diff --git a/bower.json b/bower.json index db32fd3c1..a6be135a8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ember", - "version": "2.11.0-beta.2", + "version": "2.12.0-canary", "license": "MIT", "homepage": "https://github.com/emberjs/ember.js", "main": [ diff --git a/component.json b/component.json index e1096c62e..23cb99902 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "ember", "repo": "components/ember", - "version": "2.11.0-beta.2", + "version": "2.12.0-canary", "license": "MIT", "homepage": "https://github.com/emberjs/ember.js", "main": "ember.debug.js", diff --git a/composer.json b/composer.json index 73f8310a9..88478eefe 100644 --- a/composer.json +++ b/composer.json @@ -25,5 +25,5 @@ } } }, - "version": "2.11.0-beta.2" + "version": "2.12.0-canary" } diff --git a/ember-runtime.js b/ember-runtime.js index 815220803..0cd7e89b5 100644 --- a/ember-runtime.js +++ b/ember-runtime.js @@ -1,15 +1,16 @@ ;(function() { /*! * @overview Ember - JavaScript Application Framework - * @copyright Copyright 2011-2016 Tilde Inc. and contributors + * @copyright Copyright 2011-2017 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.12.0-canary */ var enifed, requireModule, Ember; +var mainContext = this; // Used in ember-environment/lib/global.js (function() { var isNode = typeof window === 'undefined' && @@ -1187,13 +1188,20 @@ Object.defineProperty(exports, '__esModule', { value: true }); }); enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) { + /* globals Proxy */ 'use strict'; + var _Container$prototype; + exports.default = Container; exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations; var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE'); + var FACTORY_FOR = _emberUtils.symbol('FACTORY_FOR'); + exports.FACTORY_FOR = FACTORY_FOR; + var LOOKUP_FACTORY = _emberUtils.symbol('LOOKUP_FACTORY'); + exports.LOOKUP_FACTORY = LOOKUP_FACTORY; /** A container used to instantiate and cache objects. @@ -1219,7 +1227,7 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e this.isDestroyed = false; } - Container.prototype = { + Container.prototype = (_Container$prototype = { /** @private @property owner @@ -1304,57 +1312,150 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e */ lookupFactory: function (fullName, options) { _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); - return factoryFor(this, this.registry.normalize(fullName), options); - }, + _emberMetal.deprecate('Using "_lookupFactory" is deprecated. Please use container.factoryFor instead.', !_emberMetal.isFeatureEnabled('ember-factory-for'), { id: 'container-lookupFactory', until: '2.13.0', url: 'TODO' }); + + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + } + + }, _Container$prototype[LOOKUP_FACTORY] = function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + }, _Container$prototype[FACTORY_FOR] = function (fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + if (_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + if (_emberMetal.isFeatureEnabled('ember-factory-for')) { + return this.factoryFor(fullName, options); + } else { + /* This throws in case of a poorly designed build */ + throw new Error('If ember-no-double-extend is enabled, ember-factory-for must also be enabled'); + } + } + var factory = this[LOOKUP_FACTORY](fullName, options); + if (factory === undefined) { + return; + } + var manager = new DeprecatedFactoryManager(this, factory, fullName); + + _emberMetal.runInDebug(function () { + manager = wrapManagerInDeprecationProxy(manager); + }); + + return manager; + }, _Container$prototype.destroy = function () { + eachDestroyable(this, function (item) { + if (item.destroy) { + item.destroy(); + } + }); + + this.isDestroyed = true; + }, _Container$prototype.reset = function (fullName) { + if (arguments.length > 0) { + resetMember(this, this.registry.normalize(fullName)); + } else { + resetCache(this); + } + }, _Container$prototype.ownerInjection = function () { + var _ref; + + return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; + }, _Container$prototype); + + /* + * Wrap a factory manager in a proxy which will not permit properties to be + * set on the manager. + */ + function wrapManagerInDeprecationProxy(manager) { + if (_emberUtils.HAS_NATIVE_PROXY) { + var _ret = (function () { + var validator = { + get: function (obj, prop) { + if (prop !== 'class' && prop !== 'create') { + throw new Error('You attempted to access "' + prop + '" on a factory manager created by container#factoryFor. "' + prop + '" is not a member of a factory manager."'); + } + + return obj[prop]; + }, + set: function (obj, prop, value) { + throw new Error('You attempted to set "' + prop + '" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.'); + } + }; + + // Note: + // We have to proxy access to the manager here so that private property + // access doesn't cause the above errors to occur. + var m = manager; + var proxiedManager = { + class: m.class, + create: function (props) { + return m.create(props); + } + }; + + return { + v: new Proxy(proxiedManager, validator) + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } + + return manager; + } + + if (_emberMetal.isFeatureEnabled('ember-factory-for')) { /** - A depth first traversal, destroying the container, its descendant containers and all - their managed objects. - @private - @method destroy + Given a fullName, return the corresponding factory. The consumer of the factory + is responsible for the destruction of any factory instances, as there is no + way for the container to ensure instances are destroyed when it itself is + destroyed. + @public + @method factoryFor + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} */ - destroy: function () { - eachDestroyable(this, function (item) { - if (item.destroy) { - item.destroy(); + Container.prototype.factoryFor = function _factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var normalizedName = this.registry.normalize(fullName); + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(normalizedName)); + + if (options.source) { + normalizedName = this.registry.expandLocalLookup(fullName, options); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!normalizedName) { + return; } - }); + } - this.isDestroyed = true; - }, + var factory = this.registry.resolve(normalizedName); - /** - Clear either the entire cache or just the cache for a particular key. - @private - @method reset - @param {String} fullName optional key to reset; if missing, resets everything - */ - reset: function (fullName) { - if (arguments.length > 0) { - resetMember(this, this.registry.normalize(fullName)); - } else { - resetCache(this); + if (factory === undefined) { + return; } - }, - /** - Returns an object that can be used to provide an owner to a - manually created instance. - @private - @method ownerInjection - @returns { Object } - */ - ownerInjection: function () { - var _ref; + var manager = new FactoryManager(this, factory, fullName, normalizedName); - return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; - } - }; + _emberMetal.runInDebug(function () { + manager = wrapManagerInDeprecationProxy(manager); + }); + + return manager; + }; + } function isSingleton(container, fullName) { return container.registry.getOption(fullName, 'singleton') !== false; } + function shouldInstantiate(container, fullName) { + return container.registry.getOption(fullName, 'instantiate') !== false; + } + function lookup(container, fullName) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; @@ -1371,17 +1472,76 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e return container.cache[fullName]; } - var value = instantiate(container, fullName); + if (_emberMetal.isFeatureEnabled('ember-factory-for')) { + return instantiateFactory(container, fullName, options); + } else { + var factory = deprecatedFactoryFor(container, fullName); + var value = instantiate(factory, {}, container, fullName); - if (value === undefined) { + if (value === undefined) { + return; + } + + if (isSingleton(container, fullName) && options.singleton !== false) { + container.cache[fullName] = value; + } + + return value; + } + } + + function isSingletonClass(container, fullName, _ref2) { + var instantiate = _ref2.instantiate; + var singleton = _ref2.singleton; + + return singleton !== false && isSingleton(container, fullName) && !instantiate && !shouldInstantiate(container, fullName); + } + + function isSingletonInstance(container, fullName, _ref3) { + var instantiate = _ref3.instantiate; + var singleton = _ref3.singleton; + + return singleton !== false && isSingleton(container, fullName) && instantiate !== false && shouldInstantiate(container, fullName); + } + + function isFactoryClass(container, fullname, _ref4) { + var instantiate = _ref4.instantiate; + var singleton = _ref4.singleton; + + return (singleton === false || !isSingleton(container, fullname)) && instantiate === false && !shouldInstantiate(container, fullname); + } + + function isFactoryInstance(container, fullName, _ref5) { + var instantiate = _ref5.instantiate; + var singleton = _ref5.singleton; + + return (singleton !== false || isSingleton(container, fullName)) && instantiate !== false && shouldInstantiate(container, fullName); + } + + function instantiateFactory(container, fullName, options) { + var factoryManager = container[FACTORY_FOR](fullName); + + if (factoryManager === undefined) { return; } - if (isSingleton(container, fullName) && options.singleton !== false) { - container.cache[fullName] = value; + // SomeClass { singleton: true, instantiate: true } | { singleton: true } | { instantiate: true } | {} + // By default majority of objects fall into this case + if (isSingletonInstance(container, fullName, options)) { + return container.cache[fullName] = factoryManager.create(); } - return value; + // SomeClass { singleton: false, instantiate: true } + if (isFactoryInstance(container, fullName, options)) { + return factoryManager.create(); + } + + // SomeClass { singleton: true, instantiate: false } | { instantiate: false } | { singleton: false, instantiation: false } + if (isSingletonClass(container, fullName, options) || isFactoryClass(container, fullName, options)) { + return factoryManager.class; + } + + throw new Error('Could not create factory'); } function markInjectionsAsDynamic(injections) { @@ -1393,41 +1553,46 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e } function buildInjections() /* container, ...injections */{ + var _arguments = arguments; + var hash = {}; if (arguments.length > 1) { - var container = arguments[0]; - var injections = []; - var injection = undefined; + (function () { + var container = _arguments[0]; + var injections = []; + var injection = undefined; - for (var i = 1; i < arguments.length; i++) { - if (arguments[i]) { - injections = injections.concat(arguments[i]); + for (var i = 1; i < _arguments.length; i++) { + if (_arguments[i]) { + injections = injections.concat(_arguments[i]); + } } - } - container.registry.validateInjections(injections); + _emberMetal.runInDebug(function () { + container.registry.validateInjections(injections); + }); - for (var i = 0; i < injections.length; i++) { - injection = injections[i]; - hash[injection.property] = lookup(container, injection.fullName); - if (!isSingleton(container, injection.fullName)) { - markInjectionsAsDynamic(hash); + for (var i = 0; i < injections.length; i++) { + injection = injections[i]; + hash[injection.property] = lookup(container, injection.fullName); + if (!isSingleton(container, injection.fullName)) { + markInjectionsAsDynamic(hash); + } } - } + })(); } return hash; } - function factoryFor(container, fullName) { + function deprecatedFactoryFor(container, fullName) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; var registry = container.registry; if (options.source) { fullName = registry.expandLocalLookup(fullName, options); - // if expandLocalLookup returns falsey, we do not support local lookup if (!fullName) { return; @@ -1491,22 +1656,12 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e return injections; } - function factoryInjectionsFor(container, fullName) { - var registry = container.registry; - var splitName = fullName.split(':'); - var type = splitName[0]; - - var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); - factoryInjections._debugContainerKey = fullName; - - return factoryInjections; - } - - function instantiate(container, fullName) { - var factory = factoryFor(container, fullName); + function instantiate(factory, props, container, fullName) { var lazyInjections = undefined, validationCache = undefined; + props = props || {}; + if (container.registry.getOption(fullName, 'instantiate') === false) { return factory; } @@ -1534,7 +1689,7 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e if (typeof factory.extend === 'function') { // assume the factory was extendable and is already injected - obj = factory.create(); + obj = factory.create(props); } else { // assume the factory was extendable // to create time injections @@ -1546,7 +1701,7 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e // This "fake" container will be replaced after instantiation with a // property that raises deprecations every time it is accessed. injections.container = container._fakeContainerToInject; - obj = factory.create(injections); + obj = factory.create(_emberUtils.assign({}, injections, props)); // TODO - remove when Ember reaches v3.0.0 if (!Object.isFrozen(obj) && 'container' in obj) { @@ -1558,6 +1713,17 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e } } + function factoryInjectionsFor(container, fullName) { + var registry = container.registry; + var splitName = fullName.split(':'); + var type = splitName[0]; + + var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); + factoryInjections._debugContainerKey = fullName; + + return factoryInjections; + } + // TODO - remove when Ember reaches v3.0.0 function injectDeprecatedContainer(object, container) { Object.defineProperty(object, 'container', { @@ -1640,7 +1806,98 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e return container[containerProperty].apply(container, arguments); }; } + + var DeprecatedFactoryManager = (function () { + function DeprecatedFactoryManager(container, factory, fullName) { + this.container = container; + this.class = factory; + this.fullName = fullName; + } + + DeprecatedFactoryManager.prototype.create = function create() { + var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + return instantiate(this.class, props, this.container, this.fullName); + }; + + return DeprecatedFactoryManager; + })(); + + var FactoryManager = (function () { + function FactoryManager(container, factory, fullName, normalizedName) { + this.container = container; + this.class = factory; + this.fullName = fullName; + this.normalizedName = normalizedName; + } + + FactoryManager.prototype.create = function create() { + var _this = this; + + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + var injections = injectionsFor(this.container, this.normalizedName); + var props = _emberUtils.assign({}, injections, options); + + props[_emberUtils.NAME_KEY] = this.container.registry.makeToString(this.class, this.fullName); + + _emberMetal.runInDebug(function () { + var lazyInjections = undefined; + var validationCache = _this.container.validationCache; + // Ensure that all lazy injections are valid at instantiation time + if (!validationCache[_this.fullName] && _this.class && typeof _this.class._lazyInjections === 'function') { + lazyInjections = _this.class._lazyInjections(); + lazyInjections = _this.container.registry.normalizeInjectionsHash(lazyInjections); + + _this.container.registry.validateInjections(lazyInjections); + } + + validationCache[_this.fullName] = true; + }); + + if (!this.class.create) { + throw new Error('Failed to create an instance of \'' + this.normalizedName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); + } + + if (this.class.prototype) { + injectDeprecatedContainer(this.class.prototype, this.container); + } + + return this.class.create(props); + }; + + return FactoryManager; + })(); }); + +/* + * This internal version of factoryFor swaps between the public API for + * factoryFor (class is the registered class) and a transition implementation + * (class is the double-extended class). It is *not* the public API version + * of factoryFor, which always returns the registered class. + */ + +/** + A depth first traversal, destroying the container, its descendant containers and all + their managed objects. + @private + @method destroy + */ + +/** + Clear either the entire cache or just the cache for a particular key. + @private + @method reset + @param {String} fullName optional key to reset; if missing, resets everything + */ + +/** + Returns an object that can be used to provide an owner to a + manually created instance. + @private + @method ownerInjection + @returns { Object } +*/ enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) { /* Public API for the container is still in flux. @@ -1655,6 +1912,8 @@ enifed('container/index', ['exports', 'container/registry', 'container/container exports.privatize = _containerRegistry.privatize; exports.Container = _containerContainer.default; exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations; + exports.FACTORY_FOR = _containerContainer.FACTORY_FOR; + exports.LOOKUP_FACTORY = _containerContainer.LOOKUP_FACTORY; }); enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) { 'use strict'; @@ -2288,9 +2547,7 @@ enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'containe for (var i = 0; i < injections.length; i++) { fullName = injections[i].fullName; - if (!this.has(fullName)) { - throw new Error('Attempting to inject an unknown injection: \'' + fullName + '\''); - } + _emberMetal.assert('Attempting to inject an unknown injection: \'' + fullName + '\'', this.has(fullName)); } }, @@ -2783,70 +3040,80 @@ enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'emb 'use strict'; exports.default = alias; - exports.AliasedProperty = AliasedProperty; + + var CONSUMED = {}; function alias(altKey) { return new AliasedProperty(altKey); } - function AliasedProperty(altKey) { - this.isDescriptor = true; - this.altKey = altKey; - this._dependentKeys = [altKey]; - } - - AliasedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); + var AliasedProperty = (function (_Descriptor) { + babelHelpers.inherits(AliasedProperty, _Descriptor); - AliasedProperty.prototype.setup = function (obj, keyName) { - _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName); - var meta = _emberMetalMeta.meta(obj); - if (meta.peekWatching(keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + function AliasedProperty(altKey) { + _Descriptor.call(this); + this.isDescriptor = true; + this.altKey = altKey; + this._dependentKeys = [altKey]; } - }; - AliasedProperty.prototype._addDependentKeyIfMissing = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (!meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; + AliasedProperty.prototype.setup = function setup(obj, keyName) { + _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName); + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } + }; - AliasedProperty.prototype._removeDependentKeyIfAdded = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; + AliasedProperty.prototype.teardown = function teardown(obj, keyName) { + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + } + }; + + AliasedProperty.prototype.willWatch = function willWatch(obj, keyName) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); + }; - AliasedProperty.prototype.willWatch = AliasedProperty.prototype._addDependentKeyIfMissing; - AliasedProperty.prototype.didUnwatch = AliasedProperty.prototype._removeDependentKeyIfAdded; - AliasedProperty.prototype.teardown = AliasedProperty.prototype._removeDependentKeyIfAdded; + AliasedProperty.prototype.didUnwatch = function didUnwatch(obj, keyName) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); + }; - AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) { - this._addDependentKeyIfMissing(obj, keyName); + AliasedProperty.prototype.get = function get(obj, keyName) { + var ret = _emberMetalProperty_get.get(obj, this.altKey); + var meta = _emberMetalMeta.meta(obj); + var cache = meta.writableCache(); + if (cache[keyName] !== CONSUMED) { + cache[keyName] = CONSUMED; + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } + return ret; + }; - return _emberMetalProperty_get.get(obj, this.altKey); - }; + AliasedProperty.prototype.set = function set(obj, keyName, value) { + return _emberMetalProperty_set.set(obj, this.altKey, value); + }; - AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) { - return _emberMetalProperty_set.set(obj, this.altKey, value); - }; + AliasedProperty.prototype.readOnly = function readOnly() { + this.set = AliasedProperty_readOnlySet; + return this; + }; - AliasedProperty.prototype.readOnly = function () { - this.set = AliasedProperty_readOnlySet; - return this; - }; + AliasedProperty.prototype.oneWay = function oneWay() { + this.set = AliasedProperty_oneWaySet; + return this; + }; + + return AliasedProperty; + })(_emberMetalProperties.Descriptor); + + exports.AliasedProperty = AliasedProperty; function AliasedProperty_readOnlySet(obj, keyName, value) { throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); } - AliasedProperty.prototype.oneWay = function () { - this.set = AliasedProperty_oneWaySet; - return this; - }; - function AliasedProperty_oneWaySet(obj, keyName, value) { _emberMetalProperties.defineProperty(obj, keyName, null); return _emberMetalProperty_set.set(obj, keyName, value); @@ -2870,41 +3137,42 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember // BINDING // - function Binding(toPath, fromPath) { - // Configuration - this._from = fromPath; - this._to = toPath; - this._oneWay = undefined; + var Binding = (function () { + function Binding(toPath, fromPath) { + // Configuration + this._from = fromPath; + this._to = toPath; + this._oneWay = undefined; - // State - this._direction = undefined; - this._readyToSync = undefined; - this._fromObj = undefined; - this._fromPath = undefined; - this._toObj = undefined; - } + // State + this._direction = undefined; + this._readyToSync = undefined; + this._fromObj = undefined; + this._fromPath = undefined; + this._toObj = undefined; + } - /** - @class Binding - @namespace Ember - @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding - @public - */ + /** + @class Binding + @namespace Ember + @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding + @public + */ - Binding.prototype = { /** This copies the Binding so it can be connected to another object. @method copy @return {Ember.Binding} `this` @public */ - copy: function () { + + Binding.prototype.copy = function copy() { var copy = new Binding(this._to, this._from); if (this._oneWay) { copy._oneWay = true; } return copy; - }, + }; // .......................................................... // CONFIG @@ -2922,10 +3190,11 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember @return {Ember.Binding} `this` @public */ - from: function (path) { + + Binding.prototype.from = function from(path) { this._from = path; return this; - }, + }; /** This will set the `to` property path to the specified value. It will not @@ -2939,10 +3208,11 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember @return {Ember.Binding} `this` @public */ - to: function (path) { + + Binding.prototype.to = function to(path) { this._to = path; return this; - }, + }; /** Configures the binding as one way. A one-way binding will relay changes @@ -2953,20 +3223,22 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember @return {Ember.Binding} `this` @public */ - oneWay: function () { + + Binding.prototype.oneWay = function oneWay() { this._oneWay = true; return this; - }, + }; /** @method toString @return {String} string representation of binding @public */ - toString: function () { + + Binding.prototype.toString = function toString() { var oneWay = this._oneWay ? '[oneWay]' : ''; return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; - }, + }; // .......................................................... // CONNECT AND SYNC @@ -2981,7 +3253,8 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember @return {Ember.Binding} `this` @public */ - connect: function (obj) { + + Binding.prototype.connect = function connect(obj) { _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.connect()', !!obj); var fromObj = undefined, @@ -3025,7 +3298,7 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember this._toObj = obj; return this; - }, + }; /** Disconnects the binding instance. Changes will no longer be relayed. You @@ -3034,7 +3307,8 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember @return {Ember.Binding} `this` @public */ - disconnect: function () { + + Binding.prototype.disconnect = function disconnect() { _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); // Remove an observer on the object so we're no longer notified of @@ -3048,23 +3322,25 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember this._readyToSync = false; // Disable scheduled syncs... return this; - }, + }; // .......................................................... // PRIVATE // /* Called when the from side changes. */ - fromDidChange: function (target) { + + Binding.prototype.fromDidChange = function fromDidChange(target) { this._scheduleSync('fwd'); - }, + }; /* Called when the to side changes. */ - toDidChange: function (target) { + + Binding.prototype.toDidChange = function toDidChange(target) { this._scheduleSync('back'); - }, + }; - _scheduleSync: function (dir) { + Binding.prototype._scheduleSync = function _scheduleSync(dir) { var existingDir = this._direction; // If we haven't scheduled the binding yet, schedule it. @@ -3078,9 +3354,11 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember if (existingDir === 'back' && dir === 'fwd') { this._direction = 'fwd'; } - }, + }; + + Binding.prototype._sync = function _sync() { + var _this = this; - _sync: function () { var log = _emberEnvironment.ENV.LOG_BINDINGS; var toObj = this._toObj; @@ -3101,30 +3379,35 @@ enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember // If we're synchronizing from the remote object... if (direction === 'fwd') { - var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); - if (log) { - _emberConsole.default.log(' ', this.toString(), '->', fromValue, fromObj); - } - if (this._oneWay) { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - } else { - _emberMetalObserver._suspendObserver(toObj, this._to, this, 'toDidChange', function () { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - }); - } - // If we're synchronizing *to* the remote object. - } else if (direction === 'back') { - var toValue = _emberMetalProperty_get.get(toObj, this._to); + (function () { + var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); if (log) { - _emberConsole.default.log(' ', this.toString(), '<-', toValue, toObj); + _emberConsole.default.log(' ', _this.toString(), '->', fromValue, fromObj); } - _emberMetalObserver._suspendObserver(fromObj, fromPath, this, 'fromDidChange', function () { - _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); - }); + if (_this._oneWay) { + _emberMetalProperty_set.trySet(toObj, _this._to, fromValue); + } else { + _emberMetalObserver._suspendObserver(toObj, _this._to, _this, 'toDidChange', function () { + _emberMetalProperty_set.trySet(toObj, this._to, fromValue); + }); + } + // If we're synchronizing *to* the remote object. + })(); + } else if (direction === 'back') { + (function () { + var toValue = _emberMetalProperty_get.get(toObj, _this._to); + if (log) { + _emberConsole.default.log(' ', _this.toString(), '<-', toValue, toObj); + } + _emberMetalObserver._suspendObserver(fromObj, fromPath, _this, 'fromDidChange', function () { + _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); + }); + })(); } - } + }; - }; + return Binding; + })(); function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; @@ -3413,7 +3696,7 @@ enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], func return DefaultStore; })(); }); -enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalWatch_path) { +enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/computed', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalComputed, _emberMetalWatch_path) { 'use strict'; exports.finishChains = finishChains; @@ -3432,24 +3715,24 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); } - function ChainWatchers() { - // chain nodes that reference a key in this obj by key - // we only create ChainWatchers when we are going to add them - // so create this upfront - this.chains = new _emberUtils.EmptyObject(); - } + var ChainWatchers = (function () { + function ChainWatchers() { + // chain nodes that reference a key in this obj by key + // we only create ChainWatchers when we are going to add them + // so create this upfront + this.chains = new _emberUtils.EmptyObject(); + } - ChainWatchers.prototype = { - add: function (key, node) { + ChainWatchers.prototype.add = function add(key, node) { var nodes = this.chains[key]; if (nodes === undefined) { this.chains[key] = [node]; } else { nodes.push(node); } - }, + }; - remove: function (key, node) { + ChainWatchers.prototype.remove = function remove(key, node) { var nodes = this.chains[key]; if (nodes) { for (var i = 0; i < nodes.length; i++) { @@ -3459,9 +3742,9 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge } } } - }, + }; - has: function (key, node) { + ChainWatchers.prototype.has = function has(key, node) { var nodes = this.chains[key]; if (nodes) { for (var i = 0; i < nodes.length; i++) { @@ -3471,24 +3754,25 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge } } return false; - }, + }; - revalidateAll: function () { + ChainWatchers.prototype.revalidateAll = function revalidateAll() { for (var key in this.chains) { this.notify(key, true, undefined); } - }, + }; - revalidate: function (key) { + ChainWatchers.prototype.revalidate = function revalidate(key) { this.notify(key, true, undefined); - }, + }; // key: the string key that is part of a path changed // revalidate: boolean; the chains that are watching this value should revalidate // callback: function that will be called with the object and path that // will be/are invalidated by this key change, depending on // whether the revalidate flag is passed - notify: function (key, revalidate, callback) { + + ChainWatchers.prototype.notify = function notify(key, revalidate, callback) { var nodes = this.chains[key]; if (nodes === undefined || nodes.length === 0) { return; @@ -3514,8 +3798,10 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge var path = affected[i + 1]; callback(obj, path); } - } - }; + }; + + return ChainWatchers; + })(); function makeChainWatcher() { return new ChainWatchers(); @@ -3549,71 +3835,48 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge // A ChainNode watches a single key on an object. If you provide a starting // value for the key then the node won't actually watch it. For a root node // pass null for parent and key and object for value. - function ChainNode(parent, key, value) { - this._parent = parent; - this._key = key; - // _watching is true when calling get(this._parent, this._key) will - // return the value of this node. - // - // It is false for the root of a chain (because we have no parent) - // and for global paths (because the parent node is the object with - // the observer on it) - this._watching = value === undefined; - - this._chains = undefined; - this._object = undefined; - this.count = 0; + var ChainNode = (function () { + function ChainNode(parent, key, value) { + this._parent = parent; + this._key = key; - this._value = value; - this._paths = {}; - if (this._watching) { - var obj = parent.value(); - - if (!isObject(obj)) { - return; - } + // _watching is true when calling get(this._parent, this._key) will + // return the value of this node. + // + // It is false for the root of a chain (because we have no parent) + // and for global paths (because the parent node is the object with + // the observer on it) + this._watching = value === undefined; - this._object = obj; + this._chains = undefined; + this._object = undefined; + this.count = 0; - addChainWatcher(this._object, this._key, this); - } - } - - function lazyGet(obj, key) { - if (!isObject(obj)) { - return; - } + this._value = value; + this._paths = {}; + if (this._watching) { + var obj = parent.value(); - var meta = _emberMetalMeta.peekMeta(obj); + if (!isObject(obj)) { + return; + } - // check if object meant only to be a prototype - if (meta && meta.proto === obj) { - return; - } + this._object = obj; - // Use `get` if the return value is an EachProxy or an uncacheable value. - if (isVolatile(obj[key])) { - return _emberMetalProperty_get.get(obj, key); - // Otherwise attempt to get the cached value of the computed property - } else { - var cache = meta.readableCache(); - if (cache && key in cache) { - return cache[key]; - } + addChainWatcher(this._object, this._key, this); } - } + } - ChainNode.prototype = { - value: function () { + ChainNode.prototype.value = function value() { if (this._value === undefined && this._watching) { var obj = this._parent.value(); this._value = lazyGet(obj, this._key); } return this._value; - }, + }; - destroy: function () { + ChainNode.prototype.destroy = function destroy() { if (this._watching) { var obj = this._object; if (obj) { @@ -3621,10 +3884,11 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge } this._watching = false; // so future calls do nothing } - }, + }; // copies a top level object only - copy: function (obj) { + + ChainNode.prototype.copy = function copy(obj) { var ret = new ChainNode(null, null, obj); var paths = this._paths; var path = undefined; @@ -3637,11 +3901,12 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge ret.add(path); } return ret; - }, + }; // called on the root node of a chain to setup watchers on the specified // path. - add: function (path) { + + ChainNode.prototype.add = function add(path) { var paths = this._paths; paths[path] = (paths[path] || 0) + 1; @@ -3649,11 +3914,12 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge var tail = path.slice(key.length + 1); this.chain(key, tail); - }, + }; // called on the root node of a chain to teardown watcher on the specified // path - remove: function (path) { + + ChainNode.prototype.remove = function remove(path) { var paths = this._paths; if (paths[path] > 0) { paths[path]--; @@ -3663,9 +3929,9 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge var tail = path.slice(key.length + 1); this.unchain(key, tail); - }, + }; - chain: function (key, path) { + ChainNode.prototype.chain = function chain(key, path) { var chains = this._chains; var node = undefined; if (chains === undefined) { @@ -3686,9 +3952,9 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge path = path.slice(key.length + 1); node.chain(key, path); } - }, + }; - unchain: function (key, path) { + ChainNode.prototype.unchain = function unchain(key, path) { var chains = this._chains; var node = chains[key]; @@ -3705,9 +3971,9 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge chains[node._key] = undefined; node.destroy(); } - }, + }; - notify: function (revalidate, affected) { + ChainNode.prototype.notify = function notify(revalidate, affected) { if (revalidate && this._watching) { var parentValue = this._parent.value(); @@ -3741,9 +4007,9 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge if (affected && this._parent) { this._parent.populateAffected(this._key, 1, affected); } - }, + }; - populateAffected: function (path, depth, affected) { + ChainNode.prototype.populateAffected = function populateAffected(path, depth, affected) { if (this._key) { path = this._key + '.' + path; } @@ -3755,8 +4021,34 @@ enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_ge affected.push(this.value(), path); } } + }; + + return ChainNode; + })(); + + function lazyGet(obj, key) { + if (!isObject(obj)) { + return; + } + + var meta = _emberMetalMeta.peekMeta(obj); + + // check if object meant only to be a prototype + if (meta && meta.proto === obj) { + return; } - }; + + // Use `get` if the return value is an EachProxy or an uncacheable value. + if (isVolatile(obj[key])) { + return _emberMetalProperty_get.get(obj, key); + // Otherwise attempt to get the cached value of the computed property + } else { + var cache = meta.readableCache(); + if (cache) { + return _emberMetalComputed.cacheFor.get(cache, key); + } + } + } function finishChains(obj) { // We only create meta if we really have to @@ -4260,8 +4552,8 @@ enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', ' this.setProperties({ firstName, lastName }); return value; } - }); - }) + }) + }); let client = Person.create(); client.get('firstName'); // 'Betty' @@ -4618,31 +4910,37 @@ enifed("ember-metal/error", ["exports"], function (exports) { */ "use strict"; - exports.default = EmberError; + var EmberError = (function (_Error) { + babelHelpers.inherits(EmberError, _Error); - function EmberError(message) { - if (!(this instanceof EmberError)) { - return new EmberError(message); - } + function EmberError(message) { + _Error.call(this); - var error = Error.call(this, message); + if (!(this instanceof EmberError)) { + return new EmberError(message); + } - if (Error.captureStackTrace) { - Error.captureStackTrace(this, EmberError); - } else { - this.stack = error.stack; + var error = Error.call(this, message); + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, EmberError); + } else { + this.stack = error.stack; + } + + this.description = error.description; + this.fileName = error.fileName; + this.lineNumber = error.lineNumber; + this.message = error.message; + this.name = error.name; + this.number = error.number; + this.code = error.code; } - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message; - this.name = error.name; - this.number = error.number; - this.code = error.code; - } + return EmberError; + })(Error); - EmberError.prototype = Object.create(Error.prototype); + exports.default = EmberError; }); enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { 'use strict'; @@ -4657,7 +4955,7 @@ enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/te var stack = error.stack; var message = error.message; - if (stack && stack.indexOf(message) === -1) { + if (stack && !stack.includes(message)) { stack = message + '\n' + stack; } @@ -5420,6 +5718,9 @@ enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/ InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; }); enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { + /* eslint no-console:off */ + /* global console */ + 'use strict'; exports.instrument = instrument; @@ -5556,8 +5857,8 @@ enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-me result = payload; } finally { finalizer(); - return result; } + return result; } function NOOP() {} @@ -5877,8 +6178,6 @@ enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (export enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { 'use strict'; - exports.Libraries = Libraries; - /** Helper class that allows you to register your library with Ember. @@ -5889,10 +6188,20 @@ enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/fe @private */ - function Libraries() { - this._registry = []; - this._coreLibIndex = 0; - } + var Libraries = (function () { + function Libraries() { + this._registry = []; + this._coreLibIndex = 0; + } + + Libraries.prototype.isRegistered = function isRegistered(name) { + return !!this._getLibraryByName(name); + }; + + return Libraries; + })(); + + exports.Libraries = Libraries; Libraries.prototype = { constructor: Libraries, @@ -6474,12 +6783,11 @@ enifed('ember-metal/merge', ['exports'], function (exports) { return original; } }); -enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains) { +enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains', 'require'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains, _require) { 'no use strict'; // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - exports.Meta = Meta; exports.deleteMeta = deleteMeta; exports.meta = meta; @@ -6539,145 +6847,290 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) { members.lastRendered = ownMap; - members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds + if (_require.has('ember-debug')) { + //https://github.com/emberjs/ember.js/issues/14732 + members.lastRenderedReferenceMap = ownMap; + members.lastRenderedTemplateMap = ownMap; + } } var memberNames = Object.keys(members); var META_FIELD = '__ember_meta__'; - function Meta(obj, parentMeta) { - _emberMetalDebug.runInDebug(function () { - return counters.metaInstantiated++; - }); + var Meta = (function () { + function Meta(obj, parentMeta) { + var _this = this; - this._cache = undefined; - this._weak = undefined; - this._watching = undefined; - this._mixins = undefined; - this._bindings = undefined; - this._values = undefined; - this._deps = undefined; - this._chainWatchers = undefined; - this._chains = undefined; - this._tag = undefined; - this._tags = undefined; - - // initial value for all flags right now is false - // see FLAGS const for detailed list of flags used - this._flags = 0; - - // used only internally - this.source = obj; - - // when meta(obj).proto === obj, the object is intended to be only a - // prototype and doesn't need to actually be observable itself - this.proto = undefined; - - // The next meta in our inheritance chain. We (will) track this - // explicitly instead of using prototypical inheritance because we - // have detailed knowledge of how each property should really be - // inherited, and we can optimize it much better than JS runtimes. - this.parent = parentMeta; + _emberMetalDebug.runInDebug(function () { + return counters.metaInstantiated++; + }); - if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) { - this._lastRendered = undefined; - this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds + this._cache = undefined; + this._weak = undefined; + this._watching = undefined; + this._mixins = undefined; + this._bindings = undefined; + this._values = undefined; + this._deps = undefined; + this._chainWatchers = undefined; + this._chains = undefined; + this._tag = undefined; + this._tags = undefined; + + // initial value for all flags right now is false + // see FLAGS const for detailed list of flags used + this._flags = 0; + + // used only internally + this.source = obj; + + // when meta(obj).proto === obj, the object is intended to be only a + // prototype and doesn't need to actually be observable itself + this.proto = undefined; + + // The next meta in our inheritance chain. We (will) track this + // explicitly instead of using prototypical inheritance because we + // have detailed knowledge of how each property should really be + // inherited, and we can optimize it much better than JS runtimes. + this.parent = parentMeta; + + if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) { + this._lastRendered = undefined; + _emberMetalDebug.runInDebug(function () { + _this._lastRenderedReferenceMap = undefined; + _this._lastRenderedTemplateMap = undefined; + }); + } + + this._initializeListeners(); } - this._initializeListeners(); - } + Meta.prototype.isInitialized = function isInitialized(obj) { + return this.proto !== obj; + }; - Meta.prototype.isInitialized = function (obj) { - return this.proto !== obj; - }; + Meta.prototype.destroy = function destroy() { + if (this.isMetaDestroyed()) { + return; + } - var NODE_STACK = []; + // remove chainWatchers to remove circular references that would prevent GC + var nodes = undefined, + key = undefined, + nodeObject = undefined; + var node = this.readableChains(); + if (node) { + NODE_STACK.push(node); + // process tree + while (NODE_STACK.length > 0) { + node = NODE_STACK.pop(); + // push children + nodes = node._chains; + if (nodes) { + for (key in nodes) { + if (nodes[key] !== undefined) { + NODE_STACK.push(nodes[key]); + } + } + } - Meta.prototype.destroy = function () { - if (this.isMetaDestroyed()) { - return; - } + // remove chainWatcher in node object + if (node._watching) { + nodeObject = node._object; + if (nodeObject) { + var foreignMeta = peekMeta(nodeObject); + // avoid cleaning up chain watchers when both current and + // foreign objects are being destroyed + // if both are being destroyed manual cleanup is not needed + // as they will be GC'ed and no non-destroyed references will + // be remaining + if (foreignMeta && !foreignMeta.isSourceDestroying()) { + _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); + } + } + } + } + } - // remove chainWatchers to remove circular references that would prevent GC - var node = undefined, - nodes = undefined, - key = undefined, - nodeObject = undefined; - node = this.readableChains(); - if (node) { - NODE_STACK.push(node); - // process tree - while (NODE_STACK.length > 0) { - node = NODE_STACK.pop(); - // push children - nodes = node._chains; - if (nodes) { - for (key in nodes) { - if (nodes[key] !== undefined) { - NODE_STACK.push(nodes[key]); + this.setMetaDestroyed(); + }; + + Meta.prototype.isSourceDestroying = function isSourceDestroying() { + return (this._flags & SOURCE_DESTROYING) !== 0; + }; + + Meta.prototype.setSourceDestroying = function setSourceDestroying() { + this._flags |= SOURCE_DESTROYING; + }; + + Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { + return (this._flags & SOURCE_DESTROYED) !== 0; + }; + + Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { + this._flags |= SOURCE_DESTROYED; + }; + + Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { + return (this._flags & META_DESTROYED) !== 0; + }; + + Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { + this._flags |= META_DESTROYED; + }; + + Meta.prototype.isProxy = function isProxy() { + return (this._flags & IS_PROXY) !== 0; + }; + + Meta.prototype.setProxy = function setProxy() { + this._flags |= IS_PROXY; + }; + + Meta.prototype._getOrCreateOwnMap = function _getOrCreateOwnMap(key) { + return this[key] || (this[key] = new _emberUtils.EmptyObject()); + }; + + Meta.prototype._getInherited = function _getInherited(key) { + var pointer = this; + while (pointer !== undefined) { + if (pointer[key]) { + return pointer[key]; + } + pointer = pointer.parent; + } + }; + + Meta.prototype._findInherited = function _findInherited(key, subkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var value = map[subkey]; + if (value !== undefined) { + return value; + } + } + pointer = pointer.parent; + } + }; + + // Implements a member that provides a lazily created map of maps, + // with inheritance at both levels. + + Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { + _emberMetalDebug.assert('Cannot call writeDeps after the object is destroyed.', !this.isMetaDestroyed()); + + var outerMap = this._getOrCreateOwnMap('_deps'); + var innerMap = outerMap[subkey]; + if (!innerMap) { + innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); + } + innerMap[itemkey] = value; + }; + + Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer._deps; + if (map) { + var value = map[subkey]; + if (value) { + if (value[itemkey] !== undefined) { + return value[itemkey]; } } } + pointer = pointer.parent; + } + }; + + Meta.prototype.hasDeps = function hasDeps(subkey) { + var pointer = this; + while (pointer !== undefined) { + if (pointer._deps && pointer._deps[subkey]) { + return true; + } + pointer = pointer.parent; + } + return false; + }; - // remove chainWatcher in node object - if (node._watching) { - nodeObject = node._object; - if (nodeObject) { - var foreignMeta = peekMeta(nodeObject); - // avoid cleaning up chain watchers when both current and - // foreign objects are being destroyed - // if both are being destroyed manual cleanup is not needed - // as they will be GC'ed and no non-destroyed references will - // be remaining - if (foreignMeta && !foreignMeta.isSourceDestroying()) { - _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); + Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { + return this._forEachIn('_deps', subkey, fn); + }; + + Meta.prototype._forEachIn = function _forEachIn(key, subkey, fn) { + var pointer = this; + var seen = new _emberUtils.EmptyObject(); + var calls = []; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var innerMap = map[subkey]; + if (innerMap) { + for (var innerKey in innerMap) { + if (!seen[innerKey]) { + seen[innerKey] = true; + calls.push([innerKey, innerMap[innerKey]]); + } } } } + pointer = pointer.parent; } - } + for (var i = 0; i < calls.length; i++) { + var _calls$i = calls[i]; + var innerKey = _calls$i[0]; + var value = _calls$i[1]; - this.setMetaDestroyed(); - }; + fn(innerKey, value); + } + }; - for (var _name in _emberMetalMeta_listeners.protoMethods) { - Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; - } - memberNames.forEach(function (name) { - return members[name](name, Meta); - }); + Meta.prototype.readInheritedValue = function readInheritedValue(key, subkey) { + var internalKey = '_' + key; - Meta.prototype.isSourceDestroying = function isSourceDestroying() { - return (this._flags & SOURCE_DESTROYING) !== 0; - }; + var pointer = this; - Meta.prototype.setSourceDestroying = function setSourceDestroying() { - this._flags |= SOURCE_DESTROYING; - }; + while (pointer !== undefined) { + var map = pointer[internalKey]; + if (map) { + var value = map[subkey]; + if (value !== undefined || subkey in map) { + return map[subkey]; + } + } + pointer = pointer.parent; + } - Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { - return (this._flags & SOURCE_DESTROYED) !== 0; - }; + return UNDEFINED; + }; - Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { - this._flags |= SOURCE_DESTROYED; - }; + Meta.prototype.writeValue = function writeValue(obj, key, value) { + var descriptor = _emberUtils.lookupDescriptor(obj, key); + var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { - return (this._flags & META_DESTROYED) !== 0; - }; + if (isMandatorySetter) { + this.writeValues(key, value); + } else { + obj[key] = value; + } + }; - Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { - this._flags |= META_DESTROYED; - }; + return Meta; + })(); - Meta.prototype.isProxy = function isProxy() { - return (this._flags & IS_PROXY) !== 0; - }; + exports.Meta = Meta; - Meta.prototype.setProxy = function setProxy() { - this._flags |= IS_PROXY; - }; + var NODE_STACK = []; + + for (var _name in _emberMetalMeta_listeners.protoMethods) { + Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; + } + memberNames.forEach(function (name) { + return members[name](name, Meta); + }); // Implements a member that is a lazily created, non-inheritable // POJO. @@ -6692,14 +7145,6 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e }; } - Meta.prototype._getOrCreateOwnMap = function (key) { - var ret = this[key]; - if (!ret) { - ret = this[key] = new _emberUtils.EmptyObject(); - } - return ret; - }; - // Implements a member that is a lazily created POJO with inheritable // values. function inheritedMap(name, Meta) { @@ -6749,105 +7194,9 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e }; } - Meta.prototype._getInherited = function (key) { - var pointer = this; - while (pointer !== undefined) { - if (pointer[key]) { - return pointer[key]; - } - pointer = pointer.parent; - } - }; - - Meta.prototype._findInherited = function (key, subkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var value = map[subkey]; - if (value !== undefined) { - return value; - } - } - pointer = pointer.parent; - } - }; - var UNDEFINED = _emberUtils.symbol('undefined'); exports.UNDEFINED = UNDEFINED; - // Implements a member that provides a lazily created map of maps, - // with inheritance at both levels. - Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { - _emberMetalDebug.assert('Cannot call writeDeps after the object is destroyed.', !this.isMetaDestroyed()); - - var outerMap = this._getOrCreateOwnMap('_deps'); - var innerMap = outerMap[subkey]; - if (!innerMap) { - innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); - } - innerMap[itemkey] = value; - }; - - Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer._deps; - if (map) { - var value = map[subkey]; - if (value) { - if (value[itemkey] !== undefined) { - return value[itemkey]; - } - } - } - pointer = pointer.parent; - } - }; - - Meta.prototype.hasDeps = function hasDeps(subkey) { - var pointer = this; - while (pointer !== undefined) { - if (pointer._deps && pointer._deps[subkey]) { - return true; - } - pointer = pointer.parent; - } - return false; - }; - - Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { - return this._forEachIn('_deps', subkey, fn); - }; - - Meta.prototype._forEachIn = function (key, subkey, fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - var calls = []; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var innerMap = map[subkey]; - if (innerMap) { - for (var innerKey in innerMap) { - if (!seen[innerKey]) { - seen[innerKey] = true; - calls.push([innerKey, innerMap[innerKey]]); - } - } - } - } - pointer = pointer.parent; - } - for (var i = 0; i < calls.length; i++) { - var _calls$i = calls[i]; - var innerKey = _calls$i[0]; - var value = _calls$i[1]; - - fn(innerKey, value); - } - }; - // Implements a member that provides a non-heritable, lazily-created // object using the method you provide. function ownCustomObject(name, Meta) { @@ -6948,24 +7297,11 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e }; } - var HAS_NATIVE_WEAKMAP = (function () { - // detect if `WeakMap` is even present - var hasWeakMap = typeof WeakMap === 'function'; - if (!hasWeakMap) { - return false; - } - - var instance = new WeakMap(); - // use `Object`'s `.toString` directly to prevent us from detecting - // polyfills as native weakmaps - return Object.prototype.toString.call(instance) === '[object WeakMap]'; - })(); - var setMeta = undefined, peekMeta = undefined; // choose the one appropriate for given platform - if (HAS_NATIVE_WEAKMAP) { + if (_emberUtils.HAS_NATIVE_WEAKMAP) { (function () { var getPrototypeOf = Object.getPrototypeOf; var metaStore = new WeakMap(); @@ -7267,7 +7603,6 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb */ exports.detectBinding = detectBinding; exports.mixin = mixin; - exports.default = Mixin; exports.hasUnprocessedMixins = hasUnprocessedMixins; exports.clearUnprocessedMixins = clearUnprocessedMixins; exports.required = required; @@ -7279,7 +7614,9 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb function ROOT() {} ROOT.__hasSuper = false; - var a_slice = [].slice; + var a_slice = Array.prototype.slice; + var a_concat = Array.prototype.concat; + var isArray = Array.isArray; function isMethod(obj) { return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; @@ -7303,14 +7640,11 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb } function concatenatedMixinProperties(concatProp, props, values, base) { - var concats = undefined; - // reset before adding each new mixin to pickup concats from previous - concats = values[concatProp] || base[concatProp]; + var concats = values[concatProp] || base[concatProp]; if (props[concatProp]) { - concats = concats ? concats.concat(props[concatProp]) : props[concatProp]; + concats = concats ? a_concat.call(concats, props[concatProp]) : props[concatProp]; } - return concats; } @@ -7377,18 +7711,18 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb var baseValue = values[key] || obj[key]; var ret = undefined; - if (baseValue) { - if ('function' === typeof baseValue.concat) { + if (baseValue === null || baseValue === undefined) { + ret = _emberUtils.makeArray(value); + } else { + if (isArray(baseValue)) { if (value === null || value === undefined) { ret = baseValue; } else { - ret = baseValue.concat(value); + ret = a_concat.call(baseValue, value); } } else { - ret = _emberUtils.makeArray(baseValue).concat(value); + ret = a_concat.call(_emberUtils.makeArray(baseValue), value); } - } else { - ret = _emberUtils.makeArray(value); } _emberMetalDebug.runInDebug(function () { @@ -7407,7 +7741,7 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb var baseValue = values[key] || obj[key]; _emberMetalDebug.runInDebug(function () { - if (Array.isArray(value)) { + if (isArray(value)) { // use conditional to avoid stringifying every time _emberMetalDebug.assert('You passed in `' + JSON.stringify(value) + '` as the value for `' + key + '` but `' + key + '` cannot be an Array', false); } @@ -7734,70 +8068,97 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb @public */ - function Mixin(args, properties) { - this.properties = properties; + var Mixin = (function () { + function Mixin(args, properties) { + this.properties = properties; - var length = args && args.length; + var length = args && args.length; - if (length > 0) { - var m = new Array(length); + if (length > 0) { + var m = new Array(length); - for (var i = 0; i < length; i++) { - var x = args[i]; - if (x instanceof Mixin) { - m[i] = x; - } else { - m[i] = new Mixin(undefined, x); + for (var i = 0; i < length; i++) { + var x = args[i]; + if (x instanceof Mixin) { + m[i] = x; + } else { + m[i] = new Mixin(undefined, x); + } } - } - this.mixins = m; - } else { - this.mixins = undefined; + this.mixins = m; + } else { + this.mixins = undefined; + } + this.ownerConstructor = undefined; + this._without = undefined; + this[_emberUtils.GUID_KEY] = null; + this[_emberUtils.NAME_KEY] = null; + _emberMetalDebug.debugSeal(this); } - this.ownerConstructor = undefined; - this._without = undefined; - this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; - _emberMetalDebug.debugSeal(this); - } - Mixin._apply = applyMixin; + Mixin.applyPartial = function applyPartial(obj) { + var args = a_slice.call(arguments, 1); + return applyMixin(obj, args, true); + }; - Mixin.applyPartial = function (obj) { - var args = a_slice.call(arguments, 1); - return applyMixin(obj, args, true); - }; + /** + @method create + @static + @param arguments* + @public + */ - Mixin.finishPartial = finishPartial; + Mixin.create = function create() { + // ES6TODO: this relies on a global state? + unprocessedFlag = true; + var M = this; - var unprocessedFlag = false; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - function hasUnprocessedMixins() { - return unprocessedFlag; - } + return new M(args, undefined); + }; - function clearUnprocessedMixins() { - unprocessedFlag = false; - } + // returns the mixins currently applied to the specified object + // TODO: Make Ember.mixin - /** - @method create - @static - @param arguments* - @public - */ - Mixin.create = function () { - // ES6TODO: this relies on a global state? - unprocessedFlag = true; - var M = this; + Mixin.mixins = function mixins(obj) { + var m = _emberMetalMeta.peekMeta(obj); + var ret = []; + if (!m) { + return ret; + } + + m.forEachMixins(function (key, currentMixin) { + // skip primitive mixins since these are always anonymous + if (!currentMixin.properties) { + ret.push(currentMixin); + } + }); + + return ret; + }; + + return Mixin; + })(); + + exports.default = Mixin; + + Mixin._apply = applyMixin; + + Mixin.finishPartial = finishPartial; + + var unprocessedFlag = false; - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + function hasUnprocessedMixins() { + return unprocessedFlag; + } - return new M(args, undefined); - }; + function clearUnprocessedMixins() { + unprocessedFlag = false; + } var MixinPrototype = Mixin.prototype; @@ -7932,25 +8293,6 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb _emberMetalDebug.debugSeal(MixinPrototype); - // returns the mixins currently applied to the specified object - // TODO: Make Ember.mixin - Mixin.mixins = function (obj) { - var m = _emberMetalMeta.peekMeta(obj); - var ret = []; - if (!m) { - return ret; - } - - m.forEachMixins(function (key, currentMixin) { - // skip primitive mixins since these are always anonymous - if (!currentMixin.properties) { - ret.push(currentMixin); - } - }); - - return ret; - }; - var REQUIRED = new _emberMetalProperties.Descriptor(); REQUIRED.toString = function () { return '(Required Property)'; @@ -8154,7 +8496,6 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb } exports.Mixin = Mixin; - exports.required = required; exports.REQUIRED = REQUIRED; }); enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { @@ -8274,8 +8615,6 @@ enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/ enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { 'use strict'; - exports.default = ObserverSet; - /* this.observerSet = { [senderGuid]: { // variable name: `keySet` @@ -8295,53 +8634,59 @@ enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/event ] */ - function ObserverSet() { - this.clear(); - } + var ObserverSet = (function () { + function ObserverSet() { + this.clear(); + } - ObserverSet.prototype.add = function (sender, keyName, eventName) { - var observerSet = this.observerSet; - var observers = this.observers; - var senderGuid = _emberUtils.guidFor(sender); - var keySet = observerSet[senderGuid]; - var index = undefined; + ObserverSet.prototype.add = function add(sender, keyName, eventName) { + var observerSet = this.observerSet; + var observers = this.observers; + var senderGuid = _emberUtils.guidFor(sender); + var keySet = observerSet[senderGuid]; + var index = undefined; - 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; - }; + 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 = undefined, - observer = undefined, - sender = undefined; - this.clear(); - for (i = 0; i < observers.length; ++i) { - observer = observers[i]; - sender = observer.sender; - if (sender.isDestroying || sender.isDestroyed) { - continue; + ObserverSet.prototype.flush = function flush() { + var observers = this.observers; + var i = undefined, + observer = undefined, + sender = undefined; + this.clear(); + for (i = 0; i < observers.length; ++i) { + observer = observers[i]; + sender = observer.sender; + if (sender.isDestroying || sender.isDestroyed) { + continue; + } + _emberMetalEvents.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners); } - _emberMetalEvents.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners); - } - }; + }; - ObserverSet.prototype.clear = function () { - this.observerSet = {}; - this.observers = []; - }; + ObserverSet.prototype.clear = function clear() { + this.observerSet = {}; + this.observers = []; + }; + + return ObserverSet; + })(); + + exports.default = ObserverSet; }); enifed('ember-metal/path_cache', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) { 'use strict'; @@ -9976,7 +10321,7 @@ enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', return properties; } }); -enifed('ember-metal/tags', ['exports', 'glimmer-reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { +enifed('ember-metal/tags', ['exports', '@glimmer/reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { 'use strict'; exports.setHasViews = setHasViews; @@ -10079,29 +10424,21 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d didRender = undefined, assertNotRendered = undefined; - var raise = _emberMetalDebug.assert; - if (_emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) { - raise = function (message, test) { - _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' }); - }; - } - - var implication = undefined; - if (_emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) { - implication = 'will be removed in Ember 3.0.'; - } else if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender')) { - implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; - } - + // detect-backtracking-rerender by default is debug build only + // detect-glimmer-allow-backtracking-rerender can be enabled in custom builds if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) { (function () { var counter = 0; var inTransaction = false; var shouldReflush = undefined; + var debugStack = undefined; exports.default = runInTransaction = function (context, methodName) { shouldReflush = false; inTransaction = true; + _emberMetalDebug.runInDebug(function () { + debugStack = context.env.debugStack; + }); context[methodName](); inTransaction = false; counter++; @@ -10117,8 +10454,13 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d lastRendered[key] = counter; _emberMetalDebug.runInDebug(function () { - var lastRenderedFrom = meta.writableLastRenderedFrom(); - lastRenderedFrom[key] = reference; + var referenceMap = meta.writableLastRenderedReferenceMap(); + referenceMap[key] = reference; + + var templateMap = meta.writableLastRenderedTemplateMap(); + if (templateMap[key] === undefined) { + templateMap[key] = debugStack.peek(); + } }); }; @@ -10127,11 +10469,14 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d var lastRendered = meta.readableLastRendered(); if (lastRendered && lastRendered[key] === counter) { - raise((function () { - var ref = meta.readableLastRenderedFrom(); - var parts = []; - var lastRef = ref[key]; + _emberMetalDebug.runInDebug(function () { + var templateMap = meta.readableLastRenderedTemplateMap(); + var lastRenderedIn = templateMap[key]; + var currentlyIn = debugStack.peek(); + var referenceMap = meta.readableLastRenderedReferenceMap(); + var lastRef = referenceMap[key]; + var parts = []; var label = undefined; if (lastRef) { @@ -10140,29 +10485,29 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d lastRef = lastRef._parentReference; } - label = parts.join(); + label = parts.join('.'); } else { label = 'the same value'; } - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; - })(), false); + var message = 'You modified "' + label + '" twice on ' + object + ' in a single render. It was rendered in ' + lastRenderedIn + ' and modified in ' + currentlyIn + '. This was unreliable and slow in Ember 1.x and'; + + if (_emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) { + _emberMetalDebug.deprecate(message + ' will be removed in Ember 3.0.', false, { id: 'ember-views.render-double-modify', until: '3.0.0' }); + } else { + _emberMetalDebug.assert(message + ' is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.', false); + } + }); shouldReflush = true; } }; })(); } else { - exports.default = runInTransaction = function () { - throw new Error('Cannot call runInTransaction without Glimmer'); - }; - - exports.didRender = didRender = function () { - throw new Error('Cannot call didRender without Glimmer'); - }; - - exports.assertNotRendered = assertNotRendered = function () { - throw new Error('Cannot call assertNotRendered without Glimmer'); + // in production do nothing to detect reflushes + exports.default = runInTransaction = function (context, methodName) { + context[methodName](); + return false; }; } @@ -10686,21 +11031,22 @@ enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtim return spaceship(v.localeCompare(w), 0); case 'array': - var vLen = v.length; - var wLen = w.length; - var len = Math.min(vLen, wLen); - - for (var i = 0; i < len; i++) { - var r = compare(v[i], w[i]); - if (r !== 0) { - return r; + { + var vLen = v.length; + var wLen = w.length; + var len = Math.min(vLen, wLen); + + for (var i = 0; i < len; i++) { + var r = compare(v[i], w[i]); + if (r !== 0) { + return r; + } } - } - - // all elements are equal now - // shorter array should be ordered first - return spaceship(vLen, wLen); + // all elements are equal now + // shorter array should be ordered first + return spaceship(vLen, wLen); + } case 'instance': if (_emberRuntimeMixinsComparable.default && _emberRuntimeMixinsComparable.default.detect(v)) { return v.compare(v, w); @@ -10994,16 +11340,16 @@ enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], fun ```javascript let Hamster = Ember.Object.extend({ - napTime: Ember.computed.equal('state', 'sleepy') + satisfied: Ember.computed.equal('percentCarrotsEaten', 100) }); let hamster = Hamster.create(); - hamster.get('napTime'); // false - hamster.set('state', 'sleepy'); - hamster.get('napTime'); // true - hamster.set('state', 'hungry'); - hamster.get('napTime'); // false + hamster.get('satisfied'); // false + hamster.set('percentCarrotsEaten', 100); + hamster.get('satisfied'); // true + hamster.set('percentCarrotsEaten', 50); + hamster.get('satisfied'); // false ``` @method equal @@ -12146,7 +12492,7 @@ enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils if (activeObservers) { activeObservers.forEach(function (args) { - return _emberMetal.removeObserver.apply(null, args); + return _emberMetal.removeObserver.apply(undefined, args); }); } @@ -12159,7 +12505,7 @@ enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; var args = [_this5, path, sortPropertyDidChange]; - _emberMetal.addObserver.apply(null, args); + _emberMetal.addObserver.apply(undefined, args); return args; }); @@ -12917,7 +13263,7 @@ enifed('ember-runtime/is-equal', ['exports'], function (exports) { return a === b; } }); -enifed('ember-runtime/mixins/-proxy', ['exports', 'glimmer-reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { +enifed('ember-runtime/mixins/-proxy', ['exports', '@glimmer/reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { /** @module ember @submodule ember-runtime @@ -13461,9 +13807,7 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () { return objectAt(this, _emberMetal.get(this, 'length') - 1); }).readOnly(), _Mixin$create.contains = function (obj) { - if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) { - _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - } + _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); return this.indexOf(obj) >= 0; }, _Mixin$create.slice = function (beginIndex, endIndex) { @@ -13537,6 +13881,27 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' return arrayContentWillChange(this, startIdx, removeAmt, addAmt); }, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) { return arrayContentDidChange(this, startIdx, removeAmt, addAmt); + }, _Mixin$create.includes = function (obj, startAt) { + var len = _emberMetal.get(this, 'length'); + + if (startAt === undefined) { + startAt = 0; + } + + if (startAt < 0) { + startAt += len; + } + + for (var idx = startAt; idx < len; idx++) { + var currentObj = objectAt(this, idx); + + // SameValueZero comparison (NaN !== NaN) + if (obj === currentObj || obj !== obj && currentObj !== currentObj) { + return true; + } + } + + return false; }, _Mixin$create['@each'] = _emberMetal.computed(function () { // TODO use Symbol or add to meta if (!this.__each) { @@ -13546,55 +13911,6 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' return this.__each; }).volatile().readOnly(), _Mixin$create)); - if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) { - ArrayMixin.reopen({ - /** - Returns `true` if the passed object can be found in the array. - This method is a Polyfill for ES 2016 Array.includes. - If no `startAt` argument is given, the starting location to - search is 0. If it's negative, searches from the index of - `this.length + startAt` by asc. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, 3].includes(3, 2); // true - [1, 2, 3].includes(3, 3); // false - [1, 2, 3].includes(3, -1); // true - [1, 2, 3].includes(1, -1); // false - [1, 2, 3].includes(1, -4); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @param {Number} startAt optional starting location to search, default 0 - @return {Boolean} `true` if object is found in the array. - @public - */ - includes: function (obj, startAt) { - var len = _emberMetal.get(this, 'length'); - - if (startAt === undefined) { - startAt = 0; - } - - if (startAt < 0) { - startAt += len; - } - - for (var idx = startAt; idx < len; idx++) { - var currentObj = objectAt(this, idx); - - // SameValueZero comparison (NaN !== NaN) - if (obj === currentObj || obj !== obj && currentObj !== currentObj) { - return true; - } - } - - return false; - } - }); - } - exports.default = ArrayMixin; }); // ES6TODO: Ember.A @@ -13790,6 +14106,29 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' @public */ +/** + Returns `true` if the passed object can be found in the array. + This method is a Polyfill for ES 2016 Array.includes. + If no `startAt` argument is given, the starting location to + search is 0. If it's negative, searches from the index of + `this.length + startAt` by asc. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, 3].includes(3, 2); // true + [1, 2, 3].includes(3, 3); // false + [1, 2, 3].includes(3, -1); // true + [1, 2, 3].includes(1, -1); // false + [1, 2, 3].includes(1, -4); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @param {Number} startAt optional starting location to search, default 0 + @return {Boolean} `true` if object is found in the array. + @public +*/ + /** Returns a special object that can be used to observe individual properties on the array. Just get an equivalent property on this object and it will @@ -13849,13 +14188,15 @@ enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function ( compare: null }); }); -enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal', 'container'], function (exports, _emberMetal, _container) { /** @module ember @submodule ember-runtime */ 'use strict'; + var _containerProxyMixin; + /** ContainerProxyMixin is used to provide public access to specific container functionality. @@ -13863,7 +14204,7 @@ enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], funct @class ContainerProxyMixin @private */ - exports.default = _emberMetal.Mixin.create({ + var containerProxyMixin = (_containerProxyMixin = { /** The container stores state. @private @@ -13884,6 +14225,7 @@ enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], funct ``` @public @method ownerInjection + @since 2.3.0 @return {Object} */ ownerInjection: function () { @@ -13934,34 +14276,51 @@ enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], funct */ _lookupFactory: function (fullName, options) { return this.__container__.lookupFactory(fullName, options); - }, + } - /** - Given a name and a source path, resolve the fullName - @private - @method _resolveLocalLookupName - @param {String} fullName - @param {String} source - @return {String} - */ - _resolveLocalLookupName: function (name, source) { - return this.__container__.registry.expandLocalLookup('component:' + name, { - source: source - }); - }, + }, _containerProxyMixin[_container.FACTORY_FOR] = function () { + var _container__; - /** - @private - */ - willDestroy: function () { - this._super.apply(this, arguments); + return (_container__ = this.__container__)[_container.FACTORY_FOR].apply(_container__, arguments); + }, _containerProxyMixin[_container.LOOKUP_FACTORY] = function () { + var _container__2; - if (this.__container__) { - _emberMetal.run(this.__container__, 'destroy'); - } + return (_container__2 = this.__container__)[_container.LOOKUP_FACTORY].apply(_container__2, arguments); + }, _containerProxyMixin._resolveLocalLookupName = function (name, source) { + return this.__container__.registry.expandLocalLookup('component:' + name, { + source: source + }); + }, _containerProxyMixin.willDestroy = function () { + this._super.apply(this, arguments); + + if (this.__container__) { + _emberMetal.run(this.__container__, 'destroy'); } - }); + }, _containerProxyMixin); + + if (_emberMetal.isFeatureEnabled('ember-factory-for')) { + containerProxyMixin.factoryFor = function ContainerProxyMixin_factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + return this.__container__.factoryFor(fullName, options); + }; + } + + exports.default = _emberMetal.Mixin.create(containerProxyMixin); }); + +/** + Given a name and a source path, resolve the fullName + @private + @method _resolveLocalLookupName + @param {String} fullName + @param {String} source + @return {String} + */ + +/** + @private + */ enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) { 'use strict'; @@ -14306,9 +14665,7 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-meta @public */ contains: function (obj) { - if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) { - _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - } + _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); var found = this.find(function (item) { return item === obj; @@ -14829,14 +15186,15 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-meta @public */ without: function (value) { - if (!this.contains(value)) { + if (!this.includes(value)) { return this; // nothing to do } var ret = emberA(); this.forEach(function (k) { - if (k !== value) { + // SameValueZero comparison (NaN !== NaN) + if (!(k === value || k !== k && value !== value)) { ret[ret.length] = k; } }); @@ -15092,99 +15450,74 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-meta } return 0; }); - } - }); + }, - if (_emberMetal.isFeatureEnabled('ember-runtime-computed-uniq-by')) { - Enumerable.reopen({ - /** - Returns a new enumerable that contains only items containing a unique property value. - The default implementation returns an array regardless of the receiver type. - ```javascript - let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; - arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] - ``` - @method uniqBy - @return {Ember.Enumerable} - @public - */ - - uniqBy: function (key) { - var ret = emberA(); - var seen = new _emberUtils.EmptyObject(); - - this.forEach(function (item) { - var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); - if (!(guid in seen)) { - seen[guid] = true; - ret.push(item); - } - }); + /** + Returns a new enumerable that contains only items containing a unique property value. + The default implementation returns an array regardless of the receiver type. + ```javascript + let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; + arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] + ``` + @method uniqBy + @return {Ember.Enumerable} + @public + */ - return ret; - } - }); - } + uniqBy: function (key) { + var ret = emberA(); + var seen = new _emberUtils.EmptyObject(); - if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) { - Enumerable.reopen({ - /** - Returns `true` if the passed object can be found in the enumerable. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, undefined].includes(undefined); // true - [1, 2, null].includes(null); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in the enumerable. - @public - */ - includes: function (obj) { - _emberMetal.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1); - - var len = _emberMetal.get(this, 'length'); - var idx = undefined, - next = undefined; - var last = null; - var found = false; - - var context = popCtx(); - - for (idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); - - found = obj === next || obj !== obj && next !== next; - - last = next; + this.forEach(function (item) { + var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); + if (!(guid in seen)) { + seen[guid] = true; + ret.push(item); } + }); - next = last = null; - context = pushCtx(context); + return ret; + }, - return found; - }, + /** + Returns `true` if the passed object can be found in the enumerable. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, undefined].includes(undefined); // true + [1, 2, null].includes(null); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @return {Boolean} `true` if object is found in the enumerable. + @public + */ + includes: function (obj) { + _emberMetal.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1); - without: function (value) { - if (!this.includes(value)) { - return this; // nothing to do - } + var len = _emberMetal.get(this, 'length'); + var idx = undefined, + next = undefined; + var last = null; + var found = false; - var ret = emberA(); + var context = popCtx(); - this.forEach(function (k) { - // SameValueZero comparison (NaN !== NaN) - if (!(k === value || k !== k && value !== value)) { - ret[ret.length] = k; - } - }); + for (idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); - return ret; + found = obj === next || obj !== obj && next !== next; + + last = next; } - }); - } + + next = last = null; + context = pushCtx(context); + + return found; + } + }); exports.default = Enumerable; }); @@ -15512,9 +15845,9 @@ enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-r want to reuse an existing array without having to recreate it. ```javascript let colors = ['red', 'green', 'blue']; - color.length(); // 3 - colors.clear(); // [] - colors.length(); // 0 + colors.length; // 3 + colors.clear(); // [] + colors.length; // 0 ``` @method clear @return {Ember.Array} An empty Array. @@ -15778,13 +16111,7 @@ enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-r @public */ addObject: function (obj) { - var included = undefined; - - if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) { - included = this.includes(obj); - } else { - included = this.contains(obj); - } + var included = this.includes(obj); if (!included) { this.pushObject(obj); @@ -16041,7 +16368,7 @@ enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function ( args[_key] = arguments[_key]; } - return _emberMetal.getProperties.apply(null, [this].concat(args)); + return _emberMetal.getProperties.apply(undefined, [this].concat(args)); }, /** @@ -16197,27 +16524,24 @@ enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function ( will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. - You can also pass an optional context parameter to this method. The - context will be passed to your observer method whenever it is triggered. - Note that if you add the same target/method pair on a key multiple times - with different context parameters, your observer will only be called once - with the last context you passed. ### Observer Methods - Observer methods you pass should generally have the following signature if - you do not pass a `context` parameter: + Observer methods have the following signature: ```javascript - fooDidChange: function(sender, key, value, rev) { }; + export default Ember.Component.extend({ + init() { + this._super(...arguments); + this.addObserver('foo', this, 'fooDidChange'); + }, + fooDidChange(sender, key, value, rev) { + // your code + } + }); ``` - The sender is the object that changed. The key is the property that - changes. The value property is currently reserved and unused. The rev + The `sender` is the object that changed. The `key` is the property that + changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. - If you pass a `context` parameter, the context will be passed before the - revision like so: - ```javascript - fooDidChange: function(sender, key, value, context, rev) { }; - ``` - Usually you will not need the value, context or revision parameters at + Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. @@ -16691,7 +17015,7 @@ enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], functi let App = Ember.Application.create(); let appInstance = App.buildInstance(); // if all of type `connection` must not be singletons - appInstance.optionsForType('connection', { singleton: false }); + appInstance.registerOptionsForType('connection', { singleton: false }); appInstance.register('connection:twitter', TwitterConnection); appInstance.register('connection:facebook', FacebookConnection); let twitter = appInstance.lookup('connection:twitter'); @@ -16915,10 +17239,14 @@ enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environm var ret = undefined; if (target.send) { - ret = target.send.apply(target, args(actionContext, action)); + var _target; + + ret = (_target = target).send.apply(_target, args(actionContext, action)); } else { + var _target2; + _emberMetal.assert('The action \'' + action + '\' did not exist on ' + target, typeof target[action] === 'function'); - ret = target[action].apply(target, args(actionContext)); + ret = (_target2 = target)[action].apply(_target2, args(actionContext)); } if (ret !== false) { @@ -17384,133 +17712,137 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met // possible. var wasApplied = false; - var initProperties; - - var Class = function () { - if (!wasApplied) { - Class.proto(); // prepare prototype... - } + var initProperties = undefined; - if (arguments.length > 0) { - initProperties = [arguments[0]]; - } + var Class = (function () { + function Class() { + if (!wasApplied) { + Class.proto(); // prepare prototype... + } - this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); - var m = _emberMetal.meta(this); - var proto = m.proto; - m.proto = this; - if (initProperties) { - // capture locally so we can clear the closed over variable - var props = initProperties; - initProperties = null; + if (arguments.length > 0) { + initProperties = [arguments[0]]; + } - var concatenatedProperties = this.concatenatedProperties; - var mergedProperties = this.mergedProperties; + this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); + var m = _emberMetal.meta(this); + var proto = m.proto; + m.proto = this; + if (initProperties) { + // capture locally so we can clear the closed over variable + var props = initProperties; + initProperties = null; - for (var i = 0; i < props.length; i++) { - var properties = props[i]; + var concatenatedProperties = this.concatenatedProperties; + var mergedProperties = this.mergedProperties; - _emberMetal.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetal.Mixin)); + for (var i = 0; i < props.length; i++) { + var properties = props[i]; + _emberMetal.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetal.Mixin)); - if (typeof properties !== 'object' && properties !== undefined) { - throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); - } + if (typeof properties !== 'object' && properties !== undefined) { + throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); + } - if (!properties) { - continue; - } + if (!properties) { + continue; + } - var keyNames = Object.keys(properties); + var keyNames = Object.keys(properties); - for (var j = 0; j < keyNames.length; j++) { - var keyName = keyNames[j]; - var value = properties[keyName]; + for (var j = 0; j < keyNames.length; j++) { + var keyName = keyNames[j]; + var value = properties[keyName]; - if (_emberMetal.detectBinding(keyName)) { - m.writeBindings(keyName, value); - } + if (_emberMetal.detectBinding(keyName)) { + m.writeBindings(keyName, value); + } - var possibleDesc = this[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + var possibleDesc = this[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - _emberMetal.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty)); - _emberMetal.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1)); - _emberMetal.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this))); + _emberMetal.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty)); + _emberMetal.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1)); + _emberMetal.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this))); - if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { - var baseValue = this[keyName]; + if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { + var baseValue = this[keyName]; - if (baseValue) { - if ('function' === typeof baseValue.concat) { - value = baseValue.concat(value); + if (baseValue) { + if ('function' === typeof baseValue.concat) { + value = baseValue.concat(value); + } else { + value = _emberUtils.makeArray(baseValue).concat(value); + } } else { - value = _emberUtils.makeArray(baseValue).concat(value); + value = _emberUtils.makeArray(value); } - } else { - value = _emberUtils.makeArray(value); } - } - if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { - var originalValue = this[keyName]; + if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { + var originalValue = this[keyName]; - value = _emberUtils.assign({}, originalValue, value); - } + value = _emberUtils.assign({}, originalValue, value); + } - if (desc) { - desc.set(this, keyName, value); - } else { - if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { - this.setUnknownProperty(keyName, value); + if (desc) { + desc.set(this, keyName, value); } else { - if (_emberMetal.isFeatureEnabled('mandatory-setter')) { - _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter + if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { + this.setUnknownProperty(keyName, value); } else { - this[keyName] = value; - } + if (_emberMetal.isFeatureEnabled('mandatory-setter')) { + _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter + } else { + this[keyName] = value; + } + } } } } } - } - finishPartial(this, m); + finishPartial(this, m); - this.init.apply(this, arguments); + this.init.apply(this, arguments); - this[POST_INIT](); + this[POST_INIT](); - m.proto = proto; - _emberMetal.finishChains(this); - _emberMetal.sendEvent(this, 'init'); - }; - - Class.toString = _emberMetal.Mixin.prototype.toString; - Class.willReopen = function () { - if (wasApplied) { - Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); + m.proto = proto; + _emberMetal.finishChains(this); + _emberMetal.sendEvent(this, 'init'); } - wasApplied = false; - }; + Class.willReopen = function willReopen() { + if (wasApplied) { + Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); + } - Class._initProperties = function (args) { - initProperties = args; - }; + wasApplied = false; + }; - Class.proto = function () { - var superclass = Class.superclass; - if (superclass) { - superclass.proto(); - } + Class._initProperties = function _initProperties(args) { + initProperties = args; + }; - if (!wasApplied) { - wasApplied = true; - Class.PrototypeMixin.applyPartial(Class.prototype); - } + Class.proto = function proto() { + var superclass = Class.superclass; + if (superclass) { + superclass.proto(); + } - return this.prototype; - }; + if (!wasApplied) { + wasApplied = true; + Class.PrototypeMixin.applyPartial(Class.prototype); + } + + return this.prototype; + }; + + return Class; + })(); + + Class.toString = _emberMetal.Mixin.prototype.toString; return Class; } @@ -17615,7 +17947,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met }, _Mixin$create.toString = function () { var hasToStringExtension = typeof this.toStringExtension === 'function'; var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; - var ret = '<' + this.constructor.toString() + ':' + _emberUtils.guidFor(this) + extension + '>'; + var ret = '<' + (this[_emberUtils.NAME_KEY] || this.constructor.toString()) + ':' + _emberUtils.guidFor(this) + extension + '>'; return ret; }, _Mixin$create)); @@ -17635,7 +17967,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met isMethod: false }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { var Class = makeCtor(); - var proto; + var proto = undefined; Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); @@ -17691,27 +18023,27 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met var possibleDesc = proto[key]; var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); + _emberMetal.assert('metaForProperty() could not find a computed property with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); return desc._meta || {}; }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { hasCachedComputedProperties = true; var proto = this.proto(); - var property; + var property = undefined; var properties = []; - for (var name in proto) { - property = proto[name]; + for (var _name in proto) { + property = proto[_name]; if (property && property.isDescriptor) { properties.push({ - name: name, + name: _name, meta: property._meta }); } } return properties; }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; + var property = undefined; var empty = {}; var properties = _emberMetal.get(this, '_computedProperties'); @@ -17746,7 +18078,8 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met ClassMixinProps._lazyInjections = function () { var injections = {}; var proto = this.proto(); - var key, desc; + var key = undefined; + var desc = undefined; for (key in proto) { desc = proto[key]; @@ -18002,7 +18335,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met ```javascript const Person = Ember.Object.extend({ say(thing) { - var name = this.get('name'); + let name = this.get('name'); alert(`${name} says: ${thing}`); } }); @@ -18157,7 +18490,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met You can pass a hash of these values to a computed property like this: ```javascript person: Ember.computed(function() { - var personId = this.get('personId'); + let personId = this.get('personId'); return Person.create({ id: personId }); }).meta({ type: Person }) ``` @@ -18622,6 +18955,8 @@ enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-en */ 'use strict'; + var _NativeArray; + // Add Ember.Array to Array.prototype. Remove methods with native // implementations and supply some more optimized versions of generic methods // because they are so common. @@ -18711,7 +19046,7 @@ enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-en }); exports.NativeArray // TODO: only use default export - = NativeArray = NativeArray.without.apply(NativeArray, ignore); + = NativeArray = (_NativeArray = NativeArray).without.apply(_NativeArray, ignore); /** Creates an `Ember.NativeArray` from an Array like object. @@ -19396,12 +19731,12 @@ enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-r enifed("ember/features", ["exports"], function (exports) { "use strict"; - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; + exports.default = { "features-stripped-test": null, "ember-libraries-isregistered": null, "ember-improved-instrumentation": null, "ember-metal-weakmap": null, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": null, "ember-factory-for": true, "ember-no-double-extend": null, "ember-routing-router-service": null, "ember-unique-location-history-state": null, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; }); enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "2.11.0-beta.2"; + exports.default = "2.12.0-canary"; }); enifed('rsvp', ['exports'], function (exports) { 'use strict'; diff --git a/ember-template-compiler.js b/ember-template-compiler.js index 3692ca6b9..7a64d57cf 100644 --- a/ember-template-compiler.js +++ b/ember-template-compiler.js @@ -1,15 +1,16 @@ ;(function() { /*! * @overview Ember - JavaScript Application Framework - * @copyright Copyright 2011-2016 Tilde Inc. and contributors + * @copyright Copyright 2011-2017 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.12.0-canary */ var enifed, requireModule, Ember; +var mainContext = this; // Used in ember-environment/lib/global.js (function() { var isNode = typeof window === 'undefined' && @@ -183,24998 +184,16474 @@ babelHelpers = { defaults: defaults }; -enifed('backburner', ['exports'], function (exports) { 'use strict'; - -var NUMBER = /\d+/; - -function each(collection, callback) { - for (var i = 0; i < collection.length; i++) { - callback(collection[i]); - } -} - -function isString(suspect) { - return typeof suspect === 'string'; -} - -function isFunction(suspect) { - return typeof suspect === 'function'; -} - -function isNumber(suspect) { - return typeof suspect === 'number'; -} - -function isCoercableNumber(number) { - return isNumber(number) || NUMBER.test(number); -} - -function binarySearch(time, timers) { - var start = 0; - var end = timers.length - 2; - var middle, l; - - while (start < end) { - // since timers is an array of pairs 'l' will always - // be an integer - l = (end - start) / 2; - - // compensate for the index in case even number - // of pairs inside timers - middle = start + l - (l % 2); - - if (time >= timers[middle]) { - start = middle + 2; - } else { - end = middle; - } - } - - return (time >= timers[start]) ? start + 2 : start; -} - -function Queue(name, options, globalOptions) { - this.name = name; - this.globalOptions = globalOptions || {}; - this.options = options; - this._queue = []; - this.targetQueues = {}; - this._queueBeingFlushed = undefined; -} +enifed('@glimmer/compiler', ['exports', '@glimmer/syntax', '@glimmer/util', '@glimmer/wire-format'], function (exports, _glimmerSyntax, _glimmerUtil, _glimmerWireFormat) { + 'use strict'; -Queue.prototype = { - push: function(target, method, args, stack) { - var queue = this._queue; - queue.push(target, method, args, stack); + var push = Array.prototype.push; - return { - queue: this, - target: target, - method: method + var Frame = function Frame() { + this.parentNode = null; + this.children = null; + this.childIndex = null; + this.childCount = null; + this.childTemplateCount = 0; + this.mustacheCount = 0; + this.actions = []; + this.blankChildTextNodes = null; + this.symbols = null; }; - }, - - pushUniqueWithoutGuid: function(target, method, args, stack) { - var queue = this._queue; - - for (var i = 0, l = queue.length; i < l; i += 4) { - var currentTarget = queue[i]; - var currentMethod = queue[i+1]; - - if (currentTarget === target && currentMethod === method) { - queue[i+2] = args; // replace args - queue[i+3] = stack; // replace stack - return; - } - } - queue.push(target, method, args, stack); - }, + var SymbolTable = (function () { + function SymbolTable(symbols) { + var parent = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - targetQueue: function(targetQueue, target, method, args, stack) { - var queue = this._queue; + this.symbols = symbols; + this.parent = parent; + } - for (var i = 0, l = targetQueue.length; i < l; i += 2) { - var currentMethod = targetQueue[i]; - var currentIndex = targetQueue[i + 1]; + /** + * Takes in an AST and outputs a list of actions to be consumed + * by a compiler. For example, the template + * + * foo{{bar}}
baz
+ * + * produces the actions + * + * [['startProgram', [programNode, 0]], + * ['text', [textNode, 0, 3]], + * ['mustache', [mustacheNode, 1, 3]], + * ['openElement', [elementNode, 2, 3, 0]], + * ['text', [textNode, 0, 1]], + * ['closeElement', [elementNode, 2, 3], + * ['endProgram', [programNode]]] + * + * This visitor walks the AST depth first and backwards. As + * a result the bottom-most child template will appear at the + * top of the actions list whereas the root template will appear + * at the bottom of the list. For example, + * + *
{{#if}}foo{{else}}bar{{/if}}
+ * + * produces the actions + * + * [['startProgram', [programNode, 0]], + * ['text', [textNode, 0, 2, 0]], + * ['openElement', [elementNode, 1, 2, 0]], + * ['closeElement', [elementNode, 1, 2]], + * ['endProgram', [programNode]], + * ['startProgram', [programNode, 0]], + * ['text', [textNode, 0, 1]], + * ['endProgram', [programNode]], + * ['startProgram', [programNode, 2]], + * ['openElement', [elementNode, 0, 1, 1]], + * ['block', [blockNode, 0, 1]], + * ['closeElement', [elementNode, 0, 1]], + * ['endProgram', [programNode]]] + * + * The state of the traversal is maintained by a stack of frames. + * Whenever a node with children is entered (either a ProgramNode + * or an ElementNode) a frame is pushed onto the stack. The frame + * contains information about the state of the traversal of that + * node. For example, + * + * - index of the current child node being visited + * - the number of mustaches contained within its child nodes + * - the list of actions generated by its child nodes + */ - if (currentMethod === method) { - queue[currentIndex + 2] = args; // replace args - queue[currentIndex + 3] = stack; // replace stack - return; - } - } + SymbolTable.prototype.hasLocalVariable = function hasLocalVariable(name) { + var symbols = this.symbols; + var parent = this.parent; - targetQueue.push( - method, - queue.push(target, method, args, stack) - 4 - ); - }, + return symbols.indexOf(name) >= 0 || parent && parent.hasLocalVariable(name); + }; - pushUniqueWithGuid: function(guid, target, method, args, stack) { - var hasLocalQueue = this.targetQueues[guid]; + return SymbolTable; + })(); - if (hasLocalQueue) { - this.targetQueue(hasLocalQueue, target, method, args, stack); - } else { - this.targetQueues[guid] = [ - method, - this._queue.push(target, method, args, stack) - 4 - ]; + function TemplateVisitor() { + this.frameStack = []; + this.actions = []; + this.programDepth = -1; } - - return { - queue: this, - target: target, - method: method + // Traversal methods + TemplateVisitor.prototype.visit = function (node) { + this[node.type](node); }; - }, - - pushUnique: function(target, method, args, stack) { - var KEY = this.globalOptions.GUID_KEY; - - if (target && KEY) { - var guid = target[KEY]; - if (guid) { - return this.pushUniqueWithGuid(guid, target, method, args, stack); - } - } - - this.pushUniqueWithoutGuid(target, method, args, stack); - - return { - queue: this, - target: target, - method: method + TemplateVisitor.prototype.Program = function (program) { + this.programDepth++; + var parentFrame = this.getCurrentFrame(); + var programFrame = this.pushFrame(); + if (parentFrame) { + program.symbols = new SymbolTable(program.blockParams, parentFrame.symbols); + } else { + program.symbols = new SymbolTable(program.blockParams); + } + var startType = undefined, + endType = undefined; + if (this.programDepth === 0) { + startType = 'startProgram'; + endType = 'endProgram'; + } else { + startType = 'startBlock'; + endType = 'endBlock'; + } + programFrame.parentNode = program; + programFrame.children = program.body; + programFrame.childCount = program.body.length; + programFrame.blankChildTextNodes = []; + programFrame.actions.push([endType, [program, this.programDepth]]); + programFrame.symbols = program.symbols; + for (var i = program.body.length - 1; i >= 0; i--) { + programFrame.childIndex = i; + this.visit(program.body[i]); + } + programFrame.actions.push([startType, [program, programFrame.childTemplateCount, programFrame.blankChildTextNodes.reverse()]]); + this.popFrame(); + this.programDepth--; + // Push the completed template into the global actions list + if (parentFrame) { + parentFrame.childTemplateCount++; + } + push.apply(this.actions, programFrame.actions.reverse()); }; - }, - - invoke: function(target, method, args /*, onError, errorRecordedForStack */) { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - }, - - invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { - try { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - } catch(error) { - onError(error, errorRecordedForStack); + TemplateVisitor.prototype.ElementNode = function (element) { + var parentFrame = this.getCurrentFrame(); + var elementFrame = this.pushFrame(); + elementFrame.parentNode = element; + elementFrame.children = element.children; + elementFrame.childCount = element.children.length; + elementFrame.mustacheCount += element.modifiers.length; + elementFrame.blankChildTextNodes = []; + elementFrame.symbols = parentFrame.symbols; + var actionArgs = [element, parentFrame.childIndex, parentFrame.childCount]; + elementFrame.actions.push(['closeElement', actionArgs]); + for (var i = element.attributes.length - 1; i >= 0; i--) { + this.visit(element.attributes[i]); + } + for (var i = element.children.length - 1; i >= 0; i--) { + elementFrame.childIndex = i; + this.visit(element.children[i]); + } + elementFrame.actions.push(['openElement', actionArgs.concat([elementFrame.mustacheCount, elementFrame.blankChildTextNodes.reverse()])]); + this.popFrame(); + // Propagate the element's frame state to the parent frame + if (elementFrame.mustacheCount > 0) { + parentFrame.mustacheCount++; + } + parentFrame.childTemplateCount += elementFrame.childTemplateCount; + push.apply(parentFrame.actions, elementFrame.actions); + }; + TemplateVisitor.prototype.AttrNode = function (attr) { + if (attr.value.type !== 'TextNode') { + this.getCurrentFrame().mustacheCount++; + } + }; + TemplateVisitor.prototype.TextNode = function (text) { + var frame = this.getCurrentFrame(); + if (text.chars === '') { + frame.blankChildTextNodes.push(domIndexOf(frame.children, text)); + } + frame.actions.push(['text', [text, frame.childIndex, frame.childCount]]); + }; + TemplateVisitor.prototype.BlockStatement = function (node) { + var frame = this.getCurrentFrame(); + frame.mustacheCount++; + frame.actions.push(['block', [node, frame.childIndex, frame.childCount]]); + if (node.inverse) { + this.visit(node.inverse); + } + if (node.program) { + this.visit(node.program); + } + }; + TemplateVisitor.prototype.PartialStatement = function (node) { + var frame = this.getCurrentFrame(); + frame.mustacheCount++; + frame.actions.push(['mustache', [node, frame.childIndex, frame.childCount]]); + }; + TemplateVisitor.prototype.CommentStatement = function (text) { + var frame = this.getCurrentFrame(); + frame.actions.push(['comment', [text, frame.childIndex, frame.childCount]]); + }; + TemplateVisitor.prototype.MustacheCommentStatement = function () { + // Intentional empty: Handlebars comments should not affect output. + }; + TemplateVisitor.prototype.MustacheStatement = function (mustache) { + var frame = this.getCurrentFrame(); + frame.mustacheCount++; + frame.actions.push(['mustache', [mustache, frame.childIndex, frame.childCount]]); + }; + // Frame helpers + TemplateVisitor.prototype.getCurrentFrame = function () { + return this.frameStack[this.frameStack.length - 1]; + }; + TemplateVisitor.prototype.pushFrame = function () { + var frame = new Frame(); + this.frameStack.push(frame); + return frame; + }; + TemplateVisitor.prototype.popFrame = function () { + return this.frameStack.pop(); + }; + // Returns the index of `domNode` in the `nodes` array, skipping + // over any nodes which do not represent DOM nodes. + function domIndexOf(nodes, domNode) { + var index = -1; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + if (node.type !== 'TextNode' && node.type !== 'ElementNode') { + continue; + } else { + index++; + } + if (node === domNode) { + return index; + } + } + return -1; } - }, - - flush: function(sync) { - var queue = this._queue; - var length = queue.length; - if (length === 0) { - return; - } + var Block = (function () { + function Block() { + this.type = "block"; + this.statements = []; + this.positionals = []; + } - var globalOptions = this.globalOptions; - var options = this.options; - var before = options && options.before; - var after = options && options.after; - var onError = globalOptions.onError || (globalOptions.onErrorTarget && - globalOptions.onErrorTarget[globalOptions.onErrorMethod]); - var target, method, args, errorRecordedForStack; - var invoke = onError ? this.invokeWithOnError : this.invoke; + Block.prototype.toJSON = function toJSON() { + return { + statements: this.statements, + locals: this.positionals + }; + }; - this.targetQueues = Object.create(null); - var queueItems = this._queueBeingFlushed = this._queue.slice(); - this._queue = []; + Block.prototype.push = function push(statement) { + this.statements.push(statement); + }; - if (before) { - before(); - } + return Block; + })(); - for (var i = 0; i < length; i += 4) { - target = queueItems[i]; - method = queueItems[i+1]; - args = queueItems[i+2]; - errorRecordedForStack = queueItems[i+3]; // Debugging assistance + var TemplateBlock = (function (_Block) { + babelHelpers.inherits(TemplateBlock, _Block); - if (isString(method)) { - method = target[method]; - } + function TemplateBlock() { + _Block.apply(this, arguments); + this.type = "template"; + this.yields = new _glimmerUtil.DictSet(); + this.named = new _glimmerUtil.DictSet(); + this.blocks = []; + this.hasPartials = false; + } - // method could have been nullified / canceled during flush - if (method) { - // - // ** Attention intrepid developer ** - // - // To find out the stack of this task when it was scheduled onto - // the run loop, add the following to your app.js: - // - // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. - // - // Once that is in place, when you are at a breakpoint and navigate - // here in the stack explorer, you can look at `errorRecordedForStack.stack`, - // which will be the captured stack when this job was scheduled. - // - // One possible long-term solution is the following Chrome issue: - // https://bugs.chromium.org/p/chromium/issues/detail?id=332624 - // - invoke(target, method, args, onError, errorRecordedForStack); - } - } + TemplateBlock.prototype.toJSON = function toJSON() { + return { + statements: this.statements, + locals: this.positionals, + named: this.named.toArray(), + yields: this.yields.toArray(), + hasPartials: this.hasPartials + }; + }; - if (after) { - after(); - } + return TemplateBlock; + })(Block); - this._queueBeingFlushed = undefined; + var ComponentBlock = (function (_Block2) { + babelHelpers.inherits(ComponentBlock, _Block2); - if (sync !== false && - this._queue.length > 0) { - // check if new items have been added - this.flush(true); - } - }, + function ComponentBlock() { + _Block2.apply(this, arguments); + this.type = "component"; + this.attributes = []; + this.arguments = []; + this.inParams = true; + } + + ComponentBlock.prototype.push = function push(statement) { + if (this.inParams) { + if (_glimmerWireFormat.Statements.isFlushElement(statement)) { + this.inParams = false; + } else if (_glimmerWireFormat.Statements.isArgument(statement)) { + this.arguments.push(statement); + } else if (_glimmerWireFormat.Statements.isAttribute(statement)) { + this.attributes.push(statement); + } else if (_glimmerWireFormat.Statements.isModifier(statement)) { + throw new Error('Compile Error: Element modifiers are not allowed in components'); + } else { + throw new Error('Compile Error: only parameters allowed before flush-element'); + } + } else { + this.statements.push(statement); + } + }; - cancel: function(actionToCancel) { - var queue = this._queue, currentTarget, currentMethod, i, l; - var target = actionToCancel.target; - var method = actionToCancel.method; - var GUID_KEY = this.globalOptions.GUID_KEY; + ComponentBlock.prototype.toJSON = function toJSON() { + var args = this.arguments; + var keys = args.map(function (arg) { + return arg[1]; + }); + var values = args.map(function (arg) { + return arg[2]; + }); + return { + attrs: this.attributes, + args: [keys, values], + locals: this.positionals, + statements: this.statements + }; + }; - if (GUID_KEY && this.targetQueues && target) { - var targetQueue = this.targetQueues[target[GUID_KEY]]; + return ComponentBlock; + })(Block); - if (targetQueue) { - for (i = 0, l = targetQueue.length; i < l; i++) { - if (targetQueue[i] === method) { - targetQueue.splice(i, 1); - } + var Template = (function () { + function Template(meta) { + this.meta = meta; + this.block = new TemplateBlock(); } - } - } - - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; - if (currentTarget === target && - currentMethod === method) { - queue.splice(i, 4); - return true; - } - } + Template.prototype.toJSON = function toJSON() { + return { + block: this.block.toJSON(), + meta: this.meta + }; + }; - // if not found in current queue - // could be in the queue that is being flushed - queue = this._queueBeingFlushed; + return Template; + })(); - if (!queue) { - return; - } + var JavaScriptCompiler = (function () { + function JavaScriptCompiler(opcodes, meta) { + this.blocks = new _glimmerUtil.Stack(); + this.values = []; + this.opcodes = opcodes; + this.template = new Template(meta); + } - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; + JavaScriptCompiler.process = function process(opcodes, meta) { + var compiler = new JavaScriptCompiler(opcodes, meta); + return compiler.process(); + }; - if (currentTarget === target && - currentMethod === method) { - // don't mess with array during flush - // just nullify the method - queue[i+1] = null; - return true; - } - } - } -}; + JavaScriptCompiler.prototype.process = function process() { + var _this = this; -function DeferredActionQueues(queueNames, options) { - var queues = this.queues = {}; - this.queueNames = queueNames = queueNames || []; + this.opcodes.forEach(function (_ref) { + var opcode = _ref[0]; - this.options = options; + var args = _ref.slice(1); - each(queueNames, function(queueName) { - queues[queueName] = new Queue(queueName, options[queueName], options); - }); -} + if (!_this[opcode]) { + throw new Error('unimplemented ' + opcode + ' on JavaScriptCompiler'); + } + _this[opcode].apply(_this, args); + }); + return this.template; + }; -function noSuchQueue(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist'); -} + /// Nesting -function noSuchMethod(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist'); -} + JavaScriptCompiler.prototype.startBlock = function startBlock(_ref2) { + var program = _ref2[0]; -DeferredActionQueues.prototype = { - schedule: function(name, target, method, args, onceFlag, stack) { - var queues = this.queues; - var queue = queues[name]; + var block = new Block(); + block.positionals = program.blockParams; + this.blocks.push(block); + }; - if (!queue) { - noSuchQueue(name); - } + JavaScriptCompiler.prototype.endBlock = function endBlock() { + var template = this.template; + var blocks = this.blocks; - if (!method) { - noSuchMethod(name); - } + template.block.blocks.push(blocks.pop().toJSON()); + }; - if (onceFlag) { - return queue.pushUnique(target, method, args, stack); - } else { - return queue.push(target, method, args, stack); - } - }, + JavaScriptCompiler.prototype.startProgram = function startProgram() { + this.blocks.push(this.template.block); + }; - flush: function() { - var queues = this.queues; - var queueNames = this.queueNames; - var queueName, queue; - var queueNameIndex = 0; - var numberOfQueues = queueNames.length; + JavaScriptCompiler.prototype.endProgram = function endProgram() {}; - while (queueNameIndex < numberOfQueues) { - queueName = queueNames[queueNameIndex]; - queue = queues[queueName]; + /// Statements - var numberOfQueueItems = queue._queue.length; + JavaScriptCompiler.prototype.text = function text(content) { + this.push(['text', content]); + }; - if (numberOfQueueItems === 0) { - queueNameIndex++; - } else { - queue.flush(false /* async */); - queueNameIndex = 0; - } - } - } -}; + JavaScriptCompiler.prototype.append = function append(trusted) { + this.push(['append', this.popValue(), trusted]); + }; -function Backburner(queueNames, options) { - this.queueNames = queueNames; - this.options = options || {}; - if (!this.options.defaultQueue) { - this.options.defaultQueue = queueNames[0]; - } - this.instanceStack = []; - this._debouncees = []; - this._throttlers = []; - this._eventCallbacks = { - end: [], - begin: [] - }; + JavaScriptCompiler.prototype.comment = function comment(value) { + this.push(['comment', value]); + }; - var _this = this; - this._boundClearItems = function() { - clearItems(); - }; + JavaScriptCompiler.prototype.modifier = function modifier(path) { + var params = this.popValue(); + var hash = this.popValue(); + this.push(['modifier', path, params, hash]); + }; - this._timerTimeoutId = undefined; - this._timers = []; + JavaScriptCompiler.prototype.block = function block(path, template, inverse) { + var params = this.popValue(); + var hash = this.popValue(); + var blocks = this.template.block.blocks; + _glimmerUtil.assert(typeof template !== 'number' || blocks[template] !== null, 'missing block in the compiler'); + _glimmerUtil.assert(typeof inverse !== 'number' || blocks[inverse] !== null, 'missing block in the compiler'); + this.push(['block', path, params, hash, blocks[template], blocks[inverse]]); + }; - this._platform = this.options._platform || { - setTimeout: function (fn, ms) { - return setTimeout(fn, ms); - }, - clearTimeout: function (id) { - clearTimeout(id); - } - }; + JavaScriptCompiler.prototype.openElement = function openElement(tag, blockParams) { + if (tag.indexOf('-') !== -1) { + this.startComponent(blockParams); + } else { + this.push(['open-element', tag, blockParams]); + } + }; - this._boundRunExpiredTimers = function () { - _this._runExpiredTimers(); - }; -} + JavaScriptCompiler.prototype.flushElement = function flushElement() { + this.push(['flush-element']); + }; -Backburner.prototype = { - begin: function() { - var options = this.options; - var onBegin = options && options.onBegin; - var previousInstance = this.currentInstance; + JavaScriptCompiler.prototype.closeElement = function closeElement(tag) { + if (tag.indexOf('-') !== -1) { + var component = this.endComponent(); + this.push(['component', tag, component]); + } else { + this.push(['close-element']); + } + }; - if (previousInstance) { - this.instanceStack.push(previousInstance); - } + JavaScriptCompiler.prototype.staticAttr = function staticAttr(name, namespace) { + var value = this.popValue(); + this.push(['static-attr', name, value, namespace]); + }; - this.currentInstance = new DeferredActionQueues(this.queueNames, options); - this._trigger('begin', this.currentInstance, previousInstance); - if (onBegin) { - onBegin(this.currentInstance, previousInstance); - } - }, + JavaScriptCompiler.prototype.dynamicAttr = function dynamicAttr(name, namespace) { + var value = this.popValue(); + this.push(['dynamic-attr', name, value, namespace]); + }; - end: function() { - var options = this.options; - var onEnd = options && options.onEnd; - var currentInstance = this.currentInstance; - var nextInstance = null; + JavaScriptCompiler.prototype.trustingAttr = function trustingAttr(name, namespace) { + var value = this.popValue(); + this.push(['trusting-attr', name, value, namespace]); + }; - // Prevent double-finally bug in Safari 6.0.2 and iOS 6 - // This bug appears to be resolved in Safari 6.0.5 and iOS 7 - var finallyAlreadyCalled = false; - try { - currentInstance.flush(); - } finally { - if (!finallyAlreadyCalled) { - finallyAlreadyCalled = true; + JavaScriptCompiler.prototype.staticArg = function staticArg(name) { + var value = this.popValue(); + this.push(['static-arg', name.slice(1), value]); + }; - this.currentInstance = null; + JavaScriptCompiler.prototype.dynamicArg = function dynamicArg(name) { + var value = this.popValue(); + this.push(['dynamic-arg', name.slice(1), value]); + }; - if (this.instanceStack.length) { - nextInstance = this.instanceStack.pop(); - this.currentInstance = nextInstance; - } - this._trigger('end', currentInstance, nextInstance); - if (onEnd) { - onEnd(currentInstance, nextInstance); - } - } - } - }, + JavaScriptCompiler.prototype.yield = function _yield(to) { + var params = this.popValue(); + this.push(['yield', to, params]); + this.template.block.yields.add(to); + }; - /** - Trigger an event. Supports up to two arguments. Designed around - triggering transition events from one run loop instance to the - next, which requires an argument for the first instance and then - an argument for the next instance. + JavaScriptCompiler.prototype.debugger = function _debugger() { + this.push(['debugger', null, null]); + }; - @private - @method _trigger - @param {String} eventName - @param {any} arg1 - @param {any} arg2 - */ - _trigger: function(eventName, arg1, arg2) { - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - for (var i = 0; i < callbacks.length; i++) { - callbacks[i](arg1, arg2); - } - } - }, + JavaScriptCompiler.prototype.hasBlock = function hasBlock(name) { + this.pushValue(['has-block', name]); + this.template.block.yields.add(name); + }; - on: function(eventName, callback) { - if (typeof callback !== 'function') { - throw new TypeError('Callback must be a function'); - } - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - callbacks.push(callback); - } else { - throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist'); - } - }, - - off: function(eventName, callback) { - if (eventName) { - var callbacks = this._eventCallbacks[eventName]; - var callbackFound = false; - if (!callbacks) return; - if (callback) { - for (var i = 0; i < callbacks.length; i++) { - if (callbacks[i] === callback) { - callbackFound = true; - callbacks.splice(i, 1); - i--; - } - } - } - if (!callbackFound) { - throw new TypeError('Cannot off() callback that does not exist'); - } - } else { - throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist'); - } - }, + JavaScriptCompiler.prototype.hasBlockParams = function hasBlockParams(name) { + this.pushValue(['has-block-params', name]); + this.template.block.yields.add(name); + }; - run: function(/* target, method, args */) { - var length = arguments.length; - var method, target, args; + JavaScriptCompiler.prototype.partial = function partial() { + var params = this.popValue(); + this.push(['partial', params[0]]); + this.template.block.hasPartials = true; + }; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + /// Expressions - if (isString(method)) { - method = target[method]; - } + JavaScriptCompiler.prototype.literal = function literal(value) { + if (value === undefined) { + this.pushValue(['undefined']); + } else { + this.pushValue(value); + } + }; - if (length > 2) { - args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - } else { - args = []; - } + JavaScriptCompiler.prototype.unknown = function unknown(path) { + this.pushValue(['unknown', path]); + }; - var onError = getOnError(this.options); + JavaScriptCompiler.prototype.arg = function arg(path) { + this.template.block.named.add(path[0]); + this.pushValue(['arg', path]); + }; - this.begin(); + JavaScriptCompiler.prototype.get = function get(path) { + this.pushValue(['get', path]); + }; - // guard against Safari 6's double-finally bug - var didFinally = false; + JavaScriptCompiler.prototype.concat = function concat() { + this.pushValue(['concat', this.popValue()]); + }; - if (onError) { - try { - return method.apply(target, args); - } catch(error) { - onError(error); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); - } - } - } else { - try { - return method.apply(target, args); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); - } - } - } - }, + JavaScriptCompiler.prototype.helper = function helper(path) { + var params = this.popValue(); + var hash = this.popValue(); + this.pushValue(['helper', path, params, hash]); + }; - /* - Join the passed method with an existing queue and execute immediately, - if there isn't one use `Backburner#run`. + /// Stack Management Opcodes - The join method is like the run method except that it will schedule into - an existing queue if one already exists. In either case, the join method will - immediately execute the passed in function and return its result. + JavaScriptCompiler.prototype.startComponent = function startComponent(blockParams) { + var component = new ComponentBlock(); + component.positionals = blockParams; + this.blocks.push(component); + }; - @method join - @param {Object} target - @param {Function} method The method to be executed - @param {any} args The method arguments - @return method result - */ - join: function(/* target, method, args */) { - if (!this.currentInstance) { - return this.run.apply(this, arguments); - } + JavaScriptCompiler.prototype.endComponent = function endComponent() { + var component = this.blocks.pop(); + _glimmerUtil.assert(component.type === 'component', "Compiler bug: endComponent() should end a component"); + return component.toJSON(); + }; - var length = arguments.length; - var method, target; + JavaScriptCompiler.prototype.prepareArray = function prepareArray(size) { + var values = []; + for (var i = 0; i < size; i++) { + values.push(this.popValue()); + } + this.pushValue(values); + }; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + JavaScriptCompiler.prototype.prepareObject = function prepareObject(size) { + _glimmerUtil.assert(this.values.length >= size, 'Expected ' + size + ' values on the stack, found ' + this.values.length); + var keys = new Array(size); + var values = new Array(size); + for (var i = 0; i < size; i++) { + keys[i] = this.popValue(); + values[i] = this.popValue(); + } + this.pushValue([keys, values]); + }; - if (isString(method)) { - method = target[method]; - } + /// Utilities - if (length === 1) { - return method(); - } else if (length === 2) { - return method.call(target); - } else { - var args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - return method.apply(target, args); - } - }, + JavaScriptCompiler.prototype.push = function push(args) { + while (args[args.length - 1] === null) { + args.pop(); + } + this.blocks.current.push(args); + }; + JavaScriptCompiler.prototype.pushValue = function pushValue(val) { + this.values.push(val); + }; - /* - Defer the passed function to run inside the specified queue. + JavaScriptCompiler.prototype.popValue = function popValue() { + _glimmerUtil.assert(this.values.length, "No expression found on stack"); + return this.values.pop(); + }; - @method defer - @param {String} queueName - @param {Object} target - @param {Function|String} method The method or method name to be executed - @param {any} args The method arguments - @return method result - */ - defer: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + return JavaScriptCompiler; + })(); - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; + function isTrustedValue(value) { + return value.escaped !== undefined && !value.escaped; } - if (isString(method)) { - method = target[method]; - } + var TemplateCompiler = (function () { + function TemplateCompiler(options) { + this.templateId = 0; + this.templateIds = []; + this.symbols = null; + this.opcodes = []; + this.includeMeta = false; + this.options = options || {}; + } - var stack = this.DEBUG ? new Error() : undefined; + TemplateCompiler.compile = function compile(options, ast) { + var templateVisitor = new TemplateVisitor(); + templateVisitor.visit(ast); + var compiler = new TemplateCompiler(options); + var opcodes = compiler.process(templateVisitor.actions); + return JavaScriptCompiler.process(opcodes, options.meta); + }; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + TemplateCompiler.prototype.process = function process(actions) { + var _this2 = this; - if (!this.currentInstance) { createAutorun(this); } - return this.currentInstance.schedule(queueName, target, method, args, false, stack); - }, + actions.forEach(function (_ref3) { + var name = _ref3[0]; - deferOnce: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + var args = _ref3.slice(1); - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; - } + if (!_this2[name]) { + throw new Error('Unimplemented ' + name + ' on TemplateCompiler'); + } + _this2[name].apply(_this2, args); + }); + return this.opcodes; + }; - if (isString(method)) { - method = target[method]; - } + TemplateCompiler.prototype.startProgram = function startProgram(program) { + this.opcode('startProgram', program, program); + }; - var stack = this.DEBUG ? new Error() : undefined; + TemplateCompiler.prototype.endProgram = function endProgram() { + this.opcode('endProgram', null); + }; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + TemplateCompiler.prototype.startBlock = function startBlock(program) { + this.symbols = program[0].symbols; + this.templateId++; + this.opcode('startBlock', program, program); + }; - if (!this.currentInstance) { - createAutorun(this); - } - return this.currentInstance.schedule(queueName, target, method, args, true, stack); - }, + TemplateCompiler.prototype.endBlock = function endBlock() { + this.symbols = null; + this.templateIds.push(this.templateId - 1); + this.opcode('endBlock', null); + }; - setTimeout: function() { - var l = arguments.length; - var args = new Array(l); + TemplateCompiler.prototype.text = function text(_ref4) { + var action = _ref4[0]; - for (var x = 0; x < l; x++) { - args[x] = arguments[x]; - } + this.opcode('text', action, action.chars); + }; - var length = args.length, - method, wait, target, - methodOrTarget, methodOrWait, methodOrArgs; + TemplateCompiler.prototype.comment = function comment(_ref5) { + var action = _ref5[0]; - if (length === 0) { - return; - } else if (length === 1) { - method = args.shift(); - wait = 0; - } else if (length === 2) { - methodOrTarget = args[0]; - methodOrWait = args[1]; + this.opcode('comment', action, action.value); + }; - if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { - target = args.shift(); - method = args.shift(); - wait = 0; - } else if (isCoercableNumber(methodOrWait)) { - method = args.shift(); - wait = args.shift(); - } else { - method = args.shift(); - wait = 0; - } - } else { - var last = args[args.length - 1]; + TemplateCompiler.prototype.openElement = function openElement(_ref6) { + var action = _ref6[0]; - if (isCoercableNumber(last)) { - wait = args.pop(); - } else { - wait = 0; - } + this.opcode('openElement', action, action.tag, action.blockParams); + for (var i = 0; i < action.attributes.length; i++) { + this.attribute([action.attributes[i]]); + } + for (var i = 0; i < action.modifiers.length; i++) { + this.modifier([action.modifiers[i]]); + } + this.opcode('flushElement', null); + }; - methodOrTarget = args[0]; - methodOrArgs = args[1]; + TemplateCompiler.prototype.closeElement = function closeElement(_ref7) { + var action = _ref7[0]; - if (isFunction(methodOrArgs) || (isString(methodOrArgs) && - methodOrTarget !== null && - methodOrArgs in methodOrTarget)) { - target = args.shift(); - method = args.shift(); - } else { - method = args.shift(); - } - } + this.opcode('closeElement', null, action.tag); + }; - var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); + TemplateCompiler.prototype.attribute = function attribute(_ref8) { + var action = _ref8[0]; + var name = action.name; + var value = action.value; - if (isString(method)) { - method = target[method]; - } + var namespace = _glimmerUtil.getAttrNamespace(name); + var isStatic = this.prepareAttributeValue(value); + if (name.charAt(0) === '@') { + // Arguments + if (isStatic) { + this.opcode('staticArg', action, name); + } else if (action.value.type === 'MustacheStatement') { + this.opcode('dynamicArg', action, name); + } else { + this.opcode('dynamicArg', action, name); + } + } else { + var isTrusting = isTrustedValue(value); + if (isStatic) { + this.opcode('staticAttr', action, name, namespace); + } else if (isTrusting) { + this.opcode('trustingAttr', action, name, namespace); + } else if (action.value.type === 'MustacheStatement') { + this.opcode('dynamicAttr', action, name); + } else { + this.opcode('dynamicAttr', action, name, namespace); + } + } + }; - var onError = getOnError(this.options); + TemplateCompiler.prototype.modifier = function modifier(_ref9) { + var action = _ref9[0]; + var parts = action.path.parts; - function fn() { - if (onError) { - try { - method.apply(target, args); - } catch (e) { - onError(e); - } - } else { - method.apply(target, args); - } - } + this.prepareHelper(action); + this.opcode('modifier', action, parts); + }; - return this._setTimeout(fn, executeAt); - }, + TemplateCompiler.prototype.mustache = function mustache(_ref10) { + var action = _ref10[0]; - _setTimeout: function (fn, executeAt) { - if (this._timers.length === 0) { - this._timers.push(executeAt, fn); - this._installTimerTimeout(); - return fn; - } + if (isYield(action)) { + var to = assertValidYield(action); + this.yield(to, action); + } else if (isPartial(action)) { + var params = assertValidPartial(action); + this.partial(params, action); + } else if (isDebugger(action)) { + assertValidDebuggerUsage(action); + this.debugger('debugger', action); + } else { + this.mustacheExpression(action); + this.opcode('append', action, !action.escaped); + } + }; - // find position to insert - var i = binarySearch(executeAt, this._timers); + TemplateCompiler.prototype.block = function block(_ref11) /*, index, count*/{ + var action = _ref11[0]; - this._timers.splice(i, 0, executeAt, fn); + this.prepareHelper(action); + var templateId = this.templateIds.pop(); + var inverseId = action.inverse === null ? null : this.templateIds.pop(); + this.opcode('block', action, action.path.parts, templateId, inverseId); + }; - // we should be the new earliest timer if i == 0 - if (i === 0) { - this._reinstallTimerTimeout(); - } + /// Internal actions, not found in the original processed actions - return fn; - }, + TemplateCompiler.prototype.arg = function arg(_ref12) { + var path = _ref12[0]; + var parts = path.parts; - throttle: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } - var immediate = args.pop(); - var wait, throttler, index, timer; + this.opcode('arg', path, parts); + }; - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = true; - } else { - wait = args.pop(); - } + TemplateCompiler.prototype.mustacheExpression = function mustacheExpression(expr) { + if (isBuiltInHelper(expr)) { + this.builtInHelper(expr); + } else if (isLiteral(expr)) { + this.opcode('literal', expr, expr.path.value); + } else if (isArg(expr)) { + this.arg([expr.path]); + } else if (isHelperInvocation(expr)) { + this.prepareHelper(expr); + this.opcode('helper', expr, expr.path.parts); + } else if (isSelfGet(expr) || isLocalVariable(expr, this.symbols)) { + this.opcode('get', expr, expr.path.parts); + } else { + this.opcode('unknown', expr, expr.path.parts); + } + }; - wait = parseInt(wait, 10); + /// Internal Syntax - index = findThrottler(target, method, this._throttlers); - if (index > -1) { return this._throttlers[index]; } // throttled + TemplateCompiler.prototype.yield = function _yield(to, action) { + this.prepareParams(action.params); + this.opcode('yield', action, to); + }; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findThrottler(target, method, backburner._throttlers); - if (index > -1) { - backburner._throttlers.splice(index, 1); - } - }, wait); + TemplateCompiler.prototype.debugger = function _debugger(name, action) { + this.opcode('debugger', null); + }; - if (immediate) { - this.run.apply(this, args); - } + TemplateCompiler.prototype.hasBlock = function hasBlock(name, action) { + this.opcode('hasBlock', action, name); + }; - throttler = [target, method, timer]; + TemplateCompiler.prototype.hasBlockParams = function hasBlockParams(name, action) { + this.opcode('hasBlockParams', action, name); + }; - this._throttlers.push(throttler); + TemplateCompiler.prototype.partial = function partial(params, action) { + this.prepareParams(action.params); + this.opcode('partial', action); + }; - return throttler; - }, + TemplateCompiler.prototype.builtInHelper = function builtInHelper(expr) { + if (isHasBlock(expr)) { + var _name = assertValidHasBlockUsage(expr.path.original, expr); + this.hasBlock(_name, expr); + } else if (isHasBlockParams(expr)) { + var _name2 = assertValidHasBlockUsage(expr.path.original, expr); + this.hasBlockParams(_name2, expr); + } + }; - debounce: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } + /// Expressions, invoked recursively from prepareParams and prepareHash - var immediate = args.pop(); - var wait, index, debouncee, timer; + TemplateCompiler.prototype.SubExpression = function SubExpression(expr) { + if (isBuiltInHelper(expr)) { + this.builtInHelper(expr); + } else { + this.prepareHelper(expr); + this.opcode('helper', expr, expr.path.parts); + } + }; - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = false; - } else { - wait = args.pop(); - } + TemplateCompiler.prototype.PathExpression = function PathExpression(expr) { + if (expr.data) { + this.arg([expr]); + } else { + this.opcode('get', expr, expr.parts); + } + }; - wait = parseInt(wait, 10); - // Remove debouncee - index = findDebouncee(target, method, this._debouncees); + TemplateCompiler.prototype.StringLiteral = function StringLiteral(action) { + this.opcode('literal', null, action.value); + }; - if (index > -1) { - debouncee = this._debouncees[index]; - this._debouncees.splice(index, 1); - this._platform.clearTimeout(debouncee[2]); - } + TemplateCompiler.prototype.BooleanLiteral = function BooleanLiteral(action) { + this.opcode('literal', null, action.value); + }; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findDebouncee(target, method, backburner._debouncees); - if (index > -1) { - backburner._debouncees.splice(index, 1); - } - }, wait); + TemplateCompiler.prototype.NumberLiteral = function NumberLiteral(action) { + this.opcode('literal', null, action.value); + }; - if (immediate && index === -1) { - backburner.run.apply(backburner, args); - } + TemplateCompiler.prototype.NullLiteral = function NullLiteral(action) { + this.opcode('literal', null, action.value); + }; - debouncee = [ - target, - method, - timer - ]; + TemplateCompiler.prototype.UndefinedLiteral = function UndefinedLiteral(action) { + this.opcode('literal', null, action.value); + }; - backburner._debouncees.push(debouncee); + /// Utilities - return debouncee; - }, + TemplateCompiler.prototype.opcode = function opcode(name, action) { + for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } - cancelTimers: function() { - each(this._throttlers, this._boundClearItems); - this._throttlers = []; + var opcode = [name].concat(args); + if (this.includeMeta && action) { + opcode.push(this.meta(action)); + } + this.opcodes.push(opcode); + }; - each(this._debouncees, this._boundClearItems); - this._debouncees = []; + TemplateCompiler.prototype.prepareHelper = function prepareHelper(_ref13) { + var params = _ref13.params; + var hash = _ref13.hash; - this._clearTimerTimeout(); - this._timers = []; + this.prepareHash(hash); + this.prepareParams(params); + }; - if (this._autorun) { - this._platform.clearTimeout(this._autorun); - this._autorun = null; - } - }, + TemplateCompiler.prototype.preparePath = function preparePath(path) { + this.opcode('literal', path, path.parts); + }; - hasTimers: function() { - return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; - }, + TemplateCompiler.prototype.prepareParams = function prepareParams(params) { + if (!params.length) { + this.opcode('literal', null, null); + return; + } + for (var i = params.length - 1; i >= 0; i--) { + var param = params[i]; + _glimmerUtil.assert(this[param.type], 'Unimplemented ' + param.type + ' on TemplateCompiler'); + this[param.type](param); + } + this.opcode('prepareArray', null, params.length); + }; - cancel: function (timer) { - var timerType = typeof timer; + TemplateCompiler.prototype.prepareHash = function prepareHash(hash) { + var pairs = hash.pairs; + if (!pairs.length) { + this.opcode('literal', null, null); + return; + } + for (var i = pairs.length - 1; i >= 0; i--) { + var _pairs$i = pairs[i]; + var key = _pairs$i.key; + var value = _pairs$i.value; - if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce - return timer.queue.cancel(timer); - } else if (timerType === 'function') { // we're cancelling a setTimeout - for (var i = 0, l = this._timers.length; i < l; i += 2) { - if (this._timers[i + 1] === timer) { - this._timers.splice(i, 2); // remove the two elements - if (i === 0) { - this._reinstallTimerTimeout(); - } - return true; - } - } - } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce - return this._cancelItem(findThrottler, this._throttlers, timer) || - this._cancelItem(findDebouncee, this._debouncees, timer); - } else { - return; // timer was null or not a timer - } - }, + _glimmerUtil.assert(this[value.type], 'Unimplemented ' + value.type + ' on TemplateCompiler'); + this[value.type](value); + this.opcode('literal', null, key); + } + this.opcode('prepareObject', null, pairs.length); + }; - _cancelItem: function(findMethod, array, timer){ - var item, index; + TemplateCompiler.prototype.prepareAttributeValue = function prepareAttributeValue(value) { + // returns the static value if the value is static + switch (value.type) { + case 'TextNode': + this.opcode('literal', value, value.chars); + return true; + case 'MustacheStatement': + this.attributeMustache([value]); + return false; + case 'ConcatStatement': + this.prepareConcatParts(value.parts); + this.opcode('concat', value); + return false; + } + }; - if (timer.length < 3) { return false; } + TemplateCompiler.prototype.prepareConcatParts = function prepareConcatParts(parts) { + for (var i = parts.length - 1; i >= 0; i--) { + var part = parts[i]; + if (part.type === 'MustacheStatement') { + this.attributeMustache([part]); + } else if (part.type === 'TextNode') { + this.opcode('literal', null, part.chars); + } + } + this.opcode('prepareArray', null, parts.length); + }; - index = findMethod(timer[0], timer[1], array); + TemplateCompiler.prototype.attributeMustache = function attributeMustache(_ref14) { + var action = _ref14[0]; - if (index > -1) { + this.mustacheExpression(action); + }; - item = array[index]; + TemplateCompiler.prototype.meta = function meta(node) { + var loc = node.loc; + if (!loc) { + return []; + } + var source = loc.source; + var start = loc.start; + var end = loc.end; - if (item[2] === timer[2]) { - array.splice(index, 1); - this._platform.clearTimeout(timer[2]); - return true; - } + return ['loc', [source || null, [start.line, start.column], [end.line, end.column]]]; + }; + + return TemplateCompiler; + })(); + + function isHelperInvocation(mustache) { + return mustache.params && mustache.params.length > 0 || mustache.hash && mustache.hash.pairs.length > 0; } + function isSelfGet(mustache) { + var parts = mustache.path.parts; - return false; - }, + return parts[0] === null; + } + function isLocalVariable(mustache, symbols) { + var parts = mustache.path.parts; - _runExpiredTimers: function () { - this._timerTimeoutId = undefined; - this.run(this, this._scheduleExpiredTimers); - }, + return parts.length === 1 && symbols && symbols.hasLocalVariable(parts[0]); + } + function isYield(_ref15) { + var path = _ref15.path; - _scheduleExpiredTimers: function () { - var n = Date.now(); - var timers = this._timers; - var i = 0; - var l = timers.length; - for (; i < l; i += 2) { - var executeAt = timers[i]; - var fn = timers[i+1]; - if (executeAt <= n) { - this.schedule(this.options.defaultQueue, null, fn); - } else { - break; - } + return path.original === 'yield'; } - timers.splice(0, i); - this._installTimerTimeout(); - }, + function isPartial(_ref16) { + var path = _ref16.path; - _reinstallTimerTimeout: function () { - this._clearTimerTimeout(); - this._installTimerTimeout(); - }, + return path.original === 'partial'; + } + function isDebugger(_ref17) { + var path = _ref17.path; - _clearTimerTimeout: function () { - if (!this._timerTimeoutId) { - return; + return path.original === 'debugger'; } - this._platform.clearTimeout(this._timerTimeoutId); - this._timerTimeoutId = undefined; - }, + function isArg(_ref18) { + var path = _ref18.path; - _installTimerTimeout: function () { - if (!this._timers.length) { - return; + return path.data; } - var minExpiresAt = this._timers[0]; - var n = Date.now(); - var wait = Math.max(0, minExpiresAt - n); - this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); - } -}; + function isLiteral(_ref19) { + var path = _ref19.path; -Backburner.prototype.schedule = Backburner.prototype.defer; -Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; -Backburner.prototype.later = Backburner.prototype.setTimeout; + return path.type === 'StringLiteral' || path.type === 'BooleanLiteral' || path.type === 'NumberLiteral' || path.type === 'NullLiteral' || path.type === 'UndefinedLiteral'; + } + function isHasBlock(_ref20) { + var path = _ref20.path; -function getOnError(options) { - return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); -} + return path.original === 'has-block'; + } + function isHasBlockParams(_ref21) { + var path = _ref21.path; -function createAutorun(backburner) { - var setTimeout = backburner._platform.setTimeout; - backburner.begin(); - backburner._autorun = setTimeout(function() { - backburner._autorun = null; - backburner.end(); - }, 0); -} + return path.original === 'has-block-params'; + } + function isBuiltInHelper(expr) { + return isHasBlock(expr) || isHasBlockParams(expr); + } + function assertValidYield(_ref22) { + var hash = _ref22.hash; -function findDebouncee(target, method, debouncees) { - return findItem(target, method, debouncees); -} + var pairs = hash.pairs; + if (pairs.length === 1 && pairs[0].key !== 'to' || pairs.length > 1) { + throw new Error('yield only takes a single named argument: \'to\''); + } else if (pairs.length === 1 && pairs[0].value.type !== 'StringLiteral') { + throw new Error('you can only yield to a literal value'); + } else if (pairs.length === 0) { + return 'default'; + } else { + return pairs[0].value.value; + } + } + function assertValidPartial(_ref23) { + var params = _ref23.params; + var hash = _ref23.hash; + var escaped = _ref23.escaped; + var loc = _ref23.loc; -function findThrottler(target, method, throttlers) { - return findItem(target, method, throttlers); -} + if (params && params.length !== 1) { + throw new Error('Partial found with no arguments. You must specify a template name. (on line ' + loc.start.line + ')'); + } else if (hash && hash.pairs.length > 0) { + throw new Error('partial does not take any named arguments (on line ' + loc.start.line + ')'); + } else if (!escaped) { + throw new Error('{{{partial ...}}} is not supported, please use {{partial ...}} instead (on line ' + loc.start.line + ')'); + } + return params; + } + function assertValidHasBlockUsage(type, _ref24) { + var params = _ref24.params; + var hash = _ref24.hash; + var loc = _ref24.loc; -function findItem(target, method, collection) { - var item; - var index = -1; + if (hash && hash.pairs.length > 0) { + throw new Error(type + ' does not take any named arguments'); + } + if (params.length === 0) { + return 'default'; + } else if (params.length === 1) { + if (params[0].type === 'StringLiteral') { + return params[0].value; + } else { + throw new Error('you can only yield to a literal value (on line ' + loc.start.line + ')'); + } + } else { + throw new Error(type + ' only takes a single positional argument (on line ' + loc.start.line + ')'); + } + } + function assertValidDebuggerUsage(_ref25) { + var params = _ref25.params; + var hash = _ref25.hash; - for (var i = 0, l = collection.length; i < l; i++) { - item = collection[i]; - if (item[0] === target && item[1] === method) { - index = i; - break; + if (hash && hash.pairs.length > 0) { + throw new Error('debugger does not take any named arguments'); + } + if (params.length === 0) { + return 'default'; + } else { + throw new Error('debugger does not take any positional arguments'); + } } - } - return index; -} + var defaultId = (function () { + var idFn = undefined; + return function () { + if (!idFn) { + if (typeof require === 'function') { + try { + (function () { + /* tslint:disable:no-require-imports */ + var crypto = require('crypto'); + /* tslint:enable:no-require-imports */ + idFn = function (src) { + var hash = crypto.createHash('sha1'); + hash.update(src, 'utf8'); + // trim to 6 bytes of data (2^48 - 1) + return hash.digest('base64').substring(0, 8); + }; + idFn("test"); + })(); + } catch (e) { + idFn = null; + } + } + if (!idFn) { + idFn = function () { + return null; + }; + } + } + return idFn; + }; + })(); + function precompile(string, options) { + var opts = options || { + id: defaultId(), + meta: {} + }; + var ast = _glimmerSyntax.preprocess(string, opts); -function clearItems(item) { - this._platform.clearTimeout(item[2]); -} + var _TemplateCompiler$compile = TemplateCompiler.compile(opts, ast); -exports['default'] = Backburner; + var block = _TemplateCompiler$compile.block; + var meta = _TemplateCompiler$compile.meta; -Object.defineProperty(exports, '__esModule', { value: true }); + var idFn = opts.id || defaultId(); + var blockJSON = JSON.stringify(block.toJSON()); + var templateJSONObject = { + id: idFn(JSON.stringify(meta) + blockJSON), + block: blockJSON, + meta: meta + }; + // JSON is javascript + return JSON.stringify(templateJSONObject); + } + exports.precompile = precompile; + exports.TemplateVisitor = TemplateVisitor; }); -enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - 'use strict'; +enifed("@glimmer/reference", ["exports", "@glimmer/util"], function (exports, _glimmerUtil) { + "use strict"; - function K() {} + var CONSTANT = 0; + var INITIAL = 1; + var VOLATILE = NaN; - function consoleMethod(name) { - var consoleObj = undefined; - if (_emberEnvironment.context.imports.console) { - consoleObj = _emberEnvironment.context.imports.console; - } else if (typeof console !== 'undefined') { - consoleObj = console; - } + var RevisionTag = (function () { + function RevisionTag() {} - var method = typeof consoleObj === 'object' ? consoleObj[name] : null; + RevisionTag.prototype.validate = function validate(snapshot) { + return this.value() === snapshot; + }; - if (typeof method !== 'function') { - return; - } + return RevisionTag; + })(); - if (typeof method.bind === 'function') { - return method.bind(consoleObj); - } + var $REVISION = INITIAL; - return function () { - method.apply(consoleObj, arguments); - }; - } + var DirtyableTag = (function (_RevisionTag) { + babelHelpers.inherits(DirtyableTag, _RevisionTag); - function assertPolyfill(test, message) { - if (!test) { - try { - // attempt to preserve the stack - throw new Error('assertion failed: ' + message); - } catch (error) { - setTimeout(function () { - throw error; - }, 0); - } - } - } + function DirtyableTag() { + var revision = arguments.length <= 0 || arguments[0] === undefined ? $REVISION : arguments[0]; - /** - Inside Ember-Metal, simply uses the methods from `imports.console`. - Override this to provide more robust logging functionality. - - @class Logger - @namespace Ember - @public - */ - exports.default = { - /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.log('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method log - @for Ember.Logger - @param {*} arguments - @public - */ - log: consoleMethod('log') || K, + _RevisionTag.call(this); + this.revision = revision; + } - /** - Prints the arguments to the console with a warning icon. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - Ember.Logger.warn('Something happened!'); - // "Something happened!" will be printed to the console with a warning icon. - ``` - @method warn - @for Ember.Logger - @param {*} arguments - @public - */ - warn: consoleMethod('warn') || K, + DirtyableTag.prototype.value = function value() { + return this.revision; + }; - /** - Prints the arguments to the console with an error icon, red text and a stack trace. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - Ember.Logger.error('Danger! Danger!'); - // "Danger! Danger!" will be printed to the console in red text. - ``` - @method error - @for Ember.Logger - @param {*} arguments - @public - */ - error: consoleMethod('error') || K, + DirtyableTag.prototype.dirty = function dirty() { + this.revision = ++$REVISION; + }; - /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.info('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method info - @for Ember.Logger - @param {*} arguments - @public - */ - info: consoleMethod('info') || K, + return DirtyableTag; + })(RevisionTag); - /** - Logs the arguments to the console in blue text. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.debug('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method debug - @for Ember.Logger - @param {*} arguments - @public - */ - debug: consoleMethod('debug') || consoleMethod('info') || K, - - /** - If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. - ```javascript - Ember.Logger.assert(true); // undefined - Ember.Logger.assert(true === false); // Throws an Assertion failed error. - Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message. - ``` - @method assert - @for Ember.Logger - @param {Boolean} bool Value to test - @param {String} message Assertion message on failed - @public - */ - assert: consoleMethod('assert') || assertPolyfill - }; -}); -enifed('ember-debug/deprecate', ['exports', 'ember-metal', 'ember-console', 'ember-environment', 'ember-debug/handlers'], function (exports, _emberMetal, _emberConsole, _emberEnvironment, _emberDebugHandlers) { - /*global __fail__*/ - - 'use strict'; + function combineTagged(tagged) { + var optimized = []; + for (var i = 0, l = tagged.length; i < l; i++) { + var tag = tagged[i].tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function combineSlice(slice) { + var optimized = []; + var node = slice.head(); + while (node !== null) { + var tag = node.tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag !== CONSTANT_TAG) optimized.push(tag); + node = slice.nextNode(node); + } + return _combine(optimized); + } + function combine(tags) { + var optimized = []; + for (var i = 0, l = tags.length; i < l; i++) { + var tag = tags[i]; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function _combine(tags) { + switch (tags.length) { + case 0: + return CONSTANT_TAG; + case 1: + return tags[0]; + case 2: + return new TagsPair(tags[0], tags[1]); + default: + return new TagsCombinator(tags); + } + ; + } - exports.registerHandler = registerHandler; - exports.default = deprecate; + var CachedTag = (function (_RevisionTag2) { + babelHelpers.inherits(CachedTag, _RevisionTag2); - function registerHandler(handler) { - _emberDebugHandlers.registerHandler('deprecate', handler); - } + function CachedTag() { + _RevisionTag2.apply(this, arguments); + this.lastChecked = null; + this.lastValue = null; + } - function formatMessage(_message, options) { - var message = _message; + CachedTag.prototype.value = function value() { + var lastChecked = this.lastChecked; + var lastValue = this.lastValue; - if (options && options.id) { - message = message + (' [deprecation id: ' + options.id + ']'); - } + if (lastChecked !== $REVISION) { + this.lastChecked = $REVISION; + this.lastValue = lastValue = this.compute(); + } + return this.lastValue; + }; - if (options && options.url) { - message += ' See ' + options.url + ' for more details.'; - } + CachedTag.prototype.invalidate = function invalidate() { + this.lastChecked = null; + }; - return message; - } + return CachedTag; + })(RevisionTag); - registerHandler(function logDeprecationToConsole(message, options) { - var updatedMessage = formatMessage(message, options); + var TagsPair = (function (_CachedTag) { + babelHelpers.inherits(TagsPair, _CachedTag); - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage); - }); + function TagsPair(first, second) { + _CachedTag.call(this); + this.first = first; + this.second = second; + } - var captureErrorForStack = undefined; + TagsPair.prototype.compute = function compute() { + return Math.max(this.first.value(), this.second.value()); + }; - if (new Error().stack) { - captureErrorForStack = function () { - return new Error(); - }; - } else { - captureErrorForStack = function () { - try { - __fail__.fail(); - } catch (e) { - return e; - } - }; - } + return TagsPair; + })(CachedTag); - registerHandler(function logDeprecationStackTrace(message, options, next) { - if (_emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION) { - var stackStr = ''; - var error = captureErrorForStack(); - var stack = undefined; + var TagsCombinator = (function (_CachedTag2) { + babelHelpers.inherits(TagsCombinator, _CachedTag2); - if (error.stack) { - if (error['arguments']) { - // Chrome - stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); - stack.shift(); - } else { - // Firefox - stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); + function TagsCombinator(tags) { + _CachedTag2.call(this); + this.tags = tags; } - stackStr = '\n ' + stack.slice(2).join('\n '); - } + TagsCombinator.prototype.compute = function compute() { + var tags = this.tags; - var updatedMessage = formatMessage(message, options); + var max = -1; + for (var i = 0; i < tags.length; i++) { + var value = tags[i].value(); + max = Math.max(value, max); + } + return max; + }; - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage + stackStr); - } else { - next.apply(undefined, arguments); - } - }); + return TagsCombinator; + })(CachedTag); - registerHandler(function raiseOnDeprecation(message, options, next) { - if (_emberEnvironment.ENV.RAISE_ON_DEPRECATION) { - var updatedMessage = formatMessage(message); + var UpdatableTag = (function (_CachedTag3) { + babelHelpers.inherits(UpdatableTag, _CachedTag3); - throw new _emberMetal.Error(updatedMessage); - } else { - next.apply(undefined, arguments); - } - }); + function UpdatableTag(tag) { + _CachedTag3.call(this); + this.tag = tag; + this.lastUpdated = INITIAL; + } - var missingOptionsDeprecation = 'When calling `Ember.deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; - exports.missingOptionsDeprecation = missingOptionsDeprecation; - var missingOptionsIdDeprecation = 'When calling `Ember.deprecate` you must provide `id` in options.'; - exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; - var missingOptionsUntilDeprecation = 'When calling `Ember.deprecate` you must provide `until` in options.'; + ////////// - exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation; - /** - @module ember - @submodule ember-debug - */ + UpdatableTag.prototype.compute = function compute() { + return Math.max(this.lastUpdated, this.tag.value()); + }; - /** - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only). - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method deprecate - @param {String} message A description of the deprecation. - @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. - @param {Object} options - @param {String} options.id A unique id for this deprecation. The id can be - used by Ember debugging tools to change the behavior (raise, log or silence) - for that specific deprecation. The id should be namespaced by dots, e.g. - "view.helper.select". - @param {string} options.until The version of Ember when this deprecation - warning will be removed. - @param {String} [options.url] An optional url to the transition guide on the - emberjs.com website. - @for Ember - @public - */ + UpdatableTag.prototype.update = function update(tag) { + if (tag !== this.tag) { + this.tag = tag; + this.lastUpdated = $REVISION; + this.invalidate(); + } + }; - function deprecate(message, test, options) { - if (!options || !options.id && !options.until) { - deprecate(missingOptionsDeprecation, false, { - id: 'ember-debug.deprecate-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + return UpdatableTag; + })(CachedTag); - if (options && !options.id) { - deprecate(missingOptionsIdDeprecation, false, { - id: 'ember-debug.deprecate-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + var CONSTANT_TAG = new ((function (_RevisionTag3) { + babelHelpers.inherits(ConstantTag, _RevisionTag3); - if (options && !options.until) { - deprecate(missingOptionsUntilDeprecation, options && options.until, { - id: 'ember-debug.deprecate-until-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } - - _emberDebugHandlers.invoke.apply(undefined, ['deprecate'].concat(babelHelpers.slice.call(arguments))); - } -}); -enifed("ember-debug/handlers", ["exports"], function (exports) { - "use strict"; + function ConstantTag() { + _RevisionTag3.apply(this, arguments); + } - exports.registerHandler = registerHandler; - exports.invoke = invoke; - var HANDLERS = {}; + ConstantTag.prototype.value = function value() { + return CONSTANT; + }; - exports.HANDLERS = HANDLERS; + return ConstantTag; + })(RevisionTag))(); + var VOLATILE_TAG = new ((function (_RevisionTag4) { + babelHelpers.inherits(VolatileTag, _RevisionTag4); - function registerHandler(type, callback) { - var nextHandler = HANDLERS[type] || function () {}; + function VolatileTag() { + _RevisionTag4.apply(this, arguments); + } - HANDLERS[type] = function (message, options) { - callback(message, options, nextHandler); - }; - } + VolatileTag.prototype.value = function value() { + return VOLATILE; + }; - function invoke(type, message, test, options) { - if (test) { - return; - } + return VolatileTag; + })(RevisionTag))(); + var CURRENT_TAG = new ((function (_DirtyableTag) { + babelHelpers.inherits(CurrentTag, _DirtyableTag); - var handlerForType = HANDLERS[type]; + function CurrentTag() { + _DirtyableTag.apply(this, arguments); + } - if (!handlerForType) { - return; - } + CurrentTag.prototype.value = function value() { + return $REVISION; + }; - if (handlerForType) { - handlerForType(message, options); - } - } -}); -enifed('ember-debug/index', ['exports', 'ember-metal', 'ember-environment', 'ember-console', 'ember-debug/deprecate', 'ember-debug/warn'], function (exports, _emberMetal, _emberEnvironment, _emberConsole, _emberDebugDeprecate, _emberDebugWarn) { - 'use strict'; + return CurrentTag; + })(DirtyableTag))(); - exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; + var CachedReference = (function () { + function CachedReference() { + this.lastRevision = null; + this.lastValue = null; + } - /** - @module ember - @submodule ember-debug - */ + CachedReference.prototype.value = function value() { + var tag = this.tag; + var lastRevision = this.lastRevision; + var lastValue = this.lastValue; - /** - @class Ember - @public - */ + if (!lastRevision || !tag.validate(lastRevision)) { + lastValue = this.lastValue = this.compute(); + this.lastRevision = tag.value(); + } + return lastValue; + }; - /** - Define an assertion that will throw an exception if the condition is not met. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - // Test for truthiness - Ember.assert('Must pass a valid object', obj); - - // Fail unconditionally - Ember.assert('This code path should never be run'); - ``` - - @method assert - @param {String} desc A description of the assertion. This will become - the text of the Error thrown if the assertion fails. - @param {Boolean} test Must be truthy for the assertion to pass. If - falsy, an exception will be thrown. - @public - */ - _emberMetal.setDebugFunction('assert', function assert(desc, test) { - if (!test) { - throw new _emberMetal.Error('Assertion Failed: ' + desc); - } - }); + CachedReference.prototype.invalidate = function invalidate() { + this.lastRevision = null; + }; - /** - Display a debug notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.debug('I\'m a debug notice!'); - ``` - - @method debug - @param {String} message A debug message to display. - @public - */ - _emberMetal.setDebugFunction('debug', function debug(message) { - _emberConsole.default.debug('DEBUG: ' + message); - }); + return CachedReference; + })(); - /** - Display an info notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method info - @private - */ - _emberMetal.setDebugFunction('info', function info() { - _emberConsole.default.info.apply(undefined, arguments); - }); + var MapperReference = (function (_CachedReference) { + babelHelpers.inherits(MapperReference, _CachedReference); - /** - Alias an old, deprecated method with its new counterpart. - - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only) when the assigned method is called. - - * In a production build, this method is defined as an empty function (NOP). - - ```javascript - Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod); - ``` - - @method deprecateFunc - @param {String} message A description of the deprecation. - @param {Object} [options] The options object for Ember.deprecate. - @param {Function} func The new function called to replace its deprecated counterpart. - @return {Function} A new function that wraps the original function with a deprecation warning - @private - */ - _emberMetal.setDebugFunction('deprecateFunc', function deprecateFunc() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + function MapperReference(reference, mapper) { + _CachedReference.call(this); + this.tag = reference.tag; + this.reference = reference; + this.mapper = mapper; + } - if (args.length === 3) { - var _ret = (function () { - var message = args[0]; - var options = args[1]; - var func = args[2]; + MapperReference.prototype.compute = function compute() { + var reference = this.reference; + var mapper = this.mapper; - return { - v: function () { - _emberMetal.deprecate(message, false, options); - return func.apply(this, arguments); - } + return mapper(reference.value()); }; - })(); - - if (typeof _ret === 'object') return _ret.v; - } else { - var _ret2 = (function () { - var message = args[0]; - var func = args[1]; - return { - v: function () { - _emberMetal.deprecate(message); - return func.apply(this, arguments); - } - }; - })(); + return MapperReference; + })(CachedReference); - if (typeof _ret2 === 'object') return _ret2.v; + function map(reference, mapper) { + return new MapperReference(reference, mapper); } - }); + ////////// - /** - Run a function meant for debugging. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.runInDebug(() => { - Ember.Component.reopen({ - didInsertElement() { - console.log("I'm happy"); + var ReferenceCache = (function () { + function ReferenceCache(reference) { + this.lastValue = null; + this.lastRevision = null; + this.initialized = false; + this.tag = reference.tag; + this.reference = reference; } - }); - }); - ``` - - @method runInDebug - @param {Function} func The function to be executed. - @since 1.5.0 - @public - */ - _emberMetal.setDebugFunction('runInDebug', function runInDebug(func) { - func(); - }); - _emberMetal.setDebugFunction('debugSeal', function debugSeal(obj) { - Object.seal(obj); - }); + ReferenceCache.prototype.peek = function peek() { + if (!this.initialized) { + return this.initialize(); + } + return this.lastValue; + }; - _emberMetal.setDebugFunction('debugFreeze', function debugFreeze(obj) { - Object.freeze(obj); - }); + ReferenceCache.prototype.revalidate = function revalidate() { + if (!this.initialized) { + return this.initialize(); + } + var reference = this.reference; + var lastRevision = this.lastRevision; - _emberMetal.setDebugFunction('deprecate', _emberDebugDeprecate.default); + var tag = reference.tag; + if (tag.validate(lastRevision)) return NOT_MODIFIED; + this.lastRevision = tag.value(); + var lastValue = this.lastValue; - _emberMetal.setDebugFunction('warn', _emberDebugWarn.default); + var value = reference.value(); + if (value === lastValue) return NOT_MODIFIED; + this.lastValue = value; + return value; + }; - /** - Will call `Ember.warn()` if ENABLE_OPTIONAL_FEATURES or - any specific FEATURES flag is truthy. - - This method is called automatically in debug canary builds. - - @private - @method _warnIfUsingStrippedFeatureFlags - @return {void} - */ + ReferenceCache.prototype.initialize = function initialize() { + var reference = this.reference; - function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featuresWereStripped) { - if (featuresWereStripped) { - _emberMetal.warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + var value = this.lastValue = reference.value(); + this.lastRevision = reference.tag.value(); + this.initialized = true; + return value; + }; - var keys = Object.keys(FEATURES || {}); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key === 'isEnabled' || !(key in knownFeatures)) { - continue; + return ReferenceCache; + })(); + + var NOT_MODIFIED = "adb3b78e-3d22-4e4b-877a-6317c2c5c145"; + function isModified(value) { + return value !== NOT_MODIFIED; + } + + var ConstReference = (function () { + function ConstReference(inner) { + this.inner = inner; + this.tag = CONSTANT_TAG; } - _emberMetal.warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); - } + ConstReference.prototype.value = function value() { + return this.inner; + }; + + return ConstReference; + })(); + + function isConst(reference) { + return reference.tag === CONSTANT_TAG; } - } - if (!_emberMetal.isTesting()) { - (function () { - // Complain if they're using FEATURE flags in builds other than canary - _emberMetal.FEATURES['features-stripped-test'] = true; - var featuresWereStripped = true; + var ListItem = (function (_ListNode) { + babelHelpers.inherits(ListItem, _ListNode); - if (false) { - featuresWereStripped = false; - } + function ListItem(iterable, result) { + _ListNode.call(this, iterable.valueReferenceFor(result)); + this.retained = false; + this.seen = false; + this.key = result.key; + this.iterable = iterable; + this.memo = iterable.memoReferenceFor(result); + } - delete _emberMetal.FEATURES['features-stripped-test']; - _warnIfUsingStrippedFeatureFlags(_emberEnvironment.ENV.FEATURES, _emberMetal.DEFAULT_FEATURES, featuresWereStripped); + ListItem.prototype.update = function update(item) { + this.retained = true; + this.iterable.updateValueReference(this.value, item); + this.iterable.updateMemoReference(this.memo, item); + }; - // Inform the developer about the Ember Inspector if not installed. - var isFirefox = _emberEnvironment.environment.isFirefox; - var isChrome = _emberEnvironment.environment.isChrome; + ListItem.prototype.shouldRemove = function shouldRemove() { + return !this.retained; + }; - if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { - window.addEventListener('load', function () { - if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) { - var downloadURL; + ListItem.prototype.reset = function reset() { + this.retained = false; + this.seen = false; + }; - if (isChrome) { - downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'; - } else if (isFirefox) { - downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; - } + return ListItem; + })(_glimmerUtil.ListNode); - _emberMetal.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); - } - }, false); - } - })(); - } - /** - @public - @class Ember.Debug - */ - _emberMetal.default.Debug = {}; + var IterationArtifacts = (function () { + function IterationArtifacts(iterable) { + this.map = _glimmerUtil.dict(); + this.list = new _glimmerUtil.LinkedList(); + this.tag = iterable.tag; + this.iterable = iterable; + } - /** - Allows for runtime registration of handler functions that override the default deprecation behavior. - Deprecations are invoked by calls to [Ember.deprecate](http://emberjs.com/api/classes/Ember.html#method_deprecate). - The following example demonstrates its usage by registering a handler that throws an error if the - message contains the word "should", otherwise defers to the default handler. - - ```javascript - Ember.Debug.registerDeprecationHandler((message, options, next) => { - if (message.indexOf('should') !== -1) { - throw new Error(`Deprecation message with should: ${message}`); - } else { - // defer to whatever handler was registered before this one - next(message, options); - } - }); - ``` - - The handler function takes the following arguments: - - - - @public - @static - @method registerDeprecationHandler - @param handler {Function} A function to handle deprecation calls. - @since 2.1.0 - */ - _emberMetal.default.Debug.registerDeprecationHandler = _emberDebugDeprecate.registerHandler; - /** - Allows for runtime registration of handler functions that override the default warning behavior. - Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). - The following example demonstrates its usage by registering a handler that does nothing overriding Ember's - default warning behavior. - - ```javascript - // next is not called, so no warnings get the default behavior - Ember.Debug.registerWarnHandler(() => {}); - ``` - - The handler function takes the following arguments: - - - - @public - @static - @method registerWarnHandler - @param handler {Function} A function to handle warnings. - @since 2.1.0 - */ - _emberMetal.default.Debug.registerWarnHandler = _emberDebugWarn.registerHandler; + IterationArtifacts.prototype.isEmpty = function isEmpty() { + var iterator = this.iterator = this.iterable.iterate(); + return iterator.isEmpty(); + }; - /* - We are transitioning away from `ember.js` to `ember.debug.js` to make - it much clearer that it is only for local development purposes. - - This flag value is changed by the tooling (by a simple string replacement) - so that if `ember.js` (which must be output for backwards compat reasons) is - used a nice helpful warning message will be printed out. - */ - var runningNonEmberDebugJS = false; - exports.runningNonEmberDebugJS = runningNonEmberDebugJS; - if (runningNonEmberDebugJS) { - _emberMetal.warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); - } -}); -// reexports -enifed('ember-debug/warn', ['exports', 'ember-console', 'ember-metal', 'ember-debug/handlers'], function (exports, _emberConsole, _emberMetal, _emberDebugHandlers) { - 'use strict'; + IterationArtifacts.prototype.iterate = function iterate() { + var iterator = this.iterator || this.iterable.iterate(); + this.iterator = null; + return iterator; + }; - exports.registerHandler = registerHandler; - exports.default = warn; + IterationArtifacts.prototype.has = function has(key) { + return !!this.map[key]; + }; - function registerHandler(handler) { - _emberDebugHandlers.registerHandler('warn', handler); - } + IterationArtifacts.prototype.get = function get(key) { + return this.map[key]; + }; - registerHandler(function logWarning(message, options) { - _emberConsole.default.warn('WARNING: ' + message); - if ('trace' in _emberConsole.default) { - _emberConsole.default.trace(); - } - }); + IterationArtifacts.prototype.wasSeen = function wasSeen(key) { + var node = this.map[key]; + return node && node.seen; + }; - var missingOptionsDeprecation = 'When calling `Ember.warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; - exports.missingOptionsDeprecation = missingOptionsDeprecation; - var missingOptionsIdDeprecation = 'When calling `Ember.warn` you must provide `id` in options.'; + IterationArtifacts.prototype.append = function append(item) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; - /** - @module ember - @submodule ember-debug - */ + var node = map[item.key] = new ListItem(iterable, item); + list.append(node); + return node; + }; - /** - Display a warning with the provided message. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method warn - @param {String} message A warning to display. - @param {Boolean} test An optional boolean. If falsy, the warning - will be displayed. - @param {Object} options An object that can be used to pass a unique - `id` for this warning. The `id` can be used by Ember debugging tools - to change the behavior (raise, log, or silence) for that specific warning. - The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" - @for Ember - @public - */ + IterationArtifacts.prototype.insertBefore = function insertBefore(item, reference) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - function warn(message, test, options) { - if (!options) { - _emberMetal.deprecate(missingOptionsDeprecation, false, { - id: 'ember-debug.warn-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + var node = map[item.key] = new ListItem(iterable, item); + node.retained = true; + list.insertBefore(node, reference); + return node; + }; - if (options && !options.id) { - _emberMetal.deprecate(missingOptionsIdDeprecation, false, { - id: 'ember-debug.warn-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + IterationArtifacts.prototype.move = function move(item, reference) { + var list = this.list; - _emberDebugHandlers.invoke.apply(undefined, ['warn'].concat(babelHelpers.slice.call(arguments))); - } -}); -enifed('ember-environment/global', ['exports'], function (exports) { - /* globals global, window, self, mainContext */ + item.retained = true; + list.remove(item); + list.insertBefore(item, reference); + }; - // from lodash to catch fake globals - 'use strict'; + IterationArtifacts.prototype.remove = function remove(item) { + var list = this.list; - function checkGlobal(value) { - return value && value.Object === Object ? value : undefined; - } + list.remove(item); + delete this.map[item.key]; + }; - // element ids can ruin global miss checks - function checkElementIdShadowing(value) { - return value && value.nodeType === undefined ? value : undefined; - } + IterationArtifacts.prototype.nextNode = function nextNode(item) { + return this.list.nextNode(item); + }; - // export real global - exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper - new Function('return this')(); - // eval outside of strict mode -}); -enifed('ember-environment/index', ['exports', 'ember-environment/global', 'ember-environment/utils'], function (exports, _emberEnvironmentGlobal, _emberEnvironmentUtils) { - /* globals module */ - 'use strict'; + IterationArtifacts.prototype.head = function head() { + return this.list.head(); + }; - /** - 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 - backwards compatibility with earlier versions of Ember). The `EmberENV` - hash must be created before loading Ember. - - @class EmberENV - @type Object - @public - */ - var ENV = typeof _emberEnvironmentGlobal.default.EmberENV === 'object' && _emberEnvironmentGlobal.default.EmberENV || typeof _emberEnvironmentGlobal.default.ENV === 'object' && _emberEnvironmentGlobal.default.ENV || {}; + return IterationArtifacts; + })(); - exports.ENV = ENV; - // ENABLE_ALL_FEATURES was documented, but you can't actually enable non optional features. - if (ENV.ENABLE_ALL_FEATURES) { - ENV.ENABLE_OPTIONAL_FEATURES = true; - } + var ReferenceIterator = (function () { + // if anyone needs to construct this object with something other than + // an iterable, let @wycats know. - /** - Determines whether Ember should add to `Array`, `Function`, and `String` - native object prototypes, a few extra methods in order to provide a more - friendly API. - - We generally recommend leaving this option set to true however, if you need - to turn it off, you can add the configuration property - `EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`. - - Note, when disabled (the default configuration for Ember Addons), you will - instead have to access all methods and functions from the Ember - namespace. - - @property EXTEND_PROTOTYPES - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.EXTEND_PROTOTYPES = _emberEnvironmentUtils.normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); + function ReferenceIterator(iterable) { + this.iterator = null; + var artifacts = new IterationArtifacts(iterable); + this.artifacts = artifacts; + } - /** - The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log - a full stack trace during deprecation warnings. - - @property LOG_STACKTRACE_ON_DEPRECATION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_STACKTRACE_ON_DEPRECATION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); + ReferenceIterator.prototype.next = function next() { + var artifacts = this.artifacts; - /** - The `LOG_VERSION` property, when true, tells Ember to log versions of all - dependent libraries in use. - - @property LOG_VERSION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_VERSION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_VERSION); + var iterator = this.iterator = this.iterator || artifacts.iterate(); + var item = iterator.next(); + if (!item) return null; + return artifacts.append(item); + }; - // default false - ENV.MODEL_FACTORY_INJECTIONS = _emberEnvironmentUtils.defaultFalse(ENV.MODEL_FACTORY_INJECTIONS); + return ReferenceIterator; + })(); - /** - Debug parameter you can turn on. This will log all bindings that fire to - the console. This should be disabled in production code. Note that you - can also enable this from the console or temporarily. - - @property LOG_BINDINGS - @for EmberENV - @type Boolean - @default false - @public - */ - ENV.LOG_BINDINGS = _emberEnvironmentUtils.defaultFalse(ENV.LOG_BINDINGS); + var Phase; + (function (Phase) { + Phase[Phase["Append"] = 0] = "Append"; + Phase[Phase["Prune"] = 1] = "Prune"; + Phase[Phase["Done"] = 2] = "Done"; + })(Phase || (Phase = {})); - ENV.RAISE_ON_DEPRECATION = _emberEnvironmentUtils.defaultFalse(ENV.RAISE_ON_DEPRECATION); + var IteratorSynchronizer = (function () { + function IteratorSynchronizer(_ref) { + var target = _ref.target; + var artifacts = _ref.artifacts; - // check if window exists and actually is the global - var hasDOM = typeof window !== 'undefined' && window === _emberEnvironmentGlobal.default && window.document && window.document.createElement && !ENV.disableBrowserEnvironment; // is this a public thing? + this.target = target; + this.artifacts = artifacts; + this.iterator = artifacts.iterate(); + this.current = artifacts.head(); + } - // legacy imports/exports/lookup stuff (should we keep this??) - var originalContext = _emberEnvironmentGlobal.default.Ember || {}; + IteratorSynchronizer.prototype.sync = function sync() { + var phase = Phase.Append; + while (true) { + switch (phase) { + case Phase.Append: + phase = this.nextAppend(); + break; + case Phase.Prune: + phase = this.nextPrune(); + break; + case Phase.Done: + this.nextDone(); + return; + } + } + }; - var context = { - // import jQuery - imports: originalContext.imports || _emberEnvironmentGlobal.default, - // export Ember - exports: originalContext.exports || _emberEnvironmentGlobal.default, - // search for Namespaces - lookup: originalContext.lookup || _emberEnvironmentGlobal.default - }; + IteratorSynchronizer.prototype.advanceToKey = function advanceToKey(key) { + var current = this.current; + var artifacts = this.artifacts; - exports.context = context; - // TODO: cleanup single source of truth issues with this stuff - var environment = hasDOM ? { - hasDOM: true, - isChrome: !!window.chrome && !window.opera, - isFirefox: typeof InstallTrigger !== 'undefined', - isPhantom: !!window.callPhantom, - location: window.location, - history: window.history, - userAgent: window.navigator.userAgent, - window: window - } : { - hasDOM: false, - isChrome: false, - isFirefox: false, - isPhantom: false, - location: null, - history: null, - userAgent: 'Lynx (textmode)', - window: null - }; - exports.environment = environment; -}); -enifed("ember-environment/utils", ["exports"], function (exports) { - "use strict"; + var seek = current; + while (seek && seek.key !== key) { + seek.seen = true; + seek = artifacts.nextNode(seek); + } + this.current = seek && artifacts.nextNode(seek); + }; - exports.defaultTrue = defaultTrue; - exports.defaultFalse = defaultFalse; - exports.normalizeExtendPrototypes = normalizeExtendPrototypes; + IteratorSynchronizer.prototype.nextAppend = function nextAppend() { + var iterator = this.iterator; + var current = this.current; + var artifacts = this.artifacts; - function defaultTrue(v) { - return v === false ? false : true; - } - - function defaultFalse(v) { - return v === true ? true : false; - } - - function normalizeExtendPrototypes(obj) { - if (obj === false) { - return { String: false, Array: false, Function: false }; - } else if (!obj || obj === true) { - return { String: true, Array: true, Function: true }; - } else { - return { - String: defaultTrue(obj.String), - Array: defaultTrue(obj.Array), - Function: defaultTrue(obj.Function) - }; - } - } -}); -enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) { - 'use strict'; - - exports.default = alias; - exports.AliasedProperty = AliasedProperty; - - function alias(altKey) { - return new AliasedProperty(altKey); - } + var item = iterator.next(); + if (item === null) { + return this.startPrune(); + } + var key = item.key; - function AliasedProperty(altKey) { - this.isDescriptor = true; - this.altKey = altKey; - this._dependentKeys = [altKey]; - } + if (current && current.key === key) { + this.nextRetain(item); + } else if (artifacts.has(key)) { + this.nextMove(item); + } else { + this.nextInsert(item); + } + return Phase.Append; + }; - AliasedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); + IteratorSynchronizer.prototype.nextRetain = function nextRetain(item) { + var artifacts = this.artifacts; + var current = this.current; - AliasedProperty.prototype.setup = function (obj, keyName) { - _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName); - var meta = _emberMetalMeta.meta(obj); - if (meta.peekWatching(keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; + current = _glimmerUtil.expect(current, 'BUG: current is empty'); + current.update(item); + this.current = artifacts.nextNode(current); + this.target.retain(item.key, current.value, current.memo); + }; - AliasedProperty.prototype._addDependentKeyIfMissing = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (!meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; + IteratorSynchronizer.prototype.nextMove = function nextMove(item) { + var current = this.current; + var artifacts = this.artifacts; + var target = this.target; + var key = item.key; - AliasedProperty.prototype._removeDependentKeyIfAdded = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; + var found = artifacts.get(item.key); + found.update(item); + if (artifacts.wasSeen(item.key)) { + artifacts.move(found, current); + target.move(found.key, found.value, found.memo, current ? current.key : null); + } else { + this.advanceToKey(key); + } + }; - AliasedProperty.prototype.willWatch = AliasedProperty.prototype._addDependentKeyIfMissing; - AliasedProperty.prototype.didUnwatch = AliasedProperty.prototype._removeDependentKeyIfAdded; - AliasedProperty.prototype.teardown = AliasedProperty.prototype._removeDependentKeyIfAdded; + IteratorSynchronizer.prototype.nextInsert = function nextInsert(item) { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) { - this._addDependentKeyIfMissing(obj, keyName); + var node = artifacts.insertBefore(item, current); + target.insert(node.key, node.value, node.memo, current ? current.key : null); + }; - return _emberMetalProperty_get.get(obj, this.altKey); - }; + IteratorSynchronizer.prototype.startPrune = function startPrune() { + this.current = this.artifacts.head(); + return Phase.Prune; + }; - AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) { - return _emberMetalProperty_set.set(obj, this.altKey, value); - }; + IteratorSynchronizer.prototype.nextPrune = function nextPrune() { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - AliasedProperty.prototype.readOnly = function () { - this.set = AliasedProperty_readOnlySet; - return this; - }; + if (current === null) { + return Phase.Done; + } + var node = current; + this.current = artifacts.nextNode(node); + if (node.shouldRemove()) { + artifacts.remove(node); + target.delete(node.key); + } else { + node.reset(); + } + return Phase.Prune; + }; - function AliasedProperty_readOnlySet(obj, keyName, value) { - throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); - } + IteratorSynchronizer.prototype.nextDone = function nextDone() { + this.target.done(); + }; - AliasedProperty.prototype.oneWay = function () { - this.set = AliasedProperty_oneWaySet; - return this; - }; + return IteratorSynchronizer; + })(); - function AliasedProperty_oneWaySet(obj, keyName, value) { - _emberMetalProperties.defineProperty(obj, keyName, null); - return _emberMetalProperty_set.set(obj, keyName, value); - } + function referenceFromParts(root, parts) { + var reference = root; + for (var i = 0; i < parts.length; i++) { + reference = reference.get(parts[i]); + } + return reference; + } - // Backwards compatibility with Ember Data. - AliasedProperty.prototype._meta = undefined; - AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta; + exports.ConstReference = ConstReference; + exports.isConst = isConst; + exports.ListItem = ListItem; + exports.referenceFromParts = referenceFromParts; + exports.IterationArtifacts = IterationArtifacts; + exports.ReferenceIterator = ReferenceIterator; + exports.IteratorSynchronizer = IteratorSynchronizer; + exports.CONSTANT = CONSTANT; + exports.INITIAL = INITIAL; + exports.VOLATILE = VOLATILE; + exports.RevisionTag = RevisionTag; + exports.DirtyableTag = DirtyableTag; + exports.combineTagged = combineTagged; + exports.combineSlice = combineSlice; + exports.combine = combine; + exports.CachedTag = CachedTag; + exports.UpdatableTag = UpdatableTag; + exports.CONSTANT_TAG = CONSTANT_TAG; + exports.VOLATILE_TAG = VOLATILE_TAG; + exports.CURRENT_TAG = CURRENT_TAG; + exports.CachedReference = CachedReference; + exports.map = map; + exports.ReferenceCache = ReferenceCache; + exports.isModified = isModified; }); -enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) { - 'use strict'; - - exports.bind = bind; - - /** - @module ember - @submodule ember-metal - */ - - // .......................................................... - // BINDING - // - - function Binding(toPath, fromPath) { - // Configuration - this._from = fromPath; - this._to = toPath; - this._oneWay = undefined; - - // State - this._direction = undefined; - this._readyToSync = undefined; - this._fromObj = undefined; - this._fromPath = undefined; - this._toObj = undefined; - } - - /** - @class Binding - @namespace Ember - @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding - @public - */ - - Binding.prototype = { - /** - This copies the Binding so it can be connected to another object. - @method copy - @return {Ember.Binding} `this` - @public - */ - copy: function () { - var copy = new Binding(this._to, this._from); - if (this._oneWay) { - copy._oneWay = true; - } - return copy; - }, - - // .......................................................... - // CONFIG - // - - /** - This will set `from` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method from - @param {String} path The property path to connect to. - @return {Ember.Binding} `this` - @public - */ - from: function (path) { - this._from = path; - return this; - }, - - /** - This will set the `to` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method to - @param {String|Tuple} path A property path or tuple. - @return {Ember.Binding} `this` - @public - */ - to: function (path) { - this._to = path; - return this; - }, - - /** - Configures the binding as one way. A one-way binding will relay changes - on the `from` side to the `to` side, but not the other way around. This - means that if you change the `to` side directly, the `from` side may have - a different value. - @method oneWay - @return {Ember.Binding} `this` - @public - */ - oneWay: function () { - this._oneWay = true; - return this; - }, - - /** - @method toString - @return {String} string representation of binding - @public - */ - toString: function () { - var oneWay = this._oneWay ? '[oneWay]' : ''; - return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; - }, +enifed('@glimmer/runtime',['exports','@glimmer/util','@glimmer/reference','@glimmer/wire-format'],function(exports,_glimmerUtil,_glimmerReference,_glimmerWireFormat){'use strict';var PrimitiveReference=(function(_ConstReference){babelHelpers.inherits(PrimitiveReference,_ConstReference);function PrimitiveReference(value){_ConstReference.call(this,value);}PrimitiveReference.create = function create(value){if(value === undefined){return UNDEFINED_REFERENCE;}else if(value === null){return NULL_REFERENCE;}else if(value === true){return TRUE_REFERENCE;}else if(value === false){return FALSE_REFERENCE;}else if(typeof value === 'number'){return new ValueReference(value);}else {return new StringReference(value);}};PrimitiveReference.prototype.get = function get(_key){return UNDEFINED_REFERENCE;};return PrimitiveReference;})(_glimmerReference.ConstReference);var StringReference=(function(_PrimitiveReference){babelHelpers.inherits(StringReference,_PrimitiveReference);function StringReference(){_PrimitiveReference.apply(this,arguments);this.lengthReference = null;}StringReference.prototype.get = function get(key){if(key === 'length'){var lengthReference=this.lengthReference;if(lengthReference === null){lengthReference = this.lengthReference = new ValueReference(this.inner.length);}return lengthReference;}else {return _PrimitiveReference.prototype.get.call(this,key);}};return StringReference;})(PrimitiveReference);var ValueReference=(function(_PrimitiveReference2){babelHelpers.inherits(ValueReference,_PrimitiveReference2);function ValueReference(value){_PrimitiveReference2.call(this,value);}return ValueReference;})(PrimitiveReference);var UNDEFINED_REFERENCE=new ValueReference(undefined);var NULL_REFERENCE=new ValueReference(null);var TRUE_REFERENCE=new ValueReference(true);var FALSE_REFERENCE=new ValueReference(false);var ConditionalReference=(function(){function ConditionalReference(inner){this.inner = inner;this.tag = inner.tag;}ConditionalReference.prototype.value = function value(){return this.toBool(this.inner.value());};ConditionalReference.prototype.toBool = function toBool(value){return !!value;};return ConditionalReference;})();var Constants=(function(){function Constants(){ // `0` means NULL +this.references = [];this.strings = [];this.expressions = [];this.arrays = [];this.slices = [];this.blocks = [];this.functions = [];this.others = [];this.NULL_REFERENCE = this.reference(NULL_REFERENCE);this.UNDEFINED_REFERENCE = this.reference(UNDEFINED_REFERENCE);}Constants.prototype.getReference = function getReference(value){return this.references[value - 1];};Constants.prototype.reference = function reference(value){var index=this.references.length;this.references.push(value);return index + 1;};Constants.prototype.getString = function getString(value){return this.strings[value - 1];};Constants.prototype.string = function string(value){var index=this.strings.length;this.strings.push(value);return index + 1;};Constants.prototype.getExpression = function getExpression(value){return this.expressions[value - 1];};Constants.prototype.expression = function expression(value){var index=this.expressions.length;this.expressions.push(value);return index + 1;};Constants.prototype.getArray = function getArray(value){return this.arrays[value - 1];};Constants.prototype.array = function array(values){var index=this.arrays.length;this.arrays.push(values);return index + 1;};Constants.prototype.getSlice = function getSlice(value){return this.slices[value - 1];};Constants.prototype.slice = function slice(_slice2){ // TODO: Put the entire program in one big array +var index=this.slices.length;this.slices.push(_slice2);return index + 1;};Constants.prototype.getBlock = function getBlock(value){return this.blocks[value - 1];};Constants.prototype.block = function block(_block2){var index=this.blocks.length;this.blocks.push(_block2);return index + 1;};Constants.prototype.getFunction = function getFunction(value){return this.functions[value - 1];};Constants.prototype.function = function _function(f){var index=this.functions.length;this.functions.push(f);return index + 1;};Constants.prototype.getOther = function getOther(value){return this.others[value - 1];};Constants.prototype.other = function other(_other){var index=this.others.length;this.others.push(_other);return index + 1;};return Constants;})();var AppendOpcodes=(function(){function AppendOpcodes(){this.evaluateOpcode = _glimmerUtil.fillNulls(51 /* EvaluatePartial */ + 1);}AppendOpcodes.prototype.add = function add(name,evaluate){this.evaluateOpcode[name] = evaluate;};AppendOpcodes.prototype.construct = function construct(name,_debug,op1,op2,op3){return [name | 0,(op1 || 0) | 0,(op2 || 0) | 0,(op3 || 0) | 0];};AppendOpcodes.prototype.evaluate = function evaluate(vm,opcode){_glimmerUtil.LOGGER.debug('[VM] OPCODE: ' + opcode.type);var func=this.evaluateOpcode[opcode.type];func(vm,opcode);};return AppendOpcodes;})();var APPEND_OPCODES=new AppendOpcodes();var AbstractOpcode=(function(){function AbstractOpcode(){_glimmerUtil.initializeGuid(this);}AbstractOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type};};return AbstractOpcode;})();var UpdatingOpcode=(function(_AbstractOpcode){babelHelpers.inherits(UpdatingOpcode,_AbstractOpcode);function UpdatingOpcode(){_AbstractOpcode.apply(this,arguments);this.next = null;this.prev = null;}return UpdatingOpcode;})(AbstractOpcode);APPEND_OPCODES.add(20, /* OpenBlock */function(vm,_ref){var _getBlock=_ref.op1;var _args=_ref.op2;var inner=vm.constants.getOther(_getBlock);var rawArgs=vm.constants.getExpression(_args);var args=null;var block=inner.evaluate(vm);if(block){args = rawArgs.evaluate(vm);} // FIXME: can we avoid doing this when we don't have a block? +vm.pushCallerScope();if(block){vm.invokeBlock(block,args || null);}});APPEND_OPCODES.add(21, /* CloseBlock */function(vm){return vm.popScope();});APPEND_OPCODES.add(0, /* PushChildScope */function(vm){return vm.pushChildScope();});APPEND_OPCODES.add(1, /* PopScope */function(vm){return vm.popScope();});APPEND_OPCODES.add(2, /* PushDynamicScope */function(vm){return vm.pushDynamicScope();});APPEND_OPCODES.add(3, /* PopDynamicScope */function(vm){return vm.popDynamicScope();});APPEND_OPCODES.add(4, /* Put */function(vm,_ref2){var reference=_ref2.op1;vm.frame.setOperand(vm.constants.getReference(reference));});APPEND_OPCODES.add(5, /* EvaluatePut */function(vm,_ref3){var expression=_ref3.op1;var expr=vm.constants.getExpression(expression);vm.evaluateOperand(expr);});APPEND_OPCODES.add(6, /* PutArgs */function(vm,_ref4){var args=_ref4.op1;vm.evaluateArgs(vm.constants.getExpression(args));});APPEND_OPCODES.add(7, /* BindPositionalArgs */function(vm,_ref5){var _symbols=_ref5.op1;var symbols=vm.constants.getArray(_symbols);vm.bindPositionalArgs(symbols);});APPEND_OPCODES.add(8, /* BindNamedArgs */function(vm,_ref6){var _names=_ref6.op1;var _symbols=_ref6.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindNamedArgs(names,symbols);});APPEND_OPCODES.add(9, /* BindBlocks */function(vm,_ref7){var _names=_ref7.op1;var _symbols=_ref7.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindBlocks(names,symbols);});APPEND_OPCODES.add(10, /* BindPartialArgs */function(vm,_ref8){var symbol=_ref8.op1;vm.bindPartialArgs(symbol);});APPEND_OPCODES.add(11, /* BindCallerScope */function(vm){return vm.bindCallerScope();});APPEND_OPCODES.add(12, /* BindDynamicScope */function(vm,_ref9){var _names=_ref9.op1;var names=vm.constants.getArray(_names);vm.bindDynamicScope(names);});APPEND_OPCODES.add(13, /* Enter */function(vm,_ref10){var slice=_ref10.op1;return vm.enter(slice);});APPEND_OPCODES.add(14, /* Exit */function(vm){return vm.exit();});APPEND_OPCODES.add(15, /* Evaluate */function(vm,_ref11){var _block=_ref11.op1;var block=vm.constants.getBlock(_block);var args=vm.frame.getArgs();vm.invokeBlock(block,args);});APPEND_OPCODES.add(16, /* Jump */function(vm,_ref12){var target=_ref12.op1;return vm.goto(target);});APPEND_OPCODES.add(17, /* JumpIf */function(vm,_ref13){var target=_ref13.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(18, /* JumpUnless */function(vm,_ref14){var target=_ref14.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(!reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(!cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});var ConstTest=function(ref,_env){return new _glimmerReference.ConstReference(!!ref.value());};var SimpleTest=function(ref,_env){return ref;};var EnvironmentTest=function(ref,env){return env.toConditionalReference(ref);};APPEND_OPCODES.add(19, /* Test */function(vm,_ref15){var _func=_ref15.op1;var operand=vm.frame.getOperand();var func=vm.constants.getFunction(_func);vm.frame.setCondition(func(operand,vm.env));});var Assert=(function(_UpdatingOpcode){babelHelpers.inherits(Assert,_UpdatingOpcode);function Assert(cache){_UpdatingOpcode.call(this);this.type = "assert";this.tag = cache.tag;this.cache = cache;}Assert.prototype.evaluate = function evaluate(vm){var cache=this.cache;if(_glimmerReference.isModified(cache.revalidate())){vm.throw();}};Assert.prototype.toJSON = function toJSON(){var type=this.type;var _guid=this._guid;var cache=this.cache;var expected=undefined;try{expected = JSON.stringify(cache.peek());}catch(e) {expected = String(cache.peek());}return {guid:_guid,type:type,args:[],details:{expected:expected}};};return Assert;})(UpdatingOpcode);var JumpIfNotModifiedOpcode=(function(_UpdatingOpcode2){babelHelpers.inherits(JumpIfNotModifiedOpcode,_UpdatingOpcode2);function JumpIfNotModifiedOpcode(tag,target){_UpdatingOpcode2.call(this);this.target = target;this.type = "jump-if-not-modified";this.tag = tag;this.lastRevision = tag.value();}JumpIfNotModifiedOpcode.prototype.evaluate = function evaluate(vm){var tag=this.tag;var target=this.target;var lastRevision=this.lastRevision;if(!vm.alwaysRevalidate && tag.validate(lastRevision)){vm.goto(target);}};JumpIfNotModifiedOpcode.prototype.didModify = function didModify(){this.lastRevision = this.tag.value();};JumpIfNotModifiedOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.target.inspect())]};};return JumpIfNotModifiedOpcode;})(UpdatingOpcode);var DidModifyOpcode=(function(_UpdatingOpcode3){babelHelpers.inherits(DidModifyOpcode,_UpdatingOpcode3);function DidModifyOpcode(target){_UpdatingOpcode3.call(this);this.target = target;this.type = "did-modify";this.tag = _glimmerReference.CONSTANT_TAG;}DidModifyOpcode.prototype.evaluate = function evaluate(){this.target.didModify();};return DidModifyOpcode;})(UpdatingOpcode);var LabelOpcode=(function(){function LabelOpcode(label){this.tag = _glimmerReference.CONSTANT_TAG;this.type = "label";this.label = null;this.prev = null;this.next = null;_glimmerUtil.initializeGuid(this);if(label)this.label = label;}LabelOpcode.prototype.evaluate = function evaluate(){};LabelOpcode.prototype.inspect = function inspect(){return this.label + ' [' + this._guid + ']';};LabelOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.inspect())]};};return LabelOpcode;})();var EMPTY_ARRAY=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze([]):[];var EMPTY_DICT=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze(_glimmerUtil.dict()):_glimmerUtil.dict();var CompiledPositionalArgs=(function(){function CompiledPositionalArgs(values){this.values = values;this.length = values.length;}CompiledPositionalArgs.create = function create(values){if(values.length){return new this(values);}else {return COMPILED_EMPTY_POSITIONAL_ARGS;}};CompiledPositionalArgs.empty = function empty(){return COMPILED_EMPTY_POSITIONAL_ARGS;};CompiledPositionalArgs.prototype.evaluate = function evaluate(vm){var values=this.values;var length=this.length;var references=new Array(length);for(var i=0;i < length;i++) {references[i] = values[i].evaluate(vm);}return EvaluatedPositionalArgs.create(references);};CompiledPositionalArgs.prototype.toJSON = function toJSON(){return '[' + this.values.map(function(value){return value.toJSON();}).join(", ") + ']';};return CompiledPositionalArgs;})();var COMPILED_EMPTY_POSITIONAL_ARGS=new ((function(_CompiledPositionalArgs){babelHelpers.inherits(_class,_CompiledPositionalArgs);function _class(){_CompiledPositionalArgs.call(this,EMPTY_ARRAY);}_class.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_POSITIONAL_ARGS;};_class.prototype.toJSON = function toJSON(){return '';};return _class;})(CompiledPositionalArgs))();var EvaluatedPositionalArgs=(function(){function EvaluatedPositionalArgs(values){this.values = values;this.tag = _glimmerReference.combineTagged(values);this.length = values.length;}EvaluatedPositionalArgs.create = function create(values){return new this(values);};EvaluatedPositionalArgs.empty = function empty(){return EVALUATED_EMPTY_POSITIONAL_ARGS;};EvaluatedPositionalArgs.prototype.at = function at(index){var values=this.values;var length=this.length;return index < length?values[index]:UNDEFINED_REFERENCE;};EvaluatedPositionalArgs.prototype.value = function value(){var values=this.values;var length=this.length;var ret=new Array(length);for(var i=0;i < length;i++) {ret[i] = values[i].value();}return ret;};return EvaluatedPositionalArgs;})();var EVALUATED_EMPTY_POSITIONAL_ARGS=new ((function(_EvaluatedPositionalArgs){babelHelpers.inherits(_class2,_EvaluatedPositionalArgs);function _class2(){_EvaluatedPositionalArgs.call(this,EMPTY_ARRAY);}_class2.prototype.at = function at(){return UNDEFINED_REFERENCE;};_class2.prototype.value = function value(){return this.values;};return _class2;})(EvaluatedPositionalArgs))();var CompiledNamedArgs=(function(){function CompiledNamedArgs(keys,values){this.keys = keys;this.values = values;this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}CompiledNamedArgs.empty = function empty(){return COMPILED_EMPTY_NAMED_ARGS;};CompiledNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=[];for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values);}else {return COMPILED_EMPTY_NAMED_ARGS;}};CompiledNamedArgs.prototype.evaluate = function evaluate(vm){var keys=this.keys;var values=this.values;var length=this.length;var evaluated=new Array(length);for(var i=0;i < length;i++) {evaluated[i] = values[i].evaluate(vm);}return new EvaluatedNamedArgs(keys,evaluated);};CompiledNamedArgs.prototype.toJSON = function toJSON(){var keys=this.keys;var values=this.values;var inner=keys.map(function(key,i){return key + ': ' + values[i].toJSON();}).join(", ");return '{' + inner + '}';};return CompiledNamedArgs;})();var COMPILED_EMPTY_NAMED_ARGS=new ((function(_CompiledNamedArgs){babelHelpers.inherits(_class3,_CompiledNamedArgs);function _class3(){_CompiledNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY);}_class3.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_NAMED_ARGS;};_class3.prototype.toJSON = function toJSON(){return '';};return _class3;})(CompiledNamedArgs))();var EvaluatedNamedArgs=(function(){function EvaluatedNamedArgs(keys,values){var _map=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];this.keys = keys;this.values = values;this._map = _map;this.tag = _glimmerReference.combineTagged(values);this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}EvaluatedNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=new Array(length);for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values,map);}else {return EVALUATED_EMPTY_NAMED_ARGS;}};EvaluatedNamedArgs.empty = function empty(){return EVALUATED_EMPTY_NAMED_ARGS;};EvaluatedNamedArgs.prototype.get = function get(key){var keys=this.keys;var values=this.values;var index=keys.indexOf(key);return index === -1?UNDEFINED_REFERENCE:values[index];};EvaluatedNamedArgs.prototype.has = function has(key){return this.keys.indexOf(key) !== -1;};EvaluatedNamedArgs.prototype.value = function value(){var keys=this.keys;var values=this.values;var out=_glimmerUtil.dict();for(var i=0;i < keys.length;i++) {var key=keys[i];var ref=values[i];out[key] = ref.value();}return out;};babelHelpers.createClass(EvaluatedNamedArgs,[{key:'map',get:function(){var map=this._map;if(map){return map;}map = this._map = _glimmerUtil.dict();var keys=this.keys;var values=this.values;var length=this.length;for(var i=0;i < length;i++) {map[keys[i]] = values[i];}return map;}}]);return EvaluatedNamedArgs;})();var EVALUATED_EMPTY_NAMED_ARGS=new ((function(_EvaluatedNamedArgs){babelHelpers.inherits(_class4,_EvaluatedNamedArgs);function _class4(){_EvaluatedNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY,EMPTY_DICT);}_class4.prototype.get = function get(){return UNDEFINED_REFERENCE;};_class4.prototype.has = function has(_key){return false;};_class4.prototype.value = function value(){return EMPTY_DICT;};return _class4;})(EvaluatedNamedArgs))();var EMPTY_BLOCKS={default:null,inverse:null};var CompiledArgs=(function(){function CompiledArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.type = "compiled-args";}CompiledArgs.create = function create(positional,named,blocks){if(positional === COMPILED_EMPTY_POSITIONAL_ARGS && named === COMPILED_EMPTY_NAMED_ARGS && blocks === EMPTY_BLOCKS){return this.empty();}else {return new this(positional,named,blocks);}};CompiledArgs.empty = function empty(){return COMPILED_EMPTY_ARGS;};CompiledArgs.prototype.evaluate = function evaluate(vm){var positional=this.positional;var named=this.named;var blocks=this.blocks;return EvaluatedArgs.create(positional.evaluate(vm),named.evaluate(vm),blocks);};return CompiledArgs;})();var COMPILED_EMPTY_ARGS=new ((function(_CompiledArgs){babelHelpers.inherits(_class5,_CompiledArgs);function _class5(){_CompiledArgs.call(this,COMPILED_EMPTY_POSITIONAL_ARGS,COMPILED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);}_class5.prototype.evaluate = function evaluate(_vm){return EMPTY_EVALUATED_ARGS;};return _class5;})(CompiledArgs))();var EvaluatedArgs=(function(){function EvaluatedArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.tag = _glimmerReference.combineTagged([positional,named]);}EvaluatedArgs.empty = function empty(){return EMPTY_EVALUATED_ARGS;};EvaluatedArgs.create = function create(positional,named,blocks){return new this(positional,named,blocks);};EvaluatedArgs.positional = function positional(values){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EvaluatedPositionalArgs.create(values),EVALUATED_EMPTY_NAMED_ARGS,blocks);};EvaluatedArgs.named = function named(map){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EVALUATED_EMPTY_POSITIONAL_ARGS,EvaluatedNamedArgs.create(map),blocks);};return EvaluatedArgs;})();var EMPTY_EVALUATED_ARGS=new EvaluatedArgs(EVALUATED_EMPTY_POSITIONAL_ARGS,EVALUATED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);APPEND_OPCODES.add(22, /* PutDynamicComponent */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(23, /* PutComponent */function(vm,_ref16){var _component=_ref16.op1;var definition=vm.constants.getOther(_component);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(24, /* OpenComponent */function(vm,_ref17){var _args=_ref17.op1;var _shadow=_ref17.op2;var rawArgs=vm.constants.getExpression(_args);var shadow=vm.constants.getBlock(_shadow);var definition=vm.frame.getImmediate();var dynamicScope=vm.pushDynamicScope();var callerScope=vm.scope();var manager=definition.manager;var args=manager.prepareArgs(definition,rawArgs.evaluate(vm),dynamicScope);var hasDefaultBlock=!!args.blocks.default; // TODO Cleanup? +var component=manager.create(vm.env,definition,args,dynamicScope,vm.getSelf(),hasDefaultBlock);var destructor=manager.getDestructor(component);if(destructor)vm.newDestroyable(destructor);var layout=manager.layoutFor(definition,component,vm.env);var selfRef=manager.getSelf(component);vm.beginCacheGroup();vm.stack().pushSimpleBlock();vm.pushRootScope(selfRef,layout.symbols);vm.invokeLayout(args,layout,callerScope,component,manager,shadow);vm.updateWith(new UpdateComponentOpcode(definition.name,component,manager,args,dynamicScope));}); // export class DidCreateElementOpcode extends Opcode { +// public type = "did-create-element"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let action = 'DidCreateElementOpcode#evaluate'; +// manager.didCreateElement(component, vm.stack().expectConstructing(action), vm.stack().expectOperations(action)); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +APPEND_OPCODES.add(25, /* DidCreateElement */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var action='DidCreateElementOpcode#evaluate';manager.didCreateElement(component,vm.stack().expectConstructing(action),vm.stack().expectOperations(action));}); // export class ShadowAttributesOpcode extends Opcode { +// public type = "shadow-attributes"; +// evaluate(vm: VM) { +// let shadow = vm.frame.getShadow(); +// vm.pushCallerScope(); +// if (!shadow) return; +// vm.invokeBlock(shadow, EvaluatedArgs.empty()); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +// Slow path for non-specialized component invocations. Uses an internal +// named lookup on the args. +APPEND_OPCODES.add(26, /* ShadowAttributes */function(vm){var shadow=vm.frame.getShadow();vm.pushCallerScope();if(!shadow)return;vm.invokeBlock(shadow,EvaluatedArgs.empty());}); // export class DidRenderLayoutOpcode extends Opcode { +// public type = "did-render-layout"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let bounds = vm.stack().popBlock(); +// manager.didRenderLayout(component, bounds); +// vm.env.didCreate(component, manager); +// vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); +// } +// } +APPEND_OPCODES.add(27, /* DidRenderLayout */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var bounds=vm.stack().popBlock();manager.didRenderLayout(component,bounds);vm.env.didCreate(component,manager);vm.updateWith(new DidUpdateLayoutOpcode(manager,component,bounds));}); // export class CloseComponentOpcode extends Opcode { +// public type = "close-component"; +// evaluate(vm: VM) { +// vm.popScope(); +// vm.popDynamicScope(); +// vm.commitCacheGroup(); +// } +// } +APPEND_OPCODES.add(28, /* CloseComponent */function(vm){vm.popScope();vm.popDynamicScope();vm.commitCacheGroup();});var UpdateComponentOpcode=(function(_UpdatingOpcode4){babelHelpers.inherits(UpdateComponentOpcode,_UpdatingOpcode4);function UpdateComponentOpcode(name,component,manager,args,dynamicScope){_UpdatingOpcode4.call(this);this.name = name;this.component = component;this.manager = manager;this.args = args;this.dynamicScope = dynamicScope;this.type = "update-component";var componentTag=manager.getTag(component);if(componentTag){this.tag = _glimmerReference.combine([args.tag,componentTag]);}else {this.tag = args.tag;}}UpdateComponentOpcode.prototype.evaluate = function evaluate(_vm){var component=this.component;var manager=this.manager;var args=this.args;var dynamicScope=this.dynamicScope;manager.update(component,args,dynamicScope);};UpdateComponentOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.name)]};};return UpdateComponentOpcode;})(UpdatingOpcode);var DidUpdateLayoutOpcode=(function(_UpdatingOpcode5){babelHelpers.inherits(DidUpdateLayoutOpcode,_UpdatingOpcode5);function DidUpdateLayoutOpcode(manager,component,bounds){_UpdatingOpcode5.call(this);this.manager = manager;this.component = component;this.bounds = bounds;this.type = "did-update-layout";this.tag = _glimmerReference.CONSTANT_TAG;}DidUpdateLayoutOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var component=this.component;var bounds=this.bounds;manager.didUpdateLayout(component,bounds);vm.env.didUpdate(component,manager);};return DidUpdateLayoutOpcode;})(UpdatingOpcode);var Cursor=function Cursor(element,nextSibling){this.element = element;this.nextSibling = nextSibling;};var ConcreteBounds=(function(){function ConcreteBounds(parentNode,first,last){this.parentNode = parentNode;this.first = first;this.last = last;}ConcreteBounds.prototype.parentElement = function parentElement(){return this.parentNode;};ConcreteBounds.prototype.firstNode = function firstNode(){return this.first;};ConcreteBounds.prototype.lastNode = function lastNode(){return this.last;};return ConcreteBounds;})();var SingleNodeBounds=(function(){function SingleNodeBounds(parentNode,node){this.parentNode = parentNode;this.node = node;}SingleNodeBounds.prototype.parentElement = function parentElement(){return this.parentNode;};SingleNodeBounds.prototype.firstNode = function firstNode(){return this.node;};SingleNodeBounds.prototype.lastNode = function lastNode(){return this.node;};return SingleNodeBounds;})();function single(parent,node){return new SingleNodeBounds(parent,node);}function moveBounds(bounds,reference){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.insertBefore(node,reference);if(node === last)return next;node = next;}return null;}function clear(bounds){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.removeChild(node);if(node === last)return next;node = next;}return null;}function isSafeString(value){return !!value && typeof value['toHTML'] === 'function';}function isNode(value){return value !== null && typeof value === 'object' && typeof value['nodeType'] === 'number';}function isString(value){return typeof value === 'string';}var Upsert=function Upsert(bounds){this.bounds = bounds;};function cautiousInsert(dom,cursor,value){if(isString(value)){return TextUpsert.insert(dom,cursor,value);}if(isSafeString(value)){return SafeStringUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}function trustingInsert(dom,cursor,value){if(isString(value)){return HTMLUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}var TextUpsert=(function(_Upsert){babelHelpers.inherits(TextUpsert,_Upsert);TextUpsert.insert = function insert(dom,cursor,value){var textNode=dom.createTextNode(value);dom.insertBefore(cursor.element,textNode,cursor.nextSibling);var bounds=new SingleNodeBounds(cursor.element,textNode);return new TextUpsert(bounds,textNode);};function TextUpsert(bounds,textNode){_Upsert.call(this,bounds);this.textNode = textNode;}TextUpsert.prototype.update = function update(_dom,value){if(isString(value)){var textNode=this.textNode;textNode.nodeValue = value;return true;}else {return false;}};return TextUpsert;})(Upsert);var HTMLUpsert=(function(_Upsert2){babelHelpers.inherits(HTMLUpsert,_Upsert2);function HTMLUpsert(){_Upsert2.apply(this,arguments);}HTMLUpsert.insert = function insert(dom,cursor,value){var bounds=dom.insertHTMLBefore(cursor.element,value,cursor.nextSibling);return new HTMLUpsert(bounds);};HTMLUpsert.prototype.update = function update(dom,value){if(isString(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,value);return true;}else {return false;}};return HTMLUpsert;})(Upsert);var SafeStringUpsert=(function(_Upsert3){babelHelpers.inherits(SafeStringUpsert,_Upsert3);function SafeStringUpsert(bounds,lastStringValue){_Upsert3.call(this,bounds);this.lastStringValue = lastStringValue;}SafeStringUpsert.insert = function insert(dom,cursor,value){var stringValue=value.toHTML();var bounds=dom.insertHTMLBefore(cursor.element,stringValue,cursor.nextSibling);return new SafeStringUpsert(bounds,stringValue);};SafeStringUpsert.prototype.update = function update(dom,value){if(isSafeString(value)){var stringValue=value.toHTML();if(stringValue !== this.lastStringValue){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,stringValue);this.lastStringValue = stringValue;}return true;}else {return false;}};return SafeStringUpsert;})(Upsert);var NodeUpsert=(function(_Upsert4){babelHelpers.inherits(NodeUpsert,_Upsert4);function NodeUpsert(){_Upsert4.apply(this,arguments);}NodeUpsert.insert = function insert(dom,cursor,node){dom.insertBefore(cursor.element,node,cursor.nextSibling);return new NodeUpsert(single(cursor.element,node));};NodeUpsert.prototype.update = function update(dom,value){if(isNode(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertNodeBefore(parentElement,value,nextSibling);return true;}else {return false;}};return NodeUpsert;})(Upsert);var COMPONENT_DEFINITION_BRAND='COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]';function isComponentDefinition(obj){return typeof obj === 'object' && obj && obj[COMPONENT_DEFINITION_BRAND];}var ComponentDefinition=function ComponentDefinition(name,manager,ComponentClass){this[COMPONENT_DEFINITION_BRAND] = true;this.name = name;this.manager = manager;this.ComponentClass = ComponentClass;};var CompiledExpression=(function(){function CompiledExpression(){}CompiledExpression.prototype.toJSON = function toJSON(){return 'UNIMPL: ' + this.type.toUpperCase();};return CompiledExpression;})();APPEND_OPCODES.add(29, /* Text */function(vm,_ref18){var text=_ref18.op1;vm.stack().appendText(vm.constants.getString(text));});APPEND_OPCODES.add(30, /* Comment */function(vm,_ref19){var text=_ref19.op1;vm.stack().appendComment(vm.constants.getString(text));});APPEND_OPCODES.add(32, /* OpenElement */function(vm,_ref20){var tag=_ref20.op1;vm.stack().openElement(vm.constants.getString(tag));});APPEND_OPCODES.add(33, /* PushRemoteElement */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var element=cache?cache.peek():reference.value();vm.stack().pushRemoteElement(element);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(34, /* PopRemoteElement */function(vm){return vm.stack().popRemoteElement();});APPEND_OPCODES.add(35, /* OpenComponentElement */function(vm,_ref21){var _tag=_ref21.op1;var tag=vm.constants.getString(_tag);vm.stack().openElement(tag,new ComponentElementOperations(vm.env));});APPEND_OPCODES.add(36, /* OpenDynamicElement */function(vm){var tagName=vm.frame.getOperand().value();vm.stack().openElement(tagName);});var ClassList=(function(){function ClassList(){this.list = null;this.isConst = true;}ClassList.prototype.append = function append(reference){var list=this.list;var isConst$$=this.isConst;if(list === null)list = this.list = [];list.push(reference);this.isConst = isConst$$ && _glimmerReference.isConst(reference);};ClassList.prototype.toReference = function toReference(){var list=this.list;var isConst$$=this.isConst;if(!list)return NULL_REFERENCE;if(isConst$$)return PrimitiveReference.create(toClassName(list));return new ClassListReference(list);};return ClassList;})();var ClassListReference=(function(_CachedReference){babelHelpers.inherits(ClassListReference,_CachedReference);function ClassListReference(list){_CachedReference.call(this);this.list = [];this.tag = _glimmerReference.combineTagged(list);this.list = list;}ClassListReference.prototype.compute = function compute(){return toClassName(this.list);};return ClassListReference;})(_glimmerReference.CachedReference);function toClassName(list){var ret=[];for(var i=0;i < list.length;i++) {var value=list[i].value();if(value !== false && value !== null && value !== undefined)ret.push(value);}return ret.length === 0?null:ret.join(' ');}var SimpleElementOperations=(function(){function SimpleElementOperations(env){this.env = env;this.opcodes = null;this.classList = null;}SimpleElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else {this.env.getAppendOperations().setAttribute(element,name,value);}};SimpleElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){this.env.getAppendOperations().setAttribute(element,name,value,namespace);};SimpleElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else {var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(attribute);}};SimpleElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(nsAttribute);};SimpleElementOperations.prototype.flush = function flush(element,vm){var env=vm.env;var opcodes=this.opcodes;var classList=this.classList;for(var i=0;opcodes && i < opcodes.length;i++) {vm.updateWith(opcodes[i]);}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}this.opcodes = null;this.classList = null;};SimpleElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};SimpleElementOperations.prototype.addAttribute = function addAttribute(attribute){var opcode=attribute.flush(this.env);if(opcode){var opcodes=this.opcodes;if(!opcodes){opcodes = this.opcodes = [];}opcodes.push(opcode);}};return SimpleElementOperations;})();var ComponentElementOperations=(function(){function ComponentElementOperations(env){this.env = env;this.attributeNames = null;this.attributes = null;this.classList = null;}ComponentElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value));}};ComponentElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value,namespace));}};ComponentElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(name,attribute);}};ComponentElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(name,nsAttribute);}};ComponentElementOperations.prototype.flush = function flush(element,vm){var env=this.env;var attributes=this.attributes;var classList=this.classList;for(var i=0;attributes && i < attributes.length;i++) {var opcode=attributes[i].flush(env);if(opcode){vm.updateWith(opcode);}}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}};ComponentElementOperations.prototype.shouldAddAttribute = function shouldAddAttribute(name){return !this.attributeNames || this.attributeNames.indexOf(name) === -1;};ComponentElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};ComponentElementOperations.prototype.addAttribute = function addAttribute(name,attribute){var attributeNames=this.attributeNames;var attributes=this.attributes;if(!attributeNames){attributeNames = this.attributeNames = [];attributes = this.attributes = [];}attributeNames.push(name);_glimmerUtil.unwrap(attributes).push(attribute);};return ComponentElementOperations;})();APPEND_OPCODES.add(37, /* FlushElement */function(vm){var stack=vm.stack();var action='FlushElementOpcode#evaluate';stack.expectOperations(action).flush(stack.expectConstructing(action),vm);stack.flushElement();});APPEND_OPCODES.add(38, /* CloseElement */function(vm){return vm.stack().closeElement();});APPEND_OPCODES.add(39, /* PopElement */function(vm){return vm.stack().popElement();});APPEND_OPCODES.add(40, /* StaticAttr */function(vm,_ref22){var _name=_ref22.op1;var _value=_ref22.op2;var _namespace=_ref22.op3;var name=vm.constants.getString(_name);var value=vm.constants.getString(_value);if(_namespace){var namespace=vm.constants.getString(_namespace);vm.stack().setStaticAttributeNS(namespace,name,value);}else {vm.stack().setStaticAttribute(name,value);}});APPEND_OPCODES.add(41, /* Modifier */function(vm,_ref23){var _name=_ref23.op1;var _manager=_ref23.op2;var _args=_ref23.op3;var manager=vm.constants.getOther(_manager);var rawArgs=vm.constants.getExpression(_args);var stack=vm.stack();var element=stack.constructing;var updateOperations=stack.updateOperations;var args=rawArgs.evaluate(vm);var dynamicScope=vm.dynamicScope();var modifier=manager.create(element,args,dynamicScope,updateOperations);vm.env.scheduleInstallModifier(modifier,manager);var destructor=manager.getDestructor(modifier);if(destructor){vm.newDestroyable(destructor);}vm.updateWith(new UpdateModifierOpcode(manager,modifier,args));});var UpdateModifierOpcode=(function(_UpdatingOpcode6){babelHelpers.inherits(UpdateModifierOpcode,_UpdatingOpcode6);function UpdateModifierOpcode(manager,modifier,args){_UpdatingOpcode6.call(this);this.manager = manager;this.modifier = modifier;this.args = args;this.type = "update-modifier";this.tag = args.tag;this.lastUpdated = args.tag.value();}UpdateModifierOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var modifier=this.modifier;var tag=this.tag;var lastUpdated=this.lastUpdated;if(!tag.validate(lastUpdated)){vm.env.scheduleUpdateModifier(modifier,manager);this.lastUpdated = tag.value();}};UpdateModifierOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.args)]};};return UpdateModifierOpcode;})(UpdatingOpcode);var StaticAttribute=(function(){function StaticAttribute(element,name,value,namespace){this.element = element;this.name = name;this.value = value;this.namespace = namespace;}StaticAttribute.prototype.flush = function flush(env){env.getAppendOperations().setAttribute(this.element,this.name,this.value,this.namespace);return null;};return StaticAttribute;})();var DynamicAttribute=(function(){function DynamicAttribute(element,attributeManager,name,reference,namespace){this.element = element;this.attributeManager = attributeManager;this.name = name;this.reference = reference;this.namespace = namespace;this.cache = null;this.tag = reference.tag;}DynamicAttribute.prototype.patch = function patch(env){var element=this.element;var cache=this.cache;var value=_glimmerUtil.expect(cache,'must patch after flush').revalidate();if(_glimmerReference.isModified(value)){this.attributeManager.updateAttribute(env,element,value,this.namespace);}};DynamicAttribute.prototype.flush = function flush(env){var reference=this.reference;var element=this.element;if(_glimmerReference.isConst(reference)){var value=reference.value();this.attributeManager.setAttribute(env,element,value,this.namespace);return null;}else {var cache=this.cache = new _glimmerReference.ReferenceCache(reference);var value=cache.peek();this.attributeManager.setAttribute(env,element,value,this.namespace);return new PatchElementOpcode(this);}};DynamicAttribute.prototype.toJSON = function toJSON(){var element=this.element;var namespace=this.namespace;var name=this.name;var cache=this.cache;var formattedElement=formatElement(element);var lastValue=_glimmerUtil.expect(cache,'must serialize after flush').peek();if(namespace){return {element:formattedElement,type:'attribute',namespace:namespace,name:name,lastValue:lastValue};}return {element:formattedElement,type:'attribute',namespace:namespace === undefined?null:namespace,name:name,lastValue:lastValue};};return DynamicAttribute;})();function formatElement(element){return JSON.stringify('<' + element.tagName.toLowerCase() + ' />');}APPEND_OPCODES.add(42, /* DynamicAttrNS */function(vm,_ref24){var _name=_ref24.op1;var _namespace=_ref24.op2;var trusting=_ref24.op3;var name=vm.constants.getString(_name);var namespace=vm.constants.getString(_namespace);var reference=vm.frame.getOperand();vm.stack().setDynamicAttributeNS(namespace,name,reference,!!trusting);});APPEND_OPCODES.add(43, /* DynamicAttr */function(vm,_ref25){var _name=_ref25.op1;var trusting=_ref25.op2;var name=vm.constants.getString(_name);var reference=vm.frame.getOperand();vm.stack().setDynamicAttribute(name,reference,!!trusting);});var PatchElementOpcode=(function(_UpdatingOpcode7){babelHelpers.inherits(PatchElementOpcode,_UpdatingOpcode7);function PatchElementOpcode(operation){_UpdatingOpcode7.call(this);this.type = "patch-element";this.tag = operation.tag;this.operation = operation;}PatchElementOpcode.prototype.evaluate = function evaluate(vm){this.operation.patch(vm.env);};PatchElementOpcode.prototype.toJSON = function toJSON(){var _guid=this._guid;var type=this.type;var operation=this.operation;return {guid:_guid,type:type,details:operation.toJSON()};};return PatchElementOpcode;})(UpdatingOpcode);var First=(function(){function First(node){this.node = node;}First.prototype.firstNode = function firstNode(){return this.node;};return First;})();var Last=(function(){function Last(node){this.node = node;}Last.prototype.lastNode = function lastNode(){return this.node;};return Last;})();var Fragment=(function(){function Fragment(bounds){this.bounds = bounds;}Fragment.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};Fragment.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};Fragment.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};Fragment.prototype.update = function update(bounds){this.bounds = bounds;};return Fragment;})();var ElementStack=(function(){function ElementStack(env,parentNode,nextSibling){this.constructing = null;this.operations = null;this.elementStack = new _glimmerUtil.Stack();this.nextSiblingStack = new _glimmerUtil.Stack();this.blockStack = new _glimmerUtil.Stack();this.env = env;this.dom = env.getAppendOperations();this.updateOperations = env.getDOM();this.element = parentNode;this.nextSibling = nextSibling;this.defaultOperations = new SimpleElementOperations(env);this.elementStack.push(this.element);this.nextSiblingStack.push(this.nextSibling);}ElementStack.forInitialRender = function forInitialRender(env,parentNode,nextSibling){return new ElementStack(env,parentNode,nextSibling);};ElementStack.resume = function resume(env,tracker,nextSibling){var parentNode=tracker.parentElement();var stack=new ElementStack(env,parentNode,nextSibling);stack.pushBlockTracker(tracker);return stack;};ElementStack.prototype.expectConstructing = function expectConstructing(method){return _glimmerUtil.expect(this.constructing,method + ' should only be called while constructing an element');};ElementStack.prototype.expectOperations = function expectOperations(method){return _glimmerUtil.expect(this.operations,method + ' should only be called while constructing an element');};ElementStack.prototype.block = function block(){return _glimmerUtil.expect(this.blockStack.current,"Expected a current block tracker");};ElementStack.prototype.popElement = function popElement(){var elementStack=this.elementStack;var nextSiblingStack=this.nextSiblingStack;var topElement=elementStack.pop();nextSiblingStack.pop();_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.element = _glimmerUtil.expect(elementStack.current,"can't pop past the last element");this.nextSibling = nextSiblingStack.current;return topElement;};ElementStack.prototype.pushSimpleBlock = function pushSimpleBlock(){var tracker=new SimpleBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushUpdatableBlock = function pushUpdatableBlock(){var tracker=new UpdatableBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushBlockTracker = function pushBlockTracker(tracker){var isRemote=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);if(!isRemote){current.newBounds(tracker);}}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.pushBlockList = function pushBlockList(list){var tracker=new BlockListTracker(this.element,list);var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);current.newBounds(tracker);}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.popBlock = function popBlock(){this.block().finalize(this);return _glimmerUtil.expect(this.blockStack.pop(),"Expected popBlock to return a block");};ElementStack.prototype.openElement = function openElement(tag){var operations=arguments.length <= 1 || arguments[1] === undefined?this.defaultOperations:arguments[1];var element=this.dom.createElement(tag,this.element);this.constructing = element;this.operations = operations;return element;};ElementStack.prototype.flushElement = function flushElement(){var parent=this.element;var element=_glimmerUtil.expect(this.constructing,'flushElement should only be called when constructing an element');this.dom.insertBefore(parent,element,this.nextSibling);this.constructing = null;this.operations = null;this.pushElement(element);this.block().openElement(element);};ElementStack.prototype.pushRemoteElement = function pushRemoteElement(element){this.pushElement(element);var tracker=new RemoteBlockTracker(element);this.pushBlockTracker(tracker,true);};ElementStack.prototype.popRemoteElement = function popRemoteElement(){this.popBlock();this.popElement();};ElementStack.prototype.pushElement = function pushElement(element){this.element = element;this.elementStack.push(element);_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.nextSibling = null;this.nextSiblingStack.push(null);};ElementStack.prototype.newDestroyable = function newDestroyable(d){this.block().newDestroyable(d);};ElementStack.prototype.newBounds = function newBounds(bounds){this.block().newBounds(bounds);};ElementStack.prototype.appendText = function appendText(string){var dom=this.dom;var text=dom.createTextNode(string);dom.insertBefore(this.element,text,this.nextSibling);this.block().newNode(text);return text;};ElementStack.prototype.appendComment = function appendComment(string){var dom=this.dom;var comment=dom.createComment(string);dom.insertBefore(this.element,comment,this.nextSibling);this.block().newNode(comment);return comment;};ElementStack.prototype.setStaticAttribute = function setStaticAttribute(name,value){this.expectOperations('setStaticAttribute').addStaticAttribute(this.expectConstructing('setStaticAttribute'),name,value);};ElementStack.prototype.setStaticAttributeNS = function setStaticAttributeNS(namespace,name,value){this.expectOperations('setStaticAttributeNS').addStaticAttributeNS(this.expectConstructing('setStaticAttributeNS'),namespace,name,value);};ElementStack.prototype.setDynamicAttribute = function setDynamicAttribute(name,reference,isTrusting){this.expectOperations('setDynamicAttribute').addDynamicAttribute(this.expectConstructing('setDynamicAttribute'),name,reference,isTrusting);};ElementStack.prototype.setDynamicAttributeNS = function setDynamicAttributeNS(namespace,name,reference,isTrusting){this.expectOperations('setDynamicAttributeNS').addDynamicAttributeNS(this.expectConstructing('setDynamicAttributeNS'),namespace,name,reference,isTrusting);};ElementStack.prototype.closeElement = function closeElement(){this.block().closeElement();this.popElement();};return ElementStack;})();var SimpleBlockTracker=(function(){function SimpleBlockTracker(parent){this.parent = parent;this.first = null;this.last = null;this.destroyables = null;this.nesting = 0;}SimpleBlockTracker.prototype.destroy = function destroy(){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {destroyables[i].destroy();}}};SimpleBlockTracker.prototype.parentElement = function parentElement(){return this.parent;};SimpleBlockTracker.prototype.firstNode = function firstNode(){return this.first && this.first.firstNode();};SimpleBlockTracker.prototype.lastNode = function lastNode(){return this.last && this.last.lastNode();};SimpleBlockTracker.prototype.openElement = function openElement(element){this.newNode(element);this.nesting++;};SimpleBlockTracker.prototype.closeElement = function closeElement(){this.nesting--;};SimpleBlockTracker.prototype.newNode = function newNode(node){if(this.nesting !== 0)return;if(!this.first){this.first = new First(node);}this.last = new Last(node);};SimpleBlockTracker.prototype.newBounds = function newBounds(bounds){if(this.nesting !== 0)return;if(!this.first){this.first = bounds;}this.last = bounds;};SimpleBlockTracker.prototype.newDestroyable = function newDestroyable(d){this.destroyables = this.destroyables || [];this.destroyables.push(d);};SimpleBlockTracker.prototype.finalize = function finalize(stack){if(!this.first){stack.appendComment('');}};return SimpleBlockTracker;})();var RemoteBlockTracker=(function(_SimpleBlockTracker){babelHelpers.inherits(RemoteBlockTracker,_SimpleBlockTracker);function RemoteBlockTracker(){_SimpleBlockTracker.apply(this,arguments);}RemoteBlockTracker.prototype.destroy = function destroy(){_SimpleBlockTracker.prototype.destroy.call(this);clear(this);};return RemoteBlockTracker;})(SimpleBlockTracker);var UpdatableBlockTracker=(function(_SimpleBlockTracker2){babelHelpers.inherits(UpdatableBlockTracker,_SimpleBlockTracker2);function UpdatableBlockTracker(){_SimpleBlockTracker2.apply(this,arguments);}UpdatableBlockTracker.prototype.reset = function reset(env){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {env.didDestroy(destroyables[i]);}}var nextSibling=clear(this);this.destroyables = null;this.first = null;this.last = null;return nextSibling;};return UpdatableBlockTracker;})(SimpleBlockTracker);var BlockListTracker=(function(){function BlockListTracker(parent,boundList){this.parent = parent;this.boundList = boundList;this.parent = parent;this.boundList = boundList;}BlockListTracker.prototype.destroy = function destroy(){this.boundList.forEachNode(function(node){return node.destroy();});};BlockListTracker.prototype.parentElement = function parentElement(){return this.parent;};BlockListTracker.prototype.firstNode = function firstNode(){var head=this.boundList.head();return head && head.firstNode();};BlockListTracker.prototype.lastNode = function lastNode(){var tail=this.boundList.tail();return tail && tail.lastNode();};BlockListTracker.prototype.openElement = function openElement(_element){_glimmerUtil.assert(false,'Cannot openElement directly inside a block list');};BlockListTracker.prototype.closeElement = function closeElement(){_glimmerUtil.assert(false,'Cannot closeElement directly inside a block list');};BlockListTracker.prototype.newNode = function newNode(_node){_glimmerUtil.assert(false,'Cannot create a new node directly inside a block list');};BlockListTracker.prototype.newBounds = function newBounds(_bounds){};BlockListTracker.prototype.newDestroyable = function newDestroyable(_d){};BlockListTracker.prototype.finalize = function finalize(_stack){};return BlockListTracker;})();var CompiledValue=(function(_CompiledExpression){babelHelpers.inherits(CompiledValue,_CompiledExpression);function CompiledValue(value){_CompiledExpression.call(this);this.type = "value";this.reference = PrimitiveReference.create(value);}CompiledValue.prototype.evaluate = function evaluate(_vm){return this.reference;};CompiledValue.prototype.toJSON = function toJSON(){return JSON.stringify(this.reference.value());};return CompiledValue;})(CompiledExpression);var CompiledHasBlock=(function(_CompiledExpression2){babelHelpers.inherits(CompiledHasBlock,_CompiledExpression2);function CompiledHasBlock(inner){_CompiledExpression2.call(this);this.inner = inner;this.type = "has-block";}CompiledHasBlock.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);return PrimitiveReference.create(!!block);};CompiledHasBlock.prototype.toJSON = function toJSON(){return 'has-block(' + this.inner.toJSON() + ')';};return CompiledHasBlock;})(CompiledExpression);var CompiledHasBlockParams=(function(_CompiledExpression3){babelHelpers.inherits(CompiledHasBlockParams,_CompiledExpression3);function CompiledHasBlockParams(inner){_CompiledExpression3.call(this);this.inner = inner;this.type = "has-block-params";}CompiledHasBlockParams.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);var hasLocals=block && block.symbolTable.getSymbols().locals;return PrimitiveReference.create(!!hasLocals);};CompiledHasBlockParams.prototype.toJSON = function toJSON(){return 'has-block-params(' + this.inner.toJSON() + ')';};return CompiledHasBlockParams;})(CompiledExpression);var CompiledGetBlockBySymbol=(function(){function CompiledGetBlockBySymbol(symbol,debug){this.symbol = symbol;this.debug = debug;}CompiledGetBlockBySymbol.prototype.evaluate = function evaluate(vm){return vm.scope().getBlock(this.symbol);};CompiledGetBlockBySymbol.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '(' + this.debug + '))';};return CompiledGetBlockBySymbol;})();var CompiledInPartialGetBlock=(function(){function CompiledInPartialGetBlock(symbol,name){this.symbol = symbol;this.name = name;}CompiledInPartialGetBlock.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.blocks[name];};CompiledInPartialGetBlock.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '($ARGS).' + this.name + '))';};return CompiledInPartialGetBlock;})();var CompiledLookup=(function(_CompiledExpression4){babelHelpers.inherits(CompiledLookup,_CompiledExpression4);function CompiledLookup(base,path){_CompiledExpression4.call(this);this.base = base;this.path = path;this.type = "lookup";}CompiledLookup.create = function create(base,path){if(path.length === 0){return base;}else {return new this(base,path);}};CompiledLookup.prototype.evaluate = function evaluate(vm){var base=this.base;var path=this.path;return _glimmerReference.referenceFromParts(base.evaluate(vm),path);};CompiledLookup.prototype.toJSON = function toJSON(){return this.base.toJSON() + '.' + this.path.join('.');};return CompiledLookup;})(CompiledExpression);var CompiledSelf=(function(_CompiledExpression5){babelHelpers.inherits(CompiledSelf,_CompiledExpression5);function CompiledSelf(){_CompiledExpression5.apply(this,arguments);}CompiledSelf.prototype.evaluate = function evaluate(vm){return vm.getSelf();};CompiledSelf.prototype.toJSON = function toJSON(){return 'self';};return CompiledSelf;})(CompiledExpression);var CompiledSymbol=(function(_CompiledExpression6){babelHelpers.inherits(CompiledSymbol,_CompiledExpression6);function CompiledSymbol(symbol,debug){_CompiledExpression6.call(this);this.symbol = symbol;this.debug = debug;}CompiledSymbol.prototype.evaluate = function evaluate(vm){return vm.referenceForSymbol(this.symbol);};CompiledSymbol.prototype.toJSON = function toJSON(){return '$' + this.symbol + '(' + this.debug + ')';};return CompiledSymbol;})(CompiledExpression);var CompiledInPartialName=(function(_CompiledExpression7){babelHelpers.inherits(CompiledInPartialName,_CompiledExpression7);function CompiledInPartialName(symbol,name){_CompiledExpression7.call(this);this.symbol = symbol;this.name = name;}CompiledInPartialName.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.named.get(name);};CompiledInPartialName.prototype.toJSON = function toJSON(){return '$' + this.symbol + '($ARGS).' + this.name;};return CompiledInPartialName;})(CompiledExpression);var CompiledHelper=(function(_CompiledExpression8){babelHelpers.inherits(CompiledHelper,_CompiledExpression8);function CompiledHelper(name,helper,args,symbolTable){_CompiledExpression8.call(this);this.name = name;this.helper = helper;this.args = args;this.symbolTable = symbolTable;this.type = "helper";}CompiledHelper.prototype.evaluate = function evaluate(vm){var helper=this.helper;return helper(vm,this.args.evaluate(vm),this.symbolTable);};CompiledHelper.prototype.toJSON = function toJSON(){return '`' + this.name.join('.') + '($ARGS)`';};return CompiledHelper;})(CompiledExpression);var CompiledConcat=(function(){function CompiledConcat(parts){this.parts = parts;this.type = "concat";}CompiledConcat.prototype.evaluate = function evaluate(vm){var parts=new Array(this.parts.length);for(var i=0;i < this.parts.length;i++) {parts[i] = this.parts[i].evaluate(vm);}return new ConcatReference(parts);};CompiledConcat.prototype.toJSON = function toJSON(){return 'concat(' + this.parts.map(function(expr){return expr.toJSON();}).join(", ") + ')';};return CompiledConcat;})();var ConcatReference=(function(_CachedReference2){babelHelpers.inherits(ConcatReference,_CachedReference2);function ConcatReference(parts){_CachedReference2.call(this);this.parts = parts;this.tag = _glimmerReference.combineTagged(parts);}ConcatReference.prototype.compute = function compute(){var parts=new Array();for(var i=0;i < this.parts.length;i++) {var value=this.parts[i].value();if(value !== null && value !== undefined){parts[i] = castToString(value);}}if(parts.length > 0){return parts.join('');}return null;};return ConcatReference;})(_glimmerReference.CachedReference);function castToString(value){if(typeof value['toString'] !== 'function'){return '';}return String(value);}var CompiledFunctionExpression=(function(_CompiledExpression9){babelHelpers.inherits(CompiledFunctionExpression,_CompiledExpression9);function CompiledFunctionExpression(func,symbolTable){_CompiledExpression9.call(this);this.func = func;this.symbolTable = symbolTable;this.type = "function";this.func = func;}CompiledFunctionExpression.prototype.evaluate = function evaluate(vm){var func=this.func;var symbolTable=this.symbolTable;return func(vm,symbolTable);};CompiledFunctionExpression.prototype.toJSON = function toJSON(){var func=this.func;if(func.name){return '`' + func.name + '(...)`';}else {return "`func(...)`";}};return CompiledFunctionExpression;})(CompiledExpression);function debugCallback(context,get){console.info('Use `context`, and `get()` to debug this template.'); /* tslint:disable */debugger; /* tslint:enable */return {context:context,get:get};}function getter(vm,builder){return function(path){var parts=path.split('.');if(parts[0] === 'this'){parts[0] = null;}return compileRef(parts,builder).evaluate(vm);};}var callback=debugCallback; // For testing purposes +function setDebuggerCallback(cb){callback = cb;}function resetDebuggerCallback(){callback = debugCallback;}var Compilers=(function(){function Compilers(){this.names = _glimmerUtil.dict();this.funcs = [];}Compilers.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Compilers.prototype.compile = function compile(sexp,builder){var name=sexp[0];var index=this.names[name];var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected an implementation for ' + sexp[0]);return func(sexp,builder);};return Compilers;})();var STATEMENTS=new Compilers();STATEMENTS.add('text',function(sexp,builder){builder.text(sexp[1]);});STATEMENTS.add('comment',function(sexp,builder){builder.comment(sexp[1]);});STATEMENTS.add('close-element',function(_sexp,builder){_glimmerUtil.LOGGER.trace('close-element statement');builder.closeElement();});STATEMENTS.add('flush-element',function(_sexp,builder){builder.flushElement();});STATEMENTS.add('modifier',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var args=compileArgs(params,hash,builder);if(builder.env.hasModifier(path,builder.symbolTable)){builder.modifier(path[0],args);}else {throw new Error('Compile Error ' + path.join('.') + ' is not a modifier: Helpers may not be used in the element form.');}});STATEMENTS.add('static-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];builder.staticAttr(name,namespace,value);});STATEMENTS.add('any-dynamic-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];var trusting=sexp[4];builder.putValue(value);if(namespace){builder.dynamicAttrNS(name,namespace,trusting);}else {builder.dynamicAttr(name,trusting);}});STATEMENTS.add('open-element',function(sexp,builder){_glimmerUtil.LOGGER.trace('open-element statement');builder.openPrimitiveElement(sexp[1]);});STATEMENTS.add('optimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros=builder.env.macros();var inlines=_builder$env$macros.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;builder.putValue(returned[1]);if(trustingMorph){builder.trustingAppend();}else {builder.cautiousAppend();}});STATEMENTS.add('unoptimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros2=builder.env.macros();var inlines=_builder$env$macros2.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;if(trustingMorph){builder.guardedTrustingAppend(returned[1]);}else {builder.guardedCautiousAppend(returned[1]);}});STATEMENTS.add('nested-block',function(sexp,builder){var _builder$env$macros3=builder.env.macros();var blocks=_builder$env$macros3.blocks;blocks.compile(sexp,builder);});STATEMENTS.add('scanned-block',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var template=sexp[4];var inverse=sexp[5];var templateBlock=template && template.scan();var inverseBlock=inverse && inverse.scan();var _builder$env$macros4=builder.env.macros();var blocks=_builder$env$macros4.blocks;blocks.compile(['nested-block',path,params,hash,templateBlock,inverseBlock],builder);});STATEMENTS.add('scanned-component',function(sexp,builder){var tag=sexp[1];var attrs=sexp[2];var rawArgs=sexp[3];var rawBlock=sexp[4];var block=rawBlock && rawBlock.scan();var args=compileBlockArgs(null,rawArgs,{default:block,inverse:null},builder);var definition=builder.env.getComponentDefinition([tag],builder.symbolTable);builder.putComponentDefinition(definition);builder.openComponent(args,attrs.scan());builder.closeComponent();});STATEMENTS.add('static-partial',function(sexp,builder){var name=sexp[1];if(!builder.env.hasPartial(name,builder.symbolTable)){throw new Error('Compile Error: Could not find a partial named "' + name + '"');}var definition=builder.env.lookupPartial(name,builder.symbolTable);builder.putPartialDefinition(definition);builder.evaluatePartial();});STATEMENTS.add('dynamic-partial',function(sexp,builder){var name=sexp[1];builder.startLabels();builder.putValue(name);builder.test('simple');builder.enter('BEGIN','END');builder.label('BEGIN');builder.jumpUnless('END');builder.putDynamicPartialDefinition();builder.evaluatePartial();builder.label('END');builder.exit();builder.stopLabels();});STATEMENTS.add('yield',function(sexp,builder){var to=sexp[1];var params=sexp[2];var args=compileArgs(params,null,builder);builder.yield(args,to);});STATEMENTS.add('debugger',function(sexp,builder){builder.putValue(['function',function(vm){var context=vm.getSelf().value();var get=function(path){return getter(vm,builder)(path).value();};callback(context,get);}]);return sexp;});var EXPRESSIONS=new Compilers();function expr(expression,builder){if(Array.isArray(expression)){return EXPRESSIONS.compile(expression,builder);}else {return new CompiledValue(expression);}}EXPRESSIONS.add('unknown',function(sexp,builder){var path=sexp[1];if(builder.env.hasHelper(path,builder.symbolTable)){return new CompiledHelper(path,builder.env.lookupHelper(path,builder.symbolTable),CompiledArgs.empty(),builder.symbolTable);}else {return compileRef(path,builder);}});EXPRESSIONS.add('concat',function(sexp,builder){var params=sexp[1].map(function(p){return expr(p,builder);});return new CompiledConcat(params);});EXPRESSIONS.add('function',function(sexp,builder){return new CompiledFunctionExpression(sexp[1],builder.symbolTable);});EXPRESSIONS.add('helper',function(sexp,builder){var env=builder.env;var symbolTable=builder.symbolTable;var path=sexp[1];var params=sexp[2];var hash=sexp[3];if(env.hasHelper(path,symbolTable)){var args=compileArgs(params,hash,builder);return new CompiledHelper(path,env.lookupHelper(path,symbolTable),args,symbolTable);}else {throw new Error('Compile Error: ' + path.join('.') + ' is not a helper');}});EXPRESSIONS.add('get',function(sexp,builder){return compileRef(sexp[1],builder);});EXPRESSIONS.add('undefined',function(_sexp,_builder){return new CompiledValue(undefined);});EXPRESSIONS.add('arg',function(sexp,builder){var parts=sexp[1];var head=parts[0];var named=undefined,partial=undefined;if(named = builder.symbolTable.getSymbol('named',head)){var path=parts.slice(1);var inner=new CompiledSymbol(named,head);return CompiledLookup.create(inner,path);}else if(partial = builder.symbolTable.getPartialArgs()){var path=parts.slice(1);var inner=new CompiledInPartialName(partial,head);return CompiledLookup.create(inner,path);}else {throw new Error('[BUG] @' + parts.join('.') + ' is not a valid lookup path.');}});EXPRESSIONS.add('has-block',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlock(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlock(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});EXPRESSIONS.add('has-block-params',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlockParams(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlockParams(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});function compileArgs(params,hash,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,EMPTY_BLOCKS);}function compileBlockArgs(params,hash,blocks,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,blocks);}function compileBaselineArgs(args,builder){var params=args[0];var hash=args[1];var _default=args[2];var inverse=args[3];return CompiledArgs.create(compileParams(params,builder),compileHash(hash,builder),{default:_default,inverse:inverse});}function compileParams(params,builder){if(!params || params.length === 0)return COMPILED_EMPTY_POSITIONAL_ARGS;var compiled=params.map(function(p){return expr(p,builder);});return CompiledPositionalArgs.create(compiled);}function compileHash(hash,builder){if(!hash)return COMPILED_EMPTY_NAMED_ARGS;var keys=hash[0];var values=hash[1];if(keys.length === 0)return COMPILED_EMPTY_NAMED_ARGS;var compiled=values.map(function(p){return expr(p,builder);});return new CompiledNamedArgs(keys,compiled);}function compileRef(parts,builder){var head=parts[0];var local=undefined;if(head === null){var inner=new CompiledSelf();var path=parts.slice(1);return CompiledLookup.create(inner,path);}else if(local = builder.symbolTable.getSymbol('local',head)){var path=parts.slice(1);var inner=new CompiledSymbol(local,head);return CompiledLookup.create(inner,path);}else {var inner=new CompiledSelf();return CompiledLookup.create(inner,parts);}}var Blocks=(function(){function Blocks(){this.names = _glimmerUtil.dict();this.funcs = [];}Blocks.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Blocks.prototype.addMissing = function addMissing(func){this.missing = func;};Blocks.prototype.compile = function compile(sexp,builder){ // assert(sexp[1].length === 1, 'paths in blocks are not supported'); +var name=sexp[1][0];var index=this.names[name];if(index === undefined){_glimmerUtil.assert(!!this.missing,name + ' not found, and no catch-all block handler was registered');var func=this.missing;var handled=func(sexp,builder);_glimmerUtil.assert(!!handled,name + ' not found, and the catch-all block handler didn\'t handle it');}else {var func=this.funcs[index];func(sexp,builder);}};return Blocks;})();var BLOCKS=new Blocks();var Inlines=(function(){function Inlines(){this.names = _glimmerUtil.dict();this.funcs = [];}Inlines.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Inlines.prototype.addMissing = function addMissing(func){this.missing = func;};Inlines.prototype.compile = function compile(sexp,builder){var value=sexp[1]; // TODO: Fix this so that expression macros can return +// things like components, so that {{component foo}} +// is the same as {{(component foo)}} +if(!Array.isArray(value))return ['expr',value];var path=undefined;var params=undefined;var hash=undefined;if(value[0] === 'helper'){path = value[1];params = value[2];hash = value[3];}else if(value[0] === 'unknown'){path = value[1];params = hash = null;}else {return ['expr',value];}if(path.length > 1 && !params && !hash){return ['expr',value];}var name=path[0];var index=this.names[name];if(index === undefined && this.missing){var func=this.missing;var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else if(index !== undefined){var func=this.funcs[index];var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else {return ['expr',value];}};return Inlines;})();var INLINES=new Inlines();populateBuiltins(BLOCKS,INLINES);function populateBuiltins(){var blocks=arguments.length <= 0 || arguments[0] === undefined?new Blocks():arguments[0];var inlines=arguments.length <= 1 || arguments[1] === undefined?new Inlines():arguments[1];blocks.add('if',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('unless',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpIf('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpIf('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('with',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('each',function(sexp,builder){ // Enter(BEGIN, END) +// BEGIN: Noop +// PutArgs +// PutIterable +// JumpUnless(ELSE) +// EnterList(BEGIN2, END2) +// ITER: Noop +// NextIter(BREAK) +// EnterWithKey(BEGIN2, END2) +// BEGIN2: Noop +// PushChildScope +// Evaluate(default) +// PopScope +// END2: Noop +// Exit +// Jump(ITER) +// BREAK: Noop +// ExitList +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.labelled(args,function(b){b.putIterator();if(inverse){b.jumpUnless('ELSE');}else {b.jumpUnless('END');}b.iter(function(b){b.evaluate(_glimmerUtil.unwrap(_default));});if(inverse){b.jump('END');b.label('ELSE');b.evaluate(inverse);}});});return {blocks:blocks,inlines:inlines};}var badProtocols=['javascript:','vbscript:'];var badTags=['A','BODY','LINK','IMG','IFRAME','BASE','FORM'];var badTagsForDataURI=['EMBED'];var badAttributes=['href','src','background','action'];var badAttributesForDataURI=['src'];function has(array,item){return array.indexOf(item) !== -1;}function checkURI(tagName,attribute){return (tagName === null || has(badTags,tagName)) && has(badAttributes,attribute);}function checkDataURI(tagName,attribute){if(tagName === null)return false;return has(badTagsForDataURI,tagName) && has(badAttributesForDataURI,attribute);}function requiresSanitization(tagName,attribute){return checkURI(tagName,attribute) || checkDataURI(tagName,attribute);}function sanitizeAttributeValue(env,element,attribute,value){var tagName=null;if(value === null || value === undefined){return value;}if(isSafeString(value)){return value.toHTML();}if(!element){tagName = null;}else {tagName = element.tagName.toUpperCase();}var str=normalizeTextValue(value);if(checkURI(tagName,attribute)){var protocol=env.protocolForURL(str);if(has(badProtocols,protocol)){return 'unsafe:' + str;}}if(checkDataURI(tagName,attribute)){return 'unsafe:' + str;}return str;} /* + * @method normalizeProperty + * @param element {HTMLElement} + * @param slotName {String} + * @returns {Object} { name, type } + */function normalizeProperty(element,slotName){var type=undefined,normalized=undefined;if(slotName in element){normalized = slotName;type = 'prop';}else {var lower=slotName.toLowerCase();if(lower in element){type = 'prop';normalized = lower;}else {type = 'attr';normalized = slotName;}}if(type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName,normalized))){type = 'attr';}return {normalized:normalized,type:type};} // properties that MUST be set as attributes, due to: +// * browser bug +// * strange spec outlier +var ATTR_OVERRIDES={ // phantomjs < 2.0 lets you set it as a prop but won't reflect it +// back to the attribute. button.getAttribute('type') === null +BUTTON:{type:true,form:true},INPUT:{ // Some version of IE (like IE9) actually throw an exception +// if you set input.type = 'something-unknown' +type:true,form:true, // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false +// Safari 8.0.7: 'autocorrect' in document.createElement('input') === false +// Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true +autocorrect:true, // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true +// Safari 9.1.3: 'list' in document.createElement('input') === false +list:true}, // element.form is actually a legitimate readOnly property, that is to be +// mutated, but must be mutated by setAttribute... +SELECT:{form:true},OPTION:{form:true},TEXTAREA:{form:true},LABEL:{form:true},FIELDSET:{form:true},LEGEND:{form:true},OBJECT:{form:true}};function preferAttr(tagName,propName){var tag=ATTR_OVERRIDES[tagName.toUpperCase()];return tag && tag[propName.toLowerCase()] || false;}var innerHTMLWrapper={colgroup:{depth:2,before:'',after:'
'},table:{depth:1,before:'',after:'
'},tbody:{depth:2,before:'',after:'
'},tfoot:{depth:2,before:'',after:'
'},thead:{depth:2,before:'',after:'
'},tr:{depth:3,before:'',after:'
'}}; // Patch: innerHTML Fix +// Browsers: IE9 +// Reason: IE9 don't allow us to set innerHTML on col, colgroup, frameset, +// html, style, table, tbody, tfoot, thead, title, tr. +// Fix: Wrap the innerHTML we are about to set in its parents, apply the +// wrapped innerHTML on a div, then move the unwrapped nodes into the +// target position. +function domChanges(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix(document)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass){babelHelpers.inherits(DOMChangesWithInnerHTMLFix,_DOMChangesClass);function DOMChangesWithInnerHTMLFix(){_DOMChangesClass.apply(this,arguments);}DOMChangesWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixInnerHTML(parent,wrapper,div,html,nextSibling);};return DOMChangesWithInnerHTMLFix;})(DOMChangesClass);}function treeConstruction(document,DOMTreeConstructionClass){if(!document)return DOMTreeConstructionClass;if(!shouldApplyFix(document)){return DOMTreeConstructionClass;}var div=document.createElement('div');return (function(_DOMTreeConstructionClass){babelHelpers.inherits(DOMTreeConstructionWithInnerHTMLFix,_DOMTreeConstructionClass);function DOMTreeConstructionWithInnerHTMLFix(){_DOMTreeConstructionClass.apply(this,arguments);}DOMTreeConstructionWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixInnerHTML(parent,wrapper,div,html,reference);};return DOMTreeConstructionWithInnerHTMLFix;})(DOMTreeConstructionClass);}function fixInnerHTML(parent,wrapper,div,html,reference){var wrappedHtml=wrapper.before + html + wrapper.after;div.innerHTML = wrappedHtml;var parentNode=div;for(var i=0;i < wrapper.depth;i++) {parentNode = parentNode.childNodes[0];}var _moveNodesBefore=moveNodesBefore(parentNode,parent,reference);var first=_moveNodesBefore[0];var last=_moveNodesBefore[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix(document){var table=document.createElement('table');try{table.innerHTML = '';}catch(e) {}finally {if(table.childNodes.length !== 0){ // It worked as expected, no fix required +return false;}}return true;}var SVG_NAMESPACE$1='http://www.w3.org/2000/svg'; // Patch: insertAdjacentHTML on SVG Fix +// Browsers: Safari, IE, Edge, Firefox ~33-34 +// Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is +// present but throws an exception on IE and Edge. Old versions of +// Firefox create nodes in the incorrect namespace. +// Fix: Since IE and Edge silently fail to create SVG nodes using +// innerHTML, and because Firefox may create nodes in the incorrect +// namespace using innerHTML on SVG elements, an HTML-string wrapping +// approach is used. A pre/post SVG tag is added to the string, then +// that whole string is added to a div. The created nodes are plucked +// out and applied to the target location on DOM. +function domChanges$1(document,DOMChangesClass,svgNamespace){if(!document)return DOMChangesClass;if(!shouldApplyFix$1(document,svgNamespace)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass2){babelHelpers.inherits(DOMChangesWithSVGInnerHTMLFix,_DOMChangesClass2);function DOMChangesWithSVGInnerHTMLFix(){_DOMChangesClass2.apply(this,arguments);}DOMChangesWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}if(parent.namespaceURI !== svgNamespace){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixSVG(parent,div,html,nextSibling);};return DOMChangesWithSVGInnerHTMLFix;})(DOMChangesClass);}function treeConstruction$1(document,TreeConstructionClass,svgNamespace){if(!document)return TreeConstructionClass;if(!shouldApplyFix$1(document,svgNamespace)){return TreeConstructionClass;}var div=document.createElement('div');return (function(_TreeConstructionClass){babelHelpers.inherits(TreeConstructionWithSVGInnerHTMLFix,_TreeConstructionClass);function TreeConstructionWithSVGInnerHTMLFix(){_TreeConstructionClass.apply(this,arguments);}TreeConstructionWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}if(parent.namespaceURI !== svgNamespace){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixSVG(parent,div,html,reference);};return TreeConstructionWithSVGInnerHTMLFix;})(TreeConstructionClass);}function fixSVG(parent,div,html,reference){ // IE, Edge: also do not correctly support using `innerHTML` on SVG +// namespaced elements. So here a wrapper is used. +var wrappedHtml='' + html + '';div.innerHTML = wrappedHtml;var _moveNodesBefore2=moveNodesBefore(div.firstChild,parent,reference);var first=_moveNodesBefore2[0];var last=_moveNodesBefore2[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix$1(document,svgNamespace){var svg=document.createElementNS(svgNamespace,'svg');try{svg['insertAdjacentHTML']('beforeEnd','');}catch(e) {}finally { // FF: Old versions will create a node in the wrong namespace +if(svg.childNodes.length === 1 && _glimmerUtil.unwrap(svg.firstChild).namespaceURI === SVG_NAMESPACE$1){ // The test worked as expected, no fix required +return false;}return true;}} // Patch: Adjacent text node merging fix +// Browsers: IE, Edge, Firefox w/o inspector open +// Reason: These browsers will merge adjacent text nodes. For exmaple given +//
Hello
with div.insertAdjacentHTML(' world') browsers +// with proper behavior will populate div.childNodes with two items. +// These browsers will populate it with one merged node instead. +// Fix: Add these nodes to a wrapper element, then iterate the childNodes +// of that wrapper and move the nodes to their target location. Note +// that potential SVG bugs will have been handled before this fix. +// Note that this fix must only apply to the previous text node, as +// the base implementation of `insertHTMLBefore` already handles +// following text nodes correctly. +function domChanges$2(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix$2(document)){return DOMChangesClass;}return (function(_DOMChangesClass3){babelHelpers.inherits(DOMChangesWithTextNodeMergingFix,_DOMChangesClass3);function DOMChangesWithTextNodeMergingFix(document){_DOMChangesClass3.call(this,document);this.uselessComment = document.createComment('');}DOMChangesWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null){return _DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var didSetUselessComment=false;var nextPrevious=nextSibling?nextSibling.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,nextSibling);}var bounds=_DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return DOMChangesWithTextNodeMergingFix;})(DOMChangesClass);}function treeConstruction$2(document,TreeConstructionClass){if(!document)return TreeConstructionClass;if(!shouldApplyFix$2(document)){return TreeConstructionClass;}return (function(_TreeConstructionClass2){babelHelpers.inherits(TreeConstructionWithTextNodeMergingFix,_TreeConstructionClass2);function TreeConstructionWithTextNodeMergingFix(document){_TreeConstructionClass2.call(this,document);this.uselessComment = this.createComment('');}TreeConstructionWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null){return _TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);}var didSetUselessComment=false;var nextPrevious=reference?reference.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,reference);}var bounds=_TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return TreeConstructionWithTextNodeMergingFix;})(TreeConstructionClass);}function shouldApplyFix$2(document){var mergingTextDiv=document.createElement('div');mergingTextDiv.innerHTML = 'first';mergingTextDiv.insertAdjacentHTML('beforeEnd','second');if(mergingTextDiv.childNodes.length === 2){ // It worked as expected, no fix required +return false;}return true;}var SVG_NAMESPACE='http://www.w3.org/2000/svg'; // http://www.w3.org/TR/html/syntax.html#html-integration-point +var SVG_INTEGRATION_POINTS={foreignObject:1,desc:1,title:1}; // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes +// TODO: Adjust SVG attributes +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +// TODO: Adjust SVG elements +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +var BLACKLIST_TABLE=Object.create(null);["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach(function(tag){return BLACKLIST_TABLE[tag] = 1;});var WHITESPACE=/[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;var doc=typeof document === 'undefined'?null:document;function isWhitespace(string){return WHITESPACE.test(string);}function moveNodesBefore(source,target,nextSibling){var first=source.firstChild;var last=null;var current=first;while(current) {last = current;current = current.nextSibling;target.insertBefore(last,nextSibling);}return [first,last];}var DOM;(function(DOM){var TreeConstruction=(function(){function TreeConstruction(document){this.document = document;this.setupUselessElement();}TreeConstruction.prototype.setupUselessElement = function setupUselessElement(){this.uselessElement = this.document.createElement('div');};TreeConstruction.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};TreeConstruction.prototype.createElementNS = function createElementNS(namespace,tag){return this.document.createElementNS(namespace,tag);};TreeConstruction.prototype.setAttribute = function setAttribute(element,name,value,namespace){if(namespace){element.setAttributeNS(namespace,name,value);}else {element.setAttribute(name,value);}};TreeConstruction.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};TreeConstruction.prototype.createComment = function createComment(data){return this.document.createComment(data);};TreeConstruction.prototype.insertBefore = function insertBefore(parent,node,reference){parent.insertBefore(node,reference);};TreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){return _insertHTMLBefore(this.uselessElement,parent,reference,html);};return TreeConstruction;})();DOM.TreeConstruction = TreeConstruction;var appliedTreeContruction=TreeConstruction;appliedTreeContruction = treeConstruction$2(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction$1(doc,appliedTreeContruction,SVG_NAMESPACE);DOM.DOMTreeConstruction = appliedTreeContruction;})(DOM || (DOM = {}));var DOMChanges=(function(){function DOMChanges(document){this.document = document;this.namespace = null;this.uselessElement = this.document.createElement('div');}DOMChanges.prototype.setAttribute = function setAttribute(element,name,value){element.setAttribute(name,value);};DOMChanges.prototype.setAttributeNS = function setAttributeNS(element,namespace,name,value){element.setAttributeNS(namespace,name,value);};DOMChanges.prototype.removeAttribute = function removeAttribute(element,name){element.removeAttribute(name);};DOMChanges.prototype.removeAttributeNS = function removeAttributeNS(element,namespace,name){element.removeAttributeNS(namespace,name);};DOMChanges.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};DOMChanges.prototype.createComment = function createComment(data){return this.document.createComment(data);};DOMChanges.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};DOMChanges.prototype.insertHTMLBefore = function insertHTMLBefore(_parent,nextSibling,html){return _insertHTMLBefore(this.uselessElement,_parent,nextSibling,html);};DOMChanges.prototype.insertNodeBefore = function insertNodeBefore(parent,node,reference){if(isDocumentFragment(node)){var firstChild=node.firstChild;var lastChild=node.lastChild;this.insertBefore(parent,node,reference);return new ConcreteBounds(parent,firstChild,lastChild);}else {this.insertBefore(parent,node,reference);return new SingleNodeBounds(parent,node);}};DOMChanges.prototype.insertTextBefore = function insertTextBefore(parent,nextSibling,text){var textNode=this.createTextNode(text);this.insertBefore(parent,textNode,nextSibling);return textNode;};DOMChanges.prototype.insertBefore = function insertBefore(element,node,reference){element.insertBefore(node,reference);};DOMChanges.prototype.insertAfter = function insertAfter(element,node,reference){this.insertBefore(element,node,reference.nextSibling);};return DOMChanges;})();function _insertHTMLBefore(_useless,_parent,_nextSibling,html){ // TypeScript vendored an old version of the DOM spec where `insertAdjacentHTML` +// only exists on `HTMLElement` but not on `Element`. We actually work with the +// newer version of the DOM API here (and monkey-patch this method in `./compat` +// when we detect older browsers). This is a hack to work around this limitation. +var parent=_parent;var useless=_useless;var nextSibling=_nextSibling;var prev=nextSibling?nextSibling.previousSibling:parent.lastChild;var last=undefined;if(html === null || html === ''){return new ConcreteBounds(parent,null,null);}if(nextSibling === null){parent.insertAdjacentHTML('beforeEnd',html);last = parent.lastChild;}else if(nextSibling instanceof HTMLElement){nextSibling.insertAdjacentHTML('beforeBegin',html);last = nextSibling.previousSibling;}else { // Non-element nodes do not support insertAdjacentHTML, so add an +// element and call it on that element. Then remove the element. +// +// This also protects Edge, IE and Firefox w/o the inspector open +// from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts +parent.insertBefore(useless,nextSibling);useless.insertAdjacentHTML('beforeBegin',html);last = useless.previousSibling;parent.removeChild(useless);}var first=prev?prev.nextSibling:parent.firstChild;return new ConcreteBounds(parent,first,last);}function isDocumentFragment(node){return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;}var helper=DOMChanges;helper = domChanges$2(doc,helper);helper = domChanges(doc,helper);helper = domChanges$1(doc,helper,SVG_NAMESPACE);var helper$1=helper;var DOMTreeConstruction=DOM.DOMTreeConstruction;function defaultManagers(element,attr,_isTrusting,_namespace){var tagName=element.tagName;var isSVG=element.namespaceURI === SVG_NAMESPACE;if(isSVG){return defaultAttributeManagers(tagName,attr);}var _normalizeProperty=normalizeProperty(element,attr);var type=_normalizeProperty.type;var normalized=_normalizeProperty.normalized;if(type === 'attr'){return defaultAttributeManagers(tagName,normalized);}else {return defaultPropertyManagers(tagName,normalized);}}function defaultPropertyManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafePropertyManager(attr);}if(isUserInputValue(tagName,attr)){return INPUT_VALUE_PROPERTY_MANAGER;}if(isOptionSelected(tagName,attr)){return OPTION_SELECTED_MANAGER;}return new PropertyManager(attr);}function defaultAttributeManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafeAttributeManager(attr);}return new AttributeManager(attr);}function readDOMAttr(element,attr){var isSVG=element.namespaceURI === SVG_NAMESPACE;var _normalizeProperty2=normalizeProperty(element,attr);var type=_normalizeProperty2.type;var normalized=_normalizeProperty2.normalized;if(isSVG){return element.getAttribute(normalized);}if(type === 'attr'){return element.getAttribute(normalized);}{return element[normalized];}};var AttributeManager=(function(){function AttributeManager(attr){this.attr = attr;}AttributeManager.prototype.setAttribute = function setAttribute(env,element,value,namespace){var dom=env.getAppendOperations();var normalizedValue=normalizeAttributeValue(value);if(!isAttrRemovalValue(normalizedValue)){dom.setAttribute(element,this.attr,normalizedValue,namespace);}};AttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){if(value === null || value === undefined || value === false){if(namespace){env.getDOM().removeAttributeNS(element,namespace,this.attr);}else {env.getDOM().removeAttribute(element,this.attr);}}else {this.setAttribute(env,element,value);}};return AttributeManager;})();;var PropertyManager=(function(_AttributeManager){babelHelpers.inherits(PropertyManager,_AttributeManager);function PropertyManager(){_AttributeManager.apply(this,arguments);}PropertyManager.prototype.setAttribute = function setAttribute(_env,element,value,_namespace){if(!isAttrRemovalValue(value)){element[this.attr] = value;}};PropertyManager.prototype.removeAttribute = function removeAttribute(env,element,namespace){ // TODO this sucks but to preserve properties first and to meet current +// semantics we must do this. +var attr=this.attr;if(namespace){env.getDOM().removeAttributeNS(element,namespace,attr);}else {env.getDOM().removeAttribute(element,attr);}};PropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){ // ensure the property is always updated +element[this.attr] = value;if(isAttrRemovalValue(value)){this.removeAttribute(env,element,namespace);}};return PropertyManager;})(AttributeManager);;function normalizeAttributeValue(value){if(value === false || value === undefined || value === null){return null;}if(value === true){return '';} // onclick function etc in SSR +if(typeof value === 'function'){return null;}return String(value);}function isAttrRemovalValue(value){return value === null || value === undefined;}var SafePropertyManager=(function(_PropertyManager){babelHelpers.inherits(SafePropertyManager,_PropertyManager);function SafePropertyManager(){_PropertyManager.apply(this,arguments);}SafePropertyManager.prototype.setAttribute = function setAttribute(env,element,value){_PropertyManager.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafePropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value){_PropertyManager.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafePropertyManager;})(PropertyManager);function isUserInputValue(tagName,attribute){return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value';}var InputValuePropertyManager=(function(_AttributeManager2){babelHelpers.inherits(InputValuePropertyManager,_AttributeManager2);function InputValuePropertyManager(){_AttributeManager2.apply(this,arguments);}InputValuePropertyManager.prototype.setAttribute = function setAttribute(_env,element,value){var input=element;input.value = normalizeTextValue(value);};InputValuePropertyManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var input=element;var currentValue=input.value;var normalizedValue=normalizeTextValue(value);if(currentValue !== normalizedValue){input.value = normalizedValue;}};return InputValuePropertyManager;})(AttributeManager);var INPUT_VALUE_PROPERTY_MANAGER=new InputValuePropertyManager('value');function isOptionSelected(tagName,attribute){return tagName === 'OPTION' && attribute === 'selected';}var OptionSelectedManager=(function(_PropertyManager2){babelHelpers.inherits(OptionSelectedManager,_PropertyManager2);function OptionSelectedManager(){_PropertyManager2.apply(this,arguments);}OptionSelectedManager.prototype.setAttribute = function setAttribute(_env,element,value){if(value !== null && value !== undefined && value !== false){var option=element;option.selected = true;}};OptionSelectedManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var option=element;if(value){option.selected = true;}else {option.selected = false;}};return OptionSelectedManager;})(PropertyManager);var OPTION_SELECTED_MANAGER=new OptionSelectedManager('selected');var SafeAttributeManager=(function(_AttributeManager3){babelHelpers.inherits(SafeAttributeManager,_AttributeManager3);function SafeAttributeManager(){_AttributeManager3.apply(this,arguments);}SafeAttributeManager.prototype.setAttribute = function setAttribute(env,element,value){_AttributeManager3.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafeAttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,_namespace){_AttributeManager3.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafeAttributeManager;})(AttributeManager);var Scope=(function(){function Scope(references){var callerScope=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];this.callerScope = null;this.slots = references;this.callerScope = callerScope;}Scope.root = function root(self){var size=arguments.length <= 1 || arguments[1] === undefined?0:arguments[1];var refs=new Array(size + 1);for(var i=0;i <= size;i++) {refs[i] = UNDEFINED_REFERENCE;}return new Scope(refs).init({self:self});};Scope.prototype.init = function init(_ref26){var self=_ref26.self;this.slots[0] = self;return this;};Scope.prototype.getSelf = function getSelf(){return this.slots[0];};Scope.prototype.getSymbol = function getSymbol(symbol){return this.slots[symbol];};Scope.prototype.getBlock = function getBlock(symbol){return this.slots[symbol];};Scope.prototype.getPartialArgs = function getPartialArgs(symbol){return this.slots[symbol];};Scope.prototype.bindSymbol = function bindSymbol(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindBlock = function bindBlock(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindPartialArgs = function bindPartialArgs(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindCallerScope = function bindCallerScope(scope){this.callerScope = scope;};Scope.prototype.getCallerScope = function getCallerScope(){return this.callerScope;};Scope.prototype.child = function child(){return new Scope(this.slots.slice(),this.callerScope);};return Scope;})();var Transaction=(function(){function Transaction(){this.scheduledInstallManagers = [];this.scheduledInstallModifiers = [];this.scheduledUpdateModifierManagers = [];this.scheduledUpdateModifiers = [];this.createdComponents = [];this.createdManagers = [];this.updatedComponents = [];this.updatedManagers = [];this.destructors = [];}Transaction.prototype.didCreate = function didCreate(component,manager){this.createdComponents.push(component);this.createdManagers.push(manager);};Transaction.prototype.didUpdate = function didUpdate(component,manager){this.updatedComponents.push(component);this.updatedManagers.push(manager);};Transaction.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.scheduledInstallManagers.push(manager);this.scheduledInstallModifiers.push(modifier);};Transaction.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.scheduledUpdateModifierManagers.push(manager);this.scheduledUpdateModifiers.push(modifier);};Transaction.prototype.didDestroy = function didDestroy(d){this.destructors.push(d);};Transaction.prototype.commit = function commit(){var createdComponents=this.createdComponents;var createdManagers=this.createdManagers;for(var i=0;i < createdComponents.length;i++) {var component=createdComponents[i];var manager=createdManagers[i];manager.didCreate(component);}var updatedComponents=this.updatedComponents;var updatedManagers=this.updatedManagers;for(var i=0;i < updatedComponents.length;i++) {var component=updatedComponents[i];var manager=updatedManagers[i];manager.didUpdate(component);}var destructors=this.destructors;for(var i=0;i < destructors.length;i++) {destructors[i].destroy();}var scheduledInstallManagers=this.scheduledInstallManagers;var scheduledInstallModifiers=this.scheduledInstallModifiers;for(var i=0;i < scheduledInstallManagers.length;i++) {var manager=scheduledInstallManagers[i];var modifier=scheduledInstallModifiers[i];manager.install(modifier);}var scheduledUpdateModifierManagers=this.scheduledUpdateModifierManagers;var scheduledUpdateModifiers=this.scheduledUpdateModifiers;for(var i=0;i < scheduledUpdateModifierManagers.length;i++) {var manager=scheduledUpdateModifierManagers[i];var modifier=scheduledUpdateModifiers[i];manager.update(modifier);}};return Transaction;})();var Opcode=(function(){function Opcode(array){this.array = array;this.offset = 0;}babelHelpers.createClass(Opcode,[{key:'type',get:function(){return this.array[this.offset];}},{key:'op1',get:function(){return this.array[this.offset + 1];}},{key:'op2',get:function(){return this.array[this.offset + 2];}},{key:'op3',get:function(){return this.array[this.offset + 3];}}]);return Opcode;})();var Program=(function(){function Program(){this.opcodes = new _glimmerUtil.A(0x100000);this._offset = 0;this._opcode = new Opcode(this.opcodes);}Program.prototype.opcode = function opcode(offset){this._opcode.offset = offset;return this._opcode;};Program.prototype.set = function set(pos,opcode){var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[pos] = type;this.opcodes[pos + 1] = op1;this.opcodes[pos + 2] = op2;this.opcodes[pos + 3] = op3;};Program.prototype.push = function push(opcode){var offset=this._offset;var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[this._offset++] = type;this.opcodes[this._offset++] = op1;this.opcodes[this._offset++] = op2;this.opcodes[this._offset++] = op3;return offset;};babelHelpers.createClass(Program,[{key:'next',get:function(){return this._offset;}},{key:'current',get:function(){return this._offset - 4;}}]);return Program;})();var Environment=(function(){function Environment(_ref27){var appendOperations=_ref27.appendOperations;var updateOperations=_ref27.updateOperations;this._macros = null;this._transaction = null;this.constants = new Constants();this.program = new Program();this.appendOperations = appendOperations;this.updateOperations = updateOperations;}Environment.prototype.toConditionalReference = function toConditionalReference(reference){return new ConditionalReference(reference);};Environment.prototype.getAppendOperations = function getAppendOperations(){return this.appendOperations;};Environment.prototype.getDOM = function getDOM(){return this.updateOperations;};Environment.prototype.getIdentity = function getIdentity(object){return _glimmerUtil.ensureGuid(object) + '';};Environment.prototype.begin = function begin(){_glimmerUtil.assert(!this._transaction,'Cannot start a nested transaction');this._transaction = new Transaction();};Environment.prototype.didCreate = function didCreate(component,manager){this.transaction.didCreate(component,manager);};Environment.prototype.didUpdate = function didUpdate(component,manager){this.transaction.didUpdate(component,manager);};Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.transaction.scheduleInstallModifier(modifier,manager);};Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.transaction.scheduleUpdateModifier(modifier,manager);};Environment.prototype.didDestroy = function didDestroy(d){this.transaction.didDestroy(d);};Environment.prototype.commit = function commit(){this.transaction.commit();this._transaction = null;};Environment.prototype.attributeFor = function attributeFor(element,attr,isTrusting,namespace){return defaultManagers(element,attr,isTrusting,namespace === undefined?null:namespace);};Environment.prototype.macros = function macros(){var macros=this._macros;if(!macros){this._macros = macros = populateBuiltins();}return macros;};babelHelpers.createClass(Environment,[{key:'transaction',get:function(){return _glimmerUtil.expect(this._transaction,'must be in a transaction');}}]);return Environment;})();var RenderResult=(function(){function RenderResult(env,updating,bounds){this.env = env;this.updating = updating;this.bounds = bounds;}RenderResult.prototype.rerender = function rerender(){var _ref28=arguments.length <= 0 || arguments[0] === undefined?{alwaysRevalidate:false}:arguments[0];var _ref28$alwaysRevalidate=_ref28.alwaysRevalidate;var alwaysRevalidate=_ref28$alwaysRevalidate === undefined?false:_ref28$alwaysRevalidate;var env=this.env;var updating=this.updating;var vm=new UpdatingVM(env,{alwaysRevalidate:alwaysRevalidate});vm.execute(updating,this);};RenderResult.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};RenderResult.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};RenderResult.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};RenderResult.prototype.opcodes = function opcodes(){return this.updating;};RenderResult.prototype.handleException = function handleException(){throw "this should never happen";};RenderResult.prototype.destroy = function destroy(){this.bounds.destroy();clear(this.bounds);};return RenderResult;})();var CapturedFrame=function CapturedFrame(operand,args,condition){this.operand = operand;this.args = args;this.condition = condition;};var Frame=(function(){function Frame(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];this.ops = ops;this.component = component;this.manager = manager;this.shadow = shadow;this.operand = null;this.immediate = null;this.args = null;this.callerScope = null;this.blocks = null;this.condition = null;this.iterator = null;this.key = null;this.ip = ops[0];}Frame.prototype.capture = function capture(){return new CapturedFrame(this.operand,this.args,this.condition);};Frame.prototype.restore = function restore(frame){this.operand = frame['operand'];this.args = frame['args'];this.condition = frame['condition'];};return Frame;})();var FrameStack=(function(){function FrameStack(){this.frames = [];this.frame = null;}FrameStack.prototype.push = function push(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var frame=this.frame === null?this.frame = 0:++this.frame;if(this.frames.length <= frame){this.frames.push(null);}this.frames[frame] = new Frame(ops,component,manager,shadow);};FrameStack.prototype.pop = function pop(){var frames=this.frames;var frame=this.frame;frames[_glimmerUtil.expect(frame,'only pop after pushing')] = null;this.frame = frame === 0?null:frame - 1;};FrameStack.prototype.capture = function capture(){return this.currentFrame.capture();};FrameStack.prototype.restore = function restore(frame){this.currentFrame.restore(frame);};FrameStack.prototype.getOps = function getOps(){return this.currentFrame.ops;};FrameStack.prototype.getCurrent = function getCurrent(){return this.currentFrame.ip;};FrameStack.prototype.setCurrent = function setCurrent(ip){return this.currentFrame.ip = ip;};FrameStack.prototype.getOperand = function getOperand(){return _glimmerUtil.unwrap(this.currentFrame.operand);};FrameStack.prototype.setOperand = function setOperand(operand){return this.currentFrame.operand = operand;};FrameStack.prototype.getImmediate = function getImmediate(){return this.currentFrame.immediate;};FrameStack.prototype.setImmediate = function setImmediate(value){return this.currentFrame.immediate = value;}; // FIXME: These options are required in practice by the existing code, but +// figure out why. +FrameStack.prototype.getArgs = function getArgs(){return this.currentFrame.args;};FrameStack.prototype.setArgs = function setArgs(args){return this.currentFrame.args = args;};FrameStack.prototype.getCondition = function getCondition(){return _glimmerUtil.unwrap(this.currentFrame.condition);};FrameStack.prototype.setCondition = function setCondition(condition){return this.currentFrame.condition = condition;};FrameStack.prototype.getIterator = function getIterator(){return _glimmerUtil.unwrap(this.currentFrame.iterator);};FrameStack.prototype.setIterator = function setIterator(iterator){return this.currentFrame.iterator = iterator;};FrameStack.prototype.getKey = function getKey(){return this.currentFrame.key;};FrameStack.prototype.setKey = function setKey(key){return this.currentFrame.key = key;};FrameStack.prototype.getBlocks = function getBlocks(){return _glimmerUtil.unwrap(this.currentFrame.blocks);};FrameStack.prototype.setBlocks = function setBlocks(blocks){return this.currentFrame.blocks = blocks;};FrameStack.prototype.getCallerScope = function getCallerScope(){return _glimmerUtil.unwrap(this.currentFrame.callerScope);};FrameStack.prototype.setCallerScope = function setCallerScope(callerScope){return this.currentFrame.callerScope = callerScope;};FrameStack.prototype.getComponent = function getComponent(){return _glimmerUtil.unwrap(this.currentFrame.component);};FrameStack.prototype.getManager = function getManager(){return _glimmerUtil.unwrap(this.currentFrame.manager);};FrameStack.prototype.getShadow = function getShadow(){return this.currentFrame.shadow;};FrameStack.prototype.goto = function goto(ip){this.setCurrent(ip);};FrameStack.prototype.hasOpcodes = function hasOpcodes(){return this.frame !== null;};FrameStack.prototype.nextStatement = function nextStatement(env){var ip=this.frames[_glimmerUtil.unwrap(this.frame)].ip;var ops=this.getOps();if(ip <= ops[1]){var program=env.program;this.setCurrent(ip + 4);return program.opcode(ip);}else {this.pop();return null;}};babelHelpers.createClass(FrameStack,[{key:'currentFrame',get:function(){return this.frames[_glimmerUtil.unwrap(this.frame)];}}]);return FrameStack;})();var VM=(function(){function VM(env,scope,dynamicScope,elementStack){this.env = env;this.elementStack = elementStack;this.dynamicScopeStack = new _glimmerUtil.Stack();this.scopeStack = new _glimmerUtil.Stack();this.updatingOpcodeStack = new _glimmerUtil.Stack();this.cacheGroups = new _glimmerUtil.Stack();this.listBlockStack = new _glimmerUtil.Stack();this.frame = new FrameStack();this.env = env;this.constants = env.constants;this.elementStack = elementStack;this.scopeStack.push(scope);this.dynamicScopeStack.push(dynamicScope);}VM.initial = function initial(env,self,dynamicScope,elementStack,size){var scope=Scope.root(self,size);return new VM(env,scope,dynamicScope,elementStack);};VM.prototype.capture = function capture(){return {env:this.env,scope:this.scope(),dynamicScope:this.dynamicScope(),frame:this.frame.capture()};};VM.prototype.goto = function goto(ip){ // assert(this.frame.getOps().contains(op), `Illegal jump to ${op.label}`); +this.frame.goto(ip);};VM.prototype.beginCacheGroup = function beginCacheGroup(){this.cacheGroups.push(this.updating().tail());};VM.prototype.commitCacheGroup = function commitCacheGroup(){ // JumpIfNotModified(END) +// (head) +// (....) +// (tail) +// DidModify +// END: Noop +var END=new LabelOpcode("END");var opcodes=this.updating();var marker=this.cacheGroups.pop();var head=marker?opcodes.nextNode(marker):opcodes.head();var tail=opcodes.tail();var tag=_glimmerReference.combineSlice(new _glimmerUtil.ListSlice(head,tail));var guard=new JumpIfNotModifiedOpcode(tag,END);opcodes.insertBefore(guard,head);opcodes.append(new DidModifyOpcode(guard));opcodes.append(END);};VM.prototype.enter = function enter(sliceId){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var slice=this.constants.getSlice(sliceId);var tryOpcode=new TryOpcode(slice,state,tracker,updating);this.didEnter(tryOpcode,updating);};VM.prototype.enterWithKey = function enterWithKey(key,ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var tryOpcode=new TryOpcode(ops,state,tracker,updating);this.listBlock().map[key] = tryOpcode;this.didEnter(tryOpcode,updating);};VM.prototype.enterList = function enterList(ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushBlockList(updating);var state=this.capture();var artifacts=this.frame.getIterator().artifacts;var opcode=new ListBlockOpcode(ops,state,tracker,updating,artifacts);this.listBlockStack.push(opcode);this.didEnter(opcode,updating);};VM.prototype.didEnter = function didEnter(opcode,updating){this.updateWith(opcode);this.updatingOpcodeStack.push(updating);};VM.prototype.exit = function exit(){this.stack().popBlock();this.updatingOpcodeStack.pop();var parent=this.updating().tail();parent.didInitializeChildren();};VM.prototype.exitList = function exitList(){this.exit();this.listBlockStack.pop();};VM.prototype.updateWith = function updateWith(opcode){this.updating().append(opcode);};VM.prototype.listBlock = function listBlock(){return _glimmerUtil.expect(this.listBlockStack.current,'expected a list block');};VM.prototype.updating = function updating(){return _glimmerUtil.expect(this.updatingOpcodeStack.current,'expected updating opcode on the updating opcode stack');};VM.prototype.stack = function stack(){return this.elementStack;};VM.prototype.scope = function scope(){return _glimmerUtil.expect(this.scopeStack.current,'expected scope on the scope stack');};VM.prototype.dynamicScope = function dynamicScope(){return _glimmerUtil.expect(this.dynamicScopeStack.current,'expected dynamic scope on the dynamic scope stack');};VM.prototype.pushFrame = function pushFrame(block,args,callerScope){this.frame.push(block.slice);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushComponentFrame = function pushComponentFrame(layout,args,callerScope,component,manager,shadow){this.frame.push(layout.slice,component,manager,shadow);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushEvalFrame = function pushEvalFrame(slice){this.frame.push(slice);};VM.prototype.pushChildScope = function pushChildScope(){this.scopeStack.push(this.scope().child());};VM.prototype.pushCallerScope = function pushCallerScope(){this.scopeStack.push(_glimmerUtil.expect(this.scope().getCallerScope(),'pushCallerScope is called when a caller scope is present'));};VM.prototype.pushDynamicScope = function pushDynamicScope(){var child=this.dynamicScope().child();this.dynamicScopeStack.push(child);return child;};VM.prototype.pushRootScope = function pushRootScope(self,size){var scope=Scope.root(self,size);this.scopeStack.push(scope);return scope;};VM.prototype.popScope = function popScope(){this.scopeStack.pop();};VM.prototype.popDynamicScope = function popDynamicScope(){this.dynamicScopeStack.pop();};VM.prototype.newDestroyable = function newDestroyable(d){this.stack().newDestroyable(d);}; /// SCOPE HELPERS +VM.prototype.getSelf = function getSelf(){return this.scope().getSelf();};VM.prototype.referenceForSymbol = function referenceForSymbol(symbol){return this.scope().getSymbol(symbol);};VM.prototype.getArgs = function getArgs(){return this.frame.getArgs();}; /// EXECUTION +VM.prototype.resume = function resume(opcodes,frame){return this.execute(opcodes,function(vm){return vm.frame.restore(frame);});};VM.prototype.execute = function execute(opcodes,initialize){_glimmerUtil.LOGGER.debug("[VM] Begin program execution");var elementStack=this.elementStack;var frame=this.frame;var updatingOpcodeStack=this.updatingOpcodeStack;var env=this.env;elementStack.pushSimpleBlock();updatingOpcodeStack.push(new _glimmerUtil.LinkedList());frame.push(opcodes);if(initialize)initialize(this);var opcode=undefined;while(frame.hasOpcodes()) {if(opcode = frame.nextStatement(this.env)){_glimmerUtil.LOGGER.trace(opcode);APPEND_OPCODES.evaluate(this,opcode);}}_glimmerUtil.LOGGER.debug("[VM] Completed program execution");return new RenderResult(env,_glimmerUtil.expect(updatingOpcodeStack.pop(),'there should be a final updating opcode stack'),elementStack.popBlock());};VM.prototype.evaluateOpcode = function evaluateOpcode(opcode){APPEND_OPCODES.evaluate(this,opcode);}; // Make sure you have opcodes that push and pop a scope around this opcode +// if you need to change the scope. +VM.prototype.invokeBlock = function invokeBlock(block,args){var compiled=block.compile(this.env);this.pushFrame(compiled,args);};VM.prototype.invokePartial = function invokePartial(block){var compiled=block.compile(this.env);this.pushFrame(compiled);};VM.prototype.invokeLayout = function invokeLayout(args,layout,callerScope,component,manager,shadow){this.pushComponentFrame(layout,args,callerScope,component,manager,shadow);};VM.prototype.evaluateOperand = function evaluateOperand(expr){this.frame.setOperand(expr.evaluate(this));};VM.prototype.evaluateArgs = function evaluateArgs(args){var evaledArgs=this.frame.setArgs(args.evaluate(this));this.frame.setOperand(evaledArgs.positional.at(0));};VM.prototype.bindPositionalArgs = function bindPositionalArgs(symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPositionalArgs assumes a previous setArgs');var positional=args.positional;var scope=this.scope();for(var i=0;i < symbols.length;i++) {scope.bindSymbol(symbols[i],positional.at(i));}};VM.prototype.bindNamedArgs = function bindNamedArgs(names,symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindNamedArgs assumes a previous setArgs');var scope=this.scope();var named=args.named;for(var i=0;i < names.length;i++) {var _name2=this.constants.getString(names[i]);scope.bindSymbol(symbols[i],named.get(_name2));}};VM.prototype.bindBlocks = function bindBlocks(names,symbols){var blocks=this.frame.getBlocks();var scope=this.scope();for(var i=0;i < names.length;i++) {var _name3=this.constants.getString(names[i]);scope.bindBlock(symbols[i],blocks && blocks[_name3] || null);}};VM.prototype.bindPartialArgs = function bindPartialArgs(symbol){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPartialArgs assumes a previous setArgs');var scope=this.scope();_glimmerUtil.assert(args,"Cannot bind named args");scope.bindPartialArgs(symbol,args);};VM.prototype.bindCallerScope = function bindCallerScope(){var callerScope=this.frame.getCallerScope();var scope=this.scope();_glimmerUtil.assert(callerScope,"Cannot bind caller scope");scope.bindCallerScope(callerScope);};VM.prototype.bindDynamicScope = function bindDynamicScope(names){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindDynamicScope assumes a previous setArgs');var scope=this.dynamicScope();_glimmerUtil.assert(args,"Cannot bind dynamic scope");for(var i=0;i < names.length;i++) {var _name4=this.constants.getString(names[i]);scope.set(_name4,args.named.get(_name4));}};return VM;})();var UpdatingVM=(function(){function UpdatingVM(env,_ref29){var _ref29$alwaysRevalidate=_ref29.alwaysRevalidate;var alwaysRevalidate=_ref29$alwaysRevalidate === undefined?false:_ref29$alwaysRevalidate;this.frameStack = new _glimmerUtil.Stack();this.env = env;this.constants = env.constants;this.dom = env.getDOM();this.alwaysRevalidate = alwaysRevalidate;}UpdatingVM.prototype.execute = function execute(opcodes,handler){var frameStack=this.frameStack;this.try(opcodes,handler);while(true) {if(frameStack.isEmpty())break;var opcode=this.frame.nextStatement();if(opcode === null){this.frameStack.pop();continue;}_glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type);_glimmerUtil.LOGGER.trace(opcode);opcode.evaluate(this);}};UpdatingVM.prototype.goto = function goto(op){this.frame.goto(op);};UpdatingVM.prototype.try = function _try(ops,handler){this.frameStack.push(new UpdatingVMFrame(this,ops,handler));};UpdatingVM.prototype.throw = function _throw(){this.frame.handleException();this.frameStack.pop();};UpdatingVM.prototype.evaluateOpcode = function evaluateOpcode(opcode){opcode.evaluate(this);};babelHelpers.createClass(UpdatingVM,[{key:'frame',get:function(){return _glimmerUtil.expect(this.frameStack.current,'bug: expected a frame');}}]);return UpdatingVM;})();var BlockOpcode=(function(_UpdatingOpcode8){babelHelpers.inherits(BlockOpcode,_UpdatingOpcode8);function BlockOpcode(ops,state,bounds,children){_UpdatingOpcode8.call(this);this.ops = ops;this.type = "block";this.next = null;this.prev = null;var env=state.env;var scope=state.scope;var dynamicScope=state.dynamicScope;var frame=state.frame;this.children = children;this.env = env;this.scope = scope;this.dynamicScope = dynamicScope;this.frame = frame;this.bounds = bounds;}BlockOpcode.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};BlockOpcode.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};BlockOpcode.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};BlockOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,null);};BlockOpcode.prototype.destroy = function destroy(){this.bounds.destroy();};BlockOpcode.prototype.didDestroy = function didDestroy(){this.env.didDestroy(this.bounds);};BlockOpcode.prototype.toJSON = function toJSON(){var details=_glimmerUtil.dict();details["guid"] = '' + this._guid;return {guid:this._guid,type:this.type,details:details,children:this.children.toArray().map(function(op){return op.toJSON();})};};return BlockOpcode;})(UpdatingOpcode);var TryOpcode=(function(_BlockOpcode){babelHelpers.inherits(TryOpcode,_BlockOpcode);function TryOpcode(ops,state,bounds,children){_BlockOpcode.call(this,ops,state,bounds,children);this.type = "try";this.tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);}TryOpcode.prototype.didInitializeChildren = function didInitializeChildren(){this._tag.update(_glimmerReference.combineSlice(this.children));};TryOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,this);};TryOpcode.prototype.handleException = function handleException(){var env=this.env;var scope=this.scope;var ops=this.ops;var dynamicScope=this.dynamicScope;var frame=this.frame;var elementStack=ElementStack.resume(this.env,this.bounds,this.bounds.reset(env));var vm=new VM(env,scope,dynamicScope,elementStack);var result=vm.resume(ops,frame);this.children = result.opcodes();this.didInitializeChildren();};TryOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode.prototype.toJSON.call(this);var details=json["details"];if(!details){details = json["details"] = {};}return _BlockOpcode.prototype.toJSON.call(this);};return TryOpcode;})(BlockOpcode);var ListRevalidationDelegate=(function(){function ListRevalidationDelegate(opcode,marker){this.opcode = opcode;this.marker = marker;this.didInsert = false;this.didDelete = false;this.map = opcode.map;this.updating = opcode['children'];}ListRevalidationDelegate.prototype.insert = function insert(key,item,memo,before){var map=this.map;var opcode=this.opcode;var updating=this.updating;var nextSibling=null;var reference=null;if(before){reference = map[before];nextSibling = reference['bounds'].firstNode();}else {nextSibling = this.marker;}var vm=opcode.vmForInsertion(nextSibling);var tryOpcode=null;vm.execute(opcode.ops,function(vm){vm.frame.setArgs(EvaluatedArgs.positional([item,memo]));vm.frame.setOperand(item);vm.frame.setCondition(new _glimmerReference.ConstReference(true));vm.frame.setKey(key);var state=vm.capture();var tracker=vm.stack().pushUpdatableBlock();tryOpcode = new TryOpcode(opcode.ops,state,tracker,vm.updating());});tryOpcode.didInitializeChildren();updating.insertBefore(tryOpcode,reference);map[key] = tryOpcode;this.didInsert = true;};ListRevalidationDelegate.prototype.retain = function retain(_key,_item,_memo){};ListRevalidationDelegate.prototype.move = function move(key,_item,_memo,before){var map=this.map;var updating=this.updating;var entry=map[key];var reference=map[before] || null;if(before){moveBounds(entry,reference.firstNode());}else {moveBounds(entry,this.marker);}updating.remove(entry);updating.insertBefore(entry,reference);};ListRevalidationDelegate.prototype.delete = function _delete(key){var map=this.map;var opcode=map[key];opcode.didDestroy();clear(opcode);this.updating.remove(opcode);delete map[key];this.didDelete = true;};ListRevalidationDelegate.prototype.done = function done(){this.opcode.didInitializeChildren(this.didInsert || this.didDelete);};return ListRevalidationDelegate;})();var ListBlockOpcode=(function(_BlockOpcode2){babelHelpers.inherits(ListBlockOpcode,_BlockOpcode2);function ListBlockOpcode(ops,state,bounds,children,artifacts){_BlockOpcode2.call(this,ops,state,bounds,children);this.type = "list-block";this.map = _glimmerUtil.dict();this.lastIterated = _glimmerReference.INITIAL;this.artifacts = artifacts;var _tag=this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([artifacts.tag,_tag]);}ListBlockOpcode.prototype.didInitializeChildren = function didInitializeChildren(){var listDidChange=arguments.length <= 0 || arguments[0] === undefined?true:arguments[0];this.lastIterated = this.artifacts.tag.value();if(listDidChange){this._tag.update(_glimmerReference.combineSlice(this.children));}};ListBlockOpcode.prototype.evaluate = function evaluate(vm){var artifacts=this.artifacts;var lastIterated=this.lastIterated;if(!artifacts.tag.validate(lastIterated)){var bounds=this.bounds;var dom=vm.dom;var marker=dom.createComment('');dom.insertAfter(bounds.parentElement(),marker,_glimmerUtil.expect(bounds.lastNode(),"can't insert after an empty bounds"));var target=new ListRevalidationDelegate(this,marker);var synchronizer=new _glimmerReference.IteratorSynchronizer({target:target,artifacts:artifacts});synchronizer.sync();this.parentElement().removeChild(marker);} // Run now-updated updating opcodes +_BlockOpcode2.prototype.evaluate.call(this,vm);};ListBlockOpcode.prototype.vmForInsertion = function vmForInsertion(nextSibling){var env=this.env;var scope=this.scope;var dynamicScope=this.dynamicScope;var elementStack=ElementStack.forInitialRender(this.env,this.bounds.parentElement(),nextSibling);return new VM(env,scope,dynamicScope,elementStack);};ListBlockOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode2.prototype.toJSON.call(this);var map=this.map;var inner=Object.keys(map).map(function(key){return JSON.stringify(key) + ': ' + map[key]._guid;}).join(", ");var details=json["details"];if(!details){details = json["details"] = {};}details["map"] = '{' + inner + '}';return json;};return ListBlockOpcode;})(BlockOpcode);var UpdatingVMFrame=(function(){function UpdatingVMFrame(vm,ops,exceptionHandler){this.vm = vm;this.ops = ops;this.exceptionHandler = exceptionHandler;this.vm = vm;this.ops = ops;this.current = ops.head();}UpdatingVMFrame.prototype.goto = function goto(op){this.current = op;};UpdatingVMFrame.prototype.nextStatement = function nextStatement(){var current=this.current;var ops=this.ops;if(current)this.current = ops.nextNode(current);return current;};UpdatingVMFrame.prototype.handleException = function handleException(){if(this.exceptionHandler){this.exceptionHandler.handleException();}};return UpdatingVMFrame;})();var CompiledBlock=function CompiledBlock(slice){this.start = slice[0];this.end = slice[1];this.slice = slice;};var CompiledProgram=(function(_CompiledBlock){babelHelpers.inherits(CompiledProgram,_CompiledBlock);function CompiledProgram(slice,symbols){_CompiledBlock.call(this,slice);this.symbols = symbols;}return CompiledProgram;})(CompiledBlock);function entryPoint(meta){return new ProgramSymbolTable(meta);}function layout(meta,wireNamed,wireYields,hasPartials){var _symbols3=symbols(wireNamed,wireYields,hasPartials);var named=_symbols3.named;var yields=_symbols3.yields;var partialSymbol=_symbols3.partialSymbol;var size=_symbols3.size;return new ProgramSymbolTable(meta,named,yields,partialSymbol,size);}function block(parent,locals){var localsMap=null;var program=parent['program'];if(locals.length !== 0){(function(){var map=localsMap = _glimmerUtil.dict();locals.forEach(function(l){return map[l] = program.size++;});})();}return new BlockSymbolTable(parent,program,localsMap);}function symbols(named,yields,hasPartials){var yieldsMap=null;var namedMap=null;var size=1;if(yields.length !== 0){(function(){var map=yieldsMap = _glimmerUtil.dict();yields.forEach(function(y){return map[y] = size++;});})();}if(named.length !== 0){(function(){var map=namedMap = _glimmerUtil.dict();named.forEach(function(y){return map[y] = size++;});})();}var partialSymbol=hasPartials?size++:null;return {named:namedMap,yields:yieldsMap,partialSymbol:partialSymbol,size:size};}var ProgramSymbolTable=(function(){function ProgramSymbolTable(meta){var named=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var yields=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var partialArgs=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var size=arguments.length <= 4 || arguments[4] === undefined?1:arguments[4];this.meta = meta;this.named = named;this.yields = yields;this.partialArgs = partialArgs;this.size = size;this.program = this;}ProgramSymbolTable.prototype.getMeta = function getMeta(){return this.meta;};ProgramSymbolTable.prototype.getSymbols = function getSymbols(){return {named:this.named,yields:this.yields,locals:null,partialArgs:this.partialArgs};};ProgramSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local')return null;return this[kind] && this[kind][name];};ProgramSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.partialArgs || 0;};return ProgramSymbolTable;})();var BlockSymbolTable=(function(){function BlockSymbolTable(parent,program,locals){this.parent = parent;this.program = program;this.locals = locals;}BlockSymbolTable.prototype.getMeta = function getMeta(){return this.program.getMeta();};BlockSymbolTable.prototype.getSymbols = function getSymbols(){return {named:null,yields:null,locals:this.locals,partialArgs:null};};BlockSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local'){return this.getLocal(name);}else {return this.program.getSymbol(kind,name);}};BlockSymbolTable.prototype.getLocal = function getLocal(name){var locals=this.locals;var parent=this.parent;var symbol=locals && locals[name];if(!symbol && parent){symbol = parent.getSymbol('local',name);}return symbol;};BlockSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.program.getPartialArgs();};return BlockSymbolTable;})();var Specialize=(function(){function Specialize(){this.names = _glimmerUtil.dict();this.funcs = [];}Specialize.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Specialize.prototype.specialize = function specialize(sexp,table){var name=sexp[0];var index=this.names[name];if(index === undefined)return sexp;var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected a specialization for ' + sexp[0]);return func(sexp,table);};return Specialize;})();var SPECIALIZE=new Specialize();var E=_glimmerWireFormat.Expressions;SPECIALIZE.add('append',function(sexp,_symbolTable){var path=sexp[1];if(Array.isArray(path) && (E.isUnknown(path) || E.isGet(path))){if(path[1].length !== 1){return ['unoptimized-append',sexp[1],sexp[2]];}}return ['optimized-append',sexp[1],sexp[2]];});SPECIALIZE.add('dynamic-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],false];});SPECIALIZE.add('trusting-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],true];});SPECIALIZE.add('partial',function(sexp,_table){var expression=sexp[1];if(typeof expression === 'string'){return ['static-partial',expression];}else {return ['dynamic-partial',expression];}});function compileStatement(statement,builder){var refined=SPECIALIZE.specialize(statement,builder.symbolTable);STATEMENTS.compile(refined,builder);}var Template=function Template(statements,symbolTable){this.statements = statements;this.symbolTable = symbolTable;};var Layout=(function(_Template){babelHelpers.inherits(Layout,_Template);function Layout(){_Template.apply(this,arguments);}return Layout;})(Template);var EntryPoint=(function(_Template2){babelHelpers.inherits(EntryPoint,_Template2);function EntryPoint(){_Template2.apply(this,arguments);}EntryPoint.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),this.symbolTable.size);};return EntryPoint;})(Template);var InlineBlock=(function(_Template3){babelHelpers.inherits(InlineBlock,_Template3);function InlineBlock(){_Template3.apply(this,arguments);}InlineBlock.prototype.splat = function splat(builder){var table=builder.symbolTable;var locals=table.getSymbols().locals;if(locals){builder.pushChildScope();builder.bindPositionalArgsForLocals(locals);}for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,builder);}if(locals){builder.popScope();}};InlineBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);this.splat(b);return new CompiledBlock(b.toSlice());};return InlineBlock;})(Template);var PartialBlock=(function(_Template4){babelHelpers.inherits(PartialBlock,_Template4);function PartialBlock(){_Template4.apply(this,arguments);}PartialBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),table.size);};return PartialBlock;})(Template);var Scanner=(function(){function Scanner(block,meta,env){this.block = block;this.meta = meta;this.env = env;}Scanner.prototype.scanEntryPoint = function scanEntryPoint(){var block=this.block;var meta=this.meta;var symbolTable=entryPoint(meta);var child=scanBlock(block,symbolTable,this.env);return new EntryPoint(child.statements,symbolTable);};Scanner.prototype.scanLayout = function scanLayout(){var block=this.block;var meta=this.meta;var named=block.named;var yields=block.yields;var hasPartials=block.hasPartials;var symbolTable=layout(meta,named,yields,hasPartials);var child=scanBlock(block,symbolTable,this.env);return new Layout(child.statements,symbolTable);};Scanner.prototype.scanPartial = function scanPartial(symbolTable){var block=this.block;var child=scanBlock(block,symbolTable,this.env);return new PartialBlock(child.statements,symbolTable);};return Scanner;})();function scanBlock(_ref30,symbolTable,env){var statements=_ref30.statements;return new RawInlineBlock(env,symbolTable,statements).scan();}var BaselineSyntax;(function(BaselineSyntax){BaselineSyntax.isScannedComponent = _glimmerWireFormat.is('scanned-component');BaselineSyntax.isPrimitiveElement = _glimmerWireFormat.is('open-primitive-element');BaselineSyntax.isOptimizedAppend = _glimmerWireFormat.is('optimized-append');BaselineSyntax.isUnoptimizedAppend = _glimmerWireFormat.is('unoptimized-append');BaselineSyntax.isAnyAttr = _glimmerWireFormat.is('any-dynamic-attr');BaselineSyntax.isStaticPartial = _glimmerWireFormat.is('static-partial');BaselineSyntax.isDynamicPartial = _glimmerWireFormat.is('dynamic-partial');BaselineSyntax.isFunctionExpression = _glimmerWireFormat.is('function');BaselineSyntax.isNestedBlock = _glimmerWireFormat.is('nested-block');BaselineSyntax.isScannedBlock = _glimmerWireFormat.is('scanned-block');BaselineSyntax.isDebugger = _glimmerWireFormat.is('debugger');var NestedBlock;(function(NestedBlock){function defaultBlock(sexp){return sexp[4];}NestedBlock.defaultBlock = defaultBlock;function inverseBlock(sexp){return sexp[5];}NestedBlock.inverseBlock = inverseBlock;function params(sexp){return sexp[2];}NestedBlock.params = params;function hash(sexp){return sexp[3];}NestedBlock.hash = hash;})(NestedBlock = BaselineSyntax.NestedBlock || (BaselineSyntax.NestedBlock = {}));})(BaselineSyntax || (exports.BaselineSyntax = BaselineSyntax = {}));var RawInlineBlock=(function(){function RawInlineBlock(env,table,statements){this.env = env;this.table = table;this.statements = statements;}RawInlineBlock.prototype.scan = function scan(){var buffer=[];for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];if(_glimmerWireFormat.Statements.isBlock(statement)){buffer.push(this.specializeBlock(statement));}else if(_glimmerWireFormat.Statements.isComponent(statement)){buffer.push.apply(buffer,this.specializeComponent(statement));}else {buffer.push(statement);}}return new InlineBlock(buffer,this.table);};RawInlineBlock.prototype.specializeBlock = function specializeBlock(block$$){var path=block$$[1];var params=block$$[2];var hash=block$$[3];var template=block$$[4];var inverse=block$$[5];return ['scanned-block',path,params,hash,this.child(template),this.child(inverse)];};RawInlineBlock.prototype.specializeComponent = function specializeComponent(sexp){var tag=sexp[1];var component=sexp[2];if(this.env.hasComponentDefinition([tag],this.table)){var child=this.child(component);var attrs=new RawInlineBlock(this.env,this.table,component.attrs);return [['scanned-component',tag,attrs,component.args,child]];}else {var buf=[];buf.push(['open-element',tag,[]]);buf.push.apply(buf,component.attrs);buf.push(['flush-element']);buf.push.apply(buf,component.statements);buf.push(['close-element']);return buf;}};RawInlineBlock.prototype.child = function child(block$$){if(!block$$)return null;var table=block(this.table,block$$.locals);return new RawInlineBlock(this.env,table,block$$.statements);};return RawInlineBlock;})();function compileLayout(compilable,env){var builder=new ComponentLayoutBuilder(env);compilable.compile(builder);return builder.compile();}var ComponentLayoutBuilder=(function(){function ComponentLayoutBuilder(env){this.env = env;}ComponentLayoutBuilder.prototype.wrapLayout = function wrapLayout(layout){this.inner = new WrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.fromLayout = function fromLayout(layout){this.inner = new UnwrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.compile = function compile(){return this.inner.compile();};babelHelpers.createClass(ComponentLayoutBuilder,[{key:'tag',get:function(){return this.inner.tag;}},{key:'attrs',get:function(){return this.inner.attrs;}}]);return ComponentLayoutBuilder;})();var WrappedBuilder=(function(){function WrappedBuilder(env,layout){this.env = env;this.layout = layout;this.tag = new ComponentTagBuilder();this.attrs = new ComponentAttrsBuilder();}WrappedBuilder.prototype.compile = function compile(){ //========DYNAMIC +// PutValue(TagExpr) +// Test +// JumpUnless(BODY) +// OpenDynamicPrimitiveElement +// DidCreateElement +// ...attr statements... +// FlushElement +// BODY: Noop +// ...body statements... +// PutValue(TagExpr) +// Test +// JumpUnless(END) +// CloseElement +// END: Noop +// DidRenderLayout +// Exit +// +//========STATIC +// OpenPrimitiveElementOpcode +// DidCreateElement +// ...attr statements... +// FlushElement +// ...body statements... +// CloseElement +// DidRenderLayout +// Exit +var env=this.env;var layout=this.layout;var symbolTable=layout.symbolTable;var b=builder(env,layout.symbolTable);b.startLabels();var dynamicTag=this.tag.getDynamic();var staticTag=undefined;if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('BODY');b.openDynamicPrimitiveElement();b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();b.label('BODY');}else if(staticTag = this.tag.getStatic()){b.openPrimitiveElement(staticTag);b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();}b.preludeForLayout(layout);layout.statements.forEach(function(statement){return compileStatement(statement,b);});if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('END');b.closeElement();b.label('END');}else if(staticTag){b.closeElement();}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),symbolTable.size);};return WrappedBuilder;})();function isOpenElement(value){var type=value[0];return type === 'open-element' || type === 'open-primitive-element';}var UnwrappedBuilder=(function(){function UnwrappedBuilder(env,layout){this.env = env;this.layout = layout;this.attrs = new ComponentAttrsBuilder();}UnwrappedBuilder.prototype.compile = function compile(){var env=this.env;var layout=this.layout;var b=builder(env,layout.symbolTable);b.startLabels();b.preludeForLayout(layout);var attrs=this.attrs['buffer'];var attrsInserted=false;for(var i=0;i < layout.statements.length;i++) {var statement=layout.statements[i];if(!attrsInserted && isOpenElement(statement)){b.openComponentElement(statement[1]);b.didCreateElement();b.shadowAttributes();attrs.forEach(function(statement){return compileStatement(statement,b);});attrsInserted = true;}else {compileStatement(statement,b);}}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),layout.symbolTable.size);};babelHelpers.createClass(UnwrappedBuilder,[{key:'tag',get:function(){throw new Error('BUG: Cannot call `tag` on an UnwrappedBuilder');}}]);return UnwrappedBuilder;})();var ComponentTagBuilder=(function(){function ComponentTagBuilder(){this.isDynamic = null;this.isStatic = null;this.staticTagName = null;this.dynamicTagName = null;}ComponentTagBuilder.prototype.getDynamic = function getDynamic(){if(this.isDynamic){return this.dynamicTagName;}};ComponentTagBuilder.prototype.getStatic = function getStatic(){if(this.isStatic){return this.staticTagName;}};ComponentTagBuilder.prototype.static = function _static(tagName){this.isStatic = true;this.staticTagName = tagName;};ComponentTagBuilder.prototype.dynamic = function dynamic(tagName){this.isDynamic = true;this.dynamicTagName = ['function',tagName];};return ComponentTagBuilder;})();var ComponentAttrsBuilder=(function(){function ComponentAttrsBuilder(){this.buffer = [];}ComponentAttrsBuilder.prototype.static = function _static(name,value){this.buffer.push(['static-attr',name,value,null]);};ComponentAttrsBuilder.prototype.dynamic = function dynamic(name,value){this.buffer.push(['dynamic-attr',name,['function',value],null]);};return ComponentAttrsBuilder;})();var ComponentBuilder=(function(){function ComponentBuilder(builder){this.builder = builder;this.env = builder.env;}ComponentBuilder.prototype.static = function _static(definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putComponentDefinition(definition);b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();});};ComponentBuilder.prototype.dynamic = function dynamic(definitionArgs,definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putArgs(compileArgs(definitionArgs[0],definitionArgs[1],b));b.putValue(['function',definition]);b.test('simple');b.enter('BEGIN','END');b.label('BEGIN');b.jumpUnless('END');b.putDynamicComponentDefinition();b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();b.label('END');b.exit();});};return ComponentBuilder;})();function builder(env,symbolTable){return new OpcodeBuilder(symbolTable,env);}function appendOpcode(name,op1,op2,op3){return APPEND_OPCODES.construct(name,null,op1,op2,op3);}var Labels=(function(){function Labels(){this.labels = _glimmerUtil.dict();this.jumps = [];this.ranges = [];}Labels.prototype.label = function label(name,index){this.labels[name] = index;};Labels.prototype.jump = function jump(at,Target,target){this.jumps.push({at:at,target:target,Target:Target});};Labels.prototype.range = function range(at,Range,start,end){this.ranges.push({at:at,start:start,end:end,Range:Range});};Labels.prototype.patch = function patch(constants,opcodes){for(var i=0;i < this.jumps.length;i++) {var _jumps$i=this.jumps[i];var at=_jumps$i.at;var target=_jumps$i.target;var Target=_jumps$i.Target;opcodes.set(at,APPEND_OPCODES.construct(Target,null,this.labels[target]));}for(var i=0;i < this.ranges.length;i++) {var _ranges$i=this.ranges[i];var at=_ranges$i.at;var start=_ranges$i.start;var end=_ranges$i.end;var _Range=_ranges$i.Range;var slice=constants.slice([this.labels[start],this.labels[end] - 1]);opcodes.set(at,APPEND_OPCODES.construct(_Range,null,slice));}};return Labels;})();var BasicOpcodeBuilder=(function(){function BasicOpcodeBuilder(symbolTable,env,program){this.symbolTable = symbolTable;this.env = env;this.program = program;this.labelsStack = new _glimmerUtil.Stack();this.constants = env.constants;this.start = program.next;}BasicOpcodeBuilder.prototype.opcode = function opcode(name,op1,op2,op3){this.push(appendOpcode(name,op1,op2,op3));};BasicOpcodeBuilder.prototype.push = function push(op){ // console.log(`pushing ${op && op.type}`); +if(op === null){this.program.push([0,0,0,0]);}else {this.program.push(op);}};BasicOpcodeBuilder.prototype.toSlice = function toSlice(){return [this.start,this.program.current];}; // helpers +BasicOpcodeBuilder.prototype.startLabels = function startLabels(){this.labelsStack.push(new Labels());};BasicOpcodeBuilder.prototype.stopLabels = function stopLabels(){var label=_glimmerUtil.expect(this.labelsStack.pop(),'unbalanced push and pop labels');label.patch(this.constants,this.program);}; // partials +BasicOpcodeBuilder.prototype.putPartialDefinition = function putPartialDefinition(_definition){var definition=this.constants.other(_definition);this.opcode(50, /* PutPartial */definition);};BasicOpcodeBuilder.prototype.putDynamicPartialDefinition = function putDynamicPartialDefinition(){this.opcode(49, /* PutDynamicPartial */this.constants.other(this.symbolTable));};BasicOpcodeBuilder.prototype.evaluatePartial = function evaluatePartial(){this.opcode(51, /* EvaluatePartial */this.constants.other(this.symbolTable),this.constants.other(_glimmerUtil.dict()));}; // components +BasicOpcodeBuilder.prototype.putComponentDefinition = function putComponentDefinition(definition){this.opcode(23, /* PutComponent */this.other(definition));};BasicOpcodeBuilder.prototype.putDynamicComponentDefinition = function putDynamicComponentDefinition(){this.opcode(22 /* PutDynamicComponent */);};BasicOpcodeBuilder.prototype.openComponent = function openComponent(args,shadow){this.opcode(24, /* OpenComponent */this.args(args),shadow?this.block(shadow):0);};BasicOpcodeBuilder.prototype.didCreateElement = function didCreateElement(){this.opcode(25 /* DidCreateElement */);};BasicOpcodeBuilder.prototype.shadowAttributes = function shadowAttributes(){this.opcode(26 /* ShadowAttributes */);this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.didRenderLayout = function didRenderLayout(){this.opcode(27 /* DidRenderLayout */);};BasicOpcodeBuilder.prototype.closeComponent = function closeComponent(){this.opcode(28 /* CloseComponent */);}; // content +BasicOpcodeBuilder.prototype.dynamicContent = function dynamicContent(Opcode){this.opcode(31, /* DynamicContent */this.other(Opcode));};BasicOpcodeBuilder.prototype.cautiousAppend = function cautiousAppend(){this.dynamicContent(new OptimizedCautiousAppendOpcode());};BasicOpcodeBuilder.prototype.trustingAppend = function trustingAppend(){this.dynamicContent(new OptimizedTrustingAppendOpcode());};BasicOpcodeBuilder.prototype.guardedCautiousAppend = function guardedCautiousAppend(expression){this.dynamicContent(new GuardedCautiousAppendOpcode(this.compileExpression(expression),this.symbolTable));};BasicOpcodeBuilder.prototype.guardedTrustingAppend = function guardedTrustingAppend(expression){this.dynamicContent(new GuardedTrustingAppendOpcode(this.compileExpression(expression),this.symbolTable));}; // dom +BasicOpcodeBuilder.prototype.text = function text(_text){this.opcode(29, /* Text */this.constants.string(_text));};BasicOpcodeBuilder.prototype.openPrimitiveElement = function openPrimitiveElement(tag){this.opcode(32, /* OpenElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openComponentElement = function openComponentElement(tag){this.opcode(35, /* OpenComponentElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openDynamicPrimitiveElement = function openDynamicPrimitiveElement(){this.opcode(36 /* OpenDynamicElement */);};BasicOpcodeBuilder.prototype.flushElement = function flushElement(){this.opcode(37 /* FlushElement */);};BasicOpcodeBuilder.prototype.closeElement = function closeElement(){this.opcode(38 /* CloseElement */);};BasicOpcodeBuilder.prototype.staticAttr = function staticAttr(_name,_namespace,_value){var name=this.constants.string(_name);var namespace=_namespace?this.constants.string(_namespace):0;var value=this.constants.string(_value);this.opcode(40, /* StaticAttr */name,value,namespace);};BasicOpcodeBuilder.prototype.dynamicAttrNS = function dynamicAttrNS(_name,_namespace,trusting){var name=this.constants.string(_name);var namespace=this.constants.string(_namespace);this.opcode(42, /* DynamicAttrNS */name,namespace,trusting | 0);};BasicOpcodeBuilder.prototype.dynamicAttr = function dynamicAttr(_name,trusting){var name=this.constants.string(_name);this.opcode(43, /* DynamicAttr */name,trusting | 0);};BasicOpcodeBuilder.prototype.comment = function comment(_comment){var comment=this.constants.string(_comment);this.opcode(30, /* Comment */comment);};BasicOpcodeBuilder.prototype.modifier = function modifier(_name,_args){var args=this.constants.expression(this.compile(_args));var _modifierManager=this.env.lookupModifier([_name],this.symbolTable);var modifierManager=this.constants.other(_modifierManager);var name=this.constants.string(_name);this.opcode(41, /* Modifier */name,modifierManager,args);}; // lists +BasicOpcodeBuilder.prototype.putIterator = function putIterator(){this.opcode(44 /* PutIterator */);};BasicOpcodeBuilder.prototype.enterList = function enterList(start,end){this.push(null);this.labels.range(this.pos,45, /* EnterList */start,end);};BasicOpcodeBuilder.prototype.exitList = function exitList(){this.opcode(46 /* ExitList */);};BasicOpcodeBuilder.prototype.enterWithKey = function enterWithKey(start,end){this.push(null);this.labels.range(this.pos,47, /* EnterWithKey */start,end);};BasicOpcodeBuilder.prototype.nextIter = function nextIter(end){this.push(null);this.labels.jump(this.pos,48, /* NextIter */end);}; // vm +BasicOpcodeBuilder.prototype.openBlock = function openBlock(_args,_inner){var args=this.constants.expression(this.compile(_args));var inner=this.constants.other(_inner);this.opcode(20, /* OpenBlock */inner,args);};BasicOpcodeBuilder.prototype.closeBlock = function closeBlock(){this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.pushRemoteElement = function pushRemoteElement(){this.opcode(33 /* PushRemoteElement */);};BasicOpcodeBuilder.prototype.popRemoteElement = function popRemoteElement(){this.opcode(34 /* PopRemoteElement */);};BasicOpcodeBuilder.prototype.popElement = function popElement(){this.opcode(39 /* PopElement */);};BasicOpcodeBuilder.prototype.label = function label(name){this.labels.label(name,this.nextPos);};BasicOpcodeBuilder.prototype.pushChildScope = function pushChildScope(){this.opcode(0 /* PushChildScope */);};BasicOpcodeBuilder.prototype.popScope = function popScope(){this.opcode(1 /* PopScope */);};BasicOpcodeBuilder.prototype.pushDynamicScope = function pushDynamicScope(){this.opcode(2 /* PushDynamicScope */);};BasicOpcodeBuilder.prototype.popDynamicScope = function popDynamicScope(){this.opcode(3 /* PopDynamicScope */);};BasicOpcodeBuilder.prototype.putNull = function putNull(){this.opcode(4, /* Put */this.constants.NULL_REFERENCE);};BasicOpcodeBuilder.prototype.putValue = function putValue(_expression){var expr=this.constants.expression(this.compileExpression(_expression));this.opcode(5, /* EvaluatePut */expr);};BasicOpcodeBuilder.prototype.putArgs = function putArgs(_args){var args=this.constants.expression(this.compile(_args));this.opcode(6, /* PutArgs */args);};BasicOpcodeBuilder.prototype.bindDynamicScope = function bindDynamicScope(_names){this.opcode(12, /* BindDynamicScope */this.names(_names));};BasicOpcodeBuilder.prototype.bindPositionalArgs = function bindPositionalArgs(_names,_symbols){this.opcode(7, /* BindPositionalArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindNamedArgs = function bindNamedArgs(_names,_symbols){this.opcode(8, /* BindNamedArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindBlocks = function bindBlocks(_names,_symbols){this.opcode(9, /* BindBlocks */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.enter = function enter(_enter,exit){this.push(null);this.labels.range(this.pos,13, /* Enter */_enter,exit);};BasicOpcodeBuilder.prototype.exit = function exit(){this.opcode(14 /* Exit */);};BasicOpcodeBuilder.prototype.evaluate = function evaluate(_block){var block=this.constants.block(_block);this.opcode(15, /* Evaluate */block);};BasicOpcodeBuilder.prototype.test = function test(testFunc){var _func=undefined;if(testFunc === 'const'){_func = ConstTest;}else if(testFunc === 'simple'){_func = SimpleTest;}else if(testFunc === 'environment'){_func = EnvironmentTest;}else if(typeof testFunc === 'function'){_func = testFunc;}else {throw new Error('unreachable');}var func=this.constants.function(_func);this.opcode(19, /* Test */func);};BasicOpcodeBuilder.prototype.jump = function jump(target){this.push(null);this.labels.jump(this.pos,16, /* Jump */target);};BasicOpcodeBuilder.prototype.jumpIf = function jumpIf(target){this.push(null);this.labels.jump(this.pos,17, /* JumpIf */target);};BasicOpcodeBuilder.prototype.jumpUnless = function jumpUnless(target){this.push(null);this.labels.jump(this.pos,18, /* JumpUnless */target);};BasicOpcodeBuilder.prototype.names = function names(_names){var _this=this;var names=_names.map(function(n){return _this.constants.string(n);});return this.constants.array(names);};BasicOpcodeBuilder.prototype.symbols = function symbols(_symbols2){return this.constants.array(_symbols2);};BasicOpcodeBuilder.prototype.other = function other(value){return this.constants.other(value);};BasicOpcodeBuilder.prototype.args = function args(_args2){return this.constants.expression(this.compile(_args2));};BasicOpcodeBuilder.prototype.block = function block(_block3){return this.constants.block(_block3);};babelHelpers.createClass(BasicOpcodeBuilder,[{key:'pos',get:function(){return this.program.current;}},{key:'nextPos',get:function(){return this.program.next;}},{key:'labels',get:function(){return _glimmerUtil.expect(this.labelsStack.current,'bug: not in a label stack');}}]);return BasicOpcodeBuilder;})();function isCompilableExpression(expr){return expr && typeof expr['compile'] === 'function';}var OpcodeBuilder=(function(_BasicOpcodeBuilder){babelHelpers.inherits(OpcodeBuilder,_BasicOpcodeBuilder);function OpcodeBuilder(symbolTable,env){var program=arguments.length <= 2 || arguments[2] === undefined?env.program:arguments[2];return (function(){_BasicOpcodeBuilder.call(this,symbolTable,env,program);this.component = new ComponentBuilder(this);}).apply(this,arguments);}OpcodeBuilder.prototype.compile = function compile(expr){if(isCompilableExpression(expr)){return expr.compile(this);}else {return expr;}};OpcodeBuilder.prototype.compileExpression = function compileExpression(expression){if(expression instanceof CompiledExpression){return expression;}else {return expr(expression,this);}};OpcodeBuilder.prototype.bindPositionalArgsForLocals = function bindPositionalArgsForLocals(locals){var symbols=Object.keys(locals).map(function(name){return locals[name];});this.opcode(7, /* BindPositionalArgs */this.symbols(symbols));};OpcodeBuilder.prototype.preludeForLayout = function preludeForLayout(layout){var _this2=this;var symbols=layout.symbolTable.getSymbols();if(symbols.named){(function(){var named=symbols.named;var namedNames=Object.keys(named);var namedSymbols=namedNames.map(function(n){return named[n];});_this2.opcode(8, /* BindNamedArgs */_this2.names(namedNames),_this2.symbols(namedSymbols));})();}this.opcode(11 /* BindCallerScope */);if(symbols.yields){(function(){var yields=symbols.yields;var yieldNames=Object.keys(yields);var yieldSymbols=yieldNames.map(function(n){return yields[n];});_this2.opcode(9, /* BindBlocks */_this2.names(yieldNames),_this2.symbols(yieldSymbols));})();}if(symbols.partialArgs){this.opcode(10, /* BindPartialArgs */symbols.partialArgs);}};OpcodeBuilder.prototype.yield = function _yield(args,to){var yields=undefined,partial=undefined;var inner=undefined;if(yields = this.symbolTable.getSymbol('yields',to)){inner = new CompiledGetBlockBySymbol(yields,to);}else if(partial = this.symbolTable.getPartialArgs()){inner = new CompiledInPartialGetBlock(partial,to);}else {throw new Error('[BUG] ${to} is not a valid block name.');}this.openBlock(args,inner);this.closeBlock();}; // TODO +// come back to this +OpcodeBuilder.prototype.labelled = function labelled(args,callback){if(args)this.putArgs(args);this.startLabels();this.enter('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.iter = function iter(callback){this.startLabels();this.enterList('BEGIN','END');this.label('ITER');this.nextIter('BREAK');this.enterWithKey('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.jump('ITER');this.label('BREAK');this.exitList();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.unit = function unit(callback){this.startLabels();callback(this);this.stopLabels();};return OpcodeBuilder;})(BasicOpcodeBuilder);APPEND_OPCODES.add(31, /* DynamicContent */function(vm,_ref31){var append=_ref31.op1;var opcode=vm.constants.getOther(append);opcode.evaluate(vm);});function isEmpty(value){return value === null || value === undefined || typeof value['toString'] !== 'function';}function normalizeTextValue(value){if(isEmpty(value)){return '';}return String(value);}function normalizeTrustedValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value)){return value.toHTML();}if(isNode(value)){return value;}return String(value);}function normalizeValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value) || isNode(value)){return value;}return String(value);}var AppendDynamicOpcode=(function(){function AppendDynamicOpcode(){}AppendDynamicOpcode.prototype.evaluate = function evaluate(vm){var reference=vm.frame.getOperand();var normalized=this.normalize(reference);var value=undefined,cache=undefined;if(_glimmerReference.isConst(reference)){value = normalized.value();}else {cache = new _glimmerReference.ReferenceCache(normalized);value = cache.peek();}var stack=vm.stack();var upsert=this.insert(vm.env.getAppendOperations(),stack,value);var bounds=new Fragment(upsert.bounds);stack.newBounds(bounds);if(cache /* i.e. !isConst(reference) */){vm.updateWith(this.updateWith(vm,reference,cache,bounds,upsert));}};return AppendDynamicOpcode;})();var GuardedAppendOpcode=(function(_AppendDynamicOpcode){babelHelpers.inherits(GuardedAppendOpcode,_AppendDynamicOpcode);function GuardedAppendOpcode(expression,symbolTable){_AppendDynamicOpcode.call(this);this.expression = expression;this.symbolTable = symbolTable;this.deopted = null;}GuardedAppendOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.pushEvalFrame(this.deopted);}else {vm.evaluateOperand(this.expression);var value=vm.frame.getOperand().value();if(isComponentDefinition(value)){vm.pushEvalFrame(this.deopt(vm.env));}else {_AppendDynamicOpcode.prototype.evaluate.call(this,vm);}}};GuardedAppendOpcode.prototype.deopt = function deopt(env){var _this3=this; // At compile time, we determined that this append callsite might refer +// to a local variable/property lookup that resolves to a component +// definition at runtime. +// +// We could have eagerly compiled this callsite into something like this: +// +// {{#if (is-component-definition foo)}} +// {{component foo}} +// {{else}} +// {{foo}} +// {{/if}} +// +// However, in practice, there might be a large amout of these callsites +// and most of them would resolve to a simple value lookup. Therefore, we +// tried to be optimistic and assumed that the callsite will resolve to +// appending a simple value. +// +// However, we have reached here because at runtime, the guard conditional +// have detected that this callsite is indeed referring to a component +// definition object. Since this is likely going to be true for other +// instances of the same callsite, it is now appropiate to deopt into the +// expanded version that handles both cases. The compilation would look +// like this: +// +// PutValue(expression) +// Test(is-component-definition) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(VALUE) +// PutDynamicComponentDefinitionOpcode +// OpenComponent +// CloseComponent +// Jump(END) +// VALUE: Noop +// OptimizedAppend +// END: Noop +// Exit +// +// Keep in mind that even if we *don't* reach here at initial render time, +// it is still possible (although quite rare) that the simple value we +// encounter during initial render could later change into a component +// definition object at update time. That is handled by the "lazy deopt" +// code on the update side (scroll down for the next big block of comment). +var dsl=new OpcodeBuilder(this.symbolTable,env);dsl.putValue(this.expression);dsl.test(IsComponentDefinitionReference.create);dsl.labelled(null,function(dsl,_BEGIN,END){dsl.jumpUnless('VALUE');dsl.putDynamicComponentDefinition();dsl.openComponent(CompiledArgs.empty());dsl.closeComponent();dsl.jump(END);dsl.label('VALUE');dsl.dynamicContent(new _this3.AppendOpcode());});var deopted=this.deopted = dsl.toSlice(); // From this point on, we have essentially replaced ourselves with a new set +// of opcodes. Since we will always be executing the new/deopted code, it's +// a good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this.expression = null;return deopted;};return GuardedAppendOpcode;})(AppendDynamicOpcode);var IsComponentDefinitionReference=(function(_ConditionalReference){babelHelpers.inherits(IsComponentDefinitionReference,_ConditionalReference);function IsComponentDefinitionReference(){_ConditionalReference.apply(this,arguments);}IsComponentDefinitionReference.create = function create(inner){return new IsComponentDefinitionReference(inner);};IsComponentDefinitionReference.prototype.toBool = function toBool(value){return isComponentDefinition(value);};return IsComponentDefinitionReference;})(ConditionalReference);var UpdateOpcode=(function(_UpdatingOpcode9){babelHelpers.inherits(UpdateOpcode,_UpdatingOpcode9);function UpdateOpcode(cache,bounds,upsert){_UpdatingOpcode9.call(this);this.cache = cache;this.bounds = bounds;this.upsert = upsert;this.tag = cache.tag;}UpdateOpcode.prototype.evaluate = function evaluate(vm){var value=this.cache.revalidate();if(_glimmerReference.isModified(value)){var bounds=this.bounds;var upsert=this.upsert;var dom=vm.dom;if(!this.upsert.update(dom,value)){var cursor=new Cursor(bounds.parentElement(),clear(bounds));upsert = this.upsert = this.insert(vm.env.getAppendOperations(),cursor,value);}bounds.update(upsert.bounds);}};UpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var cache=this.cache;return {guid:guid,type:type,details:{lastValue:JSON.stringify(cache.peek())}};};return UpdateOpcode;})(UpdatingOpcode);var GuardedUpdateOpcode=(function(_UpdateOpcode){babelHelpers.inherits(GuardedUpdateOpcode,_UpdateOpcode);function GuardedUpdateOpcode(reference,cache,bounds,upsert,appendOpcode,state){_UpdateOpcode.call(this,cache,bounds,upsert);this.reference = reference;this.appendOpcode = appendOpcode;this.state = state;this.deopted = null;this.tag = this._tag = new _glimmerReference.UpdatableTag(this.tag);}GuardedUpdateOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.evaluateOpcode(this.deopted);}else {if(isComponentDefinition(this.reference.value())){this.lazyDeopt(vm);}else {_UpdateOpcode.prototype.evaluate.call(this,vm);}}};GuardedUpdateOpcode.prototype.lazyDeopt = function lazyDeopt(vm){ // Durign initial render, we know that the reference does not contain a +// component definition, so we optimistically assumed that this append +// is just a normal append. However, at update time, we discovered that +// the reference has switched into containing a component definition, so +// we need to do a "lazy deopt", simulating what would have happened if +// we had decided to perform the deopt in the first place during initial +// render. +// +// More concretely, we would have expanded the curly into a if/else, and +// based on whether the value is a component definition or not, we would +// have entered either the dynamic component branch or the simple value +// branch. +// +// Since we rendered a simple value during initial render (and all the +// updates up until this point), we need to pretend that the result is +// produced by the "VALUE" branch of the deopted append opcode: +// +// Try(BEGIN, END) +// Assert(IsComponentDefinition, expected=false) +// OptimizedUpdate +// +// In this case, because the reference has switched from being a simple +// value into a component definition, what would have happened is that +// the assert would throw, causing the Try opcode to teardown the bounds +// and rerun the original append opcode. +// +// Since the Try opcode would have nuked the updating opcodes anyway, we +// wouldn't have to worry about simulating those. All we have to do is to +// execute the Try opcode and immediately throw. +var bounds=this.bounds;var appendOpcode=this.appendOpcode;var state=this.state;var env=vm.env;var slice=appendOpcode.deopt(env);var enter=_glimmerUtil.expect(env.program.opcode(slice[0] + 8),'hardcoded deopt location');var ops=vm.constants.getSlice(enter.op1);var tracker=new UpdatableBlockTracker(bounds.parentElement());tracker.newBounds(this.bounds);var children=new _glimmerUtil.LinkedList();state.frame['condition'] = IsComponentDefinitionReference.create(_glimmerUtil.expect(state.frame['operand'],'operand should be populated'));var deopted=this.deopted = new TryOpcode(ops,state,tracker,children);this._tag.update(deopted.tag);vm.evaluateOpcode(deopted);vm.throw(); // From this point on, we have essentially replaced ourselve with a new +// opcode. Since we will always be executing the new/deopted code, it's a +// good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this._tag = null;this.reference = null;this.cache = null;this.bounds = null;this.upsert = null;this.appendOpcode = null;this.state = null;};GuardedUpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var deopted=this.deopted;if(deopted){return {guid:guid,type:type,deopted:true,children:[deopted.toJSON()]};}else {return _UpdateOpcode.prototype.toJSON.call(this);}};return GuardedUpdateOpcode;})(UpdateOpcode);var OptimizedCautiousAppendOpcode=(function(_AppendDynamicOpcode2){babelHelpers.inherits(OptimizedCautiousAppendOpcode,_AppendDynamicOpcode2);function OptimizedCautiousAppendOpcode(){_AppendDynamicOpcode2.apply(this,arguments);this.type = 'optimized-cautious-append';}OptimizedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};OptimizedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};OptimizedCautiousAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedCautiousUpdateOpcode(cache,bounds,upsert);};return OptimizedCautiousAppendOpcode;})(AppendDynamicOpcode);var OptimizedCautiousUpdateOpcode=(function(_UpdateOpcode2){babelHelpers.inherits(OptimizedCautiousUpdateOpcode,_UpdateOpcode2);function OptimizedCautiousUpdateOpcode(){_UpdateOpcode2.apply(this,arguments);this.type = 'optimized-cautious-update';}OptimizedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return OptimizedCautiousUpdateOpcode;})(UpdateOpcode);var GuardedCautiousAppendOpcode=(function(_GuardedAppendOpcode){babelHelpers.inherits(GuardedCautiousAppendOpcode,_GuardedAppendOpcode);function GuardedCautiousAppendOpcode(){_GuardedAppendOpcode.apply(this,arguments);this.type = 'guarded-cautious-append';this.AppendOpcode = OptimizedCautiousAppendOpcode;}GuardedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};GuardedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};GuardedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedCautiousUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedCautiousAppendOpcode;})(GuardedAppendOpcode);var GuardedCautiousUpdateOpcode=(function(_GuardedUpdateOpcode){babelHelpers.inherits(GuardedCautiousUpdateOpcode,_GuardedUpdateOpcode);function GuardedCautiousUpdateOpcode(){_GuardedUpdateOpcode.apply(this,arguments);this.type = 'guarded-cautious-update';}GuardedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return GuardedCautiousUpdateOpcode;})(GuardedUpdateOpcode);var OptimizedTrustingAppendOpcode=(function(_AppendDynamicOpcode3){babelHelpers.inherits(OptimizedTrustingAppendOpcode,_AppendDynamicOpcode3);function OptimizedTrustingAppendOpcode(){_AppendDynamicOpcode3.apply(this,arguments);this.type = 'optimized-trusting-append';}OptimizedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};OptimizedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};OptimizedTrustingAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedTrustingUpdateOpcode(cache,bounds,upsert);};return OptimizedTrustingAppendOpcode;})(AppendDynamicOpcode);var OptimizedTrustingUpdateOpcode=(function(_UpdateOpcode3){babelHelpers.inherits(OptimizedTrustingUpdateOpcode,_UpdateOpcode3);function OptimizedTrustingUpdateOpcode(){_UpdateOpcode3.apply(this,arguments);this.type = 'optimized-trusting-update';}OptimizedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return OptimizedTrustingUpdateOpcode;})(UpdateOpcode);var GuardedTrustingAppendOpcode=(function(_GuardedAppendOpcode2){babelHelpers.inherits(GuardedTrustingAppendOpcode,_GuardedAppendOpcode2);function GuardedTrustingAppendOpcode(){_GuardedAppendOpcode2.apply(this,arguments);this.type = 'guarded-trusting-append';this.AppendOpcode = OptimizedTrustingAppendOpcode;}GuardedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};GuardedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};GuardedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedTrustingUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedTrustingAppendOpcode;})(GuardedAppendOpcode);var GuardedTrustingUpdateOpcode=(function(_GuardedUpdateOpcode2){babelHelpers.inherits(GuardedTrustingUpdateOpcode,_GuardedUpdateOpcode2);function GuardedTrustingUpdateOpcode(){_GuardedUpdateOpcode2.apply(this,arguments);this.type = 'trusting-update';}GuardedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return GuardedTrustingUpdateOpcode;})(GuardedUpdateOpcode);APPEND_OPCODES.add(49, /* PutDynamicPartial */function(vm,_ref32){var _symbolTable=_ref32.op1;var env=vm.env;var symbolTable=vm.constants.getOther(_symbolTable);function lookupPartial(name){var normalized=String(name);if(!env.hasPartial(normalized,symbolTable)){throw new Error('Could not find a partial named "' + normalized + '"');}return env.lookupPartial(normalized,symbolTable);}var reference=_glimmerReference.map(vm.frame.getOperand(),lookupPartial);var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(50, /* PutPartial */function(vm,_ref33){var _definition=_ref33.op1;var definition=vm.constants.getOther(_definition);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(51, /* EvaluatePartial */function(vm,_ref34){var _symbolTable=_ref34.op1;var _cache=_ref34.op2;var symbolTable=vm.constants.getOther(_symbolTable);var cache=vm.constants.getOther(_cache);var _vm$frame$getImmediate=vm.frame.getImmediate();var template=_vm$frame$getImmediate.template;var block=cache[template.id];if(!block){block = template.asPartial(symbolTable);}vm.invokePartial(block);});var IterablePresenceReference=(function(){function IterablePresenceReference(artifacts){this.tag = artifacts.tag;this.artifacts = artifacts;}IterablePresenceReference.prototype.value = function value(){return !this.artifacts.isEmpty();};return IterablePresenceReference;})();APPEND_OPCODES.add(44, /* PutIterator */function(vm){var listRef=vm.frame.getOperand();var args=_glimmerUtil.expect(vm.frame.getArgs(),'PutIteratorOpcode expects a populated args register');var iterable=vm.env.iterableFor(listRef,args);var iterator=new _glimmerReference.ReferenceIterator(iterable);vm.frame.setIterator(iterator);vm.frame.setCondition(new IterablePresenceReference(iterator.artifacts));});APPEND_OPCODES.add(45, /* EnterList */function(vm,_ref35){var _slice=_ref35.op1;vm.enterList(vm.constants.getSlice(_slice));});APPEND_OPCODES.add(46, /* ExitList */function(vm){return vm.exitList();});APPEND_OPCODES.add(47, /* EnterWithKey */function(vm,_ref36){var _slice=_ref36.op2;var key=_glimmerUtil.expect(vm.frame.getKey(),'EnterWithKeyOpcode expects a populated key register');var slice=vm.constants.getSlice(_slice);vm.enterWithKey(key,slice);});var TRUE_REF=new _glimmerReference.ConstReference(true);var FALSE_REF=new _glimmerReference.ConstReference(false);APPEND_OPCODES.add(48, /* NextIter */function(vm,_ref37){var end=_ref37.op1;var item=vm.frame.getIterator().next();if(item){vm.frame.setCondition(TRUE_REF);vm.frame.setKey(item.key);vm.frame.setOperand(item.value);vm.frame.setArgs(EvaluatedArgs.positional([item.value,item.memo]));}else {vm.frame.setCondition(FALSE_REF);vm.goto(end);}});var clientId=0;function templateFactory(_ref38){var templateId=_ref38.id;var meta=_ref38.meta;var block=_ref38.block;var parsedBlock=undefined;var id=templateId || 'client-' + clientId++;var create=function(env,envMeta){var newMeta=envMeta?_glimmerUtil.assign({},envMeta,meta):meta;if(!parsedBlock){parsedBlock = JSON.parse(block);}return template(parsedBlock,id,newMeta,env);};return {id:id,meta:meta,create:create};}function template(block,id,meta,env){var scanner=new Scanner(block,meta,env);var entryPoint=undefined;var asEntryPoint=function(){if(!entryPoint)entryPoint = scanner.scanEntryPoint();return entryPoint;};var layout=undefined;var asLayout=function(){if(!layout)layout = scanner.scanLayout();return layout;};var asPartial=function(symbols){return scanner.scanPartial(symbols);};var render=function(self,appendTo,dynamicScope){var elementStack=ElementStack.forInitialRender(env,appendTo,null);var compiled=asEntryPoint().compile(env);var vm=VM.initial(env,self,dynamicScope,elementStack,compiled.symbols);return vm.execute(compiled.slice);};return {id:id,meta:meta,_block:block,asEntryPoint:asEntryPoint,asLayout:asLayout,asPartial:asPartial,render:render};}var DynamicVarReference=(function(){function DynamicVarReference(scope,nameRef){this.scope = scope;this.nameRef = nameRef;var varTag=this.varTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([nameRef.tag,varTag]);}DynamicVarReference.prototype.value = function value(){return this.getVar().value();};DynamicVarReference.prototype.get = function get(key){return this.getVar().get(key);};DynamicVarReference.prototype.getVar = function getVar(){var name=String(this.nameRef.value());var ref=this.scope.get(name);this.varTag.update(ref.tag);return ref;};return DynamicVarReference;})();function getDynamicVar(vm,args,_symbolTable){var scope=vm.dynamicScope();var nameRef=args.positional.at(0);return new DynamicVarReference(scope,nameRef);}var PartialDefinition=function PartialDefinition(name,template){this.name = name;this.template = template;};var NodeType;(function(NodeType){NodeType[NodeType["Element"] = 0] = "Element";NodeType[NodeType["Attribute"] = 1] = "Attribute";NodeType[NodeType["Text"] = 2] = "Text";NodeType[NodeType["CdataSection"] = 3] = "CdataSection";NodeType[NodeType["EntityReference"] = 4] = "EntityReference";NodeType[NodeType["Entity"] = 5] = "Entity";NodeType[NodeType["ProcessingInstruction"] = 6] = "ProcessingInstruction";NodeType[NodeType["Comment"] = 7] = "Comment";NodeType[NodeType["Document"] = 8] = "Document";NodeType[NodeType["DocumentType"] = 9] = "DocumentType";NodeType[NodeType["DocumentFragment"] = 10] = "DocumentFragment";NodeType[NodeType["Notation"] = 11] = "Notation";})(NodeType || (NodeType = {}));var Simple=Object.freeze({get NodeType(){return NodeType;}});exports.Simple = Simple;exports.templateFactory = templateFactory;exports.NULL_REFERENCE = NULL_REFERENCE;exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE;exports.PrimitiveReference = PrimitiveReference;exports.ConditionalReference = ConditionalReference;exports.OpcodeBuilderDSL = OpcodeBuilder;exports.compileLayout = compileLayout;exports.CompiledBlock = CompiledBlock;exports.CompiledProgram = CompiledProgram;exports.IAttributeManager = AttributeManager;exports.AttributeManager = AttributeManager;exports.PropertyManager = PropertyManager;exports.INPUT_VALUE_PROPERTY_MANAGER = INPUT_VALUE_PROPERTY_MANAGER;exports.defaultManagers = defaultManagers;exports.defaultAttributeManagers = defaultAttributeManagers;exports.defaultPropertyManagers = defaultPropertyManagers;exports.readDOMAttr = readDOMAttr;exports.normalizeTextValue = normalizeTextValue;exports.CompiledExpression = CompiledExpression;exports.CompiledArgs = CompiledArgs;exports.CompiledNamedArgs = CompiledNamedArgs;exports.CompiledPositionalArgs = CompiledPositionalArgs;exports.EvaluatedArgs = EvaluatedArgs;exports.EvaluatedNamedArgs = EvaluatedNamedArgs;exports.EvaluatedPositionalArgs = EvaluatedPositionalArgs;exports.getDynamicVar = getDynamicVar;exports.BlockMacros = Blocks;exports.InlineMacros = Inlines;exports.compileArgs = compileArgs;exports.setDebuggerCallback = setDebuggerCallback;exports.resetDebuggerCallback = resetDebuggerCallback;exports.BaselineSyntax = BaselineSyntax;exports.Layout = Layout;exports.UpdatingVM = UpdatingVM;exports.RenderResult = RenderResult;exports.isSafeString = isSafeString;exports.Scope = Scope;exports.Environment = Environment;exports.PartialDefinition = PartialDefinition;exports.ComponentDefinition = ComponentDefinition;exports.isComponentDefinition = isComponentDefinition;exports.DOMChanges = helper$1;exports.IDOMChanges = DOMChanges;exports.DOMTreeConstruction = DOMTreeConstruction;exports.isWhitespace = isWhitespace;exports.insertHTMLBefore = _insertHTMLBefore;exports.ElementStack = ElementStack;exports.ConcreteBounds = ConcreteBounds;}); +enifed('@glimmer/syntax', ['exports', 'handlebars', 'simple-html-tokenizer'], function (exports, _handlebars, _simpleHtmlTokenizer) { + 'use strict'; - // .......................................................... - // CONNECT AND SYNC - // - - /** - Attempts to connect this binding instance so that it can receive and relay - changes. This method will raise an exception if you have not set the - from/to properties yet. - @method connect - @param {Object} obj The root object for this binding. - @return {Ember.Binding} `this` - @public - */ - connect: function (obj) { - _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.connect()', !!obj); - - var fromObj = undefined, - fromPath = undefined, - possibleGlobal = undefined; - - // If the binding's "from" path could be interpreted as a global, verify - // whether the path refers to a global or not by consulting `Ember.lookup`. - if (_emberMetalPath_cache.isGlobalPath(this._from)) { - var _name = _emberMetalPath_cache.getFirstKey(this._from); - possibleGlobal = _emberEnvironment.context.lookup[_name]; - - if (possibleGlobal) { - fromObj = possibleGlobal; - fromPath = _emberMetalPath_cache.getTailPath(this._from); - } - } - - if (fromObj === undefined) { - fromObj = obj; - fromPath = this._from; - } - - _emberMetalProperty_set.trySet(obj, this._to, _emberMetalProperty_get.get(fromObj, fromPath)); - - // Add an observer on the object to be notified when the binding should be updated. - _emberMetalObserver.addObserver(fromObj, fromPath, this, 'fromDidChange'); - - // If the binding is a two-way binding, also set up an observer on the target. - if (!this._oneWay) { - _emberMetalObserver.addObserver(obj, this._to, this, 'toDidChange'); - } - - _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect'); - - fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); - - this._readyToSync = true; - this._fromObj = fromObj; - this._fromPath = fromPath; - this._toObj = obj; - - return this; - }, - - /** - Disconnects the binding instance. Changes will no longer be relayed. You - will not usually need to call this method. - @method disconnect - @return {Ember.Binding} `this` - @public - */ - disconnect: function () { - _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); - - // Remove an observer on the object so we're no longer notified of - // changes that should update bindings. - _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); - - // If the binding is two-way, remove the observer from the target as well. - if (!this._oneWay) { - _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); - } - - this._readyToSync = false; // Disable scheduled syncs... - return this; - }, - - // .......................................................... - // PRIVATE - // - - /* Called when the from side changes. */ - fromDidChange: function (target) { - this._scheduleSync('fwd'); - }, - - /* Called when the to side changes. */ - toDidChange: function (target) { - this._scheduleSync('back'); - }, - - _scheduleSync: function (dir) { - var existingDir = this._direction; - - // If we haven't scheduled the binding yet, schedule it. - if (existingDir === undefined) { - _emberMetalRun_loop.default.schedule('sync', this, '_sync'); - this._direction = dir; - } - - // If both a 'back' and 'fwd' sync have been scheduled on the same object, - // default to a 'fwd' sync so that it remains deterministic. - if (existingDir === 'back' && dir === 'fwd') { - this._direction = 'fwd'; - } - }, - - _sync: function () { - var log = _emberEnvironment.ENV.LOG_BINDINGS; - - var toObj = this._toObj; - - // Don't synchronize destroyed objects or disconnected bindings. - if (toObj.isDestroyed || !this._readyToSync) { - return; - } - - // Get the direction of the binding for the object we are - // synchronizing from. - var direction = this._direction; - - var fromObj = this._fromObj; - var fromPath = this._fromPath; - - this._direction = undefined; - - // If we're synchronizing from the remote object... - if (direction === 'fwd') { - var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); - if (log) { - _emberConsole.default.log(' ', this.toString(), '->', fromValue, fromObj); - } - if (this._oneWay) { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - } else { - _emberMetalObserver._suspendObserver(toObj, this._to, this, 'toDidChange', function () { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - }); - } - // If we're synchronizing *to* the remote object. - } else if (direction === 'back') { - var toValue = _emberMetalProperty_get.get(toObj, this._to); - if (log) { - _emberConsole.default.log(' ', this.toString(), '<-', toValue, toObj); - } - _emberMetalObserver._suspendObserver(fromObj, fromPath, this, 'fromDidChange', function () { - _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); - }); - } - } - - }; - - function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { - var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; - var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; - var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - - var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; - _emberMetalDebug.deprecate(objectInfo + deprecateGlobalMessage, !deprecateGlobal, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - _emberMetalDebug.deprecate(objectInfo + deprecateOneWayMessage, !deprecateOneWay, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - _emberMetalDebug.deprecate(objectInfo + deprecateAliasMessage, !deprecateAlias, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - } - - function mixinProperties(to, from) { - for (var key in from) { - if (from.hasOwnProperty(key)) { - to[key] = from[key]; - } - } - } - - mixinProperties(Binding, { - - /* - See `Ember.Binding.from`. - @method from - @static - */ - from: function (from) { - var C = this; - return new C(undefined, from); - }, - - /* - See `Ember.Binding.to`. - @method to - @static - */ - to: function (to) { - var C = this; - return new C(to, undefined); - } - }); - /** - An `Ember.Binding` connects the properties of two objects so that whenever - the value of one property changes, the other property will be changed also. - - ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. - - You do not usually create Binding objects directly but instead describe - bindings in your class or object definition using automatic binding - detection. - - Properties ending in a `Binding` suffix will be converted to `Ember.Binding` - instances. The value of this property should be a string representing a path - to another object or a custom binding instance created using Binding helpers - (see "One Way Bindings"): - - ``` - valueBinding: "MyApp.someController.title" - ``` - - This will create a binding from `MyApp.someController.title` to the `value` - property of your object instance automatically. Now the two values will be - kept in sync. - - ## One Way Bindings - - One especially useful binding customization you can use is the `oneWay()` - helper. This helper tells Ember that you are only interested in - receiving changes on the object you are binding from. For example, if you - are binding to a preference and you want to be notified if the preference - has changed, but your object will not be changing the preference itself, you - could do: - - ``` - bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") - ``` - - This way if the value of `MyApp.preferencesController.bigTitles` changes the - `bigTitles` property of your object will change also. However, if you - change the value of your `bigTitles` property, it will not update the - `preferencesController`. - - One way bindings are almost twice as fast to setup and twice as fast to - execute because the binding only has to worry about changes to one side. - - You should consider using one way bindings anytime you have an object that - may be created frequently and you do not intend to change a property; only - to monitor it for changes (such as in the example above). - - ## Adding Bindings Manually - - All of the examples above show you how to configure a custom binding, but the - result of these customizations will be a binding template, not a fully active - Binding instance. The binding will actually become active only when you - instantiate the object the binding belongs to. It is useful, however, to - understand what actually happens when the binding is activated. - - For a binding to function it must have at least a `from` property and a `to` - property. The `from` property path points to the object/key that you want to - bind from while the `to` path points to the object/key you want to bind to. - - When you define a custom binding, you are usually describing the property - you want to bind from (such as `MyApp.someController.value` in the examples - above). When your object is created, it will automatically assign the value - you want to bind `to` based on the name of your binding key. In the - examples above, during init, Ember objects will effectively call - something like this on your binding: - - ```javascript - binding = Ember.Binding.from("valueBinding").to("value"); - ``` - - This creates a new binding instance based on the template you provide, and - sets the to path to the `value` property of the new object. Now that the - binding is fully configured with a `from` and a `to`, it simply needs to be - connected to become active. This is done through the `connect()` method: - - ```javascript - binding.connect(this); - ``` - - Note that when you connect a binding you pass the object you want it to be - connected to. This object will be used as the root for both the from and - to side of the binding when inspecting relative paths. This allows the - binding to be automatically inherited by subclassed objects as well. - - This also allows you to bind between objects using the paths you declare in - `from` and `to`: - - ```javascript - // Example 1 - binding = Ember.Binding.from("App.someObject.value").to("value"); - binding.connect(this); - - // Example 2 - binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); - binding.connect(this); - ``` - - Now that the binding is connected, it will observe both the from and to side - and relay changes. - - If you ever needed to do so (you almost never will, but it is useful to - understand this anyway), you could manually create an active binding by - using the `Ember.bind()` helper method. (This is the same method used by - to setup your bindings on objects): - - ```javascript - Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); - ``` - - Both of these code fragments have the same effect as doing the most friendly - form of binding creation like so: - - ```javascript - MyApp.anotherObject = Ember.Object.create({ - valueBinding: "MyApp.someController.value", - - // OTHER CODE FOR THIS OBJECT... - }); - ``` - - Ember's built in binding creation method makes it easy to automatically - create bindings for you. You should always use the highest-level APIs - available, even if you understand how it works underneath. - - @class Binding - @namespace Ember - @since Ember 0.9 - @public - */ - // Ember.Binding = Binding; ES6TODO: where to put this? - - /** - Global helper method to create a new binding. Just pass the root object - along with a `to` and `from` path to create and connect the binding. - - @method bind - @for Ember - @param {Object} obj The root object of the transform. - @param {String} to The path to the 'to' side of the binding. - Must be relative to obj. - @param {String} from The path to the 'from' side of the binding. - Must be relative to obj or a global path. - @return {Ember.Binding} binding instance - @public - */ - - function bind(obj, to, from) { - return new Binding(to, from).connect(obj); - } - - exports.Binding = Binding; -}); -enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; - - var Cache = (function () { - function Cache(limit, func, key, store) { - babelHelpers.classCallCheck(this, Cache); - - this.size = 0; - this.misses = 0; - this.hits = 0; - this.limit = limit; - this.func = func; - this.key = key; - this.store = store || new DefaultStore(); - } - - Cache.prototype.get = function get(obj) { - var key = this.key === undefined ? obj : this.key(obj); - var value = this.store.get(key); - if (value === undefined) { - this.misses++; - value = this._set(key, this.func(obj)); - } else if (value === _emberMetalMeta.UNDEFINED) { - this.hits++; - value = undefined; - } else { - this.hits++; - // nothing to translate - } - - return value; - }; - - Cache.prototype.set = function set(obj, value) { - var key = this.key === undefined ? obj : this.key(obj); - return this._set(key, value); - }; - - Cache.prototype._set = function _set(key, value) { - if (this.limit > this.size) { - this.size++; - if (value === undefined) { - this.store.set(key, _emberMetalMeta.UNDEFINED); - } else { - this.store.set(key, value); - } - } - - return value; - }; - - Cache.prototype.purge = function purge() { - this.store.clear(); - this.size = 0; - this.hits = 0; - this.misses = 0; - }; - - return Cache; - })(); - - exports.default = Cache; - - var DefaultStore = (function () { - function DefaultStore() { - babelHelpers.classCallCheck(this, DefaultStore); - - this.data = new _emberUtils.EmptyObject(); - } - - DefaultStore.prototype.get = function get(key) { - return this.data[key]; - }; - - DefaultStore.prototype.set = function set(key, value) { - this.data[key] = value; - }; - - DefaultStore.prototype.clear = function clear() { - this.data = new _emberUtils.EmptyObject(); - }; - - return DefaultStore; - })(); -}); -enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalWatch_path) { - 'use strict'; - - exports.finishChains = finishChains; - - var FIRST_KEY = /^([^\.]+)/; - - function firstKey(path) { - return path.match(FIRST_KEY)[0]; - } - - function isObject(obj) { - return typeof obj === 'object' && obj; - } - - function isVolatile(obj) { - return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); - } - - function ChainWatchers() { - // chain nodes that reference a key in this obj by key - // we only create ChainWatchers when we are going to add them - // so create this upfront - this.chains = new _emberUtils.EmptyObject(); - } - - ChainWatchers.prototype = { - add: function (key, node) { - var nodes = this.chains[key]; - if (nodes === undefined) { - this.chains[key] = [node]; - } else { - nodes.push(node); - } - }, - - remove: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - nodes.splice(i, 1); - break; - } - } - } - }, - - has: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - return true; - } - } - } - return false; - }, - - revalidateAll: function () { - for (var key in this.chains) { - this.notify(key, true, undefined); - } - }, - - revalidate: function (key) { - this.notify(key, true, undefined); - }, - - // key: the string key that is part of a path changed - // revalidate: boolean; the chains that are watching this value should revalidate - // callback: function that will be called with the object and path that - // will be/are invalidated by this key change, depending on - // whether the revalidate flag is passed - notify: function (key, revalidate, callback) { - var nodes = this.chains[key]; - if (nodes === undefined || nodes.length === 0) { - return; - } - - var affected = undefined; - - if (callback) { - affected = []; - } - - for (var i = 0; i < nodes.length; i++) { - nodes[i].notify(revalidate, affected); - } - - if (callback === undefined) { - return; - } - - // we gather callbacks so we don't notify them during revalidation - for (var i = 0; i < affected.length; i += 2) { - var obj = affected[i]; - var path = affected[i + 1]; - callback(obj, path); - } - } - }; - - function makeChainWatcher() { - return new ChainWatchers(); - } - - function addChainWatcher(obj, keyName, node) { - var m = _emberMetalMeta.meta(obj); - m.writableChainWatchers(makeChainWatcher).add(keyName, node); - _emberMetalWatch_key.watchKey(obj, keyName, m); - } - - function removeChainWatcher(obj, keyName, node, _meta) { - if (!isObject(obj)) { - return; - } - - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (!meta || !meta.readableChainWatchers()) { - return; - } - - // make meta writable - meta = _emberMetalMeta.meta(obj); - - meta.readableChainWatchers().remove(keyName, node); - - _emberMetalWatch_key.unwatchKey(obj, keyName, meta); - } - - // A ChainNode watches a single key on an object. If you provide a starting - // value for the key then the node won't actually watch it. For a root node - // pass null for parent and key and object for value. - function ChainNode(parent, key, value) { - this._parent = parent; - this._key = key; - - // _watching is true when calling get(this._parent, this._key) will - // return the value of this node. - // - // It is false for the root of a chain (because we have no parent) - // and for global paths (because the parent node is the object with - // the observer on it) - this._watching = value === undefined; - - this._chains = undefined; - this._object = undefined; - this.count = 0; - - this._value = value; - this._paths = {}; - if (this._watching) { - var obj = parent.value(); - - if (!isObject(obj)) { - return; - } - - this._object = obj; - - addChainWatcher(this._object, this._key, this); - } - } - - function lazyGet(obj, key) { - if (!isObject(obj)) { - return; - } - - var meta = _emberMetalMeta.peekMeta(obj); - - // check if object meant only to be a prototype - if (meta && meta.proto === obj) { - return; - } - - // Use `get` if the return value is an EachProxy or an uncacheable value. - if (isVolatile(obj[key])) { - return _emberMetalProperty_get.get(obj, key); - // Otherwise attempt to get the cached value of the computed property - } else { - var cache = meta.readableCache(); - if (cache && key in cache) { - return cache[key]; - } - } - } - - ChainNode.prototype = { - value: function () { - if (this._value === undefined && this._watching) { - var obj = this._parent.value(); - this._value = lazyGet(obj, this._key); - } - return this._value; - }, - - destroy: function () { - if (this._watching) { - var obj = this._object; - if (obj) { - removeChainWatcher(obj, this._key, this); - } - this._watching = false; // so future calls do nothing - } - }, - - // copies a top level object only - copy: function (obj) { - var ret = new ChainNode(null, null, obj); - var paths = this._paths; - var path = undefined; - - for (path in paths) { - // this check will also catch non-number vals. - if (paths[path] <= 0) { - continue; - } - ret.add(path); - } - return ret; - }, - - // called on the root node of a chain to setup watchers on the specified - // path. - add: function (path) { - var paths = this._paths; - paths[path] = (paths[path] || 0) + 1; - - var key = firstKey(path); - var tail = path.slice(key.length + 1); - - this.chain(key, tail); - }, - - // called on the root node of a chain to teardown watcher on the specified - // path - remove: function (path) { - var paths = this._paths; - if (paths[path] > 0) { - paths[path]--; - } - - var key = firstKey(path); - var tail = path.slice(key.length + 1); - - this.unchain(key, tail); - }, - - chain: function (key, path) { - var chains = this._chains; - var node = undefined; - if (chains === undefined) { - chains = this._chains = new _emberUtils.EmptyObject(); - } else { - node = chains[key]; - } - - if (node === undefined) { - node = chains[key] = new ChainNode(this, key, undefined); - } - - node.count++; // count chains... - - // chain rest of path if there is one - if (path) { - key = firstKey(path); - path = path.slice(key.length + 1); - node.chain(key, path); - } - }, - - unchain: function (key, path) { - var chains = this._chains; - var node = chains[key]; - - // unchain rest of path first... - if (path && path.length > 1) { - var nextKey = firstKey(path); - var nextPath = path.slice(nextKey.length + 1); - node.unchain(nextKey, nextPath); - } - - // delete node if needed. - node.count--; - if (node.count <= 0) { - chains[node._key] = undefined; - node.destroy(); - } - }, - - notify: function (revalidate, affected) { - if (revalidate && this._watching) { - var parentValue = this._parent.value(); - - if (parentValue !== this._object) { - if (this._object) { - removeChainWatcher(this._object, this._key, this); - } - - if (isObject(parentValue)) { - this._object = parentValue; - addChainWatcher(parentValue, this._key, this); - } else { - this._object = undefined; - } - } - this._value = undefined; - } - - // then notify chains... - var chains = this._chains; - var node = undefined; - if (chains) { - for (var key in chains) { - node = chains[key]; - if (node !== undefined) { - node.notify(revalidate, affected); - } - } - } - - if (affected && this._parent) { - this._parent.populateAffected(this._key, 1, affected); - } - }, - - populateAffected: function (path, depth, affected) { - if (this._key) { - path = this._key + '.' + path; - } - - if (this._parent) { - this._parent.populateAffected(path, depth + 1, affected); - } else { - if (depth > 1) { - affected.push(this.value(), path); - } - } - } - }; - - function finishChains(obj) { - // We only create meta if we really have to - var m = _emberMetalMeta.peekMeta(obj); - if (m) { - m = _emberMetalMeta.meta(obj); - - // finish any current chains node watchers that reference obj - var chainWatchers = m.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidateAll(); - } - // ensure that if we have inherited any chains they have been - // copied onto our own meta. - if (m.readableChains()) { - m.writableChains(_emberMetalWatch_path.makeChainNode); - } - } - } - - exports.removeChainWatcher = removeChainWatcher; - exports.ChainNode = ChainNode; -}); -enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) { - 'use strict'; - - exports.default = computed; - - /** - @module ember - @submodule ember-metal - */ - - var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; - - /** - A computed property transforms an object literal with object's accessor function(s) 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 - `fullName` - by calling - `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter 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 - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', function() { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }) - }); - - let 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 by providing additional function (`set`) in hash argument. - If you try to set a computed property, it will try to invoke setter accessor function with the key and - value you want to set it to as arguments. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }, - set(key, value) { - let [firstName, lastName] = value.split(' '); - - this.set('firstName', firstName); - this.set('lastName', lastName); - - return value; - } - }) - }); - - let person = Person.create(); - - person.set('fullName', 'Peter Wagenet'); - person.get('firstName'); // 'Peter' - person.get('lastName'); // 'Wagenet' - ``` - - You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined. - - You can also mark computed property as `.readOnly()` and block all attempts to set it. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'); - let lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - } - }).readOnly() - }); - - let person = Person.create(); - person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX> - ``` - - Additional resources: - - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md) - - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax) - - @class ComputedProperty - @namespace Ember - @public - */ - function ComputedProperty(config, opts) { - this.isDescriptor = true; - if (typeof config === 'function') { - this._getter = config; - } else { - _emberMetalDebug.assert('Ember.computed expects a function or an object as last argument.', typeof config === 'object' && !Array.isArray(config)); - _emberMetalDebug.assert('Config object passed to an Ember.computed can only contain `get` or `set` keys.', (function () { - var keys = Object.keys(config); - for (var i = 0; i < keys.length; i++) { - if (keys[i] !== 'get' && keys[i] !== 'set') { - return false; - } - } - return true; - })()); - this._getter = config.get; - this._setter = config.set; - } - _emberMetalDebug.assert('Computed properties must receive a getter or a setter, you passed none.', !!this._getter || !!this._setter); - this._dependentKeys = undefined; - this._suspended = undefined; - this._meta = undefined; - this._volatile = false; - this._dependentKeys = opts && opts.dependentKeys; - this._readOnly = false; - } - - ComputedProperty.prototype = new _emberMetalProperties.Descriptor(); - ComputedProperty.prototype.constructor = ComputedProperty; - - var ComputedPropertyPrototype = ComputedProperty.prototype; - - /** - 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. - - It also does not automatically fire any change events. You must manually notify - any changes if you want to observe this property. - - Dependency keys have no effect on volatile properties as they are for cache - invalidation and notification when cached value is invalidated. - - ```javascript - let outsideService = Ember.Object.extend({ - value: Ember.computed(function() { - return OutsideService.getValue(); - }).volatile() - }).create(); - ``` - - @method volatile - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.volatile = function () { - this._volatile = true; - 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 - let Person = Ember.Object.extend({ - guid: Ember.computed(function() { - return 'guid-guid-guid'; - }).readOnly() - }); - - let person = Person.create(); - - person.set('guid', 'new-guid'); // will throw an exception - ``` - - @method readOnly - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.readOnly = function () { - this._readOnly = true; - _emberMetalDebug.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 - let President = Ember.Object.extend({ - fullName: Ember.computed(function() { - return this.get('firstName') + ' ' + this.get('lastName'); - - // Tell Ember that this computed property depends on firstName - // and lastName - }).property('firstName', 'lastName') - }); - - let 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 = []; - - function addArg(property) { - _emberMetalDebug.warn('Dependent keys containing @each only work one level deep. ' + ('You used the key "' + property + '" which is invalid. ') + 'Please create an intermediary computed property.', DEEP_EACH_REGEX.test(property) === false, { id: 'ember-metal.computed-deep-each' }); - args.push(property); - } - - for (var i = 0; i < arguments.length; 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: Ember.computed(function() { - let personId = this.get('personId'); - return App.Person.create({ id: personId }); - }).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; - } - }; - - // invalidate cache when CP key changes - 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._volatile || this._suspended === obj) { - return; - } - - // don't create objects just to invalidate - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta || meta.source !== obj) { - return; - } - - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - cache[keyName] = undefined; - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; - - ComputedPropertyPrototype.get = function (obj, keyName) { - if (this._volatile) { - return this._getter.call(obj, keyName); - } - - var meta = _emberMetalMeta.meta(obj); - var cache = meta.writableCache(); - - var result = cache[keyName]; - if (result === _emberMetalMeta.UNDEFINED) { - return undefined; - } else if (result !== undefined) { - return result; - } - - var ret = this._getter.call(obj, keyName); - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } - - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - - return ret; - }; - - ComputedPropertyPrototype.set = function computedPropertySetEntry(obj, keyName, value) { - if (this._readOnly) { - this._throwReadOnlyError(obj, keyName); - } - - if (!this._setter) { - return this.clobberSet(obj, keyName, value); - } - - if (this._volatile) { - return this.volatileSet(obj, keyName, value); - } - - return this.setWithSuspend(obj, keyName, value); - }; - - ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) { - throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj)); - }; - - ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) { - var cachedValue = cacheFor(obj, keyName); - _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue); - _emberMetalProperty_set.set(obj, keyName, value); - return value; - }; - - ComputedPropertyPrototype.volatileSet = function computedPropertyVolatileSet(obj, keyName, value) { - return this._setter.call(obj, keyName, value); - }; - - ComputedPropertyPrototype.setWithSuspend = function computedPropertySetWithSuspend(obj, keyName, value) { - var oldSuspended = this._suspended; - this._suspended = obj; - try { - return this._set(obj, keyName, value); - } finally { - this._suspended = oldSuspended; - } - }; - - ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { - // cache requires own meta - var meta = _emberMetalMeta.meta(obj); - // either there is a writable cache or we need one to update - var cache = meta.writableCache(); - var hadCachedValue = false; - var cachedValue = undefined; - if (cache[keyName] !== undefined) { - if (cache[keyName] !== _emberMetalMeta.UNDEFINED) { - cachedValue = cache[keyName]; - } - hadCachedValue = true; - } - - var ret = this._setter.call(obj, keyName, value, cachedValue); - - // allows setter to return the same value that is cached already - if (hadCachedValue && cachedValue === ret) { - return ret; - } - - _emberMetalProperty_events.propertyWillChange(obj, keyName); - - if (hadCachedValue) { - cache[keyName] = undefined; - } - - if (!hadCachedValue) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } - - _emberMetalProperty_events.propertyDidChange(obj, keyName); - - return ret; - }; - - /* called before property is overridden */ - ComputedPropertyPrototype.teardown = function (obj, keyName) { - if (this._volatile) { - return; - } - var meta = _emberMetalMeta.meta(obj); - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - cache[keyName] = undefined; - } - }; - - /** - This helper returns a new property descriptor that wraps the passed - computed property function. You can use this helper to define properties - with mixins or via `Ember.defineProperty()`. - - If you pass a function as an argument, it will be used as a getter. A computed - property defined in this way might look like this: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', function() { - return `${this.get('firstName')} ${this.get('lastName')}`; - }) - }); - - let client = Person.create(); - - client.get('fullName'); // 'Betty Jones' - - client.set('lastName', 'Fuller'); - client.get('fullName'); // 'Betty Fuller' - ``` - - You can pass a hash with two functions, `get` and `set`, as an - argument to provide both a getter and setter: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - return `${this.get('firstName')} ${this.get('lastName')}`; - }, - set(key, value) { - let [firstName, lastName] = value.split(/\s+/); - this.setProperties({ firstName, lastName }); - return value; - } - }); - }) - - let client = Person.create(); - client.get('firstName'); // 'Betty' - - client.set('fullName', 'Carroll Fuller'); - client.get('firstName'); // 'Carroll' - ``` - - The `set` function should accept two parameters, `key` and `value`. The value - returned from `set` will be the new value of the property. - - _Note: This is the preferred way to define computed properties when writing third-party - libraries that depend on or use Ember, since there is no guarantee that the user - will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._ - - The alternative syntax, with prototype extensions, might look like: - - ```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 = undefined; - - 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 = _emberMetalMeta.peekMeta(obj); - var cache = meta && meta.source === obj && meta.readableCache(); - var ret = cache && cache[key]; - - if (ret === _emberMetalMeta.UNDEFINED) { - return undefined; - } - return ret; - } - - cacheFor.set = function (cache, key, value) { - if (value === undefined) { - cache[key] = _emberMetalMeta.UNDEFINED; - } else { - cache[key] = value; - } - }; - - cacheFor.get = function (cache, key) { - var ret = cache[key]; - if (ret === _emberMetalMeta.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', 'ember-environment'], function (exports, _emberEnvironment) { - 'use strict'; - - /** - @module ember - @submodule ember-metal - */ - - /** - This namespace contains all Ember methods and functions. Future versions of - Ember may overwrite this namespace and therefore, you should avoid adding any - new properties. - - At the heart of Ember is Ember-Runtime, a set of core functions that provide - cross-platform compatibility and object property observing. Ember-Runtime is - small and performance-focused so you can use it alongside other - cross-platform libraries such as jQuery. For more details, see - [Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html). - - @class Ember - @static - @public - */ - var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {}; - - // Make sure these are set whether Ember was already defined or not - Ember.isNamespace = true; - Ember.toString = function () { - return 'Ember'; - }; - - // .......................................................... - // BOOTSTRAP - // - - exports.default = Ember; -}); -enifed("ember-metal/debug", ["exports"], function (exports) { - "use strict"; - - exports.getDebugFunction = getDebugFunction; - exports.setDebugFunction = setDebugFunction; - exports.assert = assert; - exports.info = info; - exports.warn = warn; - exports.debug = debug; - exports.deprecate = deprecate; - exports.deprecateFunc = deprecateFunc; - exports.runInDebug = runInDebug; - exports.debugSeal = debugSeal; - exports.debugFreeze = debugFreeze; - var debugFunctions = { - assert: function () {}, - info: function () {}, - warn: function () {}, - debug: function () {}, - deprecate: function () {}, - deprecateFunc: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return args[args.length - 1]; - }, - runInDebug: function () {}, - debugSeal: function () {}, - debugFreeze: function () {} - }; - - exports.debugFunctions = debugFunctions; - - function getDebugFunction(name) { - return debugFunctions[name]; - } - - function setDebugFunction(name, fn) { - debugFunctions[name] = fn; - } - - function assert() { - return debugFunctions.assert.apply(undefined, arguments); - } - - function info() { - return debugFunctions.info.apply(undefined, arguments); - } - - function warn() { - return debugFunctions.warn.apply(undefined, arguments); - } - - function debug() { - return debugFunctions.debug.apply(undefined, arguments); - } - - function deprecate() { - return debugFunctions.deprecate.apply(undefined, arguments); - } - - function deprecateFunc() { - return debugFunctions.deprecateFunc.apply(undefined, arguments); - } - - function runInDebug() { - return debugFunctions.runInDebug.apply(undefined, arguments); - } - - function debugSeal() { - return debugFunctions.debugSeal.apply(undefined, arguments); - } - - function debugFreeze() { - return debugFunctions.debugFreeze.apply(undefined, arguments); - } -}); -enifed('ember-metal/dependent_keys', ['exports', 'ember-metal/watching'], function (exports, _emberMetalWatching) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - exports.addDependentKeys = addDependentKeys; - exports.removeDependentKeys = removeDependentKeys; - - /** - @module ember - @submodule ember-metal - */ - - // .......................................................... - // DEPENDENT KEYS - // - - function addDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // add all of its dependent keys. - var idx = undefined, - depKey = undefined; - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; - } - - for (idx = 0; idx < depKeys.length; idx++) { - depKey = depKeys[idx]; - // Increment the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1); - // Watch the depKey - _emberMetalWatching.watch(obj, depKey, meta); - } - } - - function removeDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // remove all of its dependent keys. - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; - } - - for (var idx = 0; idx < depKeys.length; idx++) { - var depKey = depKeys[idx]; - // Decrement the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1); - // Unwatch the depKey - _emberMetalWatching.unwatch(obj, depKey, meta); - } - } -}); -enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set) { - /** - @module ember - @submodule ember-metal - */ - - 'use strict'; - - exports.deprecateProperty = deprecateProperty; - - /** - Used internally to allow changing properties in a backwards compatible way, and print a helpful - deprecation warning. - - @method deprecateProperty - @param {Object} object The object to add the deprecated property to. - @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). - @param {String} newKey The property that will be aliased. - @private - @since 1.7.0 - */ - - function deprecateProperty(object, deprecatedKey, newKey, options) { - function _deprecate() { - _emberMetalDebug.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.', false, options); - } - - Object.defineProperty(object, deprecatedKey, { - configurable: true, - enumerable: false, - set: function (value) { - _deprecate(); - _emberMetalProperty_set.set(this, newKey, value); - }, - get: function () { - _deprecate(); - return _emberMetalProperty_get.get(this, newKey); - } - }); - } -}); -enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) { - 'use strict'; - - exports.default = descriptor; - - function descriptor(desc) { - return new Descriptor(desc); - } - - /** - A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need - this at all, however, the way we currently flatten/merge our mixins require - a special value to denote a descriptor. - - @class Descriptor - @private - */ - - var Descriptor = (function (_EmberDescriptor) { - babelHelpers.inherits(Descriptor, _EmberDescriptor); - - function Descriptor(desc) { - babelHelpers.classCallCheck(this, Descriptor); - - _EmberDescriptor.call(this); - this.desc = desc; - } - - Descriptor.prototype.setup = function setup(obj, key) { - Object.defineProperty(obj, key, this.desc); - }; - - Descriptor.prototype.teardown = function teardown(obj, key) {}; - - return Descriptor; - })(_emberMetalProperties.Descriptor); -}); -enifed("ember-metal/error", ["exports"], function (exports) { - - /** - A subclass of the JavaScript Error object for use in Ember. - - @class Error - @namespace Ember - @extends Error - @constructor - @public - */ - "use strict"; - - exports.default = EmberError; - - function EmberError(message) { - if (!(this instanceof EmberError)) { - return new EmberError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, EmberError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message; - this.name = error.name; - this.number = error.number; - this.code = error.code; - } - - EmberError.prototype = Object.create(Error.prototype); -}); -enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { - 'use strict'; - - exports.getOnerror = getOnerror; - exports.setOnerror = setOnerror; - exports.dispatchError = dispatchError; - exports.setDispatchOverride = setDispatchOverride; - - // To maintain stacktrace consistency across browsers - var getStack = function (error) { - var stack = error.stack; - var message = error.message; - - if (stack && stack.indexOf(message) === -1) { - stack = message + '\n' + stack; - } - - return stack; - }; - - var onerror = undefined; - // Ember.onerror getter - - function getOnerror() { - return onerror; - } - - // Ember.onerror setter - - function setOnerror(handler) { - onerror = handler; - } - - var dispatchOverride = undefined; - // dispatch error - - function dispatchError(error) { - if (dispatchOverride) { - dispatchOverride(error); - } else { - defaultDispatch(error); - } - } - - // allows testing adapter to override dispatch - - function setDispatchOverride(handler) { - dispatchOverride = handler; - } - - function defaultDispatch(error) { - if (_emberMetalTesting.isTesting()) { - throw error; - } - if (onerror) { - onerror(error); - } else { - _emberConsole.default.error(getStack(error)); - } - } -}); -enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-metal - */ - exports.accumulateListeners = accumulateListeners; - exports.addListener = addListener; - exports.removeListener = removeListener; - exports.suspendListener = suspendListener; - exports.suspendListeners = suspendListeners; - exports.watchedEvents = watchedEvents; - exports.sendEvent = sendEvent; - exports.hasListeners = hasListeners; - exports.listenersFor = listenersFor; - exports.on = on; - - /* - The event system uses a series of nested hashes to store listeners on an - object. When a listener is registered, or when an event arrives, these - hashes are consulted to determine which target and action pair to invoke. - - The hashes are stored in the object's meta hash, and look like this: - - // Object's meta hash - { - listeners: { // variable name: `listenerSet` - "foo:changed": [ // variable name: `actions` - target, method, flags - ] - } - } - - */ - - function indexOf(array, target, method) { - var index = -1; - // hashes are added to the end of the event array - // so it makes sense to start searching at the end - // of the array and search in reverse - for (var i = array.length - 3; i >= 0; i -= 3) { - if (target === array[i] && method === array[i + 1]) { - index = i; - break; - } - } - return index; - } - - function accumulateListeners(obj, eventName, otherActions) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return; - } - var actions = meta.matchingListeners(eventName); - var newActions = []; - - for (var i = actions.length - 3; i >= 0; i -= 3) { - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - var actionIndex = indexOf(otherActions, target, method); - - if (actionIndex === -1) { - otherActions.push(target, method, flags); - newActions.push(target, method, flags); - } - } - - return newActions; - } - - /** - Add an event listener - - @method addListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Boolean} once A flag whether a function should only be called once - @public - */ - - function addListener(obj, eventName, target, method, once) { - _emberMetalDebug.assert('You must pass at least an object and event name to Ember.addListener', !!obj && !!eventName); - - _emberMetalDebug.deprecate('didInitAttrs called in ' + (obj && obj.toString && obj.toString()) + '.', eventName !== 'didInitAttrs', { - id: 'ember-views.did-init-attrs', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' - }); - - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - - var flags = 0; - if (once) { - flags |= _emberMetalMeta_listeners.ONCE; - } - - _emberMetalMeta.meta(obj).addToListeners(eventName, target, method, flags); - - if ('function' === typeof obj.didAddListener) { - obj.didAddListener(eventName, target, method); - } - } - - /** - Remove an event listener - - Arguments should match those passed to `Ember.addListener`. - - @method removeListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @public - */ - - function removeListener(obj, eventName, target, method) { - _emberMetalDebug.assert('You must pass at least an object and event name to Ember.removeListener', !!obj && !!eventName); - - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - - _emberMetalMeta.meta(obj).removeFromListeners(eventName, target, method, function () { - if ('function' === typeof obj.didRemoveListener) { - obj.didRemoveListener.apply(obj, arguments); - } - }); - } - - /** - Suspend listener during callback. - - This should only be used by the target of the event listener - when it is taking an action that would cause the event, e.g. - an object might suspend its property change listener while it is - setting that property. - - @method suspendListener - @for Ember - - @private - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ - - function suspendListener(obj, eventName, target, method, callback) { - return suspendListeners(obj, [eventName], target, method, callback); - } - - /** - Suspends multiple listeners during a callback. - - @method suspendListeners - @for Ember - - @private - @param obj - @param {Array} eventNames Array of event names - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ - - function suspendListeners(obj, eventNames, target, method, callback) { - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - return _emberMetalMeta.meta(obj).suspendListeners(eventNames, target, method, callback); - } - - /** - Return a list of currently watched events - - @private - @method watchedEvents - @for Ember - @param obj - */ - - function watchedEvents(obj) { - return _emberMetalMeta.meta(obj).watchedEvents(); - } - - /** - Send an event. The execution of suspended listeners - is skipped, and once listeners are removed. A listener without - a target is executed on the passed object. If an array of actions - is not passed, the actions stored on the passed object are invoked. - - @method sendEvent - @for Ember - @param obj - @param {String} eventName - @param {Array} params Optional parameters for each listener. - @param {Array} actions Optional array of actions (listeners). - @return true - @public - */ - - function sendEvent(obj, eventName, params, actions) { - if (!actions) { - var meta = _emberMetalMeta.peekMeta(obj); - actions = meta && meta.matchingListeners(eventName); - } - - if (!actions || actions.length === 0) { - return; - } - - for (var i = actions.length - 3; i >= 0; i -= 3) { - // looping in reverse for once listeners - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - - if (!method) { - continue; - } - if (flags & _emberMetalMeta_listeners.SUSPENDED) { - continue; - } - if (flags & _emberMetalMeta_listeners.ONCE) { - removeListener(obj, eventName, target, method); - } - if (!target) { - target = obj; - } - if ('string' === typeof method) { - if (params) { - _emberUtils.applyStr(target, method, params); - } else { - target[method](); - } - } else { - if (params) { - method.apply(target, params); - } else { - method.call(target); - } - } - } - return true; - } - - /** - @private - @method hasListeners - @for Ember - @param obj - @param {String} eventName - */ - - function hasListeners(obj, eventName) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return false; - } - return meta.matchingListeners(eventName).length > 0; - } - - /** - @private - @method listenersFor - @for Ember - @param obj - @param {String} eventName - */ - - function listenersFor(obj, eventName) { - var ret = []; - var meta = _emberMetalMeta.peekMeta(obj); - var actions = meta && meta.matchingListeners(eventName); - - if (!actions) { - return ret; - } - - for (var i = 0; i < actions.length; i += 3) { - var target = actions[i]; - var method = actions[i + 1]; - ret.push([target, method]); - } - - return ret; - } - - /** - Define a property as a function that should be executed when - a specified event or events are triggered. - - - ``` javascript - let Job = Ember.Object.extend({ - logCompleted: Ember.on('completed', function() { - console.log('Job completed!'); - }) - }); - - let job = Job.create(); - - Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' - ``` - - @method on - @for Ember - @param {String} eventNames* - @param {Function} func - @return func - @public - */ - - function on() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var func = args.pop(); - var events = args; - func.__ember_listens__ = events; - return func; - } -}); -enifed('ember-metal/expand_properties', ['exports', 'ember-metal/debug'], function (exports, _emberMetalDebug) { - 'use strict'; - - exports.default = expandProperties; - - /** - @module ember - @submodule ember-metal - */ - - var SPLIT_REGEX = /\{|\}/; - var END_WITH_EACH_REGEX = /\.@each$/; - - /** - Expands `pattern`, invoking `callback` for each expansion. - - The only pattern supported is brace-expansion, anything else will be passed - once to `callback` directly. - - Example - - ```js - function echo(arg){ console.log(arg); } - - Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' - Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' - Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' - Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' - Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' - Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' - Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' - ``` - - @method expandProperties - @for Ember - @private - @param {String} pattern The property pattern to expand. - @param {Function} callback The callback to invoke. It is invoked once per - expansion, and is passed the expansion. - */ - - function expandProperties(pattern, callback) { - _emberMetalDebug.assert('A computed property key must be a string', typeof pattern === 'string'); - _emberMetalDebug.assert('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1); - _emberMetalDebug.assert('Brace expanded properties have to be balanced and cannot be nested, pattern: ' + pattern, (function (str) { - var inBrace = 0; - var char = undefined; - for (var i = 0; i < str.length; i++) { - char = str.charAt(i); - - if (char === '{') { - inBrace++; - } else if (char === '}') { - inBrace--; - } - - if (inBrace > 1 || inBrace < 0) { - return false; - } - } - - return true; - })(pattern)); - - var parts = pattern.split(SPLIT_REGEX); - var properties = [parts]; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part.indexOf(',') >= 0) { - properties = duplicateAndReplace(properties, part.split(','), i); - } - } - - for (var i = 0; i < properties.length; i++) { - callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); - } - } - - function duplicateAndReplace(properties, currentParts, index) { - var all = []; - - properties.forEach(function (property) { - currentParts.forEach(function (part) { - var current = property.slice(0); - current[index] = part; - all.push(current); - }); - }); - - return all; - } -}); -enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) { - 'use strict'; - - exports.default = isEnabled; - - /** - The hash of enabled Canary features. Add to this, any canary features - before creating your application. - - Alternatively (and recommended), you can also define `EmberENV.FEATURES` - if you need to enable features flagged at runtime. - - @class FEATURES - @namespace Ember - @static - @since 1.1.0 - @public - */ - var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES); - - exports.FEATURES = FEATURES; - /** - Determine whether the specified `feature` is enabled. Used by Ember's - build tools to exclude experimental features from beta/stable builds. - - You can define the following configuration options: - - * `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly - enabled/disabled. - - @method isEnabled - @param {String} feature The feature to check - @return {Boolean} - @for Ember.FEATURES - @since 1.1.0 - @public - */ - - function isEnabled(feature) { - var featureValue = FEATURES[feature]; - - if (featureValue === true || featureValue === false || featureValue === undefined) { - return featureValue; - } else if (_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES) { - return true; - } else { - return false; - } - } - - exports.DEFAULT_FEATURES = _emberFeatures.default; -}); -enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; - - exports.default = getProperties; - - /** - To get multiple properties at once, call `Ember.getProperties` - with an object followed by a list of strings or an array: - - ```javascript - Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - is equivalent to: - - ```javascript - Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - @method getProperties - @for Ember - @param {Object} obj - @param {String...|Array} list of keys to get - @return {Object} - @public - */ - - function getProperties(obj) { - var ret = {}; - var propertyNames = arguments; - var i = 1; - - if (arguments.length === 2 && Array.isArray(arguments[1])) { - i = 0; - propertyNames = arguments[1]; - } - for (; i < propertyNames.length; i++) { - ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]); - } - return ret; - } -}); -enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/is_proxy', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalIs_proxy, _emberMetalDescriptor) { - /** - @module ember - @submodule ember-metal - */ - - 'use strict'; - - exports.default = _emberMetalCore.default; - // reexports - exports.computed = _emberMetalComputed.default; - exports.cacheFor = _emberMetalComputed.cacheFor; - exports.ComputedProperty = _emberMetalComputed.ComputedProperty; - exports.alias = _emberMetalAlias.default; - exports.merge = _emberMetalMerge.default; - exports.assert = _emberMetalDebug.assert; - exports.info = _emberMetalDebug.info; - exports.warn = _emberMetalDebug.warn; - exports.debug = _emberMetalDebug.debug; - exports.deprecate = _emberMetalDebug.deprecate; - exports.deprecateFunc = _emberMetalDebug.deprecateFunc; - exports.runInDebug = _emberMetalDebug.runInDebug; - exports.setDebugFunction = _emberMetalDebug.setDebugFunction; - exports.getDebugFunction = _emberMetalDebug.getDebugFunction; - exports.debugSeal = _emberMetalDebug.debugSeal; - exports.debugFreeze = _emberMetalDebug.debugFreeze; - exports.instrument = _emberMetalInstrumentation.instrument; - exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument; - exports._instrumentStart = _emberMetalInstrumentation._instrumentStart; - exports.instrumentationReset = _emberMetalInstrumentation.reset; - exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe; - exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe; - exports.isTesting = _emberMetalTesting.isTesting; - exports.setTesting = _emberMetalTesting.setTesting; - exports.getOnerror = _emberMetalError_handler.getOnerror; - exports.setOnerror = _emberMetalError_handler.setOnerror; - exports.dispatchError = _emberMetalError_handler.dispatchError; - exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride; - exports.META_DESC = _emberMetalMeta.META_DESC; - exports.meta = _emberMetalMeta.meta; - exports.peekMeta = _emberMetalMeta.peekMeta; - exports.Error = _emberMetalError.default; - exports.Cache = _emberMetalCache.default; - exports.isFeatureEnabled = _emberMetalFeatures.default; - exports.FEATURES = _emberMetalFeatures.FEATURES; - exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES; - exports._getPath = _emberMetalProperty_get._getPath; - exports.get = _emberMetalProperty_get.get; - exports.getWithDefault = _emberMetalProperty_get.getWithDefault; - exports.set = _emberMetalProperty_set.set; - exports.trySet = _emberMetalProperty_set.trySet; - exports.WeakMap = _emberMetalWeak_map.default; - exports.accumulateListeners = _emberMetalEvents.accumulateListeners; - exports.addListener = _emberMetalEvents.addListener; - exports.hasListeners = _emberMetalEvents.hasListeners; - exports.listenersFor = _emberMetalEvents.listenersFor; - exports.on = _emberMetalEvents.on; - exports.removeListener = _emberMetalEvents.removeListener; - exports.sendEvent = _emberMetalEvents.sendEvent; - exports.suspendListener = _emberMetalEvents.suspendListener; - exports.suspendListeners = _emberMetalEvents.suspendListeners; - exports.watchedEvents = _emberMetalEvents.watchedEvents; - exports.isNone = _emberMetalIs_none.default; - exports.isEmpty = _emberMetalIs_empty.default; - exports.isBlank = _emberMetalIs_blank.default; - exports.isPresent = _emberMetalIs_present.default; - exports.run = _emberMetalRun_loop.default; - exports.ObserverSet = _emberMetalObserver_set.default; - exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges; - exports.changeProperties = _emberMetalProperty_events.changeProperties; - exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges; - exports.overrideChains = _emberMetalProperty_events.overrideChains; - exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; - exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; - exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; - exports.defineProperty = _emberMetalProperties.defineProperty; - exports.Descriptor = _emberMetalProperties.Descriptor; - exports.watchKey = _emberMetalWatch_key.watchKey; - exports.unwatchKey = _emberMetalWatch_key.unwatchKey; - exports.ChainNode = _emberMetalChains.ChainNode; - exports.finishChains = _emberMetalChains.finishChains; - exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; - exports.watchPath = _emberMetalWatch_path.watchPath; - exports.unwatchPath = _emberMetalWatch_path.unwatchPath; - exports.destroy = _emberMetalWatching.destroy; - exports.isWatching = _emberMetalWatching.isWatching; - exports.unwatch = _emberMetalWatching.unwatch; - exports.watch = _emberMetalWatching.watch; - exports.watcherCount = _emberMetalWatching.watcherCount; - exports.libraries = _emberMetalLibraries.default; - exports.Map = _emberMetalMap.Map; - exports.MapWithDefault = _emberMetalMap.MapWithDefault; - exports.OrderedSet = _emberMetalMap.OrderedSet; - exports.getProperties = _emberMetalGet_properties.default; - exports.setProperties = _emberMetalSet_properties.default; - exports.expandProperties = _emberMetalExpand_properties.default; - exports._suspendObserver = _emberMetalObserver._suspendObserver; - exports._suspendObservers = _emberMetalObserver._suspendObservers; - exports.addObserver = _emberMetalObserver.addObserver; - exports.observersFor = _emberMetalObserver.observersFor; - exports.removeObserver = _emberMetalObserver.removeObserver; - exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; - exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; - exports.Mixin = _emberMetalMixin.Mixin; - exports.aliasMethod = _emberMetalMixin.aliasMethod; - exports._immediateObserver = _emberMetalMixin._immediateObserver; - exports._beforeObserver = _emberMetalMixin._beforeObserver; - exports.mixin = _emberMetalMixin.mixin; - exports.observer = _emberMetalMixin.observer; - exports.required = _emberMetalMixin.required; - exports.REQUIRED = _emberMetalMixin.REQUIRED; - exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins; - exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins; - exports.detectBinding = _emberMetalMixin.detectBinding; - exports.Binding = _emberMetalBinding.Binding; - exports.bind = _emberMetalBinding.bind; - exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath; - exports.InjectedProperty = _emberMetalInjected_property.default; - exports.setHasViews = _emberMetalTags.setHasViews; - exports.tagForProperty = _emberMetalTags.tagForProperty; - exports.tagFor = _emberMetalTags.tagFor; - exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty; - exports.replace = _emberMetalReplace.default; - exports.runInTransaction = _emberMetalTransaction.default; - exports.didRender = _emberMetalTransaction.didRender; - exports.assertNotRendered = _emberMetalTransaction.assertNotRendered; - exports.isProxy = _emberMetalIs_proxy.isProxy; - exports.descriptor = _emberMetalDescriptor.default; - - // TODO: this needs to be deleted once we refactor the build tooling - // do this for side-effects of updating Ember.assert, warn, etc when - // ember-debug is present - // This needs to be called before any deprecateFunc - - if (_require.has('ember-debug')) { - _require.default('ember-debug'); - } -}); -enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) { - 'use strict'; - - exports.default = InjectedProperty; - - /** - Read-only property that returns the result of a container lookup. - - @class InjectedProperty - @namespace Ember - @constructor - @param {String} type The container type the property will lookup - @param {String} name (optional) The name the property will lookup, defaults - to the property's name - @private - */ - - function InjectedProperty(type, name) { - this.type = type; - this.name = name; - - this._super$Constructor(injectedPropertyGet); - AliasedPropertyPrototype.oneWay.call(this); - } - - function injectedPropertyGet(keyName) { - var desc = this[keyName]; - var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat - - _emberMetalDebug.assert('InjectedProperties should be defined with the Ember.inject computed property macros.', desc && desc.isDescriptor && desc.type); - _emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', owner); - - return owner.lookup(desc.type + ':' + (desc.name || keyName)); - } - - InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); - - var InjectedPropertyPrototype = InjectedProperty.prototype; - var ComputedPropertyPrototype = _emberMetalComputed.ComputedProperty.prototype; - var AliasedPropertyPrototype = _emberMetalAlias.AliasedProperty.prototype; - - InjectedPropertyPrototype._super$Constructor = _emberMetalComputed.ComputedProperty; - - InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; - InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; - InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; -}); -enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { - 'use strict'; - - exports.instrument = instrument; - exports._instrumentStart = _instrumentStart; - exports.subscribe = subscribe; - exports.unsubscribe = unsubscribe; - exports.reset = reset; - - /** - The purpose of the Ember Instrumentation module is - to provide efficient, general-purpose instrumentation - for Ember. - - Subscribe to a listener by using `Ember.subscribe`: - - ```javascript - Ember.subscribe("render", { - before(name, timestamp, payload) { - - }, - - after(name, timestamp, payload) { - - } - }); - ``` - - If you return a value from the `before` callback, that same - value will be passed as a fourth parameter to the `after` - callback. - - Instrument a block of code by using `Ember.instrument`: - - ```javascript - Ember.instrument("render.handlebars", payload, function() { - // rendering logic - }, binding); - ``` - - Event names passed to `Ember.instrument` are namespaced - by periods, from more general to more specific. Subscribers - can listen for events by whatever level of granularity they - are interested in. - - In the above example, the event is `render.handlebars`, - and the subscriber listened for all events beginning with - `render`. It would receive callbacks for events named - `render`, `render.handlebars`, `render.container`, or - even `render.handlebars.layout`. - - @class Instrumentation - @namespace Ember - @static - @private - */ - var subscribers = []; - exports.subscribers = subscribers; - var cache = {}; - - function populateListeners(name) { - var listeners = []; - var subscriber = undefined; - - for (var i = 0; i < subscribers.length; i++) { - subscriber = subscribers[i]; - if (subscriber.regex.test(name)) { - listeners.push(subscriber.object); - } - } - - cache[name] = listeners; - return listeners; - } - - var time = (function () { - var perf = 'undefined' !== typeof window ? window.performance || {} : {}; - var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; - // fn.bind will be available in all the browsers that support the advanced window.performance... ;-) - return fn ? fn.bind(perf) : function () { - return +new Date(); - }; - })(); - - /** - Notifies event's subscribers, calls `before` and `after` hooks. - - @method instrument - @namespace Ember.Instrumentation - - @param {String} [name] Namespaced event name. - @param {Object} _payload - @param {Function} callback Function that you're instrumenting. - @param {Object} binding Context that instrument function is called with. - @private - */ - - function instrument(name, _payload, callback, binding) { - if (arguments.length <= 3 && typeof _payload === 'function') { - binding = callback; - callback = _payload; - _payload = undefined; - } - if (subscribers.length === 0) { - return callback.call(binding); - } - var payload = _payload || {}; - var finalizer = _instrumentStart(name, function () { - return payload; - }); - - if (finalizer) { - return withFinalizer(callback, finalizer, payload, binding); - } else { - return callback.call(binding); - } - } - - var flaggedInstrument = undefined; - if (false) { - exports.flaggedInstrument = flaggedInstrument = instrument; - } else { - exports.flaggedInstrument = flaggedInstrument = function (name, payload, callback) { - return callback(); - }; - } - exports.flaggedInstrument = flaggedInstrument; - - function withFinalizer(callback, finalizer, payload, binding) { - var result = undefined; - try { - result = callback.call(binding); - } catch (e) { - payload.exception = e; - result = payload; - } finally { - finalizer(); - return result; - } - } - - function NOOP() {} - - // private for now - - function _instrumentStart(name, _payload, _payloadParam) { - if (subscribers.length === 0) { - return NOOP; - } - - var listeners = cache[name]; - - if (!listeners) { - listeners = populateListeners(name); - } - - if (listeners.length === 0) { - return NOOP; - } - - var payload = _payload(_payloadParam); - - var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE; - var timeName = undefined; - if (STRUCTURED_PROFILE) { - timeName = name + ': ' + payload.object; - console.time(timeName); - } - - var beforeValues = new Array(listeners.length); - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - beforeValues[i] = listener.before(name, timestamp, payload); - } - - return function _instrumentEnd() { - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - if (typeof listener.after === 'function') { - listener.after(name, timestamp, payload, beforeValues[i]); - } - } - - if (STRUCTURED_PROFILE) { - console.timeEnd(timeName); - } - }; - } - - /** - Subscribes to a particular event or instrumented block of code. - - @method subscribe - @namespace Ember.Instrumentation - - @param {String} [pattern] Namespaced event name. - @param {Object} [object] Before and After hooks. - - @return {Subscriber} - @private - */ - - function subscribe(pattern, object) { - var paths = pattern.split('.'); - var path = undefined; - var regex = []; - - for (var i = 0; i < paths.length; i++) { - path = paths[i]; - if (path === '*') { - regex.push('[^\\.]*'); - } else { - regex.push(path); - } - } - - regex = regex.join('\\.'); - regex = regex + '(\\..*)?'; - - var subscriber = { - pattern: pattern, - regex: new RegExp('^' + regex + '$'), - object: object - }; - - subscribers.push(subscriber); - cache = {}; - - return subscriber; - } - - /** - Unsubscribes from a particular event or instrumented block of code. - - @method unsubscribe - @namespace Ember.Instrumentation - - @param {Object} [subscriber] - @private - */ - - function unsubscribe(subscriber) { - var index = undefined; - - for (var i = 0; i < subscribers.length; i++) { - if (subscribers[i] === subscriber) { - index = i; - } - } - - subscribers.splice(index, 1); - cache = {}; - } - - /** - Resets `Ember.Instrumentation` by flushing list of subscribers. - - @method reset - @namespace Ember.Instrumentation - @private - */ - - function reset() { - subscribers.length = 0; - cache = {}; - } -}); -enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, _emberMetalIs_empty) { - 'use strict'; - - exports.default = isBlank; - - /** - A value is blank if it is empty or a whitespace string. - - ```javascript - Ember.isBlank(); // true - Ember.isBlank(null); // true - Ember.isBlank(undefined); // true - Ember.isBlank(''); // true - Ember.isBlank([]); // true - Ember.isBlank('\n\t'); // true - Ember.isBlank(' '); // true - Ember.isBlank({}); // false - Ember.isBlank('\n\t Hello'); // false - Ember.isBlank('Hello world'); // false - Ember.isBlank([1,2,3]); // false - ``` - - @method isBlank - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.5.0 - @public - */ - - function isBlank(obj) { - return _emberMetalIs_empty.default(obj) || typeof obj === 'string' && obj.match(/\S/) === null; - } -}); -enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, _emberMetalProperty_get, _emberMetalIs_none) { - 'use strict'; - - exports.default = isEmpty; - - /** - Verifies that a value is `null` or an empty string, empty array, - or empty function. - - Constrains the rules on `Ember.isNone` by returning true for empty - string and empty arrays. - - ```javascript - Ember.isEmpty(); // true - Ember.isEmpty(null); // true - Ember.isEmpty(undefined); // true - Ember.isEmpty(''); // true - Ember.isEmpty([]); // true - Ember.isEmpty({}); // false - Ember.isEmpty('Adam Hawkins'); // false - Ember.isEmpty([0,1,2]); // false - Ember.isEmpty('\n\t'); // false - Ember.isEmpty(' '); // false - ``` - - @method isEmpty - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ - - function isEmpty(obj) { - var none = _emberMetalIs_none.default(obj); - if (none) { - return none; - } - - if (typeof obj.size === 'number') { - return !obj.size; - } - - var objectType = typeof obj; - - if (objectType === 'object') { - var size = _emberMetalProperty_get.get(obj, 'size'); - if (typeof size === 'number') { - return !size; - } - } - - if (typeof obj.length === 'number' && objectType !== 'function') { - return !obj.length; - } - - if (objectType === 'object') { - var _length = _emberMetalProperty_get.get(obj, 'length'); - if (typeof _length === 'number') { - return !_length; - } - } - - return false; - } -}); -enifed("ember-metal/is_none", ["exports"], function (exports) { - /** - Returns true if the passed value is null or undefined. This avoids errors - from JSLint complaining about use of ==, which can be technically - confusing. - - ```javascript - Ember.isNone(); // true - Ember.isNone(null); // true - Ember.isNone(undefined); // true - Ember.isNone(''); // false - Ember.isNone([]); // false - Ember.isNone(function() {}); // false - ``` - - @method isNone - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ - "use strict"; - - exports.default = isNone; - - function isNone(obj) { - return obj === null || obj === undefined; - } -}); -enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { - 'use strict'; - - exports.default = isPresent; - - /** - A value is present if it not `isBlank`. - - ```javascript - Ember.isPresent(); // false - Ember.isPresent(null); // false - Ember.isPresent(undefined); // false - Ember.isPresent(''); // false - Ember.isPresent(' '); // false - Ember.isPresent('\n\t'); // false - Ember.isPresent([]); // false - Ember.isPresent({ length: 0 }) // false - Ember.isPresent(false); // true - Ember.isPresent(true); // true - Ember.isPresent('string'); // true - Ember.isPresent(0); // true - Ember.isPresent(function() {}) // true - Ember.isPresent({}); // true - Ember.isPresent(false); // true - Ember.isPresent('\n\t Hello'); // true - Ember.isPresent([1,2,3]); // true - ``` - - @method isPresent - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.8.0 - @public - */ - - function isPresent(obj) { - return !_emberMetalIs_blank.default(obj); - } -}); -enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { - 'use strict'; - - exports.isProxy = isProxy; - - function isProxy(value) { - if (typeof value === 'object' && value) { - var meta = _emberMetalMeta.peekMeta(value); - return meta && meta.isProxy(); - } - - return false; - } -}); -enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; - - exports.Libraries = Libraries; - - /** - Helper class that allows you to register your library with Ember. - - Singleton created at `Ember.libraries`. - - @class Libraries - @constructor - @private - */ - - function Libraries() { - this._registry = []; - this._coreLibIndex = 0; - } - - Libraries.prototype = { - constructor: Libraries, - - _getLibraryByName: function (name) { - var libs = this._registry; - var count = libs.length; - - for (var i = 0; i < count; i++) { - if (libs[i].name === name) { - return libs[i]; - } - } - }, - - register: function (name, version, isCoreLibrary) { - var index = this._registry.length; - - if (!this._getLibraryByName(name)) { - if (isCoreLibrary) { - index = this._coreLibIndex++; - } - this._registry.splice(index, 0, { name: name, version: version }); - } else { - _emberMetalDebug.warn('Library "' + name + '" is already registered with Ember.', false, { id: 'ember-metal.libraries-register' }); - } - }, - - registerCoreLibrary: function (name, version) { - this.register(name, version, true); - }, - - deRegister: function (name) { - var lib = this._getLibraryByName(name); - var index = undefined; - - if (lib) { - index = this._registry.indexOf(lib); - this._registry.splice(index, 1); - } - } - }; - - if (false) { - Libraries.prototype.isRegistered = function (name) { - return !!this._getLibraryByName(name); - }; - } - - exports.default = new Libraries(); -}); -enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) { - /** - @module ember - @submodule ember-metal - */ - - /* - JavaScript (before ES6) does not have a Map implementation. Objects, - which are often used as dictionaries, may only have Strings as keys. - - Because Ember has a way to get a unique identifier for every object - via `Ember.guidFor`, we can implement a performant Map with arbitrary - keys. Because it is commonly used in low-level bookkeeping, Map is - implemented as a pure JavaScript object for performance. - - This implementation follows the current iteration of the ES6 proposal for - maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets), - with one exception: as we do not have the luxury of in-VM iteration, we implement a - forEach method for iteration. - - Map is mocked out to look like an Ember object, so you can do - `Ember.Map.create()` for symmetry with other Ember classes. - */ - 'use strict'; - - function missingFunction(fn) { - throw new TypeError(Object.prototype.toString.call(fn) + ' is not a function'); - } - - function missingNew(name) { - throw new TypeError('Constructor ' + name + ' requires \'new\''); - } - - function copyNull(obj) { - var output = new _emberUtils.EmptyObject(); - - for (var prop in obj) { - // hasOwnPropery is not needed because obj is new EmptyObject(); - output[prop] = obj[prop]; - } - - return output; - } - - function copyMap(original, newObject) { - var keys = original._keys.copy(); - var values = copyNull(original._values); - - newObject._keys = keys; - newObject._values = values; - newObject.size = original.size; - - return newObject; - } - - /** - This class is used internally by Ember and Ember Data. - Please do not use it at this time. We plan to clean it up - and add many tests soon. - - @class OrderedSet - @namespace Ember - @constructor - @private - */ - function OrderedSet() { - if (this instanceof OrderedSet) { - this.clear(); - this._silenceRemoveDeprecation = false; - } else { - missingNew('OrderedSet'); - } - } - - /** - @method create - @static - @return {Ember.OrderedSet} - @private - */ - OrderedSet.create = function () { - var Constructor = this; - - return new Constructor(); - }; - - OrderedSet.prototype = { - constructor: OrderedSet, - /** - @method clear - @private - */ - clear: function () { - this.presenceSet = new _emberUtils.EmptyObject(); - this.list = []; - this.size = 0; - }, - - /** - @method add - @param obj - @param guid (optional, and for internal use) - @return {Ember.OrderedSet} - @private - */ - add: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; - - if (presenceSet[guid] !== true) { - presenceSet[guid] = true; - this.size = list.push(obj); - } - - return this; - }, - - /** - @since 1.8.0 - @method delete - @param obj - @param _guid (optional and for internal use only) - @return {Boolean} - @private - */ - delete: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; - - if (presenceSet[guid] === true) { - delete presenceSet[guid]; - var index = list.indexOf(obj); - if (index > -1) { - list.splice(index, 1); - } - this.size = list.length; - return true; - } else { - return false; - } - }, - - /** - @method isEmpty - @return {Boolean} - @private - */ - isEmpty: function () { - return this.size === 0; - }, - - /** - @method has - @param obj - @return {Boolean} - @private - */ - has: function (obj) { - if (this.size === 0) { - return false; - } - - var guid = _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - - return presenceSet[guid] === true; - }, - - /** - @method forEach - @param {Function} fn - @param self - @private - */ - forEach: function (fn /*, ...thisArg*/) { - if (typeof fn !== 'function') { - missingFunction(fn); - } - - if (this.size === 0) { - return; - } - - var list = this.list; - - if (arguments.length === 2) { - for (var i = 0; i < list.length; i++) { - fn.call(arguments[1], list[i]); - } - } else { - for (var i = 0; i < list.length; i++) { - fn(list[i]); - } - } - }, - - /** - @method toArray - @return {Array} - @private - */ - toArray: function () { - return this.list.slice(); - }, - - /** - @method copy - @return {Ember.OrderedSet} - @private - */ - copy: function () { - var Constructor = this.constructor; - var set = new Constructor(); - - set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; - set.presenceSet = copyNull(this.presenceSet); - set.list = this.toArray(); - set.size = this.size; - - return set; - } - }; - - /** - A Map stores values indexed by keys. Unlike JavaScript's - default Objects, the keys of a Map can be any JavaScript - object. - - Internally, a Map has two data structures: - - 1. `keys`: an OrderedSet of all of the existing keys - 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)` - - When a key/value pair is added for the first time, we - add the key to the `keys` OrderedSet, and create or - replace an entry in `values`. When an entry is deleted, - we delete its entry in `keys` and `values`. - - @class Map - @namespace Ember - @private - @constructor - */ - function Map() { - if (this instanceof Map) { - this._keys = OrderedSet.create(); - this._keys._silenceRemoveDeprecation = true; - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - } else { - missingNew('Map'); - } - } - - /** - @method create - @static - @private - */ - Map.create = function () { - var Constructor = this; - return new Constructor(); - }; - - Map.prototype = { - constructor: Map, - - /** - This property will change as the number of objects in the map changes. - @since 1.8.0 - @property size - @type number - @default 0 - @private - */ - size: 0, - - /** - Retrieve the value associated with a given key. - @method get - @param {*} key - @return {*} the value associated with the key, or `undefined` - @private - */ - get: function (key) { - if (this.size === 0) { - return; - } - - var values = this._values; - var guid = _emberUtils.guidFor(key); - - return values[guid]; - }, - - /** - Adds a value to the map. If a value for the given key has already been - provided, the new value will replace the old value. - @method set - @param {*} key - @param {*} value - @return {Ember.Map} - @private - */ - set: function (key, value) { - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); - - // ensure we don't store -0 - var k = key === -0 ? 0 : key; - - keys.add(k, guid); - - values[guid] = value; - - this.size = keys.size; - - return this; - }, - - /** - Removes a value from the map for an associated key. - @since 1.8.0 - @method delete - @param {*} key - @return {Boolean} true if an item was removed, false otherwise - @private - */ - delete: function (key) { - if (this.size === 0) { - return false; - } - // don't use ES6 "delete" because it will be annoying - // to use in browsers that are not ES6 friendly; - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); - - if (keys.delete(key, guid)) { - delete values[guid]; - this.size = keys.size; - return true; - } else { - return false; - } - }, - - /** - Check whether a key is present. - @method has - @param {*} key - @return {Boolean} true if the item was present, false otherwise - @private - */ - has: function (key) { - return this._keys.has(key); - }, - - /** - Iterate over all the keys and values. Calls the function once - for each key, passing in value, key, and the map being iterated over, - in that order. - The keys are guaranteed to be iterated over in insertion order. - @method forEach - @param {Function} callback - @param {*} self if passed, the `this` value inside the - callback. By default, `this` is the map. - @private - */ - forEach: function (callback /*, ...thisArg*/) { - if (typeof callback !== 'function') { - missingFunction(callback); - } - - if (this.size === 0) { - return; - } - - var map = this; - var cb = undefined, - thisArg = undefined; - - if (arguments.length === 2) { - thisArg = arguments[1]; - cb = function (key) { - return callback.call(thisArg, map.get(key), key, map); - }; - } else { - cb = function (key) { - return callback(map.get(key), key, map); - }; - } - - this._keys.forEach(cb); - }, - - /** - @method clear - @private - */ - clear: function () { - this._keys.clear(); - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - }, - - /** - @method copy - @return {Ember.Map} - @private - */ - copy: function () { - return copyMap(this, new Map()); - } - }; - - /** - @class MapWithDefault - @namespace Ember - @extends Ember.Map - @private - @constructor - @param [options] - @param {*} [options.defaultValue] - */ - function MapWithDefault(options) { - this._super$constructor(); - this.defaultValue = options.defaultValue; - } - - /** - @method create - @static - @param [options] - @param {*} [options.defaultValue] - @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns - `Ember.MapWithDefault` otherwise returns `Ember.Map` - @private - */ - MapWithDefault.create = function (options) { - if (options) { - return new MapWithDefault(options); - } else { - return new Map(); - } - }; - - MapWithDefault.prototype = Object.create(Map.prototype); - MapWithDefault.prototype.constructor = MapWithDefault; - MapWithDefault.prototype._super$constructor = Map; - MapWithDefault.prototype._super$get = Map.prototype.get; - - /** - Retrieve the value associated with a given key. - - @method get - @param {*} key - @return {*} the value associated with the key, or the default value - @private - */ - MapWithDefault.prototype.get = function (key) { - var hasValue = this.has(key); - - if (hasValue) { - return this._super$get(key); - } else { - var defaultValue = this.defaultValue(key); - this.set(key, defaultValue); - return defaultValue; - } - }; - - /** - @method copy - @return {Ember.MapWithDefault} - @private - */ - MapWithDefault.prototype.copy = function () { - var Constructor = this.constructor; - return copyMap(this, new Constructor({ - defaultValue: this.defaultValue - })); - }; - - exports.default = Map; - exports.OrderedSet = OrderedSet; - exports.Map = Map; - exports.MapWithDefault = MapWithDefault; -}); -enifed('ember-metal/merge', ['exports'], function (exports) { - /** - Merge the contents of two objects together into the first object. - - ```javascript - Ember.merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' } - var a = { first: 'Yehuda' }; - var b = { last: 'Katz' }; - Ember.merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' } - ``` - - @method merge - @for Ember - @param {Object} original The object to merge into - @param {Object} updates The object to copy properties from - @return {Object} - @public - */ - 'use strict'; - - exports.default = merge; - - function merge(original, updates) { - if (!updates || typeof updates !== 'object') { - return original; - } - - var props = Object.keys(updates); - var prop = undefined; - - for (var i = 0; i < props.length; i++) { - prop = props[i]; - original[prop] = updates[prop]; - } - - return original; - } -}); -enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - exports.Meta = Meta; - exports.deleteMeta = deleteMeta; - exports.meta = meta; - - var counters = { - peekCalls: 0, - peekParentCalls: 0, - peekPrototypeWalks: 0, - setCalls: 0, - deleteCalls: 0, - metaCalls: 0, - metaInstantiated: 0 - }; - - /** - @module ember-metal - */ - - /* - This declares several meta-programmed members on the Meta class. Such - meta! - - In general, the `readable` variants will give you an object (if it - already exists) that you can read but should not modify. The - `writable` variants will give you a mutable object, and they will - create it if it didn't already exist. - - The following methods will get generated metaprogrammatically, and - I'm including them here for greppability: - - writableCache, readableCache, writeWatching, - peekWatching, clearWatching, writeMixins, - peekMixins, clearMixins, writeBindings, - peekBindings, clearBindings, writeValues, - peekValues, clearValues, writeDeps, forEachInDeps - writableChainWatchers, readableChainWatchers, writableChains, - readableChains, writableTag, readableTag, writableTags, - readableTags - */ - var members = { - cache: ownMap, - weak: ownMap, - watching: inheritedMap, - mixins: inheritedMap, - bindings: inheritedMap, - values: inheritedMap, - chainWatchers: ownCustomObject, - chains: inheritedCustomObject, - tag: ownCustomObject, - tags: ownMap - }; - - // FLAGS - var SOURCE_DESTROYING = 1 << 1; - var SOURCE_DESTROYED = 1 << 2; - var META_DESTROYED = 1 << 3; - var IS_PROXY = 1 << 4; - - if (true || false) { - members.lastRendered = ownMap; - members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds - } - - var memberNames = Object.keys(members); - var META_FIELD = '__ember_meta__'; - - function Meta(obj, parentMeta) { - _emberMetalDebug.runInDebug(function () { - return counters.metaInstantiated++; - }); - - this._cache = undefined; - this._weak = undefined; - this._watching = undefined; - this._mixins = undefined; - this._bindings = undefined; - this._values = undefined; - this._deps = undefined; - this._chainWatchers = undefined; - this._chains = undefined; - this._tag = undefined; - this._tags = undefined; - - // initial value for all flags right now is false - // see FLAGS const for detailed list of flags used - this._flags = 0; - - // used only internally - this.source = obj; - - // when meta(obj).proto === obj, the object is intended to be only a - // prototype and doesn't need to actually be observable itself - this.proto = undefined; - - // The next meta in our inheritance chain. We (will) track this - // explicitly instead of using prototypical inheritance because we - // have detailed knowledge of how each property should really be - // inherited, and we can optimize it much better than JS runtimes. - this.parent = parentMeta; - - if (true || false) { - this._lastRendered = undefined; - this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds - } - - this._initializeListeners(); - } - - Meta.prototype.isInitialized = function (obj) { - return this.proto !== obj; - }; - - var NODE_STACK = []; - - Meta.prototype.destroy = function () { - if (this.isMetaDestroyed()) { - return; - } - - // remove chainWatchers to remove circular references that would prevent GC - var node = undefined, - nodes = undefined, - key = undefined, - nodeObject = undefined; - node = this.readableChains(); - if (node) { - NODE_STACK.push(node); - // process tree - while (NODE_STACK.length > 0) { - node = NODE_STACK.pop(); - // push children - nodes = node._chains; - if (nodes) { - for (key in nodes) { - if (nodes[key] !== undefined) { - NODE_STACK.push(nodes[key]); - } - } - } - - // remove chainWatcher in node object - if (node._watching) { - nodeObject = node._object; - if (nodeObject) { - var foreignMeta = peekMeta(nodeObject); - // avoid cleaning up chain watchers when both current and - // foreign objects are being destroyed - // if both are being destroyed manual cleanup is not needed - // as they will be GC'ed and no non-destroyed references will - // be remaining - if (foreignMeta && !foreignMeta.isSourceDestroying()) { - _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); - } - } - } - } - } - - this.setMetaDestroyed(); - }; - - for (var _name in _emberMetalMeta_listeners.protoMethods) { - Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; - } - memberNames.forEach(function (name) { - return members[name](name, Meta); - }); - - Meta.prototype.isSourceDestroying = function isSourceDestroying() { - return (this._flags & SOURCE_DESTROYING) !== 0; - }; - - Meta.prototype.setSourceDestroying = function setSourceDestroying() { - this._flags |= SOURCE_DESTROYING; - }; - - Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { - return (this._flags & SOURCE_DESTROYED) !== 0; - }; - - Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { - this._flags |= SOURCE_DESTROYED; - }; - - Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { - return (this._flags & META_DESTROYED) !== 0; - }; - - Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { - this._flags |= META_DESTROYED; - }; - - Meta.prototype.isProxy = function isProxy() { - return (this._flags & IS_PROXY) !== 0; - }; - - Meta.prototype.setProxy = function setProxy() { - this._flags |= IS_PROXY; - }; - - // Implements a member that is a lazily created, non-inheritable - // POJO. - function ownMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function () { - return this._getOrCreateOwnMap(key); - }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; - }; - } - - Meta.prototype._getOrCreateOwnMap = function (key) { - var ret = this[key]; - if (!ret) { - ret = this[key] = new _emberUtils.EmptyObject(); - } - return ret; - }; - - // Implements a member that is a lazily created POJO with inheritable - // values. - function inheritedMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - - Meta.prototype['write' + capitalized] = function (subkey, value) { - _emberMetalDebug.assert('Cannot call write' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var map = this._getOrCreateOwnMap(key); - map[subkey] = value; - }; - - Meta.prototype['peek' + capitalized] = function (subkey) { - return this._findInherited(key, subkey); - }; - - Meta.prototype['forEach' + capitalized] = function (fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - for (var _key in map) { - if (!seen[_key]) { - seen[_key] = true; - fn(_key, map[_key]); - } - } - } - pointer = pointer.parent; - } - }; - - Meta.prototype['clear' + capitalized] = function () { - _emberMetalDebug.assert('Cannot call clear' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - this[key] = undefined; - }; - - Meta.prototype['deleteFrom' + capitalized] = function (subkey) { - delete this._getOrCreateOwnMap(key)[subkey]; - }; - - Meta.prototype['hasIn' + capitalized] = function (subkey) { - return this._findInherited(key, subkey) !== undefined; - }; - } - - Meta.prototype._getInherited = function (key) { - var pointer = this; - while (pointer !== undefined) { - if (pointer[key]) { - return pointer[key]; - } - pointer = pointer.parent; - } - }; - - Meta.prototype._findInherited = function (key, subkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var value = map[subkey]; - if (value !== undefined) { - return value; - } - } - pointer = pointer.parent; - } - }; - - var UNDEFINED = _emberUtils.symbol('undefined'); - - exports.UNDEFINED = UNDEFINED; - // Implements a member that provides a lazily created map of maps, - // with inheritance at both levels. - Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { - _emberMetalDebug.assert('Cannot call writeDeps after the object is destroyed.', !this.isMetaDestroyed()); - - var outerMap = this._getOrCreateOwnMap('_deps'); - var innerMap = outerMap[subkey]; - if (!innerMap) { - innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); - } - innerMap[itemkey] = value; - }; - - Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer._deps; - if (map) { - var value = map[subkey]; - if (value) { - if (value[itemkey] !== undefined) { - return value[itemkey]; - } - } - } - pointer = pointer.parent; - } - }; - - Meta.prototype.hasDeps = function hasDeps(subkey) { - var pointer = this; - while (pointer !== undefined) { - if (pointer._deps && pointer._deps[subkey]) { - return true; - } - pointer = pointer.parent; - } - return false; - }; - - Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { - return this._forEachIn('_deps', subkey, fn); - }; - - Meta.prototype._forEachIn = function (key, subkey, fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - var calls = []; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var innerMap = map[subkey]; - if (innerMap) { - for (var innerKey in innerMap) { - if (!seen[innerKey]) { - seen[innerKey] = true; - calls.push([innerKey, innerMap[innerKey]]); - } - } - } - } - pointer = pointer.parent; - } - for (var i = 0; i < calls.length; i++) { - var _calls$i = calls[i]; - var innerKey = _calls$i[0]; - var value = _calls$i[1]; - - fn(innerKey, value); - } - }; - - // Implements a member that provides a non-heritable, lazily-created - // object using the method you provide. - function ownCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { - _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var ret = this[key]; - if (!ret) { - ret = this[key] = create(this.source); - } - return ret; - }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; - }; - } - - // Implements a member that provides an inheritable, lazily-created - // object using the method you provide. We will derived children from - // their parents by calling your object's `copy()` method. - function inheritedCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { - _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var ret = this[key]; - if (!ret) { - if (this.parent) { - ret = this[key] = this.parent['writable' + capitalized](create).copy(this.source); - } else { - ret = this[key] = create(this.source); - } - } - return ret; - }; - Meta.prototype['readable' + capitalized] = function () { - return this._getInherited(key); - }; - } - - function memberProperty(name) { - return '_' + name; - } - - // there's a more general-purpose capitalize in ember-runtime, but we - // don't want to make ember-metal depend on ember-runtime. - function capitalize(name) { - return name.replace(/^\w/, function (m) { - return m.toUpperCase(); - }); - } - - var META_DESC = { - writable: true, - configurable: true, - enumerable: false, - value: null - }; - - exports.META_DESC = META_DESC; - var EMBER_META_PROPERTY = { - name: META_FIELD, - descriptor: META_DESC - }; - - if (true) { - Meta.prototype.readInheritedValue = function (key, subkey) { - var internalKey = '_' + key; - - var pointer = this; - - while (pointer !== undefined) { - var map = pointer[internalKey]; - if (map) { - var value = map[subkey]; - if (value !== undefined || subkey in map) { - return map[subkey]; - } - } - pointer = pointer.parent; - } - - return UNDEFINED; - }; - - Meta.prototype.writeValue = function (obj, key, value) { - var descriptor = _emberUtils.lookupDescriptor(obj, key); - var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - - if (isMandatorySetter) { - this.writeValues(key, value); - } else { - obj[key] = value; - } - }; - } - - var HAS_NATIVE_WEAKMAP = (function () { - // detect if `WeakMap` is even present - var hasWeakMap = typeof WeakMap === 'function'; - if (!hasWeakMap) { - return false; - } - - var instance = new WeakMap(); - // use `Object`'s `.toString` directly to prevent us from detecting - // polyfills as native weakmaps - return Object.prototype.toString.call(instance) === '[object WeakMap]'; - })(); - - var setMeta = undefined, - peekMeta = undefined; - - // choose the one appropriate for given platform - if (HAS_NATIVE_WEAKMAP) { - (function () { - var getPrototypeOf = Object.getPrototypeOf; - var metaStore = new WeakMap(); - - exports.setMeta = setMeta = function WeakMap_setMeta(obj, meta) { - _emberMetalDebug.runInDebug(function () { - return counters.setCalls++; - }); - metaStore.set(obj, meta); - }; - - exports.peekMeta = peekMeta = function WeakMap_peekMeta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.peekCalls++; - }); - - return metaStore.get(obj); - }; - - exports.peekMeta = peekMeta = function WeakMap_peekParentMeta(obj) { - var pointer = obj; - var meta = undefined; - while (pointer) { - meta = metaStore.get(pointer); - // jshint loopfunc:true - _emberMetalDebug.runInDebug(function () { - return counters.peekCalls++; - }); - // stop if we find a `null` value, since - // that means the meta was deleted - // any other truthy value is a "real" meta - if (meta === null || meta) { - return meta; - } - - pointer = getPrototypeOf(pointer); - _emberMetalDebug.runInDebug(function () { - return counters.peakPrototypeWalks++; - }); - } - }; - })(); - } else { - exports.setMeta = setMeta = function Fallback_setMeta(obj, meta) { - // if `null` already, just set it to the new value - // otherwise define property first - if (obj[META_FIELD] !== null) { - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(EMBER_META_PROPERTY); - } else { - Object.defineProperty(obj, META_FIELD, META_DESC); - } - } - - obj[META_FIELD] = meta; - }; - - exports.peekMeta = peekMeta = function Fallback_peekMeta(obj) { - return obj[META_FIELD]; - }; - } - - function deleteMeta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.deleteCalls++; - }); - - var meta = peekMeta(obj); - if (meta) { - meta.destroy(); - } - } - - /** - Retrieves the meta hash for an object. If `writable` is true ensures the - hash is writable for this object as well. - - The meta object contains information about computed property descriptors as - well as any watched properties and other information. You generally will - not access this information directly but instead work with higher level - methods that manipulate this hash indirectly. - - @method meta - @for Ember - @private - - @param {Object} obj The object to retrieve meta for - @param {Boolean} [writable=true] Pass `false` if you do not intend to modify - the meta hash, allowing the method to avoid making an unnecessary copy. - @return {Object} the meta hash for an object - */ - - function meta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.metaCalls++; - }); - - var maybeMeta = peekMeta(obj); - var parent = undefined; - - // remove this code, in-favor of explicit parent - if (maybeMeta) { - if (maybeMeta.source === obj) { - return maybeMeta; - } - parent = maybeMeta; - } - - var newMeta = new Meta(obj, parent); - setMeta(obj, newMeta); - return newMeta; - } - - exports.peekMeta = peekMeta; - exports.setMeta = setMeta; - exports.counters = counters; -}); -enifed('ember-metal/meta_listeners', ['exports'], function (exports) { - /* - When we render a rich template hierarchy, the set of events that - *might* happen tends to be much larger than the set of events that - actually happen. This implies that we should make listener creation & - destruction cheap, even at the cost of making event dispatch more - expensive. - - Thus we store a new listener with a single push and no new - allocations, without even bothering to do deduplication -- we can - save that for dispatch time, if an event actually happens. - */ - - /* listener flags */ - 'use strict'; - - var ONCE = 1; - exports.ONCE = ONCE; - var SUSPENDED = 2; - - exports.SUSPENDED = SUSPENDED; - var protoMethods = { - - addToListeners: function (eventName, target, method, flags) { - if (!this._listeners) { - this._listeners = []; - } - this._listeners.push(eventName, target, method, flags); - }, - - _finalizeListeners: function () { - if (this._listenersFinalized) { - return; - } - if (!this._listeners) { - this._listeners = []; - } - var pointer = this.parent; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - this._listeners = this._listeners.concat(listeners); - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - this._listenersFinalized = true; - }, - - removeFromListeners: function (eventName, target, method, didRemove) { - var pointer = this; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = listeners.length - 4; index >= 0; index -= 4) { - if (listeners[index] === eventName && (!method || listeners[index + 1] === target && listeners[index + 2] === method)) { - if (pointer === this) { - // we are modifying our own list, so we edit directly - if (typeof didRemove === 'function') { - didRemove(eventName, target, listeners[index + 2]); - } - listeners.splice(index, 4); - } else { - // we are trying to remove an inherited listener, so we do - // just-in-time copying to detach our own listeners from - // our inheritance chain. - this._finalizeListeners(); - return this.removeFromListeners(eventName, target, method); - } - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - }, - - matchingListeners: function (eventName) { - var pointer = this; - var result = []; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - if (listeners[index] === eventName) { - pushUniqueListener(result, listeners, index); - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - var sus = this._suspendedListeners; - if (sus) { - for (var susIndex = 0; susIndex < sus.length - 2; susIndex += 3) { - if (eventName === sus[susIndex]) { - for (var resultIndex = 0; resultIndex < result.length - 2; resultIndex += 3) { - if (result[resultIndex] === sus[susIndex + 1] && result[resultIndex + 1] === sus[susIndex + 2]) { - result[resultIndex + 2] |= SUSPENDED; - } - } - } - } - } - return result; - }, - - suspendListeners: function (eventNames, target, method, callback) { - var sus = this._suspendedListeners; - if (!sus) { - sus = this._suspendedListeners = []; - } - for (var i = 0; i < eventNames.length; i++) { - sus.push(eventNames[i], target, method); - } - try { - return callback.call(target); - } finally { - if (sus.length === eventNames.length) { - this._suspendedListeners = undefined; - } else { - for (var i = sus.length - 3; i >= 0; i -= 3) { - if (sus[i + 1] === target && sus[i + 2] === method && eventNames.indexOf(sus[i]) !== -1) { - sus.splice(i, 3); - } - } - } - } - }, - - watchedEvents: function () { - var pointer = this; - var names = {}; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - names[listeners[index]] = true; - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - return Object.keys(names); - }, - - _initializeListeners: function () { - this._listeners = undefined; - this._listenersFinalized = undefined; - this._suspendedListeners = undefined; - } - }; - - exports.protoMethods = protoMethods; - function pushUniqueListener(destination, source, index) { - var target = source[index + 1]; - var method = source[index + 2]; - for (var destinationIndex = 0; destinationIndex < destination.length - 2; destinationIndex += 3) { - if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { - return; - } - } - destination.push(target, method, source[index + 3]); - } -}); -enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-metal - */ - exports.detectBinding = detectBinding; - exports.mixin = mixin; - exports.default = Mixin; - exports.hasUnprocessedMixins = hasUnprocessedMixins; - exports.clearUnprocessedMixins = clearUnprocessedMixins; - exports.required = required; - exports.aliasMethod = aliasMethod; - exports.observer = observer; - exports._immediateObserver = _immediateObserver; - exports._beforeObserver = _beforeObserver; - - function ROOT() {} - ROOT.__hasSuper = false; - - var a_slice = [].slice; - - function isMethod(obj) { - return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; - } - - var CONTINUE = {}; - - function mixinProperties(mixinsMeta, mixin) { - var guid = undefined; - - if (mixin instanceof Mixin) { - guid = _emberUtils.guidFor(mixin); - if (mixinsMeta.peekMixins(guid)) { - return CONTINUE; - } - mixinsMeta.writeMixins(guid, mixin); - return mixin.properties; - } else { - return mixin; // apply anonymous mixin properties - } - } - - function concatenatedMixinProperties(concatProp, props, values, base) { - var concats = undefined; - - // reset before adding each new mixin to pickup concats from previous - concats = values[concatProp] || base[concatProp]; - if (props[concatProp]) { - concats = concats ? concats.concat(props[concatProp]) : props[concatProp]; - } - - return concats; - } - - function giveDescriptorSuper(meta, key, property, values, descs, base) { - var superProperty = undefined; - - // Computed properties override methods, and do not call super to them - if (values[key] === undefined) { - // Find the original descriptor in a parent mixin - superProperty = descs[key]; - } - - // If we didn't find the original descriptor in a parent mixin, find - // it on the original object. - if (!superProperty) { - var possibleDesc = base[key]; - var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - superProperty = superDesc; - } - - if (superProperty === undefined || !(superProperty instanceof _emberMetalComputed.ComputedProperty)) { - return property; - } - - // Since multiple mixins may inherit from the same parent, we need - // to clone the computed property so that other mixins do not receive - // the wrapped version. - property = Object.create(property); - property._getter = _emberUtils.wrap(property._getter, superProperty._getter); - if (superProperty._setter) { - if (property._setter) { - property._setter = _emberUtils.wrap(property._setter, superProperty._setter); - } else { - property._setter = superProperty._setter; - } - } - - return property; - } - - function giveMethodSuper(obj, key, method, values, descs) { - var superMethod = undefined; - - // Methods overwrite computed properties, and do not call super to them. - if (descs[key] === undefined) { - // Find the original method in a parent mixin - superMethod = values[key]; - } - - // If we didn't find the original value in a parent mixin, find it in - // the original object - superMethod = superMethod || obj[key]; - - // Only wrap the new method if the original method was a function - if (superMethod === undefined || 'function' !== typeof superMethod) { - return method; - } - - return _emberUtils.wrap(method, superMethod); - } - - function applyConcatenatedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; - var ret = undefined; - - if (baseValue) { - if ('function' === typeof baseValue.concat) { - if (value === null || value === undefined) { - ret = baseValue; - } else { - ret = baseValue.concat(value); - } - } else { - ret = _emberUtils.makeArray(baseValue).concat(value); - } - } else { - ret = _emberUtils.makeArray(value); - } - - _emberMetalDebug.runInDebug(function () { - // it is possible to use concatenatedProperties with strings (which cannot be frozen) - // only freeze objects... - if (typeof ret === 'object' && ret !== null) { - // prevent mutating `concatenatedProperties` array after it is applied - Object.freeze(ret); - } - }); - - return ret; - } - - function applyMergedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; - - _emberMetalDebug.runInDebug(function () { - if (Array.isArray(value)) { - // use conditional to avoid stringifying every time - _emberMetalDebug.assert('You passed in `' + JSON.stringify(value) + '` as the value for `' + key + '` but `' + key + '` cannot be an Array', false); - } - }); - - if (!baseValue) { - return value; - } - - var newBase = _emberUtils.assign({}, baseValue); - var hasFunction = false; - - for (var prop in value) { - if (!value.hasOwnProperty(prop)) { - continue; - } - - var propValue = value[prop]; - if (isMethod(propValue)) { - // TODO: support for Computed Properties, etc? - hasFunction = true; - newBase[prop] = giveMethodSuper(obj, prop, propValue, baseValue, {}); - } else { - newBase[prop] = propValue; - } - } - - if (hasFunction) { - newBase._super = ROOT; - } - - return newBase; - } - - function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { - if (value instanceof _emberMetalProperties.Descriptor) { - if (value === REQUIRED && descs[key]) { - return CONTINUE; - } - - // Wrap descriptor function to implement - // _super() if needed - if (value._getter) { - value = giveDescriptorSuper(meta, key, value, values, descs, base); - } - - descs[key] = value; - values[key] = undefined; - } else { - if (concats && concats.indexOf(key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') { - value = applyConcatenatedProperties(base, key, value, values); - } else if (mergings && mergings.indexOf(key) >= 0) { - value = applyMergedProperties(base, key, value, values); - } else if (isMethod(value)) { - value = giveMethodSuper(base, key, value, values, descs); - } - - descs[key] = undefined; - values[key] = value; - } - } - - function mergeMixins(mixins, m, descs, values, base, keys) { - var currentMixin = undefined, - props = undefined, - key = undefined, - concats = undefined, - mergings = undefined; - - function removeKeys(keyName) { - delete descs[keyName]; - delete values[keyName]; - } - - for (var i = 0; i < mixins.length; i++) { - currentMixin = mixins[i]; - _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - - props = mixinProperties(m, currentMixin); - if (props === CONTINUE) { - continue; - } - - if (props) { - if (base.willMergeMixin) { - base.willMergeMixin(props); - } - concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); - mergings = concatenatedMixinProperties('mergedProperties', props, values, base); - - for (key in props) { - if (!props.hasOwnProperty(key)) { - continue; - } - keys.push(key); - addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings); - } - - // manually copy toString() because some JS engines do not enumerate it - if (props.hasOwnProperty('toString')) { - base.toString = props.toString; - } - } else if (currentMixin.mixins) { - mergeMixins(currentMixin.mixins, m, descs, values, base, keys); - if (currentMixin._without) { - currentMixin._without.forEach(removeKeys); - } - } - } - } - - function detectBinding(key) { - var length = key.length; - - return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; - } - - // warm both paths of above function - detectBinding('notbound'); - detectBinding('fooBinding'); - - function connectBindings(obj, m) { - // TODO Mixin.apply(instance) should disconnect binding if exists - m.forEachBindings(function (key, binding) { - if (binding) { - var to = key.slice(0, -7); // strip Binding off end - if (binding instanceof _emberMetalBinding.Binding) { - binding = binding.copy(); // copy prototypes' instance - binding.to(to); - } else { - // binding is string path - binding = new _emberMetalBinding.Binding(to, binding); - } - binding.connect(obj); - obj[key] = binding; - } - }); - // mark as applied - m.clearBindings(); - } - - function finishPartial(obj, m) { - connectBindings(obj, m || _emberMetalMeta.meta(obj)); - return obj; - } - - function followAlias(obj, desc, m, descs, values) { - var altKey = desc.methodName; - var value = undefined; - var possibleDesc = undefined; - if (descs[altKey] || values[altKey]) { - value = values[altKey]; - desc = descs[altKey]; - } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - value = undefined; - } else { - desc = undefined; - value = obj[altKey]; - } - - return { desc: desc, value: value }; - } - - function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { - var paths = observerOrListener[pathsKey]; - - if (paths) { - for (var i = 0; i < paths.length; i++) { - updateMethod(obj, paths[i], null, key); - } - } - } - - function replaceObserversAndListeners(obj, key, observerOrListener) { - var prev = obj[key]; - - if ('function' === typeof prev) { - updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _emberMetalObserver._removeBeforeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_observes__', _emberMetalObserver.removeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_listens__', _emberMetalEvents.removeListener); - } - - if ('function' === typeof observerOrListener) { - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', _emberMetalObserver._addBeforeObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', _emberMetalObserver.addObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', _emberMetalEvents.addListener); - } - } - - function applyMixin(obj, mixins, partial) { - var descs = {}; - var values = {}; - var m = _emberMetalMeta.meta(obj); - var keys = []; - var key = undefined, - value = undefined, - desc = undefined; - - obj._super = ROOT; - - // Go through all mixins and hashes passed in, and: - // - // * Handle concatenated properties - // * Handle merged properties - // * Set up _super wrapping if necessary - // * Set up computed property descriptors - // * Copying `toString` in broken browsers - mergeMixins(mixins, m, descs, values, obj, keys); - - for (var i = 0; i < keys.length; i++) { - key = keys[i]; - if (key === 'constructor' || !values.hasOwnProperty(key)) { - continue; - } - - desc = descs[key]; - value = values[key]; - - if (desc === REQUIRED) { - continue; - } - - while (desc && desc instanceof Alias) { - var followed = followAlias(obj, desc, m, descs, values); - desc = followed.desc; - value = followed.value; - } - - if (desc === undefined && value === undefined) { - continue; - } - - replaceObserversAndListeners(obj, key, value); - - if (detectBinding(key)) { - m.writeBindings(key, value); - } - - _emberMetalProperties.defineProperty(obj, key, desc, value, m); - } - - if (!partial) { - // don't apply to prototype - finishPartial(obj, m); - } - - return obj; - } - - /** - @method mixin - @for Ember - @param obj - @param mixins* - @return obj - @private - */ - - function mixin(obj) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - applyMixin(obj, args, false); - return obj; - } - - /** - The `Ember.Mixin` class allows you to create mixins, whose properties can be - added to other classes. For instance, - - ```javascript - const EditableMixin = Ember.Mixin.create({ - edit() { - console.log('starting to edit'); - this.set('isEditing', true); - }, - isEditing: false - }); - - // Mix mixins into classes by passing them as the first arguments to - // `.extend.` - const Comment = Ember.Object.extend(EditableMixin, { - post: null - }); - - let comment = Comment.create(post: somePost); - comment.edit(); // outputs 'starting to edit' - ``` - - Note that Mixins are created with `Ember.Mixin.create`, not - `Ember.Mixin.extend`. - - Note that mixins extend a constructor's prototype so arrays and object literals - defined as properties will be shared amongst objects that implement the mixin. - If you want to define a property in a mixin that is not shared, you can define - it either as a computed property or have it be created on initialization of the object. - - ```javascript - // filters array will be shared amongst any object implementing mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.A() - }); - - // filters will be a separate array for every object implementing the mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.computed(function() { - return Ember.A(); - }) - }); - - // filters will be created as a separate array during the object's initialization - const Filterable = Ember.Mixin.create({ - init() { - this._super(...arguments); - this.set("filters", Ember.A()); - } - }); - ``` - - @class Mixin - @namespace Ember - @public - */ - - function Mixin(args, properties) { - this.properties = properties; - - var length = args && args.length; - - if (length > 0) { - var m = new Array(length); - - for (var i = 0; i < length; i++) { - var x = args[i]; - if (x instanceof Mixin) { - m[i] = x; - } else { - m[i] = new Mixin(undefined, x); - } - } - - this.mixins = m; - } else { - this.mixins = undefined; - } - this.ownerConstructor = undefined; - this._without = undefined; - this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; - _emberMetalDebug.debugSeal(this); - } - - Mixin._apply = applyMixin; - - Mixin.applyPartial = function (obj) { - var args = a_slice.call(arguments, 1); - return applyMixin(obj, args, true); - }; - - Mixin.finishPartial = finishPartial; - - var unprocessedFlag = false; - - function hasUnprocessedMixins() { - return unprocessedFlag; - } - - function clearUnprocessedMixins() { - unprocessedFlag = false; - } - - /** - @method create - @static - @param arguments* - @public - */ - Mixin.create = function () { - // ES6TODO: this relies on a global state? - unprocessedFlag = true; - var M = this; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return new M(args, undefined); - }; - - var MixinPrototype = Mixin.prototype; - - /** - @method reopen - @param arguments* - @private - */ - MixinPrototype.reopen = function () { - var currentMixin = undefined; - - if (this.properties) { - currentMixin = new Mixin(undefined, this.properties); - this.properties = undefined; - this.mixins = [currentMixin]; - } else if (!this.mixins) { - this.mixins = []; - } - - var mixins = this.mixins; - var idx = undefined; - - for (idx = 0; idx < arguments.length; idx++) { - currentMixin = arguments[idx]; - _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - - if (currentMixin instanceof Mixin) { - mixins.push(currentMixin); - } else { - mixins.push(new Mixin(undefined, currentMixin)); - } - } - - return this; - }; - - /** - @method apply - @param obj - @return applied object - @private - */ - MixinPrototype.apply = function (obj) { - return applyMixin(obj, [this], false); - }; - - MixinPrototype.applyPartial = function (obj) { - return applyMixin(obj, [this], true); - }; - - MixinPrototype.toString = Object.toString; - - function _detect(curMixin, targetMixin, seen) { - var guid = _emberUtils.guidFor(curMixin); - - if (seen[guid]) { - return false; - } - seen[guid] = true; - - if (curMixin === targetMixin) { - return true; - } - var mixins = curMixin.mixins; - var loc = mixins ? mixins.length : 0; - while (--loc >= 0) { - if (_detect(mixins[loc], targetMixin, seen)) { - return true; - } - } - return false; - } - - /** - @method detect - @param obj - @return {Boolean} - @private - */ - MixinPrototype.detect = function (obj) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - if (obj instanceof Mixin) { - return _detect(obj, this, {}); - } - var m = _emberMetalMeta.peekMeta(obj); - if (!m) { - return false; - } - return !!m.peekMixins(_emberUtils.guidFor(this)); - }; - - MixinPrototype.without = function () { - var ret = new Mixin([this]); - - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - ret._without = args; - return ret; - }; - - function _keys(ret, mixin, seen) { - if (seen[_emberUtils.guidFor(mixin)]) { - return; - } - seen[_emberUtils.guidFor(mixin)] = true; - - if (mixin.properties) { - 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); - }); - } - } - - MixinPrototype.keys = function () { - var keys = {}; - var seen = {}; - - _keys(keys, this, seen); - var ret = Object.keys(keys); - return ret; - }; - - _emberMetalDebug.debugSeal(MixinPrototype); - - // returns the mixins currently applied to the specified object - // TODO: Make Ember.mixin - Mixin.mixins = function (obj) { - var m = _emberMetalMeta.peekMeta(obj); - var ret = []; - if (!m) { - return ret; - } - - m.forEachMixins(function (key, currentMixin) { - // skip primitive mixins since these are always anonymous - if (!currentMixin.properties) { - ret.push(currentMixin); - } - }); - - return ret; - }; - - var REQUIRED = new _emberMetalProperties.Descriptor(); - REQUIRED.toString = function () { - return '(Required Property)'; - }; - - /** - Denotes a required property for a mixin - - @method required - @for Ember - @private - */ - - function required() { - _emberMetalDebug.deprecate('Ember.required is deprecated as its behavior is inconsistent and unreliable.', false, { id: 'ember-metal.required', until: '3.0.0' }); - return REQUIRED; - } - - function Alias(methodName) { - this.isDescriptor = true; - this.methodName = methodName; - } - - Alias.prototype = new _emberMetalProperties.Descriptor(); - - /** - Makes a method available via an additional name. - - ```javascript - App.Person = Ember.Object.extend({ - name: function() { - return 'Tomhuda Katzdale'; - }, - moniker: Ember.aliasMethod('name') - }); - - let goodGuy = App.Person.create(); - - goodGuy.name(); // 'Tomhuda Katzdale' - goodGuy.moniker(); // 'Tomhuda Katzdale' - ``` - - @method aliasMethod - @for Ember - @param {String} methodName name of the method to alias - @public - */ - - function aliasMethod(methodName) { - return new Alias(methodName); - } - - // .......................................................... - // OBSERVER HELPER - // - - /** - Specify a method that observes property changes. - - ```javascript - Ember.Object.extend({ - valueObserver: Ember.observer('value', function() { - // Executes whenever the "value" property changes - }) - }); - ``` - - Also available as `Function.prototype.observes` if prototype extensions are - enabled. - - @method observer - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func - @public - */ - - function observer() { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - _emberMetalDebug.deprecate('Passing the dependentKeys after the callback function in Ember.observer is deprecated. Ensure the callback function is the last argument.', false, { id: 'ember-metal.observer-argument-order', until: '3.0.0' }); - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('Ember.observer called without a function'); - } - - func.__ember_observes__ = paths; - return func; - } - - /** - Specify a method that observes property changes. - - ```javascript - Ember.Object.extend({ - valueObserver: Ember.immediateObserver('value', function() { - // Executes whenever the "value" property changes - }) - }); - ``` - - In the future, `Ember.observer` may become asynchronous. In this event, - `Ember.immediateObserver` will maintain the synchronous behavior. - - Also available as `Function.prototype.observesImmediately` if prototype extensions are - enabled. - - @method _immediateObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @deprecated Use `Ember.observer` instead. - @return func - @private - */ - - function _immediateObserver() { - _emberMetalDebug.deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.', false, { id: 'ember-metal.immediate-observer', until: '3.0.0' }); - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - _emberMetalDebug.assert('Immediate observers must observe internal properties only, not properties on other objects.', typeof arg !== 'string' || arg.indexOf('.') === -1); - } - - return observer.apply(this, arguments); - } - - /** - When observers fire, they are called with the arguments `obj`, `keyName`. - - Note, `@each.property` observer is called per each add or replace of an element - and it's not called with a specific enumeration item. - - A `_beforeObserver` fires before a property changes. - - @method beforeObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func - @deprecated - @private - */ - - function _beforeObserver() { - for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { - args[_key5] = arguments[_key5]; - } - - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('_beforeObserver called without a function'); - } - - func.__ember_observesBefore__ = paths; - return func; - } - - exports.Mixin = Mixin; - exports.required = required; - exports.REQUIRED = REQUIRED; -}); -enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { - 'use strict'; - - exports.addObserver = addObserver; - exports.observersFor = observersFor; - exports.removeObserver = removeObserver; - exports._addBeforeObserver = _addBeforeObserver; - exports._suspendObserver = _suspendObserver; - exports._suspendObservers = _suspendObservers; - exports._removeBeforeObserver = _removeBeforeObserver; - - /** - @module ember-metal - */ - - var AFTER_OBSERVERS = ':change'; - var BEFORE_OBSERVERS = ':before'; - - function changeEvent(keyName) { - return keyName + AFTER_OBSERVERS; - } - - function beforeEvent(keyName) { - return keyName + BEFORE_OBSERVERS; - } - - /** - @method addObserver - @for Ember - @param obj - @param {String} _path - @param {Object|Function} target - @param {Function|String} [method] - @public - */ - - function addObserver(obj, _path, target, method) { - _emberMetalEvents.addListener(obj, changeEvent(_path), target, method); - _emberMetalWatching.watch(obj, _path); - - return this; - } - - function observersFor(obj, path) { - return _emberMetalEvents.listenersFor(obj, changeEvent(path)); - } - - /** - @method removeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @public - */ - - function removeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, changeEvent(path), target, method); - - return this; - } - - /** - @method _addBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _addBeforeObserver(obj, path, target, method) { - _emberMetalEvents.addListener(obj, beforeEvent(path), target, method); - _emberMetalWatching.watch(obj, path); - - return this; - } - - // Suspend observer during callback. - // - // This should only be used by the target of the observer - // while it is setting the observed path. - - function _suspendObserver(obj, path, target, method, callback) { - return _emberMetalEvents.suspendListener(obj, changeEvent(path), target, method, callback); - } - - function _suspendObservers(obj, paths, target, method, callback) { - var events = paths.map(changeEvent); - return _emberMetalEvents.suspendListeners(obj, events, target, method, callback); - } - - /** - @method removeBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _removeBeforeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, beforeEvent(path), target, method); - - return this; - } -}); -enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { - 'use strict'; - - exports.default = ObserverSet; - - /* - this.observerSet = { - [senderGuid]: { // variable name: `keySet` - [keyName]: listIndex - } - }, - this.observers = [ - { - sender: obj, - keyName: keyName, - eventName: eventName, - listeners: [ - [target, method, flags] - ] - }, - ... - ] - */ - - function ObserverSet() { - this.clear(); - } - - ObserverSet.prototype.add = function (sender, keyName, eventName) { - var observerSet = this.observerSet; - var observers = this.observers; - var senderGuid = _emberUtils.guidFor(sender); - var keySet = observerSet[senderGuid]; - var index = undefined; - - 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 = undefined, - observer = undefined, - sender = undefined; - this.clear(); - for (i = 0; i < observers.length; ++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; - exports.hasThis = hasThis; - exports.isPath = isPath; - exports.getFirstKey = getFirstKey; - exports.getTailPath = getTailPath; - - var IS_GLOBAL = /^[A-Z$]/; - var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; - var HAS_THIS = 'this.'; - - var isGlobalCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL.test(key); - }); - var isGlobalPathCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL_PATH.test(key); - }); - var hasThisCache = new _emberMetalCache.default(1000, function (key) { - return key.lastIndexOf(HAS_THIS, 0) === 0; - }); - var firstDotIndexCache = new _emberMetalCache.default(1000, function (key) { - return key.indexOf('.'); - }); - - var firstKeyCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index === -1) { - return path; - } else { - return path.slice(0, index); - } - }); - - var tailPathCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index !== -1) { - return path.slice(index + 1); - } - }); - - var caches = { - isGlobalCache: isGlobalCache, - isGlobalPathCache: isGlobalPathCache, - hasThisCache: hasThisCache, - firstDotIndexCache: firstDotIndexCache, - firstKeyCache: firstKeyCache, - tailPathCache: tailPathCache - }; - - exports.caches = caches; - - function isGlobal(path) { - return isGlobalCache.get(path); - } - - function isGlobalPath(path) { - return isGlobalPathCache.get(path); - } - - function hasThis(path) { - return hasThisCache.get(path); - } - - function isPath(path) { - return firstDotIndexCache.get(path) !== -1; - } - - function getFirstKey(path) { - return firstKeyCache.get(path); - } - - function getTailPath(path) { - return tailPathCache.get(path); - } -}); -enifed('ember-metal/properties', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/property_events'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperty_events) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.Descriptor = Descriptor; - exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; - exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; - exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; - exports.defineProperty = defineProperty; - - // .......................................................... - // DESCRIPTOR - // - - /** - Objects of this type can implement an interface to respond to requests to - get and set. The default implementation handles simple properties. - - @class Descriptor - @private - */ - - function Descriptor() { - this.isDescriptor = true; - } - - var REDEFINE_SUPPORTED = (function () { - // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 - var a = Object.create(Object.prototype, { - prop: { - configurable: true, - value: 1 - } - }); - - Object.defineProperty(a, 'prop', { - configurable: true, - value: 2 - }); - - return a.prop === 2; - })(); - // .......................................................... - // DEFINING PROPERTIES API - // - - function MANDATORY_SETTER_FUNCTION(name) { - function SETTER_FUNCTION(value) { - var m = _emberMetalMeta.peekMeta(this); - if (!m.isInitialized(this)) { - m.writeValues(name, value); - } else { - _emberMetalDebug.assert('You must use Ember.set() to set the `' + name + '` property (of ' + this + ') to `' + value + '`.', false); - } - } - - SETTER_FUNCTION.isMandatorySetter = true; - return SETTER_FUNCTION; - } - - function DEFAULT_GETTER_FUNCTION(name) { - return function GETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - return meta && meta.peekValues(name); - }; - } - - function INHERITING_GETTER_FUNCTION(name) { - function IGETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - var val = meta && meta.readInheritedValue('values', name); - - if (val === _emberMetalMeta.UNDEFINED) { - var proto = Object.getPrototypeOf(this); - return proto && proto[name]; - } else { - return val; - } - } - - IGETTER_FUNCTION.isInheritingGetter = true; - return IGETTER_FUNCTION; - } - - /** - NOTE: This is a low-level method used by other parts of the API. You almost - never want to call this method directly. Instead you should use - `Ember.mixin()` to define new properties. - - Defines a property on an object. This method works much like the ES5 - `Object.defineProperty()` method except that it can also accept computed - properties and other special descriptors. - - Normally this method takes only three parameters. However if you pass an - instance of `Descriptor` as the third param then you can pass an - optional value as the fourth parameter. This is often more efficient than - creating new descriptor hashes for each property. - - ## Examples - - ```javascript - // ES5 compatible mode - Ember.defineProperty(contact, 'firstName', { - writable: true, - configurable: false, - enumerable: true, - value: 'Charles' - }); - - // define a simple property - Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); - - // define a computed property - Ember.defineProperty(contact, 'fullName', Ember.computed('firstName', 'lastName', function() { - return this.firstName+' '+this.lastName; - })); - ``` - - @private - @method defineProperty - @for Ember - @param {Object} obj the object to define this property on. This may be a prototype. - @param {String} keyName the name of the property - @param {Descriptor} [desc] an instance of `Descriptor` (typically a - computed property) or an ES5 descriptor. - You must provide this or `data` but not both. - @param {*} [data] something other than a descriptor, that will - become the explicit value of this property. - */ - - function defineProperty(obj, keyName, desc, data, meta) { - var possibleDesc = undefined, - existingDesc = undefined, - watching = undefined, - value = undefined; - - if (!meta) { - meta = _emberMetalMeta.meta(obj); - } - var watchEntry = meta.peekWatching(keyName); - possibleDesc = obj[keyName]; - existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - watching = watchEntry !== undefined && watchEntry > 0; - - if (existingDesc) { - existingDesc.teardown(obj, keyName); - } - - if (desc instanceof Descriptor) { - value = desc; - if (true) { - if (watching) { - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: true, - writable: true, - value: value - }); - } else { - obj[keyName] = value; - } - } else { - obj[keyName] = value; - } - if (desc.setup) { - desc.setup(obj, keyName); - } - } else { - if (desc == null) { - value = data; - - if (true) { - if (watching) { - meta.writeValues(keyName, data); - - var defaultDescriptor = { - configurable: true, - enumerable: true, - set: MANDATORY_SETTER_FUNCTION(keyName), - get: DEFAULT_GETTER_FUNCTION(keyName) - }; - - if (REDEFINE_SUPPORTED) { - Object.defineProperty(obj, keyName, defaultDescriptor); - } else { - handleBrokenPhantomDefineProperty(obj, keyName, defaultDescriptor); - } - } else { - obj[keyName] = data; - } - } else { - obj[keyName] = data; - } - } else { - value = desc; - - // fallback to ES5 - Object.defineProperty(obj, keyName, desc); - } - } - - // if key is being watched, override chains that - // were initialized with the prototype - if (watching) { - _emberMetalProperty_events.overrideChains(obj, keyName, meta); - } - - // The `value` passed to the `didDefineProperty` hook is - // either the descriptor or data, whichever was passed. - if (obj.didDefineProperty) { - obj.didDefineProperty(obj, keyName, value); - } - - return this; - } - - function handleBrokenPhantomDefineProperty(obj, keyName, desc) { - // https://github.com/ariya/phantomjs/issues/11856 - Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); - Object.defineProperty(obj, keyName, desc); - } -}); -enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) { - 'use strict'; - - var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE'); - - exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; - var beforeObserverSet = new _emberMetalObserver_set.default(); - var observerSet = new _emberMetalObserver_set.default(); - var deferred = 0; - - // .......................................................... - // PROPERTY CHANGES - // - - /** - This function is called just before an object property is about to change. - It will notify any before observers and prepare caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyDidChange()` which you should call just - after the property value changes. - - @method propertyWillChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @return {void} - @private - */ - function propertyWillChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.willChange) { - desc.willChange(obj, keyName); - } - - if (watching) { - dependentKeysWillChange(obj, keyName, meta); - chainsWillChange(obj, keyName, meta); - notifyBeforeObservers(obj, keyName, meta); - } - } - - /** - This function is called just after an object property has changed. - It will notify any observers and clear caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyWillChange()` which you should call just - before the property value changes. - - @method propertyDidChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @param {Meta} meta The objects meta. - @return {void} - @private - */ - function propertyDidChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - // shouldn't this mean that we're watching this key? - if (desc && desc.didChange) { - desc.didChange(obj, keyName); - } - - if (watching) { - if (meta.hasDeps(keyName)) { - dependentKeysDidChange(obj, keyName, meta); - } - - chainsDidChange(obj, keyName, meta, false); - notifyObservers(obj, keyName, meta); - } - - if (obj[PROPERTY_DID_CHANGE]) { - obj[PROPERTY_DID_CHANGE](keyName); - } - - if (meta && meta.isSourceDestroying()) { - return; - } - - _emberMetalTags.markObjectAsDirty(meta, keyName); - - if (true || false) { - _emberMetalTransaction.assertNotRendered(obj, keyName, meta); - } - } - - var WILL_SEEN = undefined, - DID_SEEN = undefined; - // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) - function dependentKeysWillChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = WILL_SEEN; - var _top = !seen; - - if (_top) { - seen = WILL_SEEN = {}; - } - - iterDeps(propertyWillChange, obj, depKey, seen, meta); - - if (_top) { - WILL_SEEN = null; - } - } - } - - // called whenever a property has just changed to update dependent keys - function dependentKeysDidChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = DID_SEEN; - var _top2 = !seen; - - if (_top2) { - seen = DID_SEEN = {}; - } - - iterDeps(propertyDidChange, obj, depKey, seen, meta); - - if (_top2) { - DID_SEEN = null; - } - } - } - - function iterDeps(method, obj, depKey, seen, meta) { - var possibleDesc = undefined, - desc = undefined; - var guid = _emberUtils.guidFor(obj); - var current = seen[guid]; - - if (!current) { - current = seen[guid] = {}; - } - - if (current[depKey]) { - return; - } - - current[depKey] = true; - - meta.forEachInDeps(depKey, function (key, value) { - if (!value) { - return; - } - - possibleDesc = obj[key]; - desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc._suspended === obj) { - return; - } - - method(obj, key, meta); - }); - } - - function chainsWillChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, false, propertyWillChange); - } - } - - function chainsDidChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, true, propertyDidChange); - } - } - - function overrideChains(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - } - - /** - @method beginPropertyChanges - @chainable - @private - */ - function beginPropertyChanges() { - deferred++; - } - - /** - @method endPropertyChanges - @private - */ - function endPropertyChanges() { - deferred--; - if (deferred <= 0) { - beforeObserverSet.clear(); - observerSet.flush(); - } - } - - /** - Make a series of property changes together in an - exception-safe way. - - ```javascript - Ember.changeProperties(function() { - obj1.set('foo', mayBlowUpWhenSet); - obj2.set('bar', baz); - }); - ``` - - @method changeProperties - @param {Function} callback - @param [binding] - @private - */ - function changeProperties(callback, binding) { - beginPropertyChanges(); - try { - callback.call(binding); - } finally { - endPropertyChanges.call(binding); - } - } - - function notifyBeforeObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':before'; - var listeners = undefined, - added = undefined; - if (deferred) { - listeners = beforeObserverSet.add(obj, keyName, eventName); - added = _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName], added); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - function notifyObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':change'; - var listeners = undefined; - if (deferred) { - listeners = observerSet.add(obj, keyName, eventName); - _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - exports.propertyWillChange = propertyWillChange; - exports.propertyDidChange = propertyDidChange; - exports.overrideChains = overrideChains; - exports.beginPropertyChanges = beginPropertyChanges; - exports.endPropertyChanges = endPropertyChanges; - exports.changeProperties = changeProperties; -}); -enifed('ember-metal/property_get', ['exports', 'ember-metal/debug', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalPath_cache) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.get = get; - exports._getPath = _getPath; - exports.getWithDefault = getWithDefault; - - var ALLOWABLE_TYPES = { - object: true, - function: true, - string: true - }; - - // .......................................................... - // GET AND SET - // - // If we are on a platform that supports accessors we can use those. - // Otherwise simulate accessors by looking up the property directly on the - // object. - - /** - Gets the value of a property on an object. If the property is computed, - the function will be invoked. If the property is not defined but the - object implements the `unknownProperty` method then that will be invoked. - - ```javascript - Ember.get(obj, "name"); - ``` - - If you plan to run on IE8 and older browsers then you should use this - method anytime you want to retrieve a property on an object that you don't - know for sure is private. (Properties beginning with an underscore '_' - are considered private.) - - On all newer browsers, you only need to use this method to retrieve - properties if the property might not be defined on the object and you want - to respect the `unknownProperty` handler. Otherwise you can ignore this - method. - - Note that if the object itself is `undefined`, this method will throw - an error. - - @method get - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The property key to retrieve - @return {Object} the property value or `null`. - @public - */ - - function get(obj, keyName) { - _emberMetalDebug.assert('Get must be called with two arguments; an object and a property key', arguments.length === 2); - _emberMetalDebug.assert('Cannot call get with \'' + keyName + '\' on an undefined object.', obj !== undefined && obj !== null); - _emberMetalDebug.assert('The key provided to get must be a string, you passed ' + keyName, typeof keyName === 'string'); - _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); - _emberMetalDebug.assert('Cannot call `Ember.get` with an empty string', keyName !== ''); - - var value = obj[keyName]; - var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined; - var ret = undefined; - - if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) { - return _getPath(obj, keyName); - } - - if (desc) { - return desc.get(obj, keyName); - } else { - ret = value; - - if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { - return obj.unknownProperty(keyName); - } - - return ret; - } - } - - function _getPath(root, path) { - var obj = root; - var parts = path.split('.'); - - for (var i = 0; i < parts.length; i++) { - if (!isGettable(obj)) { - return undefined; - } - - obj = get(obj, parts[i]); - - if (obj && obj.isDestroyed) { - return undefined; - } - } - - return obj; - } - - function isGettable(obj) { - if (obj == null) { - return false; - } - - return ALLOWABLE_TYPES[typeof obj]; - } - - /** - Retrieves the value of a property from an Object, or a default value in the - case that the property returns `undefined`. - - ```javascript - Ember.getWithDefault(person, 'lastName', 'Doe'); - ``` - - @method getWithDefault - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public - */ - - function getWithDefault(root, key, defaultValue) { - var value = get(root, key); - - if (value === undefined) { - return defaultValue; - } - return value; - } - - exports.default = get; -}); -enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) { - 'use strict'; - - exports.set = set; - exports.trySet = trySet; - - /** - Sets the value of a property on an object, respecting computed properties - and notifying observers and other listeners of the change. If the - property is not defined but the object implements the `setUnknownProperty` - method then that will be invoked as well. - - ```javascript - Ember.set(obj, "name", value); - ``` - - @method set - @for Ember - @param {Object} obj The object to modify. - @param {String} keyName The property key to set - @param {Object} value The value to set - @return {Object} the passed value. - @public - */ - - function set(obj, keyName, value, tolerant) { - _emberMetalDebug.assert('Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false', arguments.length === 3 || arguments.length === 4); - _emberMetalDebug.assert('Cannot call set with \'' + keyName + '\' on an undefined object.', obj && typeof obj === 'object' || typeof obj === 'function'); - _emberMetalDebug.assert('The key provided to set must be a string, you passed ' + keyName, typeof keyName === 'string'); - _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); - _emberMetalDebug.assert('calling set on destroyed object: ' + _emberUtils.toString(obj) + '.' + keyName + ' = ' + _emberUtils.toString(value), !obj.isDestroyed); - - if (_emberMetalPath_cache.isPath(keyName)) { - return setPath(obj, keyName, value, tolerant); - } - - var meta = _emberMetalMeta.peekMeta(obj); - var possibleDesc = obj[keyName]; - - var desc = undefined, - currentValue = undefined; - if (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - } else { - currentValue = possibleDesc; - } - - if (desc) { - /* computed property */ - desc.set(obj, keyName, value); - } else if (obj.setUnknownProperty && currentValue === undefined && !(keyName in obj)) { - /* unknown property */ - _emberMetalDebug.assert('setUnknownProperty must be a function', typeof obj.setUnknownProperty === 'function'); - obj.setUnknownProperty(keyName, value); - } else if (currentValue === value) { - /* no change */ - return value; - } else { - _emberMetalProperty_events.propertyWillChange(obj, keyName); - - if (true) { - setWithMandatorySetter(meta, obj, keyName, value); - } else { - obj[keyName] = value; - } - - _emberMetalProperty_events.propertyDidChange(obj, keyName); - } - - return value; - } - - if (true) { - var setWithMandatorySetter = function (meta, obj, keyName, value) { - if (meta && meta.peekWatching(keyName) > 0) { - makeEnumerable(obj, keyName); - meta.writeValue(obj, keyName, value); - } else { - obj[keyName] = value; - } - }; - - var makeEnumerable = function (obj, key) { - var desc = Object.getOwnPropertyDescriptor(obj, key); - - if (desc && desc.set && desc.set.isMandatorySetter) { - desc.enumerable = true; - Object.defineProperty(obj, key, desc); - } - }; - } - - function setPath(root, path, value, tolerant) { - // get the last part of the path - var keyName = path.slice(path.lastIndexOf('.') + 1); - - // get the first part of the part - path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); - - // unless the path is this, look up the first part to - // get the root - if (path !== 'this') { - root = _emberMetalProperty_get._getPath(root, path); - } - - if (!keyName || keyName.length === 0) { - throw new _emberMetalError.default('Property set failed: You passed an empty path'); - } - - if (!root) { - if (tolerant) { - return; - } else { - throw new _emberMetalError.default('Property set failed: object in path "' + path + '" could not be found or was destroyed.'); - } - } - - return set(root, keyName, value); - } - - /** - Error-tolerant form of `Ember.set`. Will not blow up if any part of the - chain is `undefined`, `null`, or destroyed. - - This is primarily used when syncing bindings, which may try to update after - an object has been destroyed. - - @method trySet - @for Ember - @param {Object} root The object to modify. - @param {String} path The property path to set - @param {Object} value The value to set - @public - */ - - function trySet(root, path, value) { - return set(root, path, value, true); - } -}); -enifed("ember-metal/replace", ["exports"], function (exports) { - "use strict"; - - exports.default = replace; - var splice = Array.prototype.splice; - - function replace(array, idx, amt, objects) { - var args = [].concat(objects); - var ret = []; - // https://code.google.com/p/chromium/issues/detail?id=56588 - var size = 60000; - var start = idx; - var ends = amt; - var count = undefined, - chunk = undefined; - - while (args.length) { - count = ends > size ? size : ends; - if (count <= 0) { - count = 0; - } - - chunk = args.splice(0, size); - chunk = [start, count].concat(chunk); - - start += size; - ends -= count; - - ret = ret.concat(splice.apply(array, chunk)); - } - return ret; - } -}); -enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) { - 'use strict'; - - exports.default = run; - - function onBegin(current) { - run.currentRunLoop = current; - } - - function onEnd(current, next) { - run.currentRunLoop = next; - } - - var onErrorTarget = { - get onerror() { - return _emberMetalError_handler.getOnerror(); - }, - set onerror(handler) { - return _emberMetalError_handler.setOnerror(handler); - } - }; - - var backburner = new _backburner.default(['sync', 'actions', 'destroy'], { - GUID_KEY: _emberUtils.GUID_KEY, - sync: { - before: _emberMetalProperty_events.beginPropertyChanges, - after: _emberMetalProperty_events.endPropertyChanges - }, - defaultQueue: 'actions', - onBegin: onBegin, - onEnd: onEnd, - onErrorTarget: onErrorTarget, - onErrorMethod: 'onerror' - }); - - // .......................................................... - // run - this is ideally the only public API the dev sees - // - - /** - Runs the passed target and method inside of a RunLoop, ensuring any - deferred actions including bindings and views updates are flushed at the - end. - - Normally you should not need to invoke this method yourself. However if - you are implementing raw event handlers when interfacing with other - libraries or plugins, you should probably wrap all of your code inside this - call. - - ```javascript - run(function() { - // code to be executed within a RunLoop - }); - ``` - - @class run - @namespace Ember - @static - @constructor - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} return value from invoking the passed function. - @public - */ - - function run() { - return backburner.run.apply(backburner, arguments); - } - - /** - If no run-loop is present, it creates a new one. If a run loop is - present it will queue itself to run on the existing run-loops action - queue. - - Please note: This is not for normal usage, and should be used sparingly. - - If invoked when not within a run loop: - - ```javascript - run.join(function() { - // creates a new run-loop - }); - ``` - - Alternatively, if called within an existing run loop: - - ```javascript - run(function() { - // creates a new run-loop - run.join(function() { - // joins with the existing run-loop, and queues for invocation on - // the existing run-loops action queue. - }); - }); - ``` - - @method join - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} Return value from invoking the passed function. Please note, - when called within an existing loop, no return value is possible. - @public - */ - run.join = function () { - return backburner.join.apply(backburner, arguments); - }; - - /** - Allows you to specify which context to call the specified function in while - adding the execution of that function to the Ember run loop. This ability - makes this method a great way to asynchronously integrate third-party libraries - into your Ember application. - - `run.bind` takes two main arguments, the desired context and the function to - invoke in that context. Any additional arguments will be supplied as arguments - to the function that is passed in. - - Let's use the creation of a TinyMCE component as an example. Currently, - TinyMCE provides a setup configuration option we can use to do some processing - after the TinyMCE instance is initialized but before it is actually rendered. - We can use that setup option to do some additional setup for our component. - The component itself could look something like the following: - - ```javascript - App.RichTextEditorComponent = Ember.Component.extend({ - initializeTinyMCE: Ember.on('didInsertElement', function() { - tinymce.init({ - selector: '#' + this.$().prop('id'), - setup: Ember.run.bind(this, this.setupEditor) - }); - }), - - setupEditor: function(editor) { - this.set('editor', editor); - - editor.on('change', function() { - console.log('content changed!'); - }); - } - }); - ``` - - In this example, we use Ember.run.bind to bind the setupEditor method to the - context of the App.RichTextEditorComponent and to have the invocation of that - method be safely handled and executed by the Ember run loop. - - @method bind - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Function} returns a new function that will always have a particular context - @since 1.4.0 - @public - */ - run.bind = function () { - for (var _len = arguments.length, curried = Array(_len), _key = 0; _key < _len; _key++) { - curried[_key] = arguments[_key]; - } - - return function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return run.join.apply(run, curried.concat(args)); - }; - }; - - run.backburner = backburner; - run.currentRunLoop = null; - run.queues = backburner.queueNames; - - /** - Begins a new RunLoop. Any deferred actions invoked after the begin will - be buffered until you invoke a matching call to `run.end()`. This is - a lower-level way to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method begin - @return {void} - @public - */ - run.begin = function () { - backburner.begin(); - }; - - /** - Ends a RunLoop. This must be called sometime after you call - `run.begin()` to flush any deferred actions. This is a lower-level way - to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method end - @return {void} - @public - */ - run.end = function () { - backburner.end(); - }; - - /** - Array of named queues. This array determines the order in which queues - are flushed at the end of the RunLoop. You can define your own queues by - simply adding the queue name to this array. Normally you should not need - to inspect or modify this property. - - @property queues - @type Array - @default ['sync', 'actions', 'destroy'] - @private - */ - - /** - Adds the passed target/method and any optional arguments to the named - queue to be executed at the end of the RunLoop. If you have not already - started a RunLoop when calling this method one will be started for you - automatically. - - At the end of a RunLoop, any methods scheduled in this way will be invoked. - Methods will be invoked in an order matching the named queues defined in - the `run.queues` property. - - ```javascript - run.schedule('sync', this, function() { - // this will be executed in the first RunLoop queue, when bindings are synced - console.log('scheduled on sync queue'); - }); - - run.schedule('actions', this, function() { - // this will be executed in the 'actions' queue, after bindings have synced. - console.log('scheduled on actions queue'); - }); - - // Note the functions will be run in order based on the run queues order. - // Output would be: - // scheduled on sync queue - // scheduled on actions queue - ``` - - @method schedule - @param {String} queue The name of the queue to schedule against. - Default queues are 'sync' and 'actions' - @param {Object} [target] target object to use as the context when invoking a method. - @param {String|Function} method The method to invoke. If you pass a string it - will be resolved on the target object at the time the scheduled item is - invoked allowing you to change the target function. - @param {Object} [arguments*] Optional arguments to be passed to the queued method. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.schedule = function () /* queue, target, method */{ - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - - return backburner.schedule.apply(backburner, arguments); - }; - - // Used by global test teardown - run.hasScheduledTimers = function () { - return backburner.hasTimers(); - }; - - // Used by global test teardown - run.cancelTimers = function () { - backburner.cancelTimers(); - }; - - /** - Immediately flushes any events scheduled in the 'sync' queue. Bindings - use this queue so this method is a useful way to immediately force all - bindings in the application to sync. - - You should call this method anytime you need any changed state to propagate - throughout the app immediately without repainting the UI (which happens - in the later 'render' queue added by the `ember-views` package). - - ```javascript - run.sync(); - ``` - - @method sync - @return {void} - @private - */ - run.sync = function () { - if (backburner.currentInstance) { - backburner.currentInstance.queues.sync.flush(); - } - }; - - /** - Invokes the passed target/method and optional arguments after a specified - period of time. The last parameter of this method must always be a number - of milliseconds. - - You should use this method whenever you need to run some action after a - period of time instead of using `setTimeout()`. This method will ensure that - items that expire during the same script execution cycle all execute - together, which is often more efficient than using a real setTimeout. - - ```javascript - run.later(myContext, function() { - // code here will execute within a RunLoop in about 500ms with this == myContext - }, 500); - ``` - - @method later - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.later = function () /*target, method*/{ - return backburner.later.apply(backburner, arguments); - }; - - /** - Schedule a function to run one time during the current RunLoop. This is equivalent - to calling `scheduleOnce` with the "actions" queue. - - @method once - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.once = function () { - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - args.unshift('actions'); - return backburner.scheduleOnce.apply(backburner, args); - }; - - /** - Schedules a function to run one time in a given queue of the current RunLoop. - Calling this method with the same queue/target/method combination will have - no effect (past the initial call). - - Note that although you can pass optional arguments these will not be - considered when looking for duplicates. New arguments will replace previous - calls. - - ```javascript - function sayHi() { - console.log('hi'); - } - - run(function() { - run.scheduleOnce('afterRender', myContext, sayHi); - run.scheduleOnce('afterRender', myContext, sayHi); - // sayHi will only be executed once, in the afterRender queue of the RunLoop - }); - ``` - - Also note that passing an anonymous function to `run.scheduleOnce` will - not prevent additional calls with an identical anonymous function from - scheduling the items multiple times, e.g.: - - ```javascript - function scheduleIt() { - run.scheduleOnce('actions', myContext, function() { - console.log('Closure'); - }); - } - - scheduleIt(); - scheduleIt(); - - // "Closure" will print twice, even though we're using `run.scheduleOnce`, - // because the function we pass to it is anonymous and won't match the - // previously scheduled operation. - ``` - - Available queues, and their order, can be found at `run.queues` - - @method scheduleOnce - @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'. - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.scheduleOnce = function () /*queue, target, method*/{ - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - return backburner.scheduleOnce.apply(backburner, arguments); - }; - - /** - Schedules an item to run from within a separate run loop, after - control has been returned to the system. This is equivalent to calling - `run.later` with a wait time of 1ms. - - ```javascript - run.next(myContext, function() { - // code to be executed in the next run loop, - // which will be scheduled after the current one - }); - ``` - - Multiple operations scheduled with `run.next` will coalesce - into the same later run loop, along with any other operations - scheduled by `run.later` that expire right around the same - time that `run.next` operations will fire. - - Note that there are often alternatives to using `run.next`. - For instance, if you'd like to schedule an operation to happen - after all DOM element operations have completed within the current - run loop, you can make use of the `afterRender` run loop queue (added - by the `ember-views` package, along with the preceding `render` queue - where all the DOM element operations happen). - - Example: - - ```javascript - export default Ember.Component.extend({ - didInsertElement() { - this._super(...arguments); - run.scheduleOnce('afterRender', this, 'processChildElements'); - }, - - processChildElements() { - // ... do something with component's child component - // elements after they've finished rendering, which - // can't be done within this component's - // `didInsertElement` hook because that gets run - // before the child elements have been added to the DOM. - } - }); - ``` - - One benefit of the above approach compared to using `run.next` is - that you will be able to perform DOM/CSS operations before unprocessed - elements are rendered to the screen, which may prevent flickering or - other artifacts caused by delaying processing until after rendering. - - The other major benefit to the above approach is that `run.next` - introduces an element of non-determinism, which can make things much - harder to test, due to its reliance on `setTimeout`; it's much harder - to guarantee the order of scheduled operations when they are scheduled - outside of the current run loop, i.e. with `run.next`. - - @method next - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.next = function () { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - args.push(1); - return backburner.later.apply(backburner, args); - }; - - /** - Cancels a scheduled item. Must be a value returned by `run.later()`, - `run.once()`, `run.scheduleOnce()`, `run.next()`, `run.debounce()`, or - `run.throttle()`. - - ```javascript - let runNext = run.next(myContext, function() { - // will not be executed - }); - - run.cancel(runNext); - - let runLater = run.later(myContext, function() { - // will not be executed - }, 500); - - run.cancel(runLater); - - let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { - // will not be executed - }); - - run.cancel(runScheduleOnce); - - let runOnce = run.once(myContext, function() { - // will not be executed - }); - - run.cancel(runOnce); - - let throttle = run.throttle(myContext, function() { - // will not be executed - }, 1, false); - - run.cancel(throttle); - - let debounce = run.debounce(myContext, function() { - // will not be executed - }, 1); - - run.cancel(debounce); - - let debounceImmediate = run.debounce(myContext, function() { - // will be executed since we passed in true (immediate) - }, 100, true); - - // the 100ms delay until this method can be called again will be cancelled - run.cancel(debounceImmediate); - ``` - - @method cancel - @param {Object} timer Timer object to cancel - @return {Boolean} true if cancelled or false/undefined if it wasn't found - @public - */ - run.cancel = function (timer) { - return backburner.cancel(timer); - }; - - /** - Delay calling the target method until the debounce period has elapsed - with no additional debounce calls. If `debounce` is called again before - the specified time has elapsed, the timer is reset and the entire period - must pass again before the target method is called. - - This method should be used when an event may be called multiple times - but the action should only be called once when the event is done firing. - A common example is for scroll events where you only want updates to - happen once scrolling has ceased. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150); - - // less than 150ms passes - run.debounce(myContext, whoRan, 150); - - // 150ms passes - // whoRan is invoked with context myContext - // console logs 'debounce ran.' one time. - ``` - - Immediate allows you to run the function immediately, but debounce - other calls for this function until the wait time has elapsed. If - `debounce` is called again before the specified time has elapsed, - the timer is reset and the entire period must pass again before - the method can be called again. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 100ms passes - run.debounce(myContext, whoRan, 150, true); - - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - - ``` - - @method debounce - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to false. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.debounce = function () { - return backburner.debounce.apply(backburner, arguments); - }; - - /** - Ensure that the target method is never called more frequently than - the specified spacing period. The target method is called immediately. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'throttle' }; - - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 150ms passes - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - ``` - - @method throttle - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} spacing Number of milliseconds to space out requests. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to true. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.throttle = function () { - return backburner.throttle.apply(backburner, arguments); - }; - - /** - Add a new named queue after the specified queue. - - The queue to add will only be added once. - - @method _addQueue - @param {String} name the name of the queue to add. - @param {String} after the name of the queue to add after. - @private - */ - run._addQueue = function (name, after) { - if (run.queues.indexOf(name) === -1) { - run.queues.splice(run.queues.indexOf(after) + 1, 0, name); - } - }; -}); -enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set'], function (exports, _emberMetalProperty_events, _emberMetalProperty_set) { - 'use strict'; - - exports.default = setProperties; - - /** - Set a list of properties on an object. These properties are set inside - a single `beginPropertyChanges` and `endPropertyChanges` batch, so - observers will be buffered. - - ```javascript - let anObject = Ember.Object.create(); - - anObject.setProperties({ - firstName: 'Stanley', - lastName: 'Stuart', - age: 21 - }); - ``` - - @method setProperties - @param obj - @param {Object} properties - @return properties - @public - */ - - function setProperties(obj, properties) { - if (!properties || typeof properties !== 'object') { - return properties; - } - _emberMetalProperty_events.changeProperties(function () { - var props = Object.keys(properties); - var propertyName = undefined; - - for (var i = 0; i < props.length; i++) { - propertyName = props[i]; - - _emberMetalProperty_set.set(obj, propertyName, properties[propertyName]); - } - }); - return properties; - } -}); -enifed('ember-metal/tags', ['exports', 'glimmer-reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { - 'use strict'; - - exports.setHasViews = setHasViews; - exports.tagForProperty = tagForProperty; - exports.tagFor = tagFor; - exports.markObjectAsDirty = markObjectAsDirty; - - var hasViews = function () { - return false; - }; - - function setHasViews(fn) { - hasViews = fn; - } - - function makeTag() { - return new _glimmerReference.DirtyableTag(); - } - - function tagForProperty(object, propertyKey, _meta) { - if (_emberMetalIs_proxy.isProxy(object)) { - return tagFor(object, _meta); - } - - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - var tags = meta.writableTags(); - var tag = tags[propertyKey]; - if (tag) { - return tag; - } - - return tags[propertyKey] = makeTag(); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function tagFor(object, _meta) { - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - return meta.writableTag(makeTag); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function markObjectAsDirty(meta, propertyKey) { - var objectTag = meta && meta.readableTag(); - - if (objectTag) { - objectTag.dirty(); - } - - var tags = meta && meta.readableTags(); - var propertyTag = tags && tags[propertyKey]; - - if (propertyTag) { - propertyTag.dirty(); - } - - if (objectTag || propertyTag) { - ensureRunloop(); - } - } - - var run = undefined; - - function K() {} - - function ensureRunloop() { - if (!run) { - run = _require.default('ember-metal/run_loop').default; - } - - if (hasViews() && !run.backburner.currentInstance) { - run.schedule('actions', K); - } - } -}); -enifed("ember-metal/testing", ["exports"], function (exports) { - "use strict"; - - exports.isTesting = isTesting; - exports.setTesting = setTesting; - var testing = false; - - function isTesting() { - return testing; - } - - function setTesting(value) { - testing = !!value; - } -}); -enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; - - var runInTransaction = undefined, - didRender = undefined, - assertNotRendered = undefined; - - var raise = _emberMetalDebug.assert; - if (false) { - raise = function (message, test) { - _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' }); - }; - } - - var implication = undefined; - if (false) { - implication = 'will be removed in Ember 3.0.'; - } else if (true) { - implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; - } - - if (true || false) { - (function () { - var counter = 0; - var inTransaction = false; - var shouldReflush = undefined; - - exports.default = runInTransaction = function (context, methodName) { - shouldReflush = false; - inTransaction = true; - context[methodName](); - inTransaction = false; - counter++; - return shouldReflush; - }; - - exports.didRender = didRender = function (object, key, reference) { - if (!inTransaction) { - return; - } - var meta = _emberMetalMeta.meta(object); - var lastRendered = meta.writableLastRendered(); - lastRendered[key] = counter; - - _emberMetalDebug.runInDebug(function () { - var lastRenderedFrom = meta.writableLastRenderedFrom(); - lastRenderedFrom[key] = reference; - }); - }; - - exports.assertNotRendered = assertNotRendered = function (object, key, _meta) { - var meta = _meta || _emberMetalMeta.meta(object); - var lastRendered = meta.readableLastRendered(); - - if (lastRendered && lastRendered[key] === counter) { - raise((function () { - var ref = meta.readableLastRenderedFrom(); - var parts = []; - var lastRef = ref[key]; - - var label = undefined; - - if (lastRef) { - while (lastRef && lastRef._propertyKey) { - parts.unshift(lastRef._propertyKey); - lastRef = lastRef._parentReference; - } - - label = parts.join(); - } else { - label = 'the same value'; - } - - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; - })(), false); - - shouldReflush = true; - } - }; - })(); - } else { - exports.default = runInTransaction = function () { - throw new Error('Cannot call runInTransaction without Glimmer'); - }; - - exports.didRender = didRender = function () { - throw new Error('Cannot call didRender without Glimmer'); - }; - - exports.assertNotRendered = assertNotRendered = function () { - throw new Error('Cannot call assertNotRendered without Glimmer'); - }; - } - - exports.default = runInTransaction; - exports.didRender = didRender; - exports.assertNotRendered = assertNotRendered; -}); -enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) { - 'use strict'; - - exports.watchKey = watchKey; - exports.unwatchKey = unwatchKey; - - var handleMandatorySetter = undefined; - - function watchKey(obj, keyName, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - - // activate watching first time - if (!m.peekWatching(keyName)) { - m.writeWatching(keyName, 1); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - if (desc && desc.willWatch) { - desc.willWatch(obj, keyName); - } - - if ('function' === typeof obj.willWatchProperty) { - obj.willWatchProperty(keyName); - } - - if (true) { - // NOTE: this is dropped for prod + minified builds - handleMandatorySetter(m, obj, keyName); - } - } else { - m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1); - } - } - - if (true) { - (function () { - var hasOwnProperty = function (obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - }; - - var propertyIsEnumerable = function (obj, key) { - return Object.prototype.propertyIsEnumerable.call(obj, key); - }; - - // Future traveler, although this code looks scary. It merely exists in - // development to aid in development asertions. Production builds of - // ember strip this entire block out - handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { - var descriptor = _emberUtils.lookupDescriptor(obj, keyName); - var configurable = descriptor ? descriptor.configurable : true; - var isWritable = descriptor ? descriptor.writable : true; - var hasValue = descriptor ? 'value' in descriptor : true; - var possibleDesc = descriptor && descriptor.value; - var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; - - if (isDescriptor) { - return; - } - - // this x in Y deopts, so keeping it in this function is better; - if (configurable && isWritable && hasValue && keyName in obj) { - var desc = { - configurable: true, - set: _emberMetalProperties.MANDATORY_SETTER_FUNCTION(keyName), - enumerable: propertyIsEnumerable(obj, keyName), - get: undefined - }; - - if (hasOwnProperty(obj, keyName)) { - m.writeValues(keyName, obj[keyName]); - desc.get = _emberMetalProperties.DEFAULT_GETTER_FUNCTION(keyName); - } else { - desc.get = _emberMetalProperties.INHERITING_GETTER_FUNCTION(keyName); - } - - Object.defineProperty(obj, keyName, desc); - } - }; - })(); - } - - function unwatchKey(obj, keyName, _meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var meta = _meta || _emberMetalMeta.meta(obj); - - // do nothing of this object has already been destroyed - if (meta.isSourceDestroyed()) { - return; - } - - var count = meta.peekWatching(keyName); - if (count === 1) { - meta.writeWatching(keyName, 0); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.didUnwatch) { - desc.didUnwatch(obj, keyName); - } - - if ('function' === typeof obj.didUnwatchProperty) { - obj.didUnwatchProperty(keyName); - } - - if (true) { - // It is true, the following code looks quite WAT. But have no fear, It - // exists purely to improve development ergonomics and is removed from - // ember.min.js and ember.prod.js builds. - // - // Some further context: Once a property is watched by ember, bypassing `set` - // for mutation, will bypass observation. This code exists to assert when - // that occurs, and attempt to provide more helpful feedback. The alternative - // is tricky to debug partially observable properties. - if (!desc && keyName in obj) { - var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName); - - if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { - if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { - var possibleValue = meta.readInheritedValue('values', keyName); - if (possibleValue === _emberMetalMeta.UNDEFINED) { - delete obj[keyName]; - return; - } - } - - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), - writable: true, - value: meta.peekValues(keyName) - }); - meta.deleteFromValues(keyName); - } - } - } - } else if (count > 1) { - meta.writeWatching(keyName, count - 1); - } - } -}); -enifed('ember-metal/watch_path', ['exports', 'ember-metal/meta', 'ember-metal/chains'], function (exports, _emberMetalMeta, _emberMetalChains) { - 'use strict'; - - exports.makeChainNode = makeChainNode; - exports.watchPath = watchPath; - exports.unwatchPath = unwatchPath; - - // get the chains for the current object. If the current object has - // chains inherited from the proto they will be cloned and reconfigured for - // the current object. - function chainsFor(obj, meta) { - return (meta || _emberMetalMeta.meta(obj)).writableChains(makeChainNode); - } - - function makeChainNode(obj) { - return new _emberMetalChains.ChainNode(null, null, obj); - } - - function watchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - if (!counter) { - // activate watching first time - m.writeWatching(keyPath, 1); - chainsFor(obj, m).add(keyPath); - } else { - m.writeWatching(keyPath, counter + 1); - } - } - - function unwatchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - - if (counter === 1) { - m.writeWatching(keyPath, 0); - chainsFor(obj, m).remove(keyPath); - } else if (counter > 1) { - m.writeWatching(keyPath, counter - 1); - } - } -}); -enifed('ember-metal/watching', ['exports', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.isWatching = isWatching; - exports.watcherCount = watcherCount; - exports.unwatch = unwatch; - exports.destroy = destroy; - - /** - Starts watching a property on an object. Whenever the property changes, - invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the - primitive used by observers and dependent keys; usually you will never call - this method directly but instead use higher level methods like - `Ember.addObserver()` - - @private - @method watch - @for Ember - @param obj - @param {String} _keyPath - */ - function watch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.watchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.watchPath(obj, _keyPath, m); - } - } - - exports.watch = watch; - - function isWatching(obj, key) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - var meta = _emberMetalMeta.peekMeta(obj); - return (meta && meta.peekWatching(key)) > 0; - } - - function watcherCount(obj, key) { - var meta = _emberMetalMeta.peekMeta(obj); - return meta && meta.peekWatching(key) || 0; - } - - function unwatch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.unwatchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.unwatchPath(obj, _keyPath, m); - } - } - - /** - Tears down the meta on an object so that it can be garbage collected. - Multiple calls will have no effect. - - @method destroy - @for Ember - @param {Object} obj the object to destroy - @return {void} - @private - */ - - function destroy(obj) { - _emberMetalMeta.deleteMeta(obj); - } -}); -enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; - - exports.default = WeakMap; - - var id = 0; - - // Returns whether Type(value) is Object according to the terminology in the spec - function isObject(value) { - return typeof value === 'object' && value !== null || typeof value === 'function'; - } - - /* - * @class Ember.WeakMap - * @public - * @category ember-metal-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(iterable) { - if (!(this instanceof WeakMap)) { - throw new TypeError('Constructor WeakMap requires \'new\''); - } - - this._id = _emberUtils.GUID_KEY + id++; - - if (iterable === null || iterable === undefined) { - return; - } else if (Array.isArray(iterable)) { - for (var i = 0; i < iterable.length; i++) { - var _iterable$i = iterable[i]; - var key = _iterable$i[0]; - var value = _iterable$i[1]; - - this.set(key, value); - } - } else { - throw new TypeError('The weak map constructor polyfill only supports an array argument'); - } - } - - /* - * @method get - * @param key {Object | Function} - * @return {Any} stored value - */ - WeakMap.prototype.get = function (obj) { - if (!isObject(obj)) { - return undefined; - } - - var meta = _emberMetalMeta.peekMeta(obj); - if (meta) { - var map = meta.readableWeak(); - if (map) { - if (map[this._id] === _emberMetalMeta.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 (!isObject(obj)) { - throw new TypeError('Invalid value used as weak map key'); - } - - if (value === undefined) { - value = _emberMetalMeta.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) { - if (!isObject(obj)) { - return false; - } - - 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; - } - }; - - /* - * @method toString - * @return {String} - */ - WeakMap.prototype.toString = function () { - return '[object WeakMap]'; - }; -}); -enifed('ember-template-compiler/compat', ['exports', 'ember-metal', 'ember-template-compiler/system/precompile', 'ember-template-compiler/system/compile', 'ember-template-compiler/system/compile-options'], function (exports, _emberMetal, _emberTemplateCompilerSystemPrecompile, _emberTemplateCompilerSystemCompile, _emberTemplateCompilerSystemCompileOptions) { - 'use strict'; - - var EmberHandlebars = _emberMetal.default.Handlebars = _emberMetal.default.Handlebars || {}; - var EmberHTMLBars = _emberMetal.default.HTMLBars = _emberMetal.default.HTMLBars || {}; - - EmberHTMLBars.precompile = EmberHandlebars.precompile = _emberTemplateCompilerSystemPrecompile.default; - EmberHTMLBars.compile = EmberHandlebars.compile = _emberTemplateCompilerSystemCompile.default; - EmberHTMLBars.registerPlugin = _emberTemplateCompilerSystemCompileOptions.registerPlugin; -}); -// reexports -enifed('ember-template-compiler/index', ['exports', 'ember-metal', 'ember-environment', 'ember/version', 'ember-template-compiler/compat', 'ember-template-compiler/system/bootstrap', 'ember-template-compiler/system/precompile', 'ember-template-compiler/system/compile', 'ember-template-compiler/system/compile-options', 'ember-template-compiler/plugins'], function (exports, _emberMetal, _emberEnvironment, _emberVersion, _emberTemplateCompilerCompat, _emberTemplateCompilerSystemBootstrap, _emberTemplateCompilerSystemPrecompile, _emberTemplateCompilerSystemCompile, _emberTemplateCompilerSystemCompileOptions, _emberTemplateCompilerPlugins) { - 'use strict'; - - // private API used by ember-cli-htmlbars to setup ENV and FEATURES - if (!_emberMetal.default.ENV) { - _emberMetal.default.ENV = _emberEnvironment.ENV; - } - if (!_emberMetal.default.FEATURES) { - _emberMetal.default.FEATURES = _emberMetal.FEATURES; - } - if (!_emberMetal.default.VERSION) { - _emberMetal.default.VERSION = _emberVersion.default; - } - - exports._Ember = _emberMetal.default; - exports.precompile = _emberTemplateCompilerSystemPrecompile.default; - exports.compile = _emberTemplateCompilerSystemCompile.default; - exports.compileOptions = _emberTemplateCompilerSystemCompileOptions.default; - exports.registerPlugin = _emberTemplateCompilerSystemCompileOptions.registerPlugin; - exports.defaultPlugins = _emberTemplateCompilerPlugins.default; - - // used for adding Ember.Handlebars.compile for backwards compat -}); - -// used to bootstrap templates -enifed('ember-template-compiler/plugins/assert-reserved-named-arguments', ['exports', 'ember-metal', 'ember-template-compiler/system/calculate-location-display'], function (exports, _emberMetal, _emberTemplateCompilerSystemCalculateLocationDisplay) { - 'use strict'; - - exports.default = AssertReservedNamedArguments; - - function AssertReservedNamedArguments(options) { - this.syntax = null; - this.options = options; - } - - AssertReservedNamedArguments.prototype.transform = function AssertReservedNamedArguments_transform(ast) { - var moduleName = this.options.meta.moduleName; - - this.syntax.traverse(ast, { - PathExpression: function (node) { - if (node.original[0] === '@') { - _emberMetal.assert(assertMessage(moduleName, node)); - } - } - }); - - return ast; - }; - - function assertMessage(moduleName, node) { - var path = node.original; - var source = _emberTemplateCompilerSystemCalculateLocationDisplay.default(moduleName, node.loc); - - return '\'' + path + '\' is not a valid path. ' + source; - } -}); -enifed('ember-template-compiler/plugins/deprecate-render-model', ['exports', 'ember-metal', 'ember-template-compiler/system/calculate-location-display'], function (exports, _emberMetal, _emberTemplateCompilerSystemCalculateLocationDisplay) { - 'use strict'; - - exports.default = DeprecateRenderModel; - - function DeprecateRenderModel(options) { - this.syntax = null; - this.options = options; - } - - DeprecateRenderModel.prototype.transform = function DeprecateRenderModel_transform(ast) { - var moduleName = this.options.meta.moduleName; - var walker = new this.syntax.Walker(); - - walker.visit(ast, function (node) { - if (!validate(node)) { - return; - } - - each(node.params, function (param) { - if (param.type !== 'PathExpression') { - return; - } - - _emberMetal.deprecate(deprecationMessage(moduleName, node, param), false, { - id: 'ember-template-compiler.deprecate-render-model', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_model-param-in-code-render-code-helper' - }); - }); - }); - - return ast; - }; - - function validate(node) { - return node.type === 'MustacheStatement' && node.path.original === 'render' && node.params.length > 1; - } - - function each(list, callback) { - for (var i = 0, l = list.length; i < l; i++) { - callback(list[i]); - } - } - - function deprecationMessage(moduleName, node, param) { - var sourceInformation = _emberTemplateCompilerSystemCalculateLocationDisplay.default(moduleName, node.loc); - var componentName = node.params[0].original; - var modelName = param.original; - var original = '{{render "' + componentName + '" ' + modelName + '}}'; - var preferred = '{{' + componentName + ' model=' + modelName + '}}'; - - return 'Please refactor `' + original + '` to a component and invoke via' + (' `' + preferred + '`. ' + sourceInformation); - } -}); -enifed('ember-template-compiler/plugins/deprecate-render', ['exports', 'ember-metal', 'ember-template-compiler/system/calculate-location-display'], function (exports, _emberMetal, _emberTemplateCompilerSystemCalculateLocationDisplay) { - 'use strict'; - - exports.default = DeprecateRender; - - function DeprecateRender(options) { - this.syntax = null; - this.options = options; - } - - DeprecateRender.prototype.transform = function DeprecateRender_transform(ast) { - var moduleName = this.options.meta.moduleName; - var walker = new this.syntax.Walker(); - - walker.visit(ast, function (node) { - if (!validate(node)) { - return; - } - - each(node.params, function (param) { - if (param.type !== 'StringLiteral') { - return; - } - - _emberMetal.deprecate(deprecationMessage(moduleName, node), false, { - id: 'ember-template-compiler.deprecate-render', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_code-render-code-helper' - }); - }); - }); - - return ast; - }; - - function validate(node) { - return node.type === 'MustacheStatement' && node.path.original === 'render' && node.params.length === 1; - } - - function each(list, callback) { - for (var i = 0, l = list.length; i < l; i++) { - callback(list[i]); - } - } - - function deprecationMessage(moduleName, node) { - var sourceInformation = _emberTemplateCompilerSystemCalculateLocationDisplay.default(moduleName, node.loc); - var componentName = node.params[0].original; - var original = '{{render "' + componentName + '"}}'; - var preferred = '{{' + componentName + '}}'; - - return 'Please refactor `' + original + '` to a component and invoke via' + (' `' + preferred + '`. ' + sourceInformation); - } -}); -enifed('ember-template-compiler/plugins/index', ['exports', 'ember-template-compiler/plugins/transform-old-binding-syntax', 'ember-template-compiler/plugins/transform-item-class', 'ember-template-compiler/plugins/transform-angle-bracket-components', 'ember-template-compiler/plugins/transform-input-on-to-onEvent', 'ember-template-compiler/plugins/transform-top-level-components', 'ember-template-compiler/plugins/transform-inline-link-to', 'ember-template-compiler/plugins/transform-old-class-binding-syntax', 'ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings', 'ember-template-compiler/plugins/deprecate-render-model', 'ember-template-compiler/plugins/deprecate-render', 'ember-template-compiler/plugins/assert-reserved-named-arguments', 'ember-template-compiler/plugins/transform-action-syntax', 'ember-template-compiler/plugins/transform-input-type-syntax', 'ember-template-compiler/plugins/transform-attrs-into-args', 'ember-template-compiler/plugins/transform-each-in-into-each', 'ember-template-compiler/plugins/transform-has-block-syntax'], function (exports, _emberTemplateCompilerPluginsTransformOldBindingSyntax, _emberTemplateCompilerPluginsTransformItemClass, _emberTemplateCompilerPluginsTransformAngleBracketComponents, _emberTemplateCompilerPluginsTransformInputOnToOnEvent, _emberTemplateCompilerPluginsTransformTopLevelComponents, _emberTemplateCompilerPluginsTransformInlineLinkTo, _emberTemplateCompilerPluginsTransformOldClassBindingSyntax, _emberTemplateCompilerPluginsTransformQuotedBindingsIntoJustBindings, _emberTemplateCompilerPluginsDeprecateRenderModel, _emberTemplateCompilerPluginsDeprecateRender, _emberTemplateCompilerPluginsAssertReservedNamedArguments, _emberTemplateCompilerPluginsTransformActionSyntax, _emberTemplateCompilerPluginsTransformInputTypeSyntax, _emberTemplateCompilerPluginsTransformAttrsIntoArgs, _emberTemplateCompilerPluginsTransformEachInIntoEach, _emberTemplateCompilerPluginsTransformHasBlockSyntax) { - 'use strict'; - - exports.default = Object.freeze([_emberTemplateCompilerPluginsTransformOldBindingSyntax.default, _emberTemplateCompilerPluginsTransformItemClass.default, _emberTemplateCompilerPluginsTransformAngleBracketComponents.default, _emberTemplateCompilerPluginsTransformInputOnToOnEvent.default, _emberTemplateCompilerPluginsTransformTopLevelComponents.default, _emberTemplateCompilerPluginsTransformInlineLinkTo.default, _emberTemplateCompilerPluginsTransformOldClassBindingSyntax.default, _emberTemplateCompilerPluginsTransformQuotedBindingsIntoJustBindings.default, _emberTemplateCompilerPluginsDeprecateRenderModel.default, _emberTemplateCompilerPluginsDeprecateRender.default, _emberTemplateCompilerPluginsAssertReservedNamedArguments.default, _emberTemplateCompilerPluginsTransformActionSyntax.default, _emberTemplateCompilerPluginsTransformInputTypeSyntax.default, _emberTemplateCompilerPluginsTransformAttrsIntoArgs.default, _emberTemplateCompilerPluginsTransformEachInIntoEach.default, _emberTemplateCompilerPluginsTransformHasBlockSyntax.default]); -}); -enifed('ember-template-compiler/plugins/transform-action-syntax', ['exports'], function (exports) { - /** - @module ember - @submodule ember-glimmer - */ - - /** - A Glimmer2 AST transformation that replaces all instances of - - ```handlebars - \n ')); + + App.register('component:x-bar', _emberGlimmer.Component.extend({ + counter: _emberRuntime.inject.service('shared-counter'), + + actions: { + incrementCounter: function () { + this.get('counter').increment(); + } + }, + + init: function () { + this._super(); + xBarInitCalled = true; + }, + + didInsertElement: function () { + xBarDidInsertElementCalled = true; + } + })); + }); + + var $foo = _emberViews.jQuery('
').appendTo('#qunit-fixture'); + var $bar = _emberViews.jQuery('
').appendTo('#qunit-fixture'); + + var data = encodeURIComponent(JSON.stringify({ name: 'Godfrey' })); + + return _emberRuntime.RSVP.all([_emberMetal.run(App, 'visit', '/x-foo?data=' + data, { rootElement: $foo[0] }), _emberMetal.run(App, 'visit', '/x-bar', { rootElement: $bar[0] })]).then(function () { + assert.ok(xFooInitCalled); + assert.ok(xFooDidInsertElementCalled); + + assert.ok(xBarInitCalled); + assert.ok(xBarDidInsertElementCalled); + + assert.equal($foo.find('h1').text(), 'X-Foo'); + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 0 times (0 times combined)!'); + assert.ok($foo.text().indexOf('X-Bar') === -1); + + assert.equal($bar.find('h1').text(), 'X-Bar'); + assert.equal($bar.find('button').text(), 'Join 0 others in clicking me!'); + assert.ok($bar.text().indexOf('X-Foo') === -1); + + _emberMetal.run(function () { + return $foo.find('x-foo').click(); + }); + + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (1 times combined)!'); + assert.equal($bar.find('button').text(), 'Join 1 others in clicking me!'); + + _emberMetal.run(function () { + $bar.find('button').click(); + $bar.find('button').click(); + }); + + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (3 times combined)!'); + assert.equal($bar.find('button').text(), 'Join 3 others in clicking me!'); + }); + }); + + QUnit.skip('Test setup', function (assert) {}); + + QUnit.skip('iframe setup', function (assert) {}); +}); +enifed('ember-application/tests/system/visit_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/visit_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/visit_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/test-helpers/registry-check', ['exports'], function (exports) { + 'use strict'; + + exports.verifyRegistration = verifyRegistration; + exports.verifyInjection = verifyInjection; + + function verifyRegistration(owner, fullName) { + ok(owner.resolveRegistration(fullName), 'has registration: ' + fullName); + } + + function verifyInjection(owner, fullName, property, injectionName) { + var registry = owner.__registry__; + var injections = undefined; + + if (fullName.indexOf(':') === -1) { + injections = registry.getTypeInjections(fullName); + } else { + injections = registry.getInjections(registry.normalize(fullName)); + } + + var normalizedName = registry.normalize(injectionName); + var hasInjection = false; + var injection = undefined; + + for (var i = 0, l = injections.length; i < l; i++) { + injection = injections[i]; + if (injection.property === property && injection.fullName === normalizedName) { + hasInjection = true; + break; + } + } + + ok(hasInjection, 'has injection: ' + fullName + '.' + property + ' = ' + injectionName); + } +}); +enifed('ember-application/tests/test-helpers/registry-check.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/test-helpers/registry-check.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/test-helpers/registry-check.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/utils/validate-type.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/utils/validate-type.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/utils/validate-type.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/deprecate.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/deprecate.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/deprecate.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/handlers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/handlers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/handlers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/tests/handlers-test', ['exports', 'ember-debug/handlers'], function (exports, _emberDebugHandlers) { + 'use strict'; + + QUnit.module('ember-debug/handlers', { + teardown: function () { + delete _emberDebugHandlers.HANDLERS.blarz; + } + }); + + QUnit.test('calls handler on `invoke` when `falsey`', function (assert) { + assert.expect(2); + + function handler(message) { + assert.ok(true, 'called handler'); + assert.equal(message, 'Foo bar'); + } + + _emberDebugHandlers.registerHandler('blarz', handler); + + _emberDebugHandlers.invoke('blarz', 'Foo bar', false); + }); + + QUnit.test('does not call handler on `invoke` when `truthy`', function (assert) { + assert.expect(0); + + function handler() { + assert.ok(false, 'called handler'); + } + + _emberDebugHandlers.registerHandler('blarz', handler); + + _emberDebugHandlers.invoke('blarz', 'Foo bar', true); + }); + + QUnit.test('calling `invoke` without handlers does not throw an error', function (assert) { + assert.expect(0); + + _emberDebugHandlers.invoke('blarz', 'Foo bar', false); + }); + + QUnit.test('invoking `next` argument calls the next handler', function (assert) { + assert.expect(2); + + function handler1(message, options, next) { + assert.ok(true, 'called handler1'); + } + + function handler2(message, options, next) { + assert.ok(true, 'called handler2'); + next(message, options); + } + + _emberDebugHandlers.registerHandler('blarz', handler1); + _emberDebugHandlers.registerHandler('blarz', handler2); + + _emberDebugHandlers.invoke('blarz', 'Foo', false); + }); + + QUnit.test('invoking `next` when no other handlers exists does not error', function (assert) { + assert.expect(1); + + function handler(message, options, next) { + assert.ok(true, 'called handler1'); + + next(message, options); + } + + _emberDebugHandlers.registerHandler('blarz', handler); + + _emberDebugHandlers.invoke('blarz', 'Foo', false); + }); + + QUnit.test('handlers are called in the proper order', function (assert) { + assert.expect(11); + + var expectedMessage = 'This is the message'; + var expectedOptions = { id: 'foo-bar' }; + var expected = ['first', 'second', 'third', 'fourth', 'fifth']; + var actualCalls = []; + + function generateHandler(item) { + return function (message, options, next) { + assert.equal(message, expectedMessage, 'message supplied to ' + item + ' handler is correct'); + assert.equal(options, expectedOptions, 'options supplied to ' + item + ' handler is correct'); + + actualCalls.push(item); + + next(message, options); + }; + } + + expected.forEach(function (item) { + return _emberDebugHandlers.registerHandler('blarz', generateHandler(item)); + }); + + _emberDebugHandlers.invoke('blarz', expectedMessage, false, expectedOptions); + + assert.deepEqual(actualCalls, expected.reverse(), 'handlers were called in proper order'); + }); + + QUnit.test('not invoking `next` prevents further handlers from being called', function (assert) { + assert.expect(1); + + function handler1(message, options, next) { + assert.ok(false, 'called handler1'); + } + + function handler2(message, options, next) { + assert.ok(true, 'called handler2'); + } + + _emberDebugHandlers.registerHandler('blarz', handler1); + _emberDebugHandlers.registerHandler('blarz', handler2); + + _emberDebugHandlers.invoke('blarz', 'Foo', false); + }); + + QUnit.test('handlers can call `next` with custom message and/or options', function (assert) { + assert.expect(4); + + var initialMessage = 'initial message'; + var initialOptions = { id: 'initial-options' }; + + var handler2Message = 'Handler2 Message'; + var handler2Options = { id: 'handler-2' }; + + function handler1(message, options, next) { + assert.equal(message, handler2Message, 'handler2 message provided to handler1'); + assert.equal(options, handler2Options, 'handler2 options provided to handler1'); + } + + function handler2(message, options, next) { + assert.equal(message, initialMessage, 'initial message provided to handler2'); + assert.equal(options, initialOptions, 'initial options proivided to handler2'); + + next(handler2Message, handler2Options); + } + + _emberDebugHandlers.registerHandler('blarz', handler1); + _emberDebugHandlers.registerHandler('blarz', handler2); + + _emberDebugHandlers.invoke('blarz', initialMessage, false, initialOptions); + }); +}); +enifed('ember-debug/tests/handlers-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/tests/handlers-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/tests/handlers-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/tests/main_test', ['exports', 'ember-environment', 'ember-runtime', 'ember-debug/handlers', 'ember-debug/deprecate', 'ember-debug/warn', 'ember-metal'], function (exports, _emberEnvironment, _emberRuntime, _emberDebugHandlers, _emberDebugDeprecate, _emberDebugWarn, _emberMetal) { + 'use strict'; + + var originalEnvValue = undefined; + var originalDeprecateHandler = undefined; + + QUnit.module('ember-debug', { + setup: function () { + originalEnvValue = _emberEnvironment.ENV.RAISE_ON_DEPRECATION; + originalDeprecateHandler = _emberDebugHandlers.HANDLERS.deprecate; + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = true; + }, + + teardown: function () { + _emberDebugHandlers.HANDLERS.deprecate = originalDeprecateHandler; + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = originalEnvValue; + } + }); + + QUnit.test('Ember.deprecate does not throw if RAISE_ON_DEPRECATION is false', function (assert) { + assert.expect(1); + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = false; + + try { + _emberMetal.deprecate('Should not throw', false, { id: 'test', until: 'forever' }); + assert.ok(true, 'Ember.deprecate did not throw'); + } catch (e) { + assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message); + } + }); + + QUnit.test('Ember.deprecate resets deprecation level to RAISE if ENV.RAISE_ON_DEPRECATION is set', function (assert) { + assert.expect(2); + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = false; + + try { + _emberMetal.deprecate('Should not throw', false, { id: 'test', until: 'forever' }); + assert.ok(true, 'Ember.deprecate did not throw'); + } catch (e) { + assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message); + } + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = true; + + assert.throws(function () { + _emberMetal.deprecate('Should throw', false, { id: 'test', until: 'forever' }); + }, /Should throw/); + }); + + QUnit.test('When ENV.RAISE_ON_DEPRECATION is true, it is still possible to silence a deprecation by id', function (assert) { + assert.expect(3); + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = true; + _emberDebugDeprecate.registerHandler(function (message, options, next) { + if (!options || options.id !== 'my-deprecation') { + next.apply(undefined, arguments); + } + }); + + try { + _emberMetal.deprecate('should be silenced with matching id', false, { id: 'my-deprecation', until: 'forever' }); + assert.ok(true, 'Did not throw when level is set by id'); + } catch (e) { + assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message); + } + + assert.throws(function () { + _emberMetal.deprecate('Should throw with no matching id', false, { id: 'test', until: 'forever' }); + }, /Should throw with no matching id/); + + assert.throws(function () { + _emberMetal.deprecate('Should throw with non-matching id', false, { id: 'other-id', until: 'forever' }); + }, /Should throw with non-matching id/); + }); + + QUnit.test('Ember.deprecate throws deprecation if second argument is falsy', function () { + expect(3); + + throws(function () { + return _emberMetal.deprecate('Deprecation is thrown', false, { id: 'test', until: 'forever' }); + }); + throws(function () { + return _emberMetal.deprecate('Deprecation is thrown', '', { id: 'test', until: 'forever' }); + }); + throws(function () { + return _emberMetal.deprecate('Deprecation is thrown', 0, { id: 'test', until: 'forever' }); + }); + }); + + QUnit.test('Ember.deprecate does not invoke a function as the second argument', function () { + expect(1); + + _emberMetal.deprecate('Deprecation is thrown', function () { + ok(false, 'this function should not be invoked'); + }, { id: 'test', until: 'forever' }); + + ok(true, 'deprecations were not thrown'); + }); + + QUnit.test('Ember.deprecate does not throw deprecations if second argument is truthy', function () { + expect(1); + + _emberMetal.deprecate('Deprecation is thrown', true, { id: 'test', until: 'forever' }); + _emberMetal.deprecate('Deprecation is thrown', '1', { id: 'test', until: 'forever' }); + _emberMetal.deprecate('Deprecation is thrown', 1, { id: 'test', until: 'forever' }); + + ok(true, 'deprecations were not thrown'); + }); + + QUnit.test('Ember.assert throws if second argument is falsy', function () { + expect(3); + + throws(function () { + return _emberMetal.assert('Assertion is thrown', false); + }); + throws(function () { + return _emberMetal.assert('Assertion is thrown', ''); + }); + throws(function () { + return _emberMetal.assert('Assertion is thrown', 0); + }); + }); + + QUnit.test('Ember.assert does not throw if second argument is a function', function (assert) { + assert.expect(1); + + _emberMetal.assert('Assertion is thrown', function () { + return true; + }); + + ok(true, 'assertions were not thrown'); + }); + + QUnit.test('Ember.assert does not throw if second argument is truthy', function () { + expect(1); + + _emberMetal.assert('Assertion is thrown', true); + _emberMetal.assert('Assertion is thrown', '1'); + _emberMetal.assert('Assertion is thrown', 1); + + ok(true, 'assertions were not thrown'); + }); + + QUnit.test('Ember.assert does not throw if second argument is an object', function () { + expect(1); + var Igor = _emberRuntime.Object.extend(); + + _emberMetal.assert('is truthy', Igor); + _emberMetal.assert('is truthy', Igor.create()); + + ok(true, 'assertions were not thrown'); + }); + + QUnit.test('Ember.deprecate does not throw a deprecation at log and silence levels', function () { + expect(4); + var id = 'ABC'; + var until = 'forever'; + var shouldThrow = false; + + _emberDebugDeprecate.registerHandler(function (message, options, next) { + if (options && options.id === id) { + if (shouldThrow) { + throw new Error(message); + } + } + }); + + try { + _emberMetal.deprecate('Deprecation for testing purposes', false, { id: id, until: until }); + ok(true, 'Deprecation did not throw'); + } catch (e) { + ok(false, 'Deprecation was thrown despite being added to blacklist'); + } + + try { + _emberMetal.deprecate('Deprecation for testing purposes', false, { id: id, until: until }); + ok(true, 'Deprecation did not throw'); + } catch (e) { + ok(false, 'Deprecation was thrown despite being added to blacklist'); + } + + shouldThrow = true; + + throws(function () { + _emberMetal.deprecate('Deprecation is thrown', false, { id: id, until: until }); + }); + + throws(function () { + _emberMetal.deprecate('Deprecation is thrown', false, { id: id, until: until }); + }); + }); + + QUnit.test('Ember.deprecate without options triggers a deprecation', function (assert) { + assert.expect(4); + + _emberDebugDeprecate.registerHandler(function (message) { + if (message === _emberDebugDeprecate.missingOptionsDeprecation) { + assert.ok(true, 'proper deprecation is triggered when options is missing'); + } else if (message === 'foo') { + assert.ok(true, 'original deprecation is still triggered'); + } + }); + + _emberMetal.deprecate('foo'); + _emberMetal.deprecate('foo', false, {}); + }); + + QUnit.test('Ember.deprecate without options.id triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + if (message === _emberDebugDeprecate.missingOptionsIdDeprecation) { + assert.ok(true, 'proper deprecation is triggered when options.id is missing'); + } else if (message === 'foo') { + assert.ok(true, 'original deprecation is still triggered'); + } + }); + + _emberMetal.deprecate('foo', false, { until: 'forever' }); + }); + + QUnit.test('Ember.deprecate without options.until triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + if (message === _emberDebugDeprecate.missingOptionsUntilDeprecation) { + assert.ok(true, 'proper deprecation is triggered when options.until is missing'); + } else if (message === 'foo') { + assert.ok(true, 'original deprecation is still triggered'); + } + }); + + _emberMetal.deprecate('foo', false, { id: 'test' }); + }); + + QUnit.test('warn without options triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + assert.equal(message, _emberDebugWarn.missingOptionsDeprecation, 'deprecation is triggered when options is missing'); + }); + + _emberDebugWarn.registerHandler(function (message) { + assert.equal(message, 'foo', 'original warning is triggered'); + }); + + _emberMetal.warn('foo'); + }); + + QUnit.test('warn without options.id triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + assert.equal(message, _emberDebugWarn.missingOptionsIdDeprecation, 'deprecation is triggered when options is missing'); + }); + + _emberDebugWarn.registerHandler(function (message) { + assert.equal(message, 'foo', 'original warning is triggered'); + }); + + _emberMetal.warn('foo', false, {}); + }); +}); +enifed('ember-debug/tests/main_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/tests/main_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/tests/main_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/tests/warn_if_using_stripped_feature_flags_test', ['exports', 'ember-environment', 'ember-metal', 'ember-debug/index'], function (exports, _emberEnvironment, _emberMetal, _emberDebugIndex) { + 'use strict'; + + var oldWarn = undefined, + oldRunInDebug = undefined, + origEnvFeatures = undefined, + origEnableOptional = undefined, + features = undefined, + knownFeatures = undefined; + + function confirmWarns(expectedMsg) { + var featuresWereStripped = true; + + _emberMetal.setDebugFunction('warn', function (msg, test) { + if (!test) { + equal(msg, expectedMsg); + } + }); + + _emberMetal.setDebugFunction('runInDebug', function (func) { + func(); + }); + + // Should trigger our 1 warning + _emberDebugIndex._warnIfUsingStrippedFeatureFlags(features, knownFeatures, featuresWereStripped); + + // Shouldn't trigger any warnings now that we're "in canary" + featuresWereStripped = false; + _emberDebugIndex._warnIfUsingStrippedFeatureFlags(features, knownFeatures, featuresWereStripped); + } + + QUnit.module('ember-debug - _warnIfUsingStrippedFeatureFlags', { + setup: function () { + oldWarn = _emberMetal.getDebugFunction('warn'); + oldRunInDebug = _emberMetal.getDebugFunction('runInDebug'); + origEnvFeatures = _emberEnvironment.ENV.FEATURES; + origEnableOptional = _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES; + + knownFeatures = { + 'fred': null, + 'barney': null, + 'wilma': null + }; + }, + + teardown: function () { + _emberMetal.setDebugFunction('warn', oldWarn); + _emberMetal.setDebugFunction('runInDebug', oldRunInDebug); + _emberEnvironment.ENV.FEATURES = origEnvFeatures; + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = origEnableOptional; + } + }); + + QUnit.test('Setting Ember.ENV.ENABLE_OPTIONAL_FEATURES truthy in non-canary, debug build causes a warning', function () { + expect(1); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = true; + features = {}; + + confirmWarns('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.'); + }); + + QUnit.test('Enabling a known FEATURE flag in non-canary, debug build causes a warning', function () { + expect(1); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false; + features = { + 'fred': true, + 'barney': false, + 'wilma': null + }; + + confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.'); + }); + + QUnit.test('Enabling an unknown FEATURE flag in non-canary debug build does not cause a warning', function () { + expect(0); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false; + features = { + 'some-ember-data-feature-flag': true + }; + + confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.'); + }); + + QUnit.test('`ENV.FEATURES` being undefined does not cause an error', function () { + expect(0); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false; + features = undefined; + + confirmWarns(); + }); +}); +enifed('ember-debug/tests/warn_if_using_stripped_feature_flags_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/tests/warn_if_using_stripped_feature_flags_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/tests/warn_if_using_stripped_feature_flags_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/warn.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/warn.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/warn.js should pass ESLint\n\n'); + }); +}); +enifed('ember-dev/test-helper/assertion', ['exports', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperUtils) { + 'use strict'; + + exports.default = AssertionAssert; + + /* globals QUnit */ + + var BREAK = {}; + + /** + This assertion class is used to test assertions made using Ember.assert. + It injects two helpers onto `window`: + + - expectAssertion(func: Function, [expectedMessage: String | RegExp]) + + This function calls `func` and asserts that `Ember.assert` is invoked during + the execution. Moreover, it takes a String or a RegExp as a second optional + argument that can be used to test if a specific assertion message was + generated. + + - ignoreAssertion(func: Function) + + This function calls `func` and disables `Ember.assert` during the execution. + In particular, this prevents `Ember.assert` from throw errors that would + disrupt the control flow. + */ + function AssertionAssert(env) { + this.env = env; + } + + AssertionAssert.prototype = { + reset: function reset() {}, + assert: function assert() {}, + + inject: function inject() { + var _this = this; + + var expectAssertion = function expectAssertion(func, expectedMessage) { + if (_this.env.runningProdBuild) { + QUnit.ok(true, 'Assertions disabled in production builds.'); + return; + } + + var sawCall = undefined; + var actualMessage = undefined; + + // The try-catch statement is used to "exit" `func` as soon as + // the first useful assertion has been produced. + try { + _emberDevTestHelperUtils.callWithStub(_this.env, 'assert', func, function (message, test) { + sawCall = true; + if (_emberDevTestHelperUtils.checkTest(test)) { + return; + } + actualMessage = message; + throw BREAK; + }); + } catch (e) { + if (e !== BREAK) { + throw e; + } + } + + assert(sawCall, actualMessage, expectedMessage); + }; + + var ignoreAssertion = function ignoreAssertion(func) { + _emberDevTestHelperUtils.callWithStub(_this.env, 'assert', func); + }; + + window.expectAssertion = expectAssertion; + window.ignoreAssertion = ignoreAssertion; + }, + + restore: function restore() { + window.expectAssertion = null; + window.ignoreAssertion = null; + } + }; + + function assert(sawCall, actualMessage, expectedMessage) { + // Run assertions in an order that is useful when debugging a test failure. + if (!sawCall) { + QUnit.ok(false, 'Expected Ember.assert to be called (Not called with any value).'); + } else if (!actualMessage) { + QUnit.ok(false, 'Expected a failing Ember.assert (Ember.assert called, but without a failing test).'); + } else { + if (expectedMessage) { + if (expectedMessage instanceof RegExp) { + QUnit.ok(expectedMessage.test(actualMessage), 'Expected failing Ember.assert: \'' + expectedMessage + '\', but got \'' + actualMessage + '\'.'); + } else { + QUnit.equal(actualMessage, expectedMessage, 'Expected failing Ember.assert: \'' + expectedMessage + '\', but got \'' + actualMessage + '\'.'); + } + } else { + // Positive assertion that assert was called + QUnit.ok(true, 'Expected a failing Ember.assert.'); + } + } + } +}); +enifed('ember-dev/test-helper/debug', ['exports', 'ember-dev/test-helper/method-call-tracker'], function (exports, _emberDevTestHelperMethodCallTracker) { + 'use strict'; + + var _createClass = (function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + })(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } + } + + var DebugAssert = (function () { + function DebugAssert(methodName, env) { + _classCallCheck(this, DebugAssert); + + this.methodName = methodName; + this.env = env; + } + + _createClass(DebugAssert, [{ + key: 'inject', + value: function inject() {} + }, { + key: 'restore', + value: function restore() { + this.reset(); + } + }, { + key: 'reset', + value: function reset() { + if (this.tracker) { + this.tracker.restoreMethod(); + } + + this.tracker = null; + } + }, { + key: 'assert', + value: function assert() { + if (this.tracker) { + this.tracker.assert(); + } + } + + // Run an expectation callback within the context of a new tracker, optionally + // accepting a function to run, which asserts immediately + }, { + key: 'runExpectation', + value: function runExpectation(func, callback) { + var originalTracker = undefined; + + // When helpers are passed a callback, they get a new tracker context + if (func) { + originalTracker = this.tracker; + this.tracker = null; + } + + if (!this.tracker) { + this.tracker = new _emberDevTestHelperMethodCallTracker.default(this.env, this.methodName); + } + + // Yield to caller with tracker instance + callback(this.tracker); + + // Once the given callback is invoked, the pending assertions should be + // flushed immediately + if (func) { + func(); + this.assert(); + this.reset(); + + this.tracker = originalTracker; + } + } + }]); + + return DebugAssert; + })(); + + exports.default = DebugAssert; +}); +enifed('ember-dev/test-helper/deprecation', ['exports', 'ember-dev/test-helper/debug', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperDebug, _emberDevTestHelperUtils) { + 'use strict'; + + var _createClass = (function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + })(); + + var _get = function get(_x, _x2, _x3) { + var _again = true;_function: while (_again) { + var object = _x, + property = _x2, + receiver = _x3;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) { + var parent = Object.getPrototypeOf(object);if (parent === null) { + return undefined; + } else { + _x = parent;_x2 = property;_x3 = receiver;_again = true;desc = parent = undefined;continue _function; + } + } else if ('value' in desc) { + return desc.value; + } else { + var getter = desc.get;if (getter === undefined) { + return undefined; + }return getter.call(receiver); + } + } + }; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : babelHelpers.defaults(subClass, superClass); + } + + var DeprecationAssert = (function (_DebugAssert) { + _inherits(DeprecationAssert, _DebugAssert); + + function DeprecationAssert(env) { + _classCallCheck(this, DeprecationAssert); + + _get(Object.getPrototypeOf(DeprecationAssert.prototype), 'constructor', this).call(this, 'deprecate', env); + } + + _createClass(DeprecationAssert, [{ + key: 'inject', + value: function inject() { + var _this = this; + + // Expects no deprecation to happen within a function, or if no function is + // passed, from the time of calling until the end of the test. + // + // expectNoDeprecation(function() { + // fancyNewThing(); + // }); + // + // expectNoDeprecation(); + // Ember.deprecate("Old And Busted"); + // + var expectNoDeprecation = function expectNoDeprecation(func) { + if (typeof func !== 'function') { + func = null; + } + + _this.runExpectation(func, function (tracker) { + if (tracker.isExpectingCalls()) { + throw new Error("expectNoDeprecation was called after expectDeprecation was called!"); + } + + tracker.expectNoCalls(); + }); + }; + + // Expect a deprecation to happen within a function, or if no function + // is pass, from the time of calling until the end of the test. Can be called + // multiple times to assert deprecations with different specific messages + // were fired. + // + // expectDeprecation(function() { + // Ember.deprecate("Old And Busted"); + // }, /* optionalStringOrRegex */); + // + // expectDeprecation(/* optionalStringOrRegex */); + // Ember.deprecate("Old And Busted"); + // + var expectDeprecation = function expectDeprecation(func, message) { + if (typeof func !== 'function') { + message = func; + func = null; + } + + _this.runExpectation(func, function (tracker) { + if (tracker.isExpectingNoCalls()) { + throw new Error("expectDeprecation was called after expectNoDeprecation was called!"); + } + + tracker.expectCall(message); + }); + }; + + var ignoreDeprecation = function ignoreDeprecation(func) { + _emberDevTestHelperUtils.callWithStub(_this.env, 'deprecate', func); + }; + + window.expectNoDeprecation = expectNoDeprecation; + window.expectDeprecation = expectDeprecation; + window.ignoreDeprecation = ignoreDeprecation; + } + }, { + key: 'restore', + value: function restore() { + _get(Object.getPrototypeOf(DeprecationAssert.prototype), 'restore', this).call(this); + window.expectDeprecation = null; + window.expectNoDeprecation = null; + window.ignoreDeprecation = null; + } + }]); + + return DeprecationAssert; + })(_emberDevTestHelperDebug.default); + + exports.default = DeprecationAssert; +}); +enifed("ember-dev/test-helper/index", ["exports", "ember-dev/test-helper/deprecation", "ember-dev/test-helper/warning", "ember-dev/test-helper/remaining-view", "ember-dev/test-helper/remaining-template", "ember-dev/test-helper/assertion", "ember-dev/test-helper/run-loop", "ember-dev/test-helper/utils"], function (exports, _emberDevTestHelperDeprecation, _emberDevTestHelperWarning, _emberDevTestHelperRemainingView, _emberDevTestHelperRemainingTemplate, _emberDevTestHelperAssertion, _emberDevTestHelperRunLoop, _emberDevTestHelperUtils) { + "use strict"; + + var EmberDevTestHelperAssert = _emberDevTestHelperUtils.buildCompositeAssert([_emberDevTestHelperDeprecation.default, _emberDevTestHelperWarning.default, _emberDevTestHelperRemainingView.default, _emberDevTestHelperRemainingTemplate.default, _emberDevTestHelperAssertion.default, _emberDevTestHelperRunLoop.default]); + + exports.default = EmberDevTestHelperAssert; +}); +enifed('ember-dev/test-helper/method-call-tracker', ['exports', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperUtils) { + /* globals QUnit */ + + 'use strict'; + + var MethodCallTracker = function MethodCallTracker(env, methodName) { + this._env = env; + this._methodName = methodName; + this._isExpectingNoCalls = false; + this._expecteds = []; + this._actuals = []; + }; + + MethodCallTracker.prototype = { + stubMethod: function stubMethod() { + var _this = this; + + if (this._originalMethod) { + // Method is already stubbed + return; + } + + var env = this._env; + var methodName = this._methodName; + + this._originalMethod = env.getDebugFunction(methodName); + + env.setDebugFunction(methodName, function (message, test) { + var resultOfTest = _emberDevTestHelperUtils.checkTest(test); + + _this._actuals.push([message, resultOfTest]); + }); + }, + + restoreMethod: function restoreMethod() { + if (this._originalMethod) { + this._env.setDebugFunction(this._methodName, this._originalMethod); + } + }, + + expectCall: function expectCall(message) { + this.stubMethod(); + this._expecteds.push(message || /.*/); + }, + + expectNoCalls: function expectNoCalls() { + this.stubMethod(); + this._isExpectingNoCalls = true; + }, + + isExpectingNoCalls: function isExpectingNoCalls() { + return this._isExpectingNoCalls; + }, + + isExpectingCalls: function isExpectingCalls() { + return !this._isExpectingNoCalls && this._expecteds.length; + }, + + assert: function assert() { + var env = this._env; + var methodName = this._methodName; + var isExpectingNoCalls = this._isExpectingNoCalls; + var expecteds = this._expecteds; + var actuals = this._actuals; + var o = undefined, + i = undefined; + + if (!isExpectingNoCalls && expecteds.length === 0 && actuals.length === 0) { + return; + } + + if (env.runningProdBuild) { + QUnit.ok(true, 'calls to Ember.' + methodName + ' disabled in production builds.'); + return; + } + + if (isExpectingNoCalls) { + var actualMessages = []; + for (i = 0; i < actuals.length; i++) { + if (!actuals[i][1]) { + actualMessages.push(actuals[i][0]); + } + } + QUnit.ok(actualMessages.length === 0, 'Expected no Ember.' + methodName + ' calls, got ' + actuals.length + ': ' + actualMessages.join(', ')); + return; + } + + var expected = undefined, + actual = undefined, + match = undefined; + + for (o = 0; o < expecteds.length; o++) { + expected = expecteds[o]; + for (i = 0; i < actuals.length; i++) { + actual = actuals[i]; + if (!actual[1]) { + if (expected instanceof RegExp) { + if (expected.test(actual[0])) { + match = actual; + break; + } + } else { + if (expected === actual[0]) { + match = actual; + break; + } + } + } + } + + if (!actual) { + QUnit.ok(false, 'Received no Ember.' + methodName + ' calls at all, expecting: ' + expected); + } else if (match && !match[1]) { + QUnit.ok(true, 'Received failing Ember.' + methodName + ' call with message: ' + match[0]); + } else if (match && match[1]) { + QUnit.ok(false, 'Expected failing Ember.' + methodName + ' call, got succeeding with message: ' + match[0]); + } else if (actual[1]) { + QUnit.ok(false, 'Did not receive failing Ember.' + methodName + ' call matching \'' + expected + '\', last was success with \'' + actual[0] + '\''); + } else if (!actual[1]) { + QUnit.ok(false, 'Did not receive failing Ember.' + methodName + ' call matching \'' + expected + '\', last was failure with \'' + actual[0] + '\''); + } + } + } + }; + + exports.default = MethodCallTracker; +}); +enifed("ember-dev/test-helper/remaining-template", ["exports"], function (exports) { + /* globals QUnit */ + + "use strict"; + + var RemainingTemplateAssert = function RemainingTemplateAssert(env) { + this.env = env; + }; + + RemainingTemplateAssert.prototype = { + reset: function reset() {}, + inject: function inject() {}, + assert: function assert() { + if (this.env.Ember && this.env.Ember.TEMPLATES) { + var templateNames = [], + name; + for (name in this.env.Ember.TEMPLATES) { + if (this.env.Ember.TEMPLATES[name] != null) { + templateNames.push(name); + } + } + + if (templateNames.length > 0) { + QUnit.deepEqual(templateNames, [], "Ember.TEMPLATES should be empty"); + this.env.Ember.TEMPLATES = {}; + } + } + }, + restore: function restore() {} + }; + + exports.default = RemainingTemplateAssert; +}); +enifed("ember-dev/test-helper/remaining-view", ["exports"], function (exports) { + /* globals QUnit */ + + "use strict"; + + var RemainingViewAssert = function RemainingViewAssert(env) { + this.env = env; + }; + + RemainingViewAssert.prototype = { + reset: function reset() {}, + inject: function inject() {}, + assert: function assert() { + if (this.env.Ember && this.env.Ember.View) { + var viewIds = [], + id; + for (id in this.env.Ember.View.views) { + if (this.env.Ember.View.views[id] != null) { + viewIds.push(id); + } + } + + if (viewIds.length > 0) { + QUnit.deepEqual(viewIds, [], "Ember.View.views should be empty"); + this.env.Ember.View.views = []; + } + } + }, + restore: function restore() {} + }; + + exports.default = RemainingViewAssert; +}); +enifed("ember-dev/test-helper/run-loop", ["exports"], function (exports) { + /* globals QUnit */ + + "use strict"; + + function RunLoopAssertion(env) { + this.env = env; + } + + RunLoopAssertion.prototype = { + reset: function reset() {}, + inject: function inject() {}, + assert: function assert() { + var run = this.env.Ember.run; + + if (run.currentRunLoop) { + QUnit.ok(false, "Should not be in a run loop at end of test"); + while (run.currentRunLoop) { + run.end(); + } + } + + if (run.hasScheduledTimers()) { + QUnit.ok(false, "Ember run should not have scheduled timers at end of test"); + run.cancelTimers(); + } + }, + restore: function restore() {} + }; + + exports.default = RunLoopAssertion; +}); +enifed("ember-dev/test-helper/setup-qunit", ["exports"], function (exports) { + "use strict"; + + exports.default = setupQUnit; + + /* globals QUnit */ + function setupQUnit(assertion, _qunitGlobal) { + var qunitGlobal = QUnit; + + if (_qunitGlobal) { + qunitGlobal = _qunitGlobal; + } + + var originalModule = qunitGlobal.module; + + qunitGlobal.module = function (name, _options) { + var options = _options || {}; + var originalSetup = options.setup || function () {}; + var originalTeardown = options.teardown || function () {}; + + options.setup = function () { + assertion.reset(); + assertion.inject(); + + originalSetup.apply(this, arguments); + }; + + options.teardown = function () { + originalTeardown.apply(this, arguments); + + assertion.assert(); + assertion.restore(); + }; + + return originalModule(name, options); + }; + } +}); +enifed('ember-dev/test-helper/utils', ['exports'], function (exports) { + 'use strict'; + + exports.buildCompositeAssert = buildCompositeAssert; + exports.callWithStub = callWithStub; + exports.checkTest = checkTest; + + function callForEach(prop, func) { + return function () { + for (var i = 0, l = this[prop].length; i < l; i++) { + this[prop][i][func](); + } + }; + } + + function buildCompositeAssert(assertClasses) { + function Composite(env) { + this.asserts = assertClasses.map(function (Assert) { + return new Assert(env); + }); + } + + Composite.prototype = { + reset: callForEach('asserts', 'reset'), + inject: callForEach('asserts', 'inject'), + assert: callForEach('asserts', 'assert'), + restore: callForEach('asserts', 'restore') + }; + + return Composite; + } + + function noop() {} + + function callWithStub(env, name, func) { + var debugStub = arguments.length <= 3 || arguments[3] === undefined ? noop : arguments[3]; + + var originalFunc = env.getDebugFunction(name); + try { + env.setDebugFunction(name, debugStub); + func(); + } finally { + env.setDebugFunction(name, originalFunc); + } + } + + function checkTest(test) { + return typeof test === 'function' ? test() : test; + } +}); +enifed('ember-dev/test-helper/warning', ['exports', 'ember-dev/test-helper/debug', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperDebug, _emberDevTestHelperUtils) { + 'use strict'; + + var _createClass = (function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + })(); + + var _get = function get(_x, _x2, _x3) { + var _again = true;_function: while (_again) { + var object = _x, + property = _x2, + receiver = _x3;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) { + var parent = Object.getPrototypeOf(object);if (parent === null) { + return undefined; + } else { + _x = parent;_x2 = property;_x3 = receiver;_again = true;desc = parent = undefined;continue _function; + } + } else if ('value' in desc) { + return desc.value; + } else { + var getter = desc.get;if (getter === undefined) { + return undefined; + }return getter.call(receiver); + } + } + }; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : babelHelpers.defaults(subClass, superClass); + } + + var WarningAssert = (function (_DebugAssert) { + _inherits(WarningAssert, _DebugAssert); + + function WarningAssert(env) { + _classCallCheck(this, WarningAssert); + + _get(Object.getPrototypeOf(WarningAssert.prototype), 'constructor', this).call(this, 'warn', env); + } + + _createClass(WarningAssert, [{ + key: 'inject', + value: function inject() { + var _this = this; + + // Expects no warning to happen within a function, or if no function is + // passed, from the time of calling until the end of the test. + // + // expectNoWarning(function() { + // fancyNewThing(); + // }); + // + // expectNoWarning(); + // Ember.warn("Oh snap, didn't expect that"); + // + var expectNoWarning = function expectNoWarning(func) { + if (typeof func !== 'function') { + func = null; + } + + _this.runExpectation(func, function (tracker) { + if (tracker.isExpectingCalls()) { + throw new Error("expectNoWarning was called after expectWarning was called!"); + } + + tracker.expectNoCalls(); + }); + }; + + // Expect a warning to happen within a function, or if no function is + // passed, from the time of calling until the end of the test. Can be called + // multiple times to assert warnings with different specific messages + // happened. + // + // expectWarning(function() { + // Ember.warn("Times they are a-changin'"); + // }, /* optionalStringOrRegex */); + // + // expectWarning(/* optionalStringOrRegex */); + // Ember.warn("Times definitely be changin'"); + // + var expectWarning = function expectWarning(fn, message) { + if (typeof fn !== 'function') { + message = fn; + fn = null; + } + + _this.runExpectation(fn, function (tracker) { + if (tracker.isExpectingNoCalls()) { + throw new Error("expectWarning was called after expectNoWarning was called!"); + } + + tracker.expectCall(message); + }); + }; + + var ignoreWarning = function ignoreWarning(func) { + _emberDevTestHelperUtils.callWithStub(_this.env, 'warn', func); + }; + + window.expectNoWarning = expectNoWarning; + window.expectWarning = expectWarning; + window.ignoreWarning = ignoreWarning; + } + }, { + key: 'restore', + value: function restore() { + _get(Object.getPrototypeOf(WarningAssert.prototype), 'restore', this).call(this); + window.expectWarning = null; + window.expectNoWarning = null; + window.ignoreWarning = null; + } + }]); + + return WarningAssert; + })(_emberDevTestHelperDebug.default); + + exports.default = WarningAssert; +}); +enifed('ember-extension-support/container_debug_adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/container_debug_adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/container_debug_adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/data_adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/data_adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/data_adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/tests/container_debug_adapter_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-extension-support/index', 'ember-application'], function (exports, _emberMetal, _emberRuntime, _emberExtensionSupportIndex, _emberApplication) { + 'use strict'; + + var adapter = undefined, + App = undefined, + appInstance = undefined; + + function boot() { + _emberMetal.run(App, 'advanceReadiness'); + } + + QUnit.module('Container Debug Adapter', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); // ES6TODO: this comes from the ember-application package NOT ember-runtime. + App.toString = function () { + return 'App'; + }; + App.deferReadiness(); + }); + boot(); + _emberMetal.run(function () { + appInstance = App.__deprecatedInstance__; + adapter = appInstance.lookup('container-debug-adapter:main'); + }); + }, + teardown: function () { + _emberMetal.run(function () { + adapter.destroy(); + appInstance.destroy(); + App.destroy(); + App = appInstance = adapter = null; + }); + } + }); + + QUnit.test('the default ContainerDebugAdapter cannot catalog certain entries by type', function () { + equal(adapter.canCatalogEntriesByType('model'), false, 'canCatalogEntriesByType should return false for model'); + equal(adapter.canCatalogEntriesByType('template'), false, 'canCatalogEntriesByType should return false for template'); + }); + + QUnit.test('the default ContainerDebugAdapter can catalog typical entries by type', function () { + equal(adapter.canCatalogEntriesByType('controller'), true, 'canCatalogEntriesByType should return true for controller'); + equal(adapter.canCatalogEntriesByType('route'), true, 'canCatalogEntriesByType should return true for route'); + equal(adapter.canCatalogEntriesByType('view'), true, 'canCatalogEntriesByType should return true for view'); + }); + + QUnit.test('the default ContainerDebugAdapter catalogs controller entries', function () { + App.PostController = _emberRuntime.Controller.extend(); + var controllerClasses = adapter.catalogEntriesByType('controller'); + + equal(controllerClasses.length, 1, 'found 1 class'); + equal(controllerClasses[0], 'post', 'found the right class'); + }); +}); +// Must be required to export Ember.ContainerDebugAdapter. +enifed('ember-extension-support/tests/container_debug_adapter_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/tests/container_debug_adapter_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/tests/container_debug_adapter_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/tests/data_adapter_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-extension-support/data_adapter', 'ember-application'], function (exports, _emberMetal, _emberRuntime, _emberExtensionSupportData_adapter, _emberApplication) { + 'use strict'; + + var adapter = undefined, + App = undefined; + var Model = _emberRuntime.Object.extend(); + + var DataAdapter = _emberExtensionSupportData_adapter.default.extend({ + detect: function (klass) { + return klass !== Model && Model.detect(klass); + } + }); + + QUnit.module('Data Adapter', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.toString = function () { + return 'App'; + }; + App.deferReadiness(); + App.register('data-adapter:main', DataAdapter); + }); + }, + teardown: function () { + _emberMetal.run(function () { + adapter.destroy(); + App.destroy(); + }); + } + }); + + QUnit.test('Model types added with DefaultResolver', function () { + App.Post = Model.extend(); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return _emberRuntime.A([1, 2, 3]); + }, + columnsForType: function () { + return [{ name: 'title', desc: 'Title' }]; + } + }); + + _emberMetal.run(App, 'advanceReadiness'); + + function modelTypesAdded(types) { + equal(types.length, 1); + var postType = types[0]; + equal(postType.name, 'post', 'Correctly sets the name'); + equal(postType.count, 3, 'Correctly sets the record count'); + strictEqual(postType.object, App.Post, 'Correctly sets the object'); + deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); + } + + _emberMetal.run(adapter, 'watchModelTypes', modelTypesAdded); + }); + + QUnit.test('getRecords gets a model name as second argument', function () { + App.Post = Model.extend(); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function (klass, name) { + equal(name, 'post'); + return _emberRuntime.A(); + } + }); + + adapter.watchModelTypes(function () {}); + }); + + QUnit.test('Model types added with custom container-debug-adapter', function () { + var PostClass = Model.extend(); + var StubContainerDebugAdapter = _emberApplication.Resolver.extend({ + canCatalogEntriesByType: function (type) { + return true; + }, + catalogEntriesByType: function (type) { + return [PostClass]; + } + }); + App.register('container-debug-adapter:main', StubContainerDebugAdapter); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return _emberRuntime.A([1, 2, 3]); + }, + columnsForType: function () { + return [{ name: 'title', desc: 'Title' }]; + } + }); + + _emberMetal.run(App, 'advanceReadiness'); + + function modelTypesAdded(types) { + equal(types.length, 1); + var postType = types[0]; + + equal(postType.name, PostClass.toString(), 'Correctly sets the name'); + equal(postType.count, 3, 'Correctly sets the record count'); + strictEqual(postType.object, PostClass, 'Correctly sets the object'); + deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); + } + + _emberMetal.run(adapter, 'watchModelTypes', modelTypesAdded); + }); + + QUnit.test('Model Types Updated', function () { + App.Post = Model.extend(); + + adapter = App.__container__.lookup('data-adapter:main'); + var records = _emberRuntime.A([1, 2, 3]); + adapter.reopen({ + getRecords: function () { + return records; + } + }); + + _emberMetal.run(App, 'advanceReadiness'); + + function modelTypesAdded() { + _emberMetal.run(function () { + records.pushObject(4); + }); + } + + function modelTypesUpdated(types) { + var postType = types[0]; + equal(postType.count, 4, 'Correctly updates the count'); + } + + _emberMetal.run(adapter, 'watchModelTypes', modelTypesAdded, modelTypesUpdated); + }); + + QUnit.test('Records Added', function () { + expect(8); + var countAdded = 1; + + App.Post = Model.extend(); + + var post = App.Post.create(); + var recordList = _emberRuntime.A([post]); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return recordList; + }, + getRecordColor: function () { + return 'blue'; + }, + getRecordColumnValues: function () { + return { title: 'Post ' + countAdded }; + }, + getRecordKeywords: function () { + return ['Post ' + countAdded]; + } + }); + + function recordsAdded(records) { + var record = records[0]; + equal(record.color, 'blue', 'Sets the color correctly'); + deepEqual(record.columnValues, { title: 'Post ' + countAdded }, 'Sets the column values correctly'); + deepEqual(record.searchKeywords, ['Post ' + countAdded], 'Sets search keywords correctly'); + strictEqual(record.object, post, 'Sets the object to the record instance'); + } + + adapter.watchRecords(App.Post, recordsAdded); + countAdded++; + post = App.Post.create(); + recordList.pushObject(post); + }); + + QUnit.test('Observes and releases a record correctly', function () { + var updatesCalled = 0; + App.Post = Model.extend(); + + var post = App.Post.create({ title: 'Post' }); + var recordList = _emberRuntime.A([post]); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return recordList; + }, + observeRecord: function (record, recordUpdated) { + var self = this; + function callback() { + recordUpdated(self.wrapRecord(record)); + } + _emberMetal.addObserver(record, 'title', callback); + return function () { + _emberMetal.removeObserver(record, 'title', callback); + }; + }, + getRecordColumnValues: function (record) { + return { title: _emberMetal.get(record, 'title') }; + } + }); + + function recordsAdded() { + _emberMetal.set(post, 'title', 'Post Modified'); + } + + function recordsUpdated(records) { + updatesCalled++; + equal(records[0].columnValues.title, 'Post Modified'); + } + + var release = adapter.watchRecords(App.Post, recordsAdded, recordsUpdated); + release(); + _emberMetal.set(post, 'title', 'New Title'); + equal(updatesCalled, 1, 'Release function removes observers'); + }); +}); +enifed('ember-extension-support/tests/data_adapter_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/tests/data_adapter_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/tests/data_adapter_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/checkbox.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/checkbox.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/checkbox.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/link-to.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/link-to.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/link-to.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/text_area.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/text_area.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/text_area.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/text_field.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/text_field.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/text_field.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/dom.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/dom.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/dom.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/environment.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/environment.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/environment.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helper.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helper.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helper.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-class.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-class.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-class.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-html-safe.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-html-safe.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-html-safe.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-input-type.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-input-type.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-input-type.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-normalize-class.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-normalize-class.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-normalize-class.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/action.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/action.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/action.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/concat.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/concat.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/concat.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/each-in.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/each-in.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/each-in.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/get.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/get.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/get.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/hash.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/hash.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/hash.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/if-unless.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/if-unless.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/if-unless.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/loc.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/loc.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/loc.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/log.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/log.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/log.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/mut.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/mut.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/mut.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/query-param.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/query-param.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/query-param.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/readonly.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/readonly.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/readonly.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/unbound.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/unbound.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/unbound.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/make-bound-helper.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/make-bound-helper.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/make-bound-helper.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/modifiers/action.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/modifiers/action.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/modifiers/action.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/protocol-for-url.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/protocol-for-url.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/protocol-for-url.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/renderer.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/renderer.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/renderer.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/setup-registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/setup-registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/setup-registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/-in-element.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/-in-element.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/-in-element.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/-text-area.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/-text-area.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/-text-area.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/-with-dynamic-vars.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/-with-dynamic-vars.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/-with-dynamic-vars.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/abstract-manager.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/abstract-manager.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/abstract-manager.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/curly-component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/curly-component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/curly-component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/dynamic-component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/dynamic-component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/dynamic-component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/input.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/input.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/input.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/mount.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/mount.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/mount.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/outlet.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/outlet.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/outlet.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/render.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/render.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/render.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/template.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/template.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/template.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/template_registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/template_registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/template_registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/application/actions-test', ['exports', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberRuntime, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Application test: actions', (function (_ApplicationTest) { + babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _ApplicationTest.apply(this, arguments); + } + + _class.prototype['@test actions in top level template application template target application controller'] = function testActionsInTopLevelTemplateApplicationTemplateTargetApplicationController(assert) { + var _this = this; + + assert.expect(1); + + this.registerController('application', _emberRuntime.Controller.extend({ + actions: { + handleIt: function (arg) { + assert.ok(true, 'controller received action properly'); + } + } + })); + + this.registerTemplate('application', ''); + + return this.visit('/').then(function () { + _this.runTask(function () { + return _this.$('#handle-it').click(); + }); + }); + }; + + _class.prototype['@test actions in nested outlet template target their controller'] = function testActionsInNestedOutletTemplateTargetTheirController(assert) { + var _this2 = this; + + assert.expect(1); + + this.registerController('application', _emberRuntime.Controller.extend({ + actions: { + handleIt: function (arg) { + assert.ok(false, 'application controller should not have received action!'); + } + } + })); + + this.registerController('index', _emberRuntime.Controller.extend({ + actions: { + handleIt: function (arg) { + assert.ok(true, 'controller received action properly'); + } + } + })); + + this.registerTemplate('index', ''); + + return this.visit('/').then(function () { + _this2.runTask(function () { + return _this2.$('#handle-it').click(); + }); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Rendering test: non-interactive actions', (function (_RenderingTest) { + babelHelpers.inherits(_class2, _RenderingTest); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _RenderingTest.apply(this, arguments); + } + + _class2.prototype.getBootOptions = function getBootOptions() { + return { isInteractive: false }; + }; + + _class2.prototype['@test doesn\'t attatch actions'] = function testDoesnTAttatchActions(assert) { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + fire: function () { + assert.ok(false); + } + } + }), + template: '' + }); + + this.render('{{foo-bar tagName=""}}'); + + this.assertHTML(''); + + this.$('button').click(); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/application/actions-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/application/actions-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/application/actions-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/application/engine-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-glimmer', 'ember-application', 'ember-routing'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberGlimmer, _emberApplication, _emberRouting) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n

{{contextType}}

\n {{ambiguous-curlies}}\n\n {{outlet}}\n '], ['\n

{{contextType}}

\n {{ambiguous-curlies}}\n\n {{outlet}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n

Component!

\n '], ['\n

Component!

\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{ambiguous-curlies}}\n '], ['\n {{ambiguous-curlies}}\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n

Application

\n {{my-component ambiguous-curlies="Local Data!"}}\n {{outlet}}\n '], ['\n

Application

\n {{my-component ambiguous-curlies="Local Data!"}}\n {{outlet}}\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n

Engine

\n {{my-component}}\n {{outlet}}\n '], ['\n

Engine

\n {{my-component}}\n {{outlet}}\n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n

Component!

\n '], ['\n

Component!

\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Application test: engine rendering', (function (_ApplicationTest) { +babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _ApplicationTest.apply(this, arguments); + } + + _class.prototype.setupAppAndRoutableEngine = function setupAppAndRoutableEngine() { + var hooks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + var self = this; + + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{outlet}}')); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () { + this.route('post', function () { + this.route('comments'); + this.route('likes'); + }); + this.route('category', { path: 'category/:id' }); + this.route('author', { path: 'author/:id' }); + }); + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + hooks.push('application - application'); + } + })); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('controller:application', _emberRuntime.Controller.extend({ + queryParams: ['lang'], + lang: '' + })); + this.register('controller:category', _emberRuntime.Controller.extend({ + queryParams: ['type'] + })); + this.register('controller:authorKtrl', _emberRuntime.Controller.extend({ + queryParams: ['official'] + })); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine{{lang}}{{outlet}}')); + this.register('route:application', _emberRouting.Route.extend({ + model: function () { + hooks.push('engine - application'); + } + })); + this.register('route:author', _emberRouting.Route.extend({ + controllerName: 'authorKtrl' + })); + + if (self._additionalEngineRegistrations) { + self._additionalEngineRegistrations.call(this); + } + } + })); + }; + + _class.prototype.setupAppAndRoutelessEngine = function setupAppAndRoutelessEngine(hooks) { + this.setupRoutelessEngine(hooks); + + this.registerEngine('chat-engine', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine')); + this.register('controller:application', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + hooks.push('engine - application'); + } + })); + } + })); + }; + + _class.prototype.setupAppAndRoutableEngineWithPartial = function setupAppAndRoutableEngineWithPartial(hooks) { + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{outlet}}')); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () {}); + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + hooks.push('application - application'); + } + })); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:foo', _emberGlimmerTestsUtilsHelpers.compile('foo partial')); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine{{outlet}} {{partial "foo"}}')); + this.register('route:application', _emberRouting.Route.extend({ + model: function () { + hooks.push('engine - application'); + } + })); + } + })); + }; + + _class.prototype.setupRoutelessEngine = function setupRoutelessEngine(hooks) { + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{mount "chat-engine"}}')); + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + hooks.push('application - application'); + } + })); + }; + + _class.prototype.setupAppAndRoutlessEngineWithPartial = function setupAppAndRoutlessEngineWithPartial(hooks) { + this.setupRoutelessEngine(hooks); + + this.registerEngine('chat-engine', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:foo', _emberGlimmerTestsUtilsHelpers.compile('foo partial')); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine {{partial "foo"}}')); + this.register('controller:application', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + hooks.push('engine - application'); + } + })); + } + })); + }; + + _class.prototype.additionalEngineRegistrations = function additionalEngineRegistrations(callback) { + this._additionalEngineRegistrations = callback; + }; + + _class.prototype.setupEngineWithAttrs = function setupEngineWithAttrs(hooks) { + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{mount "chat-engine"}}')); + + this.registerEngine('chat-engine', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:components/foo-bar', _emberGlimmerTestsUtilsHelpers.compile('{{partial "troll"}}')); + this.register('template:troll', _emberGlimmerTestsUtilsHelpers.compile('{{attrs.wat}}')); + this.register('controller:application', _emberRuntime.Controller.extend({ + contextType: 'Engine' + })); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine {{foo-bar wat=contextType}}')); + } + })); + }; + + _class.prototype.stringsEndWith = function stringsEndWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + }; + + _class.prototype['@test attrs in an engine'] = function testAttrsInAnEngine() { + var _this = this; + + this.setupEngineWithAttrs([]); + + return this.visit('/').then(function () { + _this.assertText('ApplicationEngine Engine'); + }); + }; + + _class.prototype['@test sharing a template between engine and application has separate refinements'] = function testSharingATemplateBetweenEngineAndApplicationHasSeparateRefinements() { + var _this2 = this; + + this.assert.expect(1); + + var sharedTemplate = _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.application.register('template:application', sharedTemplate); + this.registerController('application', _emberRuntime.Controller.extend({ + contextType: 'Application', + 'ambiguous-curlies': 'Controller Data!' + })); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () {}); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + + this.register('controller:application', _emberRuntime.Controller.extend({ + contextType: 'Engine' + })); + this.register('template:application', sharedTemplate); + this.register('template:components/ambiguous-curlies', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2))); + } + })); + + return this.visit('/blog').then(function () { + _this2.assertText('ApplicationController Data!EngineComponent!'); + }); + }; + + _class.prototype['@test sharing a layout between engine and application has separate refinements'] = function testSharingALayoutBetweenEngineAndApplicationHasSeparateRefinements() { + var _this3 = this; + + this.assert.expect(1); + + var sharedLayout = _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + var sharedComponent = _emberGlimmer.Component.extend({ + layout: sharedLayout + }); + + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4))); + + this.application.register('component:my-component', sharedComponent); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () {}); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5))); + this.register('component:my-component', sharedComponent); + this.register('template:components/ambiguous-curlies', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6))); + } + })); + + return this.visit('/blog').then(function () { + _this3.assertText('ApplicationLocal Data!EngineComponent!'); + }); + }; + + _class.prototype['@test visit() with `shouldRender: true` returns a promise that resolves when application and engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndEngineTemplatesHaveRendered(assert) { + var _this4 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutableEngine(hooks); + + return this.visit('/blog', { shouldRender: true }).then(function () { + _this4.assertText('ApplicationEngine'); + + _this4.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired'); + }); + }; + + _class.prototype['@test visit() with `shouldRender: false` returns a promise that resolves without rendering'] = function testVisitWithShouldRenderFalseReturnsAPromiseThatResolvesWithoutRendering(assert) { + var _this5 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutableEngine(hooks); + + return this.visit('/blog', { shouldRender: false }).then(function () { + _this5.assertText(''); + + _this5.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired'); + }); + }; + + _class.prototype['@test visit() with `shouldRender: true` returns a promise that resolves when application and routeless engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndRoutelessEngineTemplatesHaveRendered(assert) { + var _this6 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutelessEngine(hooks); + + return this.visit('/', { shouldRender: true }).then(function () { + _this6.assertText('ApplicationEngine'); + + _this6.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); + }); + }; + + _class.prototype['@test visit() with partials in routable engine'] = function testVisitWithPartialsInRoutableEngine(assert) { + var _this7 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutableEngineWithPartial(hooks); + + return this.visit('/blog', { shouldRender: true }).then(function () { + _this7.assertText('ApplicationEngine foo partial'); + + _this7.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); + }); + }; + + _class.prototype['@test visit() with partials in non-routable engine'] = function testVisitWithPartialsInNonRoutableEngine(assert) { + var _this8 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutlessEngineWithPartial(hooks); + + return this.visit('/', { shouldRender: true }).then(function () { + _this8.assertText('ApplicationEngine foo partial'); + + _this8.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); + }); + }; + + _class.prototype['@test deactivate should be called on Engine Routes before destruction'] = function testDeactivateShouldBeCalledOnEngineRoutesBeforeDestruction(assert) { + var _this9 = this; + + assert.expect(3); + + this.setupAppAndRoutableEngine(); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine{{outlet}}')); + this.register('route:application', _emberRouting.Route.extend({ + deactivate: function () { + assert.notOk(this.isDestroyed, 'Route is not destroyed'); + assert.notOk(this.isDestroying, 'Route is not being destroyed'); + } + })); + } + })); + + return this.visit('/blog').then(function () { + _this9.assertText('ApplicationEngine'); + }); + }; + + _class.prototype['@test engine should lookup and use correct controller'] = function testEngineShouldLookupAndUseCorrectController(assert) { + var _this10 = this; + + this.setupAppAndRoutableEngine(); + + return this.visit('/blog?lang=English').then(function () { + _this10.assertText('ApplicationEngineEnglish'); + }); + }; + + _class.prototype['@test error substate route works for the application route of an Engine'] = function testErrorSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this11 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:application_error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this11.assertText('Application'); + return _this11.transitionTo('blog.post'); + }).catch(function () { + _this11.assertText('ApplicationError! Oh, noes!'); + }); + }; + + _class.prototype['@test error route works for the application route of an Engine'] = function testErrorRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this12 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this12.assertText('Application'); + return _this12.transitionTo('blog.post'); + }).catch(function () { + _this12.assertText('ApplicationEngineError! Oh, noes!'); + }); + }; + + _class.prototype['@test error substate route works for a child route of an Engine'] = function testErrorSubstateRouteWorksForAChildRouteOfAnEngine(assert) { + var _this13 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:post_error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this13.assertText('Application'); + return _this13.transitionTo('blog.post'); + }).catch(function () { + _this13.assertText('ApplicationEngineError! Oh, noes!'); + }); + }; + + _class.prototype['@test error route works for a child route of an Engine'] = function testErrorRouteWorksForAChildRouteOfAnEngine(assert) { + var _this14 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:post.error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post.comments', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this14.assertText('Application'); + return _this14.transitionTo('blog.post.comments'); + }).catch(function () { + _this14.assertText('ApplicationEngineError! Oh, noes!'); + }); + }; + + _class.prototype['@test loading substate route works for the application route of an Engine'] = function testLoadingSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this15 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:application_loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('Post')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/').then(function () { + _this15.assertText('Application'); + var transition = _this15.transitionTo('blog.post'); + + _this15.runTaskNext(function () { + _this15.assertText('ApplicationLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this15.runTaskNext(function () { + return _this15.assertText('ApplicationEnginePost'); + }); + }); + }); + }; + + _class.prototype['@test loading route works for the application route of an Engine'] = function testLoadingRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this16 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('Post')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/').then(function () { + _this16.assertText('Application'); + var transition = _this16.transitionTo('blog.post'); + + _this16.runTaskNext(function () { + _this16.assertText('ApplicationEngineLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this16.runTaskNext(function () { + return _this16.assertText('ApplicationEnginePost'); + }); + }); + }); + }; + + _class.prototype['@test loading substate route works for a child route of an Engine'] = function testLoadingSubstateRouteWorksForAChildRouteOfAnEngine(assert) { + var _this17 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('{{outlet}}')); + this.register('template:post.comments', _emberGlimmerTestsUtilsHelpers.compile('Comments')); + this.register('template:post.likes_loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post.likes', _emberGlimmerTestsUtilsHelpers.compile('Likes')); + this.register('route:post.likes', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/blog/post/comments').then(function () { + _this17.assertText('ApplicationEngineComments'); + var transition = _this17.transitionTo('blog.post.likes'); + + _this17.runTaskNext(function () { + _this17.assertText('ApplicationEngineLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this17.runTaskNext(function () { + return _this17.assertText('ApplicationEngineLikes'); + }); + }); + }); + }; + + _class.prototype['@test loading route works for a child route of an Engine'] = function testLoadingRouteWorksForAChildRouteOfAnEngine(assert) { + var _this18 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('{{outlet}}')); + this.register('template:post.comments', _emberGlimmerTestsUtilsHelpers.compile('Comments')); + this.register('template:post.loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post.likes', _emberGlimmerTestsUtilsHelpers.compile('Likes')); + this.register('route:post.likes', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/blog/post/comments').then(function () { + _this18.assertText('ApplicationEngineComments'); + var transition = _this18.transitionTo('blog.post.likes'); + + _this18.runTaskNext(function () { + _this18.assertText('ApplicationEngineLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this18.runTaskNext(function () { + return _this18.assertText('ApplicationEngineLikes'); + }); + }); + }); + }; + + _class.prototype['@test query params don\'t have stickiness by default between model'] = function testQueryParamsDonTHaveStickinessByDefaultBetweenModel(assert) { + var _this19 = this; + + assert.expect(1); + var tmpl = '{{#link-to "blog.category" 1337}}Category 1337{{/link-to}}'; + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:category', _emberGlimmerTestsUtilsHelpers.compile(tmpl)); + }); + + return this.visit('/blog/category/1?type=news').then(function () { + var suffix = '/blog/category/1337'; + var href = _this19.element.querySelector('a').href; + + // check if link ends with the suffix + assert.ok(_this19.stringsEndWith(href, suffix)); + }); + }; + + _class.prototype['@test query params in customized controllerName have stickiness by default between model'] = function testQueryParamsInCustomizedControllerNameHaveStickinessByDefaultBetweenModel(assert) { + var _this20 = this; + + assert.expect(2); + var tmpl = '{{#link-to "blog.author" 1337 class="author-1337"}}Author 1337{{/link-to}}{{#link-to "blog.author" 1 class="author-1"}}Author 1{{/link-to}}'; + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:author', _emberGlimmerTestsUtilsHelpers.compile(tmpl)); + }); + + return this.visit('/blog/author/1?official=true').then(function () { + var suffix1 = '/blog/author/1?official=true'; + var href1 = _this20.element.querySelector('.author-1').href; + var suffix1337 = '/blog/author/1337'; + var href1337 = _this20.element.querySelector('.author-1337').href; + + // check if link ends with the suffix + assert.ok(_this20.stringsEndWith(href1, suffix1)); + assert.ok(_this20.stringsEndWith(href1337, suffix1337)); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/application/engine-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/application/engine-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/application/engine-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/application/rendering-test', ['exports', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-routing', 'ember-metal', 'ember-glimmer'], function (exports, _emberRuntime, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberRouting, _emberMetal, _emberGlimmer) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n {{#each model as |item|}}\n
  • {{item}}
  • \n {{/each}}\n
\n '], ['\n
    \n {{#each model as |item|}}\n
  • {{item}}
  • \n {{/each}}\n
\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • red
  • \n
  • yellow
  • \n
  • blue
  • \n
\n '], ['\n
    \n
  • red
  • \n
  • yellow
  • \n
  • blue
  • \n
\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n \n
{{outlet}}
\n '], ['\n \n
{{outlet}}
\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n Ember\n '], ['\n Ember\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n \n
\n
    \n
  • red
  • \n
  • yellow
  • \n
  • blue
  • \n
\n
\n '], ['\n \n
\n
    \n
  • red
  • \n
  • yellow
  • \n
  • blue
  • \n
\n
\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Application test: rendering', (function (_ApplicationTest) { +babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _ApplicationTest.apply(this, arguments); + } + + _class.prototype['@test it can render the application template'] = function testItCanRenderTheApplicationTemplate(assert) { + var _this = this; + + this.registerTemplate('application', 'Hello world!'); + + return this.visit('/').then(function () { + _this.assertText('Hello world!'); + }); + }; + + _class.prototype['@test it can access the model provided by the route'] = function testItCanAccessTheModelProvidedByTheRoute(assert) { + var _this2 = this; + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('application', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/').then(function () { + _this2.assertComponentElement(_this2.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2) + }); + }); + }; + + _class.prototype['@test it can render a nested route'] = function testItCanRenderANestedRoute(assert) { + var _this3 = this; + + this.router.map(function () { + this.route('lists', function () { + this.route('colors', function () { + this.route('favorite'); + }); + }); + }); + + // The "favorite" route will inherit the model + this.registerRoute('lists.colors', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('lists.colors.favorite', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/lists/colors/favorite').then(function () { + _this3.assertComponentElement(_this3.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2) + }); + }); + }; + + _class.prototype['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets(assert) { + var _this4 = this; + + this.router.map(function () { + this.route('colors'); + }); + + this.registerTemplate('application', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.registerTemplate('nav', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.registerRoute('application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('nav', { + into: 'application', + outlet: 'nav' + }); + } + })); + + this.registerRoute('colors', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('colors', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/colors').then(function () { + _this4.assertComponentElement(_this4.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5) + }); + }); + }; + + _class.prototype['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets(assert) { + var _this5 = this; + + this.router.map(function () { + this.route('colors'); + }); + + this.registerTemplate('application', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.registerTemplate('nav', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.registerRoute('application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('nav', { + into: 'application', + outlet: 'nav' + }); + } + })); + + this.registerRoute('colors', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('colors', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/colors').then(function () { + _this5.assertComponentElement(_this5.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5) + }); + }); + }; + + _class.prototype['@test it should update the outlets when switching between routes'] = function testItShouldUpdateTheOutletsWhenSwitchingBetweenRoutes(assert) { + var _this6 = this; + + this.router.map(function () { + this.route('a'); + this.route('b', function () { + this.route('c'); + this.route('d'); + }); + }); + + this.registerTemplate('a', 'A{{outlet}}'); + this.registerTemplate('b', 'B{{outlet}}'); + this.registerTemplate('b.c', 'C'); + this.registerTemplate('b.d', 'D'); + + return this.visit('/b/c').then(function () { + // this.assertComponentElement(this.firstChild, { content: 'BC' }); + _this6.assertText('BC'); + return _this6.visit('/a'); + }).then(function () { + // this.assertComponentElement(this.firstChild, { content: 'A' }); + _this6.assertText('A'); + return _this6.visit('/b/d'); + }).then(function () { + _this6.assertText('BD'); + // this.assertComponentElement(this.firstChild, { content: 'BD' }); + }); + }; + + _class.prototype['@test it should produce a stable DOM when the model changes'] = function testItShouldProduceAStableDOMWhenTheModelChanges(assert) { + var _this7 = this; + + this.router.map(function () { + this.route('color', { path: '/colors/:color' }); + }); + + this.registerRoute('color', _emberRouting.Route.extend({ + model: function (params) { + return params.color; + } + })); + + this.registerTemplate('color', 'color: {{model}}'); + + return this.visit('/colors/red').then(function () { + _this7.assertComponentElement(_this7.firstChild, { content: 'color: red' }); + _this7.takeSnapshot(); + return _this7.visit('/colors/green'); + }).then(function () { + _this7.assertComponentElement(_this7.firstChild, { content: 'color: green' }); + _this7.assertInvariants(); + }); + }; + + _class.prototype['@test it should have the right controller in scope for the route template'] = function testItShouldHaveTheRightControllerInScopeForTheRouteTemplate() { + var _this8 = this; + + this.router.map(function () { + this.route('a'); + this.route('b'); + }); + + this.registerController('a', _emberRuntime.Controller.extend({ + value: 'a' + })); + + this.registerController('b', _emberRuntime.Controller.extend({ + value: 'b' + })); + + this.registerTemplate('a', '{{value}}'); + this.registerTemplate('b', '{{value}}'); + + return this.visit('/a').then(function () { + _this8.assertText('a'); + return _this8.visit('/b'); + }).then(function () { + return _this8.assertText('b'); + }); + }; + + _class.prototype['@test it should update correctly when the controller changes'] = function testItShouldUpdateCorrectlyWhenTheControllerChanges(assert) { + var _this9 = this; + + this.router.map(function () { + this.route('color', { path: '/colors/:color' }); + }); + + this.registerRoute('color', _emberRouting.Route.extend({ + model: function (params) { + return { color: params.color }; + }, + + renderTemplate: function (controller, model) { + this.render({ controller: model.color, model: model }); + } + })); + + this.registerController('red', _emberRuntime.Controller.extend({ + color: 'red' + })); + + this.registerController('green', _emberRuntime.Controller.extend({ + color: 'green' + })); + + this.registerTemplate('color', 'model color: {{model.color}}, controller color: {{color}}'); + + return this.visit('/colors/red').then(function () { + _this9.assertComponentElement(_this9.firstChild, { content: 'model color: red, controller color: red' }); + _this9.takeSnapshot(); + return _this9.visit('/colors/green'); + }).then(function () { + _this9.assertComponentElement(_this9.firstChild, { content: 'model color: green, controller color: green' }); + _this9.assertInvariants(); + }); + }; + + _class.prototype['@test it should produce a stable DOM when two routes render the same template'] = function testItShouldProduceAStableDOMWhenTwoRoutesRenderTheSameTemplate(assert) { + var _this10 = this; + + this.router.map(function () { + this.route('a'); + this.route('b'); + }); + + this.registerRoute('a', _emberRouting.Route.extend({ + model: function () { + return 'A'; + }, + + renderTemplate: function (controller, model) { + this.render('common', { controller: 'common', model: model }); + } + })); + + this.registerRoute('b', _emberRouting.Route.extend({ + model: function () { + return 'B'; + }, + + renderTemplate: function (controller, model) { + this.render('common', { controller: 'common', model: model }); + } + })); + + this.registerController('common', _emberRuntime.Controller.extend({ + prefix: 'common' + })); + + this.registerTemplate('common', '{{prefix}} {{model}}'); + + return this.visit('/a').then(function () { + _this10.assertComponentElement(_this10.firstChild, { content: 'common A' }); + _this10.takeSnapshot(); + return _this10.visit('/b'); + }).then(function () { + _this10.assertComponentElement(_this10.firstChild, { content: 'common B' }); + _this10.assertInvariants(); + }); + }; + + // Regression test, glimmer child outlets tried to assume the first element. + // but the if put-args clobbered the args used by did-create-element. + // I wish there was a way to assert that the OutletComponentManager did not + // receive a didCreateElement. + + _class.prototype['@test a child outlet is always a fragment'] = function testAChildOutletIsAlwaysAFragment() { + var _this11 = this; + + this.registerTemplate('application', '{{outlet}}'); + this.registerTemplate('index', '{{#if true}}1{{/if}}
2
'); + return this.visit('/').then(function () { + _this11.assertComponentElement(_this11.firstChild, { content: '1
2
' }); + }); + }; + + _class.prototype['@test it allows a transition during route activate'] = function testItAllowsATransitionDuringRouteActivate(assert) { + var _this12 = this; + + this.router.map(function () { + this.route('a'); + }); + + this.registerRoute('index', _emberRouting.Route.extend({ + activate: function () { + this.transitionTo('a'); + } + })); + + this.registerTemplate('a', 'Hello from A!'); + + return this.visit('/').then(function () { + _this12.assertComponentElement(_this12.firstChild, { + content: 'Hello from A!' + }); + }); + }; + + _class.prototype['@test it emits a useful backtracking re-render assertion message'] = function testItEmitsAUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this13 = this; + + this.router.map(function () { + this.route('routeWithError'); + }); + + this.registerRoute('routeWithError', _emberRouting.Route.extend({ + model: function () { + return { name: 'Alex' }; + } + })); + + this.registerTemplate('routeWithError', 'Hi {{model.name}} {{x-foo person=model}}'); + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmer.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person.name', 'Ben'); + } + }), + template: 'Hi {{person.name}} from component' + }); + + var expectedBacktrackingMessage = /modified "model\.name" twice on \[object Object\] in a single render\. It was rendered in "template:routeWithError" and modified in "component:x-foo"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + return this.visit('/routeWithError'); + } else { + return this.visit('/').then(function () { + expectAssertion(function () { + _this13.visit('/routeWithError'); + }, expectedBacktrackingMessage); + }); + } + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/application/rendering-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/application/rendering-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/application/rendering-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/binding_integration_test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Binding integration tests', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should accept bindings as a string or an Ember.binding'] = function testShouldAcceptBindingsAsAStringOrAnEmberBinding() { + var _this = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + twoWayTestBinding: _emberMetal.Binding.from('direction'), + stringTestBinding: 'direction', + twoWayObjectTestBinding: _emberMetal.Binding.from('displacement.distance'), + stringObjectTestBinding: 'displacement.distance' + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: 'two way: {{twoWayTest}}, string: {{stringTest}}, object: {{twoWayObjectTest}}, string object: {{stringObjectTest}}' + }); + + expectDeprecation(function () { + _this.render('{{foo-bar direction=direction displacement=displacement}}', { + direction: 'down', + displacement: { + distance: 10 + } + }); + }, /`Ember\.Binding` is deprecated/); + + this.assertText('two way: down, string: down, object: 10, string object: 10'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'direction', 'up'); + }); + + this.assertText('two way: up, string: up, object: 10, string object: 10'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'displacement.distance', 20); + }); + + this.assertText('two way: up, string: up, object: 20, string object: 20'); + + this.runTask(function () { + _emberMetal.set(_this.context, 'direction', 'right'); + _emberMetal.set(_this.context, 'displacement.distance', 30); + }); + + this.assertText('two way: right, string: right, object: 30, string object: 30'); + + this.runTask(function () { + _emberMetal.set(_this.context, 'direction', 'down'); + _emberMetal.set(_this.context, 'displacement', { distance: 10 }); + }); + + this.assertText('two way: down, string: down, object: 10, string object: 10'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/binding_integration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/binding_integration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/binding_integration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/append-test', ['exports', 'ember-metal', 'ember-views', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberMetal, _emberViews, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if showFooBar}}\n {{foo-bar}}\n {{else}}\n {{baz-qux}}\n {{/if}}\n '], ['\n {{#if showFooBar}}\n {{foo-bar}}\n {{else}}\n {{baz-qux}}\n {{/if}}\n ']); + + var AbstractAppendTest = (function (_RenderingTest) { +babelHelpers.inherits(AbstractAppendTest, _RenderingTest); + + function AbstractAppendTest() { +babelHelpers.classCallCheck(this, AbstractAppendTest); + + _RenderingTest.call(this); + + this.components = []; + this.ids = []; + } + + AbstractAppendTest.prototype.teardown = function teardown() { + var _this = this; + + this.component = null; + + this.components.forEach(function (component) { + _this.runTask(function () { + return component.destroy(); + }); + }); + + this.ids.forEach(function (id) { + var $element = _emberViews.jQuery(id).remove(); + _this.assert.strictEqual($element.length, 0, 'Should not leak element: #' + id); + }); + + _RenderingTest.prototype.teardown.call(this); + }; + + /* abstract append(component): Element; */ + + AbstractAppendTest.prototype.didAppend = function didAppend(component) { + this.components.push(component); + this.ids.push(component.elementId); + }; + + AbstractAppendTest.prototype['@test lifecycle hooks during component append'] = function testLifecycleHooksDuringComponentAppend(assert) { + var _this3 = this; + + var hooks = []; + + var oldRegisterComponent = this.registerComponent; + var componentsByName = {}; + + // TODO: refactor/combine with other life-cycle tests + this.registerComponent = function (name, _options) { + function pushHook(hookName) { + hooks.push([name, hookName]); + } + + var options = { + ComponentClass: _options.ComponentClass.extend({ + init: function () { + var _this2 = this, + _arguments = arguments; + + expectDeprecation(function () { + _this2._super.apply(_this2, _arguments); + }, /didInitAttrs called/); + if (name in componentsByName) { + throw new TypeError('Component named: ` ' + name + ' ` already registered'); + } + componentsByName[name] = this; + pushHook('init'); + this.on('init', function () { + return pushHook('on(init)'); + }); + }, + + didInitAttrs: function (options) { + pushHook('didInitAttrs', options); + }, + + didReceiveAttrs: function () { + pushHook('didReceiveAttrs'); + }, + + willInsertElement: function () { + pushHook('willInsertElement'); + }, + + willRender: function () { + pushHook('willRender'); + }, + + didInsertElement: function () { + pushHook('didInsertElement'); + }, + + didRender: function () { + pushHook('didRender'); + }, + + didUpdateAttrs: function () { + pushHook('didUpdateAttrs'); + }, + + willUpdate: function () { + pushHook('willUpdate'); + }, + + didUpdate: function () { + pushHook('didUpdate'); + }, + + willDestroyElement: function () { + pushHook('willDestroyElement'); + }, + + willClearRender: function () { + pushHook('willClearRender'); + }, + + didDestroyElement: function () { + pushHook('didDestroyElement'); + }, + + willDestroy: function () { + pushHook('willDestroy'); + this._super.apply(this, arguments); + } + }), + template: _options.template + }; + + oldRegisterComponent.call(this, name, options); + }; + + this.registerComponent('x-parent', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-parent' + }), + + template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}' + }); + + this.registerComponent('x-child', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + + template: '[child: {{bar}}]{{yield}}' + }); + + var XParent = undefined; + + if (true) { + XParent = this.owner.factoryFor('component:x-parent'); + } else { + XParent = this.owner._lookupFactory('component:x-parent'); + } + + this.component = XParent.create({ foo: 'zomg' }); + + assert.deepEqual(hooks, [['x-parent', 'init'], ['x-parent', 'didInitAttrs'], ['x-parent', 'didReceiveAttrs'], ['x-parent', 'on(init)']], 'creation of x-parent'); + + hooks.length = 0; + + this.element = this.append(this.component); + + assert.deepEqual(hooks, [['x-parent', 'willInsertElement'], ['x-child', 'init'], ['x-child', 'didInitAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'on(init)'], ['x-child', 'willRender'], ['x-child', 'willInsertElement'], ['x-child', 'didInsertElement'], ['x-child', 'didRender'], ['x-parent', 'didInsertElement'], ['x-parent', 'didRender']], 'appending of x-parent'); + + hooks.length = 0; + + this.runTask(function () { + return componentsByName['x-parent'].rerender(); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'rerender x-parent'); + + hooks.length = 0; + + this.runTask(function () { + return componentsByName['x-child'].rerender(); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'rerender x-child'); + + hooks.length = 0; + + this.runTask(function () { + return _emberMetal.set(_this3.component, 'foo', 'wow'); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'didUpdateAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'set foo = wow'); + + hooks.length = 0; + + this.runTask(function () { + return _emberMetal.set(_this3.component, 'foo', 'zomg'); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'didUpdateAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'set foo = zomg'); + + hooks.length = 0; + + this.runTask(function () { + return _this3.component.destroy(); + }); + + assert.deepEqual(hooks, [['x-parent', 'willDestroyElement'], ['x-parent', 'willClearRender'], ['x-child', 'willDestroyElement'], ['x-child', 'willClearRender'], ['x-child', 'didDestroyElement'], ['x-parent', 'didDestroyElement'], ['x-parent', 'willDestroy'], ['x-child', 'willDestroy']], 'destroy'); + }; + + AbstractAppendTest.prototype['@test appending, updating and destroying a single component'] = function testAppendingUpdatingAndDestroyingASingleComponent(assert) { + var _this4 = this; + + var willDestroyCalled = 0; + + this.registerComponent('x-parent', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-parent', + willDestroyElement: function () { + willDestroyCalled++; + } + }), + + template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}' + }); + + this.registerComponent('x-child', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + + template: '[child: {{bar}}]{{yield}}' + }); + + var XParent = undefined; + + if (true) { + XParent = this.owner.factoryFor('component:x-parent'); + } else { + XParent = this.owner._lookupFactory('component:x-parent'); + } + + this.component = XParent.create({ foo: 'zomg' }); + + assert.ok(!this.component.element, 'precond - should not have an element'); + + this.element = this.append(this.component); + + var componentElement = this.component.element; + + this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(_this4.component, 'foo', 'wow'); + }); + + this.assertComponentElement(componentElement, { content: '[parent: wow][child: wow][yielded: wow]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(_this4.component, 'foo', 'zomg'); + }); + + this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _this4.component.destroy(); + }); + + if (this.isHTMLBars) { + // Bug in Glimmer – component should not have .element at this point + assert.ok(!this.component.element, 'It should not have an element'); + } + + assert.ok(!componentElement.parentElement, 'The component element should be detached'); + + this.assert.equal(willDestroyCalled, 1); + }; + + AbstractAppendTest.prototype['@test appending, updating and destroying multiple components'] = function testAppendingUpdatingAndDestroyingMultipleComponents(assert) { + var _this5 = this; + + var willDestroyCalled = 0; + + this.registerComponent('x-first', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-first', + + willDestroyElement: function () { + willDestroyCalled++; + } + }), + + template: 'x-first {{foo}}!' + }); + + this.registerComponent('x-second', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-second', + + willDestroyElement: function () { + willDestroyCalled++; + } + }), + + template: 'x-second {{bar}}!' + }); + + var First = undefined, + Second = undefined; + + if (true) { + First = this.owner.factoryFor('component:x-first'); + Second = this.owner.factoryFor('component:x-second'); + } else { + First = this.owner._lookupFactory('component:x-first'); + Second = this.owner._lookupFactory('component:x-second'); + } + + var first = First.create({ foo: 'foo' }); + var second = Second.create({ bar: 'bar' }); + + this.assert.ok(!first.element, 'precond - should not have an element'); + this.assert.ok(!second.element, 'precond - should not have an element'); + + var wrapper1 = undefined, + wrapper2 = undefined; + + this.runTask(function () { + return wrapper1 = _this5.append(first); + }); + this.runTask(function () { + return wrapper2 = _this5.append(second); + }); + + var componentElement1 = first.element; + var componentElement2 = second.element; + + this.assertComponentElement(componentElement1, { content: 'x-first foo!' }); + this.assertComponentElement(componentElement2, { content: 'x-second bar!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(first, 'foo', 'FOO'); + }); + + this.assertComponentElement(componentElement1, { content: 'x-first FOO!' }); + this.assertComponentElement(componentElement2, { content: 'x-second bar!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(second, 'bar', 'BAR'); + }); + + this.assertComponentElement(componentElement1, { content: 'x-first FOO!' }); + this.assertComponentElement(componentElement2, { content: 'x-second BAR!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + _emberMetal.set(first, 'foo', 'foo'); + _emberMetal.set(second, 'bar', 'bar'); + }); + + this.assertComponentElement(componentElement1, { content: 'x-first foo!' }); + this.assertComponentElement(componentElement2, { content: 'x-second bar!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + first.destroy(); + second.destroy(); + }); + + if (this.isHTMLBars) { + // Bug in Glimmer – component should not have .element at this point + assert.ok(!first.element, 'The first component should not have an element'); + assert.ok(!second.element, 'The second component should not have an element'); + } + + assert.ok(!componentElement1.parentElement, 'The first component element should be detached'); + assert.ok(!componentElement2.parentElement, 'The second component element should be detached'); + + this.assert.equal(willDestroyCalled, 2); + }; + + AbstractAppendTest.prototype['@test can appendTo while rendering'] = function testCanAppendToWhileRendering(assert) { + var _this6 = this; + + var owner = this.owner; + + var append = function (component) { + return _this6.append(component); + }; + + var element1 = undefined, + element2 = undefined; + this.registerComponent('first-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('component-one'), + + didInsertElement: function () { + element1 = this.element; + + var SecondComponent = undefined; + if (true) { + SecondComponent = owner.factoryFor('component:second-component'); + } else { + SecondComponent = owner._lookupFactory('component:second-component'); + } + + append(SecondComponent.create()); + } + }) + }); + + this.registerComponent('second-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('component-two'), + + didInsertElement: function () { + element2 = this.element; + } + }) + }); + + var FirstComponent = undefined; + + if (true) { + FirstComponent = this.owner.factoryFor('component:first-component'); + } else { + FirstComponent = this.owner._lookupFactory('component:first-component'); + } + + this.runTask(function () { + return append(FirstComponent.create()); + }); + + this.assertComponentElement(element1, { content: 'component-one' }); + this.assertComponentElement(element2, { content: 'component-two' }); + }; + + AbstractAppendTest.prototype['@test can appendTo and remove while rendering'] = function testCanAppendToAndRemoveWhileRendering(assert) { + var _this7 = this; + + var owner = this.owner; + + var append = function (component) { + return _this7.append(component); + }; + + var element1 = undefined, + element2 = undefined, + element3 = undefined, + element4 = undefined, + component1 = undefined, + component2 = undefined; + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('foo-bar'), + + init: function () { + this._super.apply(this, arguments); + component1 = this; + }, + + didInsertElement: function () { + element1 = this.element; + var OtherRoot = undefined; + + if (true) { + OtherRoot = owner.factoryFor('component:other-root'); + } else { + OtherRoot = owner._lookupFactory('component:other-root'); + } + + this._instance = OtherRoot.create({ + didInsertElement: function () { + element2 = this.element; + } + }); + + append(this._instance); + }, + + willDestroy: function () { + this._instance.destroy(); + } + }) + }); + + this.registerComponent('baz-qux', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('baz-qux'), + + init: function () { + this._super.apply(this, arguments); + component2 = this; + }, + + didInsertElement: function () { + element3 = this.element; + var OtherRoot = undefined; + + if (true) { + OtherRoot = owner.factoryFor('component:other-root'); + } else { + OtherRoot = owner._lookupFactory('component:other-root'); + } + + this._instance = OtherRoot.create({ + didInsertElement: function () { + element4 = this.element; + } + }); + + append(this._instance); + }, + + willDestroy: function () { + this._instance.destroy(); + } + }) + }); + + var instantiatedRoots = 0; + var destroyedRoots = 0; + this.registerComponent('other-root', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('fake-thing: {{counter}}'), + init: function () { + this._super.apply(this, arguments); + this.counter = instantiatedRoots++; + }, + willDestroy: function () { + destroyedRoots++; + this._super.apply(this, arguments); + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { showFooBar: true }); + + this.assertComponentElement(element1, {}); + this.assertComponentElement(element2, { content: 'fake-thing: 0' }); + assert.equal(instantiatedRoots, 1); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'showFooBar', false); + }); + + assert.equal(instantiatedRoots, 2); + assert.equal(destroyedRoots, 1); + + this.assertComponentElement(element3, {}); + this.assertComponentElement(element4, { content: 'fake-thing: 1' }); + + this.runTask(function () { + component1.destroy(); + component2.destroy(); + }); + + assert.equal(instantiatedRoots, 2); + assert.equal(destroyedRoots, 2); + }; + + return AbstractAppendTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('append: no arguments (attaching to document.body)', (function (_AbstractAppendTest) { +babelHelpers.inherits(_class, _AbstractAppendTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _AbstractAppendTest.apply(this, arguments); + } + + _class.prototype.append = function append(component) { + this.runTask(function () { + return component.append(); + }); + this.didAppend(component); + return document.body; + }; + + return _class; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('appendTo: a selector', (function (_AbstractAppendTest2) { +babelHelpers.inherits(_class2, _AbstractAppendTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _AbstractAppendTest2.apply(this, arguments); + } + + _class2.prototype.append = function append(component) { + this.runTask(function () { + return component.appendTo('#qunit-fixture'); + }); + this.didAppend(component); + return _emberViews.jQuery('#qunit-fixture')[0]; + }; + + _class2.prototype['@test raises an assertion when the target does not exist in the DOM'] = function testRaisesAnAssertionWhenTheTargetDoesNotExistInTheDOM(assert) { + var _this8 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/foo-bar' + }), + template: 'FOO BAR!' + }); + + var FooBar = undefined; + + if (true) { + FooBar = this.owner.factoryFor('component:foo-bar'); + } else { + FooBar = this.owner._lookupFactory('component:foo-bar'); + } + + this.component = FooBar.create(); + + assert.ok(!this.component.element, 'precond - should not have an element'); + + this.runTask(function () { + expectAssertion(function () { + _this8.component.appendTo('#does-not-exist-in-dom'); + }, /You tried to append to \(#does-not-exist-in-dom\) but that isn't in the DOM/); + }); + + assert.ok(!this.component.element, 'component should not have an element'); + }; + + return _class2; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('appendTo: an element', (function (_AbstractAppendTest3) { +babelHelpers.inherits(_class3, _AbstractAppendTest3); + + function _class3() { +babelHelpers.classCallCheck(this, _class3); + + _AbstractAppendTest3.apply(this, arguments); + } + + _class3.prototype.append = function append(component) { + var element = _emberViews.jQuery('#qunit-fixture')[0]; + this.runTask(function () { + return component.appendTo(element); + }); + this.didAppend(component); + return element; + }; + + return _class3; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('appendTo: with multiple components', (function (_AbstractAppendTest4) { +babelHelpers.inherits(_class4, _AbstractAppendTest4); + + function _class4() { +babelHelpers.classCallCheck(this, _class4); + + _AbstractAppendTest4.apply(this, arguments); + } + + _class4.prototype.append = function append(component) { + this.runTask(function () { + return component.appendTo('#qunit-fixture'); + }); + this.didAppend(component); + return _emberViews.jQuery('#qunit-fixture')[0]; + }; + + return _class4; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('renderToElement: no arguments (defaults to a body context)', (function (_AbstractAppendTest5) { +babelHelpers.inherits(_class5, _AbstractAppendTest5); + + function _class5() { +babelHelpers.classCallCheck(this, _class5); + + _AbstractAppendTest5.apply(this, arguments); + } + + _class5.prototype.append = function append(component) { + expectDeprecation(/Using the `renderToElement` is deprecated in favor of `appendTo`. Called in/); + var wrapper = undefined; + + this.runTask(function () { + return wrapper = component.renderToElement(); + }); + this.didAppend(component); + + this.assert.equal(wrapper.tagName, 'BODY', 'wrapper is a body element'); + this.assert.notEqual(wrapper, document.body, 'wrapper is not document.body'); + this.assert.ok(!wrapper.parentNode, 'wrapper is detached'); + + return wrapper; + }; + + return _class5; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('renderToElement: a div', (function (_AbstractAppendTest6) { +babelHelpers.inherits(_class6, _AbstractAppendTest6); + + function _class6() { +babelHelpers.classCallCheck(this, _class6); + + _AbstractAppendTest6.apply(this, arguments); + } + + _class6.prototype.append = function append(component) { + expectDeprecation(/Using the `renderToElement` is deprecated in favor of `appendTo`. Called in/); + var wrapper = undefined; + + this.runTask(function () { + return wrapper = component.renderToElement('div'); + }); + this.didAppend(component); + + this.assert.equal(wrapper.tagName, 'DIV', 'wrapper is a body element'); + this.assert.ok(!wrapper.parentNode, 'wrapper is detached'); + + return wrapper; + }; + + return _class6; + })(AbstractAppendTest)); +}); +enifed('ember-glimmer/tests/integration/components/append-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/append-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/append-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/attribute-bindings-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{foo-bar hasFoo=true foo=foo hasBar=false bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=true foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=false bar=bar}}\n '], ['\n {{foo-bar hasFoo=true foo=foo hasBar=false bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=true foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=false bar=bar}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Attribute bindings integration', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can have attribute bindings'] = function testItCanHaveAttributeBindings() { + var _this = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo:data-foo', 'bar:data-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'FOO'); + _emberMetal.set(_this.context, 'bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'foo'); + _emberMetal.set(_this.context, 'bar', 'bar'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + }; + + _class.prototype['@test it can have attribute bindings with attrs'] = function testItCanHaveAttributeBindingsWithAttrs() { + var _this2 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['attrs.foo:data-foo', 'attrs.baz.bar:data-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=model.foo baz=model.baz}}', { + model: { foo: undefined, baz: { bar: 'bar' } } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model.foo', 'foo'); + _emberMetal.set(_this2.context, 'model.baz.bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { + foo: undefined, baz: { bar: 'bar' } + }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); + }; + + _class.prototype['@test it can have attribute bindings with a nested path'] = function testItCanHaveAttributeBindingsWithANestedPath() { + var _this3 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo.bar:data-foo-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo.bar', 'FOO-BAR'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'FOO-BAR' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo.bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo', { bar: 'foo-bar' }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); + }; + + _class.prototype['@test handles non-microsyntax attributeBindings'] = function testHandlesNonMicrosyntaxAttributeBindings() { + var _this4 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['type'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar type=submit}}', { + submit: 'submit' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'submit', 'password'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'submit', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'submit', 'submit'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); + }; + + _class.prototype['@test non-microsyntax attributeBindings cannot contain nested paths'] = function testNonMicrosyntaxAttributeBindingsCannotContainNestedPaths() { + var _this5 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo.bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this5.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } }); + }, /Illegal attributeBinding: 'foo.bar' is not a valid attribute name./); + }; + + _class.prototype['@test normalizes attributeBindings for property names'] = function testNormalizesAttributeBindingsForPropertyNames() { + var _this6 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['tiTLe'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar tiTLe=name}}', { + name: 'qux' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, content: 'hello' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'name', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'name', 'qux'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, content: 'hello' }); + }; + + _class.prototype['@test normalizes attributeBindings for attribute names'] = function testNormalizesAttributeBindingsForAttributeNames() { + var _this7 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo:data-FOO'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo}}', { + foo: 'qux' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, content: 'hello' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', 'qux'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, content: 'hello' }); + }; + + _class.prototype['@test attributeBindings handles null/undefined'] = function testAttributeBindingsHandlesNullUndefined() { + var _this8 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['fizz', 'bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar fizz=fizz bar=bar}}', { + fizz: null, + bar: undefined + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'fizz', 'fizz'); + _emberMetal.set(_this8.context, 'bar', 'bar'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { fizz: 'fizz', bar: 'bar' }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'fizz', null); + _emberMetal.set(_this8.context, 'bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + }; + + _class.prototype['@test attributeBindings handles number value'] = function testAttributeBindingsHandlesNumberValue() { + var _this9 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['size'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar size=size}}', { + size: 21 + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'size', 0); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '0' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'size', 21); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); + }; + + _class.prototype['@test handles internal and external changes'] = function testHandlesInternalAndExternalChanges() { + var _this10 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['type'], + type: 'password', + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(component, 'type', 'checkbox'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'checkbox' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(component, 'type', 'password'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + }; + + _class.prototype['@test can set attributeBindings on component with a different tagName'] = function testCanSetAttributeBindingsOnComponentWithADifferentTagName() { + var _this11 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'input', + attributeBindings: ['type', 'isDisabled:disabled'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar type=type isDisabled=disabled}}', { + type: 'password', + disabled: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'type', 'checkbox'); + _emberMetal.set(_this11.context, 'disabled', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'checkbox', disabled: '' } }); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'type', 'password'); + _emberMetal.set(_this11.context, 'disabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); + }; + + _class.prototype['@test should allow namespaced attributes in micro syntax'] = function testShouldAllowNamespacedAttributesInMicroSyntax() { + var _this12 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['xlinkHref:xlink:href'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar type=type xlinkHref=xlinkHref}}', { + xlinkHref: '/foo.png' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'xlinkHref', '/lol.png'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/lol.png' } }); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'xlinkHref', '/foo.png'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); + }; + + // This comes into play when using the {{#each}} helper. If the + // passed array item is a String, it will be converted into a + // String object instead of a normal string. + + _class.prototype['@test should allow for String objects'] = function testShouldAllowForStringObjects() { + var _this13 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar foo=foo}}', { + foo: (function () { + return this; + }).call('bar') + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } }); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'foo', (function () { + return this; + }).call('baz')); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'baz' } }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'foo', (function () { + return this; + }).call('bar')); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } }); + }; + + _class.prototype['@test can set id initially via attributeBindings '] = function testCanSetIdInitiallyViaAttributeBindings() { + var _this14 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['specialSauce:id'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar specialSauce=sauce}}', { + sauce: 'special-sauce' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'sauce', 'foo'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'sauce', 'special-sauce'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + }; + + _class.prototype['@test attributeBindings are overwritten'] = function testAttributeBindingsAreOverwritten() { + var _this15 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['href'], + href: 'a href' + }); + + var FizzBarComponent = FooBarComponent.extend({ + attributeBindings: ['newHref:href'] + }); + + this.registerComponent('fizz-bar', { ComponentClass: FizzBarComponent }); + + this.render('{{fizz-bar newHref=href}}', { + href: 'dog.html' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'dog.html' } }); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'dog.html' } }); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'href', 'cat.html'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'cat.html' } }); + }; + + _class.prototype['@test it can set attribute bindings in the constructor'] = function testItCanSetAttributeBindingsInTheConstructor() { + var _this16 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + + var bindings = []; + + if (this.get('hasFoo')) { + bindings.push('foo:data-foo'); + } + + if (this.get('hasBar')) { + bindings.push('bar:data-bar'); + } + + this.attributeBindings = bindings; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { foo: 'foo', bar: 'bar' }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'foo', 'FOO'); + _emberMetal.set(_this16.context, 'bar', undefined); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: {}, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'bar', 'BAR'); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'BAR' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO', 'data-bar': 'BAR' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'foo', 'foo'); + _emberMetal.set(_this16.context, 'bar', 'bar'); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + }; + + _class.prototype['@test it should not allow attributeBindings to be set'] = function testItShouldNotAllowAttributeBindingsToBeSet() { + var _this17 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + expectAssertion(function () { + _this17.render('{{foo-bar attributeBindings="one two"}}'); + }, /Setting 'attributeBindings' via template helpers is not allowed/); + }; + + _class.prototype['@test asserts if an attributeBinding is setup on class'] = function testAssertsIfAnAttributeBindingIsSetupOnClass() { + var _this18 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['class'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this18.render('{{foo-bar}}'); + }, /You cannot use class as an attributeBinding, use classNameBindings instead./i); + }; + + _class.prototype['@test blacklists href bindings based on protocol'] = function testBlacklistsHrefBindingsBasedOnProtocol() { + /* jshint scripturl:true */ + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'a', + attributeBindings: ['href'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar href=xss}}', { + xss: 'javascript:alert(\'foo\')' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'a', attrs: { href: 'unsafe:javascript:alert(\'foo\')' } }); + }; + + _class.prototype['@test it can bind the role attribute (issue #14007)'] = function testItCanBindTheRoleAttributeIssue14007() { + var _this19 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ attributeBindings: ['role'] }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar role=role}}', { role: 'button' }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } }); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } }); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'role', 'combobox'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'combobox' } }); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'role', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div' }); + }; + + _class.prototype['@test component with an `id` attribute binding of undefined'] = function testComponentWithAnIdAttributeBindingOfUndefined() { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['id'], + + id: undefined + }) + }); + + this.registerComponent('baz-qux', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['somethingUndefined:id'], + + somethingUndefined: undefined + }) + }); + this.render('{{foo-bar}}{{baz-qux}}'); + + this.assertComponentElement(this.nthChild(0), { content: '' }); + this.assertComponentElement(this.nthChild(1), { content: '' }); + + this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used'); + this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used'); + }; + + _class.prototype['@test component with an `id` attribute binding of null'] = function testComponentWithAnIdAttributeBindingOfNull() { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['id'], + + id: null + }) + }); + + this.registerComponent('baz-qux', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['somethingNull:id'], + + somethingNull: null + }) + }); + this.render('{{foo-bar}}{{baz-qux}}'); + + this.assertComponentElement(this.nthChild(0), { content: '' }); + this.assertComponentElement(this.nthChild(1), { content: '' }); + + this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used'); + this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/attribute-bindings-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/attribute-bindings-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/attribute-bindings-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/attrs-lookup-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal, _emberGlimmerTestsUtilsTestHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: attrs lookup', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it should be able to lookup attrs without `attrs.` - template access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsTemplateAccess() { + var _this = this; + + this.registerComponent('foo-bar', { template: '{{first}}' }); + + this.render('{{foo-bar first=firstAttr}}', { + firstAttr: 'first attr' + }); + + this.assertText('first attr'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('first attr'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'firstAttr', 'second attr'); + }); + + this.assertText('second attr'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'firstAttr', 'first attr'); + }); + + this.assertText('first attr'); + }; + + _class.prototype['@test it should be able to lookup attrs without `attrs.` - component access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsComponentAccess(assert) { + var _this2 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{first}}' }); + + this.render('{{foo-bar first=firstAttr}}', { + firstAttr: 'first attr' + }); + + assert.equal(instance.get('first'), 'first attr'); + + this.runTask(function () { + return _this2.rerender(); + }); + + assert.equal(instance.get('first'), 'first attr'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'firstAttr', 'second attr'); + }); + + assert.equal(instance.get('first'), 'second attr'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'firstAttr', 'first attr'); + }); + + this.assertText('first attr'); + }; + + _class.prototype['@test should be able to modify a provided attr into local state #11571 / #11559'] = function testShouldBeAbleToModifyAProvidedAttrIntoLocalState1157111559(assert) { + var _this3 = this; + + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + didReceiveAttrs: function () { + this.set('first', this.get('first').toUpperCase()); + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{first}}' }); + + this.render('{{foo-bar first="first attr"}}'); + + assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state'); + this.assertText('FIRST ATTR'); + + this.runTask(function () { + return _this3.rerender(); + }); + + assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state during rerender'); + this.assertText('FIRST ATTR'); + + // This is testing that passing string literals for use as initial values, + // so there is no update step + }; + + _class.prototype['@test should be able to access unspecified attr #12035'] = function testShouldBeAbleToAccessUnspecifiedAttr12035(assert) { + var _this4 = this; + + var instance = undefined; + var wootVal = 'yes'; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + didReceiveAttrs: function () { + assert.equal(this.get('woot'), wootVal, 'found attr in didReceiveAttrs'); + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar woot=woot}}', { + woot: wootVal + }); + + assert.equal(instance.get('woot'), 'yes', 'component found attr'); + + this.runTask(function () { + return _this4.rerender(); + }); + + assert.equal(instance.get('woot'), 'yes', 'component found attr after rerender'); + + this.runTask(function () { + wootVal = 'nope'; + _emberMetal.set(_this4.context, 'woot', wootVal); + }); + + assert.equal(instance.get('woot'), 'nope', 'component found attr after attr change'); + + this.runTask(function () { + wootVal = 'yes'; + _emberMetal.set(_this4.context, 'woot', wootVal); + }); + + assert.equal(instance.get('woot'), 'yes', 'component found attr after reset'); + }; + + _class.prototype['@test getAttr() should return the same value as get()'] = function testGetAttrShouldReturnTheSameValueAsGet(assert) { + var _this5 = this; + + assert.expect(33); + + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + didReceiveAttrs: function () { + var rootFirstPositional = this.get('firstPositional'); + var rootFirst = this.get('first'); + var rootSecond = this.get('second'); + var attrFirstPositional = this.getAttr('firstPositional'); + var attrFirst = this.getAttr('first'); + var attrSecond = this.getAttr('second'); + + equal(rootFirstPositional, attrFirstPositional, 'root property matches attrs value'); + equal(rootFirst, attrFirst, 'root property matches attrs value'); + equal(rootSecond, attrSecond, 'root property matches attrs value'); + } + }); + + FooBarComponent.reopenClass({ + positionalParams: ['firstPositional'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar firstPositional first=first second=second}}', { + firstPositional: 'firstPositional', + first: 'first', + second: 'second' + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'first', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + + this.runTask(function () { + return _this5.rerender(); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'first', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'first', 'third'); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'third', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'second', 'fourth'); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'third', 'matches known value'); + assert.equal(instance.get('second'), 'fourth', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'firstPositional', 'fifth'); + }); + + assert.equal(instance.get('firstPositional'), 'fifth', 'matches known value'); + assert.equal(instance.get('first'), 'third', 'matches known value'); + assert.equal(instance.get('second'), 'fourth', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'firstPositional', 'firstPositional'); + _emberMetal.set(_this5.context, 'first', 'first'); + _emberMetal.set(_this5.context, 'second', 'second'); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'first', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + }; + + _class.prototype['@test bound computed properties can be overriden in extensions, set during init, and passed in as attrs'] = function testBoundComputedPropertiesCanBeOverridenInExtensionsSetDuringInitAndPassedInAsAttrs() { + var FooClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + style: _emberMetal.computed('height', 'color', function () { + var height = this.get('height'); + var color = this.get('color'); + return 'height: ' + height + 'px; background-color: ' + color + ';'; + }), + color: 'red', + height: 20 + }); + + var BarClass = FooClass.extend({ + init: function () { + this._super.apply(this, arguments); + this.height = 150; + }, + color: 'yellow' + }); + + this.registerComponent('x-foo', { ComponentClass: FooClass }); + this.registerComponent('x-bar', { ComponentClass: BarClass }); + + this.render('{{x-foo}}{{x-bar}}{{x-bar color="green"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 20px; background-color: red;') } }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 150px; background-color: yellow;') } }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 150px; background-color: green;') } }); + + this.assertStableRerender(); + + // No U-R + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/attrs-lookup-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/attrs-lookup-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/attrs-lookup-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/class-bindings-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-helpers', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestHelpers, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n '], ['\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('ClassNameBindings integration', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can have class name bindings on the class definition'] = function testItCanHaveClassNameBindingsOnTheClassDefinition() { + var _this = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['foo', 'isEnabled:enabled', 'isHappy:happy:sad'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo isEnabled=isEnabled isHappy=isHappy}}', { foo: 'foo', isEnabled: true, isHappy: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'FOO'); + _emberMetal.set(_this.context, 'isEnabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', undefined); + _emberMetal.set(_this.context, 'isHappy', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'foo'); + _emberMetal.set(_this.context, 'isEnabled', true); + _emberMetal.set(_this.context, 'isHappy', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + }; + + _class.prototype['@test attrs in classNameBindings'] = function testAttrsInClassNameBindings() { + var _this2 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['attrs.joker:purple:green', 'attrs.batman.robin:black:red'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar joker=model.wat batman=model.super}}', { + model: { wat: false, super: { robin: true } } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view green black') }, content: 'hello' }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view green black') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model.wat', true); + _emberMetal.set(_this2.context, 'model.super.robin', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view purple red') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { + wat: false, super: { robin: true } + }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view green black') }, content: 'hello' }); + }; + + _class.prototype['@test it can have class name bindings in the template'] = function testItCanHaveClassNameBindingsInTheTemplate() { + var _this3 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classNameBindings="model.someInitiallyTrueProperty model.someInitiallyFalseProperty model.someInitiallyUndefinedProperty :static model.isBig:big model.isOpen:open:closed model.isUp::down model.bar:isTruthy:isFalsy"}}', { + model: { + someInitiallyTrueProperty: true, + someInitiallyFalseProperty: false, + isBig: true, + isOpen: false, + isUp: true, + bar: true + } + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-true-property static big closed isTruthy') }, + content: 'hello' + }); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-true-property static big closed isTruthy') }, + content: 'hello' + }); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'model.someInitiallyTrueProperty', false); + _emberMetal.set(_this3.context, 'model.someInitiallyFalseProperty', true); + _emberMetal.set(_this3.context, 'model.someInitiallyUndefinedProperty', true); + _emberMetal.set(_this3.context, 'model.isBig', false); + _emberMetal.set(_this3.context, 'model.isOpen', true); + _emberMetal.set(_this3.context, 'model.isUp', false); + _emberMetal.set(_this3.context, 'model.bar', false); + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-false-property some-initially-undefined-property static open down isFalsy') }, + content: 'hello' + }); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'model', { + someInitiallyTrueProperty: true, + someInitiallyFalseProperty: false, + someInitiallyUndefinedProperty: undefined, + isBig: true, + isOpen: false, + isUp: true, + bar: true + }); + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-true-property static big closed isTruthy') }, + content: 'hello' + }); + }; + + _class.prototype['@test it can have class name bindings with nested paths'] = function testItCanHaveClassNameBindingsWithNestedPaths() { + var _this4 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['foo.bar', 'is.enabled:enabled', 'is.happy:happy:sad'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo is=is}}', { foo: { bar: 'foo-bar' }, is: { enabled: true, happy: false } }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar enabled sad') }, content: 'hello' }); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar enabled sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo.bar', 'FOO-BAR'); + _emberMetal.set(_this4.context, 'is.enabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO-BAR sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo.bar', null); + _emberMetal.set(_this4.context, 'is.happy', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo', null); + _emberMetal.set(_this4.context, 'is', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo', { bar: 'foo-bar' }); + _emberMetal.set(_this4.context, 'is', { enabled: true, happy: false }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar enabled sad') }, content: 'hello' }); + }; + + _class.prototype['@test it should dasherize the path when the it resolves to true'] = function testItShouldDasherizeThePathWhenTheItResolvesToTrue() { + var _this5 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['fooBar', 'nested.fooBarBaz'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar fooBar=fooBar nested=nested}}', { fooBar: true, nested: { fooBarBaz: false } }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') }, content: 'hello' }); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'fooBar', false); + _emberMetal.set(_this5.context, 'nested.fooBarBaz', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar-baz') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'fooBar', 'FOO-BAR'); + _emberMetal.set(_this5.context, 'nested.fooBarBaz', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO-BAR') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'nested', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO-BAR') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'fooBar', true); + _emberMetal.set(_this5.context, 'nested', { fooBarBaz: false }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') }, content: 'hello' }); + }; + + _class.prototype['@test const bindings can be set as attrs'] = function testConstBindingsCanBeSetAsAttrs() { + var _this6 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + this.render('{{foo-bar classNameBindings="foo:enabled:disabled"}}', { + foo: true + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view enabled') }, content: 'hello' }); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view enabled') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view disabled') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view enabled') }, content: 'hello' }); + }; + + _class.prototype['@test :: class name syntax works with an empty true class'] = function testClassNameSyntaxWorksWithAnEmptyTrueClass() { + var _this7 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['isEnabled::not-enabled'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar isEnabled=enabled}}', { + enabled: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view not-enabled') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'enabled', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'enabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view not-enabled') }, content: 'hello' }); + }; + + _class.prototype['@test uses all provided static class names (issue #11193)'] = function testUsesAllProvidedStaticClassNamesIssue11193() { + var _this8 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: [':class-one', ':class-two'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}', { + enabled: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view class-one class-two') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'enabled', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view class-one class-two') }, content: 'hello' }); + }; + + _class.prototype['@test Providing a binding with a space in it asserts'] = function testProvidingABindingWithASpaceInItAsserts() { + var _this9 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: 'i:think:i am:so:clever' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this9.render('{{foo-bar}}'); + }, /classNameBindings must not have spaces in them/i); + }; + + _class.prototype['@test it can set class name bindings in the constructor'] = function testItCanSetClassNameBindingsInTheConstructor() { + var _this10 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['foo'], + + init: function () { + this._super(); + + var bindings = this.classNameBindings = this.classNameBindings.slice(); + + if (this.get('bindIsEnabled')) { + bindings.push('isEnabled:enabled'); + } + + if (this.get('bindIsHappy')) { + bindings.push('isHappy:happy:sad'); + } + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { foo: 'foo', isEnabled: true, isHappy: false }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'foo', 'FOO'); + _emberMetal.set(_this10.context, 'isEnabled', false); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'foo', undefined); + _emberMetal.set(_this10.context, 'isHappy', true); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'foo', 'foo'); + _emberMetal.set(_this10.context, 'isEnabled', true); + _emberMetal.set(_this10.context, 'isHappy', false); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + }; + + _class.prototype['@test using a computed property for classNameBindings triggers an assertion'] = function testUsingAComputedPropertyForClassNameBindingsTriggersAnAssertion() { + var _this11 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: _emberMetal.computed(function () { + return ['isHappy:happy:sad']; + }) + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this11.render('{{foo-bar}}'); + }, /Only arrays are allowed/); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('ClassBinding integration', (function (_RenderingTest2) { +babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test it should apply classBinding without condition always'] = function testItShouldApplyClassBindingWithoutConditionAlways() { + var _this12 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding=":foo"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo ember-view') } }); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo ember-view') } }); + }; + + _class2.prototype['@test it should merge classBinding with class'] = function testItShouldMergeClassBindingWithClass() { + var _this13 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="birdman:respeck" class="myName"}}', { birdman: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck myName ember-view') } }); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck myName ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with only truthy condition'] = function testItShouldApplyClassBindingWithOnlyTruthyCondition() { + var _this14 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName:respeck"}}', { myName: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck ember-view') } }); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with only falsy condition'] = function testItShouldApplyClassBindingWithOnlyFalsyCondition() { + var _this15 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName::shade"}}', { myName: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('shade ember-view') } }); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('shade ember-view') } }); + }; + + _class2.prototype['@test it should apply nothing when classBinding is falsy but only supplies truthy class'] = function testItShouldApplyNothingWhenClassBindingIsFalsyButOnlySuppliesTruthyClass() { + var _this16 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName:respeck"}}', { myName: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + }; + + _class2.prototype['@test it should apply nothing when classBinding is truthy but only supplies falsy class'] = function testItShouldApplyNothingWhenClassBindingIsTruthyButOnlySuppliesFalsyClass() { + var _this17 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName::shade"}}', { myName: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with falsy condition'] = function testItShouldApplyClassBindingWithFalsyCondition() { + var _this18 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { swag: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('scrub ember-view') } }); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('scrub ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with truthy condition'] = function testItShouldApplyClassBindingWithTruthyCondition() { + var _this19 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { swag: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fresh ember-view') } }); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fresh ember-view') } }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/class-bindings-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/class-bindings-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/class-bindings-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/contextual-components-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{component (component "-looked-up") "Hodari" greeting="Hodi"}}'], ['\n {{component (component "-looked-up") "Hodari" greeting="Hodi"}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{component (component "-looked-up" "Hodari" greeting="Hodi")\n greeting="Hola"}}'], ['\n {{component (component "-looked-up" "Hodari" greeting="Hodi")\n greeting="Hola"}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash comp=(component "-looked-up" greeting=model.greeting)) as |my|}}\n {{#my.comp}}{{/my.comp}}\n {{/with}}'], ['\n {{#with (hash comp=(component "-looked-up" greeting=model.greeting)) as |my|}}\n {{#my.comp}}{{/my.comp}}\n {{/with}}']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}\n {{#with (component first greeting="Hej" name="Sigmundur") as |second|}}\n {{component second greeting=model.greeting}}\n {{/with}}\n {{/with}}'], ['\n {{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}\n {{#with (component first greeting="Hej" name="Sigmundur") as |second|}}\n {{component second greeting=model.greeting}}\n {{/with}}\n {{/with}}']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup}}\n {{/with}}']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup expectedText=model.expectedText}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup expectedText=model.expectedText}}\n {{/with}}']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up" expectedText=model.expectedText)) as |object|}}\n {{object.lookedup}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up" expectedText=model.expectedText)) as |object|}}\n {{object.lookedup}}\n {{/with}}']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup model.expectedText "Hola"}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup model.expectedText "Hola"}}\n {{/with}}']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash my-component=(component \'my-component\' first)) as |c|}}\n {{c.my-component}}\n {{/with}}'], ['\n {{#with (hash my-component=(component \'my-component\' first)) as |c|}}\n {{c.my-component}}\n {{/with}}']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#my-component my-attr=myProp as |api|}}\n {{api.my-nested-component}}\n {{/my-component}}\n
\n '], ['\n {{#my-component my-attr=myProp as |api|}}\n {{api.my-nested-component}}\n {{/my-component}}\n
\n ']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#select-box as |sb|}}\n {{sb.option label="Foo"}}\n {{sb.option}}\n {{/select-box}}'], ['\n {{#select-box as |sb|}}\n {{sb.option label="Foo"}}\n {{sb.option}}\n {{/select-box}}']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n '], ['\n ']), + _templateObject13 = babelHelpers.taggedTemplateLiteralLoose(['\n {{component (component "change-button" model.val2)}}\n {{model.val2}}'], ['\n {{component (component "change-button" model.val2)}}\n {{model.val2}}']), + _templateObject14 = babelHelpers.taggedTemplateLiteralLoose(['\n message: {{message}}{{inner-component message=message}}\n '], ['\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: contextual components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test renders with component helper'] = function testRendersWithComponentHelper() { + var _this = this; + + var expectedText = 'Hodi'; + + this.registerComponent('-looked-up', { + template: expectedText + }); + + this.render('{{component (component "-looked-up")}}'); + + this.assertText(expectedText); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with component helper with invocation params, hash'] = function testRendersWithComponentHelperWithInvocationParamsHash() { + var _this2 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertText('Hodi Hodari'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Hodi Hodari'); + }; + + _class.prototype['@test GH#13742 keeps nested rest positional parameters if rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfRenderedWithNoPositionalParameters() { + var _this3 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component "-looked-up" model.greeting model.name)}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this3.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('Good morning Zack'); + + this.runTask(function () { + return _this3.context.set('model.name', 'Matthew'); + }); + + this.assertText('Good morning Matthew'); + + this.runTask(function () { + return _this3.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('Gabon Zack'); + }; + + // Take a look at this one. Seems to pass even when currying isn't implemented. + + _class.prototype['@test overwrites nested rest positional parameters if rendered with positional parameters'] = function testOverwritesNestedRestPositionalParametersIfRenderedWithPositionalParameters() { + var _this4 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component "-looked-up" model.greeting model.name) model.name model.greeting}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this4.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('ZackGood morning '); + + this.runTask(function () { + return _this4.context.set('model.name', 'Matthew'); + }); + + this.assertText('MatthewGood morning '); + + this.runTask(function () { + return _this4.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('ZackGabon '); + }; + + _class.prototype['@test GH#13742 keeps nested rest positional parameters if nested and rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfNestedAndRenderedWithNoPositionalParameters() { + var _this5 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component (component "-looked-up" model.greeting model.name))}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this5.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('Good morning Zack'); + + this.runTask(function () { + return _this5.context.set('model.name', 'Matthew'); + }); + + this.assertText('Good morning Matthew'); + + this.runTask(function () { + return _this5.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('Gabon Zack'); + }; + + _class.prototype['@test overwrites nested rest positional parameters if nested with new pos params and rendered with no positional parameters'] = function testOverwritesNestedRestPositionalParametersIfNestedWithNewPosParamsAndRenderedWithNoPositionalParameters() { + var _this6 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component (component "-looked-up" model.greeting model.name) model.name model.greeting)}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this6.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('ZackGood morning '); + + this.runTask(function () { + return _this6.context.set('model.name', 'Matthew'); + }); + + this.assertText('MatthewGood morning '); + + this.runTask(function () { + return _this6.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('ZackGabon '); + }; + + _class.prototype['@test renders with component helper with curried params, hash'] = function testRendersWithComponentHelperWithCurriedParamsHash() { + var _this7 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertText('Hola Hodari'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('Hola Hodari'); + }; + + _class.prototype['@test updates when component path is bound'] = function testUpdatesWhenComponentPathIsBound() { + var _this8 = this; + + this.registerComponent('-mandarin', { + template: 'ni hao' + }); + + this.registerComponent('-hindi', { + template: 'Namaste' + }); + + this.render('{{component (component model.lookupComponent)}}', { + model: { + lookupComponent: '-mandarin' + } + }); + + this.assertText('ni hao'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('ni hao'); + + this.runTask(function () { + return _this8.context.set('model.lookupComponent', '-hindi'); + }); + + this.assertText('Namaste'); + + this.runTask(function () { + return _this8.context.set('model', { lookupComponent: '-mandarin' }); + }); + + this.assertText('ni hao'); + }; + + _class.prototype['@test updates when curried hash argument is bound'] = function testUpdatesWhenCurriedHashArgumentIsBound() { + var _this9 = this; + + this.registerComponent('-looked-up', { + template: '{{greeting}}' + }); + + this.render('{{component (component "-looked-up" greeting=model.greeting)}}', { + model: { + greeting: 'Hodi' + } + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this9.context.set('model.greeting', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this9.context.set('model', { greeting: 'Hodi' }); + }); + + this.assertText('Hodi'); + }; + + _class.prototype['@test updates when curried hash arguments is bound in block form'] = function testUpdatesWhenCurriedHashArgumentsIsBoundInBlockForm() { + var _this10 = this; + + this.registerComponent('-looked-up', { + template: '{{greeting}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3), { + model: { + greeting: 'Hodi' + } + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this10.context.set('model.greeting', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this10.context.set('model', { greeting: 'Hodi' }); + }); + + this.assertText('Hodi'); + }; + + _class.prototype['@test nested components overwrite named positional parameters'] = function testNestedComponentsOverwriteNamedPositionalParameters() { + var _this11 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}} {{age}}' + }); + + this.render('{{component (component (component "-looked-up" "Sergio" 29) "Marvin" 21) "Hodari"}}'); + + this.assertText('Hodari 21'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('Hodari 21'); + }; + + _class.prototype['@test nested components overwrite hash parameters'] = function testNestedComponentsOverwriteHashParameters() { + var _this12 = this; + + this.registerComponent('-looked-up', { + template: '{{greeting}} {{name}} {{age}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4), { + model: { + greeting: 'Hodi' + } + }); + + this.assertText('Hodi Sigmundur 33'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('Hodi Sigmundur 33'); + + this.runTask(function () { + return _this12.context.set('model.greeting', 'Kaixo'); + }); + + this.assertText('Kaixo Sigmundur 33'); + + this.runTask(function () { + return _this12.context.set('model', { greeting: 'Hodi' }); + }); + + this.assertText('Hodi Sigmundur 33'); + }; + + _class.prototype['@test bound outer named parameters get updated in the right scope'] = function testBoundOuterNamedParametersGetUpdatedInTheRightScope() { + var _this13 = this; + + this.registerComponent('-inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['comp'] + }), + template: '{{component comp "Inner"}}' + }); + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}} {{age}}' + }); + + this.render('{{component "-inner-component" (component "-looked-up" model.outerName model.outerAge)}}', { + model: { + outerName: 'Outer', + outerAge: 28 + } + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this13.context.set('model.outerAge', 29); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + return _this13.context.set('model.outerName', 'Not outer'); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + _this13.context.set('model', { + outerName: 'Outer', + outerAge: 28 + }); + }); + + this.assertText('Inner 28'); + }; + + _class.prototype['@test bound outer hash parameters get updated in the right scope'] = function testBoundOuterHashParametersGetUpdatedInTheRightScope() { + var _this14 = this; + + this.registerComponent('-inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['comp'] + }), + template: '{{component comp name="Inner"}}' + }); + + this.registerComponent('-looked-up', { + template: '{{name}} {{age}}' + }); + + this.render('{{component "-inner-component" (component "-looked-up" name=model.outerName age=model.outerAge)}}', { + model: { + outerName: 'Outer', + outerAge: 28 + } + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this14.context.set('model.outerAge', 29); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + return _this14.context.set('model.outerName', 'Not outer'); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + _this14.context.set('model', { + outerName: 'Outer', + outerAge: 28 + }); + }); + + this.assertText('Inner 28'); + }; + + _class.prototype['@test conflicting positional and hash parameters raise and assertion if in the same component context'] = function testConflictingPositionalAndHashParametersRaiseAndAssertionIfInTheSameComponentContext() { + var _this15 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + expectAssertion(function () { + _this15.render('{{component (component "-looked-up" "Hodari" name="Sergio") "Hodari" greeting="Hodi"}}'); + }, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.'); + }; + + _class.prototype['@test conflicting positional and hash parameters does not raise an assertion if rerendered'] = function testConflictingPositionalAndHashParametersDoesNotRaiseAnAssertionIfRerendered() { + var _this16 = this; + + // In some cases, rerendering with a positional param used to cause an + // assertion. This test checks it does not. + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render('{{component (component "-looked-up" model.name greeting="Hodi")}}', { + model: { + name: 'Hodari' + } + }); + + this.assertText('Hodi Hodari'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('Hodi Hodari'); + + this.runTask(function () { + return _this16.context.set('model.name', 'Sergio'); + }); + + this.assertText('Hodi Sergio'); + + this.runTask(function () { + return _this16.context.set('model', { name: 'Hodari' }); + }); + + this.assertText('Hodi Hodari'); + }; + + _class.prototype['@test conflicting positional and hash parameters does not raise an assertion if in different component context'] = function testConflictingPositionalAndHashParametersDoesNotRaiseAnAssertionIfInDifferentComponentContext() { + var _this17 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render('{{component (component "-looked-up" "Hodari") name="Sergio" greeting="Hodi"}}'); + + this.assertText('Hodi Sergio'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('Hodi Sergio'); + }; + + _class.prototype['@test raises an asserton when component path is null'] = function testRaisesAnAssertonWhenComponentPathIsNull() { + var _this18 = this; + + expectAssertion(function () { + _this18.render('{{component (component lookupComponent)}}'); + }); + }; + + _class.prototype['@test raises an assertion when component path is not a component name (static)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameStatic() { + var _this19 = this; + + expectAssertion(function () { + _this19.render('{{component (component "not-a-component")}}'); + }, 'The component helper cannot be used without a valid component name. You used "not-a-component" via (component "not-a-component")'); + }; + + _class.prototype['@test raises an assertion when component path is not a component name (dynamic)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameDynamic() { + var _this20 = this; + + expectAssertion(function () { + _this20.render('{{component (component compName)}}', { + compName: 'not-a-component' + }); + }, /The component helper cannot be used without a valid component name. You used "not-a-component" via \(component .*\)/); + }; + + _class.prototype['@test renders with dot path'] = function testRendersWithDotPath() { + var _this21 = this; + + var expectedText = 'Hodi'; + this.registerComponent('-looked-up', { + template: expectedText + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5)); + + this.assertText(expectedText); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with dot path and attr'] = function testRendersWithDotPathAndAttr() { + var _this22 = this; + + var expectedText = 'Hodi'; + this.registerComponent('-looked-up', { + template: '{{expectedText}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6), { + model: { + expectedText: expectedText + } + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this22.context.set('model.expectedText', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this22.context.set('model', { expectedText: expectedText }); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with dot path and curried over attr'] = function testRendersWithDotPathAndCurriedOverAttr() { + var _this23 = this; + + var expectedText = 'Hodi'; + this.registerComponent('-looked-up', { + template: '{{expectedText}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7), { + model: { + expectedText: expectedText + } + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this23.context.set('model.expectedText', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this23.context.set('model', { expectedText: expectedText }); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with dot path and with rest positional parameters'] = function testRendersWithDotPathAndWithRestPositionalParameters() { + var _this24 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{params}}' + }); + + var expectedText = 'Hodi'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8), { + model: { + expectedText: expectedText + } + }); + + this.assertText(expectedText + ',Hola'); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText(expectedText + ',Hola'); + + this.runTask(function () { + return _this24.context.set('model.expectedText', 'Kaixo'); + }); + + this.assertText('Kaixo,Hola'); + + this.runTask(function () { + return _this24.context.set('model', { expectedText: expectedText }); + }); + + this.assertText(expectedText + ',Hola'); + }; + + _class.prototype['@test renders with dot path and rest parameter does not leak'] = function testRendersWithDotPathAndRestParameterDoesNotLeak(assert) { + // In the original implementation, positional parameters were not handled + // correctly causing the first positional parameter to be the contextual + // component itself. + var value = false; + + this.registerComponent('my-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + value = this.getAttr('value'); + } + }).reopenClass({ + positionalParams: ['value'] + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9), { first: 'first' }); + + assert.equal(value, 'first', 'value is the expected parameter'); + }; + + _class.prototype['@test renders with dot path and updates attributes'] = function testRendersWithDotPathAndUpdatesAttributes(assert) { + var _this25 = this; + + this.registerComponent('my-nested-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + this.set('myProp', this.getAttr('my-parent-attr')); + } + }), + template: '{{myProp}}' + }); + + this.registerComponent('my-component', { + template: '{{yield (hash my-nested-component=(component "my-nested-component" my-parent-attr=my-attr))}}' + }); + + this.registerComponent('my-action-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + changeValue: function () { + this.incrementProperty('myProp'); + } + } + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10) + }); + + this.render('{{my-action-component myProp=model.myProp}}', { + model: { + myProp: 1 + } + }); + + assert.equal(this.$('#nested-prop').text(), '1'); + + this.runTask(function () { + return _this25.rerender(); + }); + + assert.equal(this.$('#nested-prop').text(), '1'); + + this.runTask(function () { + return _this25.$('button').click(); + }); + + assert.equal(this.$('#nested-prop').text(), '2'); + + this.runTask(function () { + return _this25.$('button').click(); + }); + + assert.equal(this.$('#nested-prop').text(), '3'); + + this.runTask(function () { + return _this25.context.set('model', { myProp: 1 }); + }); + + assert.equal(this.$('#nested-prop').text(), '1'); + }; + + _class.prototype['@test adding parameters to a contextual component\'s instance does not add it to other instances'] = function testAddingParametersToAContextualComponentSInstanceDoesNotAddItToOtherInstances() { + var _this26 = this; + + // If parameters and attributes are not handled correctly, setting a value + // in an invokation can leak to others invocation. + this.registerComponent('select-box', { + template: '{{yield (hash option=(component "select-box-option"))}}' + }); + + this.registerComponent('select-box-option', { + template: '{{label}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11)); + + this.assertText('Foo'); + + this.runTask(function () { + return _this26.rerender(); + }); + + this.assertText('Foo'); + }; + + _class.prototype['@test parameters in a contextual component are mutable when value is a param'] = function testParametersInAContextualComponentAreMutableWhenValueIsAParam(assert) { + var _this27 = this; + + // This checks that a `(mut)` is added to parameters and attributes to + // contextual components when it is a param. + + this.registerComponent('change-button', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['val'] + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject13), { + model: { + val2: 8 + } + }); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this27.rerender(); + }); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this27.$('.my-button').click(); + }); + + assert.equal(this.$('.value').text(), '10'); + + this.runTask(function () { + return _this27.context.set('model', { val2: 8 }); + }); + + assert.equal(this.$('.value').text(), '8'); + }; + + _class.prototype['@test tagless blockless components render'] = function testTaglessBlocklessComponentsRender(assert) { + var _this28 = this; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }) + }); + + this.render('{{my-comp}}'); + + this.runTask(function () { + return _this28.rerender(); + }); + + assert.equal(this.$().text(), ''); + }; + + _class.prototype['@test GH#13494 tagless blockless component with property binding'] = function testGH13494TaglessBlocklessComponentWithPropertyBinding(assert) { + var _this29 = this; + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + message: 'hello', + actions: { + change: function () { + this.set('message', 'goodbye'); + } + } + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14) + }); + + this.registerComponent('inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }) + }); + + this.render('{{outer-component}}'); + + assert.equal(this.$().text(), 'message: hello'); + + this.runTask(function () { + return _this29.rerender(); + }); + + assert.equal(this.$().text(), 'message: hello'); + + this.runTask(function () { + return _this29.$('button').click(); + }); + + assert.equal(this.$().text(), 'message: goodbye'); + + this.runTask(function () { + return _this29.rerender(); + }); + + assert.equal(this.$().text(), 'message: goodbye'); + }; + + _class.prototype['@test GH#13982 contextual component ref is stable even when bound params change'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChange(assert) { + var _this30 = this; + + var instance = undefined, + previousInstance = undefined; + var initCount = 0; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: '{{if isOpen "open" "closed"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject15), { + isOpen: true + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance was created'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this30.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this30.context.set('isOpen', false); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this30.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this30.context.set('isOpen', true); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + }; + + _class.prototype['@test GH#13982 contextual component ref is stable even when bound params change (bound name param)'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChangeBoundNameParam(assert) { + var _this31 = this; + + var instance = undefined, + previousInstance = undefined; + var initCount = 0; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: '{{if isOpen "open" "closed"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject16), { + compName: 'my-comp', + isOpen: true + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance was created'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this31.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this31.context.set('isOpen', false); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this31.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this31.context.set('isOpen', true); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + }; + + _class.prototype['@test GH#13982 contextual component ref is recomputed when component name param changes'] = function testGH13982ContextualComponentRefIsRecomputedWhenComponentNameParamChanges(assert) { + var _this32 = this; + + var instance = undefined, + previousInstance = undefined; + var initCount = 0; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: 'my-comp: {{if isOpen "open" "closed"}}' + }); + + this.registerComponent('your-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: 'your-comp: {{if isOpen "open" "closed"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject16), { + compName: 'my-comp', + isOpen: true + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance was created'); + assert.equal(previousInstance, undefined, 'there is no previous instance'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'my-comp: open'); + + this.runTask(function () { + return _this32.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance exists after rerender'); + assert.equal(previousInstance, undefined, 'there is no previous instance after rerender'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'my-comp: open'); + + this.runTask(function () { + return _this32.context.set('compName', 'your-comp'); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'an instance was created after component name changed'); + assert.ok(!_emberMetal.isEmpty(previousInstance), 'a previous instance now exists'); + assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object'); + assert.equal(initCount, 2, 'the component was constructed exactly 2 times'); + assert.equal(this.$().text(), 'your-comp: open'); + + this.runTask(function () { + return _this32.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'an instance was created after component name changed (rerender)'); + assert.ok(!_emberMetal.isEmpty(previousInstance), 'a previous instance now exists (rerender)'); + assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object (rerender)'); + assert.equal(initCount, 2, 'the component was constructed exactly 2 times (rerender)'); + assert.equal(this.$().text(), 'your-comp: open'); + + this.runTask(function () { + return _this32.context.set('compName', 'my-comp'); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'an instance was created after component name changed'); + assert.ok(!_emberMetal.isEmpty(previousInstance), 'a previous instance still exists'); + assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object'); + assert.equal(initCount, 3, 'the component was constructed exactly 3 times (rerender)'); + assert.equal(this.$().text(), 'my-comp: open'); + }; + + _class.prototype['@test GH#14508 rest positional params are received when passed as named parameter'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameter() { + var _this33 = this; + + this.registerComponent('my-link', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component "my-link") params=allParams}}', { + allParams: _emberRuntimeSystemNative_array.A(['a', 'b']) + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this33.rerender(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this33.context.get('allParams').pushObject('c'); + }); + + this.assertText('abc'); + + this.runTask(function () { + return _this33.context.get('allParams').popObject(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this33.context.get('allParams').clear(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this33.context.set('allParams', _emberRuntimeSystemNative_array.A(['1', '2'])); + }); + + this.assertText('12'); + + this.runTask(function () { + return _this33.context.set('allParams', _emberRuntimeSystemNative_array.A(['a', 'b'])); + }); + + this.assertText('ab'); + }; + + _class.prototype['@test GH#14508 rest positional params are received when passed as named parameter with dot notation'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameterWithDotNotation() { + var _this34 = this; + + this.registerComponent('my-link', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{#with (hash link=(component "my-link")) as |c|}}{{c.link params=allParams}}{{/with}}', { + allParams: _emberRuntimeSystemNative_array.A(['a', 'b']) + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this34.rerender(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this34.context.get('allParams').pushObject('c'); + }); + + this.assertText('abc'); + + this.runTask(function () { + return _this34.context.get('allParams').popObject(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this34.context.get('allParams').clear(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this34.context.set('allParams', _emberRuntimeSystemNative_array.A(['1', '2'])); + }); + + this.assertText('12'); + + this.runTask(function () { + return _this34.context.set('allParams', _emberRuntimeSystemNative_array.A(['a', 'b'])); + }); + + this.assertText('ab'); + }; + + _class.prototype['@test GH#14632 give useful warning when calling contextual components with input as a name'] = function testGH14632GiveUsefulWarningWhenCallingContextualComponentsWithInputAsAName() { + var _this35 = this; + + expectAssertion(function () { + _this35.render('{{component (component "input" type="text")}}'); + }, 'You cannot use the input helper as a contextual helper. Please extend Ember.TextField or Ember.Checkbox to use it as a contextual component.'); + }; + + _class.prototype['@test GH#14632 give useful warning when calling contextual components with textarea as a name'] = function testGH14632GiveUsefulWarningWhenCallingContextualComponentsWithTextareaAsAName() { + var _this36 = this; + + expectAssertion(function () { + _this36.render('{{component (component "textarea" type="text")}}'); + }, 'You cannot use the textarea helper as a contextual helper. Please extend Ember.TextArea to use it as a contextual component.'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + var ContextualComponentMutableParamsTest = (function (_RenderingTest2) { +babelHelpers.inherits(ContextualComponentMutableParamsTest, _RenderingTest2); + + function ContextualComponentMutableParamsTest() { +babelHelpers.classCallCheck(this, ContextualComponentMutableParamsTest); + + _RenderingTest2.apply(this, arguments); + } + + ContextualComponentMutableParamsTest.prototype.render = function render(templateStr) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + _RenderingTest2.prototype.render.call(this, templateStr + '{{model.val2}}', _emberUtils.assign(context, { model: { val2: 8 } })); + }; + + return ContextualComponentMutableParamsTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var MutableParamTestGenerator = (function () { + function MutableParamTestGenerator(cases) { +babelHelpers.classCallCheck(this, MutableParamTestGenerator); + + this.cases = cases; + } + + MutableParamTestGenerator.prototype.generate = function generate(_ref2) { + var _ref; + + var title = _ref2.title; + var setup = _ref2.setup; + + return _ref = {}, _ref['@test parameters in a contextual component are mutable when value is a ' + title] = function (assert) { + var _this37 = this; + + this.registerComponent('change-button', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['val'] + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject17) + }); + + setup.call(this, assert); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this37.rerender(); + }); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this37.$('.my-button').click(); + }); + + assert.equal(this.$('.value').text(), '10'); + + this.runTask(function () { + return _this37.context.set('model', { val2: 8 }); + }); + + assert.equal(this.$('.value').text(), '8'); + }, _ref; + }; + + return MutableParamTestGenerator; + })(); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(ContextualComponentMutableParamsTest, new MutableParamTestGenerator([{ + title: 'param', + setup: function () { + this.render('{{component (component "change-button" model.val2)}}'); + } + }, { + title: 'nested param', + setup: function () { + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['components'] + }), + template: '{{component components.comp}}' + }); + + this.render('{{my-comp (hash comp=(component "change-button" model.val2))}}'); + } + }, { + title: 'hash value', + setup: function () { + this.registerComponent('my-comp', { + template: '{{component component}}' + }); + + this.render('{{my-comp component=(component "change-button" val=model.val2)}}'); + } + }, { + title: 'nested hash value', + setup: function () { + this.registerComponent('my-comp', { + template: '{{component components.button}}' + }); + + this.render('{{my-comp components=(hash button=(component "change-button" val=model.val2))}}'); + } + }])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: contextual components -- mutable params', ContextualComponentMutableParamsTest); +}); +enifed('ember-glimmer/tests/integration/components/contextual-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/contextual-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/contextual-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/curly-components-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers) { + /* globals EmberDev */ + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{foo-bar class="bar baz"}}\n {{foo-bar classNames="bar baz"}}\n {{foo-bar}}\n '], ['\n {{foo-bar class="bar baz"}}\n {{foo-bar classNames="bar baz"}}\n {{foo-bar}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if cond1}}\n {{#foo-bar id=1}}\n {{#if cond2}}\n {{#foo-bar id=2}}{{/foo-bar}}\n {{#if cond3}}\n {{#foo-bar id=3}}\n {{#if cond4}}\n {{#foo-bar id=4}}\n {{#if cond5}}\n {{#foo-bar id=5}}{{/foo-bar}}\n {{#foo-bar id=6}}{{/foo-bar}}\n {{#foo-bar id=7}}{{/foo-bar}}\n {{/if}}\n {{#foo-bar id=8}}{{/foo-bar}}\n {{/foo-bar}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}'], ['\n {{#if cond1}}\n {{#foo-bar id=1}}\n {{#if cond2}}\n {{#foo-bar id=2}}{{/foo-bar}}\n {{#if cond3}}\n {{#foo-bar id=3}}\n {{#if cond4}}\n {{#foo-bar id=4}}\n {{#if cond5}}\n {{#foo-bar id=5}}{{/foo-bar}}\n {{#foo-bar id=6}}{{/foo-bar}}\n {{#foo-bar id=7}}{{/foo-bar}}\n {{/if}}\n {{#foo-bar id=8}}{{/foo-bar}}\n {{/foo-bar}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if isStream}}\n true\n {{else}}\n false\n {{/if}}\n '], ['\n {{#if isStream}}\n true\n {{else}}\n false\n {{/if}}\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n Args: {{this.attrs.value}} | {{attrs.value}} | {{value}}\n {{#each this.attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each items as |item|}}\n {{item}}\n {{/each}}\n '], ['\n Args: {{this.attrs.value}} | {{attrs.value}} | {{value}}\n {{#each this.attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each items as |item|}}\n {{item}}\n {{/each}}\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['Args: lul | lul | lul111'], ['Args: lul | lul | lul111']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}'], ['\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each names as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each names as |name|}}\n {{name}}\n {{/each}}']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n {{sample-component "Foo" 4 "Bar" elementId="args-3"}}\n {{sample-component "Foo" 4 "Bar" 5 "Baz" elementId="args-5"}}'], ['\n {{sample-component "Foo" 4 "Bar" elementId="args-3"}}\n {{sample-component "Foo" 4 "Bar" 5 "Baz" elementId="args-5"}}']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n {{sample-component "one" "two" elementId="two-positional"}}\n {{sample-component "one" second="two" elementId="one-positional"}}\n {{sample-component first="one" second="two" elementId="no-positional"}}'], ['\n {{sample-component "one" "two" elementId="two-positional"}}\n {{sample-component "one" second="two" elementId="one-positional"}}\n {{sample-component first="one" second="two" elementId="no-positional"}}']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each n as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each n as |name|}}\n {{name}}\n {{/each}}']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-template name="with-block"}}\n [In block - {{name}}]\n {{/with-template}}\n {{with-template name="without-block"}}'], ['\n {{#with-template name="with-block"}}\n [In block - {{name}}]\n {{/with-template}}\n {{with-template name="without-block"}}']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}'], ['\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}']), + _templateObject13 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block}}\n In template\n {{/with-block}}'], ['\n {{#with-block}}\n In template\n {{/with-block}}']), + _templateObject14 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlockParams}}\n {{yield this}} - In Component\n {{else}}\n {{yield}} No Block!\n {{/if}}'], ['\n {{#if hasBlockParams}}\n {{yield this}} - In Component\n {{else}}\n {{yield}} No Block!\n {{/if}}']), + _templateObject15 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block as |something|}}\n In template\n {{/with-block}}'], ['\n {{#with-block as |something|}}\n In template\n {{/with-block}}']), + _templateObject16 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlockParams}}\n {{yield this}}\n {{else}}\n {{yield}} No Block Param!\n {{/if}}'], ['\n {{#if hasBlockParams}}\n {{yield this}}\n {{else}}\n {{yield}} No Block Param!\n {{/if}}']), + _templateObject17 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block}}\n In block\n {{/with-block}}'], ['\n {{#with-block}}\n In block\n {{/with-block}}']), + _templateObject18 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if predicate}}\n Yes:{{yield someValue}}\n {{else}}\n No:{{yield to="inverse"}}\n {{/if}}'], ['\n {{#if predicate}}\n Yes:{{yield someValue}}\n {{else}}\n No:{{yield to="inverse"}}\n {{/if}}']), + _templateObject19 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#my-if predicate=activated someValue=42 as |result|}}\n Hello{{result}}\n {{else}}\n Goodbye\n {{/my-if}}'], ['\n {{#my-if predicate=activated someValue=42 as |result|}}\n Hello{{result}}\n {{else}}\n Goodbye\n {{/my-if}}']), + _templateObject20 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlock "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlock "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject21 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse}}{{else}}{{/check-inverse}}'], ['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse}}{{else}}{{/check-inverse}}']), + _templateObject22 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlock)}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlock)}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject23 = babelHelpers.taggedTemplateLiteralLoose(['\n {{check-block}}\n {{#check-block}}{{/check-block}}'], ['\n {{check-block}}\n {{#check-block}}{{/check-block}}']), + _templateObject24 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlockParams "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlockParams "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject25 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse as |something|}}{{/check-inverse}}'], ['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse as |something|}}{{/check-inverse}}']), + _templateObject26 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject27 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-block}}{{/check-block}}\n {{#check-block as |something|}}{{/check-block}}'], ['\n {{#check-block}}{{/check-block}}\n {{#check-block as |something|}}{{/check-block}}']), + _templateObject28 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlock}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if hasBlock}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject29 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}'], ['\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}']), + _templateObject30 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlockParams}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if hasBlockParams}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject31 = babelHelpers.taggedTemplateLiteralLoose(['\n {{check-attr}}\n {{#check-attr}}{{/check-attr}}'], ['\n {{check-attr}}\n {{#check-attr}}{{/check-attr}}']), + _templateObject32 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr}}{{else}}{{/check-attr}}'], ['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr}}{{else}}{{/check-attr}}']), + _templateObject33 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}'], ['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}']), + _templateObject34 = babelHelpers.taggedTemplateLiteralLoose(['\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}'], ['\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}']), + _templateObject35 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper}}{{else}}{{/check-helper}}'], ['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper}}{{else}}{{/check-helper}}']), + _templateObject36 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}'], ['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}']), + _templateObject37 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#x-outer}}\n {{#if showInner}}\n {{x-inner}}\n {{/if}}\n {{/x-outer}}'], ['\n {{#x-outer}}\n {{#if showInner}}\n {{x-inner}}\n {{/if}}\n {{/x-outer}}']), + _templateObject38 = babelHelpers.taggedTemplateLiteralLoose(['\n In layout. {{#each items as |item|}}\n [{{child-non-block item=item}}]\n {{/each}}'], ['\n In layout. {{#each items as |item|}}\n [{{child-non-block item=item}}]\n {{/each}}']), + _templateObject39 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#some-clicky-thing classNames="baz"}}\n Click Me\n {{/some-clicky-thing}}'], ['\n {{#some-clicky-thing classNames="baz"}}\n Click Me\n {{/some-clicky-thing}}']), + _templateObject40 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each blahzz as |p|}}\n {{p}}\n {{/each}}\n - {{yield}}'], ['\n {{#each blahzz as |p|}}\n {{p}}\n {{/each}}\n - {{yield}}']), + _templateObject41 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#some-clicky-thing blahzz="baz"}}\n Click Me\n {{/some-clicky-thing}}'], ['\n {{#some-clicky-thing blahzz="baz"}}\n Click Me\n {{/some-clicky-thing}}']), + _templateObject42 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#x-select value=value as |select|}}\n {{#x-option value="1" select=select}}1{{/x-option}}\n {{#x-option value="2" select=select}}2{{/x-option}}\n {{/x-select}}\n '], ['\n {{#x-select value=value as |select|}}\n {{#x-option value="1" select=select}}1{{/x-option}}\n {{#x-option value="2" select=select}}2{{/x-option}}\n {{/x-select}}\n ']), + _templateObject43 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#list-items items=items as |thing|}}\n |{{thing}}|\n\n {{#if editMode}}\n Remove {{thing}}\n {{/if}}\n {{/list-items}}\n '], ['\n {{#list-items items=items as |thing|}}\n |{{thing}}|\n\n {{#if editMode}}\n Remove {{thing}}\n {{/if}}\n {{/list-items}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: curly components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can render a basic component'] = function testItCanRenderABasicComponent() { + var _this = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it can render a template only component'] = function testItCanRenderATemplateOnlyComponent() { + var _this2 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it can have a custom id and it is not bound'] = function testItCanHaveACustomIdAndItIsNotBound() { + var _this3 = this; + + this.registerComponent('foo-bar', { template: '{{id}} {{elementId}}' }); + + this.render('{{foo-bar id=customId}}', { + customId: 'bizz' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'customId', 'bar'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bar bizz' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'customId', 'bizz'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); + }; + + _class.prototype['@test elementId cannot change'] = function testElementIdCannotChange(assert) { + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{elementId}}' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, content: 'blahzorz' }); + + if (EmberDev && !EmberDev.runningProdBuild) { + var willThrow = function () { + return _emberMetal.run(null, _emberMetal.set, component, 'elementId', 'herpyderpy'); + }; + + assert.throws(willThrow, /Changing a view's elementId after creation is not allowed/); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, content: 'blahzorz' }); + } + }; + + _class.prototype['@test can specify template with `layoutName` property'] = function testCanSpecifyTemplateWithLayoutNameProperty() { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + layoutName: 'fizz-bar', + init: function () { + this._super.apply(this, arguments); + this.local = 'hey'; + } + }); + + this.registerTemplate('fizz-bar', 'FIZZ BAR {{local}}'); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('FIZZ BAR hey'); + }; + + _class.prototype['@test can specify template with `defaultLayout` property [DEPRECATED]'] = function testCanSpecifyTemplateWithDefaultLayoutPropertyDEPRECATED() { + expectDeprecation(/Specifying `defaultLayout` to .* is deprecated. Please use `layout` instead/); + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + defaultLayout: _emberGlimmerTestsUtilsHelpers.compile('much wat {{lulz}}'), + init: function () { + this._super.apply(this, arguments); + this.lulz = 'hey'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('much wat hey'); + }; + + _class.prototype['@test layout takes precedence over defaultLayout'] = function testLayoutTakesPrecedenceOverDefaultLayout() { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + layout: _emberGlimmerTestsUtilsHelpers.compile('so much layout wat {{lulz}}'), + defaultLayout: _emberGlimmerTestsUtilsHelpers.compile('much wat {{lulz}}'), + init: function () { + this._super.apply(this, arguments); + this.lulz = 'hey'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('so much layout wat hey'); + }; + + _class.prototype['@test layout supports computed property'] = function testLayoutSupportsComputedProperty() { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + layout: _emberMetal.computed(function () { + return _emberGlimmerTestsUtilsHelpers.compile('so much layout wat {{lulz}}'); + }), + init: function () { + this._super.apply(this, arguments); + this.lulz = 'heyo'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('so much layout wat heyo'); + }; + + _class.prototype['@test passing undefined elementId results in a default elementId'] = function testPassingUndefinedElementIdResultsInADefaultElementId(assert) { + var _this4 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'h1' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'something' }); + + this.render('{{foo-bar id=somethingUndefined}}'); + + var foundId = this.$('h1').attr('id'); + assert.ok(/^ember/.test(foundId), 'Has a reasonable id attribute (found id=' + foundId + ').'); + + this.runTask(function () { + return _this4.rerender(); + }); + + var newFoundId = this.$('h1').attr('id'); + assert.ok(/^ember/.test(newFoundId), 'Has a reasonable id attribute (found id=' + newFoundId + ').'); + + assert.equal(foundId, newFoundId); + }; + + _class.prototype['@test id is an alias for elementId'] = function testIdIsAnAliasForElementId(assert) { + var _this5 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'h1' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'something' }); + + this.render('{{foo-bar id="custom-id"}}'); + + var foundId = this.$('h1').attr('id'); + assert.equal(foundId, 'custom-id'); + + this.runTask(function () { + return _this5.rerender(); + }); + + var newFoundId = this.$('h1').attr('id'); + assert.equal(newFoundId, 'custom-id'); + + assert.equal(foundId, newFoundId); + }; + + _class.prototype['@test cannot pass both id and elementId at the same time'] = function testCannotPassBothIdAndElementIdAtTheSameTime(assert) { + var _this6 = this; + + this.registerComponent('foo-bar', { template: '' }); + + expectAssertion(function () { + _this6.render('{{foo-bar id="zomg" elementId="lol"}}'); + }, /You cannot invoke a component with both 'id' and 'elementId' at the same time./); + }; + + _class.prototype['@test it can have a custom tagName'] = function testItCanHaveACustomTagName() { + var _this7 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'foo-bar' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + }; + + _class.prototype['@test it can have a custom tagName set in the constructor'] = function testItCanHaveACustomTagNameSetInTheConstructor() { + var _this8 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + this.tagName = 'foo-bar'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + }; + + _class.prototype['@test it can have a custom tagName from the invocation'] = function testItCanHaveACustomTagNameFromTheInvocation() { + var _this9 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar tagName="foo-bar"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + }; + + _class.prototype['@test tagName can not be a computed property'] = function testTagNameCanNotBeAComputedProperty(assert) { + var _this10 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: _emberMetal.computed(function () { + return 'foo-bar'; + }) + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this10.render('{{foo-bar}}'); + }, /You cannot use a computed property for the component's `tagName` \(<\(.+>\)\./); + }; + + _class.prototype['@test class is applied before didInsertElement'] = function testClassIsAppliedBeforeDidInsertElement(assert) { + var componentClass = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + componentClass = this.element.className; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar class="foo-bar"}}'); + + assert.equal(componentClass, 'foo-bar ember-view'); + }; + + _class.prototype['@test it can have custom classNames'] = function testItCanHaveCustomClassNames() { + var _this11 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: ['foo', 'bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar') }, content: 'hello' }); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar') }, content: 'hello' }); + }; + + _class.prototype['@test should not apply falsy class name'] = function testShouldNotApplyFalsyClassName() { + var _this12 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar class=somethingFalsy}}', { + somethingFalsy: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); + }; + + _class.prototype['@test should apply classes of the dasherized property name when bound property specified is true'] = function testShouldApplyClassesOfTheDasherizedPropertyNameWhenBoundPropertySpecifiedIsTrue() { + var _this13 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar class=model.someTruth}}', { + model: { someTruth: true } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-truth') }, content: 'hello' }); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-truth') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model.someTruth', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model', { someTruth: true }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-truth') }, content: 'hello' }); + }; + + _class.prototype['@test class property on components can be dynamic'] = function testClassPropertyOnComponentsCanBeDynamic() { + var _this14 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar class=(if fooBar "foo-bar")}}', { + fooBar: true + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') } }); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'fooBar', false); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'fooBar', true); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') } }); + }; + + _class.prototype['@test it can have custom classNames from constructor'] = function testItCanHaveCustomClassNamesFromConstructor() { + var _this15 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + this.classNames = this.classNames.slice(); + this.classNames.push('foo', 'bar', 'outside-' + this.get('extraClass')); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar extraClass="baz"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar outside-baz') }, content: 'hello' }); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar outside-baz') }, content: 'hello' }); + }; + + _class.prototype['@test it can set custom classNames from the invocation'] = function testItCanSetCustomClassNamesFromTheInvocation() { + var _this16 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: ['foo'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + }; + + _class.prototype['@test it has an element'] = function testItHasAnElement() { + var _this17 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + var element1 = instance.element; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this17.rerender(); + }); + + var element2 = instance.element; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement(assert) { + var _this18 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + var element1 = instance.$()[0]; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this18.rerender(); + }); + + var element2 = instance.$()[0]; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) { + var _this19 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'inner' }); + + this.render('outer{{foo-bar}}'); + + var $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + + this.runTask(function () { + return _this19.rerender(); + }); + + $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + }; + + _class.prototype['@test an empty component does not have childNodes'] = function testAnEmptyComponentDoesNotHaveChildNodes(assert) { + var _this20 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'input', + init: function () { + this._super(); + fooBarInstance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'input' }); + + assert.strictEqual(fooBarInstance.element.childNodes.length, 0); + + this.runTask(function () { + return _this20.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input' }); + + assert.strictEqual(fooBarInstance.element.childNodes.length, 0); + }; + + _class.prototype['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) { + var _this21 = this; + + var fooBarInstance = undefined, + fooBarBazInstance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + } + }); + + var FooBarBazComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarBazInstance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'foo-bar {{foo-bar-baz}}' }); + this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, template: 'foo-bar-baz' }); + + this.render('{{foo-bar}}'); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + + this.runTask(function () { + return _this21.rerender(); + }); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + }; + + _class.prototype['@test it renders passed named arguments'] = function testItRendersPassedNamedArguments() { + var _this22 = this; + + this.registerComponent('foo-bar', { + template: '{{foo}}' + }); + + this.render('{{foo-bar foo=model.bar}}', { + model: { + bar: 'Hola' + } + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this22.context.set('model.bar', 'Hello'); + }); + + this.assertText('Hello'); + + this.runTask(function () { + return _this22.context.set('model', { bar: 'Hola' }); + }); + + this.assertText('Hola'); + }; + + _class.prototype['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() { + var _this23 = this; + + this.registerComponent('foo-bar', { template: '{{yield}} - In component' }); + + this.render('{{#foo-bar}}hello{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); + }; + + _class.prototype['@test it can render a basic component with a block when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockWhenTheYieldIsInAPartial() { + var _this24 = this; + + this.registerPartial('_partialWithYield', 'yielded: [{{yield}}]'); + + this.registerComponent('foo-bar', { template: '{{partial "partialWithYield"}} - In component' }); + + this.render('{{#foo-bar}}hello{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + }; + + _class.prototype['@test it can render a basic component with a block param when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockParamWhenTheYieldIsInAPartial() { + var _this25 = this; + + this.registerPartial('_partialWithYield', 'yielded: [{{yield "hello"}}]'); + + this.registerComponent('foo-bar', { template: '{{partial "partialWithYield"}} - In component' }); + + this.render('{{#foo-bar as |value|}}{{value}}{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + + this.runTask(function () { + return _this25.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + }; + + _class.prototype['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() { + var _this26 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + this.set('message', 'hello'); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{message}}' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this26.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() { + var _this27 = this; + + this.registerComponent('foo-bar', { template: '{{yield}}' }); + + this.render('{{#foo-bar}}{{message}}{{/foo-bar}}', { message: 'hello' }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this27.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it can yield a block param named for reserved words [GH#14096]'] = function testItCanYieldABlockParamNamedForReservedWordsGH14096() { + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + name: 'foo-bar' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{yield this}}' }); + + this.render('{{#foo-bar as |component|}}{{component.name}}{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'foo-bar' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(instance, 'name', 'derp-qux'); + }); + + this.assertComponentElement(this.firstChild, { content: 'derp-qux' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'name', 'foo-bar'); + }); + + this.assertComponentElement(this.firstChild, { content: 'foo-bar' }); + }; + + _class.prototype['@test it can yield internal and external properties positionally'] = function testItCanYieldInternalAndExternalPropertiesPositionally() { + var _this28 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + greeting: 'hello' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{yield greeting greetee.firstName}}' }); + + this.render('{{#foo-bar greetee=person as |greeting name|}}{{name}} {{person.lastName}}, {{greeting}}{{/foo-bar}}', { + person: { + firstName: 'Joel', + lastName: 'Kang' + } + }); + + this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); + + this.runTask(function () { + return _this28.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); + + this.runTask(function () { + return _emberMetal.set(_this28.context, 'person', { firstName: 'Dora', lastName: 'the Explorer' }); + }); + + this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hello' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'greeting', 'hola'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hola' }); + + this.runTask(function () { + _emberMetal.set(instance, 'greeting', 'hello'); + _emberMetal.set(_this28.context, 'person', { + firstName: 'Joel', + lastName: 'Kang' + }); + }); + + this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); + }; + + _class.prototype['@test #11519 - block param infinite loop'] = function test11519BlockParamInfiniteLoop() { + var _this29 = this; + + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + danger: 0 + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{danger}}{{yield danger}}' }); + + // On initial render, create streams. The bug will not have manifested yet, but at this point + // we have created streams that create a circular invalidation. + this.render('{{#foo-bar as |dangerBlockParam|}}{{/foo-bar}}'); + + this.assertText('0'); + + // Trigger a non-revalidating re-render. The yielded block will not be dirtied + // nor will block param streams, and thus no infinite loop will occur. + this.runTask(function () { + return _this29.rerender(); + }); + + this.assertText('0'); + + // Trigger a revalidation, which will cause an infinite loop without the fix + // in place. Note that we do not see the infinite loop is in testing mode, + // because a deprecation warning about re-renders is issued, which Ember + // treats as an exception. + this.runTask(function () { + return _emberMetal.set(instance, 'danger', 1); + }); + + this.assertText('1'); + + this.runTask(function () { + return _emberMetal.set(instance, 'danger', 0); + }); + + this.assertText('0'); + }; + + _class.prototype['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) { + var _this30 = this; + + var destroyed = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }; + + this.registerComponent('foo-bar', { + template: '{{id}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyed[this.get('id')]++; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + cond1: true, + cond2: true, + cond3: true, + cond4: true, + cond5: true + }); + + this.assertText('1 2 3 4 5 6 7 8 '); + + this.runTask(function () { + return _this30.rerender(); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }); + + this.runTask(function () { + return _emberMetal.set(_this30.context, 'cond5', false); + }); + + this.assertText('1 2 3 4 8 '); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 1, 7: 1, 8: 0 }); + + this.runTask(function () { + _emberMetal.set(_this30.context, 'cond3', false); + _emberMetal.set(_this30.context, 'cond5', true); + _emberMetal.set(_this30.context, 'cond4', false); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + + this.runTask(function () { + _emberMetal.set(_this30.context, 'cond2', false); + _emberMetal.set(_this30.context, 'cond1', false); + }); + + assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + }; + + _class.prototype['@test should escape HTML in normal mustaches'] = function testShouldEscapeHTMLInNormalMustaches() { + var _this31 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + output: 'you need to be more bold' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{output}}' }); + + this.render('{{foo-bar}}'); + + this.assertText('you need to be more bold'); + + this.runTask(function () { + return _this31.rerender(); + }); + + this.assertText('you need to be more bold'); + + this.runTask(function () { + return _emberMetal.set(component, 'output', 'you are so super'); + }); + + this.assertText('you are so super'); + + this.runTask(function () { + return _emberMetal.set(component, 'output', 'you need to be more bold'); + }); + }; + + _class.prototype['@test should not escape HTML in triple mustaches'] = function testShouldNotEscapeHTMLInTripleMustaches(assert) { + var _this32 = this; + + var expectedHtmlBold = 'you need to be more bold'; + var expectedHtmlItalic = 'you are so super'; + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + output: expectedHtmlBold + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{{output}}}' }); + + this.render('{{foo-bar}}'); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _this32.rerender(); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _emberMetal.set(component, 'output', expectedHtmlItalic); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlItalic); + + this.runTask(function () { + return _emberMetal.set(component, 'output', expectedHtmlBold); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + }; + + _class.prototype['@test should not escape HTML if string is a htmlSafe'] = function testShouldNotEscapeHTMLIfStringIsAHtmlSafe(assert) { + var _this33 = this; + + var expectedHtmlBold = 'you need to be more bold'; + var expectedHtmlItalic = 'you are so super'; + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + output: _emberGlimmerTestsUtilsHelpers.htmlSafe(expectedHtmlBold) + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{output}}' }); + + this.render('{{foo-bar}}'); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _this33.rerender(); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _emberMetal.set(component, 'output', _emberGlimmerTestsUtilsHelpers.htmlSafe(expectedHtmlItalic)); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlItalic); + + this.runTask(function () { + return _emberMetal.set(component, 'output', _emberGlimmerTestsUtilsHelpers.htmlSafe(expectedHtmlBold)); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + }; + + _class.prototype['@test late bound layouts return the same definition'] = function testLateBoundLayoutsReturnTheSameDefinition(assert) { + var templateIds = []; + + // This is testing the scenario where you import a template and + // set it to the layout property: + // + // import layout from './template'; + // + // export default Ember.Component.extend({ + // layout + // }); + var hello = _emberGlimmerTestsUtilsHelpers.compile('Hello'); + var bye = _emberGlimmerTestsUtilsHelpers.compile('Bye'); + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.layout = this.cond ? hello : bye; + templateIds.push(this.layout.id); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar cond=true}}{{foo-bar cond=false}}{{foo-bar cond=true}}{{foo-bar cond=false}}'); + + var t1 = templateIds[0]; + var t2 = templateIds[1]; + var t3 = templateIds[2]; + var t4 = templateIds[3]; + + assert.equal(t1, t3); + assert.equal(t2, t4); + }; + + _class.prototype['@test can use isStream property without conflict (#13271)'] = function testCanUseIsStreamPropertyWithoutConflict13271() { + var _this34 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + isStream: true, + + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3) + }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'true' }); + + this.runTask(function () { + return _this34.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'true' }); + + this.runTask(function () { + return _emberMetal.set(component, 'isStream', false); + }); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + + this.runTask(function () { + return _emberMetal.set(component, 'isStream', true); + }); + + this.assertComponentElement(this.firstChild, { content: 'true' }); + }; + + _class.prototype['@test lookup of component takes priority over property'] = function testLookupOfComponentTakesPriorityOverProperty() { + var _this35 = this; + + this.registerComponent('some-component', { + template: 'some-component' + }); + + this.render('{{some-prop}} {{some-component}}', { + 'some-component': 'not-some-component', + 'some-prop': 'some-prop' + }); + + this.assertText('some-prop some-component'); + + this.runTask(function () { + return _this35.rerender(); + }); + + this.assertText('some-prop some-component'); + }; + + _class.prototype['@test component without dash is not looked up'] = function testComponentWithoutDashIsNotLookedUp() { + var _this36 = this; + + this.registerComponent('somecomponent', { + template: 'somecomponent' + }); + + this.render('{{somecomponent}}', { + 'somecomponent': 'notsomecomponent' + }); + + this.assertText('notsomecomponent'); + + this.runTask(function () { + return _this36.rerender(); + }); + + this.assertText('notsomecomponent'); + + this.runTask(function () { + return _this36.context.set('somecomponent', 'not not notsomecomponent'); + }); + + this.assertText('not not notsomecomponent'); + + this.runTask(function () { + return _this36.context.set('somecomponent', 'notsomecomponent'); + }); + + this.assertText('notsomecomponent'); + }; + + _class.prototype['@test non-block with properties on attrs'] = function testNonBlockWithPropertiesOnAttrs() { + var _this37 = this; + + this.registerComponent('non-block', { + template: 'In layout - someProp: {{attrs.someProp}}' + }); + + this.render('{{non-block someProp=prop}}', { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this37.rerender(); + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this37.context.set('prop', 'other thing there'); + }); + + this.assertText('In layout - someProp: other thing there'); + + this.runTask(function () { + return _this37.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here'); + }; + + _class.prototype['@test non-block with properties overridden in init'] = function testNonBlockWithPropertiesOverriddenInInit() { + var _this38 = this; + + var instance = undefined; + this.registerComponent('non-block', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + this.someProp = 'value set in instance'; + } + }), + template: 'In layout - someProp: {{someProp}}' + }); + + this.render('{{non-block someProp=prop}}', { + prop: 'something passed when invoked' + }); + + this.assertText('In layout - someProp: value set in instance'); + + this.runTask(function () { + return _this38.rerender(); + }); + + this.assertText('In layout - someProp: value set in instance'); + + this.runTask(function () { + return _this38.context.set('prop', 'updated something passed when invoked'); + }); + + this.assertText('In layout - someProp: updated something passed when invoked'); + + this.runTask(function () { + return instance.set('someProp', 'update value set in instance'); + }); + + this.assertText('In layout - someProp: update value set in instance'); + + this.runTask(function () { + return _this38.context.set('prop', 'something passed when invoked'); + }); + this.runTask(function () { + return instance.set('someProp', 'value set in instance'); + }); + + this.assertText('In layout - someProp: value set in instance'); + }; + + _class.prototype['@test rerendering component with attrs from parent'] = function testRerenderingComponentWithAttrsFromParent(assert) { + var _this39 = this; + + var willUpdateCount = 0; + var didReceiveAttrsCount = 0; + + function expectHooks(_ref, callback) { + var willUpdate = _ref.willUpdate; + var didReceiveAttrs = _ref.didReceiveAttrs; + + willUpdateCount = 0; + didReceiveAttrsCount = 0; + + callback(); + + if (willUpdate) { + assert.strictEqual(willUpdateCount, 1, 'The willUpdate hook was fired'); + } else { + assert.strictEqual(willUpdateCount, 0, 'The willUpdate hook was not fired'); + } + + if (didReceiveAttrs) { + assert.strictEqual(didReceiveAttrsCount, 1, 'The didReceiveAttrs hook was fired'); + } else { + assert.strictEqual(didReceiveAttrsCount, 0, 'The didReceiveAttrs hook was not fired'); + } + } + + this.registerComponent('non-block', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + didReceiveAttrsCount++; + }, + + willUpdate: function () { + willUpdateCount++; + } + }), + template: 'In layout - someProp: {{someProp}}' + }); + + expectHooks({ willUpdate: false, didReceiveAttrs: true }, function () { + _this39.render('{{non-block someProp=someProp}}', { + someProp: 'wycats' + }); + }); + + this.assertText('In layout - someProp: wycats'); + + // Note: Hooks are not fired in Glimmer for idempotent re-renders + expectHooks({ willUpdate: false, didReceiveAttrs: false }, function () { + _this39.runTask(function () { + return _this39.rerender(); + }); + }); + + this.assertText('In layout - someProp: wycats'); + + expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () { + _this39.runTask(function () { + return _this39.context.set('someProp', 'tomdale'); + }); + }); + + this.assertText('In layout - someProp: tomdale'); + + // Note: Hooks are not fired in Glimmer for idempotent re-renders + expectHooks({ willUpdate: false, didReceiveAttrs: false }, function () { + _this39.runTask(function () { + return _this39.rerender(); + }); + }); + + this.assertText('In layout - someProp: tomdale'); + + expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () { + _this39.runTask(function () { + return _this39.context.set('someProp', 'wycats'); + }); + }); + + this.assertText('In layout - someProp: wycats'); + }; + + _class.prototype['@test this.attrs.foo === attrs.foo === foo'] = function testThisAttrsFooAttrsFooFoo() { + var _this40 = this; + + this.registerComponent('foo-bar', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4) + }); + + this.render('{{foo-bar value=model.value items=model.items}}', { + model: { + value: 'wat', + items: [1, 2, 3] + } + }); + + this.assertStableRerender(); + + this.runTask(function () { + _this40.context.set('model.value', 'lul'); + _this40.context.set('model.items', [1]); + }); + + this.assertText(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5)); + + this.runTask(function () { + return _this40.context.set('model', { value: 'wat', items: [1, 2, 3] }); + }); + + this.assertText('Args: wat | wat | wat123123123'); + }; + + _class.prototype['@test non-block with properties on self'] = function testNonBlockWithPropertiesOnSelf() { + var _this41 = this; + + this.registerComponent('non-block', { + template: 'In layout - someProp: {{someProp}}' + }); + + this.render('{{non-block someProp=prop}}', { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this41.rerender(); + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this41.context.set('prop', 'something else'); + }); + + this.assertText('In layout - someProp: something else'); + + this.runTask(function () { + return _this41.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here'); + }; + + _class.prototype['@test block with properties on self'] = function testBlockWithPropertiesOnSelf() { + var _this42 = this; + + this.registerComponent('with-block', { + template: 'In layout - someProp: {{someProp}} - {{yield}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6), { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this42.rerender(); + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this42.context.set('prop', 'something else'); + }); + + this.assertText('In layout - someProp: something else - In template'); + + this.runTask(function () { + return _this42.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here - In template'); + }; + + _class.prototype['@test block with properties on attrs'] = function testBlockWithPropertiesOnAttrs() { + var _this43 = this; + + this.registerComponent('with-block', { + template: 'In layout - someProp: {{attrs.someProp}} - {{yield}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6), { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this43.rerender(); + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this43.context.set('prop', 'something else'); + }); + + this.assertText('In layout - someProp: something else - In template'); + + this.runTask(function () { + return _this43.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here - In template'); + }; + + _class.prototype['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters(assert) { + var _this44 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8)); + + assert.equal(this.$('#args-3').text(), 'Foo4Bar'); + assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz'); + + this.runTask(function () { + return _this44.rerender(); + }); + + assert.equal(this.$('#args-3').text(), 'Foo4Bar'); + assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz'); + }; + + _class.prototype['@test arbitrary positional parameter conflict with hash parameter is reported'] = function testArbitraryPositionalParameterConflictWithHashParameterIsReported() { + var _this45 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7) + }); + + expectAssertion(function () { + _this45.render('{{sample-component "Foo" 4 "Bar" names=numbers id="args-3"}}', { + numbers: [1, 2, 3] + }); + }, 'You cannot specify positional parameters and the hash argument `names`.'); + }; + + _class.prototype['@test can use hash parameter instead of arbitrary positional param [GH #12444]'] = function testCanUseHashParameterInsteadOfArbitraryPositionalParamGH12444(assert) { + var _this46 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7) + }); + + this.render('{{sample-component names=things}}', { + things: _emberRuntime.A(['Foo', 4, 'Bar']) + }); + + this.assertText('Foo4Bar'); + + this.runTask(function () { + return _this46.rerender(); + }); + + this.assertText('Foo4Bar'); + + this.runTask(function () { + return _this46.context.get('things').pushObject(5); + }); + + this.assertText('Foo4Bar5'); + + this.runTask(function () { + return _this46.context.get('things').shiftObject(); + }); + + this.assertText('4Bar5'); + + this.runTask(function () { + return _this46.context.get('things').clear(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this46.context.set('things', _emberRuntime.A(['Foo', 4, 'Bar'])); + }); + + this.assertText('Foo4Bar'); + }; + + _class.prototype['@test can use hash parameter instead of positional param'] = function testCanUseHashParameterInsteadOfPositionalParam(assert) { + var _this47 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['first', 'second'] + }), + template: '{{first}} - {{second}}' + }); + + // TODO: Fix when id is implemented + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9)); + + assert.equal(this.$('#two-positional').text(), 'one - two'); + assert.equal(this.$('#one-positional').text(), 'one - two'); + assert.equal(this.$('#no-positional').text(), 'one - two'); + + this.runTask(function () { + return _this47.rerender(); + }); + + assert.equal(this.$('#two-positional').text(), 'one - two'); + assert.equal(this.$('#one-positional').text(), 'one - two'); + assert.equal(this.$('#no-positional').text(), 'one - two'); + }; + + _class.prototype['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters(assert) { + var _this48 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'n' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10) + }); + + this.render('{{sample-component user1 user2}}', { + user1: 'Foo', + user2: 4 + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this48.rerender(); + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this48.context.set('user1', 'Bar'); + }); + + this.assertText('Bar4'); + + this.runTask(function () { + return _this48.context.set('user2', '5'); + }); + + this.assertText('Bar5'); + + this.runTask(function () { + _this48.context.set('user1', 'Foo'); + _this48.context.set('user2', 4); + }); + + this.assertText('Foo4'); + }; + + _class.prototype['@test with ariaRole specified'] = function testWithAriaRoleSpecified() { + var _this49 = this; + + this.registerComponent('aria-test', { + template: 'Here!' + }); + + this.render('{{aria-test ariaRole=role}}', { + role: 'main' + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); + + this.runTask(function () { + return _this49.rerender(); + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); + + this.runTask(function () { + return _this49.context.set('role', 'input'); + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'input' } }); + + this.runTask(function () { + return _this49.context.set('role', 'main'); + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); + }; + + _class.prototype['@test `template` specified in component is overriden by block'] = function testTemplateSpecifiedInComponentIsOverridenByBlock() { + var _this50 = this; + + this.registerComponent('with-template', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + template: _emberGlimmerTestsUtilsHelpers.compile('Should not be used') + }), + template: '[In layout - {{name}}] {{yield}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11), { + name: 'Whoop, whoop!' + }); + + this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); + + this.runTask(function () { + return _this50.rerender(); + }); + + this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); + + this.runTask(function () { + return _this50.context.set('name', 'Ole, ole'); + }); + + this.assertText('[In layout - with-block] [In block - Ole, ole][In layout - without-block] '); + + this.runTask(function () { + return _this50.context.set('name', 'Whoop, whoop!'); + }); + + this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); + }; + + _class.prototype['@test hasBlock is true when block supplied'] = function testHasBlockIsTrueWhenBlockSupplied() { + var _this51 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject13)); + + this.assertText('In template'); + + this.runTask(function () { + return _this51.rerender(); + }); + + this.assertText('In template'); + }; + + _class.prototype['@test hasBlock is false when no block supplied'] = function testHasBlockIsFalseWhenNoBlockSupplied() { + var _this52 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12) + }); + + this.render('{{with-block}}'); + + this.assertText('No Block!'); + + this.runTask(function () { + return _this52.rerender(); + }); + + this.assertText('No Block!'); + }; + + _class.prototype['@test hasBlockParams is true when block param supplied'] = function testHasBlockParamsIsTrueWhenBlockParamSupplied() { + var _this53 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject15)); + + this.assertText('In template - In Component'); + + this.runTask(function () { + return _this53.rerender(); + }); + + this.assertText('In template - In Component'); + }; + + _class.prototype['@test hasBlockParams is false when no block param supplied'] = function testHasBlockParamsIsFalseWhenNoBlockParamSupplied() { + var _this54 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject16) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject17)); + + this.assertText('In block No Block Param!'); + + this.runTask(function () { + return _this54.rerender(); + }); + + this.assertText('In block No Block Param!'); + }; + + _class.prototype['@test static named positional parameters'] = function testStaticNamedPositionalParameters() { + var _this55 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}}{{age}}' + }); + + this.render('{{sample-component "Quint" 4}}'); + + this.assertText('Quint4'); + + this.runTask(function () { + return _this55.rerender(); + }); + + this.assertText('Quint4'); + }; + + _class.prototype['@test dynamic named positional parameters'] = function testDynamicNamedPositionalParameters() { + var _this56 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}}{{age}}' + }); + + this.render('{{sample-component myName myAge}}', { + myName: 'Quint', + myAge: 4 + }); + + this.assertText('Quint4'); + + this.runTask(function () { + return _this56.rerender(); + }); + + this.assertText('Quint4'); + + this.runTask(function () { + return _this56.context.set('myName', 'Sergio'); + }); + + this.assertText('Sergio4'); + + this.runTask(function () { + return _this56.context.set('myAge', 2); + }); + + this.assertText('Sergio2'); + + this.runTask(function () { + _this56.context.set('myName', 'Quint'); + _this56.context.set('myAge', 4); + }); + + this.assertText('Quint4'); + }; + + _class.prototype['@test if a value is passed as a non-positional parameter, it raises an assertion'] = function testIfAValueIsPassedAsANonPositionalParameterItRaisesAnAssertion() { + var _this57 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{name}}' + }); + + expectAssertion(function () { + _this57.render('{{sample-component notMyName name=myName}}', { + myName: 'Quint', + notMyName: 'Sergio' + }); + }, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.'); + }; + + _class.prototype['@test yield to inverse'] = function testYieldToInverse() { + var _this58 = this; + + this.registerComponent('my-if', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject18) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject19), { + activated: true + }); + + this.assertText('Yes:Hello42'); + + this.runTask(function () { + return _this58.rerender(); + }); + + this.assertText('Yes:Hello42'); + + this.runTask(function () { + return _this58.context.set('activated', false); + }); + + this.assertText('No:Goodbye'); + + this.runTask(function () { + return _this58.context.set('activated', true); + }); + + this.assertText('Yes:Hello42'); + }; + + _class.prototype['@test expression hasBlock inverse'] = function testExpressionHasBlockInverse(assert) { + this.registerComponent('check-inverse', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject20) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject21)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlock default'] = function testExpressionHasBlockDefault(assert) { + this.registerComponent('check-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject22) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject23)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlockParams inverse'] = function testExpressionHasBlockParamsInverse(assert) { + this.registerComponent('check-inverse', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject24) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject25)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'No' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlockParams default'] = function testExpressionHasBlockParamsDefault(assert) { + this.registerComponent('check-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject26) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject27)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test non-expression hasBlock'] = function testNonExpressionHasBlock(assert) { + this.registerComponent('check-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject28) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject23)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlockParams'] = function testExpressionHasBlockParams(assert) { + this.registerComponent('check-params', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject26) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject29)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test non-expression hasBlockParams'] = function testNonExpressionHasBlockParams(assert) { + this.registerComponent('check-params', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject30) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject29)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock expression in an attribute'] = function testHasBlockExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject31)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'true' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock inverse expression in an attribute'] = function testHasBlockInverseExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }, ''); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject32)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'true' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams expression in an attribute'] = function testHasBlockParamsExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject33)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'true' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams inverse expression in an attribute'] = function testHasBlockParamsInverseExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }, ''); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject33)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'false' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock as a param to a helper'] = function testHasBlockAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if hasBlock "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject34)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock as an expression param to a helper'] = function testHasBlockAsAnExpressionParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlock) "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject34)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock inverse as a param to a helper'] = function testHasBlockInverseAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlock "inverse") "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject35)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams as a param to a helper'] = function testHasBlockParamsAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if hasBlockParams "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject36)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams as an expression param to a helper'] = function testHasBlockParamsAsAnExpressionParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlockParams) "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject36)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams inverse as a param to a helper'] = function testHasBlockParamsInverseAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlockParams "inverse") "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject36)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'false' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test component in template of a yielding component should have the proper parentView'] = function testComponentInTemplateOfAYieldingComponentShouldHaveTheProperParentView(assert) { + var _this59 = this; + + var outer = undefined, + innerTemplate = undefined, + innerLayout = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + } + }), + template: '{{x-inner-in-layout}}{{yield}}' + }); + + this.registerComponent('x-inner-in-template', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerTemplate = this; + } + }) + }); + + this.registerComponent('x-inner-in-layout', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerLayout = this; + } + }) + }); + + this.render('{{#x-outer}}{{x-inner-in-template}}{{/x-outer}}'); + + assert.equal(innerTemplate.parentView, outer, 'receives the wrapping component as its parentView in template blocks'); + assert.equal(innerLayout.parentView, outer, 'receives the wrapping component as its parentView in layout'); + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + + this.runTask(function () { + return _this59.rerender(); + }); + + assert.equal(innerTemplate.parentView, outer, 'receives the wrapping component as its parentView in template blocks'); + assert.equal(innerLayout.parentView, outer, 'receives the wrapping component as its parentView in layout'); + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + }; + + _class.prototype['@test newly-added sub-components get correct parentView'] = function testNewlyAddedSubComponentsGetCorrectParentView(assert) { + var _this60 = this; + + var outer = undefined, + inner = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + } + }) + }); + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + inner = this; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject37), { + showInner: false + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + + this.runTask(function () { + return _this60.rerender(); + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView (after rerender)'); + + this.runTask(function () { + return _this60.context.set('showInner', true); + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + assert.equal(inner.parentView, outer, 'receives the wrapping component as its parentView in template blocks'); + + this.runTask(function () { + return _this60.context.set('showInner', false); + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + }; + + _class.prototype['@test when a property is changed during children\'s rendering'] = function testWhenAPropertyIsChangedDuringChildrenSRendering(assert) { + var _this61 = this; + + var outer = undefined, + middle = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + }, + value: 1 + }), + template: '{{#x-middle}}{{x-inner value=value}}{{/x-middle}}' + }); + + this.registerComponent('x-middle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + middle = this; + }, + value: null + }), + template: '
{{value}}
{{yield}}' + }); + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + value: null, + pushDataUp: _emberMetal.observer('value', function () { + middle.set('value', this.get('value')); + }) + }), + template: '
{{value}}
' + }); + + this.render('{{x-outer}}'); + + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); + assert.equal(this.$('#middle-value').text(), '', 'initial render of middle (observers do not run during init)'); + + this.runTask(function () { + return _this61.rerender(); + }); + + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); + assert.equal(this.$('#middle-value').text(), '', 'initial render of middle (observers do not run during init)'); + + var expectedBacktrackingMessage = /modified "value" twice on <\(.+> in a single render\. It was rendered in "component:x-middle" and modified in "component:x-inner"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + this.runTask(function () { + return outer.set('value', 2); + }); + } else { + expectAssertion(function () { + _this61.runTask(function () { + return outer.set('value', 2); + }); + }, expectedBacktrackingMessage); + + return; + } + + assert.equal(this.$('#inner-value').text(), '2', 'second render of inner'); + assert.equal(this.$('#middle-value').text(), '2', 'second render of middle'); + + this.runTask(function () { + return outer.set('value', 3); + }); + + assert.equal(this.$('#inner-value').text(), '3', 'third render of inner'); + assert.equal(this.$('#middle-value').text(), '3', 'third render of middle'); + + this.runTask(function () { + return outer.set('value', 1); + }); + + assert.equal(this.$('#inner-value').text(), '1', 'reset render of inner'); + assert.equal(this.$('#middle-value').text(), '1', 'reset render of middle'); + }; + + _class.prototype['@test when a shared dependency is changed during children\'s rendering'] = function testWhenASharedDependencyIsChangedDuringChildrenSRendering(assert) { + var _this62 = this; + + var outer = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + }, + value: 1, + wrapper: _emberRuntime.Object.create({ content: null }) + }), + template: '
{{wrapper.content}}
{{x-inner value=value wrapper=wrapper}}' + }); + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + this.get('wrapper').set('content', this.get('value')); + }, + value: null + }), + template: '
{{wrapper.content}}
' + }); + + var expectedBacktrackingMessage = /modified "wrapper\.content" twice on in a single render\. It was rendered in "component:x-outer" and modified in "component:x-inner"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + this.render('{{x-outer}}'); + } else { + expectAssertion(function () { + _this62.render('{{x-outer}}'); + }, expectedBacktrackingMessage); + + return; + } + + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); + assert.equal(this.$('#outer-value').text(), '1', 'initial render of outer'); + + this.runTask(function () { + return _this62.rerender(); + }); + + assert.equal(this.$('#inner-value').text(), '1', 're-render of inner'); + assert.equal(this.$('#outer-value').text(), '1', 're-render of outer'); + + this.runTask(function () { + return outer.set('value', 2); + }); + + assert.equal(this.$('#inner-value').text(), '2', 'second render of inner'); + assert.equal(this.$('#outer-value').text(), '2', 'second render of outer'); + + this.runTask(function () { + return outer.set('value', 3); + }); + + assert.equal(this.$('#inner-value').text(), '3', 'third render of inner'); + assert.equal(this.$('#outer-value').text(), '3', 'third render of outer'); + + this.runTask(function () { + return outer.set('value', 1); + }); + + assert.equal(this.$('#inner-value').text(), '1', 'reset render of inner'); + assert.equal(this.$('#outer-value').text(), '1', 'reset render of outer'); + }; + + _class.prototype['@test non-block with each rendering child components'] = function testNonBlockWithEachRenderingChildComponents() { + var _this63 = this; + + this.registerComponent('non-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject38) + }); + + this.registerComponent('child-non-block', { + template: 'Child: {{item}}.' + }); + + var items = _emberRuntime.A(['Tom', 'Dick', 'Harry']); + + this.render('{{non-block items=items}}', { items: items }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); + + this.runTask(function () { + return _this63.rerender(); + }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); + + this.runTask(function () { + return _this63.context.get('items').pushObject('Sergio'); + }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]'); + + this.runTask(function () { + return _this63.context.get('items').shiftObject(); + }); + + this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]'); + + this.runTask(function () { + return _this63.context.set('items', _emberRuntime.A(['Tom', 'Dick', 'Harry'])); + }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); + }; + + _class.prototype['@test specifying classNames results in correct class'] = function testSpecifyingClassNamesResultsInCorrectClass(assert) { + var _this64 = this; + + this.registerComponent('some-clicky-thing', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'button', + classNames: ['foo', 'bar'] + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject39)); + + // TODO: ember-view is no longer viewable in the classNames array. Bug or + // feature? + var expectedClassNames = ['ember-view', 'foo', 'bar', 'baz']; + + assert.ok(this.$('button').is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + this.$('button').attr('class')); + // `ember-view` is no longer in classNames. + // assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined'); + this.assertComponentElement(this.firstChild, { tagName: 'button', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes(expectedClassNames.join(' ')) } }); + + this.runTask(function () { + return _this64.rerender(); + }); + + assert.ok(this.$('button').is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + this.$('button').attr('class') + ' (rerender)'); + // `ember-view` is no longer in classNames. + // assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined (rerender)'); + this.assertComponentElement(this.firstChild, { tagName: 'button', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes(expectedClassNames.join(' ')) } }); + }; + + _class.prototype['@test specifying custom concatenatedProperties avoids clobbering'] = function testSpecifyingCustomConcatenatedPropertiesAvoidsClobbering(assert) { + var _this65 = this; + + this.registerComponent('some-clicky-thing', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + concatenatedProperties: ['blahzz'], + blahzz: ['blark', 'pory'] + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject40) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject41)); + + this.assertText('blarkporybaz- Click Me'); + + this.runTask(function () { + return _this65.rerender(); + }); + + this.assertText('blarkporybaz- Click Me'); + }; + + _class.prototype['@test a two way binding flows upstream when consumed in the template'] = function testATwoWayBindingFlowsUpstreamWhenConsumedInTheTemplate() { + var _this66 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + + template: '{{bar}}' + }); + + this.render('{{localBar}} - {{foo-bar bar=localBar}}', { + localBar: 'initial value' + }); + + this.assertText('initial value - initial value'); + + this.runTask(function () { + return _this66.rerender(); + }); + + this.assertText('initial value - initial value'); + + if (true) { + expectAssertion(function () { + component.bar = 'foo-bar'; + }, /You must use Ember\.set\(\) to set the `bar` property \(of .+\) to `foo-bar`\./); + + this.assertText('initial value - initial value'); + } + + this.runTask(function () { + component.set('bar', 'updated value'); + }); + + this.assertText('updated value - updated value'); + + this.runTask(function () { + component.set('bar', undefined); + }); + + this.assertText(' - '); + + this.runTask(function () { + _this66.component.set('localBar', 'initial value'); + }); + + this.assertText('initial value - initial value'); + }; + + _class.prototype['@test a two way binding flows upstream through a CP when consumed in the template'] = function testATwoWayBindingFlowsUpstreamThroughACPWhenConsumedInTheTemplate() { + var _this67 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + bar: _emberMetal.computed({ + get: function () { + return this._bar; + }, + + set: function (key, value) { + this._bar = value; + return this._bar; + } + }) + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + + template: '{{bar}}' + }); + + this.render('{{localBar}} - {{foo-bar bar=localBar}}', { + localBar: 'initial value' + }); + + this.assertText('initial value - initial value'); + + this.runTask(function () { + return _this67.rerender(); + }); + + this.assertText('initial value - initial value'); + + this.runTask(function () { + component.set('bar', 'updated value'); + }); + + this.assertText('updated value - updated value'); + + this.runTask(function () { + _this67.component.set('localBar', 'initial value'); + }); + + this.assertText('initial value - initial value'); + }; + + _class.prototype['@test a two way binding flows upstream through a CP without template consumption'] = function testATwoWayBindingFlowsUpstreamThroughACPWithoutTemplateConsumption() { + var _this68 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + bar: _emberMetal.computed({ + get: function () { + return this._bar; + }, + + set: function (key, value) { + this._bar = value; + return this._bar; + } + }) + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '' + }); + + this.render('{{localBar}}{{foo-bar bar=localBar}}', { + localBar: 'initial value' + }); + + this.assertText('initial value'); + + this.runTask(function () { + return _this68.rerender(); + }); + + this.assertText('initial value'); + + this.runTask(function () { + component.set('bar', 'updated value'); + }); + + this.assertText('updated value'); + + this.runTask(function () { + _this68.component.set('localBar', 'initial value'); + }); + + this.assertText('initial value'); + }; + + _class.prototype['@test services can be injected into components'] = function testServicesCanBeInjectedIntoComponents() { + var _this69 = this; + + var service = undefined; + this.registerService('name', _emberRuntime.Service.extend({ + init: function () { + this._super.apply(this, arguments); + service = this; + }, + last: 'Jackson' + })); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + name: _emberRuntime.inject.service() + }), + template: '{{name.last}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('Jackson'); + + this.runTask(function () { + return _this69.rerender(); + }); + + this.assertText('Jackson'); + + this.runTask(function () { + service.set('last', 'McGuffey'); + }); + + this.assertText('McGuffey'); + + this.runTask(function () { + service.set('last', 'Jackson'); + }); + + this.assertText('Jackson'); + }; + + _class.prototype['@test injecting an unknown service raises an exception'] = function testInjectingAnUnknownServiceRaisesAnException(assert) { + var _this70 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + missingService: _emberRuntime.inject.service() + }) + }); + + expectAssertion(function () { + _this70.render('{{foo-bar}}'); + }, 'Attempting to inject an unknown injection: \'service:missingService\''); + }; + + _class.prototype['@test can access `actions` hash via `_actions` [DEPRECATED]'] = function testCanAccessActionsHashVia_actionsDEPRECATED() { + var _this71 = this; + + var component = undefined; + + function derp() {} + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + actions: { + derp: derp + } + }) + }); + + this.render('{{foo-bar}}'); + + this.assert.strictEqual(component.actions.derp, derp); + + expectDeprecation(function () { + _this71.assert.strictEqual(component._actions.derp, derp); + }, 'Usage of `_actions` is deprecated, use `actions` instead.'); + }; + + _class.prototype['@test throws if `this._super` is not called from `init`'] = function testThrowsIfThis_superIsNotCalledFromInit() { + var _this72 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () {} + }) + }); + + expectAssertion(function () { + _this72.render('{{foo-bar}}'); + }, /You must call `this._super\(...arguments\);` when overriding `init` on a framework object. Please update .* to call `this._super\(...arguments\);` from `init`./); + }; + + _class.prototype['@test should toggle visibility with isVisible'] = function testShouldToggleVisibilityWithIsVisible(assert) { + var _this73 = this; + + var assertStyle = function (expected) { + var matcher = _emberGlimmerTestsUtilsTestHelpers.styles(expected); + var actual = _this73.firstChild.getAttribute('style'); + + assert.pushResult({ + result: matcher.match(actual), + message: matcher.message(), + actual: actual, + expected: expected + }); + }; + + this.registerComponent('foo-bar', { + template: '

foo

' + }); + + this.render('{{foo-bar id="foo-bar" isVisible=visible}}', { + visible: false + }); + + assertStyle('display: none;'); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this73.context, 'visible', true); + }); + assertStyle(''); + + this.runTask(function () { + _emberMetal.set(_this73.context, 'visible', false); + }); + assertStyle('display: none;'); + }; + + _class.prototype['@test isVisible does not overwrite component style'] = function testIsVisibleDoesNotOverwriteComponentStyle(assert) { + var _this74 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + style: _emberGlimmerTestsUtilsHelpers.htmlSafe('color: blue;') + }), + + template: '

foo

' + }); + + this.render('{{foo-bar id="foo-bar" isVisible=visible}}', { + visible: false + }); + + this.assertComponentElement(this.firstChild, { + tagName: 'div', + attrs: { id: 'foo-bar', style: _emberGlimmerTestsUtilsTestHelpers.styles('color: blue; display: none;') } + }); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this74.context, 'visible', true); + }); + + this.assertComponentElement(this.firstChild, { + tagName: 'div', + attrs: { id: 'foo-bar', style: _emberGlimmerTestsUtilsTestHelpers.styles('color: blue;') } + }); + + this.runTask(function () { + _emberMetal.set(_this74.context, 'visible', false); + }); + + this.assertComponentElement(this.firstChild, { + tagName: 'div', + attrs: { id: 'foo-bar', style: _emberGlimmerTestsUtilsTestHelpers.styles('color: blue; display: none;') } + }); + }; + + _class.prototype['@test adds isVisible binding when style binding is missing and other bindings exist'] = function testAddsIsVisibleBindingWhenStyleBindingIsMissingAndOtherBindingsExist(assert) { + var _this75 = this; + + var assertStyle = function (expected) { + var matcher = _emberGlimmerTestsUtilsTestHelpers.styles(expected); + var actual = _this75.firstChild.getAttribute('style'); + + assert.pushResult({ + result: matcher.match(actual), + message: matcher.message(), + actual: actual, + expected: expected + }); + }; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo'], + foo: 'bar' + }), + template: '

foo

' + }); + + this.render('{{foo-bar id="foo-bar" foo=foo isVisible=visible}}', { + visible: false, + foo: 'baz' + }); + + assertStyle('display: none;'); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this75.context, 'visible', true); + }); + + assertStyle(''); + + this.runTask(function () { + _emberMetal.set(_this75.context, 'visible', false); + _emberMetal.set(_this75.context, 'foo', 'woo'); + }); + + assertStyle('display: none;'); + assert.equal(this.firstChild.getAttribute('foo'), 'woo'); + }; + + _class.prototype['@test it can use readDOMAttr to read input value'] = function testItCanUseReadDOMAttrToReadInputValue() { + var _this76 = this; + + var component = undefined; + var assertElement = function (expectedValue) { + // value is a property, not an attribute + _this76.assertHTML(''); + _this76.assert.equal(_this76.firstChild.value, expectedValue, 'value property is correct'); + _this76.assert.equal(_emberMetal.get(component, 'value'), expectedValue, 'component.get("value") is correct'); + }; + + this.registerComponent('one-way-input', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'input', + attributeBindings: ['value'], + + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + change: function () { + var value = this.readDOMAttr('value'); + this.set('value', value); + } + }) + }); + + this.render('{{one-way-input value=value}}', { + value: 'foo' + }); + + assertElement('foo'); + + this.assertStableRerender(); + + this.runTask(function () { + _this76.firstChild.value = 'bar'; + _this76.$('input').trigger('change'); + }); + + assertElement('bar'); + + this.runTask(function () { + _this76.firstChild.value = 'foo'; + _this76.$('input').trigger('change'); + }); + + assertElement('foo'); + + this.runTask(function () { + _emberMetal.set(component, 'value', 'bar'); + }); + + assertElement('bar'); + + this.runTask(function () { + _this76.firstChild.value = 'foo'; + _this76.$('input').trigger('change'); + }); + + assertElement('foo'); + }; + + _class.prototype['@test child triggers revalidate during parent destruction (GH#13846)'] = function testChildTriggersRevalidateDuringParentDestructionGH13846() { + this.registerComponent('x-select', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'select', + + init: function () { + this._super(); + this.options = _emberRuntime.A([]); + this.value = null; + }, + + updateValue: function () { + var newValue = this.get('options.lastObject.value'); + + this.set('value', newValue); + }, + + registerOption: function (option) { + this.get('options').addObject(option); + }, + + unregisterOption: function (option) { + this.get('options').removeObject(option); + + this.updateValue(); + } + }), + + template: '{{yield this}}' + }); + + this.registerComponent('x-option', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'option', + attributeBindings: ['selected'], + + didInsertElement: function () { + this._super.apply(this, arguments); + + this.get('select').registerOption(this); + }, + + selected: _emberMetal.computed('select.value', function () { + return this.get('value') === this.get('select.value'); + }), + + willDestroyElement: function () { + this._super.apply(this, arguments); + this.get('select').unregisterOption(this); + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject42)); + + this.teardown(); + + this.assert.ok(true, 'no errors during teardown'); + }; + + _class.prototype['@test setting a property in willDestroyElement does not assert (GH#14273)'] = function testSettingAPropertyInWillDestroyElementDoesNotAssertGH14273(assert) { + assert.expect(2); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.showFoo = true; + }, + + willDestroyElement: function () { + this.set('showFoo', false); + assert.ok(true, 'willDestroyElement was fired'); + this._super.apply(this, arguments); + } + }), + + template: '{{#if showFoo}}things{{/if}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('things'); + }; + + _class.prototype['@test using didInitAttrs as an event is deprecated'] = function testUsingDidInitAttrsAsAnEventIsDeprecated(assert) { + var _this77 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + foo: _emberMetal.on('didInitAttrs', function () { + assert.ok(true, 'should fire `didInitAttrs` event'); + }) + }) + }); + + expectDeprecation(function () { + _this77.render('{{foo-bar}}'); + }, /didInitAttrs called/); + }; + + // This test is a replication of the "component unit tests" scenario. When we deprecate + // and remove them, this test could be removed as well. This is not fully/intentionally + // supported, and it is unclear that this particular behavior is actually relied on. + // Since there is no real "invocation" here, it has other issues and inconsistencies, + // like there is no real "attrs" here, and there is no "update" pass. + + _class.prototype['@test did{Init,Receive}Attrs fires even if component is not rendered'] = function testDidInitReceiveAttrsFiresEvenIfComponentIsNotRendered(assert) { + var _this78 = this; + + expectDeprecation(/didInitAttrs called/); + + var didInitAttrsCount = 0; + var didReceiveAttrsCount = 0; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.didInit = true; + }, + + didInitAttrs: function () { + assert.ok(this.didInit, 'expected init to have run before didInitAttrs'); + didInitAttrsCount++; + }, + + didReceiveAttrs: function () { + assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs'); + didReceiveAttrsCount++; + }, + + willRender: function () { + throw new Error('Unexpected render!'); + } + }) + }); + + assert.strictEqual(didInitAttrsCount, 0, 'precond: didInitAttrs is not fired'); + assert.strictEqual(didReceiveAttrsCount, 0, 'precond: didReceiveAttrs is not fired'); + + this.runTask(function () { + return _this78.component = _this78.owner.lookup('component:foo-bar'); + }); + + assert.strictEqual(didInitAttrsCount, 1, 'precond: didInitAttrs is fired'); + assert.strictEqual(didReceiveAttrsCount, 1, 'precond: didReceiveAttrs is fired'); + }; + + _class.prototype['@test did{Init,Receive}Attrs fires after .init() but before observers become active'] = function testDidInitReceiveAttrsFiresAfterInitButBeforeObserversBecomeActive(assert) { + var _this79 = this; + + expectDeprecation(/didInitAttrs called/); + + var fooCopyDidChangeCount = 0; + var barCopyDidChangeCount = 0; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.didInit = true; + }, + + didInitAttrs: function (_ref2) { + var attrs = _ref2.attrs; + + assert.ok(this.didInit, 'expected init to have run before didInitAttrs'); + this.set('fooCopy', attrs.foo.value + 1); + }, + + didReceiveAttrs: function (_ref3) { + var newAttrs = _ref3.newAttrs; + + assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs'); + this.set('barCopy', newAttrs.bar.value + 1); + }, + + fooCopyDidChange: _emberMetal.observer('fooCopy', function () { + fooCopyDidChangeCount++; + }), + barCopyDidChange: _emberMetal.observer('barCopy', function () { + barCopyDidChangeCount++; + }) + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + + this.assertText('1-2-3-4'); + + assert.strictEqual(fooCopyDidChangeCount, 0, 'expected NO observer firing for: fooCopy'); + assert.strictEqual(barCopyDidChangeCount, 0, 'expected NO observer firing for: barCopy'); + + this.runTask(function () { + return _emberMetal.set(_this79.context, 'foo', 5); + }); + + this.assertText('5-2-3-4'); + + assert.strictEqual(fooCopyDidChangeCount, 0, 'expected observer firing for: fooCopy'); + assert.strictEqual(barCopyDidChangeCount, 0, 'expected NO observer firing for: barCopy'); + + this.runTask(function () { + return _emberMetal.set(_this79.context, 'bar', 7); + }); + + this.assertText('5-2-7-8'); + + assert.strictEqual(fooCopyDidChangeCount, 0, 'expected observer firing for: fooCopy'); + assert.strictEqual(barCopyDidChangeCount, 1, 'expected observer firing for: barCopy'); + }; + + _class.prototype['@test overriding didReceiveAttrs does not trigger deprecation'] = function testOverridingDidReceiveAttrsDoesNotTriggerDeprecation(assert) { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + assert.equal(1, this.get('foo'), 'expected attrs to have correct value'); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + }; + + _class.prototype['@test can access didReceiveAttrs arguments [DEPRECATED]'] = function testCanAccessDidReceiveAttrsArgumentsDEPRECATED(assert) { + expectDeprecation(/didReceiveAttrs.*stop taking arguments/); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function (_ref4) { + var attrs = _ref4.attrs; + + assert.equal(1, attrs.foo.value, 'expected attrs to have correct value'); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + }; + + _class.prototype['@test can access didUpdateAttrs arguments [DEPRECATED]'] = function testCanAccessDidUpdateAttrsArgumentsDEPRECATED(assert) { + var _this80 = this; + + expectDeprecation(/didUpdateAttrs.*stop taking arguments/); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didUpdateAttrs: function (_ref5) { + var newAttrs = _ref5.newAttrs; + + assert.equal(5, newAttrs.foo.value, "expected newAttrs to have new value"); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + + this.runTask(function () { + return _emberMetal.set(_this80.context, 'foo', 5); + }); + }; + + _class.prototype['@test overriding didUpdateAttrs does not trigger deprecation'] = function testOverridingDidUpdateAttrsDoesNotTriggerDeprecation(assert) { + var _this81 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didUpdateAttrs: function () { + assert.equal(5, this.get('foo'), "expected newAttrs to have new value"); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + + this.runTask(function () { + return _emberMetal.set(_this81.context, 'foo', 5); + }); + }; + + _class.prototype['@test returning `true` from an action does not bubble if `target` is not specified (GH#14275)'] = function testReturningTrueFromAnActionDoesNotBubbleIfTargetIsNotSpecifiedGH14275(assert) { + var _this82 = this; + + this.registerComponent('display-toggle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + assert.ok(true, 'display-toggle show action was called'); + return true; + } + } + }), + + template: '' + }); + + this.render('{{display-toggle}}', { + send: function () { + assert.notOk(true, 'send should not be called when action is not "subscribed" to'); + } + }); + + this.assertText('Show'); + + this.runTask(function () { + return _this82.$('button').click(); + }); + }; + + _class.prototype['@test returning `true` from an action bubbles to the `target` if specified'] = function testReturningTrueFromAnActionBubblesToTheTargetIfSpecified(assert) { + var _this83 = this; + + assert.expect(4); + + this.registerComponent('display-toggle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + assert.ok(true, 'display-toggle show action was called'); + return true; + } + } + }), + + template: '' + }); + + this.render('{{display-toggle target=this}}', { + send: function (actionName) { + assert.ok(true, 'send should be called when action is "subscribed" to'); + assert.equal(actionName, 'show'); + } + }); + + this.assertText('Show'); + + this.runTask(function () { + return _this83.$('button').click(); + }); + }; + + _class.prototype['@test component yielding in an {{#each}} has correct block values after rerendering (GH#14284)'] = function testComponentYieldingInAnEachHasCorrectBlockValuesAfterRerenderingGH14284() { + var _this84 = this; + + this.registerComponent('list-items', { + template: '{{#each items as |item|}}{{yield item}}{{/each}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject43), { + editMode: false, + items: ['foo', 'bar', 'qux', 'baz'] + }); + + this.assertText('|foo||bar||qux||baz|'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this84.context, 'editMode', true); + }); + + this.assertText('|foo|Remove foo|bar|Remove bar|qux|Remove qux|baz|Remove baz'); + + this.runTask(function () { + return _emberMetal.set(_this84.context, 'editMode', false); + }); + + this.assertText('|foo||bar||qux||baz|'); + }; + + _class.prototype['@test unimplimented positionalParams do not cause an error GH#14416'] = function testUnimplimentedPositionalParamsDoNotCauseAnErrorGH14416(assert) { + this.registerComponent('foo-bar', { + template: 'hello' + }); + + this.render('{{foo-bar wat}}'); + this.assertText('hello'); + }; + + _class.prototype['@test using attrs for positional params'] = function testUsingAttrsForPositionalParams(assert) { + var MyComponent = _emberGlimmerTestsUtilsHelpers.Component.extend(); + + this.registerComponent('foo-bar', { + ComponentClass: MyComponent.reopenClass({ + positionalParams: ['myVar'] + }), + template: 'MyVar1: {{attrs.myVar}} {{myVar}} MyVar2: {{myVar2}} {{attrs.myVar2}}' + }); + + this.render('{{foo-bar 1 myVar2=2}}'); + + this.assertText('MyVar1: 1 1 MyVar2: 2 2'); + }; + + _class.prototype['@test can use `{{this}}` to emit the component\'s toString value [GH#14581]'] = function testCanUseThisToEmitTheComponentSToStringValueGH14581(assert) { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + toString: function () { + return 'special sauce goes here!'; + } + }), + template: '{{this}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('special sauce goes here!'); + }; + + _class.prototype['@test can use `{{this` to access paths on current context [GH#14581]'] = function testCanUseThisToAccessPathsOnCurrentContextGH14581(assert) { + var instance = undefined; + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + + instance = this; + }, + + foo: { + bar: { + baz: 'huzzah!' + } + } + }), + template: '{{this.foo.bar.baz}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('huzzah!'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(instance, 'foo.bar.baz', 'yippie!'); + }); + + this.assertText('yippie!'); + + this.runTask(function () { + return _emberMetal.set(instance, 'foo.bar.baz', 'huzzah!'); + }); + + this.assertText('huzzah!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/curly-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/curly-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/curly-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/dynamic-components-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if cond1}}\n {{#component "foo-bar" id=1}}\n {{#if cond2}}\n {{#component "foo-bar" id=2}}{{/component}}\n {{#if cond3}}\n {{#component "foo-bar" id=3}}\n {{#if cond4}}\n {{#component "foo-bar" id=4}}\n {{#if cond5}}\n {{#component "foo-bar" id=5}}{{/component}}\n {{#component "foo-bar" id=6}}{{/component}}\n {{#component "foo-bar" id=7}}{{/component}}\n {{/if}}\n {{#component "foo-bar" id=8}}{{/component}}\n {{/component}}\n {{/if}}\n {{/component}}\n {{/if}}\n {{/if}}\n {{/component}}\n {{/if}}'], ['\n {{#if cond1}}\n {{#component "foo-bar" id=1}}\n {{#if cond2}}\n {{#component "foo-bar" id=2}}{{/component}}\n {{#if cond3}}\n {{#component "foo-bar" id=3}}\n {{#if cond4}}\n {{#component "foo-bar" id=4}}\n {{#if cond5}}\n {{#component "foo-bar" id=5}}{{/component}}\n {{#component "foo-bar" id=6}}{{/component}}\n {{#component "foo-bar" id=7}}{{/component}}\n {{/if}}\n {{#component "foo-bar" id=8}}{{/component}}\n {{/component}}\n {{/if}}\n {{/component}}\n {{/if}}\n {{/if}}\n {{/component}}\n {{/if}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each names as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each names as |name|}}\n {{name}}\n {{/each}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each n as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each n as |name|}}\n {{name}}\n {{/each}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: dynamic components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can render a basic component with a static component name argument'] = function testItCanRenderABasicComponentWithAStaticComponentNameArgument() { + var _this = this; + + this.registerComponent('foo-bar', { template: 'hello {{name}}' }); + + this.render('{{component "foo-bar" name=name}}', { name: 'Sarah' }); + + this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Gavin'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Gavin' }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Sarah'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); + }; + + _class.prototype['@test it can render a basic component with a dynamic component name argument'] = function testItCanRenderABasicComponentWithADynamicComponentNameArgument() { + var _this2 = this; + + this.registerComponent('foo-bar', { template: 'hello {{name}} from foo-bar' }); + this.registerComponent('foo-bar-baz', { template: 'hello {{name}} from foo-bar-baz' }); + + this.render('{{component componentName name=name}}', { componentName: 'foo-bar', name: 'Alex' }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'name', 'Ben'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'componentName', 'foo-bar-baz'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar-baz' }); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'componentName', 'foo-bar'); + _emberMetal.set(_this2.context, 'name', 'Alex'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); + }; + + _class.prototype['@test it has an element'] = function testItHasAnElement() { + var _this3 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{component "foo-bar"}}'); + + var element1 = instance.element; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this3.rerender(); + }); + + var element2 = instance.element; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement(assert) { + var _this4 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{component "foo-bar"}}'); + + var element1 = instance.$()[0]; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this4.rerender(); + }); + + var element2 = instance.$()[0]; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) { + var _this5 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'inner' }); + + this.render('outer{{component "foo-bar"}}'); + + var $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + + this.runTask(function () { + return _this5.rerender(); + }); + + $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + }; + + _class.prototype['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) { + var _this6 = this; + + var fooBarInstance = undefined, + fooBarBazInstance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + } + }); + + var FooBarBazComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarBazInstance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'foo-bar {{foo-bar-baz}}' }); + this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, template: 'foo-bar-baz' }); + + this.render('{{component "foo-bar"}}'); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + + this.runTask(function () { + return _this6.rerender(); + }); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + }; + + _class.prototype['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() { + var _this7 = this; + + this.registerComponent('foo-bar', { template: '{{yield}}' }); + + this.render('{{#component "foo-bar"}}hello{{/component}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() { + var _this8 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + this.set('message', 'hello'); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{message}}' }); + + this.render('{{component "foo-bar"}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() { + var _this9 = this; + + this.registerComponent('foo-bar', { template: '{{yield}}' }); + + this.render('{{#component "foo-bar"}}{{message}}{{/component}}', { message: 'hello' }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) { + var _this10 = this; + + var destroyed = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }; + + this.registerComponent('foo-bar', { + template: '{{id}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyed[this.get('id')]++; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + cond1: true, + cond2: true, + cond3: true, + cond4: true, + cond5: true + }); + + this.assertText('1 2 3 4 5 6 7 8 '); + + this.runTask(function () { + return _this10.rerender(); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'cond5', false); + }); + + this.assertText('1 2 3 4 8 '); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 1, 7: 1, 8: 0 }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond3', false); + _emberMetal.set(_this10.context, 'cond5', true); + _emberMetal.set(_this10.context, 'cond4', false); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond2', false); + _emberMetal.set(_this10.context, 'cond1', false); + }); + + assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + }; + + _class.prototype['@test component helper destroys underlying component when it is swapped out'] = function testComponentHelperDestroysUnderlyingComponentWhenItIsSwappedOut(assert) { + var _this11 = this; + + var destroyed = { 'foo-bar': 0, 'foo-bar-baz': 0 }; + var testContext = this; + + this.registerComponent('foo-bar', { + template: 'hello from foo-bar', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroyElement: function () { + assert.equal(testContext.$('#' + this.elementId).length, 1, 'element is still attached to the document'); + }, + + willDestroy: function () { + this._super(); + destroyed['foo-bar']++; + } + }) + }); + + this.registerComponent('foo-bar-baz', { + template: 'hello from foo-bar-baz', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyed['foo-bar-baz']++; + } + }) + }); + + this.render('{{component componentName name=name}}', { componentName: 'foo-bar' }); + + assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 }); + + this.runTask(function () { + return _this11.rerender(); + }); + + assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 }); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'componentName', 'foo-bar-baz'); + }); + + assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 0 }); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'componentName', 'foo-bar'); + }); + + assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 1 }); + }; + + _class.prototype['@test component helper with bound properties are updating correctly in init of component'] = function testComponentHelperWithBoundPropertiesAreUpdatingCorrectlyInInitOfComponent(assert) { + var _this12 = this; + + this.registerComponent('foo-bar', { + template: 'foo-bar {{location}} {{locationCopy}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('locationCopy', this.get('location')); + } + }) + }); + + this.registerComponent('foo-bar-baz', { + template: 'foo-bar-baz {{location}} {{locationCopy}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('locationCopy', this.get('location')); + } + }) + }); + + this.registerComponent('outer-component', { + template: '{{#component componentName location=location}}arepas!{{/component}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + componentName: _emberMetal.computed('location', function () { + if (this.get('location') === 'Caracas') { + return 'foo-bar'; + } else { + return 'foo-bar-baz'; + } + }) + }) + }); + + this.render('{{outer-component location=location}}', { location: 'Caracas' }); + + this.assertText('foo-bar Caracas Caracas arepas!'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('foo-bar Caracas Caracas arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'location', 'Loisaida'); + }); + + this.assertText('foo-bar-baz Loisaida Loisaida arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'location', 'Caracas'); + }); + + this.assertText('foo-bar Caracas Caracas arepas!'); + }; + + _class.prototype['@test component helper with actions'] = function testComponentHelperWithActions(assert) { + var _this14 = this; + + this.registerComponent('inner-component', { + template: 'inner-component {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: 'inner-component', + didInsertElement: function () { + var _this13 = this; + + // trigger action on click in absence of app's EventDispatcher + this.$().on('click', function () { + _this13.sendAction('somethingClicked'); + }); + }, + willDestroyElement: function () { + this.$().off('click'); + } + }) + }); + + var actionTriggered = 0; + this.registerComponent('outer-component', { + template: '{{#component componentName somethingClicked="mappedAction"}}arepas!{{/component}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: 'outer-component', + componentName: 'inner-component', + actions: { + mappedAction: function () { + actionTriggered++; + } + } + }) + }); + + this.render('{{outer-component}}'); + + assert.equal(actionTriggered, 0, 'action was not triggered'); + + this.runTask(function () { + _this14.$('.inner-component').trigger('click'); + }); + + assert.equal(actionTriggered, 1, 'action was triggered'); + }; + + _class.prototype['@test nested component helpers'] = function testNestedComponentHelpers(assert) { + var _this15 = this; + + this.registerComponent('foo-bar', { template: 'yippie! {{attrs.location}} {{yield}}' }); + this.registerComponent('baz-qux', { template: 'yummy {{attrs.location}} {{yield}}' }); + this.registerComponent('corge-grault', { template: 'delicious {{attrs.location}} {{yield}}' }); + + this.render('{{#component componentName1 location=location}}{{#component componentName2 location=location}}arepas!{{/component}}{{/component}}', { + componentName1: 'foo-bar', + componentName2: 'baz-qux', + location: 'Caracas' + }); + + this.assertText('yippie! Caracas yummy Caracas arepas!'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertText('yippie! Caracas yummy Caracas arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'location', 'Loisaida'); + }); + + this.assertText('yippie! Loisaida yummy Loisaida arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'componentName1', 'corge-grault'); + }); + + this.assertText('delicious Loisaida yummy Loisaida arepas!'); + + this.runTask(function () { + _emberMetal.set(_this15.context, 'componentName1', 'foo-bar'); + _emberMetal.set(_this15.context, 'location', 'Caracas'); + }); + + this.assertText('yippie! Caracas yummy Caracas arepas!'); + }; + + _class.prototype['@test component with dynamic name argument resolving to non-existent component'] = function testComponentWithDynamicNameArgumentResolvingToNonExistentComponent(assert) { + var _this16 = this; + + expectAssertion(function () { + _this16.render('{{component componentName}}', { componentName: 'does-not-exist' }); + }, /Could not find component named "does-not-exist"/); + }; + + _class.prototype['@test component with static name argument for non-existent component'] = function testComponentWithStaticNameArgumentForNonExistentComponent(assert) { + var _this17 = this; + + expectAssertion(function () { + _this17.render('{{component "does-not-exist"}}'); + }, /Could not find component named "does-not-exist"/); + }; + + _class.prototype['@test component with dynamic component name resolving to a component, then non-existent component'] = function testComponentWithDynamicComponentNameResolvingToAComponentThenNonExistentComponent(assert) { + var _this18 = this; + + this.registerComponent('foo-bar', { template: 'hello {{name}}' }); + + this.render('{{component componentName name=name}}', { componentName: 'foo-bar', name: 'Alex' }); + + this.assertText('hello Alex'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('hello Alex'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'componentName', undefined); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'componentName', 'foo-bar'); + }); + + this.assertText('hello Alex'); + }; + + _class.prototype['@test component helper properly invalidates hash params inside an {{each}} invocation #11044'] = function testComponentHelperProperlyInvalidatesHashParamsInsideAnEachInvocation11044(assert) { + var _this19 = this; + + this.registerComponent('foo-bar', { + template: '[{{internalName}} - {{name}}]', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willRender: function () { + // store internally available name to ensure that the name available in `this.attrs.name` + // matches the template lookup name + _emberMetal.set(this, 'internalName', this.get('name')); + } + }) + }); + + this.render('{{#each items as |item|}}{{component "foo-bar" name=item.name}}{{/each}}', { + items: [{ name: 'Robert' }, { name: 'Jacquie' }] + }); + + this.assertText('[Robert - Robert][Jacquie - Jacquie]'); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertText('[Robert - Robert][Jacquie - Jacquie]'); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'items', [{ name: 'Max' }, { name: 'James' }]); + }); + + this.assertText('[Max - Max][James - James]'); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'items', [{ name: 'Robert' }, { name: 'Jacquie' }]); + }); + + this.assertText('[Robert - Robert][Jacquie - Jacquie]'); + }; + + _class.prototype['@test dashless components should not be found'] = function testDashlessComponentsShouldNotBeFound(assert) { + var _this20 = this; + + this.registerComponent('dashless2', { template: 'Do not render me!' }); + + expectAssertion(function () { + _this20.render('{{component "dashless"}}'); + }, /You cannot use 'dashless' as a component name. Component names must contain a hyphen./); + }; + + _class.prototype['@test positional parameters does not clash when rendering different components'] = function testPositionalParametersDoesNotClashWhenRenderingDifferentComponents(assert) { + var _this21 = this; + + this.registerComponent('foo-bar', { + template: 'hello {{name}} ({{age}}) from foo-bar', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }) + }); + + this.registerComponent('foo-bar-baz', { + template: 'hello {{name}} ({{age}}) from foo-bar-baz', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }) + }); + + this.render('{{component componentName name age}}', { + componentName: 'foo-bar', + name: 'Alex', + age: 29 + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'name', 'Ben'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben (29) from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'age', 22); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'componentName', 'foo-bar-baz'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar-baz' }); + + this.runTask(function () { + _emberMetal.set(_this21.context, 'componentName', 'foo-bar'); + _emberMetal.set(_this21.context, 'name', 'Alex'); + _emberMetal.set(_this21.context, 'age', 29); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); + }; + + _class.prototype['@test positional parameters does not pollute the attributes when changing components'] = function testPositionalParametersDoesNotPolluteTheAttributesWhenChangingComponents(assert) { + var _this22 = this; + + this.registerComponent('normal-message', { + template: 'Normal: {{something}}!', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['something'] + }) + }); + + this.registerComponent('alternative-message', { + template: 'Alternative: {{something}} {{somethingElse}}!', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + something: 'Another' + }).reopenClass({ + positionalParams: ['somethingElse'] + }) + }); + + this.render('{{component componentName message}}', { componentName: 'normal-message', message: 'Hello' }); + + this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'componentName', 'alternative-message'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hello!' }); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'message', 'Hi'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hi!' }); + + this.runTask(function () { + _emberMetal.set(_this22.context, 'componentName', 'normal-message'); + _emberMetal.set(_this22.context, 'message', 'Hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); + }; + + _class.prototype['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters(assert) { + var _this23 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2) + }); + + this.render('{{component "sample-component" "Foo" 4 "Bar" 5 "Baz" elementId="helper"}}'); + + this.assertText('Foo4Bar5Baz'); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText('Foo4Bar5Baz'); + }; + + _class.prototype['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters(assert) { + var _this24 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'n' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3) + }); + + this.render('{{component "sample-component" user1 user2}}', { + user1: 'Foo', + user2: 4 + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this24.context.set('user1', 'Bar'); + }); + + this.assertText('Bar4'); + + this.runTask(function () { + return _this24.context.set('user2', '5'); + }); + + this.assertText('Bar5'); + + this.runTask(function () { + _this24.context.set('user1', 'Foo'); + _this24.context.set('user2', 4); + }); + + this.assertText('Foo4'); + }; + + _class.prototype['@test component helper emits useful backtracking re-render assertion message'] = function testComponentHelperEmitsUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this25 = this; + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person', { name: 'Alex' }); + } + }), + template: 'Hi {{person.name}}! {{component "error-component" person=person}}' + }); + + this.registerComponent('error-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person.name', { name: 'Ben' }); + } + }), + template: '{{person.name}}' + }); + + var expectedBacktrackingMessage = /modified "person\.name" twice on \[object Object\] in a single render\. It was rendered in "component:outer-component" and modified in "component:error-component"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + this.render('{{component componentName}}', { componentName: 'outer-component' }); + } else { + expectAssertion(function () { + _this25.render('{{component componentName}}', { componentName: 'outer-component' }); + }, expectedBacktrackingMessage); + } + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/dynamic-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/dynamic-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/dynamic-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/fragment-components-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['
Hey
bar'], ['
Hey
bar']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['bar'], ['bar']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['bizz'], ['bizz']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: fragment components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { + return { + hitDem: 'folks' + }; + }; + + _class.prototype['@test fragments do not render an outer tag'] = function testFragmentsDoNotRenderAnOuterTag() { + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + init: function () { + this._super(); + instance = this; + this.foo = true; + this.bar = 'bar'; + } + }); + + var template = '{{#if foo}}
Hey
{{/if}}{{yield bar}}'; + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + this.render('{{#foo-bar as |bar|}}{{bar}}{{/foo-bar}}'); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(instance, 'foo', false); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.runTask(function () { + return _emberMetal.set(instance, 'bar', 'bizz'); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + _emberMetal.set(instance, 'bar', 'bar'); + _emberMetal.set(instance, 'foo', true); + }); + }; + + _class.prototype['@test throws an error if an event function is defined in a tagless component'] = function testThrowsAnErrorIfAnEventFunctionIsDefinedInATaglessComponent() { + var _this = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + click: function () {} + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You can not define a function that handles DOM events in the .* tagless component since it doesn't have any DOM element./); + }; + + _class.prototype['@test throws an error if a custom defined event function is defined in a tagless component'] = function testThrowsAnErrorIfACustomDefinedEventFunctionIsDefinedInATaglessComponent() { + var _this2 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + folks: function () {} + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this2.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You can not define a function that handles DOM events in the .* tagless component since it doesn't have any DOM element./); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `classNameBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndClassNameBindingsAreSpecified() { + var _this3 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + foo: true, + classNameBindings: ['foo:is-foo:is-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this3.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot use `classNameBindings` on a tag-less component/); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `attributeBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndAttributeBindingsAreSpecified() { + var _this4 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + attributeBindings: ['href'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + expectAssertion(function () { + _this4.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot use `attributeBindings` on a tag-less component/); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `elementId` is specified via JS'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaJS() { + var _this5 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + elementId: 'turntUp' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + expectAssertion(function () { + _this5.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot use `elementId` on a tag-less component/); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `elementId` is specified via template'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaTemplate() { + var _this6 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + expectAssertion(function () { + _this6.render('{{#foo-bar elementId=\'turntUp\'}}{{/foo-bar}}'); + }, /You cannot use `elementId` on a tag-less component/); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via JS'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaJS() { + var template = '{{id}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + id: 'baz' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + this.render('{{#foo-bar}}{{/foo-bar}}'); + this.assertText('baz'); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via template'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaTemplate() { + var template = '{{id}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + this.render('{{#foo-bar id=\'baz\'}}{{/foo-bar}}'); + this.assertText('baz'); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is bound property specified via template'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsBoundPropertySpecifiedViaTemplate() { + var _this7 = this; + + var template = '{{id}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + this.render('{{#foo-bar id=fooBarId}}{{/foo-bar}}', { fooBarId: 'baz' }); + + this.assertText('baz'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'fooBarId', 'qux'); + }); + + this.assertText('qux'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'fooBarId', 'baz'); + }); + + this.assertText('baz'); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via template and passed to child component'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaTemplateAndPassedToChildComponent() { + var fooBarTemplate = '{{#baz-child id=id}}{{/baz-child}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + var BazChildComponent = _emberGlimmerTestsUtilsHelpers.Component.extend(); + var bazChildTemplate = '{{id}}'; + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: fooBarTemplate }); + this.registerComponent('baz-child', { ComponentClass: BazChildComponent, template: bazChildTemplate }); + this.render('{{#foo-bar id=\'baz\'}}{{/foo-bar}}'); + this.assertText('baz'); + }; + + _class.prototype['@test throws an error if when $() is accessed on component where `tagName` is an empty string'] = function testThrowsAnErrorIfWhen$IsAccessedOnComponentWhereTagNameIsAnEmptyString() { + var _this8 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + init: function () { + this._super(); + this.$(); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this8.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot access this.\$\(\) on a component with `tagName: \'\'` specified/); + }; + + _class.prototype['@test renders a contained view with omitted start tag and tagless parent view context'] = function testRendersAContainedViewWithOmittedStartTagAndTaglessParentViewContext() { + var _this9 = this; + + this.registerComponent('root-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'section' + }), + template: '{{frag-ment}}' + }); + + this.registerComponent('frag-ment', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + template: '{{my-span}}' + }); + + this.registerComponent('my-span', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'span' + }), + template: 'dab' + }); + + this.render('{{root-component}}'); + + this.assertElement(this.firstChild, { tagName: 'section' }); + this.assertElement(this.firstChild.firstElementChild, { tagName: 'span' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'section' }); + this.assertElement(this.firstChild.firstElementChild, { tagName: 'span' }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/fragment-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/fragment-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/fragment-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/instrumentation-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components instrumentation', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + var _this = this; + + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.call(this); + + this.resetEvents(); + + _emberMetal.instrumentationSubscribe('render.component', { + before: function (name, timestamp, payload) { + if (payload.view !== _this.component) { + _this.actual.before.push(payload); + } + }, + after: function (name, timestamp, payload) { + if (payload.view !== _this.component) { + _this.actual.after.push(payload); + } + } + }); + } + + _class.prototype.resetEvents = function resetEvents() { + this.expected = { + before: [], + after: [] + }; + + this.actual = { + before: [], + after: [] + }; + }; + + _class.prototype.teardown = function teardown() { + this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)'); + this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)'); + _RenderingTest.prototype.teardown.call(this); + _emberMetal.instrumentationReset(); + }; + + _class.prototype['@test zomg'] = function testZomg(assert) { + assert.ok(true); + }; + + _class.prototype['@test it should receive an instrumentation event for both initial render and updates'] = function testItShouldReceiveAnInstrumentationEventForBothInitialRenderAndUpdates(assert) { + var _this2 = this; + + var testCase = this; + + var BaseClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + + willRender: function () { + testCase.expected.before.push(this); + testCase.expected.after.unshift(this); + } + }); + + this.registerComponent('x-bar', { + template: '[x-bar: {{bar}}] {{yield}}', + ComponentClass: BaseClass.extend() + }); + + this.registerComponent('x-baz', { + template: '[x-baz: {{baz}}]', + ComponentClass: BaseClass.extend() + }); + + this.registerComponent('x-bat', { + template: '[x-bat: {{bat}}]', + ComponentClass: BaseClass.extend() + }); + + this.render('[-top-level: {{foo}}] {{#x-bar bar=bar}}{{x-baz baz=baz}}{{/x-bar}} {{x-bat bat=bat}}', { + foo: 'foo', bar: 'bar', baz: 'baz', bat: 'bat' + }); + + this.assertText('[-top-level: foo] [x-bar: bar] [x-baz: baz] [x-bat: bat]'); + + this.assertEvents('after initial render', true); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertEvents('after no-op rerender'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'foo', 'FOO'); + }); + + this.assertEvents('after updating top-level'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'baz', 'BAZ'); + }); + + this.assertEvents('after updating inner-most'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'bar', 'BAR'); + _emberMetal.set(_this2.context, 'bat', 'BAT'); + }); + + this.assertEvents('after updating the rest'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'foo', 'FOO'); + _emberMetal.set(_this2.context, 'bar', 'BAR'); + _emberMetal.set(_this2.context, 'baz', 'BAZ'); + _emberMetal.set(_this2.context, 'bat', 'BAT'); + }); + + this.assertEvents('after reset'); + }; + + _class.prototype.assertEvents = function assertEvents(label) { + var initialRender = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + var actual = this.actual; + var expected = this.expected; + + this.assert.strictEqual(actual.before.length, actual.after.length, label + ': before and after callbacks should be balanced'); + + this._assertEvents(label + ' (before):', actual.before, expected.before, initialRender); + this._assertEvents(label + ' (after):', actual.before, expected.before, initialRender); + + this.resetEvents(); + }; + + _class.prototype._assertEvents = function _assertEvents(label, actual, expected, initialRender) { + var _this3 = this; + + this.assert.equal(actual.length, expected.length, label + ': expected ' + expected.length + ' and got ' + actual.length); + + actual.forEach(function (payload, i) { + return _this3.assertPayload(payload, expected[i], initialRender); + }); + }; + + _class.prototype.assertPayload = function assertPayload(payload, component, initialRender) { + this.assert.equal(payload.object, component.toString(), 'payload.object'); + this.assert.ok(payload.containerKey, 'the container key should be present'); + this.assert.equal(payload.containerKey, component._debugContainerKey, 'payload.containerKey'); + this.assert.equal(payload.view, component, 'payload.view'); + this.assert.strictEqual(payload.initialRender, initialRender, 'payload.initialRender'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/instrumentation-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/instrumentation-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/instrumentation-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/life-cycle-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-views', 'ember-glimmer/tests/utils/test-helpers', 'ember-utils', 'internal-test-helpers'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberViews, _emberGlimmerTestsUtilsTestHelpers, _emberUtils, _internalTestHelpers) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
\n Twitter: {{', '}}|\n ', '\n
'], ['\n
\n Twitter: {{', '}}|\n ', '\n
']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n Name: {{', '}}|\n ', '\n
'], ['\n
\n Name: {{', '}}|\n ', '\n
']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n Website: {{', '}}\n
'], ['\n
\n Website: {{', '}}\n
']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n ', '|\n ', '|\n ', '\n
'], ['\n
\n ', '|\n ', '|\n ', '\n
']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n Top: ', '\n
'], ['\n
\n Top: ', '\n
']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n Middle: ', '\n
'], ['\n
\n Middle: ', '\n
']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n Bottom: {{', '}}\n
'], ['\n
\n Bottom: {{', '}}\n
']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#nested-item}}Item: {{count}}{{/nested-item}}\n '], ['\n {{#nested-item}}Item: {{count}}{{/nested-item}}\n ']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#nested-item}}Nothing to see here{{/nested-item}}\n '], ['\n {{#nested-item}}Nothing to see here{{/nested-item}}\n ']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each items as |item|}}\n ', '\n {{else}}\n ', '\n {{/each}}\n '], ['\n {{#each items as |item|}}\n ', '\n {{else}}\n ', '\n {{/each}}\n ']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n {{yield}}\n
    \n {{#nested-component nestedId=(concat itemId \'-A\')}}A{{/nested-component}}\n {{#nested-component nestedId=(concat itemId \'-B\')}}B{{/nested-component}}\n
\n '], ['\n {{yield}}\n
    \n {{#nested-component nestedId=(concat itemId \'-A\')}}A{{/nested-component}}\n {{#nested-component nestedId=(concat itemId \'-B\')}}B{{/nested-component}}\n
\n ']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each items as |item|}}\n {{#parent-component itemId=item.id}}{{item.id}}{{/parent-component}}\n {{/each}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=6}}6{{/parent-component}}\n {{/if}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=7}}7{{/parent-component}}\n {{/if}}\n '], ['\n {{#each items as |item|}}\n {{#parent-component itemId=item.id}}{{item.id}}{{/parent-component}}\n {{/each}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=6}}6{{/parent-component}}\n {{/if}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=7}}7{{/parent-component}}\n {{/if}}\n ']); + + var LifeCycleHooksTest = (function (_RenderingTest) { +babelHelpers.inherits(LifeCycleHooksTest, _RenderingTest); + + function LifeCycleHooksTest() { +babelHelpers.classCallCheck(this, LifeCycleHooksTest); + + _RenderingTest.call(this); + this.hooks = []; + this.components = {}; + this.componentRegistry = []; + this.teardownAssertions = []; + } + + LifeCycleHooksTest.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + + for (var i = 0; i < this.teardownAssertions.length; i++) { + this.teardownAssertions[i](); + } + }; + + LifeCycleHooksTest.prototype.getBootOptions = function getBootOptions() { + return { + isInteractive: this.isInteractive + }; + }; + + /* abstract */ + + /* abstract */ + + LifeCycleHooksTest.prototype.invocationFor = function invocationFor(name) { + var namedArgs = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + throw new Error('Not implemented: `invocationFor`'); + }; + + /* abstract */ + + LifeCycleHooksTest.prototype.attrFor = function attrFor(name) { + throw new Error('Not implemented: `attrFor`'); + }; + + LifeCycleHooksTest.prototype.assertRegisteredViews = function assertRegisteredViews(label) { + var viewRegistry = this.owner.lookup('-view-registry:main'); + var topLevelId = _emberViews.getViewId(this.component); + var actual = Object.keys(viewRegistry).sort().filter(function (id) { + return id !== topLevelId; + }); + + if (this.isInteractive) { + var expected = this.componentRegistry.sort(); + + this.assert.deepEqual(actual, expected, 'registered views - ' + label); + } else { + this.assert.deepEqual(actual, [], 'no views should be registered for non-interactive mode'); + } + }; + + LifeCycleHooksTest.prototype.registerComponent = function registerComponent(name, _ref) { + var _this = this; + + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; + + var pushComponent = function (instance) { + _this.components[name] = instance; + _this.componentRegistry.push(_emberViews.getViewId(instance)); + }; + + var removeComponent = function (instance) { + var index = _this.componentRegistry.indexOf(instance); + _this.componentRegistry.splice(index, 1); + + delete _this.components[name]; + }; + + var pushHook = function (hookName, args) { + _this.hooks.push(hook(name, hookName, args)); + }; + + var assertParentView = function (hookName, instance) { + _this.assert.ok(instance.parentView, 'parentView should be present in ' + hookName); + + if (hookName === 'willDestroyElement') { + _this.assert.ok(instance.parentView.childViews.indexOf(instance) !== -1, 'view is still connected to parentView in ' + hookName); + } + }; + + var assertElement = function (hookName, instance) { + var inDOM = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; + + if (instance.tagName === '') { + return; + } + + _this.assert.ok(_emberViews.getViewElement(instance), 'element should be present on ' + instance + ' during ' + hookName); + + if (_this.isInteractive) { + _this.assert.ok(instance.element, 'this.element should be present on ' + instance + ' during ' + hookName); + _this.assert.equal(document.body.contains(instance.element), inDOM, 'element for ' + instance + ' ' + (inDOM ? 'should' : 'should not') + ' be in the DOM during ' + hookName); + } else { + _this.assert.throws(function () { + return instance.element; + }, /Accessing `this.element` is not allowed in non-interactive environments/); + } + }; + + var assertNoElement = function (hookName, instance) { + _this.assert.strictEqual(_emberViews.getViewElement(instance), null, 'element should not be present in ' + hookName); + + if (_this.isInteractive) { + _this.assert.strictEqual(instance.element, null, 'this.element should not be present in ' + hookName); + } else { + _this.assert.throws(function () { + return instance.element; + }, /Accessing `this.element` is not allowed in non-interactive environments/); + } + }; + + var assertState = function (hookName, expectedState, instance) { + _this.assert.equal(instance._state, expectedState, 'within ' + hookName + ' the expected _state is ' + expectedState); + }; + + var isInteractive = this.isInteractive; + + var ComponentClass = this.ComponentClass.extend({ + init: function () { + var _this2 = this, + _arguments = arguments; + + expectDeprecation(function () { + _this2._super.apply(_this2, _arguments); + }, /didInitAttrs called/); + + this.isInitialRender = true; + this.componentName = name; + pushHook('init'); + pushComponent(this); + assertParentView('init', this); + assertNoElement('init', this); + assertState('init', 'preRender', this); + + this.on('init', function () { + return pushHook('on(init)'); + }); + + _emberMetal.run.scheduleOnce('afterRender', function () { + _this2.isInitialRender = false; + }); + }, + + didInitAttrs: function (options) { + pushHook('didInitAttrs', options); + assertParentView('didInitAttrs', this); + assertNoElement('didInitAttrs', this); + assertState('didInitAttrs', 'preRender', this); + }, + + didReceiveAttrs: function (options) { + pushHook('didReceiveAttrs', options); + assertParentView('didReceiveAttrs', this); + + if (this.isInitialRender) { + assertNoElement('didReceiveAttrs', this); + assertState('didReceiveAttrs', 'preRender', this); + } else { + assertElement('didReceiveAttrs', this); + + if (isInteractive) { + assertState('didReceiveAttrs', 'inDOM', this); + } else { + assertState('didReceiveAttrs', 'hasElement', this); + } + } + }, + + willInsertElement: function () { + pushHook('willInsertElement'); + assertParentView('willInsertElement', this); + assertElement('willInsertElement', this, false); + assertState('willInsertElement', 'hasElement', this); + }, + + willRender: function () { + pushHook('willRender'); + assertParentView('willRender', this); + + if (this.isInitialRender) { + assertNoElement('willRender', this, false); + assertState('willRender', 'preRender', this); + } else { + assertElement('willRender', this); + assertState('willRender', 'inDOM', this); + } + }, + + didInsertElement: function () { + pushHook('didInsertElement'); + assertParentView('didInsertElement', this); + assertElement('didInsertElement', this); + assertState('didInsertElement', 'inDOM', this); + }, + + didRender: function () { + pushHook('didRender'); + assertParentView('didRender', this); + assertElement('didRender', this); + assertState('didRender', 'inDOM', this); + }, + + didUpdateAttrs: function (options) { + pushHook('didUpdateAttrs', options); + assertParentView('didUpdateAttrs', this); + + if (isInteractive) { + assertState('didUpdateAttrs', 'inDOM', this); + } else { + assertState('didUpdateAttrs', 'hasElement', this); + } + }, + + willUpdate: function (options) { + pushHook('willUpdate', options); + assertParentView('willUpdate', this); + assertElement('willUpdate', this); + assertState('willUpdate', 'inDOM', this); + }, + + didUpdate: function (options) { + pushHook('didUpdate', options); + assertParentView('didUpdate', this); + assertElement('didUpdate', this); + assertState('didUpdate', 'inDOM', this); + }, + + willDestroyElement: function () { + pushHook('willDestroyElement'); + assertParentView('willDestroyElement', this); + assertElement('willDestroyElement', this); + assertState('willDestroyElement', 'inDOM', this); + }, + + willClearRender: function () { + pushHook('willClearRender'); + assertParentView('willClearRender', this); + assertElement('willClearRender', this); + assertState('willClearRender', 'inDOM', this); + }, + + didDestroyElement: function () { + pushHook('didDestroyElement'); + assertNoElement('didDestroyElement', this); + assertState('didDestroyElement', 'destroying', this); + }, + + willDestroy: function () { + pushHook('willDestroy'); + removeComponent(this); + + this._super.apply(this, arguments); + } + }); + + _RenderingTest.prototype.registerComponent.call(this, name, { ComponentClass: ComponentClass, template: template }); + }; + + LifeCycleHooksTest.prototype.assertHooks = function assertHooks(_ref2) { + var label = _ref2.label; + var interactive = _ref2.interactive; + var nonInteractive = _ref2.nonInteractive; + + var rawHooks = this.isInteractive ? interactive : nonInteractive; + var hooks = rawHooks.map(function (raw) { + return hook.apply(undefined, raw); + }); + this.assert.deepEqual(json(this.hooks), json(hooks), label); + this.hooks = []; + }; + + LifeCycleHooksTest.prototype['@test lifecycle hooks are invoked in a predictable order'] = function testLifecycleHooksAreInvokedInAPredictableOrder() { + var _this3 = this; + + var _boundHelpers = this.boundHelpers; + var attr = _boundHelpers.attr; + var invoke = _boundHelpers.invoke; + + this.registerComponent('the-top', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, attr('twitter'), invoke('the-middle', { name: string('Tom Dale') })) + }); + + this.registerComponent('the-middle', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, attr('name'), invoke('the-bottom', { website: string('tomdale.net') })) + }); + + this.registerComponent('the-bottom', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3, attr('website')) + }); + + this.render(invoke('the-top', { twitter: expr('twitter') }), { twitter: '@tomdale' }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + this.assertRegisteredViews('intial render'); + + var topAttrs = { twitter: '@tomdale' }; + var middleAttrs = { name: 'Tom Dale' }; + var bottomAttrs = { website: 'tomdale.net' }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [ + // Sync hooks + + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)'], ['the-bottom', 'willRender'], ['the-bottom', 'willInsertElement'], + + // Async hooks + + ['the-bottom', 'didInsertElement'], ['the-bottom', 'didRender'], ['the-middle', 'didInsertElement'], ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)']] + }); + + this.runTask(function () { + return _this3.components['the-bottom'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (bottom)', + + interactive: [ + // Sync hooks + ['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], ['the-bottom', 'willUpdate'], ['the-bottom', 'willRender'], + + // Async hooks + + ['the-bottom', 'didUpdate'], ['the-bottom', 'didRender'], ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this3.components['the-middle'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (middle)', + + interactive: [ + // Sync hooks + + ['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], + + // Async hooks + + ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this3.components['the-top'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (top)', + + interactive: [ + // Sync hooks + + ['the-top', 'willUpdate'], ['the-top', 'willRender'], + + // Async hooks + + ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'twitter', '@horsetomdale'); + }); + + this.assertText('Twitter: @horsetomdale|Name: Tom Dale|Website: tomdale.net'); + + // Because the `twitter` attr is only used by the topmost component, + // and not passed down, we do not expect to see lifecycle hooks + // called for child components. If the `didReceiveAttrs` hook used + // the new attribute to rerender itself imperatively, that would result + // in lifecycle hooks being invoked for the child. + + topAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + + this.assertHooks({ + label: 'after update', + + interactive: [ + // Sync hooks + + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs], ['the-top', 'willUpdate'], ['the-top', 'willRender'], + + // Async hooks + + ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs]] + }); + + this.teardownAssertions.push(function () { + _this3.assertHooks({ + label: 'destroy', + + interactive: [['the-top', 'willDestroyElement'], ['the-top', 'willClearRender'], ['the-middle', 'willDestroyElement'], ['the-middle', 'willClearRender'], ['the-bottom', 'willDestroyElement'], ['the-bottom', 'willClearRender'], ['the-top', 'didDestroyElement'], ['the-middle', 'didDestroyElement'], ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']], + + nonInteractive: [['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']] + }); + + _this3.assertRegisteredViews('after destroy'); + }); + }; + + LifeCycleHooksTest.prototype['@test lifecycle hooks are invoked in a correct sibling order'] = function testLifecycleHooksAreInvokedInACorrectSiblingOrder() { + var _this4 = this; + + var _boundHelpers2 = this.boundHelpers; + var attr = _boundHelpers2.attr; + var invoke = _boundHelpers2.invoke; + + this.registerComponent('the-parent', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4, invoke('the-first-child', { twitter: expr(attr('twitter')) }), invoke('the-second-child', { name: expr(attr('name')) }), invoke('the-last-child', { website: expr(attr('website')) })) + }); + + this.registerComponent('the-first-child', { template: 'Twitter: {{' + attr('twitter') + '}}' }); + + this.registerComponent('the-second-child', { template: 'Name: {{' + attr('name') + '}}' }); + + this.registerComponent('the-last-child', { template: 'Website: {{' + attr('website') + '}}' }); + + this.render(invoke('the-parent', { + twitter: expr('twitter'), + name: expr('name'), + website: expr('website') + }), { + twitter: '@tomdale', + name: 'Tom Dale', + website: 'tomdale.net' + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + this.assertRegisteredViews('intial render'); + + var parentAttrs = { twitter: '@tomdale', name: 'Tom Dale', website: 'tomdale.net' }; + var firstAttrs = { twitter: '@tomdale' }; + var secondAttrs = { name: 'Tom Dale' }; + var lastAttrs = { website: 'tomdale.net' }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [ + // Sync hooks + + ['the-parent', 'init'], ['the-parent', 'didInitAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'didReceiveAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'on(init)'], ['the-parent', 'willRender'], ['the-parent', 'willInsertElement'], ['the-first-child', 'init'], ['the-first-child', 'didInitAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'didReceiveAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'on(init)'], ['the-first-child', 'willRender'], ['the-first-child', 'willInsertElement'], ['the-second-child', 'init'], ['the-second-child', 'didInitAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'didReceiveAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'on(init)'], ['the-second-child', 'willRender'], ['the-second-child', 'willInsertElement'], ['the-last-child', 'init'], ['the-last-child', 'didInitAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'didReceiveAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'on(init)'], ['the-last-child', 'willRender'], ['the-last-child', 'willInsertElement'], + + // Async hooks + + ['the-first-child', 'didInsertElement'], ['the-first-child', 'didRender'], ['the-second-child', 'didInsertElement'], ['the-second-child', 'didRender'], ['the-last-child', 'didInsertElement'], ['the-last-child', 'didRender'], ['the-parent', 'didInsertElement'], ['the-parent', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-parent', 'init'], ['the-parent', 'didInitAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'didReceiveAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'on(init)'], ['the-first-child', 'init'], ['the-first-child', 'didInitAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'didReceiveAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'on(init)'], ['the-second-child', 'init'], ['the-second-child', 'didInitAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'didReceiveAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'on(init)'], ['the-last-child', 'init'], ['the-last-child', 'didInitAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'didReceiveAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'on(init)']] + }); + + this.runTask(function () { + return _this4.components['the-first-child'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (first child)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-first-child', 'willUpdate'], ['the-first-child', 'willRender'], + + // Async hooks + + ['the-first-child', 'didUpdate'], ['the-first-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this4.components['the-second-child'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (second child)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-second-child', 'willUpdate'], ['the-second-child', 'willRender'], + + // Async hooks + + ['the-second-child', 'didUpdate'], ['the-second-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this4.components['the-last-child'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (last child)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-last-child', 'willUpdate'], ['the-last-child', 'willRender'], + + // Async hooks + + ['the-last-child', 'didUpdate'], ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this4.components['the-parent'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (parent)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], + + // Async hooks + + ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _emberMetal.setProperties(_this4.context, { + twitter: '@horsetomdale', + name: 'Horse Tom Dale', + website: 'horsetomdale.net' + }); + }); + + this.assertText('Twitter: @horsetomdale|Name: Horse Tom Dale|Website: horsetomdale.net'); + + parentAttrs = { + attrs: { twitter: '@horsetomdale', name: 'Horse Tom Dale', website: 'horsetomdale.net' }, + oldAttrs: { twitter: '@tomdale', name: 'Tom Dale', website: 'tomdale.net' }, + newAttrs: { twitter: '@horsetomdale', name: 'Horse Tom Dale', website: 'horsetomdale.net' } + }; + firstAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + secondAttrs = { attrs: { name: 'Horse Tom Dale' }, oldAttrs: { name: 'Tom Dale' }, newAttrs: { name: 'Horse Tom Dale' } }; + lastAttrs = { attrs: { website: 'horsetomdale.net' }, oldAttrs: { website: 'tomdale.net' }, newAttrs: { website: 'horsetomdale.net' } }; + + this.assertHooks({ + label: 'after update', + + interactive: [ + // Sync hooks + + ['the-parent', 'didUpdateAttrs', parentAttrs], ['the-parent', 'didReceiveAttrs', parentAttrs], ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-first-child', 'didUpdateAttrs', firstAttrs], ['the-first-child', 'didReceiveAttrs', firstAttrs], ['the-first-child', 'willUpdate'], ['the-first-child', 'willRender'], ['the-second-child', 'didUpdateAttrs', secondAttrs], ['the-second-child', 'didReceiveAttrs', secondAttrs], ['the-second-child', 'willUpdate'], ['the-second-child', 'willRender'], ['the-last-child', 'didUpdateAttrs', lastAttrs], ['the-last-child', 'didReceiveAttrs', lastAttrs], ['the-last-child', 'willUpdate'], ['the-last-child', 'willRender'], + + // Async hooks + + ['the-first-child', 'didUpdate'], ['the-first-child', 'didRender'], ['the-second-child', 'didUpdate'], ['the-second-child', 'didRender'], ['the-last-child', 'didUpdate'], ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-parent', 'didUpdateAttrs', parentAttrs], ['the-parent', 'didReceiveAttrs', parentAttrs], ['the-first-child', 'didUpdateAttrs', firstAttrs], ['the-first-child', 'didReceiveAttrs', firstAttrs], ['the-second-child', 'didUpdateAttrs', secondAttrs], ['the-second-child', 'didReceiveAttrs', secondAttrs], ['the-last-child', 'didUpdateAttrs', lastAttrs], ['the-last-child', 'didReceiveAttrs', lastAttrs]] + }); + + this.teardownAssertions.push(function () { + _this4.assertHooks({ + label: 'destroy', + + interactive: [['the-parent', 'willDestroyElement'], ['the-parent', 'willClearRender'], ['the-first-child', 'willDestroyElement'], ['the-first-child', 'willClearRender'], ['the-second-child', 'willDestroyElement'], ['the-second-child', 'willClearRender'], ['the-last-child', 'willDestroyElement'], ['the-last-child', 'willClearRender'], ['the-parent', 'didDestroyElement'], ['the-first-child', 'didDestroyElement'], ['the-second-child', 'didDestroyElement'], ['the-last-child', 'didDestroyElement'], ['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], ['the-last-child', 'willDestroy']], + + nonInteractive: [['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], ['the-last-child', 'willDestroy']] + }); + + _this4.assertRegisteredViews('after destroy'); + }); + }; + + LifeCycleHooksTest.prototype['@test passing values through attrs causes lifecycle hooks to fire if the attribute values have changed'] = function testPassingValuesThroughAttrsCausesLifecycleHooksToFireIfTheAttributeValuesHaveChanged() { + var _this5 = this; + + var _boundHelpers3 = this.boundHelpers; + var attr = _boundHelpers3.attr; + var invoke = _boundHelpers3.invoke; + + this.registerComponent('the-top', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5, invoke('the-middle', { twitterTop: expr(attr('twitter')) })) + }); + + this.registerComponent('the-middle', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6, invoke('the-bottom', { twitterMiddle: expr(attr('twitterTop')) })) + }); + + this.registerComponent('the-bottom', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7, attr('twitterMiddle')) + }); + + this.render(invoke('the-top', { twitter: expr('twitter') }), { twitter: '@tomdale' }); + + this.assertText('Top: Middle: Bottom: @tomdale'); + this.assertRegisteredViews('intial render'); + + var topAttrs = { twitter: '@tomdale' }; + var middleAttrs = { twitterTop: '@tomdale' }; + var bottomAttrs = { twitterMiddle: '@tomdale' }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [ + // Sync hooks + + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)'], ['the-bottom', 'willRender'], ['the-bottom', 'willInsertElement'], + + // Async hooks + + ['the-bottom', 'didInsertElement'], ['the-bottom', 'didRender'], ['the-middle', 'didInsertElement'], ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)']] + }); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'twitter', '@horsetomdale'); + }); + + this.assertText('Top: Middle: Bottom: @horsetomdale'); + + // Because the `twitter` attr is used by the all of the components, + // the lifecycle hooks are invoked for all components. + + topAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + middleAttrs = { attrs: { twitterTop: '@horsetomdale' }, oldAttrs: { twitterTop: '@tomdale' }, newAttrs: { twitterTop: '@horsetomdale' } }; + bottomAttrs = { attrs: { twitterMiddle: '@horsetomdale' }, oldAttrs: { twitterMiddle: '@tomdale' }, newAttrs: { twitterMiddle: '@horsetomdale' } }; + + this.assertHooks({ + label: 'after updating (root)', + + interactive: [ + // Sync hooks + + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs], ['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'didUpdateAttrs', middleAttrs], ['the-middle', 'didReceiveAttrs', middleAttrs], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], ['the-bottom', 'didUpdateAttrs', bottomAttrs], ['the-bottom', 'didReceiveAttrs', bottomAttrs], ['the-bottom', 'willUpdate'], ['the-bottom', 'willRender'], + + // Async hooks + + ['the-bottom', 'didUpdate'], ['the-bottom', 'didRender'], ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs], ['the-middle', 'didUpdateAttrs', middleAttrs], ['the-middle', 'didReceiveAttrs', middleAttrs], ['the-bottom', 'didUpdateAttrs', bottomAttrs], ['the-bottom', 'didReceiveAttrs', bottomAttrs]] + }); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('Top: Middle: Bottom: @horsetomdale'); + + // In this case, because the attrs are passed down, all child components are invoked. + + topAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@horsetomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + middleAttrs = { attrs: { twitterTop: '@horsetomdale' }, oldAttrs: { twitterTop: '@horsetomdale' }, newAttrs: { twitterTop: '@horsetomdale' } }; + bottomAttrs = { attrs: { twitterMiddle: '@horsetomdale' }, oldAttrs: { twitterMiddle: '@horsetomdale' }, newAttrs: { twitterMiddle: '@horsetomdale' } }; + + this.assertHooks({ + label: 'after no-op rernder (root)', + interactive: [], + nonInteractive: [] + }); + + this.teardownAssertions.push(function () { + _this5.assertHooks({ + label: 'destroy', + + interactive: [['the-top', 'willDestroyElement'], ['the-top', 'willClearRender'], ['the-middle', 'willDestroyElement'], ['the-middle', 'willClearRender'], ['the-bottom', 'willDestroyElement'], ['the-bottom', 'willClearRender'], ['the-top', 'didDestroyElement'], ['the-middle', 'didDestroyElement'], ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']], + + nonInteractive: [['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']] + }); + + _this5.assertRegisteredViews('after destroy'); + }); + }; + + LifeCycleHooksTest.prototype['@test components rendered from `{{each}}` have correct life-cycle hooks to be called'] = function testComponentsRenderedFromEachHaveCorrectLifeCycleHooksToBeCalled() { + var _this6 = this; + + var invoke = this.boundHelpers.invoke; + + this.registerComponent('nested-item', { template: '{{yield}}' }); + + this.registerComponent('an-item', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8) }); + + this.registerComponent('no-items', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9) }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10, invoke('an-item', { count: expr('item') }), invoke('no-items')), { + items: [1, 2, 3, 4, 5] + }); + + this.assertText('Item: 1Item: 2Item: 3Item: 4Item: 5'); + this.assertRegisteredViews('intial render'); + + var initialHooks = function (count) { + var ret = [['an-item', 'init'], ['an-item', 'didInitAttrs', { attrs: { count: count }, newAttrs: { count: count } }], ['an-item', 'didReceiveAttrs', { attrs: { count: count }, newAttrs: { count: count } }], ['an-item', 'on(init)']]; + if (_this6.isInteractive) { + ret.push(['an-item', 'willRender'], ['an-item', 'willInsertElement']); + } + ret.push(['nested-item', 'init'], ['nested-item', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'on(init)']); + if (_this6.isInteractive) { + ret.push(['nested-item', 'willRender'], ['nested-item', 'willInsertElement']); + } + return ret; + }; + + var initialAfterRenderHooks = function (count) { + if (_this6.isInteractive) { + return [['nested-item', 'didInsertElement'], ['nested-item', 'didRender'], ['an-item', 'didInsertElement'], ['an-item', 'didRender']]; + } else { + return []; + } + }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [].concat(initialHooks(1), initialHooks(2), initialHooks(3), initialHooks(4), initialHooks(5), initialAfterRenderHooks(5), initialAfterRenderHooks(4), initialAfterRenderHooks(3), initialAfterRenderHooks(2), initialAfterRenderHooks(1)), + + nonInteractive: [].concat(initialHooks(1), initialHooks(2), initialHooks(3), initialHooks(4), initialHooks(5), initialAfterRenderHooks(5), initialAfterRenderHooks(4), initialAfterRenderHooks(3), initialAfterRenderHooks(2), initialAfterRenderHooks(1)) + }); + + // TODO: Is this correct? Should childViews be populated in non-interactive mode? + if (this.isInteractive) { + this.assert.equal(this.component.childViews.length, 5, 'childViews precond'); + } + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'items', []); + }); + + // TODO: Is this correct? Should childViews be populated in non-interactive mode? + if (this.isInteractive) { + this.assert.equal(this.component.childViews.length, 1, 'childViews updated'); + } + + this.assertText('Nothing to see here'); + + this.assertHooks({ + label: 'reset to empty array', + + interactive: [['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['no-items', 'init'], ['no-items', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'on(init)'], ['no-items', 'willRender'], ['no-items', 'willInsertElement'], ['nested-item', 'init'], ['nested-item', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'on(init)'], ['nested-item', 'willRender'], ['nested-item', 'willInsertElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['nested-item', 'didInsertElement'], ['nested-item', 'didRender'], ['no-items', 'didInsertElement'], ['no-items', 'didRender'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy']], + + nonInteractive: [['no-items', 'init'], ['no-items', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'on(init)'], ['nested-item', 'init'], ['nested-item', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'on(init)'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy']] + }); + + this.teardownAssertions.push(function () { + _this6.assertHooks({ + label: 'destroy', + + interactive: [['no-items', 'willDestroyElement'], ['no-items', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['no-items', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['no-items', 'willDestroy'], ['nested-item', 'willDestroy']], + + nonInteractive: [['no-items', 'willDestroy'], ['nested-item', 'willDestroy']] + }); + + _this6.assertRegisteredViews('after destroy'); + }); + }; + +babelHelpers.createClass(LifeCycleHooksTest, [{ + key: 'isInteractive', + get: function () { + return true; + } + }, { + key: 'ComponentClass', + get: function () { + throw new Error('Not implemented: `ComponentClass`'); + } + }, { + key: 'boundHelpers', + get: function () { + return { + invoke: bind(this.invocationFor, this), + attr: bind(this.attrFor, this) + }; + } + }]); + return LifeCycleHooksTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var CurlyComponentsTest = (function (_LifeCycleHooksTest) { +babelHelpers.inherits(CurlyComponentsTest, _LifeCycleHooksTest); + + function CurlyComponentsTest() { +babelHelpers.classCallCheck(this, CurlyComponentsTest); + + _LifeCycleHooksTest.apply(this, arguments); + } + + CurlyComponentsTest.prototype.invocationFor = function invocationFor(name) { + var _this7 = this; + + var namedArgs = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var attrs = Object.keys(namedArgs).map(function (k) { + return k + '=' + _this7.val(namedArgs[k]); + }).join(' '); + return '{{' + name + ' ' + attrs + '}}'; + }; + + CurlyComponentsTest.prototype.attrFor = function attrFor(name) { + return '' + name; + }; + + /* private */ + + CurlyComponentsTest.prototype.val = function val(value) { + if (value.isString) { + return JSON.stringify(value.value); + } else if (value.isExpr) { + return '(readonly ' + value.value + ')'; + } else { + throw new Error('Unknown value: ' + value); + } + }; + +babelHelpers.createClass(CurlyComponentsTest, [{ + key: 'ComponentClass', + get: function () { + return _emberGlimmerTestsUtilsHelpers.Component; + } + }]); + return CurlyComponentsTest; + })(LifeCycleHooksTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: interactive lifecycle hooks (curly components)', (function (_CurlyComponentsTest) { +babelHelpers.inherits(_class, _CurlyComponentsTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _CurlyComponentsTest.apply(this, arguments); + } + +babelHelpers.createClass(_class, [{ + key: 'isInteractive', + get: function () { + return true; + } + }]); + return _class; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: non-interactive lifecycle hooks (curly components)', (function (_CurlyComponentsTest2) { +babelHelpers.inherits(_class2, _CurlyComponentsTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _CurlyComponentsTest2.apply(this, arguments); + } + +babelHelpers.createClass(_class2, [{ + key: 'isInteractive', + get: function () { + return false; + } + }]); + return _class2; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: interactive lifecycle hooks (tagless curly components)', (function (_CurlyComponentsTest3) { +babelHelpers.inherits(_class3, _CurlyComponentsTest3); + + function _class3() { +babelHelpers.classCallCheck(this, _class3); + + _CurlyComponentsTest3.apply(this, arguments); + } + +babelHelpers.createClass(_class3, [{ + key: 'ComponentClass', + get: function () { + return _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }); + } + }, { + key: 'isInteractive', + get: function () { + return true; + } + }]); + return _class3; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: non-interactive lifecycle hooks (tagless curly components)', (function (_CurlyComponentsTest4) { +babelHelpers.inherits(_class4, _CurlyComponentsTest4); + + function _class4() { +babelHelpers.classCallCheck(this, _class4); + + _CurlyComponentsTest4.apply(this, arguments); + } + +babelHelpers.createClass(_class4, [{ + key: 'ComponentClass', + get: function () { + return _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }); + } + }, { + key: 'isInteractive', + get: function () { + return false; + } + }]); + return _class4; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Run loop and lifecycle hooks', (function (_RenderingTest2) { +babelHelpers.inherits(_class5, _RenderingTest2); + + function _class5() { +babelHelpers.classCallCheck(this, _class5); + + _RenderingTest2.apply(this, arguments); + } + + _class5.prototype['@test afterRender set'] = function testAfterRenderSet() { + var _this9 = this; + + var ComponentClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + width: '5', + didInsertElement: function () { + var _this8 = this; + + _emberMetal.run.scheduleOnce('afterRender', function () { + _this8.set('width', '10'); + }); + } + }); + + var template = '{{width}}'; + this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template }); + + this.render('{{foo-bar}}'); + + this.assertText('10'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('10'); + }; + + _class5.prototype['@test afterRender set on parent'] = function testAfterRenderSetOnParent() { + var _this11 = this; + + var ComponentClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + var _this10 = this; + + _emberMetal.run.scheduleOnce('afterRender', function () { + var parent = _this10.get('parent'); + parent.set('foo', 'wat'); + }); + } + }); + + var template = '{{foo}}'; + + this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template }); + + this.render('{{foo-bar parent=this foo=foo}}'); + + this.assertText('wat'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('wat'); + }; + + _class5.prototype['@test `willRender` can set before render (GH#14458)'] = function testWillRenderCanSetBeforeRenderGH14458(assert) { + var ComponentClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'a', + customHref: 'http://google.com', + attributeBindings: ['customHref:href'], + willRender: function () { + this.set('customHref', 'http://willRender.com'); + } + }); + + var template = 'Hello World'; + + this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template }); + + this.render('{{foo-bar id="foo"}}'); + + this.assertElement(this.firstChild, { + tagName: 'a', + attrs: { + id: 'foo', + href: 'http://willRender.com', + class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') + } + }); + }; + + _class5.prototype['@test that thing about destroying'] = function testThatThingAboutDestroying(assert) { + var _this12 = this; + + var ParentDestroyedElements = []; + var ChildDestroyedElements = []; + + var ParentComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroyElement: function () { + ParentDestroyedElements.push({ + id: this.itemId, + name: 'parent-component', + hasParent: !!this.element.parentNode, + nextSibling: !!this.element.nextSibling, + previousSibling: !!this.element.previousSibling + }); + } + }); + + var PartentTemplate = _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11); + + var NestedComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroyElement: function () { + ChildDestroyedElements.push({ + id: this.nestedId, + name: 'nested-component', + hasParent: !!this.element.parentNode, + nextSibling: !!this.element.nextSibling, + previousSibling: !!this.element.previousSibling + }); + } + }); + + var NestedTemplate = '{{yield}}'; + + this.registerComponent('parent-component', { + ComponentClass: ParentComponent, + template: PartentTemplate + }); + + this.registerComponent('nested-component', { + ComponentClass: NestedComponent, + template: NestedTemplate + }); + + var array = _emberRuntime.A([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12), { + items: array, + model: { shouldShow: true } + }); + + this.assertText('1AB2AB3AB4AB5AB6AB7AB'); + + this.runTask(function () { + array.removeAt(2); + array.removeAt(2); + _emberMetal.set(_this12.context, 'model.shouldShow', false); + }); + + this.assertText('1AB2AB5AB'); + + assertDestroyHooks(assert, [].concat(ParentDestroyedElements), [{ + id: 3, + hasParent: true, + nextSibling: true, + previousSibling: true + }, { + id: 4, + hasParent: true, + nextSibling: true, + previousSibling: true + }, { + id: 6, + hasParent: true, + nextSibling: true, + previousSibling: true + }, { + id: 7, + hasParent: true, + nextSibling: false, + previousSibling: true + }]); + + assertDestroyHooks(assert, [].concat(ChildDestroyedElements), [{ + id: '3-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '3-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }, { + id: '4-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '4-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }, { + id: '6-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '6-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }, { + id: '7-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '7-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }]); + }; + + _class5.prototype['@test lifecycle hooks have proper access to this.$()'] = function testLifecycleHooksHaveProperAccessToThis$(assert) { + assert.expect(6); + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'div', + init: function () { + assert.notOk(this.$(), 'no access to element via this.$() on init() enter'); + this._super.apply(this, arguments); + assert.notOk(this.$(), 'no access to element via this.$() after init() finished'); + }, + willInsertElement: function () { + component = this; + assert.ok(this.$(), 'willInsertElement has access to element via this.$()'); + }, + didInsertElement: function () { + assert.ok(this.$(), 'didInsertElement has access to element via this.$()'); + }, + willDestroyElement: function () { + assert.ok(this.$(), 'willDestroyElement has access to element via this.$()'); + }, + didDestroyElement: function () { + assert.notOk(this.$(), 'didDestroyElement does not have access to element via this.$()'); + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + var owner = this.owner; + + var comp = owner.lookup('component:foo-bar'); + _internalTestHelpers.runAppend(comp); + this.runTask(function () { + return _emberUtils.tryInvoke(component, 'destroy'); + }); + }; + + return _class5; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + function assertDestroyHooks(assert, _actual, _expected) { + _expected.forEach(function (expected, i) { + var name = expected.name; + assert.equal(expected.id, _actual[i].id, name + ' id is the same'); + assert.equal(expected.hasParent, _actual[i].hasParent, name + ' has parent node'); + assert.equal(expected.nextSibling, _actual[i].nextSibling, name + ' has next sibling node'); + assert.equal(expected.previousSibling, _actual[i].previousSibling, name + ' has previous sibling node'); + }); + } + + function bind(func, thisArg) { + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return func.apply(thisArg, args); + }; + } + + function string(value) { + return { isString: true, value: value }; + } + + function expr(value) { + return { isExpr: true, value: value }; + } + + function hook(name, hook) { + var _ref3 = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + + var attrs = _ref3.attrs; + var oldAttrs = _ref3.oldAttrs; + var newAttrs = _ref3.newAttrs; + + return { name: name, hook: hook, args: { attrs: attrs, oldAttrs: oldAttrs, newAttrs: newAttrs } }; + } + + function json(serializable) { + return JSON.parse(JSON.stringify(serializable)); + } +}); + +// Sync hooks + +// Async hooks + +// Sync hooks + +// Async hooks +enifed('ember-glimmer/tests/integration/components/life-cycle-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/life-cycle-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/life-cycle-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/link-to-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-runtime', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberRuntime, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Link-to component', (function (_ApplicationTest) { + babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _ApplicationTest.apply(this, arguments); + } + + _class.prototype.visitWithDeprecation = function visitWithDeprecation(path, deprecation) { + var _this = this; + + var p = undefined; + + expectDeprecation(function () { + p = _this.visit(path); + }, deprecation); + + return p; + }; + + _class.prototype['@test accessing `currentWhen` triggers a deprecation'] = function testAccessingCurrentWhenTriggersADeprecation(assert) { + var component = undefined; + this.registerComponent('link-to', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.LinkComponent.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }) + }); + + this.registerTemplate('application', '{{link-to \'Index\' \'index\'}}'); + + return this.visit('/').then(function () { + expectDeprecation(function () { + component.get('currentWhen'); + }, /Usage of `currentWhen` is deprecated, use `current-when` instead/); + }); + }; + + _class.prototype['@test should be able to be inserted in DOM when the router is not present'] = function testShouldBeAbleToBeInsertedInDOMWhenTheRouterIsNotPresent() { + var _this2 = this; + + this.registerTemplate('application', '{{#link-to \'index\'}}Go to Index{{/link-to}}'); + + return this.visit('/').then(function () { + _this2.assertText('Go to Index'); + }); + }; + + _class.prototype['@test re-renders when title changes'] = function testReRendersWhenTitleChanges() { + var _this3 = this; + + var controller = undefined; + + this.registerTemplate('application', '{{link-to title routeName}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + controller = this; + }, + title: 'foo', + routeName: 'index' + })); + + return this.visit('/').then(function () { + _this3.assertText('foo'); + _this3.runTask(function () { + return _emberMetal.set(controller, 'title', 'bar'); + }); + _this3.assertText('bar'); + }); + }; + + _class.prototype['@test escaped inline form (double curlies) escapes link title'] = function testEscapedInlineFormDoubleCurliesEscapesLinkTitle() { + var _this4 = this; + + this.registerTemplate('application', '{{link-to title \'index\'}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'blah' + })); + + return this.visit('/').then(function () { + _this4.assertText('blah'); + }); + }; + + _class.prototype['@test escaped inline form with (-html-safe) does not escape link title'] = function testEscapedInlineFormWithHtmlSafeDoesNotEscapeLinkTitle(assert) { + var _this5 = this; + + this.registerTemplate('application', '{{link-to (-html-safe title) \'index\'}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'blah' + })); + + return this.visit('/').then(function () { + _this5.assertText('blah'); + assert.equal(_this5.$('b').length, 1); + }); + }; + + _class.prototype['@test unescaped inline form (triple curlies) does not escape link title'] = function testUnescapedInlineFormTripleCurliesDoesNotEscapeLinkTitle(assert) { + var _this6 = this; + + this.registerTemplate('application', '{{{link-to title \'index\'}}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'blah' + })); + + return this.visit('/').then(function () { + _this6.assertText('blah'); + assert.equal(_this6.$('b').length, 1); + }); + }; + + _class.prototype['@test unwraps controllers'] = function testUnwrapsControllers() { + var _this7 = this; + + this.router.map(function () { + this.route('profile', { path: '/profile/:id' }); + }); + this.registerTemplate('application', '{{#link-to \'profile\' otherController}}Text{{/link-to}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + otherController: _emberRuntime.Controller.create({ + model: 'foo' + }) + })); + + var deprecation = /Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated./; + + return this.visitWithDeprecation('/', deprecation).then(function () { + _this7.assertText('Text'); + }); + }; + + _class.prototype['@test able to safely extend the built-in component and use the normal path'] = function testAbleToSafelyExtendTheBuiltInComponentAndUseTheNormalPath() { + var _this8 = this; + + this.registerComponent('custom-link-to', { ComponentClass: _emberGlimmerTestsUtilsHelpers.LinkComponent.extend() }); + this.registerTemplate('application', '{{#custom-link-to \'index\'}}{{title}}{{/custom-link-to}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'Hello' + })); + + return this.visit('/').then(function () { + _this8.assertText('Hello'); + }); + }; + + _class.prototype['@test [GH#13432] able to safely extend the built-in component and invoke it inline'] = function testGH13432AbleToSafelyExtendTheBuiltInComponentAndInvokeItInline() { + var _this9 = this; + + this.registerComponent('custom-link-to', { ComponentClass: _emberGlimmerTestsUtilsHelpers.LinkComponent.extend() }); + this.registerTemplate('application', '{{custom-link-to title \'index\'}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'Hello' + })); + + return this.visit('/').then(function () { + _this9.assertText('Hello'); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Link-to component with query-params', (function (_ApplicationTest2) { + babelHelpers.inherits(_class2, _ApplicationTest2); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _ApplicationTest2.apply(this, arguments); + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '123', + bar: 'yes' + })); + } + + _class2.prototype['@test populates href with fully supplied query param values'] = function testPopulatesHrefWithFullySuppliedQueryParamValues(assert) { + var _this10 = this; + + this.registerTemplate('index', '{{#link-to \'index\' (query-params foo=\'456\' bar=\'NAW\')}}Index{{/link-to}}'); + + return this.visit('/').then(function () { + _this10.assertComponentElement(_this10.firstChild.firstElementChild, { + tagName: 'a', + attrs: { href: '/?bar=NAW&foo=456' }, + content: 'Index' + }); + }); + }; + + _class2.prototype['@test populates href with partially supplied query param values, but omits if value is default value'] = function testPopulatesHrefWithPartiallySuppliedQueryParamValuesButOmitsIfValueIsDefaultValue() { + var _this11 = this; + + this.registerTemplate('index', '{{#link-to \'index\' (query-params foo=\'123\')}}Index{{/link-to}}'); + + return this.visit('/').then(function () { + _this11.assertComponentElement(_this11.firstChild.firstElementChild, { + tagName: 'a', + attrs: { href: '/', class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view active') }, + content: 'Index' + }); + }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/components/link-to-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/link-to-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/link-to-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/local-lookup-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + function buildResolver() { + var resolver = { + resolve: function () {}, + expandLocalLookup: function (fullName, sourceFullName) { + var _sourceFullName$split = sourceFullName.split(':'); + + var sourceType = _sourceFullName$split[0]; + var sourceName = _sourceFullName$split[1]; + + var _fullName$split = fullName.split(':'); + + var type = _fullName$split[0]; + var name = _fullName$split[1]; + + if (type !== 'template' && sourceType === 'template' && sourceName.slice(0, 11) === 'components/') { + sourceName = sourceName.slice(11); + } + + if (type === 'template' && sourceType === 'template' && name.slice(0, 11) === 'components/') { + name = name.slice(11); + } + + var result = type + ':' + sourceName + '/' + name; + + return result; + } + }; + + return resolver; + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: local lookup', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype.getResolver = function getResolver() { + return buildResolver(); + }; + + _class.prototype['@test it can lookup a local template'] = function testItCanLookupALocalTemplate() { + var _this = this; + + this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' }); + this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' }); + + this.render('{{x-outer}}'); + + this.assertText('Nested template says: Hi!', 'Initial render works'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + }; + + _class.prototype['@test tagless blockless component can lookup local template'] = function testTaglessBlocklessComponentCanLookupLocalTemplate() { + var _this2 = this; + + this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' }); + this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}'); + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }) + }); + + this.render('{{x-outer}}'); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + }; + + _class.prototype['@test it can lookup a local component template'] = function testItCanLookupALocalComponentTemplate() { + var _this3 = this; + + this.registerTemplate('components/x-outer/x-inner', 'Nested template says: {{yield}}'); + this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}'); + + this.render('{{x-outer}}'); + + this.assertText('Nested template says: Hi!', 'Initial render works'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + }; + + _class.prototype['@test it can local lookup a dynamic component'] = function testItCanLocalLookupADynamicComponent() { + var _this4 = this; + + this.registerComponent('foo-bar', { template: 'yall finished {{component child}}' }); + this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' }); + + this.render('{{foo-bar child=child}}', { child: 'biz-baz' }); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can local lookup a dynamic component from a dynamic component'] = function testItCanLocalLookupADynamicComponentFromADynamicComponent() { + var _this5 = this; + + this.registerComponent('foo-bar', { template: 'yall finished {{component child}}' }); + this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' }); + + this.render('{{component componentName child=child}}', { componentName: 'foo-bar', child: 'biz-baz' }); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can local lookup a dynamic component from a passed named argument'] = function testItCanLocalLookupADynamicComponentFromAPassedNamedArgument() { + var _this6 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-biz baz=(component \'local-bar\')}}' }); + this.registerComponent('global-biz', { template: 'or {{component baz}}' }); + this.registerComponent('parent-foo/local-bar', { template: 'yall done?' }); + + this.render('{{parent-foo}}'); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can local lookup a re-wrapped dynamic component from a passed named argument'] = function testItCanLocalLookupAReWrappedDynamicComponentFromAPassedNamedArgument() { + var _this7 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component \'local-bar\')}}' }); + this.registerComponent('global-x', { template: 'or {{global-y comp=(component comp phrase=\'done\')}}' }); + this.registerComponent('global-y', { template: '{{component comp}}?' }); + this.registerComponent('parent-foo/local-bar', { template: 'yall {{phrase}}' }); + + this.render('{{parent-foo}}'); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can nest local lookups of dynamic components from a passed named argument'] = function testItCanNestLocalLookupsOfDynamicComponentsFromAPassedNamedArgument() { + var _this8 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component \'local-bar\')}}' }); + this.registerComponent('global-x', { template: 'or {{global-y comp=(component comp phrase=\'done\')}}' }); + this.registerComponent('global-y', { template: '{{component comp}}{{component \'local-bar\'}}' }); + this.registerComponent('parent-foo/local-bar', { template: 'yall {{phrase}}' }); + this.registerComponent('global-y/local-bar', { template: '?' }); + + this.render('{{parent-foo}}'); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can switch from local to global lookups of dynamic components from a passed named argument'] = function testItCanSwitchFromLocalToGlobalLookupsOfDynamicComponentsFromAPassedNamedArgument() { + var _this9 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component bar)}}' }); + this.registerComponent('global-x', { template: 'or yall {{component comp}}' }); + this.registerComponent('parent-foo/local-bar', { template: 'done?' }); + this.registerComponent('global-bar', { template: 'ready?' }); + + this.render('{{parent-foo bar=bar}}', { bar: 'local-bar' }); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this9.context.set('bar', 'global-bar'); + }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('yall finished or yall ready?'); + }; + + _class.prototype['@test it can lookup a local helper'] = function testItCanLookupALocalHelper() { + var _this10 = this; + + this.registerHelper('x-outer/x-helper', function () { + return 'Who dis?'; + }); + this.registerComponent('x-outer', { template: 'Who dat? {{x-helper}}' }); + + this.render('{{x-outer}}'); + + this.assertText('Who dat? Who dis?', 'Initial render works'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Who dat? Who dis?', 'Re-render works'); + }; + + _class.prototype['@test it overrides global helper lookup'] = function testItOverridesGlobalHelperLookup() { + var _this11 = this; + + this.registerHelper('x-outer/x-helper', function () { + return 'Who dis?'; + }); + + this.registerHelper('x-helper', function () { + return 'I dunno'; + }); + + this.registerComponent('x-outer', { template: 'Who dat? {{x-helper}}' }); + + this.render('{{x-outer}} {{x-helper}}'); + + this.assertText('Who dat? Who dis? I dunno', 'Initial render works'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('Who dat? Who dis? I dunno', 'Re-render works'); + }; + + _class.prototype['@test lookup without match issues standard assertion (with local helper name)'] = function testLookupWithoutMatchIssuesStandardAssertionWithLocalHelperName() { + var _this12 = this; + + this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' }); + + expectAssertion(function () { + _this12.render('{{x-outer}}'); + }, /A component or helper named "x-inner" could not be found/); + }; + + _class.prototype['@test overrides global lookup'] = function testOverridesGlobalLookup() { + var _this13 = this; + + this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' }); + this.registerComponent('x-outer/x-inner', { template: 'Nested template says (from local): {{yield}}' }); + this.registerComponent('x-inner', { template: 'Nested template says (from global): {{yield}}' }); + + this.render('{{#x-inner}}Hi!{{/x-inner}} {{x-outer}} {{#x-outer/x-inner}}Hi!{{/x-outer/x-inner}}'); + + this.assertText('Nested template says (from global): Hi! Nested template says (from local): Hi! Nested template says (from local): Hi!'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('Nested template says (from global): Hi! Nested template says (from local): Hi! Nested template says (from local): Hi!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/local-lookup-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/local-lookup-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/local-lookup-test.js should pass ESLint\n\n'); + }); +}); +enifed("ember-glimmer/tests/integration/components/render-to-element-test", ["exports"], function (exports) { + "use strict"; +}); +enifed('ember-glimmer/tests/integration/components/render-to-element-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/render-to-element-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/render-to-element-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/target-action-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberRouting) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#component-a}}\n {{component-b bar="derp"}}\n {{/component-a}}\n '], ['\n {{#component-a}}\n {{component-b bar="derp"}}\n {{/component-a}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: sendAction', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.call(this); + this.actionCounts = {}; + this.sendCount = 0; + this.actionArguments = null; + + var self = this; + + this.registerComponent('action-delegate', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + self.delegate = this; + this.name = 'action-delegate'; + } + }) + }); + } + + _class.prototype.renderDelegate = function renderDelegate() { + var template = arguments.length <= 0 || arguments[0] === undefined ? '{{action-delegate}}' : arguments[0]; + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var root = this; + context = _emberUtils.assign(context, { + send: function (actionName) { + root.sendCount++; + root.actionCounts[actionName] = root.actionCounts[actionName] || 0; + root.actionCounts[actionName]++; + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + root.actionArguments = args; + } + }); + this.render(template, context); + }; + + _class.prototype.assertSendCount = function assertSendCount(count) { + this.assert.equal(this.sendCount, count, 'Send was called ' + count + ' time(s)'); + }; + + _class.prototype.assertNamedSendCount = function assertNamedSendCount(actionName, count) { + this.assert.equal(this.actionCounts[actionName], count, 'An action named \'' + actionName + '\' was sent ' + count + ' times'); + }; + + _class.prototype.assertSentWithArgs = function assertSentWithArgs(expected) { + var message = arguments.length <= 1 || arguments[1] === undefined ? 'arguments were sent with the action' : arguments[1]; + + this.assert.deepEqual(this.actionArguments, expected, message); + }; + + _class.prototype['@test Calling sendAction on a component without an action defined does nothing'] = function testCallingSendActionOnAComponentWithoutAnActionDefinedDoesNothing() { + var _this = this; + + this.renderDelegate(); + + this.runTask(function () { + return _this.delegate.sendAction(); + }); + + this.assertSendCount(0); + }; + + _class.prototype['@test Calling sendAction on a component with an action defined calls send on the controller'] = function testCallingSendActionOnAComponentWithAnActionDefinedCallsSendOnTheController() { + var _this2 = this; + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this2.delegate, 'action', 'addItem'); + _this2.delegate.sendAction(); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('addItem', 1); + }; + + _class.prototype['@test Calling sendAction on a component with a function calls the function'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunction() { + var _this3 = this; + + this.assert.expect(1); + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this3.delegate, 'action', function () { + return _this3.assert.ok(true, 'function is called'); + }); + _this3.delegate.sendAction(); + }); + }; + + _class.prototype['@test Calling sendAction on a component with a function calls the function with arguments'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunctionWithArguments() { + var _this4 = this; + + this.assert.expect(1); + var argument = {}; + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this4.delegate, 'action', function (actualArgument) { + _this4.assert.deepEqual(argument, actualArgument, 'argument is passed'); + }); + _this4.delegate.sendAction('action', argument); + }); + }; + + // TODO consolidate these next 2 tests + + _class.prototype['@test Calling sendAction on a component with a reference attr calls the function with arguments'] = function testCallingSendActionOnAComponentWithAReferenceAttrCallsTheFunctionWithArguments() { + var _this5 = this; + + this.renderDelegate('{{action-delegate playing=playing}}', { + playing: null + }); + + this.runTask(function () { + return _this5.delegate.sendAction(); + }); + + this.assertSendCount(0); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'playing', 'didStartPlaying'); + }); + + this.runTask(function () { + _this5.delegate.sendAction('playing'); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + }; + + _class.prototype['@test Calling sendAction on a component with a {{mut}} attr calls the function with arguments'] = function testCallingSendActionOnAComponentWithAMutAttrCallsTheFunctionWithArguments() { + var _this6 = this; + + this.renderDelegate('{{action-delegate playing=(mut playing)}}', { + playing: null + }); + + this.runTask(function () { + return _this6.delegate.sendAction('playing'); + }); + + this.assertSendCount(0); + + this.runTask(function () { + return _this6.delegate.attrs.playing.update('didStartPlaying'); + }); + this.runTask(function () { + return _this6.delegate.sendAction('playing'); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + }; + + _class.prototype['@test Calling sendAction with a named action uses the component\'s property as the action name'] = function testCallingSendActionWithANamedActionUsesTheComponentSPropertyAsTheActionName() { + var _this7 = this; + + this.renderDelegate(); + + var component = this.delegate; + + this.runTask(function () { + _emberMetal.set(_this7.delegate, 'playing', 'didStartPlaying'); + component.sendAction('playing'); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + + this.runTask(function () { + return component.sendAction('playing'); + }); + + this.assertSendCount(2); + this.assertNamedSendCount('didStartPlaying', 2); + + this.runTask(function () { + _emberMetal.set(component, 'action', 'didDoSomeBusiness'); + component.sendAction(); + }); + + this.assertSendCount(3); + this.assertNamedSendCount('didDoSomeBusiness', 1); + }; + + _class.prototype['@test Calling sendAction when the action name is not a string raises an exception'] = function testCallingSendActionWhenTheActionNameIsNotAStringRaisesAnException() { + var _this8 = this; + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this8.delegate, 'action', {}); + _emberMetal.set(_this8.delegate, 'playing', {}); + }); + + expectAssertion(function () { + return _this8.delegate.sendAction(); + }); + expectAssertion(function () { + return _this8.delegate.sendAction('playing'); + }); + }; + + _class.prototype['@test Calling sendAction on a component with contexts'] = function testCallingSendActionOnAComponentWithContexts() { + var _this9 = this; + + this.renderDelegate(); + + var testContext = { song: 'She Broke My Ember' }; + var firstContext = { song: 'She Broke My Ember' }; + var secondContext = { song: 'My Achey Breaky Ember' }; + + this.runTask(function () { + _emberMetal.set(_this9.delegate, 'playing', 'didStartPlaying'); + _this9.delegate.sendAction('playing', testContext); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + this.assertSentWithArgs([testContext], 'context was sent with the action'); + + this.runTask(function () { + _this9.delegate.sendAction('playing', firstContext, secondContext); + }); + + this.assertSendCount(2); + this.assertNamedSendCount('didStartPlaying', 2); + this.assertSentWithArgs([firstContext, secondContext], 'multiple contexts were sent to the action'); + }; + + _class.prototype['@test calling sendAction on a component within a block sends to the outer scope GH#14216'] = function testCallingSendActionOnAComponentWithinABlockSendsToTheOuterScopeGH14216(assert) { + var testContext = this; + // overrides default action-delegate so actions can be added + this.registerComponent('action-delegate', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + testContext.delegate = this; + this.name = 'action-delegate'; + }, + + actions: { + derp: function (arg1) { + assert.ok(true, 'action called on action-delgate'); + assert.equal(arg1, 'something special', 'argument passed through properly'); + } + } + }), + + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject) + }); + + this.registerComponent('component-a', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.name = 'component-a'; + }, + actions: { + derp: function () { + assert.ok(false, 'no! bad scoping!'); + } + } + }) + }); + + var innerChild = undefined; + this.registerComponent('component-b', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerChild = this; + this.name = 'component-b'; + } + }) + }); + + this.renderDelegate(); + + this.runTask(function () { + return innerChild.sendAction('bar', 'something special'); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: sendAction to a controller', (function (_ApplicationTest) { +babelHelpers.inherits(_class2, _ApplicationTest); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _ApplicationTest.apply(this, arguments); + } + + _class2.prototype['@test sendAction should trigger an action on the parent component\'s controller if it exists'] = function testSendActionShouldTriggerAnActionOnTheParentComponentSControllerIfItExists(assert) { + var _this10 = this; + + assert.expect(15); + + var component = undefined; + + this.router.map(function () { + this.route('a'); + this.route('b'); + this.route('c', function () { + this.route('d'); + this.route('e'); + }); + }); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '{{val}}' + }); + + this.registerController('a', _emberRuntime.Controller.extend({ + send: function (actionName, actionContext) { + assert.equal(actionName, 'poke', 'send() method was invoked from a top level controller'); + assert.equal(actionContext, 'top', 'action arguments were passed into the top level controller'); + } + })); + this.registerTemplate('a', '{{foo-bar val="a" poke="poke"}}'); + + this.registerRoute('b', _emberRouting.Route.extend({ + actions: { + poke: function (actionContext) { + assert.ok(true, 'Unhandled action sent to route'); + assert.equal(actionContext, 'top no controller'); + } + } + })); + this.registerTemplate('b', '{{foo-bar val="b" poke="poke"}}'); + + this.registerRoute('c', _emberRouting.Route.extend({ + actions: { + poke: function (actionContext) { + assert.ok(true, 'Unhandled action sent to route'); + assert.equal(actionContext, 'top with nested no controller'); + } + } + })); + this.registerTemplate('c', '{{foo-bar val="c" poke="poke"}}{{outlet}}'); + + this.registerRoute('c.d', _emberRouting.Route.extend({})); + + this.registerController('c.d', _emberRuntime.Controller.extend({ + send: function (actionName, actionContext) { + assert.equal(actionName, 'poke', 'send() method was invoked from a nested controller'); + assert.equal(actionContext, 'nested', 'action arguments were passed into the nested controller'); + } + })); + this.registerTemplate('c.d', '{{foo-bar val=".d" poke="poke"}}'); + + this.registerRoute('c.e', _emberRouting.Route.extend({ + actions: { + poke: function (actionContext) { + assert.ok(true, 'Unhandled action sent to route'); + assert.equal(actionContext, 'nested no controller'); + } + } + })); + this.registerTemplate('c.e', '{{foo-bar val=".e" poke="poke"}}'); + + return this.visit('/a').then(function () { + return component.sendAction('poke', 'top'); + }).then(function () { + _this10.assertText('a'); + return _this10.visit('/b'); + }).then(function () { + return component.sendAction('poke', 'top no controller'); + }).then(function () { + _this10.assertText('b'); + return _this10.visit('/c'); + }).then(function () { + return component.sendAction('poke', 'top with nested no controller'); + }).then(function () { + _this10.assertText('c'); + return _this10.visit('/c/d'); + }).then(function () { + return component.sendAction('poke', 'nested'); + }).then(function () { + _this10.assertText('c.d'); + return _this10.visit('/c/e'); + }).then(function () { + return component.sendAction('poke', 'nested no controller'); + }).then(function () { + return _this10.assertText('c.e'); + }); + }; + + _class2.prototype['@test sendAction should not trigger an action in an outlet\'s controller if a parent component handles it'] = function testSendActionShouldNotTriggerAnActionInAnOutletSControllerIfAParentComponentHandlesIt(assert) { + assert.expect(1); + + var component = undefined; + + this.registerComponent('x-parent', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + poke: function () { + assert.ok(true, 'parent component handled the aciton'); + } + } + }), + template: '{{x-child poke="poke"}}' + }); + + this.registerComponent('x-child', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }) + }); + + this.registerTemplate('application', '{{x-parent}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + send: function (actionName) { + throw new Error('controller action should not be called'); + } + })); + + return this.visit('/').then(function () { + return component.sendAction('poke'); + }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: sendAction of a closure action', (function (_RenderingTest2) { +babelHelpers.inherits(_class3, _RenderingTest2); + + function _class3() { +babelHelpers.classCallCheck(this, _class3); + + _RenderingTest2.apply(this, arguments); + } + + _class3.prototype['@test action should be called'] = function testActionShouldBeCalled(assert) { + assert.expect(1); + var component = undefined; + + this.registerComponent('inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + assert.ok(true, 'outerSubmit called'); + } + }), + template: '{{inner-component submitAction=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + return component.sendAction('submitAction'); + }); + }; + + _class3.prototype['@test contexts passed to sendAction are appended to the bound arguments on a closure action'] = function testContextsPassedToSendActionAreAppendedToTheBoundArgumentsOnAClosureAction() { + var first = 'mitch'; + var second = 'martin'; + var third = 'matt'; + var fourth = 'wacky wycats'; + + var innerComponent = undefined; + var actualArgs = undefined; + + this.registerComponent('inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + } + }), + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + third: third, + actions: { + outerSubmit: function () { + actualArgs = [].concat(babelHelpers.slice.call(arguments)); + } + } + }), + template: '{{inner-component innerSubmit=(action (action "outerSubmit" "' + first + '") "' + second + '" third)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + return innerComponent.sendAction('innerSubmit', fourth); + }); + + this.assert.deepEqual(actualArgs, [first, second, third, fourth], 'action has the correct args'); + }; + + return _class3; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: send', (function (_RenderingTest3) { +babelHelpers.inherits(_class4, _RenderingTest3); + + function _class4() { +babelHelpers.classCallCheck(this, _class4); + + _RenderingTest3.apply(this, arguments); + } + + _class4.prototype['@test sending to undefined actions triggers an error'] = function testSendingToUndefinedActionsTriggersAnError(assert) { + assert.expect(2); + + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + component = this; + }, + actions: { + foo: function (message) { + assert.equal('bar', message); + } + } + }) + }); + + this.render('{{foo-bar}}'); + + this.runTask(function () { + return component.send('foo', 'bar'); + }); + + expectAssertion(function () { + return component.send('baz', 'bar'); + }, /had no action handler for: baz/); + }; + + _class4.prototype['@test `send` will call send from a target if it is defined'] = function testSendWillCallSendFromATargetIfItIsDefined() { + var _this11 = this; + + var component = undefined; + var target = { + send: function (message, payload) { + _this11.assert.equal('foo', message); + _this11.assert.equal('baz', payload); + } + }; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + component = this; + }, + target: target + }) + }); + + this.render('{{foo-bar}}'); + + this.runTask(function () { + return component.send('foo', 'baz'); + }); + }; + + _class4.prototype['@test a handled action can be bubbled to the target for continued processing'] = function testAHandledActionCanBeBubbledToTheTargetForContinuedProcessing() { + var _this12 = this; + + this.assert.expect(2); + + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + poke: function () { + _this12.assert.ok(true, 'component action called'); + return true; + } + }, + target: _emberRuntime.Controller.extend({ + actions: { + poke: function () { + _this12.assert.ok(true, 'action bubbled to controller'); + } + } + }).create() + }) + }); + + this.render('{{foo-bar poke="poke"}}'); + + this.runTask(function () { + return component.send('poke'); + }); + }; + + _class4.prototype['@test action can be handled by a superclass\' actions object'] = function testActionCanBeHandledByASuperclassActionsObject(assert) { + this.assert.expect(4); + + var component = undefined; + + var SuperComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + foo: function () { + assert.ok(true, 'foo'); + }, + bar: function (msg) { + assert.equal(msg, 'HELLO'); + } + } + }); + + var BarViewMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + assert.equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + this.registerComponent('x-index', { + ComponentClass: SuperComponent.extend(BarViewMixin, { + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + baz: function () { + assert.ok(true, 'baz'); + } + } + }) + }); + + this.render('{{x-index}}'); + + this.runTask(function () { + component.send('foo'); + component.send('bar', 'HELLO'); + component.send('baz'); + }); + }; + + _class4.prototype['@test actions cannot be provided at create time'] = function testActionsCannotBeProvidedAtCreateTime(assert) { + expectAssertion(function () { + return _emberGlimmerTestsUtilsHelpers.Component.create({ + actions: { + foo: function () { + assert.ok(true, 'foo'); + } + } + }); + }); + // but should be OK on an object that doesn't mix in Ember.ActionHandler + _emberRuntime.Object.create({ + actions: ['foo'] + }); + }; + + return _class4; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/target-action-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/target-action-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/target-action-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/utils-test', ['exports', 'ember-runtime', 'ember-views', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberRuntime, _emberViews, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('View tree tests', (function (_ApplicationTest) { + babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _ApplicationTest.call(this); + + this.registerComponent('x-tagless', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + + template: '
[{{id}}] {{#if isShowing}}{{yield}}{{/if}}
' + }); + + this.registerComponent('x-toggle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + isExpanded: true, + + click: function () { + this.toggleProperty('isExpanded'); + return false; + } + }), + + template: '[{{id}}] {{#if isExpanded}}{{yield}}{{/if}}' + }); + + var ToggleController = _emberRuntime.Controller.extend({ + isExpanded: true, + + actions: { + toggle: function () { + this.toggleProperty('isExpanded'); + } + } + }); + + this.registerController('application', ToggleController); + + this.registerTemplate('application', '\n {{x-tagless id="root-1"}}\n\n {{#x-toggle id="root-2"}}\n {{x-toggle id="inner-1"}}\n\n {{#x-toggle id="inner-2"}}\n {{x-toggle id="inner-3"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n \n\n {{#if isExpanded}}\n {{x-toggle id="root-3"}}\n {{/if}}\n\n {{outlet}}\n '); + + this.registerController('index', ToggleController.extend({ + isExpanded: false + })); + + this.registerTemplate('index', '\n {{x-tagless id="root-4"}}\n\n {{#x-toggle id="root-5" isExpanded=false}}\n {{x-toggle id="inner-4"}}\n\n {{#x-toggle id="inner-5"}}\n {{x-toggle id="inner-6"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n \n\n {{#if isExpanded}}\n {{x-toggle id="root-6"}}\n {{/if}}\n '); + + this.registerTemplate('zomg', '\n {{x-tagless id="root-7"}}\n\n {{#x-toggle id="root-8"}}\n {{x-toggle id="inner-7"}}\n\n {{#x-toggle id="inner-8"}}\n {{x-toggle id="inner-9"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n {{#x-toggle id="root-9"}}\n {{outlet}}\n {{/x-toggle}}\n '); + + this.registerTemplate('zomg.lol', '\n {{x-toggle id="inner-10"}}\n '); + + this.router.map(function () { + this.route('zomg', function () { + this.route('lol'); + }); + }); + } + + _class.prototype['@test getRootViews'] = function testGetRootViews(assert) { + var _this = this; + + return this.visit('/').then(function () { + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5']); + + _this.runTask(function () { + return _emberViews.jQuery('#toggle-application').click(); + }); + + _this.assertRootViews(['root-1', 'root-2', 'root-4', 'root-5']); + + _this.runTask(function () { + _emberViews.jQuery('#toggle-application').click(); + _emberViews.jQuery('#toggle-index').click(); + }); + + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']); + + return _this.visit('/zomg/lol'); + }).then(function () { + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-7', 'root-8', 'root-9']); + + return _this.visit('/'); + }).then(function () { + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']); + }); + }; + + _class.prototype.assertRootViews = function assertRootViews(ids) { + var owner = this.applicationInstance; + + var actual = _emberViews.getRootViews(owner).map(function (view) { + return view.id; + }).sort(); + var expected = ids.sort(); + + this.assert.deepEqual(actual, expected, 'root views'); + }; + + _class.prototype['@test getChildViews'] = function testGetChildViews(assert) { + var _this2 = this; + + return this.visit('/').then(function () { + _this2.assertChildViews('root-2', ['inner-1', 'inner-2']); + _this2.assertChildViews('root-5', []); + _this2.assertChildViews('inner-2', ['inner-3']); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + + _this2.assertChildViews('root-2', []); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-5').click(); + }); + + _this2.assertChildViews('root-5', ['inner-4', 'inner-5']); + _this2.assertChildViews('inner-5', ['inner-6']); + + return _this2.visit('/zomg'); + }).then(function () { + _this2.assertChildViews('root-2', []); + _this2.assertChildViews('root-8', ['inner-7', 'inner-8']); + _this2.assertChildViews('inner-8', ['inner-9']); + _this2.assertChildViews('root-9', []); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-8').click(); + }); + + _this2.assertChildViews('root-8', []); + + return _this2.visit('/zomg/lol'); + }).then(function () { + _this2.assertChildViews('root-2', []); + _this2.assertChildViews('root-8', []); + _this2.assertChildViews('root-9', ['inner-10']); + + return _this2.visit('/'); + }).then(function () { + _this2.assertChildViews('root-2', []); + _this2.assertChildViews('root-5', []); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this2.runTask(function () { + return _emberViews.jQuery('#inner-2').click(); + }); + + _this2.assertChildViews('root-2', ['inner-1', 'inner-2']); + _this2.assertChildViews('inner-2', []); + }); + }; + + _class.prototype['@test getChildViews does not return duplicates'] = function testGetChildViewsDoesNotReturnDuplicates(assert) { + var _this3 = this; + + return this.visit('/').then(function () { + _this3.assertChildViews('root-2', ['inner-1', 'inner-2']); + + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + + _this3.assertChildViews('root-2', ['inner-1', 'inner-2']); + }); + }; + + _class.prototype.assertChildViews = function assertChildViews(parentId, childIds) { + var parentView = this.viewFor(parentId); + var childViews = _emberViews.getChildViews(parentView); + + var actual = childViews.map(function (view) { + return view.id; + }).sort(); + var expected = childIds.sort(); + + this.assert.deepEqual(actual, expected, 'child views for #' + parentId); + }; + + _class.prototype.viewFor = function viewFor(id) { + var owner = this.applicationInstance; + var registry = owner.lookup('-view-registry:main'); + return registry[id]; + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + var hasGetClientRects = undefined, + hasGetBoundingClientRect = undefined; + var ClientRectListCtor = undefined, + ClientRectCtor = undefined; + + (function () { + if (document.createRange) { + var range = document.createRange(); + + if (range.getClientRects) { + var clientRectsList = range.getClientRects(); + hasGetClientRects = true; + ClientRectListCtor = clientRectsList && clientRectsList.constructor; + } + + if (range.getBoundingClientRect) { + var clientRect = range.getBoundingClientRect(); + hasGetBoundingClientRect = true; + ClientRectCtor = clientRect && clientRect.constructor; + } + } + })(); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Bounds tests', (function (_RenderingTest) { + babelHelpers.inherits(_class2, _RenderingTest); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _RenderingTest.apply(this, arguments); + } + + _class2.prototype['@test getViewBounds on a regular component'] = function testGetViewBoundsOnARegularComponent(assert) { + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '

Hi, mom!

' + }); + + this.render('{{hi-mom}}'); + + var _getViewBounds = _emberViews.getViewBounds(component); + + var parentElement = _getViewBounds.parentElement; + var firstNode = _getViewBounds.firstNode; + var lastNode = _getViewBounds.lastNode; + + assert.equal(parentElement, this.element, 'a regular component should have the right parentElement'); + assert.equal(firstNode, component.element, 'a regular component should have a single node that is its element'); + assert.equal(lastNode, component.element, 'a regular component should have a single node that is its element'); + }; + + _class2.prototype['@test getViewBounds on a tagless component'] = function testGetViewBoundsOnATaglessComponent(assert) { + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: 'Hi, mom!' + }); + + this.render('{{hi-mom}}'); + + var _getViewBounds2 = _emberViews.getViewBounds(component); + + var parentElement = _getViewBounds2.parentElement; + var firstNode = _getViewBounds2.firstNode; + var lastNode = _getViewBounds2.lastNode; + + assert.equal(parentElement, this.element, 'a tagless component should have the right parentElement'); + assert.equal(firstNode, this.$('#start-node')[0], 'a tagless component should have a range enclosing all of its nodes'); + assert.equal(lastNode, this.$('#before-end-node')[0].nextSibling, 'a tagless component should have a range enclosing all of its nodes'); + }; + + _class2.prototype['@test getViewClientRects'] = function testGetViewClientRects(assert) { + if (!hasGetClientRects || !ClientRectListCtor) { + assert.ok(true, 'The test environment does not support the DOM API required to run this test.'); + return; + } + + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '

Hi, mom!

' + }); + + this.render('{{hi-mom}}'); + + assert.ok(_emberViews.getViewClientRects(component) instanceof ClientRectListCtor); + }; + + _class2.prototype['@test getViewBoundingClientRect'] = function testGetViewBoundingClientRect(assert) { + if (!hasGetBoundingClientRect || !ClientRectCtor) { + assert.ok(true, 'The test environment does not support the DOM API required to run this test.'); + return; + } + + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '

Hi, mom!

' + }); + + this.render('{{hi-mom}}'); + + assert.ok(_emberViews.getViewBoundingClientRect(component) instanceof ClientRectCtor); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/utils-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/utils-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/utils-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/web-component-fallback-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: web component fallback', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test custom elements are rendered'] = function testCustomElementsAreRendered() { + var template = 'hello'; + + this.render(template); + + this.assertHTML(template); + + this.assertStableRerender(); + }; + + _class.prototype['@test custom elements can have bound attributes'] = function testCustomElementsCanHaveBoundAttributes() { + var _this = this; + + var template = 'hello'; + + this.render(template, { name: 'Robert' }); + + this.assertHTML('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Kris'); + }); + + this.assertHTML('hello'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Robert'); + }); + + this.assertHTML('hello'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/web-component-fallback-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/web-component-fallback-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/web-component-fallback-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/will-destroy-element-hook-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Component willDestroyElement hook', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it calls willDestroyElement when removed by if'] = function testItCallsWillDestroyElementWhenRemovedByIf(assert) { + var _this = this; + + var didInsertElementCount = 0; + var willDestroyElementCount = 0; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + didInsertElementCount++; + assert.notEqual(this.element.parentNode, null, 'precond component is in DOM'); + }, + willDestroyElement: function () { + willDestroyElementCount++; + assert.notEqual(this.element.parentNode, null, 'has not been removed from DOM yet'); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{#if switch}}{{foo-bar}}{{/if}}', { switch: true }); + + assert.equal(didInsertElementCount, 1, 'didInsertElement was called once'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'switch', false); + }); + + assert.equal(willDestroyElementCount, 1, 'willDestroyElement was called once'); + + this.assertText(''); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/will-destroy-element-hook-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/content-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/test-helpers', 'ember-views', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsTestHelpers, _emberViews, _emberGlimmerTestsUtilsHelpers) { + /* globals EmberDev */ + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Static content tests', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can render a static text node'] = function testItCanRenderAStaticTextNode() { + var _this = this; + + this.render('hello'); + var text1 = this.assertTextNode(this.firstChild, 'hello'); + + this.runTask(function () { + return _this.rerender(); + }); + + var text2 = this.assertTextNode(this.firstChild, 'hello'); + + this.assertSameNode(text1, text2); + }; + + _class.prototype['@test it can render a static element'] = function testItCanRenderAStaticElement() { + var _this2 = this; + + this.render('

hello

'); + var p1 = this.assertElement(this.firstChild, { tagName: 'p' }); + var text1 = this.assertTextNode(this.firstChild.firstChild, 'hello'); + + this.runTask(function () { + return _this2.rerender(); + }); + + var p2 = this.assertElement(this.firstChild, { tagName: 'p' }); + var text2 = this.assertTextNode(this.firstChild.firstChild, 'hello'); + + this.assertSameNode(p1, p2); + this.assertSameNode(text1, text2); + }; + + _class.prototype['@test it can render a static template'] = function testItCanRenderAStaticTemplate() { + var _this3 = this; + + var template = '\n
\n

Welcome to Ember.js

\n
\n
\n

Why you should use Ember.js?

\n
    \n
  1. It\'s great
  2. \n
  3. It\'s awesome
  4. \n
  5. It\'s Ember.js
  6. \n
\n
\n \n '; + + this.render(template); + this.assertHTML(template); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertHTML(template); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + var DynamicContentTest = (function (_RenderingTest2) { + babelHelpers.inherits(DynamicContentTest, _RenderingTest2); + + function DynamicContentTest() { + babelHelpers.classCallCheck(this, DynamicContentTest); + + _RenderingTest2.apply(this, arguments); + } + + /* abstract */ + + DynamicContentTest.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + throw new Error('Not implemented: `renderValues`'); + }; + + DynamicContentTest.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.firstChild, null); + }; + + /* abstract */ + + DynamicContentTest.prototype.assertContent = function assertContent(content) { + throw new Error('Not implemented: `assertContent`'); + }; + + DynamicContentTest.prototype['@test it can render a dynamic path'] = function testItCanRenderADynamicPath() { + var _this4 = this; + + this.renderPath('message', { message: 'hello' }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', 'goodbye'); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', 'hello'); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test resolves the string length properly'] = function testResolvesTheStringLengthProperly() { + var _this5 = this; + + this.render('

{{foo.length}}

', { foo: undefined }); + + this.assertHTML('

'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'foo', 'foo'); + }); + + this.assertHTML('

3

'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'foo', ''); + }); + + this.assertHTML('

0

'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'foo', undefined); + }); + + this.assertHTML('

'); + }; + + DynamicContentTest.prototype['@test resolves the array length properly'] = function testResolvesTheArrayLengthProperly() { + var _this6 = this; + + this.render('

{{foo.length}}

', { foo: undefined }); + + this.assertHTML('

'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', [1, 2, 3]); + }); + + this.assertHTML('

3

'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', []); + }); + + this.assertHTML('

0

'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', undefined); + }); + + this.assertHTML('

'); + }; + + DynamicContentTest.prototype['@test it can render a capitalized path with no deprecation'] = function testItCanRenderACapitalizedPathWithNoDeprecation() { + var _this7 = this; + + expectNoDeprecation(); + + this.renderPath('CaptializedPath', { CaptializedPath: 'no deprecation' }); + + this.assertContent('no deprecation'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'CaptializedPath', 'still no deprecation'); + }); + + this.assertContent('still no deprecation'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'CaptializedPath', 'no deprecation'); + }); + + this.assertContent('no deprecation'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render undefined dynamic paths'] = function testItCanRenderUndefinedDynamicPaths() { + var _this8 = this; + + this.renderPath('name', {}); + + this.assertIsEmpty(); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'name', 'foo-bar'); + }); + + this.assertContent('foo-bar'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'name', undefined); + }); + + this.assertIsEmpty(); + }; + + DynamicContentTest.prototype['@test it can render a deeply nested dynamic path'] = function testItCanRenderADeeplyNestedDynamicPath() { + var _this9 = this; + + this.renderPath('a.b.c.d.e.f', { + a: { b: { c: { d: { e: { f: 'hello' } } } } } + }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'a.b.c.d.e.f', 'goodbye'); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'a.b.c.d', { e: { f: 'aloha' } }); + }); + + this.assertContent('aloha'); + this.assertInvariants(); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'a', { b: { c: { d: { e: { f: 'hello' } } } } }); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render a computed property'] = function testItCanRenderAComputedProperty() { + var _this10 = this; + + var Formatter = _emberRuntime.Object.extend({ + formattedMessage: _emberMetal.computed('message', function () { + return this.get('message').toUpperCase(); + }) + }); + + var m = Formatter.create({ message: 'hello' }); + + this.renderPath('m.formattedMessage', { m: m }); + + this.assertContent('HELLO'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(m, 'message', 'goodbye'); + }); + + this.assertContent('GOODBYE'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'm', Formatter.create({ message: 'hello' })); + }); + + this.assertContent('HELLO'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render a computed property with nested dependency'] = function testItCanRenderAComputedPropertyWithNestedDependency() { + var _this11 = this; + + var Formatter = _emberRuntime.Object.extend({ + formattedMessage: _emberMetal.computed('messenger.message', function () { + return this.get('messenger.message').toUpperCase(); + }) + }); + + var m = Formatter.create({ messenger: { message: 'hello' } }); + + this.renderPath('m.formattedMessage', { m: m }); + + this.assertContent('HELLO'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(m, 'messenger.message', 'goodbye'); + }); + + this.assertContent('GOODBYE'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'm', Formatter.create({ messenger: { message: 'hello' } })); + }); + + this.assertContent('HELLO'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a proxy object'] = function testItCanReadFromAProxyObject() { + var _this12 = this; + + this.renderPath('proxy.name', { proxy: _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } }) }); + + this.assertContent('Tom Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.content.name', 'Yehuda Katz'); + }); + + this.assertContent('Yehuda Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.content', { name: 'Godfrey Chan' }); + }); + + this.assertContent('Godfrey Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.name', 'Stefan Penner'); + }); + + this.assertContent('Stefan Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.content', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } })); + }); + + this.assertContent('Tom Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a nested path in a proxy object'] = function testItCanReadFromANestedPathInAProxyObject() { + var _this13 = this; + + this.renderPath('proxy.name.last', { proxy: _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }) }); + + this.assertContent('Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content.name.last', 'Cruise'); + }); + + this.assertContent('Cruise'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content.name.first', 'Suri'); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content.name', { first: 'Yehuda', last: 'Katz' }); + }); + + this.assertContent('Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content', { name: { first: 'Godfrey', last: 'Chan' } }); + }); + + this.assertContent('Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.name', { first: 'Stefan', last: 'Penner' }); + }); + + this.assertContent('Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } })); + }); + + this.assertContent('Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a path flipping between a proxy and a real object'] = function testItCanReadFromAPathFlippingBetweenAProxyAndARealObject() { + var _this14 = this; + + this.renderPath('proxyOrObject.name.last', { proxyOrObject: _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }) }); + + this.assertContent('Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', { name: { first: 'Tom', last: 'Dale' } }); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject.name.last', 'Cruise'); + }); + + this.assertContent('Cruise'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject.name.first', 'Suri'); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', { name: { first: 'Yehuda', last: 'Katz' } }); + }); + + this.assertContent('Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Godfrey', last: 'Chan' } } })); + }); + + this.assertContent('Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject.content.name', { first: 'Stefan', last: 'Penner' }); + }); + + this.assertContent('Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } })); + }); + + this.assertContent('Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a path flipping between a real object and a proxy'] = function testItCanReadFromAPathFlippingBetweenARealObjectAndAProxy() { + var _this15 = this; + + this.renderPath('objectOrProxy.name.last', { objectOrProxy: { name: { first: 'Tom', last: 'Dale' } } }); + + this.assertContent('Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } })); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.content.name.last', 'Cruise'); + }); + + this.assertContent('Cruise'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.content.name.first', 'Suri'); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.content', { name: { first: 'Yehuda', last: 'Katz' } }); + }); + + this.assertContent('Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', { name: { first: 'Godfrey', last: 'Chan' } }); + }); + + this.assertContent('Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.name', { first: 'Stefan', last: 'Penner' }); + }); + + this.assertContent('Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', { name: { first: 'Tom', last: 'Dale' } }); + }); + + this.assertContent('Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a null object'] = function testItCanReadFromANullObject() { + var _this16 = this; + + var nullObject = Object.create(null); + nullObject['message'] = 'hello'; + + this.renderPath('nullObject.message', { nullObject: nullObject }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(nullObject, 'message', 'goodbye'); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + nullObject = Object.create(null); + nullObject['message'] = 'hello'; + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'nullObject', nullObject); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render a readOnly property of a path'] = function testItCanRenderAReadOnlyPropertyOfAPath() { + var _this17 = this; + + var Messenger = _emberRuntime.Object.extend({ + message: _emberMetal.computed.readOnly('a.b.c') + }); + + var messenger = Messenger.create({ + a: { + b: { + c: 'hello' + } + } + }); + + this.renderPath('messenger.message', { messenger: messenger }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(messenger, 'a.b.c', 'hi'); + }); + + this.assertContent('hi'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'messenger.a.b', { + c: 'goodbye' + }); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'messenger', { + message: 'hello' + }); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + return DynamicContentTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var EMPTY = {}; + + var ContentTestGenerator = (function () { + function ContentTestGenerator(cases) { + var tag = arguments.length <= 1 || arguments[1] === undefined ? '@test' : arguments[1]; + babelHelpers.classCallCheck(this, ContentTestGenerator); + + this.cases = cases; + this.tag = tag; + } + + ContentTestGenerator.prototype.generate = function generate(_ref3) { + var value = _ref3[0]; + var expected = _ref3[1]; + var label = _ref3[2]; + + var tag = this.tag; + label = label || value; + + if (expected === EMPTY) { + var _ref; + + return _ref = {}, _ref[tag + ' rendering ' + label] = function () { + var _this18 = this; + + this.renderPath('value', { value: value }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'value', 'hello'); + }); + + this.assertContent('hello'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'value', value); + }); + + this.assertIsEmpty(); + }, _ref; + } else { + var _ref2; + + return _ref2 = {}, _ref2[tag + ' rendering ' + label] = function () { + var _this19 = this; + + this.renderPath('value', { value: value }); + + this.assertContent(expected); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'value', 'hello'); + }); + + this.assertContent('hello'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'value', value); + }); + + this.assertContent(expected); + this.assertInvariants(); + }, _ref2; + } + }; + + return ContentTestGenerator; + })(); + + var SharedContentTestCases = new ContentTestGenerator([['foo', 'foo'], [0, '0'], [-0, '0', '-0'], [1, '1'], [-1, '-1'], [0.0, '0', '0.0'], [0.5, '0.5'], [undefined, EMPTY], [null, EMPTY], [true, 'true'], [false, 'false'], [NaN, 'NaN'], [new Date(2000, 0, 1), String(new Date(2000, 0, 1)), 'a Date object'], [Infinity, 'Infinity'], [1 / -0, '-Infinity'], [{ foo: 'bar' }, '[object Object]', '{ foo: \'bar\' }'], [{ toString: function () { + return 'foo'; + } }, 'foo', 'an object with a custom toString function'], [{ valueOf: function () { + return 1; + } }, '[object Object]', 'an object with a custom valueOf function'], + + // Escaping tests + ['MaxJames', 'MaxJames']]); + + var GlimmerContentTestCases = new ContentTestGenerator([[Object.create(null), EMPTY, 'an object with no toString']]); + + if (typeof Symbol !== 'undefined') { + GlimmerContentTestCases.cases.push([Symbol('debug'), 'Symbol(debug)', 'a symbol']); + } + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(DynamicContentTest, SharedContentTestCases, GlimmerContentTestCases); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (content position)', (function (_DynamicContentTest) { + babelHelpers.inherits(_class2, _DynamicContentTest); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _DynamicContentTest.apply(this, arguments); + } + + _class2.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('{{' + path + '}}', context); + }; + + _class2.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node'); + this.assertTextNode(this.firstChild, content); + }; + + return _class2; + })(DynamicContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (content concat)', (function (_DynamicContentTest2) { + babelHelpers.inherits(_class3, _DynamicContentTest2); + + function _class3() { + babelHelpers.classCallCheck(this, _class3); + + _DynamicContentTest2.apply(this, arguments); + } + + _class3.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('{{concat "" ' + path + ' ""}}', context); + }; + + _class3.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node'); + this.assertTextNode(this.firstChild, content); + }; + + return _class3; + })(DynamicContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (inside an element)', (function (_DynamicContentTest3) { + babelHelpers.inherits(_class4, _DynamicContentTest3); + + function _class4() { + babelHelpers.classCallCheck(this, _class4); + + _DynamicContentTest3.apply(this, arguments); + } + + _class4.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('

{{' + path + '}}

', context); + }; + + _class4.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one

tag'); + this.assertElement(this.firstChild, { tagName: 'p' }); + this.assertText(''); + }; + + _class4.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one

tag'); + this.assertElement(this.firstChild, { tagName: 'p' }); + this.assertText(content); + }; + + return _class4; + })(DynamicContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (attribute position)', (function (_DynamicContentTest4) { + babelHelpers.inherits(_class5, _DynamicContentTest4); + + function _class5() { + babelHelpers.classCallCheck(this, _class5); + + _DynamicContentTest4.apply(this, arguments); + } + + _class5.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('

', context); + }; + + _class5.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one
tag'); + this.assertElement(this.firstChild, { tagName: 'div', content: '' }); + }; + + _class5.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one
tag'); + this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': content }, content: '' }); + }; + + return _class5; + })(DynamicContentTest)); + + var TrustedContentTest = (function (_DynamicContentTest5) { + babelHelpers.inherits(TrustedContentTest, _DynamicContentTest5); + + function TrustedContentTest() { + babelHelpers.classCallCheck(this, TrustedContentTest); + + _DynamicContentTest5.apply(this, arguments); + } + + TrustedContentTest.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.firstChild, null); + }; + + TrustedContentTest.prototype.assertContent = function assertContent(content) { + this.assertHTML(content); + }; + + TrustedContentTest.prototype.assertStableRerender = function assertStableRerender() { + var _this20 = this; + + this.takeSnapshot(); + this.runTask(function () { + return _this20.rerender(); + }); + _DynamicContentTest5.prototype.assertInvariants.call(this); + }; + + TrustedContentTest.prototype.assertInvariants = function assertInvariants() { + // If it's not stable, we will wipe out all the content and replace them, + // so there are no invariants + }; + + return TrustedContentTest; + })(DynamicContentTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (trusted)', (function (_TrustedContentTest) { + babelHelpers.inherits(_class6, _TrustedContentTest); + + function _class6() { + babelHelpers.classCallCheck(this, _class6); + + _TrustedContentTest.apply(this, arguments); + } + + _class6.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('{{{' + path + '}}}', context); + }; + + _class6.prototype['@test updating trusted curlies'] = function testUpdatingTrustedCurlies() { + var _this21 = this; + + this.render('{{{htmlContent}}}{{{nested.htmlContent}}}', { + htmlContent: 'Max', + nested: { htmlContent: 'James' } + }); + + this.assertContent('MaxJames'); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'htmlContent', 'Max'); + }); + + this.assertContent('MaxJames'); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'nested.htmlContent', 'Jammie'); + }); + + this.assertContent('MaxJammie'); + + this.runTask(function () { + _emberMetal.set(_this21.context, 'htmlContent', 'Max'); + _emberMetal.set(_this21.context, 'nested', { htmlContent: 'James' }); + }); + + this.assertContent('MaxJames'); + }; + + return _class6; + })(TrustedContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (integration)', (function (_RenderingTest3) { + babelHelpers.inherits(_class7, _RenderingTest3); + + function _class7() { + babelHelpers.classCallCheck(this, _class7); + + _RenderingTest3.apply(this, arguments); + } + + _class7.prototype['@test it can render a dynamic template'] = function testItCanRenderADynamicTemplate() { + var _this22 = this; + + var template = '\n
\n

Welcome to {{framework}}

\n
\n
\n

Why you should use {{framework}}?

\n
    \n
  1. It\'s great
  2. \n
  3. It\'s awesome
  4. \n
  5. It\'s {{framework}}
  6. \n
\n
\n \n '; + + var ember = '\n
\n

Welcome to Ember.js

\n
\n
\n

Why you should use Ember.js?

\n
    \n
  1. It\'s great
  2. \n
  3. It\'s awesome
  4. \n
  5. It\'s Ember.js
  6. \n
\n
\n \n '; + + var react = '\n
\n

Welcome to React

\n
\n
\n

Why you should use React?

\n
    \n
  1. It\'s great
  2. \n
  3. It\'s awesome
  4. \n
  5. It\'s React
  6. \n
\n
\n \n '; + + this.render(template, { + framework: 'Ember.js' + }); + this.assertHTML(ember); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertHTML(ember); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'framework', 'React'); + }); + + this.assertHTML(react); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'framework', 'Ember.js'); + }); + + this.assertHTML(ember); + }; + + _class7.prototype['@test it should evaluate to nothing if part of the path is `undefined`'] = function testItShouldEvaluateToNothingIfPartOfThePathIsUndefined() { + var _this23 = this; + + this.render('{{foo.bar.baz.bizz}}', { + foo: {} + }); + + this.assertText(''); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', { + bar: { baz: { bizz: 'Hey!' } } + }); + }); + + this.assertText('Hey!'); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', {}); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', { + bar: { baz: { bizz: 'Hello!' } } + }); + }); + + this.assertText('Hello!'); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', {}); + }); + + this.assertText(''); + }; + + _class7.prototype['@test it should evaluate to nothing if part of the path is a primative'] = function testItShouldEvaluateToNothingIfPartOfThePathIsAPrimative() { + var _this24 = this; + + this.render('{{foo.bar.baz.bizz}}', { + foo: { bar: true } + }); + + this.assertText(''); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: false + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: 'Haha' + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: null + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: undefined + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: 1 + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: { baz: { bizz: 'Hello!' } } + }); + }); + + this.assertText('Hello!'); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: true + }); + }); + + this.assertText(''); + }; + + _class7.prototype['@test can set dynamic href'] = function testCanSetDynamicHref() { + var _this25 = this; + + this.render('Example', { + model: { + url: 'http://example.com' + } + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } }); + + this.runTask(function () { + return _this25.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } }); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'model.url', 'http://linkedin.com'); + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://linkedin.com' } }); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'model', { url: 'http://example.com' }); + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } }); + }; + + _class7.prototype['@test quoteless class attributes update correctly'] = function testQuotelessClassAttributesUpdateCorrectly() { + var _this26 = this; + + this.render('
hello
', { + fooBar: true + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _this26.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _emberMetal.set(_this26.context, 'fooBar', false); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this26.context, 'fooBar', true); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + }; + + _class7.prototype['@test quoted class attributes update correctly'] = function testQuotedClassAttributesUpdateCorrectly(assert) { + var _this27 = this; + + this.render('
hello
', { + fooBar: true + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _this27.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'fooBar', false); + }); + + assert.equal(this.firstChild.className, ''); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'fooBar', true); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + }; + + _class7.prototype['@test unquoted class attribute can contain multiple classes'] = function testUnquotedClassAttributeCanContainMultipleClasses() { + var _this28 = this; + + this.render('
hello
', { + model: { + classes: 'foo bar baz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _this28.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _emberMetal.set(_this28.context, 'model.classes', 'fizz bizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this28.context, 'model', { classes: 'foo bar baz' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + }; + + _class7.prototype['@test unquoted class attribute'] = function testUnquotedClassAttribute() { + var _this29 = this; + + this.render('
hello
', { + model: { + foo: 'foo' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _this29.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _emberMetal.set(_this29.context, 'model.foo', 'fizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this29.context, 'model', { foo: 'foo' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + }; + + _class7.prototype['@test quoted class attribute'] = function testQuotedClassAttribute() { + var _this30 = this; + + this.render('
hello
', { + model: { + foo: 'foo' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _this30.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _emberMetal.set(_this30.context, 'model.foo', 'fizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this30.context, 'model', { foo: 'foo' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + }; + + _class7.prototype['@test quoted class attribute can contain multiple classes'] = function testQuotedClassAttributeCanContainMultipleClasses() { + var _this31 = this; + + this.render('
hello
', { + model: { + classes: 'foo bar baz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _this31.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _emberMetal.set(_this31.context, 'model.classes', 'fizz bizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this31.context, 'model', { classes: 'foo bar baz' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + }; + + _class7.prototype['@test class attribute concats bound values'] = function testClassAttributeConcatsBoundValues() { + var _this32 = this; + + this.render('
hello
', { + model: { + foo: 'foo', + bar: 'bar', + bizz: 'bizz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar bizz') } }); + + this.runTask(function () { + return _this32.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this32.context, 'model.foo', 'fizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bar bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this32.context, 'model.bar', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this32.context, 'model', { + foo: 'foo', + bar: 'bar', + bizz: 'bizz' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar bizz') } }); + }; + + _class7.prototype['@test class attribute accepts nested helpers, and updates'] = function testClassAttributeAcceptsNestedHelpersAndUpdates() { + var _this33 = this; + + this.render('
hello
', { + model: { + size: 'large', + hasSize: true, + hasShape: false, + shape: 'round' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large') } }); + + this.runTask(function () { + return _this33.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large') } }); + + this.runTask(function () { + return _emberMetal.set(_this33.context, 'model.hasShape', true); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large round') } }); + + this.runTask(function () { + return _emberMetal.set(_this33.context, 'model.hasSize', false); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('round') } }); + + this.runTask(function () { + return _emberMetal.set(_this33.context, 'model', { + size: 'large', + hasSize: true, + hasShape: false, + shape: 'round' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large') } }); + }; + + _class7.prototype['@test Multiple dynamic classes'] = function testMultipleDynamicClasses() { + var _this34 = this; + + this.render('
hello
', { + model: { + foo: 'foo', + bar: 'bar', + fizz: 'fizz', + baz: 'baz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar fizz baz') } }); + + this.runTask(function () { + return _this34.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar fizz baz') } }); + + this.runTask(function () { + _emberMetal.set(_this34.context, 'model.foo', null); + _emberMetal.set(_this34.context, 'model.fizz', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('bar baz') } }); + + this.runTask(function () { + _emberMetal.set(_this34.context, 'model', { + foo: 'foo', + bar: 'bar', + fizz: 'fizz', + baz: 'baz' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar fizz baz') } }); + }; + + _class7.prototype['@test classes are ordered: See issue #9912'] = function testClassesAreOrderedSeeIssue9912() { + var _this35 = this; + + this.render('
hello
', { + model: { + foo: 'foo', + bar: 'bar' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } }); + + this.runTask(function () { + return _this35.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } }); + + this.runTask(function () { + _emberMetal.set(_this35.context, 'model.bar', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static ' } }); + + this.runTask(function () { + _emberMetal.set(_this35.context, 'model', { + foo: 'foo', + bar: 'bar' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } }); + }; + + return _class7; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + var warnings = undefined, + originalWarn = undefined; + + var StyleTest = (function (_RenderingTest4) { + babelHelpers.inherits(StyleTest, _RenderingTest4); + + function StyleTest() { + babelHelpers.classCallCheck(this, StyleTest); + + _RenderingTest4.apply(this, arguments); + warnings = []; + originalWarn = _emberMetal.getDebugFunction('warn'); + _emberMetal.setDebugFunction('warn', function (message, test) { + if (!test) { + warnings.push(message); + } + }); + } + + StyleTest.prototype.teardown = function teardown() { + var _RenderingTest4$prototype$teardown; + + (_RenderingTest4$prototype$teardown = _RenderingTest4.prototype.teardown).call.apply(_RenderingTest4$prototype$teardown, [this].concat(babelHelpers.slice.call(arguments))); + _emberMetal.setDebugFunction('warn', originalWarn); + }; + + StyleTest.prototype.assertStyleWarning = function assertStyleWarning() { + this.assert.deepEqual(warnings, [_emberViews.STYLE_WARNING]); + }; + + StyleTest.prototype.assertNoWarning = function assertNoWarning() { + this.assert.deepEqual(warnings, []); + }; + + return StyleTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Inline style tests', (function (_StyleTest) { + babelHelpers.inherits(_class8, _StyleTest); + + function _class8() { + babelHelpers.classCallCheck(this, _class8); + + _StyleTest.apply(this, arguments); + } + + _class8.prototype['@test can set dynamic style'] = function testCanSetDynamicStyle() { + var _this36 = this; + + this.render('
', { + model: { + style: 'width: 60px;' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _this36.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this36.context, 'model.style', 'height: 60px;'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'height: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this36.context, 'model.style', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: {} }); + + this.runTask(function () { + return _emberMetal.set(_this36.context, 'model', { style: 'width: 60px;' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + }; + + _class8.prototype['@test can set dynamic style with -html-safe'] = function testCanSetDynamicStyleWithHtmlSafe() { + var _this37 = this; + + this.render('
', { + model: { + style: 'width: 60px;' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _this37.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this37.context, 'model.style', 'height: 60px;'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'height: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this37.context, 'model', { style: 'width: 60px;' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + }; + + return _class8; + })(StyleTest)); + + if (!EmberDev.runningProdBuild) { + _emberGlimmerTestsUtilsTestCase.moduleFor('Inline style tests - warnings', (function (_StyleTest2) { + babelHelpers.inherits(_class9, _StyleTest2); + + function _class9() { + babelHelpers.classCallCheck(this, _class9); + + _StyleTest2.apply(this, arguments); + } + + _class9.prototype['@test specifying
generates a warning'] = function testSpecifyingDivStyleUserValueDivGeneratesAWarning(assert) { + this.render('
', { + userValue: 'width: 42px' + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test specifying `attributeBindings: ["style"]` generates a warning'] = function testSpecifyingAttributeBindingsStyleGeneratesAWarning(assert) { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar style=userValue}}', { + userValue: 'width: 42px' + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test specifying `
` works properly without a warning'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithoutAWarning(assert) { + this.render('
', { + userValue: 'width: 42px' + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test specifying `
` works properly with a SafeString'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithASafeString(assert) { + this.render('
', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('width: 42px') + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test null value do not generate htmlsafe warning'] = function testNullValueDoNotGenerateHtmlsafeWarning(assert) { + this.render('
', { + userValue: null + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test undefined value do not generate htmlsafe warning'] = function testUndefinedValueDoNotGenerateHtmlsafeWarning(assert) { + this.render('
'); + + this.assertNoWarning(); + }; + + _class9.prototype['@test no warnings are triggered when using `-html-safe`'] = function testNoWarningsAreTriggeredWhenUsingHtmlSafe(assert) { + this.render('
', { + userValue: 'width: 42px' + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test no warnings are triggered when a safe string is quoted'] = function testNoWarningsAreTriggeredWhenASafeStringIsQuoted(assert) { + this.render('
', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('width: 42px') + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test binding warning is triggered when an unsafe string is quoted'] = function testBindingWarningIsTriggeredWhenAnUnsafeStringIsQuoted(assert) { + this.render('
', { + userValue: 'width: 42px' + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test binding warning is triggered when a safe string for a complete property is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForACompletePropertyIsConcatenatedInPlace(assert) { + this.render('
', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('width: 42px') + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test binding warning is triggered when a safe string for a value is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForAValueIsConcatenatedInPlace(assert) { + this.render('
', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('42px') + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test binding warning is triggered when a safe string for a property name is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForAPropertyNameIsConcatenatedInPlace(assert) { + this.render('
', { + userProperty: new _emberGlimmerTestsUtilsHelpers.SafeString('width') + }); + + this.assertStyleWarning(); + }; + + return _class9; + })(StyleTest)); + } +}); +enifed('ember-glimmer/tests/integration/content-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/content-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/content-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/event-dispatcher-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + var canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer; + + function fireNativeWithDataTransfer(node, type, dataTransfer) { + var event = document.createEvent('HTMLEvents'); + event.initEvent(type, true, true); + event.dataTransfer = dataTransfer; + node.dispatchEvent(event); + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test events bubble view hierarchy for form elements'] = function testEventsBubbleViewHierarchyForFormElements(assert) { + var _this = this; + + var receivedEvent = undefined; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + change: function (event) { + receivedEvent = event; + } + }), + template: '' + }); + + this.render('{{x-foo}}'); + + this.runTask(function () { + return _this.$('#is-done').trigger('change'); + }); + assert.ok(receivedEvent, 'change event was triggered'); + assert.strictEqual(receivedEvent.target, this.$('#is-done')[0]); + }; + + _class.prototype['@test dispatches to the nearest event manager'] = function testDispatchesToTheNearestEventManager(assert) { + var _this2 = this; + + var receivedEvent = undefined; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function (event) { + assert.notOk(true, 'should not trigger `click` on component'); + }, + + eventManager: { + click: function (event) { + receivedEvent = event; + } + } + }), + + template: '' + }); + + this.render('{{x-foo}}'); + + this.runTask(function () { + return _this2.$('#is-done').trigger('click'); + }); + assert.strictEqual(receivedEvent.target, this.$('#is-done')[0]); + }; + + _class.prototype['@test event manager can re-dispatch to the component'] = function testEventManagerCanReDispatchToTheComponent(assert) { + var _this3 = this; + + var handlers = []; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function () { + handlers.push('component'); + }, + + eventManager: { + click: function (event, component) { + handlers.push('eventManager'); + // Re-dispatch event when you get it. + // + // The second parameter tells the dispatcher + // that this event has been handled. This + // API will clearly need to be reworked since + // multiple eventManagers in a single view + // hierarchy would break, but it shows that + // re-dispatching works + component.$().trigger('click', this); + } + } + }), + + template: '' + }); + + this.render('{{x-foo}}'); + + this.runTask(function () { + return _this3.$('#is-done').trigger('click'); + }); + assert.deepEqual(handlers, ['eventManager', 'component']); + }; + + _class.prototype['@test event handlers are wrapped in a run loop'] = function testEventHandlersAreWrappedInARunLoop(assert) { + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + change: function () { + assert.ok(_emberMetal.run.currentRunLoop, 'a run loop should have started'); + } + }), + template: '' + }); + + this.render('{{x-foo}}'); + + this.$('#is-done').trigger('click'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher#setup', (function (_RenderingTest2) { + babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _RenderingTest2.call(this); + + var dispatcher = this.owner.lookup('event_dispatcher:main'); + _emberMetal.run(dispatcher, 'destroy'); + this.owner.__container__.reset('event_dispatcher:main'); + this.dispatcher = this.owner.lookup('event_dispatcher:main'); + } + + _class2.prototype['@test additonal events can be specified'] = function testAdditonalEventsCanBeSpecified(assert) { + this.dispatcher.setup({ myevent: 'myEvent' }); + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + myEvent: function () { + assert.ok(true, 'custom event was triggered'); + } + }), + template: '

Hello!

' + }); + + this.render('{{x-foo}}'); + + this.$('div').trigger('myevent'); + }; + + _class2.prototype['@test a rootElement can be specified'] = function testARootElementCanBeSpecified(assert) { + this.$().append('
'); + this.dispatcher.setup({ myevent: 'myEvent' }, '#app'); + + assert.ok(this.$('#app').hasClass('ember-application'), 'custom rootElement was used'); + assert.equal(this.dispatcher.rootElement, '#app', 'the dispatchers rootElement was updated'); + }; + + _class2.prototype['@test default events can be disabled via `customEvents`'] = function testDefaultEventsCanBeDisabledViaCustomEvents(assert) { + this.dispatcher.setup({ click: null }); + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function () { + assert.ok(false, 'click method was called'); + }, + + null: function () { + assert.ok(false, 'null method was called'); + }, + + doubleClick: function () { + assert.ok(true, 'a non-disabled event is still handled properly'); + } + }), + + template: '

Hello!

' + }); + + this.render('{{x-foo}}'); + + this.$('div').trigger('click'); + this.$('div').trigger('dblclick'); + }; + + _class2.prototype['@test throws if specified rootElement does not exist'] = function testThrowsIfSpecifiedRootElementDoesNotExist(assert) { + var _this4 = this; + + assert.throws(function () { + _this4.dispatcher.setup({ myevent: 'myEvent' }, '#app'); + }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher - Instrumentation', (function (_RenderingTest3) { + babelHelpers.inherits(_class3, _RenderingTest3); + + function _class3() { + babelHelpers.classCallCheck(this, _class3); + + _RenderingTest3.apply(this, arguments); + } + + _class3.prototype.teardown = function teardown() { + _RenderingTest3.prototype.teardown.call(this); + _emberMetal.instrumentationReset(); + }; + + _class3.prototype['@test instruments triggered events'] = function testInstrumentsTriggeredEvents(assert) { + var clicked = 0; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function (evt) { + clicked++; + } + }), + template: '

hello

' + }); + + this.render('{{x-foo}}'); + + this.$('div').trigger('click'); + + assert.equal(clicked, 1, 'precond - the click handler was invoked'); + + var clickInstrumented = 0; + _emberMetal.instrumentationSubscribe('interaction.click', { + before: function () { + clickInstrumented++; + assert.equal(clicked, 1, 'invoked before event is handled'); + }, + after: function () { + clickInstrumented++; + assert.equal(clicked, 2, 'invoked after event is handled'); + } + }); + + var keypressInstrumented = 0; + _emberMetal.instrumentationSubscribe('interaction.keypress', { + before: function () { + keypressInstrumented++; + }, + after: function () { + keypressInstrumented++; + } + }); + + this.$('div').trigger('click'); + this.$('div').trigger('change'); + assert.equal(clicked, 2, 'precond - The click handler was invoked'); + assert.equal(clickInstrumented, 2, 'The click was instrumented'); + assert.strictEqual(keypressInstrumented, 0, 'The keypress was not instrumented'); + }; + + return _class3; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } + + if (canDataTransfer) { + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher - Event Properties', (function (_RenderingTest4) { + babelHelpers.inherits(_class4, _RenderingTest4); + + function _class4() { + babelHelpers.classCallCheck(this, _class4); + + _RenderingTest4.apply(this, arguments); + } + + _class4.prototype['@test dataTransfer property is added to drop event'] = function testDataTransferPropertyIsAddedToDropEvent(assert) { + var receivedEvent = undefined; + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + drop: function (event) { + receivedEvent = event; + } + }) + }); + + this.render('{{x-foo}}'); + + fireNativeWithDataTransfer(this.$('div')[0], 'drop', 'success'); + assert.equal(receivedEvent.dataTransfer, 'success'); + }; + + return _class4; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } +}); +enifed('ember-glimmer/tests/integration/event-dispatcher-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/event-dispatcher-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/event-dispatcher-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/-class-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{-class}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test casts binding to dasherized class'] = function testCastsBindingToDasherizedClass() { + var _this = this; + + this.registerComponent('foo-bar', { template: '' }); + this.render('{{foo-bar class=(-class someTruth "someTruth")}}', { + someTruth: true + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'someTruth', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'someTruth', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + }; + + _class.prototype['@tests casts leaf path of binding to dasherized class'] = function testsCastsLeafPathOfBindingToDasherizedClass() { + var _this2 = this; + + this.registerComponent('foo-bar', { template: '' }); + this.render('{{foo-bar class=(-class model.someTruth "someTruth")}}', { + model: { + someTruth: true + } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model.someTruth', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { someTruth: true }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/-class-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/-class-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/-class-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/closure-action-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberMetal, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
clicked: {{clicked}}; foo: {{foo}}
\n\n {{click-me id="string-action" onClick=(action "on-click")}}\n {{click-me id="function-action" onClick=(action onClick)}}\n {{click-me id="mut-action" onClick=(action (mut clicked))}}\n '], ['\n
clicked: {{clicked}}; foo: {{foo}}
\n\n {{click-me id="string-action" onClick=(action "on-click")}}\n {{click-me id="function-action" onClick=(action onClick)}}\n {{click-me id="mut-action" onClick=(action (mut clicked))}}\n ']); + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: closure {{action}} improved instrumentation', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype.subscribe = function subscribe(eventName, options) { + this.subscriber = _emberMetal.instrumentationSubscribe(eventName, options); + }; + + _class.prototype.teardown = function teardown() { + if (this.subscriber) { + _emberMetal.instrumentationUnsubscribe(this.subscriber); + } + + _RenderingTest.prototype.teardown.call(this); + }; + + _class.prototype['@test interaction event subscriber should be passed parameters'] = function testInteractionEventSubscriberShouldBePassedParameters() { + var _this = this; + + var actionParam = 'So krispy'; + var beforeParameters = []; + var afterParameters = []; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + fireAction: function () { + this.attrs.submit(actionParam); + } + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () {} + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.subscribe('interaction.ember-action', { + before: function (name, timestamp, payload) { + beforeParameters.push(payload.args); + }, + after: function (name, timestamp, payload) { + afterParameters.push(payload.args); + } + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this.$('#instrument-button').trigger('click'); + }); + + this.assert.deepEqual(beforeParameters, [[], [actionParam]], 'instrumentation subscriber before function was passed closure action parameters'); + this.assert.deepEqual(afterParameters, [[actionParam], []], 'instrumentation subscriber after function was passed closure action parameters'); + }; + + _class.prototype['@test interaction event subscriber should be passed target'] = function testInteractionEventSubscriberShouldBePassedTarget() { + var _this2 = this; + + var beforeParameters = []; + var afterParameters = []; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + myProperty: 'inner-thing', + actions: { + fireAction: function () { + this.attrs.submit(); + } + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + myProperty: 'outer-thing', + outerSubmit: function () {} + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.subscribe('interaction.ember-action', { + before: function (name, timestamp, payload) { + beforeParameters.push(payload.target.get('myProperty')); + }, + after: function (name, timestamp, payload) { + afterParameters.push(payload.target.get('myProperty')); + } + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this2.$('#instrument-button').trigger('click'); + }); + + this.assert.deepEqual(beforeParameters, ['inner-thing', 'outer-thing'], 'instrumentation subscriber before function was passed target'); + this.assert.deepEqual(afterParameters, ['outer-thing', 'inner-thing'], 'instrumentation subscriber after function was passed target'); + }; + + _class.prototype['@test instrumented action should return value'] = function testInstrumentedActionShouldReturnValue() { + var _this3 = this; + + var returnedValue = 'Chris P is so krispy'; + var actualReturnedValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + fireAction: function () { + actualReturnedValue = this.attrs.submit(); + } + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + return returnedValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.subscribe('interaction.ember-action', { + before: function (name, timestamp, payload) {}, + after: function (name, timestamp, payload) {} + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this3.$('#instrument-button').trigger('click'); + }); + + this.assert.equal(actualReturnedValue, returnedValue, 'action can return to caller'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: closure {{action}}', (function (_RenderingTest2) { +babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test action should be called'] = function testActionShouldBeCalled() { + var outerActionCalled = false; + var component = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + outerActionCalled = true; + } + }); + + this.registerComponent('inner-component', { ComponentClass: InnerComponent, template: 'inner' }); + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + component.fireAction(); + }); + + this.assert.ok(outerActionCalled, 'the action was called'); + }; + + _class2.prototype['@test an error is triggered when bound action function is undefined'] = function testAnErrorIsTriggeredWhenBoundActionFunctionIsUndefined() { + var _this4 = this; + + this.registerComponent('inner-component', { + template: 'inner' + }); + this.registerComponent('outer-component', { + template: '{{inner-component submit=(action somethingThatIsUndefined)}}' + }); + + expectAssertion(function () { + _this4.render('{{outer-component}}'); + }, /Action passed is null or undefined in \(action[^)]*\) from .*\./); + }; + + _class2.prototype['@test an error is triggered when bound action being passed in is a non-function'] = function testAnErrorIsTriggeredWhenBoundActionBeingPassedInIsANonFunction() { + var _this5 = this; + + this.registerComponent('inner-component', { + template: 'inner' + }); + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + nonFunctionThing: {} + }), + template: '{{inner-component submit=(action nonFunctionThing)}}' + }); + + expectAssertion(function () { + _this5.render('{{outer-component}}'); + }, /An action could not be made for `.*` in .*\. Please confirm that you are using either a quoted action name \(i\.e\. `\(action '.*'\)`\) or a function available in .*\./); + }; + + _class2.prototype['@test [#12718] a nice error is shown when a bound action function is undefined and it is passed as attrs.foo'] = function test12718ANiceErrorIsShownWhenABoundActionFunctionIsUndefinedAndItIsPassedAsAttrsFoo() { + var _this6 = this; + + this.registerComponent('inner-component', { + template: '' + }); + + this.registerComponent('outer-component', { + template: '{{inner-component}}' + }); + + expectAssertion(function () { + _this6.render('{{outer-component}}'); + }, /Action passed is null or undefined in \(action[^)]*\) from .*\./); + }; + + _class2.prototype['@test action value is returned'] = function testActionValueIsReturned() { + var expectedValue = 'terrible tom'; + var returnedValue = undefined; + var innerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + returnedValue = this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + return expectedValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(returnedValue, expectedValue, 'action can return to caller'); + }; + + _class2.prototype['@test action should be called on the correct scope'] = function testActionShouldBeCalledOnTheCorrectScope() { + var innerComponent = undefined; + var outerComponent = undefined; + var actualComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + isOuterComponent: true, + outerSubmit: function () { + actualComponent = this; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualComponent, outerComponent, 'action has the correct context'); + this.assert.ok(actualComponent.isOuterComponent, 'action has the correct context'); + }; + + _class2.prototype['@test arguments to action are passed, curry'] = function testArgumentsToActionArePassedCurry() { + var first = 'mitch'; + var second = 'martin'; + var third = 'matt'; + var fourth = 'wacky wycats'; + + var innerComponent = undefined; + var actualArgs = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(fourth); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + third: third, + outerSubmit: function (actualFirst, actualSecond, actualThird, actualFourth) { + actualArgs = [].concat(babelHelpers.slice.call(arguments)); + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action (action outerSubmit "' + first + '") "' + second + '" third)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.deepEqual(actualArgs, [first, second, third, fourth], 'action has the correct args'); + }; + + _class2.prototype['@test `this` can be passed as an argument'] = function testThisCanBePassedAsAnArgument() { + var value = {}; + var component = undefined; + var innerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + outerAction: function (incomingValue) { + value = incomingValue; + } + } + }); + + this.registerComponent('inner-component', { ComponentClass: InnerComponent, template: 'inner' }); + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action "outerAction" this)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.strictEqual(value, component, 'the component is passed at `this`'); + }; + + _class2.prototype['@test arguments to action are bound'] = function testArgumentsToActionAreBound() { + var value = 'lazy leah'; + + var innerComponent = undefined; + var outerComponent = undefined; + var actualArg = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + value: '', + outerSubmit: function (incomingValue) { + actualArg = incomingValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit value)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.strictEqual(actualArg, '', 'action has the correct first arg'); + + this.runTask(function () { + outerComponent.set('value', value); + }); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.strictEqual(actualArg, value, 'action has the correct first arg'); + }; + + _class2.prototype['@test array arguments are passed correctly to action'] = function testArrayArgumentsArePassedCorrectlyToAction() { + var first = 'foo'; + var second = [3, 5]; + var third = [4, 9]; + + var actualFirst = undefined; + var actualSecond = undefined; + var actualThird = undefined; + + var innerComponent = undefined; + var outerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(second, third); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + outerSubmit: function (incomingFirst, incomingSecond, incomingThird) { + actualFirst = incomingFirst; + actualSecond = incomingSecond; + actualThird = incomingThird; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit first)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + outerComponent.set('first', first); + outerComponent.set('second', second); + }); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualFirst, first, 'action has the correct first arg'); + this.assert.equal(actualSecond, second, 'action has the correct second arg'); + this.assert.equal(actualThird, third, 'action has the correct third arg'); + }; + + _class2.prototype['@test mut values can be wrapped in actions, are settable'] = function testMutValuesCanBeWrappedInActionsAreSettable() { + var newValue = 'trollin trek'; + + var innerComponent = undefined; + var outerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(newValue); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + outerMut: 'patient peter' + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action (mut outerMut))}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set'); + }; + + _class2.prototype['@test mut values can be wrapped in actions, are settable with a curry'] = function testMutValuesCanBeWrappedInActionsAreSettableWithACurry() { + var newValue = 'trollin trek'; + + var innerComponent = undefined; + var outerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + outerMut: 'patient peter' + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action (mut outerMut) \'' + newValue + '\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set'); + }; + + _class2.prototype['@test action can create closures over actions'] = function testActionCanCreateClosuresOverActions() { + var first = 'raging robert'; + var second = 'mild machty'; + var returnValue = 'butch brian'; + + var actualFirst = undefined; + var actualSecond = undefined; + var actualReturnedValue = undefined; + + var innerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + actualReturnedValue = this.attrs.submit(second); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + outerAction: function (incomingFirst, incomingSecond) { + actualFirst = incomingFirst; + actualSecond = incomingSecond; + return returnValue; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'outerAction\' \'' + first + '\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualReturnedValue, returnValue, 'return value is present'); + this.assert.equal(actualFirst, first, 'first argument is correct'); + this.assert.equal(actualSecond, second, 'second argument is correct'); + }; + + _class2.prototype['@test provides a helpful error if an action is not present'] = function testProvidesAHelpfulErrorIfAnActionIsNotPresent() { + var _this7 = this; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + something: function () { + // this is present to ensure `actions` hash is present + // a different error is triggered if `actions` is missing + // completely + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'doesNotExist\')}}' + }); + + expectAssertion(function () { + _this7.render('{{outer-component}}'); + }, /An action named 'doesNotExist' was not found in /); + }; + + _class2.prototype['@test provides a helpful error if actions hash is not present'] = function testProvidesAHelpfulErrorIfActionsHashIsNotPresent() { + var _this8 = this; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'doesNotExist\')}}' + }); + + expectAssertion(function () { + _this8.render('{{outer-component}}'); + }, /An action named 'doesNotExist' was not found in /); + }; + + _class2.prototype['@test action can create closures over actions with target'] = function testActionCanCreateClosuresOverActionsWithTarget() { + var innerComponent = undefined; + var actionCalled = false; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + otherComponent: _emberMetal.computed(function () { + return { + actions: { + outerAction: function () { + actionCalled = true; + } + } + }; + }) + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'outerAction\' target=otherComponent)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.ok(actionCalled, 'action called on otherComponent'); + }; + + _class2.prototype['@test value can be used with action over actions'] = function testValueCanBeUsedWithActionOverActions() { + var newValue = 'yelping yehuda'; + + var innerComponent = undefined; + var actualValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit({ + readProp: newValue + }); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerContent: { + readProp: newValue + }, + actions: { + outerAction: function (incomingValue) { + actualValue = incomingValue; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'outerAction\' value="readProp")}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualValue, newValue, 'value is read'); + }; + + _class2.prototype['@test action will read the value of a first property'] = function testActionWillReadTheValueOfAFirstProperty() { + var newValue = 'irate igor'; + + var innerComponent = undefined; + var actualValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit({ + readProp: newValue + }); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerAction: function (incomingValue) { + actualValue = incomingValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerAction value="readProp")}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualValue, newValue, 'property is read'); + }; + + _class2.prototype['@test action will read the value of a curried first argument property'] = function testActionWillReadTheValueOfACurriedFirstArgumentProperty() { + var newValue = 'kissing kris'; + + var innerComponent = undefined; + var actualValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + objectArgument: { + readProp: newValue + }, + outerAction: function (incomingValue) { + actualValue = incomingValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerAction objectArgument value="readProp")}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualValue, newValue, 'property is read'); + }; + + _class2.prototype['@test action closure does not get auto-mut wrapped'] = function testActionClosureDoesNotGetAutoMutWrapped(assert) { + var first = 'raging robert'; + var second = 'mild machty'; + var returnValue = 'butch brian'; + + var innerComponent = undefined; + var actualFirst = undefined; + var actualSecond = undefined; + var actualReturnedValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.get('submit')(second); + this.get('attrs-submit')(second); + var attrsSubmitReturnValue = this.attrs['attrs-submit'](second); + var submitReturnValue = this.attrs.submit(second); + + assert.equal(attrsSubmitReturnValue, submitReturnValue, 'both attrs.foo and foo should behave the same'); + + return submitReturnValue; + } + }); + + var MiddleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + outerAction: function (incomingFirst, incomingSecond) { + actualFirst = incomingFirst; + actualSecond = incomingSecond; + return returnValue; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('middle-component', { + ComponentClass: MiddleComponent, + template: '{{inner-component attrs-submit=attrs.submit submit=submit}}' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{middle-component submit=(action \'outerAction\' \'' + first + '\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + actualReturnedValue = innerComponent.fireAction(); + }); + + this.assert.equal(actualFirst, first, 'first argument is correct'); + this.assert.equal(actualSecond, second, 'second argument is correct'); + this.assert.equal(actualReturnedValue, returnValue, 'return value is present'); + }; + + _class2.prototype['@test action should be called within a run loop'] = function testActionShouldBeCalledWithinARunLoop() { + var innerComponent = undefined; + var capturedRunLoop = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + submit: function () { + capturedRunLoop = _emberMetal.run.currentRunLoop; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'submit\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.ok(capturedRunLoop, 'action is called within a run loop'); + }; + + _class2.prototype['@test objects that define INVOKE can be casted to actions'] = function testObjectsThatDefineINVOKECanBeCastedToActions() { + var innerComponent = undefined; + var actionArgs = undefined; + var invokableArgs = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + actionArgs = this.attrs.submit(4, 5, 6); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + foo: 123, + submitTask: _emberMetal.computed(function () { + var _ref, + _this9 = this; + + return _ref = {}, _ref[_emberGlimmerTestsUtilsHelpers.INVOKE] = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + invokableArgs = args; + return _this9.foo; + }, _ref; + }) + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action submitTask 1 2 3)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actionArgs, 123); + this.assert.deepEqual(invokableArgs, [1, 2, 3, 4, 5, 6]); + }; + + _class2.prototype['@test closure action with `(mut undefinedThing)` works properly [GH#13959]'] = function testClosureActionWithMutUndefinedThingWorksProperlyGH13959() { + var _this10 = this; + + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + label: undefined, + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assertText('Click me'); + + this.assertStableRerender(); + + this.runTask(function () { + _this10.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', 'Dun clicked'); + }); + + this.assertText('Dun clicked'); + + this.runTask(function () { + _this10.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', undefined); + }); + + this.assertText('Click me'); + }; + + _class2.prototype['@test closure actions does not cause component hooks to fire unnecessarily [GH#14305] [GH#14654]'] = function testClosureActionsDoesNotCauseComponentHooksToFireUnnecessarilyGH14305GH14654(assert) { + var _this12 = this; + + var clicked = 0; + var didReceiveAttrsFired = 0; + + var ClickMeComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'button', + + click: function () { + this.get('onClick').call(undefined, ++clicked); + }, + + didReceiveAttrs: function () { + didReceiveAttrsFired++; + } + }); + + this.registerComponent('click-me', { + ComponentClass: ClickMeComponent + }); + + var outer = undefined; + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + clicked: 0, + + actions: { + 'on-click': function () { + this.incrementProperty('clicked'); + } + }, + + init: function () { + var _this11 = this; + + this._super(); + outer = this; + this.set('onClick', function () { + return _this11.incrementProperty('clicked'); + }); + } + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject) + }); + + this.render('{{outer-component foo=foo}}', { foo: 1 }); + + this.assertText('clicked: 0; foo: 1'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('clicked: 0; foo: 1'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'foo', 2); + }); + + this.assertText('clicked: 0; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#string-action').click(); + }); + + this.assertText('clicked: 1; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#function-action').click(); + }); + + this.assertText('clicked: 2; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _emberMetal.set(outer, 'onClick', function () { + outer.incrementProperty('clicked'); + }); + }); + + this.assertText('clicked: 2; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#function-action').click(); + }); + + this.assertText('clicked: 3; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#mut-action').click(); + }); + + this.assertText('clicked: 4; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/closure-action-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/closure-action-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/closure-action-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/concat-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{concat}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it concats static arguments'] = function testItConcatsStaticArguments() { + this.render('{{concat "foo" " " "bar" " " "baz"}}'); + this.assertText('foo bar baz'); + }; + + _class.prototype['@test it updates for bound arguments'] = function testItUpdatesForBoundArguments() { + var _this = this; + + this.render('{{concat model.first model.second}}', { + model: { first: 'one', second: 'two' } + }); + + this.assertText('onetwo'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('onetwo'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.first', 'three'); + }); + + this.assertText('threetwo'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.second', 'four'); + }); + + this.assertText('threefour'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model', { first: 'one', second: 'two' }); + }); + + this.assertText('onetwo'); + }; + + _class.prototype['@test it can be used as a sub-expression'] = function testItCanBeUsedAsASubExpression() { + var _this2 = this; + + this.render('{{concat (concat model.first model.second) (concat model.third model.fourth)}}', { + model: { + first: 'one', + second: 'two', + third: 'three', + fourth: 'four' + } + }); + + this.assertText('onetwothreefour'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('onetwothreefour'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model.first', 'five'); + }); + + this.assertText('fivetwothreefour'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model.second', 'six'); + _emberMetal.set(_this2.context, 'model.third', 'seven'); + }); + + this.assertText('fivesixsevenfour'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model', { + first: 'one', + second: 'two', + third: 'three', + fourth: 'four' + }); + }); + + this.assertText('onetwothreefour'); + }; + + _class.prototype['@test it can be used as input for other helpers'] = function testItCanBeUsedAsInputForOtherHelpers() { + var _this3 = this; + + this.registerHelper('x-eq', function (_ref) { + var actual = _ref[0]; + var expected = _ref[1]; + return actual === expected; + }); + + this.render('{{#if (x-eq (concat model.first model.second) "onetwo")}}Truthy!{{else}}False{{/if}}', { + model: { + first: 'one', + second: 'two' + } + }); + + this.assertText('Truthy!'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Truthy!'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.first', 'three'); + }); + + this.assertText('False'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { first: 'one', second: 'two' }); + }); + + this.assertText('Truthy!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/concat-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/concat-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/concat-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/custom-helper-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'internal-test-helpers', 'ember-metal', 'ember-utils'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _internalTestHelpers, _emberMetal, _emberUtils) { + /* globals EmberDev */ + 'use strict'; + + var assert = QUnit.assert; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: custom helpers', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it cannot override built-in syntax'] = function testItCannotOverrideBuiltInSyntax() { + var _this = this; + + this.registerHelper('if', function () { + return 'Nope'; + }); + expectAssertion(function () { + _this.render('{{if foo \'LOL\'}}', { foo: true }); + }, /You attempted to overwrite the built-in helper \"if\" which is not allowed. Please rename the helper./); + }; + + _class.prototype['@test it can resolve custom simple helpers with or without dashes'] = function testItCanResolveCustomSimpleHelpersWithOrWithoutDashes() { + var _this2 = this; + + this.registerHelper('hello', function () { + return 'hello'; + }); + this.registerHelper('hello-world', function () { + return 'hello world'; + }); + + this.render('{{hello}} | {{hello-world}}'); + + this.assertText('hello | hello world'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('hello | hello world'); + }; + + _class.prototype['@test it does not resolve helpers with a `.` (period)'] = function testItDoesNotResolveHelpersWithAPeriod() { + var _this3 = this; + + this.registerHelper('hello.world', function () { + return 'hello world'; + }); + + this.render('{{hello.world}}', { + hello: { + world: '' + } + }); + + this.assertText(''); + + this.assertStableRerender(); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'hello', { world: 'hello world!' }); + }); + + this.assertText('hello world!'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'hello', { + world: '' + }); + }); + + this.assertText(''); + }; + + _class.prototype['@test it can resolve custom makeBoundHelper with or without dashes [DEPRECATED]'] = function testItCanResolveCustomMakeBoundHelperWithOrWithoutDashesDEPRECATED() { + var _this4 = this; + + expectDeprecation(function () { + _this4.owner.register('helper:hello', _emberGlimmerTestsUtilsHelpers.makeBoundHelper(function () { + return 'hello'; + })); + }, 'Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.'); + + expectDeprecation(function () { + _this4.owner.register('helper:hello-world', _emberGlimmerTestsUtilsHelpers.makeBoundHelper(function () { + return 'hello world'; + })); + }, 'Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.'); + + this.render('{{hello}} | {{hello-world}}'); + + this.assertText('hello | hello world'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('hello | hello world'); + }; + + _class.prototype['@test it can resolve custom class-based helpers with or without dashes'] = function testItCanResolveCustomClassBasedHelpersWithOrWithoutDashes() { + var _this5 = this; + + this.registerHelper('hello', { + compute: function () { + return 'hello'; + } + }); + + this.registerHelper('hello-world', { + compute: function () { + return 'hello world'; + } + }); + + this.render('{{hello}} | {{hello-world}}'); + + this.assertText('hello | hello world'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('hello | hello world'); + }; + + _class.prototype['@test throws if `this._super` is not called from `init`'] = function testThrowsIfThis_superIsNotCalledFromInit() { + var _this6 = this; + + this.registerHelper('hello-world', { + init: function () {} + }); + + expectAssertion(function () { + _this6.render('{{hello-world}}'); + }, /You must call `this._super\(...arguments\);` when overriding `init` on a framework object. Please update .* to call `this._super\(...arguments\);` from `init`./); + }; + + _class.prototype['@test class-based helper can recompute a new value'] = function testClassBasedHelperCanRecomputeANewValue() { + var _this7 = this; + + var destroyCount = 0; + var computeCount = 0; + var helper = undefined; + + this.registerHelper('hello-world', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return ++computeCount; + }, + destroy: function () { + destroyCount++; + this._super(); + } + }); + + this.render('{{hello-world}}'); + + this.assertText('1'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('1'); + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('2'); + + assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation'); + }; + + _class.prototype['@test class-based helper with static arguments can recompute a new value'] = function testClassBasedHelperWithStaticArgumentsCanRecomputeANewValue() { + var _this8 = this; + + var destroyCount = 0; + var computeCount = 0; + var helper = undefined; + + this.registerHelper('hello-world', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return ++computeCount; + }, + destroy: function () { + destroyCount++; + this._super(); + } + }); + + this.render('{{hello-world "whut"}}'); + + this.assertText('1'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('1'); + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('2'); + + assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation'); + }; + + _class.prototype['@test helper params can be returned'] = function testHelperParamsCanBeReturned() { + this.registerHelper('hello-world', function (values) { + return values; + }); + + this.render('{{#each (hello-world model) as |item|}}({{item}}){{/each}}', { + model: ['bob'] + }); + + this.assertText('(bob)'); + }; + + _class.prototype['@test helper hash can be returned'] = function testHelperHashCanBeReturned() { + this.registerHelper('hello-world', function (_, hash) { + return hash.model; + }); + + this.render('{{get (hello-world model=model) \'name\'}}', { + model: { name: 'bob' } + }); + + this.assertText('bob'); + }; + + _class.prototype['@test simple helper is called for param changes'] = function testSimpleHelperIsCalledForParamChanges() { + var _this9 = this; + + var computeCount = 0; + + this.registerHelper('hello-world', function (_ref) { + var value = _ref[0]; + + computeCount++; + return value + '-value'; + }); + + this.render('{{hello-world model.name}}', { + model: { name: 'bob' } + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'model.name', 'sal'); + }); + + this.assertText('sal-value'); + + assert.strictEqual(computeCount, 2, 'compute is called exactly 2 times'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'model', { name: 'bob' }); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 3, 'compute is called exactly 3 times'); + }; + + _class.prototype['@test class-based helper compute is called for param changes'] = function testClassBasedHelperComputeIsCalledForParamChanges() { + var _this10 = this; + + var createCount = 0; + var computeCount = 0; + + this.registerHelper('hello-world', { + init: function () { + this._super.apply(this, arguments); + createCount++; + }, + compute: function (_ref2) { + var value = _ref2[0]; + + computeCount++; + return value + '-value'; + } + }); + + this.render('{{hello-world model.name}}', { + model: { name: 'bob' } + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'model.name', 'sal'); + }); + + this.assertText('sal-value'); + + assert.strictEqual(computeCount, 2, 'compute is called exactly 2 times'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'model', { name: 'bob' }); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 3, 'compute is called exactly 3 times'); + assert.strictEqual(createCount, 1, 'helper is only created once'); + }; + + _class.prototype['@test simple helper receives params, hash'] = function testSimpleHelperReceivesParamsHash() { + var _this11 = this; + + this.registerHelper('hello-world', function (_params, _hash) { + return 'params: ' + JSON.stringify(_params) + ', hash: ' + JSON.stringify(_hash); + }); + + this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', { + model: { + name: 'bob', + age: 42 + } + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'model.name', 'sal'); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'model.age', 28); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'model', { name: 'bob', age: 42 }); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + }; + + _class.prototype['@test class-based helper receives params, hash'] = function testClassBasedHelperReceivesParamsHash() { + var _this12 = this; + + this.registerHelper('hello-world', { + compute: function (_params, _hash) { + return 'params: ' + JSON.stringify(_params) + ', hash: ' + JSON.stringify(_hash); + } + }); + + this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', { + model: { + name: 'bob', + age: 42 + } + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model.name', 'sal'); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model.age', 28); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model', { name: 'bob', age: 42 }); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + }; + + _class.prototype['@test class-based helper usable in subexpressions'] = function testClassBasedHelperUsableInSubexpressions() { + var _this13 = this; + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.render('{{join-words "Who"\n (join-words "overcomes" "by")\n model.reason\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}', { model: { reason: 'force' } }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model.reason', 'Nickleback'); + }); + + this.assertText('Who overcomes by Nickleback hath overcome but half his foe'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model', { reason: 'force' }); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + }; + + _class.prototype['@test parameterless helper is usable in subexpressions'] = function testParameterlessHelperIsUsableInSubexpressions() { + var _this14 = this; + + this.registerHelper('should-show', function () { + return true; + }); + + this.render('{{#if (should-show)}}true{{/if}}'); + + this.assertText('true'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('true'); + }; + + _class.prototype['@test parameterless helper is usable in attributes'] = function testParameterlessHelperIsUsableInAttributes() { + var _this15 = this; + + this.registerHelper('foo-bar', function () { + return 'baz'; + }); + + this.render('
'); + + this.assertHTML('
'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertHTML('
'); + }; + + _class.prototype['@test simple helper not usable with a block'] = function testSimpleHelperNotUsableWithABlock() { + var _this16 = this; + + this.registerHelper('some-helper', function () {}); + + expectAssertion(function () { + _this16.render('{{#some-helper}}{{/some-helper}}'); + }, /Helpers may not be used in the block form/); + }; + + _class.prototype['@test class-based helper not usable with a block'] = function testClassBasedHelperNotUsableWithABlock() { + var _this17 = this; + + this.registerHelper('some-helper', { + compute: function () {} + }); + + expectAssertion(function () { + _this17.render('{{#some-helper}}{{/some-helper}}'); + }, /Helpers may not be used in the block form/); + }; + + _class.prototype['@test simple helper not usable within element'] = function testSimpleHelperNotUsableWithinElement() { + var _this18 = this; + + this.registerHelper('some-helper', function () {}); + + this.assert.throws(function () { + _this18.render('
'); + }, /Compile Error some-helper is not a modifier: Helpers may not be used in the element form/); + }; + + _class.prototype['@test class-based helper not usable within element'] = function testClassBasedHelperNotUsableWithinElement() { + var _this19 = this; + + this.registerHelper('some-helper', { + compute: function () {} + }); + + this.assert.throws(function () { + _this19.render('
'); + }, /Compile Error some-helper is not a modifier: Helpers may not be used in the element form/); + }; + + _class.prototype['@test class-based helper is torn down'] = function testClassBasedHelperIsTornDown() { + var destroyCalled = 0; + + this.registerHelper('some-helper', { + destroy: function () { + destroyCalled++; + this._super.apply(this, arguments); + }, + compute: function () { + return 'must define a compute'; + } + }); + + this.render('{{some-helper}}'); + + _internalTestHelpers.runDestroy(this.component); + + assert.strictEqual(destroyCalled, 1, 'destroy called once'); + }; + + _class.prototype['@test class-based helper used in subexpression can recompute'] = function testClassBasedHelperUsedInSubexpressionCanRecompute() { + var _this20 = this; + + var helper = undefined; + var phrase = 'overcomes by'; + + this.registerHelper('dynamic-segment', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return phrase; + } + }); + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.render('{{join-words "Who"\n (dynamic-segment)\n "force"\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}'); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _this20.rerender(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + phrase = 'believes his'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who believes his force hath overcome but half his foe'); + + phrase = 'overcomes by'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + }; + + _class.prototype['@test class-based helper used in subexpression can recompute component'] = function testClassBasedHelperUsedInSubexpressionCanRecomputeComponent() { + var _this21 = this; + + var helper = undefined; + var phrase = 'overcomes by'; + + this.registerHelper('dynamic-segment', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return phrase; + } + }); + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.registerComponent('some-component', { + template: '{{first}} {{second}} {{third}} {{fourth}} {{fifth}}' + }); + + this.render('{{some-component first="Who"\n second=(dynamic-segment)\n third="force"\n fourth=(join-words (join-words "hath overcome but" "half"))\n fifth=(join-words "his" (join-words "foe"))}}'); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + phrase = 'believes his'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who believes his force hath overcome but half his foe'); + + phrase = 'overcomes by'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + }; + + _class.prototype['@test class-based helper used in subexpression is destroyed'] = function testClassBasedHelperUsedInSubexpressionIsDestroyed() { + var destroyCount = 0; + + this.registerHelper('dynamic-segment', { + phrase: 'overcomes by', + init: function () { + this._super.apply(this, arguments); + }, + compute: function () { + return this.phrase; + }, + destroy: function () { + destroyCount++; + this._super.apply(this, arguments); + } + }); + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.render('{{join-words "Who"\n (dynamic-segment)\n "force"\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}'); + + _internalTestHelpers.runDestroy(this.component); + + equal(destroyCount, 1, 'destroy is called after a view is destroyed'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + // these feature detects prevent errors in these tests + // on platforms (*cough* IE9 *cough*) that do not + // property support `Object.freeze` + var pushingIntoFrozenArrayThrows = (function () { + var array = []; + Object.freeze(array); + + try { + array.push('foo'); + + return false; + } catch (e) { + return true; + } + })(); + + var assigningExistingFrozenPropertyThrows = (function () { + var obj = { foo: 'asdf' }; + Object.freeze(obj); + + try { + obj.foo = 'derp'; + + return false; + } catch (e) { + return true; + } + })(); + + var addingPropertyToFrozenObjectThrows = (function () { + var obj = { foo: 'asdf' }; + Object.freeze(obj); + + try { + obj.bar = 'derp'; + + return false; + } catch (e) { + return true; + } + })(); + + if (!EmberDev.runningProdBuild && _emberUtils.HAS_NATIVE_WEAKMAP && (pushingIntoFrozenArrayThrows || assigningExistingFrozenPropertyThrows || addingPropertyToFrozenObjectThrows)) { + (function () { + var HelperMutatingArgsTests = (function (_RenderingTest2) { + babelHelpers.inherits(HelperMutatingArgsTests, _RenderingTest2); + + function HelperMutatingArgsTests() { + babelHelpers.classCallCheck(this, HelperMutatingArgsTests); + + _RenderingTest2.apply(this, arguments); + } + + HelperMutatingArgsTests.prototype.buildCompute = function buildCompute() { + var _this22 = this; + + return function (params, hash) { + if (pushingIntoFrozenArrayThrows) { + _this22.assert.throws(function () { + params.push('foo'); + + // cannot assert error message as it varies by platform + }); + } + + if (assigningExistingFrozenPropertyThrows) { + _this22.assert.throws(function () { + hash.foo = 'bar'; + + // cannot assert error message as it varies by platform + }); + } + + if (addingPropertyToFrozenObjectThrows) { + _this22.assert.throws(function () { + hash.someUnusedHashProperty = 'bar'; + + // cannot assert error message as it varies by platform + }); + } + }; + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - no positional specified / named specified'] = function testCannotMutateParamsNoPositionalSpecifiedNamedSpecified() { + this.render('{{test-helper foo=bar}}', { bar: 'derp' }); + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - positional specified / no named specified'] = function testCannotMutateParamsPositionalSpecifiedNoNamedSpecified() { + this.render('{{test-helper bar}}', { bar: 'derp' }); + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - positional specified / named specified'] = function testCannotMutateParamsPositionalSpecifiedNamedSpecified() { + this.render('{{test-helper bar foo=qux}}', { bar: 'derp', qux: 'baz' }); + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - no positional specified / no named specified'] = function testCannotMutateParamsNoPositionalSpecifiedNoNamedSpecified() { + this.render('{{test-helper}}', { bar: 'derp', qux: 'baz' }); + }; + + return HelperMutatingArgsTests; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: mutation triggers errors - class based helper', (function (_HelperMutatingArgsTests) { + babelHelpers.inherits(_class2, _HelperMutatingArgsTests); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _HelperMutatingArgsTests.call(this); + + var compute = this.buildCompute(); + + this.registerHelper('test-helper', { + compute: compute + }); + } + + return _class2; + })(HelperMutatingArgsTests)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: mutation triggers errors - simple helper', (function (_HelperMutatingArgsTests2) { + babelHelpers.inherits(_class3, _HelperMutatingArgsTests2); + + function _class3() { + babelHelpers.classCallCheck(this, _class3); + + _HelperMutatingArgsTests2.call(this); + + var compute = this.buildCompute(); + + this.registerHelper('test-helper', compute); + } + + return _class3; + })(HelperMutatingArgsTests)); + })(); + } +}); +enifed('ember-glimmer/tests/integration/helpers/custom-helper-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/custom-helper-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/custom-helper-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/element-action-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember-runtime', 'ember-views'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal, _emberRuntime, _emberViews) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#inner-component}}\n \n {{/inner-component}}\n '], ['\n {{#inner-component}}\n \n {{/inner-component}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#target-component as |parent|}}\n {{other-component anotherTarget=parent}}\n {{/target-component}}\n '], ['\n {{#target-component as |parent|}}\n {{other-component anotherTarget=parent}}\n {{/target-component}}\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#target-component as |aTarget|}}\n click me\n {{/target-component}}\n '], ['\n {{#target-component as |aTarget|}}\n click me\n {{/target-component}}\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n click me'], ['\n click me']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#middle-component}}\n {{inner-component action="hey"}}\n {{/middle-component}}\n '], ['\n {{#middle-component}}\n {{inner-component action="hey"}}\n {{/middle-component}}\n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n \n {{yield}}\n '], ['\n \n {{yield}}\n ']); + + function getActionAttributes(element) { + var attributes = element.attributes; + var actionAttrs = []; + + for (var i = 0; i < attributes.length; i++) { + var attr = attributes.item(i); + + if (attr.name.indexOf('data-ember-action-') === 0) { + actionAttrs.push(attr.name); + } + } + + return actionAttrs; + } + + function getActionIds(element) { + return getActionAttributes(element).map(function (attribute) { + return attribute.slice('data-ember-action-'.length); + }); + } + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: element action instrumentation', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + _emberMetal.instrumentationReset(); + }; + + _class.prototype['@test action should fire interaction event with proper params'] = function testActionShouldFireInteractionEventWithProperParams() { + var _this = this; + + var subscriberCallCount = 0; + var subscriberPayload = null; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + foo: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + _emberMetal.instrumentationSubscribe('interaction.ember-action', { + before: function () { + subscriberCallCount++; + }, + after: function (name, time, payload) { + subscriberPayload = payload; + } + }); + + this.render('{{example-component}}'); + + this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called'); + + this.runTask(function () { + _this.$('button').click(); + }); + + this.assert.equal(subscriberCallCount, 1, 'subscriber has been called 1 time'); + this.assert.equal(subscriberPayload.name, 'foo', 'subscriber called with correct name'); + this.assert.equal(subscriberPayload.args[0], 'bar', 'subscriber called with correct args'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: element action', (function (_RenderingTest2) { +babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test it can call an action on its enclosing component'] = function testItCanCallAnActionOnItsEnclosingComponent() { + var _this2 = this; + + var fooCallCount = 0; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + foo: function () { + fooCallCount++; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assert.equal(fooCallCount, 0, 'foo has not been called'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assert.equal(fooCallCount, 0, 'foo has not been called'); + + this.runTask(function () { + _this2.$('button').click(); + }); + + this.assert.equal(fooCallCount, 1, 'foo has been called 1 time'); + + this.runTask(function () { + _this2.$('button').click(); + }); + + this.assert.equal(fooCallCount, 2, 'foo has been called 2 times'); + }; + + _class2.prototype['@test it can call an action with parameters'] = function testItCanCallAnActionWithParameters() { + var _this3 = this; + + var fooArgs = []; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + member: 'a', + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + foo: function (thing) { + fooArgs.push(thing); + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assert.deepEqual(fooArgs, [], 'foo has not been called'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assert.deepEqual(fooArgs, [], 'foo has not been called'); + + this.runTask(function () { + _this3.$('button').click(); + }); + + this.assert.deepEqual(fooArgs, ['a'], 'foo has not been called'); + + this.runTask(function () { + component.set('member', 'b'); + }); + + this.runTask(function () { + _this3.$('button').click(); + }); + + this.assert.deepEqual(fooArgs, ['a', 'b'], 'foo has been called with an updated value'); + }; + + _class2.prototype['@test it should output a marker attribute with a guid'] = function testItShouldOutputAMarkerAttributeWithAGuid() { + this.render(''); + + var button = this.$('button'); + + var attributes = getActionAttributes(button.get(0)); + + this.assert.ok(button.attr('data-ember-action').match(''), 'An empty data-ember-action attribute was added'); + this.assert.ok(attributes[0].match(/data-ember-action-\d+/), 'A data-ember-action-xyz attribute with a guid was added'); + }; + + _class2.prototype['@test it should allow alternative events to be handled'] = function testItShouldAllowAlternativeEventsToBeHandled() { + var _this4 = this; + + var showCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + showCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '
' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('mouseup'); + _this4.$('#show').trigger(event); + }); + + this.assert.ok(showCalled, 'show action was called on mouseUp'); + }; + + _class2.prototype['@test inside a yield, the target points at the original target'] = function testInsideAYieldTheTargetPointsAtTheOriginalTarget() { + var _this5 = this; + + var targetWatted = false; + var innerWatted = false; + + var TargetComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + wat: function () { + targetWatted = true; + } + } + }); + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + wat: function () { + innerWatted = true; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '{{yield}}' + }); + + this.registerComponent('target-component', { + ComponentClass: TargetComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject) + }); + + this.render('{{target-component}}'); + + this.runTask(function () { + _this5.$('button').click(); + }); + + this.assert.ok(targetWatted, 'the correct target was watted'); + this.assert.notOk(innerWatted, 'the inner target was not watted'); + }; + + _class2.prototype['@test it should allow a target to be specified'] = function testItShouldAllowATargetToBeSpecified() { + var _this6 = this; + + var targetWatted = false; + + var TargetComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + wat: function () { + targetWatted = true; + } + } + }); + + var OtherComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + this.registerComponent('target-component', { + ComponentClass: TargetComponent, + template: '{{yield this}}' + }); + + this.registerComponent('other-component', { + ComponentClass: OtherComponent, + template: 'Wat?' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.runTask(function () { + _this6.$('a').click(); + }); + + this.assert.equal(targetWatted, true, 'the specified target was watted'); + }; + + _class2.prototype['@test it should lazily evaluate the target'] = function testItShouldLazilyEvaluateTheTarget() { + var _this7 = this; + + var firstEdit = 0; + var secondEdit = 0; + var component = undefined; + + var first = { + edit: function () { + firstEdit++; + } + }; + + var second = { + edit: function () { + secondEdit++; + } + }; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + theTarget: first + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Edit' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this7.$('a').click(); + }); + + this.assert.equal(firstEdit, 1); + + this.runTask(function () { + _emberMetal.set(component, 'theTarget', second); + }); + + this.runTask(function () { + _this7.$('a').click(); + }); + + this.assert.equal(firstEdit, 1); + this.assert.equal(secondEdit, 1); + }; + + _class2.prototype['@test it should register an event handler'] = function testItShouldRegisterAnEventHandler() { + var _this8 = this; + + var editHandlerWasCalled = false; + var shortcutHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + shortcut: function () { + shortcutHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me
click me too
' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.altKey = true; + _this8.$('a[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.ctrlKey = true; + _this8.$('div[data-ember-action]').trigger(event); + }); + + this.assert.equal(shortcutHandlerWasCalled, true, 'the "any" shortcut\'s event handler was called'); + }; + + _class2.prototype['@test it handles whitelisted bound modifier keys'] = function testItHandlesWhitelistedBoundModifierKeys() { + var _this9 = this; + + var editHandlerWasCalled = false; + var shortcutHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + altKey: 'alt', + anyKey: 'any', + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + shortcut: function () { + shortcutHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me
click me too
' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.altKey = true; + _this9.$('a[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.ctrlKey = true; + _this9.$('div[data-ember-action]').trigger(event); + }); + + this.assert.equal(shortcutHandlerWasCalled, true, 'the "any" shortcut\'s event handler was called'); + }; + + _class2.prototype['@test it handles whitelisted bound modifier keys with current value'] = function testItHandlesWhitelistedBoundModifierKeysWithCurrentValue() { + var _this10 = this; + + var editHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + acceptedKeys: 'alt', + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.altKey = true; + _this10.$('a[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + + editHandlerWasCalled = false; + + this.runTask(function () { + component.set('acceptedKeys', ''); + }); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + _this10.$('div[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the event handler was not called'); + }; + + _class2.prototype['@test should be able to use action more than once for the same event within a view'] = function testShouldBeAbleToUseActionMoreThanOnceForTheSameEventWithinAView() { + var _this11 = this; + + var editHandlerWasCalled = false; + var deleteHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + 'delete': function () { + deleteHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'editdelete' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this11.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called (due to bubbling)'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + _this11.$('#delete').click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called (due to bubbling)'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.$().click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test the event should not bubble if `bubbles=false` is passed'] = function testTheEventShouldNotBubbleIfBubblesFalseIsPassed() { + var _this12 = this; + + var editHandlerWasCalled = false; + var deleteHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + 'delete': function () { + deleteHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'editdelete' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this12.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + _this12.$('#delete').click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.$().click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test the event should not bubble if `bubbles=false` is passed bound'] = function testTheEventShouldNotBubbleIfBubblesFalseIsPassedBound() { + var _this13 = this; + + var editHandlerWasCalled = false; + var deleteHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + isFalse: false, + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + 'delete': function () { + deleteHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'editdelete' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this13.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + _this13.$('#delete').click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.$().click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test the bubbling depends on the bound parameter'] = function testTheBubblingDependsOnTheBoundParameter() { + var _this14 = this; + + var editHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + shouldBubble: false, + actions: { + edit: function () { + editHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'edit' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this14.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.set('shouldBubble', true); + }); + + this.runTask(function () { + _this14.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test it should work properly in an #each block'] = function testItShouldWorkProperlyInAnEachBlock() { + var _this15 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + items: _emberRuntime.A([1, 2, 3, 4]), + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#each items as |item|}}click me{{/each}}' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this15.$('a').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + }; + + _class2.prototype['@test it should work properly in a {{#with foo as |bar|}} block'] = function testItShouldWorkProperlyInAWithFooAsBarBlock() { + var _this16 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + something: { ohai: 'there' }, + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#with something as |somethingElse|}}click me{{/with}}' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this16.$('a').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + }; + + _class2.prototype['@test it should unregister event handlers when an element action is removed'] = function testItShouldUnregisterEventHandlersWhenAnElementActionIsRemoved() { + var _this17 = this; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#if isActive}}click me{{/if}}' + }); + + this.render('{{example-component isActive=isActive}}', { isActive: true }); + + equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered'); + + var actionId = undefined; + + actionId = getActionIds(this.$('a[data-ember-action]').get(0))[0]; + + ok(_emberViews.ActionManager.registeredActions[actionId], 'An action is registered'); + + this.runTask(function () { + return _this17.rerender(); + }); + + equal(this.$('a[data-ember-action]').length, 1, 'The element is still present'); + + ok(_emberViews.ActionManager.registeredActions[actionId], 'The action is still registered'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'isActive', false); + }); + + strictEqual(this.$('a[data-ember-action]').length, 0, 'The element is removed'); + + ok(!_emberViews.ActionManager.registeredActions[actionId], 'The action is unregistered'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'isActive', true); + }); + + equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered'); + + actionId = getActionIds(this.$('a[data-ember-action]').get(0))[0]; + + ok(_emberViews.ActionManager.registeredActions[actionId], 'A new action is registered'); + }; + + _class2.prototype['@test it should capture events from child elements and allow them to trigger the action'] = function testItShouldCaptureEventsFromChildElementsAndAllowThemToTriggerTheAction() { + var _this18 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '
' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this18.$('button').click(); + }); + + this.assert.ok(editHandlerWasCalled, 'event on a child target triggered the action of its parent'); + }; + + _class2.prototype['@test it should allow bubbling of events from action helper to original parent event'] = function testItShouldAllowBubblingOfEventsFromActionHelperToOriginalParentEvent() { + var _this19 = this; + + var editHandlerWasCalled = false; + var originalHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this19.$('a').click(); + }); + + this.assert.ok(editHandlerWasCalled && originalHandlerWasCalled, 'both event handlers were called'); + }; + + _class2.prototype['@test it should not bubble an event from action helper to original parent event if `bubbles=false` is passed'] = function testItShouldNotBubbleAnEventFromActionHelperToOriginalParentEventIfBubblesFalseIsPassed() { + var _this20 = this; + + var editHandlerWasCalled = false; + var originalHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this20.$('a').click(); + }); + + this.assert.ok(editHandlerWasCalled, 'the child event handler was called'); + this.assert.notOk(originalHandlerWasCalled, 'the parent handler was not called'); + }; + + _class2.prototype['@test it should allow "send" as the action name (#594)'] = function testItShouldAllowSendAsTheActionName594() { + var _this21 = this; + + var sendHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + send: function () { + sendHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this21.$('a').click(); + }); + + this.assert.ok(sendHandlerWasCalled, 'the event handler was called'); + }; + + _class2.prototype['@test it should send the view, event, and current context to the action'] = function testItShouldSendTheViewEventAndCurrentContextToTheAction() { + var _this22 = this; + + var passedTarget = undefined; + var passedContext = undefined; + var targetThis = undefined; + + var TargetComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + targetThis = this; + }, + actions: { + edit: function (context) { + passedTarget = this === targetThis; + passedContext = context; + } + } + }); + + var aContext = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + aContext = this; + } + }); + + this.registerComponent('target-component', { + ComponentClass: TargetComponent, + template: '{{yield this}}' + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3) + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this22.$('#edit').click(); + }); + + this.assert.ok(passedTarget, 'the action is called with the target as this'); + this.assert.strictEqual(passedContext, aContext, 'the parameter is passed along'); + }; + + _class2.prototype['@test it should only trigger actions for the event they were registered on'] = function testItShouldOnlyTriggerActionsForTheEventTheyWereRegisteredOn() { + var _this23 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this23.$('a').click(); + }); + + this.assert.ok(editHandlerWasCalled, 'the event handler was called on click'); + + editHandlerWasCalled = false; + + this.runTask(function () { + _this23.$('a').trigger('mouseover'); + }); + + this.assert.notOk(editHandlerWasCalled, 'the event handler was not called on mouseover'); + }; + + _class2.prototype['@test it should allow multiple contexts to be specified'] = function testItShouldAllowMultipleContextsToBeSpecified() { + var _this24 = this; + + var passedContexts = undefined; + var models = [_emberRuntime.Object.create(), _emberRuntime.Object.create()]; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + modelA: models[0], + modelB: models[1], + actions: { + edit: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + passedContexts = args; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this24.$('button').click(); + }); + + this.assert.deepEqual(passedContexts, models, 'the action was called with the passed contexts'); + }; + + _class2.prototype['@test it should allow multiple contexts to be specified mixed with string args'] = function testItShouldAllowMultipleContextsToBeSpecifiedMixedWithStringArgs() { + var _this25 = this; + + var passedContexts = undefined; + var model = _emberRuntime.Object.create(); + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + model: model, + actions: { + edit: function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + passedContexts = args; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this25.$('button').click(); + }); + + this.assert.deepEqual(passedContexts, ['herp', model], 'the action was called with the passed contexts'); + }; + + _class2.prototype['@test it should not trigger action with special clicks'] = function testItShouldNotTriggerActionWithSpecialClicks() { + var showCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + show: function () { + showCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + var assert = this.assert; + + function checkClick(prop, value, expected) { + var event = _emberViews.jQuery.Event('click'); + event[prop] = value; + + component.$('button').trigger(event); + + if (expected) { + assert.ok(showCalled, 'should call action with ' + prop + ':' + value); + assert.ok(event.isDefaultPrevented(), 'should prevent default'); + } else { + assert.notOk(showCalled, 'should not call action with ' + prop + ':' + value); + assert.notOk(event.isDefaultPrevented(), 'should not prevent default'); + } + } + + checkClick('ctrlKey', true, false); + checkClick('altKey', true, false); + checkClick('metaKey', true, false); + checkClick('shiftKey', true, false); + checkClick('which', 2, false); + + checkClick('which', 1, true); + checkClick('which', undefined, true); // IE <9 + }; + + _class2.prototype['@test it can trigger actions for keyboard events'] = function testItCanTriggerActionsForKeyboardEvents() { + var _this26 = this; + + var showCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + showCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('keyup'); + event.char = 'a'; + event.which = 65; + _this26.$('input').trigger(event); + }); + + this.assert.ok(showCalled, 'the action was called with keyup'); + }; + + _class2.prototype['@test a quoteless parameter should allow dynamic lookup of the actionName'] = function testAQuotelessParameterShouldAllowDynamicLookupOfTheActionName() { + var lastAction = undefined; + var actionOrder = []; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + hookMeUp: 'rock', + actions: { + rock: function () { + lastAction = 'rock'; + actionOrder.push('rock'); + }, + paper: function () { + lastAction = 'paper'; + actionOrder.push('paper'); + }, + scissors: function () { + lastAction = 'scissors'; + actionOrder.push('scissors'); + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Whistle tips go woop woooop' + }); + + this.render('{{example-component}}'); + + var test = this; + + function testBoundAction(propertyValue) { + test.runTask(function () { + component.set('hookMeUp', propertyValue); + }); + + test.runTask(function () { + component.$('#bound-param').click(); + }); + + test.assert.ok(lastAction, propertyValue, 'lastAction set to ' + propertyValue); + } + + testBoundAction('rock'); + testBoundAction('paper'); + testBoundAction('scissors'); + + this.assert.deepEqual(actionOrder, ['rock', 'paper', 'scissors'], 'action name was looked up properly'); + }; + + _class2.prototype['@test a quoteless string parameter should resolve actionName, including path'] = function testAQuotelessStringParameterShouldResolveActionNameIncludingPath() { + var lastAction = undefined; + var actionOrder = []; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + allactions: _emberRuntime.A([{ title: 'Rock', name: 'rock' }, { title: 'Paper', name: 'paper' }, { title: 'Scissors', name: 'scissors' }]), + actions: { + rock: function () { + lastAction = 'rock'; + actionOrder.push('rock'); + }, + paper: function () { + lastAction = 'paper'; + actionOrder.push('paper'); + }, + scissors: function () { + lastAction = 'scissors'; + actionOrder.push('scissors'); + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#each allactions as |allaction|}}{{allaction.title}}{{/each}}' + }); + + this.render('{{example-component}}'); + + var test = this; + + function testBoundAction(propertyValue) { + test.runTask(function () { + component.$('#' + propertyValue).click(); + }); + + test.assert.ok(lastAction, propertyValue, 'lastAction set to ' + propertyValue); + } + + testBoundAction('rock'); + testBoundAction('paper'); + testBoundAction('scissors'); + + this.assert.deepEqual(actionOrder, ['rock', 'paper', 'scissors'], 'action name was looked up properly'); + }; + + _class2.prototype['@test a quoteless function parameter should be called, including arguments'] = function testAQuotelessFunctionParameterShouldBeCalledIncludingArguments() { + var _this27 = this; + + var submitCalled = false; + var incomingArg = undefined; + + var arg = 'rough ray'; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + submit: function (actualArg) { + incomingArg = actualArg; + submitCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this27.$('a').click(); + }); + + this.assert.ok(submitCalled, 'submit function called'); + this.assert.equal(incomingArg, arg, 'argument passed'); + }; + + _class2.prototype['@test a quoteless parameter that does not resolve to a value asserts'] = function testAQuotelessParameterThatDoesNotResolveToAValueAsserts() { + var _this28 = this; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + ohNoeNotValid: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + expectAssertion(function () { + _this28.render('{{example-component}}'); + }, 'You specified a quoteless path, `ohNoeNotValid`, to the {{action}} helper ' + 'which did not resolve to an action name (a string). ' + 'Perhaps you meant to use a quoted actionName? (e.g. {{action "ohNoeNotValid"}}).'); + }; + + _class2.prototype['@test allows multiple actions on a single element'] = function testAllowsMultipleActionsOnASingleElement() { + var _this29 = this; + + var clickActionWasCalled = false; + var doubleClickActionWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + clicked: function () { + clickActionWasCalled = true; + }, + doubleClicked: function () { + doubleClickActionWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4) + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this29.$('a').trigger('click'); + }); + + this.assert.ok(clickActionWasCalled, 'the clicked action was called'); + + this.runTask(function () { + _this29.$('a').trigger('dblclick'); + }); + + this.assert.ok(doubleClickActionWasCalled, 'the doubleClicked action was called'); + }; + + _class2.prototype['@test it should respect preventDefault option if provided'] = function testItShouldRespectPreventDefaultOptionIfProvided() { + var _this30 = this; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + this.render('{{example-component}}'); + + var event = _emberViews.jQuery.Event('click'); + + this.runTask(function () { + _this30.$('a').trigger(event); + }); + + this.assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + }; + + _class2.prototype['@test it should respect preventDefault option if provided bound'] = function testItShouldRespectPreventDefaultOptionIfProvidedBound() { + var _this31 = this; + + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + shouldPreventDefault: false, + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + show: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + this.render('{{example-component}}'); + + var event = _emberViews.jQuery.Event('click'); + + this.runTask(function () { + _this31.$('a').trigger(event); + }); + + this.assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + + event = _emberViews.jQuery.Event('click'); + + this.runTask(function () { + component.set('shouldPreventDefault', true); + _this31.$('a').trigger(event); + }); + + this.assert.equal(event.isDefaultPrevented(), true, 'should preventDefault'); + }; + + _class2.prototype['@test it should target the proper component when `action` is in yielded block [GH #12409]'] = function testItShouldTargetTheProperComponentWhenActionIsInYieldedBlockGH12409() { + var _this32 = this; + + var outerActionCalled = false; + var innerClickCalled = false; + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + hey: function () { + outerActionCalled = true; + } + } + }); + + var MiddleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function () { + innerClickCalled = true; + this.sendAction(); + } + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5) + }); + + this.registerComponent('middle-component', { + ComponentClass: MiddleComponent, + template: '{{yield}}' + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6) + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this32.$('button').click(); + }); + + this.assert.ok(outerActionCalled, 'the action fired on the proper target'); + this.assert.ok(innerClickCalled, 'the click was triggered'); + }; + + _class2.prototype['@test element action with (mut undefinedThing) works properly'] = function testElementActionWithMutUndefinedThingWorksProperly() { + var _this33 = this; + + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + label: undefined, + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assertText('Click me'); + + this.assertStableRerender(); + + this.runTask(function () { + _this33.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', 'Dun clicked'); + }); + + this.assertText('Dun clicked'); + + this.runTask(function () { + _this33.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', undefined); + }); + + this.assertText('Click me'); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/element-action-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/element-action-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/element-action-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/get-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{get}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should be able to get an object value with a static key'] = function testShouldBeAbleToGetAnObjectValueWithAStaticKey() { + var _this = this; + + this.render('[{{get colors \'apple\'}}] [{{if true (get colors \'apple\')}}]', { + colors: { apple: 'red' } + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'colors.apple', 'green'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'colors', { + apple: 'red' + }); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test should be able to get an object value with nested static key'] = function testShouldBeAbleToGetAnObjectValueWithNestedStaticKey() { + var _this2 = this; + + this.render('[{{get colors "apple.gala"}}] [{{if true (get colors "apple.gala")}}]', { + colors: { + apple: { + gala: 'red and yellow' + } + } + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'colors.apple.gala', 'yellow and red striped'); + }); + + this.assertText('[yellow and red striped] [yellow and red striped]'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'colors', { apple: { gala: 'red and yellow' } }); + }); + + this.assertText('[red and yellow] [red and yellow]'); + }; + + _class.prototype['@test should be able to get an object value with a bound/dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithABoundDynamicKey() { + var _this3 = this; + + this.render('[{{get colors key}}] [{{if true (get colors key)}}]', { + colors: { apple: 'red', banana: 'yellow' }, + key: 'apple' + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'colors.apple', 'green'); + _emberMetal.set(_this3.context, 'colors.banana', 'purple'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'key', 'apple'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'colors', { apple: 'red' }); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test should be able to get an object value with nested dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithNestedDynamicKey() { + var _this4 = this; + + this.render('[{{get colors key}}] [{{if true (get colors key)}}]', { + colors: { + apple: { + gala: 'red and yellow', + mcintosh: 'red' + }, + banana: 'yellow' + }, + key: 'apple.gala' + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'key', 'apple.mcintosh'); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'key', 'apple.gala'); + }); + + this.assertText('[red and yellow] [red and yellow]'); + }; + + _class.prototype['@test should be able to get an object value with subexpression returning nested key'] = function testShouldBeAbleToGetAnObjectValueWithSubexpressionReturningNestedKey() { + var _this5 = this; + + this.render('[{{get colors (concat \'apple\' \'.\' \'gala\')}}] [{{if true (get colors (concat \'apple\' \'.\' \'gala\'))}}]', { + colors: { + apple: { + gala: 'red and yellow', + mcintosh: 'red' + } + }, + key: 'apple.gala' + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'colors.apple.gala', 'yellow and red striped'); + }); + + this.assertText('[yellow and red striped] [yellow and red striped]'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'colors.apple.gala', 'yellow-redish'); + }); + + this.assertText('[yellow-redish] [yellow-redish]'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'colors', { + apple: { + gala: 'red and yellow', + mcintosh: 'red' + } + }); + }); + + this.assertText('[red and yellow] [red and yellow]'); + }; + + _class.prototype['@test should be able to get an object value with a get helper as the key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperAsTheKey() { + var _this6 = this; + + this.render('[{{get colors (get possibleKeys key)}}] [{{if true (get colors (get possibleKeys key))}}]', { + colors: { apple: 'red', banana: 'yellow' }, + key: 'key1', + possibleKeys: { key1: 'apple', key2: 'banana' } + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'key', 'key2'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + _emberMetal.set(_this6.context, 'colors.apple', 'green'); + _emberMetal.set(_this6.context, 'colors.banana', 'purple'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'key', 'key1'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'colors', { apple: 'red', banana: 'yellow' }); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test should be able to get an object value with a get helper value as a bound/dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperValueAsABoundDynamicKey() { + var _this7 = this; + + this.render('[{{get (get possibleValues objectKey) key}}] [{{if true (get (get possibleValues objectKey) key)}}]', { + possibleValues: { + colors1: { apple: 'red', banana: 'yellow' }, + colors2: { apple: 'green', banana: 'purple' } + }, + objectKey: 'colors1', + key: 'apple' + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors2'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors1'); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors2'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors1'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'key', 'apple'); + }); + }; + + _class.prototype['@test should be able to get an object value with a get helper as the value and a get helper as the key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperAsTheValueAndAGetHelperAsTheKey() { + var _this8 = this; + + this.render('[{{get (get possibleValues objectKey) (get possibleKeys key)}}] [{{if true (get (get possibleValues objectKey) (get possibleKeys key))}}]', { + possibleValues: { + colors1: { apple: 'red', banana: 'yellow' }, + colors2: { apple: 'green', banana: 'purple' } + }, + objectKey: 'colors1', + possibleKeys: { + key1: 'apple', + key2: 'banana' + }, + key: 'key1' + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'objectKey', 'colors2'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'objectKey', 'colors1'); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'key', 'key2'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'objectKey', 'colors2'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'objectKey', 'colors1'); + _emberMetal.set(_this8.context, 'key', 'key1'); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test the result of a get helper can be yielded'] = function testTheResultOfAGetHelperCanBeYielded() { + var _this9 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + this.mcintosh = 'red'; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (get colors mcintosh)}}' + }); + + this.render('{{#foo-bar colors=colors as |value|}}{{value}}{{/foo-bar}}', { + colors: { + red: 'banana' + } + }); + + this.assertText('banana'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('banana'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'mcintosh', 'yellow'); + _emberMetal.set(_this9.context, 'colors', { yellow: 'bus' }); + }); + + this.assertText('bus'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'mcintosh', 'red'); + _emberMetal.set(_this9.context, 'colors', { red: 'banana' }); + }); + + this.assertText('banana'); + }; + + _class.prototype['@test should handle object values as nulls'] = function testShouldHandleObjectValuesAsNulls() { + var _this10 = this; + + this.render('[{{get colors \'apple\'}}] [{{if true (get colors \'apple\')}}]', { + colors: null + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'colors', { apple: 'green', banana: 'purple' }); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'colors', null); + }); + + this.assertText('[] []'); + }; + + _class.prototype['@test should handle object keys as nulls'] = function testShouldHandleObjectKeysAsNulls() { + var _this11 = this; + + this.render('[{{get colors key}}] [{{if true (get colors key)}}]', { + colors: { + apple: 'red', + banana: 'yellow' + }, + key: null + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'key', null); + }); + + this.assertText('[] []'); + }; + + _class.prototype['@test should handle object values and keys as nulls'] = function testShouldHandleObjectValuesAndKeysAsNulls() { + this.render('[{{get colors \'apple\'}}] [{{if true (get colors key)}}]', { + colors: null, + key: null + }); + + this.assertText('[] []'); + }; + + _class.prototype['@test get helper value should be updatable using {{input}} and (mut) - static key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutStaticKey(assert) { + var _this12 = this; + + this.render('{{input type=\'text\' value=(mut (get source \'banana\')) id=\'get-input\'}}', { + source: { + banana: 'banana' + } + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _this12.rerender(); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'source.banana', 'yellow'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'yellow'); + + this.runTask(function () { + return _this12.$('#get-input').val('some value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.banana'), 'some value'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'source', { banana: 'banana' }); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + }; + + _class.prototype['@test get helper value should be updatable using {{input}} and (mut) - dynamic key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutDynamicKey(assert) { + var _this13 = this; + + this.render('{{input type=\'text\' value=(mut (get source key)) id=\'get-input\'}}', { + source: { + apple: 'apple', + banana: 'banana' + }, + key: 'banana' + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _this13.rerender(); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'source.banana', 'yellow'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'yellow'); + + this.runTask(function () { + return _this13.$('#get-input').val('some value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.banana'), 'some value'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'key', 'apple'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'apple'); + + this.runTask(function () { + return _this13.$('#get-input').val('some other value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some other value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.apple'), 'some other value'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'key', 'banana'); + _emberMetal.set(_this13.context, 'source', { banana: 'banana' }); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + }; + + _class.prototype['@test get helper value should be updatable using {{input}} and (mut) - dynamic nested key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutDynamicNestedKey(assert) { + var _this14 = this; + + this.render('{{input type=\'text\' value=(mut (get source key)) id=\'get-input\'}}', { + source: { + apple: { + gala: 'gala', + mcintosh: 'mcintosh' + }, + banana: 'banana' + }, + key: 'apple.mcintosh' + }); + + assert.strictEqual(this.$('#get-input').val(), 'mcintosh'); + + this.runTask(function () { + return _this14.rerender(); + }); + + assert.strictEqual(this.$('#get-input').val(), 'mcintosh'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'source.apple.mcintosh', 'red'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'red'); + + this.runTask(function () { + return _this14.$('#get-input').val('some value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.apple.mcintosh'), 'some value'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'key', 'apple.gala'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'gala'); + + this.runTask(function () { + return _this14.$('#get-input').val('some other value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some other value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.apple.gala'), 'some other value'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'key', 'banana'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _this14.$('#get-input').val('yet another value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'yet another value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.banana'), 'yet another value'); + + this.runTask(function () { + _emberMetal.set(_this14.context, 'key', 'apple.mcintosh'); + _emberMetal.set(_this14.context, 'source', { + apple: { + gala: 'gala', + mcintosh: 'mcintosh' + }, + banana: 'banana' + }); + }); + + assert.strictEqual(this.$('#get-input').val(), 'mcintosh'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/get-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/get-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/get-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/hash-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{hash}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test returns a hash with the right key-value'] = function testReturnsAHashWithTheRightKeyValue() { + var _this = this; + + this.render('{{#with (hash name="Sergio") as |person|}}{{person.name}}{{/with}}'); + + this.assertText('Sergio'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('Sergio'); + }; + + _class.prototype['@test can have more than one key-value'] = function testCanHaveMoreThanOneKeyValue() { + var _this2 = this; + + this.render('{{#with (hash name="Sergio" lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}'); + + this.assertText('Sergio Arbeo'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Sergio Arbeo'); + }; + + _class.prototype['@test binds values when variables are used'] = function testBindsValuesWhenVariablesAreUsed() { + var _this3 = this; + + this.render('{{#with (hash name=model.firstName lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}', { + model: { + firstName: 'Marisa' + } + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.firstName', 'Sergio'); + }); + + this.assertText('Sergio Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { firstName: 'Marisa' }); + }); + + this.assertText('Marisa Arbeo'); + }; + + _class.prototype['@test binds multiple values when variables are used'] = function testBindsMultipleValuesWhenVariablesAreUsed() { + var _this4 = this; + + this.render('{{#with (hash name=model.firstName lastName=model.lastName) as |person|}}{{person.name}} {{person.lastName}}{{/with}}', { + model: { + firstName: 'Marisa', + lastName: 'Arbeo' + } + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model.firstName', 'Sergio'); + }); + + this.assertText('Sergio Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model.lastName', 'Smith'); + }); + + this.assertText('Sergio Smith'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model', { + firstName: 'Marisa', + lastName: 'Arbeo' + }); + }); + + this.assertText('Marisa Arbeo'); + }; + + _class.prototype['@test hash helpers can be nested'] = function testHashHelpersCanBeNested() { + var _this5 = this; + + this.render('{{#with (hash person=(hash name=model.firstName)) as |ctx|}}{{ctx.person.name}}{{/with}}', { + model: { firstName: 'Balint' } + }); + + this.assertText('Balint'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('Balint'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model.firstName', 'Chad'); + }); + + this.assertText('Chad'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model', { firstName: 'Balint' }); + }); + + this.assertText('Balint'); + }; + + _class.prototype['@test should yield hash of internal properties'] = function testShouldYieldHashOfInternalProperties() { + var _this6 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + this.model = { firstName: 'Chad' }; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (hash firstName=model.firstName)}}' + }); + + this.render('{{#foo-bar as |values|}}{{values.firstName}}{{/foo-bar}}'); + + this.assertText('Chad'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('Chad'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model.firstName', 'Godfrey'); + }); + + this.assertText('Godfrey'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model', { firstName: 'Chad' }); + }); + + this.assertText('Chad'); + }; + + _class.prototype['@test should yield hash of internal and external properties'] = function testShouldYieldHashOfInternalAndExternalProperties() { + var _this7 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + this.model = { firstName: 'Chad' }; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (hash firstName=model.firstName lastName=lastName)}}' + }); + + this.render('{{#foo-bar lastName=model.lastName as |values|}}{{values.firstName}} {{values.lastName}}{{/foo-bar}}', { + model: { lastName: 'Hietala' } + }); + + this.assertText('Chad Hietala'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('Chad Hietala'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'model.firstName', 'Godfrey'); + _emberMetal.set(_this7.context, 'model.lastName', 'Chan'); + }); + + this.assertText('Godfrey Chan'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'model', { firstName: 'Chad' }); + _emberMetal.set(_this7.context, 'model', { lastName: 'Hietala' }); + }); + + this.assertText('Chad Hietala'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/hash-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/hash-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/hash-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/if-unless-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: inline {{if}}', (function (_IfUnlessHelperTest) { + babelHelpers.inherits(_class, _IfUnlessHelperTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _IfUnlessHelperTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{if ' + cond + ' ' + truthy + ' ' + falsy + '}}'; + }; + + _class.prototype['@test it raises when there are more than three arguments'] = function testItRaisesWhenThereAreMoreThanThreeArguments() { + var _this = this; + + expectAssertion(function () { + _this.render('{{if condition \'a\' \'b\' \'c\'}}', { condition: true }); + }, /The inline form of the `if` helper expects two or three arguments/); + }; + + _class.prototype['@test it raises when there are less than two arguments'] = function testItRaisesWhenThereAreLessThanTwoArguments() { + var _this2 = this; + + expectAssertion(function () { + _this2.render('{{if condition}}', { condition: true }); + }, /The inline form of the `if` helper expects two or three arguments/); + }; + + return _class; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{if}} helpers (returning truthy values)', (function (_IfUnlessHelperTest2) { + babelHelpers.inherits(_class2, _IfUnlessHelperTest2); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _IfUnlessHelperTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{if (if ' + cond + ' ' + cond + ' false) ' + truthy + ' ' + falsy + '}}'; + }; + + return _class2; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{if}} helpers (returning falsy values)', (function (_IfUnlessHelperTest3) { + babelHelpers.inherits(_class3, _IfUnlessHelperTest3); + + function _class3() { + babelHelpers.classCallCheck(this, _class3); + + _IfUnlessHelperTest3.apply(this, arguments); + } + + _class3.prototype.templateFor = function templateFor(_ref3) { + var cond = _ref3.cond; + var truthy = _ref3.truthy; + var falsy = _ref3.falsy; + + return '{{if (if ' + cond + ' true ' + cond + ') ' + truthy + ' ' + falsy + '}}'; + }; + + return _class3; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{if}} used with another helper', (function (_IfUnlessHelperTest4) { + babelHelpers.inherits(_class4, _IfUnlessHelperTest4); + + function _class4() { + babelHelpers.classCallCheck(this, _class4); + + _IfUnlessHelperTest4.apply(this, arguments); + } + + _class4.prototype.wrapperFor = function wrapperFor(templates) { + return '{{concat ' + templates.join(' ') + '}}'; + }; + + _class4.prototype.templateFor = function templateFor(_ref4) { + var cond = _ref4.cond; + var truthy = _ref4.truthy; + var falsy = _ref4.falsy; + + return '(if ' + cond + ' ' + truthy + ' ' + falsy + ')'; + }; + + return _class4; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{if}} used in attribute position', (function (_IfUnlessHelperTest5) { + babelHelpers.inherits(_class5, _IfUnlessHelperTest5); + + function _class5() { + babelHelpers.classCallCheck(this, _class5); + + _IfUnlessHelperTest5.apply(this, arguments); + } + + _class5.prototype.wrapperFor = function wrapperFor(templates) { + return '
'; + }; + + _class5.prototype.templateFor = function templateFor(_ref5) { + var cond = _ref5.cond; + var truthy = _ref5.truthy; + var falsy = _ref5.falsy; + + return '{{if ' + cond + ' ' + truthy + ' ' + falsy + '}}'; + }; + + _class5.prototype.textValue = function textValue() { + return this.$('div').attr('data-foo'); + }; + + return _class5; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: inline {{if}} and {{unless}} without the inverse argument', (function (_IfUnlessHelperTest6) { + babelHelpers.inherits(_class6, _IfUnlessHelperTest6); + + function _class6() { + babelHelpers.classCallCheck(this, _class6); + + _IfUnlessHelperTest6.apply(this, arguments); + } + + _class6.prototype.templateFor = function templateFor(_ref6) { + var cond = _ref6.cond; + var truthy = _ref6.truthy; + var falsy = _ref6.falsy; + + return '{{if ' + cond + ' ' + truthy + '}}{{unless ' + cond + ' ' + falsy + '}}'; + }; + + return _class6; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: inline {{unless}}', (function (_IfUnlessHelperTest7) { + babelHelpers.inherits(_class7, _IfUnlessHelperTest7); + + function _class7() { + babelHelpers.classCallCheck(this, _class7); + + _IfUnlessHelperTest7.apply(this, arguments); + } + + _class7.prototype.templateFor = function templateFor(_ref7) { + var cond = _ref7.cond; + var truthy = _ref7.truthy; + var falsy = _ref7.falsy; + + return '{{unless ' + cond + ' ' + falsy + ' ' + truthy + '}}'; + }; + + _class7.prototype['@test it raises when there are more than three arguments'] = function testItRaisesWhenThereAreMoreThanThreeArguments() { + var _this3 = this; + + expectAssertion(function () { + _this3.render('{{unless condition \'a\' \'b\' \'c\'}}', { condition: true }); + }, /The inline form of the `unless` helper expects two or three arguments/); + }; + + _class7.prototype['@test it raises when there are less than two arguments'] = function testItRaisesWhenThereAreLessThanTwoArguments() { + var _this4 = this; + + expectAssertion(function () { + _this4.render('{{unless condition}}', { condition: true }); + }, /The inline form of the `unless` helper expects two or three arguments/); + }; + + return _class7; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{unless}} helpers (returning truthy values)', (function (_IfUnlessHelperTest8) { + babelHelpers.inherits(_class8, _IfUnlessHelperTest8); + + function _class8() { + babelHelpers.classCallCheck(this, _class8); + + _IfUnlessHelperTest8.apply(this, arguments); + } + + _class8.prototype.templateFor = function templateFor(_ref8) { + var cond = _ref8.cond; + var truthy = _ref8.truthy; + var falsy = _ref8.falsy; + + return '{{unless (unless ' + cond + ' false ' + cond + ') ' + falsy + ' ' + truthy + '}}'; + }; + + return _class8; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{unless}} helpers (returning falsy values)', (function (_IfUnlessHelperTest9) { + babelHelpers.inherits(_class9, _IfUnlessHelperTest9); + + function _class9() { + babelHelpers.classCallCheck(this, _class9); + + _IfUnlessHelperTest9.apply(this, arguments); + } + + _class9.prototype.templateFor = function templateFor(_ref9) { + var cond = _ref9.cond; + var truthy = _ref9.truthy; + var falsy = _ref9.falsy; + + return '{{unless (unless ' + cond + ' ' + cond + ' true) ' + falsy + ' ' + truthy + '}}'; + }; + + return _class9; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{unless}} used with another helper', (function (_IfUnlessHelperTest10) { + babelHelpers.inherits(_class10, _IfUnlessHelperTest10); + + function _class10() { + babelHelpers.classCallCheck(this, _class10); + + _IfUnlessHelperTest10.apply(this, arguments); + } + + _class10.prototype.wrapperFor = function wrapperFor(templates) { + return '{{concat ' + templates.join(' ') + '}}'; + }; + + _class10.prototype.templateFor = function templateFor(_ref10) { + var cond = _ref10.cond; + var truthy = _ref10.truthy; + var falsy = _ref10.falsy; + + return '(unless ' + cond + ' ' + falsy + ' ' + truthy + ')'; + }; + + return _class10; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{unless}} used in attribute position', (function (_IfUnlessHelperTest11) { + babelHelpers.inherits(_class11, _IfUnlessHelperTest11); + + function _class11() { + babelHelpers.classCallCheck(this, _class11); + + _IfUnlessHelperTest11.apply(this, arguments); + } + + _class11.prototype.wrapperFor = function wrapperFor(templates) { + return '
'; + }; + + _class11.prototype.templateFor = function templateFor(_ref11) { + var cond = _ref11.cond; + var truthy = _ref11.truthy; + var falsy = _ref11.falsy; + + return '{{unless ' + cond + ' ' + falsy + ' ' + truthy + '}}'; + }; + + _class11.prototype.textValue = function textValue() { + return this.$('div').attr('data-foo'); + }; + + return _class11; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/if-unless-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/if-unless-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/if-unless-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/input-test', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case', 'internal-test-helpers'], function (exports, _emberUtils, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestCase, _internalTestHelpers) { + 'use strict'; + + var InputRenderingTest = (function (_RenderingTest) { + babelHelpers.inherits(InputRenderingTest, _RenderingTest); + + function InputRenderingTest() { + babelHelpers.classCallCheck(this, InputRenderingTest); + + _RenderingTest.call(this); + + this.registerComponent('-text-field', { ComponentClass: _emberGlimmerTestsUtilsHelpers.TextField }); + this.registerComponent('-checkbox', { ComponentClass: _emberGlimmerTestsUtilsHelpers.Checkbox }); + } + + InputRenderingTest.prototype.$input = function $input() { + return this.$('input'); + }; + + InputRenderingTest.prototype.inputID = function inputID() { + return this.$input().prop('id'); + }; + + InputRenderingTest.prototype.assertDisabled = function assertDisabled() { + this.assert.ok(this.$('input').prop('disabled'), 'The input is disabled'); + }; + + InputRenderingTest.prototype.assertNotDisabled = function assertNotDisabled() { + this.assert.ok(this.$('input').is(':not(:disabled)'), 'The input is not disabled'); + }; + + InputRenderingTest.prototype.assertInputId = function assertInputId(expectedId) { + this.assert.equal(this.inputID(), expectedId, 'the input id should be `expectedId`'); + }; + + InputRenderingTest.prototype.assertSingleInput = function assertSingleInput() { + this.assert.equal(this.$('input').length, 1, 'A single text field was inserted'); + }; + + InputRenderingTest.prototype.assertSingleCheckbox = function assertSingleCheckbox() { + this.assert.equal(this.$('input[type=checkbox]').length, 1, 'A single checkbox is added'); + }; + + InputRenderingTest.prototype.assertCheckboxIsChecked = function assertCheckboxIsChecked() { + this.assert.equal(this.$input().prop('checked'), true, 'the checkbox is checked'); + }; + + InputRenderingTest.prototype.assertCheckboxIsNotChecked = function assertCheckboxIsNotChecked() { + this.assert.equal(this.$input().prop('checked'), false, 'the checkbox is not checked'); + }; + + InputRenderingTest.prototype.assertValue = function assertValue(expected) { + this.assert.equal(this.$input().val(), expected, 'the input value should be ' + expected); + }; + + InputRenderingTest.prototype.assertAttr = function assertAttr(name, expected) { + this.assert.equal(this.$input().attr(name), expected, 'the input ' + name + ' attribute has the value \'' + expected + '\''); + }; + + InputRenderingTest.prototype.assertAllAttrs = function assertAllAttrs(names, expected) { + var _this = this; + + names.forEach(function (name) { + return _this.assertAttr(name, expected); + }); + }; + + InputRenderingTest.prototype.assertSelectionRange = function assertSelectionRange(start, end) { + var input = this.$input()[0]; + this.assert.equal(input.selectionStart, start, 'the cursor start position should be ' + start); + this.assert.equal(input.selectionEnd, end, 'the cursor end position should be ' + end); + }; + + InputRenderingTest.prototype.triggerEvent = function triggerEvent(type, options) { + var event = document.createEvent('Events'); + event.initEvent(type, true, true); + _emberUtils.assign(event, options); + + var element = this.$input()[0]; + this.runTask(function () { + element.dispatchEvent(event); + }); + }; + + return InputRenderingTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input}}', (function (_InputRenderingTest) { + babelHelpers.inherits(_class, _InputRenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _InputRenderingTest.apply(this, arguments); + } + + _class.prototype['@test a single text field is inserted into the DOM'] = function testASingleTextFieldIsInsertedIntoTheDOM(assert) { + var _this2 = this; + + this.render('{{input type="text" value=value}}', { value: 'hello' }); + + var id = this.inputID(); + + this.assertValue('hello'); + this.assertSingleInput(); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertValue('hello'); + this.assertSingleInput(); + this.assertInputId(id); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'value', 'goodbye'); + }); + + this.assertValue('goodbye'); + this.assertSingleInput(); + this.assertInputId(id); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'value', 'hello'); + }); + + this.assertValue('hello'); + this.assertSingleInput(); + this.assertInputId(id); + }; + + _class.prototype['@test default type'] = function testDefaultType() { + var _this3 = this; + + this.render('{{input}}'); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertAttr('type', 'text'); + }; + + _class.prototype['@test dynamic attributes'] = function testDynamicAttributes() { + var _this4 = this; + + this.render('\n {{input type="text"\n disabled=disabled\n value=value\n placeholder=placeholder\n name=name\n maxlength=maxlength\n size=size\n tabindex=tabindex\n }}', { + disabled: false, + value: 'Original value', + placeholder: 'Original placeholder', + name: 'original-name', + maxlength: 10, + size: 20, + tabindex: 30 + }); + + this.assertNotDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertNotDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + _emberMetal.set(_this4.context, 'value', 'Updated value'); + _emberMetal.set(_this4.context, 'disabled', true); + _emberMetal.set(_this4.context, 'placeholder', 'Updated placeholder'); + _emberMetal.set(_this4.context, 'name', 'updated-name'); + _emberMetal.set(_this4.context, 'maxlength', 11); + // set(this.context, 'size', 21); //NOTE: failing in IE (TEST_SUITE=sauce) + // set(this.context, 'tabindex', 31); //NOTE: failing in IE (TEST_SUITE=sauce) + }); + + this.assertDisabled(); + this.assertValue('Updated value'); + this.assertAttr('placeholder', 'Updated placeholder'); + this.assertAttr('name', 'updated-name'); + this.assertAttr('maxlength', '11'); + // this.assertAttr('size', '21'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '31'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + _emberMetal.set(_this4.context, 'value', 'Original value'); + _emberMetal.set(_this4.context, 'disabled', false); + _emberMetal.set(_this4.context, 'placeholder', 'Original placeholder'); + _emberMetal.set(_this4.context, 'name', 'original-name'); + _emberMetal.set(_this4.context, 'maxlength', 10); + // set(this.context, 'size', 20); //NOTE: failing in IE (TEST_SUITE=sauce) + // set(this.context, 'tabindex', 30); //NOTE: failing in IE (TEST_SUITE=sauce) + }); + + this.assertNotDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + }; + + _class.prototype['@test static attributes'] = function testStaticAttributes() { + var _this5 = this; + + this.render('\n {{input type="text"\n disabled=true\n value="Original value"\n placeholder="Original placeholder"\n name="original-name"\n maxlength=10\n size=20\n tabindex=30\n }}'); + + this.assertDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + }; + + _class.prototype['@test cursor selection range'] = function testCursorSelectionRange(assert) { + var _this6 = this; + + // Modifying input.selectionStart, which is utilized in the cursor tests, + // causes an event in Safari. + _internalTestHelpers.runDestroy(this.owner.lookup('event_dispatcher:main')); + + this.render('{{input type="text" value=value}}', { value: 'original' }); + + var input = this.$input()[0]; + + // See https://ember-twiddle.com/33e506329f8176ae874422644d4cc08c?openFiles=components.input-component.js%2Ctemplates.components.input-component.hbs + // this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce) + + this.runTask(function () { + return _this6.rerender(); + }); + + // this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce) + + this.runTask(function () { + input.selectionStart = 2; + input.selectionEnd = 4; + }); + + this.assertSelectionRange(2, 4); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertSelectionRange(2, 4); + + // this.runTask(() => set(this.context, 'value', 'updated')); + // + // this.assertSelectionRange(7, 7); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) + // + // this.runTask(() => set(this.context, 'value', 'original')); + // + // this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) + }; + + _class.prototype['@test specifying `on="someevent" action="foo"` results in a deprecation warning'] = function testSpecifyingOnSomeeventActionFooResultsInADeprecationWarning() { + var _this7 = this; + + expectDeprecation(function () { + _this7.render('{{input on="focus-in" action="doFoo" value="hello"}}'); + }, 'Using \'{{input on="focus-in" action="doFoo"}}\' (\'-top-level\' @ L1:C0) is deprecated. Please use \'{{input focus-in="doFoo"}}\' instead.'); + }; + + _class.prototype['@test sends an action with `{{input action="foo"}}` when is pressed [DEPRECATED]'] = function testSendsAnActionWithInputActionFooWhenEnterIsPressedDEPRECATED(assert) { + var _this8 = this; + + assert.expect(2); + + expectDeprecation(function () { + _this8.render('{{input action=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + }, /Please use '{{input enter="foo"}}' instead/); + + this.triggerEvent('keyup', { + keyCode: 13 + }); + }; + + _class.prototype['@test sends an action with `{{input enter="foo"}}` when is pressed'] = function testSendsAnActionWithInputEnterFooWhenEnterIsPressed(assert) { + assert.expect(1); + + this.render('{{input enter=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 13 + }); + }; + + _class.prototype['@test sends an action with `{{input key-press="foo"}}` is pressed'] = function testSendsAnActionWithInputKeyPressFooIsPressed(assert) { + assert.expect(1); + + this.render('{{input value=value key-press=\'foo\'}}', { + value: 'initial', + + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keypress', { + keyCode: 65 + }); + }; + + _class.prototype['@test sends an action to the parent level when `bubbles=true` is provided'] = function testSendsAnActionToTheParentLevelWhenBubblesTrueIsProvided(assert) { + assert.expect(1); + + var ParentComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + change: function () { + assert.ok(true, 'bubbled upwards'); + } + }); + + this.registerComponent('x-parent', { + ComponentClass: ParentComponent, + template: '{{input bubbles=true}}' + }); + this.render('{{x-parent}}'); + + this.triggerEvent('change'); + }; + + _class.prototype['@test triggers `focus-in` when focused'] = function testTriggersFocusInWhenFocused(assert) { + var _this9 = this; + + assert.expect(1); + + this.render('{{input focus-in=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.runTask(function () { + _this9.$input().trigger('focusin'); + }); + }; + + _class.prototype['@test sends `insert-newline` when is pressed'] = function testSendsInsertNewlineWhenEnterIsPressed(assert) { + assert.expect(1); + + this.render('{{input insert-newline=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 13 + }); + }; + + _class.prototype['@test sends an action with `{{input escape-press="foo"}}` when is pressed'] = function testSendsAnActionWithInputEscapePressFooWhenEscapeIsPressed(assert) { + assert.expect(1); + + this.render('{{input escape-press=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 27 + }); + }; + + _class.prototype['@test sends an action with `{{input key-down="foo"}}` when a key is pressed'] = function testSendsAnActionWithInputKeyDownFooWhenAKeyIsPressed(assert) { + assert.expect(1); + + this.render('{{input key-down=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keydown', { + keyCode: 65 + }); + }; + + _class.prototype['@test sends an action with `{{input key-up="foo"}}` when a key is pressed'] = function testSendsAnActionWithInputKeyUpFooWhenAKeyIsPressed(assert) { + assert.expect(1); + + this.render('{{input key-up=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 65 + }); + }; + + return _class; + })(InputRenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input}} with dynamic type', (function (_InputRenderingTest2) { + babelHelpers.inherits(_class2, _InputRenderingTest2); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _InputRenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test a bound property can be used to determine type'] = function testABoundPropertyCanBeUsedToDetermineType() { + var _this10 = this; + + this.render('{{input type=type}}', { type: 'password' }); + + this.assertAttr('type', 'password'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertAttr('type', 'password'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'type', 'text'); + }); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'type', 'password'); + }); + + this.assertAttr('type', 'password'); + }; + + _class2.prototype['@test a subexpression can be used to determine type'] = function testASubexpressionCanBeUsedToDetermineType() { + var _this11 = this; + + this.render('{{input type=(if isTruthy trueType falseType)}}', { + isTruthy: true, + trueType: 'text', + falseType: 'password' + }); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'isTruthy', false); + }); + + this.assertAttr('type', 'password'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'isTruthy', true); + }); + + this.assertAttr('type', 'text'); + }; + + return _class2; + })(InputRenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input type=\'checkbox\'}}', (function (_InputRenderingTest3) { + babelHelpers.inherits(_class3, _InputRenderingTest3); + + function _class3() { + babelHelpers.classCallCheck(this, _class3); + + _InputRenderingTest3.apply(this, arguments); + } + + _class3.prototype['@test dynamic attributes'] = function testDynamicAttributes() { + var _this12 = this; + + this.render('{{input\n type=\'checkbox\'\n disabled=disabled\n name=name\n checked=checked\n tabindex=tabindex\n }}', { + disabled: false, + name: 'original-name', + checked: false, + tabindex: 10 + }); + + this.assertSingleCheckbox(); + this.assertNotDisabled(); + this.assertAttr('name', 'original-name'); + this.assertAttr('tabindex', '10'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertSingleCheckbox(); + this.assertNotDisabled(); + this.assertAttr('name', 'original-name'); + this.assertAttr('tabindex', '10'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'disabled', true); + _emberMetal.set(_this12.context, 'name', 'updated-name'); + _emberMetal.set(_this12.context, 'tabindex', 11); + }); + + this.assertSingleCheckbox(); + this.assertDisabled(); + this.assertAttr('name', 'updated-name'); + this.assertAttr('tabindex', '11'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'disabled', false); + _emberMetal.set(_this12.context, 'name', 'original-name'); + _emberMetal.set(_this12.context, 'tabindex', 10); + }); + + this.assertSingleCheckbox(); + this.assertNotDisabled(); + this.assertAttr('name', 'original-name'); + this.assertAttr('tabindex', '10'); + }; + + _class3.prototype['@test `value` property assertion'] = function testValuePropertyAssertion() { + var _this13 = this; + + expectAssertion(function () { + _this13.render('{{input type="checkbox" value=value}}', { value: 'value' }); + }, /you must use `checked=/); + }; + + _class3.prototype['@test with a bound type'] = function testWithABoundType(assert) { + var _this14 = this; + + this.render('{{input type=inputType checked=isChecked}}', { inputType: 'checkbox', isChecked: true }); + + this.assertSingleCheckbox(); + this.assertCheckboxIsChecked(); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertCheckboxIsChecked(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'isChecked', false); + }); + + this.assertCheckboxIsNotChecked(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'isChecked', true); + }); + + this.assertCheckboxIsChecked(); + }; + + _class3.prototype['@test with static values'] = function testWithStaticValues(assert) { + var _this15 = this; + + this.render('{{input type="checkbox" disabled=false tabindex=10 name="original-name" checked=false}}'); + + this.assertSingleCheckbox(); + this.assertCheckboxIsNotChecked(); + this.assertNotDisabled(); + this.assertAttr('tabindex', '10'); + this.assertAttr('name', 'original-name'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertSingleCheckbox(); + this.assertCheckboxIsNotChecked(); + this.assertNotDisabled(); + this.assertAttr('tabindex', '10'); + this.assertAttr('name', 'original-name'); + }; + + return _class3; + })(InputRenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input type=\'text\'}}', (function (_InputRenderingTest4) { + babelHelpers.inherits(_class4, _InputRenderingTest4); + + function _class4() { + babelHelpers.classCallCheck(this, _class4); + + _InputRenderingTest4.apply(this, arguments); + } + + _class4.prototype['@test null values'] = function testNullValues(assert) { + var _this16 = this; + + var attributes = ['disabled', 'placeholder', 'name', 'maxlength', 'size', 'tabindex']; + + this.render('\n {{input type="text"\n disabled=disabled\n value=value\n placeholder=placeholder\n name=name\n maxlength=maxlength\n size=size\n tabindex=tabindex\n }}', { + disabled: null, + value: null, + placeholder: null, + name: null, + maxlength: null, + size: null, + tabindex: null + }); + + this.assertValue(''); + this.assertAllAttrs(attributes, undefined); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertValue(''); + this.assertAllAttrs(attributes, undefined); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'disabled', true); + _emberMetal.set(_this16.context, 'value', 'Updated value'); + _emberMetal.set(_this16.context, 'placeholder', 'Updated placeholder'); + _emberMetal.set(_this16.context, 'name', 'updated-name'); + _emberMetal.set(_this16.context, 'maxlength', 11); + _emberMetal.set(_this16.context, 'size', 21); + _emberMetal.set(_this16.context, 'tabindex', 31); + }); + + this.assertDisabled(); + this.assertValue('Updated value'); + this.assertAttr('placeholder', 'Updated placeholder'); + this.assertAttr('name', 'updated-name'); + this.assertAttr('maxlength', '11'); + this.assertAttr('size', '21'); + this.assertAttr('tabindex', '31'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'disabled', null); + _emberMetal.set(_this16.context, 'value', null); + _emberMetal.set(_this16.context, 'placeholder', null); + _emberMetal.set(_this16.context, 'name', null); + _emberMetal.set(_this16.context, 'maxlength', null); + // set(this.context, 'size', null); //NOTE: this fails with `Error: Failed to set the 'size' property on 'HTMLInputElement': The value provided is 0, which is an invalid size.` (TEST_SUITE=sauce) + _emberMetal.set(_this16.context, 'tabindex', null); + }); + + this.assertAttr('disabled', undefined); + this.assertValue(''); + // this.assertAttr('placeholder', undefined); //NOTE: this fails with a value of "null" (TEST_SUITE=sauce) + // this.assertAttr('name', undefined); //NOTE: this fails with a value of "null" (TEST_SUITE=sauce) + this.assertAttr('maxlength', undefined); + // this.assertAttr('size', undefined); //NOTE: re-enable once `size` bug above has been addressed + this.assertAttr('tabindex', undefined); + }; + + return _class4; + })(InputRenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/input-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/input-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/input-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/loc-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _ember) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{loc}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.call(this); + this.oldString = _ember.default.STRINGS; + _ember.default.STRINGS = { + 'Hello Friend': 'Hallo Freund', + 'Hello': 'Hallo, %@' + }; + } + + _class.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + _ember.default.STRINGS = this.oldString; + }; + + _class.prototype['@test it lets the original value through by default'] = function testItLetsTheOriginalValueThroughByDefault() { + var _this = this; + + this.render('{{loc "Hiya buddy!"}}'); + this.assertText('Hiya buddy!', 'the unlocalized string is correct'); + this.runTask(function () { + return _this.rerender(); + }); + this.assertText('Hiya buddy!', 'the unlocalized string is correct after rerender'); + }; + + _class.prototype['@test it localizes a simple string'] = function testItLocalizesASimpleString() { + var _this2 = this; + + this.render('{{loc "Hello Friend"}}'); + this.assertText('Hallo Freund', 'the localized string is correct'); + this.runTask(function () { + return _this2.rerender(); + }); + this.assertText('Hallo Freund', 'the localized string is correct after rerender'); + }; + + _class.prototype['@test it takes passed formats into an account'] = function testItTakesPassedFormatsIntoAnAccount() { + var _this3 = this; + + this.render('{{loc "%@, %@" "Hello" "Mr. Pitkin"}}'); + this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct'); + this.runTask(function () { + return _this3.rerender(); + }); + this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct after rerender'); + }; + + _class.prototype['@test it updates when bound params change'] = function testItUpdatesWhenBoundParamsChange() { + var _this4 = this; + + this.render('{{loc simple}} - {{loc personal \'Mr. Pitkin\'}}', { + simple: 'Hello Friend', + personal: 'Hello' + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct'); + + this.runTask(function () { + return _this4.rerender(); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after rerender'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'simple', 'G\'day mate'); + }); + this.assertText('G\'day mate - Hallo, Mr. Pitkin', 'the bound value is correct after update'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'simple', 'Hello Friend'); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after reset'); + }; + + _class.prototype['@test it updates when nested bound params change'] = function testItUpdatesWhenNestedBoundParamsChange() { + var _this5 = this; + + this.render('{{loc greetings.simple}} - {{loc greetings.personal \'Mr. Pitkin\'}}', { + greetings: { + simple: 'Hello Friend', + personal: 'Hello' + } + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct'); + + this.runTask(function () { + return _this5.rerender(); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after rerender'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'greetings.simple', 'G\'day mate'); + }); + this.assertText('G\'day mate - Hallo, Mr. Pitkin', 'the bound value is correct after interior mutation'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'greetings', { + simple: 'Hello Friend', + personal: 'Hello' + }); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after replacement'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/loc-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/loc-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/loc-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/log-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-console'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberConsole) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{log}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class(assert) { + var _this = this; + + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.call(this); + + this.originalLog = _emberConsole.default.log; + this.logCalls = []; + _emberConsole.default.log = function () { + var _logCalls; + + (_logCalls = _this.logCalls).push.apply(_logCalls, arguments); + }; + } + + _class.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + _emberConsole.default.log = this.originalLog; + }; + + _class.prototype.assertLog = function assertLog(values) { + this.assertText(''); + this.assert.strictEqual(this.logCalls.length, values.length); + + for (var i = 0, len = values.length; i < len; i++) { + this.assert.strictEqual(this.logCalls[i], values[i]); + } + }; + + _class.prototype['@test correctly logs primitives'] = function testCorrectlyLogsPrimitives() { + this.render('{{log "one" 1 true}}'); + + this.assertLog(['one', 1, true]); + }; + + _class.prototype['@test correctly logs a property'] = function testCorrectlyLogsAProperty() { + this.render('{{log value}}', { + value: 'one' + }); + + this.assertLog(['one']); + }; + + _class.prototype['@test correctly logs multiple arguments'] = function testCorrectlyLogsMultipleArguments() { + this.render('{{log "my variable:" value}}', { + value: 'one' + }); + + this.assertLog(['my variable:', 'one']); + }; + + _class.prototype['@test correctly logs `this`'] = function testCorrectlyLogsThis() { + this.render('{{log this}}'); + + this.assertLog([this.context]); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/log-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/log-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/log-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/mut-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal, _emberGlimmerTestsUtilsTestHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{mut}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test a simple mutable binding using `mut` propagates properly'] = function testASimpleMutableBindingUsingMutPropagatesProperly() { + var _this = this; + + var bottom = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + template: '{{bottom-mut setMe=value}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assertText('12', 'the data propagated downwards'); + + this.assertStableRerender(); + + this.runTask(function () { + return bottom.attrs.setMe.update(13); + }); + + this.assertText('13', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 13, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 13, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'setMe', 14); + }); + + this.assertText('14', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 14, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test a simple mutable binding using `mut` inserts into the DOM'] = function testASimpleMutableBindingUsingMutInsertsIntoTheDOM() { + var _this2 = this; + + var bottom = undefined, + middle = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + middle = this; + } + }), + template: '{{bottom-mut setMe=(mut value)}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assertText('12', 'the data propagated downwards'); + + this.assertStableRerender(); + + this.runTask(function () { + return bottom.attrs.setMe.update(13); + }); + + this.assertText('13', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 13, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 13, 'the set propagated to middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 13, 'the set propagated to middle\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 13, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'setMe', 14); + }); + + this.assertText('14', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 14, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 14, 'the set propagated to middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 14, 'the set propagated to middle\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test passing a literal results in a assertion'] = function testPassingALiteralResultsInAAssertion() { + var _this3 = this; + + this.registerComponent('bottom-mut', { template: '{{setMe}}' }); + + expectAssertion(function () { + _this3.render('{{bottom-mut setMe=(mut "foo bar")}}'); + }, 'You can only pass a path to mut'); + }; + + _class.prototype['@test passing the result of a helper invocation results in an assertion'] = function testPassingTheResultOfAHelperInvocationResultsInAnAssertion() { + var _this4 = this; + + this.registerComponent('bottom-mut', { template: '{{setMe}}' }); + + expectAssertion(function () { + _this4.render('{{bottom-mut setMe=(mut (concat "foo" " " "bar"))}}'); + }, 'You can only pass a path to mut'); + }; + + // See https://github.com/emberjs/ember.js/commit/807a0cd for an explanation of this test + + _class.prototype['@test using a string value through middle tier does not trigger assertion (due to the auto-mut transform)'] = function testUsingAStringValueThroughMiddleTierDoesNotTriggerAssertionDueToTheAutoMutTransform() { + var bottom = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{stuff}}' + }); + + this.registerComponent('middle-mut', { + template: '{{bottom-mut stuff=value}}' + }); + + this.render('{{middle-mut value="foo"}}'); + + this.assert.equal(_emberMetal.get(bottom, 'stuff'), 'foo', 'the data propagated'); + this.assertText('foo'); + + this.assertStableRerender(); + + // No U-R for this test + }; + + _class.prototype['@test {{readonly}} of a {{mut}} is converted into an immutable binding'] = function testReadonlyOfAMutIsConvertedIntoAnImmutableBinding() { + var _this5 = this; + + var middle = undefined, + bottom = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + middle = this; + } + }), + template: '{{bottom-mut setMe=(readonly value)}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return middle.attrs.value.update(13); + }); + + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 13, 'the set took effect on middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 13, 'the set took effect on middle\'s attr'); + + this.runTask(function () { + return _emberMetal.set(middle, 'value', 14); + }); + + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 14, 'the set took effect on middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 14, 'the set took effect on middle\'s attr'); + this.assert.strictEqual(bottom.attrs.setMe, 14, 'the mutable binding has been converted to an immutable cell'); + this.assertText('14'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test mutable bindings work inside of yielded content'] = function testMutableBindingsWorkInsideOfYieldedContent() { + var _this6 = this; + + this.registerComponent('bottom-mut', { + template: '{{yield}}' + }); + + this.registerComponent('middle-mut', { + template: '{{#bottom-mut}}{{model.name}}{{/bottom-mut}}' + }); + + this.render('{{middle-mut model=(mut model)}}', { + model: { name: 'Matthew Beale' } + }); + + this.assertText('Matthew Beale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'model.name', 'Joel Kang'); + }); + + this.assertText('Joel Kang'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'model', { name: 'Matthew Beale' }); + }); + + this.assertText('Matthew Beale'); + }; + + _class.prototype['@test a simple mutable binding using {{mut}} is available in hooks'] = function testASimpleMutableBindingUsingMutIsAvailableInHooks() { + var _this7 = this; + + var bottom = undefined; + var willRender = []; + var didInsert = []; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willRender: function () { + willRender.push(_emberMetal.get(this, 'setMe')); + }, + didInsertElement: function () { + didInsert.push(_emberMetal.get(this, 'setMe')); + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + template: '{{bottom-mut setMe=(mut value)}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assert.deepEqual(willRender, [12], 'willReceive is [12]'); + this.assert.deepEqual(didInsert, [12], 'didInsert is [12]'); + this.assertText('12'); + + this.assertStableRerender(); + + this.assert.deepEqual(willRender, [12], 'willReceive is [12]'); + this.assert.deepEqual(didInsert, [12], 'didInsert is [12]'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 12, 'the data propagated'); + + this.runTask(function () { + return bottom.attrs.setMe.update(13); + }); + + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 13, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 13, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'setMe', 14); + }); + + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 14, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test a mutable binding with a backing computed property and attribute present in the root of the component is updated when the upstream property invalidates #11023'] = function testAMutableBindingWithABackingComputedPropertyAndAttributePresentInTheRootOfTheComponentIsUpdatedWhenTheUpstreamPropertyInvalidates11023() { + var bottom = undefined, + middle = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + thingy: null, + didInsertElement: function () { + bottom = this; + } + }), + template: '{{thingy}}' + }); + + this.registerComponent('middle-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + baseValue: 12, + val: _emberMetal.computed('baseValue', function () { + return this.get('baseValue'); + }), + didInsertElement: function () { + middle = this; + } + }), + template: '{{bottom-mut thingy=(mut val)}}' + }); + + this.render('{{middle-mut}}'); + + this.assert.strictEqual(_emberMetal.get(bottom, 'thingy'), 12, 'data propagated'); + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(middle, 'baseValue', 13); + }); + + this.assert.strictEqual(_emberMetal.get(middle, 'val'), 13, 'the set took effect'); + this.assert.strictEqual(bottom.attrs.thingy.value, 13, 'the set propagated down to bottom\'s attrs'); + this.assert.strictEqual(_emberMetal.get(bottom, 'thingy'), 13, 'the set propagated down to bottom\'s prop'); + this.assertText('13'); + + this.runTask(function () { + return _emberMetal.set(middle, 'baseValue', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test automatic mutable bindings exposes a mut cell in attrs'] = function testAutomaticMutableBindingsExposesAMutCellInAttrs() { + var inner = undefined; + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + inner = this; + } + }), + template: '{{foo}}' + }); + + this.registerComponent('x-outer', { + template: '{{x-inner foo=bar}}' + }); + + this.render('{{x-outer bar=baz}}', { baz: 'foo' }); + + this.assertText('foo'); + + this.assertStableRerender(); + + this.runTask(function () { + return inner.attrs.foo.update('bar'); + }); + + this.assert.equal(inner.attrs.foo.value, 'bar'); + this.assert.equal(_emberMetal.get(inner, 'foo'), 'bar'); + this.assertText('bar'); + + this.runTask(function () { + return inner.attrs.foo.update('foo'); + }); + + this.assertText('foo'); + }; + + _class.prototype['@test automatic mutable bindings tolerate undefined non-stream inputs and attempts to set them'] = function testAutomaticMutableBindingsTolerateUndefinedNonStreamInputsAndAttemptsToSetThem() { + var inner = undefined; + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + inner = this; + } + }), + template: '{{model}}' + }); + + this.registerComponent('x-outer', { + template: '{{x-inner model=nonexistent}}' + }); + + this.render('{{x-outer}}'); + + this.assertText(''); + + this.assertStableRerender(); + + this.runTask(function () { + return inner.attrs.model.update(42); + }); + + this.assert.equal(inner.attrs.model.value, 42); + this.assert.equal(_emberMetal.get(inner, 'model'), 42); + this.assertText('42'); + + this.runTask(function () { + return inner.attrs.model.update(undefined); + }); + + this.assertText(''); + }; + + _class.prototype['@test automatic mutable bindings tolerate constant non-stream inputs and attempts to set them'] = function testAutomaticMutableBindingsTolerateConstantNonStreamInputsAndAttemptsToSetThem() { + var inner = undefined; + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + inner = this; + } + }), + template: 'hello{{model}}' + }); + + this.registerComponent('x-outer', { + template: '{{x-inner model=x}}' + }); + + this.render('{{x-outer x="foo"}}'); + + this.assertText('hellofoo'); + + this.assertStableRerender(); + + this.runTask(function () { + return inner.attrs.model.update(42); + }); + + this.assert.equal(inner.attrs.model.value, 42); + this.assert.equal(_emberMetal.get(inner, 'model'), 42); + this.assertText('hello42'); + + this.runTask(function () { + return inner.attrs.model.update('foo'); + }); + + this.assertText('hellofoo'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Mutable Bindings used in Computed Properties that are bound as attributeBindings', (function (_RenderingTest2) { + babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test an attribute binding of a computed property of a 2-way bound attr recomputes when the attr changes'] = function testAnAttributeBindingOfAComputedPropertyOfA2WayBoundAttrRecomputesWhenTheAttrChanges() { + var _this8 = this; + + var input = undefined, + output = undefined; + + this.registerComponent('x-input', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + input = this; + } + }) + }); + + this.registerComponent('x-output', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + didInsertElement: function () { + output = this; + }, + style: _emberMetal.computed('height', function () { + var height = this.get('height'); + return 'height: ' + height + 'px;'; + }), + height: 20 + }), + template: '{{height}}' + }); + + this.render('{{x-output height=height}}{{x-input height=(mut height)}}', { + height: 60 + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 60px;') }, content: '60' }); + + this.assertStableRerender(); + + this.runTask(function () { + return input.attrs.height.update(35); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'height'), 35, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'height'), 35, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 35px;') }, content: '35' }); + + this.runTask(function () { + return _emberMetal.set(input, 'height', 36); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'height'), 36, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'height'), 36, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 36px;') }, content: '36' }); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'height', 60); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 60px;') }, content: '60' }); + this.assert.strictEqual(_emberMetal.get(input, 'height'), 60); + }; + + _class2.prototype['@test an attribute binding of a computed property with a setter of a 2-way bound attr recomputes when the attr changes'] = function testAnAttributeBindingOfAComputedPropertyWithASetterOfA2WayBoundAttrRecomputesWhenTheAttrChanges() { + var _this9 = this; + + var input = undefined, + output = undefined; + + this.registerComponent('x-input', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + input = this; + } + }) + }); + + this.registerComponent('x-output', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + didInsertElement: function () { + output = this; + }, + style: _emberMetal.computed('height', 'width', function () { + var height = this.get('height'); + var width = this.get('width'); + return 'height: ' + height + 'px; width: ' + width + 'px;'; + }), + height: 20, + width: _emberMetal.computed('height', { + get: function () { + return this.get('height') * 2; + }, + set: function (keyName, width) { + this.set('height', width / 2); + return width; + } + }) + }), + template: '{{width}}x{{height}}' + }); + + this.render('{{x-output width=width}}{{x-input width=(mut width)}}', { + width: 70 + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 35px; width: 70px;') }, content: '70x35' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(input, 'width', 80); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'width'), 80, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'width'), 80, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 40px; width: 80px;') }, content: '80x40' }); + + this.runTask(function () { + return input.attrs.width.update(90); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'width'), 90, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'width'), 90, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 45px; width: 90px;') }, content: '90x45' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'width', 70); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 35px; width: 70px;') }, content: '70x35' }); + this.assert.strictEqual(_emberMetal.get(input, 'width'), 70); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/mut-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/mut-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/mut-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/partial-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each model.items as |template i|}}\n {{model.type}}: {{partial template}}\n {{/each}}'], ['\n {{#each model.items as |template i|}}\n {{model.type}}: {{partial template}}\n {{/each}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with item.thing as |t|}}\n {{partial t}}\n {{else}}\n Nothing!\n {{/with}}'], ['\n {{#with item.thing as |t|}}\n {{partial t}}\n {{else}}\n Nothing!\n {{/with}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{partial}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should render other templates registered with the container'] = function testShouldRenderOtherTemplatesRegisteredWithTheContainer() { + this.registerPartial('_subTemplateFromContainer', 'sub-template'); + + this.render('This {{partial "subTemplateFromContainer"}} is pretty great.'); + + this.assertStableRerender(); + + this.assertText('This sub-template is pretty great.'); + }; + + _class.prototype['@test should render other slash-separated templates registered with the container'] = function testShouldRenderOtherSlashSeparatedTemplatesRegisteredWithTheContainer() { + this.registerPartial('child/_subTemplateFromContainer', 'sub-template'); + + this.render('This {{partial "child/subTemplateFromContainer"}} is pretty great.'); + + this.assertStableRerender(); + + this.assertText('This sub-template is pretty great.'); + }; + + _class.prototype['@test should use the current context'] = function testShouldUseTheCurrentContext() { + var _this = this; + + this.registerPartial('_person_name', '{{model.firstName}} {{model.lastName}}'); + + this.render('Who is {{partial "person_name"}}?', { + model: { + firstName: 'Kris', + lastName: 'Selden' + } + }); + + this.assertStableRerender(); + + this.assertText('Who is Kris Selden?'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.firstName', 'Kelly'); + }); + + this.assertText('Who is Kelly Selden?'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model', { firstName: 'Kris', lastName: 'Selden' }); + }); + + this.assertText('Who is Kris Selden?'); + }; + + _class.prototype['@test Quoteless parameters passed to {{partial}} perform a bound property lookup of the partial name'] = function testQuotelessParametersPassedToPartialPerformABoundPropertyLookupOfThePartialName() { + var _this2 = this; + + this.registerPartial('_subTemplate', 'sub-template'); + this.registerPartial('_otherTemplate', 'other-template'); + + this.render('This {{partial templates.partialName}} is pretty {{partial nonexistent}}great.', { + templates: { partialName: 'subTemplate' } + }); + + this.assertStableRerender(); + + this.assertText('This sub-template is pretty great.'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'templates.partialName', 'otherTemplate'); + }); + + this.assertText('This other-template is pretty great.'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'templates.partialName', null); + }); + + this.assertText('This is pretty great.'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'templates', { partialName: 'subTemplate' }); + }); + + this.assertText('This sub-template is pretty great.'); + }; + + _class.prototype['@test dynamic partials in {{#each}}'] = function testDynamicPartialsInEach() { + var _this3 = this; + + this.registerPartial('_odd', 'ODD{{i}}'); + this.registerPartial('_even', 'EVEN{{i}}'); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + model: { + items: ['even', 'odd', 'even', 'odd'], + type: 'number' + } + }); + + this.assertStableRerender(); + + this.assertText('number: EVEN0number: ODD1number: EVEN2number: ODD3'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.type', 'integer'); + }); + + this.assertText('integer: EVEN0integer: ODD1integer: EVEN2integer: ODD3'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { + items: ['even', 'odd', 'even', 'odd'], + type: 'number' + }); + }); + + this.assertText('number: EVEN0number: ODD1number: EVEN2number: ODD3'); + }; + + _class.prototype['@test dynamic partials in {{#with}}'] = function testDynamicPartialsInWith() { + var _this4 = this; + + this.registerPartial('_thing', '{{t}}'); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + item: { thing: false } + }); + + this.assertStableRerender(); + + this.assertText('Nothing!'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'item.thing', 'thing'); + }); + + this.assertText('thing'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'item', { thing: false }); + }); + + this.assertText('Nothing!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/partial-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/partial-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/partial-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/readonly-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{readonly}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test {{readonly}} of a path should work'] = function testReadonlyOfAPathShouldWork() { + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + component = this; + } + }), + template: '{{value}}' + }); + + this.render('{{foo-bar value=(readonly val)}}', { + val: 12 + }); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(component, 'value', 13); + }); + this.assert.notOk(component.attrs.value.update); + + this.assertText('13', 'local property is updated'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'upstream attribute is not updated'); + + // No U-R + }; + + _class.prototype['@test {{readonly}} of a string renders correctly'] = function testReadonlyOfAStringRendersCorrectly() { + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + component = this; + } + }), + template: '{{value}}' + }); + + this.render('{{foo-bar value=(readonly "12")}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.assert.notOk(component.attrs.value.update); + this.assert.strictEqual(_emberMetal.get(component, 'value'), '12'); + + this.runTask(function () { + return _emberMetal.set(component, 'value', '13'); + }); + + this.assertText('13', 'local property is updated'); + this.assert.strictEqual(_emberMetal.get(component, 'value'), '13'); + + this.runTask(function () { + return _emberMetal.set(component, 'value', '12'); + }); + + this.assertText('12'); + }; + + _class.prototype['@test {{mut}} of a {{readonly}} mutates only the middle and bottom tiers'] = function testMutOfAReadonlyMutatesOnlyTheMiddleAndBottomTiers() { + var _this = this; + + var middle = undefined, + bottom = undefined; + + this.registerComponent('x-bottom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{bar}}' + }); + + this.registerComponent('x-middle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + middle = this; + } + }), + template: '{{foo}} {{x-bottom bar=(mut foo)}}' + }); + + this.render('{{x-middle foo=(readonly val)}}', { + val: 12 + }); + + this.assertText('12 12'); + + this.assertStableRerender(); + + this.assert.equal(_emberMetal.get(bottom, 'bar'), 12, 'bottom\'s local bar received the value'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 12, 'middle\'s local foo received the value'); + + this.runTask(function () { + return bottom.attrs.bar.update(13); + }); + + this.assert.equal(_emberMetal.get(bottom, 'bar'), 13, 'bottom\'s local bar was updated after set of bottom\'s bar'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 13, 'middle\'s local foo was updated after set of bottom\'s bar'); + this.assertText('13 13'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'But context val is not updated'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'bar', 14); + }); + + this.assert.equal(_emberMetal.get(bottom, 'bar'), 14, 'bottom\'s local bar was updated after set of bottom\'s bar'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 14, 'middle\'s local foo was updated after set of bottom\'s bar'); + this.assertText('14 14'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'But context val is not updated'); + + this.assert.notOk(middle.attrs.foo.update, 'middle\'s foo attr is not a mutable cell'); + this.runTask(function () { + return _emberMetal.set(middle, 'foo', 15); + }); + + this.assertText('15 15'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 15, 'set of middle\'s foo took effect'); + this.assert.equal(_emberMetal.get(bottom, 'bar'), 15, 'bottom\'s local bar was updated after set of middle\'s foo'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'Context val remains unchanged'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'val', 10); + }); + + this.assertText('10 10'); + this.assert.equal(_emberMetal.get(bottom, 'bar'), 10, 'bottom\'s local bar was updated after set of context\'s val'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 10, 'middle\'s local foo was updated after set of context\'s val'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'bar', undefined); + }); + + this.assertText(' '); + this.assert.equal(_emberMetal.get(bottom, 'bar'), undefined, 'bottom\'s local bar was updated to a falsy value'); + this.assert.equal(_emberMetal.get(middle, 'foo'), undefined, 'middle\'s local foo was updated to a falsy value'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'val', 12); + }); + this.assertText('12 12', 'bottom and middle were both reset'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/readonly-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/readonly-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/readonly-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/render-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{render}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should render given template'] = function testShouldRenderGivenTemplate() { + var _this = this; + + this.registerTemplate('home', '

BYE

'); + + expectDeprecation(function () { + _this.render('

HI

{{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test uses `controller:basic` as the basis for a generated controller when none exists for specified name'] = function testUsesControllerBasicAsTheBasisForAGeneratedControllerWhenNoneExistsForSpecifiedName() { + var _this2 = this; + + this.owner.register('controller:basic', _emberRuntime.Controller.extend({ + isBasicController: true + })); + this.registerTemplate('home', '{{isBasicController}}'); + + expectDeprecation(function () { + _this2.render('{{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('true'); + }; + + _class.prototype['@test generates a controller if none exists'] = function testGeneratesAControllerIfNoneExists() { + var _this3 = this; + + this.registerTemplate('home', '

{{this}}

'); + + expectDeprecation(function () { + _this3.render('

HI

{{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HI(generated home controller)'); + }; + + _class.prototype['@test should use controller with the same name as template if present'] = function testShouldUseControllerWithTheSameNameAsTemplateIfPresent() { + var _this4 = this; + + this.owner.register('controller:home', _emberRuntime.Controller.extend({ name: 'home' })); + this.registerTemplate('home', '{{name}}

BYE

'); + + expectDeprecation(function () { + _this4.render('

HI

{{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIhomeBYE'); + }; + + _class.prototype['@test should render nested helpers'] = function testShouldRenderNestedHelpers() { + var _this5 = this; + + this.owner.register('controller:home', _emberRuntime.Controller.extend()); + this.owner.register('controller:foo', _emberRuntime.Controller.extend()); + this.owner.register('controller:bar', _emberRuntime.Controller.extend()); + this.owner.register('controller:baz', _emberRuntime.Controller.extend()); + + this.registerTemplate('home', '

BYE

'); + this.registerTemplate('baz', '

BAZ

'); + + expectDeprecation(function () { + _this5.registerTemplate('foo', '

FOO

{{render \'bar\'}}'); + _this5.registerTemplate('bar', '

BAR

{{render \'baz\'}}'); + _this5.render('

HI

{{render \'foo\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIFOOBARBAZ'); + }; + + _class.prototype['@test should have assertion if the template does not exist'] = function testShouldHaveAssertionIfTheTemplateDoesNotExist() { + var _this6 = this; + + this.owner.register('controller:oops', _emberRuntime.Controller.extend()); + + expectDeprecation(function () { + expectAssertion(function () { + _this6.render('

HI

{{render \'oops\'}}'); + }, 'You used `{{render \'oops\'}}`, but \'oops\' can not be found as a template.'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + }; + + _class.prototype['@test should render given template with the singleton controller as its context'] = function testShouldRenderGivenTemplateWithTheSingletonControllerAsItsContext() { + var _this7 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + init: function () { + this.set('title', 'It\'s Simple Made Easy'); + } + })); + this.registerTemplate('post', '

{{title}}

'); + + expectDeprecation(function () { + _this7.render('

HI

{{render \'post\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + + var controller = this.owner.lookup('controller:post'); + + this.runTask(function () { + return _emberMetal.set(controller, 'title', 'Rails is omakase'); + }); + + this.assertText('HIRails is omakase'); + + this.runTask(function () { + return _emberMetal.set(controller, 'title', 'It\'s Simple Made Easy'); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + }; + + _class.prototype['@test should not destroy the singleton controller on teardown'] = function testShouldNotDestroyTheSingletonControllerOnTeardown(assert) { + var _this8 = this; + + var willDestroyFired = 0; + + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + init: function () { + this.set('title', 'It\'s Simple Made Easy'); + }, + + willDestroy: function () { + this._super.apply(this, arguments); + willDestroyFired++; + } + })); + + this.registerTemplate('post', '

{{title}}

'); + + expectDeprecation(function () { + _this8.render('{{#if showPost}}{{render \'post\'}}{{else}}Nothing here{{/if}}', { showPost: false }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'showPost', true); + }); + + this.assertText('It\'s Simple Made Easy'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'showPost', false); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + }; + + _class.prototype['@test should render given template with a supplied model'] = function testShouldRenderGivenTemplateWithASuppliedModel() { + var _this9 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + this.registerTemplate('post', '

{{model.title}}

'); + + expectDeprecation(function () { + _this9.render('

HI

{{render \'post\' post}}', { + post: { + title: 'It\'s Simple Made Easy' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'post.title', 'Rails is omakase'); + }); + + this.assertText('HIRails is omakase'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'post', { title: 'It\'s Simple Made Easy' }); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + }; + + _class.prototype['@test should destroy the non-singleton controllers on teardown'] = function testShouldDestroyTheNonSingletonControllersOnTeardown(assert) { + var _this10 = this; + + var willDestroyFired = 0; + + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + willDestroy: function () { + this._super.apply(this, arguments); + willDestroyFired++; + } + })); + + this.registerTemplate('post', '

{{model.title}}

'); + + expectDeprecation(function () { + _this10.render('{{#if showPost}}{{render \'post\' post}}{{else}}Nothing here{{/if}}', { + showPost: false, + post: { + title: 'It\'s Simple Made Easy' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', true); + }); + + this.assertText('It\'s Simple Made Easy'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', false); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 1, 'it did destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', true); + }); + + this.assertText('It\'s Simple Made Easy'); + + assert.strictEqual(willDestroyFired, 1, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', false); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 2, 'it did destroy the controller'); + }; + + _class.prototype['@test with a supplied model should not fire observers on the controller'] = function testWithASuppliedModelShouldNotFireObserversOnTheController() { + var _this11 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + this.registerTemplate('post', '

{{model.title}}

'); + + var postDidChange = 0; + expectDeprecation(function () { + _this11.render('

HI

{{render \'post\' post}}', { + postDidChange: _emberMetal.observer('post', function () { + postDidChange++; + }), + post: { + title: 'It\'s Simple Made Easy' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + }; + + _class.prototype['@test should raise an error when a given controller name does not resolve to a controller'] = function testShouldRaiseAnErrorWhenAGivenControllerNameDoesNotResolveToAController() { + var _this12 = this; + + this.registerTemplate('home', '

BYE

'); + this.owner.register('controller:posts', _emberRuntime.Controller.extend()); + + expectDeprecation(function () { + expectAssertion(function () { + _this12.render('

HI

{{render "home" controller="postss"}}'); + }, /The controller name you supplied \'postss\' did not resolve to a controller./); + }, /Please refactor [\w\{\}"` ]+ to a component/); + }; + + _class.prototype['@test should render with given controller'] = function testShouldRenderWithGivenController(assert) { + var _this13 = this; + + this.registerTemplate('home', '{{uniqueId}}'); + + var id = 0; + var model = {}; + + this.owner.register('controller:posts', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + this.uniqueId = id++; + this.set('model', model); + } + })); + + expectDeprecation(function () { + _this13.render('{{render "home" controller="posts"}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + var renderedController = this.owner.lookup('controller:posts'); + var uniqueId = renderedController.get('uniqueId'); + var renderedModel = renderedController.get('model'); + + assert.equal(uniqueId, 0); + assert.equal(renderedModel, model); + this.assertText('0'); + + this.runTask(function () { + return _this13.rerender(); + }); + + assert.equal(uniqueId, 0); + assert.equal(renderedModel, model); + this.assertText('0'); + }; + + _class.prototype['@test should render templates with models multiple times'] = function testShouldRenderTemplatesWithModelsMultipleTimes(assert) { + var _this14 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + + this.registerTemplate('post', '

{{model.title}}

'); + expectDeprecation(function () { + _this14.render('

HI

{{render \'post\' post1}} {{render \'post\' post2}}', { + post1: { + title: 'Me First' + }, + post2: { + title: 'Then me' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HI Me First Then me'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('HI Me First Then me'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'post1.title', 'I am new'); + }); + + this.assertText('HI I am new Then me'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'post1', { title: 'Me First' }); + }); + + this.assertText('HI Me First Then me'); + }; + + _class.prototype['@test should not treat invocations with falsy contexts as context-less'] = function testShouldNotTreatInvocationsWithFalsyContextsAsContextLess(assert) { + var _this15 = this; + + this.registerTemplate('post', '

{{#unless model.zero}}NOTHING{{/unless}}

'); + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + + expectDeprecation(function () { + _this15.render('

HI

{{render \'post\' zero}} {{render \'post\' nonexistent}}', { + model: { + zero: false + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + assert.ok(this.$().text().match(/^HI ?NOTHING ?NOTHING$/)); + }; + + _class.prototype['@test should render templates both with and without models'] = function testShouldRenderTemplatesBothWithAndWithoutModels(assert) { + var _this16 = this; + + this.registerTemplate('post', '

Title:{{model.title}}

'); + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + + var post = { + title: 'Rails is omakase' + }; + expectDeprecation(function () { + _this16.render('

HI

{{render \'post\'}} {{render \'post\' post}}', { + post: post + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/)); + + this.runTask(function () { + return _this16.rerender(); + }); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/)); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'post.title', 'Simple Made Easy'); + }); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Simple Made Easy$/)); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'post', { title: 'Rails is omakase' }); + }); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/)); + }; + + _class.prototype['@test works with dot notation'] = function testWorksWithDotNotation() { + var _this17 = this; + + this.registerTemplate('blog.post', '{{uniqueId}}'); + + var id = 0; + this.owner.register('controller:blog.post', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + this.uniqueId = id++; + } + })); + + expectDeprecation(function () { + _this17.render('{{render "blog.post"}}'); + }, /Please refactor [\w\.{\}"` ]+ to a component/); + + this.assertText('0'); + }; + + _class.prototype['@test throws an assertion if called with an unquoted template name'] = function testThrowsAnAssertionIfCalledWithAnUnquotedTemplateName() { + var _this18 = this; + + this.registerTemplate('home', '

BYE

'); + + expectAssertion(function () { + _this18.render('

HI

{{render home}}'); + }, 'The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.'); + }; + + _class.prototype['@test throws an assertion if called with a literal for a model'] = function testThrowsAnAssertionIfCalledWithALiteralForAModel() { + var _this19 = this; + + this.registerTemplate('home', '

BYE

'); + expectAssertion(function () { + _this19.render('

HI

{{render "home" "model"}}', { + model: { + title: 'Simple Made Easy' + } + }); + }, 'The second argument of {{render}} must be a path, e.g. {{render "post" post}}.'); + }; + + _class.prototype['@test should set router as target when action not found on parentController is not found'] = function testShouldSetRouterAsTargetWhenActionNotFoundOnParentControllerIsNotFound(assert) { + var _this20 = this; + + var postController = undefined; + this.registerTemplate('post', 'post template'); + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + postController = this; + } + })); + + var routerStub = { + send: function (actionName) { + assert.equal(actionName, 'someAction'); + assert.ok(true, 'routerStub#send called'); + } + }; + + this.owner.register('router:main', routerStub, { instantiate: false }); + + expectDeprecation(function () { + _this20.render('{{render \'post\' post1}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + postController.send('someAction'); + }; + + _class.prototype['@test render helper emits useful backtracking re-render assertion message'] = function testRenderHelperEmitsUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this21 = this; + + this.owner.register('controller:outer', _emberRuntime.Controller.extend()); + this.owner.register('controller:inner', _emberRuntime.Controller.extend({ + propertyWithError: _emberMetal.computed(function () { + this.set('model.name', 'this will cause a backtracking error'); + return 'foo'; + }) + })); + + var expectedBacktrackingMessage = /modified "model\.name" twice on \[object Object\] in a single render\. It was rendered in "controller:outer \(with the render helper\)" and modified in "controller:inner \(with the render helper\)"/; + + expectDeprecation(function () { + var person = { name: 'Ben' }; + + _this21.registerTemplate('outer', 'Hi {{model.name}} | {{render \'inner\' model}}'); + _this21.registerTemplate('inner', 'Hi {{propertyWithError}}'); + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + _this21.render('{{render \'outer\' person}}', { person: person }); + } else { + expectAssertion(function () { + _this21.render('{{render \'outer\' person}}', { person: person }); + }, expectedBacktrackingMessage); + } + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/render-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/render-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/render-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/text-area-test', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberUtils, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var TextAreaRenderingTest = (function (_RenderingTest) { + babelHelpers.inherits(TextAreaRenderingTest, _RenderingTest); + + function TextAreaRenderingTest() { + babelHelpers.classCallCheck(this, TextAreaRenderingTest); + + _RenderingTest.call(this); + + this.registerComponent('-text-area', { ComponentClass: _emberGlimmerTestsUtilsHelpers.TextArea }); + } + + TextAreaRenderingTest.prototype.assertTextArea = function assertTextArea() { + var _ref2 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + var attrs = _ref2.attrs; + var value = _ref2.value; + + var mergedAttrs = _emberUtils.assign({ 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view ember-text-area') }, attrs); + this.assertComponentElement(this.firstChild, { tagName: 'textarea', attrs: mergedAttrs }); + + if (value) { + this.assert.strictEqual(value, this.firstChild.value); + } + }; + + TextAreaRenderingTest.prototype.triggerEvent = function triggerEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var event = document.createEvent('Events'); + event.initEvent(type, true, true); + _emberUtils.assign(event, options); + + this.firstChild.dispatchEvent(event); + }; + + return TextAreaRenderingTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var BoundTextAreaAttributes = (function () { + function BoundTextAreaAttributes(cases) { + babelHelpers.classCallCheck(this, BoundTextAreaAttributes); + + this.cases = cases; + } + + BoundTextAreaAttributes.prototype.generate = function generate(_ref3) { + var _ref; + + var attribute = _ref3.attribute; + var first = _ref3.first; + var second = _ref3.second; + + return _ref = {}, _ref['@test ' + attribute] = function (assert) { + var _attrs, + _attrs2, + _attrs3, + _this = this; + + this.render('{{textarea ' + attribute + '=value}}', { + value: first + }); + this.assertTextArea({ attrs: (_attrs = {}, _attrs[attribute] = first, _attrs) }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'value', second); + }); + this.assertTextArea({ attrs: (_attrs2 = {}, _attrs2[attribute] = second, _attrs2) }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'value', first); + }); + this.assertTextArea({ attrs: (_attrs3 = {}, _attrs3[attribute] = first, _attrs3) }); + }, _ref; + }; + + return BoundTextAreaAttributes; + })(); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(TextAreaRenderingTest, new BoundTextAreaAttributes([{ attribute: 'placeholder', first: 'Stuff here', second: 'Other stuff' }, { attribute: 'name', first: 'Stuff here', second: 'Other stuff' }, { attribute: 'title', first: 'Stuff here', second: 'Other stuff' }, { attribute: 'maxlength', first: '1', second: '2' }, { attribute: 'rows', first: '1', second: '2' }, { attribute: 'cols', first: '1', second: '2' }, { attribute: 'tabindex', first: '1', second: '2' }])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{textarea}}', (function (_TextAreaRenderingTest) { + babelHelpers.inherits(_class, _TextAreaRenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _TextAreaRenderingTest.apply(this, arguments); + } + + _class.prototype['@test Should insert a textarea'] = function testShouldInsertATextarea() { + this.render('{{textarea}}'); + + equal(this.$('textarea').length, 1); + + this.assertStableRerender(); + }; + + _class.prototype['@test Should respect disabled'] = function testShouldRespectDisabled() { + this.render('{{textarea disabled=disabled}}', { + disabled: true + }); + ok(this.$('textarea').is(':disabled')); + }; + + _class.prototype['@test Should respect disabled when false'] = function testShouldRespectDisabledWhenFalse() { + this.render('{{textarea disabled=disabled}}', { + disabled: false + }); + ok(this.$('textarea').is(':not(:disabled)')); + }; + + _class.prototype['@test Should become disabled when the context changes'] = function testShouldBecomeDisabledWhenTheContextChanges() { + var _this2 = this; + + this.render('{{textarea disabled=disabled}}'); + ok(this.$('textarea').is(':not(:disabled)')); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'disabled', true); + }); + ok(this.$('textarea').is(':disabled')); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'disabled', false); + }); + ok(this.$('textarea').is(':not(:disabled)')); + }; + + _class.prototype['@test Should bind its contents to the specified value'] = function testShouldBindItsContentsToTheSpecifiedValue() { + var _this3 = this; + + this.render('{{textarea value=model.val}}', { + model: { val: 'A beautiful day in Seattle' } + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.val', 'Auckland'); + }); + this.assertTextArea({ value: 'Auckland' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { val: 'A beautiful day in Seattle' }); + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + }; + + _class.prototype['@test GH#14001 Should correctly handle an empty string bound value'] = function testGH14001ShouldCorrectlyHandleAnEmptyStringBoundValue() { + var _this4 = this; + + this.render('{{textarea value=message}}', { message: '' }); + + this.assert.strictEqual(this.firstChild.value, ''); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', 'hello'); + }); + + this.assert.strictEqual(this.firstChild.value, 'hello'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', ''); + }); + + this.assert.strictEqual(this.firstChild.value, ''); + }; + + _class.prototype['@test should update the value for `cut` / `input` / `change` events'] = function testShouldUpdateTheValueForCutInputChangeEvents() { + var _this5 = this; + + this.render('{{textarea value=model.val}}', { + model: { val: 'A beautiful day in Seattle' } + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + + this.assertStableRerender(); + + this.runTask(function () { + _this5.firstChild.value = 'Auckland'; + _this5.triggerEvent('cut'); + }); + this.assertTextArea({ value: 'Auckland' }); + + this.runTask(function () { + _this5.firstChild.value = 'Hope'; + _this5.triggerEvent('paste'); + }); + this.assertTextArea({ value: 'Hope' }); + + this.runTask(function () { + _this5.firstChild.value = 'Boston'; + _this5.triggerEvent('input'); + }); + this.assertTextArea({ value: 'Boston' }); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model', { val: 'A beautiful day in Seattle' }); + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + }; + + return _class; + })(TextAreaRenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/text-area-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/text-area-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/text-area-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/unbound-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-runtime'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberRuntime) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n \n '], ['\n \n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{unbound (surround model.prefix model.value "bar")}} {{surround model.prefix model.value "bar"}} {{unbound (surround "bar" model.value model.suffix)}} {{surround "bar" model.value model.suffix}}'], ['\n {{unbound (surround model.prefix model.value "bar")}} {{surround model.prefix model.value "bar"}} {{unbound (surround "bar" model.value model.suffix)}} {{surround "bar" model.value model.suffix}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (unbound model.foo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/if}}\n {{#unless (unbound model.notfoo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/unless}}'], ['\n {{#if (unbound model.foo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/if}}\n {{#unless (unbound model.notfoo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/unless}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{unbound}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should be able to output a property without binding'] = function testShouldBeAbleToOutputAPropertyWithoutBinding() { + var _this = this; + + this.render('
{{unbound content.anUnboundString}}
', { + content: { + anUnboundString: 'No spans here, son.' + } + }); + + this.assertText('No spans here, son.'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('No spans here, son.'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'content.anUnboundString', 'HEY'); + }); + + this.assertText('No spans here, son.'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'content', { + anUnboundString: 'No spans here, son.' + }); + }); + + this.assertText('No spans here, son.'); + }; + + _class.prototype['@test should be able to use unbound helper in #each helper'] = function testShouldBeAbleToUseUnboundHelperInEachHelper() { + var _this2 = this; + + this.render('
    {{#each items as |item|}}
  • {{unbound item}}
  • {{/each}}
', { + items: _emberRuntime.A(['a', 'b', 'c', 1, 2, 3]) + }); + + this.assertText('abc123'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('abc123'); + }; + + _class.prototype['@test should be able to use unbound helper in #each helper (with objects)'] = function testShouldBeAbleToUseUnboundHelperInEachHelperWithObjects() { + var _this3 = this; + + this.render('
    {{#each items as |item|}}
  • {{unbound item.wham}}
  • {{/each}}
', { + items: _emberRuntime.A([{ wham: 'bam' }, { wham: 1 }]) + }); + + this.assertText('bam1'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('bam1'); + + this.runTask(function () { + return _this3.context.items.setEach('wham', 'HEY'); + }); + + this.assertText('bam1'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'items', _emberRuntime.A([{ wham: 'bam' }, { wham: 1 }])); + }); + + this.assertText('bam1'); + }; + + _class.prototype['@test it should assert unbound cannot be called with multiple arguments'] = function testItShouldAssertUnboundCannotBeCalledWithMultipleArguments() { + var _this4 = this; + + var willThrow = function () { + _this4.render('{{unbound foo bar}}', { + foo: 'BORK', + bar: 'BLOOP' + }); + }; + + expectAssertion(willThrow, /unbound helper cannot be called with multiple params or hash params/); + }; + + _class.prototype['@test should render on attributes'] = function testShouldRenderOnAttributes() { + var _this5 = this; + + this.render('', { + model: { foo: 'BORK' } + }); + + this.assertHTML(''); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertHTML(''); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model.foo', 'OOF'); + }); + + this.assertHTML(''); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model', { foo: 'BORK' }); + }); + + this.assertHTML(''); + }; + + _class.prototype['@test should property escape unsafe hrefs'] = function testShouldPropertyEscapeUnsafeHrefs() { + var _this6 = this; + + var unsafeUrls = _emberRuntime.A([{ + name: 'Bob', + url: 'javascript:bob-is-cool' // jshint ignore:line + }, { + name: 'James', + url: 'vbscript:james-is-cool' // jshint ignore:line + }, { + name: 'Richard', + url: 'javascript:richard-is-cool' // jshint ignore:line + }]); + + this.render('', { + people: unsafeUrls + }); + + var escapedHtml = _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject); + + this.assertHTML(escapedHtml); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertHTML(escapedHtml); + + this.runTask(function () { + return _this6.context.people.setEach('url', 'http://google.com'); + }); + + this.assertHTML(escapedHtml); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'people', unsafeUrls); + }); + + this.assertHTML(escapedHtml); + }; + + _class.prototype['@skip helper form updates on parent re-render'] = function skipHelperFormUpdatesOnParentReRender() { + var _this7 = this; + + this.render('{{unbound foo}}', { + foo: 'BORK' + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', 'OOF'); + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('OOF'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', ''); + }); + + this.assertText('OOF'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', 'BORK'); + }); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('BORK'); + }; + + // semantics here is not guaranteed + + _class.prototype['@test sexpr form does not update no matter what'] = function testSexprFormDoesNotUpdateNoMatterWhat() { + var _this8 = this; + + this.registerHelper('capitalize', function (args) { + return args[0].toUpperCase(); + }); + + this.render('{{capitalize (unbound foo)}}', { + foo: 'bork' + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('BORK'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'foo', 'oof'); + _this8.rerender(); + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'foo', 'blip'); + }); + + this.assertText('BORK'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'foo', 'bork'); + _this8.rerender(); + }); + + this.assertText('BORK'); + }; + + _class.prototype['@test sexpr in helper form does not update on parent re-render'] = function testSexprInHelperFormDoesNotUpdateOnParentReRender() { + var _this9 = this; + + this.registerHelper('capitalize', function (params) { + return params[0].toUpperCase(); + }); + + this.registerHelper('doublize', function (params) { + return params[0] + ' ' + params[0]; + }); + + this.render('{{capitalize (unbound (doublize foo))}}', { + foo: 'bork' + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'foo', 'oof'); + _this9.rerender(); + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'foo', 'blip'); + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'foo', 'bork'); + _this9.rerender(); + }); + + this.assertText('BORK BORK'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation'] = function testShouldBeAbleToRenderAnUnboundHelperInvocation() { + var _this10 = this; + + this.registerHelper('repeat', function (_ref, _ref2) { + var value = _ref[0]; + var count = _ref2.count; + + var a = []; + while (a.length < count) { + a.push(value); + } + return a.join(''); + }); + + this.render('{{unbound (repeat foo count=bar)}} {{repeat foo count=bar}} {{unbound (repeat foo count=2)}} {{repeat foo count=4}}', { + foo: 'X', + bar: 5 + }); + + this.assertText('XXXXX XXXXX XX XXXX'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('XXXXX XXXXX XX XXXX'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'bar', 1); + }); + + this.assertText('XXXXX X XX XXXX'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'bar', 5); + }); + + this.assertText('XXXXX XXXXX XX XXXX'); + }; + + _class.prototype['@test should be able to render an bound helper invocation mixed with static values'] = function testShouldBeAbleToRenderAnBoundHelperInvocationMixedWithStaticValues() { + var _this11 = this; + + this.registerHelper('surround', function (_ref3) { + var prefix = _ref3[0]; + var value = _ref3[1]; + var suffix = _ref3[2]; + return prefix + '-' + value + '-' + suffix; + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + model: { + prefix: 'before', + value: 'core', + suffix: 'after' + } + }); + + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); + + this.runTask(function () { + _emberMetal.setProperties(_this11.context.model, { + prefix: 'beforeChanged', + value: 'coreChanged', + suffix: 'afterChanged' + }); + }); + + this.assertText('before-core-bar beforeChanged-coreChanged-bar bar-core-after bar-coreChanged-afterChanged'); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'model', { + prefix: 'before', + value: 'core', + suffix: 'after' + }); + }); + + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); + }; + + _class.prototype['@test should be able to render unbound forms of multi-arg helpers'] = function testShouldBeAbleToRenderUnboundFormsOfMultiArgHelpers() { + var _this12 = this; + + this.registerHelper('fauxconcat', function (params) { + return params.join(''); + }); + + this.render('{{fauxconcat model.foo model.bar model.bing}} {{unbound (fauxconcat model.foo model.bar model.bing)}}', { + model: { + foo: 'a', + bar: 'b', + bing: 'c' + } + }); + + this.assertText('abc abc'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('abc abc'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model.bar', 'X'); + }); + + this.assertText('aXc abc'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model', { + foo: 'a', + bar: 'b', + bing: 'c' + }); + }); + + this.assertText('abc abc'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation for helpers with dependent keys'] = function testShouldBeAbleToRenderAnUnboundHelperInvocationForHelpersWithDependentKeys() { + var _this13 = this; + + this.registerHelper('capitalizeName', { + destroy: function () { + this.removeObserver('value.firstName'); + this._super.apply(this, arguments); + }, + + compute: function (_ref4) { + var value = _ref4[0]; + + if (this.get('value')) { + this.removeObserver('value.firstName'); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + return value ? _emberMetal.get(value, 'firstName').toUpperCase() : ''; + } + }); + + this.registerHelper('concatNames', { + destroy: function () { + this.teardown(); + this._super.apply(this, arguments); + }, + teardown: function () { + this.removeObserver('value.firstName'); + this.removeObserver('value.lastName'); + }, + compute: function (_ref5) { + var value = _ref5[0]; + + if (this.get('value')) { + this.teardown(); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + this.addObserver('value.lastName', this, this.recompute); + return (value ? _emberMetal.get(value, 'firstName') : '') + (value ? _emberMetal.get(value, 'lastName') : ''); + } + }); + + this.render('{{capitalizeName person}} {{unbound (capitalizeName person)}} {{concatNames person}} {{unbound (concatNames person)}}', { + person: { + firstName: 'shooby', + lastName: 'taylor' + } + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'person.firstName', 'sally'); + }); + + this.assertText('SALLY SHOOBY sallytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'person', { + firstName: 'shooby', + lastName: 'taylor' + }); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation in #each helper'] = function testShouldBeAbleToRenderAnUnboundHelperInvocationInEachHelper() { + var _this14 = this; + + this.registerHelper('capitalize', function (params) { + return params[0].toUpperCase(); + }); + + this.render('{{#each people as |person|}}{{capitalize person.firstName}} {{unbound (capitalize person.firstName)}}{{/each}}', { + people: _emberRuntime.A([{ + firstName: 'shooby', + lastName: 'taylor' + }, { + firstName: 'cindy', + lastName: 'taylor' + }]) + }); + + this.assertText('SHOOBY SHOOBYCINDY CINDY'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('SHOOBY SHOOBYCINDY CINDY'); + + this.runTask(function () { + return _this14.context.people.setEach('firstName', 'chad'); + }); + + this.assertText('CHAD SHOOBYCHAD CINDY'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'people', _emberRuntime.A([{ + firstName: 'shooby', + lastName: 'taylor' + }, { + firstName: 'cindy', + lastName: 'taylor' + }])); + }); + + this.assertText('SHOOBY SHOOBYCINDY CINDY'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation with bound hash options'] = function testShouldBeAbleToRenderAnUnboundHelperInvocationWithBoundHashOptions() { + var _this15 = this; + + this.registerHelper('capitalizeName', { + destroy: function () { + this.removeObserver('value.firstName'); + this._super.apply(this, arguments); + }, + + compute: function (_ref6) { + var value = _ref6[0]; + + if (this.get('value')) { + this.removeObserver('value.firstName'); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + return value ? _emberMetal.get(value, 'firstName').toUpperCase() : ''; + } + }); + + this.registerHelper('concatNames', { + destroy: function () { + this.teardown(); + this._super.apply(this, arguments); + }, + teardown: function () { + this.removeObserver('value.firstName'); + this.removeObserver('value.lastName'); + }, + compute: function (_ref7) { + var value = _ref7[0]; + + if (this.get('value')) { + this.teardown(); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + this.addObserver('value.lastName', this, this.recompute); + return (value ? _emberMetal.get(value, 'firstName') : '') + (value ? _emberMetal.get(value, 'lastName') : ''); + } + }); + + this.render('{{capitalizeName person}} {{unbound (capitalizeName person)}} {{concatNames person}} {{unbound (concatNames person)}}', { + person: { + firstName: 'shooby', + lastName: 'taylor' + } + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'person.firstName', 'sally'); + }); + + this.assertText('SALLY SHOOBY sallytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'person', { + firstName: 'shooby', + lastName: 'taylor' + }); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + }; + + _class.prototype['@test should be able to render bound form of a helper inside unbound form of same helper'] = function testShouldBeAbleToRenderBoundFormOfAHelperInsideUnboundFormOfSameHelper() { + var _this16 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3), { + model: { + foo: true, + notfoo: false, + bar: true + } + }); + + this.assertText('truetrue'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('truetrue'); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'model.bar', false); + }); + + this.assertText('falsefalse'); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'model', { + foo: true, + notfoo: false, + bar: true + }); + }); + + this.assertText('truetrue'); + }; + + _class.prototype['@test yielding unbound does not update'] = function testYieldingUnboundDoesNotUpdate() { + var _this17 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + fooBarInstance = this; + }, + model: { foo: 'bork' } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (unbound model.foo)}}' + }); + + this.render('{{#foo-bar as |value|}}{{value}}{{/foo-bar}}'); + + this.assertText('bork'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model.foo', 'oof'); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model', { foo: 'bork' }); + }); + + this.assertText('bork'); + }; + + _class.prototype['@test yielding unbound hash does not update'] = function testYieldingUnboundHashDoesNotUpdate() { + var _this18 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + fooBarInstance = this; + }, + model: { foo: 'bork' } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (unbound (hash foo=model.foo))}}' + }); + + this.render('{{#foo-bar as |value|}}{{value.foo}}{{/foo-bar}}'); + + this.assertText('bork'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model.foo', 'oof'); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model', { foo: 'bork' }); + }); + + this.assertText('bork'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/unbound-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/unbound-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/unbound-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/yield-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{yield}} helper', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test can yield to block'] = function testCanYieldToBlock() { + var _this = this; + + this.registerComponent('yield-comp', { template: '[In layout:] {{yield}}' }); + + this.render('{{#yield-comp}}[In Block:] {{object.title}}{{/yield-comp}}', { object: { title: 'Seattle' } }); + this.assertText('[In layout:] [In Block:] Seattle'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'object.title', 'Vancouver'); + }); + this.assertText('[In layout:] [In Block:] Vancouver'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'object', { title: 'Seattle' }); + }); + this.assertText('[In layout:] [In Block:] Seattle'); + }; + + _class.prototype['@test templates should yield to block inside a nested component'] = function testTemplatesShouldYieldToBlockInsideANestedComponent() { + var _this2 = this; + + this.registerComponent('outer-comp', { template: '
[In layout:] {{yield}}
' }); + this.registerComponent('inner-comp', { template: '{{#outer-comp}}[In Block:] {{object.title}}{{/outer-comp}}' }); + + this.render('{{inner-comp object=object}}', { object: { title: 'Seattle' } }); + this.assertText('[In layout:] [In Block:] Seattle'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'object.title', 'Vancouver'); + }); + this.assertText('[In layout:] [In Block:] Vancouver'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'object', { title: 'Seattle' }); + }); + this.assertText('[In layout:] [In Block:] Seattle'); + }; + + _class.prototype['@test templates should yield to block, when the yield is embedded in a each helper'] = function testTemplatesShouldYieldToBlockWhenTheYieldIsEmbeddedInAEachHelper() { + var _this3 = this; + + var list = [1, 2, 3]; + + this.registerComponent('outer-comp', { template: '{{#each list as |item|}}{{yield}}{{/each}}' }); + + this.render('{{#outer-comp list=list}}Hello{{/outer-comp}}', { list: list }); + this.assertText('HelloHelloHello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'list', [4, 5]); + }); + this.assertText('HelloHello'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'list', list); + }); + this.assertText('HelloHelloHello'); + }; + + _class.prototype['@test templates should yield to block, when the yield is embedded in a if helper'] = function testTemplatesShouldYieldToBlockWhenTheYieldIsEmbeddedInAIfHelper() { + var _this4 = this; + + this.registerComponent('outer-comp', { template: '{{#if boolean}}{{yield}}{{/if}}' }); + + this.render('{{#outer-comp boolean=boolean}}Hello{{/outer-comp}}', { boolean: true }); + this.assertText('Hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'boolean', false); + }); + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'boolean', true); + }); + this.assertText('Hello'); + }; + + _class.prototype['@test simple curlies inside of a yielded clock should work when the yield is nested inside of another view'] = function testSimpleCurliesInsideOfAYieldedClockShouldWorkWhenTheYieldIsNestedInsideOfAnotherView() { + var _this5 = this; + + this.registerComponent('kiwi-comp', { template: '{{#if falsy}}{{else}}{{yield}}{{/if}}' }); + + this.render('{{#kiwi-comp}}{{text}}{{/kiwi-comp}}', { text: 'ohai' }); + this.assertText('ohai'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'text', 'portland'); + }); + this.assertText('portland'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'text', 'ohai'); + }); + this.assertText('ohai'); + }; + + _class.prototype['@test nested simple curlies inside of a yielded block should work when the yield is nested inside of another view'] = function testNestedSimpleCurliesInsideOfAYieldedBlockShouldWorkWhenTheYieldIsNestedInsideOfAnotherView() { + var _this6 = this; + + this.registerComponent('parent-comp', { template: '{{#if falsy}}{{else}}{{yield}}{{/if}}' }); + this.registerComponent('child-comp', { template: '{{#if falsy}}{{else}}{{text}}{{/if}}' }); + + this.render('{{#parent-comp}}{{child-comp text=text}}{{/parent-comp}}', { text: 'ohai' }); + this.assertText('ohai'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'text', 'portland'); + }); + this.assertText('portland'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'text', 'ohai'); + }); + this.assertText('ohai'); + }; + + _class.prototype['@test yielding to a non-existent block is not an error'] = function testYieldingToANonExistentBlockIsNotAnError() { + var _this7 = this; + + this.registerComponent('yielding-comp', { template: 'Hello:{{yield}}' }); + this.registerComponent('outer-comp', { template: '{{yielding-comp}} {{title}}' }); + + this.render('{{outer-comp title=title}}', { title: 'Mr. Selden' }); + + this.assertText('Hello: Mr. Selden'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'title', 'Mr. Chag'); + }); + this.assertText('Hello: Mr. Chag'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'title', 'Mr. Selden'); + }); + this.assertText('Hello: Mr. Selden'); + }; + + _class.prototype['@test yield uses the original context'] = function testYieldUsesTheOriginalContext() { + var _this8 = this; + + var KiwiCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ boundText: 'Inner' }); + + this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, template: '

{{boundText}}

{{yield}}

' }); + + this.render('{{#kiwi-comp}}{{boundText}}{{/kiwi-comp}}', { boundText: 'Original' }); + this.assertText('InnerOriginal'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'boundText', 'Otherworld'); + }); + this.assertText('InnerOtherworld'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'boundText', 'Original'); + }); + this.assertText('InnerOriginal'); + }; + + _class.prototype['@test outer block param doesn\'t mask inner component property'] = function testOuterBlockParamDoesnTMaskInnerComponentProperty() { + var _this9 = this; + + var KiwiCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ boundText: 'Inner' }); + + this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, template: '

{{boundText}}

{{yield}}

' }); + + this.render('{{#with boundText as |item|}}{{#kiwi-comp}}{{item}}{{/kiwi-comp}}{{/with}}', { boundText: 'Outer' }); + this.assertText('InnerOuter'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'boundText', 'Otherworld'); + }); + this.assertText('InnerOtherworld'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'boundText', 'Outer'); + }); + this.assertText('InnerOuter'); + }; + + _class.prototype['@test inner block param doesn\'t mask yield property'] = function testInnerBlockParamDoesnTMaskYieldProperty() { + var _this10 = this; + + var KiwiCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ boundText: 'Inner' }); + + this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, template: '{{#with boundText as |item|}}

{{item}}

{{yield}}

{{/with}}' }); + + this.render('{{#kiwi-comp}}{{item}}{{/kiwi-comp}}', { item: 'Outer' }); + this.assertText('InnerOuter'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'item', 'Otherworld'); + }); + this.assertText('InnerOtherworld'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'item', 'Outer'); + }); + this.assertText('InnerOuter'); + }; + + _class.prototype['@test can bind a block param to a component and use it in yield'] = function testCanBindABlockParamToAComponentAndUseItInYield() { + var _this11 = this; + + this.registerComponent('kiwi-comp', { template: '

{{content}}

{{yield}}

' }); + + this.render('{{#with boundText as |item|}}{{#kiwi-comp content=item}}{{item}}{{/kiwi-comp}}{{/with}}', { boundText: 'Outer' }); + this.assertText('OuterOuter'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'boundText', 'Update'); + }); + this.assertText('UpdateUpdate'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'boundText', 'Outer'); + }); + this.assertText('OuterOuter'); + }; + + // INUR not need with no data update + + _class.prototype['@test yield should not introduce a view'] = function testYieldShouldNotIntroduceAView() { + var ParentCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ isParentComponent: true }); + + var ChildCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + this._super(); + var parentView = this.get('parentView'); + + ok(parentView.get('isParentComponent')); + } + }); + + this.registerComponent('parent-comp', { ComponentClass: ParentCompComponent, template: '{{yield}}' }); + this.registerComponent('child-comp', { ComponentClass: ChildCompComponent }); + + this.render('{{#parent-comp}}{{child-comp}}{{/parent-comp}}'); + }; + + _class.prototype['@test yield with nested components (#3220)'] = function testYieldWithNestedComponents3220() { + var _this12 = this; + + this.registerComponent('inner-component', { template: '{{yield}}' }); + this.registerComponent('outer-component', { template: '{{#inner-component}}{{yield}}{{/inner-component}}' }); + + this.render('{{#outer-component}}Hello {{boundText}}{{/outer-component}}', { boundText: 'world' }); + this.assertText('Hello world'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'boundText', 'update'); + }); + this.assertText('Hello update'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'boundText', 'world'); + }); + this.assertText('Hello world'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/yield-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/yield-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/yield-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/input-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Input element tests', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype.runAttributeTest = function runAttributeTest(attributeName, values) { + var _this = this; + + var template = ''; + this.render(template, { value: values[0] }); + this.assertAttributeHasValue(attributeName, values[0], attributeName + ' is set on initial render'); + + this.runTask(function () { + return _this.rerender(); + }); + this.assertAttributeHasValue(attributeName, values[0], attributeName + ' is set on noop rerender'); + + this.setComponentValue(values[1]); + this.assertAttributeHasValue(attributeName, values[1], attributeName + ' is set on rerender'); + + this.setComponentValue(values[0]); + this.assertAttributeHasValue(attributeName, values[0], attributeName + ' can be set back to the initial value'); + }; + + _class.prototype.runPropertyTest = function runPropertyTest(propertyName, values) { + var _this2 = this; + + var attributeName = propertyName; + var template = ''; + this.render(template, { value: values[0] }); + this.assertPropertyHasValue(propertyName, values[0], propertyName + ' is set on initial render'); + + this.runTask(function () { + return _this2.rerender(); + }); + this.assertPropertyHasValue(propertyName, values[0], propertyName + ' is set on noop rerender'); + + this.setComponentValue(values[1]); + this.assertPropertyHasValue(propertyName, values[1], propertyName + ' is set on rerender'); + + this.setComponentValue(values[0]); + this.assertPropertyHasValue(propertyName, values[0], propertyName + ' can be set back to the initial value'); + }; + + _class.prototype.runFalsyValueProperty = function runFalsyValueProperty(values) { + var _this3 = this; + + var value = 'value'; + var template = ''; + this.render(template, { value: values[0] }); + this.assertPropertyHasValue(value, '', value + ' is set on initial render'); + + this.runTask(function () { + return _this3.rerender(); + }); + this.assertPropertyHasValue(value, '', value + ' is set on noop rerender'); + this.setComponentValue(values[1]); + + this.assertPropertyHasValue(value, values[1], value + ' is set on rerender'); + + this.setComponentValue(values[0]); + this.assertPropertyHasValue(value, '', value + ' can be set back to the initial value'); + }; + + _class.prototype['@test input disabled attribute'] = function testInputDisabledAttribute() { + var _this4 = this; + + var model = { model: { value: false } }; + + this.render('', model); + + this.assert.equal(this.$inputElement().prop('disabled'), false); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), false); + + this.runTask(function () { + return _this4.context.set('model.value', true); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), true); + this.assertHTML(''); // Note the DOM output is + + this.runTask(function () { + return _this4.context.set('model.value', 'wat'); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), true); + this.assertHTML(''); // Note the DOM output is + + this.runTask(function () { + return _this4.context.set('model', { value: false }); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), false); + this.assertHTML(''); + }; + + _class.prototype['@test input value attribute'] = function testInputValueAttribute() { + this.runPropertyTest('value', ['foo', 'bar']); + }; + + _class.prototype['@test input placeholder attribute'] = function testInputPlaceholderAttribute() { + this.runAttributeTest('placeholder', ['foo', 'bar']); + }; + + _class.prototype['@test input name attribute'] = function testInputNameAttribute() { + this.runAttributeTest('name', ['nam', 'name']); + }; + + _class.prototype['@test input maxlength attribute'] = function testInputMaxlengthAttribute() { + this.runAttributeTest('maxlength', [2, 3]); + }; + + _class.prototype['@test input size attribute'] = function testInputSizeAttribute() { + this.runAttributeTest('size', [2, 3]); + }; + + _class.prototype['@test input tabindex attribute'] = function testInputTabindexAttribute() { + this.runAttributeTest('tabindex', [2, 3]); + }; + + _class.prototype['@test null input value'] = function testNullInputValue() { + this.runFalsyValueProperty([null, 'hello']); + }; + + _class.prototype['@test undefined input value'] = function testUndefinedInputValue() { + this.runFalsyValueProperty([undefined, 'hello']); + }; + + _class.prototype['@test undefined `toString` method as input value'] = function testUndefinedToStringMethodAsInputValue() { + this.runFalsyValueProperty([Object.create(null), 'hello']); + }; + + _class.prototype['@test cursor position is not lost when updating content'] = function testCursorPositionIsNotLostWhenUpdatingContent() { + var template = ''; + this.render(template, { value: 'hola' }); + + this.setDOMValue('hello'); + this.setSelectionRange(1, 3); + + this.setComponentValue('hello'); + + this.assertSelectionRange(1, 3); + + // Note: We should eventually get around to testing reseting, however + // browsers handle `selectionStart` and `selectionEnd` differently + // when are synthetically testing movement of the cursor. + }; + + _class.prototype['@test input can be updated multiple times'] = function testInputCanBeUpdatedMultipleTimes() { + var template = ''; + this.render(template, { value: 'hola' }); + + this.assertValue('hola', 'Value is initialised'); + + this.setComponentValue(''); + this.assertValue('', 'Value is set in the DOM'); + + this.setDOMValue('hola'); + this.setComponentValue('hola'); + this.assertValue('hola', 'Value is updated the first time'); + + this.setComponentValue(''); + this.assertValue('', 'Value is updated the second time'); + }; + + _class.prototype['@test DOM is SSOT if value is set'] = function testDOMIsSSOTIfValueIsSet() { + var template = ''; + this.render(template, { value: 'hola' }); + + this.assertValue('hola', 'Value is initialised'); + + this.setComponentValue('hello'); + + this.assertValue('hello', 'Value is initialised'); + + this.setDOMValue('hola'); + + this.assertValue('hola', 'DOM is used'); + + this.setComponentValue('bye'); + + this.assertValue('bye', 'Value is used'); + + // Simulates setting the input to the same value as it already is which won't cause a rerender + + this.setDOMValue('hola'); + + this.assertValue('hola', 'DOM is used'); + + this.setComponentValue('hola'); + + this.assertValue('hola', 'Value is used'); + }; + + // private helpers and assertions + + _class.prototype.setDOMValue = function setDOMValue(value) { + this.inputElement().value = value; + }; + + _class.prototype.setComponentValue = function setComponentValue(value) { + var _this5 = this; + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'value', value); + }); + }; + + _class.prototype.setSelectionRange = function setSelectionRange(start, end) { + this.inputElement().selectionStart = start; + this.inputElement().selectionEnd = end; + }; + + _class.prototype.inputElement = function inputElement() { + return this.$inputElement()[0]; + }; + + _class.prototype.$inputElement = function $inputElement() { + return this.$('input'); + }; + + _class.prototype.assertValue = function assertValue(value, message) { + this.assertPropertyHasValue('value', value, message); + }; + + _class.prototype.assertAttributeHasValue = function assertAttributeHasValue(attribute, value, message) { + this.assert.equal(this.$inputElement().attr(attribute), value, attribute + ' ' + message); + }; + + _class.prototype.assertPropertyHasValue = function assertPropertyHasValue(property, value, message) { + this.assert.equal(this.$inputElement().prop(property), value, property + ' ' + message); + }; + + _class.prototype.assertSelectionRange = function assertSelectionRange(start, end) { + this.assert.equal(this.inputElement().selectionStart, start); + this.assert.equal(this.inputElement().selectionEnd, end); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/input-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/input-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/input-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/mount-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-metal', 'ember-application'], function (exports, _emberUtils, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberMetal, _emberApplication) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{mount}} assertions', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it asserts that only a single param is passed'] = function testItAssertsThatOnlyASingleParamIsPassed() { + var _this = this; + + expectAssertion(function () { + _this.render('{{mount "chat" "foo"}}'); + }, /You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}./i); + }; + + _class.prototype['@test it asserts that the engine name argument is quoted'] = function testItAssertsThatTheEngineNameArgumentIsQuoted() { + var _this2 = this; + + expectAssertion(function () { + _this2.render('{{mount chat}}'); + }, /The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}./i); + }; + + _class.prototype['@test it asserts that the specified engine is registered'] = function testItAssertsThatTheSpecifiedEngineIsRegistered() { + var _this3 = this; + + expectAssertion(function () { + _this3.render('{{mount "chat"}}'); + }, /You used `{{mount 'chat'}}`, but the engine 'chat' can not be found./i); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{mount}} test', (function (_ApplicationTest) { + babelHelpers.inherits(_class2, _ApplicationTest); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _ApplicationTest.call(this); + + var engineRegistrations = this.engineRegistrations = {}; + + this.registerEngine('chat', _emberApplication.Engine.extend({ + router: null, + + init: function () { + var _this4 = this; + + this._super.apply(this, arguments); + + Object.keys(engineRegistrations).forEach(function (fullName) { + _this4.register(fullName, engineRegistrations[fullName]); + }); + } + })); + + this.registerTemplate('index', '{{mount "chat"}}'); + } + + _class2.prototype['@test it boots an engine, instantiates its application controller, and renders its application template'] = function testItBootsAnEngineInstantiatesItsApplicationControllerAndRendersItsApplicationTemplate(assert) { + var _this5 = this; + + this.engineRegistrations['template:application'] = _emberGlimmerTestsUtilsHelpers.compile('

Chat here, {{username}}

', { moduleName: 'application' }); + + var controller = undefined; + + this.engineRegistrations['controller:application'] = _emberRuntime.Controller.extend({ + username: 'dgeb', + + init: function () { + this._super(); + controller = this; + } + }); + + return this.visit('/').then(function () { + assert.ok(controller, 'engine\'s application controller has been instantiated'); + + var engineInstance = _emberUtils.getOwner(controller); + assert.strictEqual(_emberApplication.getEngineParent(engineInstance), _this5.applicationInstance, 'engine instance has the application instance as its parent'); + + _this5.assertComponentElement(_this5.firstChild, { content: '

Chat here, dgeb

' }); + + _this5.runTask(function () { + return _emberMetal.set(controller, 'username', 'chancancode'); + }); + + _this5.assertComponentElement(_this5.firstChild, { content: '

Chat here, chancancode

' }); + + _this5.runTask(function () { + return _emberMetal.set(controller, 'username', 'dgeb'); + }); + + _this5.assertComponentElement(_this5.firstChild, { content: '

Chat here, dgeb

' }); + }); + }; + + _class2.prototype['@test it emits a useful backtracking re-render assertion message'] = function testItEmitsAUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this6 = this; + + this.router.map(function () { + this.route('route-with-mount'); + }); + + this.registerTemplate('index', ''); + this.registerTemplate('route-with-mount', '{{mount "chat"}}'); + + this.engineRegistrations['template:application'] = _emberGlimmerTestsUtilsHelpers.compile('hi {{person.name}} [{{component-with-backtracking-set person=person}}]', { moduleName: 'application' }); + this.engineRegistrations['controller:application'] = _emberRuntime.Controller.extend({ + person: { name: 'Alex' } + }); + + this.engineRegistrations['template:components/component-with-backtracking-set'] = _emberGlimmerTestsUtilsHelpers.compile('[component {{person.name}}]', { moduleName: 'components/component-with-backtracking-set' }); + this.engineRegistrations['component:component-with-backtracking-set'] = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person.name', 'Ben'); + } + }); + + var expectedBacktrackingMessage = /modified "person\.name" twice on \[object Object\] in a single render\. It was rendered in "template:route-with-mount" \(in "engine:chat"\) and modified in "component:component-with-backtracking-set" \(in "engine:chat"\)/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + return this.visit('/route-with-mount'); + } else { + return this.visit('/').then(function () { + expectAssertion(function () { + _this6.visit('/route-with-mount'); + }, expectedBacktrackingMessage); + }); + } + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/mount-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/mount-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/mount-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/outlet-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'internal-test-helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _internalTestHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('outlet view', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + + var CoreOutlet = undefined; + if (true) { + CoreOutlet = this.owner.factoryFor('view:-outlet'); + } else { + CoreOutlet = this.owner._lookupFactory('view:-outlet'); + } + + this.component = CoreOutlet.create(); + } + + _class.prototype['@test should not error when initial rendered template is undefined'] = function testShouldNotErrorWhenInitialRenderedTemplateIsUndefined() { + var _this = this; + + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: undefined, + ViewClass: undefined, + template: undefined + }, + + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText(''); + }; + + _class.prototype['@test should render the outlet when set after DOM insertion'] = function testShouldRenderTheOutletWhenSetAfterDOMInsertion() { + var _this2 = this; + + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: undefined, + ViewClass: undefined, + template: undefined + }, + + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this2.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText(''); + + this.registerTemplate('application', 'HI{{outlet}}'); + outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this2.component.setOutletState(outletState); + }); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('index', '

BYE

'); + outletState.outlets.main = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'index', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:index') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this2.component.setOutletState(outletState); + }); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test should render the outlet when set before DOM insertion'] = function testShouldRenderTheOutletWhenSetBeforeDOMInsertion() { + var _this3 = this; + + this.registerTemplate('application', 'HI{{outlet}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this3.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('index', '

BYE

'); + outletState.outlets.main = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'index', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:index') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this3.component.setOutletState(outletState); + }); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test should support an optional name'] = function testShouldSupportAnOptionalName() { + var _this4 = this; + + this.registerTemplate('application', '

HI

{{outlet "special"}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this4.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('special', '

BYE

'); + outletState.outlets.special = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'special', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:special') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this4.component.setOutletState(outletState); + }); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test does not default outlet name when positional argument is present'] = function testDoesNotDefaultOutletNameWhenPositionalArgumentIsPresent() { + var _this5 = this; + + this.registerTemplate('application', '

HI

{{outlet someUndefinedThing}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this5.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('special', '

BYE

'); + outletState.outlets.main = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'special', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:special') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this5.component.setOutletState(outletState); + }); + + this.assertText('HI'); + }; + + _class.prototype['@test should support bound outlet name'] = function testShouldSupportBoundOutletName() { + var _this6 = this; + + var controller = { outletName: 'foo' }; + this.registerTemplate('application', '

HI

{{outlet outletName}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: controller, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this6.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('foo', '

FOO

'); + outletState.outlets.foo = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'foo', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:foo') + }, + outlets: Object.create(null) + }; + + this.registerTemplate('bar', '

BAR

'); + outletState.outlets.bar = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'bar', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:bar') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this6.component.setOutletState(outletState); + }); + + this.assertText('HIFOO'); + + this.runTask(function () { + return _emberMetal.set(controller, 'outletName', 'bar'); + }); + + this.assertText('HIBAR'); + }; + + _class.prototype['@test outletState can pass through user code (liquid-fire initimate API) '] = function testOutletStateCanPassThroughUserCodeLiquidFireInitimateAPI() { + var _this7 = this; + + this.registerTemplate('outer', 'A{{#-with-dynamic-vars outletState=(identity (-get-dynamic-var "outletState"))}}B{{outlet}}D{{/-with-dynamic-vars}}E'); + this.registerTemplate('inner', 'C'); + + // This looks like it doesn't do anything, but its presence + // guarantees that the outletState gets converted from a reference + // to a value and then back to a reference. That is what we're + // testing here. + this.registerHelper('identity', function (_ref) { + var a = _ref[0]; + return a; + }); + + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'outer', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:outer') + }, + outlets: { + main: { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'inner', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:inner') + }, + outlets: Object.create(null) + } + } + }; + + this.runTask(function () { + return _this7.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('ABCDE'); + + this.assertStableRerender(); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/outlet-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/outlet-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/outlet-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/refinements-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with var as |foo|}}\n {{foo}}\n {{/with}}\n\n ---\n\n {{#with var as |render|}}\n {{render}}\n {{/with}}\n\n ---\n\n {{#with var as |outlet|}}\n {{outlet}}\n {{/with}}\n\n ---\n\n {{#with var as |mount|}}\n {{mount}}\n {{/with}}\n\n ---\n\n {{#with var as |component|}}\n {{component}}\n {{/with}}\n\n ---\n\n {{#with var as |input|}}\n {{input}}\n {{/with}}\n\n ---\n\n {{#with var as |-with-dynamic-vars|}}\n {{-with-dynamic-vars}}\n {{/with}}\n\n ---\n\n {{#with var as |-in-element|}}\n {{-in-element}}\n {{/with}}'], ['\n {{#with var as |foo|}}\n {{foo}}\n {{/with}}\n\n ---\n\n {{#with var as |render|}}\n {{render}}\n {{/with}}\n\n ---\n\n {{#with var as |outlet|}}\n {{outlet}}\n {{/with}}\n\n ---\n\n {{#with var as |mount|}}\n {{mount}}\n {{/with}}\n\n ---\n\n {{#with var as |component|}}\n {{component}}\n {{/with}}\n\n ---\n\n {{#with var as |input|}}\n {{input}}\n {{/with}}\n\n ---\n\n {{#with var as |-with-dynamic-vars|}}\n {{-with-dynamic-vars}}\n {{/with}}\n\n ---\n\n {{#with var as |-in-element|}}\n {{-in-element}}\n {{/with}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('syntax refinements', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test block params should not be refined'] = function testBlockParamsShouldNotBeRefined() { + var _this = this; + + this.registerHelper('foo', function () { + return 'bar helper'; + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { var: 'var' }); + + this.assertText('var---var---var---var---var---var---var---var'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'var', 'RARRR!!!'); + }); + + this.assertText('RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'var', 'var'); + }); + + this.assertText('var---var---var---var---var---var---var---var'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/refinements-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/refinements-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/refinements-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/svg-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
\n \n
\n '], ['\n
\n \n
\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n \n
\n '], ['\n
\n \n
\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n \n
\n '], ['\n
\n \n
\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n \n
\n '], ['\n
\n \n
\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n
\n \n
\n '], ['\n
\n \n
\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('SVG element tests', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test unquoted viewBox property is output'] = function testUnquotedViewBoxPropertyIsOutput(assert) { + var _this = this; + + var viewBoxString = '0 0 100 100'; + + this.render('
', { + model: { + viewBoxString: viewBoxString + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.viewBoxString', null); + }); + + assert.equal(this.firstChild.getAttribute('svg'), null); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model', { viewBoxString: viewBoxString }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + }; + + _class.prototype['@test quoted viewBox property is output'] = function testQuotedViewBoxPropertyIsOutput(assert) { + var _this2 = this; + + var viewBoxString = '0 0 100 100'; + + this.render('
', { + model: { + viewBoxString: viewBoxString + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model.viewBoxString', null); + }); + + assert.equal(this.firstChild.getAttribute('svg'), null); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { viewBoxString: viewBoxString }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + }; + + _class.prototype['@test quoted viewBox property is concat'] = function testQuotedViewBoxPropertyIsConcat() { + var _this3 = this; + + var viewBoxString = '100 100'; + + this.render('
', { + model: { + viewBoxString: viewBoxString + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, viewBoxString)); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, viewBoxString)); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.viewBoxString', '200 200'); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { viewBoxString: viewBoxString }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, viewBoxString)); + }; + + _class.prototype['@test class is output'] = function testClassIsOutput() { + var _this4 = this; + + this.render('
', { + model: { + color: 'blue' + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model.color', 'yellow'); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5)); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model', { color: 'blue' }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/svg-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/svg-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/svg-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/each-in-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-runtime', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberRuntime, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n {{#each-in categories as |category count|}}\n
  • {{category}}: {{count}}
  • \n {{/each-in}}\n
\n '], ['\n
    \n {{#each-in categories as |category count|}}\n
  • {{category}}: {{count}}
  • \n {{/each-in}}\n
\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Smartphones: 8203
  • \n
  • JavaScript Frameworks: Infinity
  • \n
\n '], ['\n
    \n
  • Smartphones: 8203
  • \n
  • JavaScript Frameworks: Infinity
  • \n
\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Smartphones: 100
  • \n
  • JavaScript Frameworks: Infinity
  • \n
  • Tweets: 443115
  • \n
\n '], ['\n
    \n
  • Smartphones: 100
  • \n
  • JavaScript Frameworks: Infinity
  • \n
  • Tweets: 443115
  • \n
\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n {{#each-in categories as |category data|}}\n
  • {{category}}: {{data.reports.unitsSold}}
  • \n {{/each-in}}\n
\n '], ['\n
    \n {{#each-in categories as |category data|}}\n
  • {{category}}: {{data.reports.unitsSold}}
  • \n {{/each-in}}\n
\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n {{#each-in categories key=\'@identity\' as |category count|}}\n
  • {{category}}: {{count}}
  • \n {{/each-in}}\n
\n '], ['\n
    \n {{#each-in categories key=\'@identity\' as |category count|}}\n
  • {{category}}: {{count}}
  • \n {{/each-in}}\n
\n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Smartphones: 8203
  • \n
  • Tablets: 8203
  • \n
  • JavaScript Frameworks: Infinity
  • \n
  • Bugs: Infinity
  • \n
\n '], ['\n
    \n
  • Smartphones: 8203
  • \n
  • Tablets: 8203
  • \n
  • JavaScript Frameworks: Infinity
  • \n
  • Bugs: Infinity
  • \n
\n ']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Smartphones: 100
  • \n
  • Tablets: 8203
  • \n
  • JavaScript Frameworks: Infinity
  • \n
  • Bugs: Infinity
  • \n
  • Tweets: 443115
  • \n
\n '], ['\n
    \n
  • Smartphones: 100
  • \n
  • Tablets: 8203
  • \n
  • JavaScript Frameworks: Infinity
  • \n
  • Bugs: Infinity
  • \n
  • Tweets: 443115
  • \n
\n ']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n {{#each-in (get collection type) as |category count|}}\n
  • {{category}}: {{count}}
  • \n {{/each-in}}\n
\n '], ['\n
    \n {{#each-in (get collection type) as |category count|}}\n
  • {{category}}: {{count}}
  • \n {{/each-in}}\n
\n ']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Emberinios: 533462
  • \n
  • Tweets: 7323
  • \n
\n '], ['\n
    \n
  • Emberinios: 533462
  • \n
  • Tweets: 7323
  • \n
\n ']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Televisions: 183
  • \n
  • Alarm Clocks: 999
  • \n
\n '], ['\n
    \n
  • Televisions: 183
  • \n
  • Alarm Clocks: 999
  • \n
\n ']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Televisions: 183
  • \n
  • Alarm Clocks: 999
  • \n
  • Tweets: 443115
  • \n
\n '], ['\n
    \n
  • Televisions: 183
  • \n
  • Alarm Clocks: 999
  • \n
  • Tweets: 443115
  • \n
\n ']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Emberinios: 123456
  • \n
\n '], ['\n
    \n
  • Emberinios: 123456
  • \n
\n ']), + _templateObject13 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each-in foo.bar.baz as |thing|}}\n {{thing}}\n {{/each-in}}'], ['\n {{#each-in foo.bar.baz as |thing|}}\n {{thing}}\n {{/each-in}}']), + _templateObject14 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each-in arr as |key value|}}\n [{{key}}:{{value}}]\n {{/each-in}}'], ['\n {{#each-in arr as |key value|}}\n [{{key}}:{{value}}]\n {{/each-in}}']), + _templateObject15 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n
  • Smartphones: 100
  • \n
  • Tablets: 20
  • \n
\n '], ['\n
    \n
  • Smartphones: 100
  • \n
  • Tablets: 20
  • \n
\n ']); + + var EachInTest = (function (_TogglingSyntaxConditionalsTest) { +babelHelpers.inherits(EachInTest, _TogglingSyntaxConditionalsTest); + + function EachInTest() { +babelHelpers.classCallCheck(this, EachInTest); + + _TogglingSyntaxConditionalsTest.apply(this, arguments); + } + + EachInTest.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#each-in ' + cond + ' as |key|}}' + truthy + '{{else}}' + falsy + '{{/each-in}}'; + }; + + return EachInTest; + })(_emberGlimmerTestsUtilsSharedConditionalTests.TogglingSyntaxConditionalsTest); + + function EmptyFunction() {} + + function NonEmptyFunction() {} + NonEmptyFunction.foo = 'bar'; + + var EmptyConstructor = function EmptyConstructor() { +babelHelpers.classCallCheck(this, EmptyConstructor); + }; + + var NonEmptyConstructor = function NonEmptyConstructor() { +babelHelpers.classCallCheck(this, NonEmptyConstructor); + }; + + NonEmptyConstructor.foo = 'bar'; + + var BasicEachInTest = (function (_EachInTest) { +babelHelpers.inherits(BasicEachInTest, _EachInTest); + + function BasicEachInTest() { +babelHelpers.classCallCheck(this, BasicEachInTest); + + _EachInTest.apply(this, arguments); + } + + return BasicEachInTest; + })(EachInTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(BasicEachInTest, new _emberGlimmerTestsUtilsSharedConditionalTests.TruthyGenerator([{ foo: 1 }, _emberRuntime.Object.create({ 'Not Empty': 1 }), [1], NonEmptyFunction, NonEmptyConstructor]), new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([null, undefined, false, '', 0, [], EmptyFunction, EmptyConstructor, {}, Object.create(null), Object.create({}), Object.create({ 'Not Empty': 1 }), _emberRuntime.Object.create()])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each-in}}', (function (_BasicEachInTest) { +babelHelpers.inherits(_class, _BasicEachInTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _BasicEachInTest.apply(this, arguments); + } + + _class.prototype['@test it repeats the given block for each item in the hash'] = function testItRepeatsTheGivenBlockForEachItemInTheHash() { + var _this = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + categories: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this.context, 'categories.Smartphones', 100); + _emberMetal.set(_this.context, 'categories.Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'categories', { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test it can render sub-paths of each item'] = function testItCanRenderSubPathsOfEachItem() { + var _this2 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4), { + categories: { + 'Smartphones': { reports: { unitsSold: 8203 } }, + 'JavaScript Frameworks': { reports: { unitsSold: Infinity } } + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'categories.Smartphones.reports.unitsSold', 100); + _emberMetal.set(_this2.context, 'categories.Tweets', { reports: { unitsSold: 443115 } }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'categories', { + 'Smartphones': { reports: { unitsSold: 8203 } }, + 'JavaScript Frameworks': { reports: { unitsSold: Infinity } } + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test it can render duplicate items'] = function testItCanRenderDuplicateItems() { + var _this3 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5), { + categories: { + 'Smartphones': 8203, + 'Tablets': 8203, + 'JavaScript Frameworks': Infinity, + 'Bugs': Infinity + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'categories.Smartphones', 100); + _emberMetal.set(_this3.context, 'categories.Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7)); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'categories', { + 'Smartphones': 8203, + 'Tablets': 8203, + 'JavaScript Frameworks': Infinity, + 'Bugs': Infinity + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6)); + }; + + _class.prototype['@test it repeats the given block when the hash is dynamic'] = function testItRepeatsTheGivenBlockWhenTheHashIsDynamic() { + var _this4 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8), { + collection: { + categories: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }, + otherCategories: { + 'Emberinios': 533462, + 'Tweets': 7323 + } + }, + type: 'categories' + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'type', 'otherCategories'); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9)); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'type', 'categories'); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test it only iterates over an object\'s own properties'] = function testItOnlyIteratesOverAnObjectSOwnProperties() { + var _this5 = this; + + var protoCategories = { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }; + + var categories = Object.create(protoCategories); + categories['Televisions'] = 183; + categories['Alarm Clocks'] = 999; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { categories: categories }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(protoCategories, 'Robots', 666); + _emberMetal.set(categories, 'Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11)); + + categories = Object.create(protoCategories); + categories['Televisions'] = 183; + categories['Alarm Clocks'] = 999; + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'categories', categories); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10)); + }; + + _class.prototype['@test it does not observe direct property mutations (not going through set) on the object'] = function testItDoesNotObserveDirectPropertyMutationsNotGoingThroughSetOnTheObject() { + var _this6 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + categories: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + var categories = _emberMetal.get(_this6.context, 'categories'); + delete categories.Smartphones; + }); + + this.assertInvariants(); + + this.runTask(function () { + var categories = _emberMetal.get(_this6.context, 'categories'); + categories['Emberinios'] = 123456; + }); + + this.assertInvariants(); + + this.runTask(function () { + _emberMetal.set(_this6.context, 'categories', { + Emberinios: 123456 + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12)); + + this.runTask(function () { + _emberMetal.set(_this6.context, 'categories', { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test keying off of `undefined` does not render'] = function testKeyingOffOfUndefinedDoesNotRender(assert) { + var _this7 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject13), { foo: {} }); + + this.assertText(''); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', { bar: { baz: { 'Here!': 1 } } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', {}); + }); + + this.assertText(''); + }; + + _class.prototype['@test it iterate over array with `in` instead of walking over elements'] = function testItIterateOverArrayWithInInsteadOfWalkingOverElements(assert) { + var _this8 = this; + + var arr = [1, 2, 3]; + arr.foo = 'bar'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14), { arr: arr }); + + this.assertText('[0:1][1:2][2:3][foo:bar]'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('[0:1][1:2][2:3][foo:bar]'); + + this.runTask(function () { + _emberMetal.set(arr, 'zomg', 'lol'); + }); + + this.assertText('[0:1][1:2][2:3][foo:bar][zomg:lol]'); + + arr = [1, 2, 3]; + arr.foo = 'bar'; + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'arr', arr); + }); + + this.assertText('[0:1][1:2][2:3][foo:bar]'); + }; + + _class.prototype['@test it skips holes in sparse arrays'] = function testItSkipsHolesInSparseArrays(assert) { + var arr = []; + arr[5] = 'foo'; + arr[6] = 'bar'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14), { arr: arr }); + + this.assertText('[5:foo][6:bar]'); + + this.assertStableRerender(); + }; + +babelHelpers.createClass(_class, [{ + key: 'truthyValue', + get: function () { + return { 'Not Empty': 1 }; + } + }, { + key: 'falsyValue', + get: function () { + return {}; + } + }]); + return _class; + })(BasicEachInTest)); + + var EachInEdgeCasesTest = (function (_EachInTest2) { +babelHelpers.inherits(EachInEdgeCasesTest, _EachInTest2); + + function EachInEdgeCasesTest() { +babelHelpers.classCallCheck(this, EachInEdgeCasesTest); + + _EachInTest2.apply(this, arguments); + } + + return EachInEdgeCasesTest; + })(EachInTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(EachInEdgeCasesTest, new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([true, 1, 'hello'])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each-in}} edge cases', (function (_EachInEdgeCasesTest) { +babelHelpers.inherits(_class2, _EachInEdgeCasesTest); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _EachInEdgeCasesTest.apply(this, arguments); + } + +babelHelpers.createClass(_class2, [{ + key: 'truthyValue', + get: function () { + return { 'Not Empty': 1 }; + } + }, { + key: 'falsyValue', + get: function () { + return {}; + } + }]); + return _class2; + })(EachInEdgeCasesTest)); + + var EachInProxyTest = (function (_EachInTest3) { +babelHelpers.inherits(EachInProxyTest, _EachInTest3); + + function EachInProxyTest() { +babelHelpers.classCallCheck(this, EachInProxyTest); + + _EachInTest3.apply(this, arguments); + } + + return EachInProxyTest; + })(EachInTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(EachInProxyTest, new _emberGlimmerTestsUtilsSharedConditionalTests.TruthyGenerator([_emberRuntime.ObjectProxy.create({ content: { 'Not empty': 1 } })]), new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([_emberRuntime.ObjectProxy.create(), _emberRuntime.ObjectProxy.create({ content: null }), _emberRuntime.ObjectProxy.create({ content: {} }), _emberRuntime.ObjectProxy.create({ content: Object.create(null) }), _emberRuntime.ObjectProxy.create({ content: Object.create({}) }), _emberRuntime.ObjectProxy.create({ content: Object.create({ 'Not Empty': 1 }) }), _emberRuntime.ObjectProxy.create({ content: _emberRuntime.Object.create() })])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each-in}} with `ObjectProxy`', (function (_EachInProxyTest) { +babelHelpers.inherits(_class3, _EachInProxyTest); + + function _class3() { +babelHelpers.classCallCheck(this, _class3); + + _EachInProxyTest.apply(this, arguments); + } + + _class3.prototype['@test it iterates over the content, not the proxy'] = function testItIteratesOverTheContentNotTheProxy() { + var _this9 = this; + + var content = { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }; + + var proxy = _emberRuntime.ObjectProxy.create({ + content: content, + foo: 'bar' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { categories: proxy }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(proxy, 'content.Smartphones', 100); + _emberMetal.set(proxy, 'content.Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + _emberMetal.set(proxy, 'content', { + 'Smartphones': 100, + 'Tablets': 20 + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject15)); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'categories', _emberRuntime.ObjectProxy.create({ + content: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + } + })); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + +babelHelpers.createClass(_class3, [{ + key: 'truthyValue', + get: function () { + return _emberRuntime.ObjectProxy.create({ content: { 'Not Empty': 1 } }); + } + }, { + key: 'falsyValue', + get: function () { + return _emberRuntime.ObjectProxy.create({ content: null }); + } + }]); + return _class3; + })(EachInProxyTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/each-in-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/each-in-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/each-in-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/each-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberRuntime, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each list as |item|}}\n
  • Prev
  • \n {{foo-bar item=item}}\n
  • Next
  • \n {{/each}}\n '], ['\n {{#each list as |item|}}\n
  • Prev
  • \n {{foo-bar item=item}}\n
  • Next
  • \n {{/each}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each content as |value|}}\n {{value}}-\n {{#each options as |option|}}\n {{option.value}}:{{option.label}}\n {{/each}}\n {{/each}}\n '], ['\n {{#each content as |value|}}\n {{value}}-\n {{#each options as |option|}}\n {{option.value}}:{{option.label}}\n {{/each}}\n {{/each}}\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each foo.bar.baz as |thing|}}\n {{thing}}\n {{/each}}'], ['\n {{#each foo.bar.baz as |thing|}}\n {{thing}}\n {{/each}}']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each list as |value key|}}\n [{{key}}:{{value}}]\n {{/each}}'], ['\n {{#each list as |value key|}}\n [{{key}}:{{value}}]\n {{/each}}']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n

    {{page.title}}

    \n\n
      \n {{#each model as |post|}}\n
    • {{post.title}}
    • \n {{/each}}\n
    \n '], ['\n

    {{page.title}}

    \n\n
      \n {{#each model as |post|}}\n
    • {{post.title}}
    • \n {{/each}}\n
    \n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Blog Posts

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n '], ['\n

    Blog Posts

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n ']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Essays

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n '], ['\n

    Essays

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n ']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Think Pieces™

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n '], ['\n

    Think Pieces™

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n ']); + + var ArrayLike = (function () { + function ArrayLike(content) { +babelHelpers.classCallCheck(this, ArrayLike); + + this._array = content; + } + + ArrayLike.prototype.forEach = function forEach(callback) { + this._array.forEach(callback); + }; + + // The following methods are APIs used by the tests + + ArrayLike.prototype.objectAt = function objectAt(idx) { + return this._array[idx]; + }; + + ArrayLike.prototype.clear = function clear() { + this._array.length = 0; + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.replace = function replace(idx, del, ins) { + var _array; + + (_array = this._array).splice.apply(_array, [idx, del].concat(ins)); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.unshiftObject = function unshiftObject(obj) { + this._array.unshift(obj); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.unshiftObjects = function unshiftObjects(arr) { + var _array2; + + (_array2 = this._array).unshift.apply(_array2, arr); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.pushObject = function pushObject(obj) { + this._array.push(obj); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.pushObjects = function pushObjects(arr) { + var _array3; + + (_array3 = this._array).push.apply(_array3, arr); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.shiftObject = function shiftObject() { + var obj = this._array.shift(); + this.arrayContentDidChange(); + return obj; + }; + + ArrayLike.prototype.popObject = function popObject() { + var obj = this._array.pop(); + this.arrayContentDidChange(); + return obj; + }; + + ArrayLike.prototype.insertAt = function insertAt(idx, obj) { + this._array.splice(idx, 0, obj); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.removeAt = function removeAt(idx) { + var len = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1]; + + this._array.splice(idx, len); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.arrayContentDidChange = function arrayContentDidChange() { + _emberMetal.propertyDidChange(this, '[]'); + _emberMetal.propertyDidChange(this, 'length'); + }; + +babelHelpers.createClass(ArrayLike, [{ + key: 'length', + get: function () { + return this._array.length; + } + }]); + return ArrayLike; + })(); + + var TogglingEachTest = (function (_TogglingSyntaxConditionalsTest) { +babelHelpers.inherits(TogglingEachTest, _TogglingSyntaxConditionalsTest); + + function TogglingEachTest() { +babelHelpers.classCallCheck(this, TogglingEachTest); + + _TogglingSyntaxConditionalsTest.apply(this, arguments); + } + +babelHelpers.createClass(TogglingEachTest, [{ + key: 'truthyValue', + get: function () { + return ['non-empty']; + } + }, { + key: 'falsyValue', + get: function () { + return []; + } + }]); + return TogglingEachTest; + })(_emberGlimmerTestsUtilsSharedConditionalTests.TogglingSyntaxConditionalsTest); + + var BasicEachTest = (function (_TogglingEachTest) { +babelHelpers.inherits(BasicEachTest, _TogglingEachTest); + + function BasicEachTest() { +babelHelpers.classCallCheck(this, BasicEachTest); + + _TogglingEachTest.apply(this, arguments); + } + + return BasicEachTest; + })(TogglingEachTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(BasicEachTest, new _emberGlimmerTestsUtilsSharedConditionalTests.TruthyGenerator([['hello'], _emberRuntime.A(['hello']), new ArrayLike(['hello']), _emberRuntime.ArrayProxy.create({ content: ['hello'] }), _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) })]), new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([null, undefined, false, '', 0, []]), _emberGlimmerTestsUtilsSharedConditionalTests.ArrayTestCases); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each}}', (function (_BasicEachTest) { +babelHelpers.inherits(_class, _BasicEachTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _BasicEachTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#each ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class; + })(BasicEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each as}}', (function (_BasicEachTest2) { +babelHelpers.inherits(_class2, _BasicEachTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _BasicEachTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{#each ' + cond + ' as |test|}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class2; + })(BasicEachTest)); + + var EachEdgeCasesTest = (function (_TogglingEachTest2) { +babelHelpers.inherits(EachEdgeCasesTest, _TogglingEachTest2); + + function EachEdgeCasesTest() { +babelHelpers.classCallCheck(this, EachEdgeCasesTest); + + _TogglingEachTest2.apply(this, arguments); + } + + return EachEdgeCasesTest; + })(TogglingEachTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(EachEdgeCasesTest, new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([true, 'hello', 1, Object, function () {}, {}, { foo: 'bar' }, Object.create(null), Object.create({}), Object.create({ foo: 'bar' })])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each}}', (function (_EachEdgeCasesTest) { +babelHelpers.inherits(_class3, _EachEdgeCasesTest); + + function _class3() { +babelHelpers.classCallCheck(this, _class3); + + _EachEdgeCasesTest.apply(this, arguments); + } + + _class3.prototype.templateFor = function templateFor(_ref3) { + var cond = _ref3.cond; + var truthy = _ref3.truthy; + var falsy = _ref3.falsy; + + return '{{#each ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class3; + })(EachEdgeCasesTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each as}}', (function (_EachEdgeCasesTest2) { +babelHelpers.inherits(_class4, _EachEdgeCasesTest2); + + function _class4() { +babelHelpers.classCallCheck(this, _class4); + + _EachEdgeCasesTest2.apply(this, arguments); + } + + _class4.prototype.templateFor = function templateFor(_ref4) { + var cond = _ref4.cond; + var truthy = _ref4.truthy; + var falsy = _ref4.falsy; + + return '{{#each ' + cond + ' as |test|}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class4; + })(EachEdgeCasesTest)); + + var AbstractEachTest = (function (_RenderingTest) { +babelHelpers.inherits(AbstractEachTest, _RenderingTest); + + function AbstractEachTest() { +babelHelpers.classCallCheck(this, AbstractEachTest); + + _RenderingTest.apply(this, arguments); + } + + /* abstract */ + + AbstractEachTest.prototype.makeList = function makeList() { + // this.list = this.delegate = ...; + throw new Error('Not implemented: `makeList`'); + }; + + AbstractEachTest.prototype.replaceList = function replaceList(list) { + var _this = this; + + this.runTask(function () { + return _emberMetal.set(_this.context, 'list', _this.makeList(list)); + }); + }; + + AbstractEachTest.prototype.forEach = function forEach(callback) { + return this.delegate.forEach(callback); + }; + + AbstractEachTest.prototype.objectAt = function objectAt(idx) { + return this.delegate.objectAt(idx); + }; + + AbstractEachTest.prototype.clear = function clear() { + return this.delegate.clear(); + }; + + AbstractEachTest.prototype.replace = function replace(idx, del, ins) { + return this.delegate.replace(idx, del, ins); + }; + + AbstractEachTest.prototype.unshiftObject = function unshiftObject(obj) { + return this.delegate.unshiftObject(obj); + }; + + AbstractEachTest.prototype.unshiftObjects = function unshiftObjects(arr) { + return this.delegate.unshiftObjects(arr); + }; + + AbstractEachTest.prototype.pushObject = function pushObject(obj) { + return this.delegate.pushObject(obj); + }; + + AbstractEachTest.prototype.pushObjects = function pushObjects(arr) { + return this.delegate.pushObjects(arr); + }; + + AbstractEachTest.prototype.shiftObject = function shiftObject() { + return this.delegate.shiftObject(); + }; + + AbstractEachTest.prototype.popObject = function popObject() { + return this.delegate.popObject(); + }; + + AbstractEachTest.prototype.insertAt = function insertAt(idx, obj) { + return this.delegate.insertAt(idx, obj); + }; + + AbstractEachTest.prototype.removeAt = function removeAt(idx, len) { + return this.delegate.removeAt(idx, len); + }; + + AbstractEachTest.prototype.render = function render(template) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + if (this.list === undefined) { + throw new Error('Must call `this.makeList()` before calling this.render()'); + } + + context.list = this.list; + + return _RenderingTest.prototype.render.call(this, template, context); + }; + + return AbstractEachTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var SingleEachTest = (function (_AbstractEachTest) { +babelHelpers.inherits(SingleEachTest, _AbstractEachTest); + + function SingleEachTest() { +babelHelpers.classCallCheck(this, SingleEachTest); + + _AbstractEachTest.apply(this, arguments); + } + + SingleEachTest.prototype['@test it repeats the given block for each item in the array'] = function testItRepeatsTheGivenBlockForEachItemInTheArray() { + var _this2 = this; + + this.makeList([{ text: 'hello' }]); + + this.render('{{#each list as |item|}}{{item.text}}{{else}}Empty{{/each}}'); + + this.assertText('hello'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('hello'); + + this.runTask(function () { + return _emberMetal.set(_this2.objectAt(0), 'text', 'Hello'); + }); + + this.assertText('Hello'); + + this.runTask(function () { + _this2.pushObject({ text: ' ' }); + _this2.pushObject({ text: 'World' }); + }); + + this.assertText('Hello World'); + + this.runTask(function () { + _this2.pushObject({ text: 'Earth' }); + _this2.removeAt(1); + _this2.insertAt(1, { text: 'Globe' }); + }); + + this.assertText('HelloGlobeWorldEarth'); + + this.runTask(function () { + _this2.pushObject({ text: 'Planet' }); + _this2.removeAt(1); + _this2.insertAt(1, { text: ' ' }); + _this2.pushObject({ text: ' ' }); + _this2.pushObject({ text: 'Earth' }); + _this2.removeAt(3); + }); + + this.assertText('Hello WorldPlanet Earth'); + + this.runTask(function () { + _this2.pushObject({ text: 'Globe' }); + _this2.removeAt(1); + _this2.insertAt(1, { text: ' ' }); + _this2.pushObject({ text: ' ' }); + _this2.pushObject({ text: 'World' }); + _this2.removeAt(2); + }); + + this.assertText('Hello Planet EarthGlobe World'); + + this.runTask(function () { + return _this2.replace(2, 4, { text: 'my' }); + }); + + this.assertText('Hello my World'); + + this.runTask(function () { + return _this2.clear(); + }); + + this.assertText('Empty'); + + this.replaceList([{ text: 'hello' }]); + + this.assertText('hello'); + }; + + SingleEachTest.prototype['@test it receives the index as the second parameter'] = function testItReceivesTheIndexAsTheSecondParameter() { + var _this3 = this; + + this.makeList([{ text: 'hello' }, { text: 'world' }]); + + this.render('{{#each list as |item index|}}[{{index}}. {{item.text}}]{{/each}}'); + + this.assertText('[0. hello][1. world]'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this3.insertAt(1, { text: 'my' }); + }); + + this.assertText('[0. hello][1. my][2. world]'); + + this.replaceList([{ text: 'hello' }, { text: 'world' }]); + + this.assertText('[0. hello][1. world]'); + }; + + SingleEachTest.prototype['@test it accepts a string key'] = function testItAcceptsAStringKey() { + var _this4 = this; + + this.makeList([{ text: 'hello' }, { text: 'world' }]); + + this.render('{{#each list key=\'text\' as |item|}}{{item.text}}{{/each}}'); + + this.assertText('helloworld'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this4.pushObject({ text: 'again' }); + }); + + this.assertText('helloworldagain'); + + this.replaceList([{ text: 'hello' }, { text: 'world' }]); + + this.assertText('helloworld'); + }; + + SingleEachTest.prototype['@test it accepts a numeric key'] = function testItAcceptsANumericKey() { + var _this5 = this; + + this.makeList([{ id: 1 }, { id: 2 }]); + + this.render('{{#each list key=\'id\' as |item|}}{{item.id}}{{/each}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this5.pushObject({ id: 3 }); + }); + + this.assertText('123'); + + this.replaceList([{ id: 1 }, { id: 2 }]); + + this.assertText('12'); + }; + + SingleEachTest.prototype['@test it can specify @index as the key'] = function testItCanSpecifyIndexAsTheKey() { + var _this6 = this; + + this.makeList([{ id: 1 }, { id: 2 }]); + + this.render('{{#each list key=\'@index\' as |item|}}{{item.id}}{{/each}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this6.pushObject({ id: 3 }); + }); + + this.assertText('123'); + + this.replaceList([{ id: 1 }, { id: 2 }]); + + this.assertText('12'); + }; + + SingleEachTest.prototype['@test it can specify @identity as the key for arrays of primitives'] = function testItCanSpecifyIdentityAsTheKeyForArraysOfPrimitives() { + var _this7 = this; + + this.makeList([1, 2]); + + this.render('{{#each list key=\'@identity\' as |item|}}{{item}}{{/each}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this7.pushObject(3); + }); + + this.assertText('123'); + + this.replaceList([1, 2]); + + this.assertText('12'); + }; + + SingleEachTest.prototype['@test it can specify @identity as the key for mixed arrays of objects and primitives'] = function testItCanSpecifyIdentityAsTheKeyForMixedArraysOfObjectsAndPrimitives() { + var _this8 = this; + + this.makeList([1, { id: 2 }, 3]); + + this.render('{{#each list key=\'@identity\' as |item|}}{{if item.id item.id item}}{{/each}}'); + + this.assertText('123'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this8.insertAt(2, { id: 4 }); + }); + + this.assertText('1243'); + + this.replaceList([1, { id: 2 }, 3]); + + this.assertText('123'); + }; + + SingleEachTest.prototype['@test it can render duplicate primitive items'] = function testItCanRenderDuplicatePrimitiveItems() { + var _this9 = this; + + this.makeList(['a', 'a', 'a']); + + this.render('{{#each list as |item|}}{{item}}{{/each}}'); + + this.assertText('aaa'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this9.pushObject('a'); + }); + + this.assertText('aaaa'); + + this.runTask(function () { + return _this9.pushObject('a'); + }); + + this.assertText('aaaaa'); + + this.replaceList(['a', 'a', 'a']); + + this.assertText('aaa'); + }; + + SingleEachTest.prototype['@test updating and setting within #each'] = function testUpdatingAndSettingWithinEach(assert) { + var _this10 = this; + + this.makeList([{ value: 1 }, { value: 2 }, { value: 3 }]); + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.isEven = true; + this.tagName = 'li'; + }, + + _isEven: function () { + this.set('isEven', this.get('item.value') % 2 === 0); + }, + + didUpdate: function () { + this._isEven(); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{#if isEven}}{{item.value}}{{/if}}' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertText('Prev1NextPrev2NextPrev3Next'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this10.context.list.objectAt(0), 'value', 3); + }); + + this.assertText('PrevNextPrev2NextPrev3Next'); + + this.replaceList([{ value: 1 }, { value: 2 }, { value: 3 }]); + + this.assertText('Prev1NextPrev2NextPrev3Next'); + }; + + SingleEachTest.prototype['@test it can render duplicate objects'] = function testItCanRenderDuplicateObjects() { + var _this11 = this; + + var duplicateItem = { text: 'foo' }; + + this.makeList([duplicateItem, duplicateItem, { text: 'bar' }, { text: 'baz' }]); + + this.render('{{#each list as |item|}}{{item.text}}{{/each}}'); + + this.assertText('foofoobarbaz'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this11.pushObject(duplicateItem); + }); + + this.assertText('foofoobarbazfoo'); + + this.runTask(function () { + return _this11.pushObject(duplicateItem); + }); + + this.assertText('foofoobarbazfoofoo'); + + this.replaceList([duplicateItem, duplicateItem, { text: 'bar' }, { text: 'baz' }]); + + this.assertText('foofoobarbaz'); + }; + + SingleEachTest.prototype['@test it maintains DOM stability when condition changes between objects with the same keys'] = function testItMaintainsDOMStabilityWhenConditionChangesBetweenObjectsWithTheSameKeys() { + var _this12 = this; + + this.makeList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.render('{{#each list key="text" as |item|}}{{item.text}}{{/each}}'); + + this.assertText('Hello world'); + + this.takeSnapshot(); + + this.runTask(function () { + _this12.popObject(); + _this12.popObject(); + _this12.pushObject({ text: ' ' }); + _this12.pushObject({ text: 'world' }); + }); + + this.assertText('Hello world'); + + this.assertInvariants(); + + this.replaceList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.assertText('Hello world'); + + this.assertInvariants(); + }; + + SingleEachTest.prototype['@test it maintains DOM stability for stable keys when list is updated'] = function testItMaintainsDOMStabilityForStableKeysWhenListIsUpdated() { + var _this13 = this; + + this.makeList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.render('{{#each list key="text" as |item|}}{{item.text}}{{/each}}'); + + this.assertText('Hello world'); + + this.assertStableRerender(); + + var oldSnapshot = this.takeSnapshot(); + + this.runTask(function () { + _this13.unshiftObject({ text: ', ' }); + _this13.unshiftObject({ text: 'Hi' }); + _this13.pushObject({ text: '!' }); + _this13.pushObject({ text: 'earth' }); + }); + + this.assertText('Hi, Hello world!earth'); + + this.assertPartialInvariants(2, 5); + + this.replaceList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.assertText('Hello world'); + + this.assertInvariants(oldSnapshot, this.takeSnapshot()); + }; + + SingleEachTest.prototype['@test it renders all items with duplicate key values'] = function testItRendersAllItemsWithDuplicateKeyValues() { + var _this14 = this; + + this.makeList([{ text: 'Hello' }, { text: 'Hello' }, { text: 'Hello' }]); + + this.render('{{#each list key="text" as |item|}}{{item.text}}{{/each}}'); + + this.assertText('HelloHelloHello'); + + this.runTask(function () { + _this14.forEach(function (hash) { + return _emberMetal.set(hash, 'text', 'Goodbye'); + }); + }); + + this.assertText('GoodbyeGoodbyeGoodbye'); + + this.replaceList([{ text: 'Hello' }, { text: 'Hello' }, { text: 'Hello' }]); + + this.assertText('HelloHelloHello'); + }; + + SingleEachTest.prototype['@test context is not changed to the inner scope inside an {{#each as}} block'] = function testContextIsNotChangedToTheInnerScopeInsideAnEachAsBlock() { + var _this15 = this; + + this.makeList([{ name: 'Chad' }, { name: 'Zack' }, { name: 'Asa' }]); + + this.render('{{name}}-{{#each list as |person|}}{{name}}{{/each}}-{{name}}', { + name: 'Joel' + }); + + this.assertText('Joel-JoelJoelJoel-Joel'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this15.shiftObject(); + }); + + this.assertText('Joel-JoelJoel-Joel'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'name', 'Godfrey'); + }); + + this.assertText('Godfrey-GodfreyGodfrey-Godfrey'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'name', 'Joel'); + }); + this.replaceList([{ name: 'Chad' }, { name: 'Zack' }, { name: 'Asa' }]); + + this.assertText('Joel-JoelJoelJoel-Joel'); + }; + + SingleEachTest.prototype['@test can access the item and the original scope'] = function testCanAccessTheItemAndTheOriginalScope() { + var _this16 = this; + + this.makeList([{ name: 'Tom Dale' }, { name: 'Yehuda Katz' }, { name: 'Godfrey Chan' }]); + + this.render('{{#each list key="name" as |person|}}[{{title}}: {{person.name}}]{{/each}}', { + title: 'Señor Engineer' + }); + + this.assertText('[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]'); + + this.runTask(function () { + _emberMetal.set(_this16.objectAt(1), 'name', 'Stefan Penner'); + _this16.removeAt(0); + _this16.pushObject({ name: 'Tom Dale' }); + _this16.insertAt(1, { name: 'Chad Hietala' }); + _emberMetal.set(_this16.context, 'title', 'Principal Engineer'); + }); + + this.assertText('[Principal Engineer: Stefan Penner][Principal Engineer: Chad Hietala][Principal Engineer: Godfrey Chan][Principal Engineer: Tom Dale]'); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'title', 'Señor Engineer'); + }); + this.replaceList([{ name: 'Tom Dale' }, { name: 'Yehuda Katz' }, { name: 'Godfrey Chan' }]); + + this.assertText('[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]'); + }; + + SingleEachTest.prototype['@test the scoped variable is not available outside the {{#each}} block.'] = function testTheScopedVariableIsNotAvailableOutsideTheEachBlock() { + var _this17 = this; + + this.makeList(['Yehuda']); + + this.render('{{name}}-{{#each list as |name|}}{{name}}{{/each}}-{{name}}', { + name: 'Stef' + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _this17.pushObjects([' ', 'Katz']); + }); + + this.assertText('Stef-Yehuda Katz-Stef'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'name', 'Tom'); + }); + + this.assertText('Tom-Yehuda Katz-Tom'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'name', 'Stef'); + }); + this.replaceList(['Yehuda']); + + this.assertText('Stef-Yehuda-Stef'); + }; + + SingleEachTest.prototype['@test inverse template is displayed with context'] = function testInverseTemplateIsDisplayedWithContext() { + var _this18 = this; + + this.makeList([]); + + this.render('{{#each list as |thing|}}Has Thing{{else}}No Thing {{otherThing}}{{/each}}', { + otherThing: 'bar' + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'otherThing', 'biz'); + }); + + this.assertText('No Thing biz'); + + this.runTask(function () { + return _this18.pushObject('non-empty'); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'otherThing', 'baz'); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'otherThing', 'bar'); + }); + this.replaceList([]); + + this.assertText('No Thing bar'); + }; + + SingleEachTest.prototype['@test content that are not initially present updates correctly GH#13983'] = function testContentThatAreNotInitiallyPresentUpdatesCorrectlyGH13983() { + var _this19 = this; + + // The root cause of this bug is that Glimmer did not call `didInitializeChildren` + // on the inserted `TryOpcode`, causing that `TryOpcode` to have an uninitialized + // tag. Currently the only way to observe this the "JUMP-IF-NOT-MODIFIED", i.e. by + // wrapping it in an component. + + this.registerComponent('x-wrapper', { template: '{{yield}}' }); + + this.makeList([]); + + this.render('{{#x-wrapper}}{{#each list as |obj|}}[{{obj.text}}]{{/each}}{{/x-wrapper}}'); + + this.assertText(''); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this19.pushObject({ text: 'foo' }); + }); + + this.assertText('[foo]'); + + this.runTask(function () { + return _emberMetal.set(_this19.objectAt(0), 'text', 'FOO'); + }); + + this.assertText('[FOO]'); + + this.runTask(function () { + return _this19.pushObject({ text: 'bar' }); + }); + + this.assertText('[FOO][bar]'); + + this.runTask(function () { + return _emberMetal.set(_this19.objectAt(1), 'text', 'BAR'); + }); + + this.assertText('[FOO][BAR]'); + + this.runTask(function () { + return _emberMetal.set(_this19.objectAt(1), 'text', 'baz'); + }); + + this.assertText('[FOO][baz]'); + + this.runTask(function () { + return _this19.replace(1, 1, [{ text: 'BAZ' }]); + }); + + this.assertText('[FOO][BAZ]'); + + this.replaceList([]); + + this.assertText(''); + }; + + return SingleEachTest; + })(AbstractEachTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with arrays', (function (_SingleEachTest) { +babelHelpers.inherits(_class5, _SingleEachTest); + + function _class5() { +babelHelpers.classCallCheck(this, _class5); + + _SingleEachTest.apply(this, arguments); + } + + _class5.prototype.makeList = function makeList(list) { + return this.list = this.delegate = _emberRuntime.A(list); + }; + + return _class5; + })(SingleEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with array-like objects', (function (_SingleEachTest2) { +babelHelpers.inherits(_class6, _SingleEachTest2); + + function _class6() { +babelHelpers.classCallCheck(this, _class6); + + _SingleEachTest2.apply(this, arguments); + } + + _class6.prototype.makeList = function makeList(list) { + return this.list = this.delegate = new ArrayLike(list); + }; + + return _class6; + })(SingleEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with array proxies, modifying itself', (function (_SingleEachTest3) { +babelHelpers.inherits(_class7, _SingleEachTest3); + + function _class7() { +babelHelpers.classCallCheck(this, _class7); + + _SingleEachTest3.apply(this, arguments); + } + + _class7.prototype.makeList = function makeList(list) { + return this.list = this.delegate = _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(list) }); + }; + + return _class7; + })(SingleEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with array proxies, replacing its content', (function (_SingleEachTest4) { +babelHelpers.inherits(_class8, _SingleEachTest4); + + function _class8() { +babelHelpers.classCallCheck(this, _class8); + + _SingleEachTest4.apply(this, arguments); + } + + _class8.prototype.makeList = function makeList(list) { + var content = this.delegate = _emberRuntime.A(list); + return this.list = _emberRuntime.ArrayProxy.create({ content: content }); + }; + + _class8.prototype.replaceList = function replaceList(list) { + var _this20 = this; + + this.runTask(function () { + return _this20.list.set('content', _emberRuntime.A(list)); + }); + }; + + return _class8; + })(SingleEachTest)); + + // TODO: Refactor the following tests so we can run them against different kind of arrays + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: Multiple {{#each as}} helpers', (function (_RenderingTest2) { +babelHelpers.inherits(_class9, _RenderingTest2); + + function _class9() { +babelHelpers.classCallCheck(this, _class9); + + _RenderingTest2.apply(this, arguments); + } + + _class9.prototype['@test re-using the same variable with different {{#each}} blocks does not override each other'] = function testReUsingTheSameVariableWithDifferentEachBlocksDoesNotOverrideEachOther() { + var _this21 = this; + + this.render('Admin: {{#each admins key="name" as |person|}}[{{person.name}}]{{/each}} User: {{#each users key="name" as |person|}}[{{person.name}}]{{/each}}', { + admins: _emberRuntime.A([{ name: 'Tom Dale' }]), + users: _emberRuntime.A([{ name: 'Yehuda Katz' }]) + }); + + this.assertText('Admin: [Tom Dale] User: [Yehuda Katz]'); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertText('Admin: [Tom Dale] User: [Yehuda Katz]'); + + this.runTask(function () { + _emberMetal.get(_this21.context, 'admins').pushObject({ name: 'Godfrey Chan' }); + _emberMetal.set(_emberMetal.get(_this21.context, 'users').objectAt(0), 'name', 'Stefan Penner'); + }); + + this.assertText('Admin: [Tom Dale][Godfrey Chan] User: [Stefan Penner]'); + + this.runTask(function () { + _emberMetal.set(_this21.context, 'admins', [{ name: 'Tom Dale' }]); + _emberMetal.set(_this21.context, 'users', [{ name: 'Yehuda Katz' }]); + }); + + this.assertText('Admin: [Tom Dale] User: [Yehuda Katz]'); + }; + + _class9.prototype['@test an outer {{#each}}\'s scoped variable does not clobber an inner {{#each}}\'s property if they share the same name - Issue #1315'] = function testAnOuterEachSScopedVariableDoesNotClobberAnInnerEachSPropertyIfTheyShareTheSameNameIssue1315() { + var _this22 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + content: _emberRuntime.A(['X', 'Y']), + options: _emberRuntime.A([{ label: 'One', value: 1 }, { label: 'Two', value: 2 }]) + }); + + this.assertText('X-1:One2:TwoY-1:One2:Two'); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.get(_this22.context, 'content').pushObject('Z'); + _emberMetal.set(_emberMetal.get(_this22.context, 'options').objectAt(0), 'value', 0); + }); + + this.assertText('X-0:One2:TwoY-0:One2:TwoZ-0:One2:Two'); + + this.runTask(function () { + _emberMetal.set(_this22.context, 'content', ['X', 'Y']); + _emberMetal.set(_this22.context, 'options', [{ label: 'One', value: 1 }, { label: 'Two', value: 2 }]); + }); + + this.assertText('X-1:One2:TwoY-1:One2:Two'); + }; + + _class9.prototype['@test the scoped variable is not available outside the {{#each}} block'] = function testTheScopedVariableIsNotAvailableOutsideTheEachBlock() { + var _this23 = this; + + this.render('{{ring}}-{{#each first as |ring|}}{{ring}}-{{#each fifth as |ring|}}{{ring}}-{{#each ninth as |ring|}}{{ring}}-{{/each}}{{ring}}-{{/each}}{{ring}}-{{/each}}{{ring}}', { + ring: 'Greed', + first: _emberRuntime.A(['Limbo']), + fifth: _emberRuntime.A(['Wrath']), + ninth: _emberRuntime.A(['Treachery']) + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + _emberMetal.set(_this23.context, 'ring', 'O'); + _emberMetal.get(_this23.context, 'fifth').insertAt(0, 'D'); + }); + + this.assertText('O-Limbo-D-Treachery-D-Wrath-Treachery-Wrath-Limbo-O'); + + this.runTask(function () { + _emberMetal.get(_this23.context, 'first').pushObject('I'); + _emberMetal.get(_this23.context, 'ninth').replace(0, 1, 'K'); + }); + + this.assertText('O-Limbo-D-K-D-Wrath-K-Wrath-Limbo-I-D-K-D-Wrath-K-Wrath-I-O'); + + this.runTask(function () { + _emberMetal.set(_this23.context, 'ring', 'Greed'); + _emberMetal.set(_this23.context, 'first', ['Limbo']); + _emberMetal.set(_this23.context, 'fifth', ['Wrath']); + _emberMetal.set(_this23.context, 'ninth', ['Treachery']); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + }; + + _class9.prototype['@test it should support {{#each name as |foo|}}, then {{#each foo as |bar|}}'] = function testItShouldSupportEachNameAsFooThenEachFooAsBar() { + var _this24 = this; + + this.render('{{#each name key="@index" as |foo|}}{{#each foo as |bar|}}{{bar}}{{/each}}{{/each}}', { + name: _emberRuntime.A([_emberRuntime.A(['caterpillar'])]) + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + var name = _emberMetal.get(_this24.context, 'name'); + name.objectAt(0).replace(0, 1, 'lady'); + name.pushObject(['bird']); + }); + + this.assertText('ladybird'); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'name', [['caterpillar']]); + }); + + this.assertText('caterpillar'); + }; + + return _class9; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each as}} undefined path', (function (_RenderingTest3) { +babelHelpers.inherits(_class10, _RenderingTest3); + + function _class10() { +babelHelpers.classCallCheck(this, _class10); + + _RenderingTest3.apply(this, arguments); + } + + _class10.prototype['@test keying off of `undefined` does not render'] = function testKeyingOffOfUndefinedDoesNotRender(assert) { + var _this25 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3), { foo: {} }); + + this.assertText(''); + + this.runTask(function () { + return _this25.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'foo', { bar: { baz: ['Here!'] } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'foo', {}); + }); + + this.assertText(''); + }; + + return _class10; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with sparse arrays', (function (_RenderingTest4) { +babelHelpers.inherits(_class11, _RenderingTest4); + + function _class11() { +babelHelpers.classCallCheck(this, _class11); + + _RenderingTest4.apply(this, arguments); + } + + _class11.prototype['@test it should itterate over holes'] = function testItShouldItterateOverHoles(assert) { + var _this26 = this; + + var sparseArray = []; + sparseArray[3] = 'foo'; + sparseArray[4] = 'bar'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4), { list: _emberRuntime.A(sparseArray) }); + + this.assertText('[0:][1:][2:][3:foo][4:bar]'); + + this.assertStableRerender(); + + this.runTask(function () { + var list = _emberMetal.get(_this26.context, 'list'); + list.pushObject('baz'); + }); + + this.assertText('[0:][1:][2:][3:foo][4:bar][5:baz]'); + }; + + return _class11; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + /* globals MutationObserver: false */ + if (typeof MutationObserver === 'function') { + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each as}} DOM mutation test', (function (_RenderingTest5) { +babelHelpers.inherits(_class12, _RenderingTest5); + + function _class12() { +babelHelpers.classCallCheck(this, _class12); + + _RenderingTest5.call(this); + this.observer = null; + } + + _class12.prototype.observe = function observe(element) { + var observer = this.observer = new MutationObserver(function () {}); + observer.observe(element, { childList: true, characterData: true }); + }; + + _class12.prototype.teardown = function teardown() { + if (this.observer) { + this.observer.disconnect(); + } + + _RenderingTest5.prototype.teardown.call(this); + }; + + _class12.prototype.assertNoMutation = function assertNoMutation() { + this.assert.deepEqual(this.observer.takeRecords(), [], 'Expected no mutations'); + }; + + _class12.prototype.expectMutations = function expectMutations() { + this.assert.ok(this.observer.takeRecords().length > 0, 'Expected some mutations'); + }; + + _class12.prototype['@test {{#each}} should not mutate a subtree when the array has not changed [GH #14332]'] = function testEachShouldNotMutateASubtreeWhenTheArrayHasNotChangedGH14332(assert) { + var _this27 = this; + + var page = { title: 'Blog Posts' }; + + var model = [{ title: 'Rails is omakase' }, { title: 'Ember is omakase' }]; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5), { page: page, model: model }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6)); + + this.observe(this.$('#posts')[0]); + + // MutationObserver is async + return _emberRuntime.RSVP.Promise.resolve(function () { + _this27.assertStableRerender(); + }).then(function () { + _this27.assertNoMutation(); + + _this27.runTask(function () { + return _emberMetal.set(_this27.context, 'page', { title: 'Essays' }); + }); + + _this27.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7)); + }).then(function () { + _this27.assertNoMutation(); + + _this27.runTask(function () { + return _emberMetal.set(_this27.context.page, 'title', 'Think Pieces™'); + }); + + _this27.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8)); + }).then(function () { + // The last set is localized to the `page` object, so we do not expect Glimmer + // to re-iterate the list + _this27.assertNoMutation(); + }); + }; + + return _class12; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } +}); +enifed('ember-glimmer/tests/integration/syntax/each-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/each-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/each-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/if-unless-test', ['exports', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if cond}}\n {{#each numbers as |number|}}\n {{foo-bar number=number}}\n {{/each}}\n {{else}}\n Nothing Here!\n {{/if}}'], ['\n {{#if cond}}\n {{#each numbers as |number|}}\n {{foo-bar number=number}}\n {{/each}}\n {{else}}\n Nothing Here!\n {{/if}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if foo.bar.baz}}\n Here!\n {{else}}\n Nothing Here!\n {{/if}}'], ['\n {{#if foo.bar.baz}}\n Here!\n {{else}}\n Nothing Here!\n {{/if}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#if}} with inverse', (function (_IfUnlessWithSyntaxTest) { +babelHelpers.inherits(_class, _IfUnlessWithSyntaxTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _IfUnlessWithSyntaxTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#if ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/if}}'; + }; + + return _class; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#unless}} with inverse', (function (_IfUnlessWithSyntaxTest2) { +babelHelpers.inherits(_class2, _IfUnlessWithSyntaxTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _IfUnlessWithSyntaxTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{#unless ' + cond + '}}' + falsy + '{{else}}' + truthy + '{{/unless}}'; + }; + + return _class2; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#if}} and {{#unless}} without inverse', (function (_IfUnlessWithSyntaxTest3) { +babelHelpers.inherits(_class3, _IfUnlessWithSyntaxTest3); + + function _class3() { +babelHelpers.classCallCheck(this, _class3); + + _IfUnlessWithSyntaxTest3.apply(this, arguments); + } + + _class3.prototype.templateFor = function templateFor(_ref3) { + var cond = _ref3.cond; + var truthy = _ref3.truthy; + var falsy = _ref3.falsy; + + return '{{#if ' + cond + '}}' + truthy + '{{/if}}{{#unless ' + cond + '}}' + falsy + '{{/unless}}'; + }; + + return _class3; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#if}}', (function (_RenderingTest) { +babelHelpers.inherits(_class4, _RenderingTest); + + function _class4() { +babelHelpers.classCallCheck(this, _class4); + + _RenderingTest.apply(this, arguments); + } + + _class4.prototype['@test using `if` with an `{{each}}` destroys components when transitioning to and from inverse (GH #12267)'] = function testUsingIfWithAnEachDestroysComponentsWhenTransitioningToAndFromInverseGH12267(assert) { + var _this = this; + + var destroyedChildrenCount = 0; + + this.registerComponent('foo-bar', { + template: '{{number}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyedChildrenCount++; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { cond: true, numbers: _emberRuntime.A([1, 2, 3]) }); + + this.assertText('123'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('123'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond', false); + }); + + this.assertText('Nothing Here!'); + assert.equal(destroyedChildrenCount, 3, 'the children were properly destroyed'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond', true); + }); + + this.assertText('123'); + }; + + _class4.prototype['@test looking up `undefined` property defaults to false'] = function testLookingUpUndefinedPropertyDefaultsToFalse(assert) { + var _this2 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { foo: {} }); + + this.assertText('Nothing Here!'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Nothing Here!'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'foo', { bar: { baz: true } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'foo', {}); + }); + + this.assertText('Nothing Here!'); + }; + + return _class4; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/if-unless-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/if-unless-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/if-unless-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/in-element-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/component', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerComponent, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#-in-element someElement}}\n {{text}}\n {{/-in-element}}\n '], ['\n {{#-in-element someElement}}\n {{text}}\n {{/-in-element}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if showModal}}\n {{#-in-element someElement}}\n {{modal-display text=text}}\n {{/-in-element}}\n {{/if}}\n '], ['\n {{#if showModal}}\n {{#-in-element someElement}}\n {{modal-display text=text}}\n {{/-in-element}}\n {{/if}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{-in-element}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test allows rendering into an external element'] = function testAllowsRenderingIntoAnExternalElement(assert) { + var _this = this; + + var someElement = document.createElement('div'); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + someElement: someElement, + text: 'Whoop!' + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, 'Whoop!'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'text', 'Huzzah!!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, 'Huzzah!!'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'text', 'Whoop!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, 'Whoop!'); + }; + + _class.prototype['@test components are cleaned up properly'] = function testComponentsAreCleanedUpProperly(assert) { + var _this2 = this; + + var hooks = []; + + var someElement = document.createElement('div'); + + this.registerComponent('modal-display', { + ComponentClass: _emberGlimmerComponent.default.extend({ + didInsertElement: function () { + hooks.push('didInsertElement'); + }, + + willDestroyElement: function () { + hooks.push('willDestroyElement'); + } + }), + + template: '{{text}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + someElement: someElement, + text: 'Whoop!', + showModal: false + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, ''); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'showModal', true); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + this.assertComponentElement(someElement.firstChild, { content: 'Whoop!' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'text', 'Huzzah!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + this.assertComponentElement(someElement.firstChild, { content: 'Huzzah!' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'text', 'Whoop!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + this.assertComponentElement(someElement.firstChild, { content: 'Whoop!' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'showModal', false); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, ''); + + assert.deepEqual(hooks, ['didInsertElement', 'willDestroyElement']); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/in-element-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/in-element-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/in-element-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/with-dynamic-var-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#-with-dynamic-vars foo="bar"}}\n {{-get-dynamic-var \'foo\'}}\n {{/-with-dynamic-vars}}\n '], ['\n {{#-with-dynamic-vars foo="bar"}}\n {{-get-dynamic-var \'foo\'}}\n {{/-with-dynamic-vars}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#-with-dynamic-vars outletState="bar"}}\n {{-get-dynamic-var \'outletState\'}}\n {{/-with-dynamic-vars}}\n '], ['\n {{#-with-dynamic-vars outletState="bar"}}\n {{-get-dynamic-var \'outletState\'}}\n {{/-with-dynamic-vars}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{-with-dynamic-var}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test does not allow setting values other than outletState'] = function testDoesNotAllowSettingValuesOtherThanOutletState(assert) { + var _this = this; + + expectAssertion(function () { + _this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + }, /Using `-with-dynamic-scope` is only supported for `outletState` \(you used `foo`\)./); + }; + + _class.prototype['@test allows setting/getting outletState'] = function testAllowsSettingGettingOutletState(assert) { + // this is simply asserting that we can write and read outletState + // the actual value being used here is not what is used in real life + // feel free to change the value being set and asserted as needed + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertText('bar'); + }; + + _class.prototype['@test does not allow setting values other than outletState'] = function testDoesNotAllowSettingValuesOtherThanOutletState(assert) { + var _this2 = this; + + expectAssertion(function () { + _this2.render('{{-get-dynamic-var \'foo\'}}'); + }, /Using `-get-dynamic-scope` is only supported for `outletState` \(you used `foo`\)./); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/with-dynamic-var-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/with-dynamic-var-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/with-dynamic-var-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/with-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/shared-conditional-tests', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsSharedConditionalTests, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with foo.bar.baz as |thing|}}\n {{thing}}\n {{/with}}'], ['\n {{#with foo.bar.baz as |thing|}}\n {{thing}}\n {{/with}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{name}}\n {{#with committer1.name as |name|}}\n [{{name}}\n {{#with committer2.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n {{#with committer2.name as |name|}}\n [{{name}}\n {{#with committer1.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n '], ['\n {{name}}\n {{#with committer1.name as |name|}}\n [{{name}}\n {{#with committer2.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n {{#with committer2.name as |name|}}\n [{{name}}\n {{#with committer1.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#with}}', (function (_IfUnlessWithSyntaxTest) { +babelHelpers.inherits(_class, _IfUnlessWithSyntaxTest); + + function _class() { +babelHelpers.classCallCheck(this, _class); + + _IfUnlessWithSyntaxTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#with ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/with}}'; + }; + + return _class; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#with as}}', (function (_IfUnlessWithSyntaxTest2) { +babelHelpers.inherits(_class2, _IfUnlessWithSyntaxTest2); + + function _class2() { +babelHelpers.classCallCheck(this, _class2); + + _IfUnlessWithSyntaxTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{#with ' + cond + ' as |test|}}' + truthy + '{{else}}' + falsy + '{{/with}}'; + }; + + _class2.prototype['@test keying off of `undefined` does not render'] = function testKeyingOffOfUndefinedDoesNotRender(assert) { + var _this = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { foo: {} }); + + this.assertText(''); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'foo', { bar: { baz: 'Here!' } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'foo', {}); + }); + + this.assertText(''); + }; + + _class2.prototype['@test it renders and hides the given block based on the conditional'] = function testItRendersAndHidesTheGivenBlockBasedOnTheConditional() { + var _this2 = this; + + this.render('{{#with cond1 as |cond|}}{{cond.greeting}}{{else}}False{{/with}}', { + cond1: { greeting: 'Hello' } + }); + + this.assertText('Hello'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Hello'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1.greeting', 'Hello world'); + }); + + this.assertText('Hello world'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', false); + }); + + this.assertText('False'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', { greeting: 'Hello' }); + }); + + this.assertText('Hello'); + }; + + _class2.prototype['@test can access alias and original scope'] = function testCanAccessAliasAndOriginalScope() { + var _this3 = this; + + this.render('{{#with person as |tom|}}{{title}}: {{tom.name}}{{/with}}', { + title: 'Señor Engineer', + person: { name: 'Tom Dale' } + }); + + this.assertText('Señor Engineer: Tom Dale'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Señor Engineer: Tom Dale'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'person.name', 'Yehuda Katz'); + _emberMetal.set(_this3.context, 'title', 'Principal Engineer'); + }); + + this.assertText('Principal Engineer: Yehuda Katz'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'person', { name: 'Tom Dale' }); + _emberMetal.set(_this3.context, 'title', 'Señor Engineer'); + }); + + this.assertText('Señor Engineer: Tom Dale'); + }; + + _class2.prototype['@test the scoped variable is not available outside the {{#with}} block.'] = function testTheScopedVariableIsNotAvailableOutsideTheWithBlock() { + var _this4 = this; + + this.render('{{name}}-{{#with other as |name|}}{{name}}{{/with}}-{{name}}', { + name: 'Stef', + other: 'Yehuda' + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'other', 'Chad'); + }); + + this.assertText('Stef-Chad-Stef'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'name', 'Tom'); + }); + + this.assertText('Tom-Chad-Tom'); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'name', 'Stef'); + _emberMetal.set(_this4.context, 'other', 'Yehuda'); + }); + + this.assertText('Stef-Yehuda-Stef'); + }; + + _class2.prototype['@test inverse template is displayed with context'] = function testInverseTemplateIsDisplayedWithContext() { + var _this5 = this; + + this.render('{{#with falsyThing as |thing|}}Has Thing{{else}}No Thing {{otherThing}}{{/with}}', { + falsyThing: null, + otherThing: 'bar' + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'otherThing', 'biz'); + }); + + this.assertText('No Thing biz'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'falsyThing', true); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'otherThing', 'baz'); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'otherThing', 'bar'); + _emberMetal.set(_this5.context, 'falsyThing', null); + }); + + this.assertText('No Thing bar'); + }; + + _class2.prototype['@test can access alias of a proxy'] = function testCanAccessAliasOfAProxy() { + var _this6 = this; + + this.render('{{#with proxy as |person|}}{{person.name}}{{/with}}', { + proxy: _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } }) + }); + + this.assertText('Tom Dale'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('Tom Dale'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.name', 'Yehuda Katz'); + }); + + this.assertText('Yehuda Katz'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.content', { name: 'Godfrey Chan' }); + }); + + this.assertText('Godfrey Chan'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.content.name', 'Stefan Penner'); + }); + + this.assertText('Stefan Penner'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.content', null); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } })); + }); + + this.assertText('Tom Dale'); + }; + + _class2.prototype['@test can access alias of an array'] = function testCanAccessAliasOfAnArray() { + var _this7 = this; + + this.render('{{#with arrayThing as |words|}}{{#each words as |word|}}{{word}}{{/each}}{{/with}}', { + arrayThing: _emberRuntime.A(['Hello', ' ', 'world']) + }); + + this.assertText('Hello world'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('Hello world'); + + this.runTask(function () { + var array = _emberMetal.get(_this7.context, 'arrayThing'); + array.replace(0, 1, 'Goodbye'); + _emberRuntime.removeAt(array, 1); + array.insertAt(1, ', '); + array.pushObject('!'); + }); + + this.assertText('Goodbye, world!'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'arrayThing', ['Hello', ' ', 'world']); + }); + + this.assertText('Hello world'); + }; + + _class2.prototype['@test `attrs` can be used as a block param [GH#14678]'] = function testAttrsCanBeUsedAsABlockParamGH14678() { + var _this8 = this; + + this.render('{{#with hash as |attrs|}}[{{hash.foo}}-{{attrs.foo}}]{{/with}}', { + hash: { foo: 'foo' } + }); + + this.assertText('[foo-foo]'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('[foo-foo]'); + + this.runTask(function () { + return _this8.context.set('hash.foo', 'FOO'); + }); + + this.assertText('[FOO-FOO]'); + + this.runTask(function () { + return _this8.context.set('hash.foo', 'foo'); + }); + + this.assertText('[foo-foo]'); + }; + + return _class2; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: Multiple {{#with as}} helpers', (function (_RenderingTest) { +babelHelpers.inherits(_class3, _RenderingTest); + + function _class3() { +babelHelpers.classCallCheck(this, _class3); + + _RenderingTest.apply(this, arguments); + } + + _class3.prototype['@test re-using the same variable with different {{#with}} blocks does not override each other'] = function testReUsingTheSameVariableWithDifferentWithBlocksDoesNotOverrideEachOther() { + var _this9 = this; + + this.render('Admin: {{#with admin as |person|}}{{person.name}}{{/with}} User: {{#with user as |person|}}{{person.name}}{{/with}}', { + admin: { name: 'Tom Dale' }, + user: { name: 'Yehuda Katz' } + }); + + this.assertText('Admin: Tom Dale User: Yehuda Katz'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('Admin: Tom Dale User: Yehuda Katz'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'admin.name', 'Godfrey Chan'); + _emberMetal.set(_this9.context, 'user.name', 'Stefan Penner'); + }); + + this.assertText('Admin: Godfrey Chan User: Stefan Penner'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'admin', { name: 'Tom Dale' }); + _emberMetal.set(_this9.context, 'user', { name: 'Yehuda Katz' }); + }); + + this.assertText('Admin: Tom Dale User: Yehuda Katz'); + }; + + _class3.prototype['@test the scoped variable is not available outside the {{#with}} block'] = function testTheScopedVariableIsNotAvailableOutsideTheWithBlock() { + var _this10 = this; + + this.render('{{ring}}-{{#with first as |ring|}}{{ring}}-{{#with fifth as |ring|}}{{ring}}-{{#with ninth as |ring|}}{{ring}}-{{/with}}{{ring}}-{{/with}}{{ring}}-{{/with}}{{ring}}', { + ring: 'Greed', + first: 'Limbo', + fifth: 'Wrath', + ninth: 'Treachery' + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'ring', 'O'); + _emberMetal.set(_this10.context, 'fifth', 'D'); + }); + + this.assertText('O-Limbo-D-Treachery-D-Limbo-O'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'first', 'I'); + _emberMetal.set(_this10.context, 'ninth', 'K'); + }); + + this.assertText('O-I-D-K-D-I-O'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'ring', 'Greed'); + _emberMetal.set(_this10.context, 'first', 'Limbo'); + _emberMetal.set(_this10.context, 'fifth', 'Wrath'); + _emberMetal.set(_this10.context, 'ninth', 'Treachery'); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + }; + + _class3.prototype['@test it should support {{#with name as |foo|}}, then {{#with foo as |bar|}}'] = function testItShouldSupportWithNameAsFooThenWithFooAsBar() { + var _this11 = this; + + this.render('{{#with name as |foo|}}{{#with foo as |bar|}}{{bar}}{{/with}}{{/with}}', { + name: 'caterpillar' + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'name', 'butterfly'); + }); + + this.assertText('butterfly'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'name', 'caterpillar'); + }); + + this.assertText('caterpillar'); + }; + + _class3.prototype['@test updating the context should update the alias'] = function testUpdatingTheContextShouldUpdateTheAlias() { + var _this12 = this; + + this.render('{{#with this as |person|}}{{person.name}}{{/with}}', { + name: 'Los Pivots' + }); + + this.assertText('Los Pivots'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('Los Pivots'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'name', 'l\'Pivots'); + }); + + this.assertText('l\'Pivots'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'name', 'Los Pivots'); + }); + + this.assertText('Los Pivots'); + }; + + _class3.prototype['@test nested {{#with}} blocks should have access to root context'] = function testNestedWithBlocksShouldHaveAccessToRootContext() { + var _this13 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + name: 'ebryn', + committer1: { name: 'trek' }, + committer2: { name: 'machty' } + }); + + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'name', 'chancancode'); + }); + + this.assertText('chancancode[trek[machty]trek]chancancode[machty[trek]machty]chancancode'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'committer1', { name: 'krisselden' }); + }); + + this.assertText('chancancode[krisselden[machty]krisselden]chancancode[machty[krisselden]machty]chancancode'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'committer1.name', 'wycats'); + _emberMetal.set(_this13.context, 'committer2', { name: 'rwjblue' }); + }); + + this.assertText('chancancode[wycats[rwjblue]wycats]chancancode[rwjblue[wycats]rwjblue]chancancode'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'name', 'ebryn'); + _emberMetal.set(_this13.context, 'committer1', { name: 'trek' }); + _emberMetal.set(_this13.context, 'committer2', { name: 'machty' }); + }); + + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); + }; + + return _class3; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/with-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/with-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/with-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/layout-cache-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/test-case', '@glimmer/runtime'], function (exports, _emberUtils, _emberGlimmerTestsUtilsTestCase, _glimmerRuntime) { + 'use strict'; + + var Counter = (function () { + function Counter() { + babelHelpers.classCallCheck(this, Counter); + + this.reset(); + } + + Counter.prototype.increment = function increment(key) { + this.total++; + return this.counts[key] = (this.counts[key] || 0) + 1; + }; + + Counter.prototype.get = function get(key) { + return this.counts[key] || 0; + }; + + Counter.prototype.reset = function reset() { + this.total = 0; + this.counts = new _emberUtils.EmptyObject(); + }; + + return Counter; + })(); + + var COUNTER = new Counter(); + + var BasicCompiler = (function () { + function BasicCompiler(template) { + babelHelpers.classCallCheck(this, BasicCompiler); + + this.template = template; + } + + BasicCompiler.prototype.compile = function compile(builder) { + var template = this.template; + + COUNTER.increment(this.constructor.id + '+' + template.id); + builder.wrapLayout(template.asLayout()); + }; + + return BasicCompiler; + })(); + + var TypeOneCompiler = (function (_BasicCompiler) { + babelHelpers.inherits(TypeOneCompiler, _BasicCompiler); + + function TypeOneCompiler() { + babelHelpers.classCallCheck(this, TypeOneCompiler); + + _BasicCompiler.apply(this, arguments); + } + + return TypeOneCompiler; + })(BasicCompiler); + + var TypeTwoCompiler = (function (_BasicCompiler2) { + babelHelpers.inherits(TypeTwoCompiler, _BasicCompiler2); + + function TypeTwoCompiler() { + babelHelpers.classCallCheck(this, TypeTwoCompiler); + + _BasicCompiler2.apply(this, arguments); + } + + return TypeTwoCompiler; + })(BasicCompiler); + + TypeOneCompiler.id = 'type-one'; + TypeTwoCompiler.id = 'type-two'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Layout cache test', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.call(this); + COUNTER.reset(); + } + + _class.prototype.templateFor = function templateFor(content) { + var Factory = this.compile(content); + return this.env.getTemplate(Factory, this.owner); + }; + + _class.prototype['@test each template is only compiled once'] = function testEachTemplateIsOnlyCompiledOnce(assert) { + var env = this.env; + + var template1 = this.templateFor('Hello world!'); + var template2 = this.templateFor('{{foo}} {{bar}}'); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 1); + assert.strictEqual(COUNTER.total, 2); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 1); + assert.strictEqual(COUNTER.total, 2); + }; + + _class.prototype['@test each template/compiler pair is treated as unique'] = function testEachTemplateCompilerPairIsTreatedAsUnique(assert) { + var env = this.env; + + var template = this.templateFor('Hello world!'); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 1); + assert.strictEqual(COUNTER.total, 2); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 1); + assert.strictEqual(COUNTER.total, 2); + }; + + _class.prototype['@test a template instance is returned (ensures templates can be injected into layout property)'] = function testATemplateInstanceIsReturnedEnsuresTemplatesCanBeInjectedIntoLayoutProperty(assert) { + var _this = this; + + var owner = this.owner; + var env = this.env; + + var templateInstanceFor = function (content) { + var _Factory$create; + + var Factory = _this.compile(content); + return Factory.create((_Factory$create = {}, _Factory$create[_emberUtils.OWNER] = owner, _Factory$create.env = env, _Factory$create)); + }; + + var template1 = templateInstanceFor('Hello world!'); + var template2 = templateInstanceFor('{{foo}} {{bar}}'); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/unit/layout-cache-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/layout-cache-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/layout-cache-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/outlet-test', ['exports', 'ember-glimmer/views/outlet', 'ember-metal'], function (exports, _emberGlimmerViewsOutlet, _emberMetal) { + 'use strict'; + + QUnit.module('Glimmer OutletView'); + + QUnit.test('render in the render queue', function (assert) { + var didAppendOutletView = 0; + var expectedOutlet = '#foo.bar'; + + var renderer = { + appendOutletView: function (view, target) { + didAppendOutletView++; + assert.equal(view, outletView); + assert.equal(target, expectedOutlet); + } + }; + + var outletView = new _emberGlimmerViewsOutlet.default({}, renderer); + + _emberMetal.run(function () { + assert.equal(didAppendOutletView, 0, 'appendOutletView should not yet have been called (before appendTo)'); + outletView.appendTo(expectedOutlet); + assert.equal(didAppendOutletView, 0, 'appendOutletView should not yet have been called (sync after appendTo)'); + + _emberMetal.run.schedule('actions', function () { + return assert.equal(didAppendOutletView, 0, 'appendOutletView should not yet have been called (in actions)'); + }); + _emberMetal.run.schedule('render', function () { + return assert.equal(didAppendOutletView, 1, 'appendOutletView should be invoked in render'); + }); + }); + }); +}); +enifed('ember-glimmer/tests/unit/outlet-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/outlet-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/outlet-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/template-factory-test', ['exports', 'ember-template-compiler', 'ember-glimmer/index', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberTemplateCompiler, _emberGlimmerIndex, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Template factory test', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test the template factory returned from precompile is the same as compile'] = function testTheTemplateFactoryReturnedFromPrecompileIsTheSameAsCompile(assert) { + var env = this.env; + + var templateStr = 'Hello {{name}}'; + var options = { moduleName: 'some-module' }; + + var spec = _emberTemplateCompiler.precompile(templateStr, options); + var body = 'exports.default = template(' + spec + ');'; + var module = new Function('exports', 'template', body); + var exports = {}; + module(exports, _emberGlimmerIndex.template); + var Precompiled = exports['default']; + + var Compiled = _emberTemplateCompiler.compile(templateStr, options); + + assert.equal(typeof Precompiled.create, 'function', 'precompiled is a factory'); + assert.ok(Precompiled.id, 'precompiled has id'); + + assert.equal(typeof Compiled.create, 'function', 'compiled is a factory'); + assert.ok(Compiled.id, 'compiled has id'); + + assert.equal(env._templateCache.misses, 0, 'misses 0'); + assert.equal(env._templateCache.hits, 0, 'hits 0'); + + var precompiled = env.getTemplate(Precompiled, env.owner); + + assert.equal(env._templateCache.misses, 1, 'misses 1'); + assert.equal(env._templateCache.hits, 0, 'hits 0'); + + var compiled = env.getTemplate(Compiled, env.owner); + + assert.equal(env._templateCache.misses, 2, 'misses 2'); + assert.equal(env._templateCache.hits, 0, 'hits 0'); + + assert.ok(typeof precompiled.spec !== 'string', 'Spec has been parsed'); + assert.ok(typeof compiled.spec !== 'string', 'Spec has been parsed'); + + this.registerComponent('x-precompiled', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: Precompiled + }) + }); + + this.registerComponent('x-compiled', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: Compiled + }) + }); + + this.render('{{x-precompiled name="precompiled"}} {{x-compiled name="compiled"}}'); + + assert.equal(env._templateCache.misses, 2, 'misses 2'); + assert.equal(env._templateCache.hits, 2, 'hits 2'); + + this.assertText('Hello precompiled Hello compiled'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/unit/template-factory-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/template-factory-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/template-factory-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/utils/debug-stack-test', ['exports', 'ember-glimmer/utils/debug-stack', 'ember-metal'], function (exports, _emberGlimmerUtilsDebugStack, _emberMetal) { + 'use strict'; + + _emberMetal.runInDebug(function () { + QUnit.module('Glimmer DebugStack'); + + QUnit.test('pushing and popping', function (assert) { + var stack = new _emberGlimmerUtilsDebugStack.default(); + + assert.equal(stack.peek(), undefined); + + stack.push('template:application'); + + assert.equal(stack.peek(), '"template:application"'); + + stack.push('component:top-level-component'); + + assert.equal(stack.peek(), '"component:top-level-component"'); + + stack.pushEngine('engine:my-engine'); + stack.push('component:component-in-engine'); + + assert.equal(stack.peek(), '"component:component-in-engine" (in "engine:my-engine")'); + + stack.pop(); + stack.pop(); + var item = stack.pop(); + + assert.equal(item, 'component:top-level-component'); + assert.equal(stack.peek(), '"template:application"'); + }); + }); +}); +enifed('ember-glimmer/tests/unit/utils/debug-stack-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/utils/debug-stack-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/utils/debug-stack-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/utils/iterable-test', ['exports', 'ember', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', '@glimmer/runtime'], function (exports, _ember, _emberGlimmerTestsUtilsTestCase, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerRuntime) { + 'use strict'; + + var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Iterable', (function (_TestCase) { + babelHelpers.inherits(_class, _TestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _TestCase.apply(this, arguments); + } + + _class.prototype['@test iterates over an array'] = function testIteratesOverAnArray() { + var iterator = iteratorForArray(['foo', 'bar']); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test iterates over an `Ember.A`'] = function testIteratesOverAnEmberA() { + var iterator = iteratorForArray(_ember.default.A(['foo', 'bar'])); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test returns `null` when out of items'] = function testReturnsNullWhenOutOfItems() { + var iterator = iteratorForArray(['foo']); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), null); + }; + + _class.prototype['@test iterates over an array with indices as keys'] = function testIteratesOverAnArrayWithIndicesAsKeys() { + var iterator = iteratorForArray(['foo', 'bar'], '@index'); + + this.assert.deepEqual(iterator.next(), { key: '0', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: '1', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test iterates over an array with identities as keys'] = function testIteratesOverAnArrayWithIdentitiesAsKeys() { + var iterator = iteratorForArray(['foo', 'bar'], '@identity'); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test iterates over an array with arbitrary properties as keys'] = function testIteratesOverAnArrayWithArbitraryPropertiesAsKeys() { + var iterator = iteratorForArray([{ k: 'first', v: 'foo' }, { k: 'second', v: 'bar' }], 'k'); + + this.assert.deepEqual(iterator.next(), { key: 'first', memo: 0, value: { k: 'first', v: 'foo' } }); + this.assert.deepEqual(iterator.next(), { key: 'second', memo: 1, value: { k: 'second', v: 'bar' } }); + }; + + _class.prototype['@test errors on `#next` with an undefined ref'] = function testErrorsOnNextWithAnUndefinedRef() { + var iterator = iteratorForArray(undefined); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref) { + var _message = _ref.message; + + this.assert.equal(_message, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test errors on `#next` with a null ref'] = function testErrorsOnNextWithANullRef() { + var iterator = iteratorForArray(null); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref2) { + var _message2 = _ref2.message; + + this.assert.equal(_message2, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test errors on `#next` with an invalid ref type'] = function testErrorsOnNextWithAnInvalidRefType() { + var iterator = iteratorForArray('string'); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref3) { + var _message3 = _ref3.message; + + this.assert.equal(_message3, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test errors on `#next` with an empty array'] = function testErrorsOnNextWithAnEmptyArray() { + var iterator = iteratorForArray([]); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref4) { + var _message4 = _ref4.message; + + this.assert.equal(_message4, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test iterates over an object\'s own properties'] = function testIteratesOverAnObjectSOwnProperties() { + var iterator = iteratorForObject({ first: 'foo', second: 'bar' }); + + this.assert.deepEqual(iterator.next(), { key: 'first', memo: 'first', value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'second', memo: 'second', value: 'bar' }); + }; + + _class.prototype['@test iterates over an object\'s own properties with indices as keys'] = function testIteratesOverAnObjectSOwnPropertiesWithIndicesAsKeys() { + var iterator = iteratorForObject({ first: 'foo', second: 'bar' }, '@index'); + + this.assert.deepEqual(iterator.next(), { key: 'first', memo: 'first', value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'second', memo: 'second', value: 'bar' }); + }; + + _class.prototype['@test iterates over an object\'s own properties with identities as keys'] = function testIteratesOverAnObjectSOwnPropertiesWithIdentitiesAsKeys() { + var iterator = iteratorForObject({ first: 'foo', second: 'bar' }, '@identity'); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 'first', value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 'second', value: 'bar' }); + }; + + _class.prototype['@test iterates over an object\'s own properties with arbitrary properties as keys'] = function testIteratesOverAnObjectSOwnPropertiesWithArbitraryPropertiesAsKeys() { + var iterator = iteratorForObject({ first: { k: 'uno', v: 'foo' }, second: { k: 'dos', v: 'bar' } }, 'k'); + + this.assert.deepEqual(iterator.next(), { key: 'uno', memo: 'first', value: { k: 'uno', v: 'foo' } }); + this.assert.deepEqual(iterator.next(), { key: 'dos', memo: 'second', value: { k: 'dos', v: 'bar' } }); + }; + + _class.prototype['@test each-in errors on `#next` with an undefined ref'] = function testEachInErrorsOnNextWithAnUndefinedRef() { + var iterator = iteratorForObject(undefined); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref5) { + var _message5 = _ref5.message; + + this.assert.equal(_message5, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test each-in errors on `#next` with a null ref'] = function testEachInErrorsOnNextWithANullRef() { + var iterator = iteratorForObject(null); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref6) { + var _message6 = _ref6.message; + + this.assert.equal(_message6, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test each-in errors on `#next` with an invalid ref type'] = function testEachInErrorsOnNextWithAnInvalidRefType() { + var iterator = iteratorForObject('string'); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref7) { + var _message7 = _ref7.message; + + this.assert.equal(_message7, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test ensures keys are unique'] = function testEnsuresKeysAreUnique() { + var iterator = iteratorForArray([{ k: 'qux', v: 'foo' }, { k: 'qux', v: 'bar' }, { k: 'qux', v: 'baz' }], 'k'); + + this.assert.deepEqual(iterator.next(), { key: 'qux', memo: 0, value: { k: 'qux', v: 'foo' } }); + this.assert.deepEqual(iterator.next(), { key: 'qux' + ITERATOR_KEY_GUID + '1', memo: 1, value: { k: 'qux', v: 'bar' } }); + this.assert.deepEqual(iterator.next(), { key: 'qux' + ITERATOR_KEY_GUID + '2', memo: 2, value: { k: 'qux', v: 'baz' } }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.TestCase)); + + function iteratorForArray(arr, keyPath) { + var ref = new _emberGlimmerUtilsReferences.UpdatableReference(arr); + var iterable = _emberGlimmerUtilsIterable.default(ref, keyPath); + + return iterable.iterate(); + } + + function iteratorForObject(obj, keyPath) { + var vm = null; + var positionalArgs = _glimmerRuntime.EvaluatedPositionalArgs.create([new _emberGlimmerUtilsReferences.UpdatableReference(obj)]); + var ref = _emberGlimmerHelpersEachIn.default(vm, { positional: positionalArgs }); + var iterable = _emberGlimmerUtilsIterable.default(ref, keyPath); + + return iterable.iterate(); + } +}); +enifed('ember-glimmer/tests/unit/utils/iterable-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/utils/iterable-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/utils/iterable-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/abstract-test-case', ['exports', 'internal-test-helpers'], function (exports, _internalTestHelpers) { + 'use strict'; + + exports.TestCase = _internalTestHelpers.AbstractTestCase; + exports.applyMixins = _internalTestHelpers.applyMixins; + exports.strip = _internalTestHelpers.strip; +}); +enifed('ember-glimmer/tests/utils/abstract-test-case.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/abstract-test-case.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/abstract-test-case.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/helpers', ['exports', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + exports.compile = _emberTemplateCompiler.compile; + exports.precompile = _emberTemplateCompiler.precompile; + exports.INVOKE = _emberGlimmer.INVOKE; + exports.Helper = _emberGlimmer.Helper; + exports.helper = _emberGlimmer.helper; + exports.Component = _emberGlimmer.Component; + exports.TextArea = _emberGlimmer.TextArea; + exports.LinkComponent = _emberGlimmer.LinkComponent; + exports.TextField = _emberGlimmer.TextField; + exports.InteractiveRender = _emberGlimmer.InteractiveRender; + exports.InertRenderer = _emberGlimmer.InertRenderer; + exports.makeBoundHelper = _emberGlimmer.makeBoundHelper; + exports.htmlSafe = _emberGlimmer.htmlSafe; + exports.SafeString = _emberGlimmer.SafeString; + exports.DOMChanges = _emberGlimmer.DOMChanges; + exports.isHTMLSafe = _emberGlimmer.isHTMLSafe; +}); +enifed('ember-glimmer/tests/utils/helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/shared-conditional-tests', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberUtils, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + var _ObjectTestCases, _ArrayTestCases; + + var AbstractConditionalsTest = (function (_RenderingTest) { + babelHelpers.inherits(AbstractConditionalsTest, _RenderingTest); + + function AbstractConditionalsTest() { + babelHelpers.classCallCheck(this, AbstractConditionalsTest); + + _RenderingTest.apply(this, arguments); + } + + AbstractConditionalsTest.prototype.wrapperFor = function wrapperFor(templates) { + return templates.join(''); + }; + + AbstractConditionalsTest.prototype.wrappedTemplateFor = function wrappedTemplateFor(options) { + return this.wrapperFor([this.templateFor(options)]); + }; + + /* abstract */ + + AbstractConditionalsTest.prototype.templateFor = function templateFor(_ref5) { + var cond = _ref5.cond; + var truthy = _ref5.truthy; + var falsy = _ref5.falsy; + + // e.g. `{{#if ${cond}}}${truthy}{{else}}${falsy}{{/if}}` + throw new Error('Not implemented: `templateFor`'); + }; + + /* abstract */ + + AbstractConditionalsTest.prototype.renderValues = function renderValues() { + throw new Error('Not implemented: `renderValues`'); + }; + + babelHelpers.createClass(AbstractConditionalsTest, [{ + key: 'truthyValue', + get: function () { + return true; + } + }, { + key: 'falsyValue', + get: function () { + return false; + } + }]); + return AbstractConditionalsTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var AbstractGenerator = (function () { + function AbstractGenerator(cases) { + babelHelpers.classCallCheck(this, AbstractGenerator); + + this.cases = cases; + } + + /* + The test cases in this file generally follow the following pattern: + + 1. Render with [ truthy, ...(other truthy variations), falsy, ...(other falsy variations) ] + 2. No-op rerender + 3. Make all of them falsy (through interior mutation) + 4. Make all of them truthy (through interior mutation, sometimes with some slight variations) + 5. Reset them to their original values (through replacement) + */ + + /* abstract */ + + AbstractGenerator.prototype.generate = function generate(value, idx) { + throw new Error('Not implemented: `generate`'); + }; + + return AbstractGenerator; + })(); + + var TruthyGenerator = (function (_AbstractGenerator) { + babelHelpers.inherits(TruthyGenerator, _AbstractGenerator); + + function TruthyGenerator() { + babelHelpers.classCallCheck(this, TruthyGenerator); + + _AbstractGenerator.apply(this, arguments); + } + + TruthyGenerator.prototype.generate = function generate(value, idx) { + var _ref; + + return _ref = {}, _ref['@test it should consider ' + JSON.stringify(value) + ' truthy [' + idx + ']'] = function () { + var _this = this; + + this.renderValues(value); + + this.assertText('T1'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond1', _this.falsyValue); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond1', value); + }); + + this.assertText('T1'); + }, _ref; + }; + + return TruthyGenerator; + })(AbstractGenerator); + + exports.TruthyGenerator = TruthyGenerator; + + var FalsyGenerator = (function (_AbstractGenerator2) { + babelHelpers.inherits(FalsyGenerator, _AbstractGenerator2); + + function FalsyGenerator() { + babelHelpers.classCallCheck(this, FalsyGenerator); + + _AbstractGenerator2.apply(this, arguments); + } + + FalsyGenerator.prototype.generate = function generate(value, idx) { + var _ref2; + + return _ref2 = {}, _ref2['@test it should consider ' + JSON.stringify(value) + ' falsy [' + idx + ']'] = function () { + var _this2 = this; + + this.renderValues(value); + + this.assertText('F1'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', _this2.truthyValue); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', value); + }); + + this.assertText('F1'); + }, _ref2; + }; + + return FalsyGenerator; + })(AbstractGenerator); + + exports.FalsyGenerator = FalsyGenerator; + + var StableTruthyGenerator = (function (_TruthyGenerator) { + babelHelpers.inherits(StableTruthyGenerator, _TruthyGenerator); + + function StableTruthyGenerator() { + babelHelpers.classCallCheck(this, StableTruthyGenerator); + + _TruthyGenerator.apply(this, arguments); + } + + StableTruthyGenerator.prototype.generate = function generate(value, idx) { + var _assign; + + return _emberUtils.assign(_TruthyGenerator.prototype.generate.call(this, value, idx), (_assign = {}, _assign['@test it maintains DOM stability when condition changes from ' + value + ' to another truthy value and back [' + idx + ']'] = function () { + var _this3 = this; + + this.renderValues(value); + + this.assertText('T1'); + + this.takeSnapshot(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'cond1', _this3.truthyValue); + }); + + this.assertText('T1'); + + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'cond1', value); + }); + + this.assertText('T1'); + + this.assertInvariants(); + }, _assign)); + }; + + return StableTruthyGenerator; + })(TruthyGenerator); + + exports.StableTruthyGenerator = StableTruthyGenerator; + + var StableFalsyGenerator = (function (_FalsyGenerator) { + babelHelpers.inherits(StableFalsyGenerator, _FalsyGenerator); + + function StableFalsyGenerator() { + babelHelpers.classCallCheck(this, StableFalsyGenerator); + + _FalsyGenerator.apply(this, arguments); + } + + StableFalsyGenerator.prototype.generate = function generate(value, idx) { + var _assign2; + + return _emberUtils.assign(_FalsyGenerator.prototype.generate.call(this, value), (_assign2 = {}, _assign2['@test it maintains DOM stability when condition changes from ' + value + ' to another falsy value and back [' + idx + ']'] = function () { + var _this4 = this; + + this.renderValues(value); + + this.assertText('F1'); + + this.takeSnapshot(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'cond1', _this4.falsyValue); + }); + + this.assertText('F1'); + + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'cond1', value); + }); + + this.assertText('F1'); + + this.assertInvariants(); + }, _assign2)); + }; + + return StableFalsyGenerator; + })(FalsyGenerator); + + exports.StableFalsyGenerator = StableFalsyGenerator; + + var ObjectProxyGenerator = (function (_AbstractGenerator3) { + babelHelpers.inherits(ObjectProxyGenerator, _AbstractGenerator3); + + function ObjectProxyGenerator() { + babelHelpers.classCallCheck(this, ObjectProxyGenerator); + + _AbstractGenerator3.apply(this, arguments); + } + + // Testing behaviors shared across all conditionals, i.e. {{#if}}, {{#unless}}, + // {{#with}}, {{#each}}, {{#each-in}}, (if) and (unless) + + ObjectProxyGenerator.prototype.generate = function generate(value, idx) { + // This is inconsistent with our usual to-bool policy, but the current proxy implementation + // simply uses !!content to determine truthiness + if (value) { + var _ref3; + + return _ref3 = {}, _ref3['@test it should consider an object proxy with `' + JSON.stringify(value) + '` truthy [' + idx + ']'] = function () { + var _this5 = this; + + this.renderValues(_emberRuntime.ObjectProxy.create({ content: value })); + + this.assertText('T1'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'cond1.content', _this5.falsyValue); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'cond1', _emberRuntime.ObjectProxy.create({ content: value })); + }); + + this.assertText('T1'); + }, _ref3; + } else { + var _ref4; + + return _ref4 = {}, _ref4['@test it should consider an object proxy with `' + JSON.stringify(value) + '` falsy [' + idx + ']'] = function () { + var _this6 = this; + + this.renderValues(_emberRuntime.ObjectProxy.create({ content: value })); + + this.assertText('F1'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'cond1.content', _this6.truthyValue); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'cond1', _emberRuntime.ObjectProxy.create({ content: value })); + }); + + this.assertText('F1'); + }, _ref4; + } + }; + + return ObjectProxyGenerator; + })(AbstractGenerator); + + var BasicConditionalsTest = (function (_AbstractConditionalsTest) { + babelHelpers.inherits(BasicConditionalsTest, _AbstractConditionalsTest); + + function BasicConditionalsTest() { + babelHelpers.classCallCheck(this, BasicConditionalsTest); + + _AbstractConditionalsTest.apply(this, arguments); + } + + // Testing behaviors related to ember objects, object proxies, etc + + BasicConditionalsTest.prototype['@test it renders the corresponding block based on the conditional'] = function testItRendersTheCorrespondingBlockBasedOnTheConditional() { + var _this7 = this; + + this.renderValues(this.truthyValue, this.falsyValue); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'cond1', _this7.falsyValue); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.set(_this7.context, 'cond1', _this7.truthyValue); + _emberMetal.set(_this7.context, 'cond2', _this7.truthyValue); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this7.context, 'cond1', _this7.truthyValue); + _emberMetal.set(_this7.context, 'cond2', _this7.falsyValue); + }); + + this.assertText('T1F2'); + }; + + return BasicConditionalsTest; + })(AbstractConditionalsTest); + + exports.BasicConditionalsTest = BasicConditionalsTest; + var ObjectTestCases = (_ObjectTestCases = {}, _ObjectTestCases['@test it considers object proxies without content falsy'] = function () { + var _this8 = this; + + this.renderValues(_emberRuntime.ObjectProxy.create({ content: {} }), _emberRuntime.ObjectProxy.create({ content: _emberRuntime.Object.create() }), _emberRuntime.ObjectProxy.create({ content: null })); + + this.assertText('T1T2F3'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('T1T2F3'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'cond1.content', null); + _emberMetal.set(_this8.context, 'cond2.content', null); + }); + + this.assertText('F1F2F3'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'cond1.content', _emberRuntime.Object.create()); + _emberMetal.set(_this8.context, 'cond2.content', {}); + _emberMetal.set(_this8.context, 'cond3.content', { foo: 'bar' }); + }); + + this.assertText('T1T2T3'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'cond1', _emberRuntime.ObjectProxy.create({ content: {} })); + _emberMetal.set(_this8.context, 'cond2', _emberRuntime.ObjectProxy.create({ content: _emberRuntime.Object.create() })); + _emberMetal.set(_this8.context, 'cond3', _emberRuntime.ObjectProxy.create({ content: null })); + }); + + this.assertText('T1T2F3'); + }, _ObjectTestCases); + + exports.ObjectTestCases = ObjectTestCases; + // Testing behaviors related to arrays and array proxies + var ArrayTestCases = (_ArrayTestCases = {}, _ArrayTestCases['@test it considers empty arrays falsy'] = function () { + var _this9 = this; + + this.renderValues(_emberRuntime.A(['hello']), _emberRuntime.A()); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberRuntime.removeAt(_emberMetal.get(_this9.context, 'cond1'), 0); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.get(_this9.context, 'cond1').pushObject('hello'); + _emberMetal.get(_this9.context, 'cond2').pushObjects([1]); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'cond1', _emberRuntime.A(['hello'])); + _emberMetal.set(_this9.context, 'cond2', _emberRuntime.A()); + }); + + this.assertText('T1F2'); + }, _ArrayTestCases['@test it considers array proxies without content falsy'] = function () { + var _this10 = this; + + this.renderValues(_emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) }), _emberRuntime.ArrayProxy.create({ content: null })); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond1.content', null); + _emberMetal.set(_this10.context, 'cond2.content', null); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond1.content', _emberRuntime.A(['hello'])); + _emberMetal.set(_this10.context, 'cond2.content', _emberRuntime.A([1])); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond1', _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) })); + _emberMetal.set(_this10.context, 'cond2', _emberRuntime.ArrayProxy.create({ content: null })); + }); + + this.assertText('T1F2'); + }, _ArrayTestCases['@test it considers array proxies with empty arrays falsy'] = function () { + var _this11 = this; + + this.renderValues(_emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) }), _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A() })); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberRuntime.removeAt(_emberMetal.get(_this11.context, 'cond1.content'), 0); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.get(_this11.context, 'cond1.content').pushObject('hello'); + _emberMetal.get(_this11.context, 'cond2.content').pushObjects([1]); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'cond1', _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) })); + _emberMetal.set(_this11.context, 'cond2', _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A() })); + }); + + this.assertText('T1F2'); + }, _ArrayTestCases); + + exports.ArrayTestCases = ArrayTestCases; + var IfUnlessWithTestCases = [new StableTruthyGenerator([true, ' ', 'hello', 'false', 'null', 'undefined', 1, ['hello'], _emberRuntime.A(['hello']), {}, { foo: 'bar' }, _emberRuntime.Object.create(), _emberRuntime.Object.create({ foo: 'bar' }), _emberRuntime.ObjectProxy.create({ content: true }), Object, function () {}, + /*jshint -W053 */ + new String('hello'), new String(''), new Boolean(true), new Boolean(false), + /*jshint +W053 */ + new Date()]), new StableFalsyGenerator([false, null, undefined, '', 0, [], _emberRuntime.A(), _emberRuntime.ObjectProxy.create({ content: undefined })]), new ObjectProxyGenerator([true, ' ', 'hello', 'false', 'null', 'undefined', 1, ['hello'], _emberRuntime.A(['hello']), _emberRuntime.ArrayProxy.create({ content: ['hello'] }), _emberRuntime.ArrayProxy.create({ content: [] }), {}, { foo: 'bar' }, _emberRuntime.Object.create(), _emberRuntime.Object.create({ foo: 'bar' }), _emberRuntime.ObjectProxy.create({ content: true }), _emberRuntime.ObjectProxy.create({ content: undefined }), + /*jshint -W053 */ + new String('hello'), new String(''), new Boolean(true), new Boolean(false), + /*jshint +W053 */ + new Date(), false, null, undefined, '', 0, [], _emberRuntime.A()]), ObjectTestCases, ArrayTestCases]; + + // Testing behaviors shared across the "toggling" conditionals, i.e. {{#if}}, + // {{#unless}}, {{#with}}, {{#each}}, {{#each-in}}, (if) and (unless) + + var TogglingConditionalsTest = (function (_BasicConditionalsTest) { + babelHelpers.inherits(TogglingConditionalsTest, _BasicConditionalsTest); + + function TogglingConditionalsTest() { + babelHelpers.classCallCheck(this, TogglingConditionalsTest); + + _BasicConditionalsTest.apply(this, arguments); + } + + // Testing behaviors shared across the (if) and (unless) helpers + return TogglingConditionalsTest; + })(BasicConditionalsTest); + + exports.TogglingConditionalsTest = TogglingConditionalsTest; + + var TogglingHelperConditionalsTest = (function (_TogglingConditionalsTest) { + babelHelpers.inherits(TogglingHelperConditionalsTest, _TogglingConditionalsTest); + + function TogglingHelperConditionalsTest() { + babelHelpers.classCallCheck(this, TogglingHelperConditionalsTest); + + _TogglingConditionalsTest.apply(this, arguments); + } + + TogglingHelperConditionalsTest.prototype.renderValues = function renderValues() { + var templates = []; + var context = {}; + + for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + for (var i = 1; i <= values.length; i++) { + templates.push(this.templateFor({ cond: 'cond' + i, truthy: 't' + i, falsy: 'f' + i })); + context['t' + i] = 'T' + i; + context['f' + i] = 'F' + i; + context['cond' + i] = values[i - 1]; + } + + var wrappedTemplate = this.wrapperFor(templates); + this.render(wrappedTemplate, context); + }; + + TogglingHelperConditionalsTest.prototype['@test it has access to the outer scope from both templates'] = function testItHasAccessToTheOuterScopeFromBothTemplates() { + var _this12 = this; + + var template = this.wrapperFor([this.templateFor({ cond: 'cond1', truthy: 'truthy', falsy: 'falsy' }), this.templateFor({ cond: 'cond2', truthy: 'truthy', falsy: 'falsy' })]); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue, truthy: 'YES', falsy: 'NO' }); + + this.assertText('YESNO'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('YESNO'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'truthy', 'YASS'); + _emberMetal.set(_this12.context, 'falsy', 'NOPE'); + }); + + this.assertText('YASSNOPE'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'cond1', _this12.falsyValue); + _emberMetal.set(_this12.context, 'cond2', _this12.truthyValue); + }); + + this.assertText('NOPEYASS'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'truthy', 'YES'); + _emberMetal.set(_this12.context, 'falsy', 'NO'); + _emberMetal.set(_this12.context, 'cond1', _this12.truthyValue); + _emberMetal.set(_this12.context, 'cond2', _this12.falsyValue); + }); + + this.assertText('YESNO'); + }; + + TogglingHelperConditionalsTest.prototype['@test it does not update when the unbound helper is used'] = function testItDoesNotUpdateWhenTheUnboundHelperIsUsed() { + var _this13 = this; + + var template = this.wrapperFor([this.templateFor({ cond: '(unbound cond1)', truthy: '"T1"', falsy: '"F1"' }), this.templateFor({ cond: '(unbound cond2)', truthy: '"T2"', falsy: '"F2"' })]); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'cond1', _this13.falsyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'cond1', _this13.truthyValue); + _emberMetal.set(_this13.context, 'cond2', _this13.truthyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'cond1', _this13.truthyValue); + _emberMetal.set(_this13.context, 'cond2', _this13.falsyValue); + }); + + this.assertText('T1F2'); + }; + + TogglingHelperConditionalsTest.prototype['@test evaluation should be lazy'] = function testEvaluationShouldBeLazy(assert) { + var _this14 = this; + + var truthyEvaluated = undefined; + var falsyEvaluated = undefined; + + var withoutEvaluatingTruthy = function (callback) { + truthyEvaluated = false; + callback(); + assert.ok(!truthyEvaluated, 'x-truthy is not evaluated'); + }; + + var withoutEvaluatingFalsy = function (callback) { + falsyEvaluated = false; + callback(); + assert.ok(!falsyEvaluated, 'x-falsy is not evaluated'); + }; + + this.registerHelper('x-truthy', { + compute: function () { + truthyEvaluated = true; + return 'T'; + } + }); + + this.registerHelper('x-falsy', { + compute: function () { + falsyEvaluated = true; + return 'F'; + } + }); + + var template = this.wrappedTemplateFor({ cond: 'cond', truthy: '(x-truthy)', falsy: '(x-falsy)' }); + + withoutEvaluatingFalsy(function () { + return _this14.render(template, { cond: _this14.truthyValue }); + }); + + this.assertText('T'); + + withoutEvaluatingFalsy(function () { + return _this14.runTask(function () { + return _this14.rerender(); + }); + }); + + this.assertText('T'); + + withoutEvaluatingTruthy(function () { + return _this14.runTask(function () { + return _emberMetal.set(_this14.context, 'cond', _this14.falsyValue); + }); + }); + + this.assertText('F'); + + withoutEvaluatingTruthy(function () { + return _this14.runTask(function () { + return _this14.rerender(); + }); + }); + + this.assertText('F'); + + withoutEvaluatingFalsy(function () { + return _this14.runTask(function () { + return _emberMetal.set(_this14.context, 'cond', _this14.truthyValue); + }); + }); + + this.assertText('T'); + }; + + return TogglingHelperConditionalsTest; + })(TogglingConditionalsTest); + + exports.TogglingHelperConditionalsTest = TogglingHelperConditionalsTest; + + var IfUnlessHelperTest = (function (_TogglingHelperConditionalsTest) { + babelHelpers.inherits(IfUnlessHelperTest, _TogglingHelperConditionalsTest); + + function IfUnlessHelperTest() { + babelHelpers.classCallCheck(this, IfUnlessHelperTest); + + _TogglingHelperConditionalsTest.apply(this, arguments); + } + + return IfUnlessHelperTest; + })(TogglingHelperConditionalsTest); + + exports.IfUnlessHelperTest = IfUnlessHelperTest; + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins.apply(undefined, [IfUnlessHelperTest].concat(IfUnlessWithTestCases)); + + // Testing behaviors shared across the "toggling" syntatical constructs, + // i.e. {{#if}}, {{#unless}}, {{#with}}, {{#each}} and {{#each-in}} + + var TogglingSyntaxConditionalsTest = (function (_TogglingConditionalsTest2) { + babelHelpers.inherits(TogglingSyntaxConditionalsTest, _TogglingConditionalsTest2); + + function TogglingSyntaxConditionalsTest() { + babelHelpers.classCallCheck(this, TogglingSyntaxConditionalsTest); + + _TogglingConditionalsTest2.apply(this, arguments); + } + + TogglingSyntaxConditionalsTest.prototype.renderValues = function renderValues() { + var templates = []; + var context = {}; + + for (var _len2 = arguments.length, values = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + values[_key2] = arguments[_key2]; + } + + for (var i = 1; i <= values.length; i++) { + templates.push(this.templateFor({ cond: 'cond' + i, truthy: '{{t}}' + i, falsy: '{{f}}' + i })); + context['cond' + i] = values[i - 1]; + } + + var wrappedTemplate = this.wrapperFor(templates); + this.render(wrappedTemplate, _emberUtils.assign({ t: 'T', f: 'F' }, context)); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it does not update when the unbound helper is used'] = function testItDoesNotUpdateWhenTheUnboundHelperIsUsed() { + var _this15 = this; + + var template = '' + this.templateFor({ cond: '(unbound cond1)', truthy: 'T1', falsy: 'F1' }) + this.templateFor({ cond: '(unbound cond2)', truthy: 'T2', falsy: 'F2' }); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'cond1', _this15.falsyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this15.context, 'cond1', _this15.truthyValue); + _emberMetal.set(_this15.context, 'cond2', _this15.truthyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this15.context, 'cond1', _this15.truthyValue); + _emberMetal.set(_this15.context, 'cond2', _this15.falsyValue); + }); + + this.assertText('T1F2'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it has access to the outer scope from both templates'] = function testItHasAccessToTheOuterScopeFromBothTemplates() { + var _this16 = this; + + var template = this.wrapperFor([this.templateFor({ cond: 'cond1', truthy: '{{truthy}}', falsy: '{{falsy}}' }), this.templateFor({ cond: 'cond2', truthy: '{{truthy}}', falsy: '{{falsy}}' })]); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue, truthy: 'YES', falsy: 'NO' }); + + this.assertText('YESNO'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('YESNO'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'truthy', 'YASS'); + _emberMetal.set(_this16.context, 'falsy', 'NOPE'); + }); + + this.assertText('YASSNOPE'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'cond1', _this16.falsyValue); + _emberMetal.set(_this16.context, 'cond2', _this16.truthyValue); + }); + + this.assertText('NOPEYASS'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'truthy', 'YES'); + _emberMetal.set(_this16.context, 'falsy', 'NO'); + _emberMetal.set(_this16.context, 'cond1', _this16.truthyValue); + _emberMetal.set(_this16.context, 'cond2', _this16.falsyValue); + }); + + this.assertText('YESNO'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it updates correctly when enclosing another conditional'] = function testItUpdatesCorrectlyWhenEnclosingAnotherConditional() { + var _this17 = this; + + // This tests whether the outer conditional tracks its bounds correctly as its inner bounds changes + var inner = this.templateFor({ cond: 'inner', truthy: 'T-inner', falsy: 'F-inner' }); + var template = this.wrappedTemplateFor({ cond: 'outer', truthy: inner, falsy: 'F-outer' }); + + this.render(template, { outer: this.truthyValue, inner: this.truthyValue }); + + this.assertText('T-inner'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('T-inner'); + + // Changes the inner bounds + this.runTask(function () { + return _emberMetal.set(_this17.context, 'inner', _this17.falsyValue); + }); + + this.assertText('F-inner'); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this17.context, 'outer', _this17.falsyValue); + }); + + this.assertText('F-outer'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it updates correctly when enclosing #each'] = function testItUpdatesCorrectlyWhenEnclosingEach() { + var _this18 = this; + + // This tests whether the outer conditional tracks its bounds correctly as its inner bounds changes + var template = this.wrappedTemplateFor({ cond: 'outer', truthy: '{{#each inner as |text|}}{{text}}{{/each}}', falsy: 'F-outer' }); + + this.render(template, { outer: this.truthyValue, inner: ['inner', '-', 'before'] }); + + this.assertText('inner-before'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('inner-before'); + + // Changes the inner bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'inner', ['inner-after']); + }); + + this.assertText('inner-after'); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'outer', _this18.falsyValue); + }); + + this.assertText('F-outer'); + + // Reset + this.runTask(function () { + _emberMetal.set(_this18.context, 'inner', ['inner-again']); + _emberMetal.set(_this18.context, 'outer', _this18.truthyValue); + }); + + this.assertText('inner-again'); + + // Now clear the inner bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'inner', []); + }); + + this.assertText(''); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'outer', _this18.falsyValue); + }); + + this.assertText('F-outer'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it updates correctly when enclosing triple-curlies'] = function testItUpdatesCorrectlyWhenEnclosingTripleCurlies() { + var _this19 = this; + + // This tests whether the outer conditional tracks its bounds correctly as its inner bounds changes + var template = this.wrappedTemplateFor({ cond: 'outer', truthy: '{{{inner}}}', falsy: 'F-outer' }); + + this.render(template, { outer: this.truthyValue, inner: 'inner-before' }); + + this.assertText('inner-before'); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertText('inner-before'); + + // Changes the inner bounds + this.runTask(function () { + return _emberMetal.set(_this19.context, 'inner', '

    inner-after

    '); + }); + + this.assertText('inner-after'); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this19.context, 'outer', _this19.falsyValue); + }); + + this.assertText('F-outer'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test child conditional should not render children if parent conditional becomes false'] = function testChildConditionalShouldNotRenderChildrenIfParentConditionalBecomesFalse(assert) { + var _this20 = this; + + var childCreated = false; + + this.registerComponent('foo-bar', { + template: 'foo-bar', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + childCreated = true; + } + }) + }); + + var innerTemplate = this.templateFor({ cond: 'cond2', truthy: '{{foo-bar}}', falsy: '' }); + var wrappedTemplate = this.wrappedTemplateFor({ cond: 'cond1', truthy: innerTemplate, falsy: '' }); + + this.render(wrappedTemplate, { cond1: this.truthyValue, cond2: this.falsyValue }); + + assert.ok(!childCreated); + this.assertText(''); + + this.runTask(function () { + return _this20.rerender(); + }); + + assert.ok(!childCreated); + this.assertText(''); + + this.runTask(function () { + _emberMetal.set(_this20.context, 'cond2', _this20.truthyValue); + _emberMetal.set(_this20.context, 'cond1', _this20.falsyValue); + }); + + assert.ok(!childCreated); + this.assertText(''); + + this.runTask(function () { + _emberMetal.set(_this20.context, 'cond2', _this20.falsyValue); + _emberMetal.set(_this20.context, 'cond1', _this20.truthyValue); + }); + + assert.ok(!childCreated); + this.assertText(''); + }; + + TogglingSyntaxConditionalsTest.prototype['@test evaluation should be lazy'] = function testEvaluationShouldBeLazy(assert) { + var _this21 = this; + + var truthyEvaluated = undefined; + var falsyEvaluated = undefined; + + var withoutEvaluatingTruthy = function (callback) { + truthyEvaluated = false; + callback(); + assert.ok(!truthyEvaluated, 'x-truthy is not evaluated'); + }; + + var withoutEvaluatingFalsy = function (callback) { + falsyEvaluated = false; + callback(); + assert.ok(!falsyEvaluated, 'x-falsy is not evaluated'); + }; + + this.registerHelper('x-truthy', { + compute: function () { + truthyEvaluated = true; + return 'T'; + } + }); + + this.registerHelper('x-falsy', { + compute: function () { + falsyEvaluated = true; + return 'F'; + } + }); + + var template = this.wrappedTemplateFor({ cond: 'cond', truthy: '{{x-truthy}}', falsy: '{{x-falsy}}' }); + + withoutEvaluatingFalsy(function () { + return _this21.render(template, { cond: _this21.truthyValue }); + }); + + this.assertText('T'); + + withoutEvaluatingFalsy(function () { + return _this21.runTask(function () { + return _this21.rerender(); + }); + }); + + this.assertText('T'); + + withoutEvaluatingTruthy(function () { + return _this21.runTask(function () { + return _emberMetal.set(_this21.context, 'cond', _this21.falsyValue); + }); + }); + + this.assertText('F'); + + withoutEvaluatingTruthy(function () { + return _this21.runTask(function () { + return _this21.rerender(); + }); + }); + + this.assertText('F'); + + withoutEvaluatingFalsy(function () { + return _this21.runTask(function () { + return _emberMetal.set(_this21.context, 'cond', _this21.truthyValue); + }); + }); + + this.assertText('T'); + }; + + return TogglingSyntaxConditionalsTest; + })(TogglingConditionalsTest); + + exports.TogglingSyntaxConditionalsTest = TogglingSyntaxConditionalsTest; + + var IfUnlessWithSyntaxTest = (function (_TogglingSyntaxConditionalsTest) { + babelHelpers.inherits(IfUnlessWithSyntaxTest, _TogglingSyntaxConditionalsTest); + + function IfUnlessWithSyntaxTest() { + babelHelpers.classCallCheck(this, IfUnlessWithSyntaxTest); + + _TogglingSyntaxConditionalsTest.apply(this, arguments); + } + + return IfUnlessWithSyntaxTest; + })(TogglingSyntaxConditionalsTest); + + exports.IfUnlessWithSyntaxTest = IfUnlessWithSyntaxTest; + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins.apply(undefined, [IfUnlessWithSyntaxTest].concat(IfUnlessWithTestCases)); +}); +enifed('ember-glimmer/tests/utils/shared-conditional-tests.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/shared-conditional-tests.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/shared-conditional-tests.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/string-test', ['exports', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('SafeString', (function (_TestCase) { + babelHelpers.inherits(_class, _TestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _TestCase.apply(this, arguments); + } + + _class.prototype['@test htmlSafe should return an instance of SafeString'] = function testHtmlSafeShouldReturnAnInstanceOfSafeString() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe('you need to be more bold'); + + this.assert.ok(safeString instanceof _emberGlimmerTestsUtilsHelpers.SafeString, 'should be a SafeString'); + }; + + _class.prototype['@test htmlSafe should return an empty string for null'] = function testHtmlSafeShouldReturnAnEmptyStringForNull() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe(null); + + this.assert.equal(safeString instanceof _emberGlimmerTestsUtilsHelpers.SafeString, true, 'should be a SafeString'); + this.assert.equal(safeString.toString(), '', 'should return an empty string'); + }; + + _class.prototype['@test htmlSafe should return an instance of SafeString'] = function testHtmlSafeShouldReturnAnInstanceOfSafeString() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe(); + + this.assert.equal(safeString instanceof _emberGlimmerTestsUtilsHelpers.SafeString, true, 'should be a SafeString'); + this.assert.equal(safeString.toString(), '', 'should return an empty string'); + }; + + return _class; + })(_emberGlimmerTestsUtilsAbstractTestCase.TestCase)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('SafeString isHTMLSafe', (function (_TestCase2) { + babelHelpers.inherits(_class2, _TestCase2); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _TestCase2.apply(this, arguments); + } + + _class2.prototype['@test isHTMLSafe should detect SafeString'] = function testIsHTMLSafeShouldDetectSafeString() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe('Emphasize the important things.'); + + this.assert.ok(_emberGlimmerTestsUtilsHelpers.isHTMLSafe(safeString)); + }; + + _class2.prototype['@test isHTMLSafe should not detect SafeString on primatives'] = function testIsHTMLSafeShouldNotDetectSafeStringOnPrimatives() { + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe('Hello World')); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe({})); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe([])); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe(10)); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe(null)); + }; + + return _class2; + })(_emberGlimmerTestsUtilsAbstractTestCase.TestCase)); +}); +enifed('ember-glimmer/tests/utils/string-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/string-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/string-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/test-case', ['exports', 'internal-test-helpers'], function (exports, _internalTestHelpers) { + 'use strict'; + + exports.TestCase = _internalTestHelpers.AbstractTestCase; + exports.ApplicationTest = _internalTestHelpers.ApplicationTestCase; + exports.RenderingTest = _internalTestHelpers.RenderingTestCase; + exports.moduleFor = _internalTestHelpers.moduleFor; +}); +enifed('ember-glimmer/tests/utils/test-case.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/test-case.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/test-case.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/test-helpers', ['exports', 'internal-test-helpers'], function (exports, _internalTestHelpers) { + 'use strict'; + + exports.styles = _internalTestHelpers.styles; + exports.classes = _internalTestHelpers.classes; + exports.equalTokens = _internalTestHelpers.equalTokens; + exports.equalsElement = _internalTestHelpers.equalsElement; +}); +enifed('ember-glimmer/tests/utils/test-helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/test-helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/test-helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/bindings.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/bindings.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/bindings.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/debug-stack.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/debug-stack.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/debug-stack.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/iterable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/iterable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/iterable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/process-args.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/process-args.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/process-args.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/references.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/references.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/references.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/to-bool.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/to-bool.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/to-bool.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/views/outlet.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/views/outlet.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/views/outlet.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/alias.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/alias.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/alias.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/binding.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/binding.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/binding.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/cache.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/cache.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/cache.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/chains.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/chains.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/chains.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/computed.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/computed.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/computed.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/core.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/core.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/core.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/debug.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/debug.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/debug.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/dependent_keys.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/dependent_keys.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/dependent_keys.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/deprecate_property.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/deprecate_property.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/deprecate_property.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/descriptor.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/descriptor.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/descriptor.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/error.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/error.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/error.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/error_handler.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/error_handler.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/error_handler.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/events.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/events.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/events.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/expand_properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/expand_properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/expand_properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/features.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/features.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/features.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/get_properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/get_properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/get_properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/injected_property.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/injected_property.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/injected_property.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/instrumentation.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/instrumentation.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/instrumentation.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_blank.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_blank.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_blank.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_empty.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_empty.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_empty.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_none.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_none.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_none.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_present.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_present.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_present.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/libraries.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/libraries.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/libraries.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/map.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/map.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/map.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/merge.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/merge.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/merge.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/meta.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/meta.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/meta.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/meta_listeners.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/meta_listeners.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/meta_listeners.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/mixin.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/mixin.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/mixin.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/observer.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/observer.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/observer.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/observer_set.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/observer_set.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/observer_set.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/path_cache.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/path_cache.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/path_cache.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/property_events.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/property_events.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/property_events.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/property_get.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/property_get.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/property_get.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/property_set.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/property_set.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/property_set.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/replace.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/replace.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/replace.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/run_loop.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/run_loop.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/run_loop.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/set_properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/set_properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/set_properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tags.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tags.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tags.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/testing.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/testing.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/testing.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/get_path_test', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; + + var obj = undefined; + var moduleOpts = { + setup: function () { + obj = { + foo: { + bar: { + baz: { biff: 'BIFF' } + } + }, + foothis: { + bar: { + baz: { biff: 'BIFF' } + } + }, + falseValue: false, + emptyString: '', + Wuz: { + nar: 'foo' + }, + nullValue: null + }; + }, + + teardown: function () { + obj = undefined; + } + }; + + QUnit.module('Ember.get with path', moduleOpts); + + // .......................................................... + // LOCAL PATHS + // + + QUnit.test('[obj, foo] -> obj.foo', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), obj.foo); + }); + + QUnit.test('[obj, foo.bar] -> obj.foo.bar', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'foo.bar'), obj.foo.bar); + }); + + QUnit.test('[obj, foothis.bar] -> obj.foothis.bar', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'foothis.bar'), obj.foothis.bar); + }); + + QUnit.test('[obj, falseValue.notDefined] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'falseValue.notDefined'), undefined); + }); + + QUnit.test('[obj, emptyString.length] -> 0', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'emptyString.length'), 0); + }); + + QUnit.test('[obj, nullValue.notDefined] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'nullValue.notDefined'), undefined); + }); + + // .......................................................... + // GLOBAL PATHS TREATED LOCAL WITH GET + // + + QUnit.test('[obj, Wuz] -> obj.Wuz', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'Wuz'), obj.Wuz); + }); + + QUnit.test('[obj, Wuz.nar] -> obj.Wuz.nar', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'Wuz.nar'), obj.Wuz.nar); + }); + + QUnit.test('[obj, Foo] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'Foo'), undefined); + }); + + QUnit.test('[obj, Foo.bar] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'Foo.bar'), undefined); + }); +}); +enifed('ember-metal/tests/accessors/get_path_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/get_path_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/get_path_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/get_properties_test', ['exports', 'ember-metal/get_properties'], function (exports, _emberMetalGet_properties) { + 'use strict'; + + QUnit.module('Ember.getProperties'); + + QUnit.test('can retrieve a hash of properties from an object via an argument list or array of property names', function () { + var obj = { + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }; + + deepEqual(_emberMetalGet_properties.default(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj, 'lastName'), { lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj), {}); + deepEqual(_emberMetalGet_properties.default(obj, ['firstName', 'lastName']), { firstName: 'Steve', lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj, ['firstName']), { firstName: 'Steve' }); + deepEqual(_emberMetalGet_properties.default(obj, []), {}); + }); +}); +enifed('ember-metal/tests/accessors/get_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/get_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/get_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/get_test', ['exports', 'internal-test-helpers', 'ember-metal/property_get', 'ember-metal/mixin', 'ember-metal/observer'], function (exports, _internalTestHelpers, _emberMetalProperty_get, _emberMetalMixin, _emberMetalObserver) { + 'use strict'; + + QUnit.module('Ember.get'); + + QUnit.test('should get arbitrary properties on an object', function () { + var obj = { + string: 'string', + number: 23, + boolTrue: true, + boolFalse: false, + nullValue: null + }; + + for (var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + equal(_emberMetalProperty_get.get(obj, key), obj[key], key); + } + }); + + QUnit.test('should not access a property more than once', function () { + var count = 0; + var obj = { + get id() { + return ++count; + } + }; + + _emberMetalProperty_get.get(obj, 'id'); + + equal(count, 1); + }); + + _internalTestHelpers.testBoth('should call unknownProperty on watched values if the value is undefined', function (get, set) { + var obj = { + count: 0, + unknownProperty: function (key) { + equal(key, 'foo', 'should pass key'); + this.count++; + return 'FOO'; + } + }; + + var count = 0; + _emberMetalObserver.addObserver(obj, 'foo', function () { + count++; + }); + + equal(get(obj, 'foo'), 'FOO', 'should return value from unknown'); + }); + + QUnit.test('warn on attemps to call get with no arguments', function () { + expectAssertion(function () { + _emberMetalProperty_get.get('aProperty'); + }, /Get must be called with two arguments;/i); + }); + + QUnit.test('warn on attemps to call get with only one argument', function () { + expectAssertion(function () { + _emberMetalProperty_get.get('aProperty'); + }, /Get must be called with two arguments;/i); + }); + + QUnit.test('warn on attemps to call get with more then two arguments', function () { + expectAssertion(function () { + _emberMetalProperty_get.get({}, 'aProperty', true); + }, /Get must be called with two arguments;/i); + }); + + QUnit.test('warn on attempts to get a property of undefined', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(undefined, 'aProperty'); + }, /Cannot call get with 'aProperty' on an undefined object/i); + }); + + QUnit.test('warn on attempts to get a property path of undefined', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(undefined, 'aProperty.on.aPath'); + }, /Cannot call get with 'aProperty.on.aPath' on an undefined object/); + }); + + QUnit.test('warn on attempts to get a property of null', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(null, 'aProperty'); + }, /Cannot call get with 'aProperty' on an undefined object/); + }); + + QUnit.test('warn on attempts to get a property path of null', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(null, 'aProperty.on.aPath'); + }, /Cannot call get with 'aProperty.on.aPath' on an undefined object/); + }); + + QUnit.test('warn on attempts to use get with an unsupported property path', function () { + var obj = {}; + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, null); + }, /The key provided to get must be a string, you passed null/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, NaN); + }, /The key provided to get must be a string, you passed NaN/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, undefined); + }, /The key provided to get must be a string, you passed undefined/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, false); + }, /The key provided to get must be a string, you passed false/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, 42); + }, /The key provided to get must be a string, you passed 42/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, ''); + }, /Cannot call `Ember.get` with an empty string/); + }); + + // .......................................................... + // BUGS + // + + QUnit.test('(regression) watched properties on unmodified inherited objects should still return their original value', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + someProperty: 'foo', + propertyDidChange: _emberMetalMixin.observer('someProperty', function () {}) + }); + + var baseObject = MyMixin.apply({}); + var theRealObject = Object.create(baseObject); + + equal(_emberMetalProperty_get.get(theRealObject, 'someProperty'), 'foo', 'should return the set value, not false'); + }); + + QUnit.module('Ember.getWithDefault'); + + QUnit.test('should get arbitrary properties on an object', function () { + var obj = { + string: 'string', + number: 23, + boolTrue: true, + boolFalse: false, + nullValue: null + }; + + for (var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + equal(_emberMetalProperty_get.getWithDefault(obj, key, 'fail'), obj[key], key); + } + + obj = { + undef: undefined + }; + + equal(_emberMetalProperty_get.getWithDefault(obj, 'undef', 'default'), 'default', 'explicit undefined retrieves the default'); + equal(_emberMetalProperty_get.getWithDefault(obj, 'not-present', 'default'), 'default', 'non-present key retrieves the default'); + }); + + QUnit.test('should call unknownProperty if defined and value is undefined', function () { + var obj = { + count: 0, + unknownProperty: function (key) { + equal(key, 'foo', 'should pass key'); + this.count++; + return 'FOO'; + } + }; + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should return value from unknown'); + equal(obj.count, 1, 'should have invoked'); + }); + + _internalTestHelpers.testBoth('if unknownProperty is present, it is called', function (get, set) { + var obj = { + count: 0, + unknownProperty: function (key) { + if (key === 'foo') { + equal(key, 'foo', 'should pass key'); + this.count++; + return 'FOO'; + } + } + }; + + var count = 0; + _emberMetalObserver.addObserver(obj, 'foo', function () { + return count++; + }); + + equal(_emberMetalProperty_get.getWithDefault(obj, 'foo', 'fail'), 'FOO', 'should return value from unknownProperty'); + equal(_emberMetalProperty_get.getWithDefault(obj, 'bar', 'default'), 'default', 'should convert undefined from unknownProperty into default'); + }); + + // .......................................................... + // BUGS + // + + QUnit.test('(regression) watched properties on unmodified inherited objects should still return their original value', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + someProperty: 'foo', + propertyDidChange: _emberMetalMixin.observer('someProperty', function () {/* nothing to do */}) + }); + + var baseObject = MyMixin.apply({}); + var theRealObject = Object.create(baseObject); + + equal(_emberMetalProperty_get.getWithDefault(theRealObject, 'someProperty', 'fail'), 'foo', 'should return the set value, not false'); + }); +}); +enifed('ember-metal/tests/accessors/get_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/get_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/get_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/is_global_path_test', ['exports', 'ember-metal/path_cache'], function (exports, _emberMetalPath_cache) { + 'use strict'; + + QUnit.module('Ember.isGlobalPath'); + + QUnit.test('global path\'s are recognized', function () { + ok(_emberMetalPath_cache.isGlobalPath('App.myProperty')); + ok(_emberMetalPath_cache.isGlobalPath('App.myProperty.subProperty')); + }); + + QUnit.test('if there is a \'this\' in the path, it\'s not a global path', function () { + ok(!_emberMetalPath_cache.isGlobalPath('this.myProperty')); + ok(!_emberMetalPath_cache.isGlobalPath('this')); + }); + + QUnit.test('if the path starts with a lowercase character, it is not a global path', function () { + ok(!_emberMetalPath_cache.isGlobalPath('myObj')); + ok(!_emberMetalPath_cache.isGlobalPath('myObj.SecondProperty')); + }); +}); +enifed('ember-metal/tests/accessors/is_global_path_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/is_global_path_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/is_global_path_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/mandatory_setters_test', ['exports', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/watching', 'ember-metal/meta'], function (exports, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWatching, _emberMetalMeta) { + 'use strict'; + + QUnit.module('mandatory-setters'); + + function hasMandatorySetter(object, property) { + try { + return Object.getOwnPropertyDescriptor(object, property).set.isMandatorySetter === true; + } catch (e) { + return false; + } + } + + function hasMetaValue(object, property) { + return _emberMetalMeta.meta(object).hasInValues(property); + } + + if (true) { + QUnit.test('does not assert if property is not being watched', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + obj.someProp = 'blastix'; + equal(_emberMetalProperty_get.get(obj, 'someProp'), 'blastix'); + }); + + QUnit.test('should not setup mandatory-setter if property is not writable', function () { + expect(6); + + var obj = {}; + + Object.defineProperty(obj, 'a', { value: true }); + Object.defineProperty(obj, 'b', { value: false }); + Object.defineProperty(obj, 'c', { value: undefined }); + Object.defineProperty(obj, 'd', { value: undefined, writable: false }); + Object.defineProperty(obj, 'e', { value: undefined, configurable: false }); + Object.defineProperty(obj, 'f', { value: undefined, configurable: true }); + + _emberMetalWatching.watch(obj, 'a'); + _emberMetalWatching.watch(obj, 'b'); + _emberMetalWatching.watch(obj, 'c'); + _emberMetalWatching.watch(obj, 'd'); + _emberMetalWatching.watch(obj, 'e'); + _emberMetalWatching.watch(obj, 'f'); + + ok(!hasMandatorySetter(obj, 'a'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'b'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'c'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'd'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'e'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'f'), 'mandatory-setter should not be installed'); + }); + + QUnit.test('should not teardown non mandatory-setter descriptor', function () { + expect(1); + + var obj = { get a() { + return 'hi'; + } }; + + _emberMetalWatching.watch(obj, 'a'); + _emberMetalWatching.unwatch(obj, 'a'); + + equal(obj.a, 'hi'); + }); + + QUnit.test('should not confuse non descriptor watched gets', function () { + expect(2); + + var obj = { get a() { + return 'hi'; + } }; + + _emberMetalWatching.watch(obj, 'a'); + equal(_emberMetalProperty_get.get(obj, 'a'), 'hi'); + equal(obj.a, 'hi'); + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property', function () { + expect(2); + + var obj = { someProp: null }; + + Object.defineProperty(obj, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('watched ES5 setter should not be smashed by mandatory setter', function () { + var value = undefined; + var obj = { + get foo() {}, + set foo(_value) { + value = _value; + } + }; + + _emberMetalWatching.watch(obj, 'foo'); + + _emberMetalProperty_set.set(obj, 'foo', 2); + equal(value, 2); + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property in parent prototype', function () { + expect(2); + + function Foo() {} + + Object.defineProperty(Foo.prototype, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + var obj = new Foo(); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property in grandparent prototype', function () { + expect(2); + + function Foo() {} + + Object.defineProperty(Foo.prototype, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + function Bar() {} + Bar.prototype = Object.create(Foo.prototype); + Bar.prototype.constructor = Bar; + + var obj = new Bar(); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property in great grandparent prototype', function () { + expect(2); + + function Foo() {} + + Object.defineProperty(Foo.prototype, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + function Bar() {} + Bar.prototype = Object.create(Foo.prototype); + Bar.prototype.constructor = Bar; + + function Qux() {} + Qux.prototype = Object.create(Bar.prototype); + Qux.prototype.constructor = Qux; + + var obj = new Qux(); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('should assert if set without Ember.set when property is being watched', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + _emberMetalWatching.watch(obj, 'someProp'); + + expectAssertion(function () { + obj.someProp = 'foo-bar'; + }, 'You must use Ember.set() to set the `someProp` property (of custom-object) to `foo-bar`.'); + }); + + QUnit.test('should not assert if set with Ember.set when property is being watched', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + _emberMetalWatching.watch(obj, 'someProp'); + _emberMetalProperty_set.set(obj, 'someProp', 'foo-bar'); + + equal(_emberMetalProperty_get.get(obj, 'someProp'), 'foo-bar'); + }); + + QUnit.test('does not setup mandatory-setter if non-configurable', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + Object.defineProperty(obj, 'someProp', { + configurable: false, + enumerable: true, + value: 'blastix' + }); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'blastix'); + }); + + QUnit.test('ensure after watch the property is restored (and the value is no-longer stored in meta) [non-enumerable]', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + Object.defineProperty(obj, 'someProp', { + configurable: true, + enumerable: false, + value: 'blastix' + }); + + _emberMetalWatching.watch(obj, 'someProp'); + equal(hasMandatorySetter(obj, 'someProp'), true, 'should have a mandatory setter'); + + var descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + + equal(descriptor.value, undefined, 'expected existing value to NOT remain'); + + ok(hasMetaValue(obj, 'someProp'), 'someProp is stored in meta.values'); + + _emberMetalWatching.unwatch(obj, 'someProp'); + + ok(!hasMetaValue(obj, 'someProp'), 'someProp is no longer stored in meta.values'); + + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(hasMandatorySetter(obj, 'someProp'), false, 'should no longer have a mandatory setter'); + + equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + equal(descriptor.value, 'blastix', 'expected existing value to remain'); + + obj.someProp = 'new value'; + + // make sure the descriptor remains correct (nothing funky, like a redefined, happened in the setter); + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(descriptor.value, 'new value', 'expected existing value to NOT remain'); + equal(obj.someProp, 'new value', 'expected value to be the getter'); + equal(obj.someProp, 'new value'); + }); + + QUnit.test('ensure after watch the property is restored (and the value is no-longer stored in meta) [enumerable]', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + Object.defineProperty(obj, 'someProp', { + configurable: true, + enumerable: true, + value: 'blastix' + }); + + _emberMetalWatching.watch(obj, 'someProp'); + equal(hasMandatorySetter(obj, 'someProp'), true, 'should have a mandatory setter'); + + var descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, true, 'property should remain enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + + equal(descriptor.value, undefined, 'expected existing value to NOT remain'); + + ok(hasMetaValue(obj, 'someProp'), 'someProp is stored in meta.values'); + + _emberMetalWatching.unwatch(obj, 'someProp'); + + ok(!hasMetaValue(obj, 'someProp'), 'someProp is no longer stored in meta.values'); + + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(hasMandatorySetter(obj, 'someProp'), false, 'should no longer have a mandatory setter'); + + equal(descriptor.enumerable, true, 'property should remain enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + equal(descriptor.value, 'blastix', 'expected existing value to remain'); + + obj.someProp = 'new value'; + + // make sure the descriptor remains correct (nothing funky, like a redefined, happened in the setter); + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, true, 'property should remain enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(descriptor.value, 'new value', 'expected existing value to NOT remain'); + equal(obj.someProp, 'new value'); + }); + + QUnit.test('sets up mandatory-setter if property comes from prototype', function () { + expect(2); + + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + var obj2 = Object.create(obj); + + _emberMetalWatching.watch(obj2, 'someProp'); + + ok(hasMandatorySetter(obj2, 'someProp'), 'mandatory setter has been setup'); + + expectAssertion(function () { + obj2.someProp = 'foo-bar'; + }, 'You must use Ember.set() to set the `someProp` property (of custom-object) to `foo-bar`.'); + }); + + QUnit.test('inheritance remains live', function () { + function Parent() {} + Parent.prototype.food = 'chips'; + + var child = new Parent(); + + equal(child.food, 'chips'); + + _emberMetalWatching.watch(child, 'food'); + + equal(child.food, 'chips'); + + Parent.prototype.food = 'icecreame'; + + equal(child.food, 'icecreame'); + + _emberMetalWatching.unwatch(child, 'food'); + + equal(child.food, 'icecreame'); + + Parent.prototype.food = 'chips'; + + equal(child.food, 'chips'); + }); + + QUnit.test('inheritance remains live and preserves this', function () { + function Parent(food) { + this._food = food; + } + + Object.defineProperty(Parent.prototype, 'food', { + get: function () { + return this._food; + } + }); + + var child = new Parent('chips'); + + equal(child.food, 'chips'); + + _emberMetalWatching.watch(child, 'food'); + + equal(child.food, 'chips'); + + child._food = 'icecreame'; + + equal(child.food, 'icecreame'); + + _emberMetalWatching.unwatch(child, 'food'); + + equal(child.food, 'icecreame'); + + var foodDesc = Object.getOwnPropertyDescriptor(Parent.prototype, 'food'); + ok(!foodDesc.configurable, 'Parent.prototype.food desc should be non configable'); + ok(!foodDesc.enumerable, 'Parent.prototype.food desc should be non enumerable'); + + equal(foodDesc.get.call({ + _food: 'hi' + }), 'hi'); + equal(foodDesc.set, undefined); + + equal(child.food, 'icecreame'); + }); + } +}); +enifed('ember-metal/tests/accessors/mandatory_setters_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/mandatory_setters_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/mandatory_setters_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/set_path_test', ['exports', 'ember-environment', 'ember-metal/property_set', 'ember-metal/property_get'], function (exports, _emberEnvironment, _emberMetalProperty_set, _emberMetalProperty_get) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + var obj = undefined; + function commonSetup() { + _emberEnvironment.context.lookup = lookup = {}; + obj = { + foo: { + bar: { + baz: { biff: 'BIFF' } + } + } + }; + } + + function commonTeardown() { + _emberEnvironment.context.lookup = originalLookup; + obj = null; + } + + QUnit.module('set with path', { + setup: commonSetup, + teardown: commonTeardown + }); + + QUnit.test('[Foo, bar] -> Foo.bar', function () { + lookup.Foo = { toString: function () { + return 'Foo'; + } }; // Behave like an Ember.Namespace + + _emberMetalProperty_set.set(lookup.Foo, 'bar', 'baz'); + equal(_emberMetalProperty_get.get(lookup.Foo, 'bar'), 'baz'); + }); + + // .......................................................... + // + // LOCAL PATHS + + QUnit.test('[obj, foo] -> obj.foo', function () { + _emberMetalProperty_set.set(obj, 'foo', 'BAM'); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'BAM'); + }); + + QUnit.test('[obj, foo.bar] -> obj.foo.bar', function () { + _emberMetalProperty_set.set(obj, 'foo.bar', 'BAM'); + equal(_emberMetalProperty_get.get(obj, 'foo.bar'), 'BAM'); + }); + + // .......................................................... + // DEPRECATED + // + + QUnit.module('set with path - deprecated', { + setup: commonSetup, + teardown: commonTeardown + }); + + QUnit.test('[obj, bla.bla] gives a proper exception message', function () { + var exceptionMessage = 'Property set failed: object in path \"bla\" could not be found or was destroyed.'; + try { + _emberMetalProperty_set.set(obj, 'bla.bla', 'BAM'); + } catch (ex) { + equal(ex.message, exceptionMessage); + } + }); + + QUnit.test('[obj, foo.baz.bat] -> EXCEPTION', function () { + throws(function () { + return _emberMetalProperty_set.set(obj, 'foo.baz.bat', 'BAM'); + }); + }); + + QUnit.test('[obj, foo.baz.bat] -> EXCEPTION', function () { + _emberMetalProperty_set.trySet(obj, 'foo.baz.bat', 'BAM'); + ok(true, 'does not raise'); + }); +}); +enifed('ember-metal/tests/accessors/set_path_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/set_path_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/set_path_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/set_test', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/tags'], function (exports, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalTags) { + 'use strict'; + + QUnit.module('set', { + teardown: function () { + _emberMetalTags.setHasViews(function () { + return false; + }); + } + }); + + QUnit.test('should set arbitrary properties on an object', function () { + var obj = { + string: 'string', + number: 23, + boolTrue: true, + boolFalse: false, + nullValue: null, + undefinedValue: undefined + }; + + var newObj = { + undefinedValue: 'emberjs' + }; + + for (var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + + equal(_emberMetalProperty_set.set(newObj, key, obj[key]), obj[key], 'should return value'); + equal(_emberMetalProperty_get.get(newObj, key), obj[key], 'should set value'); + } + }); + + QUnit.test('should call setUnknownProperty if defined and value is undefined', function () { + var obj = { + count: 0, + + unknownProperty: function (key, value) { + ok(false, 'should not invoke unknownProperty if setUnknownProperty is defined'); + }, + + setUnknownProperty: function (key, value) { + equal(key, 'foo', 'should pass key'); + equal(value, 'BAR', 'should pass key'); + this.count++; + return 'FOO'; + } + }; + + equal(_emberMetalProperty_set.set(obj, 'foo', 'BAR'), 'BAR', 'should return set value'); + equal(obj.count, 1, 'should have invoked'); + }); + + QUnit.test('warn on attempts to call set with undefined as object', function () { + expectAssertion(function () { + return _emberMetalProperty_set.set(undefined, 'aProperty', 'BAM'); + }, /Cannot call set with 'aProperty' on an undefined object./); + }); + + QUnit.test('warn on attempts to call set with null as object', function () { + expectAssertion(function () { + return _emberMetalProperty_set.set(null, 'aProperty', 'BAM'); + }, /Cannot call set with 'aProperty' on an undefined object./); + }); + + QUnit.test('warn on attempts to use set with an unsupported property path', function () { + var obj = {}; + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, null, 42); + }, /The key provided to set must be a string, you passed null/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, NaN, 42); + }, /The key provided to set must be a string, you passed NaN/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, undefined, 42); + }, /The key provided to set must be a string, you passed undefined/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, false, 42); + }, /The key provided to set must be a string, you passed false/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, 42, 42); + }, /The key provided to set must be a string, you passed 42/); + }); + + QUnit.test('warn on attempts of calling set on a destroyed object', function () { + var obj = { isDestroyed: true }; + + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, 'favoriteFood', 'hot dogs'); + }, 'calling set on destroyed object: [object Object].favoriteFood = hot dogs'); + }); + + QUnit.test('does not trigger auto-run assertion for objects that have not been tagged', function (assert) { + _emberMetalTags.setHasViews(function () { + return true; + }); + var obj = {}; + + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + + assert.equal(obj.foo, 'bar'); + }); +}); +enifed('ember-metal/tests/accessors/set_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/set_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/set_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/alias_test', ['exports', 'ember-metal/alias', 'ember-metal/properties', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/watching', 'ember-metal/observer', 'ember-metal/tags'], function (exports, _emberMetalAlias, _emberMetalProperties, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMeta, _emberMetalWatching, _emberMetalObserver, _emberMetalTags) { + 'use strict'; + + var obj = undefined, + count = undefined; + + QUnit.module('ember-metal/alias', { + setup: function () { + obj = { foo: { faz: 'FOO' } }; + count = 0; + }, + teardown: function () { + obj = null; + } + }); + + function incrementCount() { + count++; + } + + QUnit.test('should proxy get to alt key', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + equal(_emberMetalProperty_get.get(obj, 'bar'), 'FOO'); + }); + + QUnit.test('should proxy set to alt key', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + _emberMetalProperty_set.set(obj, 'bar', 'BAR'); + equal(_emberMetalProperty_get.get(obj, 'foo.faz'), 'BAR'); + }); + + QUnit.test('old dependent keys should not trigger property changes', function () { + var obj1 = Object.create(null); + _emberMetalProperties.defineProperty(obj1, 'foo', null, null); + _emberMetalProperties.defineProperty(obj1, 'bar', _emberMetalAlias.default('foo')); + _emberMetalProperties.defineProperty(obj1, 'baz', _emberMetalAlias.default('foo')); + _emberMetalProperties.defineProperty(obj1, 'baz', _emberMetalAlias.default('bar')); // redefine baz + _emberMetalObserver.addObserver(obj1, 'baz', incrementCount); + + _emberMetalProperty_set.set(obj1, 'foo', 'FOO'); + equal(count, 1); + + _emberMetalObserver.removeObserver(obj1, 'baz', incrementCount); + + _emberMetalProperty_set.set(obj1, 'foo', 'OOF'); + equal(count, 1); + }); + + QUnit.test('inheriting an observer of the alias from the prototype then\n redefining the alias on the instance to another property dependent on same key\n does not call the observer twice', function () { + var obj1 = Object.create(null); + + _emberMetalMeta.meta(obj1).proto = obj1; + + _emberMetalProperties.defineProperty(obj1, 'foo', null, null); + _emberMetalProperties.defineProperty(obj1, 'bar', _emberMetalAlias.default('foo')); + _emberMetalProperties.defineProperty(obj1, 'baz', _emberMetalAlias.default('foo')); + _emberMetalObserver.addObserver(obj1, 'baz', incrementCount); + + var obj2 = Object.create(obj1); + _emberMetalProperties.defineProperty(obj2, 'baz', _emberMetalAlias.default('bar')); // override baz + + _emberMetalProperty_set.set(obj2, 'foo', 'FOO'); + equal(count, 1); + + _emberMetalObserver.removeObserver(obj2, 'baz', incrementCount); + + _emberMetalProperty_set.set(obj2, 'foo', 'OOF'); + equal(count, 1); + }); + + QUnit.test('an observer of the alias works if added after defining the alias', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + _emberMetalObserver.addObserver(obj, 'bar', incrementCount); + ok(_emberMetalWatching.isWatching(obj, 'foo.faz')); + _emberMetalProperty_set.set(obj, 'foo.faz', 'BAR'); + equal(count, 1); + }); + + QUnit.test('an observer of the alias works if added before defining the alias', function () { + _emberMetalObserver.addObserver(obj, 'bar', incrementCount); + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + ok(_emberMetalWatching.isWatching(obj, 'foo.faz')); + _emberMetalProperty_set.set(obj, 'foo.faz', 'BAR'); + equal(count, 1); + }); + + QUnit.test('object with alias is dirtied if interior object of alias is set after consumption', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + _emberMetalProperty_get.get(obj, 'bar'); + assertDirty(obj, function () { + return _emberMetalProperty_set.set(obj, 'foo.faz', 'BAR'); + }, 'setting the aliased key should dirty the object'); + }); + + QUnit.test('setting alias on self should fail assertion', function () { + expectAssertion(function () { + return _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('bar')); + }, 'Setting alias \'bar\' on self'); + }); + + function assertDirty(obj, callback, label) { + var tag = _emberMetalTags.tagFor(obj); + var tagValue = tag.value(); + callback(); + ok(!tag.validate(tagValue), label); + } +}); +enifed('ember-metal/tests/alias_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/alias_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/alias_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/binding/connect_test', ['exports', 'ember-environment', 'internal-test-helpers', 'ember-metal/binding', 'ember-metal/run_loop', 'ember-metal/property_set', 'ember-metal/property_get'], function (exports, _emberEnvironment, _internalTestHelpers, _emberMetalBinding, _emberMetalRun_loop, _emberMetalProperty_set, _emberMetalProperty_get) { + 'use strict'; + + function performTest(binding, a, b, get, set, connect) { + if (connect === undefined) { + connect = function () { + return binding.connect(a); + }; + } + + ok(!_emberMetalRun_loop.default.currentRunLoop, 'performTest should not have a currentRunLoop'); + + equal(get(a, 'foo'), 'FOO', 'a should not have changed'); + equal(get(b, 'bar'), 'BAR', 'b should not have changed'); + + connect(); + + equal(get(a, 'foo'), 'BAR', 'a should have changed'); + equal(get(b, 'bar'), 'BAR', 'b should have changed'); + // + // make sure changes sync both ways + _emberMetalRun_loop.default(function () { + return set(b, 'bar', 'BAZZ'); + }); + equal(get(a, 'foo'), 'BAZZ', 'a should have changed'); + + _emberMetalRun_loop.default(function () { + return set(a, 'foo', 'BARF'); + }); + equal(get(b, 'bar'), 'BARF', 'a should have changed'); + } + + var originalLookup = undefined, + lookup = undefined, + GlobalB = undefined; + + QUnit.module('Ember.Binding', { + setup: function () { + originalLookup = _emberEnvironment.context.lookup; + _emberEnvironment.context.lookup = lookup = {}; + }, + teardown: function () { + lookup = null; + _emberEnvironment.context.lookup = originalLookup; + } + }); + + _internalTestHelpers.testBoth('Connecting a binding between two properties', function (get, set) { + var a = { foo: 'FOO', bar: 'BAR' }; + + // a.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'bar'); + + expectDeprecation(function () { + performTest(binding, a, a, get, set); + }, /`Ember\.Binding` is deprecated./); + }); + + _internalTestHelpers.testBoth('Connecting a oneWay binding raises a deprecation', function (get, set) { + var a = { foo: 'FOO', bar: 'BAR', toString: function () { + return ''; + } }; + + // a.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'bar').oneWay(); + + expectDeprecation(function () { + binding.connect(a); + }, /`Ember.Binding` is deprecated/); + }); + + _internalTestHelpers.testBoth('Connecting a binding between two objects', function (get, set) { + var b = { bar: 'BAR' }; + var a = { foo: 'FOO', b: b }; + + // b.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'b.bar'); + + expectDeprecation(function () { + performTest(binding, a, b, get, set); + }, /`Ember\.Binding` is deprecated./); + }); + + _internalTestHelpers.testBoth('Connecting a binding to path', function (get, set) { + var a = { foo: 'FOO' }; + lookup['GlobalB'] = GlobalB = { + b: { bar: 'BAR' } + }; + + var b = get(GlobalB, 'b'); + + // globalB.b.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'GlobalB.b.bar'); + + expectDeprecation(function () { + performTest(binding, a, b, get, set); + }, /`Ember\.Binding` is deprecated./); + + // make sure modifications update + b = { bar: 'BIFF' }; + + _emberMetalRun_loop.default(function () { + return set(GlobalB, 'b', b); + }); + + equal(get(a, 'foo'), 'BIFF', 'a should have changed'); + }); + + _internalTestHelpers.testBoth('Calling connect more than once', function (get, set) { + var b = { bar: 'BAR' }; + var a = { foo: 'FOO', b: b }; + + // b.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'b.bar'); + + expectDeprecation(function () { + performTest(binding, a, b, get, set, function () { + binding.connect(a); + binding.connect(a); + }); + }, /`Ember\.Binding` is deprecated./); + }); + + QUnit.test('inherited bindings should sync on create', function () { + var a = undefined; + _emberMetalRun_loop.default(function () { + function A() { + _emberMetalBinding.bind(this, 'foo', 'bar.baz'); + } + + expectDeprecation(function () { + return a = new A(); + }, /`Ember\.Binding` is deprecated/); + + _emberMetalProperty_set.set(a, 'bar', { baz: 'BAZ' }); + }); + + equal(_emberMetalProperty_get.get(a, 'foo'), 'BAZ', 'should have synced binding on new obj'); + }); +}); +enifed('ember-metal/tests/binding/connect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/binding/connect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/binding/connect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/binding/sync_test', ['exports', 'internal-test-helpers', 'ember-metal/run_loop', 'ember-metal/observer', 'ember-metal/binding', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/property_events'], function (exports, _internalTestHelpers, _emberMetalRun_loop, _emberMetalObserver, _emberMetalBinding, _emberMetalComputed, _emberMetalProperties, _emberMetalProperty_events) { + 'use strict'; + + QUnit.module('system/binding/sync_test.js'); + + _internalTestHelpers.testBoth('bindings should not sync twice in a single run loop', function (get, set) { + var a = undefined, + b = undefined, + setValue = undefined; + var setCalled = 0; + var getCalled = 0; + + _emberMetalRun_loop.default(function () { + a = {}; + + _emberMetalProperties.defineProperty(a, 'foo', _emberMetalComputed.computed({ + get: function (key) { + getCalled++; + return setValue; + }, + set: function (key, value) { + setCalled++; + _emberMetalProperty_events.propertyWillChange(this, key); + setValue = value; + _emberMetalProperty_events.propertyDidChange(this, key); + return value; + } + }).volatile()); + + b = { + a: a + }; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, /`Ember.Binding` is deprecated/); + }); + + // reset after initial binding synchronization + getCalled = 0; + + _emberMetalRun_loop.default(function () { + set(a, 'foo', 'trollface'); + }); + + equal(get(b, 'foo'), 'trollface', 'the binding should sync'); + equal(setCalled, 1, 'Set should only be called once'); + equal(getCalled, 1, 'Get should only be called once'); + }); + + _internalTestHelpers.testBoth('bindings should not infinite loop if computed properties return objects', function (get, set) { + var a = undefined, + b = undefined; + var getCalled = 0; + + _emberMetalRun_loop.default(function () { + a = {}; + + _emberMetalProperties.defineProperty(a, 'foo', _emberMetalComputed.computed(function () { + getCalled++; + if (getCalled > 1000) { + throw 'infinite loop detected'; + } + return ['foo', 'bar']; + })); + + b = { + a: a + }; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, /`Ember.Binding` is deprecated/); + }); + + deepEqual(get(b, 'foo'), ['foo', 'bar'], 'the binding should sync'); + equal(getCalled, 1, 'Get should only be called once'); + }); + + _internalTestHelpers.testBoth('bindings should do the right thing when observers trigger bindings in the opposite direction', function (get, set) { + var a = undefined, + b = undefined, + c = undefined; + + _emberMetalRun_loop.default(function () { + a = { + foo: 'trololol' + }; + + b = { + a: a + }; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, deprecationMessage); + + c = { + a: a + }; + + expectDeprecation(function () { + _emberMetalBinding.bind(c, 'foo', 'a.foo'); + }, deprecationMessage); + }); + + _emberMetalObserver.addObserver(b, 'foo', function () { + return set(c, 'foo', 'what is going on'); + }); + + _emberMetalRun_loop.default(function () { + return set(a, 'foo', 'trollface'); + }); + + equal(get(a, 'foo'), 'what is going on'); + }); + + _internalTestHelpers.testBoth('bindings should not try to sync destroyed objects', function (get, set) { + var a = undefined, + b = undefined; + + _emberMetalRun_loop.default(function () { + a = { + foo: 'trololol' + }; + + b = { + a: a + }; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, deprecationMessage); + }); + + _emberMetalRun_loop.default(function () { + set(a, 'foo', 'trollface'); + set(b, 'isDestroyed', true); + ok(true, 'should not raise'); + }); + + _emberMetalRun_loop.default(function () { + a = { + foo: 'trololol' + }; + + b = { + a: a + }; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, deprecationMessage); + }); + + _emberMetalRun_loop.default(function () { + set(b, 'foo', 'trollface'); + set(a, 'isDestroyed', true); + ok(true, 'should not raise'); + }); + }); +}); +enifed('ember-metal/tests/binding/sync_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/binding/sync_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/binding/sync_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/cache_test', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) { + 'use strict'; + + QUnit.module('Cache'); + + QUnit.test('basic', function () { + var cache = new _emberMetalCache.default(100, function (key) { + return key.toUpperCase(); + }); + + equal(cache.get('foo'), 'FOO'); + equal(cache.get('bar'), 'BAR'); + equal(cache.get('foo'), 'FOO'); + }); + + QUnit.test('explicit sets', function () { + var cache = new _emberMetalCache.default(100, function (key) { + return key.toUpperCase(); + }); + + equal(cache.get('foo'), 'FOO'); + + equal(cache.set('foo', 'FOO!!!'), 'FOO!!!'); + + equal(cache.get('foo'), 'FOO!!!'); + + strictEqual(cache.set('foo', undefined), undefined); + + strictEqual(cache.get('foo'), undefined); + }); + + QUnit.test('caches computation correctly', function () { + var count = 0; + var cache = new _emberMetalCache.default(100, function (key) { + count++; + return key.toUpperCase(); + }); + + equal(count, 0); + cache.get('foo'); + equal(count, 1); + cache.get('bar'); + equal(count, 2); + cache.get('bar'); + equal(count, 2); + cache.get('foo'); + equal(count, 2); + }); + + QUnit.test('caches computation correctly with custom cache keys', function () { + var count = 0; + var cache = new _emberMetalCache.default(100, function (obj) { + count++; + return obj.value.toUpperCase(); + }, function (obj) { + return obj.key; + }); + + equal(count, 0); + cache.get({ key: 'foo', value: 'foo' }); + equal(count, 1); + cache.get({ key: 'bar', value: 'bar' }); + equal(count, 2); + cache.get({ key: 'bar', value: 'bar' }); + equal(count, 2); + cache.get({ key: 'foo', value: 'foo' }); + equal(count, 2); + }); + + QUnit.test('handles undefined value correctly', function () { + var count = 0; + var cache = new _emberMetalCache.default(100, function (key) { + count++; + }); + + equal(count, 0); + strictEqual(cache.get('foo'), undefined); + equal(count, 1); + strictEqual(cache.get('bar'), undefined); + equal(count, 2); + strictEqual(cache.get('bar'), undefined); + equal(count, 2); + strictEqual(cache.get('foo'), undefined); + equal(count, 2); + }); + + QUnit.test('continues working after reaching cache limit', function () { + var cache = new _emberMetalCache.default(3, function (key) { + return key.toUpperCase(); + }); + + cache.get('a'); + cache.get('b'); + cache.get('c'); + + equal(cache.get('d'), 'D'); + equal(cache.get('a'), 'A'); + equal(cache.get('b'), 'B'); + equal(cache.get('c'), 'C'); + }); +}); +enifed('ember-metal/tests/cache_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/cache_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/cache_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/chains_test', ['exports', 'ember-metal/observer', 'ember-metal/property_get', 'ember-metal/chains', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/property_events', 'ember-metal/meta'], function (exports, _emberMetalObserver, _emberMetalProperty_get, _emberMetalChains, _emberMetalProperties, _emberMetalComputed, _emberMetalProperty_events, _emberMetalMeta) { + 'use strict'; + + QUnit.module('Chains'); + + QUnit.test('finishChains should properly copy chains from prototypes to instances', function () { + function didChange() {} + + var obj = {}; + _emberMetalObserver.addObserver(obj, 'foo.bar', null, didChange); + + var childObj = Object.create(obj); + _emberMetalChains.finishChains(childObj); + ok(_emberMetalMeta.peekMeta(obj) !== _emberMetalMeta.peekMeta(childObj).readableChains(), 'The chains object is copied'); + }); + + QUnit.test('does not observe primative values', function (assert) { + var obj = { + foo: { bar: 'STRING' } + }; + + _emberMetalObserver.addObserver(obj, 'foo.bar.baz', null, function () {}); + var meta = _emberMetalMeta.peekMeta(obj); + assert.notOk(meta._object); + }); + + QUnit.test('observer and CP chains', function () { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.default('qux.[]', function () {})); + _emberMetalProperties.defineProperty(obj, 'qux', _emberMetalComputed.default(function () {})); + + // create DK chains + _emberMetalProperty_get.get(obj, 'foo'); + + // create observer chain + _emberMetalObserver.addObserver(obj, 'qux.length', function () {}); + + /* + +-----+ + | qux | root CP + +-----+ + ^ + +------+-----+ + | | + +--------+ +----+ + | length | | [] | chainWatchers + +--------+ +----+ + observer CP(foo, 'qux.[]') + */ + + // invalidate qux + _emberMetalProperty_events.propertyDidChange(obj, 'qux'); + + // CP chain is blown away + + /* + +-----+ + | qux | root CP + +-----+ + ^ + +------+xxxxxx + | x + +--------+ xxxxxx + | length | x [] x chainWatchers + +--------+ xxxxxx + observer CP(foo, 'qux.[]') + */ + + _emberMetalProperty_get.get(obj, 'qux'); // CP chain re-recreated + ok(true, 'no crash'); + }); + + QUnit.test('checks cache correctly', function (assert) { + var obj = {}; + var parentChainNode = new _emberMetalChains.ChainNode(null, null, obj); + var chainNode = new _emberMetalChains.ChainNode(parentChainNode, 'foo'); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.default(function () { + return undefined; + })); + _emberMetalProperty_get.get(obj, 'foo'); + + assert.strictEqual(chainNode.value(), undefined); + }); +}); +enifed('ember-metal/tests/chains_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/chains_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/chains_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/computed_test', ['exports', 'ember-runtime', 'internal-test-helpers', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/watching', 'ember-metal/observer'], function (exports, _emberRuntime, _internalTestHelpers, _emberMetalComputed, _emberMetalProperties, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWatching, _emberMetalObserver) { + 'use strict'; + + var obj = undefined, + count = undefined; + + QUnit.module('computed'); + + QUnit.test('computed property should be an instance of descriptor', function () { + ok(_emberMetalComputed.computed(function () {}) instanceof _emberMetalProperties.Descriptor); + }); + + QUnit.test('computed properties assert the presence of a getter or setter function', function () { + expectAssertion(function () { + _emberMetalComputed.computed('nogetternorsetter', {}); + }, 'Computed properties must receive a getter or a setter, you passed none.'); + }); + + QUnit.test('computed properties check for the presence of a function or configuration object', function () { + expectAssertion(function () { + _emberMetalComputed.computed('nolastargument'); + }, 'Ember.computed expects a function or an object as last argument.'); + }); + + QUnit.test('computed properties defined with an object only allow `get` and `set` keys', function () { + expectAssertion(function () { + _emberMetalComputed.computed({ + get: function () {}, + set: function () {}, + other: function () {} + }); + }, 'Config object passed to an Ember.computed can only contain `get` or `set` keys.'); + }); + + QUnit.test('defining computed property should invoke property on get', function () { + var obj = {}; + var count = 0; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function (key) { + count++; + return 'computed ' + key; + })); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'computed foo', 'should return value'); + equal(count, 1, 'should have invoked computed property'); + }); + + QUnit.test('defining computed property should invoke property on set', function () { + var obj = {}; + var count = 0; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + count++; + this['__' + key] = 'computed ' + value; + return this['__' + key]; + } + })); + + equal(_emberMetalProperty_set.set(obj, 'foo', 'bar'), 'bar', 'should return set value'); + equal(count, 1, 'should have invoked computed property'); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'computed bar', 'should return new value'); + }); + + QUnit.test('defining a computed property with a dependent key ending with @each is expanded to []', function () { + var cp = _emberMetalComputed.computed('blazo.@each', function () {}); + + deepEqual(cp._dependentKeys, ['blazo.[]']); + + cp = _emberMetalComputed.computed('qux', 'zoopa.@each', function () {}); + + deepEqual(cp._dependentKeys, ['qux', 'zoopa.[]']); + }); + + QUnit.test('defining a computed property with a dependent key more than one level deep beyond @each is not supported', function () { + expectNoWarning(function () { + _emberMetalComputed.computed('todos', function () {}); + }); + + expectNoWarning(function () { + _emberMetalComputed.computed('todos.@each.owner', function () {}); + }); + + expectWarning(function () { + _emberMetalComputed.computed('todos.@each.owner.name', function () {}); + }, /You used the key "todos\.@each\.owner\.name" which is invalid\. /); + + expectWarning(function () { + _emberMetalComputed.computed('todos.@each.owner.@each.name', function () {}); + }, /You used the key "todos\.@each\.owner\.@each\.name" which is invalid\. /); + }); + + var objA = undefined, + objB = undefined; + QUnit.module('computed should inherit through prototype', { + setup: function () { + objA = { __foo: 'FOO' }; + _emberMetalProperties.defineProperty(objA, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'computed ' + value; + return this['__' + key]; + } + })); + + objB = Object.create(objA); + objB.__foo = 'FOO'; // make a copy; + }, + + teardown: function () { + objA = objB = null; + } + }); + + _internalTestHelpers.testBoth('using get() and set()', function (get, set) { + equal(get(objA, 'foo'), 'FOO', 'should get FOO from A'); + equal(get(objB, 'foo'), 'FOO', 'should get FOO from B'); + + set(objA, 'foo', 'BIFF'); + equal(get(objA, 'foo'), 'computed BIFF', 'should change A'); + equal(get(objB, 'foo'), 'FOO', 'should NOT change B'); + + set(objB, 'foo', 'bar'); + equal(get(objB, 'foo'), 'computed bar', 'should change B'); + equal(get(objA, 'foo'), 'computed BIFF', 'should NOT change A'); + + set(objA, 'foo', 'BAZ'); + equal(get(objA, 'foo'), 'computed BAZ', 'should change A'); + equal(get(objB, 'foo'), 'computed bar', 'should NOT change B'); + }); + + QUnit.module('redefining computed property to normal', { + setup: function () { + objA = { __foo: 'FOO' }; + _emberMetalProperties.defineProperty(objA, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'computed ' + value; + return this['__' + key]; + } + })); + + objB = Object.create(objA); + _emberMetalProperties.defineProperty(objB, 'foo'); // make this just a normal property. + }, + + teardown: function () { + objA = objB = null; + } + }); + + _internalTestHelpers.testBoth('using get() and set()', function (get, set) { + equal(get(objA, 'foo'), 'FOO', 'should get FOO from A'); + equal(get(objB, 'foo'), undefined, 'should get undefined from B'); + + set(objA, 'foo', 'BIFF'); + equal(get(objA, 'foo'), 'computed BIFF', 'should change A'); + equal(get(objB, 'foo'), undefined, 'should NOT change B'); + + set(objB, 'foo', 'bar'); + equal(get(objB, 'foo'), 'bar', 'should change B'); + equal(get(objA, 'foo'), 'computed BIFF', 'should NOT change A'); + + set(objA, 'foo', 'BAZ'); + equal(get(objA, 'foo'), 'computed BAZ', 'should change A'); + equal(get(objB, 'foo'), 'bar', 'should NOT change B'); + }); + + QUnit.module('redefining computed property to another property', { + setup: function () { + objA = { __foo: 'FOO' }; + _emberMetalProperties.defineProperty(objA, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'A ' + value; + return this['__' + key]; + } + })); + + objB = Object.create(objA); + objB.__foo = 'FOO'; + _emberMetalProperties.defineProperty(objB, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'B ' + value; + return this['__' + key]; + } + })); + }, + + teardown: function () { + objA = objB = null; + } + }); + + _internalTestHelpers.testBoth('using get() and set()', function (get, set) { + equal(get(objA, 'foo'), 'FOO', 'should get FOO from A'); + equal(get(objB, 'foo'), 'FOO', 'should get FOO from B'); + + set(objA, 'foo', 'BIFF'); + equal(get(objA, 'foo'), 'A BIFF', 'should change A'); + equal(get(objB, 'foo'), 'FOO', 'should NOT change B'); + + set(objB, 'foo', 'bar'); + equal(get(objB, 'foo'), 'B bar', 'should change B'); + equal(get(objA, 'foo'), 'A BIFF', 'should NOT change A'); + + set(objA, 'foo', 'BAZ'); + equal(get(objA, 'foo'), 'A BAZ', 'should change A'); + equal(get(objB, 'foo'), 'B bar', 'should NOT change B'); + }); + + QUnit.module('computed - metadata'); + + QUnit.test('can set metadata on a computed property', function () { + var computedProperty = _emberMetalComputed.computed(function () {}); + computedProperty.meta({ key: 'keyValue' }); + + equal(computedProperty.meta().key, 'keyValue', 'saves passed meta hash to the _meta property'); + }); + + QUnit.test('meta should return an empty hash if no meta is set', function () { + var computedProperty = _emberMetalComputed.computed(function () {}); + deepEqual(computedProperty.meta(), {}, 'returned value is an empty hash'); + }); + + // .......................................................... + // CACHEABLE + // + + QUnit.module('computed - cacheable', { + setup: function () { + obj = {}; + count = 0; + var func = function (key, value) { + count++; + return 'bar ' + count; + }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ get: func, set: func })); + }, + + teardown: function () { + obj = count = null; + } + }); + + _internalTestHelpers.testBoth('cacheable should cache', function (get, set) { + equal(get(obj, 'foo'), 'bar 1', 'first get'); + equal(get(obj, 'foo'), 'bar 1', 'second get'); + equal(count, 1, 'should only invoke once'); + }); + + _internalTestHelpers.testBoth('modifying a cacheable property should update cache', function (get, set) { + equal(get(obj, 'foo'), 'bar 1', 'first get'); + equal(get(obj, 'foo'), 'bar 1', 'second get'); + + equal(set(obj, 'foo', 'baz'), 'baz', 'setting'); + equal(get(obj, 'foo'), 'bar 2', 'third get'); + equal(count, 2, 'should not invoke again'); + }); + + _internalTestHelpers.testBoth('inherited property should not pick up cache', function (get, set) { + var objB = Object.create(obj); + + equal(get(obj, 'foo'), 'bar 1', 'obj first get'); + equal(get(objB, 'foo'), 'bar 2', 'objB first get'); + + equal(get(obj, 'foo'), 'bar 1', 'obj second get'); + equal(get(objB, 'foo'), 'bar 2', 'objB second get'); + + set(obj, 'foo', 'baz'); // modify A + equal(get(obj, 'foo'), 'bar 3', 'obj third get'); + equal(get(objB, 'foo'), 'bar 2', 'objB third get'); + }); + + _internalTestHelpers.testBoth('cacheFor should return the cached value', function (get, set) { + equal(_emberMetalComputed.cacheFor(obj, 'foo'), undefined, 'should not yet be a cached value'); + + get(obj, 'foo'); + + equal(_emberMetalComputed.cacheFor(obj, 'foo'), 'bar 1', 'should retrieve cached value'); + }); + + _internalTestHelpers.testBoth('cacheFor should return falsy cached values', function (get, set) { + _emberMetalProperties.defineProperty(obj, 'falsy', _emberMetalComputed.computed(function () { + return false; + })); + + equal(_emberMetalComputed.cacheFor(obj, 'falsy'), undefined, 'should not yet be a cached value'); + + get(obj, 'falsy'); + + equal(_emberMetalComputed.cacheFor(obj, 'falsy'), false, 'should retrieve cached value'); + }); + + _internalTestHelpers.testBoth('setting a cached computed property passes the old value as the third argument', function (get, set) { + var obj = { + foo: 0 + }; + + var receivedOldValue = undefined; + + _emberMetalProperties.defineProperty(obj, 'plusOne', _emberMetalComputed.computed({ + get: function () {}, + set: function (key, value, oldValue) { + receivedOldValue = oldValue; + return value; + } }).property('foo')); + + set(obj, 'plusOne', 1); + strictEqual(receivedOldValue, undefined, 'oldValue should be undefined'); + + set(obj, 'plusOne', 2); + strictEqual(receivedOldValue, 1, 'oldValue should be 1'); + + set(obj, 'plusOne', 3); + strictEqual(receivedOldValue, 2, 'oldValue should be 2'); + }); + + // .......................................................... + // DEPENDENT KEYS + // + + QUnit.module('computed - dependentkey', { + setup: function () { + obj = { bar: 'baz' }; + count = 0; + var getterAndSetter = function (key, value) { + count++; + _emberMetalProperty_get.get(this, 'bar'); + return 'bar ' + count; + }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: getterAndSetter, + set: getterAndSetter + }).property('bar')); + }, + + teardown: function () { + obj = count = null; + } + }); + + _internalTestHelpers.testBoth('should lazily watch dependent keys on set', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + set(obj, 'foo', 'bar'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily watching dependent key'); + }); + + _internalTestHelpers.testBoth('should lazily watch dependent keys on get', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + get(obj, 'foo'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily watching dependent key'); + }); + + _internalTestHelpers.testBoth('local dependent key should invalidate cache', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'get once'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'cached retrieve'); + + set(obj, 'bar', 'BIFF'); // should invalidate foo + + equal(get(obj, 'foo'), 'bar 2', 'should recache'); + equal(get(obj, 'foo'), 'bar 2', 'cached retrieve'); + }); + + _internalTestHelpers.testBoth('should invalidate multiple nested dependent keys', function (get, set) { + var count = 0; + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + count++; + get(this, 'baz'); + return 'baz ' + count; + }).property('baz')); + + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), false, 'precond not watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'get once'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), true, 'lazily setup watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'cached retrieve'); + + set(obj, 'baz', 'BIFF'); // should invalidate bar -> foo + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'should not be watching dependent key after cache cleared'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), false, 'should not be watching dependent key after cache cleared'); + + equal(get(obj, 'foo'), 'bar 2', 'should recache'); + equal(get(obj, 'foo'), 'bar 2', 'cached retrieve'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), true, 'lazily setup watching dependent key'); + }); + + _internalTestHelpers.testBoth('circular keys should not blow up', function (get, set) { + var func = function (key, value) { + count++; + return 'bar ' + count; + }; + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed({ get: func, set: func }).property('foo')); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function (key) { + count++; + return 'foo ' + count; + }).property('bar')); + + equal(get(obj, 'foo'), 'foo 1', 'get once'); + equal(get(obj, 'foo'), 'foo 1', 'cached retrieve'); + + set(obj, 'bar', 'BIFF'); // should invalidate bar -> foo -> bar + + equal(get(obj, 'foo'), 'foo 3', 'should recache'); + equal(get(obj, 'foo'), 'foo 3', 'cached retrieve'); + }); + + _internalTestHelpers.testBoth('redefining a property should undo old dependent keys', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + equal(get(obj, 'foo'), 'bar 1'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily watching dependent key'); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + count++; + return 'baz ' + count; + }).property('baz')); + + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'after redefining should not be watching dependent key'); + + equal(get(obj, 'foo'), 'baz 2'); + + set(obj, 'bar', 'BIFF'); // should not kill cache + equal(get(obj, 'foo'), 'baz 2'); + + set(obj, 'baz', 'BOP'); + equal(get(obj, 'foo'), 'baz 3'); + }); + + _internalTestHelpers.testBoth('can watch multiple dependent keys specified declaratively via brace expansion', function (get, set) { + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function (key) { + count++; + return 'foo ' + count; + }).property('qux.{bar,baz}')); + + equal(get(obj, 'foo'), 'foo 1', 'get once'); + equal(get(obj, 'foo'), 'foo 1', 'cached retrieve'); + + set(obj, 'qux', {}); + set(obj, 'qux.bar', 'bar'); // invalidate foo + + equal(get(obj, 'foo'), 'foo 2', 'foo invalidated from bar'); + + set(obj, 'qux.baz', 'baz'); // invalidate foo + + equal(get(obj, 'foo'), 'foo 3', 'foo invalidated from baz'); + + set(obj, 'qux.quux', 'quux'); // do not invalidate foo + + equal(get(obj, 'foo'), 'foo 3', 'foo not invalidated by quux'); + }); + + _internalTestHelpers.testBoth('throws assertion if brace expansion notation has spaces', function (get, set) { + expectAssertion(function () { + _emberMetalProperties.defineProperty(obj, 'roo', _emberMetalComputed.computed(function (key) { + count++; + return 'roo ' + count; + }).property('fee.{bar, baz,bop , }')); + }, /cannot contain spaces/); + }); + + // .......................................................... + // CHAINED DEPENDENT KEYS + // + + var func = undefined; + var moduleOpts = { + setup: function () { + obj = { + foo: { + bar: { + baz: { + biff: 'BIFF' + } + } + } + }; + + count = 0; + func = function () { + count++; + return _emberMetalProperty_get.get(obj, 'foo.bar.baz.biff') + ' ' + count; + }; + }, + + teardown: function () { + obj = count = func = null; + } + }; + + QUnit.module('computed - dependentkey with chained properties', moduleOpts); + + _internalTestHelpers.testBoth('depending on simple chain', function (get, set) { + // assign computed property + _emberMetalProperties.defineProperty(obj, 'prop', _emberMetalComputed.computed(func).property('foo.bar.baz.biff')); + + equal(get(obj, 'prop'), 'BIFF 1'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 2'); + equal(get(obj, 'prop'), 'BUZZ 2'); + + set(get(obj, 'foo.bar'), 'baz', { biff: 'BLOB' }); + equal(get(obj, 'prop'), 'BLOB 3'); + equal(get(obj, 'prop'), 'BLOB 3'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 4'); + equal(get(obj, 'prop'), 'BUZZ 4'); + + set(get(obj, 'foo'), 'bar', { baz: { biff: 'BOOM' } }); + equal(get(obj, 'prop'), 'BOOM 5'); + equal(get(obj, 'prop'), 'BOOM 5'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 6'); + equal(get(obj, 'prop'), 'BUZZ 6'); + + set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(get(obj, 'prop'), 'BLARG 7'); + equal(get(obj, 'prop'), 'BLARG 7'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 8'); + equal(get(obj, 'prop'), 'BUZZ 8'); + + _emberMetalProperties.defineProperty(obj, 'prop'); + set(obj, 'prop', 'NONE'); + equal(get(obj, 'prop'), 'NONE'); + + set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(get(obj, 'prop'), 'NONE'); // should do nothing + equal(count, 8, 'should be not have invoked computed again'); + }); + + _internalTestHelpers.testBoth('chained dependent keys should evaluate computed properties lazily', function (get, set) { + _emberMetalProperties.defineProperty(obj.foo.bar, 'b', _emberMetalComputed.computed(func)); + _emberMetalProperties.defineProperty(obj.foo, 'c', _emberMetalComputed.computed(function () {}).property('bar.b')); + equal(count, 0, 'b should not run'); + }); + + // .......................................................... + // improved-cp-syntax + // + + QUnit.module('computed - improved cp syntax'); + + QUnit.test('setter and getters are passed using an object', function () { + var testObj = _emberRuntime.Object.extend({ + a: '1', + b: '2', + aInt: _emberMetalComputed.computed('a', { + get: function (keyName) { + equal(keyName, 'aInt', 'getter receives the keyName'); + return parseInt(this.get('a')); + }, + set: function (keyName, value, oldValue) { + equal(keyName, 'aInt', 'setter receives the keyName'); + equal(value, 123, 'setter receives the new value'); + equal(oldValue, 1, 'setter receives the old value'); + this.set('a', '' + value); // side effect + return parseInt(this.get('a')); + } + }) + }).create(); + + ok(testObj.get('aInt') === 1, 'getter works'); + testObj.set('aInt', 123); + ok(testObj.get('a') === '123', 'setter works'); + ok(testObj.get('aInt') === 123, 'cp has been updated too'); + }); + + QUnit.test('setter can be omited', function () { + var testObj = _emberRuntime.Object.extend({ + a: '1', + b: '2', + aInt: _emberMetalComputed.computed('a', { + get: function (keyName) { + equal(keyName, 'aInt', 'getter receives the keyName'); + return parseInt(this.get('a')); + } + }) + }).create(); + + ok(testObj.get('aInt') === 1, 'getter works'); + ok(testObj.get('a') === '1'); + testObj.set('aInt', '123'); + ok(testObj.get('aInt') === '123', 'cp has been updated too'); + }); + + QUnit.test('the return value of the setter gets cached', function () { + var testObj = _emberRuntime.Object.extend({ + a: '1', + sampleCP: _emberMetalComputed.computed('a', { + get: function (keyName) { + ok(false, 'The getter should not be invoked'); + return 'get-value'; + }, + set: function (keyName, value, oldValue) { + return 'set-value'; + } + }) + }).create(); + + testObj.set('sampleCP', 'abcd'); + ok(testObj.get('sampleCP') === 'set-value', 'The return value of the CP was cached'); + }); + + // .......................................................... + // BUGS + // + + QUnit.module('computed edge cases'); + + QUnit.test('adding a computed property should show up in key iteration', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () {})); + + var found = []; + for (var key in obj) { + found.push(key); + } + ok(found.indexOf('foo') >= 0, 'should find computed property in iteration found=' + found); + ok('foo' in obj, 'foo in obj should pass'); + }); + + _internalTestHelpers.testBoth('when setting a value after it had been retrieved empty don\'t pass function UNDEFINED as oldValue', function (get, set) { + var obj = {}; + var oldValueIsNoFunction = true; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () {}, + set: function (key, value, oldValue) { + if (typeof oldValue === 'function') { + oldValueIsNoFunction = false; + } + return undefined; + } + })); + + get(obj, 'foo'); + set(obj, 'foo', undefined); + + ok(oldValueIsNoFunction); + }); + + QUnit.module('computed - setter'); + + _internalTestHelpers.testBoth('setting a watched computed property', function (get, set) { + var obj = { + firstName: 'Yehuda', + lastName: 'Katz' + }; + + _emberMetalProperties.defineProperty(obj, 'fullName', _emberMetalComputed.computed({ + get: function () { + return get(this, 'firstName') + ' ' + get(this, 'lastName'); + }, + set: function (key, value) { + var values = value.split(' '); + set(this, 'firstName', values[0]); + set(this, 'lastName', values[1]); + return value; + } + }).property('firstName', 'lastName')); + + var fullNameWillChange = 0; + var fullNameDidChange = 0; + var firstNameWillChange = 0; + var firstNameDidChange = 0; + var lastNameWillChange = 0; + var lastNameDidChange = 0; + _emberMetalObserver._addBeforeObserver(obj, 'fullName', function () { + fullNameWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'fullName', function () { + fullNameDidChange++; + }); + _emberMetalObserver._addBeforeObserver(obj, 'firstName', function () { + firstNameWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'firstName', function () { + firstNameDidChange++; + }); + _emberMetalObserver._addBeforeObserver(obj, 'lastName', function () { + lastNameWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'lastName', function () { + lastNameDidChange++; + }); + + equal(get(obj, 'fullName'), 'Yehuda Katz'); + + set(obj, 'fullName', 'Yehuda Katz'); + + set(obj, 'fullName', 'Kris Selden'); + + equal(get(obj, 'fullName'), 'Kris Selden'); + equal(get(obj, 'firstName'), 'Kris'); + equal(get(obj, 'lastName'), 'Selden'); + + equal(fullNameWillChange, 1); + equal(fullNameDidChange, 1); + equal(firstNameWillChange, 1); + equal(firstNameDidChange, 1); + equal(lastNameWillChange, 1); + equal(lastNameDidChange, 1); + }); + + _internalTestHelpers.testBoth('setting a cached computed property that modifies the value you give it', function (get, set) { + var obj = { + foo: 0 + }; + + _emberMetalProperties.defineProperty(obj, 'plusOne', _emberMetalComputed.computed({ + get: function (key) { + return get(this, 'foo') + 1; + }, + set: function (key, value) { + set(this, 'foo', value); + return value + 1; + } + }).property('foo')); + + var plusOneWillChange = 0; + var plusOneDidChange = 0; + _emberMetalObserver._addBeforeObserver(obj, 'plusOne', function () { + plusOneWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'plusOne', function () { + plusOneDidChange++; + }); + + equal(get(obj, 'plusOne'), 1); + set(obj, 'plusOne', 1); + equal(get(obj, 'plusOne'), 2); + set(obj, 'plusOne', 1); + equal(get(obj, 'plusOne'), 2); + + equal(plusOneWillChange, 1); + equal(plusOneDidChange, 1); + + set(obj, 'foo', 5); + equal(get(obj, 'plusOne'), 6); + + equal(plusOneWillChange, 2); + equal(plusOneDidChange, 2); + }); + + QUnit.module('computed - default setter'); + + _internalTestHelpers.testBoth('when setting a value on a computed property that doesn\'t handle sets', function (get, set) { + var obj = {}; + var observerFired = false; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return 'foo'; + })); + + _emberMetalObserver.addObserver(obj, 'foo', null, function () { + return observerFired = true; + }); + + set(obj, 'foo', 'bar'); + + equal(get(obj, 'foo'), 'bar', 'The set value is properly returned'); + ok(typeof obj.foo === 'string', 'The computed property was removed'); + ok(observerFired, 'The observer was still notified'); + }); + + QUnit.module('computed - readOnly'); + + QUnit.test('is chainable', function () { + var cp = _emberMetalComputed.computed(function () {}).readOnly(); + + ok(cp instanceof _emberMetalProperties.Descriptor); + ok(cp instanceof _emberMetalComputed.ComputedProperty); + }); + + QUnit.test('throws assertion if called over a CP with a setter defined with the new syntax', function () { + expectAssertion(function () { + _emberMetalComputed.computed({ + get: function () {}, + set: function () {} + }).readOnly(); + }, /Computed properties that define a setter using the new syntax cannot be read-only/); + }); + + _internalTestHelpers.testBoth('protects against setting', function (get, set) { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function (key) { + return 'barValue'; + }).readOnly()); + + equal(get(obj, 'bar'), 'barValue'); + + throws(function () { + set(obj, 'bar', 'newBar'); + }, /Cannot set read\-only property "bar" on object:/); + + equal(get(obj, 'bar'), 'barValue'); + }); +}); +enifed('ember-metal/tests/computed_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/computed_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/computed_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/descriptor_test', ['exports', 'ember-runtime', 'ember-metal/mixin', 'ember-metal/properties', 'ember-metal/descriptor'], function (exports, _emberRuntime, _emberMetalMixin, _emberMetalProperties, _emberMetalDescriptor) { + 'use strict'; + + // IE9 soft-fails when trying to delete a non-configurable property + var hasCompliantDelete = (function () { + var obj = {}; + + Object.defineProperty(obj, 'zomg', { configurable: false, value: 'zomg' }); + + try { + delete obj.zomg; + } catch (e) { + return true; + } + + return false; + })(); + + // IE9 soft-fails when trying to assign to a non-writable property + var hasCompliantAssign = (function () { + var obj = {}; + + Object.defineProperty(obj, 'zomg', { writable: false, value: 'zomg' }); + + try { + obj.zomg = 'lol'; + } catch (e) { + return true; + } + + return false; + })(); + + var DescriptorTest = (function () { + + /* abstract static module(title: string); */ + + DescriptorTest.test = function test(title, callback) { + var _this = this; + + QUnit.test(title, function (assert) { + callback(assert, new _this(assert)); + }); + }; + + function DescriptorTest(assert) { + babelHelpers.classCallCheck(this, DescriptorTest); + + this.assert = assert; + } + + /* abstract install(key: string, desc: Descriptor); */ + + /* abstract set(key: string, value: any); */ + + /* abstract finalize(): Object; */ + return DescriptorTest; + })(); + + var classes = [(function (_DescriptorTest) { + babelHelpers.inherits(_class, _DescriptorTest); + + _class.module = function module(title) { + QUnit.module(title + ': using defineProperty on an object directly'); + }; + + function _class(assert) { + babelHelpers.classCallCheck(this, _class); + + _DescriptorTest.call(this, assert); + this.object = {}; + } + + _class.prototype.install = function install(key, desc) { + var object = this.object; + var assert = this.assert; + + _emberMetalProperties.defineProperty(object, key, desc); + + assert.ok(object.hasOwnProperty(key)); + }; + + _class.prototype.set = function set(key, value) { + this.object[key] = value; + }; + + _class.prototype.finalize = function finalize() { + return this.object; + }; + + _class.prototype.source = function source() { + return this.object; + }; + + return _class; + })(DescriptorTest), (function (_DescriptorTest2) { + babelHelpers.inherits(_class2, _DescriptorTest2); + + _class2.module = function module(title) { + QUnit.module(title + ': using defineProperty on a prototype'); + }; + + function _class2(assert) { + babelHelpers.classCallCheck(this, _class2); + + _DescriptorTest2.call(this, assert); + this.proto = {}; + } + + _class2.prototype.install = function install(key, desc) { + var proto = this.proto; + var assert = this.assert; + + _emberMetalProperties.defineProperty(proto, key, desc); + + assert.ok(proto.hasOwnProperty(key)); + }; + + _class2.prototype.set = function set(key, value) { + this.proto[key] = value; + }; + + _class2.prototype.finalize = function finalize() { + return Object.create(this.proto); + }; + + _class2.prototype.source = function source() { + return this.proto; + }; + + return _class2; + })(DescriptorTest), (function (_DescriptorTest3) { + babelHelpers.inherits(_class3, _DescriptorTest3); + + _class3.module = function module(title) { + QUnit.module(title + ': in EmberObject.extend()'); + }; + + function _class3(assert) { + babelHelpers.classCallCheck(this, _class3); + + _DescriptorTest3.call(this, assert); + this.klass = null; + this.props = {}; + } + + _class3.prototype.install = function install(key, desc) { + this.props[key] = desc; + }; + + _class3.prototype.set = function set(key, value) { + this.props[key] = value; + }; + + _class3.prototype.finalize = function finalize() { + this.klass = _emberRuntime.Object.extend(this.props); + return this.klass.create(); + }; + + _class3.prototype.source = function source() { + return this.klass.prototype; + }; + + return _class3; + })(DescriptorTest), (function (_DescriptorTest4) { + babelHelpers.inherits(_class4, _DescriptorTest4); + + _class4.module = function module(title) { + QUnit.module(title + ': in EmberObject.extend() through a mixin'); + }; + + function _class4(assert) { + babelHelpers.classCallCheck(this, _class4); + + _DescriptorTest4.call(this, assert); + this.klass = null; + this.props = {}; + } + + _class4.prototype.install = function install(key, desc) { + this.props[key] = desc; + }; + + _class4.prototype.set = function set(key, value) { + this.props[key] = value; + }; + + _class4.prototype.finalize = function finalize() { + this.klass = _emberRuntime.Object.extend(_emberMetalMixin.Mixin.create(this.props)); + return this.klass.create(); + }; + + _class4.prototype.source = function source() { + return this.klass.prototype; + }; + + return _class4; + })(DescriptorTest), (function (_DescriptorTest5) { + babelHelpers.inherits(_class5, _DescriptorTest5); + + _class5.module = function module(title) { + QUnit.module(title + ': inherited from another EmberObject super class'); + }; + + function _class5(assert) { + babelHelpers.classCallCheck(this, _class5); + + _DescriptorTest5.call(this, assert); + this.superklass = null; + this.props = {}; + } + + _class5.prototype.install = function install(key, desc) { + this.props[key] = desc; + }; + + _class5.prototype.set = function set(key, value) { + this.props[key] = value; + }; + + _class5.prototype.finalize = function finalize() { + this.superklass = _emberRuntime.Object.extend(this.props); + return this.superklass.extend().create(); + }; + + _class5.prototype.source = function source() { + return this.superklass.prototype; + }; + + return _class5; + })(DescriptorTest)]; + + classes.forEach(function (TestClass) { + TestClass.module('ember-metal/descriptor'); + + TestClass.test('defining a configurable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ configurable: true, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + delete source.foo; + + assert.strictEqual(obj.foo, undefined); + + Object.defineProperty(source, 'foo', { configurable: true, value: 'baz' }); + + assert.equal(obj.foo, 'baz'); + }); + + TestClass.test('defining a non-configurable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ configurable: false, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + if (hasCompliantDelete) { + assert.throws(function () { + return delete source.foo; + }, TypeError); + } else { + delete source.foo; + } + + assert.throws(function () { + return Object.defineProperty(source, 'foo', { configurable: true, value: 'baz' }); + }, TypeError); + + assert.equal(obj.foo, 'bar'); + }); + + TestClass.test('defining an enumerable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ enumerable: true, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + assert.ok(Object.keys(source).indexOf('foo') !== -1); + }); + + TestClass.test('defining a non-enumerable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ enumerable: false, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + assert.ok(Object.keys(source).indexOf('foo') === -1); + }); + + TestClass.test('defining a writable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ writable: true, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + source.foo = 'baz'; + + assert.equal(obj.foo, 'baz'); + + obj.foo = 'bat'; + + assert.equal(obj.foo, 'bat'); + }); + + TestClass.test('defining a non-writable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ writable: false, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + if (hasCompliantAssign) { + assert.throws(function () { + return source.foo = 'baz'; + }, TypeError); + assert.throws(function () { + return obj.foo = 'baz'; + }, TypeError); + } else { + source.foo = 'baz'; + obj.foo = 'baz'; + } + + assert.equal(obj.foo, 'bar'); + }); + + TestClass.test('defining a getter', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ + get: function () { + return this.__foo__; + } + })); + + factory.set('__foo__', 'bar'); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + obj.__foo__ = 'baz'; + + assert.equal(obj.foo, 'baz'); + }); + + TestClass.test('defining a setter', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ + set: function (value) { + this.__foo__ = value; + } + })); + + factory.set('__foo__', 'bar'); + + var obj = factory.finalize(); + + assert.equal(obj.__foo__, 'bar'); + + obj.foo = 'baz'; + + assert.equal(obj.__foo__, 'baz'); + }); + + TestClass.test('combining multiple setter and getters', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ + get: function () { + return this.__foo__; + }, + + set: function (value) { + this.__foo__ = value; + } + })); + + factory.set('__foo__', 'foo'); + + factory.install('bar', _emberMetalDescriptor.default({ + get: function () { + return this.__bar__; + }, + + set: function (value) { + this.__bar__ = value; + } + })); + + factory.set('__bar__', 'bar'); + + factory.install('fooBar', _emberMetalDescriptor.default({ + get: function () { + return this.foo + '-' + this.bar; + } + })); + + var obj = factory.finalize(); + + assert.equal(obj.fooBar, 'foo-bar'); + + obj.foo = 'FOO'; + + assert.equal(obj.fooBar, 'FOO-bar'); + + obj.__bar__ = 'BAR'; + + assert.equal(obj.fooBar, 'FOO-BAR'); + + if (hasCompliantAssign) { + assert.throws(function () { + return obj.fooBar = 'foobar'; + }, TypeError); + } else { + obj.fooBar = 'foobar'; + } + + assert.equal(obj.fooBar, 'FOO-BAR'); + }); + }); +}); +enifed('ember-metal/tests/descriptor_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/descriptor_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/descriptor_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/error_test', ['exports', 'ember-metal/error'], function (exports, _emberMetalError) { + 'use strict'; + + QUnit.module('Ember Error Throwing'); + + QUnit.test('new Ember.Error displays provided message', function () { + throws(function () { + throw new _emberMetalError.default('A Message'); + }, function (e) { + return e.message === 'A Message'; + }, 'the assigned message was displayed'); + }); +}); +enifed('ember-metal/tests/error_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/error_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/error_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/events_test', ['exports', 'ember-metal/mixin', 'ember-metal/meta', 'ember-metal/events'], function (exports, _emberMetalMixin, _emberMetalMeta, _emberMetalEvents) { + 'use strict'; + + QUnit.module('system/props/events_test'); + + QUnit.test('listener should receive event - removing should remove', function () { + var obj = {}; + var count = 0; + + function F() { + count++; + } + + _emberMetalEvents.addListener(obj, 'event!', F); + equal(count, 0, 'nothing yet'); + + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 1, 'received event'); + + _emberMetalEvents.removeListener(obj, 'event!', F); + + count = 0; + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 0, 'received event'); + }); + + QUnit.test('listeners should be inherited', function () { + var obj = {}; + var count = 0; + var F = function () { + count++; + }; + + _emberMetalEvents.addListener(obj, 'event!', F); + + var obj2 = Object.create(obj); + + equal(count, 0, 'nothing yet'); + + _emberMetalEvents.sendEvent(obj2, 'event!'); + equal(count, 1, 'received event'); + + _emberMetalEvents.removeListener(obj2, 'event!', F); + + count = 0; + _emberMetalEvents.sendEvent(obj2, 'event!'); + equal(count, 0, 'did not receive event'); + + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 1, 'should still invoke on parent'); + }); + + QUnit.test('adding a listener more than once should only invoke once', function () { + var obj = {}; + var count = 0; + function F() { + count++; + } + _emberMetalEvents.addListener(obj, 'event!', F); + _emberMetalEvents.addListener(obj, 'event!', F); + + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 1, 'should only invoke once'); + }); + + QUnit.test('adding a listener with a target should invoke with target', function () { + var obj = {}; + var target = undefined; + + target = { + count: 0, + method: function () { + this.count++; + } + }; + + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(target.count, 1, 'should invoke'); + }); + + QUnit.test('suspending a listener should not invoke during callback', function () { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + count: 0, + method: function () { + this.count++; + } + }; + + otherTarget = { + count: 0, + method: function () { + this.count++; + } + }; + + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + _emberMetalEvents.addListener(obj, 'event!', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + _emberMetalEvents.sendEvent(obj, 'event!'); + + return 'result'; + } + + _emberMetalEvents.sendEvent(obj, 'event!'); + + equal(_emberMetalEvents.suspendListener(obj, 'event!', target, target.method, callback), 'result'); + + _emberMetalEvents.sendEvent(obj, 'event!'); + + equal(target.count, 2, 'should invoke'); + equal(otherTarget.count, 3, 'should invoke'); + }); + + QUnit.test('adding a listener with string method should lookup method on event delivery', function () { + var obj = {}; + var target = undefined; + + target = { + count: 0, + method: function () {} + }; + + _emberMetalEvents.addListener(obj, 'event!', target, 'method'); + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(target.count, 0, 'should invoke but do nothing'); + + target.method = function () { + this.count++; + }; + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(target.count, 1, 'should invoke now'); + }); + + QUnit.test('calling sendEvent with extra params should be passed to listeners', function () { + var obj = {}; + var params = null; + _emberMetalEvents.addListener(obj, 'event!', function () { + params = Array.prototype.slice.call(arguments); + }); + + _emberMetalEvents.sendEvent(obj, 'event!', ['foo', 'bar']); + deepEqual(params, ['foo', 'bar'], 'params should be saved'); + }); + + QUnit.test('hasListeners tells you if there are listeners for a given event', function () { + var obj = {}; + + function F() {} + function F2() {} + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'no listeners at first'); + + _emberMetalEvents.addListener(obj, 'event!', F); + _emberMetalEvents.addListener(obj, 'event!', F2); + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + + _emberMetalEvents.removeListener(obj, 'event!', F); + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + + _emberMetalEvents.removeListener(obj, 'event!', F2); + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'has no more listeners'); + + _emberMetalEvents.addListener(obj, 'event!', F); + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + }); + + QUnit.test('calling removeListener without method should remove all listeners', function () { + var obj = {}; + function F() {} + function F2() {} + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'no listeners at first'); + + _emberMetalEvents.addListener(obj, 'event!', F); + _emberMetalEvents.addListener(obj, 'event!', F2); + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + _emberMetalEvents.removeListener(obj, 'event!'); + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'has no more listeners'); + }); + + QUnit.test('while suspended, it should not be possible to add a duplicate listener', function () { + var obj = {}; + var target = undefined; + + target = { + count: 0, + method: function () { + this.count++; + } + }; + + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + + function callback() { + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + } + + _emberMetalEvents.sendEvent(obj, 'event!'); + + _emberMetalEvents.suspendListener(obj, 'event!', target, target.method, callback); + + equal(target.count, 1, 'should invoke'); + equal(_emberMetalMeta.meta(obj).matchingListeners('event!').length, 3, 'a duplicate listener wasn\'t added'); + + // now test suspendListeners... + + _emberMetalEvents.sendEvent(obj, 'event!'); + + _emberMetalEvents.suspendListeners(obj, ['event!'], target, target.method, callback); + + equal(target.count, 2, 'should have invoked again'); + equal(_emberMetalMeta.meta(obj).matchingListeners('event!').length, 3, 'a duplicate listener wasn\'t added'); + }); + + QUnit.test('a listener can be added as part of a mixin', function () { + var triggered = 0; + var MyMixin = _emberMetalMixin.Mixin.create({ + foo1: _emberMetalEvents.on('bar', function () { + triggered++; + }), + + foo2: _emberMetalEvents.on('bar', function () { + triggered++; + }) + }); + + var obj = {}; + MyMixin.apply(obj); + + _emberMetalEvents.sendEvent(obj, 'bar'); + equal(triggered, 2, 'should invoke listeners'); + }); + + QUnit.test('a listener added as part of a mixin may be overridden', function () { + var triggered = 0; + var FirstMixin = _emberMetalMixin.Mixin.create({ + foo: _emberMetalEvents.on('bar', function () { + triggered++; + }) + }); + var SecondMixin = _emberMetalMixin.Mixin.create({ + foo: _emberMetalEvents.on('baz', function () { + triggered++; + }) + }); + + var obj = {}; + FirstMixin.apply(obj); + SecondMixin.apply(obj); + + _emberMetalEvents.sendEvent(obj, 'bar'); + equal(triggered, 0, 'should not invoke from overriden property'); + + _emberMetalEvents.sendEvent(obj, 'baz'); + equal(triggered, 1, 'should invoke from subclass property'); + }); +}); +enifed('ember-metal/tests/events_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/events_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/events_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/expand_properties_test', ['exports', 'ember-metal/expand_properties'], function (exports, _emberMetalExpand_properties) { + 'use strict'; + + var foundProperties = []; + + function addProperty(property) { + foundProperties.push(property); + } + + QUnit.module('Property Brace Expansion Test', { + setup: function () { + foundProperties = []; + } + }); + + QUnit.test('Properties without expansions are unaffected', function () { + expect(1); + + _emberMetalExpand_properties.default('a', addProperty); + _emberMetalExpand_properties.default('a.b', addProperty); + _emberMetalExpand_properties.default('a.b.[]', addProperty); + _emberMetalExpand_properties.default('a.b.@each.c', addProperty); + + deepEqual(['a', 'a.b', 'a.b.[]', 'a.b.@each.c'].sort(), foundProperties.sort()); + }); + + QUnit.test('A single expansion at the end expands properly', function () { + expect(1); + + _emberMetalExpand_properties.default('a.b.{c,d}', addProperty); + + deepEqual(['a.b.c', 'a.b.d'].sort(), foundProperties.sort()); + }); + + QUnit.test('A property with only a brace expansion expands correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('{a,b,c}', addProperty); + + var expected = ['a', 'b', 'c']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('Expansions with single properties only expand once', function () { + expect(1); + + _emberMetalExpand_properties.default('a.b.{c}.d.{e}', addProperty); + + deepEqual(['a.b.c.d.e'], foundProperties); + }); + + QUnit.test('A single brace expansion expands correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('a.{b,c,d}.e', addProperty); + + var expected = ['a.b.e', 'a.c.e', 'a.d.e']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('Multiple brace expansions work correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('{a,b,c}.d.{e,f}.g', addProperty); + + var expected = ['a.d.e.g', 'a.d.f.g', 'b.d.e.g', 'b.d.f.g', 'c.d.e.g', 'c.d.f.g']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('A property with only brace expansions expands correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('{a,b,c}.{d}.{e,f}', addProperty); + + var expected = ['a.d.e', 'a.d.f', 'b.d.e', 'b.d.f', 'c.d.e', 'c.d.f']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('Nested brace expansions are not allowed', function () { + var nestedBraceProperties = ['a.{b.{c,d}}', 'a.{{b}.c}', 'a.{b,c}.{d.{e,f}.g', 'a.{b.{c}', 'a.{b,c}}']; + + nestedBraceProperties.forEach(function (invalidProperties) { + expectAssertion(function () { + return _emberMetalExpand_properties.default(invalidProperties, addProperty); + }); + }, /Brace expanded properties have to be balanced and cannot be nested/); + }); + + QUnit.test('A pattern must be a string', function () { + expect(1); + + expectAssertion(function () { + _emberMetalExpand_properties.default([], addProperty); + }, /A computed property key must be a string/); + }); + + QUnit.test('A pattern must not contain a space', function () { + expect(1); + + expectAssertion(function () { + _emberMetalExpand_properties.default('a, b', addProperty); + }, /Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"/); + }); +}); +enifed('ember-metal/tests/expand_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/expand_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/expand_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/injected_property_test', ['exports', 'ember-utils', 'ember-metal/properties', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/injected_property'], function (exports, _emberUtils, _emberMetalProperties, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalInjected_property) { + 'use strict'; + + QUnit.module('InjectedProperty'); + + QUnit.test('injected properties should be descriptors', function () { + ok(new _emberMetalInjected_property.default() instanceof _emberMetalProperties.Descriptor); + }); + + QUnit.test('injected properties should be overridable', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default()); + + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'bar', 'should return the overriden value'); + }); + + QUnit.test('getting on an object without an owner or container should fail assertion', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type', 'name')); + + expectAssertion(function () { + _emberMetalProperty_get.get(obj, 'foo'); + }, /Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container./); + }); + + QUnit.test('getting on an object without an owner but with a container should not fail', function () { + var obj = { + container: { + lookup: function (key) { + ok(true, 'should call container.lookup'); + return key; + } + } + }; + + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type', 'name')); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'type:name', 'should return the value of container.lookup'); + }); + + QUnit.test('getting should return a lookup on the container', function () { + expect(2); + + var obj = {}; + + _emberUtils.setOwner(obj, { + lookup: function (key) { + ok(true, 'should call container.lookup'); + return key; + } + }); + + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type', 'name')); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'type:name', 'should return the value of container.lookup'); + }); + + QUnit.test('omitting the lookup name should default to the property name', function () { + var obj = {}; + + _emberUtils.setOwner(obj, { + lookup: function (key) { + return key; + } + }); + + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type')); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'type:foo', 'should lookup the type using the property name'); + }); +}); +enifed('ember-metal/tests/injected_property_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/injected_property_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/injected_property_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/instrumentation_test', ['exports', 'ember-metal/instrumentation'], function (exports, _emberMetalInstrumentation) { + 'use strict'; + + QUnit.module('Ember Instrumentation', { + teardown: function () { + _emberMetalInstrumentation.reset(); + } + }); + + QUnit.test('execute block even if no listeners', function () { + var result = _emberMetalInstrumentation.instrument('render', {}, function () { + return 'hello'; + }); + equal(result, 'hello', 'called block'); + }); + + QUnit.test('subscribing to a simple path receives the listener', function () { + expect(12); + + var sentPayload = {}; + var count = 0; + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + if (count === 0) { + strictEqual(name, 'render'); + } else { + strictEqual(name, 'render.handlebars'); + } + + ok(typeof timestamp === 'number'); + strictEqual(payload, sentPayload); + }, + + after: function (name, timestamp, payload) { + if (count === 0) { + strictEqual(name, 'render'); + } else { + strictEqual(name, 'render.handlebars'); + } + + ok(typeof timestamp === 'number'); + strictEqual(payload, sentPayload); + + count++; + } + }); + + _emberMetalInstrumentation.instrument('render', sentPayload, function () {}); + + _emberMetalInstrumentation.instrument('render.handlebars', sentPayload, function () {}); + }); + + QUnit.test('returning a value from the before callback passes it to the after callback', function () { + expect(2); + + var passthru1 = {}; + var passthru2 = {}; + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + return passthru1; + }, + after: function (name, timestamp, payload, beforeValue) { + strictEqual(beforeValue, passthru1); + } + }); + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + return passthru2; + }, + after: function (name, timestamp, payload, beforeValue) { + strictEqual(beforeValue, passthru2); + } + }); + + _emberMetalInstrumentation.instrument('render', null, function () {}); + }); + + QUnit.test('instrument with 2 args (name, callback) no payload', function () { + expect(1); + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, {}); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', function () {}); + }); + + QUnit.test('instrument with 3 args (name, callback, binding) no payload', function () { + expect(2); + + var binding = {}; + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, {}); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', function () { + deepEqual(this, binding); + }, binding); + }); + + QUnit.test('instrument with 3 args (name, payload, callback) with payload', function () { + expect(1); + + var expectedPayload = { hi: 1 }; + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, expectedPayload); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', expectedPayload, function () {}); + }); + + QUnit.test('instrument with 4 args (name, payload, callback, binding) with payload', function () { + expect(2); + + var expectedPayload = { hi: 1 }; + var binding = {}; + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, expectedPayload); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', expectedPayload, function () { + deepEqual(this, binding); + }, binding); + }); + + QUnit.test('raising an exception in the instrumentation attaches it to the payload', function () { + expect(2); + + var error = new Error('Instrumentation'); + + _emberMetalInstrumentation.subscribe('render', { + before: function () {}, + after: function (name, timestamp, payload) { + strictEqual(payload.exception, error); + } + }); + + _emberMetalInstrumentation.subscribe('render', { + before: function () {}, + after: function (name, timestamp, payload) { + strictEqual(payload.exception, error); + } + }); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () { + throw error; + }); + }); + + QUnit.test('it is possible to add a new subscriber after the first instrument', function () { + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + + _emberMetalInstrumentation.subscribe('render', { + before: function () { + ok(true, 'Before callback was called'); + }, + after: function () { + ok(true, 'After callback was called'); + } + }); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + }); + + QUnit.test('it is possible to remove a subscriber', function () { + expect(4); + + var count = 0; + + var subscriber = _emberMetalInstrumentation.subscribe('render', { + before: function () { + equal(count, 0); + ok(true, 'Before callback was called'); + }, + after: function () { + equal(count, 0); + ok(true, 'After callback was called'); + count++; + } + }); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + + _emberMetalInstrumentation.unsubscribe(subscriber); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + }); +}); +enifed('ember-metal/tests/instrumentation_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/instrumentation_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/instrumentation_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_blank_test', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { + 'use strict'; + + QUnit.module('Ember.isBlank'); + + QUnit.test('Ember.isBlank', function () { + var string = 'string'; + var fn = function () {}; + var object = { length: 0 }; + + equal(true, _emberMetalIs_blank.default(null), 'for null'); + equal(true, _emberMetalIs_blank.default(undefined), 'for undefined'); + equal(true, _emberMetalIs_blank.default(''), 'for an empty String'); + equal(true, _emberMetalIs_blank.default(' '), 'for a whitespace String'); + equal(true, _emberMetalIs_blank.default('\n\t'), 'for another whitespace String'); + equal(false, _emberMetalIs_blank.default('\n\t Hi'), 'for a String with whitespaces'); + equal(false, _emberMetalIs_blank.default(true), 'for true'); + equal(false, _emberMetalIs_blank.default(false), 'for false'); + equal(false, _emberMetalIs_blank.default(string), 'for a String'); + equal(false, _emberMetalIs_blank.default(fn), 'for a Function'); + equal(false, _emberMetalIs_blank.default(0), 'for 0'); + equal(true, _emberMetalIs_blank.default([]), 'for an empty Array'); + equal(false, _emberMetalIs_blank.default({}), 'for an empty Object'); + equal(true, _emberMetalIs_blank.default(object), 'for an Object that has zero \'length\''); + equal(false, _emberMetalIs_blank.default([1, 2, 3]), 'for a non-empty array'); + }); +}); +enifed('ember-metal/tests/is_blank_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_blank_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_blank_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_empty_test', ['exports', 'ember-metal/is_empty', 'ember-metal/map'], function (exports, _emberMetalIs_empty, _emberMetalMap) { + 'use strict'; + + QUnit.module('Ember.isEmpty'); + + QUnit.test('Ember.isEmpty', function () { + var string = 'string'; + var fn = function () {}; + var object = { length: 0 }; + + equal(true, _emberMetalIs_empty.default(null), 'for null'); + equal(true, _emberMetalIs_empty.default(undefined), 'for undefined'); + equal(true, _emberMetalIs_empty.default(''), 'for an empty String'); + equal(false, _emberMetalIs_empty.default(' '), 'for a whitespace String'); + equal(false, _emberMetalIs_empty.default('\n\t'), 'for another whitespace String'); + equal(false, _emberMetalIs_empty.default(true), 'for true'); + equal(false, _emberMetalIs_empty.default(false), 'for false'); + equal(false, _emberMetalIs_empty.default(string), 'for a String'); + equal(false, _emberMetalIs_empty.default(fn), 'for a Function'); + equal(false, _emberMetalIs_empty.default(0), 'for 0'); + equal(true, _emberMetalIs_empty.default([]), 'for an empty Array'); + equal(false, _emberMetalIs_empty.default({}), 'for an empty Object'); + equal(true, _emberMetalIs_empty.default(object), 'for an Object that has zero \'length\''); + }); + + QUnit.test('Ember.isEmpty Ember.Map', function () { + var map = new _emberMetalMap.Map(); + equal(true, _emberMetalIs_empty.default(map), 'Empty map is empty'); + map.set('foo', 'bar'); + equal(false, _emberMetalIs_empty.default(map), 'Map is not empty'); + }); + + QUnit.test('Ember.isEmpty Ember.OrderedSet', function () { + var orderedSet = new _emberMetalMap.OrderedSet(); + equal(true, _emberMetalIs_empty.default(orderedSet), 'Empty ordered set is empty'); + orderedSet.add('foo'); + equal(false, _emberMetalIs_empty.default(orderedSet), 'Ordered set is not empty'); + }); +}); +enifed('ember-metal/tests/is_empty_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_empty_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_empty_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_none_test', ['exports', 'ember-metal/is_none'], function (exports, _emberMetalIs_none) { + 'use strict'; + + QUnit.module('Ember.isNone'); + + QUnit.test('Ember.isNone', function () { + var string = 'string'; + var fn = function () {}; + + equal(true, _emberMetalIs_none.default(null), 'for null'); + equal(true, _emberMetalIs_none.default(undefined), 'for undefined'); + equal(false, _emberMetalIs_none.default(''), 'for an empty String'); + equal(false, _emberMetalIs_none.default(true), 'for true'); + equal(false, _emberMetalIs_none.default(false), 'for false'); + equal(false, _emberMetalIs_none.default(string), 'for a String'); + equal(false, _emberMetalIs_none.default(fn), 'for a Function'); + equal(false, _emberMetalIs_none.default(0), 'for 0'); + equal(false, _emberMetalIs_none.default([]), 'for an empty Array'); + equal(false, _emberMetalIs_none.default({}), 'for an empty Object'); + }); +}); +enifed('ember-metal/tests/is_none_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_none_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_none_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_present_test', ['exports', 'ember-metal/is_present'], function (exports, _emberMetalIs_present) { + 'use strict'; + + QUnit.module('Ember.isPresent'); + + QUnit.test('Ember.isPresent', function () { + var string = 'string'; + var fn = function () {}; + var object = { length: 0 }; + + equal(false, _emberMetalIs_present.default(), 'for no params'); + equal(false, _emberMetalIs_present.default(null), 'for null'); + equal(false, _emberMetalIs_present.default(undefined), 'for undefined'); + equal(false, _emberMetalIs_present.default(''), 'for an empty String'); + equal(false, _emberMetalIs_present.default(' '), 'for a whitespace String'); + equal(false, _emberMetalIs_present.default('\n\t'), 'for another whitespace String'); + equal(true, _emberMetalIs_present.default('\n\t Hi'), 'for a String with whitespaces'); + equal(true, _emberMetalIs_present.default(true), 'for true'); + equal(true, _emberMetalIs_present.default(false), 'for false'); + equal(true, _emberMetalIs_present.default(string), 'for a String'); + equal(true, _emberMetalIs_present.default(fn), 'for a Function'); + equal(true, _emberMetalIs_present.default(0), 'for 0'); + equal(false, _emberMetalIs_present.default([]), 'for an empty Array'); + equal(true, _emberMetalIs_present.default({}), 'for an empty Object'); + equal(false, _emberMetalIs_present.default(object), 'for an Object that has zero \'length\''); + equal(true, _emberMetalIs_present.default([1, 2, 3]), 'for a non-empty array'); + }); +}); +enifed('ember-metal/tests/is_present_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_present_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_present_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/libraries_test', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/libraries'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalLibraries) { + /* globals EmberDev */ + 'use strict'; + + var libs = undefined, + registry = undefined; + var originalWarn = _emberMetalDebug.getDebugFunction('warn'); + + QUnit.module('Libraries registry', { + setup: function () { + libs = new _emberMetalLibraries.Libraries(); + registry = libs._registry; + }, + + teardown: function () { + libs = null; + registry = null; + + _emberMetalDebug.setDebugFunction('warn', originalWarn); + } + }); + + QUnit.test('core libraries come before other libraries', function () { + expect(2); + + libs.register('my-lib', '2.0.0a'); + libs.registerCoreLibrary('DS', '1.0.0-beta.2'); + + equal(registry[0].name, 'DS'); + equal(registry[1].name, 'my-lib'); + }); + + QUnit.test('only the first registration of a library is stored', function () { + expect(3); + + libs.register('magic', 1.23); + libs.register('magic', 2.23); + + equal(registry[0].name, 'magic'); + equal(registry[0].version, 1.23); + equal(registry.length, 1); + }); + + if (_emberMetalFeatures.default('ember-libraries-isregistered')) { + QUnit.test('isRegistered returns correct value', function () { + expect(3); + + equal(libs.isRegistered('magic'), false); + + libs.register('magic', 1.23); + equal(libs.isRegistered('magic'), true); + + libs.deRegister('magic'); + equal(libs.isRegistered('magic'), false); + }); + } + + QUnit.test('attempting to register a library that is already registered warns you', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + expect(1); + + libs.register('magic', 1.23); + + _emberMetalDebug.setDebugFunction('warn', function (msg, test) { + if (!test) { + equal(msg, 'Library "magic" is already registered with Ember.'); + } + }); + + // Should warn us + libs.register('magic', 2.23); + }); + + QUnit.test('libraries can be de-registered', function () { + expect(2); + + libs.register('lib1', '1.0.0b'); + libs.register('lib2', '1.0.0b'); + libs.register('lib3', '1.0.0b'); + + libs.deRegister('lib1'); + libs.deRegister('lib3'); + + equal(registry[0].name, 'lib2'); + equal(registry.length, 1); + }); +}); +enifed('ember-metal/tests/libraries_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/libraries_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/libraries_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/main_test', ['exports', 'ember-metal/index'], function (exports, _emberMetalIndex) { + 'use strict'; + + // testing reexports + + // From sindresourhus/semver-regex https://github.com/sindresorhus/semver-regex/blob/795b05628d96597ebcbe6d31ef4a432858365582/index.js#L3 + var SEMVER_REGEX = /^\bv?(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b$/; + + QUnit.module('ember-metal/core/main'); + + QUnit.test('Ember registers itself', function () { + var lib = _emberMetalIndex.default.libraries._registry[0]; + + equal(lib.name, 'Ember'); + equal(lib.version, _emberMetalIndex.default.VERSION); + }); + + QUnit.test('Ember.VERSION is in alignment with SemVer v2.0.0', function () { + ok(SEMVER_REGEX.test(_emberMetalIndex.default.VERSION), 'Ember.VERSION (' + _emberMetalIndex.default.VERSION + ')is valid SemVer v2.0.0'); + }); + + QUnit.test('SEMVER_REGEX properly validates and invalidates version numbers', function () { + function validateVersionString(versionString, expectedResult) { + equal(SEMVER_REGEX.test(versionString), expectedResult); + } + + // Postive test cases + validateVersionString('1.11.3', true); + validateVersionString('1.0.0-beta.16.1', true); + validateVersionString('1.12.1+canary.aba1412', true); + validateVersionString('2.0.0-beta.1+canary.bb344775', true); + + // Negative test cases + validateVersionString('1.11.3.aba18a', false); + validateVersionString('1.11', false); + }); + + QUnit.test('Ember.keys is deprecated', function () { + expectDeprecation(function () { + _emberMetalIndex.default.keys({}); + }, 'Ember.keys is deprecated in favor of Object.keys'); + }); + + QUnit.test('Ember.create is deprecated', function () { + expectDeprecation(function () { + _emberMetalIndex.default.create(null); + }, 'Ember.create is deprecated in favor of Object.create'); + }); + + QUnit.test('Ember.Backburner is deprecated', function () { + expectDeprecation(function () { + new _emberMetalIndex.default.Backburner(['foo']); + }, 'Usage of Ember.Backburner is deprecated.'); + }); + + QUnit.test('Ember.K is deprecated', function (assert) { + expectDeprecation(function () { + var obj = { + noop: _emberMetalIndex.default.K + }; + + assert.equal(obj, obj.noop()); + }, 'Ember.K is deprecated in favor of defining a function inline.'); + }); +}); +enifed('ember-metal/tests/main_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/main_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/main_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/map_test', ['exports', 'ember-metal/map'], function (exports, _emberMetalMap) { + 'use strict'; + + var object = undefined, + number = undefined, + string = undefined, + map = undefined, + variety = undefined; + var varieties = [['Map', _emberMetalMap.Map], ['MapWithDefault', _emberMetalMap.MapWithDefault]]; + + function testMap(nameAndFunc) { + variety = nameAndFunc[0]; + + QUnit.module('Ember.' + variety + ' (forEach and get are implicitly tested)', { + setup: function () { + object = {}; + number = 42; + string = 'foo'; + + map = nameAndFunc[1].create(); + } + }); + + var mapHasLength = function (expected, theMap) { + theMap = theMap || map; + + var length = 0; + theMap.forEach(function () { + length++; + }); + + equal(length, expected, 'map should contain ' + expected + ' items'); + }; + + var mapHasEntries = function (entries, theMap) { + theMap = theMap || map; + + for (var i = 0; i < entries.length; i++) { + equal(theMap.get(entries[i][0]), entries[i][1]); + equal(theMap.has(entries[i][0]), true); + } + + mapHasLength(entries.length, theMap); + }; + + var unboundThis = undefined; + + (function () { + unboundThis = this; + })(); + + QUnit.test('set', function () { + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + map.set(object, 'losing'); + map.set(number, 'losing'); + map.set(string, 'losing'); + + mapHasEntries([[object, 'losing'], [number, 'losing'], [string, 'losing']]); + + equal(map.has('nope'), false, 'expected the key `nope` to not be present'); + equal(map.has({}), false, 'expected they key `{}` to not be present'); + }); + + QUnit.test('set chaining', function () { + map.set(object, 'winning').set(number, 'winning').set(string, 'winning'); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + map.set(object, 'losing').set(number, 'losing').set(string, 'losing'); + + mapHasEntries([[object, 'losing'], [number, 'losing'], [string, 'losing']]); + + equal(map.has('nope'), false, 'expected the key `nope` to not be present'); + equal(map.has({}), false, 'expected they key `{}` to not be present'); + }); + + QUnit.test('with key with undefined value', function () { + map.set('foo', undefined); + + map.forEach(function (value, key) { + equal(value, undefined); + equal(key, 'foo'); + }); + + ok(map.has('foo'), 'has key foo, even with undefined value'); + + equal(map.size, 1); + }); + + QUnit.test('arity of forEach is 1 – es6 23.1.3.5', function () { + equal(map.forEach.length, 1, 'expected arity for map.forEach is 1'); + }); + + QUnit.test('forEach throws without a callback as the first argument', function () { + equal(map.forEach.length, 1, 'expected arity for map.forEach is 1'); + }); + + QUnit.test('has empty collection', function () { + equal(map.has('foo'), false); + equal(map.has(), false); + }); + + QUnit.test('delete', function () { + expectNoDeprecation(); + + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + map.delete(object); + map.delete(number); + map.delete(string); + + // doesn't explode + map.delete({}); + + mapHasEntries([]); + }); + + QUnit.test('copy and then update', function () { + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + var map2 = map.copy(); + + map2.set(object, 'losing'); + map2.set(number, 'losing'); + map2.set(string, 'losing'); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + mapHasEntries([[object, 'losing'], [number, 'losing'], [string, 'losing']], map2); + }); + + QUnit.test('copy and then delete', function () { + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + var map2 = map.copy(); + + map2.delete(object); + map2.delete(number); + map2.delete(string); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + mapHasEntries([], map2); + }); + + QUnit.test('size', function () { + //Add a key twice + equal(map.size, 0); + map.set(string, 'a string'); + equal(map.size, 1); + map.set(string, 'the same string'); + equal(map.size, 1); + + //Add another + map.set(number, 'a number'); + equal(map.size, 2); + + //Remove one that doesn't exist + map.delete('does not exist'); + equal(map.size, 2); + + //Check copy + var copy = map.copy(); + equal(copy.size, 2); + + //Remove a key twice + map.delete(number); + equal(map.size, 1); + map.delete(number); + equal(map.size, 1); + + //Remove the last key + map.delete(string); + equal(map.size, 0); + map.delete(string); + equal(map.size, 0); + }); + + QUnit.test('forEach without proper callback', function () { + QUnit.throws(function () { + map.forEach(); + }, '[object Undefined] is not a function'); + + QUnit.throws(function () { + map.forEach(undefined); + }, '[object Undefined] is not a function'); + + QUnit.throws(function () { + map.forEach(1); + }, '[object Number] is not a function'); + + QUnit.throws(function () { + map.forEach({}); + }, '[object Object] is not a function'); + + map.forEach(function (value, key) { + map.delete(key); + }); + // ensure the error happens even if no data is present + equal(map.size, 0); + QUnit.throws(function () { + map.forEach({}); + }, '[object Object] is not a function'); + }); + + QUnit.test('forEach basic', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + + var expectations = [{ value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, { value: 3, key: 'c', context: unboundThis }]; + + map.forEach(function (value, key, theMap) { + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }); + + equal(iteration, 3, 'expected 3 iterations'); + }); + + QUnit.test('forEach basic /w context', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + var context = {}; + var expectations = [{ value: 1, key: 'a', context: context }, { value: 2, key: 'b', context: context }, { value: 3, key: 'c', context: context }]; + + map.forEach(function (value, key, theMap) { + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }, context); + + equal(iteration, 3, 'expected 3 iterations'); + }); + + QUnit.test('forEach basic /w deletion while enumerating', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + + var expectations = [{ value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }]; + + map.forEach(function (value, key, theMap) { + if (iteration === 0) { + map.delete('c'); + } + + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }); + + equal(iteration, 2, 'expected 3 iterations'); + }); + + QUnit.test('forEach basic /w addition while enumerating', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + + var expectations = [{ value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, { value: 3, key: 'c', context: unboundThis }, { value: 4, key: 'd', context: unboundThis }]; + + map.forEach(function (value, key, theMap) { + if (iteration === 0) { + map.set('d', 4); + } + + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }); + + equal(iteration, 4, 'expected 3 iterations'); + }); + + QUnit.test('clear', function () { + var iterations = 0; + + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + map.set('d', 4); + + equal(map.size, 4); + + map.forEach(function () { + iterations++; + }); + equal(iterations, 4); + + map.clear(); + equal(map.size, 0); + iterations = 0; + map.forEach(function () { + iterations++; + }); + equal(iterations, 0); + }); + + QUnit.test('-0', function () { + equal(map.has(-0), false); + equal(map.has(0), false); + + map.set(-0, 'zero'); + + equal(map.has(-0), true); + equal(map.has(0), true); + + equal(map.get(0), 'zero'); + equal(map.get(-0), 'zero'); + + map.forEach(function (value, key) { + equal(1 / key, Infinity, 'spec says key should be positive zero'); + }); + }); + + QUnit.test('NaN', function () { + equal(map.has(NaN), false); + + map.set(NaN, 'not-a-number'); + + equal(map.has(NaN), true); + + equal(map.get(NaN), 'not-a-number'); + }); + + QUnit.test('NaN Boxed', function () { + //jshint -W053 + var boxed = new Number(NaN); + equal(map.has(boxed), false); + + map.set(boxed, 'not-a-number'); + + equal(map.has(boxed), true); + equal(map.has(NaN), false); + + equal(map.get(NaN), undefined); + equal(map.get(boxed), 'not-a-number'); + }); + + QUnit.test('0 value', function () { + var obj = {}; + equal(map.has(obj), false); + + equal(map.size, 0); + map.set(obj, 0); + equal(map.size, 1); + + equal(map.has(obj), true); + equal(map.get(obj), 0); + + map.delete(obj); + equal(map.has(obj), false); + equal(map.get(obj), undefined); + equal(map.size, 0); + }); + } + + for (var i = 0; i < varieties.length; i++) { + testMap(varieties[i]); + } + + QUnit.module('MapWithDefault - default values'); + + QUnit.test('Retrieving a value that has not been set returns and sets a default value', function () { + var map = _emberMetalMap.MapWithDefault.create({ + defaultValue: function (key) { + return [key]; + } + }); + + var value = map.get('ohai'); + deepEqual(value, ['ohai']); + + strictEqual(value, map.get('ohai')); + }); + + QUnit.test('Map.prototype.constructor', function () { + var map = new _emberMetalMap.Map(); + equal(map.constructor, _emberMetalMap.Map); + }); + + QUnit.test('Map() without `new`', function () { + QUnit.throws(function () { + // jshint newcap:false + _emberMetalMap.Map(); + }, /Constructor Map requires 'new'/); + }); + + QUnit.test('MapWithDefault.prototype.constructor', function () { + var map = new _emberMetalMap.MapWithDefault({ + defaultValue: function (key) { + return key; + } + }); + equal(map.constructor, _emberMetalMap.MapWithDefault); + }); + + QUnit.test('Copying a MapWithDefault copies the default value', function () { + var map = _emberMetalMap.MapWithDefault.create({ + defaultValue: function (key) { + return [key]; + } + }); + + map.set('ohai', 1); + map.get('bai'); + + var map2 = map.copy(); + + equal(map2.get('ohai'), 1); + deepEqual(map2.get('bai'), ['bai']); + + map2.set('kthx', 3); + + deepEqual(map.get('kthx'), ['kthx']); + equal(map2.get('kthx'), 3); + + deepEqual(map2.get('default'), ['default']); + + map2.defaultValue = function (key) { + return ['tom is on', key]; + }; + + deepEqual(map2.get('drugs'), ['tom is on', 'drugs']); + }); + + QUnit.module('OrderedSet', { + setup: function () { + object = {}; + number = 42; + string = 'foo'; + + map = _emberMetalMap.OrderedSet.create(); + } + }); + + QUnit.test('OrderedSet() without `new`', function () { + QUnit.throws(function () { + // jshint newcap:false + _emberMetalMap.OrderedSet(); + }, /Constructor OrderedSet requires 'new'/); + }); + + QUnit.test('add returns the set', function () { + var obj = {}; + equal(map.add(obj), map); + equal(map.add(obj), map, 'when it is already in the set'); + }); +}); +enifed('ember-metal/tests/map_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/map_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/map_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/meta_test', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { + 'use strict'; + + QUnit.module('Ember.meta'); + + QUnit.test('should return the same hash for an object', function () { + var obj = {}; + + _emberMetalMeta.meta(obj).foo = 'bar'; + + equal(_emberMetalMeta.meta(obj).foo, 'bar', 'returns same hash with multiple calls to Ember.meta()'); + }); + + QUnit.test('meta is not enumerable', function () { + var proto = undefined, + obj = undefined, + props = undefined, + prop = undefined; + proto = { foo: 'bar' }; + _emberMetalMeta.meta(proto); + obj = Object.create(proto); + _emberMetalMeta.meta(obj); + obj.bar = 'baz'; + props = []; + for (prop in obj) { + props.push(prop); + } + deepEqual(props.sort(), ['bar', 'foo']); + if (typeof JSON !== 'undefined' && 'stringify' in JSON) { + try { + JSON.stringify(obj); + } catch (e) { + ok(false, 'meta should not fail JSON.stringify'); + } + } + }); + + QUnit.test('meta.listeners basics', function (assert) { + var t = {}; + var m = _emberMetalMeta.meta({}); + m.addToListeners('hello', t, 'm', 0); + var matching = m.matchingListeners('hello'); + assert.equal(matching.length, 3); + assert.equal(matching[0], t); + m.removeFromListeners('hello', t, 'm'); + matching = m.matchingListeners('hello'); + assert.equal(matching.length, 0); + }); + + QUnit.test('meta.listeners inheritance', function (assert) { + var target = {}; + var parent = {}; + var parentMeta = _emberMetalMeta.meta(parent); + parentMeta.addToListeners('hello', target, 'm', 0); + + var child = Object.create(parent); + var m = _emberMetalMeta.meta(child); + + var matching = m.matchingListeners('hello'); + assert.equal(matching.length, 3); + assert.equal(matching[0], target); + assert.equal(matching[1], 'm'); + assert.equal(matching[2], 0); + m.removeFromListeners('hello', target, 'm'); + matching = m.matchingListeners('hello'); + assert.equal(matching.length, 0); + matching = parentMeta.matchingListeners('hello'); + assert.equal(matching.length, 3); + }); + + QUnit.test('meta.listeners deduplication', function (assert) { + var t = {}; + var m = _emberMetalMeta.meta({}); + m.addToListeners('hello', t, 'm', 0); + m.addToListeners('hello', t, 'm', 0); + var matching = m.matchingListeners('hello'); + assert.equal(matching.length, 3); + assert.equal(matching[0], t); + }); +}); +enifed('ember-metal/tests/meta_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/meta_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/meta_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/alias_method_test', ['exports', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('aliasMethod'); + + function validateAliasMethod(obj) { + equal(obj.fooMethod(), 'FOO', 'obj.fooMethod()'); + equal(obj.barMethod(), 'FOO', 'obj.barMethod should be a copy of foo'); + } + + QUnit.test('methods of another name are aliased when the mixin is applied', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + fooMethod: function () { + return 'FOO'; + }, + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = MyMixin.apply({}); + validateAliasMethod(obj); + }); + + QUnit.test('should follow aliasMethods all the way down', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + bar: _emberMetalMixin.aliasMethod('foo'), // put first to break ordered iteration + baz: function () { + return 'baz'; + }, + foo: _emberMetalMixin.aliasMethod('baz') + }); + + var obj = MyMixin.apply({}); + equal(_emberMetalProperty_get.get(obj, 'bar')(), 'baz', 'should have followed aliasMethods'); + }); + + QUnit.test('should alias methods from other dependent mixins', function () { + var BaseMixin = _emberMetalMixin.Mixin.create({ + fooMethod: function () { + return 'FOO'; + } + }); + + var MyMixin = _emberMetalMixin.Mixin.create(BaseMixin, { + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = MyMixin.apply({}); + validateAliasMethod(obj); + }); + + QUnit.test('should alias methods from other mixins applied at same time', function () { + var BaseMixin = _emberMetalMixin.Mixin.create({ + fooMethod: function () { + return 'FOO'; + } + }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = _emberMetalMixin.mixin({}, BaseMixin, MyMixin); + validateAliasMethod(obj); + }); + + QUnit.test('should alias methods from mixins already applied on object', function () { + var BaseMixin = _emberMetalMixin.Mixin.create({ + quxMethod: function () { + return 'qux'; + } + }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + bar: _emberMetalMixin.aliasMethod('foo'), + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = { + fooMethod: function () { + return 'FOO'; + } + }; + + BaseMixin.apply(obj); + MyMixin.apply(obj); + + validateAliasMethod(obj); + }); +}); +enifed('ember-metal/tests/mixin/alias_method_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/alias_method_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/alias_method_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/apply_test', ['exports', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Ember.Mixin.apply'); + + function K() {} + + QUnit.test('using apply() should apply properties', function () { + var MixinA = _emberMetalMixin.Mixin.create({ foo: 'FOO', baz: K }); + var obj = {}; + _emberMetalMixin.mixin(obj, MixinA); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'FOO', 'should apply foo'); + equal(_emberMetalProperty_get.default(obj, 'baz'), K, 'should apply foo'); + }); + + QUnit.test('applying anonymous properties', function () { + var obj = {}; + _emberMetalMixin.mixin(obj, { + foo: 'FOO', + baz: K + }); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'FOO', 'should apply foo'); + equal(_emberMetalProperty_get.default(obj, 'baz'), K, 'should apply foo'); + }); + + QUnit.test('applying null values', function () { + expectAssertion(function () { + return _emberMetalMixin.mixin({}, null); + }); + }); + + QUnit.test('applying a property with an undefined value', function () { + var obj = { tagName: '' }; + _emberMetalMixin.mixin(obj, { tagName: undefined }); + + strictEqual(_emberMetalProperty_get.default(obj, 'tagName'), ''); + }); +}); +enifed('ember-metal/tests/mixin/apply_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/apply_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/apply_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/computed_test', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/mixin', 'ember-metal/computed', 'ember-metal/properties'], function (exports, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMixin, _emberMetalComputed, _emberMetalProperties) { + 'use strict'; + + function K() { + return this; + } + + QUnit.module('Mixin Computed Properties'); + + QUnit.test('overriding computed properties', function () { + var MixinA = undefined, + MixinB = undefined, + MixinC = undefined, + MixinD = undefined; + var obj = undefined; + + MixinA = _emberMetalMixin.Mixin.create({ + aProp: _emberMetalComputed.computed(function () { + return 'A'; + }) + }); + + MixinB = _emberMetalMixin.Mixin.create(MixinA, { + aProp: _emberMetalComputed.computed(function () { + return this._super.apply(this, arguments) + 'B'; + }) + }); + + MixinC = _emberMetalMixin.Mixin.create(MixinA, { + aProp: _emberMetalComputed.computed(function () { + return this._super.apply(this, arguments) + 'C'; + }) + }); + + MixinD = _emberMetalMixin.Mixin.create({ + aProp: _emberMetalComputed.computed(function () { + return this._super.apply(this, arguments) + 'D'; + }) + }); + + obj = {}; + MixinB.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'AB', 'should expose super for B'); + + obj = {}; + MixinC.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'AC', 'should expose super for C'); + + obj = {}; + + MixinA.apply(obj); + MixinD.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'AD', 'should define super for D'); + + obj = {}; + _emberMetalProperties.defineProperty(obj, 'aProp', _emberMetalComputed.computed(function (key) { + return 'obj'; + })); + MixinD.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'objD', 'should preserve original computed property'); + }); + + QUnit.test('calling set on overridden computed properties', function () { + var SuperMixin = undefined, + SubMixin = undefined; + var obj = undefined; + + var superGetOccurred = false; + var superSetOccurred = false; + + SuperMixin = _emberMetalMixin.Mixin.create({ + aProp: _emberMetalComputed.computed({ + get: function (key) { + superGetOccurred = true; + }, + set: function (key, value) { + superSetOccurred = true; + } + }) + }); + + SubMixin = _emberMetalMixin.Mixin.create(SuperMixin, { + aProp: _emberMetalComputed.computed({ + get: function (key) { + return this._super.apply(this, arguments); + }, + set: function (key, value) { + return this._super.apply(this, arguments); + } + }) + }); + + obj = {}; + SubMixin.apply(obj); + + _emberMetalProperty_set.set(obj, 'aProp', 'set thyself'); + ok(superSetOccurred, 'should pass set to _super'); + + superSetOccurred = false; // reset the set assertion + + obj = {}; + SubMixin.apply(obj); + + _emberMetalProperty_get.get(obj, 'aProp'); + ok(superGetOccurred, 'should pass get to _super'); + + _emberMetalProperty_set.set(obj, 'aProp', 'set thyself'); + ok(superSetOccurred, 'should pass set to _super after getting'); + }); + + QUnit.test('setter behavior works properly when overriding computed properties', function () { + var obj = {}; + + var MixinA = _emberMetalMixin.Mixin.create({ + cpWithSetter2: _emberMetalComputed.computed(K), + cpWithSetter3: _emberMetalComputed.computed(K), + cpWithoutSetter: _emberMetalComputed.computed(K) + }); + + var cpWasCalled = false; + + var MixinB = _emberMetalMixin.Mixin.create({ + cpWithSetter2: _emberMetalComputed.computed({ + get: K, + set: function (k, v) { + cpWasCalled = true; + } + }), + + cpWithSetter3: _emberMetalComputed.computed({ + get: K, + set: function (k, v) { + cpWasCalled = true; + } + }), + + cpWithoutSetter: _emberMetalComputed.computed(function (k) { + cpWasCalled = true; + }) + }); + + MixinA.apply(obj); + MixinB.apply(obj); + + _emberMetalProperty_set.set(obj, 'cpWithSetter2', 'test'); + ok(cpWasCalled, 'The computed property setter was called when defined with two args'); + cpWasCalled = false; + + _emberMetalProperty_set.set(obj, 'cpWithSetter3', 'test'); + ok(cpWasCalled, 'The computed property setter was called when defined with three args'); + cpWasCalled = false; + + _emberMetalProperty_set.set(obj, 'cpWithoutSetter', 'test'); + equal(_emberMetalProperty_get.get(obj, 'cpWithoutSetter'), 'test', 'The default setter was called, the value is correct'); + ok(!cpWasCalled, 'The default setter was called, not the CP itself'); + }); +}); +enifed('ember-metal/tests/mixin/computed_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/computed_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/computed_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/concatenated_properties_test', ['exports', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin concatenatedProperties'); + + QUnit.test('defining concatenated properties should concat future version', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: ['a', 'b', 'c'] + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: ['d', 'e', 'f'] + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f']); + }); + + QUnit.test('defining concatenated properties should concat future version', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: null + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: null + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + + deepEqual(obj.concatenatedProperties, []); + }); + + QUnit.test('concatenatedProperties should be concatenated', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: ['a', 'b', 'c'] + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: 'bar', + foo: ['d', 'e', 'f'], + bar: [1, 2, 3] + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + bar: [4, 5, 6] + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB, MixinC); + deepEqual(_emberMetalProperty_get.default(obj, 'concatenatedProperties'), ['foo', 'bar'], 'get concatenatedProperties'); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f'], 'get foo'); + deepEqual(_emberMetalProperty_get.default(obj, 'bar'), [1, 2, 3, 4, 5, 6], 'get bar'); + }); + + QUnit.test('adding a prop that is not an array should make array', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: [1, 2, 3] + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: 4 + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), [1, 2, 3, 4]); + }); + + QUnit.test('adding a prop that is not an array should make array', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: 'bar' + }); + + var obj = _emberMetalMixin.mixin({}, MixinA); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), ['bar']); + }); + + QUnit.test('adding a non-concatenable property that already has a defined value should result in an array with both values', function () { + var mixinA = _emberMetalMixin.Mixin.create({ + foo: 1 + }); + + var mixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: 2 + }); + + var obj = _emberMetalMixin.mixin({}, mixinA, mixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), [1, 2]); + }); + + QUnit.test('adding a concatenable property that already has a defined value should result in a concatenated value', function () { + var mixinA = _emberMetalMixin.Mixin.create({ + foobar: 'foo' + }); + + var mixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foobar'], + foobar: 'bar' + }); + + var obj = _emberMetalMixin.mixin({}, mixinA, mixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foobar'), ['foo', 'bar']); + }); +}); +enifed('ember-metal/tests/mixin/concatenated_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/concatenated_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/concatenated_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/detect_test', ['exports', 'ember-metal/mixin'], function (exports, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin.detect'); + + QUnit.test('detect() finds a directly applied mixin', function () { + var MixinA = _emberMetalMixin.Mixin.create(); + var obj = {}; + + equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); + + MixinA.apply(obj); + equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); + }); + + QUnit.test('detect() finds nested mixins', function () { + var MixinA = _emberMetalMixin.Mixin.create({}); + var MixinB = _emberMetalMixin.Mixin.create(MixinA); + var obj = {}; + + equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); + + MixinB.apply(obj); + equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); + }); + + QUnit.test('detect() finds mixins on other mixins', function () { + var MixinA = _emberMetalMixin.Mixin.create({}); + var MixinB = _emberMetalMixin.Mixin.create(MixinA); + equal(MixinA.detect(MixinB), true, 'MixinA is part of MixinB'); + equal(MixinB.detect(MixinA), false, 'MixinB is not part of MixinA'); + }); + + QUnit.test('detect handles null values', function () { + var MixinA = _emberMetalMixin.Mixin.create(); + equal(MixinA.detect(null), false); + }); +}); +enifed('ember-metal/tests/mixin/detect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/detect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/detect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/introspection_test', ['exports', 'ember-utils', 'ember-metal/mixin'], function (exports, _emberUtils, _emberMetalMixin) { + // NOTE: A previous iteration differentiated between public and private props + // as well as methods vs props. We are just keeping these for testing; the + // current impl doesn't care about the differences as much... + + 'use strict'; + + var PrivateProperty = _emberMetalMixin.Mixin.create({ + _foo: '_FOO' + }); + var PublicProperty = _emberMetalMixin.Mixin.create({ + foo: 'FOO' + }); + var PrivateMethod = _emberMetalMixin.Mixin.create({ + _fooMethod: function () {} + }); + var PublicMethod = _emberMetalMixin.Mixin.create({ + fooMethod: function () {} + }); + var BarProperties = _emberMetalMixin.Mixin.create({ + _bar: '_BAR', + bar: 'bar' + }); + var BarMethods = _emberMetalMixin.Mixin.create({ + _barMethod: function () {}, + barMethod: function () {} + }); + + var Combined = _emberMetalMixin.Mixin.create(BarProperties, BarMethods); + + var obj = undefined; + + QUnit.module('Basic introspection', { + setup: function () { + obj = {}; + _emberMetalMixin.mixin(obj, PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined); + } + }); + + QUnit.test('Ember.mixins()', function () { + function mapGuids(ary) { + return ary.map(function (x) { + return _emberUtils.guidFor(x); + }); + } + + deepEqual(mapGuids(_emberMetalMixin.Mixin.mixins(obj)), mapGuids([PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined, BarProperties, BarMethods]), 'should return included mixins'); + }); +}); +enifed('ember-metal/tests/mixin/introspection_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/introspection_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/introspection_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/merged_properties_test', ['exports', 'ember-runtime', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberRuntime, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin mergedProperties'); + + QUnit.test('defining mergedProperties should merge future version', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: { d: true, e: true, f: true } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }); + }); + + QUnit.test('defining mergedProperties on future mixin should merged into past', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { d: true, e: true, f: true } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }); + }); + + QUnit.test('defining mergedProperties with null properties should keep properties null', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: null + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: null + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + equal(_emberMetalProperty_get.get(obj, 'foo'), null); + }); + + QUnit.test('mergedProperties\' properties can get overwritten', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: 1 } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: { a: 2 } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: 2 }); + }); + + QUnit.test('mergedProperties should be concatenated', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + mergedProperties: 'bar', + foo: { d: true, e: true, f: true }, + bar: { a: true, l: true } + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + bar: { e: true, x: true } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB, MixinC); + deepEqual(_emberMetalProperty_get.get(obj, 'mergedProperties'), ['foo', 'bar'], 'get mergedProperties'); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }, 'get foo'); + deepEqual(_emberMetalProperty_get.get(obj, 'bar'), { a: true, l: true, e: true, x: true }, 'get bar'); + }); + + QUnit.test('mergedProperties should exist even if not explicitly set on create', function () { + var AnObj = _emberRuntime.Object.extend({ + mergedProperties: ['options'], + options: { + a: 'a', + b: { + c: 'ccc' + } + } + }); + + var obj = AnObj.create({ + options: { + a: 'A' + } + }); + + equal(_emberMetalProperty_get.get(obj, 'options').a, 'A'); + equal(_emberMetalProperty_get.get(obj, 'options').b.c, 'ccc'); + }); + + QUnit.test('defining mergedProperties at create time should not modify the prototype', function () { + var AnObj = _emberRuntime.Object.extend({ + mergedProperties: ['options'], + options: { + a: 1 + } + }); + + var objA = AnObj.create({ + options: { + a: 2 + } + }); + var objB = AnObj.create({ + options: { + a: 3 + } + }); + + equal(_emberMetalProperty_get.get(objA, 'options').a, 2); + equal(_emberMetalProperty_get.get(objB, 'options').a, 3); + }); + + QUnit.test('mergedProperties\' overwriting methods can call _super', function () { + expect(4); + + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { + meth: function (a) { + equal(a, 'WOOT', '_super successfully called MixinA\'s `foo.meth` method'); + return 'WAT'; + } + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: { + meth: function (a) { + ok(true, 'MixinB\'s `foo.meth` method called'); + return this._super.apply(this, arguments); + } + } + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + foo: { + meth: function (a) { + ok(true, 'MixinC\'s `foo.meth` method called'); + return this._super(a); + } + } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB, MixinC); + equal(obj.foo.meth('WOOT'), 'WAT'); + }); + + QUnit.test('Merging an Array should raise an error', function () { + expect(1); + + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: ['a'] + }); + + expectAssertion(function () { + _emberMetalMixin.mixin({}, MixinA, MixinB); + }, 'You passed in `["a"]` as the value for `foo` but `foo` cannot be an Array'); + }); +}); +enifed('ember-metal/tests/mixin/merged_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/merged_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/merged_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/method_test', ['exports', 'ember-metal/mixin'], function (exports, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin Methods'); + + QUnit.test('defining simple methods', function () { + var MixinA = undefined, + obj = undefined, + props = undefined; + + props = { + publicMethod: function () { + return 'publicMethod'; + }, + _privateMethod: function () { + return 'privateMethod'; + } + }; + + MixinA = _emberMetalMixin.Mixin.create(props); + obj = {}; + MixinA.apply(obj); + + // but should be defined + equal(props.publicMethod(), 'publicMethod', 'publicMethod is func'); + equal(props._privateMethod(), 'privateMethod', 'privateMethod is func'); + }); + + QUnit.test('overriding public methods', function () { + var MixinA = undefined, + MixinB = undefined, + MixinD = undefined, + MixinF = undefined, + obj = undefined; + + MixinA = _emberMetalMixin.Mixin.create({ + publicMethod: function () { + return 'A'; + } + }); + + MixinB = _emberMetalMixin.Mixin.create(MixinA, { + publicMethod: function () { + return this._super.apply(this, arguments) + 'B'; + } + }); + + MixinD = _emberMetalMixin.Mixin.create(MixinA, { + publicMethod: function () { + return this._super.apply(this, arguments) + 'D'; + } + }); + + MixinF = _emberMetalMixin.Mixin.create({ + publicMethod: function () { + return this._super.apply(this, arguments) + 'F'; + } + }); + + obj = {}; + MixinB.apply(obj); + equal(obj.publicMethod(), 'AB', 'should define super for A and B'); + + obj = {}; + MixinD.apply(obj); + equal(obj.publicMethod(), 'AD', 'should define super for A and B'); + + obj = {}; + MixinA.apply(obj); + MixinF.apply(obj); + equal(obj.publicMethod(), 'AF', 'should define super for A and F'); + + obj = { publicMethod: function () { + return 'obj'; + } }; + MixinF.apply(obj); + equal(obj.publicMethod(), 'objF', 'should define super for F'); + }); + + QUnit.test('overriding inherited objects', function () { + var cnt = 0; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + cnt++; + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + cnt++; + } + }); + + var objA = {}; + MixinA.apply(objA); + + var objB = Object.create(objA); + MixinB.apply(objB); + + cnt = 0; + objB.foo(); + equal(cnt, 2, 'should invoke both methods'); + + cnt = 0; + objA.foo(); + equal(cnt, 1, 'should not screw w/ parent obj'); + }); + + QUnit.test('Including the same mixin more than once will only run once', function () { + var cnt = 0; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + cnt++; + } + }); + + var MixinB = _emberMetalMixin.Mixin.create(MixinA, { + foo: function () { + this._super.apply(this, arguments); + } + }); + + var MixinC = _emberMetalMixin.Mixin.create(MixinA, { + foo: function () { + this._super.apply(this, arguments); + } + }); + + var MixinD = _emberMetalMixin.Mixin.create(MixinB, MixinC, MixinA, { + foo: function () { + this._super.apply(this, arguments); + } + }); + + var obj = {}; + MixinD.apply(obj); + MixinA.apply(obj); // try to apply again.. + + cnt = 0; + obj.foo(); + + equal(cnt, 1, 'should invoke MixinA.foo one time'); + }); + + QUnit.test('_super from a single mixin with no superclass does not error', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + } + }); + + var obj = {}; + MixinA.apply(obj); + + obj.foo(); + ok(true); + }); + + QUnit.test('_super from a first-of-two mixins with no superclass function does not error', function () { + // _super was previously calling itself in the second assertion. + // Use remaining count of calls to ensure it doesn't loop indefinitely. + var remaining = 3; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + if (remaining-- > 0) { + this._super.apply(this, arguments); + } + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + } + }); + + var obj = {}; + MixinA.apply(obj); + MixinB.apply(obj); + + obj.foo(); + ok(true); + }); + + // .......................................................... + // CONFLICTS + // + + QUnit.module('Method Conflicts'); + + QUnit.test('overriding toString', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + toString: function () { + return 'FOO'; + } + }); + + var obj = {}; + MixinA.apply(obj); + equal(obj.toString(), 'FOO', 'should override toString w/o error'); + + obj = {}; + _emberMetalMixin.mixin(obj, { toString: function () { + return 'FOO'; + } }); + equal(obj.toString(), 'FOO', 'should override toString w/o error'); + }); + + // .......................................................... + // BUGS + // + + QUnit.module('system/mixin/method_test BUGS'); + + QUnit.test('applying several mixins at once with sup already defined causes infinite loop', function () { + var cnt = 0; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + cnt++; + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + cnt++; + } + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + cnt++; + } + }); + + var obj = {}; + _emberMetalMixin.mixin(obj, MixinA); // sup already exists + _emberMetalMixin.mixin(obj, MixinB, MixinC); // must be more than one mixin + + cnt = 0; + obj.foo(); + equal(cnt, 3, 'should invoke all 3 methods'); + }); +}); +enifed('ember-metal/tests/mixin/method_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/method_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/method_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/observer_test', ['exports', 'internal-test-helpers', 'ember-metal/mixin', 'ember-metal/watching'], function (exports, _internalTestHelpers, _emberMetalMixin, _emberMetalWatching) { + 'use strict'; + + QUnit.module('Mixin observer'); + + _internalTestHelpers.testBoth('global observer helper', function (get, set) { + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + + foo: _emberMetalMixin.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('global observer helper takes multiple params', function (get, set) { + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + + foo: _emberMetalMixin.observer('bar', 'baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 2, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('replacing observer should remove old observer', function (get, set) { + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + + foo: _emberMetalMixin.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + + }); + + var Mixin2 = _emberMetalMixin.Mixin.create({ + foo: _emberMetalMixin.observer('baz', function () { + set(this, 'count', get(this, 'count') + 10); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin, Mixin2); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 10, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property before', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + bar: obj2, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property after', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }), + bar: obj2 + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property in mixin applied later', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj2 }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + MyMixin2.apply(obj); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with existing property', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({ bar: obj2 }, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property in mixin before', function (get, set) { + var obj2 = { baz: 'baz' }; + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj2 }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin2, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property in mixin after', function (get, set) { + var obj2 = { baz: 'baz' }; + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj2 }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin, MyMixin2); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with overriden property', function (get, set) { + var obj2 = { baz: 'baz' }; + var obj3 = { baz: 'foo' }; + + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj3 }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({ bar: obj2 }, MyMixin, MyMixin2); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + equal(_emberMetalWatching.isWatching(obj2, 'baz'), false, 'should not be watching baz'); + equal(_emberMetalWatching.isWatching(obj3, 'baz'), true, 'should be watching baz'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj3, 'baz', 'BEAR'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('providing the arguments in reverse order is deprecated', function (get, set) { + expectDeprecation(/Passing the dependentKeys after the callback function in Ember\.observer is deprecated. Ensure the callback function is the last argument/); + + _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer(function () { + set(this, 'count', get(this, 'count') + 1); + }, 'bar.baz') + }); + }); +}); +enifed('ember-metal/tests/mixin/observer_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/observer_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/observer_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/reopen_test', ['exports', 'ember-metal/run_loop', 'ember-metal/property_get', 'ember-runtime', 'ember-metal/mixin'], function (exports, _emberMetalRun_loop, _emberMetalProperty_get, _emberRuntime, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Ember.Mixin#reopen'); + + QUnit.test('using reopen() to add more properties to a simple', function () { + var MixinA = _emberMetalMixin.default.create({ foo: 'FOO', baz: 'BAZ' }); + MixinA.reopen({ bar: 'BAR', foo: 'FOO2' }); + var obj = {}; + MixinA.apply(obj); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'FOO2', 'mixin() should override'); + equal(_emberMetalProperty_get.default(obj, 'baz'), 'BAZ', 'preserve MixinA props'); + equal(_emberMetalProperty_get.default(obj, 'bar'), 'BAR', 'include MixinB props'); + }); + + QUnit.test('using reopen() and calling _super where there is not a super function does not cause infinite recursion', function () { + var Taco = _emberRuntime.Object.extend({ + createBreakfast: function () { + // There is no original createBreakfast function. + // Calling the wrapped _super function here + // used to end in an infinite call loop + this._super.apply(this, arguments); + return 'Breakfast!'; + } + }); + + Taco.reopen({ + createBreakfast: function () { + return this._super.apply(this, arguments); + } + }); + + var taco = Taco.create(); + + var result = undefined; + _emberMetalRun_loop.default(function () { + try { + result = taco.createBreakfast(); + } catch (e) { + result = 'Your breakfast was interrupted by an infinite stack error.'; + } + }); + + equal(result, 'Breakfast!'); + }); +}); +enifed('ember-metal/tests/mixin/reopen_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/reopen_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/reopen_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/required_test', ['exports', 'ember-metal/mixin', 'ember-metal/property_get'], function (exports, _emberMetalMixin, _emberMetalProperty_get) { + 'use strict'; + + var PartialMixin = undefined, + FinalMixin = undefined, + obj = undefined; + + QUnit.module('Module.required', { + setup: function () { + expectDeprecation(function () { + PartialMixin = _emberMetalMixin.Mixin.create({ + foo: _emberMetalMixin.required(), + bar: 'BAR' + }); + }, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.'); + + FinalMixin = _emberMetalMixin.Mixin.create({ + foo: 'FOO' + }); + + obj = {}; + }, + + teardown: function () { + PartialMixin = FinalMixin = obj = null; + } + }); + + QUnit.test('applying a mixin to meet requirement', function () { + FinalMixin.apply(obj); + PartialMixin.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('combined mixins to meet requirement', function () { + _emberMetalMixin.Mixin.create(PartialMixin, FinalMixin).apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('merged mixin', function () { + _emberMetalMixin.Mixin.create(PartialMixin, { foo: 'FOO' }).apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('define property on source object', function () { + obj.foo = 'FOO'; + PartialMixin.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('using apply', function () { + _emberMetalMixin.mixin(obj, PartialMixin, { foo: 'FOO' }); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); +}); +enifed('ember-metal/tests/mixin/required_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/required_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/required_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/without_test', ['exports', 'ember-metal/mixin'], function (exports, _emberMetalMixin) { + 'use strict'; + + QUnit.test('without should create a new mixin excluding named properties', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + foo: 'FOO', + bar: 'BAR' + }); + + var MixinB = MixinA.without('bar'); + + var obj = {}; + MixinB.apply(obj); + + equal(obj.foo, 'FOO', 'should defined foo'); + equal(obj.bar, undefined, 'should not define bar'); + }); +}); +enifed('ember-metal/tests/mixin/without_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/without_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/without_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/observer_test', ['exports', 'ember-environment', 'internal-test-helpers', 'ember-metal/observer', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/run_loop'], function (exports, _emberEnvironment, _internalTestHelpers, _emberMetalObserver, _emberMetalProperty_events, _emberMetalProperties, _emberMetalComputed, _emberMetalMixin, _emberMetalRun_loop) { + 'use strict'; + + function K() {} + + // .......................................................... + // ADD OBSERVER + // + + QUnit.module('addObserver'); + + _internalTestHelpers.testBoth('observer should fire when property is modified', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'bar', 'should invoke AFTER value changed'); + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('observer should fire when dependent property is modified', function (get, set) { + var obj = { bar: 'bar' }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toUpperCase(); + }).property('bar')); + + get(obj, 'foo'); + + var count = 0; + _emberMetalObserver.addObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'BAZ', 'should have invoked after prop change'); + count++; + }); + + set(obj, 'bar', 'baz'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('observer should continue to fire after dependent properties are accessed', function (get, set) { + var observerCount = 0; + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'prop', _emberMetalComputed.computed(function () { + return Math.random(); + })); + _emberMetalProperties.defineProperty(obj, 'anotherProp', _emberMetalComputed.computed('prop', function () { + return get(this, 'prop') + Math.random(); + })); + + _emberMetalObserver.addObserver(obj, 'prop', function () { + observerCount++; + }); + + get(obj, 'anotherProp'); + + for (var i = 0; i < 10; i++) { + _emberMetalProperty_events.propertyWillChange(obj, 'prop'); + _emberMetalProperty_events.propertyDidChange(obj, 'prop'); + } + + equal(observerCount, 10, 'should continue to fire indefinitely'); + }); + + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + _internalTestHelpers.testBoth('observer added declaratively via brace expansion should fire when property changes', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalMixin.mixin(obj, { + observeFooAndBar: (function () { + count++; + }).observes('{foo,bar}') + }); + + set(obj, 'foo', 'foo'); + equal(count, 1, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'bar', 'bar'); + equal(count, 2, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'baz', 'baz'); + equal(count, 2, 'observer not invoked on unspecified property'); + }); + + _internalTestHelpers.testBoth('observer specified declaratively via brace expansion should fire when dependent property changes', function (get, set) { + var obj = { baz: 'Initial' }; + var count = 0; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toLowerCase(); + }).property('bar')); + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + return get(this, 'baz').toUpperCase(); + }).property('baz')); + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: (function () { + count++; + }).observes('{foo,bar}') + }); + + get(obj, 'foo'); + set(obj, 'baz', 'Baz'); + // fire once for foo, once for bar + equal(count, 2, 'observer specified via brace expansion invoked on dependent property change'); + + set(obj, 'quux', 'Quux'); + equal(count, 2, 'observer not fired on unspecified property'); + }); + } + + _internalTestHelpers.testBoth('observers watching multiple properties via brace expansion should fire when the properties change', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalMixin.mixin(obj, { + observeFooAndBar: _emberMetalMixin.observer('{foo,bar}', function () { + count++; + }) + }); + + set(obj, 'foo', 'foo'); + equal(count, 1, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'bar', 'bar'); + equal(count, 2, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'baz', 'baz'); + equal(count, 2, 'observer not invoked on unspecified property'); + }); + + _internalTestHelpers.testBoth('observers watching multiple properties via brace expansion should fire when dependent properties change', function (get, set) { + var obj = { baz: 'Initial' }; + var count = 0; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toLowerCase(); + }).property('bar')); + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + return get(this, 'baz').toUpperCase(); + }).property('baz')); + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: _emberMetalMixin.observer('{foo,bar}', function () { + count++; + }) + }); + + get(obj, 'foo'); + set(obj, 'baz', 'Baz'); + // fire once for foo, once for bar + equal(count, 2, 'observer specified via brace expansion invoked on dependent property change'); + + set(obj, 'quux', 'Quux'); + equal(count, 2, 'observer not fired on unspecified property'); + }); + + _internalTestHelpers.testBoth('nested observers should fire in order', function (get, set) { + var obj = { foo: 'foo', bar: 'bar' }; + var fooCount = 0; + var barCount = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + fooCount++; + }); + _emberMetalObserver.addObserver(obj, 'bar', function () { + set(obj, 'foo', 'BAZ'); + equal(fooCount, 1, 'fooCount should have fired already'); + barCount++; + }); + + set(obj, 'bar', 'BIFF'); + equal(barCount, 1, 'barCount should have fired'); + equal(fooCount, 1, 'foo should have fired'); + }); + + _internalTestHelpers.testBoth('removing an chain observer on change should not fail', function (get, set) { + var foo = { bar: 'bar' }; + var obj1 = { foo: foo }; + var obj2 = { foo: foo }; + var obj3 = { foo: foo }; + var obj4 = { foo: foo }; + var count1 = 0; + var count2 = 0; + var count3 = 0; + var count4 = 0; + + function observer1() { + count1++; + } + function observer2() { + count2++; + } + function observer3() { + count3++; + _emberMetalObserver.removeObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver.removeObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver.removeObserver(obj4, 'foo.bar', observer4); + } + function observer4() { + count4++; + } + + _emberMetalObserver.addObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver.addObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver.addObserver(obj3, 'foo.bar', observer3); + _emberMetalObserver.addObserver(obj4, 'foo.bar', observer4); + + set(foo, 'bar', 'baz'); + + equal(count1, 1, 'observer1 fired'); + equal(count2, 1, 'observer2 fired'); + equal(count3, 1, 'observer3 fired'); + equal(count4, 0, 'observer4 did not fire'); + }); + + _internalTestHelpers.testBoth('removing an chain before observer on change should not fail', function (get, set) { + var foo = { bar: 'bar' }; + var obj1 = { foo: foo }; + var obj2 = { foo: foo }; + var obj3 = { foo: foo }; + var obj4 = { foo: foo }; + var count1 = 0; + var count2 = 0; + var count3 = 0; + var count4 = 0; + + function observer1() { + count1++; + } + function observer2() { + count2++; + } + function observer3() { + count3++; + _emberMetalObserver._removeBeforeObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver._removeBeforeObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver._removeBeforeObserver(obj4, 'foo.bar', observer4); + } + function observer4() { + count4++; + } + + _emberMetalObserver._addBeforeObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver._addBeforeObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver._addBeforeObserver(obj3, 'foo.bar', observer3); + _emberMetalObserver._addBeforeObserver(obj4, 'foo.bar', observer4); + + set(foo, 'bar', 'baz'); + + equal(count1, 1, 'observer1 fired'); + equal(count2, 1, 'observer2 fired'); + equal(count3, 1, 'observer3 fired'); + equal(count4, 0, 'observer4 did not fire'); + }); + + _internalTestHelpers.testBoth('suspending an observer should not fire during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + equal(_emberMetalObserver._suspendObserver(obj, 'foo', target, target.method, callback), 'result'); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('suspending an observer should not defer change notifications during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + _emberMetalProperty_events.beginPropertyChanges(); + equal(_emberMetalObserver._suspendObserver(obj, 'foo', target, target.method, callback), 'result'); + _emberMetalProperty_events.endPropertyChanges(); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('suspending observers should not fire during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + equal(_emberMetalObserver._suspendObservers(obj, ['foo'], target, target.method, callback), 'result'); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('suspending observers should not defer change notifications during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + _emberMetalProperty_events.beginPropertyChanges(); + equal(_emberMetalObserver._suspendObservers(obj, ['foo'], target, target.method, callback), 'result'); + _emberMetalProperty_events.endPropertyChanges(); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('deferring property change notifications', function (get, set) { + var obj = { foo: 'foo' }; + var fooCount = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + fooCount++; + }); + + _emberMetalProperty_events.beginPropertyChanges(obj); + set(obj, 'foo', 'BIFF'); + set(obj, 'foo', 'BAZ'); + _emberMetalProperty_events.endPropertyChanges(obj); + + equal(fooCount, 1, 'foo should have fired once'); + }); + + _internalTestHelpers.testBoth('deferring property change notifications safely despite exceptions', function (get, set) { + var obj = { foo: 'foo' }; + var fooCount = 0; + var exc = new Error('Something unexpected happened!'); + + expect(2); + _emberMetalObserver.addObserver(obj, 'foo', function () { + fooCount++; + }); + + try { + _emberMetalProperty_events.changeProperties(function () { + set(obj, 'foo', 'BIFF'); + set(obj, 'foo', 'BAZ'); + throw exc; + }); + } catch (err) { + if (err !== exc) { + throw err; + } + } + + equal(fooCount, 1, 'foo should have fired once'); + + _emberMetalProperty_events.changeProperties(function () { + set(obj, 'foo', 'BIFF2'); + set(obj, 'foo', 'BAZ2'); + }); + + equal(fooCount, 2, 'foo should have fired again once'); + }); + + _internalTestHelpers.testBoth('deferring property change notifications will not defer before observers', function (get, set) { + var obj = { foo: 'foo' }; + var fooCount = 0; + + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + fooCount++; + }); + + _emberMetalProperty_events.beginPropertyChanges(obj); + set(obj, 'foo', 'BIFF'); + equal(fooCount, 1, 'should fire before observer immediately'); + set(obj, 'foo', 'BAZ'); + _emberMetalProperty_events.endPropertyChanges(obj); + + equal(fooCount, 1, 'should not fire before observer twice'); + }); + + _internalTestHelpers.testBoth('addObserver should propagate through prototype', function (get, set) { + var obj = { foo: 'foo', count: 0 }; + var obj2 = undefined; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + this.count++; + }); + obj2 = Object.create(obj); + + set(obj2, 'foo', 'bar'); + + equal(obj2.count, 1, 'should have invoked observer on inherited'); + equal(obj.count, 0, 'should not have invoked observer on parent'); + + obj2.count = 0; + set(obj, 'foo', 'baz'); + equal(obj.count, 1, 'should have invoked observer on parent'); + equal(obj2.count, 0, 'should not have invoked observer on inherited'); + }); + + _internalTestHelpers.testBoth('addObserver should respect targets with methods', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + didChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target1, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'BAZ', 'param3 should new value'); + this.count++; + } + }; + + var target2 = { + count: 0, + + didChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target2, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'BAZ', 'param3 should new value'); + this.count++; + } + }; + + _emberMetalObserver.addObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.addObserver(observed, 'foo', target2, target2.didChange); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + }); + + _internalTestHelpers.testBoth('addObserver should allow multiple objects to observe a property', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + didChange: function (obj, keyName, value) { + this.count++; + } + }; + + var target2 = { + count: 0, + + didChange: function (obj, keyName, value) { + this.count++; + } + }; + + _emberMetalObserver.addObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.addObserver(observed, 'foo', target2, 'didChange'); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + }); + + // .......................................................... + // REMOVE OBSERVER + // + + QUnit.module('removeObserver'); + + _internalTestHelpers.testBoth('removing observer should stop firing', function (get, set) { + var obj = {}; + var count = 0; + function F() { + count++; + } + _emberMetalObserver.addObserver(obj, 'foo', F); + + set(obj, 'foo', 'bar'); + equal(count, 1, 'should have invoked observer'); + + _emberMetalObserver.removeObserver(obj, 'foo', F); + + set(obj, 'foo', 'baz'); + equal(count, 1, 'removed observer shouldn\'t fire'); + }); + + _internalTestHelpers.testBoth('local observers can be removed', function (get, set) { + var barObserved = 0; + + var MyMixin = _emberMetalMixin.Mixin.create({ + foo1: _emberMetalMixin.observer('bar', function () { + barObserved++; + }), + + foo2: _emberMetalMixin.observer('bar', function () { + barObserved++; + }) + }); + + var obj = {}; + MyMixin.apply(obj); + + set(obj, 'bar', 'HI!'); + equal(barObserved, 2, 'precond - observers should be fired'); + + _emberMetalObserver.removeObserver(obj, 'bar', null, 'foo1'); + + barObserved = 0; + set(obj, 'bar', 'HI AGAIN!'); + + equal(barObserved, 1, 'removed observers should not be called'); + }); + + _internalTestHelpers.testBoth('removeObserver should respect targets with methods', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + didChange: function () { + this.count++; + } + }; + + var target2 = { + count: 0, + + didChange: function () { + this.count++; + } + }; + + _emberMetalObserver.addObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.addObserver(observed, 'foo', target2, target2.didChange); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + + _emberMetalObserver.removeObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.removeObserver(observed, 'foo', target2, target2.didChange); + + target1.count = target2.count = 0; + set(observed, 'foo', 'BAZ'); + equal(target1.count, 0, 'target1 observer should not fire again'); + equal(target2.count, 0, 'target2 observer should not fire again'); + }); + + // .......................................................... + // BEFORE OBSERVER + // + + QUnit.module('_addBeforeObserver'); + + _internalTestHelpers.testBoth('observer should fire before a property is modified', function (get, set) { + var obj = { foo: 'foo' }; + var count = 0; + + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'foo', 'should invoke before value changed'); + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('observer should fire before dependent property is modified', function (get, set) { + var obj = { bar: 'bar' }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toUpperCase(); + }).property('bar')); + + get(obj, 'foo'); + + var count = 0; + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'BAR', 'should have invoked after prop change'); + count++; + }); + + set(obj, 'bar', 'baz'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('before observer watching multiple properties via brace expansion should fire when properties change', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: _emberMetalMixin._beforeObserver('{foo,bar}', function () { + count++; + }) + }); + + set(obj, 'foo', 'foo'); + equal(count, 1, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'bar', 'bar'); + equal(count, 2, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'baz', 'baz'); + equal(count, 2, 'observer not invoked on unspecified property'); + }); + + _internalTestHelpers.testBoth('before observer watching multiple properties via brace expansion should fire when dependent property changes', function (get, set) { + var obj = { baz: 'Initial' }; + var count = 0; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toLowerCase(); + }).property('bar')); + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + return get(this, 'baz').toUpperCase(); + }).property('baz')); + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: _emberMetalMixin._beforeObserver('{foo,bar}', function () { + count++; + }) + }); + + get(obj, 'foo'); + set(obj, 'baz', 'Baz'); + // fire once for foo, once for bar + equal(count, 2, 'observer specified via brace expansion invoked on dependent property change'); + + set(obj, 'quux', 'Quux'); + equal(count, 2, 'observer not fired on unspecified property'); + }); + + _internalTestHelpers.testBoth('_addBeforeObserver should propagate through prototype', function (get, set) { + var obj = { foo: 'foo', count: 0 }; + var obj2 = undefined; + + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + this.count++; + }); + obj2 = Object.create(obj); + + set(obj2, 'foo', 'bar'); + equal(obj2.count, 1, 'should have invoked observer on inherited'); + equal(obj.count, 0, 'should not have invoked observer on parent'); + + obj2.count = 0; + set(obj, 'foo', 'baz'); + equal(obj.count, 1, 'should have invoked observer on parent'); + equal(obj2.count, 0, 'should not have invoked observer on inherited'); + }); + + _internalTestHelpers.testBoth('_addBeforeObserver should respect targets with methods', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + willChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target1, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'foo', 'param3 should old value'); + this.count++; + } + }; + + var target2 = { + count: 0, + + willChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target2, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'foo', 'param3 should old value'); + this.count++; + } + }; + + _emberMetalObserver._addBeforeObserver(observed, 'foo', target1, 'willChange'); + _emberMetalObserver._addBeforeObserver(observed, 'foo', target2, target2.willChange); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + }); + + // .......................................................... + // CHAINED OBSERVERS + // + + var obj = undefined, + count = undefined; + + QUnit.module('addObserver - dependentkey with chained properties', { + setup: function () { + obj = { + foo: { + bar: { + baz: { + biff: 'BIFF' + } + } + }, + Capital: { + foo: { + bar: { + baz: { + biff: 'BIFF' + } + } + } + } + }; + + count = 0; + }, + + teardown: function () { + obj = count = null; + } + }); + + _internalTestHelpers.testBoth('depending on a chain with a computed property', function (get, set) { + _emberMetalProperties.defineProperty(obj, 'computed', _emberMetalComputed.computed(function () { + return { foo: 'bar' }; + })); + + var changed = 0; + _emberMetalObserver.addObserver(obj, 'computed.foo', function () { + changed++; + }); + + equal(_emberMetalComputed.cacheFor(obj, 'computed'), undefined, 'addObserver should not compute CP'); + + set(obj, 'computed.foo', 'baz'); + + equal(changed, 1, 'should fire observer'); + }); + + _internalTestHelpers.testBoth('depending on a simple chain', function (get, set) { + var val = undefined; + _emberMetalObserver.addObserver(obj, 'foo.bar.baz.biff', function (target, key) { + val = get(target, key); + count++; + }); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 1); + + set(get(obj, 'foo.bar'), 'baz', { biff: 'BLARG' }); + equal(val, 'BLARG'); + equal(count, 2); + + set(get(obj, 'foo'), 'bar', { baz: { biff: 'BOOM' } }); + equal(val, 'BOOM'); + equal(count, 3); + + set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(val, 'BLARG'); + equal(count, 4); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 5); + + var foo = get(obj, 'foo'); + + set(obj, 'foo', 'BOO'); + equal(val, undefined); + equal(count, 6); + + set(foo.bar.baz, 'biff', 'BOOM'); + equal(count, 6, 'should be not have invoked observer'); + }); + + _internalTestHelpers.testBoth('depending on a chain with a capitalized first key', function (get, set) { + var val = undefined; + + _emberMetalObserver.addObserver(obj, 'Capital.foo.bar.baz.biff', function (target, key) { + val = get(obj, key); + count++; + }); + + set(get(obj, 'Capital.foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 1); + + set(get(obj, 'Capital.foo.bar'), 'baz', { biff: 'BLARG' }); + equal(val, 'BLARG'); + equal(count, 2); + + set(get(obj, 'Capital.foo'), 'bar', { baz: { biff: 'BOOM' } }); + equal(val, 'BOOM'); + equal(count, 3); + + set(obj, 'Capital.foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(val, 'BLARG'); + equal(count, 4); + + set(get(obj, 'Capital.foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 5); + + var foo = get(obj, 'foo'); + + set(obj, 'Capital.foo', 'BOO'); + equal(val, undefined); + equal(count, 6); + + set(foo.bar.baz, 'biff', 'BOOM'); + equal(count, 6, 'should be not have invoked observer'); + }); + + QUnit.module('_removeBeforeObserver'); + + // .......................................................... + // SETTING IDENTICAL VALUES + // + + QUnit.module('props/observer_test - setting identical values'); + + _internalTestHelpers.testBoth('setting simple prop should not trigger', function (get, set) { + var obj = { foo: 'bar' }; + var count = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 0, 'should not trigger observer'); + + set(obj, 'foo', 'baz'); + equal(count, 1, 'should trigger observer'); + + set(obj, 'foo', 'baz'); + equal(count, 1, 'should not trigger observer again'); + }); + + // The issue here is when a computed property is directly set with a value, then has a + // dependent key change (which triggers a cache expiration and recomputation), observers will + // not be fired if the CP setter is called with the last set value. + _internalTestHelpers.testBoth('setting a cached computed property whose value has changed should trigger', function (get, set) { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return get(this, 'baz'); + }, + set: function (key, value) { + return value; + } + }).property('baz')); + + var count = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 1); + equal(get(obj, 'foo'), 'bar'); + + set(obj, 'baz', 'qux'); + equal(count, 2); + equal(get(obj, 'foo'), 'qux'); + + get(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(count, 3); + equal(get(obj, 'foo'), 'bar'); + }); + + QUnit.module('Ember.immediateObserver (Deprecated)'); + + _internalTestHelpers.testBoth('immediate observers should fire synchronously', function (get, set) { + expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); + var obj = {}; + var observerCalled = 0; + var mixin = undefined; + + // explicitly create a run loop so we do not inadvertently + // trigger deferred behavior + _emberMetalRun_loop.default(function () { + mixin = _emberMetalMixin.Mixin.create({ + fooDidChange: _emberMetalMixin._immediateObserver('foo', function () { + observerCalled++; + equal(get(this, 'foo'), 'barbaz', 'newly set value is immediately available'); + }) + }); + + mixin.apply(obj); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return 'yes hello this is foo'; + }, + set: function (key, value) { + return value; + } + })); + + equal(get(obj, 'foo'), 'yes hello this is foo', 'precond - computed property returns a value'); + equal(observerCalled, 0, 'observer has not yet been called'); + + set(obj, 'foo', 'barbaz'); + + equal(observerCalled, 1, 'observer was called once'); + }); + }); + + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + _internalTestHelpers.testBoth('immediate observers added declaratively via brace expansion fire synchronously', function (get, set) { + var obj = {}; + var observerCalled = 0; + var mixin = undefined; + + // explicitly create a run loop so we do not inadvertently + // trigger deferred behavior + _emberMetalRun_loop.default(function () { + expectDeprecation(function () { + mixin = _emberMetalMixin.Mixin.create({ + fooDidChange: (function () { + observerCalled++; + equal(get(this, 'foo'), 'barbaz', 'newly set value is immediately available'); + }).observesImmediately('{foo,bar}') + }); + }, /Function#observesImmediately is deprecated. Use Function#observes instead/); + + mixin.apply(obj); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return 'yes hello this is foo'; + }, + set: function (key, value) { + return value; + } + })); + + equal(get(obj, 'foo'), 'yes hello this is foo', 'precond - computed property returns a value'); + equal(observerCalled, 0, 'observer has not yet been called'); + + set(obj, 'foo', 'barbaz'); + + equal(observerCalled, 1, 'observer was called once'); + }); + }); + } + + _internalTestHelpers.testBoth('immediate observers watching multiple properties via brace expansion fire synchronously', function (get, set) { + expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); + var obj = {}; + var observerCalled = 0; + var mixin = undefined; + + // explicitly create a run loop so we do not inadvertently + // trigger deferred behavior + _emberMetalRun_loop.default(function () { + mixin = _emberMetalMixin.Mixin.create({ + fooDidChange: _emberMetalMixin._immediateObserver('{foo,bar}', function () { + observerCalled++; + equal(get(this, 'foo'), 'barbaz', 'newly set value is immediately available'); + }) + }); + + mixin.apply(obj); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return 'yes hello this is foo'; + }, + set: function (key, value) { + return value; + } + })); + + equal(get(obj, 'foo'), 'yes hello this is foo', 'precond - computed property returns a value'); + equal(observerCalled, 0, 'observer has not yet been called'); + + set(obj, 'foo', 'barbaz'); + + equal(observerCalled, 1, 'observer was called once'); + }); + }); + + _internalTestHelpers.testBoth('immediate observers are for internal properties only', function (get, set) { + expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); + expectAssertion(function () { + _emberMetalMixin._immediateObserver('foo.bar', function () { + return this; + }); + }, 'Immediate observers must observe internal properties only, not properties on other objects.'); + }); + + QUnit.module('changeProperties'); + + _internalTestHelpers.testBoth('observers added/removed during changeProperties should do the right thing.', function (get, set) { + var obj = { + foo: 0 + }; + function Observer() { + this.willChangeCount = 0; + this.didChangeCount = 0; + } + Observer.prototype = { + add: function () { + _emberMetalObserver._addBeforeObserver(obj, 'foo', this, 'willChange'); + _emberMetalObserver.addObserver(obj, 'foo', this, 'didChange'); + }, + remove: function () { + _emberMetalObserver._removeBeforeObserver(obj, 'foo', this, 'willChange'); + _emberMetalObserver.removeObserver(obj, 'foo', this, 'didChange'); + }, + willChange: function () { + this.willChangeCount++; + }, + didChange: function () { + this.didChangeCount++; + } + }; + var addedBeforeFirstChangeObserver = new Observer(); + var addedAfterFirstChangeObserver = new Observer(); + var addedAfterLastChangeObserver = new Observer(); + var removedBeforeFirstChangeObserver = new Observer(); + var removedBeforeLastChangeObserver = new Observer(); + var removedAfterLastChangeObserver = new Observer(); + removedBeforeFirstChangeObserver.add(); + removedBeforeLastChangeObserver.add(); + removedAfterLastChangeObserver.add(); + _emberMetalProperty_events.changeProperties(function () { + removedBeforeFirstChangeObserver.remove(); + addedBeforeFirstChangeObserver.add(); + + set(obj, 'foo', 1); + + equal(addedBeforeFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called before the first change invoked immediately'); + equal(addedBeforeFirstChangeObserver.didChangeCount, 0, 'addObserver called before the first change is deferred'); + + addedAfterFirstChangeObserver.add(); + removedBeforeLastChangeObserver.remove(); + + set(obj, 'foo', 2); + + equal(addedAfterFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called after the first change invoked immediately'); + equal(addedAfterFirstChangeObserver.didChangeCount, 0, 'addObserver called after the first change is deferred'); + + addedAfterLastChangeObserver.add(); + removedAfterLastChangeObserver.remove(); + }); + + equal(removedBeforeFirstChangeObserver.willChangeCount, 0, '_removeBeforeObserver called before the first change sees none'); + equal(removedBeforeFirstChangeObserver.didChangeCount, 0, 'removeObserver called before the first change sees none'); + equal(addedBeforeFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called before the first change sees only 1'); + equal(addedBeforeFirstChangeObserver.didChangeCount, 1, 'addObserver called before the first change sees only 1'); + equal(addedAfterFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called after the first change sees 1'); + equal(addedAfterFirstChangeObserver.didChangeCount, 1, 'addObserver called after the first change sees 1'); + equal(addedAfterLastChangeObserver.willChangeCount, 0, '_addBeforeObserver called after the last change sees none'); + equal(addedAfterLastChangeObserver.didChangeCount, 0, 'addObserver called after the last change sees none'); + equal(removedBeforeLastChangeObserver.willChangeCount, 1, '_removeBeforeObserver called before the last change still sees 1'); + equal(removedBeforeLastChangeObserver.didChangeCount, 1, 'removeObserver called before the last change still sees 1'); + equal(removedAfterLastChangeObserver.willChangeCount, 1, '_removeBeforeObserver called after the last change still sees 1'); + equal(removedAfterLastChangeObserver.didChangeCount, 1, 'removeObserver called after the last change still sees 1'); + }); + + QUnit.module('Keys behavior with observers'); + + _internalTestHelpers.testBoth('should not leak properties on the prototype', function () { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + deepEqual(Object.keys(beer), []); + _emberMetalObserver.removeObserver(beer, 'type', K); + }); + + _internalTestHelpers.testBoth('observing a non existent property', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'brand', K); + + deepEqual(Object.keys(beer), []); + + set(beer, 'brand', 'Corona'); + deepEqual(Object.keys(beer), ['brand']); + + _emberMetalObserver.removeObserver(beer, 'brand', K); + }); + + _internalTestHelpers.testBoth('with observers switched on and off', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + _emberMetalObserver.removeObserver(beer, 'type', K); + + deepEqual(Object.keys(beer), []); + }); + + _internalTestHelpers.testBoth('observers switched on and off with setter in between', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + set(beer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + + deepEqual(Object.keys(beer), ['type']); + }); + + _internalTestHelpers.testBoth('observer switched on and off and then setter', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + _emberMetalObserver.removeObserver(beer, 'type', K); + set(beer, 'type', 'ale'); + + deepEqual(Object.keys(beer), ['type']); + }); + + _internalTestHelpers.testBoth('observers switched on and off with setter in between (observed property is not shadowing)', function (get, set) { + function Beer() {} + + var beer = new Beer(); + set(beer, 'type', 'ale'); + deepEqual(Object.keys(beer), ['type'], 'only set'); + + var otherBeer = new Beer(); + _emberMetalObserver.addObserver(otherBeer, 'type', K); + set(otherBeer, 'type', 'ale'); + deepEqual(Object.keys(otherBeer), ['type'], 'addObserver -> set'); + + var yetAnotherBeer = new Beer(); + _emberMetalObserver.addObserver(yetAnotherBeer, 'type', K); + set(yetAnotherBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(yetAnotherBeer), ['type'], 'addObserver -> set -> removeObserver'); + + var itsMyLastBeer = new Beer(); + set(itsMyLastBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); + }); + + _internalTestHelpers.testBoth('observers switched on and off with setter in between (observed property is shadowing one on the prototype)', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + set(beer, 'type', 'ale'); + deepEqual(Object.keys(beer), ['type'], 'after set'); + + var otherBeer = new Beer(); + _emberMetalObserver.addObserver(otherBeer, 'type', K); + set(otherBeer, 'type', 'ale'); + deepEqual(Object.keys(otherBeer), ['type'], 'addObserver -> set'); + + var yetAnotherBeer = new Beer(); + _emberMetalObserver.addObserver(yetAnotherBeer, 'type', K); + set(yetAnotherBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(yetAnotherBeer), ['type'], 'addObserver -> set -> removeObserver'); + + var itsMyLastBeer = new Beer(); + set(itsMyLastBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); + }); +}); +enifed('ember-metal/tests/observer_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/observer_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/observer_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/performance_test', ['exports', 'ember-metal/property_set', 'ember-metal/property_get', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/observer'], function (exports, _emberMetalProperty_set, _emberMetalProperty_get, _emberMetalComputed, _emberMetalProperties, _emberMetalProperty_events, _emberMetalObserver) { + 'use strict'; + + /* + This test file is designed to capture performance regressions related to + deferred computation. Things like run loops, computed properties, and bindings + should run the minimum amount of times to achieve best performance, so any + bugs that cause them to get evaluated more than necessary should be put here. + */ + + QUnit.module('Computed Properties - Number of times evaluated'); + + QUnit.test('computed properties that depend on multiple properties should run only once per run loop', function () { + var obj = { a: 'a', b: 'b', c: 'c' }; + var cpCount = 0; + var obsCount = 0; + + _emberMetalProperties.defineProperty(obj, 'abc', _emberMetalComputed.computed(function (key) { + cpCount++; + return 'computed ' + key; + }).property('a', 'b', 'c')); + + _emberMetalProperty_get.get(obj, 'abc'); + + cpCount = 0; + + _emberMetalObserver.addObserver(obj, 'abc', function () { + obsCount++; + }); + + _emberMetalProperty_events.beginPropertyChanges(); + _emberMetalProperty_set.set(obj, 'a', 'aa'); + _emberMetalProperty_set.set(obj, 'b', 'bb'); + _emberMetalProperty_set.set(obj, 'c', 'cc'); + _emberMetalProperty_events.endPropertyChanges(); + + _emberMetalProperty_get.get(obj, 'abc'); + + equal(cpCount, 1, 'The computed property is only invoked once'); + equal(obsCount, 1, 'The observer is only invoked once'); + }); + + QUnit.test('computed properties are not executed if they are the last segment of an observer chain pain', function () { + var foo = { bar: { baz: {} } }; + + var count = 0; + + _emberMetalProperties.defineProperty(foo.bar.baz, 'bam', _emberMetalComputed.computed(function () { + count++; + })); + + _emberMetalObserver.addObserver(foo, 'bar.baz.bam', function () {}); + + _emberMetalProperty_events.propertyDidChange(_emberMetalProperty_get.get(foo, 'bar.baz'), 'bam'); + + equal(count, 0, 'should not have recomputed property'); + }); +}); +enifed('ember-metal/tests/performance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/performance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/performance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/properties_test', ['exports', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/deprecate_property'], function (exports, _emberMetalComputed, _emberMetalProperties, _emberMetalDeprecate_property) { + 'use strict'; + + QUnit.module('Ember.defineProperty'); + + QUnit.test('toString', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'toString', undefined, function () { + return 'FOO'; + }); + equal(obj.toString(), 'FOO', 'should replace toString'); + }); + + QUnit.test('for data properties, didDefineProperty hook should be called if implemented', function () { + expect(2); + + var obj = { + didDefineProperty: function (obj, keyName, value) { + equal(keyName, 'foo', 'key name should be foo'); + equal(value, 'bar', 'value should be bar'); + } + }; + + _emberMetalProperties.defineProperty(obj, 'foo', undefined, 'bar'); + }); + + QUnit.test('for computed properties, didDefineProperty hook should be called if implemented', function () { + expect(2); + + var computedProperty = _emberMetalComputed.computed(function () { + return this; + }); + + var obj = { + didDefineProperty: function (obj, keyName, value) { + equal(keyName, 'foo', 'key name should be foo'); + strictEqual(value, computedProperty, 'value should be passed as computed property'); + } + }; + + _emberMetalProperties.defineProperty(obj, 'foo', computedProperty); + }); + + QUnit.test('for descriptor properties, didDefineProperty hook should be called if implemented', function () { + expect(2); + + var descriptor = { + writable: true, + configurable: false, + enumerable: true, + value: 42 + }; + + var obj = { + didDefineProperty: function (obj, keyName, value) { + equal(keyName, 'answer', 'key name should be answer'); + strictEqual(value, descriptor, 'value should be passed as descriptor'); + } + }; + + _emberMetalProperties.defineProperty(obj, 'answer', descriptor); + }); + + QUnit.module('Ember.deprecateProperty'); + + QUnit.test('enables access to deprecated property and returns the value of the new property', function () { + expect(3); + var obj = { foo: 'bar' }; + + _emberMetalDeprecate_property.deprecateProperty(obj, 'baz', 'foo'); + + expectDeprecation(); + equal(obj.baz, obj.foo, 'baz and foo are equal'); + + obj.foo = 'blammo'; + equal(obj.baz, obj.foo, 'baz and foo are equal'); + }); + + QUnit.test('deprecatedKey is not enumerable', function () { + expect(2); + var obj = { foo: 'bar', blammo: 'whammy' }; + + _emberMetalDeprecate_property.deprecateProperty(obj, 'baz', 'foo'); + + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + notEqual(prop, 'baz'); + } + } + }); + + QUnit.test('enables setter to deprecated property and updates the value of the new property', function () { + expect(3); + var obj = { foo: 'bar' }; + + _emberMetalDeprecate_property.deprecateProperty(obj, 'baz', 'foo'); + + expectDeprecation(); + obj.baz = 'bloop'; + equal(obj.foo, 'bloop', 'updating baz updates foo'); + equal(obj.baz, obj.foo, 'baz and foo are equal'); + }); +}); +enifed('ember-metal/tests/properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/property_did_change_hook', ['exports', 'internal-test-helpers', 'ember-metal/property_events', 'ember-metal/watching', 'ember-metal/properties', 'ember-metal/alias', 'ember-metal/computed'], function (exports, _internalTestHelpers, _emberMetalProperty_events, _emberMetalWatching, _emberMetalProperties, _emberMetalAlias, _emberMetalComputed) { + 'use strict'; + + QUnit.module('PROPERTY_DID_CHANGE'); + + _internalTestHelpers.testBoth('alias and cp', function (get, set) { + var _obj; + + var counts = {}; + var obj = (_obj = { + child: {} + }, _obj[_emberMetalProperty_events.PROPERTY_DID_CHANGE] = function (keyName) { + counts[keyName] = (counts[keyName] || 0) + 1; + }, _obj); + + _emberMetalProperties.defineProperty(obj, 'cost', _emberMetalAlias.default('child.cost')); + _emberMetalProperties.defineProperty(obj, 'tax', _emberMetalAlias.default('child.tax')); + + _emberMetalProperties.defineProperty(obj, 'total', _emberMetalComputed.computed('cost', 'tax', { + get: function () { + return get(this, 'cost') + get(this, 'tax'); + } + })); + + ok(!_emberMetalWatching.isWatching(obj, 'child.cost'), 'precond alias target `child.cost` is not watched'); + equal(get(obj, 'cost'), undefined); + // this is how PROPERTY_DID_CHANGE will get notified + ok(_emberMetalWatching.isWatching(obj, 'child.cost'), 'alias target `child.cost` is watched after consumption'); + + ok(!_emberMetalWatching.isWatching(obj, 'child.tax'), 'precond alias target `child.tax` is not watched'); + equal(get(obj, 'tax'), undefined); + // this is how PROPERTY_DID_CHANGE will get notified + ok(_emberMetalWatching.isWatching(obj, 'child.tax'), 'alias target `child.cost` is watched after consumption'); + + // increments the watching count on the alias itself to 1 + ok(isNaN(get(obj, 'total')), 'total is initialized'); + + // decrements the watching count on the alias itself to 0 + set(obj, 'child', { + cost: 399.00, + tax: 32.93 + }); + + // this should have called PROPERTY_DID_CHANGE for all of them + equal(counts['cost'], 1, 'PROPERTY_DID_CHANGE called with cost'); + equal(counts['tax'], 1, 'PROPERTY_DID_CHANGE called with tax'); + equal(counts['total'], 1, 'PROPERTY_DID_CHANGE called with total'); + + // we should still have a dependency installed + ok(_emberMetalWatching.isWatching(obj, 'child.cost'), 'watching child.cost'); + ok(_emberMetalWatching.isWatching(obj, 'child.tax'), 'watching child.tax'); + + set(obj, 'child', { + cost: 100.00, + tax: 10.00 + }); + + equal(counts['cost'], 2, 'PROPERTY_DID_CHANGE called with cost'); + equal(counts['tax'], 2, 'PROPERTY_DID_CHANGE called with tax'); + equal(counts['total'], 1, 'PROPERTY_DID_CHANGE called with total'); + }); +}); +enifed('ember-metal/tests/property_did_change_hook.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/property_did_change_hook.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/property_did_change_hook.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/add_queue_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + var originalQueues = _emberMetalRun_loop.default.queues; + var queues = undefined; + + QUnit.module('system/run_loop/add_queue_test', { + setup: function () { + _emberMetalRun_loop.default.queues = queues = ['blork', 'bleep']; + }, + teardown: function () { + _emberMetalRun_loop.default.queues = originalQueues; + } + }); + + QUnit.test('adds a queue after a specified one', function () { + _emberMetalRun_loop.default._addQueue('testeroo', 'blork'); + + equal(queues.indexOf('testeroo'), 1, 'new queue was added after specified queue'); + }); + + QUnit.test('does not add the queue if it already exists', function () { + _emberMetalRun_loop.default._addQueue('testeroo', 'blork'); + _emberMetalRun_loop.default._addQueue('testeroo', 'blork'); + + equal(queues.length, 3, 'queue was not added twice'); + }); +}); +enifed('ember-metal/tests/run_loop/add_queue_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/add_queue_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/add_queue_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/debounce_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + var originalDebounce = _emberMetalRun_loop.default.backburner.debounce; + var wasCalled = false; + + QUnit.module('Ember.run.debounce', { + setup: function () { + _emberMetalRun_loop.default.backburner.debounce = function () { + wasCalled = true; + }; + }, + teardown: function () { + _emberMetalRun_loop.default.backburner.debounce = originalDebounce; + } + }); + + QUnit.test('Ember.run.debounce uses Backburner.debounce', function () { + _emberMetalRun_loop.default.debounce(function () {}); + ok(wasCalled, 'Ember.run.debounce used'); + }); +}); +enifed('ember-metal/tests/run_loop/debounce_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/debounce_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/debounce_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/later_test', ['exports', 'ember-metal/is_none', 'ember-metal/run_loop'], function (exports, _emberMetalIs_none, _emberMetalRun_loop) { + 'use strict'; + + var originalSetTimeout = window.setTimeout; + var originalDateValueOf = Date.prototype.valueOf; + var originalPlatform = _emberMetalRun_loop.default.backburner._platform; + + function wait(callback, maxWaitCount) { + maxWaitCount = _emberMetalIs_none.default(maxWaitCount) ? 100 : maxWaitCount; + + originalSetTimeout(function () { + if (maxWaitCount > 0 && (_emberMetalRun_loop.default.hasScheduledTimers() || _emberMetalRun_loop.default.currentRunLoop)) { + wait(callback, maxWaitCount - 1); + + return; + } + + callback(); + }, 10); + } + + // Synchronous "sleep". This simulates work being done + // after run.later was called but before the run loop + // has flushed. In previous versions, this would have + // caused the run.later callback to have run from + // within the run loop flush, since by the time the + // run loop has to flush, it would have considered + // the timer already expired. + function pauseUntil(time) { + // jscs:disable + while (+new Date() < time) {} /* do nothing - sleeping */ + // jscs:enable + } + + QUnit.module('run.later', { + teardown: function () { + _emberMetalRun_loop.default.backburner._platform = originalPlatform; + window.setTimeout = originalSetTimeout; + Date.prototype.valueOf = originalDateValueOf; + } + }); + + asyncTest('should invoke after specified period of time - function only', function () { + var invoked = false; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(function () { + return invoked = true; + }, 100); + }); + + wait(function () { + QUnit.start(); + equal(invoked, true, 'should have invoked later item'); + }); + }); + + asyncTest('should invoke after specified period of time - target/method', function () { + var obj = { invoked: false }; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(obj, function () { + this.invoked = true; + }, 100); + }); + + wait(function () { + QUnit.start(); + equal(obj.invoked, true, 'should have invoked later item'); + }); + }); + + asyncTest('should invoke after specified period of time - target/method/args', function () { + var obj = { invoked: 0 }; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(obj, function (amt) { + this.invoked += amt; + }, 10, 100); + }); + + wait(function () { + QUnit.start(); + equal(obj.invoked, 10, 'should have invoked later item'); + }); + }); + + asyncTest('should always invoke within a separate runloop', function () { + var obj = { invoked: 0 }; + var firstRunLoop = undefined, + secondRunLoop = undefined; + + _emberMetalRun_loop.default(function () { + firstRunLoop = _emberMetalRun_loop.default.currentRunLoop; + + _emberMetalRun_loop.default.later(obj, function (amt) { + this.invoked += amt; + secondRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }, 10, 1); + + pauseUntil(+new Date() + 100); + }); + + ok(firstRunLoop, 'first run loop captured'); + ok(!_emberMetalRun_loop.default.currentRunLoop, 'shouldn\'t be in a run loop after flush'); + equal(obj.invoked, 0, 'shouldn\'t have invoked later item yet'); + + wait(function () { + QUnit.start(); + equal(obj.invoked, 10, 'should have invoked later item'); + ok(secondRunLoop, 'second run loop took place'); + ok(secondRunLoop !== firstRunLoop, 'two different run loops took place'); + }); + }); + + // Our current implementation doesn't allow us to correctly enforce this ordering. + // We should probably implement a queue to provide this guarantee. + // See https://github.com/emberjs/ember.js/issues/3526 for more information. + + // asyncTest('callback order', function() { + // let array = []; + // function fn(val) { array.push(val); } + + // run(function() { + // run.later(this, fn, 4, 5); + // run.later(this, fn, 1, 1); + // run.later(this, fn, 5, 10); + // run.later(this, fn, 2, 3); + // run.later(this, fn, 3, 3); + // }); + + // deepEqual(array, []); + + // wait(function() { + // QUnit.start(); + // deepEqual(array, [1,2,3,4,5], 'callbacks were called in expected order'); + // }); + // }); + + // Out current implementation doesn't allow us to properly enforce what is tested here. + // We should probably fix it, but it's not technically a bug right now. + // See https://github.com/emberjs/ember.js/issues/3522 for more information. + + // asyncTest('callbacks coalesce into same run loop if expiring at the same time', function() { + // let array = []; + // function fn(val) { array.push(run.currentRunLoop); } + + // run(function() { + + // // Force +new Date to return the same result while scheduling + // // run.later timers. Otherwise: non-determinism! + // let now = +new Date(); + // Date.prototype.valueOf = function() { return now; }; + + // run.later(this, fn, 10); + // run.later(this, fn, 200); + // run.later(this, fn, 200); + + // Date.prototype.valueOf = originalDateValueOf; + // }); + + // deepEqual(array, []); + + // wait(function() { + // QUnit.start(); + // equal(array.length, 3, 'all callbacks called'); + // ok(array[0] !== array[1], 'first two callbacks have different run loops'); + // ok(array[0], 'first runloop present'); + // ok(array[1], 'second runloop present'); + // equal(array[1], array[2], 'last two callbacks got the same run loop'); + // }); + // }); + + asyncTest('inception calls to run.later should run callbacks in separate run loops', function () { + var runLoop = undefined, + finished = undefined; + + _emberMetalRun_loop.default(function () { + runLoop = _emberMetalRun_loop.default.currentRunLoop; + ok(runLoop); + + _emberMetalRun_loop.default.later(function () { + ok(_emberMetalRun_loop.default.currentRunLoop && _emberMetalRun_loop.default.currentRunLoop !== runLoop, 'first later callback has own run loop'); + runLoop = _emberMetalRun_loop.default.currentRunLoop; + + _emberMetalRun_loop.default.later(function () { + ok(_emberMetalRun_loop.default.currentRunLoop && _emberMetalRun_loop.default.currentRunLoop !== runLoop, 'second later callback has own run loop'); + finished = true; + }, 40); + }, 40); + }); + + wait(function () { + QUnit.start(); + ok(finished, 'all .later callbacks run'); + }); + }); + + asyncTest('setTimeout should never run with a negative wait', function () { + // Rationale: The old run loop code was susceptible to an occasional + // bug where invokeLaterTimers would be scheduled with a setTimeout + // with a negative wait. Modern browsers normalize this to 0, but + // older browsers (IE <= 8) break with a negative wait, which + // happens when an expired timer callback takes a while to run, + // which is what we simulate here. + var newSetTimeoutUsed = undefined; + _emberMetalRun_loop.default.backburner._platform = { + setTimeout: function () { + var wait = arguments[arguments.length - 1]; + newSetTimeoutUsed = true; + ok(!isNaN(wait) && wait >= 0, 'wait is a non-negative number'); + + return originalPlatform.setTimeout.apply(originalPlatform, arguments); + } + }; + + var count = 0; + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(function () { + count++; + + // This will get run first. Waste some time. + // This is intended to break invokeLaterTimers code by taking a + // long enough time that other timers should technically expire. It's + // fine that they're not called in this run loop; just need to + // make sure that invokeLaterTimers doesn't end up scheduling + // a negative setTimeout. + pauseUntil(+new Date() + 60); + }, 1); + + _emberMetalRun_loop.default.later(function () { + equal(count, 1, 'callbacks called in order'); + }, 50); + }); + + wait(function () { + QUnit.start(); + ok(newSetTimeoutUsed, 'stub setTimeout was used'); + }); + }); +}); +enifed('ember-metal/tests/run_loop/later_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/later_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/later_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/next_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('run.next'); + + asyncTest('should invoke immediately on next timeout', function () { + var invoked = false; + + _emberMetalRun_loop.default(function () { + return _emberMetalRun_loop.default.next(function () { + return invoked = true; + }); + }); + + equal(invoked, false, 'should not have invoked yet'); + + setTimeout(function () { + QUnit.start(); + equal(invoked, true, 'should have invoked later item'); + }, 20); + }); + + asyncTest('callback should be called from within separate loop', function () { + var firstRunLoop = undefined, + secondRunLoop = undefined; + _emberMetalRun_loop.default(function () { + firstRunLoop = _emberMetalRun_loop.default.currentRunLoop; + _emberMetalRun_loop.default.next(function () { + return secondRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }); + }); + + setTimeout(function () { + QUnit.start(); + ok(secondRunLoop, 'callback was called from within run loop'); + ok(firstRunLoop && secondRunLoop !== firstRunLoop, 'two separate run loops were invoked'); + }, 20); + }); + + asyncTest('multiple calls to run.next share coalesce callbacks into same run loop', function () { + var secondRunLoop = undefined, + thirdRunLoop = undefined; + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.next(function () { + return secondRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }); + _emberMetalRun_loop.default.next(function () { + return thirdRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }); + }); + + setTimeout(function () { + QUnit.start(); + ok(secondRunLoop && secondRunLoop === thirdRunLoop, 'callbacks coalesced into same run loop'); + }, 20); + }); +}); +enifed('ember-metal/tests/run_loop/next_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/next_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/next_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/once_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/once_test'); + + QUnit.test('calling invokeOnce more than once invokes only once', function () { + var count = 0; + _emberMetalRun_loop.default(function () { + function F() { + count++; + } + _emberMetalRun_loop.default.once(F); + _emberMetalRun_loop.default.once(F); + _emberMetalRun_loop.default.once(F); + }); + + equal(count, 1, 'should have invoked once'); + }); + + QUnit.test('should differentiate based on target', function () { + var A = { count: 0 }; + var B = { count: 0 }; + _emberMetalRun_loop.default(function () { + function F() { + this.count++; + } + _emberMetalRun_loop.default.once(A, F); + _emberMetalRun_loop.default.once(B, F); + _emberMetalRun_loop.default.once(A, F); + _emberMetalRun_loop.default.once(B, F); + }); + + equal(A.count, 1, 'should have invoked once on A'); + equal(B.count, 1, 'should have invoked once on B'); + }); + + QUnit.test('should ignore other arguments - replacing previous ones', function () { + var A = { count: 0 }; + var B = { count: 0 }; + + _emberMetalRun_loop.default(function () { + function F(amt) { + this.count += amt; + } + _emberMetalRun_loop.default.once(A, F, 10); + _emberMetalRun_loop.default.once(B, F, 20); + _emberMetalRun_loop.default.once(A, F, 30); + _emberMetalRun_loop.default.once(B, F, 40); + }); + + equal(A.count, 30, 'should have invoked once on A'); + equal(B.count, 40, 'should have invoked once on B'); + }); + + QUnit.test('should be inside of a runloop when running', function () { + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.once(function () { + return ok(!!_emberMetalRun_loop.default.currentRunLoop, 'should have a runloop'); + }); + }); + }); +}); +enifed('ember-metal/tests/run_loop/once_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/once_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/once_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/onerror_test', ['exports', 'ember-metal/run_loop', 'ember-metal/error_handler'], function (exports, _emberMetalRun_loop, _emberMetalError_handler) { + 'use strict'; + + QUnit.module('system/run_loop/onerror_test'); + + QUnit.test('With Ember.onerror undefined, errors in Ember.run are thrown', function () { + var thrown = new Error('Boom!'); + var original = _emberMetalError_handler.getOnerror(); + + var caught = undefined; + _emberMetalError_handler.setOnerror(undefined); + try { + _emberMetalRun_loop.default(function () { + throw thrown; + }); + } catch (error) { + caught = error; + } finally { + _emberMetalError_handler.setOnerror(original); + } + + deepEqual(caught, thrown); + }); + + QUnit.test('With Ember.onerror set, errors in Ember.run are caught', function () { + var thrown = new Error('Boom!'); + var original = _emberMetalError_handler.getOnerror(); + + var caught = undefined; + _emberMetalError_handler.setOnerror(function (error) { + caught = error; + }); + try { + _emberMetalRun_loop.default(function () { + throw thrown; + }); + } finally { + _emberMetalError_handler.setOnerror(original); + } + + deepEqual(caught, thrown); + }); +}); +enifed('ember-metal/tests/run_loop/onerror_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/onerror_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/onerror_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/run_bind_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/run_bind_test'); + + QUnit.test('Ember.run.bind builds a run-loop wrapped callback handler', function () { + expect(3); + + var obj = { + value: 0, + increment: function (increment) { + ok(_emberMetalRun_loop.default.currentRunLoop, 'expected a run-loop'); + return this.value += increment; + } + }; + + var proxiedFunction = _emberMetalRun_loop.default.bind(obj, obj.increment, 1); + equal(proxiedFunction(), 1); + equal(obj.value, 1); + }); + + QUnit.test('Ember.run.bind keeps the async callback arguments', function () { + expect(4); + + function asyncCallback(increment, increment2, increment3) { + ok(_emberMetalRun_loop.default.currentRunLoop, 'expected a run-loop'); + equal(increment, 1); + equal(increment2, 2); + equal(increment3, 3); + } + + function asyncFunction(fn) { + fn(2, 3); + } + + asyncFunction(_emberMetalRun_loop.default.bind(asyncCallback, asyncCallback, 1)); + }); +}); +enifed('ember-metal/tests/run_loop/run_bind_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/run_bind_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/run_bind_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/run_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/run_test'); + + QUnit.test('Ember.run invokes passed function, returning value', function () { + var obj = { + foo: function () { + return [this.bar, 'FOO']; + }, + bar: 'BAR', + checkArgs: function (arg1, arg2) { + return [arg1, this.bar, arg2]; + } + }; + + equal(_emberMetalRun_loop.default(function () { + return 'FOO'; + }), 'FOO', 'pass function only'); + deepEqual(_emberMetalRun_loop.default(obj, obj.foo), ['BAR', 'FOO'], 'pass obj and obj.method'); + deepEqual(_emberMetalRun_loop.default(obj, 'foo'), ['BAR', 'FOO'], 'pass obj and "method"'); + deepEqual(_emberMetalRun_loop.default(obj, obj.checkArgs, 'hello', 'world'), ['hello', 'BAR', 'world'], 'pass obj, obj.method, and extra arguments'); + }); +}); +enifed('ember-metal/tests/run_loop/run_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/run_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/run_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/schedule_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/schedule_test'); + + QUnit.test('scheduling item in queue should defer until finished', function () { + var cnt = 0; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + equal(cnt, 0, 'should not run action yet'); + }); + + equal(cnt, 2, 'should flush actions now'); + }); + + QUnit.test('a scheduled item can be canceled', function (assert) { + var hasRan = false; + + _emberMetalRun_loop.default(function () { + var cancelId = _emberMetalRun_loop.default.schedule('actions', function () { + return hasRan = true; + }); + _emberMetalRun_loop.default.cancel(cancelId); + }); + + assert.notOk(hasRan, 'should not have ran callback run'); + }); + + QUnit.test('nested runs should queue each phase independently', function () { + var cnt = 0; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + equal(cnt, 0, 'should not run action yet'); + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + }); + equal(cnt, 1, 'should not run action yet'); + }); + + equal(cnt, 2, 'should flush actions now'); + }); + + QUnit.test('prior queues should be flushed before moving on to next queue', function () { + var order = []; + + _emberMetalRun_loop.default(function () { + var runLoop = _emberMetalRun_loop.default.currentRunLoop; + ok(runLoop, 'run loop present'); + + _emberMetalRun_loop.default.schedule('sync', function () { + order.push('sync'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + + _emberMetalRun_loop.default.schedule('actions', function () { + order.push('actions'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + + _emberMetalRun_loop.default.schedule('actions', function () { + order.push('actions'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + + _emberMetalRun_loop.default.schedule('sync', function () { + order.push('sync'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + }); + + _emberMetalRun_loop.default.schedule('destroy', function () { + order.push('destroy'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + }); + + deepEqual(order, ['sync', 'actions', 'sync', 'actions', 'destroy']); + }); + + QUnit.test('makes sure it does not trigger an autorun during testing', function () { + expectAssertion(function () { + return _emberMetalRun_loop.default.schedule('actions', function () {}); + }, /wrap any code with asynchronous side-effects in a run/); + + // make sure not just the first violation is asserted. + expectAssertion(function () { + return _emberMetalRun_loop.default.schedule('actions', function () {}); + }, /wrap any code with asynchronous side-effects in a run/); + }); +}); +enifed('ember-metal/tests/run_loop/schedule_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/schedule_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/schedule_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/sync_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/sync_test'); + + QUnit.test('sync() will immediately flush the sync queue only', function () { + var cnt = 0; + + _emberMetalRun_loop.default(function () { + function cntup() { + cnt++; + } + + function syncfunc() { + if (++cnt < 5) { + _emberMetalRun_loop.default.schedule('sync', syncfunc); + } + _emberMetalRun_loop.default.schedule('actions', cntup); + } + + syncfunc(); + + equal(cnt, 1, 'should not run action yet'); + _emberMetalRun_loop.default.sync(); + + equal(cnt, 5, 'should have run sync queue continuously'); + }); + + equal(cnt, 10, 'should flush actions now too'); + }); + + QUnit.test('calling sync() outside a run loop does not cause an error', function () { + expect(0); + + _emberMetalRun_loop.default.sync(); + }); +}); +enifed('ember-metal/tests/run_loop/sync_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/sync_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/sync_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/unwind_test', ['exports', 'ember-metal/run_loop', 'ember-metal/error'], function (exports, _emberMetalRun_loop, _emberMetalError) { + 'use strict'; + + QUnit.module('system/run_loop/unwind_test'); + + QUnit.test('RunLoop unwinds despite unhandled exception', function () { + var initialRunLoop = _emberMetalRun_loop.default.currentRunLoop; + + throws(function () { + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + throw new _emberMetalError.default('boom!'); + }); + }); + }, Error, 'boom!'); + + // The real danger at this point is that calls to autorun will stick + // tasks into the already-dead runloop, which will never get + // flushed. I can't easily demonstrate this in a unit test because + // autorun explicitly doesn't work in test mode. - ef4 + equal(_emberMetalRun_loop.default.currentRunLoop, initialRunLoop, 'Previous run loop should be cleaned up despite exception'); + + // Prevent a failure in this test from breaking subsequent tests. + _emberMetalRun_loop.default.currentRunLoop = initialRunLoop; + }); + + QUnit.test('run unwinds despite unhandled exception', function () { + var initialRunLoop = _emberMetalRun_loop.default.currentRunLoop; + + throws(function () { + _emberMetalRun_loop.default(function () { + throw new _emberMetalError.default('boom!'); + }); + }, _emberMetalError.default, 'boom!'); + + equal(_emberMetalRun_loop.default.currentRunLoop, initialRunLoop, 'Previous run loop should be cleaned up despite exception'); + + // Prevent a failure in this test from breaking subsequent tests. + _emberMetalRun_loop.default.currentRunLoop = initialRunLoop; + }); +}); +enifed('ember-metal/tests/run_loop/unwind_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/unwind_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/unwind_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/set_properties_test', ['exports', 'ember-metal/set_properties'], function (exports, _emberMetalSet_properties) { + 'use strict'; + + QUnit.module('Ember.setProperties'); + + QUnit.test('supports setting multiple attributes at once', function () { + deepEqual(_emberMetalSet_properties.default(null, null), null, 'noop for null properties and null object'); + deepEqual(_emberMetalSet_properties.default(undefined, undefined), undefined, 'noop for undefined properties and undefined object'); + + deepEqual(_emberMetalSet_properties.default({}), undefined, 'noop for no properties'); + deepEqual(_emberMetalSet_properties.default({}, undefined), undefined, 'noop for undefined'); + deepEqual(_emberMetalSet_properties.default({}, null), null, 'noop for null'); + deepEqual(_emberMetalSet_properties.default({}, NaN), NaN, 'noop for NaN'); + deepEqual(_emberMetalSet_properties.default({}, {}), {}, 'meh'); + + deepEqual(_emberMetalSet_properties.default({}, { foo: 1 }), { foo: 1 }, 'Set a single property'); + + deepEqual(_emberMetalSet_properties.default({}, { foo: 1, bar: 1 }), { foo: 1, bar: 1 }, 'Set multiple properties'); + + deepEqual(_emberMetalSet_properties.default({ foo: 2, baz: 2 }, { foo: 1 }), { foo: 1 }, 'Set one of multiple properties'); + + deepEqual(_emberMetalSet_properties.default({ foo: 2, baz: 2 }, { bar: 2 }), { + bar: 2 + }, 'Set an additional, previously unset property'); + }); +}); +enifed('ember-metal/tests/set_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/set_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/set_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/watching/is_watching_test', ['exports', 'ember-metal/computed', 'ember-metal/property_get', 'ember-metal/properties', 'ember-metal/mixin', 'ember-metal/observer', 'ember-metal/watching'], function (exports, _emberMetalComputed, _emberMetalProperty_get, _emberMetalProperties, _emberMetalMixin, _emberMetalObserver, _emberMetalWatching) { + 'use strict'; + + QUnit.module('isWatching'); + + function testObserver(setup, teardown) { + var key = arguments.length <= 2 || arguments[2] === undefined ? 'key' : arguments[2]; + + var obj = {}; + function fn() {} + + equal(_emberMetalWatching.isWatching(obj, key), false, 'precond - isWatching is false by default'); + setup(obj, key, fn); + equal(_emberMetalWatching.isWatching(obj, key), true, 'isWatching is true when observers are added'); + teardown(obj, key, fn); + equal(_emberMetalWatching.isWatching(obj, key), false, 'isWatching is false after observers are removed'); + } + + QUnit.test('isWatching is true for regular local observers', function () { + testObserver(function (obj, key, fn) { + _emberMetalMixin.Mixin.create({ + didChange: _emberMetalMixin.observer(key, fn) + }).apply(obj); + }, function (obj, key, fn) { + return _emberMetalObserver.removeObserver(obj, key, obj, fn); + }); + }); + + QUnit.test('isWatching is true for nonlocal observers', function () { + testObserver(function (obj, key, fn) { + _emberMetalObserver.addObserver(obj, key, obj, fn); + }, function (obj, key, fn) { + return _emberMetalObserver.removeObserver(obj, key, obj, fn); + }); + }); + + QUnit.test('isWatching is true for chained observers', function () { + testObserver(function (obj, key, fn) { + _emberMetalObserver.addObserver(obj, key + '.bar', obj, fn); + }, function (obj, key, fn) { + _emberMetalObserver.removeObserver(obj, key + '.bar', obj, fn); + }); + }); + + QUnit.test('isWatching is true for computed properties', function () { + testObserver(function (obj, key, fn) { + _emberMetalProperties.defineProperty(obj, 'computed', _emberMetalComputed.computed(fn).property(key)); + _emberMetalProperty_get.get(obj, 'computed'); + }, function (obj, key, fn) { + return _emberMetalProperties.defineProperty(obj, 'computed', null); + }); + }); + + QUnit.test('isWatching is true for chained computed properties', function () { + testObserver(function (obj, key, fn) { + _emberMetalProperties.defineProperty(obj, 'computed', _emberMetalComputed.computed(fn).property(key + '.bar')); + _emberMetalProperty_get.get(obj, 'computed'); + }, function (obj, key, fn) { + return _emberMetalProperties.defineProperty(obj, 'computed', null); + }); + }); + + // can't watch length on Array - it is special... + // But you should be able to watch a length property of an object + QUnit.test('isWatching is true for \'length\' property on object', function () { + testObserver(function (obj, key, fn) { + _emberMetalProperties.defineProperty(obj, 'length', null, '26.2 miles'); + _emberMetalObserver.addObserver(obj, 'length', obj, fn); + }, function (obj, key, fn) { + return _emberMetalObserver.removeObserver(obj, 'length', obj, fn); + }, 'length'); + }); +}); +enifed('ember-metal/tests/watching/is_watching_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/watching/is_watching_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/watching/is_watching_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/watching/unwatch_test', ['exports', 'internal-test-helpers', 'ember-metal/watching', 'ember-metal/properties', 'ember-metal/events', 'ember-metal/computed', 'ember-metal/property_set'], function (exports, _internalTestHelpers, _emberMetalWatching, _emberMetalProperties, _emberMetalEvents, _emberMetalComputed, _emberMetalProperty_set) { + 'use strict'; + + var willCount = undefined, + didCount = undefined; + + QUnit.module('unwatch', { + setup: function () { + willCount = didCount = 0; + } + }); + + function addListeners(obj, keyPath) { + _emberMetalEvents.addListener(obj, keyPath + ':before', function () { + return willCount++; + }); + _emberMetalEvents.addListener(obj, keyPath + ':change', function () { + return didCount++; + }); + } + + _internalTestHelpers.testBoth('unwatching a computed property - regular get/set', function (get, set) { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return this.__foo; + }, + set: function (keyName, value) { + this.__foo = value; + return this.__foo; + } + })); + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + set(obj, 'foo', 'BAZ'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + _internalTestHelpers.testBoth('unwatching a regular property - regular get/set', function (get, set) { + var obj = { foo: 'BIFF' }; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + set(obj, 'foo', 'BAZ'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + QUnit.test('unwatching should be nested', function () { + var obj = { foo: 'BIFF' }; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + _emberMetalWatching.watch(obj, 'foo'); + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + _emberMetalProperty_set.set(obj, 'foo', 'BAZ'); + equal(willCount, 1, 'should NOT have invoked willCount'); + equal(didCount, 1, 'should NOT have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + _emberMetalProperty_set.set(obj, 'foo', 'BAZ'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + _internalTestHelpers.testBoth('unwatching "length" property on an object', function (get, set) { + var obj = { foo: 'RUN' }; + addListeners(obj, 'length'); + + // Can watch length when it is undefined + _emberMetalWatching.watch(obj, 'length'); + set(obj, 'length', '10k'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + // Should stop watching despite length now being defined (making object 'array-like') + _emberMetalWatching.unwatch(obj, 'length'); + willCount = didCount = 0; + set(obj, 'length', '5k'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + _internalTestHelpers.testBoth('unwatching should not destroy non MANDATORY_SETTER descriptor', function (get, set) { + var obj = { get foo() { + return 'RUN'; + } }; + + equal(obj.foo, 'RUN', 'obj.foo'); + _emberMetalWatching.watch(obj, 'foo'); + equal(obj.foo, 'RUN', 'obj.foo after watch'); + _emberMetalWatching.unwatch(obj, 'foo'); + equal(obj.foo, 'RUN', 'obj.foo after unwatch'); + }); +}); +enifed('ember-metal/tests/watching/unwatch_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/watching/unwatch_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/watching/unwatch_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/watching/watch_test', ['exports', 'ember-environment', 'ember-metal/meta', 'ember-metal/property_set', 'ember-metal/property_get', 'ember-metal/computed', 'ember-metal/properties', 'internal-test-helpers', 'ember-metal/events', 'ember-metal/watching'], function (exports, _emberEnvironment, _emberMetalMeta, _emberMetalProperty_set, _emberMetalProperty_get, _emberMetalComputed, _emberMetalProperties, _internalTestHelpers, _emberMetalEvents, _emberMetalWatching) { + 'use strict'; + + var willCount = undefined, + didCount = undefined, + willKeys = undefined, + didKeys = undefined, + originalLookup = undefined; + + QUnit.module('watch', { + setup: function () { + willCount = didCount = 0; + willKeys = []; + didKeys = []; + + originalLookup = _emberEnvironment.context.lookup; + _emberEnvironment.context.lookup = {}; + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + function addListeners(obj, keyPath) { + _emberMetalEvents.addListener(obj, keyPath + ':before', function () { + willCount++; + willKeys.push(keyPath); + }); + _emberMetalEvents.addListener(obj, keyPath + ':change', function () { + didCount++; + didKeys.push(keyPath); + }); + } + + _internalTestHelpers.testBoth('watching a computed property', function (get, set) { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return this.__foo; + }, + set: function (keyName, value) { + if (value !== undefined) { + this.__foo = value; + } + return this.__foo; + } + })); + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + }); + + _internalTestHelpers.testBoth('watching a regular defined property', function (get, set) { + var obj = { foo: 'baz' }; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + equal(get(obj, 'foo'), 'baz', 'should have original prop'); + + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + equal(get(obj, 'foo'), 'bar', 'should get new value'); + equal(obj.foo, 'bar', 'property should be accessible on obj'); + }); + + _internalTestHelpers.testBoth('watching a regular undefined property', function (get, set) { + var obj = {}; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + + equal('foo' in obj, false, 'precond undefined'); + + set(obj, 'foo', 'bar'); + + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + equal(get(obj, 'foo'), 'bar', 'should get new value'); + equal(obj.foo, 'bar', 'property should be accessible on obj'); + }); + + _internalTestHelpers.testBoth('watches should inherit', function (get, set) { + var obj = { foo: 'baz' }; + var objB = Object.create(obj); + + addListeners(obj, 'foo'); + _emberMetalWatching.watch(obj, 'foo'); + equal(get(obj, 'foo'), 'baz', 'should have original prop'); + + set(obj, 'foo', 'bar'); + set(objB, 'foo', 'baz'); + equal(willCount, 2, 'should have invoked willCount once only'); + equal(didCount, 2, 'should have invoked didCount once only'); + }); + + QUnit.test('watching an object THEN defining it should work also', function () { + var obj = {}; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + + _emberMetalProperties.defineProperty(obj, 'foo'); + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'bar', 'should have set'); + equal(willCount, 1, 'should have invoked willChange once'); + equal(didCount, 1, 'should have invoked didChange once'); + }); + + QUnit.test('watching a chain then defining the property', function () { + var obj = {}; + var foo = { bar: 'bar' }; + addListeners(obj, 'foo.bar'); + addListeners(foo, 'bar'); + + _emberMetalWatching.watch(obj, 'foo.bar'); + + _emberMetalProperties.defineProperty(obj, 'foo', undefined, foo); + _emberMetalProperty_set.set(foo, 'bar', 'baz'); + + deepEqual(willKeys, ['foo.bar', 'bar'], 'should have invoked willChange with bar, foo.bar'); + deepEqual(didKeys, ['foo.bar', 'bar'], 'should have invoked didChange with bar, foo.bar'); + equal(willCount, 2, 'should have invoked willChange twice'); + equal(didCount, 2, 'should have invoked didChange twice'); + }); + + QUnit.test('watching a chain then defining the nested property', function () { + var bar = {}; + var obj = { foo: bar }; + var baz = { baz: 'baz' }; + addListeners(obj, 'foo.bar.baz'); + addListeners(baz, 'baz'); + + _emberMetalWatching.watch(obj, 'foo.bar.baz'); + + _emberMetalProperties.defineProperty(bar, 'bar', undefined, baz); + _emberMetalProperty_set.set(baz, 'baz', 'BOO'); + + deepEqual(willKeys, ['foo.bar.baz', 'baz'], 'should have invoked willChange with bar, foo.bar'); + deepEqual(didKeys, ['foo.bar.baz', 'baz'], 'should have invoked didChange with bar, foo.bar'); + equal(willCount, 2, 'should have invoked willChange twice'); + equal(didCount, 2, 'should have invoked didChange twice'); + }); + + _internalTestHelpers.testBoth('watching an object value then unwatching should restore old value', function (get, set) { + var obj = { foo: { bar: { baz: { biff: 'BIFF' } } } }; + addListeners(obj, 'foo.bar.baz.biff'); + + _emberMetalWatching.watch(obj, 'foo.bar.baz.biff'); + + var foo = get(obj, 'foo'); + equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist'); + + _emberMetalWatching.unwatch(obj, 'foo.bar.baz.biff'); + equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist'); + }); + + QUnit.test('when watching another object, destroy should remove chain watchers from the other object', function () { + var objA = {}; + var objB = { foo: 'bar' }; + objA.b = objB; + addListeners(objA, 'b.foo'); + + _emberMetalWatching.watch(objA, 'b.foo'); + + var meta_objB = _emberMetalMeta.meta(objB); + var chainNode = _emberMetalMeta.meta(objA).readableChains()._chains.b._chains.foo; + + equal(meta_objB.peekWatching('foo'), 1, 'should be watching foo'); + equal(meta_objB.readableChainWatchers().has('foo', chainNode), true, 'should have chain watcher'); + + _emberMetalWatching.destroy(objA); + + equal(meta_objB.peekWatching('foo'), 0, 'should not be watching foo'); + equal(meta_objB.readableChainWatchers().has('foo', chainNode), false, 'should not have chain watcher'); + }); + + // TESTS for length property + + _internalTestHelpers.testBoth('watching "length" property on an object', function (get, set) { + var obj = { length: '26.2 miles' }; + addListeners(obj, 'length'); + + _emberMetalWatching.watch(obj, 'length'); + equal(get(obj, 'length'), '26.2 miles', 'should have original prop'); + + set(obj, 'length', '10k'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + equal(get(obj, 'length'), '10k', 'should get new value'); + equal(obj.length, '10k', 'property should be accessible on obj'); + }); + + _internalTestHelpers.testBoth('watching "length" property on an array', function (get, set) { + var arr = []; + addListeners(arr, 'length'); + + _emberMetalWatching.watch(arr, 'length'); + equal(get(arr, 'length'), 0, 'should have original prop'); + + set(arr, 'length', '10'); + equal(willCount, 1, 'should NOT have invoked willCount'); + equal(didCount, 1, 'should NOT have invoked didCount'); + + equal(get(arr, 'length'), 10, 'should get new value'); + equal(arr.length, 10, 'property should be accessible on arr'); + }); + + _internalTestHelpers.testBoth('watch + ES5 getter', function (get) { + var parent = { b: 1 }; + var child = { + get b() { + return parent.b; + } + }; + + equal(parent.b, 1, 'parent.b should be 1'); + equal(child.b, 1, 'child.b should be 1'); + equal(get(child, 'b'), 1, 'Ember.get(child, "b") should be 1'); + + _emberMetalWatching.watch(child, 'b'); + + equal(parent.b, 1, 'parent.b should be 1 (after watch)'); + equal(child.b, 1, 'child.b should be 1 (after watch)'); + + equal(get(child, 'b'), 1, 'Ember.get(child, "b") should be 1 (after watch)'); + }); + + _internalTestHelpers.testBoth('watch + Ember.set + no-descriptor', function (get, set) { + var child = {}; + + equal(child.b, undefined, 'child.b '); + equal(get(child, 'b'), undefined, 'Ember.get(child, "b")'); + + _emberMetalWatching.watch(child, 'b'); + set(child, 'b', 1); + + equal(child.b, 1, 'child.b (after watch)'); + equal(get(child, 'b'), 1, 'Ember.get(child, "b") (after watch)'); + }); +}); +enifed('ember-metal/tests/watching/watch_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/watching/watch_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/watching/watch_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/weak_map_test', ['exports', 'ember-metal/weak_map'], function (exports, _emberMetalWeak_map) { + 'use strict'; + + QUnit.module('Ember.WeakMap'); + + QUnit.test('has weakMap like qualities', function (assert) { + var map = new _emberMetalWeak_map.default(); + var map2 = new _emberMetalWeak_map.default(); + + var a = {}; + var b = {}; + var c = {}; + + assert.strictEqual(map.get(a), undefined); + assert.strictEqual(map.get(b), undefined); + assert.strictEqual(map.get(c), undefined); + + assert.strictEqual(map2.get(a), undefined); + assert.strictEqual(map2.get(b), undefined); + assert.strictEqual(map2.get(c), undefined); + + assert.strictEqual(map.set(a, 1), map, 'map.set should return itself'); + assert.strictEqual(map.get(a), 1); + assert.strictEqual(map.set(b, undefined), map); + assert.strictEqual(map.set(a, 2), map); + assert.strictEqual(map.get(a), 2); + assert.strictEqual(map.set(b, undefined), map); + + assert.strictEqual(map2.get(a), undefined); + assert.strictEqual(map2.get(b), undefined); + assert.strictEqual(map2.get(c), undefined); + + assert.strictEqual(map.set(c, 1), map); + assert.strictEqual(map.get(c), 1); + assert.strictEqual(map.get(a), 2); + assert.strictEqual(map.get(b), undefined); + + assert.strictEqual(map2.set(a, 3), map2); + assert.strictEqual(map2.set(b, 4), map2); + assert.strictEqual(map2.set(c, 5), map2); + + assert.strictEqual(map2.get(a), 3); + assert.strictEqual(map2.get(b), 4); + assert.strictEqual(map2.get(c), 5); + + assert.strictEqual(map.get(c), 1); + assert.strictEqual(map.get(a), 2); + assert.strictEqual(map.get(b), undefined); + }); + + QUnit.test('WeakMap constructor requres new', function (assert) { + var expectedError = new TypeError('Constructor WeakMap requires \'new\''); + + assert.throws(function () { + // jshint newcap: false + _emberMetalWeak_map.default(); + }, expectedError); + }); + + QUnit.test('constructing a WeakMap with an invalid iterator throws an error', function (assert) { + var expectedError = new TypeError('The weak map constructor polyfill only supports an array argument'); + + assert.throws(function () { + new _emberMetalWeak_map.default({ a: 1 }); + }, expectedError); + }); + + QUnit.test('constructing a WeakMap with a valid iterator inserts the entries', function (assert) { + var a = {}; + var b = {}; + var c = {}; + + var map = new _emberMetalWeak_map.default([[a, 1], [b, 2], [c, 3]]); + + assert.strictEqual(map.get(a), 1); + assert.strictEqual(map.get(b), 2); + assert.strictEqual(map.get(c), 3); + }); + + QUnit.test('that error is thrown when using a primitive key', function (assert) { + var expectedError = new TypeError('Invalid value used as weak map key'); + var map = new _emberMetalWeak_map.default(); + + assert.throws(function () { + return map.set('a', 1); + }, expectedError); + assert.throws(function () { + return map.set(1, 1); + }, expectedError); + assert.throws(function () { + return map.set(true, 1); + }, expectedError); + assert.throws(function () { + return map.set(null, 1); + }, expectedError); + assert.throws(function () { + return map.set(undefined, 1); + }, expectedError); + }); + + QUnit.test('that .has and .delete work as expected', function (assert) { + var map = new _emberMetalWeak_map.default(); + var a = {}; + var b = {}; + var foo = { id: 1, name: 'My file', progress: 0 }; + + assert.strictEqual(map.set(a, foo), map); + assert.strictEqual(map.get(a), foo); + assert.strictEqual(map.has(a), true); + assert.strictEqual(map.has(b), false); + assert.strictEqual(map.delete(a), true); + assert.strictEqual(map.has(a), false); + assert.strictEqual(map.delete(a), false); + assert.strictEqual(map.set(a, undefined), map); + assert.strictEqual(map.has(a), true); + assert.strictEqual(map.delete(a), true); + assert.strictEqual(map.delete(a), false); + assert.strictEqual(map.has(a), false); + }); + + QUnit.test('that .toString works as expected', function (assert) { + var map = new _emberMetalWeak_map.default(); + + assert.strictEqual(map.toString(), '[object WeakMap]'); + }); +}); +enifed('ember-metal/tests/weak_map_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/weak_map_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/weak_map_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/transaction.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/transaction.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/transaction.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/watch_key.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/watch_key.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/watch_key.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/watch_path.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/watch_path.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/watch_path.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/watching.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/watching.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/watching.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/weak_map.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/weak_map.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/weak_map.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/ext/controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/ext/controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/ext/controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/ext/run_loop.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/ext/run_loop.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/ext/run_loop.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/api.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/api.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/api.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/auto_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/auto_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/auto_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/hash_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/hash_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/hash_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/history_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/history_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/history_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/none_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/none_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/none_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/util.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/util.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/util.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/services/router.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/services/router.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/services/router.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/services/routing.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/services/routing.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/services/routing.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/cache.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/cache.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/cache.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/controller_for.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/controller_for.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/controller_for.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/dsl.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/dsl.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/dsl.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/generate_controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/generate_controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/generate_controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/query_params.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/query_params.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/query_params.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/route.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/route.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/route.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/router.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/router.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/router.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/router_state.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/router_state.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/router_state.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/ext/controller_test', ['exports', 'ember-utils', 'internal-test-helpers', 'ember-runtime'], function (exports, _emberUtils, _internalTestHelpers, _emberRuntime) { + 'use strict'; + + QUnit.module('ember-routing/ext/controller'); + + QUnit.test('transitionToRoute considers an engine\'s mountPoint', function () { + expect(4); + + var router = { + transitionTo: function (route) { + return route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var controller = _emberRuntime.Controller.create({ target: router }); + _emberUtils.setOwner(controller, engineInstance); + + strictEqual(controller.transitionToRoute('application'), 'foo.bar.application', 'properly prefixes application route'); + strictEqual(controller.transitionToRoute('posts'), 'foo.bar.posts', 'properly prefixes child routes'); + throws(function () { + return controller.transitionToRoute('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + strictEqual(controller.transitionToRoute(queryParams), queryParams, 'passes query param only transitions through'); + }); +}); +enifed('ember-routing/tests/ext/controller_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/ext/controller_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/ext/controller_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/auto_location_test', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-routing/location/auto_location', 'ember-routing/location/history_location', 'ember-routing/location/hash_location', 'ember-routing/location/none_location', 'internal-test-helpers'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRoutingLocationAuto_location, _emberRoutingLocationHistory_location, _emberRoutingLocationHash_location, _emberRoutingLocationNone_location, _internalTestHelpers) { + 'use strict'; + + function mockBrowserLocation(overrides) { + return _emberUtils.assign({ + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function () { + ok(false, 'location.replace should not be called during testing'); + } + }, overrides); + } + + function mockBrowserHistory(overrides) { + return _emberUtils.assign({ + pushState: function () { + ok(false, 'history.pushState should not be called during testing'); + }, + replaceState: function () { + ok(false, 'history.replaceState should not be called during testing'); + } + }, overrides); + } + + function createLocation(location, history) { + var _AutoLocation$create; + + var owner = _internalTestHelpers.buildOwner(); + + owner.register('location:history', _emberRoutingLocationHistory_location.default); + owner.register('location:hash', _emberRoutingLocationHash_location.default); + owner.register('location:none', _emberRoutingLocationNone_location.default); + + var autolocation = _emberRoutingLocationAuto_location.default.create((_AutoLocation$create = {}, _AutoLocation$create[_emberUtils.OWNER] = owner, _AutoLocation$create.location = location, _AutoLocation$create.history = history, _AutoLocation$create.global = {}, _AutoLocation$create)); + + return autolocation; + } + + var location = undefined; + + QUnit.module('Ember.AutoLocation', { + teardown: function () { + if (location) { + _emberMetal.run(location, 'destroy'); + } + } + }); + + QUnit.test('AutoLocation should have the `global`', function (assert) { + var location = _emberRoutingLocationAuto_location.default.create(); + + assert.ok(location.global, 'has a global defined'); + assert.strictEqual(location.global, _emberEnvironment.environment.window, 'has the environments window global'); + }); + + QUnit.test('AutoLocation should return concrete implementation\'s value for `getURL`', function () { + expect(1); + + var browserLocation = mockBrowserLocation(); + var browserHistory = mockBrowserHistory(); + + location = createLocation(browserLocation, browserHistory); + location.detect(); + + var concreteImplementation = _emberMetal.get(location, 'concreteImplementation'); + + concreteImplementation.getURL = function () { + return '/lincoln/park'; + }; + + equal(location.getURL(), '/lincoln/park'); + }); + + QUnit.test('AutoLocation should use a HistoryLocation instance when pushStates is supported', function () { + expect(1); + + var browserLocation = mockBrowserLocation(); + var browserHistory = mockBrowserHistory(); + + location = createLocation(browserLocation, browserHistory); + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationHistory_location.default); + }); + + QUnit.test('AutoLocation should use a HashLocation instance when pushStates are not supported, but hashchange events are and the URL is already in the HashLocation format', function () { + expect(1); + + var browserLocation = mockBrowserLocation({ + hash: '#/testd' + }); + + location = createLocation(browserLocation); + location.global = { + onhashchange: function () {} + }; + + location.detect(); + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationHash_location.default); + }); + + QUnit.test('AutoLocation should use a NoneLocation instance when neither history nor hashchange are supported.', function () { + expect(1); + + location = createLocation(mockBrowserLocation()); + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationNone_location.default); + }); + + QUnit.test('AutoLocation should use an index path (i.e. \'/\') without any location.hash as OK for HashLocation', function () { + expect(1); + + var browserLocation = mockBrowserLocation({ + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function (path) { + ok(false, 'location.replace should not be called'); + } + }); + + location = createLocation(browserLocation); + location.global = { + onhashchange: function () {} + }; + + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationHash_location.default, 'uses a HashLocation'); + }); + + QUnit.test('AutoLocation should transform the URL for hashchange-only browsers viewing a HistoryLocation-formatted path', function () { + expect(3); + + var browserLocation = mockBrowserLocation({ + hash: '', + hostname: 'test.com', + href: 'http://test.com/test', + pathname: '/test', + protocol: 'http:', + port: '', + search: '', + + replace: function (path) { + equal(path, 'http://test.com/#/test', 'location.replace should be called with normalized HashLocation path'); + } + }); + + var location = createLocation(browserLocation); + location.global = { + onhashchange: function () {} + }; + + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationNone_location.default, 'NoneLocation should be used while we attempt to location.replace()'); + equal(_emberMetal.get(location, 'cancelRouterSetup'), true, 'cancelRouterSetup should be set so the router knows.'); + }); + + QUnit.test('AutoLocation should replace the URL for pushState-supported browsers viewing a HashLocation-formatted url', function () { + expect(2); + + var browserLocation = mockBrowserLocation({ + hash: '#/test', + hostname: 'test.com', + href: 'http://test.com/#/test', + pathname: '/', + protocol: 'http:', + port: '', + search: '' + }); + + var browserHistory = mockBrowserHistory({ + replaceState: function (state, title, path) { + equal(path, '/test', 'history.replaceState should be called with normalized HistoryLocation url'); + } + }); + + var location = createLocation(browserLocation, browserHistory); + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation'), _emberRoutingLocationHistory_location.default); + }); + + QUnit.test('AutoLocation requires any rootURL given to end in a trailing forward slash', function () { + expect(3); + var browserLocation = mockBrowserLocation(); + var expectedMsg = /rootURL must end with a trailing forward slash e.g. "\/app\/"/; + + location = createLocation(browserLocation); + location.rootURL = 'app'; + + expectAssertion(function () { + location.detect(); + }, expectedMsg); + + location.rootURL = '/app'; + expectAssertion(function () { + location.detect(); + }, expectedMsg); + + // Note the trailing whitespace + location.rootURL = '/app/ '; + expectAssertion(function () { + location.detect(); + }, expectedMsg); + }); + + QUnit.test('AutoLocation provides its rootURL to the concreteImplementation', function () { + expect(1); + var browserLocation = mockBrowserLocation({ + pathname: '/some/subdir/derp' + }); + var browserHistory = mockBrowserHistory(); + + location = createLocation(browserLocation, browserHistory); + location.rootURL = '/some/subdir/'; + + location.detect(); + + var concreteLocation = _emberMetal.get(location, 'concreteImplementation'); + equal(location.rootURL, concreteLocation.rootURL); + }); + + QUnit.test('getHistoryPath() should return a normalized, HistoryLocation-supported path', function () { + expect(3); + + var browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/about?foo=bar#foo', + pathname: '/app/about', + search: '?foo=bar', + hash: '#foo' + }); + + equal(_emberRoutingLocationAuto_location.getHistoryPath('/app/', browserLocation), '/app/about?foo=bar#foo', 'URLs already in HistoryLocation form should come out the same'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#/about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#/about?foo=bar#foo' + }); + equal(_emberRoutingLocationAuto_location.getHistoryPath('/app/', browserLocation), '/app/about?foo=bar#foo', 'HashLocation formed URLs should be normalized'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#about?foo=bar#foo' + }); + equal(_emberRoutingLocationAuto_location.getHistoryPath('/app', browserLocation), '/app/#about?foo=bar#foo', 'URLs with a hash not following #/ convention shouldn\'t be normalized as a route'); + }); + + QUnit.test('getHashPath() should return a normalized, HashLocation-supported path', function () { + expect(3); + + var browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#/about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#/about?foo=bar#foo' + }); + equal(_emberRoutingLocationAuto_location.getHashPath('/app/', browserLocation), '/app/#/about?foo=bar#foo', 'URLs already in HistoryLocation form should come out the same'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/about?foo=bar#foo', + pathname: '/app/about', + search: '?foo=bar', + hash: '#foo' + }); + equal(_emberRoutingLocationAuto_location.getHashPath('/app/', browserLocation), '/app/#/about?foo=bar#foo', 'HistoryLocation formed URLs should be normalized'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#about?foo=bar#foo' + }); + + equal(_emberRoutingLocationAuto_location.getHashPath('/app/', browserLocation), '/app/#/#about?foo=bar#foo', 'URLs with a hash not following #/ convention shouldn\'t be normalized as a route'); + }); +}); +enifed('ember-routing/tests/location/auto_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/auto_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/auto_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/hash_location_test', ['exports', 'ember-metal', 'ember-routing/location/hash_location'], function (exports, _emberMetal, _emberRoutingLocationHash_location) { + 'use strict'; + + var HashTestLocation = undefined, + location = undefined; + + function createLocation(options) { + if (!options) { + options = {}; + } + location = HashTestLocation.create(options); + } + + function mockBrowserLocation(path) { + // This is a neat trick to auto-magically extract the hostname from any + // url by letting the browser do the work ;) + var tmp = document.createElement('a'); + tmp.href = path; + + var protocol = !tmp.protocol || tmp.protocol === ':' ? 'http' : tmp.protocol; + var pathname = tmp.pathname.match(/^\//) ? tmp.pathname : '/' + tmp.pathname; + + return { + hash: tmp.hash, + host: tmp.host || 'localhost', + hostname: tmp.hostname || 'localhost', + href: tmp.href, + pathname: pathname, + port: tmp.port || '', + protocol: protocol, + search: tmp.search + }; + } + + function triggerHashchange() { + var event = document.createEvent('HTMLEvents'); + event.initEvent('hashchange', true, false); + window.dispatchEvent(event); + } + + QUnit.module('Ember.HashLocation', { + setup: function () { + HashTestLocation = _emberRoutingLocationHash_location.default.extend({ + _location: { + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function () { + ok(false, 'location.replace should not be called during testing'); + } + } + }); + }, + + teardown: function () { + _emberMetal.run(function () { + if (location) { + location.destroy(); + } + }); + } + }); + + QUnit.test('HashLocation.getURL() returns the current url', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#/foo/bar') + }); + + equal(location.getURL(), '/foo/bar'); + }); + + QUnit.test('HashLocation.getURL() includes extra hashes', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#/foo#bar#car') + }); + + equal(location.getURL(), '/foo#bar#car'); + }); + + QUnit.test('HashLocation.getURL() assumes location.hash without #/ prefix is not a route path', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#foo#bar') + }); + + equal(location.getURL(), '/#foo#bar'); + }); + + QUnit.test('HashLocation.getURL() returns a normal forward slash when there is no location.hash', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/') + }); + + equal(location.getURL(), '/'); + }); + + QUnit.test('HashLocation.setURL() correctly sets the url', function () { + expect(2); + + createLocation(); + + location.setURL('/bar'); + + equal(_emberMetal.get(location, 'location.hash'), '/bar'); + equal(_emberMetal.get(location, 'lastSetURL'), '/bar'); + }); + + QUnit.test('HashLocation.replaceURL() correctly replaces to the path with a page reload', function () { + expect(2); + + createLocation({ + _location: { + replace: function (path) { + equal(path, '#/foo'); + } + } + }); + + location.replaceURL('/foo'); + + equal(_emberMetal.get(location, 'lastSetURL'), '/foo'); + }); + + QUnit.test('HashLocation.onUpdateURL callback executes as expected', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#/foo/bar') + }); + + var callback = function (param) { + equal(param, '/foo/bar', 'path is passed as param'); + }; + + location.onUpdateURL(callback); + + triggerHashchange(); + }); + + QUnit.test('HashLocation.onUpdateURL doesn\'t execute callback if lastSetURL === path', function () { + expect(0); + + createLocation({ + _location: { + href: '/#/foo/bar' + }, + lastSetURL: '/foo/bar' + }); + + var callback = function (param) { + ok(false, 'callback should not be called'); + }; + + location.onUpdateURL(callback); + + triggerHashchange(); + }); + + QUnit.test('HashLocation.formatURL() prepends a # to the provided string', function () { + expect(1); + + createLocation(); + + equal(location.formatURL('/foo#bar'), '#/foo#bar'); + }); + + QUnit.test('HashLocation.willDestroy() cleans up hashchange event listener', function () { + expect(1); + + createLocation(); + + var callback = function (param) { + ok(true, 'should invoke callback once'); + }; + + location.onUpdateURL(callback); + + triggerHashchange(); + + _emberMetal.run(location, 'destroy'); + location = null; + + triggerHashchange(); + }); +}); +enifed('ember-routing/tests/location/hash_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/hash_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/hash_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/history_location_test', ['exports', 'ember-metal', 'ember-routing/location/history_location'], function (exports, _emberMetal, _emberRoutingLocationHistory_location) { + 'use strict'; + + var FakeHistory = undefined, + HistoryTestLocation = undefined, + location = undefined; + + function createLocation(options) { + if (!options) { + options = {}; + } + location = HistoryTestLocation.create(options); + } + + function mockBrowserLocation(path) { + // This is a neat trick to auto-magically extract the hostname from any + // url by letting the browser do the work ;) + var tmp = document.createElement('a'); + tmp.href = path; + + var protocol = !tmp.protocol || tmp.protocol === ':' ? 'http' : tmp.protocol; + var pathname = tmp.pathname.match(/^\//) ? tmp.pathname : '/' + tmp.pathname; + + return { + hash: tmp.hash, + host: tmp.host || 'localhost', + hostname: tmp.hostname || 'localhost', + href: tmp.href, + pathname: pathname, + port: tmp.port || '', + protocol: protocol, + search: tmp.search + }; + } + + QUnit.module('Ember.HistoryLocation', { + setup: function () { + FakeHistory = { + state: null, + _states: [], + replaceState: function (state, title, url) { + this.state = state; + this._states[0] = state; + }, + pushState: function (state, title, url) { + this.state = state; + this._states.unshift(state); + } + }; + + HistoryTestLocation = _emberRoutingLocationHistory_location.default.extend({ + history: FakeHistory + }); + }, + + teardown: function () { + _emberMetal.run(function () { + if (location) { + location.destroy(); + } + }); + } + }); + + QUnit.test('HistoryLocation initState does not get fired on init', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + ok(true, 'init was called'); + this._super.apply(this, arguments); + }, + initState: function () { + ok(false, 'initState() should not be called automatically'); + } + }); + + createLocation(); + }); + + QUnit.test('webkit doesn\'t fire popstate on page load', function () { + expect(1); + + HistoryTestLocation.reopen({ + initState: function () { + this._super.apply(this, arguments); + // these two should be equal to be able + // to successfully detect webkit initial popstate + equal(this._previousURL, this.getURL()); + } + }); + + createLocation(); + location.initState(); + }); + + QUnit.test('base URL is removed when retrieving the current pathname', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'baseURL', '/base/'); + }, + + initState: function () { + this._super.apply(this, arguments); + + equal(this.getURL(), '/foo/bar'); + } + }); + + createLocation(); + location.initState(); + }); + + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + QUnit.test('base URL is preserved when moving around', function () { + expect(2); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'baseURL', '/base/'); + } + }); + + createLocation(); + location.initState(); + location.setURL('/one/two'); + + equal(location._historyState.path, '/base/one/two'); + ok(location._historyState.uuid); + }); + + QUnit.test('setURL continues to set even with a null state (iframes may set this)', function () { + expect(2); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.setURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + ok(location._historyState.uuid); + }); + + QUnit.test('replaceURL continues to set even with a null state (iframes may set this)', function () { + expect(2); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.replaceURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + ok(location._historyState.uuid); + }); + } else { + QUnit.test('base URL is preserved when moving around', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'baseURL', '/base/'); + } + }); + + createLocation(); + location.initState(); + location.setURL('/one/two'); + + equal(location._historyState.path, '/base/one/two'); + }); + + QUnit.test('setURL continues to set even with a null state (iframes may set this)', function () { + expect(1); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.setURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + }); + + QUnit.test('replaceURL continues to set even with a null state (iframes may set this)', function () { + expect(1); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.replaceURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + }); + } + + QUnit.test('HistoryLocation.getURL() returns the current url, excluding both rootURL and baseURL', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'rootURL', '/app/'); + _emberMetal.set(this, 'baseURL', '/base/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar'); + }); + + QUnit.test('HistoryLocation.getURL() returns the current url, does not remove rootURL if its not at start of url', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar/baz')); + _emberMetal.set(this, 'rootURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar/baz'); + }); + + QUnit.test('HistoryLocation.getURL() will not remove the rootURL when only a partial match', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/bars/baz')); + _emberMetal.set(this, 'rootURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bars/baz'); + }); + + QUnit.test('HistoryLocation.getURL() returns the current url, does not remove baseURL if its not at start of url', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar/baz')); + _emberMetal.set(this, 'baseURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar/baz'); + }); + + QUnit.test('HistoryLocation.getURL() will not remove the baseURL when only a partial match', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/bars/baz')); + _emberMetal.set(this, 'baseURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bars/baz'); + }); + + QUnit.test('HistoryLocation.getURL() includes location.search', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin')); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar?time=morphin'); + }); + + QUnit.test('HistoryLocation.getURL() includes location.hash', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar#pink-power-ranger')); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar#pink-power-ranger'); + }); + + QUnit.test('HistoryLocation.getURL() includes location.hash and location.search', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin#pink-power-ranger')); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar?time=morphin#pink-power-ranger'); + }); +}); +enifed('ember-routing/tests/location/history_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/history_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/history_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/none_location_test', ['exports', 'ember-metal', 'ember-routing/location/none_location'], function (exports, _emberMetal, _emberRoutingLocationNone_location) { + 'use strict'; + + var NoneTestLocation = undefined, + location = undefined; + + function createLocation(options) { + if (!options) { + options = {}; + } + location = NoneTestLocation.create(options); + } + + QUnit.module('Ember.NoneLocation', { + setup: function () { + NoneTestLocation = _emberRoutingLocationNone_location.default.extend({}); + }, + + teardown: function () { + _emberMetal.run(function () { + if (location) { + location.destroy(); + } + }); + } + }); + + QUnit.test('NoneLocation.formatURL() returns the current url always appending rootURL', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/en/'); + } + }); + + createLocation(); + + equal(location.formatURL('/foo/bar'), '/en/foo/bar'); + }); + + QUnit.test('NoneLocation.getURL() returns the current path minus rootURL', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/foo/'); + _emberMetal.set(this, 'path', '/foo/bar'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bar'); + }); + + QUnit.test('NoneLocation.getURL() will remove the rootURL only from the beginning of a url', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/bar/'); + _emberMetal.set(this, 'path', '/foo/bar/baz'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar/baz'); + }); + + QUnit.test('NoneLocation.getURL() will not remove the rootURL when only a partial match', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/bar/'); + _emberMetal.set(this, 'path', '/bars/baz'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bars/baz'); + }); +}); +enifed('ember-routing/tests/location/none_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/none_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/none_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/util_test', ['exports', 'ember-utils', 'ember-routing/location/util'], function (exports, _emberUtils, _emberRoutingLocationUtil) { + 'use strict'; + + function mockBrowserLocation(overrides) { + return _emberUtils.assign({ + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function () { + ok(false, 'location.replace should not be called during testing'); + } + }, overrides); + } + + QUnit.module('Location Utilities'); + + QUnit.test('replacePath cannot be used to redirect to a different origin', function () { + expect(1); + + var expectedURL = undefined; + + var location = { + protocol: 'http:', + hostname: 'emberjs.com', + port: '1337', + + replace: function (url) { + equal(url, expectedURL); + } + }; + + expectedURL = 'http://emberjs.com:1337//google.com'; + _emberRoutingLocationUtil.replacePath(location, '//google.com'); + }); + + QUnit.test('getPath() should normalize location.pathname, making sure it always returns a leading slash', function () { + expect(2); + + var location = mockBrowserLocation({ pathname: 'test' }); + equal(_emberRoutingLocationUtil.getPath(location), '/test', 'When there is no leading slash, one is added.'); + + location = mockBrowserLocation({ pathname: '/test' }); + equal(_emberRoutingLocationUtil.getPath(location), '/test', 'When a leading slash is already there, it isn\'t added again'); + }); + + QUnit.test('getQuery() should return location.search as-is', function () { + expect(1); + + var location = mockBrowserLocation({ search: '?foo=bar' }); + equal(_emberRoutingLocationUtil.getQuery(location), '?foo=bar'); + }); + + QUnit.test('getFullPath() should return full pathname including query and hash', function () { + expect(1); + + var location = mockBrowserLocation({ + href: 'http://test.com/about?foo=bar#foo', + pathname: '/about', + search: '?foo=bar', + hash: '#foo' + }); + + equal(_emberRoutingLocationUtil.getFullPath(location), '/about?foo=bar#foo'); + }); + + QUnit.test('Feature-Detecting onhashchange', function () { + equal(_emberRoutingLocationUtil.supportsHashChange(undefined, { onhashchange: function () {} }), true, 'When not in IE, use onhashchange existence as evidence of the feature'); + equal(_emberRoutingLocationUtil.supportsHashChange(undefined, {}), false, 'When not in IE, use onhashchange absence as evidence of the feature absence'); + equal(_emberRoutingLocationUtil.supportsHashChange(7, { onhashchange: function () {} }), false, 'When in IE7 compatibility mode, never report existence of the feature'); + equal(_emberRoutingLocationUtil.supportsHashChange(8, { onhashchange: function () {} }), true, 'When in IE8+, use onhashchange existence as evidence of the feature'); + }); + + // jscs:disable + QUnit.test("Feature-detecting the history API", function () { + equal(_emberRoutingLocationUtil.supportsHistory("", { pushState: true }), true, "returns true if not Android Gingerbread and history.pushState exists"); + equal(_emberRoutingLocationUtil.supportsHistory("", {}), false, "returns false if history.pushState doesn't exist"); + equal(_emberRoutingLocationUtil.supportsHistory("", undefined), false, "returns false if history doesn't exist"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", { pushState: true }), false, "returns false if Android 2.x stock browser (not Chrome) claiming to support pushState"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; U; Android 4.0.3; nl-nl; GT-N7000 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30", { pushState: true }), false, "returns false for Android 4.0.x stock browser (not Chrome) claiming to support pushState"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; U; Android 20.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", { pushState: true }), true, "returns true if Android version begins with 2, but is greater than 2"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19", { pushState: true }), true, "returns true for Chrome (not stock browser) on Android 4.0.x"); + + // Windows Phone UA and History API: https://github.com/Modernizr/Modernizr/issues/1471 + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Virtual) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537", { pushState: true }), true, "returns true for Windows Phone 8.1 with misleading user agent string"); + }); + // jscs:enable +}); +enifed('ember-routing/tests/location/util_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/util_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/util_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/cache_test', ['exports', 'ember-routing/system/cache'], function (exports, _emberRoutingSystemCache) { + 'use strict'; + + QUnit.module('BucketCache', { + setup: function () { + this.cache = _emberRoutingSystemCache.default.create(); + } + }); + + QUnit.test('has - returns false when bucket is not in cache', function (assert) { + assert.strictEqual(this.cache.has('foo'), false); + assert.strictEqual(this.cache.has('constructor'), false); + }); + + QUnit.test('has - returns true when bucket is in cache', function (assert) { + var token = {}; + + this.cache.stash('foo', 'bar', token); + this.cache.stash('constructor', 'bar', token); + + assert.strictEqual(this.cache.has('foo'), true); + assert.strictEqual(this.cache.has('constructor'), true); + }); + + QUnit.test('lookup - returns stashed value if key does exist in bucket', function (assert) { + var token = {}; + var defaultValue = {}; + + this.cache.stash('foo', 'bar', token); + + assert.strictEqual(this.cache.lookup('foo', 'bar', defaultValue), token); + }); + + QUnit.test('lookup - returns default value if key does not exist in bucket', function (assert) { + var token = {}; + var defaultValue = {}; + + this.cache.stash('foo', 'bar', token); + + assert.strictEqual(this.cache.lookup('foo', 'boo', defaultValue), defaultValue); + assert.strictEqual(this.cache.lookup('foo', 'constructor', defaultValue), defaultValue); + }); + + QUnit.test('lookup - returns default value if bucket does not exist', function (assert) { + var defaultValue = {}; + + assert.strictEqual(this.cache.lookup('boo', 'bar', defaultValue), defaultValue); + assert.strictEqual(this.cache.lookup('constructor', 'bar', defaultValue), defaultValue); + }); +}); +enifed('ember-routing/tests/system/cache_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/cache_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/cache_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/controller_for_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/system/controller_for', 'ember-routing/system/generate_controller', 'internal-test-helpers'], function (exports, _emberMetal, _emberRuntime, _emberRoutingSystemController_for, _emberRoutingSystemGenerate_controller, _internalTestHelpers) { + 'use strict'; + + function buildInstance(namespace) { + var owner = _internalTestHelpers.buildOwner(); + + owner.__registry__.resolver = resolverFor(namespace); + owner.registerOptionsForType('view', { singleton: false }); + + owner.register('application:main', namespace, { instantiate: false }); + + owner.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); + + return owner; + } + + function resolverFor(namespace) { + return { + resolve: function (fullName) { + var nameParts = fullName.split(':'); + var type = nameParts[0]; + var name = nameParts[1]; + + if (name === 'basic') { + name = ''; + } + var className = _emberRuntime.String.classify(name) + _emberRuntime.String.classify(type); + var factory = _emberMetal.get(namespace, className); + + if (factory) { + return factory; + } + } + }; + } + + var appInstance = undefined, + appController = undefined, + namespace = undefined; + + QUnit.module('Ember.controllerFor', { + setup: function () { + namespace = _emberRuntime.Namespace.create(); + appInstance = buildInstance(namespace); + appInstance.register('controller:app', _emberRuntime.Controller.extend()); + appController = appInstance.lookup('controller:app'); + }, + teardown: function () { + _emberMetal.run(function () { + appInstance.destroy(); + namespace.destroy(); + }); + } + }); + + QUnit.test('controllerFor should lookup for registered controllers', function () { + var controller = _emberRoutingSystemController_for.default(appInstance, 'app'); + + equal(appController, controller, 'should find app controller'); + }); + + QUnit.module('Ember.generateController', { + setup: function () { + namespace = _emberRuntime.Namespace.create(); + appInstance = buildInstance(namespace); + }, + teardown: function () { + _emberMetal.run(function () { + appInstance.destroy(); + namespace.destroy(); + }); + } + }); + + QUnit.test('generateController should return Ember.Controller', function () { + var controller = _emberRoutingSystemGenerate_controller.default(appInstance, 'home'); + + ok(controller instanceof _emberRuntime.Controller, 'should return controller'); + }); + + QUnit.test('generateController should return App.Controller if provided', function () { + var controller = undefined; + namespace.Controller = _emberRuntime.Controller.extend(); + + controller = _emberRoutingSystemGenerate_controller.default(appInstance, 'home'); + + ok(controller instanceof namespace.Controller, 'should return controller'); + }); + + QUnit.test('generateController should return controller:basic if provided', function () { + var controller = undefined; + + var BasicController = _emberRuntime.Controller.extend(); + appInstance.register('controller:basic', BasicController); + + controller = _emberRoutingSystemGenerate_controller.default(appInstance, 'home'); + + if (_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + ok(controller instanceof BasicController, 'should return base class of controller'); + } else { + var doubleExtendedFactory = undefined; + ignoreDeprecation(function () { + doubleExtendedFactory = appInstance._lookupFactory('controller:basic'); + }); + ok(controller instanceof doubleExtendedFactory, 'should return double-extended controller'); + } + }); +}); +// A +enifed('ember-routing/tests/system/controller_for_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/controller_for_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/controller_for_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/dsl_test', ['exports', 'ember-utils', 'ember-routing/system/router', 'internal-test-helpers'], function (exports, _emberUtils, _emberRoutingSystemRouter, _internalTestHelpers) { + 'use strict'; + + var Router = undefined; + + function setup() { + Router = _emberRoutingSystemRouter.default.extend(); + } + + function teardown() { + Router = null; + } + + QUnit.module('Ember Router DSL', { + setup: setup, + teardown: teardown + }); + + QUnit.test('should fail when using a reserved route name', function () { + expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); + var reservedNames = ['array', 'basic', 'object', 'application']; + + expect(reservedNames.length * 2 + 1); + + reservedNames.forEach(function (reservedName) { + expectAssertion(function () { + Router = _emberRoutingSystemRouter.default.extend(); + + Router.map(function () { + this.route(reservedName); + }); + + var router = Router.create(); + router._initRouterJs(); + }, '\'' + reservedName + '\' cannot be used as a route name.'); + + expectAssertion(function () { + Router = _emberRoutingSystemRouter.default.extend(); + + Router.map(function () { + this.resource(reservedName); + }); + + var router = Router.create(); + router._initRouterJs(); + }, '\'' + reservedName + '\' cannot be used as a route name.'); + }); + }); + + QUnit.test('should reset namespace if nested with resource', function () { + expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); + + Router = Router.map(function () { + this.resource('bleep', function () { + this.resource('bloop', function () { + this.resource('blork'); + }); + }); + }); + + var router = Router.create(); + router._initRouterJs(); + + ok(router.router.recognizer.names['bleep'], 'nested resources do not contain parent name'); + ok(router.router.recognizer.names['bloop'], 'nested resources do not contain parent name'); + ok(router.router.recognizer.names['blork'], 'nested resources do not contain parent name'); + }); + + QUnit.test('should retain resource namespace if nested with routes', function () { + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.route('blork'); + }); + }); + }); + + var router = Router.create(); + router._initRouterJs(); + + ok(router.router.recognizer.names['bleep'], 'parent name was used as base of nested routes'); + ok(router.router.recognizer.names['bleep.bloop'], 'parent name was used as base of nested routes'); + ok(router.router.recognizer.names['bleep.bloop.blork'], 'parent name was used as base of nested routes'); + }); + + QUnit.test('should add loading and error routes if _isRouterMapResult is true', function () { + Router.map(function () { + this.route('blork'); + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + + router._initRouterJs(); + + ok(router.router.recognizer.names['blork'], 'main route was created'); + ok(router.router.recognizer.names['blork_loading'], 'loading route was added'); + ok(router.router.recognizer.names['blork_error'], 'error route was added'); + }); + + QUnit.test('should not add loading and error routes if _isRouterMapResult is false', function () { + Router.map(function () { + this.route('blork'); + }); + + var router = Router.create(); + router._initRouterJs(false); + + ok(router.router.recognizer.names['blork'], 'main route was created'); + ok(!router.router.recognizer.names['blork_loading'], 'loading route was not added'); + ok(!router.router.recognizer.names['blork_error'], 'error route was not added'); + }); + + QUnit.test('should reset namespace of loading and error routes for routes with resetNamespace', function () { + Router.map(function () { + this.route('blork', function () { + this.route('blorp'); + this.route('bleep', { resetNamespace: true }); + }); + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + + router._initRouterJs(); + + ok(router.router.recognizer.names['blork.blorp'], 'nested route was created'); + ok(router.router.recognizer.names['blork.blorp_loading'], 'nested loading route was added'); + ok(router.router.recognizer.names['blork.blorp_error'], 'nested error route was added'); + + ok(router.router.recognizer.names['bleep'], 'reset route was created'); + ok(router.router.recognizer.names['bleep_loading'], 'reset loading route was added'); + ok(router.router.recognizer.names['bleep_error'], 'reset error route was added'); + + ok(!router.router.recognizer.names['blork.bleep'], 'nested reset route was not created'); + ok(!router.router.recognizer.names['blork.bleep_loading'], 'nested reset loading route was not added'); + ok(!router.router.recognizer.names['blork.bleep_error'], 'nested reset error route was not added'); + }); + + QUnit.test('should throw an error when defining a route serializer outside an engine', function () { + Router.map(function () { + var _this = this; + + throws(function () { + _this.route('posts', { serialize: function () {} }); + }, /Defining a route serializer on route 'posts' outside an Engine is not allowed/); + }); + + Router.create()._initRouterJs(); + }); + + QUnit.module('Ember Router DSL with engines', { + setup: setup, + teardown: teardown + }); + + QUnit.test('should allow mounting of engines', function (assert) { + assert.expect(3); + + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.mount('chat'); + }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + assert.ok(router.router.recognizer.names['bleep'], 'parent name was used as base of nested routes'); + assert.ok(router.router.recognizer.names['bleep.bloop'], 'parent name was used as base of nested routes'); + assert.ok(router.router.recognizer.names['bleep.bloop.chat'], 'parent name was used as base of mounted engine'); + }); + + QUnit.test('should allow mounting of engines at a custom path', function (assert) { + assert.expect(1); + + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.mount('chat', { path: 'custom-chat' }); + }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + assert.deepEqual(router.router.recognizer.names['bleep.bloop.chat'].segments.slice(1, 4).map(function (s) { + return s.value; + }), ['bleep', 'bloop', 'custom-chat'], 'segments are properly associated with mounted engine'); + }); + + QUnit.test('should allow aliasing of engine names with `as`', function (assert) { + assert.expect(1); + + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.mount('chat', { as: 'blork' }); + }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + assert.deepEqual(router.router.recognizer.names['bleep.bloop.blork'].segments.slice(1, 4).map(function (s) { + return s.value; + }), ['bleep', 'bloop', 'blork'], 'segments are properly associated with mounted engine with aliased name'); + }); + + QUnit.test('should add loading and error routes to a mount if _isRouterMapResult is true', function () { + Router.map(function () { + this.mount('chat'); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + ok(router.router.recognizer.names['chat'], 'main route was created'); + ok(router.router.recognizer.names['chat_loading'], 'loading route was added'); + ok(router.router.recognizer.names['chat_error'], 'error route was added'); + }); + + QUnit.test('should add loading and error routes to a mount alias if _isRouterMapResult is true', function () { + Router.map(function () { + this.mount('chat', { as: 'shoutbox' }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + ok(router.router.recognizer.names['shoutbox'], 'main route was created'); + ok(router.router.recognizer.names['shoutbox_loading'], 'loading route was added'); + ok(router.router.recognizer.names['shoutbox_error'], 'error route was added'); + }); + + QUnit.test('should not add loading and error routes to a mount if _isRouterMapResult is false', function () { + Router.map(function () { + this.mount('chat'); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(false); + + ok(router.router.recognizer.names['chat'], 'main route was created'); + ok(!router.router.recognizer.names['chat_loading'], 'loading route was not added'); + ok(!router.router.recognizer.names['chat_error'], 'error route was not added'); + }); + + QUnit.test('should reset namespace of loading and error routes for mounts with resetNamespace', function () { + Router.map(function () { + this.route('news', function () { + this.mount('chat'); + this.mount('blog', { resetNamespace: true }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + ok(router.router.recognizer.names['news.chat'], 'nested route was created'); + ok(router.router.recognizer.names['news.chat_loading'], 'nested loading route was added'); + ok(router.router.recognizer.names['news.chat_error'], 'nested error route was added'); + + ok(router.router.recognizer.names['blog'], 'reset route was created'); + ok(router.router.recognizer.names['blog_loading'], 'reset loading route was added'); + ok(router.router.recognizer.names['blog_error'], 'reset error route was added'); + + ok(!router.router.recognizer.names['news.blog'], 'nested reset route was not created'); + ok(!router.router.recognizer.names['news.blog_loading'], 'nested reset loading route was not added'); + ok(!router.router.recognizer.names['news.blog_error'], 'nested reset error route was not added'); + }); +}); +enifed('ember-routing/tests/system/dsl_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/dsl_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/dsl_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/route_test', ['exports', 'ember-utils', 'internal-test-helpers', 'ember-runtime', 'ember-routing/system/route', 'container'], function (exports, _emberUtils, _internalTestHelpers, _emberRuntime, _emberRoutingSystemRoute, _container) { + 'use strict'; + + var route = undefined, + routeOne = undefined, + routeTwo = undefined, + lookupHash = undefined; + + function setup() { + route = _emberRoutingSystemRoute.default.create(); + } + + function teardown() { + _internalTestHelpers.runDestroy(route); + } + + QUnit.module('Ember.Route', { + setup: setup, + teardown: teardown + }); + + QUnit.test('default store utilizes the container to acquire the model factory', function () { + var _ownerOptions; + + expect(4); + + var Post = _emberRuntime.Object.extend(); + var post = {}; + + Post.reopenClass({ + find: function (id) { + return post; + } + }); + + var ownerOptions = { + ownerOptions: (_ownerOptions = { + hasRegistration: function () { + return true; + } + }, _ownerOptions[_container.FACTORY_FOR] = function (fullName) { + equal(fullName, 'model:post', 'correct factory was looked up'); + + return { + class: Post, + create: function () { + return Post.create(); + } + }; + }, _ownerOptions) + }; + + _emberUtils.setOwner(route, _internalTestHelpers.buildOwner(ownerOptions)); + + route.set('_qp', null); + + equal(route.model({ post_id: 1 }), post); + equal(route.findModel('post', 1), post, '#findModel returns the correct post'); + }); + + QUnit.test('\'store\' can be injected by data persistence frameworks', function () { + expect(8); + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + + var post = { + id: 1 + }; + + var Store = _emberRuntime.Object.extend({ + find: function (type, value) { + ok(true, 'injected model was called'); + equal(type, 'post', 'correct type was called'); + equal(value, 1, 'correct value was called'); + return post; + } + }); + + owner.register('route:index', _emberRoutingSystemRoute.default); + owner.register('store:main', Store); + + owner.inject('route', 'store', 'store:main'); + + route = owner.lookup('route:index'); + + equal(route.model({ post_id: 1 }), post, '#model returns the correct post'); + equal(route.findModel('post', 1), post, '#findModel returns the correct post'); + }); + + QUnit.test('assert if \'store.find\' method is not found', function () { + expect(1); + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + var Post = _emberRuntime.Object.extend(); + + owner.register('route:index', _emberRoutingSystemRoute.default); + owner.register('model:post', Post); + + route = owner.lookup('route:index'); + + expectAssertion(function () { + route.findModel('post', 1); + }, 'Post has no method `find`.'); + }); + + QUnit.test('asserts if model class is not found', function () { + expect(1); + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + owner.register('route:index', _emberRoutingSystemRoute.default); + + route = owner.lookup('route:index'); + + expectAssertion(function () { + route.model({ post_id: 1 }); + }, /You used the dynamic segment post_id in your route undefined, but .Post did not exist and you did not override your route\'s `model` hook./); + }); + + QUnit.test('\'store\' does not need to be injected', function () { + expect(1); + + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + + owner.register('route:index', _emberRoutingSystemRoute.default); + + route = owner.lookup('route:index'); + + ignoreAssertion(function () { + route.model({ post_id: 1 }); + }); + + ok(true, 'no error was raised'); + }); + + QUnit.test('modelFor doesn\'t require the router', function () { + expect(1); + + var owner = _internalTestHelpers.buildOwner(); + _emberUtils.setOwner(route, owner); + + var foo = { name: 'foo' }; + + var FooRoute = _emberRoutingSystemRoute.default.extend({ + currentModel: foo + }); + + owner.register('route:foo', FooRoute); + + strictEqual(route.modelFor('foo'), foo); + }); + + QUnit.test('.send just calls an action if the router is absent', function () { + expect(7); + var route = _emberRoutingSystemRoute.default.extend({ + actions: { + returnsTrue: function (foo, bar) { + equal(foo, 1); + equal(bar, 2); + equal(this, route); + return true; + }, + + returnsFalse: function () { + ok(true, 'returnsFalse was called'); + return false; + } + } + }).create(); + + equal(true, route.send('returnsTrue', 1, 2)); + equal(false, route.send('returnsFalse')); + equal(undefined, route.send('nonexistent', 1, 2, 3)); + }); + + QUnit.test('.send just calls an action if the routers internal router property is absent', function () { + expect(7); + var route = _emberRoutingSystemRoute.default.extend({ + router: {}, + actions: { + returnsTrue: function (foo, bar) { + equal(foo, 1); + equal(bar, 2); + equal(this, route); + return true; + }, + + returnsFalse: function () { + ok(true, 'returnsFalse was called'); + return false; + } + } + }).create(); + + equal(true, route.send('returnsTrue', 1, 2)); + equal(false, route.send('returnsFalse')); + equal(undefined, route.send('nonexistent', 1, 2, 3)); + }); + + QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function () { + expect(2); + + var route = _emberRoutingSystemRoute.default.extend({ + actions: { + foo: function () { + ok(true, 'called foo action'); + } + } + }).create(); + + expectDeprecation(function () { + route._actions.foo(); + }, 'Usage of `_actions` is deprecated, use `actions` instead.'); + }); + + QUnit.test('actions in both `_actions` and `actions` results in an assertion', function () { + expectAssertion(function () { + _emberRoutingSystemRoute.default.extend({ + _actions: {}, + actions: {} + }).create(); + }, 'Specifying `_actions` and `actions` in the same mixin is not supported.'); + }); + + QUnit.test('actions added via `_actions` can be used [DEPRECATED]', function () { + expect(3); + + var route = undefined; + expectDeprecation(function () { + route = _emberRoutingSystemRoute.default.extend({ + _actions: { + bar: function () { + ok(true, 'called bar action'); + } + } + }, { + actions: { + foo: function () { + ok(true, 'called foo action'); + } + } + }).create(); + }, 'Specifying actions in `_actions` is deprecated, please use `actions` instead.'); + + route.send('foo'); + route.send('bar'); + }); + + QUnit.module('Ember.Route serialize', { + setup: setup, + teardown: teardown + }); + + QUnit.test('returns the models properties if params does not include *_id', function () { + var model = { id: 2, firstName: 'Ned', lastName: 'Ryerson' }; + + deepEqual(route.serialize(model, ['firstName', 'lastName']), { firstName: 'Ned', lastName: 'Ryerson' }, 'serialized correctly'); + }); + + QUnit.test('returns model.id if params include *_id', function () { + var model = { id: 2 }; + + deepEqual(route.serialize(model, ['post_id']), { post_id: 2 }, 'serialized correctly'); + }); + + QUnit.test('returns checks for existence of model.post_id before trying model.id', function () { + var model = { post_id: 3 }; + + deepEqual(route.serialize(model, ['post_id']), { post_id: 3 }, 'serialized correctly'); + }); + + QUnit.test('returns undefined if model is not set', function () { + equal(route.serialize(undefined, ['post_id']), undefined, 'serialized correctly'); + }); + + QUnit.module('Ember.Route interaction', { + setup: function () { + var owner = { + lookup: function (fullName) { + return lookupHash[fullName]; + } + }; + + routeOne = _emberRoutingSystemRoute.default.create({ routeName: 'one' }); + routeTwo = _emberRoutingSystemRoute.default.create({ routeName: 'two' }); + + _emberUtils.setOwner(routeOne, owner); + _emberUtils.setOwner(routeTwo, owner); + + lookupHash = { + 'route:one': routeOne, + 'route:two': routeTwo + }; + }, + + teardown: function () { + _internalTestHelpers.runDestroy(routeOne); + _internalTestHelpers.runDestroy(routeTwo); + } + }); + + QUnit.test('controllerFor uses route\'s controllerName if specified', function () { + var testController = {}; + lookupHash['controller:test'] = testController; + + routeOne.controllerName = 'test'; + + equal(routeTwo.controllerFor('one'), testController); + }); + + QUnit.module('Route injected properties'); + + QUnit.test('services can be injected into routes', function () { + var owner = _internalTestHelpers.buildOwner(); + + owner.register('route:application', _emberRoutingSystemRoute.default.extend({ + authService: _emberRuntime.inject.service('auth') + })); + + owner.register('service:auth', _emberRuntime.Service.extend()); + + var appRoute = owner.lookup('route:application'); + var authService = owner.lookup('service:auth'); + + equal(authService, appRoute.get('authService'), 'service.auth is injected'); + }); + + QUnit.module('Ember.Route with engines'); + + QUnit.test('paramsFor considers an engine\'s mountPoint', function (assert) { + expect(2); + + var router = { + _deserializeQueryParams: function () {}, + router: { + state: { + handlerInfos: [{ name: 'posts' }], + params: { + 'foo.bar': { a: 'b' }, + 'foo.bar.posts': { c: 'd' } + } + } + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + + mountPoint: 'foo.bar', + + lookup: function (name) { + if (name === 'route:posts') { + return postsRoute; + } else if (name === 'route:application') { + return applicationRoute; + } + } + } + }); + + var applicationRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'application', fullRouteName: 'foo.bar' }); + var postsRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'posts', fullRouteName: 'foo.bar.posts' }); + var route = _emberRoutingSystemRoute.default.create({ router: router }); + + _emberUtils.setOwner(applicationRoute, engineInstance); + _emberUtils.setOwner(postsRoute, engineInstance); + _emberUtils.setOwner(route, engineInstance); + + assert.deepEqual(route.paramsFor('application'), { a: 'b' }, 'params match for root `application` route in engine'); + assert.deepEqual(route.paramsFor('posts'), { c: 'd' }, 'params match for `posts` route in engine'); + }); + + QUnit.test('modelFor considers an engine\'s mountPoint', function () { + expect(2); + + var applicationModel = { id: '1' }; + var postsModel = { id: '2' }; + + var router = { + router: { + activeTransition: { + resolvedModels: { + 'foo.bar': applicationModel, + 'foo.bar.posts': postsModel + } + } + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + + mountPoint: 'foo.bar', + + lookup: function (name) { + if (name === 'route:posts') { + return postsRoute; + } else if (name === 'route:application') { + return applicationRoute; + } + } + } + }); + + var applicationRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'application' }); + var postsRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'posts' }); + var route = _emberRoutingSystemRoute.default.create({ router: router }); + + _emberUtils.setOwner(applicationRoute, engineInstance); + _emberUtils.setOwner(postsRoute, engineInstance); + _emberUtils.setOwner(route, engineInstance); + + strictEqual(route.modelFor('application'), applicationModel); + strictEqual(route.modelFor('posts'), postsModel); + }); + + QUnit.test('transitionTo considers an engine\'s mountPoint', function () { + expect(4); + + var router = { + transitionTo: function (route) { + return route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var route = _emberRoutingSystemRoute.default.create({ router: router }); + _emberUtils.setOwner(route, engineInstance); + + strictEqual(route.transitionTo('application'), 'foo.bar.application', 'properly prefixes application route'); + strictEqual(route.transitionTo('posts'), 'foo.bar.posts', 'properly prefixes child routes'); + throws(function () { + return route.transitionTo('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + strictEqual(route.transitionTo(queryParams), queryParams, 'passes query param only transitions through'); + }); + + QUnit.test('intermediateTransitionTo considers an engine\'s mountPoint', function () { + expect(4); + + var lastRoute = undefined; + var router = { + intermediateTransitionTo: function (route) { + lastRoute = route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var route = _emberRoutingSystemRoute.default.create({ router: router }); + _emberUtils.setOwner(route, engineInstance); + + route.intermediateTransitionTo('application'); + strictEqual(lastRoute, 'foo.bar.application', 'properly prefixes application route'); + + route.intermediateTransitionTo('posts'); + strictEqual(lastRoute, 'foo.bar.posts', 'properly prefixes child routes'); + + throws(function () { + return route.intermediateTransitionTo('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + route.intermediateTransitionTo(queryParams); + strictEqual(lastRoute, queryParams, 'passes query param only transitions through'); + }); + + QUnit.test('replaceWith considers an engine\'s mountPoint', function () { + expect(4); + + var router = { + replaceWith: function (route) { + return route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var route = _emberRoutingSystemRoute.default.create({ router: router }); + _emberUtils.setOwner(route, engineInstance); + + strictEqual(route.replaceWith('application'), 'foo.bar.application', 'properly prefixes application route'); + strictEqual(route.replaceWith('posts'), 'foo.bar.posts', 'properly prefixes child routes'); + throws(function () { + return route.replaceWith('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + strictEqual(route.replaceWith(queryParams), queryParams, 'passes query param only transitions through'); + }); +}); +enifed('ember-routing/tests/system/route_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/route_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/route_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/router_test', ['exports', 'ember-utils', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/location/none_location', 'ember-routing/system/router', 'internal-test-helpers'], function (exports, _emberUtils, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingLocationNone_location, _emberRoutingSystemRouter, _internalTestHelpers) { + 'use strict'; + + var owner = undefined; + + function createRouter(settings) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var CustomRouter = _emberRoutingSystemRouter.default.extend(); + var router = CustomRouter.create(settings); + + if (!options.skipOwner) { + _emberUtils.setOwner(router, owner); + } + + if (!options.disableSetup) { + router.setupRouter(); + } + + return router; + } + + QUnit.module('Ember Router', { + setup: function () { + owner = _internalTestHelpers.buildOwner(); + + //register the HashLocation (the default) + owner.register('location:hash', _emberRoutingLocationHash_location.default); + owner.register('location:history', _emberRoutingLocationHistory_location.default); + owner.register('location:auto', _emberRoutingLocationAuto_location.default); + owner.register('location:none', _emberRoutingLocationNone_location.default); + }, + teardown: function () { + _internalTestHelpers.runDestroy(owner); + owner = null; + } + }); + + QUnit.test('can create a router without an owner', function () { + createRouter(null, { disableSetup: true, skipOwner: true }); + + ok(true, 'no errors were thrown when creating without a container'); + }); + + QUnit.test('should not create a router.js instance upon init', function () { + var router = createRouter(null, { disableSetup: true }); + + ok(!router.router); + }); + + QUnit.test('should not reify location until setupRouter is called', function () { + var router = createRouter(null, { disableSetup: true }); + equal(typeof router.location, 'string', 'location is specified as a string'); + + router.setupRouter(); + + equal(typeof router.location, 'object', 'location is reified into an object'); + }); + + QUnit.test('should destroy its location upon destroying the routers owner.', function () { + var router = createRouter(); + var location = router.get('location'); + + _internalTestHelpers.runDestroy(owner); + + ok(location.isDestroyed, 'location should be destroyed'); + }); + + QUnit.test('should instantiate its location with its `rootURL`', function () { + var router = createRouter({ + rootURL: '/rootdir/' + }); + var location = router.get('location'); + + equal(location.get('rootURL'), '/rootdir/'); + }); + + QUnit.test('replacePath should be called with the right path', function () { + expect(1); + + var location = owner.lookup('location:auto'); + + var browserLocation = { + href: 'http://test.com/rootdir/welcome', + origin: 'http://test.com', + pathname: '/rootdir/welcome', + hash: '', + search: '', + replace: function (url) { + equal(url, 'http://test.com/rootdir/#/welcome'); + } + }; + + location.location = browserLocation; + location.global = { onhashchange: function () {} }; + location.history = null; + + createRouter({ + location: 'auto', + rootURL: '/rootdir/' + }); + }); + + QUnit.test('Ember.Router._routePath should consume identical prefixes', function () { + createRouter(); + + expect(8); + + function routePath(s1, s2, s3) { + var handlerInfos = Array.prototype.slice.call(arguments).map(function (s) { + return { name: s }; + }); + handlerInfos.unshift({ name: 'ignored' }); + + return _emberRoutingSystemRouter.default._routePath(handlerInfos); + } + + equal(routePath('foo'), 'foo'); + equal(routePath('foo', 'bar', 'baz'), 'foo.bar.baz'); + equal(routePath('foo', 'foo.bar'), 'foo.bar'); + equal(routePath('foo', 'foo.bar', 'foo.bar.baz'), 'foo.bar.baz'); + equal(routePath('foo', 'foo.bar', 'foo.bar.baz.wow'), 'foo.bar.baz.wow'); + equal(routePath('foo', 'foo.bar.baz.wow'), 'foo.bar.baz.wow'); + equal(routePath('foo.bar', 'bar.baz.wow'), 'foo.bar.baz.wow'); + + // This makes no sense, not trying to handle it, just + // making sure it doesn't go boom. + equal(routePath('foo.bar.baz', 'foo'), 'foo.bar.baz.foo'); + }); + + QUnit.test('Router should cancel routing setup when the Location class says so via cancelRouterSetup', function () { + expect(0); + + var router = undefined; + var FakeLocation = { + cancelRouterSetup: true, + create: function () { + return this; + } + }; + + owner.register('location:fake', FakeLocation); + + router = createRouter({ + location: 'fake', + + _setupRouter: function () { + ok(false, '_setupRouter should not be called'); + } + }); + + router.startRouting(); + }); + + QUnit.test('AutoLocation should replace the url when it\'s not in the preferred format', function () { + expect(1); + + var location = owner.lookup('location:auto'); + + location.location = { + href: 'http://test.com/rootdir/welcome', + origin: 'http://test.com', + pathname: '/rootdir/welcome', + hash: '', + search: '', + replace: function (url) { + equal(url, 'http://test.com/rootdir/#/welcome'); + } + }; + location.history = null; + location.global = { + onhashchange: function () {} + }; + + createRouter({ + location: 'auto', + rootURL: '/rootdir/' + }); + }); + + QUnit.test('Router#handleURL should remove any #hashes before doing URL transition', function () { + expect(2); + + var router = createRouter({ + _doURLTransition: function (routerJsMethod, url) { + equal(routerJsMethod, 'handleURL'); + equal(url, '/foo/bar?time=morphin'); + } + }); + + router.handleURL('/foo/bar?time=morphin#pink-power-ranger'); + }); + + QUnit.test('Router#triggerEvent allows actions to bubble when returning true', function (assert) { + assert.expect(2); + + var handlerInfos = [{ + name: 'application', + handler: { + actions: { + loading: function () { + assert.ok(false, 'loading not handled by application route'); + } + } + } + }, { + name: 'about', + handler: { + actions: { + loading: function () { + assert.ok(true, 'loading handled by about route'); + return false; + } + } + } + }, { + name: 'about.me', + handler: { + actions: { + loading: function () { + assert.ok(true, 'loading handled by about.me route'); + return true; + } + } + } + }]; + + _emberRoutingSystemRouter.triggerEvent(handlerInfos, false, ['loading']); + }); + + QUnit.test('Router#triggerEvent ignores handlers that have not loaded yet', function (assert) { + assert.expect(1); + + var handlerInfos = [{ + name: 'about', + handler: { + actions: { + loading: function () { + assert.ok(true, 'loading handled by about route'); + } + } + } + }, { + name: 'about.me', + handler: undefined + }]; + + _emberRoutingSystemRouter.triggerEvent(handlerInfos, false, ['loading']); + }); +}); +enifed('ember-routing/tests/system/router_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/router_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/router_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/utils_test', ['exports', 'ember-routing/utils'], function (exports, _emberRoutingUtils) { + 'use strict'; + + QUnit.module('Routing query parameter utils - normalizeControllerQueryParams'); + + QUnit.test('converts array style into verbose object style', function (assert) { + var paramName = 'foo'; + var params = [paramName]; + var normalized = _emberRoutingUtils.normalizeControllerQueryParams(params); + + ok(normalized[paramName], 'turns the query param name into key'); + equal(normalized[paramName].as, null, 'includes a blank alias in \'as\' key'); + equal(normalized[paramName].scope, 'model', 'defaults scope to model'); + }); + + QUnit.test('converts object style [{foo: \'an_alias\'}]', function (assert) { + var paramName = 'foo'; + var params = [{ 'foo': 'an_alias' }]; + var normalized = _emberRoutingUtils.normalizeControllerQueryParams(params); + + ok(normalized[paramName], 'retains the query param name as key'); + equal(normalized[paramName].as, 'an_alias', 'includes the provided alias in \'as\' key'); + equal(normalized[paramName].scope, 'model', 'defaults scope to model'); + }); + + QUnit.test('retains maximally verbose object style [{foo: {as: \'foo\'}}]', function (assert) { + var paramName = 'foo'; + var params = [{ 'foo': { as: 'an_alias' } }]; + var normalized = _emberRoutingUtils.normalizeControllerQueryParams(params); + + ok(normalized[paramName], 'retains the query param name as key'); + equal(normalized[paramName].as, 'an_alias', 'includes the provided alias in \'as\' key'); + equal(normalized[paramName].scope, 'model', 'defaults scope to model'); + }); +}); +enifed('ember-routing/tests/utils_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/utils_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/utils_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/compare.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/compare.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/compare.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/computed/computed_macros.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/computed/computed_macros.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/computed/computed_macros.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/computed/reduce_computed_macros.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/computed/reduce_computed_macros.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/computed/reduce_computed_macros.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/controllers/controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/controllers/controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/controllers/controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/copy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/copy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/copy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/ext/function.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/ext/function.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/ext/function.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/ext/rsvp.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/ext/rsvp.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/ext/rsvp.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/ext/string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/ext/string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/ext/string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/inject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/inject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/inject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/is-equal.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/is-equal.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/is-equal.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/-proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/-proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/-proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/action_handler.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/action_handler.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/action_handler.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/comparable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/comparable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/comparable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/container_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/container_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/container_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/controller_content_model_alias_deprecation.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/controller_content_model_alias_deprecation.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/controller_content_model_alias_deprecation.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/copyable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/copyable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/copyable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/evented.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/evented.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/evented.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/freezable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/freezable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/freezable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/mutable_array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/mutable_array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/mutable_array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/mutable_enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/mutable_enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/mutable_enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/observable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/observable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/observable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/promise_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/promise_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/promise_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/registry_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/registry_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/registry_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/target_action_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/target_action_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/target_action_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/string_registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/string_registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/string_registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/application.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/array_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/array_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/array_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/core_object.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/core_object.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/core_object.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/each_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/each_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/each_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/lazy_load.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/lazy_load.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/lazy_load.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/namespace.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/namespace.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/namespace.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/native_array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/native_array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/native_array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/object.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/object.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/object.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/object_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/object_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/object_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/service.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/service.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/service.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/computed/computed_macros_test', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros', 'internal-test-helpers', 'ember-runtime/system/object', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros, _internalTestHelpers, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('CP macros'); + + _internalTestHelpers.testBoth('Ember.computed.empty', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + bestLannister: null, + lannisters: null, + + bestLannisterUnspecified: _emberRuntimeComputedComputed_macros.empty('bestLannister'), + noLannistersKnown: _emberRuntimeComputedComputed_macros.empty('lannisters') + }).create({ + lannisters: _emberRuntimeSystemNative_array.A() + }); + + equal(get(obj, 'bestLannisterUnspecified'), true, 'bestLannister initially empty'); + equal(get(obj, 'noLannistersKnown'), true, 'lannisters initially empty'); + + get(obj, 'lannisters').pushObject('Tyrion'); + set(obj, 'bestLannister', 'Tyrion'); + + equal(get(obj, 'bestLannisterUnspecified'), false, 'empty respects strings'); + equal(get(obj, 'noLannistersKnown'), false, 'empty respects array mutations'); + }); + + _internalTestHelpers.testBoth('Ember.computed.notEmpty', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + bestLannister: null, + lannisters: null, + + bestLannisterSpecified: _emberRuntimeComputedComputed_macros.notEmpty('bestLannister'), + LannistersKnown: _emberRuntimeComputedComputed_macros.notEmpty('lannisters') + }).create({ + lannisters: _emberRuntimeSystemNative_array.A() + }); + + equal(get(obj, 'bestLannisterSpecified'), false, 'bestLannister initially empty'); + equal(get(obj, 'LannistersKnown'), false, 'lannisters initially empty'); + + get(obj, 'lannisters').pushObject('Tyrion'); + set(obj, 'bestLannister', 'Tyrion'); + + equal(get(obj, 'bestLannisterSpecified'), true, 'empty respects strings'); + equal(get(obj, 'LannistersKnown'), true, 'empty respects array mutations'); + }); + + _internalTestHelpers.testBoth('computed.not', function (get, set) { + var obj = { foo: true }; + _emberMetal.defineProperty(obj, 'notFoo', _emberRuntimeComputedComputed_macros.not('foo')); + equal(get(obj, 'notFoo'), false); + + obj = { foo: { bar: true } }; + _emberMetal.defineProperty(obj, 'notFoo', _emberRuntimeComputedComputed_macros.not('foo.bar')); + equal(get(obj, 'notFoo'), false); + }); + + _internalTestHelpers.testBoth('computed.empty', function (get, set) { + var obj = { foo: [], bar: undefined, baz: null, quz: '' }; + _emberMetal.defineProperty(obj, 'fooEmpty', _emberRuntimeComputedComputed_macros.empty('foo')); + _emberMetal.defineProperty(obj, 'barEmpty', _emberRuntimeComputedComputed_macros.empty('bar')); + _emberMetal.defineProperty(obj, 'bazEmpty', _emberRuntimeComputedComputed_macros.empty('baz')); + _emberMetal.defineProperty(obj, 'quzEmpty', _emberRuntimeComputedComputed_macros.empty('quz')); + + equal(get(obj, 'fooEmpty'), true); + set(obj, 'foo', [1]); + equal(get(obj, 'fooEmpty'), false); + equal(get(obj, 'barEmpty'), true); + equal(get(obj, 'bazEmpty'), true); + equal(get(obj, 'quzEmpty'), true); + set(obj, 'quz', 'asdf'); + equal(get(obj, 'quzEmpty'), false); + }); + + _internalTestHelpers.testBoth('computed.bool', function (get, set) { + var obj = { foo: function () {}, bar: 'asdf', baz: null, quz: false }; + _emberMetal.defineProperty(obj, 'fooBool', _emberRuntimeComputedComputed_macros.bool('foo')); + _emberMetal.defineProperty(obj, 'barBool', _emberRuntimeComputedComputed_macros.bool('bar')); + _emberMetal.defineProperty(obj, 'bazBool', _emberRuntimeComputedComputed_macros.bool('baz')); + _emberMetal.defineProperty(obj, 'quzBool', _emberRuntimeComputedComputed_macros.bool('quz')); + equal(get(obj, 'fooBool'), true); + equal(get(obj, 'barBool'), true); + equal(get(obj, 'bazBool'), false); + equal(get(obj, 'quzBool'), false); + }); + + _internalTestHelpers.testBoth('computed.alias', function (get, set) { + var obj = { bar: 'asdf', baz: null, quz: false }; + _emberMetal.defineProperty(obj, 'bay', _emberMetal.computed(function (key) { + return 'apple'; + })); + + _emberMetal.defineProperty(obj, 'barAlias', _emberMetal.alias('bar')); + _emberMetal.defineProperty(obj, 'bazAlias', _emberMetal.alias('baz')); + _emberMetal.defineProperty(obj, 'quzAlias', _emberMetal.alias('quz')); + _emberMetal.defineProperty(obj, 'bayAlias', _emberMetal.alias('bay')); + + equal(get(obj, 'barAlias'), 'asdf'); + equal(get(obj, 'bazAlias'), null); + equal(get(obj, 'quzAlias'), false); + equal(get(obj, 'bayAlias'), 'apple'); + + set(obj, 'barAlias', 'newBar'); + set(obj, 'bazAlias', 'newBaz'); + set(obj, 'quzAlias', null); + + equal(get(obj, 'barAlias'), 'newBar'); + equal(get(obj, 'bazAlias'), 'newBaz'); + equal(get(obj, 'quzAlias'), null); + + equal(get(obj, 'bar'), 'newBar'); + equal(get(obj, 'baz'), 'newBaz'); + equal(get(obj, 'quz'), null); + }); + + _internalTestHelpers.testBoth('computed.alias set', function (get, set) { + var obj = {}; + var constantValue = 'always `a`'; + + _emberMetal.defineProperty(obj, 'original', _emberMetal.computed({ + get: function (key) { + return constantValue; + }, + set: function (key, value) { + return constantValue; + } + })); + _emberMetal.defineProperty(obj, 'aliased', _emberMetal.alias('original')); + + equal(get(obj, 'original'), constantValue); + equal(get(obj, 'aliased'), constantValue); + + set(obj, 'aliased', 'should not set to this value'); + + equal(get(obj, 'original'), constantValue); + equal(get(obj, 'aliased'), constantValue); + }); + + _internalTestHelpers.testBoth('computed.match', function (get, set) { + var obj = { name: 'Paul' }; + _emberMetal.defineProperty(obj, 'isPaul', _emberRuntimeComputedComputed_macros.match('name', /Paul/)); + + equal(get(obj, 'isPaul'), true, 'is Paul'); + + set(obj, 'name', 'Pierre'); + + equal(get(obj, 'isPaul'), false, 'is not Paul anymore'); + }); + + _internalTestHelpers.testBoth('computed.notEmpty', function (get, set) { + var obj = { items: [1] }; + _emberMetal.defineProperty(obj, 'hasItems', _emberRuntimeComputedComputed_macros.notEmpty('items')); + + equal(get(obj, 'hasItems'), true, 'is not empty'); + + set(obj, 'items', []); + + equal(get(obj, 'hasItems'), false, 'is empty'); + }); + + _internalTestHelpers.testBoth('computed.equal', function (get, set) { + var obj = { name: 'Paul' }; + _emberMetal.defineProperty(obj, 'isPaul', _emberRuntimeComputedComputed_macros.equal('name', 'Paul')); + + equal(get(obj, 'isPaul'), true, 'is Paul'); + + set(obj, 'name', 'Pierre'); + + equal(get(obj, 'isPaul'), false, 'is not Paul anymore'); + }); + + _internalTestHelpers.testBoth('computed.gt', function (get, set) { + var obj = { number: 2 }; + _emberMetal.defineProperty(obj, 'isGreaterThenOne', _emberRuntimeComputedComputed_macros.gt('number', 1)); + + equal(get(obj, 'isGreaterThenOne'), true, 'is gt'); + + set(obj, 'number', 1); + + equal(get(obj, 'isGreaterThenOne'), false, 'is not gt'); + + set(obj, 'number', 0); + + equal(get(obj, 'isGreaterThenOne'), false, 'is not gt'); + }); + + _internalTestHelpers.testBoth('computed.gte', function (get, set) { + var obj = { number: 2 }; + _emberMetal.defineProperty(obj, 'isGreaterOrEqualThenOne', _emberRuntimeComputedComputed_macros.gte('number', 1)); + + equal(get(obj, 'isGreaterOrEqualThenOne'), true, 'is gte'); + + set(obj, 'number', 1); + + equal(get(obj, 'isGreaterOrEqualThenOne'), true, 'is gte'); + + set(obj, 'number', 0); + + equal(get(obj, 'isGreaterOrEqualThenOne'), false, 'is not gte'); + }); + + _internalTestHelpers.testBoth('computed.lt', function (get, set) { + var obj = { number: 0 }; + _emberMetal.defineProperty(obj, 'isLesserThenOne', _emberRuntimeComputedComputed_macros.lt('number', 1)); + + equal(get(obj, 'isLesserThenOne'), true, 'is lt'); + + set(obj, 'number', 1); + + equal(get(obj, 'isLesserThenOne'), false, 'is not lt'); + + set(obj, 'number', 2); + + equal(get(obj, 'isLesserThenOne'), false, 'is not lt'); + }); + + _internalTestHelpers.testBoth('computed.lte', function (get, set) { + var obj = { number: 0 }; + _emberMetal.defineProperty(obj, 'isLesserOrEqualThenOne', _emberRuntimeComputedComputed_macros.lte('number', 1)); + + equal(get(obj, 'isLesserOrEqualThenOne'), true, 'is lte'); + + set(obj, 'number', 1); + + equal(get(obj, 'isLesserOrEqualThenOne'), true, 'is lte'); + + set(obj, 'number', 2); + + equal(get(obj, 'isLesserOrEqualThenOne'), false, 'is not lte'); + }); + + _internalTestHelpers.testBoth('computed.and two properties', function (get, set) { + var obj = { one: true, two: true }; + _emberMetal.defineProperty(obj, 'oneAndTwo', _emberRuntimeComputedComputed_macros.and('one', 'two')); + + equal(get(obj, 'oneAndTwo'), true, 'one and two'); + + set(obj, 'one', false); + + equal(get(obj, 'oneAndTwo'), false, 'one and not two'); + + set(obj, 'one', null); + set(obj, 'two', 'Yes'); + + equal(get(obj, 'oneAndTwo'), null, 'returns falsy value as in &&'); + + set(obj, 'one', true); + set(obj, 'two', 2); + + equal(get(obj, 'oneAndTwo'), 2, 'returns truthy value as in &&'); + }); + + _internalTestHelpers.testBoth('computed.and three properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.and('one', 'two', 'three')); + + equal(get(obj, 'oneTwoThree'), true, 'one and two and three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), false, 'one and not two and not three'); + + set(obj, 'one', true); + set(obj, 'two', 2); + set(obj, 'three', 3); + + equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&'); + }); + + _internalTestHelpers.testBoth('computed.and expand properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.and('{one,two,three}')); + + equal(get(obj, 'oneTwoThree'), true, 'one and two and three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), false, 'one and not two and not three'); + + set(obj, 'one', true); + set(obj, 'two', 2); + set(obj, 'three', 3); + + equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&'); + }); + + _internalTestHelpers.testBoth('computed.or two properties', function (get, set) { + var obj = { one: true, two: true }; + _emberMetal.defineProperty(obj, 'oneOrTwo', _emberRuntimeComputedComputed_macros.or('one', 'two')); + + equal(get(obj, 'oneOrTwo'), true, 'one or two'); + + set(obj, 'one', false); + + equal(get(obj, 'oneOrTwo'), true, 'one or two'); + + set(obj, 'two', false); + + equal(get(obj, 'oneOrTwo'), false, 'nor one nor two'); + + set(obj, 'two', null); + + equal(get(obj, 'oneOrTwo'), null, 'returns last falsy value as in ||'); + + set(obj, 'two', true); + + equal(get(obj, 'oneOrTwo'), true, 'one or two'); + + set(obj, 'one', 1); + + equal(get(obj, 'oneOrTwo'), 1, 'returns truthy value as in ||'); + }); + + _internalTestHelpers.testBoth('computed.or three properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.or('one', 'two', 'three')); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'two', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'three', false); + + equal(get(obj, 'oneTwoThree'), false, 'one or two or three'); + + set(obj, 'three', null); + + equal(get(obj, 'oneTwoThree'), null, 'returns last falsy value as in ||'); + + set(obj, 'two', true); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', 1); + + equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||'); + }); + + _internalTestHelpers.testBoth('computed.or expand properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.or('{one,two,three}')); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'two', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'three', false); + + equal(get(obj, 'oneTwoThree'), false, 'one or two or three'); + + set(obj, 'three', null); + + equal(get(obj, 'oneTwoThree'), null, 'returns last falsy value as in ||'); + + set(obj, 'two', true); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', 1); + + equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||'); + }); + + _internalTestHelpers.testBoth('computed.or and computed.and warn about dependent keys with spaces', function (get, set) { + var obj = { one: true, two: true }; + expectAssertion(function () { + _emberMetal.defineProperty(obj, 'oneOrTwo', _emberRuntimeComputedComputed_macros.or('one', 'two three')); + }, /Dependent keys passed to Ember\.computed\.or\(\) can't have spaces\./); + + expectAssertion(function () { + _emberMetal.defineProperty(obj, 'oneAndTwo', _emberRuntimeComputedComputed_macros.and('one', 'two three')); + }, /Dependent keys passed to Ember\.computed\.and\(\) can't have spaces\./); + }); + + _internalTestHelpers.testBoth('computed.oneWay', function (get, set) { + var obj = { + firstName: 'Teddy', + lastName: 'Zeenny' + }; + + _emberMetal.defineProperty(obj, 'nickName', _emberRuntimeComputedComputed_macros.oneWay('firstName')); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + equal(get(obj, 'nickName'), 'Teddy'); + + set(obj, 'nickName', 'TeddyBear'); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + + equal(get(obj, 'nickName'), 'TeddyBear'); + + set(obj, 'firstName', 'TEDDDDDDDDYYY'); + + equal(get(obj, 'nickName'), 'TeddyBear'); + }); + + _internalTestHelpers.testBoth('computed.readOnly', function (get, set) { + var obj = { + firstName: 'Teddy', + lastName: 'Zeenny' + }; + + _emberMetal.defineProperty(obj, 'nickName', _emberRuntimeComputedComputed_macros.readOnly('firstName')); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + equal(get(obj, 'nickName'), 'Teddy'); + + throws(function () { + set(obj, 'nickName', 'TeddyBear'); + }, / /); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + + equal(get(obj, 'nickName'), 'Teddy'); + + set(obj, 'firstName', 'TEDDDDDDDDYYY'); + + equal(get(obj, 'nickName'), 'TEDDDDDDDDYYY'); + }); + + _internalTestHelpers.testBoth('computed.deprecatingAlias', function (get, set) { + var obj = { bar: 'asdf', baz: null, quz: false }; + _emberMetal.defineProperty(obj, 'bay', _emberMetal.computed(function (key) { + return 'apple'; + })); + + _emberMetal.defineProperty(obj, 'barAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('bar')); + _emberMetal.defineProperty(obj, 'bazAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('baz')); + _emberMetal.defineProperty(obj, 'quzAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('quz')); + _emberMetal.defineProperty(obj, 'bayAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('bay')); + + expectDeprecation(function () { + equal(get(obj, 'barAlias'), 'asdf'); + }, 'Usage of `barAlias` is deprecated, use `bar` instead.'); + + expectDeprecation(function () { + equal(get(obj, 'bazAlias'), null); + }, 'Usage of `bazAlias` is deprecated, use `baz` instead.'); + + expectDeprecation(function () { + equal(get(obj, 'quzAlias'), false); + }, 'Usage of `quzAlias` is deprecated, use `quz` instead.'); + + expectDeprecation(function () { + equal(get(obj, 'bayAlias'), 'apple'); + }, 'Usage of `bayAlias` is deprecated, use `bay` instead.'); + + expectDeprecation(function () { + set(obj, 'barAlias', 'newBar'); + }, 'Usage of `barAlias` is deprecated, use `bar` instead.'); + + expectDeprecation(function () { + set(obj, 'bazAlias', 'newBaz'); + }, 'Usage of `bazAlias` is deprecated, use `baz` instead.'); + + expectDeprecation(function () { + set(obj, 'quzAlias', null); + }, 'Usage of `quzAlias` is deprecated, use `quz` instead.'); + + equal(get(obj, 'barAlias'), 'newBar'); + equal(get(obj, 'bazAlias'), 'newBaz'); + equal(get(obj, 'quzAlias'), null); + + equal(get(obj, 'bar'), 'newBar'); + equal(get(obj, 'baz'), 'newBaz'); + equal(get(obj, 'quz'), null); + }); +}); +enifed('ember-runtime/tests/computed/computed_macros_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/computed/computed_macros_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/computed/computed_macros_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/computed/reduce_computed_macros_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object', 'ember-runtime/system/object_proxy', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/utils', 'ember-runtime/system/native_array', 'ember-runtime/mixins/mutable_array'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject, _emberRuntimeSystemObject_proxy, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberRuntimeMixinsMutable_array) { + 'use strict'; + + var obj = undefined; + QUnit.module('map', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array.@each.v', function (item) { + return item.v; + }), + mappedObjects: _emberRuntimeComputedReduce_computed_macros.map('arrayObjects.@each.v', function (item) { + return { name: item.v.name }; + }) + }).create({ + arrayObjects: _emberRuntimeSystemNative_array.A([{ v: { name: 'Robert' } }, { v: { name: 'Leanna' } }]), + + array: _emberRuntimeSystemNative_array.A([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + }); + }, + + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('map is readOnly', function () { + QUnit.throws(function () { + obj.set('mapped', 1); + }, /Cannot set read-only property "mapped" on object:/); + }); + + QUnit.test('it maps simple properties', function () { + deepEqual(obj.get('mapped'), [1, 3, 2, 1]); + + obj.get('array').pushObject({ v: 5 }); + + deepEqual(obj.get('mapped'), [1, 3, 2, 1, 5]); + + _emberRuntimeMixinsMutable_array.removeAt(obj.get('array'), 3); + + deepEqual(obj.get('mapped'), [1, 3, 2, 5]); + }); + + QUnit.test('it maps simple unshifted properties', function () { + var array = _emberRuntimeSystemNative_array.A(); + + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array', function (item) { + return item.toUpperCase(); + }) + }).create({ + array: array + }); + + array.unshiftObject('c'); + array.unshiftObject('b'); + array.unshiftObject('a'); + + array.popObject(); + + deepEqual(obj.get('mapped'), ['A', 'B'], 'properties unshifted in sequence are mapped correctly'); + }); + + QUnit.test('it has the correct `this`', function () { + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array', function (item) { + equal(this, obj, 'should have correct context'); + return this.upperCase(item); + }), + upperCase: function (string) { + return string.toUpperCase(); + } + }).create({ + array: ['a', 'b', 'c'] + }); + + deepEqual(obj.get('mapped'), ['A', 'B', 'C'], 'properties unshifted in sequence are mapped correctly'); + }); + + QUnit.test('it passes the index to the callback', function () { + var array = ['a', 'b', 'c']; + + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array', function (item, index) { + return index; + }) + }).create({ + array: array + }); + + deepEqual(obj.get('mapped'), [0, 1, 2], 'index is passed to callback correctly'); + }); + + QUnit.test('it maps objects', function () { + deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Leanna' }]); + + obj.get('arrayObjects').pushObject({ + v: { name: 'Eddard' } + }); + + deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Leanna' }, { name: 'Eddard' }]); + + _emberRuntimeMixinsMutable_array.removeAt(obj.get('arrayObjects'), 1); + + deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Eddard' }]); + + _emberMetal.set(obj.get('arrayObjects')[0], 'v', { name: 'Stannis' }); + + deepEqual(obj.get('mappedObjects'), [{ name: 'Stannis' }, { name: 'Eddard' }]); + }); + + QUnit.test('it maps unshifted objects with property observers', function () { + var array = _emberRuntimeSystemNative_array.A(); + var cObj = { v: 'c' }; + + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array.@each.v', function (item) { + return _emberMetal.get(item, 'v').toUpperCase(); + }) + }).create({ + array: array + }); + + array.unshiftObject(cObj); + array.unshiftObject({ v: 'b' }); + array.unshiftObject({ v: 'a' }); + + _emberMetal.set(cObj, 'v', 'd'); + + deepEqual(array.mapBy('v'), ['a', 'b', 'd'], 'precond - unmapped array is correct'); + deepEqual(obj.get('mapped'), ['A', 'B', 'D'], 'properties unshifted in sequence are mapped correctly'); + }); + + QUnit.module('mapBy', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.mapBy('array', 'v') + }).create({ + array: _emberRuntimeSystemNative_array.A([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('mapBy is readOnly', function () { + QUnit.throws(function () { + obj.set('mapped', 1); + }, /Cannot set read-only property "mapped" on object:/); + }); + + QUnit.test('it maps properties', function () { + deepEqual(obj.get('mapped'), [1, 3, 2, 1]); + + obj.get('array').pushObject({ v: 5 }); + + deepEqual(obj.get('mapped'), [1, 3, 2, 1, 5]); + + _emberRuntimeMixinsMutable_array.removeAt(obj.get('array'), 3); + + deepEqual(obj.get('mapped'), [1, 3, 2, 5]); + }); + + QUnit.test('it is observable', function () { + var calls = 0; + + deepEqual(obj.get('mapped'), [1, 3, 2, 1]); + + _emberMetal.addObserver(obj, 'mapped.@each', function () { + return calls++; + }); + + obj.get('array').pushObject({ v: 5 }); + + equal(calls, 1, 'mapBy is observable'); + }); + + QUnit.module('filter', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item) { + return item % 2 === 0; + }) + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7, 8]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('filter is readOnly', function () { + QUnit.throws(function () { + obj.set('filtered', 1); + }, /Cannot set read-only property "filtered" on object:/); + }); + + QUnit.test('it filters according to the specified filter function', function () { + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'filter filters by the specified function'); + }); + + QUnit.test('it passes the index to the callback', function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item, index) { + return index === 1; + }) + }).create({ + array: ['a', 'b', 'c'] + }); + + deepEqual(_emberMetal.get(obj, 'filtered'), ['b'], 'index is passed to callback correctly'); + }); + + QUnit.test('it has the correct `this`', function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item, index) { + equal(this, obj); + return this.isOne(index); + }), + isOne: function (value) { + return value === 1; + } + }).create({ + array: ['a', 'b', 'c'] + }); + + deepEqual(_emberMetal.get(obj, 'filtered'), ['b'], 'index is passed to callback correctly'); + }); + + QUnit.test('it passes the array to the callback', function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item, index, array) { + return index === _emberMetal.get(array, 'length') - 2; + }) + }).create({ + array: _emberRuntimeSystemNative_array.A(['a', 'b', 'c']) + }); + + deepEqual(obj.get('filtered'), ['b'], 'array is passed to callback correctly'); + }); + + QUnit.test('it caches properly', function () { + var array = obj.get('array'); + + var filtered = obj.get('filtered'); + ok(filtered === obj.get('filtered')); + + array.addObject(11); + var newFiltered = obj.get('filtered'); + + ok(filtered !== newFiltered); + + ok(obj.get('filtered') === newFiltered); + }); + + QUnit.test('it updates as the array is modified', function () { + var array = obj.get('array'); + + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + array.addObject(11); + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'objects not passing the filter are not added'); + + array.addObject(12); + deepEqual(obj.get('filtered'), [2, 4, 6, 8, 12], 'objects passing the filter are added'); + + array.removeObject(3); + array.removeObject(4); + + deepEqual(obj.get('filtered'), [2, 6, 8, 12], 'objects removed from the dependent array are removed from the computed array'); + }); + + QUnit.test('the dependent array can be cleared one at a time', function () { + var array = _emberMetal.get(obj, 'array'); + + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + // clear 1-8 but in a random order + array.removeObject(3); + array.removeObject(1); + array.removeObject(2); + array.removeObject(4); + array.removeObject(8); + array.removeObject(6); + array.removeObject(5); + array.removeObject(7); + + deepEqual(obj.get('filtered'), [], 'filtered array cleared correctly'); + }); + + QUnit.test('the dependent array can be `clear`ed directly (#3272)', function () { + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + obj.get('array').clear(); + + deepEqual(obj.get('filtered'), [], 'filtered array cleared correctly'); + }); + + QUnit.test('it updates as the array is replaced', function () { + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + obj.set('array', [20, 21, 22, 23, 24]); + + deepEqual(obj.get('filtered'), [20, 22, 24], 'computed array is updated when array is changed'); + }); + + QUnit.module('filterBy', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + a1s: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'a', 1), + as: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'a'), + bs: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'b') + }).create({ + array: _emberRuntimeSystemNative_array.A([{ name: 'one', a: 1, b: false }, { name: 'two', a: 2, b: false }, { name: 'three', a: 1, b: true }, { name: 'four', b: true }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('filterBy is readOnly', function () { + QUnit.throws(function () { + obj.set('as', 1); + }, /Cannot set read-only property "as" on object:/); + }); + + QUnit.test('properties can be filtered by truthiness', function () { + deepEqual(obj.get('as').mapBy('name'), ['one', 'two', 'three'], 'properties can be filtered by existence'); + deepEqual(obj.get('bs').mapBy('name'), ['three', 'four'], 'booleans can be filtered'); + + _emberMetal.set(obj.get('array')[0], 'a', undefined); + _emberMetal.set(obj.get('array')[3], 'a', true); + + _emberMetal.set(obj.get('array')[0], 'b', true); + _emberMetal.set(obj.get('array')[3], 'b', false); + + deepEqual(obj.get('as').mapBy('name'), ['two', 'three', 'four'], 'arrays computed by filter property respond to property changes'); + deepEqual(obj.get('bs').mapBy('name'), ['one', 'three'], 'arrays computed by filtered property respond to property changes'); + + obj.get('array').pushObject({ name: 'five', a: 6, b: true }); + + deepEqual(obj.get('as').mapBy('name'), ['two', 'three', 'four', 'five'], 'arrays computed by filter property respond to added objects'); + deepEqual(obj.get('bs').mapBy('name'), ['one', 'three', 'five'], 'arrays computed by filtered property respond to added objects'); + + obj.get('array').popObject(); + + deepEqual(obj.get('as').mapBy('name'), ['two', 'three', 'four'], 'arrays computed by filter property respond to removed objects'); + deepEqual(obj.get('bs').mapBy('name'), ['one', 'three'], 'arrays computed by filtered property respond to removed objects'); + + obj.set('array', [{ name: 'six', a: 12, b: true }]); + + deepEqual(obj.get('as').mapBy('name'), ['six'], 'arrays computed by filter property respond to array changes'); + deepEqual(obj.get('bs').mapBy('name'), ['six'], 'arrays computed by filtered property respond to array changes'); + }); + + QUnit.test('properties can be filtered by values', function () { + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'three'], 'properties can be filtered by matching value'); + + obj.get('array').pushObject({ name: 'five', a: 1 }); + + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'three', 'five'], 'arrays computed by matching value respond to added objects'); + + obj.get('array').popObject(); + + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'three'], 'arrays computed by matching value respond to removed objects'); + + _emberMetal.set(obj.get('array')[1], 'a', 1); + _emberMetal.set(obj.get('array')[2], 'a', 2); + + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'two'], 'arrays computed by matching value respond to modified properties'); + }); + + QUnit.test('properties values can be replaced', function () { + obj = _emberRuntimeSystemObject.default.extend({ + a1s: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'a', 1), + a1bs: _emberRuntimeComputedReduce_computed_macros.filterBy('a1s', 'b') + }).create({ + array: [] + }); + + deepEqual(obj.get('a1bs').mapBy('name'), [], 'properties can be filtered by matching value'); + + _emberMetal.set(obj, 'array', [{ name: 'item1', a: 1, b: true }]); + + deepEqual(obj.get('a1bs').mapBy('name'), ['item1'], 'properties can be filtered by matching value'); + }); + + [['uniq', _emberRuntimeComputedReduce_computed_macros.uniq], ['union', _emberRuntimeComputedReduce_computed_macros.union]].forEach(function (tuple) { + var name = tuple[0]; + var macro = tuple[1]; + + QUnit.module('computed.' + name, { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + union: macro('array', 'array2', 'array3') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6]), + array2: _emberRuntimeSystemNative_array.A([4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9]), + array3: _emberRuntimeSystemNative_array.A([1, 8, 10]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test(name + ' is readOnly', function () { + QUnit.throws(function () { + obj.set('union', 1); + }, /Cannot set read-only property "union" on object:/); + }); + + QUnit.test('does not include duplicates', function () { + var array = obj.get('array'); + var array2 = obj.get('array2'); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' does not include duplicates'); + + array.pushObject(8); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' does not add existing items'); + + array.pushObject(11); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], name + ' adds new items'); + + _emberRuntimeMixinsMutable_array.removeAt(array2, 6); // remove 7 + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], name + ' does not remove items that are still in the dependent array'); + + array2.removeObject(7); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 8, 9, 10, 11], name + ' removes items when their last instance is gone'); + }); + + QUnit.test('has set-union semantics', function () { + var array = obj.get('array'); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' is initially correct'); + + array.removeObject(6); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'objects are not removed if they exist in other dependent arrays'); + + array.clear(); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 4, 5, 6, 7, 8, 9, 10], 'objects are removed when they are no longer in any dependent array'); + }); + }); + + QUnit.module('computed.uniqBy', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + list: null, + uniqueById: _emberRuntimeComputedReduce_computed_macros.uniqBy('list', 'id') + }).create({ + list: _emberRuntimeSystemNative_array.A([{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 1, value: 'one' }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('uniqBy is readOnly', function () { + QUnit.throws(function () { + obj.set('uniqueById', 1); + }, /Cannot set read-only property "uniqueById" on object:/); + }); + QUnit.test('does not include duplicates', function () { + deepEqual(obj.get('uniqueById'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }]); + }); + + QUnit.test('it does not share state among instances', function () { + var MyObject = _emberRuntimeSystemObject.default.extend({ + list: [], + uniqueByName: _emberRuntimeComputedReduce_computed_macros.uniqBy('list', 'name') + }); + var a = MyObject.create({ list: [{ name: 'bob' }, { name: 'mitch' }, { name: 'mitch' }] }); + var b = MyObject.create({ list: [{ name: 'warren' }, { name: 'mitch' }] }); + + deepEqual(a.get('uniqueByName'), [{ name: 'bob' }, { name: 'mitch' }]); + // Making sure that 'mitch' appears + deepEqual(b.get('uniqueByName'), [{ name: 'warren' }, { name: 'mitch' }]); + }); + + QUnit.test('it handles changes to the dependent array', function () { + obj.get('list').pushObject({ id: 3, value: 'three' }); + + deepEqual(obj.get('uniqueById'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 3, value: 'three' }], 'The list includes three'); + + obj.get('list').pushObject({ id: 3, value: 'three' }); + + deepEqual(obj.get('uniqueById'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 3, value: 'three' }], 'The list does not include a duplicate three'); + }); + + QUnit.test('it returns an empty array when computed on a non-array', function () { + var MyObject = _emberRuntimeSystemObject.default.extend({ + list: null, + uniq: _emberRuntimeComputedReduce_computed_macros.uniqBy('list', 'name') + }); + var a = MyObject.create({ list: 'not an array' }); + + deepEqual(a.get('uniq'), []); + }); + + QUnit.module('computed.intersect', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + intersection: _emberRuntimeComputedReduce_computed_macros.intersect('array', 'array2', 'array3') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6]), + array2: _emberRuntimeSystemNative_array.A([3, 3, 3, 4, 5]), + array3: _emberRuntimeSystemNative_array.A([3, 5, 6, 7, 8]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('intersect is readOnly', function () { + QUnit.throws(function () { + obj.set('intersection', 1); + }, /Cannot set read-only property "intersection" on object:/); + }); + + QUnit.test('it has set-intersection semantics', function () { + var array2 = obj.get('array2'); + var array3 = obj.get('array3'); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [3, 5], 'intersection is initially correct'); + + array2.shiftObject(); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [3, 5], 'objects are not removed when they are still in all dependent arrays'); + + array2.shiftObject(); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [3, 5], 'objects are not removed when they are still in all dependent arrays'); + + array2.shiftObject(); + + deepEqual(obj.get('intersection'), [5], 'objects are removed once they are gone from all dependent arrays'); + + array2.pushObject(1); + + deepEqual(obj.get('intersection'), [5], 'objects are not added as long as they are missing from any dependent array'); + + array3.pushObject(1); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [1, 5], 'objects added once they belong to all dependent arrays'); + }); + + QUnit.module('setDiff', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + diff: _emberRuntimeComputedReduce_computed_macros.setDiff('array', 'array2') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7]), + array2: _emberRuntimeSystemNative_array.A([3, 4, 5, 10]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('setDiff is readOnly', function () { + QUnit.throws(function () { + obj.set('diff', 1); + }, /Cannot set read-only property "diff" on object:/); + }); + + QUnit.test('it throws an error if given fewer or more than two dependent properties', function () { + throws(function () { + _emberRuntimeSystemObject.default.extend({ + diff: _emberRuntimeComputedReduce_computed_macros.setDiff('array') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7]), + array2: _emberRuntimeSystemNative_array.A([3, 4, 5]) + }); + }, /requires exactly two dependent arrays/, 'setDiff requires two dependent arrays'); + + throws(function () { + _emberRuntimeSystemObject.default.extend({ + diff: _emberRuntimeComputedReduce_computed_macros.setDiff('array', 'array2', 'array3') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7]), + array2: _emberRuntimeSystemNative_array.A([3, 4, 5]), + array3: _emberRuntimeSystemNative_array.A([7]) + }); + }, /requires exactly two dependent arrays/, 'setDiff requires two dependent arrays'); + }); + + QUnit.test('it has set-diff semantics', function () { + var array1 = obj.get('array'); + var array2 = obj.get('array2'); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'set-diff is initially correct'); + + array2.popObject(); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'removing objects from the remove set has no effect if the object is not in the keep set'); + + array2.shiftObject(); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 6, 7], 'removing objects from the remove set adds them if they\'re in the keep set'); + + array1.removeObject(3); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'removing objects from the keep array removes them from the computed array'); + + array1.pushObject(5); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'objects added to the keep array that are in the remove array are not added to the computed array'); + + array1.pushObject(22); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7, 22], 'objects added to the keep array not in the remove array are added to the computed array'); + }); + + function commonSortTests() { + QUnit.test('arrays are initially sorted', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'array is initially sorted'); + }); + + QUnit.test('default sort order is correct', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'array is initially sorted'); + }); + + QUnit.test('changing the dependent array updates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('items', [{ fname: 'Roose', lname: 'Bolton' }, { fname: 'Theon', lname: 'Greyjoy' }, { fname: 'Ramsey', lname: 'Bolton' }, { fname: 'Stannis', lname: 'Baratheon' }]); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Stannis', 'Ramsey', 'Roose', 'Theon'], 'changing dependent array updates sorted array'); + }); + + QUnit.test('adding to the dependent array updates the sorted array', function () { + var items = obj.get('items'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + items.pushObject({ + fname: 'Tyrion', + lname: 'Lannister' + }); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb'], 'Adding to the dependent array updates the sorted array'); + }); + + QUnit.test('removing from the dependent array updates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.get('items').popObject(); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Robb'], 'Removing from the dependent array updates the sorted array'); + }); + + QUnit.test('distinct items may be sort-equal, although their relative order will not be guaranteed', function () { + // We recreate jaime and "Cersei" here only for test stability: we want + // their guid-ordering to be deterministic + var jaimeInDisguise = { + fname: 'Cersei', + lname: 'Lannister', + age: 34 + }; + + var jaime = { + fname: 'Jaime', + lname: 'Lannister', + age: 34 + }; + + var items = obj.get('items'); + + items.replace(0, 1, jaime); + items.replace(1, 1, jaimeInDisguise); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(jaimeInDisguise, 'fname', 'Jaime'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Jaime', 'Bran', 'Robb'], 'sorted array is updated'); + + _emberMetal.set(jaimeInDisguise, 'fname', 'Cersei'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'sorted array is updated'); + }); + + QUnit.test('guid sort-order fallback with a search proxy is not confused by non-search ObjectProxys', function () { + var tyrion = { + fname: 'Tyrion', + lname: 'Lannister' + }; + + var tyrionInDisguise = _emberRuntimeSystemObject_proxy.default.create({ + fname: 'Yollo', + lname: '', + content: tyrion + }); + + var items = obj.get('items'); + + items.pushObject(tyrion); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb']); + + items.pushObject(tyrionInDisguise); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Yollo', 'Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb']); + }); + } + + QUnit.module('sort - sortProperties', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items', 'itemSorting') + }).create({ + itemSorting: _emberRuntimeSystemNative_array.A(['lname', 'fname']), + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sort is readOnly', function () { + QUnit.throws(function () { + obj.set('sortedItems', 1); + }, /Cannot set read-only property "sortedItems" on object:/); + }); + + commonSortTests(); + + QUnit.test('updating sort properties detaches observers for old sort properties', function () { + var objectToRemove = obj.get('items')[3]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['fname:desc'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei', 'Bran'], 'after updating sort properties array is updated'); + + obj.get('items').removeObject(objectToRemove); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei'], 'after removing item array is updated'); + + _emberMetal.set(objectToRemove, 'lname', 'Updated-Stark'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei'], 'after changing removed item array is not updated'); + }); + + QUnit.test('updating sort properties updates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['fname:desc'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei', 'Bran'], 'after updating sort properties array is updated'); + }); + + QUnit.test('updating sort properties invalidates the sorted array', function () { + var sortProps = obj.get('itemSorting'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + sortProps.clear(); + sortProps.pushObject('fname'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Bran', 'Cersei', 'Jaime', 'Robb'], 'after updating sort properties array is updated'); + }); + + QUnit.test('updating new sort properties invalidates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['age:desc', 'fname:asc'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Robb', 'Bran'], 'precond - array is correct after item sorting is changed'); + + _emberMetal.set(obj.get('items')[1], 'age', 29); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Cersei', 'Robb', 'Bran'], 'after updating sort properties array is updated'); + }); + + QUnit.test('sort direction defaults to ascending', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb']); + }); + + QUnit.test('sort direction defaults to ascending (with sort property change)', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['fname'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Bran', 'Cersei', 'Jaime', 'Robb'], 'sort direction defaults to ascending'); + }); + + QUnit.test('updating an item\'s sort properties updates the sorted array', function () { + var tyrionInDisguise = obj.get('items')[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(tyrionInDisguise, 'fname', 'Tyrion'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Tyrion', 'Bran', 'Robb'], 'updating an item\'s sort properties updates the sorted array'); + }); + + QUnit.test('updating several of an item\'s sort properties updated the sorted array', function () { + var sansaInDisguise = obj.get('items')[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.setProperties(sansaInDisguise, { + fname: 'Sansa', + lname: 'Stark' + }); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Bran', 'Robb', 'Sansa'], 'updating an item\'s sort properties updates the sorted array'); + }); + + QUnit.test('updating an item\'s sort properties does not error when binary search does a self compare (#3273)', function () { + var jaime = { + name: 'Jaime', + status: 1 + }; + + var cersei = { + name: 'Cersei', + status: 2 + }; + + var obj = _emberRuntimeSystemObject.default.extend({ + sortProps: ['status'], + sortedPeople: _emberRuntimeComputedReduce_computed_macros.sort('people', 'sortProps') + }).create({ + people: [jaime, cersei] + }); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'precond - array is initially sorted'); + + _emberMetal.set(cersei, 'status', 3); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'array is sorted correctly'); + + _emberMetal.set(cersei, 'status', 2); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'array is sorted correctly'); + }); + + QUnit.test('array observers do not leak', function () { + var daria = { name: 'Daria' }; + var jane = { name: 'Jane' }; + + var sisters = [jane, daria]; + + var sortProps = _emberRuntimeSystemNative_array.A(['name']); + var jaime = _emberRuntimeSystemObject.default.extend({ + sortedPeople: _emberRuntimeComputedReduce_computed_macros.sort('sisters', 'sortProps'), + sortProps: sortProps + }).create({ + sisters: sisters + }); + + jaime.get('sortedPeople'); + _emberMetal.run(jaime, 'destroy'); + + try { + sortProps.pushObject({ + name: 'Anna' + }); + ok(true); + } catch (e) { + ok(false, e); + } + }); + + QUnit.test('property paths in sort properties update the sorted array', function () { + var jaime = { + relatedObj: { status: 1, firstName: 'Jaime', lastName: 'Lannister' } + }; + + var cersei = { + relatedObj: { status: 2, firstName: 'Cersei', lastName: 'Lannister' } + }; + + var sansa = _emberRuntimeSystemObject.default.create({ + relatedObj: { status: 3, firstName: 'Sansa', lastName: 'Stark' } + }); + + var obj = _emberRuntimeSystemObject.default.extend({ + sortProps: ['relatedObj.status'], + sortedPeople: _emberRuntimeComputedReduce_computed_macros.sort('people', 'sortProps') + }).create({ + people: [jaime, cersei, sansa] + }); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'precond - array is initially sorted'); + + _emberMetal.set(cersei, 'status', 3); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'array is sorted correctly'); + + _emberMetal.set(cersei, 'status', 1); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'array is sorted correctly'); + + sansa.set('status', 1); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'array is sorted correctly'); + + obj.set('sortProps', ['relatedObj.firstName']); + + deepEqual(obj.get('sortedPeople'), [cersei, jaime, sansa], 'array is sorted correctly'); + }); + + QUnit.test('if the dependentKey is neither an array nor object, it will return an empty array', function () { + _emberMetal.set(obj, 'items', null); + ok(_emberRuntimeUtils.isArray(obj.get('sortedItems')), 'returns an empty arrays'); + + _emberMetal.set(obj, 'array', undefined); + ok(_emberRuntimeUtils.isArray(obj.get('sortedItems')), 'returns an empty arrays'); + + _emberMetal.set(obj, 'array', 'not an array'); + ok(_emberRuntimeUtils.isArray(obj.get('sortedItems')), 'returns an empty arrays'); + }); + + function sortByLnameFname(a, b) { + var lna = _emberMetal.get(a, 'lname'); + var lnb = _emberMetal.get(b, 'lname'); + + if (lna !== lnb) { + return lna > lnb ? 1 : -1; + } + + return sortByFnameAsc(a, b); + } + + function sortByFnameAsc(a, b) { + var fna = _emberMetal.get(a, 'fname'); + var fnb = _emberMetal.get(b, 'fname'); + + if (fna === fnb) { + return 0; + } + return fna > fnb ? 1 : -1; + } + + QUnit.module('sort - sort function', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items.@each.fname', sortByLnameFname) + }).create({ + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sort has correct `this`', function () { + var obj = _emberRuntimeSystemObject.default.extend({ + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items.@each.fname', function (a, b) { + equal(this, obj, 'expected the object to be `this`'); + return this.sortByLastName(a, b); + }), + sortByLastName: function (a, b) { + return sortByFnameAsc(a, b); + } + }).create({ + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + + obj.get('sortedItems'); + }); + + QUnit.test('sort (with function) is readOnly', function () { + QUnit.throws(function () { + obj.set('sortedItems', 1); + }, /Cannot set read-only property "sortedItems" on object:/); + }); + + commonSortTests(); + + QUnit.test('changing item properties specified via @each triggers a resort of the modified item', function () { + var items = _emberMetal.get(obj, 'items'); + + var tyrionInDisguise = items[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(tyrionInDisguise, 'fname', 'Tyrion'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Tyrion', 'Bran', 'Robb'], 'updating a specified property on an item resorts it'); + }); + + QUnit.test('changing item properties not specified via @each does not trigger a resort', function () { + var items = obj.get('items'); + var cersei = items[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(cersei, 'lname', 'Stark'); // plot twist! (possibly not canon) + + // The array has become unsorted. If your sort function is sensitive to + // properties, they *must* be specified as dependent item property keys or + // we'll be doing binary searches on unsorted arrays. + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'updating an unspecified property on an item does not resort it'); + }); + + QUnit.module('sort - stability', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sortProps: ['count', 'name'], + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items', 'sortProps') + }).create({ + items: [{ name: 'A', count: 1, thing: 4 }, { name: 'B', count: 1, thing: 3 }, { name: 'C', count: 1, thing: 2 }, { name: 'D', count: 1, thing: 4 }] + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sorts correctly as only one property changes', function () { + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[3], 'count', 2); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'final'); + }); + + var klass = undefined; + QUnit.module('sort - concurrency', { + setup: function () { + klass = _emberRuntimeSystemObject.default.extend({ + sortProps: ['count'], + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items', 'sortProps'), + customSortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items.@each.count', function (a, b) { + return a.count - b.count; + }) + }); + obj = klass.create({ + items: _emberRuntimeSystemNative_array.A([{ name: 'A', count: 1, thing: 4, id: 1 }, { name: 'B', count: 2, thing: 3, id: 2 }, { name: 'C', count: 3, thing: 2, id: 3 }, { name: 'D', count: 4, thing: 1, id: 4 }]) + }); + }, + + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sorts correctly after mutation to the sort properties', function () { + var sorted = obj.get('sortedItems'); + deepEqual(sorted.mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + }); + + QUnit.test('sort correctly after mutation to the sort', function () { + deepEqual(obj.get('customSortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + + deepEqual(obj.get('customSortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + }); + + QUnit.test('sort correctly on multiple instances of the same class', function () { + var obj2 = klass.create({ + items: _emberRuntimeSystemNative_array.A([{ name: 'W', count: 23, thing: 4 }, { name: 'X', count: 24, thing: 3 }, { name: 'Y', count: 25, thing: 2 }, { name: 'Z', count: 26, thing: 1 }]) + }); + + deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'X', 'Y', 'Z'], 'initial'); + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + _emberMetal.set(obj2.get('items')[1], 'count', 27); + _emberMetal.set(obj2.get('items')[2], 'count', 28); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'Z', 'X', 'Y'], 'final'); + + obj.set('sortProps', ['thing']); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['D', 'C', 'B', 'A'], 'final'); + + obj2.notifyPropertyChange('sortedItems'); // invalidate to flush, to get DK refreshed + obj2.get('sortedItems'); // flush to get updated DK + + obj2.set('items.firstObject.count', 9999); + + deepEqual(obj2.get('sortedItems').mapBy('name'), ['Z', 'X', 'Y', 'W'], 'final'); + }); + + QUnit.test('sort correctly when multiple sorts are chained on the same instance of a class', function () { + var obj2 = klass.extend({ + items: _emberMetal.computed('sibling.sortedItems.[]', function () { + return this.get('sibling.sortedItems'); + }), + asdf: _emberMetal.observer('sibling.sortedItems.[]', function () { + this.get('sibling.sortedItems'); + }) + }).create({ + sibling: obj + }); + + /* + ┌───────────┐ ┌────────────┐ + │sortedProps│ │sortedProps2│ + └───────────┘ └────────────┘ + ▲ ▲ + │ ╔═══════════╗ │ + │─ ─ ─ ─ ─ ─ ─ ▶║ CP (sort) ║◀─ ─ ─ ─ ─ ─ ─ ┤ + │ ╚═══════════╝ │ + │ │ + ┌───────────┐ ┏━━━━━━━━━━━┓ ┏━━━━━━━━━━━━┓ + │ │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ + │ items │◀── items.@each.count │◀──┃sortedItems┃◀─── items.@each.count │◀───┃sortedItems2┃ + │ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ + └───────────┘ ┗━━━━━━━━━━━┛ ┗━━━━━━━━━━━━┛ + */ + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'obj.sortedItems.name should be sorted alpha'); + deepEqual(obj2.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'obj2.sortedItems.name should be sorted alpha'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'obj.sortedItems.name should now have changed'); + deepEqual(obj2.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'obj2.sortedItems.name should still mirror sortedItems2'); + + obj.set('sortProps', ['thing']); + obj2.set('sortProps', ['id']); + + deepEqual(obj2.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'we now sort obj2 by id, so we expect a b c d'); + deepEqual(obj.get('sortedItems').mapBy('name'), ['D', 'C', 'B', 'A'], 'we now sort obj by thing'); + }); + + QUnit.module('max', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + max: _emberRuntimeComputedReduce_computed_macros.max('items') + }).create({ + items: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('max is readOnly', function () { + QUnit.throws(function () { + obj.set('max', 1); + }, /Cannot set read-only property "max" on object:/); + }); + + QUnit.test('max tracks the max number as objects are added', function () { + equal(obj.get('max'), 3, 'precond - max is initially correct'); + + var items = obj.get('items'); + + items.pushObject(5); + + equal(obj.get('max'), 5, 'max updates when a larger number is added'); + + items.pushObject(2); + + equal(obj.get('max'), 5, 'max does not update when a smaller number is added'); + }); + + QUnit.test('max recomputes when the current max is removed', function () { + equal(obj.get('max'), 3, 'precond - max is initially correct'); + + obj.get('items').removeObject(2); + + equal(obj.get('max'), 3, 'max is unchanged when a non-max item is removed'); + + obj.get('items').removeObject(3); + + equal(obj.get('max'), 1, 'max is recomputed when the current max is removed'); + }); + + QUnit.module('min', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + min: _emberRuntimeComputedReduce_computed_macros.min('items') + }).create({ + items: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('min is readOnly', function () { + QUnit.throws(function () { + obj.set('min', 1); + }, /Cannot set read-only property "min" on object:/); + }); + + QUnit.test('min tracks the min number as objects are added', function () { + equal(obj.get('min'), 1, 'precond - min is initially correct'); + + obj.get('items').pushObject(-2); + + equal(obj.get('min'), -2, 'min updates when a smaller number is added'); + + obj.get('items').pushObject(2); + + equal(obj.get('min'), -2, 'min does not update when a larger number is added'); + }); + + QUnit.test('min recomputes when the current min is removed', function () { + var items = obj.get('items'); + + equal(obj.get('min'), 1, 'precond - min is initially correct'); + + items.removeObject(2); + + equal(obj.get('min'), 1, 'min is unchanged when a non-min item is removed'); + + items.removeObject(1); + + equal(obj.get('min'), 3, 'min is recomputed when the current min is removed'); + }); + + QUnit.module('Ember.arrayComputed - mixed sugar', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + lannisters: _emberRuntimeComputedReduce_computed_macros.filterBy('items', 'lname', 'Lannister'), + lannisterSorting: _emberRuntimeSystemNative_array.A(['fname']), + sortedLannisters: _emberRuntimeComputedReduce_computed_macros.sort('lannisters', 'lannisterSorting'), + + starks: _emberRuntimeComputedReduce_computed_macros.filterBy('items', 'lname', 'Stark'), + starkAges: _emberRuntimeComputedReduce_computed_macros.mapBy('starks', 'age'), + oldestStarkAge: _emberRuntimeComputedReduce_computed_macros.max('starkAges') + }).create({ + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('filtering and sorting can be combined', function () { + var items = obj.get('items'); + + deepEqual(obj.get('sortedLannisters').mapBy('fname'), ['Cersei', 'Jaime'], 'precond - array is initially filtered and sorted'); + + items.pushObject({ fname: 'Tywin', lname: 'Lannister' }); + items.pushObject({ fname: 'Lyanna', lname: 'Stark' }); + items.pushObject({ fname: 'Gerion', lname: 'Lannister' }); + + deepEqual(obj.get('sortedLannisters').mapBy('fname'), ['Cersei', 'Gerion', 'Jaime', 'Tywin'], 'updates propagate to array'); + }); + + QUnit.test('filtering, sorting and reduce (max) can be combined', function () { + var items = obj.get('items'); + + equal(16, obj.get('oldestStarkAge'), 'precond - end of chain is initially correct'); + + items.pushObject({ fname: 'Rickon', lname: 'Stark', age: 5 }); + + equal(16, obj.get('oldestStarkAge'), 'chain is updated correctly'); + + items.pushObject({ fname: 'Eddard', lname: 'Stark', age: 35 }); + + equal(35, obj.get('oldestStarkAge'), 'chain is updated correctly'); + }); + + function todo(name, priority) { + return _emberRuntimeSystemObject.default.create({ name: name, priority: priority }); + } + + function priorityComparator(todoA, todoB) { + var pa = parseInt(_emberMetal.get(todoA, 'priority'), 10); + var pb = parseInt(_emberMetal.get(todoB, 'priority'), 10); + + return pa - pb; + } + + function evenPriorities(todo) { + var p = parseInt(_emberMetal.get(todo, 'priority'), 10); + + return p % 2 === 0; + } + + QUnit.module('Ember.arrayComputed - chains', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sorted: _emberRuntimeComputedReduce_computed_macros.sort('todos.@each.priority', priorityComparator), + filtered: _emberRuntimeComputedReduce_computed_macros.filter('sorted.@each.priority', evenPriorities) + }).create({ + todos: _emberRuntimeSystemNative_array.A([todo('E', 4), todo('D', 3), todo('C', 2), todo('B', 1), todo('A', 0)]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('it can filter and sort when both depend on the same item property', function () { + deepEqual(obj.get('todos').mapBy('name'), ['E', 'D', 'C', 'B', 'A'], 'precond - todos initially correct'); + deepEqual(obj.get('sorted').mapBy('name'), ['A', 'B', 'C', 'D', 'E'], 'precond - sorted initially correct'); + deepEqual(obj.get('filtered').mapBy('name'), ['A', 'C', 'E'], 'precond - filtered initially correct'); + + _emberMetal.set(obj.get('todos')[1], 'priority', 6); + + deepEqual(obj.get('todos').mapBy('name'), ['E', 'D', 'C', 'B', 'A'], 'precond - todos remain correct'); + deepEqual(obj.get('sorted').mapBy('name'), ['A', 'B', 'C', 'E', 'D'], 'precond - sorted updated correctly'); + deepEqual(obj.get('filtered').mapBy('name'), ['A', 'C', 'E', 'D'], 'filtered updated correctly'); + }); + + var userFnCalls = undefined; + QUnit.module('Chaining array and reduced CPs', { + setup: function () { + userFnCalls = 0; + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.mapBy('array', 'v'), + max: _emberRuntimeComputedReduce_computed_macros.max('mapped'), + maxDidChange: _emberMetal.observer('max', function () { + return userFnCalls++; + }) + }).create({ + array: _emberRuntimeSystemNative_array.A([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('it computes interdependent array computed properties', function () { + equal(obj.get('max'), 3, 'sanity - it properly computes the maximum value'); + + var calls = 0; + + _emberMetal.addObserver(obj, 'max', function () { + return calls++; + }); + + obj.get('array').pushObject({ v: 5 }); + + equal(obj.get('max'), 5, 'maximum value is updated correctly'); + equal(userFnCalls, 1, 'object defined observers fire'); + equal(calls, 1, 'runtime created observers fire'); + }); + + QUnit.module('sum', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + total: _emberRuntimeComputedReduce_computed_macros.sum('array') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + }, + + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sum is readOnly', function () { + QUnit.throws(function () { + obj.set('total', 1); + }, /Cannot set read-only property "total" on object:/); + }); + QUnit.test('sums the values in the dependentKey', function () { + equal(obj.get('total'), 6, 'sums the values'); + }); + + QUnit.test('if the dependentKey is neither an array nor object, it will return `0`', function () { + _emberMetal.set(obj, 'array', null); + equal(_emberMetal.get(obj, 'total'), 0, 'returns 0'); + + _emberMetal.set(obj, 'array', undefined); + equal(_emberMetal.get(obj, 'total'), 0, 'returns 0'); + + _emberMetal.set(obj, 'array', 'not an array'); + equal(_emberMetal.get(obj, 'total'), 0, 'returns 0'); + }); + + QUnit.test('updates when array is modified', function () { + obj.get('array').pushObject(1); + + equal(obj.get('total'), 7, 'recomputed when elements are added'); + + obj.get('array').popObject(); + + equal(obj.get('total'), 6, 'recomputes when elements are removed'); + }); + + QUnit.module('collect'); + + _internalTestHelpers.testBoth('works', function (get, set) { + var obj = { one: 'foo', two: 'bar', three: null }; + _emberMetal.defineProperty(obj, 'all', _emberRuntimeComputedReduce_computed_macros.collect('one', 'two', 'three', 'four')); + + deepEqual(get(obj, 'all'), ['foo', 'bar', null, null], 'have all of them'); + + set(obj, 'four', true); + + deepEqual(get(obj, 'all'), ['foo', 'bar', null, true], 'have all of them'); + + var a = []; + set(obj, 'one', 0); + set(obj, 'three', a); + + deepEqual(get(obj, 'all'), [0, 'bar', a, true], 'have all of them'); + }); +}); +enifed('ember-runtime/tests/computed/reduce_computed_macros_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/computed/reduce_computed_macros_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/computed/reduce_computed_macros_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/controllers/controller_test', ['exports', 'ember-runtime/controllers/controller', 'ember-runtime/system/service', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/inject', 'internal-test-helpers'], function (exports, _emberRuntimeControllersController, _emberRuntimeSystemService, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeInject, _internalTestHelpers) { + /* global EmberDev */ + + 'use strict'; + + QUnit.module('Controller event handling'); + + QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function () { + expect(2); + + var controller = _emberRuntimeControllersController.default.extend({ + actions: { + foo: function () { + ok(true, 'called foo action'); + } + } + }).create(); + + expectDeprecation(function () { + controller._actions.foo(); + }, 'Usage of `_actions` is deprecated, use `actions` instead.'); + }); + + QUnit.test('Action can be handled by a function on actions object', function () { + expect(1); + var TestController = _emberRuntimeControllersController.default.extend({ + actions: { + poke: function () { + ok(true, 'poked'); + } + } + }); + var controller = TestController.create(); + controller.send('poke'); + }); + + QUnit.test('A handled action can be bubbled to the target for continued processing', function () { + expect(2); + var TestController = _emberRuntimeControllersController.default.extend({ + actions: { + poke: function () { + ok(true, 'poked 1'); + return true; + } + } + }); + + var controller = TestController.create({ + target: _emberRuntimeControllersController.default.extend({ + actions: { + poke: function () { + ok(true, 'poked 2'); + } + } + }).create() + }); + controller.send('poke'); + }); + + QUnit.test('Action can be handled by a superclass\' actions object', function () { + expect(4); + + var SuperController = _emberRuntimeControllersController.default.extend({ + actions: { + foo: function () { + ok(true, 'foo'); + }, + bar: function (msg) { + equal(msg, 'HELLO'); + } + } + }); + + var BarControllerMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + var IndexController = SuperController.extend(BarControllerMixin, { + actions: { + baz: function () { + ok(true, 'baz'); + } + } + }); + + var controller = IndexController.create({}); + controller.send('foo'); + controller.send('bar', 'HELLO'); + controller.send('baz'); + }); + + QUnit.module('Controller deprecations'); + + QUnit.module('Controller Content -> Model Alias'); + + QUnit.test('`model` is aliased as `content`', function () { + expect(1); + var controller = _emberRuntimeControllersController.default.extend({ + model: 'foo-bar' + }).create(); + + equal(controller.get('content'), 'foo-bar', 'content is an alias of model'); + }); + + QUnit.test('`content` is moved to `model` when `model` is unset', function () { + expect(2); + var controller = undefined; + + ignoreDeprecation(function () { + controller = _emberRuntimeControllersController.default.extend({ + content: 'foo-bar' + }).create(); + }); + + equal(controller.get('model'), 'foo-bar', 'model is set properly'); + equal(controller.get('content'), 'foo-bar', 'content is set properly'); + }); + + QUnit.test('specifying `content` (without `model` specified) results in deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberRuntimeControllersController.default.extend({ + content: 'foo-bar' + }).create(); + }, 'Do not specify `content` on a Controller, use `model` instead.'); + }); + + QUnit.test('specifying `content` (with `model` specified) does not result in deprecation', function () { + expect(3); + expectNoDeprecation(); + + var controller = _emberRuntimeControllersController.default.extend({ + content: 'foo-bar', + model: 'blammo' + }).create(); + + equal(_emberMetal.get(controller, 'content'), 'foo-bar'); + equal(_emberMetal.get(controller, 'model'), 'blammo'); + }); + + QUnit.module('Controller injected properties'); + + if (!EmberDev.runningProdBuild) { + QUnit.test('defining a controller on a non-controller should fail assertion', function () { + expectAssertion(function () { + var owner = _internalTestHelpers.buildOwner(); + + var AnObject = _emberRuntimeSystemObject.default.extend({ + foo: _emberRuntimeInject.default.controller('bar') + }); + + owner.register('foo:main', AnObject); + + if (true) { + expectDeprecation(function () { + owner._lookupFactory('foo:main'); + }, /Using "_lookupFactory" is deprecated. Please use container.factoryFor instead./); + } else { + owner._lookupFactory('foo:main'); + } + }, /Defining an injected controller property on a non-controller is not allowed./); + }); + } + + QUnit.test('controllers can be injected into controllers', function () { + var owner = _internalTestHelpers.buildOwner(); + + owner.register('controller:post', _emberRuntimeControllersController.default.extend({ + postsController: _emberRuntimeInject.default.controller('posts') + })); + + owner.register('controller:posts', _emberRuntimeControllersController.default.extend()); + + var postController = owner.lookup('controller:post'); + var postsController = owner.lookup('controller:posts'); + + equal(postsController, postController.get('postsController'), 'controller.posts is injected'); + }); + + QUnit.test('services can be injected into controllers', function () { + var owner = _internalTestHelpers.buildOwner(); + + owner.register('controller:application', _emberRuntimeControllersController.default.extend({ + authService: _emberRuntimeInject.default.service('auth') + })); + + owner.register('service:auth', _emberRuntimeSystemService.default.extend()); + + var appController = owner.lookup('controller:application'); + var authService = owner.lookup('service:auth'); + + equal(authService, appController.get('authService'), 'service.auth is injected'); + }); +}); +enifed('ember-runtime/tests/controllers/controller_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/controllers/controller_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/controllers/controller_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/compare_test', ['exports', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/compare', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeCompare, _emberRuntimeMixinsComparable) { + 'use strict'; + + var data = []; + var Comp = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsComparable.default); + + Comp.reopenClass({ + compare: function (obj) { + return obj.get('val'); + } + }); + + QUnit.module('Ember.compare()', { + setup: function () { + data[0] = null; + data[1] = false; + data[2] = true; + data[3] = -12; + data[4] = 3.5; + data[5] = 'a string'; + data[6] = 'another string'; + data[7] = 'last string'; + data[8] = [1, 2]; + data[9] = [1, 2, 3]; + data[10] = [1, 3]; + data[11] = { a: 'hash' }; + data[12] = _emberRuntimeSystemObject.default.create(); + data[13] = function (a) { + return a; + }; + data[14] = new Date('2012/01/01'); + data[15] = new Date('2012/06/06'); + } + }); + + QUnit.test('ordering should work', function () { + var suspect = undefined, + comparable = undefined, + failureMessage = undefined, + suspectIndex = undefined, + comparableIndex = undefined; + + for (suspectIndex = 0; suspectIndex < data.length; suspectIndex++) { + suspect = data[suspectIndex]; + + equal(_emberRuntimeCompare.default(suspect, suspect), 0, suspectIndex + ' should equal itself'); + + for (comparableIndex = suspectIndex + 1; comparableIndex < data.length; comparableIndex++) { + comparable = data[comparableIndex]; + + failureMessage = 'data[' + suspectIndex + '] (' + _emberRuntimeUtils.typeOf(suspect) + ') should be smaller than data[' + comparableIndex + '] (' + _emberRuntimeUtils.typeOf(comparable) + ')'; + + equal(_emberRuntimeCompare.default(suspect, comparable), -1, failureMessage); + } + } + }); + + QUnit.test('comparables should return values in the range of -1, 0, 1', function () { + var negOne = Comp.create({ + val: -1 + }); + + var zero = Comp.create({ + val: 0 + }); + + var one = Comp.create({ + val: 1 + }); + + equal(_emberRuntimeCompare.default(negOne, 'a'), -1, 'First item comparable - returns -1 (not negated)'); + equal(_emberRuntimeCompare.default(zero, 'b'), 0, 'First item comparable - returns 0 (not negated)'); + equal(_emberRuntimeCompare.default(one, 'c'), 1, 'First item comparable - returns 1 (not negated)'); + + equal(_emberRuntimeCompare.default('a', negOne), 1, 'Second item comparable - returns -1 (negated)'); + equal(_emberRuntimeCompare.default('b', zero), 0, 'Second item comparable - returns 0 (negated)'); + equal(_emberRuntimeCompare.default('c', one), -1, 'Second item comparable - returns 1 (negated)'); + }); +}); +enifed('ember-runtime/tests/core/compare_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/compare_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/compare_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/copy_test', ['exports', 'ember-runtime/copy'], function (exports, _emberRuntimeCopy) { + 'use strict'; + + QUnit.module('Ember Copy Method'); + + QUnit.test('Ember.copy null', function () { + var obj = { field: null }; + + equal(_emberRuntimeCopy.default(obj, true).field, null, 'null should still be null'); + }); + + QUnit.test('Ember.copy date', function () { + var date = new Date(2014, 7, 22); + var dateCopy = _emberRuntimeCopy.default(date); + + equal(date.getTime(), dateCopy.getTime(), 'dates should be equivalent'); + }); + + QUnit.test('Ember.copy null prototype object', function () { + var obj = Object.create(null); + + obj.foo = 'bar'; + + equal(_emberRuntimeCopy.default(obj).foo, 'bar', 'bar should still be bar'); + }); + + QUnit.test('Ember.copy Array', function () { + var array = [1, null, new Date(2015, 9, 9), 'four']; + var arrayCopy = _emberRuntimeCopy.default(array); + + deepEqual(array, arrayCopy, 'array content cloned successfully in new array'); + }); +}); +enifed('ember-runtime/tests/core/copy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/copy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/copy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/isEqual_test', ['exports', 'ember-runtime/is-equal'], function (exports, _emberRuntimeIsEqual) { + 'use strict'; + + QUnit.module('isEqual'); + + QUnit.test('undefined and null', function () { + ok(_emberRuntimeIsEqual.default(undefined, undefined), 'undefined is equal to undefined'); + ok(!_emberRuntimeIsEqual.default(undefined, null), 'undefined is not equal to null'); + ok(_emberRuntimeIsEqual.default(null, null), 'null is equal to null'); + ok(!_emberRuntimeIsEqual.default(null, undefined), 'null is not equal to undefined'); + }); + + QUnit.test('strings should be equal', function () { + ok(!_emberRuntimeIsEqual.default('Hello', 'Hi'), 'different Strings are unequal'); + ok(_emberRuntimeIsEqual.default('Hello', 'Hello'), 'same Strings are equal'); + }); + + QUnit.test('numericals should be equal', function () { + ok(_emberRuntimeIsEqual.default(24, 24), 'same numbers are equal'); + ok(!_emberRuntimeIsEqual.default(24, 21), 'different numbers are inequal'); + }); + + QUnit.test('dates should be equal', function () { + ok(_emberRuntimeIsEqual.default(new Date(1985, 7, 22), new Date(1985, 7, 22)), 'same dates are equal'); + ok(!_emberRuntimeIsEqual.default(new Date(2014, 7, 22), new Date(1985, 7, 22)), 'different dates are not equal'); + }); + + QUnit.test('array should be equal', function () { + // NOTE: We don't test for array contents -- that would be too expensive. + ok(!_emberRuntimeIsEqual.default([1, 2], [1, 2]), 'two array instances with the same values should not be equal'); + ok(!_emberRuntimeIsEqual.default([1, 2], [1]), 'two array instances with different values should not be equal'); + }); + + QUnit.test('first object implements isEqual should use it', function () { + ok(_emberRuntimeIsEqual.default({ isEqual: function () { + return true; + } }, null), 'should return true always'); + + var obj = { isEqual: function () { + return false; + } }; + equal(_emberRuntimeIsEqual.default(obj, obj), false, 'should return false because isEqual returns false'); + }); +}); +enifed('ember-runtime/tests/core/isEqual_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/isEqual_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/isEqual_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/is_array_test', ['exports', 'ember-runtime/utils', 'ember-runtime/system/native_array', 'ember-runtime/system/array_proxy', 'ember-environment'], function (exports, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberRuntimeSystemArray_proxy, _emberEnvironment) { + 'use strict'; + + QUnit.module('Ember Type Checking'); + + var global = undefined; + + QUnit.test('Ember.isArray', function () { + var numarray = [1, 2, 3]; + var number = 23; + var strarray = ['Hello', 'Hi']; + var string = 'Hello'; + var object = {}; + var length = { length: 12 }; + var fn = function () {}; + var arrayProxy = _emberRuntimeSystemArray_proxy.default.create({ content: _emberRuntimeSystemNative_array.A() }); + + equal(_emberRuntimeUtils.isArray(numarray), true, '[1,2,3]'); + equal(_emberRuntimeUtils.isArray(number), false, '23'); + equal(_emberRuntimeUtils.isArray(strarray), true, '["Hello", "Hi"]'); + equal(_emberRuntimeUtils.isArray(string), false, '"Hello"'); + equal(_emberRuntimeUtils.isArray(object), false, '{}'); + equal(_emberRuntimeUtils.isArray(length), true, '{ length: 12 }'); + equal(_emberRuntimeUtils.isArray(global), false, 'global'); + equal(_emberRuntimeUtils.isArray(fn), false, 'function() {}'); + equal(_emberRuntimeUtils.isArray(arrayProxy), true, '[]'); + }); + + if (_emberEnvironment.environment.window && typeof _emberEnvironment.environment.window.FileList === 'function') { + QUnit.test('Ember.isArray(fileList)', function () { + var fileListElement = document.createElement('input'); + fileListElement.type = 'file'; + var fileList = fileListElement.files; + equal(_emberRuntimeUtils.isArray(fileList), false, 'fileList'); + }); + } +}); +enifed('ember-runtime/tests/core/is_array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/is_array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/is_array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/is_empty_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.isEmpty'); + + QUnit.test('Ember.isEmpty', function () { + var arrayProxy = _emberRuntimeSystemArray_proxy.default.create({ content: _emberRuntimeSystemNative_array.A() }); + + equal(true, _emberMetal.isEmpty(arrayProxy), 'for an ArrayProxy that has empty content'); + }); +}); +enifed('ember-runtime/tests/core/is_empty_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/is_empty_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/is_empty_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/type_of_test', ['exports', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-environment'], function (exports, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberEnvironment) { + 'use strict'; + + QUnit.module('Ember Type Checking'); + + QUnit.test('Ember.typeOf', function () { + var MockedDate = function () {}; + MockedDate.prototype = new Date(); + + var mockedDate = new MockedDate(); + var date = new Date(); + var error = new Error('boum'); + var object = { a: 'b' }; + var a = null; + var arr = [1, 2, 3]; + var obj = {}; + var instance = _emberRuntimeSystemObject.default.create({ method: function () {} }); + + equal(_emberRuntimeUtils.typeOf(), 'undefined', 'undefined'); + equal(_emberRuntimeUtils.typeOf(null), 'null', 'null'); + equal(_emberRuntimeUtils.typeOf('Cyril'), 'string', 'Cyril'); + equal(_emberRuntimeUtils.typeOf(101), 'number', '101'); + equal(_emberRuntimeUtils.typeOf(true), 'boolean', 'true'); + equal(_emberRuntimeUtils.typeOf([1, 2, 90]), 'array', '[1,2,90]'); + equal(_emberRuntimeUtils.typeOf(/abc/), 'regexp', '/abc/'); + equal(_emberRuntimeUtils.typeOf(date), 'date', 'new Date()'); + equal(_emberRuntimeUtils.typeOf(mockedDate), 'date', 'mocked date'); + equal(_emberRuntimeUtils.typeOf(error), 'error', 'error'); + equal(_emberRuntimeUtils.typeOf(object), 'object', 'object'); + equal(_emberRuntimeUtils.typeOf(undefined), 'undefined', 'item of type undefined'); + equal(_emberRuntimeUtils.typeOf(a), 'null', 'item of type null'); + equal(_emberRuntimeUtils.typeOf(arr), 'array', 'item of type array'); + equal(_emberRuntimeUtils.typeOf(obj), 'object', 'item of type object'); + equal(_emberRuntimeUtils.typeOf(instance), 'instance', 'item of type instance'); + equal(_emberRuntimeUtils.typeOf(instance.method), 'function', 'item of type function'); + equal(_emberRuntimeUtils.typeOf(_emberRuntimeSystemObject.default.extend()), 'class', 'item of type class'); + equal(_emberRuntimeUtils.typeOf(new Error()), 'error', 'item of type error'); + }); + + if (_emberEnvironment.environment.window && typeof _emberEnvironment.environment.window.FileList === 'function') { + QUnit.test('Ember.typeOf(fileList)', function () { + var fileListElement = document.createElement('input'); + fileListElement.type = 'file'; + var fileList = fileListElement.files; + equal(_emberRuntimeUtils.typeOf(fileList), 'filelist', 'item of type filelist'); + }); + } +}); +enifed('ember-runtime/tests/core/type_of_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/type_of_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/type_of_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/ext/function_test', ['exports', 'ember-environment', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object', 'ember-runtime/mixins/evented'], function (exports, _emberEnvironment, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject, _emberRuntimeMixinsEvented) { + 'use strict'; + + QUnit.module('Function.prototype.observes() helper'); + + _internalTestHelpers.testBoth('global observer helper takes multiple params', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('undefined' === typeof Function.prototype.observes, 'Function.prototype helper disabled'); + return; + } + + var MyMixin = _emberMetal.Mixin.create({ + + count: 0, + + foo: (function () { + set(this, 'count', get(this, 'count') + 1); + }).observes('bar', 'baz') + + }); + + var obj = _emberMetal.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 2, 'should invoke observer after change'); + }); + + QUnit.module('Function.prototype.on() helper'); + + _internalTestHelpers.testBoth('sets up an event listener, and can trigger the function on multiple events', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('undefined' === typeof Function.prototype.on, 'Function.prototype helper disabled'); + return; + } + + var MyMixin = _emberMetal.Mixin.create({ + + count: 0, + + foo: (function () { + set(this, 'count', get(this, 'count') + 1); + }).on('bar', 'baz') + + }); + + var obj = _emberMetal.mixin({}, _emberRuntimeMixinsEvented.default, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); + + obj.trigger('bar'); + obj.trigger('baz'); + equal(get(obj, 'count'), 2, 'should invoke listeners when events trigger'); + }); + + _internalTestHelpers.testBoth('can be chained with observes', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('Function.prototype helper disabled'); + return; + } + + var MyMixin = _emberMetal.Mixin.create({ + + count: 0, + bay: 'bay', + foo: (function () { + set(this, 'count', get(this, 'count') + 1); + }).observes('bay').on('bar') + }); + + var obj = _emberMetal.mixin({}, _emberRuntimeMixinsEvented.default, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); + + set(obj, 'bay', 'BAY'); + obj.trigger('bar'); + equal(get(obj, 'count'), 2, 'should invoke observer and listener'); + }); + + QUnit.module('Function.prototype.property() helper'); + + _internalTestHelpers.testBoth('sets up a ComputedProperty', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('undefined' === typeof Function.prototype.property, 'Function.prototype helper disabled'); + return; + } + + var MyClass = _emberRuntimeSystemObject.default.extend({ + firstName: null, + lastName: null, + fullName: (function () { + return get(this, 'firstName') + ' ' + get(this, 'lastName'); + }).property('firstName', 'lastName') + }); + + var obj = MyClass.create({ firstName: 'Fred', lastName: 'Flinstone' }); + equal(get(obj, 'fullName'), 'Fred Flinstone', 'should return the computed value'); + + set(obj, 'firstName', 'Wilma'); + equal(get(obj, 'fullName'), 'Wilma Flinstone', 'should return the new computed value'); + + set(obj, 'lastName', ''); + equal(get(obj, 'fullName'), 'Wilma ', 'should return the new computed value'); + }); +}); +enifed('ember-runtime/tests/ext/function_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/ext/function_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/ext/function_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/ext/mixin_test', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; + + QUnit.module('system/mixin/binding_test'); + + QUnit.test('Defining a property ending in Binding should setup binding when applied', function () { + var MyMixin = _emberMetal.Mixin.create({ + fooBinding: 'bar.baz' + }); + + var obj = { bar: { baz: 'BIFF' } }; + + _emberMetal.run(function () { + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + MyMixin.apply(obj); + }, deprecationMessage); + }); + + ok(_emberMetal.get(obj, 'fooBinding') instanceof _emberMetal.Binding, 'should be a binding object'); + equal(_emberMetal.get(obj, 'foo'), 'BIFF', 'binding should be created and synced'); + }); + + QUnit.test('Defining a property ending in Binding should apply to prototype children', function () { + var MyMixin = _emberMetal.run(function () { + return _emberMetal.Mixin.create({ + fooBinding: 'bar.baz' + }); + }); + + var obj = { bar: { baz: 'BIFF' } }; + + _emberMetal.run(function () { + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + MyMixin.apply(obj); + }, deprecationMessage); + }); + + var obj2 = Object.create(obj); + _emberMetal.run(function () { + return _emberMetal.set(_emberMetal.get(obj2, 'bar'), 'baz', 'BARG'); + }); + + ok(_emberMetal.get(obj2, 'fooBinding') instanceof _emberMetal.Binding, 'should be a binding object'); + equal(_emberMetal.get(obj2, 'foo'), 'BARG', 'binding should be created and synced'); + }); +}); +enifed('ember-runtime/tests/ext/mixin_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/ext/mixin_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/ext/mixin_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/ext/rsvp_test', ['exports', 'ember-metal', 'ember-runtime/ext/rsvp'], function (exports, _emberMetal, _emberRuntimeExtRsvp) { + 'use strict'; + + var ORIGINAL_ONERROR = _emberMetal.getOnerror(); + + QUnit.module('Ember.RSVP', { + teardown: function () { + _emberMetal.setOnerror(ORIGINAL_ONERROR); + } + }); + + QUnit.test('Ensure that errors thrown from within a promise are sent to the console', function () { + var error = new Error('Error thrown in a promise for testing purposes.'); + + try { + _emberMetal.run(function () { + new _emberRuntimeExtRsvp.default.Promise(function (resolve, reject) { + throw error; + }); + }); + ok(false, 'expected assertion to be thrown'); + } catch (e) { + equal(e, error, 'error was re-thrown'); + } + }); + + QUnit.test('TransitionAborted errors are not re-thrown', function () { + expect(1); + var fakeTransitionAbort = { name: 'TransitionAborted' }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', fakeTransitionAbort); + + ok(true, 'did not throw an error when dealing with TransitionAborted'); + }); + + QUnit.test('Can reject with non-Error object', function (assert) { + var wasEmberTesting = _emberMetal.isTesting(); + _emberMetal.setTesting(false); + expect(1); + + try { + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', 'foo'); + } catch (e) { + ok(false, 'should not throw'); + } finally { + _emberMetal.setTesting(wasEmberTesting); + } + + ok(true); + }); + + QUnit.test('Can reject with no arguments', function (assert) { + var wasEmberTesting = _emberMetal.isTesting(); + _emberMetal.setTesting(false); + expect(1); + + try { + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject'); + } catch (e) { + ok(false, 'should not throw'); + } finally { + _emberMetal.setTesting(wasEmberTesting); + } + + ok(true); + }); + + QUnit.test('rejections like jqXHR which have errorThrown property work', function () { + expect(2); + + var wasEmberTesting = _emberMetal.isTesting(); + var wasOnError = _emberMetal.getOnerror(); + + try { + (function () { + _emberMetal.setTesting(false); + _emberMetal.setOnerror(function (error) { + equal(error, actualError, 'expected the real error on the jqXHR'); + equal(error.__reason_with_error_thrown__, jqXHR, 'also retains a helpful reference to the rejection reason'); + }); + + var actualError = new Error('OMG what really happened'); + var jqXHR = { + errorThrown: actualError + }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', jqXHR); + })(); + } finally { + _emberMetal.setOnerror(wasOnError); + _emberMetal.setTesting(wasEmberTesting); + } + }); + + QUnit.test('rejections where the errorThrown is a string should wrap the sting in an error object', function () { + expect(2); + + var wasEmberTesting = _emberMetal.isTesting(); + var wasOnError = _emberMetal.getOnerror(); + + try { + (function () { + _emberMetal.setTesting(false); + _emberMetal.setOnerror(function (error) { + equal(error.message, actualError, 'expected the real error on the jqXHR'); + equal(error.__reason_with_error_thrown__, jqXHR, 'also retains a helpful reference to the rejection reason'); + }); + + var actualError = 'OMG what really happened'; + var jqXHR = { + errorThrown: actualError + }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', jqXHR); + })(); + } finally { + _emberMetal.setOnerror(wasOnError); + _emberMetal.setTesting(wasEmberTesting); + } + }); + + QUnit.test('rejections can be serialized to JSON', function (assert) { + expect(2); + + var wasEmberTesting = _emberMetal.isTesting(); + var wasOnError = _emberMetal.getOnerror(); + + try { + _emberMetal.setTesting(false); + _emberMetal.setOnerror(function (error) { + assert.equal(error.message, 'a fail'); + assert.ok(JSON.stringify(error), 'Error can be serialized'); + }); + + var jqXHR = { + errorThrown: new Error('a fail') + }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', jqXHR); + } finally { + _emberMetal.setOnerror(wasOnError); + _emberMetal.setTesting(wasEmberTesting); + } + }); + + var reason = 'i failed'; + QUnit.module('Ember.test: rejection assertions'); + + function ajax(something) { + return _emberRuntimeExtRsvp.default.Promise(function (resolve) { + QUnit.stop(); + setTimeout(function () { + QUnit.start(); + resolve(); + }, 0); // fake true / foreign async + }); + } + + QUnit.test('unambigiously unhandled rejection', function () { + QUnit.throws(function () { + _emberMetal.run(function () { + _emberRuntimeExtRsvp.default.Promise.reject(reason); + }); // something is funky, we should likely assert + }, reason); + }); + + QUnit.test('sync handled', function () { + _emberMetal.run(function () { + _emberRuntimeExtRsvp.default.Promise.reject(reason).catch(function () {}); + }); // handled, we shouldn't need to assert. + ok(true, 'reached end of test'); + }); + + QUnit.test('handled within the same micro-task (via Ember.RVP.Promise)', function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + _emberRuntimeExtRsvp.default.Promise.resolve(1).then(function () { + return rejection.catch(function () {}); + }); + }); // handled, we shouldn't need to assert. + ok(true, 'reached end of test'); + }); + + QUnit.test('handled within the same micro-task (via direct run-loop)', function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + _emberMetal.run.schedule('afterRender', function () { + return rejection.catch(function () {}); + }); + }); // handled, we shouldn't need to assert. + ok(true, 'reached end of test'); + }); + + QUnit.test('handled in the next microTask queue flush (run.next)', function () { + expect(2); + + QUnit.throws(function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + + QUnit.stop(); + _emberMetal.run.next(function () { + QUnit.start(); + rejection.catch(function () {}); + ok(true, 'reached end of test'); + }); + }); + }, reason); + + // a promise rejection survived a full flush of the run-loop without being handled + // this is very likely an issue. + }); + + QUnit.test('handled in the same microTask Queue flush do to data locality', function () { + // an ambiguous scenario, this may or may not assert + // it depends on the locality of `user#1` + var store = { + find: function () { + return _emberRuntimeExtRsvp.default.Promise.resolve(1); + } + }; + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + store.find('user', 1).then(function () { + return rejection.catch(function () {}); + }); + }); + + ok(true, 'reached end of test'); + }); + + QUnit.test('handled in a different microTask Queue flush do to data locality', function () { + // an ambiguous scenario, this may or may not assert + // it depends on the locality of `user#1` + var store = { + find: function () { + return ajax(); + } + }; + QUnit.throws(function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + store.find('user', 1).then(function () { + rejection.catch(function () {}); + ok(true, 'reached end of test'); + }); + }); + }, reason); + }); + + QUnit.test('handled in the next microTask queue flush (ajax example)', function () { + QUnit.throws(function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + ajax('/something/').then(function () { + rejection.catch(function () {}); + ok(true, 'reached end of test'); + }); + }); + }, reason); + }); +}); +enifed('ember-runtime/tests/ext/rsvp_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/ext/rsvp_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/ext/rsvp_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/inject_test', ['exports', 'ember-metal', 'ember-runtime/inject', 'ember-runtime/system/object', 'internal-test-helpers'], function (exports, _emberMetal, _emberRuntimeInject, _emberRuntimeSystemObject, _internalTestHelpers) { + /* global EmberDev */ + + 'use strict'; + + QUnit.module('inject'); + + QUnit.test('calling `inject` directly should error', function () { + expectAssertion(function () { + _emberRuntimeInject.default('foo'); + }, /Injected properties must be created through helpers/); + }); + + if (!EmberDev.runningProdBuild) { + // this check is done via an assertion which is stripped from + // production builds + QUnit.test('injection type validation is run when first looked up', function () { + _emberRuntimeInject.createInjectionHelper('foo', function () { + ok(true, 'should call validation method'); + }); + + var owner = _internalTestHelpers.buildOwner(); + + var AnObject = _emberRuntimeSystemObject.default.extend({ + bar: _emberRuntimeInject.default.foo(), + baz: _emberRuntimeInject.default.foo() + }); + + owner.register('foo:main', AnObject); + + if (true) { + expect(2); + expectDeprecation(function () { + owner._lookupFactory('foo:main'); + }, /Using "_lookupFactory" is deprecated. Please use container.factoryFor instead./); + } else { + expect(1); + owner._lookupFactory('foo:main'); + } + }); + + QUnit.test('attempting to inject a nonexistent container key should error', function () { + var owner = _internalTestHelpers.buildOwner(); + var AnObject = _emberRuntimeSystemObject.default.extend({ + foo: new _emberMetal.InjectedProperty('bar', 'baz') + }); + + owner.register('foo:main', AnObject); + + throws(function () { + owner.lookup('foo:main'); + }, /Attempting to inject an unknown injection: 'bar:baz'/); + }); + } + + QUnit.test('factories should return a list of lazy injection full names', function () { + var AnObject = _emberRuntimeSystemObject.default.extend({ + foo: new _emberMetal.InjectedProperty('foo', 'bar'), + bar: new _emberMetal.InjectedProperty('quux') + }); + + deepEqual(AnObject._lazyInjections(), { 'foo': 'foo:bar', 'bar': 'quux:bar' }, 'should return injected container keys'); + }); +}); +enifed('ember-runtime/tests/inject_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/inject_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/inject_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/chained_test', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * changed obj.set() and obj.get() to Ember.set() and Ember.get() + * changed obj.addObserver() to addObserver() + */ + + QUnit.module('Ember.Observable - Observing with @each'); + + QUnit.test('chained observers on enumerable properties are triggered when the observed property of any item changes', function () { + var family = _emberRuntimeSystemObject.default.create({ momma: null }); + var momma = _emberRuntimeSystemObject.default.create({ children: [] }); + + var child1 = _emberRuntimeSystemObject.default.create({ name: 'Bartholomew' }); + var child2 = _emberRuntimeSystemObject.default.create({ name: 'Agnes' }); + var child3 = _emberRuntimeSystemObject.default.create({ name: 'Dan' }); + var child4 = _emberRuntimeSystemObject.default.create({ name: 'Nancy' }); + + _emberMetal.set(family, 'momma', momma); + _emberMetal.set(momma, 'children', _emberRuntimeSystemNative_array.A([child1, child2, child3])); + + var observerFiredCount = 0; + _emberMetal.addObserver(family, 'momma.children.@each.name', this, function () { + observerFiredCount++; + }); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.get(momma, 'children').setEach('name', 'Juan'); + }); + equal(observerFiredCount, 3, 'observer fired after changing child names'); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.get(momma, 'children').pushObject(child4); + }); + equal(observerFiredCount, 1, 'observer fired after adding a new item'); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.set(child4, 'name', 'Herbert'); + }); + equal(observerFiredCount, 1, 'observer fired after changing property on new object'); + + _emberMetal.set(momma, 'children', []); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.set(child1, 'name', 'Hanna'); + }); + equal(observerFiredCount, 0, 'observer did not fire after removing changing property on a removed object'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/chained_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observable_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/string', 'ember-runtime/system/object', 'ember-runtime/mixins/observable', 'ember-runtime/system/native_array'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemString, _emberRuntimeSystemObject, _emberRuntimeMixinsObservable, _emberRuntimeSystemNative_array) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Added ObservableObject which applies the Ember.Observable mixin. + * Changed reference to Ember.T_FUNCTION to 'function' + * Changed all references to sc_super to this._super(...arguments) + * Changed Ember.objectForPropertyPath() to Ember.getPath() + * Removed allPropertiesDidChange test - no longer supported + * Changed test that uses 'ObjectE' as path to 'objectE' to reflect new + rule on using capital letters for property paths. + * Removed test passing context to addObserver. context param is no longer + supported. + * Changed calls to Ember.Binding.flushPendingChanges() -> run.sync() + * removed test in observer around line 862 that expected key/value to be + the last item in the chained path. Should be root and chained path + + */ + + // ======================================================================== + // Ember.Observable Tests + // ======================================================================== + + var object, ObjectC, ObjectD, objectA, objectB, lookup; + + var ObservableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default); + var originalLookup = _emberEnvironment.context.lookup; + + // .......................................................... + // GET() + // + + QUnit.module('object.get()', { + + setup: function () { + object = ObservableObject.extend(_emberRuntimeMixinsObservable.default, { + computed: _emberMetal.computed(function () { + return 'value'; + }).volatile(), + method: function () { + return 'value'; + }, + unknownProperty: function (key, value) { + this.lastUnknownProperty = key; + return 'unknown'; + } + }).create({ + normal: 'value', + numberVal: 24, + toggleVal: true, + nullProperty: null + }); + } + + }); + + QUnit.test('should get normal properties', function () { + equal(object.get('normal'), 'value'); + }); + + QUnit.test('should call computed properties and return their result', function () { + equal(object.get('computed'), 'value'); + }); + + QUnit.test('should return the function for a non-computed property', function () { + var value = object.get('method'); + equal(typeof value, 'function'); + }); + + QUnit.test('should return null when property value is null', function () { + equal(object.get('nullProperty'), null); + }); + + QUnit.test('should call unknownProperty when value is undefined', function () { + equal(object.get('unknown'), 'unknown'); + equal(object.lastUnknownProperty, 'unknown'); + }); + + // .......................................................... + // Ember.GET() + // + QUnit.module('Ember.get()', { + setup: function () { + objectA = ObservableObject.extend({ + computed: _emberMetal.computed(function () { + return 'value'; + }).volatile(), + method: function () { + return 'value'; + }, + unknownProperty: function (key, value) { + this.lastUnknownProperty = key; + return 'unknown'; + } + }).create({ + normal: 'value', + numberVal: 24, + toggleVal: true, + nullProperty: null + }); + + objectB = { + normal: 'value', + nullProperty: null + }; + } + }); + + QUnit.test('should get normal properties on Ember.Observable', function () { + equal(_emberMetal.get(objectA, 'normal'), 'value'); + }); + + QUnit.test('should call computed properties on Ember.Observable and return their result', function () { + equal(_emberMetal.get(objectA, 'computed'), 'value'); + }); + + QUnit.test('should return the function for a non-computed property on Ember.Observable', function () { + var value = _emberMetal.get(objectA, 'method'); + equal(typeof value, 'function'); + }); + + QUnit.test('should return null when property value is null on Ember.Observable', function () { + equal(_emberMetal.get(objectA, 'nullProperty'), null); + }); + + QUnit.test('should call unknownProperty when value is undefined on Ember.Observable', function () { + equal(_emberMetal.get(objectA, 'unknown'), 'unknown'); + equal(objectA.lastUnknownProperty, 'unknown'); + }); + + QUnit.test('should get normal properties on standard objects', function () { + equal(_emberMetal.get(objectB, 'normal'), 'value'); + }); + + QUnit.test('should return null when property is null on standard objects', function () { + equal(_emberMetal.get(objectB, 'nullProperty'), null); + }); + + /* + QUnit.test("raise if the provided object is null", function() { + throws(function() { + get(null, 'key'); + }); + }); + */ + + QUnit.test('raise if the provided object is undefined', function () { + expectAssertion(function () { + _emberMetal.get(undefined, 'key'); + }, /Cannot call get with 'key' on an undefined object/i); + }); + + QUnit.module('Ember.get() with paths'); + + QUnit.test('should return a property at a given path relative to the passed object', function () { + var foo = ObservableObject.create({ + bar: ObservableObject.extend({ + baz: _emberMetal.computed(function () { + return 'blargh'; + }).volatile() + }).create() + }); + + equal(_emberMetal.get(foo, 'bar.baz'), 'blargh'); + }); + + QUnit.test('should return a property at a given path relative to the passed object - JavaScript hash', function () { + var foo = { + bar: { + baz: 'blargh' + } + }; + + equal(_emberMetal.get(foo, 'bar.baz'), 'blargh'); + }); + + // .......................................................... + // SET() + // + + QUnit.module('object.set()', { + + setup: function () { + object = ObservableObject.extend({ + computed: _emberMetal.computed({ + get: function (key) { + return this._computed; + }, + set: function (key, value) { + this._computed = value; + return this._computed; + } + }).volatile(), + + method: function (key, value) { + if (value !== undefined) { + this._method = value; + } + return this._method; + }, + + unknownProperty: function (key) { + return this._unknown; + }, + + setUnknownProperty: function (key, value) { + this._unknown = value; + return this._unknown; + }, + + // normal property + normal: 'value', + + // computed property + _computed: 'computed', + // method, but not a property + _method: 'method', + // null property + nullProperty: null, + + // unknown property + _unknown: 'unknown' + }).create(); + } + + }); + + QUnit.test('should change normal properties and return the value', function () { + var ret = object.set('normal', 'changed'); + equal(object.get('normal'), 'changed'); + equal(ret, 'changed'); + }); + + QUnit.test('should call computed properties passing value and return the value', function () { + var ret = object.set('computed', 'changed'); + equal(object.get('_computed'), 'changed'); + equal(ret, 'changed'); + }); + + QUnit.test('should change normal properties when passing undefined', function () { + var ret = object.set('normal', undefined); + equal(object.get('normal'), undefined); + equal(ret, undefined); + }); + + QUnit.test('should replace the function for a non-computed property and return the value', function () { + var ret = object.set('method', 'changed'); + equal(object.get('_method'), 'method'); // make sure this was NOT run + ok(typeof object.get('method') !== 'function'); + equal(ret, 'changed'); + }); + + QUnit.test('should replace prover when property value is null', function () { + var ret = object.set('nullProperty', 'changed'); + equal(object.get('nullProperty'), 'changed'); + equal(ret, 'changed'); + }); + + QUnit.test('should call unknownProperty with value when property is undefined', function () { + var ret = object.set('unknown', 'changed'); + equal(object.get('_unknown'), 'changed'); + equal(ret, 'changed'); + }); + + // .......................................................... + // COMPUTED PROPERTIES + // + + QUnit.module('Computed properties', { + setup: function () { + lookup = _emberEnvironment.context.lookup = {}; + + object = ObservableObject.extend({ + computed: _emberMetal.computed({ + get: function () { + this.computedCalls.push('getter-called'); + return 'computed'; + }, + set: function (key, value) { + this.computedCalls.push(value); + } + }).volatile(), + + computedCached: _emberMetal.computed({ + get: function () { + this.computedCachedCalls.push('getter-called'); + return 'computedCached'; + }, + set: function (key, value) { + this.computedCachedCalls.push(value); + } + }), + + dependent: _emberMetal.computed({ + get: function () { + this.dependentCalls.push('getter-called'); + return 'dependent'; + }, + set: function (key, value) { + this.dependentCalls.push(value); + } + }).property('changer').volatile(), + dependentFront: _emberMetal.computed('changer', { + get: function () { + this.dependentFrontCalls.push('getter-called'); + return 'dependentFront'; + }, + set: function (key, value) { + this.dependentFrontCalls.push(value); + } + }).volatile(), + dependentCached: _emberMetal.computed({ + get: function () { + this.dependentCachedCalls.push('getter-called!'); + return 'dependentCached'; + }, + set: function (key, value) { + this.dependentCachedCalls.push(value); + } + }).property('changer'), + + inc: _emberMetal.computed('changer', function () { + return this.incCallCount++; + }), + + nestedInc: _emberMetal.computed(function (key) { + _emberMetal.get(this, 'inc'); + return this.nestedIncCallCount++; + }).property('inc'), + + isOn: _emberMetal.computed({ + get: function () { + return this.get('state') === 'on'; + }, + set: function (key, value) { + this.set('state', 'on'); + return this.get('state') === 'on'; + } + }).property('state').volatile(), + + isOff: _emberMetal.computed({ + get: function () { + return this.get('state') === 'off'; + }, + set: function (key, value) { + this.set('state', 'off'); + return this.get('state') === 'off'; + } + }).property('state').volatile() + + }).create({ + computedCalls: [], + computedCachedCalls: [], + changer: 'foo', + dependentCalls: [], + dependentFrontCalls: [], + dependentCachedCalls: [], + incCallCount: 0, + nestedIncCallCount: 0, + state: 'on' + }); + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('getting values should call function return value', function () { + // get each property twice. Verify return. + var keys = _emberRuntimeSystemString.w('computed computedCached dependent dependentFront dependentCached'); + + keys.forEach(function (key) { + equal(object.get(key), key, 'Try #1: object.get(' + key + ') should run function'); + equal(object.get(key), key, 'Try #2: object.get(' + key + ') should run function'); + }); + + // verify each call count. cached should only be called once + _emberRuntimeSystemString.w('computedCalls dependentFrontCalls dependentCalls').forEach(function (key) { + equal(object[key].length, 2, 'non-cached property ' + key + ' should be called 2x'); + }); + + _emberRuntimeSystemString.w('computedCachedCalls dependentCachedCalls').forEach(function (key) { + equal(object[key].length, 1, 'non-cached property ' + key + ' should be called 1x'); + }); + }); + + QUnit.test('setting values should call function return value', function () { + // get each property twice. Verify return. + var keys = _emberRuntimeSystemString.w('computed dependent dependentFront computedCached dependentCached'); + var values = _emberRuntimeSystemString.w('value1 value2'); + + keys.forEach(function (key) { + equal(object.set(key, values[0]), values[0], 'Try #1: object.set(' + key + ', ' + values[0] + ') should run function'); + + equal(object.set(key, values[1]), values[1], 'Try #2: object.set(' + key + ', ' + values[1] + ') should run function'); + + equal(object.set(key, values[1]), values[1], 'Try #3: object.set(' + key + ', ' + values[1] + ') should not run function since it is setting same value as before'); + }); + + // verify each call count. cached should only be called once + keys.forEach(function (key) { + var calls = object[key + 'Calls']; + var idx, expectedLength; + + // Cached properties first check their cached value before setting the + // property. Other properties blindly call set. + expectedLength = 3; + equal(calls.length, expectedLength, 'set(' + key + ') should be called the right amount of times'); + for (idx = 0; idx < 2; idx++) { + equal(calls[idx], values[idx], 'call #' + (idx + 1) + ' to set(' + key + ') should have passed value ' + values[idx]); + } + }); + }); + + QUnit.test('notify change should clear cache', function () { + // call get several times to collect call count + object.get('computedCached'); // should run func + object.get('computedCached'); // should not run func + + object.propertyWillChange('computedCached').propertyDidChange('computedCached'); + + object.get('computedCached'); // should run again + equal(object.computedCachedCalls.length, 2, 'should have invoked method 2x'); + }); + + QUnit.test('change dependent should clear cache', function () { + // call get several times to collect call count + var ret1 = object.get('inc'); // should run func + equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); + + object.set('changer', 'bar'); + + equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + QUnit.test('just notifying change of dependent should clear cache', function () { + // call get several times to collect call count + var ret1 = object.get('inc'); // should run func + equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); + + object.notifyPropertyChange('changer'); + + equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + QUnit.test('changing dependent should clear nested cache', function () { + // call get several times to collect call count + var ret1 = object.get('nestedInc'); // should run func + equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop'); + + object.set('changer', 'bar'); + + equal(object.get('nestedInc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + QUnit.test('just notifying change of dependent should clear nested cache', function () { + // call get several times to collect call count + var ret1 = object.get('nestedInc'); // should run func + equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop'); + + object.notifyPropertyChange('changer'); + + equal(object.get('nestedInc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + // This verifies a specific bug encountered where observers for computed + // properties would fire before their prop caches were cleared. + QUnit.test('change dependent should clear cache when observers of dependent are called', function () { + // call get several times to collect call count + var ret1 = object.get('inc'); // should run func + equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); + + // add observer to verify change... + object.addObserver('inc', this, function () { + equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + // now run + object.set('changer', 'bar'); + }); + + QUnit.test('setting one of two computed properties that depend on a third property should clear the kvo cache', function () { + // we have to call set twice to fill up the cache + object.set('isOff', true); + object.set('isOn', true); + + // setting isOff to true should clear the kvo cache + object.set('isOff', true); + equal(object.get('isOff'), true, 'object.isOff should be true'); + equal(object.get('isOn'), false, 'object.isOn should be false'); + }); + + QUnit.test('dependent keys should be able to be specified as property paths', function () { + var depObj = ObservableObject.extend({ + menuPrice: _emberMetal.computed(function () { + return this.get('menu.price'); + }).property('menu.price') + }).create({ + menu: ObservableObject.create({ + price: 5 + }) + }); + + equal(depObj.get('menuPrice'), 5, 'precond - initial value returns 5'); + + depObj.set('menu.price', 6); + + equal(depObj.get('menuPrice'), 6, 'cache is properly invalidated after nested property changes'); + }); + + QUnit.test('nested dependent keys should propagate after they update', function () { + var bindObj; + _emberMetal.run(function () { + lookup.DepObj = ObservableObject.extend({ + price: _emberMetal.computed(function () { + return this.get('restaurant.menu.price'); + }).property('restaurant.menu.price') + }).create({ + restaurant: ObservableObject.create({ + menu: ObservableObject.create({ + price: 5 + }) + }) + }); + + expectDeprecation(function () { + bindObj = ObservableObject.extend({ + priceBinding: 'DepObj.price' + }).create(); + }, /`Ember.Binding` is deprecated/); + }); + + equal(bindObj.get('price'), 5, 'precond - binding propagates'); + + _emberMetal.run(function () { + lookup.DepObj.set('restaurant.menu.price', 10); + }); + + equal(bindObj.get('price'), 10, 'binding propagates after a nested dependent keys updates'); + + _emberMetal.run(function () { + lookup.DepObj.set('restaurant.menu', ObservableObject.create({ + price: 15 + })); + }); + + equal(bindObj.get('price'), 15, 'binding propagates after a middle dependent keys updates'); + }); + + QUnit.test('cacheable nested dependent keys should clear after their dependencies update', function () { + ok(true); + + var DepObj; + + _emberMetal.run(function () { + lookup.DepObj = DepObj = ObservableObject.extend({ + price: _emberMetal.computed('restaurant.menu.price', function () { + return this.get('restaurant.menu.price'); + }) + }).create({ + restaurant: ObservableObject.create({ + menu: ObservableObject.create({ + price: 5 + }) + }) + }); + }); + + equal(DepObj.get('price'), 5, 'precond - computed property is correct'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu.price', 10); + }); + equal(DepObj.get('price'), 10, 'cacheable computed properties are invalidated even if no run loop occurred'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu.price', 20); + }); + equal(DepObj.get('price'), 20, 'cacheable computed properties are invalidated after a second get before a run loop'); + equal(DepObj.get('price'), 20, 'precond - computed properties remain correct after a run loop'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu', ObservableObject.create({ + price: 15 + })); + }); + + equal(DepObj.get('price'), 15, 'cacheable computed properties are invalidated after a middle property changes'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu', ObservableObject.create({ + price: 25 + })); + }); + + equal(DepObj.get('price'), 25, 'cacheable computed properties are invalidated after a middle property changes again, before a run loop'); + }); + + // .......................................................... + // OBSERVABLE OBJECTS + // + + QUnit.module('Observable objects & object properties ', { + setup: function () { + object = ObservableObject.extend({ + getEach: function () { + var keys = ['normal', 'abnormal']; + var ret = []; + for (var idx = 0; idx < keys.length; idx++) { + ret[ret.length] = this.get(keys[idx]); + } + return ret; + }, + + newObserver: function () { + this.abnormal = 'changedValueObserved'; + }, + + testObserver: _emberMetal.observer('normal', function () { + this.abnormal = 'removedObserver'; + }), + + testArrayObserver: _emberMetal.observer('normalArray.[]', function () { + this.abnormal = 'notifiedObserver'; + }) + }).create({ + normal: 'value', + abnormal: 'zeroValue', + numberVal: 24, + toggleVal: true, + observedProperty: 'beingWatched', + testRemove: 'observerToBeRemoved', + normalArray: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5]) + }); + } + }); + + QUnit.test('incrementProperty and decrementProperty', function () { + var newValue = object.incrementProperty('numberVal'); + + equal(25, newValue, 'numerical value incremented'); + object.numberVal = 24; + newValue = object.decrementProperty('numberVal'); + equal(23, newValue, 'numerical value decremented'); + object.numberVal = 25; + newValue = object.incrementProperty('numberVal', 5); + equal(30, newValue, 'numerical value incremented by specified increment'); + object.numberVal = 25; + newValue = object.incrementProperty('numberVal', -5); + equal(20, newValue, 'minus numerical value incremented by specified increment'); + object.numberVal = 25; + newValue = object.incrementProperty('numberVal', 0); + equal(25, newValue, 'zero numerical value incremented by specified increment'); + + expectAssertion(function () { + newValue = object.incrementProperty('numberVal', 0 - void 0); // Increment by NaN + }, /Must pass a numeric value to incrementProperty/i); + + expectAssertion(function () { + newValue = object.incrementProperty('numberVal', 'Ember'); // Increment by non-numeric String + }, /Must pass a numeric value to incrementProperty/i); + + expectAssertion(function () { + newValue = object.incrementProperty('numberVal', 1 / 0); // Increment by Infinity + }, /Must pass a numeric value to incrementProperty/i); + + equal(25, newValue, 'Attempting to increment by non-numeric values should not increment value'); + + object.numberVal = 25; + newValue = object.decrementProperty('numberVal', 5); + equal(20, newValue, 'numerical value decremented by specified increment'); + object.numberVal = 25; + newValue = object.decrementProperty('numberVal', -5); + equal(30, newValue, 'minus numerical value decremented by specified increment'); + object.numberVal = 25; + newValue = object.decrementProperty('numberVal', 0); + equal(25, newValue, 'zero numerical value decremented by specified increment'); + + expectAssertion(function () { + newValue = object.decrementProperty('numberVal', 0 - void 0); // Decrement by NaN + }, /Must pass a numeric value to decrementProperty/i); + + expectAssertion(function () { + newValue = object.decrementProperty('numberVal', 'Ember'); // Decrement by non-numeric String + }, /Must pass a numeric value to decrementProperty/i); + + expectAssertion(function () { + newValue = object.decrementProperty('numberVal', 1 / 0); // Decrement by Infinity + }, /Must pass a numeric value to decrementProperty/i); + + equal(25, newValue, 'Attempting to decrement by non-numeric values should not decrement value'); + }); + + QUnit.test('toggle function, should be boolean', function () { + equal(object.toggleProperty('toggleVal', true, false), object.get('toggleVal')); + equal(object.toggleProperty('toggleVal', true, false), object.get('toggleVal')); + equal(object.toggleProperty('toggleVal', undefined, undefined), object.get('toggleVal')); + }); + + QUnit.test('should notify array observer when array changes', function () { + _emberMetal.get(object, 'normalArray').replace(0, 0, 6); + equal(object.abnormal, 'notifiedObserver', 'observer should be notified'); + }); + + QUnit.module('object.addObserver()', { + setup: function () { + ObjectC = ObservableObject.create({ + objectE: ObservableObject.create({ + propertyVal: 'chainedProperty' + }), + + normal: 'value', + normal1: 'zeroValue', + normal2: 'dependentValue', + incrementor: 10, + + action: function () { + this.normal1 = 'newZeroValue'; + }, + + observeOnceAction: function () { + this.incrementor = this.incrementor + 1; + }, + + chainedObserver: function () { + this.normal2 = 'chainedPropertyObserved'; + } + }); + } + }); + + QUnit.test('should register an observer for a property', function () { + ObjectC.addObserver('normal', ObjectC, 'action'); + ObjectC.set('normal', 'newValue'); + equal(ObjectC.normal1, 'newZeroValue'); + }); + + QUnit.test('should register an observer for a property - Special case of chained property', function () { + ObjectC.addObserver('objectE.propertyVal', ObjectC, 'chainedObserver'); + ObjectC.objectE.set('propertyVal', 'chainedPropertyValue'); + equal('chainedPropertyObserved', ObjectC.normal2); + ObjectC.normal2 = 'dependentValue'; + ObjectC.set('objectE', ''); + equal('chainedPropertyObserved', ObjectC.normal2); + }); + + QUnit.module('object.removeObserver()', { + setup: function () { + ObjectD = ObservableObject.create({ + objectF: ObservableObject.create({ + propertyVal: 'chainedProperty' + }), + + normal: 'value', + normal1: 'zeroValue', + normal2: 'dependentValue', + ArrayKeys: ['normal', 'normal1'], + + addAction: function () { + this.normal1 = 'newZeroValue'; + }, + removeAction: function () { + this.normal2 = 'newDependentValue'; + }, + removeChainedObserver: function () { + this.normal2 = 'chainedPropertyObserved'; + }, + + observableValue: 'hello world', + + observer1: function () { + // Just an observer + }, + observer2: function () { + this.removeObserver('observableValue', null, 'observer1'); + this.removeObserver('observableValue', null, 'observer2'); + this.hasObserverFor('observableValue'); // Tickle 'getMembers()' + this.removeObserver('observableValue', null, 'observer3'); + }, + observer3: function () { + // Just an observer + } + }); + } + }); + + QUnit.test('should unregister an observer for a property', function () { + ObjectD.addObserver('normal', ObjectD, 'addAction'); + ObjectD.set('normal', 'newValue'); + equal(ObjectD.normal1, 'newZeroValue'); + + ObjectD.set('normal1', 'zeroValue'); + + ObjectD.removeObserver('normal', ObjectD, 'addAction'); + ObjectD.set('normal', 'newValue'); + equal(ObjectD.normal1, 'zeroValue'); + }); + + QUnit.test('should unregister an observer for a property - special case when key has a \'.\' in it.', function () { + ObjectD.addObserver('objectF.propertyVal', ObjectD, 'removeChainedObserver'); + ObjectD.objectF.set('propertyVal', 'chainedPropertyValue'); + ObjectD.removeObserver('objectF.propertyVal', ObjectD, 'removeChainedObserver'); + ObjectD.normal2 = 'dependentValue'; + ObjectD.objectF.set('propertyVal', 'removedPropertyValue'); + equal('dependentValue', ObjectD.normal2); + ObjectD.set('objectF', ''); + equal('dependentValue', ObjectD.normal2); + }); + + QUnit.test('removing an observer inside of an observer shouldn’t cause any problems', function () { + // The observable system should be protected against clients removing + // observers in the middle of observer notification. + var encounteredError = false; + try { + ObjectD.addObserver('observableValue', null, 'observer1'); + ObjectD.addObserver('observableValue', null, 'observer2'); + ObjectD.addObserver('observableValue', null, 'observer3'); + _emberMetal.run(function () { + ObjectD.set('observableValue', 'hi world'); + }); + } catch (e) { + encounteredError = true; + } + equal(encounteredError, false); + }); + + QUnit.module('Bind function', { + setup: function () { + objectA = ObservableObject.create({ + name: 'Sproutcore', + location: 'Timbaktu' + }); + + objectB = ObservableObject.create({ + normal: 'value', + computed: function () { + this.normal = 'newValue'; + } + }); + + lookup = _emberEnvironment.context.lookup = { + 'Namespace': { + objectA: objectA, + objectB: objectB + } + }; + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('should bind property with method parameter as undefined', function () { + // creating binding + _emberMetal.run(function () { + expectDeprecation(function () { + objectA.bind('name', 'Namespace.objectB.normal', undefined); + }, /`Ember.Binding` is deprecated/); + }); + + // now make a change to see if the binding triggers. + _emberMetal.run(function () { + objectB.set('normal', 'changedValue'); + }); + + // support new-style bindings if available + equal('changedValue', objectA.get('name'), 'objectA.name is bound'); + }); + + // .......................................................... + // SPECIAL CASES + // + + QUnit.test('changing chained observer object to null should not raise exception', function () { + var obj = ObservableObject.create({ + foo: ObservableObject.create({ + bar: ObservableObject.create({ bat: 'BAT' }) + }) + }); + + var callCount = 0; + obj.foo.addObserver('bar.bat', obj, function (target, key, value) { + callCount++; + }); + + _emberMetal.run(function () { + obj.foo.set('bar', null); + }); + + equal(callCount, 1, 'changing bar should trigger observer'); + expect(1); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/observable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsObservable) { + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Create ObservableObject which includes Ember.Observable + */ + + // ======================================================================== + // Ember.Observable Tests + // ======================================================================== + + 'use strict'; + + var ObservableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default); + + // .......................................................... + // GET() + // + + QUnit.module('object.observesForKey()'); + + QUnit.test('should get observers', function () { + var o1 = ObservableObject.create({ foo: 100 }); + var o2 = ObservableObject.create({ func: function () {} }); + var o3 = ObservableObject.create({ func: function () {} }); + var observers = null; + + equal(_emberMetal.get(o1.observersForKey('foo'), 'length'), 0, 'o1.observersForKey should return empty array'); + + o1.addObserver('foo', o2, o2.func); + o1.addObserver('foo', o3, o3.func); + + observers = o1.observersForKey('foo'); + + equal(_emberMetal.get(observers, 'length'), 2, 'o2.observersForKey should return an array with length 2'); + equal(observers[0][0], o2, 'first item in observers array should be o2'); + equal(observers[1][0], o3, 'second item in observers array should be o3'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/observable', 'ember-metal'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsObservable, _emberMetal) { + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Create ObservableObject which includes Ember.Observable + * Remove test that tests internal _kvo_changeLevel property. This is an + implementation detail. + * Remove test for allPropertiesDidChange + * Removed star observer test. no longer supported + * Removed property revision test. no longer supported + */ + + // ======================================================================== + // Ember.Observable Tests + // ======================================================================== + + 'use strict'; + + var ObservableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default); + + var ObjectA = undefined; + + QUnit.module('object.propertyChanges', { + setup: function () { + ObjectA = ObservableObject.extend({ + action: _emberMetal.observer('foo', function () { + this.set('prop', 'changedPropValue'); + }), + notifyAction: _emberMetal.observer('newFoo', function () { + this.set('newProp', 'changedNewPropValue'); + }), + + notifyAllAction: _emberMetal.observer('prop', function () { + this.set('newFoo', 'changedNewFooValue'); + }), + + starObserver: function (target, key, value, rev) { + this.starProp = key; + } + }).create({ + starProp: null, + + foo: 'fooValue', + prop: 'propValue', + + newFoo: 'newFooValue', + newProp: 'newPropValue' + }); + } + }); + + QUnit.test('should observe the changes within the nested begin / end property changes', function () { + //start the outer nest + ObjectA.beginPropertyChanges(); + + // Inner nest + ObjectA.beginPropertyChanges(); + ObjectA.set('foo', 'changeFooValue'); + + equal(ObjectA.prop, 'propValue'); + ObjectA.endPropertyChanges(); + + //end inner nest + ObjectA.set('prop', 'changePropValue'); + equal(ObjectA.newFoo, 'newFooValue'); + + //close the outer nest + ObjectA.endPropertyChanges(); + + equal(ObjectA.prop, 'changedPropValue'); + equal(ObjectA.newFoo, 'changedNewFooValue'); + }); + + QUnit.test('should observe the changes within the begin and end property changes', function () { + ObjectA.beginPropertyChanges(); + ObjectA.set('foo', 'changeFooValue'); + + equal(ObjectA.prop, 'propValue'); + ObjectA.endPropertyChanges(); + + equal(ObjectA.prop, 'changedPropValue'); + }); + + QUnit.test('should indicate that the property of an object has just changed', function () { + // indicate that property of foo will change to its subscribers + ObjectA.propertyWillChange('foo'); + + //Value of the prop is unchanged yet as this will be changed when foo changes + equal(ObjectA.prop, 'propValue'); + + //change the value of foo. + ObjectA.set('foo', 'changeFooValue'); + + // Indicate the subscribers of foo that the value has just changed + ObjectA.propertyDidChange('foo', null); + + // Values of prop has just changed + equal(ObjectA.prop, 'changedPropValue'); + }); + + QUnit.test('should notify that the property of an object has changed', function () { + // Notify to its subscriber that the values of 'newFoo' will be changed. In this + // case the observer is "newProp". Therefore this will call the notifyAction function + // and value of "newProp" will be changed. + ObjectA.notifyPropertyChange('newFoo', 'fooValue'); + + //value of newProp changed. + equal(ObjectA.newProp, 'changedNewPropValue'); + }); + + QUnit.test('should invalidate function property cache when notifyPropertyChange is called', function () { + var a = ObservableObject.extend({ + b: _emberMetal.computed({ + get: function () { + return this._b; + }, + set: function (key, value) { + this._b = value; + return this; + } + }).volatile() + }).create({ + _b: null + }); + + a.set('b', 'foo'); + equal(a.get('b'), 'foo', 'should have set the correct value for property b'); + + a._b = 'bar'; + a.notifyPropertyChange('b'); + a.set('b', 'foo'); + equal(a.get('b'), 'foo', 'should have invalidated the cache so that the newly set value is actually set'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/binding_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * All calls to run.sync() were changed to + run.sync() + + * Bindings no longer accept a root object as their second param. Instead + our test binding objects were put under a single object they could + originate from. + + * tests that inspected internal properties were removed. + + * converted foo.get/foo.set to use get/Ember.set + + * Removed tests for Binding.isConnected. Since binding instances are now + shared this property no longer makes sense. + + * Changed call calls for obj.bind(...) to bind(obj, ...); + + * Changed all calls to sc_super() to this._super(...arguments) + + * Changed all calls to disconnect() to pass the root object. + + * removed calls to Binding.destroy() as that method is no longer useful + (or defined) + + * changed use of T_STRING to 'string' + */ + + // ======================================================================== + // Binding Tests + // ======================================================================== + + var TestNamespace = undefined, + fromObject = undefined, + toObject = undefined, + binding = undefined, + Bon1 = undefined, + bon2 = undefined, + root = undefined; // global variables + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('basic object binding', { + setup: function () { + fromObject = _emberRuntimeSystemObject.default.create({ value: 'start' }); + toObject = _emberRuntimeSystemObject.default.create({ value: 'end' }); + root = { fromObject: fromObject, toObject: toObject }; + _emberMetal.run(function () { + expectDeprecation(function () { + binding = _emberMetal.bind(root, 'toObject.value', 'fromObject.value'); + }, /`Ember\.Binding` is deprecated./); + }); + } + }); + + QUnit.test('binding should have synced on connect', function () { + equal(_emberMetal.get(toObject, 'value'), 'start', 'toObject.value should match fromObject.value'); + }); + + QUnit.test('fromObject change should propagate to toObject only after flush', function () { + _emberMetal.run(function () { + _emberMetal.set(fromObject, 'value', 'change'); + equal(_emberMetal.get(toObject, 'value'), 'start'); + }); + equal(_emberMetal.get(toObject, 'value'), 'change'); + }); + + QUnit.test('toObject change should propagate to fromObject only after flush', function () { + _emberMetal.run(function () { + _emberMetal.set(toObject, 'value', 'change'); + equal(_emberMetal.get(fromObject, 'value'), 'start'); + }); + equal(_emberMetal.get(fromObject, 'value'), 'change'); + }); + + QUnit.test('deferred observing during bindings', function () { + // setup special binding + fromObject = _emberRuntimeSystemObject.default.create({ + value1: 'value1', + value2: 'value2' + }); + + toObject = _emberRuntimeSystemObject.default.extend({ + observer: _emberMetal.observer('value1', 'value2', function () { + equal(_emberMetal.get(this, 'value1'), 'CHANGED', 'value1 when observer fires'); + equal(_emberMetal.get(this, 'value2'), 'CHANGED', 'value2 when observer fires'); + this.callCount++; + }) + }).create({ + value1: 'value1', + value2: 'value2', + + callCount: 0 + }); + + var root = { fromObject: fromObject, toObject: toObject }; + _emberMetal.run(function () { + expectDeprecation(function () { + _emberMetal.bind(root, 'toObject.value1', 'fromObject.value1'); + }, /`Ember\.Binding` is deprecated./); + + expectDeprecation(function () { + _emberMetal.bind(root, 'toObject.value2', 'fromObject.value2'); + }, /`Ember\.Binding` is deprecated./); + + // change both value1 + value2, then flush bindings. observer should only + // fire after bindings are done flushing. + _emberMetal.set(fromObject, 'value1', 'CHANGED'); + _emberMetal.set(fromObject, 'value2', 'CHANGED'); + }); + + equal(toObject.callCount, 2, 'should call observer twice'); + }); + + QUnit.test('binding disconnection actually works', function () { + binding.disconnect(root); + _emberMetal.run(function () { + _emberMetal.set(fromObject, 'value', 'change'); + }); + equal(_emberMetal.get(toObject, 'value'), 'start'); + }); + + var first = undefined, + second = undefined, + third = undefined; // global variables + + // .......................................................... + // chained binding + // + + QUnit.module('chained binding', { + + setup: function () { + _emberMetal.run(function () { + first = _emberRuntimeSystemObject.default.create({ output: 'first' }); + + second = _emberRuntimeSystemObject.default.extend({ + inputDidChange: _emberMetal.observer('input', function () { + _emberMetal.set(this, 'output', _emberMetal.get(this, 'input')); + }) + }).create({ + input: 'second', + output: 'second' + }); + + third = _emberRuntimeSystemObject.default.create({ input: 'third' }); + + root = { first: first, second: second, third: third }; + + expectDeprecation(function () { + _emberMetal.bind(root, 'second.input', 'first.output'); + }, /`Ember\.Binding` is deprecated./); + + expectDeprecation(function () { + _emberMetal.bind(root, 'second.output', 'third.input'); + }, /`Ember\.Binding` is deprecated./); + }); + }, + teardown: function () { + _emberMetal.run.cancelTimers(); + } + }); + + QUnit.test('changing first output should propagate to third after flush', function () { + _emberMetal.run(function () { + _emberMetal.set(first, 'output', 'change'); + equal('change', _emberMetal.get(first, 'output'), 'first.output'); + ok('change' !== _emberMetal.get(third, 'input'), 'third.input'); + }); + + equal('change', _emberMetal.get(first, 'output'), 'first.output'); + equal('change', _emberMetal.get(second, 'input'), 'second.input'); + equal('change', _emberMetal.get(second, 'output'), 'second.output'); + equal('change', _emberMetal.get(third, 'input'), 'third.input'); + }); + + // .......................................................... + // Custom Binding + // + + QUnit.module('Custom Binding', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + Bon1 = _emberRuntimeSystemObject.default.extend({ + value1: 'hi', + value2: 83, + array1: [] + }); + + bon2 = _emberRuntimeSystemObject.default.create({ + val1: 'hello', + val2: 25, + arr: [1, 2, 3, 4] + }); + + _emberEnvironment.context.lookup['TestNamespace'] = TestNamespace = { + bon2: bon2, + Bon1: Bon1 + }; + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + Bon1 = bon2 = TestNamespace = null; + _emberMetal.run.cancelTimers(); + } + }); + + QUnit.test('two bindings to the same value should sync in the order they are initialized', function () { + _emberMetal.run.begin(); + + var a = _emberRuntimeSystemObject.default.create({ + foo: 'bar' + }); + + var b = _emberRuntimeSystemObject.default.extend({ + C: _emberRuntimeSystemObject.default.extend({ + foo: 'bee', + fooBinding: 'owner.foo' + }), + + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'c', this.C.create({ owner: this })); + } + }); + + expectDeprecation(function () { + b = b.create({ + foo: 'baz', + fooBinding: 'a.foo', + a: a + }); + }, /`Ember\.Binding` is deprecated./); + + _emberMetal.run.end(); + + equal(_emberMetal.get(a, 'foo'), 'bar', 'a.foo should not change'); + equal(_emberMetal.get(b, 'foo'), 'bar', 'a.foo should propagate up to b.foo'); + equal(_emberMetal.get(b.c, 'foo'), 'bar', 'a.foo should propagate up to b.c.foo'); + }); + + // .......................................................... + // propertyNameBinding with longhand + // + + QUnit.module('propertyNameBinding with longhand', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + lookup['TestNamespace'] = TestNamespace = {}; + _emberMetal.run(function () { + TestNamespace.fromObject = _emberRuntimeSystemObject.default.create({ + value: 'originalValue' + }); + + expectDeprecation(function () { + TestNamespace.toObject = _emberRuntimeSystemObject.default.extend({ + valueBinding: _emberMetal.Binding.from('TestNamespace.fromObject.value'), + relativeBinding: _emberMetal.Binding.from('localValue') + }).create({ + localValue: 'originalLocal' + }); + }, /`Ember\.Binding` is deprecated./); + }); + }, + teardown: function () { + TestNamespace = undefined; + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('works with full path', function () { + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.fromObject, 'value', 'updatedValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'value'), 'updatedValue'); + + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.fromObject, 'value', 'newerValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'value'), 'newerValue'); + }); + + QUnit.test('works with local path', function () { + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.toObject, 'localValue', 'updatedValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'relative'), 'updatedValue'); + + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.toObject, 'localValue', 'newerValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'relative'), 'newerValue'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/binding_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/binding_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/binding_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/base_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Changed get(obj, ) and set(obj, ) to Ember.get() and Ember.set() + * Removed obj.instanceOf() and obj.kindOf() tests. use obj instanceof Foo + instead + * Removed respondsTo() and tryToPerform() tests. Can be brought back in a + utils package. + * Removed destroy() test. You can impl yourself but not built in + * Changed Class.subclassOf() test to Class.detect() + * Remove broken test for 'superclass' property. + * Removed obj.didChangeFor() + */ + + // ======================================================================== + // EmberObject Base Tests + // ======================================================================== + + var obj = undefined, + obj1 = undefined; // global variables + + QUnit.module('A new EmberObject instance', { + + setup: function () { + obj = _emberRuntimeSystemObject.default.create({ + foo: 'bar', + total: 12345, + aMethodThatExists: function () {}, + aMethodThatReturnsTrue: function () { + return true; + }, + aMethodThatReturnsFoobar: function () { + return 'Foobar'; + }, + aMethodThatReturnsFalse: function () { + return false; + } + }); + }, + + teardown: function () { + obj = undefined; + } + + }); + + QUnit.test('Should return its properties when requested using EmberObject#get', function () { + equal(_emberMetal.get(obj, 'foo'), 'bar'); + equal(_emberMetal.get(obj, 'total'), 12345); + }); + + QUnit.test('Should allow changing of those properties by calling EmberObject#set', function () { + equal(_emberMetal.get(obj, 'foo'), 'bar'); + equal(_emberMetal.get(obj, 'total'), 12345); + + _emberMetal.set(obj, 'foo', 'Chunky Bacon'); + _emberMetal.set(obj, 'total', 12); + + equal(_emberMetal.get(obj, 'foo'), 'Chunky Bacon'); + equal(_emberMetal.get(obj, 'total'), 12); + }); + + QUnit.module('EmberObject superclass and subclasses', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + method1: function () { + return 'hello'; + } + }); + obj1 = obj.extend(); + }, + + teardown: function () { + obj = undefined; + obj1 = undefined; + } + }); + + QUnit.test('Checking the detect() function on an object and its subclass', function () { + equal(obj.detect(obj1), true); + equal(obj1.detect(obj), false); + }); + + QUnit.test('Checking the detectInstance() function on an object and its subclass', function () { + ok(_emberRuntimeSystemObject.default.detectInstance(obj.create())); + ok(obj.detectInstance(obj.create())); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/base_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/object/base_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/object/base_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/bindings_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * changed Ember.Bending.flushPendingChanges() -> run.sync(); + * changes obj.set() and obj.get() to Ember.set() and Ember.get() + * Fixed an actual bug in unit tests around line 133 + * fixed 'bindings should disconnect on destroy' test to use destroy. + */ + + // ======================================================================== + // EmberObject bindings Tests + // ======================================================================== + + var originalLookup = _emberEnvironment.context.lookup; + var testObject = undefined, + fromObject = undefined, + TestObject = undefined; + var TestNamespace = undefined, + lookup = undefined; + + QUnit.module('bind() method', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + testObject = _emberRuntimeSystemObject.default.create({ + foo: 'bar', + bar: 'foo', + extraObject: null + }); + + fromObject = _emberRuntimeSystemObject.default.create({ + bar: 'foo', + extraObject: null + }); + + lookup['TestNamespace'] = TestNamespace = { + fromObject: fromObject, + testObject: testObject + }; + }, + + teardown: function () { + testObject = fromObject = null; + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('bind(TestNamespace.fromObject.bar) should follow absolute path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject.bind('foo', 'TestNamespace.fromObject.bar'); + }, /`Ember.Binding` is deprecated/); + + // now make a change to see if the binding triggers. + _emberMetal.set(fromObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.test('bind(.bar) should bind to relative path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject.bind('foo', 'bar'); + }, /`Ember.Binding` is deprecated/); + + // now make a change to see if the binding triggers. + _emberMetal.set(testObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.module('fooBinding method', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + TestObject = _emberRuntimeSystemObject.default.extend({ + foo: 'bar', + bar: 'foo', + extraObject: null + }); + + fromObject = _emberRuntimeSystemObject.default.create({ + bar: 'foo', + extraObject: null + }); + + lookup['TestNamespace'] = TestNamespace = { + fromObject: fromObject, + testObject: TestObject + }; + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + TestObject = fromObject = null; + // delete TestNamespace; + } + }); + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + QUnit.test('fooBinding: TestNamespace.fromObject.bar should follow absolute path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject = TestObject.extend({ + fooBinding: 'TestNamespace.fromObject.bar' + }).create(); + }, deprecationMessage); + + // now make a change to see if the binding triggers. + _emberMetal.set(fromObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.test('fooBinding: .bar should bind to relative path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject = TestObject.extend({ + fooBinding: 'bar' + }).create(); + }, deprecationMessage); + + // now make a change to see if the binding triggers. + _emberMetal.set(testObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.test('fooBinding: should disconnect bindings when destroyed', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject = TestObject.extend({ + fooBinding: 'TestNamespace.fromObject.bar' + }).create(); + }, deprecationMessage); + + _emberMetal.set(TestNamespace.fromObject, 'bar', 'BAZ'); + }); + + equal(_emberMetal.get(testObject, 'foo'), 'BAZ', 'binding should have synced'); + + _emberMetal.run(function () { + return testObject.destroy(); + }); + + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.fromObject, 'bar', 'BIFF'); + }); + + ok(_emberMetal.get(testObject, 'foo') !== 'bar', 'binding should not have synced'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/bindings_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/object/bindings_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/object/bindings_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/concatenated_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * changed get(obj, ) and set(obj, ) to Ember.get() and Ember.set() + * converted uses of obj.isEqual() to use deepEqual() test since isEqual is not + always defined + */ + + function K() { + return this; + } + + var klass = undefined; + + QUnit.module('EmberObject Concatenated Properties', { + setup: function () { + klass = _emberRuntimeSystemObject.default.extend({ + concatenatedProperties: ['values', 'functions'], + values: ['a', 'b', 'c'], + functions: [K] + }); + } + }); + + QUnit.test('concatenates instances', function () { + var obj = klass.create({ + values: ['d', 'e', 'f'] + }); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates subclasses', function () { + var subKlass = klass.extend({ + values: ['d', 'e', 'f'] + }); + var obj = subKlass.create(); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates reopen', function () { + klass.reopen({ + values: ['d', 'e', 'f'] + }); + var obj = klass.create(); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates mixin', function () { + var mixin = { + values: ['d', 'e'] + }; + var subKlass = klass.extend(mixin, { + values: ['f'] + }); + var obj = subKlass.create(); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates reopen, subclass, and instance', function () { + klass.reopen({ values: ['d'] }); + var subKlass = klass.extend({ values: ['e'] }); + var obj = subKlass.create({ values: ['f'] }); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates subclasses when the values are functions', function () { + var subKlass = klass.extend({ + functions: K + }); + var obj = subKlass.create(); + + var values = _emberMetal.get(obj, 'functions'); + var expected = [K, K]; + + deepEqual(values, expected, 'should concatenate functions property (expected: ' + expected + ', got: ' + values + ')'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/concatenated_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/object/concatenated_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/object/concatenated_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/run_loop_test', ['exports', 'ember-metal', 'ember-runtime/mixins/observable', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeMixinsObservable, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Updated the API usage for setting up and syncing Binding since these + are not the APIs this file is testing. + + * Disabled a call to invokeOnce() around line 127 because it appeared to be + broken anyway. I don't think it ever even worked. + */ + + var MyApp = undefined; + + QUnit.module('System:run_loop() - chained binding', { + setup: function () { + MyApp = {}; + MyApp.first = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default).create({ + output: 'MyApp.first' + }); + + MyApp.second = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default, { + inputDidChange: _emberMetal.observer('input', function () { + this.set('output', this.get('input')); + }) + }).create({ + input: 'MyApp.second', + output: 'MyApp.second' + }); + + MyApp.third = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default).create({ + input: 'MyApp.third' + }); + } + }); + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + QUnit.test('Should propagate bindings after the RunLoop completes (using Ember.RunLoop)', function () { + _emberMetal.run(function () { + //Binding of output of MyApp.first object to input of MyApp.second object + expectDeprecation(function () { + _emberMetal.Binding.from('first.output').to('second.input').connect(MyApp); + }, deprecationMessage); + + //Binding of output of MyApp.second object to input of MyApp.third object + expectDeprecation(function () { + _emberMetal.Binding.from('second.output').to('third.input').connect(MyApp); + }, deprecationMessage); + }); + + _emberMetal.run(function () { + // Based on the above binding if you change the output of MyApp.first + // object it should change the all the variable of + // MyApp.first,MyApp.second and MyApp.third object + MyApp.first.set('output', 'change'); + + //Changes the output of the MyApp.first object + equal(MyApp.first.get('output'), 'change'); + + //since binding has not taken into effect the value still remains as change. + equal(MyApp.second.get('output'), 'MyApp.first'); + }); // allows bindings to trigger... + + //Value of the output variable changed to 'change' + equal(MyApp.first.get('output'), 'change'); + + //Since binding triggered after the end loop the value changed to 'change'. + equal(MyApp.second.get('output'), 'change'); + }); + + QUnit.test('Should propagate bindings after the RunLoop completes', function () { + _emberMetal.run(function () { + //Binding of output of MyApp.first object to input of MyApp.second object + expectDeprecation(function () { + _emberMetal.Binding.from('first.output').to('second.input').connect(MyApp); + }, deprecationMessage); + + //Binding of output of MyApp.second object to input of MyApp.third object + expectDeprecation(function () { + _emberMetal.Binding.from('second.output').to('third.input').connect(MyApp); + }, deprecationMessage); + }); + + _emberMetal.run(function () { + //Based on the above binding if you change the output of MyApp.first object it should + //change the all the variable of MyApp.first,MyApp.second and MyApp.third object + MyApp.first.set('output', 'change'); + + //Changes the output of the MyApp.first object + equal(MyApp.first.get('output'), 'change'); + + //since binding has not taken into effect the value still remains as change. + equal(MyApp.second.get('output'), 'MyApp.first'); + }); + + //Value of the output variable changed to 'change' + equal(MyApp.first.get('output'), 'change'); + + //Since binding triggered after the end loop the value changed to 'change'. + equal(MyApp.second.get('output'), 'change'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/run_loop_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/run_loop_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/run_loop_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/main_test', ['exports', 'ember-runtime/index'], function (exports, _emberRuntimeIndex) { + 'use strict'; + + QUnit.module('ember-runtime/main'); + + QUnit.test('Ember.computed.collect', function () { + var MyObj = _emberRuntimeIndex.Object.extend({ + props: _emberRuntimeIndex.collect('foo', 'bar', 'baz') + }); + + var myObj = MyObj.create({ + foo: 3, + bar: 5, + baz: 'asdf' + }); + + var propsValue = myObj.get('props'); + + deepEqual(propsValue, [3, 5, 'asdf']); + }); +}); +enifed('ember-runtime/tests/main_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/main_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/main_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/array_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/tests/suites/array', 'ember-runtime/system/object', 'ember-runtime/mixins/array', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeTestsSuitesArray, _emberRuntimeSystemObject, _emberRuntimeMixinsArray, _emberRuntimeSystemNative_array) { + 'use strict'; + + /* + Implement a basic fake mutable array. This validates that any non-native + enumerable can impl this API. + */ + var TestArray = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsArray.default, { + _content: null, + + init: function () { + var ary = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + this._content = ary; + }, + + // some methods to modify the array so we can test changes. Note that + // arrays can be modified even if they don't implement MutableArray. The + // MutableArray is just a standard API for mutation but not required. + addObject: function (obj) { + var idx = this._content.length; + _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, 0, 1); + this._content.push(obj); + _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, 0, 1); + }, + + removeFirst: function (idx) { + _emberRuntimeMixinsArray.arrayContentWillChange(this, 0, 1, 0); + this._content.shift(); + _emberRuntimeMixinsArray.arrayContentDidChange(this, 0, 1, 0); + }, + + objectAt: function (idx) { + return this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }) + }); + + _emberRuntimeTestsSuitesArray.ArrayTests.extend({ + + name: 'Basic Mutable Array', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestArray(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(this.getFixture(1)[0]); + }, + + toArray: function (obj) { + return obj.slice(); + } + + }).run(); + + QUnit.test('the return value of slice has Ember.Array applied', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsArray.default).create({ + length: 0 + }); + var y = x.slice(1); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'mixin should be applied'); + }); + + QUnit.test('slice supports negative index arguments', function () { + var testArray = new TestArray([1, 2, 3, 4]); + + deepEqual(testArray.slice(-2), [3, 4], 'slice(-2)'); + deepEqual(testArray.slice(-2, -1), [3], 'slice(-2, -1'); + deepEqual(testArray.slice(-2, -2), [], 'slice(-2, -2)'); + deepEqual(testArray.slice(-1, -2), [], 'slice(-1, -2)'); + + deepEqual(testArray.slice(-4, 1), [1], 'slice(-4, 1)'); + deepEqual(testArray.slice(-4, 5), [1, 2, 3, 4], 'slice(-4, 5)'); + deepEqual(testArray.slice(-4), [1, 2, 3, 4], 'slice(-4)'); + + deepEqual(testArray.slice(0, -1), [1, 2, 3], 'slice(0, -1)'); + deepEqual(testArray.slice(0, -4), [], 'slice(0, -4)'); + deepEqual(testArray.slice(0, -3), [1], 'slice(0, -3)'); + }); + + // .......................................................... + // CONTENT DID CHANGE + // + + var DummyArray = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsArray.default, { + nextObject: function () {}, + length: 0, + objectAt: function (idx) { + return 'ITEM-' + idx; + } + }); + + var obj = undefined, + observer = undefined; + + // .......................................................... + // NOTIFY ARRAY OBSERVERS + // + + QUnit.module('mixins/array/arrayContent[Will|Did]Change'); + + QUnit.test('should notify observers of []', function () { + obj = DummyArray.extend({ + enumerablePropertyDidChange: _emberMetal.observer('[]', function () { + this._count++; + }) + }).create({ + _count: 0 + }); + + equal(obj._count, 0, 'should not have invoked yet'); + + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + + equal(obj._count, 1, 'should have invoked'); + }); + + // .......................................................... + // NOTIFY CHANGES TO LENGTH + // + + QUnit.module('notify observers of length', { + setup: function () { + obj = DummyArray.extend({ + lengthDidChange: _emberMetal.observer('length', function () { + this._after++; + }) + }).create({ + _after: 0 + }); + + equal(obj._after, 0, 'should not have fired yet'); + }, + + teardown: function () { + obj = null; + } + }); + + QUnit.test('should notify observers when call with no params', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + equal(obj._after, 0); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + equal(obj._after, 1); + }); + + // API variation that included items only + QUnit.test('should not notify when passed lengths are same', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + equal(obj._after, 0); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + equal(obj._after, 0); + }); + + QUnit.test('should notify when passed lengths are different', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 2); + equal(obj._after, 0); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 2); + equal(obj._after, 1); + }); + + // .......................................................... + // NOTIFY ARRAY OBSERVER + // + + QUnit.module('notify array observers', { + setup: function () { + obj = DummyArray.create(); + + observer = _emberRuntimeSystemObject.default.extend({ + arrayWillChange: function () { + equal(this._before, null); // should only call once + this._before = Array.prototype.slice.call(arguments); + }, + + arrayDidChange: function () { + equal(this._after, null); // should only call once + this._after = Array.prototype.slice.call(arguments); + } + }).create({ + _before: null, + _after: null + }); + + _emberRuntimeMixinsArray.addArrayObserver(obj, observer); + }, + + teardown: function () { + obj = observer = null; + } + }); + + QUnit.test('should notify enumerable observers when called with no params', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, [obj, 0, -1, -1]); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, [obj, 0, -1, -1]); + }); + + // API variation that included items only + QUnit.test('should notify when called with same length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + deepEqual(observer._before, [obj, 0, 1, 1]); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + deepEqual(observer._after, [obj, 0, 1, 1]); + }); + + QUnit.test('should notify when called with diff length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 2, 1); + deepEqual(observer._before, [obj, 0, 2, 1]); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 2, 1); + deepEqual(observer._after, [obj, 0, 2, 1]); + }); + + QUnit.test('removing enumerable observer should disable', function () { + _emberRuntimeMixinsArray.removeArrayObserver(obj, observer); + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, null); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, null); + }); + + // .......................................................... + // NOTIFY ENUMERABLE OBSERVER + // + + QUnit.module('notify enumerable observers as well', { + setup: function () { + obj = DummyArray.create(); + + observer = _emberRuntimeSystemObject.default.extend({ + enumerableWillChange: function () { + equal(this._before, null); // should only call once + this._before = Array.prototype.slice.call(arguments); + }, + + enumerableDidChange: function () { + equal(this._after, null); // should only call once + this._after = Array.prototype.slice.call(arguments); + } + }).create({ + _before: null, + _after: null + }); + + obj.addEnumerableObserver(observer); + }, + + teardown: function () { + obj = observer = null; + } + }); + + QUnit.test('should notify enumerable observers when called with no params', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, [obj, null, null], 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, [obj, null, null], 'after'); + }); + + // API variation that included items only + QUnit.test('should notify when called with same length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + deepEqual(observer._before, [obj, ['ITEM-0'], 1], 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + deepEqual(observer._after, [obj, 1, ['ITEM-0']], 'after'); + }); + + QUnit.test('should notify when called with diff length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 2, 1); + deepEqual(observer._before, [obj, ['ITEM-0', 'ITEM-1'], 1], 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 2, 1); + deepEqual(observer._after, [obj, 2, ['ITEM-0']], 'after'); + }); + + QUnit.test('removing enumerable observer should disable', function () { + obj.removeEnumerableObserver(observer); + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, null, 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, null, 'after'); + }); + + // .......................................................... + // @each + // + + var ary = undefined; + + QUnit.module('EmberArray.@each support', { + setup: function () { + ary = new TestArray([{ isDone: true, desc: 'Todo 1' }, { isDone: false, desc: 'Todo 2' }, { isDone: true, desc: 'Todo 3' }, { isDone: false, desc: 'Todo 4' }]); + }, + + teardown: function () { + ary = null; + } + }); + + QUnit.test('adding an object should notify (@each.isDone)', function () { + var called = 0; + + var observerObject = _emberRuntimeSystemObject.default.create({ + wasCalled: function () { + called++; + } + }); + + _emberMetal.addObserver(ary, '@each.isDone', observerObject, 'wasCalled'); + + ary.addObject(_emberRuntimeSystemObject.default.create({ + desc: 'foo', + isDone: false + })); + + equal(called, 1, 'calls observer when object is pushed'); + }); + + QUnit.test('@each is readOnly', function () { + expect(1); + + throws(function () { + _emberMetal.set(ary, '@each', 'foo'); + }, /Cannot set read-only property "@each"/); + }); + + QUnit.test('using @each to observe arrays that does not return objects raise error', function () { + var called = 0; + + var observerObject = _emberRuntimeSystemObject.default.create({ + wasCalled: function () { + called++; + } + }); + + ary = TestArray.create({ + objectAt: function (idx) { + return _emberMetal.get(this._content[idx], 'desc'); + } + }); + + _emberMetal.addObserver(ary, '@each.isDone', observerObject, 'wasCalled'); + + expectAssertion(function () { + ary.addObject(_emberRuntimeSystemObject.default.create({ + desc: 'foo', + isDone: false + })); + }, /When using @each to observe the array/); + + equal(called, 0, 'not calls observer when object is pushed'); + }); + + QUnit.test('modifying the array should also indicate the isDone prop itself has changed', function () { + // NOTE: we never actually get the '@each.isDone' property here. This is + // important because it tests the case where we don't have an isDone + // EachArray materialized but just want to know when the property has + // changed. + + var each = _emberMetal.get(ary, '@each'); + var count = 0; + + _emberMetal.addObserver(each, 'isDone', function () { + return count++; + }); + + count = 0; + var item = _emberRuntimeMixinsArray.objectAt(ary, 2); + _emberMetal.set(item, 'isDone', !_emberMetal.get(item, 'isDone')); + equal(count, 1, '@each.isDone should have notified'); + }); + + QUnit.test('`objectAt` returns correct object', function () { + var arr = ['first', 'second', 'third', 'fourth']; + equal(_emberRuntimeMixinsArray.objectAt(arr, 2), 'third'); + equal(_emberRuntimeMixinsArray.objectAt(arr, 4), undefined); + }); + + _internalTestHelpers.testBoth('should be clear caches for computed properties that have dependent keys on arrays that are changed after object initialization', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + init: function () { + this._super.apply(this, arguments); + set(this, 'resources', _emberRuntimeSystemNative_array.A()); + }, + + common: _emberMetal.computed('resources.@each.common', function () { + return get(_emberRuntimeMixinsArray.objectAt(get(this, 'resources'), 0), 'common'); + }) + }).create(); + + get(obj, 'resources').pushObject(_emberRuntimeSystemObject.default.create({ common: 'HI!' })); + equal('HI!', get(obj, 'common')); + + set(_emberRuntimeMixinsArray.objectAt(get(obj, 'resources'), 0), 'common', 'BYE!'); + equal('BYE!', get(obj, 'common')); + }); + + _internalTestHelpers.testBoth('observers that contain @each in the path should fire only once the first time they are accessed', function (get, set) { + var count = 0; + + var obj = _emberRuntimeSystemObject.default.extend({ + init: function () { + this._super.apply(this, arguments); + // Observer does not fire on init + set(this, 'resources', _emberRuntimeSystemNative_array.A()); + }, + + commonDidChange: _emberMetal.observer('resources.@each.common', function () { + return count++; + }) + }).create(); + + // Observer fires second time when new object is added + get(obj, 'resources').pushObject(_emberRuntimeSystemObject.default.create({ common: 'HI!' })); + // Observer fires third time when property on an object is changed + set(_emberRuntimeMixinsArray.objectAt(get(obj, 'resources'), 0), 'common', 'BYE!'); + + equal(count, 2, 'observers should only be called once'); + }); +}); +enifed('ember-runtime/tests/mixins/array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/comparable_test', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/compare', 'ember-runtime/mixins/comparable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeCompare, _emberRuntimeMixinsComparable) { + 'use strict'; + + var Rectangle = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsComparable.default, { + length: 0, + width: 0, + + area: function () { + return _emberMetal.get(this, 'length') * _emberMetal.get(this, 'width'); + }, + + compare: function (a, b) { + return _emberRuntimeCompare.default(a.area(), b.area()); + } + + }); + + var r1 = undefined, + r2 = undefined; + + QUnit.module('Comparable', { + setup: function () { + r1 = Rectangle.create({ length: 6, width: 12 }); + r2 = Rectangle.create({ length: 6, width: 13 }); + } + }); + + QUnit.test('should be comparable and return the correct result', function () { + equal(_emberRuntimeMixinsComparable.default.detect(r1), true); + equal(_emberRuntimeCompare.default(r1, r1), 0); + equal(_emberRuntimeCompare.default(r1, r2), -1); + equal(_emberRuntimeCompare.default(r2, r1), 1); + }); +}); +enifed('ember-runtime/tests/mixins/comparable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/comparable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/comparable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/container_proxy_test', ['exports', 'ember-utils', 'container', 'ember-runtime/mixins/container_proxy', 'ember-runtime/system/object'], function (exports, _emberUtils, _container, _emberRuntimeMixinsContainer_proxy, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('ember-runtime/mixins/container_proxy', { + setup: function () { + this.Owner = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsContainer_proxy.default); + this.instance = this.Owner.create(); + + var registry = new _container.Registry(); + + this.instance.__container__ = new _container.Container(registry, { + owner: this.instance + }); + } + }); + + QUnit.test('provides ownerInjection helper method', function (assert) { + var result = this.instance.ownerInjection(); + + assert.equal(result[_emberUtils.OWNER], this.instance, 'returns an object with the OWNER symbol'); + }); +}); +enifed('ember-runtime/tests/mixins/container_proxy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/container_proxy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/container_proxy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/copyable_test', ['exports', 'ember-utils', 'ember-runtime/tests/suites/copyable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeTestsSuitesCopyable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + QUnit.module('Ember.Copyable.frozenCopy'); + + QUnit.test('should be deprecated', function () { + expectDeprecation('`frozenCopy` is deprecated, use `Object.freeze` instead.'); + + var Obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsFreezable.Freezable, _emberRuntimeMixinsCopyable.default, { + copy: function () { + return Obj.create(); + } + }); + + Obj.create().frozenCopy(); + }); + + var CopyableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsCopyable.default, { + id: null, + + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'id', _emberUtils.generateGuid()); + }, + + copy: function () { + var ret = new CopyableObject(); + _emberMetal.set(ret, 'id', _emberMetal.get(this, 'id')); + return ret; + } + }); + + _emberRuntimeTestsSuitesCopyable.default.extend({ + + name: 'Copyable Basic Test', + + newObject: function () { + return new CopyableObject(); + }, + + isEqual: function (a, b) { + if (!(a instanceof CopyableObject) || !(b instanceof CopyableObject)) { + return false; + } + + return _emberMetal.get(a, 'id') === _emberMetal.get(b, 'id'); + } + }).run(); +}); +enifed('ember-runtime/tests/mixins/copyable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/copyable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/copyable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/enumerable_test', ['exports', 'ember-runtime/tests/suites/enumerable', 'ember-runtime/system/object', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array', 'ember-runtime/system/native_array', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesEnumerable, _emberRuntimeSystemObject, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray, _emberRuntimeSystemNative_array, _emberMetal) { + 'use strict'; + + function K() { + return this; + } + + /* + Implement a basic fake enumerable. This validates that any non-native + enumerable can impl this API. + */ + var TestEnumerable = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + _content: null, + + init: function () { + var ary = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + this._content = ary; + }, + + addObject: function (obj) { + if (this._content.indexOf(obj) >= 0) { + return this; + } + + this._content.push(obj); + this.enumerableContentDidChange(); + }, + + nextObject: function (idx) { + return idx >= _emberMetal.get(this, 'length') ? undefined : this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }), + + slice: function () { + return this._content.slice(); + } + + }); + + _emberRuntimeTestsSuitesEnumerable.default.extend({ + name: 'Basic Enumerable', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestEnumerable(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(obj._content.length + 1); + }, + + toArray: function (obj) { + return obj.slice(); + } + + }).run(); + + QUnit.module('Ember.Enumerable'); + + QUnit.test('should apply Ember.Array to return value of map', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.map(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of filter', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.filter(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of invoke', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.invoke(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of toArray', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.toArray(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of without', function () { + var X = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + contains: function () { + return true; + }, + includes: function () { + return true; + } + }); + + var x = X.create(); + var y = x.without(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of uniq', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.uniq(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('any', function () { + var kittens = _emberRuntimeSystemNative_array.A([{ + color: 'white' + }, { + color: 'black' + }, { + color: 'white' + }]); + var foundWhite = kittens.any(function (kitten) { + return kitten.color === 'white'; + }); + var foundWhite2 = kittens.isAny('color', 'white'); + + equal(foundWhite, true); + equal(foundWhite2, true); + }); + + QUnit.test('any with NaN', function () { + var numbers = _emberRuntimeSystemNative_array.A([1, 2, NaN, 4]); + + var hasNaN = numbers.any(function (n) { + return isNaN(n); + }); + + equal(hasNaN, true, 'works when matching NaN'); + }); + + QUnit.test('every', function () { + var allColorsKittens = _emberRuntimeSystemNative_array.A([{ + color: 'white' + }, { + color: 'black' + }, { + color: 'white' + }]); + var allWhiteKittens = _emberRuntimeSystemNative_array.A([{ + color: 'white' + }, { + color: 'white' + }, { + color: 'white' + }]); + var allWhite = false; + var whiteKittenPredicate = function (kitten) { + return kitten.color === 'white'; + }; + + allWhite = allColorsKittens.every(whiteKittenPredicate); + equal(allWhite, false); + + allWhite = allWhiteKittens.every(whiteKittenPredicate); + equal(allWhite, true); + + allWhite = allColorsKittens.isEvery('color', 'white'); + equal(allWhite, false); + + allWhite = allWhiteKittens.isEvery('color', 'white'); + equal(allWhite, true); + }); + + QUnit.test('should throw an error passing a second argument to includes', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + + equal(x.includes('any'), false); + expectAssertion(function () { + x.includes('any', 1); + }, /Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered./); + }); + + // .......................................................... + // CONTENT DID CHANGE + // + + var DummyEnum = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + nextObject: function () {}, + length: 0 + }); + + var obj = undefined, + observer = undefined; + + // .......................................................... + // NOTIFY ENUMERABLE PROPERTY + // + + QUnit.module('mixins/enumerable/enumerableContentDidChange'); + + QUnit.test('should notify observers of []', function () { + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + nextObject: function () {}, // avoid exceptions + + enumerablePropertyDidChange: _emberMetal.observer('[]', function () { + this._count++; + }) + }).create({ + _count: 0 + }); + + equal(obj._count, 0, 'should not have invoked yet'); + obj.enumerableContentWillChange(); + obj.enumerableContentDidChange(); + equal(obj._count, 1, 'should have invoked'); + }); + + // .......................................................... + // NOTIFY CHANGES TO LENGTH + // + + QUnit.module('notify observers of length', { + setup: function () { + obj = DummyEnum.extend({ + lengthDidChange: _emberMetal.observer('length', function () { + this._after++; + }) + }).create({ + _after: 0 + }); + + equal(obj._after, 0, 'should not have fired yet'); + }, + + teardown: function () { + obj = null; + } + }); + + QUnit.test('should notify observers when call with no params', function () { + obj.enumerableContentWillChange(); + equal(obj._after, 0); + + obj.enumerableContentDidChange(); + equal(obj._after, 1); + }); + + // API variation that included items only + QUnit.test('should not notify when passed arrays of same length', function () { + var added = ['foo']; + var removed = ['bar']; + + obj.enumerableContentWillChange(removed, added); + equal(obj._after, 0); + + obj.enumerableContentDidChange(removed, added); + equal(obj._after, 0); + }); + + QUnit.test('should notify when passed arrays of different length', function () { + var added = ['foo']; + var removed = ['bar', 'baz']; + + obj.enumerableContentWillChange(removed, added); + equal(obj._after, 0); + + obj.enumerableContentDidChange(removed, added); + equal(obj._after, 1); + }); + + // API variation passes indexes only + QUnit.test('should not notify when passed with indexes', function () { + obj.enumerableContentWillChange(1, 1); + equal(obj._after, 0); + + obj.enumerableContentDidChange(1, 1); + equal(obj._after, 0); + }); + + QUnit.test('should notify when passed old index API with delta', function () { + obj.enumerableContentWillChange(1, 2); + equal(obj._after, 0); + + obj.enumerableContentDidChange(1, 2); + equal(obj._after, 1); + }); + + // .......................................................... + // NOTIFY ENUMERABLE OBSERVER + // + + QUnit.module('notify enumerable observers', { + setup: function () { + obj = DummyEnum.create(); + + observer = _emberRuntimeSystemObject.default.extend({ + enumerableWillChange: function () { + equal(this._before, null); // should only call once + this._before = Array.prototype.slice.call(arguments); + }, + + enumerableDidChange: function () { + equal(this._after, null); // should only call once + this._after = Array.prototype.slice.call(arguments); + } + }).create({ + _before: null, + _after: null + }); + + obj.addEnumerableObserver(observer); + }, + + teardown: function () { + obj = observer = null; + } + }); + + QUnit.test('should notify enumerable observers when called with no params', function () { + obj.enumerableContentWillChange(); + deepEqual(observer._before, [obj, null, null]); + + obj.enumerableContentDidChange(); + deepEqual(observer._after, [obj, null, null]); + }); + + // API variation that included items only + QUnit.test('should notify when called with same length items', function () { + var added = ['foo']; + var removed = ['bar']; + + obj.enumerableContentWillChange(removed, added); + deepEqual(observer._before, [obj, removed, added]); + + obj.enumerableContentDidChange(removed, added); + deepEqual(observer._after, [obj, removed, added]); + }); + + QUnit.test('should notify when called with diff length items', function () { + var added = ['foo', 'baz']; + var removed = ['bar']; + + obj.enumerableContentWillChange(removed, added); + deepEqual(observer._before, [obj, removed, added]); + + obj.enumerableContentDidChange(removed, added); + deepEqual(observer._after, [obj, removed, added]); + }); + + QUnit.test('should not notify when passed with indexes only', function () { + obj.enumerableContentWillChange(1, 2); + deepEqual(observer._before, [obj, 1, 2]); + + obj.enumerableContentDidChange(1, 2); + deepEqual(observer._after, [obj, 1, 2]); + }); + + QUnit.test('removing enumerable observer should disable', function () { + obj.removeEnumerableObserver(observer); + obj.enumerableContentWillChange(); + deepEqual(observer._before, null); + + obj.enumerableContentDidChange(); + deepEqual(observer._after, null); + }); +}); +enifed('ember-runtime/tests/mixins/enumerable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/enumerable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/enumerable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/freezable_test', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/freezable'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsFreezable) { + 'use strict'; + + QUnit.module('Ember.Freezable'); + + QUnit.test('should be deprecated', function () { + expectDeprecation('`Ember.Freezable` is deprecated, use `Object.freeze` instead.'); + _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsFreezable.Freezable).create(); + }); +}); +enifed('ember-runtime/tests/mixins/freezable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/freezable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/freezable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/mutable_array_test', ['exports', 'ember-metal', 'ember-runtime/tests/suites/mutable_array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/system/object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeTestsSuitesMutable_array, _emberRuntimeMixinsMutable_array, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array, _emberRuntimeMixinsArray) { + 'use strict'; + + /* + Implement a basic fake mutable array. This validates that any non-native + enumerable can impl this API. + */ + var TestMutableArray = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { + + _content: null, + + init: function () { + var ary = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + this._content = _emberRuntimeSystemNative_array.A(ary); + }, + + replace: function (idx, amt, objects) { + var args = objects ? objects.slice() : []; + var removeAmt = amt; + var addAmt = args.length; + + _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, removeAmt, addAmt); + + args.unshift(amt); + args.unshift(idx); + this._content.splice.apply(this._content, args); + _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, removeAmt, addAmt); + return this; + }, + + objectAt: function (idx) { + return this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }), + + slice: function () { + return this._content.slice(); + } + + }); + + _emberRuntimeTestsSuitesMutable_array.default.extend({ + + name: 'Basic Mutable Array', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestMutableArray(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(this.getFixture(1)[0]); + }, + + toArray: function (obj) { + return obj.slice(); + } + + }).run(); +}); +enifed('ember-runtime/tests/mixins/mutable_array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/mutable_array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/mutable_array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/mutable_enumerable_test', ['exports', 'ember-runtime/tests/suites/mutable_enumerable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesMutable_enumerable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + /* + Implement a basic fake mutable array. This validates that any non-native + enumerable can impl this API. + */ + var TestMutableEnumerable = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_enumerable.default, { + _content: null, + + addObject: function (obj) { + if (this._content.indexOf(obj) >= 0) { + return this; + } + + this.enumerableContentWillChange(null, [obj]); + this._content.push(obj); + this.enumerableContentDidChange(null, [obj]); + }, + + removeObject: function (obj) { + var idx = this._content.indexOf(obj); + if (idx < 0) { + return this; + } + + this.enumerableContentWillChange([obj], null); + this._content.splice(idx, 1); + this.enumerableContentDidChange([obj], null); + return this; + }, + + init: function (ary) { + this._content = ary || []; + }, + + nextObject: function (idx) { + return idx >= _emberMetal.get(this, 'length') ? undefined : this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }), + + slice: function () { + return this._content.slice(); + } + }); + + _emberRuntimeTestsSuitesMutable_enumerable.default.extend({ + name: 'Basic Mutable Array', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestMutableEnumerable(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(this.getFixture(1)[0]); + }, + + toArray: function (obj) { + return obj.slice(); + } + }).run(); +}); +enifed('ember-runtime/tests/mixins/mutable_enumerable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/mutable_enumerable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/mutable_enumerable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/observable_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('mixins/observable'); + + QUnit.test('should be able to use getProperties to get a POJO of provided keys', function () { + var obj = _emberRuntimeSystemObject.default.create({ + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }); + + var pojo = obj.getProperties('firstName', 'lastName'); + equal('Steve', pojo.firstName); + equal('Jobs', pojo.lastName); + }); + + QUnit.test('should be able to use getProperties with array parameter to get a POJO of provided keys', function () { + var obj = _emberRuntimeSystemObject.default.create({ + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }); + + var pojo = obj.getProperties(['firstName', 'lastName']); + equal('Steve', pojo.firstName); + equal('Jobs', pojo.lastName); + }); + + QUnit.test('should be able to use setProperties to set multiple properties at once', function () { + var obj = _emberRuntimeSystemObject.default.create({ + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }); + + obj.setProperties({ firstName: 'Tim', lastName: 'Cook' }); + equal('Tim', obj.get('firstName')); + equal('Cook', obj.get('lastName')); + }); + + _internalTestHelpers.testBoth('calling setProperties completes safely despite exceptions', function (get, set) { + var exc = new Error('Something unexpected happened!'); + var obj = _emberRuntimeSystemObject.default.extend({ + companyName: _emberMetal.computed({ + get: function () { + return 'Apple, Inc.'; + }, + set: function (key, value) { + throw exc; + } + }) + }).create({ + firstName: 'Steve', + lastName: 'Jobs' + }); + + var firstNameChangedCount = 0; + + _emberMetal.addObserver(obj, 'firstName', function () { + return firstNameChangedCount++; + }); + + try { + obj.setProperties({ + firstName: 'Tim', + lastName: 'Cook', + companyName: 'Fruit Co., Inc.' + }); + } catch (err) { + if (err !== exc) { + throw err; + } + } + + equal(firstNameChangedCount, 1, 'firstName should have fired once'); + }); + + _internalTestHelpers.testBoth('should be able to retrieve cached values of computed properties without invoking the computed property', function (get) { + var obj = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'foo'; + }) + }).create({ + bar: 'bar' + }); + + equal(obj.cacheFor('foo'), undefined, 'should return undefined if no value has been cached'); + get(obj, 'foo'); + + equal(get(obj, 'foo'), 'foo', 'precond - should cache the value'); + equal(obj.cacheFor('foo'), 'foo', 'should return the cached value after it is invoked'); + + equal(obj.cacheFor('bar'), undefined, 'returns undefined if the value is not a computed property'); + }); + + QUnit.test('incrementProperty should work even if value is number in string', function () { + var obj = _emberRuntimeSystemObject.default.create({ + age: '24' + }); + obj.incrementProperty('age'); + equal(25, obj.get('age')); + }); +}); +enifed('ember-runtime/tests/mixins/observable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/observable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/observable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/promise_proxy_test', ['exports', 'ember-metal', 'ember-runtime/system/object_proxy', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/ext/rsvp', 'rsvp'], function (exports, _emberMetal, _emberRuntimeSystemObject_proxy, _emberRuntimeMixinsPromise_proxy, _emberRuntimeExtRsvp, _rsvp) { + 'use strict'; + + var ObjectPromiseProxy = undefined; + + QUnit.test('present on ember namespace', function () { + ok(_emberRuntimeMixinsPromise_proxy.default, 'expected PromiseProxyMixin to exist'); + }); + + QUnit.module('Ember.PromiseProxy - ObjectProxy', { + setup: function () { + ObjectPromiseProxy = _emberRuntimeSystemObject_proxy.default.extend(_emberRuntimeMixinsPromise_proxy.default); + }, + + teardown: function () { + _rsvp.on('error', _emberRuntimeExtRsvp.onerrorDefault); + } + }); + + QUnit.test('no promise, invoking then should raise', function () { + var proxy = ObjectPromiseProxy.create(); + + throws(function () { + proxy.then(function () { + return this; + }, function () { + return this; + }); + }, new RegExp('PromiseProxy\'s promise must be set')); + }); + + QUnit.test('fulfillment', function () { + var value = { + firstName: 'stef', + lastName: 'penner' + }; + + var deferred = _rsvp.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + var didFulfillCount = 0; + var didRejectCount = 0; + + proxy.then(function () { + return didFulfillCount++; + }, function () { + return didRejectCount++; + }); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + equal(didFulfillCount, 0, 'should not yet have been fulfilled'); + equal(didRejectCount, 0, 'should not yet have been rejected'); + + _emberMetal.run(deferred, 'resolve', value); + + equal(didFulfillCount, 1, 'should have been fulfilled'); + equal(didRejectCount, 0, 'should not have been rejected'); + + equal(_emberMetal.get(proxy, 'content'), value, 'expects the proxy to have content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy to still have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled'); + + _emberMetal.run(deferred, 'resolve', value); + + equal(didFulfillCount, 1, 'should still have been only fulfilled once'); + equal(didRejectCount, 0, 'should still not have been rejected'); + + _emberMetal.run(deferred, 'reject', value); + + equal(didFulfillCount, 1, 'should still have been only fulfilled once'); + equal(didRejectCount, 0, 'should still not have been rejected'); + + equal(_emberMetal.get(proxy, 'content'), value, 'expects the proxy to have still have same content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy still to have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled'); + + // rest of the promise semantics are tested in directly in RSVP + }); + + QUnit.test('rejection', function () { + var reason = new Error('failure'); + var deferred = _rsvp.defer(); + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + var didFulfillCount = 0; + var didRejectCount = 0; + + proxy.then(function () { + return didFulfillCount++; + }, function () { + return didRejectCount++; + }); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + equal(didFulfillCount, 0, 'should not yet have been fulfilled'); + equal(didRejectCount, 0, 'should not yet have been rejected'); + + _emberMetal.run(deferred, 'reject', reason); + + equal(didFulfillCount, 0, 'should not yet have been fulfilled'); + equal(didRejectCount, 1, 'should have been rejected'); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), reason, 'expects the proxy to have a reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + _emberMetal.run(deferred, 'reject', reason); + + equal(didFulfillCount, 0, 'should stll not yet have been fulfilled'); + equal(didRejectCount, 1, 'should still remain rejected'); + + _emberMetal.run(deferred, 'resolve', 1); + + equal(didFulfillCount, 0, 'should stll not yet have been fulfilled'); + equal(didRejectCount, 1, 'should still remain rejected'); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), reason, 'expects the proxy to have a reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + }); + + QUnit.test('unhandled rejects still propagate to RSVP.on(\'error\', ...) ', function () { + expect(1); + + _rsvp.on('error', onerror); + _rsvp.off('error', _emberRuntimeExtRsvp.onerrorDefault); + + var expectedReason = new Error('failure'); + var deferred = _rsvp.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.get('promise'); + + function onerror(reason) { + equal(reason, expectedReason, 'expected reason'); + } + + _rsvp.on('error', onerror); + _rsvp.off('error', _emberRuntimeExtRsvp.onerrorDefault); + + _emberMetal.run(deferred, 'reject', expectedReason); + + _rsvp.on('error', _emberRuntimeExtRsvp.onerrorDefault); + _rsvp.off('error', onerror); + + _emberMetal.run(deferred, 'reject', expectedReason); + + _rsvp.on('error', _emberRuntimeExtRsvp.onerrorDefault); + _rsvp.off('error', onerror); + }); + + QUnit.test('should work with promise inheritance', function () { + function PromiseSubclass() { + _rsvp.Promise.apply(this, arguments); + } + + PromiseSubclass.prototype = Object.create(_rsvp.Promise.prototype); + PromiseSubclass.prototype.constructor = PromiseSubclass; + PromiseSubclass.cast = _rsvp.Promise.cast; + + var proxy = ObjectPromiseProxy.create({ + promise: new PromiseSubclass(function () {}) + }); + + ok(proxy.then() instanceof PromiseSubclass, 'promise proxy respected inheritance'); + }); + + QUnit.test('should reset isFulfilled and isRejected when promise is reset', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled'); + + var anotherDeferred = _emberRuntimeExtRsvp.default.defer(); + proxy.set('promise', anotherDeferred.promise); + + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + _emberMetal.run(anotherDeferred, 'reject'); + + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + }); + + QUnit.test('should have content when isFulfilled is set', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.addObserver('isFulfilled', function () { + return equal(_emberMetal.get(proxy, 'content'), true); + }); + + _emberMetal.run(deferred, 'resolve', true); + }); + + QUnit.test('should have reason when isRejected is set', function () { + var error = new Error('Y U REJECT?!?'); + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.addObserver('isRejected', function () { + return equal(_emberMetal.get(proxy, 'reason'), error); + }); + + try { + _emberMetal.run(deferred, 'reject', error); + } catch (e) { + equal(e, error); + } + }); + + QUnit.test('should not error if promise is resolved after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function () {}, function () {}); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'resolve', true); + + ok(true, 'resolving the promise after the proxy has been destroyed does not raise an error'); + }); + + QUnit.test('should not error if promise is rejected after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function () {}, function () {}); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'reject', 'some reason'); + + ok(true, 'rejecting the promise after the proxy has been destroyed does not raise an error'); + }); + + QUnit.test('promise chain is not broken if promised is resolved after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + var expectedValue = {}; + var receivedValue = undefined; + var didResolveCount = 0; + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function (value) { + receivedValue = value; + didResolveCount++; + }, function () {}); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'resolve', expectedValue); + + equal(didResolveCount, 1, 'callback called'); + equal(receivedValue, expectedValue, 'passed value is the value the promise was resolved with'); + }); + + QUnit.test('promise chain is not broken if promised is rejected after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + var expectedReason = 'some reason'; + var receivedReason = undefined; + var didRejectCount = 0; + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function () {}, function (reason) { + receivedReason = reason; + didRejectCount++; + }); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'reject', expectedReason); + + equal(didRejectCount, 1, 'callback called'); + equal(receivedReason, expectedReason, 'passed reason is the reason the promise was rejected for'); + }); +}); +enifed('ember-runtime/tests/mixins/promise_proxy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/promise_proxy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/promise_proxy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/target_action_support_test', ['exports', 'ember-environment', 'ember-runtime/system/object', 'ember-runtime/mixins/target_action_support'], function (exports, _emberEnvironment, _emberRuntimeSystemObject, _emberRuntimeMixinsTarget_action_support) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('TargetActionSupport', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('it should return false if no target or action are specified', function () { + expect(1); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create(); + + ok(false === obj.triggerAction(), 'no target or action was specified'); + }); + + QUnit.test('it should support actions specified as strings', function () { + expect(2); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called'); + } + }), + + action: 'anEvent' + }); + + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should invoke the send() method on objects that implement it', function () { + expect(3); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + send: function (evt, context) { + equal(evt, 'anEvent', 'send() method was invoked with correct event name'); + equal(context, obj, 'send() method was invoked with correct context'); + } + }), + + action: 'anEvent' + }); + + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should find targets specified using a property path', function () { + expect(2); + + var Test = {}; + lookup.Test = Test; + + Test.targetObj = _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called on global object'); + } + }); + + var myObj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: 'Test.targetObj', + action: 'anEvent' + }); + + ok(true === myObj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should use an actionContext object specified as a property on the object', function () { + expect(2); + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + action: 'anEvent', + actionContext: {}, + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(obj.actionContext === ctx, 'anEvent method was called with the expected context'); + } + }) + }); + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should find an actionContext specified as a property path', function () { + expect(2); + + var Test = {}; + lookup.Test = Test; + Test.aContext = {}; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + action: 'anEvent', + actionContext: 'Test.aContext', + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(Test.aContext === ctx, 'anEvent method was called with the expected context'); + } + }) + }); + + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should use the target specified in the argument', function () { + expect(2); + var targetObj = _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called'); + } + }); + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + action: 'anEvent' + }); + + ok(true === obj.triggerAction({ target: targetObj }), 'a valid target and action were specified'); + }); + + QUnit.test('it should use the action specified in the argument', function () { + expect(2); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called'); + } + }) + }); + ok(true === obj.triggerAction({ action: 'anEvent' }), 'a valid target and action were specified'); + }); + + QUnit.test('it should use the actionContext specified in the argument', function () { + expect(2); + var context = {}; + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(context === ctx, 'anEvent method was called with the expected context'); + } + }), + action: 'anEvent' + }); + + ok(true === obj.triggerAction({ actionContext: context }), 'a valid target and action were specified'); + }); + + QUnit.test('it should allow multiple arguments from actionContext', function () { + expect(3); + var param1 = 'someParam'; + var param2 = 'someOtherParam'; + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (first, second) { + ok(first === param1, 'anEvent method was called with the expected first argument'); + ok(second === param2, 'anEvent method was called with the expected second argument'); + } + }), + action: 'anEvent' + }); + + ok(true === obj.triggerAction({ actionContext: [param1, param2] }), 'a valid target and action were specified'); + }); + + QUnit.test('it should use a null value specified in the actionContext argument', function () { + expect(2); + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(null === ctx, 'anEvent method was called with the expected context (null)'); + } + }), + action: 'anEvent' + }); + ok(true === obj.triggerAction({ actionContext: null }), 'a valid target and action were specified'); + }); +}); +enifed('ember-runtime/tests/mixins/target_action_support_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/target_action_support_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/target_action_support_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array', ['exports', 'ember-runtime/tests/suites/enumerable', 'ember-runtime/tests/suites/array/indexOf', 'ember-runtime/tests/suites/array/lastIndexOf', 'ember-runtime/tests/suites/array/objectAt', 'ember-runtime/tests/suites/array/includes', 'ember-runtime/mixins/array'], function (exports, _emberRuntimeTestsSuitesEnumerable, _emberRuntimeTestsSuitesArrayIndexOf, _emberRuntimeTestsSuitesArrayLastIndexOf, _emberRuntimeTestsSuitesArrayObjectAt, _emberRuntimeTestsSuitesArrayIncludes, _emberRuntimeMixinsArray) { + 'use strict'; + + var ObserverClass = _emberRuntimeTestsSuitesEnumerable.ObserverClass.extend({ + observeArray: function (obj) { + _emberRuntimeMixinsArray.addArrayObserver(obj, this); + return this; + }, + + stopObserveArray: function (obj) { + _emberRuntimeMixinsArray.removeArrayObserver(obj, this); + return this; + }, + + arrayWillChange: function () { + equal(this._before, null, 'should only call once'); + this._before = Array.prototype.slice.call(arguments); + }, + + arrayDidChange: function () { + equal(this._after, null, 'should only call once'); + this._after = Array.prototype.slice.call(arguments); + } + }); + + var ArrayTests = _emberRuntimeTestsSuitesEnumerable.EnumerableTests.extend({ + observerClass: ObserverClass + }); + + ArrayTests.ObserverClass = ObserverClass; + + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayIndexOf.default); + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayLastIndexOf.default); + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayObjectAt.default); + + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayIncludes.default); + + exports.ArrayTests = ArrayTests; + exports.ObserverClass = ObserverClass; +}); +enifed('ember-runtime/tests/suites/array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/includes', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('includes'); + + suite.test('includes returns correct value if startAt is positive', function () { + var data = this.newFixture(3); + var obj = this.newObject(data); + + equal(obj.includes(data[1], 1), true, 'should return true if included'); + equal(obj.includes(data[0], 1), false, 'should return false if not included'); + }); + + suite.test('includes returns correct value if startAt is negative', function () { + var data = this.newFixture(3); + var obj = this.newObject(data); + + equal(obj.includes(data[1], -2), true, 'should return true if included'); + equal(obj.includes(data[0], -2), false, 'should return false if not included'); + }); + + suite.test('includes returns true if startAt + length is still negative', function () { + var data = this.newFixture(1); + var obj = this.newObject(data); + + equal(obj.includes(data[0], -2), true, 'should return true if included'); + equal(obj.includes(this.newFixture(1), -2), false, 'should return false if not included'); + }); + + suite.test('includes returns false if startAt out of bounds', function () { + var data = this.newFixture(1); + var obj = this.newObject(data); + + equal(obj.includes(data[0], 2), false, 'should return false if startAt >= length'); + equal(obj.includes(this.newFixture(1), 2), false, 'should return false if startAt >= length'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/includes.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/includes.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/includes.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/indexOf', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('indexOf'); + + suite.test('should return index of object', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.indexOf(expected[idx]), idx, 'obj.indexOf(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return -1 when requesting object not in index', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.indexOf(foo), -1, 'obj.indexOf(foo) should be < 0'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/indexOf.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/indexOf.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/indexOf.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/lastIndexOf', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('lastIndexOf'); + + suite.test('should return index of object\'s last occurrence', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.lastIndexOf(expected[idx]), idx, 'obj.lastIndexOf(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return index of object\'s last occurrence even startAt search location is equal to length', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.lastIndexOf(expected[idx], len), idx, 'obj.lastIndexOfs(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return index of object\'s last occurrence even startAt search location is greater than length', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.lastIndexOf(expected[idx], len + 1), idx, 'obj.lastIndexOf(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return -1 when no match is found', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.lastIndexOf(foo), -1, 'obj.lastIndexOf(foo) should be -1'); + }); + + suite.test('should return -1 when no match is found even startAt search location is equal to length', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.lastIndexOf(foo, obj.length), -1, 'obj.lastIndexOf(foo) should be -1'); + }); + + suite.test('should return -1 when no match is found even startAt search location is greater than length', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.lastIndexOf(foo, obj.length + 1), -1, 'obj.lastIndexOf(foo) should be -1'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/lastIndexOf.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/lastIndexOf.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/lastIndexOf.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/objectAt', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/mixins/array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeMixinsArray) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('objectAt'); + + suite.test('should return object at specified index', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = expected.length; + + for (var idx = 0; idx < len; idx++) { + equal(_emberRuntimeMixinsArray.objectAt(obj, idx), expected[idx], 'obj.objectAt(' + idx + ') should match'); + } + }); + + suite.test('should return undefined when requesting objects beyond index', function () { + var obj = undefined; + + obj = this.newObject(this.newFixture(3)); + equal(_emberRuntimeMixinsArray.objectAt(obj, 5), undefined, 'should return undefined for obj.objectAt(5) when len = 3'); + + obj = this.newObject([]); + equal(_emberRuntimeMixinsArray.objectAt(obj, 0), undefined, 'should return undefined for obj.objectAt(0) when len = 0'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/objectAt.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/objectAt.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/objectAt.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/copyable', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/tests/suites/copyable/copy', 'ember-runtime/tests/suites/copyable/frozenCopy'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeTestsSuitesCopyableCopy, _emberRuntimeTestsSuitesCopyableFrozenCopy) { + 'use strict'; + + var CopyableTests = _emberRuntimeTestsSuitesSuite.Suite.extend({ + + /* + __Required.__ You must implement this method to apply this mixin. + Must be able to create a new object for testing. + @returns {Object} object + */ + newObject: null, + + /* + __Required.__ You must implement this method to apply this mixin. + Compares the two passed in objects. Returns true if the two objects + are logically equivalent. + @param {Object} a + First object + @param {Object} b + Second object + @returns {Boolean} + */ + isEqual: null, + + /* + Set this to true if you expect the objects you test to be freezable. + The suite will verify that your objects actually match this. (i.e. if + you say you can't test freezable it will verify that your objects really + aren't freezable.) + @type Boolean + */ + shouldBeFreezable: false + + }); + + CopyableTests.importModuleTests(_emberRuntimeTestsSuitesCopyableCopy.default); + CopyableTests.importModuleTests(_emberRuntimeTestsSuitesCopyableFrozenCopy.default); + + exports.default = CopyableTests; +}); +enifed('ember-runtime/tests/suites/copyable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/copyable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/copyable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/copyable/copy', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('copy'); + + suite.test('should return an equivalent copy', function () { + var obj = this.newObject(); + var copy = obj.copy(); + ok(this.isEqual(obj, copy), 'old object and new object should be equivalent'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/copyable/copy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/copyable/copy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/copyable/copy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/copyable/frozenCopy', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/mixins/freezable', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeMixinsFreezable, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('frozenCopy'); + + suite.test('frozen objects should return same instance', function () { + var obj = undefined, + copy = undefined; + + obj = this.newObject(); + if (_emberMetal.get(this, 'shouldBeFreezable')) { + expectDeprecation('`frozenCopy` is deprecated, use Object.freeze instead.'); + + ok(!_emberRuntimeMixinsFreezable.Freezable || _emberRuntimeMixinsFreezable.Freezable.detect(obj), 'object should be freezable'); + + copy = obj.frozenCopy(); + ok(this.isEqual(obj, copy), 'new copy should be equal'); + ok(_emberMetal.get(copy, 'isFrozen'), 'returned value should be frozen'); + + copy = obj.freeze().frozenCopy(); + equal(copy, obj, 'returns frozen object should be same'); + ok(_emberMetal.get(copy, 'isFrozen'), 'returned object should be frozen'); + } else { + ok(!_emberRuntimeMixinsFreezable.Freezable || !_emberRuntimeMixinsFreezable.Freezable.detect(obj), 'object should not be freezable'); + } + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/copyable/frozenCopy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/copyable/frozenCopy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/copyable/frozenCopy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable', ['exports', 'ember-utils', 'ember-runtime/tests/suites/suite', 'ember-runtime/system/object', 'ember-metal', 'ember-runtime/tests/suites/enumerable/any', 'ember-runtime/tests/suites/enumerable/is_any', 'ember-runtime/tests/suites/enumerable/compact', 'ember-runtime/tests/suites/enumerable/contains', 'ember-runtime/tests/suites/enumerable/includes', 'ember-runtime/tests/suites/enumerable/every', 'ember-runtime/tests/suites/enumerable/filter', 'ember-runtime/tests/suites/enumerable/find', 'ember-runtime/tests/suites/enumerable/firstObject', 'ember-runtime/tests/suites/enumerable/forEach', 'ember-runtime/tests/suites/enumerable/mapBy', 'ember-runtime/tests/suites/enumerable/invoke', 'ember-runtime/tests/suites/enumerable/lastObject', 'ember-runtime/tests/suites/enumerable/map', 'ember-runtime/tests/suites/enumerable/reduce', 'ember-runtime/tests/suites/enumerable/reject', 'ember-runtime/tests/suites/enumerable/sortBy', 'ember-runtime/tests/suites/enumerable/toArray', 'ember-runtime/tests/suites/enumerable/uniq', 'ember-runtime/tests/suites/enumerable/uniqBy', 'ember-runtime/tests/suites/enumerable/without'], function (exports, _emberUtils, _emberRuntimeTestsSuitesSuite, _emberRuntimeSystemObject, _emberMetal, _emberRuntimeTestsSuitesEnumerableAny, _emberRuntimeTestsSuitesEnumerableIs_any, _emberRuntimeTestsSuitesEnumerableCompact, _emberRuntimeTestsSuitesEnumerableContains, _emberRuntimeTestsSuitesEnumerableIncludes, _emberRuntimeTestsSuitesEnumerableEvery, _emberRuntimeTestsSuitesEnumerableFilter, _emberRuntimeTestsSuitesEnumerableFind, _emberRuntimeTestsSuitesEnumerableFirstObject, _emberRuntimeTestsSuitesEnumerableForEach, _emberRuntimeTestsSuitesEnumerableMapBy, _emberRuntimeTestsSuitesEnumerableInvoke, _emberRuntimeTestsSuitesEnumerableLastObject, _emberRuntimeTestsSuitesEnumerableMap, _emberRuntimeTestsSuitesEnumerableReduce, _emberRuntimeTestsSuitesEnumerableReject, _emberRuntimeTestsSuitesEnumerableSortBy, _emberRuntimeTestsSuitesEnumerableToArray, _emberRuntimeTestsSuitesEnumerableUniq, _emberRuntimeTestsSuitesEnumerableUniqBy, _emberRuntimeTestsSuitesEnumerableWithout) { + 'use strict'; + + var ObserverClass = _emberRuntimeSystemObject.default.extend({ + _keysBefore: null, + _keys: null, + _values: null, + _before: null, + _after: null, + + isEnabled: true, + + init: function () { + this._super.apply(this, arguments); + this.reset(); + }, + + propertyWillChange: function (target, key) { + if (this._keysBefore[key] === undefined) { + this._keysBefore[key] = 0; + } + this._keysBefore[key]++; + }, + + /* + Invoked when the property changes. Just records the parameters for + later analysis. + */ + propertyDidChange: function (target, key, value) { + if (this._keys[key] === undefined) { + this._keys[key] = 0; + } + this._keys[key]++; + this._values[key] = value; + }, + + /* + Resets the recorded results for another run. + @returns {Object} receiver + */ + reset: function () { + this._keysBefore = {}; + this._keys = {}; + this._values = {}; + this._before = null; + this._after = null; + return this; + }, + + observeBefore: function (obj) { + var keys = Array.prototype.slice.call(arguments, 1); + var loc = keys.length; + while (--loc >= 0) { + _emberMetal._addBeforeObserver(obj, keys[loc], this, 'propertyWillChange'); + } + + return this; + }, + + /* + Begins observing the passed key names on the passed object. Any changes + on the named properties will be recorded. + @param {Ember.Enumerable} obj + The enumerable to observe. + @returns {Object} receiver + */ + observe: function (obj) { + if (obj.addObserver) { + var keys = Array.prototype.slice.call(arguments, 1); + var loc = keys.length; + + while (--loc >= 0) { + obj.addObserver(keys[loc], this, 'propertyDidChange'); + } + } else { + this.isEnabled = false; + } + return this; + }, + + /* + Returns true if the passed key was invoked. If you pass a value as + well then validates that the values match. + @param {String} key + Key to validate + @param {Object} value + (Optional) value + @returns {Boolean} + */ + validate: function (key, value) { + if (!this.isEnabled) { + return true; + } + + if (!this._keys[key]) { + return false; + } + + if (arguments.length > 1) { + return this._values[key] === value; + } else { + return true; + } + }, + + /* + Returns times the before observer as invoked. + @param {String} key + Key to check + */ + timesCalledBefore: function (key) { + return this._keysBefore[key] || 0; + }, + + /* + Returns times the observer as invoked. + @param {String} key + Key to check + */ + timesCalled: function (key) { + return this._keys[key] || 0; + }, + + /* + begins acting as an enumerable observer. + */ + observeEnumerable: function (obj) { + obj.addEnumerableObserver(this); + return this; + }, + + stopObserveEnumerable: function (obj) { + obj.removeEnumerableObserver(this); + return this; + }, + + enumerableWillChange: function () { + equal(this._before, null, 'should only call once'); + this._before = Array.prototype.slice.call(arguments); + }, + + enumerableDidChange: function () { + equal(this._after, null, 'should only call once'); + this._after = Array.prototype.slice.call(arguments); + } + }); + + var EnumerableTests = _emberRuntimeTestsSuitesSuite.Suite.extend({ + /* + __Required.__ You must implement this method to apply this mixin. + Implement to return a new enumerable object for testing. Should accept + either no parameters, a single number (indicating the desired length of + the collection) or an array of objects. + @param {Array} content + An array of items to include in the enumerable optionally. + @returns {Ember.Enumerable} a new enumerable + */ + newObject: null, + + /* + Implement to return a set of new fixture strings that can be applied to + the enumerable. This may be passed into the newObject method. + @param {Number} count + The number of items required. + @returns {Array} array of strings + */ + newFixture: function (cnt) { + var ret = []; + while (--cnt >= 0) { + ret.push(_emberUtils.generateGuid()); + } + + return ret; + }, + + /* + Implement to return a set of new fixture objects that can be applied to + the enumerable. This may be passed into the newObject method. + @param {Number} cnt + The number of items required. + @returns {Array} array of objects + */ + newObjectsFixture: function (cnt) { + var ret = []; + var item = undefined; + while (--cnt >= 0) { + item = {}; + _emberUtils.guidFor(item); + ret.push(item); + } + return ret; + }, + + /* + __Required.__ You must implement this method to apply this mixin. + Implement accept an instance of the enumerable and return an array + containing the objects in the enumerable. This is used only for testing + so performance is not important. + @param {Ember.Enumerable} enumerable + The enumerable to convert. + @returns {Array} array of items + */ + toArray: null, + + /* + Implement this method if your object can mutate internally (even if it + does not support the MutableEnumerable API). The method should accept + an object of your desired type and modify it somehow. Suite tests will + use this to ensure that all appropriate caches, etc. clear when the + mutation occurs. + If you do not define this optional method, then mutation-related tests + will be skipped. + @param {Ember.Enumerable} enumerable + The enumerable to mutate + @returns {void} + */ + mutate: function () {}, + + /* + Becomes true when you define a new mutate() method, indicating that + mutation tests should run. This is calculated automatically. + @type Boolean + */ + canTestMutation: _emberMetal.computed(function () { + return this.mutate !== EnumerableTests.prototype.mutate; + }), + + /* + Invoked to actually run the test - overridden by mixins + */ + run: function () {}, + + /* + Creates a new observer object for testing. You can add this object as an + observer on an array and it will record results anytime it is invoked. + After running the test, call the validate() method on the observer to + validate the results. + */ + newObserver: function (obj) { + var ret = _emberMetal.get(this, 'observerClass').create(); + if (arguments.length > 0) { + ret.observeBefore.apply(ret, arguments); + } + + if (arguments.length > 0) { + ret.observe.apply(ret, arguments); + } + + return ret; + }, + + observerClass: ObserverClass + }); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableAny.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableIs_any.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableCompact.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableContains.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableEvery.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableFilter.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableFind.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableFirstObject.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableForEach.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableMapBy.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableInvoke.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableLastObject.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableMap.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableReduce.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableReject.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableSortBy.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableToArray.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableUniq.default); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableUniqBy.default); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableIncludes.default); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableWithout.default); + + exports.default = EnumerableTests; + exports.EnumerableTests = EnumerableTests; + exports.ObserverClass = ObserverClass; +}); +enifed('ember-runtime/tests/suites/enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/any', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeSystemNative_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // any() + // + + suite.module('any'); + + suite.test('any should should invoke callback on each item as long as you return false', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + var result = undefined; + + result = obj.any(function (i) { + found.push(i); + return false; + }); + equal(result, false, 'return value of obj.any'); + deepEqual(found, ary, 'items passed during any() should match'); + }); + + suite.test('any should stop invoking when you return true', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var exp = cnt; + var found = []; + var result = undefined; + + result = obj.any(function (i) { + found.push(i); + return --cnt <= 0; + }); + equal(result, true, 'return value of obj.any'); + equal(found.length, exp, 'should invoke proper number of times'); + deepEqual(found, ary.slice(0, -2), 'items passed during any() should match'); + }); + + suite.test('any should return true if any object matches the callback', function () { + var obj = _emberRuntimeSystemNative_array.A([0, 1, 2]); + var result = undefined; + + result = obj.any(function (i) { + return !!i; + }); + equal(result, true, 'return value of obj.any'); + }); + + suite.test('any should return false if no object matches the callback', function () { + var obj = _emberRuntimeSystemNative_array.A([0, null, false]); + var result = undefined; + + result = obj.any(function (i) { + return !!i; + }); + equal(result, false, 'return value of obj.any'); + }); + + suite.test('any should produce correct results even if the matching element is undefined', function () { + var obj = _emberRuntimeSystemNative_array.A([undefined]); + var result = undefined; + + result = obj.any(function (i) { + return true; + }); + equal(result, true, 'return value of obj.any'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/any.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/any.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/any.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/compact', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('compact'); + + suite.test('removes null and undefined values from enumerable', function () { + var obj = this.newObject([null, 1, false, '', undefined, 0, null]); + var ary = obj.compact(); + deepEqual(ary, [1, false, '', 0]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/compact.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/compact.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/compact.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/contains', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('contains'); + + suite.test('contains returns true if item is in enumerable', function () { + var data = this.newFixture(3); + var obj = this.newObject(data); + + expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); + equal(obj.contains(data[1]), true, 'should return true if contained'); + }); + + suite.test('contains returns false if item is not in enumerable', function () { + var data = this.newFixture(1); + var obj = this.newObject(this.newFixture(3)); + + expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); + equal(obj.contains(data[0]), false, 'should return false if not contained'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/contains.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/contains.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/contains.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/every', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // every() + // + + suite.module('every'); + + suite.test('every should should invoke callback on each item as long as you return true', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + var result = undefined; + + result = obj.every(function (i) { + found.push(i); + return true; + }); + equal(result, true, 'return value of obj.every'); + deepEqual(found, ary, 'items passed during every() should match'); + }); + + suite.test('every should stop invoking when you return false', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var exp = cnt; + var found = []; + var result = undefined; + + result = obj.every(function (i) { + found.push(i); + return --cnt > 0; + }); + equal(result, false, 'return value of obj.every'); + equal(found.length, exp, 'should invoke proper number of times'); + deepEqual(found, ary.slice(0, -2), 'items passed during every() should match'); + }); + + // .......................................................... + // isEvery() + // + + suite.module('isEvery'); + + suite.test('should return true of every property matches', function () { + var obj = this.newObject([{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]); + + equal(obj.isEvery('foo', 'foo'), true, 'isEvery(foo)'); + equal(obj.isEvery('bar', 'bar'), false, 'isEvery(bar)'); + }); + + suite.test('should return true of every property is true', function () { + var obj = this.newObject([{ foo: 'foo', bar: true }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: false })]); + + // different values - all eval to true + equal(obj.isEvery('foo'), true, 'isEvery(foo)'); + equal(obj.isEvery('bar'), false, 'isEvery(bar)'); + }); + + suite.test('should return true if every property matches null', function () { + var obj = this.newObject([{ foo: null, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: null, bar: null })]); + + equal(obj.isEvery('foo', null), true, 'isEvery(\'foo\', null)'); + equal(obj.isEvery('bar', null), false, 'isEvery(\'bar\', null)'); + }); + + suite.test('should return true if every property is undefined', function () { + var obj = this.newObject([{ foo: undefined, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ bar: undefined })]); + + equal(obj.isEvery('foo', undefined), true, 'isEvery(\'foo\', undefined)'); + equal(obj.isEvery('bar', undefined), false, 'isEvery(\'bar\', undefined)'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/every.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/every.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/every.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/filter', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // filter() + // + + suite.module('filter'); + + suite.test('filter should invoke on each item', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var found = []; + var result = undefined; + + // return true on all but the last two + result = obj.filter(function (i) { + found.push(i); + return --cnt >= 0; + }); + deepEqual(found, ary, 'should have invoked on each item'); + deepEqual(result, ary.slice(0, -2), 'filtered array should exclude items'); + }); + + // .......................................................... + // filterBy() + // + + suite.module('filterBy'); + + suite.test('should filter based on object', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', 'foo'), ary, 'filterBy(foo)'); + deepEqual(obj.filterBy('bar', 'bar'), [ary[1]], 'filterBy(bar)'); + }); + + suite.test('should include in result if property is true', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: 'foo', bar: true }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: false })]; + + obj = this.newObject(ary); + + // different values - all eval to true + deepEqual(obj.filterBy('foo'), ary, 'filterBy(foo)'); + deepEqual(obj.filterBy('bar'), [ary[0]], 'filterBy(bar)'); + }); + + suite.test('should filter on second argument if provided', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 }), { name: 'obj3', foo: 2 }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', 3), [ary[0], ary[3]], 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should correctly filter null second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: null }), { name: 'obj3', foo: null }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', null), [ary[1], ary[2]], 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should not return all objects on undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', undefined), [], 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should correctly filter explicit undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', undefined), ary.slice(2), 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should not match undefined properties without second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo'), ary.slice(0, 2), 'filterBy(\'foo\', 3)\')'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/filter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/filter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/filter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/find', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + // .......................................................... + // find() + // + + suite.module('find'); + + suite.test('find should invoke callback on each item as long as you return false', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + var result = undefined; + + result = obj.find(function (i) { + found.push(i); + return false; + }); + equal(result, undefined, 'return value of obj.find'); + deepEqual(found, ary, 'items passed during find() should match'); + }); + + suite.test('every should stop invoking when you return true', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var exp = cnt; + var found = []; + var result = undefined; + + result = obj.find(function (i) { + found.push(i); + return --cnt >= 0; + }); + equal(result, ary[exp - 1], 'return value of obj.find'); + equal(found.length, exp, 'should invoke proper number of times'); + deepEqual(found, ary.slice(0, -2), 'items passed during find() should match'); + }); + + // .......................................................... + // findBy() + // + + suite.module('findBy'); + + suite.test('should return first object of property matches', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]; + + obj = this.newObject(ary); + + equal(obj.findBy('foo', 'foo'), ary[0], 'findBy(foo)'); + equal(obj.findBy('bar', 'bar'), ary[1], 'findBy(bar)'); + }); + + suite.test('should return first object with truthy prop', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: 'foo', bar: false }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: true })]; + + obj = this.newObject(ary); + + // different values - all eval to true + equal(obj.findBy('foo'), ary[0], 'findBy(foo)'); + equal(obj.findBy('bar'), ary[1], 'findBy(bar)'); + }); + + suite.test('should return first null property match', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: null, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: null, bar: null })]; + + obj = this.newObject(ary); + + equal(obj.findBy('foo', null), ary[0], 'findBy(\'foo\', null)'); + equal(obj.findBy('bar', null), ary[1], 'findBy(\'bar\', null)'); + }); + + suite.test('should return first undefined property match', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: undefined, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({})]; + + obj = this.newObject(ary); + + equal(obj.findBy('foo', undefined), ary[0], 'findBy(\'foo\', undefined)'); + equal(obj.findBy('bar', undefined), ary[1], 'findBy(\'bar\', undefined)'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/find.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/find.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/find.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/firstObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('firstObject'); + + suite.test('returns first item in enumerable', function () { + var obj = this.newObject(); + equal(_emberMetal.get(obj, 'firstObject'), this.toArray(obj)[0]); + }); + + suite.test('returns undefined if enumerable is empty', function () { + var obj = this.newObject([]); + equal(_emberMetal.get(obj, 'firstObject'), undefined); + }); + + suite.test('can not be set', function () { + var obj = this.newObject([]); + + equal(_emberMetal.get(obj, 'firstObject'), this.toArray(obj)[0]); + + throws(function () { + _emberMetal.set(obj, 'firstObject', 'foo!'); + }, /Cannot set read-only property "firstObject" on object/); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/firstObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/firstObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/firstObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/forEach', ['exports', 'ember-utils', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('forEach'); + + suite.test('forEach should iterate over list', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + + obj.forEach(function (i) { + return found.push(i); + }); + deepEqual(found, ary, 'items passed during forEach should match'); + }); + + suite.test('forEach should iterate over list after mutation', function () { + if (_emberMetal.get(this, 'canTestMutation')) { + expect(0); + return; + } + + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + + obj.forEach(function (i) { + return found.push(i); + }); + deepEqual(found, ary, 'items passed during forEach should match'); + + this.mutate(obj); + ary = this.toArray(obj); + found = []; + + obj.forEach(function (i) { + return found.push(i); + }); + deepEqual(found, ary, 'items passed during forEach should match'); + }); + + suite.test('2nd target parameter', function () { + var _this = this; + + var obj = this.newObject(); + var target = this; + + obj.forEach(function () { + // ES6TODO: When transpiled we will end up with "use strict" which disables automatically binding to the global context. + // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to + // use `Ember.lookup` if target is not specified. + // + // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context'); + }); + + obj.forEach(function () { + equal(_emberUtils.guidFor(_this), _emberUtils.guidFor(target), 'should pass target as this if context'); + }, target); + }); + + suite.test('callback params', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var loc = 0; + + obj.forEach(function (item, idx, enumerable) { + equal(item, ary[loc], 'item param'); + equal(idx, loc, 'idx param'); + equal(_emberUtils.guidFor(enumerable), _emberUtils.guidFor(obj), 'enumerable param'); + loc++; + }); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/forEach.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/forEach.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/forEach.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/includes', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('includes'); + + suite.test('includes returns true if item is in enumerable', function () { + var data = this.newFixture(1); + var obj = this.newObject([].concat(data, [NaN, undefined, null])); + + equal(obj.includes(data[0]), true, 'should return true if included'); + equal(obj.includes(NaN), true, 'should return true if NaN included'); + equal(obj.includes(undefined), true, 'should return true if undefined included'); + equal(obj.includes(null), true, 'should return true if null included'); + }); + + suite.test('includes returns false if item is not in enumerable', function () { + var data = this.newFixture(1); + var obj = this.newObject([].concat(this.newFixture(3), [null])); + + equal(obj.includes(data[0]), false, 'should return false if not included'); + equal(obj.includes(undefined), false, 'should return false if undefined not included but null is included'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/includes.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/includes.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/includes.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/invoke', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('invoke'); + + suite.test('invoke should call on each object that implements', function () { + var cnt = undefined, + ary = undefined, + obj = undefined; + + function F(amt) { + cnt += amt === undefined ? 1 : amt; + } + cnt = 0; + ary = [{ foo: F }, _emberRuntimeSystemObject.default.create({ foo: F }), + + // NOTE: does not impl foo - invoke should just skip + _emberRuntimeSystemObject.default.create({ bar: F }), { foo: F }]; + + obj = this.newObject(ary); + obj.invoke('foo'); + equal(cnt, 3, 'should have invoked 3 times'); + + cnt = 0; + obj.invoke('foo', 2); + equal(cnt, 6, 'should have invoked 3 times, passing param'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/invoke.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/invoke.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/invoke.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/is_any', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // isAny() + // + + suite.module('isAny'); + + suite.test('should return true of any property matches', function () { + var obj = this.newObject([{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]); + + equal(obj.isAny('foo', 'foo'), true, 'isAny(foo)'); + equal(obj.isAny('bar', 'bar'), true, 'isAny(bar)'); + equal(obj.isAny('bar', 'BIFF'), false, 'isAny(BIFF)'); + }); + + suite.test('should return true of any property is true', function () { + var obj = this.newObject([{ foo: 'foo', bar: true }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: false })]); + + // different values - all eval to true + equal(obj.isAny('foo'), true, 'isAny(foo)'); + equal(obj.isAny('bar'), true, 'isAny(bar)'); + equal(obj.isAny('BIFF'), false, 'isAny(biff)'); + }); + + suite.test('should return true if any property matches null', function () { + var obj = this.newObject([{ foo: null, bar: 'bar' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: null })]); + + equal(obj.isAny('foo', null), true, 'isAny(\'foo\', null)'); + equal(obj.isAny('bar', null), true, 'isAny(\'bar\', null)'); + }); + + suite.test('should return true if any property is undefined', function () { + var obj = this.newObject([{ foo: undefined, bar: 'bar' }, _emberRuntimeSystemObject.default.create({ foo: 'foo' })]); + + equal(obj.isAny('foo', undefined), true, 'isAny(\'foo\', undefined)'); + equal(obj.isAny('bar', undefined), true, 'isAny(\'bar\', undefined)'); + }); + + suite.test('should not match undefined properties without second argument', function () { + var obj = this.newObject([{ foo: undefined }, _emberRuntimeSystemObject.default.create({})]); + + equal(obj.isAny('foo'), false, 'isAny(\'foo\', undefined)'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/is_any.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/is_any.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/is_any.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/lastObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('lastObject'); + + suite.test('returns last item in enumerable', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + + equal(_emberMetal.get(obj, 'lastObject'), ary[ary.length - 1]); + }); + + suite.test('returns undefined if enumerable is empty', function () { + var obj = this.newObject([]); + + equal(_emberMetal.get(obj, 'lastObject'), undefined); + }); + + suite.test('can not be set', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + + equal(_emberMetal.get(obj, 'lastObject'), ary[ary.length - 1]); + + throws(function () { + _emberMetal.set(obj, 'lastObject', 'foo!'); + }, /Cannot set read-only property "lastObject" on object/); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/lastObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/lastObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/lastObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/map', ['exports', 'ember-utils', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('map'); + + var mapFunc = function (item) { + return item ? item.toString() : null; + }; + + suite.test('map should iterate over list', function () { + var obj = this.newObject(); + var ary = this.toArray(obj).map(mapFunc); + var found = []; + + found = obj.map(mapFunc); + deepEqual(found, ary, 'mapped arrays should match'); + }); + + suite.test('map should iterate over list after mutation', function () { + if (_emberMetal.get(this, 'canTestMutation')) { + expect(0); + return; + } + + var obj = this.newObject(); + var ary = this.toArray(obj).map(mapFunc); + var found = undefined; + + found = obj.map(mapFunc); + deepEqual(found, ary, 'items passed during forEach should match'); + + this.mutate(obj); + ary = this.toArray(obj).map(mapFunc); + found = obj.map(mapFunc); + deepEqual(found, ary, 'items passed during forEach should match'); + }); + + suite.test('2nd target parameter', function () { + var _this = this; + + var obj = this.newObject(); + var target = this; + + obj.map(function () { + // ES6TODO: When transpiled we will end up with "use strict" which disables automatically binding to the global context. + // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to + // use `Ember.lookup` if target is not specified. + // + // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context'); + }); + + obj.map(function () { + equal(_emberUtils.guidFor(_this), _emberUtils.guidFor(target), 'should pass target as this if context'); + }, target); + }); + + suite.test('callback params', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var loc = 0; + + obj.map(function (item, idx, enumerable) { + equal(item, ary[loc], 'item param'); + equal(idx, loc, 'idx param'); + equal(_emberUtils.guidFor(enumerable), _emberUtils.guidFor(obj), 'enumerable param'); + loc++; + }); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/map.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/map.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/map.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/mapBy', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('mapBy'); + + suite.test('get value of each property', function () { + var obj = this.newObject([{ a: 1 }, { a: 2 }]); + equal(obj.mapBy('a').join(''), '12'); + }); + + suite.test('should work also through getEach alias', function () { + var obj = this.newObject([{ a: 1 }, { a: 2 }]); + equal(obj.getEach('a').join(''), '12'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/mapBy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/mapBy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/mapBy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/reduce', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('reduce'); + + suite.test('collects a summary value from an enumeration', function () { + var obj = this.newObject([1, 2, 3]); + var res = obj.reduce(function (previousValue, item, index, enumerable) { + return previousValue + item; + }, 0); + equal(res, 6); + }); + + suite.test('passes index of item to callback', function () { + var obj = this.newObject([1, 2, 3]); + var res = obj.reduce(function (previousValue, item, index, enumerable) { + return previousValue + index; + }, 0); + equal(res, 3); + }); + + suite.test('passes enumerable object to callback', function () { + var obj = this.newObject([1, 2, 3]); + var res = obj.reduce(function (previousValue, item, index, enumerable) { + return enumerable; + }, 0); + equal(res, obj); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/reduce.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/reduce.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/reduce.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/reject', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // reject() + // + + suite.module('reject'); + + suite.test('should reject any item that does not meet the condition', function () { + var obj = this.newObject([1, 2, 3, 4]); + var result = undefined; + + result = obj.reject(function (i) { + return i < 3; + }); + deepEqual(result, [3, 4], 'reject the correct items'); + }); + + suite.test('should be the inverse of filter', function () { + var obj = this.newObject([1, 2, 3, 4]); + var isEven = function (i) { + return i % 2 === 0; + }; + var filtered = undefined, + rejected = undefined; + + filtered = obj.filter(isEven); + rejected = obj.reject(isEven); + + deepEqual(filtered, [2, 4], 'filtered evens'); + deepEqual(rejected, [1, 3], 'rejected evens'); + }); + + // .......................................................... + // rejectBy() + // + + suite.module('rejectBy'); + + suite.test('should reject based on object', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', 'foo'), [], 'rejectBy(foo)'); + deepEqual(obj.rejectBy('bar', 'bar'), [ary[0]], 'rejectBy(bar)'); + }); + + suite.test('should include in result if property is false', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: false, bar: true }, _emberRuntimeSystemObject.default.create({ foo: false, bar: false })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo'), ary, 'rejectBy(foo)'); + deepEqual(obj.rejectBy('bar'), [ary[1]], 'rejectBy(bar)'); + }); + + suite.test('should reject on second argument if provided', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 }), { name: 'obj3', foo: 2 }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', 3), [ary[1], ary[2]], 'rejectBy(\'foo\', 3)\')'); + }); + + suite.test('should correctly reject null second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: null }), { name: 'obj3', foo: null }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', null), [ary[0], ary[3]], 'rejectBy(\'foo\', null)\')'); + }); + + suite.test('should correctly reject undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('bar', undefined), [], 'rejectBy(\'bar\', undefined)\')'); + }); + + suite.test('should correctly reject explicit undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', undefined), ary.slice(0, 2), 'rejectBy(\'foo\', undefined)\')'); + }); + + suite.test('should match undefined, null, or false properties without second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' }), { name: 'obj7', foo: null }, _emberRuntimeSystemObject.default.create({ name: 'obj8', foo: null }), { name: 'obj9', foo: false }, _emberRuntimeSystemObject.default.create({ name: 'obj10', foo: false })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo'), ary.slice(2), 'rejectBy(\'foo\')\')'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/reject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/reject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/reject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/sortBy', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('sortBy'); + + suite.test('sort by value of property', function () { + var obj = this.newObject([{ a: 2 }, { a: 1 }]); + var sorted = obj.sortBy('a'); + + equal(_emberMetal.get(sorted[0], 'a'), 1); + equal(_emberMetal.get(sorted[1], 'a'), 2); + }); + + suite.test('supports multiple propertyNames', function () { + var obj = this.newObject([{ a: 1, b: 2 }, { a: 1, b: 1 }]); + var sorted = obj.sortBy('a', 'b'); + + equal(_emberMetal.get(sorted[0], 'b'), 1); + equal(_emberMetal.get(sorted[1], 'b'), 2); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/sortBy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/sortBy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/sortBy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/toArray', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('toArray'); + + suite.test('toArray should convert to an array', function () { + var obj = this.newObject(); + deepEqual(obj.toArray(), this.toArray(obj)); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/toArray.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/toArray.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/toArray.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/uniq', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('uniq'); + + suite.test('should return new instance with duplicates removed', function () { + var before = undefined, + after = undefined, + obj = undefined, + ret = undefined; + + after = this.newFixture(3); + before = [after[0], after[1], after[2], after[1], after[0]]; + obj = this.newObject(before); + before = obj.toArray(); // in case of set before will be different... + + ret = obj.uniq(); + deepEqual(this.toArray(ret), after, 'should have removed item'); + deepEqual(this.toArray(obj), before, 'should not have changed original'); + }); + + suite.test('should return duplicate of same content if no duplicates found', function () { + var item = undefined, + obj = undefined, + ret = undefined; + obj = this.newObject(this.newFixture(3)); + ret = obj.uniq(item); + ok(ret !== obj, 'should not be same object'); + deepEqual(this.toArray(ret), this.toArray(obj), 'should be the same content'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/uniq.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/uniq.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/uniq.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/uniqBy', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('uniqBy'); + + suite.test('should return new instance with duplicates removed', function () { + var numbers = this.newObject([{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 1, value: 'one' }]); + deepEqual(numbers.uniqBy('id'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/uniqBy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/uniqBy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/uniqBy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/without', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('without'); + + suite.test('should return new instance with item removed', function () { + var before = undefined, + after = undefined, + obj = undefined, + ret = undefined; + + before = this.newFixture(3); + after = [before[0], before[2]]; + obj = this.newObject(before); + + ret = obj.without(before[1]); + deepEqual(this.toArray(ret), after, 'should have removed item'); + deepEqual(this.toArray(obj), before, 'should not have changed original'); + }); + + suite.test('should remove NaN value', function () { + var before = undefined, + after = undefined, + obj = undefined, + ret = undefined; + + before = [].concat(this.newFixture(2), [NaN]); + after = [before[0], before[1]]; + obj = this.newObject(before); + + ret = obj.without(NaN); + deepEqual(this.toArray(ret), after, 'should have removed item'); + }); + + suite.test('should return same instance if object not found', function () { + var item = undefined, + obj = undefined, + ret = undefined; + + item = this.newFixture(1)[0]; + obj = this.newObject(this.newFixture(3)); + + ret = obj.without(item); + equal(ret, obj, 'should be same instance'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/without.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/without.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/without.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array', ['exports', 'ember-runtime/tests/suites/array', 'ember-runtime/tests/suites/mutable_array/insertAt', 'ember-runtime/tests/suites/mutable_array/popObject', 'ember-runtime/tests/suites/mutable_array/pushObject', 'ember-runtime/tests/suites/mutable_array/pushObjects', 'ember-runtime/tests/suites/mutable_array/removeAt', 'ember-runtime/tests/suites/mutable_array/replace', 'ember-runtime/tests/suites/mutable_array/shiftObject', 'ember-runtime/tests/suites/mutable_array/unshiftObject', 'ember-runtime/tests/suites/mutable_array/reverseObjects'], function (exports, _emberRuntimeTestsSuitesArray, _emberRuntimeTestsSuitesMutable_arrayInsertAt, _emberRuntimeTestsSuitesMutable_arrayPopObject, _emberRuntimeTestsSuitesMutable_arrayPushObject, _emberRuntimeTestsSuitesMutable_arrayPushObjects, _emberRuntimeTestsSuitesMutable_arrayRemoveAt, _emberRuntimeTestsSuitesMutable_arrayReplace, _emberRuntimeTestsSuitesMutable_arrayShiftObject, _emberRuntimeTestsSuitesMutable_arrayUnshiftObject, _emberRuntimeTestsSuitesMutable_arrayReverseObjects) { + 'use strict'; + + var MutableArrayTests = _emberRuntimeTestsSuitesArray.ArrayTests.extend(); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayInsertAt.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayPopObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayPushObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayPushObjects.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayRemoveAt.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayReplace.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayShiftObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayUnshiftObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayReverseObjects.default); + + exports.default = MutableArrayTests; +}); +enifed('ember-runtime/tests/suites/mutable_array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/addObject', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('addObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + equal(obj.addObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B].addObject(C) => [A,B,C] + notify', function () { + var before = this.newFixture(2); + var item = this.newFixture(1)[0]; + var after = [before[0], before[1], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.addObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + } + }); + + suite.test('[A,B,C].addObject(A) => [A,B,C] + NO notify', function () { + var before = this.newFixture(3); + var after = before; + var item = before[0]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.addObject(item); // note: item in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('@each'), false, 'should NOT have notified @each'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + } + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/addObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/addObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/addObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/clear', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('clear'); + + suite.test('[].clear() => [] + notify', function () { + var before = []; + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.clear(), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.validate('[]'), false, 'should NOT have notified [] once'); + equal(observer.validate('@each'), false, 'should NOT have notified @each once'); + equal(observer.validate('length'), false, 'should NOT have notified length once'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[X].clear() => [] + notify', function () { + var obj, before, after, observer; + + before = this.newFixture(1); + after = []; + obj = this.newObject(before); + observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.clear(), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/clear.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/clear.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/clear.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/insertAt', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('insertAt'); + + suite.test('[].insertAt(0, X) => [X] + notify', function () { + var after = this.newFixture(1); + var obj = this.newObject([]); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(0, after[0]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] did change once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each did change once'); + equal(observer.timesCalled('length'), 1, 'should have notified length did change once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject did change once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject did change once'); + }); + + suite.test('[].insertAt(200,X) => OUT_OF_RANGE_EXCEPTION exception', function () { + var obj = this.newObject([]); + var that = this; + + throws(function () { + return obj.insertAt(200, that.newFixture(1)[0]); + }, Error); + }); + + suite.test('[A].insertAt(0, X) => [X,A] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(1); + var after = [item, before[0]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(0, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A].insertAt(1, X) => [A,X] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(1); + var after = [before[0], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(1, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + suite.test('[A].insertAt(200,X) => OUT_OF_RANGE exception', function () { + var obj = this.newObject(this.newFixture(1)); + var that = this; + + throws(function () { + return obj.insertAt(200, that.newFixture(1)[0]); + }, Error); + }); + + suite.test('[A,B,C].insertAt(0,X) => [X,A,B,C] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(3); + var after = [item, before[0], before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(0, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].insertAt(1,X) => [A,X,B,C] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(3); + var after = [before[0], item, before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(1, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].insertAt(3,X) => [A,B,C,X] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(3); + var after = [before[0], before[1], before[2], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(3, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/insertAt.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/insertAt.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/insertAt.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/popObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('popObject'); + + suite.test('[].popObject() => [] + returns undefined + NO notify', function () { + var obj = this.newObject([]); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.popObject(), undefined, 'popObject results'); + + deepEqual(this.toArray(obj), [], 'post item results'); + + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('@each'), false, 'should NOT have notified @each'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[X].popObject() => [] + notify', function () { + var before = this.newFixture(1); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + var ret = obj.popObject(); + + equal(ret, before[0], 'return object'); + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].popObject() => [A,B] + notify', function () { + var before = this.newFixture(3); + var after = [before[0], before[1]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + var ret = obj.popObject(); + + equal(ret, before[2], 'return object'); + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/popObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/popObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/popObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('pushObject'); + + suite.test('returns pushed object', function () { + var exp = this.newFixture(1)[0]; + var obj = this.newObject([]); + + equal(obj.pushObject(exp), exp, 'should return pushed object'); + }); + + suite.test('[].pushObject(X) => [X] + notify', function () { + var before = []; + var after = this.newFixture(1); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.pushObject(after[0]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].pushObject(X) => [A,B,C,X] + notify', function () { + var before = this.newFixture(3); + var item = this.newFixture(1)[0]; + var after = [before[0], before[1], before[2], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.pushObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/pushObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/pushObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObjects', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('pushObjects'); + + suite.test('should raise exception if not Ember.Enumerable is passed to pushObjects', function () { + var obj = this.newObject([]); + + throws(function () { + return obj.pushObjects('string'); + }); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/pushObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/pushObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/removeAt', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal', 'ember-runtime/mixins/mutable_array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal, _emberRuntimeMixinsMutable_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeAt'); + + suite.test('removeAt([X], 0) => [] + notify', function () { + var before = this.newFixture(1); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 0), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('removeAt([], 200) => OUT_OF_RANGE_EXCEPTION exception', function () { + var obj = this.newObject([]); + throws(function () { + return _emberRuntimeMixinsMutable_array.removeAt(obj, 200); + }, Error); + }); + + suite.test('removeAt([A,B], 0) => [B] + notify', function () { + var before = this.newFixture(2); + var after = [before[1]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 0), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('removeAt([A,B], 1) => [A] + notify', function () { + var before = this.newFixture(2); + var after = [before[0]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 1), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + }); + + suite.test('removeAt([A,B,C], 1) => [A,C] + notify', function () { + var before = this.newFixture(3); + var after = [before[0], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 1), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('removeAt([A,B,C,D], 1,2) => [A,D] + notify', function () { + var before = this.newFixture(4); + var after = [before[0], before[3]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 1, 2), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B,C,D].removeAt(1,2) => [A,D] + notify', function () { + var obj, before, after, observer; + + before = this.newFixture(4); + after = [before[0], before[3]]; + obj = this.newObject(before); + observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.removeAt(1, 2), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/removeAt.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/removeAt.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/removeAt.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/removeObject', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + + equal(obj.removeObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function () { + var before = this.newFixture(3); + var after = [before[0], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.removeObject(before[1]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + } + }); + + suite.test('[A,B,C].removeObject(D) => [A,B,C]', function () { + var before = this.newFixture(3); + var after = before; + var item = this.newFixture(1)[0]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.removeObject(item); // note: item not in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('@each'), false, 'should NOT have notified @each'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + } + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/removeObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/removeObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/removeObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/replace', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('replace'); + + suite.test('[].replace(0,0,\'X\') => [\'X\'] + notify', function () { + var exp = this.newFixture(1); + var obj = this.newObject([]); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(0, 0, exp); + + deepEqual(this.toArray(obj), exp, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[].replace(0,0,"X") => ["X"] + avoid calling objectAt and notifying fistObject/lastObject when not in cache', function () { + var obj, exp, observer; + var called = 0; + exp = this.newFixture(1); + obj = this.newObject([]); + obj.objectAt = function () { + called++; + }; + observer = this.newObserver(obj, 'firstObject', 'lastObject'); + + obj.replace(0, 0, exp); + + equal(called, 0, 'should NOT have called objectAt upon replace when firstObject/lastObject are not cached'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject since not cached'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject since not cached'); + }); + + suite.test('[A,B,C,D].replace(1,2,X) => [A,X,D] + notify', function () { + var before = this.newFixture(4); + var replace = this.newFixture(1); + var after = [before[0], replace[0], before[3]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(1, 2, replace); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B,C,D].replace(1,2,[X,Y]) => [A,X,Y,D] + notify', function () { + var before = this.newFixture(4); + var replace = this.newFixture(2); + var after = [before[0], replace[0], replace[1], before[3]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(1, 2, replace); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B].replace(1,0,[X,Y]) => [A,X,Y,B] + notify', function () { + var before = this.newFixture(2); + var replace = this.newFixture(2); + var after = [before[0], replace[0], replace[1], before[1]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(1, 0, replace); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B,C,D].replace(2,2) => [A,B] + notify', function () { + var before = this.newFixture(4); + var after = [before[0], before[1]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(2, 2); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + }); + + suite.test('Adding object should notify enumerable observer', function () { + var fixtures = this.newFixture(4); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = this.newFixture(1)[0]; + + obj.replace(2, 2, [item]); + + deepEqual(observer._before, [obj, [fixtures[2], fixtures[3]], 1], 'before'); + deepEqual(observer._after, [obj, 2, [item]], 'after'); + }); + + suite.test('Adding object should notify array observer', function () { + var fixtures = this.newFixture(4); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeArray(obj); + var item = this.newFixture(1)[0]; + + obj.replace(2, 2, [item]); + + deepEqual(observer._before, [obj, 2, 2, 1], 'before'); + deepEqual(observer._after, [obj, 2, 2, 1], 'after'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/replace.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/replace.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/replace.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/reverseObjects', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('reverseObjects'); + + suite.test('[A,B,C].reverseObjects() => [] + notify', function () { + var before = this.newFixture(3); + var after = [before[2], before[1], before[0]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.reverseObjects(), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 0, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/reverseObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/reverseObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/reverseObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/setObjects', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('setObjects'); + + suite.test('[A,B,C].setObjects([]) = > [] + notify', function () { + var before = this.newFixture(3); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.setObjects(after), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].setObjects([D, E, F, G]) = > [D, E, F, G] + notify', function () { + var before = this.newFixture(3); + var after = this.newFixture(4); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.setObjects(after), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/setObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/setObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/setObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/shiftObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('shiftObject'); + + suite.test('[].shiftObject() => [] + returns undefined + NO notify', function () { + var before = []; + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.shiftObject(), undefined); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.validate('[]', undefined, 1), false, 'should NOT have notified [] once'); + equal(observer.validate('@each', undefined, 1), false, 'should NOT have notified @each once'); + equal(observer.validate('length', undefined, 1), false, 'should NOT have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[X].shiftObject() => [] + notify', function () { + var before = this.newFixture(1); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.shiftObject(), before[0], 'should return object'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].shiftObject() => [B,C] + notify', function () { + var before = this.newFixture(3); + var after = [before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.shiftObject(), before[0], 'should return object'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/shiftObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/shiftObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/shiftObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('unshiftObject'); + + suite.test('returns unshifted object', function () { + var obj = this.newObject([]); + var item = this.newFixture(1)[0]; + + equal(obj.unshiftObject(item), item, 'should return unshifted object'); + }); + + suite.test('[].unshiftObject(X) => [X] + notify', function () { + var before = []; + var item = this.newFixture(1)[0]; + var after = [item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].unshiftObject(X) => [X,A,B,C] + notify', function () { + var before = this.newFixture(3); + var item = this.newFixture(1)[0]; + var after = [item, before[0], before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].unshiftObject(A) => [A,A,B,C] + notify', function () { + var before = this.newFixture(3); + var item = before[0]; // note same object as current head. should end up twice + var after = [item, before[0], before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/unshiftObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/unshiftObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObjects', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('unshiftObjects'); + + suite.test('returns receiver', function () { + var obj = this.newObject([]); + var items = this.newFixture(3); + + equal(obj.unshiftObjects(items), obj, 'should return receiver'); + }); + + suite.test('[].unshiftObjects([A,B,C]) => [A,B,C] + notify', function () { + var before = []; + var items = this.newFixture(3); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObjects(items); + + deepEqual(this.toArray(obj), items, 'post item results'); + equal(_emberMetal.get(obj, 'length'), items.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].unshiftObjects([X,Y]) => [X,Y,A,B,C] + notify', function () { + var before = this.newFixture(3); + var items = this.newFixture(2); + var after = items.concat(before); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObjects(items); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].unshiftObjects([A,B]) => [A,B,A,B,C] + notify', function () { + var before = this.newFixture(3); + var items = [before[0], before[1]]; // note same object as current head. should end up twice + var after = items.concat(before); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObjects(items); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/unshiftObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/unshiftObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable', ['exports', 'ember-runtime/tests/suites/enumerable', 'ember-runtime/tests/suites/mutable_enumerable/addObject', 'ember-runtime/tests/suites/mutable_enumerable/removeObject', 'ember-runtime/tests/suites/mutable_enumerable/removeObjects'], function (exports, _emberRuntimeTestsSuitesEnumerable, _emberRuntimeTestsSuitesMutable_enumerableAddObject, _emberRuntimeTestsSuitesMutable_enumerableRemoveObject, _emberRuntimeTestsSuitesMutable_enumerableRemoveObjects) { + 'use strict'; + + var MutableEnumerableTests = _emberRuntimeTestsSuitesEnumerable.EnumerableTests.extend(); + MutableEnumerableTests.importModuleTests(_emberRuntimeTestsSuitesMutable_enumerableAddObject.default); + MutableEnumerableTests.importModuleTests(_emberRuntimeTestsSuitesMutable_enumerableRemoveObject.default); + MutableEnumerableTests.importModuleTests(_emberRuntimeTestsSuitesMutable_enumerableRemoveObjects.default); + + exports.default = MutableEnumerableTests; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/addObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('addObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + + equal(obj.addObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B].addObject(C) => [A,B,C] + notify', function () { + var before = this.newFixture(2); + var item = this.newFixture(1)[0]; + var after = [before[0], before[1], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + _emberMetal.get(obj, 'firstObject'); + _emberMetal.get(obj, 'lastObject'); + + obj.addObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + // This gets called since MutableEnumerable is naive about changes + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + } + }); + + suite.test('[A,B,C].addObject(A) => [A,B,C] + NO notify', function () { + var before = this.newFixture(3); + var after = before; + var item = before[0]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.addObject(item); // note: item in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('Adding object should notify enumerable observer', function () { + var obj = this.newObject(this.newFixture(3)); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = this.newFixture(1)[0]; + + obj.addObject(item); + + deepEqual(observer._before, [obj, null, [item]]); + deepEqual(observer._after, [obj, null, [item]]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/addObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable/addObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable/addObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObject', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite, _emberRuntimeSystemNative_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + + equal(obj.removeObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = [before[0], before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObject(before[1]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObject(D) => [A,B,C]', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = before; + var item = this.newFixture(1)[0]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObject(item); // Note: item not in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('Removing object should notify enumerable observer', function () { + var fixtures = this.newFixture(3); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = fixtures[1]; + + obj.removeObject(item); + + deepEqual(observer._before, [obj, [item], null]); + deepEqual(observer._after, [obj, [item], null]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable/removeObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable/removeObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObjects', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeObjects'); + + suite.test('should return receiver', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var obj = before; + + equal(obj.removeObjects(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B,C].removeObjects([B]) => [A,C] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = [before[0], before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[{A},{B},{C}].removeObjects([{B}]) => [{A},{C}] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newObjectsFixture(3)); + var after = [before[0], before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObjects([A,B]) => [C] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = [before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[0], before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[{A},{B},{C}].removeObjects([{A},{B}]) => [{C}] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newObjectsFixture(3)); + var after = [before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[0], before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObjects([A,B,C]) => [] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = []; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[0], before[1], before[2]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject'); + } + }); + + suite.test('[{A},{B},{C}].removeObjects([{A},{B},{C}]) => [] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newObjectsFixture(3)); + var after = []; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects(before); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.validate('lastObject'), 1, 'should have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObjects([D]) => [A,B,C]', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = before; + var item = this.newFixture(1)[0]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([item]); // Note: item not in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('Removing objects should notify enumerable observer', function () { + var fixtures = this.newFixture(3); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = fixtures[1]; + + obj.removeObjects([item]); + + deepEqual(observer._before, [obj, [item], null]); + deepEqual(observer._after, [obj, [item], null]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable/removeObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable/removeObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/suite', ['exports', 'ember-utils', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + /* + @class + A Suite can be used to define a reusable set of unit tests that can be + applied to any object. Suites are most useful for defining tests that + work against a mixin or plugin API. Developers implementing objects that + use the mixin or support the API can then run these tests against their + own code to verify compliance. + + To define a suite, you need to define the tests themselves as well as a + callback API implementers can use to tie your tests to their specific class. + + ## Defining a Callback API + + To define the callback API, just extend this class and add your properties + or methods that must be provided. + + ## Defining Unit Tests + + To add unit tests, use the suite.module() or suite.test() methods instead + of a regular module() or test() method when defining your tests. This will + add the tests to the suite. + + ## Using a Suite + + To use a Suite to test your own objects, extend the suite subclass and + define any required methods. Then call run() on the new subclass. This + will create an instance of your class and then defining the unit tests. + + @extends Ember.Object + @private + */ + var Suite = _emberRuntimeSystemObject.default.extend({ + + /* + __Required.__ You must implement this method to apply this mixin. + Define a name for these tests - all modules are prefixed w/ it. + @type String + */ + name: null, + + /* + Invoked to actually run the test - overridden by mixins + */ + run: function () {} + + }); + + Suite.reopenClass({ + + plan: null, + + run: function () { + var C = this; + return new C().run(); + }, + + module: function (desc, opts) { + if (!opts) { + opts = {}; + } + + var setup = opts.setup; + var teardown = opts.teardown; + this.reopen({ + run: function () { + this._super.apply(this, arguments); + var title = _emberMetal.get(this, 'name') + ': ' + desc; + var ctx = this; + QUnit.module(title, { + setup: function () { + if (setup) { + setup.call(ctx); + } + }, + + teardown: function () { + if (teardown) { + teardown.call(ctx); + } + } + }); + } + }); + }, + + test: function (name, func) { + this.reopen({ + run: function () { + this._super.apply(this, arguments); + var ctx = this; + + if (!func) { + QUnit.test(name); // output warning + } else { + QUnit.test(name, function () { + return func.call(ctx); + }); + } + } + }); + }, + + // convert to guids to minimize logging. + same: function (actual, exp, message) { + actual = actual && actual.map ? actual.map(function (x) { + return _emberUtils.guidFor(x); + }) : actual; + exp = exp && exp.map ? exp.map(function (x) { + return _emberUtils.guidFor(x); + }) : exp; + return deepEqual(actual, exp, message); + }, + + // easy way to disable tests + notest: function () {}, + + importModuleTests: function (builder) { + var _this = this; + + this.module(builder._module); + + builder._tests.forEach(function (descAndFunc) { + _this.test.apply(_this, descAndFunc); + }); + } + }); + + var SuiteModuleBuilder = _emberRuntimeSystemObject.default.extend({ + _module: null, + _tests: null, + + init: function () { + this._tests = []; + }, + + module: function (name) { + this._module = name; + }, + + test: function (name, func) { + this._tests.push([name, func]); + } + }); + + exports.SuiteModuleBuilder = SuiteModuleBuilder; + exports.Suite = Suite; + exports.default = Suite; +}); +enifed('ember-runtime/tests/suites/suite.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/suite.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/suite.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/application/base_test', ['exports', 'ember-runtime/system/namespace', 'ember-runtime/system/application'], function (exports, _emberRuntimeSystemNamespace, _emberRuntimeSystemApplication) { + 'use strict'; + + QUnit.module('Ember.Application'); + + QUnit.test('Ember.Application should be a subclass of Ember.Namespace', function () { + ok(_emberRuntimeSystemNamespace.default.detect(_emberRuntimeSystemApplication.default), 'Ember.Application subclass of Ember.Namespace'); + }); +}); +enifed('ember-runtime/tests/system/application/base_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/application/base_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/application/base_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/arranged_content_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array, _emberRuntimeMixinsArray) { + 'use strict'; + + var array = undefined; + + QUnit.module('ArrayProxy - arrangedContent', { + setup: function () { + _emberMetal.run(function () { + array = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContent: _emberMetal.computed('content.[]', function () { + var content = this.get('content'); + return content && _emberRuntimeSystemNative_array.A(content.slice().sort(function (a, b) { + if (a == null) { + a = -1; + } + if (b == null) { + b = -1; + } + return b - a; + })); + }) + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 4, 5]) + }); + }); + }, + teardown: function () { + _emberMetal.run(function () { + return array.destroy(); + }); + } + }); + + QUnit.test('addObject - adds to end of \'content\' if not present', function () { + _emberMetal.run(function () { + return array.addObject(3); + }); + + deepEqual(array.get('content'), [1, 2, 4, 5, 3], 'adds to end of content'); + deepEqual(array.get('arrangedContent'), [5, 4, 3, 2, 1], 'arrangedContent stays sorted'); + + _emberMetal.run(function () { + return array.addObject(1); + }); + + deepEqual(array.get('content'), [1, 2, 4, 5, 3], 'does not add existing number to content'); + }); + + QUnit.test('addObjects - adds to end of \'content\' if not present', function () { + _emberMetal.run(function () { + return array.addObjects([1, 3, 6]); + }); + + deepEqual(array.get('content'), [1, 2, 4, 5, 3, 6], 'adds to end of content'); + deepEqual(array.get('arrangedContent'), [6, 5, 4, 3, 2, 1], 'arrangedContent stays sorted'); + }); + + QUnit.test('compact - returns arrangedContent without nulls and undefined', function () { + _emberMetal.run(function () { + return array.set('content', _emberRuntimeSystemNative_array.A([1, 3, null, 2, undefined])); + }); + + deepEqual(array.compact(), [3, 2, 1]); + }); + + QUnit.test('indexOf - returns index of object in arrangedContent', function () { + equal(array.indexOf(4), 1, 'returns arranged index'); + }); + + QUnit.test('insertAt - raises, indeterminate behavior', function () { + throws(function () { + return _emberMetal.run(function () { + return array.insertAt(2, 3); + }); + }); + }); + + QUnit.test('lastIndexOf - returns last index of object in arrangedContent', function () { + _emberMetal.run(function () { + return array.pushObject(4); + }); + + equal(array.lastIndexOf(4), 2, 'returns last arranged index'); + }); + + QUnit.test('nextObject - returns object at index in arrangedContent', function () { + equal(array.nextObject(1), 4, 'returns object at index'); + }); + + QUnit.test('objectAt - returns object at index in arrangedContent', function () { + equal(_emberRuntimeMixinsArray.objectAt(array, 1), 4, 'returns object at index'); + }); + + // Not sure if we need a specific test for it, since it's internal + QUnit.test('objectAtContent - returns object at index in arrangedContent', function () { + equal(array.objectAtContent(1), 4, 'returns object at index'); + }); + + QUnit.test('objectsAt - returns objects at indices in arrangedContent', function () { + deepEqual(array.objectsAt([0, 2, 4]), [5, 2, undefined], 'returns objects at indices'); + }); + + QUnit.test('popObject - removes last object in arrangedContent', function () { + var popped = undefined; + _emberMetal.run(function () { + return popped = array.popObject(); + }); + equal(popped, 1, 'returns last object'); + deepEqual(array.get('content'), [2, 4, 5], 'removes from content'); + }); + + QUnit.test('pushObject - adds to end of content even if it already exists', function () { + _emberMetal.run(function () { + return array.pushObject(1); + }); + deepEqual(array.get('content'), [1, 2, 4, 5, 1], 'adds to end of content'); + }); + + QUnit.test('pushObjects - adds multiple to end of content even if it already exists', function () { + _emberMetal.run(function () { + return array.pushObjects([1, 2, 4]); + }); + deepEqual(array.get('content'), [1, 2, 4, 5, 1, 2, 4], 'adds to end of content'); + }); + + QUnit.test('removeAt - removes from index in arrangedContent', function () { + _emberMetal.run(function () { + return array.removeAt(1, 2); + }); + deepEqual(array.get('content'), [1, 5]); + }); + + QUnit.test('removeObject - removes object from content', function () { + _emberMetal.run(function () { + return array.removeObject(2); + }); + deepEqual(array.get('content'), [1, 4, 5]); + }); + + QUnit.test('removeObjects - removes objects from content', function () { + _emberMetal.run(function () { + return array.removeObjects([2, 4, 6]); + }); + deepEqual(array.get('content'), [1, 5]); + }); + + QUnit.test('replace - raises, indeterminate behavior', function () { + throws(function () { + return _emberMetal.run(function () { + return array.replace(1, 2, [3]); + }); + }); + }); + + QUnit.test('replaceContent - does a standard array replace on content', function () { + _emberMetal.run(function () { + return array.replaceContent(1, 2, [3]); + }); + deepEqual(array.get('content'), [1, 3, 5]); + }); + + QUnit.test('reverseObjects - raises, use Sortable#sortAscending', function () { + throws(function () { + return _emberMetal.run(function () { + return array.reverseObjects(); + }); + }); + }); + + QUnit.test('setObjects - replaces entire content', function () { + _emberMetal.run(function () { + return array.setObjects([6, 7, 8]); + }); + deepEqual(array.get('content'), [6, 7, 8], 'replaces content'); + }); + + QUnit.test('shiftObject - removes from start of arrangedContent', function () { + var shifted = _emberMetal.run(function () { + return array.shiftObject(); + }); + + equal(shifted, 5, 'returns first object'); + deepEqual(array.get('content'), [1, 2, 4], 'removes object from content'); + }); + + QUnit.test('slice - returns a slice of the arrangedContent', function () { + deepEqual(array.slice(1, 3), [4, 2], 'returns sliced arrangedContent'); + }); + + QUnit.test('toArray - returns copy of arrangedContent', function () { + deepEqual(array.toArray(), [5, 4, 2, 1]); + }); + + QUnit.test('unshiftObject - adds to start of content', function () { + _emberMetal.run(function () { + return array.unshiftObject(6); + }); + deepEqual(array.get('content'), [6, 1, 2, 4, 5], 'adds to start of content'); + }); + + QUnit.test('unshiftObjects - adds to start of content', function () { + _emberMetal.run(function () { + array.unshiftObjects([6, 7]); + }); + deepEqual(array.get('content'), [6, 7, 1, 2, 4, 5], 'adds to start of content'); + }); + + QUnit.test('without - returns arrangedContent without object', function () { + deepEqual(array.without(2), [5, 4, 1], 'returns arranged without object'); + }); + + QUnit.test('lastObject - returns last arranged object', function () { + equal(array.get('lastObject'), 1, 'returns last arranged object'); + }); + + QUnit.test('firstObject - returns first arranged object', function () { + equal(array.get('firstObject'), 5, 'returns first arranged object'); + }); + + QUnit.module('ArrayProxy - arrangedContent matching content', { + setup: function () { + _emberMetal.run(function () { + array = _emberRuntimeSystemArray_proxy.default.create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 4, 5]) + }); + }); + }, + teardown: function () { + _emberMetal.run(function () { + array.destroy(); + }); + } + }); + + QUnit.test('insertAt - inserts object at specified index', function () { + _emberMetal.run(function () { + array.insertAt(2, 3); + }); + deepEqual(array.get('content'), [1, 2, 3, 4, 5]); + }); + + QUnit.test('replace - does a standard array replace', function () { + _emberMetal.run(function () { + array.replace(1, 2, [3]); + }); + deepEqual(array.get('content'), [1, 3, 5]); + }); + + QUnit.test('reverseObjects - reverses content', function () { + _emberMetal.run(function () { + array.reverseObjects(); + }); + deepEqual(array.get('content'), [5, 4, 2, 1]); + }); + + QUnit.module('ArrayProxy - arrangedContent with transforms', { + setup: function () { + _emberMetal.run(function () { + array = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContent: _emberMetal.computed(function () { + var content = this.get('content'); + return content && _emberRuntimeSystemNative_array.A(content.slice().sort(function (a, b) { + if (a == null) { + a = -1; + } + if (b == null) { + b = -1; + } + return b - a; + })); + }).property('content.[]'), + + objectAtContent: function (idx) { + var obj = _emberRuntimeMixinsArray.objectAt(this.get('arrangedContent'), idx); + return obj && obj.toString(); + } + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 4, 5]) + }); + }); + }, + teardown: function () { + _emberMetal.run(function () { + array.destroy(); + }); + } + }); + + QUnit.test('indexOf - returns index of object in arrangedContent', function () { + equal(array.indexOf('4'), 1, 'returns arranged index'); + }); + + QUnit.test('lastIndexOf - returns last index of object in arrangedContent', function () { + _emberMetal.run(function () { + array.pushObject(4); + }); + equal(array.lastIndexOf('4'), 2, 'returns last arranged index'); + }); + + QUnit.test('nextObject - returns object at index in arrangedContent', function () { + equal(array.nextObject(1), '4', 'returns object at index'); + }); + + QUnit.test('objectAt - returns object at index in arrangedContent', function () { + equal(_emberRuntimeMixinsArray.objectAt(array, 1), '4', 'returns object at index'); + }); + + // Not sure if we need a specific test for it, since it's internal + QUnit.test('objectAtContent - returns object at index in arrangedContent', function () { + equal(array.objectAtContent(1), '4', 'returns object at index'); + }); + + QUnit.test('objectsAt - returns objects at indices in arrangedContent', function () { + deepEqual(array.objectsAt([0, 2, 4]), ['5', '2', undefined], 'returns objects at indices'); + }); + + QUnit.test('popObject - removes last object in arrangedContent', function () { + var popped = undefined; + _emberMetal.run(function () { + popped = array.popObject(); + }); + equal(popped, '1', 'returns last object'); + deepEqual(array.get('content'), [2, 4, 5], 'removes from content'); + }); + + QUnit.test('removeObject - removes object from content', function () { + _emberMetal.run(function () { + array.removeObject('2'); + }); + deepEqual(array.get('content'), [1, 4, 5]); + }); + + QUnit.test('removeObjects - removes objects from content', function () { + _emberMetal.run(function () { + array.removeObjects(['2', '4', '6']); + }); + deepEqual(array.get('content'), [1, 5]); + }); + + QUnit.test('shiftObject - removes from start of arrangedContent', function () { + var shifted = undefined; + _emberMetal.run(function () { + shifted = array.shiftObject(); + }); + equal(shifted, '5', 'returns first object'); + deepEqual(array.get('content'), [1, 2, 4], 'removes object from content'); + }); + + QUnit.test('slice - returns a slice of the arrangedContent', function () { + deepEqual(array.slice(1, 3), ['4', '2'], 'returns sliced arrangedContent'); + }); + + QUnit.test('toArray - returns copy of arrangedContent', function () { + deepEqual(array.toArray(), ['5', '4', '2', '1']); + }); + + QUnit.test('without - returns arrangedContent without object', function () { + deepEqual(array.without('2'), ['5', '4', '1'], 'returns arranged without object'); + }); + + QUnit.test('lastObject - returns last arranged object', function () { + equal(array.get('lastObject'), '1', 'returns last arranged object'); + }); + + QUnit.test('firstObject - returns first arranged object', function () { + equal(array.get('firstObject'), '5', 'returns first arranged object'); + }); + + QUnit.test('arrangedContentArray{Will,Did}Change are called when the arranged content changes', function () { + // The behaviour covered by this test may change in the future if we decide + // that built-in array methods are not overridable. + + var willChangeCallCount = 0; + var didChangeCallCount = 0; + + var content = _emberRuntimeSystemNative_array.A([1, 2, 3]); + _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContentArrayWillChange: function () { + willChangeCallCount++; + this._super.apply(this, arguments); + }, + arrangedContentArrayDidChange: function () { + didChangeCallCount++; + this._super.apply(this, arguments); + } + }).create({ content: content }); + + equal(willChangeCallCount, 0); + equal(didChangeCallCount, 0); + + content.pushObject(4); + content.pushObject(5); + + equal(willChangeCallCount, 2); + equal(didChangeCallCount, 2); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/arranged_content_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/arranged_content_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/arranged_content_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_change_test', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('ArrayProxy - content change'); + + QUnit.test('should update length for null content', function () { + var proxy = _emberRuntimeSystemArray_proxy.default.create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + + equal(proxy.get('length'), 3, 'precond - length is 3'); + + proxy.set('content', null); + + equal(proxy.get('length'), 0, 'length updates'); + }); + + QUnit.test('should update length for null content when there is a computed property watching length', function () { + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + isEmpty: _emberRuntimeComputedComputed_macros.not('length') + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + + equal(proxy.get('length'), 3, 'precond - length is 3'); + + // Consume computed property that depends on length + proxy.get('isEmpty'); + + // update content + proxy.set('content', null); + + equal(proxy.get('length'), 0, 'length updates'); + }); + + QUnit.test('The `arrangedContentWillChange` method is invoked before `content` is changed.', function () { + var callCount = 0; + var expectedLength = undefined; + + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContentWillChange: function () { + equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked before array has changed'); + callCount++; + } + }).create({ content: _emberRuntimeSystemNative_array.A([1, 2, 3]) }); + + proxy.pushObject(4); + equal(callCount, 0, 'pushing content onto the array doesn\'t trigger it'); + + proxy.get('content').pushObject(5); + equal(callCount, 0, 'pushing content onto the content array doesn\'t trigger it'); + + expectedLength = 5; + proxy.set('content', _emberRuntimeSystemNative_array.A(['a', 'b'])); + equal(callCount, 1, 'replacing the content array triggers the hook'); + }); + + QUnit.test('The `arrangedContentDidChange` method is invoked after `content` is changed.', function () { + var callCount = 0; + var expectedLength = undefined; + + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContentDidChange: function () { + equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked after array has changed'); + callCount++; + } + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + + equal(callCount, 0, 'hook is not called after creating the object'); + + proxy.pushObject(4); + equal(callCount, 0, 'pushing content onto the array doesn\'t trigger it'); + + proxy.get('content').pushObject(5); + equal(callCount, 0, 'pushing content onto the content array doesn\'t trigger it'); + + expectedLength = 2; + proxy.set('content', _emberRuntimeSystemNative_array.A(['a', 'b'])); + equal(callCount, 1, 'replacing the content array triggers the hook'); + }); + + QUnit.test('The ArrayProxy doesn\'t explode when assigned a destroyed object', function () { + var proxy1 = _emberRuntimeSystemArray_proxy.default.create(); + var proxy2 = _emberRuntimeSystemArray_proxy.default.create(); + + _emberMetal.run(function () { + return proxy1.destroy(); + }); + + _emberMetal.set(proxy2, 'content', proxy1); + + ok(true, 'No exception was raised'); + }); + + QUnit.test('arrayContent{Will,Did}Change are called when the content changes', function () { + // The behaviour covered by this test may change in the future if we decide + // that built-in array methods are not overridable. + + var willChangeCallCount = 0; + var didChangeCallCount = 0; + + var content = _emberRuntimeSystemNative_array.A([1, 2, 3]); + _emberRuntimeSystemArray_proxy.default.extend({ + arrayContentWillChange: function () { + willChangeCallCount++; + this._super.apply(this, arguments); + }, + arrayContentDidChange: function () { + didChangeCallCount++; + this._super.apply(this, arguments); + } + }).create({ content: content }); + + equal(willChangeCallCount, 0); + equal(didChangeCallCount, 0); + + content.pushObject(4); + content.pushObject(5); + + equal(willChangeCallCount, 2); + equal(didChangeCallCount, 2); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_change_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/content_change_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/content_change_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_update_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.ArrayProxy - content update'); + + QUnit.test('The `contentArrayDidChange` method is invoked after `content` is updated.', function () { + var observerCalled = false; + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContent: _emberMetal.computed('content', function (key) { + return _emberRuntimeSystemNative_array.A(this.get('content').slice()); + }), + + contentArrayDidChange: function (array, idx, removedCount, addedCount) { + observerCalled = true; + return this._super(array, idx, removedCount, addedCount); + } + }).create({ + content: _emberRuntimeSystemNative_array.A() + }); + + proxy.pushObject(1); + + ok(observerCalled, 'contentArrayDidChange is invoked'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_update_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/content_update_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/content_update_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/length_test', ['exports', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.ArrayProxy - content change (length)'); + + QUnit.test('array proxy + aliasedProperty complex test', function () { + var aCalled = undefined, + bCalled = undefined, + cCalled = undefined, + dCalled = undefined, + eCalled = undefined; + + aCalled = bCalled = cCalled = dCalled = eCalled = 0; + + var obj = _emberRuntimeSystemObject.default.extend({ + colors: _emberMetal.computed.reads('model'), + length: _emberMetal.computed.reads('colors.length'), + + a: _emberMetal.observer('length', function () { + return aCalled++; + }), + b: _emberMetal.observer('colors.length', function () { + return bCalled++; + }), + c: _emberMetal.observer('colors.content.length', function () { + return cCalled++; + }), + d: _emberMetal.observer('colors.[]', function () { + return dCalled++; + }), + e: _emberMetal.observer('colors.content.[]', function () { + return eCalled++; + }) + }).create(); + + obj.set('model', _emberRuntimeSystemArray_proxy.default.create({ + content: _emberRuntimeSystemNative_array.A(['red', 'yellow', 'blue']) + })); + + equal(obj.get('colors.content.length'), 3); + equal(obj.get('colors.length'), 3); + equal(obj.get('length'), 3); + + equal(aCalled, 1, 'expected observer `length` to be called ONCE'); + equal(bCalled, 1, 'expected observer `colors.length` to be called ONCE'); + equal(cCalled, 1, 'expected observer `colors.content.length` to be called ONCE'); + equal(dCalled, 1, 'expected observer `colors.[]` to be called ONCE'); + equal(eCalled, 1, 'expected observer `colors.content.[]` to be called ONCE'); + + obj.get('colors').pushObjects(['green', 'red']); + + equal(obj.get('colors.content.length'), 5); + equal(obj.get('colors.length'), 5); + equal(obj.get('length'), 5); + + equal(aCalled, 2, 'expected observer `length` to be called TWICE'); + equal(bCalled, 2, 'expected observer `colors.length` to be called TWICE'); + equal(cCalled, 2, 'expected observer `colors.content.length` to be called TWICE'); + equal(dCalled, 2, 'expected observer `colors.[]` to be called TWICE'); + equal(eCalled, 2, 'expected observer `colors.content.[]` to be called TWICE'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/length_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/length_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/length_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/suite_test', ['exports', 'ember-runtime/tests/suites/mutable_array', 'ember-runtime/system/array_proxy', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeTestsSuitesMutable_array, _emberRuntimeSystemArray_proxy, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + _emberRuntimeTestsSuitesMutable_array.default.extend({ + name: 'Ember.ArrayProxy', + + newObject: function (ary) { + var ret = ary ? ary.slice() : this.newFixture(3); + return _emberRuntimeSystemArray_proxy.default.create({ content: _emberRuntimeSystemNative_array.A(ret) }); + }, + + mutate: function (obj) { + obj.pushObject(_emberMetal.get(obj, 'length') + 1); + }, + + toArray: function (obj) { + return obj.toArray ? obj.toArray() : obj.slice(); + } + }).run(); +}); +enifed('ember-runtime/tests/system/array_proxy/suite_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/suite_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/suite_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/watching_and_listening_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + function sortedListenersFor(obj, eventName) { + return _emberMetal.listenersFor(obj, eventName).sort(function (listener1, listener2) { + return listener1[1] > listener2[1] ? -1 : 1; + }); + } + + QUnit.module('ArrayProxy - watching and listening'); + + QUnit.test('setting \'content\' adds listeners correctly', function () { + var content = _emberRuntimeSystemNative_array.A(); + var proxy = _emberRuntimeSystemArray_proxy.default.create(); + + deepEqual(sortedListenersFor(content, '@array:before'), []); + deepEqual(sortedListenersFor(content, '@array:change'), []); + + proxy.set('content', content); + + deepEqual(sortedListenersFor(content, '@array:before'), [[proxy, 'contentArrayWillChange'], [proxy, 'arrangedContentArrayWillChange']]); + deepEqual(sortedListenersFor(content, '@array:change'), [[proxy, 'contentArrayDidChange'], [proxy, 'arrangedContentArrayDidChange']]); + }); + + QUnit.test('changing \'content\' adds and removes listeners correctly', function () { + var content1 = _emberRuntimeSystemNative_array.A(); + var content2 = _emberRuntimeSystemNative_array.A(); + var proxy = _emberRuntimeSystemArray_proxy.default.create({ content: content1 }); + + deepEqual(sortedListenersFor(content1, '@array:before'), [[proxy, 'contentArrayWillChange'], [proxy, 'arrangedContentArrayWillChange']]); + deepEqual(sortedListenersFor(content1, '@array:change'), [[proxy, 'contentArrayDidChange'], [proxy, 'arrangedContentArrayDidChange']]); + + proxy.set('content', content2); + + deepEqual(sortedListenersFor(content1, '@array:before'), []); + deepEqual(sortedListenersFor(content1, '@array:change'), []); + deepEqual(sortedListenersFor(content2, '@array:before'), [[proxy, 'contentArrayWillChange'], [proxy, 'arrangedContentArrayWillChange']]); + deepEqual(sortedListenersFor(content2, '@array:change'), [[proxy, 'contentArrayDidChange'], [proxy, 'arrangedContentArrayDidChange']]); + }); + + QUnit.test('regression test for https://github.com/emberjs/ember.js/issues/12475', function () { + var item1a = { id: 1 }; + var item1b = { id: 2 }; + var item1c = { id: 3 }; + var content1 = _emberRuntimeSystemNative_array.A([item1a, item1b, item1c]); + + var proxy = _emberRuntimeSystemArray_proxy.default.create({ content: content1 }); + var obj = { proxy: proxy }; + + _emberMetal.defineProperty(obj, 'ids', _emberMetal.computed('proxy.@each.id', function () { + return _emberMetal.get(this, 'proxy').mapBy('id'); + })); + + // These manually added observers are to simulate the observers added by the + // rendering process in a template like: + // + // {{#each items as |item|}} + // {{item.id}} + // {{/each}} + _emberMetal.addObserver(item1a, 'id', function () {}); + _emberMetal.addObserver(item1b, 'id', function () {}); + _emberMetal.addObserver(item1c, 'id', function () {}); + + // The EachProxy has not yet been consumed. Only the manually added + // observers are watching. + equal(_emberMetal.watcherCount(item1a, 'id'), 1); + equal(_emberMetal.watcherCount(item1b, 'id'), 1); + equal(_emberMetal.watcherCount(item1c, 'id'), 1); + + // Consume the each proxy. This causes the EachProxy to add two observers + // per item: one for "before" events and one for "after" events. + deepEqual(_emberMetal.get(obj, 'ids'), [1, 2, 3]); + + // For each item, the two each proxy observers and one manual added observer + // are watching. + equal(_emberMetal.watcherCount(item1a, 'id'), 3); + equal(_emberMetal.watcherCount(item1b, 'id'), 3); + equal(_emberMetal.watcherCount(item1c, 'id'), 3); + + // This should be a no-op because observers do not fire if the value + // 1. is an object and 2. is the same as the old value. + proxy.set('content', content1); + + equal(_emberMetal.watcherCount(item1a, 'id'), 3); + equal(_emberMetal.watcherCount(item1b, 'id'), 3); + equal(_emberMetal.watcherCount(item1c, 'id'), 3); + + // This is repeated to catch the regression. It should still be a no-op. + proxy.set('content', content1); + + equal(_emberMetal.watcherCount(item1a, 'id'), 3); + equal(_emberMetal.watcherCount(item1b, 'id'), 3); + equal(_emberMetal.watcherCount(item1c, 'id'), 3); + + // Set the content to a new array with completely different items and + // repeat the process. + var item2a = { id: 4 }; + var item2b = { id: 5 }; + var item2c = { id: 6 }; + var content2 = _emberRuntimeSystemNative_array.A([item2a, item2b, item2c]); + + _emberMetal.addObserver(item2a, 'id', function () {}); + _emberMetal.addObserver(item2b, 'id', function () {}); + _emberMetal.addObserver(item2c, 'id', function () {}); + + proxy.set('content', content2); + + deepEqual(_emberMetal.get(obj, 'ids'), [4, 5, 6]); + + equal(_emberMetal.watcherCount(item2a, 'id'), 3); + equal(_emberMetal.watcherCount(item2b, 'id'), 3); + equal(_emberMetal.watcherCount(item2c, 'id'), 3); + + // Ensure that the observers added by the EachProxy on all items in the + // first content array have been torn down. + equal(_emberMetal.watcherCount(item1a, 'id'), 1); + equal(_emberMetal.watcherCount(item1b, 'id'), 1); + equal(_emberMetal.watcherCount(item1c, 'id'), 1); + + proxy.set('content', content2); + + equal(_emberMetal.watcherCount(item2a, 'id'), 3); + equal(_emberMetal.watcherCount(item2b, 'id'), 3); + equal(_emberMetal.watcherCount(item2c, 'id'), 3); + + proxy.set('content', content2); + + equal(_emberMetal.watcherCount(item2a, 'id'), 3); + equal(_emberMetal.watcherCount(item2b, 'id'), 3); + equal(_emberMetal.watcherCount(item2c, 'id'), 3); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/watching_and_listening_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/watching_and_listening_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/watching_and_listening_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/core_object_test', ['exports', 'ember-runtime/system/core_object', 'ember-metal/property_set', 'ember-metal/mixin'], function (exports, _emberRuntimeSystemCore_object, _emberMetalProperty_set, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Ember.CoreObject'); + + QUnit.test('works with new (one arg)', function () { + var obj = new _emberRuntimeSystemCore_object.default({ + firstName: 'Stef', + lastName: 'Penner' + }); + + equal(obj.firstName, 'Stef'); + equal(obj.lastName, 'Penner'); + }); + + QUnit.test('works with new (> 1 arg)', function () { + var obj = new _emberRuntimeSystemCore_object.default({ + firstName: 'Stef', + lastName: 'Penner' + }, { + other: 'name' + }); + + equal(obj.firstName, 'Stef'); + equal(obj.lastName, 'Penner'); + + equal(obj.other, undefined); // doesn't support multiple pojo' to the constructor + }); + + QUnit.test('toString should be not be added as a property when calling toString()', function () { + var obj = new _emberRuntimeSystemCore_object.default({ + firstName: 'Foo', + lastName: 'Bar' + }); + + obj.toString(); + + notOk(obj.hasOwnProperty('toString'), 'Calling toString() should not create a toString class property'); + }); + + QUnit.test('[POST_INIT] invoked during construction', function (assert) { + var _CoreObject$extend; + + var callCount = 0; + var Obj = _emberRuntimeSystemCore_object.default.extend((_CoreObject$extend = {}, _CoreObject$extend[_emberRuntimeSystemCore_object.POST_INIT] = function () { + callCount++; + }, _CoreObject$extend)); + + equal(callCount, 0); + + Obj.create(); + + equal(callCount, 1); + }); + + QUnit.test('[POST_INIT] invoked before finishChains', function (assert) { + var _CoreObject$extend2; + + var callCount = 0; + + var Obj = _emberRuntimeSystemCore_object.default.extend((_CoreObject$extend2 = {}, _CoreObject$extend2[_emberRuntimeSystemCore_object.POST_INIT] = function () { + _emberMetalProperty_set.set(this, 'hi', 1); + }, _CoreObject$extend2.hiDidChange = _emberMetalMixin.observer('hi', function () { + callCount++; + }), _CoreObject$extend2)); + + equal(callCount, 0); + + var obj = Obj.create(); + + equal(callCount, 0); + + _emberMetalProperty_set.set(obj, 'hi', 2); + + equal(callCount, 1); + }); +}); +enifed('ember-runtime/tests/system/core_object_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/core_object_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/core_object_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/lazy_load_test', ['exports', 'ember-metal', 'ember-runtime/system/lazy_load'], function (exports, _emberMetal, _emberRuntimeSystemLazy_load) { + 'use strict'; + + QUnit.module('Lazy Loading', { + teardown: function () { + var keys = Object.keys(_emberRuntimeSystemLazy_load._loaded); + for (var i = 0; i < keys.length; i++) { + delete _emberRuntimeSystemLazy_load._loaded[keys[i]]; + } + } + }); + + QUnit.test('if a load hook is registered, it is executed when runLoadHooks are exected', function () { + var count = 0; + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.onLoad('__test_hook__', function (object) { + count += object; + }); + }); + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.runLoadHooks('__test_hook__', 1); + }); + + equal(count, 1, 'the object was passed into the load hook'); + }); + + QUnit.test('if runLoadHooks was already run, it executes newly added hooks immediately', function () { + var count = 0; + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.onLoad('__test_hook__', function (object) { + return count += object; + }); + }); + + _emberMetal.run(function () { + return _emberRuntimeSystemLazy_load.runLoadHooks('__test_hook__', 1); + }); + + count = 0; + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.onLoad('__test_hook__', function (object) { + return count += object; + }); + }); + + equal(count, 1, 'the original object was passed into the load hook'); + }); + + QUnit.test('hooks in ENV.EMBER_LOAD_HOOKS[\'hookName\'] get executed', function () { + // Note that the necessary code to perform this test is run before + // the Ember lib is loaded in tests/index.html + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.runLoadHooks('__before_ember_test_hook__', 1); + }); + + equal(window.ENV.__test_hook_count__, 1, 'the object was passed into the load hook'); + }); + + if (typeof window === 'object' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') { + QUnit.test('load hooks trigger a custom event', function () { + var eventObject = 'super duper awesome events'; + + window.addEventListener('__test_hook_for_events__', function (e) { + ok(true, 'custom event was fired'); + equal(e.detail, eventObject, 'event details are provided properly'); + }); + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.runLoadHooks('__test_hook_for_events__', eventObject); + }); + }); + } +}); +enifed('ember-runtime/tests/system/lazy_load_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/lazy_load_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/lazy_load_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/namespace/base_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/system/namespace'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeSystemNamespace) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('Namespace', { + setup: function () { + _emberRuntimeSystemNamespace.setSearchDisabled(false); + + lookup = _emberEnvironment.context.lookup = {}; + }, + teardown: function () { + _emberRuntimeSystemNamespace.setSearchDisabled(false); + + for (var prop in lookup) { + if (lookup[prop]) { + _emberMetal.run(lookup[prop], 'destroy'); + } + } + + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('Namespace should be a subclass of EmberObject', function () { + ok(_emberRuntimeSystemObject.default.detect(_emberRuntimeSystemNamespace.default)); + }); + + QUnit.test('Namespace should be duck typed', function () { + ok(_emberMetal.get(_emberRuntimeSystemNamespace.default.create(), 'isNamespace'), 'isNamespace property is true'); + }); + + QUnit.test('Namespace is found and named', function () { + var nsA = lookup.NamespaceA = _emberRuntimeSystemNamespace.default.create(); + equal(nsA.toString(), 'NamespaceA', 'namespaces should have a name if they are on lookup'); + + var nsB = lookup.NamespaceB = _emberRuntimeSystemNamespace.default.create(); + equal(nsB.toString(), 'NamespaceB', 'namespaces work if created after the first namespace processing pass'); + }); + + QUnit.test('Classes under an Namespace are properly named', function () { + var nsA = lookup.NamespaceA = _emberRuntimeSystemNamespace.default.create(); + nsA.Foo = _emberRuntimeSystemObject.default.extend(); + equal(nsA.Foo.toString(), 'NamespaceA.Foo', 'Classes pick up their parent namespace'); + + nsA.Bar = _emberRuntimeSystemObject.default.extend(); + equal(nsA.Bar.toString(), 'NamespaceA.Bar', 'New Classes get the naming treatment too'); + + var nsB = lookup.NamespaceB = _emberRuntimeSystemNamespace.default.create(); + nsB.Foo = _emberRuntimeSystemObject.default.extend(); + equal(nsB.Foo.toString(), 'NamespaceB.Foo', 'Classes in new namespaces get the naming treatment'); + }); + + //test("Classes under Ember are properly named", function() { + // // ES6TODO: This test does not work reliably when running independent package build with Broccoli config. + // Ember.TestObject = EmberObject.extend({}); + // equal(Ember.TestObject.toString(), "Ember.TestObject", "class under Ember is given a string representation"); + //}); + + QUnit.test('Lowercase namespaces are no longer supported', function () { + var nsC = lookup.namespaceC = _emberRuntimeSystemNamespace.default.create(); + equal(nsC.toString(), undefined); + }); + + QUnit.test('A namespace can be assigned a custom name', function () { + var nsA = _emberRuntimeSystemNamespace.default.create({ + name: 'NamespaceA' + }); + + var nsB = lookup.NamespaceB = _emberRuntimeSystemNamespace.default.create({ + name: 'CustomNamespaceB' + }); + + nsA.Foo = _emberRuntimeSystemObject.default.extend(); + nsB.Foo = _emberRuntimeSystemObject.default.extend(); + + equal(nsA.Foo.toString(), 'NamespaceA.Foo', 'The namespace\'s name is used when the namespace is not in the lookup object'); + equal(nsB.Foo.toString(), 'CustomNamespaceB.Foo', 'The namespace\'s name is used when the namespace is in the lookup object'); + }); + + QUnit.test('Calling namespace.nameClasses() eagerly names all classes', function () { + _emberRuntimeSystemNamespace.setSearchDisabled(true); + + var namespace = lookup.NS = _emberRuntimeSystemNamespace.default.create(); + + namespace.ClassA = _emberRuntimeSystemObject.default.extend(); + namespace.ClassB = _emberRuntimeSystemObject.default.extend(); + + _emberRuntimeSystemNamespace.default.processAll(); + + equal(namespace.ClassA.toString(), 'NS.ClassA'); + equal(namespace.ClassB.toString(), 'NS.ClassB'); + }); + + QUnit.test('A namespace can be looked up by its name', function () { + var NS = lookup.NS = _emberRuntimeSystemNamespace.default.create(); + var UI = lookup.UI = _emberRuntimeSystemNamespace.default.create(); + var CF = lookup.CF = _emberRuntimeSystemNamespace.default.create(); + + equal(_emberRuntimeSystemNamespace.default.byName('NS'), NS); + equal(_emberRuntimeSystemNamespace.default.byName('UI'), UI); + equal(_emberRuntimeSystemNamespace.default.byName('CF'), CF); + }); + + QUnit.test('A nested namespace can be looked up by its name', function () { + var UI = lookup.UI = _emberRuntimeSystemNamespace.default.create(); + UI.Nav = _emberRuntimeSystemNamespace.default.create(); + + equal(_emberRuntimeSystemNamespace.default.byName('UI.Nav'), UI.Nav); + }); + + QUnit.test('Destroying a namespace before caching lookup removes it from the list of namespaces', function () { + var CF = lookup.CF = _emberRuntimeSystemNamespace.default.create(); + + _emberMetal.run(CF, 'destroy'); + equal(_emberRuntimeSystemNamespace.default.byName('CF'), undefined, 'namespace can not be found after destroyed'); + }); + + QUnit.test('Destroying a namespace after looking up removes it from the list of namespaces', function () { + var CF = lookup.CF = _emberRuntimeSystemNamespace.default.create(); + + equal(_emberRuntimeSystemNamespace.default.byName('CF'), CF, 'precondition - namespace can be looked up by name'); + + _emberMetal.run(CF, 'destroy'); + equal(_emberRuntimeSystemNamespace.default.byName('CF'), undefined, 'namespace can not be found after destroyed'); + }); +}); +enifed('ember-runtime/tests/system/namespace/base_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/namespace/base_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/namespace/base_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/native_array/a_test', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.A'); + + QUnit.test('Ember.A', function () { + deepEqual(_emberRuntimeSystemNative_array.A([1, 2]), [1, 2], 'array values were not be modified'); + deepEqual(_emberRuntimeSystemNative_array.A(), [], 'returned an array with no arguments'); + deepEqual(_emberRuntimeSystemNative_array.A(null), [], 'returned an array with a null argument'); + ok(_emberRuntimeMixinsArray.default.detect(_emberRuntimeSystemNative_array.A()), 'returned an ember array'); + ok(_emberRuntimeMixinsArray.default.detect(_emberRuntimeSystemNative_array.A([1, 2])), 'returned an ember array'); + }); +}); +enifed('ember-runtime/tests/system/native_array/a_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/native_array/a_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/native_array/a_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/native_array/copyable_suite_test', ['exports', 'ember-utils', 'ember-runtime/system/native_array', 'ember-runtime/tests/suites/copyable'], function (exports, _emberUtils, _emberRuntimeSystemNative_array, _emberRuntimeTestsSuitesCopyable) { + 'use strict'; + + _emberRuntimeTestsSuitesCopyable.default.extend({ + name: 'NativeArray Copyable', + + newObject: function () { + return _emberRuntimeSystemNative_array.A([_emberUtils.generateGuid()]); + }, + + isEqual: function (a, b) { + if (!(a instanceof Array)) { + return false; + } + + if (!(b instanceof Array)) { + return false; + } + + if (a.length !== b.length) { + return false; + } + + return a[0] === b[0]; + }, + + shouldBeFreezable: false + }).run(); + + QUnit.module('NativeArray Copyable'); + + QUnit.test('deep copy is respected', function () { + var array = _emberRuntimeSystemNative_array.A([{ id: 1 }, { id: 2 }, { id: 3 }]); + + var copiedArray = array.copy(true); + + deepEqual(copiedArray, array, 'copied array is equivalent'); + ok(copiedArray[0] !== array[0], 'objects inside should be unique'); + }); +}); +enifed('ember-runtime/tests/system/native_array/copyable_suite_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/native_array/copyable_suite_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/native_array/copyable_suite_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/native_array/suite_test', ['exports', 'ember-runtime/system/native_array', 'ember-runtime/tests/suites/mutable_array'], function (exports, _emberRuntimeSystemNative_array, _emberRuntimeTestsSuitesMutable_array) { + 'use strict'; + + _emberRuntimeTestsSuitesMutable_array.default.extend({ + name: 'Native Array', + + newObject: function (ary) { + return _emberRuntimeSystemNative_array.A(ary ? ary.slice() : this.newFixture(3)); + }, + + mutate: function (obj) { + obj.pushObject(obj.length + 1); + }, + + toArray: function (obj) { + return obj.slice(); // make a copy. + } + }).run(); +}); +enifed('ember-runtime/tests/system/native_array/suite_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/native_array/suite_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/native_array/suite_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/computed_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + function K() { + return this; + } + + QUnit.module('EmberObject computed property'); + + _internalTestHelpers.testWithDefault('computed property on instance', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + equal(get(new MyClass(), 'foo'), 'FOO'); + }); + + _internalTestHelpers.testWithDefault('computed property on subclass', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var Subclass = MyClass.extend({ + foo: _emberMetal.computed(function () { + return 'BAR'; + }) + }); + + equal(get(new Subclass(), 'foo'), 'BAR'); + }); + + _internalTestHelpers.testWithDefault('replacing computed property with regular val', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var Subclass = MyClass.extend({ + foo: 'BAR' + }); + + equal(get(new Subclass(), 'foo'), 'BAR'); + }); + + _internalTestHelpers.testWithDefault('complex depndent keys', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + + init: function () { + this._super.apply(this, arguments); + set(this, 'bar', { baz: 'BIFF' }); + }, + + count: 0, + + foo: _emberMetal.computed(function () { + set(this, 'count', get(this, 'count') + 1); + return _emberMetal.get(get(this, 'bar'), 'baz') + ' ' + get(this, 'count'); + }).property('bar.baz') + + }); + + var Subclass = MyClass.extend({ + count: 20 + }); + + var obj1 = new MyClass(); + var obj2 = new Subclass(); + + equal(get(obj1, 'foo'), 'BIFF 1'); + equal(get(obj2, 'foo'), 'BIFF 21'); + + set(get(obj1, 'bar'), 'baz', 'BLARG'); + + equal(get(obj1, 'foo'), 'BLARG 2'); + equal(get(obj2, 'foo'), 'BIFF 21'); + + set(get(obj2, 'bar'), 'baz', 'BOOM'); + + equal(get(obj1, 'foo'), 'BLARG 2'); + equal(get(obj2, 'foo'), 'BOOM 22'); + }); + + _internalTestHelpers.testWithDefault('complex dependent keys changing complex dependent keys', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + init: function () { + this._super.apply(this, arguments); + set(this, 'bar', { baz: 'BIFF' }); + }, + + count: 0, + + foo: _emberMetal.computed(function () { + set(this, 'count', get(this, 'count') + 1); + return _emberMetal.get(get(this, 'bar'), 'baz') + ' ' + get(this, 'count'); + }).property('bar.baz') + }); + + var Subclass = MyClass.extend({ + init: function () { + this._super.apply(this, arguments); + set(this, 'bar2', { baz: 'BIFF2' }); + }, + + count: 0, + + foo: _emberMetal.computed(function () { + set(this, 'count', get(this, 'count') + 1); + return _emberMetal.get(get(this, 'bar2'), 'baz') + ' ' + get(this, 'count'); + }).property('bar2.baz') + }); + + var obj2 = new Subclass(); + + equal(get(obj2, 'foo'), 'BIFF2 1'); + + set(get(obj2, 'bar'), 'baz', 'BLARG'); + equal(get(obj2, 'foo'), 'BIFF2 1', 'should not invalidate property'); + + set(get(obj2, 'bar2'), 'baz', 'BLARG'); + equal(get(obj2, 'foo'), 'BLARG 2', 'should invalidate property'); + }); + + QUnit.test('can retrieve metadata for a computed property', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + computedProperty: _emberMetal.computed(function () {}).meta({ key: 'keyValue' }) + }); + + equal(_emberMetal.get(MyClass.metaForProperty('computedProperty'), 'key'), 'keyValue', 'metadata saved on the computed property can be retrieved'); + + var ClassWithNoMetadata = _emberRuntimeSystemObject.default.extend({ + computedProperty: _emberMetal.computed(function () {}).volatile(), + + staticProperty: 12 + }); + + equal(typeof ClassWithNoMetadata.metaForProperty('computedProperty'), 'object', 'returns empty hash if no metadata has been saved'); + + expectAssertion(function () { + ClassWithNoMetadata.metaForProperty('nonexistentProperty'); + }, 'metaForProperty() could not find a computed property with key \'nonexistentProperty\'.'); + + expectAssertion(function () { + ClassWithNoMetadata.metaForProperty('staticProperty'); + }, 'metaForProperty() could not find a computed property with key \'staticProperty\'.'); + }); + + QUnit.test('can iterate over a list of computed properties for a class', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () {}), + + fooDidChange: _emberMetal.observer('foo', function () {}), + + bar: _emberMetal.computed(function () {}), + + qux: _emberMetal.alias('foo') + }); + + var SubClass = MyClass.extend({ + baz: _emberMetal.computed(function () {}) + }); + + SubClass.reopen({ + bat: _emberMetal.computed(function () {}).meta({ iAmBat: true }) + }); + + var list = []; + + MyClass.eachComputedProperty(function (name) { + list.push(name); + }); + + deepEqual(list.sort(), ['bar', 'foo', 'qux'], 'watched and unwatched computed properties are iterated'); + + list = []; + + SubClass.eachComputedProperty(function (name, meta) { + list.push(name); + + if (name === 'bat') { + deepEqual(meta, { iAmBat: true }); + } else { + deepEqual(meta, {}); + } + }); + + deepEqual(list.sort(), ['bar', 'bat', 'baz', 'foo', 'qux'], 'all inherited properties are included'); + }); + + QUnit.test('list of properties updates when an additional property is added (such cache busting)', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(K), + + fooDidChange: _emberMetal.observer('foo', function () {}), + + bar: _emberMetal.computed(K) + }); + + var list = []; + + MyClass.eachComputedProperty(function (name) { + list.push(name); + }); + + deepEqual(list.sort(), ['bar', 'foo'].sort(), 'expected two computed properties'); + + MyClass.reopen({ + baz: _emberMetal.computed(K) + }); + + MyClass.create(); // force apply mixins + + list = []; + + MyClass.eachComputedProperty(function (name) { + list.push(name); + }); + + deepEqual(list.sort(), ['bar', 'foo', 'baz'].sort(), 'expected three computed properties'); + }); + + QUnit.test('Calling _super in call outside the immediate function of a CP getter works', function () { + function macro(callback) { + return _emberMetal.computed(function () { + return callback.call(this); + }); + } + + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var SubClass = MyClass.extend({ + foo: macro(function () { + return this._super(); + }) + }); + + ok(_emberMetal.get(SubClass.create(), 'foo'), 'FOO', 'super value is fetched'); + }); + + QUnit.test('Calling _super in apply outside the immediate function of a CP getter works', function () { + function macro(callback) { + return _emberMetal.computed(function () { + return callback.apply(this); + }); + } + + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var SubClass = MyClass.extend({ + foo: macro(function () { + return this._super(); + }) + }); + + ok(_emberMetal.get(SubClass.create(), 'foo'), 'FOO', 'super value is fetched'); + }); +}); +enifed('ember-runtime/tests/system/object/computed_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/computed_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/computed_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/create_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('EmberObject.create', {}); + + QUnit.test('simple properties are set', function () { + var o = _emberRuntimeSystemObject.default.create({ ohai: 'there' }); + equal(o.get('ohai'), 'there'); + }); + + QUnit.test('calls computed property setters', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed({ + get: function () { + return 'this is not the value you\'re looking for'; + }, + set: function (key, value) { + return value; + } + }) + }); + + var o = MyClass.create({ foo: 'bar' }); + equal(o.get('foo'), 'bar'); + }); + + if (true) { + QUnit.test('sets up mandatory setters for watched simple properties', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: null, + bar: null, + fooDidChange: _emberMetal.observer('foo', function () {}) + }); + + var o = MyClass.create({ foo: 'bar', bar: 'baz' }); + equal(o.get('foo'), 'bar'); + + var descriptor = Object.getOwnPropertyDescriptor(o, 'foo'); + ok(descriptor.set, 'Mandatory setter was setup'); + + descriptor = Object.getOwnPropertyDescriptor(o, 'bar'); + ok(!descriptor.set, 'Mandatory setter was not setup'); + }); + } + + QUnit.test('allows bindings to be defined', function () { + var obj = undefined; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + obj = _emberRuntimeSystemObject.default.create({ + foo: 'foo', + barBinding: 'foo' + }); + }, deprecationMessage); + + equal(obj.get('bar'), 'foo', 'The binding value is correct'); + }); + + QUnit.test('calls setUnknownProperty if defined', function () { + var setUnknownPropertyCalled = false; + + var MyClass = _emberRuntimeSystemObject.default.extend({ + setUnknownProperty: function (key, value) { + setUnknownPropertyCalled = true; + } + }); + + MyClass.create({ foo: 'bar' }); + ok(setUnknownPropertyCalled, 'setUnknownProperty was called'); + }); + + QUnit.test('throws if you try to define a computed property', function () { + expectAssertion(function () { + _emberRuntimeSystemObject.default.create({ + foo: _emberMetal.computed(function () {}) + }); + }, 'Ember.Object.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().'); + }); + + QUnit.test('throws if you try to call _super in a method', function () { + expectAssertion(function () { + _emberRuntimeSystemObject.default.create({ + foo: function () { + this._super.apply(this, arguments); + } + }); + }, 'Ember.Object.create no longer supports defining methods that call _super.'); + }); + + QUnit.test('throws if you try to \'mixin\' a definition', function () { + var myMixin = _emberMetal.Mixin.create({ + adder: function (arg1, arg2) { + return arg1 + arg2; + } + }); + + expectAssertion(function () { + _emberRuntimeSystemObject.default.create(myMixin); + }, 'Ember.Object.create no longer supports mixing in other definitions, use .extend & .create separately instead.'); + }); + + // This test is for IE8. + QUnit.test('property name is the same as own prototype property', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + toString: function () { + return 'MyClass'; + } + }); + + equal(MyClass.create().toString(), 'MyClass', 'should inherit property from the arguments of `EmberObject.create`'); + }); + + QUnit.test('inherits properties from passed in EmberObject', function () { + var baseObj = _emberRuntimeSystemObject.default.create({ foo: 'bar' }); + var secondaryObj = _emberRuntimeSystemObject.default.create(baseObj); + + equal(secondaryObj.foo, baseObj.foo, 'Em.O.create inherits properties from EmberObject parameter'); + }); + + QUnit.test('throws if you try to pass anything a string as a parameter', function () { + var expected = 'EmberObject.create only accepts an objects.'; + + throws(function () { + return _emberRuntimeSystemObject.default.create('some-string'); + }, expected); + }); + + QUnit.test('EmberObject.create can take undefined as a parameter', function () { + var o = _emberRuntimeSystemObject.default.create(undefined); + deepEqual(_emberRuntimeSystemObject.default.create(), o); + }); + + QUnit.test('EmberObject.create can take null as a parameter', function () { + var o = _emberRuntimeSystemObject.default.create(null); + deepEqual(_emberRuntimeSystemObject.default.create(), o); + }); + + QUnit.test('EmberObject.create avoids allocating a binding map when not necessary', function () { + var o = _emberRuntimeSystemObject.default.create(); + var m = _emberMetal.meta(o); + ok(!m.peekBindings(), 'A binding map is not allocated'); + }); +}); +enifed('ember-runtime/tests/system/object/create_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/create_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/create_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/destroy_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('ember-runtime/system/object/destroy_test'); + + _internalTestHelpers.testBoth('should schedule objects to be destroyed at the end of the run loop', function (get, set) { + var obj = _emberRuntimeSystemObject.default.create(); + var meta = undefined; + + _emberMetal.run(function () { + obj.destroy(); + meta = _emberMetal.peekMeta(obj); + ok(meta, 'meta is not destroyed immediately'); + ok(get(obj, 'isDestroying'), 'object is marked as destroying immediately'); + ok(!get(obj, 'isDestroyed'), 'object is not destroyed immediately'); + }); + + meta = _emberMetal.peekMeta(obj); + ok(get(obj, 'isDestroyed'), 'object is destroyed after run loop finishes'); + }); + + if (true) { + // MANDATORY_SETTER moves value to meta.values + // a destroyed object removes meta but leaves the accessor + // that looks it up + QUnit.test('should raise an exception when modifying watched properties on a destroyed object', function () { + var obj = _emberRuntimeSystemObject.default.extend({ + fooDidChange: _emberMetal.observer('foo', function () {}) + }).create({ + foo: 'bar' + }); + + _emberMetal.run(function () { + return obj.destroy(); + }); + + throws(function () { + return _emberMetal.set(obj, 'foo', 'baz'); + }, Error, 'raises an exception'); + }); + } + + QUnit.test('observers should not fire after an object has been destroyed', function () { + var count = 0; + var obj = _emberRuntimeSystemObject.default.extend({ + fooDidChange: _emberMetal.observer('foo', function () { + count++; + }) + }).create(); + + obj.set('foo', 'bar'); + + equal(count, 1, 'observer was fired once'); + + _emberMetal.run(function () { + _emberMetal.beginPropertyChanges(); + obj.set('foo', 'quux'); + obj.destroy(); + _emberMetal.endPropertyChanges(); + }); + + equal(count, 1, 'observer was not called after object was destroyed'); + }); + + QUnit.test('destroyed objects should not see each others changes during teardown but a long lived object should', function () { + var shouldChange = 0; + var shouldNotChange = 0; + + var objs = {}; + + var A = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAlive: true, + willDestroy: function () { + this.set('isAlive', false); + }, + bDidChange: _emberMetal.observer('objs.b.isAlive', function () { + shouldNotChange++; + }), + cDidChange: _emberMetal.observer('objs.c.isAlive', function () { + shouldNotChange++; + }) + }); + + var B = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAlive: true, + willDestroy: function () { + this.set('isAlive', false); + }, + aDidChange: _emberMetal.observer('objs.a.isAlive', function () { + shouldNotChange++; + }), + cDidChange: _emberMetal.observer('objs.c.isAlive', function () { + shouldNotChange++; + }) + }); + + var C = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAlive: true, + willDestroy: function () { + this.set('isAlive', false); + }, + aDidChange: _emberMetal.observer('objs.a.isAlive', function () { + shouldNotChange++; + }), + bDidChange: _emberMetal.observer('objs.b.isAlive', function () { + shouldNotChange++; + }) + }); + + var LongLivedObject = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAliveDidChange: _emberMetal.observer('objs.a.isAlive', function () { + shouldChange++; + }) + }); + + objs.a = new A(); + + objs.b = new B(); + + objs.c = new C(); + + new LongLivedObject(); + + _emberMetal.run(function () { + var keys = Object.keys(objs); + for (var i = 0; i < keys.length; i++) { + objs[keys[i]].destroy(); + } + }); + + equal(shouldNotChange, 0, 'destroyed graph objs should not see change in willDestroy'); + equal(shouldChange, 1, 'long lived should see change in willDestroy'); + }); + + QUnit.test('bindings should be synced when are updated in the willDestroy hook', function () { + var bar = _emberRuntimeSystemObject.default.create({ + value: false, + willDestroy: function () { + this.set('value', true); + } + }); + + var foo = _emberRuntimeSystemObject.default.create({ + value: null, + bar: bar + }); + + _emberMetal.run(function () { + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + _emberMetal.bind(foo, 'value', 'bar.value'); + }, deprecationMessage); + }); + + ok(bar.get('value') === false, 'the initial value has been bound'); + + _emberMetal.run(function () { + return bar.destroy(); + }); + + ok(foo.get('value'), 'foo is synced when the binding is updated in the willDestroy hook'); + }); +}); +enifed('ember-runtime/tests/system/object/destroy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/destroy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/destroy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/detectInstance_test', ['exports', 'ember-runtime/system/object'], function (exports, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/detectInstance'); + + QUnit.test('detectInstance detects instances correctly', function () { + var A = _emberRuntimeSystemObject.default.extend(); + var B = A.extend(); + var C = A.extend(); + + var o = _emberRuntimeSystemObject.default.create(); + var a = A.create(); + var b = B.create(); + var c = C.create(); + + ok(_emberRuntimeSystemObject.default.detectInstance(o), 'o is an instance of EmberObject'); + ok(_emberRuntimeSystemObject.default.detectInstance(a), 'a is an instance of EmberObject'); + ok(_emberRuntimeSystemObject.default.detectInstance(b), 'b is an instance of EmberObject'); + ok(_emberRuntimeSystemObject.default.detectInstance(c), 'c is an instance of EmberObject'); + + ok(!A.detectInstance(o), 'o is not an instance of A'); + ok(A.detectInstance(a), 'a is an instance of A'); + ok(A.detectInstance(b), 'b is an instance of A'); + ok(A.detectInstance(c), 'c is an instance of A'); + + ok(!B.detectInstance(o), 'o is not an instance of B'); + ok(!B.detectInstance(a), 'a is not an instance of B'); + ok(B.detectInstance(b), 'b is an instance of B'); + ok(!B.detectInstance(c), 'c is not an instance of B'); + + ok(!C.detectInstance(o), 'o is not an instance of C'); + ok(!C.detectInstance(a), 'a is not an instance of C'); + ok(!C.detectInstance(b), 'b is not an instance of C'); + ok(C.detectInstance(c), 'c is an instance of C'); + }); +}); +enifed('ember-runtime/tests/system/object/detectInstance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/detectInstance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/detectInstance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/detect_test', ['exports', 'ember-runtime/system/object'], function (exports, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/detect'); + + QUnit.test('detect detects classes correctly', function () { + var A = _emberRuntimeSystemObject.default.extend(); + var B = A.extend(); + var C = A.extend(); + + ok(_emberRuntimeSystemObject.default.detect(_emberRuntimeSystemObject.default), 'EmberObject is an EmberObject class'); + ok(_emberRuntimeSystemObject.default.detect(A), 'A is an EmberObject class'); + ok(_emberRuntimeSystemObject.default.detect(B), 'B is an EmberObject class'); + ok(_emberRuntimeSystemObject.default.detect(C), 'C is an EmberObject class'); + + ok(!A.detect(_emberRuntimeSystemObject.default), 'EmberObject is not an A class'); + ok(A.detect(A), 'A is an A class'); + ok(A.detect(B), 'B is an A class'); + ok(A.detect(C), 'C is an A class'); + + ok(!B.detect(_emberRuntimeSystemObject.default), 'EmberObject is not a B class'); + ok(!B.detect(A), 'A is not a B class'); + ok(B.detect(B), 'B is a B class'); + ok(!B.detect(C), 'C is not a B class'); + + ok(!C.detect(_emberRuntimeSystemObject.default), 'EmberObject is not a C class'); + ok(!C.detect(A), 'A is not a C class'); + ok(!C.detect(B), 'B is not a C class'); + ok(C.detect(C), 'C is a C class'); + }); +}); +enifed('ember-runtime/tests/system/object/detect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/detect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/detect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/es-compatibility-test', ['exports', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + QUnit.module('EmberObject ES Compatibility'); + + QUnit.test('extending an Ember.Object', function (assert) { + var calls = []; + + var MyObject = (function (_EmberObject) { + babelHelpers.inherits(MyObject, _EmberObject); + + function MyObject() { + babelHelpers.classCallCheck(this, MyObject); + + calls.push('constructor'); + _EmberObject.apply(this, arguments); + this.postInitProperty = 'post-init-property'; + } + + MyObject.prototype.init = function init() { + var _EmberObject$prototype$init; + + calls.push('init'); + (_EmberObject$prototype$init = _EmberObject.prototype.init).call.apply(_EmberObject$prototype$init, [this].concat(babelHelpers.slice.call(arguments))); + this.initProperty = 'init-property'; + }; + + return MyObject; + })(_emberRuntimeSystemObject.default); + + var myObject = MyObject.create({ passedProperty: 'passed-property' }); + + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); + assert.equal(myObject.postInitProperty, 'post-init-property', 'constructor property available on instance (create)'); + assert.equal(myObject.initProperty, 'init-property', 'init property available on instance (create)'); + assert.equal(myObject.passedProperty, 'passed-property', 'passed property available on instance (create)'); + + calls = []; + myObject = new MyObject({ passedProperty: 'passed-property' }); + + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); + assert.equal(myObject.postInitProperty, 'post-init-property', 'constructor property available on instance (new)'); + assert.equal(myObject.initProperty, 'init-property', 'init property available on instance (new)'); + assert.equal(myObject.passedProperty, 'passed-property', 'passed property available on instance (new)'); + }); + + QUnit.test('using super', function (assert) { + var calls = []; + + var SuperSuperObject = _emberRuntimeSystemObject.default.extend({ + method: function () { + calls.push('super-super-method'); + } + }); + + var SuperObject = SuperSuperObject.extend({ + method: function () { + this._super(); + calls.push('super-method'); + } + }); + + var MyObject = (function (_SuperObject) { + babelHelpers.inherits(MyObject, _SuperObject); + + function MyObject() { + babelHelpers.classCallCheck(this, MyObject); + + _SuperObject.apply(this, arguments); + } + + MyObject.prototype.method = function method() { + _SuperObject.prototype.method.call(this); + calls.push('method'); + }; + + return MyObject; + })(SuperObject); + + var myObject = new MyObject(); + myObject.method(); + + assert.deepEqual(calls, ['super-super-method', 'super-method', 'method'], 'chain of prototype methods called with super'); + }); + + QUnit.test('using mixins', function (assert) { + var Mixin1 = _emberMetal.Mixin.create({ + property1: 'data-1' + }); + + var Mixin2 = _emberMetal.Mixin.create({ + property2: 'data-2' + }); + + var MyObject = (function (_EmberObject$extend) { + babelHelpers.inherits(MyObject, _EmberObject$extend); + + function MyObject() { + babelHelpers.classCallCheck(this, MyObject); + + _EmberObject$extend.apply(this, arguments); + } + + return MyObject; + })(_emberRuntimeSystemObject.default.extend(Mixin1, Mixin2)); + + var myObject = new MyObject(); + assert.equal(myObject.property1, 'data-1', 'includes the first mixin'); + assert.equal(myObject.property2, 'data-2', 'includes the second mixin'); + }); + + QUnit.test('using instanceof', function (assert) { + var MyObject = (function (_EmberObject2) { + babelHelpers.inherits(MyObject, _EmberObject2); + + function MyObject() { + babelHelpers.classCallCheck(this, MyObject); + + _EmberObject2.apply(this, arguments); + } + + return MyObject; + })(_emberRuntimeSystemObject.default); + + var myObject1 = MyObject.create(); + var myObject2 = new MyObject(); + + assert.ok(myObject1 instanceof MyObject); + assert.ok(myObject1 instanceof _emberRuntimeSystemObject.default); + + assert.ok(myObject2 instanceof MyObject); + assert.ok(myObject2 instanceof _emberRuntimeSystemObject.default); + }); + + QUnit.test('extending an ES subclass of EmberObject', function (assert) { + var calls = []; + + var SubEmberObject = (function (_EmberObject3) { + babelHelpers.inherits(SubEmberObject, _EmberObject3); + + function SubEmberObject() { + babelHelpers.classCallCheck(this, SubEmberObject); + + calls.push('constructor'); + _EmberObject3.apply(this, arguments); + } + + SubEmberObject.prototype.init = function init() { + var _EmberObject3$prototype$init; + + calls.push('init'); + (_EmberObject3$prototype$init = _EmberObject3.prototype.init).call.apply(_EmberObject3$prototype$init, [this].concat(babelHelpers.slice.call(arguments))); + }; + + return SubEmberObject; + })(_emberRuntimeSystemObject.default); + + var MyObject = (function (_SubEmberObject) { + babelHelpers.inherits(MyObject, _SubEmberObject); + + function MyObject() { + babelHelpers.classCallCheck(this, MyObject); + + _SubEmberObject.apply(this, arguments); + } + + return MyObject; + })(SubEmberObject); + + MyObject.create(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); + + calls = []; + new MyObject(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); + }); + + // TODO: Needs to be fixed. Currently only `init` is called. + QUnit.skip('calling extend on an ES subclass of EmberObject', function (assert) { + var calls = []; + + var SubEmberObject = (function (_EmberObject4) { + babelHelpers.inherits(SubEmberObject, _EmberObject4); + + function SubEmberObject() { + babelHelpers.classCallCheck(this, SubEmberObject); + + calls.push('constructor'); + _EmberObject4.apply(this, arguments); + } + + SubEmberObject.prototype.init = function init() { + var _EmberObject4$prototype$init; + + calls.push('init'); + (_EmberObject4$prototype$init = _EmberObject4.prototype.init).call.apply(_EmberObject4$prototype$init, [this].concat(babelHelpers.slice.call(arguments))); + }; + + return SubEmberObject; + })(_emberRuntimeSystemObject.default); + + var MyObject = SubEmberObject.extend({}); + + MyObject.create(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); + + calls = []; + new MyObject(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); + }); +}); +enifed('ember-runtime/tests/system/object/es-compatibility-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/es-compatibility-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/es-compatibility-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/events_test', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/evented'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsEvented) { + 'use strict'; + + QUnit.module('Object events'); + + QUnit.test('a listener can be added to an object', function () { + var count = 0; + var F = function () { + count++; + }; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.on('event!', F); + obj.trigger('event!'); + + equal(count, 1, 'the event was triggered'); + + obj.trigger('event!'); + + equal(count, 2, 'the event was triggered'); + }); + + QUnit.test('a listener can be added and removed automatically the first time it is triggered', function () { + var count = 0; + var F = function () { + count++; + }; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.one('event!', F); + obj.trigger('event!'); + + equal(count, 1, 'the event was triggered'); + + obj.trigger('event!'); + + equal(count, 1, 'the event was not triggered again'); + }); + + QUnit.test('triggering an event can have arguments', function () { + var self = undefined, + args = undefined; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.on('event!', function () { + args = [].slice.call(arguments); + self = this; + }); + + obj.trigger('event!', 'foo', 'bar'); + + deepEqual(args, ['foo', 'bar']); + equal(self, obj); + }); + + QUnit.test('a listener can be added and removed automatically and have arguments', function () { + var self = undefined, + args = undefined; + var count = 0; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.one('event!', function () { + args = [].slice.call(arguments); + self = this; + count++; + }); + + obj.trigger('event!', 'foo', 'bar'); + + deepEqual(args, ['foo', 'bar']); + equal(self, obj); + equal(count, 1, 'the event is triggered once'); + + obj.trigger('event!', 'baz', 'bat'); + + deepEqual(args, ['foo', 'bar']); + equal(count, 1, 'the event was not triggered again'); + equal(self, obj); + }); + + QUnit.test('binding an event can specify a different target', function () { + var self = undefined, + args = undefined; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + var target = {}; + + obj.on('event!', target, function () { + args = [].slice.call(arguments); + self = this; + }); + + obj.trigger('event!', 'foo', 'bar'); + + deepEqual(args, ['foo', 'bar']); + equal(self, target); + }); + + QUnit.test('a listener registered with one can take method as string and can be added with different target', function () { + var count = 0; + var target = {}; + target.fn = function () { + count++; + }; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.one('event!', target, 'fn'); + obj.trigger('event!'); + + equal(count, 1, 'the event was triggered'); + + obj.trigger('event!'); + + equal(count, 1, 'the event was not triggered again'); + }); + + QUnit.test('a listener registered with one can be removed with off', function () { + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default, { + F: function () {} + }).create(); + var F = function () {}; + + obj.one('event!', F); + obj.one('event!', obj, 'F'); + + equal(obj.has('event!'), true, 'has events'); + + obj.off('event!', F); + obj.off('event!', obj, 'F'); + + equal(obj.has('event!'), false, 'has no more events'); + }); + + QUnit.test('adding and removing listeners should be chainable', function () { + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + var F = function () {}; + + var ret = obj.on('event!', F); + equal(ret, obj, '#on returns self'); + + ret = obj.off('event!', F); + equal(ret, obj, '#off returns self'); + + ret = obj.one('event!', F); + equal(ret, obj, '#one returns self'); + }); +}); +enifed('ember-runtime/tests/system/object/events_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/events_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/events_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/extend_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('EmberObject.extend'); + + QUnit.test('Basic extend', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ foo: 'BAR' }); + ok(SomeClass.isClass, 'A class has isClass of true'); + var obj = new SomeClass(); + equal(obj.foo, 'BAR'); + }); + + QUnit.test('Sub-subclass', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ foo: 'BAR' }); + var AnotherClass = SomeClass.extend({ bar: 'FOO' }); + var obj = new AnotherClass(); + equal(obj.foo, 'BAR'); + equal(obj.bar, 'FOO'); + }); + + QUnit.test('Overriding a method several layers deep', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ + fooCnt: 0, + foo: function () { + this.fooCnt++; + }, + + barCnt: 0, + bar: function () { + this.barCnt++; + } + }); + + var AnotherClass = SomeClass.extend({ + barCnt: 0, + bar: function () { + this.barCnt++; + this._super.apply(this, arguments); + } + }); + + var FinalClass = AnotherClass.extend({ + fooCnt: 0, + foo: function () { + this.fooCnt++; + this._super.apply(this, arguments); + } + }); + + var obj = new FinalClass(); + obj.foo(); + obj.bar(); + equal(obj.fooCnt, 2, 'should invoke both'); + equal(obj.barCnt, 2, 'should invoke both'); + + // Try overriding on create also + obj = FinalClass.extend({ + foo: function () { + this.fooCnt++; + this._super.apply(this, arguments); + } + }).create(); + + obj.foo(); + obj.bar(); + equal(obj.fooCnt, 3, 'should invoke final as well'); + equal(obj.barCnt, 2, 'should invoke both'); + }); + + QUnit.test('With concatenatedProperties', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ things: 'foo', concatenatedProperties: ['things'] }); + var AnotherClass = SomeClass.extend({ things: 'bar' }); + var YetAnotherClass = SomeClass.extend({ things: 'baz' }); + var some = new SomeClass(); + var another = new AnotherClass(); + var yetAnother = new YetAnotherClass(); + deepEqual(some.get('things'), ['foo'], 'base class should have just its value'); + deepEqual(another.get('things'), ['foo', 'bar'], 'subclass should have base class\' and its own'); + deepEqual(yetAnother.get('things'), ['foo', 'baz'], 'subclass should have base class\' and its own'); + }); + + QUnit.test('With concatenatedProperties class properties', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend(); + SomeClass.reopenClass({ + concatenatedProperties: ['things'], + things: 'foo' + }); + var AnotherClass = SomeClass.extend(); + AnotherClass.reopenClass({ things: 'bar' }); + var YetAnotherClass = SomeClass.extend(); + YetAnotherClass.reopenClass({ things: 'baz' }); + var some = new SomeClass(); + var another = new AnotherClass(); + var yetAnother = new YetAnotherClass(); + deepEqual(_emberMetal.get(some.constructor, 'things'), ['foo'], 'base class should have just its value'); + deepEqual(_emberMetal.get(another.constructor, 'things'), ['foo', 'bar'], 'subclass should have base class\' and its own'); + deepEqual(_emberMetal.get(yetAnother.constructor, 'things'), ['foo', 'baz'], 'subclass should have base class\' and its own'); + }); +}); +enifed('ember-runtime/tests/system/object/extend_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/extend_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/extend_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/observer_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('EmberObject observer'); + + _internalTestHelpers.testBoth('observer on class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = new MyClass(); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer on subclass', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var Subclass = MyClass.extend({ + foo: _emberMetal.observer('baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = new Subclass(); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer on instance', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }).create({ + count: 0 + }); + + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer on instance overriding class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = MyClass.extend({ + foo: _emberMetal.observer('baz', function () { + // <-- change property we observe + set(this, 'count', get(this, 'count') + 1); + }) + }).create(); + + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer should not fire after being destroyed', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + count: 0, + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }).create(); + + equal(get(obj, 'count'), 0, 'precond - should not invoke observer immediately'); + + _emberMetal.run(function () { + return obj.destroy(); + }); + + expectAssertion(function () { + set(obj, 'bar', 'BAZ'); + }, 'calling set on destroyed object: ' + obj + '.bar = BAZ'); + + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + }); + // .......................................................... + // COMPLEX PROPERTIES + // + + _internalTestHelpers.testBoth('chain observer on class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj1 = MyClass.create({ + bar: { baz: 'biff' } + }); + + var obj2 = MyClass.create({ + bar: { baz: 'biff2' } + }); + + equal(get(obj1, 'count'), 0, 'should not invoke yet'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj1, 'bar'), 'baz', 'BIFF1'); + equal(get(obj1, 'count'), 1, 'should invoke observer on obj1'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj2, 'bar'), 'baz', 'BIFF2'); + equal(get(obj1, 'count'), 1, 'should not invoke again'); + equal(get(obj2, 'count'), 1, 'should invoke observer on obj2'); + }); + + _internalTestHelpers.testBoth('chain observer on class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj1 = MyClass.extend().create({ + bar: { baz: 'biff' } + }); + + var obj2 = MyClass.extend({ + foo: _emberMetal.observer('bar2.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }).create({ + bar: { baz: 'biff2' }, + bar2: { baz: 'biff3' } + }); + + equal(get(obj1, 'count'), 0, 'should not invoke yet'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj1, 'bar'), 'baz', 'BIFF1'); + equal(get(obj1, 'count'), 1, 'should invoke observer on obj1'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj2, 'bar'), 'baz', 'BIFF2'); + equal(get(obj1, 'count'), 1, 'should not invoke again'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj2, 'bar2'), 'baz', 'BIFF3'); + equal(get(obj1, 'count'), 1, 'should not invoke again'); + equal(get(obj2, 'count'), 1, 'should invoke observer on obj2'); + }); + + _internalTestHelpers.testBoth('chain observer on class that has a reference to an uninitialized object will finish chains that reference it', function (get, set) { + var changed = false; + + var ChildClass = _emberRuntimeSystemObject.default.extend({ + parent: null, + parentOneTwoDidChange: _emberMetal.observer('parent.one.two', function () { + changed = true; + }) + }); + + var ParentClass = _emberRuntimeSystemObject.default.extend({ + one: { + two: 'old' + }, + init: function () { + this.child = ChildClass.create({ + parent: this + }); + } + }); + + var parent = new ParentClass(); + + equal(changed, false, 'precond'); + + parent.set('one.two', 'new'); + + equal(changed, true, 'child should have been notified of change to path'); + + parent.set('one', { two: 'newer' }); + + equal(changed, true, 'child should have been notified of change to path'); + }); +}); +enifed('ember-runtime/tests/system/object/observer_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/observer_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/observer_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/reopenClass_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/reopenClass'); + + QUnit.test('adds new properties to subclass', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + Subclass.reopenClass({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + equal(Subclass.foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(Subclass, 'bar'), 'BAR', 'Adds property'); + }); + + QUnit.test('class properties inherited by subclasses', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + Subclass.reopenClass({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + var SubSub = Subclass.extend(); + + equal(SubSub.foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(SubSub, 'bar'), 'BAR', 'Adds property'); + }); +}); +enifed('ember-runtime/tests/system/object/reopenClass_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/reopenClass_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/reopenClass_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/reopen_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/core_object/reopen'); + + QUnit.test('adds new properties to subclass instance', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + Subclass.reopen({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + equal(new Subclass().foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(new Subclass(), 'bar'), 'BAR', 'Adds property'); + }); + + QUnit.test('reopened properties inherited by subclasses', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + var SubSub = Subclass.extend(); + + Subclass.reopen({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + equal(new SubSub().foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(new SubSub(), 'bar'), 'BAR', 'Adds property'); + }); + + QUnit.test('allows reopening already instantiated classes', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + + Subclass.create(); + + Subclass.reopen({ + trololol: true + }); + + equal(Subclass.create().get('trololol'), true, 'reopen works'); + }); +}); +enifed('ember-runtime/tests/system/object/reopen_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/reopen_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/reopen_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/strict-mode-test', ['exports', 'ember-runtime/system/object'], function (exports, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('strict mode tests'); + + QUnit.test('__superWrapper does not throw errors in strict mode', function () { + var Foo = _emberRuntimeSystemObject.default.extend({ + blah: function () { + return 'foo'; + } + }); + + var Bar = Foo.extend({ + blah: function () { + return 'bar'; + }, + + callBlah: function () { + var blah = this.blah; + + return blah(); + } + }); + + var bar = Bar.create(); + + equal(bar.callBlah(), 'bar', 'can call local function without call/apply'); + }); +}); +enifed('ember-runtime/tests/system/object/strict-mode-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/strict-mode-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/strict-mode-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/subclasses_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/subclasses'); + + QUnit.test('chains should copy forward to subclasses when prototype created', function () { + var ObjectWithChains = undefined, + objWithChains = undefined, + SubWithChains = undefined, + SubSub = undefined, + subSub = undefined; + _emberMetal.run(function () { + ObjectWithChains = _emberRuntimeSystemObject.default.extend({ + obj: { + a: 'a', + hi: 'hi' + }, + aBinding: 'obj.a' // add chain + }); + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + // realize prototype + objWithChains = ObjectWithChains.create(); + }, deprecationMessage); + + // should not copy chains from parent yet + SubWithChains = ObjectWithChains.extend({ + hiBinding: 'obj.hi', // add chain + hello: _emberMetal.computed(function () { + return this.get('obj.hi') + ' world'; + }).property('hi'), // observe chain + greetingBinding: 'hello' + }); + + SubSub = SubWithChains.extend(); + + expectDeprecation(function () { + // should realize prototypes and copy forward chains + subSub = SubSub.create(); + }, deprecationMessage); + }); + equal(subSub.get('greeting'), 'hi world'); + _emberMetal.run(function () { + return objWithChains.set('obj.hi', 'hello'); + }); + equal(subSub.get('greeting'), 'hello world'); + }); +}); +enifed('ember-runtime/tests/system/object/subclasses_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/subclasses_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/subclasses_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/toString_test', ['exports', 'ember-utils', 'ember-environment', 'ember-runtime/system/object', 'ember-runtime/system/namespace'], function (exports, _emberUtils, _emberEnvironment, _emberRuntimeSystemObject, _emberRuntimeSystemNamespace) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('system/object/toString', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('NAME_KEY slot is present on Class', function () { + ok(_emberRuntimeSystemObject.default.extend().hasOwnProperty(_emberUtils.NAME_KEY), 'Ember Class\'s have a NAME_KEY slot'); + }); + + QUnit.test('toString() returns the same value if called twice', function () { + var Foo = _emberRuntimeSystemNamespace.default.create(); + Foo.toString = function () { + return 'Foo'; + }; + + Foo.Bar = _emberRuntimeSystemObject.default.extend(); + + equal(Foo.Bar.toString(), 'Foo.Bar'); + equal(Foo.Bar.toString(), 'Foo.Bar'); + + var obj = Foo.Bar.create(); + + equal(obj.toString(), ''); + equal(obj.toString(), ''); + + equal(Foo.Bar.toString(), 'Foo.Bar'); + }); + + QUnit.test('toString on a class returns a useful value when nested in a namespace', function () { + var obj = undefined; + + var Foo = _emberRuntimeSystemNamespace.default.create(); + Foo.toString = function () { + return 'Foo'; + }; + + Foo.Bar = _emberRuntimeSystemObject.default.extend(); + equal(Foo.Bar.toString(), 'Foo.Bar'); + + obj = Foo.Bar.create(); + equal(obj.toString(), ''); + + Foo.Baz = Foo.Bar.extend(); + equal(Foo.Baz.toString(), 'Foo.Baz'); + + obj = Foo.Baz.create(); + equal(obj.toString(), ''); + + obj = Foo.Bar.create(); + equal(obj.toString(), ''); + }); + + QUnit.test('toString on a namespace finds the namespace in lookup', function () { + var Foo = lookup.Foo = _emberRuntimeSystemNamespace.default.create(); + + equal(Foo.toString(), 'Foo'); + }); + + QUnit.test('toString on a namespace finds the namespace in lookup', function () { + var Foo = lookup.Foo = _emberRuntimeSystemNamespace.default.create(); + var obj = undefined; + + Foo.Bar = _emberRuntimeSystemObject.default.extend(); + + equal(Foo.Bar.toString(), 'Foo.Bar'); + + obj = Foo.Bar.create(); + equal(obj.toString(), ''); + }); + + QUnit.test('toString on a namespace falls back to modulePrefix, if defined', function () { + var Foo = _emberRuntimeSystemNamespace.default.create({ modulePrefix: 'foo' }); + + equal(Foo.toString(), 'foo'); + }); + + QUnit.test('toString includes toStringExtension if defined', function () { + var Foo = _emberRuntimeSystemObject.default.extend({ + toStringExtension: function () { + return 'fooey'; + } + }); + var foo = Foo.create(); + var Bar = _emberRuntimeSystemObject.default.extend({}); + var bar = Bar.create(); + + // simulate these classes being defined on a Namespace + Foo[_emberUtils.NAME_KEY] = 'Foo'; + Bar[_emberUtils.NAME_KEY] = 'Bar'; + + equal(bar.toString(), '', 'does not include toStringExtension part'); + equal(foo.toString(), '', 'Includes toStringExtension result'); + }); +}); +enifed('ember-runtime/tests/system/object/toString_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/toString_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/toString_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object_proxy_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object_proxy'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject_proxy) { + 'use strict'; + + QUnit.module('ObjectProxy'); + + _internalTestHelpers.testBoth('should not proxy properties passed to create', function (get, set) { + var Proxy = _emberRuntimeSystemObject_proxy.default.extend({ + cp: _emberMetal.computed({ + get: function (key) { + return this._cp; + }, + set: function (key, value) { + this._cp = value; + return this._cp; + } + }) + }); + var proxy = Proxy.create({ + prop: 'Foo', + cp: 'Bar' + }); + + equal(get(proxy, 'prop'), 'Foo', 'should not have tried to proxy set'); + equal(proxy._cp, 'Bar', 'should use CP setter'); + }); + + _internalTestHelpers.testBoth('should proxy properties to content', function (get, set) { + var content = { + firstName: 'Tom', + lastName: 'Dale', + unknownProperty: function (key) { + return key + ' unknown'; + } + }; + var proxy = _emberRuntimeSystemObject_proxy.default.create(); + + equal(get(proxy, 'firstName'), undefined, 'get on proxy without content should return undefined'); + expectAssertion(function () { + set(proxy, 'firstName', 'Foo'); + }, /Cannot delegate set\('firstName', Foo\) to the 'content'/i); + + set(proxy, 'content', content); + + equal(get(proxy, 'firstName'), 'Tom', 'get on proxy with content should forward to content'); + equal(get(proxy, 'lastName'), 'Dale', 'get on proxy with content should forward to content'); + equal(get(proxy, 'foo'), 'foo unknown', 'get on proxy with content should forward to content'); + + set(proxy, 'lastName', 'Huda'); + + equal(get(content, 'lastName'), 'Huda', 'content should have new value from set on proxy'); + equal(get(proxy, 'lastName'), 'Huda', 'proxy should have new value from set on proxy'); + + set(proxy, 'content', { firstName: 'Yehuda', lastName: 'Katz' }); + + equal(get(proxy, 'firstName'), 'Yehuda', 'proxy should reflect updated content'); + equal(get(proxy, 'lastName'), 'Katz', 'proxy should reflect updated content'); + }); + + _internalTestHelpers.testBoth('should work with watched properties', function (get, set) { + var content1 = { firstName: 'Tom', lastName: 'Dale' }; + var content2 = { firstName: 'Yehuda', lastName: 'Katz' }; + var count = 0; + var last = undefined; + + var Proxy = _emberRuntimeSystemObject_proxy.default.extend({ + fullName: _emberMetal.computed(function () { + var firstName = this.get('firstName'); + var lastName = this.get('lastName'); + + if (firstName && lastName) { + return firstName + ' ' + lastName; + } + return firstName || lastName; + }).property('firstName', 'lastName') + }); + + var proxy = Proxy.create(); + + _emberMetal.addObserver(proxy, 'fullName', function () { + last = get(proxy, 'fullName'); + count++; + }); + + // proxy without content returns undefined + equal(get(proxy, 'fullName'), undefined); + + // setting content causes all watched properties to change + set(proxy, 'content', content1); + // both dependent keys changed + equal(count, 2); + equal(last, 'Tom Dale'); + + // setting property in content causes proxy property to change + set(content1, 'lastName', 'Huda'); + equal(count, 3); + equal(last, 'Tom Huda'); + + // replacing content causes all watched properties to change + set(proxy, 'content', content2); + // both dependent keys changed + equal(count, 5); + equal(last, 'Yehuda Katz'); + // content1 is no longer watched + ok(!_emberMetal.isWatching(content1, 'firstName'), 'not watching firstName'); + ok(!_emberMetal.isWatching(content1, 'lastName'), 'not watching lastName'); + + // setting property in new content + set(content2, 'firstName', 'Tomhuda'); + equal(last, 'Tomhuda Katz'); + equal(count, 6); + + // setting property in proxy syncs with new content + set(proxy, 'lastName', 'Katzdale'); + equal(count, 7); + equal(last, 'Tomhuda Katzdale'); + equal(get(content2, 'firstName'), 'Tomhuda'); + equal(get(content2, 'lastName'), 'Katzdale'); + }); + + QUnit.test('set and get should work with paths', function () { + var content = { foo: { bar: 'baz' } }; + var proxy = _emberRuntimeSystemObject_proxy.default.create({ content: content }); + var count = 0; + + proxy.set('foo.bar', 'hello'); + equal(proxy.get('foo.bar'), 'hello'); + equal(proxy.get('content.foo.bar'), 'hello'); + + proxy.addObserver('foo.bar', function () { + count++; + }); + + proxy.set('foo.bar', 'bye'); + + equal(count, 1); + equal(proxy.get('foo.bar'), 'bye'); + equal(proxy.get('content.foo.bar'), 'bye'); + }); + + _internalTestHelpers.testBoth('should transition between watched and unwatched strategies', function (get, set) { + var content = { foo: 'foo' }; + var proxy = _emberRuntimeSystemObject_proxy.default.create({ content: content }); + var count = 0; + + function observer() { + count++; + } + + equal(get(proxy, 'foo'), 'foo'); + + set(content, 'foo', 'bar'); + + equal(get(proxy, 'foo'), 'bar'); + + set(proxy, 'foo', 'foo'); + + equal(get(content, 'foo'), 'foo'); + equal(get(proxy, 'foo'), 'foo'); + + _emberMetal.addObserver(proxy, 'foo', observer); + + equal(count, 0); + equal(get(proxy, 'foo'), 'foo'); + + set(content, 'foo', 'bar'); + + equal(count, 1); + equal(get(proxy, 'foo'), 'bar'); + + set(proxy, 'foo', 'foo'); + + equal(count, 2); + equal(get(content, 'foo'), 'foo'); + equal(get(proxy, 'foo'), 'foo'); + + _emberMetal.removeObserver(proxy, 'foo', observer); + + set(content, 'foo', 'bar'); + + equal(get(proxy, 'foo'), 'bar'); + + set(proxy, 'foo', 'foo'); + + equal(get(content, 'foo'), 'foo'); + equal(get(proxy, 'foo'), 'foo'); + }); + + _internalTestHelpers.testBoth('setting `undefined` to a proxied content property should override its existing value', function (get, set) { + var proxyObject = _emberRuntimeSystemObject_proxy.default.create({ + content: { + prop: 'emberjs' + } + }); + set(proxyObject, 'prop', undefined); + equal(get(proxyObject, 'prop'), undefined, 'sets the `undefined` value to the proxied content'); + }); +}); +enifed('ember-runtime/tests/system/object_proxy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object_proxy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object_proxy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/camelize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.camelize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.camelize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.camelize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('camelize normal string', function () { + deepEqual(_emberRuntimeSystemString.camelize('my favorite items'), 'myFavoriteItems'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.camelize(), 'myFavoriteItems'); + } + }); + + QUnit.test('camelize capitalized string', function () { + deepEqual(_emberRuntimeSystemString.camelize('I Love Ramen'), 'iLoveRamen'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('I Love Ramen'.camelize(), 'iLoveRamen'); + } + }); + + QUnit.test('camelize dasherized string', function () { + deepEqual(_emberRuntimeSystemString.camelize('css-class-name'), 'cssClassName'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.camelize(), 'cssClassName'); + } + }); + + QUnit.test('camelize underscored string', function () { + deepEqual(_emberRuntimeSystemString.camelize('action_name'), 'actionName'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.camelize(), 'actionName'); + } + }); + + QUnit.test('camelize dot notation string', function () { + deepEqual(_emberRuntimeSystemString.camelize('action.name'), 'actionName'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action.name'.camelize(), 'actionName'); + } + }); + + QUnit.test('does nothing with camelcased string', function () { + deepEqual(_emberRuntimeSystemString.camelize('innerHTML'), 'innerHTML'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.camelize(), 'innerHTML'); + } + }); + + QUnit.test('camelize namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.camelize('PrivateDocs/OwnerInvoice'), 'privateDocs/ownerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.camelize(), 'privateDocs/ownerInvoice'); + } + }); + + QUnit.test('camelize namespaced underscored string', function () { + deepEqual(_emberRuntimeSystemString.camelize('private_docs/owner_invoice'), 'privateDocs/ownerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private_docs/owner_invoice'.camelize(), 'privateDocs/ownerInvoice'); + } + }); + + QUnit.test('camelize namespaced dasherized string', function () { + deepEqual(_emberRuntimeSystemString.camelize('private-docs/owner-invoice'), 'privateDocs/ownerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private-docs/owner-invoice'.camelize(), 'privateDocs/ownerInvoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/camelize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/camelize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/camelize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/capitalize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.capitalize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.capitalize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.capitalize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('capitalize normal string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('my favorite items'), 'My favorite items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.capitalize(), 'My favorite items'); + } + }); + + QUnit.test('capitalize dasherized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('css-class-name'), 'Css-class-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.capitalize(), 'Css-class-name'); + } + }); + + QUnit.test('capitalize underscored string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('action_name'), 'Action_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.capitalize(), 'Action_name'); + } + }); + + QUnit.test('capitalize camelcased string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('innerHTML'), 'InnerHTML'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.capitalize(), 'InnerHTML'); + } + }); + + QUnit.test('does nothing with capitalized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('Capitalized string'), 'Capitalized string'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('Capitalized string'.capitalize(), 'Capitalized string'); + } + }); + + QUnit.test('capitalize namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('privateDocs/ownerInvoice'), 'PrivateDocs/OwnerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.capitalize(), 'PrivateDocs/OwnerInvoice'); + } + }); + + QUnit.test('capitalize namespaced underscored string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('private_docs/owner_invoice'), 'Private_docs/Owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private_docs/owner_invoice'.capitalize(), 'Private_docs/Owner_invoice'); + } + }); + + QUnit.test('capitalize namespaced dasherized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('private-docs/owner-invoice'), 'Private-docs/Owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private-docs/owner-invoice'.capitalize(), 'Private-docs/Owner-invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/capitalize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/capitalize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/capitalize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/classify_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.classify'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.classify is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.classify, 'String.prototype helper disabled'); + }); + } + + function test(given, expected, description) { + QUnit.test(description, function () { + deepEqual(_emberRuntimeSystemString.classify(given), expected); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual(given.classify(), expected); + } + }); + } + + test('my favorite items', 'MyFavoriteItems', 'classify normal string'); + test('css-class-name', 'CssClassName', 'classify dasherized string'); + test('action_name', 'ActionName', 'classify underscored string'); + test('privateDocs/ownerInvoice', 'PrivateDocs/OwnerInvoice', 'classify namespaced camelized string'); + test('private_docs/owner_invoice', 'PrivateDocs/OwnerInvoice', 'classify namespaced underscored string'); + test('private-docs/owner-invoice', 'PrivateDocs/OwnerInvoice', 'classify namespaced dasherized string'); + test('-view-registry', '_ViewRegistry', 'classify prefixed dasherized string'); + test('components/-text-field', 'Components/_TextField', 'classify namespaced prefixed dasherized string'); + test('_Foo_Bar', '_FooBar', 'classify underscore-prefixed underscored string'); + test('_Foo-Bar', '_FooBar', 'classify underscore-prefixed dasherized string'); + test('_foo/_bar', '_Foo/_Bar', 'classify underscore-prefixed-namespaced underscore-prefixed string'); + test('-foo/_bar', '_Foo/_Bar', 'classify dash-prefixed-namespaced underscore-prefixed string'); + test('-foo/-bar', '_Foo/_Bar', 'classify dash-prefixed-namespaced dash-prefixed string'); + test('InnerHTML', 'InnerHTML', 'does nothing with classified string'); + test('_FooBar', '_FooBar', 'does nothing with classified prefixed string'); +}); +enifed('ember-runtime/tests/system/string/classify_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/classify_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/classify_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/dasherize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.dasherize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.dasherize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.dasherize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('dasherize normal string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('my favorite items'), 'my-favorite-items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.dasherize(), 'my-favorite-items'); + } + }); + + QUnit.test('does nothing with dasherized string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('css-class-name'), 'css-class-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.dasherize(), 'css-class-name'); + } + }); + + QUnit.test('dasherize underscored string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('action_name'), 'action-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.dasherize(), 'action-name'); + } + }); + + QUnit.test('dasherize camelcased string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('innerHTML'), 'inner-html'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.dasherize(), 'inner-html'); + } + }); + + QUnit.test('dasherize string that is the property name of Object.prototype', function () { + deepEqual(_emberRuntimeSystemString.dasherize('toString'), 'to-string'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('toString'.dasherize(), 'to-string'); + } + }); + + QUnit.test('dasherize namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('PrivateDocs/OwnerInvoice'), 'private-docs/owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.dasherize(), 'private-docs/owner-invoice'); + } + }); + + QUnit.test('dasherize namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('privateDocs/ownerInvoice'), 'private-docs/owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.dasherize(), 'private-docs/owner-invoice'); + } + }); + + QUnit.test('dasherize namespaced underscored string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('private_docs/owner_invoice'), 'private-docs/owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private_docs/owner_invoice'.dasherize(), 'private-docs/owner-invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/dasherize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/dasherize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/dasherize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/decamelize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.decamelize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.decamelize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.decamelize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('does nothing with normal string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('my favorite items'), 'my favorite items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.decamelize(), 'my favorite items'); + } + }); + + QUnit.test('does nothing with dasherized string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('css-class-name'), 'css-class-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.decamelize(), 'css-class-name'); + } + }); + + QUnit.test('does nothing with underscored string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('action_name'), 'action_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.decamelize(), 'action_name'); + } + }); + + QUnit.test('converts a camelized string into all lower case separated by underscores.', function () { + deepEqual(_emberRuntimeSystemString.decamelize('innerHTML'), 'inner_html'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.decamelize(), 'inner_html'); + } + }); + + QUnit.test('decamelizes strings with numbers', function () { + deepEqual(_emberRuntimeSystemString.decamelize('size160Url'), 'size160_url'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('size160Url'.decamelize(), 'size160_url'); + } + }); + + QUnit.test('decamelize namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('PrivateDocs/OwnerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.decamelize(), 'private_docs/owner_invoice'); + } + }); + + QUnit.test('decamelize namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('privateDocs/ownerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.decamelize(), 'private_docs/owner_invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/decamelize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/decamelize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/decamelize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/fmt_string_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.fmt'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.fmt is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.fmt, 'String.prototype helper disabled'); + }); + } + + QUnit.test('\'Hello %@ %@\'.fmt(\'John\', \'Doe\') => \'Hello John Doe\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('Hello %@ %@', ['John', 'Doe']), 'Hello John Doe'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('Hello %@ %@'.fmt('John', 'Doe'), 'Hello John Doe'); + } + }); + + QUnit.test('\'Hello %@2 %@1\'.fmt(\'John\', \'Doe\') => \'Hello Doe John\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('Hello %@2 %@1', ['John', 'Doe']), 'Hello Doe John'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('Hello %@2 %@1'.fmt('John', 'Doe'), 'Hello Doe John'); + } + }); + + QUnit.test('\'%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01\'.fmt(\'One\', \'Two\', \'Three\', \'Four\', \'Five\', \'Six\', \'Seven\', \'Eight\') => \'Eight Seven Six Five Four Three Two One\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01', ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight']), 'Eight Seven Six Five Four Three Two One'); + + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01'.fmt('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight'), 'Eight Seven Six Five Four Three Two One'); + } + }); + + QUnit.test('\'data: %@\'.fmt({ id: 3 }) => \'data: {id: 3}\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('data: %@', [{ id: 3 }]), 'data: {id: 3}'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('data: %@'.fmt({ id: 3 }), 'data: {id: 3}'); + } + }); + + QUnit.test('works with argument form', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('%@', 'John'), 'John'); + equal(_emberRuntimeSystemString.fmt('%@ %@', ['John'], 'Doe'), '[John] Doe'); + }); +}); +enifed('ember-runtime/tests/system/string/fmt_string_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/fmt_string_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/fmt_string_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/loc_test', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + var oldString = undefined; + + QUnit.module('EmberStringUtils.loc', { + setup: function () { + oldString = _emberMetal.default.STRINGS; + _emberMetal.default.STRINGS = { + '_Hello World': 'Bonjour le monde', + '_Hello %@': 'Bonjour %@', + '_Hello %@ %@': 'Bonjour %@ %@', + '_Hello %@# %@#': 'Bonjour %@2 %@1' + }; + }, + + teardown: function () { + _emberMetal.default.STRINGS = oldString; + } + }); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.loc is not available without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.loc, 'String.prototype helper disabled'); + }); + } + + QUnit.test('\'_Hello World\'.loc() => \'Bonjour le monde\'', function () { + equal(_emberRuntimeSystemString.loc('_Hello World'), 'Bonjour le monde'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Hello World'.loc(), 'Bonjour le monde'); + } + }); + + QUnit.test('\'_Hello %@ %@\'.loc(\'John\', \'Doe\') => \'Bonjour John Doe\'', function () { + equal(_emberRuntimeSystemString.loc('_Hello %@ %@', ['John', 'Doe']), 'Bonjour John Doe'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Hello %@ %@'.loc('John', 'Doe'), 'Bonjour John Doe'); + } + }); + + QUnit.test('\'_Hello %@# %@#\'.loc(\'John\', \'Doe\') => \'Bonjour Doe John\'', function () { + equal(_emberRuntimeSystemString.loc('_Hello %@# %@#', ['John', 'Doe']), 'Bonjour Doe John'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Hello %@# %@#'.loc('John', 'Doe'), 'Bonjour Doe John'); + } + }); + + QUnit.test('\'_Not In Strings\'.loc() => \'_Not In Strings\'', function () { + equal(_emberRuntimeSystemString.loc('_Not In Strings'), '_Not In Strings'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Not In Strings'.loc(), '_Not In Strings'); + } + }); + + QUnit.test('works with argument form', function () { + equal(_emberRuntimeSystemString.loc('_Hello %@', 'John'), 'Bonjour John'); + equal(_emberRuntimeSystemString.loc('_Hello %@ %@', ['John'], 'Doe'), 'Bonjour [John] Doe'); + }); +}); +// ES6TODO Ember.STRINGS +enifed('ember-runtime/tests/system/string/loc_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/loc_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/loc_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/underscore_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.underscore'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.underscore is not available without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.underscore, 'String.prototype helper disabled'); + }); + } + + QUnit.test('with normal string', function () { + deepEqual(_emberRuntimeSystemString.underscore('my favorite items'), 'my_favorite_items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.underscore(), 'my_favorite_items'); + } + }); + + QUnit.test('with dasherized string', function () { + deepEqual(_emberRuntimeSystemString.underscore('css-class-name'), 'css_class_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.underscore(), 'css_class_name'); + } + }); + + QUnit.test('does nothing with underscored string', function () { + deepEqual(_emberRuntimeSystemString.underscore('action_name'), 'action_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.underscore(), 'action_name'); + } + }); + + QUnit.test('with camelcased string', function () { + deepEqual(_emberRuntimeSystemString.underscore('innerHTML'), 'inner_html'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.underscore(), 'inner_html'); + } + }); + + QUnit.test('underscore namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.underscore('PrivateDocs/OwnerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.underscore(), 'private_docs/owner_invoice'); + } + }); + + QUnit.test('underscore namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.underscore('privateDocs/ownerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.underscore(), 'private_docs/owner_invoice'); + } + }); + + QUnit.test('underscore namespaced dasherized string', function () { + deepEqual(_emberRuntimeSystemString.underscore('private-docs/owner-invoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private-docs/owner-invoice'.underscore(), 'private_docs/owner_invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/underscore_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/underscore_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/underscore_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/w_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.w'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.w is not available without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.w, 'String.prototype helper disabled'); + }); + } + + QUnit.test('\'one two three\'.w() => [\'one\',\'two\',\'three\']', function () { + deepEqual(_emberRuntimeSystemString.w('one two three'), ['one', 'two', 'three']); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('one two three'.w(), ['one', 'two', 'three']); + } + }); + + QUnit.test('\'one two three\'.w() with extra spaces between words => [\'one\',\'two\',\'three\']', function () { + deepEqual(_emberRuntimeSystemString.w('one two three'), ['one', 'two', 'three']); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('one two three'.w(), ['one', 'two', 'three']); + } + }); + + QUnit.test('\'one two three\'.w() with tabs', function () { + deepEqual(_emberRuntimeSystemString.w('one\ttwo three'), ['one', 'two', 'three']); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('one\ttwo three'.w(), ['one', 'two', 'three']); + } + }); +}); +enifed('ember-runtime/tests/system/string/w_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/w_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/w_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/compat.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/compat.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/compat.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/assert-reserved-named-arguments.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/assert-reserved-named-arguments.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/assert-reserved-named-arguments.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/deprecate-render-model.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/deprecate-render-model.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/deprecate-render-model.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/deprecate-render.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/deprecate-render.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/deprecate-render.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-action-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-action-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-action-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-angle-bracket-components.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-angle-bracket-components.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-angle-bracket-components.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-attrs-into-args.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-attrs-into-args.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-attrs-into-args.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-each-in-into-each.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-each-in-into-each.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-each-in-into-each.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-has-block-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-has-block-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-has-block-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-inline-link-to.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-inline-link-to.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-inline-link-to.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-input-on-to-onEvent.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-input-on-to-onEvent.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-input-on-to-onEvent.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-input-type-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-input-type-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-input-type-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-item-class.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-item-class.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-item-class.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-old-binding-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-old-binding-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-old-binding-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-old-class-binding-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-old-class-binding-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-old-class-binding-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-top-level-components.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-top-level-components.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-top-level-components.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/bootstrap.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/bootstrap.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/bootstrap.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/calculate-location-display.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/calculate-location-display.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/calculate-location-display.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/compile-options.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/compile-options.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/compile-options.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/compile.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/compile.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/compile.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/precompile.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/precompile.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/precompile.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: assert-reserved-named-arguments'); + + QUnit.test('Paths beginning with @ are not valid', function () { + expect(3); + + expectAssertion(function () { + _emberTemplateCompilerIndex.compile('{{@foo}}', { + moduleName: 'baz/foo-bar' + }); + }, '\'@foo\' is not a valid path. (\'baz/foo-bar\' @ L1:C2) '); + + expectAssertion(function () { + _emberTemplateCompilerIndex.compile('{{#if @foo}}Yup{{/if}}', { + moduleName: 'baz/foo-bar' + }); + }, '\'@foo\' is not a valid path. (\'baz/foo-bar\' @ L1:C6) '); + + expectAssertion(function () { + _emberTemplateCompilerIndex.compile('{{input type=(if @foo "bar" "baz")}}', { + moduleName: 'baz/foo-bar' + }); + }, '\'@foo\' is not a valid path. (\'baz/foo-bar\' @ L1:C17) '); + }); +}); +enifed('ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-model-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: deprecate-model-render'); + + QUnit.test('Using `{{render` with model provides a deprecation', function () { + expect(1); + + var expectedMessage = 'Please refactor `{{render "foo-bar" coolModel}}` to a component and' + ' invoke via `{{foo-bar model=coolModel}}`. (\'baz/foo-bar\' @ L1:C0) '; + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{render "foo-bar" coolModel}}', { + moduleName: 'baz/foo-bar' + }); + }, expectedMessage); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-model-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/deprecate-render-model-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/deprecate-render-model-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: deprecate-render'); + + QUnit.test('Using `{{render` without a model provides a deprecation', function () { + expect(1); + + var expectedMessage = 'Please refactor `{{render "foo-bar"}}` to a component and' + ' invoke via `{{foo-bar}}`. (\'baz/foo-bar\' @ L1:C0) '; + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{render "foo-bar"}}', { + moduleName: 'baz/foo-bar' + }); + }, expectedMessage); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/deprecate-render-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/deprecate-render-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-inline-link-to-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: assert-no-view-and-controller-paths without legacy view support'); + + QUnit.test('Can transform an inline {{link-to}} without error', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{link-to \'foo\' \'index\'}}', { + moduleName: 'foo/bar/baz' + }); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-inline-link-to-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/transform-inline-link-to-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/transform-inline-link-to-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-on-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: transform-input-on'); + + QUnit.test('Using `action` without `on` provides a deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input action="foo"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input action="foo"}}\' (\'foo/bar/baz\' @ L1:C0) is deprecated. Please use \'{{input enter="foo"}}\' instead.'); + }); + + QUnit.test('Using `action` with `on` provides a deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input on="focus-in" action="foo"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input on="focus-in" action="foo"}}\' (\'foo/bar/baz\' @ L1:C0) is deprecated. Please use \'{{input focus-in="foo"}}\' instead.'); + }); + + QUnit.test('Using `on=\'keyPress\'` does not clobber `keyPress`', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input on="keyPress" action="foo"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input on="keyPress" action="foo"}}\' (\'foo/bar/baz\' @ L1:C0) is deprecated. Please use \'{{input key-press="foo"}}\' instead.'); + }); + + QUnit.test('Using `on=\'foo\'` without `action=\'asdf\'` raises specific deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input on="asdf"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input on="asdf" ...}}\' without specifying an action (\'foo/bar/baz\' @ L1:C0) will do nothing.'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-on-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/transform-input-on-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/transform-input-on-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-type-syntax-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: input type syntax'); + + QUnit.test('Can compile an {{input}} helper that has a sub-expression value as its type', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{input type=(if true \'password\' \'text\')}}'); + }); + + QUnit.test('Can compile an {{input}} helper with a string literal type', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{input type=\'text\'}}'); + }); + + QUnit.test('Can compile an {{input}} helper with a type stored in a var', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{input type=_type}}'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-type-syntax-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/system/bootstrap-test', ['exports', 'ember-metal', 'ember-views', 'ember-glimmer', 'ember-template-compiler/system/bootstrap', 'internal-test-helpers'], function (exports, _emberMetal, _emberViews, _emberGlimmer, _emberTemplateCompilerSystemBootstrap, _internalTestHelpers) { + 'use strict'; + + var trim = _emberViews.jQuery.trim; + + var component = undefined, + fixture = undefined; + + function checkTemplate(templateName) { + _emberMetal.run(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }); + + var template = _emberGlimmer.getTemplate(templateName); + + ok(template, 'template is available on Ember.TEMPLATES'); + equal(_emberViews.jQuery('#qunit-fixture script').length, 0, 'script removed'); + + var owner = _internalTestHelpers.buildOwner(); + owner.register('template:-top-level', template); + owner.register('component:-top-level', _emberGlimmer.Component.extend({ + layoutName: '-top-level', + firstName: 'Tobias', + drug: 'teamocil' + })); + + component = owner.lookup('component:-top-level'); + _internalTestHelpers.runAppend(component); + + equal(_emberViews.jQuery('#qunit-fixture').text().trim(), 'Tobias takes teamocil', 'template works'); + _internalTestHelpers.runDestroy(component); + } + + QUnit.module('ember-templates: bootstrap', { + setup: function () { + fixture = document.getElementById('qunit-fixture'); + }, + teardown: function () { + _emberGlimmer.setTemplates({}); + _internalTestHelpers.runDestroy(component); + } + }); + + QUnit.test('template with data-template-name should add a new template to Ember.TEMPLATES', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + checkTemplate('funkyTemplate'); + }); + + QUnit.test('template with id instead of data-template-name should add a new template to Ember.TEMPLATES', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + checkTemplate('funkyTemplate'); + }); + + QUnit.test('template without data-template-name or id should default to application', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + checkTemplate('application'); + }); + + if (typeof Handlebars === 'object') { + QUnit.test('template with type text/x-raw-handlebars should be parsed', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + _emberMetal.run(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }); + + var template = _emberGlimmer.getTemplate('funkyTemplate'); + + ok(template, 'template with name funkyTemplate available'); + + // This won't even work with Ember templates + equal(trim(template({ name: 'Tobias' })), 'Tobias'); + }); + } + + QUnit.test('duplicated default application templates should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('default application template and id application template present should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('default application template and data-template-name application template present should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('duplicated template id should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('duplicated template data-template-name should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); +}); +enifed('ember-template-compiler/tests/system/bootstrap-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/system/bootstrap-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/system/bootstrap-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/system/compile_options_test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: default compile options'); + + QUnit.test('default options are a new copy', function () { + notEqual(_emberTemplateCompilerIndex.compileOptions(), _emberTemplateCompilerIndex.compileOptions()); + }); + + QUnit.test('has default AST plugins', function (assert) { + assert.expect(_emberTemplateCompilerIndex.defaultPlugins.length); + + var plugins = _emberTemplateCompilerIndex.compileOptions().plugins.ast; + + for (var i = 0; i < _emberTemplateCompilerIndex.defaultPlugins.length; i++) { + var plugin = _emberTemplateCompilerIndex.defaultPlugins[i]; + assert.ok(plugins.indexOf(plugin) > -1, 'includes ' + plugin); + } + }); +}); +enifed('ember-template-compiler/tests/system/compile_options_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/system/compile_options_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/system/compile_options_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/adapters/adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/adapters/adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/adapters/adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/adapters/qunit.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/adapters/qunit.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/adapters/qunit.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/events.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/events.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/events.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/ext/application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/ext/application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/ext/application.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/ext/rsvp.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/ext/rsvp.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/ext/rsvp.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/and_then.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/and_then.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/and_then.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/click.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/click.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/click.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/current_path.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/current_path.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/current_path.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/current_route_name.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/current_route_name.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/current_route_name.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/current_url.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/current_url.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/current_url.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/fill_in.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/fill_in.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/fill_in.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/find.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/find.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/find.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/find_with_assert.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/find_with_assert.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/find_with_assert.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/key_event.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/key_event.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/key_event.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/pause_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/pause_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/pause_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/trigger_event.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/trigger_event.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/trigger_event.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/visit.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/visit.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/visit.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/wait.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/wait.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/wait.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/initializers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/initializers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/initializers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/setup_for_testing.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/setup_for_testing.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/setup_for_testing.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/on_inject_helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/on_inject_helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/on_inject_helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/pending_requests.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/pending_requests.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/pending_requests.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/promise.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/promise.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/promise.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/run.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/run.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/run.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/waiters.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/waiters.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/waiters.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/acceptance_test', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test', 'ember-testing/adapters/qunit', 'ember-testing/initializers', 'ember-application', 'ember-routing', 'ember-template-compiler', 'ember-runtime', 'ember-glimmer'], function (exports, _emberMetal, _emberViews, _emberTestingTest, _emberTestingAdaptersQunit, _emberTestingInitializers, _emberApplication, _emberRouting, _emberTemplateCompiler, _emberRuntime, _emberGlimmer) { + 'use strict'; + + //ES6TODO: we need {{link-to}} and {{outlet}} to exist here + + var App, find, click, fillIn, currentRoute, currentURL, visit, originalAdapter, andThen, indexHitCount; + + QUnit.module('ember-testing Acceptance', { + setup: function () { + _emberViews.jQuery('').appendTo('head'); + _emberViews.jQuery('
    ').appendTo('body'); + + originalAdapter = _emberTestingTest.default.adapter; + + _emberMetal.run(function () { + indexHitCount = 0; + + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + + App.Router.map(function () { + this.route('posts'); + this.route('comments'); + + this.route('abort_transition'); + + this.route('redirect'); + }); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + indexHitCount += 1; + } + }); + + App.PostsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + currentRoute = 'posts'; + this._super.apply(this, arguments); + } + }); + + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('
    ')); + + App.CommentsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + currentRoute = 'comments'; + this._super.apply(this, arguments); + } + }); + + _emberGlimmer.setTemplate('comments', _emberTemplateCompiler.compile('
    {{input type="text"}}
    ')); + + App.AbortTransitionRoute = _emberRouting.Route.extend({ + beforeModel: function (transition) { + transition.abort(); + } + }); + + App.RedirectRoute = _emberRouting.Route.extend({ + beforeModel: function () { + this.transitionTo('comments'); + } + }); + + App.setupForTesting(); + }); + + _emberTestingTest.default.registerAsyncHelper('slowHelper', function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + setTimeout(resolve, 10); + }); + }); + + App.injectTestHelpers(); + + find = window.find; + click = window.click; + fillIn = window.fillIn; + visit = window.visit; + andThen = window.andThen; + currentURL = window.currentURL; + }, + + teardown: function () { + _emberTestingTest.default.unregisterHelper('slowHelper'); + _emberGlimmer.setTemplates({}); + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + _emberMetal.run(App, App.destroy); + App = null; + _emberTestingTest.default.adapter = originalAdapter; + indexHitCount = 0; + } + }); + + QUnit.test('helpers can be chained with then', function () { + expect(6); + + currentRoute = 'index'; + + visit('/posts').then(function () { + equal(currentRoute, 'posts', 'Successfully visited posts route'); + equal(currentURL(), '/posts', 'posts URL is correct'); + return click('a:contains("Comments")'); + }).then(function () { + equal(currentRoute, 'comments', 'visit chained with click'); + return fillIn('.ember-text-field', 'yeah'); + }).then(function () { + equal(_emberViews.jQuery('.ember-text-field').val(), 'yeah', 'chained with fillIn'); + return fillIn('.ember-text-field', '#ember-testing-container', 'context working'); + }).then(function () { + equal(_emberViews.jQuery('.ember-text-field').val(), 'context working', 'chained with fillIn'); + return click('.does-not-exist'); + }).then(null, function (e) { + equal(e.message, 'Element .does-not-exist not found.', 'Non-existent click exception caught'); + }); + }); + + // Keep this for backwards compatibility + + QUnit.test('helpers can be chained to each other', function () { + expect(7); + + currentRoute = 'index'; + + visit('/posts').click('a:first', '#comments-link').fillIn('.ember-text-field', 'hello').then(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(_emberViews.jQuery('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + find('.ember-text-field').one('keypress', function (e) { + equal(e.keyCode, 13, 'keyevent chained with correct keyCode.'); + equal(e.which, 13, 'keyevent chained with correct which.'); + }); + }).keyEvent('.ember-text-field', 'keypress', 13).visit('/posts').then(function () { + equal(currentRoute, 'posts', 'Thens can also be chained to helpers'); + equal(currentURL(), '/posts', 'URL is set correct on chained helpers'); + }); + }); + + QUnit.test('helpers don\'t need to be chained', function () { + expect(5); + + currentRoute = 'index'; + + visit('/posts'); + + click('a:first', '#comments-link'); + + fillIn('.ember-text-field', 'hello'); + + andThen(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(find('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + }); + + visit('/posts'); + + andThen(function () { + equal(currentRoute, 'posts'); + equal(currentURL(), '/posts'); + }); + }); + + QUnit.test('Nested async helpers', function () { + expect(5); + + currentRoute = 'index'; + + visit('/posts'); + + andThen(function () { + click('a:first', '#comments-link'); + + fillIn('.ember-text-field', 'hello'); + }); + + andThen(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(find('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + }); + + visit('/posts'); + + andThen(function () { + equal(currentRoute, 'posts'); + equal(currentURL(), '/posts'); + }); + }); + + QUnit.test('Multiple nested async helpers', function () { + expect(3); + + visit('/posts'); + + andThen(function () { + click('a:first', '#comments-link'); + + fillIn('.ember-text-field', 'hello'); + fillIn('.ember-text-field', 'goodbye'); + }); + + andThen(function () { + equal(find('.ember-text-field').val(), 'goodbye', 'Fillin successfully works'); + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + }); + }); + + QUnit.test('Helpers nested in thens', function () { + expect(5); + + currentRoute = 'index'; + + visit('/posts').then(function () { + click('a:first', '#comments-link'); + }); + + andThen(function () { + fillIn('.ember-text-field', 'hello'); + }); + + andThen(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(find('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + }); + + visit('/posts'); + + andThen(function () { + equal(currentRoute, 'posts'); + equal(currentURL(), '/posts', 'Posts URL is correct'); + }); + }); + + QUnit.test('Aborted transitions are not logged via Ember.Test.adapter#exception', function () { + expect(0); + + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.create({ + exception: function (error) { + ok(false, 'aborted transitions are not logged'); + } + }); + + visit('/abort_transition'); + }); + + QUnit.test('Unhandled exceptions are logged via Ember.Test.adapter#exception', function () { + expect(2); + + var asyncHandled; + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.create({ + exception: function (error) { + equal(error.message, 'Element .does-not-exist not found.', 'Exception successfully caught and passed to Ember.Test.adapter.exception'); + asyncHandled['catch'](function () {}); // handle the rejection so it doesn't leak later. + } + }); + + visit('/posts'); + + click('.invalid-element').then(null, function (error) { + equal(error.message, 'Element .invalid-element not found.', 'Exception successfully handled in the rejection handler'); + }); + + asyncHandled = click('.does-not-exist'); + }); + + QUnit.test('Unhandled exceptions in `andThen` are logged via Ember.Test.adapter#exception', function () { + expect(1); + + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.create({ + exception: function (error) { + equal(error.message, 'Catch me', 'Exception successfully caught and passed to Ember.Test.adapter.exception'); + } + }); + + visit('/posts'); + + andThen(function () { + throw new Error('Catch me'); + }); + }); + + QUnit.test('should not start routing on the root URL when visiting another', function () { + expect(4); + + visit('/posts'); + + andThen(function () { + ok(find('#comments-link'), 'found comments-link'); + equal(currentRoute, 'posts', 'Successfully visited posts route'); + equal(currentURL(), '/posts', 'Posts URL is correct'); + equal(indexHitCount, 0, 'should not hit index route when visiting another route'); + }); + }); + + QUnit.test('only enters the index route once when visiting /', function () { + expect(1); + + visit('/'); + + andThen(function () { + equal(indexHitCount, 1, 'should hit index once when visiting /'); + }); + }); + + QUnit.test('test must not finish while asyncHelpers are pending', function () { + expect(2); + + var async = 0; + var innerRan = false; + + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.extend({ + asyncStart: function () { + async++; + this._super(); + }, + asyncEnd: function () { + async--; + this._super(); + } + }).create(); + + App.testHelpers.slowHelper(); + andThen(function () { + innerRan = true; + }); + + equal(innerRan, false, 'should not have run yet'); + ok(async > 0, 'should have told the adapter to pause'); + + if (async === 0) { + // If we failed the test, prevent zalgo from escaping and breaking + // our other tests. + _emberTestingTest.default.adapter.asyncStart(); + _emberTestingTest.default.resolve().then(function () { + _emberTestingTest.default.adapter.asyncEnd(); + }); + } + }); + + QUnit.test('visiting a URL that causes another transition should yield the correct URL', function () { + expect(1); + + visit('/redirect'); + + andThen(function () { + equal(currentURL(), '/comments', 'Redirected to Comments URL'); + }); + }); + + QUnit.test('visiting a URL and then visiting a second URL with a transition should yield the correct URL', function () { + expect(2); + + visit('/posts'); + + andThen(function () { + equal(currentURL(), '/posts', 'First visited URL is correct'); + }); + + visit('/redirect'); + + andThen(function () { + equal(currentURL(), '/comments', 'Redirected to Comments URL'); + }); + }); + + QUnit.module('ember-testing Acceptance – teardown'); + + QUnit.test('that the setup/teardown happens correct', function () { + expect(2); + + _emberViews.jQuery('').appendTo('head'); + _emberViews.jQuery('
    ').appendTo('body'); + + _emberMetal.run(function () { + indexHitCount = 0; + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + }); + App.injectTestHelpers(); + + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + ok(typeof _emberTestingTest.default.Promise.prototype.click === 'function'); + _emberMetal.run(App, App.destroy); + equal(_emberTestingTest.default.Promise.prototype.click, undefined); + App = null; + _emberTestingTest.default.adapter = originalAdapter; + indexHitCount = 0; + }); +}); +// ensure the initializer is setup +enifed('ember-testing/tests/acceptance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/acceptance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/acceptance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/adapters/adapter_test', ['exports', 'ember-metal', 'ember-testing/adapters/adapter'], function (exports, _emberMetal, _emberTestingAdaptersAdapter) { + 'use strict'; + + var adapter; + + QUnit.module('ember-testing Adapter', { + setup: function () { + adapter = new _emberTestingAdaptersAdapter.default(); + }, + teardown: function () { + _emberMetal.run(adapter, adapter.destroy); + } + }); + + // Can't test these this way anymore since we have nothing to compare to + // test("asyncStart is a noop", function() { + // equal(adapter.asyncStart, K); + // }); + + // test("asyncEnd is a noop", function() { + // equal(adapter.asyncEnd, K); + // }); + + QUnit.test('exception throws', function () { + var error = 'Hai'; + var thrown; + + try { + adapter.exception(error); + } catch (e) { + thrown = e; + } + equal(thrown, error); + }); +}); +enifed('ember-testing/tests/adapters/adapter_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/adapters/adapter_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/adapters/adapter_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/adapters/qunit_test', ['exports', 'ember-metal', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberTestingAdaptersQunit) { + 'use strict'; + + var adapter; + + QUnit.module('ember-testing QUnitAdapter', { + setup: function () { + adapter = new _emberTestingAdaptersQunit.default(); + }, + teardown: function () { + _emberMetal.run(adapter, adapter.destroy); + } + }); + + QUnit.test('asyncStart calls stop', function () { + var originalStop = QUnit.stop; + try { + QUnit.stop = function () { + ok(true, 'stop called'); + }; + adapter.asyncStart(); + } finally { + QUnit.stop = originalStop; + } + }); + + QUnit.test('asyncEnd calls start', function () { + var originalStart = QUnit.start; + try { + QUnit.start = function () { + ok(true, 'start called'); + }; + adapter.asyncEnd(); + } finally { + QUnit.start = originalStart; + } + }); + + QUnit.test('exception causes a failing assertion', function () { + var error = { err: 'hai' }; + var originalOk = window.ok; + try { + window.ok = function (val, msg) { + originalOk(!val, 'ok is called with false'); + originalOk(msg, '{err: "hai"}'); + }; + adapter.exception(error); + } finally { + window.ok = originalOk; + } + }); +}); +enifed('ember-testing/tests/adapters/qunit_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/adapters/qunit_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/adapters/qunit_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/adapters_test', ['exports', 'ember-metal', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit', 'ember-application'], function (exports, _emberMetal, _emberTestingTest, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit, _emberApplication) { + 'use strict'; + + var App, originalAdapter, originalQUnit; + + QUnit.module('ember-testing Adapters', { + setup: function () { + originalAdapter = _emberTestingTest.default.adapter; + originalQUnit = window.QUnit; + }, + teardown: function () { + _emberMetal.run(App, App.destroy); + App.removeTestHelpers(); + App = null; + + _emberTestingTest.default.adapter = originalAdapter; + window.QUnit = originalQUnit; + } + }); + + QUnit.test('Setting a test adapter manually', function () { + expect(1); + var CustomAdapter; + + CustomAdapter = _emberTestingAdaptersAdapter.default.extend({ + asyncStart: function () { + ok(true, 'Correct adapter was used'); + } + }); + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + _emberTestingTest.default.adapter = CustomAdapter.create(); + App.setupForTesting(); + }); + + _emberTestingTest.default.adapter.asyncStart(); + }); + + QUnit.test('QUnitAdapter is used by default (if QUnit is available)', function () { + expect(1); + + _emberTestingTest.default.adapter = null; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + ok(_emberTestingTest.default.adapter instanceof _emberTestingAdaptersQunit.default); + }); + + QUnit.test('Adapter is used by default (if QUnit is not available)', function () { + expect(2); + + delete window.QUnit; + + _emberTestingTest.default.adapter = null; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + ok(_emberTestingTest.default.adapter instanceof _emberTestingAdaptersAdapter.default); + ok(!(_emberTestingTest.default.adapter instanceof _emberTestingAdaptersQunit.default)); + }); +}); +enifed('ember-testing/tests/adapters_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/adapters_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/adapters_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/ext/rsvp_test', ['exports', 'ember-testing/ext/rsvp', 'ember-testing/test/adapter', 'ember-metal'], function (exports, _emberTestingExtRsvp, _emberTestingTestAdapter, _emberMetal) { + 'use strict'; + + var originalTestAdapter = _emberTestingTestAdapter.getAdapter(); + var originalTestingFlag = _emberMetal.isTesting(); + + var asyncStarted = 0; + var asyncEnded = 0; + + QUnit.module('ember-testing RSVP', { + setup: function () { + _emberMetal.setTesting(true); + _emberTestingTestAdapter.setAdapter({ + asyncStart: function () { + asyncStarted++; + QUnit.stop(); + }, + asyncEnd: function () { + asyncEnded++; + QUnit.start(); + } + }); + }, + teardown: function () { + asyncStarted = 0; + asyncEnded = 0; + _emberTestingTestAdapter.setAdapter(originalTestAdapter); + _emberMetal.setTesting(originalTestingFlag); + } + }); + + QUnit.test('given `Ember.testing = true`, correctly informs the test suite about async steps', function () { + expect(19); + + ok(!_emberMetal.run.currentRunLoop, 'expect no run-loop'); + + _emberMetal.setTesting(true); + + equal(asyncStarted, 0); + equal(asyncEnded, 0); + + var user = _emberTestingExtRsvp.default.Promise.resolve({ + name: 'tomster' + }); + + equal(asyncStarted, 0); + equal(asyncEnded, 0); + + user.then(function (user) { + equal(asyncStarted, 1); + equal(asyncEnded, 1); + + equal(user.name, 'tomster'); + + return _emberTestingExtRsvp.default.Promise.resolve(1).then(function () { + equal(asyncStarted, 1); + equal(asyncEnded, 1); + }); + }).then(function () { + equal(asyncStarted, 1); + equal(asyncEnded, 1); + + return new _emberTestingExtRsvp.default.Promise(function (resolve) { + QUnit.stop(); // raw async, we must inform the test framework manually + setTimeout(function () { + QUnit.start(); // raw async, we must inform the test framework manually + + equal(asyncStarted, 1); + equal(asyncEnded, 1); + + resolve({ + name: 'async tomster' + }); + + equal(asyncStarted, 2); + equal(asyncEnded, 1); + }, 0); + }); + }).then(function (user) { + equal(user.name, 'async tomster'); + equal(asyncStarted, 2); + equal(asyncEnded, 2); + }); + }); +}); +enifed('ember-testing/tests/ext/rsvp_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/ext/rsvp_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/ext/rsvp_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/helper_registration_test', ['exports', 'ember-metal', 'ember-testing/test', 'ember-application'], function (exports, _emberMetal, _emberTestingTest, _emberApplication) { + 'use strict'; + + var App, appBooted, helperContainer; + + function registerHelper() { + _emberTestingTest.default.registerHelper('boot', function (app) { + _emberMetal.run(app, app.advanceReadiness); + appBooted = true; + return app.testHelpers.wait(); + }); + } + + function unregisterHelper() { + _emberTestingTest.default.unregisterHelper('boot'); + } + + var originalAdapter = _emberTestingTest.default.adapter; + + function setupApp() { + appBooted = false; + helperContainer = {}; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + App.injectTestHelpers(helperContainer); + }); + } + + function destroyApp() { + if (App) { + _emberMetal.run(App, 'destroy'); + App = null; + } + } + + QUnit.module('Test - registerHelper/unregisterHelper', { + teardown: function () { + _emberTestingTest.default.adapter = originalAdapter; + destroyApp(); + } + }); + + QUnit.test('Helper gets registered', function () { + expect(2); + + registerHelper(); + setupApp(); + + ok(App.testHelpers.boot); + ok(helperContainer.boot); + }); + + QUnit.test('Helper is ran when called', function (assert) { + var done = assert.async(); + assert.expect(1); + + registerHelper(); + setupApp(); + + App.testHelpers.boot().then(function () { + assert.ok(appBooted); + }).finally(done); + }); + + QUnit.test('Helper can be unregistered', function () { + expect(4); + + registerHelper(); + setupApp(); + + ok(App.testHelpers.boot); + ok(helperContainer.boot); + + unregisterHelper(); + + setupApp(); + + ok(!App.testHelpers.boot, 'once unregistered the helper is not added to App.testHelpers'); + ok(!helperContainer.boot, 'once unregistered the helper is not added to the helperContainer'); + }); +}); +enifed('ember-testing/tests/helper_registration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/helper_registration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/helper_registration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/helpers_test', ['exports', 'ember-routing', 'ember-runtime', 'ember-metal', 'ember-views', 'ember-glimmer', 'ember-testing/test', 'ember-testing/helpers', 'ember-testing/initializers', 'ember-testing/setup_for_testing', 'ember-application', 'ember-template-compiler', 'ember-testing/test/pending_requests', 'ember-testing/test/adapter', 'ember-testing/test/waiters'], function (exports, _emberRouting, _emberRuntime, _emberMetal, _emberViews, _emberGlimmer, _emberTestingTest, _emberTestingHelpers, _emberTestingInitializers, _emberTestingSetup_for_testing, _emberApplication, _emberTemplateCompiler, _emberTestingTestPending_requests, _emberTestingTestAdapter, _emberTestingTestWaiters) { + 'use strict'; + + var App; + var originalAdapter = _emberTestingTestAdapter.getAdapter(); + + function cleanup() { + // Teardown setupForTesting + + _emberTestingTestAdapter.setAdapter(originalAdapter); + _emberMetal.run(function () { + _emberViews.jQuery(document).off('ajaxSend'); + _emberViews.jQuery(document).off('ajaxComplete'); + }); + _emberTestingTestPending_requests.clearPendingRequests(); + // Test.waiters = null; + + // Other cleanup + + if (App) { + _emberMetal.run(App, App.destroy); + App.removeTestHelpers(); + App = null; + } + + _emberGlimmer.setTemplates({}); + } + + function assertHelpers(application, helperContainer, expected) { + if (!helperContainer) { + helperContainer = window; + } + if (expected === undefined) { + expected = true; + } + + function checkHelperPresent(helper, expected) { + var presentInHelperContainer = !!helperContainer[helper]; + var presentInTestHelpers = !!application.testHelpers[helper]; + + ok(presentInHelperContainer === expected, 'Expected \'' + helper + '\' to be present in the helper container (defaults to window).'); + ok(presentInTestHelpers === expected, 'Expected \'' + helper + '\' to be present in App.testHelpers.'); + } + + checkHelperPresent('visit', expected); + checkHelperPresent('click', expected); + checkHelperPresent('keyEvent', expected); + checkHelperPresent('fillIn', expected); + checkHelperPresent('wait', expected); + checkHelperPresent('triggerEvent', expected); + } + + function assertNoHelpers(application, helperContainer) { + assertHelpers(application, helperContainer, false); + } + + function currentRouteName(app) { + return app.testHelpers.currentRouteName(); + } + + function currentPath(app) { + return app.testHelpers.currentPath(); + } + + function currentURL(app) { + return app.testHelpers.currentURL(); + } + + function setupApp() { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + + App.injectTestHelpers(); + }); + } + + QUnit.module('ember-testing: Helper setup', { + setup: function () { + cleanup(); + }, + teardown: function () { + cleanup(); + } + }); + + function registerHelper() { + _emberTestingTest.default.registerHelper('LeakyMcLeakLeak', function (app) {}); + } + + QUnit.test('Ember.Application#injectTestHelpers/#removeTestHelpers', function () { + App = _emberMetal.run(_emberApplication.Application, _emberApplication.Application.create); + assertNoHelpers(App); + + registerHelper(); + + App.injectTestHelpers(); + assertHelpers(App); + ok(_emberTestingTest.default.Promise.prototype.LeakyMcLeakLeak, 'helper in question SHOULD be present'); + + App.removeTestHelpers(); + assertNoHelpers(App); + + equal(_emberTestingTest.default.Promise.prototype.LeakyMcLeakLeak, undefined, 'should NOT leak test promise extensions'); + }); + + QUnit.test('Ember.Application#setupForTesting', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App.__container__.lookup('router:main').location, 'none'); + }); + + QUnit.test('Ember.Application.setupForTesting sets the application to `testing`.', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App.testing, true, 'Application instance is set to testing.'); + }); + + QUnit.test('Ember.Application.setupForTesting leaves the system in a deferred state.', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + }); + + QUnit.test('App.reset() after Application.setupForTesting leaves the system in a deferred state.', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + + App.reset(); + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + }); + + QUnit.test('Ember.Application#setupForTesting attaches ajax listeners', function () { + var documentEvents; + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + if (!documentEvents) { + documentEvents = {}; + } + + ok(documentEvents['ajaxSend'] === undefined, 'there are no ajaxSend listers setup prior to calling injectTestHelpers'); + ok(documentEvents['ajaxComplete'] === undefined, 'there are no ajaxComplete listers setup prior to calling injectTestHelpers'); + + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + equal(documentEvents['ajaxSend'].length, 1, 'calling injectTestHelpers registers an ajaxSend handler'); + equal(documentEvents['ajaxComplete'].length, 1, 'calling injectTestHelpers registers an ajaxComplete handler'); + }); + + QUnit.test('Ember.Application#setupForTesting attaches ajax listeners only once', function () { + var documentEvents; + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + if (!documentEvents) { + documentEvents = {}; + } + + ok(documentEvents['ajaxSend'] === undefined, 'there are no ajaxSend listeners setup prior to calling injectTestHelpers'); + ok(documentEvents['ajaxComplete'] === undefined, 'there are no ajaxComplete listeners setup prior to calling injectTestHelpers'); + + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + equal(documentEvents['ajaxSend'].length, 1, 'calling injectTestHelpers registers an ajaxSend handler'); + equal(documentEvents['ajaxComplete'].length, 1, 'calling injectTestHelpers registers an ajaxComplete handler'); + }); + + QUnit.test('Ember.Application#injectTestHelpers calls callbacks registered with onInjectHelpers', function () { + var injected = 0; + + _emberTestingTest.default.onInjectHelpers(function () { + injected++; + }); + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(injected, 0, 'onInjectHelpers are not called before injectTestHelpers'); + + App.injectTestHelpers(); + + equal(injected, 1, 'onInjectHelpers are called after injectTestHelpers'); + }); + + QUnit.test('Ember.Application#injectTestHelpers adds helpers to provided object.', function () { + var helpers = {}; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + App.injectTestHelpers(helpers); + assertHelpers(App, helpers); + + App.removeTestHelpers(); + assertNoHelpers(App, helpers); + }); + + QUnit.test('Ember.Application#removeTestHelpers resets the helperContainer\'s original values', function () { + var helpers = { visit: 'snazzleflabber' }; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + App.injectTestHelpers(helpers); + + ok(helpers.visit !== 'snazzleflabber', 'helper added to container'); + App.removeTestHelpers(); + + ok(helpers.visit === 'snazzleflabber', 'original value added back to container'); + }); + + QUnit.module('ember-testing: Helper methods', { + setup: function () { + setupApp(); + }, + teardown: function () { + cleanup(); + } + }); + + QUnit.test('`wait` respects registerWaiters', function (assert) { + assert.expect(3); + + var done = assert.async(); + + var counter = 0; + function waiter() { + return ++counter > 2; + } + + var other = 0; + function otherWaiter() { + return ++other > 2; + } + + _emberMetal.run(App, App.advanceReadiness); + _emberTestingTestWaiters.registerWaiter(waiter); + _emberTestingTestWaiters.registerWaiter(otherWaiter); + + App.testHelpers.wait().then(function () { + equal(waiter(), true, 'should not resolve until our waiter is ready'); + _emberTestingTestWaiters.unregisterWaiter(waiter); + counter = 0; + return App.testHelpers.wait(); + }).then(function () { + equal(counter, 0, 'unregistered waiter was not checked'); + equal(otherWaiter(), true, 'other waiter is still registered'); + }).finally(function () { + _emberTestingTestWaiters.unregisterWaiter(otherWaiter); + done(); + }); + }); + + QUnit.test('`visit` advances readiness.', function () { + expect(2); + + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + + return App.testHelpers.visit('/').then(function () { + equal(App._readinessDeferrals, 0, 'App\'s readiness was advanced by visit.'); + }); + }); + + QUnit.test('`wait` helper can be passed a resolution value', function () { + expect(4); + + var promise, wait; + + promise = new _emberRuntime.RSVP.Promise(function (resolve) { + _emberMetal.run(null, resolve, 'promise'); + }); + + _emberMetal.run(App, App.advanceReadiness); + + wait = App.testHelpers.wait; + + return wait('text').then(function (val) { + equal(val, 'text', 'can resolve to a string'); + return wait(1); + }).then(function (val) { + equal(val, 1, 'can resolve to an integer'); + return wait({ age: 10 }); + }).then(function (val) { + deepEqual(val, { age: 10 }, 'can resolve to an object'); + return wait(promise); + }).then(function (val) { + equal(val, 'promise', 'can resolve to a promise resolution value'); + }); + }); + + QUnit.test('`click` triggers appropriate events in order', function () { + expect(5); + + var click, wait, events; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + classNames: 'index-wrapper', + + didInsertElement: function () { + this.$().on('mousedown focusin mouseup click', function (e) { + events.push(e.type); + }); + } + }); + + App.XCheckboxComponent = _emberGlimmer.Component.extend({ + tagName: 'input', + attributeBindings: ['type'], + type: 'checkbox', + click: function () { + events.push('click:' + this.get('checked')); + }, + change: function () { + events.push('change:' + this.get('checked')); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#index-wrapper}}{{input type="text"}} {{x-checkbox type="checkbox"}} {{textarea}}
    {{/index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + click = App.testHelpers.click; + wait = App.testHelpers.wait; + + return wait().then(function () { + events = []; + return click('.index-wrapper'); + }).then(function () { + deepEqual(events, ['mousedown', 'mouseup', 'click'], 'fires events in order'); + }).then(function () { + events = []; + return click('.index-wrapper input[type=text]'); + }).then(function () { + deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on inputs'); + }).then(function () { + events = []; + return click('.index-wrapper textarea'); + }).then(function () { + deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on textareas'); + }).then(function () { + events = []; + return click('.index-wrapper div'); + }).then(function () { + deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on contenteditable'); + }).then(function () { + events = []; + return click('.index-wrapper input[type=checkbox]'); + }).then(function () { + // i.e. mousedown, mouseup, change:true, click, click:true + // Firefox differs so we can't assert the exact ordering here. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=843554. + equal(events.length, 5, 'fires click and change on checkboxes'); + }); + }); + + QUnit.test('`click` triggers native events with simulated X/Y coordinates', function () { + expect(15); + + var click, wait, events; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + classNames: 'index-wrapper', + + didInsertElement: function () { + var pushEvent = function (e) { + return events.push(e); + }; + this.element.addEventListener('mousedown', pushEvent); + this.element.addEventListener('mouseup', pushEvent); + this.element.addEventListener('click', pushEvent); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#index-wrapper}}some text{{/index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + click = App.testHelpers.click; + wait = App.testHelpers.wait; + + return wait().then(function () { + events = []; + return click('.index-wrapper'); + }).then(function () { + events.forEach(function (e) { + ok(e instanceof window.Event, 'The event is an instance of MouseEvent'); + ok(typeof e.screenX === 'number' && e.screenX > 0, 'screenX is correct'); + ok(typeof e.screenY === 'number' && e.screenY > 0, 'screenY is correct'); + ok(typeof e.clientX === 'number' && e.clientX > 0, 'clientX is correct'); + ok(typeof e.clientY === 'number' && e.clientY > 0, 'clientY is correct'); + }); + }); + }); + + QUnit.test('`triggerEvent` with mouseenter triggers native events with simulated X/Y coordinates', function () { + expect(5); + + var triggerEvent, wait, evt; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + classNames: 'index-wrapper', + + didInsertElement: function () { + this.element.addEventListener('mouseenter', function (e) { + return evt = e; + }); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#index-wrapper}}some text{{/index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.index-wrapper', 'mouseenter'); + }).then(function () { + ok(evt instanceof window.Event, 'The event is an instance of MouseEvent'); + ok(typeof evt.screenX === 'number' && evt.screenX > 0, 'screenX is correct'); + ok(typeof evt.screenY === 'number' && evt.screenY > 0, 'screenY is correct'); + ok(typeof evt.clientX === 'number' && evt.clientX > 0, 'clientX is correct'); + ok(typeof evt.clientY === 'number' && evt.clientY > 0, 'clientY is correct'); + }); + }); + + QUnit.test('`wait` waits for outstanding timers', function () { + expect(1); + + var wait_done = false; + + _emberMetal.run(App, App.advanceReadiness); + + _emberMetal.run.later(this, function () { + wait_done = true; + }, 500); + + return App.testHelpers.wait().then(function () { + equal(wait_done, true, 'should wait for the timer to be fired.'); + }); + }); + + QUnit.test('`wait` respects registerWaiters with optional context', function () { + expect(3); + + var obj = { + counter: 0, + ready: function () { + return ++this.counter > 2; + } + }; + + var other = 0; + function otherWaiter() { + return ++other > 2; + } + + _emberMetal.run(App, App.advanceReadiness); + _emberTestingTestWaiters.registerWaiter(obj, obj.ready); + _emberTestingTestWaiters.registerWaiter(otherWaiter); + + return App.testHelpers.wait().then(function () { + equal(obj.ready(), true, 'should not resolve until our waiter is ready'); + _emberTestingTestWaiters.unregisterWaiter(obj, obj.ready); + obj.counter = 0; + return App.testHelpers.wait(); + }).then(function () { + equal(obj.counter, 0, 'the unregistered waiter should still be at 0'); + equal(otherWaiter(), true, 'other waiter should still be registered'); + }).finally(function () { + _emberTestingTestWaiters.unregisterWaiter(otherWaiter); + }); + }); + + QUnit.test('`wait` does not error if routing has not begun', function () { + expect(1); + + return App.testHelpers.wait().then(function () { + ok(true, 'should not error without `visit`'); + }); + }); + + QUnit.test('`triggerEvent accepts an optional options hash without context', function () { + expect(3); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$('.input').on('keydown change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="scope" class="input"}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.input', 'keydown', { keyCode: 13 }); + }).then(function () { + equal(event.keyCode, 13, 'options were passed'); + equal(event.type, 'keydown', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'scope', 'triggered on the correct element'); + }); + }); + + QUnit.test('`triggerEvent can limit searching for a selector to a scope', function () { + expect(2); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + + didInsertElement: function () { + this.$('.input').on('blur change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="outside-scope" class="input"}}
    {{input type="text" id="inside-scope" class="input"}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.input', '#limited', 'blur'); + }).then(function () { + equal(event.type, 'blur', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'inside-scope', 'triggered on the correct element'); + }); + }); + + QUnit.test('`triggerEvent` can be used to trigger arbitrary events', function () { + expect(2); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$('#foo').on('blur change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="foo"}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('#foo', 'blur'); + }).then(function () { + equal(event.type, 'blur', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'foo', 'triggered on the correct element'); + }); + }); + + QUnit.test('`fillIn` takes context into consideration', function () { + expect(2); + var fillIn, find, visit, andThen; + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{input type="text" id="first" class="current"}}
    {{input type="text" id="second" class="current"}}')); + + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + find = App.testHelpers.find; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + + visit('/'); + fillIn('.current', '#parent', 'current value'); + + return andThen(function () { + equal(find('#first').val(), 'current value'); + equal(find('#second').val(), ''); + }); + }); + + QUnit.test('`fillIn` focuses on the element', function () { + expect(2); + var fillIn, find, visit, andThen, wait; + + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + wasFocused: function () { + ok(true, 'focusIn event was triggered'); + } + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{input type="text" id="first" focus-in="wasFocused"}}
    ')); + + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + find = App.testHelpers.find; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + wait = App.testHelpers.wait; + + visit('/'); + fillIn('#first', 'current value'); + andThen(function () { + equal(find('#first').val(), 'current value'); + }); + + return wait(); + }); + + QUnit.test('`fillIn` fires `input` and `change` events in the proper order', function () { + expect(1); + + var fillIn, visit, andThen, wait; + var events = []; + App.IndexController = _emberRuntime.Controller.extend({ + actions: { + oninputHandler: function (e) { + events.push(e.type); + }, + onchangeHandler: function (e) { + events.push(e.type); + } + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('')); + + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + wait = App.testHelpers.wait; + + visit('/'); + fillIn('#first', 'current value'); + andThen(function () { + deepEqual(events, ['input', 'change'], '`input` and `change` events are fired in the proper order'); + }); + + return wait(); + }); + + QUnit.test('`fillIn` only sets the value in the first matched element', function () { + var fillIn = undefined, + find = undefined, + visit = undefined, + andThen = undefined, + wait = undefined; + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('')); + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + find = App.testHelpers.find; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + wait = App.testHelpers.wait; + + visit('/'); + fillIn('input.in-test', 'new value'); + andThen(function () { + equal(find('#first').val(), 'new value'); + equal(find('#second').val(), ''); + }); + + return wait(); + }); + + QUnit.test('`triggerEvent accepts an optional options hash and context', function () { + expect(3); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$('.input').on('keydown change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="outside-scope" class="input"}}
    {{input type="text" id="inside-scope" class="input"}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.input', '#limited', 'keydown', { keyCode: 13 }); + }).then(function () { + equal(event.keyCode, 13, 'options were passed'); + equal(event.type, 'keydown', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'inside-scope', 'triggered on the correct element'); + }); + }); + + QUnit.module('ember-testing debugging helpers', { + setup: function () { + setupApp(); + + _emberMetal.run(function () { + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + }); + + _emberMetal.run(App, 'advanceReadiness'); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('pauseTest pauses', function () { + expect(1); + + function fakeAdapterAsyncStart() { + ok(true, 'Async start should be called after waiting for other helpers'); + } + + App.testHelpers.andThen(function () { + _emberTestingTest.default.adapter.asyncStart = fakeAdapterAsyncStart; + }); + + App.testHelpers.pauseTest(); + }); + + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + QUnit.test('resumeTest resumes paused tests', function () { + expect(1); + + var pausePromise = App.testHelpers.pauseTest(); + setTimeout(function () { + return App.testHelpers.resumeTest(); + }, 0); + + return pausePromise.then(function () { + return ok(true, 'pauseTest promise was resolved'); + }); + }); + + QUnit.test('resumeTest throws if nothing to resume', function () { + expect(1); + + throws(function () { + return App.testHelpers.resumeTest(); + }, /Testing has not been paused. There is nothing to resume./); + }); + } + + QUnit.module('ember-testing routing helpers', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + + App.injectTestHelpers(); + + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + App.Router.map(function () { + this.route('posts', { resetNamespace: true }, function () { + this.route('new'); + }); + }); + }); + + _emberMetal.run(App, 'advanceReadiness'); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('currentRouteName for \'/\'', function () { + expect(3); + + return App.testHelpers.visit('/').then(function () { + equal(App.testHelpers.currentRouteName(), 'index', 'should equal \'index\'.'); + equal(App.testHelpers.currentPath(), 'index', 'should equal \'index\'.'); + equal(App.testHelpers.currentURL(), '/', 'should equal \'/\'.'); + }); + }); + + QUnit.test('currentRouteName for \'/posts\'', function () { + expect(3); + + return App.testHelpers.visit('/posts').then(function () { + equal(App.testHelpers.currentRouteName(), 'posts.index', 'should equal \'posts.index\'.'); + equal(App.testHelpers.currentPath(), 'posts.index', 'should equal \'posts.index\'.'); + equal(App.testHelpers.currentURL(), '/posts', 'should equal \'/posts\'.'); + }); + }); + + QUnit.test('currentRouteName for \'/posts/new\'', function () { + expect(3); + + return App.testHelpers.visit('/posts/new').then(function () { + equal(App.testHelpers.currentRouteName(), 'posts.new', 'should equal \'posts.new\'.'); + equal(App.testHelpers.currentPath(), 'posts.new', 'should equal \'posts.new\'.'); + equal(App.testHelpers.currentURL(), '/posts/new', 'should equal \'/posts/new\'.'); + }); + }); + + QUnit.module('ember-testing pendingRequests', { + setup: function () { + setupApp(); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('pendingRequests is maintained for ajaxSend and ajaxComplete events', function () { + equal(_emberTestingTestPending_requests.pendingRequests(), 0); + var xhr = { some: 'xhr' }; + _emberViews.jQuery(document).trigger('ajaxSend', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); + _emberViews.jQuery(document).trigger('ajaxComplete', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 0, 'Ember.Test.pendingRequests was decremented'); + }); + + QUnit.test('pendingRequests is ignores ajaxComplete events from past setupForTesting calls', function () { + equal(_emberTestingTestPending_requests.pendingRequests(), 0); + var xhr = { some: 'xhr' }; + _emberViews.jQuery(document).trigger('ajaxSend', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); + + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + equal(_emberTestingTestPending_requests.pendingRequests(), 0, 'Ember.Test.pendingRequests was reset'); + + var altXhr = { some: 'more xhr' }; + _emberViews.jQuery(document).trigger('ajaxSend', altXhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); + _emberViews.jQuery(document).trigger('ajaxComplete', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests is not impressed with your unexpected complete'); + }); + + QUnit.test('pendingRequests is reset by setupForTesting', function () { + _emberTestingTestPending_requests.incrementPendingRequests(); + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + equal(_emberTestingTestPending_requests.pendingRequests(), 0, 'pendingRequests is reset'); + }); + + QUnit.module('ember-testing async router', { + setup: function () { + cleanup(); + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + App.Router.map(function () { + this.route('user', { resetNamespace: true }, function () { + this.route('profile'); + this.route('edit'); + }); + }); + + App.UserRoute = _emberRouting.Route.extend({ + model: function () { + return resolveLater(); + } + }); + + App.UserProfileRoute = _emberRouting.Route.extend({ + beforeModel: function () { + var self = this; + return resolveLater().then(function () { + self.transitionTo('user.edit'); + }); + } + }); + + // Emulates a long-running unscheduled async operation. + function resolveLater() { + var promise; + + _emberMetal.run(function () { + promise = new _emberRuntime.RSVP.Promise(function (resolve) { + // The wait() helper has a 10ms tick. We should resolve() after at least one tick + // to test whether wait() held off while the async router was still loading. 20ms + // should be enough. + setTimeout(function () { + _emberMetal.run(function () { + resolve(_emberRuntime.Object.create({ firstName: 'Tom' })); + }); + }, 20); + }); + }); + + return promise; + } + + App.setupForTesting(); + }); + + App.injectTestHelpers(); + _emberMetal.run(App, 'advanceReadiness'); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('currentRouteName for \'/user\'', function () { + expect(4); + + return App.testHelpers.visit('/user').then(function () { + equal(currentRouteName(App), 'user.index', 'should equal \'user.index\'.'); + equal(currentPath(App), 'user.index', 'should equal \'user.index\'.'); + equal(currentURL(App), '/user', 'should equal \'/user\'.'); + equal(App.__container__.lookup('route:user').get('controller.model.firstName'), 'Tom', 'should equal \'Tom\'.'); + }); + }); + + QUnit.test('currentRouteName for \'/user/profile\'', function () { + expect(4); + + return App.testHelpers.visit('/user/profile').then(function () { + equal(currentRouteName(App), 'user.edit', 'should equal \'user.edit\'.'); + equal(currentPath(App), 'user.edit', 'should equal \'user.edit\'.'); + equal(currentURL(App), '/user/edit', 'should equal \'/user/edit\'.'); + equal(App.__container__.lookup('route:user').get('controller.model.firstName'), 'Tom', 'should equal \'Tom\'.'); + }); + }); + + var originalVisitHelper, originalFindHelper, originalWaitHelper; + + QUnit.module('can override built-in helpers', { + setup: function () { + originalVisitHelper = _emberTestingTest.default._helpers.visit; + originalFindHelper = _emberTestingTest.default._helpers.find; + originalWaitHelper = _emberTestingTest.default._helpers.wait; + + _emberViews.jQuery('').appendTo('head'); + _emberViews.jQuery('
    ').appendTo('body'); + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + + App.setupForTesting(); + }); + }, + + teardown: function () { + cleanup(); + + _emberTestingTest.default._helpers.visit = originalVisitHelper; + _emberTestingTest.default._helpers.find = originalFindHelper; + _emberTestingTest.default._helpers.wait = originalWaitHelper; + } + }); + + QUnit.test('can override visit helper', function () { + expect(1); + + _emberTestingTest.default.registerHelper('visit', function () { + ok(true, 'custom visit helper was called'); + }); + + App.injectTestHelpers(); + + return App.testHelpers.visit(); + }); + + QUnit.test('can override find helper', function () { + expect(1); + + _emberTestingTest.default.registerHelper('find', function () { + ok(true, 'custom find helper was called'); + + return ['not empty array']; + }); + + App.injectTestHelpers(); + + return App.testHelpers.findWithAssert('.who-cares'); + }); +}); +// ensure that the helpers are loaded +// ensure the initializer is setup +enifed('ember-testing/tests/helpers_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/helpers_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/helpers_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/integration_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-testing/test', 'ember-routing', 'ember-application', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberMetal, _emberRuntime, _emberViews, _emberTestingTest, _emberRouting, _emberApplication, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + var App, find, visit; + var originalAdapter = _emberTestingTest.default.adapter; + + QUnit.module('ember-testing Integration', { + setup: function () { + _emberViews.jQuery('
    ').appendTo('body'); + _emberMetal.run(function () { + _emberGlimmer.setTemplate('people', _emberTemplateCompiler.compile('
    {{#each model as |person|}}
    {{person.firstName}}
    {{/each}}
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + + App.Router.map(function () { + this.route('people', { path: '/' }); + }); + + App.PeopleRoute = _emberRouting.Route.extend({ + model: function () { + return App.Person.find(); + } + }); + + App.PeopleController = _emberRuntime.Controller.extend({}); + + App.Person = _emberRuntime.Object.extend({ + firstName: '' + }); + + App.Person.reopenClass({ + find: function () { + return _emberRuntime.A(); + } + }); + + App.setupForTesting(); + }); + + _emberMetal.run(function () { + App.reset(); + }); + + App.injectTestHelpers(); + + find = window.find; + visit = window.visit; + }, + + teardown: function () { + App.removeTestHelpers(); + _emberGlimmer.setTemplates({}); + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + _emberMetal.run(App, App.destroy); + App = null; + _emberTestingTest.default.adapter = originalAdapter; + } + }); + + QUnit.test('template is bound to empty array of people', function () { + App.Person.find = function () { + return _emberRuntime.A(); + }; + _emberMetal.run(App, 'advanceReadiness'); + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 0, 'successfully stubbed an empty array of people'); + }); + }); + + QUnit.test('template is bound to array of 2 people', function () { + App.Person.find = function () { + var people = _emberRuntime.A(); + var first = App.Person.create({ firstName: 'x' }); + var last = App.Person.create({ firstName: 'y' }); + _emberMetal.run(people, people.pushObject, first); + _emberMetal.run(people, people.pushObject, last); + return people; + }; + _emberMetal.run(App, 'advanceReadiness'); + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 2, 'successfully stubbed a non empty array of people'); + }); + }); + + QUnit.test('template is again bound to empty array of people', function () { + App.Person.find = function () { + return _emberRuntime.A(); + }; + _emberMetal.run(App, 'advanceReadiness'); + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 0, 'successfully stubbed another empty array of people'); + }); + }); + + QUnit.test('`visit` can be called without advancedReadiness.', function () { + App.Person.find = function () { + return _emberRuntime.A(); + }; + + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 0, 'stubbed an empty array of people without calling advancedReadiness.'); + }); + }); +}); +enifed('ember-testing/tests/integration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/integration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/integration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/reexports_test', ['exports', 'ember', 'internal-test-helpers'], function (exports, _ember, _internalTestHelpers) { + 'use strict'; + + QUnit.module('ember-testing reexports'); + + [ + // ember-testing + ['Test', 'ember-testing'], ['Test.Adapter', 'ember-testing', 'Adapter'], ['Test.QUnitAdapter', 'ember-testing', 'QUnitAdapter'], ['setupForTesting', 'ember-testing']].forEach(function (reexport) { + var path = reexport[0]; + var moduleId = reexport[1]; + var exportName = reexport[2]; + + // default path === exportName if none present + if (!exportName) { + exportName = path; + } + + QUnit.test('Ember.' + path + ' exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_ember.default, assert, path, moduleId, exportName); + }); + }); +}); +enifed('ember-testing/tests/reexports_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/reexports_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/reexports_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/simple_setup', ['exports', 'ember-metal', 'ember-views'], function (exports, _emberMetal, _emberViews) { + 'use strict'; + + var App; + + QUnit.module('Simple Testing Setup', { + teardown: function () { + if (App) { + App.removeTestHelpers(); + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + _emberMetal.run(App, 'destroy'); + App = null; + } + } + }); +}); +enifed('ember-testing/tests/simple_setup.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/simple_setup.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/simple_setup.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/test/waiters-test', ['exports', 'ember-testing/test/waiters'], function (exports, _emberTestingTestWaiters) { + 'use strict'; + + var Waiters = (function () { + function Waiters() { + babelHelpers.classCallCheck(this, Waiters); + + this._waiters = []; + } + + Waiters.prototype.add = function add() { + this._waiters.push([].concat(babelHelpers.slice.call(arguments))); + }; + + Waiters.prototype.register = function register() { + this.forEach(function () { + _emberTestingTestWaiters.registerWaiter.apply(undefined, arguments); + }); + }; + + Waiters.prototype.unregister = function unregister() { + this.forEach(function () { + _emberTestingTestWaiters.unregisterWaiter.apply(undefined, arguments); + }); + }; + + Waiters.prototype.forEach = function forEach(callback) { + for (var i = 0; i < this._waiters.length; i++) { + var args = this._waiters[i]; + + callback.apply(undefined, args); + } + }; + + Waiters.prototype.check = function check() { + this.register(); + var result = _emberTestingTestWaiters.checkWaiters(); + this.unregister(); + + return result; + }; + + return Waiters; + })(); + + QUnit.module('ember-testing: waiters', { + setup: function () { + this.waiters = new Waiters(); + }, + + teardown: function () { + this.waiters.unregister(); + } + }); + + QUnit.test('registering a waiter', function (assert) { + assert.expect(2); + + var obj = { foo: true }; + + this.waiters.add(obj, function () { + assert.ok(this.foo, 'has proper `this` context'); + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'is called'); + return true; + }); + + this.waiters.check(); + }); + + QUnit.test('unregistering a waiter', function (assert) { + assert.expect(2); + + var obj = { foo: true }; + + this.waiters.add(obj, function () { + assert.ok(true, 'precond - waiter with context is registered'); + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter without context is registered'); + return true; + }); + + this.waiters.check(); + this.waiters.unregister(); + + _emberTestingTestWaiters.checkWaiters(); + }); + + QUnit.test('checkWaiters returns false if all waiters return true', function (assert) { + assert.expect(3); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return true; + }); + + assert.notOk(this.waiters.check(), 'checkWaiters returns true if all waiters return true'); + }); + + QUnit.test('checkWaiters returns true if any waiters return false', function (assert) { + assert.expect(3); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return false; + }); + + assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false'); + }); + + QUnit.test('checkWaiters short circuits after first falsey waiter', function (assert) { + assert.expect(2); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return false; + }); + + this.waiters.add(function () { + assert.notOk(true, 'waiter should not be called'); + }); + + assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false'); + }); + + QUnit.test('generateDeprecatedWaitersArray provides deprecated access to waiters array', function (assert) { + var waiter1 = function () {}; + var waiter2 = function () {}; + + this.waiters.add(waiter1); + this.waiters.add(waiter2); + + this.waiters.register(); + + var waiters = undefined; + expectDeprecation(function () { + waiters = _emberTestingTestWaiters.generateDeprecatedWaitersArray(); + }, /Usage of `Ember.Test.waiters` is deprecated/); + + assert.deepEqual(waiters, [[null, waiter1], [null, waiter2]]); + }); +}); +enifed('ember-testing/tests/test/waiters-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/test/waiters-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/test/waiters-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/apply-str.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/apply-str.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/apply-str.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/assign.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/assign.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/assign.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/dictionary.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/dictionary.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/dictionary.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/empty-object.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/empty-object.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/empty-object.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/guid.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/guid.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/guid.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/inspect.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/inspect.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/inspect.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/intern.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/intern.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/intern.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/invoke.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/invoke.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/invoke.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/lookup-descriptor.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/lookup-descriptor.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/lookup-descriptor.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/make-array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/make-array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/make-array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/name.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/name.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/name.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/owner.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/owner.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/owner.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/proxy-utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/proxy-utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/proxy-utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/super.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/super.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/super.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/symbol.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/symbol.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/symbol.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/assign_test', ['exports', 'ember-utils/assign'], function (exports, _emberUtilsAssign) { + 'use strict'; + + QUnit.module('Ember.assign'); + + QUnit.test('Ember.assign', function () { + var a = { a: 1 }; + var b = { b: 2 }; + var c = { c: 3 }; + var a2 = { a: 4 }; + + _emberUtilsAssign.default(a, b, c, a2); + + deepEqual(a, { a: 4, b: 2, c: 3 }); + deepEqual(b, { b: 2 }); + deepEqual(c, { c: 3 }); + deepEqual(a2, { a: 4 }); + }); +}); +enifed('ember-utils/tests/assign_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/assign_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/assign_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/can_invoke_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + var obj = undefined; + + QUnit.module('Ember.canInvoke', { + setup: function () { + obj = { + foobar: 'foobar', + aMethodThatExists: function () {} + }; + }, + + teardown: function () { + obj = undefined; + } + }); + + QUnit.test('should return false if the object doesn\'t exist', function () { + equal(_emberUtilsIndex.canInvoke(undefined, 'aMethodThatDoesNotExist'), false); + }); + + QUnit.test('should return true if the method exists on the object', function () { + equal(_emberUtilsIndex.canInvoke(obj, 'aMethodThatExists'), true); + }); + + QUnit.test('should return false if the method doesn\'t exist on the object', function () { + equal(_emberUtilsIndex.canInvoke(obj, 'aMethodThatDoesNotExist'), false); + }); + + QUnit.test('should return false if the property exists on the object but is a non-function', function () { + equal(_emberUtilsIndex.canInvoke(obj, 'foobar'), false); + }); +}); +enifed('ember-utils/tests/can_invoke_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/can_invoke_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/can_invoke_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/checkHasSuper_test', ['exports', 'ember-environment', 'ember-utils/index'], function (exports, _emberEnvironment, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('checkHasSuper'); + + // Only run this test on browsers that we are certain should have function + // source available. This allows the test suite to continue to pass on other + // platforms that correctly (for them) fall back to the "always wrap" code. + if (_emberEnvironment.environment.isPhantom || _emberEnvironment.environment.isChrome || _emberEnvironment.environment.isFirefox) { + QUnit.test('does not super wrap needlessly [GH #12462]', function (assert) { + assert.notOk(_emberUtilsIndex.checkHasSuper(function () {}), 'empty function does not have super'); + }); + } +}); +enifed('ember-utils/tests/checkHasSuper_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/checkHasSuper_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/checkHasSuper_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/generate_guid_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('Ember.generateGuid'); + + QUnit.test('Prefix', function () { + var a = {}; + + ok(_emberUtilsIndex.generateGuid(a, 'tyrell').indexOf('tyrell') > -1, 'guid can be prefixed'); + }); +}); +enifed('ember-utils/tests/generate_guid_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/generate_guid_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/generate_guid_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/guid_for_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('guidFor'); + + function sameGuid(a, b, message) { + equal(_emberUtilsIndex.guidFor(a), _emberUtilsIndex.guidFor(b), message); + } + + function diffGuid(a, b, message) { + ok(_emberUtilsIndex.guidFor(a) !== _emberUtilsIndex.guidFor(b), message); + } + + function nanGuid(obj) { + var type = typeof obj; + ok(isNaN(parseInt(_emberUtilsIndex.guidFor(obj), 0)), 'guids for ' + type + 'don\'t parse to numbers'); + } + + QUnit.test('Object', function () { + var a = {}; + var b = {}; + + sameGuid(a, a, 'same object always yields same guid'); + diffGuid(a, b, 'different objects yield different guids'); + nanGuid(a); + }); + + QUnit.test('strings', function () { + var a = 'string A'; + var aprime = 'string A'; + var b = 'String B'; + + sameGuid(a, a, 'same string always yields same guid'); + sameGuid(a, aprime, 'identical strings always yield the same guid'); + diffGuid(a, b, 'different strings yield different guids'); + nanGuid(a); + }); + + QUnit.test('numbers', function () { + var a = 23; + var aprime = 23; + var b = 34; + + sameGuid(a, a, 'same numbers always yields same guid'); + sameGuid(a, aprime, 'identical numbers always yield the same guid'); + diffGuid(a, b, 'different numbers yield different guids'); + nanGuid(a); + }); + + QUnit.test('numbers', function () { + var a = true; + var aprime = true; + var b = false; + + sameGuid(a, a, 'same booleans always yields same guid'); + sameGuid(a, aprime, 'identical booleans always yield the same guid'); + diffGuid(a, b, 'different boolean yield different guids'); + nanGuid(a); + nanGuid(b); + }); + + QUnit.test('null and undefined', function () { + var a = null; + var aprime = null; + var b = undefined; + + sameGuid(a, a, 'null always returns the same guid'); + sameGuid(b, b, 'undefined always returns the same guid'); + sameGuid(a, aprime, 'different nulls return the same guid'); + diffGuid(a, b, 'null and undefined return different guids'); + nanGuid(a); + nanGuid(b); + }); + + QUnit.test('arrays', function () { + var a = ['a', 'b', 'c']; + var aprime = ['a', 'b', 'c']; + var b = ['1', '2', '3']; + + sameGuid(a, a, 'same instance always yields same guid'); + diffGuid(a, aprime, 'identical arrays always yield the same guid'); + diffGuid(a, b, 'different arrays yield different guids'); + nanGuid(a); + }); +}); +enifed('ember-utils/tests/guid_for_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/guid_for_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/guid_for_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/inspect_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + // Symbol is not defined on pre-ES2015 runtimes, so this let's us safely test + // for it's existence (where a simple `if (Symbol)` would ReferenceError) + var HAS_NATIVE_SYMBOL = typeof Symbol === 'function'; + + QUnit.module('Ember.inspect'); + + QUnit.test('strings', function () { + equal(_emberUtilsIndex.inspect('foo'), 'foo'); + }); + + QUnit.test('numbers', function () { + equal(_emberUtilsIndex.inspect(2.6), '2.6'); + }); + + QUnit.test('null', function () { + equal(_emberUtilsIndex.inspect(null), 'null'); + }); + + QUnit.test('undefined', function () { + equal(_emberUtilsIndex.inspect(undefined), 'undefined'); + }); + + QUnit.test('true', function () { + equal(_emberUtilsIndex.inspect(true), 'true'); + }); + + QUnit.test('false', function () { + equal(_emberUtilsIndex.inspect(false), 'false'); + }); + + QUnit.test('object', function () { + equal(_emberUtilsIndex.inspect({}), '{}'); + equal(_emberUtilsIndex.inspect({ foo: 'bar' }), '{foo: bar}'); + equal(_emberUtilsIndex.inspect({ foo: function () { + return this; + } }), '{foo: function() { ... }}'); + }); + + QUnit.test('objects without a prototype', function () { + var prototypelessObj = Object.create(null); + equal(_emberUtilsIndex.inspect({ foo: prototypelessObj }), '{foo: [object Object]}'); + }); + + QUnit.test('array', function () { + equal(_emberUtilsIndex.inspect([1, 2, 3]), '[1,2,3]'); + }); + + QUnit.test('regexp', function () { + equal(_emberUtilsIndex.inspect(/regexp/), '/regexp/'); + }); + + QUnit.test('date', function () { + var inspected = _emberUtilsIndex.inspect(new Date('Sat Apr 30 2011 13:24:11')); + ok(inspected.match(/Sat Apr 30/), 'The inspected date has its date'); + ok(inspected.match(/2011/), 'The inspected date has its year'); + ok(inspected.match(/13:24:11/), 'The inspected date has its time'); + }); + + QUnit.test('inspect outputs the toString() representation of Symbols', function () { + if (HAS_NATIVE_SYMBOL) { + var symbol = Symbol('test'); + equal(_emberUtilsIndex.inspect(symbol), 'Symbol(test)'); + } else { + expect(0); + } + }); +}); +enifed('ember-utils/tests/inspect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/inspect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/inspect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/make_array_test', ['exports', 'ember-utils/make-array'], function (exports, _emberUtilsMakeArray) { + 'use strict'; + + QUnit.module('Ember.makeArray'); + + QUnit.test('undefined', function () { + deepEqual(_emberUtilsMakeArray.default(), []); + deepEqual(_emberUtilsMakeArray.default(undefined), []); + }); + + QUnit.test('null', function () { + deepEqual(_emberUtilsMakeArray.default(null), []); + }); + + QUnit.test('string', function () { + deepEqual(_emberUtilsMakeArray.default('lindsay'), ['lindsay']); + }); + + QUnit.test('number', function () { + deepEqual(_emberUtilsMakeArray.default(0), [0]); + deepEqual(_emberUtilsMakeArray.default(1), [1]); + }); + + QUnit.test('array', function () { + deepEqual(_emberUtilsMakeArray.default([1, 2, 42]), [1, 2, 42]); + }); + + QUnit.test('true', function () { + deepEqual(_emberUtilsMakeArray.default(true), [true]); + }); + + QUnit.test('false', function () { + deepEqual(_emberUtilsMakeArray.default(false), [false]); + }); + + QUnit.test('object', function () { + deepEqual(_emberUtilsMakeArray.default({}), [{}]); + }); +}); +enifed('ember-utils/tests/make_array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/make_array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/make_array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/to-string-test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('ember-utils toString'); + + QUnit.test('toString uses an object\'s toString method when available', function () { + var obj = { + toString: function () { + return 'bob'; + } + }; + + strictEqual(_emberUtilsIndex.toString(obj), 'bob'); + }); + + QUnit.test('toString falls back to Object.prototype.toString', function () { + var obj = Object.create(null); + + strictEqual(_emberUtilsIndex.toString(obj), ({}).toString()); + }); +}); +enifed('ember-utils/tests/to-string-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/to-string-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/to-string-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/try_invoke_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + var obj = undefined; + + QUnit.module('Ember.tryInvoke', { + setup: function () { + obj = { + aMethodThatExists: function () { + return true; + }, + aMethodThatTakesArguments: function (arg1, arg2) { + return arg1 === arg2; + } + }; + }, + + teardown: function () { + obj = undefined; + } + }); + + QUnit.test('should return undefined when the object doesn\'t exist', function () { + equal(_emberUtilsIndex.tryInvoke(undefined, 'aMethodThatDoesNotExist'), undefined); + }); + + QUnit.test('should return undefined when asked to perform a method that doesn\'t exist on the object', function () { + equal(_emberUtilsIndex.tryInvoke(obj, 'aMethodThatDoesNotExist'), undefined); + }); + + QUnit.test('should return what the method returns when asked to perform a method that exists on the object', function () { + equal(_emberUtilsIndex.tryInvoke(obj, 'aMethodThatExists'), true); + }); + + QUnit.test('should return what the method returns when asked to perform a method that takes arguments and exists on the object', function () { + equal(_emberUtilsIndex.tryInvoke(obj, 'aMethodThatTakesArguments', [true, true]), true); + }); +}); +enifed('ember-utils/tests/try_invoke_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/try_invoke_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/try_invoke_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/to-string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/to-string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/to-string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/weak-map-utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/weak-map-utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/weak-map-utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/compat/attrs.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/compat/attrs.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/compat/attrs.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/compat/fallback-view-registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/compat/fallback-view-registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/compat/fallback-view-registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/component_lookup.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/component_lookup.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/component_lookup.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/action_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/action_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/action_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/child_views_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/child_views_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/child_views_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/class_names_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/class_names_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/class_names_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/text_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/text_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/text_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/view_state_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/view_state_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/view_state_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/view_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/view_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/view_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/action_manager.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/action_manager.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/action_manager.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/event_dispatcher.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/event_dispatcher.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/event_dispatcher.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/ext.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/ext.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/ext.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/jquery.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/jquery.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/jquery.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/lookup_partial.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/lookup_partial.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/lookup_partial.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/utils/lookup-component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/utils/lookup-component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/utils/lookup-component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/core_view.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/core_view.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/core_view.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/default.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/default.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/default.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/destroying.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/destroying.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/destroying.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/has_element.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/has_element.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/has_element.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/in_dom.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/in_dom.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/in_dom.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/pre_render.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/pre_render.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/pre_render.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/view.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/view.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/view.js should pass ESLint\n\n'); + }); +}); +enifed('ember/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/application_lifecycle_test', ['exports', 'ember-application', 'ember-routing', 'ember-metal', 'ember-glimmer', 'ember-views', 'ember-template-compiler'], function (exports, _emberApplication, _emberRouting, _emberMetal, _emberGlimmer, _emberViews, _emberTemplateCompiler) { + 'use strict'; + + var App = undefined, + TEMPLATES = undefined, + appInstance = undefined, + router = undefined; + + function setupApp(klass) { + _emberMetal.run(function () { + App = klass.create({ + rootElement: '#qunit-fixture' + }); + + App.Router = App.Router.extend({ + location: 'none' + }); + + App.deferReadiness(); + + appInstance = App.__deprecatedInstance__; + }); + } + + QUnit.module('Application Lifecycle', { + setup: function () { + TEMPLATES = _emberGlimmer.getTemplates(); + setupApp(_emberApplication.Application.extend()); + }, + + teardown: function () { + router = null; + _emberMetal.run(App, 'destroy'); + _emberGlimmer.setTemplates({}); + } + }); + + function handleURL(path) { + router = appInstance.lookup('router:main'); + return _emberMetal.run(function () { + return router.handleURL(path).then(function (value) { + ok(true, 'url: `' + path + '` was handled'); + return value; + }, function (reason) { + ok(false, reason); + throw reason; + }); + }); + } + + QUnit.test('Resetting the application allows controller properties to be set when a route deactivates', function () { + App.Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('home').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('home').set('selectedMenuItem', null); + } + }); + App.ApplicationRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('application').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('application').set('selectedMenuItem', null); + } + }); + + appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + + handleURL('/'); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), 'home'); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), 'home'); + + App.reset(); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), null); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), null); + }); + + QUnit.test('Destroying the application resets the router before the appInstance is destroyed', function () { + App.Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('home').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('home').set('selectedMenuItem', null); + } + }); + App.ApplicationRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('application').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('application').set('selectedMenuItem', null); + } + }); + + appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + + handleURL('/'); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), 'home'); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), 'home'); + + _emberMetal.run(App, 'destroy'); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), null); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), null); + }); + + QUnit.test('Destroying a route after the router does create an undestroyed `toplevelView`', function () { + App.Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplates({ + index: _emberTemplateCompiler.compile('Index!'), + application: _emberTemplateCompiler.compile('Application! {{outlet}}') + }); + + App.IndexRoute = _emberRouting.Route.extend(); + _emberMetal.run(App, 'advanceReadiness'); + + handleURL('/'); + + var router = appInstance.lookup('router:main'); + var route = appInstance.lookup('route:index'); + + _emberMetal.run(router, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was cleared'); + + _emberMetal.run(route, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + + _emberMetal.run(App, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + }); + + QUnit.test('initializers can augment an applications customEvents hash', function (assert) { + assert.expect(1); + + _emberMetal.run(App, 'destroy'); + + var ApplicationSubclass = _emberApplication.Application.extend(); + + ApplicationSubclass.initializer({ + name: 'customize-things', + initialize: function (application) { + application.customEvents = { + wowza: 'wowza' + }; + } + }); + + setupApp(ApplicationSubclass); + + App.FooBarComponent = _emberGlimmer.Component.extend({ + wowza: function () { + assert.ok(true, 'fired the event!'); + } + }); + + TEMPLATES['application'] = _emberTemplateCompiler.compile('{{foo-bar}}'); + TEMPLATES['components/foo-bar'] = _emberTemplateCompiler.compile('
    '); + + _emberMetal.run(App, 'advanceReadiness'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#wowza-thingy').trigger('wowza'); + }); + }); + + QUnit.test('instanceInitializers can augment an the customEvents hash', function (assert) { + assert.expect(1); + + _emberMetal.run(App, 'destroy'); + + var ApplicationSubclass = _emberApplication.Application.extend(); + + ApplicationSubclass.instanceInitializer({ + name: 'customize-things', + initialize: function (application) { + application.customEvents = { + herky: 'jerky' + }; + } + }); + + setupApp(ApplicationSubclass); + + App.FooBarComponent = _emberGlimmer.Component.extend({ + jerky: function () { + assert.ok(true, 'fired the event!'); + } + }); + + TEMPLATES['application'] = _emberTemplateCompiler.compile('{{foo-bar}}'); + TEMPLATES['components/foo-bar'] = _emberTemplateCompiler.compile('
    '); + + _emberMetal.run(App, 'advanceReadiness'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#herky-thingy').trigger('herky'); + }); + }); +}); +enifed('ember/tests/application_lifecycle_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/application_lifecycle_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/application_lifecycle_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/component_registration_test', ['exports', 'ember-runtime', 'ember-metal', 'ember-application', 'ember-routing', 'ember-template-compiler', 'ember-glimmer', 'ember-views'], function (exports, _emberRuntime, _emberMetal, _emberApplication, _emberRouting, _emberTemplateCompiler, _emberGlimmer, _emberViews) { + 'use strict'; + + var App = undefined, + appInstance = undefined; + + function prepare() { + _emberGlimmer.setTemplate('components/expand-it', _emberTemplateCompiler.compile('

    hello {{yield}}

    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('Hello world {{#expand-it}}world{{/expand-it}}')); + } + + function cleanup() { + _emberMetal.run(function () { + try { + if (App) { + App.destroy(); + } + App = appInstance = null; + } finally { + _emberGlimmer.setTemplates({}); + } + }); + } + + QUnit.module('Application Lifecycle - Component Registration', { + setup: prepare, + teardown: cleanup + }); + + function boot(callback) { + var startURL = arguments.length <= 1 || arguments[1] === undefined ? '/' : arguments[1]; + + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + appInstance = App.__deprecatedInstance__; + + if (callback) { + callback(); + } + }); + + var router = appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + _emberMetal.run(function () { + return router.handleURL(startURL); + }); + } + + QUnit.test('The helper becomes the body of the component', function () { + boot(); + equal(_emberViews.jQuery('div.ember-view > div.ember-view', '#qunit-fixture').text(), 'hello world', 'The component is composed correctly'); + }); + + QUnit.test('If a component is registered, it is used', function () { + boot(function () { + appInstance.register('component:expand-it', _emberGlimmer.Component.extend({ + classNames: 'testing123' + })); + }); + + equal(_emberViews.jQuery('div.testing123', '#qunit-fixture').text(), 'hello world', 'The component is composed correctly'); + }); + + QUnit.test('Late-registered components can be rendered with custom `layout` property', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    there goes {{my-hero}}
    ')); + + boot(function () { + appInstance.register('component:my-hero', _emberGlimmer.Component.extend({ + classNames: 'testing123', + layout: _emberTemplateCompiler.compile('watch him as he GOES') + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'there goes watch him as he GOES', 'The component is composed correctly'); + }); + + QUnit.test('Late-registered components can be rendered with template registered on the container', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}
    ')); + + boot(function () { + appInstance.register('template:components/sally-rutherford', _emberTemplateCompiler.compile('funkytowny{{yield}}')); + appInstance.register('component:sally-rutherford', _emberGlimmer.Component); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'hello world funkytowny-funkytowny!!!', 'The component is composed correctly'); + }); + + QUnit.test('Late-registered components can be rendered with ONLY the template registered on the container', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    hello world {{borf-snorlax}}-{{#borf-snorlax}}!!!{{/borf-snorlax}}
    ')); + + boot(function () { + appInstance.register('template:components/borf-snorlax', _emberTemplateCompiler.compile('goodfreakingTIMES{{yield}}')); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'hello world goodfreakingTIMES-goodfreakingTIMES!!!', 'The component is composed correctly'); + }); + + QUnit.test('Assigning layoutName to a component should setup the template as a layout', function () { + expect(1); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('foo-bar-baz', _emberTemplateCompiler.compile('{{text}}-{{yield}}')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + layoutName: 'foo-bar-baz' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Assigning layoutName and layout to a component should use the `layout` value', function () { + expect(1); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('foo-bar-baz', _emberTemplateCompiler.compile('No way!')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + layoutName: 'foo-bar-baz', + layout: _emberTemplateCompiler.compile('{{text}}-{{yield}}') + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Assigning defaultLayout to a component should set it up as a layout if no layout was found [DEPRECATED]', function () { + expect(2); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + + expectDeprecation(function () { + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + defaultLayout: _emberTemplateCompiler.compile('{{text}}-{{yield}}') + })); + }); + }, /Specifying `defaultLayout` to .+ is deprecated\./); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Assigning defaultLayout to a component should set it up as a layout if layout was found [DEPRECATED]', function () { + expect(2); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('{{text}}-{{yield}}')); + + expectDeprecation(function () { + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + defaultLayout: _emberTemplateCompiler.compile('should not see this!') + })); + }); + }, /Specifying `defaultLayout` to .+ is deprecated\./); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Using name of component that does not exist', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#no-good}} {{/no-good}}
    ')); + + expectAssertion(function () { + return boot(); + }, /.* named "no-good" .*/); + }); + + QUnit.module('Application Lifecycle - Component Context', { + setup: prepare, + teardown: cleanup + }); + + QUnit.test('Components with a block should have the proper content when a template is provided', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('{{text}}-{{yield}}')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Components with a block should yield the proper content without a template provided', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'outer', 'The component is composed correctly'); + }); + + QUnit.test('Components without a block should have the proper content when a template is provided', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('{{text}}')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner', 'The component is composed correctly'); + }); + + QUnit.test('Components without a block should have the proper content', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$().html('Some text inserted by jQuery'); + } + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'Some text inserted by jQuery', 'The component is composed correctly'); + }); + + // The test following this one is the non-deprecated version + QUnit.test('properties of a component without a template should not collide with internal structures [DEPRECATED]', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component data=foo}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer', + 'foo': 'Some text inserted by jQuery' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$().html(this.get('data')); + } + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'Some text inserted by jQuery', 'The component is composed correctly'); + }); + + QUnit.test('attrs property of a component without a template should not collide with internal structures', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component attrs=foo}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer', + 'foo': 'Some text inserted by jQuery' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + didInsertElement: function () { + // FIXME: I'm unsure if this is even the right way to access attrs + this.$().html(this.get('attrs.attrs.value')); + } + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'Some text inserted by jQuery', 'The component is composed correctly'); + }); + + QUnit.test('Components trigger actions in the parents context when called from within a block', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}Fizzbuzz{{/my-component}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + actions: { + fizzbuzz: function () { + ok(true, 'action triggered on parent'); + } + } + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend()); + }); + + _emberMetal.run(function () { + _emberViews.jQuery('#fizzbuzz', '#wrapper').click(); + }); + }); + + QUnit.test('Components trigger actions in the components context when called from within its template', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('Fizzbuzz')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + actions: { + fizzbuzz: function () { + ok(false, 'action triggered on the wrong context'); + } + } + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + actions: { + fizzbuzz: function () { + ok(true, 'action triggered on component'); + } + } + })); + }); + + _emberViews.jQuery('#fizzbuzz', '#wrapper').click(); + }); +}); +enifed('ember/tests/component_registration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/component_registration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/component_registration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/controller_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-glimmer', 'ember-views'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberGlimmer, _emberViews) { + 'use strict'; + + /* + In Ember 1.x, controllers subtly affect things like template scope + and action targets in exciting and often inscrutable ways. This test + file contains integration tests that verify the correct behavior of + the many parts of the system that change and rely upon controller scope, + from the runtime up to the templating layer. + */ + + var App = undefined, + $fixture = undefined; + + QUnit.module('Template scoping examples', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + App.LoadingRoute = _emberRouting.Route.extend(); + }); + + $fixture = _emberViews.jQuery('#qunit-fixture'); + }, + + teardown: function () { + _emberMetal.run(function () { + return App.destroy(); + }); + + App = null; + + _emberGlimmer.setTemplates({}); + } + }); + + QUnit.test('Actions inside an outlet go to the associated controller', function () { + expect(1); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{component-with-action action=\'componentAction\'}}')); + + App.IndexController = _emberRuntime.Controller.extend({ + actions: { + componentAction: function () { + ok(true, 'received the click'); + } + } + }); + + App.ComponentWithActionComponent = _emberGlimmer.Component.extend({ + classNames: ['component-with-action'], + click: function () { + this.sendAction(); + } + }); + + bootApp(); + + $fixture.find('.component-with-action').click(); + }); + + function bootApp() { + _emberMetal.run(App, 'advanceReadiness'); + } +}); +enifed('ember/tests/controller_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/controller_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/controller_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/global-api-test', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; + + QUnit.module('Global API Tests'); + + function confirmExport(property, internal) { + QUnit.test('confirm ' + property + ' is exported', function () { + var theExport = _emberMetal.get(window, property); + ok(theExport + ' is exported'); + if (internal !== undefined) { + equal(theExport, internal, theExport + ' is exported properly'); + } + }); + } + + confirmExport('Ember.DefaultResolver'); + confirmExport('Ember.generateController'); + confirmExport('Ember.Helper'); + confirmExport('Ember.Helper.helper'); + confirmExport('Ember.isArray', _emberRuntime.isArray); +}); +enifed('ember/tests/global-api-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/global-api-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/global-api-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/helper_registration_test', ['exports', 'ember-runtime', 'ember-metal', 'ember-template-compiler', 'ember-glimmer', 'ember-application', 'ember-routing', 'ember-views'], function (exports, _emberRuntime, _emberMetal, _emberTemplateCompiler, _emberGlimmer, _emberApplication, _emberRouting, _emberViews) { + 'use strict'; + + var App = undefined, + appInstance = undefined; + + QUnit.module('Application Lifecycle - Helper Registration', { + teardown: function () { + _emberMetal.run(function () { + if (App) { + App.destroy(); + } + + App = appInstance = null; + _emberGlimmer.setTemplates({}); + }); + } + }); + + function boot(callback) { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + // We shouldn't be testing this + appInstance = App.__deprecatedInstance__; + + if (callback) { + callback(); + } + }); + + var router = appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + _emberMetal.run(function () { + return router.handleURL('/'); + }); + } + + QUnit.test('Unbound dashed helpers registered on the container can be late-invoked', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{x-borf}} {{x-borf \'YES\'}}
    ')); + var myHelper = _emberGlimmer.helper(function (params) { + return params[0] || 'BORF'; + }); + + boot(function () { + App.register('helper:x-borf', myHelper); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'BORF YES', 'The helper was invoked from the container'); + }); + + QUnit.test('Bound helpers registered on the container can be late-invoked', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{x-reverse}} {{x-reverse foo}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + foo: 'alex' + })); + + appInstance.register('helper:x-reverse', _emberGlimmer.helper(function (_ref) { + var value = _ref[0]; + + return value ? value.split('').reverse().join('') : '--'; + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), '-- xela', 'The bound helper was invoked from the container'); + }); + + QUnit.test('Undashed helpers registered on the container can be invoked', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{omg}}|{{yorp \'boo\'}}|{{yorp \'ya\'}}
    ')); + + boot(function () { + appInstance.register('helper:omg', _emberGlimmer.helper(function () { + return 'OMG'; + })); + + appInstance.register('helper:yorp', _emberGlimmer.helper(function (_ref2) { + var value = _ref2[0]; + return value; + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'OMG|boo|ya', 'The helper was invoked from the container'); + }); + + QUnit.test('Helpers can receive injections', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{full-name}}
    ')); + + var serviceCalled = false; + boot(function () { + appInstance.register('service:name-builder', _emberRuntime.Service.extend({ + build: function () { + serviceCalled = true; + } + })); + appInstance.register('helper:full-name', _emberGlimmer.Helper.extend({ + nameBuilder: _emberRuntime.inject.service('name-builder'), + compute: function () { + this.get('nameBuilder').build(); + } + })); + }); + + ok(serviceCalled, 'service was injected, method called'); + }); +}); +enifed('ember/tests/helpers/helper_registration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/helper_registration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/helper_registration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/link_to_test', ['exports', 'ember-console', 'ember-runtime', 'ember-metal', 'ember-routing', 'ember-application', 'ember-views', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberConsole, _emberRuntime, _emberMetal, _emberRouting, _emberApplication, _emberViews, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + router = undefined, + appInstance = undefined; + + function bootApplication() { + router = appInstance.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + // IE includes the host name + function normalizeUrl(url) { + return url.replace(/https?:\/\/[^\/]+/, ''); + } + + function shouldNotBeActive(selector) { + checkActive(selector, false); + } + + function shouldBeActive(selector) { + checkActive(selector, true); + } + + function checkActive(selector, active) { + var classList = _emberViews.jQuery(selector, '#qunit-fixture')[0].className; + equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); + } + + var updateCount = undefined, + replaceCount = undefined; + + function sharedSetup() { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + updateCount = replaceCount = 0; + App.Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + updateCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router = App.Router; + appInstance = App.__deprecatedInstance__; + } + + function sharedTeardown() { + _emberMetal.run(function () { + return App.destroy(); + }); + _emberGlimmer.setTemplates({}); + _emberMetal.instrumentationReset(); + } + + QUnit.module('The {{link-to}} helper', { + setup: function () { + _emberMetal.run(function () { + sharedSetup(); + + _emberGlimmer.setTemplate('app', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}{{#link-to \'index\' id=\'self-link\'}}Self{{/link-to}}')); + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile('

    About

    {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}{{#link-to \'about\' id=\'self-link\'}}Self{{/link-to}}')); + _emberGlimmer.setTemplate('item', _emberTemplateCompiler.compile('

    Item

    {{model.name}}

    {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}')); + + appInstance.unregister('router:main'); + appInstance.register('router:main', Router); + }); + }, + + teardown: sharedTeardown + }); + + QUnit.test('The {{link-to}} helper moves into the named route', function () { + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 1, 'The about template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#home-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + QUnit.test('The {{link-to}} helper fires an interaction event', function (assert) { + assert.expect(2); + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.instrumentationSubscribe('interaction.link-to', { + before: function () { + assert.ok(true, 'instrumentation subscriber was called'); + }, + after: function () { + assert.ok(true, 'instrumentation subscriber was called'); + } + }); + + _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + QUnit.test('The {{link-to}} helper interaction event includes the route name', function (assert) { + assert.expect(2); + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.instrumentationSubscribe('interaction.link-to', { + before: function (name, timestamp, _ref) { + var routeName = _ref.routeName; + + assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); + }, + after: function (name, timestamp, _ref2) { + var routeName = _ref2.routeName; + + assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); + } + }); + + _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + QUnit.test('The {{link-to}} helper interaction event includes the transition in the after hook', function (assert) { + assert.expect(1); + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.instrumentationSubscribe('interaction.link-to', { + before: function () {}, + after: function (name, timestamp, _ref3) { + var transition = _ref3.transition; + + assert.equal(transition.targetName, 'about', 'instrumentation subscriber was passed route name'); + } + }); + + _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + } + + QUnit.test('The {{link-to}} helper supports URL replacement', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' replace=true}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(updateCount, 0, 'precond: setURL has not been called'); + equal(replaceCount, 0, 'precond: replaceURL has not been called'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(updateCount, 0, 'setURL should not be called'); + equal(replaceCount, 1, 'replaceURL should be called once'); + }); + + QUnit.test('The {{link-to}} helper supports URL replacement via replace=boundTruthyThing', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' replace=boundTruthyThing}}About{{/link-to}}')); + + App.IndexController = _emberRuntime.Controller.extend({ + boundTruthyThing: true + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(updateCount, 0, 'precond: setURL has not been called'); + equal(replaceCount, 0, 'precond: replaceURL has not been called'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(updateCount, 0, 'setURL should not be called'); + equal(replaceCount, 1, 'replaceURL should be called once'); + }); + + QUnit.test('The {{link-to}} helper supports setting replace=boundFalseyThing', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' replace=boundFalseyThing}}About{{/link-to}}')); + + App.IndexController = _emberRuntime.Controller.extend({ + boundFalseyThing: false + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(updateCount, 0, 'precond: setURL has not been called'); + equal(replaceCount, 0, 'precond: replaceURL has not been called'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(updateCount, 1, 'setURL should be called'); + equal(replaceCount, 0, 'replaceURL should not be called'); + }); + + // jscs:disable + + QUnit.test("the {{link-to}} helper doesn't add an href when the tagName isn't 'a'", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'about\' id=\'about-link\' tagName=\'div\'}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link').attr('href'), undefined, 'there is no href attribute'); + }); + + QUnit.test("the {{link-to}} applies a 'disabled' class when disabled", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to "about" id="about-link-static" disabledWhen="shouldDisable"}}About{{/link-to}}\n {{#link-to "about" id="about-link-dynamic" disabledWhen=dynamicDisabledWhen}}About{{/link-to}}\n ')); + + App.IndexController = _emberRuntime.Controller.extend({ + shouldDisable: true, + dynamicDisabledWhen: 'shouldDisable' + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link-static.disabled', '#qunit-fixture').length, 1, 'The static link is disabled when its disabledWhen is true'); + equal(_emberViews.jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 1, 'The dynamic link is disabled when its disabledWhen is true'); + + _emberMetal.run(function () { + return _emberMetal.set(appInstance.lookup('controller:index'), 'dynamicDisabledWhen', false); + }); + + equal(_emberViews.jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 0, 'The dynamic link is re-enabled when its disabledWhen becomes false'); + }); + + QUnit.test("the {{link-to}} doesn't apply a 'disabled' class if disabledWhen is not provided", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link"}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + ok(!_emberViews.jQuery('#about-link', '#qunit-fixture').hasClass('disabled'), 'The link is not disabled if disabledWhen not provided'); + }); + + QUnit.test('the {{link-to}} helper supports a custom disabledClass', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=true disabledClass="do-not-want"}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link.do-not-want', '#qunit-fixture').length, 1, 'The link can apply a custom disabled class'); + }); + + QUnit.test('the {{link-to}} helper supports a custom disabledClass set via bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=true disabledClass=disabledClass}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + disabledClass: 'do-not-want' + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link.do-not-want', '#qunit-fixture').length, 1, 'The link can apply a custom disabled class via bound param'); + }); + + QUnit.test('the {{link-to}} helper does not respond to clicks when disabled', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=true}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur'); + }); + + QUnit.test('the {{link-to}} helper responds to clicks according to its disabledWhen bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=disabledWhen}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + disabledWhen: true + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur'); + + _emberMetal.run(function () { + return _emberMetal.set(appInstance.lookup('controller:index'), 'disabledWhen', false); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 1, 'Transitioning did occur when disabledWhen became false'); + }); + + QUnit.test('The {{link-to}} helper supports a custom activeClass', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'about' id='about-link'}}About{{/link-to}}{{#link-to 'index' id='self-link' activeClass='zomg-active'}}Self{{/link-to}}")); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberViews.jQuery('#self-link.zomg-active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + QUnit.test('The {{link-to}} helper supports a custom activeClass from a bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}{{#link-to \'index\' id=\'self-link\' activeClass=activeClass}}Self{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + activeClass: 'zomg-active' + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberViews.jQuery('#self-link.zomg-active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + QUnit.test("The {{link-to}} helper supports 'classNameBindings' with custom values [GH #11699]", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' classNameBindings=\'foo:foo-is-true:foo-is-false\'}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + foo: false + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link.foo-is-false', '#qunit-fixture').length, 1, 'The about-link was rendered with the falsy class'); + + var controller = appInstance.lookup('controller:index'); + + _emberMetal.run(function () { + return controller.set('foo', true); + }); + + equal(_emberViews.jQuery('#about-link.foo-is-true', '#qunit-fixture').length, 1, 'The about-link was rendered with the truthy class after toggling the property'); + }); + + QUnit.test('The {{link-to}} helper supports leaving off .index for nested routes', function () { + Router.map(function () { + this.route('about', function () { + this.route('item'); + }); + }); + + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile('

    About

    {{outlet}}')); + _emberGlimmer.setTemplate('about/index', _emberTemplateCompiler.compile("
    Index
    ")); + _emberGlimmer.setTemplate('about/item', _emberTemplateCompiler.compile("
    {{#link-to 'about'}}About{{/link-to}}
    ")); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/about/item'); + + equal(normalizeUrl(_emberViews.jQuery('#item a', '#qunit-fixture').attr('href')), '/about'); + }); + + QUnit.test('The {{link-to}} helper supports currentWhen (DEPRECATED)', function () { + expectDeprecation('Usage of `currentWhen` is deprecated, use `current-when` instead.'); + + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('item'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'item' id='other-link' currentWhen='index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active since current-when is a parent route'); + }); + + QUnit.test('The {{link-to}} helper supports custom, nested, current-when', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('item'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'item' id='other-link' current-when='index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active since current-when is a parent route'); + }); + + QUnit.test('The {{link-to}} helper does not disregard current-when when it is given explicitly for a route', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('items', function () { + this.route('item'); + }); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'items' id='other-link' current-when='index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active when current-when is given for explicitly for a route'); + }); + + QUnit.test('The {{link-to}} helper does not disregard current-when when it is set via a bound param', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('items', function () { + this.route('item'); + }); + }); + + App.IndexAboutController = _emberRuntime.Controller.extend({ + currentWhen: 'index' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'items' id='other-link' current-when=currentWhen}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active when current-when is given for explicitly for a route'); + }); + + QUnit.test('The {{link-to}} helper supports multiple current-when routes', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + this.route('item'); + this.route('foo'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'item' id='link1' current-when='item index'}}ITEM{{/link-to}}")); + _emberGlimmer.setTemplate('item', _emberTemplateCompiler.compile("{{#link-to 'item' id='link2' current-when='item index'}}ITEM{{/link-to}}")); + _emberGlimmer.setTemplate('foo', _emberTemplateCompiler.compile("{{#link-to 'item' id='link3' current-when='item index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#link1.active', '#qunit-fixture').length, 1, 'The link is active since current-when contains the parent route'); + + _emberMetal.run(function () { + return router.handleURL('/item'); + }); + + equal(_emberViews.jQuery('#link2.active', '#qunit-fixture').length, 1, 'The link is active since you are on the active route'); + + _emberMetal.run(function () { + return router.handleURL('/foo'); + }); + + equal(_emberViews.jQuery('#link3.active', '#qunit-fixture').length, 0, 'The link is not active since current-when does not contain the active route'); + }); + + QUnit.test('The {{link-to}} helper defaults to bubbling', function () { + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about.contact' id='about-contact'}}About{{/link-to}}
    {{outlet}}")); + _emberGlimmer.setTemplate('about/contact', _emberTemplateCompiler.compile("

    Contact

    ")); + + Router.map(function () { + this.route('about', function () { + this.route('contact'); + }); + }); + + var hidden = 0; + + App.AboutRoute = _emberRouting.Route.extend({ + actions: { + hide: function () { + hidden++; + } + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-contact', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); + + equal(hidden, 1, 'The link bubbles'); + }); + + QUnit.test('The {{link-to}} helper supports bubbles=false', function () { + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about.contact' id='about-contact' bubbles=false}}About{{/link-to}}
    {{outlet}}")); + _emberGlimmer.setTemplate('about/contact', _emberTemplateCompiler.compile("

    Contact

    ")); + + Router.map(function () { + this.route('about', function () { + this.route('contact'); + }); + }); + + var hidden = 0; + + App.AboutRoute = _emberRouting.Route.extend({ + actions: { + hide: function () { + hidden++; + } + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-contact', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); + + equal(hidden, 0, "The link didn't bubble"); + }); + + QUnit.test('The {{link-to}} helper supports bubbles=boundFalseyThing', function () { + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about.contact' id='about-contact' bubbles=boundFalseyThing}}About{{/link-to}}
    {{outlet}}")); + _emberGlimmer.setTemplate('about/contact', _emberTemplateCompiler.compile("

    Contact

    ")); + + App.AboutController = _emberRuntime.Controller.extend({ + boundFalseyThing: false + }); + + Router.map(function () { + this.route('about', function () { + this.route('contact'); + }); + }); + + var hidden = 0; + + App.AboutRoute = _emberRouting.Route.extend({ + actions: { + hide: function () { + hidden++; + } + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-contact', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); + + equal(hidden, 0, "The link didn't bubble"); + }); + + QUnit.test('The {{link-to}} helper moves into the named route with context', function () { + Router.map(function (match) { + this.route('about'); + this.route('item', { path: '/item/:id' }); + }); + + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("

    List

      {{#each model as |person|}}
    • {{#link-to 'item' person}}{{person.name}}{{/link-to}}
    • {{/each}}
    {{#link-to 'index' id='home-link'}}Home{{/link-to}}")); + + App.AboutRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A([{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }]); + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('h3:contains(List)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(normalizeUrl(_emberViews.jQuery('#home-link').attr('href')), '/', 'The home link points back at /'); + + _emberMetal.run(function () { + return _emberViews.jQuery('li a:contains(Yehuda)', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'Yehuda Katz', 'The name is correct'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link').click(); + }); + + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Yehuda)').attr('href')), '/item/yehuda'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Tom)').attr('href')), '/item/tom'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Erik)').attr('href')), '/item/erik'); + + _emberMetal.run(function () { + return _emberViews.jQuery('li a:contains(Erik)', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'Erik Brynroflsson', 'The name is correct'); + }); + + QUnit.test('The {{link-to}} helper binds some anchor html tag common attributes', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' title='title-attr' rel='rel-attr' tabindex='-1'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#self-link', '#qunit-fixture'); + equal(link.attr('title'), 'title-attr', 'The self-link contains title attribute'); + equal(link.attr('rel'), 'rel-attr', 'The self-link contains rel attribute'); + equal(link.attr('tabindex'), '-1', 'The self-link contains tabindex attribute'); + }); + + QUnit.test('The {{link-to}} helper supports `target` attribute', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#self-link', '#qunit-fixture'); + equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); + }); + + QUnit.test('The {{link-to}} helper supports `target` attribute specified as a bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target=boundLinkTarget}}Self{{/link-to}}")); + + App.IndexController = _emberRuntime.Controller.extend({ + boundLinkTarget: '_blank' + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#self-link', '#qunit-fixture'); + equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); + }); + + QUnit.test('The {{link-to}} helper does not call preventDefault if `target` attribute is provided', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#self-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), false, 'should not preventDefault when target attribute is specified'); + }); + + QUnit.test('The {{link-to}} helper should preventDefault when `target = _self`', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target='_self'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#self-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), true, 'should preventDefault when target attribute is `_self`'); + }); + + QUnit.test('The {{link-to}} helper should not transition if target is not equal to _self or empty', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'about' id='about-link' replace=true target='_blank'}}About{{/link-to}}")); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + notEqual(appInstance.lookup('controller:application').get('currentRouteName'), 'about', 'link-to should not transition if target is not equal to _self or empty'); + }); + + QUnit.test('The {{link-to}} helper accepts string/numeric arguments', function () { + Router.map(function () { + this.route('filter', { path: '/filters/:filter' }); + this.route('post', { path: '/post/:post_id' }); + this.route('repo', { path: '/repo/:owner/:name' }); + }); + + App.FilterController = _emberRuntime.Controller.extend({ + filter: 'unpopular', + repo: _emberRuntime.Object.create({ owner: 'ember', name: 'ember.js' }), + post_id: 123 + }); + _emberGlimmer.setTemplate('filter', _emberTemplateCompiler.compile('

    {{filter}}

    {{#link-to "filter" "unpopular" id="link"}}Unpopular{{/link-to}}{{#link-to "filter" filter id="path-link"}}Unpopular{{/link-to}}{{#link-to "post" post_id id="post-path-link"}}Post{{/link-to}}{{#link-to "post" 123 id="post-number-link"}}Post{{/link-to}}{{#link-to "repo" repo id="repo-object-link"}}Repo{{/link-to}}')); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile(' ')); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/filters/popular'); + }); + + equal(normalizeUrl(_emberViews.jQuery('#link', '#qunit-fixture').attr('href')), '/filters/unpopular'); + equal(normalizeUrl(_emberViews.jQuery('#path-link', '#qunit-fixture').attr('href')), '/filters/unpopular'); + equal(normalizeUrl(_emberViews.jQuery('#post-path-link', '#qunit-fixture').attr('href')), '/post/123'); + equal(normalizeUrl(_emberViews.jQuery('#post-number-link', '#qunit-fixture').attr('href')), '/post/123'); + equal(normalizeUrl(_emberViews.jQuery('#repo-object-link', '#qunit-fixture').attr('href')), '/repo/ember/ember.js'); + }); + + QUnit.test("Issue 4201 - Shorthand for route.index shouldn't throw errors about context arguments", function () { + expect(2); + Router.map(function () { + this.route('lobby', function () { + this.route('index', { path: ':lobby_id' }); + this.route('list'); + }); + }); + + App.LobbyIndexRoute = _emberRouting.Route.extend({ + model: function (params) { + equal(params.lobby_id, 'foobar'); + return params.lobby_id; + } + }); + + _emberGlimmer.setTemplate('lobby/index', _emberTemplateCompiler.compile("{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}")); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('lobby/list', _emberTemplateCompiler.compile("{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}")); + bootApplication(); + _emberMetal.run(router, 'handleURL', '/lobby/list'); + _emberMetal.run(_emberViews.jQuery('#lobby-link'), 'click'); + shouldBeActive('#lobby-link'); + }); + + QUnit.test('Quoteless route param performs property lookup', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'index' id='string-link'}}string{{/link-to}}{{#link-to foo id='path-link'}}path{{/link-to}}")); + + function assertEquality(href) { + equal(normalizeUrl(_emberViews.jQuery('#string-link', '#qunit-fixture').attr('href')), '/'); + equal(normalizeUrl(_emberViews.jQuery('#path-link', '#qunit-fixture').attr('href')), href); + } + + App.IndexController = _emberRuntime.Controller.extend({ + foo: 'index' + }); + + App.Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + assertEquality('/'); + + var controller = appInstance.lookup('controller:index'); + _emberMetal.run(function () { + return controller.set('foo', 'about'); + }); + + assertEquality('/about'); + }); + + QUnit.test('link-to with null/undefined dynamic parameters are put in a loading state', function () { + expect(19); + + var oldWarn = _emberConsole.default.warn; + var warnCalled = false; + _emberConsole.default.warn = function () { + warnCalled = true; + }; + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to destinationRoute routeContext loadingClass='i-am-loading' id='context-link'}}string{{/link-to}}{{#link-to secondRoute loadingClass=loadingClass id='static-link'}}string{{/link-to}}")); + + var thing = _emberRuntime.Object.create({ id: 123 }); + + App.IndexController = _emberRuntime.Controller.extend({ + destinationRoute: null, + routeContext: null, + loadingClass: 'i-am-loading' + }); + + App.AboutRoute = _emberRouting.Route.extend({ + activate: function () { + ok(true, 'About was entered'); + } + }); + + App.Router.map(function () { + this.route('thing', { path: '/thing/:thing_id' }); + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + function assertLinkStatus($link, url) { + if (url) { + equal(normalizeUrl($link.attr('href')), url, 'loaded link-to has expected href'); + ok(!$link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass'); + } else { + equal(normalizeUrl($link.attr('href')), '#', "unloaded link-to has href='#'"); + ok($link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass'); + } + } + + var $contextLink = _emberViews.jQuery('#context-link', '#qunit-fixture'); + var $staticLink = _emberViews.jQuery('#static-link', '#qunit-fixture'); + var controller = appInstance.lookup('controller:index'); + + assertLinkStatus($contextLink); + assertLinkStatus($staticLink); + + _emberMetal.run(function () { + warnCalled = false; + $contextLink.click(); + ok(warnCalled, 'Logger.warn was called from clicking loading link'); + }); + + // Set the destinationRoute (context is still null). + _emberMetal.run(controller, 'set', 'destinationRoute', 'thing'); + assertLinkStatus($contextLink); + + // Set the routeContext to an id + _emberMetal.run(controller, 'set', 'routeContext', '456'); + assertLinkStatus($contextLink, '/thing/456'); + + // Test that 0 isn't interpreted as falsy. + _emberMetal.run(controller, 'set', 'routeContext', 0); + assertLinkStatus($contextLink, '/thing/0'); + + // Set the routeContext to an object + _emberMetal.run(controller, 'set', 'routeContext', thing); + assertLinkStatus($contextLink, '/thing/123'); + + // Set the destinationRoute back to null. + _emberMetal.run(controller, 'set', 'destinationRoute', null); + assertLinkStatus($contextLink); + + _emberMetal.run(function () { + warnCalled = false; + $staticLink.click(); + ok(warnCalled, 'Logger.warn was called from clicking loading link'); + }); + + _emberMetal.run(controller, 'set', 'secondRoute', 'about'); + assertLinkStatus($staticLink, '/about'); + + // Click the now-active link + _emberMetal.run($staticLink, 'click'); + + _emberConsole.default.warn = oldWarn; + }); + + QUnit.test('The {{link-to}} helper refreshes href element when one of params changes', function () { + Router.map(function () { + this.route('post', { path: '/posts/:post_id' }); + }); + + var post = _emberRuntime.Object.create({ id: '1' }); + var secondPost = _emberRuntime.Object.create({ id: '2' }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "post" post id="post"}}post{{/link-to}}')); + + App.IndexController = _emberRuntime.Controller.extend(); + var indexController = appInstance.lookup('controller:index'); + + _emberMetal.run(function () { + return indexController.set('post', post); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(normalizeUrl(_emberViews.jQuery('#post', '#qunit-fixture').attr('href')), '/posts/1', 'precond - Link has rendered href attr properly'); + + _emberMetal.run(function () { + return indexController.set('post', secondPost); + }); + + equal(_emberViews.jQuery('#post', '#qunit-fixture').attr('href'), '/posts/2', 'href attr was updated after one of the params had been changed'); + + _emberMetal.run(function () { + return indexController.set('post', null); + }); + + equal(_emberViews.jQuery('#post', '#qunit-fixture').attr('href'), '#', 'href attr becomes # when one of the arguments in nullified'); + }); + + QUnit.test('The {{link-to}} helper is active when a route is active', function () { + Router.map(function () { + this.route('about', function () { + this.route('item'); + }); + }); + + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about' id='about-link'}}About{{/link-to}} {{#link-to 'about.item' id='item-link'}}Item{{/link-to}} {{outlet}}
    ")); + _emberGlimmer.setTemplate('about/item', _emberTemplateCompiler.compile(' ')); + _emberGlimmer.setTemplate('about/index', _emberTemplateCompiler.compile(' ')); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/about'); + + equal(_emberViews.jQuery('#about-link.active', '#qunit-fixture').length, 1, 'The about route link is active'); + equal(_emberViews.jQuery('#item-link.active', '#qunit-fixture').length, 0, 'The item route link is inactive'); + + _emberMetal.run(router, 'handleURL', '/about/item'); + + equal(_emberViews.jQuery('#about-link.active', '#qunit-fixture').length, 1, 'The about route link is active'); + equal(_emberViews.jQuery('#item-link.active', '#qunit-fixture').length, 1, 'The item route link is active'); + }); + + QUnit.test("The {{link-to}} helper works in an #each'd array of string route names", function () { + Router.map(function () { + this.route('foo'); + this.route('bar'); + this.route('rar'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + routeNames: _emberRuntime.A(['foo', 'bar', 'rar']), + route1: 'bar', + route2: 'foo' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#each routeNames as |routeName|}}{{#link-to routeName}}{{routeName}}{{/link-to}}{{/each}}{{#each routeNames as |r|}}{{#link-to r}}{{r}}{{/link-to}}{{/each}}{{#link-to route1}}a{{/link-to}}{{#link-to route2}}b{{/link-to}}')); + + bootApplication(); + + function linksEqual($links, expected) { + equal($links.length, expected.length, 'Has correct number of links'); + + var idx = undefined; + for (idx = 0; idx < $links.length; idx++) { + var href = _emberViews.jQuery($links[idx]).attr('href'); + // Old IE includes the whole hostname as well + equal(href.slice(-expected[idx].length), expected[idx], 'Expected link to be \'' + expected[idx] + '\', but was \'' + href + '\''); + } + } + + linksEqual(_emberViews.jQuery('a', '#qunit-fixture'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/bar', '/foo']); + + var indexController = appInstance.lookup('controller:index'); + _emberMetal.run(indexController, 'set', 'route1', 'rar'); + + linksEqual(_emberViews.jQuery('a', '#qunit-fixture'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); + + _emberMetal.run(indexController.routeNames, 'shiftObject'); + + linksEqual(_emberViews.jQuery('a', '#qunit-fixture'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']); + }); + + QUnit.test('The non-block form {{link-to}} helper moves into the named route', function () { + expect(3); + Router.map(function (match) { + this.route('contact'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{link-to 'Contact us' 'contact' id='contact-link'}}{{#link-to 'index' id='self-link'}}Self{{/link-to}}")); + _emberGlimmer.setTemplate('contact', _emberTemplateCompiler.compile("

    Contact

    {{link-to 'Home' 'index' id='home-link'}}{{link-to 'Self' 'contact' id='self-link'}}")); + + bootApplication(); + + _emberMetal.run(function () { + return _emberViews.jQuery('#contact-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Contact)', '#qunit-fixture').length, 1, 'The contact template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#home-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + QUnit.test('The non-block form {{link-to}} helper updates the link text when it is a binding', function () { + expect(8); + Router.map(function (match) { + this.route('contact'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + contactName: 'Jane' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{link-to contactName 'contact' id='contact-link'}}{{#link-to 'index' id='self-link'}}Self{{/link-to}}")); + _emberGlimmer.setTemplate('contact', _emberTemplateCompiler.compile("

    Contact

    {{link-to 'Home' 'index' id='home-link'}}{{link-to 'Self' 'contact' id='self-link'}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var controller = appInstance.lookup('controller:index'); + + equal(_emberViews.jQuery('#contact-link:contains(Jane)', '#qunit-fixture').length, 1, 'The link title is correctly resolved'); + + _emberMetal.run(function () { + return controller.set('contactName', 'Joe'); + }); + + equal(_emberViews.jQuery('#contact-link:contains(Joe)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the bound property changes'); + + _emberMetal.run(function () { + return controller.set('contactName', 'Robert'); + }); + + equal(_emberViews.jQuery('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the bound property changes a second time'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#contact-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Contact)', '#qunit-fixture').length, 1, 'The contact template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#home-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The index template was rendered'); + equal(_emberViews.jQuery('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the route changes'); + }); + + QUnit.test('The non-block form {{link-to}} helper moves into the named route with context', function () { + expect(5); + + Router.map(function (match) { + this.route('item', { path: '/item/:id' }); + }); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A([{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }]); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

      {{#each model as |person|}}
    • {{link-to person.name 'item' person}}
    • {{/each}}
    ")); + _emberGlimmer.setTemplate('item', _emberTemplateCompiler.compile("

    Item

    {{model.name}}

    {{#link-to 'index' id='home-link'}}Home{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return _emberViews.jQuery('li a:contains(Yehuda)', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'Yehuda Katz', 'The name is correct'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link').click(); + }); + + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Yehuda)').attr('href')), '/item/yehuda'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Tom)').attr('href')), '/item/tom'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Erik)').attr('href')), '/item/erik'); + }); + + QUnit.test('The non-block form {{link-to}} performs property lookup', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{link-to 'string' 'index' id='string-link'}}{{link-to path foo id='path-link'}}")); + + function assertEquality(href) { + equal(normalizeUrl(_emberViews.jQuery('#string-link', '#qunit-fixture').attr('href')), '/'); + equal(normalizeUrl(_emberViews.jQuery('#path-link', '#qunit-fixture').attr('href')), href); + } + + App.IndexController = _emberRuntime.Controller.extend({ + foo: 'index' + }); + + App.Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + assertEquality('/'); + + var controller = appInstance.lookup('controller:index'); + _emberMetal.run(function () { + return controller.set('foo', 'about'); + }); + + assertEquality('/about'); + }); + + QUnit.test('The non-block form {{link-to}} protects against XSS', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{link-to display 'index' id='link'}}")); + + App.ApplicationController = _emberRuntime.Controller.extend({ + display: 'blahzorz' + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var controller = appInstance.lookup('controller:application'); + + equal(_emberViews.jQuery('#link', '#qunit-fixture').text(), 'blahzorz'); + _emberMetal.run(function () { + return controller.set('display', 'BLAMMO'); + }); + + equal(_emberViews.jQuery('#link', '#qunit-fixture').text(), 'BLAMMO'); + equal(_emberViews.jQuery('b', '#qunit-fixture').length, 0); + }); + + QUnit.test('the {{link-to}} helper calls preventDefault', function () { + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#about-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), true, 'should preventDefault'); + }); + + QUnit.test('the {{link-to}} helper does not call preventDefault if `preventDefault=false` is passed as an option', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'about' id='about-link' preventDefault=false}}About{{/link-to}}")); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#about-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + }); + + QUnit.test('the {{link-to}} helper does not call preventDefault if `preventDefault=boundFalseyThing` is passed as an option', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'about' id='about-link' preventDefault=boundFalseyThing}}About{{/link-to}}")); + + App.IndexController = _emberRuntime.Controller.extend({ + boundFalseyThing: false + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#about-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + }); + + QUnit.test('the {{link-to}} helper throws a useful error if you invoke it wrong', function () { + expect(1); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{#link-to 'post'}}Post{{/link-to}}")); + + Router.map(function () { + this.route('post', { path: 'post/:post_id' }); + }); + + QUnit.throws(function () { + bootApplication(); + }, /(You attempted to define a `\{\{link-to "post"\}\}` but did not pass the parameters required for generating its dynamic segments.|You must provide param `post_id` to `generate`)/); + }); + + QUnit.test('the {{link-to}} helper does not throw an error if its route has exited', function () { + expect(0); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{#link-to 'index' id='home-link'}}Home{{/link-to}}{{#link-to 'post' defaultPost id='default-post-link'}}Default Post{{/link-to}}{{#if currentPost}}{{#link-to 'post' currentPost id='current-post-link'}}Current Post{{/link-to}}{{/if}}")); + + App.ApplicationController = _emberRuntime.Controller.extend({ + defaultPost: { id: 1 }, + postController: _emberRuntime.inject.controller('post'), + currentPost: _emberMetal.alias('postController.model') + }); + + App.PostController = _emberRuntime.Controller.extend(); + + App.PostRoute = _emberRouting.Route.extend({ + model: function () { + return { id: 2 }; + }, + serialize: function (model) { + return { post_id: model.id }; + } + }); + + Router.map(function () { + this.route('post', { path: 'post/:post_id' }); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#default-post-link', '#qunit-fixture').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link', '#qunit-fixture').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#current-post-link', '#qunit-fixture').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link', '#qunit-fixture').click(); + }); + }); + + QUnit.test('{{link-to}} active property respects changing parent route context', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{link-to 'OMG' 'things' 'omg' id='omg-link'}} " + "{{link-to 'LOL' 'things' 'lol' id='lol-link'}} ")); + + Router.map(function () { + this.route('things', { path: '/things/:name' }, function () { + this.route('other'); + }); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/things/omg'); + shouldBeActive('#omg-link'); + shouldNotBeActive('#lol-link'); + + _emberMetal.run(router, 'handleURL', '/things/omg/other'); + shouldBeActive('#omg-link'); + shouldNotBeActive('#lol-link'); + }); + + QUnit.test('{{link-to}} populates href with default query param values even without query-params object', function () { + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '123' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'index' id='the-link'}}Index{{/link-to}}")); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/', 'link has right href'); + }); + + QUnit.test('{{link-to}} populates href with default query param values with empty query-params object', function () { + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '123' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'index' (query-params) id='the-link'}}Index{{/link-to}}")); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/', 'link has right href'); + }); + + QUnit.test('{{link-to}} with only query-params and a block updates when route changes', function () { + Router.map(function () { + this.route('about'); + }); + + App.ApplicationController = _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar'], + foo: '123', + bar: 'yes' + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{#link-to (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); + }); + + QUnit.test('Block-less {{link-to}} with only query-params updates when route changes', function () { + Router.map(function () { + this.route('about'); + }); + + App.ApplicationController = _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar'], + foo: '123', + bar: 'yes' + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{link-to "Index" (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}')); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); + }); + + QUnit.test('The {{link-to}} helper can use dynamic params', function () { + Router.map(function (match) { + this.route('foo', { path: 'foo/:some/:thing' }); + this.route('bar', { path: 'bar/:some/:thing/:else' }); + }); + + var controller = undefined; + App.IndexController = _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + + controller = this; + + this.dynamicLinkParams = ['foo', 'one', 'two']; + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n

    Home

    \n\n {{#link-to params=dynamicLinkParams id="dynamic-link"}}Dynamic{{/link-to}}\n ')); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#dynamic-link', '#qunit-fixture'); + + equal(link.attr('href'), '/foo/one/two'); + + _emberMetal.run(function () { + controller.set('dynamicLinkParams', ['bar', 'one', 'two', 'three']); + }); + + equal(link.attr('href'), '/bar/one/two/three'); + }); + + QUnit.test('GJ: {{link-to}} to a parent root model hook which performs a `transitionTo` has correct active class #13256', function () { + expect(1); + + Router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + App.ParentRoute = _emberRouting.Route.extend({ + afterModel: function (transition) { + this.transitionTo('parent.child'); + } + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{link-to \'Parent\' \'parent\' id=\'parent-link\'}}\n ')); + + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#parent-link'), 'click'); + + shouldBeActive('#parent-link'); + }); +}); +enifed('ember/tests/helpers/link_to_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/link_to_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/link_to_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_transitioning_classes_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-glimmer'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberViews, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + registry = undefined, + container = undefined; + + var aboutDefer = undefined, + otherDefer = undefined; + + function bootApplication() { + container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function assertHasClass(className) { + var i = 1; + while (i < arguments.length) { + var $a = arguments[i]; + var shouldHaveClass = arguments[i + 1]; + equal($a.hasClass(className), shouldHaveClass, $a.attr('id') + ' should ' + (shouldHaveClass ? '' : 'not ') + 'have class ' + className); + i += 2; + } + } + + var updateCount = undefined, + replaceCount = undefined; + + function sharedSetup() { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + updateCount = replaceCount = 0; + App.Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + updateCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router = App.Router; + registry = App.__registry__; + container = App.__container__; + } + + function sharedTeardown() { + _emberMetal.run(function () { + return App.destroy(); + }); + _emberGlimmer.setTemplates({}); + } + + QUnit.module('The {{link-to}} helper: .transitioning-in .transitioning-out CSS classes', { + setup: function () { + _emberMetal.run(function () { + sharedSetup(); + + registry.unregister('router:main'); + registry.register('router:main', Router); + + Router.map(function () { + this.route('about'); + this.route('other'); + }); + + App.AboutRoute = _emberRouting.Route.extend({ + model: function () { + aboutDefer = _emberRuntime.RSVP.defer(); + return aboutDefer.promise; + } + }); + + App.OtherRoute = _emberRouting.Route.extend({ + model: function () { + otherDefer = _emberRuntime.RSVP.defer(); + return otherDefer.promise; + } + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{link-to \'Index\' \'index\' id=\'index-link\'}}{{link-to \'About\' \'about\' id=\'about-link\'}}{{link-to \'Other\' \'other\' id=\'other-link\'}}')); + }); + }, + + teardown: function () { + sharedTeardown(); + aboutDefer = null; + } + }); + + QUnit.test('while a transition is underway', function () { + expect(18); + bootApplication(); + + var $index = _emberViews.jQuery('#index-link'); + var $about = _emberViews.jQuery('#about-link'); + var $other = _emberViews.jQuery('#other-link'); + + _emberMetal.run($about, 'click'); + + assertHasClass('active', $index, true, $about, false, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-out', $index, true, $about, false, $other, false); + + _emberMetal.run(aboutDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + }); + + QUnit.test('while a transition is underway with nested link-to\'s', function () { + expect(54); + + Router.map(function () { + this.route('parent-route', function () { + this.route('about'); + this.route('other'); + }); + }); + + App.ParentRouteAboutRoute = _emberRouting.Route.extend({ + model: function () { + aboutDefer = _emberRuntime.RSVP.defer(); + return aboutDefer.promise; + } + }); + + App.ParentRouteOtherRoute = _emberRouting.Route.extend({ + model: function () { + otherDefer = _emberRuntime.RSVP.defer(); + return otherDefer.promise; + } + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{outlet}}\n {{#link-to \'index\' tagName=\'li\'}}\n {{link-to \'Index\' \'index\' id=\'index-link\'}}\n {{/link-to}}\n {{#link-to \'parent-route.about\' tagName=\'li\'}}\n {{link-to \'About\' \'parent-route.about\' id=\'about-link\'}}\n {{/link-to}}\n {{#link-to \'parent-route.other\' tagName=\'li\'}}\n {{link-to \'Other\' \'parent-route.other\' id=\'other-link\'}}\n {{/link-to}}\n ')); + + bootApplication(); + + var $index = _emberViews.jQuery('#index-link'); + var $about = _emberViews.jQuery('#about-link'); + var $other = _emberViews.jQuery('#other-link'); + + _emberMetal.run($about, 'click'); + + assertHasClass('active', $index, true, $about, false, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-out', $index, true, $about, false, $other, false); + + _emberMetal.run(aboutDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + + _emberMetal.run($other, 'click'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, true); + assertHasClass('ember-transitioning-out', $index, false, $about, true, $other, false); + + _emberMetal.run(otherDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, false, $other, true); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + + _emberMetal.run($about, 'click'); + + assertHasClass('active', $index, false, $about, false, $other, true); + assertHasClass('ember-transitioning-in', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, true); + + _emberMetal.run(aboutDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_with_query_params_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-glimmer'], function (exports, _emberMetal, _emberRuntime, _emberRouting, _emberTemplateCompiler, _emberApplication, _emberViews, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + router = undefined, + registry = undefined, + container = undefined; + + function bootApplication() { + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function shouldNotBeActive(selector) { + checkActive(selector, false); + } + + function shouldBeActive(selector) { + checkActive(selector, true); + } + + function checkActive(selector, active) { + var classList = _emberViews.jQuery(selector, '#qunit-fixture')[0].className; + equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); + } + + var updateCount = undefined, + replaceCount = undefined; + + function sharedSetup() { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + updateCount = replaceCount = 0; + App.Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + updateCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router = App.Router; + registry = App.__registry__; + container = App.__container__; + } + + function sharedTeardown() { + _emberMetal.run(function () { + return App.destroy(); + }); + _emberGlimmer.setTemplates({}); + } + + QUnit.module('The {{link-to}} helper: invoking with query params', { + setup: function () { + _emberMetal.run(function () { + sharedSetup(); + + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar', 'abool'], + foo: '123', + bar: 'abc', + boundThing: 'OMG', + abool: true + }); + + App.AboutController = _emberRuntime.Controller.extend({ + queryParams: ['baz', 'bat'], + baz: 'alex', + bat: 'borf' + }); + + registry.unregister('router:main'); + registry.register('router:main', Router); + }); + }, + + teardown: sharedTeardown + }); + + QUnit.test('doesn\'t update controller QP properties on current route when invoked', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'index\' id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); + }); + + QUnit.test('doesn\'t update controller QP properties on current route when invoked (empty query-params obj)', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'index\' (query-params) id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); + }); + + QUnit.test('link-to with no params throws', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to id=\'the-link\'}}Index{{/link-to}}')); + expectAssertion(function () { + return bootApplication(); + }, /one or more/); + }); + + QUnit.test('doesn\'t update controller QP properties on current route when invoked (empty query-params obj, inferred route)', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params) id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); + }); + + QUnit.test('updates controller QP properties on current route when invoked', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'index\' (query-params foo=\'456\') id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); + }); + + QUnit.test('updates controller QP properties on current route when invoked (inferred route)', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params foo=\'456\') id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); + }); + + QUnit.test('updates controller QP properties on other route after transitioning to that route', function () { + Router.map(function () { + this.route('about'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'about\' (query-params baz=\'lol\') id=\'the-link\'}}About{{/link-to}}')); + bootApplication(); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/about?baz=lol'); + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var aboutController = container.lookup('controller:about'); + deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, 'about controller QP properties updated'); + + equal(container.lookup('controller:application').get('currentPath'), 'about'); + }); + + QUnit.test('supplied QP properties can be bound', function () { + var indexController = container.lookup('controller:index'); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params foo=boundThing) id=\'the-link\'}}Index{{/link-to}}')); + + bootApplication(); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/?foo=OMG'); + _emberMetal.run(indexController, 'set', 'boundThing', 'ASL'); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?foo=ASL'); + }); + + QUnit.test('supplied QP properties can be bound (booleans)', function () { + var indexController = container.lookup('controller:index'); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params abool=boundThing) id=\'the-link\'}}Index{{/link-to}}')); + + bootApplication(); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/?abool=OMG'); + _emberMetal.run(indexController, 'set', 'boundThing', false); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?abool=false'); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + + deepEqual(indexController.getProperties('foo', 'bar', 'abool'), { foo: '123', bar: 'abc', abool: false }); + }); + + QUnit.test('href updates when unsupplied controller QP props change', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params foo=\'lol\') id=\'the-link\'}}Index{{/link-to}}')); + + bootApplication(); + var indexController = container.lookup('controller:index'); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/?foo=lol'); + _emberMetal.run(indexController, 'set', 'bar', 'BORF'); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=BORF&foo=lol'); + _emberMetal.run(indexController, 'set', 'foo', 'YEAH'); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=BORF&foo=lol'); + }); + + QUnit.test('The {{link-to}} with only query params always transitions to the current route with the query params applied', function () { + // Test harness for bug #12033 + + _emberGlimmer.setTemplate('cars', _emberTemplateCompiler.compile('\n {{#link-to \'cars.create\' id=\'create-link\'}}Create new car{{/link-to}}\n {{#link-to (query-params page=\'2\') id=\'page2-link\'}}Page 2{{/link-to}}\n {{outlet}}\n ')); + + _emberGlimmer.setTemplate('cars/create', _emberTemplateCompiler.compile('{{#link-to \'cars\' id=\'close-link\'}}Close create form{{/link-to}}')); + + Router.map(function () { + this.route('cars', function () { + this.route('create'); + }); + }); + + App.CarsController = _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1 + }); + + bootApplication(); + + var carsController = container.lookup('controller:cars'); + + _emberMetal.run(function () { + return router.handleURL('/cars/create'); + }); + + _emberMetal.run(function () { + equal(router.currentRouteName, 'cars.create'); + _emberViews.jQuery('#close-link').click(); + }); + + _emberMetal.run(function () { + equal(router.currentRouteName, 'cars.index'); + equal(router.get('url'), '/cars'); + equal(carsController.get('page'), 1, 'The page query-param is 1'); + _emberViews.jQuery('#page2-link').click(); + }); + + _emberMetal.run(function () { + equal(router.currentRouteName, 'cars.index', 'The active route is still cars'); + equal(router.get('url'), '/cars?page=2', 'The url has been updated'); + equal(carsController.get('page'), 2, 'The query params have been updated'); + }); + }); + + QUnit.test('The {{link-to}} applies activeClass when query params are not changed', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to (query-params foo=\'cat\') id=\'cat-link\'}}Index{{/link-to}}\n {{#link-to (query-params foo=\'dog\') id=\'dog-link\'}}Index{{/link-to}}\n {{#link-to \'index\' id=\'change-nothing\'}}Index{{/link-to}}\n ')); + + _emberGlimmer.setTemplate('search', _emberTemplateCompiler.compile('\n {{#link-to (query-params search=\'same\') id=\'same-search\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\') id=\'change-search\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' archive=true) id=\'same-search-add-archive\'}}Index{{/link-to}}\n {{#link-to (query-params archive=true) id=\'only-add-archive\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' archive=true) id=\'both-same\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'different\' archive=true) id=\'change-one\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'different\' archive=false) id=\'remove-one\'}}Index{{/link-to}}\n {{outlet}}\n ')); + + _emberGlimmer.setTemplate('search/results', _emberTemplateCompiler.compile('\n {{#link-to (query-params sort=\'title\') id=\'same-sort-child-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\') id=\'same-search-parent-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\') id=\'change-search-parent-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' sort=\'title\') id=\'same-search-same-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' sort=\'author\') id=\'same-search-different-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\' sort=\'title\') id=\'change-search-same-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params foo=\'dog\') id=\'dog-link\'}}Index{{/link-to}}\n ')); + + Router.map(function () { + this.route('search', function () { + this.route('results'); + }); + }); + + App.SearchController = _emberRuntime.Controller.extend({ + queryParams: ['search', 'archive'], + search: '', + archive: false + }); + + App.SearchResultsController = _emberRuntime.Controller.extend({ + queryParams: ['sort', 'showDetails'], + sort: 'title', + showDetails: true + }); + + bootApplication(); + + //Basic tests + shouldNotBeActive('#cat-link'); + shouldNotBeActive('#dog-link'); + _emberMetal.run(router, 'handleURL', '/?foo=cat'); + shouldBeActive('#cat-link'); + shouldNotBeActive('#dog-link'); + _emberMetal.run(router, 'handleURL', '/?foo=dog'); + shouldBeActive('#dog-link'); + shouldNotBeActive('#cat-link'); + shouldBeActive('#change-nothing'); + + //Multiple params + _emberMetal.run(function () { + return router.handleURL('/search?search=same'); + }); + shouldBeActive('#same-search'); + shouldNotBeActive('#change-search'); + shouldNotBeActive('#same-search-add-archive'); + shouldNotBeActive('#only-add-archive'); + shouldNotBeActive('#remove-one'); + + _emberMetal.run(function () { + return router.handleURL('/search?search=same&archive=true'); + }); + + shouldBeActive('#both-same'); + shouldNotBeActive('#change-one'); + + //Nested Controllers + _emberMetal.run(function () { + // Note: this is kind of a strange case; sort's default value is 'title', + // so this URL shouldn't have been generated in the first place, but + // we should also be able to gracefully handle these cases. + router.handleURL('/search/results?search=same&sort=title&showDetails=true'); + }); + //shouldBeActive('#same-sort-child-only'); + shouldBeActive('#same-search-parent-only'); + shouldNotBeActive('#change-search-parent-only'); + shouldBeActive('#same-search-same-sort-child-and-parent'); + shouldNotBeActive('#same-search-different-sort-child-and-parent'); + shouldNotBeActive('#change-search-same-sort-child-and-parent'); + }); + + QUnit.test('The {{link-to}} applies active class when query-param is number', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to (query-params page=pageNumber) id=\'page-link\'}}Index{{/link-to}}\n ')); + + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1, + pageNumber: 5 + }); + + bootApplication(); + + shouldNotBeActive('#page-link'); + _emberMetal.run(router, 'handleURL', '/?page=5'); + shouldBeActive('#page-link'); + }); + + QUnit.test('The {{link-to}} applies active class when query-param is array', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to (query-params pages=pagesArray) id=\'array-link\'}}Index{{/link-to}}\n {{#link-to (query-params pages=biggerArray) id=\'bigger-link\'}}Index{{/link-to}}\n {{#link-to (query-params pages=emptyArray) id=\'empty-link\'}}Index{{/link-to}}\n ')); + + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['pages'], + pages: [], + pagesArray: [1, 2], + biggerArray: [1, 2, 3], + emptyArray: [] + }); + + bootApplication(); + + shouldNotBeActive('#array-link'); + _emberMetal.run(router, 'handleURL', '/?pages=%5B1%2C2%5D'); + shouldBeActive('#array-link'); + shouldNotBeActive('#bigger-link'); + shouldNotBeActive('#empty-link'); + _emberMetal.run(router, 'handleURL', '/?pages=%5B2%2C1%5D'); + shouldNotBeActive('#array-link'); + shouldNotBeActive('#bigger-link'); + shouldNotBeActive('#empty-link'); + _emberMetal.run(router, 'handleURL', '/?pages=%5B1%2C2%2C3%5D'); + shouldBeActive('#bigger-link'); + shouldNotBeActive('#array-link'); + shouldNotBeActive('#empty-link'); + }); + + QUnit.test('The {{link-to}} helper applies active class to parent route', function () { + App.Router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{#link-to \'parent\' id=\'parent-link\'}}Parent{{/link-to}}\n {{#link-to \'parent.child\' id=\'parent-child-link\'}}Child{{/link-to}}\n {{#link-to \'parent\' (query-params foo=cat) id=\'parent-link-qp\'}}Parent{{/link-to}}\n {{outlet}}\n ')); + + App.ParentChildController = _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: 'bar' + }); + + bootApplication(); + shouldNotBeActive('#parent-link'); + shouldNotBeActive('#parent-child-link'); + shouldNotBeActive('#parent-link-qp'); + _emberMetal.run(router, 'handleURL', '/parent/child?foo=dog'); + shouldBeActive('#parent-link'); + shouldNotBeActive('#parent-link-qp'); + }); + + QUnit.test('The {{link-to}} helper disregards query-params in activeness computation when current-when specified', function () { + App.Router.map(function () { + this.route('parent'); + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{#link-to \'parent\' (query-params page=1) current-when=\'parent\' id=\'app-link\'}}Parent{{/link-to}} {{outlet}}\n ')); + _emberGlimmer.setTemplate('parent', _emberTemplateCompiler.compile('\n {{#link-to \'parent\' (query-params page=1) current-when=\'parent\' id=\'parent-link\'}}Parent{{/link-to}} {{outlet}}\n ')); + + App.ParentController = _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1 + }); + + bootApplication(); + equal(_emberViews.jQuery('#app-link').attr('href'), '/parent'); + shouldNotBeActive('#app-link'); + + _emberMetal.run(router, 'handleURL', '/parent?page=2'); + equal(_emberViews.jQuery('#app-link').attr('href'), '/parent'); + shouldBeActive('#app-link'); + equal(_emberViews.jQuery('#parent-link').attr('href'), '/parent'); + shouldBeActive('#parent-link'); + + var parentController = container.lookup('controller:parent'); + equal(parentController.get('page'), 2); + _emberMetal.run(parentController, 'set', 'page', 3); + equal(router.get('location.path'), '/parent?page=3'); + shouldBeActive('#app-link'); + shouldBeActive('#parent-link'); + + _emberViews.jQuery('#app-link').click(); + equal(router.get('location.path'), '/parent'); + }); + + QUnit.test('link-to default query params while in active transition regression test', function () { + App.Router.map(function () { + this.route('foos'); + this.route('bars'); + }); + var foos = _emberRuntime.RSVP.defer(); + var bars = _emberRuntime.RSVP.defer(); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{link-to \'Foos\' \'foos\' id=\'foos-link\'}}\n {{link-to \'Baz Foos\' \'foos\' (query-params baz=true) id=\'baz-foos-link\'}}\n {{link-to \'Quux Bars\' \'bars\' (query-params quux=true) id=\'bars-link\'}}\n ')); + + App.FoosController = _emberRuntime.Controller.extend({ + queryParams: ['status'], + baz: false + }); + + App.FoosRoute = _emberRouting.Route.extend({ + model: function () { + return foos.promise; + } + }); + + App.BarsController = _emberRuntime.Controller.extend({ + queryParams: ['status'], + quux: false + }); + + App.BarsRoute = _emberRouting.Route.extend({ + model: function () { + return bars.promise; + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#foos-link').attr('href'), '/foos'); + equal(_emberViews.jQuery('#baz-foos-link').attr('href'), '/foos?baz=true'); + equal(_emberViews.jQuery('#bars-link').attr('href'), '/bars?quux=true'); + + equal(router.get('location.path'), ''); + + shouldNotBeActive('#foos-link'); + shouldNotBeActive('#baz-foos-link'); + shouldNotBeActive('#bars-link'); + + _emberMetal.run(_emberViews.jQuery('#bars-link'), 'click'); + shouldNotBeActive('#bars-link'); + + _emberMetal.run(_emberViews.jQuery('#foos-link'), 'click'); + shouldNotBeActive('#foos-link'); + + _emberMetal.run(foos, 'resolve'); + + equal(router.get('location.path'), '/foos'); + shouldBeActive('#foos-link'); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_with_query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/link_to_test/link_to_with_query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/link_to_test/link_to_with_query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/homepage_example_test', ['exports', 'ember-routing', 'ember-metal', 'ember-application', 'ember-runtime', 'ember-template-compiler', 'ember-views', 'ember-glimmer'], function (exports, _emberRouting, _emberMetal, _emberApplication, _emberRuntime, _emberTemplateCompiler, _emberViews, _emberGlimmer) { + 'use strict'; + + var App = undefined, + $fixture = undefined; + + function setupExample() { + // setup templates + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    People

      {{#each model as |person|}}
    • Hello, {{person.fullName}}!
    • {{/each}}
    ')); + + App.Person = _emberRuntime.Object.extend({ + firstName: null, + lastName: null, + + fullName: _emberMetal.computed('firstName', 'lastName', function () { + return this.get('firstName') + ' ' + this.get('lastName'); + }) + }); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + var people = _emberRuntime.A([App.Person.create({ + firstName: 'Tom', + lastName: 'Dale' + }), App.Person.create({ + firstName: 'Yehuda', + lastName: 'Katz' + })]); + return people; + } + }); + } + + QUnit.module('Homepage Example', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + App.LoadingRoute = _emberRouting.Route.extend(); + }); + + $fixture = _emberViews.jQuery('#qunit-fixture'); + setupExample(); + }, + + teardown: function () { + _emberMetal.run(function () { + return App.destroy(); + }); + + App = null; + + _emberGlimmer.setTemplates({}); + } + }); + + QUnit.test('The example renders correctly', function () { + _emberMetal.run(App, 'advanceReadiness'); + + equal($fixture.find('h1:contains(People)').length, 1); + equal($fixture.find('li').length, 2); + equal($fixture.find('li:nth-of-type(1)').text(), 'Hello, Tom Dale!'); + equal($fixture.find('li:nth-of-type(2)').text(), 'Hello, Yehuda Katz!'); + }); +}); +enifed('ember/tests/homepage_example_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/homepage_example_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/homepage_example_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/integration/multiple-app-test', ['exports', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-glimmer', 'ember-views'], function (exports, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberGlimmer, _emberViews) { + 'use strict'; + + var App1 = undefined, + App2 = undefined, + actions = undefined; + + function startApp(rootElement) { + var application = undefined; + + _emberMetal.run(function () { + application = _emberApplication.Application.create({ + rootElement: rootElement + }); + application.deferReadiness(); + + application.Router.reopen({ + location: 'none' + }); + + var registry = application.__registry__; + + registry.register('component:special-button', _emberGlimmer.Component.extend({ + actions: { + doStuff: function () { + actions.push(rootElement); + } + } + })); + registry.register('template:application', _emberTemplateCompiler.compile('{{outlet}}', { moduleName: 'application' })); + registry.register('template:index', _emberTemplateCompiler.compile('

    Node 1

    {{special-button}}', { moduleName: 'index' })); + registry.register('template:components/special-button', _emberTemplateCompiler.compile('', { moduleName: 'components/special-button' })); + }); + + return application; + } + + function handleURL(application, path) { + var router = application.__container__.lookup('router:main'); + return _emberMetal.run(router, 'handleURL', path); + } + + QUnit.module('View Integration', { + setup: function () { + actions = []; + _emberViews.jQuery('#qunit-fixture').html('
    '); + App1 = startApp('#app-1'); + App2 = startApp('#app-2'); + }, + + teardown: function () { + _emberMetal.run(App1, 'destroy'); + _emberMetal.run(App2, 'destroy'); + App1 = App2 = null; + } + }); + + QUnit.test('booting multiple applications can properly handle events', function (assert) { + _emberMetal.run(App1, 'advanceReadiness'); + _emberMetal.run(App2, 'advanceReadiness'); + + handleURL(App1, '/'); + handleURL(App2, '/'); + + _emberViews.jQuery('#app-2 .do-stuff').click(); + _emberViews.jQuery('#app-1 .do-stuff').click(); + + assert.deepEqual(actions, ['#app-2', '#app-1']); + }); +}); +enifed('ember/tests/integration/multiple-app-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/integration/multiple-app-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/integration/multiple-app-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/reexports_test', ['exports', 'ember/index', 'internal-test-helpers', 'ember-metal'], function (exports, _emberIndex, _internalTestHelpers, _emberMetal) { + 'use strict'; + + QUnit.module('ember reexports'); + + [ + // ember-utils + ['getOwner', 'ember-utils', 'getOwner'], ['setOwner', 'ember-utils', 'setOwner'], + // ['assign', 'ember-metal'], TODO: fix this test, we use `Object.assign` if present + ['GUID_KEY', 'ember-utils'], ['uuid', 'ember-utils'], ['generateGuid', 'ember-utils'], ['guidFor', 'ember-utils'], ['inspect', 'ember-utils'], ['makeArray', 'ember-utils'], ['canInvoke', 'ember-utils'], ['tryInvoke', 'ember-utils'], ['wrap', 'ember-utils'], ['applyStr', 'ember-utils'], + + // ember-environment + // ['ENV', 'ember-environment', 'ENV'], TODO: fix this, its failing because we are hitting the getter + + // container + ['Registry', 'container', 'Registry'], ['Container', 'container', 'Container'], + + // ember-metal + ['computed', 'ember-metal'], ['computed.alias', 'ember-metal', 'alias'], ['ComputedProperty', 'ember-metal'], ['cacheFor', 'ember-metal'], ['deprecate', 'ember-metal'], ['deprecateFunc', 'ember-metal'], ['assert', 'ember-metal'], ['warn', 'ember-metal'], ['debug', 'ember-metal'], ['runInDebug', 'ember-metal'], ['merge', 'ember-metal'], ['instrument', 'ember-metal'], ['Instrumentation.instrument', 'ember-metal', 'instrument'], ['Instrumentation.subscribe', 'ember-metal', 'instrumentationSubscribe'], ['Instrumentation.unsubscribe', 'ember-metal', 'instrumentationUnsubscribe'], ['Instrumentation.reset', 'ember-metal', 'instrumentationReset'], ['testing', 'ember-metal', { get: 'isTesting', set: 'setTesting' }], ['onerror', 'ember-metal', { get: 'getOnerror', set: 'setOnerror' }], + // ['create'], TODO: figure out what to do here + // ['keys'], TODO: figure out what to do here + ['FEATURES', 'ember-metal'], ['FEATURES.isEnabled', 'ember-metal', 'isFeatureEnabled'], ['Error', 'ember-metal'], ['META_DESC', 'ember-metal'], ['meta', 'ember-metal'], ['get', 'ember-metal'], ['set', 'ember-metal'], ['_getPath', 'ember-metal'], ['getWithDefault', 'ember-metal'], ['trySet', 'ember-metal'], ['_Cache', 'ember-metal', 'Cache'], ['on', 'ember-metal'], ['addListener', 'ember-metal'], ['removeListener', 'ember-metal'], ['_suspendListener', 'ember-metal', 'suspendListener'], ['_suspendListeners', 'ember-metal', 'suspendListeners'], ['sendEvent', 'ember-metal'], ['hasListeners', 'ember-metal'], ['watchedEvents', 'ember-metal'], ['listenersFor', 'ember-metal'], ['accumulateListeners', 'ember-metal'], ['isNone', 'ember-metal'], ['isEmpty', 'ember-metal'], ['isBlank', 'ember-metal'], ['isPresent', 'ember-metal'], ['_Backburner', 'backburner', 'default'], ['run', 'ember-metal'], ['_ObserverSet', 'ember-metal', 'ObserverSet'], ['propertyWillChange', 'ember-metal'], ['propertyDidChange', 'ember-metal'], ['overrideChains', 'ember-metal'], ['beginPropertyChanges', 'ember-metal'], ['beginPropertyChanges', 'ember-metal'], ['endPropertyChanges', 'ember-metal'], ['changeProperties', 'ember-metal'], ['defineProperty', 'ember-metal'], ['watchKey', 'ember-metal'], ['unwatchKey', 'ember-metal'], ['removeChainWatcher', 'ember-metal'], ['_ChainNode', 'ember-metal', 'ChainNode'], ['finishChains', 'ember-metal'], ['watchPath', 'ember-metal'], ['unwatchPath', 'ember-metal'], ['watch', 'ember-metal'], ['isWatching', 'ember-metal'], ['unwatch', 'ember-metal'], ['destroy', 'ember-metal'], ['libraries', 'ember-metal'], ['OrderedSet', 'ember-metal'], ['Map', 'ember-metal'], ['MapWithDefault', 'ember-metal'], ['getProperties', 'ember-metal'], ['setProperties', 'ember-metal'], ['expandProperties', 'ember-metal'], ['NAME_KEY', 'ember-utils'], ['addObserver', 'ember-metal'], ['observersFor', 'ember-metal'], ['removeObserver', 'ember-metal'], ['_suspendObserver', 'ember-metal'], ['_suspendObservers', 'ember-metal'], ['required', 'ember-metal'], ['aliasMethod', 'ember-metal'], ['observer', 'ember-metal'], ['immediateObserver', 'ember-metal', '_immediateObserver'], ['mixin', 'ember-metal'], ['Mixin', 'ember-metal'], ['bind', 'ember-metal'], ['Binding', 'ember-metal'], ['isGlobalPath', 'ember-metal'], + + // ember-views + ['$', 'ember-views', 'jQuery'], ['ViewUtils.isSimpleClick', 'ember-views', 'isSimpleClick'], ['ViewUtils.getViewElement', 'ember-views', 'getViewElement'], ['ViewUtils.getViewBounds', 'ember-views', 'getViewBounds'], ['ViewUtils.getViewClientRects', 'ember-views', 'getViewClientRects'], ['ViewUtils.getViewBoundingClientRect', 'ember-views', 'getViewBoundingClientRect'], ['ViewUtils.getRootViews', 'ember-views', 'getRootViews'], ['ViewUtils.getChildViews', 'ember-views', 'getChildViews'], ['TextSupport', 'ember-views'], ['ComponentLookup', 'ember-views'], ['EventDispatcher', 'ember-views'], + + // ember-glimmer + ['Component', 'ember-glimmer', 'Component'], ['Helper', 'ember-glimmer', 'Helper'], ['Helper.helper', 'ember-glimmer', 'helper'], ['Checkbox', 'ember-glimmer', 'Checkbox'], ['LinkComponent', 'ember-glimmer', 'LinkComponent'], ['TextArea', 'ember-glimmer', 'TextArea'], ['TextField', 'ember-glimmer', 'TextField'], ['TEMPLATES', 'ember-glimmer', { get: 'getTemplates', set: 'setTemplates' }], ['Handlebars.template', 'ember-glimmer', 'template'], ['Handlebars.SafeString', 'ember-glimmer', { get: '_getSafeString' }], ['Handlebars.Utils.escapeExpression', 'ember-glimmer', 'escapeExpression'], ['String.htmlSafe', 'ember-glimmer', 'htmlSafe'], ['HTMLBars.makeBoundHelper', 'ember-glimmer', 'makeBoundHelper'], + + // ember-runtime + ['_RegistryProxyMixin', 'ember-runtime', 'RegistryProxyMixin'], ['_ContainerProxyMixin', 'ember-runtime', 'ContainerProxyMixin'], ['Object', 'ember-runtime'], ['String', 'ember-runtime'], ['compare', 'ember-runtime'], ['copy', 'ember-runtime'], ['isEqual', 'ember-runtime'], ['inject', 'ember-runtime'], ['Array', 'ember-runtime'], ['Comparable', 'ember-runtime'], ['Namespace', 'ember-runtime'], ['Enumerable', 'ember-runtime'], ['ArrayProxy', 'ember-runtime'], ['ObjectProxy', 'ember-runtime'], ['ActionHandler', 'ember-runtime'], ['CoreObject', 'ember-runtime'], ['NativeArray', 'ember-runtime'], ['Copyable', 'ember-runtime'], ['Freezable', 'ember-runtime'], ['FROZEN_ERROR', 'ember-runtime'], ['MutableEnumerable', 'ember-runtime'], ['MutableArray', 'ember-runtime'], ['TargetActionSupport', 'ember-runtime'], ['Evented', 'ember-runtime'], ['PromiseProxyMixin', 'ember-runtime'], ['Observable', 'ember-runtime'], ['typeOf', 'ember-runtime'], ['isArray', 'ember-runtime'], ['Object', 'ember-runtime'], ['onLoad', 'ember-runtime'], ['runLoadHooks', 'ember-runtime'], ['Controller', 'ember-runtime'], ['ControllerMixin', 'ember-runtime'], ['Service', 'ember-runtime'], ['_ProxyMixin', 'ember-runtime'], ['RSVP', 'ember-runtime'], ['STRINGS', 'ember-runtime', { get: 'getStrings', set: 'setStrings' }], ['BOOTED', 'ember-runtime', { get: 'isNamespaceSearchDisabled', set: 'setNamespaceSearchDisabled' }], + + // ember-routing + ['Location', 'ember-routing'], ['AutoLocation', 'ember-routing'], ['HashLocation', 'ember-routing'], ['HistoryLocation', 'ember-routing'], ['NoneLocation', 'ember-routing'], ['controllerFor', 'ember-routing'], ['generateControllerFactory', 'ember-routing'], ['generateController', 'ember-routing'], ['RouterDSL', 'ember-routing'], ['Router', 'ember-routing'], ['Route', 'ember-routing'], + + // ember-application + ['Application', 'ember-application'], ['ApplicationInstance', 'ember-application'], ['Engine', 'ember-application'], ['EngineInstance', 'ember-application'], ['Resolver', 'ember-application'], ['DefaultResolver', 'ember-application', 'Resolver'], + + // ember-extension-support + ['DataAdapter', 'ember-extension-support'], ['ContainerDebugAdapter', 'ember-extension-support']].forEach(function (reexport) { + var path = reexport[0]; + var moduleId = reexport[1]; + var exportName = reexport[2]; + + // default path === exportName if none present + if (!exportName) { + exportName = path; + } + + QUnit.test('Ember.' + path + ' exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_emberIndex.default, assert, path, moduleId, exportName); + }); + }); + + QUnit.test('Ember.String.isHTMLSafe exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_emberIndex.default, assert, 'String.isHTMLSafe', 'ember-glimmer', 'isHTMLSafe'); + }); + + if (_emberMetal.isFeatureEnabled('ember-metal-weakmap')) { + QUnit.test('Ember.WeakMap exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_emberIndex.default, assert, 'WeakMap', 'ember-metal', 'WeakMap'); + }); + } +}); +enifed('ember/tests/reexports_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/reexports_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/reexports_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/basic_test', ['exports', 'ember-utils', 'ember-console', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-glimmer', 'ember-views', 'ember-template-compiler', 'ember-application', 'router'], function (exports, _emberUtils, _emberConsole, _emberRuntime, _emberRouting, _emberMetal, _emberGlimmer, _emberViews, _emberTemplateCompiler, _emberApplication, _router) { + 'use strict'; + + var trim = _emberViews.jQuery.trim; + + var Router = undefined, + App = undefined, + router = undefined, + registry = undefined, + container = undefined, + originalLoggerError = undefined; + + function bootApplication() { + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function handleURL(path) { + return _emberMetal.run(function () { + return router.handleURL(path).then(function (value) { + ok(true, 'url: `' + path + '` was handled'); + return value; + }, function (reason) { + ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason)); + throw reason; + }); + }); + } + + function handleURLAborts(path) { + _emberMetal.run(function () { + router.handleURL(path).then(function (value) { + ok(false, 'url: `' + path + '` was NOT to be handled'); + }, function (reason) { + ok(reason && reason.message === 'TransitionAborted', 'url: `' + path + '` was to be aborted'); + }); + }); + } + + function handleURLRejectsWith(path, expectedReason) { + _emberMetal.run(function () { + router.handleURL(path).then(function (value) { + ok(false, 'expected handleURLing: `' + path + '` to fail'); + }, function (reason) { + equal(reason, expectedReason); + }); + }); + } + + QUnit.module('Basic Routing', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + Router = App.Router; + + App.LoadingRoute = _emberRouting.Route.extend({}); + + registry = App.__registry__; + container = App.__container__; + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    Hours

    ')); + _emberGlimmer.setTemplate('homepage', _emberTemplateCompiler.compile('

    Megatroll

    {{model.home}}

    ')); + _emberGlimmer.setTemplate('camelot', _emberTemplateCompiler.compile('

    Is a silly place

    ')); + + originalLoggerError = _emberConsole.default.error; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + + _emberGlimmer.setTemplates({}); + _emberConsole.default.error = originalLoggerError; + }); + } + }); + + QUnit.test('warn on URLs not included in the route set', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + bootApplication(); + + expectAssertion(function () { + return _emberMetal.run(function () { + return router.handleURL('/what-is-this-i-dont-even'); + }); + }, 'The URL \'/what-is-this-i-dont-even\' did not match any routes in your application'); + }); + + QUnit.test('The Homepage', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({}); + + var currentPath = undefined; + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + bootApplication(); + + equal(currentPath, 'home'); + equal(_emberViews.jQuery('h3:contains(Hours)', '#qunit-fixture').length, 1, 'The home template was rendered'); + }); + + QUnit.test('The Home page and the Camelot page with multiple Router.map calls', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + Router.map(function () { + this.route('camelot', { path: '/camelot' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({}); + + App.CamelotRoute = _emberRouting.Route.extend({}); + + var currentPath = undefined; + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + App.CamelotController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + bootApplication(); + + handleURL('/camelot'); + + equal(currentPath, 'camelot'); + equal(_emberViews.jQuery('h3:contains(silly)', '#qunit-fixture').length, 1, 'The camelot template was rendered'); + + handleURL('/'); + + equal(currentPath, 'home'); + equal(_emberViews.jQuery('h3:contains(Hours)', '#qunit-fixture').length, 1, 'The home template was rendered'); + }); + + QUnit.test('The Homepage with explicit template name in renderTemplate', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('homepage'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('An alternate template will pull in an alternate controller', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('homepage'); + } + }); + + App.HomepageController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from homepage' + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(Comes from homepage)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('An alternate template will pull in an alternate controller instead of controllerName', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'foo', + renderTemplate: function () { + this.render('homepage'); + } + }); + + App.FooController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from Foo' + } + }); + + App.HomepageController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from homepage' + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(Comes from homepage)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('The template will pull in an alternate controller via key/value', function () { + Router.map(function () { + this.route('homepage', { path: '/' }); + }); + + App.HomepageRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ controller: 'home' }); + } + }); + + App.HomeController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from home.' + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(Comes from home.)', '#qunit-fixture').length, 1, 'The homepage template was rendered from data from the HomeController'); + }); + + QUnit.test('The Homepage with explicit template name in renderTemplate and controller', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeController = _emberRuntime.Controller.extend({ + model: { + home: 'YES I AM HOME' + } + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('homepage'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(YES I AM HOME)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('Model passed via renderTemplate model is set as controller\'s model', function () { + _emberGlimmer.setTemplate('bio', _emberTemplateCompiler.compile('

    {{model.name}}

    ')); + + App.BioController = _emberRuntime.Controller.extend(); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('bio', { + model: { name: 'emberjs' } + }); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('p:contains(emberjs)', '#qunit-fixture').length, 1, 'Passed model was set as controllers model'); + }); + + QUnit.test('render uses templateName from route', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('the_real_home_template', _emberTemplateCompiler.compile('

    THIS IS THE REAL HOME

    ')); + + App.HomeController = _emberRuntime.Controller.extend(); + App.HomeRoute = _emberRouting.Route.extend({ + templateName: 'the_real_home_template' + }); + + bootApplication(); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'THIS IS THE REAL HOME', 'The homepage template was rendered'); + }); + + QUnit.test('defining templateName allows other templates to be rendered', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('alert', _emberTemplateCompiler.compile('
    Invader!
    ')); + _emberGlimmer.setTemplate('the_real_home_template', _emberTemplateCompiler.compile('

    THIS IS THE REAL HOME

    {{outlet \'alert\'}}')); + + App.HomeController = _emberRuntime.Controller.extend(); + App.HomeRoute = _emberRouting.Route.extend({ + templateName: 'the_real_home_template', + actions: { + showAlert: function () { + this.render('alert', { + into: 'home', + outlet: 'alert' + }); + } + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'THIS IS THE REAL HOME', 'The homepage template was rendered'); + + _emberMetal.run(function () { + return router.send('showAlert'); + }); + + equal(_emberViews.jQuery('.alert-box', '#qunit-fixture').text(), 'Invader!', 'Template for alert was render into outlet'); + }); + + QUnit.test('templateName is still used when calling render with no name and options', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('alert', _emberTemplateCompiler.compile('
    Invader!
    ')); + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    THIS IS THE REAL HOME

    {{outlet \'alert\'}}')); + + App.HomeRoute = _emberRouting.Route.extend({ + templateName: 'alert', + renderTemplate: function () { + this.render({}); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('.alert-box', '#qunit-fixture').text(), 'Invader!', 'default templateName was rendered into outlet'); + }); + + QUnit.test('The Homepage with a `setupController` hook', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + _emberMetal.set(controller, 'hours', _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm'])); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each hours as |entry|}}
    • {{entry}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context'); + }); + + QUnit.test('The route controller is still set when overriding the setupController hook', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + // no-op + // importantly, we are not calling this._super here + } + }); + + registry.register('controller:home', _emberRuntime.Controller.extend()); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:home'), 'route controller is the home controller'); + }); + + QUnit.test('The route controller can be specified via controllerName', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    {{myValue}}

    ')); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'myController' + }); + + registry.register('controller:myController', _emberRuntime.Controller.extend({ + myValue: 'foo' + })); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'foo', 'The homepage template was rendered with data from the custom controller'); + }); + + QUnit.test('The route controller specified via controllerName is used in render', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('alternative_home', _emberTemplateCompiler.compile('

    alternative home: {{myValue}}

    ')); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'myController', + renderTemplate: function () { + this.render('alternative_home'); + } + }); + + registry.register('controller:myController', _emberRuntime.Controller.extend({ + myValue: 'foo' + })); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'alternative home: foo', 'The homepage template was rendered with data from the custom controller'); + }); + + QUnit.test('The route controller specified via controllerName is used in render even when a controller with the routeName is available', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    home: {{myValue}}

    ')); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'myController' + }); + + registry.register('controller:home', _emberRuntime.Controller.extend({ + myValue: 'home' + })); + + registry.register('controller:myController', _emberRuntime.Controller.extend({ + myValue: 'myController' + })); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'home: myController', 'The homepage template was rendered with data from the custom controller'); + }); + + QUnit.test('The Homepage with a `setupController` hook modifying other controllers', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + _emberMetal.set(this.controllerFor('home'), 'hours', _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm'])); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each hours as |entry|}}
    • {{entry}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context'); + }); + + QUnit.test('The Homepage with a computed context that does not get overridden', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeController = _emberRuntime.Controller.extend({ + model: _emberMetal.computed(function () { + return _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']); + }) + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each model as |passage|}}
    • {{passage}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the context intact'); + }); + + QUnit.test('The Homepage getting its controller context via model', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']); + }, + + setupController: function (controller, model) { + equal(this.controllerFor('home'), controller); + + _emberMetal.set(this.controllerFor('home'), 'hours', model); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each hours as |entry|}}
    • {{entry}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context'); + }); + + QUnit.test('The Specials Page getting its controller context by deserializing the params hash', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + model: function (params) { + return _emberRuntime.Object.create({ + menuItemId: params.menu_item_id + }); + }, + + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.menuItemId}}

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The model was used to render the template'); + }); + + QUnit.test('The Specials Page defaults to looking models up via `find`', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + return App.MenuItem.create({ + id: id + }); + } + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The model was used to render the template'); + }); + + QUnit.test('The Special Page returning a promise puts the app into a loading state until the promise is resolved', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + var menuItem = undefined, + resolve = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + + return new _emberRuntime.RSVP.Promise(function (res) { + resolve = res; + }); + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({}); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING!

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'LOADING!', 'The app is in the loading state'); + + _emberMetal.run(function () { + return resolve(menuItem); + }); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The app is now in the specials state'); + }); + + QUnit.test('The loading state doesn\'t get entered for promises that resolve on the same run loop', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + return { id: id }; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + enter: function () { + ok(false, 'LoadingRoute shouldn\'t have been entered.'); + } + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING!

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The app is now in the specials state'); + }); + + /* + asyncTest("The Special page returning an error fires the error hook on SpecialRoute", function() { + Router.map(function() { + this.route("home", { path: "/" }); + this.route("special", { path: "/specials/:menu_item_id" }); + }); + + let menuItem; + + App.MenuItem = Ember.Object.extend(); + App.MenuItem.reopenClass({ + find: function(id) { + menuItem = App.MenuItem.create({ id: id }); + run.later(function() { menuItem.resolve(menuItem); }, 1); + return menuItem; + } + }); + + App.SpecialRoute = Route.extend({ + setup: function() { + throw 'Setup error'; + }, + actions: { + error: function(reason) { + equal(reason, 'Setup error'); + QUnit.start(); + } + } + }); + + bootApplication(); + + handleURLRejectsWith('/specials/1', 'Setup error'); + }); + */ + + QUnit.test('The Special page returning an error invokes SpecialRoute\'s error handler', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + var menuItem = undefined, + promise = undefined, + resolve = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + promise = new _emberRuntime.RSVP.Promise(function (res) { + resolve = res; + }); + + return promise; + } + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + setup: function () { + throw 'Setup error'; + }, + actions: { + error: function (reason) { + equal(reason, 'Setup error', 'SpecialRoute#error received the error thrown from setup'); + return true; + } + } + }); + + bootApplication(); + + handleURLRejectsWith('/specials/1', 'Setup error'); + + _emberMetal.run(function () { + return resolve(menuItem); + }); + }); + + var testOverridableErrorHandler = function (handlersName) { + expect(2); + + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + var menuItem = undefined, + resolve = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + return new _emberRuntime.RSVP.Promise(function (res) { + resolve = res; + }); + } + }); + + var attrs = {}; + attrs[handlersName] = { + error: function (reason) { + equal(reason, 'Setup error', 'error was correctly passed to custom ApplicationRoute handler'); + return true; + } + }; + + App.ApplicationRoute = _emberRouting.Route.extend(attrs); + + App.SpecialRoute = _emberRouting.Route.extend({ + setup: function () { + throw 'Setup error'; + } + }); + + bootApplication(); + + handleURLRejectsWith('/specials/1', 'Setup error'); + + _emberMetal.run(function () { + return resolve(menuItem); + }); + }; + + QUnit.test('ApplicationRoute\'s default error handler can be overridden', function () { + testOverridableErrorHandler('actions'); + }); + + QUnit.asyncTest('Moving from one page to another triggers the correct callbacks', function () { + expect(3); + + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.MenuItem = _emberRuntime.Object.extend(); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    Home

    ')); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + var transition = handleURL('/'); + + _emberMetal.run(function () { + transition.then(function () { + equal(_emberViews.jQuery('h3', '#qunit-fixture').text(), 'Home', 'The app is now in the initial state'); + + var promiseContext = App.MenuItem.create({ id: 1 }); + _emberMetal.run.later(function () { + return _emberRuntime.RSVP.resolve(promiseContext); + }, 1); + + return router.transitionTo('special', promiseContext); + }).then(function (result) { + deepEqual(router.location.path, '/specials/1'); + QUnit.start(); + }); + }); + }); + + QUnit.asyncTest('Nested callbacks are not exited when moving to siblings', function () { + Router.map(function () { + this.route('root', { path: '/' }, function () { + this.route('special', { path: '/specials/:menu_item_id', resetNamespace: true }); + }); + }); + + App.RootRoute = _emberRouting.Route.extend({ + model: function () { + rootModel++; + return this._super.apply(this, arguments); + }, + + setupController: function () { + rootSetup++; + }, + + renderTemplate: function () { + rootRender++; + }, + + serialize: function () { + rootSerialize++; + return this._super.apply(this, arguments); + } + }); + + var currentPath = undefined; + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + var menuItem = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + return menuItem; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({}); + + App.HomeRoute = _emberRouting.Route.extend({}); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('root/index', _emberTemplateCompiler.compile('

    Home

    ')); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING!

    ')); + + var rootSetup = 0; + var rootRender = 0; + var rootModel = 0; + var rootSerialize = 0; + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + equal(_emberViews.jQuery('h3', '#qunit-fixture').text(), 'Home', 'The app is now in the initial state'); + equal(rootSetup, 1, 'The root setup was triggered'); + equal(rootRender, 1, 'The root render was triggered'); + equal(rootSerialize, 0, 'The root serialize was not called'); + equal(rootModel, 1, 'The root model was called'); + + router = container.lookup('router:main'); + + _emberMetal.run(function () { + var menuItem = App.MenuItem.create({ id: 1 }); + _emberMetal.run.later(function () { + return _emberRuntime.RSVP.resolve(menuItem); + }, 1); + + router.transitionTo('special', menuItem).then(function (result) { + equal(rootSetup, 1, 'The root setup was not triggered again'); + equal(rootRender, 1, 'The root render was not triggered again'); + equal(rootSerialize, 0, 'The root serialize was not called'); + + // TODO: Should this be changed? + equal(rootModel, 1, 'The root model was called again'); + + deepEqual(router.location.path, '/specials/1'); + equal(currentPath, 'root.special'); + + QUnit.start(); + }); + }); + }); + + QUnit.asyncTest('Events are triggered on the controller if a matching action name is implemented', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + var model = { name: 'Tom Dale' }; + var stateIsNotCalled = true; + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return model; + }, + + actions: { + showStuff: function (obj) { + stateIsNotCalled = false; + } + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('{{name}}')); + + var controller = _emberRuntime.Controller.extend({ + actions: { + showStuff: function (context) { + ok(stateIsNotCalled, 'an event on the state is not triggered'); + deepEqual(context, { name: 'Tom Dale' }, 'an event with context is passed'); + QUnit.start(); + } + } + }); + + registry.register('controller:home', controller); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.asyncTest('Events are triggered on the current state when defined in `actions` object', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + var model = { name: 'Tom Dale' }; + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return model; + }, + + actions: { + showStuff: function (obj) { + ok(this instanceof App.HomeRoute, 'the handler is an App.HomeRoute'); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(_emberRuntime.copy(obj, true), { name: 'Tom Dale' }, 'the context is correct'); + QUnit.start(); + } + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('{{model.name}}')); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.asyncTest('Events defined in `actions` object are triggered on the current state when routes are nested', function () { + Router.map(function () { + this.route('root', { path: '/' }, function () { + this.route('index', { path: '/' }); + }); + }); + + var model = { name: 'Tom Dale' }; + + App.RootRoute = _emberRouting.Route.extend({ + actions: { + showStuff: function (obj) { + ok(this instanceof App.RootRoute, 'the handler is an App.HomeRoute'); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(_emberRuntime.copy(obj, true), { name: 'Tom Dale' }, 'the context is correct'); + QUnit.start(); + } + } + }); + + App.RootIndexRoute = _emberRouting.Route.extend({ + model: function () { + return model; + } + }); + + _emberGlimmer.setTemplate('root/index', _emberTemplateCompiler.compile('{{model.name}}')); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.test('Events can be handled by inherited event handlers', function () { + expect(4); + + App.SuperRoute = _emberRouting.Route.extend({ + actions: { + foo: function () { + ok(true, 'foo'); + }, + bar: function (msg) { + equal(msg, 'HELLO'); + } + } + }); + + App.RouteMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + App.IndexRoute = App.SuperRoute.extend(App.RouteMixin, { + actions: { + baz: function () { + ok(true, 'baz'); + } + } + }); + + bootApplication(); + + router.send('foo'); + router.send('bar', 'HELLO'); + router.send('baz'); + }); + + QUnit.asyncTest('Actions are not triggered on the controller if a matching action name is implemented as a method', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + var model = { name: 'Tom Dale' }; + var stateIsNotCalled = true; + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return model; + }, + + actions: { + showStuff: function (context) { + ok(stateIsNotCalled, 'an event on the state is not triggered'); + deepEqual(context, { name: 'Tom Dale' }, 'an event with context is passed'); + QUnit.start(); + } + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('{{name}}')); + + var controller = _emberRuntime.Controller.extend({ + showStuff: function (context) { + stateIsNotCalled = false; + ok(stateIsNotCalled, 'an event on the state is not triggered'); + } + }); + + registry.register('controller:home', controller); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.asyncTest('actions can be triggered with multiple arguments', function () { + Router.map(function () { + this.route('root', { path: '/' }, function () { + this.route('index', { path: '/' }); + }); + }); + + var model1 = { name: 'Tilde' }; + var model2 = { name: 'Tom Dale' }; + + App.RootRoute = _emberRouting.Route.extend({ + actions: { + showStuff: function (obj1, obj2) { + ok(this instanceof App.RootRoute, 'the handler is an App.HomeRoute'); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(_emberRuntime.copy(obj1, true), { name: 'Tilde' }, 'the first context is correct'); + deepEqual(_emberRuntime.copy(obj2, true), { name: 'Tom Dale' }, 'the second context is correct'); + QUnit.start(); + } + } + }); + + App.RootIndexController = _emberRuntime.Controller.extend({ + model1: model1, + model2: model2 + }); + + _emberGlimmer.setTemplate('root/index', _emberTemplateCompiler.compile('{{model1.name}}')); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.test('transitioning multiple times in a single run loop only sets the URL once', function () { + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo'); + this.route('bar'); + }); + + bootApplication(); + + var urlSetCount = 0; + + router.get('location').setURL = function (path) { + urlSetCount++; + _emberMetal.set(this, 'path', path); + }; + + equal(urlSetCount, 0); + + _emberMetal.run(function () { + router.transitionTo('foo'); + router.transitionTo('bar'); + }); + + equal(urlSetCount, 1); + equal(router.get('location').getURL(), '/bar'); + }); + + QUnit.test('navigating away triggers a url property change', function () { + expect(3); + + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo', { path: '/foo' }); + this.route('bar', { path: '/bar' }); + }); + + bootApplication(); + + _emberMetal.run(function () { + _emberMetal.addObserver(router, 'url', function () { + ok(true, 'url change event was fired'); + }); + }); + + ['foo', 'bar', '/foo'].forEach(function (destination) { + return _emberMetal.run(router, 'transitionTo', destination); + }); + }); + + QUnit.test('using replaceWith calls location.replaceURL if available', function () { + var setCount = 0; + var replaceCount = 0; + + Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + setCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo'); + }); + + bootApplication(); + + equal(setCount, 0); + equal(replaceCount, 0); + + _emberMetal.run(function () { + return router.replaceWith('foo'); + }); + + equal(setCount, 0, 'should not call setURL'); + equal(replaceCount, 1, 'should call replaceURL once'); + equal(router.get('location').getURL(), '/foo'); + }); + + QUnit.test('using replaceWith calls setURL if location.replaceURL is not defined', function () { + var setCount = 0; + + Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + setCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo'); + }); + + bootApplication(); + + equal(setCount, 0); + + _emberMetal.run(function () { + return router.replaceWith('foo'); + }); + + equal(setCount, 1, 'should call setURL once'); + equal(router.get('location').getURL(), '/foo'); + }); + + QUnit.test('Route inherits model from parent route', function () { + expect(9); + + Router.map(function () { + this.route('the_post', { path: '/posts/:post_id' }, function () { + this.route('comments'); + + this.route('shares', { path: '/shares/:share_id', resetNamespace: true }, function () { + this.route('share'); + }); + }); + }); + + var post1 = {}; + var post2 = {}; + var post3 = {}; + var share1 = {}; + var share2 = {}; + var share3 = {}; + + var posts = { + 1: post1, + 2: post2, + 3: post3 + }; + var shares = { + 1: share1, + 2: share2, + 3: share3 + }; + + App.ThePostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + App.ThePostCommentsRoute = _emberRouting.Route.extend({ + afterModel: function (post, transition) { + var parent_model = this.modelFor('thePost'); + + equal(post, parent_model); + } + }); + + App.SharesRoute = _emberRouting.Route.extend({ + model: function (params) { + return shares[params.share_id]; + } + }); + + App.SharesShareRoute = _emberRouting.Route.extend({ + afterModel: function (share, transition) { + var parent_model = this.modelFor('shares'); + + equal(share, parent_model); + } + }); + + bootApplication(); + + handleURL('/posts/1/comments'); + handleURL('/posts/1/shares/1'); + + handleURL('/posts/2/comments'); + handleURL('/posts/2/shares/2'); + + handleURL('/posts/3/comments'); + handleURL('/posts/3/shares/3'); + }); + + QUnit.test('Routes with { resetNamespace: true } inherits model from parent route', function () { + expect(6); + + Router.map(function () { + this.route('the_post', { path: '/posts/:post_id' }, function () { + this.route('comments', { resetNamespace: true }, function () {}); + }); + }); + + var post1 = {}; + var post2 = {}; + var post3 = {}; + + var posts = { + 1: post1, + 2: post2, + 3: post3 + }; + + App.ThePostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + App.CommentsRoute = _emberRouting.Route.extend({ + afterModel: function (post, transition) { + var parent_model = this.modelFor('thePost'); + + equal(post, parent_model); + } + }); + + bootApplication(); + + handleURL('/posts/1/comments'); + handleURL('/posts/2/comments'); + handleURL('/posts/3/comments'); + }); + + QUnit.test('It is possible to get the model from a parent route', function () { + expect(9); + + Router.map(function () { + this.route('the_post', { path: '/posts/:post_id' }, function () { + this.route('comments', { resetNamespace: true }); + }); + }); + + var post1 = {}; + var post2 = {}; + var post3 = {}; + var currentPost = undefined; + + var posts = { + 1: post1, + 2: post2, + 3: post3 + }; + + App.ThePostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + App.CommentsRoute = _emberRouting.Route.extend({ + model: function () { + // Allow both underscore / camelCase format. + equal(this.modelFor('thePost'), currentPost); + equal(this.modelFor('the_post'), currentPost); + } + }); + + bootApplication(); + + currentPost = post1; + handleURL('/posts/1/comments'); + + currentPost = post2; + handleURL('/posts/2/comments'); + + currentPost = post3; + handleURL('/posts/3/comments'); + }); + + QUnit.test('A redirection hook is provided', function () { + Router.map(function () { + this.route('choose', { path: '/' }); + this.route('home'); + }); + + var chooseFollowed = 0; + var destination = undefined; + + App.ChooseRoute = _emberRouting.Route.extend({ + redirect: function () { + if (destination) { + this.transitionTo(destination); + } + }, + + setupController: function () { + chooseFollowed++; + } + }); + + destination = 'home'; + + bootApplication(); + + equal(chooseFollowed, 0, 'The choose route wasn\'t entered since a transition occurred'); + equal(_emberViews.jQuery('h3:contains(Hours)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'home'); + }); + + QUnit.test('Redirecting from the middle of a route aborts the remainder of the routes', function () { + expect(3); + + Router.map(function () { + this.route('home'); + this.route('foo', function () { + this.route('bar', { resetNamespace: true }, function () { + this.route('baz'); + }); + }); + }); + + App.BarRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('home'); + }, + setupController: function () { + ok(false, 'Should transition before setupController'); + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + enter: function () { + ok(false, 'Should abort transition getting to next route'); + } + }); + + bootApplication(); + + handleURLAborts('/foo/bar/baz'); + + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'home'); + equal(router.get('location').getURL(), '/home'); + }); + + QUnit.test('Redirecting to the current target in the middle of a route does not abort initial routing', function () { + expect(5); + + Router.map(function () { + this.route('home'); + this.route('foo', function () { + this.route('bar', { resetNamespace: true }, function () { + this.route('baz'); + }); + }); + }); + + var successCount = 0; + App.BarRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('bar.baz').then(function () { + successCount++; + }); + }, + + setupController: function () { + ok(true, 'Should still invoke bar\'s setupController'); + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(true, 'Should still invoke bar.baz\'s setupController'); + } + }); + + bootApplication(); + + handleURL('/foo/bar/baz'); + + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'foo.bar.baz'); + equal(successCount, 1, 'transitionTo success handler was called once'); + }); + + QUnit.test('Redirecting to the current target with a different context aborts the remainder of the routes', function () { + expect(4); + + Router.map(function () { + this.route('home'); + this.route('foo', function () { + this.route('bar', { path: 'bar/:id', resetNamespace: true }, function () { + this.route('baz'); + }); + }); + }); + + var model = { id: 2 }; + + var count = 0; + + App.BarRoute = _emberRouting.Route.extend({ + afterModel: function (context) { + if (count++ > 10) { + ok(false, 'infinite loop'); + } else { + this.transitionTo('bar.baz', model); + } + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(true, 'Should still invoke setupController'); + } + }); + + bootApplication(); + + handleURLAborts('/foo/bar/1/baz'); + + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'foo.bar.baz'); + equal(router.get('location').getURL(), '/foo/bar/2/baz'); + }); + + QUnit.test('Transitioning from a parent event does not prevent currentPath from being set', function () { + Router.map(function () { + this.route('foo', function () { + this.route('bar', { resetNamespace: true }, function () { + this.route('baz'); + }); + this.route('qux'); + }); + }); + + App.FooRoute = _emberRouting.Route.extend({ + actions: { + goToQux: function () { + this.transitionTo('foo.qux'); + } + } + }); + + bootApplication(); + + var applicationController = _emberUtils.getOwner(router).lookup('controller:application'); + + handleURL('/foo/bar/baz'); + + equal(applicationController.get('currentPath'), 'foo.bar.baz'); + + _emberMetal.run(function () { + return router.send('goToQux'); + }); + + equal(applicationController.get('currentPath'), 'foo.qux'); + equal(router.get('location').getURL(), '/foo/qux'); + }); + + QUnit.test('Generated names can be customized when providing routes with dot notation', function () { + expect(4); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    Index
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Home

    {{outlet}}
    ')); + _emberGlimmer.setTemplate('foo', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('bar', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('bar/baz', _emberTemplateCompiler.compile('

    {{name}}Bottom!

    ')); + + Router.map(function () { + this.route('foo', { path: '/top' }, function () { + this.route('bar', { path: '/middle', resetNamespace: true }, function () { + this.route('baz', { path: '/bottom' }); + }); + }); + }); + + App.FooRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + ok(true, 'FooBarRoute was called'); + return this._super.apply(this, arguments); + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + ok(true, 'BarBazRoute was called'); + return this._super.apply(this, arguments); + } + }); + + App.BarController = _emberRuntime.Controller.extend({ + name: 'Bar' + }); + + App.BarBazController = _emberRuntime.Controller.extend({ + name: 'BarBaz' + }); + + bootApplication(); + + handleURL('/top/middle/bottom'); + + equal(_emberViews.jQuery('.main .middle .bottom p', '#qunit-fixture').text(), 'BarBazBottom!', 'The templates were rendered into their appropriate parents'); + }); + + QUnit.test('Child routes render into their parent route\'s template by default', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    Index
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Home

    {{outlet}}
    ')); + _emberGlimmer.setTemplate('top', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle/bottom', _emberTemplateCompiler.compile('

    Bottom!

    ')); + + Router.map(function () { + this.route('top', function () { + this.route('middle', { resetNamespace: true }, function () { + this.route('bottom'); + }); + }); + }); + + bootApplication(); + + handleURL('/top/middle/bottom'); + + equal(_emberViews.jQuery('.main .middle .bottom p', '#qunit-fixture').text(), 'Bottom!', 'The templates were rendered into their appropriate parents'); + }); + + QUnit.test('Child routes render into specified template', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    Index
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Home

    {{outlet}}
    ')); + _emberGlimmer.setTemplate('top', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle/bottom', _emberTemplateCompiler.compile('

    Bottom!

    ')); + + Router.map(function () { + this.route('top', function () { + this.route('middle', { resetNamespace: true }, function () { + this.route('bottom'); + }); + }); + }); + + App.MiddleBottomRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('middle/bottom', { into: 'top' }); + } + }); + + bootApplication(); + + handleURL('/top/middle/bottom'); + + equal(_emberViews.jQuery('.main .middle .bottom p', '#qunit-fixture').length, 0, 'should not render into the middle template'); + equal(_emberViews.jQuery('.main .middle > p', '#qunit-fixture').text(), 'Bottom!', 'The template was rendered into the top template'); + }); + + QUnit.test('Rendering into specified template with slash notation', function () { + _emberGlimmer.setTemplate('person/profile', _emberTemplateCompiler.compile('profile {{outlet}}')); + _emberGlimmer.setTemplate('person/details', _emberTemplateCompiler.compile('details!')); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('person/profile'); + this.render('person/details', { into: 'person/profile' }); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture:contains(profile details!)').length, 1, 'The templates were rendered'); + }); + + QUnit.test('Parent route context change', function () { + var editCount = 0; + var editedPostIds = _emberRuntime.A(); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('post', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('post/index', _emberTemplateCompiler.compile('showing')); + _emberGlimmer.setTemplate('post/edit', _emberTemplateCompiler.compile('editing')); + + Router.map(function () { + this.route('posts', function () { + this.route('post', { path: '/:postId', resetNamespace: true }, function () { + this.route('edit'); + }); + }); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + showPost: function (context) { + this.transitionTo('post', context); + } + } + }); + + App.PostRoute = _emberRouting.Route.extend({ + model: function (params) { + return { id: params.postId }; + }, + + serialize: function (model) { + return { postId: model.id }; + }, + + actions: { + editPost: function (context) { + this.transitionTo('post.edit'); + } + } + }); + + App.PostEditRoute = _emberRouting.Route.extend({ + model: function (params) { + var postId = this.modelFor('post').id; + editedPostIds.push(postId); + return null; + }, + setup: function () { + this._super.apply(this, arguments); + editCount++; + } + }); + + bootApplication(); + + handleURL('/posts/1'); + + _emberMetal.run(function () { + return router.send('editPost'); + }); + _emberMetal.run(function () { + return router.send('showPost', { id: '2' }); + }); + _emberMetal.run(function () { + return router.send('editPost'); + }); + + equal(editCount, 2, 'set up the edit route twice without failure'); + deepEqual(editedPostIds, ['1', '2'], 'modelFor posts.post returns the right context'); + }); + + QUnit.test('Router accounts for rootURL on page load when using history location', function () { + var rootURL = window.location.pathname + '/app'; + var postsTemplateRendered = false; + var setHistory = undefined, + HistoryTestLocation = undefined; + + setHistory = function (obj, path) { + obj.set('history', { state: { path: path } }); + }; + + // Create new implementation that extends HistoryLocation + // and set current location to rootURL + '/posts' + HistoryTestLocation = _emberRouting.HistoryLocation.extend({ + initState: function () { + var path = rootURL + '/posts'; + + setHistory(this, path); + this.set('location', { + pathname: path, + href: 'http://localhost/' + path + }); + }, + + replaceState: function (path) { + setHistory(this, path); + }, + + pushState: function (path) { + setHistory(this, path); + } + }); + + registry.register('location:historyTest', HistoryTestLocation); + + Router.reopen({ + location: 'historyTest', + rootURL: rootURL + }); + + Router.map(function () { + this.route('posts', { path: '/posts' }); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + model: function () {}, + renderTemplate: function () { + postsTemplateRendered = true; + } + }); + + bootApplication(); + + ok(postsTemplateRendered, 'Posts route successfully stripped from rootURL'); + }); + + QUnit.test('The rootURL is passed properly to the location implementation', function () { + expect(1); + var rootURL = '/blahzorz'; + var HistoryTestLocation = undefined; + + HistoryTestLocation = _emberRouting.HistoryLocation.extend({ + rootURL: 'this is not the URL you are looking for', + initState: function () { + equal(this.get('rootURL'), rootURL); + } + }); + + registry.register('location:history-test', HistoryTestLocation); + + Router.reopen({ + location: 'history-test', + rootURL: rootURL, + // if we transition in this test we will receive failures + // if the tests are run from a static file + _doURLTransition: function () {} + }); + + bootApplication(); + }); + + QUnit.test('Only use route rendered into main outlet for default into property on child', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet \'menu\'}}{{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('

    postsIndex

    ')); + _emberGlimmer.setTemplate('posts/menu', _emberTemplateCompiler.compile('
    postsMenu
    ')); + + Router.map(function () { + this.route('posts', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('posts/menu', { + into: 'application', + outlet: 'menu' + }); + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, 'The posts/menu template was rendered'); + equal(_emberViews.jQuery('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + }); + + QUnit.test('Generating a URL should not affect currentModel', function () { + Router.map(function () { + this.route('post', { path: '/posts/:post_id' }); + }); + + var posts = { + 1: { id: 1 }, + 2: { id: 2 } + }; + + App.PostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + bootApplication(); + + handleURL('/posts/1'); + + var route = container.lookup('route:post'); + equal(route.modelFor('post'), posts[1]); + + var url = router.generate('post', posts[2]); + equal(url, '/posts/2'); + + equal(route.modelFor('post'), posts[1]); + }); + + QUnit.test('Generated route should be an instance of App.Route if provided', function () { + var generatedRoute = undefined; + + Router.map(function () { + this.route('posts'); + }); + + App.Route = _emberRouting.Route.extend(); + + bootApplication(); + + handleURL('/posts'); + + generatedRoute = container.lookup('route:posts'); + + ok(generatedRoute instanceof App.Route, 'should extend the correct route'); + }); + + QUnit.test('Nested index route is not overriden by parent\'s implicit index route', function () { + Router.map(function () { + this.route('posts', function () { + this.route('index', { path: ':category' }); + }); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.transitionTo('posts', { category: 'emberjs' }); + }); + + deepEqual(router.location.path, '/posts/emberjs'); + }); + + QUnit.test('Application template does not duplicate when re-rendered', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    I Render Once

    {{outlet}}')); + + Router.map(function () { + this.route('posts'); + }); + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A(); + } + }); + + bootApplication(); + + // should cause application template to re-render + handleURL('/posts'); + + equal(_emberViews.jQuery('h3:contains(I Render Once)').length, 1); + }); + + QUnit.test('Child routes should render inside the application template if the application template causes a redirect', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    App

    {{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('posts')); + + Router.map(function () { + this.route('posts'); + this.route('photos'); + }); + + App.ApplicationRoute = _emberRouting.Route.extend({ + afterModel: function () { + this.transitionTo('posts'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture > div').text(), 'App posts'); + }); + + QUnit.test('The template is not re-rendered when the route\'s context changes', function () { + Router.map(function () { + this.route('page', { path: '/page/:name' }); + }); + + App.PageRoute = _emberRouting.Route.extend({ + model: function (params) { + return _emberRuntime.Object.create({ name: params.name }); + } + }); + + var insertionCount = 0; + App.FooBarComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + insertionCount += 1; + } + }); + + _emberGlimmer.setTemplate('page', _emberTemplateCompiler.compile('

    {{model.name}}{{foo-bar}}

    ')); + + bootApplication(); + + handleURL('/page/first'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'first'); + equal(insertionCount, 1); + + handleURL('/page/second'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'second'); + equal(insertionCount, 1, 'view should have inserted only once'); + + _emberMetal.run(function () { + return router.transitionTo('page', _emberRuntime.Object.create({ name: 'third' })); + }); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'third'); + equal(insertionCount, 1, 'view should still have inserted only once'); + }); + + QUnit.test('The template is not re-rendered when two routes present the exact same template & controller', function () { + Router.map(function () { + this.route('first'); + this.route('second'); + this.route('third'); + this.route('fourth'); + }); + + // Note add a component to test insertion + + var insertionCount = 0; + App.XInputComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + insertionCount += 1; + } + }); + + App.SharedRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + this.controllerFor('shared').set('message', 'This is the ' + this.routeName + ' message'); + }, + + renderTemplate: function (controller, context) { + this.render('shared', { controller: 'shared' }); + } + }); + + App.FirstRoute = App.SharedRoute.extend(); + App.SecondRoute = App.SharedRoute.extend(); + App.ThirdRoute = App.SharedRoute.extend(); + App.FourthRoute = App.SharedRoute.extend(); + + App.SharedController = _emberRuntime.Controller.extend(); + + _emberGlimmer.setTemplate('shared', _emberTemplateCompiler.compile('

    {{message}}{{x-input}}

    ')); + + bootApplication(); + + handleURL('/first'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the first message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Transition by URL + handleURL('/second'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the second message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Then transition directly by route name + _emberMetal.run(function () { + router.transitionTo('third').then(function (value) { + ok(true, 'expected transition'); + }, function (reason) { + ok(false, 'unexpected transition failure: ', QUnit.jsDump.parse(reason)); + }); + }); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the third message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Lastly transition to a different view, with the same controller and template + handleURL('/fourth'); + equal(insertionCount, 1, 'expected one assertion'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the fourth message'); + }); + + QUnit.test('ApplicationRoute with model does not proxy the currentPath', function () { + var model = {}; + var currentPath = undefined; + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return model; + } + }); + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + bootApplication(); + + equal(currentPath, 'index', 'currentPath is index'); + equal('currentPath' in model, false, 'should have defined currentPath on controller'); + }); + + QUnit.test('Promises encountered on app load put app into loading state until resolved', function () { + expect(2); + + var deferred = _emberRuntime.RSVP.defer(); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    INDEX

    ')); + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING

    ')); + + bootApplication(); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'LOADING', 'The loading state is displaying.'); + _emberMetal.run(deferred.resolve); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'INDEX', 'The index route is display.'); + }); + + QUnit.test('Route should tear down multiple outlets', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet \'menu\'}}{{outlet}}{{outlet \'footer\'}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('users', _emberTemplateCompiler.compile('users')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('

    postsIndex

    ')); + _emberGlimmer.setTemplate('posts/menu', _emberTemplateCompiler.compile('
    postsMenu
    ')); + _emberGlimmer.setTemplate('posts/footer', _emberTemplateCompiler.compile('')); + + Router.map(function () { + this.route('posts', function () {}); + this.route('users', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('posts/menu', { + into: 'application', + outlet: 'menu' + }); + + this.render(); + + this.render('posts/footer', { + into: 'application', + outlet: 'footer' + }); + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, 'The posts/menu template was rendered'); + equal(_emberViews.jQuery('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + equal(_emberViews.jQuery('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 1, 'The posts/footer template was rendered'); + + handleURL('/users'); + + equal(_emberViews.jQuery('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 0, 'The posts/menu template was removed'); + equal(_emberViews.jQuery('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, 'The posts/index template was removed'); + equal(_emberViews.jQuery('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 0, 'The posts/footer template was removed'); + }); + + QUnit.test('Route will assert if you try to explicitly render {into: ...} a missing template', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'nonexistent' }); + } + }); + + expectAssertion(function () { + return bootApplication(); + }, 'You attempted to render into \'nonexistent\' but it was not found'); + }); + + QUnit.test('Route supports clearing outlet explicitly', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet \'modal\'}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('users', _emberTemplateCompiler.compile('users')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('
    postsIndex {{outlet}}
    ')); + _emberGlimmer.setTemplate('posts/modal', _emberTemplateCompiler.compile('
    postsModal
    ')); + _emberGlimmer.setTemplate('posts/extra', _emberTemplateCompiler.compile('
    postsExtra
    ')); + + Router.map(function () { + this.route('posts', function () {}); + this.route('users', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + showModal: function () { + this.render('posts/modal', { + into: 'application', + outlet: 'modal' + }); + }, + hideModal: function () { + this.disconnectOutlet({ outlet: 'modal', parentView: 'application' }); + } + } + }); + + App.PostsIndexRoute = _emberRouting.Route.extend({ + actions: { + showExtra: function () { + this.render('posts/extra', { + into: 'posts/index' + }); + }, + hideExtra: function () { + this.disconnectOutlet({ parentView: 'posts/index' }); + } + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + + _emberMetal.run(function () { + return router.send('showModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); + + _emberMetal.run(function () { + return router.send('showExtra'); + }); + + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 1, 'The posts/extra template was rendered'); + + _emberMetal.run(function () { + return router.send('hideModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + + _emberMetal.run(function () { + return router.send('hideExtra'); + }); + + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, 'The posts/extra template was removed'); + _emberMetal.run(function () { + router.send('showModal'); + }); + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); + _emberMetal.run(function () { + router.send('showExtra'); + }); + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 1, 'The posts/extra template was rendered'); + + handleURL('/users'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, 'The posts/index template was removed'); + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, 'The posts/extra template was removed'); + }); + + QUnit.test('Route supports clearing outlet using string parameter', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet \'modal\'}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('users', _emberTemplateCompiler.compile('users')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('
    postsIndex {{outlet}}
    ')); + _emberGlimmer.setTemplate('posts/modal', _emberTemplateCompiler.compile('
    postsModal
    ')); + + Router.map(function () { + this.route('posts', function () {}); + this.route('users', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + showModal: function () { + this.render('posts/modal', { + into: 'application', + outlet: 'modal' + }); + }, + hideModal: function () { + this.disconnectOutlet('modal'); + } + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + + _emberMetal.run(function () { + return router.send('showModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); + + _emberMetal.run(function () { + return router.send('hideModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + + handleURL('/users'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, 'The posts/index template was removed'); + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + }); + + QUnit.test('Route silently fails when cleaning an outlet from an inactive view', function () { + expect(1); // handleURL + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet \'modal\'}}')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('A Yo.')); + + Router.map(function () { + this.route('posts'); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + hideSelf: function () { + this.disconnectOutlet({ outlet: 'main', parentView: 'application' }); + }, + showModal: function () { + this.render('modal', { into: 'posts', outlet: 'modal' }); + }, + hideModal: function () { + this.disconnectOutlet({ outlet: 'modal', parentView: 'posts' }); + } + } + }); + + bootApplication(); + + handleURL('/posts'); + + _emberMetal.run(function () { + return router.send('showModal'); + }); + _emberMetal.run(function () { + return router.send('hideSelf'); + }); + _emberMetal.run(function () { + return router.send('hideModal'); + }); + }); + + QUnit.test('Router `willTransition` hook passes in cancellable transition', function () { + // Should hit willTransition 3 times, once for the initial route, and then 2 more times + // for the two handleURL calls below + expect(3); + + Router.map(function () { + this.route('nork'); + this.route('about'); + }); + + Router.reopen({ + init: function () { + this._super(); + this.on('willTransition', this.testWillTransitionHook); + }, + testWillTransitionHook: function (transition, url) { + ok(true, 'willTransition was called ' + url); + transition.abort(); + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + activate: function () { + ok(false, 'LoadingRoute was not entered'); + } + }); + + App.NorkRoute = _emberRouting.Route.extend({ + activate: function () { + ok(false, 'NorkRoute was not entered'); + } + }); + + App.AboutRoute = _emberRouting.Route.extend({ + activate: function () { + ok(false, 'AboutRoute was not entered'); + } + }); + + bootApplication(); + + // Attempted transitions out of index should abort. + _emberMetal.run(router, 'handleURL', '/nork'); + _emberMetal.run(router, 'handleURL', '/about'); + }); + + QUnit.test('Aborting/redirecting the transition in `willTransition` prevents LoadingRoute from being entered', function () { + expect(8); + + Router.map(function () { + this.route('nork'); + this.route('about'); + }); + + var redirect = false; + + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + willTransition: function (transition) { + ok(true, 'willTransition was called'); + if (redirect) { + // router.js won't refire `willTransition` for this redirect + this.transitionTo('about'); + } else { + transition.abort(); + } + } + } + }); + + var deferred = null; + + App.LoadingRoute = _emberRouting.Route.extend({ + activate: function () { + ok(deferred, 'LoadingRoute should be entered at this time'); + }, + deactivate: function () { + ok(true, 'LoadingRoute was exited'); + } + }); + + App.NorkRoute = _emberRouting.Route.extend({ + activate: function () { + ok(true, 'NorkRoute was entered'); + } + }); + + App.AboutRoute = _emberRouting.Route.extend({ + activate: function () { + ok(true, 'AboutRoute was entered'); + }, + model: function () { + if (deferred) { + return deferred.promise; + } + } + }); + + bootApplication(); + + // Attempted transitions out of index should abort. + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(router, 'handleURL', '/nork'); + + // Attempted transitions out of index should redirect to about + redirect = true; + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(router, 'transitionTo', 'index'); + + // Redirected transitions out of index to a route with a + // promise model should pause the transition and + // activate LoadingRoute + deferred = _emberRuntime.RSVP.defer(); + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(deferred.resolve); + }); + + QUnit.test('`didTransition` event fires on the router', function () { + expect(3); + + Router.map(function () { + this.route('nork'); + }); + + router = container.lookup('router:main'); + + router.one('didTransition', function () { + ok(true, 'didTransition fired on initial routing'); + }); + + bootApplication(); + + router.one('didTransition', function () { + ok(true, 'didTransition fired on the router'); + equal(router.get('url'), '/nork', 'The url property is updated by the time didTransition fires'); + }); + + _emberMetal.run(router, 'transitionTo', 'nork'); + }); + QUnit.test('`didTransition` can be reopened', function () { + expect(1); + + Router.map(function () { + this.route('nork'); + }); + + Router.reopen({ + didTransition: function () { + this._super.apply(this, arguments); + ok(true, 'reopened didTransition was called'); + } + }); + + bootApplication(); + }); + + QUnit.test('`activate` event fires on the route', function () { + expect(2); + + var eventFired = 0; + + Router.map(function () { + this.route('nork'); + }); + + App.NorkRoute = _emberRouting.Route.extend({ + init: function () { + this._super.apply(this, arguments); + + this.on('activate', function () { + equal(++eventFired, 1, 'activate event is fired once'); + }); + }, + + activate: function () { + ok(true, 'activate hook is called'); + } + }); + + bootApplication(); + + _emberMetal.run(router, 'transitionTo', 'nork'); + }); + + QUnit.test('`deactivate` event fires on the route', function () { + expect(2); + + var eventFired = 0; + + Router.map(function () { + this.route('nork'); + this.route('dork'); + }); + + App.NorkRoute = _emberRouting.Route.extend({ + init: function () { + this._super.apply(this, arguments); + + this.on('deactivate', function () { + equal(++eventFired, 1, 'deactivate event is fired once'); + }); + }, + + deactivate: function () { + ok(true, 'deactivate hook is called'); + } + }); + + bootApplication(); + + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(router, 'transitionTo', 'dork'); + }); + + QUnit.test('Actions can be handled by inherited action handlers', function () { + expect(4); + + App.SuperRoute = _emberRouting.Route.extend({ + actions: { + foo: function () { + ok(true, 'foo'); + }, + bar: function (msg) { + equal(msg, 'HELLO'); + } + } + }); + + App.RouteMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + App.IndexRoute = App.SuperRoute.extend(App.RouteMixin, { + actions: { + baz: function () { + ok(true, 'baz'); + } + } + }); + + bootApplication(); + + router.send('foo'); + router.send('bar', 'HELLO'); + router.send('baz'); + }); + + QUnit.test('transitionTo returns Transition when passed a route name', function () { + expect(1); + Router.map(function () { + this.route('root', { path: '/' }); + this.route('bar'); + }); + + bootApplication(); + + var transition = _emberMetal.run(function () { + return router.transitionTo('bar'); + }); + + equal(transition instanceof _router.Transition, true); + }); + + QUnit.test('transitionTo returns Transition when passed a url', function () { + expect(1); + Router.map(function () { + this.route('root', { path: '/' }); + this.route('bar', function () { + this.route('baz'); + }); + }); + + bootApplication(); + + var transition = _emberMetal.run(function () { + return router.transitionTo('/bar/baz'); + }); + + equal(transition instanceof _router.Transition, true); + }); + + QUnit.test('currentRouteName is a property installed on ApplicationController that can be used in transitionTo', function () { + expect(24); + + Router.map(function () { + this.route('be', function () { + this.route('excellent', { resetNamespace: true }, function () { + this.route('to', { resetNamespace: true }, function () { + this.route('each', { resetNamespace: true }, function () { + this.route('other'); + }); + }); + }); + }); + }); + + bootApplication(); + + var appController = _emberUtils.getOwner(router).lookup('controller:application'); + + function transitionAndCheck(path, expectedPath, expectedRouteName) { + if (path) { + _emberMetal.run(router, 'transitionTo', path); + } + equal(appController.get('currentPath'), expectedPath); + equal(appController.get('currentRouteName'), expectedRouteName); + } + + transitionAndCheck(null, 'index', 'index'); + transitionAndCheck('/be', 'be.index', 'be.index'); + transitionAndCheck('/be/excellent', 'be.excellent.index', 'excellent.index'); + transitionAndCheck('/be/excellent/to', 'be.excellent.to.index', 'to.index'); + transitionAndCheck('/be/excellent/to/each', 'be.excellent.to.each.index', 'each.index'); + transitionAndCheck('/be/excellent/to/each/other', 'be.excellent.to.each.other', 'each.other'); + + transitionAndCheck('index', 'index', 'index'); + transitionAndCheck('be', 'be.index', 'be.index'); + transitionAndCheck('excellent', 'be.excellent.index', 'excellent.index'); + transitionAndCheck('to.index', 'be.excellent.to.index', 'to.index'); + transitionAndCheck('each', 'be.excellent.to.each.index', 'each.index'); + transitionAndCheck('each.other', 'be.excellent.to.each.other', 'each.other'); + }); + + QUnit.test('Route model hook finds the same model as a manual find', function () { + var Post = undefined; + App.Post = _emberRuntime.Object.extend(); + App.Post.reopenClass({ + find: function () { + Post = this; + return {}; + } + }); + + Router.map(function () { + this.route('post', { path: '/post/:post_id' }); + }); + + bootApplication(); + + handleURL('/post/1'); + + equal(App.Post, Post); + }); + + QUnit.test('Routes can refresh themselves causing their model hooks to be re-run', function () { + Router.map(function () { + this.route('parent', { path: '/parent/:parent_id' }, function () { + this.route('child'); + }); + }); + + var appcount = 0; + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + ++appcount; + } + }); + + var parentcount = 0; + App.ParentRoute = _emberRouting.Route.extend({ + model: function (params) { + equal(params.parent_id, '123'); + ++parentcount; + }, + actions: { + refreshParent: function () { + this.refresh(); + } + } + }); + + var childcount = 0; + App.ParentChildRoute = _emberRouting.Route.extend({ + model: function () { + ++childcount; + } + }); + + bootApplication(); + + equal(appcount, 1); + equal(parentcount, 0); + equal(childcount, 0); + + _emberMetal.run(router, 'transitionTo', 'parent.child', '123'); + + equal(appcount, 1); + equal(parentcount, 1); + equal(childcount, 1); + + _emberMetal.run(router, 'send', 'refreshParent'); + + equal(appcount, 1); + equal(parentcount, 2); + equal(childcount, 2); + }); + + QUnit.test('Specifying non-existent controller name in route#render throws', function () { + expect(1); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + try { + this.render('homepage', { controller: 'stefanpenneristhemanforme' }); + } catch (e) { + equal(e.message, 'You passed `controller: \'stefanpenneristhemanforme\'` into the `render` method, but no such controller could be found.'); + } + } + }); + + bootApplication(); + }); + + QUnit.test('Redirecting with null model doesn\'t error out', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('about', { path: '/about/:hurhurhur' }); + }); + + App.AboutRoute = _emberRouting.Route.extend({ + serialize: function (model) { + if (model === null) { + return { hurhurhur: 'TreeklesMcGeekles' }; + } + } + }); + + App.HomeRoute = _emberRouting.Route.extend({ + beforeModel: function () { + this.transitionTo('about', null); + } + }); + + bootApplication(); + + equal(router.get('location.path'), '/about/TreeklesMcGeekles'); + }); + + QUnit.test('rejecting the model hooks promise with a non-error prints the `message` property', function () { + expect(5); + + var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; + var rejectedStack = 'Yeah, buddy: stack gets printed too.'; + + Router.map(function () { + this.route('yippie', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage, errorMessage, errorStack) { + equal(initialMessage, 'Error while processing route: yippie', 'a message with the current route name is printed'); + equal(errorMessage, rejectedMessage, 'the rejected reason\'s message property is logged'); + equal(errorStack, rejectedStack, 'the rejected reason\'s stack property is logged'); + }; + + App.YippieRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ message: rejectedMessage, stack: rejectedStack }); + } + }); + + throws(function () { + bootApplication(); + }, function (err) { + equal(err.message, rejectedMessage); + return true; + }, 'expected an exception'); + }); + + QUnit.test('rejecting the model hooks promise with an error with `errorThrown` property prints `errorThrown.message` property', function () { + expect(5); + var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; + var rejectedStack = 'Yeah, buddy: stack gets printed too.'; + + Router.map(function () { + this.route('yippie', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage, errorMessage, errorStack) { + equal(initialMessage, 'Error while processing route: yippie', 'a message with the current route name is printed'); + equal(errorMessage, rejectedMessage, 'the rejected reason\'s message property is logged'); + equal(errorStack, rejectedStack, 'the rejected reason\'s stack property is logged'); + }; + + App.YippieRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ + errorThrown: { message: rejectedMessage, stack: rejectedStack } + }); + } + }); + + throws(function () { + return bootApplication(); + }, function (err) { + equal(err.message, rejectedMessage); + return true; + }, 'expected an exception'); + }); + + QUnit.test('rejecting the model hooks promise with no reason still logs error', function () { + Router.map(function () { + this.route('wowzers', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage) { + equal(initialMessage, 'Error while processing route: wowzers', 'a message with the current route name is printed'); + }; + + App.WowzersRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(); + } + }); + + bootApplication(); + }); + + QUnit.test('rejecting the model hooks promise with a string shows a good error', function () { + expect(3); + var originalLoggerError = _emberConsole.default.error; + var rejectedMessage = 'Supercalifragilisticexpialidocious'; + + Router.map(function () { + this.route('yondo', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage, errorMessage) { + equal(initialMessage, 'Error while processing route: yondo', 'a message with the current route name is printed'); + equal(errorMessage, rejectedMessage, 'the rejected reason\'s message property is logged'); + }; + + App.YondoRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(rejectedMessage); + } + }); + + throws(function () { + return bootApplication(); + }, rejectedMessage, 'expected an exception'); + + _emberConsole.default.error = originalLoggerError; + }); + + QUnit.test('willLeave, willChangeContext, willChangeModel actions don\'t fire unless feature flag enabled', function () { + expect(1); + + App.Router.map(function () { + this.route('about'); + }); + + function shouldNotFire() { + ok(false, 'this action shouldn\'t have been received'); + } + + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + willChangeModel: shouldNotFire, + willChangeContext: shouldNotFire, + willLeave: shouldNotFire + } + }); + + App.AboutRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(true, 'about route was entered'); + } + }); + + bootApplication(); + _emberMetal.run(router, 'transitionTo', 'about'); + }); + + QUnit.test('Errors in transitionTo within redirect hook are logged', function () { + expect(4); + var actual = []; + + Router.map(function () { + this.route('yondo', { path: '/' }); + this.route('stink-bomb'); + }); + + App.YondoRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('stink-bomb', { something: 'goes boom' }); + } + }); + + _emberConsole.default.error = function () { + // push the arguments onto an array so we can detect if the error gets logged twice + actual.push(arguments); + }; + + throws(function () { + return bootApplication(); + }, /More context objects were passed/); + + equal(actual.length, 1, 'the error is only logged once'); + equal(actual[0][0], 'Error while processing route: yondo', 'source route is printed'); + ok(actual[0][1].match(/More context objects were passed than there are dynamic segments for the route: stink-bomb/), 'the error is printed'); + }); + + QUnit.test('Errors in transition show error template if available', function () { + _emberGlimmer.setTemplate('error', _emberTemplateCompiler.compile('
    Error!
    ')); + + Router.map(function () { + this.route('yondo', { path: '/' }); + this.route('stink-bomb'); + }); + + App.YondoRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('stink-bomb', { something: 'goes boom' }); + } + }); + + throws(function () { + return bootApplication(); + }, /More context objects were passed/); + + equal(_emberViews.jQuery('#error').length, 1, 'Error template was rendered.'); + }); + + QUnit.test('Route#resetController gets fired when changing models and exiting routes', function () { + expect(4); + + Router.map(function () { + this.route('a', function () { + this.route('b', { path: '/b/:id', resetNamespace: true }, function () {}); + this.route('c', { path: '/c/:id', resetNamespace: true }, function () {}); + }); + this.route('out'); + }); + + var calls = []; + + var SpyRoute = _emberRouting.Route.extend({ + setupController: function (controller, model, transition) { + calls.push(['setup', this.routeName]); + }, + + resetController: function (controller) { + calls.push(['reset', this.routeName]); + } + }); + + App.ARoute = SpyRoute.extend(); + App.BRoute = SpyRoute.extend(); + App.CRoute = SpyRoute.extend(); + App.OutRoute = SpyRoute.extend(); + + bootApplication(); + deepEqual(calls, []); + + _emberMetal.run(router, 'transitionTo', 'b', 'b-1'); + deepEqual(calls, [['setup', 'a'], ['setup', 'b']]); + calls.length = 0; + + _emberMetal.run(router, 'transitionTo', 'c', 'c-1'); + deepEqual(calls, [['reset', 'b'], ['setup', 'c']]); + calls.length = 0; + + _emberMetal.run(router, 'transitionTo', 'out'); + deepEqual(calls, [['reset', 'c'], ['reset', 'a'], ['setup', 'out']]); + }); + + QUnit.test('Exception during initialization of non-initial route is not swallowed', function () { + Router.map(function () { + this.route('boom'); + }); + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + bootApplication(); + throws(function () { + return _emberMetal.run(router, 'transitionTo', 'boom'); + }, /\bboom\b/); + }); + + QUnit.test('Exception during load of non-initial route is not swallowed', function () { + Router.map(function () { + this.route('boom'); + }); + var lookup = container.lookup; + container.lookup = function () { + if (arguments[0] === 'route:boom') { + throw new Error('boom!'); + } + return lookup.apply(this, arguments); + }; + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + bootApplication(); + throws(function () { + return _emberMetal.run(router, 'transitionTo', 'boom'); + }); + }); + + QUnit.test('Exception during initialization of initial route is not swallowed', function () { + Router.map(function () { + this.route('boom', { path: '/' }); + }); + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + throws(function () { + return bootApplication(); + }, /\bboom\b/); + }); + + QUnit.test('Exception during load of initial route is not swallowed', function () { + Router.map(function () { + this.route('boom', { path: '/' }); + }); + var lookup = container.lookup; + container.lookup = function () { + if (arguments[0] === 'route:boom') { + throw new Error('boom!'); + } + return lookup.apply(this, arguments); + }; + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + throws(function () { + return bootApplication(); + }, /\bboom\b/); + }); + + QUnit.test('{{outlet}} works when created after initial render', function () { + _emberGlimmer.setTemplate('sample', _emberTemplateCompiler.compile('Hi{{#if showTheThing}}{{outlet}}{{/if}}Bye')); + _emberGlimmer.setTemplate('sample/inner', _emberTemplateCompiler.compile('Yay')); + _emberGlimmer.setTemplate('sample/inner2', _emberTemplateCompiler.compile('Boo')); + Router.map(function () { + this.route('sample', { path: '/' }, function () { + this.route('inner', { path: '/' }); + this.route('inner2', { path: '/2' }); + }); + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'HiBye', 'initial render'); + + _emberMetal.run(function () { + return container.lookup('controller:sample').set('showTheThing', true); + }); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'HiYayBye', 'second render'); + + handleURL('/2'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'HiBooBye', 'third render'); + }); + + QUnit.test('Can render into a named outlet at the top level', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('The index')); + + registry.register('route:application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('modal', { + into: 'application', + outlet: 'other' + }); + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B-Hello world-C', 'initial render'); + }); + + QUnit.test('Can disconnect a named outlet at the top level', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('The index')); + + registry.register('route:application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('modal', { + into: 'application', + outlet: 'other' + }); + }, + actions: { + banish: function () { + this.disconnectOutlet({ + parentView: 'application', + outlet: 'other' + }); + } + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B-Hello world-C', 'initial render'); + + _emberMetal.run(router, 'send', 'banish'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B--C', 'second render'); + }); + + QUnit.test('Can render into a named outlet at the top level, with empty main outlet', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + + Router.map(function () { + this.route('hasNoTemplate', { path: '/' }); + }); + + registry.register('route:application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('modal', { + into: 'application', + outlet: 'other' + }); + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A--B-Hello world-C', 'initial render'); + }); + + QUnit.test('Can render into a named outlet at the top level, later', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('The index')); + + registry.register('route:application', _emberRouting.Route.extend({ + actions: { + launch: function () { + this.render('modal', { + into: 'application', + outlet: 'other' + }); + } + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B--C', 'initial render'); + + _emberMetal.run(router, 'send', 'launch'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B-Hello world-C', 'second render'); + }); + + QUnit.test('Can render routes with no \'main\' outlet and their children', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{outlet "app"}}
    ')); + _emberGlimmer.setTemplate('app', _emberTemplateCompiler.compile('
    {{outlet "common"}}
    {{outlet "sub"}}
    ')); + _emberGlimmer.setTemplate('common', _emberTemplateCompiler.compile('
    ')); + _emberGlimmer.setTemplate('sub', _emberTemplateCompiler.compile('
    ')); + + Router.map(function () { + this.route('app', { path: '/app' }, function () { + this.route('sub', { path: '/sub', resetNamespace: true }); + }); + }); + + App.AppRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('app', { + outlet: 'app', + into: 'application' + }); + this.render('common', { + outlet: 'common', + into: 'app' + }); + } + }); + + App.SubRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('sub', { + outlet: 'sub', + into: 'app' + }); + } + }); + + bootApplication(); + handleURL('/app'); + equal(_emberViews.jQuery('#app-common #common').length, 1, 'Finds common while viewing /app'); + handleURL('/app/sub'); + equal(_emberViews.jQuery('#app-common #common').length, 1, 'Finds common while viewing /app/sub'); + equal(_emberViews.jQuery('#app-sub #sub').length, 1, 'Finds sub while viewing /app/sub'); + }); + + QUnit.test('Tolerates stacked renders', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet "modal"}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('hi')); + _emberGlimmer.setTemplate('layer', _emberTemplateCompiler.compile('layer')); + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + openLayer: function () { + this.render('layer', { + into: 'application', + outlet: 'modal' + }); + }, + close: function () { + this.disconnectOutlet({ + outlet: 'modal', + parentView: 'application' + }); + } + } + }); + bootApplication(); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + _emberMetal.run(router, 'send', 'openLayer'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hilayer'); + _emberMetal.run(router, 'send', 'openLayer'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hilayer'); + _emberMetal.run(router, 'send', 'close'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + }); + + QUnit.test('Renders child into parent with non-default template name', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('exports/root', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('exports/index', _emberTemplateCompiler.compile('
    ')); + + Router.map(function () { + this.route('root', function () {}); + }); + + App.RootRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('exports/root'); + } + }); + + App.RootIndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('exports/index'); + } + }); + + bootApplication(); + handleURL('/root'); + equal(_emberViews.jQuery('#qunit-fixture .a .b .c').length, 1); + }); + + QUnit.test('Allows any route to disconnectOutlet another route\'s templates', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet "modal"}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('hi')); + _emberGlimmer.setTemplate('layer', _emberTemplateCompiler.compile('layer')); + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + openLayer: function () { + this.render('layer', { + into: 'application', + outlet: 'modal' + }); + } + } + }); + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + close: function () { + this.disconnectOutlet({ + parentView: 'application', + outlet: 'modal' + }); + } + } + }); + bootApplication(); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + _emberMetal.run(router, 'send', 'openLayer'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hilayer'); + _emberMetal.run(router, 'send', 'close'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + }); + + QUnit.test('Can this.render({into:...}) the render helper', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + _emberGlimmer.setTemplate('bar', _emberTemplateCompiler.compile('bar')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + }, + actions: { + changeToBar: function () { + this.disconnectOutlet({ + parentView: 'sidebar', + outlet: 'main' + }); + this.render('bar', { into: 'sidebar' }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), 'other'); + _emberMetal.run(router, 'send', 'changeToBar'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), 'bar'); + }); + + QUnit.test('Can disconnect from the render helper', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + }, + actions: { + disconnect: function () { + this.disconnectOutlet({ + parentView: 'sidebar', + outlet: 'main' + }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), 'other'); + _emberMetal.run(router, 'send', 'disconnect'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), ''); + }); + + QUnit.test('Can this.render({into:...}) the render helper\'s children', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('other', _emberTemplateCompiler.compile('other')); + _emberGlimmer.setTemplate('bar', _emberTemplateCompiler.compile('bar')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + this.render('other', { into: 'index' }); + }, + actions: { + changeToBar: function () { + this.disconnectOutlet({ + parentView: 'index', + outlet: 'main' + }); + this.render('bar', { into: 'index' }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), 'other'); + _emberMetal.run(router, 'send', 'changeToBar'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), 'bar'); + }); + + QUnit.test('Can disconnect from the render helper\'s children', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('other', _emberTemplateCompiler.compile('other')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + this.render('other', { into: 'index' }); + }, + actions: { + disconnect: function () { + this.disconnectOutlet({ + parentView: 'index', + outlet: 'main' + }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), 'other'); + _emberMetal.run(router, 'send', 'disconnect'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), ''); + }); + + QUnit.test('Can this.render({into:...}) nested render helpers', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('cart', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + _emberGlimmer.setTemplate('baz', _emberTemplateCompiler.compile('baz')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'cart' }); + }, + actions: { + changeToBaz: function () { + this.disconnectOutlet({ + parentView: 'cart', + outlet: 'main' + }); + this.render('baz', { into: 'cart' }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), 'other'); + _emberMetal.run(router, 'send', 'changeToBaz'); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), 'baz'); + }); + + QUnit.test('Can disconnect from nested render helpers', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('cart', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'cart' }); + }, + actions: { + disconnect: function () { + this.disconnectOutlet({ + parentView: 'cart', + outlet: 'main' + }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), 'other'); + _emberMetal.run(router, 'send', 'disconnect'); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), ''); + }); + + QUnit.test('Components inside an outlet have their didInsertElement hook invoked when the route is displayed', function (assert) { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#if showFirst}}{{my-component}}{{else}}{{other-component}}{{/if}}')); + + var myComponentCounter = 0; + var otherComponentCounter = 0; + var indexController = undefined; + + App.IndexController = _emberRuntime.Controller.extend({ + showFirst: true + }); + + App.IndexRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + indexController = controller; + } + }); + + App.MyComponentComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + myComponentCounter++; + } + }); + + App.OtherComponentComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + otherComponentCounter++; + } + }); + + bootApplication(); + + assert.strictEqual(myComponentCounter, 1, 'didInsertElement invoked on displayed component'); + assert.strictEqual(otherComponentCounter, 0, 'didInsertElement not invoked on displayed component'); + + _emberMetal.run(function () { + return indexController.set('showFirst', false); + }); + + assert.strictEqual(myComponentCounter, 1, 'didInsertElement not invoked on displayed component'); + assert.strictEqual(otherComponentCounter, 1, 'didInsertElement invoked on displayed component'); + }); + + QUnit.test('Doesnt swallow exception thrown from willTransition', function () { + expect(1); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('index')); + _emberGlimmer.setTemplate('other', _emberTemplateCompiler.compile('other')); + + Router.map(function () { + this.route('other', function () {}); + }); + + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + willTransition: function () { + throw new Error('boom'); + } + } + }); + + bootApplication(); + + throws(function () { + _emberMetal.run(function () { + return router.handleURL('/other'); + }); + }, /boom/, 'expected an exception that didnt happen'); + }); + + QUnit.test('Exception if outlet name is undefined in render and disconnectOutlet', function (assert) { + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + showModal: function () { + this.render({ + outlet: undefined, + parentView: 'application' + }); + }, + hideModal: function () { + this.disconnectOutlet({ + outlet: undefined, + parentView: 'application' + }); + } + } + }); + + bootApplication(); + + throws(function () { + _emberMetal.run(function () { + return router.send('showModal'); + }); + }, /You passed undefined as the outlet name/); + + throws(function () { + _emberMetal.run(function () { + return router.send('hideModal'); + }); + }, /You passed undefined as the outlet name/); + }); + + QUnit.test('Route serializers work for Engines', function () { + expect(2); + + // Register engine + var BlogEngine = _emberApplication.Engine.extend(); + registry.register('engine:blog', BlogEngine); + + // Register engine route map + var postSerialize = function (params) { + ok(true, 'serialize hook runs'); + return { + post_id: params.id + }; + }; + var BlogMap = function () { + this.route('post', { path: '/post/:post_id', serialize: postSerialize }); + }; + registry.register('route-map:blog', BlogMap); + + Router.map(function () { + this.mount('blog'); + }); + + bootApplication(); + + equal(router.router.generate('blog.post', { id: '13' }), '/blog/post/13', 'url is generated properly'); + }); + + QUnit.test('Defining a Route#serialize method in an Engine throws an error', function () { + expect(1); + + // Register engine + var BlogEngine = _emberApplication.Engine.extend(); + registry.register('engine:blog', BlogEngine); + + // Register engine route map + var BlogMap = function () { + this.route('post'); + }; + registry.register('route-map:blog', BlogMap); + + Router.map(function () { + this.mount('blog'); + }); + + bootApplication(); + + var PostRoute = _emberRouting.Route.extend({ serialize: function () {} }); + container.lookup('engine:blog').register('route:post', PostRoute); + + throws(function () { + return router.transitionTo('blog.post'); + }, /Defining a custom serialize method on an Engine route is not supported/); + }); + + QUnit.test('App.destroy does not leave undestroyed views after clearing engines', function () { + expect(4); + + var engineInstance = undefined; + // Register engine + var BlogEngine = _emberApplication.Engine.extend(); + registry.register('engine:blog', BlogEngine); + var EngineIndexRoute = _emberRouting.Route.extend({ + init: function () { + this._super.apply(this, arguments); + engineInstance = _emberUtils.getOwner(this); + } + }); + + // Register engine route map + var BlogMap = function () { + this.route('post'); + }; + registry.register('route-map:blog', BlogMap); + + Router.map(function () { + this.mount('blog'); + }); + + bootApplication(); + + var engine = container.lookup('engine:blog'); + engine.register('route:index', EngineIndexRoute); + engine.register('template:index', _emberTemplateCompiler.compile('Engine Post!')); + + handleURL('/blog'); + + var route = engineInstance.lookup('route:index'); + + _emberMetal.run(router, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was cleared'); + + _emberMetal.run(route, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + + _emberMetal.run(App, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + }); +}); +enifed('ember/tests/routing/basic_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/basic_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/basic_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test', ['exports', 'ember-runtime', 'ember-metal', 'ember-routing', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _emberMetal, _emberRouting, _emberViews, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - main', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.refreshModelWhileLoadingTest = function refreshModelWhileLoadingTest(loadingReturn) { + var _actions, + _this = this; + + var assert = this.assert; + + assert.expect(9); + + var appModelCount = 0; + var promiseResolve = undefined; + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + appomg: { + defaultValue: 'applol' + } + }, + model: function (params) { + appModelCount++; + } + })); + + this.setSingleQPController('index', 'omg', undefined, { + omg: undefined + }); + + var actionName = typeof loadingReturn !== 'undefined' ? 'loading' : 'ignore'; + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + actions: (_actions = {}, _actions[actionName] = function () { + return loadingReturn; + }, _actions), + model: function (params) { + indexModelCount++; + if (indexModelCount === 2) { + assert.deepEqual(params, { omg: 'lex' }); + return new _emberRuntime.RSVP.Promise(function (resolve) { + promiseResolve = resolve; + return; + }); + } else if (indexModelCount === 3) { + assert.deepEqual(params, { omg: 'hello' }, 'Model hook reruns even if the previous one didnt finish'); + } + } + })); + + return this.visit('/').then(function () { + assert.equal(appModelCount, 1, 'appModelCount is 1'); + assert.equal(indexModelCount, 1); + + var indexController = _this.getController('index'); + _this.setAndFlush(indexController, 'omg', 'lex'); + + assert.equal(appModelCount, 1, 'appModelCount is 1'); + assert.equal(indexModelCount, 2); + + _this.setAndFlush(indexController, 'omg', 'hello'); + assert.equal(appModelCount, 1, 'appModelCount is 1'); + assert.equal(indexModelCount, 3); + + _emberMetal.run(function () { + promiseResolve(); + }); + + assert.equal(_emberMetal.get(indexController, 'omg'), 'hello', 'At the end last value prevails'); + }); + }; + + _class.prototype['@test No replaceURL occurs on startup because default values don\'t show up in URL'] = function testNoReplaceURLOccursOnStartupBecauseDefaultValuesDonTShowUpInURL(assert) { + assert.expect(1); + + this.setSingleQPController('index'); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test Calling transitionTo does not lose query params already on the activeTransition'] = function testCallingTransitionToDoesNotLoseQueryParamsAlreadyOnTheActiveTransition(assert) { + var _this2 = this; + + assert.expect(2); + + this.router.map(function () { + this.route('parent', function () { + this.route('child'); + this.route('sibling'); + }); + }); + + this.registerRoute('parent.child', _emberRouting.Route.extend({ + afterModel: function () { + this.transitionTo('parent.sibling'); + } + })); + + this.setSingleQPController('parent'); + + return this.visit('/parent/child?foo=lol').then(function () { + _this2.assertCurrentPath('/parent/sibling?foo=lol', 'redirected to the sibling route, instead of child route'); + assert.equal(_this2.getController('parent').get('foo'), 'lol', 'controller has value from the active transition'); + }); + }; + + _class.prototype['@test Single query params can be set on the controller and reflected in the url'] = function testSingleQueryParamsCanBeSetOnTheControllerAndReflectedInTheUrl(assert) { + var _this3 = this; + + assert.expect(3); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + this.setSingleQPController('home'); + + return this.visitAndAssert('/').then(function () { + var controller = _this3.getController('home'); + + _this3.setAndFlush(controller, 'foo', '456'); + _this3.assertCurrentPath('/?foo=456'); + + _this3.setAndFlush(controller, 'foo', '987'); + _this3.assertCurrentPath('/?foo=987'); + }); + }; + + _class.prototype['@test Query params can map to different url keys configured on the controller'] = function testQueryParamsCanMapToDifferentUrlKeysConfiguredOnTheController(assert) { + var _this4 = this; + + assert.expect(6); + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: [{ foo: 'other_foo', bar: { as: 'other_bar' } }], + foo: 'FOO', + bar: 'BAR' + })); + + return this.visitAndAssert('/').then(function () { + var controller = _this4.getController('index'); + + _this4.setAndFlush(controller, 'foo', 'LEX'); + _this4.assertCurrentPath('/?other_foo=LEX', 'QP mapped correctly without \'as\''); + + _this4.setAndFlush(controller, 'foo', 'WOO'); + _this4.assertCurrentPath('/?other_foo=WOO', 'QP updated correctly without \'as\''); + + _this4.transitionTo('/?other_foo=NAW'); + assert.equal(controller.get('foo'), 'NAW', 'QP managed correctly on URL transition'); + + _this4.setAndFlush(controller, 'bar', 'NERK'); + _this4.assertCurrentPath('/?other_bar=NERK&other_foo=NAW', 'QP mapped correctly with \'as\''); + + _this4.setAndFlush(controller, 'bar', 'NUKE'); + _this4.assertCurrentPath('/?other_bar=NUKE&other_foo=NAW', 'QP updated correctly with \'as\''); + }); + }; + + _class.prototype['@test Routes have a private overridable serializeQueryParamKey hook'] = function testRoutesHaveAPrivateOverridableSerializeQueryParamKeyHook(assert) { + var _this5 = this; + + assert.expect(2); + + this.registerRoute('index', _emberRouting.Route.extend({ + serializeQueryParamKey: _emberRuntime.String.dasherize + })); + + this.setSingleQPController('index', 'funTimes', ''); + + return this.visitAndAssert('/').then(function () { + var controller = _this5.getController('index'); + + _this5.setAndFlush(controller, 'funTimes', 'woot'); + _this5.assertCurrentPath('/?fun-times=woot'); + }); + }; + + _class.prototype['@test Can override inherited QP behavior by specifying queryParams as a computed property'] = function testCanOverrideInheritedQPBehaviorBySpecifyingQueryParamsAsAComputedProperty(assert) { + var _this6 = this; + + assert.expect(3); + + this.setSingleQPController('index', 'a', 0, { + queryParams: _emberMetal.computed(function () { + return ['c']; + }), + c: true + }); + + return this.visitAndAssert('/').then(function () { + var indexController = _this6.getController('index'); + + _this6.setAndFlush(indexController, 'a', 1); + _this6.assertCurrentPath('/', 'QP did not update due to being overriden'); + + _this6.setAndFlush(indexController, 'c', false); + _this6.assertCurrentPath('/?c=false', 'QP updated with overriden param'); + }); + }; + + _class.prototype['@test Can concatenate inherited QP behavior by specifying queryParams as an array'] = function testCanConcatenateInheritedQPBehaviorBySpecifyingQueryParamsAsAnArray(assert) { + var _this7 = this; + + assert.expect(3); + + this.setSingleQPController('index', 'a', 0, { + queryParams: ['c'], + c: true + }); + + return this.visitAndAssert('/').then(function () { + var indexController = _this7.getController('index'); + + _this7.setAndFlush(indexController, 'a', 1); + _this7.assertCurrentPath('/?a=1', 'Inherited QP did update'); + + _this7.setAndFlush(indexController, 'c', false); + _this7.assertCurrentPath('/?a=1&c=false', 'New QP did update'); + }); + }; + + _class.prototype['@test model hooks receives query params'] = function testModelHooksReceivesQueryParams(assert) { + assert.expect(2); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: 'bar' }); + } + })); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test model hooks receives query params with dynamic segment params'] = function testModelHooksReceivesQueryParamsWithDynamicSegmentParams(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:id' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: 'bar', id: 'baz' }); + } + })); + + return this.visitAndAssert('/baz'); + }; + + _class.prototype['@test model hooks receives query params (overridden by incoming url value)'] = function testModelHooksReceivesQueryParamsOverriddenByIncomingUrlValue(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:id' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: 'baz', id: 'boo' }); + } + })); + + return this.visitAndAssert('/boo?foo=baz'); + }; + + _class.prototype['@test error is thrown if dynamic segment and query param have same name'] = function testErrorIsThrownIfDynamicSegmentAndQueryParamHaveSameName(assert) { + var _this8 = this; + + assert.expect(1); + + this.router.map(function () { + this.route('index', { path: '/:foo' }); + }); + + this.setSingleQPController('index'); + + expectAssertion(function () { + _this8.visitAndAssert('/boo?foo=baz'); + }, 'The route \'index\' has both a dynamic segment and query param with name \'foo\'. Please rename one to avoid collisions.'); + }; + + _class.prototype['@test controllers won\'t be eagerly instantiated by internal query params logic'] = function testControllersWonTBeEagerlyInstantiatedByInternalQueryParamsLogic(assert) { + var _this9 = this; + + assert.expect(10); + + this.router.map(function () { + this.route('cats', function () { + this.route('index', { path: '/' }); + }); + this.route('home', { path: '/' }); + this.route('about'); + }); + + this.registerTemplate('home', '

    {{link-to \'About\' \'about\' (query-params lol=\'wat\') id=\'link-to-about\'}}

    '); + this.registerTemplate('about', '

    {{link-to \'Home\' \'home\' (query-params foo=\'naw\')}}

    '); + this.registerTemplate('cats.index', '

    {{link-to \'Cats\' \'cats\' (query-params name=\'domino\') id=\'cats-link\'}}

    '); + + var homeShouldBeCreated = false; + var aboutShouldBeCreated = false; + var catsIndexShouldBeCreated = false; + + this.registerRoute('home', _emberRouting.Route.extend({ + setup: function () { + homeShouldBeCreated = true; + this._super.apply(this, arguments); + } + })); + + this.setSingleQPController('home', 'foo', '123', { + init: function () { + this._super.apply(this, arguments); + assert.ok(homeShouldBeCreated, 'HomeController should be created at this time'); + } + }); + + this.registerRoute('about', _emberRouting.Route.extend({ + setup: function () { + aboutShouldBeCreated = true; + this._super.apply(this, arguments); + } + })); + + this.setSingleQPController('about', 'lol', 'haha', { + init: function () { + this._super.apply(this, arguments); + assert.ok(aboutShouldBeCreated, 'AboutController should be created at this time'); + } + }); + + this.registerRoute('cats.index', _emberRouting.Route.extend({ + model: function () { + return []; + }, + setup: function () { + catsIndexShouldBeCreated = true; + this._super.apply(this, arguments); + }, + setupController: function (controller, context) { + controller.set('model', context); + } + })); + + this.registerController('cats.index', _emberRuntime.Controller.extend({ + queryParams: ['breed', 'name'], + breed: 'Golden', + name: null, + init: function () { + this._super.apply(this, arguments); + assert.ok(catsIndexShouldBeCreated, 'CatsIndexController should be created at this time'); + } + })); + + return this.visitAndAssert('/').then(function () { + var controller = _this9.getController('home'); + + _this9.setAndFlush(controller, 'foo', '456'); + _this9.assertCurrentPath('/?foo=456'); + assert.equal(_emberViews.jQuery('#link-to-about').attr('href'), '/about?lol=wat', 'link to about is correct'); + + _this9.transitionTo('about'); + _this9.assertCurrentPath('/about'); + + _this9.transitionTo('cats'); + _this9.assertCurrentPath('/cats'); + assert.equal(_emberViews.jQuery('#cats-link').attr('href'), '/cats?name=domino', 'link to cats is correct'); + + _emberMetal.run(_emberViews.jQuery('#cats-link'), 'click'); + _this9.assertCurrentPath('/cats?name=domino'); + }); + }; + + _class.prototype['@test query params have been set by the time setupController is called'] = function testQueryParamsHaveBeenSetByTheTimeSetupControllerIsCalled(assert) { + assert.expect(2); + + this.setSingleQPController('application'); + + this.registerRoute('application', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.equal(controller.get('foo'), 'YEAH', 'controller\'s foo QP property set before setupController called'); + } + })); + + return this.visitAndAssert('/?foo=YEAH'); + }; + + _class.prototype['@test mapped query params have been set by the time setupController is called'] = function testMappedQueryParamsHaveBeenSetByTheTimeSetupControllerIsCalled(assert) { + assert.expect(2); + + this.setSingleQPController('application', { faz: 'foo' }); + + this.registerRoute('application', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.equal(controller.get('faz'), 'YEAH', 'controller\'s foo QP property set before setupController called'); + } + })); + + return this.visitAndAssert('/?foo=YEAH'); + }; + + _class.prototype['@test Route#paramsFor fetches query params with default value'] = function testRouteParamsForFetchesQueryParamsWithDefaultValue(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'bar' }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz'); + }; + + _class.prototype['@test Route#paramsFor fetches query params with non-default value'] = function testRouteParamsForFetchesQueryParamsWithNonDefaultValue(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'boo' }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz?foo=boo'); + }; + + _class.prototype['@test Route#paramsFor fetches default falsy query params'] = function testRouteParamsForFetchesDefaultFalsyQueryParams(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index', 'foo', false); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz'); + }; + + _class.prototype['@test Route#paramsFor fetches non-default falsy query params'] = function testRouteParamsForFetchesNonDefaultFalsyQueryParams(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index', 'foo', true); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz?foo=false'); + }; + + _class.prototype['@test model hook can query prefix-less application params'] = function testModelHookCanQueryPrefixLessApplicationParams(assert) { + assert.expect(4); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { appomg: 'applol' }); + } + })); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { omg: 'lol' }); + assert.deepEqual(this.paramsFor('application'), { appomg: 'applol' }); + } + })); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test model hook can query prefix-less application params (overridden by incoming url value)'] = function testModelHookCanQueryPrefixLessApplicationParamsOverriddenByIncomingUrlValue(assert) { + assert.expect(4); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { appomg: 'appyes' }); + } + })); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { omg: 'yes' }); + assert.deepEqual(this.paramsFor('application'), { appomg: 'appyes' }); + } + })); + + return this.visitAndAssert('/?appomg=appyes&omg=yes'); + }; + + _class.prototype['@test can opt into full transition by setting refreshModel in route queryParams'] = function testCanOptIntoFullTransitionBySettingRefreshModelInRouteQueryParams(assert) { + var _this10 = this; + + assert.expect(7); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + var appModelCount = 0; + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + appModelCount++; + } + })); + + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + model: function (params) { + indexModelCount++; + + if (indexModelCount === 1) { + assert.deepEqual(params, { omg: 'lol' }, 'params are correct on first pass'); + } else if (indexModelCount === 2) { + assert.deepEqual(params, { omg: 'lex' }, 'params are correct on second pass'); + } + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(appModelCount, 1, 'app model hook ran'); + assert.equal(indexModelCount, 1, 'index model hook ran'); + + var indexController = _this10.getController('index'); + _this10.setAndFlush(indexController, 'omg', 'lex'); + + assert.equal(appModelCount, 1, 'app model hook did not run again'); + assert.equal(indexModelCount, 2, 'index model hook ran again due to refreshModel'); + }); + }; + + _class.prototype['@test multiple QP value changes only cause a single model refresh'] = function testMultipleQPValueChangesOnlyCauseASingleModelRefresh(assert) { + var _this11 = this; + + assert.expect(2); + + this.setSingleQPController('index', 'alex', 'lol'); + this.setSingleQPController('index', 'steely', 'lel'); + + var refreshCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + alex: { + refreshModel: true + }, + steely: { + refreshModel: true + } + }, + refresh: function () { + refreshCount++; + } + })); + + return this.visitAndAssert('/').then(function () { + var indexController = _this11.getController('index'); + _emberMetal.run(indexController, 'setProperties', { alex: 'fran', steely: 'david' }); + assert.equal(refreshCount, 1, 'index refresh hook only run once'); + }); + }; + + _class.prototype['@test refreshModel does not cause a second transition during app boot '] = function testRefreshModelDoesNotCauseASecondTransitionDuringAppBoot(assert) { + assert.expect(1); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + refresh: function () { + assert.ok(false); + } + })); + + return this.visitAndAssert('/?appomg=hello&omg=world'); + }; + + _class.prototype['@test queryParams are updated when a controller property is set and the route is refreshed. Issue #13263 '] = function testQueryParamsAreUpdatedWhenAControllerPropertyIsSetAndTheRouteIsRefreshedIssue13263(assert) { + var _this12 = this; + + this.registerTemplate('application', '{{foo}}{{outlet}}'); + + this.setSingleQPController('application', 'foo', 1, { + actions: { + increment: function () { + this.incrementProperty('foo'); + this.send('refreshRoute'); + } + } + }); + + this.registerRoute('application', _emberRouting.Route.extend({ + actions: { + refreshRoute: function () { + this.refresh(); + } + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(_emberViews.jQuery('#test-value').text().trim(), '1'); + + _emberMetal.run(_emberViews.jQuery('#test-button'), 'click'); + assert.equal(_emberViews.jQuery('#test-value').text().trim(), '2'); + _this12.assertCurrentPath('/?foo=2'); + + _emberMetal.run(_emberViews.jQuery('#test-button'), 'click'); + assert.equal(_emberViews.jQuery('#test-value').text().trim(), '3'); + _this12.assertCurrentPath('/?foo=3'); + }); + }; + + _class.prototype['@test Use Ember.get to retrieve query params \'refreshModel\' configuration'] = function testUseEmberGetToRetrieveQueryParamsRefreshModelConfiguration(assert) { + var _this13 = this; + + assert.expect(7); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + var appModelCount = 0; + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + appModelCount++; + } + })); + + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: _emberRuntime.Object.create({ + unknownProperty: function (keyName) { + return { refreshModel: true }; + } + }), + model: function (params) { + indexModelCount++; + + if (indexModelCount === 1) { + assert.deepEqual(params, { omg: 'lol' }); + } else if (indexModelCount === 2) { + assert.deepEqual(params, { omg: 'lex' }); + } + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(appModelCount, 1); + assert.equal(indexModelCount, 1); + + var indexController = _this13.getController('index'); + _this13.setAndFlush(indexController, 'omg', 'lex'); + + assert.equal(appModelCount, 1); + assert.equal(indexModelCount, 2); + }); + }; + + _class.prototype['@test can use refreshModel even with URL changes that remove QPs from address bar'] = function testCanUseRefreshModelEvenWithURLChangesThatRemoveQPsFromAddressBar(assert) { + var _this14 = this; + + assert.expect(4); + + this.setSingleQPController('index', 'omg', 'lol'); + + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + model: function (params) { + indexModelCount++; + + var data = undefined; + if (indexModelCount === 1) { + data = 'foo'; + } else if (indexModelCount === 2) { + data = 'lol'; + } + + assert.deepEqual(params, { omg: data }, 'index#model receives right data'); + } + })); + + return this.visitAndAssert('/?omg=foo').then(function () { + _this14.transitionTo('/'); + + var indexController = _this14.getController('index'); + assert.equal(indexController.get('omg'), 'lol'); + }); + }; + + _class.prototype['@test can opt into a replace query by specifying replace:true in the Route config hash'] = function testCanOptIntoAReplaceQueryBySpecifyingReplaceTrueInTheRouteConfigHash(assert) { + var _this15 = this; + + assert.expect(2); + + this.setSingleQPController('application', 'alex', 'matchneer'); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + alex: { + replace: true + } + } + })); + + return this.visitAndAssert('/').then(function () { + var appController = _this15.getController('application'); + _this15.expectedReplaceURL = '/?alex=wallace'; + _this15.setAndFlush(appController, 'alex', 'wallace'); + }); + }; + + _class.prototype['@test Route query params config can be configured using property name instead of URL key'] = function testRouteQueryParamsConfigCanBeConfiguredUsingPropertyNameInsteadOfURLKey(assert) { + var _this16 = this; + + assert.expect(2); + + this.registerController('application', _emberRuntime.Controller.extend({ + queryParams: [{ commitBy: 'commit_by' }] + })); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + commitBy: { + replace: true + } + } + })); + + return this.visitAndAssert('/').then(function () { + var appController = _this16.getController('application'); + _this16.expectedReplaceURL = '/?commit_by=igor_seb'; + _this16.setAndFlush(appController, 'commitBy', 'igor_seb'); + }); + }; + + _class.prototype['@test An explicit replace:false on a changed QP always wins and causes a pushState'] = function testAnExplicitReplaceFalseOnAChangedQPAlwaysWinsAndCausesAPushState(assert) { + var _this17 = this; + + assert.expect(3); + + this.registerController('application', _emberRuntime.Controller.extend({ + queryParams: ['alex', 'steely'], + alex: 'matchneer', + steely: 'dan' + })); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + alex: { + replace: true + }, + steely: { + replace: false + } + } + })); + + return this.visit('/').then(function () { + var appController = _this17.getController('application'); + _this17.expectedPushURL = '/?alex=wallace&steely=jan'; + _emberMetal.run(appController, 'setProperties', { alex: 'wallace', steely: 'jan' }); + + _this17.expectedPushURL = '/?alex=wallace&steely=fran'; + _emberMetal.run(appController, 'setProperties', { steely: 'fran' }); + + _this17.expectedReplaceURL = '/?alex=sriracha&steely=fran'; + _emberMetal.run(appController, 'setProperties', { alex: 'sriracha' }); + }); + }; + + _class.prototype['@test can opt into full transition by setting refreshModel in route queryParams when transitioning from child to parent'] = function testCanOptIntoFullTransitionBySettingRefreshModelInRouteQueryParamsWhenTransitioningFromChildToParent(assert) { + this.registerTemplate('parent', '{{outlet}}'); + this.registerTemplate('parent.child', '{{link-to \'Parent\' \'parent\' (query-params foo=\'change\') id=\'parent-link\'}}'); + + this.router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + var parentModelCount = 0; + this.registerRoute('parent', _emberRouting.Route.extend({ + model: function () { + parentModelCount++; + }, + queryParams: { + foo: { + refreshModel: true + } + } + })); + + this.setSingleQPController('parent', 'foo', 'abc'); + + return this.visit('/parent/child?foo=lol').then(function () { + assert.equal(parentModelCount, 1); + + _emberMetal.run(_emberViews.jQuery('#parent-link'), 'click'); + assert.equal(parentModelCount, 2); + }); + }; + + _class.prototype['@test Use Ember.get to retrieve query params \'replace\' configuration'] = function testUseEmberGetToRetrieveQueryParamsReplaceConfiguration(assert) { + var _this18 = this; + + assert.expect(2); + + this.setSingleQPController('application', 'alex', 'matchneer'); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: _emberRuntime.Object.create({ + unknownProperty: function (keyName) { + // We are simulating all qps requiring refresh + return { replace: true }; + } + }) + })); + + return this.visitAndAssert('/').then(function () { + var appController = _this18.getController('application'); + _this18.expectedReplaceURL = '/?alex=wallace'; + _this18.setAndFlush(appController, 'alex', 'wallace'); + }); + }; + + _class.prototype['@test can override incoming QP values in setupController'] = function testCanOverrideIncomingQPValuesInSetupController(assert) { + var _this19 = this; + + assert.expect(3); + + this.router.map(function () { + this.route('about'); + }); + + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('index', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.ok(true, 'setupController called'); + controller.set('omg', 'OVERRIDE'); + }, + actions: { + queryParamsDidChange: function () { + assert.ok(false, 'queryParamsDidChange shouldn\'t fire'); + } + } + })); + + return this.visitAndAssert('/about').then(function () { + _this19.transitionTo('index'); + _this19.assertCurrentPath('/?omg=OVERRIDE'); + }); + }; + + _class.prototype['@test can override incoming QP array values in setupController'] = function testCanOverrideIncomingQPArrayValuesInSetupController(assert) { + var _this20 = this; + + assert.expect(3); + + this.router.map(function () { + this.route('about'); + }); + + this.setSingleQPController('index', 'omg', ['lol']); + + this.registerRoute('index', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.ok(true, 'setupController called'); + controller.set('omg', ['OVERRIDE']); + }, + actions: { + queryParamsDidChange: function () { + assert.ok(false, 'queryParamsDidChange shouldn\'t fire'); + } + } + })); + + return this.visitAndAssert('/about').then(function () { + _this20.transitionTo('index'); + _this20.assertCurrentPath('/?omg=' + encodeURIComponent(JSON.stringify(['OVERRIDE']))); + }); + }; + + _class.prototype['@test URL transitions that remove QPs still register as QP changes'] = function testURLTransitionsThatRemoveQPsStillRegisterAsQPChanges(assert) { + var _this21 = this; + + assert.expect(2); + + this.setSingleQPController('index', 'omg', 'lol'); + + return this.visit('/?omg=borf').then(function () { + var indexController = _this21.getController('index'); + assert.equal(indexController.get('omg'), 'borf'); + + _this21.transitionTo('/'); + assert.equal(indexController.get('omg'), 'lol'); + }); + }; + + _class.prototype['@test Subresource naming style is supported'] = function testSubresourceNamingStyleIsSupported(assert) { + var _this22 = this; + + assert.expect(5); + + this.router.map(function () { + this.route('abc.def', { path: '/abcdef' }, function () { + this.route('zoo'); + }); + }); + + this.registerTemplate('application', '{{link-to \'A\' \'abc.def\' (query-params foo=\'123\') id=\'one\'}}{{link-to \'B\' \'abc.def.zoo\' (query-params foo=\'123\' bar=\'456\') id=\'two\'}}{{outlet}}'); + + this.setSingleQPController('abc.def', 'foo', 'lol'); + this.setSingleQPController('abc.def.zoo', 'bar', 'haha'); + + return this.visitAndAssert('/').then(function () { + assert.equal(_emberViews.jQuery('#one').attr('href'), '/abcdef?foo=123'); + assert.equal(_emberViews.jQuery('#two').attr('href'), '/abcdef/zoo?bar=456&foo=123'); + + _emberMetal.run(_emberViews.jQuery('#one'), 'click'); + _this22.assertCurrentPath('/abcdef?foo=123'); + + _emberMetal.run(_emberViews.jQuery('#two'), 'click'); + _this22.assertCurrentPath('/abcdef/zoo?bar=456&foo=123'); + }); + }; + + _class.prototype['@test transitionTo supports query params'] = function testTransitionToSupportsQueryParams(assert) { + var _this23 = this; + + this.setSingleQPController('index', 'foo', 'lol'); + + return this.visitAndAssert('/').then(function () { + _this23.transitionTo({ queryParams: { foo: 'borf' } }); + _this23.assertCurrentPath('/?foo=borf', 'shorthand supported'); + + _this23.transitionTo({ queryParams: { 'index:foo': 'blaf' } }); + _this23.assertCurrentPath('/?foo=blaf', 'longform supported'); + + _this23.transitionTo({ queryParams: { 'index:foo': false } }); + _this23.assertCurrentPath('/?foo=false', 'longform supported (bool)'); + + _this23.transitionTo({ queryParams: { foo: false } }); + _this23.assertCurrentPath('/?foo=false', 'shorhand supported (bool)'); + }); + }; + + _class.prototype['@test transitionTo supports query params (multiple)'] = function testTransitionToSupportsQueryParamsMultiple(assert) { + var _this24 = this; + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar'], + foo: 'lol', + bar: 'wat' + })); + + return this.visitAndAssert('/').then(function () { + _this24.transitionTo({ queryParams: { foo: 'borf' } }); + _this24.assertCurrentPath('/?foo=borf', 'shorthand supported'); + + _this24.transitionTo({ queryParams: { 'index:foo': 'blaf' } }); + _this24.assertCurrentPath('/?foo=blaf', 'longform supported'); + + _this24.transitionTo({ queryParams: { 'index:foo': false } }); + _this24.assertCurrentPath('/?foo=false', 'longform supported (bool)'); + + _this24.transitionTo({ queryParams: { foo: false } }); + _this24.assertCurrentPath('/?foo=false', 'shorhand supported (bool)'); + }); + }; + + _class.prototype['@test setting controller QP to empty string doesn\'t generate null in URL'] = function testSettingControllerQPToEmptyStringDoesnTGenerateNullInURL(assert) { + var _this25 = this; + + assert.expect(1); + + this.setSingleQPController('index', 'foo', '123'); + + return this.visit('/').then(function () { + var controller = _this25.getController('index'); + + _this25.expectedPushURL = '/?foo='; + _this25.setAndFlush(controller, 'foo', ''); + }); + }; + + _class.prototype['@test setting QP to empty string doesn\'t generate null in URL'] = function testSettingQPToEmptyStringDoesnTGenerateNullInURL(assert) { + var _this26 = this; + + assert.expect(1); + + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + foo: { + defaultValue: '123' + } + } + })); + + return this.visit('/').then(function () { + var controller = _this26.getController('index'); + + _this26.expectedPushURL = '/?foo='; + _this26.setAndFlush(controller, 'foo', ''); + }); + }; + + _class.prototype['@test A default boolean value deserializes QPs as booleans rather than strings'] = function testADefaultBooleanValueDeserializesQPsAsBooleansRatherThanStrings(assert) { + var _this27 = this; + + assert.expect(3); + + this.setSingleQPController('index', 'foo', false); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.equal(params.foo, true, 'model hook received foo as boolean true'); + } + })); + + return this.visit('/?foo=true').then(function () { + var controller = _this27.getController('index'); + assert.equal(controller.get('foo'), true); + + _this27.transitionTo('/?foo=false'); + assert.equal(controller.get('foo'), false); + }); + }; + + _class.prototype['@test Query param without value are empty string'] = function testQueryParamWithoutValueAreEmptyString(assert) { + var _this28 = this; + + assert.expect(1); + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '' + })); + + return this.visit('/?foo=').then(function () { + var controller = _this28.getController('index'); + assert.equal(controller.get('foo'), ''); + }); + }; + + _class.prototype['@test Array query params can be set'] = function testArrayQueryParamsCanBeSet(assert) { + var _this29 = this; + + assert.expect(2); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + this.setSingleQPController('home', 'foo', []); + + return this.visit('/').then(function () { + var controller = _this29.getController('home'); + + _this29.setAndFlush(controller, 'foo', [1, 2]); + _this29.assertCurrentPath('/?foo=%5B1%2C2%5D'); + + _this29.setAndFlush(controller, 'foo', [3, 4]); + _this29.assertCurrentPath('/?foo=%5B3%2C4%5D'); + }); + }; + + _class.prototype['@test (de)serialization: arrays'] = function testDeSerializationArrays(assert) { + var _this30 = this; + + assert.expect(4); + + this.setSingleQPController('index', 'foo', [1]); + + return this.visitAndAssert('/').then(function () { + _this30.transitionTo({ queryParams: { foo: [2, 3] } }); + _this30.assertCurrentPath('/?foo=%5B2%2C3%5D', 'shorthand supported'); + _this30.transitionTo({ queryParams: { 'index:foo': [4, 5] } }); + _this30.assertCurrentPath('/?foo=%5B4%2C5%5D', 'longform supported'); + _this30.transitionTo({ queryParams: { foo: [] } }); + _this30.assertCurrentPath('/?foo=%5B%5D', 'longform supported'); + }); + }; + + _class.prototype['@test Url with array query param sets controller property to array'] = function testUrlWithArrayQueryParamSetsControllerPropertyToArray(assert) { + var _this31 = this; + + assert.expect(1); + + this.setSingleQPController('index', 'foo', ''); + + return this.visit('/?foo[]=1&foo[]=2&foo[]=3').then(function () { + var controller = _this31.getController('index'); + assert.deepEqual(controller.get('foo'), ['1', '2', '3']); + }); + }; + + _class.prototype['@test Array query params can be pushed/popped'] = function testArrayQueryParamsCanBePushedPopped(assert) { + var _this32 = this; + + assert.expect(17); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + this.setSingleQPController('home', 'foo', _emberRuntime.A()); + + return this.visitAndAssert('/').then(function () { + var controller = _this32.getController('home'); + + _emberMetal.run(controller.foo, 'pushObject', 1); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'popObject'); + _this32.assertCurrentPath('/'); + assert.deepEqual(controller.foo, []); + + _emberMetal.run(controller.foo, 'pushObject', 1); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'popObject'); + _this32.assertCurrentPath('/'); + assert.deepEqual(controller.foo, []); + + _emberMetal.run(controller.foo, 'pushObject', 1); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'pushObject', 2); + _this32.assertCurrentPath('/?foo=%5B1%2C2%5D'); + assert.deepEqual(controller.foo, [1, 2]); + + _emberMetal.run(controller.foo, 'popObject'); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'unshiftObject', 'lol'); + _this32.assertCurrentPath('/?foo=%5B%22lol%22%2C1%5D'); + assert.deepEqual(controller.foo, ['lol', 1]); + }); + }; + + _class.prototype['@test Overwriting with array with same content shouldn\'t refire update'] = function testOverwritingWithArrayWithSameContentShouldnTRefireUpdate(assert) { + var _this33 = this; + + assert.expect(4); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + var modelCount = 0; + this.registerRoute('home', _emberRouting.Route.extend({ + model: function () { + modelCount++; + } + })); + + this.setSingleQPController('home', 'foo', _emberRuntime.A([1])); + + return this.visitAndAssert('/').then(function () { + assert.equal(modelCount, 1); + + var controller = _this33.getController('home'); + _this33.setAndFlush(controller, 'model', _emberRuntime.A([1])); + + assert.equal(modelCount, 1); + _this33.assertCurrentPath('/'); + }); + }; + + _class.prototype['@test Defaulting to params hash as the model should not result in that params object being watched'] = function testDefaultingToParamsHashAsTheModelShouldNotResultInThatParamsObjectBeingWatched(assert) { + var _this34 = this; + + assert.expect(1); + + this.router.map(function () { + this.route('other'); + }); + + // This causes the params hash, which is returned as a route's + // model if no other model could be resolved given the provided + // params (and no custom model hook was defined), to be watched, + // unless we return a copy of the params hash. + this.setSingleQPController('application', 'woot', 'wat'); + + this.registerRoute('other', _emberRouting.Route.extend({ + model: function (p, trans) { + var m = _emberMetal.meta(trans.params.application); + assert.ok(!m.peekWatching('woot'), 'A meta object isn\'t constructed for this params POJO'); + } + })); + + return this.visit('/').then(function () { + _this34.transitionTo('other'); + }); + }; + + _class.prototype['@test A child of a resource route still defaults to parent route\'s model even if the child route has a query param'] = function testAChildOfAResourceRouteStillDefaultsToParentRouteSModelEvenIfTheChildRouteHasAQueryParam(assert) { + assert.expect(2); + + this.setSingleQPController('index', 'woot', undefined, { + woot: undefined + }); + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (p, trans) { + return { woot: true }; + } + })); + + this.registerRoute('index', _emberRouting.Route.extend({ + setupController: function (controller, model) { + assert.deepEqual(model, { woot: true }, 'index route inherited model route from parent route'); + } + })); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test opting into replace does not affect transitions between routes'] = function testOptingIntoReplaceDoesNotAffectTransitionsBetweenRoutes(assert) { + var _this35 = this; + + assert.expect(5); + + this.registerTemplate('application', '{{link-to \'Foo\' \'foo\' id=\'foo-link\'}}{{link-to \'Bar\' \'bar\' id=\'bar-no-qp-link\'}}{{link-to \'Bar\' \'bar\' (query-params raytiley=\'isthebest\') id=\'bar-link\'}}{{outlet}}'); + + this.router.map(function () { + this.route('foo'); + this.route('bar'); + }); + + this.setSingleQPController('bar', 'raytiley', 'israd'); + + this.registerRoute('bar', _emberRouting.Route.extend({ + queryParams: { + raytiley: { + replace: true + } + } + })); + + return this.visit('/').then(function () { + var controller = _this35.getController('bar'); + + _this35.expectedPushURL = '/foo'; + _emberMetal.run(_emberViews.jQuery('#foo-link'), 'click'); + + _this35.expectedPushURL = '/bar'; + _emberMetal.run(_emberViews.jQuery('#bar-no-qp-link'), 'click'); + + _this35.expectedReplaceURL = '/bar?raytiley=woot'; + _this35.setAndFlush(controller, 'raytiley', 'woot'); + + _this35.expectedPushURL = '/foo'; + _emberMetal.run(_emberViews.jQuery('#foo-link'), 'click'); + + _this35.expectedPushURL = '/bar?raytiley=isthebest'; + _emberMetal.run(_emberViews.jQuery('#bar-link'), 'click'); + }); + }; + + _class.prototype['@test undefined isn\'t serialized or deserialized into a string'] = function testUndefinedIsnTSerializedOrDeserializedIntoAString(assert) { + var _this36 = this; + + assert.expect(4); + + this.router.map(function () { + this.route('example'); + }); + + this.registerTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); + + this.setSingleQPController('example', 'foo', undefined, { + foo: undefined + }); + + this.registerRoute('example', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: undefined }); + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(_this36.$('#the-link').attr('href'), '/example', 'renders without undefined qp serialized'); + + return _this36.transitionTo('example', { queryParams: { foo: undefined } }).then(function () { + _this36.assertCurrentPath('/example'); + }); + }); + }; + + _class.prototype['@test when refreshModel is true and loading hook is undefined, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookIsUndefinedModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) { + return this.refreshModelWhileLoadingTest(); + }; + + _class.prototype['@test when refreshModel is true and loading hook returns false, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookReturnsFalseModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) { + return this.refreshModelWhileLoadingTest(false); + }; + + _class.prototype['@test when refreshModel is true and loading hook returns true, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookReturnsTrueModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) { + return this.refreshModelWhileLoadingTest(true); + }; + + _class.prototype['@test warn user that Route\'s queryParams configuration must be an Object, not an Array'] = function testWarnUserThatRouteSQueryParamsConfigurationMustBeAnObjectNotAnArray(assert) { + var _this37 = this; + + assert.expect(1); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: [{ commitBy: { replace: true } }] + })); + + expectAssertion(function () { + _this37.visit('/'); + }, 'You passed in `[{"commitBy":{"replace":true}}]` as the value for `queryParams` but `queryParams` cannot be an Array'); + }; + + _class.prototype['@test handle route names that clash with Object.prototype properties'] = function testHandleRouteNamesThatClashWithObjectPrototypeProperties(assert) { + var _this38 = this; + + assert.expect(1); + + this.router.map(function () { + this.route('constructor'); + }); + + this.registerRoute('constructor', _emberRouting.Route.extend({ + queryParams: { + foo: { + defaultValue: '123' + } + } + })); + + return this.visit('/').then(function () { + _this38.transitionTo('constructor', { queryParams: { foo: '999' } }); + var controller = _this38.getController('constructor'); + assert.equal(_emberMetal.get(controller, 'foo'), '999'); + }); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberViews, _internalTestHelpers) { + 'use strict'; + + var ModelDependentQPTestCase = (function (_QueryParamTestCase) { + babelHelpers.inherits(ModelDependentQPTestCase, _QueryParamTestCase); + + function ModelDependentQPTestCase() { + babelHelpers.classCallCheck(this, ModelDependentQPTestCase); + + _QueryParamTestCase.apply(this, arguments); + } + + ModelDependentQPTestCase.prototype.boot = function boot() { + this.setupApplication(); + return this.visitApplication(); + }; + + ModelDependentQPTestCase.prototype.teardown = function teardown() { + var _QueryParamTestCase$prototype$teardown; + + (_QueryParamTestCase$prototype$teardown = _QueryParamTestCase.prototype.teardown).call.apply(_QueryParamTestCase$prototype$teardown, [this].concat(babelHelpers.slice.call(arguments))); + this.assert.ok(!this.expectedModelHookParams, 'there should be no pending expectation of expected model hook params'); + }; + + ModelDependentQPTestCase.prototype.reopenController = function reopenController(name, options) { + this.application.resolveRegistration('controller:' + name).reopen(options); + }; + + ModelDependentQPTestCase.prototype.reopenRoute = function reopenRoute(name, options) { + this.application.resolveRegistration('route:' + name).reopen(options); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest1 = function queryParamsStickyTest1(urlPrefix) { + var _this = this; + + var assert = this.assert; + + assert.expect(14); + + return this.boot().then(function () { + _emberMetal.run(_this.$link1, 'click'); + _this.assertCurrentPath(urlPrefix + '/a-1'); + + _this.setAndFlush(_this.controller, 'q', 'lol'); + + assert.equal(_this.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this.$link3.attr('href'), urlPrefix + '/a-3'); + + _emberMetal.run(_this.$link2, 'click'); + + assert.equal(_this.controller.get('q'), 'wat'); + assert.equal(_this.controller.get('z'), 0); + assert.deepEqual(_this.controller.get('model'), { id: 'a-2' }); + assert.equal(_this.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this.$link3.attr('href'), urlPrefix + '/a-3'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest2 = function queryParamsStickyTest2(urlPrefix) { + var _this2 = this; + + var assert = this.assert; + + assert.expect(24); + + return this.boot().then(function () { + _this2.expectedModelHookParams = { id: 'a-1', q: 'lol', z: 0 }; + _this2.transitionTo(urlPrefix + '/a-1?q=lol'); + + assert.deepEqual(_this2.controller.get('model'), { id: 'a-1' }); + assert.equal(_this2.controller.get('q'), 'lol'); + assert.equal(_this2.controller.get('z'), 0); + assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3'); + + _this2.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 }; + _this2.transitionTo(urlPrefix + '/a-2?q=lol'); + + assert.deepEqual(_this2.controller.get('model'), { id: 'a-2' }, 'controller\'s model changed to a-2'); + assert.equal(_this2.controller.get('q'), 'lol'); + assert.equal(_this2.controller.get('z'), 0); + assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); // fail + assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3'); + + _this2.expectedModelHookParams = { id: 'a-3', q: 'lol', z: 123 }; + _this2.transitionTo(urlPrefix + '/a-3?q=lol&z=123'); + + assert.equal(_this2.controller.get('q'), 'lol'); + assert.equal(_this2.controller.get('z'), 123); + assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3?q=lol&z=123'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest3 = function queryParamsStickyTest3(urlPrefix, articleLookup) { + var _this3 = this; + + var assert = this.assert; + + assert.expect(32); + + this.registerTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'' + articleLookup + '\' a.id id=a.id}} {{/each}}'); + + return this.boot().then(function () { + _this3.expectedModelHookParams = { id: 'a-1', q: 'wat', z: 0 }; + _this3.transitionTo(articleLookup, 'a-1'); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-1' }); + assert.equal(_this3.controller.get('q'), 'wat'); + assert.equal(_this3.controller.get('z'), 0); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3'); + + _this3.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 }; + _this3.transitionTo(articleLookup, 'a-2', { queryParams: { q: 'lol' } }); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-2' }); + assert.equal(_this3.controller.get('q'), 'lol'); + assert.equal(_this3.controller.get('z'), 0); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3'); + + _this3.expectedModelHookParams = { id: 'a-3', q: 'hay', z: 0 }; + _this3.transitionTo(articleLookup, 'a-3', { queryParams: { q: 'hay' } }); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-3' }); + assert.equal(_this3.controller.get('q'), 'hay'); + assert.equal(_this3.controller.get('z'), 0); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3?q=hay'); + + _this3.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 1 }; + _this3.transitionTo(articleLookup, 'a-2', { queryParams: { z: 1 } }); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-2' }); + assert.equal(_this3.controller.get('q'), 'lol'); + assert.equal(_this3.controller.get('z'), 1); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol&z=1'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3?q=hay'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest4 = function queryParamsStickyTest4(urlPrefix, articleLookup) { + var _this4 = this; + + var assert = this.assert; + + assert.expect(24); + + this.setupApplication(); + + this.reopenController(articleLookup, { + queryParams: { q: { scope: 'controller' } } + }); + + return this.visitApplication().then(function () { + _emberMetal.run(_this4.$link1, 'click'); + _this4.assertCurrentPath(urlPrefix + '/a-1'); + + _this4.setAndFlush(_this4.controller, 'q', 'lol'); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=lol'); + + _emberMetal.run(_this4.$link2, 'click'); + + assert.equal(_this4.controller.get('q'), 'lol'); + assert.equal(_this4.controller.get('z'), 0); + assert.deepEqual(_this4.controller.get('model'), { id: 'a-2' }); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=lol'); + + _this4.expectedModelHookParams = { id: 'a-3', q: 'haha', z: 123 }; + _this4.transitionTo(urlPrefix + '/a-3?q=haha&z=123'); + + assert.deepEqual(_this4.controller.get('model'), { id: 'a-3' }); + assert.equal(_this4.controller.get('q'), 'haha'); + assert.equal(_this4.controller.get('z'), 123); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=haha'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=haha'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=haha&z=123'); + + _this4.setAndFlush(_this4.controller, 'q', 'woot'); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=woot'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=woot'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=woot&z=123'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest5 = function queryParamsStickyTest5(urlPrefix, commentsLookupKey) { + var _this5 = this; + + var assert = this.assert; + + assert.expect(12); + + return this.boot().then(function () { + _this5.transitionTo(commentsLookupKey, 'a-1'); + + var commentsCtrl = _this5.getController(commentsLookupKey); + assert.equal(commentsCtrl.get('page'), 1); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments'); + + _this5.setAndFlush(commentsCtrl, 'page', 2); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments?page=2'); + + _this5.setAndFlush(commentsCtrl, 'page', 3); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments?page=3'); + + _this5.transitionTo(commentsLookupKey, 'a-2'); + assert.equal(commentsCtrl.get('page'), 1); + _this5.assertCurrentPath(urlPrefix + '/a-2/comments'); + + _this5.transitionTo(commentsLookupKey, 'a-1'); + assert.equal(commentsCtrl.get('page'), 3); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments?page=3'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest6 = function queryParamsStickyTest6(urlPrefix, articleLookup, commentsLookup) { + var _this6 = this; + + var assert = this.assert; + + assert.expect(13); + + this.setupApplication(); + + this.reopenRoute(articleLookup, { + resetController: function (controller, isExiting) { + this.controllerFor(commentsLookup).set('page', 1); + if (isExiting) { + controller.set('q', 'imdone'); + } + } + }); + + this.registerTemplate('about', '{{link-to \'A\' \'' + commentsLookup + '\' \'a-1\' id=\'one\'}} {{link-to \'B\' \'' + commentsLookup + '\' \'a-2\' id=\'two\'}}'); + + return this.visitApplication().then(function () { + _this6.transitionTo(commentsLookup, 'a-1'); + + var commentsCtrl = _this6.getController(commentsLookup); + assert.equal(commentsCtrl.get('page'), 1); + _this6.assertCurrentPath(urlPrefix + '/a-1/comments'); + + _this6.setAndFlush(commentsCtrl, 'page', 2); + _this6.assertCurrentPath(urlPrefix + '/a-1/comments?page=2'); + + _this6.transitionTo(commentsLookup, 'a-2'); + assert.equal(commentsCtrl.get('page'), 1); + assert.equal(_this6.controller.get('q'), 'wat'); + + _this6.transitionTo(commentsLookup, 'a-1'); + + _this6.assertCurrentPath(urlPrefix + '/a-1/comments'); + assert.equal(commentsCtrl.get('page'), 1); + + _this6.transitionTo('about'); + assert.equal(_emberViews.jQuery('#one').attr('href'), urlPrefix + '/a-1/comments?q=imdone'); + assert.equal(_emberViews.jQuery('#two').attr('href'), urlPrefix + '/a-2/comments'); + }); + }; + + return ModelDependentQPTestCase; + })(_internalTestHelpers.QueryParamTestCase); + + _internalTestHelpers.moduleFor('Query Params - model-dependent state', (function (_ModelDependentQPTestCase) { + babelHelpers.inherits(_class, _ModelDependentQPTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _ModelDependentQPTestCase.apply(this, arguments); + } + + _class.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('article', { path: '/a/:id' }, function () { + this.route('comments', { resetNamespace: true }); + }); + this.route('about'); + }); + + var articles = _emberRuntime.A([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + + this.registerController('application', _emberRuntime.Controller.extend({ + articles: articles + })); + + var self = this; + var assert = this.assert; + this.registerRoute('article', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedModelHookParams) { + assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedModelHookParams = null; + } + return articles.findBy('id', params.id); + } + })); + + this.registerController('article', _emberRuntime.Controller.extend({ + queryParams: ['q', 'z'], + q: 'wat', + z: 0 + })); + + this.registerController('comments', _emberRuntime.Controller.extend({ + queryParams: 'page', + page: 1 + })); + + this.registerTemplate('application', '{{#each articles as |a|}} 1{{link-to \'Article\' \'article\' a id=a.id}} {{/each}} {{outlet}}'); + }; + + _class.prototype.visitApplication = function visitApplication() { + var _this7 = this; + + return this.visit('/').then(function () { + var assert = _this7.assert; + + _this7.$link1 = _emberViews.jQuery('#a-1'); + _this7.$link2 = _emberViews.jQuery('#a-2'); + _this7.$link3 = _emberViews.jQuery('#a-3'); + + assert.equal(_this7.$link1.attr('href'), '/a/a-1'); + assert.equal(_this7.$link2.attr('href'), '/a/a-2'); + assert.equal(_this7.$link3.attr('href'), '/a/a-3'); + + _this7.controller = _this7.getController('article'); + }); + }; + + _class.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault() { + return this.queryParamsStickyTest1('/a'); + }; + + _class.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges() { + return this.queryParamsStickyTest2('/a'); + }; + + _class.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions() { + return this.queryParamsStickyTest3('/a', 'article'); + }; + + _class.prototype['@test \'controller\' stickiness shares QP state between models'] = function testControllerStickinessSharesQPStateBetweenModels() { + return this.queryParamsStickyTest4('/a', 'article'); + }; + + _class.prototype['@test \'model\' stickiness is scoped to current or first dynamic parent route'] = function testModelStickinessIsScopedToCurrentOrFirstDynamicParentRoute() { + return this.queryParamsStickyTest5('/a', 'comments'); + }; + + _class.prototype['@test can reset query params using the resetController hook'] = function testCanResetQueryParamsUsingTheResetControllerHook() { + return this.queryParamsStickyTest6('/a', 'article', 'comments'); + }; + + return _class; + })(ModelDependentQPTestCase)); + + _internalTestHelpers.moduleFor('Query Params - model-dependent state (nested)', (function (_ModelDependentQPTestCase2) { + babelHelpers.inherits(_class2, _ModelDependentQPTestCase2); + + function _class2() { + babelHelpers.classCallCheck(this, _class2); + + _ModelDependentQPTestCase2.apply(this, arguments); + } + + _class2.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('site', function () { + this.route('article', { path: '/a/:id' }, function () { + this.route('comments'); + }); + }); + this.route('about'); + }); + + var site_articles = _emberRuntime.A([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + + this.registerController('application', _emberRuntime.Controller.extend({ + articles: site_articles + })); + + var self = this; + var assert = this.assert; + this.registerRoute('site.article', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedModelHookParams) { + assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedModelHookParams = null; + } + return site_articles.findBy('id', params.id); + } + })); + + this.registerController('site.article', _emberRuntime.Controller.extend({ + queryParams: ['q', 'z'], + q: 'wat', + z: 0 + })); + + this.registerController('site.article.comments', _emberRuntime.Controller.extend({ + queryParams: 'page', + page: 1 + })); + + this.registerTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'site.article\' a id=a.id}} {{/each}} {{outlet}}'); + }; + + _class2.prototype.visitApplication = function visitApplication() { + var _this8 = this; + + return this.visit('/').then(function () { + var assert = _this8.assert; + + _this8.$link1 = _emberViews.jQuery('#a-1'); + _this8.$link2 = _emberViews.jQuery('#a-2'); + _this8.$link3 = _emberViews.jQuery('#a-3'); + + assert.equal(_this8.$link1.attr('href'), '/site/a/a-1'); + assert.equal(_this8.$link2.attr('href'), '/site/a/a-2'); + assert.equal(_this8.$link3.attr('href'), '/site/a/a-3'); + + _this8.controller = _this8.getController('site.article'); + }); + }; + + _class2.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault() { + return this.queryParamsStickyTest1('/site/a'); + }; + + _class2.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges() { + return this.queryParamsStickyTest2('/site/a'); + }; + + _class2.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions() { + return this.queryParamsStickyTest3('/site/a', 'site.article'); + }; + + _class2.prototype['@test \'controller\' stickiness shares QP state between models'] = function testControllerStickinessSharesQPStateBetweenModels() { + return this.queryParamsStickyTest4('/site/a', 'site.article'); + }; + + _class2.prototype['@test \'model\' stickiness is scoped to current or first dynamic parent route'] = function testModelStickinessIsScopedToCurrentOrFirstDynamicParentRoute() { + return this.queryParamsStickyTest5('/site/a', 'site.article.comments'); + }; + + _class2.prototype['@test can reset query params using the resetController hook'] = function testCanResetQueryParamsUsingTheResetControllerHook() { + return this.queryParamsStickyTest6('/site/a', 'site.article', 'site.article.comments'); + }; + + return _class2; + })(ModelDependentQPTestCase)); + + _internalTestHelpers.moduleFor('Query Params - model-dependent state (nested & more than 1 dynamic segment)', (function (_ModelDependentQPTestCase3) { + babelHelpers.inherits(_class3, _ModelDependentQPTestCase3); + + function _class3() { + babelHelpers.classCallCheck(this, _class3); + + _ModelDependentQPTestCase3.apply(this, arguments); + } + + _class3.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('site', { path: '/site/:site_id' }, function () { + this.route('article', { path: '/a/:article_id' }, function () { + this.route('comments'); + }); + }); + }); + + var sites = _emberRuntime.A([{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]); + var site_articles = _emberRuntime.A([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + + this.registerController('application', _emberRuntime.Controller.extend({ + siteArticles: site_articles, + sites: sites, + allSitesAllArticles: _emberMetal.computed({ + get: function () { + var ret = []; + var siteArticles = this.siteArticles; + var sites = this.sites; + sites.forEach(function (site) { + ret = ret.concat(siteArticles.map(function (article) { + return { id: site.id + '-' + article.id, site_id: site.id, article_id: article.id }; + })); + }); + return ret; + } + }) + })); + + var self = this; + var assert = this.assert; + this.registerRoute('site', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedSiteModelHookParams) { + assert.deepEqual(params, self.expectedSiteModelHookParams, 'the SiteRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedSiteModelHookParams = null; + } + return sites.findBy('id', params.site_id); + } + })); + + this.registerRoute('site.article', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedArticleModelHookParams) { + assert.deepEqual(params, self.expectedArticleModelHookParams, 'the SiteArticleRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedArticleModelHookParams = null; + } + return site_articles.findBy('id', params.article_id); + } + })); + + this.registerController('site', _emberRuntime.Controller.extend({ + queryParams: ['country'], + country: 'au' + })); + + this.registerController('site.article', _emberRuntime.Controller.extend({ + queryParams: ['q', 'z'], + q: 'wat', + z: 0 + })); + + this.registerController('site.article.comments', _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1 + })); + + this.registerTemplate('application', '{{#each allSitesAllArticles as |a|}} {{#link-to \'site.article\' a.site_id a.article_id id=a.id}}Article [{{a.site_id}}] [{{a.article_id}}]{{/link-to}} {{/each}} {{outlet}}'); + }; + + _class3.prototype.visitApplication = function visitApplication() { + var _this9 = this; + + return this.visit('/').then(function () { + var assert = _this9.assert; + + _this9.links = {}; + _this9.links['s-1-a-1'] = _emberViews.jQuery('#s-1-a-1'); + _this9.links['s-1-a-2'] = _emberViews.jQuery('#s-1-a-2'); + _this9.links['s-1-a-3'] = _emberViews.jQuery('#s-1-a-3'); + _this9.links['s-2-a-1'] = _emberViews.jQuery('#s-2-a-1'); + _this9.links['s-2-a-2'] = _emberViews.jQuery('#s-2-a-2'); + _this9.links['s-2-a-3'] = _emberViews.jQuery('#s-2-a-3'); + _this9.links['s-3-a-1'] = _emberViews.jQuery('#s-3-a-1'); + _this9.links['s-3-a-2'] = _emberViews.jQuery('#s-3-a-2'); + _this9.links['s-3-a-3'] = _emberViews.jQuery('#s-3-a-3'); + + assert.equal(_this9.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this9.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this9.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this9.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this9.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this9.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this9.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this9.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this9.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this9.site_controller = _this9.getController('site'); + _this9.article_controller = _this9.getController('site.article'); + }); + }; + + _class3.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault(assert) { + var _this10 = this; + + assert.expect(59); // Insane. + + return this.boot().then(function () { + _emberMetal.run(_this10.links['s-1-a-1'], 'click'); + assert.deepEqual(_this10.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this10.article_controller.get('model'), { id: 'a-1' }); + _this10.assertCurrentPath('/site/s-1/a/a-1'); + + _this10.setAndFlush(_this10.article_controller, 'q', 'lol'); + + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this10.setAndFlush(_this10.site_controller, 'country', 'us'); + + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _emberMetal.run(_this10.links['s-1-a-2'], 'click'); + + assert.equal(_this10.site_controller.get('country'), 'us'); + assert.equal(_this10.article_controller.get('q'), 'wat'); + assert.equal(_this10.article_controller.get('z'), 0); + assert.deepEqual(_this10.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this10.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _emberMetal.run(_this10.links['s-2-a-2'], 'click'); + + assert.equal(_this10.site_controller.get('country'), 'au'); + assert.equal(_this10.article_controller.get('q'), 'wat'); + assert.equal(_this10.article_controller.get('z'), 0); + assert.deepEqual(_this10.site_controller.get('model'), { id: 's-2' }); + assert.deepEqual(_this10.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + }); + }; + + _class3.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges(assert) { + var _this11 = this; + + assert.expect(88); // INSANE. + + return this.boot().then(function () { + _this11.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', z: 0 }; + _this11.transitionTo('/site/s-1/a/a-1?q=lol'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-1' }, 'site controller\'s model is s-1'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-1' }, 'article controller\'s model is a-1'); + assert.equal(_this11.site_controller.get('country'), 'au'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 0); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this11.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', z: 0 }; + _this11.transitionTo('/site/s-2/a/a-1?country=us&q=lol'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-1' }, 'article controller\'s model is a-1'); + assert.equal(_this11.site_controller.get('country'), 'us'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 0); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this11.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 0 }; + _this11.transitionTo('/site/s-2/a/a-2?country=us&q=lol'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-2' }, 'article controller\'s model is a-2'); + assert.equal(_this11.site_controller.get('country'), 'us'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 0); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this11.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', z: 123 }; + _this11.transitionTo('/site/s-2/a/a-3?country=us&q=lol&z=123'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-3' }, 'article controller\'s model is a-3'); + assert.equal(_this11.site_controller.get('country'), 'us'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 123); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=lol&z=123'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=lol&z=123'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=lol&z=123'); + + _this11.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', z: 123 }; + _this11.transitionTo('/site/s-3/a/a-3?country=nz&q=lol&z=123'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-3' }, 'site controller\'s model is s-3'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-3' }, 'article controller\'s model is a-3'); + assert.equal(_this11.site_controller.get('country'), 'nz'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 123); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=lol&z=123'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=lol&z=123'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?country=nz&q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?country=nz&q=lol'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?country=nz&q=lol&z=123'); + }); + }; + + _class3.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions(assert) { + var _this12 = this; + + assert.expect(118); // <-- INSANE! Like why is this even a thing? + + return this.boot().then(function () { + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-1', q: 'wat', z: 0 }; + _this12.transitionTo('site.article', 's-1', 'a-1'); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-1' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'wat'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 0 }; + _this12.transitionTo('site.article', 's-1', 'a-2', { queryParams: { q: 'lol' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'lol'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', z: 0 }; + _this12.transitionTo('site.article', 's-1', 'a-3', { queryParams: { q: 'hay' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-3' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'hay'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 1 }; + _this12.transitionTo('site.article', 's-1', 'a-2', { queryParams: { z: 1 } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'lol'); + assert.equal(_this12.article_controller.get('z'), 1); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 1 }; + _this12.transitionTo('site.article', 's-2', 'a-2', { queryParams: { country: 'us' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-2' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this12.site_controller.get('country'), 'us'); + assert.equal(_this12.article_controller.get('q'), 'lol'); + assert.equal(_this12.article_controller.get('z'), 1); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-1', q: 'yeah', z: 0 }; + _this12.transitionTo('site.article', 's-2', 'a-1', { queryParams: { q: 'yeah' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-2' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-1' }); + assert.equal(_this12.site_controller.get('country'), 'us'); + assert.equal(_this12.article_controller.get('q'), 'yeah'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=yeah'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=yeah'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=yeah'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', z: 3 }; + _this12.transitionTo('site.article', 's-3', 'a-3', { queryParams: { country: 'nz', z: 3 } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-3' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-3' }); + assert.equal(_this12.site_controller.get('country'), 'nz'); + assert.equal(_this12.article_controller.get('q'), 'hay'); + assert.equal(_this12.article_controller.get('z'), 3); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=yeah'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay&z=3'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=yeah'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay&z=3'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?country=nz&q=yeah'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?country=nz&q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?country=nz&q=hay&z=3'); + }); + }; + + return _class3; + })(ModelDependentQPTestCase)); +}); +enifed('ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/overlapping_query_params_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - overlapping query param property names', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.setupBase = function setupBase() { + this.router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + return this.visit('/parent/child'); + }; + + _class.prototype['@test can remap same-named qp props'] = function testCanRemapSameNamedQpProps(assert) { + var _this = this; + + assert.expect(7); + + this.setMappedQPController('parent'); + this.setMappedQPController('parent.child', 'page', 'childPage'); + + return this.setupBase().then(function () { + _this.assertCurrentPath('/parent/child'); + + var parentController = _this.getController('parent'); + var parentChildController = _this.getController('parent.child'); + + _this.setAndFlush(parentController, 'page', 2); + _this.assertCurrentPath('/parent/child?parentPage=2'); + _this.setAndFlush(parentController, 'page', 1); + _this.assertCurrentPath('/parent/child'); + + _this.setAndFlush(parentChildController, 'page', 2); + _this.assertCurrentPath('/parent/child?childPage=2'); + _this.setAndFlush(parentChildController, 'page', 1); + _this.assertCurrentPath('/parent/child'); + + _emberMetal.run(function () { + parentController.set('page', 2); + parentChildController.set('page', 2); + }); + + _this.assertCurrentPath('/parent/child?childPage=2&parentPage=2'); + + _emberMetal.run(function () { + parentController.set('page', 1); + parentChildController.set('page', 1); + }); + + _this.assertCurrentPath('/parent/child'); + }); + }; + + _class.prototype['@test query params can be either controller property or url key'] = function testQueryParamsCanBeEitherControllerPropertyOrUrlKey(assert) { + var _this2 = this; + + assert.expect(3); + + this.setMappedQPController('parent'); + + return this.setupBase().then(function () { + _this2.assertCurrentPath('/parent/child'); + + _this2.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this2.assertCurrentPath('/parent/child?parentPage=2'); + + _this2.transitionTo('parent.child', { queryParams: { parentPage: 3 } }); + _this2.assertCurrentPath('/parent/child?parentPage=3'); + }); + }; + + _class.prototype['@test query param matching a url key and controller property'] = function testQueryParamMatchingAUrlKeyAndControllerProperty(assert) { + var _this3 = this; + + assert.expect(3); + + this.setMappedQPController('parent', 'page', 'parentPage'); + this.setMappedQPController('parent.child', 'index', 'page'); + + return this.setupBase().then(function () { + _this3.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this3.assertCurrentPath('/parent/child?parentPage=2'); + + _this3.transitionTo('parent.child', { queryParams: { parentPage: 3 } }); + _this3.assertCurrentPath('/parent/child?parentPage=3'); + + _this3.transitionTo('parent.child', { queryParams: { index: 2, page: 2 } }); + _this3.assertCurrentPath('/parent/child?page=2&parentPage=2'); + }); + }; + + _class.prototype['@test query param matching same property on two controllers use the urlKey higher in the chain'] = function testQueryParamMatchingSamePropertyOnTwoControllersUseTheUrlKeyHigherInTheChain(assert) { + var _this4 = this; + + assert.expect(4); + + this.setMappedQPController('parent', 'page', 'parentPage'); + this.setMappedQPController('parent.child', 'page', 'childPage'); + + return this.setupBase().then(function () { + _this4.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this4.assertCurrentPath('/parent/child?parentPage=2'); + + _this4.transitionTo('parent.child', { queryParams: { parentPage: 3 } }); + _this4.assertCurrentPath('/parent/child?parentPage=3'); + + _this4.transitionTo('parent.child', { queryParams: { childPage: 2, page: 2 } }); + _this4.assertCurrentPath('/parent/child?childPage=2&parentPage=2'); + + _this4.transitionTo('parent.child', { queryParams: { childPage: 3, parentPage: 4 } }); + _this4.assertCurrentPath('/parent/child?childPage=3&parentPage=4'); + }); + }; + + _class.prototype['@test query params does not error when a query parameter exists for route instances that share a controller'] = function testQueryParamsDoesNotErrorWhenAQueryParameterExistsForRouteInstancesThatShareAController(assert) { + var _this5 = this; + + assert.expect(1); + + var parentController = _emberRuntime.Controller.extend({ + queryParams: { page: 'page' } + }); + this.registerController('parent', parentController); + this.registerRoute('parent.child', _emberRouting.Route.extend({ controllerName: 'parent' })); + + return this.setupBase('/parent').then(function () { + _this5.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this5.assertCurrentPath('/parent/child?page=2'); + }); + }; + + _class.prototype['@test query params in the same route hierarchy with the same url key get auto-scoped'] = function testQueryParamsInTheSameRouteHierarchyWithTheSameUrlKeyGetAutoScoped(assert) { + var _this6 = this; + + assert.expect(1); + + this.setMappedQPController('parent'); + this.setMappedQPController('parent.child'); + + expectAssertion(function () { + _this6.setupBase(); + }, 'You\'re not allowed to have more than one controller property map to the same query param key, but both `parent:page` and `parent.child:page` map to `parentPage`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `page: { as: \'other-page\' }`'); + }; + + _class.prototype['@test Support shared but overridable mixin pattern'] = function testSupportSharedButOverridableMixinPattern(assert) { + var _this7 = this; + + assert.expect(7); + + var HasPage = _emberMetal.Mixin.create({ + queryParams: 'page', + page: 1 + }); + + this.registerController('parent', _emberRuntime.Controller.extend(HasPage, { + queryParams: { page: 'yespage' } + })); + + this.registerController('parent.child', _emberRuntime.Controller.extend(HasPage)); + + return this.setupBase().then(function () { + _this7.assertCurrentPath('/parent/child'); + + var parentController = _this7.getController('parent'); + var parentChildController = _this7.getController('parent.child'); + + _this7.setAndFlush(parentChildController, 'page', 2); + _this7.assertCurrentPath('/parent/child?page=2'); + assert.equal(parentController.get('page'), 1); + assert.equal(parentChildController.get('page'), 2); + + _this7.setAndFlush(parentController, 'page', 2); + _this7.assertCurrentPath('/parent/child?page=2&yespage=2'); + assert.equal(parentController.get('page'), 2); + assert.equal(parentChildController.get('page'), 2); + }); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/overlapping_query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/overlapping_query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/overlapping_query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/query_param_async_get_handler_test', ['exports', 'ember-runtime', 'ember-routing', 'internal-test-helpers'], function (exports, _emberRuntime, _emberRouting, _internalTestHelpers) { + 'use strict'; + + // These tests mimic what happens with lazily loaded Engines. + _internalTestHelpers.moduleFor('Query Params - async get handler', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype['@test can render a link to an asynchronously loaded route without fetching the route'] = function testCanRenderALinkToAnAsynchronouslyLoadedRouteWithoutFetchingTheRoute(assert) { + var _this = this; + + assert.expect(4); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }); + }); + + this.setSingleQPController('post'); + + var setupAppTemplate = function () { + _this.registerTemplate('application', '\n {{link-to \'Post\' \'post\' 1337 (query-params foo=\'bar\') class=\'post-link\'}}\n {{link-to \'Post\' \'post\' 7331 (query-params foo=\'boo\') class=\'post-link\'}}\n {{outlet}}\n '); + }; + + setupAppTemplate(); + + return this.visitAndAssert('/').then(function () { + assert.equal(_this.$('.post-link').eq(0).attr('href'), '/post/1337?foo=bar', 'renders correctly with default QP value'); + assert.equal(_this.$('.post-link').eq(1).attr('href'), '/post/7331?foo=boo', 'renders correctly with non-default QP value'); + assert.deepEqual(_this.fetchedHandlers, ['application', 'index'], 'only fetched the handlers for the route we\'re on'); + }); + }; + + _class.prototype['@test can transitionTo to an asynchronously loaded route with simple query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithSimpleQueryParams(assert) { + var _this2 = this; + + assert.expect(6); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }); + this.route('posts'); + }); + + this.setSingleQPController('post'); + + var postController = undefined; + return this.visitAndAssert('/').then(function () { + postController = _this2.getController('post'); + + return _this2.transitionTo('posts').then(function () { + _this2.assertCurrentPath('/posts'); + }); + }).then(function () { + return _this2.transitionTo('post', 1337, { queryParams: { foo: 'boo' } }).then(function () { + assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly set on controller'); + _this2.assertCurrentPath('/post/1337?foo=boo'); + }); + }).then(function () { + return _this2.transitionTo('post', 1337, { queryParams: { foo: 'bar' } }).then(function () { + assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly set with default value'); + _this2.assertCurrentPath('/post/1337'); + }); + }); + }; + + _class.prototype['@test can transitionTo to an asynchronously loaded route with array query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithArrayQueryParams(assert) { + var _this3 = this; + + assert.expect(5); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }); + }); + + this.setSingleQPController('post', 'comments', []); + + var postController = undefined; + return this.visitAndAssert('/').then(function () { + postController = _this3.getController('post'); + return _this3.transitionTo('post', 1337, { queryParams: { comments: [1, 2] } }).then(function () { + assert.deepEqual(postController.get('comments'), [1, 2], 'array QP is correctly set with default value'); + _this3.assertCurrentPath('/post/1337?comments=%5B1%2C2%5D'); + }); + }).then(function () { + return _this3.transitionTo('post', 1338).then(function () { + assert.deepEqual(postController.get('comments'), [], 'array QP is correctly set on controller'); + _this3.assertCurrentPath('/post/1338'); + }); + }); + }; + + _class.prototype['@test can transitionTo to an asynchronously loaded route with mapped query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithMappedQueryParams(assert) { + var _this4 = this; + + assert.expect(7); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }, function () { + this.route('index', { path: '/' }); + }); + }); + + this.setSingleQPController('post'); + this.setMappedQPController('post.index', 'comment', 'note'); + + var postController = undefined; + var postIndexController = undefined; + + return this.visitAndAssert('/').then(function () { + postController = _this4.getController('post'); + postIndexController = _this4.getController('post.index'); + + return _this4.transitionTo('post.index', 1337, { queryParams: { note: 6, foo: 'boo' } }).then(function () { + assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly set on controller'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP is correctly set on controller'); + _this4.assertCurrentPath('/post/1337?foo=boo¬e=6'); + }); + }).then(function () { + return _this4.transitionTo('post', 1337, { queryParams: { foo: 'bar' } }).then(function () { + assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly set with default value'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP retains value scoped to model'); + _this4.assertCurrentPath('/post/1337?note=6'); + }); + }); + }; + + _class.prototype['@test can transitionTo with a URL'] = function testCanTransitionToWithAURL(assert) { + var _this5 = this; + + assert.expect(7); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }, function () { + this.route('index', { path: '/' }); + }); + }); + + this.setSingleQPController('post'); + this.setMappedQPController('post.index', 'comment', 'note'); + + var postController = undefined; + var postIndexController = undefined; + + return this.visitAndAssert('/').then(function () { + postController = _this5.getController('post'); + postIndexController = _this5.getController('post.index'); + + return _this5.transitionTo('/post/1337?foo=boo¬e=6').then(function () { + assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly deserialized on controller'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP is correctly deserialized on controller'); + _this5.assertCurrentPath('/post/1337?foo=boo¬e=6'); + }); + }).then(function () { + return _this5.transitionTo('/post/1337?note=6').then(function () { + assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly deserialized with default value'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP retains value scoped to model'); + _this5.assertCurrentPath('/post/1337?note=6'); + }); + }); + }; + + _class.prototype['@test undefined isn\'t serialized or deserialized into a string'] = function testUndefinedIsnTSerializedOrDeserializedIntoAString(assert) { + var _this6 = this; + + assert.expect(4); + + this.router.map(function () { + this.route('example'); + }); + + this.registerTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); + + this.setSingleQPController('example', 'foo', undefined, { + foo: undefined + }); + + this.registerRoute('example', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: undefined }); + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(_this6.$('#the-link').attr('href'), '/example', 'renders without undefined qp serialized'); + + return _this6.transitionTo('example', { queryParams: { foo: undefined } }).then(function () { + _this6.assertCurrentPath('/example'); + }); + }); + }; + + babelHelpers.createClass(_class, [{ + key: 'routerOptions', + get: function () { + var fetchedHandlers = this.fetchedHandlers = []; + + return { + location: 'test', + + _getQPMeta: function (handlerInfo) { + return this._bucketCache.lookup('route-meta', handlerInfo.name); + }, + + _getHandlerFunction: function () { + var getHandler = this._super.apply(this, arguments); + var cache = {}; + + return function (routeName) { + fetchedHandlers.push(routeName); + + // Cache the returns so we don't have more than one Promise for a + // given handler. + return cache[routeName] || (cache[routeName] = new _emberRuntime.RSVP.Promise(function (resolve) { + setTimeout(function () { + return resolve(getHandler(routeName)); + }, 10); + })); + }; + } + }; + } + }]); + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/query_param_async_get_handler_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/query_param_async_get_handler_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/query_param_async_get_handler_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/query_params_paramless_link_to_test', ['exports', 'ember-runtime', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _emberViews, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - paramless link-to', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.testParamlessLinks = function testParamlessLinks(assert, routeName) { + assert.expect(1); + + this.registerTemplate(routeName, '{{link-to \'index\' \'index\' id=\'index-link\'}}'); + + this.registerController(routeName, _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: 'wat' + })); + + return this.visit('/?foo=YEAH').then(function () { + assert.equal(_emberViews.jQuery('#index-link').attr('href'), '/?foo=YEAH'); + }); + }; + + _class.prototype['@test param-less links in an app booted with query params in the URL don\'t reset the query params: application'] = function testParamLessLinksInAnAppBootedWithQueryParamsInTheURLDonTResetTheQueryParamsApplication(assert) { + return this.testParamlessLinks(assert, 'application'); + }; + + _class.prototype['@test param-less links in an app booted with query params in the URL don\'t reset the query params: index'] = function testParamLessLinksInAnAppBootedWithQueryParamsInTheURLDonTResetTheQueryParamsIndex(assert) { + return this.testParamlessLinks(assert, 'index'); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/query_params_paramless_link_to_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/shared_state_test', ['exports', 'ember-runtime', 'ember', 'ember-metal', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _ember, _emberMetal, _emberViews, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - shared service state', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.boot = function boot() { + this.setupApplication(); + return this.visitApplication(); + }; + + _class.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('home', { path: '/' }); + this.route('dashboard'); + }); + + this.application.register('service:filters', _emberRuntime.Service.extend({ + shared: true + })); + + this.registerController('home', _emberRuntime.Controller.extend({ + filters: _ember.default.inject.service() + })); + + this.registerController('dashboard', _emberRuntime.Controller.extend({ + filters: _ember.default.inject.service(), + queryParams: [{ 'filters.shared': 'shared' }] + })); + + this.registerTemplate('application', '{{link-to \'Home\' \'home\' }}
    {{outlet}}
    '); + this.registerTemplate('home', '{{link-to \'Dashboard\' \'dashboard\' }}{{input type="checkbox" id=\'filters-checkbox\' checked=(mut filters.shared) }}'); + this.registerTemplate('dashboard', '{{link-to \'Home\' \'home\' }}'); + }; + + _class.prototype.visitApplication = function visitApplication() { + return this.visit('/'); + }; + + _class.prototype['@test can modify shared state before transition'] = function testCanModifySharedStateBeforeTransition(assert) { + var _this = this; + + assert.expect(1); + + return this.boot().then(function () { + _this.$input = _emberViews.jQuery('#filters-checkbox'); + + // click the checkbox once to set filters.shared to false + _emberMetal.run(_this.$input, 'click'); + + return _this.visit('/dashboard').then(function () { + assert.ok(true, 'expecting navigating to dashboard to succeed'); + }); + }); + }; + + _class.prototype['@test can modify shared state back to the default value before transition'] = function testCanModifySharedStateBackToTheDefaultValueBeforeTransition(assert) { + var _this2 = this; + + assert.expect(1); + + return this.boot().then(function () { + _this2.$input = _emberViews.jQuery('#filters-checkbox'); + + // click the checkbox twice to set filters.shared to false and back to true + _emberMetal.run(_this2.$input, 'click'); + _emberMetal.run(_this2.$input, 'click'); + + return _this2.visit('/dashboard').then(function () { + assert.ok(true, 'expecting navigating to dashboard to succeed'); + }); + }); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/shared_state_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/shared_state_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/shared_state_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_map_test', ['exports', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-routing', 'ember-views', 'ember-glimmer'], function (exports, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberRouting, _emberViews, _emberGlimmer) { + 'use strict'; + + var router = undefined, + App = undefined, + container = undefined; + + function bootApplication() { + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function handleURL(path) { + return _emberMetal.run(function () { + return router.handleURL(path).then(function (value) { + ok(true, 'url: `' + path + '` was handled'); + return value; + }, function (reason) { + ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason)); + throw reason; + }); + }); + } + + QUnit.module('Router.map', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + container = App.__container__; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + + _emberGlimmer.setTemplates({}); + }); + } + }); + + QUnit.test('Router.map returns an Ember Router class', function () { + expect(1); + + var ret = App.Router.map(function () { + this.route('hello'); + }); + + ok(_emberRouting.Router.detect(ret)); + }); + + QUnit.test('Router.map can be called multiple times', function () { + expect(4); + + _emberGlimmer.setTemplate('hello', _emberTemplateCompiler.compile('Hello!')); + _emberGlimmer.setTemplate('goodbye', _emberTemplateCompiler.compile('Goodbye!')); + + App.Router.map(function () { + this.route('hello'); + }); + + App.Router.map(function () { + this.route('goodbye'); + }); + + bootApplication(); + + handleURL('/hello'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'Hello!', 'The hello template was rendered'); + + handleURL('/goodbye'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'Goodbye!', 'The goodbye template was rendered'); + }); +}); +enifed('ember/tests/routing/router_map_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_map_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_map_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/basic_test', ['exports', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers'], function (exports, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + _internalTestHelpers.moduleFor('Router Service - main', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RouterTestCase.apply(this, arguments); + } + + _class.prototype['@test RouterService#currentRouteName is correctly set for top level route'] = function testRouterServiceCurrentRouteNameIsCorrectlySetForTopLevelRoute(assert) { + var _this = this; + + assert.expect(1); + + return this.visit('/').then(function () { + assert.equal(_this.routerService.get('currentRouteName'), 'parent.index'); + }); + }; + + _class.prototype['@test RouterService#currentRouteName is correctly set for child route'] = function testRouterServiceCurrentRouteNameIsCorrectlySetForChildRoute(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + assert.equal(_this2.routerService.get('currentRouteName'), 'parent.child'); + }); + }; + + _class.prototype['@test RouterService#currentRouteName is correctly set after transition'] = function testRouterServiceCurrentRouteNameIsCorrectlySetAfterTransition(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + assert.equal(_this3.routerService.get('currentRouteName'), 'parent.sister'); + }); + }; + + _class.prototype['@test RouterService#currentRouteName is correctly set on each transition'] = function testRouterServiceCurrentRouteNameIsCorrectlySetOnEachTransition(assert) { + var _this4 = this; + + assert.expect(3); + + return this.visit('/child').then(function () { + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.child'); + + return _this4.visit('/sister'); + }).then(function () { + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.sister'); + + return _this4.visit('/brother'); + }).then(function () { + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.brother'); + }); + }; + + _class.prototype['@test RouterService#rootURL is correctly set to the default value'] = function testRouterServiceRootURLIsCorrectlySetToTheDefaultValue(assert) { + var _this5 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + assert.equal(_this5.routerService.get('rootURL'), '/'); + }); + }; + + _class.prototype['@test RouterService#rootURL is correctly set to a custom value'] = function testRouterServiceRootURLIsCorrectlySetToACustomValue(assert) { + var _this6 = this; + + assert.expect(1); + + this.registerRoute('parent.index', _emberRouting.Route.extend({ + init: function () { + this._super(); + _emberMetal.set(this.router, 'rootURL', '/homepage'); + } + })); + + return this.visit('/').then(function () { + assert.equal(_this6.routerService.get('rootURL'), '/homepage'); + }); + }; + + _class.prototype['@test RouterService#location is correctly delegated from router:main'] = function testRouterServiceLocationIsCorrectlyDelegatedFromRouterMain(assert) { + var _this7 = this; + + assert.expect(2); + + return this.visit('/').then(function () { + var location = _this7.routerService.get('location'); + assert.ok(location); + assert.ok(location instanceof _emberRouting.NoneLocation); + }); + }; + + return _class; + })(_internalTestHelpers.RouterTestCase)); + } +}); +enifed('ember/tests/routing/router_service_test/basic_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/basic_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/basic_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/currenturl_lifecycle_test', ['exports', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers'], function (exports, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + (function () { + var results = []; + var ROUTE_NAMES = ['index', 'child', 'sister', 'brother']; + + var InstrumentedRoute = _emberRouting.Route.extend({ + routerService: _emberRuntime.inject.service('router'), + + beforeModel: function () { + var service = _emberMetal.get(this, 'routerService'); + results.push([service.get('currentRouteName'), 'beforeModel', service.get('currentURL')]); + }, + + model: function () { + var service = _emberMetal.get(this, 'routerService'); + results.push([service.get('currentRouteName'), 'model', service.get('currentURL')]); + }, + + afterModel: function () { + var service = _emberMetal.get(this, 'routerService'); + results.push([service.get('currentRouteName'), 'afterModel', service.get('currentURL')]); + } + }); + + _internalTestHelpers.moduleFor('Router Service - currentURL', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + var _this = this; + + babelHelpers.classCallCheck(this, _class); + + _RouterTestCase.call(this); + + results = []; + + ROUTE_NAMES.forEach(function (name) { + var routeName = 'parent.' + name; + _this.registerRoute(routeName, InstrumentedRoute.extend()); + _this.registerTemplate(routeName, '{{current-url}}'); + }); + + this.registerComponent('current-url', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + currentURL: _emberRuntime.readOnly('routerService.currentURL') + }), + template: '{{currentURL}}' + }); + } + + _class.prototype['@test RouterService#currentURL is correctly set for top level route'] = function testRouterServiceCurrentURLIsCorrectlySetForTopLevelRoute(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + assert.equal(_this2.routerService.get('currentURL'), '/'); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set for child route'] = function testRouterServiceCurrentURLIsCorrectlySetForChildRoute(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + assert.equal(_this3.routerService.get('currentURL'), '/child'); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set after transition'] = function testRouterServiceCurrentURLIsCorrectlySetAfterTransition(assert) { + var _this4 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + return _this4.routerService.transitionTo('parent.sister'); + }).then(function () { + assert.equal(_this4.routerService.get('currentURL'), '/sister'); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set on each transition'] = function testRouterServiceCurrentURLIsCorrectlySetOnEachTransition(assert) { + var _this5 = this; + + assert.expect(3); + + return this.visit('/child').then(function () { + assert.equal(_this5.routerService.get('currentURL'), '/child'); + + return _this5.visit('/sister'); + }).then(function () { + assert.equal(_this5.routerService.get('currentURL'), '/sister'); + + return _this5.visit('/brother'); + }).then(function () { + assert.equal(_this5.routerService.get('currentURL'), '/brother'); + }); + }; + + _class.prototype['@test RouterService#currentURL is not set during lifecycle hooks'] = function testRouterServiceCurrentURLIsNotSetDuringLifecycleHooks(assert) { + var _this6 = this; + + assert.expect(2); + + return this.visit('/').then(function () { + assert.deepEqual(results, [[null, 'beforeModel', null], [null, 'model', null], [null, 'afterModel', null]]); + + results = []; + + return _this6.visit('/child'); + }).then(function () { + assert.deepEqual(results, [['parent.index', 'beforeModel', '/'], ['parent.index', 'model', '/'], ['parent.index', 'afterModel', '/']]); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set with component after consecutive visits'] = function testRouterServiceCurrentURLIsCorrectlySetWithComponentAfterConsecutiveVisits(assert) { + var _this7 = this; + + assert.expect(3); + + return this.visit('/').then(function () { + _this7.assertText('/'); + + return _this7.visit('/child'); + }).then(function () { + _this7.assertText('/child'); + + return _this7.visit('/'); + }).then(function () { + _this7.assertText('/'); + }); + }; + + return _class; + })(_internalTestHelpers.RouterTestCase)); + })(); + } +}); +enifed('ember/tests/routing/router_service_test/currenturl_lifecycle_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/currenturl_lifecycle_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/currenturl_lifecycle_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/replaceWith_test', ['exports', 'ember-routing', 'internal-test-helpers', 'router', 'ember-metal'], function (exports, _emberRouting, _internalTestHelpers, _router, _emberMetal) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + _internalTestHelpers.moduleFor('Router Service - replaceWith', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RouterTestCase.call(this); + + var testCase = this; + testCase.state = []; + + this.application.register('location:test', _emberRouting.NoneLocation.extend({ + setURL: function (path) { + testCase.state.push(path); + this.set('path', path); + }, + + replaceURL: function (path) { + testCase.state.splice(testCase.state.length - 1, 1, path); + this.set('path', path); + } + })); + } + + _class.prototype['@test RouterService#replaceWith returns a Transition'] = function testRouterServiceReplaceWithReturnsATransition(assert) { + var _this = this; + + assert.expect(1); + + var transition = undefined; + + return this.visit('/').then(function () { + transition = _this.routerService.replaceWith('parent.child'); + + assert.ok(transition instanceof _router.Transition); + + return transition; + }); + }; + + _class.prototype['@test RouterService#replaceWith with basic route replaces location'] = function testRouterServiceReplaceWithWithBasicRouteReplacesLocation(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this2.routerService.transitionTo('parent.child'); + }).then(function () { + return _this2.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this2.routerService.replaceWith('parent.brother'); + }).then(function () { + assert.deepEqual(_this2.state, ['/', '/child', '/brother']); + }); + }; + + _class.prototype['@test RouterService#replaceWith transitioning back to previously visited route replaces location'] = function testRouterServiceReplaceWithTransitioningBackToPreviouslyVisitedRouteReplacesLocation(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this3.routerService.transitionTo('parent.child'); + }).then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this3.routerService.transitionTo('parent.brother'); + }).then(function () { + return _this3.routerService.replaceWith('parent.sister'); + }).then(function () { + assert.deepEqual(_this3.state, ['/', '/child', '/sister', '/sister']); + }); + }; + + babelHelpers.createClass(_class, [{ + key: 'routerOptions', + get: function () { + return { + location: 'test' + }; + } + }]); + return _class; + })(_internalTestHelpers.RouterTestCase)); + } +}); +enifed('ember/tests/routing/router_service_test/replaceWith_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/replaceWith_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/replaceWith_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/transitionTo_test', ['exports', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers', 'router'], function (exports, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers, _router) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + _internalTestHelpers.moduleFor('Router Service - transitionTo', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + babelHelpers.classCallCheck(this, _class); + + _RouterTestCase.call(this); + + var testCase = this; + testCase.state = []; + + this.application.register('location:test', _emberRouting.NoneLocation.extend({ + setURL: function (path) { + testCase.state.push(path); + this.set('path', path); + }, + + replaceURL: function (path) { + testCase.state.splice(testCase.state.length - 1, 1, path); + this.set('path', path); + } + })); + } + + _class.prototype['@test RouterService#transitionTo returns a Transition'] = function testRouterServiceTransitionToReturnsATransition(assert) { + var _this = this; + + assert.expect(1); + + var transition = undefined; + + return this.visit('/').then(function () { + transition = _this.routerService.transitionTo('parent.child'); + + assert.ok(transition instanceof _router.Transition); + + return transition; + }); + }; + + _class.prototype['@test RouterService#transitionTo with basic route updates location'] = function testRouterServiceTransitionToWithBasicRouteUpdatesLocation(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this2.routerService.transitionTo('parent.child'); + }).then(function () { + return _this2.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this2.routerService.transitionTo('parent.brother'); + }).then(function () { + assert.deepEqual(_this2.state, ['/', '/child', '/sister', '/brother']); + }); + }; + + _class.prototype['@test RouterService#transitionTo transitioning back to previously visited route updates location'] = function testRouterServiceTransitionToTransitioningBackToPreviouslyVisitedRouteUpdatesLocation(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this3.routerService.transitionTo('parent.child'); + }).then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this3.routerService.transitionTo('parent.brother'); + }).then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + assert.deepEqual(_this3.state, ['/', '/child', '/sister', '/brother', '/sister']); + }); + }; + + _class.prototype['@test RouterService#transitionTo with basic route'] = function testRouterServiceTransitionToWithBasicRoute(assert) { + var _this4 = this; + + assert.expect(1); + + var componentInstance = undefined; + + this.registerTemplate('parent.index', '{{foo-bar}}'); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + init: function () { + this._super(); + componentInstance = this; + }, + actions: { + transitionToSister: function () { + _emberMetal.get(this, 'routerService').transitionTo('parent.sister'); + } + } + }), + template: 'foo-bar' + }); + + return this.visit('/').then(function () { + _emberMetal.run(function () { + componentInstance.send('transitionToSister'); + }); + + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.sister'); + }); + }; + + _class.prototype['@test RouterService#transitionTo with dynamic segment'] = function testRouterServiceTransitionToWithDynamicSegment(assert) { + var _this5 = this; + + assert.expect(3); + + var componentInstance = undefined; + var dynamicModel = { id: 1, contents: 'much dynamicism' }; + + this.registerTemplate('parent.index', '{{foo-bar}}'); + this.registerTemplate('dynamic', '{{model.contents}}'); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + init: function () { + this._super(); + componentInstance = this; + }, + actions: { + transitionToDynamic: function () { + _emberMetal.get(this, 'routerService').transitionTo('dynamic', dynamicModel); + } + } + }), + template: 'foo-bar' + }); + + return this.visit('/').then(function () { + _emberMetal.run(function () { + componentInstance.send('transitionToDynamic'); + }); + + assert.equal(_this5.routerService.get('currentRouteName'), 'dynamic'); + assert.equal(_this5.routerService.get('currentURL'), '/dynamic/1'); + _this5.assertText('much dynamicism'); + }); + }; + + _class.prototype['@test RouterService#transitionTo with dynamic segment and model hook'] = function testRouterServiceTransitionToWithDynamicSegmentAndModelHook(assert) { + var _this6 = this; + + assert.expect(3); + + var componentInstance = undefined; + var dynamicModel = { id: 1, contents: 'much dynamicism' }; + + this.registerRoute('dynamic', _emberRouting.Route.extend({ + model: function () { + return dynamicModel; + } + })); + + this.registerTemplate('parent.index', '{{foo-bar}}'); + this.registerTemplate('dynamic', '{{model.contents}}'); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + init: function () { + this._super(); + componentInstance = this; + }, + actions: { + transitionToDynamic: function () { + _emberMetal.get(this, 'routerService').transitionTo('dynamic', 1); + } + } + }), + template: 'foo-bar' + }); + + return this.visit('/').then(function () { + _emberMetal.run(function () { + componentInstance.send('transitionToDynamic'); + }); + + assert.equal(_this6.routerService.get('currentRouteName'), 'dynamic'); + assert.equal(_this6.routerService.get('currentURL'), '/dynamic/1'); + _this6.assertText('much dynamicism'); + }); + }; + + babelHelpers.createClass(_class, [{ + key: 'routerOptions', + get: function () { + return { + location: 'test' + }; + } + }]); + return _class; + })(_internalTestHelpers.RouterTestCase)); + } +}); +enifed('ember/tests/routing/router_service_test/transitionTo_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/transitionTo_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/transitionTo_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/substates_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-glimmer'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberViews, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + templates = undefined, + router = undefined, + container = undefined, + counter = undefined; + + function step(expectedValue, description) { + equal(counter, expectedValue, 'Step ' + expectedValue + ': ' + description); + counter++; + } + + function bootApplication(startingURL) { + for (var _name in templates) { + _emberGlimmer.setTemplate(_name, _emberTemplateCompiler.compile(templates[_name])); + } + + if (startingURL) { + _emberRouting.NoneLocation.reopen({ + path: startingURL + }); + } + + startingURL = startingURL || ''; + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + QUnit.module('Loading/Error Substates', { + setup: function () { + counter = 1; + + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture', + // fake a modules resolver + Resolver: _emberApplication.Resolver.extend({ moduleBasedResolver: true }) + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + Router = App.Router; + + container = App.__container__; + + templates = { + application: '
    {{outlet}}
    ', + index: 'INDEX', + loading: 'LOADING', + bro: 'BRO', + sis: 'SIS' + }; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + + _emberGlimmer.setTemplates({}); + }); + + _emberRouting.NoneLocation.reopen({ + path: '' + }); + } + }); + + QUnit.test('Slow promise from a child route of application enters nested loading state', function () { + var broModel = {}; + var broDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('bro'); + }); + + App.ApplicationRoute = _emberRouting.Route.extend({ + setupController: function () { + step(2, 'ApplicationRoute#setup'); + } + }); + + App.BroRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'BroRoute#model'); + return broDeferred.promise; + } + }); + + bootApplication('/bro'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'LOADING', 'The Loading template is nested in application template\'s outlet'); + + _emberMetal.run(broDeferred, 'resolve', broModel); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'BRO', 'bro template has loaded and replaced loading template'); + }); + + QUnit.test('Slow promises waterfall on startup', function () { + expect(7); + + var grandmaDeferred = _emberRuntime.RSVP.defer(); + var sallyDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + templates.grandma = 'GRANDMA {{outlet}}'; + templates.mom = 'MOM {{outlet}}'; + templates['mom/loading'] = 'MOMLOADING'; + templates['mom/sally'] = 'SALLY'; + + App.GrandmaRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'GrandmaRoute#model'); + return grandmaDeferred.promise; + } + }); + + App.MomRoute = _emberRouting.Route.extend({ + model: function () { + step(2, 'Mom#model'); + return {}; + } + }); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(3, 'SallyRoute#model'); + return sallyDeferred.promise; + }, + setupController: function () { + step(4, 'SallyRoute#setupController'); + } + }); + + bootApplication('/grandma/mom/sally'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'LOADING', 'The Loading template is nested in application template\'s outlet'); + + _emberMetal.run(grandmaDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM MOMLOADING', 'Mom\'s child loading route is displayed due to sally\'s slow promise'); + + _emberMetal.run(sallyDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM SALLY', 'Sally template displayed'); + }); + + QUnit.test('ApplicationRoute#currentPath reflects loading state path', function () { + expect(4); + + var momDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom'); + }); + }); + + templates.grandma = 'GRANDMA {{outlet}}'; + templates['grandma/loading'] = 'GRANDMALOADING'; + templates['grandma/mom'] = 'MOM'; + + App.GrandmaMomRoute = _emberRouting.Route.extend({ + model: function () { + return momDeferred.promise; + } + }); + + bootApplication('/grandma/mom'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA GRANDMALOADING'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.loading', 'currentPath reflects loading state'); + + _emberMetal.run(momDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM'); + equal(appController.get('currentPath'), 'grandma.mom', 'currentPath reflects final state'); + }); + + QUnit.test('Slow promises returned from ApplicationRoute#model don\'t enter LoadingRoute', function () { + expect(2); + + var appDeferred = _emberRuntime.RSVP.defer(); + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return appDeferred.promise; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(false, 'shouldn\'t get here'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), '', 'nothing has been rendered yet'); + + _emberMetal.run(appDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Don\'t enter loading route unless either route or template defined', function () { + delete templates.loading; + + expect(2); + + var indexDeferred = _emberRuntime.RSVP.defer(); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + return indexDeferred.promise; + } + }); + + bootApplication(); + + var appController = container.lookup('controller:application'); + ok(appController.get('currentPath') !== 'loading', 'loading state not entered'); + + _emberMetal.run(indexDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Enter loading route if only LoadingRoute defined', function () { + delete templates.loading; + + expect(4); + + var indexDeferred = _emberRuntime.RSVP.defer(); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'IndexRoute#model'); + return indexDeferred.promise; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + setupController: function () { + step(2, 'LoadingRoute#setupController'); + } + }); + + bootApplication(); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'loading', 'loading state entered'); + + _emberMetal.run(indexDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Enter child loading state of pivot route', function () { + expect(4); + + var deferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + this.route('smells'); + }); + }); + + templates['grandma/loading'] = 'GMONEYLOADING'; + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + setupController: function () { + step(1, 'SallyRoute#setupController'); + } + }); + + App.GrandmaSmellsRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/grandma/mom/sally'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.mom.sally', 'Initial route fully loaded'); + + _emberMetal.run(router, 'transitionTo', 'grandma.smells'); + equal(appController.get('currentPath'), 'grandma.loading', 'in pivot route\'s child loading state'); + + _emberMetal.run(deferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.smells', 'Finished transition'); + }); + + QUnit.test('Loading actions bubble to root, but don\'t enter substates above pivot', function () { + expect(6); + + delete templates.loading; + + var sallyDeferred = _emberRuntime.RSVP.defer(); + var smellsDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + this.route('smells'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + loading: function (transition, route) { + ok(true, 'loading action received on ApplicationRoute'); + } + } + }); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + return sallyDeferred.promise; + } + }); + + App.GrandmaSmellsRoute = _emberRouting.Route.extend({ + model: function () { + return smellsDeferred.promise; + } + }); + + bootApplication('/grandma/mom/sally'); + + var appController = container.lookup('controller:application'); + ok(!appController.get('currentPath'), 'Initial route fully loaded'); + _emberMetal.run(sallyDeferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.mom.sally', 'transition completed'); + + _emberMetal.run(router, 'transitionTo', 'grandma.smells'); + equal(appController.get('currentPath'), 'grandma.mom.sally', 'still in initial state because the only loading state is above the pivot route'); + + _emberMetal.run(smellsDeferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.smells', 'Finished transition'); + }); + + QUnit.test('Default error event moves into nested route', function () { + expect(6); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + templates['grandma/error'] = 'ERROR: {{model.msg}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function () { + step(2, 'MomSallyRoute#actions.error'); + return true; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + step(3, 'App finished booting'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA ERROR: did it broke?', 'error bubbles'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.error', 'Initial route fully loaded'); + }); + + QUnit.test('Error events that aren\'t bubbled don\t throw application assertions', function () { + expect(2); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + equal(err.msg, 'did it broke?'); + return false; + } + } + }); + + bootApplication('/grandma/mom/sally'); + }); + + QUnit.test('Non-bubbled errors that re-throw aren\'t swallowed', function () { + expect(2); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + // returns undefined which is falsey + throw err; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + }); + + QUnit.test('Handled errors that re-throw aren\'t swallowed', function () { + expect(4); + + var handledError = undefined; + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + this.route('this-route-throws'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + + handledError = err; + + this.transitionTo('mom.this-route-throws'); + + // Marks error as handled + return false; + } + } + }); + + App.MomThisRouteThrowsRoute = _emberRouting.Route.extend({ + model: function () { + step(3, 'MomThisRouteThrows#model'); + + throw handledError; + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + }); + + QUnit.test('Handled errors that bubble can be handled at a higher level', function () { + expect(4); + + var handledError = undefined; + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomRoute = _emberRouting.Route.extend({ + actions: { + error: function (err) { + step(3, 'MomRoute#error'); + + equal(err, handledError, 'error handled and rebubbled is handleable at heigher route'); + } + } + }); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + + handledError = err; + + return true; + } + } + }); + + bootApplication('/grandma/mom/sally'); + }); + + QUnit.test('errors that are bubbled are thrown at a higher level if not handled', function () { + expect(3); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + return true; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }, 'Correct error was thrown'); + }); + + QUnit.test('Handled errors that are thrown through rejection aren\'t swallowed', function () { + expect(4); + + var handledError = undefined; + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + this.route('this-route-throws'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + + handledError = err; + + this.transitionTo('mom.this-route-throws'); + + // Marks error as handled + return false; + } + } + }); + + App.MomThisRouteThrowsRoute = _emberRouting.Route.extend({ + model: function () { + step(3, 'MomThisRouteThrows#model'); + + return _emberRuntime.RSVP.reject(handledError); + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + }); + + QUnit.test('Setting a query param during a slow transition should work', function () { + var deferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', { path: '/grandma/:seg' }, function () {}); + }); + + templates['grandma/loading'] = 'GMONEYLOADING'; + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.IndexRoute = _emberRouting.Route.extend({ + beforeModel: function () { + this.transitionTo('grandma', 1); + } + }); + + App.GrandmaRoute = _emberRouting.Route.extend({ + queryParams: { + test: { defaultValue: 1 } + } + }); + + App.GrandmaIndexRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/'); + + var appController = container.lookup('controller:application'); + var grandmaController = container.lookup('controller:grandma'); + + equal(appController.get('currentPath'), 'grandma.loading', 'Initial route should be loading'); + + _emberMetal.run(function () { + grandmaController.set('test', 3); + }); + + equal(appController.get('currentPath'), 'grandma.loading', 'Route should still be loading'); + equal(grandmaController.get('test'), 3, 'Controller query param value should have changed'); + + _emberMetal.run(deferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.index', 'Transition should be complete'); + }); + + QUnit.test('Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present', function () { + expect(2); + + var appDeferred = _emberRuntime.RSVP.defer(); + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return appDeferred.promise; + } + }); + + var loadingRouteEntered = false; + App.ApplicationLoadingRoute = _emberRouting.Route.extend({ + setupController: function () { + loadingRouteEntered = true; + } + }); + + bootApplication(); + + ok(loadingRouteEntered, 'ApplicationLoadingRoute was entered'); + + _emberMetal.run(appDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Slow promises returned from ApplicationRoute#model enter application_loading if template present', function () { + expect(3); + + templates['application_loading'] = '
    TOPLEVEL LOADING
    '; + + var appDeferred = _emberRuntime.RSVP.defer(); + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return appDeferred.promise; + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture #toplevel-loading').text(), 'TOPLEVEL LOADING'); + + _emberMetal.run(appDeferred, 'resolve', {}); + + equal(_emberViews.jQuery('#toplevel-loading', '#qunit-fixture').length, 0, 'top-level loading View has been entirely removed from DOM'); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Default error event moves into nested route, prioritizing more specifically named error route', function () { + expect(6); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + templates['grandma/error'] = 'ERROR: {{model.msg}}'; + templates['mom_error'] = 'MOM ERROR: {{model.msg}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function () { + step(2, 'MomSallyRoute#actions.error'); + return true; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + step(3, 'App finished booting'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM ERROR: did it broke?', 'the more specifically-named mom error substate was entered over the other error route'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.mom_error', 'Initial route fully loaded'); + }); + + QUnit.test('Prioritized substate entry works with preserved-namespace nested routes', function () { + expect(2); + + templates['foo/bar_loading'] = 'FOOBAR LOADING'; + templates['foo/bar/index'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar', { path: '/bar' }, function () {}); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.FooBarRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/foo/bar'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOOBAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized substate entry works with reset-namespace nested routes', function () { + expect(2); + + templates['bar_loading'] = 'BAR LOADING'; + templates['bar/index'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar', { path: '/bar', resetNamespace: true }, function () {}); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.BarRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/foo/bar'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'BAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized loading substate entry works with preserved-namespace nested routes', function () { + expect(2); + + templates['foo/bar_loading'] = 'FOOBAR LOADING'; + templates['foo/bar'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.FooBarRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/foo/bar'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOOBAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized error substate entry works with preserved-namespace nested routes', function () { + expect(2); + + templates['foo/bar_error'] = 'FOOBAR ERROR: {{model.msg}}'; + templates['foo/bar'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.FooBarRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + } + }); + + throws(function () { + bootApplication('/foo/bar'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOOBAR ERROR: did it broke?', 'foo.bar_error was entered (as opposed to something like foo/foo/bar_error)'); + }); + + QUnit.test('Prioritized loading substate entry works with auto-generated index routes', function () { + expect(2); + + templates['foo/index_loading'] = 'FOO LOADING'; + templates['foo/index'] = 'YAY'; + templates['foo'] = '{{outlet}}'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.FooIndexRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + App.FooRoute = _emberRouting.Route.extend({ + model: function () { + return true; + } + }); + + bootApplication('/foo'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOO LOADING', 'foo.index_loading was entered'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized error substate entry works with auto-generated index routes', function () { + expect(2); + + templates['foo/index_error'] = 'FOO ERROR: {{model.msg}}'; + templates['foo/index'] = 'YAY'; + templates['foo'] = '{{outlet}}'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.FooIndexRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + } + }); + App.FooRoute = _emberRouting.Route.extend({ + model: function () { + return true; + } + }); + + throws(function () { + return bootApplication('/foo'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOO ERROR: did it broke?', 'foo.index_error was entered'); + }); + + QUnit.test('Rejected promises returned from ApplicationRoute transition into top-level application_error', function () { + expect(3); + + templates['application_error'] = '

    TOPLEVEL ERROR: {{model.msg}}

    '; + + var reject = true; + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + if (reject) { + return _emberRuntime.RSVP.reject({ msg: 'BAD NEWS BEARS' }); + } else { + return {}; + } + } + }); + + throws(function () { + return bootApplication(); + }, function (err) { + return err.msg === 'BAD NEWS BEARS'; + }); + + equal(_emberViews.jQuery('#toplevel-error', '#qunit-fixture').text(), 'TOPLEVEL ERROR: BAD NEWS BEARS'); + + reject = false; + _emberMetal.run(router, 'transitionTo', 'index'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); +}); +enifed('ember/tests/routing/substates_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/substates_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/substates_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/toplevel_dom_test', ['exports', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-routing', 'ember-glimmer'], function (exports, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberViews, _emberRouting, _emberGlimmer) { + 'use strict'; + + var App = undefined, + templates = undefined, + container = undefined; + + function bootApplication() { + for (var _name in templates) { + _emberGlimmer.setTemplate(_name, _emberTemplateCompiler.compile(templates[_name])); + } + container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + QUnit.module('Top Level DOM Structure', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + container = App.__container__; + + templates = { + application: 'hello world' + }; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + _emberGlimmer.setTemplates({}); + }); + + _emberRouting.NoneLocation.reopen({ + path: '' + }); + } + }); + + QUnit.test('Topmost template always get an element', function () { + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture > .ember-view').text(), 'hello world'); + }); +}); +enifed('ember/tests/routing/toplevel_dom_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/toplevel_dom_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/toplevel_dom_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/view_instrumentation_test', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + var App = undefined, + $fixture = undefined; + + function setupExample() { + // setup templates + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Index

    ')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('

    Posts

    ')); + + App.Router.map(function () { + this.route('posts'); + }); + } + + function handleURL(path) { + var router = App.__container__.lookup('router:main'); + return _emberMetal.run(router, 'handleURL', path); + } + + QUnit.module('View Instrumentation', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + rootElement: '#qunit-fixture' + }); + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + }); + + $fixture = _emberViews.jQuery('#qunit-fixture'); + setupExample(); + }, + + teardown: function () { + _emberMetal.instrumentationReset(); + _emberMetal.run(App, 'destroy'); + App = null; + _emberGlimmer.setTemplates({}); + } + }); + + QUnit.test('Nodes without view instances are instrumented', function (assert) { + var called = false; + _emberMetal.instrumentationSubscribe('render', { + before: function () { + called = true; + }, + after: function () {} + }); + _emberMetal.run(App, 'advanceReadiness'); + assert.equal($fixture.text(), 'Index', 'It rendered the right template'); + assert.ok(called, 'Instrumentation called on first render'); + called = false; + handleURL('/posts'); + assert.equal($fixture.text(), 'Posts', 'It rendered the right template'); + assert.ok(called, 'instrumentation called on transition to non-view backed route'); + }); +}); +enifed('ember/tests/view_instrumentation_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/view_instrumentation_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/view_instrumentation_test.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/apply-mixins.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/apply-mixins.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/apply-mixins.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/build-owner.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/build-owner.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/build-owner.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/confirm-export.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/confirm-export.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/confirm-export.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/equal-inner-html.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/equal-inner-html.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/equal-inner-html.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/equal-tokens.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/equal-tokens.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/equal-tokens.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/factory.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/factory.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/factory.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/index.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/matchers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/matchers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/matchers.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/module-for.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/module-for.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/module-for.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/run.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/run.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/run.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/strip.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/strip.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/strip.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/abstract-application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/abstract-application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/abstract-application.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/abstract-rendering.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/abstract-rendering.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/abstract-rendering.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/abstract.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/abstract.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/abstract.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/application.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/query-param.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/query-param.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/query-param.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/rendering.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/rendering.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/rendering.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/router.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/router.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/router.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-groups.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-groups.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-groups.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/tests/index-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('internal-test-helpers'); + + QUnit.test('module present', function (assert) { + assert.ok(true, 'each package needs at least one test to be able to run through `npm test`'); + }); +}); +enifed('internal-test-helpers/tests/index-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/tests/index-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/tests/index-test.js should pass ESLint\n\n'); + }); +}); +}()); diff --git a/ember-tests.prod.js b/ember-tests.prod.js new file mode 100644 index 000000000..4eb235448 --- /dev/null +++ b/ember-tests.prod.js @@ -0,0 +1,79491 @@ +;(function() { +/*! + * @overview Ember - JavaScript Application Framework + * @copyright Copyright 2011-2017 Tilde Inc. and contributors + * Portions Copyright 2006-2011 Strobe Inc. + * Portions Copyright 2008-2011 Apple Inc. All rights reserved. + * @license Licensed under MIT license + * See https://raw.github.com/emberjs/ember.js/master/LICENSE + * @version 2.12.0-canary + */ + +var enifed, requireModule, Ember; +var mainContext = this; // Used in ember-environment/lib/global.js + +(function() { + var isNode = typeof window === 'undefined' && + typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; + + if (!isNode) { + Ember = this.Ember = this.Ember || {}; + } + + if (typeof Ember === 'undefined') { Ember = {}; } + + if (typeof Ember.__loader === 'undefined') { + var registry = {}; + var seen = {}; + + enifed = function(name, deps, callback) { + var value = { }; + + if (!callback) { + value.deps = []; + value.callback = deps; + } else { + value.deps = deps; + value.callback = callback; + } + + registry[name] = value; + }; + + requireModule = function(name) { + return internalRequire(name, null); + }; + + // setup `require` module + requireModule['default'] = requireModule; + + requireModule.has = function registryHas(moduleName) { + return !!registry[moduleName] || !!registry[moduleName + '/index']; + }; + + function missingModule(name, referrerName) { + if (referrerName) { + throw new Error('Could not find module ' + name + ' required by: ' + referrerName); + } else { + throw new Error('Could not find module ' + name); + } + } + + function internalRequire(_name, referrerName) { + var name = _name; + var mod = registry[name]; + + if (!mod) { + name = name + '/index'; + mod = registry[name]; + } + + var exports = seen[name]; + + if (exports !== undefined) { + return exports; + } + + exports = seen[name] = {}; + + if (!mod) { + missingModule(_name, referrerName); + } + + var deps = mod.deps; + var callback = mod.callback; + var reified = new Array(deps.length); + + for (var i = 0; i < deps.length; i++) { + if (deps[i] === 'exports') { + reified[i] = exports; + } else if (deps[i] === 'require') { + reified[i] = requireModule; + } else { + reified[i] = internalRequire(deps[i], name); + } + } + + callback.apply(this, reified); + + return exports; + } + + requireModule._eak_seen = registry; + + Ember.__loader = { + define: enifed, + require: requireModule, + registry: registry + }; + } else { + enifed = Ember.__loader.define; + requireModule = Ember.__loader.require; + } +})(); + +function inherits(subClass, superClass) { + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : defaults(subClass, superClass); +} + +function taggedTemplateLiteralLoose(strings, raw) { + strings.raw = raw; + return strings; +} + +function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ('value' in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function createClass(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; +} + +function interopExportWildcard(obj, defaults) { + var newObj = defaults({}, obj); + delete newObj['default']; + return newObj; +} + +function defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + return obj; +} + +babelHelpers = { + inherits: inherits, + taggedTemplateLiteralLoose: taggedTemplateLiteralLoose, + slice: Array.prototype.slice, + createClass: createClass, + interopExportWildcard: interopExportWildcard, + defaults: defaults +}; + +enifed('container/container.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | container/container.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'container/container.js should pass ESLint\n\n'); + }); +}); +enifed('container/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | container/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'container/index.js should pass ESLint\n\n'); + }); +}); +enifed('container/registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | container/registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'container/registry.js should pass ESLint\n\n'); + }); +}); +enifed('container/tests/container_test', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'container/index', 'internal-test-helpers', 'container'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _containerIndex, _internalTestHelpers, _container) { + 'use strict'; + + var originalModelInjections = undefined; + + QUnit.module('Container', { + setup: function () { + originalModelInjections = _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; + }, + teardown: function () { + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = originalModelInjections; + } + }); + + function lookupFactory(name, container, options) { + return container[_container.LOOKUP_FACTORY](name, options); + } + + QUnit.test('A registered factory returns the same instance each time', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + var postController = container.lookup('controller:post'); + + ok(postController instanceof PostController, 'The lookup is an instance of the factory'); + + equal(postController, container.lookup('controller:post')); + }); + + QUnit.test('A registered factory is returned from lookupFactory', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + var PostControllerFactory = lookupFactory('controller:post', container); + + ok(PostControllerFactory, 'factory is returned'); + ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController'); + }); + + QUnit.test('A registered factory is returned from lookupFactory is the same factory each time', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + var Post1 = lookupFactory('controller:post', container); + var Post2 = lookupFactory('controller:post', container); + + deepEqual(Post1, Post2, 'The return of lookupFactory is always the same'); + }); + + QUnit.test('A factory returned from lookupFactory has a debugkey', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + var PostFactory = lookupFactory('controller:post', container); + equal(PostFactory._debugContainerKey, 'controller:post', 'factory instance receives _debugContainerKey'); + }); + + QUnit.test('fallback for to create time injections if factory has no extend', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var AppleController = _internalTestHelpers.factory(); + var PostController = _internalTestHelpers.factory(); + + PostController.extend = undefined; // remove extend + + registry.register('controller:apple', AppleController); + registry.register('controller:post', PostController); + registry.injection('controller:post', 'apple', 'controller:apple'); + + var postController = container.lookup('controller:post'); + + equal(postController._debugContainerKey, 'controller:post', 'instance receives _debugContainerKey'); + ok(postController.apple instanceof AppleController, 'instance receives an apple of instance AppleController'); + }); + + QUnit.test('The descendants of a factory returned from lookupFactory have a container and debugkey', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var instance = undefined; + + registry.register('controller:post', PostController); + instance = lookupFactory('controller:post', container).create(); + + equal(instance._debugContainerKey, 'controller:post', 'factory instance receives _debugContainerKey'); + + ok(instance instanceof PostController, 'factory instance is instance of factory'); + }); + + QUnit.test('A registered factory returns a fresh instance if singleton: false is passed as an option', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + var postController1 = container.lookup('controller:post'); + var postController2 = container.lookup('controller:post', { singleton: false }); + var postController3 = container.lookup('controller:post', { singleton: false }); + var postController4 = container.lookup('controller:post'); + + equal(postController1.toString(), postController4.toString(), 'Singleton factories looked up normally return the same value'); + notEqual(postController1.toString(), postController2.toString(), 'Singleton factories are not equal to factories looked up with singleton: false'); + notEqual(postController2.toString(), postController3.toString(), 'Two factories looked up with singleton: false are not equal'); + notEqual(postController3.toString(), postController4.toString(), 'A singleton factory looked up after a factory called with singleton: false is not equal'); + + ok(postController1 instanceof PostController, 'All instances are instances of the registered factory'); + ok(postController2 instanceof PostController, 'All instances are instances of the registered factory'); + ok(postController3 instanceof PostController, 'All instances are instances of the registered factory'); + ok(postController4 instanceof PostController, 'All instances are instances of the registered factory'); + }); + + QUnit.test('A factory type with a registered injection\'s instances receive that injection', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var Store = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + registry.register('store:main', Store); + + registry.typeInjection('controller', 'store', 'store:main'); + + var postController = container.lookup('controller:post'); + var store = container.lookup('store:main'); + + equal(postController.store, store); + }); + + QUnit.test('An individual factory with a registered injection receives the injection', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var Store = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + registry.register('store:main', Store); + + registry.injection('controller:post', 'store', 'store:main'); + + var postController = container.lookup('controller:post'); + var store = container.lookup('store:main'); + + equal(store._debugContainerKey, 'store:main'); + + equal(postController._debugContainerKey, 'controller:post'); + equal(postController.store, store, 'has the correct store injected'); + }); + + QUnit.test('A factory with both type and individual injections', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var Store = _internalTestHelpers.factory(); + var Router = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + registry.register('store:main', Store); + registry.register('router:main', Router); + + registry.injection('controller:post', 'store', 'store:main'); + registry.typeInjection('controller', 'router', 'router:main'); + + var postController = container.lookup('controller:post'); + var store = container.lookup('store:main'); + var router = container.lookup('router:main'); + + equal(postController.store, store); + equal(postController.router, router); + }); + + QUnit.test('A factory with both type and individual factoryInjections', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var Store = _internalTestHelpers.factory(); + var Router = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + registry.register('store:main', Store); + registry.register('router:main', Router); + + registry.factoryInjection('controller:post', 'store', 'store:main'); + registry.factoryTypeInjection('controller', 'router', 'router:main'); + + var PostControllerFactory = lookupFactory('controller:post', container); + var store = container.lookup('store:main'); + var router = container.lookup('router:main'); + + equal(PostControllerFactory.store, store, 'PostControllerFactory has the instance of store'); + equal(PostControllerFactory.router, router, 'PostControllerFactory has the route instance'); + }); + + QUnit.test('A non-singleton instance is never cached', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostView = _internalTestHelpers.factory(); + + registry.register('view:post', PostView, { singleton: false }); + + var postView1 = container.lookup('view:post'); + var postView2 = container.lookup('view:post'); + + ok(postView1 !== postView2, 'Non-singletons are not cached'); + }); + + QUnit.test('A non-instantiated property is not instantiated', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var template = function () {}; + registry.register('template:foo', template, { instantiate: false }); + equal(container.lookup('template:foo'), template); + }); + + QUnit.test('A failed lookup returns undefined', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + equal(container.lookup('doesnot:exist'), undefined); + }); + + QUnit.test('An invalid factory throws an error', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + registry.register('controller:foo', {}); + + throws(function () { + container.lookup('controller:foo'); + }, /Failed to create an instance of \'controller:foo\'/); + }); + + QUnit.test('Injecting a failed lookup raises an error', function () { + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = true; + + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var fooInstance = {}; + var fooFactory = {}; + + var Foo = { + create: function (args) { + return fooInstance; + }, + extend: function (args) { + return fooFactory; + } + }; + + registry.register('model:foo', Foo); + registry.injection('model:foo', 'store', 'store:main'); + + throws(function () { + container.lookup('model:foo'); + }); + }); + + QUnit.test('Injecting a falsy value does not raise an error', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var ApplicationController = _internalTestHelpers.factory(); + + registry.register('controller:application', ApplicationController); + registry.register('user:current', null, { instantiate: false }); + registry.injection('controller:application', 'currentUser', 'user:current'); + + strictEqual(container.lookup('controller:application').currentUser, null); + }); + + QUnit.test('The container returns same value each time even if the value is falsy', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + registry.register('falsy:value', null, { instantiate: false }); + + strictEqual(container.lookup('falsy:value'), container.lookup('falsy:value')); + }); + + QUnit.test('Destroying the container destroys any cached singletons', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var PostView = _internalTestHelpers.factory(); + var template = function () {}; + + registry.register('controller:post', PostController); + registry.register('view:post', PostView, { singleton: false }); + registry.register('template:post', template, { instantiate: false }); + + registry.injection('controller:post', 'postView', 'view:post'); + + var postController = container.lookup('controller:post'); + var postView = postController.postView; + + ok(postView instanceof PostView, 'The non-singleton was injected'); + + container.destroy(); + + ok(postController.isDestroyed, 'Singletons are destroyed'); + ok(!postView.isDestroyed, 'Non-singletons are not destroyed'); + }); + + QUnit.test('The container can use a registry hook to resolve factories lazily', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.resolver = { + resolve: function (fullName) { + if (fullName === 'controller:post') { + return PostController; + } + } + }; + + var postController = container.lookup('controller:post'); + + ok(postController instanceof PostController, 'The correct factory was provided'); + }); + + QUnit.test('The container normalizes names before resolving', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.normalizeFullName = function (fullName) { + return 'controller:post'; + }; + + registry.register('controller:post', PostController); + var postController = container.lookup('controller:normalized'); + + ok(postController instanceof PostController, 'Normalizes the name before resolving'); + }); + + QUnit.test('The container normalizes names when looking factory up', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.normalizeFullName = function (fullName) { + return 'controller:post'; + }; + + registry.register('controller:post', PostController); + var fact = lookupFactory('controller:normalized', container); + + equal(fact.toString() === PostController.extend().toString(), true, 'Normalizes the name when looking factory up'); + }); + + QUnit.test('Options can be registered that should be applied to a given factory', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostView = _internalTestHelpers.factory(); + + registry.resolver = { + resolve: function (fullName) { + if (fullName === 'view:post') { + return PostView; + } + } + }; + + registry.options('view:post', { instantiate: true, singleton: false }); + + var postView1 = container.lookup('view:post'); + var postView2 = container.lookup('view:post'); + + ok(postView1 instanceof PostView, 'The correct factory was provided'); + ok(postView2 instanceof PostView, 'The correct factory was provided'); + + ok(postView1 !== postView2, 'The two lookups are different'); + }); + + QUnit.test('Options can be registered that should be applied to all factories for a given type', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostView = _internalTestHelpers.factory(); + + registry.resolver = { + resolve: function (fullName) { + if (fullName === 'view:post') { + return PostView; + } + } + }; + + registry.optionsForType('view', { singleton: false }); + + var postView1 = container.lookup('view:post'); + var postView2 = container.lookup('view:post'); + + ok(postView1 instanceof PostView, 'The correct factory was provided'); + ok(postView2 instanceof PostView, 'The correct factory was provided'); + + ok(postView1 !== postView2, 'The two lookups are different'); + }); + + QUnit.test('An injected non-singleton instance is never cached', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostView = _internalTestHelpers.factory(); + var PostViewHelper = _internalTestHelpers.factory(); + + registry.register('view:post', PostView, { singleton: false }); + registry.register('view_helper:post', PostViewHelper, { singleton: false }); + registry.injection('view:post', 'viewHelper', 'view_helper:post'); + + var postView1 = container.lookup('view:post'); + var postView2 = container.lookup('view:post'); + + ok(postView1.viewHelper !== postView2.viewHelper, 'Injected non-singletons are not cached'); + }); + + QUnit.test('Factory resolves are cached', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var resolveWasCalled = []; + registry.resolve = function (fullName) { + resolveWasCalled.push(fullName); + return PostController; + }; + + deepEqual(resolveWasCalled, []); + lookupFactory('controller:post', container); + deepEqual(resolveWasCalled, ['controller:post']); + + lookupFactory('controller:post', container); + deepEqual(resolveWasCalled, ['controller:post']); + }); + + QUnit.test('factory for non extendables (MODEL) resolves are cached', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + var resolveWasCalled = []; + registry.resolve = function (fullName) { + resolveWasCalled.push(fullName); + return PostController; + }; + + deepEqual(resolveWasCalled, []); + lookupFactory('model:post', container); + deepEqual(resolveWasCalled, ['model:post']); + + lookupFactory('model:post', container); + deepEqual(resolveWasCalled, ['model:post']); + }); + + QUnit.test('factory for non extendables resolves are cached', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = {}; + var resolveWasCalled = []; + + registry.resolve = function (fullName) { + resolveWasCalled.push(fullName); + return PostController; + }; + + deepEqual(resolveWasCalled, []); + lookupFactory('foo:post', container); + deepEqual(resolveWasCalled, ['foo:post']); + + lookupFactory('foo:post', container); + deepEqual(resolveWasCalled, ['foo:post']); + }); + + QUnit.test('The `_onLookup` hook is called on factories when looked up the first time', function () { + expect(2); + + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var Apple = _internalTestHelpers.factory(); + + Apple.reopenClass({ + _onLookup: function (fullName) { + equal(fullName, 'apple:main', 'calls lazy injection method with the lookup full name'); + equal(this, Apple, 'calls lazy injection method in the factory context'); + } + }); + + registry.register('apple:main', Apple); + + lookupFactory('apple:main', container); + lookupFactory('apple:main', container); + }); + + QUnit.test('A factory\'s lazy injections are validated when first instantiated', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var Apple = _internalTestHelpers.factory(); + var Orange = _internalTestHelpers.factory(); + + Apple.reopenClass({ + _lazyInjections: function () { + return ['orange:main', 'banana:main']; + } + }); + + registry.register('apple:main', Apple); + registry.register('orange:main', Orange); + + throws(function () { + container.lookup('apple:main'); + }, /Attempting to inject an unknown injection: 'banana:main'/); + }); + + QUnit.test('Lazy injection validations are cached', function () { + expect(1); + + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var Apple = _internalTestHelpers.factory(); + var Orange = _internalTestHelpers.factory(); + + Apple.reopenClass({ + _lazyInjections: function () { + ok(true, 'should call lazy injection method'); + return ['orange:main']; + } + }); + + registry.register('apple:main', Apple); + registry.register('orange:main', Orange); + + container.lookup('apple:main'); + container.lookup('apple:main'); + }); + + QUnit.test('An object with its owner pre-set should be returned from ownerInjection', function () { + var owner = {}; + var registry = new _containerIndex.Registry(); + var container = registry.container({ owner: owner }); + + var result = container.ownerInjection(); + + equal(result[_emberUtils.OWNER], owner, 'owner is properly included'); + }); + + QUnit.test('A deprecated `container` property is appended to every object instantiated from an extendable factory', function () { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + registry.register('controller:post', PostController); + var postController = container.lookup('controller:post'); + + expectDeprecation(function () { + _emberMetal.get(postController, 'container'); + }, 'Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.'); + + expectDeprecation(function () { + var c = postController.container; + strictEqual(c, container); + }, 'Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.'); + }); + + // This is testing that container was passed as an option + QUnit.test('A deprecated `container` property is appended to every object instantiated from a non-extendable factory, and a fake container is available during instantiation.', function () { + if (!true) { + expect(8); + } else { + expect(1); + ok(true, '[SKIPPED] This will be removed when `factoryFor` lands.'); + } + + var owner = {}; + var registry = new _containerIndex.Registry(); + var container = registry.container({ owner: owner }); + + // Define a simple non-extendable factory + function PostController(options) { + this.container = options.container; + } + + PostController.create = function (options) { + ok(options.container, 'fake container has been injected and is available during `create`.'); + + expectDeprecation(function () { + options.container.lookup('abc:one'); + }, 'Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `lookup` instead.'); + + expectDeprecation(function () { + options.container.lookupFactory('abc:two'); + }, 'Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `_lookupFactory` instead.'); + + // non-deprecated usage of `lookup` and `_lookupFactory` + owner.lookup = function (fullName) { + equal(fullName, 'abc:one', 'lookup on owner called properly'); + }; + owner._lookupFactory = function (fullName) { + equal(fullName, 'abc:two', '_lookupFactory on owner called properly'); + }; + var foundOwner = _emberUtils.getOwner(options); + foundOwner.lookup('abc:one'); + foundOwner._lookupFactory('abc:two'); + + return new PostController(options); + }; + + registry.register('controller:post', PostController); + + if (!true) { + (function () { + var postController = container.lookup('controller:post'); + + expectDeprecation(function () { + _emberMetal.get(postController, 'container'); + }, 'Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.'); + + expectDeprecation(function () { + var c = postController.container; + strictEqual(c, container, 'Injected container is now regular (not fake) container, but access is still deprecated.'); + }, 'Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.'); + })(); + } + }); + + QUnit.test('An extendable factory can provide `container` upon create, with a deprecation', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + registry.register('controller:post', _internalTestHelpers.factory()); + + var PostController = lookupFactory('controller:post', container); + + var postController = undefined; + + expectDeprecation(function () { + postController = PostController.create({ + container: 'foo' + }); + }, /Providing the \`container\` property to .+ is deprecated. Please use \`Ember.setOwner\` or \`owner.ownerInjection\(\)\` instead to provide an owner to the instance being created/); + + expectDeprecation(function () { + var c = postController.container; + assert.equal(c, 'foo', 'the `container` provided to `.create`was used'); + }, 'Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.'); + }); + + QUnit.test('lookupFactory passes options through to expandlocallookup', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + registry.expandLocalLookup = function (fullName, options) { + assert.ok(true, 'expandLocalLookup was called'); + assert.equal(fullName, 'foo:bar'); + assert.deepEqual(options, { source: 'baz:qux' }); + + return 'controller:post'; + }; + + var PostControllerFactory = lookupFactory('foo:bar', container, { source: 'baz:qux' }); + + assert.ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController'); + }); + + QUnit.test('lookup passes options through to expandlocallookup', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + registry.expandLocalLookup = function (fullName, options) { + assert.ok(true, 'expandLocalLookup was called'); + assert.equal(fullName, 'foo:bar'); + assert.deepEqual(options, { source: 'baz:qux' }); + + return 'controller:post'; + }; + + var PostControllerLookupResult = container.lookup('foo:bar', { source: 'baz:qux' }); + + assert.ok(PostControllerLookupResult instanceof PostController); + }); + + QUnit.test('#[FACTORY_FOR] class is the injected factory', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var Component = _internalTestHelpers.factory(); + registry.register('component:foo-bar', Component); + + var factoryCreator = container[_container.FACTORY_FOR]('component:foo-bar'); + if (_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + assert.deepEqual(factoryCreator.class, Component, 'No double extend'); + } else { + assert.deepEqual(factoryCreator.class, lookupFactory('component:foo-bar', container), 'Double extended class'); + } + }); + + if (true) { + QUnit.test('#factoryFor must supply a fullname', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + assert.throws(function () { + container.factoryFor('chad-bar'); + }, /Invalid Fullname, expected: 'type:name' got: chad-bar/); + }); + + QUnit.test('#factoryFor returns a factory creator', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var Component = _internalTestHelpers.factory(); + registry.register('component:foo-bar', Component); + + var factoryCreator = container.factoryFor('component:foo-bar'); + assert.ok(factoryCreator.create); + assert.ok(factoryCreator.class); + }); + + QUnit.test('#factoryFor class returns the factory function', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var Component = _internalTestHelpers.factory(); + registry.register('component:foo-bar', Component); + + var factoryCreator = container.factoryFor('component:foo-bar'); + assert.deepEqual(factoryCreator.class, Component, 'No double extend'); + }); + + QUnit.test('#factoryFor instance have a common parent', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var Component = _internalTestHelpers.factory(); + registry.register('component:foo-bar', Component); + + var factoryCreator1 = container.factoryFor('component:foo-bar'); + var factoryCreator2 = container.factoryFor('component:foo-bar'); + var instance1 = factoryCreator1.create({ foo: 'foo' }); + var instance2 = factoryCreator2.create({ bar: 'bar' }); + + assert.deepEqual(instance1.constructor, instance2.constructor); + }); + + QUnit.test('#factoryFor created instances come with instance injections', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var Component = _internalTestHelpers.factory(); + var Ajax = _internalTestHelpers.factory(); + registry.register('component:foo-bar', Component); + registry.register('util:ajax', Ajax); + registry.injection('component:foo-bar', 'ajax', 'util:ajax'); + + var componentFactory = container.factoryFor('component:foo-bar'); + var component = componentFactory.create(); + + assert.ok(component.ajax); + assert.ok(component.ajax instanceof Ajax); + }); + + QUnit.test('#factoryFor options passed to create clobber injections', function (assert) { + var registry = new _containerIndex.Registry(); + var container = registry.container(); + + var Component = _internalTestHelpers.factory(); + var Ajax = _internalTestHelpers.factory(); + registry.register('component:foo-bar', Component); + registry.register('util:ajax', Ajax); + registry.injection('component:foo-bar', 'ajax', 'util:ajax'); + + var componentFactory = container.factoryFor('component:foo-bar'); + + var instrance = componentFactory.create({ ajax: 'fetch' }); + + assert.equal(instrance.ajax, 'fetch'); + }); + } +}); +enifed('container/tests/container_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | container/tests/container_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'container/tests/container_test.js should pass ESLint\n\n'); + }); +}); +enifed('container/tests/owner_test', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; + + QUnit.module('Owner', {}); + + QUnit.test('An owner can be set with `setOwner` and retrieved with `getOwner`', function () { + var owner = {}; + var obj = {}; + + strictEqual(_emberUtils.getOwner(obj), undefined, 'owner has not been set'); + + _emberUtils.setOwner(obj, owner); + + strictEqual(_emberUtils.getOwner(obj), owner, 'owner has been set'); + + strictEqual(obj[_emberUtils.OWNER], owner, 'owner has been set to the OWNER symbol'); + }); +}); +enifed('container/tests/owner_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | container/tests/owner_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'container/tests/owner_test.js should pass ESLint\n\n'); + }); +}); +enifed('container/tests/registry_test', ['exports', 'container/index', 'internal-test-helpers'], function (exports, _containerIndex, _internalTestHelpers) { + 'use strict'; + + QUnit.module('Registry'); + + QUnit.test('A registered factory is returned from resolve', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + var PostControllerFactory = registry.resolve('controller:post'); + + ok(PostControllerFactory, 'factory is returned'); + ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController'); + }); + + QUnit.test('The registered factory returned from resolve is the same factory each time', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + deepEqual(registry.resolve('controller:post'), registry.resolve('controller:post'), 'The return of resolve is always the same'); + }); + + QUnit.test('The registered value returned from resolve is the same value each time even if the value is falsy', function () { + var registry = new _containerIndex.Registry(); + + registry.register('falsy:value', null, { instantiate: false }); + + strictEqual(registry.resolve('falsy:value'), registry.resolve('falsy:value'), 'The return of resolve is always the same'); + }); + + QUnit.test('The value returned from resolver is the same value as the original value even if the value is falsy', function () { + var resolver = { + resolve: function (fullName) { + if (fullName === 'falsy:value') { + return null; + } + } + }; + var registry = new _containerIndex.Registry({ resolver: resolver }); + + strictEqual(registry.resolve('falsy:value'), null); + }); + + QUnit.test('A registered factory returns true for `has` if an item is registered', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + equal(registry.has('controller:post'), true, 'The `has` method returned true for registered factories'); + equal(registry.has('controller:posts'), false, 'The `has` method returned false for unregistered factories'); + }); + + QUnit.test('Throw exception when trying to inject `type:thing` on all type(s)', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + + registry.register('controller:post', PostController); + + throws(function () { + registry.typeInjection('controller', 'injected', 'controller:post'); + }, /Cannot inject a 'controller:post' on other controller\(s\)\./); + }); + + QUnit.test('The registry can take a hook to resolve factories lazily', function () { + var PostController = _internalTestHelpers.factory(); + var resolver = { + resolve: function (fullName) { + if (fullName === 'controller:post') { + return PostController; + } + } + }; + var registry = new _containerIndex.Registry({ resolver: resolver }); + + strictEqual(registry.resolve('controller:post'), PostController, 'The correct factory was provided'); + }); + + QUnit.test('The registry respects the resolver hook for `has`', function () { + var PostController = _internalTestHelpers.factory(); + var resolver = { + resolve: function (fullName) { + if (fullName === 'controller:post') { + return PostController; + } + } + }; + var registry = new _containerIndex.Registry({ resolver: resolver }); + + ok(registry.has('controller:post'), 'the `has` method uses the resolver hook'); + }); + + QUnit.test('The registry normalizes names when resolving', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + + registry.normalizeFullName = function (fullName) { + return 'controller:post'; + }; + + registry.register('controller:post', PostController); + var type = registry.resolve('controller:normalized'); + + strictEqual(type, PostController, 'Normalizes the name when resolving'); + }); + + QUnit.test('The registry normalizes names when checking if the factory is registered', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + + registry.normalizeFullName = function (fullName) { + return fullName === 'controller:normalized' ? 'controller:post' : fullName; + }; + + registry.register('controller:post', PostController); + var isPresent = registry.has('controller:normalized'); + + equal(isPresent, true, 'Normalizes the name when checking if the factory or instance is present'); + }); + + QUnit.test('validateFullName throws an error if name is incorrect', function () { + expect(2); + + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + + registry.normalize = function (fullName) { + return 'controller:post'; + }; + + registry.register('controller:post', PostController); + throws(function () { + registry.validateFullName('post'); + }, /TypeError: Invalid Fullname, expected: 'type:name' got: post/); + + throws(function () { + registry.validateFullName('route:http://foo.bar.com/baz'); + }, /TypeError: Invalid Fullname, expected: 'type:name' got: route:http:\/\/foo.bar.com\/baz/); + }); + + QUnit.test('The registry normalizes names when injecting', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + var user = { name: 'Stef' }; + + registry.normalize = function (fullName) { + return 'controller:post'; + }; + + registry.register('controller:post', PostController); + registry.register('user:post', user, { instantiate: false }); + registry.injection('controller:post', 'user', 'controller:normalized'); + + deepEqual(registry.resolve('controller:post'), user, 'Normalizes the name when injecting'); + }); + + QUnit.test('cannot register an `undefined` factory', function () { + var registry = new _containerIndex.Registry(); + + throws(function () { + registry.register('controller:apple', undefined); + }, ''); + }); + + QUnit.test('can re-register a factory', function () { + var registry = new _containerIndex.Registry(); + var FirstApple = _internalTestHelpers.factory('first'); + var SecondApple = _internalTestHelpers.factory('second'); + + registry.register('controller:apple', FirstApple); + registry.register('controller:apple', SecondApple); + + ok(registry.resolve('controller:apple').create() instanceof SecondApple); + }); + + QUnit.test('cannot re-register a factory if it has been resolved', function () { + var registry = new _containerIndex.Registry(); + var FirstApple = _internalTestHelpers.factory('first'); + var SecondApple = _internalTestHelpers.factory('second'); + + registry.register('controller:apple', FirstApple); + strictEqual(registry.resolve('controller:apple'), FirstApple); + + throws(function () { + registry.register('controller:apple', SecondApple); + }, /Cannot re-register: 'controller:apple', as it has already been resolved\./); + + strictEqual(registry.resolve('controller:apple'), FirstApple); + }); + + QUnit.test('registry.has should not accidentally cause injections on that factory to be run. (Mitigate merely on observing)', function () { + expect(1); + + var registry = new _containerIndex.Registry(); + var FirstApple = _internalTestHelpers.factory('first'); + var SecondApple = _internalTestHelpers.factory('second'); + + SecondApple.extend = function (a, b, c) { + ok(false, 'should not extend or touch the injected model, merely to inspect existence of another'); + }; + + registry.register('controller:apple', FirstApple); + registry.register('controller:second-apple', SecondApple); + registry.injection('controller:apple', 'badApple', 'controller:second-apple'); + + ok(registry.has('controller:apple')); + }); + + QUnit.test('registry.has should not error for invalid fullNames)', function () { + expect(1); + + var registry = new _containerIndex.Registry(); + + ok(!registry.has('foo:bar:baz')); + }); + + QUnit.test('once resolved, always return the same result', function () { + expect(1); + + var registry = new _containerIndex.Registry(); + + registry.resolver = { + resolve: function () { + return 'bar'; + } + }; + + var Bar = registry.resolve('models:bar'); + + registry.resolver = { + resolve: function () { + return 'not bar'; + } + }; + + equal(registry.resolve('models:bar'), Bar); + }); + + QUnit.test('factory resolves are cached', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + var resolveWasCalled = []; + + registry.resolver = { + resolve: function (fullName) { + resolveWasCalled.push(fullName); + return PostController; + } + }; + + deepEqual(resolveWasCalled, []); + registry.resolve('controller:post'); + deepEqual(resolveWasCalled, ['controller:post']); + + registry.resolve('controller:post'); + deepEqual(resolveWasCalled, ['controller:post']); + }); + + QUnit.test('factory for non extendables (MODEL) resolves are cached', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + var resolveWasCalled = []; + + registry.resolver = { + resolve: function (fullName) { + resolveWasCalled.push(fullName); + return PostController; + } + }; + + deepEqual(resolveWasCalled, []); + registry.resolve('model:post'); + deepEqual(resolveWasCalled, ['model:post']); + + registry.resolve('model:post'); + deepEqual(resolveWasCalled, ['model:post']); + }); + + QUnit.test('factory for non extendables resolves are cached', function () { + var registry = new _containerIndex.Registry(); + var PostController = {}; + var resolveWasCalled = []; + + registry.resolver = { + resolve: function (fullName) { + resolveWasCalled.push(fullName); + return PostController; + } + }; + + deepEqual(resolveWasCalled, []); + registry.resolve('foo:post'); + deepEqual(resolveWasCalled, ['foo:post']); + + registry.resolve('foo:post'); + deepEqual(resolveWasCalled, ['foo:post']); + }); + + QUnit.test('registry.container creates a container', function () { + var registry = new _containerIndex.Registry(); + var PostController = _internalTestHelpers.factory(); + registry.register('controller:post', PostController); + + var container = registry.container(); + var postController = container.lookup('controller:post'); + + ok(postController instanceof PostController, 'The lookup is an instance of the registered factory'); + }); + + QUnit.test('`describe` will be handled by the resolver, then by the fallback registry, if available', function () { + var fallback = { + describe: function (fullName) { + return fullName + '-fallback'; + } + }; + + var resolver = { + lookupDescription: function (fullName) { + return fullName + '-resolver'; + } + }; + + var registry = new _containerIndex.Registry({ fallback: fallback, resolver: resolver }); + + equal(registry.describe('controller:post'), 'controller:post-resolver', '`describe` handled by the resolver first.'); + + registry.resolver = null; + + equal(registry.describe('controller:post'), 'controller:post-fallback', '`describe` handled by fallback registry next.'); + + registry.fallback = null; + + equal(registry.describe('controller:post'), 'controller:post', '`describe` by default returns argument.'); + }); + + QUnit.test('`normalizeFullName` will be handled by the resolver, then by the fallback registry, if available', function () { + var fallback = { + normalizeFullName: function (fullName) { + return fullName + '-fallback'; + } + }; + + var resolver = { + normalize: function (fullName) { + return fullName + '-resolver'; + } + }; + + var registry = new _containerIndex.Registry({ fallback: fallback, resolver: resolver }); + + equal(registry.normalizeFullName('controller:post'), 'controller:post-resolver', '`normalizeFullName` handled by the resolver first.'); + + registry.resolver = null; + + equal(registry.normalizeFullName('controller:post'), 'controller:post-fallback', '`normalizeFullName` handled by fallback registry next.'); + + registry.fallback = null; + + equal(registry.normalizeFullName('controller:post'), 'controller:post', '`normalizeFullName` by default returns argument.'); + }); + + QUnit.test('`makeToString` will be handled by the resolver, then by the fallback registry, if available', function () { + var fallback = { + makeToString: function (fullName) { + return fullName + '-fallback'; + } + }; + + var resolver = { + makeToString: function (fullName) { + return fullName + '-resolver'; + } + }; + + var registry = new _containerIndex.Registry({ fallback: fallback, resolver: resolver }); + + equal(registry.makeToString('controller:post'), 'controller:post-resolver', '`makeToString` handled by the resolver first.'); + + registry.resolver = null; + + equal(registry.makeToString('controller:post'), 'controller:post-fallback', '`makeToString` handled by fallback registry next.'); + + registry.fallback = null; + + equal(registry.makeToString('controller:post'), 'controller:post', '`makeToString` by default returns argument.'); + }); + + QUnit.test('`resolve` can be handled by a fallback registry', function () { + var fallback = new _containerIndex.Registry(); + + var registry = new _containerIndex.Registry({ fallback: fallback }); + var PostController = _internalTestHelpers.factory(); + + fallback.register('controller:post', PostController); + + var PostControllerFactory = registry.resolve('controller:post'); + + ok(PostControllerFactory, 'factory is returned'); + ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController'); + }); + + QUnit.test('`has` can be handled by a fallback registry', function () { + var fallback = new _containerIndex.Registry(); + + var registry = new _containerIndex.Registry({ fallback: fallback }); + var PostController = _internalTestHelpers.factory(); + + fallback.register('controller:post', PostController); + + equal(registry.has('controller:post'), true, 'Fallback registry is checked for registration'); + }); + + QUnit.test('`getInjections` includes injections from a fallback registry', function () { + var fallback = new _containerIndex.Registry(); + var registry = new _containerIndex.Registry({ fallback: fallback }); + + equal(registry.getInjections('model:user').length, 0, 'No injections in the primary registry'); + + fallback.injection('model:user', 'post', 'model:post'); + + equal(registry.getInjections('model:user').length, 1, 'Injections from the fallback registry are merged'); + }); + + QUnit.test('`getTypeInjections` includes type injections from a fallback registry', function () { + var fallback = new _containerIndex.Registry(); + var registry = new _containerIndex.Registry({ fallback: fallback }); + + equal(registry.getTypeInjections('model').length, 0, 'No injections in the primary registry'); + + fallback.injection('model', 'source', 'source:main'); + + equal(registry.getTypeInjections('model').length, 1, 'Injections from the fallback registry are merged'); + }); + + QUnit.test('`getFactoryInjections` includes factory injections from a fallback registry', function () { + var fallback = new _containerIndex.Registry(); + var registry = new _containerIndex.Registry({ fallback: fallback }); + + equal(registry.getFactoryInjections('model:user').length, 0, 'No factory injections in the primary registry'); + + fallback.factoryInjection('model:user', 'store', 'store:main'); + + equal(registry.getFactoryInjections('model:user').length, 1, 'Factory injections from the fallback registry are merged'); + }); + + QUnit.test('`getFactoryTypeInjections` includes factory type injections from a fallback registry', function () { + var fallback = new _containerIndex.Registry(); + var registry = new _containerIndex.Registry({ fallback: fallback }); + + equal(registry.getFactoryTypeInjections('model').length, 0, 'No factory type injections in the primary registry'); + + fallback.factoryInjection('model', 'store', 'store:main'); + + equal(registry.getFactoryTypeInjections('model').length, 1, 'Factory type injections from the fallback registry are merged'); + }); + + QUnit.test('`knownForType` contains keys for each item of a given type', function () { + var registry = new _containerIndex.Registry(); + + registry.register('foo:bar-baz', 'baz'); + registry.register('foo:qux-fez', 'fez'); + + var found = registry.knownForType('foo'); + + deepEqual(found, { + 'foo:bar-baz': true, + 'foo:qux-fez': true + }); + }); + + QUnit.test('`knownForType` includes fallback registry results', function () { + var fallback = new _containerIndex.Registry(); + var registry = new _containerIndex.Registry({ fallback: fallback }); + + registry.register('foo:bar-baz', 'baz'); + registry.register('foo:qux-fez', 'fez'); + fallback.register('foo:zurp-zorp', 'zorp'); + + var found = registry.knownForType('foo'); + + deepEqual(found, { + 'foo:bar-baz': true, + 'foo:qux-fez': true, + 'foo:zurp-zorp': true + }); + }); + + QUnit.test('`knownForType` is called on the resolver if present', function () { + expect(3); + + var resolver = { + knownForType: function (type) { + ok(true, 'knownForType called on the resolver'); + equal(type, 'foo', 'the type was passed through'); + + return { 'foo:yorp': true }; + } + }; + + var registry = new _containerIndex.Registry({ + resolver: resolver + }); + registry.register('foo:bar-baz', 'baz'); + + var found = registry.knownForType('foo'); + + deepEqual(found, { + 'foo:yorp': true, + 'foo:bar-baz': true + }); + }); + + QUnit.test('A registry can be created with a deprecated `resolver` function instead of an object', function () { + expect(2); + + var registry = undefined; + + expectDeprecation(function () { + registry = new _containerIndex.Registry({ + resolver: function (fullName) { + return fullName + '-resolved'; + } + }); + }, 'Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.'); + + equal(registry.resolve('foo:bar'), 'foo:bar-resolved', '`resolve` still calls the deprecated function'); + }); + + QUnit.test('resolver.expandLocalLookup is not required', function (assert) { + assert.expect(1); + + var registry = new _containerIndex.Registry({ + resolver: {} + }); + + var result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, null); + }); + + QUnit.test('expandLocalLookup is called on the resolver if present', function (assert) { + assert.expect(4); + + var resolver = { + expandLocalLookup: function (targetFullName, sourceFullName) { + assert.ok(true, 'expandLocalLookup is called on the resolver'); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); + + return 'foo:qux/bar'; + } + }; + + var registry = new _containerIndex.Registry({ + resolver: resolver + }); + + var result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, 'foo:qux/bar'); + }); + + QUnit.test('`expandLocalLookup` is handled by the resolver, then by the fallback registry, if available', function (assert) { + assert.expect(9); + + var fallbackResolver = { + expandLocalLookup: function (targetFullName, sourceFullName) { + assert.ok(true, 'expandLocalLookup is called on the fallback resolver'); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); + + return 'foo:qux/bar-fallback'; + } + }; + + var resolver = { + expandLocalLookup: function (targetFullName, sourceFullName) { + assert.ok(true, 'expandLocalLookup is called on the resolver'); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); + + return 'foo:qux/bar-resolver'; + } + }; + + var fallbackRegistry = new _containerIndex.Registry({ + resolver: fallbackResolver + }); + + var registry = new _containerIndex.Registry({ + fallback: fallbackRegistry, + resolver: resolver + }); + + var result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, 'foo:qux/bar-resolver', 'handled by the resolver'); + + registry.resolver = null; + + result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, 'foo:qux/bar-fallback', 'handled by the fallback registry'); + + registry.fallback = null; + + result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, null, 'null is returned by default when no resolver or fallback registry is present'); + }); + + QUnit.test('resolver.expandLocalLookup result is cached', function (assert) { + assert.expect(3); + var result = undefined; + + var resolver = { + expandLocalLookup: function (targetFullName, sourceFullName) { + assert.ok(true, 'expandLocalLookup is called on the resolver'); + + return 'foo:qux/bar'; + } + }; + + var registry = new _containerIndex.Registry({ + resolver: resolver + }); + + result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, 'foo:qux/bar'); + + result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, 'foo:qux/bar'); + }); + + QUnit.test('resolver.expandLocalLookup cache is busted when any unregister is called', function (assert) { + assert.expect(4); + var result = undefined; + + var resolver = { + expandLocalLookup: function (targetFullName, sourceFullName) { + assert.ok(true, 'expandLocalLookup is called on the resolver'); + + return 'foo:qux/bar'; + } + }; + + var registry = new _containerIndex.Registry({ + resolver: resolver + }); + + result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, 'foo:qux/bar'); + + registry.unregister('foo:bar'); + + result = registry.expandLocalLookup('foo:bar', { + source: 'baz:qux' + }); + + assert.equal(result, 'foo:qux/bar'); + }); + + QUnit.test('resolve calls expandLocallookup when it receives options.source', function (assert) { + assert.expect(3); + + var resolver = { + resolve: function () {}, + expandLocalLookup: function (targetFullName, sourceFullName) { + assert.ok(true, 'expandLocalLookup is called on the resolver'); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); + + return 'foo:qux/bar'; + } + }; + + var registry = new _containerIndex.Registry({ + resolver: resolver + }); + + registry.resolve('foo:bar', { + source: 'baz:qux' + }); + }); + + QUnit.test('has uses expandLocalLookup', function (assert) { + assert.expect(5); + var resolvedFullNames = []; + var result = undefined; + + var resolver = { + resolve: function (name) { + resolvedFullNames.push(name); + + return 'yippie!'; + }, + + expandLocalLookup: function (targetFullName, sourceFullName) { + assert.ok(true, 'expandLocalLookup is called on the resolver'); + + if (targetFullName === 'foo:bar') { + return 'foo:qux/bar'; + } else { + return null; + } + } + }; + + var registry = new _containerIndex.Registry({ + resolver: resolver + }); + + result = registry.has('foo:bar', { + source: 'baz:qux' + }); + + assert.ok(result, 'found foo:bar/qux'); + + result = registry.has('foo:baz', { + source: 'baz:qux' + }); + + assert.ok(!result, 'foo:baz/qux not found'); + + assert.deepEqual(['foo:qux/bar'], resolvedFullNames); + }); +}); +enifed('container/tests/registry_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | container/tests/registry_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'container/tests/registry_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/initializers/dom-templates.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/initializers/dom-templates.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/initializers/dom-templates.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/system/application-instance.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/system/application-instance.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/system/application-instance.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/system/application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/system/application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/system/application.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/system/engine-instance.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/system/engine-instance.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/system/engine-instance.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/system/engine-parent.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/system/engine-parent.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/system/engine-parent.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/system/engine.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/system/engine.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/system/engine.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/system/resolver.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/system/resolver.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/system/resolver.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/application_instance_test', ['exports', 'ember-application/system/engine', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-metal', 'ember-views', 'container', 'internal-test-helpers', 'ember-runtime'], function (exports, _emberApplicationSystemEngine, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberMetal, _emberViews, _container, _internalTestHelpers, _emberRuntime) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + + var application = undefined, + appInstance = undefined; + + QUnit.module('Ember.ApplicationInstance', { + setup: function () { + _emberViews.jQuery('#qunit-fixture').html('
    HI
    HI
    '); + application = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ rootElement: '#one', router: null }); + }); + }, + + teardown: function () { + _emberViews.jQuery('#qunit-fixture').empty(); + + if (appInstance) { + _emberMetal.run(appInstance, 'destroy'); + } + + if (application) { + _emberMetal.run(application, 'destroy'); + } + } + }); + + QUnit.test('an application instance can be created based upon an application', function () { + appInstance = _emberMetal.run(function () { + return appInstance = _emberApplicationSystemApplicationInstance.default.create({ application: application }); + }); + + ok(appInstance, 'instance should be created'); + equal(appInstance.application, application, 'application should be set to parent'); + }); + + QUnit.test('properties (and aliases) are correctly assigned for accessing the container and registry', function () { + expect(9); + + appInstance = _emberMetal.run(function () { + return _emberApplicationSystemApplicationInstance.default.create({ application: application }); + }); + + ok(appInstance, 'instance should be created'); + ok(appInstance.__container__, '#__container__ is accessible'); + ok(appInstance.__registry__, '#__registry__ is accessible'); + + ok(typeof appInstance.container.lookup === 'function', '#container.lookup is available as a function'); + + // stub with a no-op to keep deprecation test simple + appInstance.__container__.lookup = function () { + ok(true, '#loookup alias is called correctly'); + }; + + expectDeprecation(function () { + appInstance.container.lookup(); + }, /Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead./); + + ok(typeof appInstance.registry.register === 'function', '#registry.register is available as a function'); + appInstance.__registry__.register = function () { + ok(true, '#register alias is called correctly'); + }; + + expectDeprecation(function () { + appInstance.registry.register(); + }, /Using `ApplicationInstance.registry.register` is deprecated. Please use `ApplicationInstance.register` instead./); + }); + + QUnit.test('customEvents added to the application before setupEventDispatcher', function (assert) { + assert.expect(1); + + appInstance = _emberMetal.run(function () { + return _emberApplicationSystemApplicationInstance.default.create({ application: application }); + }); + + application.customEvents = { + awesome: 'sauce' + }; + + var eventDispatcher = appInstance.lookup('event_dispatcher:main'); + eventDispatcher.setup = function (events) { + assert.equal(events.awesome, 'sauce'); + }; + + appInstance.setupEventDispatcher(); + }); + + QUnit.test('customEvents added to the application before setupEventDispatcher', function (assert) { + assert.expect(1); + + _emberMetal.run(function () { + return appInstance = _emberApplicationSystemApplicationInstance.default.create({ application: application }); + }); + + application.customEvents = { + awesome: 'sauce' + }; + + var eventDispatcher = appInstance.lookup('event_dispatcher:main'); + eventDispatcher.setup = function (events) { + assert.equal(events.awesome, 'sauce'); + }; + + appInstance.setupEventDispatcher(); + }); + + QUnit.test('customEvents added to the application instance before setupEventDispatcher', function (assert) { + assert.expect(1); + + appInstance = _emberMetal.run(function () { + return _emberApplicationSystemApplicationInstance.default.create({ application: application }); + }); + + appInstance.customEvents = { + awesome: 'sauce' + }; + + var eventDispatcher = appInstance.lookup('event_dispatcher:main'); + eventDispatcher.setup = function (events) { + assert.equal(events.awesome, 'sauce'); + }; + + appInstance.setupEventDispatcher(); + }); + + QUnit.test('unregistering a factory clears all cached instances of that factory', function (assert) { + assert.expect(3); + + appInstance = _emberMetal.run(function () { + return _emberApplicationSystemApplicationInstance.default.create({ application: application }); + }); + + var PostController = _internalTestHelpers.factory(); + + appInstance.register('controller:post', PostController); + + var postController1 = appInstance.lookup('controller:post'); + assert.ok(postController1, 'lookup creates instance'); + + appInstance.unregister('controller:post'); + appInstance.register('controller:post', PostController); + + var postController2 = appInstance.lookup('controller:post'); + assert.ok(postController2, 'lookup creates instance'); + + assert.notStrictEqual(postController1, postController2, 'lookup creates a brand new instance, because the previous one was reset'); + }); + + QUnit.test('can build and boot a registered engine', function (assert) { + assert.expect(10); + + var ChatEngine = _emberApplicationSystemEngine.default.extend(); + var chatEngineInstance = undefined; + + application.register('engine:chat', ChatEngine); + + _emberMetal.run(function () { + appInstance = _emberApplicationSystemApplicationInstance.default.create({ application: application }); + appInstance.setupRegistry(); + chatEngineInstance = appInstance.buildChildEngineInstance('chat'); + }); + + return chatEngineInstance.boot().then(function () { + assert.ok(true, 'boot successful'); + + var registrations = ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment']; + + registrations.forEach(function (key) { + assert.strictEqual(chatEngineInstance.resolveRegistration(key), appInstance.resolveRegistration(key), 'Engine and parent app share registrations for \'' + key + '\''); + }); + + var singletons = ['router:main', _container.privatize(_templateObject), '-view-registry:main', '-environment:main']; + + var env = appInstance.lookup('-environment:main'); + singletons.push(env.isInteractive ? 'renderer:-dom' : 'renderer:-inert'); + + singletons.forEach(function (key) { + assert.strictEqual(chatEngineInstance.lookup(key), appInstance.lookup(key), 'Engine and parent app share singleton \'' + key + '\''); + }); + }); + }); + + QUnit.test('can build a registry via Ember.ApplicationInstance.setupRegistry() -- simulates ember-test-helpers', function (assert) { + var namespace = _emberRuntime.Object.create({ + Resolver: { create: function () {} } + }); + + var registry = _emberApplicationSystemApplication.default.buildRegistry(namespace); + + _emberApplicationSystemApplicationInstance.default.setupRegistry(registry); + + assert.equal(registry.resolve('service:-document'), document); + }); +}); +enifed('ember-application/tests/system/application_instance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/application_instance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/application_instance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/application_test', ['exports', 'ember', 'ember-environment', 'ember-metal', 'ember-application/system/application', 'ember-application/system/resolver', 'ember-routing', 'ember-views', 'ember-runtime', 'ember-template-compiler', 'ember-glimmer', 'container', 'ember-application/tests/test-helpers/registry-check'], function (exports, _ember, _emberEnvironment, _emberMetal, _emberApplicationSystemApplication, _emberApplicationSystemResolver, _emberRouting, _emberViews, _emberRuntime, _emberTemplateCompiler, _emberGlimmer, _container, _emberApplicationTestsTestHelpersRegistryCheck) { + /*globals EmberDev */ + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); + + var trim = _emberViews.jQuery.trim; + + var app = undefined, + application = undefined, + originalLookup = undefined, + originalDebug = undefined, + originalWarn = undefined; + + QUnit.module('Ember.Application', { + setup: function () { + originalLookup = _emberEnvironment.context.lookup; + originalDebug = _emberMetal.getDebugFunction('debug'); + originalWarn = _emberMetal.getDebugFunction('warn'); + + _emberViews.jQuery('#qunit-fixture').html('
    HI
    HI
    '); + application = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ rootElement: '#one', router: null }); + }); + }, + + teardown: function () { + _emberViews.jQuery('#qunit-fixture').empty(); + _emberMetal.setDebugFunction('debug', originalDebug); + _emberMetal.setDebugFunction('warn', originalWarn); + + _emberEnvironment.context.lookup = originalLookup; + + if (application) { + _emberMetal.run(application, 'destroy'); + } + + if (app) { + _emberMetal.run(app, 'destroy'); + } + } + }); + + QUnit.test('you can make a new application in a non-overlapping element', function () { + app = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ rootElement: '#two', router: null }); + }); + + _emberMetal.run(app, 'destroy'); + ok(true, 'should not raise'); + }); + + QUnit.test('you cannot make a new application that is a parent of an existing application', function () { + expectAssertion(function () { + _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ rootElement: '#qunit-fixture' }); + }); + }); + }); + + QUnit.test('you cannot make a new application that is a descendant of an existing application', function () { + expectAssertion(function () { + _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ rootElement: '#one-child' }); + }); + }); + }); + + QUnit.test('you cannot make a new application that is a duplicate of an existing application', function () { + expectAssertion(function () { + _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ rootElement: '#one' }); + }); + }); + }); + + QUnit.test('you cannot make two default applications without a rootElement error', function () { + expectAssertion(function () { + _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ router: false }); + }); + }); + }); + + QUnit.test('acts like a namespace', function () { + var lookup = _emberEnvironment.context.lookup = {}; + + app = _emberMetal.run(function () { + return lookup.TestApp = _emberApplicationSystemApplication.default.create({ rootElement: '#two', router: false }); + }); + + _emberRuntime.setNamespaceSearchDisabled(false); + app.Foo = _emberRuntime.Object.extend(); + equal(app.Foo.toString(), 'TestApp.Foo', 'Classes pick up their parent namespace'); + }); + + QUnit.test('includes deprecated access to `application.registry`', function () { + expect(3); + + ok(typeof application.registry.register === 'function', '#registry.register is available as a function'); + + application.__registry__.register = function () { + ok(true, '#register alias is called correctly'); + }; + + expectDeprecation(function () { + application.registry.register(); + }, /Using `Application.registry.register` is deprecated. Please use `Application.register` instead./); + }); + + QUnit.test('builds a registry', function () { + strictEqual(application.resolveRegistration('application:main'), application, 'application:main is registered'); + deepEqual(application.registeredOptionsForType('component'), { singleton: false }, 'optionsForType \'component\''); + deepEqual(application.registeredOptionsForType('view'), { singleton: false }, 'optionsForType \'view\''); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'controller:basic'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, '-view-registry:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'view', '_viewRegistry', '-view-registry:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'route', '_topLevelViewTemplate', 'template:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'route:basic'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'event_dispatcher:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'router:main', 'namespace', 'application:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'view:-outlet', 'namespace', 'application:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'location:auto'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'location:hash'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'location:history'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'location:none'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'controller', 'target', 'router:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'controller', 'namespace', 'application:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, _container.privatize(_templateObject)); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'router', '_bucketCache', _container.privatize(_templateObject)); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'route', '_bucketCache', _container.privatize(_templateObject)); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'route', 'router', 'router:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'component:-text-field'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'component:-text-area'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'component:-checkbox'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'component:link-to'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'service:-routing'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'service:-routing', 'router', 'router:main'); + + // DEBUGGING + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'resolver-for-debugging:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'container-debug-adapter:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'component-lookup:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'service:-glimmer-environment'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'service:-dom-changes'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'service:-dom-tree-construction'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'renderer', 'env', 'service:-glimmer-environment'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'view:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'renderer:-dom'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'renderer:-inert'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, _container.privatize(_templateObject2)); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(application, 'template:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'view:-outlet', 'template', 'template:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(application, 'template', 'env', 'service:-glimmer-environment'); + deepEqual(application.registeredOptionsForType('helper'), { instantiate: false }, 'optionsForType \'helper\''); + }); + + var originalLogVersion = _emberEnvironment.ENV.LOG_VERSION; + + QUnit.module('Ember.Application initialization', { + teardown: function () { + if (app) { + _emberMetal.run(app, 'destroy'); + } + _emberGlimmer.setTemplates({}); + _emberEnvironment.ENV.LOG_VERSION = originalLogVersion; + } + }); + + QUnit.test('initialized application goes to initial route', function () { + _emberMetal.run(function () { + app = _emberApplicationSystemApplication.default.create({ + rootElement: '#qunit-fixture' + }); + + app.Router.reopen({ + location: 'none' + }); + + app.register('template:application', _emberTemplateCompiler.compile('{{outlet}}')); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Hi from index

    ')); + }); + + equal(_emberViews.jQuery('#qunit-fixture h1').text(), 'Hi from index'); + }); + + QUnit.test('ready hook is called before routing begins', function () { + expect(2); + + _emberMetal.run(function () { + function registerRoute(application, name, callback) { + var route = _emberRouting.Route.extend({ + activate: callback + }); + + application.register('route:' + name, route); + } + + var MyApplication = _emberApplicationSystemApplication.default.extend({ + ready: function () { + registerRoute(this, 'index', function () { + ok(true, 'last-minute route is activated'); + }); + } + }); + + app = MyApplication.create({ + rootElement: '#qunit-fixture' + }); + + app.Router.reopen({ + location: 'none' + }); + + registerRoute(app, 'application', function () { + return ok(true, 'normal route is activated'); + }); + }); + }); + + QUnit.test('initialize application via initialize call', function () { + _emberMetal.run(function () { + app = _emberApplicationSystemApplication.default.create({ + rootElement: '#qunit-fixture' + }); + + app.Router.reopen({ + location: 'none' + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Hello!

    ')); + }); + + // This is not a public way to access the container; we just + // need to make some assertions about the created router + var router = app.__container__.lookup('router:main'); + equal(router instanceof _emberRouting.Router, true, 'Router was set from initialize call'); + equal(router.location instanceof _emberRouting.NoneLocation, true, 'Location was set from location implementation name'); + }); + + QUnit.test('initialize application with stateManager via initialize call from Router class', function () { + _emberMetal.run(function () { + app = _emberApplicationSystemApplication.default.create({ + rootElement: '#qunit-fixture' + }); + + app.Router.reopen({ + location: 'none' + }); + + app.register('template:application', _emberTemplateCompiler.compile('

    Hello!

    ')); + }); + + var router = app.__container__.lookup('router:main'); + equal(router instanceof _emberRouting.Router, true, 'Router was set from initialize call'); + equal(_emberViews.jQuery('#qunit-fixture h1').text(), 'Hello!'); + }); + + QUnit.test('ApplicationView is inserted into the page', function () { + _emberMetal.run(function () { + app = _emberApplicationSystemApplication.default.create({ + rootElement: '#qunit-fixture' + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Hello!

    ')); + + app.ApplicationController = _emberRuntime.Controller.extend(); + + app.Router.reopen({ + location: 'none' + }); + }); + + equal(_emberViews.jQuery('#qunit-fixture h1').text(), 'Hello!'); + }); + + QUnit.test('Minimal Application initialized with just an application template', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + app = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ + rootElement: '#qunit-fixture' + }); + }); + + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'Hello World'); + }); + + QUnit.test('enable log of libraries with an ENV var', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + var messages = []; + + _emberEnvironment.ENV.LOG_VERSION = true; + + _emberMetal.setDebugFunction('debug', function (message) { + return messages.push(message); + }); + + _emberMetal.libraries.register('my-lib', '2.0.0a'); + + app = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ + rootElement: '#qunit-fixture' + }); + }); + + equal(messages[1], 'Ember : ' + _ember.VERSION); + equal(messages[2], 'jQuery : ' + _emberViews.jQuery().jquery); + equal(messages[3], 'my-lib : ' + '2.0.0a'); + + _emberMetal.libraries.deRegister('my-lib'); + }); + + QUnit.test('disable log version of libraries with an ENV var', function () { + var logged = false; + + _emberEnvironment.ENV.LOG_VERSION = false; + + _emberMetal.setDebugFunction('debug', function () { + return logged = true; + }); + + _emberViews.jQuery('#qunit-fixture').empty(); + + _emberMetal.run(function () { + app = _emberApplicationSystemApplication.default.create({ + rootElement: '#qunit-fixture' + }); + + app.Router.reopen({ + location: 'none' + }); + }); + + ok(!logged, 'library version logging skipped'); + }); + + QUnit.test('can resolve custom router', function () { + var CustomRouter = _emberRouting.Router.extend(); + + var Resolver = _emberApplicationSystemResolver.default.extend({ + resolveMain: function (parsedName) { + if (parsedName.type === 'router') { + return CustomRouter; + } else { + return this._super(parsedName); + } + } + }); + + app = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ + Resolver: Resolver + }); + }); + + ok(app.__container__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router'); + }); + + QUnit.test('can specify custom router', function () { + app = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ + Router: _emberRouting.Router.extend() + }); + }); + + ok(app.__container__.lookup('router:main') instanceof _emberRouting.Router, 'application resolved the correct router'); + }); + + QUnit.test('does not leak itself in onLoad._loaded', function () { + equal(_emberRuntime._loaded.application, undefined); + var app = _emberMetal.run(_emberApplicationSystemApplication.default, 'create'); + equal(_emberRuntime._loaded.application, app); + _emberMetal.run(app, 'destroy'); + equal(_emberRuntime._loaded.application, undefined); + }); + + QUnit.test('can build a registry via Ember.Application.buildRegistry() --- simulates ember-test-helpers', function (assert) { + var namespace = _emberRuntime.Object.create({ + Resolver: { create: function () {} } + }); + + var registry = _emberApplicationSystemApplication.default.buildRegistry(namespace); + + assert.equal(registry.resolve('application:main'), namespace); + }); +}); +enifed('ember-application/tests/system/application_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/application_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/application_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/bootstrap-test', ['exports', 'ember-metal', 'ember-application/system/application', 'ember-routing', 'ember-views', 'ember-glimmer'], function (exports, _emberMetal, _emberApplicationSystemApplication, _emberRouting, _emberViews, _emberGlimmer) { + 'use strict'; + + var app = undefined; + + QUnit.module('Ember.Application', { + teardown: function () { + if (app) { + _emberMetal.run(app, 'destroy'); + } + + _emberGlimmer.setTemplates({}); + } + }); + + QUnit.test('templates in script tags are extracted at application creation', function (assert) { + _emberViews.jQuery('#qunit-fixture').html('\n
    \n\n \n \n '); + + var application = _emberApplicationSystemApplication.default.extend(); + application.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + app = _emberMetal.run(function () { + return application.create({ rootElement: '#app' }); + }); + + assert.equal(_emberViews.jQuery('#app').text(), 'Hello World!'); + }); +}); +enifed('ember-application/tests/system/bootstrap-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/bootstrap-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/bootstrap-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/dependency_injection/custom_resolver_test', ['exports', 'ember-views', 'ember-metal', 'ember-application/system/application', 'ember-application/system/resolver', 'ember-template-compiler'], function (exports, _emberViews, _emberMetal, _emberApplicationSystemApplication, _emberApplicationSystemResolver, _emberTemplateCompiler) { + 'use strict'; + + var application = undefined; + + QUnit.module('Ember.Application Dependency Injection – customResolver', { + setup: function () { + var fallbackTemplate = _emberTemplateCompiler.compile('

    Fallback

    '); + + var Resolver = _emberApplicationSystemResolver.default.extend({ + resolveTemplate: function (resolvable) { + var resolvedTemplate = this._super(resolvable); + if (resolvedTemplate) { + return resolvedTemplate; + } + if (resolvable.fullNameWithoutType === 'application') { + return fallbackTemplate; + } else { + return; + } + } + }); + + application = _emberMetal.run(function () { + return _emberApplicationSystemApplication.default.create({ + Resolver: Resolver, + rootElement: '#qunit-fixture' + }); + }); + }, + + teardown: function () { + _emberMetal.run(application, 'destroy'); + } + }); + + QUnit.test('a resolver can be supplied to application', function () { + equal(_emberViews.jQuery('h1', application.rootElement).text(), 'Fallback'); + }); +}); +enifed('ember-application/tests/system/dependency_injection/custom_resolver_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/dependency_injection/custom_resolver_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/dependency_injection/custom_resolver_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/dependency_injection/default_resolver_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-routing', 'ember-application/system/application', 'ember-glimmer', 'ember-template-compiler'], function (exports, _emberEnvironment, _emberMetal, _emberRuntime, _emberRouting, _emberApplicationSystemApplication, _emberGlimmer, _emberTemplateCompiler) { + /* globals EmberDev */ + 'use strict'; + + var registry = undefined, + locator = undefined, + application = undefined, + originalLookup = undefined, + originalInfo = undefined; + + QUnit.module('Ember.Application Dependency Injection - default resolver', { + setup: function () { + originalLookup = _emberEnvironment.context.lookup; + application = _emberMetal.run(_emberApplicationSystemApplication.default, 'create'); + + registry = application.__registry__; + locator = application.__container__; + originalInfo = _emberMetal.getDebugFunction('info'); + }, + + teardown: function () { + _emberGlimmer.setTemplates({}); + _emberEnvironment.context.lookup = originalLookup; + _emberMetal.run(application, 'destroy'); + var UserInterfaceNamespace = _emberRuntime.Namespace.NAMESPACES_BY_ID['UserInterface']; + if (UserInterfaceNamespace) { + _emberMetal.run(UserInterfaceNamespace, 'destroy'); + } + + _emberMetal.setDebugFunction('info', originalInfo); + } + }); + + QUnit.test('the default resolver can look things up in other namespaces', function () { + var UserInterface = _emberEnvironment.context.lookup.UserInterface = _emberRuntime.Namespace.create(); + UserInterface.NavigationController = _emberRuntime.Controller.extend(); + + var nav = locator.lookup('controller:userInterface/navigation'); + + ok(nav instanceof UserInterface.NavigationController, 'the result should be an instance of the specified class'); + }); + + QUnit.test('the default resolver looks up templates in Ember.TEMPLATES', function () { + var fooTemplate = _emberTemplateCompiler.compile('foo template'); + var fooBarTemplate = _emberTemplateCompiler.compile('fooBar template'); + var fooBarBazTemplate = _emberTemplateCompiler.compile('fooBar/baz template'); + + _emberGlimmer.setTemplate('foo', fooTemplate); + _emberGlimmer.setTemplate('fooBar', fooBarTemplate); + _emberGlimmer.setTemplate('fooBar/baz', fooBarBazTemplate); + + ignoreDeprecation(function () { + equal(locator.lookupFactory('template:foo'), fooTemplate, 'resolves template:foo'); + equal(locator.lookupFactory('template:fooBar'), fooBarTemplate, 'resolves template:foo_bar'); + equal(locator.lookupFactory('template:fooBar.baz'), fooBarBazTemplate, 'resolves template:foo_bar.baz'); + }); + + if (true) { + equal(locator.factoryFor('template:foo').class, fooTemplate, 'resolves template:foo'); + equal(locator.factoryFor('template:fooBar').class, fooBarTemplate, 'resolves template:foo_bar'); + equal(locator.factoryFor('template:fooBar.baz').class, fooBarBazTemplate, 'resolves template:foo_bar.baz'); + } + }); + + QUnit.test('the default resolver looks up basic name as no prefix', function () { + ok(_emberRuntime.Controller.detect(locator.lookup('controller:basic')), 'locator looks up correct controller'); + }); + + function detectEqual(first, second, message) { + ok(first.detect(second), message); + } + + QUnit.test('the default resolver looks up arbitrary types on the namespace', function () { + application.FooManager = _emberRuntime.Object.extend({}); + + detectEqual(application.FooManager, registry.resolve('manager:foo'), 'looks up FooManager on application'); + }); + + QUnit.test('the default resolver resolves models on the namespace', function () { + application.Post = _emberRuntime.Object.extend({}); + + ignoreDeprecation(function () { + detectEqual(application.Post, locator.lookupFactory('model:post'), 'looks up Post model on application'); + }); + if (true) { + detectEqual(application.Post, locator.factoryFor('model:post').class, 'looks up Post model on application'); + } + }); + + QUnit.test('the default resolver resolves *:main on the namespace', function () { + application.FooBar = _emberRuntime.Object.extend({}); + + ignoreDeprecation(function () { + detectEqual(application.FooBar, locator.lookupFactory('foo-bar:main'), 'looks up FooBar type without name on application'); + }); + if (true) { + detectEqual(application.FooBar, locator.factoryFor('foo-bar:main').class, 'looks up FooBar type without name on application'); + } + }); + + if (true) { + QUnit.test('the default resolver resolves container-registered helpers', function () { + var shorthandHelper = _emberGlimmer.helper(function () {}); + var helper = _emberGlimmer.Helper.extend(); + + application.register('helper:shorthand', shorthandHelper); + application.register('helper:complete', helper); + + var lookedUpShorthandHelper = locator.factoryFor('helper:shorthand').class; + + ok(lookedUpShorthandHelper.isHelperInstance, 'shorthand helper isHelper'); + + var lookedUpHelper = locator.factoryFor('helper:complete').class; + + ok(lookedUpHelper.isHelperFactory, 'complete helper is factory'); + ok(helper.detect(lookedUpHelper), 'looked up complete helper'); + }); + } + + QUnit.test('the default resolver resolves container-registered helpers via lookupFor', function () { + var shorthandHelper = _emberGlimmer.helper(function () {}); + var helper = _emberGlimmer.Helper.extend(); + + application.register('helper:shorthand', shorthandHelper); + application.register('helper:complete', helper); + + ignoreDeprecation(function () { + var lookedUpShorthandHelper = locator.lookupFactory('helper:shorthand'); + + ok(lookedUpShorthandHelper.isHelperInstance, 'shorthand helper isHelper'); + + var lookedUpHelper = locator.lookupFactory('helper:complete'); + + ok(lookedUpHelper.isHelperFactory, 'complete helper is factory'); + ok(helper.detect(lookedUpHelper), 'looked up complete helper'); + }); + }); + + QUnit.test('the default resolver resolves helpers on the namespace', function () { + var ShorthandHelper = _emberGlimmer.helper(function () {}); + var CompleteHelper = _emberGlimmer.Helper.extend(); + var LegacyHTMLBarsBoundHelper = undefined; + + expectDeprecation(function () { + LegacyHTMLBarsBoundHelper = _emberGlimmer.makeBoundHelper(function () {}); + }, 'Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.'); + + application.ShorthandHelper = ShorthandHelper; + application.CompleteHelper = CompleteHelper; + application.LegacyHtmlBarsBoundHelper = LegacyHTMLBarsBoundHelper; // Must use lowered "tml" in "HTMLBars" for resolver to find this + + var resolvedShorthand = registry.resolve('helper:shorthand'); + var resolvedComplete = registry.resolve('helper:complete'); + var resolvedLegacyHTMLBars = registry.resolve('helper:legacy-html-bars-bound'); + + equal(resolvedShorthand, ShorthandHelper, 'resolve fetches the shorthand helper factory'); + equal(resolvedComplete, CompleteHelper, 'resolve fetches the complete helper factory'); + equal(resolvedLegacyHTMLBars, LegacyHTMLBarsBoundHelper, 'resolves legacy HTMLBars bound helper'); + }); + + QUnit.test('the default resolver resolves to the same instance, no matter the notation ', function () { + application.NestedPostController = _emberRuntime.Controller.extend({}); + + equal(locator.lookup('controller:nested-post'), locator.lookup('controller:nested_post'), 'looks up NestedPost controller on application'); + }); + + QUnit.test('the default resolver throws an error if the fullName to resolve is invalid', function () { + throws(function () { + registry.resolve(undefined); + }, TypeError, /Invalid fullName/); + throws(function () { + registry.resolve(null); + }, TypeError, /Invalid fullName/); + throws(function () { + registry.resolve(''); + }, TypeError, /Invalid fullName/); + throws(function () { + registry.resolve(''); + }, TypeError, /Invalid fullName/); + throws(function () { + registry.resolve(':'); + }, TypeError, /Invalid fullName/); + throws(function () { + registry.resolve('model'); + }, TypeError, /Invalid fullName/); + throws(function () { + registry.resolve('model:'); + }, TypeError, /Invalid fullName/); + throws(function () { + registry.resolve(':type'); + }, TypeError, /Invalid fullName/); + }); + + QUnit.test('the default resolver logs hits if `LOG_RESOLVER` is set', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + expect(3); + + application.LOG_RESOLVER = true; + application.ScoobyDoo = _emberRuntime.Object.extend(); + application.toString = function () { + return 'App'; + }; + + _emberMetal.setDebugFunction('info', function (symbol, name, padding, lookupDescription) { + equal(symbol, '[✓]', 'proper symbol is printed when a module is found'); + equal(name, 'doo:scooby', 'proper lookup value is logged'); + equal(lookupDescription, 'App.ScoobyDoo'); + }); + + registry.resolve('doo:scooby'); + }); + + QUnit.test('the default resolver logs misses if `LOG_RESOLVER` is set', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + expect(3); + + application.LOG_RESOLVER = true; + application.toString = function () { + return 'App'; + }; + + _emberMetal.setDebugFunction('info', function (symbol, name, padding, lookupDescription) { + equal(symbol, '[ ]', 'proper symbol is printed when a module is not found'); + equal(name, 'doo:scooby', 'proper lookup value is logged'); + equal(lookupDescription, 'App.ScoobyDoo'); + }); + + registry.resolve('doo:scooby'); + }); + + QUnit.test('doesn\'t log without LOG_RESOLVER', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + var infoCount = 0; + + application.ScoobyDoo = _emberRuntime.Object.extend(); + + _emberMetal.setDebugFunction('info', function (symbol, name) { + return infoCount = infoCount + 1; + }); + + registry.resolve('doo:scooby'); + registry.resolve('doo:scrappy'); + equal(infoCount, 0, 'Logger.info should not be called if LOG_RESOLVER is not set'); + }); + + QUnit.test('lookup description', function () { + application.toString = function () { + return 'App'; + }; + + equal(registry.describe('controller:foo'), 'App.FooController', 'Type gets appended at the end'); + equal(registry.describe('controller:foo.bar'), 'App.FooBarController', 'dots are removed'); + equal(registry.describe('model:foo'), 'App.Foo', 'models don\'t get appended at the end'); + }); + + QUnit.test('assertion for routes without isRouteFactory property', function () { + application.FooRoute = _emberGlimmer.Component.extend(); + + expectAssertion(function () { + return registry.resolve('route:foo'); + }, /to resolve to an Ember.Route/, 'Should assert'); + }); + + QUnit.test('no assertion for routes that extend from Ember.Route', function () { + expect(0); + application.FooRoute = _emberRouting.Route.extend(); + registry.resolve('route:foo'); + }); + + QUnit.test('deprecation warning for service factories without isServiceFactory property', function () { + expectDeprecation(/service factories must have an `isServiceFactory` property/); + application.FooService = _emberRuntime.Object.extend(); + registry.resolve('service:foo'); + }); + + QUnit.test('no deprecation warning for service factories that extend from Ember.Service', function () { + expectNoDeprecation(); + application.FooService = _emberRuntime.Service.extend(); + registry.resolve('service:foo'); + }); + + QUnit.test('deprecation warning for component factories without isComponentFactory property', function () { + expectDeprecation(/component factories must have an `isComponentFactory` property/); + application.FooComponent = _emberRuntime.Object.extend(); + registry.resolve('component:foo'); + }); + + QUnit.test('no deprecation warning for component factories that extend from Ember.Component', function () { + expectNoDeprecation(); + application.FooView = _emberGlimmer.Component.extend(); + registry.resolve('component:foo'); + }); + + QUnit.test('knownForType returns each item for a given type found', function () { + application.FooBarHelper = 'foo'; + application.BazQuxHelper = 'bar'; + + var found = registry.resolver.knownForType('helper'); + + // using `Object.keys` and manually confirming values over using `deepEqual` + // due to an issue in QUnit (through at least 1.20.0) that are unable to properly compare + // objects with an `undefined` constructor (like ember-metal/empty_object) + var foundKeys = Object.keys(found); + + deepEqual(foundKeys, ['helper:foo-bar', 'helper:baz-qux']); + ok(found['helper:foo-bar']); + ok(found['helper:baz-qux']); + }); + + QUnit.test('knownForType is not required to be present on the resolver', function () { + delete registry.resolver.knownForType; + + registry.resolver.knownForType('helper', function () {}); + + ok(true, 'does not error'); + }); +}); +enifed('ember-application/tests/system/dependency_injection/default_resolver_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/dependency_injection/default_resolver_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/dependency_injection/default_resolver_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/dependency_injection/normalization_test', ['exports', 'ember-metal', 'ember-application/system/application'], function (exports, _emberMetal, _emberApplicationSystemApplication) { + 'use strict'; + + var application = undefined, + registry = undefined; + + QUnit.module('Ember.Application Dependency Injection – normalization', { + setup: function () { + application = _emberMetal.run(_emberApplicationSystemApplication.default, 'create'); + registry = application.__registry__; + }, + + teardown: function () { + _emberMetal.run(application, 'destroy'); + } + }); + + QUnit.test('normalization', function () { + ok(registry.normalize, 'registry#normalize is present'); + + equal(registry.normalize('foo:bar'), 'foo:bar'); + + equal(registry.normalize('controller:posts'), 'controller:posts'); + equal(registry.normalize('controller:posts_index'), 'controller:postsIndex'); + equal(registry.normalize('controller:posts.index'), 'controller:postsIndex'); + equal(registry.normalize('controller:posts-index'), 'controller:postsIndex'); + equal(registry.normalize('controller:posts.post.index'), 'controller:postsPostIndex'); + equal(registry.normalize('controller:posts_post.index'), 'controller:postsPostIndex'); + equal(registry.normalize('controller:posts.post_index'), 'controller:postsPostIndex'); + equal(registry.normalize('controller:posts.post-index'), 'controller:postsPostIndex'); + equal(registry.normalize('controller:postsIndex'), 'controller:postsIndex'); + equal(registry.normalize('controller:blogPosts.index'), 'controller:blogPostsIndex'); + equal(registry.normalize('controller:blog/posts.index'), 'controller:blog/postsIndex'); + equal(registry.normalize('controller:blog/posts-index'), 'controller:blog/postsIndex'); + equal(registry.normalize('controller:blog/posts.post.index'), 'controller:blog/postsPostIndex'); + equal(registry.normalize('controller:blog/posts_post.index'), 'controller:blog/postsPostIndex'); + equal(registry.normalize('controller:blog/posts_post-index'), 'controller:blog/postsPostIndex'); + + equal(registry.normalize('template:blog/posts_index'), 'template:blog/posts_index'); + }); + + QUnit.test('normalization is indempotent', function () { + var examples = ['controller:posts', 'controller:posts.post.index', 'controller:blog/posts.post_index', 'template:foo_bar']; + + examples.forEach(function (example) { + equal(registry.normalize(registry.normalize(example)), registry.normalize(example)); + }); + }); +}); +enifed('ember-application/tests/system/dependency_injection/normalization_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/dependency_injection/normalization_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/dependency_injection/normalization_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/dependency_injection/to_string_test', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-application/system/application', 'ember-runtime', 'ember-application/system/resolver'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberApplicationSystemApplication, _emberRuntime, _emberApplicationSystemResolver) { + 'use strict'; + + var originalLookup = undefined, + App = undefined, + originalModelInjections = undefined; + + QUnit.module('Ember.Application Dependency Injection – toString', { + setup: function () { + originalModelInjections = _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = true; + + originalLookup = _emberEnvironment.context.lookup; + + _emberMetal.run(function () { + App = _emberApplicationSystemApplication.default.create(); + _emberEnvironment.context.lookup = { + App: App + }; + }); + + App.Post = _emberRuntime.Object.extend(); + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + _emberMetal.run(App, 'destroy'); + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = originalModelInjections; + } + }); + + QUnit.test('factories', function () { + var PostFactory = undefined; + if (true) { + PostFactory = App.__container__.factoryFor('model:post').class; + } else { + PostFactory = App.__container__.lookupFactory('model:post'); + } + equal(PostFactory.toString(), 'App.Post', 'expecting the model to be post'); + }); + + QUnit.test('instances', function () { + var post = App.__container__.lookup('model:post'); + var guid = _emberUtils.guidFor(post); + + equal(post.toString(), '', 'expecting the model to be post'); + }); + + QUnit.test('with a custom resolver', function () { + _emberMetal.run(App, 'destroy'); + + _emberMetal.run(function () { + App = _emberApplicationSystemApplication.default.create({ + Resolver: _emberApplicationSystemResolver.default.extend({ + makeToString: function (factory, fullName) { + return fullName; + } + }) + }); + }); + + App.register('model:peter', _emberRuntime.Object.extend()); + + var peter = App.__container__.lookup('model:peter'); + var guid = _emberUtils.guidFor(peter); + + equal(peter.toString(), '', 'expecting the supermodel to be peter'); + }); +}); +// lookup, etc +enifed('ember-application/tests/system/dependency_injection/to_string_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/dependency_injection/to_string_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/dependency_injection/to_string_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/dependency_injection_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-application/system/application'], function (exports, _emberEnvironment, _emberMetal, _emberRuntime, _emberApplicationSystemApplication) { + 'use strict'; + + var EmberApplication = _emberApplicationSystemApplication.default; + + var originalLookup = _emberEnvironment.context.lookup; + var registry = undefined, + locator = undefined, + application = undefined, + originalModelInjections = undefined; + + QUnit.module('Ember.Application Dependency Injection', { + setup: function () { + originalModelInjections = _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = true; + + application = _emberMetal.run(EmberApplication, 'create'); + + application.Person = _emberRuntime.Object.extend({}); + application.Orange = _emberRuntime.Object.extend({}); + application.Email = _emberRuntime.Object.extend({}); + application.User = _emberRuntime.Object.extend({}); + application.PostIndexController = _emberRuntime.Object.extend({}); + + application.register('model:person', application.Person, { singleton: false }); + application.register('model:user', application.User, { singleton: false }); + application.register('fruit:favorite', application.Orange); + application.register('communication:main', application.Email, { singleton: false }); + application.register('controller:postIndex', application.PostIndexController, { singleton: true }); + + registry = application.__registry__; + locator = application.__container__; + + _emberEnvironment.context.lookup = {}; + }, + teardown: function () { + _emberMetal.run(application, 'destroy'); + application = locator = null; + _emberEnvironment.context.lookup = originalLookup; + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = originalModelInjections; + } + }); + + QUnit.test('container lookup is normalized', function () { + var dotNotationController = locator.lookup('controller:post.index'); + var camelCaseController = locator.lookup('controller:postIndex'); + + ok(dotNotationController instanceof application.PostIndexController); + ok(camelCaseController instanceof application.PostIndexController); + + equal(dotNotationController, camelCaseController); + }); + + QUnit.test('registered entities can be looked up later', function () { + equal(registry.resolve('model:person'), application.Person); + equal(registry.resolve('model:user'), application.User); + equal(registry.resolve('fruit:favorite'), application.Orange); + equal(registry.resolve('communication:main'), application.Email); + equal(registry.resolve('controller:postIndex'), application.PostIndexController); + + equal(locator.lookup('fruit:favorite'), locator.lookup('fruit:favorite'), 'singleton lookup worked'); + ok(locator.lookup('model:user') !== locator.lookup('model:user'), 'non-singleton lookup worked'); + }); + + QUnit.test('injections', function () { + application.inject('model', 'fruit', 'fruit:favorite'); + application.inject('model:user', 'communication', 'communication:main'); + + var user = locator.lookup('model:user'); + var person = locator.lookup('model:person'); + var fruit = locator.lookup('fruit:favorite'); + + equal(user.get('fruit'), fruit); + equal(person.get('fruit'), fruit); + + ok(application.Email.detectInstance(user.get('communication'))); + }); +}); +enifed('ember-application/tests/system/dependency_injection_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/dependency_injection_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/dependency_injection_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/engine_initializers_test', ['exports', 'ember-metal', 'ember-application/system/engine'], function (exports, _emberMetal, _emberApplicationSystemEngine) { + 'use strict'; + + var MyEngine = undefined, + myEngine = undefined, + myEngineInstance = undefined; + + QUnit.module('Ember.Engine initializers', { + setup: function () {}, + + teardown: function () { + _emberMetal.run(function () { + if (myEngineInstance) { + myEngineInstance.destroy(); + } + + if (myEngine) { + myEngine.destroy(); + } + }); + } + }); + + QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function () { + MyEngine = _emberApplicationSystemEngine.default.extend(); + + expectAssertion(function () { + _emberMetal.run(function () { + MyEngine.initializer({ name: 'initializer' }); + }); + }); + + expectAssertion(function () { + _emberMetal.run(function () { + MyEngine.initializer({ initialize: function () {} }); + }); + }); + }); + + QUnit.test('initializers are passed an Engine', function () { + MyEngine = _emberApplicationSystemEngine.default.extend(); + + MyEngine.initializer({ + name: 'initializer', + initialize: function (engine) { + ok(engine instanceof _emberApplicationSystemEngine.default, 'initialize is passed an Engine'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = myEngine.buildInstance(); + }); + + QUnit.test('initializers can be registered in a specified order', function () { + var order = []; + + MyEngine = _emberApplicationSystemEngine.default.extend(); + MyEngine.initializer({ + name: 'fourth', + after: 'third', + initialize: function (engine) { + order.push('fourth'); + } + }); + + MyEngine.initializer({ + name: 'second', + after: 'first', + before: 'third', + initialize: function (engine) { + order.push('second'); + } + }); + + MyEngine.initializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (engine) { + order.push('fifth'); + } + }); + + MyEngine.initializer({ + name: 'first', + before: 'second', + initialize: function (engine) { + order.push('first'); + } + }); + + MyEngine.initializer({ + name: 'third', + initialize: function (engine) { + order.push('third'); + } + }); + + MyEngine.initializer({ + name: 'sixth', + initialize: function (engine) { + order.push('sixth'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = myEngine.buildInstance(); + + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + + QUnit.test('initializers can be registered in a specified order as an array', function () { + var order = []; + + MyEngine = _emberApplicationSystemEngine.default.extend(); + + MyEngine.initializer({ + name: 'third', + initialize: function (engine) { + order.push('third'); + } + }); + + MyEngine.initializer({ + name: 'second', + after: 'first', + before: ['third', 'fourth'], + initialize: function (engine) { + order.push('second'); + } + }); + + MyEngine.initializer({ + name: 'fourth', + after: ['second', 'third'], + initialize: function (engine) { + order.push('fourth'); + } + }); + + MyEngine.initializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (engine) { + order.push('fifth'); + } + }); + + MyEngine.initializer({ + name: 'first', + before: ['second'], + initialize: function (engine) { + order.push('first'); + } + }); + + MyEngine.initializer({ + name: 'sixth', + initialize: function (engine) { + order.push('sixth'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = myEngine.buildInstance(); + + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + + QUnit.test('initializers can have multiple dependencies', function () { + var order = []; + + MyEngine = _emberApplicationSystemEngine.default.extend(); + + var a = { + name: 'a', + before: 'b', + initialize: function (engine) { + order.push('a'); + } + }; + var b = { + name: 'b', + initialize: function (engine) { + order.push('b'); + } + }; + var c = { + name: 'c', + after: 'b', + initialize: function (engine) { + order.push('c'); + } + }; + var afterB = { + name: 'after b', + after: 'b', + initialize: function (engine) { + order.push('after b'); + } + }; + var afterC = { + name: 'after c', + after: 'c', + initialize: function (engine) { + order.push('after c'); + } + }; + + MyEngine.initializer(b); + MyEngine.initializer(a); + MyEngine.initializer(afterC); + MyEngine.initializer(afterB); + MyEngine.initializer(c); + + myEngine = MyEngine.create(); + myEngineInstance = myEngine.buildInstance(); + + ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); + ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); + ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); + }); + + QUnit.test('initializers set on Engine subclasses are not shared between engines', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstEngine = _emberApplicationSystemEngine.default.extend(); + + FirstEngine.initializer({ + name: 'first', + initialize: function (engine) { + firstInitializerRunCount++; + } + }); + + var SecondEngine = _emberApplicationSystemEngine.default.extend(); + + SecondEngine.initializer({ + name: 'second', + initialize: function (engine) { + secondInitializerRunCount++; + } + }); + + var firstEngine = FirstEngine.create(); + var firstEngineInstance = firstEngine.buildInstance(); + + equal(firstInitializerRunCount, 1, 'first initializer only was run'); + equal(secondInitializerRunCount, 0, 'first initializer only was run'); + + var secondEngine = SecondEngine.create(); + var secondEngineInstance = secondEngine.buildInstance(); + + equal(firstInitializerRunCount, 1, 'second initializer only was run'); + equal(secondInitializerRunCount, 1, 'second initializer only was run'); + + _emberMetal.run(function () { + firstEngineInstance.destroy(); + secondEngineInstance.destroy(); + + firstEngine.destroy(); + secondEngine.destroy(); + }); + }); + + QUnit.test('initializers are concatenated', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstEngine = _emberApplicationSystemEngine.default.extend(); + + FirstEngine.initializer({ + name: 'first', + initialize: function (engine) { + firstInitializerRunCount++; + } + }); + + var SecondEngine = FirstEngine.extend(); + + SecondEngine.initializer({ + name: 'second', + initialize: function (engine) { + secondInitializerRunCount++; + } + }); + + var firstEngine = FirstEngine.create(); + var firstEngineInstance = firstEngine.buildInstance(); + + equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created'); + equal(secondInitializerRunCount, 0, 'second initializer was not run when first base class created'); + firstInitializerRunCount = 0; + + var secondEngine = SecondEngine.create(); + var secondEngineInstance = secondEngine.buildInstance(); + + equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); + equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created'); + + _emberMetal.run(function () { + firstEngineInstance.destroy(); + secondEngineInstance.destroy(); + + firstEngine.destroy(); + secondEngine.destroy(); + }); + }); + + QUnit.test('initializers are per-engine', function () { + expect(2); + + var FirstEngine = _emberApplicationSystemEngine.default.extend(); + + FirstEngine.initializer({ + name: 'abc', + initialize: function (engine) {} + }); + + expectAssertion(function () { + FirstEngine.initializer({ + name: 'abc', + initialize: function (engine) {} + }); + }); + + var SecondEngine = _emberApplicationSystemEngine.default.extend(); + SecondEngine.instanceInitializer({ + name: 'abc', + initialize: function (engine) {} + }); + + ok(true, 'Two engines can have initializers named the same.'); + }); + + QUnit.test('initializers are executed in their own context', function () { + expect(1); + + MyEngine = _emberApplicationSystemEngine.default.extend(); + + MyEngine.initializer({ + name: 'coolInitializer', + myProperty: 'cool', + initialize: function (engine) { + equal(this.myProperty, 'cool', 'should have access to its own context'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = myEngine.buildInstance(); + }); +}); +enifed('ember-application/tests/system/engine_initializers_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/engine_initializers_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/engine_initializers_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/engine_instance_initializers_test', ['exports', 'ember-metal', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (exports, _emberMetal, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent) { + 'use strict'; + + var MyEngine = undefined, + myEngine = undefined, + myEngineInstance = undefined; + + function buildEngineInstance(EngineClass) { + var engineInstance = EngineClass.buildInstance(); + _emberApplicationSystemEngineParent.setEngineParent(engineInstance, { + lookup: function () { + return {}; + }, + resolveRegistration: function () { + return {}; + } + }); + return engineInstance; + } + + QUnit.module('Ember.Engine instance initializers', { + setup: function () {}, + + teardown: function () { + _emberMetal.run(function () { + if (myEngineInstance) { + myEngineInstance.destroy(); + } + + if (myEngine) { + myEngine.destroy(); + } + }); + } + }); + + QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function () { + MyEngine = _emberApplicationSystemEngine.default.extend(); + + expectAssertion(function () { + _emberMetal.run(function () { + MyEngine.instanceInitializer({ name: 'initializer' }); + }); + }); + + expectAssertion(function () { + _emberMetal.run(function () { + MyEngine.instanceInitializer({ initialize: function () {} }); + }); + }); + }); + + QUnit.test('initializers are passed an engine instance', function () { + MyEngine = _emberApplicationSystemEngine.default.extend(); + + MyEngine.instanceInitializer({ + name: 'initializer', + initialize: function (instance) { + ok(instance instanceof _emberApplicationSystemEngineInstance.default, 'initialize is passed an engine instance'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = buildEngineInstance(myEngine); + return myEngineInstance.boot(); + }); + + QUnit.test('initializers can be registered in a specified order', function () { + var order = []; + + MyEngine = _emberApplicationSystemEngine.default.extend(); + + MyEngine.instanceInitializer({ + name: 'fourth', + after: 'third', + initialize: function (engine) { + order.push('fourth'); + } + }); + + MyEngine.instanceInitializer({ + name: 'second', + after: 'first', + before: 'third', + initialize: function (engine) { + order.push('second'); + } + }); + + MyEngine.instanceInitializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (engine) { + order.push('fifth'); + } + }); + + MyEngine.instanceInitializer({ + name: 'first', + before: 'second', + initialize: function (engine) { + order.push('first'); + } + }); + + MyEngine.instanceInitializer({ + name: 'third', + initialize: function (engine) { + order.push('third'); + } + }); + + MyEngine.instanceInitializer({ + name: 'sixth', + initialize: function (engine) { + order.push('sixth'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = buildEngineInstance(myEngine); + + return myEngineInstance.boot().then(function () { + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + }); + + QUnit.test('initializers can be registered in a specified order as an array', function () { + var order = []; + MyEngine = _emberApplicationSystemEngine.default.extend(); + + MyEngine.instanceInitializer({ + name: 'third', + initialize: function (engine) { + order.push('third'); + } + }); + + MyEngine.instanceInitializer({ + name: 'second', + after: 'first', + before: ['third', 'fourth'], + initialize: function (engine) { + order.push('second'); + } + }); + + MyEngine.instanceInitializer({ + name: 'fourth', + after: ['second', 'third'], + initialize: function (engine) { + order.push('fourth'); + } + }); + + MyEngine.instanceInitializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (engine) { + order.push('fifth'); + } + }); + + MyEngine.instanceInitializer({ + name: 'first', + before: ['second'], + initialize: function (engine) { + order.push('first'); + } + }); + + MyEngine.instanceInitializer({ + name: 'sixth', + initialize: function (engine) { + order.push('sixth'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = buildEngineInstance(myEngine); + + return myEngineInstance.boot().then(function () { + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + }); + + QUnit.test('initializers can have multiple dependencies', function () { + var order = []; + + MyEngine = _emberApplicationSystemEngine.default.extend(); + + var a = { + name: 'a', + before: 'b', + initialize: function (engine) { + order.push('a'); + } + }; + var b = { + name: 'b', + initialize: function (engine) { + order.push('b'); + } + }; + var c = { + name: 'c', + after: 'b', + initialize: function (engine) { + order.push('c'); + } + }; + var afterB = { + name: 'after b', + after: 'b', + initialize: function (engine) { + order.push('after b'); + } + }; + var afterC = { + name: 'after c', + after: 'c', + initialize: function (engine) { + order.push('after c'); + } + }; + + MyEngine.instanceInitializer(b); + MyEngine.instanceInitializer(a); + MyEngine.instanceInitializer(afterC); + MyEngine.instanceInitializer(afterB); + MyEngine.instanceInitializer(c); + + myEngine = MyEngine.create(); + myEngineInstance = buildEngineInstance(myEngine); + + return myEngineInstance.boot().then(function () { + ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); + ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); + ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); + }); + }); + + QUnit.test('initializers set on Engine subclasses should not be shared between engines', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstEngine = _emberApplicationSystemEngine.default.extend(); + var firstEngine = undefined, + firstEngineInstance = undefined; + + FirstEngine.instanceInitializer({ + name: 'first', + initialize: function (engine) { + firstInitializerRunCount++; + } + }); + + var SecondEngine = _emberApplicationSystemEngine.default.extend(); + var secondEngine = undefined, + secondEngineInstance = undefined; + + SecondEngine.instanceInitializer({ + name: 'second', + initialize: function (engine) { + secondInitializerRunCount++; + } + }); + + firstEngine = FirstEngine.create(); + firstEngineInstance = buildEngineInstance(firstEngine); + + return firstEngineInstance.boot().then(function () { + equal(firstInitializerRunCount, 1, 'first initializer only was run'); + equal(secondInitializerRunCount, 0, 'first initializer only was run'); + + secondEngine = SecondEngine.create(); + secondEngineInstance = buildEngineInstance(secondEngine); + return secondEngineInstance.boot(); + }).then(function () { + equal(firstInitializerRunCount, 1, 'second initializer only was run'); + equal(secondInitializerRunCount, 1, 'second initializer only was run'); + + _emberMetal.run(function () { + firstEngineInstance.destroy(); + secondEngineInstance.destroy(); + + firstEngine.destroy(); + secondEngine.destroy(); + }); + }); + }); + + QUnit.test('initializers are concatenated', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstEngine = _emberApplicationSystemEngine.default.extend(); + + FirstEngine.instanceInitializer({ + name: 'first', + initialize: function (engine) { + firstInitializerRunCount++; + } + }); + + var SecondEngine = FirstEngine.extend(); + + SecondEngine.instanceInitializer({ + name: 'second', + initialize: function (engine) { + secondInitializerRunCount++; + } + }); + + var firstEngine = FirstEngine.create(); + var firstEngineInstance = buildEngineInstance(firstEngine); + + var secondEngine = undefined, + secondEngineInstance = undefined; + + return firstEngineInstance.boot().then(function () { + equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created'); + equal(secondInitializerRunCount, 0, 'second initializer was not run when first base class created'); + firstInitializerRunCount = 0; + + secondEngine = SecondEngine.create(); + secondEngineInstance = buildEngineInstance(secondEngine); + return secondEngineInstance.boot(); + }).then(function () { + equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); + equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created'); + + _emberMetal.run(function () { + firstEngineInstance.destroy(); + secondEngineInstance.destroy(); + + firstEngine.destroy(); + secondEngine.destroy(); + }); + }); + }); + + QUnit.test('initializers are per-engine', function () { + expect(2); + + var FirstEngine = _emberApplicationSystemEngine.default.extend(); + + FirstEngine.instanceInitializer({ + name: 'abc', + initialize: function (engine) {} + }); + + expectAssertion(function () { + FirstEngine.instanceInitializer({ + name: 'abc', + initialize: function (engine) {} + }); + }); + + var SecondEngine = _emberApplicationSystemEngine.default.extend(); + SecondEngine.instanceInitializer({ + name: 'abc', + initialize: function (engine) {} + }); + + ok(true, 'Two engines can have initializers named the same.'); + }); + + QUnit.test('initializers are executed in their own context', function () { + expect(1); + + var MyEngine = _emberApplicationSystemEngine.default.extend(); + + MyEngine.instanceInitializer({ + name: 'coolInitializer', + myProperty: 'cool', + initialize: function (engine) { + equal(this.myProperty, 'cool', 'should have access to its own context'); + } + }); + + myEngine = MyEngine.create(); + myEngineInstance = buildEngineInstance(myEngine); + + return myEngineInstance.boot(); + }); +}); +enifed('ember-application/tests/system/engine_instance_initializers_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/engine_instance_initializers_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/engine_instance_initializers_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/engine_instance_test', ['exports', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent', 'ember-metal', 'internal-test-helpers'], function (exports, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent, _emberMetal, _internalTestHelpers) { + 'use strict'; + + var engine = undefined, + engineInstance = undefined; + + QUnit.module('Ember.EngineInstance', { + setup: function () { + _emberMetal.run(function () { + engine = _emberApplicationSystemEngine.default.create({ router: null }); + }); + }, + + teardown: function () { + if (engineInstance) { + _emberMetal.run(engineInstance, 'destroy'); + } + + if (engine) { + _emberMetal.run(engine, 'destroy'); + } + } + }); + + QUnit.test('an engine instance can be created based upon a base engine', function () { + _emberMetal.run(function () { + engineInstance = _emberApplicationSystemEngineInstance.default.create({ base: engine }); + }); + + ok(engineInstance, 'instance should be created'); + equal(engineInstance.base, engine, 'base should be set to engine'); + }); + + QUnit.test('unregistering a factory clears all cached instances of that factory', function (assert) { + assert.expect(3); + + engineInstance = _emberMetal.run(function () { + return _emberApplicationSystemEngineInstance.default.create({ base: engine }); + }); + + var PostComponent = _internalTestHelpers.factory(); + + engineInstance.register('component:post', PostComponent); + + var postComponent1 = engineInstance.lookup('component:post'); + assert.ok(postComponent1, 'lookup creates instance'); + + engineInstance.unregister('component:post'); + engineInstance.register('component:post', PostComponent); + + var postComponent2 = engineInstance.lookup('component:post'); + assert.ok(postComponent2, 'lookup creates instance'); + + assert.notStrictEqual(postComponent1, postComponent2, 'lookup creates a brand new instance because previous one was reset'); + }); + + QUnit.test('can be booted when its parent has been set', function (assert) { + assert.expect(3); + + engineInstance = _emberMetal.run(function () { + return _emberApplicationSystemEngineInstance.default.create({ base: engine }); + }); + + expectAssertion(function () { + engineInstance._bootSync(); + }, 'An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.'); + + _emberApplicationSystemEngineParent.setEngineParent(engineInstance, {}); + + // Stub `cloneParentDependencies`, the internals of which are tested along + // with application instances. + engineInstance.cloneParentDependencies = function () { + assert.ok(true, 'parent dependencies are cloned'); + }; + + return engineInstance.boot().then(function () { + assert.ok(true, 'boot successful'); + }); + }); + + QUnit.test('can build a child instance of a registered engine', function (assert) { + var ChatEngine = _emberApplicationSystemEngine.default.extend(); + var chatEngineInstance = undefined; + + engine.register('engine:chat', ChatEngine); + + _emberMetal.run(function () { + engineInstance = _emberApplicationSystemEngineInstance.default.create({ base: engine }); + + // Try to build an unregistered engine. + throws(function () { + engineInstance.buildChildEngineInstance('fake'); + }, 'You attempted to mount the engine \'fake\', but it is not registered with its parent.'); + + // Build the `chat` engine, registered above. + chatEngineInstance = engineInstance.buildChildEngineInstance('chat'); + }); + + assert.ok(chatEngineInstance, 'child engine instance successfully created'); + + assert.strictEqual(_emberApplicationSystemEngineParent.getEngineParent(chatEngineInstance), engineInstance, 'child engine instance is assigned the correct parent'); + }); +}); +enifed('ember-application/tests/system/engine_instance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/engine_instance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/engine_instance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/engine_parent_test', ['exports', 'ember-application/system/engine-parent'], function (exports, _emberApplicationSystemEngineParent) { + 'use strict'; + + QUnit.module('EngineParent', {}); + + QUnit.test('An engine\'s parent can be set with `setEngineParent` and retrieved with `getEngineParent`', function () { + var engine = {}; + var parent = {}; + + strictEqual(_emberApplicationSystemEngineParent.getEngineParent(engine), undefined, 'parent has not been set'); + + _emberApplicationSystemEngineParent.setEngineParent(engine, parent); + + strictEqual(_emberApplicationSystemEngineParent.getEngineParent(engine), parent, 'parent has been set'); + + strictEqual(engine[_emberApplicationSystemEngineParent.ENGINE_PARENT], parent, 'parent has been set to the ENGINE_PARENT symbol'); + }); +}); +enifed('ember-application/tests/system/engine_parent_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/engine_parent_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/engine_parent_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/engine_test', ['exports', 'ember-environment', 'ember-metal', 'ember-application/system/engine', 'ember-runtime', 'container', 'ember-application/tests/test-helpers/registry-check'], function (exports, _emberEnvironment, _emberMetal, _emberApplicationSystemEngine, _emberRuntime, _container, _emberApplicationTestsTestHelpersRegistryCheck) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); + + var engine = undefined; + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('Ember.Engine', { + setup: function () { + lookup = _emberEnvironment.context.lookup = {}; + engine = _emberMetal.run(function () { + return _emberApplicationSystemEngine.default.create(); + }); + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + if (engine) { + _emberMetal.run(engine, 'destroy'); + } + } + }); + + QUnit.test('acts like a namespace', function () { + engine = _emberMetal.run(function () { + return lookup.TestEngine = _emberApplicationSystemEngine.default.create(); + }); + + engine.Foo = _emberRuntime.Object.extend(); + equal(engine.Foo.toString(), 'TestEngine.Foo', 'Classes pick up their parent namespace'); + }); + + QUnit.test('builds a registry', function () { + strictEqual(engine.resolveRegistration('application:main'), engine, 'application:main is registered'); + deepEqual(engine.registeredOptionsForType('component'), { singleton: false }, 'optionsForType \'component\''); + deepEqual(engine.registeredOptionsForType('view'), { singleton: false }, 'optionsForType \'view\''); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'controller:basic'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'view', '_viewRegistry', '-view-registry:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'route', '_topLevelViewTemplate', 'template:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'view:-outlet', 'namespace', 'application:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'controller', 'target', 'router:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'controller', 'namespace', 'application:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'router', '_bucketCache', _container.privatize(_templateObject)); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'route', '_bucketCache', _container.privatize(_templateObject)); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'route', 'router', 'router:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'component:-text-field'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'component:-text-area'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'component:-checkbox'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'component:link-to'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'service:-routing'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'service:-routing', 'router', 'router:main'); + + // DEBUGGING + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'resolver-for-debugging:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'container-debug-adapter:main'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'component-lookup:main'); + + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'service:-dom-changes', 'document', 'service:-document'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'service:-dom-tree-construction', 'document', 'service:-document'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'view:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, _container.privatize(_templateObject2)); + _emberApplicationTestsTestHelpersRegistryCheck.verifyRegistration(engine, 'template:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'view:-outlet', 'template', 'template:-outlet'); + _emberApplicationTestsTestHelpersRegistryCheck.verifyInjection(engine, 'template', 'env', 'service:-glimmer-environment'); + deepEqual(engine.registeredOptionsForType('helper'), { instantiate: false }, 'optionsForType \'helper\''); + }); +}); +enifed('ember-application/tests/system/engine_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/engine_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/engine_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/initializers_test', ['exports', 'ember-metal', 'ember-application/system/application', 'ember-views'], function (exports, _emberMetal, _emberApplicationSystemApplication, _emberViews) { + 'use strict'; + + var app = undefined; + + QUnit.module('Ember.Application initializers', { + teardown: function () { + if (app) { + _emberMetal.run(function () { + return app.destroy(); + }); + } + } + }); + + QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function () { + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + expectAssertion(function () { + _emberMetal.run(function () { + MyApplication.initializer({ name: 'initializer' }); + }); + }); + + expectAssertion(function () { + _emberMetal.run(function () { + MyApplication.initializer({ initialize: function () {} }); + }); + }); + }); + + QUnit.test('initializers that throw errors cause the boot promise to reject with the error', function () { + QUnit.expect(2); + QUnit.stop(); + + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.initializer({ + name: 'initializer', + initialize: function () { + throw new Error('boot failure'); + } + }); + + app = MyApplication.create({ + autoboot: false + }); + + try { + app.boot().then(function (app) { + QUnit.start(); + ok(false, 'The boot promise should not resolve when there is a boot error'); + }, function (err) { + QUnit.start(); + ok(err instanceof Error, 'The boot promise should reject with an error'); + equal(err.message, 'boot failure'); + }); + } catch (e) { + QUnit.start(); + ok(false, 'The boot method should not throw'); + throw e; + } + }); + + QUnit.test('initializers are passed an App', function () { + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.initializer({ + name: 'initializer', + initialize: function (App) { + ok(App instanceof _emberApplicationSystemApplication.default, 'initialize is passed an Application'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + }); + + QUnit.test('initializers can be registered in a specified order', function () { + var order = []; + var MyApplication = _emberApplicationSystemApplication.default.extend(); + MyApplication.initializer({ + name: 'fourth', + after: 'third', + initialize: function (registry) { + order.push('fourth'); + } + }); + + MyApplication.initializer({ + name: 'second', + after: 'first', + before: 'third', + initialize: function (registry) { + order.push('second'); + } + }); + + MyApplication.initializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (registry) { + order.push('fifth'); + } + }); + + MyApplication.initializer({ + name: 'first', + before: 'second', + initialize: function (registry) { + order.push('first'); + } + }); + + MyApplication.initializer({ + name: 'third', + initialize: function (registry) { + order.push('third'); + } + }); + + MyApplication.initializer({ + name: 'sixth', + initialize: function (registry) { + order.push('sixth'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + + QUnit.test('initializers can be registered in a specified order as an array', function () { + var order = []; + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.initializer({ + name: 'third', + initialize: function (registry) { + order.push('third'); + } + }); + + MyApplication.initializer({ + name: 'second', + after: 'first', + before: ['third', 'fourth'], + initialize: function (registry) { + order.push('second'); + } + }); + + MyApplication.initializer({ + name: 'fourth', + after: ['second', 'third'], + initialize: function (registry) { + order.push('fourth'); + } + }); + + MyApplication.initializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (registry) { + order.push('fifth'); + } + }); + + MyApplication.initializer({ + name: 'first', + before: ['second'], + initialize: function (registry) { + order.push('first'); + } + }); + + MyApplication.initializer({ + name: 'sixth', + initialize: function (registry) { + order.push('sixth'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + + QUnit.test('initializers can have multiple dependencies', function () { + var order = []; + var a = { + name: 'a', + before: 'b', + initialize: function (registry) { + order.push('a'); + } + }; + var b = { + name: 'b', + initialize: function (registry) { + order.push('b'); + } + }; + var c = { + name: 'c', + after: 'b', + initialize: function (registry) { + order.push('c'); + } + }; + var afterB = { + name: 'after b', + after: 'b', + initialize: function (registry) { + order.push('after b'); + } + }; + var afterC = { + name: 'after c', + after: 'c', + initialize: function (registry) { + order.push('after c'); + } + }; + + _emberApplicationSystemApplication.default.initializer(b); + _emberApplicationSystemApplication.default.initializer(a); + _emberApplicationSystemApplication.default.initializer(afterC); + _emberApplicationSystemApplication.default.initializer(afterB); + _emberApplicationSystemApplication.default.initializer(c); + + _emberMetal.run(function () { + app = _emberApplicationSystemApplication.default.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + + ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); + ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); + ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); + }); + + QUnit.test('initializers set on Application subclasses are not shared between apps', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstApp = _emberApplicationSystemApplication.default.extend(); + + FirstApp.initializer({ + name: 'first', + initialize: function (registry) { + firstInitializerRunCount++; + } + }); + + var SecondApp = _emberApplicationSystemApplication.default.extend(); + + SecondApp.initializer({ + name: 'second', + initialize: function (registry) { + secondInitializerRunCount++; + } + }); + + _emberViews.jQuery('#qunit-fixture').html('
    '); + + var firstApp = _emberMetal.run(function () { + return FirstApp.create({ + router: false, + rootElement: '#qunit-fixture #first' + }); + }); + + equal(firstInitializerRunCount, 1, 'first initializer only was run'); + equal(secondInitializerRunCount, 0, 'first initializer only was run'); + + var secondApp = _emberMetal.run(function () { + return SecondApp.create({ + router: false, + rootElement: '#qunit-fixture #second' + }); + }); + + equal(firstInitializerRunCount, 1, 'second initializer only was run'); + equal(secondInitializerRunCount, 1, 'second initializer only was run'); + + _emberMetal.run(function () { + firstApp.destroy(); + secondApp.destroy(); + }); + }); + + QUnit.test('initializers are concatenated', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstApp = _emberApplicationSystemApplication.default.extend(); + + FirstApp.initializer({ + name: 'first', + initialize: function (registry) { + firstInitializerRunCount++; + } + }); + + var SecondApp = FirstApp.extend(); + SecondApp.initializer({ + name: 'second', + initialize: function (registry) { + secondInitializerRunCount++; + } + }); + + _emberViews.jQuery('#qunit-fixture').html('
    '); + var firstApp = _emberMetal.run(function () { + return FirstApp.create({ + router: false, + rootElement: '#qunit-fixture #first' + }); + }); + equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created'); + equal(secondInitializerRunCount, 0, 'first initializer only was run when base class created'); + firstInitializerRunCount = 0; + + var secondApp = _emberMetal.run(function () { + return SecondApp.create({ + router: false, + rootElement: '#qunit-fixture #second' + }); + }); + + equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); + equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created'); + _emberMetal.run(function () { + firstApp.destroy(); + secondApp.destroy(); + }); + }); + + QUnit.test('initializers are per-app', function () { + expect(2); + + var FirstApp = _emberApplicationSystemApplication.default.extend(); + + FirstApp.initializer({ + name: 'abc', + initialize: function (app) {} + }); + + expectAssertion(function () { + FirstApp.initializer({ + name: 'abc', + initialize: function (app) {} + }); + }); + + var SecondApp = _emberApplicationSystemApplication.default.extend(); + SecondApp.instanceInitializer({ + name: 'abc', + initialize: function (app) {} + }); + + ok(true, 'Two apps can have initializers named the same.'); + }); + + QUnit.test('initializers are executed in their own context', function () { + expect(1); + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.initializer({ + name: 'coolInitializer', + myProperty: 'cool', + initialize: function (application) { + equal(this.myProperty, 'cool', 'should have access to its own context'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + }); + + QUnit.test('initializers throw a deprecation warning when receiving a second argument', function () { + expect(1); + + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.initializer({ + name: 'deprecated', + initialize: function (registry, application) {} + }); + + expectDeprecation(function () { + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + }, /The `initialize` method for Application initializer 'deprecated' should take only one argument - `App`, an instance of an `Application`./); + }); +}); +enifed('ember-application/tests/system/initializers_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/initializers_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/initializers_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/instance_initializers_test', ['exports', 'ember-metal', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-views'], function (exports, _emberMetal, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberViews) { + 'use strict'; + + var app = undefined; + + QUnit.module('Ember.Application instance initializers', { + teardown: function () { + if (app) { + _emberMetal.run(function () { + return app.destroy(); + }); + } + } + }); + + QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function () { + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + expectAssertion(function () { + _emberMetal.run(function () { + MyApplication.instanceInitializer({ name: 'initializer' }); + }); + }); + + expectAssertion(function () { + _emberMetal.run(function () { + MyApplication.instanceInitializer({ initialize: function () {} }); + }); + }); + }); + + QUnit.test('initializers are passed an app instance', function () { + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.instanceInitializer({ + name: 'initializer', + initialize: function (instance) { + ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'initialize is passed an application instance'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + }); + + QUnit.test('initializers can be registered in a specified order', function () { + var order = []; + var MyApplication = _emberApplicationSystemApplication.default.extend(); + MyApplication.instanceInitializer({ + name: 'fourth', + after: 'third', + initialize: function (registry) { + order.push('fourth'); + } + }); + + MyApplication.instanceInitializer({ + name: 'second', + after: 'first', + before: 'third', + initialize: function (registry) { + order.push('second'); + } + }); + + MyApplication.instanceInitializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (registry) { + order.push('fifth'); + } + }); + + MyApplication.instanceInitializer({ + name: 'first', + before: 'second', + initialize: function (registry) { + order.push('first'); + } + }); + + MyApplication.instanceInitializer({ + name: 'third', + initialize: function (registry) { + order.push('third'); + } + }); + + MyApplication.instanceInitializer({ + name: 'sixth', + initialize: function (registry) { + order.push('sixth'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + + QUnit.test('initializers can be registered in a specified order as an array', function () { + var order = []; + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.instanceInitializer({ + name: 'third', + initialize: function (registry) { + order.push('third'); + } + }); + + MyApplication.instanceInitializer({ + name: 'second', + after: 'first', + before: ['third', 'fourth'], + initialize: function (registry) { + order.push('second'); + } + }); + + MyApplication.instanceInitializer({ + name: 'fourth', + after: ['second', 'third'], + initialize: function (registry) { + order.push('fourth'); + } + }); + + MyApplication.instanceInitializer({ + name: 'fifth', + after: 'fourth', + before: 'sixth', + initialize: function (registry) { + order.push('fifth'); + } + }); + + MyApplication.instanceInitializer({ + name: 'first', + before: ['second'], + initialize: function (registry) { + order.push('first'); + } + }); + + MyApplication.instanceInitializer({ + name: 'sixth', + initialize: function (registry) { + order.push('sixth'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + + deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); + }); + + QUnit.test('initializers can have multiple dependencies', function () { + var order = []; + var a = { + name: 'a', + before: 'b', + initialize: function (registry) { + order.push('a'); + } + }; + var b = { + name: 'b', + initialize: function (registry) { + order.push('b'); + } + }; + var c = { + name: 'c', + after: 'b', + initialize: function (registry) { + order.push('c'); + } + }; + var afterB = { + name: 'after b', + after: 'b', + initialize: function (registry) { + order.push('after b'); + } + }; + var afterC = { + name: 'after c', + after: 'c', + initialize: function (registry) { + order.push('after c'); + } + }; + + _emberApplicationSystemApplication.default.instanceInitializer(b); + _emberApplicationSystemApplication.default.instanceInitializer(a); + _emberApplicationSystemApplication.default.instanceInitializer(afterC); + _emberApplicationSystemApplication.default.instanceInitializer(afterB); + _emberApplicationSystemApplication.default.instanceInitializer(c); + + _emberMetal.run(function () { + app = _emberApplicationSystemApplication.default.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + + ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); + ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); + ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); + }); + + QUnit.test('initializers set on Application subclasses should not be shared between apps', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstApp = _emberApplicationSystemApplication.default.extend(); + var firstApp = undefined, + secondApp = undefined; + + FirstApp.instanceInitializer({ + name: 'first', + initialize: function (registry) { + firstInitializerRunCount++; + } + }); + var SecondApp = _emberApplicationSystemApplication.default.extend(); + SecondApp.instanceInitializer({ + name: 'second', + initialize: function (registry) { + secondInitializerRunCount++; + } + }); + _emberViews.jQuery('#qunit-fixture').html('
    '); + _emberMetal.run(function () { + firstApp = FirstApp.create({ + router: false, + rootElement: '#qunit-fixture #first' + }); + }); + equal(firstInitializerRunCount, 1, 'first initializer only was run'); + equal(secondInitializerRunCount, 0, 'first initializer only was run'); + _emberMetal.run(function () { + secondApp = SecondApp.create({ + router: false, + rootElement: '#qunit-fixture #second' + }); + }); + equal(firstInitializerRunCount, 1, 'second initializer only was run'); + equal(secondInitializerRunCount, 1, 'second initializer only was run'); + _emberMetal.run(function () { + firstApp.destroy(); + secondApp.destroy(); + }); + }); + + QUnit.test('initializers are concatenated', function () { + var firstInitializerRunCount = 0; + var secondInitializerRunCount = 0; + var FirstApp = _emberApplicationSystemApplication.default.extend(); + var firstApp = undefined, + secondApp = undefined; + + FirstApp.instanceInitializer({ + name: 'first', + initialize: function (registry) { + firstInitializerRunCount++; + } + }); + + var SecondApp = FirstApp.extend(); + SecondApp.instanceInitializer({ + name: 'second', + initialize: function (registry) { + secondInitializerRunCount++; + } + }); + + _emberViews.jQuery('#qunit-fixture').html('
    '); + _emberMetal.run(function () { + firstApp = FirstApp.create({ + router: false, + rootElement: '#qunit-fixture #first' + }); + }); + equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created'); + equal(secondInitializerRunCount, 0, 'first initializer only was run when base class created'); + firstInitializerRunCount = 0; + _emberMetal.run(function () { + secondApp = SecondApp.create({ + router: false, + rootElement: '#qunit-fixture #second' + }); + }); + equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); + equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created'); + _emberMetal.run(function () { + firstApp.destroy(); + secondApp.destroy(); + }); + }); + + QUnit.test('initializers are per-app', function () { + expect(2); + + var FirstApp = _emberApplicationSystemApplication.default.extend(); + + FirstApp.instanceInitializer({ + name: 'abc', + initialize: function (app) {} + }); + + expectAssertion(function () { + FirstApp.instanceInitializer({ + name: 'abc', + initialize: function (app) {} + }); + }); + + var SecondApp = _emberApplicationSystemApplication.default.extend(); + SecondApp.instanceInitializer({ + name: 'abc', + initialize: function (app) {} + }); + + ok(true, 'Two apps can have initializers named the same.'); + }); + + QUnit.test('initializers are run before ready hook', function () { + expect(2); + + var readyWasCalled = false; + + var MyApplication = _emberApplicationSystemApplication.default.extend({ + ready: function () { + ok(true, 'ready is called'); + readyWasCalled = true; + } + }); + + MyApplication.instanceInitializer({ + name: 'initializer', + initialize: function () { + ok(!readyWasCalled, 'ready is not yet called'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + }); + + QUnit.test('initializers are executed in their own context', function () { + expect(1); + + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.instanceInitializer({ + name: 'coolInitializer', + myProperty: 'cool', + initialize: function (registry, application) { + equal(this.myProperty, 'cool', 'should have access to its own context'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + }); + + QUnit.test('initializers get an instance on app reset', function () { + expect(2); + + var MyApplication = _emberApplicationSystemApplication.default.extend(); + + MyApplication.instanceInitializer({ + name: 'giveMeAnInstance', + initialize: function (instance) { + ok(!!instance, 'Initializer got an instance'); + } + }); + + _emberMetal.run(function () { + app = MyApplication.create({ + router: false, + rootElement: '#qunit-fixture' + }); + }); + + _emberMetal.run(app, 'reset'); + }); +}); +enifed('ember-application/tests/system/instance_initializers_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/instance_initializers_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/instance_initializers_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/logging_test', ['exports', 'ember-console', 'ember-metal', 'ember-application/system/application', 'ember-runtime', 'ember-routing', 'ember-template-compiler'], function (exports, _emberConsole, _emberMetal, _emberApplicationSystemApplication, _emberRuntime, _emberRouting, _emberTemplateCompiler) { + /*globals EmberDev */ + + 'use strict'; + + var App = undefined, + logs = undefined, + originalLogger = undefined; + + QUnit.module('Ember.Application – logging of generated classes', { + setup: function () { + logs = {}; + + originalLogger = _emberConsole.default.info; + + _emberConsole.default.info = function () { + var fullName = arguments[1].fullName; + + logs[fullName] = logs[fullName] || 0; + logs[fullName]++; + }; + + _emberMetal.run(function () { + App = _emberApplicationSystemApplication.default.create({ + LOG_ACTIVE_GENERATION: true + }); + + App.Router.reopen({ + location: 'none' + }); + + App.Router.map(function () { + this.route('posts', { resetNamespace: true }); + }); + + App.deferReadiness(); + }); + }, + + teardown: function () { + _emberConsole.default.info = originalLogger; + + _emberMetal.run(App, 'destroy'); + + logs = App = null; + } + }); + + function visit(path) { + QUnit.stop(); + + var promise = _emberMetal.run(function () { + return new _emberRuntime.RSVP.Promise(function (resolve, reject) { + var router = App.__container__.lookup('router:main'); + + resolve(router.handleURL(path).then(function (value) { + QUnit.start(); + ok(true, 'visited: `' + path + '`'); + return value; + }, function (reason) { + QUnit.start(); + ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason)); + throw reason; + })); + }); + }); + + return { + then: function (resolve, reject) { + _emberMetal.run(promise, 'then', resolve, reject); + } + }; + } + + QUnit.test('log class generation if logging enabled', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + _emberMetal.run(App, 'advanceReadiness'); + + visit('/posts').then(function () { + equal(Object.keys(logs).length, 6, 'expected logs'); + }); + }); + + QUnit.test('do NOT log class generation if logging disabled', function () { + App.reopen({ + LOG_ACTIVE_GENERATION: false + }); + + _emberMetal.run(App, 'advanceReadiness'); + + visit('/posts').then(function () { + equal(Object.keys(logs).length, 0, 'expected no logs'); + }); + }); + + QUnit.test('actively generated classes get logged', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + _emberMetal.run(App, 'advanceReadiness'); + + visit('/posts').then(function () { + equal(logs['controller:application'], 1, 'expected: ApplicationController was generated'); + equal(logs['controller:posts'], 1, 'expected: PostsController was generated'); + + equal(logs['route:application'], 1, 'expected: ApplicationRoute was generated'); + equal(logs['route:posts'], 1, 'expected: PostsRoute was generated'); + }); + }); + + QUnit.test('predefined classes do not get logged', function () { + App.ApplicationController = _emberRuntime.Controller.extend(); + App.PostsController = _emberRuntime.Controller.extend(); + + App.ApplicationRoute = _emberRouting.Route.extend(); + App.PostsRoute = _emberRouting.Route.extend(); + + _emberMetal.run(App, 'advanceReadiness'); + + visit('/posts').then(function () { + ok(!logs['controller:application'], 'did not expect: ApplicationController was generated'); + ok(!logs['controller:posts'], 'did not expect: PostsController was generated'); + + ok(!logs['route:application'], 'did not expect: ApplicationRoute was generated'); + ok(!logs['route:posts'], 'did not expect: PostsRoute was generated'); + }); + }); + + QUnit.module('Ember.Application – logging of view lookups', { + setup: function () { + logs = {}; + + originalLogger = _emberConsole.default.info; + + _emberConsole.default.info = function () { + var fullName = arguments[1].fullName; + + logs[fullName] = logs[fullName] || 0; + logs[fullName]++; + }; + + _emberMetal.run(function () { + App = _emberApplicationSystemApplication.default.create({ + LOG_VIEW_LOOKUPS: true + }); + + App.Router.reopen({ + location: 'none' + }); + + App.Router.map(function () { + this.route('posts', { resetNamespace: true }); + }); + + App.deferReadiness(); + }); + }, + + teardown: function () { + _emberConsole.default.info = originalLogger; + + _emberMetal.run(App, 'destroy'); + + logs = App = null; + } + }); + + QUnit.test('log when template and view are missing when flag is active', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + App.register('template:application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberMetal.run(App, 'advanceReadiness'); + + visit('/posts').then(function () { + equal(logs['template:application'], undefined, 'expected: Should not log template:application since it exists.'); + equal(logs['template:index'], 1, 'expected: Could not find "index" template or view.'); + equal(logs['template:posts'], 1, 'expected: Could not find "posts" template or view.'); + }); + }); + + QUnit.test('do not log when template and view are missing when flag is not true', function () { + App.reopen({ + LOG_VIEW_LOOKUPS: false + }); + + _emberMetal.run(App, 'advanceReadiness'); + + visit('/posts').then(function () { + equal(Object.keys(logs).length, 0, 'expected no logs'); + }); + }); + + QUnit.test('do not log which views are used with templates when flag is not true', function () { + App.reopen({ + LOG_VIEW_LOOKUPS: false + }); + + _emberMetal.run(App, 'advanceReadiness'); + + visit('/posts').then(function () { + equal(Object.keys(logs).length, 0, 'expected no logs'); + }); + }); +}); +enifed('ember-application/tests/system/logging_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/logging_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/logging_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/readiness_test', ['exports', 'ember-metal', 'ember-application/system/application'], function (exports, _emberMetal, _emberApplicationSystemApplication) { + 'use strict'; + + var jQuery = undefined, + application = undefined, + Application = undefined; + var readyWasCalled = undefined, + domReady = undefined, + readyCallbacks = undefined; + + // We are using a small mock of jQuery because jQuery is third-party code with + // very well-defined semantics, and we want to confirm that a jQuery stub run + // in a more minimal server environment that implements this behavior will be + // sufficient for Ember's requirements. + + QUnit.module('Application readiness', { + setup: function () { + readyWasCalled = 0; + readyCallbacks = []; + + var jQueryInstance = { + ready: function (callback) { + readyCallbacks.push(callback); + if (jQuery.isReady) { + domReady(); + } + } + }; + + jQuery = function () { + return jQueryInstance; + }; + jQuery.isReady = false; + + var domReadyCalled = 0; + domReady = function () { + if (domReadyCalled !== 0) { + return; + } + domReadyCalled++; + for (var i = 0; i < readyCallbacks.length; i++) { + readyCallbacks[i](); + } + }; + + Application = _emberApplicationSystemApplication.default.extend({ + $: jQuery, + + ready: function () { + readyWasCalled++; + } + }); + }, + + teardown: function () { + if (application) { + _emberMetal.run(function () { + return application.destroy(); + }); + } + } + }); + + // These tests are confirming that if the callbacks passed into jQuery's ready hook is called + // synchronously during the application's initialization, we get the same behavior as if + // it was triggered after initialization. + + QUnit.test('Ember.Application\'s ready event is called right away if jQuery is already ready', function () { + jQuery.isReady = true; + + _emberMetal.run(function () { + application = Application.create({ router: false }); + + equal(readyWasCalled, 0, 'ready is not called until later'); + }); + + equal(readyWasCalled, 1, 'ready was called'); + + domReady(); + + equal(readyWasCalled, 1, 'application\'s ready was not called again'); + }); + + QUnit.test('Ember.Application\'s ready event is called after the document becomes ready', function () { + _emberMetal.run(function () { + application = Application.create({ router: false }); + }); + + equal(readyWasCalled, 0, 'ready wasn\'t called yet'); + + domReady(); + + equal(readyWasCalled, 1, 'ready was called now that DOM is ready'); + }); + + QUnit.test('Ember.Application\'s ready event can be deferred by other components', function () { + _emberMetal.run(function () { + application = Application.create({ router: false }); + application.deferReadiness(); + }); + + equal(readyWasCalled, 0, 'ready wasn\'t called yet'); + + domReady(); + + equal(readyWasCalled, 0, 'ready wasn\'t called yet'); + + _emberMetal.run(function () { + application.advanceReadiness(); + equal(readyWasCalled, 0); + }); + + equal(readyWasCalled, 1, 'ready was called now all readiness deferrals are advanced'); + }); + + QUnit.test('Ember.Application\'s ready event can be deferred by other components', function () { + jQuery.isReady = false; + + _emberMetal.run(function () { + application = Application.create({ router: false }); + application.deferReadiness(); + equal(readyWasCalled, 0, 'ready wasn\'t called yet'); + }); + + domReady(); + + equal(readyWasCalled, 0, 'ready wasn\'t called yet'); + + _emberMetal.run(function () { + application.advanceReadiness(); + }); + + equal(readyWasCalled, 1, 'ready was called now all readiness deferrals are advanced'); + + expectAssertion(function () { + application.deferReadiness(); + }); + }); +}); +enifed('ember-application/tests/system/readiness_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/readiness_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/readiness_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/reset_test', ['exports', 'ember-metal', 'ember-application/system/application', 'ember-runtime', 'ember-routing', 'container'], function (exports, _emberMetal, _emberApplicationSystemApplication, _emberRuntime, _emberRouting, _container) { + 'use strict'; + + var application = undefined, + Application = undefined; + + QUnit.module('Ember.Application - resetting', { + setup: function () { + Application = _emberApplicationSystemApplication.default.extend({ + name: 'App', + rootElement: '#qunit-fixture' + }); + }, + teardown: function () { + Application = null; + if (application) { + _emberMetal.run(application, 'destroy'); + } + } + }); + + QUnit.test('Brings its own run-loop if not provided', function () { + application = _emberMetal.run(Application, 'create'); + application.ready = function () { + QUnit.start(); + ok(true, 'app booted'); + }; + + QUnit.stop(); + application.reset(); + }); + + QUnit.test('Does not bring its own run loop if one is already provided', function () { + expect(3); + + var didBecomeReady = false; + + application = _emberMetal.run(Application, 'create'); + + _emberMetal.run(function () { + application.ready = function () { + didBecomeReady = true; + }; + + application.reset(); + + application.deferReadiness(); + ok(!didBecomeReady, 'app is not ready'); + }); + + ok(!didBecomeReady, 'app is not ready'); + _emberMetal.run(application, 'advanceReadiness'); + ok(didBecomeReady, 'app is ready'); + }); + + QUnit.test('When an application is reset, new instances of controllers are generated', function () { + _emberMetal.run(function () { + application = Application.create(); + application.AcademicController = _emberRuntime.Controller.extend(); + }); + + var firstController = application.__container__.lookup('controller:academic'); + var secondController = application.__container__.lookup('controller:academic'); + + application.reset(); + + var thirdController = application.__container__.lookup('controller:academic'); + + strictEqual(firstController, secondController, 'controllers looked up in succession should be the same instance'); + + ok(firstController.isDestroying, 'controllers are destroyed when their application is reset'); + + notStrictEqual(firstController, thirdController, 'controllers looked up after the application is reset should not be the same instance'); + }); + + QUnit.test('When an application is reset, the eventDispatcher is destroyed and recreated', function () { + var eventDispatcherWasSetup = undefined, + eventDispatcherWasDestroyed = undefined; + + eventDispatcherWasSetup = 0; + eventDispatcherWasDestroyed = 0; + + var mock_event_dispatcher = { + create: function () { + return { + setup: function () { + eventDispatcherWasSetup++; + }, + destroy: function () { + eventDispatcherWasDestroyed++; + } + }; + } + }; + + // this is pretty awful. We should make this less Global-ly. + var originalRegister = _container.Registry.prototype.register; + _container.Registry.prototype.register = function (name, type, options) { + if (name === 'event_dispatcher:main') { + return mock_event_dispatcher; + } else { + return originalRegister.call(this, name, type, options); + } + }; + + try { + _emberMetal.run(function () { + application = Application.create(); + + equal(eventDispatcherWasSetup, 0); + equal(eventDispatcherWasDestroyed, 0); + }); + + equal(eventDispatcherWasSetup, 1); + equal(eventDispatcherWasDestroyed, 0); + + application.reset(); + + equal(eventDispatcherWasDestroyed, 1); + equal(eventDispatcherWasSetup, 2, 'setup called after reset'); + } catch (error) { + _container.Registry.prototype.register = originalRegister; + } + + _container.Registry.prototype.register = originalRegister; + }); + + QUnit.test('When an application is reset, the router URL is reset to `/`', function () { + var location = undefined, + router = undefined; + + _emberMetal.run(function () { + application = Application.create(); + application.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + application.Router.map(function () { + this.route('one'); + this.route('two'); + }); + }); + + router = application.__container__.lookup('router:main'); + + location = router.get('location'); + + _emberMetal.run(function () { + location.handleURL('/one'); + }); + + application.reset(); + + var applicationController = application.__container__.lookup('controller:application'); + router = application.__container__.lookup('router:main'); + location = router.get('location'); + + equal(location.getURL(), ''); + + equal(_emberMetal.get(applicationController, 'currentPath'), 'index'); + + location = application.__container__.lookup('router:main').get('location'); + _emberMetal.run(function () { + location.handleURL('/one'); + }); + + equal(_emberMetal.get(applicationController, 'currentPath'), 'one'); + }); + + QUnit.test('When an application with advance/deferReadiness is reset, the app does correctly become ready after reset', function () { + var readyCallCount; + + readyCallCount = 0; + + _emberMetal.run(function () { + application = Application.create({ + ready: function () { + readyCallCount++; + } + }); + + application.deferReadiness(); + equal(readyCallCount, 0, 'ready has not yet been called'); + }); + + _emberMetal.run(function () { + application.advanceReadiness(); + }); + + equal(readyCallCount, 1, 'ready was called once'); + + application.reset(); + + equal(readyCallCount, 2, 'ready was called twice'); + }); + + QUnit.test('With ember-data like initializer and constant', function () { + var DS = { + Store: _emberRuntime.Object.extend({ + init: function () { + if (!_emberMetal.get(DS, 'defaultStore')) { + _emberMetal.set(DS, 'defaultStore', this); + } + + this._super.apply(this, arguments); + }, + willDestroy: function () { + if (_emberMetal.get(DS, 'defaultStore') === this) { + _emberMetal.set(DS, 'defaultStore', null); + } + } + }) + }; + + Application.initializer({ + name: 'store', + initialize: function (application) { + application.unregister('store:main'); + application.register('store:main', application.Store); + + application.__container__.lookup('store:main'); + } + }); + + _emberMetal.run(function () { + application = Application.create(); + application.Store = DS.Store; + }); + + ok(DS.defaultStore, 'has defaultStore'); + + application.reset(); + + ok(DS.defaultStore, 'still has defaultStore'); + ok(application.__container__.lookup('store:main'), 'store is still present'); + }); +}); +enifed('ember-application/tests/system/reset_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/reset_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/reset_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/system/visit_test', ['exports', 'ember-runtime', 'ember-metal', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/engine', 'ember-routing', 'ember-glimmer', 'ember-template-compiler', 'ember-views'], function (exports, _emberRuntime, _emberMetal, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberApplicationSystemEngine, _emberRouting, _emberGlimmer, _emberTemplateCompiler, _emberViews) { + 'use strict'; + + var App = null; + var instance = null; + var instances = []; + + function createApplication(integration) { + App = _emberApplicationSystemApplication.default.extend().create({ + autoboot: false, + rootElement: '#qunit-fixture', + LOG_TRANSITIONS: true, + LOG_TRANSITIONS_INTERNAL: true, + LOG_ACTIVE_GENERATION: true + }); + + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + if (integration) { + App.instanceInitializer({ + name: 'auto-cleanup', + initialize: function (_instance) { + instances.push(_instance); + } + }); + } else { + App.instanceInitializer({ + name: 'auto-cleanup', + initialize: function (_instance) { + if (instance) { + _emberMetal.run(instance, 'destroy'); + } + + instance = _instance; + } + }); + } + + return App; + } + + function expectAsyncError() { + _emberRuntime.RSVP.off('error'); + } + + QUnit.module('Ember.Application - visit()', { + teardown: function () { + _emberRuntime.RSVP.on('error', _emberRuntime.onerrorDefault); + + if (instance) { + _emberMetal.run(instance, 'destroy'); + instance = null; + } + + if (App) { + _emberMetal.run(App, 'destroy'); + App = null; + } + } + }); + + // This tests whether the application is "autobooted" by registering an + // instance initializer and asserting it never gets run. Since this is + // inherently testing that async behavior *doesn't* happen, we set a + // 500ms timeout to verify that when autoboot is set to false, the + // instance initializer that would normally get called on DOM ready + // does not fire. + QUnit.test('Applications with autoboot set to false do not autoboot', function (assert) { + function delay(time) { + return new _emberRuntime.RSVP.Promise(function (resolve) { + return _emberMetal.run.later(resolve, time); + }); + } + + var appBooted = 0; + var instanceBooted = 0; + + _emberMetal.run(function () { + createApplication(); + + App.initializer({ + name: 'assert-no-autoboot', + initialize: function () { + appBooted++; + } + }); + + App.instanceInitializer({ + name: 'assert-no-autoboot', + initialize: function () { + instanceBooted++; + } + }); + }); + + // Continue after 500ms + return delay(500).then(function () { + assert.ok(appBooted === 0, '500ms elapsed without app being booted'); + assert.ok(instanceBooted === 0, '500ms elapsed without instances being booted'); + + return _emberMetal.run(App, 'boot'); + }).then(function () { + assert.ok(appBooted === 1, 'app should boot when manually calling `app.boot()`'); + assert.ok(instanceBooted === 0, 'no instances should be booted automatically when manually calling `app.boot()'); + }); + }); + + QUnit.test('calling visit() on an app without first calling boot() should boot the app', function (assert) { + var appBooted = 0; + var instanceBooted = 0; + + _emberMetal.run(function () { + createApplication(); + + App.initializer({ + name: 'assert-no-autoboot', + initialize: function () { + appBooted++; + } + }); + + App.instanceInitializer({ + name: 'assert-no-autoboot', + initialize: function () { + instanceBooted++; + } + }); + }); + + return _emberMetal.run(App, 'visit', '/').then(function () { + assert.ok(appBooted === 1, 'the app should be booted`'); + assert.ok(instanceBooted === 1, 'an instances should be booted'); + }); + }); + + QUnit.test('calling visit() on an already booted app should not boot it again', function (assert) { + var appBooted = 0; + var instanceBooted = 0; + + _emberMetal.run(function () { + createApplication(); + + App.initializer({ + name: 'assert-no-autoboot', + initialize: function () { + appBooted++; + } + }); + + App.instanceInitializer({ + name: 'assert-no-autoboot', + initialize: function () { + instanceBooted++; + } + }); + }); + + return _emberMetal.run(App, 'boot').then(function () { + assert.ok(appBooted === 1, 'the app should be booted'); + assert.ok(instanceBooted === 0, 'no instances should be booted'); + + return _emberMetal.run(App, 'visit', '/'); + }).then(function () { + assert.ok(appBooted === 1, 'the app should not be booted again'); + assert.ok(instanceBooted === 1, 'an instance should be booted'); + + return _emberMetal.run(App, 'visit', '/'); + }).then(function () { + assert.ok(appBooted === 1, 'the app should not be booted again'); + assert.ok(instanceBooted === 2, 'another instance should be booted'); + }); + }); + + QUnit.test('visit() rejects on application boot failure', function (assert) { + _emberMetal.run(function () { + createApplication(); + + App.initializer({ + name: 'error', + initialize: function () { + throw new Error('boot failure'); + } + }); + }); + + expectAsyncError(); + + return _emberMetal.run(App, 'visit', '/').then(function () { + assert.ok(false, 'It should not resolve the promise'); + }, function (error) { + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); + assert.equal(error.message, 'boot failure'); + }); + }); + + QUnit.test('visit() rejects on instance boot failure', function (assert) { + _emberMetal.run(function () { + createApplication(); + + App.instanceInitializer({ + name: 'error', + initialize: function () { + throw new Error('boot failure'); + } + }); + }); + + expectAsyncError(); + + return _emberMetal.run(App, 'visit', '/').then(function () { + assert.ok(false, 'It should not resolve the promise'); + }, function (error) { + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); + assert.equal(error.message, 'boot failure'); + }); + }); + + QUnit.test('visit() follows redirects', function (assert) { + _emberMetal.run(function () { + createApplication(); + + App.Router.map(function () { + this.route('a'); + this.route('b', { path: '/b/:b' }); + this.route('c', { path: '/c/:c' }); + }); + + App.register('route:a', _emberRouting.Route.extend({ + afterModel: function () { + this.replaceWith('b', 'zomg'); + } + })); + + App.register('route:b', _emberRouting.Route.extend({ + afterModel: function (params) { + this.transitionTo('c', params.b); + } + })); + }); + + return _emberMetal.run(App, 'visit', '/a').then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/c/zomg', 'It should follow all redirects'); + }); + }); + + QUnit.test('visit() rejects if an error occured during a transition', function (assert) { + _emberMetal.run(function () { + createApplication(); + + App.Router.map(function () { + this.route('a'); + this.route('b', { path: '/b/:b' }); + this.route('c', { path: '/c/:c' }); + }); + + App.register('route:a', _emberRouting.Route.extend({ + afterModel: function () { + this.replaceWith('b', 'zomg'); + } + })); + + App.register('route:b', _emberRouting.Route.extend({ + afterModel: function (params) { + this.transitionTo('c', params.b); + } + })); + + App.register('route:c', _emberRouting.Route.extend({ + afterModel: function (params) { + throw new Error('transition failure'); + } + })); + }); + + expectAsyncError(); + + return _emberMetal.run(App, 'visit', '/a').then(function () { + assert.ok(false, 'It should not resolve the promise'); + }, function (error) { + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); + assert.equal(error.message, 'transition failure'); + }); + }); + + QUnit.test('visit() chain', function (assert) { + _emberMetal.run(function () { + createApplication(); + + App.Router.map(function () { + this.route('a'); + this.route('b'); + this.route('c'); + }); + }); + + return _emberMetal.run(App, 'visit', '/').then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/'); + + return instance.visit('/a'); + }).then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/a'); + + return instance.visit('/b'); + }).then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/b'); + + return instance.visit('/c'); + }).then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/c'); + }); + }); + + QUnit.test('visit() returns a promise that resolves when the view has rendered', function (assert) { + _emberMetal.run(function () { + createApplication(); + + App.register('template:application', _emberTemplateCompiler.compile('

    Hello world

    ')); + }); + + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + + return _emberMetal.run(App, 'visit', '/').then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.equal(_emberViews.jQuery('#qunit-fixture > .ember-view h1').text(), 'Hello world', 'the application was rendered once the promise resolves'); + }); + }); + + QUnit.test('visit() returns a promise that resolves without rendering when shouldRender is set to false', function (assert) { + assert.expect(3); + + _emberMetal.run(function () { + createApplication(); + + App.register('template:application', _emberTemplateCompiler.compile('

    Hello world

    ')); + }); + + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + + return _emberMetal.run(App, 'visit', '/', { shouldRender: false }).then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are still no elements in the fixture element after visit'); + }); + }); + + QUnit.test('visit() renders a template when shouldRender is set to true', function (assert) { + assert.expect(3); + + _emberMetal.run(function () { + createApplication(); + + App.register('template:application', _emberTemplateCompiler.compile('

    Hello world

    ')); + }); + + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + + return _emberMetal.run(App, 'visit', '/', { shouldRender: true }).then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 1, 'there is 1 element in the fixture element after visit'); + }); + }); + + QUnit.test('visit() returns a promise that resolves without rendering when shouldRender is set to false with Engines', function (assert) { + assert.expect(3); + + _emberMetal.run(function () { + createApplication(); + + App.register('template:application', _emberTemplateCompiler.compile('

    Hello world

    ')); + + // Register engine + var BlogEngine = _emberApplicationSystemEngine.default.extend(); + App.register('engine:blog', BlogEngine); + + // Register engine route map + var BlogMap = function () {}; + App.register('route-map:blog', BlogMap); + + App.Router.map(function () { + this.mount('blog'); + }); + }); + + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + + return _emberMetal.run(App, 'visit', '/blog', { shouldRender: false }).then(function (instance) { + assert.ok(instance instanceof _emberApplicationSystemApplicationInstance.default, 'promise is resolved with an ApplicationInstance'); + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are still no elements in the fixture element after visit'); + }); + }); + + QUnit.test('visit() on engine resolves engine component', function (assert) { + assert.expect(2); + + _emberMetal.run(function () { + createApplication(); + + // Register engine + var BlogEngine = _emberApplicationSystemEngine.default.extend({ + init: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + this._super.apply(this, args); + this.register('template:application', _emberTemplateCompiler.compile('{{cache-money}}')); + this.register('template:components/cache-money', _emberTemplateCompiler.compile('\n

    Dis cache money

    \n ')); + this.register('component:cache-money', _emberGlimmer.Component.extend({})); + } + }); + App.register('engine:blog', BlogEngine); + + // Register engine route map + var BlogMap = function () {}; + App.register('route-map:blog', BlogMap); + + App.Router.map(function () { + this.mount('blog'); + }); + }); + + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + + return _emberMetal.run(App, 'visit', '/blog', { shouldRender: true }).then(function (instance) { + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').find('p').text(), 'Dis cache money', 'Engine component is resolved'); + }); + }); + + QUnit.test('visit() on engine resolves engine helper', function (assert) { + assert.expect(2); + + _emberMetal.run(function () { + createApplication(); + + // Register engine + var BlogEngine = _emberApplicationSystemEngine.default.extend({ + init: function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + this._super.apply(this, args); + this.register('template:application', _emberTemplateCompiler.compile('{{swag}}')); + this.register('helper:swag', _emberGlimmer.helper(function () { + return 'turnt up'; + })); + } + }); + App.register('engine:blog', BlogEngine); + + // Register engine route map + var BlogMap = function () {}; + App.register('route-map:blog', BlogMap); + + App.Router.map(function () { + this.mount('blog'); + }); + }); + + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + + return _emberMetal.run(App, 'visit', '/blog', { shouldRender: true }).then(function (instance) { + assert.strictEqual(_emberViews.jQuery('#qunit-fixture').text(), 'turnt up', 'Engine component is resolved'); + }); + }); + + QUnit.module('Ember.Application - visit() Integration Tests', { + teardown: function () { + if (instances) { + _emberMetal.run(instances, 'forEach', function (i) { + return i.destroy(); + }); + instances = []; + } + + if (App) { + _emberMetal.run(App, 'destroy'); + App = null; + } + } + }); + + QUnit.test('Ember Islands-style setup', function (assert) { + var xFooInitCalled = false; + var xFooDidInsertElementCalled = false; + + var xBarInitCalled = false; + var xBarDidInsertElementCalled = false; + + _emberMetal.run(function () { + createApplication(true); + + App.Router.map(function () { + this.route('show', { path: '/:component_name' }); + }); + + App.register('route:show', _emberRouting.Route.extend({ + queryParams: { + data: { refreshModel: true } + }, + + model: function (params) { + return { + componentName: params.component_name, + componentData: params.data ? JSON.parse(params.data) : undefined + }; + } + })); + + var Counter = _emberRuntime.Object.extend({ + value: 0, + + increment: function () { + this.incrementProperty('value'); + } + }); + + App.register('service:isolated-counter', Counter); + App.register('service:shared-counter', Counter.create(), { instantiate: false }); + + App.register('template:show', _emberTemplateCompiler.compile('{{component model.componentName model=model.componentData}}')); + + App.register('template:components/x-foo', _emberTemplateCompiler.compile('\n

    X-Foo

    \n

    Hello {{model.name}}, I have been clicked {{isolatedCounter.value}} times ({{sharedCounter.value}} times combined)!

    \n ')); + + App.register('component:x-foo', _emberGlimmer.Component.extend({ + tagName: 'x-foo', + + isolatedCounter: _emberRuntime.inject.service(), + sharedCounter: _emberRuntime.inject.service(), + + init: function () { + this._super(); + xFooInitCalled = true; + }, + + didInsertElement: function () { + xFooDidInsertElementCalled = true; + }, + + click: function () { + this.get('isolatedCounter').increment(); + this.get('sharedCounter').increment(); + } + })); + + App.register('template:components/x-bar', _emberTemplateCompiler.compile('\n

    X-Bar

    \n \n ')); + + App.register('component:x-bar', _emberGlimmer.Component.extend({ + counter: _emberRuntime.inject.service('shared-counter'), + + actions: { + incrementCounter: function () { + this.get('counter').increment(); + } + }, + + init: function () { + this._super(); + xBarInitCalled = true; + }, + + didInsertElement: function () { + xBarDidInsertElementCalled = true; + } + })); + }); + + var $foo = _emberViews.jQuery('
    ').appendTo('#qunit-fixture'); + var $bar = _emberViews.jQuery('
    ').appendTo('#qunit-fixture'); + + var data = encodeURIComponent(JSON.stringify({ name: 'Godfrey' })); + + return _emberRuntime.RSVP.all([_emberMetal.run(App, 'visit', '/x-foo?data=' + data, { rootElement: $foo[0] }), _emberMetal.run(App, 'visit', '/x-bar', { rootElement: $bar[0] })]).then(function () { + assert.ok(xFooInitCalled); + assert.ok(xFooDidInsertElementCalled); + + assert.ok(xBarInitCalled); + assert.ok(xBarDidInsertElementCalled); + + assert.equal($foo.find('h1').text(), 'X-Foo'); + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 0 times (0 times combined)!'); + assert.ok($foo.text().indexOf('X-Bar') === -1); + + assert.equal($bar.find('h1').text(), 'X-Bar'); + assert.equal($bar.find('button').text(), 'Join 0 others in clicking me!'); + assert.ok($bar.text().indexOf('X-Foo') === -1); + + _emberMetal.run(function () { + return $foo.find('x-foo').click(); + }); + + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (1 times combined)!'); + assert.equal($bar.find('button').text(), 'Join 1 others in clicking me!'); + + _emberMetal.run(function () { + $bar.find('button').click(); + $bar.find('button').click(); + }); + + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (3 times combined)!'); + assert.equal($bar.find('button').text(), 'Join 3 others in clicking me!'); + }); + }); + + QUnit.skip('Test setup', function (assert) {}); + + QUnit.skip('iframe setup', function (assert) {}); +}); +enifed('ember-application/tests/system/visit_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/system/visit_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/system/visit_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/tests/test-helpers/registry-check', ['exports'], function (exports) { + 'use strict'; + + exports.verifyRegistration = verifyRegistration; + exports.verifyInjection = verifyInjection; + + function verifyRegistration(owner, fullName) { + ok(owner.resolveRegistration(fullName), 'has registration: ' + fullName); + } + + function verifyInjection(owner, fullName, property, injectionName) { + var registry = owner.__registry__; + var injections = undefined; + + if (fullName.indexOf(':') === -1) { + injections = registry.getTypeInjections(fullName); + } else { + injections = registry.getInjections(registry.normalize(fullName)); + } + + var normalizedName = registry.normalize(injectionName); + var hasInjection = false; + var injection = undefined; + + for (var i = 0, l = injections.length; i < l; i++) { + injection = injections[i]; + if (injection.property === property && injection.fullName === normalizedName) { + hasInjection = true; + break; + } + } + + ok(hasInjection, 'has injection: ' + fullName + '.' + property + ' = ' + injectionName); + } +}); +enifed('ember-application/tests/test-helpers/registry-check.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/tests/test-helpers/registry-check.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/tests/test-helpers/registry-check.js should pass ESLint\n\n'); + }); +}); +enifed('ember-application/utils/validate-type.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-application/utils/validate-type.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-application/utils/validate-type.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/deprecate.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/deprecate.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/deprecate.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/handlers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/handlers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/handlers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/tests/handlers-test', ['exports', 'ember-debug/handlers'], function (exports, _emberDebugHandlers) { + 'use strict'; + + QUnit.module('ember-debug/handlers', { + teardown: function () { + delete _emberDebugHandlers.HANDLERS.blarz; + } + }); + + QUnit.test('calls handler on `invoke` when `falsey`', function (assert) { + assert.expect(2); + + function handler(message) { + assert.ok(true, 'called handler'); + assert.equal(message, 'Foo bar'); + } + + _emberDebugHandlers.registerHandler('blarz', handler); + + _emberDebugHandlers.invoke('blarz', 'Foo bar', false); + }); + + QUnit.test('does not call handler on `invoke` when `truthy`', function (assert) { + assert.expect(0); + + function handler() { + assert.ok(false, 'called handler'); + } + + _emberDebugHandlers.registerHandler('blarz', handler); + + _emberDebugHandlers.invoke('blarz', 'Foo bar', true); + }); + + QUnit.test('calling `invoke` without handlers does not throw an error', function (assert) { + assert.expect(0); + + _emberDebugHandlers.invoke('blarz', 'Foo bar', false); + }); + + QUnit.test('invoking `next` argument calls the next handler', function (assert) { + assert.expect(2); + + function handler1(message, options, next) { + assert.ok(true, 'called handler1'); + } + + function handler2(message, options, next) { + assert.ok(true, 'called handler2'); + next(message, options); + } + + _emberDebugHandlers.registerHandler('blarz', handler1); + _emberDebugHandlers.registerHandler('blarz', handler2); + + _emberDebugHandlers.invoke('blarz', 'Foo', false); + }); + + QUnit.test('invoking `next` when no other handlers exists does not error', function (assert) { + assert.expect(1); + + function handler(message, options, next) { + assert.ok(true, 'called handler1'); + + next(message, options); + } + + _emberDebugHandlers.registerHandler('blarz', handler); + + _emberDebugHandlers.invoke('blarz', 'Foo', false); + }); + + QUnit.test('handlers are called in the proper order', function (assert) { + assert.expect(11); + + var expectedMessage = 'This is the message'; + var expectedOptions = { id: 'foo-bar' }; + var expected = ['first', 'second', 'third', 'fourth', 'fifth']; + var actualCalls = []; + + function generateHandler(item) { + return function (message, options, next) { + assert.equal(message, expectedMessage, 'message supplied to ' + item + ' handler is correct'); + assert.equal(options, expectedOptions, 'options supplied to ' + item + ' handler is correct'); + + actualCalls.push(item); + + next(message, options); + }; + } + + expected.forEach(function (item) { + return _emberDebugHandlers.registerHandler('blarz', generateHandler(item)); + }); + + _emberDebugHandlers.invoke('blarz', expectedMessage, false, expectedOptions); + + assert.deepEqual(actualCalls, expected.reverse(), 'handlers were called in proper order'); + }); + + QUnit.test('not invoking `next` prevents further handlers from being called', function (assert) { + assert.expect(1); + + function handler1(message, options, next) { + assert.ok(false, 'called handler1'); + } + + function handler2(message, options, next) { + assert.ok(true, 'called handler2'); + } + + _emberDebugHandlers.registerHandler('blarz', handler1); + _emberDebugHandlers.registerHandler('blarz', handler2); + + _emberDebugHandlers.invoke('blarz', 'Foo', false); + }); + + QUnit.test('handlers can call `next` with custom message and/or options', function (assert) { + assert.expect(4); + + var initialMessage = 'initial message'; + var initialOptions = { id: 'initial-options' }; + + var handler2Message = 'Handler2 Message'; + var handler2Options = { id: 'handler-2' }; + + function handler1(message, options, next) { + assert.equal(message, handler2Message, 'handler2 message provided to handler1'); + assert.equal(options, handler2Options, 'handler2 options provided to handler1'); + } + + function handler2(message, options, next) { + assert.equal(message, initialMessage, 'initial message provided to handler2'); + assert.equal(options, initialOptions, 'initial options proivided to handler2'); + + next(handler2Message, handler2Options); + } + + _emberDebugHandlers.registerHandler('blarz', handler1); + _emberDebugHandlers.registerHandler('blarz', handler2); + + _emberDebugHandlers.invoke('blarz', initialMessage, false, initialOptions); + }); +}); +enifed('ember-debug/tests/handlers-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/tests/handlers-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/tests/handlers-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/tests/main_test', ['exports', 'ember-environment', 'ember-runtime', 'ember-debug/handlers', 'ember-debug/deprecate', 'ember-debug/warn', 'ember-metal'], function (exports, _emberEnvironment, _emberRuntime, _emberDebugHandlers, _emberDebugDeprecate, _emberDebugWarn, _emberMetal) { + 'use strict'; + + var originalEnvValue = undefined; + var originalDeprecateHandler = undefined; + + QUnit.module('ember-debug', { + setup: function () { + originalEnvValue = _emberEnvironment.ENV.RAISE_ON_DEPRECATION; + originalDeprecateHandler = _emberDebugHandlers.HANDLERS.deprecate; + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = true; + }, + + teardown: function () { + _emberDebugHandlers.HANDLERS.deprecate = originalDeprecateHandler; + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = originalEnvValue; + } + }); + + QUnit.test('Ember.deprecate does not throw if RAISE_ON_DEPRECATION is false', function (assert) { + assert.expect(1); + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = false; + + try { + assert.ok(true, 'Ember.deprecate did not throw'); + } catch (e) { + assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message); + } + }); + + QUnit.test('Ember.deprecate resets deprecation level to RAISE if ENV.RAISE_ON_DEPRECATION is set', function (assert) { + assert.expect(2); + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = false; + + try { + assert.ok(true, 'Ember.deprecate did not throw'); + } catch (e) { + assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message); + } + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = true; + + assert.throws(function () {}, /Should throw/); + }); + + QUnit.test('When ENV.RAISE_ON_DEPRECATION is true, it is still possible to silence a deprecation by id', function (assert) { + assert.expect(3); + + _emberEnvironment.ENV.RAISE_ON_DEPRECATION = true; + _emberDebugDeprecate.registerHandler(function (message, options, next) { + if (!options || options.id !== 'my-deprecation') { + next.apply(undefined, arguments); + } + }); + + try { + assert.ok(true, 'Did not throw when level is set by id'); + } catch (e) { + assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message); + } + + assert.throws(function () {}, /Should throw with no matching id/); + + assert.throws(function () {}, /Should throw with non-matching id/); + }); + + QUnit.test('Ember.deprecate throws deprecation if second argument is falsy', function () { + expect(3); + }); + + QUnit.test('Ember.deprecate does not invoke a function as the second argument', function () { + expect(1); + + ok(true, 'deprecations were not thrown'); + }); + + QUnit.test('Ember.deprecate does not throw deprecations if second argument is truthy', function () { + expect(1); + + ok(true, 'deprecations were not thrown'); + }); + + QUnit.test('Ember.assert throws if second argument is falsy', function () { + expect(3); + }); + + QUnit.test('Ember.assert does not throw if second argument is a function', function (assert) { + assert.expect(1); + + ok(true, 'assertions were not thrown'); + }); + + QUnit.test('Ember.assert does not throw if second argument is truthy', function () { + expect(1); + + ok(true, 'assertions were not thrown'); + }); + + QUnit.test('Ember.assert does not throw if second argument is an object', function () { + expect(1); + var Igor = _emberRuntime.Object.extend(); + + ok(true, 'assertions were not thrown'); + }); + + QUnit.test('Ember.deprecate does not throw a deprecation at log and silence levels', function () { + expect(4); + var id = 'ABC'; + var until = 'forever'; + var shouldThrow = false; + + _emberDebugDeprecate.registerHandler(function (message, options, next) { + if (options && options.id === id) { + if (shouldThrow) { + throw new Error(message); + } + } + }); + + try { + ok(true, 'Deprecation did not throw'); + } catch (e) { + ok(false, 'Deprecation was thrown despite being added to blacklist'); + } + + try { + ok(true, 'Deprecation did not throw'); + } catch (e) { + ok(false, 'Deprecation was thrown despite being added to blacklist'); + } + + shouldThrow = true; + + throws(function () {}); + + throws(function () {}); + }); + + QUnit.test('Ember.deprecate without options triggers a deprecation', function (assert) { + assert.expect(4); + + _emberDebugDeprecate.registerHandler(function (message) { + if (message === _emberDebugDeprecate.missingOptionsDeprecation) { + assert.ok(true, 'proper deprecation is triggered when options is missing'); + } else if (message === 'foo') { + assert.ok(true, 'original deprecation is still triggered'); + } + }); + }); + + QUnit.test('Ember.deprecate without options.id triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + if (message === _emberDebugDeprecate.missingOptionsIdDeprecation) { + assert.ok(true, 'proper deprecation is triggered when options.id is missing'); + } else if (message === 'foo') { + assert.ok(true, 'original deprecation is still triggered'); + } + }); + }); + + QUnit.test('Ember.deprecate without options.until triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + if (message === _emberDebugDeprecate.missingOptionsUntilDeprecation) { + assert.ok(true, 'proper deprecation is triggered when options.until is missing'); + } else if (message === 'foo') { + assert.ok(true, 'original deprecation is still triggered'); + } + }); + }); + + QUnit.test('warn without options triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + assert.equal(message, _emberDebugWarn.missingOptionsDeprecation, 'deprecation is triggered when options is missing'); + }); + + _emberDebugWarn.registerHandler(function (message) { + assert.equal(message, 'foo', 'original warning is triggered'); + }); + }); + + QUnit.test('warn without options.id triggers a deprecation', function (assert) { + assert.expect(2); + + _emberDebugDeprecate.registerHandler(function (message) { + assert.equal(message, _emberDebugWarn.missingOptionsIdDeprecation, 'deprecation is triggered when options is missing'); + }); + + _emberDebugWarn.registerHandler(function (message) { + assert.equal(message, 'foo', 'original warning is triggered'); + }); + }); +}); +enifed('ember-debug/tests/main_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/tests/main_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/tests/main_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/tests/warn_if_using_stripped_feature_flags_test', ['exports', 'ember-environment', 'ember-metal', 'ember-debug/index'], function (exports, _emberEnvironment, _emberMetal, _emberDebugIndex) { + 'use strict'; + + var oldWarn = undefined, + oldRunInDebug = undefined, + origEnvFeatures = undefined, + origEnableOptional = undefined, + features = undefined, + knownFeatures = undefined; + + function confirmWarns(expectedMsg) { + var featuresWereStripped = true; + + _emberMetal.setDebugFunction('warn', function (msg, test) { + if (!test) { + equal(msg, expectedMsg); + } + }); + + _emberMetal.setDebugFunction('runInDebug', function (func) { + func(); + }); + + // Should trigger our 1 warning + _emberDebugIndex._warnIfUsingStrippedFeatureFlags(features, knownFeatures, featuresWereStripped); + + // Shouldn't trigger any warnings now that we're "in canary" + featuresWereStripped = false; + _emberDebugIndex._warnIfUsingStrippedFeatureFlags(features, knownFeatures, featuresWereStripped); + } + + QUnit.module('ember-debug - _warnIfUsingStrippedFeatureFlags', { + setup: function () { + oldWarn = _emberMetal.getDebugFunction('warn'); + oldRunInDebug = _emberMetal.getDebugFunction('runInDebug'); + origEnvFeatures = _emberEnvironment.ENV.FEATURES; + origEnableOptional = _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES; + + knownFeatures = { + 'fred': null, + 'barney': null, + 'wilma': null + }; + }, + + teardown: function () { + _emberMetal.setDebugFunction('warn', oldWarn); + _emberMetal.setDebugFunction('runInDebug', oldRunInDebug); + _emberEnvironment.ENV.FEATURES = origEnvFeatures; + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = origEnableOptional; + } + }); + + QUnit.test('Setting Ember.ENV.ENABLE_OPTIONAL_FEATURES truthy in non-canary, debug build causes a warning', function () { + expect(1); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = true; + features = {}; + + confirmWarns('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.'); + }); + + QUnit.test('Enabling a known FEATURE flag in non-canary, debug build causes a warning', function () { + expect(1); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false; + features = { + 'fred': true, + 'barney': false, + 'wilma': null + }; + + confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.'); + }); + + QUnit.test('Enabling an unknown FEATURE flag in non-canary debug build does not cause a warning', function () { + expect(0); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false; + features = { + 'some-ember-data-feature-flag': true + }; + + confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.'); + }); + + QUnit.test('`ENV.FEATURES` being undefined does not cause an error', function () { + expect(0); + + _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false; + features = undefined; + + confirmWarns(); + }); +}); +enifed('ember-debug/tests/warn_if_using_stripped_feature_flags_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/tests/warn_if_using_stripped_feature_flags_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/tests/warn_if_using_stripped_feature_flags_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-debug/warn.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-debug/warn.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-debug/warn.js should pass ESLint\n\n'); + }); +}); +enifed('ember-dev/test-helper/assertion', ['exports', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperUtils) { + 'use strict'; + + exports.default = AssertionAssert; + + /* globals QUnit */ + + var BREAK = {}; + + /** + This assertion class is used to test assertions made using Ember.assert. + It injects two helpers onto `window`: + + - expectAssertion(func: Function, [expectedMessage: String | RegExp]) + + This function calls `func` and asserts that `Ember.assert` is invoked during + the execution. Moreover, it takes a String or a RegExp as a second optional + argument that can be used to test if a specific assertion message was + generated. + + - ignoreAssertion(func: Function) + + This function calls `func` and disables `Ember.assert` during the execution. + In particular, this prevents `Ember.assert` from throw errors that would + disrupt the control flow. + */ + function AssertionAssert(env) { + this.env = env; + } + + AssertionAssert.prototype = { + reset: function reset() {}, + assert: function assert() {}, + + inject: function inject() { + var _this = this; + + var expectAssertion = function expectAssertion(func, expectedMessage) { + if (_this.env.runningProdBuild) { + QUnit.ok(true, 'Assertions disabled in production builds.'); + return; + } + + var sawCall = undefined; + var actualMessage = undefined; + + // The try-catch statement is used to "exit" `func` as soon as + // the first useful assertion has been produced. + try { + _emberDevTestHelperUtils.callWithStub(_this.env, 'assert', func, function (message, test) { + sawCall = true; + if (_emberDevTestHelperUtils.checkTest(test)) { + return; + } + actualMessage = message; + throw BREAK; + }); + } catch (e) { + if (e !== BREAK) { + throw e; + } + } + + assert(sawCall, actualMessage, expectedMessage); + }; + + var ignoreAssertion = function ignoreAssertion(func) { + _emberDevTestHelperUtils.callWithStub(_this.env, 'assert', func); + }; + + window.expectAssertion = expectAssertion; + window.ignoreAssertion = ignoreAssertion; + }, + + restore: function restore() { + window.expectAssertion = null; + window.ignoreAssertion = null; + } + }; + + function assert(sawCall, actualMessage, expectedMessage) { + // Run assertions in an order that is useful when debugging a test failure. + if (!sawCall) { + QUnit.ok(false, 'Expected Ember.assert to be called (Not called with any value).'); + } else if (!actualMessage) { + QUnit.ok(false, 'Expected a failing Ember.assert (Ember.assert called, but without a failing test).'); + } else { + if (expectedMessage) { + if (expectedMessage instanceof RegExp) { + QUnit.ok(expectedMessage.test(actualMessage), 'Expected failing Ember.assert: \'' + expectedMessage + '\', but got \'' + actualMessage + '\'.'); + } else { + QUnit.equal(actualMessage, expectedMessage, 'Expected failing Ember.assert: \'' + expectedMessage + '\', but got \'' + actualMessage + '\'.'); + } + } else { + // Positive assertion that assert was called + QUnit.ok(true, 'Expected a failing Ember.assert.'); + } + } + } +}); +enifed('ember-dev/test-helper/debug', ['exports', 'ember-dev/test-helper/method-call-tracker'], function (exports, _emberDevTestHelperMethodCallTracker) { + 'use strict'; + + var _createClass = (function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + })(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } + } + + var DebugAssert = (function () { + function DebugAssert(methodName, env) { + _classCallCheck(this, DebugAssert); + + this.methodName = methodName; + this.env = env; + } + + _createClass(DebugAssert, [{ + key: 'inject', + value: function inject() {} + }, { + key: 'restore', + value: function restore() { + this.reset(); + } + }, { + key: 'reset', + value: function reset() { + if (this.tracker) { + this.tracker.restoreMethod(); + } + + this.tracker = null; + } + }, { + key: 'assert', + value: function assert() { + if (this.tracker) { + this.tracker.assert(); + } + } + + // Run an expectation callback within the context of a new tracker, optionally + // accepting a function to run, which asserts immediately + }, { + key: 'runExpectation', + value: function runExpectation(func, callback) { + var originalTracker = undefined; + + // When helpers are passed a callback, they get a new tracker context + if (func) { + originalTracker = this.tracker; + this.tracker = null; + } + + if (!this.tracker) { + this.tracker = new _emberDevTestHelperMethodCallTracker.default(this.env, this.methodName); + } + + // Yield to caller with tracker instance + callback(this.tracker); + + // Once the given callback is invoked, the pending assertions should be + // flushed immediately + if (func) { + func(); + this.assert(); + this.reset(); + + this.tracker = originalTracker; + } + } + }]); + + return DebugAssert; + })(); + + exports.default = DebugAssert; +}); +enifed('ember-dev/test-helper/deprecation', ['exports', 'ember-dev/test-helper/debug', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperDebug, _emberDevTestHelperUtils) { + 'use strict'; + + var _createClass = (function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + })(); + + var _get = function get(_x, _x2, _x3) { + var _again = true;_function: while (_again) { + var object = _x, + property = _x2, + receiver = _x3;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) { + var parent = Object.getPrototypeOf(object);if (parent === null) { + return undefined; + } else { + _x = parent;_x2 = property;_x3 = receiver;_again = true;desc = parent = undefined;continue _function; + } + } else if ('value' in desc) { + return desc.value; + } else { + var getter = desc.get;if (getter === undefined) { + return undefined; + }return getter.call(receiver); + } + } + }; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : babelHelpers.defaults(subClass, superClass); + } + + var DeprecationAssert = (function (_DebugAssert) { + _inherits(DeprecationAssert, _DebugAssert); + + function DeprecationAssert(env) { + _classCallCheck(this, DeprecationAssert); + + _get(Object.getPrototypeOf(DeprecationAssert.prototype), 'constructor', this).call(this, 'deprecate', env); + } + + _createClass(DeprecationAssert, [{ + key: 'inject', + value: function inject() { + var _this = this; + + // Expects no deprecation to happen within a function, or if no function is + // passed, from the time of calling until the end of the test. + // + // expectNoDeprecation(function() { + // fancyNewThing(); + // }); + // + // expectNoDeprecation(); + // Ember.deprecate("Old And Busted"); + // + var expectNoDeprecation = function expectNoDeprecation(func) { + if (typeof func !== 'function') { + func = null; + } + + _this.runExpectation(func, function (tracker) { + if (tracker.isExpectingCalls()) { + throw new Error("expectNoDeprecation was called after expectDeprecation was called!"); + } + + tracker.expectNoCalls(); + }); + }; + + // Expect a deprecation to happen within a function, or if no function + // is pass, from the time of calling until the end of the test. Can be called + // multiple times to assert deprecations with different specific messages + // were fired. + // + // expectDeprecation(function() { + // Ember.deprecate("Old And Busted"); + // }, /* optionalStringOrRegex */); + // + // expectDeprecation(/* optionalStringOrRegex */); + // Ember.deprecate("Old And Busted"); + // + var expectDeprecation = function expectDeprecation(func, message) { + if (typeof func !== 'function') { + message = func; + func = null; + } + + _this.runExpectation(func, function (tracker) { + if (tracker.isExpectingNoCalls()) { + throw new Error("expectDeprecation was called after expectNoDeprecation was called!"); + } + + tracker.expectCall(message); + }); + }; + + var ignoreDeprecation = function ignoreDeprecation(func) { + _emberDevTestHelperUtils.callWithStub(_this.env, 'deprecate', func); + }; + + window.expectNoDeprecation = expectNoDeprecation; + window.expectDeprecation = expectDeprecation; + window.ignoreDeprecation = ignoreDeprecation; + } + }, { + key: 'restore', + value: function restore() { + _get(Object.getPrototypeOf(DeprecationAssert.prototype), 'restore', this).call(this); + window.expectDeprecation = null; + window.expectNoDeprecation = null; + window.ignoreDeprecation = null; + } + }]); + + return DeprecationAssert; + })(_emberDevTestHelperDebug.default); + + exports.default = DeprecationAssert; +}); +enifed("ember-dev/test-helper/index", ["exports", "ember-dev/test-helper/deprecation", "ember-dev/test-helper/warning", "ember-dev/test-helper/remaining-view", "ember-dev/test-helper/remaining-template", "ember-dev/test-helper/assertion", "ember-dev/test-helper/run-loop", "ember-dev/test-helper/utils"], function (exports, _emberDevTestHelperDeprecation, _emberDevTestHelperWarning, _emberDevTestHelperRemainingView, _emberDevTestHelperRemainingTemplate, _emberDevTestHelperAssertion, _emberDevTestHelperRunLoop, _emberDevTestHelperUtils) { + "use strict"; + + var EmberDevTestHelperAssert = _emberDevTestHelperUtils.buildCompositeAssert([_emberDevTestHelperDeprecation.default, _emberDevTestHelperWarning.default, _emberDevTestHelperRemainingView.default, _emberDevTestHelperRemainingTemplate.default, _emberDevTestHelperAssertion.default, _emberDevTestHelperRunLoop.default]); + + exports.default = EmberDevTestHelperAssert; +}); +enifed('ember-dev/test-helper/method-call-tracker', ['exports', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperUtils) { + /* globals QUnit */ + + 'use strict'; + + var MethodCallTracker = function MethodCallTracker(env, methodName) { + this._env = env; + this._methodName = methodName; + this._isExpectingNoCalls = false; + this._expecteds = []; + this._actuals = []; + }; + + MethodCallTracker.prototype = { + stubMethod: function stubMethod() { + var _this = this; + + if (this._originalMethod) { + // Method is already stubbed + return; + } + + var env = this._env; + var methodName = this._methodName; + + this._originalMethod = env.getDebugFunction(methodName); + + env.setDebugFunction(methodName, function (message, test) { + var resultOfTest = _emberDevTestHelperUtils.checkTest(test); + + _this._actuals.push([message, resultOfTest]); + }); + }, + + restoreMethod: function restoreMethod() { + if (this._originalMethod) { + this._env.setDebugFunction(this._methodName, this._originalMethod); + } + }, + + expectCall: function expectCall(message) { + this.stubMethod(); + this._expecteds.push(message || /.*/); + }, + + expectNoCalls: function expectNoCalls() { + this.stubMethod(); + this._isExpectingNoCalls = true; + }, + + isExpectingNoCalls: function isExpectingNoCalls() { + return this._isExpectingNoCalls; + }, + + isExpectingCalls: function isExpectingCalls() { + return !this._isExpectingNoCalls && this._expecteds.length; + }, + + assert: function assert() { + var env = this._env; + var methodName = this._methodName; + var isExpectingNoCalls = this._isExpectingNoCalls; + var expecteds = this._expecteds; + var actuals = this._actuals; + var o = undefined, + i = undefined; + + if (!isExpectingNoCalls && expecteds.length === 0 && actuals.length === 0) { + return; + } + + if (env.runningProdBuild) { + QUnit.ok(true, 'calls to Ember.' + methodName + ' disabled in production builds.'); + return; + } + + if (isExpectingNoCalls) { + var actualMessages = []; + for (i = 0; i < actuals.length; i++) { + if (!actuals[i][1]) { + actualMessages.push(actuals[i][0]); + } + } + QUnit.ok(actualMessages.length === 0, 'Expected no Ember.' + methodName + ' calls, got ' + actuals.length + ': ' + actualMessages.join(', ')); + return; + } + + var expected = undefined, + actual = undefined, + match = undefined; + + for (o = 0; o < expecteds.length; o++) { + expected = expecteds[o]; + for (i = 0; i < actuals.length; i++) { + actual = actuals[i]; + if (!actual[1]) { + if (expected instanceof RegExp) { + if (expected.test(actual[0])) { + match = actual; + break; + } + } else { + if (expected === actual[0]) { + match = actual; + break; + } + } + } + } + + if (!actual) { + QUnit.ok(false, 'Received no Ember.' + methodName + ' calls at all, expecting: ' + expected); + } else if (match && !match[1]) { + QUnit.ok(true, 'Received failing Ember.' + methodName + ' call with message: ' + match[0]); + } else if (match && match[1]) { + QUnit.ok(false, 'Expected failing Ember.' + methodName + ' call, got succeeding with message: ' + match[0]); + } else if (actual[1]) { + QUnit.ok(false, 'Did not receive failing Ember.' + methodName + ' call matching \'' + expected + '\', last was success with \'' + actual[0] + '\''); + } else if (!actual[1]) { + QUnit.ok(false, 'Did not receive failing Ember.' + methodName + ' call matching \'' + expected + '\', last was failure with \'' + actual[0] + '\''); + } + } + } + }; + + exports.default = MethodCallTracker; +}); +enifed("ember-dev/test-helper/remaining-template", ["exports"], function (exports) { + /* globals QUnit */ + + "use strict"; + + var RemainingTemplateAssert = function RemainingTemplateAssert(env) { + this.env = env; + }; + + RemainingTemplateAssert.prototype = { + reset: function reset() {}, + inject: function inject() {}, + assert: function assert() { + if (this.env.Ember && this.env.Ember.TEMPLATES) { + var templateNames = [], + name; + for (name in this.env.Ember.TEMPLATES) { + if (this.env.Ember.TEMPLATES[name] != null) { + templateNames.push(name); + } + } + + if (templateNames.length > 0) { + QUnit.deepEqual(templateNames, [], "Ember.TEMPLATES should be empty"); + this.env.Ember.TEMPLATES = {}; + } + } + }, + restore: function restore() {} + }; + + exports.default = RemainingTemplateAssert; +}); +enifed("ember-dev/test-helper/remaining-view", ["exports"], function (exports) { + /* globals QUnit */ + + "use strict"; + + var RemainingViewAssert = function RemainingViewAssert(env) { + this.env = env; + }; + + RemainingViewAssert.prototype = { + reset: function reset() {}, + inject: function inject() {}, + assert: function assert() { + if (this.env.Ember && this.env.Ember.View) { + var viewIds = [], + id; + for (id in this.env.Ember.View.views) { + if (this.env.Ember.View.views[id] != null) { + viewIds.push(id); + } + } + + if (viewIds.length > 0) { + QUnit.deepEqual(viewIds, [], "Ember.View.views should be empty"); + this.env.Ember.View.views = []; + } + } + }, + restore: function restore() {} + }; + + exports.default = RemainingViewAssert; +}); +enifed("ember-dev/test-helper/run-loop", ["exports"], function (exports) { + /* globals QUnit */ + + "use strict"; + + function RunLoopAssertion(env) { + this.env = env; + } + + RunLoopAssertion.prototype = { + reset: function reset() {}, + inject: function inject() {}, + assert: function assert() { + var run = this.env.Ember.run; + + if (run.currentRunLoop) { + QUnit.ok(false, "Should not be in a run loop at end of test"); + while (run.currentRunLoop) { + run.end(); + } + } + + if (run.hasScheduledTimers()) { + QUnit.ok(false, "Ember run should not have scheduled timers at end of test"); + run.cancelTimers(); + } + }, + restore: function restore() {} + }; + + exports.default = RunLoopAssertion; +}); +enifed("ember-dev/test-helper/setup-qunit", ["exports"], function (exports) { + "use strict"; + + exports.default = setupQUnit; + + /* globals QUnit */ + function setupQUnit(assertion, _qunitGlobal) { + var qunitGlobal = QUnit; + + if (_qunitGlobal) { + qunitGlobal = _qunitGlobal; + } + + var originalModule = qunitGlobal.module; + + qunitGlobal.module = function (name, _options) { + var options = _options || {}; + var originalSetup = options.setup || function () {}; + var originalTeardown = options.teardown || function () {}; + + options.setup = function () { + assertion.reset(); + assertion.inject(); + + originalSetup.apply(this, arguments); + }; + + options.teardown = function () { + originalTeardown.apply(this, arguments); + + assertion.assert(); + assertion.restore(); + }; + + return originalModule(name, options); + }; + } +}); +enifed('ember-dev/test-helper/utils', ['exports'], function (exports) { + 'use strict'; + + exports.buildCompositeAssert = buildCompositeAssert; + exports.callWithStub = callWithStub; + exports.checkTest = checkTest; + + function callForEach(prop, func) { + return function () { + for (var i = 0, l = this[prop].length; i < l; i++) { + this[prop][i][func](); + } + }; + } + + function buildCompositeAssert(assertClasses) { + function Composite(env) { + this.asserts = assertClasses.map(function (Assert) { + return new Assert(env); + }); + } + + Composite.prototype = { + reset: callForEach('asserts', 'reset'), + inject: callForEach('asserts', 'inject'), + assert: callForEach('asserts', 'assert'), + restore: callForEach('asserts', 'restore') + }; + + return Composite; + } + + function noop() {} + + function callWithStub(env, name, func) { + var debugStub = arguments.length <= 3 || arguments[3] === undefined ? noop : arguments[3]; + + var originalFunc = env.getDebugFunction(name); + try { + env.setDebugFunction(name, debugStub); + func(); + } finally { + env.setDebugFunction(name, originalFunc); + } + } + + function checkTest(test) { + return typeof test === 'function' ? test() : test; + } +}); +enifed('ember-dev/test-helper/warning', ['exports', 'ember-dev/test-helper/debug', 'ember-dev/test-helper/utils'], function (exports, _emberDevTestHelperDebug, _emberDevTestHelperUtils) { + 'use strict'; + + var _createClass = (function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + })(); + + var _get = function get(_x, _x2, _x3) { + var _again = true;_function: while (_again) { + var object = _x, + property = _x2, + receiver = _x3;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) { + var parent = Object.getPrototypeOf(object);if (parent === null) { + return undefined; + } else { + _x = parent;_x2 = property;_x3 = receiver;_again = true;desc = parent = undefined;continue _function; + } + } else if ('value' in desc) { + return desc.value; + } else { + var getter = desc.get;if (getter === undefined) { + return undefined; + }return getter.call(receiver); + } + } + }; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : babelHelpers.defaults(subClass, superClass); + } + + var WarningAssert = (function (_DebugAssert) { + _inherits(WarningAssert, _DebugAssert); + + function WarningAssert(env) { + _classCallCheck(this, WarningAssert); + + _get(Object.getPrototypeOf(WarningAssert.prototype), 'constructor', this).call(this, 'warn', env); + } + + _createClass(WarningAssert, [{ + key: 'inject', + value: function inject() { + var _this = this; + + // Expects no warning to happen within a function, or if no function is + // passed, from the time of calling until the end of the test. + // + // expectNoWarning(function() { + // fancyNewThing(); + // }); + // + // expectNoWarning(); + // Ember.warn("Oh snap, didn't expect that"); + // + var expectNoWarning = function expectNoWarning(func) { + if (typeof func !== 'function') { + func = null; + } + + _this.runExpectation(func, function (tracker) { + if (tracker.isExpectingCalls()) { + throw new Error("expectNoWarning was called after expectWarning was called!"); + } + + tracker.expectNoCalls(); + }); + }; + + // Expect a warning to happen within a function, or if no function is + // passed, from the time of calling until the end of the test. Can be called + // multiple times to assert warnings with different specific messages + // happened. + // + // expectWarning(function() { + // Ember.warn("Times they are a-changin'"); + // }, /* optionalStringOrRegex */); + // + // expectWarning(/* optionalStringOrRegex */); + // Ember.warn("Times definitely be changin'"); + // + var expectWarning = function expectWarning(fn, message) { + if (typeof fn !== 'function') { + message = fn; + fn = null; + } + + _this.runExpectation(fn, function (tracker) { + if (tracker.isExpectingNoCalls()) { + throw new Error("expectWarning was called after expectNoWarning was called!"); + } + + tracker.expectCall(message); + }); + }; + + var ignoreWarning = function ignoreWarning(func) { + _emberDevTestHelperUtils.callWithStub(_this.env, 'warn', func); + }; + + window.expectNoWarning = expectNoWarning; + window.expectWarning = expectWarning; + window.ignoreWarning = ignoreWarning; + } + }, { + key: 'restore', + value: function restore() { + _get(Object.getPrototypeOf(WarningAssert.prototype), 'restore', this).call(this); + window.expectWarning = null; + window.expectNoWarning = null; + window.ignoreWarning = null; + } + }]); + + return WarningAssert; + })(_emberDevTestHelperDebug.default); + + exports.default = WarningAssert; +}); +enifed('ember-extension-support/container_debug_adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/container_debug_adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/container_debug_adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/data_adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/data_adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/data_adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/tests/container_debug_adapter_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-extension-support/index', 'ember-application'], function (exports, _emberMetal, _emberRuntime, _emberExtensionSupportIndex, _emberApplication) { + 'use strict'; + + var adapter = undefined, + App = undefined, + appInstance = undefined; + + function boot() { + _emberMetal.run(App, 'advanceReadiness'); + } + + QUnit.module('Container Debug Adapter', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); // ES6TODO: this comes from the ember-application package NOT ember-runtime. + App.toString = function () { + return 'App'; + }; + App.deferReadiness(); + }); + boot(); + _emberMetal.run(function () { + appInstance = App.__deprecatedInstance__; + adapter = appInstance.lookup('container-debug-adapter:main'); + }); + }, + teardown: function () { + _emberMetal.run(function () { + adapter.destroy(); + appInstance.destroy(); + App.destroy(); + App = appInstance = adapter = null; + }); + } + }); + + QUnit.test('the default ContainerDebugAdapter cannot catalog certain entries by type', function () { + equal(adapter.canCatalogEntriesByType('model'), false, 'canCatalogEntriesByType should return false for model'); + equal(adapter.canCatalogEntriesByType('template'), false, 'canCatalogEntriesByType should return false for template'); + }); + + QUnit.test('the default ContainerDebugAdapter can catalog typical entries by type', function () { + equal(adapter.canCatalogEntriesByType('controller'), true, 'canCatalogEntriesByType should return true for controller'); + equal(adapter.canCatalogEntriesByType('route'), true, 'canCatalogEntriesByType should return true for route'); + equal(adapter.canCatalogEntriesByType('view'), true, 'canCatalogEntriesByType should return true for view'); + }); + + QUnit.test('the default ContainerDebugAdapter catalogs controller entries', function () { + App.PostController = _emberRuntime.Controller.extend(); + var controllerClasses = adapter.catalogEntriesByType('controller'); + + equal(controllerClasses.length, 1, 'found 1 class'); + equal(controllerClasses[0], 'post', 'found the right class'); + }); +}); +// Must be required to export Ember.ContainerDebugAdapter. +enifed('ember-extension-support/tests/container_debug_adapter_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/tests/container_debug_adapter_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/tests/container_debug_adapter_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-extension-support/tests/data_adapter_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-extension-support/data_adapter', 'ember-application'], function (exports, _emberMetal, _emberRuntime, _emberExtensionSupportData_adapter, _emberApplication) { + 'use strict'; + + var adapter = undefined, + App = undefined; + var Model = _emberRuntime.Object.extend(); + + var DataAdapter = _emberExtensionSupportData_adapter.default.extend({ + detect: function (klass) { + return klass !== Model && Model.detect(klass); + } + }); + + QUnit.module('Data Adapter', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.toString = function () { + return 'App'; + }; + App.deferReadiness(); + App.register('data-adapter:main', DataAdapter); + }); + }, + teardown: function () { + _emberMetal.run(function () { + adapter.destroy(); + App.destroy(); + }); + } + }); + + QUnit.test('Model types added with DefaultResolver', function () { + App.Post = Model.extend(); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return _emberRuntime.A([1, 2, 3]); + }, + columnsForType: function () { + return [{ name: 'title', desc: 'Title' }]; + } + }); + + _emberMetal.run(App, 'advanceReadiness'); + + function modelTypesAdded(types) { + equal(types.length, 1); + var postType = types[0]; + equal(postType.name, 'post', 'Correctly sets the name'); + equal(postType.count, 3, 'Correctly sets the record count'); + strictEqual(postType.object, App.Post, 'Correctly sets the object'); + deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); + } + + _emberMetal.run(adapter, 'watchModelTypes', modelTypesAdded); + }); + + QUnit.test('getRecords gets a model name as second argument', function () { + App.Post = Model.extend(); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function (klass, name) { + equal(name, 'post'); + return _emberRuntime.A(); + } + }); + + adapter.watchModelTypes(function () {}); + }); + + QUnit.test('Model types added with custom container-debug-adapter', function () { + var PostClass = Model.extend(); + var StubContainerDebugAdapter = _emberApplication.Resolver.extend({ + canCatalogEntriesByType: function (type) { + return true; + }, + catalogEntriesByType: function (type) { + return [PostClass]; + } + }); + App.register('container-debug-adapter:main', StubContainerDebugAdapter); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return _emberRuntime.A([1, 2, 3]); + }, + columnsForType: function () { + return [{ name: 'title', desc: 'Title' }]; + } + }); + + _emberMetal.run(App, 'advanceReadiness'); + + function modelTypesAdded(types) { + equal(types.length, 1); + var postType = types[0]; + + equal(postType.name, PostClass.toString(), 'Correctly sets the name'); + equal(postType.count, 3, 'Correctly sets the record count'); + strictEqual(postType.object, PostClass, 'Correctly sets the object'); + deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); + } + + _emberMetal.run(adapter, 'watchModelTypes', modelTypesAdded); + }); + + QUnit.test('Model Types Updated', function () { + App.Post = Model.extend(); + + adapter = App.__container__.lookup('data-adapter:main'); + var records = _emberRuntime.A([1, 2, 3]); + adapter.reopen({ + getRecords: function () { + return records; + } + }); + + _emberMetal.run(App, 'advanceReadiness'); + + function modelTypesAdded() { + _emberMetal.run(function () { + records.pushObject(4); + }); + } + + function modelTypesUpdated(types) { + var postType = types[0]; + equal(postType.count, 4, 'Correctly updates the count'); + } + + _emberMetal.run(adapter, 'watchModelTypes', modelTypesAdded, modelTypesUpdated); + }); + + QUnit.test('Records Added', function () { + expect(8); + var countAdded = 1; + + App.Post = Model.extend(); + + var post = App.Post.create(); + var recordList = _emberRuntime.A([post]); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return recordList; + }, + getRecordColor: function () { + return 'blue'; + }, + getRecordColumnValues: function () { + return { title: 'Post ' + countAdded }; + }, + getRecordKeywords: function () { + return ['Post ' + countAdded]; + } + }); + + function recordsAdded(records) { + var record = records[0]; + equal(record.color, 'blue', 'Sets the color correctly'); + deepEqual(record.columnValues, { title: 'Post ' + countAdded }, 'Sets the column values correctly'); + deepEqual(record.searchKeywords, ['Post ' + countAdded], 'Sets search keywords correctly'); + strictEqual(record.object, post, 'Sets the object to the record instance'); + } + + adapter.watchRecords(App.Post, recordsAdded); + countAdded++; + post = App.Post.create(); + recordList.pushObject(post); + }); + + QUnit.test('Observes and releases a record correctly', function () { + var updatesCalled = 0; + App.Post = Model.extend(); + + var post = App.Post.create({ title: 'Post' }); + var recordList = _emberRuntime.A([post]); + + adapter = App.__container__.lookup('data-adapter:main'); + adapter.reopen({ + getRecords: function () { + return recordList; + }, + observeRecord: function (record, recordUpdated) { + var self = this; + function callback() { + recordUpdated(self.wrapRecord(record)); + } + _emberMetal.addObserver(record, 'title', callback); + return function () { + _emberMetal.removeObserver(record, 'title', callback); + }; + }, + getRecordColumnValues: function (record) { + return { title: _emberMetal.get(record, 'title') }; + } + }); + + function recordsAdded() { + _emberMetal.set(post, 'title', 'Post Modified'); + } + + function recordsUpdated(records) { + updatesCalled++; + equal(records[0].columnValues.title, 'Post Modified'); + } + + var release = adapter.watchRecords(App.Post, recordsAdded, recordsUpdated); + release(); + _emberMetal.set(post, 'title', 'New Title'); + equal(updatesCalled, 1, 'Release function removes observers'); + }); +}); +enifed('ember-extension-support/tests/data_adapter_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-extension-support/tests/data_adapter_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-extension-support/tests/data_adapter_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/checkbox.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/checkbox.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/checkbox.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/link-to.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/link-to.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/link-to.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/text_area.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/text_area.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/text_area.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/components/text_field.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/components/text_field.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/components/text_field.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/dom.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/dom.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/dom.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/environment.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/environment.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/environment.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helper.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helper.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helper.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-class.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-class.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-class.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-html-safe.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-html-safe.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-html-safe.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-input-type.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-input-type.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-input-type.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/-normalize-class.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/-normalize-class.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/-normalize-class.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/action.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/action.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/action.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/concat.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/concat.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/concat.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/each-in.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/each-in.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/each-in.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/get.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/get.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/get.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/hash.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/hash.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/hash.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/if-unless.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/if-unless.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/if-unless.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/loc.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/loc.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/loc.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/log.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/log.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/log.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/mut.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/mut.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/mut.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/query-param.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/query-param.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/query-param.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/readonly.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/readonly.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/readonly.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/helpers/unbound.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/helpers/unbound.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/helpers/unbound.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/make-bound-helper.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/make-bound-helper.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/make-bound-helper.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/modifiers/action.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/modifiers/action.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/modifiers/action.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/protocol-for-url.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/protocol-for-url.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/protocol-for-url.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/renderer.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/renderer.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/renderer.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/setup-registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/setup-registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/setup-registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/-in-element.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/-in-element.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/-in-element.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/-text-area.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/-text-area.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/-text-area.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/-with-dynamic-vars.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/-with-dynamic-vars.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/-with-dynamic-vars.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/abstract-manager.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/abstract-manager.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/abstract-manager.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/curly-component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/curly-component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/curly-component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/dynamic-component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/dynamic-component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/dynamic-component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/input.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/input.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/input.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/mount.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/mount.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/mount.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/outlet.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/outlet.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/outlet.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/syntax/render.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/syntax/render.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/syntax/render.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/template.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/template.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/template.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/template_registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/template_registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/template_registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/application/actions-test', ['exports', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberRuntime, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Application test: actions', (function (_ApplicationTest) { + babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + _ApplicationTest.apply(this, arguments); + } + + _class.prototype['@test actions in top level template application template target application controller'] = function testActionsInTopLevelTemplateApplicationTemplateTargetApplicationController(assert) { + var _this = this; + + assert.expect(1); + + this.registerController('application', _emberRuntime.Controller.extend({ + actions: { + handleIt: function (arg) { + assert.ok(true, 'controller received action properly'); + } + } + })); + + this.registerTemplate('application', ''); + + return this.visit('/').then(function () { + _this.runTask(function () { + return _this.$('#handle-it').click(); + }); + }); + }; + + _class.prototype['@test actions in nested outlet template target their controller'] = function testActionsInNestedOutletTemplateTargetTheirController(assert) { + var _this2 = this; + + assert.expect(1); + + this.registerController('application', _emberRuntime.Controller.extend({ + actions: { + handleIt: function (arg) { + assert.ok(false, 'application controller should not have received action!'); + } + } + })); + + this.registerController('index', _emberRuntime.Controller.extend({ + actions: { + handleIt: function (arg) { + assert.ok(true, 'controller received action properly'); + } + } + })); + + this.registerTemplate('index', ''); + + return this.visit('/').then(function () { + _this2.runTask(function () { + return _this2.$('#handle-it').click(); + }); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Rendering test: non-interactive actions', (function (_RenderingTest) { + babelHelpers.inherits(_class2, _RenderingTest); + + function _class2() { + _RenderingTest.apply(this, arguments); + } + + _class2.prototype.getBootOptions = function getBootOptions() { + return { isInteractive: false }; + }; + + _class2.prototype['@test doesn\'t attatch actions'] = function testDoesnTAttatchActions(assert) { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + fire: function () { + assert.ok(false); + } + } + }), + template: '' + }); + + this.render('{{foo-bar tagName=""}}'); + + this.assertHTML(''); + + this.$('button').click(); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/application/actions-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/application/actions-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/application/actions-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/application/engine-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-glimmer', 'ember-application', 'ember-routing'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberGlimmer, _emberApplication, _emberRouting) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n

    {{contextType}}

    \n {{ambiguous-curlies}}\n\n {{outlet}}\n '], ['\n

    {{contextType}}

    \n {{ambiguous-curlies}}\n\n {{outlet}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Component!

    \n '], ['\n

    Component!

    \n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{ambiguous-curlies}}\n '], ['\n {{ambiguous-curlies}}\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Application

    \n {{my-component ambiguous-curlies="Local Data!"}}\n {{outlet}}\n '], ['\n

    Application

    \n {{my-component ambiguous-curlies="Local Data!"}}\n {{outlet}}\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Engine

    \n {{my-component}}\n {{outlet}}\n '], ['\n

    Engine

    \n {{my-component}}\n {{outlet}}\n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Component!

    \n '], ['\n

    Component!

    \n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Application test: engine rendering', (function (_ApplicationTest) { +babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + _ApplicationTest.apply(this, arguments); + } + + _class.prototype.setupAppAndRoutableEngine = function setupAppAndRoutableEngine() { + var hooks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + var self = this; + + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{outlet}}')); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () { + this.route('post', function () { + this.route('comments'); + this.route('likes'); + }); + this.route('category', { path: 'category/:id' }); + this.route('author', { path: 'author/:id' }); + }); + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + hooks.push('application - application'); + } + })); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('controller:application', _emberRuntime.Controller.extend({ + queryParams: ['lang'], + lang: '' + })); + this.register('controller:category', _emberRuntime.Controller.extend({ + queryParams: ['type'] + })); + this.register('controller:authorKtrl', _emberRuntime.Controller.extend({ + queryParams: ['official'] + })); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine{{lang}}{{outlet}}')); + this.register('route:application', _emberRouting.Route.extend({ + model: function () { + hooks.push('engine - application'); + } + })); + this.register('route:author', _emberRouting.Route.extend({ + controllerName: 'authorKtrl' + })); + + if (self._additionalEngineRegistrations) { + self._additionalEngineRegistrations.call(this); + } + } + })); + }; + + _class.prototype.setupAppAndRoutelessEngine = function setupAppAndRoutelessEngine(hooks) { + this.setupRoutelessEngine(hooks); + + this.registerEngine('chat-engine', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine')); + this.register('controller:application', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + hooks.push('engine - application'); + } + })); + } + })); + }; + + _class.prototype.setupAppAndRoutableEngineWithPartial = function setupAppAndRoutableEngineWithPartial(hooks) { + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{outlet}}')); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () {}); + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + hooks.push('application - application'); + } + })); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:foo', _emberGlimmerTestsUtilsHelpers.compile('foo partial')); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine{{outlet}} {{partial "foo"}}')); + this.register('route:application', _emberRouting.Route.extend({ + model: function () { + hooks.push('engine - application'); + } + })); + } + })); + }; + + _class.prototype.setupRoutelessEngine = function setupRoutelessEngine(hooks) { + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{mount "chat-engine"}}')); + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + hooks.push('application - application'); + } + })); + }; + + _class.prototype.setupAppAndRoutlessEngineWithPartial = function setupAppAndRoutlessEngineWithPartial(hooks) { + this.setupRoutelessEngine(hooks); + + this.registerEngine('chat-engine', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:foo', _emberGlimmerTestsUtilsHelpers.compile('foo partial')); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine {{partial "foo"}}')); + this.register('controller:application', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + hooks.push('engine - application'); + } + })); + } + })); + }; + + _class.prototype.additionalEngineRegistrations = function additionalEngineRegistrations(callback) { + this._additionalEngineRegistrations = callback; + }; + + _class.prototype.setupEngineWithAttrs = function setupEngineWithAttrs(hooks) { + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Application{{mount "chat-engine"}}')); + + this.registerEngine('chat-engine', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:components/foo-bar', _emberGlimmerTestsUtilsHelpers.compile('{{partial "troll"}}')); + this.register('template:troll', _emberGlimmerTestsUtilsHelpers.compile('{{attrs.wat}}')); + this.register('controller:application', _emberRuntime.Controller.extend({ + contextType: 'Engine' + })); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine {{foo-bar wat=contextType}}')); + } + })); + }; + + _class.prototype.stringsEndWith = function stringsEndWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + }; + + _class.prototype['@test attrs in an engine'] = function testAttrsInAnEngine() { + var _this = this; + + this.setupEngineWithAttrs([]); + + return this.visit('/').then(function () { + _this.assertText('ApplicationEngine Engine'); + }); + }; + + _class.prototype['@test sharing a template between engine and application has separate refinements'] = function testSharingATemplateBetweenEngineAndApplicationHasSeparateRefinements() { + var _this2 = this; + + this.assert.expect(1); + + var sharedTemplate = _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.application.register('template:application', sharedTemplate); + this.registerController('application', _emberRuntime.Controller.extend({ + contextType: 'Application', + 'ambiguous-curlies': 'Controller Data!' + })); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () {}); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + + this.register('controller:application', _emberRuntime.Controller.extend({ + contextType: 'Engine' + })); + this.register('template:application', sharedTemplate); + this.register('template:components/ambiguous-curlies', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2))); + } + })); + + return this.visit('/blog').then(function () { + _this2.assertText('ApplicationController Data!EngineComponent!'); + }); + }; + + _class.prototype['@test sharing a layout between engine and application has separate refinements'] = function testSharingALayoutBetweenEngineAndApplicationHasSeparateRefinements() { + var _this3 = this; + + this.assert.expect(1); + + var sharedLayout = _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + var sharedComponent = _emberGlimmer.Component.extend({ + layout: sharedLayout + }); + + this.application.register('template:application', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4))); + + this.application.register('component:my-component', sharedComponent); + + this.router.map(function () { + this.mount('blog'); + }); + this.application.register('route-map:blog', function () {}); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5))); + this.register('component:my-component', sharedComponent); + this.register('template:components/ambiguous-curlies', _emberGlimmerTestsUtilsHelpers.compile(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6))); + } + })); + + return this.visit('/blog').then(function () { + _this3.assertText('ApplicationLocal Data!EngineComponent!'); + }); + }; + + _class.prototype['@test visit() with `shouldRender: true` returns a promise that resolves when application and engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndEngineTemplatesHaveRendered(assert) { + var _this4 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutableEngine(hooks); + + return this.visit('/blog', { shouldRender: true }).then(function () { + _this4.assertText('ApplicationEngine'); + + _this4.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired'); + }); + }; + + _class.prototype['@test visit() with `shouldRender: false` returns a promise that resolves without rendering'] = function testVisitWithShouldRenderFalseReturnsAPromiseThatResolvesWithoutRendering(assert) { + var _this5 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutableEngine(hooks); + + return this.visit('/blog', { shouldRender: false }).then(function () { + _this5.assertText(''); + + _this5.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired'); + }); + }; + + _class.prototype['@test visit() with `shouldRender: true` returns a promise that resolves when application and routeless engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndRoutelessEngineTemplatesHaveRendered(assert) { + var _this6 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutelessEngine(hooks); + + return this.visit('/', { shouldRender: true }).then(function () { + _this6.assertText('ApplicationEngine'); + + _this6.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); + }); + }; + + _class.prototype['@test visit() with partials in routable engine'] = function testVisitWithPartialsInRoutableEngine(assert) { + var _this7 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutableEngineWithPartial(hooks); + + return this.visit('/blog', { shouldRender: true }).then(function () { + _this7.assertText('ApplicationEngine foo partial'); + + _this7.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); + }); + }; + + _class.prototype['@test visit() with partials in non-routable engine'] = function testVisitWithPartialsInNonRoutableEngine(assert) { + var _this8 = this; + + assert.expect(2); + + var hooks = []; + + this.setupAppAndRoutlessEngineWithPartial(hooks); + + return this.visit('/', { shouldRender: true }).then(function () { + _this8.assertText('ApplicationEngine foo partial'); + + _this8.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); + }); + }; + + _class.prototype['@test deactivate should be called on Engine Routes before destruction'] = function testDeactivateShouldBeCalledOnEngineRoutesBeforeDestruction(assert) { + var _this9 = this; + + assert.expect(3); + + this.setupAppAndRoutableEngine(); + + this.registerEngine('blog', _emberApplication.Engine.extend({ + init: function () { + this._super.apply(this, arguments); + this.register('template:application', _emberGlimmerTestsUtilsHelpers.compile('Engine{{outlet}}')); + this.register('route:application', _emberRouting.Route.extend({ + deactivate: function () { + assert.notOk(this.isDestroyed, 'Route is not destroyed'); + assert.notOk(this.isDestroying, 'Route is not being destroyed'); + } + })); + } + })); + + return this.visit('/blog').then(function () { + _this9.assertText('ApplicationEngine'); + }); + }; + + _class.prototype['@test engine should lookup and use correct controller'] = function testEngineShouldLookupAndUseCorrectController(assert) { + var _this10 = this; + + this.setupAppAndRoutableEngine(); + + return this.visit('/blog?lang=English').then(function () { + _this10.assertText('ApplicationEngineEnglish'); + }); + }; + + _class.prototype['@test error substate route works for the application route of an Engine'] = function testErrorSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this11 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:application_error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this11.assertText('Application'); + return _this11.transitionTo('blog.post'); + }).catch(function () { + _this11.assertText('ApplicationError! Oh, noes!'); + }); + }; + + _class.prototype['@test error route works for the application route of an Engine'] = function testErrorRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this12 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this12.assertText('Application'); + return _this12.transitionTo('blog.post'); + }).catch(function () { + _this12.assertText('ApplicationEngineError! Oh, noes!'); + }); + }; + + _class.prototype['@test error substate route works for a child route of an Engine'] = function testErrorSubstateRouteWorksForAChildRouteOfAnEngine(assert) { + var _this13 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:post_error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this13.assertText('Application'); + return _this13.transitionTo('blog.post'); + }).catch(function () { + _this13.assertText('ApplicationEngineError! Oh, noes!'); + }); + }; + + _class.prototype['@test error route works for a child route of an Engine'] = function testErrorRouteWorksForAChildRouteOfAnEngine(assert) { + var _this14 = this; + + assert.expect(2); + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:post.error', _emberGlimmerTestsUtilsHelpers.compile('Error! {{model.message}}')); + this.register('route:post.comments', _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(new Error('Oh, noes!')); + } + })); + }); + + return this.visit('/').then(function () { + _this14.assertText('Application'); + return _this14.transitionTo('blog.post.comments'); + }).catch(function () { + _this14.assertText('ApplicationEngineError! Oh, noes!'); + }); + }; + + _class.prototype['@test loading substate route works for the application route of an Engine'] = function testLoadingSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this15 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:application_loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('Post')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/').then(function () { + _this15.assertText('Application'); + var transition = _this15.transitionTo('blog.post'); + + _this15.runTaskNext(function () { + _this15.assertText('ApplicationLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this15.runTaskNext(function () { + return _this15.assertText('ApplicationEnginePost'); + }); + }); + }); + }; + + _class.prototype['@test loading route works for the application route of an Engine'] = function testLoadingRouteWorksForTheApplicationRouteOfAnEngine(assert) { + var _this16 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('Post')); + this.register('route:post', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/').then(function () { + _this16.assertText('Application'); + var transition = _this16.transitionTo('blog.post'); + + _this16.runTaskNext(function () { + _this16.assertText('ApplicationEngineLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this16.runTaskNext(function () { + return _this16.assertText('ApplicationEnginePost'); + }); + }); + }); + }; + + _class.prototype['@test loading substate route works for a child route of an Engine'] = function testLoadingSubstateRouteWorksForAChildRouteOfAnEngine(assert) { + var _this17 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.application.__registry__.resolver.moduleBasedResolver = true; + this.additionalEngineRegistrations(function () { + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('{{outlet}}')); + this.register('template:post.comments', _emberGlimmerTestsUtilsHelpers.compile('Comments')); + this.register('template:post.likes_loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post.likes', _emberGlimmerTestsUtilsHelpers.compile('Likes')); + this.register('route:post.likes', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/blog/post/comments').then(function () { + _this17.assertText('ApplicationEngineComments'); + var transition = _this17.transitionTo('blog.post.likes'); + + _this17.runTaskNext(function () { + _this17.assertText('ApplicationEngineLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this17.runTaskNext(function () { + return _this17.assertText('ApplicationEngineLikes'); + }); + }); + }); + }; + + _class.prototype['@test loading route works for a child route of an Engine'] = function testLoadingRouteWorksForAChildRouteOfAnEngine(assert) { + var _this18 = this; + + assert.expect(3); + + var resolveLoading = undefined; + + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:post', _emberGlimmerTestsUtilsHelpers.compile('{{outlet}}')); + this.register('template:post.comments', _emberGlimmerTestsUtilsHelpers.compile('Comments')); + this.register('template:post.loading', _emberGlimmerTestsUtilsHelpers.compile('Loading')); + this.register('template:post.likes', _emberGlimmerTestsUtilsHelpers.compile('Likes')); + this.register('route:post.likes', _emberRouting.Route.extend({ + model: function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + resolveLoading = resolve; + }); + } + })); + }); + + return this.visit('/blog/post/comments').then(function () { + _this18.assertText('ApplicationEngineComments'); + var transition = _this18.transitionTo('blog.post.likes'); + + _this18.runTaskNext(function () { + _this18.assertText('ApplicationEngineLoading'); + resolveLoading(); + }); + + return transition.then(function () { + _this18.runTaskNext(function () { + return _this18.assertText('ApplicationEngineLikes'); + }); + }); + }); + }; + + _class.prototype['@test query params don\'t have stickiness by default between model'] = function testQueryParamsDonTHaveStickinessByDefaultBetweenModel(assert) { + var _this19 = this; + + assert.expect(1); + var tmpl = '{{#link-to "blog.category" 1337}}Category 1337{{/link-to}}'; + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:category', _emberGlimmerTestsUtilsHelpers.compile(tmpl)); + }); + + return this.visit('/blog/category/1?type=news').then(function () { + var suffix = '/blog/category/1337'; + var href = _this19.element.querySelector('a').href; + + // check if link ends with the suffix + assert.ok(_this19.stringsEndWith(href, suffix)); + }); + }; + + _class.prototype['@test query params in customized controllerName have stickiness by default between model'] = function testQueryParamsInCustomizedControllerNameHaveStickinessByDefaultBetweenModel(assert) { + var _this20 = this; + + assert.expect(2); + var tmpl = '{{#link-to "blog.author" 1337 class="author-1337"}}Author 1337{{/link-to}}{{#link-to "blog.author" 1 class="author-1"}}Author 1{{/link-to}}'; + this.setupAppAndRoutableEngine(); + this.additionalEngineRegistrations(function () { + this.register('template:author', _emberGlimmerTestsUtilsHelpers.compile(tmpl)); + }); + + return this.visit('/blog/author/1?official=true').then(function () { + var suffix1 = '/blog/author/1?official=true'; + var href1 = _this20.element.querySelector('.author-1').href; + var suffix1337 = '/blog/author/1337'; + var href1337 = _this20.element.querySelector('.author-1337').href; + + // check if link ends with the suffix + assert.ok(_this20.stringsEndWith(href1, suffix1)); + assert.ok(_this20.stringsEndWith(href1337, suffix1337)); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/application/engine-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/application/engine-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/application/engine-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/application/rendering-test', ['exports', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-routing', 'ember-metal', 'ember-glimmer'], function (exports, _emberRuntime, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberRouting, _emberMetal, _emberGlimmer) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n {{#each model as |item|}}\n
    • {{item}}
    • \n {{/each}}\n
    \n '], ['\n
      \n {{#each model as |item|}}\n
    • {{item}}
    • \n {{/each}}\n
    \n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • red
    • \n
    • yellow
    • \n
    • blue
    • \n
    \n '], ['\n
      \n
    • red
    • \n
    • yellow
    • \n
    • blue
    • \n
    \n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n \n
    {{outlet}}
    \n '], ['\n \n
    {{outlet}}
    \n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n Ember\n '], ['\n Ember\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n \n
    \n
      \n
    • red
    • \n
    • yellow
    • \n
    • blue
    • \n
    \n
    \n '], ['\n \n
    \n
      \n
    • red
    • \n
    • yellow
    • \n
    • blue
    • \n
    \n
    \n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Application test: rendering', (function (_ApplicationTest) { +babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + _ApplicationTest.apply(this, arguments); + } + + _class.prototype['@test it can render the application template'] = function testItCanRenderTheApplicationTemplate(assert) { + var _this = this; + + this.registerTemplate('application', 'Hello world!'); + + return this.visit('/').then(function () { + _this.assertText('Hello world!'); + }); + }; + + _class.prototype['@test it can access the model provided by the route'] = function testItCanAccessTheModelProvidedByTheRoute(assert) { + var _this2 = this; + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('application', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/').then(function () { + _this2.assertComponentElement(_this2.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2) + }); + }); + }; + + _class.prototype['@test it can render a nested route'] = function testItCanRenderANestedRoute(assert) { + var _this3 = this; + + this.router.map(function () { + this.route('lists', function () { + this.route('colors', function () { + this.route('favorite'); + }); + }); + }); + + // The "favorite" route will inherit the model + this.registerRoute('lists.colors', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('lists.colors.favorite', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/lists/colors/favorite').then(function () { + _this3.assertComponentElement(_this3.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2) + }); + }); + }; + + _class.prototype['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets(assert) { + var _this4 = this; + + this.router.map(function () { + this.route('colors'); + }); + + this.registerTemplate('application', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.registerTemplate('nav', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.registerRoute('application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('nav', { + into: 'application', + outlet: 'nav' + }); + } + })); + + this.registerRoute('colors', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('colors', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/colors').then(function () { + _this4.assertComponentElement(_this4.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5) + }); + }); + }; + + _class.prototype['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets(assert) { + var _this5 = this; + + this.router.map(function () { + this.route('colors'); + }); + + this.registerTemplate('application', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.registerTemplate('nav', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.registerRoute('application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('nav', { + into: 'application', + outlet: 'nav' + }); + } + })); + + this.registerRoute('colors', _emberRouting.Route.extend({ + model: function () { + return ['red', 'yellow', 'blue']; + } + })); + + this.registerTemplate('colors', _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + return this.visit('/colors').then(function () { + _this5.assertComponentElement(_this5.firstChild, { + content: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5) + }); + }); + }; + + _class.prototype['@test it should update the outlets when switching between routes'] = function testItShouldUpdateTheOutletsWhenSwitchingBetweenRoutes(assert) { + var _this6 = this; + + this.router.map(function () { + this.route('a'); + this.route('b', function () { + this.route('c'); + this.route('d'); + }); + }); + + this.registerTemplate('a', 'A{{outlet}}'); + this.registerTemplate('b', 'B{{outlet}}'); + this.registerTemplate('b.c', 'C'); + this.registerTemplate('b.d', 'D'); + + return this.visit('/b/c').then(function () { + // this.assertComponentElement(this.firstChild, { content: 'BC' }); + _this6.assertText('BC'); + return _this6.visit('/a'); + }).then(function () { + // this.assertComponentElement(this.firstChild, { content: 'A' }); + _this6.assertText('A'); + return _this6.visit('/b/d'); + }).then(function () { + _this6.assertText('BD'); + // this.assertComponentElement(this.firstChild, { content: 'BD' }); + }); + }; + + _class.prototype['@test it should produce a stable DOM when the model changes'] = function testItShouldProduceAStableDOMWhenTheModelChanges(assert) { + var _this7 = this; + + this.router.map(function () { + this.route('color', { path: '/colors/:color' }); + }); + + this.registerRoute('color', _emberRouting.Route.extend({ + model: function (params) { + return params.color; + } + })); + + this.registerTemplate('color', 'color: {{model}}'); + + return this.visit('/colors/red').then(function () { + _this7.assertComponentElement(_this7.firstChild, { content: 'color: red' }); + _this7.takeSnapshot(); + return _this7.visit('/colors/green'); + }).then(function () { + _this7.assertComponentElement(_this7.firstChild, { content: 'color: green' }); + _this7.assertInvariants(); + }); + }; + + _class.prototype['@test it should have the right controller in scope for the route template'] = function testItShouldHaveTheRightControllerInScopeForTheRouteTemplate() { + var _this8 = this; + + this.router.map(function () { + this.route('a'); + this.route('b'); + }); + + this.registerController('a', _emberRuntime.Controller.extend({ + value: 'a' + })); + + this.registerController('b', _emberRuntime.Controller.extend({ + value: 'b' + })); + + this.registerTemplate('a', '{{value}}'); + this.registerTemplate('b', '{{value}}'); + + return this.visit('/a').then(function () { + _this8.assertText('a'); + return _this8.visit('/b'); + }).then(function () { + return _this8.assertText('b'); + }); + }; + + _class.prototype['@test it should update correctly when the controller changes'] = function testItShouldUpdateCorrectlyWhenTheControllerChanges(assert) { + var _this9 = this; + + this.router.map(function () { + this.route('color', { path: '/colors/:color' }); + }); + + this.registerRoute('color', _emberRouting.Route.extend({ + model: function (params) { + return { color: params.color }; + }, + + renderTemplate: function (controller, model) { + this.render({ controller: model.color, model: model }); + } + })); + + this.registerController('red', _emberRuntime.Controller.extend({ + color: 'red' + })); + + this.registerController('green', _emberRuntime.Controller.extend({ + color: 'green' + })); + + this.registerTemplate('color', 'model color: {{model.color}}, controller color: {{color}}'); + + return this.visit('/colors/red').then(function () { + _this9.assertComponentElement(_this9.firstChild, { content: 'model color: red, controller color: red' }); + _this9.takeSnapshot(); + return _this9.visit('/colors/green'); + }).then(function () { + _this9.assertComponentElement(_this9.firstChild, { content: 'model color: green, controller color: green' }); + _this9.assertInvariants(); + }); + }; + + _class.prototype['@test it should produce a stable DOM when two routes render the same template'] = function testItShouldProduceAStableDOMWhenTwoRoutesRenderTheSameTemplate(assert) { + var _this10 = this; + + this.router.map(function () { + this.route('a'); + this.route('b'); + }); + + this.registerRoute('a', _emberRouting.Route.extend({ + model: function () { + return 'A'; + }, + + renderTemplate: function (controller, model) { + this.render('common', { controller: 'common', model: model }); + } + })); + + this.registerRoute('b', _emberRouting.Route.extend({ + model: function () { + return 'B'; + }, + + renderTemplate: function (controller, model) { + this.render('common', { controller: 'common', model: model }); + } + })); + + this.registerController('common', _emberRuntime.Controller.extend({ + prefix: 'common' + })); + + this.registerTemplate('common', '{{prefix}} {{model}}'); + + return this.visit('/a').then(function () { + _this10.assertComponentElement(_this10.firstChild, { content: 'common A' }); + _this10.takeSnapshot(); + return _this10.visit('/b'); + }).then(function () { + _this10.assertComponentElement(_this10.firstChild, { content: 'common B' }); + _this10.assertInvariants(); + }); + }; + + // Regression test, glimmer child outlets tried to assume the first element. + // but the if put-args clobbered the args used by did-create-element. + // I wish there was a way to assert that the OutletComponentManager did not + // receive a didCreateElement. + + _class.prototype['@test a child outlet is always a fragment'] = function testAChildOutletIsAlwaysAFragment() { + var _this11 = this; + + this.registerTemplate('application', '{{outlet}}'); + this.registerTemplate('index', '{{#if true}}1{{/if}}
    2
    '); + return this.visit('/').then(function () { + _this11.assertComponentElement(_this11.firstChild, { content: '1
    2
    ' }); + }); + }; + + _class.prototype['@test it allows a transition during route activate'] = function testItAllowsATransitionDuringRouteActivate(assert) { + var _this12 = this; + + this.router.map(function () { + this.route('a'); + }); + + this.registerRoute('index', _emberRouting.Route.extend({ + activate: function () { + this.transitionTo('a'); + } + })); + + this.registerTemplate('a', 'Hello from A!'); + + return this.visit('/').then(function () { + _this12.assertComponentElement(_this12.firstChild, { + content: 'Hello from A!' + }); + }); + }; + + _class.prototype['@test it emits a useful backtracking re-render assertion message'] = function testItEmitsAUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this13 = this; + + this.router.map(function () { + this.route('routeWithError'); + }); + + this.registerRoute('routeWithError', _emberRouting.Route.extend({ + model: function () { + return { name: 'Alex' }; + } + })); + + this.registerTemplate('routeWithError', 'Hi {{model.name}} {{x-foo person=model}}'); + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmer.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person.name', 'Ben'); + } + }), + template: 'Hi {{person.name}} from component' + }); + + var expectedBacktrackingMessage = /modified "model\.name" twice on \[object Object\] in a single render\. It was rendered in "template:routeWithError" and modified in "component:x-foo"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + return this.visit('/routeWithError'); + } else { + return this.visit('/').then(function () { + expectAssertion(function () { + _this13.visit('/routeWithError'); + }, expectedBacktrackingMessage); + }); + } + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/application/rendering-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/application/rendering-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/application/rendering-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/binding_integration_test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Binding integration tests', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should accept bindings as a string or an Ember.binding'] = function testShouldAcceptBindingsAsAStringOrAnEmberBinding() { + var _this = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + twoWayTestBinding: _emberMetal.Binding.from('direction'), + stringTestBinding: 'direction', + twoWayObjectTestBinding: _emberMetal.Binding.from('displacement.distance'), + stringObjectTestBinding: 'displacement.distance' + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: 'two way: {{twoWayTest}}, string: {{stringTest}}, object: {{twoWayObjectTest}}, string object: {{stringObjectTest}}' + }); + + expectDeprecation(function () { + _this.render('{{foo-bar direction=direction displacement=displacement}}', { + direction: 'down', + displacement: { + distance: 10 + } + }); + }, /`Ember\.Binding` is deprecated/); + + this.assertText('two way: down, string: down, object: 10, string object: 10'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'direction', 'up'); + }); + + this.assertText('two way: up, string: up, object: 10, string object: 10'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'displacement.distance', 20); + }); + + this.assertText('two way: up, string: up, object: 20, string object: 20'); + + this.runTask(function () { + _emberMetal.set(_this.context, 'direction', 'right'); + _emberMetal.set(_this.context, 'displacement.distance', 30); + }); + + this.assertText('two way: right, string: right, object: 30, string object: 30'); + + this.runTask(function () { + _emberMetal.set(_this.context, 'direction', 'down'); + _emberMetal.set(_this.context, 'displacement', { distance: 10 }); + }); + + this.assertText('two way: down, string: down, object: 10, string object: 10'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/binding_integration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/binding_integration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/binding_integration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/append-test', ['exports', 'ember-metal', 'ember-views', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberMetal, _emberViews, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if showFooBar}}\n {{foo-bar}}\n {{else}}\n {{baz-qux}}\n {{/if}}\n '], ['\n {{#if showFooBar}}\n {{foo-bar}}\n {{else}}\n {{baz-qux}}\n {{/if}}\n ']); + + var AbstractAppendTest = (function (_RenderingTest) { +babelHelpers.inherits(AbstractAppendTest, _RenderingTest); + + function AbstractAppendTest() { + _RenderingTest.call(this); + + this.components = []; + this.ids = []; + } + + AbstractAppendTest.prototype.teardown = function teardown() { + var _this = this; + + this.component = null; + + this.components.forEach(function (component) { + _this.runTask(function () { + return component.destroy(); + }); + }); + + this.ids.forEach(function (id) { + var $element = _emberViews.jQuery(id).remove(); + _this.assert.strictEqual($element.length, 0, 'Should not leak element: #' + id); + }); + + _RenderingTest.prototype.teardown.call(this); + }; + + /* abstract append(component): Element; */ + + AbstractAppendTest.prototype.didAppend = function didAppend(component) { + this.components.push(component); + this.ids.push(component.elementId); + }; + + AbstractAppendTest.prototype['@test lifecycle hooks during component append'] = function testLifecycleHooksDuringComponentAppend(assert) { + var _this3 = this; + + var hooks = []; + + var oldRegisterComponent = this.registerComponent; + var componentsByName = {}; + + // TODO: refactor/combine with other life-cycle tests + this.registerComponent = function (name, _options) { + function pushHook(hookName) { + hooks.push([name, hookName]); + } + + var options = { + ComponentClass: _options.ComponentClass.extend({ + init: function () { + var _this2 = this, + _arguments = arguments; + + expectDeprecation(function () { + _this2._super.apply(_this2, _arguments); + }, /didInitAttrs called/); + if (name in componentsByName) { + throw new TypeError('Component named: ` ' + name + ' ` already registered'); + } + componentsByName[name] = this; + pushHook('init'); + this.on('init', function () { + return pushHook('on(init)'); + }); + }, + + didInitAttrs: function (options) { + pushHook('didInitAttrs', options); + }, + + didReceiveAttrs: function () { + pushHook('didReceiveAttrs'); + }, + + willInsertElement: function () { + pushHook('willInsertElement'); + }, + + willRender: function () { + pushHook('willRender'); + }, + + didInsertElement: function () { + pushHook('didInsertElement'); + }, + + didRender: function () { + pushHook('didRender'); + }, + + didUpdateAttrs: function () { + pushHook('didUpdateAttrs'); + }, + + willUpdate: function () { + pushHook('willUpdate'); + }, + + didUpdate: function () { + pushHook('didUpdate'); + }, + + willDestroyElement: function () { + pushHook('willDestroyElement'); + }, + + willClearRender: function () { + pushHook('willClearRender'); + }, + + didDestroyElement: function () { + pushHook('didDestroyElement'); + }, + + willDestroy: function () { + pushHook('willDestroy'); + this._super.apply(this, arguments); + } + }), + template: _options.template + }; + + oldRegisterComponent.call(this, name, options); + }; + + this.registerComponent('x-parent', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-parent' + }), + + template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}' + }); + + this.registerComponent('x-child', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + + template: '[child: {{bar}}]{{yield}}' + }); + + var XParent = undefined; + + if (true) { + XParent = this.owner.factoryFor('component:x-parent'); + } else { + XParent = this.owner._lookupFactory('component:x-parent'); + } + + this.component = XParent.create({ foo: 'zomg' }); + + assert.deepEqual(hooks, [['x-parent', 'init'], ['x-parent', 'didInitAttrs'], ['x-parent', 'didReceiveAttrs'], ['x-parent', 'on(init)']], 'creation of x-parent'); + + hooks.length = 0; + + this.element = this.append(this.component); + + assert.deepEqual(hooks, [['x-parent', 'willInsertElement'], ['x-child', 'init'], ['x-child', 'didInitAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'on(init)'], ['x-child', 'willRender'], ['x-child', 'willInsertElement'], ['x-child', 'didInsertElement'], ['x-child', 'didRender'], ['x-parent', 'didInsertElement'], ['x-parent', 'didRender']], 'appending of x-parent'); + + hooks.length = 0; + + this.runTask(function () { + return componentsByName['x-parent'].rerender(); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'rerender x-parent'); + + hooks.length = 0; + + this.runTask(function () { + return componentsByName['x-child'].rerender(); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'rerender x-child'); + + hooks.length = 0; + + this.runTask(function () { + return _emberMetal.set(_this3.component, 'foo', 'wow'); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'didUpdateAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'set foo = wow'); + + hooks.length = 0; + + this.runTask(function () { + return _emberMetal.set(_this3.component, 'foo', 'zomg'); + }); + + assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'didUpdateAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'set foo = zomg'); + + hooks.length = 0; + + this.runTask(function () { + return _this3.component.destroy(); + }); + + assert.deepEqual(hooks, [['x-parent', 'willDestroyElement'], ['x-parent', 'willClearRender'], ['x-child', 'willDestroyElement'], ['x-child', 'willClearRender'], ['x-child', 'didDestroyElement'], ['x-parent', 'didDestroyElement'], ['x-parent', 'willDestroy'], ['x-child', 'willDestroy']], 'destroy'); + }; + + AbstractAppendTest.prototype['@test appending, updating and destroying a single component'] = function testAppendingUpdatingAndDestroyingASingleComponent(assert) { + var _this4 = this; + + var willDestroyCalled = 0; + + this.registerComponent('x-parent', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-parent', + willDestroyElement: function () { + willDestroyCalled++; + } + }), + + template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}' + }); + + this.registerComponent('x-child', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + + template: '[child: {{bar}}]{{yield}}' + }); + + var XParent = undefined; + + if (true) { + XParent = this.owner.factoryFor('component:x-parent'); + } else { + XParent = this.owner._lookupFactory('component:x-parent'); + } + + this.component = XParent.create({ foo: 'zomg' }); + + assert.ok(!this.component.element, 'precond - should not have an element'); + + this.element = this.append(this.component); + + var componentElement = this.component.element; + + this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(_this4.component, 'foo', 'wow'); + }); + + this.assertComponentElement(componentElement, { content: '[parent: wow][child: wow][yielded: wow]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(_this4.component, 'foo', 'zomg'); + }); + + this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' }); + + assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); + + this.runTask(function () { + return _this4.component.destroy(); + }); + + if (this.isHTMLBars) { + // Bug in Glimmer – component should not have .element at this point + assert.ok(!this.component.element, 'It should not have an element'); + } + + assert.ok(!componentElement.parentElement, 'The component element should be detached'); + + this.assert.equal(willDestroyCalled, 1); + }; + + AbstractAppendTest.prototype['@test appending, updating and destroying multiple components'] = function testAppendingUpdatingAndDestroyingMultipleComponents(assert) { + var _this5 = this; + + var willDestroyCalled = 0; + + this.registerComponent('x-first', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-first', + + willDestroyElement: function () { + willDestroyCalled++; + } + }), + + template: 'x-first {{foo}}!' + }); + + this.registerComponent('x-second', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/x-second', + + willDestroyElement: function () { + willDestroyCalled++; + } + }), + + template: 'x-second {{bar}}!' + }); + + var First = undefined, + Second = undefined; + + if (true) { + First = this.owner.factoryFor('component:x-first'); + Second = this.owner.factoryFor('component:x-second'); + } else { + First = this.owner._lookupFactory('component:x-first'); + Second = this.owner._lookupFactory('component:x-second'); + } + + var first = First.create({ foo: 'foo' }); + var second = Second.create({ bar: 'bar' }); + + this.assert.ok(!first.element, 'precond - should not have an element'); + this.assert.ok(!second.element, 'precond - should not have an element'); + + var wrapper1 = undefined, + wrapper2 = undefined; + + this.runTask(function () { + return wrapper1 = _this5.append(first); + }); + this.runTask(function () { + return wrapper2 = _this5.append(second); + }); + + var componentElement1 = first.element; + var componentElement2 = second.element; + + this.assertComponentElement(componentElement1, { content: 'x-first foo!' }); + this.assertComponentElement(componentElement2, { content: 'x-second bar!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(first, 'foo', 'FOO'); + }); + + this.assertComponentElement(componentElement1, { content: 'x-first FOO!' }); + this.assertComponentElement(componentElement2, { content: 'x-second bar!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + return _emberMetal.set(second, 'bar', 'BAR'); + }); + + this.assertComponentElement(componentElement1, { content: 'x-first FOO!' }); + this.assertComponentElement(componentElement2, { content: 'x-second BAR!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + _emberMetal.set(first, 'foo', 'foo'); + _emberMetal.set(second, 'bar', 'bar'); + }); + + this.assertComponentElement(componentElement1, { content: 'x-first foo!' }); + this.assertComponentElement(componentElement2, { content: 'x-second bar!' }); + + assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target'); + assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target'); + + this.runTask(function () { + first.destroy(); + second.destroy(); + }); + + if (this.isHTMLBars) { + // Bug in Glimmer – component should not have .element at this point + assert.ok(!first.element, 'The first component should not have an element'); + assert.ok(!second.element, 'The second component should not have an element'); + } + + assert.ok(!componentElement1.parentElement, 'The first component element should be detached'); + assert.ok(!componentElement2.parentElement, 'The second component element should be detached'); + + this.assert.equal(willDestroyCalled, 2); + }; + + AbstractAppendTest.prototype['@test can appendTo while rendering'] = function testCanAppendToWhileRendering(assert) { + var _this6 = this; + + var owner = this.owner; + + var append = function (component) { + return _this6.append(component); + }; + + var element1 = undefined, + element2 = undefined; + this.registerComponent('first-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('component-one'), + + didInsertElement: function () { + element1 = this.element; + + var SecondComponent = undefined; + if (true) { + SecondComponent = owner.factoryFor('component:second-component'); + } else { + SecondComponent = owner._lookupFactory('component:second-component'); + } + + append(SecondComponent.create()); + } + }) + }); + + this.registerComponent('second-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('component-two'), + + didInsertElement: function () { + element2 = this.element; + } + }) + }); + + var FirstComponent = undefined; + + if (true) { + FirstComponent = this.owner.factoryFor('component:first-component'); + } else { + FirstComponent = this.owner._lookupFactory('component:first-component'); + } + + this.runTask(function () { + return append(FirstComponent.create()); + }); + + this.assertComponentElement(element1, { content: 'component-one' }); + this.assertComponentElement(element2, { content: 'component-two' }); + }; + + AbstractAppendTest.prototype['@test can appendTo and remove while rendering'] = function testCanAppendToAndRemoveWhileRendering(assert) { + var _this7 = this; + + var owner = this.owner; + + var append = function (component) { + return _this7.append(component); + }; + + var element1 = undefined, + element2 = undefined, + element3 = undefined, + element4 = undefined, + component1 = undefined, + component2 = undefined; + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('foo-bar'), + + init: function () { + this._super.apply(this, arguments); + component1 = this; + }, + + didInsertElement: function () { + element1 = this.element; + var OtherRoot = undefined; + + if (true) { + OtherRoot = owner.factoryFor('component:other-root'); + } else { + OtherRoot = owner._lookupFactory('component:other-root'); + } + + this._instance = OtherRoot.create({ + didInsertElement: function () { + element2 = this.element; + } + }); + + append(this._instance); + }, + + willDestroy: function () { + this._instance.destroy(); + } + }) + }); + + this.registerComponent('baz-qux', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('baz-qux'), + + init: function () { + this._super.apply(this, arguments); + component2 = this; + }, + + didInsertElement: function () { + element3 = this.element; + var OtherRoot = undefined; + + if (true) { + OtherRoot = owner.factoryFor('component:other-root'); + } else { + OtherRoot = owner._lookupFactory('component:other-root'); + } + + this._instance = OtherRoot.create({ + didInsertElement: function () { + element4 = this.element; + } + }); + + append(this._instance); + }, + + willDestroy: function () { + this._instance.destroy(); + } + }) + }); + + var instantiatedRoots = 0; + var destroyedRoots = 0; + this.registerComponent('other-root', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: _emberGlimmerTestsUtilsHelpers.compile('fake-thing: {{counter}}'), + init: function () { + this._super.apply(this, arguments); + this.counter = instantiatedRoots++; + }, + willDestroy: function () { + destroyedRoots++; + this._super.apply(this, arguments); + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { showFooBar: true }); + + this.assertComponentElement(element1, {}); + this.assertComponentElement(element2, { content: 'fake-thing: 0' }); + assert.equal(instantiatedRoots, 1); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'showFooBar', false); + }); + + assert.equal(instantiatedRoots, 2); + assert.equal(destroyedRoots, 1); + + this.assertComponentElement(element3, {}); + this.assertComponentElement(element4, { content: 'fake-thing: 1' }); + + this.runTask(function () { + component1.destroy(); + component2.destroy(); + }); + + assert.equal(instantiatedRoots, 2); + assert.equal(destroyedRoots, 2); + }; + + return AbstractAppendTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('append: no arguments (attaching to document.body)', (function (_AbstractAppendTest) { +babelHelpers.inherits(_class, _AbstractAppendTest); + + function _class() { + _AbstractAppendTest.apply(this, arguments); + } + + _class.prototype.append = function append(component) { + this.runTask(function () { + return component.append(); + }); + this.didAppend(component); + return document.body; + }; + + return _class; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('appendTo: a selector', (function (_AbstractAppendTest2) { +babelHelpers.inherits(_class2, _AbstractAppendTest2); + + function _class2() { + _AbstractAppendTest2.apply(this, arguments); + } + + _class2.prototype.append = function append(component) { + this.runTask(function () { + return component.appendTo('#qunit-fixture'); + }); + this.didAppend(component); + return _emberViews.jQuery('#qunit-fixture')[0]; + }; + + _class2.prototype['@test raises an assertion when the target does not exist in the DOM'] = function testRaisesAnAssertionWhenTheTargetDoesNotExistInTheDOM(assert) { + var _this8 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layoutName: 'components/foo-bar' + }), + template: 'FOO BAR!' + }); + + var FooBar = undefined; + + if (true) { + FooBar = this.owner.factoryFor('component:foo-bar'); + } else { + FooBar = this.owner._lookupFactory('component:foo-bar'); + } + + this.component = FooBar.create(); + + assert.ok(!this.component.element, 'precond - should not have an element'); + + this.runTask(function () { + expectAssertion(function () { + _this8.component.appendTo('#does-not-exist-in-dom'); + }, /You tried to append to \(#does-not-exist-in-dom\) but that isn't in the DOM/); + }); + + assert.ok(!this.component.element, 'component should not have an element'); + }; + + return _class2; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('appendTo: an element', (function (_AbstractAppendTest3) { +babelHelpers.inherits(_class3, _AbstractAppendTest3); + + function _class3() { + _AbstractAppendTest3.apply(this, arguments); + } + + _class3.prototype.append = function append(component) { + var element = _emberViews.jQuery('#qunit-fixture')[0]; + this.runTask(function () { + return component.appendTo(element); + }); + this.didAppend(component); + return element; + }; + + return _class3; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('appendTo: with multiple components', (function (_AbstractAppendTest4) { +babelHelpers.inherits(_class4, _AbstractAppendTest4); + + function _class4() { + _AbstractAppendTest4.apply(this, arguments); + } + + _class4.prototype.append = function append(component) { + this.runTask(function () { + return component.appendTo('#qunit-fixture'); + }); + this.didAppend(component); + return _emberViews.jQuery('#qunit-fixture')[0]; + }; + + return _class4; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('renderToElement: no arguments (defaults to a body context)', (function (_AbstractAppendTest5) { +babelHelpers.inherits(_class5, _AbstractAppendTest5); + + function _class5() { + _AbstractAppendTest5.apply(this, arguments); + } + + _class5.prototype.append = function append(component) { + expectDeprecation(/Using the `renderToElement` is deprecated in favor of `appendTo`. Called in/); + var wrapper = undefined; + + this.runTask(function () { + return wrapper = component.renderToElement(); + }); + this.didAppend(component); + + this.assert.equal(wrapper.tagName, 'BODY', 'wrapper is a body element'); + this.assert.notEqual(wrapper, document.body, 'wrapper is not document.body'); + this.assert.ok(!wrapper.parentNode, 'wrapper is detached'); + + return wrapper; + }; + + return _class5; + })(AbstractAppendTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('renderToElement: a div', (function (_AbstractAppendTest6) { +babelHelpers.inherits(_class6, _AbstractAppendTest6); + + function _class6() { + _AbstractAppendTest6.apply(this, arguments); + } + + _class6.prototype.append = function append(component) { + expectDeprecation(/Using the `renderToElement` is deprecated in favor of `appendTo`. Called in/); + var wrapper = undefined; + + this.runTask(function () { + return wrapper = component.renderToElement('div'); + }); + this.didAppend(component); + + this.assert.equal(wrapper.tagName, 'DIV', 'wrapper is a body element'); + this.assert.ok(!wrapper.parentNode, 'wrapper is detached'); + + return wrapper; + }; + + return _class6; + })(AbstractAppendTest)); +}); +enifed('ember-glimmer/tests/integration/components/append-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/append-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/append-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/attribute-bindings-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{foo-bar hasFoo=true foo=foo hasBar=false bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=true foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=false bar=bar}}\n '], ['\n {{foo-bar hasFoo=true foo=foo hasBar=false bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=true foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=false bar=bar}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Attribute bindings integration', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can have attribute bindings'] = function testItCanHaveAttributeBindings() { + var _this = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo:data-foo', 'bar:data-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'FOO'); + _emberMetal.set(_this.context, 'bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'foo'); + _emberMetal.set(_this.context, 'bar', 'bar'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + }; + + _class.prototype['@test it can have attribute bindings with attrs'] = function testItCanHaveAttributeBindingsWithAttrs() { + var _this2 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['attrs.foo:data-foo', 'attrs.baz.bar:data-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=model.foo baz=model.baz}}', { + model: { foo: undefined, baz: { bar: 'bar' } } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model.foo', 'foo'); + _emberMetal.set(_this2.context, 'model.baz.bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { + foo: undefined, baz: { bar: 'bar' } + }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); + }; + + _class.prototype['@test it can have attribute bindings with a nested path'] = function testItCanHaveAttributeBindingsWithANestedPath() { + var _this3 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo.bar:data-foo-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo.bar', 'FOO-BAR'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'FOO-BAR' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo.bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'foo', { bar: 'foo-bar' }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); + }; + + _class.prototype['@test handles non-microsyntax attributeBindings'] = function testHandlesNonMicrosyntaxAttributeBindings() { + var _this4 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['type'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar type=submit}}', { + submit: 'submit' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'submit', 'password'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'submit', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'submit', 'submit'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); + }; + + _class.prototype['@test non-microsyntax attributeBindings cannot contain nested paths'] = function testNonMicrosyntaxAttributeBindingsCannotContainNestedPaths() { + var _this5 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo.bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this5.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } }); + }, /Illegal attributeBinding: 'foo.bar' is not a valid attribute name./); + }; + + _class.prototype['@test normalizes attributeBindings for property names'] = function testNormalizesAttributeBindingsForPropertyNames() { + var _this6 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['tiTLe'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar tiTLe=name}}', { + name: 'qux' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, content: 'hello' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'name', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'name', 'qux'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, content: 'hello' }); + }; + + _class.prototype['@test normalizes attributeBindings for attribute names'] = function testNormalizesAttributeBindingsForAttributeNames() { + var _this7 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo:data-FOO'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo}}', { + foo: 'qux' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, content: 'hello' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', 'qux'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, content: 'hello' }); + }; + + _class.prototype['@test attributeBindings handles null/undefined'] = function testAttributeBindingsHandlesNullUndefined() { + var _this8 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['fizz', 'bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar fizz=fizz bar=bar}}', { + fizz: null, + bar: undefined + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'fizz', 'fizz'); + _emberMetal.set(_this8.context, 'bar', 'bar'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { fizz: 'fizz', bar: 'bar' }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'fizz', null); + _emberMetal.set(_this8.context, 'bar', undefined); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); + }; + + _class.prototype['@test attributeBindings handles number value'] = function testAttributeBindingsHandlesNumberValue() { + var _this9 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['size'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar size=size}}', { + size: 21 + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'size', 0); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '0' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'size', 21); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); + }; + + _class.prototype['@test handles internal and external changes'] = function testHandlesInternalAndExternalChanges() { + var _this10 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['type'], + type: 'password', + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(component, 'type', 'checkbox'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'checkbox' }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(component, 'type', 'password'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); + }; + + _class.prototype['@test can set attributeBindings on component with a different tagName'] = function testCanSetAttributeBindingsOnComponentWithADifferentTagName() { + var _this11 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'input', + attributeBindings: ['type', 'isDisabled:disabled'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar type=type isDisabled=disabled}}', { + type: 'password', + disabled: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'type', 'checkbox'); + _emberMetal.set(_this11.context, 'disabled', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'checkbox', disabled: '' } }); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'type', 'password'); + _emberMetal.set(_this11.context, 'disabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); + }; + + _class.prototype['@test should allow namespaced attributes in micro syntax'] = function testShouldAllowNamespacedAttributesInMicroSyntax() { + var _this12 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['xlinkHref:xlink:href'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar type=type xlinkHref=xlinkHref}}', { + xlinkHref: '/foo.png' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'xlinkHref', '/lol.png'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/lol.png' } }); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'xlinkHref', '/foo.png'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); + }; + + // This comes into play when using the {{#each}} helper. If the + // passed array item is a String, it will be converted into a + // String object instead of a normal string. + + _class.prototype['@test should allow for String objects'] = function testShouldAllowForStringObjects() { + var _this13 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar foo=foo}}', { + foo: (function () { + return this; + }).call('bar') + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } }); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'foo', (function () { + return this; + }).call('baz')); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'baz' } }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'foo', (function () { + return this; + }).call('bar')); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } }); + }; + + _class.prototype['@test can set id initially via attributeBindings '] = function testCanSetIdInitiallyViaAttributeBindings() { + var _this14 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['specialSauce:id'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar specialSauce=sauce}}', { + sauce: 'special-sauce' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'sauce', 'foo'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'sauce', 'special-sauce'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } }); + }; + + _class.prototype['@test attributeBindings are overwritten'] = function testAttributeBindingsAreOverwritten() { + var _this15 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['href'], + href: 'a href' + }); + + var FizzBarComponent = FooBarComponent.extend({ + attributeBindings: ['newHref:href'] + }); + + this.registerComponent('fizz-bar', { ComponentClass: FizzBarComponent }); + + this.render('{{fizz-bar newHref=href}}', { + href: 'dog.html' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'dog.html' } }); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'dog.html' } }); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'href', 'cat.html'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'cat.html' } }); + }; + + _class.prototype['@test it can set attribute bindings in the constructor'] = function testItCanSetAttributeBindingsInTheConstructor() { + var _this16 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + + var bindings = []; + + if (this.get('hasFoo')) { + bindings.push('foo:data-foo'); + } + + if (this.get('hasBar')) { + bindings.push('bar:data-bar'); + } + + this.attributeBindings = bindings; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { foo: 'foo', bar: 'bar' }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'foo', 'FOO'); + _emberMetal.set(_this16.context, 'bar', undefined); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: {}, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'bar', 'BAR'); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'BAR' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO', 'data-bar': 'BAR' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'foo', 'foo'); + _emberMetal.set(_this16.context, 'bar', 'bar'); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' }); + }; + + _class.prototype['@test it should not allow attributeBindings to be set'] = function testItShouldNotAllowAttributeBindingsToBeSet() { + var _this17 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + expectAssertion(function () { + _this17.render('{{foo-bar attributeBindings="one two"}}'); + }, /Setting 'attributeBindings' via template helpers is not allowed/); + }; + + _class.prototype['@test asserts if an attributeBinding is setup on class'] = function testAssertsIfAnAttributeBindingIsSetupOnClass() { + var _this18 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['class'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this18.render('{{foo-bar}}'); + }, /You cannot use class as an attributeBinding, use classNameBindings instead./i); + }; + + _class.prototype['@test blacklists href bindings based on protocol'] = function testBlacklistsHrefBindingsBasedOnProtocol() { + /* jshint scripturl:true */ + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'a', + attributeBindings: ['href'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar href=xss}}', { + xss: 'javascript:alert(\'foo\')' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'a', attrs: { href: 'unsafe:javascript:alert(\'foo\')' } }); + }; + + _class.prototype['@test it can bind the role attribute (issue #14007)'] = function testItCanBindTheRoleAttributeIssue14007() { + var _this19 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ attributeBindings: ['role'] }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar role=role}}', { role: 'button' }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } }); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } }); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'role', 'combobox'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'combobox' } }); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'role', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div' }); + }; + + _class.prototype['@test component with an `id` attribute binding of undefined'] = function testComponentWithAnIdAttributeBindingOfUndefined() { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['id'], + + id: undefined + }) + }); + + this.registerComponent('baz-qux', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['somethingUndefined:id'], + + somethingUndefined: undefined + }) + }); + this.render('{{foo-bar}}{{baz-qux}}'); + + this.assertComponentElement(this.nthChild(0), { content: '' }); + this.assertComponentElement(this.nthChild(1), { content: '' }); + + this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used'); + this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used'); + }; + + _class.prototype['@test component with an `id` attribute binding of null'] = function testComponentWithAnIdAttributeBindingOfNull() { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['id'], + + id: null + }) + }); + + this.registerComponent('baz-qux', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['somethingNull:id'], + + somethingNull: null + }) + }); + this.render('{{foo-bar}}{{baz-qux}}'); + + this.assertComponentElement(this.nthChild(0), { content: '' }); + this.assertComponentElement(this.nthChild(1), { content: '' }); + + this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used'); + this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/attribute-bindings-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/attribute-bindings-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/attribute-bindings-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/attrs-lookup-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal, _emberGlimmerTestsUtilsTestHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: attrs lookup', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it should be able to lookup attrs without `attrs.` - template access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsTemplateAccess() { + var _this = this; + + this.registerComponent('foo-bar', { template: '{{first}}' }); + + this.render('{{foo-bar first=firstAttr}}', { + firstAttr: 'first attr' + }); + + this.assertText('first attr'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('first attr'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'firstAttr', 'second attr'); + }); + + this.assertText('second attr'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'firstAttr', 'first attr'); + }); + + this.assertText('first attr'); + }; + + _class.prototype['@test it should be able to lookup attrs without `attrs.` - component access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsComponentAccess(assert) { + var _this2 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{first}}' }); + + this.render('{{foo-bar first=firstAttr}}', { + firstAttr: 'first attr' + }); + + assert.equal(instance.get('first'), 'first attr'); + + this.runTask(function () { + return _this2.rerender(); + }); + + assert.equal(instance.get('first'), 'first attr'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'firstAttr', 'second attr'); + }); + + assert.equal(instance.get('first'), 'second attr'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'firstAttr', 'first attr'); + }); + + this.assertText('first attr'); + }; + + _class.prototype['@test should be able to modify a provided attr into local state #11571 / #11559'] = function testShouldBeAbleToModifyAProvidedAttrIntoLocalState1157111559(assert) { + var _this3 = this; + + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + didReceiveAttrs: function () { + this.set('first', this.get('first').toUpperCase()); + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{first}}' }); + + this.render('{{foo-bar first="first attr"}}'); + + assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state'); + this.assertText('FIRST ATTR'); + + this.runTask(function () { + return _this3.rerender(); + }); + + assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state during rerender'); + this.assertText('FIRST ATTR'); + + // This is testing that passing string literals for use as initial values, + // so there is no update step + }; + + _class.prototype['@test should be able to access unspecified attr #12035'] = function testShouldBeAbleToAccessUnspecifiedAttr12035(assert) { + var _this4 = this; + + var instance = undefined; + var wootVal = 'yes'; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + didReceiveAttrs: function () { + assert.equal(this.get('woot'), wootVal, 'found attr in didReceiveAttrs'); + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar woot=woot}}', { + woot: wootVal + }); + + assert.equal(instance.get('woot'), 'yes', 'component found attr'); + + this.runTask(function () { + return _this4.rerender(); + }); + + assert.equal(instance.get('woot'), 'yes', 'component found attr after rerender'); + + this.runTask(function () { + wootVal = 'nope'; + _emberMetal.set(_this4.context, 'woot', wootVal); + }); + + assert.equal(instance.get('woot'), 'nope', 'component found attr after attr change'); + + this.runTask(function () { + wootVal = 'yes'; + _emberMetal.set(_this4.context, 'woot', wootVal); + }); + + assert.equal(instance.get('woot'), 'yes', 'component found attr after reset'); + }; + + _class.prototype['@test getAttr() should return the same value as get()'] = function testGetAttrShouldReturnTheSameValueAsGet(assert) { + var _this5 = this; + + assert.expect(33); + + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + didReceiveAttrs: function () { + var rootFirstPositional = this.get('firstPositional'); + var rootFirst = this.get('first'); + var rootSecond = this.get('second'); + var attrFirstPositional = this.getAttr('firstPositional'); + var attrFirst = this.getAttr('first'); + var attrSecond = this.getAttr('second'); + + equal(rootFirstPositional, attrFirstPositional, 'root property matches attrs value'); + equal(rootFirst, attrFirst, 'root property matches attrs value'); + equal(rootSecond, attrSecond, 'root property matches attrs value'); + } + }); + + FooBarComponent.reopenClass({ + positionalParams: ['firstPositional'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar firstPositional first=first second=second}}', { + firstPositional: 'firstPositional', + first: 'first', + second: 'second' + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'first', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + + this.runTask(function () { + return _this5.rerender(); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'first', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'first', 'third'); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'third', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'second', 'fourth'); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'third', 'matches known value'); + assert.equal(instance.get('second'), 'fourth', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'firstPositional', 'fifth'); + }); + + assert.equal(instance.get('firstPositional'), 'fifth', 'matches known value'); + assert.equal(instance.get('first'), 'third', 'matches known value'); + assert.equal(instance.get('second'), 'fourth', 'matches known value'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'firstPositional', 'firstPositional'); + _emberMetal.set(_this5.context, 'first', 'first'); + _emberMetal.set(_this5.context, 'second', 'second'); + }); + + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); + assert.equal(instance.get('first'), 'first', 'matches known value'); + assert.equal(instance.get('second'), 'second', 'matches known value'); + }; + + _class.prototype['@test bound computed properties can be overriden in extensions, set during init, and passed in as attrs'] = function testBoundComputedPropertiesCanBeOverridenInExtensionsSetDuringInitAndPassedInAsAttrs() { + var FooClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + style: _emberMetal.computed('height', 'color', function () { + var height = this.get('height'); + var color = this.get('color'); + return 'height: ' + height + 'px; background-color: ' + color + ';'; + }), + color: 'red', + height: 20 + }); + + var BarClass = FooClass.extend({ + init: function () { + this._super.apply(this, arguments); + this.height = 150; + }, + color: 'yellow' + }); + + this.registerComponent('x-foo', { ComponentClass: FooClass }); + this.registerComponent('x-bar', { ComponentClass: BarClass }); + + this.render('{{x-foo}}{{x-bar}}{{x-bar color="green"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 20px; background-color: red;') } }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 150px; background-color: yellow;') } }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 150px; background-color: green;') } }); + + this.assertStableRerender(); + + // No U-R + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/attrs-lookup-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/attrs-lookup-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/attrs-lookup-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/class-bindings-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-helpers', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestHelpers, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n '], ['\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('ClassNameBindings integration', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can have class name bindings on the class definition'] = function testItCanHaveClassNameBindingsOnTheClassDefinition() { + var _this = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['foo', 'isEnabled:enabled', 'isHappy:happy:sad'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo isEnabled=isEnabled isHappy=isHappy}}', { foo: 'foo', isEnabled: true, isHappy: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'FOO'); + _emberMetal.set(_this.context, 'isEnabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', undefined); + _emberMetal.set(_this.context, 'isHappy', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this.context, 'foo', 'foo'); + _emberMetal.set(_this.context, 'isEnabled', true); + _emberMetal.set(_this.context, 'isHappy', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + }; + + _class.prototype['@test attrs in classNameBindings'] = function testAttrsInClassNameBindings() { + var _this2 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['attrs.joker:purple:green', 'attrs.batman.robin:black:red'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar joker=model.wat batman=model.super}}', { + model: { wat: false, super: { robin: true } } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view green black') }, content: 'hello' }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view green black') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model.wat', true); + _emberMetal.set(_this2.context, 'model.super.robin', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view purple red') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { + wat: false, super: { robin: true } + }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view green black') }, content: 'hello' }); + }; + + _class.prototype['@test it can have class name bindings in the template'] = function testItCanHaveClassNameBindingsInTheTemplate() { + var _this3 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classNameBindings="model.someInitiallyTrueProperty model.someInitiallyFalseProperty model.someInitiallyUndefinedProperty :static model.isBig:big model.isOpen:open:closed model.isUp::down model.bar:isTruthy:isFalsy"}}', { + model: { + someInitiallyTrueProperty: true, + someInitiallyFalseProperty: false, + isBig: true, + isOpen: false, + isUp: true, + bar: true + } + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-true-property static big closed isTruthy') }, + content: 'hello' + }); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-true-property static big closed isTruthy') }, + content: 'hello' + }); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'model.someInitiallyTrueProperty', false); + _emberMetal.set(_this3.context, 'model.someInitiallyFalseProperty', true); + _emberMetal.set(_this3.context, 'model.someInitiallyUndefinedProperty', true); + _emberMetal.set(_this3.context, 'model.isBig', false); + _emberMetal.set(_this3.context, 'model.isOpen', true); + _emberMetal.set(_this3.context, 'model.isUp', false); + _emberMetal.set(_this3.context, 'model.bar', false); + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-false-property some-initially-undefined-property static open down isFalsy') }, + content: 'hello' + }); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'model', { + someInitiallyTrueProperty: true, + someInitiallyFalseProperty: false, + someInitiallyUndefinedProperty: undefined, + isBig: true, + isOpen: false, + isUp: true, + bar: true + }); + }); + + this.assertComponentElement(this.firstChild, { + attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-initially-true-property static big closed isTruthy') }, + content: 'hello' + }); + }; + + _class.prototype['@test it can have class name bindings with nested paths'] = function testItCanHaveClassNameBindingsWithNestedPaths() { + var _this4 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['foo.bar', 'is.enabled:enabled', 'is.happy:happy:sad'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar foo=foo is=is}}', { foo: { bar: 'foo-bar' }, is: { enabled: true, happy: false } }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar enabled sad') }, content: 'hello' }); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar enabled sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo.bar', 'FOO-BAR'); + _emberMetal.set(_this4.context, 'is.enabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO-BAR sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo.bar', null); + _emberMetal.set(_this4.context, 'is.happy', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo', null); + _emberMetal.set(_this4.context, 'is', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view sad') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'foo', { bar: 'foo-bar' }); + _emberMetal.set(_this4.context, 'is', { enabled: true, happy: false }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar enabled sad') }, content: 'hello' }); + }; + + _class.prototype['@test it should dasherize the path when the it resolves to true'] = function testItShouldDasherizeThePathWhenTheItResolvesToTrue() { + var _this5 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['fooBar', 'nested.fooBarBaz'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar fooBar=fooBar nested=nested}}', { fooBar: true, nested: { fooBarBaz: false } }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') }, content: 'hello' }); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'fooBar', false); + _emberMetal.set(_this5.context, 'nested.fooBarBaz', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar-baz') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'fooBar', 'FOO-BAR'); + _emberMetal.set(_this5.context, 'nested.fooBarBaz', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO-BAR') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'nested', null); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO-BAR') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'fooBar', true); + _emberMetal.set(_this5.context, 'nested', { fooBarBaz: false }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') }, content: 'hello' }); + }; + + _class.prototype['@test const bindings can be set as attrs'] = function testConstBindingsCanBeSetAsAttrs() { + var _this6 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + this.render('{{foo-bar classNameBindings="foo:enabled:disabled"}}', { + foo: true + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view enabled') }, content: 'hello' }); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view enabled') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view disabled') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view enabled') }, content: 'hello' }); + }; + + _class.prototype['@test :: class name syntax works with an empty true class'] = function testClassNameSyntaxWorksWithAnEmptyTrueClass() { + var _this7 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['isEnabled::not-enabled'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar isEnabled=enabled}}', { + enabled: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view not-enabled') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'enabled', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'enabled', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view not-enabled') }, content: 'hello' }); + }; + + _class.prototype['@test uses all provided static class names (issue #11193)'] = function testUsesAllProvidedStaticClassNamesIssue11193() { + var _this8 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: [':class-one', ':class-two'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}', { + enabled: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view class-one class-two') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'enabled', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view class-one class-two') }, content: 'hello' }); + }; + + _class.prototype['@test Providing a binding with a space in it asserts'] = function testProvidingABindingWithASpaceInItAsserts() { + var _this9 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: 'i:think:i am:so:clever' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this9.render('{{foo-bar}}'); + }, /classNameBindings must not have spaces in them/i); + }; + + _class.prototype['@test it can set class name bindings in the constructor'] = function testItCanSetClassNameBindingsInTheConstructor() { + var _this10 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: ['foo'], + + init: function () { + this._super(); + + var bindings = this.classNameBindings = this.classNameBindings.slice(); + + if (this.get('bindIsEnabled')) { + bindings.push('isEnabled:enabled'); + } + + if (this.get('bindIsHappy')) { + bindings.push('isHappy:happy:sad'); + } + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { foo: 'foo', isEnabled: true, isHappy: false }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'foo', 'FOO'); + _emberMetal.set(_this10.context, 'isEnabled', false); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view FOO') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'foo', undefined); + _emberMetal.set(_this10.context, 'isHappy', true); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view happy') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'foo', 'foo'); + _emberMetal.set(_this10.context, 'isEnabled', true); + _emberMetal.set(_this10.context, 'isHappy', false); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo enabled sad') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + }; + + _class.prototype['@test using a computed property for classNameBindings triggers an assertion'] = function testUsingAComputedPropertyForClassNameBindingsTriggersAnAssertion() { + var _this11 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNameBindings: _emberMetal.computed(function () { + return ['isHappy:happy:sad']; + }) + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this11.render('{{foo-bar}}'); + }, /Only arrays are allowed/); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('ClassBinding integration', (function (_RenderingTest2) { +babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test it should apply classBinding without condition always'] = function testItShouldApplyClassBindingWithoutConditionAlways() { + var _this12 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding=":foo"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo ember-view') } }); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo ember-view') } }); + }; + + _class2.prototype['@test it should merge classBinding with class'] = function testItShouldMergeClassBindingWithClass() { + var _this13 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="birdman:respeck" class="myName"}}', { birdman: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck myName ember-view') } }); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck myName ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with only truthy condition'] = function testItShouldApplyClassBindingWithOnlyTruthyCondition() { + var _this14 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName:respeck"}}', { myName: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck ember-view') } }); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('respeck ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with only falsy condition'] = function testItShouldApplyClassBindingWithOnlyFalsyCondition() { + var _this15 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName::shade"}}', { myName: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('shade ember-view') } }); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('shade ember-view') } }); + }; + + _class2.prototype['@test it should apply nothing when classBinding is falsy but only supplies truthy class'] = function testItShouldApplyNothingWhenClassBindingIsFalsyButOnlySuppliesTruthyClass() { + var _this16 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName:respeck"}}', { myName: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + }; + + _class2.prototype['@test it should apply nothing when classBinding is truthy but only supplies falsy class'] = function testItShouldApplyNothingWhenClassBindingIsTruthyButOnlySuppliesFalsyClass() { + var _this17 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="myName::shade"}}', { myName: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with falsy condition'] = function testItShouldApplyClassBindingWithFalsyCondition() { + var _this18 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { swag: false }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('scrub ember-view') } }); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('scrub ember-view') } }); + }; + + _class2.prototype['@test it should apply classBinding with truthy condition'] = function testItShouldApplyClassBindingWithTruthyCondition() { + var _this19 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { swag: true }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fresh ember-view') } }); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fresh ember-view') } }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/class-bindings-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/class-bindings-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/class-bindings-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/contextual-components-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{component (component "-looked-up") "Hodari" greeting="Hodi"}}'], ['\n {{component (component "-looked-up") "Hodari" greeting="Hodi"}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{component (component "-looked-up" "Hodari" greeting="Hodi")\n greeting="Hola"}}'], ['\n {{component (component "-looked-up" "Hodari" greeting="Hodi")\n greeting="Hola"}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash comp=(component "-looked-up" greeting=model.greeting)) as |my|}}\n {{#my.comp}}{{/my.comp}}\n {{/with}}'], ['\n {{#with (hash comp=(component "-looked-up" greeting=model.greeting)) as |my|}}\n {{#my.comp}}{{/my.comp}}\n {{/with}}']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}\n {{#with (component first greeting="Hej" name="Sigmundur") as |second|}}\n {{component second greeting=model.greeting}}\n {{/with}}\n {{/with}}'], ['\n {{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}\n {{#with (component first greeting="Hej" name="Sigmundur") as |second|}}\n {{component second greeting=model.greeting}}\n {{/with}}\n {{/with}}']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup}}\n {{/with}}']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup expectedText=model.expectedText}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup expectedText=model.expectedText}}\n {{/with}}']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up" expectedText=model.expectedText)) as |object|}}\n {{object.lookedup}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up" expectedText=model.expectedText)) as |object|}}\n {{object.lookedup}}\n {{/with}}']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup model.expectedText "Hola"}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup model.expectedText "Hola"}}\n {{/with}}']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with (hash my-component=(component \'my-component\' first)) as |c|}}\n {{c.my-component}}\n {{/with}}'], ['\n {{#with (hash my-component=(component \'my-component\' first)) as |c|}}\n {{c.my-component}}\n {{/with}}']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#my-component my-attr=myProp as |api|}}\n {{api.my-nested-component}}\n {{/my-component}}\n
    \n '], ['\n {{#my-component my-attr=myProp as |api|}}\n {{api.my-nested-component}}\n {{/my-component}}\n
    \n ']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#select-box as |sb|}}\n {{sb.option label="Foo"}}\n {{sb.option}}\n {{/select-box}}'], ['\n {{#select-box as |sb|}}\n {{sb.option label="Foo"}}\n {{sb.option}}\n {{/select-box}}']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n '], ['\n ']), + _templateObject13 = babelHelpers.taggedTemplateLiteralLoose(['\n {{component (component "change-button" model.val2)}}\n {{model.val2}}'], ['\n {{component (component "change-button" model.val2)}}\n {{model.val2}}']), + _templateObject14 = babelHelpers.taggedTemplateLiteralLoose(['\n message: {{message}}{{inner-component message=message}}\n '], ['\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: contextual components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test renders with component helper'] = function testRendersWithComponentHelper() { + var _this = this; + + var expectedText = 'Hodi'; + + this.registerComponent('-looked-up', { + template: expectedText + }); + + this.render('{{component (component "-looked-up")}}'); + + this.assertText(expectedText); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with component helper with invocation params, hash'] = function testRendersWithComponentHelperWithInvocationParamsHash() { + var _this2 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertText('Hodi Hodari'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Hodi Hodari'); + }; + + _class.prototype['@test GH#13742 keeps nested rest positional parameters if rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfRenderedWithNoPositionalParameters() { + var _this3 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component "-looked-up" model.greeting model.name)}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this3.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('Good morning Zack'); + + this.runTask(function () { + return _this3.context.set('model.name', 'Matthew'); + }); + + this.assertText('Good morning Matthew'); + + this.runTask(function () { + return _this3.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('Gabon Zack'); + }; + + // Take a look at this one. Seems to pass even when currying isn't implemented. + + _class.prototype['@test overwrites nested rest positional parameters if rendered with positional parameters'] = function testOverwritesNestedRestPositionalParametersIfRenderedWithPositionalParameters() { + var _this4 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component "-looked-up" model.greeting model.name) model.name model.greeting}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this4.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('ZackGood morning '); + + this.runTask(function () { + return _this4.context.set('model.name', 'Matthew'); + }); + + this.assertText('MatthewGood morning '); + + this.runTask(function () { + return _this4.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('ZackGabon '); + }; + + _class.prototype['@test GH#13742 keeps nested rest positional parameters if nested and rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfNestedAndRenderedWithNoPositionalParameters() { + var _this5 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component (component "-looked-up" model.greeting model.name))}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('Gabon Zack'); + + this.runTask(function () { + return _this5.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('Good morning Zack'); + + this.runTask(function () { + return _this5.context.set('model.name', 'Matthew'); + }); + + this.assertText('Good morning Matthew'); + + this.runTask(function () { + return _this5.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('Gabon Zack'); + }; + + _class.prototype['@test overwrites nested rest positional parameters if nested with new pos params and rendered with no positional parameters'] = function testOverwritesNestedRestPositionalParametersIfNestedWithNewPosParamsAndRenderedWithNoPositionalParameters() { + var _this6 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component (component "-looked-up" model.greeting model.name) model.name model.greeting)}}', { + model: { + greeting: 'Gabon ', + name: 'Zack' + } + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('ZackGabon '); + + this.runTask(function () { + return _this6.context.set('model.greeting', 'Good morning '); + }); + + this.assertText('ZackGood morning '); + + this.runTask(function () { + return _this6.context.set('model.name', 'Matthew'); + }); + + this.assertText('MatthewGood morning '); + + this.runTask(function () { + return _this6.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); + }); + + this.assertText('ZackGabon '); + }; + + _class.prototype['@test renders with component helper with curried params, hash'] = function testRendersWithComponentHelperWithCurriedParamsHash() { + var _this7 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertText('Hola Hodari'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('Hola Hodari'); + }; + + _class.prototype['@test updates when component path is bound'] = function testUpdatesWhenComponentPathIsBound() { + var _this8 = this; + + this.registerComponent('-mandarin', { + template: 'ni hao' + }); + + this.registerComponent('-hindi', { + template: 'Namaste' + }); + + this.render('{{component (component model.lookupComponent)}}', { + model: { + lookupComponent: '-mandarin' + } + }); + + this.assertText('ni hao'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('ni hao'); + + this.runTask(function () { + return _this8.context.set('model.lookupComponent', '-hindi'); + }); + + this.assertText('Namaste'); + + this.runTask(function () { + return _this8.context.set('model', { lookupComponent: '-mandarin' }); + }); + + this.assertText('ni hao'); + }; + + _class.prototype['@test updates when curried hash argument is bound'] = function testUpdatesWhenCurriedHashArgumentIsBound() { + var _this9 = this; + + this.registerComponent('-looked-up', { + template: '{{greeting}}' + }); + + this.render('{{component (component "-looked-up" greeting=model.greeting)}}', { + model: { + greeting: 'Hodi' + } + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this9.context.set('model.greeting', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this9.context.set('model', { greeting: 'Hodi' }); + }); + + this.assertText('Hodi'); + }; + + _class.prototype['@test updates when curried hash arguments is bound in block form'] = function testUpdatesWhenCurriedHashArgumentsIsBoundInBlockForm() { + var _this10 = this; + + this.registerComponent('-looked-up', { + template: '{{greeting}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3), { + model: { + greeting: 'Hodi' + } + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Hodi'); + + this.runTask(function () { + return _this10.context.set('model.greeting', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this10.context.set('model', { greeting: 'Hodi' }); + }); + + this.assertText('Hodi'); + }; + + _class.prototype['@test nested components overwrite named positional parameters'] = function testNestedComponentsOverwriteNamedPositionalParameters() { + var _this11 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}} {{age}}' + }); + + this.render('{{component (component (component "-looked-up" "Sergio" 29) "Marvin" 21) "Hodari"}}'); + + this.assertText('Hodari 21'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('Hodari 21'); + }; + + _class.prototype['@test nested components overwrite hash parameters'] = function testNestedComponentsOverwriteHashParameters() { + var _this12 = this; + + this.registerComponent('-looked-up', { + template: '{{greeting}} {{name}} {{age}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4), { + model: { + greeting: 'Hodi' + } + }); + + this.assertText('Hodi Sigmundur 33'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('Hodi Sigmundur 33'); + + this.runTask(function () { + return _this12.context.set('model.greeting', 'Kaixo'); + }); + + this.assertText('Kaixo Sigmundur 33'); + + this.runTask(function () { + return _this12.context.set('model', { greeting: 'Hodi' }); + }); + + this.assertText('Hodi Sigmundur 33'); + }; + + _class.prototype['@test bound outer named parameters get updated in the right scope'] = function testBoundOuterNamedParametersGetUpdatedInTheRightScope() { + var _this13 = this; + + this.registerComponent('-inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['comp'] + }), + template: '{{component comp "Inner"}}' + }); + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}} {{age}}' + }); + + this.render('{{component "-inner-component" (component "-looked-up" model.outerName model.outerAge)}}', { + model: { + outerName: 'Outer', + outerAge: 28 + } + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this13.context.set('model.outerAge', 29); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + return _this13.context.set('model.outerName', 'Not outer'); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + _this13.context.set('model', { + outerName: 'Outer', + outerAge: 28 + }); + }); + + this.assertText('Inner 28'); + }; + + _class.prototype['@test bound outer hash parameters get updated in the right scope'] = function testBoundOuterHashParametersGetUpdatedInTheRightScope() { + var _this14 = this; + + this.registerComponent('-inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['comp'] + }), + template: '{{component comp name="Inner"}}' + }); + + this.registerComponent('-looked-up', { + template: '{{name}} {{age}}' + }); + + this.render('{{component "-inner-component" (component "-looked-up" name=model.outerName age=model.outerAge)}}', { + model: { + outerName: 'Outer', + outerAge: 28 + } + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('Inner 28'); + + this.runTask(function () { + return _this14.context.set('model.outerAge', 29); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + return _this14.context.set('model.outerName', 'Not outer'); + }); + + this.assertText('Inner 29'); + + this.runTask(function () { + _this14.context.set('model', { + outerName: 'Outer', + outerAge: 28 + }); + }); + + this.assertText('Inner 28'); + }; + + _class.prototype['@test conflicting positional and hash parameters raise and assertion if in the same component context'] = function testConflictingPositionalAndHashParametersRaiseAndAssertionIfInTheSameComponentContext() { + var _this15 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + expectAssertion(function () { + _this15.render('{{component (component "-looked-up" "Hodari" name="Sergio") "Hodari" greeting="Hodi"}}'); + }, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.'); + }; + + _class.prototype['@test conflicting positional and hash parameters does not raise an assertion if rerendered'] = function testConflictingPositionalAndHashParametersDoesNotRaiseAnAssertionIfRerendered() { + var _this16 = this; + + // In some cases, rerendering with a positional param used to cause an + // assertion. This test checks it does not. + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render('{{component (component "-looked-up" model.name greeting="Hodi")}}', { + model: { + name: 'Hodari' + } + }); + + this.assertText('Hodi Hodari'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('Hodi Hodari'); + + this.runTask(function () { + return _this16.context.set('model.name', 'Sergio'); + }); + + this.assertText('Hodi Sergio'); + + this.runTask(function () { + return _this16.context.set('model', { name: 'Hodari' }); + }); + + this.assertText('Hodi Hodari'); + }; + + _class.prototype['@test conflicting positional and hash parameters does not raise an assertion if in different component context'] = function testConflictingPositionalAndHashParametersDoesNotRaiseAnAssertionIfInDifferentComponentContext() { + var _this17 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{greeting}} {{name}}' + }); + + this.render('{{component (component "-looked-up" "Hodari") name="Sergio" greeting="Hodi"}}'); + + this.assertText('Hodi Sergio'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('Hodi Sergio'); + }; + + _class.prototype['@test raises an asserton when component path is null'] = function testRaisesAnAssertonWhenComponentPathIsNull() { + var _this18 = this; + + expectAssertion(function () { + _this18.render('{{component (component lookupComponent)}}'); + }); + }; + + _class.prototype['@test raises an assertion when component path is not a component name (static)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameStatic() { + var _this19 = this; + + expectAssertion(function () { + _this19.render('{{component (component "not-a-component")}}'); + }, 'The component helper cannot be used without a valid component name. You used "not-a-component" via (component "not-a-component")'); + }; + + _class.prototype['@test raises an assertion when component path is not a component name (dynamic)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameDynamic() { + var _this20 = this; + + expectAssertion(function () { + _this20.render('{{component (component compName)}}', { + compName: 'not-a-component' + }); + }, /The component helper cannot be used without a valid component name. You used "not-a-component" via \(component .*\)/); + }; + + _class.prototype['@test renders with dot path'] = function testRendersWithDotPath() { + var _this21 = this; + + var expectedText = 'Hodi'; + this.registerComponent('-looked-up', { + template: expectedText + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5)); + + this.assertText(expectedText); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with dot path and attr'] = function testRendersWithDotPathAndAttr() { + var _this22 = this; + + var expectedText = 'Hodi'; + this.registerComponent('-looked-up', { + template: '{{expectedText}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6), { + model: { + expectedText: expectedText + } + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this22.context.set('model.expectedText', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this22.context.set('model', { expectedText: expectedText }); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with dot path and curried over attr'] = function testRendersWithDotPathAndCurriedOverAttr() { + var _this23 = this; + + var expectedText = 'Hodi'; + this.registerComponent('-looked-up', { + template: '{{expectedText}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7), { + model: { + expectedText: expectedText + } + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText(expectedText); + + this.runTask(function () { + return _this23.context.set('model.expectedText', 'Hola'); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this23.context.set('model', { expectedText: expectedText }); + }); + + this.assertText(expectedText); + }; + + _class.prototype['@test renders with dot path and with rest positional parameters'] = function testRendersWithDotPathAndWithRestPositionalParameters() { + var _this24 = this; + + this.registerComponent('-looked-up', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{params}}' + }); + + var expectedText = 'Hodi'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8), { + model: { + expectedText: expectedText + } + }); + + this.assertText(expectedText + ',Hola'); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText(expectedText + ',Hola'); + + this.runTask(function () { + return _this24.context.set('model.expectedText', 'Kaixo'); + }); + + this.assertText('Kaixo,Hola'); + + this.runTask(function () { + return _this24.context.set('model', { expectedText: expectedText }); + }); + + this.assertText(expectedText + ',Hola'); + }; + + _class.prototype['@test renders with dot path and rest parameter does not leak'] = function testRendersWithDotPathAndRestParameterDoesNotLeak(assert) { + // In the original implementation, positional parameters were not handled + // correctly causing the first positional parameter to be the contextual + // component itself. + var value = false; + + this.registerComponent('my-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + value = this.getAttr('value'); + } + }).reopenClass({ + positionalParams: ['value'] + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9), { first: 'first' }); + + assert.equal(value, 'first', 'value is the expected parameter'); + }; + + _class.prototype['@test renders with dot path and updates attributes'] = function testRendersWithDotPathAndUpdatesAttributes(assert) { + var _this25 = this; + + this.registerComponent('my-nested-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + this.set('myProp', this.getAttr('my-parent-attr')); + } + }), + template: '{{myProp}}' + }); + + this.registerComponent('my-component', { + template: '{{yield (hash my-nested-component=(component "my-nested-component" my-parent-attr=my-attr))}}' + }); + + this.registerComponent('my-action-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + changeValue: function () { + this.incrementProperty('myProp'); + } + } + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10) + }); + + this.render('{{my-action-component myProp=model.myProp}}', { + model: { + myProp: 1 + } + }); + + assert.equal(this.$('#nested-prop').text(), '1'); + + this.runTask(function () { + return _this25.rerender(); + }); + + assert.equal(this.$('#nested-prop').text(), '1'); + + this.runTask(function () { + return _this25.$('button').click(); + }); + + assert.equal(this.$('#nested-prop').text(), '2'); + + this.runTask(function () { + return _this25.$('button').click(); + }); + + assert.equal(this.$('#nested-prop').text(), '3'); + + this.runTask(function () { + return _this25.context.set('model', { myProp: 1 }); + }); + + assert.equal(this.$('#nested-prop').text(), '1'); + }; + + _class.prototype['@test adding parameters to a contextual component\'s instance does not add it to other instances'] = function testAddingParametersToAContextualComponentSInstanceDoesNotAddItToOtherInstances() { + var _this26 = this; + + // If parameters and attributes are not handled correctly, setting a value + // in an invokation can leak to others invocation. + this.registerComponent('select-box', { + template: '{{yield (hash option=(component "select-box-option"))}}' + }); + + this.registerComponent('select-box-option', { + template: '{{label}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11)); + + this.assertText('Foo'); + + this.runTask(function () { + return _this26.rerender(); + }); + + this.assertText('Foo'); + }; + + _class.prototype['@test parameters in a contextual component are mutable when value is a param'] = function testParametersInAContextualComponentAreMutableWhenValueIsAParam(assert) { + var _this27 = this; + + // This checks that a `(mut)` is added to parameters and attributes to + // contextual components when it is a param. + + this.registerComponent('change-button', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['val'] + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject13), { + model: { + val2: 8 + } + }); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this27.rerender(); + }); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this27.$('.my-button').click(); + }); + + assert.equal(this.$('.value').text(), '10'); + + this.runTask(function () { + return _this27.context.set('model', { val2: 8 }); + }); + + assert.equal(this.$('.value').text(), '8'); + }; + + _class.prototype['@test tagless blockless components render'] = function testTaglessBlocklessComponentsRender(assert) { + var _this28 = this; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }) + }); + + this.render('{{my-comp}}'); + + this.runTask(function () { + return _this28.rerender(); + }); + + assert.equal(this.$().text(), ''); + }; + + _class.prototype['@test GH#13494 tagless blockless component with property binding'] = function testGH13494TaglessBlocklessComponentWithPropertyBinding(assert) { + var _this29 = this; + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + message: 'hello', + actions: { + change: function () { + this.set('message', 'goodbye'); + } + } + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14) + }); + + this.registerComponent('inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }) + }); + + this.render('{{outer-component}}'); + + assert.equal(this.$().text(), 'message: hello'); + + this.runTask(function () { + return _this29.rerender(); + }); + + assert.equal(this.$().text(), 'message: hello'); + + this.runTask(function () { + return _this29.$('button').click(); + }); + + assert.equal(this.$().text(), 'message: goodbye'); + + this.runTask(function () { + return _this29.rerender(); + }); + + assert.equal(this.$().text(), 'message: goodbye'); + }; + + _class.prototype['@test GH#13982 contextual component ref is stable even when bound params change'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChange(assert) { + var _this30 = this; + + var instance = undefined, + previousInstance = undefined; + var initCount = 0; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: '{{if isOpen "open" "closed"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject15), { + isOpen: true + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance was created'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this30.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this30.context.set('isOpen', false); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this30.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this30.context.set('isOpen', true); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + }; + + _class.prototype['@test GH#13982 contextual component ref is stable even when bound params change (bound name param)'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChangeBoundNameParam(assert) { + var _this31 = this; + + var instance = undefined, + previousInstance = undefined; + var initCount = 0; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: '{{if isOpen "open" "closed"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject16), { + compName: 'my-comp', + isOpen: true + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance was created'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this31.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + + this.runTask(function () { + return _this31.context.set('isOpen', false); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this31.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'closed', 'the component text is "closed"'); + + this.runTask(function () { + return _this31.context.set('isOpen', true); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'the component instance exists'); + assert.equal(previousInstance, undefined, 'no previous component exists'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'open', 'the componet text is "open"'); + }; + + _class.prototype['@test GH#13982 contextual component ref is recomputed when component name param changes'] = function testGH13982ContextualComponentRefIsRecomputedWhenComponentNameParamChanges(assert) { + var _this32 = this; + + var instance = undefined, + previousInstance = undefined; + var initCount = 0; + + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: 'my-comp: {{if isOpen "open" "closed"}}' + }); + + this.registerComponent('your-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + previousInstance = instance; + instance = this; + initCount++; + }, + isOpen: undefined + }), + template: 'your-comp: {{if isOpen "open" "closed"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject16), { + compName: 'my-comp', + isOpen: true + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance was created'); + assert.equal(previousInstance, undefined, 'there is no previous instance'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'my-comp: open'); + + this.runTask(function () { + return _this32.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'a instance exists after rerender'); + assert.equal(previousInstance, undefined, 'there is no previous instance after rerender'); + assert.equal(initCount, 1, 'the component was constructed exactly 1 time'); + assert.equal(this.$().text(), 'my-comp: open'); + + this.runTask(function () { + return _this32.context.set('compName', 'your-comp'); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'an instance was created after component name changed'); + assert.ok(!_emberMetal.isEmpty(previousInstance), 'a previous instance now exists'); + assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object'); + assert.equal(initCount, 2, 'the component was constructed exactly 2 times'); + assert.equal(this.$().text(), 'your-comp: open'); + + this.runTask(function () { + return _this32.rerender(); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'an instance was created after component name changed (rerender)'); + assert.ok(!_emberMetal.isEmpty(previousInstance), 'a previous instance now exists (rerender)'); + assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object (rerender)'); + assert.equal(initCount, 2, 'the component was constructed exactly 2 times (rerender)'); + assert.equal(this.$().text(), 'your-comp: open'); + + this.runTask(function () { + return _this32.context.set('compName', 'my-comp'); + }); + + assert.ok(!_emberMetal.isEmpty(instance), 'an instance was created after component name changed'); + assert.ok(!_emberMetal.isEmpty(previousInstance), 'a previous instance still exists'); + assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object'); + assert.equal(initCount, 3, 'the component was constructed exactly 3 times (rerender)'); + assert.equal(this.$().text(), 'my-comp: open'); + }; + + _class.prototype['@test GH#14508 rest positional params are received when passed as named parameter'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameter() { + var _this33 = this; + + this.registerComponent('my-link', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{component (component "my-link") params=allParams}}', { + allParams: _emberRuntimeSystemNative_array.A(['a', 'b']) + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this33.rerender(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this33.context.get('allParams').pushObject('c'); + }); + + this.assertText('abc'); + + this.runTask(function () { + return _this33.context.get('allParams').popObject(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this33.context.get('allParams').clear(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this33.context.set('allParams', _emberRuntimeSystemNative_array.A(['1', '2'])); + }); + + this.assertText('12'); + + this.runTask(function () { + return _this33.context.set('allParams', _emberRuntimeSystemNative_array.A(['a', 'b'])); + }); + + this.assertText('ab'); + }; + + _class.prototype['@test GH#14508 rest positional params are received when passed as named parameter with dot notation'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameterWithDotNotation() { + var _this34 = this; + + this.registerComponent('my-link', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'params' + }), + template: '{{#each params as |p|}}{{p}}{{/each}}' + }); + + this.render('{{#with (hash link=(component "my-link")) as |c|}}{{c.link params=allParams}}{{/with}}', { + allParams: _emberRuntimeSystemNative_array.A(['a', 'b']) + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this34.rerender(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this34.context.get('allParams').pushObject('c'); + }); + + this.assertText('abc'); + + this.runTask(function () { + return _this34.context.get('allParams').popObject(); + }); + + this.assertText('ab'); + + this.runTask(function () { + return _this34.context.get('allParams').clear(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this34.context.set('allParams', _emberRuntimeSystemNative_array.A(['1', '2'])); + }); + + this.assertText('12'); + + this.runTask(function () { + return _this34.context.set('allParams', _emberRuntimeSystemNative_array.A(['a', 'b'])); + }); + + this.assertText('ab'); + }; + + _class.prototype['@test GH#14632 give useful warning when calling contextual components with input as a name'] = function testGH14632GiveUsefulWarningWhenCallingContextualComponentsWithInputAsAName() { + var _this35 = this; + + expectAssertion(function () { + _this35.render('{{component (component "input" type="text")}}'); + }, 'You cannot use the input helper as a contextual helper. Please extend Ember.TextField or Ember.Checkbox to use it as a contextual component.'); + }; + + _class.prototype['@test GH#14632 give useful warning when calling contextual components with textarea as a name'] = function testGH14632GiveUsefulWarningWhenCallingContextualComponentsWithTextareaAsAName() { + var _this36 = this; + + expectAssertion(function () { + _this36.render('{{component (component "textarea" type="text")}}'); + }, 'You cannot use the textarea helper as a contextual helper. Please extend Ember.TextArea to use it as a contextual component.'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + var ContextualComponentMutableParamsTest = (function (_RenderingTest2) { +babelHelpers.inherits(ContextualComponentMutableParamsTest, _RenderingTest2); + + function ContextualComponentMutableParamsTest() { + _RenderingTest2.apply(this, arguments); + } + + ContextualComponentMutableParamsTest.prototype.render = function render(templateStr) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + _RenderingTest2.prototype.render.call(this, templateStr + '{{model.val2}}', _emberUtils.assign(context, { model: { val2: 8 } })); + }; + + return ContextualComponentMutableParamsTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var MutableParamTestGenerator = (function () { + function MutableParamTestGenerator(cases) { + this.cases = cases; + } + + MutableParamTestGenerator.prototype.generate = function generate(_ref2) { + var _ref; + + var title = _ref2.title; + var setup = _ref2.setup; + + return _ref = {}, _ref['@test parameters in a contextual component are mutable when value is a ' + title] = function (assert) { + var _this37 = this; + + this.registerComponent('change-button', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['val'] + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject17) + }); + + setup.call(this, assert); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this37.rerender(); + }); + + assert.equal(this.$('.value').text(), '8'); + + this.runTask(function () { + return _this37.$('.my-button').click(); + }); + + assert.equal(this.$('.value').text(), '10'); + + this.runTask(function () { + return _this37.context.set('model', { val2: 8 }); + }); + + assert.equal(this.$('.value').text(), '8'); + }, _ref; + }; + + return MutableParamTestGenerator; + })(); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(ContextualComponentMutableParamsTest, new MutableParamTestGenerator([{ + title: 'param', + setup: function () { + this.render('{{component (component "change-button" model.val2)}}'); + } + }, { + title: 'nested param', + setup: function () { + this.registerComponent('my-comp', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['components'] + }), + template: '{{component components.comp}}' + }); + + this.render('{{my-comp (hash comp=(component "change-button" model.val2))}}'); + } + }, { + title: 'hash value', + setup: function () { + this.registerComponent('my-comp', { + template: '{{component component}}' + }); + + this.render('{{my-comp component=(component "change-button" val=model.val2)}}'); + } + }, { + title: 'nested hash value', + setup: function () { + this.registerComponent('my-comp', { + template: '{{component components.button}}' + }); + + this.render('{{my-comp components=(hash button=(component "change-button" val=model.val2))}}'); + } + }])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: contextual components -- mutable params', ContextualComponentMutableParamsTest); +}); +enifed('ember-glimmer/tests/integration/components/contextual-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/contextual-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/contextual-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/curly-components-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers) { + /* globals EmberDev */ + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{foo-bar class="bar baz"}}\n {{foo-bar classNames="bar baz"}}\n {{foo-bar}}\n '], ['\n {{foo-bar class="bar baz"}}\n {{foo-bar classNames="bar baz"}}\n {{foo-bar}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if cond1}}\n {{#foo-bar id=1}}\n {{#if cond2}}\n {{#foo-bar id=2}}{{/foo-bar}}\n {{#if cond3}}\n {{#foo-bar id=3}}\n {{#if cond4}}\n {{#foo-bar id=4}}\n {{#if cond5}}\n {{#foo-bar id=5}}{{/foo-bar}}\n {{#foo-bar id=6}}{{/foo-bar}}\n {{#foo-bar id=7}}{{/foo-bar}}\n {{/if}}\n {{#foo-bar id=8}}{{/foo-bar}}\n {{/foo-bar}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}'], ['\n {{#if cond1}}\n {{#foo-bar id=1}}\n {{#if cond2}}\n {{#foo-bar id=2}}{{/foo-bar}}\n {{#if cond3}}\n {{#foo-bar id=3}}\n {{#if cond4}}\n {{#foo-bar id=4}}\n {{#if cond5}}\n {{#foo-bar id=5}}{{/foo-bar}}\n {{#foo-bar id=6}}{{/foo-bar}}\n {{#foo-bar id=7}}{{/foo-bar}}\n {{/if}}\n {{#foo-bar id=8}}{{/foo-bar}}\n {{/foo-bar}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if isStream}}\n true\n {{else}}\n false\n {{/if}}\n '], ['\n {{#if isStream}}\n true\n {{else}}\n false\n {{/if}}\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n Args: {{this.attrs.value}} | {{attrs.value}} | {{value}}\n {{#each this.attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each items as |item|}}\n {{item}}\n {{/each}}\n '], ['\n Args: {{this.attrs.value}} | {{attrs.value}} | {{value}}\n {{#each this.attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each items as |item|}}\n {{item}}\n {{/each}}\n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['Args: lul | lul | lul111'], ['Args: lul | lul | lul111']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}'], ['\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each names as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each names as |name|}}\n {{name}}\n {{/each}}']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n {{sample-component "Foo" 4 "Bar" elementId="args-3"}}\n {{sample-component "Foo" 4 "Bar" 5 "Baz" elementId="args-5"}}'], ['\n {{sample-component "Foo" 4 "Bar" elementId="args-3"}}\n {{sample-component "Foo" 4 "Bar" 5 "Baz" elementId="args-5"}}']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n {{sample-component "one" "two" elementId="two-positional"}}\n {{sample-component "one" second="two" elementId="one-positional"}}\n {{sample-component first="one" second="two" elementId="no-positional"}}'], ['\n {{sample-component "one" "two" elementId="two-positional"}}\n {{sample-component "one" second="two" elementId="one-positional"}}\n {{sample-component first="one" second="two" elementId="no-positional"}}']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each n as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each n as |name|}}\n {{name}}\n {{/each}}']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-template name="with-block"}}\n [In block - {{name}}]\n {{/with-template}}\n {{with-template name="without-block"}}'], ['\n {{#with-template name="with-block"}}\n [In block - {{name}}]\n {{/with-template}}\n {{with-template name="without-block"}}']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}'], ['\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}']), + _templateObject13 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block}}\n In template\n {{/with-block}}'], ['\n {{#with-block}}\n In template\n {{/with-block}}']), + _templateObject14 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlockParams}}\n {{yield this}} - In Component\n {{else}}\n {{yield}} No Block!\n {{/if}}'], ['\n {{#if hasBlockParams}}\n {{yield this}} - In Component\n {{else}}\n {{yield}} No Block!\n {{/if}}']), + _templateObject15 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block as |something|}}\n In template\n {{/with-block}}'], ['\n {{#with-block as |something|}}\n In template\n {{/with-block}}']), + _templateObject16 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlockParams}}\n {{yield this}}\n {{else}}\n {{yield}} No Block Param!\n {{/if}}'], ['\n {{#if hasBlockParams}}\n {{yield this}}\n {{else}}\n {{yield}} No Block Param!\n {{/if}}']), + _templateObject17 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with-block}}\n In block\n {{/with-block}}'], ['\n {{#with-block}}\n In block\n {{/with-block}}']), + _templateObject18 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if predicate}}\n Yes:{{yield someValue}}\n {{else}}\n No:{{yield to="inverse"}}\n {{/if}}'], ['\n {{#if predicate}}\n Yes:{{yield someValue}}\n {{else}}\n No:{{yield to="inverse"}}\n {{/if}}']), + _templateObject19 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#my-if predicate=activated someValue=42 as |result|}}\n Hello{{result}}\n {{else}}\n Goodbye\n {{/my-if}}'], ['\n {{#my-if predicate=activated someValue=42 as |result|}}\n Hello{{result}}\n {{else}}\n Goodbye\n {{/my-if}}']), + _templateObject20 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlock "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlock "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject21 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse}}{{else}}{{/check-inverse}}'], ['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse}}{{else}}{{/check-inverse}}']), + _templateObject22 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlock)}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlock)}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject23 = babelHelpers.taggedTemplateLiteralLoose(['\n {{check-block}}\n {{#check-block}}{{/check-block}}'], ['\n {{check-block}}\n {{#check-block}}{{/check-block}}']), + _templateObject24 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlockParams "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlockParams "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject25 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse as |something|}}{{/check-inverse}}'], ['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse as |something|}}{{/check-inverse}}']), + _templateObject26 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject27 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-block}}{{/check-block}}\n {{#check-block as |something|}}{{/check-block}}'], ['\n {{#check-block}}{{/check-block}}\n {{#check-block as |something|}}{{/check-block}}']), + _templateObject28 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlock}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if hasBlock}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject29 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}'], ['\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}']), + _templateObject30 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if hasBlockParams}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if hasBlockParams}}\n Yes\n {{else}}\n No\n {{/if}}']), + _templateObject31 = babelHelpers.taggedTemplateLiteralLoose(['\n {{check-attr}}\n {{#check-attr}}{{/check-attr}}'], ['\n {{check-attr}}\n {{#check-attr}}{{/check-attr}}']), + _templateObject32 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr}}{{else}}{{/check-attr}}'], ['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr}}{{else}}{{/check-attr}}']), + _templateObject33 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}'], ['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}']), + _templateObject34 = babelHelpers.taggedTemplateLiteralLoose(['\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}'], ['\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}']), + _templateObject35 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper}}{{else}}{{/check-helper}}'], ['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper}}{{else}}{{/check-helper}}']), + _templateObject36 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}'], ['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}']), + _templateObject37 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#x-outer}}\n {{#if showInner}}\n {{x-inner}}\n {{/if}}\n {{/x-outer}}'], ['\n {{#x-outer}}\n {{#if showInner}}\n {{x-inner}}\n {{/if}}\n {{/x-outer}}']), + _templateObject38 = babelHelpers.taggedTemplateLiteralLoose(['\n In layout. {{#each items as |item|}}\n [{{child-non-block item=item}}]\n {{/each}}'], ['\n In layout. {{#each items as |item|}}\n [{{child-non-block item=item}}]\n {{/each}}']), + _templateObject39 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#some-clicky-thing classNames="baz"}}\n Click Me\n {{/some-clicky-thing}}'], ['\n {{#some-clicky-thing classNames="baz"}}\n Click Me\n {{/some-clicky-thing}}']), + _templateObject40 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each blahzz as |p|}}\n {{p}}\n {{/each}}\n - {{yield}}'], ['\n {{#each blahzz as |p|}}\n {{p}}\n {{/each}}\n - {{yield}}']), + _templateObject41 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#some-clicky-thing blahzz="baz"}}\n Click Me\n {{/some-clicky-thing}}'], ['\n {{#some-clicky-thing blahzz="baz"}}\n Click Me\n {{/some-clicky-thing}}']), + _templateObject42 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#x-select value=value as |select|}}\n {{#x-option value="1" select=select}}1{{/x-option}}\n {{#x-option value="2" select=select}}2{{/x-option}}\n {{/x-select}}\n '], ['\n {{#x-select value=value as |select|}}\n {{#x-option value="1" select=select}}1{{/x-option}}\n {{#x-option value="2" select=select}}2{{/x-option}}\n {{/x-select}}\n ']), + _templateObject43 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#list-items items=items as |thing|}}\n |{{thing}}|\n\n {{#if editMode}}\n Remove {{thing}}\n {{/if}}\n {{/list-items}}\n '], ['\n {{#list-items items=items as |thing|}}\n |{{thing}}|\n\n {{#if editMode}}\n Remove {{thing}}\n {{/if}}\n {{/list-items}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: curly components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can render a basic component'] = function testItCanRenderABasicComponent() { + var _this = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it can render a template only component'] = function testItCanRenderATemplateOnlyComponent() { + var _this2 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it can have a custom id and it is not bound'] = function testItCanHaveACustomIdAndItIsNotBound() { + var _this3 = this; + + this.registerComponent('foo-bar', { template: '{{id}} {{elementId}}' }); + + this.render('{{foo-bar id=customId}}', { + customId: 'bizz' + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'customId', 'bar'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bar bizz' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'customId', 'bizz'); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); + }; + + _class.prototype['@test elementId cannot change'] = function testElementIdCannotChange(assert) { + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{elementId}}' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, content: 'blahzorz' }); + + if (EmberDev && !EmberDev.runningProdBuild) { + var willThrow = function () { + return _emberMetal.run(null, _emberMetal.set, component, 'elementId', 'herpyderpy'); + }; + + assert.throws(willThrow, /Changing a view's elementId after creation is not allowed/); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, content: 'blahzorz' }); + } + }; + + _class.prototype['@test can specify template with `layoutName` property'] = function testCanSpecifyTemplateWithLayoutNameProperty() { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + layoutName: 'fizz-bar', + init: function () { + this._super.apply(this, arguments); + this.local = 'hey'; + } + }); + + this.registerTemplate('fizz-bar', 'FIZZ BAR {{local}}'); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('FIZZ BAR hey'); + }; + + _class.prototype['@test can specify template with `defaultLayout` property [DEPRECATED]'] = function testCanSpecifyTemplateWithDefaultLayoutPropertyDEPRECATED() { + expectDeprecation(/Specifying `defaultLayout` to .* is deprecated. Please use `layout` instead/); + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + defaultLayout: _emberGlimmerTestsUtilsHelpers.compile('much wat {{lulz}}'), + init: function () { + this._super.apply(this, arguments); + this.lulz = 'hey'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('much wat hey'); + }; + + _class.prototype['@test layout takes precedence over defaultLayout'] = function testLayoutTakesPrecedenceOverDefaultLayout() { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + layout: _emberGlimmerTestsUtilsHelpers.compile('so much layout wat {{lulz}}'), + defaultLayout: _emberGlimmerTestsUtilsHelpers.compile('much wat {{lulz}}'), + init: function () { + this._super.apply(this, arguments); + this.lulz = 'hey'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('so much layout wat hey'); + }; + + _class.prototype['@test layout supports computed property'] = function testLayoutSupportsComputedProperty() { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + elementId: 'blahzorz', + layout: _emberMetal.computed(function () { + return _emberGlimmerTestsUtilsHelpers.compile('so much layout wat {{lulz}}'); + }), + init: function () { + this._super.apply(this, arguments); + this.lulz = 'heyo'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + + this.assertText('so much layout wat heyo'); + }; + + _class.prototype['@test passing undefined elementId results in a default elementId'] = function testPassingUndefinedElementIdResultsInADefaultElementId(assert) { + var _this4 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'h1' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'something' }); + + this.render('{{foo-bar id=somethingUndefined}}'); + + var foundId = this.$('h1').attr('id'); + assert.ok(/^ember/.test(foundId), 'Has a reasonable id attribute (found id=' + foundId + ').'); + + this.runTask(function () { + return _this4.rerender(); + }); + + var newFoundId = this.$('h1').attr('id'); + assert.ok(/^ember/.test(newFoundId), 'Has a reasonable id attribute (found id=' + newFoundId + ').'); + + assert.equal(foundId, newFoundId); + }; + + _class.prototype['@test id is an alias for elementId'] = function testIdIsAnAliasForElementId(assert) { + var _this5 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'h1' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'something' }); + + this.render('{{foo-bar id="custom-id"}}'); + + var foundId = this.$('h1').attr('id'); + assert.equal(foundId, 'custom-id'); + + this.runTask(function () { + return _this5.rerender(); + }); + + var newFoundId = this.$('h1').attr('id'); + assert.equal(newFoundId, 'custom-id'); + + assert.equal(foundId, newFoundId); + }; + + _class.prototype['@test cannot pass both id and elementId at the same time'] = function testCannotPassBothIdAndElementIdAtTheSameTime(assert) { + var _this6 = this; + + this.registerComponent('foo-bar', { template: '' }); + + expectAssertion(function () { + _this6.render('{{foo-bar id="zomg" elementId="lol"}}'); + }, /You cannot invoke a component with both 'id' and 'elementId' at the same time./); + }; + + _class.prototype['@test it can have a custom tagName'] = function testItCanHaveACustomTagName() { + var _this7 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'foo-bar' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + }; + + _class.prototype['@test it can have a custom tagName set in the constructor'] = function testItCanHaveACustomTagNameSetInTheConstructor() { + var _this8 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + this.tagName = 'foo-bar'; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + }; + + _class.prototype['@test it can have a custom tagName from the invocation'] = function testItCanHaveACustomTagNameFromTheInvocation() { + var _this9 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar tagName="foo-bar"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); + }; + + _class.prototype['@test tagName can not be a computed property'] = function testTagNameCanNotBeAComputedProperty(assert) { + var _this10 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: _emberMetal.computed(function () { + return 'foo-bar'; + }) + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + expectAssertion(function () { + _this10.render('{{foo-bar}}'); + }, /You cannot use a computed property for the component's `tagName` \(<\(.+>\)\./); + }; + + _class.prototype['@test class is applied before didInsertElement'] = function testClassIsAppliedBeforeDidInsertElement(assert) { + var componentClass = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + componentClass = this.element.className; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar class="foo-bar"}}'); + + assert.equal(componentClass, 'foo-bar ember-view'); + }; + + _class.prototype['@test it can have custom classNames'] = function testItCanHaveCustomClassNames() { + var _this11 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: ['foo', 'bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar') }, content: 'hello' }); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar') }, content: 'hello' }); + }; + + _class.prototype['@test should not apply falsy class name'] = function testShouldNotApplyFalsyClassName() { + var _this12 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar class=somethingFalsy}}', { + somethingFalsy: false + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); + }; + + _class.prototype['@test should apply classes of the dasherized property name when bound property specified is true'] = function testShouldApplyClassesOfTheDasherizedPropertyNameWhenBoundPropertySpecifiedIsTrue() { + var _this13 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar class=model.someTruth}}', { + model: { someTruth: true } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-truth') }, content: 'hello' }); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-truth') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model.someTruth', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') }, content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model', { someTruth: true }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view some-truth') }, content: 'hello' }); + }; + + _class.prototype['@test class property on components can be dynamic'] = function testClassPropertyOnComponentsCanBeDynamic() { + var _this14 = this; + + this.registerComponent('foo-bar', { template: 'hello' }); + + this.render('{{foo-bar class=(if fooBar "foo-bar")}}', { + fooBar: true + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') } }); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'fooBar', false); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'fooBar', true); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo-bar') } }); + }; + + _class.prototype['@test it can have custom classNames from constructor'] = function testItCanHaveCustomClassNamesFromConstructor() { + var _this15 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + this.classNames = this.classNames.slice(); + this.classNames.push('foo', 'bar', 'outside-' + this.get('extraClass')); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar extraClass="baz"}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar outside-baz') }, content: 'hello' }); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar outside-baz') }, content: 'hello' }); + }; + + _class.prototype['@test it can set custom classNames from the invocation'] = function testItCanSetCustomClassNamesFromTheInvocation() { + var _this16 = this; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: ['foo'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo bar baz') }, content: 'hello' }); + this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view foo') }, content: 'hello' }); + }; + + _class.prototype['@test it has an element'] = function testItHasAnElement() { + var _this17 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + var element1 = instance.element; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this17.rerender(); + }); + + var element2 = instance.element; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement(assert) { + var _this18 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar}}'); + + var element1 = instance.$()[0]; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this18.rerender(); + }); + + var element2 = instance.$()[0]; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) { + var _this19 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'inner' }); + + this.render('outer{{foo-bar}}'); + + var $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + + this.runTask(function () { + return _this19.rerender(); + }); + + $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + }; + + _class.prototype['@test an empty component does not have childNodes'] = function testAnEmptyComponentDoesNotHaveChildNodes(assert) { + var _this20 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'input', + init: function () { + this._super(); + fooBarInstance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { tagName: 'input' }); + + assert.strictEqual(fooBarInstance.element.childNodes.length, 0); + + this.runTask(function () { + return _this20.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'input' }); + + assert.strictEqual(fooBarInstance.element.childNodes.length, 0); + }; + + _class.prototype['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) { + var _this21 = this; + + var fooBarInstance = undefined, + fooBarBazInstance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + } + }); + + var FooBarBazComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarBazInstance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'foo-bar {{foo-bar-baz}}' }); + this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, template: 'foo-bar-baz' }); + + this.render('{{foo-bar}}'); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + + this.runTask(function () { + return _this21.rerender(); + }); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + }; + + _class.prototype['@test it renders passed named arguments'] = function testItRendersPassedNamedArguments() { + var _this22 = this; + + this.registerComponent('foo-bar', { + template: '{{foo}}' + }); + + this.render('{{foo-bar foo=model.bar}}', { + model: { + bar: 'Hola' + } + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertText('Hola'); + + this.runTask(function () { + return _this22.context.set('model.bar', 'Hello'); + }); + + this.assertText('Hello'); + + this.runTask(function () { + return _this22.context.set('model', { bar: 'Hola' }); + }); + + this.assertText('Hola'); + }; + + _class.prototype['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() { + var _this23 = this; + + this.registerComponent('foo-bar', { template: '{{yield}} - In component' }); + + this.render('{{#foo-bar}}hello{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); + }; + + _class.prototype['@test it can render a basic component with a block when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockWhenTheYieldIsInAPartial() { + var _this24 = this; + + this.registerPartial('_partialWithYield', 'yielded: [{{yield}}]'); + + this.registerComponent('foo-bar', { template: '{{partial "partialWithYield"}} - In component' }); + + this.render('{{#foo-bar}}hello{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + }; + + _class.prototype['@test it can render a basic component with a block param when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockParamWhenTheYieldIsInAPartial() { + var _this25 = this; + + this.registerPartial('_partialWithYield', 'yielded: [{{yield "hello"}}]'); + + this.registerComponent('foo-bar', { template: '{{partial "partialWithYield"}} - In component' }); + + this.render('{{#foo-bar as |value|}}{{value}}{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + + this.runTask(function () { + return _this25.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); + }; + + _class.prototype['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() { + var _this26 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + this.set('message', 'hello'); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{message}}' }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this26.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() { + var _this27 = this; + + this.registerComponent('foo-bar', { template: '{{yield}}' }); + + this.render('{{#foo-bar}}{{message}}{{/foo-bar}}', { message: 'hello' }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this27.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it can yield a block param named for reserved words [GH#14096]'] = function testItCanYieldABlockParamNamedForReservedWordsGH14096() { + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + + name: 'foo-bar' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{yield this}}' }); + + this.render('{{#foo-bar as |component|}}{{component.name}}{{/foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'foo-bar' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(instance, 'name', 'derp-qux'); + }); + + this.assertComponentElement(this.firstChild, { content: 'derp-qux' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'name', 'foo-bar'); + }); + + this.assertComponentElement(this.firstChild, { content: 'foo-bar' }); + }; + + _class.prototype['@test it can yield internal and external properties positionally'] = function testItCanYieldInternalAndExternalPropertiesPositionally() { + var _this28 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + greeting: 'hello' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{yield greeting greetee.firstName}}' }); + + this.render('{{#foo-bar greetee=person as |greeting name|}}{{name}} {{person.lastName}}, {{greeting}}{{/foo-bar}}', { + person: { + firstName: 'Joel', + lastName: 'Kang' + } + }); + + this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); + + this.runTask(function () { + return _this28.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); + + this.runTask(function () { + return _emberMetal.set(_this28.context, 'person', { firstName: 'Dora', lastName: 'the Explorer' }); + }); + + this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hello' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'greeting', 'hola'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hola' }); + + this.runTask(function () { + _emberMetal.set(instance, 'greeting', 'hello'); + _emberMetal.set(_this28.context, 'person', { + firstName: 'Joel', + lastName: 'Kang' + }); + }); + + this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); + }; + + _class.prototype['@test #11519 - block param infinite loop'] = function test11519BlockParamInfiniteLoop() { + var _this29 = this; + + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + }, + danger: 0 + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{danger}}{{yield danger}}' }); + + // On initial render, create streams. The bug will not have manifested yet, but at this point + // we have created streams that create a circular invalidation. + this.render('{{#foo-bar as |dangerBlockParam|}}{{/foo-bar}}'); + + this.assertText('0'); + + // Trigger a non-revalidating re-render. The yielded block will not be dirtied + // nor will block param streams, and thus no infinite loop will occur. + this.runTask(function () { + return _this29.rerender(); + }); + + this.assertText('0'); + + // Trigger a revalidation, which will cause an infinite loop without the fix + // in place. Note that we do not see the infinite loop is in testing mode, + // because a deprecation warning about re-renders is issued, which Ember + // treats as an exception. + this.runTask(function () { + return _emberMetal.set(instance, 'danger', 1); + }); + + this.assertText('1'); + + this.runTask(function () { + return _emberMetal.set(instance, 'danger', 0); + }); + + this.assertText('0'); + }; + + _class.prototype['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) { + var _this30 = this; + + var destroyed = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }; + + this.registerComponent('foo-bar', { + template: '{{id}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyed[this.get('id')]++; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + cond1: true, + cond2: true, + cond3: true, + cond4: true, + cond5: true + }); + + this.assertText('1 2 3 4 5 6 7 8 '); + + this.runTask(function () { + return _this30.rerender(); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }); + + this.runTask(function () { + return _emberMetal.set(_this30.context, 'cond5', false); + }); + + this.assertText('1 2 3 4 8 '); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 1, 7: 1, 8: 0 }); + + this.runTask(function () { + _emberMetal.set(_this30.context, 'cond3', false); + _emberMetal.set(_this30.context, 'cond5', true); + _emberMetal.set(_this30.context, 'cond4', false); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + + this.runTask(function () { + _emberMetal.set(_this30.context, 'cond2', false); + _emberMetal.set(_this30.context, 'cond1', false); + }); + + assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + }; + + _class.prototype['@test should escape HTML in normal mustaches'] = function testShouldEscapeHTMLInNormalMustaches() { + var _this31 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + output: 'you need to be more bold' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{output}}' }); + + this.render('{{foo-bar}}'); + + this.assertText('you need to be more bold'); + + this.runTask(function () { + return _this31.rerender(); + }); + + this.assertText('you need to be more bold'); + + this.runTask(function () { + return _emberMetal.set(component, 'output', 'you are so super'); + }); + + this.assertText('you are so super'); + + this.runTask(function () { + return _emberMetal.set(component, 'output', 'you need to be more bold'); + }); + }; + + _class.prototype['@test should not escape HTML in triple mustaches'] = function testShouldNotEscapeHTMLInTripleMustaches(assert) { + var _this32 = this; + + var expectedHtmlBold = 'you need to be more bold'; + var expectedHtmlItalic = 'you are so super'; + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + output: expectedHtmlBold + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{{output}}}' }); + + this.render('{{foo-bar}}'); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _this32.rerender(); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _emberMetal.set(component, 'output', expectedHtmlItalic); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlItalic); + + this.runTask(function () { + return _emberMetal.set(component, 'output', expectedHtmlBold); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + }; + + _class.prototype['@test should not escape HTML if string is a htmlSafe'] = function testShouldNotEscapeHTMLIfStringIsAHtmlSafe(assert) { + var _this33 = this; + + var expectedHtmlBold = 'you need to be more bold'; + var expectedHtmlItalic = 'you are so super'; + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + output: _emberGlimmerTestsUtilsHelpers.htmlSafe(expectedHtmlBold) + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{output}}' }); + + this.render('{{foo-bar}}'); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _this33.rerender(); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + + this.runTask(function () { + return _emberMetal.set(component, 'output', _emberGlimmerTestsUtilsHelpers.htmlSafe(expectedHtmlItalic)); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlItalic); + + this.runTask(function () { + return _emberMetal.set(component, 'output', _emberGlimmerTestsUtilsHelpers.htmlSafe(expectedHtmlBold)); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.firstChild, expectedHtmlBold); + }; + + _class.prototype['@test late bound layouts return the same definition'] = function testLateBoundLayoutsReturnTheSameDefinition(assert) { + var templateIds = []; + + // This is testing the scenario where you import a template and + // set it to the layout property: + // + // import layout from './template'; + // + // export default Ember.Component.extend({ + // layout + // }); + var hello = _emberGlimmerTestsUtilsHelpers.compile('Hello'); + var bye = _emberGlimmerTestsUtilsHelpers.compile('Bye'); + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.layout = this.cond ? hello : bye; + templateIds.push(this.layout.id); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar cond=true}}{{foo-bar cond=false}}{{foo-bar cond=true}}{{foo-bar cond=false}}'); + + var t1 = templateIds[0]; + var t2 = templateIds[1]; + var t3 = templateIds[2]; + var t4 = templateIds[3]; + + assert.equal(t1, t3); + assert.equal(t2, t4); + }; + + _class.prototype['@test can use isStream property without conflict (#13271)'] = function testCanUseIsStreamPropertyWithoutConflict13271() { + var _this34 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + isStream: true, + + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3) + }); + + this.render('{{foo-bar}}'); + + this.assertComponentElement(this.firstChild, { content: 'true' }); + + this.runTask(function () { + return _this34.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'true' }); + + this.runTask(function () { + return _emberMetal.set(component, 'isStream', false); + }); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + + this.runTask(function () { + return _emberMetal.set(component, 'isStream', true); + }); + + this.assertComponentElement(this.firstChild, { content: 'true' }); + }; + + _class.prototype['@test lookup of component takes priority over property'] = function testLookupOfComponentTakesPriorityOverProperty() { + var _this35 = this; + + this.registerComponent('some-component', { + template: 'some-component' + }); + + this.render('{{some-prop}} {{some-component}}', { + 'some-component': 'not-some-component', + 'some-prop': 'some-prop' + }); + + this.assertText('some-prop some-component'); + + this.runTask(function () { + return _this35.rerender(); + }); + + this.assertText('some-prop some-component'); + }; + + _class.prototype['@test component without dash is not looked up'] = function testComponentWithoutDashIsNotLookedUp() { + var _this36 = this; + + this.registerComponent('somecomponent', { + template: 'somecomponent' + }); + + this.render('{{somecomponent}}', { + 'somecomponent': 'notsomecomponent' + }); + + this.assertText('notsomecomponent'); + + this.runTask(function () { + return _this36.rerender(); + }); + + this.assertText('notsomecomponent'); + + this.runTask(function () { + return _this36.context.set('somecomponent', 'not not notsomecomponent'); + }); + + this.assertText('not not notsomecomponent'); + + this.runTask(function () { + return _this36.context.set('somecomponent', 'notsomecomponent'); + }); + + this.assertText('notsomecomponent'); + }; + + _class.prototype['@test non-block with properties on attrs'] = function testNonBlockWithPropertiesOnAttrs() { + var _this37 = this; + + this.registerComponent('non-block', { + template: 'In layout - someProp: {{attrs.someProp}}' + }); + + this.render('{{non-block someProp=prop}}', { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this37.rerender(); + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this37.context.set('prop', 'other thing there'); + }); + + this.assertText('In layout - someProp: other thing there'); + + this.runTask(function () { + return _this37.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here'); + }; + + _class.prototype['@test non-block with properties overridden in init'] = function testNonBlockWithPropertiesOverriddenInInit() { + var _this38 = this; + + var instance = undefined; + this.registerComponent('non-block', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + instance = this; + this.someProp = 'value set in instance'; + } + }), + template: 'In layout - someProp: {{someProp}}' + }); + + this.render('{{non-block someProp=prop}}', { + prop: 'something passed when invoked' + }); + + this.assertText('In layout - someProp: value set in instance'); + + this.runTask(function () { + return _this38.rerender(); + }); + + this.assertText('In layout - someProp: value set in instance'); + + this.runTask(function () { + return _this38.context.set('prop', 'updated something passed when invoked'); + }); + + this.assertText('In layout - someProp: updated something passed when invoked'); + + this.runTask(function () { + return instance.set('someProp', 'update value set in instance'); + }); + + this.assertText('In layout - someProp: update value set in instance'); + + this.runTask(function () { + return _this38.context.set('prop', 'something passed when invoked'); + }); + this.runTask(function () { + return instance.set('someProp', 'value set in instance'); + }); + + this.assertText('In layout - someProp: value set in instance'); + }; + + _class.prototype['@test rerendering component with attrs from parent'] = function testRerenderingComponentWithAttrsFromParent(assert) { + var _this39 = this; + + var willUpdateCount = 0; + var didReceiveAttrsCount = 0; + + function expectHooks(_ref, callback) { + var willUpdate = _ref.willUpdate; + var didReceiveAttrs = _ref.didReceiveAttrs; + + willUpdateCount = 0; + didReceiveAttrsCount = 0; + + callback(); + + if (willUpdate) { + assert.strictEqual(willUpdateCount, 1, 'The willUpdate hook was fired'); + } else { + assert.strictEqual(willUpdateCount, 0, 'The willUpdate hook was not fired'); + } + + if (didReceiveAttrs) { + assert.strictEqual(didReceiveAttrsCount, 1, 'The didReceiveAttrs hook was fired'); + } else { + assert.strictEqual(didReceiveAttrsCount, 0, 'The didReceiveAttrs hook was not fired'); + } + } + + this.registerComponent('non-block', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + didReceiveAttrsCount++; + }, + + willUpdate: function () { + willUpdateCount++; + } + }), + template: 'In layout - someProp: {{someProp}}' + }); + + expectHooks({ willUpdate: false, didReceiveAttrs: true }, function () { + _this39.render('{{non-block someProp=someProp}}', { + someProp: 'wycats' + }); + }); + + this.assertText('In layout - someProp: wycats'); + + // Note: Hooks are not fired in Glimmer for idempotent re-renders + expectHooks({ willUpdate: false, didReceiveAttrs: false }, function () { + _this39.runTask(function () { + return _this39.rerender(); + }); + }); + + this.assertText('In layout - someProp: wycats'); + + expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () { + _this39.runTask(function () { + return _this39.context.set('someProp', 'tomdale'); + }); + }); + + this.assertText('In layout - someProp: tomdale'); + + // Note: Hooks are not fired in Glimmer for idempotent re-renders + expectHooks({ willUpdate: false, didReceiveAttrs: false }, function () { + _this39.runTask(function () { + return _this39.rerender(); + }); + }); + + this.assertText('In layout - someProp: tomdale'); + + expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () { + _this39.runTask(function () { + return _this39.context.set('someProp', 'wycats'); + }); + }); + + this.assertText('In layout - someProp: wycats'); + }; + + _class.prototype['@test this.attrs.foo === attrs.foo === foo'] = function testThisAttrsFooAttrsFooFoo() { + var _this40 = this; + + this.registerComponent('foo-bar', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4) + }); + + this.render('{{foo-bar value=model.value items=model.items}}', { + model: { + value: 'wat', + items: [1, 2, 3] + } + }); + + this.assertStableRerender(); + + this.runTask(function () { + _this40.context.set('model.value', 'lul'); + _this40.context.set('model.items', [1]); + }); + + this.assertText(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5)); + + this.runTask(function () { + return _this40.context.set('model', { value: 'wat', items: [1, 2, 3] }); + }); + + this.assertText('Args: wat | wat | wat123123123'); + }; + + _class.prototype['@test non-block with properties on self'] = function testNonBlockWithPropertiesOnSelf() { + var _this41 = this; + + this.registerComponent('non-block', { + template: 'In layout - someProp: {{someProp}}' + }); + + this.render('{{non-block someProp=prop}}', { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this41.rerender(); + }); + + this.assertText('In layout - someProp: something here'); + + this.runTask(function () { + return _this41.context.set('prop', 'something else'); + }); + + this.assertText('In layout - someProp: something else'); + + this.runTask(function () { + return _this41.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here'); + }; + + _class.prototype['@test block with properties on self'] = function testBlockWithPropertiesOnSelf() { + var _this42 = this; + + this.registerComponent('with-block', { + template: 'In layout - someProp: {{someProp}} - {{yield}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6), { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this42.rerender(); + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this42.context.set('prop', 'something else'); + }); + + this.assertText('In layout - someProp: something else - In template'); + + this.runTask(function () { + return _this42.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here - In template'); + }; + + _class.prototype['@test block with properties on attrs'] = function testBlockWithPropertiesOnAttrs() { + var _this43 = this; + + this.registerComponent('with-block', { + template: 'In layout - someProp: {{attrs.someProp}} - {{yield}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6), { + prop: 'something here' + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this43.rerender(); + }); + + this.assertText('In layout - someProp: something here - In template'); + + this.runTask(function () { + return _this43.context.set('prop', 'something else'); + }); + + this.assertText('In layout - someProp: something else - In template'); + + this.runTask(function () { + return _this43.context.set('prop', 'something here'); + }); + + this.assertText('In layout - someProp: something here - In template'); + }; + + _class.prototype['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters(assert) { + var _this44 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8)); + + assert.equal(this.$('#args-3').text(), 'Foo4Bar'); + assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz'); + + this.runTask(function () { + return _this44.rerender(); + }); + + assert.equal(this.$('#args-3').text(), 'Foo4Bar'); + assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz'); + }; + + _class.prototype['@test arbitrary positional parameter conflict with hash parameter is reported'] = function testArbitraryPositionalParameterConflictWithHashParameterIsReported() { + var _this45 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7) + }); + + expectAssertion(function () { + _this45.render('{{sample-component "Foo" 4 "Bar" names=numbers id="args-3"}}', { + numbers: [1, 2, 3] + }); + }, 'You cannot specify positional parameters and the hash argument `names`.'); + }; + + _class.prototype['@test can use hash parameter instead of arbitrary positional param [GH #12444]'] = function testCanUseHashParameterInsteadOfArbitraryPositionalParamGH12444(assert) { + var _this46 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7) + }); + + this.render('{{sample-component names=things}}', { + things: _emberRuntime.A(['Foo', 4, 'Bar']) + }); + + this.assertText('Foo4Bar'); + + this.runTask(function () { + return _this46.rerender(); + }); + + this.assertText('Foo4Bar'); + + this.runTask(function () { + return _this46.context.get('things').pushObject(5); + }); + + this.assertText('Foo4Bar5'); + + this.runTask(function () { + return _this46.context.get('things').shiftObject(); + }); + + this.assertText('4Bar5'); + + this.runTask(function () { + return _this46.context.get('things').clear(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this46.context.set('things', _emberRuntime.A(['Foo', 4, 'Bar'])); + }); + + this.assertText('Foo4Bar'); + }; + + _class.prototype['@test can use hash parameter instead of positional param'] = function testCanUseHashParameterInsteadOfPositionalParam(assert) { + var _this47 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['first', 'second'] + }), + template: '{{first}} - {{second}}' + }); + + // TODO: Fix when id is implemented + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9)); + + assert.equal(this.$('#two-positional').text(), 'one - two'); + assert.equal(this.$('#one-positional').text(), 'one - two'); + assert.equal(this.$('#no-positional').text(), 'one - two'); + + this.runTask(function () { + return _this47.rerender(); + }); + + assert.equal(this.$('#two-positional').text(), 'one - two'); + assert.equal(this.$('#one-positional').text(), 'one - two'); + assert.equal(this.$('#no-positional').text(), 'one - two'); + }; + + _class.prototype['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters(assert) { + var _this48 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'n' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10) + }); + + this.render('{{sample-component user1 user2}}', { + user1: 'Foo', + user2: 4 + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this48.rerender(); + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this48.context.set('user1', 'Bar'); + }); + + this.assertText('Bar4'); + + this.runTask(function () { + return _this48.context.set('user2', '5'); + }); + + this.assertText('Bar5'); + + this.runTask(function () { + _this48.context.set('user1', 'Foo'); + _this48.context.set('user2', 4); + }); + + this.assertText('Foo4'); + }; + + _class.prototype['@test with ariaRole specified'] = function testWithAriaRoleSpecified() { + var _this49 = this; + + this.registerComponent('aria-test', { + template: 'Here!' + }); + + this.render('{{aria-test ariaRole=role}}', { + role: 'main' + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); + + this.runTask(function () { + return _this49.rerender(); + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); + + this.runTask(function () { + return _this49.context.set('role', 'input'); + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'input' } }); + + this.runTask(function () { + return _this49.context.set('role', 'main'); + }); + + this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); + }; + + _class.prototype['@test `template` specified in component is overriden by block'] = function testTemplateSpecifiedInComponentIsOverridenByBlock() { + var _this50 = this; + + this.registerComponent('with-template', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + template: _emberGlimmerTestsUtilsHelpers.compile('Should not be used') + }), + template: '[In layout - {{name}}] {{yield}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11), { + name: 'Whoop, whoop!' + }); + + this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); + + this.runTask(function () { + return _this50.rerender(); + }); + + this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); + + this.runTask(function () { + return _this50.context.set('name', 'Ole, ole'); + }); + + this.assertText('[In layout - with-block] [In block - Ole, ole][In layout - without-block] '); + + this.runTask(function () { + return _this50.context.set('name', 'Whoop, whoop!'); + }); + + this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); + }; + + _class.prototype['@test hasBlock is true when block supplied'] = function testHasBlockIsTrueWhenBlockSupplied() { + var _this51 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject13)); + + this.assertText('In template'); + + this.runTask(function () { + return _this51.rerender(); + }); + + this.assertText('In template'); + }; + + _class.prototype['@test hasBlock is false when no block supplied'] = function testHasBlockIsFalseWhenNoBlockSupplied() { + var _this52 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12) + }); + + this.render('{{with-block}}'); + + this.assertText('No Block!'); + + this.runTask(function () { + return _this52.rerender(); + }); + + this.assertText('No Block!'); + }; + + _class.prototype['@test hasBlockParams is true when block param supplied'] = function testHasBlockParamsIsTrueWhenBlockParamSupplied() { + var _this53 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject15)); + + this.assertText('In template - In Component'); + + this.runTask(function () { + return _this53.rerender(); + }); + + this.assertText('In template - In Component'); + }; + + _class.prototype['@test hasBlockParams is false when no block param supplied'] = function testHasBlockParamsIsFalseWhenNoBlockParamSupplied() { + var _this54 = this; + + this.registerComponent('with-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject16) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject17)); + + this.assertText('In block No Block Param!'); + + this.runTask(function () { + return _this54.rerender(); + }); + + this.assertText('In block No Block Param!'); + }; + + _class.prototype['@test static named positional parameters'] = function testStaticNamedPositionalParameters() { + var _this55 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}}{{age}}' + }); + + this.render('{{sample-component "Quint" 4}}'); + + this.assertText('Quint4'); + + this.runTask(function () { + return _this55.rerender(); + }); + + this.assertText('Quint4'); + }; + + _class.prototype['@test dynamic named positional parameters'] = function testDynamicNamedPositionalParameters() { + var _this56 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }), + template: '{{name}}{{age}}' + }); + + this.render('{{sample-component myName myAge}}', { + myName: 'Quint', + myAge: 4 + }); + + this.assertText('Quint4'); + + this.runTask(function () { + return _this56.rerender(); + }); + + this.assertText('Quint4'); + + this.runTask(function () { + return _this56.context.set('myName', 'Sergio'); + }); + + this.assertText('Sergio4'); + + this.runTask(function () { + return _this56.context.set('myAge', 2); + }); + + this.assertText('Sergio2'); + + this.runTask(function () { + _this56.context.set('myName', 'Quint'); + _this56.context.set('myAge', 4); + }); + + this.assertText('Quint4'); + }; + + _class.prototype['@test if a value is passed as a non-positional parameter, it raises an assertion'] = function testIfAValueIsPassedAsANonPositionalParameterItRaisesAnAssertion() { + var _this57 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name'] + }), + template: '{{name}}' + }); + + expectAssertion(function () { + _this57.render('{{sample-component notMyName name=myName}}', { + myName: 'Quint', + notMyName: 'Sergio' + }); + }, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.'); + }; + + _class.prototype['@test yield to inverse'] = function testYieldToInverse() { + var _this58 = this; + + this.registerComponent('my-if', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject18) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject19), { + activated: true + }); + + this.assertText('Yes:Hello42'); + + this.runTask(function () { + return _this58.rerender(); + }); + + this.assertText('Yes:Hello42'); + + this.runTask(function () { + return _this58.context.set('activated', false); + }); + + this.assertText('No:Goodbye'); + + this.runTask(function () { + return _this58.context.set('activated', true); + }); + + this.assertText('Yes:Hello42'); + }; + + _class.prototype['@test expression hasBlock inverse'] = function testExpressionHasBlockInverse(assert) { + this.registerComponent('check-inverse', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject20) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject21)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlock default'] = function testExpressionHasBlockDefault(assert) { + this.registerComponent('check-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject22) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject23)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlockParams inverse'] = function testExpressionHasBlockParamsInverse(assert) { + this.registerComponent('check-inverse', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject24) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject25)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'No' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlockParams default'] = function testExpressionHasBlockParamsDefault(assert) { + this.registerComponent('check-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject26) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject27)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test non-expression hasBlock'] = function testNonExpressionHasBlock(assert) { + this.registerComponent('check-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject28) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject23)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test expression hasBlockParams'] = function testExpressionHasBlockParams(assert) { + this.registerComponent('check-params', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject26) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject29)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test non-expression hasBlockParams'] = function testNonExpressionHasBlockParams(assert) { + this.registerComponent('check-params', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject30) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject29)); + + this.assertComponentElement(this.firstChild, { content: 'No' }); + this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock expression in an attribute'] = function testHasBlockExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject31)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'true' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock inverse expression in an attribute'] = function testHasBlockInverseExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }, ''); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject32)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'true' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams expression in an attribute'] = function testHasBlockParamsExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject33)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'true' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams inverse expression in an attribute'] = function testHasBlockParamsInverseExpressionInAnAttribute(assert) { + this.registerComponent('check-attr', { + template: '' + }, ''); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject33)); + + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[0], 'button', { name: 'false' }, ''); + _emberGlimmerTestsUtilsTestHelpers.equalsElement(this.$('button')[1], 'button', { name: 'false' }, ''); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock as a param to a helper'] = function testHasBlockAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if hasBlock "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject34)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock as an expression param to a helper'] = function testHasBlockAsAnExpressionParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlock) "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject34)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlock inverse as a param to a helper'] = function testHasBlockInverseAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlock "inverse") "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject35)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams as a param to a helper'] = function testHasBlockParamsAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if hasBlockParams "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject36)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams as an expression param to a helper'] = function testHasBlockParamsAsAnExpressionParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlockParams) "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject36)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'true' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test hasBlockParams inverse as a param to a helper'] = function testHasBlockParamsInverseAsAParamToAHelper(assert) { + this.registerComponent('check-helper', { + template: '{{if (hasBlockParams "inverse") "true" "false"}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject36)); + + this.assertComponentElement(this.firstChild, { content: 'false' }); + this.assertComponentElement(this.nthChild(1), { content: 'false' }); + + this.assertStableRerender(); + }; + + _class.prototype['@test component in template of a yielding component should have the proper parentView'] = function testComponentInTemplateOfAYieldingComponentShouldHaveTheProperParentView(assert) { + var _this59 = this; + + var outer = undefined, + innerTemplate = undefined, + innerLayout = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + } + }), + template: '{{x-inner-in-layout}}{{yield}}' + }); + + this.registerComponent('x-inner-in-template', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerTemplate = this; + } + }) + }); + + this.registerComponent('x-inner-in-layout', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerLayout = this; + } + }) + }); + + this.render('{{#x-outer}}{{x-inner-in-template}}{{/x-outer}}'); + + assert.equal(innerTemplate.parentView, outer, 'receives the wrapping component as its parentView in template blocks'); + assert.equal(innerLayout.parentView, outer, 'receives the wrapping component as its parentView in layout'); + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + + this.runTask(function () { + return _this59.rerender(); + }); + + assert.equal(innerTemplate.parentView, outer, 'receives the wrapping component as its parentView in template blocks'); + assert.equal(innerLayout.parentView, outer, 'receives the wrapping component as its parentView in layout'); + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + }; + + _class.prototype['@test newly-added sub-components get correct parentView'] = function testNewlyAddedSubComponentsGetCorrectParentView(assert) { + var _this60 = this; + + var outer = undefined, + inner = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + } + }) + }); + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + inner = this; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject37), { + showInner: false + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + + this.runTask(function () { + return _this60.rerender(); + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView (after rerender)'); + + this.runTask(function () { + return _this60.context.set('showInner', true); + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + assert.equal(inner.parentView, outer, 'receives the wrapping component as its parentView in template blocks'); + + this.runTask(function () { + return _this60.context.set('showInner', false); + }); + + assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); + }; + + _class.prototype['@test when a property is changed during children\'s rendering'] = function testWhenAPropertyIsChangedDuringChildrenSRendering(assert) { + var _this61 = this; + + var outer = undefined, + middle = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + }, + value: 1 + }), + template: '{{#x-middle}}{{x-inner value=value}}{{/x-middle}}' + }); + + this.registerComponent('x-middle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + middle = this; + }, + value: null + }), + template: '
    {{value}}
    {{yield}}' + }); + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + value: null, + pushDataUp: _emberMetal.observer('value', function () { + middle.set('value', this.get('value')); + }) + }), + template: '
    {{value}}
    ' + }); + + this.render('{{x-outer}}'); + + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); + assert.equal(this.$('#middle-value').text(), '', 'initial render of middle (observers do not run during init)'); + + this.runTask(function () { + return _this61.rerender(); + }); + + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); + assert.equal(this.$('#middle-value').text(), '', 'initial render of middle (observers do not run during init)'); + + var expectedBacktrackingMessage = /modified "value" twice on <\(.+> in a single render\. It was rendered in "component:x-middle" and modified in "component:x-inner"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + this.runTask(function () { + return outer.set('value', 2); + }); + } else { + expectAssertion(function () { + _this61.runTask(function () { + return outer.set('value', 2); + }); + }, expectedBacktrackingMessage); + + return; + } + + assert.equal(this.$('#inner-value').text(), '2', 'second render of inner'); + assert.equal(this.$('#middle-value').text(), '2', 'second render of middle'); + + this.runTask(function () { + return outer.set('value', 3); + }); + + assert.equal(this.$('#inner-value').text(), '3', 'third render of inner'); + assert.equal(this.$('#middle-value').text(), '3', 'third render of middle'); + + this.runTask(function () { + return outer.set('value', 1); + }); + + assert.equal(this.$('#inner-value').text(), '1', 'reset render of inner'); + assert.equal(this.$('#middle-value').text(), '1', 'reset render of middle'); + }; + + _class.prototype['@test when a shared dependency is changed during children\'s rendering'] = function testWhenASharedDependencyIsChangedDuringChildrenSRendering(assert) { + var _this62 = this; + + var outer = undefined; + + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outer = this; + }, + value: 1, + wrapper: _emberRuntime.Object.create({ content: null }) + }), + template: '
    {{wrapper.content}}
    {{x-inner value=value wrapper=wrapper}}' + }); + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + this.get('wrapper').set('content', this.get('value')); + }, + value: null + }), + template: '
    {{wrapper.content}}
    ' + }); + + var expectedBacktrackingMessage = /modified "wrapper\.content" twice on in a single render\. It was rendered in "component:x-outer" and modified in "component:x-inner"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + this.render('{{x-outer}}'); + } else { + expectAssertion(function () { + _this62.render('{{x-outer}}'); + }, expectedBacktrackingMessage); + + return; + } + + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); + assert.equal(this.$('#outer-value').text(), '1', 'initial render of outer'); + + this.runTask(function () { + return _this62.rerender(); + }); + + assert.equal(this.$('#inner-value').text(), '1', 're-render of inner'); + assert.equal(this.$('#outer-value').text(), '1', 're-render of outer'); + + this.runTask(function () { + return outer.set('value', 2); + }); + + assert.equal(this.$('#inner-value').text(), '2', 'second render of inner'); + assert.equal(this.$('#outer-value').text(), '2', 'second render of outer'); + + this.runTask(function () { + return outer.set('value', 3); + }); + + assert.equal(this.$('#inner-value').text(), '3', 'third render of inner'); + assert.equal(this.$('#outer-value').text(), '3', 'third render of outer'); + + this.runTask(function () { + return outer.set('value', 1); + }); + + assert.equal(this.$('#inner-value').text(), '1', 'reset render of inner'); + assert.equal(this.$('#outer-value').text(), '1', 'reset render of outer'); + }; + + _class.prototype['@test non-block with each rendering child components'] = function testNonBlockWithEachRenderingChildComponents() { + var _this63 = this; + + this.registerComponent('non-block', { + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject38) + }); + + this.registerComponent('child-non-block', { + template: 'Child: {{item}}.' + }); + + var items = _emberRuntime.A(['Tom', 'Dick', 'Harry']); + + this.render('{{non-block items=items}}', { items: items }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); + + this.runTask(function () { + return _this63.rerender(); + }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); + + this.runTask(function () { + return _this63.context.get('items').pushObject('Sergio'); + }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]'); + + this.runTask(function () { + return _this63.context.get('items').shiftObject(); + }); + + this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]'); + + this.runTask(function () { + return _this63.context.set('items', _emberRuntime.A(['Tom', 'Dick', 'Harry'])); + }); + + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); + }; + + _class.prototype['@test specifying classNames results in correct class'] = function testSpecifyingClassNamesResultsInCorrectClass(assert) { + var _this64 = this; + + this.registerComponent('some-clicky-thing', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'button', + classNames: ['foo', 'bar'] + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject39)); + + // TODO: ember-view is no longer viewable in the classNames array. Bug or + // feature? + var expectedClassNames = ['ember-view', 'foo', 'bar', 'baz']; + + assert.ok(this.$('button').is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + this.$('button').attr('class')); + // `ember-view` is no longer in classNames. + // assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined'); + this.assertComponentElement(this.firstChild, { tagName: 'button', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes(expectedClassNames.join(' ')) } }); + + this.runTask(function () { + return _this64.rerender(); + }); + + assert.ok(this.$('button').is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + this.$('button').attr('class') + ' (rerender)'); + // `ember-view` is no longer in classNames. + // assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined (rerender)'); + this.assertComponentElement(this.firstChild, { tagName: 'button', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes(expectedClassNames.join(' ')) } }); + }; + + _class.prototype['@test specifying custom concatenatedProperties avoids clobbering'] = function testSpecifyingCustomConcatenatedPropertiesAvoidsClobbering(assert) { + var _this65 = this; + + this.registerComponent('some-clicky-thing', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + concatenatedProperties: ['blahzz'], + blahzz: ['blark', 'pory'] + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject40) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject41)); + + this.assertText('blarkporybaz- Click Me'); + + this.runTask(function () { + return _this65.rerender(); + }); + + this.assertText('blarkporybaz- Click Me'); + }; + + _class.prototype['@test a two way binding flows upstream when consumed in the template'] = function testATwoWayBindingFlowsUpstreamWhenConsumedInTheTemplate() { + var _this66 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + + template: '{{bar}}' + }); + + this.render('{{localBar}} - {{foo-bar bar=localBar}}', { + localBar: 'initial value' + }); + + this.assertText('initial value - initial value'); + + this.runTask(function () { + return _this66.rerender(); + }); + + this.assertText('initial value - initial value'); + + if (false) { + expectAssertion(function () { + component.bar = 'foo-bar'; + }, /You must use Ember\.set\(\) to set the `bar` property \(of .+\) to `foo-bar`\./); + + this.assertText('initial value - initial value'); + } + + this.runTask(function () { + component.set('bar', 'updated value'); + }); + + this.assertText('updated value - updated value'); + + this.runTask(function () { + component.set('bar', undefined); + }); + + this.assertText(' - '); + + this.runTask(function () { + _this66.component.set('localBar', 'initial value'); + }); + + this.assertText('initial value - initial value'); + }; + + _class.prototype['@test a two way binding flows upstream through a CP when consumed in the template'] = function testATwoWayBindingFlowsUpstreamThroughACPWhenConsumedInTheTemplate() { + var _this67 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + bar: _emberMetal.computed({ + get: function () { + return this._bar; + }, + + set: function (key, value) { + this._bar = value; + return this._bar; + } + }) + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + + template: '{{bar}}' + }); + + this.render('{{localBar}} - {{foo-bar bar=localBar}}', { + localBar: 'initial value' + }); + + this.assertText('initial value - initial value'); + + this.runTask(function () { + return _this67.rerender(); + }); + + this.assertText('initial value - initial value'); + + this.runTask(function () { + component.set('bar', 'updated value'); + }); + + this.assertText('updated value - updated value'); + + this.runTask(function () { + _this67.component.set('localBar', 'initial value'); + }); + + this.assertText('initial value - initial value'); + }; + + _class.prototype['@test a two way binding flows upstream through a CP without template consumption'] = function testATwoWayBindingFlowsUpstreamThroughACPWithoutTemplateConsumption() { + var _this68 = this; + + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + bar: _emberMetal.computed({ + get: function () { + return this._bar; + }, + + set: function (key, value) { + this._bar = value; + return this._bar; + } + }) + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '' + }); + + this.render('{{localBar}}{{foo-bar bar=localBar}}', { + localBar: 'initial value' + }); + + this.assertText('initial value'); + + this.runTask(function () { + return _this68.rerender(); + }); + + this.assertText('initial value'); + + this.runTask(function () { + component.set('bar', 'updated value'); + }); + + this.assertText('updated value'); + + this.runTask(function () { + _this68.component.set('localBar', 'initial value'); + }); + + this.assertText('initial value'); + }; + + _class.prototype['@test services can be injected into components'] = function testServicesCanBeInjectedIntoComponents() { + var _this69 = this; + + var service = undefined; + this.registerService('name', _emberRuntime.Service.extend({ + init: function () { + this._super.apply(this, arguments); + service = this; + }, + last: 'Jackson' + })); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + name: _emberRuntime.inject.service() + }), + template: '{{name.last}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('Jackson'); + + this.runTask(function () { + return _this69.rerender(); + }); + + this.assertText('Jackson'); + + this.runTask(function () { + service.set('last', 'McGuffey'); + }); + + this.assertText('McGuffey'); + + this.runTask(function () { + service.set('last', 'Jackson'); + }); + + this.assertText('Jackson'); + }; + + _class.prototype['@test injecting an unknown service raises an exception'] = function testInjectingAnUnknownServiceRaisesAnException(assert) { + var _this70 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + missingService: _emberRuntime.inject.service() + }) + }); + + expectAssertion(function () { + _this70.render('{{foo-bar}}'); + }, 'Attempting to inject an unknown injection: \'service:missingService\''); + }; + + _class.prototype['@test can access `actions` hash via `_actions` [DEPRECATED]'] = function testCanAccessActionsHashVia_actionsDEPRECATED() { + var _this71 = this; + + var component = undefined; + + function derp() {} + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + actions: { + derp: derp + } + }) + }); + + this.render('{{foo-bar}}'); + + this.assert.strictEqual(component.actions.derp, derp); + + expectDeprecation(function () { + _this71.assert.strictEqual(component._actions.derp, derp); + }, 'Usage of `_actions` is deprecated, use `actions` instead.'); + }; + + _class.prototype['@test throws if `this._super` is not called from `init`'] = function testThrowsIfThis_superIsNotCalledFromInit() { + var _this72 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () {} + }) + }); + + expectAssertion(function () { + _this72.render('{{foo-bar}}'); + }, /You must call `this._super\(...arguments\);` when overriding `init` on a framework object. Please update .* to call `this._super\(...arguments\);` from `init`./); + }; + + _class.prototype['@test should toggle visibility with isVisible'] = function testShouldToggleVisibilityWithIsVisible(assert) { + var _this73 = this; + + var assertStyle = function (expected) { + var matcher = _emberGlimmerTestsUtilsTestHelpers.styles(expected); + var actual = _this73.firstChild.getAttribute('style'); + + assert.pushResult({ + result: matcher.match(actual), + message: matcher.message(), + actual: actual, + expected: expected + }); + }; + + this.registerComponent('foo-bar', { + template: '

    foo

    ' + }); + + this.render('{{foo-bar id="foo-bar" isVisible=visible}}', { + visible: false + }); + + assertStyle('display: none;'); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this73.context, 'visible', true); + }); + assertStyle(''); + + this.runTask(function () { + _emberMetal.set(_this73.context, 'visible', false); + }); + assertStyle('display: none;'); + }; + + _class.prototype['@test isVisible does not overwrite component style'] = function testIsVisibleDoesNotOverwriteComponentStyle(assert) { + var _this74 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + style: _emberGlimmerTestsUtilsHelpers.htmlSafe('color: blue;') + }), + + template: '

    foo

    ' + }); + + this.render('{{foo-bar id="foo-bar" isVisible=visible}}', { + visible: false + }); + + this.assertComponentElement(this.firstChild, { + tagName: 'div', + attrs: { id: 'foo-bar', style: _emberGlimmerTestsUtilsTestHelpers.styles('color: blue; display: none;') } + }); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this74.context, 'visible', true); + }); + + this.assertComponentElement(this.firstChild, { + tagName: 'div', + attrs: { id: 'foo-bar', style: _emberGlimmerTestsUtilsTestHelpers.styles('color: blue;') } + }); + + this.runTask(function () { + _emberMetal.set(_this74.context, 'visible', false); + }); + + this.assertComponentElement(this.firstChild, { + tagName: 'div', + attrs: { id: 'foo-bar', style: _emberGlimmerTestsUtilsTestHelpers.styles('color: blue; display: none;') } + }); + }; + + _class.prototype['@test adds isVisible binding when style binding is missing and other bindings exist'] = function testAddsIsVisibleBindingWhenStyleBindingIsMissingAndOtherBindingsExist(assert) { + var _this75 = this; + + var assertStyle = function (expected) { + var matcher = _emberGlimmerTestsUtilsTestHelpers.styles(expected); + var actual = _this75.firstChild.getAttribute('style'); + + assert.pushResult({ + result: matcher.match(actual), + message: matcher.message(), + actual: actual, + expected: expected + }); + }; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['foo'], + foo: 'bar' + }), + template: '

    foo

    ' + }); + + this.render('{{foo-bar id="foo-bar" foo=foo isVisible=visible}}', { + visible: false, + foo: 'baz' + }); + + assertStyle('display: none;'); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this75.context, 'visible', true); + }); + + assertStyle(''); + + this.runTask(function () { + _emberMetal.set(_this75.context, 'visible', false); + _emberMetal.set(_this75.context, 'foo', 'woo'); + }); + + assertStyle('display: none;'); + assert.equal(this.firstChild.getAttribute('foo'), 'woo'); + }; + + _class.prototype['@test it can use readDOMAttr to read input value'] = function testItCanUseReadDOMAttrToReadInputValue() { + var _this76 = this; + + var component = undefined; + var assertElement = function (expectedValue) { + // value is a property, not an attribute + _this76.assertHTML(''); + _this76.assert.equal(_this76.firstChild.value, expectedValue, 'value property is correct'); + _this76.assert.equal(_emberMetal.get(component, 'value'), expectedValue, 'component.get("value") is correct'); + }; + + this.registerComponent('one-way-input', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'input', + attributeBindings: ['value'], + + init: function () { + this._super.apply(this, arguments); + component = this; + }, + + change: function () { + var value = this.readDOMAttr('value'); + this.set('value', value); + } + }) + }); + + this.render('{{one-way-input value=value}}', { + value: 'foo' + }); + + assertElement('foo'); + + this.assertStableRerender(); + + this.runTask(function () { + _this76.firstChild.value = 'bar'; + _this76.$('input').trigger('change'); + }); + + assertElement('bar'); + + this.runTask(function () { + _this76.firstChild.value = 'foo'; + _this76.$('input').trigger('change'); + }); + + assertElement('foo'); + + this.runTask(function () { + _emberMetal.set(component, 'value', 'bar'); + }); + + assertElement('bar'); + + this.runTask(function () { + _this76.firstChild.value = 'foo'; + _this76.$('input').trigger('change'); + }); + + assertElement('foo'); + }; + + _class.prototype['@test child triggers revalidate during parent destruction (GH#13846)'] = function testChildTriggersRevalidateDuringParentDestructionGH13846() { + this.registerComponent('x-select', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'select', + + init: function () { + this._super(); + this.options = _emberRuntime.A([]); + this.value = null; + }, + + updateValue: function () { + var newValue = this.get('options.lastObject.value'); + + this.set('value', newValue); + }, + + registerOption: function (option) { + this.get('options').addObject(option); + }, + + unregisterOption: function (option) { + this.get('options').removeObject(option); + + this.updateValue(); + } + }), + + template: '{{yield this}}' + }); + + this.registerComponent('x-option', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'option', + attributeBindings: ['selected'], + + didInsertElement: function () { + this._super.apply(this, arguments); + + this.get('select').registerOption(this); + }, + + selected: _emberMetal.computed('select.value', function () { + return this.get('value') === this.get('select.value'); + }), + + willDestroyElement: function () { + this._super.apply(this, arguments); + this.get('select').unregisterOption(this); + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject42)); + + this.teardown(); + + this.assert.ok(true, 'no errors during teardown'); + }; + + _class.prototype['@test setting a property in willDestroyElement does not assert (GH#14273)'] = function testSettingAPropertyInWillDestroyElementDoesNotAssertGH14273(assert) { + assert.expect(2); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.showFoo = true; + }, + + willDestroyElement: function () { + this.set('showFoo', false); + assert.ok(true, 'willDestroyElement was fired'); + this._super.apply(this, arguments); + } + }), + + template: '{{#if showFoo}}things{{/if}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('things'); + }; + + _class.prototype['@test using didInitAttrs as an event is deprecated'] = function testUsingDidInitAttrsAsAnEventIsDeprecated(assert) { + var _this77 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + foo: _emberMetal.on('didInitAttrs', function () { + assert.ok(true, 'should fire `didInitAttrs` event'); + }) + }) + }); + + expectDeprecation(function () { + _this77.render('{{foo-bar}}'); + }, /didInitAttrs called/); + }; + + // This test is a replication of the "component unit tests" scenario. When we deprecate + // and remove them, this test could be removed as well. This is not fully/intentionally + // supported, and it is unclear that this particular behavior is actually relied on. + // Since there is no real "invocation" here, it has other issues and inconsistencies, + // like there is no real "attrs" here, and there is no "update" pass. + + _class.prototype['@test did{Init,Receive}Attrs fires even if component is not rendered'] = function testDidInitReceiveAttrsFiresEvenIfComponentIsNotRendered(assert) { + var _this78 = this; + + expectDeprecation(/didInitAttrs called/); + + var didInitAttrsCount = 0; + var didReceiveAttrsCount = 0; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.didInit = true; + }, + + didInitAttrs: function () { + assert.ok(this.didInit, 'expected init to have run before didInitAttrs'); + didInitAttrsCount++; + }, + + didReceiveAttrs: function () { + assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs'); + didReceiveAttrsCount++; + }, + + willRender: function () { + throw new Error('Unexpected render!'); + } + }) + }); + + assert.strictEqual(didInitAttrsCount, 0, 'precond: didInitAttrs is not fired'); + assert.strictEqual(didReceiveAttrsCount, 0, 'precond: didReceiveAttrs is not fired'); + + this.runTask(function () { + return _this78.component = _this78.owner.lookup('component:foo-bar'); + }); + + assert.strictEqual(didInitAttrsCount, 1, 'precond: didInitAttrs is fired'); + assert.strictEqual(didReceiveAttrsCount, 1, 'precond: didReceiveAttrs is fired'); + }; + + _class.prototype['@test did{Init,Receive}Attrs fires after .init() but before observers become active'] = function testDidInitReceiveAttrsFiresAfterInitButBeforeObserversBecomeActive(assert) { + var _this79 = this; + + expectDeprecation(/didInitAttrs called/); + + var fooCopyDidChangeCount = 0; + var barCopyDidChangeCount = 0; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.didInit = true; + }, + + didInitAttrs: function (_ref2) { + var attrs = _ref2.attrs; + + assert.ok(this.didInit, 'expected init to have run before didInitAttrs'); + this.set('fooCopy', attrs.foo.value + 1); + }, + + didReceiveAttrs: function (_ref3) { + var newAttrs = _ref3.newAttrs; + + assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs'); + this.set('barCopy', newAttrs.bar.value + 1); + }, + + fooCopyDidChange: _emberMetal.observer('fooCopy', function () { + fooCopyDidChangeCount++; + }), + barCopyDidChange: _emberMetal.observer('barCopy', function () { + barCopyDidChangeCount++; + }) + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + + this.assertText('1-2-3-4'); + + assert.strictEqual(fooCopyDidChangeCount, 0, 'expected NO observer firing for: fooCopy'); + assert.strictEqual(barCopyDidChangeCount, 0, 'expected NO observer firing for: barCopy'); + + this.runTask(function () { + return _emberMetal.set(_this79.context, 'foo', 5); + }); + + this.assertText('5-2-3-4'); + + assert.strictEqual(fooCopyDidChangeCount, 0, 'expected observer firing for: fooCopy'); + assert.strictEqual(barCopyDidChangeCount, 0, 'expected NO observer firing for: barCopy'); + + this.runTask(function () { + return _emberMetal.set(_this79.context, 'bar', 7); + }); + + this.assertText('5-2-7-8'); + + assert.strictEqual(fooCopyDidChangeCount, 0, 'expected observer firing for: fooCopy'); + assert.strictEqual(barCopyDidChangeCount, 1, 'expected observer firing for: barCopy'); + }; + + _class.prototype['@test overriding didReceiveAttrs does not trigger deprecation'] = function testOverridingDidReceiveAttrsDoesNotTriggerDeprecation(assert) { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + assert.equal(1, this.get('foo'), 'expected attrs to have correct value'); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + }; + + _class.prototype['@test can access didReceiveAttrs arguments [DEPRECATED]'] = function testCanAccessDidReceiveAttrsArgumentsDEPRECATED(assert) { + expectDeprecation(/didReceiveAttrs.*stop taking arguments/); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function (_ref4) { + var attrs = _ref4.attrs; + + assert.equal(1, attrs.foo.value, 'expected attrs to have correct value'); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + }; + + _class.prototype['@test can access didUpdateAttrs arguments [DEPRECATED]'] = function testCanAccessDidUpdateAttrsArgumentsDEPRECATED(assert) { + var _this80 = this; + + expectDeprecation(/didUpdateAttrs.*stop taking arguments/); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didUpdateAttrs: function (_ref5) { + var newAttrs = _ref5.newAttrs; + + assert.equal(5, newAttrs.foo.value, "expected newAttrs to have new value"); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + + this.runTask(function () { + return _emberMetal.set(_this80.context, 'foo', 5); + }); + }; + + _class.prototype['@test overriding didUpdateAttrs does not trigger deprecation'] = function testOverridingDidUpdateAttrsDoesNotTriggerDeprecation(assert) { + var _this81 = this; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didUpdateAttrs: function () { + assert.equal(5, this.get('foo'), "expected newAttrs to have new value"); + } + }), + + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + }); + + this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 }); + + this.runTask(function () { + return _emberMetal.set(_this81.context, 'foo', 5); + }); + }; + + _class.prototype['@test returning `true` from an action does not bubble if `target` is not specified (GH#14275)'] = function testReturningTrueFromAnActionDoesNotBubbleIfTargetIsNotSpecifiedGH14275(assert) { + var _this82 = this; + + this.registerComponent('display-toggle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + assert.ok(true, 'display-toggle show action was called'); + return true; + } + } + }), + + template: '' + }); + + this.render('{{display-toggle}}', { + send: function () { + assert.notOk(true, 'send should not be called when action is not "subscribed" to'); + } + }); + + this.assertText('Show'); + + this.runTask(function () { + return _this82.$('button').click(); + }); + }; + + _class.prototype['@test returning `true` from an action bubbles to the `target` if specified'] = function testReturningTrueFromAnActionBubblesToTheTargetIfSpecified(assert) { + var _this83 = this; + + assert.expect(4); + + this.registerComponent('display-toggle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + assert.ok(true, 'display-toggle show action was called'); + return true; + } + } + }), + + template: '' + }); + + this.render('{{display-toggle target=this}}', { + send: function (actionName) { + assert.ok(true, 'send should be called when action is "subscribed" to'); + assert.equal(actionName, 'show'); + } + }); + + this.assertText('Show'); + + this.runTask(function () { + return _this83.$('button').click(); + }); + }; + + _class.prototype['@test component yielding in an {{#each}} has correct block values after rerendering (GH#14284)'] = function testComponentYieldingInAnEachHasCorrectBlockValuesAfterRerenderingGH14284() { + var _this84 = this; + + this.registerComponent('list-items', { + template: '{{#each items as |item|}}{{yield item}}{{/each}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject43), { + editMode: false, + items: ['foo', 'bar', 'qux', 'baz'] + }); + + this.assertText('|foo||bar||qux||baz|'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this84.context, 'editMode', true); + }); + + this.assertText('|foo|Remove foo|bar|Remove bar|qux|Remove qux|baz|Remove baz'); + + this.runTask(function () { + return _emberMetal.set(_this84.context, 'editMode', false); + }); + + this.assertText('|foo||bar||qux||baz|'); + }; + + _class.prototype['@test unimplimented positionalParams do not cause an error GH#14416'] = function testUnimplimentedPositionalParamsDoNotCauseAnErrorGH14416(assert) { + this.registerComponent('foo-bar', { + template: 'hello' + }); + + this.render('{{foo-bar wat}}'); + this.assertText('hello'); + }; + + _class.prototype['@test using attrs for positional params'] = function testUsingAttrsForPositionalParams(assert) { + var MyComponent = _emberGlimmerTestsUtilsHelpers.Component.extend(); + + this.registerComponent('foo-bar', { + ComponentClass: MyComponent.reopenClass({ + positionalParams: ['myVar'] + }), + template: 'MyVar1: {{attrs.myVar}} {{myVar}} MyVar2: {{myVar2}} {{attrs.myVar2}}' + }); + + this.render('{{foo-bar 1 myVar2=2}}'); + + this.assertText('MyVar1: 1 1 MyVar2: 2 2'); + }; + + _class.prototype['@test can use `{{this}}` to emit the component\'s toString value [GH#14581]'] = function testCanUseThisToEmitTheComponentSToStringValueGH14581(assert) { + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + toString: function () { + return 'special sauce goes here!'; + } + }), + template: '{{this}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('special sauce goes here!'); + }; + + _class.prototype['@test can use `{{this` to access paths on current context [GH#14581]'] = function testCanUseThisToAccessPathsOnCurrentContextGH14581(assert) { + var instance = undefined; + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + + instance = this; + }, + + foo: { + bar: { + baz: 'huzzah!' + } + } + }), + template: '{{this.foo.bar.baz}}' + }); + + this.render('{{foo-bar}}'); + + this.assertText('huzzah!'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(instance, 'foo.bar.baz', 'yippie!'); + }); + + this.assertText('yippie!'); + + this.runTask(function () { + return _emberMetal.set(instance, 'foo.bar.baz', 'huzzah!'); + }); + + this.assertText('huzzah!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/curly-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/curly-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/curly-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/dynamic-components-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if cond1}}\n {{#component "foo-bar" id=1}}\n {{#if cond2}}\n {{#component "foo-bar" id=2}}{{/component}}\n {{#if cond3}}\n {{#component "foo-bar" id=3}}\n {{#if cond4}}\n {{#component "foo-bar" id=4}}\n {{#if cond5}}\n {{#component "foo-bar" id=5}}{{/component}}\n {{#component "foo-bar" id=6}}{{/component}}\n {{#component "foo-bar" id=7}}{{/component}}\n {{/if}}\n {{#component "foo-bar" id=8}}{{/component}}\n {{/component}}\n {{/if}}\n {{/component}}\n {{/if}}\n {{/if}}\n {{/component}}\n {{/if}}'], ['\n {{#if cond1}}\n {{#component "foo-bar" id=1}}\n {{#if cond2}}\n {{#component "foo-bar" id=2}}{{/component}}\n {{#if cond3}}\n {{#component "foo-bar" id=3}}\n {{#if cond4}}\n {{#component "foo-bar" id=4}}\n {{#if cond5}}\n {{#component "foo-bar" id=5}}{{/component}}\n {{#component "foo-bar" id=6}}{{/component}}\n {{#component "foo-bar" id=7}}{{/component}}\n {{/if}}\n {{#component "foo-bar" id=8}}{{/component}}\n {{/component}}\n {{/if}}\n {{/component}}\n {{/if}}\n {{/if}}\n {{/component}}\n {{/if}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each names as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each names as |name|}}\n {{name}}\n {{/each}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each n as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each n as |name|}}\n {{name}}\n {{/each}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: dynamic components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can render a basic component with a static component name argument'] = function testItCanRenderABasicComponentWithAStaticComponentNameArgument() { + var _this = this; + + this.registerComponent('foo-bar', { template: 'hello {{name}}' }); + + this.render('{{component "foo-bar" name=name}}', { name: 'Sarah' }); + + this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Gavin'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Gavin' }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Sarah'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); + }; + + _class.prototype['@test it can render a basic component with a dynamic component name argument'] = function testItCanRenderABasicComponentWithADynamicComponentNameArgument() { + var _this2 = this; + + this.registerComponent('foo-bar', { template: 'hello {{name}} from foo-bar' }); + this.registerComponent('foo-bar-baz', { template: 'hello {{name}} from foo-bar-baz' }); + + this.render('{{component componentName name=name}}', { componentName: 'foo-bar', name: 'Alex' }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'name', 'Ben'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'componentName', 'foo-bar-baz'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar-baz' }); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'componentName', 'foo-bar'); + _emberMetal.set(_this2.context, 'name', 'Alex'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); + }; + + _class.prototype['@test it has an element'] = function testItHasAnElement() { + var _this3 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{component "foo-bar"}}'); + + var element1 = instance.element; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this3.rerender(); + }); + + var element2 = instance.element; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement(assert) { + var _this4 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{component "foo-bar"}}'); + + var element1 = instance.$()[0]; + + this.assertComponentElement(element1, { content: 'hello' }); + + this.runTask(function () { + return _this4.rerender(); + }); + + var element2 = instance.$()[0]; + + this.assertComponentElement(element2, { content: 'hello' }); + + this.assertSameNode(element2, element1); + }; + + _class.prototype['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) { + var _this5 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'inner' }); + + this.render('outer{{component "foo-bar"}}'); + + var $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + + this.runTask(function () { + return _this5.rerender(); + }); + + $span = instance.$('span'); + + assert.equal($span.length, 1); + assert.equal($span.attr('class'), 'inner'); + }; + + _class.prototype['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) { + var _this6 = this; + + var fooBarInstance = undefined, + fooBarBazInstance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + } + }); + + var FooBarBazComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarBazInstance = this; + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'foo-bar {{foo-bar-baz}}' }); + this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, template: 'foo-bar-baz' }); + + this.render('{{component "foo-bar"}}'); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + + this.runTask(function () { + return _this6.rerender(); + }); + this.assertText('foo-bar foo-bar-baz'); + + assert.equal(fooBarInstance.parentView, this.component); + assert.equal(fooBarBazInstance.parentView, fooBarInstance); + + assert.deepEqual(this.component.childViews, [fooBarInstance]); + assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]); + }; + + _class.prototype['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() { + var _this7 = this; + + this.registerComponent('foo-bar', { template: '{{yield}}' }); + + this.render('{{#component "foo-bar"}}hello{{/component}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() { + var _this8 = this; + + var instance = undefined; + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + instance = this; + this.set('message', 'hello'); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{message}}' }); + + this.render('{{component "foo-bar"}}'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(instance, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() { + var _this9 = this; + + this.registerComponent('foo-bar', { template: '{{yield}}' }); + + this.render('{{#component "foo-bar"}}{{message}}{{/component}}', { message: 'hello' }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'message', 'goodbye'); + }); + + this.assertComponentElement(this.firstChild, { content: 'goodbye' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'message', 'hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + }; + + _class.prototype['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) { + var _this10 = this; + + var destroyed = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }; + + this.registerComponent('foo-bar', { + template: '{{id}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyed[this.get('id')]++; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + cond1: true, + cond2: true, + cond3: true, + cond4: true, + cond5: true + }); + + this.assertText('1 2 3 4 5 6 7 8 '); + + this.runTask(function () { + return _this10.rerender(); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'cond5', false); + }); + + this.assertText('1 2 3 4 8 '); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 1, 7: 1, 8: 0 }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond3', false); + _emberMetal.set(_this10.context, 'cond5', true); + _emberMetal.set(_this10.context, 'cond4', false); + }); + + assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond2', false); + _emberMetal.set(_this10.context, 'cond1', false); + }); + + assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); + }; + + _class.prototype['@test component helper destroys underlying component when it is swapped out'] = function testComponentHelperDestroysUnderlyingComponentWhenItIsSwappedOut(assert) { + var _this11 = this; + + var destroyed = { 'foo-bar': 0, 'foo-bar-baz': 0 }; + var testContext = this; + + this.registerComponent('foo-bar', { + template: 'hello from foo-bar', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroyElement: function () { + assert.equal(testContext.$('#' + this.elementId).length, 1, 'element is still attached to the document'); + }, + + willDestroy: function () { + this._super(); + destroyed['foo-bar']++; + } + }) + }); + + this.registerComponent('foo-bar-baz', { + template: 'hello from foo-bar-baz', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyed['foo-bar-baz']++; + } + }) + }); + + this.render('{{component componentName name=name}}', { componentName: 'foo-bar' }); + + assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 }); + + this.runTask(function () { + return _this11.rerender(); + }); + + assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 }); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'componentName', 'foo-bar-baz'); + }); + + assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 0 }); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'componentName', 'foo-bar'); + }); + + assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 1 }); + }; + + _class.prototype['@test component helper with bound properties are updating correctly in init of component'] = function testComponentHelperWithBoundPropertiesAreUpdatingCorrectlyInInitOfComponent(assert) { + var _this12 = this; + + this.registerComponent('foo-bar', { + template: 'foo-bar {{location}} {{locationCopy}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('locationCopy', this.get('location')); + } + }) + }); + + this.registerComponent('foo-bar-baz', { + template: 'foo-bar-baz {{location}} {{locationCopy}} {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('locationCopy', this.get('location')); + } + }) + }); + + this.registerComponent('outer-component', { + template: '{{#component componentName location=location}}arepas!{{/component}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + componentName: _emberMetal.computed('location', function () { + if (this.get('location') === 'Caracas') { + return 'foo-bar'; + } else { + return 'foo-bar-baz'; + } + }) + }) + }); + + this.render('{{outer-component location=location}}', { location: 'Caracas' }); + + this.assertText('foo-bar Caracas Caracas arepas!'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('foo-bar Caracas Caracas arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'location', 'Loisaida'); + }); + + this.assertText('foo-bar-baz Loisaida Loisaida arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'location', 'Caracas'); + }); + + this.assertText('foo-bar Caracas Caracas arepas!'); + }; + + _class.prototype['@test component helper with actions'] = function testComponentHelperWithActions(assert) { + var _this14 = this; + + this.registerComponent('inner-component', { + template: 'inner-component {{yield}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: 'inner-component', + didInsertElement: function () { + var _this13 = this; + + // trigger action on click in absence of app's EventDispatcher + this.$().on('click', function () { + _this13.sendAction('somethingClicked'); + }); + }, + willDestroyElement: function () { + this.$().off('click'); + } + }) + }); + + var actionTriggered = 0; + this.registerComponent('outer-component', { + template: '{{#component componentName somethingClicked="mappedAction"}}arepas!{{/component}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + classNames: 'outer-component', + componentName: 'inner-component', + actions: { + mappedAction: function () { + actionTriggered++; + } + } + }) + }); + + this.render('{{outer-component}}'); + + assert.equal(actionTriggered, 0, 'action was not triggered'); + + this.runTask(function () { + _this14.$('.inner-component').trigger('click'); + }); + + assert.equal(actionTriggered, 1, 'action was triggered'); + }; + + _class.prototype['@test nested component helpers'] = function testNestedComponentHelpers(assert) { + var _this15 = this; + + this.registerComponent('foo-bar', { template: 'yippie! {{attrs.location}} {{yield}}' }); + this.registerComponent('baz-qux', { template: 'yummy {{attrs.location}} {{yield}}' }); + this.registerComponent('corge-grault', { template: 'delicious {{attrs.location}} {{yield}}' }); + + this.render('{{#component componentName1 location=location}}{{#component componentName2 location=location}}arepas!{{/component}}{{/component}}', { + componentName1: 'foo-bar', + componentName2: 'baz-qux', + location: 'Caracas' + }); + + this.assertText('yippie! Caracas yummy Caracas arepas!'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertText('yippie! Caracas yummy Caracas arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'location', 'Loisaida'); + }); + + this.assertText('yippie! Loisaida yummy Loisaida arepas!'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'componentName1', 'corge-grault'); + }); + + this.assertText('delicious Loisaida yummy Loisaida arepas!'); + + this.runTask(function () { + _emberMetal.set(_this15.context, 'componentName1', 'foo-bar'); + _emberMetal.set(_this15.context, 'location', 'Caracas'); + }); + + this.assertText('yippie! Caracas yummy Caracas arepas!'); + }; + + _class.prototype['@test component with dynamic name argument resolving to non-existent component'] = function testComponentWithDynamicNameArgumentResolvingToNonExistentComponent(assert) { + var _this16 = this; + + expectAssertion(function () { + _this16.render('{{component componentName}}', { componentName: 'does-not-exist' }); + }, /Could not find component named "does-not-exist"/); + }; + + _class.prototype['@test component with static name argument for non-existent component'] = function testComponentWithStaticNameArgumentForNonExistentComponent(assert) { + var _this17 = this; + + expectAssertion(function () { + _this17.render('{{component "does-not-exist"}}'); + }, /Could not find component named "does-not-exist"/); + }; + + _class.prototype['@test component with dynamic component name resolving to a component, then non-existent component'] = function testComponentWithDynamicComponentNameResolvingToAComponentThenNonExistentComponent(assert) { + var _this18 = this; + + this.registerComponent('foo-bar', { template: 'hello {{name}}' }); + + this.render('{{component componentName name=name}}', { componentName: 'foo-bar', name: 'Alex' }); + + this.assertText('hello Alex'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('hello Alex'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'componentName', undefined); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'componentName', 'foo-bar'); + }); + + this.assertText('hello Alex'); + }; + + _class.prototype['@test component helper properly invalidates hash params inside an {{each}} invocation #11044'] = function testComponentHelperProperlyInvalidatesHashParamsInsideAnEachInvocation11044(assert) { + var _this19 = this; + + this.registerComponent('foo-bar', { + template: '[{{internalName}} - {{name}}]', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willRender: function () { + // store internally available name to ensure that the name available in `this.attrs.name` + // matches the template lookup name + _emberMetal.set(this, 'internalName', this.get('name')); + } + }) + }); + + this.render('{{#each items as |item|}}{{component "foo-bar" name=item.name}}{{/each}}', { + items: [{ name: 'Robert' }, { name: 'Jacquie' }] + }); + + this.assertText('[Robert - Robert][Jacquie - Jacquie]'); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertText('[Robert - Robert][Jacquie - Jacquie]'); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'items', [{ name: 'Max' }, { name: 'James' }]); + }); + + this.assertText('[Max - Max][James - James]'); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'items', [{ name: 'Robert' }, { name: 'Jacquie' }]); + }); + + this.assertText('[Robert - Robert][Jacquie - Jacquie]'); + }; + + _class.prototype['@test dashless components should not be found'] = function testDashlessComponentsShouldNotBeFound(assert) { + var _this20 = this; + + this.registerComponent('dashless2', { template: 'Do not render me!' }); + + expectAssertion(function () { + _this20.render('{{component "dashless"}}'); + }, /You cannot use 'dashless' as a component name. Component names must contain a hyphen./); + }; + + _class.prototype['@test positional parameters does not clash when rendering different components'] = function testPositionalParametersDoesNotClashWhenRenderingDifferentComponents(assert) { + var _this21 = this; + + this.registerComponent('foo-bar', { + template: 'hello {{name}} ({{age}}) from foo-bar', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }) + }); + + this.registerComponent('foo-bar-baz', { + template: 'hello {{name}} ({{age}}) from foo-bar-baz', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['name', 'age'] + }) + }); + + this.render('{{component componentName name age}}', { + componentName: 'foo-bar', + name: 'Alex', + age: 29 + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'name', 'Ben'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben (29) from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'age', 22); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar' }); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'componentName', 'foo-bar-baz'); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar-baz' }); + + this.runTask(function () { + _emberMetal.set(_this21.context, 'componentName', 'foo-bar'); + _emberMetal.set(_this21.context, 'name', 'Alex'); + _emberMetal.set(_this21.context, 'age', 29); + }); + + this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); + }; + + _class.prototype['@test positional parameters does not pollute the attributes when changing components'] = function testPositionalParametersDoesNotPolluteTheAttributesWhenChangingComponents(assert) { + var _this22 = this; + + this.registerComponent('normal-message', { + template: 'Normal: {{something}}!', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: ['something'] + }) + }); + + this.registerComponent('alternative-message', { + template: 'Alternative: {{something}} {{somethingElse}}!', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + something: 'Another' + }).reopenClass({ + positionalParams: ['somethingElse'] + }) + }); + + this.render('{{component componentName message}}', { componentName: 'normal-message', message: 'Hello' }); + + this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'componentName', 'alternative-message'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hello!' }); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'message', 'Hi'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hi!' }); + + this.runTask(function () { + _emberMetal.set(_this22.context, 'componentName', 'normal-message'); + _emberMetal.set(_this22.context, 'message', 'Hello'); + }); + + this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); + }; + + _class.prototype['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters(assert) { + var _this23 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'names' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2) + }); + + this.render('{{component "sample-component" "Foo" 4 "Bar" 5 "Baz" elementId="helper"}}'); + + this.assertText('Foo4Bar5Baz'); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText('Foo4Bar5Baz'); + }; + + _class.prototype['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters(assert) { + var _this24 = this; + + this.registerComponent('sample-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend().reopenClass({ + positionalParams: 'n' + }), + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3) + }); + + this.render('{{component "sample-component" user1 user2}}', { + user1: 'Foo', + user2: 4 + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText('Foo4'); + + this.runTask(function () { + return _this24.context.set('user1', 'Bar'); + }); + + this.assertText('Bar4'); + + this.runTask(function () { + return _this24.context.set('user2', '5'); + }); + + this.assertText('Bar5'); + + this.runTask(function () { + _this24.context.set('user1', 'Foo'); + _this24.context.set('user2', 4); + }); + + this.assertText('Foo4'); + }; + + _class.prototype['@test component helper emits useful backtracking re-render assertion message'] = function testComponentHelperEmitsUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this25 = this; + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person', { name: 'Alex' }); + } + }), + template: 'Hi {{person.name}}! {{component "error-component" person=person}}' + }); + + this.registerComponent('error-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person.name', { name: 'Ben' }); + } + }), + template: '{{person.name}}' + }); + + var expectedBacktrackingMessage = /modified "person\.name" twice on \[object Object\] in a single render\. It was rendered in "component:outer-component" and modified in "component:error-component"/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + this.render('{{component componentName}}', { componentName: 'outer-component' }); + } else { + expectAssertion(function () { + _this25.render('{{component componentName}}', { componentName: 'outer-component' }); + }, expectedBacktrackingMessage); + } + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/dynamic-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/dynamic-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/dynamic-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/fragment-components-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['
    Hey
    bar'], ['
    Hey
    bar']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['bar'], ['bar']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['bizz'], ['bizz']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: fragment components', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { + return { + hitDem: 'folks' + }; + }; + + _class.prototype['@test fragments do not render an outer tag'] = function testFragmentsDoNotRenderAnOuterTag() { + var instance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + init: function () { + this._super(); + instance = this; + this.foo = true; + this.bar = 'bar'; + } + }); + + var template = '{{#if foo}}
    Hey
    {{/if}}{{yield bar}}'; + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + this.render('{{#foo-bar as |bar|}}{{bar}}{{/foo-bar}}'); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(instance, 'foo', false); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.runTask(function () { + return _emberMetal.set(instance, 'bar', 'bizz'); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + _emberMetal.set(instance, 'bar', 'bar'); + _emberMetal.set(instance, 'foo', true); + }); + }; + + _class.prototype['@test throws an error if an event function is defined in a tagless component'] = function testThrowsAnErrorIfAnEventFunctionIsDefinedInATaglessComponent() { + var _this = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + click: function () {} + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You can not define a function that handles DOM events in the .* tagless component since it doesn't have any DOM element./); + }; + + _class.prototype['@test throws an error if a custom defined event function is defined in a tagless component'] = function testThrowsAnErrorIfACustomDefinedEventFunctionIsDefinedInATaglessComponent() { + var _this2 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + folks: function () {} + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this2.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You can not define a function that handles DOM events in the .* tagless component since it doesn't have any DOM element./); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `classNameBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndClassNameBindingsAreSpecified() { + var _this3 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + foo: true, + classNameBindings: ['foo:is-foo:is-bar'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this3.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot use `classNameBindings` on a tag-less component/); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `attributeBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndAttributeBindingsAreSpecified() { + var _this4 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + attributeBindings: ['href'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + expectAssertion(function () { + _this4.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot use `attributeBindings` on a tag-less component/); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `elementId` is specified via JS'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaJS() { + var _this5 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + elementId: 'turntUp' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + expectAssertion(function () { + _this5.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot use `elementId` on a tag-less component/); + }; + + _class.prototype['@test throws an error if `tagName` is an empty string and `elementId` is specified via template'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaTemplate() { + var _this6 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + expectAssertion(function () { + _this6.render('{{#foo-bar elementId=\'turntUp\'}}{{/foo-bar}}'); + }, /You cannot use `elementId` on a tag-less component/); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via JS'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaJS() { + var template = '{{id}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + id: 'baz' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + this.render('{{#foo-bar}}{{/foo-bar}}'); + this.assertText('baz'); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via template'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaTemplate() { + var template = '{{id}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + this.render('{{#foo-bar id=\'baz\'}}{{/foo-bar}}'); + this.assertText('baz'); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is bound property specified via template'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsBoundPropertySpecifiedViaTemplate() { + var _this7 = this; + + var template = '{{id}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + this.render('{{#foo-bar id=fooBarId}}{{/foo-bar}}', { fooBarId: 'baz' }); + + this.assertText('baz'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'fooBarId', 'qux'); + }); + + this.assertText('qux'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'fooBarId', 'baz'); + }); + + this.assertText('baz'); + }; + + _class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via template and passed to child component'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaTemplateAndPassedToChildComponent() { + var fooBarTemplate = '{{#baz-child id=id}}{{/baz-child}}'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }); + var BazChildComponent = _emberGlimmerTestsUtilsHelpers.Component.extend(); + var bazChildTemplate = '{{id}}'; + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: fooBarTemplate }); + this.registerComponent('baz-child', { ComponentClass: BazChildComponent, template: bazChildTemplate }); + this.render('{{#foo-bar id=\'baz\'}}{{/foo-bar}}'); + this.assertText('baz'); + }; + + _class.prototype['@test throws an error if when $() is accessed on component where `tagName` is an empty string'] = function testThrowsAnErrorIfWhen$IsAccessedOnComponentWhereTagNameIsAnEmptyString() { + var _this8 = this; + + var template = 'hit dem folks'; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + init: function () { + this._super(); + this.$(); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); + + expectAssertion(function () { + _this8.render('{{#foo-bar}}{{/foo-bar}}'); + }, /You cannot access this.\$\(\) on a component with `tagName: \'\'` specified/); + }; + + _class.prototype['@test renders a contained view with omitted start tag and tagless parent view context'] = function testRendersAContainedViewWithOmittedStartTagAndTaglessParentViewContext() { + var _this9 = this; + + this.registerComponent('root-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'section' + }), + template: '{{frag-ment}}' + }); + + this.registerComponent('frag-ment', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + template: '{{my-span}}' + }); + + this.registerComponent('my-span', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'span' + }), + template: 'dab' + }); + + this.render('{{root-component}}'); + + this.assertElement(this.firstChild, { tagName: 'section' }); + this.assertElement(this.firstChild.firstElementChild, { tagName: 'span' }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'section' }); + this.assertElement(this.firstChild.firstElementChild, { tagName: 'span' }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/fragment-components-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/fragment-components-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/fragment-components-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/instrumentation-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components instrumentation', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + var _this = this; + + _RenderingTest.call(this); + + this.resetEvents(); + + _emberMetal.instrumentationSubscribe('render.component', { + before: function (name, timestamp, payload) { + if (payload.view !== _this.component) { + _this.actual.before.push(payload); + } + }, + after: function (name, timestamp, payload) { + if (payload.view !== _this.component) { + _this.actual.after.push(payload); + } + } + }); + } + + _class.prototype.resetEvents = function resetEvents() { + this.expected = { + before: [], + after: [] + }; + + this.actual = { + before: [], + after: [] + }; + }; + + _class.prototype.teardown = function teardown() { + this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)'); + this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)'); + _RenderingTest.prototype.teardown.call(this); + _emberMetal.instrumentationReset(); + }; + + _class.prototype['@test zomg'] = function testZomg(assert) { + assert.ok(true); + }; + + _class.prototype['@test it should receive an instrumentation event for both initial render and updates'] = function testItShouldReceiveAnInstrumentationEventForBothInitialRenderAndUpdates(assert) { + var _this2 = this; + + var testCase = this; + + var BaseClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + + willRender: function () { + testCase.expected.before.push(this); + testCase.expected.after.unshift(this); + } + }); + + this.registerComponent('x-bar', { + template: '[x-bar: {{bar}}] {{yield}}', + ComponentClass: BaseClass.extend() + }); + + this.registerComponent('x-baz', { + template: '[x-baz: {{baz}}]', + ComponentClass: BaseClass.extend() + }); + + this.registerComponent('x-bat', { + template: '[x-bat: {{bat}}]', + ComponentClass: BaseClass.extend() + }); + + this.render('[-top-level: {{foo}}] {{#x-bar bar=bar}}{{x-baz baz=baz}}{{/x-bar}} {{x-bat bat=bat}}', { + foo: 'foo', bar: 'bar', baz: 'baz', bat: 'bat' + }); + + this.assertText('[-top-level: foo] [x-bar: bar] [x-baz: baz] [x-bat: bat]'); + + this.assertEvents('after initial render', true); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertEvents('after no-op rerender'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'foo', 'FOO'); + }); + + this.assertEvents('after updating top-level'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'baz', 'BAZ'); + }); + + this.assertEvents('after updating inner-most'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'bar', 'BAR'); + _emberMetal.set(_this2.context, 'bat', 'BAT'); + }); + + this.assertEvents('after updating the rest'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'foo', 'FOO'); + _emberMetal.set(_this2.context, 'bar', 'BAR'); + _emberMetal.set(_this2.context, 'baz', 'BAZ'); + _emberMetal.set(_this2.context, 'bat', 'BAT'); + }); + + this.assertEvents('after reset'); + }; + + _class.prototype.assertEvents = function assertEvents(label) { + var initialRender = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + var actual = this.actual; + var expected = this.expected; + + this.assert.strictEqual(actual.before.length, actual.after.length, label + ': before and after callbacks should be balanced'); + + this._assertEvents(label + ' (before):', actual.before, expected.before, initialRender); + this._assertEvents(label + ' (after):', actual.before, expected.before, initialRender); + + this.resetEvents(); + }; + + _class.prototype._assertEvents = function _assertEvents(label, actual, expected, initialRender) { + var _this3 = this; + + this.assert.equal(actual.length, expected.length, label + ': expected ' + expected.length + ' and got ' + actual.length); + + actual.forEach(function (payload, i) { + return _this3.assertPayload(payload, expected[i], initialRender); + }); + }; + + _class.prototype.assertPayload = function assertPayload(payload, component, initialRender) { + this.assert.equal(payload.object, component.toString(), 'payload.object'); + this.assert.ok(payload.containerKey, 'the container key should be present'); + this.assert.equal(payload.containerKey, component._debugContainerKey, 'payload.containerKey'); + this.assert.equal(payload.view, component, 'payload.view'); + this.assert.strictEqual(payload.initialRender, initialRender, 'payload.initialRender'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/instrumentation-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/instrumentation-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/instrumentation-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/life-cycle-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-views', 'ember-glimmer/tests/utils/test-helpers', 'ember-utils', 'internal-test-helpers'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberViews, _emberGlimmerTestsUtilsTestHelpers, _emberUtils, _internalTestHelpers) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n Twitter: {{', '}}|\n ', '\n
    '], ['\n
    \n Twitter: {{', '}}|\n ', '\n
    ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n Name: {{', '}}|\n ', '\n
    '], ['\n
    \n Name: {{', '}}|\n ', '\n
    ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n Website: {{', '}}\n
    '], ['\n
    \n Website: {{', '}}\n
    ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n ', '|\n ', '|\n ', '\n
    '], ['\n
    \n ', '|\n ', '|\n ', '\n
    ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n Top: ', '\n
    '], ['\n
    \n Top: ', '\n
    ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n Middle: ', '\n
    '], ['\n
    \n Middle: ', '\n
    ']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n Bottom: {{', '}}\n
    '], ['\n
    \n Bottom: {{', '}}\n
    ']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#nested-item}}Item: {{count}}{{/nested-item}}\n '], ['\n {{#nested-item}}Item: {{count}}{{/nested-item}}\n ']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#nested-item}}Nothing to see here{{/nested-item}}\n '], ['\n {{#nested-item}}Nothing to see here{{/nested-item}}\n ']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each items as |item|}}\n ', '\n {{else}}\n ', '\n {{/each}}\n '], ['\n {{#each items as |item|}}\n ', '\n {{else}}\n ', '\n {{/each}}\n ']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n {{yield}}\n
      \n {{#nested-component nestedId=(concat itemId \'-A\')}}A{{/nested-component}}\n {{#nested-component nestedId=(concat itemId \'-B\')}}B{{/nested-component}}\n
    \n '], ['\n {{yield}}\n
      \n {{#nested-component nestedId=(concat itemId \'-A\')}}A{{/nested-component}}\n {{#nested-component nestedId=(concat itemId \'-B\')}}B{{/nested-component}}\n
    \n ']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each items as |item|}}\n {{#parent-component itemId=item.id}}{{item.id}}{{/parent-component}}\n {{/each}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=6}}6{{/parent-component}}\n {{/if}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=7}}7{{/parent-component}}\n {{/if}}\n '], ['\n {{#each items as |item|}}\n {{#parent-component itemId=item.id}}{{item.id}}{{/parent-component}}\n {{/each}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=6}}6{{/parent-component}}\n {{/if}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=7}}7{{/parent-component}}\n {{/if}}\n ']); + + var LifeCycleHooksTest = (function (_RenderingTest) { +babelHelpers.inherits(LifeCycleHooksTest, _RenderingTest); + + function LifeCycleHooksTest() { + _RenderingTest.call(this); + this.hooks = []; + this.components = {}; + this.componentRegistry = []; + this.teardownAssertions = []; + } + + LifeCycleHooksTest.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + + for (var i = 0; i < this.teardownAssertions.length; i++) { + this.teardownAssertions[i](); + } + }; + + LifeCycleHooksTest.prototype.getBootOptions = function getBootOptions() { + return { + isInteractive: this.isInteractive + }; + }; + + /* abstract */ + + /* abstract */ + + LifeCycleHooksTest.prototype.invocationFor = function invocationFor(name) { + var namedArgs = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + throw new Error('Not implemented: `invocationFor`'); + }; + + /* abstract */ + + LifeCycleHooksTest.prototype.attrFor = function attrFor(name) { + throw new Error('Not implemented: `attrFor`'); + }; + + LifeCycleHooksTest.prototype.assertRegisteredViews = function assertRegisteredViews(label) { + var viewRegistry = this.owner.lookup('-view-registry:main'); + var topLevelId = _emberViews.getViewId(this.component); + var actual = Object.keys(viewRegistry).sort().filter(function (id) { + return id !== topLevelId; + }); + + if (this.isInteractive) { + var expected = this.componentRegistry.sort(); + + this.assert.deepEqual(actual, expected, 'registered views - ' + label); + } else { + this.assert.deepEqual(actual, [], 'no views should be registered for non-interactive mode'); + } + }; + + LifeCycleHooksTest.prototype.registerComponent = function registerComponent(name, _ref) { + var _this = this; + + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; + + var pushComponent = function (instance) { + _this.components[name] = instance; + _this.componentRegistry.push(_emberViews.getViewId(instance)); + }; + + var removeComponent = function (instance) { + var index = _this.componentRegistry.indexOf(instance); + _this.componentRegistry.splice(index, 1); + + delete _this.components[name]; + }; + + var pushHook = function (hookName, args) { + _this.hooks.push(hook(name, hookName, args)); + }; + + var assertParentView = function (hookName, instance) { + _this.assert.ok(instance.parentView, 'parentView should be present in ' + hookName); + + if (hookName === 'willDestroyElement') { + _this.assert.ok(instance.parentView.childViews.indexOf(instance) !== -1, 'view is still connected to parentView in ' + hookName); + } + }; + + var assertElement = function (hookName, instance) { + var inDOM = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; + + if (instance.tagName === '') { + return; + } + + _this.assert.ok(_emberViews.getViewElement(instance), 'element should be present on ' + instance + ' during ' + hookName); + + if (_this.isInteractive) { + _this.assert.ok(instance.element, 'this.element should be present on ' + instance + ' during ' + hookName); + _this.assert.equal(document.body.contains(instance.element), inDOM, 'element for ' + instance + ' ' + (inDOM ? 'should' : 'should not') + ' be in the DOM during ' + hookName); + } else { + _this.assert.throws(function () { + return instance.element; + }, /Accessing `this.element` is not allowed in non-interactive environments/); + } + }; + + var assertNoElement = function (hookName, instance) { + _this.assert.strictEqual(_emberViews.getViewElement(instance), null, 'element should not be present in ' + hookName); + + if (_this.isInteractive) { + _this.assert.strictEqual(instance.element, null, 'this.element should not be present in ' + hookName); + } else { + _this.assert.throws(function () { + return instance.element; + }, /Accessing `this.element` is not allowed in non-interactive environments/); + } + }; + + var assertState = function (hookName, expectedState, instance) { + _this.assert.equal(instance._state, expectedState, 'within ' + hookName + ' the expected _state is ' + expectedState); + }; + + var isInteractive = this.isInteractive; + + var ComponentClass = this.ComponentClass.extend({ + init: function () { + var _this2 = this, + _arguments = arguments; + + expectDeprecation(function () { + _this2._super.apply(_this2, _arguments); + }, /didInitAttrs called/); + + this.isInitialRender = true; + this.componentName = name; + pushHook('init'); + pushComponent(this); + assertParentView('init', this); + assertNoElement('init', this); + assertState('init', 'preRender', this); + + this.on('init', function () { + return pushHook('on(init)'); + }); + + _emberMetal.run.scheduleOnce('afterRender', function () { + _this2.isInitialRender = false; + }); + }, + + didInitAttrs: function (options) { + pushHook('didInitAttrs', options); + assertParentView('didInitAttrs', this); + assertNoElement('didInitAttrs', this); + assertState('didInitAttrs', 'preRender', this); + }, + + didReceiveAttrs: function (options) { + pushHook('didReceiveAttrs', options); + assertParentView('didReceiveAttrs', this); + + if (this.isInitialRender) { + assertNoElement('didReceiveAttrs', this); + assertState('didReceiveAttrs', 'preRender', this); + } else { + assertElement('didReceiveAttrs', this); + + if (isInteractive) { + assertState('didReceiveAttrs', 'inDOM', this); + } else { + assertState('didReceiveAttrs', 'hasElement', this); + } + } + }, + + willInsertElement: function () { + pushHook('willInsertElement'); + assertParentView('willInsertElement', this); + assertElement('willInsertElement', this, false); + assertState('willInsertElement', 'hasElement', this); + }, + + willRender: function () { + pushHook('willRender'); + assertParentView('willRender', this); + + if (this.isInitialRender) { + assertNoElement('willRender', this, false); + assertState('willRender', 'preRender', this); + } else { + assertElement('willRender', this); + assertState('willRender', 'inDOM', this); + } + }, + + didInsertElement: function () { + pushHook('didInsertElement'); + assertParentView('didInsertElement', this); + assertElement('didInsertElement', this); + assertState('didInsertElement', 'inDOM', this); + }, + + didRender: function () { + pushHook('didRender'); + assertParentView('didRender', this); + assertElement('didRender', this); + assertState('didRender', 'inDOM', this); + }, + + didUpdateAttrs: function (options) { + pushHook('didUpdateAttrs', options); + assertParentView('didUpdateAttrs', this); + + if (isInteractive) { + assertState('didUpdateAttrs', 'inDOM', this); + } else { + assertState('didUpdateAttrs', 'hasElement', this); + } + }, + + willUpdate: function (options) { + pushHook('willUpdate', options); + assertParentView('willUpdate', this); + assertElement('willUpdate', this); + assertState('willUpdate', 'inDOM', this); + }, + + didUpdate: function (options) { + pushHook('didUpdate', options); + assertParentView('didUpdate', this); + assertElement('didUpdate', this); + assertState('didUpdate', 'inDOM', this); + }, + + willDestroyElement: function () { + pushHook('willDestroyElement'); + assertParentView('willDestroyElement', this); + assertElement('willDestroyElement', this); + assertState('willDestroyElement', 'inDOM', this); + }, + + willClearRender: function () { + pushHook('willClearRender'); + assertParentView('willClearRender', this); + assertElement('willClearRender', this); + assertState('willClearRender', 'inDOM', this); + }, + + didDestroyElement: function () { + pushHook('didDestroyElement'); + assertNoElement('didDestroyElement', this); + assertState('didDestroyElement', 'destroying', this); + }, + + willDestroy: function () { + pushHook('willDestroy'); + removeComponent(this); + + this._super.apply(this, arguments); + } + }); + + _RenderingTest.prototype.registerComponent.call(this, name, { ComponentClass: ComponentClass, template: template }); + }; + + LifeCycleHooksTest.prototype.assertHooks = function assertHooks(_ref2) { + var label = _ref2.label; + var interactive = _ref2.interactive; + var nonInteractive = _ref2.nonInteractive; + + var rawHooks = this.isInteractive ? interactive : nonInteractive; + var hooks = rawHooks.map(function (raw) { + return hook.apply(undefined, raw); + }); + this.assert.deepEqual(json(this.hooks), json(hooks), label); + this.hooks = []; + }; + + LifeCycleHooksTest.prototype['@test lifecycle hooks are invoked in a predictable order'] = function testLifecycleHooksAreInvokedInAPredictableOrder() { + var _this3 = this; + + var _boundHelpers = this.boundHelpers; + var attr = _boundHelpers.attr; + var invoke = _boundHelpers.invoke; + + this.registerComponent('the-top', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, attr('twitter'), invoke('the-middle', { name: string('Tom Dale') })) + }); + + this.registerComponent('the-middle', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, attr('name'), invoke('the-bottom', { website: string('tomdale.net') })) + }); + + this.registerComponent('the-bottom', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3, attr('website')) + }); + + this.render(invoke('the-top', { twitter: expr('twitter') }), { twitter: '@tomdale' }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + this.assertRegisteredViews('intial render'); + + var topAttrs = { twitter: '@tomdale' }; + var middleAttrs = { name: 'Tom Dale' }; + var bottomAttrs = { website: 'tomdale.net' }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [ + // Sync hooks + + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)'], ['the-bottom', 'willRender'], ['the-bottom', 'willInsertElement'], + + // Async hooks + + ['the-bottom', 'didInsertElement'], ['the-bottom', 'didRender'], ['the-middle', 'didInsertElement'], ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)']] + }); + + this.runTask(function () { + return _this3.components['the-bottom'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (bottom)', + + interactive: [ + // Sync hooks + ['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], ['the-bottom', 'willUpdate'], ['the-bottom', 'willRender'], + + // Async hooks + + ['the-bottom', 'didUpdate'], ['the-bottom', 'didRender'], ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this3.components['the-middle'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (middle)', + + interactive: [ + // Sync hooks + + ['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], + + // Async hooks + + ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this3.components['the-top'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (top)', + + interactive: [ + // Sync hooks + + ['the-top', 'willUpdate'], ['the-top', 'willRender'], + + // Async hooks + + ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'twitter', '@horsetomdale'); + }); + + this.assertText('Twitter: @horsetomdale|Name: Tom Dale|Website: tomdale.net'); + + // Because the `twitter` attr is only used by the topmost component, + // and not passed down, we do not expect to see lifecycle hooks + // called for child components. If the `didReceiveAttrs` hook used + // the new attribute to rerender itself imperatively, that would result + // in lifecycle hooks being invoked for the child. + + topAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + + this.assertHooks({ + label: 'after update', + + interactive: [ + // Sync hooks + + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs], ['the-top', 'willUpdate'], ['the-top', 'willRender'], + + // Async hooks + + ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs]] + }); + + this.teardownAssertions.push(function () { + _this3.assertHooks({ + label: 'destroy', + + interactive: [['the-top', 'willDestroyElement'], ['the-top', 'willClearRender'], ['the-middle', 'willDestroyElement'], ['the-middle', 'willClearRender'], ['the-bottom', 'willDestroyElement'], ['the-bottom', 'willClearRender'], ['the-top', 'didDestroyElement'], ['the-middle', 'didDestroyElement'], ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']], + + nonInteractive: [['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']] + }); + + _this3.assertRegisteredViews('after destroy'); + }); + }; + + LifeCycleHooksTest.prototype['@test lifecycle hooks are invoked in a correct sibling order'] = function testLifecycleHooksAreInvokedInACorrectSiblingOrder() { + var _this4 = this; + + var _boundHelpers2 = this.boundHelpers; + var attr = _boundHelpers2.attr; + var invoke = _boundHelpers2.invoke; + + this.registerComponent('the-parent', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4, invoke('the-first-child', { twitter: expr(attr('twitter')) }), invoke('the-second-child', { name: expr(attr('name')) }), invoke('the-last-child', { website: expr(attr('website')) })) + }); + + this.registerComponent('the-first-child', { template: 'Twitter: {{' + attr('twitter') + '}}' }); + + this.registerComponent('the-second-child', { template: 'Name: {{' + attr('name') + '}}' }); + + this.registerComponent('the-last-child', { template: 'Website: {{' + attr('website') + '}}' }); + + this.render(invoke('the-parent', { + twitter: expr('twitter'), + name: expr('name'), + website: expr('website') + }), { + twitter: '@tomdale', + name: 'Tom Dale', + website: 'tomdale.net' + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + this.assertRegisteredViews('intial render'); + + var parentAttrs = { twitter: '@tomdale', name: 'Tom Dale', website: 'tomdale.net' }; + var firstAttrs = { twitter: '@tomdale' }; + var secondAttrs = { name: 'Tom Dale' }; + var lastAttrs = { website: 'tomdale.net' }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [ + // Sync hooks + + ['the-parent', 'init'], ['the-parent', 'didInitAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'didReceiveAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'on(init)'], ['the-parent', 'willRender'], ['the-parent', 'willInsertElement'], ['the-first-child', 'init'], ['the-first-child', 'didInitAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'didReceiveAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'on(init)'], ['the-first-child', 'willRender'], ['the-first-child', 'willInsertElement'], ['the-second-child', 'init'], ['the-second-child', 'didInitAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'didReceiveAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'on(init)'], ['the-second-child', 'willRender'], ['the-second-child', 'willInsertElement'], ['the-last-child', 'init'], ['the-last-child', 'didInitAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'didReceiveAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'on(init)'], ['the-last-child', 'willRender'], ['the-last-child', 'willInsertElement'], + + // Async hooks + + ['the-first-child', 'didInsertElement'], ['the-first-child', 'didRender'], ['the-second-child', 'didInsertElement'], ['the-second-child', 'didRender'], ['the-last-child', 'didInsertElement'], ['the-last-child', 'didRender'], ['the-parent', 'didInsertElement'], ['the-parent', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-parent', 'init'], ['the-parent', 'didInitAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'didReceiveAttrs', { attrs: parentAttrs, newAttrs: parentAttrs }], ['the-parent', 'on(init)'], ['the-first-child', 'init'], ['the-first-child', 'didInitAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'didReceiveAttrs', { attrs: firstAttrs, newAttrs: firstAttrs }], ['the-first-child', 'on(init)'], ['the-second-child', 'init'], ['the-second-child', 'didInitAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'didReceiveAttrs', { attrs: secondAttrs, newAttrs: secondAttrs }], ['the-second-child', 'on(init)'], ['the-last-child', 'init'], ['the-last-child', 'didInitAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'didReceiveAttrs', { attrs: lastAttrs, newAttrs: lastAttrs }], ['the-last-child', 'on(init)']] + }); + + this.runTask(function () { + return _this4.components['the-first-child'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (first child)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-first-child', 'willUpdate'], ['the-first-child', 'willRender'], + + // Async hooks + + ['the-first-child', 'didUpdate'], ['the-first-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this4.components['the-second-child'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (second child)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-second-child', 'willUpdate'], ['the-second-child', 'willRender'], + + // Async hooks + + ['the-second-child', 'didUpdate'], ['the-second-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this4.components['the-last-child'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (last child)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-last-child', 'willUpdate'], ['the-last-child', 'willRender'], + + // Async hooks + + ['the-last-child', 'didUpdate'], ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _this4.components['the-parent'].rerender(); + }); + + this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); + + this.assertHooks({ + label: 'after no-op rerender (parent)', + + interactive: [ + // Sync hooks + + ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], + + // Async hooks + + ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [] + }); + + this.runTask(function () { + return _emberMetal.setProperties(_this4.context, { + twitter: '@horsetomdale', + name: 'Horse Tom Dale', + website: 'horsetomdale.net' + }); + }); + + this.assertText('Twitter: @horsetomdale|Name: Horse Tom Dale|Website: horsetomdale.net'); + + parentAttrs = { + attrs: { twitter: '@horsetomdale', name: 'Horse Tom Dale', website: 'horsetomdale.net' }, + oldAttrs: { twitter: '@tomdale', name: 'Tom Dale', website: 'tomdale.net' }, + newAttrs: { twitter: '@horsetomdale', name: 'Horse Tom Dale', website: 'horsetomdale.net' } + }; + firstAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + secondAttrs = { attrs: { name: 'Horse Tom Dale' }, oldAttrs: { name: 'Tom Dale' }, newAttrs: { name: 'Horse Tom Dale' } }; + lastAttrs = { attrs: { website: 'horsetomdale.net' }, oldAttrs: { website: 'tomdale.net' }, newAttrs: { website: 'horsetomdale.net' } }; + + this.assertHooks({ + label: 'after update', + + interactive: [ + // Sync hooks + + ['the-parent', 'didUpdateAttrs', parentAttrs], ['the-parent', 'didReceiveAttrs', parentAttrs], ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-first-child', 'didUpdateAttrs', firstAttrs], ['the-first-child', 'didReceiveAttrs', firstAttrs], ['the-first-child', 'willUpdate'], ['the-first-child', 'willRender'], ['the-second-child', 'didUpdateAttrs', secondAttrs], ['the-second-child', 'didReceiveAttrs', secondAttrs], ['the-second-child', 'willUpdate'], ['the-second-child', 'willRender'], ['the-last-child', 'didUpdateAttrs', lastAttrs], ['the-last-child', 'didReceiveAttrs', lastAttrs], ['the-last-child', 'willUpdate'], ['the-last-child', 'willRender'], + + // Async hooks + + ['the-first-child', 'didUpdate'], ['the-first-child', 'didRender'], ['the-second-child', 'didUpdate'], ['the-second-child', 'didRender'], ['the-last-child', 'didUpdate'], ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-parent', 'didUpdateAttrs', parentAttrs], ['the-parent', 'didReceiveAttrs', parentAttrs], ['the-first-child', 'didUpdateAttrs', firstAttrs], ['the-first-child', 'didReceiveAttrs', firstAttrs], ['the-second-child', 'didUpdateAttrs', secondAttrs], ['the-second-child', 'didReceiveAttrs', secondAttrs], ['the-last-child', 'didUpdateAttrs', lastAttrs], ['the-last-child', 'didReceiveAttrs', lastAttrs]] + }); + + this.teardownAssertions.push(function () { + _this4.assertHooks({ + label: 'destroy', + + interactive: [['the-parent', 'willDestroyElement'], ['the-parent', 'willClearRender'], ['the-first-child', 'willDestroyElement'], ['the-first-child', 'willClearRender'], ['the-second-child', 'willDestroyElement'], ['the-second-child', 'willClearRender'], ['the-last-child', 'willDestroyElement'], ['the-last-child', 'willClearRender'], ['the-parent', 'didDestroyElement'], ['the-first-child', 'didDestroyElement'], ['the-second-child', 'didDestroyElement'], ['the-last-child', 'didDestroyElement'], ['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], ['the-last-child', 'willDestroy']], + + nonInteractive: [['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], ['the-last-child', 'willDestroy']] + }); + + _this4.assertRegisteredViews('after destroy'); + }); + }; + + LifeCycleHooksTest.prototype['@test passing values through attrs causes lifecycle hooks to fire if the attribute values have changed'] = function testPassingValuesThroughAttrsCausesLifecycleHooksToFireIfTheAttributeValuesHaveChanged() { + var _this5 = this; + + var _boundHelpers3 = this.boundHelpers; + var attr = _boundHelpers3.attr; + var invoke = _boundHelpers3.invoke; + + this.registerComponent('the-top', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5, invoke('the-middle', { twitterTop: expr(attr('twitter')) })) + }); + + this.registerComponent('the-middle', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6, invoke('the-bottom', { twitterMiddle: expr(attr('twitterTop')) })) + }); + + this.registerComponent('the-bottom', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7, attr('twitterMiddle')) + }); + + this.render(invoke('the-top', { twitter: expr('twitter') }), { twitter: '@tomdale' }); + + this.assertText('Top: Middle: Bottom: @tomdale'); + this.assertRegisteredViews('intial render'); + + var topAttrs = { twitter: '@tomdale' }; + var middleAttrs = { twitterTop: '@tomdale' }; + var bottomAttrs = { twitterMiddle: '@tomdale' }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [ + // Sync hooks + + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)'], ['the-bottom', 'willRender'], ['the-bottom', 'willInsertElement'], + + // Async hooks + + ['the-bottom', 'didInsertElement'], ['the-bottom', 'didRender'], ['the-middle', 'didInsertElement'], ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-top', 'init'], ['the-top', 'didInitAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'didReceiveAttrs', { attrs: topAttrs, newAttrs: topAttrs }], ['the-top', 'on(init)'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'didReceiveAttrs', { attrs: middleAttrs, newAttrs: middleAttrs }], ['the-middle', 'on(init)'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'didReceiveAttrs', { attrs: bottomAttrs, newAttrs: bottomAttrs }], ['the-bottom', 'on(init)']] + }); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'twitter', '@horsetomdale'); + }); + + this.assertText('Top: Middle: Bottom: @horsetomdale'); + + // Because the `twitter` attr is used by the all of the components, + // the lifecycle hooks are invoked for all components. + + topAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + middleAttrs = { attrs: { twitterTop: '@horsetomdale' }, oldAttrs: { twitterTop: '@tomdale' }, newAttrs: { twitterTop: '@horsetomdale' } }; + bottomAttrs = { attrs: { twitterMiddle: '@horsetomdale' }, oldAttrs: { twitterMiddle: '@tomdale' }, newAttrs: { twitterMiddle: '@horsetomdale' } }; + + this.assertHooks({ + label: 'after updating (root)', + + interactive: [ + // Sync hooks + + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs], ['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'didUpdateAttrs', middleAttrs], ['the-middle', 'didReceiveAttrs', middleAttrs], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], ['the-bottom', 'didUpdateAttrs', bottomAttrs], ['the-bottom', 'didReceiveAttrs', bottomAttrs], ['the-bottom', 'willUpdate'], ['the-bottom', 'willRender'], + + // Async hooks + + ['the-bottom', 'didUpdate'], ['the-bottom', 'didRender'], ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']], + + nonInteractive: [ + // Sync hooks + + ['the-top', 'didUpdateAttrs', topAttrs], ['the-top', 'didReceiveAttrs', topAttrs], ['the-middle', 'didUpdateAttrs', middleAttrs], ['the-middle', 'didReceiveAttrs', middleAttrs], ['the-bottom', 'didUpdateAttrs', bottomAttrs], ['the-bottom', 'didReceiveAttrs', bottomAttrs]] + }); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('Top: Middle: Bottom: @horsetomdale'); + + // In this case, because the attrs are passed down, all child components are invoked. + + topAttrs = { attrs: { twitter: '@horsetomdale' }, oldAttrs: { twitter: '@horsetomdale' }, newAttrs: { twitter: '@horsetomdale' } }; + middleAttrs = { attrs: { twitterTop: '@horsetomdale' }, oldAttrs: { twitterTop: '@horsetomdale' }, newAttrs: { twitterTop: '@horsetomdale' } }; + bottomAttrs = { attrs: { twitterMiddle: '@horsetomdale' }, oldAttrs: { twitterMiddle: '@horsetomdale' }, newAttrs: { twitterMiddle: '@horsetomdale' } }; + + this.assertHooks({ + label: 'after no-op rernder (root)', + interactive: [], + nonInteractive: [] + }); + + this.teardownAssertions.push(function () { + _this5.assertHooks({ + label: 'destroy', + + interactive: [['the-top', 'willDestroyElement'], ['the-top', 'willClearRender'], ['the-middle', 'willDestroyElement'], ['the-middle', 'willClearRender'], ['the-bottom', 'willDestroyElement'], ['the-bottom', 'willClearRender'], ['the-top', 'didDestroyElement'], ['the-middle', 'didDestroyElement'], ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']], + + nonInteractive: [['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']] + }); + + _this5.assertRegisteredViews('after destroy'); + }); + }; + + LifeCycleHooksTest.prototype['@test components rendered from `{{each}}` have correct life-cycle hooks to be called'] = function testComponentsRenderedFromEachHaveCorrectLifeCycleHooksToBeCalled() { + var _this6 = this; + + var invoke = this.boundHelpers.invoke; + + this.registerComponent('nested-item', { template: '{{yield}}' }); + + this.registerComponent('an-item', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8) }); + + this.registerComponent('no-items', { template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9) }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10, invoke('an-item', { count: expr('item') }), invoke('no-items')), { + items: [1, 2, 3, 4, 5] + }); + + this.assertText('Item: 1Item: 2Item: 3Item: 4Item: 5'); + this.assertRegisteredViews('intial render'); + + var initialHooks = function (count) { + var ret = [['an-item', 'init'], ['an-item', 'didInitAttrs', { attrs: { count: count }, newAttrs: { count: count } }], ['an-item', 'didReceiveAttrs', { attrs: { count: count }, newAttrs: { count: count } }], ['an-item', 'on(init)']]; + if (_this6.isInteractive) { + ret.push(['an-item', 'willRender'], ['an-item', 'willInsertElement']); + } + ret.push(['nested-item', 'init'], ['nested-item', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'on(init)']); + if (_this6.isInteractive) { + ret.push(['nested-item', 'willRender'], ['nested-item', 'willInsertElement']); + } + return ret; + }; + + var initialAfterRenderHooks = function (count) { + if (_this6.isInteractive) { + return [['nested-item', 'didInsertElement'], ['nested-item', 'didRender'], ['an-item', 'didInsertElement'], ['an-item', 'didRender']]; + } else { + return []; + } + }; + + this.assertHooks({ + label: 'after initial render', + + interactive: [].concat(initialHooks(1), initialHooks(2), initialHooks(3), initialHooks(4), initialHooks(5), initialAfterRenderHooks(5), initialAfterRenderHooks(4), initialAfterRenderHooks(3), initialAfterRenderHooks(2), initialAfterRenderHooks(1)), + + nonInteractive: [].concat(initialHooks(1), initialHooks(2), initialHooks(3), initialHooks(4), initialHooks(5), initialAfterRenderHooks(5), initialAfterRenderHooks(4), initialAfterRenderHooks(3), initialAfterRenderHooks(2), initialAfterRenderHooks(1)) + }); + + // TODO: Is this correct? Should childViews be populated in non-interactive mode? + if (this.isInteractive) { + this.assert.equal(this.component.childViews.length, 5, 'childViews precond'); + } + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'items', []); + }); + + // TODO: Is this correct? Should childViews be populated in non-interactive mode? + if (this.isInteractive) { + this.assert.equal(this.component.childViews.length, 1, 'childViews updated'); + } + + this.assertText('Nothing to see here'); + + this.assertHooks({ + label: 'reset to empty array', + + interactive: [['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['no-items', 'init'], ['no-items', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'on(init)'], ['no-items', 'willRender'], ['no-items', 'willInsertElement'], ['nested-item', 'init'], ['nested-item', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'on(init)'], ['nested-item', 'willRender'], ['nested-item', 'willInsertElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['nested-item', 'didInsertElement'], ['nested-item', 'didRender'], ['no-items', 'didInsertElement'], ['no-items', 'didRender'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy']], + + nonInteractive: [['no-items', 'init'], ['no-items', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['no-items', 'on(init)'], ['nested-item', 'init'], ['nested-item', 'didInitAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'didReceiveAttrs', { attrs: {}, newAttrs: {} }], ['nested-item', 'on(init)'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy']] + }); + + this.teardownAssertions.push(function () { + _this6.assertHooks({ + label: 'destroy', + + interactive: [['no-items', 'willDestroyElement'], ['no-items', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['no-items', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['no-items', 'willDestroy'], ['nested-item', 'willDestroy']], + + nonInteractive: [['no-items', 'willDestroy'], ['nested-item', 'willDestroy']] + }); + + _this6.assertRegisteredViews('after destroy'); + }); + }; + +babelHelpers.createClass(LifeCycleHooksTest, [{ + key: 'isInteractive', + get: function () { + return true; + } + }, { + key: 'ComponentClass', + get: function () { + throw new Error('Not implemented: `ComponentClass`'); + } + }, { + key: 'boundHelpers', + get: function () { + return { + invoke: bind(this.invocationFor, this), + attr: bind(this.attrFor, this) + }; + } + }]); + return LifeCycleHooksTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var CurlyComponentsTest = (function (_LifeCycleHooksTest) { +babelHelpers.inherits(CurlyComponentsTest, _LifeCycleHooksTest); + + function CurlyComponentsTest() { + _LifeCycleHooksTest.apply(this, arguments); + } + + CurlyComponentsTest.prototype.invocationFor = function invocationFor(name) { + var _this7 = this; + + var namedArgs = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var attrs = Object.keys(namedArgs).map(function (k) { + return k + '=' + _this7.val(namedArgs[k]); + }).join(' '); + return '{{' + name + ' ' + attrs + '}}'; + }; + + CurlyComponentsTest.prototype.attrFor = function attrFor(name) { + return '' + name; + }; + + /* private */ + + CurlyComponentsTest.prototype.val = function val(value) { + if (value.isString) { + return JSON.stringify(value.value); + } else if (value.isExpr) { + return '(readonly ' + value.value + ')'; + } else { + throw new Error('Unknown value: ' + value); + } + }; + +babelHelpers.createClass(CurlyComponentsTest, [{ + key: 'ComponentClass', + get: function () { + return _emberGlimmerTestsUtilsHelpers.Component; + } + }]); + return CurlyComponentsTest; + })(LifeCycleHooksTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: interactive lifecycle hooks (curly components)', (function (_CurlyComponentsTest) { +babelHelpers.inherits(_class, _CurlyComponentsTest); + + function _class() { + _CurlyComponentsTest.apply(this, arguments); + } + +babelHelpers.createClass(_class, [{ + key: 'isInteractive', + get: function () { + return true; + } + }]); + return _class; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: non-interactive lifecycle hooks (curly components)', (function (_CurlyComponentsTest2) { +babelHelpers.inherits(_class2, _CurlyComponentsTest2); + + function _class2() { + _CurlyComponentsTest2.apply(this, arguments); + } + +babelHelpers.createClass(_class2, [{ + key: 'isInteractive', + get: function () { + return false; + } + }]); + return _class2; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: interactive lifecycle hooks (tagless curly components)', (function (_CurlyComponentsTest3) { +babelHelpers.inherits(_class3, _CurlyComponentsTest3); + + function _class3() { + _CurlyComponentsTest3.apply(this, arguments); + } + +babelHelpers.createClass(_class3, [{ + key: 'ComponentClass', + get: function () { + return _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }); + } + }, { + key: 'isInteractive', + get: function () { + return true; + } + }]); + return _class3; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: non-interactive lifecycle hooks (tagless curly components)', (function (_CurlyComponentsTest4) { +babelHelpers.inherits(_class4, _CurlyComponentsTest4); + + function _class4() { + _CurlyComponentsTest4.apply(this, arguments); + } + +babelHelpers.createClass(_class4, [{ + key: 'ComponentClass', + get: function () { + return _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }); + } + }, { + key: 'isInteractive', + get: function () { + return false; + } + }]); + return _class4; + })(CurlyComponentsTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Run loop and lifecycle hooks', (function (_RenderingTest2) { +babelHelpers.inherits(_class5, _RenderingTest2); + + function _class5() { + _RenderingTest2.apply(this, arguments); + } + + _class5.prototype['@test afterRender set'] = function testAfterRenderSet() { + var _this9 = this; + + var ComponentClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + width: '5', + didInsertElement: function () { + var _this8 = this; + + _emberMetal.run.scheduleOnce('afterRender', function () { + _this8.set('width', '10'); + }); + } + }); + + var template = '{{width}}'; + this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template }); + + this.render('{{foo-bar}}'); + + this.assertText('10'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('10'); + }; + + _class5.prototype['@test afterRender set on parent'] = function testAfterRenderSetOnParent() { + var _this11 = this; + + var ComponentClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + var _this10 = this; + + _emberMetal.run.scheduleOnce('afterRender', function () { + var parent = _this10.get('parent'); + parent.set('foo', 'wat'); + }); + } + }); + + var template = '{{foo}}'; + + this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template }); + + this.render('{{foo-bar parent=this foo=foo}}'); + + this.assertText('wat'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('wat'); + }; + + _class5.prototype['@test `willRender` can set before render (GH#14458)'] = function testWillRenderCanSetBeforeRenderGH14458(assert) { + var ComponentClass = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'a', + customHref: 'http://google.com', + attributeBindings: ['customHref:href'], + willRender: function () { + this.set('customHref', 'http://willRender.com'); + } + }); + + var template = 'Hello World'; + + this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template }); + + this.render('{{foo-bar id="foo"}}'); + + this.assertElement(this.firstChild, { + tagName: 'a', + attrs: { + id: 'foo', + href: 'http://willRender.com', + class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') + } + }); + }; + + _class5.prototype['@test that thing about destroying'] = function testThatThingAboutDestroying(assert) { + var _this12 = this; + + var ParentDestroyedElements = []; + var ChildDestroyedElements = []; + + var ParentComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroyElement: function () { + ParentDestroyedElements.push({ + id: this.itemId, + name: 'parent-component', + hasParent: !!this.element.parentNode, + nextSibling: !!this.element.nextSibling, + previousSibling: !!this.element.previousSibling + }); + } + }); + + var PartentTemplate = _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11); + + var NestedComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroyElement: function () { + ChildDestroyedElements.push({ + id: this.nestedId, + name: 'nested-component', + hasParent: !!this.element.parentNode, + nextSibling: !!this.element.nextSibling, + previousSibling: !!this.element.previousSibling + }); + } + }); + + var NestedTemplate = '{{yield}}'; + + this.registerComponent('parent-component', { + ComponentClass: ParentComponent, + template: PartentTemplate + }); + + this.registerComponent('nested-component', { + ComponentClass: NestedComponent, + template: NestedTemplate + }); + + var array = _emberRuntime.A([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12), { + items: array, + model: { shouldShow: true } + }); + + this.assertText('1AB2AB3AB4AB5AB6AB7AB'); + + this.runTask(function () { + array.removeAt(2); + array.removeAt(2); + _emberMetal.set(_this12.context, 'model.shouldShow', false); + }); + + this.assertText('1AB2AB5AB'); + + assertDestroyHooks(assert, [].concat(ParentDestroyedElements), [{ + id: 3, + hasParent: true, + nextSibling: true, + previousSibling: true + }, { + id: 4, + hasParent: true, + nextSibling: true, + previousSibling: true + }, { + id: 6, + hasParent: true, + nextSibling: true, + previousSibling: true + }, { + id: 7, + hasParent: true, + nextSibling: false, + previousSibling: true + }]); + + assertDestroyHooks(assert, [].concat(ChildDestroyedElements), [{ + id: '3-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '3-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }, { + id: '4-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '4-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }, { + id: '6-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '6-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }, { + id: '7-A', + hasParent: true, + nextSibling: true, + previousSibling: false + }, { + id: '7-B', + hasParent: true, + nextSibling: false, + previousSibling: true + }]); + }; + + _class5.prototype['@test lifecycle hooks have proper access to this.$()'] = function testLifecycleHooksHaveProperAccessToThis$(assert) { + assert.expect(6); + var component = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'div', + init: function () { + assert.notOk(this.$(), 'no access to element via this.$() on init() enter'); + this._super.apply(this, arguments); + assert.notOk(this.$(), 'no access to element via this.$() after init() finished'); + }, + willInsertElement: function () { + component = this; + assert.ok(this.$(), 'willInsertElement has access to element via this.$()'); + }, + didInsertElement: function () { + assert.ok(this.$(), 'didInsertElement has access to element via this.$()'); + }, + willDestroyElement: function () { + assert.ok(this.$(), 'willDestroyElement has access to element via this.$()'); + }, + didDestroyElement: function () { + assert.notOk(this.$(), 'didDestroyElement does not have access to element via this.$()'); + } + }); + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + var owner = this.owner; + + var comp = owner.lookup('component:foo-bar'); + _internalTestHelpers.runAppend(comp); + this.runTask(function () { + return _emberUtils.tryInvoke(component, 'destroy'); + }); + }; + + return _class5; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + function assertDestroyHooks(assert, _actual, _expected) { + _expected.forEach(function (expected, i) { + var name = expected.name; + assert.equal(expected.id, _actual[i].id, name + ' id is the same'); + assert.equal(expected.hasParent, _actual[i].hasParent, name + ' has parent node'); + assert.equal(expected.nextSibling, _actual[i].nextSibling, name + ' has next sibling node'); + assert.equal(expected.previousSibling, _actual[i].previousSibling, name + ' has previous sibling node'); + }); + } + + function bind(func, thisArg) { + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return func.apply(thisArg, args); + }; + } + + function string(value) { + return { isString: true, value: value }; + } + + function expr(value) { + return { isExpr: true, value: value }; + } + + function hook(name, hook) { + var _ref3 = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + + var attrs = _ref3.attrs; + var oldAttrs = _ref3.oldAttrs; + var newAttrs = _ref3.newAttrs; + + return { name: name, hook: hook, args: { attrs: attrs, oldAttrs: oldAttrs, newAttrs: newAttrs } }; + } + + function json(serializable) { + return JSON.parse(JSON.stringify(serializable)); + } +}); + +// Sync hooks + +// Async hooks + +// Sync hooks + +// Async hooks +enifed('ember-glimmer/tests/integration/components/life-cycle-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/life-cycle-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/life-cycle-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/link-to-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-runtime', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberRuntime, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Link-to component', (function (_ApplicationTest) { + babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + _ApplicationTest.apply(this, arguments); + } + + _class.prototype.visitWithDeprecation = function visitWithDeprecation(path, deprecation) { + var _this = this; + + var p = undefined; + + expectDeprecation(function () { + p = _this.visit(path); + }, deprecation); + + return p; + }; + + _class.prototype['@test accessing `currentWhen` triggers a deprecation'] = function testAccessingCurrentWhenTriggersADeprecation(assert) { + var component = undefined; + this.registerComponent('link-to', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.LinkComponent.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }) + }); + + this.registerTemplate('application', '{{link-to \'Index\' \'index\'}}'); + + return this.visit('/').then(function () { + expectDeprecation(function () { + component.get('currentWhen'); + }, /Usage of `currentWhen` is deprecated, use `current-when` instead/); + }); + }; + + _class.prototype['@test should be able to be inserted in DOM when the router is not present'] = function testShouldBeAbleToBeInsertedInDOMWhenTheRouterIsNotPresent() { + var _this2 = this; + + this.registerTemplate('application', '{{#link-to \'index\'}}Go to Index{{/link-to}}'); + + return this.visit('/').then(function () { + _this2.assertText('Go to Index'); + }); + }; + + _class.prototype['@test re-renders when title changes'] = function testReRendersWhenTitleChanges() { + var _this3 = this; + + var controller = undefined; + + this.registerTemplate('application', '{{link-to title routeName}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + controller = this; + }, + title: 'foo', + routeName: 'index' + })); + + return this.visit('/').then(function () { + _this3.assertText('foo'); + _this3.runTask(function () { + return _emberMetal.set(controller, 'title', 'bar'); + }); + _this3.assertText('bar'); + }); + }; + + _class.prototype['@test escaped inline form (double curlies) escapes link title'] = function testEscapedInlineFormDoubleCurliesEscapesLinkTitle() { + var _this4 = this; + + this.registerTemplate('application', '{{link-to title \'index\'}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'blah' + })); + + return this.visit('/').then(function () { + _this4.assertText('blah'); + }); + }; + + _class.prototype['@test escaped inline form with (-html-safe) does not escape link title'] = function testEscapedInlineFormWithHtmlSafeDoesNotEscapeLinkTitle(assert) { + var _this5 = this; + + this.registerTemplate('application', '{{link-to (-html-safe title) \'index\'}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'blah' + })); + + return this.visit('/').then(function () { + _this5.assertText('blah'); + assert.equal(_this5.$('b').length, 1); + }); + }; + + _class.prototype['@test unescaped inline form (triple curlies) does not escape link title'] = function testUnescapedInlineFormTripleCurliesDoesNotEscapeLinkTitle(assert) { + var _this6 = this; + + this.registerTemplate('application', '{{{link-to title \'index\'}}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'blah' + })); + + return this.visit('/').then(function () { + _this6.assertText('blah'); + assert.equal(_this6.$('b').length, 1); + }); + }; + + _class.prototype['@test unwraps controllers'] = function testUnwrapsControllers() { + var _this7 = this; + + this.router.map(function () { + this.route('profile', { path: '/profile/:id' }); + }); + this.registerTemplate('application', '{{#link-to \'profile\' otherController}}Text{{/link-to}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + otherController: _emberRuntime.Controller.create({ + model: 'foo' + }) + })); + + var deprecation = /Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated./; + + return this.visitWithDeprecation('/', deprecation).then(function () { + _this7.assertText('Text'); + }); + }; + + _class.prototype['@test able to safely extend the built-in component and use the normal path'] = function testAbleToSafelyExtendTheBuiltInComponentAndUseTheNormalPath() { + var _this8 = this; + + this.registerComponent('custom-link-to', { ComponentClass: _emberGlimmerTestsUtilsHelpers.LinkComponent.extend() }); + this.registerTemplate('application', '{{#custom-link-to \'index\'}}{{title}}{{/custom-link-to}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'Hello' + })); + + return this.visit('/').then(function () { + _this8.assertText('Hello'); + }); + }; + + _class.prototype['@test [GH#13432] able to safely extend the built-in component and invoke it inline'] = function testGH13432AbleToSafelyExtendTheBuiltInComponentAndInvokeItInline() { + var _this9 = this; + + this.registerComponent('custom-link-to', { ComponentClass: _emberGlimmerTestsUtilsHelpers.LinkComponent.extend() }); + this.registerTemplate('application', '{{custom-link-to title \'index\'}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + title: 'Hello' + })); + + return this.visit('/').then(function () { + _this9.assertText('Hello'); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Link-to component with query-params', (function (_ApplicationTest2) { + babelHelpers.inherits(_class2, _ApplicationTest2); + + function _class2() { + _ApplicationTest2.apply(this, arguments); + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '123', + bar: 'yes' + })); + } + + _class2.prototype['@test populates href with fully supplied query param values'] = function testPopulatesHrefWithFullySuppliedQueryParamValues(assert) { + var _this10 = this; + + this.registerTemplate('index', '{{#link-to \'index\' (query-params foo=\'456\' bar=\'NAW\')}}Index{{/link-to}}'); + + return this.visit('/').then(function () { + _this10.assertComponentElement(_this10.firstChild.firstElementChild, { + tagName: 'a', + attrs: { href: '/?bar=NAW&foo=456' }, + content: 'Index' + }); + }); + }; + + _class2.prototype['@test populates href with partially supplied query param values, but omits if value is default value'] = function testPopulatesHrefWithPartiallySuppliedQueryParamValuesButOmitsIfValueIsDefaultValue() { + var _this11 = this; + + this.registerTemplate('index', '{{#link-to \'index\' (query-params foo=\'123\')}}Index{{/link-to}}'); + + return this.visit('/').then(function () { + _this11.assertComponentElement(_this11.firstChild.firstElementChild, { + tagName: 'a', + attrs: { href: '/', class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view active') }, + content: 'Index' + }); + }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/components/link-to-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/link-to-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/link-to-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/local-lookup-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + function buildResolver() { + var resolver = { + resolve: function () {}, + expandLocalLookup: function (fullName, sourceFullName) { + var _sourceFullName$split = sourceFullName.split(':'); + + var sourceType = _sourceFullName$split[0]; + var sourceName = _sourceFullName$split[1]; + + var _fullName$split = fullName.split(':'); + + var type = _fullName$split[0]; + var name = _fullName$split[1]; + + if (type !== 'template' && sourceType === 'template' && sourceName.slice(0, 11) === 'components/') { + sourceName = sourceName.slice(11); + } + + if (type === 'template' && sourceType === 'template' && name.slice(0, 11) === 'components/') { + name = name.slice(11); + } + + var result = type + ':' + sourceName + '/' + name; + + return result; + } + }; + + return resolver; + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: local lookup', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype.getResolver = function getResolver() { + return buildResolver(); + }; + + _class.prototype['@test it can lookup a local template'] = function testItCanLookupALocalTemplate() { + var _this = this; + + this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' }); + this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' }); + + this.render('{{x-outer}}'); + + this.assertText('Nested template says: Hi!', 'Initial render works'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + }; + + _class.prototype['@test tagless blockless component can lookup local template'] = function testTaglessBlocklessComponentCanLookupLocalTemplate() { + var _this2 = this; + + this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' }); + this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}'); + this.registerComponent('x-outer', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ tagName: '' }) + }); + + this.render('{{x-outer}}'); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + }; + + _class.prototype['@test it can lookup a local component template'] = function testItCanLookupALocalComponentTemplate() { + var _this3 = this; + + this.registerTemplate('components/x-outer/x-inner', 'Nested template says: {{yield}}'); + this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}'); + + this.render('{{x-outer}}'); + + this.assertText('Nested template says: Hi!', 'Initial render works'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Nested template says: Hi!', 'Re-render works'); + }; + + _class.prototype['@test it can local lookup a dynamic component'] = function testItCanLocalLookupADynamicComponent() { + var _this4 = this; + + this.registerComponent('foo-bar', { template: 'yall finished {{component child}}' }); + this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' }); + + this.render('{{foo-bar child=child}}', { child: 'biz-baz' }); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can local lookup a dynamic component from a dynamic component'] = function testItCanLocalLookupADynamicComponentFromADynamicComponent() { + var _this5 = this; + + this.registerComponent('foo-bar', { template: 'yall finished {{component child}}' }); + this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' }); + + this.render('{{component componentName child=child}}', { componentName: 'foo-bar', child: 'biz-baz' }); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can local lookup a dynamic component from a passed named argument'] = function testItCanLocalLookupADynamicComponentFromAPassedNamedArgument() { + var _this6 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-biz baz=(component \'local-bar\')}}' }); + this.registerComponent('global-biz', { template: 'or {{component baz}}' }); + this.registerComponent('parent-foo/local-bar', { template: 'yall done?' }); + + this.render('{{parent-foo}}'); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can local lookup a re-wrapped dynamic component from a passed named argument'] = function testItCanLocalLookupAReWrappedDynamicComponentFromAPassedNamedArgument() { + var _this7 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component \'local-bar\')}}' }); + this.registerComponent('global-x', { template: 'or {{global-y comp=(component comp phrase=\'done\')}}' }); + this.registerComponent('global-y', { template: '{{component comp}}?' }); + this.registerComponent('parent-foo/local-bar', { template: 'yall {{phrase}}' }); + + this.render('{{parent-foo}}'); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can nest local lookups of dynamic components from a passed named argument'] = function testItCanNestLocalLookupsOfDynamicComponentsFromAPassedNamedArgument() { + var _this8 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component \'local-bar\')}}' }); + this.registerComponent('global-x', { template: 'or {{global-y comp=(component comp phrase=\'done\')}}' }); + this.registerComponent('global-y', { template: '{{component comp}}{{component \'local-bar\'}}' }); + this.registerComponent('parent-foo/local-bar', { template: 'yall {{phrase}}' }); + this.registerComponent('global-y/local-bar', { template: '?' }); + + this.render('{{parent-foo}}'); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('yall finished or yall done?'); + }; + + _class.prototype['@test it can switch from local to global lookups of dynamic components from a passed named argument'] = function testItCanSwitchFromLocalToGlobalLookupsOfDynamicComponentsFromAPassedNamedArgument() { + var _this9 = this; + + this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component bar)}}' }); + this.registerComponent('global-x', { template: 'or yall {{component comp}}' }); + this.registerComponent('parent-foo/local-bar', { template: 'done?' }); + this.registerComponent('global-bar', { template: 'ready?' }); + + this.render('{{parent-foo bar=bar}}', { bar: 'local-bar' }); + + this.assertText('yall finished or yall done?'); + + this.runTask(function () { + return _this9.context.set('bar', 'global-bar'); + }); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('yall finished or yall ready?'); + }; + + _class.prototype['@test it can lookup a local helper'] = function testItCanLookupALocalHelper() { + var _this10 = this; + + this.registerHelper('x-outer/x-helper', function () { + return 'Who dis?'; + }); + this.registerComponent('x-outer', { template: 'Who dat? {{x-helper}}' }); + + this.render('{{x-outer}}'); + + this.assertText('Who dat? Who dis?', 'Initial render works'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Who dat? Who dis?', 'Re-render works'); + }; + + _class.prototype['@test it overrides global helper lookup'] = function testItOverridesGlobalHelperLookup() { + var _this11 = this; + + this.registerHelper('x-outer/x-helper', function () { + return 'Who dis?'; + }); + + this.registerHelper('x-helper', function () { + return 'I dunno'; + }); + + this.registerComponent('x-outer', { template: 'Who dat? {{x-helper}}' }); + + this.render('{{x-outer}} {{x-helper}}'); + + this.assertText('Who dat? Who dis? I dunno', 'Initial render works'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('Who dat? Who dis? I dunno', 'Re-render works'); + }; + + _class.prototype['@test lookup without match issues standard assertion (with local helper name)'] = function testLookupWithoutMatchIssuesStandardAssertionWithLocalHelperName() { + var _this12 = this; + + this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' }); + + expectAssertion(function () { + _this12.render('{{x-outer}}'); + }, /A component or helper named "x-inner" could not be found/); + }; + + _class.prototype['@test overrides global lookup'] = function testOverridesGlobalLookup() { + var _this13 = this; + + this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' }); + this.registerComponent('x-outer/x-inner', { template: 'Nested template says (from local): {{yield}}' }); + this.registerComponent('x-inner', { template: 'Nested template says (from global): {{yield}}' }); + + this.render('{{#x-inner}}Hi!{{/x-inner}} {{x-outer}} {{#x-outer/x-inner}}Hi!{{/x-outer/x-inner}}'); + + this.assertText('Nested template says (from global): Hi! Nested template says (from local): Hi! Nested template says (from local): Hi!'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('Nested template says (from global): Hi! Nested template says (from local): Hi! Nested template says (from local): Hi!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/local-lookup-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/local-lookup-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/local-lookup-test.js should pass ESLint\n\n'); + }); +}); +enifed("ember-glimmer/tests/integration/components/render-to-element-test", ["exports"], function (exports) { + "use strict"; +}); +enifed('ember-glimmer/tests/integration/components/render-to-element-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/render-to-element-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/render-to-element-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/target-action-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberRouting) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#component-a}}\n {{component-b bar="derp"}}\n {{/component-a}}\n '], ['\n {{#component-a}}\n {{component-b bar="derp"}}\n {{/component-a}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: sendAction', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.call(this); + this.actionCounts = {}; + this.sendCount = 0; + this.actionArguments = null; + + var self = this; + + this.registerComponent('action-delegate', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + self.delegate = this; + this.name = 'action-delegate'; + } + }) + }); + } + + _class.prototype.renderDelegate = function renderDelegate() { + var template = arguments.length <= 0 || arguments[0] === undefined ? '{{action-delegate}}' : arguments[0]; + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var root = this; + context = _emberUtils.assign(context, { + send: function (actionName) { + root.sendCount++; + root.actionCounts[actionName] = root.actionCounts[actionName] || 0; + root.actionCounts[actionName]++; + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + root.actionArguments = args; + } + }); + this.render(template, context); + }; + + _class.prototype.assertSendCount = function assertSendCount(count) { + this.assert.equal(this.sendCount, count, 'Send was called ' + count + ' time(s)'); + }; + + _class.prototype.assertNamedSendCount = function assertNamedSendCount(actionName, count) { + this.assert.equal(this.actionCounts[actionName], count, 'An action named \'' + actionName + '\' was sent ' + count + ' times'); + }; + + _class.prototype.assertSentWithArgs = function assertSentWithArgs(expected) { + var message = arguments.length <= 1 || arguments[1] === undefined ? 'arguments were sent with the action' : arguments[1]; + + this.assert.deepEqual(this.actionArguments, expected, message); + }; + + _class.prototype['@test Calling sendAction on a component without an action defined does nothing'] = function testCallingSendActionOnAComponentWithoutAnActionDefinedDoesNothing() { + var _this = this; + + this.renderDelegate(); + + this.runTask(function () { + return _this.delegate.sendAction(); + }); + + this.assertSendCount(0); + }; + + _class.prototype['@test Calling sendAction on a component with an action defined calls send on the controller'] = function testCallingSendActionOnAComponentWithAnActionDefinedCallsSendOnTheController() { + var _this2 = this; + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this2.delegate, 'action', 'addItem'); + _this2.delegate.sendAction(); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('addItem', 1); + }; + + _class.prototype['@test Calling sendAction on a component with a function calls the function'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunction() { + var _this3 = this; + + this.assert.expect(1); + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this3.delegate, 'action', function () { + return _this3.assert.ok(true, 'function is called'); + }); + _this3.delegate.sendAction(); + }); + }; + + _class.prototype['@test Calling sendAction on a component with a function calls the function with arguments'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunctionWithArguments() { + var _this4 = this; + + this.assert.expect(1); + var argument = {}; + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this4.delegate, 'action', function (actualArgument) { + _this4.assert.deepEqual(argument, actualArgument, 'argument is passed'); + }); + _this4.delegate.sendAction('action', argument); + }); + }; + + // TODO consolidate these next 2 tests + + _class.prototype['@test Calling sendAction on a component with a reference attr calls the function with arguments'] = function testCallingSendActionOnAComponentWithAReferenceAttrCallsTheFunctionWithArguments() { + var _this5 = this; + + this.renderDelegate('{{action-delegate playing=playing}}', { + playing: null + }); + + this.runTask(function () { + return _this5.delegate.sendAction(); + }); + + this.assertSendCount(0); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'playing', 'didStartPlaying'); + }); + + this.runTask(function () { + _this5.delegate.sendAction('playing'); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + }; + + _class.prototype['@test Calling sendAction on a component with a {{mut}} attr calls the function with arguments'] = function testCallingSendActionOnAComponentWithAMutAttrCallsTheFunctionWithArguments() { + var _this6 = this; + + this.renderDelegate('{{action-delegate playing=(mut playing)}}', { + playing: null + }); + + this.runTask(function () { + return _this6.delegate.sendAction('playing'); + }); + + this.assertSendCount(0); + + this.runTask(function () { + return _this6.delegate.attrs.playing.update('didStartPlaying'); + }); + this.runTask(function () { + return _this6.delegate.sendAction('playing'); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + }; + + _class.prototype['@test Calling sendAction with a named action uses the component\'s property as the action name'] = function testCallingSendActionWithANamedActionUsesTheComponentSPropertyAsTheActionName() { + var _this7 = this; + + this.renderDelegate(); + + var component = this.delegate; + + this.runTask(function () { + _emberMetal.set(_this7.delegate, 'playing', 'didStartPlaying'); + component.sendAction('playing'); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + + this.runTask(function () { + return component.sendAction('playing'); + }); + + this.assertSendCount(2); + this.assertNamedSendCount('didStartPlaying', 2); + + this.runTask(function () { + _emberMetal.set(component, 'action', 'didDoSomeBusiness'); + component.sendAction(); + }); + + this.assertSendCount(3); + this.assertNamedSendCount('didDoSomeBusiness', 1); + }; + + _class.prototype['@test Calling sendAction when the action name is not a string raises an exception'] = function testCallingSendActionWhenTheActionNameIsNotAStringRaisesAnException() { + var _this8 = this; + + this.renderDelegate(); + + this.runTask(function () { + _emberMetal.set(_this8.delegate, 'action', {}); + _emberMetal.set(_this8.delegate, 'playing', {}); + }); + + expectAssertion(function () { + return _this8.delegate.sendAction(); + }); + expectAssertion(function () { + return _this8.delegate.sendAction('playing'); + }); + }; + + _class.prototype['@test Calling sendAction on a component with contexts'] = function testCallingSendActionOnAComponentWithContexts() { + var _this9 = this; + + this.renderDelegate(); + + var testContext = { song: 'She Broke My Ember' }; + var firstContext = { song: 'She Broke My Ember' }; + var secondContext = { song: 'My Achey Breaky Ember' }; + + this.runTask(function () { + _emberMetal.set(_this9.delegate, 'playing', 'didStartPlaying'); + _this9.delegate.sendAction('playing', testContext); + }); + + this.assertSendCount(1); + this.assertNamedSendCount('didStartPlaying', 1); + this.assertSentWithArgs([testContext], 'context was sent with the action'); + + this.runTask(function () { + _this9.delegate.sendAction('playing', firstContext, secondContext); + }); + + this.assertSendCount(2); + this.assertNamedSendCount('didStartPlaying', 2); + this.assertSentWithArgs([firstContext, secondContext], 'multiple contexts were sent to the action'); + }; + + _class.prototype['@test calling sendAction on a component within a block sends to the outer scope GH#14216'] = function testCallingSendActionOnAComponentWithinABlockSendsToTheOuterScopeGH14216(assert) { + var testContext = this; + // overrides default action-delegate so actions can be added + this.registerComponent('action-delegate', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + testContext.delegate = this; + this.name = 'action-delegate'; + }, + + actions: { + derp: function (arg1) { + assert.ok(true, 'action called on action-delgate'); + assert.equal(arg1, 'something special', 'argument passed through properly'); + } + } + }), + + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject) + }); + + this.registerComponent('component-a', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.name = 'component-a'; + }, + actions: { + derp: function () { + assert.ok(false, 'no! bad scoping!'); + } + } + }) + }); + + var innerChild = undefined; + this.registerComponent('component-b', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerChild = this; + this.name = 'component-b'; + } + }) + }); + + this.renderDelegate(); + + this.runTask(function () { + return innerChild.sendAction('bar', 'something special'); + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: sendAction to a controller', (function (_ApplicationTest) { +babelHelpers.inherits(_class2, _ApplicationTest); + + function _class2() { + _ApplicationTest.apply(this, arguments); + } + + _class2.prototype['@test sendAction should trigger an action on the parent component\'s controller if it exists'] = function testSendActionShouldTriggerAnActionOnTheParentComponentSControllerIfItExists(assert) { + var _this10 = this; + + assert.expect(15); + + var component = undefined; + + this.router.map(function () { + this.route('a'); + this.route('b'); + this.route('c', function () { + this.route('d'); + this.route('e'); + }); + }); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '{{val}}' + }); + + this.registerController('a', _emberRuntime.Controller.extend({ + send: function (actionName, actionContext) { + assert.equal(actionName, 'poke', 'send() method was invoked from a top level controller'); + assert.equal(actionContext, 'top', 'action arguments were passed into the top level controller'); + } + })); + this.registerTemplate('a', '{{foo-bar val="a" poke="poke"}}'); + + this.registerRoute('b', _emberRouting.Route.extend({ + actions: { + poke: function (actionContext) { + assert.ok(true, 'Unhandled action sent to route'); + assert.equal(actionContext, 'top no controller'); + } + } + })); + this.registerTemplate('b', '{{foo-bar val="b" poke="poke"}}'); + + this.registerRoute('c', _emberRouting.Route.extend({ + actions: { + poke: function (actionContext) { + assert.ok(true, 'Unhandled action sent to route'); + assert.equal(actionContext, 'top with nested no controller'); + } + } + })); + this.registerTemplate('c', '{{foo-bar val="c" poke="poke"}}{{outlet}}'); + + this.registerRoute('c.d', _emberRouting.Route.extend({})); + + this.registerController('c.d', _emberRuntime.Controller.extend({ + send: function (actionName, actionContext) { + assert.equal(actionName, 'poke', 'send() method was invoked from a nested controller'); + assert.equal(actionContext, 'nested', 'action arguments were passed into the nested controller'); + } + })); + this.registerTemplate('c.d', '{{foo-bar val=".d" poke="poke"}}'); + + this.registerRoute('c.e', _emberRouting.Route.extend({ + actions: { + poke: function (actionContext) { + assert.ok(true, 'Unhandled action sent to route'); + assert.equal(actionContext, 'nested no controller'); + } + } + })); + this.registerTemplate('c.e', '{{foo-bar val=".e" poke="poke"}}'); + + return this.visit('/a').then(function () { + return component.sendAction('poke', 'top'); + }).then(function () { + _this10.assertText('a'); + return _this10.visit('/b'); + }).then(function () { + return component.sendAction('poke', 'top no controller'); + }).then(function () { + _this10.assertText('b'); + return _this10.visit('/c'); + }).then(function () { + return component.sendAction('poke', 'top with nested no controller'); + }).then(function () { + _this10.assertText('c'); + return _this10.visit('/c/d'); + }).then(function () { + return component.sendAction('poke', 'nested'); + }).then(function () { + _this10.assertText('c.d'); + return _this10.visit('/c/e'); + }).then(function () { + return component.sendAction('poke', 'nested no controller'); + }).then(function () { + return _this10.assertText('c.e'); + }); + }; + + _class2.prototype['@test sendAction should not trigger an action in an outlet\'s controller if a parent component handles it'] = function testSendActionShouldNotTriggerAnActionInAnOutletSControllerIfAParentComponentHandlesIt(assert) { + assert.expect(1); + + var component = undefined; + + this.registerComponent('x-parent', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + poke: function () { + assert.ok(true, 'parent component handled the aciton'); + } + } + }), + template: '{{x-child poke="poke"}}' + }); + + this.registerComponent('x-child', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }) + }); + + this.registerTemplate('application', '{{x-parent}}'); + this.registerController('application', _emberRuntime.Controller.extend({ + send: function (actionName) { + throw new Error('controller action should not be called'); + } + })); + + return this.visit('/').then(function () { + return component.sendAction('poke'); + }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: sendAction of a closure action', (function (_RenderingTest2) { +babelHelpers.inherits(_class3, _RenderingTest2); + + function _class3() { + _RenderingTest2.apply(this, arguments); + } + + _class3.prototype['@test action should be called'] = function testActionShouldBeCalled(assert) { + assert.expect(1); + var component = undefined; + + this.registerComponent('inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + assert.ok(true, 'outerSubmit called'); + } + }), + template: '{{inner-component submitAction=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + return component.sendAction('submitAction'); + }); + }; + + _class3.prototype['@test contexts passed to sendAction are appended to the bound arguments on a closure action'] = function testContextsPassedToSendActionAreAppendedToTheBoundArgumentsOnAClosureAction() { + var first = 'mitch'; + var second = 'martin'; + var third = 'matt'; + var fourth = 'wacky wycats'; + + var innerComponent = undefined; + var actualArgs = undefined; + + this.registerComponent('inner-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + } + }), + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + third: third, + actions: { + outerSubmit: function () { + actualArgs = [].concat(babelHelpers.slice.call(arguments)); + } + } + }), + template: '{{inner-component innerSubmit=(action (action "outerSubmit" "' + first + '") "' + second + '" third)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + return innerComponent.sendAction('innerSubmit', fourth); + }); + + this.assert.deepEqual(actualArgs, [first, second, third, fourth], 'action has the correct args'); + }; + + return _class3; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: send', (function (_RenderingTest3) { +babelHelpers.inherits(_class4, _RenderingTest3); + + function _class4() { + _RenderingTest3.apply(this, arguments); + } + + _class4.prototype['@test sending to undefined actions triggers an error'] = function testSendingToUndefinedActionsTriggersAnError(assert) { + assert.expect(2); + + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + component = this; + }, + actions: { + foo: function (message) { + assert.equal('bar', message); + } + } + }) + }); + + this.render('{{foo-bar}}'); + + this.runTask(function () { + return component.send('foo', 'bar'); + }); + + expectAssertion(function () { + return component.send('baz', 'bar'); + }, /had no action handler for: baz/); + }; + + _class4.prototype['@test `send` will call send from a target if it is defined'] = function testSendWillCallSendFromATargetIfItIsDefined() { + var _this11 = this; + + var component = undefined; + var target = { + send: function (message, payload) { + _this11.assert.equal('foo', message); + _this11.assert.equal('baz', payload); + } + }; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + component = this; + }, + target: target + }) + }); + + this.render('{{foo-bar}}'); + + this.runTask(function () { + return component.send('foo', 'baz'); + }); + }; + + _class4.prototype['@test a handled action can be bubbled to the target for continued processing'] = function testAHandledActionCanBeBubbledToTheTargetForContinuedProcessing() { + var _this12 = this; + + this.assert.expect(2); + + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + poke: function () { + _this12.assert.ok(true, 'component action called'); + return true; + } + }, + target: _emberRuntime.Controller.extend({ + actions: { + poke: function () { + _this12.assert.ok(true, 'action bubbled to controller'); + } + } + }).create() + }) + }); + + this.render('{{foo-bar poke="poke"}}'); + + this.runTask(function () { + return component.send('poke'); + }); + }; + + _class4.prototype['@test action can be handled by a superclass\' actions object'] = function testActionCanBeHandledByASuperclassActionsObject(assert) { + this.assert.expect(4); + + var component = undefined; + + var SuperComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + foo: function () { + assert.ok(true, 'foo'); + }, + bar: function (msg) { + assert.equal(msg, 'HELLO'); + } + } + }); + + var BarViewMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + assert.equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + this.registerComponent('x-index', { + ComponentClass: SuperComponent.extend(BarViewMixin, { + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + baz: function () { + assert.ok(true, 'baz'); + } + } + }) + }); + + this.render('{{x-index}}'); + + this.runTask(function () { + component.send('foo'); + component.send('bar', 'HELLO'); + component.send('baz'); + }); + }; + + _class4.prototype['@test actions cannot be provided at create time'] = function testActionsCannotBeProvidedAtCreateTime(assert) { + expectAssertion(function () { + return _emberGlimmerTestsUtilsHelpers.Component.create({ + actions: { + foo: function () { + assert.ok(true, 'foo'); + } + } + }); + }); + // but should be OK on an object that doesn't mix in Ember.ActionHandler + _emberRuntime.Object.create({ + actions: ['foo'] + }); + }; + + return _class4; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/target-action-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/target-action-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/target-action-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/utils-test', ['exports', 'ember-runtime', 'ember-views', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberRuntime, _emberViews, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('View tree tests', (function (_ApplicationTest) { + babelHelpers.inherits(_class, _ApplicationTest); + + function _class() { + _ApplicationTest.call(this); + + this.registerComponent('x-tagless', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '' + }), + + template: '
    [{{id}}] {{#if isShowing}}{{yield}}{{/if}}
    ' + }); + + this.registerComponent('x-toggle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + isExpanded: true, + + click: function () { + this.toggleProperty('isExpanded'); + return false; + } + }), + + template: '[{{id}}] {{#if isExpanded}}{{yield}}{{/if}}' + }); + + var ToggleController = _emberRuntime.Controller.extend({ + isExpanded: true, + + actions: { + toggle: function () { + this.toggleProperty('isExpanded'); + } + } + }); + + this.registerController('application', ToggleController); + + this.registerTemplate('application', '\n {{x-tagless id="root-1"}}\n\n {{#x-toggle id="root-2"}}\n {{x-toggle id="inner-1"}}\n\n {{#x-toggle id="inner-2"}}\n {{x-toggle id="inner-3"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n \n\n {{#if isExpanded}}\n {{x-toggle id="root-3"}}\n {{/if}}\n\n {{outlet}}\n '); + + this.registerController('index', ToggleController.extend({ + isExpanded: false + })); + + this.registerTemplate('index', '\n {{x-tagless id="root-4"}}\n\n {{#x-toggle id="root-5" isExpanded=false}}\n {{x-toggle id="inner-4"}}\n\n {{#x-toggle id="inner-5"}}\n {{x-toggle id="inner-6"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n \n\n {{#if isExpanded}}\n {{x-toggle id="root-6"}}\n {{/if}}\n '); + + this.registerTemplate('zomg', '\n {{x-tagless id="root-7"}}\n\n {{#x-toggle id="root-8"}}\n {{x-toggle id="inner-7"}}\n\n {{#x-toggle id="inner-8"}}\n {{x-toggle id="inner-9"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n {{#x-toggle id="root-9"}}\n {{outlet}}\n {{/x-toggle}}\n '); + + this.registerTemplate('zomg.lol', '\n {{x-toggle id="inner-10"}}\n '); + + this.router.map(function () { + this.route('zomg', function () { + this.route('lol'); + }); + }); + } + + _class.prototype['@test getRootViews'] = function testGetRootViews(assert) { + var _this = this; + + return this.visit('/').then(function () { + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5']); + + _this.runTask(function () { + return _emberViews.jQuery('#toggle-application').click(); + }); + + _this.assertRootViews(['root-1', 'root-2', 'root-4', 'root-5']); + + _this.runTask(function () { + _emberViews.jQuery('#toggle-application').click(); + _emberViews.jQuery('#toggle-index').click(); + }); + + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']); + + return _this.visit('/zomg/lol'); + }).then(function () { + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-7', 'root-8', 'root-9']); + + return _this.visit('/'); + }).then(function () { + _this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']); + }); + }; + + _class.prototype.assertRootViews = function assertRootViews(ids) { + var owner = this.applicationInstance; + + var actual = _emberViews.getRootViews(owner).map(function (view) { + return view.id; + }).sort(); + var expected = ids.sort(); + + this.assert.deepEqual(actual, expected, 'root views'); + }; + + _class.prototype['@test getChildViews'] = function testGetChildViews(assert) { + var _this2 = this; + + return this.visit('/').then(function () { + _this2.assertChildViews('root-2', ['inner-1', 'inner-2']); + _this2.assertChildViews('root-5', []); + _this2.assertChildViews('inner-2', ['inner-3']); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + + _this2.assertChildViews('root-2', []); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-5').click(); + }); + + _this2.assertChildViews('root-5', ['inner-4', 'inner-5']); + _this2.assertChildViews('inner-5', ['inner-6']); + + return _this2.visit('/zomg'); + }).then(function () { + _this2.assertChildViews('root-2', []); + _this2.assertChildViews('root-8', ['inner-7', 'inner-8']); + _this2.assertChildViews('inner-8', ['inner-9']); + _this2.assertChildViews('root-9', []); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-8').click(); + }); + + _this2.assertChildViews('root-8', []); + + return _this2.visit('/zomg/lol'); + }).then(function () { + _this2.assertChildViews('root-2', []); + _this2.assertChildViews('root-8', []); + _this2.assertChildViews('root-9', ['inner-10']); + + return _this2.visit('/'); + }).then(function () { + _this2.assertChildViews('root-2', []); + _this2.assertChildViews('root-5', []); + + _this2.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this2.runTask(function () { + return _emberViews.jQuery('#inner-2').click(); + }); + + _this2.assertChildViews('root-2', ['inner-1', 'inner-2']); + _this2.assertChildViews('inner-2', []); + }); + }; + + _class.prototype['@test getChildViews does not return duplicates'] = function testGetChildViewsDoesNotReturnDuplicates(assert) { + var _this3 = this; + + return this.visit('/').then(function () { + _this3.assertChildViews('root-2', ['inner-1', 'inner-2']); + + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + _this3.runTask(function () { + return _emberViews.jQuery('#root-2').click(); + }); + + _this3.assertChildViews('root-2', ['inner-1', 'inner-2']); + }); + }; + + _class.prototype.assertChildViews = function assertChildViews(parentId, childIds) { + var parentView = this.viewFor(parentId); + var childViews = _emberViews.getChildViews(parentView); + + var actual = childViews.map(function (view) { + return view.id; + }).sort(); + var expected = childIds.sort(); + + this.assert.deepEqual(actual, expected, 'child views for #' + parentId); + }; + + _class.prototype.viewFor = function viewFor(id) { + var owner = this.applicationInstance; + var registry = owner.lookup('-view-registry:main'); + return registry[id]; + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); + + var hasGetClientRects = undefined, + hasGetBoundingClientRect = undefined; + var ClientRectListCtor = undefined, + ClientRectCtor = undefined; + + (function () { + if (document.createRange) { + var range = document.createRange(); + + if (range.getClientRects) { + var clientRectsList = range.getClientRects(); + hasGetClientRects = true; + ClientRectListCtor = clientRectsList && clientRectsList.constructor; + } + + if (range.getBoundingClientRect) { + var clientRect = range.getBoundingClientRect(); + hasGetBoundingClientRect = true; + ClientRectCtor = clientRect && clientRect.constructor; + } + } + })(); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Bounds tests', (function (_RenderingTest) { + babelHelpers.inherits(_class2, _RenderingTest); + + function _class2() { + _RenderingTest.apply(this, arguments); + } + + _class2.prototype['@test getViewBounds on a regular component'] = function testGetViewBoundsOnARegularComponent(assert) { + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '

    Hi, mom!

    ' + }); + + this.render('{{hi-mom}}'); + + var _getViewBounds = _emberViews.getViewBounds(component); + + var parentElement = _getViewBounds.parentElement; + var firstNode = _getViewBounds.firstNode; + var lastNode = _getViewBounds.lastNode; + + assert.equal(parentElement, this.element, 'a regular component should have the right parentElement'); + assert.equal(firstNode, component.element, 'a regular component should have a single node that is its element'); + assert.equal(lastNode, component.element, 'a regular component should have a single node that is its element'); + }; + + _class2.prototype['@test getViewBounds on a tagless component'] = function testGetViewBoundsOnATaglessComponent(assert) { + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: '', + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: 'Hi, mom!' + }); + + this.render('{{hi-mom}}'); + + var _getViewBounds2 = _emberViews.getViewBounds(component); + + var parentElement = _getViewBounds2.parentElement; + var firstNode = _getViewBounds2.firstNode; + var lastNode = _getViewBounds2.lastNode; + + assert.equal(parentElement, this.element, 'a tagless component should have the right parentElement'); + assert.equal(firstNode, this.$('#start-node')[0], 'a tagless component should have a range enclosing all of its nodes'); + assert.equal(lastNode, this.$('#before-end-node')[0].nextSibling, 'a tagless component should have a range enclosing all of its nodes'); + }; + + _class2.prototype['@test getViewClientRects'] = function testGetViewClientRects(assert) { + if (!hasGetClientRects || !ClientRectListCtor) { + assert.ok(true, 'The test environment does not support the DOM API required to run this test.'); + return; + } + + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '

    Hi, mom!

    ' + }); + + this.render('{{hi-mom}}'); + + assert.ok(_emberViews.getViewClientRects(component) instanceof ClientRectListCtor); + }; + + _class2.prototype['@test getViewBoundingClientRect'] = function testGetViewBoundingClientRect(assert) { + if (!hasGetBoundingClientRect || !ClientRectCtor) { + assert.ok(true, 'The test environment does not support the DOM API required to run this test.'); + return; + } + + var component = undefined; + this.registerComponent('hi-mom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + } + }), + template: '

    Hi, mom!

    ' + }); + + this.render('{{hi-mom}}'); + + assert.ok(_emberViews.getViewBoundingClientRect(component) instanceof ClientRectCtor); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/utils-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/utils-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/utils-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/web-component-fallback-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Components test: web component fallback', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test custom elements are rendered'] = function testCustomElementsAreRendered() { + var template = 'hello'; + + this.render(template); + + this.assertHTML(template); + + this.assertStableRerender(); + }; + + _class.prototype['@test custom elements can have bound attributes'] = function testCustomElementsCanHaveBoundAttributes() { + var _this = this; + + var template = 'hello'; + + this.render(template, { name: 'Robert' }); + + this.assertHTML('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Kris'); + }); + + this.assertHTML('hello'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'name', 'Robert'); + }); + + this.assertHTML('hello'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/web-component-fallback-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/web-component-fallback-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/web-component-fallback-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/components/will-destroy-element-hook-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Component willDestroyElement hook', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it calls willDestroyElement when removed by if'] = function testItCallsWillDestroyElementWhenRemovedByIf(assert) { + var _this = this; + + var didInsertElementCount = 0; + var willDestroyElementCount = 0; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + didInsertElementCount++; + assert.notEqual(this.element.parentNode, null, 'precond component is in DOM'); + }, + willDestroyElement: function () { + willDestroyElementCount++; + assert.notEqual(this.element.parentNode, null, 'has not been removed from DOM yet'); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{#if switch}}{{foo-bar}}{{/if}}', { switch: true }); + + assert.equal(didInsertElementCount, 1, 'didInsertElement was called once'); + + this.assertComponentElement(this.firstChild, { content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'switch', false); + }); + + assert.equal(willDestroyElementCount, 1, 'willDestroyElement was called once'); + + this.assertText(''); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/components/will-destroy-element-hook-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/content-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/test-helpers', 'ember-views', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsTestHelpers, _emberViews, _emberGlimmerTestsUtilsHelpers) { + /* globals EmberDev */ + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Static content tests', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it can render a static text node'] = function testItCanRenderAStaticTextNode() { + var _this = this; + + this.render('hello'); + var text1 = this.assertTextNode(this.firstChild, 'hello'); + + this.runTask(function () { + return _this.rerender(); + }); + + var text2 = this.assertTextNode(this.firstChild, 'hello'); + + this.assertSameNode(text1, text2); + }; + + _class.prototype['@test it can render a static element'] = function testItCanRenderAStaticElement() { + var _this2 = this; + + this.render('

    hello

    '); + var p1 = this.assertElement(this.firstChild, { tagName: 'p' }); + var text1 = this.assertTextNode(this.firstChild.firstChild, 'hello'); + + this.runTask(function () { + return _this2.rerender(); + }); + + var p2 = this.assertElement(this.firstChild, { tagName: 'p' }); + var text2 = this.assertTextNode(this.firstChild.firstChild, 'hello'); + + this.assertSameNode(p1, p2); + this.assertSameNode(text1, text2); + }; + + _class.prototype['@test it can render a static template'] = function testItCanRenderAStaticTemplate() { + var _this3 = this; + + var template = '\n
    \n

    Welcome to Ember.js

    \n
    \n
    \n

    Why you should use Ember.js?

    \n
      \n
    1. It\'s great
    2. \n
    3. It\'s awesome
    4. \n
    5. It\'s Ember.js
    6. \n
    \n
    \n \n '; + + this.render(template); + this.assertHTML(template); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertHTML(template); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + var DynamicContentTest = (function (_RenderingTest2) { + babelHelpers.inherits(DynamicContentTest, _RenderingTest2); + + function DynamicContentTest() { + _RenderingTest2.apply(this, arguments); + } + + /* abstract */ + + DynamicContentTest.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + throw new Error('Not implemented: `renderValues`'); + }; + + DynamicContentTest.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.firstChild, null); + }; + + /* abstract */ + + DynamicContentTest.prototype.assertContent = function assertContent(content) { + throw new Error('Not implemented: `assertContent`'); + }; + + DynamicContentTest.prototype['@test it can render a dynamic path'] = function testItCanRenderADynamicPath() { + var _this4 = this; + + this.renderPath('message', { message: 'hello' }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', 'goodbye'); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', 'hello'); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test resolves the string length properly'] = function testResolvesTheStringLengthProperly() { + var _this5 = this; + + this.render('

    {{foo.length}}

    ', { foo: undefined }); + + this.assertHTML('

    '); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'foo', 'foo'); + }); + + this.assertHTML('

    3

    '); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'foo', ''); + }); + + this.assertHTML('

    0

    '); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'foo', undefined); + }); + + this.assertHTML('

    '); + }; + + DynamicContentTest.prototype['@test resolves the array length properly'] = function testResolvesTheArrayLengthProperly() { + var _this6 = this; + + this.render('

    {{foo.length}}

    ', { foo: undefined }); + + this.assertHTML('

    '); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', [1, 2, 3]); + }); + + this.assertHTML('

    3

    '); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', []); + }); + + this.assertHTML('

    0

    '); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'foo', undefined); + }); + + this.assertHTML('

    '); + }; + + DynamicContentTest.prototype['@test it can render a capitalized path with no deprecation'] = function testItCanRenderACapitalizedPathWithNoDeprecation() { + var _this7 = this; + + expectNoDeprecation(); + + this.renderPath('CaptializedPath', { CaptializedPath: 'no deprecation' }); + + this.assertContent('no deprecation'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'CaptializedPath', 'still no deprecation'); + }); + + this.assertContent('still no deprecation'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'CaptializedPath', 'no deprecation'); + }); + + this.assertContent('no deprecation'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render undefined dynamic paths'] = function testItCanRenderUndefinedDynamicPaths() { + var _this8 = this; + + this.renderPath('name', {}); + + this.assertIsEmpty(); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'name', 'foo-bar'); + }); + + this.assertContent('foo-bar'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'name', undefined); + }); + + this.assertIsEmpty(); + }; + + DynamicContentTest.prototype['@test it can render a deeply nested dynamic path'] = function testItCanRenderADeeplyNestedDynamicPath() { + var _this9 = this; + + this.renderPath('a.b.c.d.e.f', { + a: { b: { c: { d: { e: { f: 'hello' } } } } } + }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'a.b.c.d.e.f', 'goodbye'); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'a.b.c.d', { e: { f: 'aloha' } }); + }); + + this.assertContent('aloha'); + this.assertInvariants(); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'a', { b: { c: { d: { e: { f: 'hello' } } } } }); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render a computed property'] = function testItCanRenderAComputedProperty() { + var _this10 = this; + + var Formatter = _emberRuntime.Object.extend({ + formattedMessage: _emberMetal.computed('message', function () { + return this.get('message').toUpperCase(); + }) + }); + + var m = Formatter.create({ message: 'hello' }); + + this.renderPath('m.formattedMessage', { m: m }); + + this.assertContent('HELLO'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(m, 'message', 'goodbye'); + }); + + this.assertContent('GOODBYE'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'm', Formatter.create({ message: 'hello' })); + }); + + this.assertContent('HELLO'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render a computed property with nested dependency'] = function testItCanRenderAComputedPropertyWithNestedDependency() { + var _this11 = this; + + var Formatter = _emberRuntime.Object.extend({ + formattedMessage: _emberMetal.computed('messenger.message', function () { + return this.get('messenger.message').toUpperCase(); + }) + }); + + var m = Formatter.create({ messenger: { message: 'hello' } }); + + this.renderPath('m.formattedMessage', { m: m }); + + this.assertContent('HELLO'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(m, 'messenger.message', 'goodbye'); + }); + + this.assertContent('GOODBYE'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'm', Formatter.create({ messenger: { message: 'hello' } })); + }); + + this.assertContent('HELLO'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a proxy object'] = function testItCanReadFromAProxyObject() { + var _this12 = this; + + this.renderPath('proxy.name', { proxy: _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } }) }); + + this.assertContent('Tom Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.content.name', 'Yehuda Katz'); + }); + + this.assertContent('Yehuda Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.content', { name: 'Godfrey Chan' }); + }); + + this.assertContent('Godfrey Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.name', 'Stefan Penner'); + }); + + this.assertContent('Stefan Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy.content', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } })); + }); + + this.assertContent('Tom Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a nested path in a proxy object'] = function testItCanReadFromANestedPathInAProxyObject() { + var _this13 = this; + + this.renderPath('proxy.name.last', { proxy: _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }) }); + + this.assertContent('Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content.name.last', 'Cruise'); + }); + + this.assertContent('Cruise'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content.name.first', 'Suri'); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content.name', { first: 'Yehuda', last: 'Katz' }); + }); + + this.assertContent('Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.content', { name: { first: 'Godfrey', last: 'Chan' } }); + }); + + this.assertContent('Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy.name', { first: 'Stefan', last: 'Penner' }); + }); + + this.assertContent('Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } })); + }); + + this.assertContent('Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a path flipping between a proxy and a real object'] = function testItCanReadFromAPathFlippingBetweenAProxyAndARealObject() { + var _this14 = this; + + this.renderPath('proxyOrObject.name.last', { proxyOrObject: _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }) }); + + this.assertContent('Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', { name: { first: 'Tom', last: 'Dale' } }); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject.name.last', 'Cruise'); + }); + + this.assertContent('Cruise'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject.name.first', 'Suri'); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', { name: { first: 'Yehuda', last: 'Katz' } }); + }); + + this.assertContent('Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Godfrey', last: 'Chan' } } })); + }); + + this.assertContent('Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject.content.name', { first: 'Stefan', last: 'Penner' }); + }); + + this.assertContent('Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'proxyOrObject', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } })); + }); + + this.assertContent('Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a path flipping between a real object and a proxy'] = function testItCanReadFromAPathFlippingBetweenARealObjectAndAProxy() { + var _this15 = this; + + this.renderPath('objectOrProxy.name.last', { objectOrProxy: { name: { first: 'Tom', last: 'Dale' } } }); + + this.assertContent('Dale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } })); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.content.name.last', 'Cruise'); + }); + + this.assertContent('Cruise'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.content.name.first', 'Suri'); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.content', { name: { first: 'Yehuda', last: 'Katz' } }); + }); + + this.assertContent('Katz'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', { name: { first: 'Godfrey', last: 'Chan' } }); + }); + + this.assertContent('Chan'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy.name', { first: 'Stefan', last: 'Penner' }); + }); + + this.assertContent('Penner'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', null); + }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'objectOrProxy', { name: { first: 'Tom', last: 'Dale' } }); + }); + + this.assertContent('Dale'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can read from a null object'] = function testItCanReadFromANullObject() { + var _this16 = this; + + var nullObject = Object.create(null); + nullObject['message'] = 'hello'; + + this.renderPath('nullObject.message', { nullObject: nullObject }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(nullObject, 'message', 'goodbye'); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + nullObject = Object.create(null); + nullObject['message'] = 'hello'; + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'nullObject', nullObject); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + DynamicContentTest.prototype['@test it can render a readOnly property of a path'] = function testItCanRenderAReadOnlyPropertyOfAPath() { + var _this17 = this; + + var Messenger = _emberRuntime.Object.extend({ + message: _emberMetal.computed.readOnly('a.b.c') + }); + + var messenger = Messenger.create({ + a: { + b: { + c: 'hello' + } + } + }); + + this.renderPath('messenger.message', { messenger: messenger }); + + this.assertContent('hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(messenger, 'a.b.c', 'hi'); + }); + + this.assertContent('hi'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'messenger.a.b', { + c: 'goodbye' + }); + }); + + this.assertContent('goodbye'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'messenger', { + message: 'hello' + }); + }); + + this.assertContent('hello'); + this.assertInvariants(); + }; + + return DynamicContentTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var EMPTY = {}; + + var ContentTestGenerator = (function () { + function ContentTestGenerator(cases) { + var tag = arguments.length <= 1 || arguments[1] === undefined ? '@test' : arguments[1]; + + this.cases = cases; + this.tag = tag; + } + + ContentTestGenerator.prototype.generate = function generate(_ref3) { + var value = _ref3[0]; + var expected = _ref3[1]; + var label = _ref3[2]; + + var tag = this.tag; + label = label || value; + + if (expected === EMPTY) { + var _ref; + + return _ref = {}, _ref[tag + ' rendering ' + label] = function () { + var _this18 = this; + + this.renderPath('value', { value: value }); + + this.assertIsEmpty(); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'value', 'hello'); + }); + + this.assertContent('hello'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'value', value); + }); + + this.assertIsEmpty(); + }, _ref; + } else { + var _ref2; + + return _ref2 = {}, _ref2[tag + ' rendering ' + label] = function () { + var _this19 = this; + + this.renderPath('value', { value: value }); + + this.assertContent(expected); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'value', 'hello'); + }); + + this.assertContent('hello'); + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this19.context, 'value', value); + }); + + this.assertContent(expected); + this.assertInvariants(); + }, _ref2; + } + }; + + return ContentTestGenerator; + })(); + + var SharedContentTestCases = new ContentTestGenerator([['foo', 'foo'], [0, '0'], [-0, '0', '-0'], [1, '1'], [-1, '-1'], [0.0, '0', '0.0'], [0.5, '0.5'], [undefined, EMPTY], [null, EMPTY], [true, 'true'], [false, 'false'], [NaN, 'NaN'], [new Date(2000, 0, 1), String(new Date(2000, 0, 1)), 'a Date object'], [Infinity, 'Infinity'], [1 / -0, '-Infinity'], [{ foo: 'bar' }, '[object Object]', '{ foo: \'bar\' }'], [{ toString: function () { + return 'foo'; + } }, 'foo', 'an object with a custom toString function'], [{ valueOf: function () { + return 1; + } }, '[object Object]', 'an object with a custom valueOf function'], + + // Escaping tests + ['MaxJames', 'MaxJames']]); + + var GlimmerContentTestCases = new ContentTestGenerator([[Object.create(null), EMPTY, 'an object with no toString']]); + + if (typeof Symbol !== 'undefined') { + GlimmerContentTestCases.cases.push([Symbol('debug'), 'Symbol(debug)', 'a symbol']); + } + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(DynamicContentTest, SharedContentTestCases, GlimmerContentTestCases); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (content position)', (function (_DynamicContentTest) { + babelHelpers.inherits(_class2, _DynamicContentTest); + + function _class2() { + _DynamicContentTest.apply(this, arguments); + } + + _class2.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('{{' + path + '}}', context); + }; + + _class2.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node'); + this.assertTextNode(this.firstChild, content); + }; + + return _class2; + })(DynamicContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (content concat)', (function (_DynamicContentTest2) { + babelHelpers.inherits(_class3, _DynamicContentTest2); + + function _class3() { + _DynamicContentTest2.apply(this, arguments); + } + + _class3.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('{{concat "" ' + path + ' ""}}', context); + }; + + _class3.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node'); + this.assertTextNode(this.firstChild, content); + }; + + return _class3; + })(DynamicContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (inside an element)', (function (_DynamicContentTest3) { + babelHelpers.inherits(_class4, _DynamicContentTest3); + + function _class4() { + _DynamicContentTest3.apply(this, arguments); + } + + _class4.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('

    {{' + path + '}}

    ', context); + }; + + _class4.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one

    tag'); + this.assertElement(this.firstChild, { tagName: 'p' }); + this.assertText(''); + }; + + _class4.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one

    tag'); + this.assertElement(this.firstChild, { tagName: 'p' }); + this.assertText(content); + }; + + return _class4; + })(DynamicContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (attribute position)', (function (_DynamicContentTest4) { + babelHelpers.inherits(_class5, _DynamicContentTest4); + + function _class5() { + _DynamicContentTest4.apply(this, arguments); + } + + _class5.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('

    ', context); + }; + + _class5.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one
    tag'); + this.assertElement(this.firstChild, { tagName: 'div', content: '' }); + }; + + _class5.prototype.assertContent = function assertContent(content) { + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one
    tag'); + this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': content }, content: '' }); + }; + + return _class5; + })(DynamicContentTest)); + + var TrustedContentTest = (function (_DynamicContentTest5) { + babelHelpers.inherits(TrustedContentTest, _DynamicContentTest5); + + function TrustedContentTest() { + _DynamicContentTest5.apply(this, arguments); + } + + TrustedContentTest.prototype.assertIsEmpty = function assertIsEmpty() { + this.assert.strictEqual(this.firstChild, null); + }; + + TrustedContentTest.prototype.assertContent = function assertContent(content) { + this.assertHTML(content); + }; + + TrustedContentTest.prototype.assertStableRerender = function assertStableRerender() { + var _this20 = this; + + this.takeSnapshot(); + this.runTask(function () { + return _this20.rerender(); + }); + _DynamicContentTest5.prototype.assertInvariants.call(this); + }; + + TrustedContentTest.prototype.assertInvariants = function assertInvariants() { + // If it's not stable, we will wipe out all the content and replace them, + // so there are no invariants + }; + + return TrustedContentTest; + })(DynamicContentTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (trusted)', (function (_TrustedContentTest) { + babelHelpers.inherits(_class6, _TrustedContentTest); + + function _class6() { + _TrustedContentTest.apply(this, arguments); + } + + _class6.prototype.renderPath = function renderPath(path) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + this.render('{{{' + path + '}}}', context); + }; + + _class6.prototype['@test updating trusted curlies'] = function testUpdatingTrustedCurlies() { + var _this21 = this; + + this.render('{{{htmlContent}}}{{{nested.htmlContent}}}', { + htmlContent: 'Max', + nested: { htmlContent: 'James' } + }); + + this.assertContent('MaxJames'); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'htmlContent', 'Max'); + }); + + this.assertContent('MaxJames'); + + this.runTask(function () { + return _emberMetal.set(_this21.context, 'nested.htmlContent', 'Jammie'); + }); + + this.assertContent('MaxJammie'); + + this.runTask(function () { + _emberMetal.set(_this21.context, 'htmlContent', 'Max'); + _emberMetal.set(_this21.context, 'nested', { htmlContent: 'James' }); + }); + + this.assertContent('MaxJames'); + }; + + return _class6; + })(TrustedContentTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Dynamic content tests (integration)', (function (_RenderingTest3) { + babelHelpers.inherits(_class7, _RenderingTest3); + + function _class7() { + _RenderingTest3.apply(this, arguments); + } + + _class7.prototype['@test it can render a dynamic template'] = function testItCanRenderADynamicTemplate() { + var _this22 = this; + + var template = '\n
    \n

    Welcome to {{framework}}

    \n
    \n
    \n

    Why you should use {{framework}}?

    \n
      \n
    1. It\'s great
    2. \n
    3. It\'s awesome
    4. \n
    5. It\'s {{framework}}
    6. \n
    \n
    \n \n '; + + var ember = '\n
    \n

    Welcome to Ember.js

    \n
    \n
    \n

    Why you should use Ember.js?

    \n
      \n
    1. It\'s great
    2. \n
    3. It\'s awesome
    4. \n
    5. It\'s Ember.js
    6. \n
    \n
    \n \n '; + + var react = '\n
    \n

    Welcome to React

    \n
    \n
    \n

    Why you should use React?

    \n
      \n
    1. It\'s great
    2. \n
    3. It\'s awesome
    4. \n
    5. It\'s React
    6. \n
    \n
    \n \n '; + + this.render(template, { + framework: 'Ember.js' + }); + this.assertHTML(ember); + + this.runTask(function () { + return _this22.rerender(); + }); + + this.assertHTML(ember); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'framework', 'React'); + }); + + this.assertHTML(react); + + this.runTask(function () { + return _emberMetal.set(_this22.context, 'framework', 'Ember.js'); + }); + + this.assertHTML(ember); + }; + + _class7.prototype['@test it should evaluate to nothing if part of the path is `undefined`'] = function testItShouldEvaluateToNothingIfPartOfThePathIsUndefined() { + var _this23 = this; + + this.render('{{foo.bar.baz.bizz}}', { + foo: {} + }); + + this.assertText(''); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', { + bar: { baz: { bizz: 'Hey!' } } + }); + }); + + this.assertText('Hey!'); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', {}); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', { + bar: { baz: { bizz: 'Hello!' } } + }); + }); + + this.assertText('Hello!'); + + this.runTask(function () { + return _emberMetal.set(_this23.context, 'foo', {}); + }); + + this.assertText(''); + }; + + _class7.prototype['@test it should evaluate to nothing if part of the path is a primative'] = function testItShouldEvaluateToNothingIfPartOfThePathIsAPrimative() { + var _this24 = this; + + this.render('{{foo.bar.baz.bizz}}', { + foo: { bar: true } + }); + + this.assertText(''); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: false + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: 'Haha' + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: null + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: undefined + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: 1 + }); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: { baz: { bizz: 'Hello!' } } + }); + }); + + this.assertText('Hello!'); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'foo', { + bar: true + }); + }); + + this.assertText(''); + }; + + _class7.prototype['@test can set dynamic href'] = function testCanSetDynamicHref() { + var _this25 = this; + + this.render('Example', { + model: { + url: 'http://example.com' + } + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } }); + + this.runTask(function () { + return _this25.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } }); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'model.url', 'http://linkedin.com'); + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://linkedin.com' } }); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'model', { url: 'http://example.com' }); + }); + + this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } }); + }; + + _class7.prototype['@test quoteless class attributes update correctly'] = function testQuotelessClassAttributesUpdateCorrectly() { + var _this26 = this; + + this.render('
    hello
    ', { + fooBar: true + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _this26.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _emberMetal.set(_this26.context, 'fooBar', false); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello' }); + + this.runTask(function () { + return _emberMetal.set(_this26.context, 'fooBar', true); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + }; + + _class7.prototype['@test quoted class attributes update correctly'] = function testQuotedClassAttributesUpdateCorrectly(assert) { + var _this27 = this; + + this.render('
    hello
    ', { + fooBar: true + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _this27.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'fooBar', false); + }); + + assert.equal(this.firstChild.className, ''); + + this.runTask(function () { + return _emberMetal.set(_this27.context, 'fooBar', true); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo-bar') } }); + }; + + _class7.prototype['@test unquoted class attribute can contain multiple classes'] = function testUnquotedClassAttributeCanContainMultipleClasses() { + var _this28 = this; + + this.render('
    hello
    ', { + model: { + classes: 'foo bar baz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _this28.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _emberMetal.set(_this28.context, 'model.classes', 'fizz bizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this28.context, 'model', { classes: 'foo bar baz' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + }; + + _class7.prototype['@test unquoted class attribute'] = function testUnquotedClassAttribute() { + var _this29 = this; + + this.render('
    hello
    ', { + model: { + foo: 'foo' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _this29.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _emberMetal.set(_this29.context, 'model.foo', 'fizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this29.context, 'model', { foo: 'foo' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + }; + + _class7.prototype['@test quoted class attribute'] = function testQuotedClassAttribute() { + var _this30 = this; + + this.render('
    hello
    ', { + model: { + foo: 'foo' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _this30.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + + this.runTask(function () { + return _emberMetal.set(_this30.context, 'model.foo', 'fizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this30.context, 'model', { foo: 'foo' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo') } }); + }; + + _class7.prototype['@test quoted class attribute can contain multiple classes'] = function testQuotedClassAttributeCanContainMultipleClasses() { + var _this31 = this; + + this.render('
    hello
    ', { + model: { + classes: 'foo bar baz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _this31.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + + this.runTask(function () { + return _emberMetal.set(_this31.context, 'model.classes', 'fizz bizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this31.context, 'model', { classes: 'foo bar baz' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar baz') } }); + }; + + _class7.prototype['@test class attribute concats bound values'] = function testClassAttributeConcatsBoundValues() { + var _this32 = this; + + this.render('
    hello
    ', { + model: { + foo: 'foo', + bar: 'bar', + bizz: 'bizz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar bizz') } }); + + this.runTask(function () { + return _this32.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this32.context, 'model.foo', 'fizz'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bar bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this32.context, 'model.bar', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('fizz bizz') } }); + + this.runTask(function () { + return _emberMetal.set(_this32.context, 'model', { + foo: 'foo', + bar: 'bar', + bizz: 'bizz' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar bizz') } }); + }; + + _class7.prototype['@test class attribute accepts nested helpers, and updates'] = function testClassAttributeAcceptsNestedHelpersAndUpdates() { + var _this33 = this; + + this.render('
    hello
    ', { + model: { + size: 'large', + hasSize: true, + hasShape: false, + shape: 'round' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large') } }); + + this.runTask(function () { + return _this33.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large') } }); + + this.runTask(function () { + return _emberMetal.set(_this33.context, 'model.hasShape', true); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large round') } }); + + this.runTask(function () { + return _emberMetal.set(_this33.context, 'model.hasSize', false); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('round') } }); + + this.runTask(function () { + return _emberMetal.set(_this33.context, 'model', { + size: 'large', + hasSize: true, + hasShape: false, + shape: 'round' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('large') } }); + }; + + _class7.prototype['@test Multiple dynamic classes'] = function testMultipleDynamicClasses() { + var _this34 = this; + + this.render('
    hello
    ', { + model: { + foo: 'foo', + bar: 'bar', + fizz: 'fizz', + baz: 'baz' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar fizz baz') } }); + + this.runTask(function () { + return _this34.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar fizz baz') } }); + + this.runTask(function () { + _emberMetal.set(_this34.context, 'model.foo', null); + _emberMetal.set(_this34.context, 'model.fizz', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('bar baz') } }); + + this.runTask(function () { + _emberMetal.set(_this34.context, 'model', { + foo: 'foo', + bar: 'bar', + fizz: 'fizz', + baz: 'baz' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': _emberGlimmerTestsUtilsTestHelpers.classes('foo bar fizz baz') } }); + }; + + _class7.prototype['@test classes are ordered: See issue #9912'] = function testClassesAreOrderedSeeIssue9912() { + var _this35 = this; + + this.render('
    hello
    ', { + model: { + foo: 'foo', + bar: 'bar' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } }); + + this.runTask(function () { + return _this35.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } }); + + this.runTask(function () { + _emberMetal.set(_this35.context, 'model.bar', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static ' } }); + + this.runTask(function () { + _emberMetal.set(_this35.context, 'model', { + foo: 'foo', + bar: 'bar' + }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } }); + }; + + return _class7; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + var warnings = undefined, + originalWarn = undefined; + + var StyleTest = (function (_RenderingTest4) { + babelHelpers.inherits(StyleTest, _RenderingTest4); + + function StyleTest() { + _RenderingTest4.apply(this, arguments); + warnings = []; + originalWarn = _emberMetal.getDebugFunction('warn'); + _emberMetal.setDebugFunction('warn', function (message, test) { + if (!test) { + warnings.push(message); + } + }); + } + + StyleTest.prototype.teardown = function teardown() { + var _RenderingTest4$prototype$teardown; + + (_RenderingTest4$prototype$teardown = _RenderingTest4.prototype.teardown).call.apply(_RenderingTest4$prototype$teardown, [this].concat(babelHelpers.slice.call(arguments))); + _emberMetal.setDebugFunction('warn', originalWarn); + }; + + StyleTest.prototype.assertStyleWarning = function assertStyleWarning() { + this.assert.deepEqual(warnings, [_emberViews.STYLE_WARNING]); + }; + + StyleTest.prototype.assertNoWarning = function assertNoWarning() { + this.assert.deepEqual(warnings, []); + }; + + return StyleTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Inline style tests', (function (_StyleTest) { + babelHelpers.inherits(_class8, _StyleTest); + + function _class8() { + _StyleTest.apply(this, arguments); + } + + _class8.prototype['@test can set dynamic style'] = function testCanSetDynamicStyle() { + var _this36 = this; + + this.render('
    ', { + model: { + style: 'width: 60px;' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _this36.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this36.context, 'model.style', 'height: 60px;'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'height: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this36.context, 'model.style', null); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: {} }); + + this.runTask(function () { + return _emberMetal.set(_this36.context, 'model', { style: 'width: 60px;' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + }; + + _class8.prototype['@test can set dynamic style with -html-safe'] = function testCanSetDynamicStyleWithHtmlSafe() { + var _this37 = this; + + this.render('
    ', { + model: { + style: 'width: 60px;' + } + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _this37.rerender(); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this37.context, 'model.style', 'height: 60px;'); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'height: 60px;' } }); + + this.runTask(function () { + return _emberMetal.set(_this37.context, 'model', { style: 'width: 60px;' }); + }); + + this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } }); + }; + + return _class8; + })(StyleTest)); + + if (!EmberDev.runningProdBuild) { + _emberGlimmerTestsUtilsTestCase.moduleFor('Inline style tests - warnings', (function (_StyleTest2) { + babelHelpers.inherits(_class9, _StyleTest2); + + function _class9() { + _StyleTest2.apply(this, arguments); + } + + _class9.prototype['@test specifying
    generates a warning'] = function testSpecifyingDivStyleUserValueDivGeneratesAWarning(assert) { + this.render('
    ', { + userValue: 'width: 42px' + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test specifying `attributeBindings: ["style"]` generates a warning'] = function testSpecifyingAttributeBindingsStyleGeneratesAWarning(assert) { + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'] + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); + + this.render('{{foo-bar style=userValue}}', { + userValue: 'width: 42px' + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test specifying `
    ` works properly without a warning'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithoutAWarning(assert) { + this.render('
    ', { + userValue: 'width: 42px' + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test specifying `
    ` works properly with a SafeString'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithASafeString(assert) { + this.render('
    ', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('width: 42px') + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test null value do not generate htmlsafe warning'] = function testNullValueDoNotGenerateHtmlsafeWarning(assert) { + this.render('
    ', { + userValue: null + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test undefined value do not generate htmlsafe warning'] = function testUndefinedValueDoNotGenerateHtmlsafeWarning(assert) { + this.render('
    '); + + this.assertNoWarning(); + }; + + _class9.prototype['@test no warnings are triggered when using `-html-safe`'] = function testNoWarningsAreTriggeredWhenUsingHtmlSafe(assert) { + this.render('
    ', { + userValue: 'width: 42px' + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test no warnings are triggered when a safe string is quoted'] = function testNoWarningsAreTriggeredWhenASafeStringIsQuoted(assert) { + this.render('
    ', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('width: 42px') + }); + + this.assertNoWarning(); + }; + + _class9.prototype['@test binding warning is triggered when an unsafe string is quoted'] = function testBindingWarningIsTriggeredWhenAnUnsafeStringIsQuoted(assert) { + this.render('
    ', { + userValue: 'width: 42px' + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test binding warning is triggered when a safe string for a complete property is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForACompletePropertyIsConcatenatedInPlace(assert) { + this.render('
    ', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('width: 42px') + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test binding warning is triggered when a safe string for a value is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForAValueIsConcatenatedInPlace(assert) { + this.render('
    ', { + userValue: new _emberGlimmerTestsUtilsHelpers.SafeString('42px') + }); + + this.assertStyleWarning(); + }; + + _class9.prototype['@test binding warning is triggered when a safe string for a property name is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForAPropertyNameIsConcatenatedInPlace(assert) { + this.render('
    ', { + userProperty: new _emberGlimmerTestsUtilsHelpers.SafeString('width') + }); + + this.assertStyleWarning(); + }; + + return _class9; + })(StyleTest)); + } +}); +enifed('ember-glimmer/tests/integration/content-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/content-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/content-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/event-dispatcher-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + var canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer; + + function fireNativeWithDataTransfer(node, type, dataTransfer) { + var event = document.createEvent('HTMLEvents'); + event.initEvent(type, true, true); + event.dataTransfer = dataTransfer; + node.dispatchEvent(event); + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test events bubble view hierarchy for form elements'] = function testEventsBubbleViewHierarchyForFormElements(assert) { + var _this = this; + + var receivedEvent = undefined; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + change: function (event) { + receivedEvent = event; + } + }), + template: '' + }); + + this.render('{{x-foo}}'); + + this.runTask(function () { + return _this.$('#is-done').trigger('change'); + }); + assert.ok(receivedEvent, 'change event was triggered'); + assert.strictEqual(receivedEvent.target, this.$('#is-done')[0]); + }; + + _class.prototype['@test dispatches to the nearest event manager'] = function testDispatchesToTheNearestEventManager(assert) { + var _this2 = this; + + var receivedEvent = undefined; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function (event) { + assert.notOk(true, 'should not trigger `click` on component'); + }, + + eventManager: { + click: function (event) { + receivedEvent = event; + } + } + }), + + template: '' + }); + + this.render('{{x-foo}}'); + + this.runTask(function () { + return _this2.$('#is-done').trigger('click'); + }); + assert.strictEqual(receivedEvent.target, this.$('#is-done')[0]); + }; + + _class.prototype['@test event manager can re-dispatch to the component'] = function testEventManagerCanReDispatchToTheComponent(assert) { + var _this3 = this; + + var handlers = []; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function () { + handlers.push('component'); + }, + + eventManager: { + click: function (event, component) { + handlers.push('eventManager'); + // Re-dispatch event when you get it. + // + // The second parameter tells the dispatcher + // that this event has been handled. This + // API will clearly need to be reworked since + // multiple eventManagers in a single view + // hierarchy would break, but it shows that + // re-dispatching works + component.$().trigger('click', this); + } + } + }), + + template: '' + }); + + this.render('{{x-foo}}'); + + this.runTask(function () { + return _this3.$('#is-done').trigger('click'); + }); + assert.deepEqual(handlers, ['eventManager', 'component']); + }; + + _class.prototype['@test event handlers are wrapped in a run loop'] = function testEventHandlersAreWrappedInARunLoop(assert) { + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + change: function () { + assert.ok(_emberMetal.run.currentRunLoop, 'a run loop should have started'); + } + }), + template: '' + }); + + this.render('{{x-foo}}'); + + this.$('#is-done').trigger('click'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher#setup', (function (_RenderingTest2) { + babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { + _RenderingTest2.call(this); + + var dispatcher = this.owner.lookup('event_dispatcher:main'); + _emberMetal.run(dispatcher, 'destroy'); + this.owner.__container__.reset('event_dispatcher:main'); + this.dispatcher = this.owner.lookup('event_dispatcher:main'); + } + + _class2.prototype['@test additonal events can be specified'] = function testAdditonalEventsCanBeSpecified(assert) { + this.dispatcher.setup({ myevent: 'myEvent' }); + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + myEvent: function () { + assert.ok(true, 'custom event was triggered'); + } + }), + template: '

    Hello!

    ' + }); + + this.render('{{x-foo}}'); + + this.$('div').trigger('myevent'); + }; + + _class2.prototype['@test a rootElement can be specified'] = function testARootElementCanBeSpecified(assert) { + this.$().append('
    '); + this.dispatcher.setup({ myevent: 'myEvent' }, '#app'); + + assert.ok(this.$('#app').hasClass('ember-application'), 'custom rootElement was used'); + assert.equal(this.dispatcher.rootElement, '#app', 'the dispatchers rootElement was updated'); + }; + + _class2.prototype['@test default events can be disabled via `customEvents`'] = function testDefaultEventsCanBeDisabledViaCustomEvents(assert) { + this.dispatcher.setup({ click: null }); + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function () { + assert.ok(false, 'click method was called'); + }, + + null: function () { + assert.ok(false, 'null method was called'); + }, + + doubleClick: function () { + assert.ok(true, 'a non-disabled event is still handled properly'); + } + }), + + template: '

    Hello!

    ' + }); + + this.render('{{x-foo}}'); + + this.$('div').trigger('click'); + this.$('div').trigger('dblclick'); + }; + + _class2.prototype['@test throws if specified rootElement does not exist'] = function testThrowsIfSpecifiedRootElementDoesNotExist(assert) { + var _this4 = this; + + assert.throws(function () { + _this4.dispatcher.setup({ myevent: 'myEvent' }, '#app'); + }); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher - Instrumentation', (function (_RenderingTest3) { + babelHelpers.inherits(_class3, _RenderingTest3); + + function _class3() { + _RenderingTest3.apply(this, arguments); + } + + _class3.prototype.teardown = function teardown() { + _RenderingTest3.prototype.teardown.call(this); + _emberMetal.instrumentationReset(); + }; + + _class3.prototype['@test instruments triggered events'] = function testInstrumentsTriggeredEvents(assert) { + var clicked = 0; + + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function (evt) { + clicked++; + } + }), + template: '

    hello

    ' + }); + + this.render('{{x-foo}}'); + + this.$('div').trigger('click'); + + assert.equal(clicked, 1, 'precond - the click handler was invoked'); + + var clickInstrumented = 0; + _emberMetal.instrumentationSubscribe('interaction.click', { + before: function () { + clickInstrumented++; + assert.equal(clicked, 1, 'invoked before event is handled'); + }, + after: function () { + clickInstrumented++; + assert.equal(clicked, 2, 'invoked after event is handled'); + } + }); + + var keypressInstrumented = 0; + _emberMetal.instrumentationSubscribe('interaction.keypress', { + before: function () { + keypressInstrumented++; + }, + after: function () { + keypressInstrumented++; + } + }); + + this.$('div').trigger('click'); + this.$('div').trigger('change'); + assert.equal(clicked, 2, 'precond - The click handler was invoked'); + assert.equal(clickInstrumented, 2, 'The click was instrumented'); + assert.strictEqual(keypressInstrumented, 0, 'The keypress was not instrumented'); + }; + + return _class3; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } + + if (canDataTransfer) { + _emberGlimmerTestsUtilsTestCase.moduleFor('EventDispatcher - Event Properties', (function (_RenderingTest4) { + babelHelpers.inherits(_class4, _RenderingTest4); + + function _class4() { + _RenderingTest4.apply(this, arguments); + } + + _class4.prototype['@test dataTransfer property is added to drop event'] = function testDataTransferPropertyIsAddedToDropEvent(assert) { + var receivedEvent = undefined; + this.registerComponent('x-foo', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + drop: function (event) { + receivedEvent = event; + } + }) + }); + + this.render('{{x-foo}}'); + + fireNativeWithDataTransfer(this.$('div')[0], 'drop', 'success'); + assert.equal(receivedEvent.dataTransfer, 'success'); + }; + + return _class4; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } +}); +enifed('ember-glimmer/tests/integration/event-dispatcher-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/event-dispatcher-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/event-dispatcher-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/-class-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{-class}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test casts binding to dasherized class'] = function testCastsBindingToDasherizedClass() { + var _this = this; + + this.registerComponent('foo-bar', { template: '' }); + this.render('{{foo-bar class=(-class someTruth "someTruth")}}', { + someTruth: true + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'someTruth', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'someTruth', true); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + }; + + _class.prototype['@tests casts leaf path of binding to dasherized class'] = function testsCastsLeafPathOfBindingToDasherizedClass() { + var _this2 = this; + + this.registerComponent('foo-bar', { template: '' }); + this.render('{{foo-bar class=(-class model.someTruth "someTruth")}}', { + model: { + someTruth: true + } + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model.someTruth', false); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('ember-view') } }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { someTruth: true }); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: _emberGlimmerTestsUtilsTestHelpers.classes('some-truth ember-view') } }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/-class-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/-class-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/-class-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/closure-action-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberMetal, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
    clicked: {{clicked}}; foo: {{foo}}
    \n\n {{click-me id="string-action" onClick=(action "on-click")}}\n {{click-me id="function-action" onClick=(action onClick)}}\n {{click-me id="mut-action" onClick=(action (mut clicked))}}\n '], ['\n
    clicked: {{clicked}}; foo: {{foo}}
    \n\n {{click-me id="string-action" onClick=(action "on-click")}}\n {{click-me id="function-action" onClick=(action onClick)}}\n {{click-me id="mut-action" onClick=(action (mut clicked))}}\n ']); + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: closure {{action}} improved instrumentation', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype.subscribe = function subscribe(eventName, options) { + this.subscriber = _emberMetal.instrumentationSubscribe(eventName, options); + }; + + _class.prototype.teardown = function teardown() { + if (this.subscriber) { + _emberMetal.instrumentationUnsubscribe(this.subscriber); + } + + _RenderingTest.prototype.teardown.call(this); + }; + + _class.prototype['@test interaction event subscriber should be passed parameters'] = function testInteractionEventSubscriberShouldBePassedParameters() { + var _this = this; + + var actionParam = 'So krispy'; + var beforeParameters = []; + var afterParameters = []; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + fireAction: function () { + this.attrs.submit(actionParam); + } + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () {} + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.subscribe('interaction.ember-action', { + before: function (name, timestamp, payload) { + beforeParameters.push(payload.args); + }, + after: function (name, timestamp, payload) { + afterParameters.push(payload.args); + } + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this.$('#instrument-button').trigger('click'); + }); + + this.assert.deepEqual(beforeParameters, [[], [actionParam]], 'instrumentation subscriber before function was passed closure action parameters'); + this.assert.deepEqual(afterParameters, [[actionParam], []], 'instrumentation subscriber after function was passed closure action parameters'); + }; + + _class.prototype['@test interaction event subscriber should be passed target'] = function testInteractionEventSubscriberShouldBePassedTarget() { + var _this2 = this; + + var beforeParameters = []; + var afterParameters = []; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + myProperty: 'inner-thing', + actions: { + fireAction: function () { + this.attrs.submit(); + } + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + myProperty: 'outer-thing', + outerSubmit: function () {} + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.subscribe('interaction.ember-action', { + before: function (name, timestamp, payload) { + beforeParameters.push(payload.target.get('myProperty')); + }, + after: function (name, timestamp, payload) { + afterParameters.push(payload.target.get('myProperty')); + } + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this2.$('#instrument-button').trigger('click'); + }); + + this.assert.deepEqual(beforeParameters, ['inner-thing', 'outer-thing'], 'instrumentation subscriber before function was passed target'); + this.assert.deepEqual(afterParameters, ['outer-thing', 'inner-thing'], 'instrumentation subscriber after function was passed target'); + }; + + _class.prototype['@test instrumented action should return value'] = function testInstrumentedActionShouldReturnValue() { + var _this3 = this; + + var returnedValue = 'Chris P is so krispy'; + var actualReturnedValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + fireAction: function () { + actualReturnedValue = this.attrs.submit(); + } + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + return returnedValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.subscribe('interaction.ember-action', { + before: function (name, timestamp, payload) {}, + after: function (name, timestamp, payload) {} + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this3.$('#instrument-button').trigger('click'); + }); + + this.assert.equal(actualReturnedValue, returnedValue, 'action can return to caller'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: closure {{action}}', (function (_RenderingTest2) { +babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test action should be called'] = function testActionShouldBeCalled() { + var outerActionCalled = false; + var component = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + outerActionCalled = true; + } + }); + + this.registerComponent('inner-component', { ComponentClass: InnerComponent, template: 'inner' }); + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + component.fireAction(); + }); + + this.assert.ok(outerActionCalled, 'the action was called'); + }; + + _class2.prototype['@test an error is triggered when bound action function is undefined'] = function testAnErrorIsTriggeredWhenBoundActionFunctionIsUndefined() { + var _this4 = this; + + this.registerComponent('inner-component', { + template: 'inner' + }); + this.registerComponent('outer-component', { + template: '{{inner-component submit=(action somethingThatIsUndefined)}}' + }); + + expectAssertion(function () { + _this4.render('{{outer-component}}'); + }, /Action passed is null or undefined in \(action[^)]*\) from .*\./); + }; + + _class2.prototype['@test an error is triggered when bound action being passed in is a non-function'] = function testAnErrorIsTriggeredWhenBoundActionBeingPassedInIsANonFunction() { + var _this5 = this; + + this.registerComponent('inner-component', { + template: 'inner' + }); + this.registerComponent('outer-component', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + nonFunctionThing: {} + }), + template: '{{inner-component submit=(action nonFunctionThing)}}' + }); + + expectAssertion(function () { + _this5.render('{{outer-component}}'); + }, /An action could not be made for `.*` in .*\. Please confirm that you are using either a quoted action name \(i\.e\. `\(action '.*'\)`\) or a function available in .*\./); + }; + + _class2.prototype['@test [#12718] a nice error is shown when a bound action function is undefined and it is passed as attrs.foo'] = function test12718ANiceErrorIsShownWhenABoundActionFunctionIsUndefinedAndItIsPassedAsAttrsFoo() { + var _this6 = this; + + this.registerComponent('inner-component', { + template: '' + }); + + this.registerComponent('outer-component', { + template: '{{inner-component}}' + }); + + expectAssertion(function () { + _this6.render('{{outer-component}}'); + }, /Action passed is null or undefined in \(action[^)]*\) from .*\./); + }; + + _class2.prototype['@test action value is returned'] = function testActionValueIsReturned() { + var expectedValue = 'terrible tom'; + var returnedValue = undefined; + var innerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + returnedValue = this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerSubmit: function () { + return expectedValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(returnedValue, expectedValue, 'action can return to caller'); + }; + + _class2.prototype['@test action should be called on the correct scope'] = function testActionShouldBeCalledOnTheCorrectScope() { + var innerComponent = undefined; + var outerComponent = undefined; + var actualComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + isOuterComponent: true, + outerSubmit: function () { + actualComponent = this; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualComponent, outerComponent, 'action has the correct context'); + this.assert.ok(actualComponent.isOuterComponent, 'action has the correct context'); + }; + + _class2.prototype['@test arguments to action are passed, curry'] = function testArgumentsToActionArePassedCurry() { + var first = 'mitch'; + var second = 'martin'; + var third = 'matt'; + var fourth = 'wacky wycats'; + + var innerComponent = undefined; + var actualArgs = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(fourth); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + third: third, + outerSubmit: function (actualFirst, actualSecond, actualThird, actualFourth) { + actualArgs = [].concat(babelHelpers.slice.call(arguments)); + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action (action outerSubmit "' + first + '") "' + second + '" third)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.deepEqual(actualArgs, [first, second, third, fourth], 'action has the correct args'); + }; + + _class2.prototype['@test `this` can be passed as an argument'] = function testThisCanBePassedAsAnArgument() { + var value = {}; + var component = undefined; + var innerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + outerAction: function (incomingValue) { + value = incomingValue; + } + } + }); + + this.registerComponent('inner-component', { ComponentClass: InnerComponent, template: 'inner' }); + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action "outerAction" this)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.strictEqual(value, component, 'the component is passed at `this`'); + }; + + _class2.prototype['@test arguments to action are bound'] = function testArgumentsToActionAreBound() { + var value = 'lazy leah'; + + var innerComponent = undefined; + var outerComponent = undefined; + var actualArg = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + value: '', + outerSubmit: function (incomingValue) { + actualArg = incomingValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit value)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.strictEqual(actualArg, '', 'action has the correct first arg'); + + this.runTask(function () { + outerComponent.set('value', value); + }); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.strictEqual(actualArg, value, 'action has the correct first arg'); + }; + + _class2.prototype['@test array arguments are passed correctly to action'] = function testArrayArgumentsArePassedCorrectlyToAction() { + var first = 'foo'; + var second = [3, 5]; + var third = [4, 9]; + + var actualFirst = undefined; + var actualSecond = undefined; + var actualThird = undefined; + + var innerComponent = undefined; + var outerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(second, third); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + outerSubmit: function (incomingFirst, incomingSecond, incomingThird) { + actualFirst = incomingFirst; + actualSecond = incomingSecond; + actualThird = incomingThird; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerSubmit first)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + outerComponent.set('first', first); + outerComponent.set('second', second); + }); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualFirst, first, 'action has the correct first arg'); + this.assert.equal(actualSecond, second, 'action has the correct second arg'); + this.assert.equal(actualThird, third, 'action has the correct third arg'); + }; + + _class2.prototype['@test mut values can be wrapped in actions, are settable'] = function testMutValuesCanBeWrappedInActionsAreSettable() { + var newValue = 'trollin trek'; + + var innerComponent = undefined; + var outerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(newValue); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + outerMut: 'patient peter' + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action (mut outerMut))}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set'); + }; + + _class2.prototype['@test mut values can be wrapped in actions, are settable with a curry'] = function testMutValuesCanBeWrappedInActionsAreSettableWithACurry() { + var newValue = 'trollin trek'; + + var innerComponent = undefined; + var outerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + outerComponent = this; + }, + outerMut: 'patient peter' + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action (mut outerMut) \'' + newValue + '\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set'); + }; + + _class2.prototype['@test action can create closures over actions'] = function testActionCanCreateClosuresOverActions() { + var first = 'raging robert'; + var second = 'mild machty'; + var returnValue = 'butch brian'; + + var actualFirst = undefined; + var actualSecond = undefined; + var actualReturnedValue = undefined; + + var innerComponent = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + actualReturnedValue = this.attrs.submit(second); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + outerAction: function (incomingFirst, incomingSecond) { + actualFirst = incomingFirst; + actualSecond = incomingSecond; + return returnValue; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'outerAction\' \'' + first + '\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualReturnedValue, returnValue, 'return value is present'); + this.assert.equal(actualFirst, first, 'first argument is correct'); + this.assert.equal(actualSecond, second, 'second argument is correct'); + }; + + _class2.prototype['@test provides a helpful error if an action is not present'] = function testProvidesAHelpfulErrorIfAnActionIsNotPresent() { + var _this7 = this; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + something: function () { + // this is present to ensure `actions` hash is present + // a different error is triggered if `actions` is missing + // completely + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'doesNotExist\')}}' + }); + + expectAssertion(function () { + _this7.render('{{outer-component}}'); + }, /An action named 'doesNotExist' was not found in /); + }; + + _class2.prototype['@test provides a helpful error if actions hash is not present'] = function testProvidesAHelpfulErrorIfActionsHashIsNotPresent() { + var _this8 = this; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'doesNotExist\')}}' + }); + + expectAssertion(function () { + _this8.render('{{outer-component}}'); + }, /An action named 'doesNotExist' was not found in /); + }; + + _class2.prototype['@test action can create closures over actions with target'] = function testActionCanCreateClosuresOverActionsWithTarget() { + var innerComponent = undefined; + var actionCalled = false; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + otherComponent: _emberMetal.computed(function () { + return { + actions: { + outerAction: function () { + actionCalled = true; + } + } + }; + }) + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'outerAction\' target=otherComponent)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.ok(actionCalled, 'action called on otherComponent'); + }; + + _class2.prototype['@test value can be used with action over actions'] = function testValueCanBeUsedWithActionOverActions() { + var newValue = 'yelping yehuda'; + + var innerComponent = undefined; + var actualValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit({ + readProp: newValue + }); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerContent: { + readProp: newValue + }, + actions: { + outerAction: function (incomingValue) { + actualValue = incomingValue; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'outerAction\' value="readProp")}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualValue, newValue, 'value is read'); + }; + + _class2.prototype['@test action will read the value of a first property'] = function testActionWillReadTheValueOfAFirstProperty() { + var newValue = 'irate igor'; + + var innerComponent = undefined; + var actualValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit({ + readProp: newValue + }); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + outerAction: function (incomingValue) { + actualValue = incomingValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerAction value="readProp")}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualValue, newValue, 'property is read'); + }; + + _class2.prototype['@test action will read the value of a curried first argument property'] = function testActionWillReadTheValueOfACurriedFirstArgumentProperty() { + var newValue = 'kissing kris'; + + var innerComponent = undefined; + var actualValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + objectArgument: { + readProp: newValue + }, + outerAction: function (incomingValue) { + actualValue = incomingValue; + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action outerAction objectArgument value="readProp")}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actualValue, newValue, 'property is read'); + }; + + _class2.prototype['@test action closure does not get auto-mut wrapped'] = function testActionClosureDoesNotGetAutoMutWrapped(assert) { + var first = 'raging robert'; + var second = 'mild machty'; + var returnValue = 'butch brian'; + + var innerComponent = undefined; + var actualFirst = undefined; + var actualSecond = undefined; + var actualReturnedValue = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.get('submit')(second); + this.get('attrs-submit')(second); + var attrsSubmitReturnValue = this.attrs['attrs-submit'](second); + var submitReturnValue = this.attrs.submit(second); + + assert.equal(attrsSubmitReturnValue, submitReturnValue, 'both attrs.foo and foo should behave the same'); + + return submitReturnValue; + } + }); + + var MiddleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + outerAction: function (incomingFirst, incomingSecond) { + actualFirst = incomingFirst; + actualSecond = incomingSecond; + return returnValue; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('middle-component', { + ComponentClass: MiddleComponent, + template: '{{inner-component attrs-submit=attrs.submit submit=submit}}' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{middle-component submit=(action \'outerAction\' \'' + first + '\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + actualReturnedValue = innerComponent.fireAction(); + }); + + this.assert.equal(actualFirst, first, 'first argument is correct'); + this.assert.equal(actualSecond, second, 'second argument is correct'); + this.assert.equal(actualReturnedValue, returnValue, 'return value is present'); + }; + + _class2.prototype['@test action should be called within a run loop'] = function testActionShouldBeCalledWithinARunLoop() { + var innerComponent = undefined; + var capturedRunLoop = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + this.attrs.submit(); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + submit: function () { + capturedRunLoop = _emberMetal.run.currentRunLoop; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action \'submit\')}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.ok(capturedRunLoop, 'action is called within a run loop'); + }; + + _class2.prototype['@test objects that define INVOKE can be casted to actions'] = function testObjectsThatDefineINVOKECanBeCastedToActions() { + var innerComponent = undefined; + var actionArgs = undefined; + var invokableArgs = undefined; + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + innerComponent = this; + }, + fireAction: function () { + actionArgs = this.attrs.submit(4, 5, 6); + } + }); + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + foo: 123, + submitTask: _emberMetal.computed(function () { + var _ref, + _this9 = this; + + return _ref = {}, _ref[_emberGlimmerTestsUtilsHelpers.INVOKE] = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + invokableArgs = args; + return _this9.foo; + }, _ref; + }) + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: 'inner' + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: '{{inner-component submit=(action submitTask 1 2 3)}}' + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + innerComponent.fireAction(); + }); + + this.assert.equal(actionArgs, 123); + this.assert.deepEqual(invokableArgs, [1, 2, 3, 4, 5, 6]); + }; + + _class2.prototype['@test closure action with `(mut undefinedThing)` works properly [GH#13959]'] = function testClosureActionWithMutUndefinedThingWorksProperlyGH13959() { + var _this10 = this; + + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + label: undefined, + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assertText('Click me'); + + this.assertStableRerender(); + + this.runTask(function () { + _this10.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', 'Dun clicked'); + }); + + this.assertText('Dun clicked'); + + this.runTask(function () { + _this10.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', undefined); + }); + + this.assertText('Click me'); + }; + + _class2.prototype['@test closure actions does not cause component hooks to fire unnecessarily [GH#14305] [GH#14654]'] = function testClosureActionsDoesNotCauseComponentHooksToFireUnnecessarilyGH14305GH14654(assert) { + var _this12 = this; + + var clicked = 0; + var didReceiveAttrsFired = 0; + + var ClickMeComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + tagName: 'button', + + click: function () { + this.get('onClick').call(undefined, ++clicked); + }, + + didReceiveAttrs: function () { + didReceiveAttrsFired++; + } + }); + + this.registerComponent('click-me', { + ComponentClass: ClickMeComponent + }); + + var outer = undefined; + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + clicked: 0, + + actions: { + 'on-click': function () { + this.incrementProperty('clicked'); + } + }, + + init: function () { + var _this11 = this; + + this._super(); + outer = this; + this.set('onClick', function () { + return _this11.incrementProperty('clicked'); + }); + } + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject) + }); + + this.render('{{outer-component foo=foo}}', { foo: 1 }); + + this.assertText('clicked: 0; foo: 1'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('clicked: 0; foo: 1'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'foo', 2); + }); + + this.assertText('clicked: 0; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#string-action').click(); + }); + + this.assertText('clicked: 1; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#function-action').click(); + }); + + this.assertText('clicked: 2; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _emberMetal.set(outer, 'onClick', function () { + outer.incrementProperty('clicked'); + }); + }); + + this.assertText('clicked: 2; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#function-action').click(); + }); + + this.assertText('clicked: 3; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + + this.runTask(function () { + return _this12.$('#mut-action').click(); + }); + + this.assertText('clicked: 4; foo: 2'); + + assert.equal(didReceiveAttrsFired, 3); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/closure-action-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/closure-action-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/closure-action-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/concat-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{concat}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it concats static arguments'] = function testItConcatsStaticArguments() { + this.render('{{concat "foo" " " "bar" " " "baz"}}'); + this.assertText('foo bar baz'); + }; + + _class.prototype['@test it updates for bound arguments'] = function testItUpdatesForBoundArguments() { + var _this = this; + + this.render('{{concat model.first model.second}}', { + model: { first: 'one', second: 'two' } + }); + + this.assertText('onetwo'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('onetwo'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.first', 'three'); + }); + + this.assertText('threetwo'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.second', 'four'); + }); + + this.assertText('threefour'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model', { first: 'one', second: 'two' }); + }); + + this.assertText('onetwo'); + }; + + _class.prototype['@test it can be used as a sub-expression'] = function testItCanBeUsedAsASubExpression() { + var _this2 = this; + + this.render('{{concat (concat model.first model.second) (concat model.third model.fourth)}}', { + model: { + first: 'one', + second: 'two', + third: 'three', + fourth: 'four' + } + }); + + this.assertText('onetwothreefour'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('onetwothreefour'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model.first', 'five'); + }); + + this.assertText('fivetwothreefour'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model.second', 'six'); + _emberMetal.set(_this2.context, 'model.third', 'seven'); + }); + + this.assertText('fivesixsevenfour'); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'model', { + first: 'one', + second: 'two', + third: 'three', + fourth: 'four' + }); + }); + + this.assertText('onetwothreefour'); + }; + + _class.prototype['@test it can be used as input for other helpers'] = function testItCanBeUsedAsInputForOtherHelpers() { + var _this3 = this; + + this.registerHelper('x-eq', function (_ref) { + var actual = _ref[0]; + var expected = _ref[1]; + return actual === expected; + }); + + this.render('{{#if (x-eq (concat model.first model.second) "onetwo")}}Truthy!{{else}}False{{/if}}', { + model: { + first: 'one', + second: 'two' + } + }); + + this.assertText('Truthy!'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Truthy!'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.first', 'three'); + }); + + this.assertText('False'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { first: 'one', second: 'two' }); + }); + + this.assertText('Truthy!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/concat-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/concat-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/concat-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/custom-helper-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'internal-test-helpers', 'ember-metal', 'ember-utils'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _internalTestHelpers, _emberMetal, _emberUtils) { + /* globals EmberDev */ + 'use strict'; + + var assert = QUnit.assert; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: custom helpers', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it cannot override built-in syntax'] = function testItCannotOverrideBuiltInSyntax() { + var _this = this; + + this.registerHelper('if', function () { + return 'Nope'; + }); + expectAssertion(function () { + _this.render('{{if foo \'LOL\'}}', { foo: true }); + }, /You attempted to overwrite the built-in helper \"if\" which is not allowed. Please rename the helper./); + }; + + _class.prototype['@test it can resolve custom simple helpers with or without dashes'] = function testItCanResolveCustomSimpleHelpersWithOrWithoutDashes() { + var _this2 = this; + + this.registerHelper('hello', function () { + return 'hello'; + }); + this.registerHelper('hello-world', function () { + return 'hello world'; + }); + + this.render('{{hello}} | {{hello-world}}'); + + this.assertText('hello | hello world'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('hello | hello world'); + }; + + _class.prototype['@test it does not resolve helpers with a `.` (period)'] = function testItDoesNotResolveHelpersWithAPeriod() { + var _this3 = this; + + this.registerHelper('hello.world', function () { + return 'hello world'; + }); + + this.render('{{hello.world}}', { + hello: { + world: '' + } + }); + + this.assertText(''); + + this.assertStableRerender(); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'hello', { world: 'hello world!' }); + }); + + this.assertText('hello world!'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'hello', { + world: '' + }); + }); + + this.assertText(''); + }; + + _class.prototype['@test it can resolve custom makeBoundHelper with or without dashes [DEPRECATED]'] = function testItCanResolveCustomMakeBoundHelperWithOrWithoutDashesDEPRECATED() { + var _this4 = this; + + expectDeprecation(function () { + _this4.owner.register('helper:hello', _emberGlimmerTestsUtilsHelpers.makeBoundHelper(function () { + return 'hello'; + })); + }, 'Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.'); + + expectDeprecation(function () { + _this4.owner.register('helper:hello-world', _emberGlimmerTestsUtilsHelpers.makeBoundHelper(function () { + return 'hello world'; + })); + }, 'Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.'); + + this.render('{{hello}} | {{hello-world}}'); + + this.assertText('hello | hello world'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('hello | hello world'); + }; + + _class.prototype['@test it can resolve custom class-based helpers with or without dashes'] = function testItCanResolveCustomClassBasedHelpersWithOrWithoutDashes() { + var _this5 = this; + + this.registerHelper('hello', { + compute: function () { + return 'hello'; + } + }); + + this.registerHelper('hello-world', { + compute: function () { + return 'hello world'; + } + }); + + this.render('{{hello}} | {{hello-world}}'); + + this.assertText('hello | hello world'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('hello | hello world'); + }; + + _class.prototype['@test throws if `this._super` is not called from `init`'] = function testThrowsIfThis_superIsNotCalledFromInit() { + var _this6 = this; + + this.registerHelper('hello-world', { + init: function () {} + }); + + expectAssertion(function () { + _this6.render('{{hello-world}}'); + }, /You must call `this._super\(...arguments\);` when overriding `init` on a framework object. Please update .* to call `this._super\(...arguments\);` from `init`./); + }; + + _class.prototype['@test class-based helper can recompute a new value'] = function testClassBasedHelperCanRecomputeANewValue() { + var _this7 = this; + + var destroyCount = 0; + var computeCount = 0; + var helper = undefined; + + this.registerHelper('hello-world', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return ++computeCount; + }, + destroy: function () { + destroyCount++; + this._super(); + } + }); + + this.render('{{hello-world}}'); + + this.assertText('1'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('1'); + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('2'); + + assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation'); + }; + + _class.prototype['@test class-based helper with static arguments can recompute a new value'] = function testClassBasedHelperWithStaticArgumentsCanRecomputeANewValue() { + var _this8 = this; + + var destroyCount = 0; + var computeCount = 0; + var helper = undefined; + + this.registerHelper('hello-world', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return ++computeCount; + }, + destroy: function () { + destroyCount++; + this._super(); + } + }); + + this.render('{{hello-world "whut"}}'); + + this.assertText('1'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('1'); + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('2'); + + assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation'); + }; + + _class.prototype['@test helper params can be returned'] = function testHelperParamsCanBeReturned() { + this.registerHelper('hello-world', function (values) { + return values; + }); + + this.render('{{#each (hello-world model) as |item|}}({{item}}){{/each}}', { + model: ['bob'] + }); + + this.assertText('(bob)'); + }; + + _class.prototype['@test helper hash can be returned'] = function testHelperHashCanBeReturned() { + this.registerHelper('hello-world', function (_, hash) { + return hash.model; + }); + + this.render('{{get (hello-world model=model) \'name\'}}', { + model: { name: 'bob' } + }); + + this.assertText('bob'); + }; + + _class.prototype['@test simple helper is called for param changes'] = function testSimpleHelperIsCalledForParamChanges() { + var _this9 = this; + + var computeCount = 0; + + this.registerHelper('hello-world', function (_ref) { + var value = _ref[0]; + + computeCount++; + return value + '-value'; + }); + + this.render('{{hello-world model.name}}', { + model: { name: 'bob' } + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'model.name', 'sal'); + }); + + this.assertText('sal-value'); + + assert.strictEqual(computeCount, 2, 'compute is called exactly 2 times'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'model', { name: 'bob' }); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 3, 'compute is called exactly 3 times'); + }; + + _class.prototype['@test class-based helper compute is called for param changes'] = function testClassBasedHelperComputeIsCalledForParamChanges() { + var _this10 = this; + + var createCount = 0; + var computeCount = 0; + + this.registerHelper('hello-world', { + init: function () { + this._super.apply(this, arguments); + createCount++; + }, + compute: function (_ref2) { + var value = _ref2[0]; + + computeCount++; + return value + '-value'; + } + }); + + this.render('{{hello-world model.name}}', { + model: { name: 'bob' } + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'model.name', 'sal'); + }); + + this.assertText('sal-value'); + + assert.strictEqual(computeCount, 2, 'compute is called exactly 2 times'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'model', { name: 'bob' }); + }); + + this.assertText('bob-value'); + + assert.strictEqual(computeCount, 3, 'compute is called exactly 3 times'); + assert.strictEqual(createCount, 1, 'helper is only created once'); + }; + + _class.prototype['@test simple helper receives params, hash'] = function testSimpleHelperReceivesParamsHash() { + var _this11 = this; + + this.registerHelper('hello-world', function (_params, _hash) { + return 'params: ' + JSON.stringify(_params) + ', hash: ' + JSON.stringify(_hash); + }); + + this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', { + model: { + name: 'bob', + age: 42 + } + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'model.name', 'sal'); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'model.age', 28); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'model', { name: 'bob', age: 42 }); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + }; + + _class.prototype['@test class-based helper receives params, hash'] = function testClassBasedHelperReceivesParamsHash() { + var _this12 = this; + + this.registerHelper('hello-world', { + compute: function (_params, _hash) { + return 'params: ' + JSON.stringify(_params) + ', hash: ' + JSON.stringify(_hash); + } + }); + + this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', { + model: { + name: 'bob', + age: 42 + } + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model.name', 'sal'); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model.age', 28); + }); + + this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model', { name: 'bob', age: 42 }); + }); + + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); + }; + + _class.prototype['@test class-based helper usable in subexpressions'] = function testClassBasedHelperUsableInSubexpressions() { + var _this13 = this; + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.render('{{join-words "Who"\n (join-words "overcomes" "by")\n model.reason\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}', { model: { reason: 'force' } }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model.reason', 'Nickleback'); + }); + + this.assertText('Who overcomes by Nickleback hath overcome but half his foe'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'model', { reason: 'force' }); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + }; + + _class.prototype['@test parameterless helper is usable in subexpressions'] = function testParameterlessHelperIsUsableInSubexpressions() { + var _this14 = this; + + this.registerHelper('should-show', function () { + return true; + }); + + this.render('{{#if (should-show)}}true{{/if}}'); + + this.assertText('true'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('true'); + }; + + _class.prototype['@test parameterless helper is usable in attributes'] = function testParameterlessHelperIsUsableInAttributes() { + var _this15 = this; + + this.registerHelper('foo-bar', function () { + return 'baz'; + }); + + this.render('
    '); + + this.assertHTML('
    '); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertHTML('
    '); + }; + + _class.prototype['@test simple helper not usable with a block'] = function testSimpleHelperNotUsableWithABlock() { + var _this16 = this; + + this.registerHelper('some-helper', function () {}); + + expectAssertion(function () { + _this16.render('{{#some-helper}}{{/some-helper}}'); + }, /Helpers may not be used in the block form/); + }; + + _class.prototype['@test class-based helper not usable with a block'] = function testClassBasedHelperNotUsableWithABlock() { + var _this17 = this; + + this.registerHelper('some-helper', { + compute: function () {} + }); + + expectAssertion(function () { + _this17.render('{{#some-helper}}{{/some-helper}}'); + }, /Helpers may not be used in the block form/); + }; + + _class.prototype['@test simple helper not usable within element'] = function testSimpleHelperNotUsableWithinElement() { + var _this18 = this; + + this.registerHelper('some-helper', function () {}); + + this.assert.throws(function () { + _this18.render('
    '); + }, /Compile Error some-helper is not a modifier: Helpers may not be used in the element form/); + }; + + _class.prototype['@test class-based helper not usable within element'] = function testClassBasedHelperNotUsableWithinElement() { + var _this19 = this; + + this.registerHelper('some-helper', { + compute: function () {} + }); + + this.assert.throws(function () { + _this19.render('
    '); + }, /Compile Error some-helper is not a modifier: Helpers may not be used in the element form/); + }; + + _class.prototype['@test class-based helper is torn down'] = function testClassBasedHelperIsTornDown() { + var destroyCalled = 0; + + this.registerHelper('some-helper', { + destroy: function () { + destroyCalled++; + this._super.apply(this, arguments); + }, + compute: function () { + return 'must define a compute'; + } + }); + + this.render('{{some-helper}}'); + + _internalTestHelpers.runDestroy(this.component); + + assert.strictEqual(destroyCalled, 1, 'destroy called once'); + }; + + _class.prototype['@test class-based helper used in subexpression can recompute'] = function testClassBasedHelperUsedInSubexpressionCanRecompute() { + var _this20 = this; + + var helper = undefined; + var phrase = 'overcomes by'; + + this.registerHelper('dynamic-segment', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return phrase; + } + }); + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.render('{{join-words "Who"\n (dynamic-segment)\n "force"\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}'); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _this20.rerender(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + phrase = 'believes his'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who believes his force hath overcome but half his foe'); + + phrase = 'overcomes by'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + }; + + _class.prototype['@test class-based helper used in subexpression can recompute component'] = function testClassBasedHelperUsedInSubexpressionCanRecomputeComponent() { + var _this21 = this; + + var helper = undefined; + var phrase = 'overcomes by'; + + this.registerHelper('dynamic-segment', { + init: function () { + this._super.apply(this, arguments); + helper = this; + }, + compute: function () { + return phrase; + } + }); + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.registerComponent('some-component', { + template: '{{first}} {{second}} {{third}} {{fourth}} {{fifth}}' + }); + + this.render('{{some-component first="Who"\n second=(dynamic-segment)\n third="force"\n fourth=(join-words (join-words "hath overcome but" "half"))\n fifth=(join-words "his" (join-words "foe"))}}'); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + + phrase = 'believes his'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who believes his force hath overcome but half his foe'); + + phrase = 'overcomes by'; + + this.runTask(function () { + return helper.recompute(); + }); + + this.assertText('Who overcomes by force hath overcome but half his foe'); + }; + + _class.prototype['@test class-based helper used in subexpression is destroyed'] = function testClassBasedHelperUsedInSubexpressionIsDestroyed() { + var destroyCount = 0; + + this.registerHelper('dynamic-segment', { + phrase: 'overcomes by', + init: function () { + this._super.apply(this, arguments); + }, + compute: function () { + return this.phrase; + }, + destroy: function () { + destroyCount++; + this._super.apply(this, arguments); + } + }); + + this.registerHelper('join-words', { + compute: function (params) { + return params.join(' '); + } + }); + + this.render('{{join-words "Who"\n (dynamic-segment)\n "force"\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}'); + + _internalTestHelpers.runDestroy(this.component); + + equal(destroyCount, 1, 'destroy is called after a view is destroyed'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + // these feature detects prevent errors in these tests + // on platforms (*cough* IE9 *cough*) that do not + // property support `Object.freeze` + var pushingIntoFrozenArrayThrows = (function () { + var array = []; + Object.freeze(array); + + try { + array.push('foo'); + + return false; + } catch (e) { + return true; + } + })(); + + var assigningExistingFrozenPropertyThrows = (function () { + var obj = { foo: 'asdf' }; + Object.freeze(obj); + + try { + obj.foo = 'derp'; + + return false; + } catch (e) { + return true; + } + })(); + + var addingPropertyToFrozenObjectThrows = (function () { + var obj = { foo: 'asdf' }; + Object.freeze(obj); + + try { + obj.bar = 'derp'; + + return false; + } catch (e) { + return true; + } + })(); + + if (!EmberDev.runningProdBuild && _emberUtils.HAS_NATIVE_WEAKMAP && (pushingIntoFrozenArrayThrows || assigningExistingFrozenPropertyThrows || addingPropertyToFrozenObjectThrows)) { + (function () { + var HelperMutatingArgsTests = (function (_RenderingTest2) { + babelHelpers.inherits(HelperMutatingArgsTests, _RenderingTest2); + + function HelperMutatingArgsTests() { + _RenderingTest2.apply(this, arguments); + } + + HelperMutatingArgsTests.prototype.buildCompute = function buildCompute() { + var _this22 = this; + + return function (params, hash) { + if (pushingIntoFrozenArrayThrows) { + _this22.assert.throws(function () { + params.push('foo'); + + // cannot assert error message as it varies by platform + }); + } + + if (assigningExistingFrozenPropertyThrows) { + _this22.assert.throws(function () { + hash.foo = 'bar'; + + // cannot assert error message as it varies by platform + }); + } + + if (addingPropertyToFrozenObjectThrows) { + _this22.assert.throws(function () { + hash.someUnusedHashProperty = 'bar'; + + // cannot assert error message as it varies by platform + }); + } + }; + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - no positional specified / named specified'] = function testCannotMutateParamsNoPositionalSpecifiedNamedSpecified() { + this.render('{{test-helper foo=bar}}', { bar: 'derp' }); + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - positional specified / no named specified'] = function testCannotMutateParamsPositionalSpecifiedNoNamedSpecified() { + this.render('{{test-helper bar}}', { bar: 'derp' }); + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - positional specified / named specified'] = function testCannotMutateParamsPositionalSpecifiedNamedSpecified() { + this.render('{{test-helper bar foo=qux}}', { bar: 'derp', qux: 'baz' }); + }; + + HelperMutatingArgsTests.prototype['@test cannot mutate params - no positional specified / no named specified'] = function testCannotMutateParamsNoPositionalSpecifiedNoNamedSpecified() { + this.render('{{test-helper}}', { bar: 'derp', qux: 'baz' }); + }; + + return HelperMutatingArgsTests; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: mutation triggers errors - class based helper', (function (_HelperMutatingArgsTests) { + babelHelpers.inherits(_class2, _HelperMutatingArgsTests); + + function _class2() { + _HelperMutatingArgsTests.call(this); + + var compute = this.buildCompute(); + + this.registerHelper('test-helper', { + compute: compute + }); + } + + return _class2; + })(HelperMutatingArgsTests)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: mutation triggers errors - simple helper', (function (_HelperMutatingArgsTests2) { + babelHelpers.inherits(_class3, _HelperMutatingArgsTests2); + + function _class3() { + _HelperMutatingArgsTests2.call(this); + + var compute = this.buildCompute(); + + this.registerHelper('test-helper', compute); + } + + return _class3; + })(HelperMutatingArgsTests)); + })(); + } +}); +enifed('ember-glimmer/tests/integration/helpers/custom-helper-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/custom-helper-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/custom-helper-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/element-action-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember-runtime', 'ember-views'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal, _emberRuntime, _emberViews) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#inner-component}}\n \n {{/inner-component}}\n '], ['\n {{#inner-component}}\n \n {{/inner-component}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#target-component as |parent|}}\n {{other-component anotherTarget=parent}}\n {{/target-component}}\n '], ['\n {{#target-component as |parent|}}\n {{other-component anotherTarget=parent}}\n {{/target-component}}\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#target-component as |aTarget|}}\n click me\n {{/target-component}}\n '], ['\n {{#target-component as |aTarget|}}\n click me\n {{/target-component}}\n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n click me'], ['\n click me']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#middle-component}}\n {{inner-component action="hey"}}\n {{/middle-component}}\n '], ['\n {{#middle-component}}\n {{inner-component action="hey"}}\n {{/middle-component}}\n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n \n {{yield}}\n '], ['\n \n {{yield}}\n ']); + + function getActionAttributes(element) { + var attributes = element.attributes; + var actionAttrs = []; + + for (var i = 0; i < attributes.length; i++) { + var attr = attributes.item(i); + + if (attr.name.indexOf('data-ember-action-') === 0) { + actionAttrs.push(attr.name); + } + } + + return actionAttrs; + } + + function getActionIds(element) { + return getActionAttributes(element).map(function (attribute) { + return attribute.slice('data-ember-action-'.length); + }); + } + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: element action instrumentation', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + _emberMetal.instrumentationReset(); + }; + + _class.prototype['@test action should fire interaction event with proper params'] = function testActionShouldFireInteractionEventWithProperParams() { + var _this = this; + + var subscriberCallCount = 0; + var subscriberPayload = null; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + foo: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + _emberMetal.instrumentationSubscribe('interaction.ember-action', { + before: function () { + subscriberCallCount++; + }, + after: function (name, time, payload) { + subscriberPayload = payload; + } + }); + + this.render('{{example-component}}'); + + this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called'); + + this.runTask(function () { + _this.$('button').click(); + }); + + this.assert.equal(subscriberCallCount, 1, 'subscriber has been called 1 time'); + this.assert.equal(subscriberPayload.name, 'foo', 'subscriber called with correct name'); + this.assert.equal(subscriberPayload.args[0], 'bar', 'subscriber called with correct args'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: element action', (function (_RenderingTest2) { +babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test it can call an action on its enclosing component'] = function testItCanCallAnActionOnItsEnclosingComponent() { + var _this2 = this; + + var fooCallCount = 0; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + foo: function () { + fooCallCount++; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assert.equal(fooCallCount, 0, 'foo has not been called'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assert.equal(fooCallCount, 0, 'foo has not been called'); + + this.runTask(function () { + _this2.$('button').click(); + }); + + this.assert.equal(fooCallCount, 1, 'foo has been called 1 time'); + + this.runTask(function () { + _this2.$('button').click(); + }); + + this.assert.equal(fooCallCount, 2, 'foo has been called 2 times'); + }; + + _class2.prototype['@test it can call an action with parameters'] = function testItCanCallAnActionWithParameters() { + var _this3 = this; + + var fooArgs = []; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + member: 'a', + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + foo: function (thing) { + fooArgs.push(thing); + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assert.deepEqual(fooArgs, [], 'foo has not been called'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assert.deepEqual(fooArgs, [], 'foo has not been called'); + + this.runTask(function () { + _this3.$('button').click(); + }); + + this.assert.deepEqual(fooArgs, ['a'], 'foo has not been called'); + + this.runTask(function () { + component.set('member', 'b'); + }); + + this.runTask(function () { + _this3.$('button').click(); + }); + + this.assert.deepEqual(fooArgs, ['a', 'b'], 'foo has been called with an updated value'); + }; + + _class2.prototype['@test it should output a marker attribute with a guid'] = function testItShouldOutputAMarkerAttributeWithAGuid() { + this.render(''); + + var button = this.$('button'); + + var attributes = getActionAttributes(button.get(0)); + + this.assert.ok(button.attr('data-ember-action').match(''), 'An empty data-ember-action attribute was added'); + this.assert.ok(attributes[0].match(/data-ember-action-\d+/), 'A data-ember-action-xyz attribute with a guid was added'); + }; + + _class2.prototype['@test it should allow alternative events to be handled'] = function testItShouldAllowAlternativeEventsToBeHandled() { + var _this4 = this; + + var showCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + showCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '
    ' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('mouseup'); + _this4.$('#show').trigger(event); + }); + + this.assert.ok(showCalled, 'show action was called on mouseUp'); + }; + + _class2.prototype['@test inside a yield, the target points at the original target'] = function testInsideAYieldTheTargetPointsAtTheOriginalTarget() { + var _this5 = this; + + var targetWatted = false; + var innerWatted = false; + + var TargetComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + wat: function () { + targetWatted = true; + } + } + }); + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + wat: function () { + innerWatted = true; + } + } + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: '{{yield}}' + }); + + this.registerComponent('target-component', { + ComponentClass: TargetComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject) + }); + + this.render('{{target-component}}'); + + this.runTask(function () { + _this5.$('button').click(); + }); + + this.assert.ok(targetWatted, 'the correct target was watted'); + this.assert.notOk(innerWatted, 'the inner target was not watted'); + }; + + _class2.prototype['@test it should allow a target to be specified'] = function testItShouldAllowATargetToBeSpecified() { + var _this6 = this; + + var targetWatted = false; + + var TargetComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + wat: function () { + targetWatted = true; + } + } + }); + + var OtherComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + this.registerComponent('target-component', { + ComponentClass: TargetComponent, + template: '{{yield this}}' + }); + + this.registerComponent('other-component', { + ComponentClass: OtherComponent, + template: 'Wat?' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.runTask(function () { + _this6.$('a').click(); + }); + + this.assert.equal(targetWatted, true, 'the specified target was watted'); + }; + + _class2.prototype['@test it should lazily evaluate the target'] = function testItShouldLazilyEvaluateTheTarget() { + var _this7 = this; + + var firstEdit = 0; + var secondEdit = 0; + var component = undefined; + + var first = { + edit: function () { + firstEdit++; + } + }; + + var second = { + edit: function () { + secondEdit++; + } + }; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + theTarget: first + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Edit' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this7.$('a').click(); + }); + + this.assert.equal(firstEdit, 1); + + this.runTask(function () { + _emberMetal.set(component, 'theTarget', second); + }); + + this.runTask(function () { + _this7.$('a').click(); + }); + + this.assert.equal(firstEdit, 1); + this.assert.equal(secondEdit, 1); + }; + + _class2.prototype['@test it should register an event handler'] = function testItShouldRegisterAnEventHandler() { + var _this8 = this; + + var editHandlerWasCalled = false; + var shortcutHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + shortcut: function () { + shortcutHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me
    click me too
    ' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.altKey = true; + _this8.$('a[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.ctrlKey = true; + _this8.$('div[data-ember-action]').trigger(event); + }); + + this.assert.equal(shortcutHandlerWasCalled, true, 'the "any" shortcut\'s event handler was called'); + }; + + _class2.prototype['@test it handles whitelisted bound modifier keys'] = function testItHandlesWhitelistedBoundModifierKeys() { + var _this9 = this; + + var editHandlerWasCalled = false; + var shortcutHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + altKey: 'alt', + anyKey: 'any', + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + shortcut: function () { + shortcutHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me
    click me too
    ' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.altKey = true; + _this9.$('a[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.ctrlKey = true; + _this9.$('div[data-ember-action]').trigger(event); + }); + + this.assert.equal(shortcutHandlerWasCalled, true, 'the "any" shortcut\'s event handler was called'); + }; + + _class2.prototype['@test it handles whitelisted bound modifier keys with current value'] = function testItHandlesWhitelistedBoundModifierKeysWithCurrentValue() { + var _this10 = this; + + var editHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + acceptedKeys: 'alt', + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + event.altKey = true; + _this10.$('a[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + + editHandlerWasCalled = false; + + this.runTask(function () { + component.set('acceptedKeys', ''); + }); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('click'); + _this10.$('div[data-ember-action]').trigger(event); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the event handler was not called'); + }; + + _class2.prototype['@test should be able to use action more than once for the same event within a view'] = function testShouldBeAbleToUseActionMoreThanOnceForTheSameEventWithinAView() { + var _this11 = this; + + var editHandlerWasCalled = false; + var deleteHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + 'delete': function () { + deleteHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'editdelete' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this11.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called (due to bubbling)'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + _this11.$('#delete').click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called (due to bubbling)'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.$().click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test the event should not bubble if `bubbles=false` is passed'] = function testTheEventShouldNotBubbleIfBubblesFalseIsPassed() { + var _this12 = this; + + var editHandlerWasCalled = false; + var deleteHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + 'delete': function () { + deleteHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'editdelete' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this12.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + _this12.$('#delete').click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.$().click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test the event should not bubble if `bubbles=false` is passed bound'] = function testTheEventShouldNotBubbleIfBubblesFalseIsPassedBound() { + var _this13 = this; + + var editHandlerWasCalled = false; + var deleteHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + isFalse: false, + actions: { + edit: function () { + editHandlerWasCalled = true; + }, + 'delete': function () { + deleteHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'editdelete' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this13.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + _this13.$('#delete').click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.$().click(); + }); + + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test the bubbling depends on the bound parameter'] = function testTheBubblingDependsOnTheBoundParameter() { + var _this14 = this; + + var editHandlerWasCalled = false; + var originalHandlerWasCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + shouldBubble: false, + actions: { + edit: function () { + editHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'edit' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this14.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); + + editHandlerWasCalled = originalHandlerWasCalled = false; + + this.runTask(function () { + component.set('shouldBubble', true); + }); + + this.runTask(function () { + _this14.$('#edit').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); + }; + + _class2.prototype['@test it should work properly in an #each block'] = function testItShouldWorkProperlyInAnEachBlock() { + var _this15 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + items: _emberRuntime.A([1, 2, 3, 4]), + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#each items as |item|}}click me{{/each}}' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this15.$('a').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + }; + + _class2.prototype['@test it should work properly in a {{#with foo as |bar|}} block'] = function testItShouldWorkProperlyInAWithFooAsBarBlock() { + var _this16 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + something: { ohai: 'there' }, + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#with something as |somethingElse|}}click me{{/with}}' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this16.$('a').click(); + }); + + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); + }; + + _class2.prototype['@test it should unregister event handlers when an element action is removed'] = function testItShouldUnregisterEventHandlersWhenAnElementActionIsRemoved() { + var _this17 = this; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#if isActive}}click me{{/if}}' + }); + + this.render('{{example-component isActive=isActive}}', { isActive: true }); + + equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered'); + + var actionId = undefined; + + actionId = getActionIds(this.$('a[data-ember-action]').get(0))[0]; + + ok(_emberViews.ActionManager.registeredActions[actionId], 'An action is registered'); + + this.runTask(function () { + return _this17.rerender(); + }); + + equal(this.$('a[data-ember-action]').length, 1, 'The element is still present'); + + ok(_emberViews.ActionManager.registeredActions[actionId], 'The action is still registered'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'isActive', false); + }); + + strictEqual(this.$('a[data-ember-action]').length, 0, 'The element is removed'); + + ok(!_emberViews.ActionManager.registeredActions[actionId], 'The action is unregistered'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'isActive', true); + }); + + equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered'); + + actionId = getActionIds(this.$('a[data-ember-action]').get(0))[0]; + + ok(_emberViews.ActionManager.registeredActions[actionId], 'A new action is registered'); + }; + + _class2.prototype['@test it should capture events from child elements and allow them to trigger the action'] = function testItShouldCaptureEventsFromChildElementsAndAllowThemToTriggerTheAction() { + var _this18 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '
    ' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this18.$('button').click(); + }); + + this.assert.ok(editHandlerWasCalled, 'event on a child target triggered the action of its parent'); + }; + + _class2.prototype['@test it should allow bubbling of events from action helper to original parent event'] = function testItShouldAllowBubblingOfEventsFromActionHelperToOriginalParentEvent() { + var _this19 = this; + + var editHandlerWasCalled = false; + var originalHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this19.$('a').click(); + }); + + this.assert.ok(editHandlerWasCalled && originalHandlerWasCalled, 'both event handlers were called'); + }; + + _class2.prototype['@test it should not bubble an event from action helper to original parent event if `bubbles=false` is passed'] = function testItShouldNotBubbleAnEventFromActionHelperToOriginalParentEventIfBubblesFalseIsPassed() { + var _this20 = this; + + var editHandlerWasCalled = false; + var originalHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + }, + click: function () { + originalHandlerWasCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this20.$('a').click(); + }); + + this.assert.ok(editHandlerWasCalled, 'the child event handler was called'); + this.assert.notOk(originalHandlerWasCalled, 'the parent handler was not called'); + }; + + _class2.prototype['@test it should allow "send" as the action name (#594)'] = function testItShouldAllowSendAsTheActionName594() { + var _this21 = this; + + var sendHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + send: function () { + sendHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this21.$('a').click(); + }); + + this.assert.ok(sendHandlerWasCalled, 'the event handler was called'); + }; + + _class2.prototype['@test it should send the view, event, and current context to the action'] = function testItShouldSendTheViewEventAndCurrentContextToTheAction() { + var _this22 = this; + + var passedTarget = undefined; + var passedContext = undefined; + var targetThis = undefined; + + var TargetComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + targetThis = this; + }, + actions: { + edit: function (context) { + passedTarget = this === targetThis; + passedContext = context; + } + } + }); + + var aContext = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + aContext = this; + } + }); + + this.registerComponent('target-component', { + ComponentClass: TargetComponent, + template: '{{yield this}}' + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3) + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this22.$('#edit').click(); + }); + + this.assert.ok(passedTarget, 'the action is called with the target as this'); + this.assert.strictEqual(passedContext, aContext, 'the parameter is passed along'); + }; + + _class2.prototype['@test it should only trigger actions for the event they were registered on'] = function testItShouldOnlyTriggerActionsForTheEventTheyWereRegisteredOn() { + var _this23 = this; + + var editHandlerWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + edit: function () { + editHandlerWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'click me' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this23.$('a').click(); + }); + + this.assert.ok(editHandlerWasCalled, 'the event handler was called on click'); + + editHandlerWasCalled = false; + + this.runTask(function () { + _this23.$('a').trigger('mouseover'); + }); + + this.assert.notOk(editHandlerWasCalled, 'the event handler was not called on mouseover'); + }; + + _class2.prototype['@test it should allow multiple contexts to be specified'] = function testItShouldAllowMultipleContextsToBeSpecified() { + var _this24 = this; + + var passedContexts = undefined; + var models = [_emberRuntime.Object.create(), _emberRuntime.Object.create()]; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + modelA: models[0], + modelB: models[1], + actions: { + edit: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + passedContexts = args; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this24.$('button').click(); + }); + + this.assert.deepEqual(passedContexts, models, 'the action was called with the passed contexts'); + }; + + _class2.prototype['@test it should allow multiple contexts to be specified mixed with string args'] = function testItShouldAllowMultipleContextsToBeSpecifiedMixedWithStringArgs() { + var _this25 = this; + + var passedContexts = undefined; + var model = _emberRuntime.Object.create(); + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + model: model, + actions: { + edit: function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + passedContexts = args; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this25.$('button').click(); + }); + + this.assert.deepEqual(passedContexts, ['herp', model], 'the action was called with the passed contexts'); + }; + + _class2.prototype['@test it should not trigger action with special clicks'] = function testItShouldNotTriggerActionWithSpecialClicks() { + var showCalled = false; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + show: function () { + showCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + var assert = this.assert; + + function checkClick(prop, value, expected) { + var event = _emberViews.jQuery.Event('click'); + event[prop] = value; + + component.$('button').trigger(event); + + if (expected) { + assert.ok(showCalled, 'should call action with ' + prop + ':' + value); + assert.ok(event.isDefaultPrevented(), 'should prevent default'); + } else { + assert.notOk(showCalled, 'should not call action with ' + prop + ':' + value); + assert.notOk(event.isDefaultPrevented(), 'should not prevent default'); + } + } + + checkClick('ctrlKey', true, false); + checkClick('altKey', true, false); + checkClick('metaKey', true, false); + checkClick('shiftKey', true, false); + checkClick('which', 2, false); + + checkClick('which', 1, true); + checkClick('which', undefined, true); // IE <9 + }; + + _class2.prototype['@test it can trigger actions for keyboard events'] = function testItCanTriggerActionsForKeyboardEvents() { + var _this26 = this; + + var showCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () { + showCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + var event = _emberViews.jQuery.Event('keyup'); + event.char = 'a'; + event.which = 65; + _this26.$('input').trigger(event); + }); + + this.assert.ok(showCalled, 'the action was called with keyup'); + }; + + _class2.prototype['@test a quoteless parameter should allow dynamic lookup of the actionName'] = function testAQuotelessParameterShouldAllowDynamicLookupOfTheActionName() { + var lastAction = undefined; + var actionOrder = []; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + hookMeUp: 'rock', + actions: { + rock: function () { + lastAction = 'rock'; + actionOrder.push('rock'); + }, + paper: function () { + lastAction = 'paper'; + actionOrder.push('paper'); + }, + scissors: function () { + lastAction = 'scissors'; + actionOrder.push('scissors'); + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Whistle tips go woop woooop' + }); + + this.render('{{example-component}}'); + + var test = this; + + function testBoundAction(propertyValue) { + test.runTask(function () { + component.set('hookMeUp', propertyValue); + }); + + test.runTask(function () { + component.$('#bound-param').click(); + }); + + test.assert.ok(lastAction, propertyValue, 'lastAction set to ' + propertyValue); + } + + testBoundAction('rock'); + testBoundAction('paper'); + testBoundAction('scissors'); + + this.assert.deepEqual(actionOrder, ['rock', 'paper', 'scissors'], 'action name was looked up properly'); + }; + + _class2.prototype['@test a quoteless string parameter should resolve actionName, including path'] = function testAQuotelessStringParameterShouldResolveActionNameIncludingPath() { + var lastAction = undefined; + var actionOrder = []; + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + component = this; + }, + allactions: _emberRuntime.A([{ title: 'Rock', name: 'rock' }, { title: 'Paper', name: 'paper' }, { title: 'Scissors', name: 'scissors' }]), + actions: { + rock: function () { + lastAction = 'rock'; + actionOrder.push('rock'); + }, + paper: function () { + lastAction = 'paper'; + actionOrder.push('paper'); + }, + scissors: function () { + lastAction = 'scissors'; + actionOrder.push('scissors'); + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '{{#each allactions as |allaction|}}{{allaction.title}}{{/each}}' + }); + + this.render('{{example-component}}'); + + var test = this; + + function testBoundAction(propertyValue) { + test.runTask(function () { + component.$('#' + propertyValue).click(); + }); + + test.assert.ok(lastAction, propertyValue, 'lastAction set to ' + propertyValue); + } + + testBoundAction('rock'); + testBoundAction('paper'); + testBoundAction('scissors'); + + this.assert.deepEqual(actionOrder, ['rock', 'paper', 'scissors'], 'action name was looked up properly'); + }; + + _class2.prototype['@test a quoteless function parameter should be called, including arguments'] = function testAQuotelessFunctionParameterShouldBeCalledIncludingArguments() { + var _this27 = this; + + var submitCalled = false; + var incomingArg = undefined; + + var arg = 'rough ray'; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + submit: function (actualArg) { + incomingArg = actualArg; + submitCalled = true; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this27.$('a').click(); + }); + + this.assert.ok(submitCalled, 'submit function called'); + this.assert.equal(incomingArg, arg, 'argument passed'); + }; + + _class2.prototype['@test a quoteless parameter that does not resolve to a value asserts'] = function testAQuotelessParameterThatDoesNotResolveToAValueAsserts() { + var _this28 = this; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + ohNoeNotValid: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + expectAssertion(function () { + _this28.render('{{example-component}}'); + }, 'You specified a quoteless path, `ohNoeNotValid`, to the {{action}} helper ' + 'which did not resolve to an action name (a string). ' + 'Perhaps you meant to use a quoted actionName? (e.g. {{action "ohNoeNotValid"}}).'); + }; + + _class2.prototype['@test allows multiple actions on a single element'] = function testAllowsMultipleActionsOnASingleElement() { + var _this29 = this; + + var clickActionWasCalled = false; + var doubleClickActionWasCalled = false; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + clicked: function () { + clickActionWasCalled = true; + }, + doubleClicked: function () { + doubleClickActionWasCalled = true; + } + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4) + }); + + this.render('{{example-component}}'); + + this.runTask(function () { + _this29.$('a').trigger('click'); + }); + + this.assert.ok(clickActionWasCalled, 'the clicked action was called'); + + this.runTask(function () { + _this29.$('a').trigger('dblclick'); + }); + + this.assert.ok(doubleClickActionWasCalled, 'the doubleClicked action was called'); + }; + + _class2.prototype['@test it should respect preventDefault option if provided'] = function testItShouldRespectPreventDefaultOptionIfProvided() { + var _this30 = this; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + show: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + this.render('{{example-component}}'); + + var event = _emberViews.jQuery.Event('click'); + + this.runTask(function () { + _this30.$('a').trigger(event); + }); + + this.assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + }; + + _class2.prototype['@test it should respect preventDefault option if provided bound'] = function testItShouldRespectPreventDefaultOptionIfProvidedBound() { + var _this31 = this; + + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + shouldPreventDefault: false, + init: function () { + this._super.apply(this, arguments); + component = this; + }, + actions: { + show: function () {} + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: 'Hi' + }); + + this.render('{{example-component}}'); + + var event = _emberViews.jQuery.Event('click'); + + this.runTask(function () { + _this31.$('a').trigger(event); + }); + + this.assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + + event = _emberViews.jQuery.Event('click'); + + this.runTask(function () { + component.set('shouldPreventDefault', true); + _this31.$('a').trigger(event); + }); + + this.assert.equal(event.isDefaultPrevented(), true, 'should preventDefault'); + }; + + _class2.prototype['@test it should target the proper component when `action` is in yielded block [GH #12409]'] = function testItShouldTargetTheProperComponentWhenActionIsInYieldedBlockGH12409() { + var _this32 = this; + + var outerActionCalled = false; + var innerClickCalled = false; + + var OuterComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + actions: { + hey: function () { + outerActionCalled = true; + } + } + }); + + var MiddleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({}); + + var InnerComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + click: function () { + innerClickCalled = true; + this.sendAction(); + } + }); + + this.registerComponent('outer-component', { + ComponentClass: OuterComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5) + }); + + this.registerComponent('middle-component', { + ComponentClass: MiddleComponent, + template: '{{yield}}' + }); + + this.registerComponent('inner-component', { + ComponentClass: InnerComponent, + template: _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6) + }); + + this.render('{{outer-component}}'); + + this.runTask(function () { + _this32.$('button').click(); + }); + + this.assert.ok(outerActionCalled, 'the action fired on the proper target'); + this.assert.ok(innerClickCalled, 'the click was triggered'); + }; + + _class2.prototype['@test element action with (mut undefinedThing) works properly'] = function testElementActionWithMutUndefinedThingWorksProperly() { + var _this33 = this; + + var component = undefined; + + var ExampleComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + label: undefined, + init: function () { + this._super.apply(this, arguments); + component = this; + } + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: '' + }); + + this.render('{{example-component}}'); + + this.assertText('Click me'); + + this.assertStableRerender(); + + this.runTask(function () { + _this33.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', 'Dun clicked'); + }); + + this.assertText('Dun clicked'); + + this.runTask(function () { + _this33.$('button').click(); + }); + + this.assertText('Clicked!'); + + this.runTask(function () { + component.set('label', undefined); + }); + + this.assertText('Click me'); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/element-action-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/element-action-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/element-action-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/get-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{get}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should be able to get an object value with a static key'] = function testShouldBeAbleToGetAnObjectValueWithAStaticKey() { + var _this = this; + + this.render('[{{get colors \'apple\'}}] [{{if true (get colors \'apple\')}}]', { + colors: { apple: 'red' } + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'colors.apple', 'green'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'colors', { + apple: 'red' + }); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test should be able to get an object value with nested static key'] = function testShouldBeAbleToGetAnObjectValueWithNestedStaticKey() { + var _this2 = this; + + this.render('[{{get colors "apple.gala"}}] [{{if true (get colors "apple.gala")}}]', { + colors: { + apple: { + gala: 'red and yellow' + } + } + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'colors.apple.gala', 'yellow and red striped'); + }); + + this.assertText('[yellow and red striped] [yellow and red striped]'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'colors', { apple: { gala: 'red and yellow' } }); + }); + + this.assertText('[red and yellow] [red and yellow]'); + }; + + _class.prototype['@test should be able to get an object value with a bound/dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithABoundDynamicKey() { + var _this3 = this; + + this.render('[{{get colors key}}] [{{if true (get colors key)}}]', { + colors: { apple: 'red', banana: 'yellow' }, + key: 'apple' + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'colors.apple', 'green'); + _emberMetal.set(_this3.context, 'colors.banana', 'purple'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'key', 'apple'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'colors', { apple: 'red' }); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test should be able to get an object value with nested dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithNestedDynamicKey() { + var _this4 = this; + + this.render('[{{get colors key}}] [{{if true (get colors key)}}]', { + colors: { + apple: { + gala: 'red and yellow', + mcintosh: 'red' + }, + banana: 'yellow' + }, + key: 'apple.gala' + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'key', 'apple.mcintosh'); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'key', 'apple.gala'); + }); + + this.assertText('[red and yellow] [red and yellow]'); + }; + + _class.prototype['@test should be able to get an object value with subexpression returning nested key'] = function testShouldBeAbleToGetAnObjectValueWithSubexpressionReturningNestedKey() { + var _this5 = this; + + this.render('[{{get colors (concat \'apple\' \'.\' \'gala\')}}] [{{if true (get colors (concat \'apple\' \'.\' \'gala\'))}}]', { + colors: { + apple: { + gala: 'red and yellow', + mcintosh: 'red' + } + }, + key: 'apple.gala' + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('[red and yellow] [red and yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'colors.apple.gala', 'yellow and red striped'); + }); + + this.assertText('[yellow and red striped] [yellow and red striped]'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'colors.apple.gala', 'yellow-redish'); + }); + + this.assertText('[yellow-redish] [yellow-redish]'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'colors', { + apple: { + gala: 'red and yellow', + mcintosh: 'red' + } + }); + }); + + this.assertText('[red and yellow] [red and yellow]'); + }; + + _class.prototype['@test should be able to get an object value with a get helper as the key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperAsTheKey() { + var _this6 = this; + + this.render('[{{get colors (get possibleKeys key)}}] [{{if true (get colors (get possibleKeys key))}}]', { + colors: { apple: 'red', banana: 'yellow' }, + key: 'key1', + possibleKeys: { key1: 'apple', key2: 'banana' } + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'key', 'key2'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + _emberMetal.set(_this6.context, 'colors.apple', 'green'); + _emberMetal.set(_this6.context, 'colors.banana', 'purple'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'key', 'key1'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'colors', { apple: 'red', banana: 'yellow' }); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test should be able to get an object value with a get helper value as a bound/dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperValueAsABoundDynamicKey() { + var _this7 = this; + + this.render('[{{get (get possibleValues objectKey) key}}] [{{if true (get (get possibleValues objectKey) key)}}]', { + possibleValues: { + colors1: { apple: 'red', banana: 'yellow' }, + colors2: { apple: 'green', banana: 'purple' } + }, + objectKey: 'colors1', + key: 'apple' + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors2'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors1'); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors2'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'objectKey', 'colors1'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'key', 'apple'); + }); + }; + + _class.prototype['@test should be able to get an object value with a get helper as the value and a get helper as the key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperAsTheValueAndAGetHelperAsTheKey() { + var _this8 = this; + + this.render('[{{get (get possibleValues objectKey) (get possibleKeys key)}}] [{{if true (get (get possibleValues objectKey) (get possibleKeys key))}}]', { + possibleValues: { + colors1: { apple: 'red', banana: 'yellow' }, + colors2: { apple: 'green', banana: 'purple' } + }, + objectKey: 'colors1', + possibleKeys: { + key1: 'apple', + key2: 'banana' + }, + key: 'key1' + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'objectKey', 'colors2'); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'objectKey', 'colors1'); + }); + + this.assertText('[red] [red]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'key', 'key2'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'objectKey', 'colors2'); + }); + + this.assertText('[purple] [purple]'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'objectKey', 'colors1'); + _emberMetal.set(_this8.context, 'key', 'key1'); + }); + + this.assertText('[red] [red]'); + }; + + _class.prototype['@test the result of a get helper can be yielded'] = function testTheResultOfAGetHelperCanBeYielded() { + var _this9 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + this.mcintosh = 'red'; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (get colors mcintosh)}}' + }); + + this.render('{{#foo-bar colors=colors as |value|}}{{value}}{{/foo-bar}}', { + colors: { + red: 'banana' + } + }); + + this.assertText('banana'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('banana'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'mcintosh', 'yellow'); + _emberMetal.set(_this9.context, 'colors', { yellow: 'bus' }); + }); + + this.assertText('bus'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'mcintosh', 'red'); + _emberMetal.set(_this9.context, 'colors', { red: 'banana' }); + }); + + this.assertText('banana'); + }; + + _class.prototype['@test should handle object values as nulls'] = function testShouldHandleObjectValuesAsNulls() { + var _this10 = this; + + this.render('[{{get colors \'apple\'}}] [{{if true (get colors \'apple\')}}]', { + colors: null + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'colors', { apple: 'green', banana: 'purple' }); + }); + + this.assertText('[green] [green]'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'colors', null); + }); + + this.assertText('[] []'); + }; + + _class.prototype['@test should handle object keys as nulls'] = function testShouldHandleObjectKeysAsNulls() { + var _this11 = this; + + this.render('[{{get colors key}}] [{{if true (get colors key)}}]', { + colors: { + apple: 'red', + banana: 'yellow' + }, + key: null + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('[] []'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'key', 'banana'); + }); + + this.assertText('[yellow] [yellow]'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'key', null); + }); + + this.assertText('[] []'); + }; + + _class.prototype['@test should handle object values and keys as nulls'] = function testShouldHandleObjectValuesAndKeysAsNulls() { + this.render('[{{get colors \'apple\'}}] [{{if true (get colors key)}}]', { + colors: null, + key: null + }); + + this.assertText('[] []'); + }; + + _class.prototype['@test get helper value should be updatable using {{input}} and (mut) - static key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutStaticKey(assert) { + var _this12 = this; + + this.render('{{input type=\'text\' value=(mut (get source \'banana\')) id=\'get-input\'}}', { + source: { + banana: 'banana' + } + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _this12.rerender(); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'source.banana', 'yellow'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'yellow'); + + this.runTask(function () { + return _this12.$('#get-input').val('some value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.banana'), 'some value'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'source', { banana: 'banana' }); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + }; + + _class.prototype['@test get helper value should be updatable using {{input}} and (mut) - dynamic key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutDynamicKey(assert) { + var _this13 = this; + + this.render('{{input type=\'text\' value=(mut (get source key)) id=\'get-input\'}}', { + source: { + apple: 'apple', + banana: 'banana' + }, + key: 'banana' + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _this13.rerender(); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'source.banana', 'yellow'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'yellow'); + + this.runTask(function () { + return _this13.$('#get-input').val('some value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.banana'), 'some value'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'key', 'apple'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'apple'); + + this.runTask(function () { + return _this13.$('#get-input').val('some other value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some other value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.apple'), 'some other value'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'key', 'banana'); + _emberMetal.set(_this13.context, 'source', { banana: 'banana' }); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + }; + + _class.prototype['@test get helper value should be updatable using {{input}} and (mut) - dynamic nested key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutDynamicNestedKey(assert) { + var _this14 = this; + + this.render('{{input type=\'text\' value=(mut (get source key)) id=\'get-input\'}}', { + source: { + apple: { + gala: 'gala', + mcintosh: 'mcintosh' + }, + banana: 'banana' + }, + key: 'apple.mcintosh' + }); + + assert.strictEqual(this.$('#get-input').val(), 'mcintosh'); + + this.runTask(function () { + return _this14.rerender(); + }); + + assert.strictEqual(this.$('#get-input').val(), 'mcintosh'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'source.apple.mcintosh', 'red'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'red'); + + this.runTask(function () { + return _this14.$('#get-input').val('some value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.apple.mcintosh'), 'some value'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'key', 'apple.gala'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'gala'); + + this.runTask(function () { + return _this14.$('#get-input').val('some other value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'some other value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.apple.gala'), 'some other value'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'key', 'banana'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'banana'); + + this.runTask(function () { + return _this14.$('#get-input').val('yet another value').trigger('change'); + }); + + assert.strictEqual(this.$('#get-input').val(), 'yet another value'); + assert.strictEqual(_emberMetal.get(this.context, 'source.banana'), 'yet another value'); + + this.runTask(function () { + _emberMetal.set(_this14.context, 'key', 'apple.mcintosh'); + _emberMetal.set(_this14.context, 'source', { + apple: { + gala: 'gala', + mcintosh: 'mcintosh' + }, + banana: 'banana' + }); + }); + + assert.strictEqual(this.$('#get-input').val(), 'mcintosh'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/get-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/get-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/get-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/hash-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{hash}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test returns a hash with the right key-value'] = function testReturnsAHashWithTheRightKeyValue() { + var _this = this; + + this.render('{{#with (hash name="Sergio") as |person|}}{{person.name}}{{/with}}'); + + this.assertText('Sergio'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('Sergio'); + }; + + _class.prototype['@test can have more than one key-value'] = function testCanHaveMoreThanOneKeyValue() { + var _this2 = this; + + this.render('{{#with (hash name="Sergio" lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}'); + + this.assertText('Sergio Arbeo'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Sergio Arbeo'); + }; + + _class.prototype['@test binds values when variables are used'] = function testBindsValuesWhenVariablesAreUsed() { + var _this3 = this; + + this.render('{{#with (hash name=model.firstName lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}', { + model: { + firstName: 'Marisa' + } + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.firstName', 'Sergio'); + }); + + this.assertText('Sergio Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { firstName: 'Marisa' }); + }); + + this.assertText('Marisa Arbeo'); + }; + + _class.prototype['@test binds multiple values when variables are used'] = function testBindsMultipleValuesWhenVariablesAreUsed() { + var _this4 = this; + + this.render('{{#with (hash name=model.firstName lastName=model.lastName) as |person|}}{{person.name}} {{person.lastName}}{{/with}}', { + model: { + firstName: 'Marisa', + lastName: 'Arbeo' + } + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('Marisa Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model.firstName', 'Sergio'); + }); + + this.assertText('Sergio Arbeo'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model.lastName', 'Smith'); + }); + + this.assertText('Sergio Smith'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model', { + firstName: 'Marisa', + lastName: 'Arbeo' + }); + }); + + this.assertText('Marisa Arbeo'); + }; + + _class.prototype['@test hash helpers can be nested'] = function testHashHelpersCanBeNested() { + var _this5 = this; + + this.render('{{#with (hash person=(hash name=model.firstName)) as |ctx|}}{{ctx.person.name}}{{/with}}', { + model: { firstName: 'Balint' } + }); + + this.assertText('Balint'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('Balint'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model.firstName', 'Chad'); + }); + + this.assertText('Chad'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model', { firstName: 'Balint' }); + }); + + this.assertText('Balint'); + }; + + _class.prototype['@test should yield hash of internal properties'] = function testShouldYieldHashOfInternalProperties() { + var _this6 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + this.model = { firstName: 'Chad' }; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (hash firstName=model.firstName)}}' + }); + + this.render('{{#foo-bar as |values|}}{{values.firstName}}{{/foo-bar}}'); + + this.assertText('Chad'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('Chad'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model.firstName', 'Godfrey'); + }); + + this.assertText('Godfrey'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model', { firstName: 'Chad' }); + }); + + this.assertText('Chad'); + }; + + _class.prototype['@test should yield hash of internal and external properties'] = function testShouldYieldHashOfInternalAndExternalProperties() { + var _this7 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super(); + fooBarInstance = this; + this.model = { firstName: 'Chad' }; + } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (hash firstName=model.firstName lastName=lastName)}}' + }); + + this.render('{{#foo-bar lastName=model.lastName as |values|}}{{values.firstName}} {{values.lastName}}{{/foo-bar}}', { + model: { lastName: 'Hietala' } + }); + + this.assertText('Chad Hietala'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('Chad Hietala'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'model.firstName', 'Godfrey'); + _emberMetal.set(_this7.context, 'model.lastName', 'Chan'); + }); + + this.assertText('Godfrey Chan'); + + this.runTask(function () { + _emberMetal.set(fooBarInstance, 'model', { firstName: 'Chad' }); + _emberMetal.set(_this7.context, 'model', { lastName: 'Hietala' }); + }); + + this.assertText('Chad Hietala'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/hash-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/hash-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/hash-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/if-unless-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: inline {{if}}', (function (_IfUnlessHelperTest) { + babelHelpers.inherits(_class, _IfUnlessHelperTest); + + function _class() { + _IfUnlessHelperTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{if ' + cond + ' ' + truthy + ' ' + falsy + '}}'; + }; + + _class.prototype['@test it raises when there are more than three arguments'] = function testItRaisesWhenThereAreMoreThanThreeArguments() { + var _this = this; + + expectAssertion(function () { + _this.render('{{if condition \'a\' \'b\' \'c\'}}', { condition: true }); + }, /The inline form of the `if` helper expects two or three arguments/); + }; + + _class.prototype['@test it raises when there are less than two arguments'] = function testItRaisesWhenThereAreLessThanTwoArguments() { + var _this2 = this; + + expectAssertion(function () { + _this2.render('{{if condition}}', { condition: true }); + }, /The inline form of the `if` helper expects two or three arguments/); + }; + + return _class; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{if}} helpers (returning truthy values)', (function (_IfUnlessHelperTest2) { + babelHelpers.inherits(_class2, _IfUnlessHelperTest2); + + function _class2() { + _IfUnlessHelperTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{if (if ' + cond + ' ' + cond + ' false) ' + truthy + ' ' + falsy + '}}'; + }; + + return _class2; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{if}} helpers (returning falsy values)', (function (_IfUnlessHelperTest3) { + babelHelpers.inherits(_class3, _IfUnlessHelperTest3); + + function _class3() { + _IfUnlessHelperTest3.apply(this, arguments); + } + + _class3.prototype.templateFor = function templateFor(_ref3) { + var cond = _ref3.cond; + var truthy = _ref3.truthy; + var falsy = _ref3.falsy; + + return '{{if (if ' + cond + ' true ' + cond + ') ' + truthy + ' ' + falsy + '}}'; + }; + + return _class3; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{if}} used with another helper', (function (_IfUnlessHelperTest4) { + babelHelpers.inherits(_class4, _IfUnlessHelperTest4); + + function _class4() { + _IfUnlessHelperTest4.apply(this, arguments); + } + + _class4.prototype.wrapperFor = function wrapperFor(templates) { + return '{{concat ' + templates.join(' ') + '}}'; + }; + + _class4.prototype.templateFor = function templateFor(_ref4) { + var cond = _ref4.cond; + var truthy = _ref4.truthy; + var falsy = _ref4.falsy; + + return '(if ' + cond + ' ' + truthy + ' ' + falsy + ')'; + }; + + return _class4; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{if}} used in attribute position', (function (_IfUnlessHelperTest5) { + babelHelpers.inherits(_class5, _IfUnlessHelperTest5); + + function _class5() { + _IfUnlessHelperTest5.apply(this, arguments); + } + + _class5.prototype.wrapperFor = function wrapperFor(templates) { + return '
    '; + }; + + _class5.prototype.templateFor = function templateFor(_ref5) { + var cond = _ref5.cond; + var truthy = _ref5.truthy; + var falsy = _ref5.falsy; + + return '{{if ' + cond + ' ' + truthy + ' ' + falsy + '}}'; + }; + + _class5.prototype.textValue = function textValue() { + return this.$('div').attr('data-foo'); + }; + + return _class5; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: inline {{if}} and {{unless}} without the inverse argument', (function (_IfUnlessHelperTest6) { + babelHelpers.inherits(_class6, _IfUnlessHelperTest6); + + function _class6() { + _IfUnlessHelperTest6.apply(this, arguments); + } + + _class6.prototype.templateFor = function templateFor(_ref6) { + var cond = _ref6.cond; + var truthy = _ref6.truthy; + var falsy = _ref6.falsy; + + return '{{if ' + cond + ' ' + truthy + '}}{{unless ' + cond + ' ' + falsy + '}}'; + }; + + return _class6; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: inline {{unless}}', (function (_IfUnlessHelperTest7) { + babelHelpers.inherits(_class7, _IfUnlessHelperTest7); + + function _class7() { + _IfUnlessHelperTest7.apply(this, arguments); + } + + _class7.prototype.templateFor = function templateFor(_ref7) { + var cond = _ref7.cond; + var truthy = _ref7.truthy; + var falsy = _ref7.falsy; + + return '{{unless ' + cond + ' ' + falsy + ' ' + truthy + '}}'; + }; + + _class7.prototype['@test it raises when there are more than three arguments'] = function testItRaisesWhenThereAreMoreThanThreeArguments() { + var _this3 = this; + + expectAssertion(function () { + _this3.render('{{unless condition \'a\' \'b\' \'c\'}}', { condition: true }); + }, /The inline form of the `unless` helper expects two or three arguments/); + }; + + _class7.prototype['@test it raises when there are less than two arguments'] = function testItRaisesWhenThereAreLessThanTwoArguments() { + var _this4 = this; + + expectAssertion(function () { + _this4.render('{{unless condition}}', { condition: true }); + }, /The inline form of the `unless` helper expects two or three arguments/); + }; + + return _class7; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{unless}} helpers (returning truthy values)', (function (_IfUnlessHelperTest8) { + babelHelpers.inherits(_class8, _IfUnlessHelperTest8); + + function _class8() { + _IfUnlessHelperTest8.apply(this, arguments); + } + + _class8.prototype.templateFor = function templateFor(_ref8) { + var cond = _ref8.cond; + var truthy = _ref8.truthy; + var falsy = _ref8.falsy; + + return '{{unless (unless ' + cond + ' false ' + cond + ') ' + falsy + ' ' + truthy + '}}'; + }; + + return _class8; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: nested {{unless}} helpers (returning falsy values)', (function (_IfUnlessHelperTest9) { + babelHelpers.inherits(_class9, _IfUnlessHelperTest9); + + function _class9() { + _IfUnlessHelperTest9.apply(this, arguments); + } + + _class9.prototype.templateFor = function templateFor(_ref9) { + var cond = _ref9.cond; + var truthy = _ref9.truthy; + var falsy = _ref9.falsy; + + return '{{unless (unless ' + cond + ' ' + cond + ' true) ' + falsy + ' ' + truthy + '}}'; + }; + + return _class9; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{unless}} used with another helper', (function (_IfUnlessHelperTest10) { + babelHelpers.inherits(_class10, _IfUnlessHelperTest10); + + function _class10() { + _IfUnlessHelperTest10.apply(this, arguments); + } + + _class10.prototype.wrapperFor = function wrapperFor(templates) { + return '{{concat ' + templates.join(' ') + '}}'; + }; + + _class10.prototype.templateFor = function templateFor(_ref10) { + var cond = _ref10.cond; + var truthy = _ref10.truthy; + var falsy = _ref10.falsy; + + return '(unless ' + cond + ' ' + falsy + ' ' + truthy + ')'; + }; + + return _class10; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{unless}} used in attribute position', (function (_IfUnlessHelperTest11) { + babelHelpers.inherits(_class11, _IfUnlessHelperTest11); + + function _class11() { + _IfUnlessHelperTest11.apply(this, arguments); + } + + _class11.prototype.wrapperFor = function wrapperFor(templates) { + return '
    '; + }; + + _class11.prototype.templateFor = function templateFor(_ref11) { + var cond = _ref11.cond; + var truthy = _ref11.truthy; + var falsy = _ref11.falsy; + + return '{{unless ' + cond + ' ' + falsy + ' ' + truthy + '}}'; + }; + + _class11.prototype.textValue = function textValue() { + return this.$('div').attr('data-foo'); + }; + + return _class11; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessHelperTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/if-unless-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/if-unless-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/if-unless-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/input-test', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case', 'internal-test-helpers'], function (exports, _emberUtils, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestCase, _internalTestHelpers) { + 'use strict'; + + var InputRenderingTest = (function (_RenderingTest) { + babelHelpers.inherits(InputRenderingTest, _RenderingTest); + + function InputRenderingTest() { + _RenderingTest.call(this); + + this.registerComponent('-text-field', { ComponentClass: _emberGlimmerTestsUtilsHelpers.TextField }); + this.registerComponent('-checkbox', { ComponentClass: _emberGlimmerTestsUtilsHelpers.Checkbox }); + } + + InputRenderingTest.prototype.$input = function $input() { + return this.$('input'); + }; + + InputRenderingTest.prototype.inputID = function inputID() { + return this.$input().prop('id'); + }; + + InputRenderingTest.prototype.assertDisabled = function assertDisabled() { + this.assert.ok(this.$('input').prop('disabled'), 'The input is disabled'); + }; + + InputRenderingTest.prototype.assertNotDisabled = function assertNotDisabled() { + this.assert.ok(this.$('input').is(':not(:disabled)'), 'The input is not disabled'); + }; + + InputRenderingTest.prototype.assertInputId = function assertInputId(expectedId) { + this.assert.equal(this.inputID(), expectedId, 'the input id should be `expectedId`'); + }; + + InputRenderingTest.prototype.assertSingleInput = function assertSingleInput() { + this.assert.equal(this.$('input').length, 1, 'A single text field was inserted'); + }; + + InputRenderingTest.prototype.assertSingleCheckbox = function assertSingleCheckbox() { + this.assert.equal(this.$('input[type=checkbox]').length, 1, 'A single checkbox is added'); + }; + + InputRenderingTest.prototype.assertCheckboxIsChecked = function assertCheckboxIsChecked() { + this.assert.equal(this.$input().prop('checked'), true, 'the checkbox is checked'); + }; + + InputRenderingTest.prototype.assertCheckboxIsNotChecked = function assertCheckboxIsNotChecked() { + this.assert.equal(this.$input().prop('checked'), false, 'the checkbox is not checked'); + }; + + InputRenderingTest.prototype.assertValue = function assertValue(expected) { + this.assert.equal(this.$input().val(), expected, 'the input value should be ' + expected); + }; + + InputRenderingTest.prototype.assertAttr = function assertAttr(name, expected) { + this.assert.equal(this.$input().attr(name), expected, 'the input ' + name + ' attribute has the value \'' + expected + '\''); + }; + + InputRenderingTest.prototype.assertAllAttrs = function assertAllAttrs(names, expected) { + var _this = this; + + names.forEach(function (name) { + return _this.assertAttr(name, expected); + }); + }; + + InputRenderingTest.prototype.assertSelectionRange = function assertSelectionRange(start, end) { + var input = this.$input()[0]; + this.assert.equal(input.selectionStart, start, 'the cursor start position should be ' + start); + this.assert.equal(input.selectionEnd, end, 'the cursor end position should be ' + end); + }; + + InputRenderingTest.prototype.triggerEvent = function triggerEvent(type, options) { + var event = document.createEvent('Events'); + event.initEvent(type, true, true); + _emberUtils.assign(event, options); + + var element = this.$input()[0]; + this.runTask(function () { + element.dispatchEvent(event); + }); + }; + + return InputRenderingTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input}}', (function (_InputRenderingTest) { + babelHelpers.inherits(_class, _InputRenderingTest); + + function _class() { + _InputRenderingTest.apply(this, arguments); + } + + _class.prototype['@test a single text field is inserted into the DOM'] = function testASingleTextFieldIsInsertedIntoTheDOM(assert) { + var _this2 = this; + + this.render('{{input type="text" value=value}}', { value: 'hello' }); + + var id = this.inputID(); + + this.assertValue('hello'); + this.assertSingleInput(); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertValue('hello'); + this.assertSingleInput(); + this.assertInputId(id); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'value', 'goodbye'); + }); + + this.assertValue('goodbye'); + this.assertSingleInput(); + this.assertInputId(id); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'value', 'hello'); + }); + + this.assertValue('hello'); + this.assertSingleInput(); + this.assertInputId(id); + }; + + _class.prototype['@test default type'] = function testDefaultType() { + var _this3 = this; + + this.render('{{input}}'); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertAttr('type', 'text'); + }; + + _class.prototype['@test dynamic attributes'] = function testDynamicAttributes() { + var _this4 = this; + + this.render('\n {{input type="text"\n disabled=disabled\n value=value\n placeholder=placeholder\n name=name\n maxlength=maxlength\n size=size\n tabindex=tabindex\n }}', { + disabled: false, + value: 'Original value', + placeholder: 'Original placeholder', + name: 'original-name', + maxlength: 10, + size: 20, + tabindex: 30 + }); + + this.assertNotDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertNotDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + _emberMetal.set(_this4.context, 'value', 'Updated value'); + _emberMetal.set(_this4.context, 'disabled', true); + _emberMetal.set(_this4.context, 'placeholder', 'Updated placeholder'); + _emberMetal.set(_this4.context, 'name', 'updated-name'); + _emberMetal.set(_this4.context, 'maxlength', 11); + // set(this.context, 'size', 21); //NOTE: failing in IE (TEST_SUITE=sauce) + // set(this.context, 'tabindex', 31); //NOTE: failing in IE (TEST_SUITE=sauce) + }); + + this.assertDisabled(); + this.assertValue('Updated value'); + this.assertAttr('placeholder', 'Updated placeholder'); + this.assertAttr('name', 'updated-name'); + this.assertAttr('maxlength', '11'); + // this.assertAttr('size', '21'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '31'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + _emberMetal.set(_this4.context, 'value', 'Original value'); + _emberMetal.set(_this4.context, 'disabled', false); + _emberMetal.set(_this4.context, 'placeholder', 'Original placeholder'); + _emberMetal.set(_this4.context, 'name', 'original-name'); + _emberMetal.set(_this4.context, 'maxlength', 10); + // set(this.context, 'size', 20); //NOTE: failing in IE (TEST_SUITE=sauce) + // set(this.context, 'tabindex', 30); //NOTE: failing in IE (TEST_SUITE=sauce) + }); + + this.assertNotDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + }; + + _class.prototype['@test static attributes'] = function testStaticAttributes() { + var _this5 = this; + + this.render('\n {{input type="text"\n disabled=true\n value="Original value"\n placeholder="Original placeholder"\n name="original-name"\n maxlength=10\n size=20\n tabindex=30\n }}'); + + this.assertDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertDisabled(); + this.assertValue('Original value'); + this.assertAttr('placeholder', 'Original placeholder'); + this.assertAttr('name', 'original-name'); + this.assertAttr('maxlength', '10'); + // this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce) + // this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce) + }; + + _class.prototype['@test cursor selection range'] = function testCursorSelectionRange(assert) { + var _this6 = this; + + // Modifying input.selectionStart, which is utilized in the cursor tests, + // causes an event in Safari. + _internalTestHelpers.runDestroy(this.owner.lookup('event_dispatcher:main')); + + this.render('{{input type="text" value=value}}', { value: 'original' }); + + var input = this.$input()[0]; + + // See https://ember-twiddle.com/33e506329f8176ae874422644d4cc08c?openFiles=components.input-component.js%2Ctemplates.components.input-component.hbs + // this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce) + + this.runTask(function () { + return _this6.rerender(); + }); + + // this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce) + + this.runTask(function () { + input.selectionStart = 2; + input.selectionEnd = 4; + }); + + this.assertSelectionRange(2, 4); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertSelectionRange(2, 4); + + // this.runTask(() => set(this.context, 'value', 'updated')); + // + // this.assertSelectionRange(7, 7); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) + // + // this.runTask(() => set(this.context, 'value', 'original')); + // + // this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) + }; + + _class.prototype['@test specifying `on="someevent" action="foo"` results in a deprecation warning'] = function testSpecifyingOnSomeeventActionFooResultsInADeprecationWarning() { + var _this7 = this; + + expectDeprecation(function () { + _this7.render('{{input on="focus-in" action="doFoo" value="hello"}}'); + }, 'Using \'{{input on="focus-in" action="doFoo"}}\' (\'-top-level\' @ L1:C0) is deprecated. Please use \'{{input focus-in="doFoo"}}\' instead.'); + }; + + _class.prototype['@test sends an action with `{{input action="foo"}}` when is pressed [DEPRECATED]'] = function testSendsAnActionWithInputActionFooWhenEnterIsPressedDEPRECATED(assert) { + var _this8 = this; + + assert.expect(2); + + expectDeprecation(function () { + _this8.render('{{input action=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + }, /Please use '{{input enter="foo"}}' instead/); + + this.triggerEvent('keyup', { + keyCode: 13 + }); + }; + + _class.prototype['@test sends an action with `{{input enter="foo"}}` when is pressed'] = function testSendsAnActionWithInputEnterFooWhenEnterIsPressed(assert) { + assert.expect(1); + + this.render('{{input enter=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 13 + }); + }; + + _class.prototype['@test sends an action with `{{input key-press="foo"}}` is pressed'] = function testSendsAnActionWithInputKeyPressFooIsPressed(assert) { + assert.expect(1); + + this.render('{{input value=value key-press=\'foo\'}}', { + value: 'initial', + + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keypress', { + keyCode: 65 + }); + }; + + _class.prototype['@test sends an action to the parent level when `bubbles=true` is provided'] = function testSendsAnActionToTheParentLevelWhenBubblesTrueIsProvided(assert) { + assert.expect(1); + + var ParentComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + change: function () { + assert.ok(true, 'bubbled upwards'); + } + }); + + this.registerComponent('x-parent', { + ComponentClass: ParentComponent, + template: '{{input bubbles=true}}' + }); + this.render('{{x-parent}}'); + + this.triggerEvent('change'); + }; + + _class.prototype['@test triggers `focus-in` when focused'] = function testTriggersFocusInWhenFocused(assert) { + var _this9 = this; + + assert.expect(1); + + this.render('{{input focus-in=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.runTask(function () { + _this9.$input().trigger('focusin'); + }); + }; + + _class.prototype['@test sends `insert-newline` when is pressed'] = function testSendsInsertNewlineWhenEnterIsPressed(assert) { + assert.expect(1); + + this.render('{{input insert-newline=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 13 + }); + }; + + _class.prototype['@test sends an action with `{{input escape-press="foo"}}` when is pressed'] = function testSendsAnActionWithInputEscapePressFooWhenEscapeIsPressed(assert) { + assert.expect(1); + + this.render('{{input escape-press=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 27 + }); + }; + + _class.prototype['@test sends an action with `{{input key-down="foo"}}` when a key is pressed'] = function testSendsAnActionWithInputKeyDownFooWhenAKeyIsPressed(assert) { + assert.expect(1); + + this.render('{{input key-down=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keydown', { + keyCode: 65 + }); + }; + + _class.prototype['@test sends an action with `{{input key-up="foo"}}` when a key is pressed'] = function testSendsAnActionWithInputKeyUpFooWhenAKeyIsPressed(assert) { + assert.expect(1); + + this.render('{{input key-up=\'foo\'}}', { + actions: { + foo: function () { + assert.ok(true, 'action was triggered'); + } + } + }); + + this.triggerEvent('keyup', { + keyCode: 65 + }); + }; + + return _class; + })(InputRenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input}} with dynamic type', (function (_InputRenderingTest2) { + babelHelpers.inherits(_class2, _InputRenderingTest2); + + function _class2() { + _InputRenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test a bound property can be used to determine type'] = function testABoundPropertyCanBeUsedToDetermineType() { + var _this10 = this; + + this.render('{{input type=type}}', { type: 'password' }); + + this.assertAttr('type', 'password'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertAttr('type', 'password'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'type', 'text'); + }); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'type', 'password'); + }); + + this.assertAttr('type', 'password'); + }; + + _class2.prototype['@test a subexpression can be used to determine type'] = function testASubexpressionCanBeUsedToDetermineType() { + var _this11 = this; + + this.render('{{input type=(if isTruthy trueType falseType)}}', { + isTruthy: true, + trueType: 'text', + falseType: 'password' + }); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertAttr('type', 'text'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'isTruthy', false); + }); + + this.assertAttr('type', 'password'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'isTruthy', true); + }); + + this.assertAttr('type', 'text'); + }; + + return _class2; + })(InputRenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input type=\'checkbox\'}}', (function (_InputRenderingTest3) { + babelHelpers.inherits(_class3, _InputRenderingTest3); + + function _class3() { + _InputRenderingTest3.apply(this, arguments); + } + + _class3.prototype['@test dynamic attributes'] = function testDynamicAttributes() { + var _this12 = this; + + this.render('{{input\n type=\'checkbox\'\n disabled=disabled\n name=name\n checked=checked\n tabindex=tabindex\n }}', { + disabled: false, + name: 'original-name', + checked: false, + tabindex: 10 + }); + + this.assertSingleCheckbox(); + this.assertNotDisabled(); + this.assertAttr('name', 'original-name'); + this.assertAttr('tabindex', '10'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertSingleCheckbox(); + this.assertNotDisabled(); + this.assertAttr('name', 'original-name'); + this.assertAttr('tabindex', '10'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'disabled', true); + _emberMetal.set(_this12.context, 'name', 'updated-name'); + _emberMetal.set(_this12.context, 'tabindex', 11); + }); + + this.assertSingleCheckbox(); + this.assertDisabled(); + this.assertAttr('name', 'updated-name'); + this.assertAttr('tabindex', '11'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'disabled', false); + _emberMetal.set(_this12.context, 'name', 'original-name'); + _emberMetal.set(_this12.context, 'tabindex', 10); + }); + + this.assertSingleCheckbox(); + this.assertNotDisabled(); + this.assertAttr('name', 'original-name'); + this.assertAttr('tabindex', '10'); + }; + + _class3.prototype['@test `value` property assertion'] = function testValuePropertyAssertion() { + var _this13 = this; + + expectAssertion(function () { + _this13.render('{{input type="checkbox" value=value}}', { value: 'value' }); + }, /you must use `checked=/); + }; + + _class3.prototype['@test with a bound type'] = function testWithABoundType(assert) { + var _this14 = this; + + this.render('{{input type=inputType checked=isChecked}}', { inputType: 'checkbox', isChecked: true }); + + this.assertSingleCheckbox(); + this.assertCheckboxIsChecked(); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertCheckboxIsChecked(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'isChecked', false); + }); + + this.assertCheckboxIsNotChecked(); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'isChecked', true); + }); + + this.assertCheckboxIsChecked(); + }; + + _class3.prototype['@test with static values'] = function testWithStaticValues(assert) { + var _this15 = this; + + this.render('{{input type="checkbox" disabled=false tabindex=10 name="original-name" checked=false}}'); + + this.assertSingleCheckbox(); + this.assertCheckboxIsNotChecked(); + this.assertNotDisabled(); + this.assertAttr('tabindex', '10'); + this.assertAttr('name', 'original-name'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertSingleCheckbox(); + this.assertCheckboxIsNotChecked(); + this.assertNotDisabled(); + this.assertAttr('tabindex', '10'); + this.assertAttr('name', 'original-name'); + }; + + return _class3; + })(InputRenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{input type=\'text\'}}', (function (_InputRenderingTest4) { + babelHelpers.inherits(_class4, _InputRenderingTest4); + + function _class4() { + _InputRenderingTest4.apply(this, arguments); + } + + _class4.prototype['@test null values'] = function testNullValues(assert) { + var _this16 = this; + + var attributes = ['disabled', 'placeholder', 'name', 'maxlength', 'size', 'tabindex']; + + this.render('\n {{input type="text"\n disabled=disabled\n value=value\n placeholder=placeholder\n name=name\n maxlength=maxlength\n size=size\n tabindex=tabindex\n }}', { + disabled: null, + value: null, + placeholder: null, + name: null, + maxlength: null, + size: null, + tabindex: null + }); + + this.assertValue(''); + this.assertAllAttrs(attributes, undefined); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertValue(''); + this.assertAllAttrs(attributes, undefined); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'disabled', true); + _emberMetal.set(_this16.context, 'value', 'Updated value'); + _emberMetal.set(_this16.context, 'placeholder', 'Updated placeholder'); + _emberMetal.set(_this16.context, 'name', 'updated-name'); + _emberMetal.set(_this16.context, 'maxlength', 11); + _emberMetal.set(_this16.context, 'size', 21); + _emberMetal.set(_this16.context, 'tabindex', 31); + }); + + this.assertDisabled(); + this.assertValue('Updated value'); + this.assertAttr('placeholder', 'Updated placeholder'); + this.assertAttr('name', 'updated-name'); + this.assertAttr('maxlength', '11'); + this.assertAttr('size', '21'); + this.assertAttr('tabindex', '31'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'disabled', null); + _emberMetal.set(_this16.context, 'value', null); + _emberMetal.set(_this16.context, 'placeholder', null); + _emberMetal.set(_this16.context, 'name', null); + _emberMetal.set(_this16.context, 'maxlength', null); + // set(this.context, 'size', null); //NOTE: this fails with `Error: Failed to set the 'size' property on 'HTMLInputElement': The value provided is 0, which is an invalid size.` (TEST_SUITE=sauce) + _emberMetal.set(_this16.context, 'tabindex', null); + }); + + this.assertAttr('disabled', undefined); + this.assertValue(''); + // this.assertAttr('placeholder', undefined); //NOTE: this fails with a value of "null" (TEST_SUITE=sauce) + // this.assertAttr('name', undefined); //NOTE: this fails with a value of "null" (TEST_SUITE=sauce) + this.assertAttr('maxlength', undefined); + // this.assertAttr('size', undefined); //NOTE: re-enable once `size` bug above has been addressed + this.assertAttr('tabindex', undefined); + }; + + return _class4; + })(InputRenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/input-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/input-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/input-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/loc-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _ember) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{loc}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.call(this); + this.oldString = _ember.default.STRINGS; + _ember.default.STRINGS = { + 'Hello Friend': 'Hallo Freund', + 'Hello': 'Hallo, %@' + }; + } + + _class.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + _ember.default.STRINGS = this.oldString; + }; + + _class.prototype['@test it lets the original value through by default'] = function testItLetsTheOriginalValueThroughByDefault() { + var _this = this; + + this.render('{{loc "Hiya buddy!"}}'); + this.assertText('Hiya buddy!', 'the unlocalized string is correct'); + this.runTask(function () { + return _this.rerender(); + }); + this.assertText('Hiya buddy!', 'the unlocalized string is correct after rerender'); + }; + + _class.prototype['@test it localizes a simple string'] = function testItLocalizesASimpleString() { + var _this2 = this; + + this.render('{{loc "Hello Friend"}}'); + this.assertText('Hallo Freund', 'the localized string is correct'); + this.runTask(function () { + return _this2.rerender(); + }); + this.assertText('Hallo Freund', 'the localized string is correct after rerender'); + }; + + _class.prototype['@test it takes passed formats into an account'] = function testItTakesPassedFormatsIntoAnAccount() { + var _this3 = this; + + this.render('{{loc "%@, %@" "Hello" "Mr. Pitkin"}}'); + this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct'); + this.runTask(function () { + return _this3.rerender(); + }); + this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct after rerender'); + }; + + _class.prototype['@test it updates when bound params change'] = function testItUpdatesWhenBoundParamsChange() { + var _this4 = this; + + this.render('{{loc simple}} - {{loc personal \'Mr. Pitkin\'}}', { + simple: 'Hello Friend', + personal: 'Hello' + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct'); + + this.runTask(function () { + return _this4.rerender(); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after rerender'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'simple', 'G\'day mate'); + }); + this.assertText('G\'day mate - Hallo, Mr. Pitkin', 'the bound value is correct after update'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'simple', 'Hello Friend'); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after reset'); + }; + + _class.prototype['@test it updates when nested bound params change'] = function testItUpdatesWhenNestedBoundParamsChange() { + var _this5 = this; + + this.render('{{loc greetings.simple}} - {{loc greetings.personal \'Mr. Pitkin\'}}', { + greetings: { + simple: 'Hello Friend', + personal: 'Hello' + } + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct'); + + this.runTask(function () { + return _this5.rerender(); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after rerender'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'greetings.simple', 'G\'day mate'); + }); + this.assertText('G\'day mate - Hallo, Mr. Pitkin', 'the bound value is correct after interior mutation'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'greetings', { + simple: 'Hello Friend', + personal: 'Hello' + }); + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after replacement'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/loc-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/loc-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/loc-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/log-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-console'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberConsole) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{log}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class(assert) { + var _this = this; + + _RenderingTest.call(this); + + this.originalLog = _emberConsole.default.log; + this.logCalls = []; + _emberConsole.default.log = function () { + var _logCalls; + + (_logCalls = _this.logCalls).push.apply(_logCalls, arguments); + }; + } + + _class.prototype.teardown = function teardown() { + _RenderingTest.prototype.teardown.call(this); + _emberConsole.default.log = this.originalLog; + }; + + _class.prototype.assertLog = function assertLog(values) { + this.assertText(''); + this.assert.strictEqual(this.logCalls.length, values.length); + + for (var i = 0, len = values.length; i < len; i++) { + this.assert.strictEqual(this.logCalls[i], values[i]); + } + }; + + _class.prototype['@test correctly logs primitives'] = function testCorrectlyLogsPrimitives() { + this.render('{{log "one" 1 true}}'); + + this.assertLog(['one', 1, true]); + }; + + _class.prototype['@test correctly logs a property'] = function testCorrectlyLogsAProperty() { + this.render('{{log value}}', { + value: 'one' + }); + + this.assertLog(['one']); + }; + + _class.prototype['@test correctly logs multiple arguments'] = function testCorrectlyLogsMultipleArguments() { + this.render('{{log "my variable:" value}}', { + value: 'one' + }); + + this.assertLog(['my variable:', 'one']); + }; + + _class.prototype['@test correctly logs `this`'] = function testCorrectlyLogsThis() { + this.render('{{log this}}'); + + this.assertLog([this.context]); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/log-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/log-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/log-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/mut-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember-glimmer/tests/utils/test-helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal, _emberGlimmerTestsUtilsTestHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{mut}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test a simple mutable binding using `mut` propagates properly'] = function testASimpleMutableBindingUsingMutPropagatesProperly() { + var _this = this; + + var bottom = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + template: '{{bottom-mut setMe=value}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assertText('12', 'the data propagated downwards'); + + this.assertStableRerender(); + + this.runTask(function () { + return bottom.attrs.setMe.update(13); + }); + + this.assertText('13', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 13, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 13, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'setMe', 14); + }); + + this.assertText('14', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 14, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test a simple mutable binding using `mut` inserts into the DOM'] = function testASimpleMutableBindingUsingMutInsertsIntoTheDOM() { + var _this2 = this; + + var bottom = undefined, + middle = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + middle = this; + } + }), + template: '{{bottom-mut setMe=(mut value)}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assertText('12', 'the data propagated downwards'); + + this.assertStableRerender(); + + this.runTask(function () { + return bottom.attrs.setMe.update(13); + }); + + this.assertText('13', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 13, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 13, 'the set propagated to middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 13, 'the set propagated to middle\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 13, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'setMe', 14); + }); + + this.assertText('14', 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 14, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 14, 'the set propagated to middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 14, 'the set propagated to middle\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test passing a literal results in a assertion'] = function testPassingALiteralResultsInAAssertion() { + var _this3 = this; + + this.registerComponent('bottom-mut', { template: '{{setMe}}' }); + + expectAssertion(function () { + _this3.render('{{bottom-mut setMe=(mut "foo bar")}}'); + }, 'You can only pass a path to mut'); + }; + + _class.prototype['@test passing the result of a helper invocation results in an assertion'] = function testPassingTheResultOfAHelperInvocationResultsInAnAssertion() { + var _this4 = this; + + this.registerComponent('bottom-mut', { template: '{{setMe}}' }); + + expectAssertion(function () { + _this4.render('{{bottom-mut setMe=(mut (concat "foo" " " "bar"))}}'); + }, 'You can only pass a path to mut'); + }; + + // See https://github.com/emberjs/ember.js/commit/807a0cd for an explanation of this test + + _class.prototype['@test using a string value through middle tier does not trigger assertion (due to the auto-mut transform)'] = function testUsingAStringValueThroughMiddleTierDoesNotTriggerAssertionDueToTheAutoMutTransform() { + var bottom = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{stuff}}' + }); + + this.registerComponent('middle-mut', { + template: '{{bottom-mut stuff=value}}' + }); + + this.render('{{middle-mut value="foo"}}'); + + this.assert.equal(_emberMetal.get(bottom, 'stuff'), 'foo', 'the data propagated'); + this.assertText('foo'); + + this.assertStableRerender(); + + // No U-R for this test + }; + + _class.prototype['@test {{readonly}} of a {{mut}} is converted into an immutable binding'] = function testReadonlyOfAMutIsConvertedIntoAnImmutableBinding() { + var _this5 = this; + + var middle = undefined, + bottom = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + middle = this; + } + }), + template: '{{bottom-mut setMe=(readonly value)}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return middle.attrs.value.update(13); + }); + + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 13, 'the set took effect on middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 13, 'the set took effect on middle\'s attr'); + + this.runTask(function () { + return _emberMetal.set(middle, 'value', 14); + }); + + this.assert.strictEqual(_emberMetal.get(middle, 'value'), 14, 'the set took effect on middle\'s prop'); + this.assert.strictEqual(middle.attrs.value.value, 14, 'the set took effect on middle\'s attr'); + this.assert.strictEqual(bottom.attrs.setMe, 14, 'the mutable binding has been converted to an immutable cell'); + this.assertText('14'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test mutable bindings work inside of yielded content'] = function testMutableBindingsWorkInsideOfYieldedContent() { + var _this6 = this; + + this.registerComponent('bottom-mut', { + template: '{{yield}}' + }); + + this.registerComponent('middle-mut', { + template: '{{#bottom-mut}}{{model.name}}{{/bottom-mut}}' + }); + + this.render('{{middle-mut model=(mut model)}}', { + model: { name: 'Matthew Beale' } + }); + + this.assertText('Matthew Beale'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'model.name', 'Joel Kang'); + }); + + this.assertText('Joel Kang'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'model', { name: 'Matthew Beale' }); + }); + + this.assertText('Matthew Beale'); + }; + + _class.prototype['@test a simple mutable binding using {{mut}} is available in hooks'] = function testASimpleMutableBindingUsingMutIsAvailableInHooks() { + var _this7 = this; + + var bottom = undefined; + var willRender = []; + var didInsert = []; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willRender: function () { + willRender.push(_emberMetal.get(this, 'setMe')); + }, + didInsertElement: function () { + didInsert.push(_emberMetal.get(this, 'setMe')); + bottom = this; + } + }), + template: '{{setMe}}' + }); + + this.registerComponent('middle-mut', { + template: '{{bottom-mut setMe=(mut value)}}' + }); + + this.render('{{middle-mut value=(mut val)}}', { + val: 12 + }); + + this.assert.deepEqual(willRender, [12], 'willReceive is [12]'); + this.assert.deepEqual(didInsert, [12], 'didInsert is [12]'); + this.assertText('12'); + + this.assertStableRerender(); + + this.assert.deepEqual(willRender, [12], 'willReceive is [12]'); + this.assert.deepEqual(didInsert, [12], 'didInsert is [12]'); + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 12, 'the data propagated'); + + this.runTask(function () { + return bottom.attrs.setMe.update(13); + }); + + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 13, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 13, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'setMe', 14); + }); + + this.assert.strictEqual(_emberMetal.get(bottom, 'setMe'), 14, 'the set took effect on bottom\'s prop'); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, 'the set took effect on bottom\'s attr'); + this.assert.strictEqual(_emberMetal.get(this.context, 'val'), 14, 'the set propagated back up'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'val', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test a mutable binding with a backing computed property and attribute present in the root of the component is updated when the upstream property invalidates #11023'] = function testAMutableBindingWithABackingComputedPropertyAndAttributePresentInTheRootOfTheComponentIsUpdatedWhenTheUpstreamPropertyInvalidates11023() { + var bottom = undefined, + middle = undefined; + + this.registerComponent('bottom-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + thingy: null, + didInsertElement: function () { + bottom = this; + } + }), + template: '{{thingy}}' + }); + + this.registerComponent('middle-mut', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + baseValue: 12, + val: _emberMetal.computed('baseValue', function () { + return this.get('baseValue'); + }), + didInsertElement: function () { + middle = this; + } + }), + template: '{{bottom-mut thingy=(mut val)}}' + }); + + this.render('{{middle-mut}}'); + + this.assert.strictEqual(_emberMetal.get(bottom, 'thingy'), 12, 'data propagated'); + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(middle, 'baseValue', 13); + }); + + this.assert.strictEqual(_emberMetal.get(middle, 'val'), 13, 'the set took effect'); + this.assert.strictEqual(bottom.attrs.thingy.value, 13, 'the set propagated down to bottom\'s attrs'); + this.assert.strictEqual(_emberMetal.get(bottom, 'thingy'), 13, 'the set propagated down to bottom\'s prop'); + this.assertText('13'); + + this.runTask(function () { + return _emberMetal.set(middle, 'baseValue', 12); + }); + + this.assertText('12'); + }; + + _class.prototype['@test automatic mutable bindings exposes a mut cell in attrs'] = function testAutomaticMutableBindingsExposesAMutCellInAttrs() { + var inner = undefined; + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + inner = this; + } + }), + template: '{{foo}}' + }); + + this.registerComponent('x-outer', { + template: '{{x-inner foo=bar}}' + }); + + this.render('{{x-outer bar=baz}}', { baz: 'foo' }); + + this.assertText('foo'); + + this.assertStableRerender(); + + this.runTask(function () { + return inner.attrs.foo.update('bar'); + }); + + this.assert.equal(inner.attrs.foo.value, 'bar'); + this.assert.equal(_emberMetal.get(inner, 'foo'), 'bar'); + this.assertText('bar'); + + this.runTask(function () { + return inner.attrs.foo.update('foo'); + }); + + this.assertText('foo'); + }; + + _class.prototype['@test automatic mutable bindings tolerate undefined non-stream inputs and attempts to set them'] = function testAutomaticMutableBindingsTolerateUndefinedNonStreamInputsAndAttemptsToSetThem() { + var inner = undefined; + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + inner = this; + } + }), + template: '{{model}}' + }); + + this.registerComponent('x-outer', { + template: '{{x-inner model=nonexistent}}' + }); + + this.render('{{x-outer}}'); + + this.assertText(''); + + this.assertStableRerender(); + + this.runTask(function () { + return inner.attrs.model.update(42); + }); + + this.assert.equal(inner.attrs.model.value, 42); + this.assert.equal(_emberMetal.get(inner, 'model'), 42); + this.assertText('42'); + + this.runTask(function () { + return inner.attrs.model.update(undefined); + }); + + this.assertText(''); + }; + + _class.prototype['@test automatic mutable bindings tolerate constant non-stream inputs and attempts to set them'] = function testAutomaticMutableBindingsTolerateConstantNonStreamInputsAndAttemptsToSetThem() { + var inner = undefined; + + this.registerComponent('x-inner', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + inner = this; + } + }), + template: 'hello{{model}}' + }); + + this.registerComponent('x-outer', { + template: '{{x-inner model=x}}' + }); + + this.render('{{x-outer x="foo"}}'); + + this.assertText('hellofoo'); + + this.assertStableRerender(); + + this.runTask(function () { + return inner.attrs.model.update(42); + }); + + this.assert.equal(inner.attrs.model.value, 42); + this.assert.equal(_emberMetal.get(inner, 'model'), 42); + this.assertText('hello42'); + + this.runTask(function () { + return inner.attrs.model.update('foo'); + }); + + this.assertText('hellofoo'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Mutable Bindings used in Computed Properties that are bound as attributeBindings', (function (_RenderingTest2) { + babelHelpers.inherits(_class2, _RenderingTest2); + + function _class2() { + _RenderingTest2.apply(this, arguments); + } + + _class2.prototype['@test an attribute binding of a computed property of a 2-way bound attr recomputes when the attr changes'] = function testAnAttributeBindingOfAComputedPropertyOfA2WayBoundAttrRecomputesWhenTheAttrChanges() { + var _this8 = this; + + var input = undefined, + output = undefined; + + this.registerComponent('x-input', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + input = this; + } + }) + }); + + this.registerComponent('x-output', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + didInsertElement: function () { + output = this; + }, + style: _emberMetal.computed('height', function () { + var height = this.get('height'); + return 'height: ' + height + 'px;'; + }), + height: 20 + }), + template: '{{height}}' + }); + + this.render('{{x-output height=height}}{{x-input height=(mut height)}}', { + height: 60 + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 60px;') }, content: '60' }); + + this.assertStableRerender(); + + this.runTask(function () { + return input.attrs.height.update(35); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'height'), 35, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'height'), 35, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 35px;') }, content: '35' }); + + this.runTask(function () { + return _emberMetal.set(input, 'height', 36); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'height'), 36, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'height'), 36, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 36px;') }, content: '36' }); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'height', 60); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 60px;') }, content: '60' }); + this.assert.strictEqual(_emberMetal.get(input, 'height'), 60); + }; + + _class2.prototype['@test an attribute binding of a computed property with a setter of a 2-way bound attr recomputes when the attr changes'] = function testAnAttributeBindingOfAComputedPropertyWithASetterOfA2WayBoundAttrRecomputesWhenTheAttrChanges() { + var _this9 = this; + + var input = undefined, + output = undefined; + + this.registerComponent('x-input', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + input = this; + } + }) + }); + + this.registerComponent('x-output', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + attributeBindings: ['style'], + didInsertElement: function () { + output = this; + }, + style: _emberMetal.computed('height', 'width', function () { + var height = this.get('height'); + var width = this.get('width'); + return 'height: ' + height + 'px; width: ' + width + 'px;'; + }), + height: 20, + width: _emberMetal.computed('height', { + get: function () { + return this.get('height') * 2; + }, + set: function (keyName, width) { + this.set('height', width / 2); + return width; + } + }) + }), + template: '{{width}}x{{height}}' + }); + + this.render('{{x-output width=width}}{{x-input width=(mut width)}}', { + width: 70 + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 35px; width: 70px;') }, content: '70x35' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(input, 'width', 80); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'width'), 80, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'width'), 80, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 40px; width: 80px;') }, content: '80x40' }); + + this.runTask(function () { + return input.attrs.width.update(90); + }); + + this.assert.strictEqual(_emberMetal.get(output, 'width'), 90, 'the set took effect'); + this.assert.strictEqual(_emberMetal.get(this.context, 'width'), 90, 'the set propagated back up'); + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 45px; width: 90px;') }, content: '90x45' }); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'width', 70); + }); + + this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: _emberGlimmerTestsUtilsTestHelpers.styles('height: 35px; width: 70px;') }, content: '70x35' }); + this.assert.strictEqual(_emberMetal.get(input, 'width'), 70); + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/mut-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/mut-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/mut-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/partial-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each model.items as |template i|}}\n {{model.type}}: {{partial template}}\n {{/each}}'], ['\n {{#each model.items as |template i|}}\n {{model.type}}: {{partial template}}\n {{/each}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with item.thing as |t|}}\n {{partial t}}\n {{else}}\n Nothing!\n {{/with}}'], ['\n {{#with item.thing as |t|}}\n {{partial t}}\n {{else}}\n Nothing!\n {{/with}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{partial}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should render other templates registered with the container'] = function testShouldRenderOtherTemplatesRegisteredWithTheContainer() { + this.registerPartial('_subTemplateFromContainer', 'sub-template'); + + this.render('This {{partial "subTemplateFromContainer"}} is pretty great.'); + + this.assertStableRerender(); + + this.assertText('This sub-template is pretty great.'); + }; + + _class.prototype['@test should render other slash-separated templates registered with the container'] = function testShouldRenderOtherSlashSeparatedTemplatesRegisteredWithTheContainer() { + this.registerPartial('child/_subTemplateFromContainer', 'sub-template'); + + this.render('This {{partial "child/subTemplateFromContainer"}} is pretty great.'); + + this.assertStableRerender(); + + this.assertText('This sub-template is pretty great.'); + }; + + _class.prototype['@test should use the current context'] = function testShouldUseTheCurrentContext() { + var _this = this; + + this.registerPartial('_person_name', '{{model.firstName}} {{model.lastName}}'); + + this.render('Who is {{partial "person_name"}}?', { + model: { + firstName: 'Kris', + lastName: 'Selden' + } + }); + + this.assertStableRerender(); + + this.assertText('Who is Kris Selden?'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.firstName', 'Kelly'); + }); + + this.assertText('Who is Kelly Selden?'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model', { firstName: 'Kris', lastName: 'Selden' }); + }); + + this.assertText('Who is Kris Selden?'); + }; + + _class.prototype['@test Quoteless parameters passed to {{partial}} perform a bound property lookup of the partial name'] = function testQuotelessParametersPassedToPartialPerformABoundPropertyLookupOfThePartialName() { + var _this2 = this; + + this.registerPartial('_subTemplate', 'sub-template'); + this.registerPartial('_otherTemplate', 'other-template'); + + this.render('This {{partial templates.partialName}} is pretty {{partial nonexistent}}great.', { + templates: { partialName: 'subTemplate' } + }); + + this.assertStableRerender(); + + this.assertText('This sub-template is pretty great.'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'templates.partialName', 'otherTemplate'); + }); + + this.assertText('This other-template is pretty great.'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'templates.partialName', null); + }); + + this.assertText('This is pretty great.'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'templates', { partialName: 'subTemplate' }); + }); + + this.assertText('This sub-template is pretty great.'); + }; + + _class.prototype['@test dynamic partials in {{#each}}'] = function testDynamicPartialsInEach() { + var _this3 = this; + + this.registerPartial('_odd', 'ODD{{i}}'); + this.registerPartial('_even', 'EVEN{{i}}'); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + model: { + items: ['even', 'odd', 'even', 'odd'], + type: 'number' + } + }); + + this.assertStableRerender(); + + this.assertText('number: EVEN0number: ODD1number: EVEN2number: ODD3'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.type', 'integer'); + }); + + this.assertText('integer: EVEN0integer: ODD1integer: EVEN2integer: ODD3'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { + items: ['even', 'odd', 'even', 'odd'], + type: 'number' + }); + }); + + this.assertText('number: EVEN0number: ODD1number: EVEN2number: ODD3'); + }; + + _class.prototype['@test dynamic partials in {{#with}}'] = function testDynamicPartialsInWith() { + var _this4 = this; + + this.registerPartial('_thing', '{{t}}'); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + item: { thing: false } + }); + + this.assertStableRerender(); + + this.assertText('Nothing!'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'item.thing', 'thing'); + }); + + this.assertText('thing'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'item', { thing: false }); + }); + + this.assertText('Nothing!'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/partial-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/partial-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/partial-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/readonly-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{readonly}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test {{readonly}} of a path should work'] = function testReadonlyOfAPathShouldWork() { + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + component = this; + } + }), + template: '{{value}}' + }); + + this.render('{{foo-bar value=(readonly val)}}', { + val: 12 + }); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(component, 'value', 13); + }); + this.assert.notOk(component.attrs.value.update); + + this.assertText('13', 'local property is updated'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'upstream attribute is not updated'); + + // No U-R + }; + + _class.prototype['@test {{readonly}} of a string renders correctly'] = function testReadonlyOfAStringRendersCorrectly() { + var component = undefined; + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + component = this; + } + }), + template: '{{value}}' + }); + + this.render('{{foo-bar value=(readonly "12")}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.assert.notOk(component.attrs.value.update); + this.assert.strictEqual(_emberMetal.get(component, 'value'), '12'); + + this.runTask(function () { + return _emberMetal.set(component, 'value', '13'); + }); + + this.assertText('13', 'local property is updated'); + this.assert.strictEqual(_emberMetal.get(component, 'value'), '13'); + + this.runTask(function () { + return _emberMetal.set(component, 'value', '12'); + }); + + this.assertText('12'); + }; + + _class.prototype['@test {{mut}} of a {{readonly}} mutates only the middle and bottom tiers'] = function testMutOfAReadonlyMutatesOnlyTheMiddleAndBottomTiers() { + var _this = this; + + var middle = undefined, + bottom = undefined; + + this.registerComponent('x-bottom', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + bottom = this; + } + }), + template: '{{bar}}' + }); + + this.registerComponent('x-middle', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + didInsertElement: function () { + middle = this; + } + }), + template: '{{foo}} {{x-bottom bar=(mut foo)}}' + }); + + this.render('{{x-middle foo=(readonly val)}}', { + val: 12 + }); + + this.assertText('12 12'); + + this.assertStableRerender(); + + this.assert.equal(_emberMetal.get(bottom, 'bar'), 12, 'bottom\'s local bar received the value'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 12, 'middle\'s local foo received the value'); + + this.runTask(function () { + return bottom.attrs.bar.update(13); + }); + + this.assert.equal(_emberMetal.get(bottom, 'bar'), 13, 'bottom\'s local bar was updated after set of bottom\'s bar'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 13, 'middle\'s local foo was updated after set of bottom\'s bar'); + this.assertText('13 13'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'But context val is not updated'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'bar', 14); + }); + + this.assert.equal(_emberMetal.get(bottom, 'bar'), 14, 'bottom\'s local bar was updated after set of bottom\'s bar'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 14, 'middle\'s local foo was updated after set of bottom\'s bar'); + this.assertText('14 14'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'But context val is not updated'); + + this.assert.notOk(middle.attrs.foo.update, 'middle\'s foo attr is not a mutable cell'); + this.runTask(function () { + return _emberMetal.set(middle, 'foo', 15); + }); + + this.assertText('15 15'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 15, 'set of middle\'s foo took effect'); + this.assert.equal(_emberMetal.get(bottom, 'bar'), 15, 'bottom\'s local bar was updated after set of middle\'s foo'); + this.assert.equal(_emberMetal.get(this.context, 'val'), 12, 'Context val remains unchanged'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'val', 10); + }); + + this.assertText('10 10'); + this.assert.equal(_emberMetal.get(bottom, 'bar'), 10, 'bottom\'s local bar was updated after set of context\'s val'); + this.assert.equal(_emberMetal.get(middle, 'foo'), 10, 'middle\'s local foo was updated after set of context\'s val'); + + this.runTask(function () { + return _emberMetal.set(bottom, 'bar', undefined); + }); + + this.assertText(' '); + this.assert.equal(_emberMetal.get(bottom, 'bar'), undefined, 'bottom\'s local bar was updated to a falsy value'); + this.assert.equal(_emberMetal.get(middle, 'foo'), undefined, 'middle\'s local foo was updated to a falsy value'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'val', 12); + }); + this.assertText('12 12', 'bottom and middle were both reset'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/readonly-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/readonly-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/readonly-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/render-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{render}}', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should render given template'] = function testShouldRenderGivenTemplate() { + var _this = this; + + this.registerTemplate('home', '

    BYE

    '); + + expectDeprecation(function () { + _this.render('

    HI

    {{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test uses `controller:basic` as the basis for a generated controller when none exists for specified name'] = function testUsesControllerBasicAsTheBasisForAGeneratedControllerWhenNoneExistsForSpecifiedName() { + var _this2 = this; + + this.owner.register('controller:basic', _emberRuntime.Controller.extend({ + isBasicController: true + })); + this.registerTemplate('home', '{{isBasicController}}'); + + expectDeprecation(function () { + _this2.render('{{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('true'); + }; + + _class.prototype['@test generates a controller if none exists'] = function testGeneratesAControllerIfNoneExists() { + var _this3 = this; + + this.registerTemplate('home', '

    {{this}}

    '); + + expectDeprecation(function () { + _this3.render('

    HI

    {{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HI(generated home controller)'); + }; + + _class.prototype['@test should use controller with the same name as template if present'] = function testShouldUseControllerWithTheSameNameAsTemplateIfPresent() { + var _this4 = this; + + this.owner.register('controller:home', _emberRuntime.Controller.extend({ name: 'home' })); + this.registerTemplate('home', '{{name}}

    BYE

    '); + + expectDeprecation(function () { + _this4.render('

    HI

    {{render \'home\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIhomeBYE'); + }; + + _class.prototype['@test should render nested helpers'] = function testShouldRenderNestedHelpers() { + var _this5 = this; + + this.owner.register('controller:home', _emberRuntime.Controller.extend()); + this.owner.register('controller:foo', _emberRuntime.Controller.extend()); + this.owner.register('controller:bar', _emberRuntime.Controller.extend()); + this.owner.register('controller:baz', _emberRuntime.Controller.extend()); + + this.registerTemplate('home', '

    BYE

    '); + this.registerTemplate('baz', '

    BAZ

    '); + + expectDeprecation(function () { + _this5.registerTemplate('foo', '

    FOO

    {{render \'bar\'}}'); + _this5.registerTemplate('bar', '

    BAR

    {{render \'baz\'}}'); + _this5.render('

    HI

    {{render \'foo\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIFOOBARBAZ'); + }; + + _class.prototype['@test should have assertion if the template does not exist'] = function testShouldHaveAssertionIfTheTemplateDoesNotExist() { + var _this6 = this; + + this.owner.register('controller:oops', _emberRuntime.Controller.extend()); + + expectDeprecation(function () { + expectAssertion(function () { + _this6.render('

    HI

    {{render \'oops\'}}'); + }, 'You used `{{render \'oops\'}}`, but \'oops\' can not be found as a template.'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + }; + + _class.prototype['@test should render given template with the singleton controller as its context'] = function testShouldRenderGivenTemplateWithTheSingletonControllerAsItsContext() { + var _this7 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + init: function () { + this.set('title', 'It\'s Simple Made Easy'); + } + })); + this.registerTemplate('post', '

    {{title}}

    '); + + expectDeprecation(function () { + _this7.render('

    HI

    {{render \'post\'}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + + var controller = this.owner.lookup('controller:post'); + + this.runTask(function () { + return _emberMetal.set(controller, 'title', 'Rails is omakase'); + }); + + this.assertText('HIRails is omakase'); + + this.runTask(function () { + return _emberMetal.set(controller, 'title', 'It\'s Simple Made Easy'); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + }; + + _class.prototype['@test should not destroy the singleton controller on teardown'] = function testShouldNotDestroyTheSingletonControllerOnTeardown(assert) { + var _this8 = this; + + var willDestroyFired = 0; + + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + init: function () { + this.set('title', 'It\'s Simple Made Easy'); + }, + + willDestroy: function () { + this._super.apply(this, arguments); + willDestroyFired++; + } + })); + + this.registerTemplate('post', '

    {{title}}

    '); + + expectDeprecation(function () { + _this8.render('{{#if showPost}}{{render \'post\'}}{{else}}Nothing here{{/if}}', { showPost: false }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'showPost', true); + }); + + this.assertText('It\'s Simple Made Easy'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'showPost', false); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + }; + + _class.prototype['@test should render given template with a supplied model'] = function testShouldRenderGivenTemplateWithASuppliedModel() { + var _this9 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + this.registerTemplate('post', '

    {{model.title}}

    '); + + expectDeprecation(function () { + _this9.render('

    HI

    {{render \'post\' post}}', { + post: { + title: 'It\'s Simple Made Easy' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'post.title', 'Rails is omakase'); + }); + + this.assertText('HIRails is omakase'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'post', { title: 'It\'s Simple Made Easy' }); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + }; + + _class.prototype['@test should destroy the non-singleton controllers on teardown'] = function testShouldDestroyTheNonSingletonControllersOnTeardown(assert) { + var _this10 = this; + + var willDestroyFired = 0; + + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + willDestroy: function () { + this._super.apply(this, arguments); + willDestroyFired++; + } + })); + + this.registerTemplate('post', '

    {{model.title}}

    '); + + expectDeprecation(function () { + _this10.render('{{#if showPost}}{{render \'post\' post}}{{else}}Nothing here{{/if}}', { + showPost: false, + post: { + title: 'It\'s Simple Made Easy' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', true); + }); + + this.assertText('It\'s Simple Made Easy'); + + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', false); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 1, 'it did destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', true); + }); + + this.assertText('It\'s Simple Made Easy'); + + assert.strictEqual(willDestroyFired, 1, 'it did not destroy the controller'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'showPost', false); + }); + + this.assertText('Nothing here'); + + assert.strictEqual(willDestroyFired, 2, 'it did destroy the controller'); + }; + + _class.prototype['@test with a supplied model should not fire observers on the controller'] = function testWithASuppliedModelShouldNotFireObserversOnTheController() { + var _this11 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + this.registerTemplate('post', '

    {{model.title}}

    '); + + var postDidChange = 0; + expectDeprecation(function () { + _this11.render('

    HI

    {{render \'post\' post}}', { + postDidChange: _emberMetal.observer('post', function () { + postDidChange++; + }), + post: { + title: 'It\'s Simple Made Easy' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HIIt\'s Simple Made Easy'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('HIIt\'s Simple Made Easy'); + }; + + _class.prototype['@test should raise an error when a given controller name does not resolve to a controller'] = function testShouldRaiseAnErrorWhenAGivenControllerNameDoesNotResolveToAController() { + var _this12 = this; + + this.registerTemplate('home', '

    BYE

    '); + this.owner.register('controller:posts', _emberRuntime.Controller.extend()); + + expectDeprecation(function () { + expectAssertion(function () { + _this12.render('

    HI

    {{render "home" controller="postss"}}'); + }, /The controller name you supplied \'postss\' did not resolve to a controller./); + }, /Please refactor [\w\{\}"` ]+ to a component/); + }; + + _class.prototype['@test should render with given controller'] = function testShouldRenderWithGivenController(assert) { + var _this13 = this; + + this.registerTemplate('home', '{{uniqueId}}'); + + var id = 0; + var model = {}; + + this.owner.register('controller:posts', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + this.uniqueId = id++; + this.set('model', model); + } + })); + + expectDeprecation(function () { + _this13.render('{{render "home" controller="posts"}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + var renderedController = this.owner.lookup('controller:posts'); + var uniqueId = renderedController.get('uniqueId'); + var renderedModel = renderedController.get('model'); + + assert.equal(uniqueId, 0); + assert.equal(renderedModel, model); + this.assertText('0'); + + this.runTask(function () { + return _this13.rerender(); + }); + + assert.equal(uniqueId, 0); + assert.equal(renderedModel, model); + this.assertText('0'); + }; + + _class.prototype['@test should render templates with models multiple times'] = function testShouldRenderTemplatesWithModelsMultipleTimes(assert) { + var _this14 = this; + + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + + this.registerTemplate('post', '

    {{model.title}}

    '); + expectDeprecation(function () { + _this14.render('

    HI

    {{render \'post\' post1}} {{render \'post\' post2}}', { + post1: { + title: 'Me First' + }, + post2: { + title: 'Then me' + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + this.assertText('HI Me First Then me'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('HI Me First Then me'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'post1.title', 'I am new'); + }); + + this.assertText('HI I am new Then me'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'post1', { title: 'Me First' }); + }); + + this.assertText('HI Me First Then me'); + }; + + _class.prototype['@test should not treat invocations with falsy contexts as context-less'] = function testShouldNotTreatInvocationsWithFalsyContextsAsContextLess(assert) { + var _this15 = this; + + this.registerTemplate('post', '

    {{#unless model.zero}}NOTHING{{/unless}}

    '); + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + + expectDeprecation(function () { + _this15.render('

    HI

    {{render \'post\' zero}} {{render \'post\' nonexistent}}', { + model: { + zero: false + } + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + assert.ok(this.$().text().match(/^HI ?NOTHING ?NOTHING$/)); + }; + + _class.prototype['@test should render templates both with and without models'] = function testShouldRenderTemplatesBothWithAndWithoutModels(assert) { + var _this16 = this; + + this.registerTemplate('post', '

    Title:{{model.title}}

    '); + this.owner.register('controller:post', _emberRuntime.Controller.extend()); + + var post = { + title: 'Rails is omakase' + }; + expectDeprecation(function () { + _this16.render('

    HI

    {{render \'post\'}} {{render \'post\' post}}', { + post: post + }); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/)); + + this.runTask(function () { + return _this16.rerender(); + }); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/)); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'post.title', 'Simple Made Easy'); + }); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Simple Made Easy$/)); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'post', { title: 'Rails is omakase' }); + }); + + assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/)); + }; + + _class.prototype['@test works with dot notation'] = function testWorksWithDotNotation() { + var _this17 = this; + + this.registerTemplate('blog.post', '{{uniqueId}}'); + + var id = 0; + this.owner.register('controller:blog.post', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + this.uniqueId = id++; + } + })); + + expectDeprecation(function () { + _this17.render('{{render "blog.post"}}'); + }, /Please refactor [\w\.{\}"` ]+ to a component/); + + this.assertText('0'); + }; + + _class.prototype['@test throws an assertion if called with an unquoted template name'] = function testThrowsAnAssertionIfCalledWithAnUnquotedTemplateName() { + var _this18 = this; + + this.registerTemplate('home', '

    BYE

    '); + + expectAssertion(function () { + _this18.render('

    HI

    {{render home}}'); + }, 'The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.'); + }; + + _class.prototype['@test throws an assertion if called with a literal for a model'] = function testThrowsAnAssertionIfCalledWithALiteralForAModel() { + var _this19 = this; + + this.registerTemplate('home', '

    BYE

    '); + expectAssertion(function () { + _this19.render('

    HI

    {{render "home" "model"}}', { + model: { + title: 'Simple Made Easy' + } + }); + }, 'The second argument of {{render}} must be a path, e.g. {{render "post" post}}.'); + }; + + _class.prototype['@test should set router as target when action not found on parentController is not found'] = function testShouldSetRouterAsTargetWhenActionNotFoundOnParentControllerIsNotFound(assert) { + var _this20 = this; + + var postController = undefined; + this.registerTemplate('post', 'post template'); + this.owner.register('controller:post', _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + postController = this; + } + })); + + var routerStub = { + send: function (actionName) { + assert.equal(actionName, 'someAction'); + assert.ok(true, 'routerStub#send called'); + } + }; + + this.owner.register('router:main', routerStub, { instantiate: false }); + + expectDeprecation(function () { + _this20.render('{{render \'post\' post1}}'); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + postController.send('someAction'); + }; + + _class.prototype['@test render helper emits useful backtracking re-render assertion message'] = function testRenderHelperEmitsUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this21 = this; + + this.owner.register('controller:outer', _emberRuntime.Controller.extend()); + this.owner.register('controller:inner', _emberRuntime.Controller.extend({ + propertyWithError: _emberMetal.computed(function () { + this.set('model.name', 'this will cause a backtracking error'); + return 'foo'; + }) + })); + + var expectedBacktrackingMessage = /modified "model\.name" twice on \[object Object\] in a single render\. It was rendered in "controller:outer \(with the render helper\)" and modified in "controller:inner \(with the render helper\)"/; + + expectDeprecation(function () { + var person = { name: 'Ben' }; + + _this21.registerTemplate('outer', 'Hi {{model.name}} | {{render \'inner\' model}}'); + _this21.registerTemplate('inner', 'Hi {{propertyWithError}}'); + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + _this21.render('{{render \'outer\' person}}', { person: person }); + } else { + expectAssertion(function () { + _this21.render('{{render \'outer\' person}}', { person: person }); + }, expectedBacktrackingMessage); + } + }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/render-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/render-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/render-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/text-area-test', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberUtils, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var TextAreaRenderingTest = (function (_RenderingTest) { + babelHelpers.inherits(TextAreaRenderingTest, _RenderingTest); + + function TextAreaRenderingTest() { + _RenderingTest.call(this); + + this.registerComponent('-text-area', { ComponentClass: _emberGlimmerTestsUtilsHelpers.TextArea }); + } + + TextAreaRenderingTest.prototype.assertTextArea = function assertTextArea() { + var _ref2 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + var attrs = _ref2.attrs; + var value = _ref2.value; + + var mergedAttrs = _emberUtils.assign({ 'class': _emberGlimmerTestsUtilsTestHelpers.classes('ember-view ember-text-area') }, attrs); + this.assertComponentElement(this.firstChild, { tagName: 'textarea', attrs: mergedAttrs }); + + if (value) { + this.assert.strictEqual(value, this.firstChild.value); + } + }; + + TextAreaRenderingTest.prototype.triggerEvent = function triggerEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var event = document.createEvent('Events'); + event.initEvent(type, true, true); + _emberUtils.assign(event, options); + + this.firstChild.dispatchEvent(event); + }; + + return TextAreaRenderingTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var BoundTextAreaAttributes = (function () { + function BoundTextAreaAttributes(cases) { + this.cases = cases; + } + + BoundTextAreaAttributes.prototype.generate = function generate(_ref3) { + var _ref; + + var attribute = _ref3.attribute; + var first = _ref3.first; + var second = _ref3.second; + + return _ref = {}, _ref['@test ' + attribute] = function (assert) { + var _attrs, + _attrs2, + _attrs3, + _this = this; + + this.render('{{textarea ' + attribute + '=value}}', { + value: first + }); + this.assertTextArea({ attrs: (_attrs = {}, _attrs[attribute] = first, _attrs) }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'value', second); + }); + this.assertTextArea({ attrs: (_attrs2 = {}, _attrs2[attribute] = second, _attrs2) }); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'value', first); + }); + this.assertTextArea({ attrs: (_attrs3 = {}, _attrs3[attribute] = first, _attrs3) }); + }, _ref; + }; + + return BoundTextAreaAttributes; + })(); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(TextAreaRenderingTest, new BoundTextAreaAttributes([{ attribute: 'placeholder', first: 'Stuff here', second: 'Other stuff' }, { attribute: 'name', first: 'Stuff here', second: 'Other stuff' }, { attribute: 'title', first: 'Stuff here', second: 'Other stuff' }, { attribute: 'maxlength', first: '1', second: '2' }, { attribute: 'rows', first: '1', second: '2' }, { attribute: 'cols', first: '1', second: '2' }, { attribute: 'tabindex', first: '1', second: '2' }])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{textarea}}', (function (_TextAreaRenderingTest) { + babelHelpers.inherits(_class, _TextAreaRenderingTest); + + function _class() { + _TextAreaRenderingTest.apply(this, arguments); + } + + _class.prototype['@test Should insert a textarea'] = function testShouldInsertATextarea() { + this.render('{{textarea}}'); + + equal(this.$('textarea').length, 1); + + this.assertStableRerender(); + }; + + _class.prototype['@test Should respect disabled'] = function testShouldRespectDisabled() { + this.render('{{textarea disabled=disabled}}', { + disabled: true + }); + ok(this.$('textarea').is(':disabled')); + }; + + _class.prototype['@test Should respect disabled when false'] = function testShouldRespectDisabledWhenFalse() { + this.render('{{textarea disabled=disabled}}', { + disabled: false + }); + ok(this.$('textarea').is(':not(:disabled)')); + }; + + _class.prototype['@test Should become disabled when the context changes'] = function testShouldBecomeDisabledWhenTheContextChanges() { + var _this2 = this; + + this.render('{{textarea disabled=disabled}}'); + ok(this.$('textarea').is(':not(:disabled)')); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'disabled', true); + }); + ok(this.$('textarea').is(':disabled')); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'disabled', false); + }); + ok(this.$('textarea').is(':not(:disabled)')); + }; + + _class.prototype['@test Should bind its contents to the specified value'] = function testShouldBindItsContentsToTheSpecifiedValue() { + var _this3 = this; + + this.render('{{textarea value=model.val}}', { + model: { val: 'A beautiful day in Seattle' } + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.val', 'Auckland'); + }); + this.assertTextArea({ value: 'Auckland' }); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { val: 'A beautiful day in Seattle' }); + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + }; + + _class.prototype['@test GH#14001 Should correctly handle an empty string bound value'] = function testGH14001ShouldCorrectlyHandleAnEmptyStringBoundValue() { + var _this4 = this; + + this.render('{{textarea value=message}}', { message: '' }); + + this.assert.strictEqual(this.firstChild.value, ''); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', 'hello'); + }); + + this.assert.strictEqual(this.firstChild.value, 'hello'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'message', ''); + }); + + this.assert.strictEqual(this.firstChild.value, ''); + }; + + _class.prototype['@test should update the value for `cut` / `input` / `change` events'] = function testShouldUpdateTheValueForCutInputChangeEvents() { + var _this5 = this; + + this.render('{{textarea value=model.val}}', { + model: { val: 'A beautiful day in Seattle' } + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + + this.assertStableRerender(); + + this.runTask(function () { + _this5.firstChild.value = 'Auckland'; + _this5.triggerEvent('cut'); + }); + this.assertTextArea({ value: 'Auckland' }); + + this.runTask(function () { + _this5.firstChild.value = 'Hope'; + _this5.triggerEvent('paste'); + }); + this.assertTextArea({ value: 'Hope' }); + + this.runTask(function () { + _this5.firstChild.value = 'Boston'; + _this5.triggerEvent('input'); + }); + this.assertTextArea({ value: 'Boston' }); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model', { val: 'A beautiful day in Seattle' }); + }); + this.assertTextArea({ value: 'A beautiful day in Seattle' }); + }; + + return _class; + })(TextAreaRenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/text-area-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/text-area-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/text-area-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/unbound-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-runtime'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal, _emberGlimmerTestsUtilsHelpers, _emberRuntime) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n \n '], ['\n \n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{unbound (surround model.prefix model.value "bar")}} {{surround model.prefix model.value "bar"}} {{unbound (surround "bar" model.value model.suffix)}} {{surround "bar" model.value model.suffix}}'], ['\n {{unbound (surround model.prefix model.value "bar")}} {{surround model.prefix model.value "bar"}} {{unbound (surround "bar" model.value model.suffix)}} {{surround "bar" model.value model.suffix}}']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if (unbound model.foo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/if}}\n {{#unless (unbound model.notfoo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/unless}}'], ['\n {{#if (unbound model.foo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/if}}\n {{#unless (unbound model.notfoo)}}\n {{#if model.bar}}true{{/if}}\n {{#unless model.bar}}false{{/unless}}\n {{/unless}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{unbound}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test should be able to output a property without binding'] = function testShouldBeAbleToOutputAPropertyWithoutBinding() { + var _this = this; + + this.render('
    {{unbound content.anUnboundString}}
    ', { + content: { + anUnboundString: 'No spans here, son.' + } + }); + + this.assertText('No spans here, son.'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('No spans here, son.'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'content.anUnboundString', 'HEY'); + }); + + this.assertText('No spans here, son.'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'content', { + anUnboundString: 'No spans here, son.' + }); + }); + + this.assertText('No spans here, son.'); + }; + + _class.prototype['@test should be able to use unbound helper in #each helper'] = function testShouldBeAbleToUseUnboundHelperInEachHelper() { + var _this2 = this; + + this.render('
      {{#each items as |item|}}
    • {{unbound item}}
    • {{/each}}
    ', { + items: _emberRuntime.A(['a', 'b', 'c', 1, 2, 3]) + }); + + this.assertText('abc123'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('abc123'); + }; + + _class.prototype['@test should be able to use unbound helper in #each helper (with objects)'] = function testShouldBeAbleToUseUnboundHelperInEachHelperWithObjects() { + var _this3 = this; + + this.render('
      {{#each items as |item|}}
    • {{unbound item.wham}}
    • {{/each}}
    ', { + items: _emberRuntime.A([{ wham: 'bam' }, { wham: 1 }]) + }); + + this.assertText('bam1'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('bam1'); + + this.runTask(function () { + return _this3.context.items.setEach('wham', 'HEY'); + }); + + this.assertText('bam1'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'items', _emberRuntime.A([{ wham: 'bam' }, { wham: 1 }])); + }); + + this.assertText('bam1'); + }; + + _class.prototype['@test it should assert unbound cannot be called with multiple arguments'] = function testItShouldAssertUnboundCannotBeCalledWithMultipleArguments() { + var _this4 = this; + + var willThrow = function () { + _this4.render('{{unbound foo bar}}', { + foo: 'BORK', + bar: 'BLOOP' + }); + }; + + expectAssertion(willThrow, /unbound helper cannot be called with multiple params or hash params/); + }; + + _class.prototype['@test should render on attributes'] = function testShouldRenderOnAttributes() { + var _this5 = this; + + this.render('', { + model: { foo: 'BORK' } + }); + + this.assertHTML(''); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertHTML(''); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model.foo', 'OOF'); + }); + + this.assertHTML(''); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'model', { foo: 'BORK' }); + }); + + this.assertHTML(''); + }; + + _class.prototype['@test should property escape unsafe hrefs'] = function testShouldPropertyEscapeUnsafeHrefs() { + var _this6 = this; + + var unsafeUrls = _emberRuntime.A([{ + name: 'Bob', + url: 'javascript:bob-is-cool' // jshint ignore:line + }, { + name: 'James', + url: 'vbscript:james-is-cool' // jshint ignore:line + }, { + name: 'Richard', + url: 'javascript:richard-is-cool' // jshint ignore:line + }]); + + this.render('', { + people: unsafeUrls + }); + + var escapedHtml = _emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject); + + this.assertHTML(escapedHtml); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertHTML(escapedHtml); + + this.runTask(function () { + return _this6.context.people.setEach('url', 'http://google.com'); + }); + + this.assertHTML(escapedHtml); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'people', unsafeUrls); + }); + + this.assertHTML(escapedHtml); + }; + + _class.prototype['@skip helper form updates on parent re-render'] = function skipHelperFormUpdatesOnParentReRender() { + var _this7 = this; + + this.render('{{unbound foo}}', { + foo: 'BORK' + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', 'OOF'); + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('OOF'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', ''); + }); + + this.assertText('OOF'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', 'BORK'); + }); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('BORK'); + }; + + // semantics here is not guaranteed + + _class.prototype['@test sexpr form does not update no matter what'] = function testSexprFormDoesNotUpdateNoMatterWhat() { + var _this8 = this; + + this.registerHelper('capitalize', function (args) { + return args[0].toUpperCase(); + }); + + this.render('{{capitalize (unbound foo)}}', { + foo: 'bork' + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('BORK'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'foo', 'oof'); + _this8.rerender(); + }); + + this.assertText('BORK'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'foo', 'blip'); + }); + + this.assertText('BORK'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'foo', 'bork'); + _this8.rerender(); + }); + + this.assertText('BORK'); + }; + + _class.prototype['@test sexpr in helper form does not update on parent re-render'] = function testSexprInHelperFormDoesNotUpdateOnParentReRender() { + var _this9 = this; + + this.registerHelper('capitalize', function (params) { + return params[0].toUpperCase(); + }); + + this.registerHelper('doublize', function (params) { + return params[0] + ' ' + params[0]; + }); + + this.render('{{capitalize (unbound (doublize foo))}}', { + foo: 'bork' + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'foo', 'oof'); + _this9.rerender(); + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'foo', 'blip'); + }); + + this.assertText('BORK BORK'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'foo', 'bork'); + _this9.rerender(); + }); + + this.assertText('BORK BORK'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation'] = function testShouldBeAbleToRenderAnUnboundHelperInvocation() { + var _this10 = this; + + this.registerHelper('repeat', function (_ref, _ref2) { + var value = _ref[0]; + var count = _ref2.count; + + var a = []; + while (a.length < count) { + a.push(value); + } + return a.join(''); + }); + + this.render('{{unbound (repeat foo count=bar)}} {{repeat foo count=bar}} {{unbound (repeat foo count=2)}} {{repeat foo count=4}}', { + foo: 'X', + bar: 5 + }); + + this.assertText('XXXXX XXXXX XX XXXX'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('XXXXX XXXXX XX XXXX'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'bar', 1); + }); + + this.assertText('XXXXX X XX XXXX'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'bar', 5); + }); + + this.assertText('XXXXX XXXXX XX XXXX'); + }; + + _class.prototype['@test should be able to render an bound helper invocation mixed with static values'] = function testShouldBeAbleToRenderAnBoundHelperInvocationMixedWithStaticValues() { + var _this11 = this; + + this.registerHelper('surround', function (_ref3) { + var prefix = _ref3[0]; + var value = _ref3[1]; + var suffix = _ref3[2]; + return prefix + '-' + value + '-' + suffix; + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + model: { + prefix: 'before', + value: 'core', + suffix: 'after' + } + }); + + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); + + this.runTask(function () { + _emberMetal.setProperties(_this11.context.model, { + prefix: 'beforeChanged', + value: 'coreChanged', + suffix: 'afterChanged' + }); + }); + + this.assertText('before-core-bar beforeChanged-coreChanged-bar bar-core-after bar-coreChanged-afterChanged'); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'model', { + prefix: 'before', + value: 'core', + suffix: 'after' + }); + }); + + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); + }; + + _class.prototype['@test should be able to render unbound forms of multi-arg helpers'] = function testShouldBeAbleToRenderUnboundFormsOfMultiArgHelpers() { + var _this12 = this; + + this.registerHelper('fauxconcat', function (params) { + return params.join(''); + }); + + this.render('{{fauxconcat model.foo model.bar model.bing}} {{unbound (fauxconcat model.foo model.bar model.bing)}}', { + model: { + foo: 'a', + bar: 'b', + bing: 'c' + } + }); + + this.assertText('abc abc'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('abc abc'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model.bar', 'X'); + }); + + this.assertText('aXc abc'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'model', { + foo: 'a', + bar: 'b', + bing: 'c' + }); + }); + + this.assertText('abc abc'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation for helpers with dependent keys'] = function testShouldBeAbleToRenderAnUnboundHelperInvocationForHelpersWithDependentKeys() { + var _this13 = this; + + this.registerHelper('capitalizeName', { + destroy: function () { + this.removeObserver('value.firstName'); + this._super.apply(this, arguments); + }, + + compute: function (_ref4) { + var value = _ref4[0]; + + if (this.get('value')) { + this.removeObserver('value.firstName'); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + return value ? _emberMetal.get(value, 'firstName').toUpperCase() : ''; + } + }); + + this.registerHelper('concatNames', { + destroy: function () { + this.teardown(); + this._super.apply(this, arguments); + }, + teardown: function () { + this.removeObserver('value.firstName'); + this.removeObserver('value.lastName'); + }, + compute: function (_ref5) { + var value = _ref5[0]; + + if (this.get('value')) { + this.teardown(); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + this.addObserver('value.lastName', this, this.recompute); + return (value ? _emberMetal.get(value, 'firstName') : '') + (value ? _emberMetal.get(value, 'lastName') : ''); + } + }); + + this.render('{{capitalizeName person}} {{unbound (capitalizeName person)}} {{concatNames person}} {{unbound (concatNames person)}}', { + person: { + firstName: 'shooby', + lastName: 'taylor' + } + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'person.firstName', 'sally'); + }); + + this.assertText('SALLY SHOOBY sallytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'person', { + firstName: 'shooby', + lastName: 'taylor' + }); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation in #each helper'] = function testShouldBeAbleToRenderAnUnboundHelperInvocationInEachHelper() { + var _this14 = this; + + this.registerHelper('capitalize', function (params) { + return params[0].toUpperCase(); + }); + + this.render('{{#each people as |person|}}{{capitalize person.firstName}} {{unbound (capitalize person.firstName)}}{{/each}}', { + people: _emberRuntime.A([{ + firstName: 'shooby', + lastName: 'taylor' + }, { + firstName: 'cindy', + lastName: 'taylor' + }]) + }); + + this.assertText('SHOOBY SHOOBYCINDY CINDY'); + + this.runTask(function () { + return _this14.rerender(); + }); + + this.assertText('SHOOBY SHOOBYCINDY CINDY'); + + this.runTask(function () { + return _this14.context.people.setEach('firstName', 'chad'); + }); + + this.assertText('CHAD SHOOBYCHAD CINDY'); + + this.runTask(function () { + return _emberMetal.set(_this14.context, 'people', _emberRuntime.A([{ + firstName: 'shooby', + lastName: 'taylor' + }, { + firstName: 'cindy', + lastName: 'taylor' + }])); + }); + + this.assertText('SHOOBY SHOOBYCINDY CINDY'); + }; + + _class.prototype['@test should be able to render an unbound helper invocation with bound hash options'] = function testShouldBeAbleToRenderAnUnboundHelperInvocationWithBoundHashOptions() { + var _this15 = this; + + this.registerHelper('capitalizeName', { + destroy: function () { + this.removeObserver('value.firstName'); + this._super.apply(this, arguments); + }, + + compute: function (_ref6) { + var value = _ref6[0]; + + if (this.get('value')) { + this.removeObserver('value.firstName'); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + return value ? _emberMetal.get(value, 'firstName').toUpperCase() : ''; + } + }); + + this.registerHelper('concatNames', { + destroy: function () { + this.teardown(); + this._super.apply(this, arguments); + }, + teardown: function () { + this.removeObserver('value.firstName'); + this.removeObserver('value.lastName'); + }, + compute: function (_ref7) { + var value = _ref7[0]; + + if (this.get('value')) { + this.teardown(); + } + this.set('value', value); + this.addObserver('value.firstName', this, this.recompute); + this.addObserver('value.lastName', this, this.recompute); + return (value ? _emberMetal.get(value, 'firstName') : '') + (value ? _emberMetal.get(value, 'lastName') : ''); + } + }); + + this.render('{{capitalizeName person}} {{unbound (capitalizeName person)}} {{concatNames person}} {{unbound (concatNames person)}}', { + person: { + firstName: 'shooby', + lastName: 'taylor' + } + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'person.firstName', 'sally'); + }); + + this.assertText('SALLY SHOOBY sallytaylor shoobytaylor'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'person', { + firstName: 'shooby', + lastName: 'taylor' + }); + }); + + this.assertText('SHOOBY SHOOBY shoobytaylor shoobytaylor'); + }; + + _class.prototype['@test should be able to render bound form of a helper inside unbound form of same helper'] = function testShouldBeAbleToRenderBoundFormOfAHelperInsideUnboundFormOfSameHelper() { + var _this16 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3), { + model: { + foo: true, + notfoo: false, + bar: true + } + }); + + this.assertText('truetrue'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('truetrue'); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'model.bar', false); + }); + + this.assertText('falsefalse'); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'model', { + foo: true, + notfoo: false, + bar: true + }); + }); + + this.assertText('truetrue'); + }; + + _class.prototype['@test yielding unbound does not update'] = function testYieldingUnboundDoesNotUpdate() { + var _this17 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + fooBarInstance = this; + }, + model: { foo: 'bork' } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (unbound model.foo)}}' + }); + + this.render('{{#foo-bar as |value|}}{{value}}{{/foo-bar}}'); + + this.assertText('bork'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model.foo', 'oof'); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model', { foo: 'bork' }); + }); + + this.assertText('bork'); + }; + + _class.prototype['@test yielding unbound hash does not update'] = function testYieldingUnboundHashDoesNotUpdate() { + var _this18 = this; + + var fooBarInstance = undefined; + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + fooBarInstance = this; + }, + model: { foo: 'bork' } + }); + + this.registerComponent('foo-bar', { + ComponentClass: FooBarComponent, + template: '{{yield (unbound (hash foo=model.foo))}}' + }); + + this.render('{{#foo-bar as |value|}}{{value.foo}}{{/foo-bar}}'); + + this.assertText('bork'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model.foo', 'oof'); + }); + + this.assertText('bork'); + + this.runTask(function () { + return _emberMetal.set(fooBarInstance, 'model', { foo: 'bork' }); + }); + + this.assertText('bork'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/unbound-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/unbound-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/unbound-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/helpers/yield-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Helpers test: {{yield}} helper', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test can yield to block'] = function testCanYieldToBlock() { + var _this = this; + + this.registerComponent('yield-comp', { template: '[In layout:] {{yield}}' }); + + this.render('{{#yield-comp}}[In Block:] {{object.title}}{{/yield-comp}}', { object: { title: 'Seattle' } }); + this.assertText('[In layout:] [In Block:] Seattle'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'object.title', 'Vancouver'); + }); + this.assertText('[In layout:] [In Block:] Vancouver'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'object', { title: 'Seattle' }); + }); + this.assertText('[In layout:] [In Block:] Seattle'); + }; + + _class.prototype['@test templates should yield to block inside a nested component'] = function testTemplatesShouldYieldToBlockInsideANestedComponent() { + var _this2 = this; + + this.registerComponent('outer-comp', { template: '
    [In layout:] {{yield}}
    ' }); + this.registerComponent('inner-comp', { template: '{{#outer-comp}}[In Block:] {{object.title}}{{/outer-comp}}' }); + + this.render('{{inner-comp object=object}}', { object: { title: 'Seattle' } }); + this.assertText('[In layout:] [In Block:] Seattle'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'object.title', 'Vancouver'); + }); + this.assertText('[In layout:] [In Block:] Vancouver'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'object', { title: 'Seattle' }); + }); + this.assertText('[In layout:] [In Block:] Seattle'); + }; + + _class.prototype['@test templates should yield to block, when the yield is embedded in a each helper'] = function testTemplatesShouldYieldToBlockWhenTheYieldIsEmbeddedInAEachHelper() { + var _this3 = this; + + var list = [1, 2, 3]; + + this.registerComponent('outer-comp', { template: '{{#each list as |item|}}{{yield}}{{/each}}' }); + + this.render('{{#outer-comp list=list}}Hello{{/outer-comp}}', { list: list }); + this.assertText('HelloHelloHello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'list', [4, 5]); + }); + this.assertText('HelloHello'); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'list', list); + }); + this.assertText('HelloHelloHello'); + }; + + _class.prototype['@test templates should yield to block, when the yield is embedded in a if helper'] = function testTemplatesShouldYieldToBlockWhenTheYieldIsEmbeddedInAIfHelper() { + var _this4 = this; + + this.registerComponent('outer-comp', { template: '{{#if boolean}}{{yield}}{{/if}}' }); + + this.render('{{#outer-comp boolean=boolean}}Hello{{/outer-comp}}', { boolean: true }); + this.assertText('Hello'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'boolean', false); + }); + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'boolean', true); + }); + this.assertText('Hello'); + }; + + _class.prototype['@test simple curlies inside of a yielded clock should work when the yield is nested inside of another view'] = function testSimpleCurliesInsideOfAYieldedClockShouldWorkWhenTheYieldIsNestedInsideOfAnotherView() { + var _this5 = this; + + this.registerComponent('kiwi-comp', { template: '{{#if falsy}}{{else}}{{yield}}{{/if}}' }); + + this.render('{{#kiwi-comp}}{{text}}{{/kiwi-comp}}', { text: 'ohai' }); + this.assertText('ohai'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'text', 'portland'); + }); + this.assertText('portland'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'text', 'ohai'); + }); + this.assertText('ohai'); + }; + + _class.prototype['@test nested simple curlies inside of a yielded block should work when the yield is nested inside of another view'] = function testNestedSimpleCurliesInsideOfAYieldedBlockShouldWorkWhenTheYieldIsNestedInsideOfAnotherView() { + var _this6 = this; + + this.registerComponent('parent-comp', { template: '{{#if falsy}}{{else}}{{yield}}{{/if}}' }); + this.registerComponent('child-comp', { template: '{{#if falsy}}{{else}}{{text}}{{/if}}' }); + + this.render('{{#parent-comp}}{{child-comp text=text}}{{/parent-comp}}', { text: 'ohai' }); + this.assertText('ohai'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'text', 'portland'); + }); + this.assertText('portland'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'text', 'ohai'); + }); + this.assertText('ohai'); + }; + + _class.prototype['@test yielding to a non-existent block is not an error'] = function testYieldingToANonExistentBlockIsNotAnError() { + var _this7 = this; + + this.registerComponent('yielding-comp', { template: 'Hello:{{yield}}' }); + this.registerComponent('outer-comp', { template: '{{yielding-comp}} {{title}}' }); + + this.render('{{outer-comp title=title}}', { title: 'Mr. Selden' }); + + this.assertText('Hello: Mr. Selden'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'title', 'Mr. Chag'); + }); + this.assertText('Hello: Mr. Chag'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'title', 'Mr. Selden'); + }); + this.assertText('Hello: Mr. Selden'); + }; + + _class.prototype['@test yield uses the original context'] = function testYieldUsesTheOriginalContext() { + var _this8 = this; + + var KiwiCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ boundText: 'Inner' }); + + this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, template: '

    {{boundText}}

    {{yield}}

    ' }); + + this.render('{{#kiwi-comp}}{{boundText}}{{/kiwi-comp}}', { boundText: 'Original' }); + this.assertText('InnerOriginal'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'boundText', 'Otherworld'); + }); + this.assertText('InnerOtherworld'); + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'boundText', 'Original'); + }); + this.assertText('InnerOriginal'); + }; + + _class.prototype['@test outer block param doesn\'t mask inner component property'] = function testOuterBlockParamDoesnTMaskInnerComponentProperty() { + var _this9 = this; + + var KiwiCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ boundText: 'Inner' }); + + this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, template: '

    {{boundText}}

    {{yield}}

    ' }); + + this.render('{{#with boundText as |item|}}{{#kiwi-comp}}{{item}}{{/kiwi-comp}}{{/with}}', { boundText: 'Outer' }); + this.assertText('InnerOuter'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'boundText', 'Otherworld'); + }); + this.assertText('InnerOtherworld'); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'boundText', 'Outer'); + }); + this.assertText('InnerOuter'); + }; + + _class.prototype['@test inner block param doesn\'t mask yield property'] = function testInnerBlockParamDoesnTMaskYieldProperty() { + var _this10 = this; + + var KiwiCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ boundText: 'Inner' }); + + this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, template: '{{#with boundText as |item|}}

    {{item}}

    {{yield}}

    {{/with}}' }); + + this.render('{{#kiwi-comp}}{{item}}{{/kiwi-comp}}', { item: 'Outer' }); + this.assertText('InnerOuter'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'item', 'Otherworld'); + }); + this.assertText('InnerOtherworld'); + + this.runTask(function () { + return _emberMetal.set(_this10.context, 'item', 'Outer'); + }); + this.assertText('InnerOuter'); + }; + + _class.prototype['@test can bind a block param to a component and use it in yield'] = function testCanBindABlockParamToAComponentAndUseItInYield() { + var _this11 = this; + + this.registerComponent('kiwi-comp', { template: '

    {{content}}

    {{yield}}

    ' }); + + this.render('{{#with boundText as |item|}}{{#kiwi-comp content=item}}{{item}}{{/kiwi-comp}}{{/with}}', { boundText: 'Outer' }); + this.assertText('OuterOuter'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'boundText', 'Update'); + }); + this.assertText('UpdateUpdate'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'boundText', 'Outer'); + }); + this.assertText('OuterOuter'); + }; + + // INUR not need with no data update + + _class.prototype['@test yield should not introduce a view'] = function testYieldShouldNotIntroduceAView() { + var ParentCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ isParentComponent: true }); + + var ChildCompComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + didReceiveAttrs: function () { + this._super(); + var parentView = this.get('parentView'); + + ok(parentView.get('isParentComponent')); + } + }); + + this.registerComponent('parent-comp', { ComponentClass: ParentCompComponent, template: '{{yield}}' }); + this.registerComponent('child-comp', { ComponentClass: ChildCompComponent }); + + this.render('{{#parent-comp}}{{child-comp}}{{/parent-comp}}'); + }; + + _class.prototype['@test yield with nested components (#3220)'] = function testYieldWithNestedComponents3220() { + var _this12 = this; + + this.registerComponent('inner-component', { template: '{{yield}}' }); + this.registerComponent('outer-component', { template: '{{#inner-component}}{{yield}}{{/inner-component}}' }); + + this.render('{{#outer-component}}Hello {{boundText}}{{/outer-component}}', { boundText: 'world' }); + this.assertText('Hello world'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'boundText', 'update'); + }); + this.assertText('Hello update'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'boundText', 'world'); + }); + this.assertText('Hello world'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/helpers/yield-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/yield-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/helpers/yield-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/input-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Input element tests', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype.runAttributeTest = function runAttributeTest(attributeName, values) { + var _this = this; + + var template = ''; + this.render(template, { value: values[0] }); + this.assertAttributeHasValue(attributeName, values[0], attributeName + ' is set on initial render'); + + this.runTask(function () { + return _this.rerender(); + }); + this.assertAttributeHasValue(attributeName, values[0], attributeName + ' is set on noop rerender'); + + this.setComponentValue(values[1]); + this.assertAttributeHasValue(attributeName, values[1], attributeName + ' is set on rerender'); + + this.setComponentValue(values[0]); + this.assertAttributeHasValue(attributeName, values[0], attributeName + ' can be set back to the initial value'); + }; + + _class.prototype.runPropertyTest = function runPropertyTest(propertyName, values) { + var _this2 = this; + + var attributeName = propertyName; + var template = ''; + this.render(template, { value: values[0] }); + this.assertPropertyHasValue(propertyName, values[0], propertyName + ' is set on initial render'); + + this.runTask(function () { + return _this2.rerender(); + }); + this.assertPropertyHasValue(propertyName, values[0], propertyName + ' is set on noop rerender'); + + this.setComponentValue(values[1]); + this.assertPropertyHasValue(propertyName, values[1], propertyName + ' is set on rerender'); + + this.setComponentValue(values[0]); + this.assertPropertyHasValue(propertyName, values[0], propertyName + ' can be set back to the initial value'); + }; + + _class.prototype.runFalsyValueProperty = function runFalsyValueProperty(values) { + var _this3 = this; + + var value = 'value'; + var template = ''; + this.render(template, { value: values[0] }); + this.assertPropertyHasValue(value, '', value + ' is set on initial render'); + + this.runTask(function () { + return _this3.rerender(); + }); + this.assertPropertyHasValue(value, '', value + ' is set on noop rerender'); + this.setComponentValue(values[1]); + + this.assertPropertyHasValue(value, values[1], value + ' is set on rerender'); + + this.setComponentValue(values[0]); + this.assertPropertyHasValue(value, '', value + ' can be set back to the initial value'); + }; + + _class.prototype['@test input disabled attribute'] = function testInputDisabledAttribute() { + var _this4 = this; + + var model = { model: { value: false } }; + + this.render('', model); + + this.assert.equal(this.$inputElement().prop('disabled'), false); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), false); + + this.runTask(function () { + return _this4.context.set('model.value', true); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), true); + this.assertHTML(''); // Note the DOM output is + + this.runTask(function () { + return _this4.context.set('model.value', 'wat'); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), true); + this.assertHTML(''); // Note the DOM output is + + this.runTask(function () { + return _this4.context.set('model', { value: false }); + }); + + this.assert.equal(this.$inputElement().prop('disabled'), false); + this.assertHTML(''); + }; + + _class.prototype['@test input value attribute'] = function testInputValueAttribute() { + this.runPropertyTest('value', ['foo', 'bar']); + }; + + _class.prototype['@test input placeholder attribute'] = function testInputPlaceholderAttribute() { + this.runAttributeTest('placeholder', ['foo', 'bar']); + }; + + _class.prototype['@test input name attribute'] = function testInputNameAttribute() { + this.runAttributeTest('name', ['nam', 'name']); + }; + + _class.prototype['@test input maxlength attribute'] = function testInputMaxlengthAttribute() { + this.runAttributeTest('maxlength', [2, 3]); + }; + + _class.prototype['@test input size attribute'] = function testInputSizeAttribute() { + this.runAttributeTest('size', [2, 3]); + }; + + _class.prototype['@test input tabindex attribute'] = function testInputTabindexAttribute() { + this.runAttributeTest('tabindex', [2, 3]); + }; + + _class.prototype['@test null input value'] = function testNullInputValue() { + this.runFalsyValueProperty([null, 'hello']); + }; + + _class.prototype['@test undefined input value'] = function testUndefinedInputValue() { + this.runFalsyValueProperty([undefined, 'hello']); + }; + + _class.prototype['@test undefined `toString` method as input value'] = function testUndefinedToStringMethodAsInputValue() { + this.runFalsyValueProperty([Object.create(null), 'hello']); + }; + + _class.prototype['@test cursor position is not lost when updating content'] = function testCursorPositionIsNotLostWhenUpdatingContent() { + var template = ''; + this.render(template, { value: 'hola' }); + + this.setDOMValue('hello'); + this.setSelectionRange(1, 3); + + this.setComponentValue('hello'); + + this.assertSelectionRange(1, 3); + + // Note: We should eventually get around to testing reseting, however + // browsers handle `selectionStart` and `selectionEnd` differently + // when are synthetically testing movement of the cursor. + }; + + _class.prototype['@test input can be updated multiple times'] = function testInputCanBeUpdatedMultipleTimes() { + var template = ''; + this.render(template, { value: 'hola' }); + + this.assertValue('hola', 'Value is initialised'); + + this.setComponentValue(''); + this.assertValue('', 'Value is set in the DOM'); + + this.setDOMValue('hola'); + this.setComponentValue('hola'); + this.assertValue('hola', 'Value is updated the first time'); + + this.setComponentValue(''); + this.assertValue('', 'Value is updated the second time'); + }; + + _class.prototype['@test DOM is SSOT if value is set'] = function testDOMIsSSOTIfValueIsSet() { + var template = ''; + this.render(template, { value: 'hola' }); + + this.assertValue('hola', 'Value is initialised'); + + this.setComponentValue('hello'); + + this.assertValue('hello', 'Value is initialised'); + + this.setDOMValue('hola'); + + this.assertValue('hola', 'DOM is used'); + + this.setComponentValue('bye'); + + this.assertValue('bye', 'Value is used'); + + // Simulates setting the input to the same value as it already is which won't cause a rerender + + this.setDOMValue('hola'); + + this.assertValue('hola', 'DOM is used'); + + this.setComponentValue('hola'); + + this.assertValue('hola', 'Value is used'); + }; + + // private helpers and assertions + + _class.prototype.setDOMValue = function setDOMValue(value) { + this.inputElement().value = value; + }; + + _class.prototype.setComponentValue = function setComponentValue(value) { + var _this5 = this; + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'value', value); + }); + }; + + _class.prototype.setSelectionRange = function setSelectionRange(start, end) { + this.inputElement().selectionStart = start; + this.inputElement().selectionEnd = end; + }; + + _class.prototype.inputElement = function inputElement() { + return this.$inputElement()[0]; + }; + + _class.prototype.$inputElement = function $inputElement() { + return this.$('input'); + }; + + _class.prototype.assertValue = function assertValue(value, message) { + this.assertPropertyHasValue('value', value, message); + }; + + _class.prototype.assertAttributeHasValue = function assertAttributeHasValue(attribute, value, message) { + this.assert.equal(this.$inputElement().attr(attribute), value, attribute + ' ' + message); + }; + + _class.prototype.assertPropertyHasValue = function assertPropertyHasValue(property, value, message) { + this.assert.equal(this.$inputElement().prop(property), value, property + ' ' + message); + }; + + _class.prototype.assertSelectionRange = function assertSelectionRange(start, end) { + this.assert.equal(this.inputElement().selectionStart, start); + this.assert.equal(this.inputElement().selectionEnd, end); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/input-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/input-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/input-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/mount-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-metal', 'ember-application'], function (exports, _emberUtils, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberMetal, _emberApplication) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{mount}} assertions', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test it asserts that only a single param is passed'] = function testItAssertsThatOnlyASingleParamIsPassed() { + var _this = this; + + expectAssertion(function () { + _this.render('{{mount "chat" "foo"}}'); + }, /You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}./i); + }; + + _class.prototype['@test it asserts that the engine name argument is quoted'] = function testItAssertsThatTheEngineNameArgumentIsQuoted() { + var _this2 = this; + + expectAssertion(function () { + _this2.render('{{mount chat}}'); + }, /The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}./i); + }; + + _class.prototype['@test it asserts that the specified engine is registered'] = function testItAssertsThatTheSpecifiedEngineIsRegistered() { + var _this3 = this; + + expectAssertion(function () { + _this3.render('{{mount "chat"}}'); + }, /You used `{{mount 'chat'}}`, but the engine 'chat' can not be found./i); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{mount}} test', (function (_ApplicationTest) { + babelHelpers.inherits(_class2, _ApplicationTest); + + function _class2() { + _ApplicationTest.call(this); + + var engineRegistrations = this.engineRegistrations = {}; + + this.registerEngine('chat', _emberApplication.Engine.extend({ + router: null, + + init: function () { + var _this4 = this; + + this._super.apply(this, arguments); + + Object.keys(engineRegistrations).forEach(function (fullName) { + _this4.register(fullName, engineRegistrations[fullName]); + }); + } + })); + + this.registerTemplate('index', '{{mount "chat"}}'); + } + + _class2.prototype['@test it boots an engine, instantiates its application controller, and renders its application template'] = function testItBootsAnEngineInstantiatesItsApplicationControllerAndRendersItsApplicationTemplate(assert) { + var _this5 = this; + + this.engineRegistrations['template:application'] = _emberGlimmerTestsUtilsHelpers.compile('

    Chat here, {{username}}

    ', { moduleName: 'application' }); + + var controller = undefined; + + this.engineRegistrations['controller:application'] = _emberRuntime.Controller.extend({ + username: 'dgeb', + + init: function () { + this._super(); + controller = this; + } + }); + + return this.visit('/').then(function () { + assert.ok(controller, 'engine\'s application controller has been instantiated'); + + var engineInstance = _emberUtils.getOwner(controller); + assert.strictEqual(_emberApplication.getEngineParent(engineInstance), _this5.applicationInstance, 'engine instance has the application instance as its parent'); + + _this5.assertComponentElement(_this5.firstChild, { content: '

    Chat here, dgeb

    ' }); + + _this5.runTask(function () { + return _emberMetal.set(controller, 'username', 'chancancode'); + }); + + _this5.assertComponentElement(_this5.firstChild, { content: '

    Chat here, chancancode

    ' }); + + _this5.runTask(function () { + return _emberMetal.set(controller, 'username', 'dgeb'); + }); + + _this5.assertComponentElement(_this5.firstChild, { content: '

    Chat here, dgeb

    ' }); + }); + }; + + _class2.prototype['@test it emits a useful backtracking re-render assertion message'] = function testItEmitsAUsefulBacktrackingReRenderAssertionMessage(assert) { + var _this6 = this; + + this.router.map(function () { + this.route('route-with-mount'); + }); + + this.registerTemplate('index', ''); + this.registerTemplate('route-with-mount', '{{mount "chat"}}'); + + this.engineRegistrations['template:application'] = _emberGlimmerTestsUtilsHelpers.compile('hi {{person.name}} [{{component-with-backtracking-set person=person}}]', { moduleName: 'application' }); + this.engineRegistrations['controller:application'] = _emberRuntime.Controller.extend({ + person: { name: 'Alex' } + }); + + this.engineRegistrations['template:components/component-with-backtracking-set'] = _emberGlimmerTestsUtilsHelpers.compile('[component {{person.name}}]', { moduleName: 'components/component-with-backtracking-set' }); + this.engineRegistrations['component:component-with-backtracking-set'] = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.set('person.name', 'Ben'); + } + }); + + var expectedBacktrackingMessage = /modified "person\.name" twice on \[object Object\] in a single render\. It was rendered in "template:route-with-mount" \(in "engine:chat"\) and modified in "component:component-with-backtracking-set" \(in "engine:chat"\)/; + + if (false) { + expectDeprecation(expectedBacktrackingMessage); + return this.visit('/route-with-mount'); + } else { + return this.visit('/').then(function () { + expectAssertion(function () { + _this6.visit('/route-with-mount'); + }, expectedBacktrackingMessage); + }); + } + }; + + return _class2; + })(_emberGlimmerTestsUtilsTestCase.ApplicationTest)); +}); +enifed('ember-glimmer/tests/integration/mount-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/mount-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/mount-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/outlet-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'internal-test-helpers', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _internalTestHelpers, _emberMetal) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('outlet view', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + + var CoreOutlet = undefined; + if (true) { + CoreOutlet = this.owner.factoryFor('view:-outlet'); + } else { + CoreOutlet = this.owner._lookupFactory('view:-outlet'); + } + + this.component = CoreOutlet.create(); + } + + _class.prototype['@test should not error when initial rendered template is undefined'] = function testShouldNotErrorWhenInitialRenderedTemplateIsUndefined() { + var _this = this; + + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: undefined, + ViewClass: undefined, + template: undefined + }, + + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText(''); + }; + + _class.prototype['@test should render the outlet when set after DOM insertion'] = function testShouldRenderTheOutletWhenSetAfterDOMInsertion() { + var _this2 = this; + + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: undefined, + ViewClass: undefined, + template: undefined + }, + + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this2.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText(''); + + this.registerTemplate('application', 'HI{{outlet}}'); + outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this2.component.setOutletState(outletState); + }); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('index', '

    BYE

    '); + outletState.outlets.main = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'index', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:index') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this2.component.setOutletState(outletState); + }); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test should render the outlet when set before DOM insertion'] = function testShouldRenderTheOutletWhenSetBeforeDOMInsertion() { + var _this3 = this; + + this.registerTemplate('application', 'HI{{outlet}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this3.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('index', '

    BYE

    '); + outletState.outlets.main = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'index', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:index') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this3.component.setOutletState(outletState); + }); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test should support an optional name'] = function testShouldSupportAnOptionalName() { + var _this4 = this; + + this.registerTemplate('application', '

    HI

    {{outlet "special"}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this4.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('special', '

    BYE

    '); + outletState.outlets.special = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'special', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:special') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this4.component.setOutletState(outletState); + }); + + this.assertText('HIBYE'); + }; + + _class.prototype['@test does not default outlet name when positional argument is present'] = function testDoesNotDefaultOutletNameWhenPositionalArgumentIsPresent() { + var _this5 = this; + + this.registerTemplate('application', '

    HI

    {{outlet someUndefinedThing}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this5.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('special', '

    BYE

    '); + outletState.outlets.main = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'special', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:special') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this5.component.setOutletState(outletState); + }); + + this.assertText('HI'); + }; + + _class.prototype['@test should support bound outlet name'] = function testShouldSupportBoundOutletName() { + var _this6 = this; + + var controller = { outletName: 'foo' }; + this.registerTemplate('application', '

    HI

    {{outlet outletName}}'); + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'application', + controller: controller, + ViewClass: undefined, + template: this.owner.lookup('template:application') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this6.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('HI'); + + this.assertStableRerender(); + + this.registerTemplate('foo', '

    FOO

    '); + outletState.outlets.foo = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'foo', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:foo') + }, + outlets: Object.create(null) + }; + + this.registerTemplate('bar', '

    BAR

    '); + outletState.outlets.bar = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'bar', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:bar') + }, + outlets: Object.create(null) + }; + + this.runTask(function () { + return _this6.component.setOutletState(outletState); + }); + + this.assertText('HIFOO'); + + this.runTask(function () { + return _emberMetal.set(controller, 'outletName', 'bar'); + }); + + this.assertText('HIBAR'); + }; + + _class.prototype['@test outletState can pass through user code (liquid-fire initimate API) '] = function testOutletStateCanPassThroughUserCodeLiquidFireInitimateAPI() { + var _this7 = this; + + this.registerTemplate('outer', 'A{{#-with-dynamic-vars outletState=(identity (-get-dynamic-var "outletState"))}}B{{outlet}}D{{/-with-dynamic-vars}}E'); + this.registerTemplate('inner', 'C'); + + // This looks like it doesn't do anything, but its presence + // guarantees that the outletState gets converted from a reference + // to a value and then back to a reference. That is what we're + // testing here. + this.registerHelper('identity', function (_ref) { + var a = _ref[0]; + return a; + }); + + var outletState = { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'outer', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:outer') + }, + outlets: { + main: { + render: { + owner: this.owner, + into: undefined, + outlet: 'main', + name: 'inner', + controller: {}, + ViewClass: undefined, + template: this.owner.lookup('template:inner') + }, + outlets: Object.create(null) + } + } + }; + + this.runTask(function () { + return _this7.component.setOutletState(outletState); + }); + + _internalTestHelpers.runAppend(this.component); + + this.assertText('ABCDE'); + + this.assertStableRerender(); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/outlet-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/outlet-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/outlet-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/refinements-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with var as |foo|}}\n {{foo}}\n {{/with}}\n\n ---\n\n {{#with var as |render|}}\n {{render}}\n {{/with}}\n\n ---\n\n {{#with var as |outlet|}}\n {{outlet}}\n {{/with}}\n\n ---\n\n {{#with var as |mount|}}\n {{mount}}\n {{/with}}\n\n ---\n\n {{#with var as |component|}}\n {{component}}\n {{/with}}\n\n ---\n\n {{#with var as |input|}}\n {{input}}\n {{/with}}\n\n ---\n\n {{#with var as |-with-dynamic-vars|}}\n {{-with-dynamic-vars}}\n {{/with}}\n\n ---\n\n {{#with var as |-in-element|}}\n {{-in-element}}\n {{/with}}'], ['\n {{#with var as |foo|}}\n {{foo}}\n {{/with}}\n\n ---\n\n {{#with var as |render|}}\n {{render}}\n {{/with}}\n\n ---\n\n {{#with var as |outlet|}}\n {{outlet}}\n {{/with}}\n\n ---\n\n {{#with var as |mount|}}\n {{mount}}\n {{/with}}\n\n ---\n\n {{#with var as |component|}}\n {{component}}\n {{/with}}\n\n ---\n\n {{#with var as |input|}}\n {{input}}\n {{/with}}\n\n ---\n\n {{#with var as |-with-dynamic-vars|}}\n {{-with-dynamic-vars}}\n {{/with}}\n\n ---\n\n {{#with var as |-in-element|}}\n {{-in-element}}\n {{/with}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('syntax refinements', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test block params should not be refined'] = function testBlockParamsShouldNotBeRefined() { + var _this = this; + + this.registerHelper('foo', function () { + return 'bar helper'; + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { var: 'var' }); + + this.assertText('var---var---var---var---var---var---var---var'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'var', 'RARRR!!!'); + }); + + this.assertText('RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!---RARRR!!!'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'var', 'var'); + }); + + this.assertText('var---var---var---var---var---var---var---var'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/refinements-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/refinements-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/refinements-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/svg-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n \n
    \n '], ['\n
    \n \n
    \n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n \n
    \n '], ['\n
    \n \n
    \n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n \n
    \n '], ['\n
    \n \n
    \n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n \n
    \n '], ['\n
    \n \n
    \n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n
    \n \n
    \n '], ['\n
    \n \n
    \n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('SVG element tests', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test unquoted viewBox property is output'] = function testUnquotedViewBoxPropertyIsOutput(assert) { + var _this = this; + + var viewBoxString = '0 0 100 100'; + + this.render('
    ', { + model: { + viewBoxString: viewBoxString + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model.viewBoxString', null); + }); + + assert.equal(this.firstChild.getAttribute('svg'), null); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'model', { viewBoxString: viewBoxString }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + }; + + _class.prototype['@test quoted viewBox property is output'] = function testQuotedViewBoxPropertyIsOutput(assert) { + var _this2 = this; + + var viewBoxString = '0 0 100 100'; + + this.render('
    ', { + model: { + viewBoxString: viewBoxString + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model.viewBoxString', null); + }); + + assert.equal(this.firstChild.getAttribute('svg'), null); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'model', { viewBoxString: viewBoxString }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject, viewBoxString)); + }; + + _class.prototype['@test quoted viewBox property is concat'] = function testQuotedViewBoxPropertyIsConcat() { + var _this3 = this; + + var viewBoxString = '100 100'; + + this.render('
    ', { + model: { + viewBoxString: viewBoxString + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, viewBoxString)); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, viewBoxString)); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model.viewBoxString', '200 200'); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'model', { viewBoxString: viewBoxString }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2, viewBoxString)); + }; + + _class.prototype['@test class is output'] = function testClassIsOutput() { + var _this4 = this; + + this.render('
    ', { + model: { + color: 'blue' + } + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model.color', 'yellow'); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5)); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'model', { color: 'blue' }); + }); + + this.assertInnerHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4)); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/svg-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/svg-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/svg-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/each-in-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-runtime', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberRuntime, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n {{#each-in categories as |category count|}}\n
    • {{category}}: {{count}}
    • \n {{/each-in}}\n
    \n '], ['\n
      \n {{#each-in categories as |category count|}}\n
    • {{category}}: {{count}}
    • \n {{/each-in}}\n
    \n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Smartphones: 8203
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    \n '], ['\n
      \n
    • Smartphones: 8203
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    \n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Smartphones: 100
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    • Tweets: 443115
    • \n
    \n '], ['\n
      \n
    • Smartphones: 100
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    • Tweets: 443115
    • \n
    \n ']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n {{#each-in categories as |category data|}}\n
    • {{category}}: {{data.reports.unitsSold}}
    • \n {{/each-in}}\n
    \n '], ['\n
      \n {{#each-in categories as |category data|}}\n
    • {{category}}: {{data.reports.unitsSold}}
    • \n {{/each-in}}\n
    \n ']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n {{#each-in categories key=\'@identity\' as |category count|}}\n
    • {{category}}: {{count}}
    • \n {{/each-in}}\n
    \n '], ['\n
      \n {{#each-in categories key=\'@identity\' as |category count|}}\n
    • {{category}}: {{count}}
    • \n {{/each-in}}\n
    \n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Smartphones: 8203
    • \n
    • Tablets: 8203
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    • Bugs: Infinity
    • \n
    \n '], ['\n
      \n
    • Smartphones: 8203
    • \n
    • Tablets: 8203
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    • Bugs: Infinity
    • \n
    \n ']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Smartphones: 100
    • \n
    • Tablets: 8203
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    • Bugs: Infinity
    • \n
    • Tweets: 443115
    • \n
    \n '], ['\n
      \n
    • Smartphones: 100
    • \n
    • Tablets: 8203
    • \n
    • JavaScript Frameworks: Infinity
    • \n
    • Bugs: Infinity
    • \n
    • Tweets: 443115
    • \n
    \n ']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n {{#each-in (get collection type) as |category count|}}\n
    • {{category}}: {{count}}
    • \n {{/each-in}}\n
    \n '], ['\n
      \n {{#each-in (get collection type) as |category count|}}\n
    • {{category}}: {{count}}
    • \n {{/each-in}}\n
    \n ']), + _templateObject9 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Emberinios: 533462
    • \n
    • Tweets: 7323
    • \n
    \n '], ['\n
      \n
    • Emberinios: 533462
    • \n
    • Tweets: 7323
    • \n
    \n ']), + _templateObject10 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Televisions: 183
    • \n
    • Alarm Clocks: 999
    • \n
    \n '], ['\n
      \n
    • Televisions: 183
    • \n
    • Alarm Clocks: 999
    • \n
    \n ']), + _templateObject11 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Televisions: 183
    • \n
    • Alarm Clocks: 999
    • \n
    • Tweets: 443115
    • \n
    \n '], ['\n
      \n
    • Televisions: 183
    • \n
    • Alarm Clocks: 999
    • \n
    • Tweets: 443115
    • \n
    \n ']), + _templateObject12 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Emberinios: 123456
    • \n
    \n '], ['\n
      \n
    • Emberinios: 123456
    • \n
    \n ']), + _templateObject13 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each-in foo.bar.baz as |thing|}}\n {{thing}}\n {{/each-in}}'], ['\n {{#each-in foo.bar.baz as |thing|}}\n {{thing}}\n {{/each-in}}']), + _templateObject14 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each-in arr as |key value|}}\n [{{key}}:{{value}}]\n {{/each-in}}'], ['\n {{#each-in arr as |key value|}}\n [{{key}}:{{value}}]\n {{/each-in}}']), + _templateObject15 = babelHelpers.taggedTemplateLiteralLoose(['\n
      \n
    • Smartphones: 100
    • \n
    • Tablets: 20
    • \n
    \n '], ['\n
      \n
    • Smartphones: 100
    • \n
    • Tablets: 20
    • \n
    \n ']); + + var EachInTest = (function (_TogglingSyntaxConditionalsTest) { +babelHelpers.inherits(EachInTest, _TogglingSyntaxConditionalsTest); + + function EachInTest() { + _TogglingSyntaxConditionalsTest.apply(this, arguments); + } + + EachInTest.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#each-in ' + cond + ' as |key|}}' + truthy + '{{else}}' + falsy + '{{/each-in}}'; + }; + + return EachInTest; + })(_emberGlimmerTestsUtilsSharedConditionalTests.TogglingSyntaxConditionalsTest); + + function EmptyFunction() {} + + function NonEmptyFunction() {} + NonEmptyFunction.foo = 'bar'; + + var EmptyConstructor = function EmptyConstructor() {}; + + var NonEmptyConstructor = function NonEmptyConstructor() {}; + + NonEmptyConstructor.foo = 'bar'; + + var BasicEachInTest = (function (_EachInTest) { +babelHelpers.inherits(BasicEachInTest, _EachInTest); + + function BasicEachInTest() { + _EachInTest.apply(this, arguments); + } + + return BasicEachInTest; + })(EachInTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(BasicEachInTest, new _emberGlimmerTestsUtilsSharedConditionalTests.TruthyGenerator([{ foo: 1 }, _emberRuntime.Object.create({ 'Not Empty': 1 }), [1], NonEmptyFunction, NonEmptyConstructor]), new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([null, undefined, false, '', 0, [], EmptyFunction, EmptyConstructor, {}, Object.create(null), Object.create({}), Object.create({ 'Not Empty': 1 }), _emberRuntime.Object.create()])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each-in}}', (function (_BasicEachInTest) { +babelHelpers.inherits(_class, _BasicEachInTest); + + function _class() { + _BasicEachInTest.apply(this, arguments); + } + + _class.prototype['@test it repeats the given block for each item in the hash'] = function testItRepeatsTheGivenBlockForEachItemInTheHash() { + var _this = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + categories: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this.context, 'categories.Smartphones', 100); + _emberMetal.set(_this.context, 'categories.Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'categories', { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test it can render sub-paths of each item'] = function testItCanRenderSubPathsOfEachItem() { + var _this2 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4), { + categories: { + 'Smartphones': { reports: { unitsSold: 8203 } }, + 'JavaScript Frameworks': { reports: { unitsSold: Infinity } } + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this2.context, 'categories.Smartphones.reports.unitsSold', 100); + _emberMetal.set(_this2.context, 'categories.Tweets', { reports: { unitsSold: 443115 } }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'categories', { + 'Smartphones': { reports: { unitsSold: 8203 } }, + 'JavaScript Frameworks': { reports: { unitsSold: Infinity } } + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test it can render duplicate items'] = function testItCanRenderDuplicateItems() { + var _this3 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5), { + categories: { + 'Smartphones': 8203, + 'Tablets': 8203, + 'JavaScript Frameworks': Infinity, + 'Bugs': Infinity + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'categories.Smartphones', 100); + _emberMetal.set(_this3.context, 'categories.Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7)); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'categories', { + 'Smartphones': 8203, + 'Tablets': 8203, + 'JavaScript Frameworks': Infinity, + 'Bugs': Infinity + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6)); + }; + + _class.prototype['@test it repeats the given block when the hash is dynamic'] = function testItRepeatsTheGivenBlockWhenTheHashIsDynamic() { + var _this4 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8), { + collection: { + categories: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }, + otherCategories: { + 'Emberinios': 533462, + 'Tweets': 7323 + } + }, + type: 'categories' + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'type', 'otherCategories'); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject9)); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'type', 'categories'); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test it only iterates over an object\'s own properties'] = function testItOnlyIteratesOverAnObjectSOwnProperties() { + var _this5 = this; + + var protoCategories = { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }; + + var categories = Object.create(protoCategories); + categories['Televisions'] = 183; + categories['Alarm Clocks'] = 999; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { categories: categories }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(protoCategories, 'Robots', 666); + _emberMetal.set(categories, 'Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject11)); + + categories = Object.create(protoCategories); + categories['Televisions'] = 183; + categories['Alarm Clocks'] = 999; + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'categories', categories); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject10)); + }; + + _class.prototype['@test it does not observe direct property mutations (not going through set) on the object'] = function testItDoesNotObserveDirectPropertyMutationsNotGoingThroughSetOnTheObject() { + var _this6 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + categories: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + } + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + var categories = _emberMetal.get(_this6.context, 'categories'); + delete categories.Smartphones; + }); + + this.assertInvariants(); + + this.runTask(function () { + var categories = _emberMetal.get(_this6.context, 'categories'); + categories['Emberinios'] = 123456; + }); + + this.assertInvariants(); + + this.runTask(function () { + _emberMetal.set(_this6.context, 'categories', { + Emberinios: 123456 + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject12)); + + this.runTask(function () { + _emberMetal.set(_this6.context, 'categories', { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + + _class.prototype['@test keying off of `undefined` does not render'] = function testKeyingOffOfUndefinedDoesNotRender(assert) { + var _this7 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject13), { foo: {} }); + + this.assertText(''); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', { bar: { baz: { 'Here!': 1 } } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'foo', {}); + }); + + this.assertText(''); + }; + + _class.prototype['@test it iterate over array with `in` instead of walking over elements'] = function testItIterateOverArrayWithInInsteadOfWalkingOverElements(assert) { + var _this8 = this; + + var arr = [1, 2, 3]; + arr.foo = 'bar'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14), { arr: arr }); + + this.assertText('[0:1][1:2][2:3][foo:bar]'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('[0:1][1:2][2:3][foo:bar]'); + + this.runTask(function () { + _emberMetal.set(arr, 'zomg', 'lol'); + }); + + this.assertText('[0:1][1:2][2:3][foo:bar][zomg:lol]'); + + arr = [1, 2, 3]; + arr.foo = 'bar'; + + this.runTask(function () { + return _emberMetal.set(_this8.context, 'arr', arr); + }); + + this.assertText('[0:1][1:2][2:3][foo:bar]'); + }; + + _class.prototype['@test it skips holes in sparse arrays'] = function testItSkipsHolesInSparseArrays(assert) { + var arr = []; + arr[5] = 'foo'; + arr[6] = 'bar'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject14), { arr: arr }); + + this.assertText('[5:foo][6:bar]'); + + this.assertStableRerender(); + }; + +babelHelpers.createClass(_class, [{ + key: 'truthyValue', + get: function () { + return { 'Not Empty': 1 }; + } + }, { + key: 'falsyValue', + get: function () { + return {}; + } + }]); + return _class; + })(BasicEachInTest)); + + var EachInEdgeCasesTest = (function (_EachInTest2) { +babelHelpers.inherits(EachInEdgeCasesTest, _EachInTest2); + + function EachInEdgeCasesTest() { + _EachInTest2.apply(this, arguments); + } + + return EachInEdgeCasesTest; + })(EachInTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(EachInEdgeCasesTest, new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([true, 1, 'hello'])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each-in}} edge cases', (function (_EachInEdgeCasesTest) { +babelHelpers.inherits(_class2, _EachInEdgeCasesTest); + + function _class2() { + _EachInEdgeCasesTest.apply(this, arguments); + } + +babelHelpers.createClass(_class2, [{ + key: 'truthyValue', + get: function () { + return { 'Not Empty': 1 }; + } + }, { + key: 'falsyValue', + get: function () { + return {}; + } + }]); + return _class2; + })(EachInEdgeCasesTest)); + + var EachInProxyTest = (function (_EachInTest3) { +babelHelpers.inherits(EachInProxyTest, _EachInTest3); + + function EachInProxyTest() { + _EachInTest3.apply(this, arguments); + } + + return EachInProxyTest; + })(EachInTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(EachInProxyTest, new _emberGlimmerTestsUtilsSharedConditionalTests.TruthyGenerator([_emberRuntime.ObjectProxy.create({ content: { 'Not empty': 1 } })]), new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([_emberRuntime.ObjectProxy.create(), _emberRuntime.ObjectProxy.create({ content: null }), _emberRuntime.ObjectProxy.create({ content: {} }), _emberRuntime.ObjectProxy.create({ content: Object.create(null) }), _emberRuntime.ObjectProxy.create({ content: Object.create({}) }), _emberRuntime.ObjectProxy.create({ content: Object.create({ 'Not Empty': 1 }) }), _emberRuntime.ObjectProxy.create({ content: _emberRuntime.Object.create() })])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each-in}} with `ObjectProxy`', (function (_EachInProxyTest) { +babelHelpers.inherits(_class3, _EachInProxyTest); + + function _class3() { + _EachInProxyTest.apply(this, arguments); + } + + _class3.prototype['@test it iterates over the content, not the proxy'] = function testItIteratesOverTheContentNotTheProxy() { + var _this9 = this; + + var content = { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + }; + + var proxy = _emberRuntime.ObjectProxy.create({ + content: content, + foo: 'bar' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { categories: proxy }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.set(proxy, 'content.Smartphones', 100); + _emberMetal.set(proxy, 'content.Tweets', 443115); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3)); + + this.runTask(function () { + _emberMetal.set(proxy, 'content', { + 'Smartphones': 100, + 'Tablets': 20 + }); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject15)); + + this.runTask(function () { + return _emberMetal.set(_this9.context, 'categories', _emberRuntime.ObjectProxy.create({ + content: { + 'Smartphones': 8203, + 'JavaScript Frameworks': Infinity + } + })); + }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + }; + +babelHelpers.createClass(_class3, [{ + key: 'truthyValue', + get: function () { + return _emberRuntime.ObjectProxy.create({ content: { 'Not Empty': 1 } }); + } + }, { + key: 'falsyValue', + get: function () { + return _emberRuntime.ObjectProxy.create({ content: null }); + } + }]); + return _class3; + })(EachInProxyTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/each-in-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/each-in-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/each-in-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/each-test', ['exports', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberRuntime, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each list as |item|}}\n
  • Prev
  • \n {{foo-bar item=item}}\n
  • Next
  • \n {{/each}}\n '], ['\n {{#each list as |item|}}\n
  • Prev
  • \n {{foo-bar item=item}}\n
  • Next
  • \n {{/each}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each content as |value|}}\n {{value}}-\n {{#each options as |option|}}\n {{option.value}}:{{option.label}}\n {{/each}}\n {{/each}}\n '], ['\n {{#each content as |value|}}\n {{value}}-\n {{#each options as |option|}}\n {{option.value}}:{{option.label}}\n {{/each}}\n {{/each}}\n ']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each foo.bar.baz as |thing|}}\n {{thing}}\n {{/each}}'], ['\n {{#each foo.bar.baz as |thing|}}\n {{thing}}\n {{/each}}']), + _templateObject4 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#each list as |value key|}}\n [{{key}}:{{value}}]\n {{/each}}'], ['\n {{#each list as |value key|}}\n [{{key}}:{{value}}]\n {{/each}}']), + _templateObject5 = babelHelpers.taggedTemplateLiteralLoose(['\n

    {{page.title}}

    \n\n
      \n {{#each model as |post|}}\n
    • {{post.title}}
    • \n {{/each}}\n
    \n '], ['\n

    {{page.title}}

    \n\n
      \n {{#each model as |post|}}\n
    • {{post.title}}
    • \n {{/each}}\n
    \n ']), + _templateObject6 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Blog Posts

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n '], ['\n

    Blog Posts

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n ']), + _templateObject7 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Essays

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n '], ['\n

    Essays

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n ']), + _templateObject8 = babelHelpers.taggedTemplateLiteralLoose(['\n

    Think Pieces™

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n '], ['\n

    Think Pieces™

    \n\n
      \n
    • Rails is omakase
    • \n
    • Ember is omakase
    • \n
    \n ']); + + var ArrayLike = (function () { + function ArrayLike(content) { + this._array = content; + } + + ArrayLike.prototype.forEach = function forEach(callback) { + this._array.forEach(callback); + }; + + // The following methods are APIs used by the tests + + ArrayLike.prototype.objectAt = function objectAt(idx) { + return this._array[idx]; + }; + + ArrayLike.prototype.clear = function clear() { + this._array.length = 0; + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.replace = function replace(idx, del, ins) { + var _array; + + (_array = this._array).splice.apply(_array, [idx, del].concat(ins)); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.unshiftObject = function unshiftObject(obj) { + this._array.unshift(obj); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.unshiftObjects = function unshiftObjects(arr) { + var _array2; + + (_array2 = this._array).unshift.apply(_array2, arr); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.pushObject = function pushObject(obj) { + this._array.push(obj); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.pushObjects = function pushObjects(arr) { + var _array3; + + (_array3 = this._array).push.apply(_array3, arr); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.shiftObject = function shiftObject() { + var obj = this._array.shift(); + this.arrayContentDidChange(); + return obj; + }; + + ArrayLike.prototype.popObject = function popObject() { + var obj = this._array.pop(); + this.arrayContentDidChange(); + return obj; + }; + + ArrayLike.prototype.insertAt = function insertAt(idx, obj) { + this._array.splice(idx, 0, obj); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.removeAt = function removeAt(idx) { + var len = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1]; + + this._array.splice(idx, len); + this.arrayContentDidChange(); + }; + + ArrayLike.prototype.arrayContentDidChange = function arrayContentDidChange() { + _emberMetal.propertyDidChange(this, '[]'); + _emberMetal.propertyDidChange(this, 'length'); + }; + +babelHelpers.createClass(ArrayLike, [{ + key: 'length', + get: function () { + return this._array.length; + } + }]); + return ArrayLike; + })(); + + var TogglingEachTest = (function (_TogglingSyntaxConditionalsTest) { +babelHelpers.inherits(TogglingEachTest, _TogglingSyntaxConditionalsTest); + + function TogglingEachTest() { + _TogglingSyntaxConditionalsTest.apply(this, arguments); + } + +babelHelpers.createClass(TogglingEachTest, [{ + key: 'truthyValue', + get: function () { + return ['non-empty']; + } + }, { + key: 'falsyValue', + get: function () { + return []; + } + }]); + return TogglingEachTest; + })(_emberGlimmerTestsUtilsSharedConditionalTests.TogglingSyntaxConditionalsTest); + + var BasicEachTest = (function (_TogglingEachTest) { +babelHelpers.inherits(BasicEachTest, _TogglingEachTest); + + function BasicEachTest() { + _TogglingEachTest.apply(this, arguments); + } + + return BasicEachTest; + })(TogglingEachTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(BasicEachTest, new _emberGlimmerTestsUtilsSharedConditionalTests.TruthyGenerator([['hello'], _emberRuntime.A(['hello']), new ArrayLike(['hello']), _emberRuntime.ArrayProxy.create({ content: ['hello'] }), _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) })]), new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([null, undefined, false, '', 0, []]), _emberGlimmerTestsUtilsSharedConditionalTests.ArrayTestCases); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each}}', (function (_BasicEachTest) { +babelHelpers.inherits(_class, _BasicEachTest); + + function _class() { + _BasicEachTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#each ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class; + })(BasicEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each as}}', (function (_BasicEachTest2) { +babelHelpers.inherits(_class2, _BasicEachTest2); + + function _class2() { + _BasicEachTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{#each ' + cond + ' as |test|}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class2; + })(BasicEachTest)); + + var EachEdgeCasesTest = (function (_TogglingEachTest2) { +babelHelpers.inherits(EachEdgeCasesTest, _TogglingEachTest2); + + function EachEdgeCasesTest() { + _TogglingEachTest2.apply(this, arguments); + } + + return EachEdgeCasesTest; + })(TogglingEachTest); + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins(EachEdgeCasesTest, new _emberGlimmerTestsUtilsSharedConditionalTests.FalsyGenerator([true, 'hello', 1, Object, function () {}, {}, { foo: 'bar' }, Object.create(null), Object.create({}), Object.create({ foo: 'bar' })])); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each}}', (function (_EachEdgeCasesTest) { +babelHelpers.inherits(_class3, _EachEdgeCasesTest); + + function _class3() { + _EachEdgeCasesTest.apply(this, arguments); + } + + _class3.prototype.templateFor = function templateFor(_ref3) { + var cond = _ref3.cond; + var truthy = _ref3.truthy; + var falsy = _ref3.falsy; + + return '{{#each ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class3; + })(EachEdgeCasesTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: toggling {{#each as}}', (function (_EachEdgeCasesTest2) { +babelHelpers.inherits(_class4, _EachEdgeCasesTest2); + + function _class4() { + _EachEdgeCasesTest2.apply(this, arguments); + } + + _class4.prototype.templateFor = function templateFor(_ref4) { + var cond = _ref4.cond; + var truthy = _ref4.truthy; + var falsy = _ref4.falsy; + + return '{{#each ' + cond + ' as |test|}}' + truthy + '{{else}}' + falsy + '{{/each}}'; + }; + + return _class4; + })(EachEdgeCasesTest)); + + var AbstractEachTest = (function (_RenderingTest) { +babelHelpers.inherits(AbstractEachTest, _RenderingTest); + + function AbstractEachTest() { + _RenderingTest.apply(this, arguments); + } + + /* abstract */ + + AbstractEachTest.prototype.makeList = function makeList() { + // this.list = this.delegate = ...; + throw new Error('Not implemented: `makeList`'); + }; + + AbstractEachTest.prototype.replaceList = function replaceList(list) { + var _this = this; + + this.runTask(function () { + return _emberMetal.set(_this.context, 'list', _this.makeList(list)); + }); + }; + + AbstractEachTest.prototype.forEach = function forEach(callback) { + return this.delegate.forEach(callback); + }; + + AbstractEachTest.prototype.objectAt = function objectAt(idx) { + return this.delegate.objectAt(idx); + }; + + AbstractEachTest.prototype.clear = function clear() { + return this.delegate.clear(); + }; + + AbstractEachTest.prototype.replace = function replace(idx, del, ins) { + return this.delegate.replace(idx, del, ins); + }; + + AbstractEachTest.prototype.unshiftObject = function unshiftObject(obj) { + return this.delegate.unshiftObject(obj); + }; + + AbstractEachTest.prototype.unshiftObjects = function unshiftObjects(arr) { + return this.delegate.unshiftObjects(arr); + }; + + AbstractEachTest.prototype.pushObject = function pushObject(obj) { + return this.delegate.pushObject(obj); + }; + + AbstractEachTest.prototype.pushObjects = function pushObjects(arr) { + return this.delegate.pushObjects(arr); + }; + + AbstractEachTest.prototype.shiftObject = function shiftObject() { + return this.delegate.shiftObject(); + }; + + AbstractEachTest.prototype.popObject = function popObject() { + return this.delegate.popObject(); + }; + + AbstractEachTest.prototype.insertAt = function insertAt(idx, obj) { + return this.delegate.insertAt(idx, obj); + }; + + AbstractEachTest.prototype.removeAt = function removeAt(idx, len) { + return this.delegate.removeAt(idx, len); + }; + + AbstractEachTest.prototype.render = function render(template) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + if (this.list === undefined) { + throw new Error('Must call `this.makeList()` before calling this.render()'); + } + + context.list = this.list; + + return _RenderingTest.prototype.render.call(this, template, context); + }; + + return AbstractEachTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var SingleEachTest = (function (_AbstractEachTest) { +babelHelpers.inherits(SingleEachTest, _AbstractEachTest); + + function SingleEachTest() { + _AbstractEachTest.apply(this, arguments); + } + + SingleEachTest.prototype['@test it repeats the given block for each item in the array'] = function testItRepeatsTheGivenBlockForEachItemInTheArray() { + var _this2 = this; + + this.makeList([{ text: 'hello' }]); + + this.render('{{#each list as |item|}}{{item.text}}{{else}}Empty{{/each}}'); + + this.assertText('hello'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('hello'); + + this.runTask(function () { + return _emberMetal.set(_this2.objectAt(0), 'text', 'Hello'); + }); + + this.assertText('Hello'); + + this.runTask(function () { + _this2.pushObject({ text: ' ' }); + _this2.pushObject({ text: 'World' }); + }); + + this.assertText('Hello World'); + + this.runTask(function () { + _this2.pushObject({ text: 'Earth' }); + _this2.removeAt(1); + _this2.insertAt(1, { text: 'Globe' }); + }); + + this.assertText('HelloGlobeWorldEarth'); + + this.runTask(function () { + _this2.pushObject({ text: 'Planet' }); + _this2.removeAt(1); + _this2.insertAt(1, { text: ' ' }); + _this2.pushObject({ text: ' ' }); + _this2.pushObject({ text: 'Earth' }); + _this2.removeAt(3); + }); + + this.assertText('Hello WorldPlanet Earth'); + + this.runTask(function () { + _this2.pushObject({ text: 'Globe' }); + _this2.removeAt(1); + _this2.insertAt(1, { text: ' ' }); + _this2.pushObject({ text: ' ' }); + _this2.pushObject({ text: 'World' }); + _this2.removeAt(2); + }); + + this.assertText('Hello Planet EarthGlobe World'); + + this.runTask(function () { + return _this2.replace(2, 4, { text: 'my' }); + }); + + this.assertText('Hello my World'); + + this.runTask(function () { + return _this2.clear(); + }); + + this.assertText('Empty'); + + this.replaceList([{ text: 'hello' }]); + + this.assertText('hello'); + }; + + SingleEachTest.prototype['@test it receives the index as the second parameter'] = function testItReceivesTheIndexAsTheSecondParameter() { + var _this3 = this; + + this.makeList([{ text: 'hello' }, { text: 'world' }]); + + this.render('{{#each list as |item index|}}[{{index}}. {{item.text}}]{{/each}}'); + + this.assertText('[0. hello][1. world]'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this3.insertAt(1, { text: 'my' }); + }); + + this.assertText('[0. hello][1. my][2. world]'); + + this.replaceList([{ text: 'hello' }, { text: 'world' }]); + + this.assertText('[0. hello][1. world]'); + }; + + SingleEachTest.prototype['@test it accepts a string key'] = function testItAcceptsAStringKey() { + var _this4 = this; + + this.makeList([{ text: 'hello' }, { text: 'world' }]); + + this.render('{{#each list key=\'text\' as |item|}}{{item.text}}{{/each}}'); + + this.assertText('helloworld'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this4.pushObject({ text: 'again' }); + }); + + this.assertText('helloworldagain'); + + this.replaceList([{ text: 'hello' }, { text: 'world' }]); + + this.assertText('helloworld'); + }; + + SingleEachTest.prototype['@test it accepts a numeric key'] = function testItAcceptsANumericKey() { + var _this5 = this; + + this.makeList([{ id: 1 }, { id: 2 }]); + + this.render('{{#each list key=\'id\' as |item|}}{{item.id}}{{/each}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this5.pushObject({ id: 3 }); + }); + + this.assertText('123'); + + this.replaceList([{ id: 1 }, { id: 2 }]); + + this.assertText('12'); + }; + + SingleEachTest.prototype['@test it can specify @index as the key'] = function testItCanSpecifyIndexAsTheKey() { + var _this6 = this; + + this.makeList([{ id: 1 }, { id: 2 }]); + + this.render('{{#each list key=\'@index\' as |item|}}{{item.id}}{{/each}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this6.pushObject({ id: 3 }); + }); + + this.assertText('123'); + + this.replaceList([{ id: 1 }, { id: 2 }]); + + this.assertText('12'); + }; + + SingleEachTest.prototype['@test it can specify @identity as the key for arrays of primitives'] = function testItCanSpecifyIdentityAsTheKeyForArraysOfPrimitives() { + var _this7 = this; + + this.makeList([1, 2]); + + this.render('{{#each list key=\'@identity\' as |item|}}{{item}}{{/each}}'); + + this.assertText('12'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this7.pushObject(3); + }); + + this.assertText('123'); + + this.replaceList([1, 2]); + + this.assertText('12'); + }; + + SingleEachTest.prototype['@test it can specify @identity as the key for mixed arrays of objects and primitives'] = function testItCanSpecifyIdentityAsTheKeyForMixedArraysOfObjectsAndPrimitives() { + var _this8 = this; + + this.makeList([1, { id: 2 }, 3]); + + this.render('{{#each list key=\'@identity\' as |item|}}{{if item.id item.id item}}{{/each}}'); + + this.assertText('123'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this8.insertAt(2, { id: 4 }); + }); + + this.assertText('1243'); + + this.replaceList([1, { id: 2 }, 3]); + + this.assertText('123'); + }; + + SingleEachTest.prototype['@test it can render duplicate primitive items'] = function testItCanRenderDuplicatePrimitiveItems() { + var _this9 = this; + + this.makeList(['a', 'a', 'a']); + + this.render('{{#each list as |item|}}{{item}}{{/each}}'); + + this.assertText('aaa'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this9.pushObject('a'); + }); + + this.assertText('aaaa'); + + this.runTask(function () { + return _this9.pushObject('a'); + }); + + this.assertText('aaaaa'); + + this.replaceList(['a', 'a', 'a']); + + this.assertText('aaa'); + }; + + SingleEachTest.prototype['@test updating and setting within #each'] = function testUpdatingAndSettingWithinEach(assert) { + var _this10 = this; + + this.makeList([{ value: 1 }, { value: 2 }, { value: 3 }]); + + var FooBarComponent = _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + this.isEven = true; + this.tagName = 'li'; + }, + + _isEven: function () { + this.set('isEven', this.get('item.value') % 2 === 0); + }, + + didUpdate: function () { + this._isEven(); + } + }); + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{#if isEven}}{{item.value}}{{/if}}' }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + + this.assertText('Prev1NextPrev2NextPrev3Next'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this10.context.list.objectAt(0), 'value', 3); + }); + + this.assertText('PrevNextPrev2NextPrev3Next'); + + this.replaceList([{ value: 1 }, { value: 2 }, { value: 3 }]); + + this.assertText('Prev1NextPrev2NextPrev3Next'); + }; + + SingleEachTest.prototype['@test it can render duplicate objects'] = function testItCanRenderDuplicateObjects() { + var _this11 = this; + + var duplicateItem = { text: 'foo' }; + + this.makeList([duplicateItem, duplicateItem, { text: 'bar' }, { text: 'baz' }]); + + this.render('{{#each list as |item|}}{{item.text}}{{/each}}'); + + this.assertText('foofoobarbaz'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this11.pushObject(duplicateItem); + }); + + this.assertText('foofoobarbazfoo'); + + this.runTask(function () { + return _this11.pushObject(duplicateItem); + }); + + this.assertText('foofoobarbazfoofoo'); + + this.replaceList([duplicateItem, duplicateItem, { text: 'bar' }, { text: 'baz' }]); + + this.assertText('foofoobarbaz'); + }; + + SingleEachTest.prototype['@test it maintains DOM stability when condition changes between objects with the same keys'] = function testItMaintainsDOMStabilityWhenConditionChangesBetweenObjectsWithTheSameKeys() { + var _this12 = this; + + this.makeList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.render('{{#each list key="text" as |item|}}{{item.text}}{{/each}}'); + + this.assertText('Hello world'); + + this.takeSnapshot(); + + this.runTask(function () { + _this12.popObject(); + _this12.popObject(); + _this12.pushObject({ text: ' ' }); + _this12.pushObject({ text: 'world' }); + }); + + this.assertText('Hello world'); + + this.assertInvariants(); + + this.replaceList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.assertText('Hello world'); + + this.assertInvariants(); + }; + + SingleEachTest.prototype['@test it maintains DOM stability for stable keys when list is updated'] = function testItMaintainsDOMStabilityForStableKeysWhenListIsUpdated() { + var _this13 = this; + + this.makeList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.render('{{#each list key="text" as |item|}}{{item.text}}{{/each}}'); + + this.assertText('Hello world'); + + this.assertStableRerender(); + + var oldSnapshot = this.takeSnapshot(); + + this.runTask(function () { + _this13.unshiftObject({ text: ', ' }); + _this13.unshiftObject({ text: 'Hi' }); + _this13.pushObject({ text: '!' }); + _this13.pushObject({ text: 'earth' }); + }); + + this.assertText('Hi, Hello world!earth'); + + this.assertPartialInvariants(2, 5); + + this.replaceList([{ text: 'Hello' }, { text: ' ' }, { text: 'world' }]); + + this.assertText('Hello world'); + + this.assertInvariants(oldSnapshot, this.takeSnapshot()); + }; + + SingleEachTest.prototype['@test it renders all items with duplicate key values'] = function testItRendersAllItemsWithDuplicateKeyValues() { + var _this14 = this; + + this.makeList([{ text: 'Hello' }, { text: 'Hello' }, { text: 'Hello' }]); + + this.render('{{#each list key="text" as |item|}}{{item.text}}{{/each}}'); + + this.assertText('HelloHelloHello'); + + this.runTask(function () { + _this14.forEach(function (hash) { + return _emberMetal.set(hash, 'text', 'Goodbye'); + }); + }); + + this.assertText('GoodbyeGoodbyeGoodbye'); + + this.replaceList([{ text: 'Hello' }, { text: 'Hello' }, { text: 'Hello' }]); + + this.assertText('HelloHelloHello'); + }; + + SingleEachTest.prototype['@test context is not changed to the inner scope inside an {{#each as}} block'] = function testContextIsNotChangedToTheInnerScopeInsideAnEachAsBlock() { + var _this15 = this; + + this.makeList([{ name: 'Chad' }, { name: 'Zack' }, { name: 'Asa' }]); + + this.render('{{name}}-{{#each list as |person|}}{{name}}{{/each}}-{{name}}', { + name: 'Joel' + }); + + this.assertText('Joel-JoelJoelJoel-Joel'); + + this.assertStableRerender(); + + this.runTask(function () { + return _this15.shiftObject(); + }); + + this.assertText('Joel-JoelJoel-Joel'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'name', 'Godfrey'); + }); + + this.assertText('Godfrey-GodfreyGodfrey-Godfrey'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'name', 'Joel'); + }); + this.replaceList([{ name: 'Chad' }, { name: 'Zack' }, { name: 'Asa' }]); + + this.assertText('Joel-JoelJoelJoel-Joel'); + }; + + SingleEachTest.prototype['@test can access the item and the original scope'] = function testCanAccessTheItemAndTheOriginalScope() { + var _this16 = this; + + this.makeList([{ name: 'Tom Dale' }, { name: 'Yehuda Katz' }, { name: 'Godfrey Chan' }]); + + this.render('{{#each list key="name" as |person|}}[{{title}}: {{person.name}}]{{/each}}', { + title: 'Señor Engineer' + }); + + this.assertText('[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]'); + + this.runTask(function () { + _emberMetal.set(_this16.objectAt(1), 'name', 'Stefan Penner'); + _this16.removeAt(0); + _this16.pushObject({ name: 'Tom Dale' }); + _this16.insertAt(1, { name: 'Chad Hietala' }); + _emberMetal.set(_this16.context, 'title', 'Principal Engineer'); + }); + + this.assertText('[Principal Engineer: Stefan Penner][Principal Engineer: Chad Hietala][Principal Engineer: Godfrey Chan][Principal Engineer: Tom Dale]'); + + this.runTask(function () { + return _emberMetal.set(_this16.context, 'title', 'Señor Engineer'); + }); + this.replaceList([{ name: 'Tom Dale' }, { name: 'Yehuda Katz' }, { name: 'Godfrey Chan' }]); + + this.assertText('[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]'); + }; + + SingleEachTest.prototype['@test the scoped variable is not available outside the {{#each}} block.'] = function testTheScopedVariableIsNotAvailableOutsideTheEachBlock() { + var _this17 = this; + + this.makeList(['Yehuda']); + + this.render('{{name}}-{{#each list as |name|}}{{name}}{{/each}}-{{name}}', { + name: 'Stef' + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _this17.pushObjects([' ', 'Katz']); + }); + + this.assertText('Stef-Yehuda Katz-Stef'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'name', 'Tom'); + }); + + this.assertText('Tom-Yehuda Katz-Tom'); + + this.runTask(function () { + return _emberMetal.set(_this17.context, 'name', 'Stef'); + }); + this.replaceList(['Yehuda']); + + this.assertText('Stef-Yehuda-Stef'); + }; + + SingleEachTest.prototype['@test inverse template is displayed with context'] = function testInverseTemplateIsDisplayedWithContext() { + var _this18 = this; + + this.makeList([]); + + this.render('{{#each list as |thing|}}Has Thing{{else}}No Thing {{otherThing}}{{/each}}', { + otherThing: 'bar' + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'otherThing', 'biz'); + }); + + this.assertText('No Thing biz'); + + this.runTask(function () { + return _this18.pushObject('non-empty'); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'otherThing', 'baz'); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + return _emberMetal.set(_this18.context, 'otherThing', 'bar'); + }); + this.replaceList([]); + + this.assertText('No Thing bar'); + }; + + SingleEachTest.prototype['@test content that are not initially present updates correctly GH#13983'] = function testContentThatAreNotInitiallyPresentUpdatesCorrectlyGH13983() { + var _this19 = this; + + // The root cause of this bug is that Glimmer did not call `didInitializeChildren` + // on the inserted `TryOpcode`, causing that `TryOpcode` to have an uninitialized + // tag. Currently the only way to observe this the "JUMP-IF-NOT-MODIFIED", i.e. by + // wrapping it in an component. + + this.registerComponent('x-wrapper', { template: '{{yield}}' }); + + this.makeList([]); + + this.render('{{#x-wrapper}}{{#each list as |obj|}}[{{obj.text}}]{{/each}}{{/x-wrapper}}'); + + this.assertText(''); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _this19.pushObject({ text: 'foo' }); + }); + + this.assertText('[foo]'); + + this.runTask(function () { + return _emberMetal.set(_this19.objectAt(0), 'text', 'FOO'); + }); + + this.assertText('[FOO]'); + + this.runTask(function () { + return _this19.pushObject({ text: 'bar' }); + }); + + this.assertText('[FOO][bar]'); + + this.runTask(function () { + return _emberMetal.set(_this19.objectAt(1), 'text', 'BAR'); + }); + + this.assertText('[FOO][BAR]'); + + this.runTask(function () { + return _emberMetal.set(_this19.objectAt(1), 'text', 'baz'); + }); + + this.assertText('[FOO][baz]'); + + this.runTask(function () { + return _this19.replace(1, 1, [{ text: 'BAZ' }]); + }); + + this.assertText('[FOO][BAZ]'); + + this.replaceList([]); + + this.assertText(''); + }; + + return SingleEachTest; + })(AbstractEachTest); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with arrays', (function (_SingleEachTest) { +babelHelpers.inherits(_class5, _SingleEachTest); + + function _class5() { + _SingleEachTest.apply(this, arguments); + } + + _class5.prototype.makeList = function makeList(list) { + return this.list = this.delegate = _emberRuntime.A(list); + }; + + return _class5; + })(SingleEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with array-like objects', (function (_SingleEachTest2) { +babelHelpers.inherits(_class6, _SingleEachTest2); + + function _class6() { + _SingleEachTest2.apply(this, arguments); + } + + _class6.prototype.makeList = function makeList(list) { + return this.list = this.delegate = new ArrayLike(list); + }; + + return _class6; + })(SingleEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with array proxies, modifying itself', (function (_SingleEachTest3) { +babelHelpers.inherits(_class7, _SingleEachTest3); + + function _class7() { + _SingleEachTest3.apply(this, arguments); + } + + _class7.prototype.makeList = function makeList(list) { + return this.list = this.delegate = _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(list) }); + }; + + return _class7; + })(SingleEachTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with array proxies, replacing its content', (function (_SingleEachTest4) { +babelHelpers.inherits(_class8, _SingleEachTest4); + + function _class8() { + _SingleEachTest4.apply(this, arguments); + } + + _class8.prototype.makeList = function makeList(list) { + var content = this.delegate = _emberRuntime.A(list); + return this.list = _emberRuntime.ArrayProxy.create({ content: content }); + }; + + _class8.prototype.replaceList = function replaceList(list) { + var _this20 = this; + + this.runTask(function () { + return _this20.list.set('content', _emberRuntime.A(list)); + }); + }; + + return _class8; + })(SingleEachTest)); + + // TODO: Refactor the following tests so we can run them against different kind of arrays + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: Multiple {{#each as}} helpers', (function (_RenderingTest2) { +babelHelpers.inherits(_class9, _RenderingTest2); + + function _class9() { + _RenderingTest2.apply(this, arguments); + } + + _class9.prototype['@test re-using the same variable with different {{#each}} blocks does not override each other'] = function testReUsingTheSameVariableWithDifferentEachBlocksDoesNotOverrideEachOther() { + var _this21 = this; + + this.render('Admin: {{#each admins key="name" as |person|}}[{{person.name}}]{{/each}} User: {{#each users key="name" as |person|}}[{{person.name}}]{{/each}}', { + admins: _emberRuntime.A([{ name: 'Tom Dale' }]), + users: _emberRuntime.A([{ name: 'Yehuda Katz' }]) + }); + + this.assertText('Admin: [Tom Dale] User: [Yehuda Katz]'); + + this.runTask(function () { + return _this21.rerender(); + }); + + this.assertText('Admin: [Tom Dale] User: [Yehuda Katz]'); + + this.runTask(function () { + _emberMetal.get(_this21.context, 'admins').pushObject({ name: 'Godfrey Chan' }); + _emberMetal.set(_emberMetal.get(_this21.context, 'users').objectAt(0), 'name', 'Stefan Penner'); + }); + + this.assertText('Admin: [Tom Dale][Godfrey Chan] User: [Stefan Penner]'); + + this.runTask(function () { + _emberMetal.set(_this21.context, 'admins', [{ name: 'Tom Dale' }]); + _emberMetal.set(_this21.context, 'users', [{ name: 'Yehuda Katz' }]); + }); + + this.assertText('Admin: [Tom Dale] User: [Yehuda Katz]'); + }; + + _class9.prototype['@test an outer {{#each}}\'s scoped variable does not clobber an inner {{#each}}\'s property if they share the same name - Issue #1315'] = function testAnOuterEachSScopedVariableDoesNotClobberAnInnerEachSPropertyIfTheyShareTheSameNameIssue1315() { + var _this22 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + content: _emberRuntime.A(['X', 'Y']), + options: _emberRuntime.A([{ label: 'One', value: 1 }, { label: 'Two', value: 2 }]) + }); + + this.assertText('X-1:One2:TwoY-1:One2:Two'); + + this.assertStableRerender(); + + this.runTask(function () { + _emberMetal.get(_this22.context, 'content').pushObject('Z'); + _emberMetal.set(_emberMetal.get(_this22.context, 'options').objectAt(0), 'value', 0); + }); + + this.assertText('X-0:One2:TwoY-0:One2:TwoZ-0:One2:Two'); + + this.runTask(function () { + _emberMetal.set(_this22.context, 'content', ['X', 'Y']); + _emberMetal.set(_this22.context, 'options', [{ label: 'One', value: 1 }, { label: 'Two', value: 2 }]); + }); + + this.assertText('X-1:One2:TwoY-1:One2:Two'); + }; + + _class9.prototype['@test the scoped variable is not available outside the {{#each}} block'] = function testTheScopedVariableIsNotAvailableOutsideTheEachBlock() { + var _this23 = this; + + this.render('{{ring}}-{{#each first as |ring|}}{{ring}}-{{#each fifth as |ring|}}{{ring}}-{{#each ninth as |ring|}}{{ring}}-{{/each}}{{ring}}-{{/each}}{{ring}}-{{/each}}{{ring}}', { + ring: 'Greed', + first: _emberRuntime.A(['Limbo']), + fifth: _emberRuntime.A(['Wrath']), + ninth: _emberRuntime.A(['Treachery']) + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + return _this23.rerender(); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + _emberMetal.set(_this23.context, 'ring', 'O'); + _emberMetal.get(_this23.context, 'fifth').insertAt(0, 'D'); + }); + + this.assertText('O-Limbo-D-Treachery-D-Wrath-Treachery-Wrath-Limbo-O'); + + this.runTask(function () { + _emberMetal.get(_this23.context, 'first').pushObject('I'); + _emberMetal.get(_this23.context, 'ninth').replace(0, 1, 'K'); + }); + + this.assertText('O-Limbo-D-K-D-Wrath-K-Wrath-Limbo-I-D-K-D-Wrath-K-Wrath-I-O'); + + this.runTask(function () { + _emberMetal.set(_this23.context, 'ring', 'Greed'); + _emberMetal.set(_this23.context, 'first', ['Limbo']); + _emberMetal.set(_this23.context, 'fifth', ['Wrath']); + _emberMetal.set(_this23.context, 'ninth', ['Treachery']); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + }; + + _class9.prototype['@test it should support {{#each name as |foo|}}, then {{#each foo as |bar|}}'] = function testItShouldSupportEachNameAsFooThenEachFooAsBar() { + var _this24 = this; + + this.render('{{#each name key="@index" as |foo|}}{{#each foo as |bar|}}{{bar}}{{/each}}{{/each}}', { + name: _emberRuntime.A([_emberRuntime.A(['caterpillar'])]) + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + return _this24.rerender(); + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + var name = _emberMetal.get(_this24.context, 'name'); + name.objectAt(0).replace(0, 1, 'lady'); + name.pushObject(['bird']); + }); + + this.assertText('ladybird'); + + this.runTask(function () { + return _emberMetal.set(_this24.context, 'name', [['caterpillar']]); + }); + + this.assertText('caterpillar'); + }; + + return _class9; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each as}} undefined path', (function (_RenderingTest3) { +babelHelpers.inherits(_class10, _RenderingTest3); + + function _class10() { + _RenderingTest3.apply(this, arguments); + } + + _class10.prototype['@test keying off of `undefined` does not render'] = function testKeyingOffOfUndefinedDoesNotRender(assert) { + var _this25 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject3), { foo: {} }); + + this.assertText(''); + + this.runTask(function () { + return _this25.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'foo', { bar: { baz: ['Here!'] } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this25.context, 'foo', {}); + }); + + this.assertText(''); + }; + + return _class10; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each}} with sparse arrays', (function (_RenderingTest4) { +babelHelpers.inherits(_class11, _RenderingTest4); + + function _class11() { + _RenderingTest4.apply(this, arguments); + } + + _class11.prototype['@test it should itterate over holes'] = function testItShouldItterateOverHoles(assert) { + var _this26 = this; + + var sparseArray = []; + sparseArray[3] = 'foo'; + sparseArray[4] = 'bar'; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject4), { list: _emberRuntime.A(sparseArray) }); + + this.assertText('[0:][1:][2:][3:foo][4:bar]'); + + this.assertStableRerender(); + + this.runTask(function () { + var list = _emberMetal.get(_this26.context, 'list'); + list.pushObject('baz'); + }); + + this.assertText('[0:][1:][2:][3:foo][4:bar][5:baz]'); + }; + + return _class11; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + + /* globals MutationObserver: false */ + if (typeof MutationObserver === 'function') { + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#each as}} DOM mutation test', (function (_RenderingTest5) { +babelHelpers.inherits(_class12, _RenderingTest5); + + function _class12() { + _RenderingTest5.call(this); + this.observer = null; + } + + _class12.prototype.observe = function observe(element) { + var observer = this.observer = new MutationObserver(function () {}); + observer.observe(element, { childList: true, characterData: true }); + }; + + _class12.prototype.teardown = function teardown() { + if (this.observer) { + this.observer.disconnect(); + } + + _RenderingTest5.prototype.teardown.call(this); + }; + + _class12.prototype.assertNoMutation = function assertNoMutation() { + this.assert.deepEqual(this.observer.takeRecords(), [], 'Expected no mutations'); + }; + + _class12.prototype.expectMutations = function expectMutations() { + this.assert.ok(this.observer.takeRecords().length > 0, 'Expected some mutations'); + }; + + _class12.prototype['@test {{#each}} should not mutate a subtree when the array has not changed [GH #14332]'] = function testEachShouldNotMutateASubtreeWhenTheArrayHasNotChangedGH14332(assert) { + var _this27 = this; + + var page = { title: 'Blog Posts' }; + + var model = [{ title: 'Rails is omakase' }, { title: 'Ember is omakase' }]; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject5), { page: page, model: model }); + + this.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject6)); + + this.observe(this.$('#posts')[0]); + + // MutationObserver is async + return _emberRuntime.RSVP.Promise.resolve(function () { + _this27.assertStableRerender(); + }).then(function () { + _this27.assertNoMutation(); + + _this27.runTask(function () { + return _emberMetal.set(_this27.context, 'page', { title: 'Essays' }); + }); + + _this27.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject7)); + }).then(function () { + _this27.assertNoMutation(); + + _this27.runTask(function () { + return _emberMetal.set(_this27.context.page, 'title', 'Think Pieces™'); + }); + + _this27.assertHTML(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject8)); + }).then(function () { + // The last set is localized to the `page` object, so we do not expect Glimmer + // to re-iterate the list + _this27.assertNoMutation(); + }); + }; + + return _class12; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); + } +}); +enifed('ember-glimmer/tests/integration/syntax/each-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/each-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/each-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/if-unless-test', ['exports', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (exports, _emberGlimmerTestsUtilsHelpers, _emberRuntime, _emberMetal, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsSharedConditionalTests) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if cond}}\n {{#each numbers as |number|}}\n {{foo-bar number=number}}\n {{/each}}\n {{else}}\n Nothing Here!\n {{/if}}'], ['\n {{#if cond}}\n {{#each numbers as |number|}}\n {{foo-bar number=number}}\n {{/each}}\n {{else}}\n Nothing Here!\n {{/if}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if foo.bar.baz}}\n Here!\n {{else}}\n Nothing Here!\n {{/if}}'], ['\n {{#if foo.bar.baz}}\n Here!\n {{else}}\n Nothing Here!\n {{/if}}']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#if}} with inverse', (function (_IfUnlessWithSyntaxTest) { +babelHelpers.inherits(_class, _IfUnlessWithSyntaxTest); + + function _class() { + _IfUnlessWithSyntaxTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#if ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/if}}'; + }; + + return _class; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#unless}} with inverse', (function (_IfUnlessWithSyntaxTest2) { +babelHelpers.inherits(_class2, _IfUnlessWithSyntaxTest2); + + function _class2() { + _IfUnlessWithSyntaxTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{#unless ' + cond + '}}' + falsy + '{{else}}' + truthy + '{{/unless}}'; + }; + + return _class2; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#if}} and {{#unless}} without inverse', (function (_IfUnlessWithSyntaxTest3) { +babelHelpers.inherits(_class3, _IfUnlessWithSyntaxTest3); + + function _class3() { + _IfUnlessWithSyntaxTest3.apply(this, arguments); + } + + _class3.prototype.templateFor = function templateFor(_ref3) { + var cond = _ref3.cond; + var truthy = _ref3.truthy; + var falsy = _ref3.falsy; + + return '{{#if ' + cond + '}}' + truthy + '{{/if}}{{#unless ' + cond + '}}' + falsy + '{{/unless}}'; + }; + + return _class3; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#if}}', (function (_RenderingTest) { +babelHelpers.inherits(_class4, _RenderingTest); + + function _class4() { + _RenderingTest.apply(this, arguments); + } + + _class4.prototype['@test using `if` with an `{{each}}` destroys components when transitioning to and from inverse (GH #12267)'] = function testUsingIfWithAnEachDestroysComponentsWhenTransitioningToAndFromInverseGH12267(assert) { + var _this = this; + + var destroyedChildrenCount = 0; + + this.registerComponent('foo-bar', { + template: '{{number}}', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + willDestroy: function () { + this._super(); + destroyedChildrenCount++; + } + }) + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { cond: true, numbers: _emberRuntime.A([1, 2, 3]) }); + + this.assertText('123'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('123'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond', false); + }); + + this.assertText('Nothing Here!'); + assert.equal(destroyedChildrenCount, 3, 'the children were properly destroyed'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond', true); + }); + + this.assertText('123'); + }; + + _class4.prototype['@test looking up `undefined` property defaults to false'] = function testLookingUpUndefinedPropertyDefaultsToFalse(assert) { + var _this2 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { foo: {} }); + + this.assertText('Nothing Here!'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Nothing Here!'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'foo', { bar: { baz: true } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'foo', {}); + }); + + this.assertText('Nothing Here!'); + }; + + return _class4; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/if-unless-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/if-unless-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/if-unless-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/in-element-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/component', 'ember-metal'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsTestHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerComponent, _emberMetal) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#-in-element someElement}}\n {{text}}\n {{/-in-element}}\n '], ['\n {{#-in-element someElement}}\n {{text}}\n {{/-in-element}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#if showModal}}\n {{#-in-element someElement}}\n {{modal-display text=text}}\n {{/-in-element}}\n {{/if}}\n '], ['\n {{#if showModal}}\n {{#-in-element someElement}}\n {{modal-display text=text}}\n {{/-in-element}}\n {{/if}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{-in-element}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test allows rendering into an external element'] = function testAllowsRenderingIntoAnExternalElement(assert) { + var _this = this; + + var someElement = document.createElement('div'); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { + someElement: someElement, + text: 'Whoop!' + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, 'Whoop!'); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'text', 'Huzzah!!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, 'Huzzah!!'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'text', 'Whoop!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, 'Whoop!'); + }; + + _class.prototype['@test components are cleaned up properly'] = function testComponentsAreCleanedUpProperly(assert) { + var _this2 = this; + + var hooks = []; + + var someElement = document.createElement('div'); + + this.registerComponent('modal-display', { + ComponentClass: _emberGlimmerComponent.default.extend({ + didInsertElement: function () { + hooks.push('didInsertElement'); + }, + + willDestroyElement: function () { + hooks.push('willDestroyElement'); + } + }), + + template: '{{text}}' + }); + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + someElement: someElement, + text: 'Whoop!', + showModal: false + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, ''); + + this.assertStableRerender(); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'showModal', true); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + this.assertComponentElement(someElement.firstChild, { content: 'Whoop!' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'text', 'Huzzah!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + this.assertComponentElement(someElement.firstChild, { content: 'Huzzah!' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'text', 'Whoop!'); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + this.assertComponentElement(someElement.firstChild, { content: 'Whoop!' }); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'showModal', false); + }); + + _emberGlimmerTestsUtilsTestHelpers.equalTokens(this.element, ''); + _emberGlimmerTestsUtilsTestHelpers.equalTokens(someElement, ''); + + assert.deepEqual(hooks, ['didInsertElement', 'willDestroyElement']); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/in-element-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/in-element-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/in-element-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/with-dynamic-var-test', ['exports', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#-with-dynamic-vars foo="bar"}}\n {{-get-dynamic-var \'foo\'}}\n {{/-with-dynamic-vars}}\n '], ['\n {{#-with-dynamic-vars foo="bar"}}\n {{-get-dynamic-var \'foo\'}}\n {{/-with-dynamic-vars}}\n ']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{#-with-dynamic-vars outletState="bar"}}\n {{-get-dynamic-var \'outletState\'}}\n {{/-with-dynamic-vars}}\n '], ['\n {{#-with-dynamic-vars outletState="bar"}}\n {{-get-dynamic-var \'outletState\'}}\n {{/-with-dynamic-vars}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('{{-with-dynamic-var}}', (function (_RenderingTest) { +babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test does not allow setting values other than outletState'] = function testDoesNotAllowSettingValuesOtherThanOutletState(assert) { + var _this = this; + + expectAssertion(function () { + _this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject)); + }, /Using `-with-dynamic-scope` is only supported for `outletState` \(you used `foo`\)./); + }; + + _class.prototype['@test allows setting/getting outletState'] = function testAllowsSettingGettingOutletState(assert) { + // this is simply asserting that we can write and read outletState + // the actual value being used here is not what is used in real life + // feel free to change the value being set and asserted as needed + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2)); + + this.assertText('bar'); + }; + + _class.prototype['@test does not allow setting values other than outletState'] = function testDoesNotAllowSettingValuesOtherThanOutletState(assert) { + var _this2 = this; + + expectAssertion(function () { + _this2.render('{{-get-dynamic-var \'foo\'}}'); + }, /Using `-get-dynamic-scope` is only supported for `outletState` \(you used `foo`\)./); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/with-dynamic-var-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/with-dynamic-var-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/with-dynamic-var-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/integration/syntax/with-test', ['exports', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/shared-conditional-tests', 'ember-glimmer/tests/utils/abstract-test-case'], function (exports, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsSharedConditionalTests, _emberGlimmerTestsUtilsAbstractTestCase) { + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['\n {{#with foo.bar.baz as |thing|}}\n {{thing}}\n {{/with}}'], ['\n {{#with foo.bar.baz as |thing|}}\n {{thing}}\n {{/with}}']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['\n {{name}}\n {{#with committer1.name as |name|}}\n [{{name}}\n {{#with committer2.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n {{#with committer2.name as |name|}}\n [{{name}}\n {{#with committer1.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n '], ['\n {{name}}\n {{#with committer1.name as |name|}}\n [{{name}}\n {{#with committer2.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n {{#with committer2.name as |name|}}\n [{{name}}\n {{#with committer1.name as |name|}}\n [{{name}}]\n {{/with}}\n {{name}}]\n {{/with}}\n {{name}}\n ']); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#with}}', (function (_IfUnlessWithSyntaxTest) { +babelHelpers.inherits(_class, _IfUnlessWithSyntaxTest); + + function _class() { + _IfUnlessWithSyntaxTest.apply(this, arguments); + } + + _class.prototype.templateFor = function templateFor(_ref) { + var cond = _ref.cond; + var truthy = _ref.truthy; + var falsy = _ref.falsy; + + return '{{#with ' + cond + '}}' + truthy + '{{else}}' + falsy + '{{/with}}'; + }; + + return _class; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: {{#with as}}', (function (_IfUnlessWithSyntaxTest2) { +babelHelpers.inherits(_class2, _IfUnlessWithSyntaxTest2); + + function _class2() { + _IfUnlessWithSyntaxTest2.apply(this, arguments); + } + + _class2.prototype.templateFor = function templateFor(_ref2) { + var cond = _ref2.cond; + var truthy = _ref2.truthy; + var falsy = _ref2.falsy; + + return '{{#with ' + cond + ' as |test|}}' + truthy + '{{else}}' + falsy + '{{/with}}'; + }; + + _class2.prototype['@test keying off of `undefined` does not render'] = function testKeyingOffOfUndefinedDoesNotRender(assert) { + var _this = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject), { foo: {} }); + + this.assertText(''); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'foo', { bar: { baz: 'Here!' } }); + }); + + this.assertText('Here!'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'foo', {}); + }); + + this.assertText(''); + }; + + _class2.prototype['@test it renders and hides the given block based on the conditional'] = function testItRendersAndHidesTheGivenBlockBasedOnTheConditional() { + var _this2 = this; + + this.render('{{#with cond1 as |cond|}}{{cond.greeting}}{{else}}False{{/with}}', { + cond1: { greeting: 'Hello' } + }); + + this.assertText('Hello'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('Hello'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1.greeting', 'Hello world'); + }); + + this.assertText('Hello world'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', false); + }); + + this.assertText('False'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', { greeting: 'Hello' }); + }); + + this.assertText('Hello'); + }; + + _class2.prototype['@test can access alias and original scope'] = function testCanAccessAliasAndOriginalScope() { + var _this3 = this; + + this.render('{{#with person as |tom|}}{{title}}: {{tom.name}}{{/with}}', { + title: 'Señor Engineer', + person: { name: 'Tom Dale' } + }); + + this.assertText('Señor Engineer: Tom Dale'); + + this.runTask(function () { + return _this3.rerender(); + }); + + this.assertText('Señor Engineer: Tom Dale'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'person.name', 'Yehuda Katz'); + _emberMetal.set(_this3.context, 'title', 'Principal Engineer'); + }); + + this.assertText('Principal Engineer: Yehuda Katz'); + + this.runTask(function () { + _emberMetal.set(_this3.context, 'person', { name: 'Tom Dale' }); + _emberMetal.set(_this3.context, 'title', 'Señor Engineer'); + }); + + this.assertText('Señor Engineer: Tom Dale'); + }; + + _class2.prototype['@test the scoped variable is not available outside the {{#with}} block.'] = function testTheScopedVariableIsNotAvailableOutsideTheWithBlock() { + var _this4 = this; + + this.render('{{name}}-{{#with other as |name|}}{{name}}{{/with}}-{{name}}', { + name: 'Stef', + other: 'Yehuda' + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _this4.rerender(); + }); + + this.assertText('Stef-Yehuda-Stef'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'other', 'Chad'); + }); + + this.assertText('Stef-Chad-Stef'); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'name', 'Tom'); + }); + + this.assertText('Tom-Chad-Tom'); + + this.runTask(function () { + _emberMetal.set(_this4.context, 'name', 'Stef'); + _emberMetal.set(_this4.context, 'other', 'Yehuda'); + }); + + this.assertText('Stef-Yehuda-Stef'); + }; + + _class2.prototype['@test inverse template is displayed with context'] = function testInverseTemplateIsDisplayedWithContext() { + var _this5 = this; + + this.render('{{#with falsyThing as |thing|}}Has Thing{{else}}No Thing {{otherThing}}{{/with}}', { + falsyThing: null, + otherThing: 'bar' + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('No Thing bar'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'otherThing', 'biz'); + }); + + this.assertText('No Thing biz'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'falsyThing', true); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'otherThing', 'baz'); + }); + + this.assertText('Has Thing'); + + this.runTask(function () { + _emberMetal.set(_this5.context, 'otherThing', 'bar'); + _emberMetal.set(_this5.context, 'falsyThing', null); + }); + + this.assertText('No Thing bar'); + }; + + _class2.prototype['@test can access alias of a proxy'] = function testCanAccessAliasOfAProxy() { + var _this6 = this; + + this.render('{{#with proxy as |person|}}{{person.name}}{{/with}}', { + proxy: _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } }) + }); + + this.assertText('Tom Dale'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('Tom Dale'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.name', 'Yehuda Katz'); + }); + + this.assertText('Yehuda Katz'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.content', { name: 'Godfrey Chan' }); + }); + + this.assertText('Godfrey Chan'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.content.name', 'Stefan Penner'); + }); + + this.assertText('Stefan Penner'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy.content', null); + }); + + this.assertText(''); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } })); + }); + + this.assertText('Tom Dale'); + }; + + _class2.prototype['@test can access alias of an array'] = function testCanAccessAliasOfAnArray() { + var _this7 = this; + + this.render('{{#with arrayThing as |words|}}{{#each words as |word|}}{{word}}{{/each}}{{/with}}', { + arrayThing: _emberRuntime.A(['Hello', ' ', 'world']) + }); + + this.assertText('Hello world'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('Hello world'); + + this.runTask(function () { + var array = _emberMetal.get(_this7.context, 'arrayThing'); + array.replace(0, 1, 'Goodbye'); + _emberRuntime.removeAt(array, 1); + array.insertAt(1, ', '); + array.pushObject('!'); + }); + + this.assertText('Goodbye, world!'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'arrayThing', ['Hello', ' ', 'world']); + }); + + this.assertText('Hello world'); + }; + + _class2.prototype['@test `attrs` can be used as a block param [GH#14678]'] = function testAttrsCanBeUsedAsABlockParamGH14678() { + var _this8 = this; + + this.render('{{#with hash as |attrs|}}[{{hash.foo}}-{{attrs.foo}}]{{/with}}', { + hash: { foo: 'foo' } + }); + + this.assertText('[foo-foo]'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('[foo-foo]'); + + this.runTask(function () { + return _this8.context.set('hash.foo', 'FOO'); + }); + + this.assertText('[FOO-FOO]'); + + this.runTask(function () { + return _this8.context.set('hash.foo', 'foo'); + }); + + this.assertText('[foo-foo]'); + }; + + return _class2; + })(_emberGlimmerTestsUtilsSharedConditionalTests.IfUnlessWithSyntaxTest)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('Syntax test: Multiple {{#with as}} helpers', (function (_RenderingTest) { +babelHelpers.inherits(_class3, _RenderingTest); + + function _class3() { + _RenderingTest.apply(this, arguments); + } + + _class3.prototype['@test re-using the same variable with different {{#with}} blocks does not override each other'] = function testReUsingTheSameVariableWithDifferentWithBlocksDoesNotOverrideEachOther() { + var _this9 = this; + + this.render('Admin: {{#with admin as |person|}}{{person.name}}{{/with}} User: {{#with user as |person|}}{{person.name}}{{/with}}', { + admin: { name: 'Tom Dale' }, + user: { name: 'Yehuda Katz' } + }); + + this.assertText('Admin: Tom Dale User: Yehuda Katz'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('Admin: Tom Dale User: Yehuda Katz'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'admin.name', 'Godfrey Chan'); + _emberMetal.set(_this9.context, 'user.name', 'Stefan Penner'); + }); + + this.assertText('Admin: Godfrey Chan User: Stefan Penner'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'admin', { name: 'Tom Dale' }); + _emberMetal.set(_this9.context, 'user', { name: 'Yehuda Katz' }); + }); + + this.assertText('Admin: Tom Dale User: Yehuda Katz'); + }; + + _class3.prototype['@test the scoped variable is not available outside the {{#with}} block'] = function testTheScopedVariableIsNotAvailableOutsideTheWithBlock() { + var _this10 = this; + + this.render('{{ring}}-{{#with first as |ring|}}{{ring}}-{{#with fifth as |ring|}}{{ring}}-{{#with ninth as |ring|}}{{ring}}-{{/with}}{{ring}}-{{/with}}{{ring}}-{{/with}}{{ring}}', { + ring: 'Greed', + first: 'Limbo', + fifth: 'Wrath', + ninth: 'Treachery' + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'ring', 'O'); + _emberMetal.set(_this10.context, 'fifth', 'D'); + }); + + this.assertText('O-Limbo-D-Treachery-D-Limbo-O'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'first', 'I'); + _emberMetal.set(_this10.context, 'ninth', 'K'); + }); + + this.assertText('O-I-D-K-D-I-O'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'ring', 'Greed'); + _emberMetal.set(_this10.context, 'first', 'Limbo'); + _emberMetal.set(_this10.context, 'fifth', 'Wrath'); + _emberMetal.set(_this10.context, 'ninth', 'Treachery'); + }); + + this.assertText('Greed-Limbo-Wrath-Treachery-Wrath-Limbo-Greed'); + }; + + _class3.prototype['@test it should support {{#with name as |foo|}}, then {{#with foo as |bar|}}'] = function testItShouldSupportWithNameAsFooThenWithFooAsBar() { + var _this11 = this; + + this.render('{{#with name as |foo|}}{{#with foo as |bar|}}{{bar}}{{/with}}{{/with}}', { + name: 'caterpillar' + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('caterpillar'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'name', 'butterfly'); + }); + + this.assertText('butterfly'); + + this.runTask(function () { + return _emberMetal.set(_this11.context, 'name', 'caterpillar'); + }); + + this.assertText('caterpillar'); + }; + + _class3.prototype['@test updating the context should update the alias'] = function testUpdatingTheContextShouldUpdateTheAlias() { + var _this12 = this; + + this.render('{{#with this as |person|}}{{person.name}}{{/with}}', { + name: 'Los Pivots' + }); + + this.assertText('Los Pivots'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('Los Pivots'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'name', 'l\'Pivots'); + }); + + this.assertText('l\'Pivots'); + + this.runTask(function () { + return _emberMetal.set(_this12.context, 'name', 'Los Pivots'); + }); + + this.assertText('Los Pivots'); + }; + + _class3.prototype['@test nested {{#with}} blocks should have access to root context'] = function testNestedWithBlocksShouldHaveAccessToRootContext() { + var _this13 = this; + + this.render(_emberGlimmerTestsUtilsAbstractTestCase.strip(_templateObject2), { + name: 'ebryn', + committer1: { name: 'trek' }, + committer2: { name: 'machty' } + }); + + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'name', 'chancancode'); + }); + + this.assertText('chancancode[trek[machty]trek]chancancode[machty[trek]machty]chancancode'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'committer1', { name: 'krisselden' }); + }); + + this.assertText('chancancode[krisselden[machty]krisselden]chancancode[machty[krisselden]machty]chancancode'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'committer1.name', 'wycats'); + _emberMetal.set(_this13.context, 'committer2', { name: 'rwjblue' }); + }); + + this.assertText('chancancode[wycats[rwjblue]wycats]chancancode[rwjblue[wycats]rwjblue]chancancode'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'name', 'ebryn'); + _emberMetal.set(_this13.context, 'committer1', { name: 'trek' }); + _emberMetal.set(_this13.context, 'committer2', { name: 'machty' }); + }); + + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); + }; + + return _class3; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/integration/syntax/with-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/integration/syntax/with-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/integration/syntax/with-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/layout-cache-test', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/test-case', '@glimmer/runtime'], function (exports, _emberUtils, _emberGlimmerTestsUtilsTestCase, _glimmerRuntime) { + 'use strict'; + + var Counter = (function () { + function Counter() { + this.reset(); + } + + Counter.prototype.increment = function increment(key) { + this.total++; + return this.counts[key] = (this.counts[key] || 0) + 1; + }; + + Counter.prototype.get = function get(key) { + return this.counts[key] || 0; + }; + + Counter.prototype.reset = function reset() { + this.total = 0; + this.counts = new _emberUtils.EmptyObject(); + }; + + return Counter; + })(); + + var COUNTER = new Counter(); + + var BasicCompiler = (function () { + function BasicCompiler(template) { + this.template = template; + } + + BasicCompiler.prototype.compile = function compile(builder) { + var template = this.template; + + COUNTER.increment(this.constructor.id + '+' + template.id); + builder.wrapLayout(template.asLayout()); + }; + + return BasicCompiler; + })(); + + var TypeOneCompiler = (function (_BasicCompiler) { + babelHelpers.inherits(TypeOneCompiler, _BasicCompiler); + + function TypeOneCompiler() { + _BasicCompiler.apply(this, arguments); + } + + return TypeOneCompiler; + })(BasicCompiler); + + var TypeTwoCompiler = (function (_BasicCompiler2) { + babelHelpers.inherits(TypeTwoCompiler, _BasicCompiler2); + + function TypeTwoCompiler() { + _BasicCompiler2.apply(this, arguments); + } + + return TypeTwoCompiler; + })(BasicCompiler); + + TypeOneCompiler.id = 'type-one'; + TypeTwoCompiler.id = 'type-two'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Layout cache test', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.call(this); + COUNTER.reset(); + } + + _class.prototype.templateFor = function templateFor(content) { + var Factory = this.compile(content); + return this.env.getTemplate(Factory, this.owner); + }; + + _class.prototype['@test each template is only compiled once'] = function testEachTemplateIsOnlyCompiledOnce(assert) { + var env = this.env; + + var template1 = this.templateFor('Hello world!'); + var template2 = this.templateFor('{{foo}} {{bar}}'); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 1); + assert.strictEqual(COUNTER.total, 2); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + + assert.strictEqual(COUNTER.get('type-one+' + template1.id), 1); + assert.strictEqual(COUNTER.get('type-one+' + template2.id), 1); + assert.strictEqual(COUNTER.total, 2); + }; + + _class.prototype['@test each template/compiler pair is treated as unique'] = function testEachTemplateCompilerPairIsTreatedAsUnique(assert) { + var env = this.env; + + var template = this.templateFor('Hello world!'); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 0); + assert.strictEqual(COUNTER.total, 1); + + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 1); + assert.strictEqual(COUNTER.total, 2); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeTwoCompiler, template) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + + assert.strictEqual(COUNTER.get('type-one+' + template.id), 1); + assert.strictEqual(COUNTER.get('type-two+' + template.id), 1); + assert.strictEqual(COUNTER.total, 2); + }; + + _class.prototype['@test a template instance is returned (ensures templates can be injected into layout property)'] = function testATemplateInstanceIsReturnedEnsuresTemplatesCanBeInjectedIntoLayoutProperty(assert) { + var _this = this; + + var owner = this.owner; + var env = this.env; + + var templateInstanceFor = function (content) { + var _Factory$create; + + var Factory = _this.compile(content); + return Factory.create((_Factory$create = {}, _Factory$create[_emberUtils.OWNER] = owner, _Factory$create.env = env, _Factory$create)); + }; + + var template1 = templateInstanceFor('Hello world!'); + var template2 = templateInstanceFor('{{foo}} {{bar}}'); + + assert.ok(env.getCompiledBlock(TypeOneCompiler, template1) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + assert.ok(env.getCompiledBlock(TypeOneCompiler, template2) instanceof _glimmerRuntime.CompiledBlock, 'should return a CompiledBlock'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/unit/layout-cache-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/layout-cache-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/layout-cache-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/outlet-test', ['exports', 'ember-glimmer/views/outlet', 'ember-metal'], function (exports, _emberGlimmerViewsOutlet, _emberMetal) { + 'use strict'; + + QUnit.module('Glimmer OutletView'); + + QUnit.test('render in the render queue', function (assert) { + var didAppendOutletView = 0; + var expectedOutlet = '#foo.bar'; + + var renderer = { + appendOutletView: function (view, target) { + didAppendOutletView++; + assert.equal(view, outletView); + assert.equal(target, expectedOutlet); + } + }; + + var outletView = new _emberGlimmerViewsOutlet.default({}, renderer); + + _emberMetal.run(function () { + assert.equal(didAppendOutletView, 0, 'appendOutletView should not yet have been called (before appendTo)'); + outletView.appendTo(expectedOutlet); + assert.equal(didAppendOutletView, 0, 'appendOutletView should not yet have been called (sync after appendTo)'); + + _emberMetal.run.schedule('actions', function () { + return assert.equal(didAppendOutletView, 0, 'appendOutletView should not yet have been called (in actions)'); + }); + _emberMetal.run.schedule('render', function () { + return assert.equal(didAppendOutletView, 1, 'appendOutletView should be invoked in render'); + }); + }); + }); +}); +enifed('ember-glimmer/tests/unit/outlet-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/outlet-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/outlet-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/template-factory-test', ['exports', 'ember-template-compiler', 'ember-glimmer/index', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberTemplateCompiler, _emberGlimmerIndex, _emberGlimmerTestsUtilsTestCase, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Template factory test', (function (_RenderingTest) { + babelHelpers.inherits(_class, _RenderingTest); + + function _class() { + _RenderingTest.apply(this, arguments); + } + + _class.prototype['@test the template factory returned from precompile is the same as compile'] = function testTheTemplateFactoryReturnedFromPrecompileIsTheSameAsCompile(assert) { + var env = this.env; + + var templateStr = 'Hello {{name}}'; + var options = { moduleName: 'some-module' }; + + var spec = _emberTemplateCompiler.precompile(templateStr, options); + var body = 'exports.default = template(' + spec + ');'; + var module = new Function('exports', 'template', body); + var exports = {}; + module(exports, _emberGlimmerIndex.template); + var Precompiled = exports['default']; + + var Compiled = _emberTemplateCompiler.compile(templateStr, options); + + assert.equal(typeof Precompiled.create, 'function', 'precompiled is a factory'); + assert.ok(Precompiled.id, 'precompiled has id'); + + assert.equal(typeof Compiled.create, 'function', 'compiled is a factory'); + assert.ok(Compiled.id, 'compiled has id'); + + assert.equal(env._templateCache.misses, 0, 'misses 0'); + assert.equal(env._templateCache.hits, 0, 'hits 0'); + + var precompiled = env.getTemplate(Precompiled, env.owner); + + assert.equal(env._templateCache.misses, 1, 'misses 1'); + assert.equal(env._templateCache.hits, 0, 'hits 0'); + + var compiled = env.getTemplate(Compiled, env.owner); + + assert.equal(env._templateCache.misses, 2, 'misses 2'); + assert.equal(env._templateCache.hits, 0, 'hits 0'); + + assert.ok(typeof precompiled.spec !== 'string', 'Spec has been parsed'); + assert.ok(typeof compiled.spec !== 'string', 'Spec has been parsed'); + + this.registerComponent('x-precompiled', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: Precompiled + }) + }); + + this.registerComponent('x-compiled', { + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + layout: Compiled + }) + }); + + this.render('{{x-precompiled name="precompiled"}} {{x-compiled name="compiled"}}'); + + assert.equal(env._templateCache.misses, 2, 'misses 2'); + assert.equal(env._templateCache.hits, 2, 'hits 2'); + + this.assertText('Hello precompiled Hello compiled'); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest)); +}); +enifed('ember-glimmer/tests/unit/template-factory-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/template-factory-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/template-factory-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/utils/debug-stack-test', ['exports', 'ember-glimmer/utils/debug-stack', 'ember-metal'], function (exports, _emberGlimmerUtilsDebugStack, _emberMetal) { + 'use strict'; +}); +enifed('ember-glimmer/tests/unit/utils/debug-stack-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/utils/debug-stack-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/utils/debug-stack-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/unit/utils/iterable-test', ['exports', 'ember', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', '@glimmer/runtime'], function (exports, _ember, _emberGlimmerTestsUtilsTestCase, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerRuntime) { + 'use strict'; + + var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('Iterable', (function (_TestCase) { + babelHelpers.inherits(_class, _TestCase); + + function _class() { + _TestCase.apply(this, arguments); + } + + _class.prototype['@test iterates over an array'] = function testIteratesOverAnArray() { + var iterator = iteratorForArray(['foo', 'bar']); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test iterates over an `Ember.A`'] = function testIteratesOverAnEmberA() { + var iterator = iteratorForArray(_ember.default.A(['foo', 'bar'])); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test returns `null` when out of items'] = function testReturnsNullWhenOutOfItems() { + var iterator = iteratorForArray(['foo']); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), null); + }; + + _class.prototype['@test iterates over an array with indices as keys'] = function testIteratesOverAnArrayWithIndicesAsKeys() { + var iterator = iteratorForArray(['foo', 'bar'], '@index'); + + this.assert.deepEqual(iterator.next(), { key: '0', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: '1', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test iterates over an array with identities as keys'] = function testIteratesOverAnArrayWithIdentitiesAsKeys() { + var iterator = iteratorForArray(['foo', 'bar'], '@identity'); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 0, value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 1, value: 'bar' }); + }; + + _class.prototype['@test iterates over an array with arbitrary properties as keys'] = function testIteratesOverAnArrayWithArbitraryPropertiesAsKeys() { + var iterator = iteratorForArray([{ k: 'first', v: 'foo' }, { k: 'second', v: 'bar' }], 'k'); + + this.assert.deepEqual(iterator.next(), { key: 'first', memo: 0, value: { k: 'first', v: 'foo' } }); + this.assert.deepEqual(iterator.next(), { key: 'second', memo: 1, value: { k: 'second', v: 'bar' } }); + }; + + _class.prototype['@test errors on `#next` with an undefined ref'] = function testErrorsOnNextWithAnUndefinedRef() { + var iterator = iteratorForArray(undefined); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref) { + var _message = _ref.message; + + this.assert.equal(_message, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test errors on `#next` with a null ref'] = function testErrorsOnNextWithANullRef() { + var iterator = iteratorForArray(null); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref2) { + var _message2 = _ref2.message; + + this.assert.equal(_message2, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test errors on `#next` with an invalid ref type'] = function testErrorsOnNextWithAnInvalidRefType() { + var iterator = iteratorForArray('string'); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref3) { + var _message3 = _ref3.message; + + this.assert.equal(_message3, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test errors on `#next` with an empty array'] = function testErrorsOnNextWithAnEmptyArray() { + var iterator = iteratorForArray([]); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref4) { + var _message4 = _ref4.message; + + this.assert.equal(_message4, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test iterates over an object\'s own properties'] = function testIteratesOverAnObjectSOwnProperties() { + var iterator = iteratorForObject({ first: 'foo', second: 'bar' }); + + this.assert.deepEqual(iterator.next(), { key: 'first', memo: 'first', value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'second', memo: 'second', value: 'bar' }); + }; + + _class.prototype['@test iterates over an object\'s own properties with indices as keys'] = function testIteratesOverAnObjectSOwnPropertiesWithIndicesAsKeys() { + var iterator = iteratorForObject({ first: 'foo', second: 'bar' }, '@index'); + + this.assert.deepEqual(iterator.next(), { key: 'first', memo: 'first', value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'second', memo: 'second', value: 'bar' }); + }; + + _class.prototype['@test iterates over an object\'s own properties with identities as keys'] = function testIteratesOverAnObjectSOwnPropertiesWithIdentitiesAsKeys() { + var iterator = iteratorForObject({ first: 'foo', second: 'bar' }, '@identity'); + + this.assert.deepEqual(iterator.next(), { key: 'foo', memo: 'first', value: 'foo' }); + this.assert.deepEqual(iterator.next(), { key: 'bar', memo: 'second', value: 'bar' }); + }; + + _class.prototype['@test iterates over an object\'s own properties with arbitrary properties as keys'] = function testIteratesOverAnObjectSOwnPropertiesWithArbitraryPropertiesAsKeys() { + var iterator = iteratorForObject({ first: { k: 'uno', v: 'foo' }, second: { k: 'dos', v: 'bar' } }, 'k'); + + this.assert.deepEqual(iterator.next(), { key: 'uno', memo: 'first', value: { k: 'uno', v: 'foo' } }); + this.assert.deepEqual(iterator.next(), { key: 'dos', memo: 'second', value: { k: 'dos', v: 'bar' } }); + }; + + _class.prototype['@test each-in errors on `#next` with an undefined ref'] = function testEachInErrorsOnNextWithAnUndefinedRef() { + var iterator = iteratorForObject(undefined); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref5) { + var _message5 = _ref5.message; + + this.assert.equal(_message5, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test each-in errors on `#next` with a null ref'] = function testEachInErrorsOnNextWithANullRef() { + var iterator = iteratorForObject(null); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref6) { + var _message6 = _ref6.message; + + this.assert.equal(_message6, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test each-in errors on `#next` with an invalid ref type'] = function testEachInErrorsOnNextWithAnInvalidRefType() { + var iterator = iteratorForObject('string'); + + this.assert.expect(1); + + try { + iterator.next(); + } catch (_ref7) { + var _message7 = _ref7.message; + + this.assert.equal(_message7, 'Cannot call next() on an empty iterator'); + } + }; + + _class.prototype['@test ensures keys are unique'] = function testEnsuresKeysAreUnique() { + var iterator = iteratorForArray([{ k: 'qux', v: 'foo' }, { k: 'qux', v: 'bar' }, { k: 'qux', v: 'baz' }], 'k'); + + this.assert.deepEqual(iterator.next(), { key: 'qux', memo: 0, value: { k: 'qux', v: 'foo' } }); + this.assert.deepEqual(iterator.next(), { key: 'qux' + ITERATOR_KEY_GUID + '1', memo: 1, value: { k: 'qux', v: 'bar' } }); + this.assert.deepEqual(iterator.next(), { key: 'qux' + ITERATOR_KEY_GUID + '2', memo: 2, value: { k: 'qux', v: 'baz' } }); + }; + + return _class; + })(_emberGlimmerTestsUtilsTestCase.TestCase)); + + function iteratorForArray(arr, keyPath) { + var ref = new _emberGlimmerUtilsReferences.UpdatableReference(arr); + var iterable = _emberGlimmerUtilsIterable.default(ref, keyPath); + + return iterable.iterate(); + } + + function iteratorForObject(obj, keyPath) { + var vm = null; + var positionalArgs = _glimmerRuntime.EvaluatedPositionalArgs.create([new _emberGlimmerUtilsReferences.UpdatableReference(obj)]); + var ref = _emberGlimmerHelpersEachIn.default(vm, { positional: positionalArgs }); + var iterable = _emberGlimmerUtilsIterable.default(ref, keyPath); + + return iterable.iterate(); + } +}); +enifed('ember-glimmer/tests/unit/utils/iterable-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/unit/utils/iterable-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/unit/utils/iterable-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/abstract-test-case', ['exports', 'internal-test-helpers'], function (exports, _internalTestHelpers) { + 'use strict'; + + exports.TestCase = _internalTestHelpers.AbstractTestCase; + exports.applyMixins = _internalTestHelpers.applyMixins; + exports.strip = _internalTestHelpers.strip; +}); +enifed('ember-glimmer/tests/utils/abstract-test-case.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/abstract-test-case.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/abstract-test-case.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/helpers', ['exports', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + exports.compile = _emberTemplateCompiler.compile; + exports.precompile = _emberTemplateCompiler.precompile; + exports.INVOKE = _emberGlimmer.INVOKE; + exports.Helper = _emberGlimmer.Helper; + exports.helper = _emberGlimmer.helper; + exports.Component = _emberGlimmer.Component; + exports.TextArea = _emberGlimmer.TextArea; + exports.LinkComponent = _emberGlimmer.LinkComponent; + exports.TextField = _emberGlimmer.TextField; + exports.InteractiveRender = _emberGlimmer.InteractiveRender; + exports.InertRenderer = _emberGlimmer.InertRenderer; + exports.makeBoundHelper = _emberGlimmer.makeBoundHelper; + exports.htmlSafe = _emberGlimmer.htmlSafe; + exports.SafeString = _emberGlimmer.SafeString; + exports.DOMChanges = _emberGlimmer.DOMChanges; + exports.isHTMLSafe = _emberGlimmer.isHTMLSafe; +}); +enifed('ember-glimmer/tests/utils/helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/shared-conditional-tests', ['exports', 'ember-utils', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers'], function (exports, _emberUtils, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase, _emberMetal, _emberRuntime, _emberGlimmerTestsUtilsHelpers) { + 'use strict'; + + var _ObjectTestCases, _ArrayTestCases; + + var AbstractConditionalsTest = (function (_RenderingTest) { + babelHelpers.inherits(AbstractConditionalsTest, _RenderingTest); + + function AbstractConditionalsTest() { + _RenderingTest.apply(this, arguments); + } + + AbstractConditionalsTest.prototype.wrapperFor = function wrapperFor(templates) { + return templates.join(''); + }; + + AbstractConditionalsTest.prototype.wrappedTemplateFor = function wrappedTemplateFor(options) { + return this.wrapperFor([this.templateFor(options)]); + }; + + /* abstract */ + + AbstractConditionalsTest.prototype.templateFor = function templateFor(_ref5) { + var cond = _ref5.cond; + var truthy = _ref5.truthy; + var falsy = _ref5.falsy; + + // e.g. `{{#if ${cond}}}${truthy}{{else}}${falsy}{{/if}}` + throw new Error('Not implemented: `templateFor`'); + }; + + /* abstract */ + + AbstractConditionalsTest.prototype.renderValues = function renderValues() { + throw new Error('Not implemented: `renderValues`'); + }; + + babelHelpers.createClass(AbstractConditionalsTest, [{ + key: 'truthyValue', + get: function () { + return true; + } + }, { + key: 'falsyValue', + get: function () { + return false; + } + }]); + return AbstractConditionalsTest; + })(_emberGlimmerTestsUtilsTestCase.RenderingTest); + + var AbstractGenerator = (function () { + function AbstractGenerator(cases) { + this.cases = cases; + } + + /* + The test cases in this file generally follow the following pattern: + + 1. Render with [ truthy, ...(other truthy variations), falsy, ...(other falsy variations) ] + 2. No-op rerender + 3. Make all of them falsy (through interior mutation) + 4. Make all of them truthy (through interior mutation, sometimes with some slight variations) + 5. Reset them to their original values (through replacement) + */ + + /* abstract */ + + AbstractGenerator.prototype.generate = function generate(value, idx) { + throw new Error('Not implemented: `generate`'); + }; + + return AbstractGenerator; + })(); + + var TruthyGenerator = (function (_AbstractGenerator) { + babelHelpers.inherits(TruthyGenerator, _AbstractGenerator); + + function TruthyGenerator() { + _AbstractGenerator.apply(this, arguments); + } + + TruthyGenerator.prototype.generate = function generate(value, idx) { + var _ref; + + return _ref = {}, _ref['@test it should consider ' + JSON.stringify(value) + ' truthy [' + idx + ']'] = function () { + var _this = this; + + this.renderValues(value); + + this.assertText('T1'); + + this.runTask(function () { + return _this.rerender(); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond1', _this.falsyValue); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this.context, 'cond1', value); + }); + + this.assertText('T1'); + }, _ref; + }; + + return TruthyGenerator; + })(AbstractGenerator); + + exports.TruthyGenerator = TruthyGenerator; + + var FalsyGenerator = (function (_AbstractGenerator2) { + babelHelpers.inherits(FalsyGenerator, _AbstractGenerator2); + + function FalsyGenerator() { + _AbstractGenerator2.apply(this, arguments); + } + + FalsyGenerator.prototype.generate = function generate(value, idx) { + var _ref2; + + return _ref2 = {}, _ref2['@test it should consider ' + JSON.stringify(value) + ' falsy [' + idx + ']'] = function () { + var _this2 = this; + + this.renderValues(value); + + this.assertText('F1'); + + this.runTask(function () { + return _this2.rerender(); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', _this2.truthyValue); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this2.context, 'cond1', value); + }); + + this.assertText('F1'); + }, _ref2; + }; + + return FalsyGenerator; + })(AbstractGenerator); + + exports.FalsyGenerator = FalsyGenerator; + + var StableTruthyGenerator = (function (_TruthyGenerator) { + babelHelpers.inherits(StableTruthyGenerator, _TruthyGenerator); + + function StableTruthyGenerator() { + _TruthyGenerator.apply(this, arguments); + } + + StableTruthyGenerator.prototype.generate = function generate(value, idx) { + var _assign; + + return _emberUtils.assign(_TruthyGenerator.prototype.generate.call(this, value, idx), (_assign = {}, _assign['@test it maintains DOM stability when condition changes from ' + value + ' to another truthy value and back [' + idx + ']'] = function () { + var _this3 = this; + + this.renderValues(value); + + this.assertText('T1'); + + this.takeSnapshot(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'cond1', _this3.truthyValue); + }); + + this.assertText('T1'); + + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this3.context, 'cond1', value); + }); + + this.assertText('T1'); + + this.assertInvariants(); + }, _assign)); + }; + + return StableTruthyGenerator; + })(TruthyGenerator); + + exports.StableTruthyGenerator = StableTruthyGenerator; + + var StableFalsyGenerator = (function (_FalsyGenerator) { + babelHelpers.inherits(StableFalsyGenerator, _FalsyGenerator); + + function StableFalsyGenerator() { + _FalsyGenerator.apply(this, arguments); + } + + StableFalsyGenerator.prototype.generate = function generate(value, idx) { + var _assign2; + + return _emberUtils.assign(_FalsyGenerator.prototype.generate.call(this, value), (_assign2 = {}, _assign2['@test it maintains DOM stability when condition changes from ' + value + ' to another falsy value and back [' + idx + ']'] = function () { + var _this4 = this; + + this.renderValues(value); + + this.assertText('F1'); + + this.takeSnapshot(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'cond1', _this4.falsyValue); + }); + + this.assertText('F1'); + + this.assertInvariants(); + + this.runTask(function () { + return _emberMetal.set(_this4.context, 'cond1', value); + }); + + this.assertText('F1'); + + this.assertInvariants(); + }, _assign2)); + }; + + return StableFalsyGenerator; + })(FalsyGenerator); + + exports.StableFalsyGenerator = StableFalsyGenerator; + + var ObjectProxyGenerator = (function (_AbstractGenerator3) { + babelHelpers.inherits(ObjectProxyGenerator, _AbstractGenerator3); + + function ObjectProxyGenerator() { + _AbstractGenerator3.apply(this, arguments); + } + + // Testing behaviors shared across all conditionals, i.e. {{#if}}, {{#unless}}, + // {{#with}}, {{#each}}, {{#each-in}}, (if) and (unless) + + ObjectProxyGenerator.prototype.generate = function generate(value, idx) { + // This is inconsistent with our usual to-bool policy, but the current proxy implementation + // simply uses !!content to determine truthiness + if (value) { + var _ref3; + + return _ref3 = {}, _ref3['@test it should consider an object proxy with `' + JSON.stringify(value) + '` truthy [' + idx + ']'] = function () { + var _this5 = this; + + this.renderValues(_emberRuntime.ObjectProxy.create({ content: value })); + + this.assertText('T1'); + + this.runTask(function () { + return _this5.rerender(); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'cond1.content', _this5.falsyValue); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this5.context, 'cond1', _emberRuntime.ObjectProxy.create({ content: value })); + }); + + this.assertText('T1'); + }, _ref3; + } else { + var _ref4; + + return _ref4 = {}, _ref4['@test it should consider an object proxy with `' + JSON.stringify(value) + '` falsy [' + idx + ']'] = function () { + var _this6 = this; + + this.renderValues(_emberRuntime.ObjectProxy.create({ content: value })); + + this.assertText('F1'); + + this.runTask(function () { + return _this6.rerender(); + }); + + this.assertText('F1'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'cond1.content', _this6.truthyValue); + }); + + this.assertText('T1'); + + this.runTask(function () { + return _emberMetal.set(_this6.context, 'cond1', _emberRuntime.ObjectProxy.create({ content: value })); + }); + + this.assertText('F1'); + }, _ref4; + } + }; + + return ObjectProxyGenerator; + })(AbstractGenerator); + + var BasicConditionalsTest = (function (_AbstractConditionalsTest) { + babelHelpers.inherits(BasicConditionalsTest, _AbstractConditionalsTest); + + function BasicConditionalsTest() { + _AbstractConditionalsTest.apply(this, arguments); + } + + // Testing behaviors related to ember objects, object proxies, etc + + BasicConditionalsTest.prototype['@test it renders the corresponding block based on the conditional'] = function testItRendersTheCorrespondingBlockBasedOnTheConditional() { + var _this7 = this; + + this.renderValues(this.truthyValue, this.falsyValue); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this7.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberMetal.set(_this7.context, 'cond1', _this7.falsyValue); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.set(_this7.context, 'cond1', _this7.truthyValue); + _emberMetal.set(_this7.context, 'cond2', _this7.truthyValue); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this7.context, 'cond1', _this7.truthyValue); + _emberMetal.set(_this7.context, 'cond2', _this7.falsyValue); + }); + + this.assertText('T1F2'); + }; + + return BasicConditionalsTest; + })(AbstractConditionalsTest); + + exports.BasicConditionalsTest = BasicConditionalsTest; + var ObjectTestCases = (_ObjectTestCases = {}, _ObjectTestCases['@test it considers object proxies without content falsy'] = function () { + var _this8 = this; + + this.renderValues(_emberRuntime.ObjectProxy.create({ content: {} }), _emberRuntime.ObjectProxy.create({ content: _emberRuntime.Object.create() }), _emberRuntime.ObjectProxy.create({ content: null })); + + this.assertText('T1T2F3'); + + this.runTask(function () { + return _this8.rerender(); + }); + + this.assertText('T1T2F3'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'cond1.content', null); + _emberMetal.set(_this8.context, 'cond2.content', null); + }); + + this.assertText('F1F2F3'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'cond1.content', _emberRuntime.Object.create()); + _emberMetal.set(_this8.context, 'cond2.content', {}); + _emberMetal.set(_this8.context, 'cond3.content', { foo: 'bar' }); + }); + + this.assertText('T1T2T3'); + + this.runTask(function () { + _emberMetal.set(_this8.context, 'cond1', _emberRuntime.ObjectProxy.create({ content: {} })); + _emberMetal.set(_this8.context, 'cond2', _emberRuntime.ObjectProxy.create({ content: _emberRuntime.Object.create() })); + _emberMetal.set(_this8.context, 'cond3', _emberRuntime.ObjectProxy.create({ content: null })); + }); + + this.assertText('T1T2F3'); + }, _ObjectTestCases); + + exports.ObjectTestCases = ObjectTestCases; + // Testing behaviors related to arrays and array proxies + var ArrayTestCases = (_ArrayTestCases = {}, _ArrayTestCases['@test it considers empty arrays falsy'] = function () { + var _this9 = this; + + this.renderValues(_emberRuntime.A(['hello']), _emberRuntime.A()); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this9.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberRuntime.removeAt(_emberMetal.get(_this9.context, 'cond1'), 0); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.get(_this9.context, 'cond1').pushObject('hello'); + _emberMetal.get(_this9.context, 'cond2').pushObjects([1]); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this9.context, 'cond1', _emberRuntime.A(['hello'])); + _emberMetal.set(_this9.context, 'cond2', _emberRuntime.A()); + }); + + this.assertText('T1F2'); + }, _ArrayTestCases['@test it considers array proxies without content falsy'] = function () { + var _this10 = this; + + this.renderValues(_emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) }), _emberRuntime.ArrayProxy.create({ content: null })); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this10.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond1.content', null); + _emberMetal.set(_this10.context, 'cond2.content', null); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond1.content', _emberRuntime.A(['hello'])); + _emberMetal.set(_this10.context, 'cond2.content', _emberRuntime.A([1])); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this10.context, 'cond1', _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) })); + _emberMetal.set(_this10.context, 'cond2', _emberRuntime.ArrayProxy.create({ content: null })); + }); + + this.assertText('T1F2'); + }, _ArrayTestCases['@test it considers array proxies with empty arrays falsy'] = function () { + var _this11 = this; + + this.renderValues(_emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) }), _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A() })); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this11.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberRuntime.removeAt(_emberMetal.get(_this11.context, 'cond1.content'), 0); + }); + + this.assertText('F1F2'); + + this.runTask(function () { + _emberMetal.get(_this11.context, 'cond1.content').pushObject('hello'); + _emberMetal.get(_this11.context, 'cond2.content').pushObjects([1]); + }); + + this.assertText('T1T2'); + + this.runTask(function () { + _emberMetal.set(_this11.context, 'cond1', _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A(['hello']) })); + _emberMetal.set(_this11.context, 'cond2', _emberRuntime.ArrayProxy.create({ content: _emberRuntime.A() })); + }); + + this.assertText('T1F2'); + }, _ArrayTestCases); + + exports.ArrayTestCases = ArrayTestCases; + var IfUnlessWithTestCases = [new StableTruthyGenerator([true, ' ', 'hello', 'false', 'null', 'undefined', 1, ['hello'], _emberRuntime.A(['hello']), {}, { foo: 'bar' }, _emberRuntime.Object.create(), _emberRuntime.Object.create({ foo: 'bar' }), _emberRuntime.ObjectProxy.create({ content: true }), Object, function () {}, + /*jshint -W053 */ + new String('hello'), new String(''), new Boolean(true), new Boolean(false), + /*jshint +W053 */ + new Date()]), new StableFalsyGenerator([false, null, undefined, '', 0, [], _emberRuntime.A(), _emberRuntime.ObjectProxy.create({ content: undefined })]), new ObjectProxyGenerator([true, ' ', 'hello', 'false', 'null', 'undefined', 1, ['hello'], _emberRuntime.A(['hello']), _emberRuntime.ArrayProxy.create({ content: ['hello'] }), _emberRuntime.ArrayProxy.create({ content: [] }), {}, { foo: 'bar' }, _emberRuntime.Object.create(), _emberRuntime.Object.create({ foo: 'bar' }), _emberRuntime.ObjectProxy.create({ content: true }), _emberRuntime.ObjectProxy.create({ content: undefined }), + /*jshint -W053 */ + new String('hello'), new String(''), new Boolean(true), new Boolean(false), + /*jshint +W053 */ + new Date(), false, null, undefined, '', 0, [], _emberRuntime.A()]), ObjectTestCases, ArrayTestCases]; + + // Testing behaviors shared across the "toggling" conditionals, i.e. {{#if}}, + // {{#unless}}, {{#with}}, {{#each}}, {{#each-in}}, (if) and (unless) + + var TogglingConditionalsTest = (function (_BasicConditionalsTest) { + babelHelpers.inherits(TogglingConditionalsTest, _BasicConditionalsTest); + + function TogglingConditionalsTest() { + _BasicConditionalsTest.apply(this, arguments); + } + + // Testing behaviors shared across the (if) and (unless) helpers + return TogglingConditionalsTest; + })(BasicConditionalsTest); + + exports.TogglingConditionalsTest = TogglingConditionalsTest; + + var TogglingHelperConditionalsTest = (function (_TogglingConditionalsTest) { + babelHelpers.inherits(TogglingHelperConditionalsTest, _TogglingConditionalsTest); + + function TogglingHelperConditionalsTest() { + _TogglingConditionalsTest.apply(this, arguments); + } + + TogglingHelperConditionalsTest.prototype.renderValues = function renderValues() { + var templates = []; + var context = {}; + + for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + for (var i = 1; i <= values.length; i++) { + templates.push(this.templateFor({ cond: 'cond' + i, truthy: 't' + i, falsy: 'f' + i })); + context['t' + i] = 'T' + i; + context['f' + i] = 'F' + i; + context['cond' + i] = values[i - 1]; + } + + var wrappedTemplate = this.wrapperFor(templates); + this.render(wrappedTemplate, context); + }; + + TogglingHelperConditionalsTest.prototype['@test it has access to the outer scope from both templates'] = function testItHasAccessToTheOuterScopeFromBothTemplates() { + var _this12 = this; + + var template = this.wrapperFor([this.templateFor({ cond: 'cond1', truthy: 'truthy', falsy: 'falsy' }), this.templateFor({ cond: 'cond2', truthy: 'truthy', falsy: 'falsy' })]); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue, truthy: 'YES', falsy: 'NO' }); + + this.assertText('YESNO'); + + this.runTask(function () { + return _this12.rerender(); + }); + + this.assertText('YESNO'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'truthy', 'YASS'); + _emberMetal.set(_this12.context, 'falsy', 'NOPE'); + }); + + this.assertText('YASSNOPE'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'cond1', _this12.falsyValue); + _emberMetal.set(_this12.context, 'cond2', _this12.truthyValue); + }); + + this.assertText('NOPEYASS'); + + this.runTask(function () { + _emberMetal.set(_this12.context, 'truthy', 'YES'); + _emberMetal.set(_this12.context, 'falsy', 'NO'); + _emberMetal.set(_this12.context, 'cond1', _this12.truthyValue); + _emberMetal.set(_this12.context, 'cond2', _this12.falsyValue); + }); + + this.assertText('YESNO'); + }; + + TogglingHelperConditionalsTest.prototype['@test it does not update when the unbound helper is used'] = function testItDoesNotUpdateWhenTheUnboundHelperIsUsed() { + var _this13 = this; + + var template = this.wrapperFor([this.templateFor({ cond: '(unbound cond1)', truthy: '"T1"', falsy: '"F1"' }), this.templateFor({ cond: '(unbound cond2)', truthy: '"T2"', falsy: '"F2"' })]); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this13.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberMetal.set(_this13.context, 'cond1', _this13.falsyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'cond1', _this13.truthyValue); + _emberMetal.set(_this13.context, 'cond2', _this13.truthyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this13.context, 'cond1', _this13.truthyValue); + _emberMetal.set(_this13.context, 'cond2', _this13.falsyValue); + }); + + this.assertText('T1F2'); + }; + + TogglingHelperConditionalsTest.prototype['@test evaluation should be lazy'] = function testEvaluationShouldBeLazy(assert) { + var _this14 = this; + + var truthyEvaluated = undefined; + var falsyEvaluated = undefined; + + var withoutEvaluatingTruthy = function (callback) { + truthyEvaluated = false; + callback(); + assert.ok(!truthyEvaluated, 'x-truthy is not evaluated'); + }; + + var withoutEvaluatingFalsy = function (callback) { + falsyEvaluated = false; + callback(); + assert.ok(!falsyEvaluated, 'x-falsy is not evaluated'); + }; + + this.registerHelper('x-truthy', { + compute: function () { + truthyEvaluated = true; + return 'T'; + } + }); + + this.registerHelper('x-falsy', { + compute: function () { + falsyEvaluated = true; + return 'F'; + } + }); + + var template = this.wrappedTemplateFor({ cond: 'cond', truthy: '(x-truthy)', falsy: '(x-falsy)' }); + + withoutEvaluatingFalsy(function () { + return _this14.render(template, { cond: _this14.truthyValue }); + }); + + this.assertText('T'); + + withoutEvaluatingFalsy(function () { + return _this14.runTask(function () { + return _this14.rerender(); + }); + }); + + this.assertText('T'); + + withoutEvaluatingTruthy(function () { + return _this14.runTask(function () { + return _emberMetal.set(_this14.context, 'cond', _this14.falsyValue); + }); + }); + + this.assertText('F'); + + withoutEvaluatingTruthy(function () { + return _this14.runTask(function () { + return _this14.rerender(); + }); + }); + + this.assertText('F'); + + withoutEvaluatingFalsy(function () { + return _this14.runTask(function () { + return _emberMetal.set(_this14.context, 'cond', _this14.truthyValue); + }); + }); + + this.assertText('T'); + }; + + return TogglingHelperConditionalsTest; + })(TogglingConditionalsTest); + + exports.TogglingHelperConditionalsTest = TogglingHelperConditionalsTest; + + var IfUnlessHelperTest = (function (_TogglingHelperConditionalsTest) { + babelHelpers.inherits(IfUnlessHelperTest, _TogglingHelperConditionalsTest); + + function IfUnlessHelperTest() { + _TogglingHelperConditionalsTest.apply(this, arguments); + } + + return IfUnlessHelperTest; + })(TogglingHelperConditionalsTest); + + exports.IfUnlessHelperTest = IfUnlessHelperTest; + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins.apply(undefined, [IfUnlessHelperTest].concat(IfUnlessWithTestCases)); + + // Testing behaviors shared across the "toggling" syntatical constructs, + // i.e. {{#if}}, {{#unless}}, {{#with}}, {{#each}} and {{#each-in}} + + var TogglingSyntaxConditionalsTest = (function (_TogglingConditionalsTest2) { + babelHelpers.inherits(TogglingSyntaxConditionalsTest, _TogglingConditionalsTest2); + + function TogglingSyntaxConditionalsTest() { + _TogglingConditionalsTest2.apply(this, arguments); + } + + TogglingSyntaxConditionalsTest.prototype.renderValues = function renderValues() { + var templates = []; + var context = {}; + + for (var _len2 = arguments.length, values = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + values[_key2] = arguments[_key2]; + } + + for (var i = 1; i <= values.length; i++) { + templates.push(this.templateFor({ cond: 'cond' + i, truthy: '{{t}}' + i, falsy: '{{f}}' + i })); + context['cond' + i] = values[i - 1]; + } + + var wrappedTemplate = this.wrapperFor(templates); + this.render(wrappedTemplate, _emberUtils.assign({ t: 'T', f: 'F' }, context)); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it does not update when the unbound helper is used'] = function testItDoesNotUpdateWhenTheUnboundHelperIsUsed() { + var _this15 = this; + + var template = '' + this.templateFor({ cond: '(unbound cond1)', truthy: 'T1', falsy: 'F1' }) + this.templateFor({ cond: '(unbound cond2)', truthy: 'T2', falsy: 'F2' }); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _this15.rerender(); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + return _emberMetal.set(_this15.context, 'cond1', _this15.falsyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this15.context, 'cond1', _this15.truthyValue); + _emberMetal.set(_this15.context, 'cond2', _this15.truthyValue); + }); + + this.assertText('T1F2'); + + this.runTask(function () { + _emberMetal.set(_this15.context, 'cond1', _this15.truthyValue); + _emberMetal.set(_this15.context, 'cond2', _this15.falsyValue); + }); + + this.assertText('T1F2'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it has access to the outer scope from both templates'] = function testItHasAccessToTheOuterScopeFromBothTemplates() { + var _this16 = this; + + var template = this.wrapperFor([this.templateFor({ cond: 'cond1', truthy: '{{truthy}}', falsy: '{{falsy}}' }), this.templateFor({ cond: 'cond2', truthy: '{{truthy}}', falsy: '{{falsy}}' })]); + + this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue, truthy: 'YES', falsy: 'NO' }); + + this.assertText('YESNO'); + + this.runTask(function () { + return _this16.rerender(); + }); + + this.assertText('YESNO'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'truthy', 'YASS'); + _emberMetal.set(_this16.context, 'falsy', 'NOPE'); + }); + + this.assertText('YASSNOPE'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'cond1', _this16.falsyValue); + _emberMetal.set(_this16.context, 'cond2', _this16.truthyValue); + }); + + this.assertText('NOPEYASS'); + + this.runTask(function () { + _emberMetal.set(_this16.context, 'truthy', 'YES'); + _emberMetal.set(_this16.context, 'falsy', 'NO'); + _emberMetal.set(_this16.context, 'cond1', _this16.truthyValue); + _emberMetal.set(_this16.context, 'cond2', _this16.falsyValue); + }); + + this.assertText('YESNO'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it updates correctly when enclosing another conditional'] = function testItUpdatesCorrectlyWhenEnclosingAnotherConditional() { + var _this17 = this; + + // This tests whether the outer conditional tracks its bounds correctly as its inner bounds changes + var inner = this.templateFor({ cond: 'inner', truthy: 'T-inner', falsy: 'F-inner' }); + var template = this.wrappedTemplateFor({ cond: 'outer', truthy: inner, falsy: 'F-outer' }); + + this.render(template, { outer: this.truthyValue, inner: this.truthyValue }); + + this.assertText('T-inner'); + + this.runTask(function () { + return _this17.rerender(); + }); + + this.assertText('T-inner'); + + // Changes the inner bounds + this.runTask(function () { + return _emberMetal.set(_this17.context, 'inner', _this17.falsyValue); + }); + + this.assertText('F-inner'); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this17.context, 'outer', _this17.falsyValue); + }); + + this.assertText('F-outer'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it updates correctly when enclosing #each'] = function testItUpdatesCorrectlyWhenEnclosingEach() { + var _this18 = this; + + // This tests whether the outer conditional tracks its bounds correctly as its inner bounds changes + var template = this.wrappedTemplateFor({ cond: 'outer', truthy: '{{#each inner as |text|}}{{text}}{{/each}}', falsy: 'F-outer' }); + + this.render(template, { outer: this.truthyValue, inner: ['inner', '-', 'before'] }); + + this.assertText('inner-before'); + + this.runTask(function () { + return _this18.rerender(); + }); + + this.assertText('inner-before'); + + // Changes the inner bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'inner', ['inner-after']); + }); + + this.assertText('inner-after'); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'outer', _this18.falsyValue); + }); + + this.assertText('F-outer'); + + // Reset + this.runTask(function () { + _emberMetal.set(_this18.context, 'inner', ['inner-again']); + _emberMetal.set(_this18.context, 'outer', _this18.truthyValue); + }); + + this.assertText('inner-again'); + + // Now clear the inner bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'inner', []); + }); + + this.assertText(''); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this18.context, 'outer', _this18.falsyValue); + }); + + this.assertText('F-outer'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test it updates correctly when enclosing triple-curlies'] = function testItUpdatesCorrectlyWhenEnclosingTripleCurlies() { + var _this19 = this; + + // This tests whether the outer conditional tracks its bounds correctly as its inner bounds changes + var template = this.wrappedTemplateFor({ cond: 'outer', truthy: '{{{inner}}}', falsy: 'F-outer' }); + + this.render(template, { outer: this.truthyValue, inner: 'inner-before' }); + + this.assertText('inner-before'); + + this.runTask(function () { + return _this19.rerender(); + }); + + this.assertText('inner-before'); + + // Changes the inner bounds + this.runTask(function () { + return _emberMetal.set(_this19.context, 'inner', '

    inner-after

    '); + }); + + this.assertText('inner-after'); + + // Now rerender the outer conditional, which require first clearing its bounds + this.runTask(function () { + return _emberMetal.set(_this19.context, 'outer', _this19.falsyValue); + }); + + this.assertText('F-outer'); + }; + + TogglingSyntaxConditionalsTest.prototype['@test child conditional should not render children if parent conditional becomes false'] = function testChildConditionalShouldNotRenderChildrenIfParentConditionalBecomesFalse(assert) { + var _this20 = this; + + var childCreated = false; + + this.registerComponent('foo-bar', { + template: 'foo-bar', + ComponentClass: _emberGlimmerTestsUtilsHelpers.Component.extend({ + init: function () { + this._super.apply(this, arguments); + childCreated = true; + } + }) + }); + + var innerTemplate = this.templateFor({ cond: 'cond2', truthy: '{{foo-bar}}', falsy: '' }); + var wrappedTemplate = this.wrappedTemplateFor({ cond: 'cond1', truthy: innerTemplate, falsy: '' }); + + this.render(wrappedTemplate, { cond1: this.truthyValue, cond2: this.falsyValue }); + + assert.ok(!childCreated); + this.assertText(''); + + this.runTask(function () { + return _this20.rerender(); + }); + + assert.ok(!childCreated); + this.assertText(''); + + this.runTask(function () { + _emberMetal.set(_this20.context, 'cond2', _this20.truthyValue); + _emberMetal.set(_this20.context, 'cond1', _this20.falsyValue); + }); + + assert.ok(!childCreated); + this.assertText(''); + + this.runTask(function () { + _emberMetal.set(_this20.context, 'cond2', _this20.falsyValue); + _emberMetal.set(_this20.context, 'cond1', _this20.truthyValue); + }); + + assert.ok(!childCreated); + this.assertText(''); + }; + + TogglingSyntaxConditionalsTest.prototype['@test evaluation should be lazy'] = function testEvaluationShouldBeLazy(assert) { + var _this21 = this; + + var truthyEvaluated = undefined; + var falsyEvaluated = undefined; + + var withoutEvaluatingTruthy = function (callback) { + truthyEvaluated = false; + callback(); + assert.ok(!truthyEvaluated, 'x-truthy is not evaluated'); + }; + + var withoutEvaluatingFalsy = function (callback) { + falsyEvaluated = false; + callback(); + assert.ok(!falsyEvaluated, 'x-falsy is not evaluated'); + }; + + this.registerHelper('x-truthy', { + compute: function () { + truthyEvaluated = true; + return 'T'; + } + }); + + this.registerHelper('x-falsy', { + compute: function () { + falsyEvaluated = true; + return 'F'; + } + }); + + var template = this.wrappedTemplateFor({ cond: 'cond', truthy: '{{x-truthy}}', falsy: '{{x-falsy}}' }); + + withoutEvaluatingFalsy(function () { + return _this21.render(template, { cond: _this21.truthyValue }); + }); + + this.assertText('T'); + + withoutEvaluatingFalsy(function () { + return _this21.runTask(function () { + return _this21.rerender(); + }); + }); + + this.assertText('T'); + + withoutEvaluatingTruthy(function () { + return _this21.runTask(function () { + return _emberMetal.set(_this21.context, 'cond', _this21.falsyValue); + }); + }); + + this.assertText('F'); + + withoutEvaluatingTruthy(function () { + return _this21.runTask(function () { + return _this21.rerender(); + }); + }); + + this.assertText('F'); + + withoutEvaluatingFalsy(function () { + return _this21.runTask(function () { + return _emberMetal.set(_this21.context, 'cond', _this21.truthyValue); + }); + }); + + this.assertText('T'); + }; + + return TogglingSyntaxConditionalsTest; + })(TogglingConditionalsTest); + + exports.TogglingSyntaxConditionalsTest = TogglingSyntaxConditionalsTest; + + var IfUnlessWithSyntaxTest = (function (_TogglingSyntaxConditionalsTest) { + babelHelpers.inherits(IfUnlessWithSyntaxTest, _TogglingSyntaxConditionalsTest); + + function IfUnlessWithSyntaxTest() { + _TogglingSyntaxConditionalsTest.apply(this, arguments); + } + + return IfUnlessWithSyntaxTest; + })(TogglingSyntaxConditionalsTest); + + exports.IfUnlessWithSyntaxTest = IfUnlessWithSyntaxTest; + + _emberGlimmerTestsUtilsAbstractTestCase.applyMixins.apply(undefined, [IfUnlessWithSyntaxTest].concat(IfUnlessWithTestCases)); +}); +enifed('ember-glimmer/tests/utils/shared-conditional-tests.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/shared-conditional-tests.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/shared-conditional-tests.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/string-test', ['exports', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case'], function (exports, _emberGlimmerTestsUtilsHelpers, _emberGlimmerTestsUtilsAbstractTestCase, _emberGlimmerTestsUtilsTestCase) { + 'use strict'; + + _emberGlimmerTestsUtilsTestCase.moduleFor('SafeString', (function (_TestCase) { + babelHelpers.inherits(_class, _TestCase); + + function _class() { + _TestCase.apply(this, arguments); + } + + _class.prototype['@test htmlSafe should return an instance of SafeString'] = function testHtmlSafeShouldReturnAnInstanceOfSafeString() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe('you need to be more bold'); + + this.assert.ok(safeString instanceof _emberGlimmerTestsUtilsHelpers.SafeString, 'should be a SafeString'); + }; + + _class.prototype['@test htmlSafe should return an empty string for null'] = function testHtmlSafeShouldReturnAnEmptyStringForNull() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe(null); + + this.assert.equal(safeString instanceof _emberGlimmerTestsUtilsHelpers.SafeString, true, 'should be a SafeString'); + this.assert.equal(safeString.toString(), '', 'should return an empty string'); + }; + + _class.prototype['@test htmlSafe should return an instance of SafeString'] = function testHtmlSafeShouldReturnAnInstanceOfSafeString() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe(); + + this.assert.equal(safeString instanceof _emberGlimmerTestsUtilsHelpers.SafeString, true, 'should be a SafeString'); + this.assert.equal(safeString.toString(), '', 'should return an empty string'); + }; + + return _class; + })(_emberGlimmerTestsUtilsAbstractTestCase.TestCase)); + + _emberGlimmerTestsUtilsTestCase.moduleFor('SafeString isHTMLSafe', (function (_TestCase2) { + babelHelpers.inherits(_class2, _TestCase2); + + function _class2() { + _TestCase2.apply(this, arguments); + } + + _class2.prototype['@test isHTMLSafe should detect SafeString'] = function testIsHTMLSafeShouldDetectSafeString() { + var safeString = _emberGlimmerTestsUtilsHelpers.htmlSafe('Emphasize the important things.'); + + this.assert.ok(_emberGlimmerTestsUtilsHelpers.isHTMLSafe(safeString)); + }; + + _class2.prototype['@test isHTMLSafe should not detect SafeString on primatives'] = function testIsHTMLSafeShouldNotDetectSafeStringOnPrimatives() { + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe('Hello World')); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe({})); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe([])); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe(10)); + this.assert.notOk(_emberGlimmerTestsUtilsHelpers.isHTMLSafe(null)); + }; + + return _class2; + })(_emberGlimmerTestsUtilsAbstractTestCase.TestCase)); +}); +enifed('ember-glimmer/tests/utils/string-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/string-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/string-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/test-case', ['exports', 'internal-test-helpers'], function (exports, _internalTestHelpers) { + 'use strict'; + + exports.TestCase = _internalTestHelpers.AbstractTestCase; + exports.ApplicationTest = _internalTestHelpers.ApplicationTestCase; + exports.RenderingTest = _internalTestHelpers.RenderingTestCase; + exports.moduleFor = _internalTestHelpers.moduleFor; +}); +enifed('ember-glimmer/tests/utils/test-case.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/test-case.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/test-case.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/tests/utils/test-helpers', ['exports', 'internal-test-helpers'], function (exports, _internalTestHelpers) { + 'use strict'; + + exports.styles = _internalTestHelpers.styles; + exports.classes = _internalTestHelpers.classes; + exports.equalTokens = _internalTestHelpers.equalTokens; + exports.equalsElement = _internalTestHelpers.equalsElement; +}); +enifed('ember-glimmer/tests/utils/test-helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/tests/utils/test-helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/tests/utils/test-helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/bindings.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/bindings.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/bindings.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/debug-stack.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/debug-stack.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/debug-stack.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/iterable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/iterable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/iterable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/process-args.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/process-args.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/process-args.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/references.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/references.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/references.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/utils/to-bool.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/utils/to-bool.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/utils/to-bool.js should pass ESLint\n\n'); + }); +}); +enifed('ember-glimmer/views/outlet.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-glimmer/views/outlet.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-glimmer/views/outlet.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/alias.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/alias.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/alias.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/binding.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/binding.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/binding.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/cache.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/cache.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/cache.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/chains.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/chains.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/chains.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/computed.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/computed.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/computed.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/core.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/core.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/core.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/debug.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/debug.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/debug.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/dependent_keys.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/dependent_keys.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/dependent_keys.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/deprecate_property.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/deprecate_property.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/deprecate_property.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/descriptor.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/descriptor.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/descriptor.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/error.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/error.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/error.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/error_handler.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/error_handler.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/error_handler.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/events.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/events.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/events.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/expand_properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/expand_properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/expand_properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/features.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/features.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/features.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/get_properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/get_properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/get_properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/injected_property.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/injected_property.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/injected_property.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/instrumentation.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/instrumentation.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/instrumentation.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_blank.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_blank.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_blank.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_empty.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_empty.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_empty.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_none.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_none.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_none.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_present.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_present.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_present.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/is_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/is_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/is_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/libraries.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/libraries.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/libraries.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/map.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/map.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/map.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/merge.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/merge.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/merge.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/meta.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/meta.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/meta.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/meta_listeners.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/meta_listeners.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/meta_listeners.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/mixin.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/mixin.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/mixin.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/observer.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/observer.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/observer.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/observer_set.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/observer_set.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/observer_set.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/path_cache.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/path_cache.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/path_cache.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/property_events.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/property_events.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/property_events.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/property_get.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/property_get.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/property_get.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/property_set.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/property_set.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/property_set.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/replace.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/replace.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/replace.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/run_loop.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/run_loop.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/run_loop.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/set_properties.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/set_properties.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/set_properties.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tags.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tags.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tags.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/testing.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/testing.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/testing.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/get_path_test', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; + + var obj = undefined; + var moduleOpts = { + setup: function () { + obj = { + foo: { + bar: { + baz: { biff: 'BIFF' } + } + }, + foothis: { + bar: { + baz: { biff: 'BIFF' } + } + }, + falseValue: false, + emptyString: '', + Wuz: { + nar: 'foo' + }, + nullValue: null + }; + }, + + teardown: function () { + obj = undefined; + } + }; + + QUnit.module('Ember.get with path', moduleOpts); + + // .......................................................... + // LOCAL PATHS + // + + QUnit.test('[obj, foo] -> obj.foo', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), obj.foo); + }); + + QUnit.test('[obj, foo.bar] -> obj.foo.bar', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'foo.bar'), obj.foo.bar); + }); + + QUnit.test('[obj, foothis.bar] -> obj.foothis.bar', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'foothis.bar'), obj.foothis.bar); + }); + + QUnit.test('[obj, falseValue.notDefined] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'falseValue.notDefined'), undefined); + }); + + QUnit.test('[obj, emptyString.length] -> 0', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'emptyString.length'), 0); + }); + + QUnit.test('[obj, nullValue.notDefined] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'nullValue.notDefined'), undefined); + }); + + // .......................................................... + // GLOBAL PATHS TREATED LOCAL WITH GET + // + + QUnit.test('[obj, Wuz] -> obj.Wuz', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'Wuz'), obj.Wuz); + }); + + QUnit.test('[obj, Wuz.nar] -> obj.Wuz.nar', function () { + deepEqual(_emberMetalProperty_get.get(obj, 'Wuz.nar'), obj.Wuz.nar); + }); + + QUnit.test('[obj, Foo] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'Foo'), undefined); + }); + + QUnit.test('[obj, Foo.bar] -> (undefined)', function () { + strictEqual(_emberMetalProperty_get.get(obj, 'Foo.bar'), undefined); + }); +}); +enifed('ember-metal/tests/accessors/get_path_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/get_path_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/get_path_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/get_properties_test', ['exports', 'ember-metal/get_properties'], function (exports, _emberMetalGet_properties) { + 'use strict'; + + QUnit.module('Ember.getProperties'); + + QUnit.test('can retrieve a hash of properties from an object via an argument list or array of property names', function () { + var obj = { + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }; + + deepEqual(_emberMetalGet_properties.default(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj, 'lastName'), { lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj), {}); + deepEqual(_emberMetalGet_properties.default(obj, ['firstName', 'lastName']), { firstName: 'Steve', lastName: 'Jobs' }); + deepEqual(_emberMetalGet_properties.default(obj, ['firstName']), { firstName: 'Steve' }); + deepEqual(_emberMetalGet_properties.default(obj, []), {}); + }); +}); +enifed('ember-metal/tests/accessors/get_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/get_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/get_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/get_test', ['exports', 'internal-test-helpers', 'ember-metal/property_get', 'ember-metal/mixin', 'ember-metal/observer'], function (exports, _internalTestHelpers, _emberMetalProperty_get, _emberMetalMixin, _emberMetalObserver) { + 'use strict'; + + QUnit.module('Ember.get'); + + QUnit.test('should get arbitrary properties on an object', function () { + var obj = { + string: 'string', + number: 23, + boolTrue: true, + boolFalse: false, + nullValue: null + }; + + for (var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + equal(_emberMetalProperty_get.get(obj, key), obj[key], key); + } + }); + + QUnit.test('should not access a property more than once', function () { + var count = 0; + var obj = { + get id() { + return ++count; + } + }; + + _emberMetalProperty_get.get(obj, 'id'); + + equal(count, 1); + }); + + _internalTestHelpers.testBoth('should call unknownProperty on watched values if the value is undefined', function (get, set) { + var obj = { + count: 0, + unknownProperty: function (key) { + equal(key, 'foo', 'should pass key'); + this.count++; + return 'FOO'; + } + }; + + var count = 0; + _emberMetalObserver.addObserver(obj, 'foo', function () { + count++; + }); + + equal(get(obj, 'foo'), 'FOO', 'should return value from unknown'); + }); + + QUnit.test('warn on attemps to call get with no arguments', function () { + expectAssertion(function () { + _emberMetalProperty_get.get('aProperty'); + }, /Get must be called with two arguments;/i); + }); + + QUnit.test('warn on attemps to call get with only one argument', function () { + expectAssertion(function () { + _emberMetalProperty_get.get('aProperty'); + }, /Get must be called with two arguments;/i); + }); + + QUnit.test('warn on attemps to call get with more then two arguments', function () { + expectAssertion(function () { + _emberMetalProperty_get.get({}, 'aProperty', true); + }, /Get must be called with two arguments;/i); + }); + + QUnit.test('warn on attempts to get a property of undefined', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(undefined, 'aProperty'); + }, /Cannot call get with 'aProperty' on an undefined object/i); + }); + + QUnit.test('warn on attempts to get a property path of undefined', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(undefined, 'aProperty.on.aPath'); + }, /Cannot call get with 'aProperty.on.aPath' on an undefined object/); + }); + + QUnit.test('warn on attempts to get a property of null', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(null, 'aProperty'); + }, /Cannot call get with 'aProperty' on an undefined object/); + }); + + QUnit.test('warn on attempts to get a property path of null', function () { + expectAssertion(function () { + _emberMetalProperty_get.get(null, 'aProperty.on.aPath'); + }, /Cannot call get with 'aProperty.on.aPath' on an undefined object/); + }); + + QUnit.test('warn on attempts to use get with an unsupported property path', function () { + var obj = {}; + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, null); + }, /The key provided to get must be a string, you passed null/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, NaN); + }, /The key provided to get must be a string, you passed NaN/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, undefined); + }, /The key provided to get must be a string, you passed undefined/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, false); + }, /The key provided to get must be a string, you passed false/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, 42); + }, /The key provided to get must be a string, you passed 42/); + expectAssertion(function () { + return _emberMetalProperty_get.get(obj, ''); + }, /Cannot call `Ember.get` with an empty string/); + }); + + // .......................................................... + // BUGS + // + + QUnit.test('(regression) watched properties on unmodified inherited objects should still return their original value', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + someProperty: 'foo', + propertyDidChange: _emberMetalMixin.observer('someProperty', function () {}) + }); + + var baseObject = MyMixin.apply({}); + var theRealObject = Object.create(baseObject); + + equal(_emberMetalProperty_get.get(theRealObject, 'someProperty'), 'foo', 'should return the set value, not false'); + }); + + QUnit.module('Ember.getWithDefault'); + + QUnit.test('should get arbitrary properties on an object', function () { + var obj = { + string: 'string', + number: 23, + boolTrue: true, + boolFalse: false, + nullValue: null + }; + + for (var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + equal(_emberMetalProperty_get.getWithDefault(obj, key, 'fail'), obj[key], key); + } + + obj = { + undef: undefined + }; + + equal(_emberMetalProperty_get.getWithDefault(obj, 'undef', 'default'), 'default', 'explicit undefined retrieves the default'); + equal(_emberMetalProperty_get.getWithDefault(obj, 'not-present', 'default'), 'default', 'non-present key retrieves the default'); + }); + + QUnit.test('should call unknownProperty if defined and value is undefined', function () { + var obj = { + count: 0, + unknownProperty: function (key) { + equal(key, 'foo', 'should pass key'); + this.count++; + return 'FOO'; + } + }; + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should return value from unknown'); + equal(obj.count, 1, 'should have invoked'); + }); + + _internalTestHelpers.testBoth('if unknownProperty is present, it is called', function (get, set) { + var obj = { + count: 0, + unknownProperty: function (key) { + if (key === 'foo') { + equal(key, 'foo', 'should pass key'); + this.count++; + return 'FOO'; + } + } + }; + + var count = 0; + _emberMetalObserver.addObserver(obj, 'foo', function () { + return count++; + }); + + equal(_emberMetalProperty_get.getWithDefault(obj, 'foo', 'fail'), 'FOO', 'should return value from unknownProperty'); + equal(_emberMetalProperty_get.getWithDefault(obj, 'bar', 'default'), 'default', 'should convert undefined from unknownProperty into default'); + }); + + // .......................................................... + // BUGS + // + + QUnit.test('(regression) watched properties on unmodified inherited objects should still return their original value', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + someProperty: 'foo', + propertyDidChange: _emberMetalMixin.observer('someProperty', function () {/* nothing to do */}) + }); + + var baseObject = MyMixin.apply({}); + var theRealObject = Object.create(baseObject); + + equal(_emberMetalProperty_get.getWithDefault(theRealObject, 'someProperty', 'fail'), 'foo', 'should return the set value, not false'); + }); +}); +enifed('ember-metal/tests/accessors/get_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/get_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/get_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/is_global_path_test', ['exports', 'ember-metal/path_cache'], function (exports, _emberMetalPath_cache) { + 'use strict'; + + QUnit.module('Ember.isGlobalPath'); + + QUnit.test('global path\'s are recognized', function () { + ok(_emberMetalPath_cache.isGlobalPath('App.myProperty')); + ok(_emberMetalPath_cache.isGlobalPath('App.myProperty.subProperty')); + }); + + QUnit.test('if there is a \'this\' in the path, it\'s not a global path', function () { + ok(!_emberMetalPath_cache.isGlobalPath('this.myProperty')); + ok(!_emberMetalPath_cache.isGlobalPath('this')); + }); + + QUnit.test('if the path starts with a lowercase character, it is not a global path', function () { + ok(!_emberMetalPath_cache.isGlobalPath('myObj')); + ok(!_emberMetalPath_cache.isGlobalPath('myObj.SecondProperty')); + }); +}); +enifed('ember-metal/tests/accessors/is_global_path_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/is_global_path_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/is_global_path_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/mandatory_setters_test', ['exports', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/watching', 'ember-metal/meta'], function (exports, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWatching, _emberMetalMeta) { + 'use strict'; + + QUnit.module('mandatory-setters'); + + function hasMandatorySetter(object, property) { + try { + return Object.getOwnPropertyDescriptor(object, property).set.isMandatorySetter === true; + } catch (e) { + return false; + } + } + + function hasMetaValue(object, property) { + return _emberMetalMeta.meta(object).hasInValues(property); + } + + if (false) { + QUnit.test('does not assert if property is not being watched', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + obj.someProp = 'blastix'; + equal(_emberMetalProperty_get.get(obj, 'someProp'), 'blastix'); + }); + + QUnit.test('should not setup mandatory-setter if property is not writable', function () { + expect(6); + + var obj = {}; + + Object.defineProperty(obj, 'a', { value: true }); + Object.defineProperty(obj, 'b', { value: false }); + Object.defineProperty(obj, 'c', { value: undefined }); + Object.defineProperty(obj, 'd', { value: undefined, writable: false }); + Object.defineProperty(obj, 'e', { value: undefined, configurable: false }); + Object.defineProperty(obj, 'f', { value: undefined, configurable: true }); + + _emberMetalWatching.watch(obj, 'a'); + _emberMetalWatching.watch(obj, 'b'); + _emberMetalWatching.watch(obj, 'c'); + _emberMetalWatching.watch(obj, 'd'); + _emberMetalWatching.watch(obj, 'e'); + _emberMetalWatching.watch(obj, 'f'); + + ok(!hasMandatorySetter(obj, 'a'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'b'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'c'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'd'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'e'), 'mandatory-setter should not be installed'); + ok(!hasMandatorySetter(obj, 'f'), 'mandatory-setter should not be installed'); + }); + + QUnit.test('should not teardown non mandatory-setter descriptor', function () { + expect(1); + + var obj = { get a() { + return 'hi'; + } }; + + _emberMetalWatching.watch(obj, 'a'); + _emberMetalWatching.unwatch(obj, 'a'); + + equal(obj.a, 'hi'); + }); + + QUnit.test('should not confuse non descriptor watched gets', function () { + expect(2); + + var obj = { get a() { + return 'hi'; + } }; + + _emberMetalWatching.watch(obj, 'a'); + equal(_emberMetalProperty_get.get(obj, 'a'), 'hi'); + equal(obj.a, 'hi'); + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property', function () { + expect(2); + + var obj = { someProp: null }; + + Object.defineProperty(obj, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('watched ES5 setter should not be smashed by mandatory setter', function () { + var value = undefined; + var obj = { + get foo() {}, + set foo(_value) { + value = _value; + } + }; + + _emberMetalWatching.watch(obj, 'foo'); + + _emberMetalProperty_set.set(obj, 'foo', 2); + equal(value, 2); + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property in parent prototype', function () { + expect(2); + + function Foo() {} + + Object.defineProperty(Foo.prototype, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + var obj = new Foo(); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property in grandparent prototype', function () { + expect(2); + + function Foo() {} + + Object.defineProperty(Foo.prototype, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + function Bar() {} + Bar.prototype = Object.create(Foo.prototype); + Bar.prototype.constructor = Bar; + + var obj = new Bar(); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('should not setup mandatory-setter if setter is already setup on property in great grandparent prototype', function () { + expect(2); + + function Foo() {} + + Object.defineProperty(Foo.prototype, 'someProp', { + get: function () { + return null; + }, + + set: function (value) { + equal(value, 'foo-bar', 'custom setter was called'); + } + }); + + function Bar() {} + Bar.prototype = Object.create(Foo.prototype); + Bar.prototype.constructor = Bar; + + function Qux() {} + Qux.prototype = Object.create(Bar.prototype); + Qux.prototype.constructor = Qux; + + var obj = new Qux(); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); + + obj.someProp = 'foo-bar'; + }); + + QUnit.test('should assert if set without Ember.set when property is being watched', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + _emberMetalWatching.watch(obj, 'someProp'); + + expectAssertion(function () { + obj.someProp = 'foo-bar'; + }, 'You must use Ember.set() to set the `someProp` property (of custom-object) to `foo-bar`.'); + }); + + QUnit.test('should not assert if set with Ember.set when property is being watched', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + _emberMetalWatching.watch(obj, 'someProp'); + _emberMetalProperty_set.set(obj, 'someProp', 'foo-bar'); + + equal(_emberMetalProperty_get.get(obj, 'someProp'), 'foo-bar'); + }); + + QUnit.test('does not setup mandatory-setter if non-configurable', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + Object.defineProperty(obj, 'someProp', { + configurable: false, + enumerable: true, + value: 'blastix' + }); + + _emberMetalWatching.watch(obj, 'someProp'); + ok(!hasMandatorySetter(obj, 'someProp'), 'blastix'); + }); + + QUnit.test('ensure after watch the property is restored (and the value is no-longer stored in meta) [non-enumerable]', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + Object.defineProperty(obj, 'someProp', { + configurable: true, + enumerable: false, + value: 'blastix' + }); + + _emberMetalWatching.watch(obj, 'someProp'); + equal(hasMandatorySetter(obj, 'someProp'), true, 'should have a mandatory setter'); + + var descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + + equal(descriptor.value, undefined, 'expected existing value to NOT remain'); + + ok(hasMetaValue(obj, 'someProp'), 'someProp is stored in meta.values'); + + _emberMetalWatching.unwatch(obj, 'someProp'); + + ok(!hasMetaValue(obj, 'someProp'), 'someProp is no longer stored in meta.values'); + + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(hasMandatorySetter(obj, 'someProp'), false, 'should no longer have a mandatory setter'); + + equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + equal(descriptor.value, 'blastix', 'expected existing value to remain'); + + obj.someProp = 'new value'; + + // make sure the descriptor remains correct (nothing funky, like a redefined, happened in the setter); + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(descriptor.value, 'new value', 'expected existing value to NOT remain'); + equal(obj.someProp, 'new value', 'expected value to be the getter'); + equal(obj.someProp, 'new value'); + }); + + QUnit.test('ensure after watch the property is restored (and the value is no-longer stored in meta) [enumerable]', function () { + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + Object.defineProperty(obj, 'someProp', { + configurable: true, + enumerable: true, + value: 'blastix' + }); + + _emberMetalWatching.watch(obj, 'someProp'); + equal(hasMandatorySetter(obj, 'someProp'), true, 'should have a mandatory setter'); + + var descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, true, 'property should remain enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + + equal(descriptor.value, undefined, 'expected existing value to NOT remain'); + + ok(hasMetaValue(obj, 'someProp'), 'someProp is stored in meta.values'); + + _emberMetalWatching.unwatch(obj, 'someProp'); + + ok(!hasMetaValue(obj, 'someProp'), 'someProp is no longer stored in meta.values'); + + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(hasMandatorySetter(obj, 'someProp'), false, 'should no longer have a mandatory setter'); + + equal(descriptor.enumerable, true, 'property should remain enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(obj.someProp, 'blastix', 'expected value to be the getter'); + equal(descriptor.value, 'blastix', 'expected existing value to remain'); + + obj.someProp = 'new value'; + + // make sure the descriptor remains correct (nothing funky, like a redefined, happened in the setter); + descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); + + equal(descriptor.enumerable, true, 'property should remain enumerable'); + equal(descriptor.configurable, true, 'property should remain configurable'); + equal(descriptor.value, 'new value', 'expected existing value to NOT remain'); + equal(obj.someProp, 'new value'); + }); + + QUnit.test('sets up mandatory-setter if property comes from prototype', function () { + expect(2); + + var obj = { + someProp: null, + toString: function () { + return 'custom-object'; + } + }; + + var obj2 = Object.create(obj); + + _emberMetalWatching.watch(obj2, 'someProp'); + + ok(hasMandatorySetter(obj2, 'someProp'), 'mandatory setter has been setup'); + + expectAssertion(function () { + obj2.someProp = 'foo-bar'; + }, 'You must use Ember.set() to set the `someProp` property (of custom-object) to `foo-bar`.'); + }); + + QUnit.test('inheritance remains live', function () { + function Parent() {} + Parent.prototype.food = 'chips'; + + var child = new Parent(); + + equal(child.food, 'chips'); + + _emberMetalWatching.watch(child, 'food'); + + equal(child.food, 'chips'); + + Parent.prototype.food = 'icecreame'; + + equal(child.food, 'icecreame'); + + _emberMetalWatching.unwatch(child, 'food'); + + equal(child.food, 'icecreame'); + + Parent.prototype.food = 'chips'; + + equal(child.food, 'chips'); + }); + + QUnit.test('inheritance remains live and preserves this', function () { + function Parent(food) { + this._food = food; + } + + Object.defineProperty(Parent.prototype, 'food', { + get: function () { + return this._food; + } + }); + + var child = new Parent('chips'); + + equal(child.food, 'chips'); + + _emberMetalWatching.watch(child, 'food'); + + equal(child.food, 'chips'); + + child._food = 'icecreame'; + + equal(child.food, 'icecreame'); + + _emberMetalWatching.unwatch(child, 'food'); + + equal(child.food, 'icecreame'); + + var foodDesc = Object.getOwnPropertyDescriptor(Parent.prototype, 'food'); + ok(!foodDesc.configurable, 'Parent.prototype.food desc should be non configable'); + ok(!foodDesc.enumerable, 'Parent.prototype.food desc should be non enumerable'); + + equal(foodDesc.get.call({ + _food: 'hi' + }), 'hi'); + equal(foodDesc.set, undefined); + + equal(child.food, 'icecreame'); + }); + } +}); +enifed('ember-metal/tests/accessors/mandatory_setters_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/mandatory_setters_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/mandatory_setters_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/set_path_test', ['exports', 'ember-environment', 'ember-metal/property_set', 'ember-metal/property_get'], function (exports, _emberEnvironment, _emberMetalProperty_set, _emberMetalProperty_get) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + var obj = undefined; + function commonSetup() { + _emberEnvironment.context.lookup = lookup = {}; + obj = { + foo: { + bar: { + baz: { biff: 'BIFF' } + } + } + }; + } + + function commonTeardown() { + _emberEnvironment.context.lookup = originalLookup; + obj = null; + } + + QUnit.module('set with path', { + setup: commonSetup, + teardown: commonTeardown + }); + + QUnit.test('[Foo, bar] -> Foo.bar', function () { + lookup.Foo = { toString: function () { + return 'Foo'; + } }; // Behave like an Ember.Namespace + + _emberMetalProperty_set.set(lookup.Foo, 'bar', 'baz'); + equal(_emberMetalProperty_get.get(lookup.Foo, 'bar'), 'baz'); + }); + + // .......................................................... + // + // LOCAL PATHS + + QUnit.test('[obj, foo] -> obj.foo', function () { + _emberMetalProperty_set.set(obj, 'foo', 'BAM'); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'BAM'); + }); + + QUnit.test('[obj, foo.bar] -> obj.foo.bar', function () { + _emberMetalProperty_set.set(obj, 'foo.bar', 'BAM'); + equal(_emberMetalProperty_get.get(obj, 'foo.bar'), 'BAM'); + }); + + // .......................................................... + // DEPRECATED + // + + QUnit.module('set with path - deprecated', { + setup: commonSetup, + teardown: commonTeardown + }); + + QUnit.test('[obj, bla.bla] gives a proper exception message', function () { + var exceptionMessage = 'Property set failed: object in path \"bla\" could not be found or was destroyed.'; + try { + _emberMetalProperty_set.set(obj, 'bla.bla', 'BAM'); + } catch (ex) { + equal(ex.message, exceptionMessage); + } + }); + + QUnit.test('[obj, foo.baz.bat] -> EXCEPTION', function () { + throws(function () { + return _emberMetalProperty_set.set(obj, 'foo.baz.bat', 'BAM'); + }); + }); + + QUnit.test('[obj, foo.baz.bat] -> EXCEPTION', function () { + _emberMetalProperty_set.trySet(obj, 'foo.baz.bat', 'BAM'); + ok(true, 'does not raise'); + }); +}); +enifed('ember-metal/tests/accessors/set_path_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/set_path_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/set_path_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/accessors/set_test', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/tags'], function (exports, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalTags) { + 'use strict'; + + QUnit.module('set', { + teardown: function () { + _emberMetalTags.setHasViews(function () { + return false; + }); + } + }); + + QUnit.test('should set arbitrary properties on an object', function () { + var obj = { + string: 'string', + number: 23, + boolTrue: true, + boolFalse: false, + nullValue: null, + undefinedValue: undefined + }; + + var newObj = { + undefinedValue: 'emberjs' + }; + + for (var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + + equal(_emberMetalProperty_set.set(newObj, key, obj[key]), obj[key], 'should return value'); + equal(_emberMetalProperty_get.get(newObj, key), obj[key], 'should set value'); + } + }); + + QUnit.test('should call setUnknownProperty if defined and value is undefined', function () { + var obj = { + count: 0, + + unknownProperty: function (key, value) { + ok(false, 'should not invoke unknownProperty if setUnknownProperty is defined'); + }, + + setUnknownProperty: function (key, value) { + equal(key, 'foo', 'should pass key'); + equal(value, 'BAR', 'should pass key'); + this.count++; + return 'FOO'; + } + }; + + equal(_emberMetalProperty_set.set(obj, 'foo', 'BAR'), 'BAR', 'should return set value'); + equal(obj.count, 1, 'should have invoked'); + }); + + QUnit.test('warn on attempts to call set with undefined as object', function () { + expectAssertion(function () { + return _emberMetalProperty_set.set(undefined, 'aProperty', 'BAM'); + }, /Cannot call set with 'aProperty' on an undefined object./); + }); + + QUnit.test('warn on attempts to call set with null as object', function () { + expectAssertion(function () { + return _emberMetalProperty_set.set(null, 'aProperty', 'BAM'); + }, /Cannot call set with 'aProperty' on an undefined object./); + }); + + QUnit.test('warn on attempts to use set with an unsupported property path', function () { + var obj = {}; + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, null, 42); + }, /The key provided to set must be a string, you passed null/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, NaN, 42); + }, /The key provided to set must be a string, you passed NaN/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, undefined, 42); + }, /The key provided to set must be a string, you passed undefined/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, false, 42); + }, /The key provided to set must be a string, you passed false/); + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, 42, 42); + }, /The key provided to set must be a string, you passed 42/); + }); + + QUnit.test('warn on attempts of calling set on a destroyed object', function () { + var obj = { isDestroyed: true }; + + expectAssertion(function () { + return _emberMetalProperty_set.set(obj, 'favoriteFood', 'hot dogs'); + }, 'calling set on destroyed object: [object Object].favoriteFood = hot dogs'); + }); + + QUnit.test('does not trigger auto-run assertion for objects that have not been tagged', function (assert) { + _emberMetalTags.setHasViews(function () { + return true; + }); + var obj = {}; + + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + + assert.equal(obj.foo, 'bar'); + }); +}); +enifed('ember-metal/tests/accessors/set_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/accessors/set_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/accessors/set_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/alias_test', ['exports', 'ember-metal/alias', 'ember-metal/properties', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/watching', 'ember-metal/observer', 'ember-metal/tags'], function (exports, _emberMetalAlias, _emberMetalProperties, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMeta, _emberMetalWatching, _emberMetalObserver, _emberMetalTags) { + 'use strict'; + + var obj = undefined, + count = undefined; + + QUnit.module('ember-metal/alias', { + setup: function () { + obj = { foo: { faz: 'FOO' } }; + count = 0; + }, + teardown: function () { + obj = null; + } + }); + + function incrementCount() { + count++; + } + + QUnit.test('should proxy get to alt key', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + equal(_emberMetalProperty_get.get(obj, 'bar'), 'FOO'); + }); + + QUnit.test('should proxy set to alt key', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + _emberMetalProperty_set.set(obj, 'bar', 'BAR'); + equal(_emberMetalProperty_get.get(obj, 'foo.faz'), 'BAR'); + }); + + QUnit.test('old dependent keys should not trigger property changes', function () { + var obj1 = Object.create(null); + _emberMetalProperties.defineProperty(obj1, 'foo', null, null); + _emberMetalProperties.defineProperty(obj1, 'bar', _emberMetalAlias.default('foo')); + _emberMetalProperties.defineProperty(obj1, 'baz', _emberMetalAlias.default('foo')); + _emberMetalProperties.defineProperty(obj1, 'baz', _emberMetalAlias.default('bar')); // redefine baz + _emberMetalObserver.addObserver(obj1, 'baz', incrementCount); + + _emberMetalProperty_set.set(obj1, 'foo', 'FOO'); + equal(count, 1); + + _emberMetalObserver.removeObserver(obj1, 'baz', incrementCount); + + _emberMetalProperty_set.set(obj1, 'foo', 'OOF'); + equal(count, 1); + }); + + QUnit.test('inheriting an observer of the alias from the prototype then\n redefining the alias on the instance to another property dependent on same key\n does not call the observer twice', function () { + var obj1 = Object.create(null); + + _emberMetalMeta.meta(obj1).proto = obj1; + + _emberMetalProperties.defineProperty(obj1, 'foo', null, null); + _emberMetalProperties.defineProperty(obj1, 'bar', _emberMetalAlias.default('foo')); + _emberMetalProperties.defineProperty(obj1, 'baz', _emberMetalAlias.default('foo')); + _emberMetalObserver.addObserver(obj1, 'baz', incrementCount); + + var obj2 = Object.create(obj1); + _emberMetalProperties.defineProperty(obj2, 'baz', _emberMetalAlias.default('bar')); // override baz + + _emberMetalProperty_set.set(obj2, 'foo', 'FOO'); + equal(count, 1); + + _emberMetalObserver.removeObserver(obj2, 'baz', incrementCount); + + _emberMetalProperty_set.set(obj2, 'foo', 'OOF'); + equal(count, 1); + }); + + QUnit.test('an observer of the alias works if added after defining the alias', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + _emberMetalObserver.addObserver(obj, 'bar', incrementCount); + ok(_emberMetalWatching.isWatching(obj, 'foo.faz')); + _emberMetalProperty_set.set(obj, 'foo.faz', 'BAR'); + equal(count, 1); + }); + + QUnit.test('an observer of the alias works if added before defining the alias', function () { + _emberMetalObserver.addObserver(obj, 'bar', incrementCount); + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + ok(_emberMetalWatching.isWatching(obj, 'foo.faz')); + _emberMetalProperty_set.set(obj, 'foo.faz', 'BAR'); + equal(count, 1); + }); + + QUnit.test('object with alias is dirtied if interior object of alias is set after consumption', function () { + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('foo.faz')); + _emberMetalProperty_get.get(obj, 'bar'); + assertDirty(obj, function () { + return _emberMetalProperty_set.set(obj, 'foo.faz', 'BAR'); + }, 'setting the aliased key should dirty the object'); + }); + + QUnit.test('setting alias on self should fail assertion', function () { + expectAssertion(function () { + return _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalAlias.default('bar')); + }, 'Setting alias \'bar\' on self'); + }); + + function assertDirty(obj, callback, label) { + var tag = _emberMetalTags.tagFor(obj); + var tagValue = tag.value(); + callback(); + ok(!tag.validate(tagValue), label); + } +}); +enifed('ember-metal/tests/alias_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/alias_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/alias_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/binding/connect_test', ['exports', 'ember-environment', 'internal-test-helpers', 'ember-metal/binding', 'ember-metal/run_loop', 'ember-metal/property_set', 'ember-metal/property_get'], function (exports, _emberEnvironment, _internalTestHelpers, _emberMetalBinding, _emberMetalRun_loop, _emberMetalProperty_set, _emberMetalProperty_get) { + 'use strict'; + + function performTest(binding, a, b, get, set, connect) { + if (connect === undefined) { + connect = function () { + return binding.connect(a); + }; + } + + ok(!_emberMetalRun_loop.default.currentRunLoop, 'performTest should not have a currentRunLoop'); + + equal(get(a, 'foo'), 'FOO', 'a should not have changed'); + equal(get(b, 'bar'), 'BAR', 'b should not have changed'); + + connect(); + + equal(get(a, 'foo'), 'BAR', 'a should have changed'); + equal(get(b, 'bar'), 'BAR', 'b should have changed'); + // + // make sure changes sync both ways + _emberMetalRun_loop.default(function () { + return set(b, 'bar', 'BAZZ'); + }); + equal(get(a, 'foo'), 'BAZZ', 'a should have changed'); + + _emberMetalRun_loop.default(function () { + return set(a, 'foo', 'BARF'); + }); + equal(get(b, 'bar'), 'BARF', 'a should have changed'); + } + + var originalLookup = undefined, + lookup = undefined, + GlobalB = undefined; + + QUnit.module('Ember.Binding', { + setup: function () { + originalLookup = _emberEnvironment.context.lookup; + _emberEnvironment.context.lookup = lookup = {}; + }, + teardown: function () { + lookup = null; + _emberEnvironment.context.lookup = originalLookup; + } + }); + + _internalTestHelpers.testBoth('Connecting a binding between two properties', function (get, set) { + var a = { foo: 'FOO', bar: 'BAR' }; + + // a.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'bar'); + + expectDeprecation(function () { + performTest(binding, a, a, get, set); + }, /`Ember\.Binding` is deprecated./); + }); + + _internalTestHelpers.testBoth('Connecting a oneWay binding raises a deprecation', function (get, set) { + var a = { foo: 'FOO', bar: 'BAR', toString: function () { + return ''; + } }; + + // a.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'bar').oneWay(); + + expectDeprecation(function () { + binding.connect(a); + }, /`Ember.Binding` is deprecated/); + }); + + _internalTestHelpers.testBoth('Connecting a binding between two objects', function (get, set) { + var b = { bar: 'BAR' }; + var a = { foo: 'FOO', b: b }; + + // b.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'b.bar'); + + expectDeprecation(function () { + performTest(binding, a, b, get, set); + }, /`Ember\.Binding` is deprecated./); + }); + + _internalTestHelpers.testBoth('Connecting a binding to path', function (get, set) { + var a = { foo: 'FOO' }; + lookup['GlobalB'] = GlobalB = { + b: { bar: 'BAR' } + }; + + var b = get(GlobalB, 'b'); + + // globalB.b.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'GlobalB.b.bar'); + + expectDeprecation(function () { + performTest(binding, a, b, get, set); + }, /`Ember\.Binding` is deprecated./); + + // make sure modifications update + b = { bar: 'BIFF' }; + + _emberMetalRun_loop.default(function () { + return set(GlobalB, 'b', b); + }); + + equal(get(a, 'foo'), 'BIFF', 'a should have changed'); + }); + + _internalTestHelpers.testBoth('Calling connect more than once', function (get, set) { + var b = { bar: 'BAR' }; + var a = { foo: 'FOO', b: b }; + + // b.bar -> a.foo + var binding = new _emberMetalBinding.Binding('foo', 'b.bar'); + + expectDeprecation(function () { + performTest(binding, a, b, get, set, function () { + binding.connect(a); + binding.connect(a); + }); + }, /`Ember\.Binding` is deprecated./); + }); + + QUnit.test('inherited bindings should sync on create', function () { + var a = undefined; + _emberMetalRun_loop.default(function () { + function A() { + _emberMetalBinding.bind(this, 'foo', 'bar.baz'); + } + + expectDeprecation(function () { + return a = new A(); + }, /`Ember\.Binding` is deprecated/); + + _emberMetalProperty_set.set(a, 'bar', { baz: 'BAZ' }); + }); + + equal(_emberMetalProperty_get.get(a, 'foo'), 'BAZ', 'should have synced binding on new obj'); + }); +}); +enifed('ember-metal/tests/binding/connect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/binding/connect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/binding/connect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/binding/sync_test', ['exports', 'internal-test-helpers', 'ember-metal/run_loop', 'ember-metal/observer', 'ember-metal/binding', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/property_events'], function (exports, _internalTestHelpers, _emberMetalRun_loop, _emberMetalObserver, _emberMetalBinding, _emberMetalComputed, _emberMetalProperties, _emberMetalProperty_events) { + 'use strict'; + + QUnit.module('system/binding/sync_test.js'); + + _internalTestHelpers.testBoth('bindings should not sync twice in a single run loop', function (get, set) { + var a = undefined, + b = undefined, + setValue = undefined; + var setCalled = 0; + var getCalled = 0; + + _emberMetalRun_loop.default(function () { + a = {}; + + _emberMetalProperties.defineProperty(a, 'foo', _emberMetalComputed.computed({ + get: function (key) { + getCalled++; + return setValue; + }, + set: function (key, value) { + setCalled++; + _emberMetalProperty_events.propertyWillChange(this, key); + setValue = value; + _emberMetalProperty_events.propertyDidChange(this, key); + return value; + } + }).volatile()); + + b = { + a: a + }; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, /`Ember.Binding` is deprecated/); + }); + + // reset after initial binding synchronization + getCalled = 0; + + _emberMetalRun_loop.default(function () { + set(a, 'foo', 'trollface'); + }); + + equal(get(b, 'foo'), 'trollface', 'the binding should sync'); + equal(setCalled, 1, 'Set should only be called once'); + equal(getCalled, 1, 'Get should only be called once'); + }); + + _internalTestHelpers.testBoth('bindings should not infinite loop if computed properties return objects', function (get, set) { + var a = undefined, + b = undefined; + var getCalled = 0; + + _emberMetalRun_loop.default(function () { + a = {}; + + _emberMetalProperties.defineProperty(a, 'foo', _emberMetalComputed.computed(function () { + getCalled++; + if (getCalled > 1000) { + throw 'infinite loop detected'; + } + return ['foo', 'bar']; + })); + + b = { + a: a + }; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, /`Ember.Binding` is deprecated/); + }); + + deepEqual(get(b, 'foo'), ['foo', 'bar'], 'the binding should sync'); + equal(getCalled, 1, 'Get should only be called once'); + }); + + _internalTestHelpers.testBoth('bindings should do the right thing when observers trigger bindings in the opposite direction', function (get, set) { + var a = undefined, + b = undefined, + c = undefined; + + _emberMetalRun_loop.default(function () { + a = { + foo: 'trololol' + }; + + b = { + a: a + }; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, deprecationMessage); + + c = { + a: a + }; + + expectDeprecation(function () { + _emberMetalBinding.bind(c, 'foo', 'a.foo'); + }, deprecationMessage); + }); + + _emberMetalObserver.addObserver(b, 'foo', function () { + return set(c, 'foo', 'what is going on'); + }); + + _emberMetalRun_loop.default(function () { + return set(a, 'foo', 'trollface'); + }); + + equal(get(a, 'foo'), 'what is going on'); + }); + + _internalTestHelpers.testBoth('bindings should not try to sync destroyed objects', function (get, set) { + var a = undefined, + b = undefined; + + _emberMetalRun_loop.default(function () { + a = { + foo: 'trololol' + }; + + b = { + a: a + }; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, deprecationMessage); + }); + + _emberMetalRun_loop.default(function () { + set(a, 'foo', 'trollface'); + set(b, 'isDestroyed', true); + ok(true, 'should not raise'); + }); + + _emberMetalRun_loop.default(function () { + a = { + foo: 'trololol' + }; + + b = { + a: a + }; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + return _emberMetalBinding.bind(b, 'foo', 'a.foo'); + }, deprecationMessage); + }); + + _emberMetalRun_loop.default(function () { + set(b, 'foo', 'trollface'); + set(a, 'isDestroyed', true); + ok(true, 'should not raise'); + }); + }); +}); +enifed('ember-metal/tests/binding/sync_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/binding/sync_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/binding/sync_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/cache_test', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) { + 'use strict'; + + QUnit.module('Cache'); + + QUnit.test('basic', function () { + var cache = new _emberMetalCache.default(100, function (key) { + return key.toUpperCase(); + }); + + equal(cache.get('foo'), 'FOO'); + equal(cache.get('bar'), 'BAR'); + equal(cache.get('foo'), 'FOO'); + }); + + QUnit.test('explicit sets', function () { + var cache = new _emberMetalCache.default(100, function (key) { + return key.toUpperCase(); + }); + + equal(cache.get('foo'), 'FOO'); + + equal(cache.set('foo', 'FOO!!!'), 'FOO!!!'); + + equal(cache.get('foo'), 'FOO!!!'); + + strictEqual(cache.set('foo', undefined), undefined); + + strictEqual(cache.get('foo'), undefined); + }); + + QUnit.test('caches computation correctly', function () { + var count = 0; + var cache = new _emberMetalCache.default(100, function (key) { + count++; + return key.toUpperCase(); + }); + + equal(count, 0); + cache.get('foo'); + equal(count, 1); + cache.get('bar'); + equal(count, 2); + cache.get('bar'); + equal(count, 2); + cache.get('foo'); + equal(count, 2); + }); + + QUnit.test('caches computation correctly with custom cache keys', function () { + var count = 0; + var cache = new _emberMetalCache.default(100, function (obj) { + count++; + return obj.value.toUpperCase(); + }, function (obj) { + return obj.key; + }); + + equal(count, 0); + cache.get({ key: 'foo', value: 'foo' }); + equal(count, 1); + cache.get({ key: 'bar', value: 'bar' }); + equal(count, 2); + cache.get({ key: 'bar', value: 'bar' }); + equal(count, 2); + cache.get({ key: 'foo', value: 'foo' }); + equal(count, 2); + }); + + QUnit.test('handles undefined value correctly', function () { + var count = 0; + var cache = new _emberMetalCache.default(100, function (key) { + count++; + }); + + equal(count, 0); + strictEqual(cache.get('foo'), undefined); + equal(count, 1); + strictEqual(cache.get('bar'), undefined); + equal(count, 2); + strictEqual(cache.get('bar'), undefined); + equal(count, 2); + strictEqual(cache.get('foo'), undefined); + equal(count, 2); + }); + + QUnit.test('continues working after reaching cache limit', function () { + var cache = new _emberMetalCache.default(3, function (key) { + return key.toUpperCase(); + }); + + cache.get('a'); + cache.get('b'); + cache.get('c'); + + equal(cache.get('d'), 'D'); + equal(cache.get('a'), 'A'); + equal(cache.get('b'), 'B'); + equal(cache.get('c'), 'C'); + }); +}); +enifed('ember-metal/tests/cache_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/cache_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/cache_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/chains_test', ['exports', 'ember-metal/observer', 'ember-metal/property_get', 'ember-metal/chains', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/property_events', 'ember-metal/meta'], function (exports, _emberMetalObserver, _emberMetalProperty_get, _emberMetalChains, _emberMetalProperties, _emberMetalComputed, _emberMetalProperty_events, _emberMetalMeta) { + 'use strict'; + + QUnit.module('Chains'); + + QUnit.test('finishChains should properly copy chains from prototypes to instances', function () { + function didChange() {} + + var obj = {}; + _emberMetalObserver.addObserver(obj, 'foo.bar', null, didChange); + + var childObj = Object.create(obj); + _emberMetalChains.finishChains(childObj); + ok(_emberMetalMeta.peekMeta(obj) !== _emberMetalMeta.peekMeta(childObj).readableChains(), 'The chains object is copied'); + }); + + QUnit.test('does not observe primative values', function (assert) { + var obj = { + foo: { bar: 'STRING' } + }; + + _emberMetalObserver.addObserver(obj, 'foo.bar.baz', null, function () {}); + var meta = _emberMetalMeta.peekMeta(obj); + assert.notOk(meta._object); + }); + + QUnit.test('observer and CP chains', function () { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.default('qux.[]', function () {})); + _emberMetalProperties.defineProperty(obj, 'qux', _emberMetalComputed.default(function () {})); + + // create DK chains + _emberMetalProperty_get.get(obj, 'foo'); + + // create observer chain + _emberMetalObserver.addObserver(obj, 'qux.length', function () {}); + + /* + +-----+ + | qux | root CP + +-----+ + ^ + +------+-----+ + | | + +--------+ +----+ + | length | | [] | chainWatchers + +--------+ +----+ + observer CP(foo, 'qux.[]') + */ + + // invalidate qux + _emberMetalProperty_events.propertyDidChange(obj, 'qux'); + + // CP chain is blown away + + /* + +-----+ + | qux | root CP + +-----+ + ^ + +------+xxxxxx + | x + +--------+ xxxxxx + | length | x [] x chainWatchers + +--------+ xxxxxx + observer CP(foo, 'qux.[]') + */ + + _emberMetalProperty_get.get(obj, 'qux'); // CP chain re-recreated + ok(true, 'no crash'); + }); + + QUnit.test('checks cache correctly', function (assert) { + var obj = {}; + var parentChainNode = new _emberMetalChains.ChainNode(null, null, obj); + var chainNode = new _emberMetalChains.ChainNode(parentChainNode, 'foo'); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.default(function () { + return undefined; + })); + _emberMetalProperty_get.get(obj, 'foo'); + + assert.strictEqual(chainNode.value(), undefined); + }); +}); +enifed('ember-metal/tests/chains_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/chains_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/chains_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/computed_test', ['exports', 'ember-runtime', 'internal-test-helpers', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/watching', 'ember-metal/observer'], function (exports, _emberRuntime, _internalTestHelpers, _emberMetalComputed, _emberMetalProperties, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWatching, _emberMetalObserver) { + 'use strict'; + + var obj = undefined, + count = undefined; + + QUnit.module('computed'); + + QUnit.test('computed property should be an instance of descriptor', function () { + ok(_emberMetalComputed.computed(function () {}) instanceof _emberMetalProperties.Descriptor); + }); + + QUnit.test('computed properties assert the presence of a getter or setter function', function () { + expectAssertion(function () { + _emberMetalComputed.computed('nogetternorsetter', {}); + }, 'Computed properties must receive a getter or a setter, you passed none.'); + }); + + QUnit.test('computed properties check for the presence of a function or configuration object', function () { + expectAssertion(function () { + _emberMetalComputed.computed('nolastargument'); + }, 'Ember.computed expects a function or an object as last argument.'); + }); + + QUnit.test('computed properties defined with an object only allow `get` and `set` keys', function () { + expectAssertion(function () { + _emberMetalComputed.computed({ + get: function () {}, + set: function () {}, + other: function () {} + }); + }, 'Config object passed to an Ember.computed can only contain `get` or `set` keys.'); + }); + + QUnit.test('defining computed property should invoke property on get', function () { + var obj = {}; + var count = 0; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function (key) { + count++; + return 'computed ' + key; + })); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'computed foo', 'should return value'); + equal(count, 1, 'should have invoked computed property'); + }); + + QUnit.test('defining computed property should invoke property on set', function () { + var obj = {}; + var count = 0; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + count++; + this['__' + key] = 'computed ' + value; + return this['__' + key]; + } + })); + + equal(_emberMetalProperty_set.set(obj, 'foo', 'bar'), 'bar', 'should return set value'); + equal(count, 1, 'should have invoked computed property'); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'computed bar', 'should return new value'); + }); + + QUnit.test('defining a computed property with a dependent key ending with @each is expanded to []', function () { + var cp = _emberMetalComputed.computed('blazo.@each', function () {}); + + deepEqual(cp._dependentKeys, ['blazo.[]']); + + cp = _emberMetalComputed.computed('qux', 'zoopa.@each', function () {}); + + deepEqual(cp._dependentKeys, ['qux', 'zoopa.[]']); + }); + + QUnit.test('defining a computed property with a dependent key more than one level deep beyond @each is not supported', function () { + expectNoWarning(function () { + _emberMetalComputed.computed('todos', function () {}); + }); + + expectNoWarning(function () { + _emberMetalComputed.computed('todos.@each.owner', function () {}); + }); + + expectWarning(function () { + _emberMetalComputed.computed('todos.@each.owner.name', function () {}); + }, /You used the key "todos\.@each\.owner\.name" which is invalid\. /); + + expectWarning(function () { + _emberMetalComputed.computed('todos.@each.owner.@each.name', function () {}); + }, /You used the key "todos\.@each\.owner\.@each\.name" which is invalid\. /); + }); + + var objA = undefined, + objB = undefined; + QUnit.module('computed should inherit through prototype', { + setup: function () { + objA = { __foo: 'FOO' }; + _emberMetalProperties.defineProperty(objA, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'computed ' + value; + return this['__' + key]; + } + })); + + objB = Object.create(objA); + objB.__foo = 'FOO'; // make a copy; + }, + + teardown: function () { + objA = objB = null; + } + }); + + _internalTestHelpers.testBoth('using get() and set()', function (get, set) { + equal(get(objA, 'foo'), 'FOO', 'should get FOO from A'); + equal(get(objB, 'foo'), 'FOO', 'should get FOO from B'); + + set(objA, 'foo', 'BIFF'); + equal(get(objA, 'foo'), 'computed BIFF', 'should change A'); + equal(get(objB, 'foo'), 'FOO', 'should NOT change B'); + + set(objB, 'foo', 'bar'); + equal(get(objB, 'foo'), 'computed bar', 'should change B'); + equal(get(objA, 'foo'), 'computed BIFF', 'should NOT change A'); + + set(objA, 'foo', 'BAZ'); + equal(get(objA, 'foo'), 'computed BAZ', 'should change A'); + equal(get(objB, 'foo'), 'computed bar', 'should NOT change B'); + }); + + QUnit.module('redefining computed property to normal', { + setup: function () { + objA = { __foo: 'FOO' }; + _emberMetalProperties.defineProperty(objA, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'computed ' + value; + return this['__' + key]; + } + })); + + objB = Object.create(objA); + _emberMetalProperties.defineProperty(objB, 'foo'); // make this just a normal property. + }, + + teardown: function () { + objA = objB = null; + } + }); + + _internalTestHelpers.testBoth('using get() and set()', function (get, set) { + equal(get(objA, 'foo'), 'FOO', 'should get FOO from A'); + equal(get(objB, 'foo'), undefined, 'should get undefined from B'); + + set(objA, 'foo', 'BIFF'); + equal(get(objA, 'foo'), 'computed BIFF', 'should change A'); + equal(get(objB, 'foo'), undefined, 'should NOT change B'); + + set(objB, 'foo', 'bar'); + equal(get(objB, 'foo'), 'bar', 'should change B'); + equal(get(objA, 'foo'), 'computed BIFF', 'should NOT change A'); + + set(objA, 'foo', 'BAZ'); + equal(get(objA, 'foo'), 'computed BAZ', 'should change A'); + equal(get(objB, 'foo'), 'bar', 'should NOT change B'); + }); + + QUnit.module('redefining computed property to another property', { + setup: function () { + objA = { __foo: 'FOO' }; + _emberMetalProperties.defineProperty(objA, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'A ' + value; + return this['__' + key]; + } + })); + + objB = Object.create(objA); + objB.__foo = 'FOO'; + _emberMetalProperties.defineProperty(objB, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return this['__' + key]; + }, + set: function (key, value) { + this['__' + key] = 'B ' + value; + return this['__' + key]; + } + })); + }, + + teardown: function () { + objA = objB = null; + } + }); + + _internalTestHelpers.testBoth('using get() and set()', function (get, set) { + equal(get(objA, 'foo'), 'FOO', 'should get FOO from A'); + equal(get(objB, 'foo'), 'FOO', 'should get FOO from B'); + + set(objA, 'foo', 'BIFF'); + equal(get(objA, 'foo'), 'A BIFF', 'should change A'); + equal(get(objB, 'foo'), 'FOO', 'should NOT change B'); + + set(objB, 'foo', 'bar'); + equal(get(objB, 'foo'), 'B bar', 'should change B'); + equal(get(objA, 'foo'), 'A BIFF', 'should NOT change A'); + + set(objA, 'foo', 'BAZ'); + equal(get(objA, 'foo'), 'A BAZ', 'should change A'); + equal(get(objB, 'foo'), 'B bar', 'should NOT change B'); + }); + + QUnit.module('computed - metadata'); + + QUnit.test('can set metadata on a computed property', function () { + var computedProperty = _emberMetalComputed.computed(function () {}); + computedProperty.meta({ key: 'keyValue' }); + + equal(computedProperty.meta().key, 'keyValue', 'saves passed meta hash to the _meta property'); + }); + + QUnit.test('meta should return an empty hash if no meta is set', function () { + var computedProperty = _emberMetalComputed.computed(function () {}); + deepEqual(computedProperty.meta(), {}, 'returned value is an empty hash'); + }); + + // .......................................................... + // CACHEABLE + // + + QUnit.module('computed - cacheable', { + setup: function () { + obj = {}; + count = 0; + var func = function (key, value) { + count++; + return 'bar ' + count; + }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ get: func, set: func })); + }, + + teardown: function () { + obj = count = null; + } + }); + + _internalTestHelpers.testBoth('cacheable should cache', function (get, set) { + equal(get(obj, 'foo'), 'bar 1', 'first get'); + equal(get(obj, 'foo'), 'bar 1', 'second get'); + equal(count, 1, 'should only invoke once'); + }); + + _internalTestHelpers.testBoth('modifying a cacheable property should update cache', function (get, set) { + equal(get(obj, 'foo'), 'bar 1', 'first get'); + equal(get(obj, 'foo'), 'bar 1', 'second get'); + + equal(set(obj, 'foo', 'baz'), 'baz', 'setting'); + equal(get(obj, 'foo'), 'bar 2', 'third get'); + equal(count, 2, 'should not invoke again'); + }); + + _internalTestHelpers.testBoth('inherited property should not pick up cache', function (get, set) { + var objB = Object.create(obj); + + equal(get(obj, 'foo'), 'bar 1', 'obj first get'); + equal(get(objB, 'foo'), 'bar 2', 'objB first get'); + + equal(get(obj, 'foo'), 'bar 1', 'obj second get'); + equal(get(objB, 'foo'), 'bar 2', 'objB second get'); + + set(obj, 'foo', 'baz'); // modify A + equal(get(obj, 'foo'), 'bar 3', 'obj third get'); + equal(get(objB, 'foo'), 'bar 2', 'objB third get'); + }); + + _internalTestHelpers.testBoth('cacheFor should return the cached value', function (get, set) { + equal(_emberMetalComputed.cacheFor(obj, 'foo'), undefined, 'should not yet be a cached value'); + + get(obj, 'foo'); + + equal(_emberMetalComputed.cacheFor(obj, 'foo'), 'bar 1', 'should retrieve cached value'); + }); + + _internalTestHelpers.testBoth('cacheFor should return falsy cached values', function (get, set) { + _emberMetalProperties.defineProperty(obj, 'falsy', _emberMetalComputed.computed(function () { + return false; + })); + + equal(_emberMetalComputed.cacheFor(obj, 'falsy'), undefined, 'should not yet be a cached value'); + + get(obj, 'falsy'); + + equal(_emberMetalComputed.cacheFor(obj, 'falsy'), false, 'should retrieve cached value'); + }); + + _internalTestHelpers.testBoth('setting a cached computed property passes the old value as the third argument', function (get, set) { + var obj = { + foo: 0 + }; + + var receivedOldValue = undefined; + + _emberMetalProperties.defineProperty(obj, 'plusOne', _emberMetalComputed.computed({ + get: function () {}, + set: function (key, value, oldValue) { + receivedOldValue = oldValue; + return value; + } }).property('foo')); + + set(obj, 'plusOne', 1); + strictEqual(receivedOldValue, undefined, 'oldValue should be undefined'); + + set(obj, 'plusOne', 2); + strictEqual(receivedOldValue, 1, 'oldValue should be 1'); + + set(obj, 'plusOne', 3); + strictEqual(receivedOldValue, 2, 'oldValue should be 2'); + }); + + // .......................................................... + // DEPENDENT KEYS + // + + QUnit.module('computed - dependentkey', { + setup: function () { + obj = { bar: 'baz' }; + count = 0; + var getterAndSetter = function (key, value) { + count++; + _emberMetalProperty_get.get(this, 'bar'); + return 'bar ' + count; + }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: getterAndSetter, + set: getterAndSetter + }).property('bar')); + }, + + teardown: function () { + obj = count = null; + } + }); + + _internalTestHelpers.testBoth('should lazily watch dependent keys on set', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + set(obj, 'foo', 'bar'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily watching dependent key'); + }); + + _internalTestHelpers.testBoth('should lazily watch dependent keys on get', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + get(obj, 'foo'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily watching dependent key'); + }); + + _internalTestHelpers.testBoth('local dependent key should invalidate cache', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'get once'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'cached retrieve'); + + set(obj, 'bar', 'BIFF'); // should invalidate foo + + equal(get(obj, 'foo'), 'bar 2', 'should recache'); + equal(get(obj, 'foo'), 'bar 2', 'cached retrieve'); + }); + + _internalTestHelpers.testBoth('should invalidate multiple nested dependent keys', function (get, set) { + var count = 0; + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + count++; + get(this, 'baz'); + return 'baz ' + count; + }).property('baz')); + + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), false, 'precond not watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'get once'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), true, 'lazily setup watching dependent key'); + equal(get(obj, 'foo'), 'bar 1', 'cached retrieve'); + + set(obj, 'baz', 'BIFF'); // should invalidate bar -> foo + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'should not be watching dependent key after cache cleared'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), false, 'should not be watching dependent key after cache cleared'); + + equal(get(obj, 'foo'), 'bar 2', 'should recache'); + equal(get(obj, 'foo'), 'bar 2', 'cached retrieve'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + equal(_emberMetalWatching.isWatching(obj, 'baz'), true, 'lazily setup watching dependent key'); + }); + + _internalTestHelpers.testBoth('circular keys should not blow up', function (get, set) { + var func = function (key, value) { + count++; + return 'bar ' + count; + }; + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed({ get: func, set: func }).property('foo')); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function (key) { + count++; + return 'foo ' + count; + }).property('bar')); + + equal(get(obj, 'foo'), 'foo 1', 'get once'); + equal(get(obj, 'foo'), 'foo 1', 'cached retrieve'); + + set(obj, 'bar', 'BIFF'); // should invalidate bar -> foo -> bar + + equal(get(obj, 'foo'), 'foo 3', 'should recache'); + equal(get(obj, 'foo'), 'foo 3', 'cached retrieve'); + }); + + _internalTestHelpers.testBoth('redefining a property should undo old dependent keys', function (get, set) { + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + equal(get(obj, 'foo'), 'bar 1'); + equal(_emberMetalWatching.isWatching(obj, 'bar'), true, 'lazily watching dependent key'); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + count++; + return 'baz ' + count; + }).property('baz')); + + equal(_emberMetalWatching.isWatching(obj, 'bar'), false, 'after redefining should not be watching dependent key'); + + equal(get(obj, 'foo'), 'baz 2'); + + set(obj, 'bar', 'BIFF'); // should not kill cache + equal(get(obj, 'foo'), 'baz 2'); + + set(obj, 'baz', 'BOP'); + equal(get(obj, 'foo'), 'baz 3'); + }); + + _internalTestHelpers.testBoth('can watch multiple dependent keys specified declaratively via brace expansion', function (get, set) { + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function (key) { + count++; + return 'foo ' + count; + }).property('qux.{bar,baz}')); + + equal(get(obj, 'foo'), 'foo 1', 'get once'); + equal(get(obj, 'foo'), 'foo 1', 'cached retrieve'); + + set(obj, 'qux', {}); + set(obj, 'qux.bar', 'bar'); // invalidate foo + + equal(get(obj, 'foo'), 'foo 2', 'foo invalidated from bar'); + + set(obj, 'qux.baz', 'baz'); // invalidate foo + + equal(get(obj, 'foo'), 'foo 3', 'foo invalidated from baz'); + + set(obj, 'qux.quux', 'quux'); // do not invalidate foo + + equal(get(obj, 'foo'), 'foo 3', 'foo not invalidated by quux'); + }); + + _internalTestHelpers.testBoth('throws assertion if brace expansion notation has spaces', function (get, set) { + expectAssertion(function () { + _emberMetalProperties.defineProperty(obj, 'roo', _emberMetalComputed.computed(function (key) { + count++; + return 'roo ' + count; + }).property('fee.{bar, baz,bop , }')); + }, /cannot contain spaces/); + }); + + // .......................................................... + // CHAINED DEPENDENT KEYS + // + + var func = undefined; + var moduleOpts = { + setup: function () { + obj = { + foo: { + bar: { + baz: { + biff: 'BIFF' + } + } + } + }; + + count = 0; + func = function () { + count++; + return _emberMetalProperty_get.get(obj, 'foo.bar.baz.biff') + ' ' + count; + }; + }, + + teardown: function () { + obj = count = func = null; + } + }; + + QUnit.module('computed - dependentkey with chained properties', moduleOpts); + + _internalTestHelpers.testBoth('depending on simple chain', function (get, set) { + // assign computed property + _emberMetalProperties.defineProperty(obj, 'prop', _emberMetalComputed.computed(func).property('foo.bar.baz.biff')); + + equal(get(obj, 'prop'), 'BIFF 1'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 2'); + equal(get(obj, 'prop'), 'BUZZ 2'); + + set(get(obj, 'foo.bar'), 'baz', { biff: 'BLOB' }); + equal(get(obj, 'prop'), 'BLOB 3'); + equal(get(obj, 'prop'), 'BLOB 3'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 4'); + equal(get(obj, 'prop'), 'BUZZ 4'); + + set(get(obj, 'foo'), 'bar', { baz: { biff: 'BOOM' } }); + equal(get(obj, 'prop'), 'BOOM 5'); + equal(get(obj, 'prop'), 'BOOM 5'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 6'); + equal(get(obj, 'prop'), 'BUZZ 6'); + + set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(get(obj, 'prop'), 'BLARG 7'); + equal(get(obj, 'prop'), 'BLARG 7'); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(get(obj, 'prop'), 'BUZZ 8'); + equal(get(obj, 'prop'), 'BUZZ 8'); + + _emberMetalProperties.defineProperty(obj, 'prop'); + set(obj, 'prop', 'NONE'); + equal(get(obj, 'prop'), 'NONE'); + + set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(get(obj, 'prop'), 'NONE'); // should do nothing + equal(count, 8, 'should be not have invoked computed again'); + }); + + _internalTestHelpers.testBoth('chained dependent keys should evaluate computed properties lazily', function (get, set) { + _emberMetalProperties.defineProperty(obj.foo.bar, 'b', _emberMetalComputed.computed(func)); + _emberMetalProperties.defineProperty(obj.foo, 'c', _emberMetalComputed.computed(function () {}).property('bar.b')); + equal(count, 0, 'b should not run'); + }); + + // .......................................................... + // improved-cp-syntax + // + + QUnit.module('computed - improved cp syntax'); + + QUnit.test('setter and getters are passed using an object', function () { + var testObj = _emberRuntime.Object.extend({ + a: '1', + b: '2', + aInt: _emberMetalComputed.computed('a', { + get: function (keyName) { + equal(keyName, 'aInt', 'getter receives the keyName'); + return parseInt(this.get('a')); + }, + set: function (keyName, value, oldValue) { + equal(keyName, 'aInt', 'setter receives the keyName'); + equal(value, 123, 'setter receives the new value'); + equal(oldValue, 1, 'setter receives the old value'); + this.set('a', '' + value); // side effect + return parseInt(this.get('a')); + } + }) + }).create(); + + ok(testObj.get('aInt') === 1, 'getter works'); + testObj.set('aInt', 123); + ok(testObj.get('a') === '123', 'setter works'); + ok(testObj.get('aInt') === 123, 'cp has been updated too'); + }); + + QUnit.test('setter can be omited', function () { + var testObj = _emberRuntime.Object.extend({ + a: '1', + b: '2', + aInt: _emberMetalComputed.computed('a', { + get: function (keyName) { + equal(keyName, 'aInt', 'getter receives the keyName'); + return parseInt(this.get('a')); + } + }) + }).create(); + + ok(testObj.get('aInt') === 1, 'getter works'); + ok(testObj.get('a') === '1'); + testObj.set('aInt', '123'); + ok(testObj.get('aInt') === '123', 'cp has been updated too'); + }); + + QUnit.test('the return value of the setter gets cached', function () { + var testObj = _emberRuntime.Object.extend({ + a: '1', + sampleCP: _emberMetalComputed.computed('a', { + get: function (keyName) { + ok(false, 'The getter should not be invoked'); + return 'get-value'; + }, + set: function (keyName, value, oldValue) { + return 'set-value'; + } + }) + }).create(); + + testObj.set('sampleCP', 'abcd'); + ok(testObj.get('sampleCP') === 'set-value', 'The return value of the CP was cached'); + }); + + // .......................................................... + // BUGS + // + + QUnit.module('computed edge cases'); + + QUnit.test('adding a computed property should show up in key iteration', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () {})); + + var found = []; + for (var key in obj) { + found.push(key); + } + ok(found.indexOf('foo') >= 0, 'should find computed property in iteration found=' + found); + ok('foo' in obj, 'foo in obj should pass'); + }); + + _internalTestHelpers.testBoth('when setting a value after it had been retrieved empty don\'t pass function UNDEFINED as oldValue', function (get, set) { + var obj = {}; + var oldValueIsNoFunction = true; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () {}, + set: function (key, value, oldValue) { + if (typeof oldValue === 'function') { + oldValueIsNoFunction = false; + } + return undefined; + } + })); + + get(obj, 'foo'); + set(obj, 'foo', undefined); + + ok(oldValueIsNoFunction); + }); + + QUnit.module('computed - setter'); + + _internalTestHelpers.testBoth('setting a watched computed property', function (get, set) { + var obj = { + firstName: 'Yehuda', + lastName: 'Katz' + }; + + _emberMetalProperties.defineProperty(obj, 'fullName', _emberMetalComputed.computed({ + get: function () { + return get(this, 'firstName') + ' ' + get(this, 'lastName'); + }, + set: function (key, value) { + var values = value.split(' '); + set(this, 'firstName', values[0]); + set(this, 'lastName', values[1]); + return value; + } + }).property('firstName', 'lastName')); + + var fullNameWillChange = 0; + var fullNameDidChange = 0; + var firstNameWillChange = 0; + var firstNameDidChange = 0; + var lastNameWillChange = 0; + var lastNameDidChange = 0; + _emberMetalObserver._addBeforeObserver(obj, 'fullName', function () { + fullNameWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'fullName', function () { + fullNameDidChange++; + }); + _emberMetalObserver._addBeforeObserver(obj, 'firstName', function () { + firstNameWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'firstName', function () { + firstNameDidChange++; + }); + _emberMetalObserver._addBeforeObserver(obj, 'lastName', function () { + lastNameWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'lastName', function () { + lastNameDidChange++; + }); + + equal(get(obj, 'fullName'), 'Yehuda Katz'); + + set(obj, 'fullName', 'Yehuda Katz'); + + set(obj, 'fullName', 'Kris Selden'); + + equal(get(obj, 'fullName'), 'Kris Selden'); + equal(get(obj, 'firstName'), 'Kris'); + equal(get(obj, 'lastName'), 'Selden'); + + equal(fullNameWillChange, 1); + equal(fullNameDidChange, 1); + equal(firstNameWillChange, 1); + equal(firstNameDidChange, 1); + equal(lastNameWillChange, 1); + equal(lastNameDidChange, 1); + }); + + _internalTestHelpers.testBoth('setting a cached computed property that modifies the value you give it', function (get, set) { + var obj = { + foo: 0 + }; + + _emberMetalProperties.defineProperty(obj, 'plusOne', _emberMetalComputed.computed({ + get: function (key) { + return get(this, 'foo') + 1; + }, + set: function (key, value) { + set(this, 'foo', value); + return value + 1; + } + }).property('foo')); + + var plusOneWillChange = 0; + var plusOneDidChange = 0; + _emberMetalObserver._addBeforeObserver(obj, 'plusOne', function () { + plusOneWillChange++; + }); + _emberMetalObserver.addObserver(obj, 'plusOne', function () { + plusOneDidChange++; + }); + + equal(get(obj, 'plusOne'), 1); + set(obj, 'plusOne', 1); + equal(get(obj, 'plusOne'), 2); + set(obj, 'plusOne', 1); + equal(get(obj, 'plusOne'), 2); + + equal(plusOneWillChange, 1); + equal(plusOneDidChange, 1); + + set(obj, 'foo', 5); + equal(get(obj, 'plusOne'), 6); + + equal(plusOneWillChange, 2); + equal(plusOneDidChange, 2); + }); + + QUnit.module('computed - default setter'); + + _internalTestHelpers.testBoth('when setting a value on a computed property that doesn\'t handle sets', function (get, set) { + var obj = {}; + var observerFired = false; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return 'foo'; + })); + + _emberMetalObserver.addObserver(obj, 'foo', null, function () { + return observerFired = true; + }); + + set(obj, 'foo', 'bar'); + + equal(get(obj, 'foo'), 'bar', 'The set value is properly returned'); + ok(typeof obj.foo === 'string', 'The computed property was removed'); + ok(observerFired, 'The observer was still notified'); + }); + + QUnit.module('computed - readOnly'); + + QUnit.test('is chainable', function () { + var cp = _emberMetalComputed.computed(function () {}).readOnly(); + + ok(cp instanceof _emberMetalProperties.Descriptor); + ok(cp instanceof _emberMetalComputed.ComputedProperty); + }); + + QUnit.test('throws assertion if called over a CP with a setter defined with the new syntax', function () { + expectAssertion(function () { + _emberMetalComputed.computed({ + get: function () {}, + set: function () {} + }).readOnly(); + }, /Computed properties that define a setter using the new syntax cannot be read-only/); + }); + + _internalTestHelpers.testBoth('protects against setting', function (get, set) { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function (key) { + return 'barValue'; + }).readOnly()); + + equal(get(obj, 'bar'), 'barValue'); + + throws(function () { + set(obj, 'bar', 'newBar'); + }, /Cannot set read\-only property "bar" on object:/); + + equal(get(obj, 'bar'), 'barValue'); + }); +}); +enifed('ember-metal/tests/computed_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/computed_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/computed_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/descriptor_test', ['exports', 'ember-runtime', 'ember-metal/mixin', 'ember-metal/properties', 'ember-metal/descriptor'], function (exports, _emberRuntime, _emberMetalMixin, _emberMetalProperties, _emberMetalDescriptor) { + 'use strict'; + + // IE9 soft-fails when trying to delete a non-configurable property + var hasCompliantDelete = (function () { + var obj = {}; + + Object.defineProperty(obj, 'zomg', { configurable: false, value: 'zomg' }); + + try { + delete obj.zomg; + } catch (e) { + return true; + } + + return false; + })(); + + // IE9 soft-fails when trying to assign to a non-writable property + var hasCompliantAssign = (function () { + var obj = {}; + + Object.defineProperty(obj, 'zomg', { writable: false, value: 'zomg' }); + + try { + obj.zomg = 'lol'; + } catch (e) { + return true; + } + + return false; + })(); + + var DescriptorTest = (function () { + + /* abstract static module(title: string); */ + + DescriptorTest.test = function test(title, callback) { + var _this = this; + + QUnit.test(title, function (assert) { + callback(assert, new _this(assert)); + }); + }; + + function DescriptorTest(assert) { + this.assert = assert; + } + + /* abstract install(key: string, desc: Descriptor); */ + + /* abstract set(key: string, value: any); */ + + /* abstract finalize(): Object; */ + return DescriptorTest; + })(); + + var classes = [(function (_DescriptorTest) { + babelHelpers.inherits(_class, _DescriptorTest); + + _class.module = function module(title) { + QUnit.module(title + ': using defineProperty on an object directly'); + }; + + function _class(assert) { + _DescriptorTest.call(this, assert); + this.object = {}; + } + + _class.prototype.install = function install(key, desc) { + var object = this.object; + var assert = this.assert; + + _emberMetalProperties.defineProperty(object, key, desc); + + assert.ok(object.hasOwnProperty(key)); + }; + + _class.prototype.set = function set(key, value) { + this.object[key] = value; + }; + + _class.prototype.finalize = function finalize() { + return this.object; + }; + + _class.prototype.source = function source() { + return this.object; + }; + + return _class; + })(DescriptorTest), (function (_DescriptorTest2) { + babelHelpers.inherits(_class2, _DescriptorTest2); + + _class2.module = function module(title) { + QUnit.module(title + ': using defineProperty on a prototype'); + }; + + function _class2(assert) { + _DescriptorTest2.call(this, assert); + this.proto = {}; + } + + _class2.prototype.install = function install(key, desc) { + var proto = this.proto; + var assert = this.assert; + + _emberMetalProperties.defineProperty(proto, key, desc); + + assert.ok(proto.hasOwnProperty(key)); + }; + + _class2.prototype.set = function set(key, value) { + this.proto[key] = value; + }; + + _class2.prototype.finalize = function finalize() { + return Object.create(this.proto); + }; + + _class2.prototype.source = function source() { + return this.proto; + }; + + return _class2; + })(DescriptorTest), (function (_DescriptorTest3) { + babelHelpers.inherits(_class3, _DescriptorTest3); + + _class3.module = function module(title) { + QUnit.module(title + ': in EmberObject.extend()'); + }; + + function _class3(assert) { + _DescriptorTest3.call(this, assert); + this.klass = null; + this.props = {}; + } + + _class3.prototype.install = function install(key, desc) { + this.props[key] = desc; + }; + + _class3.prototype.set = function set(key, value) { + this.props[key] = value; + }; + + _class3.prototype.finalize = function finalize() { + this.klass = _emberRuntime.Object.extend(this.props); + return this.klass.create(); + }; + + _class3.prototype.source = function source() { + return this.klass.prototype; + }; + + return _class3; + })(DescriptorTest), (function (_DescriptorTest4) { + babelHelpers.inherits(_class4, _DescriptorTest4); + + _class4.module = function module(title) { + QUnit.module(title + ': in EmberObject.extend() through a mixin'); + }; + + function _class4(assert) { + _DescriptorTest4.call(this, assert); + this.klass = null; + this.props = {}; + } + + _class4.prototype.install = function install(key, desc) { + this.props[key] = desc; + }; + + _class4.prototype.set = function set(key, value) { + this.props[key] = value; + }; + + _class4.prototype.finalize = function finalize() { + this.klass = _emberRuntime.Object.extend(_emberMetalMixin.Mixin.create(this.props)); + return this.klass.create(); + }; + + _class4.prototype.source = function source() { + return this.klass.prototype; + }; + + return _class4; + })(DescriptorTest), (function (_DescriptorTest5) { + babelHelpers.inherits(_class5, _DescriptorTest5); + + _class5.module = function module(title) { + QUnit.module(title + ': inherited from another EmberObject super class'); + }; + + function _class5(assert) { + _DescriptorTest5.call(this, assert); + this.superklass = null; + this.props = {}; + } + + _class5.prototype.install = function install(key, desc) { + this.props[key] = desc; + }; + + _class5.prototype.set = function set(key, value) { + this.props[key] = value; + }; + + _class5.prototype.finalize = function finalize() { + this.superklass = _emberRuntime.Object.extend(this.props); + return this.superklass.extend().create(); + }; + + _class5.prototype.source = function source() { + return this.superklass.prototype; + }; + + return _class5; + })(DescriptorTest)]; + + classes.forEach(function (TestClass) { + TestClass.module('ember-metal/descriptor'); + + TestClass.test('defining a configurable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ configurable: true, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + delete source.foo; + + assert.strictEqual(obj.foo, undefined); + + Object.defineProperty(source, 'foo', { configurable: true, value: 'baz' }); + + assert.equal(obj.foo, 'baz'); + }); + + TestClass.test('defining a non-configurable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ configurable: false, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + if (hasCompliantDelete) { + assert.throws(function () { + return delete source.foo; + }, TypeError); + } else { + delete source.foo; + } + + assert.throws(function () { + return Object.defineProperty(source, 'foo', { configurable: true, value: 'baz' }); + }, TypeError); + + assert.equal(obj.foo, 'bar'); + }); + + TestClass.test('defining an enumerable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ enumerable: true, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + assert.ok(Object.keys(source).indexOf('foo') !== -1); + }); + + TestClass.test('defining a non-enumerable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ enumerable: false, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + assert.ok(Object.keys(source).indexOf('foo') === -1); + }); + + TestClass.test('defining a writable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ writable: true, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + source.foo = 'baz'; + + assert.equal(obj.foo, 'baz'); + + obj.foo = 'bat'; + + assert.equal(obj.foo, 'bat'); + }); + + TestClass.test('defining a non-writable property', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ writable: false, value: 'bar' })); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + var source = factory.source(); + + if (hasCompliantAssign) { + assert.throws(function () { + return source.foo = 'baz'; + }, TypeError); + assert.throws(function () { + return obj.foo = 'baz'; + }, TypeError); + } else { + source.foo = 'baz'; + obj.foo = 'baz'; + } + + assert.equal(obj.foo, 'bar'); + }); + + TestClass.test('defining a getter', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ + get: function () { + return this.__foo__; + } + })); + + factory.set('__foo__', 'bar'); + + var obj = factory.finalize(); + + assert.equal(obj.foo, 'bar'); + + obj.__foo__ = 'baz'; + + assert.equal(obj.foo, 'baz'); + }); + + TestClass.test('defining a setter', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ + set: function (value) { + this.__foo__ = value; + } + })); + + factory.set('__foo__', 'bar'); + + var obj = factory.finalize(); + + assert.equal(obj.__foo__, 'bar'); + + obj.foo = 'baz'; + + assert.equal(obj.__foo__, 'baz'); + }); + + TestClass.test('combining multiple setter and getters', function (assert, factory) { + factory.install('foo', _emberMetalDescriptor.default({ + get: function () { + return this.__foo__; + }, + + set: function (value) { + this.__foo__ = value; + } + })); + + factory.set('__foo__', 'foo'); + + factory.install('bar', _emberMetalDescriptor.default({ + get: function () { + return this.__bar__; + }, + + set: function (value) { + this.__bar__ = value; + } + })); + + factory.set('__bar__', 'bar'); + + factory.install('fooBar', _emberMetalDescriptor.default({ + get: function () { + return this.foo + '-' + this.bar; + } + })); + + var obj = factory.finalize(); + + assert.equal(obj.fooBar, 'foo-bar'); + + obj.foo = 'FOO'; + + assert.equal(obj.fooBar, 'FOO-bar'); + + obj.__bar__ = 'BAR'; + + assert.equal(obj.fooBar, 'FOO-BAR'); + + if (hasCompliantAssign) { + assert.throws(function () { + return obj.fooBar = 'foobar'; + }, TypeError); + } else { + obj.fooBar = 'foobar'; + } + + assert.equal(obj.fooBar, 'FOO-BAR'); + }); + }); +}); +enifed('ember-metal/tests/descriptor_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/descriptor_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/descriptor_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/error_test', ['exports', 'ember-metal/error'], function (exports, _emberMetalError) { + 'use strict'; + + QUnit.module('Ember Error Throwing'); + + QUnit.test('new Ember.Error displays provided message', function () { + throws(function () { + throw new _emberMetalError.default('A Message'); + }, function (e) { + return e.message === 'A Message'; + }, 'the assigned message was displayed'); + }); +}); +enifed('ember-metal/tests/error_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/error_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/error_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/events_test', ['exports', 'ember-metal/mixin', 'ember-metal/meta', 'ember-metal/events'], function (exports, _emberMetalMixin, _emberMetalMeta, _emberMetalEvents) { + 'use strict'; + + QUnit.module('system/props/events_test'); + + QUnit.test('listener should receive event - removing should remove', function () { + var obj = {}; + var count = 0; + + function F() { + count++; + } + + _emberMetalEvents.addListener(obj, 'event!', F); + equal(count, 0, 'nothing yet'); + + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 1, 'received event'); + + _emberMetalEvents.removeListener(obj, 'event!', F); + + count = 0; + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 0, 'received event'); + }); + + QUnit.test('listeners should be inherited', function () { + var obj = {}; + var count = 0; + var F = function () { + count++; + }; + + _emberMetalEvents.addListener(obj, 'event!', F); + + var obj2 = Object.create(obj); + + equal(count, 0, 'nothing yet'); + + _emberMetalEvents.sendEvent(obj2, 'event!'); + equal(count, 1, 'received event'); + + _emberMetalEvents.removeListener(obj2, 'event!', F); + + count = 0; + _emberMetalEvents.sendEvent(obj2, 'event!'); + equal(count, 0, 'did not receive event'); + + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 1, 'should still invoke on parent'); + }); + + QUnit.test('adding a listener more than once should only invoke once', function () { + var obj = {}; + var count = 0; + function F() { + count++; + } + _emberMetalEvents.addListener(obj, 'event!', F); + _emberMetalEvents.addListener(obj, 'event!', F); + + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(count, 1, 'should only invoke once'); + }); + + QUnit.test('adding a listener with a target should invoke with target', function () { + var obj = {}; + var target = undefined; + + target = { + count: 0, + method: function () { + this.count++; + } + }; + + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(target.count, 1, 'should invoke'); + }); + + QUnit.test('suspending a listener should not invoke during callback', function () { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + count: 0, + method: function () { + this.count++; + } + }; + + otherTarget = { + count: 0, + method: function () { + this.count++; + } + }; + + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + _emberMetalEvents.addListener(obj, 'event!', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + _emberMetalEvents.sendEvent(obj, 'event!'); + + return 'result'; + } + + _emberMetalEvents.sendEvent(obj, 'event!'); + + equal(_emberMetalEvents.suspendListener(obj, 'event!', target, target.method, callback), 'result'); + + _emberMetalEvents.sendEvent(obj, 'event!'); + + equal(target.count, 2, 'should invoke'); + equal(otherTarget.count, 3, 'should invoke'); + }); + + QUnit.test('adding a listener with string method should lookup method on event delivery', function () { + var obj = {}; + var target = undefined; + + target = { + count: 0, + method: function () {} + }; + + _emberMetalEvents.addListener(obj, 'event!', target, 'method'); + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(target.count, 0, 'should invoke but do nothing'); + + target.method = function () { + this.count++; + }; + _emberMetalEvents.sendEvent(obj, 'event!'); + equal(target.count, 1, 'should invoke now'); + }); + + QUnit.test('calling sendEvent with extra params should be passed to listeners', function () { + var obj = {}; + var params = null; + _emberMetalEvents.addListener(obj, 'event!', function () { + params = Array.prototype.slice.call(arguments); + }); + + _emberMetalEvents.sendEvent(obj, 'event!', ['foo', 'bar']); + deepEqual(params, ['foo', 'bar'], 'params should be saved'); + }); + + QUnit.test('hasListeners tells you if there are listeners for a given event', function () { + var obj = {}; + + function F() {} + function F2() {} + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'no listeners at first'); + + _emberMetalEvents.addListener(obj, 'event!', F); + _emberMetalEvents.addListener(obj, 'event!', F2); + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + + _emberMetalEvents.removeListener(obj, 'event!', F); + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + + _emberMetalEvents.removeListener(obj, 'event!', F2); + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'has no more listeners'); + + _emberMetalEvents.addListener(obj, 'event!', F); + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + }); + + QUnit.test('calling removeListener without method should remove all listeners', function () { + var obj = {}; + function F() {} + function F2() {} + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'no listeners at first'); + + _emberMetalEvents.addListener(obj, 'event!', F); + _emberMetalEvents.addListener(obj, 'event!', F2); + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), true, 'has listeners'); + _emberMetalEvents.removeListener(obj, 'event!'); + + equal(_emberMetalEvents.hasListeners(obj, 'event!'), false, 'has no more listeners'); + }); + + QUnit.test('while suspended, it should not be possible to add a duplicate listener', function () { + var obj = {}; + var target = undefined; + + target = { + count: 0, + method: function () { + this.count++; + } + }; + + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + + function callback() { + _emberMetalEvents.addListener(obj, 'event!', target, target.method); + } + + _emberMetalEvents.sendEvent(obj, 'event!'); + + _emberMetalEvents.suspendListener(obj, 'event!', target, target.method, callback); + + equal(target.count, 1, 'should invoke'); + equal(_emberMetalMeta.meta(obj).matchingListeners('event!').length, 3, 'a duplicate listener wasn\'t added'); + + // now test suspendListeners... + + _emberMetalEvents.sendEvent(obj, 'event!'); + + _emberMetalEvents.suspendListeners(obj, ['event!'], target, target.method, callback); + + equal(target.count, 2, 'should have invoked again'); + equal(_emberMetalMeta.meta(obj).matchingListeners('event!').length, 3, 'a duplicate listener wasn\'t added'); + }); + + QUnit.test('a listener can be added as part of a mixin', function () { + var triggered = 0; + var MyMixin = _emberMetalMixin.Mixin.create({ + foo1: _emberMetalEvents.on('bar', function () { + triggered++; + }), + + foo2: _emberMetalEvents.on('bar', function () { + triggered++; + }) + }); + + var obj = {}; + MyMixin.apply(obj); + + _emberMetalEvents.sendEvent(obj, 'bar'); + equal(triggered, 2, 'should invoke listeners'); + }); + + QUnit.test('a listener added as part of a mixin may be overridden', function () { + var triggered = 0; + var FirstMixin = _emberMetalMixin.Mixin.create({ + foo: _emberMetalEvents.on('bar', function () { + triggered++; + }) + }); + var SecondMixin = _emberMetalMixin.Mixin.create({ + foo: _emberMetalEvents.on('baz', function () { + triggered++; + }) + }); + + var obj = {}; + FirstMixin.apply(obj); + SecondMixin.apply(obj); + + _emberMetalEvents.sendEvent(obj, 'bar'); + equal(triggered, 0, 'should not invoke from overriden property'); + + _emberMetalEvents.sendEvent(obj, 'baz'); + equal(triggered, 1, 'should invoke from subclass property'); + }); +}); +enifed('ember-metal/tests/events_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/events_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/events_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/expand_properties_test', ['exports', 'ember-metal/expand_properties'], function (exports, _emberMetalExpand_properties) { + 'use strict'; + + var foundProperties = []; + + function addProperty(property) { + foundProperties.push(property); + } + + QUnit.module('Property Brace Expansion Test', { + setup: function () { + foundProperties = []; + } + }); + + QUnit.test('Properties without expansions are unaffected', function () { + expect(1); + + _emberMetalExpand_properties.default('a', addProperty); + _emberMetalExpand_properties.default('a.b', addProperty); + _emberMetalExpand_properties.default('a.b.[]', addProperty); + _emberMetalExpand_properties.default('a.b.@each.c', addProperty); + + deepEqual(['a', 'a.b', 'a.b.[]', 'a.b.@each.c'].sort(), foundProperties.sort()); + }); + + QUnit.test('A single expansion at the end expands properly', function () { + expect(1); + + _emberMetalExpand_properties.default('a.b.{c,d}', addProperty); + + deepEqual(['a.b.c', 'a.b.d'].sort(), foundProperties.sort()); + }); + + QUnit.test('A property with only a brace expansion expands correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('{a,b,c}', addProperty); + + var expected = ['a', 'b', 'c']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('Expansions with single properties only expand once', function () { + expect(1); + + _emberMetalExpand_properties.default('a.b.{c}.d.{e}', addProperty); + + deepEqual(['a.b.c.d.e'], foundProperties); + }); + + QUnit.test('A single brace expansion expands correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('a.{b,c,d}.e', addProperty); + + var expected = ['a.b.e', 'a.c.e', 'a.d.e']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('Multiple brace expansions work correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('{a,b,c}.d.{e,f}.g', addProperty); + + var expected = ['a.d.e.g', 'a.d.f.g', 'b.d.e.g', 'b.d.f.g', 'c.d.e.g', 'c.d.f.g']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('A property with only brace expansions expands correctly', function () { + expect(1); + + _emberMetalExpand_properties.default('{a,b,c}.{d}.{e,f}', addProperty); + + var expected = ['a.d.e', 'a.d.f', 'b.d.e', 'b.d.f', 'c.d.e', 'c.d.f']; + deepEqual(expected.sort(), foundProperties.sort()); + }); + + QUnit.test('Nested brace expansions are not allowed', function () { + var nestedBraceProperties = ['a.{b.{c,d}}', 'a.{{b}.c}', 'a.{b,c}.{d.{e,f}.g', 'a.{b.{c}', 'a.{b,c}}']; + + nestedBraceProperties.forEach(function (invalidProperties) { + expectAssertion(function () { + return _emberMetalExpand_properties.default(invalidProperties, addProperty); + }); + }, /Brace expanded properties have to be balanced and cannot be nested/); + }); + + QUnit.test('A pattern must be a string', function () { + expect(1); + + expectAssertion(function () { + _emberMetalExpand_properties.default([], addProperty); + }, /A computed property key must be a string/); + }); + + QUnit.test('A pattern must not contain a space', function () { + expect(1); + + expectAssertion(function () { + _emberMetalExpand_properties.default('a, b', addProperty); + }, /Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"/); + }); +}); +enifed('ember-metal/tests/expand_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/expand_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/expand_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/injected_property_test', ['exports', 'ember-utils', 'ember-metal/properties', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/injected_property'], function (exports, _emberUtils, _emberMetalProperties, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalInjected_property) { + 'use strict'; + + QUnit.module('InjectedProperty'); + + QUnit.test('injected properties should be descriptors', function () { + ok(new _emberMetalInjected_property.default() instanceof _emberMetalProperties.Descriptor); + }); + + QUnit.test('injected properties should be overridable', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default()); + + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'bar', 'should return the overriden value'); + }); + + QUnit.test('getting on an object without an owner or container should fail assertion', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type', 'name')); + + expectAssertion(function () { + _emberMetalProperty_get.get(obj, 'foo'); + }, /Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container./); + }); + + QUnit.test('getting on an object without an owner but with a container should not fail', function () { + var obj = { + container: { + lookup: function (key) { + ok(true, 'should call container.lookup'); + return key; + } + } + }; + + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type', 'name')); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'type:name', 'should return the value of container.lookup'); + }); + + QUnit.test('getting should return a lookup on the container', function () { + expect(2); + + var obj = {}; + + _emberUtils.setOwner(obj, { + lookup: function (key) { + ok(true, 'should call container.lookup'); + return key; + } + }); + + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type', 'name')); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'type:name', 'should return the value of container.lookup'); + }); + + QUnit.test('omitting the lookup name should default to the property name', function () { + var obj = {}; + + _emberUtils.setOwner(obj, { + lookup: function (key) { + return key; + } + }); + + _emberMetalProperties.defineProperty(obj, 'foo', new _emberMetalInjected_property.default('type')); + + equal(_emberMetalProperty_get.get(obj, 'foo'), 'type:foo', 'should lookup the type using the property name'); + }); +}); +enifed('ember-metal/tests/injected_property_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/injected_property_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/injected_property_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/instrumentation_test', ['exports', 'ember-metal/instrumentation'], function (exports, _emberMetalInstrumentation) { + 'use strict'; + + QUnit.module('Ember Instrumentation', { + teardown: function () { + _emberMetalInstrumentation.reset(); + } + }); + + QUnit.test('execute block even if no listeners', function () { + var result = _emberMetalInstrumentation.instrument('render', {}, function () { + return 'hello'; + }); + equal(result, 'hello', 'called block'); + }); + + QUnit.test('subscribing to a simple path receives the listener', function () { + expect(12); + + var sentPayload = {}; + var count = 0; + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + if (count === 0) { + strictEqual(name, 'render'); + } else { + strictEqual(name, 'render.handlebars'); + } + + ok(typeof timestamp === 'number'); + strictEqual(payload, sentPayload); + }, + + after: function (name, timestamp, payload) { + if (count === 0) { + strictEqual(name, 'render'); + } else { + strictEqual(name, 'render.handlebars'); + } + + ok(typeof timestamp === 'number'); + strictEqual(payload, sentPayload); + + count++; + } + }); + + _emberMetalInstrumentation.instrument('render', sentPayload, function () {}); + + _emberMetalInstrumentation.instrument('render.handlebars', sentPayload, function () {}); + }); + + QUnit.test('returning a value from the before callback passes it to the after callback', function () { + expect(2); + + var passthru1 = {}; + var passthru2 = {}; + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + return passthru1; + }, + after: function (name, timestamp, payload, beforeValue) { + strictEqual(beforeValue, passthru1); + } + }); + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + return passthru2; + }, + after: function (name, timestamp, payload, beforeValue) { + strictEqual(beforeValue, passthru2); + } + }); + + _emberMetalInstrumentation.instrument('render', null, function () {}); + }); + + QUnit.test('instrument with 2 args (name, callback) no payload', function () { + expect(1); + + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, {}); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', function () {}); + }); + + QUnit.test('instrument with 3 args (name, callback, binding) no payload', function () { + expect(2); + + var binding = {}; + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, {}); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', function () { + deepEqual(this, binding); + }, binding); + }); + + QUnit.test('instrument with 3 args (name, payload, callback) with payload', function () { + expect(1); + + var expectedPayload = { hi: 1 }; + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, expectedPayload); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', expectedPayload, function () {}); + }); + + QUnit.test('instrument with 4 args (name, payload, callback, binding) with payload', function () { + expect(2); + + var expectedPayload = { hi: 1 }; + var binding = {}; + _emberMetalInstrumentation.subscribe('render', { + before: function (name, timestamp, payload) { + deepEqual(payload, expectedPayload); + }, + after: function () {} + }); + + _emberMetalInstrumentation.instrument('render', expectedPayload, function () { + deepEqual(this, binding); + }, binding); + }); + + QUnit.test('raising an exception in the instrumentation attaches it to the payload', function () { + expect(2); + + var error = new Error('Instrumentation'); + + _emberMetalInstrumentation.subscribe('render', { + before: function () {}, + after: function (name, timestamp, payload) { + strictEqual(payload.exception, error); + } + }); + + _emberMetalInstrumentation.subscribe('render', { + before: function () {}, + after: function (name, timestamp, payload) { + strictEqual(payload.exception, error); + } + }); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () { + throw error; + }); + }); + + QUnit.test('it is possible to add a new subscriber after the first instrument', function () { + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + + _emberMetalInstrumentation.subscribe('render', { + before: function () { + ok(true, 'Before callback was called'); + }, + after: function () { + ok(true, 'After callback was called'); + } + }); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + }); + + QUnit.test('it is possible to remove a subscriber', function () { + expect(4); + + var count = 0; + + var subscriber = _emberMetalInstrumentation.subscribe('render', { + before: function () { + equal(count, 0); + ok(true, 'Before callback was called'); + }, + after: function () { + equal(count, 0); + ok(true, 'After callback was called'); + count++; + } + }); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + + _emberMetalInstrumentation.unsubscribe(subscriber); + + _emberMetalInstrumentation.instrument('render.handlebars', null, function () {}); + }); +}); +enifed('ember-metal/tests/instrumentation_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/instrumentation_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/instrumentation_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_blank_test', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { + 'use strict'; + + QUnit.module('Ember.isBlank'); + + QUnit.test('Ember.isBlank', function () { + var string = 'string'; + var fn = function () {}; + var object = { length: 0 }; + + equal(true, _emberMetalIs_blank.default(null), 'for null'); + equal(true, _emberMetalIs_blank.default(undefined), 'for undefined'); + equal(true, _emberMetalIs_blank.default(''), 'for an empty String'); + equal(true, _emberMetalIs_blank.default(' '), 'for a whitespace String'); + equal(true, _emberMetalIs_blank.default('\n\t'), 'for another whitespace String'); + equal(false, _emberMetalIs_blank.default('\n\t Hi'), 'for a String with whitespaces'); + equal(false, _emberMetalIs_blank.default(true), 'for true'); + equal(false, _emberMetalIs_blank.default(false), 'for false'); + equal(false, _emberMetalIs_blank.default(string), 'for a String'); + equal(false, _emberMetalIs_blank.default(fn), 'for a Function'); + equal(false, _emberMetalIs_blank.default(0), 'for 0'); + equal(true, _emberMetalIs_blank.default([]), 'for an empty Array'); + equal(false, _emberMetalIs_blank.default({}), 'for an empty Object'); + equal(true, _emberMetalIs_blank.default(object), 'for an Object that has zero \'length\''); + equal(false, _emberMetalIs_blank.default([1, 2, 3]), 'for a non-empty array'); + }); +}); +enifed('ember-metal/tests/is_blank_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_blank_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_blank_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_empty_test', ['exports', 'ember-metal/is_empty', 'ember-metal/map'], function (exports, _emberMetalIs_empty, _emberMetalMap) { + 'use strict'; + + QUnit.module('Ember.isEmpty'); + + QUnit.test('Ember.isEmpty', function () { + var string = 'string'; + var fn = function () {}; + var object = { length: 0 }; + + equal(true, _emberMetalIs_empty.default(null), 'for null'); + equal(true, _emberMetalIs_empty.default(undefined), 'for undefined'); + equal(true, _emberMetalIs_empty.default(''), 'for an empty String'); + equal(false, _emberMetalIs_empty.default(' '), 'for a whitespace String'); + equal(false, _emberMetalIs_empty.default('\n\t'), 'for another whitespace String'); + equal(false, _emberMetalIs_empty.default(true), 'for true'); + equal(false, _emberMetalIs_empty.default(false), 'for false'); + equal(false, _emberMetalIs_empty.default(string), 'for a String'); + equal(false, _emberMetalIs_empty.default(fn), 'for a Function'); + equal(false, _emberMetalIs_empty.default(0), 'for 0'); + equal(true, _emberMetalIs_empty.default([]), 'for an empty Array'); + equal(false, _emberMetalIs_empty.default({}), 'for an empty Object'); + equal(true, _emberMetalIs_empty.default(object), 'for an Object that has zero \'length\''); + }); + + QUnit.test('Ember.isEmpty Ember.Map', function () { + var map = new _emberMetalMap.Map(); + equal(true, _emberMetalIs_empty.default(map), 'Empty map is empty'); + map.set('foo', 'bar'); + equal(false, _emberMetalIs_empty.default(map), 'Map is not empty'); + }); + + QUnit.test('Ember.isEmpty Ember.OrderedSet', function () { + var orderedSet = new _emberMetalMap.OrderedSet(); + equal(true, _emberMetalIs_empty.default(orderedSet), 'Empty ordered set is empty'); + orderedSet.add('foo'); + equal(false, _emberMetalIs_empty.default(orderedSet), 'Ordered set is not empty'); + }); +}); +enifed('ember-metal/tests/is_empty_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_empty_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_empty_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_none_test', ['exports', 'ember-metal/is_none'], function (exports, _emberMetalIs_none) { + 'use strict'; + + QUnit.module('Ember.isNone'); + + QUnit.test('Ember.isNone', function () { + var string = 'string'; + var fn = function () {}; + + equal(true, _emberMetalIs_none.default(null), 'for null'); + equal(true, _emberMetalIs_none.default(undefined), 'for undefined'); + equal(false, _emberMetalIs_none.default(''), 'for an empty String'); + equal(false, _emberMetalIs_none.default(true), 'for true'); + equal(false, _emberMetalIs_none.default(false), 'for false'); + equal(false, _emberMetalIs_none.default(string), 'for a String'); + equal(false, _emberMetalIs_none.default(fn), 'for a Function'); + equal(false, _emberMetalIs_none.default(0), 'for 0'); + equal(false, _emberMetalIs_none.default([]), 'for an empty Array'); + equal(false, _emberMetalIs_none.default({}), 'for an empty Object'); + }); +}); +enifed('ember-metal/tests/is_none_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_none_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_none_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/is_present_test', ['exports', 'ember-metal/is_present'], function (exports, _emberMetalIs_present) { + 'use strict'; + + QUnit.module('Ember.isPresent'); + + QUnit.test('Ember.isPresent', function () { + var string = 'string'; + var fn = function () {}; + var object = { length: 0 }; + + equal(false, _emberMetalIs_present.default(), 'for no params'); + equal(false, _emberMetalIs_present.default(null), 'for null'); + equal(false, _emberMetalIs_present.default(undefined), 'for undefined'); + equal(false, _emberMetalIs_present.default(''), 'for an empty String'); + equal(false, _emberMetalIs_present.default(' '), 'for a whitespace String'); + equal(false, _emberMetalIs_present.default('\n\t'), 'for another whitespace String'); + equal(true, _emberMetalIs_present.default('\n\t Hi'), 'for a String with whitespaces'); + equal(true, _emberMetalIs_present.default(true), 'for true'); + equal(true, _emberMetalIs_present.default(false), 'for false'); + equal(true, _emberMetalIs_present.default(string), 'for a String'); + equal(true, _emberMetalIs_present.default(fn), 'for a Function'); + equal(true, _emberMetalIs_present.default(0), 'for 0'); + equal(false, _emberMetalIs_present.default([]), 'for an empty Array'); + equal(true, _emberMetalIs_present.default({}), 'for an empty Object'); + equal(false, _emberMetalIs_present.default(object), 'for an Object that has zero \'length\''); + equal(true, _emberMetalIs_present.default([1, 2, 3]), 'for a non-empty array'); + }); +}); +enifed('ember-metal/tests/is_present_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/is_present_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/is_present_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/libraries_test', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/libraries'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalLibraries) { + /* globals EmberDev */ + 'use strict'; + + var libs = undefined, + registry = undefined; + var originalWarn = _emberMetalDebug.getDebugFunction('warn'); + + QUnit.module('Libraries registry', { + setup: function () { + libs = new _emberMetalLibraries.Libraries(); + registry = libs._registry; + }, + + teardown: function () { + libs = null; + registry = null; + + _emberMetalDebug.setDebugFunction('warn', originalWarn); + } + }); + + QUnit.test('core libraries come before other libraries', function () { + expect(2); + + libs.register('my-lib', '2.0.0a'); + libs.registerCoreLibrary('DS', '1.0.0-beta.2'); + + equal(registry[0].name, 'DS'); + equal(registry[1].name, 'my-lib'); + }); + + QUnit.test('only the first registration of a library is stored', function () { + expect(3); + + libs.register('magic', 1.23); + libs.register('magic', 2.23); + + equal(registry[0].name, 'magic'); + equal(registry[0].version, 1.23); + equal(registry.length, 1); + }); + + if (_emberMetalFeatures.default('ember-libraries-isregistered')) { + QUnit.test('isRegistered returns correct value', function () { + expect(3); + + equal(libs.isRegistered('magic'), false); + + libs.register('magic', 1.23); + equal(libs.isRegistered('magic'), true); + + libs.deRegister('magic'); + equal(libs.isRegistered('magic'), false); + }); + } + + QUnit.test('attempting to register a library that is already registered warns you', function () { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + + expect(1); + + libs.register('magic', 1.23); + + _emberMetalDebug.setDebugFunction('warn', function (msg, test) { + if (!test) { + equal(msg, 'Library "magic" is already registered with Ember.'); + } + }); + + // Should warn us + libs.register('magic', 2.23); + }); + + QUnit.test('libraries can be de-registered', function () { + expect(2); + + libs.register('lib1', '1.0.0b'); + libs.register('lib2', '1.0.0b'); + libs.register('lib3', '1.0.0b'); + + libs.deRegister('lib1'); + libs.deRegister('lib3'); + + equal(registry[0].name, 'lib2'); + equal(registry.length, 1); + }); +}); +enifed('ember-metal/tests/libraries_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/libraries_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/libraries_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/main_test', ['exports', 'ember-metal/index'], function (exports, _emberMetalIndex) { + 'use strict'; + + // testing reexports + + // From sindresourhus/semver-regex https://github.com/sindresorhus/semver-regex/blob/795b05628d96597ebcbe6d31ef4a432858365582/index.js#L3 + var SEMVER_REGEX = /^\bv?(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b$/; + + QUnit.module('ember-metal/core/main'); + + QUnit.test('Ember registers itself', function () { + var lib = _emberMetalIndex.default.libraries._registry[0]; + + equal(lib.name, 'Ember'); + equal(lib.version, _emberMetalIndex.default.VERSION); + }); + + QUnit.test('Ember.VERSION is in alignment with SemVer v2.0.0', function () { + ok(SEMVER_REGEX.test(_emberMetalIndex.default.VERSION), 'Ember.VERSION (' + _emberMetalIndex.default.VERSION + ')is valid SemVer v2.0.0'); + }); + + QUnit.test('SEMVER_REGEX properly validates and invalidates version numbers', function () { + function validateVersionString(versionString, expectedResult) { + equal(SEMVER_REGEX.test(versionString), expectedResult); + } + + // Postive test cases + validateVersionString('1.11.3', true); + validateVersionString('1.0.0-beta.16.1', true); + validateVersionString('1.12.1+canary.aba1412', true); + validateVersionString('2.0.0-beta.1+canary.bb344775', true); + + // Negative test cases + validateVersionString('1.11.3.aba18a', false); + validateVersionString('1.11', false); + }); + + QUnit.test('Ember.keys is deprecated', function () { + expectDeprecation(function () { + _emberMetalIndex.default.keys({}); + }, 'Ember.keys is deprecated in favor of Object.keys'); + }); + + QUnit.test('Ember.create is deprecated', function () { + expectDeprecation(function () { + _emberMetalIndex.default.create(null); + }, 'Ember.create is deprecated in favor of Object.create'); + }); + + QUnit.test('Ember.Backburner is deprecated', function () { + expectDeprecation(function () { + new _emberMetalIndex.default.Backburner(['foo']); + }, 'Usage of Ember.Backburner is deprecated.'); + }); + + QUnit.test('Ember.K is deprecated', function (assert) { + expectDeprecation(function () { + var obj = { + noop: _emberMetalIndex.default.K + }; + + assert.equal(obj, obj.noop()); + }, 'Ember.K is deprecated in favor of defining a function inline.'); + }); +}); +enifed('ember-metal/tests/main_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/main_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/main_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/map_test', ['exports', 'ember-metal/map'], function (exports, _emberMetalMap) { + 'use strict'; + + var object = undefined, + number = undefined, + string = undefined, + map = undefined, + variety = undefined; + var varieties = [['Map', _emberMetalMap.Map], ['MapWithDefault', _emberMetalMap.MapWithDefault]]; + + function testMap(nameAndFunc) { + variety = nameAndFunc[0]; + + QUnit.module('Ember.' + variety + ' (forEach and get are implicitly tested)', { + setup: function () { + object = {}; + number = 42; + string = 'foo'; + + map = nameAndFunc[1].create(); + } + }); + + var mapHasLength = function (expected, theMap) { + theMap = theMap || map; + + var length = 0; + theMap.forEach(function () { + length++; + }); + + equal(length, expected, 'map should contain ' + expected + ' items'); + }; + + var mapHasEntries = function (entries, theMap) { + theMap = theMap || map; + + for (var i = 0; i < entries.length; i++) { + equal(theMap.get(entries[i][0]), entries[i][1]); + equal(theMap.has(entries[i][0]), true); + } + + mapHasLength(entries.length, theMap); + }; + + var unboundThis = undefined; + + (function () { + unboundThis = this; + })(); + + QUnit.test('set', function () { + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + map.set(object, 'losing'); + map.set(number, 'losing'); + map.set(string, 'losing'); + + mapHasEntries([[object, 'losing'], [number, 'losing'], [string, 'losing']]); + + equal(map.has('nope'), false, 'expected the key `nope` to not be present'); + equal(map.has({}), false, 'expected they key `{}` to not be present'); + }); + + QUnit.test('set chaining', function () { + map.set(object, 'winning').set(number, 'winning').set(string, 'winning'); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + map.set(object, 'losing').set(number, 'losing').set(string, 'losing'); + + mapHasEntries([[object, 'losing'], [number, 'losing'], [string, 'losing']]); + + equal(map.has('nope'), false, 'expected the key `nope` to not be present'); + equal(map.has({}), false, 'expected they key `{}` to not be present'); + }); + + QUnit.test('with key with undefined value', function () { + map.set('foo', undefined); + + map.forEach(function (value, key) { + equal(value, undefined); + equal(key, 'foo'); + }); + + ok(map.has('foo'), 'has key foo, even with undefined value'); + + equal(map.size, 1); + }); + + QUnit.test('arity of forEach is 1 – es6 23.1.3.5', function () { + equal(map.forEach.length, 1, 'expected arity for map.forEach is 1'); + }); + + QUnit.test('forEach throws without a callback as the first argument', function () { + equal(map.forEach.length, 1, 'expected arity for map.forEach is 1'); + }); + + QUnit.test('has empty collection', function () { + equal(map.has('foo'), false); + equal(map.has(), false); + }); + + QUnit.test('delete', function () { + expectNoDeprecation(); + + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + map.delete(object); + map.delete(number); + map.delete(string); + + // doesn't explode + map.delete({}); + + mapHasEntries([]); + }); + + QUnit.test('copy and then update', function () { + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + var map2 = map.copy(); + + map2.set(object, 'losing'); + map2.set(number, 'losing'); + map2.set(string, 'losing'); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + mapHasEntries([[object, 'losing'], [number, 'losing'], [string, 'losing']], map2); + }); + + QUnit.test('copy and then delete', function () { + map.set(object, 'winning'); + map.set(number, 'winning'); + map.set(string, 'winning'); + + var map2 = map.copy(); + + map2.delete(object); + map2.delete(number); + map2.delete(string); + + mapHasEntries([[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + mapHasEntries([], map2); + }); + + QUnit.test('size', function () { + //Add a key twice + equal(map.size, 0); + map.set(string, 'a string'); + equal(map.size, 1); + map.set(string, 'the same string'); + equal(map.size, 1); + + //Add another + map.set(number, 'a number'); + equal(map.size, 2); + + //Remove one that doesn't exist + map.delete('does not exist'); + equal(map.size, 2); + + //Check copy + var copy = map.copy(); + equal(copy.size, 2); + + //Remove a key twice + map.delete(number); + equal(map.size, 1); + map.delete(number); + equal(map.size, 1); + + //Remove the last key + map.delete(string); + equal(map.size, 0); + map.delete(string); + equal(map.size, 0); + }); + + QUnit.test('forEach without proper callback', function () { + QUnit.throws(function () { + map.forEach(); + }, '[object Undefined] is not a function'); + + QUnit.throws(function () { + map.forEach(undefined); + }, '[object Undefined] is not a function'); + + QUnit.throws(function () { + map.forEach(1); + }, '[object Number] is not a function'); + + QUnit.throws(function () { + map.forEach({}); + }, '[object Object] is not a function'); + + map.forEach(function (value, key) { + map.delete(key); + }); + // ensure the error happens even if no data is present + equal(map.size, 0); + QUnit.throws(function () { + map.forEach({}); + }, '[object Object] is not a function'); + }); + + QUnit.test('forEach basic', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + + var expectations = [{ value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, { value: 3, key: 'c', context: unboundThis }]; + + map.forEach(function (value, key, theMap) { + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }); + + equal(iteration, 3, 'expected 3 iterations'); + }); + + QUnit.test('forEach basic /w context', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + var context = {}; + var expectations = [{ value: 1, key: 'a', context: context }, { value: 2, key: 'b', context: context }, { value: 3, key: 'c', context: context }]; + + map.forEach(function (value, key, theMap) { + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }, context); + + equal(iteration, 3, 'expected 3 iterations'); + }); + + QUnit.test('forEach basic /w deletion while enumerating', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + + var expectations = [{ value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }]; + + map.forEach(function (value, key, theMap) { + if (iteration === 0) { + map.delete('c'); + } + + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }); + + equal(iteration, 2, 'expected 3 iterations'); + }); + + QUnit.test('forEach basic /w addition while enumerating', function () { + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + + var iteration = 0; + + var expectations = [{ value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, { value: 3, key: 'c', context: unboundThis }, { value: 4, key: 'd', context: unboundThis }]; + + map.forEach(function (value, key, theMap) { + if (iteration === 0) { + map.set('d', 4); + } + + var expectation = expectations[iteration]; + + equal(value, expectation.value, 'value should be correct'); + equal(key, expectation.key, 'key should be correct'); + equal(this, expectation.context, 'context should be as if it was unbound'); + equal(map, theMap, 'map being iterated over should be passed in'); + + iteration++; + }); + + equal(iteration, 4, 'expected 3 iterations'); + }); + + QUnit.test('clear', function () { + var iterations = 0; + + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + map.set('d', 4); + + equal(map.size, 4); + + map.forEach(function () { + iterations++; + }); + equal(iterations, 4); + + map.clear(); + equal(map.size, 0); + iterations = 0; + map.forEach(function () { + iterations++; + }); + equal(iterations, 0); + }); + + QUnit.test('-0', function () { + equal(map.has(-0), false); + equal(map.has(0), false); + + map.set(-0, 'zero'); + + equal(map.has(-0), true); + equal(map.has(0), true); + + equal(map.get(0), 'zero'); + equal(map.get(-0), 'zero'); + + map.forEach(function (value, key) { + equal(1 / key, Infinity, 'spec says key should be positive zero'); + }); + }); + + QUnit.test('NaN', function () { + equal(map.has(NaN), false); + + map.set(NaN, 'not-a-number'); + + equal(map.has(NaN), true); + + equal(map.get(NaN), 'not-a-number'); + }); + + QUnit.test('NaN Boxed', function () { + //jshint -W053 + var boxed = new Number(NaN); + equal(map.has(boxed), false); + + map.set(boxed, 'not-a-number'); + + equal(map.has(boxed), true); + equal(map.has(NaN), false); + + equal(map.get(NaN), undefined); + equal(map.get(boxed), 'not-a-number'); + }); + + QUnit.test('0 value', function () { + var obj = {}; + equal(map.has(obj), false); + + equal(map.size, 0); + map.set(obj, 0); + equal(map.size, 1); + + equal(map.has(obj), true); + equal(map.get(obj), 0); + + map.delete(obj); + equal(map.has(obj), false); + equal(map.get(obj), undefined); + equal(map.size, 0); + }); + } + + for (var i = 0; i < varieties.length; i++) { + testMap(varieties[i]); + } + + QUnit.module('MapWithDefault - default values'); + + QUnit.test('Retrieving a value that has not been set returns and sets a default value', function () { + var map = _emberMetalMap.MapWithDefault.create({ + defaultValue: function (key) { + return [key]; + } + }); + + var value = map.get('ohai'); + deepEqual(value, ['ohai']); + + strictEqual(value, map.get('ohai')); + }); + + QUnit.test('Map.prototype.constructor', function () { + var map = new _emberMetalMap.Map(); + equal(map.constructor, _emberMetalMap.Map); + }); + + QUnit.test('Map() without `new`', function () { + QUnit.throws(function () { + // jshint newcap:false + _emberMetalMap.Map(); + }, /Constructor Map requires 'new'/); + }); + + QUnit.test('MapWithDefault.prototype.constructor', function () { + var map = new _emberMetalMap.MapWithDefault({ + defaultValue: function (key) { + return key; + } + }); + equal(map.constructor, _emberMetalMap.MapWithDefault); + }); + + QUnit.test('Copying a MapWithDefault copies the default value', function () { + var map = _emberMetalMap.MapWithDefault.create({ + defaultValue: function (key) { + return [key]; + } + }); + + map.set('ohai', 1); + map.get('bai'); + + var map2 = map.copy(); + + equal(map2.get('ohai'), 1); + deepEqual(map2.get('bai'), ['bai']); + + map2.set('kthx', 3); + + deepEqual(map.get('kthx'), ['kthx']); + equal(map2.get('kthx'), 3); + + deepEqual(map2.get('default'), ['default']); + + map2.defaultValue = function (key) { + return ['tom is on', key]; + }; + + deepEqual(map2.get('drugs'), ['tom is on', 'drugs']); + }); + + QUnit.module('OrderedSet', { + setup: function () { + object = {}; + number = 42; + string = 'foo'; + + map = _emberMetalMap.OrderedSet.create(); + } + }); + + QUnit.test('OrderedSet() without `new`', function () { + QUnit.throws(function () { + // jshint newcap:false + _emberMetalMap.OrderedSet(); + }, /Constructor OrderedSet requires 'new'/); + }); + + QUnit.test('add returns the set', function () { + var obj = {}; + equal(map.add(obj), map); + equal(map.add(obj), map, 'when it is already in the set'); + }); +}); +enifed('ember-metal/tests/map_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/map_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/map_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/meta_test', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { + 'use strict'; + + QUnit.module('Ember.meta'); + + QUnit.test('should return the same hash for an object', function () { + var obj = {}; + + _emberMetalMeta.meta(obj).foo = 'bar'; + + equal(_emberMetalMeta.meta(obj).foo, 'bar', 'returns same hash with multiple calls to Ember.meta()'); + }); + + QUnit.test('meta is not enumerable', function () { + var proto = undefined, + obj = undefined, + props = undefined, + prop = undefined; + proto = { foo: 'bar' }; + _emberMetalMeta.meta(proto); + obj = Object.create(proto); + _emberMetalMeta.meta(obj); + obj.bar = 'baz'; + props = []; + for (prop in obj) { + props.push(prop); + } + deepEqual(props.sort(), ['bar', 'foo']); + if (typeof JSON !== 'undefined' && 'stringify' in JSON) { + try { + JSON.stringify(obj); + } catch (e) { + ok(false, 'meta should not fail JSON.stringify'); + } + } + }); + + QUnit.test('meta.listeners basics', function (assert) { + var t = {}; + var m = _emberMetalMeta.meta({}); + m.addToListeners('hello', t, 'm', 0); + var matching = m.matchingListeners('hello'); + assert.equal(matching.length, 3); + assert.equal(matching[0], t); + m.removeFromListeners('hello', t, 'm'); + matching = m.matchingListeners('hello'); + assert.equal(matching.length, 0); + }); + + QUnit.test('meta.listeners inheritance', function (assert) { + var target = {}; + var parent = {}; + var parentMeta = _emberMetalMeta.meta(parent); + parentMeta.addToListeners('hello', target, 'm', 0); + + var child = Object.create(parent); + var m = _emberMetalMeta.meta(child); + + var matching = m.matchingListeners('hello'); + assert.equal(matching.length, 3); + assert.equal(matching[0], target); + assert.equal(matching[1], 'm'); + assert.equal(matching[2], 0); + m.removeFromListeners('hello', target, 'm'); + matching = m.matchingListeners('hello'); + assert.equal(matching.length, 0); + matching = parentMeta.matchingListeners('hello'); + assert.equal(matching.length, 3); + }); + + QUnit.test('meta.listeners deduplication', function (assert) { + var t = {}; + var m = _emberMetalMeta.meta({}); + m.addToListeners('hello', t, 'm', 0); + m.addToListeners('hello', t, 'm', 0); + var matching = m.matchingListeners('hello'); + assert.equal(matching.length, 3); + assert.equal(matching[0], t); + }); +}); +enifed('ember-metal/tests/meta_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/meta_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/meta_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/alias_method_test', ['exports', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('aliasMethod'); + + function validateAliasMethod(obj) { + equal(obj.fooMethod(), 'FOO', 'obj.fooMethod()'); + equal(obj.barMethod(), 'FOO', 'obj.barMethod should be a copy of foo'); + } + + QUnit.test('methods of another name are aliased when the mixin is applied', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + fooMethod: function () { + return 'FOO'; + }, + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = MyMixin.apply({}); + validateAliasMethod(obj); + }); + + QUnit.test('should follow aliasMethods all the way down', function () { + var MyMixin = _emberMetalMixin.Mixin.create({ + bar: _emberMetalMixin.aliasMethod('foo'), // put first to break ordered iteration + baz: function () { + return 'baz'; + }, + foo: _emberMetalMixin.aliasMethod('baz') + }); + + var obj = MyMixin.apply({}); + equal(_emberMetalProperty_get.get(obj, 'bar')(), 'baz', 'should have followed aliasMethods'); + }); + + QUnit.test('should alias methods from other dependent mixins', function () { + var BaseMixin = _emberMetalMixin.Mixin.create({ + fooMethod: function () { + return 'FOO'; + } + }); + + var MyMixin = _emberMetalMixin.Mixin.create(BaseMixin, { + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = MyMixin.apply({}); + validateAliasMethod(obj); + }); + + QUnit.test('should alias methods from other mixins applied at same time', function () { + var BaseMixin = _emberMetalMixin.Mixin.create({ + fooMethod: function () { + return 'FOO'; + } + }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = _emberMetalMixin.mixin({}, BaseMixin, MyMixin); + validateAliasMethod(obj); + }); + + QUnit.test('should alias methods from mixins already applied on object', function () { + var BaseMixin = _emberMetalMixin.Mixin.create({ + quxMethod: function () { + return 'qux'; + } + }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + bar: _emberMetalMixin.aliasMethod('foo'), + barMethod: _emberMetalMixin.aliasMethod('fooMethod') + }); + + var obj = { + fooMethod: function () { + return 'FOO'; + } + }; + + BaseMixin.apply(obj); + MyMixin.apply(obj); + + validateAliasMethod(obj); + }); +}); +enifed('ember-metal/tests/mixin/alias_method_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/alias_method_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/alias_method_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/apply_test', ['exports', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Ember.Mixin.apply'); + + function K() {} + + QUnit.test('using apply() should apply properties', function () { + var MixinA = _emberMetalMixin.Mixin.create({ foo: 'FOO', baz: K }); + var obj = {}; + _emberMetalMixin.mixin(obj, MixinA); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'FOO', 'should apply foo'); + equal(_emberMetalProperty_get.default(obj, 'baz'), K, 'should apply foo'); + }); + + QUnit.test('applying anonymous properties', function () { + var obj = {}; + _emberMetalMixin.mixin(obj, { + foo: 'FOO', + baz: K + }); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'FOO', 'should apply foo'); + equal(_emberMetalProperty_get.default(obj, 'baz'), K, 'should apply foo'); + }); + + QUnit.test('applying null values', function () { + expectAssertion(function () { + return _emberMetalMixin.mixin({}, null); + }); + }); + + QUnit.test('applying a property with an undefined value', function () { + var obj = { tagName: '' }; + _emberMetalMixin.mixin(obj, { tagName: undefined }); + + strictEqual(_emberMetalProperty_get.default(obj, 'tagName'), ''); + }); +}); +enifed('ember-metal/tests/mixin/apply_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/apply_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/apply_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/computed_test', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/mixin', 'ember-metal/computed', 'ember-metal/properties'], function (exports, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMixin, _emberMetalComputed, _emberMetalProperties) { + 'use strict'; + + function K() { + return this; + } + + QUnit.module('Mixin Computed Properties'); + + QUnit.test('overriding computed properties', function () { + var MixinA = undefined, + MixinB = undefined, + MixinC = undefined, + MixinD = undefined; + var obj = undefined; + + MixinA = _emberMetalMixin.Mixin.create({ + aProp: _emberMetalComputed.computed(function () { + return 'A'; + }) + }); + + MixinB = _emberMetalMixin.Mixin.create(MixinA, { + aProp: _emberMetalComputed.computed(function () { + return this._super.apply(this, arguments) + 'B'; + }) + }); + + MixinC = _emberMetalMixin.Mixin.create(MixinA, { + aProp: _emberMetalComputed.computed(function () { + return this._super.apply(this, arguments) + 'C'; + }) + }); + + MixinD = _emberMetalMixin.Mixin.create({ + aProp: _emberMetalComputed.computed(function () { + return this._super.apply(this, arguments) + 'D'; + }) + }); + + obj = {}; + MixinB.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'AB', 'should expose super for B'); + + obj = {}; + MixinC.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'AC', 'should expose super for C'); + + obj = {}; + + MixinA.apply(obj); + MixinD.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'AD', 'should define super for D'); + + obj = {}; + _emberMetalProperties.defineProperty(obj, 'aProp', _emberMetalComputed.computed(function (key) { + return 'obj'; + })); + MixinD.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'aProp'), 'objD', 'should preserve original computed property'); + }); + + QUnit.test('calling set on overridden computed properties', function () { + var SuperMixin = undefined, + SubMixin = undefined; + var obj = undefined; + + var superGetOccurred = false; + var superSetOccurred = false; + + SuperMixin = _emberMetalMixin.Mixin.create({ + aProp: _emberMetalComputed.computed({ + get: function (key) { + superGetOccurred = true; + }, + set: function (key, value) { + superSetOccurred = true; + } + }) + }); + + SubMixin = _emberMetalMixin.Mixin.create(SuperMixin, { + aProp: _emberMetalComputed.computed({ + get: function (key) { + return this._super.apply(this, arguments); + }, + set: function (key, value) { + return this._super.apply(this, arguments); + } + }) + }); + + obj = {}; + SubMixin.apply(obj); + + _emberMetalProperty_set.set(obj, 'aProp', 'set thyself'); + ok(superSetOccurred, 'should pass set to _super'); + + superSetOccurred = false; // reset the set assertion + + obj = {}; + SubMixin.apply(obj); + + _emberMetalProperty_get.get(obj, 'aProp'); + ok(superGetOccurred, 'should pass get to _super'); + + _emberMetalProperty_set.set(obj, 'aProp', 'set thyself'); + ok(superSetOccurred, 'should pass set to _super after getting'); + }); + + QUnit.test('setter behavior works properly when overriding computed properties', function () { + var obj = {}; + + var MixinA = _emberMetalMixin.Mixin.create({ + cpWithSetter2: _emberMetalComputed.computed(K), + cpWithSetter3: _emberMetalComputed.computed(K), + cpWithoutSetter: _emberMetalComputed.computed(K) + }); + + var cpWasCalled = false; + + var MixinB = _emberMetalMixin.Mixin.create({ + cpWithSetter2: _emberMetalComputed.computed({ + get: K, + set: function (k, v) { + cpWasCalled = true; + } + }), + + cpWithSetter3: _emberMetalComputed.computed({ + get: K, + set: function (k, v) { + cpWasCalled = true; + } + }), + + cpWithoutSetter: _emberMetalComputed.computed(function (k) { + cpWasCalled = true; + }) + }); + + MixinA.apply(obj); + MixinB.apply(obj); + + _emberMetalProperty_set.set(obj, 'cpWithSetter2', 'test'); + ok(cpWasCalled, 'The computed property setter was called when defined with two args'); + cpWasCalled = false; + + _emberMetalProperty_set.set(obj, 'cpWithSetter3', 'test'); + ok(cpWasCalled, 'The computed property setter was called when defined with three args'); + cpWasCalled = false; + + _emberMetalProperty_set.set(obj, 'cpWithoutSetter', 'test'); + equal(_emberMetalProperty_get.get(obj, 'cpWithoutSetter'), 'test', 'The default setter was called, the value is correct'); + ok(!cpWasCalled, 'The default setter was called, not the CP itself'); + }); +}); +enifed('ember-metal/tests/mixin/computed_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/computed_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/computed_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/concatenated_properties_test', ['exports', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin concatenatedProperties'); + + QUnit.test('defining concatenated properties should concat future version', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: ['a', 'b', 'c'] + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: ['d', 'e', 'f'] + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f']); + }); + + QUnit.test('defining concatenated properties should concat future version', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: null + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: null + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + + deepEqual(obj.concatenatedProperties, []); + }); + + QUnit.test('concatenatedProperties should be concatenated', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: ['a', 'b', 'c'] + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: 'bar', + foo: ['d', 'e', 'f'], + bar: [1, 2, 3] + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + bar: [4, 5, 6] + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB, MixinC); + deepEqual(_emberMetalProperty_get.default(obj, 'concatenatedProperties'), ['foo', 'bar'], 'get concatenatedProperties'); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f'], 'get foo'); + deepEqual(_emberMetalProperty_get.default(obj, 'bar'), [1, 2, 3, 4, 5, 6], 'get bar'); + }); + + QUnit.test('adding a prop that is not an array should make array', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: [1, 2, 3] + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: 4 + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), [1, 2, 3, 4]); + }); + + QUnit.test('adding a prop that is not an array should make array', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: 'bar' + }); + + var obj = _emberMetalMixin.mixin({}, MixinA); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), ['bar']); + }); + + QUnit.test('adding a non-concatenable property that already has a defined value should result in an array with both values', function () { + var mixinA = _emberMetalMixin.Mixin.create({ + foo: 1 + }); + + var mixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foo'], + foo: 2 + }); + + var obj = _emberMetalMixin.mixin({}, mixinA, mixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foo'), [1, 2]); + }); + + QUnit.test('adding a concatenable property that already has a defined value should result in a concatenated value', function () { + var mixinA = _emberMetalMixin.Mixin.create({ + foobar: 'foo' + }); + + var mixinB = _emberMetalMixin.Mixin.create({ + concatenatedProperties: ['foobar'], + foobar: 'bar' + }); + + var obj = _emberMetalMixin.mixin({}, mixinA, mixinB); + deepEqual(_emberMetalProperty_get.default(obj, 'foobar'), ['foo', 'bar']); + }); +}); +enifed('ember-metal/tests/mixin/concatenated_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/concatenated_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/concatenated_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/detect_test', ['exports', 'ember-metal/mixin'], function (exports, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin.detect'); + + QUnit.test('detect() finds a directly applied mixin', function () { + var MixinA = _emberMetalMixin.Mixin.create(); + var obj = {}; + + equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); + + MixinA.apply(obj); + equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); + }); + + QUnit.test('detect() finds nested mixins', function () { + var MixinA = _emberMetalMixin.Mixin.create({}); + var MixinB = _emberMetalMixin.Mixin.create(MixinA); + var obj = {}; + + equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); + + MixinB.apply(obj); + equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); + }); + + QUnit.test('detect() finds mixins on other mixins', function () { + var MixinA = _emberMetalMixin.Mixin.create({}); + var MixinB = _emberMetalMixin.Mixin.create(MixinA); + equal(MixinA.detect(MixinB), true, 'MixinA is part of MixinB'); + equal(MixinB.detect(MixinA), false, 'MixinB is not part of MixinA'); + }); + + QUnit.test('detect handles null values', function () { + var MixinA = _emberMetalMixin.Mixin.create(); + equal(MixinA.detect(null), false); + }); +}); +enifed('ember-metal/tests/mixin/detect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/detect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/detect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/introspection_test', ['exports', 'ember-utils', 'ember-metal/mixin'], function (exports, _emberUtils, _emberMetalMixin) { + // NOTE: A previous iteration differentiated between public and private props + // as well as methods vs props. We are just keeping these for testing; the + // current impl doesn't care about the differences as much... + + 'use strict'; + + var PrivateProperty = _emberMetalMixin.Mixin.create({ + _foo: '_FOO' + }); + var PublicProperty = _emberMetalMixin.Mixin.create({ + foo: 'FOO' + }); + var PrivateMethod = _emberMetalMixin.Mixin.create({ + _fooMethod: function () {} + }); + var PublicMethod = _emberMetalMixin.Mixin.create({ + fooMethod: function () {} + }); + var BarProperties = _emberMetalMixin.Mixin.create({ + _bar: '_BAR', + bar: 'bar' + }); + var BarMethods = _emberMetalMixin.Mixin.create({ + _barMethod: function () {}, + barMethod: function () {} + }); + + var Combined = _emberMetalMixin.Mixin.create(BarProperties, BarMethods); + + var obj = undefined; + + QUnit.module('Basic introspection', { + setup: function () { + obj = {}; + _emberMetalMixin.mixin(obj, PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined); + } + }); + + QUnit.test('Ember.mixins()', function () { + function mapGuids(ary) { + return ary.map(function (x) { + return _emberUtils.guidFor(x); + }); + } + + deepEqual(mapGuids(_emberMetalMixin.Mixin.mixins(obj)), mapGuids([PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined, BarProperties, BarMethods]), 'should return included mixins'); + }); +}); +enifed('ember-metal/tests/mixin/introspection_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/introspection_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/introspection_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/merged_properties_test', ['exports', 'ember-runtime', 'ember-metal/property_get', 'ember-metal/mixin'], function (exports, _emberRuntime, _emberMetalProperty_get, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin mergedProperties'); + + QUnit.test('defining mergedProperties should merge future version', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: { d: true, e: true, f: true } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }); + }); + + QUnit.test('defining mergedProperties on future mixin should merged into past', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { d: true, e: true, f: true } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }); + }); + + QUnit.test('defining mergedProperties with null properties should keep properties null', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: null + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: null + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + equal(_emberMetalProperty_get.get(obj, 'foo'), null); + }); + + QUnit.test('mergedProperties\' properties can get overwritten', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: 1 } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: { a: 2 } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: 2 }); + }); + + QUnit.test('mergedProperties should be concatenated', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + mergedProperties: 'bar', + foo: { d: true, e: true, f: true }, + bar: { a: true, l: true } + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + bar: { e: true, x: true } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB, MixinC); + deepEqual(_emberMetalProperty_get.get(obj, 'mergedProperties'), ['foo', 'bar'], 'get mergedProperties'); + deepEqual(_emberMetalProperty_get.get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }, 'get foo'); + deepEqual(_emberMetalProperty_get.get(obj, 'bar'), { a: true, l: true, e: true, x: true }, 'get bar'); + }); + + QUnit.test('mergedProperties should exist even if not explicitly set on create', function () { + var AnObj = _emberRuntime.Object.extend({ + mergedProperties: ['options'], + options: { + a: 'a', + b: { + c: 'ccc' + } + } + }); + + var obj = AnObj.create({ + options: { + a: 'A' + } + }); + + equal(_emberMetalProperty_get.get(obj, 'options').a, 'A'); + equal(_emberMetalProperty_get.get(obj, 'options').b.c, 'ccc'); + }); + + QUnit.test('defining mergedProperties at create time should not modify the prototype', function () { + var AnObj = _emberRuntime.Object.extend({ + mergedProperties: ['options'], + options: { + a: 1 + } + }); + + var objA = AnObj.create({ + options: { + a: 2 + } + }); + var objB = AnObj.create({ + options: { + a: 3 + } + }); + + equal(_emberMetalProperty_get.get(objA, 'options').a, 2); + equal(_emberMetalProperty_get.get(objB, 'options').a, 3); + }); + + QUnit.test('mergedProperties\' overwriting methods can call _super', function () { + expect(4); + + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { + meth: function (a) { + equal(a, 'WOOT', '_super successfully called MixinA\'s `foo.meth` method'); + return 'WAT'; + } + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: { + meth: function (a) { + ok(true, 'MixinB\'s `foo.meth` method called'); + return this._super.apply(this, arguments); + } + } + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + foo: { + meth: function (a) { + ok(true, 'MixinC\'s `foo.meth` method called'); + return this._super(a); + } + } + }); + + var obj = _emberMetalMixin.mixin({}, MixinA, MixinB, MixinC); + equal(obj.foo.meth('WOOT'), 'WAT'); + }); + + QUnit.test('Merging an Array should raise an error', function () { + expect(1); + + var MixinA = _emberMetalMixin.Mixin.create({ + mergedProperties: ['foo'], + foo: { a: true, b: true, c: true } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: ['a'] + }); + + expectAssertion(function () { + _emberMetalMixin.mixin({}, MixinA, MixinB); + }, 'You passed in `["a"]` as the value for `foo` but `foo` cannot be an Array'); + }); +}); +enifed('ember-metal/tests/mixin/merged_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/merged_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/merged_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/method_test', ['exports', 'ember-metal/mixin'], function (exports, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Mixin Methods'); + + QUnit.test('defining simple methods', function () { + var MixinA = undefined, + obj = undefined, + props = undefined; + + props = { + publicMethod: function () { + return 'publicMethod'; + }, + _privateMethod: function () { + return 'privateMethod'; + } + }; + + MixinA = _emberMetalMixin.Mixin.create(props); + obj = {}; + MixinA.apply(obj); + + // but should be defined + equal(props.publicMethod(), 'publicMethod', 'publicMethod is func'); + equal(props._privateMethod(), 'privateMethod', 'privateMethod is func'); + }); + + QUnit.test('overriding public methods', function () { + var MixinA = undefined, + MixinB = undefined, + MixinD = undefined, + MixinF = undefined, + obj = undefined; + + MixinA = _emberMetalMixin.Mixin.create({ + publicMethod: function () { + return 'A'; + } + }); + + MixinB = _emberMetalMixin.Mixin.create(MixinA, { + publicMethod: function () { + return this._super.apply(this, arguments) + 'B'; + } + }); + + MixinD = _emberMetalMixin.Mixin.create(MixinA, { + publicMethod: function () { + return this._super.apply(this, arguments) + 'D'; + } + }); + + MixinF = _emberMetalMixin.Mixin.create({ + publicMethod: function () { + return this._super.apply(this, arguments) + 'F'; + } + }); + + obj = {}; + MixinB.apply(obj); + equal(obj.publicMethod(), 'AB', 'should define super for A and B'); + + obj = {}; + MixinD.apply(obj); + equal(obj.publicMethod(), 'AD', 'should define super for A and B'); + + obj = {}; + MixinA.apply(obj); + MixinF.apply(obj); + equal(obj.publicMethod(), 'AF', 'should define super for A and F'); + + obj = { publicMethod: function () { + return 'obj'; + } }; + MixinF.apply(obj); + equal(obj.publicMethod(), 'objF', 'should define super for F'); + }); + + QUnit.test('overriding inherited objects', function () { + var cnt = 0; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + cnt++; + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + cnt++; + } + }); + + var objA = {}; + MixinA.apply(objA); + + var objB = Object.create(objA); + MixinB.apply(objB); + + cnt = 0; + objB.foo(); + equal(cnt, 2, 'should invoke both methods'); + + cnt = 0; + objA.foo(); + equal(cnt, 1, 'should not screw w/ parent obj'); + }); + + QUnit.test('Including the same mixin more than once will only run once', function () { + var cnt = 0; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + cnt++; + } + }); + + var MixinB = _emberMetalMixin.Mixin.create(MixinA, { + foo: function () { + this._super.apply(this, arguments); + } + }); + + var MixinC = _emberMetalMixin.Mixin.create(MixinA, { + foo: function () { + this._super.apply(this, arguments); + } + }); + + var MixinD = _emberMetalMixin.Mixin.create(MixinB, MixinC, MixinA, { + foo: function () { + this._super.apply(this, arguments); + } + }); + + var obj = {}; + MixinD.apply(obj); + MixinA.apply(obj); // try to apply again.. + + cnt = 0; + obj.foo(); + + equal(cnt, 1, 'should invoke MixinA.foo one time'); + }); + + QUnit.test('_super from a single mixin with no superclass does not error', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + } + }); + + var obj = {}; + MixinA.apply(obj); + + obj.foo(); + ok(true); + }); + + QUnit.test('_super from a first-of-two mixins with no superclass function does not error', function () { + // _super was previously calling itself in the second assertion. + // Use remaining count of calls to ensure it doesn't loop indefinitely. + var remaining = 3; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + if (remaining-- > 0) { + this._super.apply(this, arguments); + } + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + } + }); + + var obj = {}; + MixinA.apply(obj); + MixinB.apply(obj); + + obj.foo(); + ok(true); + }); + + // .......................................................... + // CONFLICTS + // + + QUnit.module('Method Conflicts'); + + QUnit.test('overriding toString', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + toString: function () { + return 'FOO'; + } + }); + + var obj = {}; + MixinA.apply(obj); + equal(obj.toString(), 'FOO', 'should override toString w/o error'); + + obj = {}; + _emberMetalMixin.mixin(obj, { toString: function () { + return 'FOO'; + } }); + equal(obj.toString(), 'FOO', 'should override toString w/o error'); + }); + + // .......................................................... + // BUGS + // + + QUnit.module('system/mixin/method_test BUGS'); + + QUnit.test('applying several mixins at once with sup already defined causes infinite loop', function () { + var cnt = 0; + var MixinA = _emberMetalMixin.Mixin.create({ + foo: function () { + cnt++; + } + }); + + var MixinB = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + cnt++; + } + }); + + var MixinC = _emberMetalMixin.Mixin.create({ + foo: function () { + this._super.apply(this, arguments); + cnt++; + } + }); + + var obj = {}; + _emberMetalMixin.mixin(obj, MixinA); // sup already exists + _emberMetalMixin.mixin(obj, MixinB, MixinC); // must be more than one mixin + + cnt = 0; + obj.foo(); + equal(cnt, 3, 'should invoke all 3 methods'); + }); +}); +enifed('ember-metal/tests/mixin/method_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/method_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/method_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/observer_test', ['exports', 'internal-test-helpers', 'ember-metal/mixin', 'ember-metal/watching'], function (exports, _internalTestHelpers, _emberMetalMixin, _emberMetalWatching) { + 'use strict'; + + QUnit.module('Mixin observer'); + + _internalTestHelpers.testBoth('global observer helper', function (get, set) { + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + + foo: _emberMetalMixin.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('global observer helper takes multiple params', function (get, set) { + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + + foo: _emberMetalMixin.observer('bar', 'baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 2, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('replacing observer should remove old observer', function (get, set) { + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + + foo: _emberMetalMixin.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + + }); + + var Mixin2 = _emberMetalMixin.Mixin.create({ + foo: _emberMetalMixin.observer('baz', function () { + set(this, 'count', get(this, 'count') + 10); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin, Mixin2); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 10, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property before', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + bar: obj2, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property after', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }), + bar: obj2 + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property in mixin applied later', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj2 }); + + var obj = _emberMetalMixin.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + MyMixin2.apply(obj); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with existing property', function (get, set) { + var obj2 = { baz: 'baz' }; + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({ bar: obj2 }, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property in mixin before', function (get, set) { + var obj2 = { baz: 'baz' }; + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj2 }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin2, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with property in mixin after', function (get, set) { + var obj2 = { baz: 'baz' }; + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj2 }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({}, MyMixin, MyMixin2); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observing chain with overriden property', function (get, set) { + var obj2 = { baz: 'baz' }; + var obj3 = { baz: 'foo' }; + + var MyMixin2 = _emberMetalMixin.Mixin.create({ bar: obj3 }); + + var MyMixin = _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = _emberMetalMixin.mixin({ bar: obj2 }, MyMixin, MyMixin2); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + equal(_emberMetalWatching.isWatching(obj2, 'baz'), false, 'should not be watching baz'); + equal(_emberMetalWatching.isWatching(obj3, 'baz'), true, 'should be watching baz'); + + set(obj2, 'baz', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj3, 'baz', 'BEAR'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('providing the arguments in reverse order is deprecated', function (get, set) { + expectDeprecation(/Passing the dependentKeys after the callback function in Ember\.observer is deprecated. Ensure the callback function is the last argument/); + + _emberMetalMixin.Mixin.create({ + count: 0, + foo: _emberMetalMixin.observer(function () { + set(this, 'count', get(this, 'count') + 1); + }, 'bar.baz') + }); + }); +}); +enifed('ember-metal/tests/mixin/observer_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/observer_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/observer_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/reopen_test', ['exports', 'ember-metal/run_loop', 'ember-metal/property_get', 'ember-runtime', 'ember-metal/mixin'], function (exports, _emberMetalRun_loop, _emberMetalProperty_get, _emberRuntime, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Ember.Mixin#reopen'); + + QUnit.test('using reopen() to add more properties to a simple', function () { + var MixinA = _emberMetalMixin.default.create({ foo: 'FOO', baz: 'BAZ' }); + MixinA.reopen({ bar: 'BAR', foo: 'FOO2' }); + var obj = {}; + MixinA.apply(obj); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'FOO2', 'mixin() should override'); + equal(_emberMetalProperty_get.default(obj, 'baz'), 'BAZ', 'preserve MixinA props'); + equal(_emberMetalProperty_get.default(obj, 'bar'), 'BAR', 'include MixinB props'); + }); + + QUnit.test('using reopen() and calling _super where there is not a super function does not cause infinite recursion', function () { + var Taco = _emberRuntime.Object.extend({ + createBreakfast: function () { + // There is no original createBreakfast function. + // Calling the wrapped _super function here + // used to end in an infinite call loop + this._super.apply(this, arguments); + return 'Breakfast!'; + } + }); + + Taco.reopen({ + createBreakfast: function () { + return this._super.apply(this, arguments); + } + }); + + var taco = Taco.create(); + + var result = undefined; + _emberMetalRun_loop.default(function () { + try { + result = taco.createBreakfast(); + } catch (e) { + result = 'Your breakfast was interrupted by an infinite stack error.'; + } + }); + + equal(result, 'Breakfast!'); + }); +}); +enifed('ember-metal/tests/mixin/reopen_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/reopen_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/reopen_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/required_test', ['exports', 'ember-metal/mixin', 'ember-metal/property_get'], function (exports, _emberMetalMixin, _emberMetalProperty_get) { + 'use strict'; + + var PartialMixin = undefined, + FinalMixin = undefined, + obj = undefined; + + QUnit.module('Module.required', { + setup: function () { + expectDeprecation(function () { + PartialMixin = _emberMetalMixin.Mixin.create({ + foo: _emberMetalMixin.required(), + bar: 'BAR' + }); + }, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.'); + + FinalMixin = _emberMetalMixin.Mixin.create({ + foo: 'FOO' + }); + + obj = {}; + }, + + teardown: function () { + PartialMixin = FinalMixin = obj = null; + } + }); + + QUnit.test('applying a mixin to meet requirement', function () { + FinalMixin.apply(obj); + PartialMixin.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('combined mixins to meet requirement', function () { + _emberMetalMixin.Mixin.create(PartialMixin, FinalMixin).apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('merged mixin', function () { + _emberMetalMixin.Mixin.create(PartialMixin, { foo: 'FOO' }).apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('define property on source object', function () { + obj.foo = 'FOO'; + PartialMixin.apply(obj); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); + + QUnit.test('using apply', function () { + _emberMetalMixin.mixin(obj, PartialMixin, { foo: 'FOO' }); + equal(_emberMetalProperty_get.get(obj, 'foo'), 'FOO', 'should now be defined'); + }); +}); +enifed('ember-metal/tests/mixin/required_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/required_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/required_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/mixin/without_test', ['exports', 'ember-metal/mixin'], function (exports, _emberMetalMixin) { + 'use strict'; + + QUnit.test('without should create a new mixin excluding named properties', function () { + var MixinA = _emberMetalMixin.Mixin.create({ + foo: 'FOO', + bar: 'BAR' + }); + + var MixinB = MixinA.without('bar'); + + var obj = {}; + MixinB.apply(obj); + + equal(obj.foo, 'FOO', 'should defined foo'); + equal(obj.bar, undefined, 'should not define bar'); + }); +}); +enifed('ember-metal/tests/mixin/without_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/mixin/without_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/mixin/without_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/observer_test', ['exports', 'ember-environment', 'internal-test-helpers', 'ember-metal/observer', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/run_loop'], function (exports, _emberEnvironment, _internalTestHelpers, _emberMetalObserver, _emberMetalProperty_events, _emberMetalProperties, _emberMetalComputed, _emberMetalMixin, _emberMetalRun_loop) { + 'use strict'; + + function K() {} + + // .......................................................... + // ADD OBSERVER + // + + QUnit.module('addObserver'); + + _internalTestHelpers.testBoth('observer should fire when property is modified', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'bar', 'should invoke AFTER value changed'); + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('observer should fire when dependent property is modified', function (get, set) { + var obj = { bar: 'bar' }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toUpperCase(); + }).property('bar')); + + get(obj, 'foo'); + + var count = 0; + _emberMetalObserver.addObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'BAZ', 'should have invoked after prop change'); + count++; + }); + + set(obj, 'bar', 'baz'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('observer should continue to fire after dependent properties are accessed', function (get, set) { + var observerCount = 0; + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'prop', _emberMetalComputed.computed(function () { + return Math.random(); + })); + _emberMetalProperties.defineProperty(obj, 'anotherProp', _emberMetalComputed.computed('prop', function () { + return get(this, 'prop') + Math.random(); + })); + + _emberMetalObserver.addObserver(obj, 'prop', function () { + observerCount++; + }); + + get(obj, 'anotherProp'); + + for (var i = 0; i < 10; i++) { + _emberMetalProperty_events.propertyWillChange(obj, 'prop'); + _emberMetalProperty_events.propertyDidChange(obj, 'prop'); + } + + equal(observerCount, 10, 'should continue to fire indefinitely'); + }); + + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + _internalTestHelpers.testBoth('observer added declaratively via brace expansion should fire when property changes', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalMixin.mixin(obj, { + observeFooAndBar: (function () { + count++; + }).observes('{foo,bar}') + }); + + set(obj, 'foo', 'foo'); + equal(count, 1, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'bar', 'bar'); + equal(count, 2, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'baz', 'baz'); + equal(count, 2, 'observer not invoked on unspecified property'); + }); + + _internalTestHelpers.testBoth('observer specified declaratively via brace expansion should fire when dependent property changes', function (get, set) { + var obj = { baz: 'Initial' }; + var count = 0; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toLowerCase(); + }).property('bar')); + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + return get(this, 'baz').toUpperCase(); + }).property('baz')); + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: (function () { + count++; + }).observes('{foo,bar}') + }); + + get(obj, 'foo'); + set(obj, 'baz', 'Baz'); + // fire once for foo, once for bar + equal(count, 2, 'observer specified via brace expansion invoked on dependent property change'); + + set(obj, 'quux', 'Quux'); + equal(count, 2, 'observer not fired on unspecified property'); + }); + } + + _internalTestHelpers.testBoth('observers watching multiple properties via brace expansion should fire when the properties change', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalMixin.mixin(obj, { + observeFooAndBar: _emberMetalMixin.observer('{foo,bar}', function () { + count++; + }) + }); + + set(obj, 'foo', 'foo'); + equal(count, 1, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'bar', 'bar'); + equal(count, 2, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'baz', 'baz'); + equal(count, 2, 'observer not invoked on unspecified property'); + }); + + _internalTestHelpers.testBoth('observers watching multiple properties via brace expansion should fire when dependent properties change', function (get, set) { + var obj = { baz: 'Initial' }; + var count = 0; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toLowerCase(); + }).property('bar')); + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + return get(this, 'baz').toUpperCase(); + }).property('baz')); + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: _emberMetalMixin.observer('{foo,bar}', function () { + count++; + }) + }); + + get(obj, 'foo'); + set(obj, 'baz', 'Baz'); + // fire once for foo, once for bar + equal(count, 2, 'observer specified via brace expansion invoked on dependent property change'); + + set(obj, 'quux', 'Quux'); + equal(count, 2, 'observer not fired on unspecified property'); + }); + + _internalTestHelpers.testBoth('nested observers should fire in order', function (get, set) { + var obj = { foo: 'foo', bar: 'bar' }; + var fooCount = 0; + var barCount = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + fooCount++; + }); + _emberMetalObserver.addObserver(obj, 'bar', function () { + set(obj, 'foo', 'BAZ'); + equal(fooCount, 1, 'fooCount should have fired already'); + barCount++; + }); + + set(obj, 'bar', 'BIFF'); + equal(barCount, 1, 'barCount should have fired'); + equal(fooCount, 1, 'foo should have fired'); + }); + + _internalTestHelpers.testBoth('removing an chain observer on change should not fail', function (get, set) { + var foo = { bar: 'bar' }; + var obj1 = { foo: foo }; + var obj2 = { foo: foo }; + var obj3 = { foo: foo }; + var obj4 = { foo: foo }; + var count1 = 0; + var count2 = 0; + var count3 = 0; + var count4 = 0; + + function observer1() { + count1++; + } + function observer2() { + count2++; + } + function observer3() { + count3++; + _emberMetalObserver.removeObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver.removeObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver.removeObserver(obj4, 'foo.bar', observer4); + } + function observer4() { + count4++; + } + + _emberMetalObserver.addObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver.addObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver.addObserver(obj3, 'foo.bar', observer3); + _emberMetalObserver.addObserver(obj4, 'foo.bar', observer4); + + set(foo, 'bar', 'baz'); + + equal(count1, 1, 'observer1 fired'); + equal(count2, 1, 'observer2 fired'); + equal(count3, 1, 'observer3 fired'); + equal(count4, 0, 'observer4 did not fire'); + }); + + _internalTestHelpers.testBoth('removing an chain before observer on change should not fail', function (get, set) { + var foo = { bar: 'bar' }; + var obj1 = { foo: foo }; + var obj2 = { foo: foo }; + var obj3 = { foo: foo }; + var obj4 = { foo: foo }; + var count1 = 0; + var count2 = 0; + var count3 = 0; + var count4 = 0; + + function observer1() { + count1++; + } + function observer2() { + count2++; + } + function observer3() { + count3++; + _emberMetalObserver._removeBeforeObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver._removeBeforeObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver._removeBeforeObserver(obj4, 'foo.bar', observer4); + } + function observer4() { + count4++; + } + + _emberMetalObserver._addBeforeObserver(obj1, 'foo.bar', observer1); + _emberMetalObserver._addBeforeObserver(obj2, 'foo.bar', observer2); + _emberMetalObserver._addBeforeObserver(obj3, 'foo.bar', observer3); + _emberMetalObserver._addBeforeObserver(obj4, 'foo.bar', observer4); + + set(foo, 'bar', 'baz'); + + equal(count1, 1, 'observer1 fired'); + equal(count2, 1, 'observer2 fired'); + equal(count3, 1, 'observer3 fired'); + equal(count4, 0, 'observer4 did not fire'); + }); + + _internalTestHelpers.testBoth('suspending an observer should not fire during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + equal(_emberMetalObserver._suspendObserver(obj, 'foo', target, target.method, callback), 'result'); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('suspending an observer should not defer change notifications during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + _emberMetalProperty_events.beginPropertyChanges(); + equal(_emberMetalObserver._suspendObserver(obj, 'foo', target, target.method, callback), 'result'); + _emberMetalProperty_events.endPropertyChanges(); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('suspending observers should not fire during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + equal(_emberMetalObserver._suspendObservers(obj, ['foo'], target, target.method, callback), 'result'); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('suspending observers should not defer change notifications during callback', function (get, set) { + var obj = {}; + var target = undefined, + otherTarget = undefined; + + target = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + otherTarget = { + values: [], + method: function () { + this.values.push(get(obj, 'foo')); + } + }; + + _emberMetalObserver.addObserver(obj, 'foo', target, target.method); + _emberMetalObserver.addObserver(obj, 'foo', otherTarget, otherTarget.method); + + function callback() { + /*jshint validthis:true */ + equal(this, target); + + set(obj, 'foo', '2'); + + return 'result'; + } + + set(obj, 'foo', '1'); + + _emberMetalProperty_events.beginPropertyChanges(); + equal(_emberMetalObserver._suspendObservers(obj, ['foo'], target, target.method, callback), 'result'); + _emberMetalProperty_events.endPropertyChanges(); + + set(obj, 'foo', '3'); + + deepEqual(target.values, ['1', '3'], 'should invoke'); + deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke'); + }); + + _internalTestHelpers.testBoth('deferring property change notifications', function (get, set) { + var obj = { foo: 'foo' }; + var fooCount = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + fooCount++; + }); + + _emberMetalProperty_events.beginPropertyChanges(obj); + set(obj, 'foo', 'BIFF'); + set(obj, 'foo', 'BAZ'); + _emberMetalProperty_events.endPropertyChanges(obj); + + equal(fooCount, 1, 'foo should have fired once'); + }); + + _internalTestHelpers.testBoth('deferring property change notifications safely despite exceptions', function (get, set) { + var obj = { foo: 'foo' }; + var fooCount = 0; + var exc = new Error('Something unexpected happened!'); + + expect(2); + _emberMetalObserver.addObserver(obj, 'foo', function () { + fooCount++; + }); + + try { + _emberMetalProperty_events.changeProperties(function () { + set(obj, 'foo', 'BIFF'); + set(obj, 'foo', 'BAZ'); + throw exc; + }); + } catch (err) { + if (err !== exc) { + throw err; + } + } + + equal(fooCount, 1, 'foo should have fired once'); + + _emberMetalProperty_events.changeProperties(function () { + set(obj, 'foo', 'BIFF2'); + set(obj, 'foo', 'BAZ2'); + }); + + equal(fooCount, 2, 'foo should have fired again once'); + }); + + _internalTestHelpers.testBoth('deferring property change notifications will not defer before observers', function (get, set) { + var obj = { foo: 'foo' }; + var fooCount = 0; + + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + fooCount++; + }); + + _emberMetalProperty_events.beginPropertyChanges(obj); + set(obj, 'foo', 'BIFF'); + equal(fooCount, 1, 'should fire before observer immediately'); + set(obj, 'foo', 'BAZ'); + _emberMetalProperty_events.endPropertyChanges(obj); + + equal(fooCount, 1, 'should not fire before observer twice'); + }); + + _internalTestHelpers.testBoth('addObserver should propagate through prototype', function (get, set) { + var obj = { foo: 'foo', count: 0 }; + var obj2 = undefined; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + this.count++; + }); + obj2 = Object.create(obj); + + set(obj2, 'foo', 'bar'); + + equal(obj2.count, 1, 'should have invoked observer on inherited'); + equal(obj.count, 0, 'should not have invoked observer on parent'); + + obj2.count = 0; + set(obj, 'foo', 'baz'); + equal(obj.count, 1, 'should have invoked observer on parent'); + equal(obj2.count, 0, 'should not have invoked observer on inherited'); + }); + + _internalTestHelpers.testBoth('addObserver should respect targets with methods', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + didChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target1, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'BAZ', 'param3 should new value'); + this.count++; + } + }; + + var target2 = { + count: 0, + + didChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target2, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'BAZ', 'param3 should new value'); + this.count++; + } + }; + + _emberMetalObserver.addObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.addObserver(observed, 'foo', target2, target2.didChange); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + }); + + _internalTestHelpers.testBoth('addObserver should allow multiple objects to observe a property', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + didChange: function (obj, keyName, value) { + this.count++; + } + }; + + var target2 = { + count: 0, + + didChange: function (obj, keyName, value) { + this.count++; + } + }; + + _emberMetalObserver.addObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.addObserver(observed, 'foo', target2, 'didChange'); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + }); + + // .......................................................... + // REMOVE OBSERVER + // + + QUnit.module('removeObserver'); + + _internalTestHelpers.testBoth('removing observer should stop firing', function (get, set) { + var obj = {}; + var count = 0; + function F() { + count++; + } + _emberMetalObserver.addObserver(obj, 'foo', F); + + set(obj, 'foo', 'bar'); + equal(count, 1, 'should have invoked observer'); + + _emberMetalObserver.removeObserver(obj, 'foo', F); + + set(obj, 'foo', 'baz'); + equal(count, 1, 'removed observer shouldn\'t fire'); + }); + + _internalTestHelpers.testBoth('local observers can be removed', function (get, set) { + var barObserved = 0; + + var MyMixin = _emberMetalMixin.Mixin.create({ + foo1: _emberMetalMixin.observer('bar', function () { + barObserved++; + }), + + foo2: _emberMetalMixin.observer('bar', function () { + barObserved++; + }) + }); + + var obj = {}; + MyMixin.apply(obj); + + set(obj, 'bar', 'HI!'); + equal(barObserved, 2, 'precond - observers should be fired'); + + _emberMetalObserver.removeObserver(obj, 'bar', null, 'foo1'); + + barObserved = 0; + set(obj, 'bar', 'HI AGAIN!'); + + equal(barObserved, 1, 'removed observers should not be called'); + }); + + _internalTestHelpers.testBoth('removeObserver should respect targets with methods', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + didChange: function () { + this.count++; + } + }; + + var target2 = { + count: 0, + + didChange: function () { + this.count++; + } + }; + + _emberMetalObserver.addObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.addObserver(observed, 'foo', target2, target2.didChange); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + + _emberMetalObserver.removeObserver(observed, 'foo', target1, 'didChange'); + _emberMetalObserver.removeObserver(observed, 'foo', target2, target2.didChange); + + target1.count = target2.count = 0; + set(observed, 'foo', 'BAZ'); + equal(target1.count, 0, 'target1 observer should not fire again'); + equal(target2.count, 0, 'target2 observer should not fire again'); + }); + + // .......................................................... + // BEFORE OBSERVER + // + + QUnit.module('_addBeforeObserver'); + + _internalTestHelpers.testBoth('observer should fire before a property is modified', function (get, set) { + var obj = { foo: 'foo' }; + var count = 0; + + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'foo', 'should invoke before value changed'); + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('observer should fire before dependent property is modified', function (get, set) { + var obj = { bar: 'bar' }; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toUpperCase(); + }).property('bar')); + + get(obj, 'foo'); + + var count = 0; + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + equal(get(obj, 'foo'), 'BAR', 'should have invoked after prop change'); + count++; + }); + + set(obj, 'bar', 'baz'); + equal(count, 1, 'should have invoked observer'); + }); + + _internalTestHelpers.testBoth('before observer watching multiple properties via brace expansion should fire when properties change', function (get, set) { + var obj = {}; + var count = 0; + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: _emberMetalMixin._beforeObserver('{foo,bar}', function () { + count++; + }) + }); + + set(obj, 'foo', 'foo'); + equal(count, 1, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'bar', 'bar'); + equal(count, 2, 'observer specified via brace expansion invoked on property change'); + + set(obj, 'baz', 'baz'); + equal(count, 2, 'observer not invoked on unspecified property'); + }); + + _internalTestHelpers.testBoth('before observer watching multiple properties via brace expansion should fire when dependent property changes', function (get, set) { + var obj = { baz: 'Initial' }; + var count = 0; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed(function () { + return get(this, 'bar').toLowerCase(); + }).property('bar')); + + _emberMetalProperties.defineProperty(obj, 'bar', _emberMetalComputed.computed(function () { + return get(this, 'baz').toUpperCase(); + }).property('baz')); + + _emberMetalMixin.mixin(obj, { + fooAndBarWatcher: _emberMetalMixin._beforeObserver('{foo,bar}', function () { + count++; + }) + }); + + get(obj, 'foo'); + set(obj, 'baz', 'Baz'); + // fire once for foo, once for bar + equal(count, 2, 'observer specified via brace expansion invoked on dependent property change'); + + set(obj, 'quux', 'Quux'); + equal(count, 2, 'observer not fired on unspecified property'); + }); + + _internalTestHelpers.testBoth('_addBeforeObserver should propagate through prototype', function (get, set) { + var obj = { foo: 'foo', count: 0 }; + var obj2 = undefined; + + _emberMetalObserver._addBeforeObserver(obj, 'foo', function () { + this.count++; + }); + obj2 = Object.create(obj); + + set(obj2, 'foo', 'bar'); + equal(obj2.count, 1, 'should have invoked observer on inherited'); + equal(obj.count, 0, 'should not have invoked observer on parent'); + + obj2.count = 0; + set(obj, 'foo', 'baz'); + equal(obj.count, 1, 'should have invoked observer on parent'); + equal(obj2.count, 0, 'should not have invoked observer on inherited'); + }); + + _internalTestHelpers.testBoth('_addBeforeObserver should respect targets with methods', function (get, set) { + var observed = { foo: 'foo' }; + + var target1 = { + count: 0, + + willChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target1, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'foo', 'param3 should old value'); + this.count++; + } + }; + + var target2 = { + count: 0, + + willChange: function (obj, keyName) { + var value = get(obj, keyName); + equal(this, target2, 'should invoke with this'); + equal(obj, observed, 'param1 should be observed object'); + equal(keyName, 'foo', 'param2 should be keyName'); + equal(value, 'foo', 'param3 should old value'); + this.count++; + } + }; + + _emberMetalObserver._addBeforeObserver(observed, 'foo', target1, 'willChange'); + _emberMetalObserver._addBeforeObserver(observed, 'foo', target2, target2.willChange); + + set(observed, 'foo', 'BAZ'); + equal(target1.count, 1, 'target1 observer should have fired'); + equal(target2.count, 1, 'target2 observer should have fired'); + }); + + // .......................................................... + // CHAINED OBSERVERS + // + + var obj = undefined, + count = undefined; + + QUnit.module('addObserver - dependentkey with chained properties', { + setup: function () { + obj = { + foo: { + bar: { + baz: { + biff: 'BIFF' + } + } + }, + Capital: { + foo: { + bar: { + baz: { + biff: 'BIFF' + } + } + } + } + }; + + count = 0; + }, + + teardown: function () { + obj = count = null; + } + }); + + _internalTestHelpers.testBoth('depending on a chain with a computed property', function (get, set) { + _emberMetalProperties.defineProperty(obj, 'computed', _emberMetalComputed.computed(function () { + return { foo: 'bar' }; + })); + + var changed = 0; + _emberMetalObserver.addObserver(obj, 'computed.foo', function () { + changed++; + }); + + equal(_emberMetalComputed.cacheFor(obj, 'computed'), undefined, 'addObserver should not compute CP'); + + set(obj, 'computed.foo', 'baz'); + + equal(changed, 1, 'should fire observer'); + }); + + _internalTestHelpers.testBoth('depending on a simple chain', function (get, set) { + var val = undefined; + _emberMetalObserver.addObserver(obj, 'foo.bar.baz.biff', function (target, key) { + val = get(target, key); + count++; + }); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 1); + + set(get(obj, 'foo.bar'), 'baz', { biff: 'BLARG' }); + equal(val, 'BLARG'); + equal(count, 2); + + set(get(obj, 'foo'), 'bar', { baz: { biff: 'BOOM' } }); + equal(val, 'BOOM'); + equal(count, 3); + + set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(val, 'BLARG'); + equal(count, 4); + + set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 5); + + var foo = get(obj, 'foo'); + + set(obj, 'foo', 'BOO'); + equal(val, undefined); + equal(count, 6); + + set(foo.bar.baz, 'biff', 'BOOM'); + equal(count, 6, 'should be not have invoked observer'); + }); + + _internalTestHelpers.testBoth('depending on a chain with a capitalized first key', function (get, set) { + var val = undefined; + + _emberMetalObserver.addObserver(obj, 'Capital.foo.bar.baz.biff', function (target, key) { + val = get(obj, key); + count++; + }); + + set(get(obj, 'Capital.foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 1); + + set(get(obj, 'Capital.foo.bar'), 'baz', { biff: 'BLARG' }); + equal(val, 'BLARG'); + equal(count, 2); + + set(get(obj, 'Capital.foo'), 'bar', { baz: { biff: 'BOOM' } }); + equal(val, 'BOOM'); + equal(count, 3); + + set(obj, 'Capital.foo', { bar: { baz: { biff: 'BLARG' } } }); + equal(val, 'BLARG'); + equal(count, 4); + + set(get(obj, 'Capital.foo.bar.baz'), 'biff', 'BUZZ'); + equal(val, 'BUZZ'); + equal(count, 5); + + var foo = get(obj, 'foo'); + + set(obj, 'Capital.foo', 'BOO'); + equal(val, undefined); + equal(count, 6); + + set(foo.bar.baz, 'biff', 'BOOM'); + equal(count, 6, 'should be not have invoked observer'); + }); + + QUnit.module('_removeBeforeObserver'); + + // .......................................................... + // SETTING IDENTICAL VALUES + // + + QUnit.module('props/observer_test - setting identical values'); + + _internalTestHelpers.testBoth('setting simple prop should not trigger', function (get, set) { + var obj = { foo: 'bar' }; + var count = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 0, 'should not trigger observer'); + + set(obj, 'foo', 'baz'); + equal(count, 1, 'should trigger observer'); + + set(obj, 'foo', 'baz'); + equal(count, 1, 'should not trigger observer again'); + }); + + // The issue here is when a computed property is directly set with a value, then has a + // dependent key change (which triggers a cache expiration and recomputation), observers will + // not be fired if the CP setter is called with the last set value. + _internalTestHelpers.testBoth('setting a cached computed property whose value has changed should trigger', function (get, set) { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return get(this, 'baz'); + }, + set: function (key, value) { + return value; + } + }).property('baz')); + + var count = 0; + + _emberMetalObserver.addObserver(obj, 'foo', function () { + count++; + }); + + set(obj, 'foo', 'bar'); + equal(count, 1); + equal(get(obj, 'foo'), 'bar'); + + set(obj, 'baz', 'qux'); + equal(count, 2); + equal(get(obj, 'foo'), 'qux'); + + get(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(count, 3); + equal(get(obj, 'foo'), 'bar'); + }); + + QUnit.module('Ember.immediateObserver (Deprecated)'); + + _internalTestHelpers.testBoth('immediate observers should fire synchronously', function (get, set) { + expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); + var obj = {}; + var observerCalled = 0; + var mixin = undefined; + + // explicitly create a run loop so we do not inadvertently + // trigger deferred behavior + _emberMetalRun_loop.default(function () { + mixin = _emberMetalMixin.Mixin.create({ + fooDidChange: _emberMetalMixin._immediateObserver('foo', function () { + observerCalled++; + equal(get(this, 'foo'), 'barbaz', 'newly set value is immediately available'); + }) + }); + + mixin.apply(obj); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return 'yes hello this is foo'; + }, + set: function (key, value) { + return value; + } + })); + + equal(get(obj, 'foo'), 'yes hello this is foo', 'precond - computed property returns a value'); + equal(observerCalled, 0, 'observer has not yet been called'); + + set(obj, 'foo', 'barbaz'); + + equal(observerCalled, 1, 'observer was called once'); + }); + }); + + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + _internalTestHelpers.testBoth('immediate observers added declaratively via brace expansion fire synchronously', function (get, set) { + var obj = {}; + var observerCalled = 0; + var mixin = undefined; + + // explicitly create a run loop so we do not inadvertently + // trigger deferred behavior + _emberMetalRun_loop.default(function () { + expectDeprecation(function () { + mixin = _emberMetalMixin.Mixin.create({ + fooDidChange: (function () { + observerCalled++; + equal(get(this, 'foo'), 'barbaz', 'newly set value is immediately available'); + }).observesImmediately('{foo,bar}') + }); + }, /Function#observesImmediately is deprecated. Use Function#observes instead/); + + mixin.apply(obj); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function (key) { + return 'yes hello this is foo'; + }, + set: function (key, value) { + return value; + } + })); + + equal(get(obj, 'foo'), 'yes hello this is foo', 'precond - computed property returns a value'); + equal(observerCalled, 0, 'observer has not yet been called'); + + set(obj, 'foo', 'barbaz'); + + equal(observerCalled, 1, 'observer was called once'); + }); + }); + } + + _internalTestHelpers.testBoth('immediate observers watching multiple properties via brace expansion fire synchronously', function (get, set) { + expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); + var obj = {}; + var observerCalled = 0; + var mixin = undefined; + + // explicitly create a run loop so we do not inadvertently + // trigger deferred behavior + _emberMetalRun_loop.default(function () { + mixin = _emberMetalMixin.Mixin.create({ + fooDidChange: _emberMetalMixin._immediateObserver('{foo,bar}', function () { + observerCalled++; + equal(get(this, 'foo'), 'barbaz', 'newly set value is immediately available'); + }) + }); + + mixin.apply(obj); + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return 'yes hello this is foo'; + }, + set: function (key, value) { + return value; + } + })); + + equal(get(obj, 'foo'), 'yes hello this is foo', 'precond - computed property returns a value'); + equal(observerCalled, 0, 'observer has not yet been called'); + + set(obj, 'foo', 'barbaz'); + + equal(observerCalled, 1, 'observer was called once'); + }); + }); + + _internalTestHelpers.testBoth('immediate observers are for internal properties only', function (get, set) { + expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); + expectAssertion(function () { + _emberMetalMixin._immediateObserver('foo.bar', function () { + return this; + }); + }, 'Immediate observers must observe internal properties only, not properties on other objects.'); + }); + + QUnit.module('changeProperties'); + + _internalTestHelpers.testBoth('observers added/removed during changeProperties should do the right thing.', function (get, set) { + var obj = { + foo: 0 + }; + function Observer() { + this.willChangeCount = 0; + this.didChangeCount = 0; + } + Observer.prototype = { + add: function () { + _emberMetalObserver._addBeforeObserver(obj, 'foo', this, 'willChange'); + _emberMetalObserver.addObserver(obj, 'foo', this, 'didChange'); + }, + remove: function () { + _emberMetalObserver._removeBeforeObserver(obj, 'foo', this, 'willChange'); + _emberMetalObserver.removeObserver(obj, 'foo', this, 'didChange'); + }, + willChange: function () { + this.willChangeCount++; + }, + didChange: function () { + this.didChangeCount++; + } + }; + var addedBeforeFirstChangeObserver = new Observer(); + var addedAfterFirstChangeObserver = new Observer(); + var addedAfterLastChangeObserver = new Observer(); + var removedBeforeFirstChangeObserver = new Observer(); + var removedBeforeLastChangeObserver = new Observer(); + var removedAfterLastChangeObserver = new Observer(); + removedBeforeFirstChangeObserver.add(); + removedBeforeLastChangeObserver.add(); + removedAfterLastChangeObserver.add(); + _emberMetalProperty_events.changeProperties(function () { + removedBeforeFirstChangeObserver.remove(); + addedBeforeFirstChangeObserver.add(); + + set(obj, 'foo', 1); + + equal(addedBeforeFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called before the first change invoked immediately'); + equal(addedBeforeFirstChangeObserver.didChangeCount, 0, 'addObserver called before the first change is deferred'); + + addedAfterFirstChangeObserver.add(); + removedBeforeLastChangeObserver.remove(); + + set(obj, 'foo', 2); + + equal(addedAfterFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called after the first change invoked immediately'); + equal(addedAfterFirstChangeObserver.didChangeCount, 0, 'addObserver called after the first change is deferred'); + + addedAfterLastChangeObserver.add(); + removedAfterLastChangeObserver.remove(); + }); + + equal(removedBeforeFirstChangeObserver.willChangeCount, 0, '_removeBeforeObserver called before the first change sees none'); + equal(removedBeforeFirstChangeObserver.didChangeCount, 0, 'removeObserver called before the first change sees none'); + equal(addedBeforeFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called before the first change sees only 1'); + equal(addedBeforeFirstChangeObserver.didChangeCount, 1, 'addObserver called before the first change sees only 1'); + equal(addedAfterFirstChangeObserver.willChangeCount, 1, '_addBeforeObserver called after the first change sees 1'); + equal(addedAfterFirstChangeObserver.didChangeCount, 1, 'addObserver called after the first change sees 1'); + equal(addedAfterLastChangeObserver.willChangeCount, 0, '_addBeforeObserver called after the last change sees none'); + equal(addedAfterLastChangeObserver.didChangeCount, 0, 'addObserver called after the last change sees none'); + equal(removedBeforeLastChangeObserver.willChangeCount, 1, '_removeBeforeObserver called before the last change still sees 1'); + equal(removedBeforeLastChangeObserver.didChangeCount, 1, 'removeObserver called before the last change still sees 1'); + equal(removedAfterLastChangeObserver.willChangeCount, 1, '_removeBeforeObserver called after the last change still sees 1'); + equal(removedAfterLastChangeObserver.didChangeCount, 1, 'removeObserver called after the last change still sees 1'); + }); + + QUnit.module('Keys behavior with observers'); + + _internalTestHelpers.testBoth('should not leak properties on the prototype', function () { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + deepEqual(Object.keys(beer), []); + _emberMetalObserver.removeObserver(beer, 'type', K); + }); + + _internalTestHelpers.testBoth('observing a non existent property', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'brand', K); + + deepEqual(Object.keys(beer), []); + + set(beer, 'brand', 'Corona'); + deepEqual(Object.keys(beer), ['brand']); + + _emberMetalObserver.removeObserver(beer, 'brand', K); + }); + + _internalTestHelpers.testBoth('with observers switched on and off', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + _emberMetalObserver.removeObserver(beer, 'type', K); + + deepEqual(Object.keys(beer), []); + }); + + _internalTestHelpers.testBoth('observers switched on and off with setter in between', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + set(beer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + + deepEqual(Object.keys(beer), ['type']); + }); + + _internalTestHelpers.testBoth('observer switched on and off and then setter', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + + _emberMetalObserver.addObserver(beer, 'type', K); + _emberMetalObserver.removeObserver(beer, 'type', K); + set(beer, 'type', 'ale'); + + deepEqual(Object.keys(beer), ['type']); + }); + + _internalTestHelpers.testBoth('observers switched on and off with setter in between (observed property is not shadowing)', function (get, set) { + function Beer() {} + + var beer = new Beer(); + set(beer, 'type', 'ale'); + deepEqual(Object.keys(beer), ['type'], 'only set'); + + var otherBeer = new Beer(); + _emberMetalObserver.addObserver(otherBeer, 'type', K); + set(otherBeer, 'type', 'ale'); + deepEqual(Object.keys(otherBeer), ['type'], 'addObserver -> set'); + + var yetAnotherBeer = new Beer(); + _emberMetalObserver.addObserver(yetAnotherBeer, 'type', K); + set(yetAnotherBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(yetAnotherBeer), ['type'], 'addObserver -> set -> removeObserver'); + + var itsMyLastBeer = new Beer(); + set(itsMyLastBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); + }); + + _internalTestHelpers.testBoth('observers switched on and off with setter in between (observed property is shadowing one on the prototype)', function (get, set) { + function Beer() {} + Beer.prototype.type = 'ipa'; + + var beer = new Beer(); + set(beer, 'type', 'ale'); + deepEqual(Object.keys(beer), ['type'], 'after set'); + + var otherBeer = new Beer(); + _emberMetalObserver.addObserver(otherBeer, 'type', K); + set(otherBeer, 'type', 'ale'); + deepEqual(Object.keys(otherBeer), ['type'], 'addObserver -> set'); + + var yetAnotherBeer = new Beer(); + _emberMetalObserver.addObserver(yetAnotherBeer, 'type', K); + set(yetAnotherBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(yetAnotherBeer), ['type'], 'addObserver -> set -> removeObserver'); + + var itsMyLastBeer = new Beer(); + set(itsMyLastBeer, 'type', 'ale'); + _emberMetalObserver.removeObserver(beer, 'type', K); + deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); + }); +}); +enifed('ember-metal/tests/observer_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/observer_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/observer_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/performance_test', ['exports', 'ember-metal/property_set', 'ember-metal/property_get', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/observer'], function (exports, _emberMetalProperty_set, _emberMetalProperty_get, _emberMetalComputed, _emberMetalProperties, _emberMetalProperty_events, _emberMetalObserver) { + 'use strict'; + + /* + This test file is designed to capture performance regressions related to + deferred computation. Things like run loops, computed properties, and bindings + should run the minimum amount of times to achieve best performance, so any + bugs that cause them to get evaluated more than necessary should be put here. + */ + + QUnit.module('Computed Properties - Number of times evaluated'); + + QUnit.test('computed properties that depend on multiple properties should run only once per run loop', function () { + var obj = { a: 'a', b: 'b', c: 'c' }; + var cpCount = 0; + var obsCount = 0; + + _emberMetalProperties.defineProperty(obj, 'abc', _emberMetalComputed.computed(function (key) { + cpCount++; + return 'computed ' + key; + }).property('a', 'b', 'c')); + + _emberMetalProperty_get.get(obj, 'abc'); + + cpCount = 0; + + _emberMetalObserver.addObserver(obj, 'abc', function () { + obsCount++; + }); + + _emberMetalProperty_events.beginPropertyChanges(); + _emberMetalProperty_set.set(obj, 'a', 'aa'); + _emberMetalProperty_set.set(obj, 'b', 'bb'); + _emberMetalProperty_set.set(obj, 'c', 'cc'); + _emberMetalProperty_events.endPropertyChanges(); + + _emberMetalProperty_get.get(obj, 'abc'); + + equal(cpCount, 1, 'The computed property is only invoked once'); + equal(obsCount, 1, 'The observer is only invoked once'); + }); + + QUnit.test('computed properties are not executed if they are the last segment of an observer chain pain', function () { + var foo = { bar: { baz: {} } }; + + var count = 0; + + _emberMetalProperties.defineProperty(foo.bar.baz, 'bam', _emberMetalComputed.computed(function () { + count++; + })); + + _emberMetalObserver.addObserver(foo, 'bar.baz.bam', function () {}); + + _emberMetalProperty_events.propertyDidChange(_emberMetalProperty_get.get(foo, 'bar.baz'), 'bam'); + + equal(count, 0, 'should not have recomputed property'); + }); +}); +enifed('ember-metal/tests/performance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/performance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/performance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/properties_test', ['exports', 'ember-metal/computed', 'ember-metal/properties', 'ember-metal/deprecate_property'], function (exports, _emberMetalComputed, _emberMetalProperties, _emberMetalDeprecate_property) { + 'use strict'; + + QUnit.module('Ember.defineProperty'); + + QUnit.test('toString', function () { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'toString', undefined, function () { + return 'FOO'; + }); + equal(obj.toString(), 'FOO', 'should replace toString'); + }); + + QUnit.test('for data properties, didDefineProperty hook should be called if implemented', function () { + expect(2); + + var obj = { + didDefineProperty: function (obj, keyName, value) { + equal(keyName, 'foo', 'key name should be foo'); + equal(value, 'bar', 'value should be bar'); + } + }; + + _emberMetalProperties.defineProperty(obj, 'foo', undefined, 'bar'); + }); + + QUnit.test('for computed properties, didDefineProperty hook should be called if implemented', function () { + expect(2); + + var computedProperty = _emberMetalComputed.computed(function () { + return this; + }); + + var obj = { + didDefineProperty: function (obj, keyName, value) { + equal(keyName, 'foo', 'key name should be foo'); + strictEqual(value, computedProperty, 'value should be passed as computed property'); + } + }; + + _emberMetalProperties.defineProperty(obj, 'foo', computedProperty); + }); + + QUnit.test('for descriptor properties, didDefineProperty hook should be called if implemented', function () { + expect(2); + + var descriptor = { + writable: true, + configurable: false, + enumerable: true, + value: 42 + }; + + var obj = { + didDefineProperty: function (obj, keyName, value) { + equal(keyName, 'answer', 'key name should be answer'); + strictEqual(value, descriptor, 'value should be passed as descriptor'); + } + }; + + _emberMetalProperties.defineProperty(obj, 'answer', descriptor); + }); + + QUnit.module('Ember.deprecateProperty'); + + QUnit.test('enables access to deprecated property and returns the value of the new property', function () { + expect(3); + var obj = { foo: 'bar' }; + + _emberMetalDeprecate_property.deprecateProperty(obj, 'baz', 'foo'); + + expectDeprecation(); + equal(obj.baz, obj.foo, 'baz and foo are equal'); + + obj.foo = 'blammo'; + equal(obj.baz, obj.foo, 'baz and foo are equal'); + }); + + QUnit.test('deprecatedKey is not enumerable', function () { + expect(2); + var obj = { foo: 'bar', blammo: 'whammy' }; + + _emberMetalDeprecate_property.deprecateProperty(obj, 'baz', 'foo'); + + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + notEqual(prop, 'baz'); + } + } + }); + + QUnit.test('enables setter to deprecated property and updates the value of the new property', function () { + expect(3); + var obj = { foo: 'bar' }; + + _emberMetalDeprecate_property.deprecateProperty(obj, 'baz', 'foo'); + + expectDeprecation(); + obj.baz = 'bloop'; + equal(obj.foo, 'bloop', 'updating baz updates foo'); + equal(obj.baz, obj.foo, 'baz and foo are equal'); + }); +}); +enifed('ember-metal/tests/properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/property_did_change_hook', ['exports', 'internal-test-helpers', 'ember-metal/property_events', 'ember-metal/watching', 'ember-metal/properties', 'ember-metal/alias', 'ember-metal/computed'], function (exports, _internalTestHelpers, _emberMetalProperty_events, _emberMetalWatching, _emberMetalProperties, _emberMetalAlias, _emberMetalComputed) { + 'use strict'; + + QUnit.module('PROPERTY_DID_CHANGE'); + + _internalTestHelpers.testBoth('alias and cp', function (get, set) { + var _obj; + + var counts = {}; + var obj = (_obj = { + child: {} + }, _obj[_emberMetalProperty_events.PROPERTY_DID_CHANGE] = function (keyName) { + counts[keyName] = (counts[keyName] || 0) + 1; + }, _obj); + + _emberMetalProperties.defineProperty(obj, 'cost', _emberMetalAlias.default('child.cost')); + _emberMetalProperties.defineProperty(obj, 'tax', _emberMetalAlias.default('child.tax')); + + _emberMetalProperties.defineProperty(obj, 'total', _emberMetalComputed.computed('cost', 'tax', { + get: function () { + return get(this, 'cost') + get(this, 'tax'); + } + })); + + ok(!_emberMetalWatching.isWatching(obj, 'child.cost'), 'precond alias target `child.cost` is not watched'); + equal(get(obj, 'cost'), undefined); + // this is how PROPERTY_DID_CHANGE will get notified + ok(_emberMetalWatching.isWatching(obj, 'child.cost'), 'alias target `child.cost` is watched after consumption'); + + ok(!_emberMetalWatching.isWatching(obj, 'child.tax'), 'precond alias target `child.tax` is not watched'); + equal(get(obj, 'tax'), undefined); + // this is how PROPERTY_DID_CHANGE will get notified + ok(_emberMetalWatching.isWatching(obj, 'child.tax'), 'alias target `child.cost` is watched after consumption'); + + // increments the watching count on the alias itself to 1 + ok(isNaN(get(obj, 'total')), 'total is initialized'); + + // decrements the watching count on the alias itself to 0 + set(obj, 'child', { + cost: 399.00, + tax: 32.93 + }); + + // this should have called PROPERTY_DID_CHANGE for all of them + equal(counts['cost'], 1, 'PROPERTY_DID_CHANGE called with cost'); + equal(counts['tax'], 1, 'PROPERTY_DID_CHANGE called with tax'); + equal(counts['total'], 1, 'PROPERTY_DID_CHANGE called with total'); + + // we should still have a dependency installed + ok(_emberMetalWatching.isWatching(obj, 'child.cost'), 'watching child.cost'); + ok(_emberMetalWatching.isWatching(obj, 'child.tax'), 'watching child.tax'); + + set(obj, 'child', { + cost: 100.00, + tax: 10.00 + }); + + equal(counts['cost'], 2, 'PROPERTY_DID_CHANGE called with cost'); + equal(counts['tax'], 2, 'PROPERTY_DID_CHANGE called with tax'); + equal(counts['total'], 1, 'PROPERTY_DID_CHANGE called with total'); + }); +}); +enifed('ember-metal/tests/property_did_change_hook.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/property_did_change_hook.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/property_did_change_hook.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/add_queue_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + var originalQueues = _emberMetalRun_loop.default.queues; + var queues = undefined; + + QUnit.module('system/run_loop/add_queue_test', { + setup: function () { + _emberMetalRun_loop.default.queues = queues = ['blork', 'bleep']; + }, + teardown: function () { + _emberMetalRun_loop.default.queues = originalQueues; + } + }); + + QUnit.test('adds a queue after a specified one', function () { + _emberMetalRun_loop.default._addQueue('testeroo', 'blork'); + + equal(queues.indexOf('testeroo'), 1, 'new queue was added after specified queue'); + }); + + QUnit.test('does not add the queue if it already exists', function () { + _emberMetalRun_loop.default._addQueue('testeroo', 'blork'); + _emberMetalRun_loop.default._addQueue('testeroo', 'blork'); + + equal(queues.length, 3, 'queue was not added twice'); + }); +}); +enifed('ember-metal/tests/run_loop/add_queue_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/add_queue_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/add_queue_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/debounce_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + var originalDebounce = _emberMetalRun_loop.default.backburner.debounce; + var wasCalled = false; + + QUnit.module('Ember.run.debounce', { + setup: function () { + _emberMetalRun_loop.default.backburner.debounce = function () { + wasCalled = true; + }; + }, + teardown: function () { + _emberMetalRun_loop.default.backburner.debounce = originalDebounce; + } + }); + + QUnit.test('Ember.run.debounce uses Backburner.debounce', function () { + _emberMetalRun_loop.default.debounce(function () {}); + ok(wasCalled, 'Ember.run.debounce used'); + }); +}); +enifed('ember-metal/tests/run_loop/debounce_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/debounce_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/debounce_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/later_test', ['exports', 'ember-metal/is_none', 'ember-metal/run_loop'], function (exports, _emberMetalIs_none, _emberMetalRun_loop) { + 'use strict'; + + var originalSetTimeout = window.setTimeout; + var originalDateValueOf = Date.prototype.valueOf; + var originalPlatform = _emberMetalRun_loop.default.backburner._platform; + + function wait(callback, maxWaitCount) { + maxWaitCount = _emberMetalIs_none.default(maxWaitCount) ? 100 : maxWaitCount; + + originalSetTimeout(function () { + if (maxWaitCount > 0 && (_emberMetalRun_loop.default.hasScheduledTimers() || _emberMetalRun_loop.default.currentRunLoop)) { + wait(callback, maxWaitCount - 1); + + return; + } + + callback(); + }, 10); + } + + // Synchronous "sleep". This simulates work being done + // after run.later was called but before the run loop + // has flushed. In previous versions, this would have + // caused the run.later callback to have run from + // within the run loop flush, since by the time the + // run loop has to flush, it would have considered + // the timer already expired. + function pauseUntil(time) { + // jscs:disable + while (+new Date() < time) {} /* do nothing - sleeping */ + // jscs:enable + } + + QUnit.module('run.later', { + teardown: function () { + _emberMetalRun_loop.default.backburner._platform = originalPlatform; + window.setTimeout = originalSetTimeout; + Date.prototype.valueOf = originalDateValueOf; + } + }); + + asyncTest('should invoke after specified period of time - function only', function () { + var invoked = false; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(function () { + return invoked = true; + }, 100); + }); + + wait(function () { + QUnit.start(); + equal(invoked, true, 'should have invoked later item'); + }); + }); + + asyncTest('should invoke after specified period of time - target/method', function () { + var obj = { invoked: false }; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(obj, function () { + this.invoked = true; + }, 100); + }); + + wait(function () { + QUnit.start(); + equal(obj.invoked, true, 'should have invoked later item'); + }); + }); + + asyncTest('should invoke after specified period of time - target/method/args', function () { + var obj = { invoked: 0 }; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(obj, function (amt) { + this.invoked += amt; + }, 10, 100); + }); + + wait(function () { + QUnit.start(); + equal(obj.invoked, 10, 'should have invoked later item'); + }); + }); + + asyncTest('should always invoke within a separate runloop', function () { + var obj = { invoked: 0 }; + var firstRunLoop = undefined, + secondRunLoop = undefined; + + _emberMetalRun_loop.default(function () { + firstRunLoop = _emberMetalRun_loop.default.currentRunLoop; + + _emberMetalRun_loop.default.later(obj, function (amt) { + this.invoked += amt; + secondRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }, 10, 1); + + pauseUntil(+new Date() + 100); + }); + + ok(firstRunLoop, 'first run loop captured'); + ok(!_emberMetalRun_loop.default.currentRunLoop, 'shouldn\'t be in a run loop after flush'); + equal(obj.invoked, 0, 'shouldn\'t have invoked later item yet'); + + wait(function () { + QUnit.start(); + equal(obj.invoked, 10, 'should have invoked later item'); + ok(secondRunLoop, 'second run loop took place'); + ok(secondRunLoop !== firstRunLoop, 'two different run loops took place'); + }); + }); + + // Our current implementation doesn't allow us to correctly enforce this ordering. + // We should probably implement a queue to provide this guarantee. + // See https://github.com/emberjs/ember.js/issues/3526 for more information. + + // asyncTest('callback order', function() { + // let array = []; + // function fn(val) { array.push(val); } + + // run(function() { + // run.later(this, fn, 4, 5); + // run.later(this, fn, 1, 1); + // run.later(this, fn, 5, 10); + // run.later(this, fn, 2, 3); + // run.later(this, fn, 3, 3); + // }); + + // deepEqual(array, []); + + // wait(function() { + // QUnit.start(); + // deepEqual(array, [1,2,3,4,5], 'callbacks were called in expected order'); + // }); + // }); + + // Out current implementation doesn't allow us to properly enforce what is tested here. + // We should probably fix it, but it's not technically a bug right now. + // See https://github.com/emberjs/ember.js/issues/3522 for more information. + + // asyncTest('callbacks coalesce into same run loop if expiring at the same time', function() { + // let array = []; + // function fn(val) { array.push(run.currentRunLoop); } + + // run(function() { + + // // Force +new Date to return the same result while scheduling + // // run.later timers. Otherwise: non-determinism! + // let now = +new Date(); + // Date.prototype.valueOf = function() { return now; }; + + // run.later(this, fn, 10); + // run.later(this, fn, 200); + // run.later(this, fn, 200); + + // Date.prototype.valueOf = originalDateValueOf; + // }); + + // deepEqual(array, []); + + // wait(function() { + // QUnit.start(); + // equal(array.length, 3, 'all callbacks called'); + // ok(array[0] !== array[1], 'first two callbacks have different run loops'); + // ok(array[0], 'first runloop present'); + // ok(array[1], 'second runloop present'); + // equal(array[1], array[2], 'last two callbacks got the same run loop'); + // }); + // }); + + asyncTest('inception calls to run.later should run callbacks in separate run loops', function () { + var runLoop = undefined, + finished = undefined; + + _emberMetalRun_loop.default(function () { + runLoop = _emberMetalRun_loop.default.currentRunLoop; + ok(runLoop); + + _emberMetalRun_loop.default.later(function () { + ok(_emberMetalRun_loop.default.currentRunLoop && _emberMetalRun_loop.default.currentRunLoop !== runLoop, 'first later callback has own run loop'); + runLoop = _emberMetalRun_loop.default.currentRunLoop; + + _emberMetalRun_loop.default.later(function () { + ok(_emberMetalRun_loop.default.currentRunLoop && _emberMetalRun_loop.default.currentRunLoop !== runLoop, 'second later callback has own run loop'); + finished = true; + }, 40); + }, 40); + }); + + wait(function () { + QUnit.start(); + ok(finished, 'all .later callbacks run'); + }); + }); + + asyncTest('setTimeout should never run with a negative wait', function () { + // Rationale: The old run loop code was susceptible to an occasional + // bug where invokeLaterTimers would be scheduled with a setTimeout + // with a negative wait. Modern browsers normalize this to 0, but + // older browsers (IE <= 8) break with a negative wait, which + // happens when an expired timer callback takes a while to run, + // which is what we simulate here. + var newSetTimeoutUsed = undefined; + _emberMetalRun_loop.default.backburner._platform = { + setTimeout: function () { + var wait = arguments[arguments.length - 1]; + newSetTimeoutUsed = true; + ok(!isNaN(wait) && wait >= 0, 'wait is a non-negative number'); + + return originalPlatform.setTimeout.apply(originalPlatform, arguments); + } + }; + + var count = 0; + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.later(function () { + count++; + + // This will get run first. Waste some time. + // This is intended to break invokeLaterTimers code by taking a + // long enough time that other timers should technically expire. It's + // fine that they're not called in this run loop; just need to + // make sure that invokeLaterTimers doesn't end up scheduling + // a negative setTimeout. + pauseUntil(+new Date() + 60); + }, 1); + + _emberMetalRun_loop.default.later(function () { + equal(count, 1, 'callbacks called in order'); + }, 50); + }); + + wait(function () { + QUnit.start(); + ok(newSetTimeoutUsed, 'stub setTimeout was used'); + }); + }); +}); +enifed('ember-metal/tests/run_loop/later_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/later_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/later_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/next_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('run.next'); + + asyncTest('should invoke immediately on next timeout', function () { + var invoked = false; + + _emberMetalRun_loop.default(function () { + return _emberMetalRun_loop.default.next(function () { + return invoked = true; + }); + }); + + equal(invoked, false, 'should not have invoked yet'); + + setTimeout(function () { + QUnit.start(); + equal(invoked, true, 'should have invoked later item'); + }, 20); + }); + + asyncTest('callback should be called from within separate loop', function () { + var firstRunLoop = undefined, + secondRunLoop = undefined; + _emberMetalRun_loop.default(function () { + firstRunLoop = _emberMetalRun_loop.default.currentRunLoop; + _emberMetalRun_loop.default.next(function () { + return secondRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }); + }); + + setTimeout(function () { + QUnit.start(); + ok(secondRunLoop, 'callback was called from within run loop'); + ok(firstRunLoop && secondRunLoop !== firstRunLoop, 'two separate run loops were invoked'); + }, 20); + }); + + asyncTest('multiple calls to run.next share coalesce callbacks into same run loop', function () { + var secondRunLoop = undefined, + thirdRunLoop = undefined; + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.next(function () { + return secondRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }); + _emberMetalRun_loop.default.next(function () { + return thirdRunLoop = _emberMetalRun_loop.default.currentRunLoop; + }); + }); + + setTimeout(function () { + QUnit.start(); + ok(secondRunLoop && secondRunLoop === thirdRunLoop, 'callbacks coalesced into same run loop'); + }, 20); + }); +}); +enifed('ember-metal/tests/run_loop/next_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/next_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/next_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/once_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/once_test'); + + QUnit.test('calling invokeOnce more than once invokes only once', function () { + var count = 0; + _emberMetalRun_loop.default(function () { + function F() { + count++; + } + _emberMetalRun_loop.default.once(F); + _emberMetalRun_loop.default.once(F); + _emberMetalRun_loop.default.once(F); + }); + + equal(count, 1, 'should have invoked once'); + }); + + QUnit.test('should differentiate based on target', function () { + var A = { count: 0 }; + var B = { count: 0 }; + _emberMetalRun_loop.default(function () { + function F() { + this.count++; + } + _emberMetalRun_loop.default.once(A, F); + _emberMetalRun_loop.default.once(B, F); + _emberMetalRun_loop.default.once(A, F); + _emberMetalRun_loop.default.once(B, F); + }); + + equal(A.count, 1, 'should have invoked once on A'); + equal(B.count, 1, 'should have invoked once on B'); + }); + + QUnit.test('should ignore other arguments - replacing previous ones', function () { + var A = { count: 0 }; + var B = { count: 0 }; + + _emberMetalRun_loop.default(function () { + function F(amt) { + this.count += amt; + } + _emberMetalRun_loop.default.once(A, F, 10); + _emberMetalRun_loop.default.once(B, F, 20); + _emberMetalRun_loop.default.once(A, F, 30); + _emberMetalRun_loop.default.once(B, F, 40); + }); + + equal(A.count, 30, 'should have invoked once on A'); + equal(B.count, 40, 'should have invoked once on B'); + }); + + QUnit.test('should be inside of a runloop when running', function () { + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.once(function () { + return ok(!!_emberMetalRun_loop.default.currentRunLoop, 'should have a runloop'); + }); + }); + }); +}); +enifed('ember-metal/tests/run_loop/once_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/once_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/once_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/onerror_test', ['exports', 'ember-metal/run_loop', 'ember-metal/error_handler'], function (exports, _emberMetalRun_loop, _emberMetalError_handler) { + 'use strict'; + + QUnit.module('system/run_loop/onerror_test'); + + QUnit.test('With Ember.onerror undefined, errors in Ember.run are thrown', function () { + var thrown = new Error('Boom!'); + var original = _emberMetalError_handler.getOnerror(); + + var caught = undefined; + _emberMetalError_handler.setOnerror(undefined); + try { + _emberMetalRun_loop.default(function () { + throw thrown; + }); + } catch (error) { + caught = error; + } finally { + _emberMetalError_handler.setOnerror(original); + } + + deepEqual(caught, thrown); + }); + + QUnit.test('With Ember.onerror set, errors in Ember.run are caught', function () { + var thrown = new Error('Boom!'); + var original = _emberMetalError_handler.getOnerror(); + + var caught = undefined; + _emberMetalError_handler.setOnerror(function (error) { + caught = error; + }); + try { + _emberMetalRun_loop.default(function () { + throw thrown; + }); + } finally { + _emberMetalError_handler.setOnerror(original); + } + + deepEqual(caught, thrown); + }); +}); +enifed('ember-metal/tests/run_loop/onerror_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/onerror_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/onerror_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/run_bind_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/run_bind_test'); + + QUnit.test('Ember.run.bind builds a run-loop wrapped callback handler', function () { + expect(3); + + var obj = { + value: 0, + increment: function (increment) { + ok(_emberMetalRun_loop.default.currentRunLoop, 'expected a run-loop'); + return this.value += increment; + } + }; + + var proxiedFunction = _emberMetalRun_loop.default.bind(obj, obj.increment, 1); + equal(proxiedFunction(), 1); + equal(obj.value, 1); + }); + + QUnit.test('Ember.run.bind keeps the async callback arguments', function () { + expect(4); + + function asyncCallback(increment, increment2, increment3) { + ok(_emberMetalRun_loop.default.currentRunLoop, 'expected a run-loop'); + equal(increment, 1); + equal(increment2, 2); + equal(increment3, 3); + } + + function asyncFunction(fn) { + fn(2, 3); + } + + asyncFunction(_emberMetalRun_loop.default.bind(asyncCallback, asyncCallback, 1)); + }); +}); +enifed('ember-metal/tests/run_loop/run_bind_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/run_bind_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/run_bind_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/run_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/run_test'); + + QUnit.test('Ember.run invokes passed function, returning value', function () { + var obj = { + foo: function () { + return [this.bar, 'FOO']; + }, + bar: 'BAR', + checkArgs: function (arg1, arg2) { + return [arg1, this.bar, arg2]; + } + }; + + equal(_emberMetalRun_loop.default(function () { + return 'FOO'; + }), 'FOO', 'pass function only'); + deepEqual(_emberMetalRun_loop.default(obj, obj.foo), ['BAR', 'FOO'], 'pass obj and obj.method'); + deepEqual(_emberMetalRun_loop.default(obj, 'foo'), ['BAR', 'FOO'], 'pass obj and "method"'); + deepEqual(_emberMetalRun_loop.default(obj, obj.checkArgs, 'hello', 'world'), ['hello', 'BAR', 'world'], 'pass obj, obj.method, and extra arguments'); + }); +}); +enifed('ember-metal/tests/run_loop/run_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/run_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/run_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/schedule_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/schedule_test'); + + QUnit.test('scheduling item in queue should defer until finished', function () { + var cnt = 0; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + equal(cnt, 0, 'should not run action yet'); + }); + + equal(cnt, 2, 'should flush actions now'); + }); + + QUnit.test('a scheduled item can be canceled', function (assert) { + var hasRan = false; + + _emberMetalRun_loop.default(function () { + var cancelId = _emberMetalRun_loop.default.schedule('actions', function () { + return hasRan = true; + }); + _emberMetalRun_loop.default.cancel(cancelId); + }); + + assert.notOk(hasRan, 'should not have ran callback run'); + }); + + QUnit.test('nested runs should queue each phase independently', function () { + var cnt = 0; + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + equal(cnt, 0, 'should not run action yet'); + + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + return cnt++; + }); + }); + equal(cnt, 1, 'should not run action yet'); + }); + + equal(cnt, 2, 'should flush actions now'); + }); + + QUnit.test('prior queues should be flushed before moving on to next queue', function () { + var order = []; + + _emberMetalRun_loop.default(function () { + var runLoop = _emberMetalRun_loop.default.currentRunLoop; + ok(runLoop, 'run loop present'); + + _emberMetalRun_loop.default.schedule('sync', function () { + order.push('sync'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + + _emberMetalRun_loop.default.schedule('actions', function () { + order.push('actions'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + + _emberMetalRun_loop.default.schedule('actions', function () { + order.push('actions'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + + _emberMetalRun_loop.default.schedule('sync', function () { + order.push('sync'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + }); + + _emberMetalRun_loop.default.schedule('destroy', function () { + order.push('destroy'); + equal(runLoop, _emberMetalRun_loop.default.currentRunLoop, 'same run loop used'); + }); + }); + + deepEqual(order, ['sync', 'actions', 'sync', 'actions', 'destroy']); + }); + + QUnit.test('makes sure it does not trigger an autorun during testing', function () { + expectAssertion(function () { + return _emberMetalRun_loop.default.schedule('actions', function () {}); + }, /wrap any code with asynchronous side-effects in a run/); + + // make sure not just the first violation is asserted. + expectAssertion(function () { + return _emberMetalRun_loop.default.schedule('actions', function () {}); + }, /wrap any code with asynchronous side-effects in a run/); + }); +}); +enifed('ember-metal/tests/run_loop/schedule_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/schedule_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/schedule_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/sync_test', ['exports', 'ember-metal/run_loop'], function (exports, _emberMetalRun_loop) { + 'use strict'; + + QUnit.module('system/run_loop/sync_test'); + + QUnit.test('sync() will immediately flush the sync queue only', function () { + var cnt = 0; + + _emberMetalRun_loop.default(function () { + function cntup() { + cnt++; + } + + function syncfunc() { + if (++cnt < 5) { + _emberMetalRun_loop.default.schedule('sync', syncfunc); + } + _emberMetalRun_loop.default.schedule('actions', cntup); + } + + syncfunc(); + + equal(cnt, 1, 'should not run action yet'); + _emberMetalRun_loop.default.sync(); + + equal(cnt, 5, 'should have run sync queue continuously'); + }); + + equal(cnt, 10, 'should flush actions now too'); + }); + + QUnit.test('calling sync() outside a run loop does not cause an error', function () { + expect(0); + + _emberMetalRun_loop.default.sync(); + }); +}); +enifed('ember-metal/tests/run_loop/sync_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/sync_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/sync_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/run_loop/unwind_test', ['exports', 'ember-metal/run_loop', 'ember-metal/error'], function (exports, _emberMetalRun_loop, _emberMetalError) { + 'use strict'; + + QUnit.module('system/run_loop/unwind_test'); + + QUnit.test('RunLoop unwinds despite unhandled exception', function () { + var initialRunLoop = _emberMetalRun_loop.default.currentRunLoop; + + throws(function () { + _emberMetalRun_loop.default(function () { + _emberMetalRun_loop.default.schedule('actions', function () { + throw new _emberMetalError.default('boom!'); + }); + }); + }, Error, 'boom!'); + + // The real danger at this point is that calls to autorun will stick + // tasks into the already-dead runloop, which will never get + // flushed. I can't easily demonstrate this in a unit test because + // autorun explicitly doesn't work in test mode. - ef4 + equal(_emberMetalRun_loop.default.currentRunLoop, initialRunLoop, 'Previous run loop should be cleaned up despite exception'); + + // Prevent a failure in this test from breaking subsequent tests. + _emberMetalRun_loop.default.currentRunLoop = initialRunLoop; + }); + + QUnit.test('run unwinds despite unhandled exception', function () { + var initialRunLoop = _emberMetalRun_loop.default.currentRunLoop; + + throws(function () { + _emberMetalRun_loop.default(function () { + throw new _emberMetalError.default('boom!'); + }); + }, _emberMetalError.default, 'boom!'); + + equal(_emberMetalRun_loop.default.currentRunLoop, initialRunLoop, 'Previous run loop should be cleaned up despite exception'); + + // Prevent a failure in this test from breaking subsequent tests. + _emberMetalRun_loop.default.currentRunLoop = initialRunLoop; + }); +}); +enifed('ember-metal/tests/run_loop/unwind_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/run_loop/unwind_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/run_loop/unwind_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/set_properties_test', ['exports', 'ember-metal/set_properties'], function (exports, _emberMetalSet_properties) { + 'use strict'; + + QUnit.module('Ember.setProperties'); + + QUnit.test('supports setting multiple attributes at once', function () { + deepEqual(_emberMetalSet_properties.default(null, null), null, 'noop for null properties and null object'); + deepEqual(_emberMetalSet_properties.default(undefined, undefined), undefined, 'noop for undefined properties and undefined object'); + + deepEqual(_emberMetalSet_properties.default({}), undefined, 'noop for no properties'); + deepEqual(_emberMetalSet_properties.default({}, undefined), undefined, 'noop for undefined'); + deepEqual(_emberMetalSet_properties.default({}, null), null, 'noop for null'); + deepEqual(_emberMetalSet_properties.default({}, NaN), NaN, 'noop for NaN'); + deepEqual(_emberMetalSet_properties.default({}, {}), {}, 'meh'); + + deepEqual(_emberMetalSet_properties.default({}, { foo: 1 }), { foo: 1 }, 'Set a single property'); + + deepEqual(_emberMetalSet_properties.default({}, { foo: 1, bar: 1 }), { foo: 1, bar: 1 }, 'Set multiple properties'); + + deepEqual(_emberMetalSet_properties.default({ foo: 2, baz: 2 }, { foo: 1 }), { foo: 1 }, 'Set one of multiple properties'); + + deepEqual(_emberMetalSet_properties.default({ foo: 2, baz: 2 }, { bar: 2 }), { + bar: 2 + }, 'Set an additional, previously unset property'); + }); +}); +enifed('ember-metal/tests/set_properties_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/set_properties_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/set_properties_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/watching/is_watching_test', ['exports', 'ember-metal/computed', 'ember-metal/property_get', 'ember-metal/properties', 'ember-metal/mixin', 'ember-metal/observer', 'ember-metal/watching'], function (exports, _emberMetalComputed, _emberMetalProperty_get, _emberMetalProperties, _emberMetalMixin, _emberMetalObserver, _emberMetalWatching) { + 'use strict'; + + QUnit.module('isWatching'); + + function testObserver(setup, teardown) { + var key = arguments.length <= 2 || arguments[2] === undefined ? 'key' : arguments[2]; + + var obj = {}; + function fn() {} + + equal(_emberMetalWatching.isWatching(obj, key), false, 'precond - isWatching is false by default'); + setup(obj, key, fn); + equal(_emberMetalWatching.isWatching(obj, key), true, 'isWatching is true when observers are added'); + teardown(obj, key, fn); + equal(_emberMetalWatching.isWatching(obj, key), false, 'isWatching is false after observers are removed'); + } + + QUnit.test('isWatching is true for regular local observers', function () { + testObserver(function (obj, key, fn) { + _emberMetalMixin.Mixin.create({ + didChange: _emberMetalMixin.observer(key, fn) + }).apply(obj); + }, function (obj, key, fn) { + return _emberMetalObserver.removeObserver(obj, key, obj, fn); + }); + }); + + QUnit.test('isWatching is true for nonlocal observers', function () { + testObserver(function (obj, key, fn) { + _emberMetalObserver.addObserver(obj, key, obj, fn); + }, function (obj, key, fn) { + return _emberMetalObserver.removeObserver(obj, key, obj, fn); + }); + }); + + QUnit.test('isWatching is true for chained observers', function () { + testObserver(function (obj, key, fn) { + _emberMetalObserver.addObserver(obj, key + '.bar', obj, fn); + }, function (obj, key, fn) { + _emberMetalObserver.removeObserver(obj, key + '.bar', obj, fn); + }); + }); + + QUnit.test('isWatching is true for computed properties', function () { + testObserver(function (obj, key, fn) { + _emberMetalProperties.defineProperty(obj, 'computed', _emberMetalComputed.computed(fn).property(key)); + _emberMetalProperty_get.get(obj, 'computed'); + }, function (obj, key, fn) { + return _emberMetalProperties.defineProperty(obj, 'computed', null); + }); + }); + + QUnit.test('isWatching is true for chained computed properties', function () { + testObserver(function (obj, key, fn) { + _emberMetalProperties.defineProperty(obj, 'computed', _emberMetalComputed.computed(fn).property(key + '.bar')); + _emberMetalProperty_get.get(obj, 'computed'); + }, function (obj, key, fn) { + return _emberMetalProperties.defineProperty(obj, 'computed', null); + }); + }); + + // can't watch length on Array - it is special... + // But you should be able to watch a length property of an object + QUnit.test('isWatching is true for \'length\' property on object', function () { + testObserver(function (obj, key, fn) { + _emberMetalProperties.defineProperty(obj, 'length', null, '26.2 miles'); + _emberMetalObserver.addObserver(obj, 'length', obj, fn); + }, function (obj, key, fn) { + return _emberMetalObserver.removeObserver(obj, 'length', obj, fn); + }, 'length'); + }); +}); +enifed('ember-metal/tests/watching/is_watching_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/watching/is_watching_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/watching/is_watching_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/watching/unwatch_test', ['exports', 'internal-test-helpers', 'ember-metal/watching', 'ember-metal/properties', 'ember-metal/events', 'ember-metal/computed', 'ember-metal/property_set'], function (exports, _internalTestHelpers, _emberMetalWatching, _emberMetalProperties, _emberMetalEvents, _emberMetalComputed, _emberMetalProperty_set) { + 'use strict'; + + var willCount = undefined, + didCount = undefined; + + QUnit.module('unwatch', { + setup: function () { + willCount = didCount = 0; + } + }); + + function addListeners(obj, keyPath) { + _emberMetalEvents.addListener(obj, keyPath + ':before', function () { + return willCount++; + }); + _emberMetalEvents.addListener(obj, keyPath + ':change', function () { + return didCount++; + }); + } + + _internalTestHelpers.testBoth('unwatching a computed property - regular get/set', function (get, set) { + var obj = {}; + + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return this.__foo; + }, + set: function (keyName, value) { + this.__foo = value; + return this.__foo; + } + })); + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + set(obj, 'foo', 'BAZ'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + _internalTestHelpers.testBoth('unwatching a regular property - regular get/set', function (get, set) { + var obj = { foo: 'BIFF' }; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + set(obj, 'foo', 'BAZ'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + QUnit.test('unwatching should be nested', function () { + var obj = { foo: 'BIFF' }; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + _emberMetalWatching.watch(obj, 'foo'); + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + _emberMetalProperty_set.set(obj, 'foo', 'BAZ'); + equal(willCount, 1, 'should NOT have invoked willCount'); + equal(didCount, 1, 'should NOT have invoked didCount'); + + _emberMetalWatching.unwatch(obj, 'foo'); + willCount = didCount = 0; + _emberMetalProperty_set.set(obj, 'foo', 'BAZ'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + _internalTestHelpers.testBoth('unwatching "length" property on an object', function (get, set) { + var obj = { foo: 'RUN' }; + addListeners(obj, 'length'); + + // Can watch length when it is undefined + _emberMetalWatching.watch(obj, 'length'); + set(obj, 'length', '10k'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + // Should stop watching despite length now being defined (making object 'array-like') + _emberMetalWatching.unwatch(obj, 'length'); + willCount = didCount = 0; + set(obj, 'length', '5k'); + equal(willCount, 0, 'should NOT have invoked willCount'); + equal(didCount, 0, 'should NOT have invoked didCount'); + }); + + _internalTestHelpers.testBoth('unwatching should not destroy non MANDATORY_SETTER descriptor', function (get, set) { + var obj = { get foo() { + return 'RUN'; + } }; + + equal(obj.foo, 'RUN', 'obj.foo'); + _emberMetalWatching.watch(obj, 'foo'); + equal(obj.foo, 'RUN', 'obj.foo after watch'); + _emberMetalWatching.unwatch(obj, 'foo'); + equal(obj.foo, 'RUN', 'obj.foo after unwatch'); + }); +}); +enifed('ember-metal/tests/watching/unwatch_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/watching/unwatch_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/watching/unwatch_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/watching/watch_test', ['exports', 'ember-environment', 'ember-metal/meta', 'ember-metal/property_set', 'ember-metal/property_get', 'ember-metal/computed', 'ember-metal/properties', 'internal-test-helpers', 'ember-metal/events', 'ember-metal/watching'], function (exports, _emberEnvironment, _emberMetalMeta, _emberMetalProperty_set, _emberMetalProperty_get, _emberMetalComputed, _emberMetalProperties, _internalTestHelpers, _emberMetalEvents, _emberMetalWatching) { + 'use strict'; + + var willCount = undefined, + didCount = undefined, + willKeys = undefined, + didKeys = undefined, + originalLookup = undefined; + + QUnit.module('watch', { + setup: function () { + willCount = didCount = 0; + willKeys = []; + didKeys = []; + + originalLookup = _emberEnvironment.context.lookup; + _emberEnvironment.context.lookup = {}; + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + function addListeners(obj, keyPath) { + _emberMetalEvents.addListener(obj, keyPath + ':before', function () { + willCount++; + willKeys.push(keyPath); + }); + _emberMetalEvents.addListener(obj, keyPath + ':change', function () { + didCount++; + didKeys.push(keyPath); + }); + } + + _internalTestHelpers.testBoth('watching a computed property', function (get, set) { + var obj = {}; + _emberMetalProperties.defineProperty(obj, 'foo', _emberMetalComputed.computed({ + get: function () { + return this.__foo; + }, + set: function (keyName, value) { + if (value !== undefined) { + this.__foo = value; + } + return this.__foo; + } + })); + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + }); + + _internalTestHelpers.testBoth('watching a regular defined property', function (get, set) { + var obj = { foo: 'baz' }; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + equal(get(obj, 'foo'), 'baz', 'should have original prop'); + + set(obj, 'foo', 'bar'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + equal(get(obj, 'foo'), 'bar', 'should get new value'); + equal(obj.foo, 'bar', 'property should be accessible on obj'); + }); + + _internalTestHelpers.testBoth('watching a regular undefined property', function (get, set) { + var obj = {}; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + + equal('foo' in obj, false, 'precond undefined'); + + set(obj, 'foo', 'bar'); + + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + equal(get(obj, 'foo'), 'bar', 'should get new value'); + equal(obj.foo, 'bar', 'property should be accessible on obj'); + }); + + _internalTestHelpers.testBoth('watches should inherit', function (get, set) { + var obj = { foo: 'baz' }; + var objB = Object.create(obj); + + addListeners(obj, 'foo'); + _emberMetalWatching.watch(obj, 'foo'); + equal(get(obj, 'foo'), 'baz', 'should have original prop'); + + set(obj, 'foo', 'bar'); + set(objB, 'foo', 'baz'); + equal(willCount, 2, 'should have invoked willCount once only'); + equal(didCount, 2, 'should have invoked didCount once only'); + }); + + QUnit.test('watching an object THEN defining it should work also', function () { + var obj = {}; + addListeners(obj, 'foo'); + + _emberMetalWatching.watch(obj, 'foo'); + + _emberMetalProperties.defineProperty(obj, 'foo'); + _emberMetalProperty_set.set(obj, 'foo', 'bar'); + + equal(_emberMetalProperty_get.default(obj, 'foo'), 'bar', 'should have set'); + equal(willCount, 1, 'should have invoked willChange once'); + equal(didCount, 1, 'should have invoked didChange once'); + }); + + QUnit.test('watching a chain then defining the property', function () { + var obj = {}; + var foo = { bar: 'bar' }; + addListeners(obj, 'foo.bar'); + addListeners(foo, 'bar'); + + _emberMetalWatching.watch(obj, 'foo.bar'); + + _emberMetalProperties.defineProperty(obj, 'foo', undefined, foo); + _emberMetalProperty_set.set(foo, 'bar', 'baz'); + + deepEqual(willKeys, ['foo.bar', 'bar'], 'should have invoked willChange with bar, foo.bar'); + deepEqual(didKeys, ['foo.bar', 'bar'], 'should have invoked didChange with bar, foo.bar'); + equal(willCount, 2, 'should have invoked willChange twice'); + equal(didCount, 2, 'should have invoked didChange twice'); + }); + + QUnit.test('watching a chain then defining the nested property', function () { + var bar = {}; + var obj = { foo: bar }; + var baz = { baz: 'baz' }; + addListeners(obj, 'foo.bar.baz'); + addListeners(baz, 'baz'); + + _emberMetalWatching.watch(obj, 'foo.bar.baz'); + + _emberMetalProperties.defineProperty(bar, 'bar', undefined, baz); + _emberMetalProperty_set.set(baz, 'baz', 'BOO'); + + deepEqual(willKeys, ['foo.bar.baz', 'baz'], 'should have invoked willChange with bar, foo.bar'); + deepEqual(didKeys, ['foo.bar.baz', 'baz'], 'should have invoked didChange with bar, foo.bar'); + equal(willCount, 2, 'should have invoked willChange twice'); + equal(didCount, 2, 'should have invoked didChange twice'); + }); + + _internalTestHelpers.testBoth('watching an object value then unwatching should restore old value', function (get, set) { + var obj = { foo: { bar: { baz: { biff: 'BIFF' } } } }; + addListeners(obj, 'foo.bar.baz.biff'); + + _emberMetalWatching.watch(obj, 'foo.bar.baz.biff'); + + var foo = get(obj, 'foo'); + equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist'); + + _emberMetalWatching.unwatch(obj, 'foo.bar.baz.biff'); + equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist'); + }); + + QUnit.test('when watching another object, destroy should remove chain watchers from the other object', function () { + var objA = {}; + var objB = { foo: 'bar' }; + objA.b = objB; + addListeners(objA, 'b.foo'); + + _emberMetalWatching.watch(objA, 'b.foo'); + + var meta_objB = _emberMetalMeta.meta(objB); + var chainNode = _emberMetalMeta.meta(objA).readableChains()._chains.b._chains.foo; + + equal(meta_objB.peekWatching('foo'), 1, 'should be watching foo'); + equal(meta_objB.readableChainWatchers().has('foo', chainNode), true, 'should have chain watcher'); + + _emberMetalWatching.destroy(objA); + + equal(meta_objB.peekWatching('foo'), 0, 'should not be watching foo'); + equal(meta_objB.readableChainWatchers().has('foo', chainNode), false, 'should not have chain watcher'); + }); + + // TESTS for length property + + _internalTestHelpers.testBoth('watching "length" property on an object', function (get, set) { + var obj = { length: '26.2 miles' }; + addListeners(obj, 'length'); + + _emberMetalWatching.watch(obj, 'length'); + equal(get(obj, 'length'), '26.2 miles', 'should have original prop'); + + set(obj, 'length', '10k'); + equal(willCount, 1, 'should have invoked willCount'); + equal(didCount, 1, 'should have invoked didCount'); + + equal(get(obj, 'length'), '10k', 'should get new value'); + equal(obj.length, '10k', 'property should be accessible on obj'); + }); + + _internalTestHelpers.testBoth('watching "length" property on an array', function (get, set) { + var arr = []; + addListeners(arr, 'length'); + + _emberMetalWatching.watch(arr, 'length'); + equal(get(arr, 'length'), 0, 'should have original prop'); + + set(arr, 'length', '10'); + equal(willCount, 1, 'should NOT have invoked willCount'); + equal(didCount, 1, 'should NOT have invoked didCount'); + + equal(get(arr, 'length'), 10, 'should get new value'); + equal(arr.length, 10, 'property should be accessible on arr'); + }); + + _internalTestHelpers.testBoth('watch + ES5 getter', function (get) { + var parent = { b: 1 }; + var child = { + get b() { + return parent.b; + } + }; + + equal(parent.b, 1, 'parent.b should be 1'); + equal(child.b, 1, 'child.b should be 1'); + equal(get(child, 'b'), 1, 'Ember.get(child, "b") should be 1'); + + _emberMetalWatching.watch(child, 'b'); + + equal(parent.b, 1, 'parent.b should be 1 (after watch)'); + equal(child.b, 1, 'child.b should be 1 (after watch)'); + + equal(get(child, 'b'), 1, 'Ember.get(child, "b") should be 1 (after watch)'); + }); + + _internalTestHelpers.testBoth('watch + Ember.set + no-descriptor', function (get, set) { + var child = {}; + + equal(child.b, undefined, 'child.b '); + equal(get(child, 'b'), undefined, 'Ember.get(child, "b")'); + + _emberMetalWatching.watch(child, 'b'); + set(child, 'b', 1); + + equal(child.b, 1, 'child.b (after watch)'); + equal(get(child, 'b'), 1, 'Ember.get(child, "b") (after watch)'); + }); +}); +enifed('ember-metal/tests/watching/watch_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/watching/watch_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/watching/watch_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/tests/weak_map_test', ['exports', 'ember-metal/weak_map'], function (exports, _emberMetalWeak_map) { + 'use strict'; + + QUnit.module('Ember.WeakMap'); + + QUnit.test('has weakMap like qualities', function (assert) { + var map = new _emberMetalWeak_map.default(); + var map2 = new _emberMetalWeak_map.default(); + + var a = {}; + var b = {}; + var c = {}; + + assert.strictEqual(map.get(a), undefined); + assert.strictEqual(map.get(b), undefined); + assert.strictEqual(map.get(c), undefined); + + assert.strictEqual(map2.get(a), undefined); + assert.strictEqual(map2.get(b), undefined); + assert.strictEqual(map2.get(c), undefined); + + assert.strictEqual(map.set(a, 1), map, 'map.set should return itself'); + assert.strictEqual(map.get(a), 1); + assert.strictEqual(map.set(b, undefined), map); + assert.strictEqual(map.set(a, 2), map); + assert.strictEqual(map.get(a), 2); + assert.strictEqual(map.set(b, undefined), map); + + assert.strictEqual(map2.get(a), undefined); + assert.strictEqual(map2.get(b), undefined); + assert.strictEqual(map2.get(c), undefined); + + assert.strictEqual(map.set(c, 1), map); + assert.strictEqual(map.get(c), 1); + assert.strictEqual(map.get(a), 2); + assert.strictEqual(map.get(b), undefined); + + assert.strictEqual(map2.set(a, 3), map2); + assert.strictEqual(map2.set(b, 4), map2); + assert.strictEqual(map2.set(c, 5), map2); + + assert.strictEqual(map2.get(a), 3); + assert.strictEqual(map2.get(b), 4); + assert.strictEqual(map2.get(c), 5); + + assert.strictEqual(map.get(c), 1); + assert.strictEqual(map.get(a), 2); + assert.strictEqual(map.get(b), undefined); + }); + + QUnit.test('WeakMap constructor requres new', function (assert) { + var expectedError = new TypeError('Constructor WeakMap requires \'new\''); + + assert.throws(function () { + // jshint newcap: false + _emberMetalWeak_map.default(); + }, expectedError); + }); + + QUnit.test('constructing a WeakMap with an invalid iterator throws an error', function (assert) { + var expectedError = new TypeError('The weak map constructor polyfill only supports an array argument'); + + assert.throws(function () { + new _emberMetalWeak_map.default({ a: 1 }); + }, expectedError); + }); + + QUnit.test('constructing a WeakMap with a valid iterator inserts the entries', function (assert) { + var a = {}; + var b = {}; + var c = {}; + + var map = new _emberMetalWeak_map.default([[a, 1], [b, 2], [c, 3]]); + + assert.strictEqual(map.get(a), 1); + assert.strictEqual(map.get(b), 2); + assert.strictEqual(map.get(c), 3); + }); + + QUnit.test('that error is thrown when using a primitive key', function (assert) { + var expectedError = new TypeError('Invalid value used as weak map key'); + var map = new _emberMetalWeak_map.default(); + + assert.throws(function () { + return map.set('a', 1); + }, expectedError); + assert.throws(function () { + return map.set(1, 1); + }, expectedError); + assert.throws(function () { + return map.set(true, 1); + }, expectedError); + assert.throws(function () { + return map.set(null, 1); + }, expectedError); + assert.throws(function () { + return map.set(undefined, 1); + }, expectedError); + }); + + QUnit.test('that .has and .delete work as expected', function (assert) { + var map = new _emberMetalWeak_map.default(); + var a = {}; + var b = {}; + var foo = { id: 1, name: 'My file', progress: 0 }; + + assert.strictEqual(map.set(a, foo), map); + assert.strictEqual(map.get(a), foo); + assert.strictEqual(map.has(a), true); + assert.strictEqual(map.has(b), false); + assert.strictEqual(map.delete(a), true); + assert.strictEqual(map.has(a), false); + assert.strictEqual(map.delete(a), false); + assert.strictEqual(map.set(a, undefined), map); + assert.strictEqual(map.has(a), true); + assert.strictEqual(map.delete(a), true); + assert.strictEqual(map.delete(a), false); + assert.strictEqual(map.has(a), false); + }); + + QUnit.test('that .toString works as expected', function (assert) { + var map = new _emberMetalWeak_map.default(); + + assert.strictEqual(map.toString(), '[object WeakMap]'); + }); +}); +enifed('ember-metal/tests/weak_map_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/tests/weak_map_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/tests/weak_map_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/transaction.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/transaction.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/transaction.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/watch_key.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/watch_key.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/watch_key.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/watch_path.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/watch_path.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/watch_path.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/watching.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/watching.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/watching.js should pass ESLint\n\n'); + }); +}); +enifed('ember-metal/weak_map.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-metal/weak_map.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-metal/weak_map.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/ext/controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/ext/controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/ext/controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/ext/run_loop.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/ext/run_loop.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/ext/run_loop.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/api.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/api.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/api.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/auto_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/auto_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/auto_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/hash_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/hash_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/hash_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/history_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/history_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/history_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/none_location.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/none_location.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/none_location.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/location/util.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/location/util.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/location/util.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/services/router.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/services/router.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/services/router.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/services/routing.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/services/routing.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/services/routing.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/cache.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/cache.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/cache.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/controller_for.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/controller_for.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/controller_for.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/dsl.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/dsl.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/dsl.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/generate_controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/generate_controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/generate_controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/query_params.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/query_params.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/query_params.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/route.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/route.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/route.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/router.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/router.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/router.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/system/router_state.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/system/router_state.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/system/router_state.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/ext/controller_test', ['exports', 'ember-utils', 'internal-test-helpers', 'ember-runtime'], function (exports, _emberUtils, _internalTestHelpers, _emberRuntime) { + 'use strict'; + + QUnit.module('ember-routing/ext/controller'); + + QUnit.test('transitionToRoute considers an engine\'s mountPoint', function () { + expect(4); + + var router = { + transitionTo: function (route) { + return route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var controller = _emberRuntime.Controller.create({ target: router }); + _emberUtils.setOwner(controller, engineInstance); + + strictEqual(controller.transitionToRoute('application'), 'foo.bar.application', 'properly prefixes application route'); + strictEqual(controller.transitionToRoute('posts'), 'foo.bar.posts', 'properly prefixes child routes'); + throws(function () { + return controller.transitionToRoute('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + strictEqual(controller.transitionToRoute(queryParams), queryParams, 'passes query param only transitions through'); + }); +}); +enifed('ember-routing/tests/ext/controller_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/ext/controller_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/ext/controller_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/auto_location_test', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-routing/location/auto_location', 'ember-routing/location/history_location', 'ember-routing/location/hash_location', 'ember-routing/location/none_location', 'internal-test-helpers'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRoutingLocationAuto_location, _emberRoutingLocationHistory_location, _emberRoutingLocationHash_location, _emberRoutingLocationNone_location, _internalTestHelpers) { + 'use strict'; + + function mockBrowserLocation(overrides) { + return _emberUtils.assign({ + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function () { + ok(false, 'location.replace should not be called during testing'); + } + }, overrides); + } + + function mockBrowserHistory(overrides) { + return _emberUtils.assign({ + pushState: function () { + ok(false, 'history.pushState should not be called during testing'); + }, + replaceState: function () { + ok(false, 'history.replaceState should not be called during testing'); + } + }, overrides); + } + + function createLocation(location, history) { + var _AutoLocation$create; + + var owner = _internalTestHelpers.buildOwner(); + + owner.register('location:history', _emberRoutingLocationHistory_location.default); + owner.register('location:hash', _emberRoutingLocationHash_location.default); + owner.register('location:none', _emberRoutingLocationNone_location.default); + + var autolocation = _emberRoutingLocationAuto_location.default.create((_AutoLocation$create = {}, _AutoLocation$create[_emberUtils.OWNER] = owner, _AutoLocation$create.location = location, _AutoLocation$create.history = history, _AutoLocation$create.global = {}, _AutoLocation$create)); + + return autolocation; + } + + var location = undefined; + + QUnit.module('Ember.AutoLocation', { + teardown: function () { + if (location) { + _emberMetal.run(location, 'destroy'); + } + } + }); + + QUnit.test('AutoLocation should have the `global`', function (assert) { + var location = _emberRoutingLocationAuto_location.default.create(); + + assert.ok(location.global, 'has a global defined'); + assert.strictEqual(location.global, _emberEnvironment.environment.window, 'has the environments window global'); + }); + + QUnit.test('AutoLocation should return concrete implementation\'s value for `getURL`', function () { + expect(1); + + var browserLocation = mockBrowserLocation(); + var browserHistory = mockBrowserHistory(); + + location = createLocation(browserLocation, browserHistory); + location.detect(); + + var concreteImplementation = _emberMetal.get(location, 'concreteImplementation'); + + concreteImplementation.getURL = function () { + return '/lincoln/park'; + }; + + equal(location.getURL(), '/lincoln/park'); + }); + + QUnit.test('AutoLocation should use a HistoryLocation instance when pushStates is supported', function () { + expect(1); + + var browserLocation = mockBrowserLocation(); + var browserHistory = mockBrowserHistory(); + + location = createLocation(browserLocation, browserHistory); + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationHistory_location.default); + }); + + QUnit.test('AutoLocation should use a HashLocation instance when pushStates are not supported, but hashchange events are and the URL is already in the HashLocation format', function () { + expect(1); + + var browserLocation = mockBrowserLocation({ + hash: '#/testd' + }); + + location = createLocation(browserLocation); + location.global = { + onhashchange: function () {} + }; + + location.detect(); + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationHash_location.default); + }); + + QUnit.test('AutoLocation should use a NoneLocation instance when neither history nor hashchange are supported.', function () { + expect(1); + + location = createLocation(mockBrowserLocation()); + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationNone_location.default); + }); + + QUnit.test('AutoLocation should use an index path (i.e. \'/\') without any location.hash as OK for HashLocation', function () { + expect(1); + + var browserLocation = mockBrowserLocation({ + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function (path) { + ok(false, 'location.replace should not be called'); + } + }); + + location = createLocation(browserLocation); + location.global = { + onhashchange: function () {} + }; + + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationHash_location.default, 'uses a HashLocation'); + }); + + QUnit.test('AutoLocation should transform the URL for hashchange-only browsers viewing a HistoryLocation-formatted path', function () { + expect(3); + + var browserLocation = mockBrowserLocation({ + hash: '', + hostname: 'test.com', + href: 'http://test.com/test', + pathname: '/test', + protocol: 'http:', + port: '', + search: '', + + replace: function (path) { + equal(path, 'http://test.com/#/test', 'location.replace should be called with normalized HashLocation path'); + } + }); + + var location = createLocation(browserLocation); + location.global = { + onhashchange: function () {} + }; + + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation') instanceof _emberRoutingLocationNone_location.default, 'NoneLocation should be used while we attempt to location.replace()'); + equal(_emberMetal.get(location, 'cancelRouterSetup'), true, 'cancelRouterSetup should be set so the router knows.'); + }); + + QUnit.test('AutoLocation should replace the URL for pushState-supported browsers viewing a HashLocation-formatted url', function () { + expect(2); + + var browserLocation = mockBrowserLocation({ + hash: '#/test', + hostname: 'test.com', + href: 'http://test.com/#/test', + pathname: '/', + protocol: 'http:', + port: '', + search: '' + }); + + var browserHistory = mockBrowserHistory({ + replaceState: function (state, title, path) { + equal(path, '/test', 'history.replaceState should be called with normalized HistoryLocation url'); + } + }); + + var location = createLocation(browserLocation, browserHistory); + location.detect(); + + ok(_emberMetal.get(location, 'concreteImplementation'), _emberRoutingLocationHistory_location.default); + }); + + QUnit.test('AutoLocation requires any rootURL given to end in a trailing forward slash', function () { + expect(3); + var browserLocation = mockBrowserLocation(); + var expectedMsg = /rootURL must end with a trailing forward slash e.g. "\/app\/"/; + + location = createLocation(browserLocation); + location.rootURL = 'app'; + + expectAssertion(function () { + location.detect(); + }, expectedMsg); + + location.rootURL = '/app'; + expectAssertion(function () { + location.detect(); + }, expectedMsg); + + // Note the trailing whitespace + location.rootURL = '/app/ '; + expectAssertion(function () { + location.detect(); + }, expectedMsg); + }); + + QUnit.test('AutoLocation provides its rootURL to the concreteImplementation', function () { + expect(1); + var browserLocation = mockBrowserLocation({ + pathname: '/some/subdir/derp' + }); + var browserHistory = mockBrowserHistory(); + + location = createLocation(browserLocation, browserHistory); + location.rootURL = '/some/subdir/'; + + location.detect(); + + var concreteLocation = _emberMetal.get(location, 'concreteImplementation'); + equal(location.rootURL, concreteLocation.rootURL); + }); + + QUnit.test('getHistoryPath() should return a normalized, HistoryLocation-supported path', function () { + expect(3); + + var browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/about?foo=bar#foo', + pathname: '/app/about', + search: '?foo=bar', + hash: '#foo' + }); + + equal(_emberRoutingLocationAuto_location.getHistoryPath('/app/', browserLocation), '/app/about?foo=bar#foo', 'URLs already in HistoryLocation form should come out the same'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#/about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#/about?foo=bar#foo' + }); + equal(_emberRoutingLocationAuto_location.getHistoryPath('/app/', browserLocation), '/app/about?foo=bar#foo', 'HashLocation formed URLs should be normalized'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#about?foo=bar#foo' + }); + equal(_emberRoutingLocationAuto_location.getHistoryPath('/app', browserLocation), '/app/#about?foo=bar#foo', 'URLs with a hash not following #/ convention shouldn\'t be normalized as a route'); + }); + + QUnit.test('getHashPath() should return a normalized, HashLocation-supported path', function () { + expect(3); + + var browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#/about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#/about?foo=bar#foo' + }); + equal(_emberRoutingLocationAuto_location.getHashPath('/app/', browserLocation), '/app/#/about?foo=bar#foo', 'URLs already in HistoryLocation form should come out the same'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/about?foo=bar#foo', + pathname: '/app/about', + search: '?foo=bar', + hash: '#foo' + }); + equal(_emberRoutingLocationAuto_location.getHashPath('/app/', browserLocation), '/app/#/about?foo=bar#foo', 'HistoryLocation formed URLs should be normalized'); + + browserLocation = mockBrowserLocation({ + href: 'http://test.com/app/#about?foo=bar#foo', + pathname: '/app/', + search: '', + hash: '#about?foo=bar#foo' + }); + + equal(_emberRoutingLocationAuto_location.getHashPath('/app/', browserLocation), '/app/#/#about?foo=bar#foo', 'URLs with a hash not following #/ convention shouldn\'t be normalized as a route'); + }); +}); +enifed('ember-routing/tests/location/auto_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/auto_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/auto_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/hash_location_test', ['exports', 'ember-metal', 'ember-routing/location/hash_location'], function (exports, _emberMetal, _emberRoutingLocationHash_location) { + 'use strict'; + + var HashTestLocation = undefined, + location = undefined; + + function createLocation(options) { + if (!options) { + options = {}; + } + location = HashTestLocation.create(options); + } + + function mockBrowserLocation(path) { + // This is a neat trick to auto-magically extract the hostname from any + // url by letting the browser do the work ;) + var tmp = document.createElement('a'); + tmp.href = path; + + var protocol = !tmp.protocol || tmp.protocol === ':' ? 'http' : tmp.protocol; + var pathname = tmp.pathname.match(/^\//) ? tmp.pathname : '/' + tmp.pathname; + + return { + hash: tmp.hash, + host: tmp.host || 'localhost', + hostname: tmp.hostname || 'localhost', + href: tmp.href, + pathname: pathname, + port: tmp.port || '', + protocol: protocol, + search: tmp.search + }; + } + + function triggerHashchange() { + var event = document.createEvent('HTMLEvents'); + event.initEvent('hashchange', true, false); + window.dispatchEvent(event); + } + + QUnit.module('Ember.HashLocation', { + setup: function () { + HashTestLocation = _emberRoutingLocationHash_location.default.extend({ + _location: { + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function () { + ok(false, 'location.replace should not be called during testing'); + } + } + }); + }, + + teardown: function () { + _emberMetal.run(function () { + if (location) { + location.destroy(); + } + }); + } + }); + + QUnit.test('HashLocation.getURL() returns the current url', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#/foo/bar') + }); + + equal(location.getURL(), '/foo/bar'); + }); + + QUnit.test('HashLocation.getURL() includes extra hashes', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#/foo#bar#car') + }); + + equal(location.getURL(), '/foo#bar#car'); + }); + + QUnit.test('HashLocation.getURL() assumes location.hash without #/ prefix is not a route path', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#foo#bar') + }); + + equal(location.getURL(), '/#foo#bar'); + }); + + QUnit.test('HashLocation.getURL() returns a normal forward slash when there is no location.hash', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/') + }); + + equal(location.getURL(), '/'); + }); + + QUnit.test('HashLocation.setURL() correctly sets the url', function () { + expect(2); + + createLocation(); + + location.setURL('/bar'); + + equal(_emberMetal.get(location, 'location.hash'), '/bar'); + equal(_emberMetal.get(location, 'lastSetURL'), '/bar'); + }); + + QUnit.test('HashLocation.replaceURL() correctly replaces to the path with a page reload', function () { + expect(2); + + createLocation({ + _location: { + replace: function (path) { + equal(path, '#/foo'); + } + } + }); + + location.replaceURL('/foo'); + + equal(_emberMetal.get(location, 'lastSetURL'), '/foo'); + }); + + QUnit.test('HashLocation.onUpdateURL callback executes as expected', function () { + expect(1); + + createLocation({ + _location: mockBrowserLocation('/#/foo/bar') + }); + + var callback = function (param) { + equal(param, '/foo/bar', 'path is passed as param'); + }; + + location.onUpdateURL(callback); + + triggerHashchange(); + }); + + QUnit.test('HashLocation.onUpdateURL doesn\'t execute callback if lastSetURL === path', function () { + expect(0); + + createLocation({ + _location: { + href: '/#/foo/bar' + }, + lastSetURL: '/foo/bar' + }); + + var callback = function (param) { + ok(false, 'callback should not be called'); + }; + + location.onUpdateURL(callback); + + triggerHashchange(); + }); + + QUnit.test('HashLocation.formatURL() prepends a # to the provided string', function () { + expect(1); + + createLocation(); + + equal(location.formatURL('/foo#bar'), '#/foo#bar'); + }); + + QUnit.test('HashLocation.willDestroy() cleans up hashchange event listener', function () { + expect(1); + + createLocation(); + + var callback = function (param) { + ok(true, 'should invoke callback once'); + }; + + location.onUpdateURL(callback); + + triggerHashchange(); + + _emberMetal.run(location, 'destroy'); + location = null; + + triggerHashchange(); + }); +}); +enifed('ember-routing/tests/location/hash_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/hash_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/hash_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/history_location_test', ['exports', 'ember-metal', 'ember-routing/location/history_location'], function (exports, _emberMetal, _emberRoutingLocationHistory_location) { + 'use strict'; + + var FakeHistory = undefined, + HistoryTestLocation = undefined, + location = undefined; + + function createLocation(options) { + if (!options) { + options = {}; + } + location = HistoryTestLocation.create(options); + } + + function mockBrowserLocation(path) { + // This is a neat trick to auto-magically extract the hostname from any + // url by letting the browser do the work ;) + var tmp = document.createElement('a'); + tmp.href = path; + + var protocol = !tmp.protocol || tmp.protocol === ':' ? 'http' : tmp.protocol; + var pathname = tmp.pathname.match(/^\//) ? tmp.pathname : '/' + tmp.pathname; + + return { + hash: tmp.hash, + host: tmp.host || 'localhost', + hostname: tmp.hostname || 'localhost', + href: tmp.href, + pathname: pathname, + port: tmp.port || '', + protocol: protocol, + search: tmp.search + }; + } + + QUnit.module('Ember.HistoryLocation', { + setup: function () { + FakeHistory = { + state: null, + _states: [], + replaceState: function (state, title, url) { + this.state = state; + this._states[0] = state; + }, + pushState: function (state, title, url) { + this.state = state; + this._states.unshift(state); + } + }; + + HistoryTestLocation = _emberRoutingLocationHistory_location.default.extend({ + history: FakeHistory + }); + }, + + teardown: function () { + _emberMetal.run(function () { + if (location) { + location.destroy(); + } + }); + } + }); + + QUnit.test('HistoryLocation initState does not get fired on init', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + ok(true, 'init was called'); + this._super.apply(this, arguments); + }, + initState: function () { + ok(false, 'initState() should not be called automatically'); + } + }); + + createLocation(); + }); + + QUnit.test('webkit doesn\'t fire popstate on page load', function () { + expect(1); + + HistoryTestLocation.reopen({ + initState: function () { + this._super.apply(this, arguments); + // these two should be equal to be able + // to successfully detect webkit initial popstate + equal(this._previousURL, this.getURL()); + } + }); + + createLocation(); + location.initState(); + }); + + QUnit.test('base URL is removed when retrieving the current pathname', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'baseURL', '/base/'); + }, + + initState: function () { + this._super.apply(this, arguments); + + equal(this.getURL(), '/foo/bar'); + } + }); + + createLocation(); + location.initState(); + }); + + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + QUnit.test('base URL is preserved when moving around', function () { + expect(2); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'baseURL', '/base/'); + } + }); + + createLocation(); + location.initState(); + location.setURL('/one/two'); + + equal(location._historyState.path, '/base/one/two'); + ok(location._historyState.uuid); + }); + + QUnit.test('setURL continues to set even with a null state (iframes may set this)', function () { + expect(2); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.setURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + ok(location._historyState.uuid); + }); + + QUnit.test('replaceURL continues to set even with a null state (iframes may set this)', function () { + expect(2); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.replaceURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + ok(location._historyState.uuid); + }); + } else { + QUnit.test('base URL is preserved when moving around', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'baseURL', '/base/'); + } + }); + + createLocation(); + location.initState(); + location.setURL('/one/two'); + + equal(location._historyState.path, '/base/one/two'); + }); + + QUnit.test('setURL continues to set even with a null state (iframes may set this)', function () { + expect(1); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.setURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + }); + + QUnit.test('replaceURL continues to set even with a null state (iframes may set this)', function () { + expect(1); + + createLocation(); + location.initState(); + + FakeHistory.pushState(null); + location.replaceURL('/three/four'); + + equal(location._historyState.path, '/three/four'); + }); + } + + QUnit.test('HistoryLocation.getURL() returns the current url, excluding both rootURL and baseURL', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/base/foo/bar')); + _emberMetal.set(this, 'rootURL', '/app/'); + _emberMetal.set(this, 'baseURL', '/base/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar'); + }); + + QUnit.test('HistoryLocation.getURL() returns the current url, does not remove rootURL if its not at start of url', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar/baz')); + _emberMetal.set(this, 'rootURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar/baz'); + }); + + QUnit.test('HistoryLocation.getURL() will not remove the rootURL when only a partial match', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/bars/baz')); + _emberMetal.set(this, 'rootURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bars/baz'); + }); + + QUnit.test('HistoryLocation.getURL() returns the current url, does not remove baseURL if its not at start of url', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar/baz')); + _emberMetal.set(this, 'baseURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar/baz'); + }); + + QUnit.test('HistoryLocation.getURL() will not remove the baseURL when only a partial match', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/bars/baz')); + _emberMetal.set(this, 'baseURL', '/bar/'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bars/baz'); + }); + + QUnit.test('HistoryLocation.getURL() includes location.search', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin')); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar?time=morphin'); + }); + + QUnit.test('HistoryLocation.getURL() includes location.hash', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar#pink-power-ranger')); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar#pink-power-ranger'); + }); + + QUnit.test('HistoryLocation.getURL() includes location.hash and location.search', function () { + expect(1); + + HistoryTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin#pink-power-ranger')); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar?time=morphin#pink-power-ranger'); + }); +}); +enifed('ember-routing/tests/location/history_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/history_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/history_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/none_location_test', ['exports', 'ember-metal', 'ember-routing/location/none_location'], function (exports, _emberMetal, _emberRoutingLocationNone_location) { + 'use strict'; + + var NoneTestLocation = undefined, + location = undefined; + + function createLocation(options) { + if (!options) { + options = {}; + } + location = NoneTestLocation.create(options); + } + + QUnit.module('Ember.NoneLocation', { + setup: function () { + NoneTestLocation = _emberRoutingLocationNone_location.default.extend({}); + }, + + teardown: function () { + _emberMetal.run(function () { + if (location) { + location.destroy(); + } + }); + } + }); + + QUnit.test('NoneLocation.formatURL() returns the current url always appending rootURL', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/en/'); + } + }); + + createLocation(); + + equal(location.formatURL('/foo/bar'), '/en/foo/bar'); + }); + + QUnit.test('NoneLocation.getURL() returns the current path minus rootURL', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/foo/'); + _emberMetal.set(this, 'path', '/foo/bar'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bar'); + }); + + QUnit.test('NoneLocation.getURL() will remove the rootURL only from the beginning of a url', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/bar/'); + _emberMetal.set(this, 'path', '/foo/bar/baz'); + } + }); + + createLocation(); + + equal(location.getURL(), '/foo/bar/baz'); + }); + + QUnit.test('NoneLocation.getURL() will not remove the rootURL when only a partial match', function () { + expect(1); + + NoneTestLocation.reopen({ + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'rootURL', '/bar/'); + _emberMetal.set(this, 'path', '/bars/baz'); + } + }); + + createLocation(); + + equal(location.getURL(), '/bars/baz'); + }); +}); +enifed('ember-routing/tests/location/none_location_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/none_location_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/none_location_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/location/util_test', ['exports', 'ember-utils', 'ember-routing/location/util'], function (exports, _emberUtils, _emberRoutingLocationUtil) { + 'use strict'; + + function mockBrowserLocation(overrides) { + return _emberUtils.assign({ + href: 'http://test.com/', + pathname: '/', + hash: '', + search: '', + replace: function () { + ok(false, 'location.replace should not be called during testing'); + } + }, overrides); + } + + QUnit.module('Location Utilities'); + + QUnit.test('replacePath cannot be used to redirect to a different origin', function () { + expect(1); + + var expectedURL = undefined; + + var location = { + protocol: 'http:', + hostname: 'emberjs.com', + port: '1337', + + replace: function (url) { + equal(url, expectedURL); + } + }; + + expectedURL = 'http://emberjs.com:1337//google.com'; + _emberRoutingLocationUtil.replacePath(location, '//google.com'); + }); + + QUnit.test('getPath() should normalize location.pathname, making sure it always returns a leading slash', function () { + expect(2); + + var location = mockBrowserLocation({ pathname: 'test' }); + equal(_emberRoutingLocationUtil.getPath(location), '/test', 'When there is no leading slash, one is added.'); + + location = mockBrowserLocation({ pathname: '/test' }); + equal(_emberRoutingLocationUtil.getPath(location), '/test', 'When a leading slash is already there, it isn\'t added again'); + }); + + QUnit.test('getQuery() should return location.search as-is', function () { + expect(1); + + var location = mockBrowserLocation({ search: '?foo=bar' }); + equal(_emberRoutingLocationUtil.getQuery(location), '?foo=bar'); + }); + + QUnit.test('getFullPath() should return full pathname including query and hash', function () { + expect(1); + + var location = mockBrowserLocation({ + href: 'http://test.com/about?foo=bar#foo', + pathname: '/about', + search: '?foo=bar', + hash: '#foo' + }); + + equal(_emberRoutingLocationUtil.getFullPath(location), '/about?foo=bar#foo'); + }); + + QUnit.test('Feature-Detecting onhashchange', function () { + equal(_emberRoutingLocationUtil.supportsHashChange(undefined, { onhashchange: function () {} }), true, 'When not in IE, use onhashchange existence as evidence of the feature'); + equal(_emberRoutingLocationUtil.supportsHashChange(undefined, {}), false, 'When not in IE, use onhashchange absence as evidence of the feature absence'); + equal(_emberRoutingLocationUtil.supportsHashChange(7, { onhashchange: function () {} }), false, 'When in IE7 compatibility mode, never report existence of the feature'); + equal(_emberRoutingLocationUtil.supportsHashChange(8, { onhashchange: function () {} }), true, 'When in IE8+, use onhashchange existence as evidence of the feature'); + }); + + // jscs:disable + QUnit.test("Feature-detecting the history API", function () { + equal(_emberRoutingLocationUtil.supportsHistory("", { pushState: true }), true, "returns true if not Android Gingerbread and history.pushState exists"); + equal(_emberRoutingLocationUtil.supportsHistory("", {}), false, "returns false if history.pushState doesn't exist"); + equal(_emberRoutingLocationUtil.supportsHistory("", undefined), false, "returns false if history doesn't exist"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", { pushState: true }), false, "returns false if Android 2.x stock browser (not Chrome) claiming to support pushState"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; U; Android 4.0.3; nl-nl; GT-N7000 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30", { pushState: true }), false, "returns false for Android 4.0.x stock browser (not Chrome) claiming to support pushState"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; U; Android 20.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", { pushState: true }), true, "returns true if Android version begins with 2, but is greater than 2"); + + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19", { pushState: true }), true, "returns true for Chrome (not stock browser) on Android 4.0.x"); + + // Windows Phone UA and History API: https://github.com/Modernizr/Modernizr/issues/1471 + equal(_emberRoutingLocationUtil.supportsHistory("Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Virtual) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537", { pushState: true }), true, "returns true for Windows Phone 8.1 with misleading user agent string"); + }); + // jscs:enable +}); +enifed('ember-routing/tests/location/util_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/location/util_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/location/util_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/cache_test', ['exports', 'ember-routing/system/cache'], function (exports, _emberRoutingSystemCache) { + 'use strict'; + + QUnit.module('BucketCache', { + setup: function () { + this.cache = _emberRoutingSystemCache.default.create(); + } + }); + + QUnit.test('has - returns false when bucket is not in cache', function (assert) { + assert.strictEqual(this.cache.has('foo'), false); + assert.strictEqual(this.cache.has('constructor'), false); + }); + + QUnit.test('has - returns true when bucket is in cache', function (assert) { + var token = {}; + + this.cache.stash('foo', 'bar', token); + this.cache.stash('constructor', 'bar', token); + + assert.strictEqual(this.cache.has('foo'), true); + assert.strictEqual(this.cache.has('constructor'), true); + }); + + QUnit.test('lookup - returns stashed value if key does exist in bucket', function (assert) { + var token = {}; + var defaultValue = {}; + + this.cache.stash('foo', 'bar', token); + + assert.strictEqual(this.cache.lookup('foo', 'bar', defaultValue), token); + }); + + QUnit.test('lookup - returns default value if key does not exist in bucket', function (assert) { + var token = {}; + var defaultValue = {}; + + this.cache.stash('foo', 'bar', token); + + assert.strictEqual(this.cache.lookup('foo', 'boo', defaultValue), defaultValue); + assert.strictEqual(this.cache.lookup('foo', 'constructor', defaultValue), defaultValue); + }); + + QUnit.test('lookup - returns default value if bucket does not exist', function (assert) { + var defaultValue = {}; + + assert.strictEqual(this.cache.lookup('boo', 'bar', defaultValue), defaultValue); + assert.strictEqual(this.cache.lookup('constructor', 'bar', defaultValue), defaultValue); + }); +}); +enifed('ember-routing/tests/system/cache_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/cache_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/cache_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/controller_for_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/system/controller_for', 'ember-routing/system/generate_controller', 'internal-test-helpers'], function (exports, _emberMetal, _emberRuntime, _emberRoutingSystemController_for, _emberRoutingSystemGenerate_controller, _internalTestHelpers) { + 'use strict'; + + function buildInstance(namespace) { + var owner = _internalTestHelpers.buildOwner(); + + owner.__registry__.resolver = resolverFor(namespace); + owner.registerOptionsForType('view', { singleton: false }); + + owner.register('application:main', namespace, { instantiate: false }); + + owner.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); + + return owner; + } + + function resolverFor(namespace) { + return { + resolve: function (fullName) { + var nameParts = fullName.split(':'); + var type = nameParts[0]; + var name = nameParts[1]; + + if (name === 'basic') { + name = ''; + } + var className = _emberRuntime.String.classify(name) + _emberRuntime.String.classify(type); + var factory = _emberMetal.get(namespace, className); + + if (factory) { + return factory; + } + } + }; + } + + var appInstance = undefined, + appController = undefined, + namespace = undefined; + + QUnit.module('Ember.controllerFor', { + setup: function () { + namespace = _emberRuntime.Namespace.create(); + appInstance = buildInstance(namespace); + appInstance.register('controller:app', _emberRuntime.Controller.extend()); + appController = appInstance.lookup('controller:app'); + }, + teardown: function () { + _emberMetal.run(function () { + appInstance.destroy(); + namespace.destroy(); + }); + } + }); + + QUnit.test('controllerFor should lookup for registered controllers', function () { + var controller = _emberRoutingSystemController_for.default(appInstance, 'app'); + + equal(appController, controller, 'should find app controller'); + }); + + QUnit.module('Ember.generateController', { + setup: function () { + namespace = _emberRuntime.Namespace.create(); + appInstance = buildInstance(namespace); + }, + teardown: function () { + _emberMetal.run(function () { + appInstance.destroy(); + namespace.destroy(); + }); + } + }); + + QUnit.test('generateController should return Ember.Controller', function () { + var controller = _emberRoutingSystemGenerate_controller.default(appInstance, 'home'); + + ok(controller instanceof _emberRuntime.Controller, 'should return controller'); + }); + + QUnit.test('generateController should return App.Controller if provided', function () { + var controller = undefined; + namespace.Controller = _emberRuntime.Controller.extend(); + + controller = _emberRoutingSystemGenerate_controller.default(appInstance, 'home'); + + ok(controller instanceof namespace.Controller, 'should return controller'); + }); + + QUnit.test('generateController should return controller:basic if provided', function () { + var controller = undefined; + + var BasicController = _emberRuntime.Controller.extend(); + appInstance.register('controller:basic', BasicController); + + controller = _emberRoutingSystemGenerate_controller.default(appInstance, 'home'); + + if (_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + ok(controller instanceof BasicController, 'should return base class of controller'); + } else { + var doubleExtendedFactory = undefined; + ignoreDeprecation(function () { + doubleExtendedFactory = appInstance._lookupFactory('controller:basic'); + }); + ok(controller instanceof doubleExtendedFactory, 'should return double-extended controller'); + } + }); +}); +// A +enifed('ember-routing/tests/system/controller_for_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/controller_for_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/controller_for_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/dsl_test', ['exports', 'ember-utils', 'ember-routing/system/router', 'internal-test-helpers'], function (exports, _emberUtils, _emberRoutingSystemRouter, _internalTestHelpers) { + 'use strict'; + + var Router = undefined; + + function setup() { + Router = _emberRoutingSystemRouter.default.extend(); + } + + function teardown() { + Router = null; + } + + QUnit.module('Ember Router DSL', { + setup: setup, + teardown: teardown + }); + + QUnit.test('should fail when using a reserved route name', function () { + expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); + var reservedNames = ['array', 'basic', 'object', 'application']; + + expect(reservedNames.length * 2 + 1); + + reservedNames.forEach(function (reservedName) { + expectAssertion(function () { + Router = _emberRoutingSystemRouter.default.extend(); + + Router.map(function () { + this.route(reservedName); + }); + + var router = Router.create(); + router._initRouterJs(); + }, '\'' + reservedName + '\' cannot be used as a route name.'); + + expectAssertion(function () { + Router = _emberRoutingSystemRouter.default.extend(); + + Router.map(function () { + this.resource(reservedName); + }); + + var router = Router.create(); + router._initRouterJs(); + }, '\'' + reservedName + '\' cannot be used as a route name.'); + }); + }); + + QUnit.test('should reset namespace if nested with resource', function () { + expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); + + Router = Router.map(function () { + this.resource('bleep', function () { + this.resource('bloop', function () { + this.resource('blork'); + }); + }); + }); + + var router = Router.create(); + router._initRouterJs(); + + ok(router.router.recognizer.names['bleep'], 'nested resources do not contain parent name'); + ok(router.router.recognizer.names['bloop'], 'nested resources do not contain parent name'); + ok(router.router.recognizer.names['blork'], 'nested resources do not contain parent name'); + }); + + QUnit.test('should retain resource namespace if nested with routes', function () { + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.route('blork'); + }); + }); + }); + + var router = Router.create(); + router._initRouterJs(); + + ok(router.router.recognizer.names['bleep'], 'parent name was used as base of nested routes'); + ok(router.router.recognizer.names['bleep.bloop'], 'parent name was used as base of nested routes'); + ok(router.router.recognizer.names['bleep.bloop.blork'], 'parent name was used as base of nested routes'); + }); + + QUnit.test('should add loading and error routes if _isRouterMapResult is true', function () { + Router.map(function () { + this.route('blork'); + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + + router._initRouterJs(); + + ok(router.router.recognizer.names['blork'], 'main route was created'); + ok(router.router.recognizer.names['blork_loading'], 'loading route was added'); + ok(router.router.recognizer.names['blork_error'], 'error route was added'); + }); + + QUnit.test('should not add loading and error routes if _isRouterMapResult is false', function () { + Router.map(function () { + this.route('blork'); + }); + + var router = Router.create(); + router._initRouterJs(false); + + ok(router.router.recognizer.names['blork'], 'main route was created'); + ok(!router.router.recognizer.names['blork_loading'], 'loading route was not added'); + ok(!router.router.recognizer.names['blork_error'], 'error route was not added'); + }); + + QUnit.test('should reset namespace of loading and error routes for routes with resetNamespace', function () { + Router.map(function () { + this.route('blork', function () { + this.route('blorp'); + this.route('bleep', { resetNamespace: true }); + }); + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + + router._initRouterJs(); + + ok(router.router.recognizer.names['blork.blorp'], 'nested route was created'); + ok(router.router.recognizer.names['blork.blorp_loading'], 'nested loading route was added'); + ok(router.router.recognizer.names['blork.blorp_error'], 'nested error route was added'); + + ok(router.router.recognizer.names['bleep'], 'reset route was created'); + ok(router.router.recognizer.names['bleep_loading'], 'reset loading route was added'); + ok(router.router.recognizer.names['bleep_error'], 'reset error route was added'); + + ok(!router.router.recognizer.names['blork.bleep'], 'nested reset route was not created'); + ok(!router.router.recognizer.names['blork.bleep_loading'], 'nested reset loading route was not added'); + ok(!router.router.recognizer.names['blork.bleep_error'], 'nested reset error route was not added'); + }); + + QUnit.test('should throw an error when defining a route serializer outside an engine', function () { + Router.map(function () { + var _this = this; + + throws(function () { + _this.route('posts', { serialize: function () {} }); + }, /Defining a route serializer on route 'posts' outside an Engine is not allowed/); + }); + + Router.create()._initRouterJs(); + }); + + QUnit.module('Ember Router DSL with engines', { + setup: setup, + teardown: teardown + }); + + QUnit.test('should allow mounting of engines', function (assert) { + assert.expect(3); + + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.mount('chat'); + }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + assert.ok(router.router.recognizer.names['bleep'], 'parent name was used as base of nested routes'); + assert.ok(router.router.recognizer.names['bleep.bloop'], 'parent name was used as base of nested routes'); + assert.ok(router.router.recognizer.names['bleep.bloop.chat'], 'parent name was used as base of mounted engine'); + }); + + QUnit.test('should allow mounting of engines at a custom path', function (assert) { + assert.expect(1); + + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.mount('chat', { path: 'custom-chat' }); + }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + assert.deepEqual(router.router.recognizer.names['bleep.bloop.chat'].segments.slice(1, 4).map(function (s) { + return s.value; + }), ['bleep', 'bloop', 'custom-chat'], 'segments are properly associated with mounted engine'); + }); + + QUnit.test('should allow aliasing of engine names with `as`', function (assert) { + assert.expect(1); + + Router = Router.map(function () { + this.route('bleep', function () { + this.route('bloop', function () { + this.mount('chat', { as: 'blork' }); + }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + assert.deepEqual(router.router.recognizer.names['bleep.bloop.blork'].segments.slice(1, 4).map(function (s) { + return s.value; + }), ['bleep', 'bloop', 'blork'], 'segments are properly associated with mounted engine with aliased name'); + }); + + QUnit.test('should add loading and error routes to a mount if _isRouterMapResult is true', function () { + Router.map(function () { + this.mount('chat'); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + ok(router.router.recognizer.names['chat'], 'main route was created'); + ok(router.router.recognizer.names['chat_loading'], 'loading route was added'); + ok(router.router.recognizer.names['chat_error'], 'error route was added'); + }); + + QUnit.test('should add loading and error routes to a mount alias if _isRouterMapResult is true', function () { + Router.map(function () { + this.mount('chat', { as: 'shoutbox' }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + ok(router.router.recognizer.names['shoutbox'], 'main route was created'); + ok(router.router.recognizer.names['shoutbox_loading'], 'loading route was added'); + ok(router.router.recognizer.names['shoutbox_error'], 'error route was added'); + }); + + QUnit.test('should not add loading and error routes to a mount if _isRouterMapResult is false', function () { + Router.map(function () { + this.mount('chat'); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create(); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(false); + + ok(router.router.recognizer.names['chat'], 'main route was created'); + ok(!router.router.recognizer.names['chat_loading'], 'loading route was not added'); + ok(!router.router.recognizer.names['chat_error'], 'error route was not added'); + }); + + QUnit.test('should reset namespace of loading and error routes for mounts with resetNamespace', function () { + Router.map(function () { + this.route('news', function () { + this.mount('chat'); + this.mount('blog', { resetNamespace: true }); + }); + }); + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { routable: true } + }); + + var router = Router.create({ + _hasModuleBasedResolver: function () { + return true; + } + }); + _emberUtils.setOwner(router, engineInstance); + router._initRouterJs(); + + ok(router.router.recognizer.names['news.chat'], 'nested route was created'); + ok(router.router.recognizer.names['news.chat_loading'], 'nested loading route was added'); + ok(router.router.recognizer.names['news.chat_error'], 'nested error route was added'); + + ok(router.router.recognizer.names['blog'], 'reset route was created'); + ok(router.router.recognizer.names['blog_loading'], 'reset loading route was added'); + ok(router.router.recognizer.names['blog_error'], 'reset error route was added'); + + ok(!router.router.recognizer.names['news.blog'], 'nested reset route was not created'); + ok(!router.router.recognizer.names['news.blog_loading'], 'nested reset loading route was not added'); + ok(!router.router.recognizer.names['news.blog_error'], 'nested reset error route was not added'); + }); +}); +enifed('ember-routing/tests/system/dsl_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/dsl_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/dsl_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/route_test', ['exports', 'ember-utils', 'internal-test-helpers', 'ember-runtime', 'ember-routing/system/route', 'container'], function (exports, _emberUtils, _internalTestHelpers, _emberRuntime, _emberRoutingSystemRoute, _container) { + 'use strict'; + + var route = undefined, + routeOne = undefined, + routeTwo = undefined, + lookupHash = undefined; + + function setup() { + route = _emberRoutingSystemRoute.default.create(); + } + + function teardown() { + _internalTestHelpers.runDestroy(route); + } + + QUnit.module('Ember.Route', { + setup: setup, + teardown: teardown + }); + + QUnit.test('default store utilizes the container to acquire the model factory', function () { + var _ownerOptions; + + expect(4); + + var Post = _emberRuntime.Object.extend(); + var post = {}; + + Post.reopenClass({ + find: function (id) { + return post; + } + }); + + var ownerOptions = { + ownerOptions: (_ownerOptions = { + hasRegistration: function () { + return true; + } + }, _ownerOptions[_container.FACTORY_FOR] = function (fullName) { + equal(fullName, 'model:post', 'correct factory was looked up'); + + return { + class: Post, + create: function () { + return Post.create(); + } + }; + }, _ownerOptions) + }; + + _emberUtils.setOwner(route, _internalTestHelpers.buildOwner(ownerOptions)); + + route.set('_qp', null); + + equal(route.model({ post_id: 1 }), post); + equal(route.findModel('post', 1), post, '#findModel returns the correct post'); + }); + + QUnit.test('\'store\' can be injected by data persistence frameworks', function () { + expect(8); + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + + var post = { + id: 1 + }; + + var Store = _emberRuntime.Object.extend({ + find: function (type, value) { + ok(true, 'injected model was called'); + equal(type, 'post', 'correct type was called'); + equal(value, 1, 'correct value was called'); + return post; + } + }); + + owner.register('route:index', _emberRoutingSystemRoute.default); + owner.register('store:main', Store); + + owner.inject('route', 'store', 'store:main'); + + route = owner.lookup('route:index'); + + equal(route.model({ post_id: 1 }), post, '#model returns the correct post'); + equal(route.findModel('post', 1), post, '#findModel returns the correct post'); + }); + + QUnit.test('assert if \'store.find\' method is not found', function () { + expect(1); + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + var Post = _emberRuntime.Object.extend(); + + owner.register('route:index', _emberRoutingSystemRoute.default); + owner.register('model:post', Post); + + route = owner.lookup('route:index'); + + expectAssertion(function () { + route.findModel('post', 1); + }, 'Post has no method `find`.'); + }); + + QUnit.test('asserts if model class is not found', function () { + expect(1); + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + owner.register('route:index', _emberRoutingSystemRoute.default); + + route = owner.lookup('route:index'); + + expectAssertion(function () { + route.model({ post_id: 1 }); + }, /You used the dynamic segment post_id in your route undefined, but .Post did not exist and you did not override your route\'s `model` hook./); + }); + + QUnit.test('\'store\' does not need to be injected', function () { + expect(1); + + _internalTestHelpers.runDestroy(route); + + var owner = _internalTestHelpers.buildOwner(); + + owner.register('route:index', _emberRoutingSystemRoute.default); + + route = owner.lookup('route:index'); + + ignoreAssertion(function () { + route.model({ post_id: 1 }); + }); + + ok(true, 'no error was raised'); + }); + + QUnit.test('modelFor doesn\'t require the router', function () { + expect(1); + + var owner = _internalTestHelpers.buildOwner(); + _emberUtils.setOwner(route, owner); + + var foo = { name: 'foo' }; + + var FooRoute = _emberRoutingSystemRoute.default.extend({ + currentModel: foo + }); + + owner.register('route:foo', FooRoute); + + strictEqual(route.modelFor('foo'), foo); + }); + + QUnit.test('.send just calls an action if the router is absent', function () { + expect(7); + var route = _emberRoutingSystemRoute.default.extend({ + actions: { + returnsTrue: function (foo, bar) { + equal(foo, 1); + equal(bar, 2); + equal(this, route); + return true; + }, + + returnsFalse: function () { + ok(true, 'returnsFalse was called'); + return false; + } + } + }).create(); + + equal(true, route.send('returnsTrue', 1, 2)); + equal(false, route.send('returnsFalse')); + equal(undefined, route.send('nonexistent', 1, 2, 3)); + }); + + QUnit.test('.send just calls an action if the routers internal router property is absent', function () { + expect(7); + var route = _emberRoutingSystemRoute.default.extend({ + router: {}, + actions: { + returnsTrue: function (foo, bar) { + equal(foo, 1); + equal(bar, 2); + equal(this, route); + return true; + }, + + returnsFalse: function () { + ok(true, 'returnsFalse was called'); + return false; + } + } + }).create(); + + equal(true, route.send('returnsTrue', 1, 2)); + equal(false, route.send('returnsFalse')); + equal(undefined, route.send('nonexistent', 1, 2, 3)); + }); + + QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function () { + expect(2); + + var route = _emberRoutingSystemRoute.default.extend({ + actions: { + foo: function () { + ok(true, 'called foo action'); + } + } + }).create(); + + expectDeprecation(function () { + route._actions.foo(); + }, 'Usage of `_actions` is deprecated, use `actions` instead.'); + }); + + QUnit.test('actions in both `_actions` and `actions` results in an assertion', function () { + expectAssertion(function () { + _emberRoutingSystemRoute.default.extend({ + _actions: {}, + actions: {} + }).create(); + }, 'Specifying `_actions` and `actions` in the same mixin is not supported.'); + }); + + QUnit.test('actions added via `_actions` can be used [DEPRECATED]', function () { + expect(3); + + var route = undefined; + expectDeprecation(function () { + route = _emberRoutingSystemRoute.default.extend({ + _actions: { + bar: function () { + ok(true, 'called bar action'); + } + } + }, { + actions: { + foo: function () { + ok(true, 'called foo action'); + } + } + }).create(); + }, 'Specifying actions in `_actions` is deprecated, please use `actions` instead.'); + + route.send('foo'); + route.send('bar'); + }); + + QUnit.module('Ember.Route serialize', { + setup: setup, + teardown: teardown + }); + + QUnit.test('returns the models properties if params does not include *_id', function () { + var model = { id: 2, firstName: 'Ned', lastName: 'Ryerson' }; + + deepEqual(route.serialize(model, ['firstName', 'lastName']), { firstName: 'Ned', lastName: 'Ryerson' }, 'serialized correctly'); + }); + + QUnit.test('returns model.id if params include *_id', function () { + var model = { id: 2 }; + + deepEqual(route.serialize(model, ['post_id']), { post_id: 2 }, 'serialized correctly'); + }); + + QUnit.test('returns checks for existence of model.post_id before trying model.id', function () { + var model = { post_id: 3 }; + + deepEqual(route.serialize(model, ['post_id']), { post_id: 3 }, 'serialized correctly'); + }); + + QUnit.test('returns undefined if model is not set', function () { + equal(route.serialize(undefined, ['post_id']), undefined, 'serialized correctly'); + }); + + QUnit.module('Ember.Route interaction', { + setup: function () { + var owner = { + lookup: function (fullName) { + return lookupHash[fullName]; + } + }; + + routeOne = _emberRoutingSystemRoute.default.create({ routeName: 'one' }); + routeTwo = _emberRoutingSystemRoute.default.create({ routeName: 'two' }); + + _emberUtils.setOwner(routeOne, owner); + _emberUtils.setOwner(routeTwo, owner); + + lookupHash = { + 'route:one': routeOne, + 'route:two': routeTwo + }; + }, + + teardown: function () { + _internalTestHelpers.runDestroy(routeOne); + _internalTestHelpers.runDestroy(routeTwo); + } + }); + + QUnit.test('controllerFor uses route\'s controllerName if specified', function () { + var testController = {}; + lookupHash['controller:test'] = testController; + + routeOne.controllerName = 'test'; + + equal(routeTwo.controllerFor('one'), testController); + }); + + QUnit.module('Route injected properties'); + + QUnit.test('services can be injected into routes', function () { + var owner = _internalTestHelpers.buildOwner(); + + owner.register('route:application', _emberRoutingSystemRoute.default.extend({ + authService: _emberRuntime.inject.service('auth') + })); + + owner.register('service:auth', _emberRuntime.Service.extend()); + + var appRoute = owner.lookup('route:application'); + var authService = owner.lookup('service:auth'); + + equal(authService, appRoute.get('authService'), 'service.auth is injected'); + }); + + QUnit.module('Ember.Route with engines'); + + QUnit.test('paramsFor considers an engine\'s mountPoint', function (assert) { + expect(2); + + var router = { + _deserializeQueryParams: function () {}, + router: { + state: { + handlerInfos: [{ name: 'posts' }], + params: { + 'foo.bar': { a: 'b' }, + 'foo.bar.posts': { c: 'd' } + } + } + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + + mountPoint: 'foo.bar', + + lookup: function (name) { + if (name === 'route:posts') { + return postsRoute; + } else if (name === 'route:application') { + return applicationRoute; + } + } + } + }); + + var applicationRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'application', fullRouteName: 'foo.bar' }); + var postsRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'posts', fullRouteName: 'foo.bar.posts' }); + var route = _emberRoutingSystemRoute.default.create({ router: router }); + + _emberUtils.setOwner(applicationRoute, engineInstance); + _emberUtils.setOwner(postsRoute, engineInstance); + _emberUtils.setOwner(route, engineInstance); + + assert.deepEqual(route.paramsFor('application'), { a: 'b' }, 'params match for root `application` route in engine'); + assert.deepEqual(route.paramsFor('posts'), { c: 'd' }, 'params match for `posts` route in engine'); + }); + + QUnit.test('modelFor considers an engine\'s mountPoint', function () { + expect(2); + + var applicationModel = { id: '1' }; + var postsModel = { id: '2' }; + + var router = { + router: { + activeTransition: { + resolvedModels: { + 'foo.bar': applicationModel, + 'foo.bar.posts': postsModel + } + } + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + + mountPoint: 'foo.bar', + + lookup: function (name) { + if (name === 'route:posts') { + return postsRoute; + } else if (name === 'route:application') { + return applicationRoute; + } + } + } + }); + + var applicationRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'application' }); + var postsRoute = _emberRoutingSystemRoute.default.create({ router: router, routeName: 'posts' }); + var route = _emberRoutingSystemRoute.default.create({ router: router }); + + _emberUtils.setOwner(applicationRoute, engineInstance); + _emberUtils.setOwner(postsRoute, engineInstance); + _emberUtils.setOwner(route, engineInstance); + + strictEqual(route.modelFor('application'), applicationModel); + strictEqual(route.modelFor('posts'), postsModel); + }); + + QUnit.test('transitionTo considers an engine\'s mountPoint', function () { + expect(4); + + var router = { + transitionTo: function (route) { + return route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var route = _emberRoutingSystemRoute.default.create({ router: router }); + _emberUtils.setOwner(route, engineInstance); + + strictEqual(route.transitionTo('application'), 'foo.bar.application', 'properly prefixes application route'); + strictEqual(route.transitionTo('posts'), 'foo.bar.posts', 'properly prefixes child routes'); + throws(function () { + return route.transitionTo('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + strictEqual(route.transitionTo(queryParams), queryParams, 'passes query param only transitions through'); + }); + + QUnit.test('intermediateTransitionTo considers an engine\'s mountPoint', function () { + expect(4); + + var lastRoute = undefined; + var router = { + intermediateTransitionTo: function (route) { + lastRoute = route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var route = _emberRoutingSystemRoute.default.create({ router: router }); + _emberUtils.setOwner(route, engineInstance); + + route.intermediateTransitionTo('application'); + strictEqual(lastRoute, 'foo.bar.application', 'properly prefixes application route'); + + route.intermediateTransitionTo('posts'); + strictEqual(lastRoute, 'foo.bar.posts', 'properly prefixes child routes'); + + throws(function () { + return route.intermediateTransitionTo('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + route.intermediateTransitionTo(queryParams); + strictEqual(lastRoute, queryParams, 'passes query param only transitions through'); + }); + + QUnit.test('replaceWith considers an engine\'s mountPoint', function () { + expect(4); + + var router = { + replaceWith: function (route) { + return route; + } + }; + + var engineInstance = _internalTestHelpers.buildOwner({ + ownerOptions: { + routable: true, + mountPoint: 'foo.bar' + } + }); + + var route = _emberRoutingSystemRoute.default.create({ router: router }); + _emberUtils.setOwner(route, engineInstance); + + strictEqual(route.replaceWith('application'), 'foo.bar.application', 'properly prefixes application route'); + strictEqual(route.replaceWith('posts'), 'foo.bar.posts', 'properly prefixes child routes'); + throws(function () { + return route.replaceWith('/posts'); + }, 'throws when trying to use a url'); + + var queryParams = {}; + strictEqual(route.replaceWith(queryParams), queryParams, 'passes query param only transitions through'); + }); +}); +enifed('ember-routing/tests/system/route_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/route_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/route_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/system/router_test', ['exports', 'ember-utils', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/location/none_location', 'ember-routing/system/router', 'internal-test-helpers'], function (exports, _emberUtils, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingLocationNone_location, _emberRoutingSystemRouter, _internalTestHelpers) { + 'use strict'; + + var owner = undefined; + + function createRouter(settings) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var CustomRouter = _emberRoutingSystemRouter.default.extend(); + var router = CustomRouter.create(settings); + + if (!options.skipOwner) { + _emberUtils.setOwner(router, owner); + } + + if (!options.disableSetup) { + router.setupRouter(); + } + + return router; + } + + QUnit.module('Ember Router', { + setup: function () { + owner = _internalTestHelpers.buildOwner(); + + //register the HashLocation (the default) + owner.register('location:hash', _emberRoutingLocationHash_location.default); + owner.register('location:history', _emberRoutingLocationHistory_location.default); + owner.register('location:auto', _emberRoutingLocationAuto_location.default); + owner.register('location:none', _emberRoutingLocationNone_location.default); + }, + teardown: function () { + _internalTestHelpers.runDestroy(owner); + owner = null; + } + }); + + QUnit.test('can create a router without an owner', function () { + createRouter(null, { disableSetup: true, skipOwner: true }); + + ok(true, 'no errors were thrown when creating without a container'); + }); + + QUnit.test('should not create a router.js instance upon init', function () { + var router = createRouter(null, { disableSetup: true }); + + ok(!router.router); + }); + + QUnit.test('should not reify location until setupRouter is called', function () { + var router = createRouter(null, { disableSetup: true }); + equal(typeof router.location, 'string', 'location is specified as a string'); + + router.setupRouter(); + + equal(typeof router.location, 'object', 'location is reified into an object'); + }); + + QUnit.test('should destroy its location upon destroying the routers owner.', function () { + var router = createRouter(); + var location = router.get('location'); + + _internalTestHelpers.runDestroy(owner); + + ok(location.isDestroyed, 'location should be destroyed'); + }); + + QUnit.test('should instantiate its location with its `rootURL`', function () { + var router = createRouter({ + rootURL: '/rootdir/' + }); + var location = router.get('location'); + + equal(location.get('rootURL'), '/rootdir/'); + }); + + QUnit.test('replacePath should be called with the right path', function () { + expect(1); + + var location = owner.lookup('location:auto'); + + var browserLocation = { + href: 'http://test.com/rootdir/welcome', + origin: 'http://test.com', + pathname: '/rootdir/welcome', + hash: '', + search: '', + replace: function (url) { + equal(url, 'http://test.com/rootdir/#/welcome'); + } + }; + + location.location = browserLocation; + location.global = { onhashchange: function () {} }; + location.history = null; + + createRouter({ + location: 'auto', + rootURL: '/rootdir/' + }); + }); + + QUnit.test('Ember.Router._routePath should consume identical prefixes', function () { + createRouter(); + + expect(8); + + function routePath(s1, s2, s3) { + var handlerInfos = Array.prototype.slice.call(arguments).map(function (s) { + return { name: s }; + }); + handlerInfos.unshift({ name: 'ignored' }); + + return _emberRoutingSystemRouter.default._routePath(handlerInfos); + } + + equal(routePath('foo'), 'foo'); + equal(routePath('foo', 'bar', 'baz'), 'foo.bar.baz'); + equal(routePath('foo', 'foo.bar'), 'foo.bar'); + equal(routePath('foo', 'foo.bar', 'foo.bar.baz'), 'foo.bar.baz'); + equal(routePath('foo', 'foo.bar', 'foo.bar.baz.wow'), 'foo.bar.baz.wow'); + equal(routePath('foo', 'foo.bar.baz.wow'), 'foo.bar.baz.wow'); + equal(routePath('foo.bar', 'bar.baz.wow'), 'foo.bar.baz.wow'); + + // This makes no sense, not trying to handle it, just + // making sure it doesn't go boom. + equal(routePath('foo.bar.baz', 'foo'), 'foo.bar.baz.foo'); + }); + + QUnit.test('Router should cancel routing setup when the Location class says so via cancelRouterSetup', function () { + expect(0); + + var router = undefined; + var FakeLocation = { + cancelRouterSetup: true, + create: function () { + return this; + } + }; + + owner.register('location:fake', FakeLocation); + + router = createRouter({ + location: 'fake', + + _setupRouter: function () { + ok(false, '_setupRouter should not be called'); + } + }); + + router.startRouting(); + }); + + QUnit.test('AutoLocation should replace the url when it\'s not in the preferred format', function () { + expect(1); + + var location = owner.lookup('location:auto'); + + location.location = { + href: 'http://test.com/rootdir/welcome', + origin: 'http://test.com', + pathname: '/rootdir/welcome', + hash: '', + search: '', + replace: function (url) { + equal(url, 'http://test.com/rootdir/#/welcome'); + } + }; + location.history = null; + location.global = { + onhashchange: function () {} + }; + + createRouter({ + location: 'auto', + rootURL: '/rootdir/' + }); + }); + + QUnit.test('Router#handleURL should remove any #hashes before doing URL transition', function () { + expect(2); + + var router = createRouter({ + _doURLTransition: function (routerJsMethod, url) { + equal(routerJsMethod, 'handleURL'); + equal(url, '/foo/bar?time=morphin'); + } + }); + + router.handleURL('/foo/bar?time=morphin#pink-power-ranger'); + }); + + QUnit.test('Router#triggerEvent allows actions to bubble when returning true', function (assert) { + assert.expect(2); + + var handlerInfos = [{ + name: 'application', + handler: { + actions: { + loading: function () { + assert.ok(false, 'loading not handled by application route'); + } + } + } + }, { + name: 'about', + handler: { + actions: { + loading: function () { + assert.ok(true, 'loading handled by about route'); + return false; + } + } + } + }, { + name: 'about.me', + handler: { + actions: { + loading: function () { + assert.ok(true, 'loading handled by about.me route'); + return true; + } + } + } + }]; + + _emberRoutingSystemRouter.triggerEvent(handlerInfos, false, ['loading']); + }); + + QUnit.test('Router#triggerEvent ignores handlers that have not loaded yet', function (assert) { + assert.expect(1); + + var handlerInfos = [{ + name: 'about', + handler: { + actions: { + loading: function () { + assert.ok(true, 'loading handled by about route'); + } + } + } + }, { + name: 'about.me', + handler: undefined + }]; + + _emberRoutingSystemRouter.triggerEvent(handlerInfos, false, ['loading']); + }); +}); +enifed('ember-routing/tests/system/router_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/system/router_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/system/router_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/tests/utils_test', ['exports', 'ember-routing/utils'], function (exports, _emberRoutingUtils) { + 'use strict'; + + QUnit.module('Routing query parameter utils - normalizeControllerQueryParams'); + + QUnit.test('converts array style into verbose object style', function (assert) { + var paramName = 'foo'; + var params = [paramName]; + var normalized = _emberRoutingUtils.normalizeControllerQueryParams(params); + + ok(normalized[paramName], 'turns the query param name into key'); + equal(normalized[paramName].as, null, 'includes a blank alias in \'as\' key'); + equal(normalized[paramName].scope, 'model', 'defaults scope to model'); + }); + + QUnit.test('converts object style [{foo: \'an_alias\'}]', function (assert) { + var paramName = 'foo'; + var params = [{ 'foo': 'an_alias' }]; + var normalized = _emberRoutingUtils.normalizeControllerQueryParams(params); + + ok(normalized[paramName], 'retains the query param name as key'); + equal(normalized[paramName].as, 'an_alias', 'includes the provided alias in \'as\' key'); + equal(normalized[paramName].scope, 'model', 'defaults scope to model'); + }); + + QUnit.test('retains maximally verbose object style [{foo: {as: \'foo\'}}]', function (assert) { + var paramName = 'foo'; + var params = [{ 'foo': { as: 'an_alias' } }]; + var normalized = _emberRoutingUtils.normalizeControllerQueryParams(params); + + ok(normalized[paramName], 'retains the query param name as key'); + equal(normalized[paramName].as, 'an_alias', 'includes the provided alias in \'as\' key'); + equal(normalized[paramName].scope, 'model', 'defaults scope to model'); + }); +}); +enifed('ember-routing/tests/utils_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/tests/utils_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/tests/utils_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-routing/utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-routing/utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-routing/utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/compare.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/compare.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/compare.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/computed/computed_macros.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/computed/computed_macros.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/computed/computed_macros.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/computed/reduce_computed_macros.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/computed/reduce_computed_macros.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/computed/reduce_computed_macros.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/controllers/controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/controllers/controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/controllers/controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/copy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/copy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/copy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/ext/function.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/ext/function.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/ext/function.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/ext/rsvp.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/ext/rsvp.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/ext/rsvp.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/ext/string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/ext/string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/ext/string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/inject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/inject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/inject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/is-equal.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/is-equal.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/is-equal.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/-proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/-proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/-proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/action_handler.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/action_handler.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/action_handler.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/comparable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/comparable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/comparable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/container_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/container_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/container_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/controller.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/controller.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/controller.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/controller_content_model_alias_deprecation.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/controller_content_model_alias_deprecation.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/controller_content_model_alias_deprecation.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/copyable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/copyable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/copyable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/evented.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/evented.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/evented.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/freezable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/freezable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/freezable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/mutable_array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/mutable_array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/mutable_array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/mutable_enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/mutable_enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/mutable_enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/observable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/observable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/observable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/promise_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/promise_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/promise_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/registry_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/registry_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/registry_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/mixins/target_action_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/mixins/target_action_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/mixins/target_action_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/string_registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/string_registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/string_registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/application.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/array_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/array_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/array_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/core_object.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/core_object.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/core_object.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/each_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/each_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/each_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/lazy_load.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/lazy_load.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/lazy_load.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/namespace.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/namespace.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/namespace.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/native_array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/native_array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/native_array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/object.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/object.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/object.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/object_proxy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/object_proxy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/object_proxy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/service.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/service.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/service.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/system/string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/system/string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/system/string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/computed/computed_macros_test', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros', 'internal-test-helpers', 'ember-runtime/system/object', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros, _internalTestHelpers, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('CP macros'); + + _internalTestHelpers.testBoth('Ember.computed.empty', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + bestLannister: null, + lannisters: null, + + bestLannisterUnspecified: _emberRuntimeComputedComputed_macros.empty('bestLannister'), + noLannistersKnown: _emberRuntimeComputedComputed_macros.empty('lannisters') + }).create({ + lannisters: _emberRuntimeSystemNative_array.A() + }); + + equal(get(obj, 'bestLannisterUnspecified'), true, 'bestLannister initially empty'); + equal(get(obj, 'noLannistersKnown'), true, 'lannisters initially empty'); + + get(obj, 'lannisters').pushObject('Tyrion'); + set(obj, 'bestLannister', 'Tyrion'); + + equal(get(obj, 'bestLannisterUnspecified'), false, 'empty respects strings'); + equal(get(obj, 'noLannistersKnown'), false, 'empty respects array mutations'); + }); + + _internalTestHelpers.testBoth('Ember.computed.notEmpty', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + bestLannister: null, + lannisters: null, + + bestLannisterSpecified: _emberRuntimeComputedComputed_macros.notEmpty('bestLannister'), + LannistersKnown: _emberRuntimeComputedComputed_macros.notEmpty('lannisters') + }).create({ + lannisters: _emberRuntimeSystemNative_array.A() + }); + + equal(get(obj, 'bestLannisterSpecified'), false, 'bestLannister initially empty'); + equal(get(obj, 'LannistersKnown'), false, 'lannisters initially empty'); + + get(obj, 'lannisters').pushObject('Tyrion'); + set(obj, 'bestLannister', 'Tyrion'); + + equal(get(obj, 'bestLannisterSpecified'), true, 'empty respects strings'); + equal(get(obj, 'LannistersKnown'), true, 'empty respects array mutations'); + }); + + _internalTestHelpers.testBoth('computed.not', function (get, set) { + var obj = { foo: true }; + _emberMetal.defineProperty(obj, 'notFoo', _emberRuntimeComputedComputed_macros.not('foo')); + equal(get(obj, 'notFoo'), false); + + obj = { foo: { bar: true } }; + _emberMetal.defineProperty(obj, 'notFoo', _emberRuntimeComputedComputed_macros.not('foo.bar')); + equal(get(obj, 'notFoo'), false); + }); + + _internalTestHelpers.testBoth('computed.empty', function (get, set) { + var obj = { foo: [], bar: undefined, baz: null, quz: '' }; + _emberMetal.defineProperty(obj, 'fooEmpty', _emberRuntimeComputedComputed_macros.empty('foo')); + _emberMetal.defineProperty(obj, 'barEmpty', _emberRuntimeComputedComputed_macros.empty('bar')); + _emberMetal.defineProperty(obj, 'bazEmpty', _emberRuntimeComputedComputed_macros.empty('baz')); + _emberMetal.defineProperty(obj, 'quzEmpty', _emberRuntimeComputedComputed_macros.empty('quz')); + + equal(get(obj, 'fooEmpty'), true); + set(obj, 'foo', [1]); + equal(get(obj, 'fooEmpty'), false); + equal(get(obj, 'barEmpty'), true); + equal(get(obj, 'bazEmpty'), true); + equal(get(obj, 'quzEmpty'), true); + set(obj, 'quz', 'asdf'); + equal(get(obj, 'quzEmpty'), false); + }); + + _internalTestHelpers.testBoth('computed.bool', function (get, set) { + var obj = { foo: function () {}, bar: 'asdf', baz: null, quz: false }; + _emberMetal.defineProperty(obj, 'fooBool', _emberRuntimeComputedComputed_macros.bool('foo')); + _emberMetal.defineProperty(obj, 'barBool', _emberRuntimeComputedComputed_macros.bool('bar')); + _emberMetal.defineProperty(obj, 'bazBool', _emberRuntimeComputedComputed_macros.bool('baz')); + _emberMetal.defineProperty(obj, 'quzBool', _emberRuntimeComputedComputed_macros.bool('quz')); + equal(get(obj, 'fooBool'), true); + equal(get(obj, 'barBool'), true); + equal(get(obj, 'bazBool'), false); + equal(get(obj, 'quzBool'), false); + }); + + _internalTestHelpers.testBoth('computed.alias', function (get, set) { + var obj = { bar: 'asdf', baz: null, quz: false }; + _emberMetal.defineProperty(obj, 'bay', _emberMetal.computed(function (key) { + return 'apple'; + })); + + _emberMetal.defineProperty(obj, 'barAlias', _emberMetal.alias('bar')); + _emberMetal.defineProperty(obj, 'bazAlias', _emberMetal.alias('baz')); + _emberMetal.defineProperty(obj, 'quzAlias', _emberMetal.alias('quz')); + _emberMetal.defineProperty(obj, 'bayAlias', _emberMetal.alias('bay')); + + equal(get(obj, 'barAlias'), 'asdf'); + equal(get(obj, 'bazAlias'), null); + equal(get(obj, 'quzAlias'), false); + equal(get(obj, 'bayAlias'), 'apple'); + + set(obj, 'barAlias', 'newBar'); + set(obj, 'bazAlias', 'newBaz'); + set(obj, 'quzAlias', null); + + equal(get(obj, 'barAlias'), 'newBar'); + equal(get(obj, 'bazAlias'), 'newBaz'); + equal(get(obj, 'quzAlias'), null); + + equal(get(obj, 'bar'), 'newBar'); + equal(get(obj, 'baz'), 'newBaz'); + equal(get(obj, 'quz'), null); + }); + + _internalTestHelpers.testBoth('computed.alias set', function (get, set) { + var obj = {}; + var constantValue = 'always `a`'; + + _emberMetal.defineProperty(obj, 'original', _emberMetal.computed({ + get: function (key) { + return constantValue; + }, + set: function (key, value) { + return constantValue; + } + })); + _emberMetal.defineProperty(obj, 'aliased', _emberMetal.alias('original')); + + equal(get(obj, 'original'), constantValue); + equal(get(obj, 'aliased'), constantValue); + + set(obj, 'aliased', 'should not set to this value'); + + equal(get(obj, 'original'), constantValue); + equal(get(obj, 'aliased'), constantValue); + }); + + _internalTestHelpers.testBoth('computed.match', function (get, set) { + var obj = { name: 'Paul' }; + _emberMetal.defineProperty(obj, 'isPaul', _emberRuntimeComputedComputed_macros.match('name', /Paul/)); + + equal(get(obj, 'isPaul'), true, 'is Paul'); + + set(obj, 'name', 'Pierre'); + + equal(get(obj, 'isPaul'), false, 'is not Paul anymore'); + }); + + _internalTestHelpers.testBoth('computed.notEmpty', function (get, set) { + var obj = { items: [1] }; + _emberMetal.defineProperty(obj, 'hasItems', _emberRuntimeComputedComputed_macros.notEmpty('items')); + + equal(get(obj, 'hasItems'), true, 'is not empty'); + + set(obj, 'items', []); + + equal(get(obj, 'hasItems'), false, 'is empty'); + }); + + _internalTestHelpers.testBoth('computed.equal', function (get, set) { + var obj = { name: 'Paul' }; + _emberMetal.defineProperty(obj, 'isPaul', _emberRuntimeComputedComputed_macros.equal('name', 'Paul')); + + equal(get(obj, 'isPaul'), true, 'is Paul'); + + set(obj, 'name', 'Pierre'); + + equal(get(obj, 'isPaul'), false, 'is not Paul anymore'); + }); + + _internalTestHelpers.testBoth('computed.gt', function (get, set) { + var obj = { number: 2 }; + _emberMetal.defineProperty(obj, 'isGreaterThenOne', _emberRuntimeComputedComputed_macros.gt('number', 1)); + + equal(get(obj, 'isGreaterThenOne'), true, 'is gt'); + + set(obj, 'number', 1); + + equal(get(obj, 'isGreaterThenOne'), false, 'is not gt'); + + set(obj, 'number', 0); + + equal(get(obj, 'isGreaterThenOne'), false, 'is not gt'); + }); + + _internalTestHelpers.testBoth('computed.gte', function (get, set) { + var obj = { number: 2 }; + _emberMetal.defineProperty(obj, 'isGreaterOrEqualThenOne', _emberRuntimeComputedComputed_macros.gte('number', 1)); + + equal(get(obj, 'isGreaterOrEqualThenOne'), true, 'is gte'); + + set(obj, 'number', 1); + + equal(get(obj, 'isGreaterOrEqualThenOne'), true, 'is gte'); + + set(obj, 'number', 0); + + equal(get(obj, 'isGreaterOrEqualThenOne'), false, 'is not gte'); + }); + + _internalTestHelpers.testBoth('computed.lt', function (get, set) { + var obj = { number: 0 }; + _emberMetal.defineProperty(obj, 'isLesserThenOne', _emberRuntimeComputedComputed_macros.lt('number', 1)); + + equal(get(obj, 'isLesserThenOne'), true, 'is lt'); + + set(obj, 'number', 1); + + equal(get(obj, 'isLesserThenOne'), false, 'is not lt'); + + set(obj, 'number', 2); + + equal(get(obj, 'isLesserThenOne'), false, 'is not lt'); + }); + + _internalTestHelpers.testBoth('computed.lte', function (get, set) { + var obj = { number: 0 }; + _emberMetal.defineProperty(obj, 'isLesserOrEqualThenOne', _emberRuntimeComputedComputed_macros.lte('number', 1)); + + equal(get(obj, 'isLesserOrEqualThenOne'), true, 'is lte'); + + set(obj, 'number', 1); + + equal(get(obj, 'isLesserOrEqualThenOne'), true, 'is lte'); + + set(obj, 'number', 2); + + equal(get(obj, 'isLesserOrEqualThenOne'), false, 'is not lte'); + }); + + _internalTestHelpers.testBoth('computed.and two properties', function (get, set) { + var obj = { one: true, two: true }; + _emberMetal.defineProperty(obj, 'oneAndTwo', _emberRuntimeComputedComputed_macros.and('one', 'two')); + + equal(get(obj, 'oneAndTwo'), true, 'one and two'); + + set(obj, 'one', false); + + equal(get(obj, 'oneAndTwo'), false, 'one and not two'); + + set(obj, 'one', null); + set(obj, 'two', 'Yes'); + + equal(get(obj, 'oneAndTwo'), null, 'returns falsy value as in &&'); + + set(obj, 'one', true); + set(obj, 'two', 2); + + equal(get(obj, 'oneAndTwo'), 2, 'returns truthy value as in &&'); + }); + + _internalTestHelpers.testBoth('computed.and three properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.and('one', 'two', 'three')); + + equal(get(obj, 'oneTwoThree'), true, 'one and two and three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), false, 'one and not two and not three'); + + set(obj, 'one', true); + set(obj, 'two', 2); + set(obj, 'three', 3); + + equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&'); + }); + + _internalTestHelpers.testBoth('computed.and expand properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.and('{one,two,three}')); + + equal(get(obj, 'oneTwoThree'), true, 'one and two and three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), false, 'one and not two and not three'); + + set(obj, 'one', true); + set(obj, 'two', 2); + set(obj, 'three', 3); + + equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&'); + }); + + _internalTestHelpers.testBoth('computed.or two properties', function (get, set) { + var obj = { one: true, two: true }; + _emberMetal.defineProperty(obj, 'oneOrTwo', _emberRuntimeComputedComputed_macros.or('one', 'two')); + + equal(get(obj, 'oneOrTwo'), true, 'one or two'); + + set(obj, 'one', false); + + equal(get(obj, 'oneOrTwo'), true, 'one or two'); + + set(obj, 'two', false); + + equal(get(obj, 'oneOrTwo'), false, 'nor one nor two'); + + set(obj, 'two', null); + + equal(get(obj, 'oneOrTwo'), null, 'returns last falsy value as in ||'); + + set(obj, 'two', true); + + equal(get(obj, 'oneOrTwo'), true, 'one or two'); + + set(obj, 'one', 1); + + equal(get(obj, 'oneOrTwo'), 1, 'returns truthy value as in ||'); + }); + + _internalTestHelpers.testBoth('computed.or three properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.or('one', 'two', 'three')); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'two', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'three', false); + + equal(get(obj, 'oneTwoThree'), false, 'one or two or three'); + + set(obj, 'three', null); + + equal(get(obj, 'oneTwoThree'), null, 'returns last falsy value as in ||'); + + set(obj, 'two', true); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', 1); + + equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||'); + }); + + _internalTestHelpers.testBoth('computed.or expand properties', function (get, set) { + var obj = { one: true, two: true, three: true }; + _emberMetal.defineProperty(obj, 'oneTwoThree', _emberRuntimeComputedComputed_macros.or('{one,two,three}')); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'two', false); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'three', false); + + equal(get(obj, 'oneTwoThree'), false, 'one or two or three'); + + set(obj, 'three', null); + + equal(get(obj, 'oneTwoThree'), null, 'returns last falsy value as in ||'); + + set(obj, 'two', true); + + equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); + + set(obj, 'one', 1); + + equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||'); + }); + + _internalTestHelpers.testBoth('computed.or and computed.and warn about dependent keys with spaces', function (get, set) { + var obj = { one: true, two: true }; + expectAssertion(function () { + _emberMetal.defineProperty(obj, 'oneOrTwo', _emberRuntimeComputedComputed_macros.or('one', 'two three')); + }, /Dependent keys passed to Ember\.computed\.or\(\) can't have spaces\./); + + expectAssertion(function () { + _emberMetal.defineProperty(obj, 'oneAndTwo', _emberRuntimeComputedComputed_macros.and('one', 'two three')); + }, /Dependent keys passed to Ember\.computed\.and\(\) can't have spaces\./); + }); + + _internalTestHelpers.testBoth('computed.oneWay', function (get, set) { + var obj = { + firstName: 'Teddy', + lastName: 'Zeenny' + }; + + _emberMetal.defineProperty(obj, 'nickName', _emberRuntimeComputedComputed_macros.oneWay('firstName')); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + equal(get(obj, 'nickName'), 'Teddy'); + + set(obj, 'nickName', 'TeddyBear'); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + + equal(get(obj, 'nickName'), 'TeddyBear'); + + set(obj, 'firstName', 'TEDDDDDDDDYYY'); + + equal(get(obj, 'nickName'), 'TeddyBear'); + }); + + _internalTestHelpers.testBoth('computed.readOnly', function (get, set) { + var obj = { + firstName: 'Teddy', + lastName: 'Zeenny' + }; + + _emberMetal.defineProperty(obj, 'nickName', _emberRuntimeComputedComputed_macros.readOnly('firstName')); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + equal(get(obj, 'nickName'), 'Teddy'); + + throws(function () { + set(obj, 'nickName', 'TeddyBear'); + }, / /); + + equal(get(obj, 'firstName'), 'Teddy'); + equal(get(obj, 'lastName'), 'Zeenny'); + + equal(get(obj, 'nickName'), 'Teddy'); + + set(obj, 'firstName', 'TEDDDDDDDDYYY'); + + equal(get(obj, 'nickName'), 'TEDDDDDDDDYYY'); + }); + + _internalTestHelpers.testBoth('computed.deprecatingAlias', function (get, set) { + var obj = { bar: 'asdf', baz: null, quz: false }; + _emberMetal.defineProperty(obj, 'bay', _emberMetal.computed(function (key) { + return 'apple'; + })); + + _emberMetal.defineProperty(obj, 'barAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('bar')); + _emberMetal.defineProperty(obj, 'bazAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('baz')); + _emberMetal.defineProperty(obj, 'quzAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('quz')); + _emberMetal.defineProperty(obj, 'bayAlias', _emberRuntimeComputedComputed_macros.deprecatingAlias('bay')); + + expectDeprecation(function () { + equal(get(obj, 'barAlias'), 'asdf'); + }, 'Usage of `barAlias` is deprecated, use `bar` instead.'); + + expectDeprecation(function () { + equal(get(obj, 'bazAlias'), null); + }, 'Usage of `bazAlias` is deprecated, use `baz` instead.'); + + expectDeprecation(function () { + equal(get(obj, 'quzAlias'), false); + }, 'Usage of `quzAlias` is deprecated, use `quz` instead.'); + + expectDeprecation(function () { + equal(get(obj, 'bayAlias'), 'apple'); + }, 'Usage of `bayAlias` is deprecated, use `bay` instead.'); + + expectDeprecation(function () { + set(obj, 'barAlias', 'newBar'); + }, 'Usage of `barAlias` is deprecated, use `bar` instead.'); + + expectDeprecation(function () { + set(obj, 'bazAlias', 'newBaz'); + }, 'Usage of `bazAlias` is deprecated, use `baz` instead.'); + + expectDeprecation(function () { + set(obj, 'quzAlias', null); + }, 'Usage of `quzAlias` is deprecated, use `quz` instead.'); + + equal(get(obj, 'barAlias'), 'newBar'); + equal(get(obj, 'bazAlias'), 'newBaz'); + equal(get(obj, 'quzAlias'), null); + + equal(get(obj, 'bar'), 'newBar'); + equal(get(obj, 'baz'), 'newBaz'); + equal(get(obj, 'quz'), null); + }); +}); +enifed('ember-runtime/tests/computed/computed_macros_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/computed/computed_macros_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/computed/computed_macros_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/computed/reduce_computed_macros_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object', 'ember-runtime/system/object_proxy', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/utils', 'ember-runtime/system/native_array', 'ember-runtime/mixins/mutable_array'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject, _emberRuntimeSystemObject_proxy, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberRuntimeMixinsMutable_array) { + 'use strict'; + + var obj = undefined; + QUnit.module('map', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array.@each.v', function (item) { + return item.v; + }), + mappedObjects: _emberRuntimeComputedReduce_computed_macros.map('arrayObjects.@each.v', function (item) { + return { name: item.v.name }; + }) + }).create({ + arrayObjects: _emberRuntimeSystemNative_array.A([{ v: { name: 'Robert' } }, { v: { name: 'Leanna' } }]), + + array: _emberRuntimeSystemNative_array.A([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + }); + }, + + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('map is readOnly', function () { + QUnit.throws(function () { + obj.set('mapped', 1); + }, /Cannot set read-only property "mapped" on object:/); + }); + + QUnit.test('it maps simple properties', function () { + deepEqual(obj.get('mapped'), [1, 3, 2, 1]); + + obj.get('array').pushObject({ v: 5 }); + + deepEqual(obj.get('mapped'), [1, 3, 2, 1, 5]); + + _emberRuntimeMixinsMutable_array.removeAt(obj.get('array'), 3); + + deepEqual(obj.get('mapped'), [1, 3, 2, 5]); + }); + + QUnit.test('it maps simple unshifted properties', function () { + var array = _emberRuntimeSystemNative_array.A(); + + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array', function (item) { + return item.toUpperCase(); + }) + }).create({ + array: array + }); + + array.unshiftObject('c'); + array.unshiftObject('b'); + array.unshiftObject('a'); + + array.popObject(); + + deepEqual(obj.get('mapped'), ['A', 'B'], 'properties unshifted in sequence are mapped correctly'); + }); + + QUnit.test('it has the correct `this`', function () { + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array', function (item) { + equal(this, obj, 'should have correct context'); + return this.upperCase(item); + }), + upperCase: function (string) { + return string.toUpperCase(); + } + }).create({ + array: ['a', 'b', 'c'] + }); + + deepEqual(obj.get('mapped'), ['A', 'B', 'C'], 'properties unshifted in sequence are mapped correctly'); + }); + + QUnit.test('it passes the index to the callback', function () { + var array = ['a', 'b', 'c']; + + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array', function (item, index) { + return index; + }) + }).create({ + array: array + }); + + deepEqual(obj.get('mapped'), [0, 1, 2], 'index is passed to callback correctly'); + }); + + QUnit.test('it maps objects', function () { + deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Leanna' }]); + + obj.get('arrayObjects').pushObject({ + v: { name: 'Eddard' } + }); + + deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Leanna' }, { name: 'Eddard' }]); + + _emberRuntimeMixinsMutable_array.removeAt(obj.get('arrayObjects'), 1); + + deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Eddard' }]); + + _emberMetal.set(obj.get('arrayObjects')[0], 'v', { name: 'Stannis' }); + + deepEqual(obj.get('mappedObjects'), [{ name: 'Stannis' }, { name: 'Eddard' }]); + }); + + QUnit.test('it maps unshifted objects with property observers', function () { + var array = _emberRuntimeSystemNative_array.A(); + var cObj = { v: 'c' }; + + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.map('array.@each.v', function (item) { + return _emberMetal.get(item, 'v').toUpperCase(); + }) + }).create({ + array: array + }); + + array.unshiftObject(cObj); + array.unshiftObject({ v: 'b' }); + array.unshiftObject({ v: 'a' }); + + _emberMetal.set(cObj, 'v', 'd'); + + deepEqual(array.mapBy('v'), ['a', 'b', 'd'], 'precond - unmapped array is correct'); + deepEqual(obj.get('mapped'), ['A', 'B', 'D'], 'properties unshifted in sequence are mapped correctly'); + }); + + QUnit.module('mapBy', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.mapBy('array', 'v') + }).create({ + array: _emberRuntimeSystemNative_array.A([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('mapBy is readOnly', function () { + QUnit.throws(function () { + obj.set('mapped', 1); + }, /Cannot set read-only property "mapped" on object:/); + }); + + QUnit.test('it maps properties', function () { + deepEqual(obj.get('mapped'), [1, 3, 2, 1]); + + obj.get('array').pushObject({ v: 5 }); + + deepEqual(obj.get('mapped'), [1, 3, 2, 1, 5]); + + _emberRuntimeMixinsMutable_array.removeAt(obj.get('array'), 3); + + deepEqual(obj.get('mapped'), [1, 3, 2, 5]); + }); + + QUnit.test('it is observable', function () { + var calls = 0; + + deepEqual(obj.get('mapped'), [1, 3, 2, 1]); + + _emberMetal.addObserver(obj, 'mapped.@each', function () { + return calls++; + }); + + obj.get('array').pushObject({ v: 5 }); + + equal(calls, 1, 'mapBy is observable'); + }); + + QUnit.module('filter', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item) { + return item % 2 === 0; + }) + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7, 8]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('filter is readOnly', function () { + QUnit.throws(function () { + obj.set('filtered', 1); + }, /Cannot set read-only property "filtered" on object:/); + }); + + QUnit.test('it filters according to the specified filter function', function () { + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'filter filters by the specified function'); + }); + + QUnit.test('it passes the index to the callback', function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item, index) { + return index === 1; + }) + }).create({ + array: ['a', 'b', 'c'] + }); + + deepEqual(_emberMetal.get(obj, 'filtered'), ['b'], 'index is passed to callback correctly'); + }); + + QUnit.test('it has the correct `this`', function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item, index) { + equal(this, obj); + return this.isOne(index); + }), + isOne: function (value) { + return value === 1; + } + }).create({ + array: ['a', 'b', 'c'] + }); + + deepEqual(_emberMetal.get(obj, 'filtered'), ['b'], 'index is passed to callback correctly'); + }); + + QUnit.test('it passes the array to the callback', function () { + obj = _emberRuntimeSystemObject.default.extend({ + filtered: _emberRuntimeComputedReduce_computed_macros.filter('array', function (item, index, array) { + return index === _emberMetal.get(array, 'length') - 2; + }) + }).create({ + array: _emberRuntimeSystemNative_array.A(['a', 'b', 'c']) + }); + + deepEqual(obj.get('filtered'), ['b'], 'array is passed to callback correctly'); + }); + + QUnit.test('it caches properly', function () { + var array = obj.get('array'); + + var filtered = obj.get('filtered'); + ok(filtered === obj.get('filtered')); + + array.addObject(11); + var newFiltered = obj.get('filtered'); + + ok(filtered !== newFiltered); + + ok(obj.get('filtered') === newFiltered); + }); + + QUnit.test('it updates as the array is modified', function () { + var array = obj.get('array'); + + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + array.addObject(11); + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'objects not passing the filter are not added'); + + array.addObject(12); + deepEqual(obj.get('filtered'), [2, 4, 6, 8, 12], 'objects passing the filter are added'); + + array.removeObject(3); + array.removeObject(4); + + deepEqual(obj.get('filtered'), [2, 6, 8, 12], 'objects removed from the dependent array are removed from the computed array'); + }); + + QUnit.test('the dependent array can be cleared one at a time', function () { + var array = _emberMetal.get(obj, 'array'); + + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + // clear 1-8 but in a random order + array.removeObject(3); + array.removeObject(1); + array.removeObject(2); + array.removeObject(4); + array.removeObject(8); + array.removeObject(6); + array.removeObject(5); + array.removeObject(7); + + deepEqual(obj.get('filtered'), [], 'filtered array cleared correctly'); + }); + + QUnit.test('the dependent array can be `clear`ed directly (#3272)', function () { + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + obj.get('array').clear(); + + deepEqual(obj.get('filtered'), [], 'filtered array cleared correctly'); + }); + + QUnit.test('it updates as the array is replaced', function () { + deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); + + obj.set('array', [20, 21, 22, 23, 24]); + + deepEqual(obj.get('filtered'), [20, 22, 24], 'computed array is updated when array is changed'); + }); + + QUnit.module('filterBy', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + a1s: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'a', 1), + as: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'a'), + bs: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'b') + }).create({ + array: _emberRuntimeSystemNative_array.A([{ name: 'one', a: 1, b: false }, { name: 'two', a: 2, b: false }, { name: 'three', a: 1, b: true }, { name: 'four', b: true }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('filterBy is readOnly', function () { + QUnit.throws(function () { + obj.set('as', 1); + }, /Cannot set read-only property "as" on object:/); + }); + + QUnit.test('properties can be filtered by truthiness', function () { + deepEqual(obj.get('as').mapBy('name'), ['one', 'two', 'three'], 'properties can be filtered by existence'); + deepEqual(obj.get('bs').mapBy('name'), ['three', 'four'], 'booleans can be filtered'); + + _emberMetal.set(obj.get('array')[0], 'a', undefined); + _emberMetal.set(obj.get('array')[3], 'a', true); + + _emberMetal.set(obj.get('array')[0], 'b', true); + _emberMetal.set(obj.get('array')[3], 'b', false); + + deepEqual(obj.get('as').mapBy('name'), ['two', 'three', 'four'], 'arrays computed by filter property respond to property changes'); + deepEqual(obj.get('bs').mapBy('name'), ['one', 'three'], 'arrays computed by filtered property respond to property changes'); + + obj.get('array').pushObject({ name: 'five', a: 6, b: true }); + + deepEqual(obj.get('as').mapBy('name'), ['two', 'three', 'four', 'five'], 'arrays computed by filter property respond to added objects'); + deepEqual(obj.get('bs').mapBy('name'), ['one', 'three', 'five'], 'arrays computed by filtered property respond to added objects'); + + obj.get('array').popObject(); + + deepEqual(obj.get('as').mapBy('name'), ['two', 'three', 'four'], 'arrays computed by filter property respond to removed objects'); + deepEqual(obj.get('bs').mapBy('name'), ['one', 'three'], 'arrays computed by filtered property respond to removed objects'); + + obj.set('array', [{ name: 'six', a: 12, b: true }]); + + deepEqual(obj.get('as').mapBy('name'), ['six'], 'arrays computed by filter property respond to array changes'); + deepEqual(obj.get('bs').mapBy('name'), ['six'], 'arrays computed by filtered property respond to array changes'); + }); + + QUnit.test('properties can be filtered by values', function () { + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'three'], 'properties can be filtered by matching value'); + + obj.get('array').pushObject({ name: 'five', a: 1 }); + + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'three', 'five'], 'arrays computed by matching value respond to added objects'); + + obj.get('array').popObject(); + + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'three'], 'arrays computed by matching value respond to removed objects'); + + _emberMetal.set(obj.get('array')[1], 'a', 1); + _emberMetal.set(obj.get('array')[2], 'a', 2); + + deepEqual(obj.get('a1s').mapBy('name'), ['one', 'two'], 'arrays computed by matching value respond to modified properties'); + }); + + QUnit.test('properties values can be replaced', function () { + obj = _emberRuntimeSystemObject.default.extend({ + a1s: _emberRuntimeComputedReduce_computed_macros.filterBy('array', 'a', 1), + a1bs: _emberRuntimeComputedReduce_computed_macros.filterBy('a1s', 'b') + }).create({ + array: [] + }); + + deepEqual(obj.get('a1bs').mapBy('name'), [], 'properties can be filtered by matching value'); + + _emberMetal.set(obj, 'array', [{ name: 'item1', a: 1, b: true }]); + + deepEqual(obj.get('a1bs').mapBy('name'), ['item1'], 'properties can be filtered by matching value'); + }); + + [['uniq', _emberRuntimeComputedReduce_computed_macros.uniq], ['union', _emberRuntimeComputedReduce_computed_macros.union]].forEach(function (tuple) { + var name = tuple[0]; + var macro = tuple[1]; + + QUnit.module('computed.' + name, { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + union: macro('array', 'array2', 'array3') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6]), + array2: _emberRuntimeSystemNative_array.A([4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9]), + array3: _emberRuntimeSystemNative_array.A([1, 8, 10]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test(name + ' is readOnly', function () { + QUnit.throws(function () { + obj.set('union', 1); + }, /Cannot set read-only property "union" on object:/); + }); + + QUnit.test('does not include duplicates', function () { + var array = obj.get('array'); + var array2 = obj.get('array2'); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' does not include duplicates'); + + array.pushObject(8); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' does not add existing items'); + + array.pushObject(11); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], name + ' adds new items'); + + _emberRuntimeMixinsMutable_array.removeAt(array2, 6); // remove 7 + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], name + ' does not remove items that are still in the dependent array'); + + array2.removeObject(7); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 8, 9, 10, 11], name + ' removes items when their last instance is gone'); + }); + + QUnit.test('has set-union semantics', function () { + var array = obj.get('array'); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' is initially correct'); + + array.removeObject(6); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'objects are not removed if they exist in other dependent arrays'); + + array.clear(); + + deepEqual(obj.get('union').sort(function (x, y) { + return x - y; + }), [1, 4, 5, 6, 7, 8, 9, 10], 'objects are removed when they are no longer in any dependent array'); + }); + }); + + QUnit.module('computed.uniqBy', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + list: null, + uniqueById: _emberRuntimeComputedReduce_computed_macros.uniqBy('list', 'id') + }).create({ + list: _emberRuntimeSystemNative_array.A([{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 1, value: 'one' }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('uniqBy is readOnly', function () { + QUnit.throws(function () { + obj.set('uniqueById', 1); + }, /Cannot set read-only property "uniqueById" on object:/); + }); + QUnit.test('does not include duplicates', function () { + deepEqual(obj.get('uniqueById'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }]); + }); + + QUnit.test('it does not share state among instances', function () { + var MyObject = _emberRuntimeSystemObject.default.extend({ + list: [], + uniqueByName: _emberRuntimeComputedReduce_computed_macros.uniqBy('list', 'name') + }); + var a = MyObject.create({ list: [{ name: 'bob' }, { name: 'mitch' }, { name: 'mitch' }] }); + var b = MyObject.create({ list: [{ name: 'warren' }, { name: 'mitch' }] }); + + deepEqual(a.get('uniqueByName'), [{ name: 'bob' }, { name: 'mitch' }]); + // Making sure that 'mitch' appears + deepEqual(b.get('uniqueByName'), [{ name: 'warren' }, { name: 'mitch' }]); + }); + + QUnit.test('it handles changes to the dependent array', function () { + obj.get('list').pushObject({ id: 3, value: 'three' }); + + deepEqual(obj.get('uniqueById'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 3, value: 'three' }], 'The list includes three'); + + obj.get('list').pushObject({ id: 3, value: 'three' }); + + deepEqual(obj.get('uniqueById'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 3, value: 'three' }], 'The list does not include a duplicate three'); + }); + + QUnit.test('it returns an empty array when computed on a non-array', function () { + var MyObject = _emberRuntimeSystemObject.default.extend({ + list: null, + uniq: _emberRuntimeComputedReduce_computed_macros.uniqBy('list', 'name') + }); + var a = MyObject.create({ list: 'not an array' }); + + deepEqual(a.get('uniq'), []); + }); + + QUnit.module('computed.intersect', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + intersection: _emberRuntimeComputedReduce_computed_macros.intersect('array', 'array2', 'array3') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6]), + array2: _emberRuntimeSystemNative_array.A([3, 3, 3, 4, 5]), + array3: _emberRuntimeSystemNative_array.A([3, 5, 6, 7, 8]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('intersect is readOnly', function () { + QUnit.throws(function () { + obj.set('intersection', 1); + }, /Cannot set read-only property "intersection" on object:/); + }); + + QUnit.test('it has set-intersection semantics', function () { + var array2 = obj.get('array2'); + var array3 = obj.get('array3'); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [3, 5], 'intersection is initially correct'); + + array2.shiftObject(); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [3, 5], 'objects are not removed when they are still in all dependent arrays'); + + array2.shiftObject(); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [3, 5], 'objects are not removed when they are still in all dependent arrays'); + + array2.shiftObject(); + + deepEqual(obj.get('intersection'), [5], 'objects are removed once they are gone from all dependent arrays'); + + array2.pushObject(1); + + deepEqual(obj.get('intersection'), [5], 'objects are not added as long as they are missing from any dependent array'); + + array3.pushObject(1); + + deepEqual(obj.get('intersection').sort(function (x, y) { + return x - y; + }), [1, 5], 'objects added once they belong to all dependent arrays'); + }); + + QUnit.module('setDiff', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + diff: _emberRuntimeComputedReduce_computed_macros.setDiff('array', 'array2') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7]), + array2: _emberRuntimeSystemNative_array.A([3, 4, 5, 10]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('setDiff is readOnly', function () { + QUnit.throws(function () { + obj.set('diff', 1); + }, /Cannot set read-only property "diff" on object:/); + }); + + QUnit.test('it throws an error if given fewer or more than two dependent properties', function () { + throws(function () { + _emberRuntimeSystemObject.default.extend({ + diff: _emberRuntimeComputedReduce_computed_macros.setDiff('array') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7]), + array2: _emberRuntimeSystemNative_array.A([3, 4, 5]) + }); + }, /requires exactly two dependent arrays/, 'setDiff requires two dependent arrays'); + + throws(function () { + _emberRuntimeSystemObject.default.extend({ + diff: _emberRuntimeComputedReduce_computed_macros.setDiff('array', 'array2', 'array3') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5, 6, 7]), + array2: _emberRuntimeSystemNative_array.A([3, 4, 5]), + array3: _emberRuntimeSystemNative_array.A([7]) + }); + }, /requires exactly two dependent arrays/, 'setDiff requires two dependent arrays'); + }); + + QUnit.test('it has set-diff semantics', function () { + var array1 = obj.get('array'); + var array2 = obj.get('array2'); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'set-diff is initially correct'); + + array2.popObject(); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'removing objects from the remove set has no effect if the object is not in the keep set'); + + array2.shiftObject(); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 3, 6, 7], 'removing objects from the remove set adds them if they\'re in the keep set'); + + array1.removeObject(3); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'removing objects from the keep array removes them from the computed array'); + + array1.pushObject(5); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7], 'objects added to the keep array that are in the remove array are not added to the computed array'); + + array1.pushObject(22); + + deepEqual(obj.get('diff').sort(function (x, y) { + return x - y; + }), [1, 2, 6, 7, 22], 'objects added to the keep array not in the remove array are added to the computed array'); + }); + + function commonSortTests() { + QUnit.test('arrays are initially sorted', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'array is initially sorted'); + }); + + QUnit.test('default sort order is correct', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'array is initially sorted'); + }); + + QUnit.test('changing the dependent array updates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('items', [{ fname: 'Roose', lname: 'Bolton' }, { fname: 'Theon', lname: 'Greyjoy' }, { fname: 'Ramsey', lname: 'Bolton' }, { fname: 'Stannis', lname: 'Baratheon' }]); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Stannis', 'Ramsey', 'Roose', 'Theon'], 'changing dependent array updates sorted array'); + }); + + QUnit.test('adding to the dependent array updates the sorted array', function () { + var items = obj.get('items'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + items.pushObject({ + fname: 'Tyrion', + lname: 'Lannister' + }); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb'], 'Adding to the dependent array updates the sorted array'); + }); + + QUnit.test('removing from the dependent array updates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.get('items').popObject(); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Robb'], 'Removing from the dependent array updates the sorted array'); + }); + + QUnit.test('distinct items may be sort-equal, although their relative order will not be guaranteed', function () { + // We recreate jaime and "Cersei" here only for test stability: we want + // their guid-ordering to be deterministic + var jaimeInDisguise = { + fname: 'Cersei', + lname: 'Lannister', + age: 34 + }; + + var jaime = { + fname: 'Jaime', + lname: 'Lannister', + age: 34 + }; + + var items = obj.get('items'); + + items.replace(0, 1, jaime); + items.replace(1, 1, jaimeInDisguise); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(jaimeInDisguise, 'fname', 'Jaime'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Jaime', 'Bran', 'Robb'], 'sorted array is updated'); + + _emberMetal.set(jaimeInDisguise, 'fname', 'Cersei'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'sorted array is updated'); + }); + + QUnit.test('guid sort-order fallback with a search proxy is not confused by non-search ObjectProxys', function () { + var tyrion = { + fname: 'Tyrion', + lname: 'Lannister' + }; + + var tyrionInDisguise = _emberRuntimeSystemObject_proxy.default.create({ + fname: 'Yollo', + lname: '', + content: tyrion + }); + + var items = obj.get('items'); + + items.pushObject(tyrion); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb']); + + items.pushObject(tyrionInDisguise); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Yollo', 'Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb']); + }); + } + + QUnit.module('sort - sortProperties', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items', 'itemSorting') + }).create({ + itemSorting: _emberRuntimeSystemNative_array.A(['lname', 'fname']), + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sort is readOnly', function () { + QUnit.throws(function () { + obj.set('sortedItems', 1); + }, /Cannot set read-only property "sortedItems" on object:/); + }); + + commonSortTests(); + + QUnit.test('updating sort properties detaches observers for old sort properties', function () { + var objectToRemove = obj.get('items')[3]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['fname:desc'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei', 'Bran'], 'after updating sort properties array is updated'); + + obj.get('items').removeObject(objectToRemove); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei'], 'after removing item array is updated'); + + _emberMetal.set(objectToRemove, 'lname', 'Updated-Stark'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei'], 'after changing removed item array is not updated'); + }); + + QUnit.test('updating sort properties updates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['fname:desc'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Robb', 'Jaime', 'Cersei', 'Bran'], 'after updating sort properties array is updated'); + }); + + QUnit.test('updating sort properties invalidates the sorted array', function () { + var sortProps = obj.get('itemSorting'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + sortProps.clear(); + sortProps.pushObject('fname'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Bran', 'Cersei', 'Jaime', 'Robb'], 'after updating sort properties array is updated'); + }); + + QUnit.test('updating new sort properties invalidates the sorted array', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['age:desc', 'fname:asc'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Robb', 'Bran'], 'precond - array is correct after item sorting is changed'); + + _emberMetal.set(obj.get('items')[1], 'age', 29); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Cersei', 'Robb', 'Bran'], 'after updating sort properties array is updated'); + }); + + QUnit.test('sort direction defaults to ascending', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb']); + }); + + QUnit.test('sort direction defaults to ascending (with sort property change)', function () { + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + obj.set('itemSorting', _emberRuntimeSystemNative_array.A(['fname'])); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Bran', 'Cersei', 'Jaime', 'Robb'], 'sort direction defaults to ascending'); + }); + + QUnit.test('updating an item\'s sort properties updates the sorted array', function () { + var tyrionInDisguise = obj.get('items')[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(tyrionInDisguise, 'fname', 'Tyrion'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Tyrion', 'Bran', 'Robb'], 'updating an item\'s sort properties updates the sorted array'); + }); + + QUnit.test('updating several of an item\'s sort properties updated the sorted array', function () { + var sansaInDisguise = obj.get('items')[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.setProperties(sansaInDisguise, { + fname: 'Sansa', + lname: 'Stark' + }); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Bran', 'Robb', 'Sansa'], 'updating an item\'s sort properties updates the sorted array'); + }); + + QUnit.test('updating an item\'s sort properties does not error when binary search does a self compare (#3273)', function () { + var jaime = { + name: 'Jaime', + status: 1 + }; + + var cersei = { + name: 'Cersei', + status: 2 + }; + + var obj = _emberRuntimeSystemObject.default.extend({ + sortProps: ['status'], + sortedPeople: _emberRuntimeComputedReduce_computed_macros.sort('people', 'sortProps') + }).create({ + people: [jaime, cersei] + }); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'precond - array is initially sorted'); + + _emberMetal.set(cersei, 'status', 3); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'array is sorted correctly'); + + _emberMetal.set(cersei, 'status', 2); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'array is sorted correctly'); + }); + + QUnit.test('array observers do not leak', function () { + var daria = { name: 'Daria' }; + var jane = { name: 'Jane' }; + + var sisters = [jane, daria]; + + var sortProps = _emberRuntimeSystemNative_array.A(['name']); + var jaime = _emberRuntimeSystemObject.default.extend({ + sortedPeople: _emberRuntimeComputedReduce_computed_macros.sort('sisters', 'sortProps'), + sortProps: sortProps + }).create({ + sisters: sisters + }); + + jaime.get('sortedPeople'); + _emberMetal.run(jaime, 'destroy'); + + try { + sortProps.pushObject({ + name: 'Anna' + }); + ok(true); + } catch (e) { + ok(false, e); + } + }); + + QUnit.test('property paths in sort properties update the sorted array', function () { + var jaime = { + relatedObj: { status: 1, firstName: 'Jaime', lastName: 'Lannister' } + }; + + var cersei = { + relatedObj: { status: 2, firstName: 'Cersei', lastName: 'Lannister' } + }; + + var sansa = _emberRuntimeSystemObject.default.create({ + relatedObj: { status: 3, firstName: 'Sansa', lastName: 'Stark' } + }); + + var obj = _emberRuntimeSystemObject.default.extend({ + sortProps: ['relatedObj.status'], + sortedPeople: _emberRuntimeComputedReduce_computed_macros.sort('people', 'sortProps') + }).create({ + people: [jaime, cersei, sansa] + }); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'precond - array is initially sorted'); + + _emberMetal.set(cersei, 'status', 3); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'array is sorted correctly'); + + _emberMetal.set(cersei, 'status', 1); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'array is sorted correctly'); + + sansa.set('status', 1); + + deepEqual(obj.get('sortedPeople'), [jaime, cersei, sansa], 'array is sorted correctly'); + + obj.set('sortProps', ['relatedObj.firstName']); + + deepEqual(obj.get('sortedPeople'), [cersei, jaime, sansa], 'array is sorted correctly'); + }); + + QUnit.test('if the dependentKey is neither an array nor object, it will return an empty array', function () { + _emberMetal.set(obj, 'items', null); + ok(_emberRuntimeUtils.isArray(obj.get('sortedItems')), 'returns an empty arrays'); + + _emberMetal.set(obj, 'array', undefined); + ok(_emberRuntimeUtils.isArray(obj.get('sortedItems')), 'returns an empty arrays'); + + _emberMetal.set(obj, 'array', 'not an array'); + ok(_emberRuntimeUtils.isArray(obj.get('sortedItems')), 'returns an empty arrays'); + }); + + function sortByLnameFname(a, b) { + var lna = _emberMetal.get(a, 'lname'); + var lnb = _emberMetal.get(b, 'lname'); + + if (lna !== lnb) { + return lna > lnb ? 1 : -1; + } + + return sortByFnameAsc(a, b); + } + + function sortByFnameAsc(a, b) { + var fna = _emberMetal.get(a, 'fname'); + var fnb = _emberMetal.get(b, 'fname'); + + if (fna === fnb) { + return 0; + } + return fna > fnb ? 1 : -1; + } + + QUnit.module('sort - sort function', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items.@each.fname', sortByLnameFname) + }).create({ + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sort has correct `this`', function () { + var obj = _emberRuntimeSystemObject.default.extend({ + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items.@each.fname', function (a, b) { + equal(this, obj, 'expected the object to be `this`'); + return this.sortByLastName(a, b); + }), + sortByLastName: function (a, b) { + return sortByFnameAsc(a, b); + } + }).create({ + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + + obj.get('sortedItems'); + }); + + QUnit.test('sort (with function) is readOnly', function () { + QUnit.throws(function () { + obj.set('sortedItems', 1); + }, /Cannot set read-only property "sortedItems" on object:/); + }); + + commonSortTests(); + + QUnit.test('changing item properties specified via @each triggers a resort of the modified item', function () { + var items = _emberMetal.get(obj, 'items'); + + var tyrionInDisguise = items[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(tyrionInDisguise, 'fname', 'Tyrion'); + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Jaime', 'Tyrion', 'Bran', 'Robb'], 'updating a specified property on an item resorts it'); + }); + + QUnit.test('changing item properties not specified via @each does not trigger a resort', function () { + var items = obj.get('items'); + var cersei = items[1]; + + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); + + _emberMetal.set(cersei, 'lname', 'Stark'); // plot twist! (possibly not canon) + + // The array has become unsorted. If your sort function is sensitive to + // properties, they *must* be specified as dependent item property keys or + // we'll be doing binary searches on unsorted arrays. + deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'updating an unspecified property on an item does not resort it'); + }); + + QUnit.module('sort - stability', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sortProps: ['count', 'name'], + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items', 'sortProps') + }).create({ + items: [{ name: 'A', count: 1, thing: 4 }, { name: 'B', count: 1, thing: 3 }, { name: 'C', count: 1, thing: 2 }, { name: 'D', count: 1, thing: 4 }] + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sorts correctly as only one property changes', function () { + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[3], 'count', 2); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'final'); + }); + + var klass = undefined; + QUnit.module('sort - concurrency', { + setup: function () { + klass = _emberRuntimeSystemObject.default.extend({ + sortProps: ['count'], + sortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items', 'sortProps'), + customSortedItems: _emberRuntimeComputedReduce_computed_macros.sort('items.@each.count', function (a, b) { + return a.count - b.count; + }) + }); + obj = klass.create({ + items: _emberRuntimeSystemNative_array.A([{ name: 'A', count: 1, thing: 4, id: 1 }, { name: 'B', count: 2, thing: 3, id: 2 }, { name: 'C', count: 3, thing: 2, id: 3 }, { name: 'D', count: 4, thing: 1, id: 4 }]) + }); + }, + + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sorts correctly after mutation to the sort properties', function () { + var sorted = obj.get('sortedItems'); + deepEqual(sorted.mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + }); + + QUnit.test('sort correctly after mutation to the sort', function () { + deepEqual(obj.get('customSortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + + deepEqual(obj.get('customSortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + }); + + QUnit.test('sort correctly on multiple instances of the same class', function () { + var obj2 = klass.create({ + items: _emberRuntimeSystemNative_array.A([{ name: 'W', count: 23, thing: 4 }, { name: 'X', count: 24, thing: 3 }, { name: 'Y', count: 25, thing: 2 }, { name: 'Z', count: 26, thing: 1 }]) + }); + + deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'X', 'Y', 'Z'], 'initial'); + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + _emberMetal.set(obj2.get('items')[1], 'count', 27); + _emberMetal.set(obj2.get('items')[2], 'count', 28); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'Z', 'X', 'Y'], 'final'); + + obj.set('sortProps', ['thing']); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['D', 'C', 'B', 'A'], 'final'); + + obj2.notifyPropertyChange('sortedItems'); // invalidate to flush, to get DK refreshed + obj2.get('sortedItems'); // flush to get updated DK + + obj2.set('items.firstObject.count', 9999); + + deepEqual(obj2.get('sortedItems').mapBy('name'), ['Z', 'X', 'Y', 'W'], 'final'); + }); + + QUnit.test('sort correctly when multiple sorts are chained on the same instance of a class', function () { + var obj2 = klass.extend({ + items: _emberMetal.computed('sibling.sortedItems.[]', function () { + return this.get('sibling.sortedItems'); + }), + asdf: _emberMetal.observer('sibling.sortedItems.[]', function () { + this.get('sibling.sortedItems'); + }) + }).create({ + sibling: obj + }); + + /* + ┌───────────┐ ┌────────────┐ + │sortedProps│ │sortedProps2│ + └───────────┘ └────────────┘ + ▲ ▲ + │ ╔═══════════╗ │ + │─ ─ ─ ─ ─ ─ ─ ▶║ CP (sort) ║◀─ ─ ─ ─ ─ ─ ─ ┤ + │ ╚═══════════╝ │ + │ │ + ┌───────────┐ ┏━━━━━━━━━━━┓ ┏━━━━━━━━━━━━┓ + │ │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ + │ items │◀── items.@each.count │◀──┃sortedItems┃◀─── items.@each.count │◀───┃sortedItems2┃ + │ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃ ┃ + └───────────┘ ┗━━━━━━━━━━━┛ ┗━━━━━━━━━━━━┛ + */ + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'obj.sortedItems.name should be sorted alpha'); + deepEqual(obj2.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'obj2.sortedItems.name should be sorted alpha'); + + _emberMetal.set(obj.get('items')[1], 'count', 5); + _emberMetal.set(obj.get('items')[2], 'count', 6); + + deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'obj.sortedItems.name should now have changed'); + deepEqual(obj2.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'obj2.sortedItems.name should still mirror sortedItems2'); + + obj.set('sortProps', ['thing']); + obj2.set('sortProps', ['id']); + + deepEqual(obj2.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'we now sort obj2 by id, so we expect a b c d'); + deepEqual(obj.get('sortedItems').mapBy('name'), ['D', 'C', 'B', 'A'], 'we now sort obj by thing'); + }); + + QUnit.module('max', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + max: _emberRuntimeComputedReduce_computed_macros.max('items') + }).create({ + items: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('max is readOnly', function () { + QUnit.throws(function () { + obj.set('max', 1); + }, /Cannot set read-only property "max" on object:/); + }); + + QUnit.test('max tracks the max number as objects are added', function () { + equal(obj.get('max'), 3, 'precond - max is initially correct'); + + var items = obj.get('items'); + + items.pushObject(5); + + equal(obj.get('max'), 5, 'max updates when a larger number is added'); + + items.pushObject(2); + + equal(obj.get('max'), 5, 'max does not update when a smaller number is added'); + }); + + QUnit.test('max recomputes when the current max is removed', function () { + equal(obj.get('max'), 3, 'precond - max is initially correct'); + + obj.get('items').removeObject(2); + + equal(obj.get('max'), 3, 'max is unchanged when a non-max item is removed'); + + obj.get('items').removeObject(3); + + equal(obj.get('max'), 1, 'max is recomputed when the current max is removed'); + }); + + QUnit.module('min', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + min: _emberRuntimeComputedReduce_computed_macros.min('items') + }).create({ + items: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('min is readOnly', function () { + QUnit.throws(function () { + obj.set('min', 1); + }, /Cannot set read-only property "min" on object:/); + }); + + QUnit.test('min tracks the min number as objects are added', function () { + equal(obj.get('min'), 1, 'precond - min is initially correct'); + + obj.get('items').pushObject(-2); + + equal(obj.get('min'), -2, 'min updates when a smaller number is added'); + + obj.get('items').pushObject(2); + + equal(obj.get('min'), -2, 'min does not update when a larger number is added'); + }); + + QUnit.test('min recomputes when the current min is removed', function () { + var items = obj.get('items'); + + equal(obj.get('min'), 1, 'precond - min is initially correct'); + + items.removeObject(2); + + equal(obj.get('min'), 1, 'min is unchanged when a non-min item is removed'); + + items.removeObject(1); + + equal(obj.get('min'), 3, 'min is recomputed when the current min is removed'); + }); + + QUnit.module('Ember.arrayComputed - mixed sugar', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + lannisters: _emberRuntimeComputedReduce_computed_macros.filterBy('items', 'lname', 'Lannister'), + lannisterSorting: _emberRuntimeSystemNative_array.A(['fname']), + sortedLannisters: _emberRuntimeComputedReduce_computed_macros.sort('lannisters', 'lannisterSorting'), + + starks: _emberRuntimeComputedReduce_computed_macros.filterBy('items', 'lname', 'Stark'), + starkAges: _emberRuntimeComputedReduce_computed_macros.mapBy('starks', 'age'), + oldestStarkAge: _emberRuntimeComputedReduce_computed_macros.max('starkAges') + }).create({ + items: _emberRuntimeSystemNative_array.A([{ fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, { fname: 'Bran', lname: 'Stark', age: 8 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('filtering and sorting can be combined', function () { + var items = obj.get('items'); + + deepEqual(obj.get('sortedLannisters').mapBy('fname'), ['Cersei', 'Jaime'], 'precond - array is initially filtered and sorted'); + + items.pushObject({ fname: 'Tywin', lname: 'Lannister' }); + items.pushObject({ fname: 'Lyanna', lname: 'Stark' }); + items.pushObject({ fname: 'Gerion', lname: 'Lannister' }); + + deepEqual(obj.get('sortedLannisters').mapBy('fname'), ['Cersei', 'Gerion', 'Jaime', 'Tywin'], 'updates propagate to array'); + }); + + QUnit.test('filtering, sorting and reduce (max) can be combined', function () { + var items = obj.get('items'); + + equal(16, obj.get('oldestStarkAge'), 'precond - end of chain is initially correct'); + + items.pushObject({ fname: 'Rickon', lname: 'Stark', age: 5 }); + + equal(16, obj.get('oldestStarkAge'), 'chain is updated correctly'); + + items.pushObject({ fname: 'Eddard', lname: 'Stark', age: 35 }); + + equal(35, obj.get('oldestStarkAge'), 'chain is updated correctly'); + }); + + function todo(name, priority) { + return _emberRuntimeSystemObject.default.create({ name: name, priority: priority }); + } + + function priorityComparator(todoA, todoB) { + var pa = parseInt(_emberMetal.get(todoA, 'priority'), 10); + var pb = parseInt(_emberMetal.get(todoB, 'priority'), 10); + + return pa - pb; + } + + function evenPriorities(todo) { + var p = parseInt(_emberMetal.get(todo, 'priority'), 10); + + return p % 2 === 0; + } + + QUnit.module('Ember.arrayComputed - chains', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + sorted: _emberRuntimeComputedReduce_computed_macros.sort('todos.@each.priority', priorityComparator), + filtered: _emberRuntimeComputedReduce_computed_macros.filter('sorted.@each.priority', evenPriorities) + }).create({ + todos: _emberRuntimeSystemNative_array.A([todo('E', 4), todo('D', 3), todo('C', 2), todo('B', 1), todo('A', 0)]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('it can filter and sort when both depend on the same item property', function () { + deepEqual(obj.get('todos').mapBy('name'), ['E', 'D', 'C', 'B', 'A'], 'precond - todos initially correct'); + deepEqual(obj.get('sorted').mapBy('name'), ['A', 'B', 'C', 'D', 'E'], 'precond - sorted initially correct'); + deepEqual(obj.get('filtered').mapBy('name'), ['A', 'C', 'E'], 'precond - filtered initially correct'); + + _emberMetal.set(obj.get('todos')[1], 'priority', 6); + + deepEqual(obj.get('todos').mapBy('name'), ['E', 'D', 'C', 'B', 'A'], 'precond - todos remain correct'); + deepEqual(obj.get('sorted').mapBy('name'), ['A', 'B', 'C', 'E', 'D'], 'precond - sorted updated correctly'); + deepEqual(obj.get('filtered').mapBy('name'), ['A', 'C', 'E', 'D'], 'filtered updated correctly'); + }); + + var userFnCalls = undefined; + QUnit.module('Chaining array and reduced CPs', { + setup: function () { + userFnCalls = 0; + obj = _emberRuntimeSystemObject.default.extend({ + mapped: _emberRuntimeComputedReduce_computed_macros.mapBy('array', 'v'), + max: _emberRuntimeComputedReduce_computed_macros.max('mapped'), + maxDidChange: _emberMetal.observer('max', function () { + return userFnCalls++; + }) + }).create({ + array: _emberRuntimeSystemNative_array.A([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + }); + }, + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('it computes interdependent array computed properties', function () { + equal(obj.get('max'), 3, 'sanity - it properly computes the maximum value'); + + var calls = 0; + + _emberMetal.addObserver(obj, 'max', function () { + return calls++; + }); + + obj.get('array').pushObject({ v: 5 }); + + equal(obj.get('max'), 5, 'maximum value is updated correctly'); + equal(userFnCalls, 1, 'object defined observers fire'); + equal(calls, 1, 'runtime created observers fire'); + }); + + QUnit.module('sum', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + total: _emberRuntimeComputedReduce_computed_macros.sum('array') + }).create({ + array: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + }, + + teardown: function () { + _emberMetal.run(obj, 'destroy'); + } + }); + + QUnit.test('sum is readOnly', function () { + QUnit.throws(function () { + obj.set('total', 1); + }, /Cannot set read-only property "total" on object:/); + }); + QUnit.test('sums the values in the dependentKey', function () { + equal(obj.get('total'), 6, 'sums the values'); + }); + + QUnit.test('if the dependentKey is neither an array nor object, it will return `0`', function () { + _emberMetal.set(obj, 'array', null); + equal(_emberMetal.get(obj, 'total'), 0, 'returns 0'); + + _emberMetal.set(obj, 'array', undefined); + equal(_emberMetal.get(obj, 'total'), 0, 'returns 0'); + + _emberMetal.set(obj, 'array', 'not an array'); + equal(_emberMetal.get(obj, 'total'), 0, 'returns 0'); + }); + + QUnit.test('updates when array is modified', function () { + obj.get('array').pushObject(1); + + equal(obj.get('total'), 7, 'recomputed when elements are added'); + + obj.get('array').popObject(); + + equal(obj.get('total'), 6, 'recomputes when elements are removed'); + }); + + QUnit.module('collect'); + + _internalTestHelpers.testBoth('works', function (get, set) { + var obj = { one: 'foo', two: 'bar', three: null }; + _emberMetal.defineProperty(obj, 'all', _emberRuntimeComputedReduce_computed_macros.collect('one', 'two', 'three', 'four')); + + deepEqual(get(obj, 'all'), ['foo', 'bar', null, null], 'have all of them'); + + set(obj, 'four', true); + + deepEqual(get(obj, 'all'), ['foo', 'bar', null, true], 'have all of them'); + + var a = []; + set(obj, 'one', 0); + set(obj, 'three', a); + + deepEqual(get(obj, 'all'), [0, 'bar', a, true], 'have all of them'); + }); +}); +enifed('ember-runtime/tests/computed/reduce_computed_macros_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/computed/reduce_computed_macros_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/computed/reduce_computed_macros_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/controllers/controller_test', ['exports', 'ember-runtime/controllers/controller', 'ember-runtime/system/service', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/inject', 'internal-test-helpers'], function (exports, _emberRuntimeControllersController, _emberRuntimeSystemService, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeInject, _internalTestHelpers) { + /* global EmberDev */ + + 'use strict'; + + QUnit.module('Controller event handling'); + + QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function () { + expect(2); + + var controller = _emberRuntimeControllersController.default.extend({ + actions: { + foo: function () { + ok(true, 'called foo action'); + } + } + }).create(); + + expectDeprecation(function () { + controller._actions.foo(); + }, 'Usage of `_actions` is deprecated, use `actions` instead.'); + }); + + QUnit.test('Action can be handled by a function on actions object', function () { + expect(1); + var TestController = _emberRuntimeControllersController.default.extend({ + actions: { + poke: function () { + ok(true, 'poked'); + } + } + }); + var controller = TestController.create(); + controller.send('poke'); + }); + + QUnit.test('A handled action can be bubbled to the target for continued processing', function () { + expect(2); + var TestController = _emberRuntimeControllersController.default.extend({ + actions: { + poke: function () { + ok(true, 'poked 1'); + return true; + } + } + }); + + var controller = TestController.create({ + target: _emberRuntimeControllersController.default.extend({ + actions: { + poke: function () { + ok(true, 'poked 2'); + } + } + }).create() + }); + controller.send('poke'); + }); + + QUnit.test('Action can be handled by a superclass\' actions object', function () { + expect(4); + + var SuperController = _emberRuntimeControllersController.default.extend({ + actions: { + foo: function () { + ok(true, 'foo'); + }, + bar: function (msg) { + equal(msg, 'HELLO'); + } + } + }); + + var BarControllerMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + var IndexController = SuperController.extend(BarControllerMixin, { + actions: { + baz: function () { + ok(true, 'baz'); + } + } + }); + + var controller = IndexController.create({}); + controller.send('foo'); + controller.send('bar', 'HELLO'); + controller.send('baz'); + }); + + QUnit.module('Controller deprecations'); + + QUnit.module('Controller Content -> Model Alias'); + + QUnit.test('`model` is aliased as `content`', function () { + expect(1); + var controller = _emberRuntimeControllersController.default.extend({ + model: 'foo-bar' + }).create(); + + equal(controller.get('content'), 'foo-bar', 'content is an alias of model'); + }); + + QUnit.test('`content` is moved to `model` when `model` is unset', function () { + expect(2); + var controller = undefined; + + ignoreDeprecation(function () { + controller = _emberRuntimeControllersController.default.extend({ + content: 'foo-bar' + }).create(); + }); + + equal(controller.get('model'), 'foo-bar', 'model is set properly'); + equal(controller.get('content'), 'foo-bar', 'content is set properly'); + }); + + QUnit.test('specifying `content` (without `model` specified) results in deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberRuntimeControllersController.default.extend({ + content: 'foo-bar' + }).create(); + }, 'Do not specify `content` on a Controller, use `model` instead.'); + }); + + QUnit.test('specifying `content` (with `model` specified) does not result in deprecation', function () { + expect(3); + expectNoDeprecation(); + + var controller = _emberRuntimeControllersController.default.extend({ + content: 'foo-bar', + model: 'blammo' + }).create(); + + equal(_emberMetal.get(controller, 'content'), 'foo-bar'); + equal(_emberMetal.get(controller, 'model'), 'blammo'); + }); + + QUnit.module('Controller injected properties'); + + if (!EmberDev.runningProdBuild) { + QUnit.test('defining a controller on a non-controller should fail assertion', function () { + expectAssertion(function () { + var owner = _internalTestHelpers.buildOwner(); + + var AnObject = _emberRuntimeSystemObject.default.extend({ + foo: _emberRuntimeInject.default.controller('bar') + }); + + owner.register('foo:main', AnObject); + + if (true) { + expectDeprecation(function () { + owner._lookupFactory('foo:main'); + }, /Using "_lookupFactory" is deprecated. Please use container.factoryFor instead./); + } else { + owner._lookupFactory('foo:main'); + } + }, /Defining an injected controller property on a non-controller is not allowed./); + }); + } + + QUnit.test('controllers can be injected into controllers', function () { + var owner = _internalTestHelpers.buildOwner(); + + owner.register('controller:post', _emberRuntimeControllersController.default.extend({ + postsController: _emberRuntimeInject.default.controller('posts') + })); + + owner.register('controller:posts', _emberRuntimeControllersController.default.extend()); + + var postController = owner.lookup('controller:post'); + var postsController = owner.lookup('controller:posts'); + + equal(postsController, postController.get('postsController'), 'controller.posts is injected'); + }); + + QUnit.test('services can be injected into controllers', function () { + var owner = _internalTestHelpers.buildOwner(); + + owner.register('controller:application', _emberRuntimeControllersController.default.extend({ + authService: _emberRuntimeInject.default.service('auth') + })); + + owner.register('service:auth', _emberRuntimeSystemService.default.extend()); + + var appController = owner.lookup('controller:application'); + var authService = owner.lookup('service:auth'); + + equal(authService, appController.get('authService'), 'service.auth is injected'); + }); +}); +enifed('ember-runtime/tests/controllers/controller_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/controllers/controller_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/controllers/controller_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/compare_test', ['exports', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/compare', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeCompare, _emberRuntimeMixinsComparable) { + 'use strict'; + + var data = []; + var Comp = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsComparable.default); + + Comp.reopenClass({ + compare: function (obj) { + return obj.get('val'); + } + }); + + QUnit.module('Ember.compare()', { + setup: function () { + data[0] = null; + data[1] = false; + data[2] = true; + data[3] = -12; + data[4] = 3.5; + data[5] = 'a string'; + data[6] = 'another string'; + data[7] = 'last string'; + data[8] = [1, 2]; + data[9] = [1, 2, 3]; + data[10] = [1, 3]; + data[11] = { a: 'hash' }; + data[12] = _emberRuntimeSystemObject.default.create(); + data[13] = function (a) { + return a; + }; + data[14] = new Date('2012/01/01'); + data[15] = new Date('2012/06/06'); + } + }); + + QUnit.test('ordering should work', function () { + var suspect = undefined, + comparable = undefined, + failureMessage = undefined, + suspectIndex = undefined, + comparableIndex = undefined; + + for (suspectIndex = 0; suspectIndex < data.length; suspectIndex++) { + suspect = data[suspectIndex]; + + equal(_emberRuntimeCompare.default(suspect, suspect), 0, suspectIndex + ' should equal itself'); + + for (comparableIndex = suspectIndex + 1; comparableIndex < data.length; comparableIndex++) { + comparable = data[comparableIndex]; + + failureMessage = 'data[' + suspectIndex + '] (' + _emberRuntimeUtils.typeOf(suspect) + ') should be smaller than data[' + comparableIndex + '] (' + _emberRuntimeUtils.typeOf(comparable) + ')'; + + equal(_emberRuntimeCompare.default(suspect, comparable), -1, failureMessage); + } + } + }); + + QUnit.test('comparables should return values in the range of -1, 0, 1', function () { + var negOne = Comp.create({ + val: -1 + }); + + var zero = Comp.create({ + val: 0 + }); + + var one = Comp.create({ + val: 1 + }); + + equal(_emberRuntimeCompare.default(negOne, 'a'), -1, 'First item comparable - returns -1 (not negated)'); + equal(_emberRuntimeCompare.default(zero, 'b'), 0, 'First item comparable - returns 0 (not negated)'); + equal(_emberRuntimeCompare.default(one, 'c'), 1, 'First item comparable - returns 1 (not negated)'); + + equal(_emberRuntimeCompare.default('a', negOne), 1, 'Second item comparable - returns -1 (negated)'); + equal(_emberRuntimeCompare.default('b', zero), 0, 'Second item comparable - returns 0 (negated)'); + equal(_emberRuntimeCompare.default('c', one), -1, 'Second item comparable - returns 1 (negated)'); + }); +}); +enifed('ember-runtime/tests/core/compare_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/compare_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/compare_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/copy_test', ['exports', 'ember-runtime/copy'], function (exports, _emberRuntimeCopy) { + 'use strict'; + + QUnit.module('Ember Copy Method'); + + QUnit.test('Ember.copy null', function () { + var obj = { field: null }; + + equal(_emberRuntimeCopy.default(obj, true).field, null, 'null should still be null'); + }); + + QUnit.test('Ember.copy date', function () { + var date = new Date(2014, 7, 22); + var dateCopy = _emberRuntimeCopy.default(date); + + equal(date.getTime(), dateCopy.getTime(), 'dates should be equivalent'); + }); + + QUnit.test('Ember.copy null prototype object', function () { + var obj = Object.create(null); + + obj.foo = 'bar'; + + equal(_emberRuntimeCopy.default(obj).foo, 'bar', 'bar should still be bar'); + }); + + QUnit.test('Ember.copy Array', function () { + var array = [1, null, new Date(2015, 9, 9), 'four']; + var arrayCopy = _emberRuntimeCopy.default(array); + + deepEqual(array, arrayCopy, 'array content cloned successfully in new array'); + }); +}); +enifed('ember-runtime/tests/core/copy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/copy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/copy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/isEqual_test', ['exports', 'ember-runtime/is-equal'], function (exports, _emberRuntimeIsEqual) { + 'use strict'; + + QUnit.module('isEqual'); + + QUnit.test('undefined and null', function () { + ok(_emberRuntimeIsEqual.default(undefined, undefined), 'undefined is equal to undefined'); + ok(!_emberRuntimeIsEqual.default(undefined, null), 'undefined is not equal to null'); + ok(_emberRuntimeIsEqual.default(null, null), 'null is equal to null'); + ok(!_emberRuntimeIsEqual.default(null, undefined), 'null is not equal to undefined'); + }); + + QUnit.test('strings should be equal', function () { + ok(!_emberRuntimeIsEqual.default('Hello', 'Hi'), 'different Strings are unequal'); + ok(_emberRuntimeIsEqual.default('Hello', 'Hello'), 'same Strings are equal'); + }); + + QUnit.test('numericals should be equal', function () { + ok(_emberRuntimeIsEqual.default(24, 24), 'same numbers are equal'); + ok(!_emberRuntimeIsEqual.default(24, 21), 'different numbers are inequal'); + }); + + QUnit.test('dates should be equal', function () { + ok(_emberRuntimeIsEqual.default(new Date(1985, 7, 22), new Date(1985, 7, 22)), 'same dates are equal'); + ok(!_emberRuntimeIsEqual.default(new Date(2014, 7, 22), new Date(1985, 7, 22)), 'different dates are not equal'); + }); + + QUnit.test('array should be equal', function () { + // NOTE: We don't test for array contents -- that would be too expensive. + ok(!_emberRuntimeIsEqual.default([1, 2], [1, 2]), 'two array instances with the same values should not be equal'); + ok(!_emberRuntimeIsEqual.default([1, 2], [1]), 'two array instances with different values should not be equal'); + }); + + QUnit.test('first object implements isEqual should use it', function () { + ok(_emberRuntimeIsEqual.default({ isEqual: function () { + return true; + } }, null), 'should return true always'); + + var obj = { isEqual: function () { + return false; + } }; + equal(_emberRuntimeIsEqual.default(obj, obj), false, 'should return false because isEqual returns false'); + }); +}); +enifed('ember-runtime/tests/core/isEqual_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/isEqual_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/isEqual_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/is_array_test', ['exports', 'ember-runtime/utils', 'ember-runtime/system/native_array', 'ember-runtime/system/array_proxy', 'ember-environment'], function (exports, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberRuntimeSystemArray_proxy, _emberEnvironment) { + 'use strict'; + + QUnit.module('Ember Type Checking'); + + var global = undefined; + + QUnit.test('Ember.isArray', function () { + var numarray = [1, 2, 3]; + var number = 23; + var strarray = ['Hello', 'Hi']; + var string = 'Hello'; + var object = {}; + var length = { length: 12 }; + var fn = function () {}; + var arrayProxy = _emberRuntimeSystemArray_proxy.default.create({ content: _emberRuntimeSystemNative_array.A() }); + + equal(_emberRuntimeUtils.isArray(numarray), true, '[1,2,3]'); + equal(_emberRuntimeUtils.isArray(number), false, '23'); + equal(_emberRuntimeUtils.isArray(strarray), true, '["Hello", "Hi"]'); + equal(_emberRuntimeUtils.isArray(string), false, '"Hello"'); + equal(_emberRuntimeUtils.isArray(object), false, '{}'); + equal(_emberRuntimeUtils.isArray(length), true, '{ length: 12 }'); + equal(_emberRuntimeUtils.isArray(global), false, 'global'); + equal(_emberRuntimeUtils.isArray(fn), false, 'function() {}'); + equal(_emberRuntimeUtils.isArray(arrayProxy), true, '[]'); + }); + + if (_emberEnvironment.environment.window && typeof _emberEnvironment.environment.window.FileList === 'function') { + QUnit.test('Ember.isArray(fileList)', function () { + var fileListElement = document.createElement('input'); + fileListElement.type = 'file'; + var fileList = fileListElement.files; + equal(_emberRuntimeUtils.isArray(fileList), false, 'fileList'); + }); + } +}); +enifed('ember-runtime/tests/core/is_array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/is_array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/is_array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/is_empty_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.isEmpty'); + + QUnit.test('Ember.isEmpty', function () { + var arrayProxy = _emberRuntimeSystemArray_proxy.default.create({ content: _emberRuntimeSystemNative_array.A() }); + + equal(true, _emberMetal.isEmpty(arrayProxy), 'for an ArrayProxy that has empty content'); + }); +}); +enifed('ember-runtime/tests/core/is_empty_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/is_empty_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/is_empty_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/core/type_of_test', ['exports', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-environment'], function (exports, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberEnvironment) { + 'use strict'; + + QUnit.module('Ember Type Checking'); + + QUnit.test('Ember.typeOf', function () { + var MockedDate = function () {}; + MockedDate.prototype = new Date(); + + var mockedDate = new MockedDate(); + var date = new Date(); + var error = new Error('boum'); + var object = { a: 'b' }; + var a = null; + var arr = [1, 2, 3]; + var obj = {}; + var instance = _emberRuntimeSystemObject.default.create({ method: function () {} }); + + equal(_emberRuntimeUtils.typeOf(), 'undefined', 'undefined'); + equal(_emberRuntimeUtils.typeOf(null), 'null', 'null'); + equal(_emberRuntimeUtils.typeOf('Cyril'), 'string', 'Cyril'); + equal(_emberRuntimeUtils.typeOf(101), 'number', '101'); + equal(_emberRuntimeUtils.typeOf(true), 'boolean', 'true'); + equal(_emberRuntimeUtils.typeOf([1, 2, 90]), 'array', '[1,2,90]'); + equal(_emberRuntimeUtils.typeOf(/abc/), 'regexp', '/abc/'); + equal(_emberRuntimeUtils.typeOf(date), 'date', 'new Date()'); + equal(_emberRuntimeUtils.typeOf(mockedDate), 'date', 'mocked date'); + equal(_emberRuntimeUtils.typeOf(error), 'error', 'error'); + equal(_emberRuntimeUtils.typeOf(object), 'object', 'object'); + equal(_emberRuntimeUtils.typeOf(undefined), 'undefined', 'item of type undefined'); + equal(_emberRuntimeUtils.typeOf(a), 'null', 'item of type null'); + equal(_emberRuntimeUtils.typeOf(arr), 'array', 'item of type array'); + equal(_emberRuntimeUtils.typeOf(obj), 'object', 'item of type object'); + equal(_emberRuntimeUtils.typeOf(instance), 'instance', 'item of type instance'); + equal(_emberRuntimeUtils.typeOf(instance.method), 'function', 'item of type function'); + equal(_emberRuntimeUtils.typeOf(_emberRuntimeSystemObject.default.extend()), 'class', 'item of type class'); + equal(_emberRuntimeUtils.typeOf(new Error()), 'error', 'item of type error'); + }); + + if (_emberEnvironment.environment.window && typeof _emberEnvironment.environment.window.FileList === 'function') { + QUnit.test('Ember.typeOf(fileList)', function () { + var fileListElement = document.createElement('input'); + fileListElement.type = 'file'; + var fileList = fileListElement.files; + equal(_emberRuntimeUtils.typeOf(fileList), 'filelist', 'item of type filelist'); + }); + } +}); +enifed('ember-runtime/tests/core/type_of_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/core/type_of_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/core/type_of_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/ext/function_test', ['exports', 'ember-environment', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object', 'ember-runtime/mixins/evented'], function (exports, _emberEnvironment, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject, _emberRuntimeMixinsEvented) { + 'use strict'; + + QUnit.module('Function.prototype.observes() helper'); + + _internalTestHelpers.testBoth('global observer helper takes multiple params', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('undefined' === typeof Function.prototype.observes, 'Function.prototype helper disabled'); + return; + } + + var MyMixin = _emberMetal.Mixin.create({ + + count: 0, + + foo: (function () { + set(this, 'count', get(this, 'count') + 1); + }).observes('bar', 'baz') + + }); + + var obj = _emberMetal.mixin({}, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 2, 'should invoke observer after change'); + }); + + QUnit.module('Function.prototype.on() helper'); + + _internalTestHelpers.testBoth('sets up an event listener, and can trigger the function on multiple events', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('undefined' === typeof Function.prototype.on, 'Function.prototype helper disabled'); + return; + } + + var MyMixin = _emberMetal.Mixin.create({ + + count: 0, + + foo: (function () { + set(this, 'count', get(this, 'count') + 1); + }).on('bar', 'baz') + + }); + + var obj = _emberMetal.mixin({}, _emberRuntimeMixinsEvented.default, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); + + obj.trigger('bar'); + obj.trigger('baz'); + equal(get(obj, 'count'), 2, 'should invoke listeners when events trigger'); + }); + + _internalTestHelpers.testBoth('can be chained with observes', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('Function.prototype helper disabled'); + return; + } + + var MyMixin = _emberMetal.Mixin.create({ + + count: 0, + bay: 'bay', + foo: (function () { + set(this, 'count', get(this, 'count') + 1); + }).observes('bay').on('bar') + }); + + var obj = _emberMetal.mixin({}, _emberRuntimeMixinsEvented.default, MyMixin); + equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); + + set(obj, 'bay', 'BAY'); + obj.trigger('bar'); + equal(get(obj, 'count'), 2, 'should invoke observer and listener'); + }); + + QUnit.module('Function.prototype.property() helper'); + + _internalTestHelpers.testBoth('sets up a ComputedProperty', function (get, set) { + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + ok('undefined' === typeof Function.prototype.property, 'Function.prototype helper disabled'); + return; + } + + var MyClass = _emberRuntimeSystemObject.default.extend({ + firstName: null, + lastName: null, + fullName: (function () { + return get(this, 'firstName') + ' ' + get(this, 'lastName'); + }).property('firstName', 'lastName') + }); + + var obj = MyClass.create({ firstName: 'Fred', lastName: 'Flinstone' }); + equal(get(obj, 'fullName'), 'Fred Flinstone', 'should return the computed value'); + + set(obj, 'firstName', 'Wilma'); + equal(get(obj, 'fullName'), 'Wilma Flinstone', 'should return the new computed value'); + + set(obj, 'lastName', ''); + equal(get(obj, 'fullName'), 'Wilma ', 'should return the new computed value'); + }); +}); +enifed('ember-runtime/tests/ext/function_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/ext/function_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/ext/function_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/ext/mixin_test', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; + + QUnit.module('system/mixin/binding_test'); + + QUnit.test('Defining a property ending in Binding should setup binding when applied', function () { + var MyMixin = _emberMetal.Mixin.create({ + fooBinding: 'bar.baz' + }); + + var obj = { bar: { baz: 'BIFF' } }; + + _emberMetal.run(function () { + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + MyMixin.apply(obj); + }, deprecationMessage); + }); + + ok(_emberMetal.get(obj, 'fooBinding') instanceof _emberMetal.Binding, 'should be a binding object'); + equal(_emberMetal.get(obj, 'foo'), 'BIFF', 'binding should be created and synced'); + }); + + QUnit.test('Defining a property ending in Binding should apply to prototype children', function () { + var MyMixin = _emberMetal.run(function () { + return _emberMetal.Mixin.create({ + fooBinding: 'bar.baz' + }); + }); + + var obj = { bar: { baz: 'BIFF' } }; + + _emberMetal.run(function () { + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + MyMixin.apply(obj); + }, deprecationMessage); + }); + + var obj2 = Object.create(obj); + _emberMetal.run(function () { + return _emberMetal.set(_emberMetal.get(obj2, 'bar'), 'baz', 'BARG'); + }); + + ok(_emberMetal.get(obj2, 'fooBinding') instanceof _emberMetal.Binding, 'should be a binding object'); + equal(_emberMetal.get(obj2, 'foo'), 'BARG', 'binding should be created and synced'); + }); +}); +enifed('ember-runtime/tests/ext/mixin_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/ext/mixin_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/ext/mixin_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/ext/rsvp_test', ['exports', 'ember-metal', 'ember-runtime/ext/rsvp'], function (exports, _emberMetal, _emberRuntimeExtRsvp) { + 'use strict'; + + var ORIGINAL_ONERROR = _emberMetal.getOnerror(); + + QUnit.module('Ember.RSVP', { + teardown: function () { + _emberMetal.setOnerror(ORIGINAL_ONERROR); + } + }); + + QUnit.test('Ensure that errors thrown from within a promise are sent to the console', function () { + var error = new Error('Error thrown in a promise for testing purposes.'); + + try { + _emberMetal.run(function () { + new _emberRuntimeExtRsvp.default.Promise(function (resolve, reject) { + throw error; + }); + }); + ok(false, 'expected assertion to be thrown'); + } catch (e) { + equal(e, error, 'error was re-thrown'); + } + }); + + QUnit.test('TransitionAborted errors are not re-thrown', function () { + expect(1); + var fakeTransitionAbort = { name: 'TransitionAborted' }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', fakeTransitionAbort); + + ok(true, 'did not throw an error when dealing with TransitionAborted'); + }); + + QUnit.test('Can reject with non-Error object', function (assert) { + var wasEmberTesting = _emberMetal.isTesting(); + _emberMetal.setTesting(false); + expect(1); + + try { + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', 'foo'); + } catch (e) { + ok(false, 'should not throw'); + } finally { + _emberMetal.setTesting(wasEmberTesting); + } + + ok(true); + }); + + QUnit.test('Can reject with no arguments', function (assert) { + var wasEmberTesting = _emberMetal.isTesting(); + _emberMetal.setTesting(false); + expect(1); + + try { + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject'); + } catch (e) { + ok(false, 'should not throw'); + } finally { + _emberMetal.setTesting(wasEmberTesting); + } + + ok(true); + }); + + QUnit.test('rejections like jqXHR which have errorThrown property work', function () { + expect(2); + + var wasEmberTesting = _emberMetal.isTesting(); + var wasOnError = _emberMetal.getOnerror(); + + try { + (function () { + _emberMetal.setTesting(false); + _emberMetal.setOnerror(function (error) { + equal(error, actualError, 'expected the real error on the jqXHR'); + equal(error.__reason_with_error_thrown__, jqXHR, 'also retains a helpful reference to the rejection reason'); + }); + + var actualError = new Error('OMG what really happened'); + var jqXHR = { + errorThrown: actualError + }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', jqXHR); + })(); + } finally { + _emberMetal.setOnerror(wasOnError); + _emberMetal.setTesting(wasEmberTesting); + } + }); + + QUnit.test('rejections where the errorThrown is a string should wrap the sting in an error object', function () { + expect(2); + + var wasEmberTesting = _emberMetal.isTesting(); + var wasOnError = _emberMetal.getOnerror(); + + try { + (function () { + _emberMetal.setTesting(false); + _emberMetal.setOnerror(function (error) { + equal(error.message, actualError, 'expected the real error on the jqXHR'); + equal(error.__reason_with_error_thrown__, jqXHR, 'also retains a helpful reference to the rejection reason'); + }); + + var actualError = 'OMG what really happened'; + var jqXHR = { + errorThrown: actualError + }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', jqXHR); + })(); + } finally { + _emberMetal.setOnerror(wasOnError); + _emberMetal.setTesting(wasEmberTesting); + } + }); + + QUnit.test('rejections can be serialized to JSON', function (assert) { + expect(2); + + var wasEmberTesting = _emberMetal.isTesting(); + var wasOnError = _emberMetal.getOnerror(); + + try { + _emberMetal.setTesting(false); + _emberMetal.setOnerror(function (error) { + assert.equal(error.message, 'a fail'); + assert.ok(JSON.stringify(error), 'Error can be serialized'); + }); + + var jqXHR = { + errorThrown: new Error('a fail') + }; + + _emberMetal.run(_emberRuntimeExtRsvp.default, 'reject', jqXHR); + } finally { + _emberMetal.setOnerror(wasOnError); + _emberMetal.setTesting(wasEmberTesting); + } + }); + + var reason = 'i failed'; + QUnit.module('Ember.test: rejection assertions'); + + function ajax(something) { + return _emberRuntimeExtRsvp.default.Promise(function (resolve) { + QUnit.stop(); + setTimeout(function () { + QUnit.start(); + resolve(); + }, 0); // fake true / foreign async + }); + } + + QUnit.test('unambigiously unhandled rejection', function () { + QUnit.throws(function () { + _emberMetal.run(function () { + _emberRuntimeExtRsvp.default.Promise.reject(reason); + }); // something is funky, we should likely assert + }, reason); + }); + + QUnit.test('sync handled', function () { + _emberMetal.run(function () { + _emberRuntimeExtRsvp.default.Promise.reject(reason).catch(function () {}); + }); // handled, we shouldn't need to assert. + ok(true, 'reached end of test'); + }); + + QUnit.test('handled within the same micro-task (via Ember.RVP.Promise)', function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + _emberRuntimeExtRsvp.default.Promise.resolve(1).then(function () { + return rejection.catch(function () {}); + }); + }); // handled, we shouldn't need to assert. + ok(true, 'reached end of test'); + }); + + QUnit.test('handled within the same micro-task (via direct run-loop)', function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + _emberMetal.run.schedule('afterRender', function () { + return rejection.catch(function () {}); + }); + }); // handled, we shouldn't need to assert. + ok(true, 'reached end of test'); + }); + + QUnit.test('handled in the next microTask queue flush (run.next)', function () { + expect(2); + + QUnit.throws(function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + + QUnit.stop(); + _emberMetal.run.next(function () { + QUnit.start(); + rejection.catch(function () {}); + ok(true, 'reached end of test'); + }); + }); + }, reason); + + // a promise rejection survived a full flush of the run-loop without being handled + // this is very likely an issue. + }); + + QUnit.test('handled in the same microTask Queue flush do to data locality', function () { + // an ambiguous scenario, this may or may not assert + // it depends on the locality of `user#1` + var store = { + find: function () { + return _emberRuntimeExtRsvp.default.Promise.resolve(1); + } + }; + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + store.find('user', 1).then(function () { + return rejection.catch(function () {}); + }); + }); + + ok(true, 'reached end of test'); + }); + + QUnit.test('handled in a different microTask Queue flush do to data locality', function () { + // an ambiguous scenario, this may or may not assert + // it depends on the locality of `user#1` + var store = { + find: function () { + return ajax(); + } + }; + QUnit.throws(function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + store.find('user', 1).then(function () { + rejection.catch(function () {}); + ok(true, 'reached end of test'); + }); + }); + }, reason); + }); + + QUnit.test('handled in the next microTask queue flush (ajax example)', function () { + QUnit.throws(function () { + _emberMetal.run(function () { + var rejection = _emberRuntimeExtRsvp.default.Promise.reject(reason); + ajax('/something/').then(function () { + rejection.catch(function () {}); + ok(true, 'reached end of test'); + }); + }); + }, reason); + }); +}); +enifed('ember-runtime/tests/ext/rsvp_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/ext/rsvp_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/ext/rsvp_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/inject_test', ['exports', 'ember-metal', 'ember-runtime/inject', 'ember-runtime/system/object', 'internal-test-helpers'], function (exports, _emberMetal, _emberRuntimeInject, _emberRuntimeSystemObject, _internalTestHelpers) { + /* global EmberDev */ + + 'use strict'; + + QUnit.module('inject'); + + QUnit.test('calling `inject` directly should error', function () { + expectAssertion(function () { + _emberRuntimeInject.default('foo'); + }, /Injected properties must be created through helpers/); + }); + + if (!EmberDev.runningProdBuild) { + // this check is done via an assertion which is stripped from + // production builds + QUnit.test('injection type validation is run when first looked up', function () { + _emberRuntimeInject.createInjectionHelper('foo', function () { + ok(true, 'should call validation method'); + }); + + var owner = _internalTestHelpers.buildOwner(); + + var AnObject = _emberRuntimeSystemObject.default.extend({ + bar: _emberRuntimeInject.default.foo(), + baz: _emberRuntimeInject.default.foo() + }); + + owner.register('foo:main', AnObject); + + if (true) { + expect(2); + expectDeprecation(function () { + owner._lookupFactory('foo:main'); + }, /Using "_lookupFactory" is deprecated. Please use container.factoryFor instead./); + } else { + expect(1); + owner._lookupFactory('foo:main'); + } + }); + + QUnit.test('attempting to inject a nonexistent container key should error', function () { + var owner = _internalTestHelpers.buildOwner(); + var AnObject = _emberRuntimeSystemObject.default.extend({ + foo: new _emberMetal.InjectedProperty('bar', 'baz') + }); + + owner.register('foo:main', AnObject); + + throws(function () { + owner.lookup('foo:main'); + }, /Attempting to inject an unknown injection: 'bar:baz'/); + }); + } + + QUnit.test('factories should return a list of lazy injection full names', function () { + var AnObject = _emberRuntimeSystemObject.default.extend({ + foo: new _emberMetal.InjectedProperty('foo', 'bar'), + bar: new _emberMetal.InjectedProperty('quux') + }); + + deepEqual(AnObject._lazyInjections(), { 'foo': 'foo:bar', 'bar': 'quux:bar' }, 'should return injected container keys'); + }); +}); +enifed('ember-runtime/tests/inject_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/inject_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/inject_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/chained_test', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * changed obj.set() and obj.get() to Ember.set() and Ember.get() + * changed obj.addObserver() to addObserver() + */ + + QUnit.module('Ember.Observable - Observing with @each'); + + QUnit.test('chained observers on enumerable properties are triggered when the observed property of any item changes', function () { + var family = _emberRuntimeSystemObject.default.create({ momma: null }); + var momma = _emberRuntimeSystemObject.default.create({ children: [] }); + + var child1 = _emberRuntimeSystemObject.default.create({ name: 'Bartholomew' }); + var child2 = _emberRuntimeSystemObject.default.create({ name: 'Agnes' }); + var child3 = _emberRuntimeSystemObject.default.create({ name: 'Dan' }); + var child4 = _emberRuntimeSystemObject.default.create({ name: 'Nancy' }); + + _emberMetal.set(family, 'momma', momma); + _emberMetal.set(momma, 'children', _emberRuntimeSystemNative_array.A([child1, child2, child3])); + + var observerFiredCount = 0; + _emberMetal.addObserver(family, 'momma.children.@each.name', this, function () { + observerFiredCount++; + }); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.get(momma, 'children').setEach('name', 'Juan'); + }); + equal(observerFiredCount, 3, 'observer fired after changing child names'); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.get(momma, 'children').pushObject(child4); + }); + equal(observerFiredCount, 1, 'observer fired after adding a new item'); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.set(child4, 'name', 'Herbert'); + }); + equal(observerFiredCount, 1, 'observer fired after changing property on new object'); + + _emberMetal.set(momma, 'children', []); + + observerFiredCount = 0; + _emberMetal.run(function () { + return _emberMetal.set(child1, 'name', 'Hanna'); + }); + equal(observerFiredCount, 0, 'observer did not fire after removing changing property on a removed object'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/chained_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observable_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/string', 'ember-runtime/system/object', 'ember-runtime/mixins/observable', 'ember-runtime/system/native_array'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemString, _emberRuntimeSystemObject, _emberRuntimeMixinsObservable, _emberRuntimeSystemNative_array) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Added ObservableObject which applies the Ember.Observable mixin. + * Changed reference to Ember.T_FUNCTION to 'function' + * Changed all references to sc_super to this._super(...arguments) + * Changed Ember.objectForPropertyPath() to Ember.getPath() + * Removed allPropertiesDidChange test - no longer supported + * Changed test that uses 'ObjectE' as path to 'objectE' to reflect new + rule on using capital letters for property paths. + * Removed test passing context to addObserver. context param is no longer + supported. + * Changed calls to Ember.Binding.flushPendingChanges() -> run.sync() + * removed test in observer around line 862 that expected key/value to be + the last item in the chained path. Should be root and chained path + + */ + + // ======================================================================== + // Ember.Observable Tests + // ======================================================================== + + var object, ObjectC, ObjectD, objectA, objectB, lookup; + + var ObservableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default); + var originalLookup = _emberEnvironment.context.lookup; + + // .......................................................... + // GET() + // + + QUnit.module('object.get()', { + + setup: function () { + object = ObservableObject.extend(_emberRuntimeMixinsObservable.default, { + computed: _emberMetal.computed(function () { + return 'value'; + }).volatile(), + method: function () { + return 'value'; + }, + unknownProperty: function (key, value) { + this.lastUnknownProperty = key; + return 'unknown'; + } + }).create({ + normal: 'value', + numberVal: 24, + toggleVal: true, + nullProperty: null + }); + } + + }); + + QUnit.test('should get normal properties', function () { + equal(object.get('normal'), 'value'); + }); + + QUnit.test('should call computed properties and return their result', function () { + equal(object.get('computed'), 'value'); + }); + + QUnit.test('should return the function for a non-computed property', function () { + var value = object.get('method'); + equal(typeof value, 'function'); + }); + + QUnit.test('should return null when property value is null', function () { + equal(object.get('nullProperty'), null); + }); + + QUnit.test('should call unknownProperty when value is undefined', function () { + equal(object.get('unknown'), 'unknown'); + equal(object.lastUnknownProperty, 'unknown'); + }); + + // .......................................................... + // Ember.GET() + // + QUnit.module('Ember.get()', { + setup: function () { + objectA = ObservableObject.extend({ + computed: _emberMetal.computed(function () { + return 'value'; + }).volatile(), + method: function () { + return 'value'; + }, + unknownProperty: function (key, value) { + this.lastUnknownProperty = key; + return 'unknown'; + } + }).create({ + normal: 'value', + numberVal: 24, + toggleVal: true, + nullProperty: null + }); + + objectB = { + normal: 'value', + nullProperty: null + }; + } + }); + + QUnit.test('should get normal properties on Ember.Observable', function () { + equal(_emberMetal.get(objectA, 'normal'), 'value'); + }); + + QUnit.test('should call computed properties on Ember.Observable and return their result', function () { + equal(_emberMetal.get(objectA, 'computed'), 'value'); + }); + + QUnit.test('should return the function for a non-computed property on Ember.Observable', function () { + var value = _emberMetal.get(objectA, 'method'); + equal(typeof value, 'function'); + }); + + QUnit.test('should return null when property value is null on Ember.Observable', function () { + equal(_emberMetal.get(objectA, 'nullProperty'), null); + }); + + QUnit.test('should call unknownProperty when value is undefined on Ember.Observable', function () { + equal(_emberMetal.get(objectA, 'unknown'), 'unknown'); + equal(objectA.lastUnknownProperty, 'unknown'); + }); + + QUnit.test('should get normal properties on standard objects', function () { + equal(_emberMetal.get(objectB, 'normal'), 'value'); + }); + + QUnit.test('should return null when property is null on standard objects', function () { + equal(_emberMetal.get(objectB, 'nullProperty'), null); + }); + + /* + QUnit.test("raise if the provided object is null", function() { + throws(function() { + get(null, 'key'); + }); + }); + */ + + QUnit.test('raise if the provided object is undefined', function () { + expectAssertion(function () { + _emberMetal.get(undefined, 'key'); + }, /Cannot call get with 'key' on an undefined object/i); + }); + + QUnit.module('Ember.get() with paths'); + + QUnit.test('should return a property at a given path relative to the passed object', function () { + var foo = ObservableObject.create({ + bar: ObservableObject.extend({ + baz: _emberMetal.computed(function () { + return 'blargh'; + }).volatile() + }).create() + }); + + equal(_emberMetal.get(foo, 'bar.baz'), 'blargh'); + }); + + QUnit.test('should return a property at a given path relative to the passed object - JavaScript hash', function () { + var foo = { + bar: { + baz: 'blargh' + } + }; + + equal(_emberMetal.get(foo, 'bar.baz'), 'blargh'); + }); + + // .......................................................... + // SET() + // + + QUnit.module('object.set()', { + + setup: function () { + object = ObservableObject.extend({ + computed: _emberMetal.computed({ + get: function (key) { + return this._computed; + }, + set: function (key, value) { + this._computed = value; + return this._computed; + } + }).volatile(), + + method: function (key, value) { + if (value !== undefined) { + this._method = value; + } + return this._method; + }, + + unknownProperty: function (key) { + return this._unknown; + }, + + setUnknownProperty: function (key, value) { + this._unknown = value; + return this._unknown; + }, + + // normal property + normal: 'value', + + // computed property + _computed: 'computed', + // method, but not a property + _method: 'method', + // null property + nullProperty: null, + + // unknown property + _unknown: 'unknown' + }).create(); + } + + }); + + QUnit.test('should change normal properties and return the value', function () { + var ret = object.set('normal', 'changed'); + equal(object.get('normal'), 'changed'); + equal(ret, 'changed'); + }); + + QUnit.test('should call computed properties passing value and return the value', function () { + var ret = object.set('computed', 'changed'); + equal(object.get('_computed'), 'changed'); + equal(ret, 'changed'); + }); + + QUnit.test('should change normal properties when passing undefined', function () { + var ret = object.set('normal', undefined); + equal(object.get('normal'), undefined); + equal(ret, undefined); + }); + + QUnit.test('should replace the function for a non-computed property and return the value', function () { + var ret = object.set('method', 'changed'); + equal(object.get('_method'), 'method'); // make sure this was NOT run + ok(typeof object.get('method') !== 'function'); + equal(ret, 'changed'); + }); + + QUnit.test('should replace prover when property value is null', function () { + var ret = object.set('nullProperty', 'changed'); + equal(object.get('nullProperty'), 'changed'); + equal(ret, 'changed'); + }); + + QUnit.test('should call unknownProperty with value when property is undefined', function () { + var ret = object.set('unknown', 'changed'); + equal(object.get('_unknown'), 'changed'); + equal(ret, 'changed'); + }); + + // .......................................................... + // COMPUTED PROPERTIES + // + + QUnit.module('Computed properties', { + setup: function () { + lookup = _emberEnvironment.context.lookup = {}; + + object = ObservableObject.extend({ + computed: _emberMetal.computed({ + get: function () { + this.computedCalls.push('getter-called'); + return 'computed'; + }, + set: function (key, value) { + this.computedCalls.push(value); + } + }).volatile(), + + computedCached: _emberMetal.computed({ + get: function () { + this.computedCachedCalls.push('getter-called'); + return 'computedCached'; + }, + set: function (key, value) { + this.computedCachedCalls.push(value); + } + }), + + dependent: _emberMetal.computed({ + get: function () { + this.dependentCalls.push('getter-called'); + return 'dependent'; + }, + set: function (key, value) { + this.dependentCalls.push(value); + } + }).property('changer').volatile(), + dependentFront: _emberMetal.computed('changer', { + get: function () { + this.dependentFrontCalls.push('getter-called'); + return 'dependentFront'; + }, + set: function (key, value) { + this.dependentFrontCalls.push(value); + } + }).volatile(), + dependentCached: _emberMetal.computed({ + get: function () { + this.dependentCachedCalls.push('getter-called!'); + return 'dependentCached'; + }, + set: function (key, value) { + this.dependentCachedCalls.push(value); + } + }).property('changer'), + + inc: _emberMetal.computed('changer', function () { + return this.incCallCount++; + }), + + nestedInc: _emberMetal.computed(function (key) { + _emberMetal.get(this, 'inc'); + return this.nestedIncCallCount++; + }).property('inc'), + + isOn: _emberMetal.computed({ + get: function () { + return this.get('state') === 'on'; + }, + set: function (key, value) { + this.set('state', 'on'); + return this.get('state') === 'on'; + } + }).property('state').volatile(), + + isOff: _emberMetal.computed({ + get: function () { + return this.get('state') === 'off'; + }, + set: function (key, value) { + this.set('state', 'off'); + return this.get('state') === 'off'; + } + }).property('state').volatile() + + }).create({ + computedCalls: [], + computedCachedCalls: [], + changer: 'foo', + dependentCalls: [], + dependentFrontCalls: [], + dependentCachedCalls: [], + incCallCount: 0, + nestedIncCallCount: 0, + state: 'on' + }); + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('getting values should call function return value', function () { + // get each property twice. Verify return. + var keys = _emberRuntimeSystemString.w('computed computedCached dependent dependentFront dependentCached'); + + keys.forEach(function (key) { + equal(object.get(key), key, 'Try #1: object.get(' + key + ') should run function'); + equal(object.get(key), key, 'Try #2: object.get(' + key + ') should run function'); + }); + + // verify each call count. cached should only be called once + _emberRuntimeSystemString.w('computedCalls dependentFrontCalls dependentCalls').forEach(function (key) { + equal(object[key].length, 2, 'non-cached property ' + key + ' should be called 2x'); + }); + + _emberRuntimeSystemString.w('computedCachedCalls dependentCachedCalls').forEach(function (key) { + equal(object[key].length, 1, 'non-cached property ' + key + ' should be called 1x'); + }); + }); + + QUnit.test('setting values should call function return value', function () { + // get each property twice. Verify return. + var keys = _emberRuntimeSystemString.w('computed dependent dependentFront computedCached dependentCached'); + var values = _emberRuntimeSystemString.w('value1 value2'); + + keys.forEach(function (key) { + equal(object.set(key, values[0]), values[0], 'Try #1: object.set(' + key + ', ' + values[0] + ') should run function'); + + equal(object.set(key, values[1]), values[1], 'Try #2: object.set(' + key + ', ' + values[1] + ') should run function'); + + equal(object.set(key, values[1]), values[1], 'Try #3: object.set(' + key + ', ' + values[1] + ') should not run function since it is setting same value as before'); + }); + + // verify each call count. cached should only be called once + keys.forEach(function (key) { + var calls = object[key + 'Calls']; + var idx, expectedLength; + + // Cached properties first check their cached value before setting the + // property. Other properties blindly call set. + expectedLength = 3; + equal(calls.length, expectedLength, 'set(' + key + ') should be called the right amount of times'); + for (idx = 0; idx < 2; idx++) { + equal(calls[idx], values[idx], 'call #' + (idx + 1) + ' to set(' + key + ') should have passed value ' + values[idx]); + } + }); + }); + + QUnit.test('notify change should clear cache', function () { + // call get several times to collect call count + object.get('computedCached'); // should run func + object.get('computedCached'); // should not run func + + object.propertyWillChange('computedCached').propertyDidChange('computedCached'); + + object.get('computedCached'); // should run again + equal(object.computedCachedCalls.length, 2, 'should have invoked method 2x'); + }); + + QUnit.test('change dependent should clear cache', function () { + // call get several times to collect call count + var ret1 = object.get('inc'); // should run func + equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); + + object.set('changer', 'bar'); + + equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + QUnit.test('just notifying change of dependent should clear cache', function () { + // call get several times to collect call count + var ret1 = object.get('inc'); // should run func + equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); + + object.notifyPropertyChange('changer'); + + equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + QUnit.test('changing dependent should clear nested cache', function () { + // call get several times to collect call count + var ret1 = object.get('nestedInc'); // should run func + equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop'); + + object.set('changer', 'bar'); + + equal(object.get('nestedInc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + QUnit.test('just notifying change of dependent should clear nested cache', function () { + // call get several times to collect call count + var ret1 = object.get('nestedInc'); // should run func + equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop'); + + object.notifyPropertyChange('changer'); + + equal(object.get('nestedInc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + // This verifies a specific bug encountered where observers for computed + // properties would fire before their prop caches were cleared. + QUnit.test('change dependent should clear cache when observers of dependent are called', function () { + // call get several times to collect call count + var ret1 = object.get('inc'); // should run func + equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); + + // add observer to verify change... + object.addObserver('inc', this, function () { + equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again + }); + + // now run + object.set('changer', 'bar'); + }); + + QUnit.test('setting one of two computed properties that depend on a third property should clear the kvo cache', function () { + // we have to call set twice to fill up the cache + object.set('isOff', true); + object.set('isOn', true); + + // setting isOff to true should clear the kvo cache + object.set('isOff', true); + equal(object.get('isOff'), true, 'object.isOff should be true'); + equal(object.get('isOn'), false, 'object.isOn should be false'); + }); + + QUnit.test('dependent keys should be able to be specified as property paths', function () { + var depObj = ObservableObject.extend({ + menuPrice: _emberMetal.computed(function () { + return this.get('menu.price'); + }).property('menu.price') + }).create({ + menu: ObservableObject.create({ + price: 5 + }) + }); + + equal(depObj.get('menuPrice'), 5, 'precond - initial value returns 5'); + + depObj.set('menu.price', 6); + + equal(depObj.get('menuPrice'), 6, 'cache is properly invalidated after nested property changes'); + }); + + QUnit.test('nested dependent keys should propagate after they update', function () { + var bindObj; + _emberMetal.run(function () { + lookup.DepObj = ObservableObject.extend({ + price: _emberMetal.computed(function () { + return this.get('restaurant.menu.price'); + }).property('restaurant.menu.price') + }).create({ + restaurant: ObservableObject.create({ + menu: ObservableObject.create({ + price: 5 + }) + }) + }); + + expectDeprecation(function () { + bindObj = ObservableObject.extend({ + priceBinding: 'DepObj.price' + }).create(); + }, /`Ember.Binding` is deprecated/); + }); + + equal(bindObj.get('price'), 5, 'precond - binding propagates'); + + _emberMetal.run(function () { + lookup.DepObj.set('restaurant.menu.price', 10); + }); + + equal(bindObj.get('price'), 10, 'binding propagates after a nested dependent keys updates'); + + _emberMetal.run(function () { + lookup.DepObj.set('restaurant.menu', ObservableObject.create({ + price: 15 + })); + }); + + equal(bindObj.get('price'), 15, 'binding propagates after a middle dependent keys updates'); + }); + + QUnit.test('cacheable nested dependent keys should clear after their dependencies update', function () { + ok(true); + + var DepObj; + + _emberMetal.run(function () { + lookup.DepObj = DepObj = ObservableObject.extend({ + price: _emberMetal.computed('restaurant.menu.price', function () { + return this.get('restaurant.menu.price'); + }) + }).create({ + restaurant: ObservableObject.create({ + menu: ObservableObject.create({ + price: 5 + }) + }) + }); + }); + + equal(DepObj.get('price'), 5, 'precond - computed property is correct'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu.price', 10); + }); + equal(DepObj.get('price'), 10, 'cacheable computed properties are invalidated even if no run loop occurred'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu.price', 20); + }); + equal(DepObj.get('price'), 20, 'cacheable computed properties are invalidated after a second get before a run loop'); + equal(DepObj.get('price'), 20, 'precond - computed properties remain correct after a run loop'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu', ObservableObject.create({ + price: 15 + })); + }); + + equal(DepObj.get('price'), 15, 'cacheable computed properties are invalidated after a middle property changes'); + + _emberMetal.run(function () { + DepObj.set('restaurant.menu', ObservableObject.create({ + price: 25 + })); + }); + + equal(DepObj.get('price'), 25, 'cacheable computed properties are invalidated after a middle property changes again, before a run loop'); + }); + + // .......................................................... + // OBSERVABLE OBJECTS + // + + QUnit.module('Observable objects & object properties ', { + setup: function () { + object = ObservableObject.extend({ + getEach: function () { + var keys = ['normal', 'abnormal']; + var ret = []; + for (var idx = 0; idx < keys.length; idx++) { + ret[ret.length] = this.get(keys[idx]); + } + return ret; + }, + + newObserver: function () { + this.abnormal = 'changedValueObserved'; + }, + + testObserver: _emberMetal.observer('normal', function () { + this.abnormal = 'removedObserver'; + }), + + testArrayObserver: _emberMetal.observer('normalArray.[]', function () { + this.abnormal = 'notifiedObserver'; + }) + }).create({ + normal: 'value', + abnormal: 'zeroValue', + numberVal: 24, + toggleVal: true, + observedProperty: 'beingWatched', + testRemove: 'observerToBeRemoved', + normalArray: _emberRuntimeSystemNative_array.A([1, 2, 3, 4, 5]) + }); + } + }); + + QUnit.test('incrementProperty and decrementProperty', function () { + var newValue = object.incrementProperty('numberVal'); + + equal(25, newValue, 'numerical value incremented'); + object.numberVal = 24; + newValue = object.decrementProperty('numberVal'); + equal(23, newValue, 'numerical value decremented'); + object.numberVal = 25; + newValue = object.incrementProperty('numberVal', 5); + equal(30, newValue, 'numerical value incremented by specified increment'); + object.numberVal = 25; + newValue = object.incrementProperty('numberVal', -5); + equal(20, newValue, 'minus numerical value incremented by specified increment'); + object.numberVal = 25; + newValue = object.incrementProperty('numberVal', 0); + equal(25, newValue, 'zero numerical value incremented by specified increment'); + + expectAssertion(function () { + newValue = object.incrementProperty('numberVal', 0 - void 0); // Increment by NaN + }, /Must pass a numeric value to incrementProperty/i); + + expectAssertion(function () { + newValue = object.incrementProperty('numberVal', 'Ember'); // Increment by non-numeric String + }, /Must pass a numeric value to incrementProperty/i); + + expectAssertion(function () { + newValue = object.incrementProperty('numberVal', 1 / 0); // Increment by Infinity + }, /Must pass a numeric value to incrementProperty/i); + + equal(25, newValue, 'Attempting to increment by non-numeric values should not increment value'); + + object.numberVal = 25; + newValue = object.decrementProperty('numberVal', 5); + equal(20, newValue, 'numerical value decremented by specified increment'); + object.numberVal = 25; + newValue = object.decrementProperty('numberVal', -5); + equal(30, newValue, 'minus numerical value decremented by specified increment'); + object.numberVal = 25; + newValue = object.decrementProperty('numberVal', 0); + equal(25, newValue, 'zero numerical value decremented by specified increment'); + + expectAssertion(function () { + newValue = object.decrementProperty('numberVal', 0 - void 0); // Decrement by NaN + }, /Must pass a numeric value to decrementProperty/i); + + expectAssertion(function () { + newValue = object.decrementProperty('numberVal', 'Ember'); // Decrement by non-numeric String + }, /Must pass a numeric value to decrementProperty/i); + + expectAssertion(function () { + newValue = object.decrementProperty('numberVal', 1 / 0); // Decrement by Infinity + }, /Must pass a numeric value to decrementProperty/i); + + equal(25, newValue, 'Attempting to decrement by non-numeric values should not decrement value'); + }); + + QUnit.test('toggle function, should be boolean', function () { + equal(object.toggleProperty('toggleVal', true, false), object.get('toggleVal')); + equal(object.toggleProperty('toggleVal', true, false), object.get('toggleVal')); + equal(object.toggleProperty('toggleVal', undefined, undefined), object.get('toggleVal')); + }); + + QUnit.test('should notify array observer when array changes', function () { + _emberMetal.get(object, 'normalArray').replace(0, 0, 6); + equal(object.abnormal, 'notifiedObserver', 'observer should be notified'); + }); + + QUnit.module('object.addObserver()', { + setup: function () { + ObjectC = ObservableObject.create({ + objectE: ObservableObject.create({ + propertyVal: 'chainedProperty' + }), + + normal: 'value', + normal1: 'zeroValue', + normal2: 'dependentValue', + incrementor: 10, + + action: function () { + this.normal1 = 'newZeroValue'; + }, + + observeOnceAction: function () { + this.incrementor = this.incrementor + 1; + }, + + chainedObserver: function () { + this.normal2 = 'chainedPropertyObserved'; + } + }); + } + }); + + QUnit.test('should register an observer for a property', function () { + ObjectC.addObserver('normal', ObjectC, 'action'); + ObjectC.set('normal', 'newValue'); + equal(ObjectC.normal1, 'newZeroValue'); + }); + + QUnit.test('should register an observer for a property - Special case of chained property', function () { + ObjectC.addObserver('objectE.propertyVal', ObjectC, 'chainedObserver'); + ObjectC.objectE.set('propertyVal', 'chainedPropertyValue'); + equal('chainedPropertyObserved', ObjectC.normal2); + ObjectC.normal2 = 'dependentValue'; + ObjectC.set('objectE', ''); + equal('chainedPropertyObserved', ObjectC.normal2); + }); + + QUnit.module('object.removeObserver()', { + setup: function () { + ObjectD = ObservableObject.create({ + objectF: ObservableObject.create({ + propertyVal: 'chainedProperty' + }), + + normal: 'value', + normal1: 'zeroValue', + normal2: 'dependentValue', + ArrayKeys: ['normal', 'normal1'], + + addAction: function () { + this.normal1 = 'newZeroValue'; + }, + removeAction: function () { + this.normal2 = 'newDependentValue'; + }, + removeChainedObserver: function () { + this.normal2 = 'chainedPropertyObserved'; + }, + + observableValue: 'hello world', + + observer1: function () { + // Just an observer + }, + observer2: function () { + this.removeObserver('observableValue', null, 'observer1'); + this.removeObserver('observableValue', null, 'observer2'); + this.hasObserverFor('observableValue'); // Tickle 'getMembers()' + this.removeObserver('observableValue', null, 'observer3'); + }, + observer3: function () { + // Just an observer + } + }); + } + }); + + QUnit.test('should unregister an observer for a property', function () { + ObjectD.addObserver('normal', ObjectD, 'addAction'); + ObjectD.set('normal', 'newValue'); + equal(ObjectD.normal1, 'newZeroValue'); + + ObjectD.set('normal1', 'zeroValue'); + + ObjectD.removeObserver('normal', ObjectD, 'addAction'); + ObjectD.set('normal', 'newValue'); + equal(ObjectD.normal1, 'zeroValue'); + }); + + QUnit.test('should unregister an observer for a property - special case when key has a \'.\' in it.', function () { + ObjectD.addObserver('objectF.propertyVal', ObjectD, 'removeChainedObserver'); + ObjectD.objectF.set('propertyVal', 'chainedPropertyValue'); + ObjectD.removeObserver('objectF.propertyVal', ObjectD, 'removeChainedObserver'); + ObjectD.normal2 = 'dependentValue'; + ObjectD.objectF.set('propertyVal', 'removedPropertyValue'); + equal('dependentValue', ObjectD.normal2); + ObjectD.set('objectF', ''); + equal('dependentValue', ObjectD.normal2); + }); + + QUnit.test('removing an observer inside of an observer shouldn’t cause any problems', function () { + // The observable system should be protected against clients removing + // observers in the middle of observer notification. + var encounteredError = false; + try { + ObjectD.addObserver('observableValue', null, 'observer1'); + ObjectD.addObserver('observableValue', null, 'observer2'); + ObjectD.addObserver('observableValue', null, 'observer3'); + _emberMetal.run(function () { + ObjectD.set('observableValue', 'hi world'); + }); + } catch (e) { + encounteredError = true; + } + equal(encounteredError, false); + }); + + QUnit.module('Bind function', { + setup: function () { + objectA = ObservableObject.create({ + name: 'Sproutcore', + location: 'Timbaktu' + }); + + objectB = ObservableObject.create({ + normal: 'value', + computed: function () { + this.normal = 'newValue'; + } + }); + + lookup = _emberEnvironment.context.lookup = { + 'Namespace': { + objectA: objectA, + objectB: objectB + } + }; + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('should bind property with method parameter as undefined', function () { + // creating binding + _emberMetal.run(function () { + expectDeprecation(function () { + objectA.bind('name', 'Namespace.objectB.normal', undefined); + }, /`Ember.Binding` is deprecated/); + }); + + // now make a change to see if the binding triggers. + _emberMetal.run(function () { + objectB.set('normal', 'changedValue'); + }); + + // support new-style bindings if available + equal('changedValue', objectA.get('name'), 'objectA.name is bound'); + }); + + // .......................................................... + // SPECIAL CASES + // + + QUnit.test('changing chained observer object to null should not raise exception', function () { + var obj = ObservableObject.create({ + foo: ObservableObject.create({ + bar: ObservableObject.create({ bat: 'BAT' }) + }) + }); + + var callCount = 0; + obj.foo.addObserver('bar.bat', obj, function (target, key, value) { + callCount++; + }); + + _emberMetal.run(function () { + obj.foo.set('bar', null); + }); + + equal(callCount, 1, 'changing bar should trigger observer'); + expect(1); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/observable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsObservable) { + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Create ObservableObject which includes Ember.Observable + */ + + // ======================================================================== + // Ember.Observable Tests + // ======================================================================== + + 'use strict'; + + var ObservableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default); + + // .......................................................... + // GET() + // + + QUnit.module('object.observesForKey()'); + + QUnit.test('should get observers', function () { + var o1 = ObservableObject.create({ foo: 100 }); + var o2 = ObservableObject.create({ func: function () {} }); + var o3 = ObservableObject.create({ func: function () {} }); + var observers = null; + + equal(_emberMetal.get(o1.observersForKey('foo'), 'length'), 0, 'o1.observersForKey should return empty array'); + + o1.addObserver('foo', o2, o2.func); + o1.addObserver('foo', o3, o3.func); + + observers = o1.observersForKey('foo'); + + equal(_emberMetal.get(observers, 'length'), 2, 'o2.observersForKey should return an array with length 2'); + equal(observers[0][0], o2, 'first item in observers array should be o2'); + equal(observers[1][0], o3, 'second item in observers array should be o3'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/observable', 'ember-metal'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsObservable, _emberMetal) { + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Create ObservableObject which includes Ember.Observable + * Remove test that tests internal _kvo_changeLevel property. This is an + implementation detail. + * Remove test for allPropertiesDidChange + * Removed star observer test. no longer supported + * Removed property revision test. no longer supported + */ + + // ======================================================================== + // Ember.Observable Tests + // ======================================================================== + + 'use strict'; + + var ObservableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default); + + var ObjectA = undefined; + + QUnit.module('object.propertyChanges', { + setup: function () { + ObjectA = ObservableObject.extend({ + action: _emberMetal.observer('foo', function () { + this.set('prop', 'changedPropValue'); + }), + notifyAction: _emberMetal.observer('newFoo', function () { + this.set('newProp', 'changedNewPropValue'); + }), + + notifyAllAction: _emberMetal.observer('prop', function () { + this.set('newFoo', 'changedNewFooValue'); + }), + + starObserver: function (target, key, value, rev) { + this.starProp = key; + } + }).create({ + starProp: null, + + foo: 'fooValue', + prop: 'propValue', + + newFoo: 'newFooValue', + newProp: 'newPropValue' + }); + } + }); + + QUnit.test('should observe the changes within the nested begin / end property changes', function () { + //start the outer nest + ObjectA.beginPropertyChanges(); + + // Inner nest + ObjectA.beginPropertyChanges(); + ObjectA.set('foo', 'changeFooValue'); + + equal(ObjectA.prop, 'propValue'); + ObjectA.endPropertyChanges(); + + //end inner nest + ObjectA.set('prop', 'changePropValue'); + equal(ObjectA.newFoo, 'newFooValue'); + + //close the outer nest + ObjectA.endPropertyChanges(); + + equal(ObjectA.prop, 'changedPropValue'); + equal(ObjectA.newFoo, 'changedNewFooValue'); + }); + + QUnit.test('should observe the changes within the begin and end property changes', function () { + ObjectA.beginPropertyChanges(); + ObjectA.set('foo', 'changeFooValue'); + + equal(ObjectA.prop, 'propValue'); + ObjectA.endPropertyChanges(); + + equal(ObjectA.prop, 'changedPropValue'); + }); + + QUnit.test('should indicate that the property of an object has just changed', function () { + // indicate that property of foo will change to its subscribers + ObjectA.propertyWillChange('foo'); + + //Value of the prop is unchanged yet as this will be changed when foo changes + equal(ObjectA.prop, 'propValue'); + + //change the value of foo. + ObjectA.set('foo', 'changeFooValue'); + + // Indicate the subscribers of foo that the value has just changed + ObjectA.propertyDidChange('foo', null); + + // Values of prop has just changed + equal(ObjectA.prop, 'changedPropValue'); + }); + + QUnit.test('should notify that the property of an object has changed', function () { + // Notify to its subscriber that the values of 'newFoo' will be changed. In this + // case the observer is "newProp". Therefore this will call the notifyAction function + // and value of "newProp" will be changed. + ObjectA.notifyPropertyChange('newFoo', 'fooValue'); + + //value of newProp changed. + equal(ObjectA.newProp, 'changedNewPropValue'); + }); + + QUnit.test('should invalidate function property cache when notifyPropertyChange is called', function () { + var a = ObservableObject.extend({ + b: _emberMetal.computed({ + get: function () { + return this._b; + }, + set: function (key, value) { + this._b = value; + return this; + } + }).volatile() + }).create({ + _b: null + }); + + a.set('b', 'foo'); + equal(a.get('b'), 'foo', 'should have set the correct value for property b'); + + a._b = 'bar'; + a.notifyPropertyChange('b'); + a.set('b', 'foo'); + equal(a.get('b'), 'foo', 'should have invalidated the cache so that the newly set value is actually set'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/binding_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * All calls to run.sync() were changed to + run.sync() + + * Bindings no longer accept a root object as their second param. Instead + our test binding objects were put under a single object they could + originate from. + + * tests that inspected internal properties were removed. + + * converted foo.get/foo.set to use get/Ember.set + + * Removed tests for Binding.isConnected. Since binding instances are now + shared this property no longer makes sense. + + * Changed call calls for obj.bind(...) to bind(obj, ...); + + * Changed all calls to sc_super() to this._super(...arguments) + + * Changed all calls to disconnect() to pass the root object. + + * removed calls to Binding.destroy() as that method is no longer useful + (or defined) + + * changed use of T_STRING to 'string' + */ + + // ======================================================================== + // Binding Tests + // ======================================================================== + + var TestNamespace = undefined, + fromObject = undefined, + toObject = undefined, + binding = undefined, + Bon1 = undefined, + bon2 = undefined, + root = undefined; // global variables + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('basic object binding', { + setup: function () { + fromObject = _emberRuntimeSystemObject.default.create({ value: 'start' }); + toObject = _emberRuntimeSystemObject.default.create({ value: 'end' }); + root = { fromObject: fromObject, toObject: toObject }; + _emberMetal.run(function () { + expectDeprecation(function () { + binding = _emberMetal.bind(root, 'toObject.value', 'fromObject.value'); + }, /`Ember\.Binding` is deprecated./); + }); + } + }); + + QUnit.test('binding should have synced on connect', function () { + equal(_emberMetal.get(toObject, 'value'), 'start', 'toObject.value should match fromObject.value'); + }); + + QUnit.test('fromObject change should propagate to toObject only after flush', function () { + _emberMetal.run(function () { + _emberMetal.set(fromObject, 'value', 'change'); + equal(_emberMetal.get(toObject, 'value'), 'start'); + }); + equal(_emberMetal.get(toObject, 'value'), 'change'); + }); + + QUnit.test('toObject change should propagate to fromObject only after flush', function () { + _emberMetal.run(function () { + _emberMetal.set(toObject, 'value', 'change'); + equal(_emberMetal.get(fromObject, 'value'), 'start'); + }); + equal(_emberMetal.get(fromObject, 'value'), 'change'); + }); + + QUnit.test('deferred observing during bindings', function () { + // setup special binding + fromObject = _emberRuntimeSystemObject.default.create({ + value1: 'value1', + value2: 'value2' + }); + + toObject = _emberRuntimeSystemObject.default.extend({ + observer: _emberMetal.observer('value1', 'value2', function () { + equal(_emberMetal.get(this, 'value1'), 'CHANGED', 'value1 when observer fires'); + equal(_emberMetal.get(this, 'value2'), 'CHANGED', 'value2 when observer fires'); + this.callCount++; + }) + }).create({ + value1: 'value1', + value2: 'value2', + + callCount: 0 + }); + + var root = { fromObject: fromObject, toObject: toObject }; + _emberMetal.run(function () { + expectDeprecation(function () { + _emberMetal.bind(root, 'toObject.value1', 'fromObject.value1'); + }, /`Ember\.Binding` is deprecated./); + + expectDeprecation(function () { + _emberMetal.bind(root, 'toObject.value2', 'fromObject.value2'); + }, /`Ember\.Binding` is deprecated./); + + // change both value1 + value2, then flush bindings. observer should only + // fire after bindings are done flushing. + _emberMetal.set(fromObject, 'value1', 'CHANGED'); + _emberMetal.set(fromObject, 'value2', 'CHANGED'); + }); + + equal(toObject.callCount, 2, 'should call observer twice'); + }); + + QUnit.test('binding disconnection actually works', function () { + binding.disconnect(root); + _emberMetal.run(function () { + _emberMetal.set(fromObject, 'value', 'change'); + }); + equal(_emberMetal.get(toObject, 'value'), 'start'); + }); + + var first = undefined, + second = undefined, + third = undefined; // global variables + + // .......................................................... + // chained binding + // + + QUnit.module('chained binding', { + + setup: function () { + _emberMetal.run(function () { + first = _emberRuntimeSystemObject.default.create({ output: 'first' }); + + second = _emberRuntimeSystemObject.default.extend({ + inputDidChange: _emberMetal.observer('input', function () { + _emberMetal.set(this, 'output', _emberMetal.get(this, 'input')); + }) + }).create({ + input: 'second', + output: 'second' + }); + + third = _emberRuntimeSystemObject.default.create({ input: 'third' }); + + root = { first: first, second: second, third: third }; + + expectDeprecation(function () { + _emberMetal.bind(root, 'second.input', 'first.output'); + }, /`Ember\.Binding` is deprecated./); + + expectDeprecation(function () { + _emberMetal.bind(root, 'second.output', 'third.input'); + }, /`Ember\.Binding` is deprecated./); + }); + }, + teardown: function () { + _emberMetal.run.cancelTimers(); + } + }); + + QUnit.test('changing first output should propagate to third after flush', function () { + _emberMetal.run(function () { + _emberMetal.set(first, 'output', 'change'); + equal('change', _emberMetal.get(first, 'output'), 'first.output'); + ok('change' !== _emberMetal.get(third, 'input'), 'third.input'); + }); + + equal('change', _emberMetal.get(first, 'output'), 'first.output'); + equal('change', _emberMetal.get(second, 'input'), 'second.input'); + equal('change', _emberMetal.get(second, 'output'), 'second.output'); + equal('change', _emberMetal.get(third, 'input'), 'third.input'); + }); + + // .......................................................... + // Custom Binding + // + + QUnit.module('Custom Binding', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + Bon1 = _emberRuntimeSystemObject.default.extend({ + value1: 'hi', + value2: 83, + array1: [] + }); + + bon2 = _emberRuntimeSystemObject.default.create({ + val1: 'hello', + val2: 25, + arr: [1, 2, 3, 4] + }); + + _emberEnvironment.context.lookup['TestNamespace'] = TestNamespace = { + bon2: bon2, + Bon1: Bon1 + }; + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + Bon1 = bon2 = TestNamespace = null; + _emberMetal.run.cancelTimers(); + } + }); + + QUnit.test('two bindings to the same value should sync in the order they are initialized', function () { + _emberMetal.run.begin(); + + var a = _emberRuntimeSystemObject.default.create({ + foo: 'bar' + }); + + var b = _emberRuntimeSystemObject.default.extend({ + C: _emberRuntimeSystemObject.default.extend({ + foo: 'bee', + fooBinding: 'owner.foo' + }), + + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'c', this.C.create({ owner: this })); + } + }); + + expectDeprecation(function () { + b = b.create({ + foo: 'baz', + fooBinding: 'a.foo', + a: a + }); + }, /`Ember\.Binding` is deprecated./); + + _emberMetal.run.end(); + + equal(_emberMetal.get(a, 'foo'), 'bar', 'a.foo should not change'); + equal(_emberMetal.get(b, 'foo'), 'bar', 'a.foo should propagate up to b.foo'); + equal(_emberMetal.get(b.c, 'foo'), 'bar', 'a.foo should propagate up to b.c.foo'); + }); + + // .......................................................... + // propertyNameBinding with longhand + // + + QUnit.module('propertyNameBinding with longhand', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + lookup['TestNamespace'] = TestNamespace = {}; + _emberMetal.run(function () { + TestNamespace.fromObject = _emberRuntimeSystemObject.default.create({ + value: 'originalValue' + }); + + expectDeprecation(function () { + TestNamespace.toObject = _emberRuntimeSystemObject.default.extend({ + valueBinding: _emberMetal.Binding.from('TestNamespace.fromObject.value'), + relativeBinding: _emberMetal.Binding.from('localValue') + }).create({ + localValue: 'originalLocal' + }); + }, /`Ember\.Binding` is deprecated./); + }); + }, + teardown: function () { + TestNamespace = undefined; + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('works with full path', function () { + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.fromObject, 'value', 'updatedValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'value'), 'updatedValue'); + + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.fromObject, 'value', 'newerValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'value'), 'newerValue'); + }); + + QUnit.test('works with local path', function () { + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.toObject, 'localValue', 'updatedValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'relative'), 'updatedValue'); + + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.toObject, 'localValue', 'newerValue'); + }); + + equal(_emberMetal.get(TestNamespace.toObject, 'relative'), 'newerValue'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/binding_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/binding_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/binding_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/base_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Changed get(obj, ) and set(obj, ) to Ember.get() and Ember.set() + * Removed obj.instanceOf() and obj.kindOf() tests. use obj instanceof Foo + instead + * Removed respondsTo() and tryToPerform() tests. Can be brought back in a + utils package. + * Removed destroy() test. You can impl yourself but not built in + * Changed Class.subclassOf() test to Class.detect() + * Remove broken test for 'superclass' property. + * Removed obj.didChangeFor() + */ + + // ======================================================================== + // EmberObject Base Tests + // ======================================================================== + + var obj = undefined, + obj1 = undefined; // global variables + + QUnit.module('A new EmberObject instance', { + + setup: function () { + obj = _emberRuntimeSystemObject.default.create({ + foo: 'bar', + total: 12345, + aMethodThatExists: function () {}, + aMethodThatReturnsTrue: function () { + return true; + }, + aMethodThatReturnsFoobar: function () { + return 'Foobar'; + }, + aMethodThatReturnsFalse: function () { + return false; + } + }); + }, + + teardown: function () { + obj = undefined; + } + + }); + + QUnit.test('Should return its properties when requested using EmberObject#get', function () { + equal(_emberMetal.get(obj, 'foo'), 'bar'); + equal(_emberMetal.get(obj, 'total'), 12345); + }); + + QUnit.test('Should allow changing of those properties by calling EmberObject#set', function () { + equal(_emberMetal.get(obj, 'foo'), 'bar'); + equal(_emberMetal.get(obj, 'total'), 12345); + + _emberMetal.set(obj, 'foo', 'Chunky Bacon'); + _emberMetal.set(obj, 'total', 12); + + equal(_emberMetal.get(obj, 'foo'), 'Chunky Bacon'); + equal(_emberMetal.get(obj, 'total'), 12); + }); + + QUnit.module('EmberObject superclass and subclasses', { + setup: function () { + obj = _emberRuntimeSystemObject.default.extend({ + method1: function () { + return 'hello'; + } + }); + obj1 = obj.extend(); + }, + + teardown: function () { + obj = undefined; + obj1 = undefined; + } + }); + + QUnit.test('Checking the detect() function on an object and its subclass', function () { + equal(obj.detect(obj1), true); + equal(obj1.detect(obj), false); + }); + + QUnit.test('Checking the detectInstance() function on an object and its subclass', function () { + ok(_emberRuntimeSystemObject.default.detectInstance(obj.create())); + ok(obj.detectInstance(obj.create())); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/base_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/object/base_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/object/base_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/bindings_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * changed Ember.Bending.flushPendingChanges() -> run.sync(); + * changes obj.set() and obj.get() to Ember.set() and Ember.get() + * Fixed an actual bug in unit tests around line 133 + * fixed 'bindings should disconnect on destroy' test to use destroy. + */ + + // ======================================================================== + // EmberObject bindings Tests + // ======================================================================== + + var originalLookup = _emberEnvironment.context.lookup; + var testObject = undefined, + fromObject = undefined, + TestObject = undefined; + var TestNamespace = undefined, + lookup = undefined; + + QUnit.module('bind() method', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + testObject = _emberRuntimeSystemObject.default.create({ + foo: 'bar', + bar: 'foo', + extraObject: null + }); + + fromObject = _emberRuntimeSystemObject.default.create({ + bar: 'foo', + extraObject: null + }); + + lookup['TestNamespace'] = TestNamespace = { + fromObject: fromObject, + testObject: testObject + }; + }, + + teardown: function () { + testObject = fromObject = null; + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('bind(TestNamespace.fromObject.bar) should follow absolute path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject.bind('foo', 'TestNamespace.fromObject.bar'); + }, /`Ember.Binding` is deprecated/); + + // now make a change to see if the binding triggers. + _emberMetal.set(fromObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.test('bind(.bar) should bind to relative path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject.bind('foo', 'bar'); + }, /`Ember.Binding` is deprecated/); + + // now make a change to see if the binding triggers. + _emberMetal.set(testObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.module('fooBinding method', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + + TestObject = _emberRuntimeSystemObject.default.extend({ + foo: 'bar', + bar: 'foo', + extraObject: null + }); + + fromObject = _emberRuntimeSystemObject.default.create({ + bar: 'foo', + extraObject: null + }); + + lookup['TestNamespace'] = TestNamespace = { + fromObject: fromObject, + testObject: TestObject + }; + }, + + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + TestObject = fromObject = null; + // delete TestNamespace; + } + }); + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + QUnit.test('fooBinding: TestNamespace.fromObject.bar should follow absolute path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject = TestObject.extend({ + fooBinding: 'TestNamespace.fromObject.bar' + }).create(); + }, deprecationMessage); + + // now make a change to see if the binding triggers. + _emberMetal.set(fromObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.test('fooBinding: .bar should bind to relative path', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject = TestObject.extend({ + fooBinding: 'bar' + }).create(); + }, deprecationMessage); + + // now make a change to see if the binding triggers. + _emberMetal.set(testObject, 'bar', 'changedValue'); + }); + + equal('changedValue', _emberMetal.get(testObject, 'foo'), 'testObject.foo'); + }); + + QUnit.test('fooBinding: should disconnect bindings when destroyed', function () { + _emberMetal.run(function () { + expectDeprecation(function () { + // create binding + testObject = TestObject.extend({ + fooBinding: 'TestNamespace.fromObject.bar' + }).create(); + }, deprecationMessage); + + _emberMetal.set(TestNamespace.fromObject, 'bar', 'BAZ'); + }); + + equal(_emberMetal.get(testObject, 'foo'), 'BAZ', 'binding should have synced'); + + _emberMetal.run(function () { + return testObject.destroy(); + }); + + _emberMetal.run(function () { + return _emberMetal.set(TestNamespace.fromObject, 'bar', 'BIFF'); + }); + + ok(_emberMetal.get(testObject, 'foo') !== 'bar', 'binding should not have synced'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/bindings_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/object/bindings_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/object/bindings_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/concatenated_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * changed get(obj, ) and set(obj, ) to Ember.get() and Ember.set() + * converted uses of obj.isEqual() to use deepEqual() test since isEqual is not + always defined + */ + + function K() { + return this; + } + + var klass = undefined; + + QUnit.module('EmberObject Concatenated Properties', { + setup: function () { + klass = _emberRuntimeSystemObject.default.extend({ + concatenatedProperties: ['values', 'functions'], + values: ['a', 'b', 'c'], + functions: [K] + }); + } + }); + + QUnit.test('concatenates instances', function () { + var obj = klass.create({ + values: ['d', 'e', 'f'] + }); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates subclasses', function () { + var subKlass = klass.extend({ + values: ['d', 'e', 'f'] + }); + var obj = subKlass.create(); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates reopen', function () { + klass.reopen({ + values: ['d', 'e', 'f'] + }); + var obj = klass.create(); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates mixin', function () { + var mixin = { + values: ['d', 'e'] + }; + var subKlass = klass.extend(mixin, { + values: ['f'] + }); + var obj = subKlass.create(); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates reopen, subclass, and instance', function () { + klass.reopen({ values: ['d'] }); + var subKlass = klass.extend({ values: ['e'] }); + var obj = subKlass.create({ values: ['f'] }); + + var values = _emberMetal.get(obj, 'values'); + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + + deepEqual(values, expected, 'should concatenate values property (expected: ' + expected + ', got: ' + values + ')'); + }); + + QUnit.test('concatenates subclasses when the values are functions', function () { + var subKlass = klass.extend({ + functions: K + }); + var obj = subKlass.create(); + + var values = _emberMetal.get(obj, 'functions'); + var expected = [K, K]; + + deepEqual(values, expected, 'should concatenate functions property (expected: ' + expected + ', got: ' + values + ')'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/object/concatenated_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/object/concatenated_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/object/concatenated_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/run_loop_test', ['exports', 'ember-metal', 'ember-runtime/mixins/observable', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeMixinsObservable, _emberRuntimeSystemObject) { + 'use strict'; + + /* + NOTE: This test is adapted from the 1.x series of unit tests. The tests + are the same except for places where we intend to break the API we instead + validate that we warn the developer appropriately. + + CHANGES FROM 1.6: + + * Updated the API usage for setting up and syncing Binding since these + are not the APIs this file is testing. + + * Disabled a call to invokeOnce() around line 127 because it appeared to be + broken anyway. I don't think it ever even worked. + */ + + var MyApp = undefined; + + QUnit.module('System:run_loop() - chained binding', { + setup: function () { + MyApp = {}; + MyApp.first = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default).create({ + output: 'MyApp.first' + }); + + MyApp.second = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default, { + inputDidChange: _emberMetal.observer('input', function () { + this.set('output', this.get('input')); + }) + }).create({ + input: 'MyApp.second', + output: 'MyApp.second' + }); + + MyApp.third = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsObservable.default).create({ + input: 'MyApp.third' + }); + } + }); + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + QUnit.test('Should propagate bindings after the RunLoop completes (using Ember.RunLoop)', function () { + _emberMetal.run(function () { + //Binding of output of MyApp.first object to input of MyApp.second object + expectDeprecation(function () { + _emberMetal.Binding.from('first.output').to('second.input').connect(MyApp); + }, deprecationMessage); + + //Binding of output of MyApp.second object to input of MyApp.third object + expectDeprecation(function () { + _emberMetal.Binding.from('second.output').to('third.input').connect(MyApp); + }, deprecationMessage); + }); + + _emberMetal.run(function () { + // Based on the above binding if you change the output of MyApp.first + // object it should change the all the variable of + // MyApp.first,MyApp.second and MyApp.third object + MyApp.first.set('output', 'change'); + + //Changes the output of the MyApp.first object + equal(MyApp.first.get('output'), 'change'); + + //since binding has not taken into effect the value still remains as change. + equal(MyApp.second.get('output'), 'MyApp.first'); + }); // allows bindings to trigger... + + //Value of the output variable changed to 'change' + equal(MyApp.first.get('output'), 'change'); + + //Since binding triggered after the end loop the value changed to 'change'. + equal(MyApp.second.get('output'), 'change'); + }); + + QUnit.test('Should propagate bindings after the RunLoop completes', function () { + _emberMetal.run(function () { + //Binding of output of MyApp.first object to input of MyApp.second object + expectDeprecation(function () { + _emberMetal.Binding.from('first.output').to('second.input').connect(MyApp); + }, deprecationMessage); + + //Binding of output of MyApp.second object to input of MyApp.third object + expectDeprecation(function () { + _emberMetal.Binding.from('second.output').to('third.input').connect(MyApp); + }, deprecationMessage); + }); + + _emberMetal.run(function () { + //Based on the above binding if you change the output of MyApp.first object it should + //change the all the variable of MyApp.first,MyApp.second and MyApp.third object + MyApp.first.set('output', 'change'); + + //Changes the output of the MyApp.first object + equal(MyApp.first.get('output'), 'change'); + + //since binding has not taken into effect the value still remains as change. + equal(MyApp.second.get('output'), 'MyApp.first'); + }); + + //Value of the output variable changed to 'change' + equal(MyApp.first.get('output'), 'change'); + + //Since binding triggered after the end loop the value changed to 'change'. + equal(MyApp.second.get('output'), 'change'); + }); +}); +enifed('ember-runtime/tests/legacy_1x/system/run_loop_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/legacy_1x/system/run_loop_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/legacy_1x/system/run_loop_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/main_test', ['exports', 'ember-runtime/index'], function (exports, _emberRuntimeIndex) { + 'use strict'; + + QUnit.module('ember-runtime/main'); + + QUnit.test('Ember.computed.collect', function () { + var MyObj = _emberRuntimeIndex.Object.extend({ + props: _emberRuntimeIndex.collect('foo', 'bar', 'baz') + }); + + var myObj = MyObj.create({ + foo: 3, + bar: 5, + baz: 'asdf' + }); + + var propsValue = myObj.get('props'); + + deepEqual(propsValue, [3, 5, 'asdf']); + }); +}); +enifed('ember-runtime/tests/main_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/main_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/main_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/array_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/tests/suites/array', 'ember-runtime/system/object', 'ember-runtime/mixins/array', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeTestsSuitesArray, _emberRuntimeSystemObject, _emberRuntimeMixinsArray, _emberRuntimeSystemNative_array) { + 'use strict'; + + /* + Implement a basic fake mutable array. This validates that any non-native + enumerable can impl this API. + */ + var TestArray = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsArray.default, { + _content: null, + + init: function () { + var ary = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + this._content = ary; + }, + + // some methods to modify the array so we can test changes. Note that + // arrays can be modified even if they don't implement MutableArray. The + // MutableArray is just a standard API for mutation but not required. + addObject: function (obj) { + var idx = this._content.length; + _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, 0, 1); + this._content.push(obj); + _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, 0, 1); + }, + + removeFirst: function (idx) { + _emberRuntimeMixinsArray.arrayContentWillChange(this, 0, 1, 0); + this._content.shift(); + _emberRuntimeMixinsArray.arrayContentDidChange(this, 0, 1, 0); + }, + + objectAt: function (idx) { + return this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }) + }); + + _emberRuntimeTestsSuitesArray.ArrayTests.extend({ + + name: 'Basic Mutable Array', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestArray(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(this.getFixture(1)[0]); + }, + + toArray: function (obj) { + return obj.slice(); + } + + }).run(); + + QUnit.test('the return value of slice has Ember.Array applied', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsArray.default).create({ + length: 0 + }); + var y = x.slice(1); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'mixin should be applied'); + }); + + QUnit.test('slice supports negative index arguments', function () { + var testArray = new TestArray([1, 2, 3, 4]); + + deepEqual(testArray.slice(-2), [3, 4], 'slice(-2)'); + deepEqual(testArray.slice(-2, -1), [3], 'slice(-2, -1'); + deepEqual(testArray.slice(-2, -2), [], 'slice(-2, -2)'); + deepEqual(testArray.slice(-1, -2), [], 'slice(-1, -2)'); + + deepEqual(testArray.slice(-4, 1), [1], 'slice(-4, 1)'); + deepEqual(testArray.slice(-4, 5), [1, 2, 3, 4], 'slice(-4, 5)'); + deepEqual(testArray.slice(-4), [1, 2, 3, 4], 'slice(-4)'); + + deepEqual(testArray.slice(0, -1), [1, 2, 3], 'slice(0, -1)'); + deepEqual(testArray.slice(0, -4), [], 'slice(0, -4)'); + deepEqual(testArray.slice(0, -3), [1], 'slice(0, -3)'); + }); + + // .......................................................... + // CONTENT DID CHANGE + // + + var DummyArray = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsArray.default, { + nextObject: function () {}, + length: 0, + objectAt: function (idx) { + return 'ITEM-' + idx; + } + }); + + var obj = undefined, + observer = undefined; + + // .......................................................... + // NOTIFY ARRAY OBSERVERS + // + + QUnit.module('mixins/array/arrayContent[Will|Did]Change'); + + QUnit.test('should notify observers of []', function () { + obj = DummyArray.extend({ + enumerablePropertyDidChange: _emberMetal.observer('[]', function () { + this._count++; + }) + }).create({ + _count: 0 + }); + + equal(obj._count, 0, 'should not have invoked yet'); + + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + + equal(obj._count, 1, 'should have invoked'); + }); + + // .......................................................... + // NOTIFY CHANGES TO LENGTH + // + + QUnit.module('notify observers of length', { + setup: function () { + obj = DummyArray.extend({ + lengthDidChange: _emberMetal.observer('length', function () { + this._after++; + }) + }).create({ + _after: 0 + }); + + equal(obj._after, 0, 'should not have fired yet'); + }, + + teardown: function () { + obj = null; + } + }); + + QUnit.test('should notify observers when call with no params', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + equal(obj._after, 0); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + equal(obj._after, 1); + }); + + // API variation that included items only + QUnit.test('should not notify when passed lengths are same', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + equal(obj._after, 0); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + equal(obj._after, 0); + }); + + QUnit.test('should notify when passed lengths are different', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 2); + equal(obj._after, 0); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 2); + equal(obj._after, 1); + }); + + // .......................................................... + // NOTIFY ARRAY OBSERVER + // + + QUnit.module('notify array observers', { + setup: function () { + obj = DummyArray.create(); + + observer = _emberRuntimeSystemObject.default.extend({ + arrayWillChange: function () { + equal(this._before, null); // should only call once + this._before = Array.prototype.slice.call(arguments); + }, + + arrayDidChange: function () { + equal(this._after, null); // should only call once + this._after = Array.prototype.slice.call(arguments); + } + }).create({ + _before: null, + _after: null + }); + + _emberRuntimeMixinsArray.addArrayObserver(obj, observer); + }, + + teardown: function () { + obj = observer = null; + } + }); + + QUnit.test('should notify enumerable observers when called with no params', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, [obj, 0, -1, -1]); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, [obj, 0, -1, -1]); + }); + + // API variation that included items only + QUnit.test('should notify when called with same length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + deepEqual(observer._before, [obj, 0, 1, 1]); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + deepEqual(observer._after, [obj, 0, 1, 1]); + }); + + QUnit.test('should notify when called with diff length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 2, 1); + deepEqual(observer._before, [obj, 0, 2, 1]); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 2, 1); + deepEqual(observer._after, [obj, 0, 2, 1]); + }); + + QUnit.test('removing enumerable observer should disable', function () { + _emberRuntimeMixinsArray.removeArrayObserver(obj, observer); + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, null); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, null); + }); + + // .......................................................... + // NOTIFY ENUMERABLE OBSERVER + // + + QUnit.module('notify enumerable observers as well', { + setup: function () { + obj = DummyArray.create(); + + observer = _emberRuntimeSystemObject.default.extend({ + enumerableWillChange: function () { + equal(this._before, null); // should only call once + this._before = Array.prototype.slice.call(arguments); + }, + + enumerableDidChange: function () { + equal(this._after, null); // should only call once + this._after = Array.prototype.slice.call(arguments); + } + }).create({ + _before: null, + _after: null + }); + + obj.addEnumerableObserver(observer); + }, + + teardown: function () { + obj = observer = null; + } + }); + + QUnit.test('should notify enumerable observers when called with no params', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, [obj, null, null], 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, [obj, null, null], 'after'); + }); + + // API variation that included items only + QUnit.test('should notify when called with same length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 1, 1); + deepEqual(observer._before, [obj, ['ITEM-0'], 1], 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 1, 1); + deepEqual(observer._after, [obj, 1, ['ITEM-0']], 'after'); + }); + + QUnit.test('should notify when called with diff length items', function () { + _emberRuntimeMixinsArray.arrayContentWillChange(obj, 0, 2, 1); + deepEqual(observer._before, [obj, ['ITEM-0', 'ITEM-1'], 1], 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj, 0, 2, 1); + deepEqual(observer._after, [obj, 2, ['ITEM-0']], 'after'); + }); + + QUnit.test('removing enumerable observer should disable', function () { + obj.removeEnumerableObserver(observer); + _emberRuntimeMixinsArray.arrayContentWillChange(obj); + deepEqual(observer._before, null, 'before'); + + _emberRuntimeMixinsArray.arrayContentDidChange(obj); + deepEqual(observer._after, null, 'after'); + }); + + // .......................................................... + // @each + // + + var ary = undefined; + + QUnit.module('EmberArray.@each support', { + setup: function () { + ary = new TestArray([{ isDone: true, desc: 'Todo 1' }, { isDone: false, desc: 'Todo 2' }, { isDone: true, desc: 'Todo 3' }, { isDone: false, desc: 'Todo 4' }]); + }, + + teardown: function () { + ary = null; + } + }); + + QUnit.test('adding an object should notify (@each.isDone)', function () { + var called = 0; + + var observerObject = _emberRuntimeSystemObject.default.create({ + wasCalled: function () { + called++; + } + }); + + _emberMetal.addObserver(ary, '@each.isDone', observerObject, 'wasCalled'); + + ary.addObject(_emberRuntimeSystemObject.default.create({ + desc: 'foo', + isDone: false + })); + + equal(called, 1, 'calls observer when object is pushed'); + }); + + QUnit.test('@each is readOnly', function () { + expect(1); + + throws(function () { + _emberMetal.set(ary, '@each', 'foo'); + }, /Cannot set read-only property "@each"/); + }); + + QUnit.test('using @each to observe arrays that does not return objects raise error', function () { + var called = 0; + + var observerObject = _emberRuntimeSystemObject.default.create({ + wasCalled: function () { + called++; + } + }); + + ary = TestArray.create({ + objectAt: function (idx) { + return _emberMetal.get(this._content[idx], 'desc'); + } + }); + + _emberMetal.addObserver(ary, '@each.isDone', observerObject, 'wasCalled'); + + expectAssertion(function () { + ary.addObject(_emberRuntimeSystemObject.default.create({ + desc: 'foo', + isDone: false + })); + }, /When using @each to observe the array/); + + equal(called, 0, 'not calls observer when object is pushed'); + }); + + QUnit.test('modifying the array should also indicate the isDone prop itself has changed', function () { + // NOTE: we never actually get the '@each.isDone' property here. This is + // important because it tests the case where we don't have an isDone + // EachArray materialized but just want to know when the property has + // changed. + + var each = _emberMetal.get(ary, '@each'); + var count = 0; + + _emberMetal.addObserver(each, 'isDone', function () { + return count++; + }); + + count = 0; + var item = _emberRuntimeMixinsArray.objectAt(ary, 2); + _emberMetal.set(item, 'isDone', !_emberMetal.get(item, 'isDone')); + equal(count, 1, '@each.isDone should have notified'); + }); + + QUnit.test('`objectAt` returns correct object', function () { + var arr = ['first', 'second', 'third', 'fourth']; + equal(_emberRuntimeMixinsArray.objectAt(arr, 2), 'third'); + equal(_emberRuntimeMixinsArray.objectAt(arr, 4), undefined); + }); + + _internalTestHelpers.testBoth('should be clear caches for computed properties that have dependent keys on arrays that are changed after object initialization', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + init: function () { + this._super.apply(this, arguments); + set(this, 'resources', _emberRuntimeSystemNative_array.A()); + }, + + common: _emberMetal.computed('resources.@each.common', function () { + return get(_emberRuntimeMixinsArray.objectAt(get(this, 'resources'), 0), 'common'); + }) + }).create(); + + get(obj, 'resources').pushObject(_emberRuntimeSystemObject.default.create({ common: 'HI!' })); + equal('HI!', get(obj, 'common')); + + set(_emberRuntimeMixinsArray.objectAt(get(obj, 'resources'), 0), 'common', 'BYE!'); + equal('BYE!', get(obj, 'common')); + }); + + _internalTestHelpers.testBoth('observers that contain @each in the path should fire only once the first time they are accessed', function (get, set) { + var count = 0; + + var obj = _emberRuntimeSystemObject.default.extend({ + init: function () { + this._super.apply(this, arguments); + // Observer does not fire on init + set(this, 'resources', _emberRuntimeSystemNative_array.A()); + }, + + commonDidChange: _emberMetal.observer('resources.@each.common', function () { + return count++; + }) + }).create(); + + // Observer fires second time when new object is added + get(obj, 'resources').pushObject(_emberRuntimeSystemObject.default.create({ common: 'HI!' })); + // Observer fires third time when property on an object is changed + set(_emberRuntimeMixinsArray.objectAt(get(obj, 'resources'), 0), 'common', 'BYE!'); + + equal(count, 2, 'observers should only be called once'); + }); +}); +enifed('ember-runtime/tests/mixins/array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/comparable_test', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/compare', 'ember-runtime/mixins/comparable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeCompare, _emberRuntimeMixinsComparable) { + 'use strict'; + + var Rectangle = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsComparable.default, { + length: 0, + width: 0, + + area: function () { + return _emberMetal.get(this, 'length') * _emberMetal.get(this, 'width'); + }, + + compare: function (a, b) { + return _emberRuntimeCompare.default(a.area(), b.area()); + } + + }); + + var r1 = undefined, + r2 = undefined; + + QUnit.module('Comparable', { + setup: function () { + r1 = Rectangle.create({ length: 6, width: 12 }); + r2 = Rectangle.create({ length: 6, width: 13 }); + } + }); + + QUnit.test('should be comparable and return the correct result', function () { + equal(_emberRuntimeMixinsComparable.default.detect(r1), true); + equal(_emberRuntimeCompare.default(r1, r1), 0); + equal(_emberRuntimeCompare.default(r1, r2), -1); + equal(_emberRuntimeCompare.default(r2, r1), 1); + }); +}); +enifed('ember-runtime/tests/mixins/comparable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/comparable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/comparable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/container_proxy_test', ['exports', 'ember-utils', 'container', 'ember-runtime/mixins/container_proxy', 'ember-runtime/system/object'], function (exports, _emberUtils, _container, _emberRuntimeMixinsContainer_proxy, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('ember-runtime/mixins/container_proxy', { + setup: function () { + this.Owner = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsContainer_proxy.default); + this.instance = this.Owner.create(); + + var registry = new _container.Registry(); + + this.instance.__container__ = new _container.Container(registry, { + owner: this.instance + }); + } + }); + + QUnit.test('provides ownerInjection helper method', function (assert) { + var result = this.instance.ownerInjection(); + + assert.equal(result[_emberUtils.OWNER], this.instance, 'returns an object with the OWNER symbol'); + }); +}); +enifed('ember-runtime/tests/mixins/container_proxy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/container_proxy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/container_proxy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/copyable_test', ['exports', 'ember-utils', 'ember-runtime/tests/suites/copyable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeTestsSuitesCopyable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + QUnit.module('Ember.Copyable.frozenCopy'); + + QUnit.test('should be deprecated', function () { + expectDeprecation('`frozenCopy` is deprecated, use `Object.freeze` instead.'); + + var Obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsFreezable.Freezable, _emberRuntimeMixinsCopyable.default, { + copy: function () { + return Obj.create(); + } + }); + + Obj.create().frozenCopy(); + }); + + var CopyableObject = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsCopyable.default, { + id: null, + + init: function () { + this._super.apply(this, arguments); + _emberMetal.set(this, 'id', _emberUtils.generateGuid()); + }, + + copy: function () { + var ret = new CopyableObject(); + _emberMetal.set(ret, 'id', _emberMetal.get(this, 'id')); + return ret; + } + }); + + _emberRuntimeTestsSuitesCopyable.default.extend({ + + name: 'Copyable Basic Test', + + newObject: function () { + return new CopyableObject(); + }, + + isEqual: function (a, b) { + if (!(a instanceof CopyableObject) || !(b instanceof CopyableObject)) { + return false; + } + + return _emberMetal.get(a, 'id') === _emberMetal.get(b, 'id'); + } + }).run(); +}); +enifed('ember-runtime/tests/mixins/copyable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/copyable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/copyable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/enumerable_test', ['exports', 'ember-runtime/tests/suites/enumerable', 'ember-runtime/system/object', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array', 'ember-runtime/system/native_array', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesEnumerable, _emberRuntimeSystemObject, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray, _emberRuntimeSystemNative_array, _emberMetal) { + 'use strict'; + + function K() { + return this; + } + + /* + Implement a basic fake enumerable. This validates that any non-native + enumerable can impl this API. + */ + var TestEnumerable = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + _content: null, + + init: function () { + var ary = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + this._content = ary; + }, + + addObject: function (obj) { + if (this._content.indexOf(obj) >= 0) { + return this; + } + + this._content.push(obj); + this.enumerableContentDidChange(); + }, + + nextObject: function (idx) { + return idx >= _emberMetal.get(this, 'length') ? undefined : this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }), + + slice: function () { + return this._content.slice(); + } + + }); + + _emberRuntimeTestsSuitesEnumerable.default.extend({ + name: 'Basic Enumerable', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestEnumerable(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(obj._content.length + 1); + }, + + toArray: function (obj) { + return obj.slice(); + } + + }).run(); + + QUnit.module('Ember.Enumerable'); + + QUnit.test('should apply Ember.Array to return value of map', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.map(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of filter', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.filter(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of invoke', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.invoke(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of toArray', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.toArray(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of without', function () { + var X = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + contains: function () { + return true; + }, + includes: function () { + return true; + } + }); + + var x = X.create(); + var y = x.without(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('should apply Ember.Array to return value of uniq', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + var y = x.uniq(K); + equal(_emberRuntimeMixinsArray.default.detect(y), true, 'should have mixin applied'); + }); + + QUnit.test('any', function () { + var kittens = _emberRuntimeSystemNative_array.A([{ + color: 'white' + }, { + color: 'black' + }, { + color: 'white' + }]); + var foundWhite = kittens.any(function (kitten) { + return kitten.color === 'white'; + }); + var foundWhite2 = kittens.isAny('color', 'white'); + + equal(foundWhite, true); + equal(foundWhite2, true); + }); + + QUnit.test('any with NaN', function () { + var numbers = _emberRuntimeSystemNative_array.A([1, 2, NaN, 4]); + + var hasNaN = numbers.any(function (n) { + return isNaN(n); + }); + + equal(hasNaN, true, 'works when matching NaN'); + }); + + QUnit.test('every', function () { + var allColorsKittens = _emberRuntimeSystemNative_array.A([{ + color: 'white' + }, { + color: 'black' + }, { + color: 'white' + }]); + var allWhiteKittens = _emberRuntimeSystemNative_array.A([{ + color: 'white' + }, { + color: 'white' + }, { + color: 'white' + }]); + var allWhite = false; + var whiteKittenPredicate = function (kitten) { + return kitten.color === 'white'; + }; + + allWhite = allColorsKittens.every(whiteKittenPredicate); + equal(allWhite, false); + + allWhite = allWhiteKittens.every(whiteKittenPredicate); + equal(allWhite, true); + + allWhite = allColorsKittens.isEvery('color', 'white'); + equal(allWhite, false); + + allWhite = allWhiteKittens.isEvery('color', 'white'); + equal(allWhite, true); + }); + + QUnit.test('should throw an error passing a second argument to includes', function () { + var x = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default).create(); + + equal(x.includes('any'), false); + expectAssertion(function () { + x.includes('any', 1); + }, /Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered./); + }); + + // .......................................................... + // CONTENT DID CHANGE + // + + var DummyEnum = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + nextObject: function () {}, + length: 0 + }); + + var obj = undefined, + observer = undefined; + + // .......................................................... + // NOTIFY ENUMERABLE PROPERTY + // + + QUnit.module('mixins/enumerable/enumerableContentDidChange'); + + QUnit.test('should notify observers of []', function () { + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEnumerable.default, { + nextObject: function () {}, // avoid exceptions + + enumerablePropertyDidChange: _emberMetal.observer('[]', function () { + this._count++; + }) + }).create({ + _count: 0 + }); + + equal(obj._count, 0, 'should not have invoked yet'); + obj.enumerableContentWillChange(); + obj.enumerableContentDidChange(); + equal(obj._count, 1, 'should have invoked'); + }); + + // .......................................................... + // NOTIFY CHANGES TO LENGTH + // + + QUnit.module('notify observers of length', { + setup: function () { + obj = DummyEnum.extend({ + lengthDidChange: _emberMetal.observer('length', function () { + this._after++; + }) + }).create({ + _after: 0 + }); + + equal(obj._after, 0, 'should not have fired yet'); + }, + + teardown: function () { + obj = null; + } + }); + + QUnit.test('should notify observers when call with no params', function () { + obj.enumerableContentWillChange(); + equal(obj._after, 0); + + obj.enumerableContentDidChange(); + equal(obj._after, 1); + }); + + // API variation that included items only + QUnit.test('should not notify when passed arrays of same length', function () { + var added = ['foo']; + var removed = ['bar']; + + obj.enumerableContentWillChange(removed, added); + equal(obj._after, 0); + + obj.enumerableContentDidChange(removed, added); + equal(obj._after, 0); + }); + + QUnit.test('should notify when passed arrays of different length', function () { + var added = ['foo']; + var removed = ['bar', 'baz']; + + obj.enumerableContentWillChange(removed, added); + equal(obj._after, 0); + + obj.enumerableContentDidChange(removed, added); + equal(obj._after, 1); + }); + + // API variation passes indexes only + QUnit.test('should not notify when passed with indexes', function () { + obj.enumerableContentWillChange(1, 1); + equal(obj._after, 0); + + obj.enumerableContentDidChange(1, 1); + equal(obj._after, 0); + }); + + QUnit.test('should notify when passed old index API with delta', function () { + obj.enumerableContentWillChange(1, 2); + equal(obj._after, 0); + + obj.enumerableContentDidChange(1, 2); + equal(obj._after, 1); + }); + + // .......................................................... + // NOTIFY ENUMERABLE OBSERVER + // + + QUnit.module('notify enumerable observers', { + setup: function () { + obj = DummyEnum.create(); + + observer = _emberRuntimeSystemObject.default.extend({ + enumerableWillChange: function () { + equal(this._before, null); // should only call once + this._before = Array.prototype.slice.call(arguments); + }, + + enumerableDidChange: function () { + equal(this._after, null); // should only call once + this._after = Array.prototype.slice.call(arguments); + } + }).create({ + _before: null, + _after: null + }); + + obj.addEnumerableObserver(observer); + }, + + teardown: function () { + obj = observer = null; + } + }); + + QUnit.test('should notify enumerable observers when called with no params', function () { + obj.enumerableContentWillChange(); + deepEqual(observer._before, [obj, null, null]); + + obj.enumerableContentDidChange(); + deepEqual(observer._after, [obj, null, null]); + }); + + // API variation that included items only + QUnit.test('should notify when called with same length items', function () { + var added = ['foo']; + var removed = ['bar']; + + obj.enumerableContentWillChange(removed, added); + deepEqual(observer._before, [obj, removed, added]); + + obj.enumerableContentDidChange(removed, added); + deepEqual(observer._after, [obj, removed, added]); + }); + + QUnit.test('should notify when called with diff length items', function () { + var added = ['foo', 'baz']; + var removed = ['bar']; + + obj.enumerableContentWillChange(removed, added); + deepEqual(observer._before, [obj, removed, added]); + + obj.enumerableContentDidChange(removed, added); + deepEqual(observer._after, [obj, removed, added]); + }); + + QUnit.test('should not notify when passed with indexes only', function () { + obj.enumerableContentWillChange(1, 2); + deepEqual(observer._before, [obj, 1, 2]); + + obj.enumerableContentDidChange(1, 2); + deepEqual(observer._after, [obj, 1, 2]); + }); + + QUnit.test('removing enumerable observer should disable', function () { + obj.removeEnumerableObserver(observer); + obj.enumerableContentWillChange(); + deepEqual(observer._before, null); + + obj.enumerableContentDidChange(); + deepEqual(observer._after, null); + }); +}); +enifed('ember-runtime/tests/mixins/enumerable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/enumerable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/enumerable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/freezable_test', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/freezable'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsFreezable) { + 'use strict'; + + QUnit.module('Ember.Freezable'); + + QUnit.test('should be deprecated', function () { + expectDeprecation('`Ember.Freezable` is deprecated, use `Object.freeze` instead.'); + _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsFreezable.Freezable).create(); + }); +}); +enifed('ember-runtime/tests/mixins/freezable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/freezable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/freezable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/mutable_array_test', ['exports', 'ember-metal', 'ember-runtime/tests/suites/mutable_array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/system/object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeTestsSuitesMutable_array, _emberRuntimeMixinsMutable_array, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array, _emberRuntimeMixinsArray) { + 'use strict'; + + /* + Implement a basic fake mutable array. This validates that any non-native + enumerable can impl this API. + */ + var TestMutableArray = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { + + _content: null, + + init: function () { + var ary = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + + this._content = _emberRuntimeSystemNative_array.A(ary); + }, + + replace: function (idx, amt, objects) { + var args = objects ? objects.slice() : []; + var removeAmt = amt; + var addAmt = args.length; + + _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, removeAmt, addAmt); + + args.unshift(amt); + args.unshift(idx); + this._content.splice.apply(this._content, args); + _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, removeAmt, addAmt); + return this; + }, + + objectAt: function (idx) { + return this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }), + + slice: function () { + return this._content.slice(); + } + + }); + + _emberRuntimeTestsSuitesMutable_array.default.extend({ + + name: 'Basic Mutable Array', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestMutableArray(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(this.getFixture(1)[0]); + }, + + toArray: function (obj) { + return obj.slice(); + } + + }).run(); +}); +enifed('ember-runtime/tests/mixins/mutable_array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/mutable_array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/mutable_array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/mutable_enumerable_test', ['exports', 'ember-runtime/tests/suites/mutable_enumerable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesMutable_enumerable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + /* + Implement a basic fake mutable array. This validates that any non-native + enumerable can impl this API. + */ + var TestMutableEnumerable = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_enumerable.default, { + _content: null, + + addObject: function (obj) { + if (this._content.indexOf(obj) >= 0) { + return this; + } + + this.enumerableContentWillChange(null, [obj]); + this._content.push(obj); + this.enumerableContentDidChange(null, [obj]); + }, + + removeObject: function (obj) { + var idx = this._content.indexOf(obj); + if (idx < 0) { + return this; + } + + this.enumerableContentWillChange([obj], null); + this._content.splice(idx, 1); + this.enumerableContentDidChange([obj], null); + return this; + }, + + init: function (ary) { + this._content = ary || []; + }, + + nextObject: function (idx) { + return idx >= _emberMetal.get(this, 'length') ? undefined : this._content[idx]; + }, + + length: _emberMetal.computed(function () { + return this._content.length; + }), + + slice: function () { + return this._content.slice(); + } + }); + + _emberRuntimeTestsSuitesMutable_enumerable.default.extend({ + name: 'Basic Mutable Array', + + newObject: function (ary) { + ary = ary ? ary.slice() : this.newFixture(3); + return new TestMutableEnumerable(ary); + }, + + // allows for testing of the basic enumerable after an internal mutation + mutate: function (obj) { + obj.addObject(this.getFixture(1)[0]); + }, + + toArray: function (obj) { + return obj.slice(); + } + }).run(); +}); +enifed('ember-runtime/tests/mixins/mutable_enumerable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/mutable_enumerable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/mutable_enumerable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/observable_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('mixins/observable'); + + QUnit.test('should be able to use getProperties to get a POJO of provided keys', function () { + var obj = _emberRuntimeSystemObject.default.create({ + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }); + + var pojo = obj.getProperties('firstName', 'lastName'); + equal('Steve', pojo.firstName); + equal('Jobs', pojo.lastName); + }); + + QUnit.test('should be able to use getProperties with array parameter to get a POJO of provided keys', function () { + var obj = _emberRuntimeSystemObject.default.create({ + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }); + + var pojo = obj.getProperties(['firstName', 'lastName']); + equal('Steve', pojo.firstName); + equal('Jobs', pojo.lastName); + }); + + QUnit.test('should be able to use setProperties to set multiple properties at once', function () { + var obj = _emberRuntimeSystemObject.default.create({ + firstName: 'Steve', + lastName: 'Jobs', + companyName: 'Apple, Inc.' + }); + + obj.setProperties({ firstName: 'Tim', lastName: 'Cook' }); + equal('Tim', obj.get('firstName')); + equal('Cook', obj.get('lastName')); + }); + + _internalTestHelpers.testBoth('calling setProperties completes safely despite exceptions', function (get, set) { + var exc = new Error('Something unexpected happened!'); + var obj = _emberRuntimeSystemObject.default.extend({ + companyName: _emberMetal.computed({ + get: function () { + return 'Apple, Inc.'; + }, + set: function (key, value) { + throw exc; + } + }) + }).create({ + firstName: 'Steve', + lastName: 'Jobs' + }); + + var firstNameChangedCount = 0; + + _emberMetal.addObserver(obj, 'firstName', function () { + return firstNameChangedCount++; + }); + + try { + obj.setProperties({ + firstName: 'Tim', + lastName: 'Cook', + companyName: 'Fruit Co., Inc.' + }); + } catch (err) { + if (err !== exc) { + throw err; + } + } + + equal(firstNameChangedCount, 1, 'firstName should have fired once'); + }); + + _internalTestHelpers.testBoth('should be able to retrieve cached values of computed properties without invoking the computed property', function (get) { + var obj = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'foo'; + }) + }).create({ + bar: 'bar' + }); + + equal(obj.cacheFor('foo'), undefined, 'should return undefined if no value has been cached'); + get(obj, 'foo'); + + equal(get(obj, 'foo'), 'foo', 'precond - should cache the value'); + equal(obj.cacheFor('foo'), 'foo', 'should return the cached value after it is invoked'); + + equal(obj.cacheFor('bar'), undefined, 'returns undefined if the value is not a computed property'); + }); + + QUnit.test('incrementProperty should work even if value is number in string', function () { + var obj = _emberRuntimeSystemObject.default.create({ + age: '24' + }); + obj.incrementProperty('age'); + equal(25, obj.get('age')); + }); +}); +enifed('ember-runtime/tests/mixins/observable_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/observable_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/observable_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/promise_proxy_test', ['exports', 'ember-metal', 'ember-runtime/system/object_proxy', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/ext/rsvp', 'rsvp'], function (exports, _emberMetal, _emberRuntimeSystemObject_proxy, _emberRuntimeMixinsPromise_proxy, _emberRuntimeExtRsvp, _rsvp) { + 'use strict'; + + var ObjectPromiseProxy = undefined; + + QUnit.test('present on ember namespace', function () { + ok(_emberRuntimeMixinsPromise_proxy.default, 'expected PromiseProxyMixin to exist'); + }); + + QUnit.module('Ember.PromiseProxy - ObjectProxy', { + setup: function () { + ObjectPromiseProxy = _emberRuntimeSystemObject_proxy.default.extend(_emberRuntimeMixinsPromise_proxy.default); + }, + + teardown: function () { + _rsvp.on('error', _emberRuntimeExtRsvp.onerrorDefault); + } + }); + + QUnit.test('no promise, invoking then should raise', function () { + var proxy = ObjectPromiseProxy.create(); + + throws(function () { + proxy.then(function () { + return this; + }, function () { + return this; + }); + }, new RegExp('PromiseProxy\'s promise must be set')); + }); + + QUnit.test('fulfillment', function () { + var value = { + firstName: 'stef', + lastName: 'penner' + }; + + var deferred = _rsvp.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + var didFulfillCount = 0; + var didRejectCount = 0; + + proxy.then(function () { + return didFulfillCount++; + }, function () { + return didRejectCount++; + }); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + equal(didFulfillCount, 0, 'should not yet have been fulfilled'); + equal(didRejectCount, 0, 'should not yet have been rejected'); + + _emberMetal.run(deferred, 'resolve', value); + + equal(didFulfillCount, 1, 'should have been fulfilled'); + equal(didRejectCount, 0, 'should not have been rejected'); + + equal(_emberMetal.get(proxy, 'content'), value, 'expects the proxy to have content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy to still have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled'); + + _emberMetal.run(deferred, 'resolve', value); + + equal(didFulfillCount, 1, 'should still have been only fulfilled once'); + equal(didRejectCount, 0, 'should still not have been rejected'); + + _emberMetal.run(deferred, 'reject', value); + + equal(didFulfillCount, 1, 'should still have been only fulfilled once'); + equal(didRejectCount, 0, 'should still not have been rejected'); + + equal(_emberMetal.get(proxy, 'content'), value, 'expects the proxy to have still have same content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy still to have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled'); + + // rest of the promise semantics are tested in directly in RSVP + }); + + QUnit.test('rejection', function () { + var reason = new Error('failure'); + var deferred = _rsvp.defer(); + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + var didFulfillCount = 0; + var didRejectCount = 0; + + proxy.then(function () { + return didFulfillCount++; + }, function () { + return didRejectCount++; + }); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + equal(didFulfillCount, 0, 'should not yet have been fulfilled'); + equal(didRejectCount, 0, 'should not yet have been rejected'); + + _emberMetal.run(deferred, 'reject', reason); + + equal(didFulfillCount, 0, 'should not yet have been fulfilled'); + equal(didRejectCount, 1, 'should have been rejected'); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), reason, 'expects the proxy to have a reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + _emberMetal.run(deferred, 'reject', reason); + + equal(didFulfillCount, 0, 'should stll not yet have been fulfilled'); + equal(didRejectCount, 1, 'should still remain rejected'); + + _emberMetal.run(deferred, 'resolve', 1); + + equal(didFulfillCount, 0, 'should stll not yet have been fulfilled'); + equal(didRejectCount, 1, 'should still remain rejected'); + + equal(_emberMetal.get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + equal(_emberMetal.get(proxy, 'reason'), reason, 'expects the proxy to have a reason'); + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + }); + + QUnit.test('unhandled rejects still propagate to RSVP.on(\'error\', ...) ', function () { + expect(1); + + _rsvp.on('error', onerror); + _rsvp.off('error', _emberRuntimeExtRsvp.onerrorDefault); + + var expectedReason = new Error('failure'); + var deferred = _rsvp.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.get('promise'); + + function onerror(reason) { + equal(reason, expectedReason, 'expected reason'); + } + + _rsvp.on('error', onerror); + _rsvp.off('error', _emberRuntimeExtRsvp.onerrorDefault); + + _emberMetal.run(deferred, 'reject', expectedReason); + + _rsvp.on('error', _emberRuntimeExtRsvp.onerrorDefault); + _rsvp.off('error', onerror); + + _emberMetal.run(deferred, 'reject', expectedReason); + + _rsvp.on('error', _emberRuntimeExtRsvp.onerrorDefault); + _rsvp.off('error', onerror); + }); + + QUnit.test('should work with promise inheritance', function () { + function PromiseSubclass() { + _rsvp.Promise.apply(this, arguments); + } + + PromiseSubclass.prototype = Object.create(_rsvp.Promise.prototype); + PromiseSubclass.prototype.constructor = PromiseSubclass; + PromiseSubclass.cast = _rsvp.Promise.cast; + + var proxy = ObjectPromiseProxy.create({ + promise: new PromiseSubclass(function () {}) + }); + + ok(proxy.then() instanceof PromiseSubclass, 'promise proxy respected inheritance'); + }); + + QUnit.test('should reset isFulfilled and isRejected when promise is reset', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled'); + + var anotherDeferred = _emberRuntimeExtRsvp.default.defer(); + proxy.set('promise', anotherDeferred.promise); + + equal(_emberMetal.get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); + equal(_emberMetal.get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled'); + equal(_emberMetal.get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + + _emberMetal.run(anotherDeferred, 'reject'); + + equal(_emberMetal.get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading'); + equal(_emberMetal.get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled'); + equal(_emberMetal.get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected'); + equal(_emberMetal.get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled'); + }); + + QUnit.test('should have content when isFulfilled is set', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.addObserver('isFulfilled', function () { + return equal(_emberMetal.get(proxy, 'content'), true); + }); + + _emberMetal.run(deferred, 'resolve', true); + }); + + QUnit.test('should have reason when isRejected is set', function () { + var error = new Error('Y U REJECT?!?'); + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.addObserver('isRejected', function () { + return equal(_emberMetal.get(proxy, 'reason'), error); + }); + + try { + _emberMetal.run(deferred, 'reject', error); + } catch (e) { + equal(e, error); + } + }); + + QUnit.test('should not error if promise is resolved after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function () {}, function () {}); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'resolve', true); + + ok(true, 'resolving the promise after the proxy has been destroyed does not raise an error'); + }); + + QUnit.test('should not error if promise is rejected after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function () {}, function () {}); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'reject', 'some reason'); + + ok(true, 'rejecting the promise after the proxy has been destroyed does not raise an error'); + }); + + QUnit.test('promise chain is not broken if promised is resolved after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + var expectedValue = {}; + var receivedValue = undefined; + var didResolveCount = 0; + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function (value) { + receivedValue = value; + didResolveCount++; + }, function () {}); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'resolve', expectedValue); + + equal(didResolveCount, 1, 'callback called'); + equal(receivedValue, expectedValue, 'passed value is the value the promise was resolved with'); + }); + + QUnit.test('promise chain is not broken if promised is rejected after proxy has been destroyed', function () { + var deferred = _emberRuntimeExtRsvp.default.defer(); + var expectedReason = 'some reason'; + var receivedReason = undefined; + var didRejectCount = 0; + + var proxy = ObjectPromiseProxy.create({ + promise: deferred.promise + }); + + proxy.then(function () {}, function (reason) { + receivedReason = reason; + didRejectCount++; + }); + + _emberMetal.run(proxy, 'destroy'); + + _emberMetal.run(deferred, 'reject', expectedReason); + + equal(didRejectCount, 1, 'callback called'); + equal(receivedReason, expectedReason, 'passed reason is the reason the promise was rejected for'); + }); +}); +enifed('ember-runtime/tests/mixins/promise_proxy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/promise_proxy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/promise_proxy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/mixins/target_action_support_test', ['exports', 'ember-environment', 'ember-runtime/system/object', 'ember-runtime/mixins/target_action_support'], function (exports, _emberEnvironment, _emberRuntimeSystemObject, _emberRuntimeMixinsTarget_action_support) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('TargetActionSupport', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('it should return false if no target or action are specified', function () { + expect(1); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create(); + + ok(false === obj.triggerAction(), 'no target or action was specified'); + }); + + QUnit.test('it should support actions specified as strings', function () { + expect(2); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called'); + } + }), + + action: 'anEvent' + }); + + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should invoke the send() method on objects that implement it', function () { + expect(3); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + send: function (evt, context) { + equal(evt, 'anEvent', 'send() method was invoked with correct event name'); + equal(context, obj, 'send() method was invoked with correct context'); + } + }), + + action: 'anEvent' + }); + + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should find targets specified using a property path', function () { + expect(2); + + var Test = {}; + lookup.Test = Test; + + Test.targetObj = _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called on global object'); + } + }); + + var myObj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: 'Test.targetObj', + action: 'anEvent' + }); + + ok(true === myObj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should use an actionContext object specified as a property on the object', function () { + expect(2); + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + action: 'anEvent', + actionContext: {}, + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(obj.actionContext === ctx, 'anEvent method was called with the expected context'); + } + }) + }); + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should find an actionContext specified as a property path', function () { + expect(2); + + var Test = {}; + lookup.Test = Test; + Test.aContext = {}; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + action: 'anEvent', + actionContext: 'Test.aContext', + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(Test.aContext === ctx, 'anEvent method was called with the expected context'); + } + }) + }); + + ok(true === obj.triggerAction(), 'a valid target and action were specified'); + }); + + QUnit.test('it should use the target specified in the argument', function () { + expect(2); + var targetObj = _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called'); + } + }); + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + action: 'anEvent' + }); + + ok(true === obj.triggerAction({ target: targetObj }), 'a valid target and action were specified'); + }); + + QUnit.test('it should use the action specified in the argument', function () { + expect(2); + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function () { + ok(true, 'anEvent method was called'); + } + }) + }); + ok(true === obj.triggerAction({ action: 'anEvent' }), 'a valid target and action were specified'); + }); + + QUnit.test('it should use the actionContext specified in the argument', function () { + expect(2); + var context = {}; + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(context === ctx, 'anEvent method was called with the expected context'); + } + }), + action: 'anEvent' + }); + + ok(true === obj.triggerAction({ actionContext: context }), 'a valid target and action were specified'); + }); + + QUnit.test('it should allow multiple arguments from actionContext', function () { + expect(3); + var param1 = 'someParam'; + var param2 = 'someOtherParam'; + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (first, second) { + ok(first === param1, 'anEvent method was called with the expected first argument'); + ok(second === param2, 'anEvent method was called with the expected second argument'); + } + }), + action: 'anEvent' + }); + + ok(true === obj.triggerAction({ actionContext: [param1, param2] }), 'a valid target and action were specified'); + }); + + QUnit.test('it should use a null value specified in the actionContext argument', function () { + expect(2); + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsTarget_action_support.default).create({ + target: _emberRuntimeSystemObject.default.create({ + anEvent: function (ctx) { + ok(null === ctx, 'anEvent method was called with the expected context (null)'); + } + }), + action: 'anEvent' + }); + ok(true === obj.triggerAction({ actionContext: null }), 'a valid target and action were specified'); + }); +}); +enifed('ember-runtime/tests/mixins/target_action_support_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/mixins/target_action_support_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/mixins/target_action_support_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array', ['exports', 'ember-runtime/tests/suites/enumerable', 'ember-runtime/tests/suites/array/indexOf', 'ember-runtime/tests/suites/array/lastIndexOf', 'ember-runtime/tests/suites/array/objectAt', 'ember-runtime/tests/suites/array/includes', 'ember-runtime/mixins/array'], function (exports, _emberRuntimeTestsSuitesEnumerable, _emberRuntimeTestsSuitesArrayIndexOf, _emberRuntimeTestsSuitesArrayLastIndexOf, _emberRuntimeTestsSuitesArrayObjectAt, _emberRuntimeTestsSuitesArrayIncludes, _emberRuntimeMixinsArray) { + 'use strict'; + + var ObserverClass = _emberRuntimeTestsSuitesEnumerable.ObserverClass.extend({ + observeArray: function (obj) { + _emberRuntimeMixinsArray.addArrayObserver(obj, this); + return this; + }, + + stopObserveArray: function (obj) { + _emberRuntimeMixinsArray.removeArrayObserver(obj, this); + return this; + }, + + arrayWillChange: function () { + equal(this._before, null, 'should only call once'); + this._before = Array.prototype.slice.call(arguments); + }, + + arrayDidChange: function () { + equal(this._after, null, 'should only call once'); + this._after = Array.prototype.slice.call(arguments); + } + }); + + var ArrayTests = _emberRuntimeTestsSuitesEnumerable.EnumerableTests.extend({ + observerClass: ObserverClass + }); + + ArrayTests.ObserverClass = ObserverClass; + + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayIndexOf.default); + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayLastIndexOf.default); + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayObjectAt.default); + + ArrayTests.importModuleTests(_emberRuntimeTestsSuitesArrayIncludes.default); + + exports.ArrayTests = ArrayTests; + exports.ObserverClass = ObserverClass; +}); +enifed('ember-runtime/tests/suites/array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/includes', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('includes'); + + suite.test('includes returns correct value if startAt is positive', function () { + var data = this.newFixture(3); + var obj = this.newObject(data); + + equal(obj.includes(data[1], 1), true, 'should return true if included'); + equal(obj.includes(data[0], 1), false, 'should return false if not included'); + }); + + suite.test('includes returns correct value if startAt is negative', function () { + var data = this.newFixture(3); + var obj = this.newObject(data); + + equal(obj.includes(data[1], -2), true, 'should return true if included'); + equal(obj.includes(data[0], -2), false, 'should return false if not included'); + }); + + suite.test('includes returns true if startAt + length is still negative', function () { + var data = this.newFixture(1); + var obj = this.newObject(data); + + equal(obj.includes(data[0], -2), true, 'should return true if included'); + equal(obj.includes(this.newFixture(1), -2), false, 'should return false if not included'); + }); + + suite.test('includes returns false if startAt out of bounds', function () { + var data = this.newFixture(1); + var obj = this.newObject(data); + + equal(obj.includes(data[0], 2), false, 'should return false if startAt >= length'); + equal(obj.includes(this.newFixture(1), 2), false, 'should return false if startAt >= length'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/includes.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/includes.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/includes.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/indexOf', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('indexOf'); + + suite.test('should return index of object', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.indexOf(expected[idx]), idx, 'obj.indexOf(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return -1 when requesting object not in index', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.indexOf(foo), -1, 'obj.indexOf(foo) should be < 0'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/indexOf.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/indexOf.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/indexOf.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/lastIndexOf', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('lastIndexOf'); + + suite.test('should return index of object\'s last occurrence', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.lastIndexOf(expected[idx]), idx, 'obj.lastIndexOf(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return index of object\'s last occurrence even startAt search location is equal to length', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.lastIndexOf(expected[idx], len), idx, 'obj.lastIndexOfs(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return index of object\'s last occurrence even startAt search location is greater than length', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = 3; + + for (var idx = 0; idx < len; idx++) { + equal(obj.lastIndexOf(expected[idx], len + 1), idx, 'obj.lastIndexOf(' + expected[idx] + ') should match idx'); + } + }); + + suite.test('should return -1 when no match is found', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.lastIndexOf(foo), -1, 'obj.lastIndexOf(foo) should be -1'); + }); + + suite.test('should return -1 when no match is found even startAt search location is equal to length', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.lastIndexOf(foo, obj.length), -1, 'obj.lastIndexOf(foo) should be -1'); + }); + + suite.test('should return -1 when no match is found even startAt search location is greater than length', function () { + var obj = this.newObject(this.newFixture(3)); + var foo = {}; + + equal(obj.lastIndexOf(foo, obj.length + 1), -1, 'obj.lastIndexOf(foo) should be -1'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/lastIndexOf.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/lastIndexOf.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/lastIndexOf.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/array/objectAt', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/mixins/array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeMixinsArray) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('objectAt'); + + suite.test('should return object at specified index', function () { + var expected = this.newFixture(3); + var obj = this.newObject(expected); + var len = expected.length; + + for (var idx = 0; idx < len; idx++) { + equal(_emberRuntimeMixinsArray.objectAt(obj, idx), expected[idx], 'obj.objectAt(' + idx + ') should match'); + } + }); + + suite.test('should return undefined when requesting objects beyond index', function () { + var obj = undefined; + + obj = this.newObject(this.newFixture(3)); + equal(_emberRuntimeMixinsArray.objectAt(obj, 5), undefined, 'should return undefined for obj.objectAt(5) when len = 3'); + + obj = this.newObject([]); + equal(_emberRuntimeMixinsArray.objectAt(obj, 0), undefined, 'should return undefined for obj.objectAt(0) when len = 0'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/array/objectAt.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/array/objectAt.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/array/objectAt.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/copyable', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/tests/suites/copyable/copy', 'ember-runtime/tests/suites/copyable/frozenCopy'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeTestsSuitesCopyableCopy, _emberRuntimeTestsSuitesCopyableFrozenCopy) { + 'use strict'; + + var CopyableTests = _emberRuntimeTestsSuitesSuite.Suite.extend({ + + /* + __Required.__ You must implement this method to apply this mixin. + Must be able to create a new object for testing. + @returns {Object} object + */ + newObject: null, + + /* + __Required.__ You must implement this method to apply this mixin. + Compares the two passed in objects. Returns true if the two objects + are logically equivalent. + @param {Object} a + First object + @param {Object} b + Second object + @returns {Boolean} + */ + isEqual: null, + + /* + Set this to true if you expect the objects you test to be freezable. + The suite will verify that your objects actually match this. (i.e. if + you say you can't test freezable it will verify that your objects really + aren't freezable.) + @type Boolean + */ + shouldBeFreezable: false + + }); + + CopyableTests.importModuleTests(_emberRuntimeTestsSuitesCopyableCopy.default); + CopyableTests.importModuleTests(_emberRuntimeTestsSuitesCopyableFrozenCopy.default); + + exports.default = CopyableTests; +}); +enifed('ember-runtime/tests/suites/copyable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/copyable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/copyable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/copyable/copy', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('copy'); + + suite.test('should return an equivalent copy', function () { + var obj = this.newObject(); + var copy = obj.copy(); + ok(this.isEqual(obj, copy), 'old object and new object should be equivalent'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/copyable/copy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/copyable/copy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/copyable/copy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/copyable/frozenCopy', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/mixins/freezable', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeMixinsFreezable, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('frozenCopy'); + + suite.test('frozen objects should return same instance', function () { + var obj = undefined, + copy = undefined; + + obj = this.newObject(); + if (_emberMetal.get(this, 'shouldBeFreezable')) { + expectDeprecation('`frozenCopy` is deprecated, use Object.freeze instead.'); + + ok(!_emberRuntimeMixinsFreezable.Freezable || _emberRuntimeMixinsFreezable.Freezable.detect(obj), 'object should be freezable'); + + copy = obj.frozenCopy(); + ok(this.isEqual(obj, copy), 'new copy should be equal'); + ok(_emberMetal.get(copy, 'isFrozen'), 'returned value should be frozen'); + + copy = obj.freeze().frozenCopy(); + equal(copy, obj, 'returns frozen object should be same'); + ok(_emberMetal.get(copy, 'isFrozen'), 'returned object should be frozen'); + } else { + ok(!_emberRuntimeMixinsFreezable.Freezable || !_emberRuntimeMixinsFreezable.Freezable.detect(obj), 'object should not be freezable'); + } + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/copyable/frozenCopy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/copyable/frozenCopy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/copyable/frozenCopy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable', ['exports', 'ember-utils', 'ember-runtime/tests/suites/suite', 'ember-runtime/system/object', 'ember-metal', 'ember-runtime/tests/suites/enumerable/any', 'ember-runtime/tests/suites/enumerable/is_any', 'ember-runtime/tests/suites/enumerable/compact', 'ember-runtime/tests/suites/enumerable/contains', 'ember-runtime/tests/suites/enumerable/includes', 'ember-runtime/tests/suites/enumerable/every', 'ember-runtime/tests/suites/enumerable/filter', 'ember-runtime/tests/suites/enumerable/find', 'ember-runtime/tests/suites/enumerable/firstObject', 'ember-runtime/tests/suites/enumerable/forEach', 'ember-runtime/tests/suites/enumerable/mapBy', 'ember-runtime/tests/suites/enumerable/invoke', 'ember-runtime/tests/suites/enumerable/lastObject', 'ember-runtime/tests/suites/enumerable/map', 'ember-runtime/tests/suites/enumerable/reduce', 'ember-runtime/tests/suites/enumerable/reject', 'ember-runtime/tests/suites/enumerable/sortBy', 'ember-runtime/tests/suites/enumerable/toArray', 'ember-runtime/tests/suites/enumerable/uniq', 'ember-runtime/tests/suites/enumerable/uniqBy', 'ember-runtime/tests/suites/enumerable/without'], function (exports, _emberUtils, _emberRuntimeTestsSuitesSuite, _emberRuntimeSystemObject, _emberMetal, _emberRuntimeTestsSuitesEnumerableAny, _emberRuntimeTestsSuitesEnumerableIs_any, _emberRuntimeTestsSuitesEnumerableCompact, _emberRuntimeTestsSuitesEnumerableContains, _emberRuntimeTestsSuitesEnumerableIncludes, _emberRuntimeTestsSuitesEnumerableEvery, _emberRuntimeTestsSuitesEnumerableFilter, _emberRuntimeTestsSuitesEnumerableFind, _emberRuntimeTestsSuitesEnumerableFirstObject, _emberRuntimeTestsSuitesEnumerableForEach, _emberRuntimeTestsSuitesEnumerableMapBy, _emberRuntimeTestsSuitesEnumerableInvoke, _emberRuntimeTestsSuitesEnumerableLastObject, _emberRuntimeTestsSuitesEnumerableMap, _emberRuntimeTestsSuitesEnumerableReduce, _emberRuntimeTestsSuitesEnumerableReject, _emberRuntimeTestsSuitesEnumerableSortBy, _emberRuntimeTestsSuitesEnumerableToArray, _emberRuntimeTestsSuitesEnumerableUniq, _emberRuntimeTestsSuitesEnumerableUniqBy, _emberRuntimeTestsSuitesEnumerableWithout) { + 'use strict'; + + var ObserverClass = _emberRuntimeSystemObject.default.extend({ + _keysBefore: null, + _keys: null, + _values: null, + _before: null, + _after: null, + + isEnabled: true, + + init: function () { + this._super.apply(this, arguments); + this.reset(); + }, + + propertyWillChange: function (target, key) { + if (this._keysBefore[key] === undefined) { + this._keysBefore[key] = 0; + } + this._keysBefore[key]++; + }, + + /* + Invoked when the property changes. Just records the parameters for + later analysis. + */ + propertyDidChange: function (target, key, value) { + if (this._keys[key] === undefined) { + this._keys[key] = 0; + } + this._keys[key]++; + this._values[key] = value; + }, + + /* + Resets the recorded results for another run. + @returns {Object} receiver + */ + reset: function () { + this._keysBefore = {}; + this._keys = {}; + this._values = {}; + this._before = null; + this._after = null; + return this; + }, + + observeBefore: function (obj) { + var keys = Array.prototype.slice.call(arguments, 1); + var loc = keys.length; + while (--loc >= 0) { + _emberMetal._addBeforeObserver(obj, keys[loc], this, 'propertyWillChange'); + } + + return this; + }, + + /* + Begins observing the passed key names on the passed object. Any changes + on the named properties will be recorded. + @param {Ember.Enumerable} obj + The enumerable to observe. + @returns {Object} receiver + */ + observe: function (obj) { + if (obj.addObserver) { + var keys = Array.prototype.slice.call(arguments, 1); + var loc = keys.length; + + while (--loc >= 0) { + obj.addObserver(keys[loc], this, 'propertyDidChange'); + } + } else { + this.isEnabled = false; + } + return this; + }, + + /* + Returns true if the passed key was invoked. If you pass a value as + well then validates that the values match. + @param {String} key + Key to validate + @param {Object} value + (Optional) value + @returns {Boolean} + */ + validate: function (key, value) { + if (!this.isEnabled) { + return true; + } + + if (!this._keys[key]) { + return false; + } + + if (arguments.length > 1) { + return this._values[key] === value; + } else { + return true; + } + }, + + /* + Returns times the before observer as invoked. + @param {String} key + Key to check + */ + timesCalledBefore: function (key) { + return this._keysBefore[key] || 0; + }, + + /* + Returns times the observer as invoked. + @param {String} key + Key to check + */ + timesCalled: function (key) { + return this._keys[key] || 0; + }, + + /* + begins acting as an enumerable observer. + */ + observeEnumerable: function (obj) { + obj.addEnumerableObserver(this); + return this; + }, + + stopObserveEnumerable: function (obj) { + obj.removeEnumerableObserver(this); + return this; + }, + + enumerableWillChange: function () { + equal(this._before, null, 'should only call once'); + this._before = Array.prototype.slice.call(arguments); + }, + + enumerableDidChange: function () { + equal(this._after, null, 'should only call once'); + this._after = Array.prototype.slice.call(arguments); + } + }); + + var EnumerableTests = _emberRuntimeTestsSuitesSuite.Suite.extend({ + /* + __Required.__ You must implement this method to apply this mixin. + Implement to return a new enumerable object for testing. Should accept + either no parameters, a single number (indicating the desired length of + the collection) or an array of objects. + @param {Array} content + An array of items to include in the enumerable optionally. + @returns {Ember.Enumerable} a new enumerable + */ + newObject: null, + + /* + Implement to return a set of new fixture strings that can be applied to + the enumerable. This may be passed into the newObject method. + @param {Number} count + The number of items required. + @returns {Array} array of strings + */ + newFixture: function (cnt) { + var ret = []; + while (--cnt >= 0) { + ret.push(_emberUtils.generateGuid()); + } + + return ret; + }, + + /* + Implement to return a set of new fixture objects that can be applied to + the enumerable. This may be passed into the newObject method. + @param {Number} cnt + The number of items required. + @returns {Array} array of objects + */ + newObjectsFixture: function (cnt) { + var ret = []; + var item = undefined; + while (--cnt >= 0) { + item = {}; + _emberUtils.guidFor(item); + ret.push(item); + } + return ret; + }, + + /* + __Required.__ You must implement this method to apply this mixin. + Implement accept an instance of the enumerable and return an array + containing the objects in the enumerable. This is used only for testing + so performance is not important. + @param {Ember.Enumerable} enumerable + The enumerable to convert. + @returns {Array} array of items + */ + toArray: null, + + /* + Implement this method if your object can mutate internally (even if it + does not support the MutableEnumerable API). The method should accept + an object of your desired type and modify it somehow. Suite tests will + use this to ensure that all appropriate caches, etc. clear when the + mutation occurs. + If you do not define this optional method, then mutation-related tests + will be skipped. + @param {Ember.Enumerable} enumerable + The enumerable to mutate + @returns {void} + */ + mutate: function () {}, + + /* + Becomes true when you define a new mutate() method, indicating that + mutation tests should run. This is calculated automatically. + @type Boolean + */ + canTestMutation: _emberMetal.computed(function () { + return this.mutate !== EnumerableTests.prototype.mutate; + }), + + /* + Invoked to actually run the test - overridden by mixins + */ + run: function () {}, + + /* + Creates a new observer object for testing. You can add this object as an + observer on an array and it will record results anytime it is invoked. + After running the test, call the validate() method on the observer to + validate the results. + */ + newObserver: function (obj) { + var ret = _emberMetal.get(this, 'observerClass').create(); + if (arguments.length > 0) { + ret.observeBefore.apply(ret, arguments); + } + + if (arguments.length > 0) { + ret.observe.apply(ret, arguments); + } + + return ret; + }, + + observerClass: ObserverClass + }); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableAny.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableIs_any.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableCompact.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableContains.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableEvery.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableFilter.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableFind.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableFirstObject.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableForEach.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableMapBy.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableInvoke.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableLastObject.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableMap.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableReduce.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableReject.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableSortBy.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableToArray.default); + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableUniq.default); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableUniqBy.default); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableIncludes.default); + + EnumerableTests.importModuleTests(_emberRuntimeTestsSuitesEnumerableWithout.default); + + exports.default = EnumerableTests; + exports.EnumerableTests = EnumerableTests; + exports.ObserverClass = ObserverClass; +}); +enifed('ember-runtime/tests/suites/enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/any', ['exports', 'ember-runtime/tests/suites/suite', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberRuntimeSystemNative_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // any() + // + + suite.module('any'); + + suite.test('any should should invoke callback on each item as long as you return false', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + var result = undefined; + + result = obj.any(function (i) { + found.push(i); + return false; + }); + equal(result, false, 'return value of obj.any'); + deepEqual(found, ary, 'items passed during any() should match'); + }); + + suite.test('any should stop invoking when you return true', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var exp = cnt; + var found = []; + var result = undefined; + + result = obj.any(function (i) { + found.push(i); + return --cnt <= 0; + }); + equal(result, true, 'return value of obj.any'); + equal(found.length, exp, 'should invoke proper number of times'); + deepEqual(found, ary.slice(0, -2), 'items passed during any() should match'); + }); + + suite.test('any should return true if any object matches the callback', function () { + var obj = _emberRuntimeSystemNative_array.A([0, 1, 2]); + var result = undefined; + + result = obj.any(function (i) { + return !!i; + }); + equal(result, true, 'return value of obj.any'); + }); + + suite.test('any should return false if no object matches the callback', function () { + var obj = _emberRuntimeSystemNative_array.A([0, null, false]); + var result = undefined; + + result = obj.any(function (i) { + return !!i; + }); + equal(result, false, 'return value of obj.any'); + }); + + suite.test('any should produce correct results even if the matching element is undefined', function () { + var obj = _emberRuntimeSystemNative_array.A([undefined]); + var result = undefined; + + result = obj.any(function (i) { + return true; + }); + equal(result, true, 'return value of obj.any'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/any.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/any.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/any.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/compact', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('compact'); + + suite.test('removes null and undefined values from enumerable', function () { + var obj = this.newObject([null, 1, false, '', undefined, 0, null]); + var ary = obj.compact(); + deepEqual(ary, [1, false, '', 0]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/compact.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/compact.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/compact.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/contains', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('contains'); + + suite.test('contains returns true if item is in enumerable', function () { + var data = this.newFixture(3); + var obj = this.newObject(data); + + expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); + equal(obj.contains(data[1]), true, 'should return true if contained'); + }); + + suite.test('contains returns false if item is not in enumerable', function () { + var data = this.newFixture(1); + var obj = this.newObject(this.newFixture(3)); + + expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); + equal(obj.contains(data[0]), false, 'should return false if not contained'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/contains.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/contains.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/contains.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/every', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // every() + // + + suite.module('every'); + + suite.test('every should should invoke callback on each item as long as you return true', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + var result = undefined; + + result = obj.every(function (i) { + found.push(i); + return true; + }); + equal(result, true, 'return value of obj.every'); + deepEqual(found, ary, 'items passed during every() should match'); + }); + + suite.test('every should stop invoking when you return false', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var exp = cnt; + var found = []; + var result = undefined; + + result = obj.every(function (i) { + found.push(i); + return --cnt > 0; + }); + equal(result, false, 'return value of obj.every'); + equal(found.length, exp, 'should invoke proper number of times'); + deepEqual(found, ary.slice(0, -2), 'items passed during every() should match'); + }); + + // .......................................................... + // isEvery() + // + + suite.module('isEvery'); + + suite.test('should return true of every property matches', function () { + var obj = this.newObject([{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]); + + equal(obj.isEvery('foo', 'foo'), true, 'isEvery(foo)'); + equal(obj.isEvery('bar', 'bar'), false, 'isEvery(bar)'); + }); + + suite.test('should return true of every property is true', function () { + var obj = this.newObject([{ foo: 'foo', bar: true }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: false })]); + + // different values - all eval to true + equal(obj.isEvery('foo'), true, 'isEvery(foo)'); + equal(obj.isEvery('bar'), false, 'isEvery(bar)'); + }); + + suite.test('should return true if every property matches null', function () { + var obj = this.newObject([{ foo: null, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: null, bar: null })]); + + equal(obj.isEvery('foo', null), true, 'isEvery(\'foo\', null)'); + equal(obj.isEvery('bar', null), false, 'isEvery(\'bar\', null)'); + }); + + suite.test('should return true if every property is undefined', function () { + var obj = this.newObject([{ foo: undefined, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ bar: undefined })]); + + equal(obj.isEvery('foo', undefined), true, 'isEvery(\'foo\', undefined)'); + equal(obj.isEvery('bar', undefined), false, 'isEvery(\'bar\', undefined)'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/every.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/every.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/every.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/filter', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // filter() + // + + suite.module('filter'); + + suite.test('filter should invoke on each item', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var found = []; + var result = undefined; + + // return true on all but the last two + result = obj.filter(function (i) { + found.push(i); + return --cnt >= 0; + }); + deepEqual(found, ary, 'should have invoked on each item'); + deepEqual(result, ary.slice(0, -2), 'filtered array should exclude items'); + }); + + // .......................................................... + // filterBy() + // + + suite.module('filterBy'); + + suite.test('should filter based on object', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', 'foo'), ary, 'filterBy(foo)'); + deepEqual(obj.filterBy('bar', 'bar'), [ary[1]], 'filterBy(bar)'); + }); + + suite.test('should include in result if property is true', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: 'foo', bar: true }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: false })]; + + obj = this.newObject(ary); + + // different values - all eval to true + deepEqual(obj.filterBy('foo'), ary, 'filterBy(foo)'); + deepEqual(obj.filterBy('bar'), [ary[0]], 'filterBy(bar)'); + }); + + suite.test('should filter on second argument if provided', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 }), { name: 'obj3', foo: 2 }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', 3), [ary[0], ary[3]], 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should correctly filter null second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: null }), { name: 'obj3', foo: null }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', null), [ary[1], ary[2]], 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should not return all objects on undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', undefined), [], 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should correctly filter explicit undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo', undefined), ary.slice(2), 'filterBy(\'foo\', 3)\')'); + }); + + suite.test('should not match undefined properties without second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' })]; + + obj = this.newObject(ary); + + deepEqual(obj.filterBy('foo'), ary.slice(0, 2), 'filterBy(\'foo\', 3)\')'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/filter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/filter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/filter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/find', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + // .......................................................... + // find() + // + + suite.module('find'); + + suite.test('find should invoke callback on each item as long as you return false', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + var result = undefined; + + result = obj.find(function (i) { + found.push(i); + return false; + }); + equal(result, undefined, 'return value of obj.find'); + deepEqual(found, ary, 'items passed during find() should match'); + }); + + suite.test('every should stop invoking when you return true', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var cnt = ary.length - 2; + var exp = cnt; + var found = []; + var result = undefined; + + result = obj.find(function (i) { + found.push(i); + return --cnt >= 0; + }); + equal(result, ary[exp - 1], 'return value of obj.find'); + equal(found.length, exp, 'should invoke proper number of times'); + deepEqual(found, ary.slice(0, -2), 'items passed during find() should match'); + }); + + // .......................................................... + // findBy() + // + + suite.module('findBy'); + + suite.test('should return first object of property matches', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]; + + obj = this.newObject(ary); + + equal(obj.findBy('foo', 'foo'), ary[0], 'findBy(foo)'); + equal(obj.findBy('bar', 'bar'), ary[1], 'findBy(bar)'); + }); + + suite.test('should return first object with truthy prop', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: 'foo', bar: false }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: true })]; + + obj = this.newObject(ary); + + // different values - all eval to true + equal(obj.findBy('foo'), ary[0], 'findBy(foo)'); + equal(obj.findBy('bar'), ary[1], 'findBy(bar)'); + }); + + suite.test('should return first null property match', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: null, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: null, bar: null })]; + + obj = this.newObject(ary); + + equal(obj.findBy('foo', null), ary[0], 'findBy(\'foo\', null)'); + equal(obj.findBy('bar', null), ary[1], 'findBy(\'bar\', null)'); + }); + + suite.test('should return first undefined property match', function () { + var ary = undefined, + obj = undefined; + + ary = [{ foo: undefined, bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({})]; + + obj = this.newObject(ary); + + equal(obj.findBy('foo', undefined), ary[0], 'findBy(\'foo\', undefined)'); + equal(obj.findBy('bar', undefined), ary[1], 'findBy(\'bar\', undefined)'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/find.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/find.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/find.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/firstObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('firstObject'); + + suite.test('returns first item in enumerable', function () { + var obj = this.newObject(); + equal(_emberMetal.get(obj, 'firstObject'), this.toArray(obj)[0]); + }); + + suite.test('returns undefined if enumerable is empty', function () { + var obj = this.newObject([]); + equal(_emberMetal.get(obj, 'firstObject'), undefined); + }); + + suite.test('can not be set', function () { + var obj = this.newObject([]); + + equal(_emberMetal.get(obj, 'firstObject'), this.toArray(obj)[0]); + + throws(function () { + _emberMetal.set(obj, 'firstObject', 'foo!'); + }, /Cannot set read-only property "firstObject" on object/); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/firstObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/firstObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/firstObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/forEach', ['exports', 'ember-utils', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('forEach'); + + suite.test('forEach should iterate over list', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + + obj.forEach(function (i) { + return found.push(i); + }); + deepEqual(found, ary, 'items passed during forEach should match'); + }); + + suite.test('forEach should iterate over list after mutation', function () { + if (_emberMetal.get(this, 'canTestMutation')) { + expect(0); + return; + } + + var obj = this.newObject(); + var ary = this.toArray(obj); + var found = []; + + obj.forEach(function (i) { + return found.push(i); + }); + deepEqual(found, ary, 'items passed during forEach should match'); + + this.mutate(obj); + ary = this.toArray(obj); + found = []; + + obj.forEach(function (i) { + return found.push(i); + }); + deepEqual(found, ary, 'items passed during forEach should match'); + }); + + suite.test('2nd target parameter', function () { + var _this = this; + + var obj = this.newObject(); + var target = this; + + obj.forEach(function () { + // ES6TODO: When transpiled we will end up with "use strict" which disables automatically binding to the global context. + // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to + // use `Ember.lookup` if target is not specified. + // + // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context'); + }); + + obj.forEach(function () { + equal(_emberUtils.guidFor(_this), _emberUtils.guidFor(target), 'should pass target as this if context'); + }, target); + }); + + suite.test('callback params', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var loc = 0; + + obj.forEach(function (item, idx, enumerable) { + equal(item, ary[loc], 'item param'); + equal(idx, loc, 'idx param'); + equal(_emberUtils.guidFor(enumerable), _emberUtils.guidFor(obj), 'enumerable param'); + loc++; + }); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/forEach.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/forEach.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/forEach.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/includes', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('includes'); + + suite.test('includes returns true if item is in enumerable', function () { + var data = this.newFixture(1); + var obj = this.newObject([].concat(data, [NaN, undefined, null])); + + equal(obj.includes(data[0]), true, 'should return true if included'); + equal(obj.includes(NaN), true, 'should return true if NaN included'); + equal(obj.includes(undefined), true, 'should return true if undefined included'); + equal(obj.includes(null), true, 'should return true if null included'); + }); + + suite.test('includes returns false if item is not in enumerable', function () { + var data = this.newFixture(1); + var obj = this.newObject([].concat(this.newFixture(3), [null])); + + equal(obj.includes(data[0]), false, 'should return false if not included'); + equal(obj.includes(undefined), false, 'should return false if undefined not included but null is included'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/includes.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/includes.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/includes.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/invoke', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('invoke'); + + suite.test('invoke should call on each object that implements', function () { + var cnt = undefined, + ary = undefined, + obj = undefined; + + function F(amt) { + cnt += amt === undefined ? 1 : amt; + } + cnt = 0; + ary = [{ foo: F }, _emberRuntimeSystemObject.default.create({ foo: F }), + + // NOTE: does not impl foo - invoke should just skip + _emberRuntimeSystemObject.default.create({ bar: F }), { foo: F }]; + + obj = this.newObject(ary); + obj.invoke('foo'); + equal(cnt, 3, 'should have invoked 3 times'); + + cnt = 0; + obj.invoke('foo', 2); + equal(cnt, 6, 'should have invoked 3 times, passing param'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/invoke.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/invoke.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/invoke.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/is_any', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // isAny() + // + + suite.module('isAny'); + + suite.test('should return true of any property matches', function () { + var obj = this.newObject([{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]); + + equal(obj.isAny('foo', 'foo'), true, 'isAny(foo)'); + equal(obj.isAny('bar', 'bar'), true, 'isAny(bar)'); + equal(obj.isAny('bar', 'BIFF'), false, 'isAny(BIFF)'); + }); + + suite.test('should return true of any property is true', function () { + var obj = this.newObject([{ foo: 'foo', bar: true }, _emberRuntimeSystemObject.default.create({ foo: 'bar', bar: false })]); + + // different values - all eval to true + equal(obj.isAny('foo'), true, 'isAny(foo)'); + equal(obj.isAny('bar'), true, 'isAny(bar)'); + equal(obj.isAny('BIFF'), false, 'isAny(biff)'); + }); + + suite.test('should return true if any property matches null', function () { + var obj = this.newObject([{ foo: null, bar: 'bar' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: null })]); + + equal(obj.isAny('foo', null), true, 'isAny(\'foo\', null)'); + equal(obj.isAny('bar', null), true, 'isAny(\'bar\', null)'); + }); + + suite.test('should return true if any property is undefined', function () { + var obj = this.newObject([{ foo: undefined, bar: 'bar' }, _emberRuntimeSystemObject.default.create({ foo: 'foo' })]); + + equal(obj.isAny('foo', undefined), true, 'isAny(\'foo\', undefined)'); + equal(obj.isAny('bar', undefined), true, 'isAny(\'bar\', undefined)'); + }); + + suite.test('should not match undefined properties without second argument', function () { + var obj = this.newObject([{ foo: undefined }, _emberRuntimeSystemObject.default.create({})]); + + equal(obj.isAny('foo'), false, 'isAny(\'foo\', undefined)'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/is_any.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/is_any.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/is_any.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/lastObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('lastObject'); + + suite.test('returns last item in enumerable', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + + equal(_emberMetal.get(obj, 'lastObject'), ary[ary.length - 1]); + }); + + suite.test('returns undefined if enumerable is empty', function () { + var obj = this.newObject([]); + + equal(_emberMetal.get(obj, 'lastObject'), undefined); + }); + + suite.test('can not be set', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + + equal(_emberMetal.get(obj, 'lastObject'), ary[ary.length - 1]); + + throws(function () { + _emberMetal.set(obj, 'lastObject', 'foo!'); + }, /Cannot set read-only property "lastObject" on object/); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/lastObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/lastObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/lastObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/map', ['exports', 'ember-utils', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('map'); + + var mapFunc = function (item) { + return item ? item.toString() : null; + }; + + suite.test('map should iterate over list', function () { + var obj = this.newObject(); + var ary = this.toArray(obj).map(mapFunc); + var found = []; + + found = obj.map(mapFunc); + deepEqual(found, ary, 'mapped arrays should match'); + }); + + suite.test('map should iterate over list after mutation', function () { + if (_emberMetal.get(this, 'canTestMutation')) { + expect(0); + return; + } + + var obj = this.newObject(); + var ary = this.toArray(obj).map(mapFunc); + var found = undefined; + + found = obj.map(mapFunc); + deepEqual(found, ary, 'items passed during forEach should match'); + + this.mutate(obj); + ary = this.toArray(obj).map(mapFunc); + found = obj.map(mapFunc); + deepEqual(found, ary, 'items passed during forEach should match'); + }); + + suite.test('2nd target parameter', function () { + var _this = this; + + var obj = this.newObject(); + var target = this; + + obj.map(function () { + // ES6TODO: When transpiled we will end up with "use strict" which disables automatically binding to the global context. + // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to + // use `Ember.lookup` if target is not specified. + // + // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context'); + }); + + obj.map(function () { + equal(_emberUtils.guidFor(_this), _emberUtils.guidFor(target), 'should pass target as this if context'); + }, target); + }); + + suite.test('callback params', function () { + var obj = this.newObject(); + var ary = this.toArray(obj); + var loc = 0; + + obj.map(function (item, idx, enumerable) { + equal(item, ary[loc], 'item param'); + equal(idx, loc, 'idx param'); + equal(_emberUtils.guidFor(enumerable), _emberUtils.guidFor(obj), 'enumerable param'); + loc++; + }); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/map.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/map.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/map.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/mapBy', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('mapBy'); + + suite.test('get value of each property', function () { + var obj = this.newObject([{ a: 1 }, { a: 2 }]); + equal(obj.mapBy('a').join(''), '12'); + }); + + suite.test('should work also through getEach alias', function () { + var obj = this.newObject([{ a: 1 }, { a: 2 }]); + equal(obj.getEach('a').join(''), '12'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/mapBy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/mapBy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/mapBy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/reduce', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('reduce'); + + suite.test('collects a summary value from an enumeration', function () { + var obj = this.newObject([1, 2, 3]); + var res = obj.reduce(function (previousValue, item, index, enumerable) { + return previousValue + item; + }, 0); + equal(res, 6); + }); + + suite.test('passes index of item to callback', function () { + var obj = this.newObject([1, 2, 3]); + var res = obj.reduce(function (previousValue, item, index, enumerable) { + return previousValue + index; + }, 0); + equal(res, 3); + }); + + suite.test('passes enumerable object to callback', function () { + var obj = this.newObject([1, 2, 3]); + var res = obj.reduce(function (previousValue, item, index, enumerable) { + return enumerable; + }, 0); + equal(res, obj); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/reduce.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/reduce.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/reduce.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/reject', ['exports', 'ember-runtime/system/object', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeSystemObject, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + // .......................................................... + // reject() + // + + suite.module('reject'); + + suite.test('should reject any item that does not meet the condition', function () { + var obj = this.newObject([1, 2, 3, 4]); + var result = undefined; + + result = obj.reject(function (i) { + return i < 3; + }); + deepEqual(result, [3, 4], 'reject the correct items'); + }); + + suite.test('should be the inverse of filter', function () { + var obj = this.newObject([1, 2, 3, 4]); + var isEven = function (i) { + return i % 2 === 0; + }; + var filtered = undefined, + rejected = undefined; + + filtered = obj.filter(isEven); + rejected = obj.reject(isEven); + + deepEqual(filtered, [2, 4], 'filtered evens'); + deepEqual(rejected, [1, 3], 'rejected evens'); + }); + + // .......................................................... + // rejectBy() + // + + suite.module('rejectBy'); + + suite.test('should reject based on object', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: 'foo', bar: 'BAZ' }, _emberRuntimeSystemObject.default.create({ foo: 'foo', bar: 'bar' })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', 'foo'), [], 'rejectBy(foo)'); + deepEqual(obj.rejectBy('bar', 'bar'), [ary[0]], 'rejectBy(bar)'); + }); + + suite.test('should include in result if property is false', function () { + var obj = undefined, + ary = undefined; + + ary = [{ foo: false, bar: true }, _emberRuntimeSystemObject.default.create({ foo: false, bar: false })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo'), ary, 'rejectBy(foo)'); + deepEqual(obj.rejectBy('bar'), [ary[1]], 'rejectBy(bar)'); + }); + + suite.test('should reject on second argument if provided', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 }), { name: 'obj3', foo: 2 }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', 3), [ary[1], ary[2]], 'rejectBy(\'foo\', 3)\')'); + }); + + suite.test('should correctly reject null second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: null }), { name: 'obj3', foo: null }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: 3 })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', null), [ary[0], ary[3]], 'rejectBy(\'foo\', null)\')'); + }); + + suite.test('should correctly reject undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 2 })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('bar', undefined), [], 'rejectBy(\'bar\', undefined)\')'); + }); + + suite.test('should correctly reject explicit undefined second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo', undefined), ary.slice(0, 2), 'rejectBy(\'foo\', undefined)\')'); + }); + + suite.test('should match undefined, null, or false properties without second argument', function () { + var obj = undefined, + ary = undefined; + + ary = [{ name: 'obj1', foo: 3 }, _emberRuntimeSystemObject.default.create({ name: 'obj2', foo: 3 }), { name: 'obj3', foo: undefined }, _emberRuntimeSystemObject.default.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, _emberRuntimeSystemObject.default.create({ name: 'obj6' }), { name: 'obj7', foo: null }, _emberRuntimeSystemObject.default.create({ name: 'obj8', foo: null }), { name: 'obj9', foo: false }, _emberRuntimeSystemObject.default.create({ name: 'obj10', foo: false })]; + + obj = this.newObject(ary); + + deepEqual(obj.rejectBy('foo'), ary.slice(2), 'rejectBy(\'foo\')\')'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/reject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/reject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/reject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/sortBy', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('sortBy'); + + suite.test('sort by value of property', function () { + var obj = this.newObject([{ a: 2 }, { a: 1 }]); + var sorted = obj.sortBy('a'); + + equal(_emberMetal.get(sorted[0], 'a'), 1); + equal(_emberMetal.get(sorted[1], 'a'), 2); + }); + + suite.test('supports multiple propertyNames', function () { + var obj = this.newObject([{ a: 1, b: 2 }, { a: 1, b: 1 }]); + var sorted = obj.sortBy('a', 'b'); + + equal(_emberMetal.get(sorted[0], 'b'), 1); + equal(_emberMetal.get(sorted[1], 'b'), 2); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/sortBy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/sortBy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/sortBy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/toArray', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('toArray'); + + suite.test('toArray should convert to an array', function () { + var obj = this.newObject(); + deepEqual(obj.toArray(), this.toArray(obj)); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/toArray.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/toArray.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/toArray.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/uniq', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('uniq'); + + suite.test('should return new instance with duplicates removed', function () { + var before = undefined, + after = undefined, + obj = undefined, + ret = undefined; + + after = this.newFixture(3); + before = [after[0], after[1], after[2], after[1], after[0]]; + obj = this.newObject(before); + before = obj.toArray(); // in case of set before will be different... + + ret = obj.uniq(); + deepEqual(this.toArray(ret), after, 'should have removed item'); + deepEqual(this.toArray(obj), before, 'should not have changed original'); + }); + + suite.test('should return duplicate of same content if no duplicates found', function () { + var item = undefined, + obj = undefined, + ret = undefined; + obj = this.newObject(this.newFixture(3)); + ret = obj.uniq(item); + ok(ret !== obj, 'should not be same object'); + deepEqual(this.toArray(ret), this.toArray(obj), 'should be the same content'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/uniq.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/uniq.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/uniq.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/uniqBy', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('uniqBy'); + + suite.test('should return new instance with duplicates removed', function () { + var numbers = this.newObject([{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 1, value: 'one' }]); + deepEqual(numbers.uniqBy('id'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/uniqBy.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/uniqBy.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/uniqBy.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/enumerable/without', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('without'); + + suite.test('should return new instance with item removed', function () { + var before = undefined, + after = undefined, + obj = undefined, + ret = undefined; + + before = this.newFixture(3); + after = [before[0], before[2]]; + obj = this.newObject(before); + + ret = obj.without(before[1]); + deepEqual(this.toArray(ret), after, 'should have removed item'); + deepEqual(this.toArray(obj), before, 'should not have changed original'); + }); + + suite.test('should remove NaN value', function () { + var before = undefined, + after = undefined, + obj = undefined, + ret = undefined; + + before = [].concat(this.newFixture(2), [NaN]); + after = [before[0], before[1]]; + obj = this.newObject(before); + + ret = obj.without(NaN); + deepEqual(this.toArray(ret), after, 'should have removed item'); + }); + + suite.test('should return same instance if object not found', function () { + var item = undefined, + obj = undefined, + ret = undefined; + + item = this.newFixture(1)[0]; + obj = this.newObject(this.newFixture(3)); + + ret = obj.without(item); + equal(ret, obj, 'should be same instance'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/enumerable/without.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/enumerable/without.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/enumerable/without.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array', ['exports', 'ember-runtime/tests/suites/array', 'ember-runtime/tests/suites/mutable_array/insertAt', 'ember-runtime/tests/suites/mutable_array/popObject', 'ember-runtime/tests/suites/mutable_array/pushObject', 'ember-runtime/tests/suites/mutable_array/pushObjects', 'ember-runtime/tests/suites/mutable_array/removeAt', 'ember-runtime/tests/suites/mutable_array/replace', 'ember-runtime/tests/suites/mutable_array/shiftObject', 'ember-runtime/tests/suites/mutable_array/unshiftObject', 'ember-runtime/tests/suites/mutable_array/reverseObjects'], function (exports, _emberRuntimeTestsSuitesArray, _emberRuntimeTestsSuitesMutable_arrayInsertAt, _emberRuntimeTestsSuitesMutable_arrayPopObject, _emberRuntimeTestsSuitesMutable_arrayPushObject, _emberRuntimeTestsSuitesMutable_arrayPushObjects, _emberRuntimeTestsSuitesMutable_arrayRemoveAt, _emberRuntimeTestsSuitesMutable_arrayReplace, _emberRuntimeTestsSuitesMutable_arrayShiftObject, _emberRuntimeTestsSuitesMutable_arrayUnshiftObject, _emberRuntimeTestsSuitesMutable_arrayReverseObjects) { + 'use strict'; + + var MutableArrayTests = _emberRuntimeTestsSuitesArray.ArrayTests.extend(); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayInsertAt.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayPopObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayPushObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayPushObjects.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayRemoveAt.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayReplace.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayShiftObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayUnshiftObject.default); + MutableArrayTests.importModuleTests(_emberRuntimeTestsSuitesMutable_arrayReverseObjects.default); + + exports.default = MutableArrayTests; +}); +enifed('ember-runtime/tests/suites/mutable_array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/addObject', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('addObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + equal(obj.addObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B].addObject(C) => [A,B,C] + notify', function () { + var before = this.newFixture(2); + var item = this.newFixture(1)[0]; + var after = [before[0], before[1], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.addObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + } + }); + + suite.test('[A,B,C].addObject(A) => [A,B,C] + NO notify', function () { + var before = this.newFixture(3); + var after = before; + var item = before[0]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.addObject(item); // note: item in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('@each'), false, 'should NOT have notified @each'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + } + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/addObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/addObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/addObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/clear', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('clear'); + + suite.test('[].clear() => [] + notify', function () { + var before = []; + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.clear(), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.validate('[]'), false, 'should NOT have notified [] once'); + equal(observer.validate('@each'), false, 'should NOT have notified @each once'); + equal(observer.validate('length'), false, 'should NOT have notified length once'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[X].clear() => [] + notify', function () { + var obj, before, after, observer; + + before = this.newFixture(1); + after = []; + obj = this.newObject(before); + observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.clear(), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/clear.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/clear.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/clear.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/insertAt', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('insertAt'); + + suite.test('[].insertAt(0, X) => [X] + notify', function () { + var after = this.newFixture(1); + var obj = this.newObject([]); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(0, after[0]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] did change once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each did change once'); + equal(observer.timesCalled('length'), 1, 'should have notified length did change once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject did change once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject did change once'); + }); + + suite.test('[].insertAt(200,X) => OUT_OF_RANGE_EXCEPTION exception', function () { + var obj = this.newObject([]); + var that = this; + + throws(function () { + return obj.insertAt(200, that.newFixture(1)[0]); + }, Error); + }); + + suite.test('[A].insertAt(0, X) => [X,A] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(1); + var after = [item, before[0]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(0, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A].insertAt(1, X) => [A,X] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(1); + var after = [before[0], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(1, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + suite.test('[A].insertAt(200,X) => OUT_OF_RANGE exception', function () { + var obj = this.newObject(this.newFixture(1)); + var that = this; + + throws(function () { + return obj.insertAt(200, that.newFixture(1)[0]); + }, Error); + }); + + suite.test('[A,B,C].insertAt(0,X) => [X,A,B,C] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(3); + var after = [item, before[0], before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(0, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].insertAt(1,X) => [A,X,B,C] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(3); + var after = [before[0], item, before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(1, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].insertAt(3,X) => [A,B,C,X] + notify', function () { + var item = this.newFixture(1)[0]; + var before = this.newFixture(3); + var after = [before[0], before[1], before[2], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.insertAt(3, item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once'); + equal(observer.timesCalledBefore('@each'), 0, 'should not have notified @each will change once'); + equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once'); + equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once'); + equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/insertAt.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/insertAt.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/insertAt.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/popObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('popObject'); + + suite.test('[].popObject() => [] + returns undefined + NO notify', function () { + var obj = this.newObject([]); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.popObject(), undefined, 'popObject results'); + + deepEqual(this.toArray(obj), [], 'post item results'); + + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('@each'), false, 'should NOT have notified @each'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[X].popObject() => [] + notify', function () { + var before = this.newFixture(1); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + var ret = obj.popObject(); + + equal(ret, before[0], 'return object'); + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].popObject() => [A,B] + notify', function () { + var before = this.newFixture(3); + var after = [before[0], before[1]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + var ret = obj.popObject(); + + equal(ret, before[2], 'return object'); + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/popObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/popObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/popObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('pushObject'); + + suite.test('returns pushed object', function () { + var exp = this.newFixture(1)[0]; + var obj = this.newObject([]); + + equal(obj.pushObject(exp), exp, 'should return pushed object'); + }); + + suite.test('[].pushObject(X) => [X] + notify', function () { + var before = []; + var after = this.newFixture(1); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.pushObject(after[0]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].pushObject(X) => [A,B,C,X] + notify', function () { + var before = this.newFixture(3); + var item = this.newFixture(1)[0]; + var after = [before[0], before[1], before[2], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.pushObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/pushObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/pushObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObjects', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('pushObjects'); + + suite.test('should raise exception if not Ember.Enumerable is passed to pushObjects', function () { + var obj = this.newObject([]); + + throws(function () { + return obj.pushObjects('string'); + }); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/pushObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/pushObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/pushObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/removeAt', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal', 'ember-runtime/mixins/mutable_array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal, _emberRuntimeMixinsMutable_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeAt'); + + suite.test('removeAt([X], 0) => [] + notify', function () { + var before = this.newFixture(1); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 0), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('removeAt([], 200) => OUT_OF_RANGE_EXCEPTION exception', function () { + var obj = this.newObject([]); + throws(function () { + return _emberRuntimeMixinsMutable_array.removeAt(obj, 200); + }, Error); + }); + + suite.test('removeAt([A,B], 0) => [B] + notify', function () { + var before = this.newFixture(2); + var after = [before[1]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 0), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('removeAt([A,B], 1) => [A] + notify', function () { + var before = this.newFixture(2); + var after = [before[0]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 1), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + }); + + suite.test('removeAt([A,B,C], 1) => [A,C] + notify', function () { + var before = this.newFixture(3); + var after = [before[0], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 1), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('removeAt([A,B,C,D], 1,2) => [A,D] + notify', function () { + var before = this.newFixture(4); + var after = [before[0], before[3]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(_emberRuntimeMixinsMutable_array.removeAt(obj, 1, 2), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B,C,D].removeAt(1,2) => [A,D] + notify', function () { + var obj, before, after, observer; + + before = this.newFixture(4); + after = [before[0], before[3]]; + obj = this.newObject(before); + observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.removeAt(1, 2), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/removeAt.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/removeAt.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/removeAt.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/removeObject', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + + equal(obj.removeObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function () { + var before = this.newFixture(3); + var after = [before[0], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.removeObject(before[1]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + } + }); + + suite.test('[A,B,C].removeObject(D) => [A,B,C]', function () { + var before = this.newFixture(3); + var after = before; + var item = this.newFixture(1)[0]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.removeObject(item); // note: item not in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('@each'), false, 'should NOT have notified @each'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + } + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/removeObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/removeObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/removeObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/replace', ['exports', 'ember-runtime/tests/suites/suite'], function (exports, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('replace'); + + suite.test('[].replace(0,0,\'X\') => [\'X\'] + notify', function () { + var exp = this.newFixture(1); + var obj = this.newObject([]); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(0, 0, exp); + + deepEqual(this.toArray(obj), exp, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[].replace(0,0,"X") => ["X"] + avoid calling objectAt and notifying fistObject/lastObject when not in cache', function () { + var obj, exp, observer; + var called = 0; + exp = this.newFixture(1); + obj = this.newObject([]); + obj.objectAt = function () { + called++; + }; + observer = this.newObserver(obj, 'firstObject', 'lastObject'); + + obj.replace(0, 0, exp); + + equal(called, 0, 'should NOT have called objectAt upon replace when firstObject/lastObject are not cached'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject since not cached'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject since not cached'); + }); + + suite.test('[A,B,C,D].replace(1,2,X) => [A,X,D] + notify', function () { + var before = this.newFixture(4); + var replace = this.newFixture(1); + var after = [before[0], replace[0], before[3]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(1, 2, replace); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B,C,D].replace(1,2,[X,Y]) => [A,X,Y,D] + notify', function () { + var before = this.newFixture(4); + var replace = this.newFixture(2); + var after = [before[0], replace[0], replace[1], before[3]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(1, 2, replace); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B].replace(1,0,[X,Y]) => [A,X,Y,B] + notify', function () { + var before = this.newFixture(2); + var replace = this.newFixture(2); + var after = [before[0], replace[0], replace[1], before[1]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(1, 0, replace); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[A,B,C,D].replace(2,2) => [A,B] + notify', function () { + var before = this.newFixture(4); + var after = [before[0], before[1]]; + + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.replace(2, 2); + + deepEqual(this.toArray(obj), after, 'post item results'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + }); + + suite.test('Adding object should notify enumerable observer', function () { + var fixtures = this.newFixture(4); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = this.newFixture(1)[0]; + + obj.replace(2, 2, [item]); + + deepEqual(observer._before, [obj, [fixtures[2], fixtures[3]], 1], 'before'); + deepEqual(observer._after, [obj, 2, [item]], 'after'); + }); + + suite.test('Adding object should notify array observer', function () { + var fixtures = this.newFixture(4); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeArray(obj); + var item = this.newFixture(1)[0]; + + obj.replace(2, 2, [item]); + + deepEqual(observer._before, [obj, 2, 2, 1], 'before'); + deepEqual(observer._after, [obj, 2, 2, 1], 'after'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/replace.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/replace.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/replace.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/reverseObjects', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('reverseObjects'); + + suite.test('[A,B,C].reverseObjects() => [] + notify', function () { + var before = this.newFixture(3); + var after = [before[2], before[1], before[0]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.reverseObjects(), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 0, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/reverseObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/reverseObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/reverseObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/setObjects', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('setObjects'); + + suite.test('[A,B,C].setObjects([]) = > [] + notify', function () { + var before = this.newFixture(3); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.setObjects(after), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].setObjects([D, E, F, G]) = > [D, E, F, G] + notify', function () { + var before = this.newFixture(3); + var after = this.newFixture(4); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.setObjects(after), obj, 'return self'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/setObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/setObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/setObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/shiftObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('shiftObject'); + + suite.test('[].shiftObject() => [] + returns undefined + NO notify', function () { + var before = []; + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.shiftObject(), undefined); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.validate('[]', undefined, 1), false, 'should NOT have notified [] once'); + equal(observer.validate('@each', undefined, 1), false, 'should NOT have notified @each once'); + equal(observer.validate('length', undefined, 1), false, 'should NOT have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + suite.test('[X].shiftObject() => [] + notify', function () { + var before = this.newFixture(1); + var after = []; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.shiftObject(), before[0], 'should return object'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].shiftObject() => [B,C] + notify', function () { + var before = this.newFixture(3); + var after = [before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + equal(obj.shiftObject(), before[0], 'should return object'); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/shiftObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/shiftObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/shiftObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('unshiftObject'); + + suite.test('returns unshifted object', function () { + var obj = this.newObject([]); + var item = this.newFixture(1)[0]; + + equal(obj.unshiftObject(item), item, 'should return unshifted object'); + }); + + suite.test('[].unshiftObject(X) => [X] + notify', function () { + var before = []; + var item = this.newFixture(1)[0]; + var after = [item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].unshiftObject(X) => [X,A,B,C] + notify', function () { + var before = this.newFixture(3); + var item = this.newFixture(1)[0]; + var after = [item, before[0], before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].unshiftObject(A) => [A,A,B,C] + notify', function () { + var before = this.newFixture(3); + var item = before[0]; // note same object as current head. should end up twice + var after = [item, before[0], before[1], before[2]]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/unshiftObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/unshiftObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObjects', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('unshiftObjects'); + + suite.test('returns receiver', function () { + var obj = this.newObject([]); + var items = this.newFixture(3); + + equal(obj.unshiftObjects(items), obj, 'should return receiver'); + }); + + suite.test('[].unshiftObjects([A,B,C]) => [A,B,C] + notify', function () { + var before = []; + var items = this.newFixture(3); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObjects(items); + + deepEqual(this.toArray(obj), items, 'post item results'); + equal(_emberMetal.get(obj, 'length'), items.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + }); + + suite.test('[A,B,C].unshiftObjects([X,Y]) => [X,Y,A,B,C] + notify', function () { + var before = this.newFixture(3); + var items = this.newFixture(2); + var after = items.concat(before); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObjects(items); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + suite.test('[A,B,C].unshiftObjects([A,B]) => [A,B,A,B,C] + notify', function () { + var before = this.newFixture(3); + var items = [before[0], before[1]]; // note same object as current head. should end up twice + var after = items.concat(before); + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ + + obj.unshiftObjects(items); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_array/unshiftObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_array/unshiftObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_array/unshiftObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable', ['exports', 'ember-runtime/tests/suites/enumerable', 'ember-runtime/tests/suites/mutable_enumerable/addObject', 'ember-runtime/tests/suites/mutable_enumerable/removeObject', 'ember-runtime/tests/suites/mutable_enumerable/removeObjects'], function (exports, _emberRuntimeTestsSuitesEnumerable, _emberRuntimeTestsSuitesMutable_enumerableAddObject, _emberRuntimeTestsSuitesMutable_enumerableRemoveObject, _emberRuntimeTestsSuitesMutable_enumerableRemoveObjects) { + 'use strict'; + + var MutableEnumerableTests = _emberRuntimeTestsSuitesEnumerable.EnumerableTests.extend(); + MutableEnumerableTests.importModuleTests(_emberRuntimeTestsSuitesMutable_enumerableAddObject.default); + MutableEnumerableTests.importModuleTests(_emberRuntimeTestsSuitesMutable_enumerableRemoveObject.default); + MutableEnumerableTests.importModuleTests(_emberRuntimeTestsSuitesMutable_enumerableRemoveObjects.default); + + exports.default = MutableEnumerableTests; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/addObject', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('addObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + + equal(obj.addObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B].addObject(C) => [A,B,C] + notify', function () { + var before = this.newFixture(2); + var item = this.newFixture(1)[0]; + var after = [before[0], before[1], item]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + _emberMetal.get(obj, 'firstObject'); + _emberMetal.get(obj, 'lastObject'); + + obj.addObject(item); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); + // This gets called since MutableEnumerable is naive about changes + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); + } + }); + + suite.test('[A,B,C].addObject(A) => [A,B,C] + NO notify', function () { + var before = this.newFixture(3); + var after = before; + var item = before[0]; + var obj = this.newObject(before); + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.addObject(item); // note: item in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('Adding object should notify enumerable observer', function () { + var obj = this.newObject(this.newFixture(3)); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = this.newFixture(1)[0]; + + obj.addObject(item); + + deepEqual(observer._before, [obj, null, [item]]); + deepEqual(observer._after, [obj, null, [item]]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/addObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable/addObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable/addObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObject', ['exports', 'ember-metal', 'ember-runtime/tests/suites/suite', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeTestsSuitesSuite, _emberRuntimeSystemNative_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeObject'); + + suite.test('should return receiver', function () { + var before = this.newFixture(3); + var obj = this.newObject(before); + + equal(obj.removeObject(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = [before[0], before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObject(before[1]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObject(D) => [A,B,C]', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = before; + var item = this.newFixture(1)[0]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObject(item); // Note: item not in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('Removing object should notify enumerable observer', function () { + var fixtures = this.newFixture(3); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = fixtures[1]; + + obj.removeObject(item); + + deepEqual(observer._before, [obj, [item], null]); + deepEqual(observer._after, [obj, [item], null]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObject.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable/removeObject.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable/removeObject.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObjects', ['exports', 'ember-runtime/tests/suites/suite', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeTestsSuitesSuite, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + var suite = _emberRuntimeTestsSuitesSuite.SuiteModuleBuilder.create(); + + suite.module('removeObjects'); + + suite.test('should return receiver', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var obj = before; + + equal(obj.removeObjects(before[1]), obj, 'should return receiver'); + }); + + suite.test('[A,B,C].removeObjects([B]) => [A,C] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = [before[0], before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[{A},{B},{C}].removeObjects([{B}]) => [{A},{C}] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newObjectsFixture(3)); + var after = [before[0], before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObjects([A,B]) => [C] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = [before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[0], before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[{A},{B},{C}].removeObjects([{A},{B}]) => [{C}] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newObjectsFixture(3)); + var after = [before[2]]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[0], before[1]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObjects([A,B,C]) => [] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = []; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([before[0], before[1], before[2]]); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject'); + } + }); + + suite.test('[{A},{B},{C}].removeObjects([{A},{B},{C}]) => [] + notify', function () { + var before = _emberRuntimeSystemNative_array.A(this.newObjectsFixture(3)); + var after = []; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects(before); + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + equal(observer.timesCalled('length'), 1, 'should have notified length once'); + + equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + equal(observer.validate('lastObject'), 1, 'should have notified lastObject'); + } + }); + + suite.test('[A,B,C].removeObjects([D]) => [A,B,C]', function () { + var before = _emberRuntimeSystemNative_array.A(this.newFixture(3)); + var after = before; + var item = this.newFixture(1)[0]; + var obj = before; + var observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + + obj.getProperties('firstObject', 'lastObject'); // Prime the cache + + obj.removeObjects([item]); // Note: item not in set + + deepEqual(this.toArray(obj), after, 'post item results'); + equal(_emberMetal.get(obj, 'length'), after.length, 'length'); + + if (observer.isEnabled) { + equal(observer.validate('[]'), false, 'should NOT have notified []'); + equal(observer.validate('length'), false, 'should NOT have notified length'); + + equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); + equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject'); + } + }); + + suite.test('Removing objects should notify enumerable observer', function () { + var fixtures = this.newFixture(3); + var obj = this.newObject(fixtures); + var observer = this.newObserver(obj).observeEnumerable(obj); + var item = fixtures[1]; + + obj.removeObjects([item]); + + deepEqual(observer._before, [obj, [item], null]); + deepEqual(observer._after, [obj, [item], null]); + }); + + exports.default = suite; +}); +enifed('ember-runtime/tests/suites/mutable_enumerable/removeObjects.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/mutable_enumerable/removeObjects.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/mutable_enumerable/removeObjects.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/suites/suite', ['exports', 'ember-utils', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberUtils, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + /* + @class + A Suite can be used to define a reusable set of unit tests that can be + applied to any object. Suites are most useful for defining tests that + work against a mixin or plugin API. Developers implementing objects that + use the mixin or support the API can then run these tests against their + own code to verify compliance. + + To define a suite, you need to define the tests themselves as well as a + callback API implementers can use to tie your tests to their specific class. + + ## Defining a Callback API + + To define the callback API, just extend this class and add your properties + or methods that must be provided. + + ## Defining Unit Tests + + To add unit tests, use the suite.module() or suite.test() methods instead + of a regular module() or test() method when defining your tests. This will + add the tests to the suite. + + ## Using a Suite + + To use a Suite to test your own objects, extend the suite subclass and + define any required methods. Then call run() on the new subclass. This + will create an instance of your class and then defining the unit tests. + + @extends Ember.Object + @private + */ + var Suite = _emberRuntimeSystemObject.default.extend({ + + /* + __Required.__ You must implement this method to apply this mixin. + Define a name for these tests - all modules are prefixed w/ it. + @type String + */ + name: null, + + /* + Invoked to actually run the test - overridden by mixins + */ + run: function () {} + + }); + + Suite.reopenClass({ + + plan: null, + + run: function () { + var C = this; + return new C().run(); + }, + + module: function (desc, opts) { + if (!opts) { + opts = {}; + } + + var setup = opts.setup; + var teardown = opts.teardown; + this.reopen({ + run: function () { + this._super.apply(this, arguments); + var title = _emberMetal.get(this, 'name') + ': ' + desc; + var ctx = this; + QUnit.module(title, { + setup: function () { + if (setup) { + setup.call(ctx); + } + }, + + teardown: function () { + if (teardown) { + teardown.call(ctx); + } + } + }); + } + }); + }, + + test: function (name, func) { + this.reopen({ + run: function () { + this._super.apply(this, arguments); + var ctx = this; + + if (!func) { + QUnit.test(name); // output warning + } else { + QUnit.test(name, function () { + return func.call(ctx); + }); + } + } + }); + }, + + // convert to guids to minimize logging. + same: function (actual, exp, message) { + actual = actual && actual.map ? actual.map(function (x) { + return _emberUtils.guidFor(x); + }) : actual; + exp = exp && exp.map ? exp.map(function (x) { + return _emberUtils.guidFor(x); + }) : exp; + return deepEqual(actual, exp, message); + }, + + // easy way to disable tests + notest: function () {}, + + importModuleTests: function (builder) { + var _this = this; + + this.module(builder._module); + + builder._tests.forEach(function (descAndFunc) { + _this.test.apply(_this, descAndFunc); + }); + } + }); + + var SuiteModuleBuilder = _emberRuntimeSystemObject.default.extend({ + _module: null, + _tests: null, + + init: function () { + this._tests = []; + }, + + module: function (name) { + this._module = name; + }, + + test: function (name, func) { + this._tests.push([name, func]); + } + }); + + exports.SuiteModuleBuilder = SuiteModuleBuilder; + exports.Suite = Suite; + exports.default = Suite; +}); +enifed('ember-runtime/tests/suites/suite.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/suites/suite.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/suites/suite.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/application/base_test', ['exports', 'ember-runtime/system/namespace', 'ember-runtime/system/application'], function (exports, _emberRuntimeSystemNamespace, _emberRuntimeSystemApplication) { + 'use strict'; + + QUnit.module('Ember.Application'); + + QUnit.test('Ember.Application should be a subclass of Ember.Namespace', function () { + ok(_emberRuntimeSystemNamespace.default.detect(_emberRuntimeSystemApplication.default), 'Ember.Application subclass of Ember.Namespace'); + }); +}); +enifed('ember-runtime/tests/system/application/base_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/application/base_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/application/base_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/arranged_content_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array, _emberRuntimeMixinsArray) { + 'use strict'; + + var array = undefined; + + QUnit.module('ArrayProxy - arrangedContent', { + setup: function () { + _emberMetal.run(function () { + array = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContent: _emberMetal.computed('content.[]', function () { + var content = this.get('content'); + return content && _emberRuntimeSystemNative_array.A(content.slice().sort(function (a, b) { + if (a == null) { + a = -1; + } + if (b == null) { + b = -1; + } + return b - a; + })); + }) + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 4, 5]) + }); + }); + }, + teardown: function () { + _emberMetal.run(function () { + return array.destroy(); + }); + } + }); + + QUnit.test('addObject - adds to end of \'content\' if not present', function () { + _emberMetal.run(function () { + return array.addObject(3); + }); + + deepEqual(array.get('content'), [1, 2, 4, 5, 3], 'adds to end of content'); + deepEqual(array.get('arrangedContent'), [5, 4, 3, 2, 1], 'arrangedContent stays sorted'); + + _emberMetal.run(function () { + return array.addObject(1); + }); + + deepEqual(array.get('content'), [1, 2, 4, 5, 3], 'does not add existing number to content'); + }); + + QUnit.test('addObjects - adds to end of \'content\' if not present', function () { + _emberMetal.run(function () { + return array.addObjects([1, 3, 6]); + }); + + deepEqual(array.get('content'), [1, 2, 4, 5, 3, 6], 'adds to end of content'); + deepEqual(array.get('arrangedContent'), [6, 5, 4, 3, 2, 1], 'arrangedContent stays sorted'); + }); + + QUnit.test('compact - returns arrangedContent without nulls and undefined', function () { + _emberMetal.run(function () { + return array.set('content', _emberRuntimeSystemNative_array.A([1, 3, null, 2, undefined])); + }); + + deepEqual(array.compact(), [3, 2, 1]); + }); + + QUnit.test('indexOf - returns index of object in arrangedContent', function () { + equal(array.indexOf(4), 1, 'returns arranged index'); + }); + + QUnit.test('insertAt - raises, indeterminate behavior', function () { + throws(function () { + return _emberMetal.run(function () { + return array.insertAt(2, 3); + }); + }); + }); + + QUnit.test('lastIndexOf - returns last index of object in arrangedContent', function () { + _emberMetal.run(function () { + return array.pushObject(4); + }); + + equal(array.lastIndexOf(4), 2, 'returns last arranged index'); + }); + + QUnit.test('nextObject - returns object at index in arrangedContent', function () { + equal(array.nextObject(1), 4, 'returns object at index'); + }); + + QUnit.test('objectAt - returns object at index in arrangedContent', function () { + equal(_emberRuntimeMixinsArray.objectAt(array, 1), 4, 'returns object at index'); + }); + + // Not sure if we need a specific test for it, since it's internal + QUnit.test('objectAtContent - returns object at index in arrangedContent', function () { + equal(array.objectAtContent(1), 4, 'returns object at index'); + }); + + QUnit.test('objectsAt - returns objects at indices in arrangedContent', function () { + deepEqual(array.objectsAt([0, 2, 4]), [5, 2, undefined], 'returns objects at indices'); + }); + + QUnit.test('popObject - removes last object in arrangedContent', function () { + var popped = undefined; + _emberMetal.run(function () { + return popped = array.popObject(); + }); + equal(popped, 1, 'returns last object'); + deepEqual(array.get('content'), [2, 4, 5], 'removes from content'); + }); + + QUnit.test('pushObject - adds to end of content even if it already exists', function () { + _emberMetal.run(function () { + return array.pushObject(1); + }); + deepEqual(array.get('content'), [1, 2, 4, 5, 1], 'adds to end of content'); + }); + + QUnit.test('pushObjects - adds multiple to end of content even if it already exists', function () { + _emberMetal.run(function () { + return array.pushObjects([1, 2, 4]); + }); + deepEqual(array.get('content'), [1, 2, 4, 5, 1, 2, 4], 'adds to end of content'); + }); + + QUnit.test('removeAt - removes from index in arrangedContent', function () { + _emberMetal.run(function () { + return array.removeAt(1, 2); + }); + deepEqual(array.get('content'), [1, 5]); + }); + + QUnit.test('removeObject - removes object from content', function () { + _emberMetal.run(function () { + return array.removeObject(2); + }); + deepEqual(array.get('content'), [1, 4, 5]); + }); + + QUnit.test('removeObjects - removes objects from content', function () { + _emberMetal.run(function () { + return array.removeObjects([2, 4, 6]); + }); + deepEqual(array.get('content'), [1, 5]); + }); + + QUnit.test('replace - raises, indeterminate behavior', function () { + throws(function () { + return _emberMetal.run(function () { + return array.replace(1, 2, [3]); + }); + }); + }); + + QUnit.test('replaceContent - does a standard array replace on content', function () { + _emberMetal.run(function () { + return array.replaceContent(1, 2, [3]); + }); + deepEqual(array.get('content'), [1, 3, 5]); + }); + + QUnit.test('reverseObjects - raises, use Sortable#sortAscending', function () { + throws(function () { + return _emberMetal.run(function () { + return array.reverseObjects(); + }); + }); + }); + + QUnit.test('setObjects - replaces entire content', function () { + _emberMetal.run(function () { + return array.setObjects([6, 7, 8]); + }); + deepEqual(array.get('content'), [6, 7, 8], 'replaces content'); + }); + + QUnit.test('shiftObject - removes from start of arrangedContent', function () { + var shifted = _emberMetal.run(function () { + return array.shiftObject(); + }); + + equal(shifted, 5, 'returns first object'); + deepEqual(array.get('content'), [1, 2, 4], 'removes object from content'); + }); + + QUnit.test('slice - returns a slice of the arrangedContent', function () { + deepEqual(array.slice(1, 3), [4, 2], 'returns sliced arrangedContent'); + }); + + QUnit.test('toArray - returns copy of arrangedContent', function () { + deepEqual(array.toArray(), [5, 4, 2, 1]); + }); + + QUnit.test('unshiftObject - adds to start of content', function () { + _emberMetal.run(function () { + return array.unshiftObject(6); + }); + deepEqual(array.get('content'), [6, 1, 2, 4, 5], 'adds to start of content'); + }); + + QUnit.test('unshiftObjects - adds to start of content', function () { + _emberMetal.run(function () { + array.unshiftObjects([6, 7]); + }); + deepEqual(array.get('content'), [6, 7, 1, 2, 4, 5], 'adds to start of content'); + }); + + QUnit.test('without - returns arrangedContent without object', function () { + deepEqual(array.without(2), [5, 4, 1], 'returns arranged without object'); + }); + + QUnit.test('lastObject - returns last arranged object', function () { + equal(array.get('lastObject'), 1, 'returns last arranged object'); + }); + + QUnit.test('firstObject - returns first arranged object', function () { + equal(array.get('firstObject'), 5, 'returns first arranged object'); + }); + + QUnit.module('ArrayProxy - arrangedContent matching content', { + setup: function () { + _emberMetal.run(function () { + array = _emberRuntimeSystemArray_proxy.default.create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 4, 5]) + }); + }); + }, + teardown: function () { + _emberMetal.run(function () { + array.destroy(); + }); + } + }); + + QUnit.test('insertAt - inserts object at specified index', function () { + _emberMetal.run(function () { + array.insertAt(2, 3); + }); + deepEqual(array.get('content'), [1, 2, 3, 4, 5]); + }); + + QUnit.test('replace - does a standard array replace', function () { + _emberMetal.run(function () { + array.replace(1, 2, [3]); + }); + deepEqual(array.get('content'), [1, 3, 5]); + }); + + QUnit.test('reverseObjects - reverses content', function () { + _emberMetal.run(function () { + array.reverseObjects(); + }); + deepEqual(array.get('content'), [5, 4, 2, 1]); + }); + + QUnit.module('ArrayProxy - arrangedContent with transforms', { + setup: function () { + _emberMetal.run(function () { + array = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContent: _emberMetal.computed(function () { + var content = this.get('content'); + return content && _emberRuntimeSystemNative_array.A(content.slice().sort(function (a, b) { + if (a == null) { + a = -1; + } + if (b == null) { + b = -1; + } + return b - a; + })); + }).property('content.[]'), + + objectAtContent: function (idx) { + var obj = _emberRuntimeMixinsArray.objectAt(this.get('arrangedContent'), idx); + return obj && obj.toString(); + } + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 4, 5]) + }); + }); + }, + teardown: function () { + _emberMetal.run(function () { + array.destroy(); + }); + } + }); + + QUnit.test('indexOf - returns index of object in arrangedContent', function () { + equal(array.indexOf('4'), 1, 'returns arranged index'); + }); + + QUnit.test('lastIndexOf - returns last index of object in arrangedContent', function () { + _emberMetal.run(function () { + array.pushObject(4); + }); + equal(array.lastIndexOf('4'), 2, 'returns last arranged index'); + }); + + QUnit.test('nextObject - returns object at index in arrangedContent', function () { + equal(array.nextObject(1), '4', 'returns object at index'); + }); + + QUnit.test('objectAt - returns object at index in arrangedContent', function () { + equal(_emberRuntimeMixinsArray.objectAt(array, 1), '4', 'returns object at index'); + }); + + // Not sure if we need a specific test for it, since it's internal + QUnit.test('objectAtContent - returns object at index in arrangedContent', function () { + equal(array.objectAtContent(1), '4', 'returns object at index'); + }); + + QUnit.test('objectsAt - returns objects at indices in arrangedContent', function () { + deepEqual(array.objectsAt([0, 2, 4]), ['5', '2', undefined], 'returns objects at indices'); + }); + + QUnit.test('popObject - removes last object in arrangedContent', function () { + var popped = undefined; + _emberMetal.run(function () { + popped = array.popObject(); + }); + equal(popped, '1', 'returns last object'); + deepEqual(array.get('content'), [2, 4, 5], 'removes from content'); + }); + + QUnit.test('removeObject - removes object from content', function () { + _emberMetal.run(function () { + array.removeObject('2'); + }); + deepEqual(array.get('content'), [1, 4, 5]); + }); + + QUnit.test('removeObjects - removes objects from content', function () { + _emberMetal.run(function () { + array.removeObjects(['2', '4', '6']); + }); + deepEqual(array.get('content'), [1, 5]); + }); + + QUnit.test('shiftObject - removes from start of arrangedContent', function () { + var shifted = undefined; + _emberMetal.run(function () { + shifted = array.shiftObject(); + }); + equal(shifted, '5', 'returns first object'); + deepEqual(array.get('content'), [1, 2, 4], 'removes object from content'); + }); + + QUnit.test('slice - returns a slice of the arrangedContent', function () { + deepEqual(array.slice(1, 3), ['4', '2'], 'returns sliced arrangedContent'); + }); + + QUnit.test('toArray - returns copy of arrangedContent', function () { + deepEqual(array.toArray(), ['5', '4', '2', '1']); + }); + + QUnit.test('without - returns arrangedContent without object', function () { + deepEqual(array.without('2'), ['5', '4', '1'], 'returns arranged without object'); + }); + + QUnit.test('lastObject - returns last arranged object', function () { + equal(array.get('lastObject'), '1', 'returns last arranged object'); + }); + + QUnit.test('firstObject - returns first arranged object', function () { + equal(array.get('firstObject'), '5', 'returns first arranged object'); + }); + + QUnit.test('arrangedContentArray{Will,Did}Change are called when the arranged content changes', function () { + // The behaviour covered by this test may change in the future if we decide + // that built-in array methods are not overridable. + + var willChangeCallCount = 0; + var didChangeCallCount = 0; + + var content = _emberRuntimeSystemNative_array.A([1, 2, 3]); + _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContentArrayWillChange: function () { + willChangeCallCount++; + this._super.apply(this, arguments); + }, + arrangedContentArrayDidChange: function () { + didChangeCallCount++; + this._super.apply(this, arguments); + } + }).create({ content: content }); + + equal(willChangeCallCount, 0); + equal(didChangeCallCount, 0); + + content.pushObject(4); + content.pushObject(5); + + equal(willChangeCallCount, 2); + equal(didChangeCallCount, 2); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/arranged_content_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/arranged_content_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/arranged_content_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_change_test', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('ArrayProxy - content change'); + + QUnit.test('should update length for null content', function () { + var proxy = _emberRuntimeSystemArray_proxy.default.create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + + equal(proxy.get('length'), 3, 'precond - length is 3'); + + proxy.set('content', null); + + equal(proxy.get('length'), 0, 'length updates'); + }); + + QUnit.test('should update length for null content when there is a computed property watching length', function () { + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + isEmpty: _emberRuntimeComputedComputed_macros.not('length') + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + + equal(proxy.get('length'), 3, 'precond - length is 3'); + + // Consume computed property that depends on length + proxy.get('isEmpty'); + + // update content + proxy.set('content', null); + + equal(proxy.get('length'), 0, 'length updates'); + }); + + QUnit.test('The `arrangedContentWillChange` method is invoked before `content` is changed.', function () { + var callCount = 0; + var expectedLength = undefined; + + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContentWillChange: function () { + equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked before array has changed'); + callCount++; + } + }).create({ content: _emberRuntimeSystemNative_array.A([1, 2, 3]) }); + + proxy.pushObject(4); + equal(callCount, 0, 'pushing content onto the array doesn\'t trigger it'); + + proxy.get('content').pushObject(5); + equal(callCount, 0, 'pushing content onto the content array doesn\'t trigger it'); + + expectedLength = 5; + proxy.set('content', _emberRuntimeSystemNative_array.A(['a', 'b'])); + equal(callCount, 1, 'replacing the content array triggers the hook'); + }); + + QUnit.test('The `arrangedContentDidChange` method is invoked after `content` is changed.', function () { + var callCount = 0; + var expectedLength = undefined; + + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContentDidChange: function () { + equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked after array has changed'); + callCount++; + } + }).create({ + content: _emberRuntimeSystemNative_array.A([1, 2, 3]) + }); + + equal(callCount, 0, 'hook is not called after creating the object'); + + proxy.pushObject(4); + equal(callCount, 0, 'pushing content onto the array doesn\'t trigger it'); + + proxy.get('content').pushObject(5); + equal(callCount, 0, 'pushing content onto the content array doesn\'t trigger it'); + + expectedLength = 2; + proxy.set('content', _emberRuntimeSystemNative_array.A(['a', 'b'])); + equal(callCount, 1, 'replacing the content array triggers the hook'); + }); + + QUnit.test('The ArrayProxy doesn\'t explode when assigned a destroyed object', function () { + var proxy1 = _emberRuntimeSystemArray_proxy.default.create(); + var proxy2 = _emberRuntimeSystemArray_proxy.default.create(); + + _emberMetal.run(function () { + return proxy1.destroy(); + }); + + _emberMetal.set(proxy2, 'content', proxy1); + + ok(true, 'No exception was raised'); + }); + + QUnit.test('arrayContent{Will,Did}Change are called when the content changes', function () { + // The behaviour covered by this test may change in the future if we decide + // that built-in array methods are not overridable. + + var willChangeCallCount = 0; + var didChangeCallCount = 0; + + var content = _emberRuntimeSystemNative_array.A([1, 2, 3]); + _emberRuntimeSystemArray_proxy.default.extend({ + arrayContentWillChange: function () { + willChangeCallCount++; + this._super.apply(this, arguments); + }, + arrayContentDidChange: function () { + didChangeCallCount++; + this._super.apply(this, arguments); + } + }).create({ content: content }); + + equal(willChangeCallCount, 0); + equal(didChangeCallCount, 0); + + content.pushObject(4); + content.pushObject(5); + + equal(willChangeCallCount, 2); + equal(didChangeCallCount, 2); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_change_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/content_change_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/content_change_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_update_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.ArrayProxy - content update'); + + QUnit.test('The `contentArrayDidChange` method is invoked after `content` is updated.', function () { + var observerCalled = false; + var proxy = _emberRuntimeSystemArray_proxy.default.extend({ + arrangedContent: _emberMetal.computed('content', function (key) { + return _emberRuntimeSystemNative_array.A(this.get('content').slice()); + }), + + contentArrayDidChange: function (array, idx, removedCount, addedCount) { + observerCalled = true; + return this._super(array, idx, removedCount, addedCount); + } + }).create({ + content: _emberRuntimeSystemNative_array.A() + }); + + proxy.pushObject(1); + + ok(observerCalled, 'contentArrayDidChange is invoked'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/content_update_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/content_update_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/content_update_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/length_test', ['exports', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.ArrayProxy - content change (length)'); + + QUnit.test('array proxy + aliasedProperty complex test', function () { + var aCalled = undefined, + bCalled = undefined, + cCalled = undefined, + dCalled = undefined, + eCalled = undefined; + + aCalled = bCalled = cCalled = dCalled = eCalled = 0; + + var obj = _emberRuntimeSystemObject.default.extend({ + colors: _emberMetal.computed.reads('model'), + length: _emberMetal.computed.reads('colors.length'), + + a: _emberMetal.observer('length', function () { + return aCalled++; + }), + b: _emberMetal.observer('colors.length', function () { + return bCalled++; + }), + c: _emberMetal.observer('colors.content.length', function () { + return cCalled++; + }), + d: _emberMetal.observer('colors.[]', function () { + return dCalled++; + }), + e: _emberMetal.observer('colors.content.[]', function () { + return eCalled++; + }) + }).create(); + + obj.set('model', _emberRuntimeSystemArray_proxy.default.create({ + content: _emberRuntimeSystemNative_array.A(['red', 'yellow', 'blue']) + })); + + equal(obj.get('colors.content.length'), 3); + equal(obj.get('colors.length'), 3); + equal(obj.get('length'), 3); + + equal(aCalled, 1, 'expected observer `length` to be called ONCE'); + equal(bCalled, 1, 'expected observer `colors.length` to be called ONCE'); + equal(cCalled, 1, 'expected observer `colors.content.length` to be called ONCE'); + equal(dCalled, 1, 'expected observer `colors.[]` to be called ONCE'); + equal(eCalled, 1, 'expected observer `colors.content.[]` to be called ONCE'); + + obj.get('colors').pushObjects(['green', 'red']); + + equal(obj.get('colors.content.length'), 5); + equal(obj.get('colors.length'), 5); + equal(obj.get('length'), 5); + + equal(aCalled, 2, 'expected observer `length` to be called TWICE'); + equal(bCalled, 2, 'expected observer `colors.length` to be called TWICE'); + equal(cCalled, 2, 'expected observer `colors.content.length` to be called TWICE'); + equal(dCalled, 2, 'expected observer `colors.[]` to be called TWICE'); + equal(eCalled, 2, 'expected observer `colors.content.[]` to be called TWICE'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/length_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/length_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/length_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/suite_test', ['exports', 'ember-runtime/tests/suites/mutable_array', 'ember-runtime/system/array_proxy', 'ember-metal', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeTestsSuitesMutable_array, _emberRuntimeSystemArray_proxy, _emberMetal, _emberRuntimeSystemNative_array) { + 'use strict'; + + _emberRuntimeTestsSuitesMutable_array.default.extend({ + name: 'Ember.ArrayProxy', + + newObject: function (ary) { + var ret = ary ? ary.slice() : this.newFixture(3); + return _emberRuntimeSystemArray_proxy.default.create({ content: _emberRuntimeSystemNative_array.A(ret) }); + }, + + mutate: function (obj) { + obj.pushObject(_emberMetal.get(obj, 'length') + 1); + }, + + toArray: function (obj) { + return obj.toArray ? obj.toArray() : obj.slice(); + } + }).run(); +}); +enifed('ember-runtime/tests/system/array_proxy/suite_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/suite_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/suite_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/watching_and_listening_test', ['exports', 'ember-metal', 'ember-runtime/system/array_proxy', 'ember-runtime/system/native_array'], function (exports, _emberMetal, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemNative_array) { + 'use strict'; + + function sortedListenersFor(obj, eventName) { + return _emberMetal.listenersFor(obj, eventName).sort(function (listener1, listener2) { + return listener1[1] > listener2[1] ? -1 : 1; + }); + } + + QUnit.module('ArrayProxy - watching and listening'); + + QUnit.test('setting \'content\' adds listeners correctly', function () { + var content = _emberRuntimeSystemNative_array.A(); + var proxy = _emberRuntimeSystemArray_proxy.default.create(); + + deepEqual(sortedListenersFor(content, '@array:before'), []); + deepEqual(sortedListenersFor(content, '@array:change'), []); + + proxy.set('content', content); + + deepEqual(sortedListenersFor(content, '@array:before'), [[proxy, 'contentArrayWillChange'], [proxy, 'arrangedContentArrayWillChange']]); + deepEqual(sortedListenersFor(content, '@array:change'), [[proxy, 'contentArrayDidChange'], [proxy, 'arrangedContentArrayDidChange']]); + }); + + QUnit.test('changing \'content\' adds and removes listeners correctly', function () { + var content1 = _emberRuntimeSystemNative_array.A(); + var content2 = _emberRuntimeSystemNative_array.A(); + var proxy = _emberRuntimeSystemArray_proxy.default.create({ content: content1 }); + + deepEqual(sortedListenersFor(content1, '@array:before'), [[proxy, 'contentArrayWillChange'], [proxy, 'arrangedContentArrayWillChange']]); + deepEqual(sortedListenersFor(content1, '@array:change'), [[proxy, 'contentArrayDidChange'], [proxy, 'arrangedContentArrayDidChange']]); + + proxy.set('content', content2); + + deepEqual(sortedListenersFor(content1, '@array:before'), []); + deepEqual(sortedListenersFor(content1, '@array:change'), []); + deepEqual(sortedListenersFor(content2, '@array:before'), [[proxy, 'contentArrayWillChange'], [proxy, 'arrangedContentArrayWillChange']]); + deepEqual(sortedListenersFor(content2, '@array:change'), [[proxy, 'contentArrayDidChange'], [proxy, 'arrangedContentArrayDidChange']]); + }); + + QUnit.test('regression test for https://github.com/emberjs/ember.js/issues/12475', function () { + var item1a = { id: 1 }; + var item1b = { id: 2 }; + var item1c = { id: 3 }; + var content1 = _emberRuntimeSystemNative_array.A([item1a, item1b, item1c]); + + var proxy = _emberRuntimeSystemArray_proxy.default.create({ content: content1 }); + var obj = { proxy: proxy }; + + _emberMetal.defineProperty(obj, 'ids', _emberMetal.computed('proxy.@each.id', function () { + return _emberMetal.get(this, 'proxy').mapBy('id'); + })); + + // These manually added observers are to simulate the observers added by the + // rendering process in a template like: + // + // {{#each items as |item|}} + // {{item.id}} + // {{/each}} + _emberMetal.addObserver(item1a, 'id', function () {}); + _emberMetal.addObserver(item1b, 'id', function () {}); + _emberMetal.addObserver(item1c, 'id', function () {}); + + // The EachProxy has not yet been consumed. Only the manually added + // observers are watching. + equal(_emberMetal.watcherCount(item1a, 'id'), 1); + equal(_emberMetal.watcherCount(item1b, 'id'), 1); + equal(_emberMetal.watcherCount(item1c, 'id'), 1); + + // Consume the each proxy. This causes the EachProxy to add two observers + // per item: one for "before" events and one for "after" events. + deepEqual(_emberMetal.get(obj, 'ids'), [1, 2, 3]); + + // For each item, the two each proxy observers and one manual added observer + // are watching. + equal(_emberMetal.watcherCount(item1a, 'id'), 3); + equal(_emberMetal.watcherCount(item1b, 'id'), 3); + equal(_emberMetal.watcherCount(item1c, 'id'), 3); + + // This should be a no-op because observers do not fire if the value + // 1. is an object and 2. is the same as the old value. + proxy.set('content', content1); + + equal(_emberMetal.watcherCount(item1a, 'id'), 3); + equal(_emberMetal.watcherCount(item1b, 'id'), 3); + equal(_emberMetal.watcherCount(item1c, 'id'), 3); + + // This is repeated to catch the regression. It should still be a no-op. + proxy.set('content', content1); + + equal(_emberMetal.watcherCount(item1a, 'id'), 3); + equal(_emberMetal.watcherCount(item1b, 'id'), 3); + equal(_emberMetal.watcherCount(item1c, 'id'), 3); + + // Set the content to a new array with completely different items and + // repeat the process. + var item2a = { id: 4 }; + var item2b = { id: 5 }; + var item2c = { id: 6 }; + var content2 = _emberRuntimeSystemNative_array.A([item2a, item2b, item2c]); + + _emberMetal.addObserver(item2a, 'id', function () {}); + _emberMetal.addObserver(item2b, 'id', function () {}); + _emberMetal.addObserver(item2c, 'id', function () {}); + + proxy.set('content', content2); + + deepEqual(_emberMetal.get(obj, 'ids'), [4, 5, 6]); + + equal(_emberMetal.watcherCount(item2a, 'id'), 3); + equal(_emberMetal.watcherCount(item2b, 'id'), 3); + equal(_emberMetal.watcherCount(item2c, 'id'), 3); + + // Ensure that the observers added by the EachProxy on all items in the + // first content array have been torn down. + equal(_emberMetal.watcherCount(item1a, 'id'), 1); + equal(_emberMetal.watcherCount(item1b, 'id'), 1); + equal(_emberMetal.watcherCount(item1c, 'id'), 1); + + proxy.set('content', content2); + + equal(_emberMetal.watcherCount(item2a, 'id'), 3); + equal(_emberMetal.watcherCount(item2b, 'id'), 3); + equal(_emberMetal.watcherCount(item2c, 'id'), 3); + + proxy.set('content', content2); + + equal(_emberMetal.watcherCount(item2a, 'id'), 3); + equal(_emberMetal.watcherCount(item2b, 'id'), 3); + equal(_emberMetal.watcherCount(item2c, 'id'), 3); + }); +}); +enifed('ember-runtime/tests/system/array_proxy/watching_and_listening_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/array_proxy/watching_and_listening_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/array_proxy/watching_and_listening_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/core_object_test', ['exports', 'ember-runtime/system/core_object', 'ember-metal/property_set', 'ember-metal/mixin'], function (exports, _emberRuntimeSystemCore_object, _emberMetalProperty_set, _emberMetalMixin) { + 'use strict'; + + QUnit.module('Ember.CoreObject'); + + QUnit.test('works with new (one arg)', function () { + var obj = new _emberRuntimeSystemCore_object.default({ + firstName: 'Stef', + lastName: 'Penner' + }); + + equal(obj.firstName, 'Stef'); + equal(obj.lastName, 'Penner'); + }); + + QUnit.test('works with new (> 1 arg)', function () { + var obj = new _emberRuntimeSystemCore_object.default({ + firstName: 'Stef', + lastName: 'Penner' + }, { + other: 'name' + }); + + equal(obj.firstName, 'Stef'); + equal(obj.lastName, 'Penner'); + + equal(obj.other, undefined); // doesn't support multiple pojo' to the constructor + }); + + QUnit.test('toString should be not be added as a property when calling toString()', function () { + var obj = new _emberRuntimeSystemCore_object.default({ + firstName: 'Foo', + lastName: 'Bar' + }); + + obj.toString(); + + notOk(obj.hasOwnProperty('toString'), 'Calling toString() should not create a toString class property'); + }); + + QUnit.test('[POST_INIT] invoked during construction', function (assert) { + var _CoreObject$extend; + + var callCount = 0; + var Obj = _emberRuntimeSystemCore_object.default.extend((_CoreObject$extend = {}, _CoreObject$extend[_emberRuntimeSystemCore_object.POST_INIT] = function () { + callCount++; + }, _CoreObject$extend)); + + equal(callCount, 0); + + Obj.create(); + + equal(callCount, 1); + }); + + QUnit.test('[POST_INIT] invoked before finishChains', function (assert) { + var _CoreObject$extend2; + + var callCount = 0; + + var Obj = _emberRuntimeSystemCore_object.default.extend((_CoreObject$extend2 = {}, _CoreObject$extend2[_emberRuntimeSystemCore_object.POST_INIT] = function () { + _emberMetalProperty_set.set(this, 'hi', 1); + }, _CoreObject$extend2.hiDidChange = _emberMetalMixin.observer('hi', function () { + callCount++; + }), _CoreObject$extend2)); + + equal(callCount, 0); + + var obj = Obj.create(); + + equal(callCount, 0); + + _emberMetalProperty_set.set(obj, 'hi', 2); + + equal(callCount, 1); + }); +}); +enifed('ember-runtime/tests/system/core_object_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/core_object_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/core_object_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/lazy_load_test', ['exports', 'ember-metal', 'ember-runtime/system/lazy_load'], function (exports, _emberMetal, _emberRuntimeSystemLazy_load) { + 'use strict'; + + QUnit.module('Lazy Loading', { + teardown: function () { + var keys = Object.keys(_emberRuntimeSystemLazy_load._loaded); + for (var i = 0; i < keys.length; i++) { + delete _emberRuntimeSystemLazy_load._loaded[keys[i]]; + } + } + }); + + QUnit.test('if a load hook is registered, it is executed when runLoadHooks are exected', function () { + var count = 0; + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.onLoad('__test_hook__', function (object) { + count += object; + }); + }); + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.runLoadHooks('__test_hook__', 1); + }); + + equal(count, 1, 'the object was passed into the load hook'); + }); + + QUnit.test('if runLoadHooks was already run, it executes newly added hooks immediately', function () { + var count = 0; + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.onLoad('__test_hook__', function (object) { + return count += object; + }); + }); + + _emberMetal.run(function () { + return _emberRuntimeSystemLazy_load.runLoadHooks('__test_hook__', 1); + }); + + count = 0; + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.onLoad('__test_hook__', function (object) { + return count += object; + }); + }); + + equal(count, 1, 'the original object was passed into the load hook'); + }); + + QUnit.test('hooks in ENV.EMBER_LOAD_HOOKS[\'hookName\'] get executed', function () { + // Note that the necessary code to perform this test is run before + // the Ember lib is loaded in tests/index.html + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.runLoadHooks('__before_ember_test_hook__', 1); + }); + + equal(window.ENV.__test_hook_count__, 1, 'the object was passed into the load hook'); + }); + + if (typeof window === 'object' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') { + QUnit.test('load hooks trigger a custom event', function () { + var eventObject = 'super duper awesome events'; + + window.addEventListener('__test_hook_for_events__', function (e) { + ok(true, 'custom event was fired'); + equal(e.detail, eventObject, 'event details are provided properly'); + }); + + _emberMetal.run(function () { + _emberRuntimeSystemLazy_load.runLoadHooks('__test_hook_for_events__', eventObject); + }); + }); + } +}); +enifed('ember-runtime/tests/system/lazy_load_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/lazy_load_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/lazy_load_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/namespace/base_test', ['exports', 'ember-environment', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/system/namespace'], function (exports, _emberEnvironment, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeSystemNamespace) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('Namespace', { + setup: function () { + _emberRuntimeSystemNamespace.setSearchDisabled(false); + + lookup = _emberEnvironment.context.lookup = {}; + }, + teardown: function () { + _emberRuntimeSystemNamespace.setSearchDisabled(false); + + for (var prop in lookup) { + if (lookup[prop]) { + _emberMetal.run(lookup[prop], 'destroy'); + } + } + + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('Namespace should be a subclass of EmberObject', function () { + ok(_emberRuntimeSystemObject.default.detect(_emberRuntimeSystemNamespace.default)); + }); + + QUnit.test('Namespace should be duck typed', function () { + ok(_emberMetal.get(_emberRuntimeSystemNamespace.default.create(), 'isNamespace'), 'isNamespace property is true'); + }); + + QUnit.test('Namespace is found and named', function () { + var nsA = lookup.NamespaceA = _emberRuntimeSystemNamespace.default.create(); + equal(nsA.toString(), 'NamespaceA', 'namespaces should have a name if they are on lookup'); + + var nsB = lookup.NamespaceB = _emberRuntimeSystemNamespace.default.create(); + equal(nsB.toString(), 'NamespaceB', 'namespaces work if created after the first namespace processing pass'); + }); + + QUnit.test('Classes under an Namespace are properly named', function () { + var nsA = lookup.NamespaceA = _emberRuntimeSystemNamespace.default.create(); + nsA.Foo = _emberRuntimeSystemObject.default.extend(); + equal(nsA.Foo.toString(), 'NamespaceA.Foo', 'Classes pick up their parent namespace'); + + nsA.Bar = _emberRuntimeSystemObject.default.extend(); + equal(nsA.Bar.toString(), 'NamespaceA.Bar', 'New Classes get the naming treatment too'); + + var nsB = lookup.NamespaceB = _emberRuntimeSystemNamespace.default.create(); + nsB.Foo = _emberRuntimeSystemObject.default.extend(); + equal(nsB.Foo.toString(), 'NamespaceB.Foo', 'Classes in new namespaces get the naming treatment'); + }); + + //test("Classes under Ember are properly named", function() { + // // ES6TODO: This test does not work reliably when running independent package build with Broccoli config. + // Ember.TestObject = EmberObject.extend({}); + // equal(Ember.TestObject.toString(), "Ember.TestObject", "class under Ember is given a string representation"); + //}); + + QUnit.test('Lowercase namespaces are no longer supported', function () { + var nsC = lookup.namespaceC = _emberRuntimeSystemNamespace.default.create(); + equal(nsC.toString(), undefined); + }); + + QUnit.test('A namespace can be assigned a custom name', function () { + var nsA = _emberRuntimeSystemNamespace.default.create({ + name: 'NamespaceA' + }); + + var nsB = lookup.NamespaceB = _emberRuntimeSystemNamespace.default.create({ + name: 'CustomNamespaceB' + }); + + nsA.Foo = _emberRuntimeSystemObject.default.extend(); + nsB.Foo = _emberRuntimeSystemObject.default.extend(); + + equal(nsA.Foo.toString(), 'NamespaceA.Foo', 'The namespace\'s name is used when the namespace is not in the lookup object'); + equal(nsB.Foo.toString(), 'CustomNamespaceB.Foo', 'The namespace\'s name is used when the namespace is in the lookup object'); + }); + + QUnit.test('Calling namespace.nameClasses() eagerly names all classes', function () { + _emberRuntimeSystemNamespace.setSearchDisabled(true); + + var namespace = lookup.NS = _emberRuntimeSystemNamespace.default.create(); + + namespace.ClassA = _emberRuntimeSystemObject.default.extend(); + namespace.ClassB = _emberRuntimeSystemObject.default.extend(); + + _emberRuntimeSystemNamespace.default.processAll(); + + equal(namespace.ClassA.toString(), 'NS.ClassA'); + equal(namespace.ClassB.toString(), 'NS.ClassB'); + }); + + QUnit.test('A namespace can be looked up by its name', function () { + var NS = lookup.NS = _emberRuntimeSystemNamespace.default.create(); + var UI = lookup.UI = _emberRuntimeSystemNamespace.default.create(); + var CF = lookup.CF = _emberRuntimeSystemNamespace.default.create(); + + equal(_emberRuntimeSystemNamespace.default.byName('NS'), NS); + equal(_emberRuntimeSystemNamespace.default.byName('UI'), UI); + equal(_emberRuntimeSystemNamespace.default.byName('CF'), CF); + }); + + QUnit.test('A nested namespace can be looked up by its name', function () { + var UI = lookup.UI = _emberRuntimeSystemNamespace.default.create(); + UI.Nav = _emberRuntimeSystemNamespace.default.create(); + + equal(_emberRuntimeSystemNamespace.default.byName('UI.Nav'), UI.Nav); + }); + + QUnit.test('Destroying a namespace before caching lookup removes it from the list of namespaces', function () { + var CF = lookup.CF = _emberRuntimeSystemNamespace.default.create(); + + _emberMetal.run(CF, 'destroy'); + equal(_emberRuntimeSystemNamespace.default.byName('CF'), undefined, 'namespace can not be found after destroyed'); + }); + + QUnit.test('Destroying a namespace after looking up removes it from the list of namespaces', function () { + var CF = lookup.CF = _emberRuntimeSystemNamespace.default.create(); + + equal(_emberRuntimeSystemNamespace.default.byName('CF'), CF, 'precondition - namespace can be looked up by name'); + + _emberMetal.run(CF, 'destroy'); + equal(_emberRuntimeSystemNamespace.default.byName('CF'), undefined, 'namespace can not be found after destroyed'); + }); +}); +enifed('ember-runtime/tests/system/namespace/base_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/namespace/base_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/namespace/base_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/native_array/a_test', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/native_array'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemNative_array) { + 'use strict'; + + QUnit.module('Ember.A'); + + QUnit.test('Ember.A', function () { + deepEqual(_emberRuntimeSystemNative_array.A([1, 2]), [1, 2], 'array values were not be modified'); + deepEqual(_emberRuntimeSystemNative_array.A(), [], 'returned an array with no arguments'); + deepEqual(_emberRuntimeSystemNative_array.A(null), [], 'returned an array with a null argument'); + ok(_emberRuntimeMixinsArray.default.detect(_emberRuntimeSystemNative_array.A()), 'returned an ember array'); + ok(_emberRuntimeMixinsArray.default.detect(_emberRuntimeSystemNative_array.A([1, 2])), 'returned an ember array'); + }); +}); +enifed('ember-runtime/tests/system/native_array/a_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/native_array/a_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/native_array/a_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/native_array/copyable_suite_test', ['exports', 'ember-utils', 'ember-runtime/system/native_array', 'ember-runtime/tests/suites/copyable'], function (exports, _emberUtils, _emberRuntimeSystemNative_array, _emberRuntimeTestsSuitesCopyable) { + 'use strict'; + + _emberRuntimeTestsSuitesCopyable.default.extend({ + name: 'NativeArray Copyable', + + newObject: function () { + return _emberRuntimeSystemNative_array.A([_emberUtils.generateGuid()]); + }, + + isEqual: function (a, b) { + if (!(a instanceof Array)) { + return false; + } + + if (!(b instanceof Array)) { + return false; + } + + if (a.length !== b.length) { + return false; + } + + return a[0] === b[0]; + }, + + shouldBeFreezable: false + }).run(); + + QUnit.module('NativeArray Copyable'); + + QUnit.test('deep copy is respected', function () { + var array = _emberRuntimeSystemNative_array.A([{ id: 1 }, { id: 2 }, { id: 3 }]); + + var copiedArray = array.copy(true); + + deepEqual(copiedArray, array, 'copied array is equivalent'); + ok(copiedArray[0] !== array[0], 'objects inside should be unique'); + }); +}); +enifed('ember-runtime/tests/system/native_array/copyable_suite_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/native_array/copyable_suite_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/native_array/copyable_suite_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/native_array/suite_test', ['exports', 'ember-runtime/system/native_array', 'ember-runtime/tests/suites/mutable_array'], function (exports, _emberRuntimeSystemNative_array, _emberRuntimeTestsSuitesMutable_array) { + 'use strict'; + + _emberRuntimeTestsSuitesMutable_array.default.extend({ + name: 'Native Array', + + newObject: function (ary) { + return _emberRuntimeSystemNative_array.A(ary ? ary.slice() : this.newFixture(3)); + }, + + mutate: function (obj) { + obj.pushObject(obj.length + 1); + }, + + toArray: function (obj) { + return obj.slice(); // make a copy. + } + }).run(); +}); +enifed('ember-runtime/tests/system/native_array/suite_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/native_array/suite_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/native_array/suite_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/computed_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + function K() { + return this; + } + + QUnit.module('EmberObject computed property'); + + _internalTestHelpers.testWithDefault('computed property on instance', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + equal(get(new MyClass(), 'foo'), 'FOO'); + }); + + _internalTestHelpers.testWithDefault('computed property on subclass', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var Subclass = MyClass.extend({ + foo: _emberMetal.computed(function () { + return 'BAR'; + }) + }); + + equal(get(new Subclass(), 'foo'), 'BAR'); + }); + + _internalTestHelpers.testWithDefault('replacing computed property with regular val', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var Subclass = MyClass.extend({ + foo: 'BAR' + }); + + equal(get(new Subclass(), 'foo'), 'BAR'); + }); + + _internalTestHelpers.testWithDefault('complex depndent keys', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + + init: function () { + this._super.apply(this, arguments); + set(this, 'bar', { baz: 'BIFF' }); + }, + + count: 0, + + foo: _emberMetal.computed(function () { + set(this, 'count', get(this, 'count') + 1); + return _emberMetal.get(get(this, 'bar'), 'baz') + ' ' + get(this, 'count'); + }).property('bar.baz') + + }); + + var Subclass = MyClass.extend({ + count: 20 + }); + + var obj1 = new MyClass(); + var obj2 = new Subclass(); + + equal(get(obj1, 'foo'), 'BIFF 1'); + equal(get(obj2, 'foo'), 'BIFF 21'); + + set(get(obj1, 'bar'), 'baz', 'BLARG'); + + equal(get(obj1, 'foo'), 'BLARG 2'); + equal(get(obj2, 'foo'), 'BIFF 21'); + + set(get(obj2, 'bar'), 'baz', 'BOOM'); + + equal(get(obj1, 'foo'), 'BLARG 2'); + equal(get(obj2, 'foo'), 'BOOM 22'); + }); + + _internalTestHelpers.testWithDefault('complex dependent keys changing complex dependent keys', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + init: function () { + this._super.apply(this, arguments); + set(this, 'bar', { baz: 'BIFF' }); + }, + + count: 0, + + foo: _emberMetal.computed(function () { + set(this, 'count', get(this, 'count') + 1); + return _emberMetal.get(get(this, 'bar'), 'baz') + ' ' + get(this, 'count'); + }).property('bar.baz') + }); + + var Subclass = MyClass.extend({ + init: function () { + this._super.apply(this, arguments); + set(this, 'bar2', { baz: 'BIFF2' }); + }, + + count: 0, + + foo: _emberMetal.computed(function () { + set(this, 'count', get(this, 'count') + 1); + return _emberMetal.get(get(this, 'bar2'), 'baz') + ' ' + get(this, 'count'); + }).property('bar2.baz') + }); + + var obj2 = new Subclass(); + + equal(get(obj2, 'foo'), 'BIFF2 1'); + + set(get(obj2, 'bar'), 'baz', 'BLARG'); + equal(get(obj2, 'foo'), 'BIFF2 1', 'should not invalidate property'); + + set(get(obj2, 'bar2'), 'baz', 'BLARG'); + equal(get(obj2, 'foo'), 'BLARG 2', 'should invalidate property'); + }); + + QUnit.test('can retrieve metadata for a computed property', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + computedProperty: _emberMetal.computed(function () {}).meta({ key: 'keyValue' }) + }); + + equal(_emberMetal.get(MyClass.metaForProperty('computedProperty'), 'key'), 'keyValue', 'metadata saved on the computed property can be retrieved'); + + var ClassWithNoMetadata = _emberRuntimeSystemObject.default.extend({ + computedProperty: _emberMetal.computed(function () {}).volatile(), + + staticProperty: 12 + }); + + equal(typeof ClassWithNoMetadata.metaForProperty('computedProperty'), 'object', 'returns empty hash if no metadata has been saved'); + + expectAssertion(function () { + ClassWithNoMetadata.metaForProperty('nonexistentProperty'); + }, 'metaForProperty() could not find a computed property with key \'nonexistentProperty\'.'); + + expectAssertion(function () { + ClassWithNoMetadata.metaForProperty('staticProperty'); + }, 'metaForProperty() could not find a computed property with key \'staticProperty\'.'); + }); + + QUnit.test('can iterate over a list of computed properties for a class', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () {}), + + fooDidChange: _emberMetal.observer('foo', function () {}), + + bar: _emberMetal.computed(function () {}), + + qux: _emberMetal.alias('foo') + }); + + var SubClass = MyClass.extend({ + baz: _emberMetal.computed(function () {}) + }); + + SubClass.reopen({ + bat: _emberMetal.computed(function () {}).meta({ iAmBat: true }) + }); + + var list = []; + + MyClass.eachComputedProperty(function (name) { + list.push(name); + }); + + deepEqual(list.sort(), ['bar', 'foo', 'qux'], 'watched and unwatched computed properties are iterated'); + + list = []; + + SubClass.eachComputedProperty(function (name, meta) { + list.push(name); + + if (name === 'bat') { + deepEqual(meta, { iAmBat: true }); + } else { + deepEqual(meta, {}); + } + }); + + deepEqual(list.sort(), ['bar', 'bat', 'baz', 'foo', 'qux'], 'all inherited properties are included'); + }); + + QUnit.test('list of properties updates when an additional property is added (such cache busting)', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(K), + + fooDidChange: _emberMetal.observer('foo', function () {}), + + bar: _emberMetal.computed(K) + }); + + var list = []; + + MyClass.eachComputedProperty(function (name) { + list.push(name); + }); + + deepEqual(list.sort(), ['bar', 'foo'].sort(), 'expected two computed properties'); + + MyClass.reopen({ + baz: _emberMetal.computed(K) + }); + + MyClass.create(); // force apply mixins + + list = []; + + MyClass.eachComputedProperty(function (name) { + list.push(name); + }); + + deepEqual(list.sort(), ['bar', 'foo', 'baz'].sort(), 'expected three computed properties'); + }); + + QUnit.test('Calling _super in call outside the immediate function of a CP getter works', function () { + function macro(callback) { + return _emberMetal.computed(function () { + return callback.call(this); + }); + } + + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var SubClass = MyClass.extend({ + foo: macro(function () { + return this._super(); + }) + }); + + ok(_emberMetal.get(SubClass.create(), 'foo'), 'FOO', 'super value is fetched'); + }); + + QUnit.test('Calling _super in apply outside the immediate function of a CP getter works', function () { + function macro(callback) { + return _emberMetal.computed(function () { + return callback.apply(this); + }); + } + + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed(function () { + return 'FOO'; + }) + }); + + var SubClass = MyClass.extend({ + foo: macro(function () { + return this._super(); + }) + }); + + ok(_emberMetal.get(SubClass.create(), 'foo'), 'FOO', 'super value is fetched'); + }); +}); +enifed('ember-runtime/tests/system/object/computed_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/computed_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/computed_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/create_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('EmberObject.create', {}); + + QUnit.test('simple properties are set', function () { + var o = _emberRuntimeSystemObject.default.create({ ohai: 'there' }); + equal(o.get('ohai'), 'there'); + }); + + QUnit.test('calls computed property setters', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.computed({ + get: function () { + return 'this is not the value you\'re looking for'; + }, + set: function (key, value) { + return value; + } + }) + }); + + var o = MyClass.create({ foo: 'bar' }); + equal(o.get('foo'), 'bar'); + }); + + if (false) { + QUnit.test('sets up mandatory setters for watched simple properties', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + foo: null, + bar: null, + fooDidChange: _emberMetal.observer('foo', function () {}) + }); + + var o = MyClass.create({ foo: 'bar', bar: 'baz' }); + equal(o.get('foo'), 'bar'); + + var descriptor = Object.getOwnPropertyDescriptor(o, 'foo'); + ok(descriptor.set, 'Mandatory setter was setup'); + + descriptor = Object.getOwnPropertyDescriptor(o, 'bar'); + ok(!descriptor.set, 'Mandatory setter was not setup'); + }); + } + + QUnit.test('allows bindings to be defined', function () { + var obj = undefined; + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + obj = _emberRuntimeSystemObject.default.create({ + foo: 'foo', + barBinding: 'foo' + }); + }, deprecationMessage); + + equal(obj.get('bar'), 'foo', 'The binding value is correct'); + }); + + QUnit.test('calls setUnknownProperty if defined', function () { + var setUnknownPropertyCalled = false; + + var MyClass = _emberRuntimeSystemObject.default.extend({ + setUnknownProperty: function (key, value) { + setUnknownPropertyCalled = true; + } + }); + + MyClass.create({ foo: 'bar' }); + ok(setUnknownPropertyCalled, 'setUnknownProperty was called'); + }); + + QUnit.test('throws if you try to define a computed property', function () { + expectAssertion(function () { + _emberRuntimeSystemObject.default.create({ + foo: _emberMetal.computed(function () {}) + }); + }, 'Ember.Object.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().'); + }); + + QUnit.test('throws if you try to call _super in a method', function () { + expectAssertion(function () { + _emberRuntimeSystemObject.default.create({ + foo: function () { + this._super.apply(this, arguments); + } + }); + }, 'Ember.Object.create no longer supports defining methods that call _super.'); + }); + + QUnit.test('throws if you try to \'mixin\' a definition', function () { + var myMixin = _emberMetal.Mixin.create({ + adder: function (arg1, arg2) { + return arg1 + arg2; + } + }); + + expectAssertion(function () { + _emberRuntimeSystemObject.default.create(myMixin); + }, 'Ember.Object.create no longer supports mixing in other definitions, use .extend & .create separately instead.'); + }); + + // This test is for IE8. + QUnit.test('property name is the same as own prototype property', function () { + var MyClass = _emberRuntimeSystemObject.default.extend({ + toString: function () { + return 'MyClass'; + } + }); + + equal(MyClass.create().toString(), 'MyClass', 'should inherit property from the arguments of `EmberObject.create`'); + }); + + QUnit.test('inherits properties from passed in EmberObject', function () { + var baseObj = _emberRuntimeSystemObject.default.create({ foo: 'bar' }); + var secondaryObj = _emberRuntimeSystemObject.default.create(baseObj); + + equal(secondaryObj.foo, baseObj.foo, 'Em.O.create inherits properties from EmberObject parameter'); + }); + + QUnit.test('throws if you try to pass anything a string as a parameter', function () { + var expected = 'EmberObject.create only accepts an objects.'; + + throws(function () { + return _emberRuntimeSystemObject.default.create('some-string'); + }, expected); + }); + + QUnit.test('EmberObject.create can take undefined as a parameter', function () { + var o = _emberRuntimeSystemObject.default.create(undefined); + deepEqual(_emberRuntimeSystemObject.default.create(), o); + }); + + QUnit.test('EmberObject.create can take null as a parameter', function () { + var o = _emberRuntimeSystemObject.default.create(null); + deepEqual(_emberRuntimeSystemObject.default.create(), o); + }); + + QUnit.test('EmberObject.create avoids allocating a binding map when not necessary', function () { + var o = _emberRuntimeSystemObject.default.create(); + var m = _emberMetal.meta(o); + ok(!m.peekBindings(), 'A binding map is not allocated'); + }); +}); +enifed('ember-runtime/tests/system/object/create_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/create_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/create_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/destroy_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('ember-runtime/system/object/destroy_test'); + + _internalTestHelpers.testBoth('should schedule objects to be destroyed at the end of the run loop', function (get, set) { + var obj = _emberRuntimeSystemObject.default.create(); + var meta = undefined; + + _emberMetal.run(function () { + obj.destroy(); + meta = _emberMetal.peekMeta(obj); + ok(meta, 'meta is not destroyed immediately'); + ok(get(obj, 'isDestroying'), 'object is marked as destroying immediately'); + ok(!get(obj, 'isDestroyed'), 'object is not destroyed immediately'); + }); + + meta = _emberMetal.peekMeta(obj); + ok(get(obj, 'isDestroyed'), 'object is destroyed after run loop finishes'); + }); + + if (false) { + // MANDATORY_SETTER moves value to meta.values + // a destroyed object removes meta but leaves the accessor + // that looks it up + QUnit.test('should raise an exception when modifying watched properties on a destroyed object', function () { + var obj = _emberRuntimeSystemObject.default.extend({ + fooDidChange: _emberMetal.observer('foo', function () {}) + }).create({ + foo: 'bar' + }); + + _emberMetal.run(function () { + return obj.destroy(); + }); + + throws(function () { + return _emberMetal.set(obj, 'foo', 'baz'); + }, Error, 'raises an exception'); + }); + } + + QUnit.test('observers should not fire after an object has been destroyed', function () { + var count = 0; + var obj = _emberRuntimeSystemObject.default.extend({ + fooDidChange: _emberMetal.observer('foo', function () { + count++; + }) + }).create(); + + obj.set('foo', 'bar'); + + equal(count, 1, 'observer was fired once'); + + _emberMetal.run(function () { + _emberMetal.beginPropertyChanges(); + obj.set('foo', 'quux'); + obj.destroy(); + _emberMetal.endPropertyChanges(); + }); + + equal(count, 1, 'observer was not called after object was destroyed'); + }); + + QUnit.test('destroyed objects should not see each others changes during teardown but a long lived object should', function () { + var shouldChange = 0; + var shouldNotChange = 0; + + var objs = {}; + + var A = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAlive: true, + willDestroy: function () { + this.set('isAlive', false); + }, + bDidChange: _emberMetal.observer('objs.b.isAlive', function () { + shouldNotChange++; + }), + cDidChange: _emberMetal.observer('objs.c.isAlive', function () { + shouldNotChange++; + }) + }); + + var B = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAlive: true, + willDestroy: function () { + this.set('isAlive', false); + }, + aDidChange: _emberMetal.observer('objs.a.isAlive', function () { + shouldNotChange++; + }), + cDidChange: _emberMetal.observer('objs.c.isAlive', function () { + shouldNotChange++; + }) + }); + + var C = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAlive: true, + willDestroy: function () { + this.set('isAlive', false); + }, + aDidChange: _emberMetal.observer('objs.a.isAlive', function () { + shouldNotChange++; + }), + bDidChange: _emberMetal.observer('objs.b.isAlive', function () { + shouldNotChange++; + }) + }); + + var LongLivedObject = _emberRuntimeSystemObject.default.extend({ + objs: objs, + isAliveDidChange: _emberMetal.observer('objs.a.isAlive', function () { + shouldChange++; + }) + }); + + objs.a = new A(); + + objs.b = new B(); + + objs.c = new C(); + + new LongLivedObject(); + + _emberMetal.run(function () { + var keys = Object.keys(objs); + for (var i = 0; i < keys.length; i++) { + objs[keys[i]].destroy(); + } + }); + + equal(shouldNotChange, 0, 'destroyed graph objs should not see change in willDestroy'); + equal(shouldChange, 1, 'long lived should see change in willDestroy'); + }); + + QUnit.test('bindings should be synced when are updated in the willDestroy hook', function () { + var bar = _emberRuntimeSystemObject.default.create({ + value: false, + willDestroy: function () { + this.set('value', true); + } + }); + + var foo = _emberRuntimeSystemObject.default.create({ + value: null, + bar: bar + }); + + _emberMetal.run(function () { + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + _emberMetal.bind(foo, 'value', 'bar.value'); + }, deprecationMessage); + }); + + ok(bar.get('value') === false, 'the initial value has been bound'); + + _emberMetal.run(function () { + return bar.destroy(); + }); + + ok(foo.get('value'), 'foo is synced when the binding is updated in the willDestroy hook'); + }); +}); +enifed('ember-runtime/tests/system/object/destroy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/destroy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/destroy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/detectInstance_test', ['exports', 'ember-runtime/system/object'], function (exports, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/detectInstance'); + + QUnit.test('detectInstance detects instances correctly', function () { + var A = _emberRuntimeSystemObject.default.extend(); + var B = A.extend(); + var C = A.extend(); + + var o = _emberRuntimeSystemObject.default.create(); + var a = A.create(); + var b = B.create(); + var c = C.create(); + + ok(_emberRuntimeSystemObject.default.detectInstance(o), 'o is an instance of EmberObject'); + ok(_emberRuntimeSystemObject.default.detectInstance(a), 'a is an instance of EmberObject'); + ok(_emberRuntimeSystemObject.default.detectInstance(b), 'b is an instance of EmberObject'); + ok(_emberRuntimeSystemObject.default.detectInstance(c), 'c is an instance of EmberObject'); + + ok(!A.detectInstance(o), 'o is not an instance of A'); + ok(A.detectInstance(a), 'a is an instance of A'); + ok(A.detectInstance(b), 'b is an instance of A'); + ok(A.detectInstance(c), 'c is an instance of A'); + + ok(!B.detectInstance(o), 'o is not an instance of B'); + ok(!B.detectInstance(a), 'a is not an instance of B'); + ok(B.detectInstance(b), 'b is an instance of B'); + ok(!B.detectInstance(c), 'c is not an instance of B'); + + ok(!C.detectInstance(o), 'o is not an instance of C'); + ok(!C.detectInstance(a), 'a is not an instance of C'); + ok(!C.detectInstance(b), 'b is not an instance of C'); + ok(C.detectInstance(c), 'c is an instance of C'); + }); +}); +enifed('ember-runtime/tests/system/object/detectInstance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/detectInstance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/detectInstance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/detect_test', ['exports', 'ember-runtime/system/object'], function (exports, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/detect'); + + QUnit.test('detect detects classes correctly', function () { + var A = _emberRuntimeSystemObject.default.extend(); + var B = A.extend(); + var C = A.extend(); + + ok(_emberRuntimeSystemObject.default.detect(_emberRuntimeSystemObject.default), 'EmberObject is an EmberObject class'); + ok(_emberRuntimeSystemObject.default.detect(A), 'A is an EmberObject class'); + ok(_emberRuntimeSystemObject.default.detect(B), 'B is an EmberObject class'); + ok(_emberRuntimeSystemObject.default.detect(C), 'C is an EmberObject class'); + + ok(!A.detect(_emberRuntimeSystemObject.default), 'EmberObject is not an A class'); + ok(A.detect(A), 'A is an A class'); + ok(A.detect(B), 'B is an A class'); + ok(A.detect(C), 'C is an A class'); + + ok(!B.detect(_emberRuntimeSystemObject.default), 'EmberObject is not a B class'); + ok(!B.detect(A), 'A is not a B class'); + ok(B.detect(B), 'B is a B class'); + ok(!B.detect(C), 'C is not a B class'); + + ok(!C.detect(_emberRuntimeSystemObject.default), 'EmberObject is not a C class'); + ok(!C.detect(A), 'A is not a C class'); + ok(!C.detect(B), 'B is not a C class'); + ok(C.detect(C), 'C is a C class'); + }); +}); +enifed('ember-runtime/tests/system/object/detect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/detect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/detect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/es-compatibility-test', ['exports', 'ember-runtime/system/object', 'ember-metal'], function (exports, _emberRuntimeSystemObject, _emberMetal) { + 'use strict'; + + QUnit.module('EmberObject ES Compatibility'); + + QUnit.test('extending an Ember.Object', function (assert) { + var calls = []; + + var MyObject = (function (_EmberObject) { + babelHelpers.inherits(MyObject, _EmberObject); + + function MyObject() { + calls.push('constructor'); + _EmberObject.apply(this, arguments); + this.postInitProperty = 'post-init-property'; + } + + MyObject.prototype.init = function init() { + var _EmberObject$prototype$init; + + calls.push('init'); + (_EmberObject$prototype$init = _EmberObject.prototype.init).call.apply(_EmberObject$prototype$init, [this].concat(babelHelpers.slice.call(arguments))); + this.initProperty = 'init-property'; + }; + + return MyObject; + })(_emberRuntimeSystemObject.default); + + var myObject = MyObject.create({ passedProperty: 'passed-property' }); + + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); + assert.equal(myObject.postInitProperty, 'post-init-property', 'constructor property available on instance (create)'); + assert.equal(myObject.initProperty, 'init-property', 'init property available on instance (create)'); + assert.equal(myObject.passedProperty, 'passed-property', 'passed property available on instance (create)'); + + calls = []; + myObject = new MyObject({ passedProperty: 'passed-property' }); + + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); + assert.equal(myObject.postInitProperty, 'post-init-property', 'constructor property available on instance (new)'); + assert.equal(myObject.initProperty, 'init-property', 'init property available on instance (new)'); + assert.equal(myObject.passedProperty, 'passed-property', 'passed property available on instance (new)'); + }); + + QUnit.test('using super', function (assert) { + var calls = []; + + var SuperSuperObject = _emberRuntimeSystemObject.default.extend({ + method: function () { + calls.push('super-super-method'); + } + }); + + var SuperObject = SuperSuperObject.extend({ + method: function () { + this._super(); + calls.push('super-method'); + } + }); + + var MyObject = (function (_SuperObject) { + babelHelpers.inherits(MyObject, _SuperObject); + + function MyObject() { + _SuperObject.apply(this, arguments); + } + + MyObject.prototype.method = function method() { + _SuperObject.prototype.method.call(this); + calls.push('method'); + }; + + return MyObject; + })(SuperObject); + + var myObject = new MyObject(); + myObject.method(); + + assert.deepEqual(calls, ['super-super-method', 'super-method', 'method'], 'chain of prototype methods called with super'); + }); + + QUnit.test('using mixins', function (assert) { + var Mixin1 = _emberMetal.Mixin.create({ + property1: 'data-1' + }); + + var Mixin2 = _emberMetal.Mixin.create({ + property2: 'data-2' + }); + + var MyObject = (function (_EmberObject$extend) { + babelHelpers.inherits(MyObject, _EmberObject$extend); + + function MyObject() { + _EmberObject$extend.apply(this, arguments); + } + + return MyObject; + })(_emberRuntimeSystemObject.default.extend(Mixin1, Mixin2)); + + var myObject = new MyObject(); + assert.equal(myObject.property1, 'data-1', 'includes the first mixin'); + assert.equal(myObject.property2, 'data-2', 'includes the second mixin'); + }); + + QUnit.test('using instanceof', function (assert) { + var MyObject = (function (_EmberObject2) { + babelHelpers.inherits(MyObject, _EmberObject2); + + function MyObject() { + _EmberObject2.apply(this, arguments); + } + + return MyObject; + })(_emberRuntimeSystemObject.default); + + var myObject1 = MyObject.create(); + var myObject2 = new MyObject(); + + assert.ok(myObject1 instanceof MyObject); + assert.ok(myObject1 instanceof _emberRuntimeSystemObject.default); + + assert.ok(myObject2 instanceof MyObject); + assert.ok(myObject2 instanceof _emberRuntimeSystemObject.default); + }); + + QUnit.test('extending an ES subclass of EmberObject', function (assert) { + var calls = []; + + var SubEmberObject = (function (_EmberObject3) { + babelHelpers.inherits(SubEmberObject, _EmberObject3); + + function SubEmberObject() { + calls.push('constructor'); + _EmberObject3.apply(this, arguments); + } + + SubEmberObject.prototype.init = function init() { + var _EmberObject3$prototype$init; + + calls.push('init'); + (_EmberObject3$prototype$init = _EmberObject3.prototype.init).call.apply(_EmberObject3$prototype$init, [this].concat(babelHelpers.slice.call(arguments))); + }; + + return SubEmberObject; + })(_emberRuntimeSystemObject.default); + + var MyObject = (function (_SubEmberObject) { + babelHelpers.inherits(MyObject, _SubEmberObject); + + function MyObject() { + _SubEmberObject.apply(this, arguments); + } + + return MyObject; + })(SubEmberObject); + + MyObject.create(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); + + calls = []; + new MyObject(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); + }); + + // TODO: Needs to be fixed. Currently only `init` is called. + QUnit.skip('calling extend on an ES subclass of EmberObject', function (assert) { + var calls = []; + + var SubEmberObject = (function (_EmberObject4) { + babelHelpers.inherits(SubEmberObject, _EmberObject4); + + function SubEmberObject() { + calls.push('constructor'); + _EmberObject4.apply(this, arguments); + } + + SubEmberObject.prototype.init = function init() { + var _EmberObject4$prototype$init; + + calls.push('init'); + (_EmberObject4$prototype$init = _EmberObject4.prototype.init).call.apply(_EmberObject4$prototype$init, [this].concat(babelHelpers.slice.call(arguments))); + }; + + return SubEmberObject; + })(_emberRuntimeSystemObject.default); + + var MyObject = SubEmberObject.extend({}); + + MyObject.create(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); + + calls = []; + new MyObject(); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); + }); +}); +enifed('ember-runtime/tests/system/object/es-compatibility-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/es-compatibility-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/es-compatibility-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/events_test', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/evented'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsEvented) { + 'use strict'; + + QUnit.module('Object events'); + + QUnit.test('a listener can be added to an object', function () { + var count = 0; + var F = function () { + count++; + }; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.on('event!', F); + obj.trigger('event!'); + + equal(count, 1, 'the event was triggered'); + + obj.trigger('event!'); + + equal(count, 2, 'the event was triggered'); + }); + + QUnit.test('a listener can be added and removed automatically the first time it is triggered', function () { + var count = 0; + var F = function () { + count++; + }; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.one('event!', F); + obj.trigger('event!'); + + equal(count, 1, 'the event was triggered'); + + obj.trigger('event!'); + + equal(count, 1, 'the event was not triggered again'); + }); + + QUnit.test('triggering an event can have arguments', function () { + var self = undefined, + args = undefined; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.on('event!', function () { + args = [].slice.call(arguments); + self = this; + }); + + obj.trigger('event!', 'foo', 'bar'); + + deepEqual(args, ['foo', 'bar']); + equal(self, obj); + }); + + QUnit.test('a listener can be added and removed automatically and have arguments', function () { + var self = undefined, + args = undefined; + var count = 0; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.one('event!', function () { + args = [].slice.call(arguments); + self = this; + count++; + }); + + obj.trigger('event!', 'foo', 'bar'); + + deepEqual(args, ['foo', 'bar']); + equal(self, obj); + equal(count, 1, 'the event is triggered once'); + + obj.trigger('event!', 'baz', 'bat'); + + deepEqual(args, ['foo', 'bar']); + equal(count, 1, 'the event was not triggered again'); + equal(self, obj); + }); + + QUnit.test('binding an event can specify a different target', function () { + var self = undefined, + args = undefined; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + var target = {}; + + obj.on('event!', target, function () { + args = [].slice.call(arguments); + self = this; + }); + + obj.trigger('event!', 'foo', 'bar'); + + deepEqual(args, ['foo', 'bar']); + equal(self, target); + }); + + QUnit.test('a listener registered with one can take method as string and can be added with different target', function () { + var count = 0; + var target = {}; + target.fn = function () { + count++; + }; + + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + + obj.one('event!', target, 'fn'); + obj.trigger('event!'); + + equal(count, 1, 'the event was triggered'); + + obj.trigger('event!'); + + equal(count, 1, 'the event was not triggered again'); + }); + + QUnit.test('a listener registered with one can be removed with off', function () { + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default, { + F: function () {} + }).create(); + var F = function () {}; + + obj.one('event!', F); + obj.one('event!', obj, 'F'); + + equal(obj.has('event!'), true, 'has events'); + + obj.off('event!', F); + obj.off('event!', obj, 'F'); + + equal(obj.has('event!'), false, 'has no more events'); + }); + + QUnit.test('adding and removing listeners should be chainable', function () { + var obj = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsEvented.default).create(); + var F = function () {}; + + var ret = obj.on('event!', F); + equal(ret, obj, '#on returns self'); + + ret = obj.off('event!', F); + equal(ret, obj, '#off returns self'); + + ret = obj.one('event!', F); + equal(ret, obj, '#one returns self'); + }); +}); +enifed('ember-runtime/tests/system/object/events_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/events_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/events_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/extend_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('EmberObject.extend'); + + QUnit.test('Basic extend', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ foo: 'BAR' }); + ok(SomeClass.isClass, 'A class has isClass of true'); + var obj = new SomeClass(); + equal(obj.foo, 'BAR'); + }); + + QUnit.test('Sub-subclass', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ foo: 'BAR' }); + var AnotherClass = SomeClass.extend({ bar: 'FOO' }); + var obj = new AnotherClass(); + equal(obj.foo, 'BAR'); + equal(obj.bar, 'FOO'); + }); + + QUnit.test('Overriding a method several layers deep', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ + fooCnt: 0, + foo: function () { + this.fooCnt++; + }, + + barCnt: 0, + bar: function () { + this.barCnt++; + } + }); + + var AnotherClass = SomeClass.extend({ + barCnt: 0, + bar: function () { + this.barCnt++; + this._super.apply(this, arguments); + } + }); + + var FinalClass = AnotherClass.extend({ + fooCnt: 0, + foo: function () { + this.fooCnt++; + this._super.apply(this, arguments); + } + }); + + var obj = new FinalClass(); + obj.foo(); + obj.bar(); + equal(obj.fooCnt, 2, 'should invoke both'); + equal(obj.barCnt, 2, 'should invoke both'); + + // Try overriding on create also + obj = FinalClass.extend({ + foo: function () { + this.fooCnt++; + this._super.apply(this, arguments); + } + }).create(); + + obj.foo(); + obj.bar(); + equal(obj.fooCnt, 3, 'should invoke final as well'); + equal(obj.barCnt, 2, 'should invoke both'); + }); + + QUnit.test('With concatenatedProperties', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend({ things: 'foo', concatenatedProperties: ['things'] }); + var AnotherClass = SomeClass.extend({ things: 'bar' }); + var YetAnotherClass = SomeClass.extend({ things: 'baz' }); + var some = new SomeClass(); + var another = new AnotherClass(); + var yetAnother = new YetAnotherClass(); + deepEqual(some.get('things'), ['foo'], 'base class should have just its value'); + deepEqual(another.get('things'), ['foo', 'bar'], 'subclass should have base class\' and its own'); + deepEqual(yetAnother.get('things'), ['foo', 'baz'], 'subclass should have base class\' and its own'); + }); + + QUnit.test('With concatenatedProperties class properties', function () { + var SomeClass = _emberRuntimeSystemObject.default.extend(); + SomeClass.reopenClass({ + concatenatedProperties: ['things'], + things: 'foo' + }); + var AnotherClass = SomeClass.extend(); + AnotherClass.reopenClass({ things: 'bar' }); + var YetAnotherClass = SomeClass.extend(); + YetAnotherClass.reopenClass({ things: 'baz' }); + var some = new SomeClass(); + var another = new AnotherClass(); + var yetAnother = new YetAnotherClass(); + deepEqual(_emberMetal.get(some.constructor, 'things'), ['foo'], 'base class should have just its value'); + deepEqual(_emberMetal.get(another.constructor, 'things'), ['foo', 'bar'], 'subclass should have base class\' and its own'); + deepEqual(_emberMetal.get(yetAnother.constructor, 'things'), ['foo', 'baz'], 'subclass should have base class\' and its own'); + }); +}); +enifed('ember-runtime/tests/system/object/extend_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/extend_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/extend_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/observer_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('EmberObject observer'); + + _internalTestHelpers.testBoth('observer on class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = new MyClass(); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer on subclass', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var Subclass = MyClass.extend({ + foo: _emberMetal.observer('baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = new Subclass(); + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer on instance', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }).create({ + count: 0 + }); + + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer on instance overriding class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj = MyClass.extend({ + foo: _emberMetal.observer('baz', function () { + // <-- change property we observe + set(this, 'count', get(this, 'count') + 1); + }) + }).create(); + + equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + set(obj, 'bar', 'BAZ'); + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + + set(obj, 'baz', 'BAZ'); + equal(get(obj, 'count'), 1, 'should invoke observer after change'); + }); + + _internalTestHelpers.testBoth('observer should not fire after being destroyed', function (get, set) { + var obj = _emberRuntimeSystemObject.default.extend({ + count: 0, + foo: _emberMetal.observer('bar', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }).create(); + + equal(get(obj, 'count'), 0, 'precond - should not invoke observer immediately'); + + _emberMetal.run(function () { + return obj.destroy(); + }); + + expectAssertion(function () { + set(obj, 'bar', 'BAZ'); + }, 'calling set on destroyed object: ' + obj + '.bar = BAZ'); + + equal(get(obj, 'count'), 0, 'should not invoke observer after change'); + }); + // .......................................................... + // COMPLEX PROPERTIES + // + + _internalTestHelpers.testBoth('chain observer on class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj1 = MyClass.create({ + bar: { baz: 'biff' } + }); + + var obj2 = MyClass.create({ + bar: { baz: 'biff2' } + }); + + equal(get(obj1, 'count'), 0, 'should not invoke yet'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj1, 'bar'), 'baz', 'BIFF1'); + equal(get(obj1, 'count'), 1, 'should invoke observer on obj1'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj2, 'bar'), 'baz', 'BIFF2'); + equal(get(obj1, 'count'), 1, 'should not invoke again'); + equal(get(obj2, 'count'), 1, 'should invoke observer on obj2'); + }); + + _internalTestHelpers.testBoth('chain observer on class', function (get, set) { + var MyClass = _emberRuntimeSystemObject.default.extend({ + count: 0, + + foo: _emberMetal.observer('bar.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }); + + var obj1 = MyClass.extend().create({ + bar: { baz: 'biff' } + }); + + var obj2 = MyClass.extend({ + foo: _emberMetal.observer('bar2.baz', function () { + set(this, 'count', get(this, 'count') + 1); + }) + }).create({ + bar: { baz: 'biff2' }, + bar2: { baz: 'biff3' } + }); + + equal(get(obj1, 'count'), 0, 'should not invoke yet'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj1, 'bar'), 'baz', 'BIFF1'); + equal(get(obj1, 'count'), 1, 'should invoke observer on obj1'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj2, 'bar'), 'baz', 'BIFF2'); + equal(get(obj1, 'count'), 1, 'should not invoke again'); + equal(get(obj2, 'count'), 0, 'should not invoke yet'); + + set(get(obj2, 'bar2'), 'baz', 'BIFF3'); + equal(get(obj1, 'count'), 1, 'should not invoke again'); + equal(get(obj2, 'count'), 1, 'should invoke observer on obj2'); + }); + + _internalTestHelpers.testBoth('chain observer on class that has a reference to an uninitialized object will finish chains that reference it', function (get, set) { + var changed = false; + + var ChildClass = _emberRuntimeSystemObject.default.extend({ + parent: null, + parentOneTwoDidChange: _emberMetal.observer('parent.one.two', function () { + changed = true; + }) + }); + + var ParentClass = _emberRuntimeSystemObject.default.extend({ + one: { + two: 'old' + }, + init: function () { + this.child = ChildClass.create({ + parent: this + }); + } + }); + + var parent = new ParentClass(); + + equal(changed, false, 'precond'); + + parent.set('one.two', 'new'); + + equal(changed, true, 'child should have been notified of change to path'); + + parent.set('one', { two: 'newer' }); + + equal(changed, true, 'child should have been notified of change to path'); + }); +}); +enifed('ember-runtime/tests/system/object/observer_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/observer_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/observer_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/reopenClass_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/reopenClass'); + + QUnit.test('adds new properties to subclass', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + Subclass.reopenClass({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + equal(Subclass.foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(Subclass, 'bar'), 'BAR', 'Adds property'); + }); + + QUnit.test('class properties inherited by subclasses', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + Subclass.reopenClass({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + var SubSub = Subclass.extend(); + + equal(SubSub.foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(SubSub, 'bar'), 'BAR', 'Adds property'); + }); +}); +enifed('ember-runtime/tests/system/object/reopenClass_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/reopenClass_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/reopenClass_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/reopen_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/core_object/reopen'); + + QUnit.test('adds new properties to subclass instance', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + Subclass.reopen({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + equal(new Subclass().foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(new Subclass(), 'bar'), 'BAR', 'Adds property'); + }); + + QUnit.test('reopened properties inherited by subclasses', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + var SubSub = Subclass.extend(); + + Subclass.reopen({ + foo: function () { + return 'FOO'; + }, + bar: 'BAR' + }); + + equal(new SubSub().foo(), 'FOO', 'Adds method'); + equal(_emberMetal.get(new SubSub(), 'bar'), 'BAR', 'Adds property'); + }); + + QUnit.test('allows reopening already instantiated classes', function () { + var Subclass = _emberRuntimeSystemObject.default.extend(); + + Subclass.create(); + + Subclass.reopen({ + trololol: true + }); + + equal(Subclass.create().get('trololol'), true, 'reopen works'); + }); +}); +enifed('ember-runtime/tests/system/object/reopen_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/reopen_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/reopen_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/strict-mode-test', ['exports', 'ember-runtime/system/object'], function (exports, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('strict mode tests'); + + QUnit.test('__superWrapper does not throw errors in strict mode', function () { + var Foo = _emberRuntimeSystemObject.default.extend({ + blah: function () { + return 'foo'; + } + }); + + var Bar = Foo.extend({ + blah: function () { + return 'bar'; + }, + + callBlah: function () { + var blah = this.blah; + + return blah(); + } + }); + + var bar = Bar.create(); + + equal(bar.callBlah(), 'bar', 'can call local function without call/apply'); + }); +}); +enifed('ember-runtime/tests/system/object/strict-mode-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/strict-mode-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/strict-mode-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/subclasses_test', ['exports', 'ember-metal', 'ember-runtime/system/object'], function (exports, _emberMetal, _emberRuntimeSystemObject) { + 'use strict'; + + QUnit.module('system/object/subclasses'); + + QUnit.test('chains should copy forward to subclasses when prototype created', function () { + var ObjectWithChains = undefined, + objWithChains = undefined, + SubWithChains = undefined, + SubSub = undefined, + subSub = undefined; + _emberMetal.run(function () { + ObjectWithChains = _emberRuntimeSystemObject.default.extend({ + obj: { + a: 'a', + hi: 'hi' + }, + aBinding: 'obj.a' // add chain + }); + + var deprecationMessage = /`Ember.Binding` is deprecated/; + + expectDeprecation(function () { + // realize prototype + objWithChains = ObjectWithChains.create(); + }, deprecationMessage); + + // should not copy chains from parent yet + SubWithChains = ObjectWithChains.extend({ + hiBinding: 'obj.hi', // add chain + hello: _emberMetal.computed(function () { + return this.get('obj.hi') + ' world'; + }).property('hi'), // observe chain + greetingBinding: 'hello' + }); + + SubSub = SubWithChains.extend(); + + expectDeprecation(function () { + // should realize prototypes and copy forward chains + subSub = SubSub.create(); + }, deprecationMessage); + }); + equal(subSub.get('greeting'), 'hi world'); + _emberMetal.run(function () { + return objWithChains.set('obj.hi', 'hello'); + }); + equal(subSub.get('greeting'), 'hello world'); + }); +}); +enifed('ember-runtime/tests/system/object/subclasses_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/subclasses_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/subclasses_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object/toString_test', ['exports', 'ember-utils', 'ember-environment', 'ember-runtime/system/object', 'ember-runtime/system/namespace'], function (exports, _emberUtils, _emberEnvironment, _emberRuntimeSystemObject, _emberRuntimeSystemNamespace) { + 'use strict'; + + var originalLookup = _emberEnvironment.context.lookup; + var lookup = undefined; + + QUnit.module('system/object/toString', { + setup: function () { + _emberEnvironment.context.lookup = lookup = {}; + }, + teardown: function () { + _emberEnvironment.context.lookup = originalLookup; + } + }); + + QUnit.test('NAME_KEY slot is present on Class', function () { + ok(_emberRuntimeSystemObject.default.extend().hasOwnProperty(_emberUtils.NAME_KEY), 'Ember Class\'s have a NAME_KEY slot'); + }); + + QUnit.test('toString() returns the same value if called twice', function () { + var Foo = _emberRuntimeSystemNamespace.default.create(); + Foo.toString = function () { + return 'Foo'; + }; + + Foo.Bar = _emberRuntimeSystemObject.default.extend(); + + equal(Foo.Bar.toString(), 'Foo.Bar'); + equal(Foo.Bar.toString(), 'Foo.Bar'); + + var obj = Foo.Bar.create(); + + equal(obj.toString(), ''); + equal(obj.toString(), ''); + + equal(Foo.Bar.toString(), 'Foo.Bar'); + }); + + QUnit.test('toString on a class returns a useful value when nested in a namespace', function () { + var obj = undefined; + + var Foo = _emberRuntimeSystemNamespace.default.create(); + Foo.toString = function () { + return 'Foo'; + }; + + Foo.Bar = _emberRuntimeSystemObject.default.extend(); + equal(Foo.Bar.toString(), 'Foo.Bar'); + + obj = Foo.Bar.create(); + equal(obj.toString(), ''); + + Foo.Baz = Foo.Bar.extend(); + equal(Foo.Baz.toString(), 'Foo.Baz'); + + obj = Foo.Baz.create(); + equal(obj.toString(), ''); + + obj = Foo.Bar.create(); + equal(obj.toString(), ''); + }); + + QUnit.test('toString on a namespace finds the namespace in lookup', function () { + var Foo = lookup.Foo = _emberRuntimeSystemNamespace.default.create(); + + equal(Foo.toString(), 'Foo'); + }); + + QUnit.test('toString on a namespace finds the namespace in lookup', function () { + var Foo = lookup.Foo = _emberRuntimeSystemNamespace.default.create(); + var obj = undefined; + + Foo.Bar = _emberRuntimeSystemObject.default.extend(); + + equal(Foo.Bar.toString(), 'Foo.Bar'); + + obj = Foo.Bar.create(); + equal(obj.toString(), ''); + }); + + QUnit.test('toString on a namespace falls back to modulePrefix, if defined', function () { + var Foo = _emberRuntimeSystemNamespace.default.create({ modulePrefix: 'foo' }); + + equal(Foo.toString(), 'foo'); + }); + + QUnit.test('toString includes toStringExtension if defined', function () { + var Foo = _emberRuntimeSystemObject.default.extend({ + toStringExtension: function () { + return 'fooey'; + } + }); + var foo = Foo.create(); + var Bar = _emberRuntimeSystemObject.default.extend({}); + var bar = Bar.create(); + + // simulate these classes being defined on a Namespace + Foo[_emberUtils.NAME_KEY] = 'Foo'; + Bar[_emberUtils.NAME_KEY] = 'Bar'; + + equal(bar.toString(), '', 'does not include toStringExtension part'); + equal(foo.toString(), '', 'Includes toStringExtension result'); + }); +}); +enifed('ember-runtime/tests/system/object/toString_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object/toString_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object/toString_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/object_proxy_test', ['exports', 'ember-metal', 'internal-test-helpers', 'ember-runtime/system/object_proxy'], function (exports, _emberMetal, _internalTestHelpers, _emberRuntimeSystemObject_proxy) { + 'use strict'; + + QUnit.module('ObjectProxy'); + + _internalTestHelpers.testBoth('should not proxy properties passed to create', function (get, set) { + var Proxy = _emberRuntimeSystemObject_proxy.default.extend({ + cp: _emberMetal.computed({ + get: function (key) { + return this._cp; + }, + set: function (key, value) { + this._cp = value; + return this._cp; + } + }) + }); + var proxy = Proxy.create({ + prop: 'Foo', + cp: 'Bar' + }); + + equal(get(proxy, 'prop'), 'Foo', 'should not have tried to proxy set'); + equal(proxy._cp, 'Bar', 'should use CP setter'); + }); + + _internalTestHelpers.testBoth('should proxy properties to content', function (get, set) { + var content = { + firstName: 'Tom', + lastName: 'Dale', + unknownProperty: function (key) { + return key + ' unknown'; + } + }; + var proxy = _emberRuntimeSystemObject_proxy.default.create(); + + equal(get(proxy, 'firstName'), undefined, 'get on proxy without content should return undefined'); + expectAssertion(function () { + set(proxy, 'firstName', 'Foo'); + }, /Cannot delegate set\('firstName', Foo\) to the 'content'/i); + + set(proxy, 'content', content); + + equal(get(proxy, 'firstName'), 'Tom', 'get on proxy with content should forward to content'); + equal(get(proxy, 'lastName'), 'Dale', 'get on proxy with content should forward to content'); + equal(get(proxy, 'foo'), 'foo unknown', 'get on proxy with content should forward to content'); + + set(proxy, 'lastName', 'Huda'); + + equal(get(content, 'lastName'), 'Huda', 'content should have new value from set on proxy'); + equal(get(proxy, 'lastName'), 'Huda', 'proxy should have new value from set on proxy'); + + set(proxy, 'content', { firstName: 'Yehuda', lastName: 'Katz' }); + + equal(get(proxy, 'firstName'), 'Yehuda', 'proxy should reflect updated content'); + equal(get(proxy, 'lastName'), 'Katz', 'proxy should reflect updated content'); + }); + + _internalTestHelpers.testBoth('should work with watched properties', function (get, set) { + var content1 = { firstName: 'Tom', lastName: 'Dale' }; + var content2 = { firstName: 'Yehuda', lastName: 'Katz' }; + var count = 0; + var last = undefined; + + var Proxy = _emberRuntimeSystemObject_proxy.default.extend({ + fullName: _emberMetal.computed(function () { + var firstName = this.get('firstName'); + var lastName = this.get('lastName'); + + if (firstName && lastName) { + return firstName + ' ' + lastName; + } + return firstName || lastName; + }).property('firstName', 'lastName') + }); + + var proxy = Proxy.create(); + + _emberMetal.addObserver(proxy, 'fullName', function () { + last = get(proxy, 'fullName'); + count++; + }); + + // proxy without content returns undefined + equal(get(proxy, 'fullName'), undefined); + + // setting content causes all watched properties to change + set(proxy, 'content', content1); + // both dependent keys changed + equal(count, 2); + equal(last, 'Tom Dale'); + + // setting property in content causes proxy property to change + set(content1, 'lastName', 'Huda'); + equal(count, 3); + equal(last, 'Tom Huda'); + + // replacing content causes all watched properties to change + set(proxy, 'content', content2); + // both dependent keys changed + equal(count, 5); + equal(last, 'Yehuda Katz'); + // content1 is no longer watched + ok(!_emberMetal.isWatching(content1, 'firstName'), 'not watching firstName'); + ok(!_emberMetal.isWatching(content1, 'lastName'), 'not watching lastName'); + + // setting property in new content + set(content2, 'firstName', 'Tomhuda'); + equal(last, 'Tomhuda Katz'); + equal(count, 6); + + // setting property in proxy syncs with new content + set(proxy, 'lastName', 'Katzdale'); + equal(count, 7); + equal(last, 'Tomhuda Katzdale'); + equal(get(content2, 'firstName'), 'Tomhuda'); + equal(get(content2, 'lastName'), 'Katzdale'); + }); + + QUnit.test('set and get should work with paths', function () { + var content = { foo: { bar: 'baz' } }; + var proxy = _emberRuntimeSystemObject_proxy.default.create({ content: content }); + var count = 0; + + proxy.set('foo.bar', 'hello'); + equal(proxy.get('foo.bar'), 'hello'); + equal(proxy.get('content.foo.bar'), 'hello'); + + proxy.addObserver('foo.bar', function () { + count++; + }); + + proxy.set('foo.bar', 'bye'); + + equal(count, 1); + equal(proxy.get('foo.bar'), 'bye'); + equal(proxy.get('content.foo.bar'), 'bye'); + }); + + _internalTestHelpers.testBoth('should transition between watched and unwatched strategies', function (get, set) { + var content = { foo: 'foo' }; + var proxy = _emberRuntimeSystemObject_proxy.default.create({ content: content }); + var count = 0; + + function observer() { + count++; + } + + equal(get(proxy, 'foo'), 'foo'); + + set(content, 'foo', 'bar'); + + equal(get(proxy, 'foo'), 'bar'); + + set(proxy, 'foo', 'foo'); + + equal(get(content, 'foo'), 'foo'); + equal(get(proxy, 'foo'), 'foo'); + + _emberMetal.addObserver(proxy, 'foo', observer); + + equal(count, 0); + equal(get(proxy, 'foo'), 'foo'); + + set(content, 'foo', 'bar'); + + equal(count, 1); + equal(get(proxy, 'foo'), 'bar'); + + set(proxy, 'foo', 'foo'); + + equal(count, 2); + equal(get(content, 'foo'), 'foo'); + equal(get(proxy, 'foo'), 'foo'); + + _emberMetal.removeObserver(proxy, 'foo', observer); + + set(content, 'foo', 'bar'); + + equal(get(proxy, 'foo'), 'bar'); + + set(proxy, 'foo', 'foo'); + + equal(get(content, 'foo'), 'foo'); + equal(get(proxy, 'foo'), 'foo'); + }); + + _internalTestHelpers.testBoth('setting `undefined` to a proxied content property should override its existing value', function (get, set) { + var proxyObject = _emberRuntimeSystemObject_proxy.default.create({ + content: { + prop: 'emberjs' + } + }); + set(proxyObject, 'prop', undefined); + equal(get(proxyObject, 'prop'), undefined, 'sets the `undefined` value to the proxied content'); + }); +}); +enifed('ember-runtime/tests/system/object_proxy_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/object_proxy_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/object_proxy_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/camelize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.camelize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.camelize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.camelize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('camelize normal string', function () { + deepEqual(_emberRuntimeSystemString.camelize('my favorite items'), 'myFavoriteItems'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.camelize(), 'myFavoriteItems'); + } + }); + + QUnit.test('camelize capitalized string', function () { + deepEqual(_emberRuntimeSystemString.camelize('I Love Ramen'), 'iLoveRamen'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('I Love Ramen'.camelize(), 'iLoveRamen'); + } + }); + + QUnit.test('camelize dasherized string', function () { + deepEqual(_emberRuntimeSystemString.camelize('css-class-name'), 'cssClassName'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.camelize(), 'cssClassName'); + } + }); + + QUnit.test('camelize underscored string', function () { + deepEqual(_emberRuntimeSystemString.camelize('action_name'), 'actionName'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.camelize(), 'actionName'); + } + }); + + QUnit.test('camelize dot notation string', function () { + deepEqual(_emberRuntimeSystemString.camelize('action.name'), 'actionName'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action.name'.camelize(), 'actionName'); + } + }); + + QUnit.test('does nothing with camelcased string', function () { + deepEqual(_emberRuntimeSystemString.camelize('innerHTML'), 'innerHTML'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.camelize(), 'innerHTML'); + } + }); + + QUnit.test('camelize namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.camelize('PrivateDocs/OwnerInvoice'), 'privateDocs/ownerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.camelize(), 'privateDocs/ownerInvoice'); + } + }); + + QUnit.test('camelize namespaced underscored string', function () { + deepEqual(_emberRuntimeSystemString.camelize('private_docs/owner_invoice'), 'privateDocs/ownerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private_docs/owner_invoice'.camelize(), 'privateDocs/ownerInvoice'); + } + }); + + QUnit.test('camelize namespaced dasherized string', function () { + deepEqual(_emberRuntimeSystemString.camelize('private-docs/owner-invoice'), 'privateDocs/ownerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private-docs/owner-invoice'.camelize(), 'privateDocs/ownerInvoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/camelize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/camelize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/camelize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/capitalize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.capitalize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.capitalize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.capitalize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('capitalize normal string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('my favorite items'), 'My favorite items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.capitalize(), 'My favorite items'); + } + }); + + QUnit.test('capitalize dasherized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('css-class-name'), 'Css-class-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.capitalize(), 'Css-class-name'); + } + }); + + QUnit.test('capitalize underscored string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('action_name'), 'Action_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.capitalize(), 'Action_name'); + } + }); + + QUnit.test('capitalize camelcased string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('innerHTML'), 'InnerHTML'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.capitalize(), 'InnerHTML'); + } + }); + + QUnit.test('does nothing with capitalized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('Capitalized string'), 'Capitalized string'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('Capitalized string'.capitalize(), 'Capitalized string'); + } + }); + + QUnit.test('capitalize namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('privateDocs/ownerInvoice'), 'PrivateDocs/OwnerInvoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.capitalize(), 'PrivateDocs/OwnerInvoice'); + } + }); + + QUnit.test('capitalize namespaced underscored string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('private_docs/owner_invoice'), 'Private_docs/Owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private_docs/owner_invoice'.capitalize(), 'Private_docs/Owner_invoice'); + } + }); + + QUnit.test('capitalize namespaced dasherized string', function () { + deepEqual(_emberRuntimeSystemString.capitalize('private-docs/owner-invoice'), 'Private-docs/Owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private-docs/owner-invoice'.capitalize(), 'Private-docs/Owner-invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/capitalize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/capitalize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/capitalize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/classify_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.classify'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.classify is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.classify, 'String.prototype helper disabled'); + }); + } + + function test(given, expected, description) { + QUnit.test(description, function () { + deepEqual(_emberRuntimeSystemString.classify(given), expected); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual(given.classify(), expected); + } + }); + } + + test('my favorite items', 'MyFavoriteItems', 'classify normal string'); + test('css-class-name', 'CssClassName', 'classify dasherized string'); + test('action_name', 'ActionName', 'classify underscored string'); + test('privateDocs/ownerInvoice', 'PrivateDocs/OwnerInvoice', 'classify namespaced camelized string'); + test('private_docs/owner_invoice', 'PrivateDocs/OwnerInvoice', 'classify namespaced underscored string'); + test('private-docs/owner-invoice', 'PrivateDocs/OwnerInvoice', 'classify namespaced dasherized string'); + test('-view-registry', '_ViewRegistry', 'classify prefixed dasherized string'); + test('components/-text-field', 'Components/_TextField', 'classify namespaced prefixed dasherized string'); + test('_Foo_Bar', '_FooBar', 'classify underscore-prefixed underscored string'); + test('_Foo-Bar', '_FooBar', 'classify underscore-prefixed dasherized string'); + test('_foo/_bar', '_Foo/_Bar', 'classify underscore-prefixed-namespaced underscore-prefixed string'); + test('-foo/_bar', '_Foo/_Bar', 'classify dash-prefixed-namespaced underscore-prefixed string'); + test('-foo/-bar', '_Foo/_Bar', 'classify dash-prefixed-namespaced dash-prefixed string'); + test('InnerHTML', 'InnerHTML', 'does nothing with classified string'); + test('_FooBar', '_FooBar', 'does nothing with classified prefixed string'); +}); +enifed('ember-runtime/tests/system/string/classify_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/classify_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/classify_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/dasherize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.dasherize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.dasherize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.dasherize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('dasherize normal string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('my favorite items'), 'my-favorite-items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.dasherize(), 'my-favorite-items'); + } + }); + + QUnit.test('does nothing with dasherized string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('css-class-name'), 'css-class-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.dasherize(), 'css-class-name'); + } + }); + + QUnit.test('dasherize underscored string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('action_name'), 'action-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.dasherize(), 'action-name'); + } + }); + + QUnit.test('dasherize camelcased string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('innerHTML'), 'inner-html'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.dasherize(), 'inner-html'); + } + }); + + QUnit.test('dasherize string that is the property name of Object.prototype', function () { + deepEqual(_emberRuntimeSystemString.dasherize('toString'), 'to-string'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('toString'.dasherize(), 'to-string'); + } + }); + + QUnit.test('dasherize namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('PrivateDocs/OwnerInvoice'), 'private-docs/owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.dasherize(), 'private-docs/owner-invoice'); + } + }); + + QUnit.test('dasherize namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('privateDocs/ownerInvoice'), 'private-docs/owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.dasherize(), 'private-docs/owner-invoice'); + } + }); + + QUnit.test('dasherize namespaced underscored string', function () { + deepEqual(_emberRuntimeSystemString.dasherize('private_docs/owner_invoice'), 'private-docs/owner-invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private_docs/owner_invoice'.dasherize(), 'private-docs/owner-invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/dasherize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/dasherize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/dasherize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/decamelize_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.decamelize'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.decamelize is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.decamelize, 'String.prototype helper disabled'); + }); + } + + QUnit.test('does nothing with normal string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('my favorite items'), 'my favorite items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.decamelize(), 'my favorite items'); + } + }); + + QUnit.test('does nothing with dasherized string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('css-class-name'), 'css-class-name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.decamelize(), 'css-class-name'); + } + }); + + QUnit.test('does nothing with underscored string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('action_name'), 'action_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.decamelize(), 'action_name'); + } + }); + + QUnit.test('converts a camelized string into all lower case separated by underscores.', function () { + deepEqual(_emberRuntimeSystemString.decamelize('innerHTML'), 'inner_html'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.decamelize(), 'inner_html'); + } + }); + + QUnit.test('decamelizes strings with numbers', function () { + deepEqual(_emberRuntimeSystemString.decamelize('size160Url'), 'size160_url'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('size160Url'.decamelize(), 'size160_url'); + } + }); + + QUnit.test('decamelize namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('PrivateDocs/OwnerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.decamelize(), 'private_docs/owner_invoice'); + } + }); + + QUnit.test('decamelize namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.decamelize('privateDocs/ownerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.decamelize(), 'private_docs/owner_invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/decamelize_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/decamelize_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/decamelize_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/fmt_string_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.fmt'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.fmt is not modified without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.fmt, 'String.prototype helper disabled'); + }); + } + + QUnit.test('\'Hello %@ %@\'.fmt(\'John\', \'Doe\') => \'Hello John Doe\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('Hello %@ %@', ['John', 'Doe']), 'Hello John Doe'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('Hello %@ %@'.fmt('John', 'Doe'), 'Hello John Doe'); + } + }); + + QUnit.test('\'Hello %@2 %@1\'.fmt(\'John\', \'Doe\') => \'Hello Doe John\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('Hello %@2 %@1', ['John', 'Doe']), 'Hello Doe John'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('Hello %@2 %@1'.fmt('John', 'Doe'), 'Hello Doe John'); + } + }); + + QUnit.test('\'%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01\'.fmt(\'One\', \'Two\', \'Three\', \'Four\', \'Five\', \'Six\', \'Seven\', \'Eight\') => \'Eight Seven Six Five Four Three Two One\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01', ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight']), 'Eight Seven Six Five Four Three Two One'); + + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01'.fmt('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight'), 'Eight Seven Six Five Four Three Two One'); + } + }); + + QUnit.test('\'data: %@\'.fmt({ id: 3 }) => \'data: {id: 3}\'', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('data: %@', [{ id: 3 }]), 'data: {id: 3}'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('data: %@'.fmt({ id: 3 }), 'data: {id: 3}'); + } + }); + + QUnit.test('works with argument form', function () { + expectDeprecation('Ember.String.fmt is deprecated, use ES6 template strings instead.'); + equal(_emberRuntimeSystemString.fmt('%@', 'John'), 'John'); + equal(_emberRuntimeSystemString.fmt('%@ %@', ['John'], 'Doe'), '[John] Doe'); + }); +}); +enifed('ember-runtime/tests/system/string/fmt_string_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/fmt_string_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/fmt_string_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/loc_test', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + var oldString = undefined; + + QUnit.module('EmberStringUtils.loc', { + setup: function () { + oldString = _emberMetal.default.STRINGS; + _emberMetal.default.STRINGS = { + '_Hello World': 'Bonjour le monde', + '_Hello %@': 'Bonjour %@', + '_Hello %@ %@': 'Bonjour %@ %@', + '_Hello %@# %@#': 'Bonjour %@2 %@1' + }; + }, + + teardown: function () { + _emberMetal.default.STRINGS = oldString; + } + }); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.loc is not available without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.loc, 'String.prototype helper disabled'); + }); + } + + QUnit.test('\'_Hello World\'.loc() => \'Bonjour le monde\'', function () { + equal(_emberRuntimeSystemString.loc('_Hello World'), 'Bonjour le monde'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Hello World'.loc(), 'Bonjour le monde'); + } + }); + + QUnit.test('\'_Hello %@ %@\'.loc(\'John\', \'Doe\') => \'Bonjour John Doe\'', function () { + equal(_emberRuntimeSystemString.loc('_Hello %@ %@', ['John', 'Doe']), 'Bonjour John Doe'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Hello %@ %@'.loc('John', 'Doe'), 'Bonjour John Doe'); + } + }); + + QUnit.test('\'_Hello %@# %@#\'.loc(\'John\', \'Doe\') => \'Bonjour Doe John\'', function () { + equal(_emberRuntimeSystemString.loc('_Hello %@# %@#', ['John', 'Doe']), 'Bonjour Doe John'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Hello %@# %@#'.loc('John', 'Doe'), 'Bonjour Doe John'); + } + }); + + QUnit.test('\'_Not In Strings\'.loc() => \'_Not In Strings\'', function () { + equal(_emberRuntimeSystemString.loc('_Not In Strings'), '_Not In Strings'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + equal('_Not In Strings'.loc(), '_Not In Strings'); + } + }); + + QUnit.test('works with argument form', function () { + equal(_emberRuntimeSystemString.loc('_Hello %@', 'John'), 'Bonjour John'); + equal(_emberRuntimeSystemString.loc('_Hello %@ %@', ['John'], 'Doe'), 'Bonjour [John] Doe'); + }); +}); +// ES6TODO Ember.STRINGS +enifed('ember-runtime/tests/system/string/loc_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/loc_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/loc_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/underscore_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.underscore'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.underscore is not available without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.underscore, 'String.prototype helper disabled'); + }); + } + + QUnit.test('with normal string', function () { + deepEqual(_emberRuntimeSystemString.underscore('my favorite items'), 'my_favorite_items'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('my favorite items'.underscore(), 'my_favorite_items'); + } + }); + + QUnit.test('with dasherized string', function () { + deepEqual(_emberRuntimeSystemString.underscore('css-class-name'), 'css_class_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('css-class-name'.underscore(), 'css_class_name'); + } + }); + + QUnit.test('does nothing with underscored string', function () { + deepEqual(_emberRuntimeSystemString.underscore('action_name'), 'action_name'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('action_name'.underscore(), 'action_name'); + } + }); + + QUnit.test('with camelcased string', function () { + deepEqual(_emberRuntimeSystemString.underscore('innerHTML'), 'inner_html'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('innerHTML'.underscore(), 'inner_html'); + } + }); + + QUnit.test('underscore namespaced classified string', function () { + deepEqual(_emberRuntimeSystemString.underscore('PrivateDocs/OwnerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('PrivateDocs/OwnerInvoice'.underscore(), 'private_docs/owner_invoice'); + } + }); + + QUnit.test('underscore namespaced camelized string', function () { + deepEqual(_emberRuntimeSystemString.underscore('privateDocs/ownerInvoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('privateDocs/ownerInvoice'.underscore(), 'private_docs/owner_invoice'); + } + }); + + QUnit.test('underscore namespaced dasherized string', function () { + deepEqual(_emberRuntimeSystemString.underscore('private-docs/owner-invoice'), 'private_docs/owner_invoice'); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('private-docs/owner-invoice'.underscore(), 'private_docs/owner_invoice'); + } + }); +}); +enifed('ember-runtime/tests/system/string/underscore_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/underscore_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/underscore_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/tests/system/string/w_test', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + 'use strict'; + + QUnit.module('EmberStringUtils.w'); + + if (!_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + QUnit.test('String.prototype.w is not available without EXTEND_PROTOTYPES', function () { + ok('undefined' === typeof String.prototype.w, 'String.prototype helper disabled'); + }); + } + + QUnit.test('\'one two three\'.w() => [\'one\',\'two\',\'three\']', function () { + deepEqual(_emberRuntimeSystemString.w('one two three'), ['one', 'two', 'three']); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('one two three'.w(), ['one', 'two', 'three']); + } + }); + + QUnit.test('\'one two three\'.w() with extra spaces between words => [\'one\',\'two\',\'three\']', function () { + deepEqual(_emberRuntimeSystemString.w('one two three'), ['one', 'two', 'three']); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('one two three'.w(), ['one', 'two', 'three']); + } + }); + + QUnit.test('\'one two three\'.w() with tabs', function () { + deepEqual(_emberRuntimeSystemString.w('one\ttwo three'), ['one', 'two', 'three']); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + deepEqual('one\ttwo three'.w(), ['one', 'two', 'three']); + } + }); +}); +enifed('ember-runtime/tests/system/string/w_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/tests/system/string/w_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/tests/system/string/w_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-runtime/utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-runtime/utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-runtime/utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/compat.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/compat.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/compat.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/assert-reserved-named-arguments.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/assert-reserved-named-arguments.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/assert-reserved-named-arguments.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/deprecate-render-model.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/deprecate-render-model.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/deprecate-render-model.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/deprecate-render.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/deprecate-render.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/deprecate-render.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-action-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-action-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-action-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-angle-bracket-components.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-angle-bracket-components.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-angle-bracket-components.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-attrs-into-args.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-attrs-into-args.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-attrs-into-args.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-each-in-into-each.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-each-in-into-each.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-each-in-into-each.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-has-block-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-has-block-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-has-block-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-inline-link-to.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-inline-link-to.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-inline-link-to.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-input-on-to-onEvent.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-input-on-to-onEvent.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-input-on-to-onEvent.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-input-type-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-input-type-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-input-type-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-item-class.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-item-class.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-item-class.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-old-binding-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-old-binding-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-old-binding-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-old-class-binding-syntax.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-old-class-binding-syntax.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-old-class-binding-syntax.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/plugins/transform-top-level-components.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/plugins/transform-top-level-components.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/plugins/transform-top-level-components.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/bootstrap.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/bootstrap.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/bootstrap.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/calculate-location-display.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/calculate-location-display.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/calculate-location-display.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/compile-options.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/compile-options.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/compile-options.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/compile.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/compile.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/compile.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/system/precompile.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/system/precompile.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/system/precompile.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: assert-reserved-named-arguments'); + + QUnit.test('Paths beginning with @ are not valid', function () { + expect(3); + + expectAssertion(function () { + _emberTemplateCompilerIndex.compile('{{@foo}}', { + moduleName: 'baz/foo-bar' + }); + }, '\'@foo\' is not a valid path. (\'baz/foo-bar\' @ L1:C2) '); + + expectAssertion(function () { + _emberTemplateCompilerIndex.compile('{{#if @foo}}Yup{{/if}}', { + moduleName: 'baz/foo-bar' + }); + }, '\'@foo\' is not a valid path. (\'baz/foo-bar\' @ L1:C6) '); + + expectAssertion(function () { + _emberTemplateCompilerIndex.compile('{{input type=(if @foo "bar" "baz")}}', { + moduleName: 'baz/foo-bar' + }); + }, '\'@foo\' is not a valid path. (\'baz/foo-bar\' @ L1:C17) '); + }); +}); +enifed('ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-model-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: deprecate-model-render'); + + QUnit.test('Using `{{render` with model provides a deprecation', function () { + expect(1); + + var expectedMessage = 'Please refactor `{{render "foo-bar" coolModel}}` to a component and' + ' invoke via `{{foo-bar model=coolModel}}`. (\'baz/foo-bar\' @ L1:C0) '; + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{render "foo-bar" coolModel}}', { + moduleName: 'baz/foo-bar' + }); + }, expectedMessage); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-model-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/deprecate-render-model-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/deprecate-render-model-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: deprecate-render'); + + QUnit.test('Using `{{render` without a model provides a deprecation', function () { + expect(1); + + var expectedMessage = 'Please refactor `{{render "foo-bar"}}` to a component and' + ' invoke via `{{foo-bar}}`. (\'baz/foo-bar\' @ L1:C0) '; + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{render "foo-bar"}}', { + moduleName: 'baz/foo-bar' + }); + }, expectedMessage); + }); +}); +enifed('ember-template-compiler/tests/plugins/deprecate-render-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/deprecate-render-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/deprecate-render-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-inline-link-to-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: assert-no-view-and-controller-paths without legacy view support'); + + QUnit.test('Can transform an inline {{link-to}} without error', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{link-to \'foo\' \'index\'}}', { + moduleName: 'foo/bar/baz' + }); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-inline-link-to-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/transform-inline-link-to-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/transform-inline-link-to-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-on-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: transform-input-on'); + + QUnit.test('Using `action` without `on` provides a deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input action="foo"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input action="foo"}}\' (\'foo/bar/baz\' @ L1:C0) is deprecated. Please use \'{{input enter="foo"}}\' instead.'); + }); + + QUnit.test('Using `action` with `on` provides a deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input on="focus-in" action="foo"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input on="focus-in" action="foo"}}\' (\'foo/bar/baz\' @ L1:C0) is deprecated. Please use \'{{input focus-in="foo"}}\' instead.'); + }); + + QUnit.test('Using `on=\'keyPress\'` does not clobber `keyPress`', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input on="keyPress" action="foo"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input on="keyPress" action="foo"}}\' (\'foo/bar/baz\' @ L1:C0) is deprecated. Please use \'{{input key-press="foo"}}\' instead.'); + }); + + QUnit.test('Using `on=\'foo\'` without `action=\'asdf\'` raises specific deprecation', function () { + expect(1); + + expectDeprecation(function () { + _emberTemplateCompilerIndex.compile('{{input on="asdf"}}', { + moduleName: 'foo/bar/baz' + }); + }, 'Using \'{{input on="asdf" ...}}\' without specifying an action (\'foo/bar/baz\' @ L1:C0) will do nothing.'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-on-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/transform-input-on-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/transform-input-on-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-type-syntax-test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: input type syntax'); + + QUnit.test('Can compile an {{input}} helper that has a sub-expression value as its type', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{input type=(if true \'password\' \'text\')}}'); + }); + + QUnit.test('Can compile an {{input}} helper with a string literal type', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{input type=\'text\'}}'); + }); + + QUnit.test('Can compile an {{input}} helper with a type stored in a var', function () { + expect(0); + + _emberTemplateCompilerIndex.compile('{{input type=_type}}'); + }); +}); +enifed('ember-template-compiler/tests/plugins/transform-input-type-syntax-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/system/bootstrap-test', ['exports', 'ember-metal', 'ember-views', 'ember-glimmer', 'ember-template-compiler/system/bootstrap', 'internal-test-helpers'], function (exports, _emberMetal, _emberViews, _emberGlimmer, _emberTemplateCompilerSystemBootstrap, _internalTestHelpers) { + 'use strict'; + + var trim = _emberViews.jQuery.trim; + + var component = undefined, + fixture = undefined; + + function checkTemplate(templateName) { + _emberMetal.run(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }); + + var template = _emberGlimmer.getTemplate(templateName); + + ok(template, 'template is available on Ember.TEMPLATES'); + equal(_emberViews.jQuery('#qunit-fixture script').length, 0, 'script removed'); + + var owner = _internalTestHelpers.buildOwner(); + owner.register('template:-top-level', template); + owner.register('component:-top-level', _emberGlimmer.Component.extend({ + layoutName: '-top-level', + firstName: 'Tobias', + drug: 'teamocil' + })); + + component = owner.lookup('component:-top-level'); + _internalTestHelpers.runAppend(component); + + equal(_emberViews.jQuery('#qunit-fixture').text().trim(), 'Tobias takes teamocil', 'template works'); + _internalTestHelpers.runDestroy(component); + } + + QUnit.module('ember-templates: bootstrap', { + setup: function () { + fixture = document.getElementById('qunit-fixture'); + }, + teardown: function () { + _emberGlimmer.setTemplates({}); + _internalTestHelpers.runDestroy(component); + } + }); + + QUnit.test('template with data-template-name should add a new template to Ember.TEMPLATES', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + checkTemplate('funkyTemplate'); + }); + + QUnit.test('template with id instead of data-template-name should add a new template to Ember.TEMPLATES', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + checkTemplate('funkyTemplate'); + }); + + QUnit.test('template without data-template-name or id should default to application', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + checkTemplate('application'); + }); + + if (typeof Handlebars === 'object') { + QUnit.test('template with type text/x-raw-handlebars should be parsed', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + _emberMetal.run(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }); + + var template = _emberGlimmer.getTemplate('funkyTemplate'); + + ok(template, 'template with name funkyTemplate available'); + + // This won't even work with Ember templates + equal(trim(template({ name: 'Tobias' })), 'Tobias'); + }); + } + + QUnit.test('duplicated default application templates should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('default application template and id application template present should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('default application template and data-template-name application template present should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('duplicated template id should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); + + QUnit.test('duplicated template data-template-name should throw exception', function () { + _emberViews.jQuery('#qunit-fixture').html(''); + + throws(function () { + return _emberTemplateCompilerSystemBootstrap.default({ context: fixture, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + }, /Template named "[^"]+" already exists\./, 'duplicate templates should not be allowed'); + }); +}); +enifed('ember-template-compiler/tests/system/bootstrap-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/system/bootstrap-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/system/bootstrap-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-template-compiler/tests/system/compile_options_test', ['exports', 'ember-template-compiler/index'], function (exports, _emberTemplateCompilerIndex) { + 'use strict'; + + QUnit.module('ember-template-compiler: default compile options'); + + QUnit.test('default options are a new copy', function () { + notEqual(_emberTemplateCompilerIndex.compileOptions(), _emberTemplateCompilerIndex.compileOptions()); + }); + + QUnit.test('has default AST plugins', function (assert) { + assert.expect(_emberTemplateCompilerIndex.defaultPlugins.length); + + var plugins = _emberTemplateCompilerIndex.compileOptions().plugins.ast; + + for (var i = 0; i < _emberTemplateCompilerIndex.defaultPlugins.length; i++) { + var plugin = _emberTemplateCompilerIndex.defaultPlugins[i]; + assert.ok(plugins.indexOf(plugin) > -1, 'includes ' + plugin); + } + }); +}); +enifed('ember-template-compiler/tests/system/compile_options_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-template-compiler/tests/system/compile_options_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-template-compiler/tests/system/compile_options_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/adapters/adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/adapters/adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/adapters/adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/adapters/qunit.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/adapters/qunit.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/adapters/qunit.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/events.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/events.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/events.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/ext/application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/ext/application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/ext/application.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/ext/rsvp.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/ext/rsvp.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/ext/rsvp.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/and_then.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/and_then.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/and_then.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/click.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/click.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/click.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/current_path.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/current_path.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/current_path.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/current_route_name.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/current_route_name.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/current_route_name.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/current_url.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/current_url.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/current_url.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/fill_in.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/fill_in.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/fill_in.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/find.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/find.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/find.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/find_with_assert.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/find_with_assert.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/find_with_assert.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/key_event.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/key_event.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/key_event.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/pause_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/pause_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/pause_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/trigger_event.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/trigger_event.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/trigger_event.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/visit.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/visit.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/visit.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/helpers/wait.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/helpers/wait.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/helpers/wait.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/initializers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/initializers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/initializers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/setup_for_testing.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/setup_for_testing.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/setup_for_testing.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/adapter.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/adapter.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/adapter.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/on_inject_helpers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/on_inject_helpers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/on_inject_helpers.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/pending_requests.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/pending_requests.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/pending_requests.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/promise.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/promise.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/promise.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/run.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/run.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/run.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/test/waiters.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/test/waiters.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/test/waiters.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/acceptance_test', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test', 'ember-testing/adapters/qunit', 'ember-testing/initializers', 'ember-application', 'ember-routing', 'ember-template-compiler', 'ember-runtime', 'ember-glimmer'], function (exports, _emberMetal, _emberViews, _emberTestingTest, _emberTestingAdaptersQunit, _emberTestingInitializers, _emberApplication, _emberRouting, _emberTemplateCompiler, _emberRuntime, _emberGlimmer) { + 'use strict'; + + //ES6TODO: we need {{link-to}} and {{outlet}} to exist here + + var App, find, click, fillIn, currentRoute, currentURL, visit, originalAdapter, andThen, indexHitCount; + + QUnit.module('ember-testing Acceptance', { + setup: function () { + _emberViews.jQuery('').appendTo('head'); + _emberViews.jQuery('
    ').appendTo('body'); + + originalAdapter = _emberTestingTest.default.adapter; + + _emberMetal.run(function () { + indexHitCount = 0; + + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + + App.Router.map(function () { + this.route('posts'); + this.route('comments'); + + this.route('abort_transition'); + + this.route('redirect'); + }); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + indexHitCount += 1; + } + }); + + App.PostsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + currentRoute = 'posts'; + this._super.apply(this, arguments); + } + }); + + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('
    ')); + + App.CommentsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + currentRoute = 'comments'; + this._super.apply(this, arguments); + } + }); + + _emberGlimmer.setTemplate('comments', _emberTemplateCompiler.compile('
    {{input type="text"}}
    ')); + + App.AbortTransitionRoute = _emberRouting.Route.extend({ + beforeModel: function (transition) { + transition.abort(); + } + }); + + App.RedirectRoute = _emberRouting.Route.extend({ + beforeModel: function () { + this.transitionTo('comments'); + } + }); + + App.setupForTesting(); + }); + + _emberTestingTest.default.registerAsyncHelper('slowHelper', function () { + return new _emberRuntime.RSVP.Promise(function (resolve) { + setTimeout(resolve, 10); + }); + }); + + App.injectTestHelpers(); + + find = window.find; + click = window.click; + fillIn = window.fillIn; + visit = window.visit; + andThen = window.andThen; + currentURL = window.currentURL; + }, + + teardown: function () { + _emberTestingTest.default.unregisterHelper('slowHelper'); + _emberGlimmer.setTemplates({}); + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + _emberMetal.run(App, App.destroy); + App = null; + _emberTestingTest.default.adapter = originalAdapter; + indexHitCount = 0; + } + }); + + QUnit.test('helpers can be chained with then', function () { + expect(6); + + currentRoute = 'index'; + + visit('/posts').then(function () { + equal(currentRoute, 'posts', 'Successfully visited posts route'); + equal(currentURL(), '/posts', 'posts URL is correct'); + return click('a:contains("Comments")'); + }).then(function () { + equal(currentRoute, 'comments', 'visit chained with click'); + return fillIn('.ember-text-field', 'yeah'); + }).then(function () { + equal(_emberViews.jQuery('.ember-text-field').val(), 'yeah', 'chained with fillIn'); + return fillIn('.ember-text-field', '#ember-testing-container', 'context working'); + }).then(function () { + equal(_emberViews.jQuery('.ember-text-field').val(), 'context working', 'chained with fillIn'); + return click('.does-not-exist'); + }).then(null, function (e) { + equal(e.message, 'Element .does-not-exist not found.', 'Non-existent click exception caught'); + }); + }); + + // Keep this for backwards compatibility + + QUnit.test('helpers can be chained to each other', function () { + expect(7); + + currentRoute = 'index'; + + visit('/posts').click('a:first', '#comments-link').fillIn('.ember-text-field', 'hello').then(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(_emberViews.jQuery('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + find('.ember-text-field').one('keypress', function (e) { + equal(e.keyCode, 13, 'keyevent chained with correct keyCode.'); + equal(e.which, 13, 'keyevent chained with correct which.'); + }); + }).keyEvent('.ember-text-field', 'keypress', 13).visit('/posts').then(function () { + equal(currentRoute, 'posts', 'Thens can also be chained to helpers'); + equal(currentURL(), '/posts', 'URL is set correct on chained helpers'); + }); + }); + + QUnit.test('helpers don\'t need to be chained', function () { + expect(5); + + currentRoute = 'index'; + + visit('/posts'); + + click('a:first', '#comments-link'); + + fillIn('.ember-text-field', 'hello'); + + andThen(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(find('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + }); + + visit('/posts'); + + andThen(function () { + equal(currentRoute, 'posts'); + equal(currentURL(), '/posts'); + }); + }); + + QUnit.test('Nested async helpers', function () { + expect(5); + + currentRoute = 'index'; + + visit('/posts'); + + andThen(function () { + click('a:first', '#comments-link'); + + fillIn('.ember-text-field', 'hello'); + }); + + andThen(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(find('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + }); + + visit('/posts'); + + andThen(function () { + equal(currentRoute, 'posts'); + equal(currentURL(), '/posts'); + }); + }); + + QUnit.test('Multiple nested async helpers', function () { + expect(3); + + visit('/posts'); + + andThen(function () { + click('a:first', '#comments-link'); + + fillIn('.ember-text-field', 'hello'); + fillIn('.ember-text-field', 'goodbye'); + }); + + andThen(function () { + equal(find('.ember-text-field').val(), 'goodbye', 'Fillin successfully works'); + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + }); + }); + + QUnit.test('Helpers nested in thens', function () { + expect(5); + + currentRoute = 'index'; + + visit('/posts').then(function () { + click('a:first', '#comments-link'); + }); + + andThen(function () { + fillIn('.ember-text-field', 'hello'); + }); + + andThen(function () { + equal(currentRoute, 'comments', 'Successfully visited comments route'); + equal(currentURL(), '/comments', 'Comments URL is correct'); + equal(find('.ember-text-field').val(), 'hello', 'Fillin successfully works'); + }); + + visit('/posts'); + + andThen(function () { + equal(currentRoute, 'posts'); + equal(currentURL(), '/posts', 'Posts URL is correct'); + }); + }); + + QUnit.test('Aborted transitions are not logged via Ember.Test.adapter#exception', function () { + expect(0); + + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.create({ + exception: function (error) { + ok(false, 'aborted transitions are not logged'); + } + }); + + visit('/abort_transition'); + }); + + QUnit.test('Unhandled exceptions are logged via Ember.Test.adapter#exception', function () { + expect(2); + + var asyncHandled; + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.create({ + exception: function (error) { + equal(error.message, 'Element .does-not-exist not found.', 'Exception successfully caught and passed to Ember.Test.adapter.exception'); + asyncHandled['catch'](function () {}); // handle the rejection so it doesn't leak later. + } + }); + + visit('/posts'); + + click('.invalid-element').then(null, function (error) { + equal(error.message, 'Element .invalid-element not found.', 'Exception successfully handled in the rejection handler'); + }); + + asyncHandled = click('.does-not-exist'); + }); + + QUnit.test('Unhandled exceptions in `andThen` are logged via Ember.Test.adapter#exception', function () { + expect(1); + + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.create({ + exception: function (error) { + equal(error.message, 'Catch me', 'Exception successfully caught and passed to Ember.Test.adapter.exception'); + } + }); + + visit('/posts'); + + andThen(function () { + throw new Error('Catch me'); + }); + }); + + QUnit.test('should not start routing on the root URL when visiting another', function () { + expect(4); + + visit('/posts'); + + andThen(function () { + ok(find('#comments-link'), 'found comments-link'); + equal(currentRoute, 'posts', 'Successfully visited posts route'); + equal(currentURL(), '/posts', 'Posts URL is correct'); + equal(indexHitCount, 0, 'should not hit index route when visiting another route'); + }); + }); + + QUnit.test('only enters the index route once when visiting /', function () { + expect(1); + + visit('/'); + + andThen(function () { + equal(indexHitCount, 1, 'should hit index once when visiting /'); + }); + }); + + QUnit.test('test must not finish while asyncHelpers are pending', function () { + expect(2); + + var async = 0; + var innerRan = false; + + _emberTestingTest.default.adapter = _emberTestingAdaptersQunit.default.extend({ + asyncStart: function () { + async++; + this._super(); + }, + asyncEnd: function () { + async--; + this._super(); + } + }).create(); + + App.testHelpers.slowHelper(); + andThen(function () { + innerRan = true; + }); + + equal(innerRan, false, 'should not have run yet'); + ok(async > 0, 'should have told the adapter to pause'); + + if (async === 0) { + // If we failed the test, prevent zalgo from escaping and breaking + // our other tests. + _emberTestingTest.default.adapter.asyncStart(); + _emberTestingTest.default.resolve().then(function () { + _emberTestingTest.default.adapter.asyncEnd(); + }); + } + }); + + QUnit.test('visiting a URL that causes another transition should yield the correct URL', function () { + expect(1); + + visit('/redirect'); + + andThen(function () { + equal(currentURL(), '/comments', 'Redirected to Comments URL'); + }); + }); + + QUnit.test('visiting a URL and then visiting a second URL with a transition should yield the correct URL', function () { + expect(2); + + visit('/posts'); + + andThen(function () { + equal(currentURL(), '/posts', 'First visited URL is correct'); + }); + + visit('/redirect'); + + andThen(function () { + equal(currentURL(), '/comments', 'Redirected to Comments URL'); + }); + }); + + QUnit.module('ember-testing Acceptance – teardown'); + + QUnit.test('that the setup/teardown happens correct', function () { + expect(2); + + _emberViews.jQuery('').appendTo('head'); + _emberViews.jQuery('
    ').appendTo('body'); + + _emberMetal.run(function () { + indexHitCount = 0; + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + }); + App.injectTestHelpers(); + + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + ok(typeof _emberTestingTest.default.Promise.prototype.click === 'function'); + _emberMetal.run(App, App.destroy); + equal(_emberTestingTest.default.Promise.prototype.click, undefined); + App = null; + _emberTestingTest.default.adapter = originalAdapter; + indexHitCount = 0; + }); +}); +// ensure the initializer is setup +enifed('ember-testing/tests/acceptance_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/acceptance_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/acceptance_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/adapters/adapter_test', ['exports', 'ember-metal', 'ember-testing/adapters/adapter'], function (exports, _emberMetal, _emberTestingAdaptersAdapter) { + 'use strict'; + + var adapter; + + QUnit.module('ember-testing Adapter', { + setup: function () { + adapter = new _emberTestingAdaptersAdapter.default(); + }, + teardown: function () { + _emberMetal.run(adapter, adapter.destroy); + } + }); + + // Can't test these this way anymore since we have nothing to compare to + // test("asyncStart is a noop", function() { + // equal(adapter.asyncStart, K); + // }); + + // test("asyncEnd is a noop", function() { + // equal(adapter.asyncEnd, K); + // }); + + QUnit.test('exception throws', function () { + var error = 'Hai'; + var thrown; + + try { + adapter.exception(error); + } catch (e) { + thrown = e; + } + equal(thrown, error); + }); +}); +enifed('ember-testing/tests/adapters/adapter_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/adapters/adapter_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/adapters/adapter_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/adapters/qunit_test', ['exports', 'ember-metal', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberTestingAdaptersQunit) { + 'use strict'; + + var adapter; + + QUnit.module('ember-testing QUnitAdapter', { + setup: function () { + adapter = new _emberTestingAdaptersQunit.default(); + }, + teardown: function () { + _emberMetal.run(adapter, adapter.destroy); + } + }); + + QUnit.test('asyncStart calls stop', function () { + var originalStop = QUnit.stop; + try { + QUnit.stop = function () { + ok(true, 'stop called'); + }; + adapter.asyncStart(); + } finally { + QUnit.stop = originalStop; + } + }); + + QUnit.test('asyncEnd calls start', function () { + var originalStart = QUnit.start; + try { + QUnit.start = function () { + ok(true, 'start called'); + }; + adapter.asyncEnd(); + } finally { + QUnit.start = originalStart; + } + }); + + QUnit.test('exception causes a failing assertion', function () { + var error = { err: 'hai' }; + var originalOk = window.ok; + try { + window.ok = function (val, msg) { + originalOk(!val, 'ok is called with false'); + originalOk(msg, '{err: "hai"}'); + }; + adapter.exception(error); + } finally { + window.ok = originalOk; + } + }); +}); +enifed('ember-testing/tests/adapters/qunit_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/adapters/qunit_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/adapters/qunit_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/adapters_test', ['exports', 'ember-metal', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit', 'ember-application'], function (exports, _emberMetal, _emberTestingTest, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit, _emberApplication) { + 'use strict'; + + var App, originalAdapter, originalQUnit; + + QUnit.module('ember-testing Adapters', { + setup: function () { + originalAdapter = _emberTestingTest.default.adapter; + originalQUnit = window.QUnit; + }, + teardown: function () { + _emberMetal.run(App, App.destroy); + App.removeTestHelpers(); + App = null; + + _emberTestingTest.default.adapter = originalAdapter; + window.QUnit = originalQUnit; + } + }); + + QUnit.test('Setting a test adapter manually', function () { + expect(1); + var CustomAdapter; + + CustomAdapter = _emberTestingAdaptersAdapter.default.extend({ + asyncStart: function () { + ok(true, 'Correct adapter was used'); + } + }); + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + _emberTestingTest.default.adapter = CustomAdapter.create(); + App.setupForTesting(); + }); + + _emberTestingTest.default.adapter.asyncStart(); + }); + + QUnit.test('QUnitAdapter is used by default (if QUnit is available)', function () { + expect(1); + + _emberTestingTest.default.adapter = null; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + ok(_emberTestingTest.default.adapter instanceof _emberTestingAdaptersQunit.default); + }); + + QUnit.test('Adapter is used by default (if QUnit is not available)', function () { + expect(2); + + delete window.QUnit; + + _emberTestingTest.default.adapter = null; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + ok(_emberTestingTest.default.adapter instanceof _emberTestingAdaptersAdapter.default); + ok(!(_emberTestingTest.default.adapter instanceof _emberTestingAdaptersQunit.default)); + }); +}); +enifed('ember-testing/tests/adapters_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/adapters_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/adapters_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/ext/rsvp_test', ['exports', 'ember-testing/ext/rsvp', 'ember-testing/test/adapter', 'ember-metal'], function (exports, _emberTestingExtRsvp, _emberTestingTestAdapter, _emberMetal) { + 'use strict'; + + var originalTestAdapter = _emberTestingTestAdapter.getAdapter(); + var originalTestingFlag = _emberMetal.isTesting(); + + var asyncStarted = 0; + var asyncEnded = 0; + + QUnit.module('ember-testing RSVP', { + setup: function () { + _emberMetal.setTesting(true); + _emberTestingTestAdapter.setAdapter({ + asyncStart: function () { + asyncStarted++; + QUnit.stop(); + }, + asyncEnd: function () { + asyncEnded++; + QUnit.start(); + } + }); + }, + teardown: function () { + asyncStarted = 0; + asyncEnded = 0; + _emberTestingTestAdapter.setAdapter(originalTestAdapter); + _emberMetal.setTesting(originalTestingFlag); + } + }); + + QUnit.test('given `Ember.testing = true`, correctly informs the test suite about async steps', function () { + expect(19); + + ok(!_emberMetal.run.currentRunLoop, 'expect no run-loop'); + + _emberMetal.setTesting(true); + + equal(asyncStarted, 0); + equal(asyncEnded, 0); + + var user = _emberTestingExtRsvp.default.Promise.resolve({ + name: 'tomster' + }); + + equal(asyncStarted, 0); + equal(asyncEnded, 0); + + user.then(function (user) { + equal(asyncStarted, 1); + equal(asyncEnded, 1); + + equal(user.name, 'tomster'); + + return _emberTestingExtRsvp.default.Promise.resolve(1).then(function () { + equal(asyncStarted, 1); + equal(asyncEnded, 1); + }); + }).then(function () { + equal(asyncStarted, 1); + equal(asyncEnded, 1); + + return new _emberTestingExtRsvp.default.Promise(function (resolve) { + QUnit.stop(); // raw async, we must inform the test framework manually + setTimeout(function () { + QUnit.start(); // raw async, we must inform the test framework manually + + equal(asyncStarted, 1); + equal(asyncEnded, 1); + + resolve({ + name: 'async tomster' + }); + + equal(asyncStarted, 2); + equal(asyncEnded, 1); + }, 0); + }); + }).then(function (user) { + equal(user.name, 'async tomster'); + equal(asyncStarted, 2); + equal(asyncEnded, 2); + }); + }); +}); +enifed('ember-testing/tests/ext/rsvp_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/ext/rsvp_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/ext/rsvp_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/helper_registration_test', ['exports', 'ember-metal', 'ember-testing/test', 'ember-application'], function (exports, _emberMetal, _emberTestingTest, _emberApplication) { + 'use strict'; + + var App, appBooted, helperContainer; + + function registerHelper() { + _emberTestingTest.default.registerHelper('boot', function (app) { + _emberMetal.run(app, app.advanceReadiness); + appBooted = true; + return app.testHelpers.wait(); + }); + } + + function unregisterHelper() { + _emberTestingTest.default.unregisterHelper('boot'); + } + + var originalAdapter = _emberTestingTest.default.adapter; + + function setupApp() { + appBooted = false; + helperContainer = {}; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + App.injectTestHelpers(helperContainer); + }); + } + + function destroyApp() { + if (App) { + _emberMetal.run(App, 'destroy'); + App = null; + } + } + + QUnit.module('Test - registerHelper/unregisterHelper', { + teardown: function () { + _emberTestingTest.default.adapter = originalAdapter; + destroyApp(); + } + }); + + QUnit.test('Helper gets registered', function () { + expect(2); + + registerHelper(); + setupApp(); + + ok(App.testHelpers.boot); + ok(helperContainer.boot); + }); + + QUnit.test('Helper is ran when called', function (assert) { + var done = assert.async(); + assert.expect(1); + + registerHelper(); + setupApp(); + + App.testHelpers.boot().then(function () { + assert.ok(appBooted); + }).finally(done); + }); + + QUnit.test('Helper can be unregistered', function () { + expect(4); + + registerHelper(); + setupApp(); + + ok(App.testHelpers.boot); + ok(helperContainer.boot); + + unregisterHelper(); + + setupApp(); + + ok(!App.testHelpers.boot, 'once unregistered the helper is not added to App.testHelpers'); + ok(!helperContainer.boot, 'once unregistered the helper is not added to the helperContainer'); + }); +}); +enifed('ember-testing/tests/helper_registration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/helper_registration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/helper_registration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/helpers_test', ['exports', 'ember-routing', 'ember-runtime', 'ember-metal', 'ember-views', 'ember-glimmer', 'ember-testing/test', 'ember-testing/helpers', 'ember-testing/initializers', 'ember-testing/setup_for_testing', 'ember-application', 'ember-template-compiler', 'ember-testing/test/pending_requests', 'ember-testing/test/adapter', 'ember-testing/test/waiters'], function (exports, _emberRouting, _emberRuntime, _emberMetal, _emberViews, _emberGlimmer, _emberTestingTest, _emberTestingHelpers, _emberTestingInitializers, _emberTestingSetup_for_testing, _emberApplication, _emberTemplateCompiler, _emberTestingTestPending_requests, _emberTestingTestAdapter, _emberTestingTestWaiters) { + 'use strict'; + + var App; + var originalAdapter = _emberTestingTestAdapter.getAdapter(); + + function cleanup() { + // Teardown setupForTesting + + _emberTestingTestAdapter.setAdapter(originalAdapter); + _emberMetal.run(function () { + _emberViews.jQuery(document).off('ajaxSend'); + _emberViews.jQuery(document).off('ajaxComplete'); + }); + _emberTestingTestPending_requests.clearPendingRequests(); + // Test.waiters = null; + + // Other cleanup + + if (App) { + _emberMetal.run(App, App.destroy); + App.removeTestHelpers(); + App = null; + } + + _emberGlimmer.setTemplates({}); + } + + function assertHelpers(application, helperContainer, expected) { + if (!helperContainer) { + helperContainer = window; + } + if (expected === undefined) { + expected = true; + } + + function checkHelperPresent(helper, expected) { + var presentInHelperContainer = !!helperContainer[helper]; + var presentInTestHelpers = !!application.testHelpers[helper]; + + ok(presentInHelperContainer === expected, 'Expected \'' + helper + '\' to be present in the helper container (defaults to window).'); + ok(presentInTestHelpers === expected, 'Expected \'' + helper + '\' to be present in App.testHelpers.'); + } + + checkHelperPresent('visit', expected); + checkHelperPresent('click', expected); + checkHelperPresent('keyEvent', expected); + checkHelperPresent('fillIn', expected); + checkHelperPresent('wait', expected); + checkHelperPresent('triggerEvent', expected); + } + + function assertNoHelpers(application, helperContainer) { + assertHelpers(application, helperContainer, false); + } + + function currentRouteName(app) { + return app.testHelpers.currentRouteName(); + } + + function currentPath(app) { + return app.testHelpers.currentPath(); + } + + function currentURL(app) { + return app.testHelpers.currentURL(); + } + + function setupApp() { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + + App.injectTestHelpers(); + }); + } + + QUnit.module('ember-testing: Helper setup', { + setup: function () { + cleanup(); + }, + teardown: function () { + cleanup(); + } + }); + + function registerHelper() { + _emberTestingTest.default.registerHelper('LeakyMcLeakLeak', function (app) {}); + } + + QUnit.test('Ember.Application#injectTestHelpers/#removeTestHelpers', function () { + App = _emberMetal.run(_emberApplication.Application, _emberApplication.Application.create); + assertNoHelpers(App); + + registerHelper(); + + App.injectTestHelpers(); + assertHelpers(App); + ok(_emberTestingTest.default.Promise.prototype.LeakyMcLeakLeak, 'helper in question SHOULD be present'); + + App.removeTestHelpers(); + assertNoHelpers(App); + + equal(_emberTestingTest.default.Promise.prototype.LeakyMcLeakLeak, undefined, 'should NOT leak test promise extensions'); + }); + + QUnit.test('Ember.Application#setupForTesting', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App.__container__.lookup('router:main').location, 'none'); + }); + + QUnit.test('Ember.Application.setupForTesting sets the application to `testing`.', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App.testing, true, 'Application instance is set to testing.'); + }); + + QUnit.test('Ember.Application.setupForTesting leaves the system in a deferred state.', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + }); + + QUnit.test('App.reset() after Application.setupForTesting leaves the system in a deferred state.', function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + + App.reset(); + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + }); + + QUnit.test('Ember.Application#setupForTesting attaches ajax listeners', function () { + var documentEvents; + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + if (!documentEvents) { + documentEvents = {}; + } + + ok(documentEvents['ajaxSend'] === undefined, 'there are no ajaxSend listers setup prior to calling injectTestHelpers'); + ok(documentEvents['ajaxComplete'] === undefined, 'there are no ajaxComplete listers setup prior to calling injectTestHelpers'); + + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + equal(documentEvents['ajaxSend'].length, 1, 'calling injectTestHelpers registers an ajaxSend handler'); + equal(documentEvents['ajaxComplete'].length, 1, 'calling injectTestHelpers registers an ajaxComplete handler'); + }); + + QUnit.test('Ember.Application#setupForTesting attaches ajax listeners only once', function () { + var documentEvents; + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + if (!documentEvents) { + documentEvents = {}; + } + + ok(documentEvents['ajaxSend'] === undefined, 'there are no ajaxSend listeners setup prior to calling injectTestHelpers'); + ok(documentEvents['ajaxComplete'] === undefined, 'there are no ajaxComplete listeners setup prior to calling injectTestHelpers'); + + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + + documentEvents = _emberViews.jQuery._data(document, 'events'); + + equal(documentEvents['ajaxSend'].length, 1, 'calling injectTestHelpers registers an ajaxSend handler'); + equal(documentEvents['ajaxComplete'].length, 1, 'calling injectTestHelpers registers an ajaxComplete handler'); + }); + + QUnit.test('Ember.Application#injectTestHelpers calls callbacks registered with onInjectHelpers', function () { + var injected = 0; + + _emberTestingTest.default.onInjectHelpers(function () { + injected++; + }); + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + equal(injected, 0, 'onInjectHelpers are not called before injectTestHelpers'); + + App.injectTestHelpers(); + + equal(injected, 1, 'onInjectHelpers are called after injectTestHelpers'); + }); + + QUnit.test('Ember.Application#injectTestHelpers adds helpers to provided object.', function () { + var helpers = {}; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + App.injectTestHelpers(helpers); + assertHelpers(App, helpers); + + App.removeTestHelpers(); + assertNoHelpers(App, helpers); + }); + + QUnit.test('Ember.Application#removeTestHelpers resets the helperContainer\'s original values', function () { + var helpers = { visit: 'snazzleflabber' }; + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + }); + + App.injectTestHelpers(helpers); + + ok(helpers.visit !== 'snazzleflabber', 'helper added to container'); + App.removeTestHelpers(); + + ok(helpers.visit === 'snazzleflabber', 'original value added back to container'); + }); + + QUnit.module('ember-testing: Helper methods', { + setup: function () { + setupApp(); + }, + teardown: function () { + cleanup(); + } + }); + + QUnit.test('`wait` respects registerWaiters', function (assert) { + assert.expect(3); + + var done = assert.async(); + + var counter = 0; + function waiter() { + return ++counter > 2; + } + + var other = 0; + function otherWaiter() { + return ++other > 2; + } + + _emberMetal.run(App, App.advanceReadiness); + _emberTestingTestWaiters.registerWaiter(waiter); + _emberTestingTestWaiters.registerWaiter(otherWaiter); + + App.testHelpers.wait().then(function () { + equal(waiter(), true, 'should not resolve until our waiter is ready'); + _emberTestingTestWaiters.unregisterWaiter(waiter); + counter = 0; + return App.testHelpers.wait(); + }).then(function () { + equal(counter, 0, 'unregistered waiter was not checked'); + equal(otherWaiter(), true, 'other waiter is still registered'); + }).finally(function () { + _emberTestingTestWaiters.unregisterWaiter(otherWaiter); + done(); + }); + }); + + QUnit.test('`visit` advances readiness.', function () { + expect(2); + + equal(App._readinessDeferrals, 1, 'App is in deferred state after setupForTesting.'); + + return App.testHelpers.visit('/').then(function () { + equal(App._readinessDeferrals, 0, 'App\'s readiness was advanced by visit.'); + }); + }); + + QUnit.test('`wait` helper can be passed a resolution value', function () { + expect(4); + + var promise, wait; + + promise = new _emberRuntime.RSVP.Promise(function (resolve) { + _emberMetal.run(null, resolve, 'promise'); + }); + + _emberMetal.run(App, App.advanceReadiness); + + wait = App.testHelpers.wait; + + return wait('text').then(function (val) { + equal(val, 'text', 'can resolve to a string'); + return wait(1); + }).then(function (val) { + equal(val, 1, 'can resolve to an integer'); + return wait({ age: 10 }); + }).then(function (val) { + deepEqual(val, { age: 10 }, 'can resolve to an object'); + return wait(promise); + }).then(function (val) { + equal(val, 'promise', 'can resolve to a promise resolution value'); + }); + }); + + QUnit.test('`click` triggers appropriate events in order', function () { + expect(5); + + var click, wait, events; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + classNames: 'index-wrapper', + + didInsertElement: function () { + this.$().on('mousedown focusin mouseup click', function (e) { + events.push(e.type); + }); + } + }); + + App.XCheckboxComponent = _emberGlimmer.Component.extend({ + tagName: 'input', + attributeBindings: ['type'], + type: 'checkbox', + click: function () { + events.push('click:' + this.get('checked')); + }, + change: function () { + events.push('change:' + this.get('checked')); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#index-wrapper}}{{input type="text"}} {{x-checkbox type="checkbox"}} {{textarea}}
    {{/index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + click = App.testHelpers.click; + wait = App.testHelpers.wait; + + return wait().then(function () { + events = []; + return click('.index-wrapper'); + }).then(function () { + deepEqual(events, ['mousedown', 'mouseup', 'click'], 'fires events in order'); + }).then(function () { + events = []; + return click('.index-wrapper input[type=text]'); + }).then(function () { + deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on inputs'); + }).then(function () { + events = []; + return click('.index-wrapper textarea'); + }).then(function () { + deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on textareas'); + }).then(function () { + events = []; + return click('.index-wrapper div'); + }).then(function () { + deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on contenteditable'); + }).then(function () { + events = []; + return click('.index-wrapper input[type=checkbox]'); + }).then(function () { + // i.e. mousedown, mouseup, change:true, click, click:true + // Firefox differs so we can't assert the exact ordering here. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=843554. + equal(events.length, 5, 'fires click and change on checkboxes'); + }); + }); + + QUnit.test('`click` triggers native events with simulated X/Y coordinates', function () { + expect(15); + + var click, wait, events; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + classNames: 'index-wrapper', + + didInsertElement: function () { + var pushEvent = function (e) { + return events.push(e); + }; + this.element.addEventListener('mousedown', pushEvent); + this.element.addEventListener('mouseup', pushEvent); + this.element.addEventListener('click', pushEvent); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#index-wrapper}}some text{{/index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + click = App.testHelpers.click; + wait = App.testHelpers.wait; + + return wait().then(function () { + events = []; + return click('.index-wrapper'); + }).then(function () { + events.forEach(function (e) { + ok(e instanceof window.Event, 'The event is an instance of MouseEvent'); + ok(typeof e.screenX === 'number' && e.screenX > 0, 'screenX is correct'); + ok(typeof e.screenY === 'number' && e.screenY > 0, 'screenY is correct'); + ok(typeof e.clientX === 'number' && e.clientX > 0, 'clientX is correct'); + ok(typeof e.clientY === 'number' && e.clientY > 0, 'clientY is correct'); + }); + }); + }); + + QUnit.test('`triggerEvent` with mouseenter triggers native events with simulated X/Y coordinates', function () { + expect(5); + + var triggerEvent, wait, evt; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + classNames: 'index-wrapper', + + didInsertElement: function () { + this.element.addEventListener('mouseenter', function (e) { + return evt = e; + }); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#index-wrapper}}some text{{/index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.index-wrapper', 'mouseenter'); + }).then(function () { + ok(evt instanceof window.Event, 'The event is an instance of MouseEvent'); + ok(typeof evt.screenX === 'number' && evt.screenX > 0, 'screenX is correct'); + ok(typeof evt.screenY === 'number' && evt.screenY > 0, 'screenY is correct'); + ok(typeof evt.clientX === 'number' && evt.clientX > 0, 'clientX is correct'); + ok(typeof evt.clientY === 'number' && evt.clientY > 0, 'clientY is correct'); + }); + }); + + QUnit.test('`wait` waits for outstanding timers', function () { + expect(1); + + var wait_done = false; + + _emberMetal.run(App, App.advanceReadiness); + + _emberMetal.run.later(this, function () { + wait_done = true; + }, 500); + + return App.testHelpers.wait().then(function () { + equal(wait_done, true, 'should wait for the timer to be fired.'); + }); + }); + + QUnit.test('`wait` respects registerWaiters with optional context', function () { + expect(3); + + var obj = { + counter: 0, + ready: function () { + return ++this.counter > 2; + } + }; + + var other = 0; + function otherWaiter() { + return ++other > 2; + } + + _emberMetal.run(App, App.advanceReadiness); + _emberTestingTestWaiters.registerWaiter(obj, obj.ready); + _emberTestingTestWaiters.registerWaiter(otherWaiter); + + return App.testHelpers.wait().then(function () { + equal(obj.ready(), true, 'should not resolve until our waiter is ready'); + _emberTestingTestWaiters.unregisterWaiter(obj, obj.ready); + obj.counter = 0; + return App.testHelpers.wait(); + }).then(function () { + equal(obj.counter, 0, 'the unregistered waiter should still be at 0'); + equal(otherWaiter(), true, 'other waiter should still be registered'); + }).finally(function () { + _emberTestingTestWaiters.unregisterWaiter(otherWaiter); + }); + }); + + QUnit.test('`wait` does not error if routing has not begun', function () { + expect(1); + + return App.testHelpers.wait().then(function () { + ok(true, 'should not error without `visit`'); + }); + }); + + QUnit.test('`triggerEvent accepts an optional options hash without context', function () { + expect(3); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$('.input').on('keydown change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="scope" class="input"}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.input', 'keydown', { keyCode: 13 }); + }).then(function () { + equal(event.keyCode, 13, 'options were passed'); + equal(event.type, 'keydown', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'scope', 'triggered on the correct element'); + }); + }); + + QUnit.test('`triggerEvent can limit searching for a selector to a scope', function () { + expect(2); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + + didInsertElement: function () { + this.$('.input').on('blur change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="outside-scope" class="input"}}
    {{input type="text" id="inside-scope" class="input"}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.input', '#limited', 'blur'); + }).then(function () { + equal(event.type, 'blur', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'inside-scope', 'triggered on the correct element'); + }); + }); + + QUnit.test('`triggerEvent` can be used to trigger arbitrary events', function () { + expect(2); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$('#foo').on('blur change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="foo"}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('#foo', 'blur'); + }).then(function () { + equal(event.type, 'blur', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'foo', 'triggered on the correct element'); + }); + }); + + QUnit.test('`fillIn` takes context into consideration', function () { + expect(2); + var fillIn, find, visit, andThen; + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{input type="text" id="first" class="current"}}
    {{input type="text" id="second" class="current"}}')); + + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + find = App.testHelpers.find; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + + visit('/'); + fillIn('.current', '#parent', 'current value'); + + return andThen(function () { + equal(find('#first').val(), 'current value'); + equal(find('#second').val(), ''); + }); + }); + + QUnit.test('`fillIn` focuses on the element', function () { + expect(2); + var fillIn, find, visit, andThen, wait; + + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + wasFocused: function () { + ok(true, 'focusIn event was triggered'); + } + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{input type="text" id="first" focus-in="wasFocused"}}
    ')); + + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + find = App.testHelpers.find; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + wait = App.testHelpers.wait; + + visit('/'); + fillIn('#first', 'current value'); + andThen(function () { + equal(find('#first').val(), 'current value'); + }); + + return wait(); + }); + + QUnit.test('`fillIn` fires `input` and `change` events in the proper order', function () { + expect(1); + + var fillIn, visit, andThen, wait; + var events = []; + App.IndexController = _emberRuntime.Controller.extend({ + actions: { + oninputHandler: function (e) { + events.push(e.type); + }, + onchangeHandler: function (e) { + events.push(e.type); + } + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('')); + + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + wait = App.testHelpers.wait; + + visit('/'); + fillIn('#first', 'current value'); + andThen(function () { + deepEqual(events, ['input', 'change'], '`input` and `change` events are fired in the proper order'); + }); + + return wait(); + }); + + QUnit.test('`fillIn` only sets the value in the first matched element', function () { + var fillIn = undefined, + find = undefined, + visit = undefined, + andThen = undefined, + wait = undefined; + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('')); + _emberMetal.run(App, App.advanceReadiness); + + fillIn = App.testHelpers.fillIn; + find = App.testHelpers.find; + visit = App.testHelpers.visit; + andThen = App.testHelpers.andThen; + wait = App.testHelpers.wait; + + visit('/'); + fillIn('input.in-test', 'new value'); + andThen(function () { + equal(find('#first').val(), 'new value'); + equal(find('#second').val(), ''); + }); + + return wait(); + }); + + QUnit.test('`triggerEvent accepts an optional options hash and context', function () { + expect(3); + + var triggerEvent, wait, event; + + App.IndexWrapperComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$('.input').on('keydown change', function (e) { + event = e; + }); + } + }); + + _emberGlimmer.setTemplate('components/index-wrapper', _emberTemplateCompiler.compile('{{input type="text" id="outside-scope" class="input"}}
    {{input type="text" id="inside-scope" class="input"}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{index-wrapper}}')); + + _emberMetal.run(App, App.advanceReadiness); + + triggerEvent = App.testHelpers.triggerEvent; + wait = App.testHelpers.wait; + + return wait().then(function () { + return triggerEvent('.input', '#limited', 'keydown', { keyCode: 13 }); + }).then(function () { + equal(event.keyCode, 13, 'options were passed'); + equal(event.type, 'keydown', 'correct event was triggered'); + equal(event.target.getAttribute('id'), 'inside-scope', 'triggered on the correct element'); + }); + }); + + QUnit.module('ember-testing debugging helpers', { + setup: function () { + setupApp(); + + _emberMetal.run(function () { + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + }); + + _emberMetal.run(App, 'advanceReadiness'); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('pauseTest pauses', function () { + expect(1); + + function fakeAdapterAsyncStart() { + ok(true, 'Async start should be called after waiting for other helpers'); + } + + App.testHelpers.andThen(function () { + _emberTestingTest.default.adapter.asyncStart = fakeAdapterAsyncStart; + }); + + App.testHelpers.pauseTest(); + }); + + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + QUnit.test('resumeTest resumes paused tests', function () { + expect(1); + + var pausePromise = App.testHelpers.pauseTest(); + setTimeout(function () { + return App.testHelpers.resumeTest(); + }, 0); + + return pausePromise.then(function () { + return ok(true, 'pauseTest promise was resolved'); + }); + }); + + QUnit.test('resumeTest throws if nothing to resume', function () { + expect(1); + + throws(function () { + return App.testHelpers.resumeTest(); + }, /Testing has not been paused. There is nothing to resume./); + }); + } + + QUnit.module('ember-testing routing helpers', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.setupForTesting(); + + App.injectTestHelpers(); + + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + App.Router.map(function () { + this.route('posts', { resetNamespace: true }, function () { + this.route('new'); + }); + }); + }); + + _emberMetal.run(App, 'advanceReadiness'); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('currentRouteName for \'/\'', function () { + expect(3); + + return App.testHelpers.visit('/').then(function () { + equal(App.testHelpers.currentRouteName(), 'index', 'should equal \'index\'.'); + equal(App.testHelpers.currentPath(), 'index', 'should equal \'index\'.'); + equal(App.testHelpers.currentURL(), '/', 'should equal \'/\'.'); + }); + }); + + QUnit.test('currentRouteName for \'/posts\'', function () { + expect(3); + + return App.testHelpers.visit('/posts').then(function () { + equal(App.testHelpers.currentRouteName(), 'posts.index', 'should equal \'posts.index\'.'); + equal(App.testHelpers.currentPath(), 'posts.index', 'should equal \'posts.index\'.'); + equal(App.testHelpers.currentURL(), '/posts', 'should equal \'/posts\'.'); + }); + }); + + QUnit.test('currentRouteName for \'/posts/new\'', function () { + expect(3); + + return App.testHelpers.visit('/posts/new').then(function () { + equal(App.testHelpers.currentRouteName(), 'posts.new', 'should equal \'posts.new\'.'); + equal(App.testHelpers.currentPath(), 'posts.new', 'should equal \'posts.new\'.'); + equal(App.testHelpers.currentURL(), '/posts/new', 'should equal \'/posts/new\'.'); + }); + }); + + QUnit.module('ember-testing pendingRequests', { + setup: function () { + setupApp(); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('pendingRequests is maintained for ajaxSend and ajaxComplete events', function () { + equal(_emberTestingTestPending_requests.pendingRequests(), 0); + var xhr = { some: 'xhr' }; + _emberViews.jQuery(document).trigger('ajaxSend', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); + _emberViews.jQuery(document).trigger('ajaxComplete', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 0, 'Ember.Test.pendingRequests was decremented'); + }); + + QUnit.test('pendingRequests is ignores ajaxComplete events from past setupForTesting calls', function () { + equal(_emberTestingTestPending_requests.pendingRequests(), 0); + var xhr = { some: 'xhr' }; + _emberViews.jQuery(document).trigger('ajaxSend', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); + + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + equal(_emberTestingTestPending_requests.pendingRequests(), 0, 'Ember.Test.pendingRequests was reset'); + + var altXhr = { some: 'more xhr' }; + _emberViews.jQuery(document).trigger('ajaxSend', altXhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); + _emberViews.jQuery(document).trigger('ajaxComplete', xhr); + equal(_emberTestingTestPending_requests.pendingRequests(), 1, 'Ember.Test.pendingRequests is not impressed with your unexpected complete'); + }); + + QUnit.test('pendingRequests is reset by setupForTesting', function () { + _emberTestingTestPending_requests.incrementPendingRequests(); + _emberMetal.run(function () { + _emberTestingSetup_for_testing.default(); + }); + equal(_emberTestingTestPending_requests.pendingRequests(), 0, 'pendingRequests is reset'); + }); + + QUnit.module('ember-testing async router', { + setup: function () { + cleanup(); + + _emberMetal.run(function () { + App = _emberApplication.Application.create(); + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + App.Router.map(function () { + this.route('user', { resetNamespace: true }, function () { + this.route('profile'); + this.route('edit'); + }); + }); + + App.UserRoute = _emberRouting.Route.extend({ + model: function () { + return resolveLater(); + } + }); + + App.UserProfileRoute = _emberRouting.Route.extend({ + beforeModel: function () { + var self = this; + return resolveLater().then(function () { + self.transitionTo('user.edit'); + }); + } + }); + + // Emulates a long-running unscheduled async operation. + function resolveLater() { + var promise; + + _emberMetal.run(function () { + promise = new _emberRuntime.RSVP.Promise(function (resolve) { + // The wait() helper has a 10ms tick. We should resolve() after at least one tick + // to test whether wait() held off while the async router was still loading. 20ms + // should be enough. + setTimeout(function () { + _emberMetal.run(function () { + resolve(_emberRuntime.Object.create({ firstName: 'Tom' })); + }); + }, 20); + }); + }); + + return promise; + } + + App.setupForTesting(); + }); + + App.injectTestHelpers(); + _emberMetal.run(App, 'advanceReadiness'); + }, + + teardown: function () { + cleanup(); + } + }); + + QUnit.test('currentRouteName for \'/user\'', function () { + expect(4); + + return App.testHelpers.visit('/user').then(function () { + equal(currentRouteName(App), 'user.index', 'should equal \'user.index\'.'); + equal(currentPath(App), 'user.index', 'should equal \'user.index\'.'); + equal(currentURL(App), '/user', 'should equal \'/user\'.'); + equal(App.__container__.lookup('route:user').get('controller.model.firstName'), 'Tom', 'should equal \'Tom\'.'); + }); + }); + + QUnit.test('currentRouteName for \'/user/profile\'', function () { + expect(4); + + return App.testHelpers.visit('/user/profile').then(function () { + equal(currentRouteName(App), 'user.edit', 'should equal \'user.edit\'.'); + equal(currentPath(App), 'user.edit', 'should equal \'user.edit\'.'); + equal(currentURL(App), '/user/edit', 'should equal \'/user/edit\'.'); + equal(App.__container__.lookup('route:user').get('controller.model.firstName'), 'Tom', 'should equal \'Tom\'.'); + }); + }); + + var originalVisitHelper, originalFindHelper, originalWaitHelper; + + QUnit.module('can override built-in helpers', { + setup: function () { + originalVisitHelper = _emberTestingTest.default._helpers.visit; + originalFindHelper = _emberTestingTest.default._helpers.find; + originalWaitHelper = _emberTestingTest.default._helpers.wait; + + _emberViews.jQuery('').appendTo('head'); + _emberViews.jQuery('
    ').appendTo('body'); + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + + App.setupForTesting(); + }); + }, + + teardown: function () { + cleanup(); + + _emberTestingTest.default._helpers.visit = originalVisitHelper; + _emberTestingTest.default._helpers.find = originalFindHelper; + _emberTestingTest.default._helpers.wait = originalWaitHelper; + } + }); + + QUnit.test('can override visit helper', function () { + expect(1); + + _emberTestingTest.default.registerHelper('visit', function () { + ok(true, 'custom visit helper was called'); + }); + + App.injectTestHelpers(); + + return App.testHelpers.visit(); + }); + + QUnit.test('can override find helper', function () { + expect(1); + + _emberTestingTest.default.registerHelper('find', function () { + ok(true, 'custom find helper was called'); + + return ['not empty array']; + }); + + App.injectTestHelpers(); + + return App.testHelpers.findWithAssert('.who-cares'); + }); +}); +// ensure that the helpers are loaded +// ensure the initializer is setup +enifed('ember-testing/tests/helpers_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/helpers_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/helpers_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/integration_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-testing/test', 'ember-routing', 'ember-application', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberMetal, _emberRuntime, _emberViews, _emberTestingTest, _emberRouting, _emberApplication, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + var App, find, visit; + var originalAdapter = _emberTestingTest.default.adapter; + + QUnit.module('ember-testing Integration', { + setup: function () { + _emberViews.jQuery('
    ').appendTo('body'); + _emberMetal.run(function () { + _emberGlimmer.setTemplate('people', _emberTemplateCompiler.compile('
    {{#each model as |person|}}
    {{person.firstName}}
    {{/each}}
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + + App = _emberApplication.Application.create({ + rootElement: '#ember-testing' + }); + + App.Router.map(function () { + this.route('people', { path: '/' }); + }); + + App.PeopleRoute = _emberRouting.Route.extend({ + model: function () { + return App.Person.find(); + } + }); + + App.PeopleController = _emberRuntime.Controller.extend({}); + + App.Person = _emberRuntime.Object.extend({ + firstName: '' + }); + + App.Person.reopenClass({ + find: function () { + return _emberRuntime.A(); + } + }); + + App.setupForTesting(); + }); + + _emberMetal.run(function () { + App.reset(); + }); + + App.injectTestHelpers(); + + find = window.find; + visit = window.visit; + }, + + teardown: function () { + App.removeTestHelpers(); + _emberGlimmer.setTemplates({}); + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + _emberMetal.run(App, App.destroy); + App = null; + _emberTestingTest.default.adapter = originalAdapter; + } + }); + + QUnit.test('template is bound to empty array of people', function () { + App.Person.find = function () { + return _emberRuntime.A(); + }; + _emberMetal.run(App, 'advanceReadiness'); + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 0, 'successfully stubbed an empty array of people'); + }); + }); + + QUnit.test('template is bound to array of 2 people', function () { + App.Person.find = function () { + var people = _emberRuntime.A(); + var first = App.Person.create({ firstName: 'x' }); + var last = App.Person.create({ firstName: 'y' }); + _emberMetal.run(people, people.pushObject, first); + _emberMetal.run(people, people.pushObject, last); + return people; + }; + _emberMetal.run(App, 'advanceReadiness'); + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 2, 'successfully stubbed a non empty array of people'); + }); + }); + + QUnit.test('template is again bound to empty array of people', function () { + App.Person.find = function () { + return _emberRuntime.A(); + }; + _emberMetal.run(App, 'advanceReadiness'); + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 0, 'successfully stubbed another empty array of people'); + }); + }); + + QUnit.test('`visit` can be called without advancedReadiness.', function () { + App.Person.find = function () { + return _emberRuntime.A(); + }; + + visit('/').then(function () { + var rows = find('.name').length; + equal(rows, 0, 'stubbed an empty array of people without calling advancedReadiness.'); + }); + }); +}); +enifed('ember-testing/tests/integration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/integration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/integration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/reexports_test', ['exports', 'ember', 'internal-test-helpers'], function (exports, _ember, _internalTestHelpers) { + 'use strict'; + + QUnit.module('ember-testing reexports'); + + [ + // ember-testing + ['Test', 'ember-testing'], ['Test.Adapter', 'ember-testing', 'Adapter'], ['Test.QUnitAdapter', 'ember-testing', 'QUnitAdapter'], ['setupForTesting', 'ember-testing']].forEach(function (reexport) { + var path = reexport[0]; + var moduleId = reexport[1]; + var exportName = reexport[2]; + + // default path === exportName if none present + if (!exportName) { + exportName = path; + } + + QUnit.test('Ember.' + path + ' exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_ember.default, assert, path, moduleId, exportName); + }); + }); +}); +enifed('ember-testing/tests/reexports_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/reexports_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/reexports_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/simple_setup', ['exports', 'ember-metal', 'ember-views'], function (exports, _emberMetal, _emberViews) { + 'use strict'; + + var App; + + QUnit.module('Simple Testing Setup', { + teardown: function () { + if (App) { + App.removeTestHelpers(); + _emberViews.jQuery('#ember-testing-container, #ember-testing').remove(); + _emberMetal.run(App, 'destroy'); + App = null; + } + } + }); +}); +enifed('ember-testing/tests/simple_setup.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/simple_setup.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/simple_setup.js should pass ESLint\n\n'); + }); +}); +enifed('ember-testing/tests/test/waiters-test', ['exports', 'ember-testing/test/waiters'], function (exports, _emberTestingTestWaiters) { + 'use strict'; + + var Waiters = (function () { + function Waiters() { + this._waiters = []; + } + + Waiters.prototype.add = function add() { + this._waiters.push([].concat(babelHelpers.slice.call(arguments))); + }; + + Waiters.prototype.register = function register() { + this.forEach(function () { + _emberTestingTestWaiters.registerWaiter.apply(undefined, arguments); + }); + }; + + Waiters.prototype.unregister = function unregister() { + this.forEach(function () { + _emberTestingTestWaiters.unregisterWaiter.apply(undefined, arguments); + }); + }; + + Waiters.prototype.forEach = function forEach(callback) { + for (var i = 0; i < this._waiters.length; i++) { + var args = this._waiters[i]; + + callback.apply(undefined, args); + } + }; + + Waiters.prototype.check = function check() { + this.register(); + var result = _emberTestingTestWaiters.checkWaiters(); + this.unregister(); + + return result; + }; + + return Waiters; + })(); + + QUnit.module('ember-testing: waiters', { + setup: function () { + this.waiters = new Waiters(); + }, + + teardown: function () { + this.waiters.unregister(); + } + }); + + QUnit.test('registering a waiter', function (assert) { + assert.expect(2); + + var obj = { foo: true }; + + this.waiters.add(obj, function () { + assert.ok(this.foo, 'has proper `this` context'); + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'is called'); + return true; + }); + + this.waiters.check(); + }); + + QUnit.test('unregistering a waiter', function (assert) { + assert.expect(2); + + var obj = { foo: true }; + + this.waiters.add(obj, function () { + assert.ok(true, 'precond - waiter with context is registered'); + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter without context is registered'); + return true; + }); + + this.waiters.check(); + this.waiters.unregister(); + + _emberTestingTestWaiters.checkWaiters(); + }); + + QUnit.test('checkWaiters returns false if all waiters return true', function (assert) { + assert.expect(3); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return true; + }); + + assert.notOk(this.waiters.check(), 'checkWaiters returns true if all waiters return true'); + }); + + QUnit.test('checkWaiters returns true if any waiters return false', function (assert) { + assert.expect(3); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return true; + }); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return false; + }); + + assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false'); + }); + + QUnit.test('checkWaiters short circuits after first falsey waiter', function (assert) { + assert.expect(2); + + this.waiters.add(function () { + assert.ok(true, 'precond - waiter is registered'); + + return false; + }); + + this.waiters.add(function () { + assert.notOk(true, 'waiter should not be called'); + }); + + assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false'); + }); + + QUnit.test('generateDeprecatedWaitersArray provides deprecated access to waiters array', function (assert) { + var waiter1 = function () {}; + var waiter2 = function () {}; + + this.waiters.add(waiter1); + this.waiters.add(waiter2); + + this.waiters.register(); + + var waiters = undefined; + expectDeprecation(function () { + waiters = _emberTestingTestWaiters.generateDeprecatedWaitersArray(); + }, /Usage of `Ember.Test.waiters` is deprecated/); + + assert.deepEqual(waiters, [[null, waiter1], [null, waiter2]]); + }); +}); +enifed('ember-testing/tests/test/waiters-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-testing/tests/test/waiters-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-testing/tests/test/waiters-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/apply-str.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/apply-str.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/apply-str.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/assign.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/assign.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/assign.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/dictionary.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/dictionary.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/dictionary.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/empty-object.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/empty-object.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/empty-object.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/guid.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/guid.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/guid.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/inspect.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/inspect.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/inspect.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/intern.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/intern.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/intern.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/invoke.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/invoke.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/invoke.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/lookup-descriptor.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/lookup-descriptor.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/lookup-descriptor.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/make-array.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/make-array.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/make-array.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/name.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/name.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/name.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/owner.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/owner.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/owner.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/proxy-utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/proxy-utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/proxy-utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/super.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/super.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/super.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/symbol.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/symbol.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/symbol.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/assign_test', ['exports', 'ember-utils/assign'], function (exports, _emberUtilsAssign) { + 'use strict'; + + QUnit.module('Ember.assign'); + + QUnit.test('Ember.assign', function () { + var a = { a: 1 }; + var b = { b: 2 }; + var c = { c: 3 }; + var a2 = { a: 4 }; + + _emberUtilsAssign.default(a, b, c, a2); + + deepEqual(a, { a: 4, b: 2, c: 3 }); + deepEqual(b, { b: 2 }); + deepEqual(c, { c: 3 }); + deepEqual(a2, { a: 4 }); + }); +}); +enifed('ember-utils/tests/assign_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/assign_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/assign_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/can_invoke_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + var obj = undefined; + + QUnit.module('Ember.canInvoke', { + setup: function () { + obj = { + foobar: 'foobar', + aMethodThatExists: function () {} + }; + }, + + teardown: function () { + obj = undefined; + } + }); + + QUnit.test('should return false if the object doesn\'t exist', function () { + equal(_emberUtilsIndex.canInvoke(undefined, 'aMethodThatDoesNotExist'), false); + }); + + QUnit.test('should return true if the method exists on the object', function () { + equal(_emberUtilsIndex.canInvoke(obj, 'aMethodThatExists'), true); + }); + + QUnit.test('should return false if the method doesn\'t exist on the object', function () { + equal(_emberUtilsIndex.canInvoke(obj, 'aMethodThatDoesNotExist'), false); + }); + + QUnit.test('should return false if the property exists on the object but is a non-function', function () { + equal(_emberUtilsIndex.canInvoke(obj, 'foobar'), false); + }); +}); +enifed('ember-utils/tests/can_invoke_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/can_invoke_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/can_invoke_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/checkHasSuper_test', ['exports', 'ember-environment', 'ember-utils/index'], function (exports, _emberEnvironment, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('checkHasSuper'); + + // Only run this test on browsers that we are certain should have function + // source available. This allows the test suite to continue to pass on other + // platforms that correctly (for them) fall back to the "always wrap" code. + if (_emberEnvironment.environment.isPhantom || _emberEnvironment.environment.isChrome || _emberEnvironment.environment.isFirefox) { + QUnit.test('does not super wrap needlessly [GH #12462]', function (assert) { + assert.notOk(_emberUtilsIndex.checkHasSuper(function () {}), 'empty function does not have super'); + }); + } +}); +enifed('ember-utils/tests/checkHasSuper_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/checkHasSuper_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/checkHasSuper_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/generate_guid_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('Ember.generateGuid'); + + QUnit.test('Prefix', function () { + var a = {}; + + ok(_emberUtilsIndex.generateGuid(a, 'tyrell').indexOf('tyrell') > -1, 'guid can be prefixed'); + }); +}); +enifed('ember-utils/tests/generate_guid_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/generate_guid_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/generate_guid_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/guid_for_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('guidFor'); + + function sameGuid(a, b, message) { + equal(_emberUtilsIndex.guidFor(a), _emberUtilsIndex.guidFor(b), message); + } + + function diffGuid(a, b, message) { + ok(_emberUtilsIndex.guidFor(a) !== _emberUtilsIndex.guidFor(b), message); + } + + function nanGuid(obj) { + var type = typeof obj; + ok(isNaN(parseInt(_emberUtilsIndex.guidFor(obj), 0)), 'guids for ' + type + 'don\'t parse to numbers'); + } + + QUnit.test('Object', function () { + var a = {}; + var b = {}; + + sameGuid(a, a, 'same object always yields same guid'); + diffGuid(a, b, 'different objects yield different guids'); + nanGuid(a); + }); + + QUnit.test('strings', function () { + var a = 'string A'; + var aprime = 'string A'; + var b = 'String B'; + + sameGuid(a, a, 'same string always yields same guid'); + sameGuid(a, aprime, 'identical strings always yield the same guid'); + diffGuid(a, b, 'different strings yield different guids'); + nanGuid(a); + }); + + QUnit.test('numbers', function () { + var a = 23; + var aprime = 23; + var b = 34; + + sameGuid(a, a, 'same numbers always yields same guid'); + sameGuid(a, aprime, 'identical numbers always yield the same guid'); + diffGuid(a, b, 'different numbers yield different guids'); + nanGuid(a); + }); + + QUnit.test('numbers', function () { + var a = true; + var aprime = true; + var b = false; + + sameGuid(a, a, 'same booleans always yields same guid'); + sameGuid(a, aprime, 'identical booleans always yield the same guid'); + diffGuid(a, b, 'different boolean yield different guids'); + nanGuid(a); + nanGuid(b); + }); + + QUnit.test('null and undefined', function () { + var a = null; + var aprime = null; + var b = undefined; + + sameGuid(a, a, 'null always returns the same guid'); + sameGuid(b, b, 'undefined always returns the same guid'); + sameGuid(a, aprime, 'different nulls return the same guid'); + diffGuid(a, b, 'null and undefined return different guids'); + nanGuid(a); + nanGuid(b); + }); + + QUnit.test('arrays', function () { + var a = ['a', 'b', 'c']; + var aprime = ['a', 'b', 'c']; + var b = ['1', '2', '3']; + + sameGuid(a, a, 'same instance always yields same guid'); + diffGuid(a, aprime, 'identical arrays always yield the same guid'); + diffGuid(a, b, 'different arrays yield different guids'); + nanGuid(a); + }); +}); +enifed('ember-utils/tests/guid_for_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/guid_for_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/guid_for_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/inspect_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + // Symbol is not defined on pre-ES2015 runtimes, so this let's us safely test + // for it's existence (where a simple `if (Symbol)` would ReferenceError) + var HAS_NATIVE_SYMBOL = typeof Symbol === 'function'; + + QUnit.module('Ember.inspect'); + + QUnit.test('strings', function () { + equal(_emberUtilsIndex.inspect('foo'), 'foo'); + }); + + QUnit.test('numbers', function () { + equal(_emberUtilsIndex.inspect(2.6), '2.6'); + }); + + QUnit.test('null', function () { + equal(_emberUtilsIndex.inspect(null), 'null'); + }); + + QUnit.test('undefined', function () { + equal(_emberUtilsIndex.inspect(undefined), 'undefined'); + }); + + QUnit.test('true', function () { + equal(_emberUtilsIndex.inspect(true), 'true'); + }); + + QUnit.test('false', function () { + equal(_emberUtilsIndex.inspect(false), 'false'); + }); + + QUnit.test('object', function () { + equal(_emberUtilsIndex.inspect({}), '{}'); + equal(_emberUtilsIndex.inspect({ foo: 'bar' }), '{foo: bar}'); + equal(_emberUtilsIndex.inspect({ foo: function () { + return this; + } }), '{foo: function() { ... }}'); + }); + + QUnit.test('objects without a prototype', function () { + var prototypelessObj = Object.create(null); + equal(_emberUtilsIndex.inspect({ foo: prototypelessObj }), '{foo: [object Object]}'); + }); + + QUnit.test('array', function () { + equal(_emberUtilsIndex.inspect([1, 2, 3]), '[1,2,3]'); + }); + + QUnit.test('regexp', function () { + equal(_emberUtilsIndex.inspect(/regexp/), '/regexp/'); + }); + + QUnit.test('date', function () { + var inspected = _emberUtilsIndex.inspect(new Date('Sat Apr 30 2011 13:24:11')); + ok(inspected.match(/Sat Apr 30/), 'The inspected date has its date'); + ok(inspected.match(/2011/), 'The inspected date has its year'); + ok(inspected.match(/13:24:11/), 'The inspected date has its time'); + }); + + QUnit.test('inspect outputs the toString() representation of Symbols', function () { + if (HAS_NATIVE_SYMBOL) { + var symbol = Symbol('test'); + equal(_emberUtilsIndex.inspect(symbol), 'Symbol(test)'); + } else { + expect(0); + } + }); +}); +enifed('ember-utils/tests/inspect_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/inspect_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/inspect_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/make_array_test', ['exports', 'ember-utils/make-array'], function (exports, _emberUtilsMakeArray) { + 'use strict'; + + QUnit.module('Ember.makeArray'); + + QUnit.test('undefined', function () { + deepEqual(_emberUtilsMakeArray.default(), []); + deepEqual(_emberUtilsMakeArray.default(undefined), []); + }); + + QUnit.test('null', function () { + deepEqual(_emberUtilsMakeArray.default(null), []); + }); + + QUnit.test('string', function () { + deepEqual(_emberUtilsMakeArray.default('lindsay'), ['lindsay']); + }); + + QUnit.test('number', function () { + deepEqual(_emberUtilsMakeArray.default(0), [0]); + deepEqual(_emberUtilsMakeArray.default(1), [1]); + }); + + QUnit.test('array', function () { + deepEqual(_emberUtilsMakeArray.default([1, 2, 42]), [1, 2, 42]); + }); + + QUnit.test('true', function () { + deepEqual(_emberUtilsMakeArray.default(true), [true]); + }); + + QUnit.test('false', function () { + deepEqual(_emberUtilsMakeArray.default(false), [false]); + }); + + QUnit.test('object', function () { + deepEqual(_emberUtilsMakeArray.default({}), [{}]); + }); +}); +enifed('ember-utils/tests/make_array_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/make_array_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/make_array_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/to-string-test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + QUnit.module('ember-utils toString'); + + QUnit.test('toString uses an object\'s toString method when available', function () { + var obj = { + toString: function () { + return 'bob'; + } + }; + + strictEqual(_emberUtilsIndex.toString(obj), 'bob'); + }); + + QUnit.test('toString falls back to Object.prototype.toString', function () { + var obj = Object.create(null); + + strictEqual(_emberUtilsIndex.toString(obj), ({}).toString()); + }); +}); +enifed('ember-utils/tests/to-string-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/to-string-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/to-string-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/tests/try_invoke_test', ['exports', 'ember-utils/index'], function (exports, _emberUtilsIndex) { + 'use strict'; + + var obj = undefined; + + QUnit.module('Ember.tryInvoke', { + setup: function () { + obj = { + aMethodThatExists: function () { + return true; + }, + aMethodThatTakesArguments: function (arg1, arg2) { + return arg1 === arg2; + } + }; + }, + + teardown: function () { + obj = undefined; + } + }); + + QUnit.test('should return undefined when the object doesn\'t exist', function () { + equal(_emberUtilsIndex.tryInvoke(undefined, 'aMethodThatDoesNotExist'), undefined); + }); + + QUnit.test('should return undefined when asked to perform a method that doesn\'t exist on the object', function () { + equal(_emberUtilsIndex.tryInvoke(obj, 'aMethodThatDoesNotExist'), undefined); + }); + + QUnit.test('should return what the method returns when asked to perform a method that exists on the object', function () { + equal(_emberUtilsIndex.tryInvoke(obj, 'aMethodThatExists'), true); + }); + + QUnit.test('should return what the method returns when asked to perform a method that takes arguments and exists on the object', function () { + equal(_emberUtilsIndex.tryInvoke(obj, 'aMethodThatTakesArguments', [true, true]), true); + }); +}); +enifed('ember-utils/tests/try_invoke_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/tests/try_invoke_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/tests/try_invoke_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/to-string.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/to-string.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/to-string.js should pass ESLint\n\n'); + }); +}); +enifed('ember-utils/weak-map-utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-utils/weak-map-utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-utils/weak-map-utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/compat/attrs.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/compat/attrs.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/compat/attrs.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/compat/fallback-view-registry.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/compat/fallback-view-registry.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/compat/fallback-view-registry.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/component_lookup.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/component_lookup.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/component_lookup.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/action_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/action_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/action_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/child_views_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/child_views_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/child_views_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/class_names_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/class_names_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/class_names_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/text_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/text_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/text_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/view_state_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/view_state_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/view_state_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/mixins/view_support.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/mixins/view_support.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/mixins/view_support.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/action_manager.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/action_manager.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/action_manager.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/event_dispatcher.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/event_dispatcher.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/event_dispatcher.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/ext.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/ext.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/ext.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/jquery.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/jquery.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/jquery.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/lookup_partial.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/lookup_partial.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/lookup_partial.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/system/utils.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/system/utils.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/system/utils.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/utils/lookup-component.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/utils/lookup-component.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/utils/lookup-component.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/core_view.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/core_view.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/core_view.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/default.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/default.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/default.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/destroying.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/destroying.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/destroying.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/has_element.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/has_element.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/has_element.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/in_dom.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/in_dom.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/in_dom.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/states/pre_render.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/states/pre_render.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/states/pre_render.js should pass ESLint\n\n'); + }); +}); +enifed('ember-views/views/view.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember-views/views/view.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember-views/views/view.js should pass ESLint\n\n'); + }); +}); +enifed('ember/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/index.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/application_lifecycle_test', ['exports', 'ember-application', 'ember-routing', 'ember-metal', 'ember-glimmer', 'ember-views', 'ember-template-compiler'], function (exports, _emberApplication, _emberRouting, _emberMetal, _emberGlimmer, _emberViews, _emberTemplateCompiler) { + 'use strict'; + + var App = undefined, + TEMPLATES = undefined, + appInstance = undefined, + router = undefined; + + function setupApp(klass) { + _emberMetal.run(function () { + App = klass.create({ + rootElement: '#qunit-fixture' + }); + + App.Router = App.Router.extend({ + location: 'none' + }); + + App.deferReadiness(); + + appInstance = App.__deprecatedInstance__; + }); + } + + QUnit.module('Application Lifecycle', { + setup: function () { + TEMPLATES = _emberGlimmer.getTemplates(); + setupApp(_emberApplication.Application.extend()); + }, + + teardown: function () { + router = null; + _emberMetal.run(App, 'destroy'); + _emberGlimmer.setTemplates({}); + } + }); + + function handleURL(path) { + router = appInstance.lookup('router:main'); + return _emberMetal.run(function () { + return router.handleURL(path).then(function (value) { + ok(true, 'url: `' + path + '` was handled'); + return value; + }, function (reason) { + ok(false, reason); + throw reason; + }); + }); + } + + QUnit.test('Resetting the application allows controller properties to be set when a route deactivates', function () { + App.Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('home').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('home').set('selectedMenuItem', null); + } + }); + App.ApplicationRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('application').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('application').set('selectedMenuItem', null); + } + }); + + appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + + handleURL('/'); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), 'home'); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), 'home'); + + App.reset(); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), null); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), null); + }); + + QUnit.test('Destroying the application resets the router before the appInstance is destroyed', function () { + App.Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('home').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('home').set('selectedMenuItem', null); + } + }); + App.ApplicationRoute = _emberRouting.Route.extend({ + setupController: function () { + this.controllerFor('application').set('selectedMenuItem', 'home'); + }, + deactivate: function () { + this.controllerFor('application').set('selectedMenuItem', null); + } + }); + + appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + + handleURL('/'); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), 'home'); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), 'home'); + + _emberMetal.run(App, 'destroy'); + + equal(_emberRouting.controllerFor(appInstance, 'home').get('selectedMenuItem'), null); + equal(_emberRouting.controllerFor(appInstance, 'application').get('selectedMenuItem'), null); + }); + + QUnit.test('Destroying a route after the router does create an undestroyed `toplevelView`', function () { + App.Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplates({ + index: _emberTemplateCompiler.compile('Index!'), + application: _emberTemplateCompiler.compile('Application! {{outlet}}') + }); + + App.IndexRoute = _emberRouting.Route.extend(); + _emberMetal.run(App, 'advanceReadiness'); + + handleURL('/'); + + var router = appInstance.lookup('router:main'); + var route = appInstance.lookup('route:index'); + + _emberMetal.run(router, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was cleared'); + + _emberMetal.run(route, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + + _emberMetal.run(App, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + }); + + QUnit.test('initializers can augment an applications customEvents hash', function (assert) { + assert.expect(1); + + _emberMetal.run(App, 'destroy'); + + var ApplicationSubclass = _emberApplication.Application.extend(); + + ApplicationSubclass.initializer({ + name: 'customize-things', + initialize: function (application) { + application.customEvents = { + wowza: 'wowza' + }; + } + }); + + setupApp(ApplicationSubclass); + + App.FooBarComponent = _emberGlimmer.Component.extend({ + wowza: function () { + assert.ok(true, 'fired the event!'); + } + }); + + TEMPLATES['application'] = _emberTemplateCompiler.compile('{{foo-bar}}'); + TEMPLATES['components/foo-bar'] = _emberTemplateCompiler.compile('
    '); + + _emberMetal.run(App, 'advanceReadiness'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#wowza-thingy').trigger('wowza'); + }); + }); + + QUnit.test('instanceInitializers can augment an the customEvents hash', function (assert) { + assert.expect(1); + + _emberMetal.run(App, 'destroy'); + + var ApplicationSubclass = _emberApplication.Application.extend(); + + ApplicationSubclass.instanceInitializer({ + name: 'customize-things', + initialize: function (application) { + application.customEvents = { + herky: 'jerky' + }; + } + }); + + setupApp(ApplicationSubclass); + + App.FooBarComponent = _emberGlimmer.Component.extend({ + jerky: function () { + assert.ok(true, 'fired the event!'); + } + }); + + TEMPLATES['application'] = _emberTemplateCompiler.compile('{{foo-bar}}'); + TEMPLATES['components/foo-bar'] = _emberTemplateCompiler.compile('
    '); + + _emberMetal.run(App, 'advanceReadiness'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#herky-thingy').trigger('herky'); + }); + }); +}); +enifed('ember/tests/application_lifecycle_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/application_lifecycle_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/application_lifecycle_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/component_registration_test', ['exports', 'ember-runtime', 'ember-metal', 'ember-application', 'ember-routing', 'ember-template-compiler', 'ember-glimmer', 'ember-views'], function (exports, _emberRuntime, _emberMetal, _emberApplication, _emberRouting, _emberTemplateCompiler, _emberGlimmer, _emberViews) { + 'use strict'; + + var App = undefined, + appInstance = undefined; + + function prepare() { + _emberGlimmer.setTemplate('components/expand-it', _emberTemplateCompiler.compile('

    hello {{yield}}

    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('Hello world {{#expand-it}}world{{/expand-it}}')); + } + + function cleanup() { + _emberMetal.run(function () { + try { + if (App) { + App.destroy(); + } + App = appInstance = null; + } finally { + _emberGlimmer.setTemplates({}); + } + }); + } + + QUnit.module('Application Lifecycle - Component Registration', { + setup: prepare, + teardown: cleanup + }); + + function boot(callback) { + var startURL = arguments.length <= 1 || arguments[1] === undefined ? '/' : arguments[1]; + + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + appInstance = App.__deprecatedInstance__; + + if (callback) { + callback(); + } + }); + + var router = appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + _emberMetal.run(function () { + return router.handleURL(startURL); + }); + } + + QUnit.test('The helper becomes the body of the component', function () { + boot(); + equal(_emberViews.jQuery('div.ember-view > div.ember-view', '#qunit-fixture').text(), 'hello world', 'The component is composed correctly'); + }); + + QUnit.test('If a component is registered, it is used', function () { + boot(function () { + appInstance.register('component:expand-it', _emberGlimmer.Component.extend({ + classNames: 'testing123' + })); + }); + + equal(_emberViews.jQuery('div.testing123', '#qunit-fixture').text(), 'hello world', 'The component is composed correctly'); + }); + + QUnit.test('Late-registered components can be rendered with custom `layout` property', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    there goes {{my-hero}}
    ')); + + boot(function () { + appInstance.register('component:my-hero', _emberGlimmer.Component.extend({ + classNames: 'testing123', + layout: _emberTemplateCompiler.compile('watch him as he GOES') + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'there goes watch him as he GOES', 'The component is composed correctly'); + }); + + QUnit.test('Late-registered components can be rendered with template registered on the container', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}
    ')); + + boot(function () { + appInstance.register('template:components/sally-rutherford', _emberTemplateCompiler.compile('funkytowny{{yield}}')); + appInstance.register('component:sally-rutherford', _emberGlimmer.Component); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'hello world funkytowny-funkytowny!!!', 'The component is composed correctly'); + }); + + QUnit.test('Late-registered components can be rendered with ONLY the template registered on the container', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    hello world {{borf-snorlax}}-{{#borf-snorlax}}!!!{{/borf-snorlax}}
    ')); + + boot(function () { + appInstance.register('template:components/borf-snorlax', _emberTemplateCompiler.compile('goodfreakingTIMES{{yield}}')); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'hello world goodfreakingTIMES-goodfreakingTIMES!!!', 'The component is composed correctly'); + }); + + QUnit.test('Assigning layoutName to a component should setup the template as a layout', function () { + expect(1); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('foo-bar-baz', _emberTemplateCompiler.compile('{{text}}-{{yield}}')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + layoutName: 'foo-bar-baz' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Assigning layoutName and layout to a component should use the `layout` value', function () { + expect(1); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('foo-bar-baz', _emberTemplateCompiler.compile('No way!')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + layoutName: 'foo-bar-baz', + layout: _emberTemplateCompiler.compile('{{text}}-{{yield}}') + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Assigning defaultLayout to a component should set it up as a layout if no layout was found [DEPRECATED]', function () { + expect(2); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + + expectDeprecation(function () { + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + defaultLayout: _emberTemplateCompiler.compile('{{text}}-{{yield}}') + })); + }); + }, /Specifying `defaultLayout` to .+ is deprecated\./); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Assigning defaultLayout to a component should set it up as a layout if layout was found [DEPRECATED]', function () { + expect(2); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('{{text}}-{{yield}}')); + + expectDeprecation(function () { + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner', + defaultLayout: _emberTemplateCompiler.compile('should not see this!') + })); + }); + }, /Specifying `defaultLayout` to .+ is deprecated\./); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Using name of component that does not exist', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#no-good}} {{/no-good}}
    ')); + + expectAssertion(function () { + return boot(); + }, /.* named "no-good" .*/); + }); + + QUnit.module('Application Lifecycle - Component Context', { + setup: prepare, + teardown: cleanup + }); + + QUnit.test('Components with a block should have the proper content when a template is provided', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('{{text}}-{{yield}}')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner-outer', 'The component is composed correctly'); + }); + + QUnit.test('Components with a block should yield the proper content without a template provided', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'outer', 'The component is composed correctly'); + }); + + QUnit.test('Components without a block should have the proper content when a template is provided', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('{{text}}')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + text: 'inner' + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'inner', 'The component is composed correctly'); + }); + + QUnit.test('Components without a block should have the proper content', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$().html('Some text inserted by jQuery'); + } + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'Some text inserted by jQuery', 'The component is composed correctly'); + }); + + // The test following this one is the non-deprecated version + QUnit.test('properties of a component without a template should not collide with internal structures [DEPRECATED]', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component data=foo}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer', + 'foo': 'Some text inserted by jQuery' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + didInsertElement: function () { + this.$().html(this.get('data')); + } + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'Some text inserted by jQuery', 'The component is composed correctly'); + }); + + QUnit.test('attrs property of a component without a template should not collide with internal structures', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{my-component attrs=foo}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + 'text': 'outer', + 'foo': 'Some text inserted by jQuery' + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + didInsertElement: function () { + // FIXME: I'm unsure if this is even the right way to access attrs + this.$().html(this.get('attrs.attrs.value')); + } + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'Some text inserted by jQuery', 'The component is composed correctly'); + }); + + QUnit.test('Components trigger actions in the parents context when called from within a block', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}Fizzbuzz{{/my-component}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + actions: { + fizzbuzz: function () { + ok(true, 'action triggered on parent'); + } + } + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend()); + }); + + _emberMetal.run(function () { + _emberViews.jQuery('#fizzbuzz', '#wrapper').click(); + }); + }); + + QUnit.test('Components trigger actions in the components context when called from within its template', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{#my-component}}{{text}}{{/my-component}}
    ')); + _emberGlimmer.setTemplate('components/my-component', _emberTemplateCompiler.compile('Fizzbuzz')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + actions: { + fizzbuzz: function () { + ok(false, 'action triggered on the wrong context'); + } + } + })); + + appInstance.register('component:my-component', _emberGlimmer.Component.extend({ + actions: { + fizzbuzz: function () { + ok(true, 'action triggered on component'); + } + } + })); + }); + + _emberViews.jQuery('#fizzbuzz', '#wrapper').click(); + }); +}); +enifed('ember/tests/component_registration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/component_registration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/component_registration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/controller_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-glimmer', 'ember-views'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberGlimmer, _emberViews) { + 'use strict'; + + /* + In Ember 1.x, controllers subtly affect things like template scope + and action targets in exciting and often inscrutable ways. This test + file contains integration tests that verify the correct behavior of + the many parts of the system that change and rely upon controller scope, + from the runtime up to the templating layer. + */ + + var App = undefined, + $fixture = undefined; + + QUnit.module('Template scoping examples', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + App.LoadingRoute = _emberRouting.Route.extend(); + }); + + $fixture = _emberViews.jQuery('#qunit-fixture'); + }, + + teardown: function () { + _emberMetal.run(function () { + return App.destroy(); + }); + + App = null; + + _emberGlimmer.setTemplates({}); + } + }); + + QUnit.test('Actions inside an outlet go to the associated controller', function () { + expect(1); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{component-with-action action=\'componentAction\'}}')); + + App.IndexController = _emberRuntime.Controller.extend({ + actions: { + componentAction: function () { + ok(true, 'received the click'); + } + } + }); + + App.ComponentWithActionComponent = _emberGlimmer.Component.extend({ + classNames: ['component-with-action'], + click: function () { + this.sendAction(); + } + }); + + bootApp(); + + $fixture.find('.component-with-action').click(); + }); + + function bootApp() { + _emberMetal.run(App, 'advanceReadiness'); + } +}); +enifed('ember/tests/controller_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/controller_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/controller_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/global-api-test', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; + + QUnit.module('Global API Tests'); + + function confirmExport(property, internal) { + QUnit.test('confirm ' + property + ' is exported', function () { + var theExport = _emberMetal.get(window, property); + ok(theExport + ' is exported'); + if (internal !== undefined) { + equal(theExport, internal, theExport + ' is exported properly'); + } + }); + } + + confirmExport('Ember.DefaultResolver'); + confirmExport('Ember.generateController'); + confirmExport('Ember.Helper'); + confirmExport('Ember.Helper.helper'); + confirmExport('Ember.isArray', _emberRuntime.isArray); +}); +enifed('ember/tests/global-api-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/global-api-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/global-api-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/helper_registration_test', ['exports', 'ember-runtime', 'ember-metal', 'ember-template-compiler', 'ember-glimmer', 'ember-application', 'ember-routing', 'ember-views'], function (exports, _emberRuntime, _emberMetal, _emberTemplateCompiler, _emberGlimmer, _emberApplication, _emberRouting, _emberViews) { + 'use strict'; + + var App = undefined, + appInstance = undefined; + + QUnit.module('Application Lifecycle - Helper Registration', { + teardown: function () { + _emberMetal.run(function () { + if (App) { + App.destroy(); + } + + App = appInstance = null; + _emberGlimmer.setTemplates({}); + }); + } + }); + + function boot(callback) { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router = _emberRouting.Router.extend({ + location: 'none' + }); + + // We shouldn't be testing this + appInstance = App.__deprecatedInstance__; + + if (callback) { + callback(); + } + }); + + var router = appInstance.lookup('router:main'); + + _emberMetal.run(App, 'advanceReadiness'); + _emberMetal.run(function () { + return router.handleURL('/'); + }); + } + + QUnit.test('Unbound dashed helpers registered on the container can be late-invoked', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{x-borf}} {{x-borf \'YES\'}}
    ')); + var myHelper = _emberGlimmer.helper(function (params) { + return params[0] || 'BORF'; + }); + + boot(function () { + App.register('helper:x-borf', myHelper); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'BORF YES', 'The helper was invoked from the container'); + }); + + QUnit.test('Bound helpers registered on the container can be late-invoked', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{x-reverse}} {{x-reverse foo}}
    ')); + + boot(function () { + appInstance.register('controller:application', _emberRuntime.Controller.extend({ + foo: 'alex' + })); + + appInstance.register('helper:x-reverse', _emberGlimmer.helper(function (_ref) { + var value = _ref[0]; + + return value ? value.split('').reverse().join('') : '--'; + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), '-- xela', 'The bound helper was invoked from the container'); + }); + + QUnit.test('Undashed helpers registered on the container can be invoked', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{omg}}|{{yorp \'boo\'}}|{{yorp \'ya\'}}
    ')); + + boot(function () { + appInstance.register('helper:omg', _emberGlimmer.helper(function () { + return 'OMG'; + })); + + appInstance.register('helper:yorp', _emberGlimmer.helper(function (_ref2) { + var value = _ref2[0]; + return value; + })); + }); + + equal(_emberViews.jQuery('#wrapper').text(), 'OMG|boo|ya', 'The helper was invoked from the container'); + }); + + QUnit.test('Helpers can receive injections', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{full-name}}
    ')); + + var serviceCalled = false; + boot(function () { + appInstance.register('service:name-builder', _emberRuntime.Service.extend({ + build: function () { + serviceCalled = true; + } + })); + appInstance.register('helper:full-name', _emberGlimmer.Helper.extend({ + nameBuilder: _emberRuntime.inject.service('name-builder'), + compute: function () { + this.get('nameBuilder').build(); + } + })); + }); + + ok(serviceCalled, 'service was injected, method called'); + }); +}); +enifed('ember/tests/helpers/helper_registration_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/helper_registration_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/helper_registration_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/link_to_test', ['exports', 'ember-console', 'ember-runtime', 'ember-metal', 'ember-routing', 'ember-application', 'ember-views', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberConsole, _emberRuntime, _emberMetal, _emberRouting, _emberApplication, _emberViews, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + router = undefined, + appInstance = undefined; + + function bootApplication() { + router = appInstance.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + // IE includes the host name + function normalizeUrl(url) { + return url.replace(/https?:\/\/[^\/]+/, ''); + } + + function shouldNotBeActive(selector) { + checkActive(selector, false); + } + + function shouldBeActive(selector) { + checkActive(selector, true); + } + + function checkActive(selector, active) { + var classList = _emberViews.jQuery(selector, '#qunit-fixture')[0].className; + equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); + } + + var updateCount = undefined, + replaceCount = undefined; + + function sharedSetup() { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + updateCount = replaceCount = 0; + App.Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + updateCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router = App.Router; + appInstance = App.__deprecatedInstance__; + } + + function sharedTeardown() { + _emberMetal.run(function () { + return App.destroy(); + }); + _emberGlimmer.setTemplates({}); + _emberMetal.instrumentationReset(); + } + + QUnit.module('The {{link-to}} helper', { + setup: function () { + _emberMetal.run(function () { + sharedSetup(); + + _emberGlimmer.setTemplate('app', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}{{#link-to \'index\' id=\'self-link\'}}Self{{/link-to}}')); + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile('

    About

    {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}{{#link-to \'about\' id=\'self-link\'}}Self{{/link-to}}')); + _emberGlimmer.setTemplate('item', _emberTemplateCompiler.compile('

    Item

    {{model.name}}

    {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}')); + + appInstance.unregister('router:main'); + appInstance.register('router:main', Router); + }); + }, + + teardown: sharedTeardown + }); + + QUnit.test('The {{link-to}} helper moves into the named route', function () { + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 1, 'The about template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#home-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + if (_emberMetal.isFeatureEnabled('ember-improved-instrumentation')) { + QUnit.test('The {{link-to}} helper fires an interaction event', function (assert) { + assert.expect(2); + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.instrumentationSubscribe('interaction.link-to', { + before: function () { + assert.ok(true, 'instrumentation subscriber was called'); + }, + after: function () { + assert.ok(true, 'instrumentation subscriber was called'); + } + }); + + _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + QUnit.test('The {{link-to}} helper interaction event includes the route name', function (assert) { + assert.expect(2); + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.instrumentationSubscribe('interaction.link-to', { + before: function (name, timestamp, _ref) { + var routeName = _ref.routeName; + + assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); + }, + after: function (name, timestamp, _ref2) { + var routeName = _ref2.routeName; + + assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); + } + }); + + _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + QUnit.test('The {{link-to}} helper interaction event includes the transition in the after hook', function (assert) { + assert.expect(1); + Router.map(function (match) { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.instrumentationSubscribe('interaction.link-to', { + before: function () {}, + after: function (name, timestamp, _ref3) { + var transition = _ref3.transition; + + assert.equal(transition.targetName, 'about', 'instrumentation subscriber was passed route name'); + } + }); + + _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + } + + QUnit.test('The {{link-to}} helper supports URL replacement', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' replace=true}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(updateCount, 0, 'precond: setURL has not been called'); + equal(replaceCount, 0, 'precond: replaceURL has not been called'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(updateCount, 0, 'setURL should not be called'); + equal(replaceCount, 1, 'replaceURL should be called once'); + }); + + QUnit.test('The {{link-to}} helper supports URL replacement via replace=boundTruthyThing', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' replace=boundTruthyThing}}About{{/link-to}}')); + + App.IndexController = _emberRuntime.Controller.extend({ + boundTruthyThing: true + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(updateCount, 0, 'precond: setURL has not been called'); + equal(replaceCount, 0, 'precond: replaceURL has not been called'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(updateCount, 0, 'setURL should not be called'); + equal(replaceCount, 1, 'replaceURL should be called once'); + }); + + QUnit.test('The {{link-to}} helper supports setting replace=boundFalseyThing', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' replace=boundFalseyThing}}About{{/link-to}}')); + + App.IndexController = _emberRuntime.Controller.extend({ + boundFalseyThing: false + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(updateCount, 0, 'precond: setURL has not been called'); + equal(replaceCount, 0, 'precond: replaceURL has not been called'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(updateCount, 1, 'setURL should be called'); + equal(replaceCount, 0, 'replaceURL should not be called'); + }); + + // jscs:disable + + QUnit.test("the {{link-to}} helper doesn't add an href when the tagName isn't 'a'", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'about\' id=\'about-link\' tagName=\'div\'}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link').attr('href'), undefined, 'there is no href attribute'); + }); + + QUnit.test("the {{link-to}} applies a 'disabled' class when disabled", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to "about" id="about-link-static" disabledWhen="shouldDisable"}}About{{/link-to}}\n {{#link-to "about" id="about-link-dynamic" disabledWhen=dynamicDisabledWhen}}About{{/link-to}}\n ')); + + App.IndexController = _emberRuntime.Controller.extend({ + shouldDisable: true, + dynamicDisabledWhen: 'shouldDisable' + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link-static.disabled', '#qunit-fixture').length, 1, 'The static link is disabled when its disabledWhen is true'); + equal(_emberViews.jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 1, 'The dynamic link is disabled when its disabledWhen is true'); + + _emberMetal.run(function () { + return _emberMetal.set(appInstance.lookup('controller:index'), 'dynamicDisabledWhen', false); + }); + + equal(_emberViews.jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 0, 'The dynamic link is re-enabled when its disabledWhen becomes false'); + }); + + QUnit.test("the {{link-to}} doesn't apply a 'disabled' class if disabledWhen is not provided", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link"}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + ok(!_emberViews.jQuery('#about-link', '#qunit-fixture').hasClass('disabled'), 'The link is not disabled if disabledWhen not provided'); + }); + + QUnit.test('the {{link-to}} helper supports a custom disabledClass', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=true disabledClass="do-not-want"}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link.do-not-want', '#qunit-fixture').length, 1, 'The link can apply a custom disabled class'); + }); + + QUnit.test('the {{link-to}} helper supports a custom disabledClass set via bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=true disabledClass=disabledClass}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + disabledClass: 'do-not-want' + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link.do-not-want', '#qunit-fixture').length, 1, 'The link can apply a custom disabled class via bound param'); + }); + + QUnit.test('the {{link-to}} helper does not respond to clicks when disabled', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=true}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur'); + }); + + QUnit.test('the {{link-to}} helper responds to clicks according to its disabledWhen bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "about" id="about-link" disabledWhen=disabledWhen}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + disabledWhen: true + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur'); + + _emberMetal.run(function () { + return _emberMetal.set(appInstance.lookup('controller:index'), 'disabledWhen', false); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(About)', '#qunit-fixture').length, 1, 'Transitioning did occur when disabledWhen became false'); + }); + + QUnit.test('The {{link-to}} helper supports a custom activeClass', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'about' id='about-link'}}About{{/link-to}}{{#link-to 'index' id='self-link' activeClass='zomg-active'}}Self{{/link-to}}")); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberViews.jQuery('#self-link.zomg-active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + QUnit.test('The {{link-to}} helper supports a custom activeClass from a bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}{{#link-to \'index\' id=\'self-link\' activeClass=activeClass}}Self{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + activeClass: 'zomg-active' + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberViews.jQuery('#self-link.zomg-active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + QUnit.test("The {{link-to}} helper supports 'classNameBindings' with custom values [GH #11699]", function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{#link-to \'about\' id=\'about-link\' classNameBindings=\'foo:foo-is-true:foo-is-false\'}}About{{/link-to}}')); + + Router.map(function () { + this.route('about'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + foo: false + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(_emberViews.jQuery('#about-link.foo-is-false', '#qunit-fixture').length, 1, 'The about-link was rendered with the falsy class'); + + var controller = appInstance.lookup('controller:index'); + + _emberMetal.run(function () { + return controller.set('foo', true); + }); + + equal(_emberViews.jQuery('#about-link.foo-is-true', '#qunit-fixture').length, 1, 'The about-link was rendered with the truthy class after toggling the property'); + }); + + QUnit.test('The {{link-to}} helper supports leaving off .index for nested routes', function () { + Router.map(function () { + this.route('about', function () { + this.route('item'); + }); + }); + + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile('

    About

    {{outlet}}')); + _emberGlimmer.setTemplate('about/index', _emberTemplateCompiler.compile("
    Index
    ")); + _emberGlimmer.setTemplate('about/item', _emberTemplateCompiler.compile("
    {{#link-to 'about'}}About{{/link-to}}
    ")); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/about/item'); + + equal(normalizeUrl(_emberViews.jQuery('#item a', '#qunit-fixture').attr('href')), '/about'); + }); + + QUnit.test('The {{link-to}} helper supports currentWhen (DEPRECATED)', function () { + expectDeprecation('Usage of `currentWhen` is deprecated, use `current-when` instead.'); + + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('item'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'item' id='other-link' currentWhen='index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active since current-when is a parent route'); + }); + + QUnit.test('The {{link-to}} helper supports custom, nested, current-when', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('item'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'item' id='other-link' current-when='index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active since current-when is a parent route'); + }); + + QUnit.test('The {{link-to}} helper does not disregard current-when when it is given explicitly for a route', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('items', function () { + this.route('item'); + }); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'items' id='other-link' current-when='index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active when current-when is given for explicitly for a route'); + }); + + QUnit.test('The {{link-to}} helper does not disregard current-when when it is set via a bound param', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + + this.route('items', function () { + this.route('item'); + }); + }); + + App.IndexAboutController = _emberRuntime.Controller.extend({ + currentWhen: 'index' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'items' id='other-link' current-when=currentWhen}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active when current-when is given for explicitly for a route'); + }); + + QUnit.test('The {{link-to}} helper supports multiple current-when routes', function () { + Router.map(function (match) { + this.route('index', { path: '/' }, function () { + this.route('about'); + }); + this.route('item'); + this.route('foo'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Home

    {{outlet}}')); + _emberGlimmer.setTemplate('index/about', _emberTemplateCompiler.compile("{{#link-to 'item' id='link1' current-when='item index'}}ITEM{{/link-to}}")); + _emberGlimmer.setTemplate('item', _emberTemplateCompiler.compile("{{#link-to 'item' id='link2' current-when='item index'}}ITEM{{/link-to}}")); + _emberGlimmer.setTemplate('foo', _emberTemplateCompiler.compile("{{#link-to 'item' id='link3' current-when='item index'}}ITEM{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#link1.active', '#qunit-fixture').length, 1, 'The link is active since current-when contains the parent route'); + + _emberMetal.run(function () { + return router.handleURL('/item'); + }); + + equal(_emberViews.jQuery('#link2.active', '#qunit-fixture').length, 1, 'The link is active since you are on the active route'); + + _emberMetal.run(function () { + return router.handleURL('/foo'); + }); + + equal(_emberViews.jQuery('#link3.active', '#qunit-fixture').length, 0, 'The link is not active since current-when does not contain the active route'); + }); + + QUnit.test('The {{link-to}} helper defaults to bubbling', function () { + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about.contact' id='about-contact'}}About{{/link-to}}
    {{outlet}}")); + _emberGlimmer.setTemplate('about/contact', _emberTemplateCompiler.compile("

    Contact

    ")); + + Router.map(function () { + this.route('about', function () { + this.route('contact'); + }); + }); + + var hidden = 0; + + App.AboutRoute = _emberRouting.Route.extend({ + actions: { + hide: function () { + hidden++; + } + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-contact', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); + + equal(hidden, 1, 'The link bubbles'); + }); + + QUnit.test('The {{link-to}} helper supports bubbles=false', function () { + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about.contact' id='about-contact' bubbles=false}}About{{/link-to}}
    {{outlet}}")); + _emberGlimmer.setTemplate('about/contact', _emberTemplateCompiler.compile("

    Contact

    ")); + + Router.map(function () { + this.route('about', function () { + this.route('contact'); + }); + }); + + var hidden = 0; + + App.AboutRoute = _emberRouting.Route.extend({ + actions: { + hide: function () { + hidden++; + } + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + _emberMetal.run(function () { + return _emberViews.jQuery('#about-contact', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); + + equal(hidden, 0, "The link didn't bubble"); + }); + + QUnit.test('The {{link-to}} helper supports bubbles=boundFalseyThing', function () { + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about.contact' id='about-contact' bubbles=boundFalseyThing}}About{{/link-to}}
    {{outlet}}")); + _emberGlimmer.setTemplate('about/contact', _emberTemplateCompiler.compile("

    Contact

    ")); + + App.AboutController = _emberRuntime.Controller.extend({ + boundFalseyThing: false + }); + + Router.map(function () { + this.route('about', function () { + this.route('contact'); + }); + }); + + var hidden = 0; + + App.AboutRoute = _emberRouting.Route.extend({ + actions: { + hide: function () { + hidden++; + } + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-contact', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); + + equal(hidden, 0, "The link didn't bubble"); + }); + + QUnit.test('The {{link-to}} helper moves into the named route with context', function () { + Router.map(function (match) { + this.route('about'); + this.route('item', { path: '/item/:id' }); + }); + + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("

    List

      {{#each model as |person|}}
    • {{#link-to 'item' person}}{{person.name}}{{/link-to}}
    • {{/each}}
    {{#link-to 'index' id='home-link'}}Home{{/link-to}}")); + + App.AboutRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A([{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }]); + } + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('h3:contains(List)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(normalizeUrl(_emberViews.jQuery('#home-link').attr('href')), '/', 'The home link points back at /'); + + _emberMetal.run(function () { + return _emberViews.jQuery('li a:contains(Yehuda)', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'Yehuda Katz', 'The name is correct'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link').click(); + }); + + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Yehuda)').attr('href')), '/item/yehuda'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Tom)').attr('href')), '/item/tom'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Erik)').attr('href')), '/item/erik'); + + _emberMetal.run(function () { + return _emberViews.jQuery('li a:contains(Erik)', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'Erik Brynroflsson', 'The name is correct'); + }); + + QUnit.test('The {{link-to}} helper binds some anchor html tag common attributes', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' title='title-attr' rel='rel-attr' tabindex='-1'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#self-link', '#qunit-fixture'); + equal(link.attr('title'), 'title-attr', 'The self-link contains title attribute'); + equal(link.attr('rel'), 'rel-attr', 'The self-link contains rel attribute'); + equal(link.attr('tabindex'), '-1', 'The self-link contains tabindex attribute'); + }); + + QUnit.test('The {{link-to}} helper supports `target` attribute', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#self-link', '#qunit-fixture'); + equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); + }); + + QUnit.test('The {{link-to}} helper supports `target` attribute specified as a bound param', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target=boundLinkTarget}}Self{{/link-to}}")); + + App.IndexController = _emberRuntime.Controller.extend({ + boundLinkTarget: '_blank' + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#self-link', '#qunit-fixture'); + equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); + }); + + QUnit.test('The {{link-to}} helper does not call preventDefault if `target` attribute is provided', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#self-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), false, 'should not preventDefault when target attribute is specified'); + }); + + QUnit.test('The {{link-to}} helper should preventDefault when `target = _self`', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{#link-to 'index' id='self-link' target='_self'}}Self{{/link-to}}")); + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#self-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), true, 'should preventDefault when target attribute is `_self`'); + }); + + QUnit.test('The {{link-to}} helper should not transition if target is not equal to _self or empty', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'about' id='about-link' replace=true target='_blank'}}About{{/link-to}}")); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#about-link', '#qunit-fixture').click(); + }); + + notEqual(appInstance.lookup('controller:application').get('currentRouteName'), 'about', 'link-to should not transition if target is not equal to _self or empty'); + }); + + QUnit.test('The {{link-to}} helper accepts string/numeric arguments', function () { + Router.map(function () { + this.route('filter', { path: '/filters/:filter' }); + this.route('post', { path: '/post/:post_id' }); + this.route('repo', { path: '/repo/:owner/:name' }); + }); + + App.FilterController = _emberRuntime.Controller.extend({ + filter: 'unpopular', + repo: _emberRuntime.Object.create({ owner: 'ember', name: 'ember.js' }), + post_id: 123 + }); + _emberGlimmer.setTemplate('filter', _emberTemplateCompiler.compile('

    {{filter}}

    {{#link-to "filter" "unpopular" id="link"}}Unpopular{{/link-to}}{{#link-to "filter" filter id="path-link"}}Unpopular{{/link-to}}{{#link-to "post" post_id id="post-path-link"}}Post{{/link-to}}{{#link-to "post" 123 id="post-number-link"}}Post{{/link-to}}{{#link-to "repo" repo id="repo-object-link"}}Repo{{/link-to}}')); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile(' ')); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/filters/popular'); + }); + + equal(normalizeUrl(_emberViews.jQuery('#link', '#qunit-fixture').attr('href')), '/filters/unpopular'); + equal(normalizeUrl(_emberViews.jQuery('#path-link', '#qunit-fixture').attr('href')), '/filters/unpopular'); + equal(normalizeUrl(_emberViews.jQuery('#post-path-link', '#qunit-fixture').attr('href')), '/post/123'); + equal(normalizeUrl(_emberViews.jQuery('#post-number-link', '#qunit-fixture').attr('href')), '/post/123'); + equal(normalizeUrl(_emberViews.jQuery('#repo-object-link', '#qunit-fixture').attr('href')), '/repo/ember/ember.js'); + }); + + QUnit.test("Issue 4201 - Shorthand for route.index shouldn't throw errors about context arguments", function () { + expect(2); + Router.map(function () { + this.route('lobby', function () { + this.route('index', { path: ':lobby_id' }); + this.route('list'); + }); + }); + + App.LobbyIndexRoute = _emberRouting.Route.extend({ + model: function (params) { + equal(params.lobby_id, 'foobar'); + return params.lobby_id; + } + }); + + _emberGlimmer.setTemplate('lobby/index', _emberTemplateCompiler.compile("{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}")); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('lobby/list', _emberTemplateCompiler.compile("{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}")); + bootApplication(); + _emberMetal.run(router, 'handleURL', '/lobby/list'); + _emberMetal.run(_emberViews.jQuery('#lobby-link'), 'click'); + shouldBeActive('#lobby-link'); + }); + + QUnit.test('Quoteless route param performs property lookup', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'index' id='string-link'}}string{{/link-to}}{{#link-to foo id='path-link'}}path{{/link-to}}")); + + function assertEquality(href) { + equal(normalizeUrl(_emberViews.jQuery('#string-link', '#qunit-fixture').attr('href')), '/'); + equal(normalizeUrl(_emberViews.jQuery('#path-link', '#qunit-fixture').attr('href')), href); + } + + App.IndexController = _emberRuntime.Controller.extend({ + foo: 'index' + }); + + App.Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + assertEquality('/'); + + var controller = appInstance.lookup('controller:index'); + _emberMetal.run(function () { + return controller.set('foo', 'about'); + }); + + assertEquality('/about'); + }); + + QUnit.test('link-to with null/undefined dynamic parameters are put in a loading state', function () { + expect(19); + + var oldWarn = _emberConsole.default.warn; + var warnCalled = false; + _emberConsole.default.warn = function () { + warnCalled = true; + }; + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to destinationRoute routeContext loadingClass='i-am-loading' id='context-link'}}string{{/link-to}}{{#link-to secondRoute loadingClass=loadingClass id='static-link'}}string{{/link-to}}")); + + var thing = _emberRuntime.Object.create({ id: 123 }); + + App.IndexController = _emberRuntime.Controller.extend({ + destinationRoute: null, + routeContext: null, + loadingClass: 'i-am-loading' + }); + + App.AboutRoute = _emberRouting.Route.extend({ + activate: function () { + ok(true, 'About was entered'); + } + }); + + App.Router.map(function () { + this.route('thing', { path: '/thing/:thing_id' }); + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + function assertLinkStatus($link, url) { + if (url) { + equal(normalizeUrl($link.attr('href')), url, 'loaded link-to has expected href'); + ok(!$link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass'); + } else { + equal(normalizeUrl($link.attr('href')), '#', "unloaded link-to has href='#'"); + ok($link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass'); + } + } + + var $contextLink = _emberViews.jQuery('#context-link', '#qunit-fixture'); + var $staticLink = _emberViews.jQuery('#static-link', '#qunit-fixture'); + var controller = appInstance.lookup('controller:index'); + + assertLinkStatus($contextLink); + assertLinkStatus($staticLink); + + _emberMetal.run(function () { + warnCalled = false; + $contextLink.click(); + ok(warnCalled, 'Logger.warn was called from clicking loading link'); + }); + + // Set the destinationRoute (context is still null). + _emberMetal.run(controller, 'set', 'destinationRoute', 'thing'); + assertLinkStatus($contextLink); + + // Set the routeContext to an id + _emberMetal.run(controller, 'set', 'routeContext', '456'); + assertLinkStatus($contextLink, '/thing/456'); + + // Test that 0 isn't interpreted as falsy. + _emberMetal.run(controller, 'set', 'routeContext', 0); + assertLinkStatus($contextLink, '/thing/0'); + + // Set the routeContext to an object + _emberMetal.run(controller, 'set', 'routeContext', thing); + assertLinkStatus($contextLink, '/thing/123'); + + // Set the destinationRoute back to null. + _emberMetal.run(controller, 'set', 'destinationRoute', null); + assertLinkStatus($contextLink); + + _emberMetal.run(function () { + warnCalled = false; + $staticLink.click(); + ok(warnCalled, 'Logger.warn was called from clicking loading link'); + }); + + _emberMetal.run(controller, 'set', 'secondRoute', 'about'); + assertLinkStatus($staticLink, '/about'); + + // Click the now-active link + _emberMetal.run($staticLink, 'click'); + + _emberConsole.default.warn = oldWarn; + }); + + QUnit.test('The {{link-to}} helper refreshes href element when one of params changes', function () { + Router.map(function () { + this.route('post', { path: '/posts/:post_id' }); + }); + + var post = _emberRuntime.Object.create({ id: '1' }); + var secondPost = _emberRuntime.Object.create({ id: '2' }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to "post" post id="post"}}post{{/link-to}}')); + + App.IndexController = _emberRuntime.Controller.extend(); + var indexController = appInstance.lookup('controller:index'); + + _emberMetal.run(function () { + return indexController.set('post', post); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + equal(normalizeUrl(_emberViews.jQuery('#post', '#qunit-fixture').attr('href')), '/posts/1', 'precond - Link has rendered href attr properly'); + + _emberMetal.run(function () { + return indexController.set('post', secondPost); + }); + + equal(_emberViews.jQuery('#post', '#qunit-fixture').attr('href'), '/posts/2', 'href attr was updated after one of the params had been changed'); + + _emberMetal.run(function () { + return indexController.set('post', null); + }); + + equal(_emberViews.jQuery('#post', '#qunit-fixture').attr('href'), '#', 'href attr becomes # when one of the arguments in nullified'); + }); + + QUnit.test('The {{link-to}} helper is active when a route is active', function () { + Router.map(function () { + this.route('about', function () { + this.route('item'); + }); + }); + + _emberGlimmer.setTemplate('about', _emberTemplateCompiler.compile("
    {{#link-to 'about' id='about-link'}}About{{/link-to}} {{#link-to 'about.item' id='item-link'}}Item{{/link-to}} {{outlet}}
    ")); + _emberGlimmer.setTemplate('about/item', _emberTemplateCompiler.compile(' ')); + _emberGlimmer.setTemplate('about/index', _emberTemplateCompiler.compile(' ')); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/about'); + + equal(_emberViews.jQuery('#about-link.active', '#qunit-fixture').length, 1, 'The about route link is active'); + equal(_emberViews.jQuery('#item-link.active', '#qunit-fixture').length, 0, 'The item route link is inactive'); + + _emberMetal.run(router, 'handleURL', '/about/item'); + + equal(_emberViews.jQuery('#about-link.active', '#qunit-fixture').length, 1, 'The about route link is active'); + equal(_emberViews.jQuery('#item-link.active', '#qunit-fixture').length, 1, 'The item route link is active'); + }); + + QUnit.test("The {{link-to}} helper works in an #each'd array of string route names", function () { + Router.map(function () { + this.route('foo'); + this.route('bar'); + this.route('rar'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + routeNames: _emberRuntime.A(['foo', 'bar', 'rar']), + route1: 'bar', + route2: 'foo' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#each routeNames as |routeName|}}{{#link-to routeName}}{{routeName}}{{/link-to}}{{/each}}{{#each routeNames as |r|}}{{#link-to r}}{{r}}{{/link-to}}{{/each}}{{#link-to route1}}a{{/link-to}}{{#link-to route2}}b{{/link-to}}')); + + bootApplication(); + + function linksEqual($links, expected) { + equal($links.length, expected.length, 'Has correct number of links'); + + var idx = undefined; + for (idx = 0; idx < $links.length; idx++) { + var href = _emberViews.jQuery($links[idx]).attr('href'); + // Old IE includes the whole hostname as well + equal(href.slice(-expected[idx].length), expected[idx], 'Expected link to be \'' + expected[idx] + '\', but was \'' + href + '\''); + } + } + + linksEqual(_emberViews.jQuery('a', '#qunit-fixture'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/bar', '/foo']); + + var indexController = appInstance.lookup('controller:index'); + _emberMetal.run(indexController, 'set', 'route1', 'rar'); + + linksEqual(_emberViews.jQuery('a', '#qunit-fixture'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); + + _emberMetal.run(indexController.routeNames, 'shiftObject'); + + linksEqual(_emberViews.jQuery('a', '#qunit-fixture'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']); + }); + + QUnit.test('The non-block form {{link-to}} helper moves into the named route', function () { + expect(3); + Router.map(function (match) { + this.route('contact'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{link-to 'Contact us' 'contact' id='contact-link'}}{{#link-to 'index' id='self-link'}}Self{{/link-to}}")); + _emberGlimmer.setTemplate('contact', _emberTemplateCompiler.compile("

    Contact

    {{link-to 'Home' 'index' id='home-link'}}{{link-to 'Self' 'contact' id='self-link'}}")); + + bootApplication(); + + _emberMetal.run(function () { + return _emberViews.jQuery('#contact-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Contact)', '#qunit-fixture').length, 1, 'The contact template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#home-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + }); + + QUnit.test('The non-block form {{link-to}} helper updates the link text when it is a binding', function () { + expect(8); + Router.map(function (match) { + this.route('contact'); + }); + + App.IndexController = _emberRuntime.Controller.extend({ + contactName: 'Jane' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

    {{link-to contactName 'contact' id='contact-link'}}{{#link-to 'index' id='self-link'}}Self{{/link-to}}")); + _emberGlimmer.setTemplate('contact', _emberTemplateCompiler.compile("

    Contact

    {{link-to 'Home' 'index' id='home-link'}}{{link-to 'Self' 'contact' id='self-link'}}")); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var controller = appInstance.lookup('controller:index'); + + equal(_emberViews.jQuery('#contact-link:contains(Jane)', '#qunit-fixture').length, 1, 'The link title is correctly resolved'); + + _emberMetal.run(function () { + return controller.set('contactName', 'Joe'); + }); + + equal(_emberViews.jQuery('#contact-link:contains(Joe)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the bound property changes'); + + _emberMetal.run(function () { + return controller.set('contactName', 'Robert'); + }); + + equal(_emberViews.jQuery('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the bound property changes a second time'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#contact-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Contact)', '#qunit-fixture').length, 1, 'The contact template was rendered'); + equal(_emberViews.jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); + equal(_emberViews.jQuery('#home-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The index template was rendered'); + equal(_emberViews.jQuery('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the route changes'); + }); + + QUnit.test('The non-block form {{link-to}} helper moves into the named route with context', function () { + expect(5); + + Router.map(function (match) { + this.route('item', { path: '/item/:id' }); + }); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A([{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }]); + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("

    Home

      {{#each model as |person|}}
    • {{link-to person.name 'item' person}}
    • {{/each}}
    ")); + _emberGlimmer.setTemplate('item', _emberTemplateCompiler.compile("

    Item

    {{model.name}}

    {{#link-to 'index' id='home-link'}}Home{{/link-to}}")); + + bootApplication(); + + _emberMetal.run(function () { + return _emberViews.jQuery('li a:contains(Yehuda)', '#qunit-fixture').click(); + }); + + equal(_emberViews.jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'Yehuda Katz', 'The name is correct'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link').click(); + }); + + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Yehuda)').attr('href')), '/item/yehuda'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Tom)').attr('href')), '/item/tom'); + equal(normalizeUrl(_emberViews.jQuery('li a:contains(Erik)').attr('href')), '/item/erik'); + }); + + QUnit.test('The non-block form {{link-to}} performs property lookup', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{link-to 'string' 'index' id='string-link'}}{{link-to path foo id='path-link'}}")); + + function assertEquality(href) { + equal(normalizeUrl(_emberViews.jQuery('#string-link', '#qunit-fixture').attr('href')), '/'); + equal(normalizeUrl(_emberViews.jQuery('#path-link', '#qunit-fixture').attr('href')), href); + } + + App.IndexController = _emberRuntime.Controller.extend({ + foo: 'index' + }); + + App.Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + assertEquality('/'); + + var controller = appInstance.lookup('controller:index'); + _emberMetal.run(function () { + return controller.set('foo', 'about'); + }); + + assertEquality('/about'); + }); + + QUnit.test('The non-block form {{link-to}} protects against XSS', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{link-to display 'index' id='link'}}")); + + App.ApplicationController = _emberRuntime.Controller.extend({ + display: 'blahzorz' + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var controller = appInstance.lookup('controller:application'); + + equal(_emberViews.jQuery('#link', '#qunit-fixture').text(), 'blahzorz'); + _emberMetal.run(function () { + return controller.set('display', 'BLAMMO'); + }); + + equal(_emberViews.jQuery('#link', '#qunit-fixture').text(), 'BLAMMO'); + equal(_emberViews.jQuery('b', '#qunit-fixture').length, 0); + }); + + QUnit.test('the {{link-to}} helper calls preventDefault', function () { + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#about-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), true, 'should preventDefault'); + }); + + QUnit.test('the {{link-to}} helper does not call preventDefault if `preventDefault=false` is passed as an option', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'about' id='about-link' preventDefault=false}}About{{/link-to}}")); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#about-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + }); + + QUnit.test('the {{link-to}} helper does not call preventDefault if `preventDefault=boundFalseyThing` is passed as an option', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'about' id='about-link' preventDefault=boundFalseyThing}}About{{/link-to}}")); + + App.IndexController = _emberRuntime.Controller.extend({ + boundFalseyThing: false + }); + + Router.map(function () { + this.route('about'); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + var event = _emberViews.jQuery.Event('click'); + _emberViews.jQuery('#about-link', '#qunit-fixture').trigger(event); + + equal(event.isDefaultPrevented(), false, 'should not preventDefault'); + }); + + QUnit.test('the {{link-to}} helper throws a useful error if you invoke it wrong', function () { + expect(1); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{#link-to 'post'}}Post{{/link-to}}")); + + Router.map(function () { + this.route('post', { path: 'post/:post_id' }); + }); + + QUnit.throws(function () { + bootApplication(); + }, /(You attempted to define a `\{\{link-to "post"\}\}` but did not pass the parameters required for generating its dynamic segments.|You must provide param `post_id` to `generate`)/); + }); + + QUnit.test('the {{link-to}} helper does not throw an error if its route has exited', function () { + expect(0); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{#link-to 'index' id='home-link'}}Home{{/link-to}}{{#link-to 'post' defaultPost id='default-post-link'}}Default Post{{/link-to}}{{#if currentPost}}{{#link-to 'post' currentPost id='current-post-link'}}Current Post{{/link-to}}{{/if}}")); + + App.ApplicationController = _emberRuntime.Controller.extend({ + defaultPost: { id: 1 }, + postController: _emberRuntime.inject.controller('post'), + currentPost: _emberMetal.alias('postController.model') + }); + + App.PostController = _emberRuntime.Controller.extend(); + + App.PostRoute = _emberRouting.Route.extend({ + model: function () { + return { id: 2 }; + }, + serialize: function (model) { + return { post_id: model.id }; + } + }); + + Router.map(function () { + this.route('post', { path: 'post/:post_id' }); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/'); + + _emberMetal.run(function () { + return _emberViews.jQuery('#default-post-link', '#qunit-fixture').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link', '#qunit-fixture').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#current-post-link', '#qunit-fixture').click(); + }); + _emberMetal.run(function () { + return _emberViews.jQuery('#home-link', '#qunit-fixture').click(); + }); + }); + + QUnit.test('{{link-to}} active property respects changing parent route context', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile("{{link-to 'OMG' 'things' 'omg' id='omg-link'}} " + "{{link-to 'LOL' 'things' 'lol' id='lol-link'}} ")); + + Router.map(function () { + this.route('things', { path: '/things/:name' }, function () { + this.route('other'); + }); + }); + + bootApplication(); + + _emberMetal.run(router, 'handleURL', '/things/omg'); + shouldBeActive('#omg-link'); + shouldNotBeActive('#lol-link'); + + _emberMetal.run(router, 'handleURL', '/things/omg/other'); + shouldBeActive('#omg-link'); + shouldNotBeActive('#lol-link'); + }); + + QUnit.test('{{link-to}} populates href with default query param values even without query-params object', function () { + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '123' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'index' id='the-link'}}Index{{/link-to}}")); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/', 'link has right href'); + }); + + QUnit.test('{{link-to}} populates href with default query param values with empty query-params object', function () { + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '123' + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile("{{#link-to 'index' (query-params) id='the-link'}}Index{{/link-to}}")); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/', 'link has right href'); + }); + + QUnit.test('{{link-to}} with only query-params and a block updates when route changes', function () { + Router.map(function () { + this.route('about'); + }); + + App.ApplicationController = _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar'], + foo: '123', + bar: 'yes' + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{#link-to (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); + }); + + QUnit.test('Block-less {{link-to}} with only query-params updates when route changes', function () { + Router.map(function () { + this.route('about'); + }); + + App.ApplicationController = _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar'], + foo: '123', + bar: 'yes' + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{link-to "Index" (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}')); + bootApplication(); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); + + _emberMetal.run(function () { + return router.handleURL('/about'); + }); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); + }); + + QUnit.test('The {{link-to}} helper can use dynamic params', function () { + Router.map(function (match) { + this.route('foo', { path: 'foo/:some/:thing' }); + this.route('bar', { path: 'bar/:some/:thing/:else' }); + }); + + var controller = undefined; + App.IndexController = _emberRuntime.Controller.extend({ + init: function () { + this._super.apply(this, arguments); + + controller = this; + + this.dynamicLinkParams = ['foo', 'one', 'two']; + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n

    Home

    \n\n {{#link-to params=dynamicLinkParams id="dynamic-link"}}Dynamic{{/link-to}}\n ')); + + bootApplication(); + + _emberMetal.run(function () { + return router.handleURL('/'); + }); + + var link = _emberViews.jQuery('#dynamic-link', '#qunit-fixture'); + + equal(link.attr('href'), '/foo/one/two'); + + _emberMetal.run(function () { + controller.set('dynamicLinkParams', ['bar', 'one', 'two', 'three']); + }); + + equal(link.attr('href'), '/bar/one/two/three'); + }); + + QUnit.test('GJ: {{link-to}} to a parent root model hook which performs a `transitionTo` has correct active class #13256', function () { + expect(1); + + Router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + App.ParentRoute = _emberRouting.Route.extend({ + afterModel: function (transition) { + this.transitionTo('parent.child'); + } + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{link-to \'Parent\' \'parent\' id=\'parent-link\'}}\n ')); + + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#parent-link'), 'click'); + + shouldBeActive('#parent-link'); + }); +}); +enifed('ember/tests/helpers/link_to_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/link_to_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/link_to_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_transitioning_classes_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-glimmer'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberViews, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + registry = undefined, + container = undefined; + + var aboutDefer = undefined, + otherDefer = undefined; + + function bootApplication() { + container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function assertHasClass(className) { + var i = 1; + while (i < arguments.length) { + var $a = arguments[i]; + var shouldHaveClass = arguments[i + 1]; + equal($a.hasClass(className), shouldHaveClass, $a.attr('id') + ' should ' + (shouldHaveClass ? '' : 'not ') + 'have class ' + className); + i += 2; + } + } + + var updateCount = undefined, + replaceCount = undefined; + + function sharedSetup() { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + updateCount = replaceCount = 0; + App.Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + updateCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router = App.Router; + registry = App.__registry__; + container = App.__container__; + } + + function sharedTeardown() { + _emberMetal.run(function () { + return App.destroy(); + }); + _emberGlimmer.setTemplates({}); + } + + QUnit.module('The {{link-to}} helper: .transitioning-in .transitioning-out CSS classes', { + setup: function () { + _emberMetal.run(function () { + sharedSetup(); + + registry.unregister('router:main'); + registry.register('router:main', Router); + + Router.map(function () { + this.route('about'); + this.route('other'); + }); + + App.AboutRoute = _emberRouting.Route.extend({ + model: function () { + aboutDefer = _emberRuntime.RSVP.defer(); + return aboutDefer.promise; + } + }); + + App.OtherRoute = _emberRouting.Route.extend({ + model: function () { + otherDefer = _emberRuntime.RSVP.defer(); + return otherDefer.promise; + } + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{link-to \'Index\' \'index\' id=\'index-link\'}}{{link-to \'About\' \'about\' id=\'about-link\'}}{{link-to \'Other\' \'other\' id=\'other-link\'}}')); + }); + }, + + teardown: function () { + sharedTeardown(); + aboutDefer = null; + } + }); + + QUnit.test('while a transition is underway', function () { + expect(18); + bootApplication(); + + var $index = _emberViews.jQuery('#index-link'); + var $about = _emberViews.jQuery('#about-link'); + var $other = _emberViews.jQuery('#other-link'); + + _emberMetal.run($about, 'click'); + + assertHasClass('active', $index, true, $about, false, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-out', $index, true, $about, false, $other, false); + + _emberMetal.run(aboutDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + }); + + QUnit.test('while a transition is underway with nested link-to\'s', function () { + expect(54); + + Router.map(function () { + this.route('parent-route', function () { + this.route('about'); + this.route('other'); + }); + }); + + App.ParentRouteAboutRoute = _emberRouting.Route.extend({ + model: function () { + aboutDefer = _emberRuntime.RSVP.defer(); + return aboutDefer.promise; + } + }); + + App.ParentRouteOtherRoute = _emberRouting.Route.extend({ + model: function () { + otherDefer = _emberRuntime.RSVP.defer(); + return otherDefer.promise; + } + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{outlet}}\n {{#link-to \'index\' tagName=\'li\'}}\n {{link-to \'Index\' \'index\' id=\'index-link\'}}\n {{/link-to}}\n {{#link-to \'parent-route.about\' tagName=\'li\'}}\n {{link-to \'About\' \'parent-route.about\' id=\'about-link\'}}\n {{/link-to}}\n {{#link-to \'parent-route.other\' tagName=\'li\'}}\n {{link-to \'Other\' \'parent-route.other\' id=\'other-link\'}}\n {{/link-to}}\n ')); + + bootApplication(); + + var $index = _emberViews.jQuery('#index-link'); + var $about = _emberViews.jQuery('#about-link'); + var $other = _emberViews.jQuery('#other-link'); + + _emberMetal.run($about, 'click'); + + assertHasClass('active', $index, true, $about, false, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-out', $index, true, $about, false, $other, false); + + _emberMetal.run(aboutDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + + _emberMetal.run($other, 'click'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, true); + assertHasClass('ember-transitioning-out', $index, false, $about, true, $other, false); + + _emberMetal.run(otherDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, false, $other, true); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + + _emberMetal.run($about, 'click'); + + assertHasClass('active', $index, false, $about, false, $other, true); + assertHasClass('ember-transitioning-in', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, true); + + _emberMetal.run(aboutDefer, 'resolve'); + + assertHasClass('active', $index, false, $about, true, $other, false); + assertHasClass('ember-transitioning-in', $index, false, $about, false, $other, false); + assertHasClass('ember-transitioning-out', $index, false, $about, false, $other, false); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_with_query_params_test', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-glimmer'], function (exports, _emberMetal, _emberRuntime, _emberRouting, _emberTemplateCompiler, _emberApplication, _emberViews, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + router = undefined, + registry = undefined, + container = undefined; + + function bootApplication() { + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function shouldNotBeActive(selector) { + checkActive(selector, false); + } + + function shouldBeActive(selector) { + checkActive(selector, true); + } + + function checkActive(selector, active) { + var classList = _emberViews.jQuery(selector, '#qunit-fixture')[0].className; + equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); + } + + var updateCount = undefined, + replaceCount = undefined; + + function sharedSetup() { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + updateCount = replaceCount = 0; + App.Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + updateCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router = App.Router; + registry = App.__registry__; + container = App.__container__; + } + + function sharedTeardown() { + _emberMetal.run(function () { + return App.destroy(); + }); + _emberGlimmer.setTemplates({}); + } + + QUnit.module('The {{link-to}} helper: invoking with query params', { + setup: function () { + _emberMetal.run(function () { + sharedSetup(); + + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar', 'abool'], + foo: '123', + bar: 'abc', + boundThing: 'OMG', + abool: true + }); + + App.AboutController = _emberRuntime.Controller.extend({ + queryParams: ['baz', 'bat'], + baz: 'alex', + bat: 'borf' + }); + + registry.unregister('router:main'); + registry.register('router:main', Router); + }); + }, + + teardown: sharedTeardown + }); + + QUnit.test('doesn\'t update controller QP properties on current route when invoked', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'index\' id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); + }); + + QUnit.test('doesn\'t update controller QP properties on current route when invoked (empty query-params obj)', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'index\' (query-params) id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); + }); + + QUnit.test('link-to with no params throws', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to id=\'the-link\'}}Index{{/link-to}}')); + expectAssertion(function () { + return bootApplication(); + }, /one or more/); + }); + + QUnit.test('doesn\'t update controller QP properties on current route when invoked (empty query-params obj, inferred route)', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params) id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); + }); + + QUnit.test('updates controller QP properties on current route when invoked', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'index\' (query-params foo=\'456\') id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); + }); + + QUnit.test('updates controller QP properties on current route when invoked (inferred route)', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params foo=\'456\') id=\'the-link\'}}Index{{/link-to}}')); + bootApplication(); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var indexController = container.lookup('controller:index'); + deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); + }); + + QUnit.test('updates controller QP properties on other route after transitioning to that route', function () { + Router.map(function () { + this.route('about'); + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to \'about\' (query-params baz=\'lol\') id=\'the-link\'}}About{{/link-to}}')); + bootApplication(); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/about?baz=lol'); + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + var aboutController = container.lookup('controller:about'); + deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, 'about controller QP properties updated'); + + equal(container.lookup('controller:application').get('currentPath'), 'about'); + }); + + QUnit.test('supplied QP properties can be bound', function () { + var indexController = container.lookup('controller:index'); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params foo=boundThing) id=\'the-link\'}}Index{{/link-to}}')); + + bootApplication(); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/?foo=OMG'); + _emberMetal.run(indexController, 'set', 'boundThing', 'ASL'); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?foo=ASL'); + }); + + QUnit.test('supplied QP properties can be bound (booleans)', function () { + var indexController = container.lookup('controller:index'); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params abool=boundThing) id=\'the-link\'}}Index{{/link-to}}')); + + bootApplication(); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/?abool=OMG'); + _emberMetal.run(indexController, 'set', 'boundThing', false); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?abool=false'); + + _emberMetal.run(_emberViews.jQuery('#the-link'), 'click'); + + deepEqual(indexController.getProperties('foo', 'bar', 'abool'), { foo: '123', bar: 'abc', abool: false }); + }); + + QUnit.test('href updates when unsupplied controller QP props change', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#link-to (query-params foo=\'lol\') id=\'the-link\'}}Index{{/link-to}}')); + + bootApplication(); + var indexController = container.lookup('controller:index'); + + equal(_emberViews.jQuery('#the-link').attr('href'), '/?foo=lol'); + _emberMetal.run(indexController, 'set', 'bar', 'BORF'); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=BORF&foo=lol'); + _emberMetal.run(indexController, 'set', 'foo', 'YEAH'); + equal(_emberViews.jQuery('#the-link').attr('href'), '/?bar=BORF&foo=lol'); + }); + + QUnit.test('The {{link-to}} with only query params always transitions to the current route with the query params applied', function () { + // Test harness for bug #12033 + + _emberGlimmer.setTemplate('cars', _emberTemplateCompiler.compile('\n {{#link-to \'cars.create\' id=\'create-link\'}}Create new car{{/link-to}}\n {{#link-to (query-params page=\'2\') id=\'page2-link\'}}Page 2{{/link-to}}\n {{outlet}}\n ')); + + _emberGlimmer.setTemplate('cars/create', _emberTemplateCompiler.compile('{{#link-to \'cars\' id=\'close-link\'}}Close create form{{/link-to}}')); + + Router.map(function () { + this.route('cars', function () { + this.route('create'); + }); + }); + + App.CarsController = _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1 + }); + + bootApplication(); + + var carsController = container.lookup('controller:cars'); + + _emberMetal.run(function () { + return router.handleURL('/cars/create'); + }); + + _emberMetal.run(function () { + equal(router.currentRouteName, 'cars.create'); + _emberViews.jQuery('#close-link').click(); + }); + + _emberMetal.run(function () { + equal(router.currentRouteName, 'cars.index'); + equal(router.get('url'), '/cars'); + equal(carsController.get('page'), 1, 'The page query-param is 1'); + _emberViews.jQuery('#page2-link').click(); + }); + + _emberMetal.run(function () { + equal(router.currentRouteName, 'cars.index', 'The active route is still cars'); + equal(router.get('url'), '/cars?page=2', 'The url has been updated'); + equal(carsController.get('page'), 2, 'The query params have been updated'); + }); + }); + + QUnit.test('The {{link-to}} applies activeClass when query params are not changed', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to (query-params foo=\'cat\') id=\'cat-link\'}}Index{{/link-to}}\n {{#link-to (query-params foo=\'dog\') id=\'dog-link\'}}Index{{/link-to}}\n {{#link-to \'index\' id=\'change-nothing\'}}Index{{/link-to}}\n ')); + + _emberGlimmer.setTemplate('search', _emberTemplateCompiler.compile('\n {{#link-to (query-params search=\'same\') id=\'same-search\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\') id=\'change-search\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' archive=true) id=\'same-search-add-archive\'}}Index{{/link-to}}\n {{#link-to (query-params archive=true) id=\'only-add-archive\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' archive=true) id=\'both-same\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'different\' archive=true) id=\'change-one\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'different\' archive=false) id=\'remove-one\'}}Index{{/link-to}}\n {{outlet}}\n ')); + + _emberGlimmer.setTemplate('search/results', _emberTemplateCompiler.compile('\n {{#link-to (query-params sort=\'title\') id=\'same-sort-child-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\') id=\'same-search-parent-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\') id=\'change-search-parent-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' sort=\'title\') id=\'same-search-same-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' sort=\'author\') id=\'same-search-different-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\' sort=\'title\') id=\'change-search-same-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params foo=\'dog\') id=\'dog-link\'}}Index{{/link-to}}\n ')); + + Router.map(function () { + this.route('search', function () { + this.route('results'); + }); + }); + + App.SearchController = _emberRuntime.Controller.extend({ + queryParams: ['search', 'archive'], + search: '', + archive: false + }); + + App.SearchResultsController = _emberRuntime.Controller.extend({ + queryParams: ['sort', 'showDetails'], + sort: 'title', + showDetails: true + }); + + bootApplication(); + + //Basic tests + shouldNotBeActive('#cat-link'); + shouldNotBeActive('#dog-link'); + _emberMetal.run(router, 'handleURL', '/?foo=cat'); + shouldBeActive('#cat-link'); + shouldNotBeActive('#dog-link'); + _emberMetal.run(router, 'handleURL', '/?foo=dog'); + shouldBeActive('#dog-link'); + shouldNotBeActive('#cat-link'); + shouldBeActive('#change-nothing'); + + //Multiple params + _emberMetal.run(function () { + return router.handleURL('/search?search=same'); + }); + shouldBeActive('#same-search'); + shouldNotBeActive('#change-search'); + shouldNotBeActive('#same-search-add-archive'); + shouldNotBeActive('#only-add-archive'); + shouldNotBeActive('#remove-one'); + + _emberMetal.run(function () { + return router.handleURL('/search?search=same&archive=true'); + }); + + shouldBeActive('#both-same'); + shouldNotBeActive('#change-one'); + + //Nested Controllers + _emberMetal.run(function () { + // Note: this is kind of a strange case; sort's default value is 'title', + // so this URL shouldn't have been generated in the first place, but + // we should also be able to gracefully handle these cases. + router.handleURL('/search/results?search=same&sort=title&showDetails=true'); + }); + //shouldBeActive('#same-sort-child-only'); + shouldBeActive('#same-search-parent-only'); + shouldNotBeActive('#change-search-parent-only'); + shouldBeActive('#same-search-same-sort-child-and-parent'); + shouldNotBeActive('#same-search-different-sort-child-and-parent'); + shouldNotBeActive('#change-search-same-sort-child-and-parent'); + }); + + QUnit.test('The {{link-to}} applies active class when query-param is number', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to (query-params page=pageNumber) id=\'page-link\'}}Index{{/link-to}}\n ')); + + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1, + pageNumber: 5 + }); + + bootApplication(); + + shouldNotBeActive('#page-link'); + _emberMetal.run(router, 'handleURL', '/?page=5'); + shouldBeActive('#page-link'); + }); + + QUnit.test('The {{link-to}} applies active class when query-param is array', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('\n {{#link-to (query-params pages=pagesArray) id=\'array-link\'}}Index{{/link-to}}\n {{#link-to (query-params pages=biggerArray) id=\'bigger-link\'}}Index{{/link-to}}\n {{#link-to (query-params pages=emptyArray) id=\'empty-link\'}}Index{{/link-to}}\n ')); + + App.IndexController = _emberRuntime.Controller.extend({ + queryParams: ['pages'], + pages: [], + pagesArray: [1, 2], + biggerArray: [1, 2, 3], + emptyArray: [] + }); + + bootApplication(); + + shouldNotBeActive('#array-link'); + _emberMetal.run(router, 'handleURL', '/?pages=%5B1%2C2%5D'); + shouldBeActive('#array-link'); + shouldNotBeActive('#bigger-link'); + shouldNotBeActive('#empty-link'); + _emberMetal.run(router, 'handleURL', '/?pages=%5B2%2C1%5D'); + shouldNotBeActive('#array-link'); + shouldNotBeActive('#bigger-link'); + shouldNotBeActive('#empty-link'); + _emberMetal.run(router, 'handleURL', '/?pages=%5B1%2C2%2C3%5D'); + shouldBeActive('#bigger-link'); + shouldNotBeActive('#array-link'); + shouldNotBeActive('#empty-link'); + }); + + QUnit.test('The {{link-to}} helper applies active class to parent route', function () { + App.Router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{#link-to \'parent\' id=\'parent-link\'}}Parent{{/link-to}}\n {{#link-to \'parent.child\' id=\'parent-child-link\'}}Child{{/link-to}}\n {{#link-to \'parent\' (query-params foo=cat) id=\'parent-link-qp\'}}Parent{{/link-to}}\n {{outlet}}\n ')); + + App.ParentChildController = _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: 'bar' + }); + + bootApplication(); + shouldNotBeActive('#parent-link'); + shouldNotBeActive('#parent-child-link'); + shouldNotBeActive('#parent-link-qp'); + _emberMetal.run(router, 'handleURL', '/parent/child?foo=dog'); + shouldBeActive('#parent-link'); + shouldNotBeActive('#parent-link-qp'); + }); + + QUnit.test('The {{link-to}} helper disregards query-params in activeness computation when current-when specified', function () { + App.Router.map(function () { + this.route('parent'); + }); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{#link-to \'parent\' (query-params page=1) current-when=\'parent\' id=\'app-link\'}}Parent{{/link-to}} {{outlet}}\n ')); + _emberGlimmer.setTemplate('parent', _emberTemplateCompiler.compile('\n {{#link-to \'parent\' (query-params page=1) current-when=\'parent\' id=\'parent-link\'}}Parent{{/link-to}} {{outlet}}\n ')); + + App.ParentController = _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1 + }); + + bootApplication(); + equal(_emberViews.jQuery('#app-link').attr('href'), '/parent'); + shouldNotBeActive('#app-link'); + + _emberMetal.run(router, 'handleURL', '/parent?page=2'); + equal(_emberViews.jQuery('#app-link').attr('href'), '/parent'); + shouldBeActive('#app-link'); + equal(_emberViews.jQuery('#parent-link').attr('href'), '/parent'); + shouldBeActive('#parent-link'); + + var parentController = container.lookup('controller:parent'); + equal(parentController.get('page'), 2); + _emberMetal.run(parentController, 'set', 'page', 3); + equal(router.get('location.path'), '/parent?page=3'); + shouldBeActive('#app-link'); + shouldBeActive('#parent-link'); + + _emberViews.jQuery('#app-link').click(); + equal(router.get('location.path'), '/parent'); + }); + + QUnit.test('link-to default query params while in active transition regression test', function () { + App.Router.map(function () { + this.route('foos'); + this.route('bars'); + }); + var foos = _emberRuntime.RSVP.defer(); + var bars = _emberRuntime.RSVP.defer(); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('\n {{link-to \'Foos\' \'foos\' id=\'foos-link\'}}\n {{link-to \'Baz Foos\' \'foos\' (query-params baz=true) id=\'baz-foos-link\'}}\n {{link-to \'Quux Bars\' \'bars\' (query-params quux=true) id=\'bars-link\'}}\n ')); + + App.FoosController = _emberRuntime.Controller.extend({ + queryParams: ['status'], + baz: false + }); + + App.FoosRoute = _emberRouting.Route.extend({ + model: function () { + return foos.promise; + } + }); + + App.BarsController = _emberRuntime.Controller.extend({ + queryParams: ['status'], + quux: false + }); + + App.BarsRoute = _emberRouting.Route.extend({ + model: function () { + return bars.promise; + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#foos-link').attr('href'), '/foos'); + equal(_emberViews.jQuery('#baz-foos-link').attr('href'), '/foos?baz=true'); + equal(_emberViews.jQuery('#bars-link').attr('href'), '/bars?quux=true'); + + equal(router.get('location.path'), ''); + + shouldNotBeActive('#foos-link'); + shouldNotBeActive('#baz-foos-link'); + shouldNotBeActive('#bars-link'); + + _emberMetal.run(_emberViews.jQuery('#bars-link'), 'click'); + shouldNotBeActive('#bars-link'); + + _emberMetal.run(_emberViews.jQuery('#foos-link'), 'click'); + shouldNotBeActive('#foos-link'); + + _emberMetal.run(foos, 'resolve'); + + equal(router.get('location.path'), '/foos'); + shouldBeActive('#foos-link'); + }); +}); +enifed('ember/tests/helpers/link_to_test/link_to_with_query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/helpers/link_to_test/link_to_with_query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/helpers/link_to_test/link_to_with_query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/homepage_example_test', ['exports', 'ember-routing', 'ember-metal', 'ember-application', 'ember-runtime', 'ember-template-compiler', 'ember-views', 'ember-glimmer'], function (exports, _emberRouting, _emberMetal, _emberApplication, _emberRuntime, _emberTemplateCompiler, _emberViews, _emberGlimmer) { + 'use strict'; + + var App = undefined, + $fixture = undefined; + + function setupExample() { + // setup templates + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    People

      {{#each model as |person|}}
    • Hello, {{person.fullName}}!
    • {{/each}}
    ')); + + App.Person = _emberRuntime.Object.extend({ + firstName: null, + lastName: null, + + fullName: _emberMetal.computed('firstName', 'lastName', function () { + return this.get('firstName') + ' ' + this.get('lastName'); + }) + }); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + var people = _emberRuntime.A([App.Person.create({ + firstName: 'Tom', + lastName: 'Dale' + }), App.Person.create({ + firstName: 'Yehuda', + lastName: 'Katz' + })]); + return people; + } + }); + } + + QUnit.module('Homepage Example', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + App.LoadingRoute = _emberRouting.Route.extend(); + }); + + $fixture = _emberViews.jQuery('#qunit-fixture'); + setupExample(); + }, + + teardown: function () { + _emberMetal.run(function () { + return App.destroy(); + }); + + App = null; + + _emberGlimmer.setTemplates({}); + } + }); + + QUnit.test('The example renders correctly', function () { + _emberMetal.run(App, 'advanceReadiness'); + + equal($fixture.find('h1:contains(People)').length, 1); + equal($fixture.find('li').length, 2); + equal($fixture.find('li:nth-of-type(1)').text(), 'Hello, Tom Dale!'); + equal($fixture.find('li:nth-of-type(2)').text(), 'Hello, Yehuda Katz!'); + }); +}); +enifed('ember/tests/homepage_example_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/homepage_example_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/homepage_example_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/integration/multiple-app-test', ['exports', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-glimmer', 'ember-views'], function (exports, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberGlimmer, _emberViews) { + 'use strict'; + + var App1 = undefined, + App2 = undefined, + actions = undefined; + + function startApp(rootElement) { + var application = undefined; + + _emberMetal.run(function () { + application = _emberApplication.Application.create({ + rootElement: rootElement + }); + application.deferReadiness(); + + application.Router.reopen({ + location: 'none' + }); + + var registry = application.__registry__; + + registry.register('component:special-button', _emberGlimmer.Component.extend({ + actions: { + doStuff: function () { + actions.push(rootElement); + } + } + })); + registry.register('template:application', _emberTemplateCompiler.compile('{{outlet}}', { moduleName: 'application' })); + registry.register('template:index', _emberTemplateCompiler.compile('

    Node 1

    {{special-button}}', { moduleName: 'index' })); + registry.register('template:components/special-button', _emberTemplateCompiler.compile('', { moduleName: 'components/special-button' })); + }); + + return application; + } + + function handleURL(application, path) { + var router = application.__container__.lookup('router:main'); + return _emberMetal.run(router, 'handleURL', path); + } + + QUnit.module('View Integration', { + setup: function () { + actions = []; + _emberViews.jQuery('#qunit-fixture').html('
    '); + App1 = startApp('#app-1'); + App2 = startApp('#app-2'); + }, + + teardown: function () { + _emberMetal.run(App1, 'destroy'); + _emberMetal.run(App2, 'destroy'); + App1 = App2 = null; + } + }); + + QUnit.test('booting multiple applications can properly handle events', function (assert) { + _emberMetal.run(App1, 'advanceReadiness'); + _emberMetal.run(App2, 'advanceReadiness'); + + handleURL(App1, '/'); + handleURL(App2, '/'); + + _emberViews.jQuery('#app-2 .do-stuff').click(); + _emberViews.jQuery('#app-1 .do-stuff').click(); + + assert.deepEqual(actions, ['#app-2', '#app-1']); + }); +}); +enifed('ember/tests/integration/multiple-app-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/integration/multiple-app-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/integration/multiple-app-test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/reexports_test', ['exports', 'ember/index', 'internal-test-helpers', 'ember-metal'], function (exports, _emberIndex, _internalTestHelpers, _emberMetal) { + 'use strict'; + + QUnit.module('ember reexports'); + + [ + // ember-utils + ['getOwner', 'ember-utils', 'getOwner'], ['setOwner', 'ember-utils', 'setOwner'], + // ['assign', 'ember-metal'], TODO: fix this test, we use `Object.assign` if present + ['GUID_KEY', 'ember-utils'], ['uuid', 'ember-utils'], ['generateGuid', 'ember-utils'], ['guidFor', 'ember-utils'], ['inspect', 'ember-utils'], ['makeArray', 'ember-utils'], ['canInvoke', 'ember-utils'], ['tryInvoke', 'ember-utils'], ['wrap', 'ember-utils'], ['applyStr', 'ember-utils'], + + // ember-environment + // ['ENV', 'ember-environment', 'ENV'], TODO: fix this, its failing because we are hitting the getter + + // container + ['Registry', 'container', 'Registry'], ['Container', 'container', 'Container'], + + // ember-metal + ['computed', 'ember-metal'], ['computed.alias', 'ember-metal', 'alias'], ['ComputedProperty', 'ember-metal'], ['cacheFor', 'ember-metal'], ['deprecate', 'ember-metal'], ['deprecateFunc', 'ember-metal'], ['assert', 'ember-metal'], ['warn', 'ember-metal'], ['debug', 'ember-metal'], ['runInDebug', 'ember-metal'], ['merge', 'ember-metal'], ['instrument', 'ember-metal'], ['Instrumentation.instrument', 'ember-metal', 'instrument'], ['Instrumentation.subscribe', 'ember-metal', 'instrumentationSubscribe'], ['Instrumentation.unsubscribe', 'ember-metal', 'instrumentationUnsubscribe'], ['Instrumentation.reset', 'ember-metal', 'instrumentationReset'], ['testing', 'ember-metal', { get: 'isTesting', set: 'setTesting' }], ['onerror', 'ember-metal', { get: 'getOnerror', set: 'setOnerror' }], + // ['create'], TODO: figure out what to do here + // ['keys'], TODO: figure out what to do here + ['FEATURES', 'ember-metal'], ['FEATURES.isEnabled', 'ember-metal', 'isFeatureEnabled'], ['Error', 'ember-metal'], ['META_DESC', 'ember-metal'], ['meta', 'ember-metal'], ['get', 'ember-metal'], ['set', 'ember-metal'], ['_getPath', 'ember-metal'], ['getWithDefault', 'ember-metal'], ['trySet', 'ember-metal'], ['_Cache', 'ember-metal', 'Cache'], ['on', 'ember-metal'], ['addListener', 'ember-metal'], ['removeListener', 'ember-metal'], ['_suspendListener', 'ember-metal', 'suspendListener'], ['_suspendListeners', 'ember-metal', 'suspendListeners'], ['sendEvent', 'ember-metal'], ['hasListeners', 'ember-metal'], ['watchedEvents', 'ember-metal'], ['listenersFor', 'ember-metal'], ['accumulateListeners', 'ember-metal'], ['isNone', 'ember-metal'], ['isEmpty', 'ember-metal'], ['isBlank', 'ember-metal'], ['isPresent', 'ember-metal'], ['_Backburner', 'backburner', 'default'], ['run', 'ember-metal'], ['_ObserverSet', 'ember-metal', 'ObserverSet'], ['propertyWillChange', 'ember-metal'], ['propertyDidChange', 'ember-metal'], ['overrideChains', 'ember-metal'], ['beginPropertyChanges', 'ember-metal'], ['beginPropertyChanges', 'ember-metal'], ['endPropertyChanges', 'ember-metal'], ['changeProperties', 'ember-metal'], ['defineProperty', 'ember-metal'], ['watchKey', 'ember-metal'], ['unwatchKey', 'ember-metal'], ['removeChainWatcher', 'ember-metal'], ['_ChainNode', 'ember-metal', 'ChainNode'], ['finishChains', 'ember-metal'], ['watchPath', 'ember-metal'], ['unwatchPath', 'ember-metal'], ['watch', 'ember-metal'], ['isWatching', 'ember-metal'], ['unwatch', 'ember-metal'], ['destroy', 'ember-metal'], ['libraries', 'ember-metal'], ['OrderedSet', 'ember-metal'], ['Map', 'ember-metal'], ['MapWithDefault', 'ember-metal'], ['getProperties', 'ember-metal'], ['setProperties', 'ember-metal'], ['expandProperties', 'ember-metal'], ['NAME_KEY', 'ember-utils'], ['addObserver', 'ember-metal'], ['observersFor', 'ember-metal'], ['removeObserver', 'ember-metal'], ['_suspendObserver', 'ember-metal'], ['_suspendObservers', 'ember-metal'], ['required', 'ember-metal'], ['aliasMethod', 'ember-metal'], ['observer', 'ember-metal'], ['immediateObserver', 'ember-metal', '_immediateObserver'], ['mixin', 'ember-metal'], ['Mixin', 'ember-metal'], ['bind', 'ember-metal'], ['Binding', 'ember-metal'], ['isGlobalPath', 'ember-metal'], + + // ember-views + ['$', 'ember-views', 'jQuery'], ['ViewUtils.isSimpleClick', 'ember-views', 'isSimpleClick'], ['ViewUtils.getViewElement', 'ember-views', 'getViewElement'], ['ViewUtils.getViewBounds', 'ember-views', 'getViewBounds'], ['ViewUtils.getViewClientRects', 'ember-views', 'getViewClientRects'], ['ViewUtils.getViewBoundingClientRect', 'ember-views', 'getViewBoundingClientRect'], ['ViewUtils.getRootViews', 'ember-views', 'getRootViews'], ['ViewUtils.getChildViews', 'ember-views', 'getChildViews'], ['TextSupport', 'ember-views'], ['ComponentLookup', 'ember-views'], ['EventDispatcher', 'ember-views'], + + // ember-glimmer + ['Component', 'ember-glimmer', 'Component'], ['Helper', 'ember-glimmer', 'Helper'], ['Helper.helper', 'ember-glimmer', 'helper'], ['Checkbox', 'ember-glimmer', 'Checkbox'], ['LinkComponent', 'ember-glimmer', 'LinkComponent'], ['TextArea', 'ember-glimmer', 'TextArea'], ['TextField', 'ember-glimmer', 'TextField'], ['TEMPLATES', 'ember-glimmer', { get: 'getTemplates', set: 'setTemplates' }], ['Handlebars.template', 'ember-glimmer', 'template'], ['Handlebars.SafeString', 'ember-glimmer', { get: '_getSafeString' }], ['Handlebars.Utils.escapeExpression', 'ember-glimmer', 'escapeExpression'], ['String.htmlSafe', 'ember-glimmer', 'htmlSafe'], ['HTMLBars.makeBoundHelper', 'ember-glimmer', 'makeBoundHelper'], + + // ember-runtime + ['_RegistryProxyMixin', 'ember-runtime', 'RegistryProxyMixin'], ['_ContainerProxyMixin', 'ember-runtime', 'ContainerProxyMixin'], ['Object', 'ember-runtime'], ['String', 'ember-runtime'], ['compare', 'ember-runtime'], ['copy', 'ember-runtime'], ['isEqual', 'ember-runtime'], ['inject', 'ember-runtime'], ['Array', 'ember-runtime'], ['Comparable', 'ember-runtime'], ['Namespace', 'ember-runtime'], ['Enumerable', 'ember-runtime'], ['ArrayProxy', 'ember-runtime'], ['ObjectProxy', 'ember-runtime'], ['ActionHandler', 'ember-runtime'], ['CoreObject', 'ember-runtime'], ['NativeArray', 'ember-runtime'], ['Copyable', 'ember-runtime'], ['Freezable', 'ember-runtime'], ['FROZEN_ERROR', 'ember-runtime'], ['MutableEnumerable', 'ember-runtime'], ['MutableArray', 'ember-runtime'], ['TargetActionSupport', 'ember-runtime'], ['Evented', 'ember-runtime'], ['PromiseProxyMixin', 'ember-runtime'], ['Observable', 'ember-runtime'], ['typeOf', 'ember-runtime'], ['isArray', 'ember-runtime'], ['Object', 'ember-runtime'], ['onLoad', 'ember-runtime'], ['runLoadHooks', 'ember-runtime'], ['Controller', 'ember-runtime'], ['ControllerMixin', 'ember-runtime'], ['Service', 'ember-runtime'], ['_ProxyMixin', 'ember-runtime'], ['RSVP', 'ember-runtime'], ['STRINGS', 'ember-runtime', { get: 'getStrings', set: 'setStrings' }], ['BOOTED', 'ember-runtime', { get: 'isNamespaceSearchDisabled', set: 'setNamespaceSearchDisabled' }], + + // ember-routing + ['Location', 'ember-routing'], ['AutoLocation', 'ember-routing'], ['HashLocation', 'ember-routing'], ['HistoryLocation', 'ember-routing'], ['NoneLocation', 'ember-routing'], ['controllerFor', 'ember-routing'], ['generateControllerFactory', 'ember-routing'], ['generateController', 'ember-routing'], ['RouterDSL', 'ember-routing'], ['Router', 'ember-routing'], ['Route', 'ember-routing'], + + // ember-application + ['Application', 'ember-application'], ['ApplicationInstance', 'ember-application'], ['Engine', 'ember-application'], ['EngineInstance', 'ember-application'], ['Resolver', 'ember-application'], ['DefaultResolver', 'ember-application', 'Resolver'], + + // ember-extension-support + ['DataAdapter', 'ember-extension-support'], ['ContainerDebugAdapter', 'ember-extension-support']].forEach(function (reexport) { + var path = reexport[0]; + var moduleId = reexport[1]; + var exportName = reexport[2]; + + // default path === exportName if none present + if (!exportName) { + exportName = path; + } + + QUnit.test('Ember.' + path + ' exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_emberIndex.default, assert, path, moduleId, exportName); + }); + }); + + QUnit.test('Ember.String.isHTMLSafe exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_emberIndex.default, assert, 'String.isHTMLSafe', 'ember-glimmer', 'isHTMLSafe'); + }); + + if (_emberMetal.isFeatureEnabled('ember-metal-weakmap')) { + QUnit.test('Ember.WeakMap exports correctly', function (assert) { + _internalTestHelpers.confirmExport(_emberIndex.default, assert, 'WeakMap', 'ember-metal', 'WeakMap'); + }); + } +}); +enifed('ember/tests/reexports_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/reexports_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/reexports_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/basic_test', ['exports', 'ember-utils', 'ember-console', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-glimmer', 'ember-views', 'ember-template-compiler', 'ember-application', 'router'], function (exports, _emberUtils, _emberConsole, _emberRuntime, _emberRouting, _emberMetal, _emberGlimmer, _emberViews, _emberTemplateCompiler, _emberApplication, _router) { + 'use strict'; + + var trim = _emberViews.jQuery.trim; + + var Router = undefined, + App = undefined, + router = undefined, + registry = undefined, + container = undefined, + originalLoggerError = undefined; + + function bootApplication() { + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function handleURL(path) { + return _emberMetal.run(function () { + return router.handleURL(path).then(function (value) { + ok(true, 'url: `' + path + '` was handled'); + return value; + }, function (reason) { + ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason)); + throw reason; + }); + }); + } + + function handleURLAborts(path) { + _emberMetal.run(function () { + router.handleURL(path).then(function (value) { + ok(false, 'url: `' + path + '` was NOT to be handled'); + }, function (reason) { + ok(reason && reason.message === 'TransitionAborted', 'url: `' + path + '` was to be aborted'); + }); + }); + } + + function handleURLRejectsWith(path, expectedReason) { + _emberMetal.run(function () { + router.handleURL(path).then(function (value) { + ok(false, 'expected handleURLing: `' + path + '` to fail'); + }, function (reason) { + equal(reason, expectedReason); + }); + }); + } + + QUnit.module('Basic Routing', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + Router = App.Router; + + App.LoadingRoute = _emberRouting.Route.extend({}); + + registry = App.__registry__; + container = App.__container__; + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    Hours

    ')); + _emberGlimmer.setTemplate('homepage', _emberTemplateCompiler.compile('

    Megatroll

    {{model.home}}

    ')); + _emberGlimmer.setTemplate('camelot', _emberTemplateCompiler.compile('

    Is a silly place

    ')); + + originalLoggerError = _emberConsole.default.error; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + + _emberGlimmer.setTemplates({}); + _emberConsole.default.error = originalLoggerError; + }); + } + }); + + QUnit.test('warn on URLs not included in the route set', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + bootApplication(); + + expectAssertion(function () { + return _emberMetal.run(function () { + return router.handleURL('/what-is-this-i-dont-even'); + }); + }, 'The URL \'/what-is-this-i-dont-even\' did not match any routes in your application'); + }); + + QUnit.test('The Homepage', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({}); + + var currentPath = undefined; + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + bootApplication(); + + equal(currentPath, 'home'); + equal(_emberViews.jQuery('h3:contains(Hours)', '#qunit-fixture').length, 1, 'The home template was rendered'); + }); + + QUnit.test('The Home page and the Camelot page with multiple Router.map calls', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + Router.map(function () { + this.route('camelot', { path: '/camelot' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({}); + + App.CamelotRoute = _emberRouting.Route.extend({}); + + var currentPath = undefined; + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + App.CamelotController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + bootApplication(); + + handleURL('/camelot'); + + equal(currentPath, 'camelot'); + equal(_emberViews.jQuery('h3:contains(silly)', '#qunit-fixture').length, 1, 'The camelot template was rendered'); + + handleURL('/'); + + equal(currentPath, 'home'); + equal(_emberViews.jQuery('h3:contains(Hours)', '#qunit-fixture').length, 1, 'The home template was rendered'); + }); + + QUnit.test('The Homepage with explicit template name in renderTemplate', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('homepage'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('An alternate template will pull in an alternate controller', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('homepage'); + } + }); + + App.HomepageController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from homepage' + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(Comes from homepage)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('An alternate template will pull in an alternate controller instead of controllerName', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'foo', + renderTemplate: function () { + this.render('homepage'); + } + }); + + App.FooController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from Foo' + } + }); + + App.HomepageController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from homepage' + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(Comes from homepage)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('The template will pull in an alternate controller via key/value', function () { + Router.map(function () { + this.route('homepage', { path: '/' }); + }); + + App.HomepageRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ controller: 'home' }); + } + }); + + App.HomeController = _emberRuntime.Controller.extend({ + model: { + home: 'Comes from home.' + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(Comes from home.)', '#qunit-fixture').length, 1, 'The homepage template was rendered from data from the HomeController'); + }); + + QUnit.test('The Homepage with explicit template name in renderTemplate and controller', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeController = _emberRuntime.Controller.extend({ + model: { + home: 'YES I AM HOME' + } + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('homepage'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('h3:contains(Megatroll) + p:contains(YES I AM HOME)', '#qunit-fixture').length, 1, 'The homepage template was rendered'); + }); + + QUnit.test('Model passed via renderTemplate model is set as controller\'s model', function () { + _emberGlimmer.setTemplate('bio', _emberTemplateCompiler.compile('

    {{model.name}}

    ')); + + App.BioController = _emberRuntime.Controller.extend(); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('bio', { + model: { name: 'emberjs' } + }); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('p:contains(emberjs)', '#qunit-fixture').length, 1, 'Passed model was set as controllers model'); + }); + + QUnit.test('render uses templateName from route', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('the_real_home_template', _emberTemplateCompiler.compile('

    THIS IS THE REAL HOME

    ')); + + App.HomeController = _emberRuntime.Controller.extend(); + App.HomeRoute = _emberRouting.Route.extend({ + templateName: 'the_real_home_template' + }); + + bootApplication(); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'THIS IS THE REAL HOME', 'The homepage template was rendered'); + }); + + QUnit.test('defining templateName allows other templates to be rendered', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('alert', _emberTemplateCompiler.compile('
    Invader!
    ')); + _emberGlimmer.setTemplate('the_real_home_template', _emberTemplateCompiler.compile('

    THIS IS THE REAL HOME

    {{outlet \'alert\'}}')); + + App.HomeController = _emberRuntime.Controller.extend(); + App.HomeRoute = _emberRouting.Route.extend({ + templateName: 'the_real_home_template', + actions: { + showAlert: function () { + this.render('alert', { + into: 'home', + outlet: 'alert' + }); + } + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'THIS IS THE REAL HOME', 'The homepage template was rendered'); + + _emberMetal.run(function () { + return router.send('showAlert'); + }); + + equal(_emberViews.jQuery('.alert-box', '#qunit-fixture').text(), 'Invader!', 'Template for alert was render into outlet'); + }); + + QUnit.test('templateName is still used when calling render with no name and options', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('alert', _emberTemplateCompiler.compile('
    Invader!
    ')); + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    THIS IS THE REAL HOME

    {{outlet \'alert\'}}')); + + App.HomeRoute = _emberRouting.Route.extend({ + templateName: 'alert', + renderTemplate: function () { + this.render({}); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('.alert-box', '#qunit-fixture').text(), 'Invader!', 'default templateName was rendered into outlet'); + }); + + QUnit.test('The Homepage with a `setupController` hook', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + _emberMetal.set(controller, 'hours', _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm'])); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each hours as |entry|}}
    • {{entry}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context'); + }); + + QUnit.test('The route controller is still set when overriding the setupController hook', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + // no-op + // importantly, we are not calling this._super here + } + }); + + registry.register('controller:home', _emberRuntime.Controller.extend()); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:home'), 'route controller is the home controller'); + }); + + QUnit.test('The route controller can be specified via controllerName', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    {{myValue}}

    ')); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'myController' + }); + + registry.register('controller:myController', _emberRuntime.Controller.extend({ + myValue: 'foo' + })); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'foo', 'The homepage template was rendered with data from the custom controller'); + }); + + QUnit.test('The route controller specified via controllerName is used in render', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('alternative_home', _emberTemplateCompiler.compile('

    alternative home: {{myValue}}

    ')); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'myController', + renderTemplate: function () { + this.render('alternative_home'); + } + }); + + registry.register('controller:myController', _emberRuntime.Controller.extend({ + myValue: 'foo' + })); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'alternative home: foo', 'The homepage template was rendered with data from the custom controller'); + }); + + QUnit.test('The route controller specified via controllerName is used in render even when a controller with the routeName is available', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    home: {{myValue}}

    ')); + + App.HomeRoute = _emberRouting.Route.extend({ + controllerName: 'myController' + }); + + registry.register('controller:home', _emberRuntime.Controller.extend({ + myValue: 'home' + })); + + registry.register('controller:myController', _emberRuntime.Controller.extend({ + myValue: 'myController' + })); + + bootApplication(); + + deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName'); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'home: myController', 'The homepage template was rendered with data from the custom controller'); + }); + + QUnit.test('The Homepage with a `setupController` hook modifying other controllers', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + _emberMetal.set(this.controllerFor('home'), 'hours', _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm'])); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each hours as |entry|}}
    • {{entry}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context'); + }); + + QUnit.test('The Homepage with a computed context that does not get overridden', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeController = _emberRuntime.Controller.extend({ + model: _emberMetal.computed(function () { + return _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']); + }) + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each model as |passage|}}
    • {{passage}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the context intact'); + }); + + QUnit.test('The Homepage getting its controller context via model', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']); + }, + + setupController: function (controller, model) { + equal(this.controllerFor('home'), controller); + + _emberMetal.set(this.controllerFor('home'), 'hours', model); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('
      {{#each hours as |entry|}}
    • {{entry}}
    • {{/each}}
    ')); + + bootApplication(); + + equal(_emberViews.jQuery('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context'); + }); + + QUnit.test('The Specials Page getting its controller context by deserializing the params hash', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + model: function (params) { + return _emberRuntime.Object.create({ + menuItemId: params.menu_item_id + }); + }, + + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.menuItemId}}

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The model was used to render the template'); + }); + + QUnit.test('The Specials Page defaults to looking models up via `find`', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + return App.MenuItem.create({ + id: id + }); + } + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The model was used to render the template'); + }); + + QUnit.test('The Special Page returning a promise puts the app into a loading state until the promise is resolved', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + var menuItem = undefined, + resolve = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + + return new _emberRuntime.RSVP.Promise(function (res) { + resolve = res; + }); + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({}); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING!

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'LOADING!', 'The app is in the loading state'); + + _emberMetal.run(function () { + return resolve(menuItem); + }); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The app is now in the specials state'); + }); + + QUnit.test('The loading state doesn\'t get entered for promises that resolve on the same run loop', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + return { id: id }; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + enter: function () { + ok(false, 'LoadingRoute shouldn\'t have been entered.'); + } + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING!

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + handleURL('/specials/1'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), '1', 'The app is now in the specials state'); + }); + + /* + asyncTest("The Special page returning an error fires the error hook on SpecialRoute", function() { + Router.map(function() { + this.route("home", { path: "/" }); + this.route("special", { path: "/specials/:menu_item_id" }); + }); + + let menuItem; + + App.MenuItem = Ember.Object.extend(); + App.MenuItem.reopenClass({ + find: function(id) { + menuItem = App.MenuItem.create({ id: id }); + run.later(function() { menuItem.resolve(menuItem); }, 1); + return menuItem; + } + }); + + App.SpecialRoute = Route.extend({ + setup: function() { + throw 'Setup error'; + }, + actions: { + error: function(reason) { + equal(reason, 'Setup error'); + QUnit.start(); + } + } + }); + + bootApplication(); + + handleURLRejectsWith('/specials/1', 'Setup error'); + }); + */ + + QUnit.test('The Special page returning an error invokes SpecialRoute\'s error handler', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + var menuItem = undefined, + promise = undefined, + resolve = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + promise = new _emberRuntime.RSVP.Promise(function (res) { + resolve = res; + }); + + return promise; + } + }); + + App.SpecialRoute = _emberRouting.Route.extend({ + setup: function () { + throw 'Setup error'; + }, + actions: { + error: function (reason) { + equal(reason, 'Setup error', 'SpecialRoute#error received the error thrown from setup'); + return true; + } + } + }); + + bootApplication(); + + handleURLRejectsWith('/specials/1', 'Setup error'); + + _emberMetal.run(function () { + return resolve(menuItem); + }); + }); + + var testOverridableErrorHandler = function (handlersName) { + expect(2); + + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + var menuItem = undefined, + resolve = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + return new _emberRuntime.RSVP.Promise(function (res) { + resolve = res; + }); + } + }); + + var attrs = {}; + attrs[handlersName] = { + error: function (reason) { + equal(reason, 'Setup error', 'error was correctly passed to custom ApplicationRoute handler'); + return true; + } + }; + + App.ApplicationRoute = _emberRouting.Route.extend(attrs); + + App.SpecialRoute = _emberRouting.Route.extend({ + setup: function () { + throw 'Setup error'; + } + }); + + bootApplication(); + + handleURLRejectsWith('/specials/1', 'Setup error'); + + _emberMetal.run(function () { + return resolve(menuItem); + }); + }; + + QUnit.test('ApplicationRoute\'s default error handler can be overridden', function () { + testOverridableErrorHandler('actions'); + }); + + QUnit.asyncTest('Moving from one page to another triggers the correct callbacks', function () { + expect(3); + + Router.map(function () { + this.route('home', { path: '/' }); + this.route('special', { path: '/specials/:menu_item_id' }); + }); + + App.MenuItem = _emberRuntime.Object.extend(); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('

    Home

    ')); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + var transition = handleURL('/'); + + _emberMetal.run(function () { + transition.then(function () { + equal(_emberViews.jQuery('h3', '#qunit-fixture').text(), 'Home', 'The app is now in the initial state'); + + var promiseContext = App.MenuItem.create({ id: 1 }); + _emberMetal.run.later(function () { + return _emberRuntime.RSVP.resolve(promiseContext); + }, 1); + + return router.transitionTo('special', promiseContext); + }).then(function (result) { + deepEqual(router.location.path, '/specials/1'); + QUnit.start(); + }); + }); + }); + + QUnit.asyncTest('Nested callbacks are not exited when moving to siblings', function () { + Router.map(function () { + this.route('root', { path: '/' }, function () { + this.route('special', { path: '/specials/:menu_item_id', resetNamespace: true }); + }); + }); + + App.RootRoute = _emberRouting.Route.extend({ + model: function () { + rootModel++; + return this._super.apply(this, arguments); + }, + + setupController: function () { + rootSetup++; + }, + + renderTemplate: function () { + rootRender++; + }, + + serialize: function () { + rootSerialize++; + return this._super.apply(this, arguments); + } + }); + + var currentPath = undefined; + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + var menuItem = undefined; + + App.MenuItem = _emberRuntime.Object.extend(); + App.MenuItem.reopenClass({ + find: function (id) { + menuItem = App.MenuItem.create({ id: id }); + return menuItem; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({}); + + App.HomeRoute = _emberRouting.Route.extend({}); + + App.SpecialRoute = _emberRouting.Route.extend({ + setupController: function (controller, model) { + _emberMetal.set(controller, 'model', model); + } + }); + + _emberGlimmer.setTemplate('root/index', _emberTemplateCompiler.compile('

    Home

    ')); + + _emberGlimmer.setTemplate('special', _emberTemplateCompiler.compile('

    {{model.id}}

    ')); + + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING!

    ')); + + var rootSetup = 0; + var rootRender = 0; + var rootModel = 0; + var rootSerialize = 0; + + bootApplication(); + + registry.register('controller:special', _emberRuntime.Controller.extend()); + + equal(_emberViews.jQuery('h3', '#qunit-fixture').text(), 'Home', 'The app is now in the initial state'); + equal(rootSetup, 1, 'The root setup was triggered'); + equal(rootRender, 1, 'The root render was triggered'); + equal(rootSerialize, 0, 'The root serialize was not called'); + equal(rootModel, 1, 'The root model was called'); + + router = container.lookup('router:main'); + + _emberMetal.run(function () { + var menuItem = App.MenuItem.create({ id: 1 }); + _emberMetal.run.later(function () { + return _emberRuntime.RSVP.resolve(menuItem); + }, 1); + + router.transitionTo('special', menuItem).then(function (result) { + equal(rootSetup, 1, 'The root setup was not triggered again'); + equal(rootRender, 1, 'The root render was not triggered again'); + equal(rootSerialize, 0, 'The root serialize was not called'); + + // TODO: Should this be changed? + equal(rootModel, 1, 'The root model was called again'); + + deepEqual(router.location.path, '/specials/1'); + equal(currentPath, 'root.special'); + + QUnit.start(); + }); + }); + }); + + QUnit.asyncTest('Events are triggered on the controller if a matching action name is implemented', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + var model = { name: 'Tom Dale' }; + var stateIsNotCalled = true; + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return model; + }, + + actions: { + showStuff: function (obj) { + stateIsNotCalled = false; + } + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('{{name}}')); + + var controller = _emberRuntime.Controller.extend({ + actions: { + showStuff: function (context) { + ok(stateIsNotCalled, 'an event on the state is not triggered'); + deepEqual(context, { name: 'Tom Dale' }, 'an event with context is passed'); + QUnit.start(); + } + } + }); + + registry.register('controller:home', controller); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.asyncTest('Events are triggered on the current state when defined in `actions` object', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + var model = { name: 'Tom Dale' }; + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return model; + }, + + actions: { + showStuff: function (obj) { + ok(this instanceof App.HomeRoute, 'the handler is an App.HomeRoute'); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(_emberRuntime.copy(obj, true), { name: 'Tom Dale' }, 'the context is correct'); + QUnit.start(); + } + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('{{model.name}}')); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.asyncTest('Events defined in `actions` object are triggered on the current state when routes are nested', function () { + Router.map(function () { + this.route('root', { path: '/' }, function () { + this.route('index', { path: '/' }); + }); + }); + + var model = { name: 'Tom Dale' }; + + App.RootRoute = _emberRouting.Route.extend({ + actions: { + showStuff: function (obj) { + ok(this instanceof App.RootRoute, 'the handler is an App.HomeRoute'); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(_emberRuntime.copy(obj, true), { name: 'Tom Dale' }, 'the context is correct'); + QUnit.start(); + } + } + }); + + App.RootIndexRoute = _emberRouting.Route.extend({ + model: function () { + return model; + } + }); + + _emberGlimmer.setTemplate('root/index', _emberTemplateCompiler.compile('{{model.name}}')); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.test('Events can be handled by inherited event handlers', function () { + expect(4); + + App.SuperRoute = _emberRouting.Route.extend({ + actions: { + foo: function () { + ok(true, 'foo'); + }, + bar: function (msg) { + equal(msg, 'HELLO'); + } + } + }); + + App.RouteMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + App.IndexRoute = App.SuperRoute.extend(App.RouteMixin, { + actions: { + baz: function () { + ok(true, 'baz'); + } + } + }); + + bootApplication(); + + router.send('foo'); + router.send('bar', 'HELLO'); + router.send('baz'); + }); + + QUnit.asyncTest('Actions are not triggered on the controller if a matching action name is implemented as a method', function () { + Router.map(function () { + this.route('home', { path: '/' }); + }); + + var model = { name: 'Tom Dale' }; + var stateIsNotCalled = true; + + App.HomeRoute = _emberRouting.Route.extend({ + model: function () { + return model; + }, + + actions: { + showStuff: function (context) { + ok(stateIsNotCalled, 'an event on the state is not triggered'); + deepEqual(context, { name: 'Tom Dale' }, 'an event with context is passed'); + QUnit.start(); + } + } + }); + + _emberGlimmer.setTemplate('home', _emberTemplateCompiler.compile('{{name}}')); + + var controller = _emberRuntime.Controller.extend({ + showStuff: function (context) { + stateIsNotCalled = false; + ok(stateIsNotCalled, 'an event on the state is not triggered'); + } + }); + + registry.register('controller:home', controller); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.asyncTest('actions can be triggered with multiple arguments', function () { + Router.map(function () { + this.route('root', { path: '/' }, function () { + this.route('index', { path: '/' }); + }); + }); + + var model1 = { name: 'Tilde' }; + var model2 = { name: 'Tom Dale' }; + + App.RootRoute = _emberRouting.Route.extend({ + actions: { + showStuff: function (obj1, obj2) { + ok(this instanceof App.RootRoute, 'the handler is an App.HomeRoute'); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(_emberRuntime.copy(obj1, true), { name: 'Tilde' }, 'the first context is correct'); + deepEqual(_emberRuntime.copy(obj2, true), { name: 'Tom Dale' }, 'the second context is correct'); + QUnit.start(); + } + } + }); + + App.RootIndexController = _emberRuntime.Controller.extend({ + model1: model1, + model2: model2 + }); + + _emberGlimmer.setTemplate('root/index', _emberTemplateCompiler.compile('{{model1.name}}')); + + bootApplication(); + + _emberViews.jQuery('#qunit-fixture a').click(); + }); + + QUnit.test('transitioning multiple times in a single run loop only sets the URL once', function () { + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo'); + this.route('bar'); + }); + + bootApplication(); + + var urlSetCount = 0; + + router.get('location').setURL = function (path) { + urlSetCount++; + _emberMetal.set(this, 'path', path); + }; + + equal(urlSetCount, 0); + + _emberMetal.run(function () { + router.transitionTo('foo'); + router.transitionTo('bar'); + }); + + equal(urlSetCount, 1); + equal(router.get('location').getURL(), '/bar'); + }); + + QUnit.test('navigating away triggers a url property change', function () { + expect(3); + + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo', { path: '/foo' }); + this.route('bar', { path: '/bar' }); + }); + + bootApplication(); + + _emberMetal.run(function () { + _emberMetal.addObserver(router, 'url', function () { + ok(true, 'url change event was fired'); + }); + }); + + ['foo', 'bar', '/foo'].forEach(function (destination) { + return _emberMetal.run(router, 'transitionTo', destination); + }); + }); + + QUnit.test('using replaceWith calls location.replaceURL if available', function () { + var setCount = 0; + var replaceCount = 0; + + Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + setCount++; + _emberMetal.set(this, 'path', path); + }, + + replaceURL: function (path) { + replaceCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo'); + }); + + bootApplication(); + + equal(setCount, 0); + equal(replaceCount, 0); + + _emberMetal.run(function () { + return router.replaceWith('foo'); + }); + + equal(setCount, 0, 'should not call setURL'); + equal(replaceCount, 1, 'should call replaceURL once'); + equal(router.get('location').getURL(), '/foo'); + }); + + QUnit.test('using replaceWith calls setURL if location.replaceURL is not defined', function () { + var setCount = 0; + + Router.reopen({ + location: _emberRouting.NoneLocation.create({ + setURL: function (path) { + setCount++; + _emberMetal.set(this, 'path', path); + } + }) + }); + + Router.map(function () { + this.route('root', { path: '/' }); + this.route('foo'); + }); + + bootApplication(); + + equal(setCount, 0); + + _emberMetal.run(function () { + return router.replaceWith('foo'); + }); + + equal(setCount, 1, 'should call setURL once'); + equal(router.get('location').getURL(), '/foo'); + }); + + QUnit.test('Route inherits model from parent route', function () { + expect(9); + + Router.map(function () { + this.route('the_post', { path: '/posts/:post_id' }, function () { + this.route('comments'); + + this.route('shares', { path: '/shares/:share_id', resetNamespace: true }, function () { + this.route('share'); + }); + }); + }); + + var post1 = {}; + var post2 = {}; + var post3 = {}; + var share1 = {}; + var share2 = {}; + var share3 = {}; + + var posts = { + 1: post1, + 2: post2, + 3: post3 + }; + var shares = { + 1: share1, + 2: share2, + 3: share3 + }; + + App.ThePostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + App.ThePostCommentsRoute = _emberRouting.Route.extend({ + afterModel: function (post, transition) { + var parent_model = this.modelFor('thePost'); + + equal(post, parent_model); + } + }); + + App.SharesRoute = _emberRouting.Route.extend({ + model: function (params) { + return shares[params.share_id]; + } + }); + + App.SharesShareRoute = _emberRouting.Route.extend({ + afterModel: function (share, transition) { + var parent_model = this.modelFor('shares'); + + equal(share, parent_model); + } + }); + + bootApplication(); + + handleURL('/posts/1/comments'); + handleURL('/posts/1/shares/1'); + + handleURL('/posts/2/comments'); + handleURL('/posts/2/shares/2'); + + handleURL('/posts/3/comments'); + handleURL('/posts/3/shares/3'); + }); + + QUnit.test('Routes with { resetNamespace: true } inherits model from parent route', function () { + expect(6); + + Router.map(function () { + this.route('the_post', { path: '/posts/:post_id' }, function () { + this.route('comments', { resetNamespace: true }, function () {}); + }); + }); + + var post1 = {}; + var post2 = {}; + var post3 = {}; + + var posts = { + 1: post1, + 2: post2, + 3: post3 + }; + + App.ThePostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + App.CommentsRoute = _emberRouting.Route.extend({ + afterModel: function (post, transition) { + var parent_model = this.modelFor('thePost'); + + equal(post, parent_model); + } + }); + + bootApplication(); + + handleURL('/posts/1/comments'); + handleURL('/posts/2/comments'); + handleURL('/posts/3/comments'); + }); + + QUnit.test('It is possible to get the model from a parent route', function () { + expect(9); + + Router.map(function () { + this.route('the_post', { path: '/posts/:post_id' }, function () { + this.route('comments', { resetNamespace: true }); + }); + }); + + var post1 = {}; + var post2 = {}; + var post3 = {}; + var currentPost = undefined; + + var posts = { + 1: post1, + 2: post2, + 3: post3 + }; + + App.ThePostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + App.CommentsRoute = _emberRouting.Route.extend({ + model: function () { + // Allow both underscore / camelCase format. + equal(this.modelFor('thePost'), currentPost); + equal(this.modelFor('the_post'), currentPost); + } + }); + + bootApplication(); + + currentPost = post1; + handleURL('/posts/1/comments'); + + currentPost = post2; + handleURL('/posts/2/comments'); + + currentPost = post3; + handleURL('/posts/3/comments'); + }); + + QUnit.test('A redirection hook is provided', function () { + Router.map(function () { + this.route('choose', { path: '/' }); + this.route('home'); + }); + + var chooseFollowed = 0; + var destination = undefined; + + App.ChooseRoute = _emberRouting.Route.extend({ + redirect: function () { + if (destination) { + this.transitionTo(destination); + } + }, + + setupController: function () { + chooseFollowed++; + } + }); + + destination = 'home'; + + bootApplication(); + + equal(chooseFollowed, 0, 'The choose route wasn\'t entered since a transition occurred'); + equal(_emberViews.jQuery('h3:contains(Hours)', '#qunit-fixture').length, 1, 'The home template was rendered'); + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'home'); + }); + + QUnit.test('Redirecting from the middle of a route aborts the remainder of the routes', function () { + expect(3); + + Router.map(function () { + this.route('home'); + this.route('foo', function () { + this.route('bar', { resetNamespace: true }, function () { + this.route('baz'); + }); + }); + }); + + App.BarRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('home'); + }, + setupController: function () { + ok(false, 'Should transition before setupController'); + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + enter: function () { + ok(false, 'Should abort transition getting to next route'); + } + }); + + bootApplication(); + + handleURLAborts('/foo/bar/baz'); + + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'home'); + equal(router.get('location').getURL(), '/home'); + }); + + QUnit.test('Redirecting to the current target in the middle of a route does not abort initial routing', function () { + expect(5); + + Router.map(function () { + this.route('home'); + this.route('foo', function () { + this.route('bar', { resetNamespace: true }, function () { + this.route('baz'); + }); + }); + }); + + var successCount = 0; + App.BarRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('bar.baz').then(function () { + successCount++; + }); + }, + + setupController: function () { + ok(true, 'Should still invoke bar\'s setupController'); + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(true, 'Should still invoke bar.baz\'s setupController'); + } + }); + + bootApplication(); + + handleURL('/foo/bar/baz'); + + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'foo.bar.baz'); + equal(successCount, 1, 'transitionTo success handler was called once'); + }); + + QUnit.test('Redirecting to the current target with a different context aborts the remainder of the routes', function () { + expect(4); + + Router.map(function () { + this.route('home'); + this.route('foo', function () { + this.route('bar', { path: 'bar/:id', resetNamespace: true }, function () { + this.route('baz'); + }); + }); + }); + + var model = { id: 2 }; + + var count = 0; + + App.BarRoute = _emberRouting.Route.extend({ + afterModel: function (context) { + if (count++ > 10) { + ok(false, 'infinite loop'); + } else { + this.transitionTo('bar.baz', model); + } + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(true, 'Should still invoke setupController'); + } + }); + + bootApplication(); + + handleURLAborts('/foo/bar/1/baz'); + + equal(_emberUtils.getOwner(router).lookup('controller:application').get('currentPath'), 'foo.bar.baz'); + equal(router.get('location').getURL(), '/foo/bar/2/baz'); + }); + + QUnit.test('Transitioning from a parent event does not prevent currentPath from being set', function () { + Router.map(function () { + this.route('foo', function () { + this.route('bar', { resetNamespace: true }, function () { + this.route('baz'); + }); + this.route('qux'); + }); + }); + + App.FooRoute = _emberRouting.Route.extend({ + actions: { + goToQux: function () { + this.transitionTo('foo.qux'); + } + } + }); + + bootApplication(); + + var applicationController = _emberUtils.getOwner(router).lookup('controller:application'); + + handleURL('/foo/bar/baz'); + + equal(applicationController.get('currentPath'), 'foo.bar.baz'); + + _emberMetal.run(function () { + return router.send('goToQux'); + }); + + equal(applicationController.get('currentPath'), 'foo.qux'); + equal(router.get('location').getURL(), '/foo/qux'); + }); + + QUnit.test('Generated names can be customized when providing routes with dot notation', function () { + expect(4); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    Index
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Home

    {{outlet}}
    ')); + _emberGlimmer.setTemplate('foo', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('bar', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('bar/baz', _emberTemplateCompiler.compile('

    {{name}}Bottom!

    ')); + + Router.map(function () { + this.route('foo', { path: '/top' }, function () { + this.route('bar', { path: '/middle', resetNamespace: true }, function () { + this.route('baz', { path: '/bottom' }); + }); + }); + }); + + App.FooRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + ok(true, 'FooBarRoute was called'); + return this._super.apply(this, arguments); + } + }); + + App.BarBazRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + ok(true, 'BarBazRoute was called'); + return this._super.apply(this, arguments); + } + }); + + App.BarController = _emberRuntime.Controller.extend({ + name: 'Bar' + }); + + App.BarBazController = _emberRuntime.Controller.extend({ + name: 'BarBaz' + }); + + bootApplication(); + + handleURL('/top/middle/bottom'); + + equal(_emberViews.jQuery('.main .middle .bottom p', '#qunit-fixture').text(), 'BarBazBottom!', 'The templates were rendered into their appropriate parents'); + }); + + QUnit.test('Child routes render into their parent route\'s template by default', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    Index
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Home

    {{outlet}}
    ')); + _emberGlimmer.setTemplate('top', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle/bottom', _emberTemplateCompiler.compile('

    Bottom!

    ')); + + Router.map(function () { + this.route('top', function () { + this.route('middle', { resetNamespace: true }, function () { + this.route('bottom'); + }); + }); + }); + + bootApplication(); + + handleURL('/top/middle/bottom'); + + equal(_emberViews.jQuery('.main .middle .bottom p', '#qunit-fixture').text(), 'Bottom!', 'The templates were rendered into their appropriate parents'); + }); + + QUnit.test('Child routes render into specified template', function () { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    Index
    ')); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    Home

    {{outlet}}
    ')); + _emberGlimmer.setTemplate('top', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('middle/bottom', _emberTemplateCompiler.compile('

    Bottom!

    ')); + + Router.map(function () { + this.route('top', function () { + this.route('middle', { resetNamespace: true }, function () { + this.route('bottom'); + }); + }); + }); + + App.MiddleBottomRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('middle/bottom', { into: 'top' }); + } + }); + + bootApplication(); + + handleURL('/top/middle/bottom'); + + equal(_emberViews.jQuery('.main .middle .bottom p', '#qunit-fixture').length, 0, 'should not render into the middle template'); + equal(_emberViews.jQuery('.main .middle > p', '#qunit-fixture').text(), 'Bottom!', 'The template was rendered into the top template'); + }); + + QUnit.test('Rendering into specified template with slash notation', function () { + _emberGlimmer.setTemplate('person/profile', _emberTemplateCompiler.compile('profile {{outlet}}')); + _emberGlimmer.setTemplate('person/details', _emberTemplateCompiler.compile('details!')); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('person/profile'); + this.render('person/details', { into: 'person/profile' }); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture:contains(profile details!)').length, 1, 'The templates were rendered'); + }); + + QUnit.test('Parent route context change', function () { + var editCount = 0; + var editedPostIds = _emberRuntime.A(); + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('post', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('post/index', _emberTemplateCompiler.compile('showing')); + _emberGlimmer.setTemplate('post/edit', _emberTemplateCompiler.compile('editing')); + + Router.map(function () { + this.route('posts', function () { + this.route('post', { path: '/:postId', resetNamespace: true }, function () { + this.route('edit'); + }); + }); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + showPost: function (context) { + this.transitionTo('post', context); + } + } + }); + + App.PostRoute = _emberRouting.Route.extend({ + model: function (params) { + return { id: params.postId }; + }, + + serialize: function (model) { + return { postId: model.id }; + }, + + actions: { + editPost: function (context) { + this.transitionTo('post.edit'); + } + } + }); + + App.PostEditRoute = _emberRouting.Route.extend({ + model: function (params) { + var postId = this.modelFor('post').id; + editedPostIds.push(postId); + return null; + }, + setup: function () { + this._super.apply(this, arguments); + editCount++; + } + }); + + bootApplication(); + + handleURL('/posts/1'); + + _emberMetal.run(function () { + return router.send('editPost'); + }); + _emberMetal.run(function () { + return router.send('showPost', { id: '2' }); + }); + _emberMetal.run(function () { + return router.send('editPost'); + }); + + equal(editCount, 2, 'set up the edit route twice without failure'); + deepEqual(editedPostIds, ['1', '2'], 'modelFor posts.post returns the right context'); + }); + + QUnit.test('Router accounts for rootURL on page load when using history location', function () { + var rootURL = window.location.pathname + '/app'; + var postsTemplateRendered = false; + var setHistory = undefined, + HistoryTestLocation = undefined; + + setHistory = function (obj, path) { + obj.set('history', { state: { path: path } }); + }; + + // Create new implementation that extends HistoryLocation + // and set current location to rootURL + '/posts' + HistoryTestLocation = _emberRouting.HistoryLocation.extend({ + initState: function () { + var path = rootURL + '/posts'; + + setHistory(this, path); + this.set('location', { + pathname: path, + href: 'http://localhost/' + path + }); + }, + + replaceState: function (path) { + setHistory(this, path); + }, + + pushState: function (path) { + setHistory(this, path); + } + }); + + registry.register('location:historyTest', HistoryTestLocation); + + Router.reopen({ + location: 'historyTest', + rootURL: rootURL + }); + + Router.map(function () { + this.route('posts', { path: '/posts' }); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + model: function () {}, + renderTemplate: function () { + postsTemplateRendered = true; + } + }); + + bootApplication(); + + ok(postsTemplateRendered, 'Posts route successfully stripped from rootURL'); + }); + + QUnit.test('The rootURL is passed properly to the location implementation', function () { + expect(1); + var rootURL = '/blahzorz'; + var HistoryTestLocation = undefined; + + HistoryTestLocation = _emberRouting.HistoryLocation.extend({ + rootURL: 'this is not the URL you are looking for', + initState: function () { + equal(this.get('rootURL'), rootURL); + } + }); + + registry.register('location:history-test', HistoryTestLocation); + + Router.reopen({ + location: 'history-test', + rootURL: rootURL, + // if we transition in this test we will receive failures + // if the tests are run from a static file + _doURLTransition: function () {} + }); + + bootApplication(); + }); + + QUnit.test('Only use route rendered into main outlet for default into property on child', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet \'menu\'}}{{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('

    postsIndex

    ')); + _emberGlimmer.setTemplate('posts/menu', _emberTemplateCompiler.compile('
    postsMenu
    ')); + + Router.map(function () { + this.route('posts', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('posts/menu', { + into: 'application', + outlet: 'menu' + }); + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, 'The posts/menu template was rendered'); + equal(_emberViews.jQuery('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + }); + + QUnit.test('Generating a URL should not affect currentModel', function () { + Router.map(function () { + this.route('post', { path: '/posts/:post_id' }); + }); + + var posts = { + 1: { id: 1 }, + 2: { id: 2 } + }; + + App.PostRoute = _emberRouting.Route.extend({ + model: function (params) { + return posts[params.post_id]; + } + }); + + bootApplication(); + + handleURL('/posts/1'); + + var route = container.lookup('route:post'); + equal(route.modelFor('post'), posts[1]); + + var url = router.generate('post', posts[2]); + equal(url, '/posts/2'); + + equal(route.modelFor('post'), posts[1]); + }); + + QUnit.test('Generated route should be an instance of App.Route if provided', function () { + var generatedRoute = undefined; + + Router.map(function () { + this.route('posts'); + }); + + App.Route = _emberRouting.Route.extend(); + + bootApplication(); + + handleURL('/posts'); + + generatedRoute = container.lookup('route:posts'); + + ok(generatedRoute instanceof App.Route, 'should extend the correct route'); + }); + + QUnit.test('Nested index route is not overriden by parent\'s implicit index route', function () { + Router.map(function () { + this.route('posts', function () { + this.route('index', { path: ':category' }); + }); + }); + + bootApplication(); + + _emberMetal.run(function () { + return router.transitionTo('posts', { category: 'emberjs' }); + }); + + deepEqual(router.location.path, '/posts/emberjs'); + }); + + QUnit.test('Application template does not duplicate when re-rendered', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    I Render Once

    {{outlet}}')); + + Router.map(function () { + this.route('posts'); + }); + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.A(); + } + }); + + bootApplication(); + + // should cause application template to re-render + handleURL('/posts'); + + equal(_emberViews.jQuery('h3:contains(I Render Once)').length, 1); + }); + + QUnit.test('Child routes should render inside the application template if the application template causes a redirect', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('

    App

    {{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('posts')); + + Router.map(function () { + this.route('posts'); + this.route('photos'); + }); + + App.ApplicationRoute = _emberRouting.Route.extend({ + afterModel: function () { + this.transitionTo('posts'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture > div').text(), 'App posts'); + }); + + QUnit.test('The template is not re-rendered when the route\'s context changes', function () { + Router.map(function () { + this.route('page', { path: '/page/:name' }); + }); + + App.PageRoute = _emberRouting.Route.extend({ + model: function (params) { + return _emberRuntime.Object.create({ name: params.name }); + } + }); + + var insertionCount = 0; + App.FooBarComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + insertionCount += 1; + } + }); + + _emberGlimmer.setTemplate('page', _emberTemplateCompiler.compile('

    {{model.name}}{{foo-bar}}

    ')); + + bootApplication(); + + handleURL('/page/first'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'first'); + equal(insertionCount, 1); + + handleURL('/page/second'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'second'); + equal(insertionCount, 1, 'view should have inserted only once'); + + _emberMetal.run(function () { + return router.transitionTo('page', _emberRuntime.Object.create({ name: 'third' })); + }); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'third'); + equal(insertionCount, 1, 'view should still have inserted only once'); + }); + + QUnit.test('The template is not re-rendered when two routes present the exact same template & controller', function () { + Router.map(function () { + this.route('first'); + this.route('second'); + this.route('third'); + this.route('fourth'); + }); + + // Note add a component to test insertion + + var insertionCount = 0; + App.XInputComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + insertionCount += 1; + } + }); + + App.SharedRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + this.controllerFor('shared').set('message', 'This is the ' + this.routeName + ' message'); + }, + + renderTemplate: function (controller, context) { + this.render('shared', { controller: 'shared' }); + } + }); + + App.FirstRoute = App.SharedRoute.extend(); + App.SecondRoute = App.SharedRoute.extend(); + App.ThirdRoute = App.SharedRoute.extend(); + App.FourthRoute = App.SharedRoute.extend(); + + App.SharedController = _emberRuntime.Controller.extend(); + + _emberGlimmer.setTemplate('shared', _emberTemplateCompiler.compile('

    {{message}}{{x-input}}

    ')); + + bootApplication(); + + handleURL('/first'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the first message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Transition by URL + handleURL('/second'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the second message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Then transition directly by route name + _emberMetal.run(function () { + router.transitionTo('third').then(function (value) { + ok(true, 'expected transition'); + }, function (reason) { + ok(false, 'unexpected transition failure: ', QUnit.jsDump.parse(reason)); + }); + }); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the third message'); + equal(insertionCount, 1, 'expected one assertion'); + + // Lastly transition to a different view, with the same controller and template + handleURL('/fourth'); + equal(insertionCount, 1, 'expected one assertion'); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'This is the fourth message'); + }); + + QUnit.test('ApplicationRoute with model does not proxy the currentPath', function () { + var model = {}; + var currentPath = undefined; + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return model; + } + }); + + App.ApplicationController = _emberRuntime.Controller.extend({ + currentPathDidChange: _emberMetal.observer('currentPath', function () { + currentPath = _emberMetal.get(this, 'currentPath'); + }) + }); + + bootApplication(); + + equal(currentPath, 'index', 'currentPath is index'); + equal('currentPath' in model, false, 'should have defined currentPath on controller'); + }); + + QUnit.test('Promises encountered on app load put app into loading state until resolved', function () { + expect(2); + + var deferred = _emberRuntime.RSVP.defer(); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    INDEX

    ')); + _emberGlimmer.setTemplate('loading', _emberTemplateCompiler.compile('

    LOADING

    ')); + + bootApplication(); + + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'LOADING', 'The loading state is displaying.'); + _emberMetal.run(deferred.resolve); + equal(_emberViews.jQuery('p', '#qunit-fixture').text(), 'INDEX', 'The index route is display.'); + }); + + QUnit.test('Route should tear down multiple outlets', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet \'menu\'}}{{outlet}}{{outlet \'footer\'}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('users', _emberTemplateCompiler.compile('users')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('

    postsIndex

    ')); + _emberGlimmer.setTemplate('posts/menu', _emberTemplateCompiler.compile('
    postsMenu
    ')); + _emberGlimmer.setTemplate('posts/footer', _emberTemplateCompiler.compile('')); + + Router.map(function () { + this.route('posts', function () {}); + this.route('users', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('posts/menu', { + into: 'application', + outlet: 'menu' + }); + + this.render(); + + this.render('posts/footer', { + into: 'application', + outlet: 'footer' + }); + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, 'The posts/menu template was rendered'); + equal(_emberViews.jQuery('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + equal(_emberViews.jQuery('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 1, 'The posts/footer template was rendered'); + + handleURL('/users'); + + equal(_emberViews.jQuery('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 0, 'The posts/menu template was removed'); + equal(_emberViews.jQuery('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, 'The posts/index template was removed'); + equal(_emberViews.jQuery('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 0, 'The posts/footer template was removed'); + }); + + QUnit.test('Route will assert if you try to explicitly render {into: ...} a missing template', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'nonexistent' }); + } + }); + + expectAssertion(function () { + return bootApplication(); + }, 'You attempted to render into \'nonexistent\' but it was not found'); + }); + + QUnit.test('Route supports clearing outlet explicitly', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet \'modal\'}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('users', _emberTemplateCompiler.compile('users')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('
    postsIndex {{outlet}}
    ')); + _emberGlimmer.setTemplate('posts/modal', _emberTemplateCompiler.compile('
    postsModal
    ')); + _emberGlimmer.setTemplate('posts/extra', _emberTemplateCompiler.compile('
    postsExtra
    ')); + + Router.map(function () { + this.route('posts', function () {}); + this.route('users', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + showModal: function () { + this.render('posts/modal', { + into: 'application', + outlet: 'modal' + }); + }, + hideModal: function () { + this.disconnectOutlet({ outlet: 'modal', parentView: 'application' }); + } + } + }); + + App.PostsIndexRoute = _emberRouting.Route.extend({ + actions: { + showExtra: function () { + this.render('posts/extra', { + into: 'posts/index' + }); + }, + hideExtra: function () { + this.disconnectOutlet({ parentView: 'posts/index' }); + } + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + + _emberMetal.run(function () { + return router.send('showModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); + + _emberMetal.run(function () { + return router.send('showExtra'); + }); + + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 1, 'The posts/extra template was rendered'); + + _emberMetal.run(function () { + return router.send('hideModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + + _emberMetal.run(function () { + return router.send('hideExtra'); + }); + + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, 'The posts/extra template was removed'); + _emberMetal.run(function () { + router.send('showModal'); + }); + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); + _emberMetal.run(function () { + router.send('showExtra'); + }); + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 1, 'The posts/extra template was rendered'); + + handleURL('/users'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, 'The posts/index template was removed'); + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + equal(_emberViews.jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, 'The posts/extra template was removed'); + }); + + QUnit.test('Route supports clearing outlet using string parameter', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet \'modal\'}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('users', _emberTemplateCompiler.compile('users')); + _emberGlimmer.setTemplate('posts/index', _emberTemplateCompiler.compile('
    postsIndex {{outlet}}
    ')); + _emberGlimmer.setTemplate('posts/modal', _emberTemplateCompiler.compile('
    postsModal
    ')); + + Router.map(function () { + this.route('posts', function () {}); + this.route('users', function () {}); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + showModal: function () { + this.render('posts/modal', { + into: 'application', + outlet: 'modal' + }); + }, + hideModal: function () { + this.disconnectOutlet('modal'); + } + } + }); + + bootApplication(); + + handleURL('/posts'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); + + _emberMetal.run(function () { + return router.send('showModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); + + _emberMetal.run(function () { + return router.send('hideModal'); + }); + + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + + handleURL('/users'); + + equal(_emberViews.jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, 'The posts/index template was removed'); + equal(_emberViews.jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); + }); + + QUnit.test('Route silently fails when cleaning an outlet from an inactive view', function () { + expect(1); // handleURL + + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('{{outlet \'modal\'}}')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('A Yo.')); + + Router.map(function () { + this.route('posts'); + }); + + App.PostsRoute = _emberRouting.Route.extend({ + actions: { + hideSelf: function () { + this.disconnectOutlet({ outlet: 'main', parentView: 'application' }); + }, + showModal: function () { + this.render('modal', { into: 'posts', outlet: 'modal' }); + }, + hideModal: function () { + this.disconnectOutlet({ outlet: 'modal', parentView: 'posts' }); + } + } + }); + + bootApplication(); + + handleURL('/posts'); + + _emberMetal.run(function () { + return router.send('showModal'); + }); + _emberMetal.run(function () { + return router.send('hideSelf'); + }); + _emberMetal.run(function () { + return router.send('hideModal'); + }); + }); + + QUnit.test('Router `willTransition` hook passes in cancellable transition', function () { + // Should hit willTransition 3 times, once for the initial route, and then 2 more times + // for the two handleURL calls below + expect(3); + + Router.map(function () { + this.route('nork'); + this.route('about'); + }); + + Router.reopen({ + init: function () { + this._super(); + this.on('willTransition', this.testWillTransitionHook); + }, + testWillTransitionHook: function (transition, url) { + ok(true, 'willTransition was called ' + url); + transition.abort(); + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + activate: function () { + ok(false, 'LoadingRoute was not entered'); + } + }); + + App.NorkRoute = _emberRouting.Route.extend({ + activate: function () { + ok(false, 'NorkRoute was not entered'); + } + }); + + App.AboutRoute = _emberRouting.Route.extend({ + activate: function () { + ok(false, 'AboutRoute was not entered'); + } + }); + + bootApplication(); + + // Attempted transitions out of index should abort. + _emberMetal.run(router, 'handleURL', '/nork'); + _emberMetal.run(router, 'handleURL', '/about'); + }); + + QUnit.test('Aborting/redirecting the transition in `willTransition` prevents LoadingRoute from being entered', function () { + expect(8); + + Router.map(function () { + this.route('nork'); + this.route('about'); + }); + + var redirect = false; + + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + willTransition: function (transition) { + ok(true, 'willTransition was called'); + if (redirect) { + // router.js won't refire `willTransition` for this redirect + this.transitionTo('about'); + } else { + transition.abort(); + } + } + } + }); + + var deferred = null; + + App.LoadingRoute = _emberRouting.Route.extend({ + activate: function () { + ok(deferred, 'LoadingRoute should be entered at this time'); + }, + deactivate: function () { + ok(true, 'LoadingRoute was exited'); + } + }); + + App.NorkRoute = _emberRouting.Route.extend({ + activate: function () { + ok(true, 'NorkRoute was entered'); + } + }); + + App.AboutRoute = _emberRouting.Route.extend({ + activate: function () { + ok(true, 'AboutRoute was entered'); + }, + model: function () { + if (deferred) { + return deferred.promise; + } + } + }); + + bootApplication(); + + // Attempted transitions out of index should abort. + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(router, 'handleURL', '/nork'); + + // Attempted transitions out of index should redirect to about + redirect = true; + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(router, 'transitionTo', 'index'); + + // Redirected transitions out of index to a route with a + // promise model should pause the transition and + // activate LoadingRoute + deferred = _emberRuntime.RSVP.defer(); + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(deferred.resolve); + }); + + QUnit.test('`didTransition` event fires on the router', function () { + expect(3); + + Router.map(function () { + this.route('nork'); + }); + + router = container.lookup('router:main'); + + router.one('didTransition', function () { + ok(true, 'didTransition fired on initial routing'); + }); + + bootApplication(); + + router.one('didTransition', function () { + ok(true, 'didTransition fired on the router'); + equal(router.get('url'), '/nork', 'The url property is updated by the time didTransition fires'); + }); + + _emberMetal.run(router, 'transitionTo', 'nork'); + }); + QUnit.test('`didTransition` can be reopened', function () { + expect(1); + + Router.map(function () { + this.route('nork'); + }); + + Router.reopen({ + didTransition: function () { + this._super.apply(this, arguments); + ok(true, 'reopened didTransition was called'); + } + }); + + bootApplication(); + }); + + QUnit.test('`activate` event fires on the route', function () { + expect(2); + + var eventFired = 0; + + Router.map(function () { + this.route('nork'); + }); + + App.NorkRoute = _emberRouting.Route.extend({ + init: function () { + this._super.apply(this, arguments); + + this.on('activate', function () { + equal(++eventFired, 1, 'activate event is fired once'); + }); + }, + + activate: function () { + ok(true, 'activate hook is called'); + } + }); + + bootApplication(); + + _emberMetal.run(router, 'transitionTo', 'nork'); + }); + + QUnit.test('`deactivate` event fires on the route', function () { + expect(2); + + var eventFired = 0; + + Router.map(function () { + this.route('nork'); + this.route('dork'); + }); + + App.NorkRoute = _emberRouting.Route.extend({ + init: function () { + this._super.apply(this, arguments); + + this.on('deactivate', function () { + equal(++eventFired, 1, 'deactivate event is fired once'); + }); + }, + + deactivate: function () { + ok(true, 'deactivate hook is called'); + } + }); + + bootApplication(); + + _emberMetal.run(router, 'transitionTo', 'nork'); + _emberMetal.run(router, 'transitionTo', 'dork'); + }); + + QUnit.test('Actions can be handled by inherited action handlers', function () { + expect(4); + + App.SuperRoute = _emberRouting.Route.extend({ + actions: { + foo: function () { + ok(true, 'foo'); + }, + bar: function (msg) { + equal(msg, 'HELLO'); + } + } + }); + + App.RouteMixin = _emberMetal.Mixin.create({ + actions: { + bar: function (msg) { + equal(msg, 'HELLO'); + this._super(msg); + } + } + }); + + App.IndexRoute = App.SuperRoute.extend(App.RouteMixin, { + actions: { + baz: function () { + ok(true, 'baz'); + } + } + }); + + bootApplication(); + + router.send('foo'); + router.send('bar', 'HELLO'); + router.send('baz'); + }); + + QUnit.test('transitionTo returns Transition when passed a route name', function () { + expect(1); + Router.map(function () { + this.route('root', { path: '/' }); + this.route('bar'); + }); + + bootApplication(); + + var transition = _emberMetal.run(function () { + return router.transitionTo('bar'); + }); + + equal(transition instanceof _router.Transition, true); + }); + + QUnit.test('transitionTo returns Transition when passed a url', function () { + expect(1); + Router.map(function () { + this.route('root', { path: '/' }); + this.route('bar', function () { + this.route('baz'); + }); + }); + + bootApplication(); + + var transition = _emberMetal.run(function () { + return router.transitionTo('/bar/baz'); + }); + + equal(transition instanceof _router.Transition, true); + }); + + QUnit.test('currentRouteName is a property installed on ApplicationController that can be used in transitionTo', function () { + expect(24); + + Router.map(function () { + this.route('be', function () { + this.route('excellent', { resetNamespace: true }, function () { + this.route('to', { resetNamespace: true }, function () { + this.route('each', { resetNamespace: true }, function () { + this.route('other'); + }); + }); + }); + }); + }); + + bootApplication(); + + var appController = _emberUtils.getOwner(router).lookup('controller:application'); + + function transitionAndCheck(path, expectedPath, expectedRouteName) { + if (path) { + _emberMetal.run(router, 'transitionTo', path); + } + equal(appController.get('currentPath'), expectedPath); + equal(appController.get('currentRouteName'), expectedRouteName); + } + + transitionAndCheck(null, 'index', 'index'); + transitionAndCheck('/be', 'be.index', 'be.index'); + transitionAndCheck('/be/excellent', 'be.excellent.index', 'excellent.index'); + transitionAndCheck('/be/excellent/to', 'be.excellent.to.index', 'to.index'); + transitionAndCheck('/be/excellent/to/each', 'be.excellent.to.each.index', 'each.index'); + transitionAndCheck('/be/excellent/to/each/other', 'be.excellent.to.each.other', 'each.other'); + + transitionAndCheck('index', 'index', 'index'); + transitionAndCheck('be', 'be.index', 'be.index'); + transitionAndCheck('excellent', 'be.excellent.index', 'excellent.index'); + transitionAndCheck('to.index', 'be.excellent.to.index', 'to.index'); + transitionAndCheck('each', 'be.excellent.to.each.index', 'each.index'); + transitionAndCheck('each.other', 'be.excellent.to.each.other', 'each.other'); + }); + + QUnit.test('Route model hook finds the same model as a manual find', function () { + var Post = undefined; + App.Post = _emberRuntime.Object.extend(); + App.Post.reopenClass({ + find: function () { + Post = this; + return {}; + } + }); + + Router.map(function () { + this.route('post', { path: '/post/:post_id' }); + }); + + bootApplication(); + + handleURL('/post/1'); + + equal(App.Post, Post); + }); + + QUnit.test('Routes can refresh themselves causing their model hooks to be re-run', function () { + Router.map(function () { + this.route('parent', { path: '/parent/:parent_id' }, function () { + this.route('child'); + }); + }); + + var appcount = 0; + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + ++appcount; + } + }); + + var parentcount = 0; + App.ParentRoute = _emberRouting.Route.extend({ + model: function (params) { + equal(params.parent_id, '123'); + ++parentcount; + }, + actions: { + refreshParent: function () { + this.refresh(); + } + } + }); + + var childcount = 0; + App.ParentChildRoute = _emberRouting.Route.extend({ + model: function () { + ++childcount; + } + }); + + bootApplication(); + + equal(appcount, 1); + equal(parentcount, 0); + equal(childcount, 0); + + _emberMetal.run(router, 'transitionTo', 'parent.child', '123'); + + equal(appcount, 1); + equal(parentcount, 1); + equal(childcount, 1); + + _emberMetal.run(router, 'send', 'refreshParent'); + + equal(appcount, 1); + equal(parentcount, 2); + equal(childcount, 2); + }); + + QUnit.test('Specifying non-existent controller name in route#render throws', function () { + expect(1); + + Router.map(function () { + this.route('home', { path: '/' }); + }); + + App.HomeRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + try { + this.render('homepage', { controller: 'stefanpenneristhemanforme' }); + } catch (e) { + equal(e.message, 'You passed `controller: \'stefanpenneristhemanforme\'` into the `render` method, but no such controller could be found.'); + } + } + }); + + bootApplication(); + }); + + QUnit.test('Redirecting with null model doesn\'t error out', function () { + Router.map(function () { + this.route('home', { path: '/' }); + this.route('about', { path: '/about/:hurhurhur' }); + }); + + App.AboutRoute = _emberRouting.Route.extend({ + serialize: function (model) { + if (model === null) { + return { hurhurhur: 'TreeklesMcGeekles' }; + } + } + }); + + App.HomeRoute = _emberRouting.Route.extend({ + beforeModel: function () { + this.transitionTo('about', null); + } + }); + + bootApplication(); + + equal(router.get('location.path'), '/about/TreeklesMcGeekles'); + }); + + QUnit.test('rejecting the model hooks promise with a non-error prints the `message` property', function () { + expect(5); + + var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; + var rejectedStack = 'Yeah, buddy: stack gets printed too.'; + + Router.map(function () { + this.route('yippie', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage, errorMessage, errorStack) { + equal(initialMessage, 'Error while processing route: yippie', 'a message with the current route name is printed'); + equal(errorMessage, rejectedMessage, 'the rejected reason\'s message property is logged'); + equal(errorStack, rejectedStack, 'the rejected reason\'s stack property is logged'); + }; + + App.YippieRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ message: rejectedMessage, stack: rejectedStack }); + } + }); + + throws(function () { + bootApplication(); + }, function (err) { + equal(err.message, rejectedMessage); + return true; + }, 'expected an exception'); + }); + + QUnit.test('rejecting the model hooks promise with an error with `errorThrown` property prints `errorThrown.message` property', function () { + expect(5); + var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; + var rejectedStack = 'Yeah, buddy: stack gets printed too.'; + + Router.map(function () { + this.route('yippie', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage, errorMessage, errorStack) { + equal(initialMessage, 'Error while processing route: yippie', 'a message with the current route name is printed'); + equal(errorMessage, rejectedMessage, 'the rejected reason\'s message property is logged'); + equal(errorStack, rejectedStack, 'the rejected reason\'s stack property is logged'); + }; + + App.YippieRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ + errorThrown: { message: rejectedMessage, stack: rejectedStack } + }); + } + }); + + throws(function () { + return bootApplication(); + }, function (err) { + equal(err.message, rejectedMessage); + return true; + }, 'expected an exception'); + }); + + QUnit.test('rejecting the model hooks promise with no reason still logs error', function () { + Router.map(function () { + this.route('wowzers', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage) { + equal(initialMessage, 'Error while processing route: wowzers', 'a message with the current route name is printed'); + }; + + App.WowzersRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(); + } + }); + + bootApplication(); + }); + + QUnit.test('rejecting the model hooks promise with a string shows a good error', function () { + expect(3); + var originalLoggerError = _emberConsole.default.error; + var rejectedMessage = 'Supercalifragilisticexpialidocious'; + + Router.map(function () { + this.route('yondo', { path: '/' }); + }); + + _emberConsole.default.error = function (initialMessage, errorMessage) { + equal(initialMessage, 'Error while processing route: yondo', 'a message with the current route name is printed'); + equal(errorMessage, rejectedMessage, 'the rejected reason\'s message property is logged'); + }; + + App.YondoRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject(rejectedMessage); + } + }); + + throws(function () { + return bootApplication(); + }, rejectedMessage, 'expected an exception'); + + _emberConsole.default.error = originalLoggerError; + }); + + QUnit.test('willLeave, willChangeContext, willChangeModel actions don\'t fire unless feature flag enabled', function () { + expect(1); + + App.Router.map(function () { + this.route('about'); + }); + + function shouldNotFire() { + ok(false, 'this action shouldn\'t have been received'); + } + + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + willChangeModel: shouldNotFire, + willChangeContext: shouldNotFire, + willLeave: shouldNotFire + } + }); + + App.AboutRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(true, 'about route was entered'); + } + }); + + bootApplication(); + _emberMetal.run(router, 'transitionTo', 'about'); + }); + + QUnit.test('Errors in transitionTo within redirect hook are logged', function () { + expect(4); + var actual = []; + + Router.map(function () { + this.route('yondo', { path: '/' }); + this.route('stink-bomb'); + }); + + App.YondoRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('stink-bomb', { something: 'goes boom' }); + } + }); + + _emberConsole.default.error = function () { + // push the arguments onto an array so we can detect if the error gets logged twice + actual.push(arguments); + }; + + throws(function () { + return bootApplication(); + }, /More context objects were passed/); + + equal(actual.length, 1, 'the error is only logged once'); + equal(actual[0][0], 'Error while processing route: yondo', 'source route is printed'); + ok(actual[0][1].match(/More context objects were passed than there are dynamic segments for the route: stink-bomb/), 'the error is printed'); + }); + + QUnit.test('Errors in transition show error template if available', function () { + _emberGlimmer.setTemplate('error', _emberTemplateCompiler.compile('
    Error!
    ')); + + Router.map(function () { + this.route('yondo', { path: '/' }); + this.route('stink-bomb'); + }); + + App.YondoRoute = _emberRouting.Route.extend({ + redirect: function () { + this.transitionTo('stink-bomb', { something: 'goes boom' }); + } + }); + + throws(function () { + return bootApplication(); + }, /More context objects were passed/); + + equal(_emberViews.jQuery('#error').length, 1, 'Error template was rendered.'); + }); + + QUnit.test('Route#resetController gets fired when changing models and exiting routes', function () { + expect(4); + + Router.map(function () { + this.route('a', function () { + this.route('b', { path: '/b/:id', resetNamespace: true }, function () {}); + this.route('c', { path: '/c/:id', resetNamespace: true }, function () {}); + }); + this.route('out'); + }); + + var calls = []; + + var SpyRoute = _emberRouting.Route.extend({ + setupController: function (controller, model, transition) { + calls.push(['setup', this.routeName]); + }, + + resetController: function (controller) { + calls.push(['reset', this.routeName]); + } + }); + + App.ARoute = SpyRoute.extend(); + App.BRoute = SpyRoute.extend(); + App.CRoute = SpyRoute.extend(); + App.OutRoute = SpyRoute.extend(); + + bootApplication(); + deepEqual(calls, []); + + _emberMetal.run(router, 'transitionTo', 'b', 'b-1'); + deepEqual(calls, [['setup', 'a'], ['setup', 'b']]); + calls.length = 0; + + _emberMetal.run(router, 'transitionTo', 'c', 'c-1'); + deepEqual(calls, [['reset', 'b'], ['setup', 'c']]); + calls.length = 0; + + _emberMetal.run(router, 'transitionTo', 'out'); + deepEqual(calls, [['reset', 'c'], ['reset', 'a'], ['setup', 'out']]); + }); + + QUnit.test('Exception during initialization of non-initial route is not swallowed', function () { + Router.map(function () { + this.route('boom'); + }); + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + bootApplication(); + throws(function () { + return _emberMetal.run(router, 'transitionTo', 'boom'); + }, /\bboom\b/); + }); + + QUnit.test('Exception during load of non-initial route is not swallowed', function () { + Router.map(function () { + this.route('boom'); + }); + var lookup = container.lookup; + container.lookup = function () { + if (arguments[0] === 'route:boom') { + throw new Error('boom!'); + } + return lookup.apply(this, arguments); + }; + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + bootApplication(); + throws(function () { + return _emberMetal.run(router, 'transitionTo', 'boom'); + }); + }); + + QUnit.test('Exception during initialization of initial route is not swallowed', function () { + Router.map(function () { + this.route('boom', { path: '/' }); + }); + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + throws(function () { + return bootApplication(); + }, /\bboom\b/); + }); + + QUnit.test('Exception during load of initial route is not swallowed', function () { + Router.map(function () { + this.route('boom', { path: '/' }); + }); + var lookup = container.lookup; + container.lookup = function () { + if (arguments[0] === 'route:boom') { + throw new Error('boom!'); + } + return lookup.apply(this, arguments); + }; + App.BoomRoute = _emberRouting.Route.extend({ + init: function () { + throw new Error('boom!'); + } + }); + throws(function () { + return bootApplication(); + }, /\bboom\b/); + }); + + QUnit.test('{{outlet}} works when created after initial render', function () { + _emberGlimmer.setTemplate('sample', _emberTemplateCompiler.compile('Hi{{#if showTheThing}}{{outlet}}{{/if}}Bye')); + _emberGlimmer.setTemplate('sample/inner', _emberTemplateCompiler.compile('Yay')); + _emberGlimmer.setTemplate('sample/inner2', _emberTemplateCompiler.compile('Boo')); + Router.map(function () { + this.route('sample', { path: '/' }, function () { + this.route('inner', { path: '/' }); + this.route('inner2', { path: '/2' }); + }); + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'HiBye', 'initial render'); + + _emberMetal.run(function () { + return container.lookup('controller:sample').set('showTheThing', true); + }); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'HiYayBye', 'second render'); + + handleURL('/2'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'HiBooBye', 'third render'); + }); + + QUnit.test('Can render into a named outlet at the top level', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('The index')); + + registry.register('route:application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('modal', { + into: 'application', + outlet: 'other' + }); + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B-Hello world-C', 'initial render'); + }); + + QUnit.test('Can disconnect a named outlet at the top level', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('The index')); + + registry.register('route:application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('modal', { + into: 'application', + outlet: 'other' + }); + }, + actions: { + banish: function () { + this.disconnectOutlet({ + parentView: 'application', + outlet: 'other' + }); + } + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B-Hello world-C', 'initial render'); + + _emberMetal.run(router, 'send', 'banish'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B--C', 'second render'); + }); + + QUnit.test('Can render into a named outlet at the top level, with empty main outlet', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + + Router.map(function () { + this.route('hasNoTemplate', { path: '/' }); + }); + + registry.register('route:application', _emberRouting.Route.extend({ + renderTemplate: function () { + this.render(); + this.render('modal', { + into: 'application', + outlet: 'other' + }); + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A--B-Hello world-C', 'initial render'); + }); + + QUnit.test('Can render into a named outlet at the top level, later', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('A-{{outlet}}-B-{{outlet "other"}}-C')); + _emberGlimmer.setTemplate('modal', _emberTemplateCompiler.compile('Hello world')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('The index')); + + registry.register('route:application', _emberRouting.Route.extend({ + actions: { + launch: function () { + this.render('modal', { + into: 'application', + outlet: 'other' + }); + } + } + })); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B--C', 'initial render'); + + _emberMetal.run(router, 'send', 'launch'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'A-The index-B-Hello world-C', 'second render'); + }); + + QUnit.test('Can render routes with no \'main\' outlet and their children', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{outlet "app"}}
    ')); + _emberGlimmer.setTemplate('app', _emberTemplateCompiler.compile('
    {{outlet "common"}}
    {{outlet "sub"}}
    ')); + _emberGlimmer.setTemplate('common', _emberTemplateCompiler.compile('
    ')); + _emberGlimmer.setTemplate('sub', _emberTemplateCompiler.compile('
    ')); + + Router.map(function () { + this.route('app', { path: '/app' }, function () { + this.route('sub', { path: '/sub', resetNamespace: true }); + }); + }); + + App.AppRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('app', { + outlet: 'app', + into: 'application' + }); + this.render('common', { + outlet: 'common', + into: 'app' + }); + } + }); + + App.SubRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('sub', { + outlet: 'sub', + into: 'app' + }); + } + }); + + bootApplication(); + handleURL('/app'); + equal(_emberViews.jQuery('#app-common #common').length, 1, 'Finds common while viewing /app'); + handleURL('/app/sub'); + equal(_emberViews.jQuery('#app-common #common').length, 1, 'Finds common while viewing /app/sub'); + equal(_emberViews.jQuery('#app-sub #sub').length, 1, 'Finds sub while viewing /app/sub'); + }); + + QUnit.test('Tolerates stacked renders', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet "modal"}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('hi')); + _emberGlimmer.setTemplate('layer', _emberTemplateCompiler.compile('layer')); + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + openLayer: function () { + this.render('layer', { + into: 'application', + outlet: 'modal' + }); + }, + close: function () { + this.disconnectOutlet({ + outlet: 'modal', + parentView: 'application' + }); + } + } + }); + bootApplication(); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + _emberMetal.run(router, 'send', 'openLayer'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hilayer'); + _emberMetal.run(router, 'send', 'openLayer'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hilayer'); + _emberMetal.run(router, 'send', 'close'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + }); + + QUnit.test('Renders child into parent with non-default template name', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('exports/root', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('exports/index', _emberTemplateCompiler.compile('
    ')); + + Router.map(function () { + this.route('root', function () {}); + }); + + App.RootRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('exports/root'); + } + }); + + App.RootIndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render('exports/index'); + } + }); + + bootApplication(); + handleURL('/root'); + equal(_emberViews.jQuery('#qunit-fixture .a .b .c').length, 1); + }); + + QUnit.test('Allows any route to disconnectOutlet another route\'s templates', function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}{{outlet "modal"}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('hi')); + _emberGlimmer.setTemplate('layer', _emberTemplateCompiler.compile('layer')); + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + openLayer: function () { + this.render('layer', { + into: 'application', + outlet: 'modal' + }); + } + } + }); + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + close: function () { + this.disconnectOutlet({ + parentView: 'application', + outlet: 'modal' + }); + } + } + }); + bootApplication(); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + _emberMetal.run(router, 'send', 'openLayer'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hilayer'); + _emberMetal.run(router, 'send', 'close'); + equal(trim(_emberViews.jQuery('#qunit-fixture').text()), 'hi'); + }); + + QUnit.test('Can this.render({into:...}) the render helper', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + _emberGlimmer.setTemplate('bar', _emberTemplateCompiler.compile('bar')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + }, + actions: { + changeToBar: function () { + this.disconnectOutlet({ + parentView: 'sidebar', + outlet: 'main' + }); + this.render('bar', { into: 'sidebar' }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), 'other'); + _emberMetal.run(router, 'send', 'changeToBar'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), 'bar'); + }); + + QUnit.test('Can disconnect from the render helper', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + }, + actions: { + disconnect: function () { + this.disconnectOutlet({ + parentView: 'sidebar', + outlet: 'main' + }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), 'other'); + _emberMetal.run(router, 'send', 'disconnect'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar').text(), ''); + }); + + QUnit.test('Can this.render({into:...}) the render helper\'s children', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('other', _emberTemplateCompiler.compile('other')); + _emberGlimmer.setTemplate('bar', _emberTemplateCompiler.compile('bar')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + this.render('other', { into: 'index' }); + }, + actions: { + changeToBar: function () { + this.disconnectOutlet({ + parentView: 'index', + outlet: 'main' + }); + this.render('bar', { into: 'index' }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), 'other'); + _emberMetal.run(router, 'send', 'changeToBar'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), 'bar'); + }); + + QUnit.test('Can disconnect from the render helper\'s children', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('other', _emberTemplateCompiler.compile('other')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'sidebar' }); + this.render('other', { into: 'index' }); + }, + actions: { + disconnect: function () { + this.disconnectOutlet({ + parentView: 'index', + outlet: 'main' + }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), 'other'); + _emberMetal.run(router, 'send', 'disconnect'); + equal(_emberViews.jQuery('#qunit-fixture .sidebar .index').text(), ''); + }); + + QUnit.test('Can this.render({into:...}) nested render helpers', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('cart', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + _emberGlimmer.setTemplate('baz', _emberTemplateCompiler.compile('baz')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'cart' }); + }, + actions: { + changeToBaz: function () { + this.disconnectOutlet({ + parentView: 'cart', + outlet: 'main' + }); + this.render('baz', { into: 'cart' }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), 'other'); + _emberMetal.run(router, 'send', 'changeToBaz'); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), 'baz'); + }); + + QUnit.test('Can disconnect from nested render helpers', function () { + expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{render "sidebar"}}')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + expectDeprecation(function () { + _emberGlimmer.setTemplate('sidebar', _emberTemplateCompiler.compile('')); + }, /Please refactor [\w\{\}"` ]+ to a component/); + + _emberGlimmer.setTemplate('cart', _emberTemplateCompiler.compile('
    {{outlet}}
    ')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('other')); + + App.IndexRoute = _emberRouting.Route.extend({ + renderTemplate: function () { + this.render({ into: 'cart' }); + }, + actions: { + disconnect: function () { + this.disconnectOutlet({ + parentView: 'cart', + outlet: 'main' + }); + } + } + }); + + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), 'other'); + _emberMetal.run(router, 'send', 'disconnect'); + equal(_emberViews.jQuery('#qunit-fixture .cart').text(), ''); + }); + + QUnit.test('Components inside an outlet have their didInsertElement hook invoked when the route is displayed', function (assert) { + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('{{#if showFirst}}{{my-component}}{{else}}{{other-component}}{{/if}}')); + + var myComponentCounter = 0; + var otherComponentCounter = 0; + var indexController = undefined; + + App.IndexController = _emberRuntime.Controller.extend({ + showFirst: true + }); + + App.IndexRoute = _emberRouting.Route.extend({ + setupController: function (controller) { + indexController = controller; + } + }); + + App.MyComponentComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + myComponentCounter++; + } + }); + + App.OtherComponentComponent = _emberGlimmer.Component.extend({ + didInsertElement: function () { + otherComponentCounter++; + } + }); + + bootApplication(); + + assert.strictEqual(myComponentCounter, 1, 'didInsertElement invoked on displayed component'); + assert.strictEqual(otherComponentCounter, 0, 'didInsertElement not invoked on displayed component'); + + _emberMetal.run(function () { + return indexController.set('showFirst', false); + }); + + assert.strictEqual(myComponentCounter, 1, 'didInsertElement not invoked on displayed component'); + assert.strictEqual(otherComponentCounter, 1, 'didInsertElement invoked on displayed component'); + }); + + QUnit.test('Doesnt swallow exception thrown from willTransition', function () { + expect(1); + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('index')); + _emberGlimmer.setTemplate('other', _emberTemplateCompiler.compile('other')); + + Router.map(function () { + this.route('other', function () {}); + }); + + App.IndexRoute = _emberRouting.Route.extend({ + actions: { + willTransition: function () { + throw new Error('boom'); + } + } + }); + + bootApplication(); + + throws(function () { + _emberMetal.run(function () { + return router.handleURL('/other'); + }); + }, /boom/, 'expected an exception that didnt happen'); + }); + + QUnit.test('Exception if outlet name is undefined in render and disconnectOutlet', function (assert) { + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + showModal: function () { + this.render({ + outlet: undefined, + parentView: 'application' + }); + }, + hideModal: function () { + this.disconnectOutlet({ + outlet: undefined, + parentView: 'application' + }); + } + } + }); + + bootApplication(); + + throws(function () { + _emberMetal.run(function () { + return router.send('showModal'); + }); + }, /You passed undefined as the outlet name/); + + throws(function () { + _emberMetal.run(function () { + return router.send('hideModal'); + }); + }, /You passed undefined as the outlet name/); + }); + + QUnit.test('Route serializers work for Engines', function () { + expect(2); + + // Register engine + var BlogEngine = _emberApplication.Engine.extend(); + registry.register('engine:blog', BlogEngine); + + // Register engine route map + var postSerialize = function (params) { + ok(true, 'serialize hook runs'); + return { + post_id: params.id + }; + }; + var BlogMap = function () { + this.route('post', { path: '/post/:post_id', serialize: postSerialize }); + }; + registry.register('route-map:blog', BlogMap); + + Router.map(function () { + this.mount('blog'); + }); + + bootApplication(); + + equal(router.router.generate('blog.post', { id: '13' }), '/blog/post/13', 'url is generated properly'); + }); + + QUnit.test('Defining a Route#serialize method in an Engine throws an error', function () { + expect(1); + + // Register engine + var BlogEngine = _emberApplication.Engine.extend(); + registry.register('engine:blog', BlogEngine); + + // Register engine route map + var BlogMap = function () { + this.route('post'); + }; + registry.register('route-map:blog', BlogMap); + + Router.map(function () { + this.mount('blog'); + }); + + bootApplication(); + + var PostRoute = _emberRouting.Route.extend({ serialize: function () {} }); + container.lookup('engine:blog').register('route:post', PostRoute); + + throws(function () { + return router.transitionTo('blog.post'); + }, /Defining a custom serialize method on an Engine route is not supported/); + }); + + QUnit.test('App.destroy does not leave undestroyed views after clearing engines', function () { + expect(4); + + var engineInstance = undefined; + // Register engine + var BlogEngine = _emberApplication.Engine.extend(); + registry.register('engine:blog', BlogEngine); + var EngineIndexRoute = _emberRouting.Route.extend({ + init: function () { + this._super.apply(this, arguments); + engineInstance = _emberUtils.getOwner(this); + } + }); + + // Register engine route map + var BlogMap = function () { + this.route('post'); + }; + registry.register('route-map:blog', BlogMap); + + Router.map(function () { + this.mount('blog'); + }); + + bootApplication(); + + var engine = container.lookup('engine:blog'); + engine.register('route:index', EngineIndexRoute); + engine.register('template:index', _emberTemplateCompiler.compile('Engine Post!')); + + handleURL('/blog'); + + var route = engineInstance.lookup('route:index'); + + _emberMetal.run(router, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was cleared'); + + _emberMetal.run(route, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + + _emberMetal.run(App, 'destroy'); + equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); + }); +}); +enifed('ember/tests/routing/basic_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/basic_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/basic_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test', ['exports', 'ember-runtime', 'ember-metal', 'ember-routing', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _emberMetal, _emberRouting, _emberViews, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - main', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.refreshModelWhileLoadingTest = function refreshModelWhileLoadingTest(loadingReturn) { + var _actions, + _this = this; + + var assert = this.assert; + + assert.expect(9); + + var appModelCount = 0; + var promiseResolve = undefined; + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + appomg: { + defaultValue: 'applol' + } + }, + model: function (params) { + appModelCount++; + } + })); + + this.setSingleQPController('index', 'omg', undefined, { + omg: undefined + }); + + var actionName = typeof loadingReturn !== 'undefined' ? 'loading' : 'ignore'; + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + actions: (_actions = {}, _actions[actionName] = function () { + return loadingReturn; + }, _actions), + model: function (params) { + indexModelCount++; + if (indexModelCount === 2) { + assert.deepEqual(params, { omg: 'lex' }); + return new _emberRuntime.RSVP.Promise(function (resolve) { + promiseResolve = resolve; + return; + }); + } else if (indexModelCount === 3) { + assert.deepEqual(params, { omg: 'hello' }, 'Model hook reruns even if the previous one didnt finish'); + } + } + })); + + return this.visit('/').then(function () { + assert.equal(appModelCount, 1, 'appModelCount is 1'); + assert.equal(indexModelCount, 1); + + var indexController = _this.getController('index'); + _this.setAndFlush(indexController, 'omg', 'lex'); + + assert.equal(appModelCount, 1, 'appModelCount is 1'); + assert.equal(indexModelCount, 2); + + _this.setAndFlush(indexController, 'omg', 'hello'); + assert.equal(appModelCount, 1, 'appModelCount is 1'); + assert.equal(indexModelCount, 3); + + _emberMetal.run(function () { + promiseResolve(); + }); + + assert.equal(_emberMetal.get(indexController, 'omg'), 'hello', 'At the end last value prevails'); + }); + }; + + _class.prototype['@test No replaceURL occurs on startup because default values don\'t show up in URL'] = function testNoReplaceURLOccursOnStartupBecauseDefaultValuesDonTShowUpInURL(assert) { + assert.expect(1); + + this.setSingleQPController('index'); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test Calling transitionTo does not lose query params already on the activeTransition'] = function testCallingTransitionToDoesNotLoseQueryParamsAlreadyOnTheActiveTransition(assert) { + var _this2 = this; + + assert.expect(2); + + this.router.map(function () { + this.route('parent', function () { + this.route('child'); + this.route('sibling'); + }); + }); + + this.registerRoute('parent.child', _emberRouting.Route.extend({ + afterModel: function () { + this.transitionTo('parent.sibling'); + } + })); + + this.setSingleQPController('parent'); + + return this.visit('/parent/child?foo=lol').then(function () { + _this2.assertCurrentPath('/parent/sibling?foo=lol', 'redirected to the sibling route, instead of child route'); + assert.equal(_this2.getController('parent').get('foo'), 'lol', 'controller has value from the active transition'); + }); + }; + + _class.prototype['@test Single query params can be set on the controller and reflected in the url'] = function testSingleQueryParamsCanBeSetOnTheControllerAndReflectedInTheUrl(assert) { + var _this3 = this; + + assert.expect(3); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + this.setSingleQPController('home'); + + return this.visitAndAssert('/').then(function () { + var controller = _this3.getController('home'); + + _this3.setAndFlush(controller, 'foo', '456'); + _this3.assertCurrentPath('/?foo=456'); + + _this3.setAndFlush(controller, 'foo', '987'); + _this3.assertCurrentPath('/?foo=987'); + }); + }; + + _class.prototype['@test Query params can map to different url keys configured on the controller'] = function testQueryParamsCanMapToDifferentUrlKeysConfiguredOnTheController(assert) { + var _this4 = this; + + assert.expect(6); + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: [{ foo: 'other_foo', bar: { as: 'other_bar' } }], + foo: 'FOO', + bar: 'BAR' + })); + + return this.visitAndAssert('/').then(function () { + var controller = _this4.getController('index'); + + _this4.setAndFlush(controller, 'foo', 'LEX'); + _this4.assertCurrentPath('/?other_foo=LEX', 'QP mapped correctly without \'as\''); + + _this4.setAndFlush(controller, 'foo', 'WOO'); + _this4.assertCurrentPath('/?other_foo=WOO', 'QP updated correctly without \'as\''); + + _this4.transitionTo('/?other_foo=NAW'); + assert.equal(controller.get('foo'), 'NAW', 'QP managed correctly on URL transition'); + + _this4.setAndFlush(controller, 'bar', 'NERK'); + _this4.assertCurrentPath('/?other_bar=NERK&other_foo=NAW', 'QP mapped correctly with \'as\''); + + _this4.setAndFlush(controller, 'bar', 'NUKE'); + _this4.assertCurrentPath('/?other_bar=NUKE&other_foo=NAW', 'QP updated correctly with \'as\''); + }); + }; + + _class.prototype['@test Routes have a private overridable serializeQueryParamKey hook'] = function testRoutesHaveAPrivateOverridableSerializeQueryParamKeyHook(assert) { + var _this5 = this; + + assert.expect(2); + + this.registerRoute('index', _emberRouting.Route.extend({ + serializeQueryParamKey: _emberRuntime.String.dasherize + })); + + this.setSingleQPController('index', 'funTimes', ''); + + return this.visitAndAssert('/').then(function () { + var controller = _this5.getController('index'); + + _this5.setAndFlush(controller, 'funTimes', 'woot'); + _this5.assertCurrentPath('/?fun-times=woot'); + }); + }; + + _class.prototype['@test Can override inherited QP behavior by specifying queryParams as a computed property'] = function testCanOverrideInheritedQPBehaviorBySpecifyingQueryParamsAsAComputedProperty(assert) { + var _this6 = this; + + assert.expect(3); + + this.setSingleQPController('index', 'a', 0, { + queryParams: _emberMetal.computed(function () { + return ['c']; + }), + c: true + }); + + return this.visitAndAssert('/').then(function () { + var indexController = _this6.getController('index'); + + _this6.setAndFlush(indexController, 'a', 1); + _this6.assertCurrentPath('/', 'QP did not update due to being overriden'); + + _this6.setAndFlush(indexController, 'c', false); + _this6.assertCurrentPath('/?c=false', 'QP updated with overriden param'); + }); + }; + + _class.prototype['@test Can concatenate inherited QP behavior by specifying queryParams as an array'] = function testCanConcatenateInheritedQPBehaviorBySpecifyingQueryParamsAsAnArray(assert) { + var _this7 = this; + + assert.expect(3); + + this.setSingleQPController('index', 'a', 0, { + queryParams: ['c'], + c: true + }); + + return this.visitAndAssert('/').then(function () { + var indexController = _this7.getController('index'); + + _this7.setAndFlush(indexController, 'a', 1); + _this7.assertCurrentPath('/?a=1', 'Inherited QP did update'); + + _this7.setAndFlush(indexController, 'c', false); + _this7.assertCurrentPath('/?a=1&c=false', 'New QP did update'); + }); + }; + + _class.prototype['@test model hooks receives query params'] = function testModelHooksReceivesQueryParams(assert) { + assert.expect(2); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: 'bar' }); + } + })); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test model hooks receives query params with dynamic segment params'] = function testModelHooksReceivesQueryParamsWithDynamicSegmentParams(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:id' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: 'bar', id: 'baz' }); + } + })); + + return this.visitAndAssert('/baz'); + }; + + _class.prototype['@test model hooks receives query params (overridden by incoming url value)'] = function testModelHooksReceivesQueryParamsOverriddenByIncomingUrlValue(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:id' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: 'baz', id: 'boo' }); + } + })); + + return this.visitAndAssert('/boo?foo=baz'); + }; + + _class.prototype['@test error is thrown if dynamic segment and query param have same name'] = function testErrorIsThrownIfDynamicSegmentAndQueryParamHaveSameName(assert) { + var _this8 = this; + + assert.expect(1); + + this.router.map(function () { + this.route('index', { path: '/:foo' }); + }); + + this.setSingleQPController('index'); + + expectAssertion(function () { + _this8.visitAndAssert('/boo?foo=baz'); + }, 'The route \'index\' has both a dynamic segment and query param with name \'foo\'. Please rename one to avoid collisions.'); + }; + + _class.prototype['@test controllers won\'t be eagerly instantiated by internal query params logic'] = function testControllersWonTBeEagerlyInstantiatedByInternalQueryParamsLogic(assert) { + var _this9 = this; + + assert.expect(10); + + this.router.map(function () { + this.route('cats', function () { + this.route('index', { path: '/' }); + }); + this.route('home', { path: '/' }); + this.route('about'); + }); + + this.registerTemplate('home', '

    {{link-to \'About\' \'about\' (query-params lol=\'wat\') id=\'link-to-about\'}}

    '); + this.registerTemplate('about', '

    {{link-to \'Home\' \'home\' (query-params foo=\'naw\')}}

    '); + this.registerTemplate('cats.index', '

    {{link-to \'Cats\' \'cats\' (query-params name=\'domino\') id=\'cats-link\'}}

    '); + + var homeShouldBeCreated = false; + var aboutShouldBeCreated = false; + var catsIndexShouldBeCreated = false; + + this.registerRoute('home', _emberRouting.Route.extend({ + setup: function () { + homeShouldBeCreated = true; + this._super.apply(this, arguments); + } + })); + + this.setSingleQPController('home', 'foo', '123', { + init: function () { + this._super.apply(this, arguments); + assert.ok(homeShouldBeCreated, 'HomeController should be created at this time'); + } + }); + + this.registerRoute('about', _emberRouting.Route.extend({ + setup: function () { + aboutShouldBeCreated = true; + this._super.apply(this, arguments); + } + })); + + this.setSingleQPController('about', 'lol', 'haha', { + init: function () { + this._super.apply(this, arguments); + assert.ok(aboutShouldBeCreated, 'AboutController should be created at this time'); + } + }); + + this.registerRoute('cats.index', _emberRouting.Route.extend({ + model: function () { + return []; + }, + setup: function () { + catsIndexShouldBeCreated = true; + this._super.apply(this, arguments); + }, + setupController: function (controller, context) { + controller.set('model', context); + } + })); + + this.registerController('cats.index', _emberRuntime.Controller.extend({ + queryParams: ['breed', 'name'], + breed: 'Golden', + name: null, + init: function () { + this._super.apply(this, arguments); + assert.ok(catsIndexShouldBeCreated, 'CatsIndexController should be created at this time'); + } + })); + + return this.visitAndAssert('/').then(function () { + var controller = _this9.getController('home'); + + _this9.setAndFlush(controller, 'foo', '456'); + _this9.assertCurrentPath('/?foo=456'); + assert.equal(_emberViews.jQuery('#link-to-about').attr('href'), '/about?lol=wat', 'link to about is correct'); + + _this9.transitionTo('about'); + _this9.assertCurrentPath('/about'); + + _this9.transitionTo('cats'); + _this9.assertCurrentPath('/cats'); + assert.equal(_emberViews.jQuery('#cats-link').attr('href'), '/cats?name=domino', 'link to cats is correct'); + + _emberMetal.run(_emberViews.jQuery('#cats-link'), 'click'); + _this9.assertCurrentPath('/cats?name=domino'); + }); + }; + + _class.prototype['@test query params have been set by the time setupController is called'] = function testQueryParamsHaveBeenSetByTheTimeSetupControllerIsCalled(assert) { + assert.expect(2); + + this.setSingleQPController('application'); + + this.registerRoute('application', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.equal(controller.get('foo'), 'YEAH', 'controller\'s foo QP property set before setupController called'); + } + })); + + return this.visitAndAssert('/?foo=YEAH'); + }; + + _class.prototype['@test mapped query params have been set by the time setupController is called'] = function testMappedQueryParamsHaveBeenSetByTheTimeSetupControllerIsCalled(assert) { + assert.expect(2); + + this.setSingleQPController('application', { faz: 'foo' }); + + this.registerRoute('application', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.equal(controller.get('faz'), 'YEAH', 'controller\'s foo QP property set before setupController called'); + } + })); + + return this.visitAndAssert('/?foo=YEAH'); + }; + + _class.prototype['@test Route#paramsFor fetches query params with default value'] = function testRouteParamsForFetchesQueryParamsWithDefaultValue(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'bar' }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz'); + }; + + _class.prototype['@test Route#paramsFor fetches query params with non-default value'] = function testRouteParamsForFetchesQueryParamsWithNonDefaultValue(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index'); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'boo' }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz?foo=boo'); + }; + + _class.prototype['@test Route#paramsFor fetches default falsy query params'] = function testRouteParamsForFetchesDefaultFalsyQueryParams(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index', 'foo', false); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz'); + }; + + _class.prototype['@test Route#paramsFor fetches non-default falsy query params'] = function testRouteParamsForFetchesNonDefaultFalsyQueryParams(assert) { + assert.expect(2); + + this.router.map(function () { + this.route('index', { path: '/:something' }); + }); + + this.setSingleQPController('index', 'foo', true); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params, transition) { + assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index'); + } + })); + + return this.visitAndAssert('/baz?foo=false'); + }; + + _class.prototype['@test model hook can query prefix-less application params'] = function testModelHookCanQueryPrefixLessApplicationParams(assert) { + assert.expect(4); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { appomg: 'applol' }); + } + })); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { omg: 'lol' }); + assert.deepEqual(this.paramsFor('application'), { appomg: 'applol' }); + } + })); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test model hook can query prefix-less application params (overridden by incoming url value)'] = function testModelHookCanQueryPrefixLessApplicationParamsOverriddenByIncomingUrlValue(assert) { + assert.expect(4); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { appomg: 'appyes' }); + } + })); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { omg: 'yes' }); + assert.deepEqual(this.paramsFor('application'), { appomg: 'appyes' }); + } + })); + + return this.visitAndAssert('/?appomg=appyes&omg=yes'); + }; + + _class.prototype['@test can opt into full transition by setting refreshModel in route queryParams'] = function testCanOptIntoFullTransitionBySettingRefreshModelInRouteQueryParams(assert) { + var _this10 = this; + + assert.expect(7); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + var appModelCount = 0; + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + appModelCount++; + } + })); + + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + model: function (params) { + indexModelCount++; + + if (indexModelCount === 1) { + assert.deepEqual(params, { omg: 'lol' }, 'params are correct on first pass'); + } else if (indexModelCount === 2) { + assert.deepEqual(params, { omg: 'lex' }, 'params are correct on second pass'); + } + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(appModelCount, 1, 'app model hook ran'); + assert.equal(indexModelCount, 1, 'index model hook ran'); + + var indexController = _this10.getController('index'); + _this10.setAndFlush(indexController, 'omg', 'lex'); + + assert.equal(appModelCount, 1, 'app model hook did not run again'); + assert.equal(indexModelCount, 2, 'index model hook ran again due to refreshModel'); + }); + }; + + _class.prototype['@test multiple QP value changes only cause a single model refresh'] = function testMultipleQPValueChangesOnlyCauseASingleModelRefresh(assert) { + var _this11 = this; + + assert.expect(2); + + this.setSingleQPController('index', 'alex', 'lol'); + this.setSingleQPController('index', 'steely', 'lel'); + + var refreshCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + alex: { + refreshModel: true + }, + steely: { + refreshModel: true + } + }, + refresh: function () { + refreshCount++; + } + })); + + return this.visitAndAssert('/').then(function () { + var indexController = _this11.getController('index'); + _emberMetal.run(indexController, 'setProperties', { alex: 'fran', steely: 'david' }); + assert.equal(refreshCount, 1, 'index refresh hook only run once'); + }); + }; + + _class.prototype['@test refreshModel does not cause a second transition during app boot '] = function testRefreshModelDoesNotCauseASecondTransitionDuringAppBoot(assert) { + assert.expect(1); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + refresh: function () { + assert.ok(false); + } + })); + + return this.visitAndAssert('/?appomg=hello&omg=world'); + }; + + _class.prototype['@test queryParams are updated when a controller property is set and the route is refreshed. Issue #13263 '] = function testQueryParamsAreUpdatedWhenAControllerPropertyIsSetAndTheRouteIsRefreshedIssue13263(assert) { + var _this12 = this; + + this.registerTemplate('application', '{{foo}}{{outlet}}'); + + this.setSingleQPController('application', 'foo', 1, { + actions: { + increment: function () { + this.incrementProperty('foo'); + this.send('refreshRoute'); + } + } + }); + + this.registerRoute('application', _emberRouting.Route.extend({ + actions: { + refreshRoute: function () { + this.refresh(); + } + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(_emberViews.jQuery('#test-value').text().trim(), '1'); + + _emberMetal.run(_emberViews.jQuery('#test-button'), 'click'); + assert.equal(_emberViews.jQuery('#test-value').text().trim(), '2'); + _this12.assertCurrentPath('/?foo=2'); + + _emberMetal.run(_emberViews.jQuery('#test-button'), 'click'); + assert.equal(_emberViews.jQuery('#test-value').text().trim(), '3'); + _this12.assertCurrentPath('/?foo=3'); + }); + }; + + _class.prototype['@test Use Ember.get to retrieve query params \'refreshModel\' configuration'] = function testUseEmberGetToRetrieveQueryParamsRefreshModelConfiguration(assert) { + var _this13 = this; + + assert.expect(7); + + this.setSingleQPController('application', 'appomg', 'applol'); + this.setSingleQPController('index', 'omg', 'lol'); + + var appModelCount = 0; + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (params) { + appModelCount++; + } + })); + + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: _emberRuntime.Object.create({ + unknownProperty: function (keyName) { + return { refreshModel: true }; + } + }), + model: function (params) { + indexModelCount++; + + if (indexModelCount === 1) { + assert.deepEqual(params, { omg: 'lol' }); + } else if (indexModelCount === 2) { + assert.deepEqual(params, { omg: 'lex' }); + } + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(appModelCount, 1); + assert.equal(indexModelCount, 1); + + var indexController = _this13.getController('index'); + _this13.setAndFlush(indexController, 'omg', 'lex'); + + assert.equal(appModelCount, 1); + assert.equal(indexModelCount, 2); + }); + }; + + _class.prototype['@test can use refreshModel even with URL changes that remove QPs from address bar'] = function testCanUseRefreshModelEvenWithURLChangesThatRemoveQPsFromAddressBar(assert) { + var _this14 = this; + + assert.expect(4); + + this.setSingleQPController('index', 'omg', 'lol'); + + var indexModelCount = 0; + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + omg: { + refreshModel: true + } + }, + model: function (params) { + indexModelCount++; + + var data = undefined; + if (indexModelCount === 1) { + data = 'foo'; + } else if (indexModelCount === 2) { + data = 'lol'; + } + + assert.deepEqual(params, { omg: data }, 'index#model receives right data'); + } + })); + + return this.visitAndAssert('/?omg=foo').then(function () { + _this14.transitionTo('/'); + + var indexController = _this14.getController('index'); + assert.equal(indexController.get('omg'), 'lol'); + }); + }; + + _class.prototype['@test can opt into a replace query by specifying replace:true in the Route config hash'] = function testCanOptIntoAReplaceQueryBySpecifyingReplaceTrueInTheRouteConfigHash(assert) { + var _this15 = this; + + assert.expect(2); + + this.setSingleQPController('application', 'alex', 'matchneer'); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + alex: { + replace: true + } + } + })); + + return this.visitAndAssert('/').then(function () { + var appController = _this15.getController('application'); + _this15.expectedReplaceURL = '/?alex=wallace'; + _this15.setAndFlush(appController, 'alex', 'wallace'); + }); + }; + + _class.prototype['@test Route query params config can be configured using property name instead of URL key'] = function testRouteQueryParamsConfigCanBeConfiguredUsingPropertyNameInsteadOfURLKey(assert) { + var _this16 = this; + + assert.expect(2); + + this.registerController('application', _emberRuntime.Controller.extend({ + queryParams: [{ commitBy: 'commit_by' }] + })); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + commitBy: { + replace: true + } + } + })); + + return this.visitAndAssert('/').then(function () { + var appController = _this16.getController('application'); + _this16.expectedReplaceURL = '/?commit_by=igor_seb'; + _this16.setAndFlush(appController, 'commitBy', 'igor_seb'); + }); + }; + + _class.prototype['@test An explicit replace:false on a changed QP always wins and causes a pushState'] = function testAnExplicitReplaceFalseOnAChangedQPAlwaysWinsAndCausesAPushState(assert) { + var _this17 = this; + + assert.expect(3); + + this.registerController('application', _emberRuntime.Controller.extend({ + queryParams: ['alex', 'steely'], + alex: 'matchneer', + steely: 'dan' + })); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: { + alex: { + replace: true + }, + steely: { + replace: false + } + } + })); + + return this.visit('/').then(function () { + var appController = _this17.getController('application'); + _this17.expectedPushURL = '/?alex=wallace&steely=jan'; + _emberMetal.run(appController, 'setProperties', { alex: 'wallace', steely: 'jan' }); + + _this17.expectedPushURL = '/?alex=wallace&steely=fran'; + _emberMetal.run(appController, 'setProperties', { steely: 'fran' }); + + _this17.expectedReplaceURL = '/?alex=sriracha&steely=fran'; + _emberMetal.run(appController, 'setProperties', { alex: 'sriracha' }); + }); + }; + + _class.prototype['@test can opt into full transition by setting refreshModel in route queryParams when transitioning from child to parent'] = function testCanOptIntoFullTransitionBySettingRefreshModelInRouteQueryParamsWhenTransitioningFromChildToParent(assert) { + this.registerTemplate('parent', '{{outlet}}'); + this.registerTemplate('parent.child', '{{link-to \'Parent\' \'parent\' (query-params foo=\'change\') id=\'parent-link\'}}'); + + this.router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + var parentModelCount = 0; + this.registerRoute('parent', _emberRouting.Route.extend({ + model: function () { + parentModelCount++; + }, + queryParams: { + foo: { + refreshModel: true + } + } + })); + + this.setSingleQPController('parent', 'foo', 'abc'); + + return this.visit('/parent/child?foo=lol').then(function () { + assert.equal(parentModelCount, 1); + + _emberMetal.run(_emberViews.jQuery('#parent-link'), 'click'); + assert.equal(parentModelCount, 2); + }); + }; + + _class.prototype['@test Use Ember.get to retrieve query params \'replace\' configuration'] = function testUseEmberGetToRetrieveQueryParamsReplaceConfiguration(assert) { + var _this18 = this; + + assert.expect(2); + + this.setSingleQPController('application', 'alex', 'matchneer'); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: _emberRuntime.Object.create({ + unknownProperty: function (keyName) { + // We are simulating all qps requiring refresh + return { replace: true }; + } + }) + })); + + return this.visitAndAssert('/').then(function () { + var appController = _this18.getController('application'); + _this18.expectedReplaceURL = '/?alex=wallace'; + _this18.setAndFlush(appController, 'alex', 'wallace'); + }); + }; + + _class.prototype['@test can override incoming QP values in setupController'] = function testCanOverrideIncomingQPValuesInSetupController(assert) { + var _this19 = this; + + assert.expect(3); + + this.router.map(function () { + this.route('about'); + }); + + this.setSingleQPController('index', 'omg', 'lol'); + + this.registerRoute('index', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.ok(true, 'setupController called'); + controller.set('omg', 'OVERRIDE'); + }, + actions: { + queryParamsDidChange: function () { + assert.ok(false, 'queryParamsDidChange shouldn\'t fire'); + } + } + })); + + return this.visitAndAssert('/about').then(function () { + _this19.transitionTo('index'); + _this19.assertCurrentPath('/?omg=OVERRIDE'); + }); + }; + + _class.prototype['@test can override incoming QP array values in setupController'] = function testCanOverrideIncomingQPArrayValuesInSetupController(assert) { + var _this20 = this; + + assert.expect(3); + + this.router.map(function () { + this.route('about'); + }); + + this.setSingleQPController('index', 'omg', ['lol']); + + this.registerRoute('index', _emberRouting.Route.extend({ + setupController: function (controller) { + assert.ok(true, 'setupController called'); + controller.set('omg', ['OVERRIDE']); + }, + actions: { + queryParamsDidChange: function () { + assert.ok(false, 'queryParamsDidChange shouldn\'t fire'); + } + } + })); + + return this.visitAndAssert('/about').then(function () { + _this20.transitionTo('index'); + _this20.assertCurrentPath('/?omg=' + encodeURIComponent(JSON.stringify(['OVERRIDE']))); + }); + }; + + _class.prototype['@test URL transitions that remove QPs still register as QP changes'] = function testURLTransitionsThatRemoveQPsStillRegisterAsQPChanges(assert) { + var _this21 = this; + + assert.expect(2); + + this.setSingleQPController('index', 'omg', 'lol'); + + return this.visit('/?omg=borf').then(function () { + var indexController = _this21.getController('index'); + assert.equal(indexController.get('omg'), 'borf'); + + _this21.transitionTo('/'); + assert.equal(indexController.get('omg'), 'lol'); + }); + }; + + _class.prototype['@test Subresource naming style is supported'] = function testSubresourceNamingStyleIsSupported(assert) { + var _this22 = this; + + assert.expect(5); + + this.router.map(function () { + this.route('abc.def', { path: '/abcdef' }, function () { + this.route('zoo'); + }); + }); + + this.registerTemplate('application', '{{link-to \'A\' \'abc.def\' (query-params foo=\'123\') id=\'one\'}}{{link-to \'B\' \'abc.def.zoo\' (query-params foo=\'123\' bar=\'456\') id=\'two\'}}{{outlet}}'); + + this.setSingleQPController('abc.def', 'foo', 'lol'); + this.setSingleQPController('abc.def.zoo', 'bar', 'haha'); + + return this.visitAndAssert('/').then(function () { + assert.equal(_emberViews.jQuery('#one').attr('href'), '/abcdef?foo=123'); + assert.equal(_emberViews.jQuery('#two').attr('href'), '/abcdef/zoo?bar=456&foo=123'); + + _emberMetal.run(_emberViews.jQuery('#one'), 'click'); + _this22.assertCurrentPath('/abcdef?foo=123'); + + _emberMetal.run(_emberViews.jQuery('#two'), 'click'); + _this22.assertCurrentPath('/abcdef/zoo?bar=456&foo=123'); + }); + }; + + _class.prototype['@test transitionTo supports query params'] = function testTransitionToSupportsQueryParams(assert) { + var _this23 = this; + + this.setSingleQPController('index', 'foo', 'lol'); + + return this.visitAndAssert('/').then(function () { + _this23.transitionTo({ queryParams: { foo: 'borf' } }); + _this23.assertCurrentPath('/?foo=borf', 'shorthand supported'); + + _this23.transitionTo({ queryParams: { 'index:foo': 'blaf' } }); + _this23.assertCurrentPath('/?foo=blaf', 'longform supported'); + + _this23.transitionTo({ queryParams: { 'index:foo': false } }); + _this23.assertCurrentPath('/?foo=false', 'longform supported (bool)'); + + _this23.transitionTo({ queryParams: { foo: false } }); + _this23.assertCurrentPath('/?foo=false', 'shorhand supported (bool)'); + }); + }; + + _class.prototype['@test transitionTo supports query params (multiple)'] = function testTransitionToSupportsQueryParamsMultiple(assert) { + var _this24 = this; + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: ['foo', 'bar'], + foo: 'lol', + bar: 'wat' + })); + + return this.visitAndAssert('/').then(function () { + _this24.transitionTo({ queryParams: { foo: 'borf' } }); + _this24.assertCurrentPath('/?foo=borf', 'shorthand supported'); + + _this24.transitionTo({ queryParams: { 'index:foo': 'blaf' } }); + _this24.assertCurrentPath('/?foo=blaf', 'longform supported'); + + _this24.transitionTo({ queryParams: { 'index:foo': false } }); + _this24.assertCurrentPath('/?foo=false', 'longform supported (bool)'); + + _this24.transitionTo({ queryParams: { foo: false } }); + _this24.assertCurrentPath('/?foo=false', 'shorhand supported (bool)'); + }); + }; + + _class.prototype['@test setting controller QP to empty string doesn\'t generate null in URL'] = function testSettingControllerQPToEmptyStringDoesnTGenerateNullInURL(assert) { + var _this25 = this; + + assert.expect(1); + + this.setSingleQPController('index', 'foo', '123'); + + return this.visit('/').then(function () { + var controller = _this25.getController('index'); + + _this25.expectedPushURL = '/?foo='; + _this25.setAndFlush(controller, 'foo', ''); + }); + }; + + _class.prototype['@test setting QP to empty string doesn\'t generate null in URL'] = function testSettingQPToEmptyStringDoesnTGenerateNullInURL(assert) { + var _this26 = this; + + assert.expect(1); + + this.registerRoute('index', _emberRouting.Route.extend({ + queryParams: { + foo: { + defaultValue: '123' + } + } + })); + + return this.visit('/').then(function () { + var controller = _this26.getController('index'); + + _this26.expectedPushURL = '/?foo='; + _this26.setAndFlush(controller, 'foo', ''); + }); + }; + + _class.prototype['@test A default boolean value deserializes QPs as booleans rather than strings'] = function testADefaultBooleanValueDeserializesQPsAsBooleansRatherThanStrings(assert) { + var _this27 = this; + + assert.expect(3); + + this.setSingleQPController('index', 'foo', false); + + this.registerRoute('index', _emberRouting.Route.extend({ + model: function (params) { + assert.equal(params.foo, true, 'model hook received foo as boolean true'); + } + })); + + return this.visit('/?foo=true').then(function () { + var controller = _this27.getController('index'); + assert.equal(controller.get('foo'), true); + + _this27.transitionTo('/?foo=false'); + assert.equal(controller.get('foo'), false); + }); + }; + + _class.prototype['@test Query param without value are empty string'] = function testQueryParamWithoutValueAreEmptyString(assert) { + var _this28 = this; + + assert.expect(1); + + this.registerController('index', _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: '' + })); + + return this.visit('/?foo=').then(function () { + var controller = _this28.getController('index'); + assert.equal(controller.get('foo'), ''); + }); + }; + + _class.prototype['@test Array query params can be set'] = function testArrayQueryParamsCanBeSet(assert) { + var _this29 = this; + + assert.expect(2); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + this.setSingleQPController('home', 'foo', []); + + return this.visit('/').then(function () { + var controller = _this29.getController('home'); + + _this29.setAndFlush(controller, 'foo', [1, 2]); + _this29.assertCurrentPath('/?foo=%5B1%2C2%5D'); + + _this29.setAndFlush(controller, 'foo', [3, 4]); + _this29.assertCurrentPath('/?foo=%5B3%2C4%5D'); + }); + }; + + _class.prototype['@test (de)serialization: arrays'] = function testDeSerializationArrays(assert) { + var _this30 = this; + + assert.expect(4); + + this.setSingleQPController('index', 'foo', [1]); + + return this.visitAndAssert('/').then(function () { + _this30.transitionTo({ queryParams: { foo: [2, 3] } }); + _this30.assertCurrentPath('/?foo=%5B2%2C3%5D', 'shorthand supported'); + _this30.transitionTo({ queryParams: { 'index:foo': [4, 5] } }); + _this30.assertCurrentPath('/?foo=%5B4%2C5%5D', 'longform supported'); + _this30.transitionTo({ queryParams: { foo: [] } }); + _this30.assertCurrentPath('/?foo=%5B%5D', 'longform supported'); + }); + }; + + _class.prototype['@test Url with array query param sets controller property to array'] = function testUrlWithArrayQueryParamSetsControllerPropertyToArray(assert) { + var _this31 = this; + + assert.expect(1); + + this.setSingleQPController('index', 'foo', ''); + + return this.visit('/?foo[]=1&foo[]=2&foo[]=3').then(function () { + var controller = _this31.getController('index'); + assert.deepEqual(controller.get('foo'), ['1', '2', '3']); + }); + }; + + _class.prototype['@test Array query params can be pushed/popped'] = function testArrayQueryParamsCanBePushedPopped(assert) { + var _this32 = this; + + assert.expect(17); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + this.setSingleQPController('home', 'foo', _emberRuntime.A()); + + return this.visitAndAssert('/').then(function () { + var controller = _this32.getController('home'); + + _emberMetal.run(controller.foo, 'pushObject', 1); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'popObject'); + _this32.assertCurrentPath('/'); + assert.deepEqual(controller.foo, []); + + _emberMetal.run(controller.foo, 'pushObject', 1); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'popObject'); + _this32.assertCurrentPath('/'); + assert.deepEqual(controller.foo, []); + + _emberMetal.run(controller.foo, 'pushObject', 1); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'pushObject', 2); + _this32.assertCurrentPath('/?foo=%5B1%2C2%5D'); + assert.deepEqual(controller.foo, [1, 2]); + + _emberMetal.run(controller.foo, 'popObject'); + _this32.assertCurrentPath('/?foo=%5B1%5D'); + assert.deepEqual(controller.foo, [1]); + + _emberMetal.run(controller.foo, 'unshiftObject', 'lol'); + _this32.assertCurrentPath('/?foo=%5B%22lol%22%2C1%5D'); + assert.deepEqual(controller.foo, ['lol', 1]); + }); + }; + + _class.prototype['@test Overwriting with array with same content shouldn\'t refire update'] = function testOverwritingWithArrayWithSameContentShouldnTRefireUpdate(assert) { + var _this33 = this; + + assert.expect(4); + + this.router.map(function () { + this.route('home', { path: '/' }); + }); + + var modelCount = 0; + this.registerRoute('home', _emberRouting.Route.extend({ + model: function () { + modelCount++; + } + })); + + this.setSingleQPController('home', 'foo', _emberRuntime.A([1])); + + return this.visitAndAssert('/').then(function () { + assert.equal(modelCount, 1); + + var controller = _this33.getController('home'); + _this33.setAndFlush(controller, 'model', _emberRuntime.A([1])); + + assert.equal(modelCount, 1); + _this33.assertCurrentPath('/'); + }); + }; + + _class.prototype['@test Defaulting to params hash as the model should not result in that params object being watched'] = function testDefaultingToParamsHashAsTheModelShouldNotResultInThatParamsObjectBeingWatched(assert) { + var _this34 = this; + + assert.expect(1); + + this.router.map(function () { + this.route('other'); + }); + + // This causes the params hash, which is returned as a route's + // model if no other model could be resolved given the provided + // params (and no custom model hook was defined), to be watched, + // unless we return a copy of the params hash. + this.setSingleQPController('application', 'woot', 'wat'); + + this.registerRoute('other', _emberRouting.Route.extend({ + model: function (p, trans) { + var m = _emberMetal.meta(trans.params.application); + assert.ok(!m.peekWatching('woot'), 'A meta object isn\'t constructed for this params POJO'); + } + })); + + return this.visit('/').then(function () { + _this34.transitionTo('other'); + }); + }; + + _class.prototype['@test A child of a resource route still defaults to parent route\'s model even if the child route has a query param'] = function testAChildOfAResourceRouteStillDefaultsToParentRouteSModelEvenIfTheChildRouteHasAQueryParam(assert) { + assert.expect(2); + + this.setSingleQPController('index', 'woot', undefined, { + woot: undefined + }); + + this.registerRoute('application', _emberRouting.Route.extend({ + model: function (p, trans) { + return { woot: true }; + } + })); + + this.registerRoute('index', _emberRouting.Route.extend({ + setupController: function (controller, model) { + assert.deepEqual(model, { woot: true }, 'index route inherited model route from parent route'); + } + })); + + return this.visitAndAssert('/'); + }; + + _class.prototype['@test opting into replace does not affect transitions between routes'] = function testOptingIntoReplaceDoesNotAffectTransitionsBetweenRoutes(assert) { + var _this35 = this; + + assert.expect(5); + + this.registerTemplate('application', '{{link-to \'Foo\' \'foo\' id=\'foo-link\'}}{{link-to \'Bar\' \'bar\' id=\'bar-no-qp-link\'}}{{link-to \'Bar\' \'bar\' (query-params raytiley=\'isthebest\') id=\'bar-link\'}}{{outlet}}'); + + this.router.map(function () { + this.route('foo'); + this.route('bar'); + }); + + this.setSingleQPController('bar', 'raytiley', 'israd'); + + this.registerRoute('bar', _emberRouting.Route.extend({ + queryParams: { + raytiley: { + replace: true + } + } + })); + + return this.visit('/').then(function () { + var controller = _this35.getController('bar'); + + _this35.expectedPushURL = '/foo'; + _emberMetal.run(_emberViews.jQuery('#foo-link'), 'click'); + + _this35.expectedPushURL = '/bar'; + _emberMetal.run(_emberViews.jQuery('#bar-no-qp-link'), 'click'); + + _this35.expectedReplaceURL = '/bar?raytiley=woot'; + _this35.setAndFlush(controller, 'raytiley', 'woot'); + + _this35.expectedPushURL = '/foo'; + _emberMetal.run(_emberViews.jQuery('#foo-link'), 'click'); + + _this35.expectedPushURL = '/bar?raytiley=isthebest'; + _emberMetal.run(_emberViews.jQuery('#bar-link'), 'click'); + }); + }; + + _class.prototype['@test undefined isn\'t serialized or deserialized into a string'] = function testUndefinedIsnTSerializedOrDeserializedIntoAString(assert) { + var _this36 = this; + + assert.expect(4); + + this.router.map(function () { + this.route('example'); + }); + + this.registerTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); + + this.setSingleQPController('example', 'foo', undefined, { + foo: undefined + }); + + this.registerRoute('example', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: undefined }); + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(_this36.$('#the-link').attr('href'), '/example', 'renders without undefined qp serialized'); + + return _this36.transitionTo('example', { queryParams: { foo: undefined } }).then(function () { + _this36.assertCurrentPath('/example'); + }); + }); + }; + + _class.prototype['@test when refreshModel is true and loading hook is undefined, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookIsUndefinedModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) { + return this.refreshModelWhileLoadingTest(); + }; + + _class.prototype['@test when refreshModel is true and loading hook returns false, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookReturnsFalseModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) { + return this.refreshModelWhileLoadingTest(false); + }; + + _class.prototype['@test when refreshModel is true and loading hook returns true, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookReturnsTrueModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) { + return this.refreshModelWhileLoadingTest(true); + }; + + _class.prototype['@test warn user that Route\'s queryParams configuration must be an Object, not an Array'] = function testWarnUserThatRouteSQueryParamsConfigurationMustBeAnObjectNotAnArray(assert) { + var _this37 = this; + + assert.expect(1); + + this.registerRoute('application', _emberRouting.Route.extend({ + queryParams: [{ commitBy: { replace: true } }] + })); + + expectAssertion(function () { + _this37.visit('/'); + }, 'You passed in `[{"commitBy":{"replace":true}}]` as the value for `queryParams` but `queryParams` cannot be an Array'); + }; + + _class.prototype['@test handle route names that clash with Object.prototype properties'] = function testHandleRouteNamesThatClashWithObjectPrototypeProperties(assert) { + var _this38 = this; + + assert.expect(1); + + this.router.map(function () { + this.route('constructor'); + }); + + this.registerRoute('constructor', _emberRouting.Route.extend({ + queryParams: { + foo: { + defaultValue: '123' + } + } + })); + + return this.visit('/').then(function () { + _this38.transitionTo('constructor', { queryParams: { foo: '999' } }); + var controller = _this38.getController('constructor'); + assert.equal(_emberMetal.get(controller, 'foo'), '999'); + }); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberViews, _internalTestHelpers) { + 'use strict'; + + var ModelDependentQPTestCase = (function (_QueryParamTestCase) { + babelHelpers.inherits(ModelDependentQPTestCase, _QueryParamTestCase); + + function ModelDependentQPTestCase() { + _QueryParamTestCase.apply(this, arguments); + } + + ModelDependentQPTestCase.prototype.boot = function boot() { + this.setupApplication(); + return this.visitApplication(); + }; + + ModelDependentQPTestCase.prototype.teardown = function teardown() { + var _QueryParamTestCase$prototype$teardown; + + (_QueryParamTestCase$prototype$teardown = _QueryParamTestCase.prototype.teardown).call.apply(_QueryParamTestCase$prototype$teardown, [this].concat(babelHelpers.slice.call(arguments))); + this.assert.ok(!this.expectedModelHookParams, 'there should be no pending expectation of expected model hook params'); + }; + + ModelDependentQPTestCase.prototype.reopenController = function reopenController(name, options) { + this.application.resolveRegistration('controller:' + name).reopen(options); + }; + + ModelDependentQPTestCase.prototype.reopenRoute = function reopenRoute(name, options) { + this.application.resolveRegistration('route:' + name).reopen(options); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest1 = function queryParamsStickyTest1(urlPrefix) { + var _this = this; + + var assert = this.assert; + + assert.expect(14); + + return this.boot().then(function () { + _emberMetal.run(_this.$link1, 'click'); + _this.assertCurrentPath(urlPrefix + '/a-1'); + + _this.setAndFlush(_this.controller, 'q', 'lol'); + + assert.equal(_this.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this.$link3.attr('href'), urlPrefix + '/a-3'); + + _emberMetal.run(_this.$link2, 'click'); + + assert.equal(_this.controller.get('q'), 'wat'); + assert.equal(_this.controller.get('z'), 0); + assert.deepEqual(_this.controller.get('model'), { id: 'a-2' }); + assert.equal(_this.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this.$link3.attr('href'), urlPrefix + '/a-3'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest2 = function queryParamsStickyTest2(urlPrefix) { + var _this2 = this; + + var assert = this.assert; + + assert.expect(24); + + return this.boot().then(function () { + _this2.expectedModelHookParams = { id: 'a-1', q: 'lol', z: 0 }; + _this2.transitionTo(urlPrefix + '/a-1?q=lol'); + + assert.deepEqual(_this2.controller.get('model'), { id: 'a-1' }); + assert.equal(_this2.controller.get('q'), 'lol'); + assert.equal(_this2.controller.get('z'), 0); + assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3'); + + _this2.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 }; + _this2.transitionTo(urlPrefix + '/a-2?q=lol'); + + assert.deepEqual(_this2.controller.get('model'), { id: 'a-2' }, 'controller\'s model changed to a-2'); + assert.equal(_this2.controller.get('q'), 'lol'); + assert.equal(_this2.controller.get('z'), 0); + assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); // fail + assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3'); + + _this2.expectedModelHookParams = { id: 'a-3', q: 'lol', z: 123 }; + _this2.transitionTo(urlPrefix + '/a-3?q=lol&z=123'); + + assert.equal(_this2.controller.get('q'), 'lol'); + assert.equal(_this2.controller.get('z'), 123); + assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3?q=lol&z=123'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest3 = function queryParamsStickyTest3(urlPrefix, articleLookup) { + var _this3 = this; + + var assert = this.assert; + + assert.expect(32); + + this.registerTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'' + articleLookup + '\' a.id id=a.id}} {{/each}}'); + + return this.boot().then(function () { + _this3.expectedModelHookParams = { id: 'a-1', q: 'wat', z: 0 }; + _this3.transitionTo(articleLookup, 'a-1'); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-1' }); + assert.equal(_this3.controller.get('q'), 'wat'); + assert.equal(_this3.controller.get('z'), 0); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3'); + + _this3.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 }; + _this3.transitionTo(articleLookup, 'a-2', { queryParams: { q: 'lol' } }); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-2' }); + assert.equal(_this3.controller.get('q'), 'lol'); + assert.equal(_this3.controller.get('z'), 0); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3'); + + _this3.expectedModelHookParams = { id: 'a-3', q: 'hay', z: 0 }; + _this3.transitionTo(articleLookup, 'a-3', { queryParams: { q: 'hay' } }); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-3' }); + assert.equal(_this3.controller.get('q'), 'hay'); + assert.equal(_this3.controller.get('z'), 0); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3?q=hay'); + + _this3.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 1 }; + _this3.transitionTo(articleLookup, 'a-2', { queryParams: { z: 1 } }); + + assert.deepEqual(_this3.controller.get('model'), { id: 'a-2' }); + assert.equal(_this3.controller.get('q'), 'lol'); + assert.equal(_this3.controller.get('z'), 1); + assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1'); + assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol&z=1'); + assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3?q=hay'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest4 = function queryParamsStickyTest4(urlPrefix, articleLookup) { + var _this4 = this; + + var assert = this.assert; + + assert.expect(24); + + this.setupApplication(); + + this.reopenController(articleLookup, { + queryParams: { q: { scope: 'controller' } } + }); + + return this.visitApplication().then(function () { + _emberMetal.run(_this4.$link1, 'click'); + _this4.assertCurrentPath(urlPrefix + '/a-1'); + + _this4.setAndFlush(_this4.controller, 'q', 'lol'); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=lol'); + + _emberMetal.run(_this4.$link2, 'click'); + + assert.equal(_this4.controller.get('q'), 'lol'); + assert.equal(_this4.controller.get('z'), 0); + assert.deepEqual(_this4.controller.get('model'), { id: 'a-2' }); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=lol'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=lol'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=lol'); + + _this4.expectedModelHookParams = { id: 'a-3', q: 'haha', z: 123 }; + _this4.transitionTo(urlPrefix + '/a-3?q=haha&z=123'); + + assert.deepEqual(_this4.controller.get('model'), { id: 'a-3' }); + assert.equal(_this4.controller.get('q'), 'haha'); + assert.equal(_this4.controller.get('z'), 123); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=haha'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=haha'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=haha&z=123'); + + _this4.setAndFlush(_this4.controller, 'q', 'woot'); + + assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1?q=woot'); + assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=woot'); + assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=woot&z=123'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest5 = function queryParamsStickyTest5(urlPrefix, commentsLookupKey) { + var _this5 = this; + + var assert = this.assert; + + assert.expect(12); + + return this.boot().then(function () { + _this5.transitionTo(commentsLookupKey, 'a-1'); + + var commentsCtrl = _this5.getController(commentsLookupKey); + assert.equal(commentsCtrl.get('page'), 1); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments'); + + _this5.setAndFlush(commentsCtrl, 'page', 2); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments?page=2'); + + _this5.setAndFlush(commentsCtrl, 'page', 3); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments?page=3'); + + _this5.transitionTo(commentsLookupKey, 'a-2'); + assert.equal(commentsCtrl.get('page'), 1); + _this5.assertCurrentPath(urlPrefix + '/a-2/comments'); + + _this5.transitionTo(commentsLookupKey, 'a-1'); + assert.equal(commentsCtrl.get('page'), 3); + _this5.assertCurrentPath(urlPrefix + '/a-1/comments?page=3'); + }); + }; + + ModelDependentQPTestCase.prototype.queryParamsStickyTest6 = function queryParamsStickyTest6(urlPrefix, articleLookup, commentsLookup) { + var _this6 = this; + + var assert = this.assert; + + assert.expect(13); + + this.setupApplication(); + + this.reopenRoute(articleLookup, { + resetController: function (controller, isExiting) { + this.controllerFor(commentsLookup).set('page', 1); + if (isExiting) { + controller.set('q', 'imdone'); + } + } + }); + + this.registerTemplate('about', '{{link-to \'A\' \'' + commentsLookup + '\' \'a-1\' id=\'one\'}} {{link-to \'B\' \'' + commentsLookup + '\' \'a-2\' id=\'two\'}}'); + + return this.visitApplication().then(function () { + _this6.transitionTo(commentsLookup, 'a-1'); + + var commentsCtrl = _this6.getController(commentsLookup); + assert.equal(commentsCtrl.get('page'), 1); + _this6.assertCurrentPath(urlPrefix + '/a-1/comments'); + + _this6.setAndFlush(commentsCtrl, 'page', 2); + _this6.assertCurrentPath(urlPrefix + '/a-1/comments?page=2'); + + _this6.transitionTo(commentsLookup, 'a-2'); + assert.equal(commentsCtrl.get('page'), 1); + assert.equal(_this6.controller.get('q'), 'wat'); + + _this6.transitionTo(commentsLookup, 'a-1'); + + _this6.assertCurrentPath(urlPrefix + '/a-1/comments'); + assert.equal(commentsCtrl.get('page'), 1); + + _this6.transitionTo('about'); + assert.equal(_emberViews.jQuery('#one').attr('href'), urlPrefix + '/a-1/comments?q=imdone'); + assert.equal(_emberViews.jQuery('#two').attr('href'), urlPrefix + '/a-2/comments'); + }); + }; + + return ModelDependentQPTestCase; + })(_internalTestHelpers.QueryParamTestCase); + + _internalTestHelpers.moduleFor('Query Params - model-dependent state', (function (_ModelDependentQPTestCase) { + babelHelpers.inherits(_class, _ModelDependentQPTestCase); + + function _class() { + _ModelDependentQPTestCase.apply(this, arguments); + } + + _class.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('article', { path: '/a/:id' }, function () { + this.route('comments', { resetNamespace: true }); + }); + this.route('about'); + }); + + var articles = _emberRuntime.A([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + + this.registerController('application', _emberRuntime.Controller.extend({ + articles: articles + })); + + var self = this; + var assert = this.assert; + this.registerRoute('article', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedModelHookParams) { + assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedModelHookParams = null; + } + return articles.findBy('id', params.id); + } + })); + + this.registerController('article', _emberRuntime.Controller.extend({ + queryParams: ['q', 'z'], + q: 'wat', + z: 0 + })); + + this.registerController('comments', _emberRuntime.Controller.extend({ + queryParams: 'page', + page: 1 + })); + + this.registerTemplate('application', '{{#each articles as |a|}} 1{{link-to \'Article\' \'article\' a id=a.id}} {{/each}} {{outlet}}'); + }; + + _class.prototype.visitApplication = function visitApplication() { + var _this7 = this; + + return this.visit('/').then(function () { + var assert = _this7.assert; + + _this7.$link1 = _emberViews.jQuery('#a-1'); + _this7.$link2 = _emberViews.jQuery('#a-2'); + _this7.$link3 = _emberViews.jQuery('#a-3'); + + assert.equal(_this7.$link1.attr('href'), '/a/a-1'); + assert.equal(_this7.$link2.attr('href'), '/a/a-2'); + assert.equal(_this7.$link3.attr('href'), '/a/a-3'); + + _this7.controller = _this7.getController('article'); + }); + }; + + _class.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault() { + return this.queryParamsStickyTest1('/a'); + }; + + _class.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges() { + return this.queryParamsStickyTest2('/a'); + }; + + _class.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions() { + return this.queryParamsStickyTest3('/a', 'article'); + }; + + _class.prototype['@test \'controller\' stickiness shares QP state between models'] = function testControllerStickinessSharesQPStateBetweenModels() { + return this.queryParamsStickyTest4('/a', 'article'); + }; + + _class.prototype['@test \'model\' stickiness is scoped to current or first dynamic parent route'] = function testModelStickinessIsScopedToCurrentOrFirstDynamicParentRoute() { + return this.queryParamsStickyTest5('/a', 'comments'); + }; + + _class.prototype['@test can reset query params using the resetController hook'] = function testCanResetQueryParamsUsingTheResetControllerHook() { + return this.queryParamsStickyTest6('/a', 'article', 'comments'); + }; + + return _class; + })(ModelDependentQPTestCase)); + + _internalTestHelpers.moduleFor('Query Params - model-dependent state (nested)', (function (_ModelDependentQPTestCase2) { + babelHelpers.inherits(_class2, _ModelDependentQPTestCase2); + + function _class2() { + _ModelDependentQPTestCase2.apply(this, arguments); + } + + _class2.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('site', function () { + this.route('article', { path: '/a/:id' }, function () { + this.route('comments'); + }); + }); + this.route('about'); + }); + + var site_articles = _emberRuntime.A([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + + this.registerController('application', _emberRuntime.Controller.extend({ + articles: site_articles + })); + + var self = this; + var assert = this.assert; + this.registerRoute('site.article', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedModelHookParams) { + assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedModelHookParams = null; + } + return site_articles.findBy('id', params.id); + } + })); + + this.registerController('site.article', _emberRuntime.Controller.extend({ + queryParams: ['q', 'z'], + q: 'wat', + z: 0 + })); + + this.registerController('site.article.comments', _emberRuntime.Controller.extend({ + queryParams: 'page', + page: 1 + })); + + this.registerTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'site.article\' a id=a.id}} {{/each}} {{outlet}}'); + }; + + _class2.prototype.visitApplication = function visitApplication() { + var _this8 = this; + + return this.visit('/').then(function () { + var assert = _this8.assert; + + _this8.$link1 = _emberViews.jQuery('#a-1'); + _this8.$link2 = _emberViews.jQuery('#a-2'); + _this8.$link3 = _emberViews.jQuery('#a-3'); + + assert.equal(_this8.$link1.attr('href'), '/site/a/a-1'); + assert.equal(_this8.$link2.attr('href'), '/site/a/a-2'); + assert.equal(_this8.$link3.attr('href'), '/site/a/a-3'); + + _this8.controller = _this8.getController('site.article'); + }); + }; + + _class2.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault() { + return this.queryParamsStickyTest1('/site/a'); + }; + + _class2.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges() { + return this.queryParamsStickyTest2('/site/a'); + }; + + _class2.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions() { + return this.queryParamsStickyTest3('/site/a', 'site.article'); + }; + + _class2.prototype['@test \'controller\' stickiness shares QP state between models'] = function testControllerStickinessSharesQPStateBetweenModels() { + return this.queryParamsStickyTest4('/site/a', 'site.article'); + }; + + _class2.prototype['@test \'model\' stickiness is scoped to current or first dynamic parent route'] = function testModelStickinessIsScopedToCurrentOrFirstDynamicParentRoute() { + return this.queryParamsStickyTest5('/site/a', 'site.article.comments'); + }; + + _class2.prototype['@test can reset query params using the resetController hook'] = function testCanResetQueryParamsUsingTheResetControllerHook() { + return this.queryParamsStickyTest6('/site/a', 'site.article', 'site.article.comments'); + }; + + return _class2; + })(ModelDependentQPTestCase)); + + _internalTestHelpers.moduleFor('Query Params - model-dependent state (nested & more than 1 dynamic segment)', (function (_ModelDependentQPTestCase3) { + babelHelpers.inherits(_class3, _ModelDependentQPTestCase3); + + function _class3() { + _ModelDependentQPTestCase3.apply(this, arguments); + } + + _class3.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('site', { path: '/site/:site_id' }, function () { + this.route('article', { path: '/a/:article_id' }, function () { + this.route('comments'); + }); + }); + }); + + var sites = _emberRuntime.A([{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]); + var site_articles = _emberRuntime.A([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + + this.registerController('application', _emberRuntime.Controller.extend({ + siteArticles: site_articles, + sites: sites, + allSitesAllArticles: _emberMetal.computed({ + get: function () { + var ret = []; + var siteArticles = this.siteArticles; + var sites = this.sites; + sites.forEach(function (site) { + ret = ret.concat(siteArticles.map(function (article) { + return { id: site.id + '-' + article.id, site_id: site.id, article_id: article.id }; + })); + }); + return ret; + } + }) + })); + + var self = this; + var assert = this.assert; + this.registerRoute('site', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedSiteModelHookParams) { + assert.deepEqual(params, self.expectedSiteModelHookParams, 'the SiteRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedSiteModelHookParams = null; + } + return sites.findBy('id', params.site_id); + } + })); + + this.registerRoute('site.article', _emberRouting.Route.extend({ + model: function (params) { + if (self.expectedArticleModelHookParams) { + assert.deepEqual(params, self.expectedArticleModelHookParams, 'the SiteArticleRoute model hook received the expected merged dynamic segment + query params hash'); + self.expectedArticleModelHookParams = null; + } + return site_articles.findBy('id', params.article_id); + } + })); + + this.registerController('site', _emberRuntime.Controller.extend({ + queryParams: ['country'], + country: 'au' + })); + + this.registerController('site.article', _emberRuntime.Controller.extend({ + queryParams: ['q', 'z'], + q: 'wat', + z: 0 + })); + + this.registerController('site.article.comments', _emberRuntime.Controller.extend({ + queryParams: ['page'], + page: 1 + })); + + this.registerTemplate('application', '{{#each allSitesAllArticles as |a|}} {{#link-to \'site.article\' a.site_id a.article_id id=a.id}}Article [{{a.site_id}}] [{{a.article_id}}]{{/link-to}} {{/each}} {{outlet}}'); + }; + + _class3.prototype.visitApplication = function visitApplication() { + var _this9 = this; + + return this.visit('/').then(function () { + var assert = _this9.assert; + + _this9.links = {}; + _this9.links['s-1-a-1'] = _emberViews.jQuery('#s-1-a-1'); + _this9.links['s-1-a-2'] = _emberViews.jQuery('#s-1-a-2'); + _this9.links['s-1-a-3'] = _emberViews.jQuery('#s-1-a-3'); + _this9.links['s-2-a-1'] = _emberViews.jQuery('#s-2-a-1'); + _this9.links['s-2-a-2'] = _emberViews.jQuery('#s-2-a-2'); + _this9.links['s-2-a-3'] = _emberViews.jQuery('#s-2-a-3'); + _this9.links['s-3-a-1'] = _emberViews.jQuery('#s-3-a-1'); + _this9.links['s-3-a-2'] = _emberViews.jQuery('#s-3-a-2'); + _this9.links['s-3-a-3'] = _emberViews.jQuery('#s-3-a-3'); + + assert.equal(_this9.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this9.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this9.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this9.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this9.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this9.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this9.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this9.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this9.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this9.site_controller = _this9.getController('site'); + _this9.article_controller = _this9.getController('site.article'); + }); + }; + + _class3.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault(assert) { + var _this10 = this; + + assert.expect(59); // Insane. + + return this.boot().then(function () { + _emberMetal.run(_this10.links['s-1-a-1'], 'click'); + assert.deepEqual(_this10.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this10.article_controller.get('model'), { id: 'a-1' }); + _this10.assertCurrentPath('/site/s-1/a/a-1'); + + _this10.setAndFlush(_this10.article_controller, 'q', 'lol'); + + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this10.setAndFlush(_this10.site_controller, 'country', 'us'); + + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _emberMetal.run(_this10.links['s-1-a-2'], 'click'); + + assert.equal(_this10.site_controller.get('country'), 'us'); + assert.equal(_this10.article_controller.get('q'), 'wat'); + assert.equal(_this10.article_controller.get('z'), 0); + assert.deepEqual(_this10.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this10.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _emberMetal.run(_this10.links['s-2-a-2'], 'click'); + + assert.equal(_this10.site_controller.get('country'), 'au'); + assert.equal(_this10.article_controller.get('q'), 'wat'); + assert.equal(_this10.article_controller.get('z'), 0); + assert.deepEqual(_this10.site_controller.get('model'), { id: 's-2' }); + assert.deepEqual(_this10.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this10.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol'); + assert.equal(_this10.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(_this10.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(_this10.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this10.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this10.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this10.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this10.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this10.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + }); + }; + + _class3.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges(assert) { + var _this11 = this; + + assert.expect(88); // INSANE. + + return this.boot().then(function () { + _this11.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', z: 0 }; + _this11.transitionTo('/site/s-1/a/a-1?q=lol'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-1' }, 'site controller\'s model is s-1'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-1' }, 'article controller\'s model is a-1'); + assert.equal(_this11.site_controller.get('country'), 'au'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 0); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this11.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', z: 0 }; + _this11.transitionTo('/site/s-2/a/a-1?country=us&q=lol'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-1' }, 'article controller\'s model is a-1'); + assert.equal(_this11.site_controller.get('country'), 'us'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 0); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this11.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 0 }; + _this11.transitionTo('/site/s-2/a/a-2?country=us&q=lol'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-2' }, 'article controller\'s model is a-2'); + assert.equal(_this11.site_controller.get('country'), 'us'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 0); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this11.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', z: 123 }; + _this11.transitionTo('/site/s-2/a/a-3?country=us&q=lol&z=123'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-3' }, 'article controller\'s model is a-3'); + assert.equal(_this11.site_controller.get('country'), 'us'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 123); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=lol&z=123'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=lol&z=123'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=lol&z=123'); + + _this11.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' }; + _this11.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', z: 123 }; + _this11.transitionTo('/site/s-3/a/a-3?country=nz&q=lol&z=123'); + + assert.deepEqual(_this11.site_controller.get('model'), { id: 's-3' }, 'site controller\'s model is s-3'); + assert.deepEqual(_this11.article_controller.get('model'), { id: 'a-3' }, 'article controller\'s model is a-3'); + assert.equal(_this11.site_controller.get('country'), 'nz'); + assert.equal(_this11.article_controller.get('q'), 'lol'); + assert.equal(_this11.article_controller.get('z'), 123); + assert.equal(_this11.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(_this11.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this11.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=lol&z=123'); + assert.equal(_this11.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol'); + assert.equal(_this11.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=lol&z=123'); + assert.equal(_this11.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?country=nz&q=lol'); + assert.equal(_this11.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?country=nz&q=lol'); + assert.equal(_this11.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?country=nz&q=lol&z=123'); + }); + }; + + _class3.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions(assert) { + var _this12 = this; + + assert.expect(118); // <-- INSANE! Like why is this even a thing? + + return this.boot().then(function () { + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-1', q: 'wat', z: 0 }; + _this12.transitionTo('site.article', 's-1', 'a-1'); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-1' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'wat'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 0 }; + _this12.transitionTo('site.article', 's-1', 'a-2', { queryParams: { q: 'lol' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'lol'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3'); + + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', z: 0 }; + _this12.transitionTo('site.article', 's-1', 'a-3', { queryParams: { q: 'hay' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-3' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'hay'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 1 }; + _this12.transitionTo('site.article', 's-1', 'a-2', { queryParams: { z: 1 } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-1' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this12.site_controller.get('country'), 'au'); + assert.equal(_this12.article_controller.get('q'), 'lol'); + assert.equal(_this12.article_controller.get('z'), 1); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 1 }; + _this12.transitionTo('site.article', 's-2', 'a-2', { queryParams: { country: 'us' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-2' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-2' }); + assert.equal(_this12.site_controller.get('country'), 'us'); + assert.equal(_this12.article_controller.get('q'), 'lol'); + assert.equal(_this12.article_controller.get('z'), 1); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-1', q: 'yeah', z: 0 }; + _this12.transitionTo('site.article', 's-2', 'a-1', { queryParams: { q: 'yeah' } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-2' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-1' }); + assert.equal(_this12.site_controller.get('country'), 'us'); + assert.equal(_this12.article_controller.get('q'), 'yeah'); + assert.equal(_this12.article_controller.get('z'), 0); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=yeah'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=yeah'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=yeah'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay'); + + _this12.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' }; + _this12.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', z: 3 }; + _this12.transitionTo('site.article', 's-3', 'a-3', { queryParams: { country: 'nz', z: 3 } }); + + assert.deepEqual(_this12.site_controller.get('model'), { id: 's-3' }); + assert.deepEqual(_this12.article_controller.get('model'), { id: 'a-3' }); + assert.equal(_this12.site_controller.get('country'), 'nz'); + assert.equal(_this12.article_controller.get('q'), 'hay'); + assert.equal(_this12.article_controller.get('z'), 3); + assert.equal(_this12.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=yeah'); + assert.equal(_this12.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(_this12.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay&z=3'); + assert.equal(_this12.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=yeah'); + assert.equal(_this12.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1'); + assert.equal(_this12.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay&z=3'); + assert.equal(_this12.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?country=nz&q=yeah'); + assert.equal(_this12.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?country=nz&q=lol&z=1'); + assert.equal(_this12.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?country=nz&q=hay&z=3'); + }); + }; + + return _class3; + })(ModelDependentQPTestCase)); +}); +enifed('ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/overlapping_query_params_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - overlapping query param property names', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.setupBase = function setupBase() { + this.router.map(function () { + this.route('parent', function () { + this.route('child'); + }); + }); + + return this.visit('/parent/child'); + }; + + _class.prototype['@test can remap same-named qp props'] = function testCanRemapSameNamedQpProps(assert) { + var _this = this; + + assert.expect(7); + + this.setMappedQPController('parent'); + this.setMappedQPController('parent.child', 'page', 'childPage'); + + return this.setupBase().then(function () { + _this.assertCurrentPath('/parent/child'); + + var parentController = _this.getController('parent'); + var parentChildController = _this.getController('parent.child'); + + _this.setAndFlush(parentController, 'page', 2); + _this.assertCurrentPath('/parent/child?parentPage=2'); + _this.setAndFlush(parentController, 'page', 1); + _this.assertCurrentPath('/parent/child'); + + _this.setAndFlush(parentChildController, 'page', 2); + _this.assertCurrentPath('/parent/child?childPage=2'); + _this.setAndFlush(parentChildController, 'page', 1); + _this.assertCurrentPath('/parent/child'); + + _emberMetal.run(function () { + parentController.set('page', 2); + parentChildController.set('page', 2); + }); + + _this.assertCurrentPath('/parent/child?childPage=2&parentPage=2'); + + _emberMetal.run(function () { + parentController.set('page', 1); + parentChildController.set('page', 1); + }); + + _this.assertCurrentPath('/parent/child'); + }); + }; + + _class.prototype['@test query params can be either controller property or url key'] = function testQueryParamsCanBeEitherControllerPropertyOrUrlKey(assert) { + var _this2 = this; + + assert.expect(3); + + this.setMappedQPController('parent'); + + return this.setupBase().then(function () { + _this2.assertCurrentPath('/parent/child'); + + _this2.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this2.assertCurrentPath('/parent/child?parentPage=2'); + + _this2.transitionTo('parent.child', { queryParams: { parentPage: 3 } }); + _this2.assertCurrentPath('/parent/child?parentPage=3'); + }); + }; + + _class.prototype['@test query param matching a url key and controller property'] = function testQueryParamMatchingAUrlKeyAndControllerProperty(assert) { + var _this3 = this; + + assert.expect(3); + + this.setMappedQPController('parent', 'page', 'parentPage'); + this.setMappedQPController('parent.child', 'index', 'page'); + + return this.setupBase().then(function () { + _this3.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this3.assertCurrentPath('/parent/child?parentPage=2'); + + _this3.transitionTo('parent.child', { queryParams: { parentPage: 3 } }); + _this3.assertCurrentPath('/parent/child?parentPage=3'); + + _this3.transitionTo('parent.child', { queryParams: { index: 2, page: 2 } }); + _this3.assertCurrentPath('/parent/child?page=2&parentPage=2'); + }); + }; + + _class.prototype['@test query param matching same property on two controllers use the urlKey higher in the chain'] = function testQueryParamMatchingSamePropertyOnTwoControllersUseTheUrlKeyHigherInTheChain(assert) { + var _this4 = this; + + assert.expect(4); + + this.setMappedQPController('parent', 'page', 'parentPage'); + this.setMappedQPController('parent.child', 'page', 'childPage'); + + return this.setupBase().then(function () { + _this4.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this4.assertCurrentPath('/parent/child?parentPage=2'); + + _this4.transitionTo('parent.child', { queryParams: { parentPage: 3 } }); + _this4.assertCurrentPath('/parent/child?parentPage=3'); + + _this4.transitionTo('parent.child', { queryParams: { childPage: 2, page: 2 } }); + _this4.assertCurrentPath('/parent/child?childPage=2&parentPage=2'); + + _this4.transitionTo('parent.child', { queryParams: { childPage: 3, parentPage: 4 } }); + _this4.assertCurrentPath('/parent/child?childPage=3&parentPage=4'); + }); + }; + + _class.prototype['@test query params does not error when a query parameter exists for route instances that share a controller'] = function testQueryParamsDoesNotErrorWhenAQueryParameterExistsForRouteInstancesThatShareAController(assert) { + var _this5 = this; + + assert.expect(1); + + var parentController = _emberRuntime.Controller.extend({ + queryParams: { page: 'page' } + }); + this.registerController('parent', parentController); + this.registerRoute('parent.child', _emberRouting.Route.extend({ controllerName: 'parent' })); + + return this.setupBase('/parent').then(function () { + _this5.transitionTo('parent.child', { queryParams: { page: 2 } }); + _this5.assertCurrentPath('/parent/child?page=2'); + }); + }; + + _class.prototype['@test query params in the same route hierarchy with the same url key get auto-scoped'] = function testQueryParamsInTheSameRouteHierarchyWithTheSameUrlKeyGetAutoScoped(assert) { + var _this6 = this; + + assert.expect(1); + + this.setMappedQPController('parent'); + this.setMappedQPController('parent.child'); + + expectAssertion(function () { + _this6.setupBase(); + }, 'You\'re not allowed to have more than one controller property map to the same query param key, but both `parent:page` and `parent.child:page` map to `parentPage`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `page: { as: \'other-page\' }`'); + }; + + _class.prototype['@test Support shared but overridable mixin pattern'] = function testSupportSharedButOverridableMixinPattern(assert) { + var _this7 = this; + + assert.expect(7); + + var HasPage = _emberMetal.Mixin.create({ + queryParams: 'page', + page: 1 + }); + + this.registerController('parent', _emberRuntime.Controller.extend(HasPage, { + queryParams: { page: 'yespage' } + })); + + this.registerController('parent.child', _emberRuntime.Controller.extend(HasPage)); + + return this.setupBase().then(function () { + _this7.assertCurrentPath('/parent/child'); + + var parentController = _this7.getController('parent'); + var parentChildController = _this7.getController('parent.child'); + + _this7.setAndFlush(parentChildController, 'page', 2); + _this7.assertCurrentPath('/parent/child?page=2'); + assert.equal(parentController.get('page'), 1); + assert.equal(parentChildController.get('page'), 2); + + _this7.setAndFlush(parentController, 'page', 2); + _this7.assertCurrentPath('/parent/child?page=2&yespage=2'); + assert.equal(parentController.get('page'), 2); + assert.equal(parentChildController.get('page'), 2); + }); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/overlapping_query_params_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/overlapping_query_params_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/overlapping_query_params_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/query_param_async_get_handler_test', ['exports', 'ember-runtime', 'ember-routing', 'internal-test-helpers'], function (exports, _emberRuntime, _emberRouting, _internalTestHelpers) { + 'use strict'; + + // These tests mimic what happens with lazily loaded Engines. + _internalTestHelpers.moduleFor('Query Params - async get handler', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype['@test can render a link to an asynchronously loaded route without fetching the route'] = function testCanRenderALinkToAnAsynchronouslyLoadedRouteWithoutFetchingTheRoute(assert) { + var _this = this; + + assert.expect(4); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }); + }); + + this.setSingleQPController('post'); + + var setupAppTemplate = function () { + _this.registerTemplate('application', '\n {{link-to \'Post\' \'post\' 1337 (query-params foo=\'bar\') class=\'post-link\'}}\n {{link-to \'Post\' \'post\' 7331 (query-params foo=\'boo\') class=\'post-link\'}}\n {{outlet}}\n '); + }; + + setupAppTemplate(); + + return this.visitAndAssert('/').then(function () { + assert.equal(_this.$('.post-link').eq(0).attr('href'), '/post/1337?foo=bar', 'renders correctly with default QP value'); + assert.equal(_this.$('.post-link').eq(1).attr('href'), '/post/7331?foo=boo', 'renders correctly with non-default QP value'); + assert.deepEqual(_this.fetchedHandlers, ['application', 'index'], 'only fetched the handlers for the route we\'re on'); + }); + }; + + _class.prototype['@test can transitionTo to an asynchronously loaded route with simple query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithSimpleQueryParams(assert) { + var _this2 = this; + + assert.expect(6); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }); + this.route('posts'); + }); + + this.setSingleQPController('post'); + + var postController = undefined; + return this.visitAndAssert('/').then(function () { + postController = _this2.getController('post'); + + return _this2.transitionTo('posts').then(function () { + _this2.assertCurrentPath('/posts'); + }); + }).then(function () { + return _this2.transitionTo('post', 1337, { queryParams: { foo: 'boo' } }).then(function () { + assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly set on controller'); + _this2.assertCurrentPath('/post/1337?foo=boo'); + }); + }).then(function () { + return _this2.transitionTo('post', 1337, { queryParams: { foo: 'bar' } }).then(function () { + assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly set with default value'); + _this2.assertCurrentPath('/post/1337'); + }); + }); + }; + + _class.prototype['@test can transitionTo to an asynchronously loaded route with array query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithArrayQueryParams(assert) { + var _this3 = this; + + assert.expect(5); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }); + }); + + this.setSingleQPController('post', 'comments', []); + + var postController = undefined; + return this.visitAndAssert('/').then(function () { + postController = _this3.getController('post'); + return _this3.transitionTo('post', 1337, { queryParams: { comments: [1, 2] } }).then(function () { + assert.deepEqual(postController.get('comments'), [1, 2], 'array QP is correctly set with default value'); + _this3.assertCurrentPath('/post/1337?comments=%5B1%2C2%5D'); + }); + }).then(function () { + return _this3.transitionTo('post', 1338).then(function () { + assert.deepEqual(postController.get('comments'), [], 'array QP is correctly set on controller'); + _this3.assertCurrentPath('/post/1338'); + }); + }); + }; + + _class.prototype['@test can transitionTo to an asynchronously loaded route with mapped query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithMappedQueryParams(assert) { + var _this4 = this; + + assert.expect(7); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }, function () { + this.route('index', { path: '/' }); + }); + }); + + this.setSingleQPController('post'); + this.setMappedQPController('post.index', 'comment', 'note'); + + var postController = undefined; + var postIndexController = undefined; + + return this.visitAndAssert('/').then(function () { + postController = _this4.getController('post'); + postIndexController = _this4.getController('post.index'); + + return _this4.transitionTo('post.index', 1337, { queryParams: { note: 6, foo: 'boo' } }).then(function () { + assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly set on controller'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP is correctly set on controller'); + _this4.assertCurrentPath('/post/1337?foo=boo¬e=6'); + }); + }).then(function () { + return _this4.transitionTo('post', 1337, { queryParams: { foo: 'bar' } }).then(function () { + assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly set with default value'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP retains value scoped to model'); + _this4.assertCurrentPath('/post/1337?note=6'); + }); + }); + }; + + _class.prototype['@test can transitionTo with a URL'] = function testCanTransitionToWithAURL(assert) { + var _this5 = this; + + assert.expect(7); + + this.router.map(function () { + this.route('post', { path: '/post/:id' }, function () { + this.route('index', { path: '/' }); + }); + }); + + this.setSingleQPController('post'); + this.setMappedQPController('post.index', 'comment', 'note'); + + var postController = undefined; + var postIndexController = undefined; + + return this.visitAndAssert('/').then(function () { + postController = _this5.getController('post'); + postIndexController = _this5.getController('post.index'); + + return _this5.transitionTo('/post/1337?foo=boo¬e=6').then(function () { + assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly deserialized on controller'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP is correctly deserialized on controller'); + _this5.assertCurrentPath('/post/1337?foo=boo¬e=6'); + }); + }).then(function () { + return _this5.transitionTo('/post/1337?note=6').then(function () { + assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly deserialized with default value'); + assert.equal(postIndexController.get('comment'), 6, 'mapped QP retains value scoped to model'); + _this5.assertCurrentPath('/post/1337?note=6'); + }); + }); + }; + + _class.prototype['@test undefined isn\'t serialized or deserialized into a string'] = function testUndefinedIsnTSerializedOrDeserializedIntoAString(assert) { + var _this6 = this; + + assert.expect(4); + + this.router.map(function () { + this.route('example'); + }); + + this.registerTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); + + this.setSingleQPController('example', 'foo', undefined, { + foo: undefined + }); + + this.registerRoute('example', _emberRouting.Route.extend({ + model: function (params) { + assert.deepEqual(params, { foo: undefined }); + } + })); + + return this.visitAndAssert('/').then(function () { + assert.equal(_this6.$('#the-link').attr('href'), '/example', 'renders without undefined qp serialized'); + + return _this6.transitionTo('example', { queryParams: { foo: undefined } }).then(function () { + _this6.assertCurrentPath('/example'); + }); + }); + }; + + babelHelpers.createClass(_class, [{ + key: 'routerOptions', + get: function () { + var fetchedHandlers = this.fetchedHandlers = []; + + return { + location: 'test', + + _getQPMeta: function (handlerInfo) { + return this._bucketCache.lookup('route-meta', handlerInfo.name); + }, + + _getHandlerFunction: function () { + var getHandler = this._super.apply(this, arguments); + var cache = {}; + + return function (routeName) { + fetchedHandlers.push(routeName); + + // Cache the returns so we don't have more than one Promise for a + // given handler. + return cache[routeName] || (cache[routeName] = new _emberRuntime.RSVP.Promise(function (resolve) { + setTimeout(function () { + return resolve(getHandler(routeName)); + }, 10); + })); + }; + } + }; + } + }]); + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/query_param_async_get_handler_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/query_param_async_get_handler_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/query_param_async_get_handler_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/query_params_paramless_link_to_test', ['exports', 'ember-runtime', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _emberViews, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - paramless link-to', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.testParamlessLinks = function testParamlessLinks(assert, routeName) { + assert.expect(1); + + this.registerTemplate(routeName, '{{link-to \'index\' \'index\' id=\'index-link\'}}'); + + this.registerController(routeName, _emberRuntime.Controller.extend({ + queryParams: ['foo'], + foo: 'wat' + })); + + return this.visit('/?foo=YEAH').then(function () { + assert.equal(_emberViews.jQuery('#index-link').attr('href'), '/?foo=YEAH'); + }); + }; + + _class.prototype['@test param-less links in an app booted with query params in the URL don\'t reset the query params: application'] = function testParamLessLinksInAnAppBootedWithQueryParamsInTheURLDonTResetTheQueryParamsApplication(assert) { + return this.testParamlessLinks(assert, 'application'); + }; + + _class.prototype['@test param-less links in an app booted with query params in the URL don\'t reset the query params: index'] = function testParamLessLinksInAnAppBootedWithQueryParamsInTheURLDonTResetTheQueryParamsIndex(assert) { + return this.testParamlessLinks(assert, 'index'); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/query_params_paramless_link_to_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/query_params_test/shared_state_test', ['exports', 'ember-runtime', 'ember', 'ember-metal', 'ember-views', 'internal-test-helpers'], function (exports, _emberRuntime, _ember, _emberMetal, _emberViews, _internalTestHelpers) { + 'use strict'; + + _internalTestHelpers.moduleFor('Query Params - shared service state', (function (_QueryParamTestCase) { + babelHelpers.inherits(_class, _QueryParamTestCase); + + function _class() { + _QueryParamTestCase.apply(this, arguments); + } + + _class.prototype.boot = function boot() { + this.setupApplication(); + return this.visitApplication(); + }; + + _class.prototype.setupApplication = function setupApplication() { + this.router.map(function () { + this.route('home', { path: '/' }); + this.route('dashboard'); + }); + + this.application.register('service:filters', _emberRuntime.Service.extend({ + shared: true + })); + + this.registerController('home', _emberRuntime.Controller.extend({ + filters: _ember.default.inject.service() + })); + + this.registerController('dashboard', _emberRuntime.Controller.extend({ + filters: _ember.default.inject.service(), + queryParams: [{ 'filters.shared': 'shared' }] + })); + + this.registerTemplate('application', '{{link-to \'Home\' \'home\' }}
    {{outlet}}
    '); + this.registerTemplate('home', '{{link-to \'Dashboard\' \'dashboard\' }}{{input type="checkbox" id=\'filters-checkbox\' checked=(mut filters.shared) }}'); + this.registerTemplate('dashboard', '{{link-to \'Home\' \'home\' }}'); + }; + + _class.prototype.visitApplication = function visitApplication() { + return this.visit('/'); + }; + + _class.prototype['@test can modify shared state before transition'] = function testCanModifySharedStateBeforeTransition(assert) { + var _this = this; + + assert.expect(1); + + return this.boot().then(function () { + _this.$input = _emberViews.jQuery('#filters-checkbox'); + + // click the checkbox once to set filters.shared to false + _emberMetal.run(_this.$input, 'click'); + + return _this.visit('/dashboard').then(function () { + assert.ok(true, 'expecting navigating to dashboard to succeed'); + }); + }); + }; + + _class.prototype['@test can modify shared state back to the default value before transition'] = function testCanModifySharedStateBackToTheDefaultValueBeforeTransition(assert) { + var _this2 = this; + + assert.expect(1); + + return this.boot().then(function () { + _this2.$input = _emberViews.jQuery('#filters-checkbox'); + + // click the checkbox twice to set filters.shared to false and back to true + _emberMetal.run(_this2.$input, 'click'); + _emberMetal.run(_this2.$input, 'click'); + + return _this2.visit('/dashboard').then(function () { + assert.ok(true, 'expecting navigating to dashboard to succeed'); + }); + }); + }; + + return _class; + })(_internalTestHelpers.QueryParamTestCase)); +}); +enifed('ember/tests/routing/query_params_test/shared_state_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/query_params_test/shared_state_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/query_params_test/shared_state_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_map_test', ['exports', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-routing', 'ember-views', 'ember-glimmer'], function (exports, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberRouting, _emberViews, _emberGlimmer) { + 'use strict'; + + var router = undefined, + App = undefined, + container = undefined; + + function bootApplication() { + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + function handleURL(path) { + return _emberMetal.run(function () { + return router.handleURL(path).then(function (value) { + ok(true, 'url: `' + path + '` was handled'); + return value; + }, function (reason) { + ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason)); + throw reason; + }); + }); + } + + QUnit.module('Router.map', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + container = App.__container__; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + + _emberGlimmer.setTemplates({}); + }); + } + }); + + QUnit.test('Router.map returns an Ember Router class', function () { + expect(1); + + var ret = App.Router.map(function () { + this.route('hello'); + }); + + ok(_emberRouting.Router.detect(ret)); + }); + + QUnit.test('Router.map can be called multiple times', function () { + expect(4); + + _emberGlimmer.setTemplate('hello', _emberTemplateCompiler.compile('Hello!')); + _emberGlimmer.setTemplate('goodbye', _emberTemplateCompiler.compile('Goodbye!')); + + App.Router.map(function () { + this.route('hello'); + }); + + App.Router.map(function () { + this.route('goodbye'); + }); + + bootApplication(); + + handleURL('/hello'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'Hello!', 'The hello template was rendered'); + + handleURL('/goodbye'); + + equal(_emberViews.jQuery('#qunit-fixture').text(), 'Goodbye!', 'The goodbye template was rendered'); + }); +}); +enifed('ember/tests/routing/router_map_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_map_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_map_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/basic_test', ['exports', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers'], function (exports, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + _internalTestHelpers.moduleFor('Router Service - main', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + _RouterTestCase.apply(this, arguments); + } + + _class.prototype['@test RouterService#currentRouteName is correctly set for top level route'] = function testRouterServiceCurrentRouteNameIsCorrectlySetForTopLevelRoute(assert) { + var _this = this; + + assert.expect(1); + + return this.visit('/').then(function () { + assert.equal(_this.routerService.get('currentRouteName'), 'parent.index'); + }); + }; + + _class.prototype['@test RouterService#currentRouteName is correctly set for child route'] = function testRouterServiceCurrentRouteNameIsCorrectlySetForChildRoute(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + assert.equal(_this2.routerService.get('currentRouteName'), 'parent.child'); + }); + }; + + _class.prototype['@test RouterService#currentRouteName is correctly set after transition'] = function testRouterServiceCurrentRouteNameIsCorrectlySetAfterTransition(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + assert.equal(_this3.routerService.get('currentRouteName'), 'parent.sister'); + }); + }; + + _class.prototype['@test RouterService#currentRouteName is correctly set on each transition'] = function testRouterServiceCurrentRouteNameIsCorrectlySetOnEachTransition(assert) { + var _this4 = this; + + assert.expect(3); + + return this.visit('/child').then(function () { + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.child'); + + return _this4.visit('/sister'); + }).then(function () { + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.sister'); + + return _this4.visit('/brother'); + }).then(function () { + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.brother'); + }); + }; + + _class.prototype['@test RouterService#rootURL is correctly set to the default value'] = function testRouterServiceRootURLIsCorrectlySetToTheDefaultValue(assert) { + var _this5 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + assert.equal(_this5.routerService.get('rootURL'), '/'); + }); + }; + + _class.prototype['@test RouterService#rootURL is correctly set to a custom value'] = function testRouterServiceRootURLIsCorrectlySetToACustomValue(assert) { + var _this6 = this; + + assert.expect(1); + + this.registerRoute('parent.index', _emberRouting.Route.extend({ + init: function () { + this._super(); + _emberMetal.set(this.router, 'rootURL', '/homepage'); + } + })); + + return this.visit('/').then(function () { + assert.equal(_this6.routerService.get('rootURL'), '/homepage'); + }); + }; + + _class.prototype['@test RouterService#location is correctly delegated from router:main'] = function testRouterServiceLocationIsCorrectlyDelegatedFromRouterMain(assert) { + var _this7 = this; + + assert.expect(2); + + return this.visit('/').then(function () { + var location = _this7.routerService.get('location'); + assert.ok(location); + assert.ok(location instanceof _emberRouting.NoneLocation); + }); + }; + + return _class; + })(_internalTestHelpers.RouterTestCase)); + } +}); +enifed('ember/tests/routing/router_service_test/basic_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/basic_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/basic_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/currenturl_lifecycle_test', ['exports', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers'], function (exports, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + (function () { + var results = []; + var ROUTE_NAMES = ['index', 'child', 'sister', 'brother']; + + var InstrumentedRoute = _emberRouting.Route.extend({ + routerService: _emberRuntime.inject.service('router'), + + beforeModel: function () { + var service = _emberMetal.get(this, 'routerService'); + results.push([service.get('currentRouteName'), 'beforeModel', service.get('currentURL')]); + }, + + model: function () { + var service = _emberMetal.get(this, 'routerService'); + results.push([service.get('currentRouteName'), 'model', service.get('currentURL')]); + }, + + afterModel: function () { + var service = _emberMetal.get(this, 'routerService'); + results.push([service.get('currentRouteName'), 'afterModel', service.get('currentURL')]); + } + }); + + _internalTestHelpers.moduleFor('Router Service - currentURL', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + var _this = this; + + _RouterTestCase.call(this); + + results = []; + + ROUTE_NAMES.forEach(function (name) { + var routeName = 'parent.' + name; + _this.registerRoute(routeName, InstrumentedRoute.extend()); + _this.registerTemplate(routeName, '{{current-url}}'); + }); + + this.registerComponent('current-url', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + currentURL: _emberRuntime.readOnly('routerService.currentURL') + }), + template: '{{currentURL}}' + }); + } + + _class.prototype['@test RouterService#currentURL is correctly set for top level route'] = function testRouterServiceCurrentURLIsCorrectlySetForTopLevelRoute(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + assert.equal(_this2.routerService.get('currentURL'), '/'); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set for child route'] = function testRouterServiceCurrentURLIsCorrectlySetForChildRoute(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + assert.equal(_this3.routerService.get('currentURL'), '/child'); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set after transition'] = function testRouterServiceCurrentURLIsCorrectlySetAfterTransition(assert) { + var _this4 = this; + + assert.expect(1); + + return this.visit('/child').then(function () { + return _this4.routerService.transitionTo('parent.sister'); + }).then(function () { + assert.equal(_this4.routerService.get('currentURL'), '/sister'); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set on each transition'] = function testRouterServiceCurrentURLIsCorrectlySetOnEachTransition(assert) { + var _this5 = this; + + assert.expect(3); + + return this.visit('/child').then(function () { + assert.equal(_this5.routerService.get('currentURL'), '/child'); + + return _this5.visit('/sister'); + }).then(function () { + assert.equal(_this5.routerService.get('currentURL'), '/sister'); + + return _this5.visit('/brother'); + }).then(function () { + assert.equal(_this5.routerService.get('currentURL'), '/brother'); + }); + }; + + _class.prototype['@test RouterService#currentURL is not set during lifecycle hooks'] = function testRouterServiceCurrentURLIsNotSetDuringLifecycleHooks(assert) { + var _this6 = this; + + assert.expect(2); + + return this.visit('/').then(function () { + assert.deepEqual(results, [[null, 'beforeModel', null], [null, 'model', null], [null, 'afterModel', null]]); + + results = []; + + return _this6.visit('/child'); + }).then(function () { + assert.deepEqual(results, [['parent.index', 'beforeModel', '/'], ['parent.index', 'model', '/'], ['parent.index', 'afterModel', '/']]); + }); + }; + + _class.prototype['@test RouterService#currentURL is correctly set with component after consecutive visits'] = function testRouterServiceCurrentURLIsCorrectlySetWithComponentAfterConsecutiveVisits(assert) { + var _this7 = this; + + assert.expect(3); + + return this.visit('/').then(function () { + _this7.assertText('/'); + + return _this7.visit('/child'); + }).then(function () { + _this7.assertText('/child'); + + return _this7.visit('/'); + }).then(function () { + _this7.assertText('/'); + }); + }; + + return _class; + })(_internalTestHelpers.RouterTestCase)); + })(); + } +}); +enifed('ember/tests/routing/router_service_test/currenturl_lifecycle_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/currenturl_lifecycle_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/currenturl_lifecycle_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/replaceWith_test', ['exports', 'ember-routing', 'internal-test-helpers', 'router', 'ember-metal'], function (exports, _emberRouting, _internalTestHelpers, _router, _emberMetal) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + _internalTestHelpers.moduleFor('Router Service - replaceWith', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + _RouterTestCase.call(this); + + var testCase = this; + testCase.state = []; + + this.application.register('location:test', _emberRouting.NoneLocation.extend({ + setURL: function (path) { + testCase.state.push(path); + this.set('path', path); + }, + + replaceURL: function (path) { + testCase.state.splice(testCase.state.length - 1, 1, path); + this.set('path', path); + } + })); + } + + _class.prototype['@test RouterService#replaceWith returns a Transition'] = function testRouterServiceReplaceWithReturnsATransition(assert) { + var _this = this; + + assert.expect(1); + + var transition = undefined; + + return this.visit('/').then(function () { + transition = _this.routerService.replaceWith('parent.child'); + + assert.ok(transition instanceof _router.Transition); + + return transition; + }); + }; + + _class.prototype['@test RouterService#replaceWith with basic route replaces location'] = function testRouterServiceReplaceWithWithBasicRouteReplacesLocation(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this2.routerService.transitionTo('parent.child'); + }).then(function () { + return _this2.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this2.routerService.replaceWith('parent.brother'); + }).then(function () { + assert.deepEqual(_this2.state, ['/', '/child', '/brother']); + }); + }; + + _class.prototype['@test RouterService#replaceWith transitioning back to previously visited route replaces location'] = function testRouterServiceReplaceWithTransitioningBackToPreviouslyVisitedRouteReplacesLocation(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this3.routerService.transitionTo('parent.child'); + }).then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this3.routerService.transitionTo('parent.brother'); + }).then(function () { + return _this3.routerService.replaceWith('parent.sister'); + }).then(function () { + assert.deepEqual(_this3.state, ['/', '/child', '/sister', '/sister']); + }); + }; + + babelHelpers.createClass(_class, [{ + key: 'routerOptions', + get: function () { + return { + location: 'test' + }; + } + }]); + return _class; + })(_internalTestHelpers.RouterTestCase)); + } +}); +enifed('ember/tests/routing/router_service_test/replaceWith_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/replaceWith_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/replaceWith_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/router_service_test/transitionTo_test', ['exports', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers', 'router'], function (exports, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers, _router) { + 'use strict'; + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + _internalTestHelpers.moduleFor('Router Service - transitionTo', (function (_RouterTestCase) { + babelHelpers.inherits(_class, _RouterTestCase); + + function _class() { + _RouterTestCase.call(this); + + var testCase = this; + testCase.state = []; + + this.application.register('location:test', _emberRouting.NoneLocation.extend({ + setURL: function (path) { + testCase.state.push(path); + this.set('path', path); + }, + + replaceURL: function (path) { + testCase.state.splice(testCase.state.length - 1, 1, path); + this.set('path', path); + } + })); + } + + _class.prototype['@test RouterService#transitionTo returns a Transition'] = function testRouterServiceTransitionToReturnsATransition(assert) { + var _this = this; + + assert.expect(1); + + var transition = undefined; + + return this.visit('/').then(function () { + transition = _this.routerService.transitionTo('parent.child'); + + assert.ok(transition instanceof _router.Transition); + + return transition; + }); + }; + + _class.prototype['@test RouterService#transitionTo with basic route updates location'] = function testRouterServiceTransitionToWithBasicRouteUpdatesLocation(assert) { + var _this2 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this2.routerService.transitionTo('parent.child'); + }).then(function () { + return _this2.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this2.routerService.transitionTo('parent.brother'); + }).then(function () { + assert.deepEqual(_this2.state, ['/', '/child', '/sister', '/brother']); + }); + }; + + _class.prototype['@test RouterService#transitionTo transitioning back to previously visited route updates location'] = function testRouterServiceTransitionToTransitioningBackToPreviouslyVisitedRouteUpdatesLocation(assert) { + var _this3 = this; + + assert.expect(1); + + return this.visit('/').then(function () { + return _this3.routerService.transitionTo('parent.child'); + }).then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + return _this3.routerService.transitionTo('parent.brother'); + }).then(function () { + return _this3.routerService.transitionTo('parent.sister'); + }).then(function () { + assert.deepEqual(_this3.state, ['/', '/child', '/sister', '/brother', '/sister']); + }); + }; + + _class.prototype['@test RouterService#transitionTo with basic route'] = function testRouterServiceTransitionToWithBasicRoute(assert) { + var _this4 = this; + + assert.expect(1); + + var componentInstance = undefined; + + this.registerTemplate('parent.index', '{{foo-bar}}'); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + init: function () { + this._super(); + componentInstance = this; + }, + actions: { + transitionToSister: function () { + _emberMetal.get(this, 'routerService').transitionTo('parent.sister'); + } + } + }), + template: 'foo-bar' + }); + + return this.visit('/').then(function () { + _emberMetal.run(function () { + componentInstance.send('transitionToSister'); + }); + + assert.equal(_this4.routerService.get('currentRouteName'), 'parent.sister'); + }); + }; + + _class.prototype['@test RouterService#transitionTo with dynamic segment'] = function testRouterServiceTransitionToWithDynamicSegment(assert) { + var _this5 = this; + + assert.expect(3); + + var componentInstance = undefined; + var dynamicModel = { id: 1, contents: 'much dynamicism' }; + + this.registerTemplate('parent.index', '{{foo-bar}}'); + this.registerTemplate('dynamic', '{{model.contents}}'); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + init: function () { + this._super(); + componentInstance = this; + }, + actions: { + transitionToDynamic: function () { + _emberMetal.get(this, 'routerService').transitionTo('dynamic', dynamicModel); + } + } + }), + template: 'foo-bar' + }); + + return this.visit('/').then(function () { + _emberMetal.run(function () { + componentInstance.send('transitionToDynamic'); + }); + + assert.equal(_this5.routerService.get('currentRouteName'), 'dynamic'); + assert.equal(_this5.routerService.get('currentURL'), '/dynamic/1'); + _this5.assertText('much dynamicism'); + }); + }; + + _class.prototype['@test RouterService#transitionTo with dynamic segment and model hook'] = function testRouterServiceTransitionToWithDynamicSegmentAndModelHook(assert) { + var _this6 = this; + + assert.expect(3); + + var componentInstance = undefined; + var dynamicModel = { id: 1, contents: 'much dynamicism' }; + + this.registerRoute('dynamic', _emberRouting.Route.extend({ + model: function () { + return dynamicModel; + } + })); + + this.registerTemplate('parent.index', '{{foo-bar}}'); + this.registerTemplate('dynamic', '{{model.contents}}'); + + this.registerComponent('foo-bar', { + ComponentClass: _emberGlimmer.Component.extend({ + routerService: _emberRuntime.inject.service('router'), + init: function () { + this._super(); + componentInstance = this; + }, + actions: { + transitionToDynamic: function () { + _emberMetal.get(this, 'routerService').transitionTo('dynamic', 1); + } + } + }), + template: 'foo-bar' + }); + + return this.visit('/').then(function () { + _emberMetal.run(function () { + componentInstance.send('transitionToDynamic'); + }); + + assert.equal(_this6.routerService.get('currentRouteName'), 'dynamic'); + assert.equal(_this6.routerService.get('currentURL'), '/dynamic/1'); + _this6.assertText('much dynamicism'); + }); + }; + + babelHelpers.createClass(_class, [{ + key: 'routerOptions', + get: function () { + return { + location: 'test' + }; + } + }]); + return _class; + })(_internalTestHelpers.RouterTestCase)); + } +}); +enifed('ember/tests/routing/router_service_test/transitionTo_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/router_service_test/transitionTo_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/router_service_test/transitionTo_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/substates_test', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-glimmer'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberViews, _emberGlimmer) { + 'use strict'; + + var Router = undefined, + App = undefined, + templates = undefined, + router = undefined, + container = undefined, + counter = undefined; + + function step(expectedValue, description) { + equal(counter, expectedValue, 'Step ' + expectedValue + ': ' + description); + counter++; + } + + function bootApplication(startingURL) { + for (var _name in templates) { + _emberGlimmer.setTemplate(_name, _emberTemplateCompiler.compile(templates[_name])); + } + + if (startingURL) { + _emberRouting.NoneLocation.reopen({ + path: startingURL + }); + } + + startingURL = startingURL || ''; + router = container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + QUnit.module('Loading/Error Substates', { + setup: function () { + counter = 1; + + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture', + // fake a modules resolver + Resolver: _emberApplication.Resolver.extend({ moduleBasedResolver: true }) + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + Router = App.Router; + + container = App.__container__; + + templates = { + application: '
    {{outlet}}
    ', + index: 'INDEX', + loading: 'LOADING', + bro: 'BRO', + sis: 'SIS' + }; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + + _emberGlimmer.setTemplates({}); + }); + + _emberRouting.NoneLocation.reopen({ + path: '' + }); + } + }); + + QUnit.test('Slow promise from a child route of application enters nested loading state', function () { + var broModel = {}; + var broDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('bro'); + }); + + App.ApplicationRoute = _emberRouting.Route.extend({ + setupController: function () { + step(2, 'ApplicationRoute#setup'); + } + }); + + App.BroRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'BroRoute#model'); + return broDeferred.promise; + } + }); + + bootApplication('/bro'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'LOADING', 'The Loading template is nested in application template\'s outlet'); + + _emberMetal.run(broDeferred, 'resolve', broModel); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'BRO', 'bro template has loaded and replaced loading template'); + }); + + QUnit.test('Slow promises waterfall on startup', function () { + expect(7); + + var grandmaDeferred = _emberRuntime.RSVP.defer(); + var sallyDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + templates.grandma = 'GRANDMA {{outlet}}'; + templates.mom = 'MOM {{outlet}}'; + templates['mom/loading'] = 'MOMLOADING'; + templates['mom/sally'] = 'SALLY'; + + App.GrandmaRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'GrandmaRoute#model'); + return grandmaDeferred.promise; + } + }); + + App.MomRoute = _emberRouting.Route.extend({ + model: function () { + step(2, 'Mom#model'); + return {}; + } + }); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(3, 'SallyRoute#model'); + return sallyDeferred.promise; + }, + setupController: function () { + step(4, 'SallyRoute#setupController'); + } + }); + + bootApplication('/grandma/mom/sally'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'LOADING', 'The Loading template is nested in application template\'s outlet'); + + _emberMetal.run(grandmaDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM MOMLOADING', 'Mom\'s child loading route is displayed due to sally\'s slow promise'); + + _emberMetal.run(sallyDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM SALLY', 'Sally template displayed'); + }); + + QUnit.test('ApplicationRoute#currentPath reflects loading state path', function () { + expect(4); + + var momDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom'); + }); + }); + + templates.grandma = 'GRANDMA {{outlet}}'; + templates['grandma/loading'] = 'GRANDMALOADING'; + templates['grandma/mom'] = 'MOM'; + + App.GrandmaMomRoute = _emberRouting.Route.extend({ + model: function () { + return momDeferred.promise; + } + }); + + bootApplication('/grandma/mom'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA GRANDMALOADING'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.loading', 'currentPath reflects loading state'); + + _emberMetal.run(momDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM'); + equal(appController.get('currentPath'), 'grandma.mom', 'currentPath reflects final state'); + }); + + QUnit.test('Slow promises returned from ApplicationRoute#model don\'t enter LoadingRoute', function () { + expect(2); + + var appDeferred = _emberRuntime.RSVP.defer(); + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return appDeferred.promise; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + setupController: function () { + ok(false, 'shouldn\'t get here'); + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), '', 'nothing has been rendered yet'); + + _emberMetal.run(appDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Don\'t enter loading route unless either route or template defined', function () { + delete templates.loading; + + expect(2); + + var indexDeferred = _emberRuntime.RSVP.defer(); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + return indexDeferred.promise; + } + }); + + bootApplication(); + + var appController = container.lookup('controller:application'); + ok(appController.get('currentPath') !== 'loading', 'loading state not entered'); + + _emberMetal.run(indexDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Enter loading route if only LoadingRoute defined', function () { + delete templates.loading; + + expect(4); + + var indexDeferred = _emberRuntime.RSVP.defer(); + + App.IndexRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'IndexRoute#model'); + return indexDeferred.promise; + } + }); + + App.LoadingRoute = _emberRouting.Route.extend({ + setupController: function () { + step(2, 'LoadingRoute#setupController'); + } + }); + + bootApplication(); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'loading', 'loading state entered'); + + _emberMetal.run(indexDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Enter child loading state of pivot route', function () { + expect(4); + + var deferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + this.route('smells'); + }); + }); + + templates['grandma/loading'] = 'GMONEYLOADING'; + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + setupController: function () { + step(1, 'SallyRoute#setupController'); + } + }); + + App.GrandmaSmellsRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/grandma/mom/sally'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.mom.sally', 'Initial route fully loaded'); + + _emberMetal.run(router, 'transitionTo', 'grandma.smells'); + equal(appController.get('currentPath'), 'grandma.loading', 'in pivot route\'s child loading state'); + + _emberMetal.run(deferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.smells', 'Finished transition'); + }); + + QUnit.test('Loading actions bubble to root, but don\'t enter substates above pivot', function () { + expect(6); + + delete templates.loading; + + var sallyDeferred = _emberRuntime.RSVP.defer(); + var smellsDeferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + this.route('smells'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.ApplicationRoute = _emberRouting.Route.extend({ + actions: { + loading: function (transition, route) { + ok(true, 'loading action received on ApplicationRoute'); + } + } + }); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + return sallyDeferred.promise; + } + }); + + App.GrandmaSmellsRoute = _emberRouting.Route.extend({ + model: function () { + return smellsDeferred.promise; + } + }); + + bootApplication('/grandma/mom/sally'); + + var appController = container.lookup('controller:application'); + ok(!appController.get('currentPath'), 'Initial route fully loaded'); + _emberMetal.run(sallyDeferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.mom.sally', 'transition completed'); + + _emberMetal.run(router, 'transitionTo', 'grandma.smells'); + equal(appController.get('currentPath'), 'grandma.mom.sally', 'still in initial state because the only loading state is above the pivot route'); + + _emberMetal.run(smellsDeferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.smells', 'Finished transition'); + }); + + QUnit.test('Default error event moves into nested route', function () { + expect(6); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + templates['grandma/error'] = 'ERROR: {{model.msg}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function () { + step(2, 'MomSallyRoute#actions.error'); + return true; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + step(3, 'App finished booting'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA ERROR: did it broke?', 'error bubbles'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.error', 'Initial route fully loaded'); + }); + + QUnit.test('Error events that aren\'t bubbled don\t throw application assertions', function () { + expect(2); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + equal(err.msg, 'did it broke?'); + return false; + } + } + }); + + bootApplication('/grandma/mom/sally'); + }); + + QUnit.test('Non-bubbled errors that re-throw aren\'t swallowed', function () { + expect(2); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + // returns undefined which is falsey + throw err; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + }); + + QUnit.test('Handled errors that re-throw aren\'t swallowed', function () { + expect(4); + + var handledError = undefined; + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + this.route('this-route-throws'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + + handledError = err; + + this.transitionTo('mom.this-route-throws'); + + // Marks error as handled + return false; + } + } + }); + + App.MomThisRouteThrowsRoute = _emberRouting.Route.extend({ + model: function () { + step(3, 'MomThisRouteThrows#model'); + + throw handledError; + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + }); + + QUnit.test('Handled errors that bubble can be handled at a higher level', function () { + expect(4); + + var handledError = undefined; + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomRoute = _emberRouting.Route.extend({ + actions: { + error: function (err) { + step(3, 'MomRoute#error'); + + equal(err, handledError, 'error handled and rebubbled is handleable at heigher route'); + } + } + }); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + + handledError = err; + + return true; + } + } + }); + + bootApplication('/grandma/mom/sally'); + }); + + QUnit.test('errors that are bubbled are thrown at a higher level if not handled', function () { + expect(3); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + return true; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }, 'Correct error was thrown'); + }); + + QUnit.test('Handled errors that are thrown through rejection aren\'t swallowed', function () { + expect(4); + + var handledError = undefined; + + templates['grandma'] = 'GRANDMA {{outlet}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + this.route('this-route-throws'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function (err) { + step(2, 'MomSallyRoute#error'); + + handledError = err; + + this.transitionTo('mom.this-route-throws'); + + // Marks error as handled + return false; + } + } + }); + + App.MomThisRouteThrowsRoute = _emberRouting.Route.extend({ + model: function () { + step(3, 'MomThisRouteThrows#model'); + + return _emberRuntime.RSVP.reject(handledError); + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + }); + + QUnit.test('Setting a query param during a slow transition should work', function () { + var deferred = _emberRuntime.RSVP.defer(); + + Router.map(function () { + this.route('grandma', { path: '/grandma/:seg' }, function () {}); + }); + + templates['grandma/loading'] = 'GMONEYLOADING'; + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.IndexRoute = _emberRouting.Route.extend({ + beforeModel: function () { + this.transitionTo('grandma', 1); + } + }); + + App.GrandmaRoute = _emberRouting.Route.extend({ + queryParams: { + test: { defaultValue: 1 } + } + }); + + App.GrandmaIndexRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/'); + + var appController = container.lookup('controller:application'); + var grandmaController = container.lookup('controller:grandma'); + + equal(appController.get('currentPath'), 'grandma.loading', 'Initial route should be loading'); + + _emberMetal.run(function () { + grandmaController.set('test', 3); + }); + + equal(appController.get('currentPath'), 'grandma.loading', 'Route should still be loading'); + equal(grandmaController.get('test'), 3, 'Controller query param value should have changed'); + + _emberMetal.run(deferred, 'resolve', {}); + + equal(appController.get('currentPath'), 'grandma.index', 'Transition should be complete'); + }); + + QUnit.test('Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present', function () { + expect(2); + + var appDeferred = _emberRuntime.RSVP.defer(); + + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return appDeferred.promise; + } + }); + + var loadingRouteEntered = false; + App.ApplicationLoadingRoute = _emberRouting.Route.extend({ + setupController: function () { + loadingRouteEntered = true; + } + }); + + bootApplication(); + + ok(loadingRouteEntered, 'ApplicationLoadingRoute was entered'); + + _emberMetal.run(appDeferred, 'resolve', {}); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Slow promises returned from ApplicationRoute#model enter application_loading if template present', function () { + expect(3); + + templates['application_loading'] = '
    TOPLEVEL LOADING
    '; + + var appDeferred = _emberRuntime.RSVP.defer(); + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + return appDeferred.promise; + } + }); + + bootApplication(); + + equal(_emberViews.jQuery('#qunit-fixture #toplevel-loading').text(), 'TOPLEVEL LOADING'); + + _emberMetal.run(appDeferred, 'resolve', {}); + + equal(_emberViews.jQuery('#toplevel-loading', '#qunit-fixture').length, 0, 'top-level loading View has been entirely removed from DOM'); + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); + + QUnit.test('Default error event moves into nested route, prioritizing more specifically named error route', function () { + expect(6); + + templates['grandma'] = 'GRANDMA {{outlet}}'; + templates['grandma/error'] = 'ERROR: {{model.msg}}'; + templates['mom_error'] = 'MOM ERROR: {{model.msg}}'; + + Router.map(function () { + this.route('grandma', function () { + this.route('mom', { resetNamespace: true }, function () { + this.route('sally'); + }); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.MomSallyRoute = _emberRouting.Route.extend({ + model: function () { + step(1, 'MomSallyRoute#model'); + + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + }, + actions: { + error: function () { + step(2, 'MomSallyRoute#actions.error'); + return true; + } + } + }); + + throws(function () { + bootApplication('/grandma/mom/sally'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + step(3, 'App finished booting'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM ERROR: did it broke?', 'the more specifically-named mom error substate was entered over the other error route'); + + var appController = container.lookup('controller:application'); + equal(appController.get('currentPath'), 'grandma.mom_error', 'Initial route fully loaded'); + }); + + QUnit.test('Prioritized substate entry works with preserved-namespace nested routes', function () { + expect(2); + + templates['foo/bar_loading'] = 'FOOBAR LOADING'; + templates['foo/bar/index'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar', { path: '/bar' }, function () {}); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.FooBarRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/foo/bar'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOOBAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized substate entry works with reset-namespace nested routes', function () { + expect(2); + + templates['bar_loading'] = 'BAR LOADING'; + templates['bar/index'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar', { path: '/bar', resetNamespace: true }, function () {}); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.BarRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/foo/bar'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'BAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized loading substate entry works with preserved-namespace nested routes', function () { + expect(2); + + templates['foo/bar_loading'] = 'FOOBAR LOADING'; + templates['foo/bar'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.FooBarRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + + bootApplication('/foo/bar'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOOBAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized error substate entry works with preserved-namespace nested routes', function () { + expect(2); + + templates['foo/bar_error'] = 'FOOBAR ERROR: {{model.msg}}'; + templates['foo/bar'] = 'YAY'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.FooBarRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + } + }); + + throws(function () { + bootApplication('/foo/bar'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOOBAR ERROR: did it broke?', 'foo.bar_error was entered (as opposed to something like foo/foo/bar_error)'); + }); + + QUnit.test('Prioritized loading substate entry works with auto-generated index routes', function () { + expect(2); + + templates['foo/index_loading'] = 'FOO LOADING'; + templates['foo/index'] = 'YAY'; + templates['foo'] = '{{outlet}}'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + var deferred = _emberRuntime.RSVP.defer(); + App.FooIndexRoute = _emberRouting.Route.extend({ + model: function () { + return deferred.promise; + } + }); + App.FooRoute = _emberRouting.Route.extend({ + model: function () { + return true; + } + }); + + bootApplication('/foo'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOO LOADING', 'foo.index_loading was entered'); + + _emberMetal.run(deferred, 'resolve'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'YAY'); + }); + + QUnit.test('Prioritized error substate entry works with auto-generated index routes', function () { + expect(2); + + templates['foo/index_error'] = 'FOO ERROR: {{model.msg}}'; + templates['foo/index'] = 'YAY'; + templates['foo'] = '{{outlet}}'; + + Router.map(function () { + this.route('foo', function () { + this.route('bar'); + }); + }); + + App.ApplicationController = _emberRuntime.Controller.extend(); + + App.FooIndexRoute = _emberRouting.Route.extend({ + model: function () { + return _emberRuntime.RSVP.reject({ + msg: 'did it broke?' + }); + } + }); + App.FooRoute = _emberRouting.Route.extend({ + model: function () { + return true; + } + }); + + throws(function () { + return bootApplication('/foo'); + }, function (err) { + return err.msg === 'did it broke?'; + }); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'FOO ERROR: did it broke?', 'foo.index_error was entered'); + }); + + QUnit.test('Rejected promises returned from ApplicationRoute transition into top-level application_error', function () { + expect(3); + + templates['application_error'] = '

    TOPLEVEL ERROR: {{model.msg}}

    '; + + var reject = true; + App.ApplicationRoute = _emberRouting.Route.extend({ + model: function () { + if (reject) { + return _emberRuntime.RSVP.reject({ msg: 'BAD NEWS BEARS' }); + } else { + return {}; + } + } + }); + + throws(function () { + return bootApplication(); + }, function (err) { + return err.msg === 'BAD NEWS BEARS'; + }); + + equal(_emberViews.jQuery('#toplevel-error', '#qunit-fixture').text(), 'TOPLEVEL ERROR: BAD NEWS BEARS'); + + reject = false; + _emberMetal.run(router, 'transitionTo', 'index'); + + equal(_emberViews.jQuery('#app', '#qunit-fixture').text(), 'INDEX'); + }); +}); +enifed('ember/tests/routing/substates_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/substates_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/substates_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/routing/toplevel_dom_test', ['exports', 'ember-metal', 'ember-template-compiler', 'ember-application', 'ember-views', 'ember-routing', 'ember-glimmer'], function (exports, _emberMetal, _emberTemplateCompiler, _emberApplication, _emberViews, _emberRouting, _emberGlimmer) { + 'use strict'; + + var App = undefined, + templates = undefined, + container = undefined; + + function bootApplication() { + for (var _name in templates) { + _emberGlimmer.setTemplate(_name, _emberTemplateCompiler.compile(templates[_name])); + } + container.lookup('router:main'); + _emberMetal.run(App, 'advanceReadiness'); + } + + QUnit.module('Top Level DOM Structure', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + name: 'App', + rootElement: '#qunit-fixture' + }); + + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + + container = App.__container__; + + templates = { + application: 'hello world' + }; + }); + }, + + teardown: function () { + _emberMetal.run(function () { + App.destroy(); + App = null; + _emberGlimmer.setTemplates({}); + }); + + _emberRouting.NoneLocation.reopen({ + path: '' + }); + } + }); + + QUnit.test('Topmost template always get an element', function () { + bootApplication(); + equal(_emberViews.jQuery('#qunit-fixture > .ember-view').text(), 'hello world'); + }); +}); +enifed('ember/tests/routing/toplevel_dom_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/routing/toplevel_dom_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/routing/toplevel_dom_test.js should pass ESLint\n\n'); + }); +}); +enifed('ember/tests/view_instrumentation_test', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-template-compiler', 'ember-glimmer'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberTemplateCompiler, _emberGlimmer) { + 'use strict'; + + var App = undefined, + $fixture = undefined; + + function setupExample() { + // setup templates + _emberGlimmer.setTemplate('application', _emberTemplateCompiler.compile('{{outlet}}')); + _emberGlimmer.setTemplate('index', _emberTemplateCompiler.compile('

    Index

    ')); + _emberGlimmer.setTemplate('posts', _emberTemplateCompiler.compile('

    Posts

    ')); + + App.Router.map(function () { + this.route('posts'); + }); + } + + function handleURL(path) { + var router = App.__container__.lookup('router:main'); + return _emberMetal.run(router, 'handleURL', path); + } + + QUnit.module('View Instrumentation', { + setup: function () { + _emberMetal.run(function () { + App = _emberApplication.Application.create({ + rootElement: '#qunit-fixture' + }); + App.deferReadiness(); + + App.Router.reopen({ + location: 'none' + }); + }); + + $fixture = _emberViews.jQuery('#qunit-fixture'); + setupExample(); + }, + + teardown: function () { + _emberMetal.instrumentationReset(); + _emberMetal.run(App, 'destroy'); + App = null; + _emberGlimmer.setTemplates({}); + } + }); + + QUnit.test('Nodes without view instances are instrumented', function (assert) { + var called = false; + _emberMetal.instrumentationSubscribe('render', { + before: function () { + called = true; + }, + after: function () {} + }); + _emberMetal.run(App, 'advanceReadiness'); + assert.equal($fixture.text(), 'Index', 'It rendered the right template'); + assert.ok(called, 'Instrumentation called on first render'); + called = false; + handleURL('/posts'); + assert.equal($fixture.text(), 'Posts', 'It rendered the right template'); + assert.ok(called, 'instrumentation called on transition to non-view backed route'); + }); +}); +enifed('ember/tests/view_instrumentation_test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | ember/tests/view_instrumentation_test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'ember/tests/view_instrumentation_test.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/apply-mixins.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/apply-mixins.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/apply-mixins.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/build-owner.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/build-owner.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/build-owner.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/confirm-export.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/confirm-export.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/confirm-export.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/equal-inner-html.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/equal-inner-html.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/equal-inner-html.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/equal-tokens.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/equal-tokens.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/equal-tokens.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/factory.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/factory.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/factory.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/index.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/index.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/index.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/matchers.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/matchers.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/matchers.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/module-for.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/module-for.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/module-for.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/run.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/run.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/run.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/strip.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/strip.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/strip.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/abstract-application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/abstract-application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/abstract-application.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/abstract-rendering.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/abstract-rendering.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/abstract-rendering.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/abstract.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/abstract.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/abstract.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/application.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/application.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/application.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/query-param.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/query-param.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/query-param.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/rendering.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/rendering.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/rendering.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-cases/router.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-cases/router.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-cases/router.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/test-groups.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/test-groups.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/test-groups.js should pass ESLint\n\n'); + }); +}); +enifed('internal-test-helpers/tests/index-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('internal-test-helpers'); + + QUnit.test('module present', function (assert) { + assert.ok(true, 'each package needs at least one test to be able to run through `npm test`'); + }); +}); +enifed('internal-test-helpers/tests/index-test.lint-test', ['exports'], function (exports) { + 'use strict'; + + QUnit.module('ESLint | internal-test-helpers/tests/index-test.js'); + QUnit.test('should pass ESLint', function (assert) { + assert.expect(1); + assert.ok(true, 'internal-test-helpers/tests/index-test.js should pass ESLint\n\n'); + }); +}); +}()); diff --git a/ember.debug.js b/ember.debug.js index 066dd3dbd..3013033c6 100644 --- a/ember.debug.js +++ b/ember.debug.js @@ -1,15 +1,16 @@ ;(function() { /*! * @overview Ember - JavaScript Application Framework - * @copyright Copyright 2011-2016 Tilde Inc. and contributors + * @copyright Copyright 2011-2017 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.12.0-canary */ var enifed, requireModule, Ember; +var mainContext = this; // Used in ember-environment/lib/global.js (function() { var isNode = typeof window === 'undefined' && @@ -183,54795 +184,46183 @@ babelHelpers = { defaults: defaults }; -enifed('backburner', ['exports'], function (exports) { 'use strict'; - -var NUMBER = /\d+/; +enifed('@glimmer/node', ['exports', '@glimmer/runtime'], function (exports, _glimmerRuntime) { + 'use strict'; -function each(collection, callback) { - for (var i = 0; i < collection.length; i++) { - callback(collection[i]); - } -} + var NodeDOMTreeConstruction = (function (_DOMTreeConstruction) { + babelHelpers.inherits(NodeDOMTreeConstruction, _DOMTreeConstruction); -function isString(suspect) { - return typeof suspect === 'string'; -} + function NodeDOMTreeConstruction(doc) { + _DOMTreeConstruction.call(this, doc); + } -function isFunction(suspect) { - return typeof suspect === 'function'; -} + // override to prevent usage of `this.document` until after the constructor -function isNumber(suspect) { - return typeof suspect === 'number'; -} + NodeDOMTreeConstruction.prototype.setupUselessElement = function setupUselessElement() {}; -function isCoercableNumber(number) { - return isNumber(number) || NUMBER.test(number); -} + NodeDOMTreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { + var prev = reference ? reference.previousSibling : parent.lastChild; + var raw = this.document.createRawHTMLSection(html); + parent.insertBefore(raw, reference); + var first = prev ? prev.nextSibling : parent.firstChild; + var last = reference ? reference.previousSibling : parent.lastChild; + return new _glimmerRuntime.ConcreteBounds(parent, first, last); + }; -function binarySearch(time, timers) { - var start = 0; - var end = timers.length - 2; - var middle, l; + // override to avoid SVG detection/work when in node (this is not needed in SSR) - while (start < end) { - // since timers is an array of pairs 'l' will always - // be an integer - l = (end - start) / 2; + NodeDOMTreeConstruction.prototype.createElement = function createElement(tag) { + return this.document.createElement(tag); + }; - // compensate for the index in case even number - // of pairs inside timers - middle = start + l - (l % 2); + // override to avoid namespace shenanigans when in node (this is not needed in SSR) - if (time >= timers[middle]) { - start = middle + 2; - } else { - end = middle; - } - } + NodeDOMTreeConstruction.prototype.setAttribute = function setAttribute(element, name, value) { + element.setAttribute(name, value); + }; - return (time >= timers[start]) ? start + 2 : start; -} + return NodeDOMTreeConstruction; + })(_glimmerRuntime.DOMTreeConstruction); -function Queue(name, options, globalOptions) { - this.name = name; - this.globalOptions = globalOptions || {}; - this.options = options; - this._queue = []; - this.targetQueues = {}; - this._queueBeingFlushed = undefined; -} + exports.NodeDOMTreeConstruction = NodeDOMTreeConstruction; +}); +enifed("@glimmer/reference", ["exports", "@glimmer/util"], function (exports, _glimmerUtil) { + "use strict"; -Queue.prototype = { - push: function(target, method, args, stack) { - var queue = this._queue; - queue.push(target, method, args, stack); + var CONSTANT = 0; + var INITIAL = 1; + var VOLATILE = NaN; - return { - queue: this, - target: target, - method: method - }; - }, + var RevisionTag = (function () { + function RevisionTag() {} - pushUniqueWithoutGuid: function(target, method, args, stack) { - var queue = this._queue; + RevisionTag.prototype.validate = function validate(snapshot) { + return this.value() === snapshot; + }; - for (var i = 0, l = queue.length; i < l; i += 4) { - var currentTarget = queue[i]; - var currentMethod = queue[i+1]; + return RevisionTag; + })(); - if (currentTarget === target && currentMethod === method) { - queue[i+2] = args; // replace args - queue[i+3] = stack; // replace stack - return; - } - } + var $REVISION = INITIAL; - queue.push(target, method, args, stack); - }, + var DirtyableTag = (function (_RevisionTag) { + babelHelpers.inherits(DirtyableTag, _RevisionTag); - targetQueue: function(targetQueue, target, method, args, stack) { - var queue = this._queue; + function DirtyableTag() { + var revision = arguments.length <= 0 || arguments[0] === undefined ? $REVISION : arguments[0]; - for (var i = 0, l = targetQueue.length; i < l; i += 2) { - var currentMethod = targetQueue[i]; - var currentIndex = targetQueue[i + 1]; + _RevisionTag.call(this); + this.revision = revision; + } - if (currentMethod === method) { - queue[currentIndex + 2] = args; // replace args - queue[currentIndex + 3] = stack; // replace stack - return; - } - } + DirtyableTag.prototype.value = function value() { + return this.revision; + }; - targetQueue.push( - method, - queue.push(target, method, args, stack) - 4 - ); - }, + DirtyableTag.prototype.dirty = function dirty() { + this.revision = ++$REVISION; + }; - pushUniqueWithGuid: function(guid, target, method, args, stack) { - var hasLocalQueue = this.targetQueues[guid]; + return DirtyableTag; + })(RevisionTag); - if (hasLocalQueue) { - this.targetQueue(hasLocalQueue, target, method, args, stack); - } else { - this.targetQueues[guid] = [ - method, - this._queue.push(target, method, args, stack) - 4 - ]; + function combineTagged(tagged) { + var optimized = []; + for (var i = 0, l = tagged.length; i < l; i++) { + var tag = tagged[i].tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function combineSlice(slice) { + var optimized = []; + var node = slice.head(); + while (node !== null) { + var tag = node.tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag !== CONSTANT_TAG) optimized.push(tag); + node = slice.nextNode(node); + } + return _combine(optimized); + } + function combine(tags) { + var optimized = []; + for (var i = 0, l = tags.length; i < l; i++) { + var tag = tags[i]; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function _combine(tags) { + switch (tags.length) { + case 0: + return CONSTANT_TAG; + case 1: + return tags[0]; + case 2: + return new TagsPair(tags[0], tags[1]); + default: + return new TagsCombinator(tags); + } + ; } - return { - queue: this, - target: target, - method: method - }; - }, + var CachedTag = (function (_RevisionTag2) { + babelHelpers.inherits(CachedTag, _RevisionTag2); - pushUnique: function(target, method, args, stack) { - var KEY = this.globalOptions.GUID_KEY; + function CachedTag() { + _RevisionTag2.apply(this, arguments); + this.lastChecked = null; + this.lastValue = null; + } - if (target && KEY) { - var guid = target[KEY]; - if (guid) { - return this.pushUniqueWithGuid(guid, target, method, args, stack); - } - } + CachedTag.prototype.value = function value() { + var lastChecked = this.lastChecked; + var lastValue = this.lastValue; - this.pushUniqueWithoutGuid(target, method, args, stack); + if (lastChecked !== $REVISION) { + this.lastChecked = $REVISION; + this.lastValue = lastValue = this.compute(); + } + return this.lastValue; + }; - return { - queue: this, - target: target, - method: method - }; - }, + CachedTag.prototype.invalidate = function invalidate() { + this.lastChecked = null; + }; - invoke: function(target, method, args /*, onError, errorRecordedForStack */) { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - }, + return CachedTag; + })(RevisionTag); - invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { - try { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - } catch(error) { - onError(error, errorRecordedForStack); - } - }, + var TagsPair = (function (_CachedTag) { + babelHelpers.inherits(TagsPair, _CachedTag); - flush: function(sync) { - var queue = this._queue; - var length = queue.length; + function TagsPair(first, second) { + _CachedTag.call(this); + this.first = first; + this.second = second; + } - if (length === 0) { - return; - } + TagsPair.prototype.compute = function compute() { + return Math.max(this.first.value(), this.second.value()); + }; - var globalOptions = this.globalOptions; - var options = this.options; - var before = options && options.before; - var after = options && options.after; - var onError = globalOptions.onError || (globalOptions.onErrorTarget && - globalOptions.onErrorTarget[globalOptions.onErrorMethod]); - var target, method, args, errorRecordedForStack; - var invoke = onError ? this.invokeWithOnError : this.invoke; + return TagsPair; + })(CachedTag); - this.targetQueues = Object.create(null); - var queueItems = this._queueBeingFlushed = this._queue.slice(); - this._queue = []; + var TagsCombinator = (function (_CachedTag2) { + babelHelpers.inherits(TagsCombinator, _CachedTag2); - if (before) { - before(); - } + function TagsCombinator(tags) { + _CachedTag2.call(this); + this.tags = tags; + } - for (var i = 0; i < length; i += 4) { - target = queueItems[i]; - method = queueItems[i+1]; - args = queueItems[i+2]; - errorRecordedForStack = queueItems[i+3]; // Debugging assistance + TagsCombinator.prototype.compute = function compute() { + var tags = this.tags; - if (isString(method)) { - method = target[method]; - } + var max = -1; + for (var i = 0; i < tags.length; i++) { + var value = tags[i].value(); + max = Math.max(value, max); + } + return max; + }; - // method could have been nullified / canceled during flush - if (method) { - // - // ** Attention intrepid developer ** - // - // To find out the stack of this task when it was scheduled onto - // the run loop, add the following to your app.js: - // - // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. - // - // Once that is in place, when you are at a breakpoint and navigate - // here in the stack explorer, you can look at `errorRecordedForStack.stack`, - // which will be the captured stack when this job was scheduled. - // - // One possible long-term solution is the following Chrome issue: - // https://bugs.chromium.org/p/chromium/issues/detail?id=332624 - // - invoke(target, method, args, onError, errorRecordedForStack); - } - } + return TagsCombinator; + })(CachedTag); - if (after) { - after(); - } + var UpdatableTag = (function (_CachedTag3) { + babelHelpers.inherits(UpdatableTag, _CachedTag3); - this._queueBeingFlushed = undefined; + function UpdatableTag(tag) { + _CachedTag3.call(this); + this.tag = tag; + this.lastUpdated = INITIAL; + } - if (sync !== false && - this._queue.length > 0) { - // check if new items have been added - this.flush(true); - } - }, + ////////// - cancel: function(actionToCancel) { - var queue = this._queue, currentTarget, currentMethod, i, l; - var target = actionToCancel.target; - var method = actionToCancel.method; - var GUID_KEY = this.globalOptions.GUID_KEY; + UpdatableTag.prototype.compute = function compute() { + return Math.max(this.lastUpdated, this.tag.value()); + }; - if (GUID_KEY && this.targetQueues && target) { - var targetQueue = this.targetQueues[target[GUID_KEY]]; + UpdatableTag.prototype.update = function update(tag) { + if (tag !== this.tag) { + this.tag = tag; + this.lastUpdated = $REVISION; + this.invalidate(); + } + }; - if (targetQueue) { - for (i = 0, l = targetQueue.length; i < l; i++) { - if (targetQueue[i] === method) { - targetQueue.splice(i, 1); - } + return UpdatableTag; + })(CachedTag); + + var CONSTANT_TAG = new ((function (_RevisionTag3) { + babelHelpers.inherits(ConstantTag, _RevisionTag3); + + function ConstantTag() { + _RevisionTag3.apply(this, arguments); } - } - } - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; + ConstantTag.prototype.value = function value() { + return CONSTANT; + }; - if (currentTarget === target && - currentMethod === method) { - queue.splice(i, 4); - return true; - } - } + return ConstantTag; + })(RevisionTag))(); + var VOLATILE_TAG = new ((function (_RevisionTag4) { + babelHelpers.inherits(VolatileTag, _RevisionTag4); - // if not found in current queue - // could be in the queue that is being flushed - queue = this._queueBeingFlushed; + function VolatileTag() { + _RevisionTag4.apply(this, arguments); + } - if (!queue) { - return; - } + VolatileTag.prototype.value = function value() { + return VOLATILE; + }; - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; + return VolatileTag; + })(RevisionTag))(); + var CURRENT_TAG = new ((function (_DirtyableTag) { + babelHelpers.inherits(CurrentTag, _DirtyableTag); - if (currentTarget === target && - currentMethod === method) { - // don't mess with array during flush - // just nullify the method - queue[i+1] = null; - return true; - } - } - } -}; + function CurrentTag() { + _DirtyableTag.apply(this, arguments); + } -function DeferredActionQueues(queueNames, options) { - var queues = this.queues = {}; - this.queueNames = queueNames = queueNames || []; + CurrentTag.prototype.value = function value() { + return $REVISION; + }; - this.options = options; + return CurrentTag; + })(DirtyableTag))(); - each(queueNames, function(queueName) { - queues[queueName] = new Queue(queueName, options[queueName], options); - }); -} + var CachedReference = (function () { + function CachedReference() { + this.lastRevision = null; + this.lastValue = null; + } -function noSuchQueue(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist'); -} + CachedReference.prototype.value = function value() { + var tag = this.tag; + var lastRevision = this.lastRevision; + var lastValue = this.lastValue; -function noSuchMethod(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist'); -} + if (!lastRevision || !tag.validate(lastRevision)) { + lastValue = this.lastValue = this.compute(); + this.lastRevision = tag.value(); + } + return lastValue; + }; -DeferredActionQueues.prototype = { - schedule: function(name, target, method, args, onceFlag, stack) { - var queues = this.queues; - var queue = queues[name]; + CachedReference.prototype.invalidate = function invalidate() { + this.lastRevision = null; + }; - if (!queue) { - noSuchQueue(name); - } + return CachedReference; + })(); - if (!method) { - noSuchMethod(name); - } + var MapperReference = (function (_CachedReference) { + babelHelpers.inherits(MapperReference, _CachedReference); - if (onceFlag) { - return queue.pushUnique(target, method, args, stack); - } else { - return queue.push(target, method, args, stack); - } - }, + function MapperReference(reference, mapper) { + _CachedReference.call(this); + this.tag = reference.tag; + this.reference = reference; + this.mapper = mapper; + } - flush: function() { - var queues = this.queues; - var queueNames = this.queueNames; - var queueName, queue; - var queueNameIndex = 0; - var numberOfQueues = queueNames.length; + MapperReference.prototype.compute = function compute() { + var reference = this.reference; + var mapper = this.mapper; - while (queueNameIndex < numberOfQueues) { - queueName = queueNames[queueNameIndex]; - queue = queues[queueName]; + return mapper(reference.value()); + }; - var numberOfQueueItems = queue._queue.length; + return MapperReference; + })(CachedReference); - if (numberOfQueueItems === 0) { - queueNameIndex++; - } else { - queue.flush(false /* async */); - queueNameIndex = 0; - } + function map(reference, mapper) { + return new MapperReference(reference, mapper); } - } -}; - -function Backburner(queueNames, options) { - this.queueNames = queueNames; - this.options = options || {}; - if (!this.options.defaultQueue) { - this.options.defaultQueue = queueNames[0]; - } - this.instanceStack = []; - this._debouncees = []; - this._throttlers = []; - this._eventCallbacks = { - end: [], - begin: [] - }; - - var _this = this; - this._boundClearItems = function() { - clearItems(); - }; - - this._timerTimeoutId = undefined; - this._timers = []; + ////////// - this._platform = this.options._platform || { - setTimeout: function (fn, ms) { - return setTimeout(fn, ms); - }, - clearTimeout: function (id) { - clearTimeout(id); - } - }; + var ReferenceCache = (function () { + function ReferenceCache(reference) { + this.lastValue = null; + this.lastRevision = null; + this.initialized = false; + this.tag = reference.tag; + this.reference = reference; + } - this._boundRunExpiredTimers = function () { - _this._runExpiredTimers(); - }; -} + ReferenceCache.prototype.peek = function peek() { + if (!this.initialized) { + return this.initialize(); + } + return this.lastValue; + }; -Backburner.prototype = { - begin: function() { - var options = this.options; - var onBegin = options && options.onBegin; - var previousInstance = this.currentInstance; + ReferenceCache.prototype.revalidate = function revalidate() { + if (!this.initialized) { + return this.initialize(); + } + var reference = this.reference; + var lastRevision = this.lastRevision; - if (previousInstance) { - this.instanceStack.push(previousInstance); - } + var tag = reference.tag; + if (tag.validate(lastRevision)) return NOT_MODIFIED; + this.lastRevision = tag.value(); + var lastValue = this.lastValue; - this.currentInstance = new DeferredActionQueues(this.queueNames, options); - this._trigger('begin', this.currentInstance, previousInstance); - if (onBegin) { - onBegin(this.currentInstance, previousInstance); - } - }, + var value = reference.value(); + if (value === lastValue) return NOT_MODIFIED; + this.lastValue = value; + return value; + }; - end: function() { - var options = this.options; - var onEnd = options && options.onEnd; - var currentInstance = this.currentInstance; - var nextInstance = null; + ReferenceCache.prototype.initialize = function initialize() { + var reference = this.reference; - // Prevent double-finally bug in Safari 6.0.2 and iOS 6 - // This bug appears to be resolved in Safari 6.0.5 and iOS 7 - var finallyAlreadyCalled = false; - try { - currentInstance.flush(); - } finally { - if (!finallyAlreadyCalled) { - finallyAlreadyCalled = true; + var value = this.lastValue = reference.value(); + this.lastRevision = reference.tag.value(); + this.initialized = true; + return value; + }; - this.currentInstance = null; + return ReferenceCache; + })(); - if (this.instanceStack.length) { - nextInstance = this.instanceStack.pop(); - this.currentInstance = nextInstance; - } - this._trigger('end', currentInstance, nextInstance); - if (onEnd) { - onEnd(currentInstance, nextInstance); - } - } + var NOT_MODIFIED = "adb3b78e-3d22-4e4b-877a-6317c2c5c145"; + function isModified(value) { + return value !== NOT_MODIFIED; } - }, - /** - Trigger an event. Supports up to two arguments. Designed around - triggering transition events from one run loop instance to the - next, which requires an argument for the first instance and then - an argument for the next instance. + var ConstReference = (function () { + function ConstReference(inner) { + this.inner = inner; + this.tag = CONSTANT_TAG; + } - @private - @method _trigger - @param {String} eventName - @param {any} arg1 - @param {any} arg2 - */ - _trigger: function(eventName, arg1, arg2) { - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - for (var i = 0; i < callbacks.length; i++) { - callbacks[i](arg1, arg2); - } - } - }, + ConstReference.prototype.value = function value() { + return this.inner; + }; - on: function(eventName, callback) { - if (typeof callback !== 'function') { - throw new TypeError('Callback must be a function'); - } - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - callbacks.push(callback); - } else { - throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist'); - } - }, + return ConstReference; + })(); - off: function(eventName, callback) { - if (eventName) { - var callbacks = this._eventCallbacks[eventName]; - var callbackFound = false; - if (!callbacks) return; - if (callback) { - for (var i = 0; i < callbacks.length; i++) { - if (callbacks[i] === callback) { - callbackFound = true; - callbacks.splice(i, 1); - i--; - } - } - } - if (!callbackFound) { - throw new TypeError('Cannot off() callback that does not exist'); - } - } else { - throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist'); + function isConst(reference) { + return reference.tag === CONSTANT_TAG; } - }, - - run: function(/* target, method, args */) { - var length = arguments.length; - var method, target, args; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + var ListItem = (function (_ListNode) { + babelHelpers.inherits(ListItem, _ListNode); - if (isString(method)) { - method = target[method]; - } + function ListItem(iterable, result) { + _ListNode.call(this, iterable.valueReferenceFor(result)); + this.retained = false; + this.seen = false; + this.key = result.key; + this.iterable = iterable; + this.memo = iterable.memoReferenceFor(result); + } - if (length > 2) { - args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - } else { - args = []; - } + ListItem.prototype.update = function update(item) { + this.retained = true; + this.iterable.updateValueReference(this.value, item); + this.iterable.updateMemoReference(this.memo, item); + }; - var onError = getOnError(this.options); + ListItem.prototype.shouldRemove = function shouldRemove() { + return !this.retained; + }; - this.begin(); + ListItem.prototype.reset = function reset() { + this.retained = false; + this.seen = false; + }; - // guard against Safari 6's double-finally bug - var didFinally = false; + return ListItem; + })(_glimmerUtil.ListNode); - if (onError) { - try { - return method.apply(target, args); - } catch(error) { - onError(error); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); - } - } - } else { - try { - return method.apply(target, args); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); + var IterationArtifacts = (function () { + function IterationArtifacts(iterable) { + this.map = _glimmerUtil.dict(); + this.list = new _glimmerUtil.LinkedList(); + this.tag = iterable.tag; + this.iterable = iterable; } - } - } - }, - /* - Join the passed method with an existing queue and execute immediately, - if there isn't one use `Backburner#run`. + IterationArtifacts.prototype.isEmpty = function isEmpty() { + var iterator = this.iterator = this.iterable.iterate(); + return iterator.isEmpty(); + }; - The join method is like the run method except that it will schedule into - an existing queue if one already exists. In either case, the join method will - immediately execute the passed in function and return its result. + IterationArtifacts.prototype.iterate = function iterate() { + var iterator = this.iterator || this.iterable.iterate(); + this.iterator = null; + return iterator; + }; - @method join - @param {Object} target - @param {Function} method The method to be executed - @param {any} args The method arguments - @return method result - */ - join: function(/* target, method, args */) { - if (!this.currentInstance) { - return this.run.apply(this, arguments); - } + IterationArtifacts.prototype.has = function has(key) { + return !!this.map[key]; + }; - var length = arguments.length; - var method, target; + IterationArtifacts.prototype.get = function get(key) { + return this.map[key]; + }; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + IterationArtifacts.prototype.wasSeen = function wasSeen(key) { + var node = this.map[key]; + return node && node.seen; + }; - if (isString(method)) { - method = target[method]; - } + IterationArtifacts.prototype.append = function append(item) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - if (length === 1) { - return method(); - } else if (length === 2) { - return method.call(target); - } else { - var args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - return method.apply(target, args); - } - }, + var node = map[item.key] = new ListItem(iterable, item); + list.append(node); + return node; + }; + IterationArtifacts.prototype.insertBefore = function insertBefore(item, reference) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - /* - Defer the passed function to run inside the specified queue. + var node = map[item.key] = new ListItem(iterable, item); + node.retained = true; + list.insertBefore(node, reference); + return node; + }; - @method defer - @param {String} queueName - @param {Object} target - @param {Function|String} method The method or method name to be executed - @param {any} args The method arguments - @return method result - */ - defer: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + IterationArtifacts.prototype.move = function move(item, reference) { + var list = this.list; - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; - } + item.retained = true; + list.remove(item); + list.insertBefore(item, reference); + }; - if (isString(method)) { - method = target[method]; - } + IterationArtifacts.prototype.remove = function remove(item) { + var list = this.list; - var stack = this.DEBUG ? new Error() : undefined; + list.remove(item); + delete this.map[item.key]; + }; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + IterationArtifacts.prototype.nextNode = function nextNode(item) { + return this.list.nextNode(item); + }; - if (!this.currentInstance) { createAutorun(this); } - return this.currentInstance.schedule(queueName, target, method, args, false, stack); - }, + IterationArtifacts.prototype.head = function head() { + return this.list.head(); + }; - deferOnce: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + return IterationArtifacts; + })(); - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; - } + var ReferenceIterator = (function () { + // if anyone needs to construct this object with something other than + // an iterable, let @wycats know. - if (isString(method)) { - method = target[method]; - } + function ReferenceIterator(iterable) { + this.iterator = null; + var artifacts = new IterationArtifacts(iterable); + this.artifacts = artifacts; + } - var stack = this.DEBUG ? new Error() : undefined; + ReferenceIterator.prototype.next = function next() { + var artifacts = this.artifacts; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + var iterator = this.iterator = this.iterator || artifacts.iterate(); + var item = iterator.next(); + if (!item) return null; + return artifacts.append(item); + }; - if (!this.currentInstance) { - createAutorun(this); - } - return this.currentInstance.schedule(queueName, target, method, args, true, stack); - }, + return ReferenceIterator; + })(); - setTimeout: function() { - var l = arguments.length; - var args = new Array(l); + var Phase; + (function (Phase) { + Phase[Phase["Append"] = 0] = "Append"; + Phase[Phase["Prune"] = 1] = "Prune"; + Phase[Phase["Done"] = 2] = "Done"; + })(Phase || (Phase = {})); - for (var x = 0; x < l; x++) { - args[x] = arguments[x]; - } + var IteratorSynchronizer = (function () { + function IteratorSynchronizer(_ref) { + var target = _ref.target; + var artifacts = _ref.artifacts; - var length = args.length, - method, wait, target, - methodOrTarget, methodOrWait, methodOrArgs; + this.target = target; + this.artifacts = artifacts; + this.iterator = artifacts.iterate(); + this.current = artifacts.head(); + } - if (length === 0) { - return; - } else if (length === 1) { - method = args.shift(); - wait = 0; - } else if (length === 2) { - methodOrTarget = args[0]; - methodOrWait = args[1]; + IteratorSynchronizer.prototype.sync = function sync() { + var phase = Phase.Append; + while (true) { + switch (phase) { + case Phase.Append: + phase = this.nextAppend(); + break; + case Phase.Prune: + phase = this.nextPrune(); + break; + case Phase.Done: + this.nextDone(); + return; + } + } + }; - if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { - target = args.shift(); - method = args.shift(); - wait = 0; - } else if (isCoercableNumber(methodOrWait)) { - method = args.shift(); - wait = args.shift(); - } else { - method = args.shift(); - wait = 0; - } - } else { - var last = args[args.length - 1]; + IteratorSynchronizer.prototype.advanceToKey = function advanceToKey(key) { + var current = this.current; + var artifacts = this.artifacts; - if (isCoercableNumber(last)) { - wait = args.pop(); - } else { - wait = 0; - } + var seek = current; + while (seek && seek.key !== key) { + seek.seen = true; + seek = artifacts.nextNode(seek); + } + this.current = seek && artifacts.nextNode(seek); + }; - methodOrTarget = args[0]; - methodOrArgs = args[1]; + IteratorSynchronizer.prototype.nextAppend = function nextAppend() { + var iterator = this.iterator; + var current = this.current; + var artifacts = this.artifacts; - if (isFunction(methodOrArgs) || (isString(methodOrArgs) && - methodOrTarget !== null && - methodOrArgs in methodOrTarget)) { - target = args.shift(); - method = args.shift(); - } else { - method = args.shift(); - } - } - - var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); - - if (isString(method)) { - method = target[method]; - } - - var onError = getOnError(this.options); + var item = iterator.next(); + if (item === null) { + return this.startPrune(); + } + var key = item.key; - function fn() { - if (onError) { - try { - method.apply(target, args); - } catch (e) { - onError(e); - } - } else { - method.apply(target, args); - } - } + if (current && current.key === key) { + this.nextRetain(item); + } else if (artifacts.has(key)) { + this.nextMove(item); + } else { + this.nextInsert(item); + } + return Phase.Append; + }; - return this._setTimeout(fn, executeAt); - }, + IteratorSynchronizer.prototype.nextRetain = function nextRetain(item) { + var artifacts = this.artifacts; + var current = this.current; - _setTimeout: function (fn, executeAt) { - if (this._timers.length === 0) { - this._timers.push(executeAt, fn); - this._installTimerTimeout(); - return fn; - } + current = _glimmerUtil.expect(current, 'BUG: current is empty'); + current.update(item); + this.current = artifacts.nextNode(current); + this.target.retain(item.key, current.value, current.memo); + }; - // find position to insert - var i = binarySearch(executeAt, this._timers); + IteratorSynchronizer.prototype.nextMove = function nextMove(item) { + var current = this.current; + var artifacts = this.artifacts; + var target = this.target; + var key = item.key; - this._timers.splice(i, 0, executeAt, fn); + var found = artifacts.get(item.key); + found.update(item); + if (artifacts.wasSeen(item.key)) { + artifacts.move(found, current); + target.move(found.key, found.value, found.memo, current ? current.key : null); + } else { + this.advanceToKey(key); + } + }; - // we should be the new earliest timer if i == 0 - if (i === 0) { - this._reinstallTimerTimeout(); - } + IteratorSynchronizer.prototype.nextInsert = function nextInsert(item) { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - return fn; - }, + var node = artifacts.insertBefore(item, current); + target.insert(node.key, node.value, node.memo, current ? current.key : null); + }; - throttle: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } - var immediate = args.pop(); - var wait, throttler, index, timer; + IteratorSynchronizer.prototype.startPrune = function startPrune() { + this.current = this.artifacts.head(); + return Phase.Prune; + }; - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = true; - } else { - wait = args.pop(); - } + IteratorSynchronizer.prototype.nextPrune = function nextPrune() { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - wait = parseInt(wait, 10); + if (current === null) { + return Phase.Done; + } + var node = current; + this.current = artifacts.nextNode(node); + if (node.shouldRemove()) { + artifacts.remove(node); + target.delete(node.key); + } else { + node.reset(); + } + return Phase.Prune; + }; - index = findThrottler(target, method, this._throttlers); - if (index > -1) { return this._throttlers[index]; } // throttled + IteratorSynchronizer.prototype.nextDone = function nextDone() { + this.target.done(); + }; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findThrottler(target, method, backburner._throttlers); - if (index > -1) { - backburner._throttlers.splice(index, 1); - } - }, wait); + return IteratorSynchronizer; + })(); - if (immediate) { - this.run.apply(this, args); + function referenceFromParts(root, parts) { + var reference = root; + for (var i = 0; i < parts.length; i++) { + reference = reference.get(parts[i]); + } + return reference; } - throttler = [target, method, timer]; + exports.ConstReference = ConstReference; + exports.isConst = isConst; + exports.ListItem = ListItem; + exports.referenceFromParts = referenceFromParts; + exports.IterationArtifacts = IterationArtifacts; + exports.ReferenceIterator = ReferenceIterator; + exports.IteratorSynchronizer = IteratorSynchronizer; + exports.CONSTANT = CONSTANT; + exports.INITIAL = INITIAL; + exports.VOLATILE = VOLATILE; + exports.RevisionTag = RevisionTag; + exports.DirtyableTag = DirtyableTag; + exports.combineTagged = combineTagged; + exports.combineSlice = combineSlice; + exports.combine = combine; + exports.CachedTag = CachedTag; + exports.UpdatableTag = UpdatableTag; + exports.CONSTANT_TAG = CONSTANT_TAG; + exports.VOLATILE_TAG = VOLATILE_TAG; + exports.CURRENT_TAG = CURRENT_TAG; + exports.CachedReference = CachedReference; + exports.map = map; + exports.ReferenceCache = ReferenceCache; + exports.isModified = isModified; +}); +enifed('@glimmer/runtime',['exports','@glimmer/util','@glimmer/reference','@glimmer/wire-format'],function(exports,_glimmerUtil,_glimmerReference,_glimmerWireFormat){'use strict';var PrimitiveReference=(function(_ConstReference){babelHelpers.inherits(PrimitiveReference,_ConstReference);function PrimitiveReference(value){_ConstReference.call(this,value);}PrimitiveReference.create = function create(value){if(value === undefined){return UNDEFINED_REFERENCE;}else if(value === null){return NULL_REFERENCE;}else if(value === true){return TRUE_REFERENCE;}else if(value === false){return FALSE_REFERENCE;}else if(typeof value === 'number'){return new ValueReference(value);}else {return new StringReference(value);}};PrimitiveReference.prototype.get = function get(_key){return UNDEFINED_REFERENCE;};return PrimitiveReference;})(_glimmerReference.ConstReference);var StringReference=(function(_PrimitiveReference){babelHelpers.inherits(StringReference,_PrimitiveReference);function StringReference(){_PrimitiveReference.apply(this,arguments);this.lengthReference = null;}StringReference.prototype.get = function get(key){if(key === 'length'){var lengthReference=this.lengthReference;if(lengthReference === null){lengthReference = this.lengthReference = new ValueReference(this.inner.length);}return lengthReference;}else {return _PrimitiveReference.prototype.get.call(this,key);}};return StringReference;})(PrimitiveReference);var ValueReference=(function(_PrimitiveReference2){babelHelpers.inherits(ValueReference,_PrimitiveReference2);function ValueReference(value){_PrimitiveReference2.call(this,value);}return ValueReference;})(PrimitiveReference);var UNDEFINED_REFERENCE=new ValueReference(undefined);var NULL_REFERENCE=new ValueReference(null);var TRUE_REFERENCE=new ValueReference(true);var FALSE_REFERENCE=new ValueReference(false);var ConditionalReference=(function(){function ConditionalReference(inner){this.inner = inner;this.tag = inner.tag;}ConditionalReference.prototype.value = function value(){return this.toBool(this.inner.value());};ConditionalReference.prototype.toBool = function toBool(value){return !!value;};return ConditionalReference;})();var Constants=(function(){function Constants(){ // `0` means NULL +this.references = [];this.strings = [];this.expressions = [];this.arrays = [];this.slices = [];this.blocks = [];this.functions = [];this.others = [];this.NULL_REFERENCE = this.reference(NULL_REFERENCE);this.UNDEFINED_REFERENCE = this.reference(UNDEFINED_REFERENCE);}Constants.prototype.getReference = function getReference(value){return this.references[value - 1];};Constants.prototype.reference = function reference(value){var index=this.references.length;this.references.push(value);return index + 1;};Constants.prototype.getString = function getString(value){return this.strings[value - 1];};Constants.prototype.string = function string(value){var index=this.strings.length;this.strings.push(value);return index + 1;};Constants.prototype.getExpression = function getExpression(value){return this.expressions[value - 1];};Constants.prototype.expression = function expression(value){var index=this.expressions.length;this.expressions.push(value);return index + 1;};Constants.prototype.getArray = function getArray(value){return this.arrays[value - 1];};Constants.prototype.array = function array(values){var index=this.arrays.length;this.arrays.push(values);return index + 1;};Constants.prototype.getSlice = function getSlice(value){return this.slices[value - 1];};Constants.prototype.slice = function slice(_slice2){ // TODO: Put the entire program in one big array +var index=this.slices.length;this.slices.push(_slice2);return index + 1;};Constants.prototype.getBlock = function getBlock(value){return this.blocks[value - 1];};Constants.prototype.block = function block(_block2){var index=this.blocks.length;this.blocks.push(_block2);return index + 1;};Constants.prototype.getFunction = function getFunction(value){return this.functions[value - 1];};Constants.prototype.function = function _function(f){var index=this.functions.length;this.functions.push(f);return index + 1;};Constants.prototype.getOther = function getOther(value){return this.others[value - 1];};Constants.prototype.other = function other(_other){var index=this.others.length;this.others.push(_other);return index + 1;};return Constants;})();var AppendOpcodes=(function(){function AppendOpcodes(){this.evaluateOpcode = _glimmerUtil.fillNulls(51 /* EvaluatePartial */ + 1);}AppendOpcodes.prototype.add = function add(name,evaluate){this.evaluateOpcode[name] = evaluate;};AppendOpcodes.prototype.construct = function construct(name,_debug,op1,op2,op3){return [name | 0,(op1 || 0) | 0,(op2 || 0) | 0,(op3 || 0) | 0];};AppendOpcodes.prototype.evaluate = function evaluate(vm,opcode){_glimmerUtil.LOGGER.debug('[VM] OPCODE: ' + opcode.type);var func=this.evaluateOpcode[opcode.type];func(vm,opcode);};return AppendOpcodes;})();var APPEND_OPCODES=new AppendOpcodes();var AbstractOpcode=(function(){function AbstractOpcode(){_glimmerUtil.initializeGuid(this);}AbstractOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type};};return AbstractOpcode;})();var UpdatingOpcode=(function(_AbstractOpcode){babelHelpers.inherits(UpdatingOpcode,_AbstractOpcode);function UpdatingOpcode(){_AbstractOpcode.apply(this,arguments);this.next = null;this.prev = null;}return UpdatingOpcode;})(AbstractOpcode);APPEND_OPCODES.add(20, /* OpenBlock */function(vm,_ref){var _getBlock=_ref.op1;var _args=_ref.op2;var inner=vm.constants.getOther(_getBlock);var rawArgs=vm.constants.getExpression(_args);var args=null;var block=inner.evaluate(vm);if(block){args = rawArgs.evaluate(vm);} // FIXME: can we avoid doing this when we don't have a block? +vm.pushCallerScope();if(block){vm.invokeBlock(block,args || null);}});APPEND_OPCODES.add(21, /* CloseBlock */function(vm){return vm.popScope();});APPEND_OPCODES.add(0, /* PushChildScope */function(vm){return vm.pushChildScope();});APPEND_OPCODES.add(1, /* PopScope */function(vm){return vm.popScope();});APPEND_OPCODES.add(2, /* PushDynamicScope */function(vm){return vm.pushDynamicScope();});APPEND_OPCODES.add(3, /* PopDynamicScope */function(vm){return vm.popDynamicScope();});APPEND_OPCODES.add(4, /* Put */function(vm,_ref2){var reference=_ref2.op1;vm.frame.setOperand(vm.constants.getReference(reference));});APPEND_OPCODES.add(5, /* EvaluatePut */function(vm,_ref3){var expression=_ref3.op1;var expr=vm.constants.getExpression(expression);vm.evaluateOperand(expr);});APPEND_OPCODES.add(6, /* PutArgs */function(vm,_ref4){var args=_ref4.op1;vm.evaluateArgs(vm.constants.getExpression(args));});APPEND_OPCODES.add(7, /* BindPositionalArgs */function(vm,_ref5){var _symbols=_ref5.op1;var symbols=vm.constants.getArray(_symbols);vm.bindPositionalArgs(symbols);});APPEND_OPCODES.add(8, /* BindNamedArgs */function(vm,_ref6){var _names=_ref6.op1;var _symbols=_ref6.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindNamedArgs(names,symbols);});APPEND_OPCODES.add(9, /* BindBlocks */function(vm,_ref7){var _names=_ref7.op1;var _symbols=_ref7.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindBlocks(names,symbols);});APPEND_OPCODES.add(10, /* BindPartialArgs */function(vm,_ref8){var symbol=_ref8.op1;vm.bindPartialArgs(symbol);});APPEND_OPCODES.add(11, /* BindCallerScope */function(vm){return vm.bindCallerScope();});APPEND_OPCODES.add(12, /* BindDynamicScope */function(vm,_ref9){var _names=_ref9.op1;var names=vm.constants.getArray(_names);vm.bindDynamicScope(names);});APPEND_OPCODES.add(13, /* Enter */function(vm,_ref10){var slice=_ref10.op1;return vm.enter(slice);});APPEND_OPCODES.add(14, /* Exit */function(vm){return vm.exit();});APPEND_OPCODES.add(15, /* Evaluate */function(vm,_ref11){var _block=_ref11.op1;var block=vm.constants.getBlock(_block);var args=vm.frame.getArgs();vm.invokeBlock(block,args);});APPEND_OPCODES.add(16, /* Jump */function(vm,_ref12){var target=_ref12.op1;return vm.goto(target);});APPEND_OPCODES.add(17, /* JumpIf */function(vm,_ref13){var target=_ref13.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(18, /* JumpUnless */function(vm,_ref14){var target=_ref14.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(!reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(!cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});var ConstTest=function(ref,_env){return new _glimmerReference.ConstReference(!!ref.value());};var SimpleTest=function(ref,_env){return ref;};var EnvironmentTest=function(ref,env){return env.toConditionalReference(ref);};APPEND_OPCODES.add(19, /* Test */function(vm,_ref15){var _func=_ref15.op1;var operand=vm.frame.getOperand();var func=vm.constants.getFunction(_func);vm.frame.setCondition(func(operand,vm.env));});var Assert=(function(_UpdatingOpcode){babelHelpers.inherits(Assert,_UpdatingOpcode);function Assert(cache){_UpdatingOpcode.call(this);this.type = "assert";this.tag = cache.tag;this.cache = cache;}Assert.prototype.evaluate = function evaluate(vm){var cache=this.cache;if(_glimmerReference.isModified(cache.revalidate())){vm.throw();}};Assert.prototype.toJSON = function toJSON(){var type=this.type;var _guid=this._guid;var cache=this.cache;var expected=undefined;try{expected = JSON.stringify(cache.peek());}catch(e) {expected = String(cache.peek());}return {guid:_guid,type:type,args:[],details:{expected:expected}};};return Assert;})(UpdatingOpcode);var JumpIfNotModifiedOpcode=(function(_UpdatingOpcode2){babelHelpers.inherits(JumpIfNotModifiedOpcode,_UpdatingOpcode2);function JumpIfNotModifiedOpcode(tag,target){_UpdatingOpcode2.call(this);this.target = target;this.type = "jump-if-not-modified";this.tag = tag;this.lastRevision = tag.value();}JumpIfNotModifiedOpcode.prototype.evaluate = function evaluate(vm){var tag=this.tag;var target=this.target;var lastRevision=this.lastRevision;if(!vm.alwaysRevalidate && tag.validate(lastRevision)){vm.goto(target);}};JumpIfNotModifiedOpcode.prototype.didModify = function didModify(){this.lastRevision = this.tag.value();};JumpIfNotModifiedOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.target.inspect())]};};return JumpIfNotModifiedOpcode;})(UpdatingOpcode);var DidModifyOpcode=(function(_UpdatingOpcode3){babelHelpers.inherits(DidModifyOpcode,_UpdatingOpcode3);function DidModifyOpcode(target){_UpdatingOpcode3.call(this);this.target = target;this.type = "did-modify";this.tag = _glimmerReference.CONSTANT_TAG;}DidModifyOpcode.prototype.evaluate = function evaluate(){this.target.didModify();};return DidModifyOpcode;})(UpdatingOpcode);var LabelOpcode=(function(){function LabelOpcode(label){this.tag = _glimmerReference.CONSTANT_TAG;this.type = "label";this.label = null;this.prev = null;this.next = null;_glimmerUtil.initializeGuid(this);if(label)this.label = label;}LabelOpcode.prototype.evaluate = function evaluate(){};LabelOpcode.prototype.inspect = function inspect(){return this.label + ' [' + this._guid + ']';};LabelOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.inspect())]};};return LabelOpcode;})();var EMPTY_ARRAY=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze([]):[];var EMPTY_DICT=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze(_glimmerUtil.dict()):_glimmerUtil.dict();var CompiledPositionalArgs=(function(){function CompiledPositionalArgs(values){this.values = values;this.length = values.length;}CompiledPositionalArgs.create = function create(values){if(values.length){return new this(values);}else {return COMPILED_EMPTY_POSITIONAL_ARGS;}};CompiledPositionalArgs.empty = function empty(){return COMPILED_EMPTY_POSITIONAL_ARGS;};CompiledPositionalArgs.prototype.evaluate = function evaluate(vm){var values=this.values;var length=this.length;var references=new Array(length);for(var i=0;i < length;i++) {references[i] = values[i].evaluate(vm);}return EvaluatedPositionalArgs.create(references);};CompiledPositionalArgs.prototype.toJSON = function toJSON(){return '[' + this.values.map(function(value){return value.toJSON();}).join(", ") + ']';};return CompiledPositionalArgs;})();var COMPILED_EMPTY_POSITIONAL_ARGS=new ((function(_CompiledPositionalArgs){babelHelpers.inherits(_class,_CompiledPositionalArgs);function _class(){_CompiledPositionalArgs.call(this,EMPTY_ARRAY);}_class.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_POSITIONAL_ARGS;};_class.prototype.toJSON = function toJSON(){return '';};return _class;})(CompiledPositionalArgs))();var EvaluatedPositionalArgs=(function(){function EvaluatedPositionalArgs(values){this.values = values;this.tag = _glimmerReference.combineTagged(values);this.length = values.length;}EvaluatedPositionalArgs.create = function create(values){return new this(values);};EvaluatedPositionalArgs.empty = function empty(){return EVALUATED_EMPTY_POSITIONAL_ARGS;};EvaluatedPositionalArgs.prototype.at = function at(index){var values=this.values;var length=this.length;return index < length?values[index]:UNDEFINED_REFERENCE;};EvaluatedPositionalArgs.prototype.value = function value(){var values=this.values;var length=this.length;var ret=new Array(length);for(var i=0;i < length;i++) {ret[i] = values[i].value();}return ret;};return EvaluatedPositionalArgs;})();var EVALUATED_EMPTY_POSITIONAL_ARGS=new ((function(_EvaluatedPositionalArgs){babelHelpers.inherits(_class2,_EvaluatedPositionalArgs);function _class2(){_EvaluatedPositionalArgs.call(this,EMPTY_ARRAY);}_class2.prototype.at = function at(){return UNDEFINED_REFERENCE;};_class2.prototype.value = function value(){return this.values;};return _class2;})(EvaluatedPositionalArgs))();var CompiledNamedArgs=(function(){function CompiledNamedArgs(keys,values){this.keys = keys;this.values = values;this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}CompiledNamedArgs.empty = function empty(){return COMPILED_EMPTY_NAMED_ARGS;};CompiledNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=[];for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values);}else {return COMPILED_EMPTY_NAMED_ARGS;}};CompiledNamedArgs.prototype.evaluate = function evaluate(vm){var keys=this.keys;var values=this.values;var length=this.length;var evaluated=new Array(length);for(var i=0;i < length;i++) {evaluated[i] = values[i].evaluate(vm);}return new EvaluatedNamedArgs(keys,evaluated);};CompiledNamedArgs.prototype.toJSON = function toJSON(){var keys=this.keys;var values=this.values;var inner=keys.map(function(key,i){return key + ': ' + values[i].toJSON();}).join(", ");return '{' + inner + '}';};return CompiledNamedArgs;})();var COMPILED_EMPTY_NAMED_ARGS=new ((function(_CompiledNamedArgs){babelHelpers.inherits(_class3,_CompiledNamedArgs);function _class3(){_CompiledNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY);}_class3.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_NAMED_ARGS;};_class3.prototype.toJSON = function toJSON(){return '';};return _class3;})(CompiledNamedArgs))();var EvaluatedNamedArgs=(function(){function EvaluatedNamedArgs(keys,values){var _map=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];this.keys = keys;this.values = values;this._map = _map;this.tag = _glimmerReference.combineTagged(values);this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}EvaluatedNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=new Array(length);for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values,map);}else {return EVALUATED_EMPTY_NAMED_ARGS;}};EvaluatedNamedArgs.empty = function empty(){return EVALUATED_EMPTY_NAMED_ARGS;};EvaluatedNamedArgs.prototype.get = function get(key){var keys=this.keys;var values=this.values;var index=keys.indexOf(key);return index === -1?UNDEFINED_REFERENCE:values[index];};EvaluatedNamedArgs.prototype.has = function has(key){return this.keys.indexOf(key) !== -1;};EvaluatedNamedArgs.prototype.value = function value(){var keys=this.keys;var values=this.values;var out=_glimmerUtil.dict();for(var i=0;i < keys.length;i++) {var key=keys[i];var ref=values[i];out[key] = ref.value();}return out;};babelHelpers.createClass(EvaluatedNamedArgs,[{key:'map',get:function(){var map=this._map;if(map){return map;}map = this._map = _glimmerUtil.dict();var keys=this.keys;var values=this.values;var length=this.length;for(var i=0;i < length;i++) {map[keys[i]] = values[i];}return map;}}]);return EvaluatedNamedArgs;})();var EVALUATED_EMPTY_NAMED_ARGS=new ((function(_EvaluatedNamedArgs){babelHelpers.inherits(_class4,_EvaluatedNamedArgs);function _class4(){_EvaluatedNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY,EMPTY_DICT);}_class4.prototype.get = function get(){return UNDEFINED_REFERENCE;};_class4.prototype.has = function has(_key){return false;};_class4.prototype.value = function value(){return EMPTY_DICT;};return _class4;})(EvaluatedNamedArgs))();var EMPTY_BLOCKS={default:null,inverse:null};var CompiledArgs=(function(){function CompiledArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.type = "compiled-args";}CompiledArgs.create = function create(positional,named,blocks){if(positional === COMPILED_EMPTY_POSITIONAL_ARGS && named === COMPILED_EMPTY_NAMED_ARGS && blocks === EMPTY_BLOCKS){return this.empty();}else {return new this(positional,named,blocks);}};CompiledArgs.empty = function empty(){return COMPILED_EMPTY_ARGS;};CompiledArgs.prototype.evaluate = function evaluate(vm){var positional=this.positional;var named=this.named;var blocks=this.blocks;return EvaluatedArgs.create(positional.evaluate(vm),named.evaluate(vm),blocks);};return CompiledArgs;})();var COMPILED_EMPTY_ARGS=new ((function(_CompiledArgs){babelHelpers.inherits(_class5,_CompiledArgs);function _class5(){_CompiledArgs.call(this,COMPILED_EMPTY_POSITIONAL_ARGS,COMPILED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);}_class5.prototype.evaluate = function evaluate(_vm){return EMPTY_EVALUATED_ARGS;};return _class5;})(CompiledArgs))();var EvaluatedArgs=(function(){function EvaluatedArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.tag = _glimmerReference.combineTagged([positional,named]);}EvaluatedArgs.empty = function empty(){return EMPTY_EVALUATED_ARGS;};EvaluatedArgs.create = function create(positional,named,blocks){return new this(positional,named,blocks);};EvaluatedArgs.positional = function positional(values){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EvaluatedPositionalArgs.create(values),EVALUATED_EMPTY_NAMED_ARGS,blocks);};EvaluatedArgs.named = function named(map){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EVALUATED_EMPTY_POSITIONAL_ARGS,EvaluatedNamedArgs.create(map),blocks);};return EvaluatedArgs;})();var EMPTY_EVALUATED_ARGS=new EvaluatedArgs(EVALUATED_EMPTY_POSITIONAL_ARGS,EVALUATED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);APPEND_OPCODES.add(22, /* PutDynamicComponent */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(23, /* PutComponent */function(vm,_ref16){var _component=_ref16.op1;var definition=vm.constants.getOther(_component);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(24, /* OpenComponent */function(vm,_ref17){var _args=_ref17.op1;var _shadow=_ref17.op2;var rawArgs=vm.constants.getExpression(_args);var shadow=vm.constants.getBlock(_shadow);var definition=vm.frame.getImmediate();var dynamicScope=vm.pushDynamicScope();var callerScope=vm.scope();var manager=definition.manager;var args=manager.prepareArgs(definition,rawArgs.evaluate(vm),dynamicScope);var hasDefaultBlock=!!args.blocks.default; // TODO Cleanup? +var component=manager.create(vm.env,definition,args,dynamicScope,vm.getSelf(),hasDefaultBlock);var destructor=manager.getDestructor(component);if(destructor)vm.newDestroyable(destructor);var layout=manager.layoutFor(definition,component,vm.env);var selfRef=manager.getSelf(component);vm.beginCacheGroup();vm.stack().pushSimpleBlock();vm.pushRootScope(selfRef,layout.symbols);vm.invokeLayout(args,layout,callerScope,component,manager,shadow);vm.updateWith(new UpdateComponentOpcode(definition.name,component,manager,args,dynamicScope));}); // export class DidCreateElementOpcode extends Opcode { +// public type = "did-create-element"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let action = 'DidCreateElementOpcode#evaluate'; +// manager.didCreateElement(component, vm.stack().expectConstructing(action), vm.stack().expectOperations(action)); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +APPEND_OPCODES.add(25, /* DidCreateElement */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var action='DidCreateElementOpcode#evaluate';manager.didCreateElement(component,vm.stack().expectConstructing(action),vm.stack().expectOperations(action));}); // export class ShadowAttributesOpcode extends Opcode { +// public type = "shadow-attributes"; +// evaluate(vm: VM) { +// let shadow = vm.frame.getShadow(); +// vm.pushCallerScope(); +// if (!shadow) return; +// vm.invokeBlock(shadow, EvaluatedArgs.empty()); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +// Slow path for non-specialized component invocations. Uses an internal +// named lookup on the args. +APPEND_OPCODES.add(26, /* ShadowAttributes */function(vm){var shadow=vm.frame.getShadow();vm.pushCallerScope();if(!shadow)return;vm.invokeBlock(shadow,EvaluatedArgs.empty());}); // export class DidRenderLayoutOpcode extends Opcode { +// public type = "did-render-layout"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let bounds = vm.stack().popBlock(); +// manager.didRenderLayout(component, bounds); +// vm.env.didCreate(component, manager); +// vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); +// } +// } +APPEND_OPCODES.add(27, /* DidRenderLayout */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var bounds=vm.stack().popBlock();manager.didRenderLayout(component,bounds);vm.env.didCreate(component,manager);vm.updateWith(new DidUpdateLayoutOpcode(manager,component,bounds));}); // export class CloseComponentOpcode extends Opcode { +// public type = "close-component"; +// evaluate(vm: VM) { +// vm.popScope(); +// vm.popDynamicScope(); +// vm.commitCacheGroup(); +// } +// } +APPEND_OPCODES.add(28, /* CloseComponent */function(vm){vm.popScope();vm.popDynamicScope();vm.commitCacheGroup();});var UpdateComponentOpcode=(function(_UpdatingOpcode4){babelHelpers.inherits(UpdateComponentOpcode,_UpdatingOpcode4);function UpdateComponentOpcode(name,component,manager,args,dynamicScope){_UpdatingOpcode4.call(this);this.name = name;this.component = component;this.manager = manager;this.args = args;this.dynamicScope = dynamicScope;this.type = "update-component";var componentTag=manager.getTag(component);if(componentTag){this.tag = _glimmerReference.combine([args.tag,componentTag]);}else {this.tag = args.tag;}}UpdateComponentOpcode.prototype.evaluate = function evaluate(_vm){var component=this.component;var manager=this.manager;var args=this.args;var dynamicScope=this.dynamicScope;manager.update(component,args,dynamicScope);};UpdateComponentOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.name)]};};return UpdateComponentOpcode;})(UpdatingOpcode);var DidUpdateLayoutOpcode=(function(_UpdatingOpcode5){babelHelpers.inherits(DidUpdateLayoutOpcode,_UpdatingOpcode5);function DidUpdateLayoutOpcode(manager,component,bounds){_UpdatingOpcode5.call(this);this.manager = manager;this.component = component;this.bounds = bounds;this.type = "did-update-layout";this.tag = _glimmerReference.CONSTANT_TAG;}DidUpdateLayoutOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var component=this.component;var bounds=this.bounds;manager.didUpdateLayout(component,bounds);vm.env.didUpdate(component,manager);};return DidUpdateLayoutOpcode;})(UpdatingOpcode);var Cursor=function Cursor(element,nextSibling){this.element = element;this.nextSibling = nextSibling;};var ConcreteBounds=(function(){function ConcreteBounds(parentNode,first,last){this.parentNode = parentNode;this.first = first;this.last = last;}ConcreteBounds.prototype.parentElement = function parentElement(){return this.parentNode;};ConcreteBounds.prototype.firstNode = function firstNode(){return this.first;};ConcreteBounds.prototype.lastNode = function lastNode(){return this.last;};return ConcreteBounds;})();var SingleNodeBounds=(function(){function SingleNodeBounds(parentNode,node){this.parentNode = parentNode;this.node = node;}SingleNodeBounds.prototype.parentElement = function parentElement(){return this.parentNode;};SingleNodeBounds.prototype.firstNode = function firstNode(){return this.node;};SingleNodeBounds.prototype.lastNode = function lastNode(){return this.node;};return SingleNodeBounds;})();function single(parent,node){return new SingleNodeBounds(parent,node);}function moveBounds(bounds,reference){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.insertBefore(node,reference);if(node === last)return next;node = next;}return null;}function clear(bounds){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.removeChild(node);if(node === last)return next;node = next;}return null;}function isSafeString(value){return !!value && typeof value['toHTML'] === 'function';}function isNode(value){return value !== null && typeof value === 'object' && typeof value['nodeType'] === 'number';}function isString(value){return typeof value === 'string';}var Upsert=function Upsert(bounds){this.bounds = bounds;};function cautiousInsert(dom,cursor,value){if(isString(value)){return TextUpsert.insert(dom,cursor,value);}if(isSafeString(value)){return SafeStringUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}function trustingInsert(dom,cursor,value){if(isString(value)){return HTMLUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}var TextUpsert=(function(_Upsert){babelHelpers.inherits(TextUpsert,_Upsert);TextUpsert.insert = function insert(dom,cursor,value){var textNode=dom.createTextNode(value);dom.insertBefore(cursor.element,textNode,cursor.nextSibling);var bounds=new SingleNodeBounds(cursor.element,textNode);return new TextUpsert(bounds,textNode);};function TextUpsert(bounds,textNode){_Upsert.call(this,bounds);this.textNode = textNode;}TextUpsert.prototype.update = function update(_dom,value){if(isString(value)){var textNode=this.textNode;textNode.nodeValue = value;return true;}else {return false;}};return TextUpsert;})(Upsert);var HTMLUpsert=(function(_Upsert2){babelHelpers.inherits(HTMLUpsert,_Upsert2);function HTMLUpsert(){_Upsert2.apply(this,arguments);}HTMLUpsert.insert = function insert(dom,cursor,value){var bounds=dom.insertHTMLBefore(cursor.element,value,cursor.nextSibling);return new HTMLUpsert(bounds);};HTMLUpsert.prototype.update = function update(dom,value){if(isString(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,value);return true;}else {return false;}};return HTMLUpsert;})(Upsert);var SafeStringUpsert=(function(_Upsert3){babelHelpers.inherits(SafeStringUpsert,_Upsert3);function SafeStringUpsert(bounds,lastStringValue){_Upsert3.call(this,bounds);this.lastStringValue = lastStringValue;}SafeStringUpsert.insert = function insert(dom,cursor,value){var stringValue=value.toHTML();var bounds=dom.insertHTMLBefore(cursor.element,stringValue,cursor.nextSibling);return new SafeStringUpsert(bounds,stringValue);};SafeStringUpsert.prototype.update = function update(dom,value){if(isSafeString(value)){var stringValue=value.toHTML();if(stringValue !== this.lastStringValue){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,stringValue);this.lastStringValue = stringValue;}return true;}else {return false;}};return SafeStringUpsert;})(Upsert);var NodeUpsert=(function(_Upsert4){babelHelpers.inherits(NodeUpsert,_Upsert4);function NodeUpsert(){_Upsert4.apply(this,arguments);}NodeUpsert.insert = function insert(dom,cursor,node){dom.insertBefore(cursor.element,node,cursor.nextSibling);return new NodeUpsert(single(cursor.element,node));};NodeUpsert.prototype.update = function update(dom,value){if(isNode(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertNodeBefore(parentElement,value,nextSibling);return true;}else {return false;}};return NodeUpsert;})(Upsert);var COMPONENT_DEFINITION_BRAND='COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]';function isComponentDefinition(obj){return typeof obj === 'object' && obj && obj[COMPONENT_DEFINITION_BRAND];}var ComponentDefinition=function ComponentDefinition(name,manager,ComponentClass){this[COMPONENT_DEFINITION_BRAND] = true;this.name = name;this.manager = manager;this.ComponentClass = ComponentClass;};var CompiledExpression=(function(){function CompiledExpression(){}CompiledExpression.prototype.toJSON = function toJSON(){return 'UNIMPL: ' + this.type.toUpperCase();};return CompiledExpression;})();APPEND_OPCODES.add(29, /* Text */function(vm,_ref18){var text=_ref18.op1;vm.stack().appendText(vm.constants.getString(text));});APPEND_OPCODES.add(30, /* Comment */function(vm,_ref19){var text=_ref19.op1;vm.stack().appendComment(vm.constants.getString(text));});APPEND_OPCODES.add(32, /* OpenElement */function(vm,_ref20){var tag=_ref20.op1;vm.stack().openElement(vm.constants.getString(tag));});APPEND_OPCODES.add(33, /* PushRemoteElement */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var element=cache?cache.peek():reference.value();vm.stack().pushRemoteElement(element);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(34, /* PopRemoteElement */function(vm){return vm.stack().popRemoteElement();});APPEND_OPCODES.add(35, /* OpenComponentElement */function(vm,_ref21){var _tag=_ref21.op1;var tag=vm.constants.getString(_tag);vm.stack().openElement(tag,new ComponentElementOperations(vm.env));});APPEND_OPCODES.add(36, /* OpenDynamicElement */function(vm){var tagName=vm.frame.getOperand().value();vm.stack().openElement(tagName);});var ClassList=(function(){function ClassList(){this.list = null;this.isConst = true;}ClassList.prototype.append = function append(reference){var list=this.list;var isConst$$=this.isConst;if(list === null)list = this.list = [];list.push(reference);this.isConst = isConst$$ && _glimmerReference.isConst(reference);};ClassList.prototype.toReference = function toReference(){var list=this.list;var isConst$$=this.isConst;if(!list)return NULL_REFERENCE;if(isConst$$)return PrimitiveReference.create(toClassName(list));return new ClassListReference(list);};return ClassList;})();var ClassListReference=(function(_CachedReference){babelHelpers.inherits(ClassListReference,_CachedReference);function ClassListReference(list){_CachedReference.call(this);this.list = [];this.tag = _glimmerReference.combineTagged(list);this.list = list;}ClassListReference.prototype.compute = function compute(){return toClassName(this.list);};return ClassListReference;})(_glimmerReference.CachedReference);function toClassName(list){var ret=[];for(var i=0;i < list.length;i++) {var value=list[i].value();if(value !== false && value !== null && value !== undefined)ret.push(value);}return ret.length === 0?null:ret.join(' ');}var SimpleElementOperations=(function(){function SimpleElementOperations(env){this.env = env;this.opcodes = null;this.classList = null;}SimpleElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else {this.env.getAppendOperations().setAttribute(element,name,value);}};SimpleElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){this.env.getAppendOperations().setAttribute(element,name,value,namespace);};SimpleElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else {var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(attribute);}};SimpleElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(nsAttribute);};SimpleElementOperations.prototype.flush = function flush(element,vm){var env=vm.env;var opcodes=this.opcodes;var classList=this.classList;for(var i=0;opcodes && i < opcodes.length;i++) {vm.updateWith(opcodes[i]);}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}this.opcodes = null;this.classList = null;};SimpleElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};SimpleElementOperations.prototype.addAttribute = function addAttribute(attribute){var opcode=attribute.flush(this.env);if(opcode){var opcodes=this.opcodes;if(!opcodes){opcodes = this.opcodes = [];}opcodes.push(opcode);}};return SimpleElementOperations;})();var ComponentElementOperations=(function(){function ComponentElementOperations(env){this.env = env;this.attributeNames = null;this.attributes = null;this.classList = null;}ComponentElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value));}};ComponentElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value,namespace));}};ComponentElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(name,attribute);}};ComponentElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(name,nsAttribute);}};ComponentElementOperations.prototype.flush = function flush(element,vm){var env=this.env;var attributes=this.attributes;var classList=this.classList;for(var i=0;attributes && i < attributes.length;i++) {var opcode=attributes[i].flush(env);if(opcode){vm.updateWith(opcode);}}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}};ComponentElementOperations.prototype.shouldAddAttribute = function shouldAddAttribute(name){return !this.attributeNames || this.attributeNames.indexOf(name) === -1;};ComponentElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};ComponentElementOperations.prototype.addAttribute = function addAttribute(name,attribute){var attributeNames=this.attributeNames;var attributes=this.attributes;if(!attributeNames){attributeNames = this.attributeNames = [];attributes = this.attributes = [];}attributeNames.push(name);_glimmerUtil.unwrap(attributes).push(attribute);};return ComponentElementOperations;})();APPEND_OPCODES.add(37, /* FlushElement */function(vm){var stack=vm.stack();var action='FlushElementOpcode#evaluate';stack.expectOperations(action).flush(stack.expectConstructing(action),vm);stack.flushElement();});APPEND_OPCODES.add(38, /* CloseElement */function(vm){return vm.stack().closeElement();});APPEND_OPCODES.add(39, /* PopElement */function(vm){return vm.stack().popElement();});APPEND_OPCODES.add(40, /* StaticAttr */function(vm,_ref22){var _name=_ref22.op1;var _value=_ref22.op2;var _namespace=_ref22.op3;var name=vm.constants.getString(_name);var value=vm.constants.getString(_value);if(_namespace){var namespace=vm.constants.getString(_namespace);vm.stack().setStaticAttributeNS(namespace,name,value);}else {vm.stack().setStaticAttribute(name,value);}});APPEND_OPCODES.add(41, /* Modifier */function(vm,_ref23){var _name=_ref23.op1;var _manager=_ref23.op2;var _args=_ref23.op3;var manager=vm.constants.getOther(_manager);var rawArgs=vm.constants.getExpression(_args);var stack=vm.stack();var element=stack.constructing;var updateOperations=stack.updateOperations;var args=rawArgs.evaluate(vm);var dynamicScope=vm.dynamicScope();var modifier=manager.create(element,args,dynamicScope,updateOperations);vm.env.scheduleInstallModifier(modifier,manager);var destructor=manager.getDestructor(modifier);if(destructor){vm.newDestroyable(destructor);}vm.updateWith(new UpdateModifierOpcode(manager,modifier,args));});var UpdateModifierOpcode=(function(_UpdatingOpcode6){babelHelpers.inherits(UpdateModifierOpcode,_UpdatingOpcode6);function UpdateModifierOpcode(manager,modifier,args){_UpdatingOpcode6.call(this);this.manager = manager;this.modifier = modifier;this.args = args;this.type = "update-modifier";this.tag = args.tag;this.lastUpdated = args.tag.value();}UpdateModifierOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var modifier=this.modifier;var tag=this.tag;var lastUpdated=this.lastUpdated;if(!tag.validate(lastUpdated)){vm.env.scheduleUpdateModifier(modifier,manager);this.lastUpdated = tag.value();}};UpdateModifierOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.args)]};};return UpdateModifierOpcode;})(UpdatingOpcode);var StaticAttribute=(function(){function StaticAttribute(element,name,value,namespace){this.element = element;this.name = name;this.value = value;this.namespace = namespace;}StaticAttribute.prototype.flush = function flush(env){env.getAppendOperations().setAttribute(this.element,this.name,this.value,this.namespace);return null;};return StaticAttribute;})();var DynamicAttribute=(function(){function DynamicAttribute(element,attributeManager,name,reference,namespace){this.element = element;this.attributeManager = attributeManager;this.name = name;this.reference = reference;this.namespace = namespace;this.cache = null;this.tag = reference.tag;}DynamicAttribute.prototype.patch = function patch(env){var element=this.element;var cache=this.cache;var value=_glimmerUtil.expect(cache,'must patch after flush').revalidate();if(_glimmerReference.isModified(value)){this.attributeManager.updateAttribute(env,element,value,this.namespace);}};DynamicAttribute.prototype.flush = function flush(env){var reference=this.reference;var element=this.element;if(_glimmerReference.isConst(reference)){var value=reference.value();this.attributeManager.setAttribute(env,element,value,this.namespace);return null;}else {var cache=this.cache = new _glimmerReference.ReferenceCache(reference);var value=cache.peek();this.attributeManager.setAttribute(env,element,value,this.namespace);return new PatchElementOpcode(this);}};DynamicAttribute.prototype.toJSON = function toJSON(){var element=this.element;var namespace=this.namespace;var name=this.name;var cache=this.cache;var formattedElement=formatElement(element);var lastValue=_glimmerUtil.expect(cache,'must serialize after flush').peek();if(namespace){return {element:formattedElement,type:'attribute',namespace:namespace,name:name,lastValue:lastValue};}return {element:formattedElement,type:'attribute',namespace:namespace === undefined?null:namespace,name:name,lastValue:lastValue};};return DynamicAttribute;})();function formatElement(element){return JSON.stringify('<' + element.tagName.toLowerCase() + ' />');}APPEND_OPCODES.add(42, /* DynamicAttrNS */function(vm,_ref24){var _name=_ref24.op1;var _namespace=_ref24.op2;var trusting=_ref24.op3;var name=vm.constants.getString(_name);var namespace=vm.constants.getString(_namespace);var reference=vm.frame.getOperand();vm.stack().setDynamicAttributeNS(namespace,name,reference,!!trusting);});APPEND_OPCODES.add(43, /* DynamicAttr */function(vm,_ref25){var _name=_ref25.op1;var trusting=_ref25.op2;var name=vm.constants.getString(_name);var reference=vm.frame.getOperand();vm.stack().setDynamicAttribute(name,reference,!!trusting);});var PatchElementOpcode=(function(_UpdatingOpcode7){babelHelpers.inherits(PatchElementOpcode,_UpdatingOpcode7);function PatchElementOpcode(operation){_UpdatingOpcode7.call(this);this.type = "patch-element";this.tag = operation.tag;this.operation = operation;}PatchElementOpcode.prototype.evaluate = function evaluate(vm){this.operation.patch(vm.env);};PatchElementOpcode.prototype.toJSON = function toJSON(){var _guid=this._guid;var type=this.type;var operation=this.operation;return {guid:_guid,type:type,details:operation.toJSON()};};return PatchElementOpcode;})(UpdatingOpcode);var First=(function(){function First(node){this.node = node;}First.prototype.firstNode = function firstNode(){return this.node;};return First;})();var Last=(function(){function Last(node){this.node = node;}Last.prototype.lastNode = function lastNode(){return this.node;};return Last;})();var Fragment=(function(){function Fragment(bounds){this.bounds = bounds;}Fragment.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};Fragment.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};Fragment.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};Fragment.prototype.update = function update(bounds){this.bounds = bounds;};return Fragment;})();var ElementStack=(function(){function ElementStack(env,parentNode,nextSibling){this.constructing = null;this.operations = null;this.elementStack = new _glimmerUtil.Stack();this.nextSiblingStack = new _glimmerUtil.Stack();this.blockStack = new _glimmerUtil.Stack();this.env = env;this.dom = env.getAppendOperations();this.updateOperations = env.getDOM();this.element = parentNode;this.nextSibling = nextSibling;this.defaultOperations = new SimpleElementOperations(env);this.elementStack.push(this.element);this.nextSiblingStack.push(this.nextSibling);}ElementStack.forInitialRender = function forInitialRender(env,parentNode,nextSibling){return new ElementStack(env,parentNode,nextSibling);};ElementStack.resume = function resume(env,tracker,nextSibling){var parentNode=tracker.parentElement();var stack=new ElementStack(env,parentNode,nextSibling);stack.pushBlockTracker(tracker);return stack;};ElementStack.prototype.expectConstructing = function expectConstructing(method){return _glimmerUtil.expect(this.constructing,method + ' should only be called while constructing an element');};ElementStack.prototype.expectOperations = function expectOperations(method){return _glimmerUtil.expect(this.operations,method + ' should only be called while constructing an element');};ElementStack.prototype.block = function block(){return _glimmerUtil.expect(this.blockStack.current,"Expected a current block tracker");};ElementStack.prototype.popElement = function popElement(){var elementStack=this.elementStack;var nextSiblingStack=this.nextSiblingStack;var topElement=elementStack.pop();nextSiblingStack.pop();_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.element = _glimmerUtil.expect(elementStack.current,"can't pop past the last element");this.nextSibling = nextSiblingStack.current;return topElement;};ElementStack.prototype.pushSimpleBlock = function pushSimpleBlock(){var tracker=new SimpleBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushUpdatableBlock = function pushUpdatableBlock(){var tracker=new UpdatableBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushBlockTracker = function pushBlockTracker(tracker){var isRemote=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);if(!isRemote){current.newBounds(tracker);}}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.pushBlockList = function pushBlockList(list){var tracker=new BlockListTracker(this.element,list);var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);current.newBounds(tracker);}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.popBlock = function popBlock(){this.block().finalize(this);return _glimmerUtil.expect(this.blockStack.pop(),"Expected popBlock to return a block");};ElementStack.prototype.openElement = function openElement(tag){var operations=arguments.length <= 1 || arguments[1] === undefined?this.defaultOperations:arguments[1];var element=this.dom.createElement(tag,this.element);this.constructing = element;this.operations = operations;return element;};ElementStack.prototype.flushElement = function flushElement(){var parent=this.element;var element=_glimmerUtil.expect(this.constructing,'flushElement should only be called when constructing an element');this.dom.insertBefore(parent,element,this.nextSibling);this.constructing = null;this.operations = null;this.pushElement(element);this.block().openElement(element);};ElementStack.prototype.pushRemoteElement = function pushRemoteElement(element){this.pushElement(element);var tracker=new RemoteBlockTracker(element);this.pushBlockTracker(tracker,true);};ElementStack.prototype.popRemoteElement = function popRemoteElement(){this.popBlock();this.popElement();};ElementStack.prototype.pushElement = function pushElement(element){this.element = element;this.elementStack.push(element);_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.nextSibling = null;this.nextSiblingStack.push(null);};ElementStack.prototype.newDestroyable = function newDestroyable(d){this.block().newDestroyable(d);};ElementStack.prototype.newBounds = function newBounds(bounds){this.block().newBounds(bounds);};ElementStack.prototype.appendText = function appendText(string){var dom=this.dom;var text=dom.createTextNode(string);dom.insertBefore(this.element,text,this.nextSibling);this.block().newNode(text);return text;};ElementStack.prototype.appendComment = function appendComment(string){var dom=this.dom;var comment=dom.createComment(string);dom.insertBefore(this.element,comment,this.nextSibling);this.block().newNode(comment);return comment;};ElementStack.prototype.setStaticAttribute = function setStaticAttribute(name,value){this.expectOperations('setStaticAttribute').addStaticAttribute(this.expectConstructing('setStaticAttribute'),name,value);};ElementStack.prototype.setStaticAttributeNS = function setStaticAttributeNS(namespace,name,value){this.expectOperations('setStaticAttributeNS').addStaticAttributeNS(this.expectConstructing('setStaticAttributeNS'),namespace,name,value);};ElementStack.prototype.setDynamicAttribute = function setDynamicAttribute(name,reference,isTrusting){this.expectOperations('setDynamicAttribute').addDynamicAttribute(this.expectConstructing('setDynamicAttribute'),name,reference,isTrusting);};ElementStack.prototype.setDynamicAttributeNS = function setDynamicAttributeNS(namespace,name,reference,isTrusting){this.expectOperations('setDynamicAttributeNS').addDynamicAttributeNS(this.expectConstructing('setDynamicAttributeNS'),namespace,name,reference,isTrusting);};ElementStack.prototype.closeElement = function closeElement(){this.block().closeElement();this.popElement();};return ElementStack;})();var SimpleBlockTracker=(function(){function SimpleBlockTracker(parent){this.parent = parent;this.first = null;this.last = null;this.destroyables = null;this.nesting = 0;}SimpleBlockTracker.prototype.destroy = function destroy(){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {destroyables[i].destroy();}}};SimpleBlockTracker.prototype.parentElement = function parentElement(){return this.parent;};SimpleBlockTracker.prototype.firstNode = function firstNode(){return this.first && this.first.firstNode();};SimpleBlockTracker.prototype.lastNode = function lastNode(){return this.last && this.last.lastNode();};SimpleBlockTracker.prototype.openElement = function openElement(element){this.newNode(element);this.nesting++;};SimpleBlockTracker.prototype.closeElement = function closeElement(){this.nesting--;};SimpleBlockTracker.prototype.newNode = function newNode(node){if(this.nesting !== 0)return;if(!this.first){this.first = new First(node);}this.last = new Last(node);};SimpleBlockTracker.prototype.newBounds = function newBounds(bounds){if(this.nesting !== 0)return;if(!this.first){this.first = bounds;}this.last = bounds;};SimpleBlockTracker.prototype.newDestroyable = function newDestroyable(d){this.destroyables = this.destroyables || [];this.destroyables.push(d);};SimpleBlockTracker.prototype.finalize = function finalize(stack){if(!this.first){stack.appendComment('');}};return SimpleBlockTracker;})();var RemoteBlockTracker=(function(_SimpleBlockTracker){babelHelpers.inherits(RemoteBlockTracker,_SimpleBlockTracker);function RemoteBlockTracker(){_SimpleBlockTracker.apply(this,arguments);}RemoteBlockTracker.prototype.destroy = function destroy(){_SimpleBlockTracker.prototype.destroy.call(this);clear(this);};return RemoteBlockTracker;})(SimpleBlockTracker);var UpdatableBlockTracker=(function(_SimpleBlockTracker2){babelHelpers.inherits(UpdatableBlockTracker,_SimpleBlockTracker2);function UpdatableBlockTracker(){_SimpleBlockTracker2.apply(this,arguments);}UpdatableBlockTracker.prototype.reset = function reset(env){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {env.didDestroy(destroyables[i]);}}var nextSibling=clear(this);this.destroyables = null;this.first = null;this.last = null;return nextSibling;};return UpdatableBlockTracker;})(SimpleBlockTracker);var BlockListTracker=(function(){function BlockListTracker(parent,boundList){this.parent = parent;this.boundList = boundList;this.parent = parent;this.boundList = boundList;}BlockListTracker.prototype.destroy = function destroy(){this.boundList.forEachNode(function(node){return node.destroy();});};BlockListTracker.prototype.parentElement = function parentElement(){return this.parent;};BlockListTracker.prototype.firstNode = function firstNode(){var head=this.boundList.head();return head && head.firstNode();};BlockListTracker.prototype.lastNode = function lastNode(){var tail=this.boundList.tail();return tail && tail.lastNode();};BlockListTracker.prototype.openElement = function openElement(_element){_glimmerUtil.assert(false,'Cannot openElement directly inside a block list');};BlockListTracker.prototype.closeElement = function closeElement(){_glimmerUtil.assert(false,'Cannot closeElement directly inside a block list');};BlockListTracker.prototype.newNode = function newNode(_node){_glimmerUtil.assert(false,'Cannot create a new node directly inside a block list');};BlockListTracker.prototype.newBounds = function newBounds(_bounds){};BlockListTracker.prototype.newDestroyable = function newDestroyable(_d){};BlockListTracker.prototype.finalize = function finalize(_stack){};return BlockListTracker;})();var CompiledValue=(function(_CompiledExpression){babelHelpers.inherits(CompiledValue,_CompiledExpression);function CompiledValue(value){_CompiledExpression.call(this);this.type = "value";this.reference = PrimitiveReference.create(value);}CompiledValue.prototype.evaluate = function evaluate(_vm){return this.reference;};CompiledValue.prototype.toJSON = function toJSON(){return JSON.stringify(this.reference.value());};return CompiledValue;})(CompiledExpression);var CompiledHasBlock=(function(_CompiledExpression2){babelHelpers.inherits(CompiledHasBlock,_CompiledExpression2);function CompiledHasBlock(inner){_CompiledExpression2.call(this);this.inner = inner;this.type = "has-block";}CompiledHasBlock.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);return PrimitiveReference.create(!!block);};CompiledHasBlock.prototype.toJSON = function toJSON(){return 'has-block(' + this.inner.toJSON() + ')';};return CompiledHasBlock;})(CompiledExpression);var CompiledHasBlockParams=(function(_CompiledExpression3){babelHelpers.inherits(CompiledHasBlockParams,_CompiledExpression3);function CompiledHasBlockParams(inner){_CompiledExpression3.call(this);this.inner = inner;this.type = "has-block-params";}CompiledHasBlockParams.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);var hasLocals=block && block.symbolTable.getSymbols().locals;return PrimitiveReference.create(!!hasLocals);};CompiledHasBlockParams.prototype.toJSON = function toJSON(){return 'has-block-params(' + this.inner.toJSON() + ')';};return CompiledHasBlockParams;})(CompiledExpression);var CompiledGetBlockBySymbol=(function(){function CompiledGetBlockBySymbol(symbol,debug){this.symbol = symbol;this.debug = debug;}CompiledGetBlockBySymbol.prototype.evaluate = function evaluate(vm){return vm.scope().getBlock(this.symbol);};CompiledGetBlockBySymbol.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '(' + this.debug + '))';};return CompiledGetBlockBySymbol;})();var CompiledInPartialGetBlock=(function(){function CompiledInPartialGetBlock(symbol,name){this.symbol = symbol;this.name = name;}CompiledInPartialGetBlock.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.blocks[name];};CompiledInPartialGetBlock.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '($ARGS).' + this.name + '))';};return CompiledInPartialGetBlock;})();var CompiledLookup=(function(_CompiledExpression4){babelHelpers.inherits(CompiledLookup,_CompiledExpression4);function CompiledLookup(base,path){_CompiledExpression4.call(this);this.base = base;this.path = path;this.type = "lookup";}CompiledLookup.create = function create(base,path){if(path.length === 0){return base;}else {return new this(base,path);}};CompiledLookup.prototype.evaluate = function evaluate(vm){var base=this.base;var path=this.path;return _glimmerReference.referenceFromParts(base.evaluate(vm),path);};CompiledLookup.prototype.toJSON = function toJSON(){return this.base.toJSON() + '.' + this.path.join('.');};return CompiledLookup;})(CompiledExpression);var CompiledSelf=(function(_CompiledExpression5){babelHelpers.inherits(CompiledSelf,_CompiledExpression5);function CompiledSelf(){_CompiledExpression5.apply(this,arguments);}CompiledSelf.prototype.evaluate = function evaluate(vm){return vm.getSelf();};CompiledSelf.prototype.toJSON = function toJSON(){return 'self';};return CompiledSelf;})(CompiledExpression);var CompiledSymbol=(function(_CompiledExpression6){babelHelpers.inherits(CompiledSymbol,_CompiledExpression6);function CompiledSymbol(symbol,debug){_CompiledExpression6.call(this);this.symbol = symbol;this.debug = debug;}CompiledSymbol.prototype.evaluate = function evaluate(vm){return vm.referenceForSymbol(this.symbol);};CompiledSymbol.prototype.toJSON = function toJSON(){return '$' + this.symbol + '(' + this.debug + ')';};return CompiledSymbol;})(CompiledExpression);var CompiledInPartialName=(function(_CompiledExpression7){babelHelpers.inherits(CompiledInPartialName,_CompiledExpression7);function CompiledInPartialName(symbol,name){_CompiledExpression7.call(this);this.symbol = symbol;this.name = name;}CompiledInPartialName.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.named.get(name);};CompiledInPartialName.prototype.toJSON = function toJSON(){return '$' + this.symbol + '($ARGS).' + this.name;};return CompiledInPartialName;})(CompiledExpression);var CompiledHelper=(function(_CompiledExpression8){babelHelpers.inherits(CompiledHelper,_CompiledExpression8);function CompiledHelper(name,helper,args,symbolTable){_CompiledExpression8.call(this);this.name = name;this.helper = helper;this.args = args;this.symbolTable = symbolTable;this.type = "helper";}CompiledHelper.prototype.evaluate = function evaluate(vm){var helper=this.helper;return helper(vm,this.args.evaluate(vm),this.symbolTable);};CompiledHelper.prototype.toJSON = function toJSON(){return '`' + this.name.join('.') + '($ARGS)`';};return CompiledHelper;})(CompiledExpression);var CompiledConcat=(function(){function CompiledConcat(parts){this.parts = parts;this.type = "concat";}CompiledConcat.prototype.evaluate = function evaluate(vm){var parts=new Array(this.parts.length);for(var i=0;i < this.parts.length;i++) {parts[i] = this.parts[i].evaluate(vm);}return new ConcatReference(parts);};CompiledConcat.prototype.toJSON = function toJSON(){return 'concat(' + this.parts.map(function(expr){return expr.toJSON();}).join(", ") + ')';};return CompiledConcat;})();var ConcatReference=(function(_CachedReference2){babelHelpers.inherits(ConcatReference,_CachedReference2);function ConcatReference(parts){_CachedReference2.call(this);this.parts = parts;this.tag = _glimmerReference.combineTagged(parts);}ConcatReference.prototype.compute = function compute(){var parts=new Array();for(var i=0;i < this.parts.length;i++) {var value=this.parts[i].value();if(value !== null && value !== undefined){parts[i] = castToString(value);}}if(parts.length > 0){return parts.join('');}return null;};return ConcatReference;})(_glimmerReference.CachedReference);function castToString(value){if(typeof value['toString'] !== 'function'){return '';}return String(value);}var CompiledFunctionExpression=(function(_CompiledExpression9){babelHelpers.inherits(CompiledFunctionExpression,_CompiledExpression9);function CompiledFunctionExpression(func,symbolTable){_CompiledExpression9.call(this);this.func = func;this.symbolTable = symbolTable;this.type = "function";this.func = func;}CompiledFunctionExpression.prototype.evaluate = function evaluate(vm){var func=this.func;var symbolTable=this.symbolTable;return func(vm,symbolTable);};CompiledFunctionExpression.prototype.toJSON = function toJSON(){var func=this.func;if(func.name){return '`' + func.name + '(...)`';}else {return "`func(...)`";}};return CompiledFunctionExpression;})(CompiledExpression);function debugCallback(context,get){console.info('Use `context`, and `get()` to debug this template.'); /* tslint:disable */debugger; /* tslint:enable */return {context:context,get:get};}function getter(vm,builder){return function(path){var parts=path.split('.');if(parts[0] === 'this'){parts[0] = null;}return compileRef(parts,builder).evaluate(vm);};}var callback=debugCallback; // For testing purposes +function setDebuggerCallback(cb){callback = cb;}function resetDebuggerCallback(){callback = debugCallback;}var Compilers=(function(){function Compilers(){this.names = _glimmerUtil.dict();this.funcs = [];}Compilers.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Compilers.prototype.compile = function compile(sexp,builder){var name=sexp[0];var index=this.names[name];var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected an implementation for ' + sexp[0]);return func(sexp,builder);};return Compilers;})();var STATEMENTS=new Compilers();STATEMENTS.add('text',function(sexp,builder){builder.text(sexp[1]);});STATEMENTS.add('comment',function(sexp,builder){builder.comment(sexp[1]);});STATEMENTS.add('close-element',function(_sexp,builder){_glimmerUtil.LOGGER.trace('close-element statement');builder.closeElement();});STATEMENTS.add('flush-element',function(_sexp,builder){builder.flushElement();});STATEMENTS.add('modifier',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var args=compileArgs(params,hash,builder);if(builder.env.hasModifier(path,builder.symbolTable)){builder.modifier(path[0],args);}else {throw new Error('Compile Error ' + path.join('.') + ' is not a modifier: Helpers may not be used in the element form.');}});STATEMENTS.add('static-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];builder.staticAttr(name,namespace,value);});STATEMENTS.add('any-dynamic-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];var trusting=sexp[4];builder.putValue(value);if(namespace){builder.dynamicAttrNS(name,namespace,trusting);}else {builder.dynamicAttr(name,trusting);}});STATEMENTS.add('open-element',function(sexp,builder){_glimmerUtil.LOGGER.trace('open-element statement');builder.openPrimitiveElement(sexp[1]);});STATEMENTS.add('optimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros=builder.env.macros();var inlines=_builder$env$macros.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;builder.putValue(returned[1]);if(trustingMorph){builder.trustingAppend();}else {builder.cautiousAppend();}});STATEMENTS.add('unoptimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros2=builder.env.macros();var inlines=_builder$env$macros2.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;if(trustingMorph){builder.guardedTrustingAppend(returned[1]);}else {builder.guardedCautiousAppend(returned[1]);}});STATEMENTS.add('nested-block',function(sexp,builder){var _builder$env$macros3=builder.env.macros();var blocks=_builder$env$macros3.blocks;blocks.compile(sexp,builder);});STATEMENTS.add('scanned-block',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var template=sexp[4];var inverse=sexp[5];var templateBlock=template && template.scan();var inverseBlock=inverse && inverse.scan();var _builder$env$macros4=builder.env.macros();var blocks=_builder$env$macros4.blocks;blocks.compile(['nested-block',path,params,hash,templateBlock,inverseBlock],builder);});STATEMENTS.add('scanned-component',function(sexp,builder){var tag=sexp[1];var attrs=sexp[2];var rawArgs=sexp[3];var rawBlock=sexp[4];var block=rawBlock && rawBlock.scan();var args=compileBlockArgs(null,rawArgs,{default:block,inverse:null},builder);var definition=builder.env.getComponentDefinition([tag],builder.symbolTable);builder.putComponentDefinition(definition);builder.openComponent(args,attrs.scan());builder.closeComponent();});STATEMENTS.add('static-partial',function(sexp,builder){var name=sexp[1];if(!builder.env.hasPartial(name,builder.symbolTable)){throw new Error('Compile Error: Could not find a partial named "' + name + '"');}var definition=builder.env.lookupPartial(name,builder.symbolTable);builder.putPartialDefinition(definition);builder.evaluatePartial();});STATEMENTS.add('dynamic-partial',function(sexp,builder){var name=sexp[1];builder.startLabels();builder.putValue(name);builder.test('simple');builder.enter('BEGIN','END');builder.label('BEGIN');builder.jumpUnless('END');builder.putDynamicPartialDefinition();builder.evaluatePartial();builder.label('END');builder.exit();builder.stopLabels();});STATEMENTS.add('yield',function(sexp,builder){var to=sexp[1];var params=sexp[2];var args=compileArgs(params,null,builder);builder.yield(args,to);});STATEMENTS.add('debugger',function(sexp,builder){builder.putValue(['function',function(vm){var context=vm.getSelf().value();var get=function(path){return getter(vm,builder)(path).value();};callback(context,get);}]);return sexp;});var EXPRESSIONS=new Compilers();function expr(expression,builder){if(Array.isArray(expression)){return EXPRESSIONS.compile(expression,builder);}else {return new CompiledValue(expression);}}EXPRESSIONS.add('unknown',function(sexp,builder){var path=sexp[1];if(builder.env.hasHelper(path,builder.symbolTable)){return new CompiledHelper(path,builder.env.lookupHelper(path,builder.symbolTable),CompiledArgs.empty(),builder.symbolTable);}else {return compileRef(path,builder);}});EXPRESSIONS.add('concat',function(sexp,builder){var params=sexp[1].map(function(p){return expr(p,builder);});return new CompiledConcat(params);});EXPRESSIONS.add('function',function(sexp,builder){return new CompiledFunctionExpression(sexp[1],builder.symbolTable);});EXPRESSIONS.add('helper',function(sexp,builder){var env=builder.env;var symbolTable=builder.symbolTable;var path=sexp[1];var params=sexp[2];var hash=sexp[3];if(env.hasHelper(path,symbolTable)){var args=compileArgs(params,hash,builder);return new CompiledHelper(path,env.lookupHelper(path,symbolTable),args,symbolTable);}else {throw new Error('Compile Error: ' + path.join('.') + ' is not a helper');}});EXPRESSIONS.add('get',function(sexp,builder){return compileRef(sexp[1],builder);});EXPRESSIONS.add('undefined',function(_sexp,_builder){return new CompiledValue(undefined);});EXPRESSIONS.add('arg',function(sexp,builder){var parts=sexp[1];var head=parts[0];var named=undefined,partial=undefined;if(named = builder.symbolTable.getSymbol('named',head)){var path=parts.slice(1);var inner=new CompiledSymbol(named,head);return CompiledLookup.create(inner,path);}else if(partial = builder.symbolTable.getPartialArgs()){var path=parts.slice(1);var inner=new CompiledInPartialName(partial,head);return CompiledLookup.create(inner,path);}else {throw new Error('[BUG] @' + parts.join('.') + ' is not a valid lookup path.');}});EXPRESSIONS.add('has-block',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlock(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlock(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});EXPRESSIONS.add('has-block-params',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlockParams(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlockParams(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});function compileArgs(params,hash,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,EMPTY_BLOCKS);}function compileBlockArgs(params,hash,blocks,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,blocks);}function compileBaselineArgs(args,builder){var params=args[0];var hash=args[1];var _default=args[2];var inverse=args[3];return CompiledArgs.create(compileParams(params,builder),compileHash(hash,builder),{default:_default,inverse:inverse});}function compileParams(params,builder){if(!params || params.length === 0)return COMPILED_EMPTY_POSITIONAL_ARGS;var compiled=params.map(function(p){return expr(p,builder);});return CompiledPositionalArgs.create(compiled);}function compileHash(hash,builder){if(!hash)return COMPILED_EMPTY_NAMED_ARGS;var keys=hash[0];var values=hash[1];if(keys.length === 0)return COMPILED_EMPTY_NAMED_ARGS;var compiled=values.map(function(p){return expr(p,builder);});return new CompiledNamedArgs(keys,compiled);}function compileRef(parts,builder){var head=parts[0];var local=undefined;if(head === null){var inner=new CompiledSelf();var path=parts.slice(1);return CompiledLookup.create(inner,path);}else if(local = builder.symbolTable.getSymbol('local',head)){var path=parts.slice(1);var inner=new CompiledSymbol(local,head);return CompiledLookup.create(inner,path);}else {var inner=new CompiledSelf();return CompiledLookup.create(inner,parts);}}var Blocks=(function(){function Blocks(){this.names = _glimmerUtil.dict();this.funcs = [];}Blocks.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Blocks.prototype.addMissing = function addMissing(func){this.missing = func;};Blocks.prototype.compile = function compile(sexp,builder){ // assert(sexp[1].length === 1, 'paths in blocks are not supported'); +var name=sexp[1][0];var index=this.names[name];if(index === undefined){_glimmerUtil.assert(!!this.missing,name + ' not found, and no catch-all block handler was registered');var func=this.missing;var handled=func(sexp,builder);_glimmerUtil.assert(!!handled,name + ' not found, and the catch-all block handler didn\'t handle it');}else {var func=this.funcs[index];func(sexp,builder);}};return Blocks;})();var BLOCKS=new Blocks();var Inlines=(function(){function Inlines(){this.names = _glimmerUtil.dict();this.funcs = [];}Inlines.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Inlines.prototype.addMissing = function addMissing(func){this.missing = func;};Inlines.prototype.compile = function compile(sexp,builder){var value=sexp[1]; // TODO: Fix this so that expression macros can return +// things like components, so that {{component foo}} +// is the same as {{(component foo)}} +if(!Array.isArray(value))return ['expr',value];var path=undefined;var params=undefined;var hash=undefined;if(value[0] === 'helper'){path = value[1];params = value[2];hash = value[3];}else if(value[0] === 'unknown'){path = value[1];params = hash = null;}else {return ['expr',value];}if(path.length > 1 && !params && !hash){return ['expr',value];}var name=path[0];var index=this.names[name];if(index === undefined && this.missing){var func=this.missing;var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else if(index !== undefined){var func=this.funcs[index];var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else {return ['expr',value];}};return Inlines;})();var INLINES=new Inlines();populateBuiltins(BLOCKS,INLINES);function populateBuiltins(){var blocks=arguments.length <= 0 || arguments[0] === undefined?new Blocks():arguments[0];var inlines=arguments.length <= 1 || arguments[1] === undefined?new Inlines():arguments[1];blocks.add('if',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('unless',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpIf('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpIf('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('with',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('each',function(sexp,builder){ // Enter(BEGIN, END) +// BEGIN: Noop +// PutArgs +// PutIterable +// JumpUnless(ELSE) +// EnterList(BEGIN2, END2) +// ITER: Noop +// NextIter(BREAK) +// EnterWithKey(BEGIN2, END2) +// BEGIN2: Noop +// PushChildScope +// Evaluate(default) +// PopScope +// END2: Noop +// Exit +// Jump(ITER) +// BREAK: Noop +// ExitList +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.labelled(args,function(b){b.putIterator();if(inverse){b.jumpUnless('ELSE');}else {b.jumpUnless('END');}b.iter(function(b){b.evaluate(_glimmerUtil.unwrap(_default));});if(inverse){b.jump('END');b.label('ELSE');b.evaluate(inverse);}});});return {blocks:blocks,inlines:inlines};}var badProtocols=['javascript:','vbscript:'];var badTags=['A','BODY','LINK','IMG','IFRAME','BASE','FORM'];var badTagsForDataURI=['EMBED'];var badAttributes=['href','src','background','action'];var badAttributesForDataURI=['src'];function has(array,item){return array.indexOf(item) !== -1;}function checkURI(tagName,attribute){return (tagName === null || has(badTags,tagName)) && has(badAttributes,attribute);}function checkDataURI(tagName,attribute){if(tagName === null)return false;return has(badTagsForDataURI,tagName) && has(badAttributesForDataURI,attribute);}function requiresSanitization(tagName,attribute){return checkURI(tagName,attribute) || checkDataURI(tagName,attribute);}function sanitizeAttributeValue(env,element,attribute,value){var tagName=null;if(value === null || value === undefined){return value;}if(isSafeString(value)){return value.toHTML();}if(!element){tagName = null;}else {tagName = element.tagName.toUpperCase();}var str=normalizeTextValue(value);if(checkURI(tagName,attribute)){var protocol=env.protocolForURL(str);if(has(badProtocols,protocol)){return 'unsafe:' + str;}}if(checkDataURI(tagName,attribute)){return 'unsafe:' + str;}return str;} /* + * @method normalizeProperty + * @param element {HTMLElement} + * @param slotName {String} + * @returns {Object} { name, type } + */function normalizeProperty(element,slotName){var type=undefined,normalized=undefined;if(slotName in element){normalized = slotName;type = 'prop';}else {var lower=slotName.toLowerCase();if(lower in element){type = 'prop';normalized = lower;}else {type = 'attr';normalized = slotName;}}if(type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName,normalized))){type = 'attr';}return {normalized:normalized,type:type};} // properties that MUST be set as attributes, due to: +// * browser bug +// * strange spec outlier +var ATTR_OVERRIDES={ // phantomjs < 2.0 lets you set it as a prop but won't reflect it +// back to the attribute. button.getAttribute('type') === null +BUTTON:{type:true,form:true},INPUT:{ // Some version of IE (like IE9) actually throw an exception +// if you set input.type = 'something-unknown' +type:true,form:true, // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false +// Safari 8.0.7: 'autocorrect' in document.createElement('input') === false +// Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true +autocorrect:true, // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true +// Safari 9.1.3: 'list' in document.createElement('input') === false +list:true}, // element.form is actually a legitimate readOnly property, that is to be +// mutated, but must be mutated by setAttribute... +SELECT:{form:true},OPTION:{form:true},TEXTAREA:{form:true},LABEL:{form:true},FIELDSET:{form:true},LEGEND:{form:true},OBJECT:{form:true}};function preferAttr(tagName,propName){var tag=ATTR_OVERRIDES[tagName.toUpperCase()];return tag && tag[propName.toLowerCase()] || false;}var innerHTMLWrapper={colgroup:{depth:2,before:'',after:'
    '},table:{depth:1,before:'',after:'
    '},tbody:{depth:2,before:'',after:'
    '},tfoot:{depth:2,before:'',after:'
    '},thead:{depth:2,before:'',after:'
    '},tr:{depth:3,before:'',after:'
    '}}; // Patch: innerHTML Fix +// Browsers: IE9 +// Reason: IE9 don't allow us to set innerHTML on col, colgroup, frameset, +// html, style, table, tbody, tfoot, thead, title, tr. +// Fix: Wrap the innerHTML we are about to set in its parents, apply the +// wrapped innerHTML on a div, then move the unwrapped nodes into the +// target position. +function domChanges(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix(document)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass){babelHelpers.inherits(DOMChangesWithInnerHTMLFix,_DOMChangesClass);function DOMChangesWithInnerHTMLFix(){_DOMChangesClass.apply(this,arguments);}DOMChangesWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixInnerHTML(parent,wrapper,div,html,nextSibling);};return DOMChangesWithInnerHTMLFix;})(DOMChangesClass);}function treeConstruction(document,DOMTreeConstructionClass){if(!document)return DOMTreeConstructionClass;if(!shouldApplyFix(document)){return DOMTreeConstructionClass;}var div=document.createElement('div');return (function(_DOMTreeConstructionClass){babelHelpers.inherits(DOMTreeConstructionWithInnerHTMLFix,_DOMTreeConstructionClass);function DOMTreeConstructionWithInnerHTMLFix(){_DOMTreeConstructionClass.apply(this,arguments);}DOMTreeConstructionWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixInnerHTML(parent,wrapper,div,html,reference);};return DOMTreeConstructionWithInnerHTMLFix;})(DOMTreeConstructionClass);}function fixInnerHTML(parent,wrapper,div,html,reference){var wrappedHtml=wrapper.before + html + wrapper.after;div.innerHTML = wrappedHtml;var parentNode=div;for(var i=0;i < wrapper.depth;i++) {parentNode = parentNode.childNodes[0];}var _moveNodesBefore=moveNodesBefore(parentNode,parent,reference);var first=_moveNodesBefore[0];var last=_moveNodesBefore[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix(document){var table=document.createElement('table');try{table.innerHTML = '';}catch(e) {}finally {if(table.childNodes.length !== 0){ // It worked as expected, no fix required +return false;}}return true;}var SVG_NAMESPACE$1='http://www.w3.org/2000/svg'; // Patch: insertAdjacentHTML on SVG Fix +// Browsers: Safari, IE, Edge, Firefox ~33-34 +// Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is +// present but throws an exception on IE and Edge. Old versions of +// Firefox create nodes in the incorrect namespace. +// Fix: Since IE and Edge silently fail to create SVG nodes using +// innerHTML, and because Firefox may create nodes in the incorrect +// namespace using innerHTML on SVG elements, an HTML-string wrapping +// approach is used. A pre/post SVG tag is added to the string, then +// that whole string is added to a div. The created nodes are plucked +// out and applied to the target location on DOM. +function domChanges$1(document,DOMChangesClass,svgNamespace){if(!document)return DOMChangesClass;if(!shouldApplyFix$1(document,svgNamespace)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass2){babelHelpers.inherits(DOMChangesWithSVGInnerHTMLFix,_DOMChangesClass2);function DOMChangesWithSVGInnerHTMLFix(){_DOMChangesClass2.apply(this,arguments);}DOMChangesWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}if(parent.namespaceURI !== svgNamespace){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixSVG(parent,div,html,nextSibling);};return DOMChangesWithSVGInnerHTMLFix;})(DOMChangesClass);}function treeConstruction$1(document,TreeConstructionClass,svgNamespace){if(!document)return TreeConstructionClass;if(!shouldApplyFix$1(document,svgNamespace)){return TreeConstructionClass;}var div=document.createElement('div');return (function(_TreeConstructionClass){babelHelpers.inherits(TreeConstructionWithSVGInnerHTMLFix,_TreeConstructionClass);function TreeConstructionWithSVGInnerHTMLFix(){_TreeConstructionClass.apply(this,arguments);}TreeConstructionWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}if(parent.namespaceURI !== svgNamespace){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixSVG(parent,div,html,reference);};return TreeConstructionWithSVGInnerHTMLFix;})(TreeConstructionClass);}function fixSVG(parent,div,html,reference){ // IE, Edge: also do not correctly support using `innerHTML` on SVG +// namespaced elements. So here a wrapper is used. +var wrappedHtml='' + html + '';div.innerHTML = wrappedHtml;var _moveNodesBefore2=moveNodesBefore(div.firstChild,parent,reference);var first=_moveNodesBefore2[0];var last=_moveNodesBefore2[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix$1(document,svgNamespace){var svg=document.createElementNS(svgNamespace,'svg');try{svg['insertAdjacentHTML']('beforeEnd','');}catch(e) {}finally { // FF: Old versions will create a node in the wrong namespace +if(svg.childNodes.length === 1 && _glimmerUtil.unwrap(svg.firstChild).namespaceURI === SVG_NAMESPACE$1){ // The test worked as expected, no fix required +return false;}return true;}} // Patch: Adjacent text node merging fix +// Browsers: IE, Edge, Firefox w/o inspector open +// Reason: These browsers will merge adjacent text nodes. For exmaple given +//
    Hello
    with div.insertAdjacentHTML(' world') browsers +// with proper behavior will populate div.childNodes with two items. +// These browsers will populate it with one merged node instead. +// Fix: Add these nodes to a wrapper element, then iterate the childNodes +// of that wrapper and move the nodes to their target location. Note +// that potential SVG bugs will have been handled before this fix. +// Note that this fix must only apply to the previous text node, as +// the base implementation of `insertHTMLBefore` already handles +// following text nodes correctly. +function domChanges$2(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix$2(document)){return DOMChangesClass;}return (function(_DOMChangesClass3){babelHelpers.inherits(DOMChangesWithTextNodeMergingFix,_DOMChangesClass3);function DOMChangesWithTextNodeMergingFix(document){_DOMChangesClass3.call(this,document);this.uselessComment = document.createComment('');}DOMChangesWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null){return _DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var didSetUselessComment=false;var nextPrevious=nextSibling?nextSibling.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,nextSibling);}var bounds=_DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return DOMChangesWithTextNodeMergingFix;})(DOMChangesClass);}function treeConstruction$2(document,TreeConstructionClass){if(!document)return TreeConstructionClass;if(!shouldApplyFix$2(document)){return TreeConstructionClass;}return (function(_TreeConstructionClass2){babelHelpers.inherits(TreeConstructionWithTextNodeMergingFix,_TreeConstructionClass2);function TreeConstructionWithTextNodeMergingFix(document){_TreeConstructionClass2.call(this,document);this.uselessComment = this.createComment('');}TreeConstructionWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null){return _TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);}var didSetUselessComment=false;var nextPrevious=reference?reference.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,reference);}var bounds=_TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return TreeConstructionWithTextNodeMergingFix;})(TreeConstructionClass);}function shouldApplyFix$2(document){var mergingTextDiv=document.createElement('div');mergingTextDiv.innerHTML = 'first';mergingTextDiv.insertAdjacentHTML('beforeEnd','second');if(mergingTextDiv.childNodes.length === 2){ // It worked as expected, no fix required +return false;}return true;}var SVG_NAMESPACE='http://www.w3.org/2000/svg'; // http://www.w3.org/TR/html/syntax.html#html-integration-point +var SVG_INTEGRATION_POINTS={foreignObject:1,desc:1,title:1}; // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes +// TODO: Adjust SVG attributes +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +// TODO: Adjust SVG elements +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +var BLACKLIST_TABLE=Object.create(null);["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach(function(tag){return BLACKLIST_TABLE[tag] = 1;});var WHITESPACE=/[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;var doc=typeof document === 'undefined'?null:document;function isWhitespace(string){return WHITESPACE.test(string);}function moveNodesBefore(source,target,nextSibling){var first=source.firstChild;var last=null;var current=first;while(current) {last = current;current = current.nextSibling;target.insertBefore(last,nextSibling);}return [first,last];}var DOM;(function(DOM){var TreeConstruction=(function(){function TreeConstruction(document){this.document = document;this.setupUselessElement();}TreeConstruction.prototype.setupUselessElement = function setupUselessElement(){this.uselessElement = this.document.createElement('div');};TreeConstruction.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};TreeConstruction.prototype.createElementNS = function createElementNS(namespace,tag){return this.document.createElementNS(namespace,tag);};TreeConstruction.prototype.setAttribute = function setAttribute(element,name,value,namespace){if(namespace){element.setAttributeNS(namespace,name,value);}else {element.setAttribute(name,value);}};TreeConstruction.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};TreeConstruction.prototype.createComment = function createComment(data){return this.document.createComment(data);};TreeConstruction.prototype.insertBefore = function insertBefore(parent,node,reference){parent.insertBefore(node,reference);};TreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){return _insertHTMLBefore(this.uselessElement,parent,reference,html);};return TreeConstruction;})();DOM.TreeConstruction = TreeConstruction;var appliedTreeContruction=TreeConstruction;appliedTreeContruction = treeConstruction$2(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction$1(doc,appliedTreeContruction,SVG_NAMESPACE);DOM.DOMTreeConstruction = appliedTreeContruction;})(DOM || (DOM = {}));var DOMChanges=(function(){function DOMChanges(document){this.document = document;this.namespace = null;this.uselessElement = this.document.createElement('div');}DOMChanges.prototype.setAttribute = function setAttribute(element,name,value){element.setAttribute(name,value);};DOMChanges.prototype.setAttributeNS = function setAttributeNS(element,namespace,name,value){element.setAttributeNS(namespace,name,value);};DOMChanges.prototype.removeAttribute = function removeAttribute(element,name){element.removeAttribute(name);};DOMChanges.prototype.removeAttributeNS = function removeAttributeNS(element,namespace,name){element.removeAttributeNS(namespace,name);};DOMChanges.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};DOMChanges.prototype.createComment = function createComment(data){return this.document.createComment(data);};DOMChanges.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};DOMChanges.prototype.insertHTMLBefore = function insertHTMLBefore(_parent,nextSibling,html){return _insertHTMLBefore(this.uselessElement,_parent,nextSibling,html);};DOMChanges.prototype.insertNodeBefore = function insertNodeBefore(parent,node,reference){if(isDocumentFragment(node)){var firstChild=node.firstChild;var lastChild=node.lastChild;this.insertBefore(parent,node,reference);return new ConcreteBounds(parent,firstChild,lastChild);}else {this.insertBefore(parent,node,reference);return new SingleNodeBounds(parent,node);}};DOMChanges.prototype.insertTextBefore = function insertTextBefore(parent,nextSibling,text){var textNode=this.createTextNode(text);this.insertBefore(parent,textNode,nextSibling);return textNode;};DOMChanges.prototype.insertBefore = function insertBefore(element,node,reference){element.insertBefore(node,reference);};DOMChanges.prototype.insertAfter = function insertAfter(element,node,reference){this.insertBefore(element,node,reference.nextSibling);};return DOMChanges;})();function _insertHTMLBefore(_useless,_parent,_nextSibling,html){ // TypeScript vendored an old version of the DOM spec where `insertAdjacentHTML` +// only exists on `HTMLElement` but not on `Element`. We actually work with the +// newer version of the DOM API here (and monkey-patch this method in `./compat` +// when we detect older browsers). This is a hack to work around this limitation. +var parent=_parent;var useless=_useless;var nextSibling=_nextSibling;var prev=nextSibling?nextSibling.previousSibling:parent.lastChild;var last=undefined;if(html === null || html === ''){return new ConcreteBounds(parent,null,null);}if(nextSibling === null){parent.insertAdjacentHTML('beforeEnd',html);last = parent.lastChild;}else if(nextSibling instanceof HTMLElement){nextSibling.insertAdjacentHTML('beforeBegin',html);last = nextSibling.previousSibling;}else { // Non-element nodes do not support insertAdjacentHTML, so add an +// element and call it on that element. Then remove the element. +// +// This also protects Edge, IE and Firefox w/o the inspector open +// from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts +parent.insertBefore(useless,nextSibling);useless.insertAdjacentHTML('beforeBegin',html);last = useless.previousSibling;parent.removeChild(useless);}var first=prev?prev.nextSibling:parent.firstChild;return new ConcreteBounds(parent,first,last);}function isDocumentFragment(node){return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;}var helper=DOMChanges;helper = domChanges$2(doc,helper);helper = domChanges(doc,helper);helper = domChanges$1(doc,helper,SVG_NAMESPACE);var helper$1=helper;var DOMTreeConstruction=DOM.DOMTreeConstruction;function defaultManagers(element,attr,_isTrusting,_namespace){var tagName=element.tagName;var isSVG=element.namespaceURI === SVG_NAMESPACE;if(isSVG){return defaultAttributeManagers(tagName,attr);}var _normalizeProperty=normalizeProperty(element,attr);var type=_normalizeProperty.type;var normalized=_normalizeProperty.normalized;if(type === 'attr'){return defaultAttributeManagers(tagName,normalized);}else {return defaultPropertyManagers(tagName,normalized);}}function defaultPropertyManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafePropertyManager(attr);}if(isUserInputValue(tagName,attr)){return INPUT_VALUE_PROPERTY_MANAGER;}if(isOptionSelected(tagName,attr)){return OPTION_SELECTED_MANAGER;}return new PropertyManager(attr);}function defaultAttributeManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafeAttributeManager(attr);}return new AttributeManager(attr);}function readDOMAttr(element,attr){var isSVG=element.namespaceURI === SVG_NAMESPACE;var _normalizeProperty2=normalizeProperty(element,attr);var type=_normalizeProperty2.type;var normalized=_normalizeProperty2.normalized;if(isSVG){return element.getAttribute(normalized);}if(type === 'attr'){return element.getAttribute(normalized);}{return element[normalized];}};var AttributeManager=(function(){function AttributeManager(attr){this.attr = attr;}AttributeManager.prototype.setAttribute = function setAttribute(env,element,value,namespace){var dom=env.getAppendOperations();var normalizedValue=normalizeAttributeValue(value);if(!isAttrRemovalValue(normalizedValue)){dom.setAttribute(element,this.attr,normalizedValue,namespace);}};AttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){if(value === null || value === undefined || value === false){if(namespace){env.getDOM().removeAttributeNS(element,namespace,this.attr);}else {env.getDOM().removeAttribute(element,this.attr);}}else {this.setAttribute(env,element,value);}};return AttributeManager;})();;var PropertyManager=(function(_AttributeManager){babelHelpers.inherits(PropertyManager,_AttributeManager);function PropertyManager(){_AttributeManager.apply(this,arguments);}PropertyManager.prototype.setAttribute = function setAttribute(_env,element,value,_namespace){if(!isAttrRemovalValue(value)){element[this.attr] = value;}};PropertyManager.prototype.removeAttribute = function removeAttribute(env,element,namespace){ // TODO this sucks but to preserve properties first and to meet current +// semantics we must do this. +var attr=this.attr;if(namespace){env.getDOM().removeAttributeNS(element,namespace,attr);}else {env.getDOM().removeAttribute(element,attr);}};PropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){ // ensure the property is always updated +element[this.attr] = value;if(isAttrRemovalValue(value)){this.removeAttribute(env,element,namespace);}};return PropertyManager;})(AttributeManager);;function normalizeAttributeValue(value){if(value === false || value === undefined || value === null){return null;}if(value === true){return '';} // onclick function etc in SSR +if(typeof value === 'function'){return null;}return String(value);}function isAttrRemovalValue(value){return value === null || value === undefined;}var SafePropertyManager=(function(_PropertyManager){babelHelpers.inherits(SafePropertyManager,_PropertyManager);function SafePropertyManager(){_PropertyManager.apply(this,arguments);}SafePropertyManager.prototype.setAttribute = function setAttribute(env,element,value){_PropertyManager.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafePropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value){_PropertyManager.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafePropertyManager;})(PropertyManager);function isUserInputValue(tagName,attribute){return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value';}var InputValuePropertyManager=(function(_AttributeManager2){babelHelpers.inherits(InputValuePropertyManager,_AttributeManager2);function InputValuePropertyManager(){_AttributeManager2.apply(this,arguments);}InputValuePropertyManager.prototype.setAttribute = function setAttribute(_env,element,value){var input=element;input.value = normalizeTextValue(value);};InputValuePropertyManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var input=element;var currentValue=input.value;var normalizedValue=normalizeTextValue(value);if(currentValue !== normalizedValue){input.value = normalizedValue;}};return InputValuePropertyManager;})(AttributeManager);var INPUT_VALUE_PROPERTY_MANAGER=new InputValuePropertyManager('value');function isOptionSelected(tagName,attribute){return tagName === 'OPTION' && attribute === 'selected';}var OptionSelectedManager=(function(_PropertyManager2){babelHelpers.inherits(OptionSelectedManager,_PropertyManager2);function OptionSelectedManager(){_PropertyManager2.apply(this,arguments);}OptionSelectedManager.prototype.setAttribute = function setAttribute(_env,element,value){if(value !== null && value !== undefined && value !== false){var option=element;option.selected = true;}};OptionSelectedManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var option=element;if(value){option.selected = true;}else {option.selected = false;}};return OptionSelectedManager;})(PropertyManager);var OPTION_SELECTED_MANAGER=new OptionSelectedManager('selected');var SafeAttributeManager=(function(_AttributeManager3){babelHelpers.inherits(SafeAttributeManager,_AttributeManager3);function SafeAttributeManager(){_AttributeManager3.apply(this,arguments);}SafeAttributeManager.prototype.setAttribute = function setAttribute(env,element,value){_AttributeManager3.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafeAttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,_namespace){_AttributeManager3.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafeAttributeManager;})(AttributeManager);var Scope=(function(){function Scope(references){var callerScope=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];this.callerScope = null;this.slots = references;this.callerScope = callerScope;}Scope.root = function root(self){var size=arguments.length <= 1 || arguments[1] === undefined?0:arguments[1];var refs=new Array(size + 1);for(var i=0;i <= size;i++) {refs[i] = UNDEFINED_REFERENCE;}return new Scope(refs).init({self:self});};Scope.prototype.init = function init(_ref26){var self=_ref26.self;this.slots[0] = self;return this;};Scope.prototype.getSelf = function getSelf(){return this.slots[0];};Scope.prototype.getSymbol = function getSymbol(symbol){return this.slots[symbol];};Scope.prototype.getBlock = function getBlock(symbol){return this.slots[symbol];};Scope.prototype.getPartialArgs = function getPartialArgs(symbol){return this.slots[symbol];};Scope.prototype.bindSymbol = function bindSymbol(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindBlock = function bindBlock(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindPartialArgs = function bindPartialArgs(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindCallerScope = function bindCallerScope(scope){this.callerScope = scope;};Scope.prototype.getCallerScope = function getCallerScope(){return this.callerScope;};Scope.prototype.child = function child(){return new Scope(this.slots.slice(),this.callerScope);};return Scope;})();var Transaction=(function(){function Transaction(){this.scheduledInstallManagers = [];this.scheduledInstallModifiers = [];this.scheduledUpdateModifierManagers = [];this.scheduledUpdateModifiers = [];this.createdComponents = [];this.createdManagers = [];this.updatedComponents = [];this.updatedManagers = [];this.destructors = [];}Transaction.prototype.didCreate = function didCreate(component,manager){this.createdComponents.push(component);this.createdManagers.push(manager);};Transaction.prototype.didUpdate = function didUpdate(component,manager){this.updatedComponents.push(component);this.updatedManagers.push(manager);};Transaction.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.scheduledInstallManagers.push(manager);this.scheduledInstallModifiers.push(modifier);};Transaction.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.scheduledUpdateModifierManagers.push(manager);this.scheduledUpdateModifiers.push(modifier);};Transaction.prototype.didDestroy = function didDestroy(d){this.destructors.push(d);};Transaction.prototype.commit = function commit(){var createdComponents=this.createdComponents;var createdManagers=this.createdManagers;for(var i=0;i < createdComponents.length;i++) {var component=createdComponents[i];var manager=createdManagers[i];manager.didCreate(component);}var updatedComponents=this.updatedComponents;var updatedManagers=this.updatedManagers;for(var i=0;i < updatedComponents.length;i++) {var component=updatedComponents[i];var manager=updatedManagers[i];manager.didUpdate(component);}var destructors=this.destructors;for(var i=0;i < destructors.length;i++) {destructors[i].destroy();}var scheduledInstallManagers=this.scheduledInstallManagers;var scheduledInstallModifiers=this.scheduledInstallModifiers;for(var i=0;i < scheduledInstallManagers.length;i++) {var manager=scheduledInstallManagers[i];var modifier=scheduledInstallModifiers[i];manager.install(modifier);}var scheduledUpdateModifierManagers=this.scheduledUpdateModifierManagers;var scheduledUpdateModifiers=this.scheduledUpdateModifiers;for(var i=0;i < scheduledUpdateModifierManagers.length;i++) {var manager=scheduledUpdateModifierManagers[i];var modifier=scheduledUpdateModifiers[i];manager.update(modifier);}};return Transaction;})();var Opcode=(function(){function Opcode(array){this.array = array;this.offset = 0;}babelHelpers.createClass(Opcode,[{key:'type',get:function(){return this.array[this.offset];}},{key:'op1',get:function(){return this.array[this.offset + 1];}},{key:'op2',get:function(){return this.array[this.offset + 2];}},{key:'op3',get:function(){return this.array[this.offset + 3];}}]);return Opcode;})();var Program=(function(){function Program(){this.opcodes = new _glimmerUtil.A(0x100000);this._offset = 0;this._opcode = new Opcode(this.opcodes);}Program.prototype.opcode = function opcode(offset){this._opcode.offset = offset;return this._opcode;};Program.prototype.set = function set(pos,opcode){var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[pos] = type;this.opcodes[pos + 1] = op1;this.opcodes[pos + 2] = op2;this.opcodes[pos + 3] = op3;};Program.prototype.push = function push(opcode){var offset=this._offset;var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[this._offset++] = type;this.opcodes[this._offset++] = op1;this.opcodes[this._offset++] = op2;this.opcodes[this._offset++] = op3;return offset;};babelHelpers.createClass(Program,[{key:'next',get:function(){return this._offset;}},{key:'current',get:function(){return this._offset - 4;}}]);return Program;})();var Environment=(function(){function Environment(_ref27){var appendOperations=_ref27.appendOperations;var updateOperations=_ref27.updateOperations;this._macros = null;this._transaction = null;this.constants = new Constants();this.program = new Program();this.appendOperations = appendOperations;this.updateOperations = updateOperations;}Environment.prototype.toConditionalReference = function toConditionalReference(reference){return new ConditionalReference(reference);};Environment.prototype.getAppendOperations = function getAppendOperations(){return this.appendOperations;};Environment.prototype.getDOM = function getDOM(){return this.updateOperations;};Environment.prototype.getIdentity = function getIdentity(object){return _glimmerUtil.ensureGuid(object) + '';};Environment.prototype.begin = function begin(){_glimmerUtil.assert(!this._transaction,'Cannot start a nested transaction');this._transaction = new Transaction();};Environment.prototype.didCreate = function didCreate(component,manager){this.transaction.didCreate(component,manager);};Environment.prototype.didUpdate = function didUpdate(component,manager){this.transaction.didUpdate(component,manager);};Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.transaction.scheduleInstallModifier(modifier,manager);};Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.transaction.scheduleUpdateModifier(modifier,manager);};Environment.prototype.didDestroy = function didDestroy(d){this.transaction.didDestroy(d);};Environment.prototype.commit = function commit(){this.transaction.commit();this._transaction = null;};Environment.prototype.attributeFor = function attributeFor(element,attr,isTrusting,namespace){return defaultManagers(element,attr,isTrusting,namespace === undefined?null:namespace);};Environment.prototype.macros = function macros(){var macros=this._macros;if(!macros){this._macros = macros = populateBuiltins();}return macros;};babelHelpers.createClass(Environment,[{key:'transaction',get:function(){return _glimmerUtil.expect(this._transaction,'must be in a transaction');}}]);return Environment;})();var RenderResult=(function(){function RenderResult(env,updating,bounds){this.env = env;this.updating = updating;this.bounds = bounds;}RenderResult.prototype.rerender = function rerender(){var _ref28=arguments.length <= 0 || arguments[0] === undefined?{alwaysRevalidate:false}:arguments[0];var _ref28$alwaysRevalidate=_ref28.alwaysRevalidate;var alwaysRevalidate=_ref28$alwaysRevalidate === undefined?false:_ref28$alwaysRevalidate;var env=this.env;var updating=this.updating;var vm=new UpdatingVM(env,{alwaysRevalidate:alwaysRevalidate});vm.execute(updating,this);};RenderResult.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};RenderResult.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};RenderResult.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};RenderResult.prototype.opcodes = function opcodes(){return this.updating;};RenderResult.prototype.handleException = function handleException(){throw "this should never happen";};RenderResult.prototype.destroy = function destroy(){this.bounds.destroy();clear(this.bounds);};return RenderResult;})();var CapturedFrame=function CapturedFrame(operand,args,condition){this.operand = operand;this.args = args;this.condition = condition;};var Frame=(function(){function Frame(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];this.ops = ops;this.component = component;this.manager = manager;this.shadow = shadow;this.operand = null;this.immediate = null;this.args = null;this.callerScope = null;this.blocks = null;this.condition = null;this.iterator = null;this.key = null;this.ip = ops[0];}Frame.prototype.capture = function capture(){return new CapturedFrame(this.operand,this.args,this.condition);};Frame.prototype.restore = function restore(frame){this.operand = frame['operand'];this.args = frame['args'];this.condition = frame['condition'];};return Frame;})();var FrameStack=(function(){function FrameStack(){this.frames = [];this.frame = null;}FrameStack.prototype.push = function push(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var frame=this.frame === null?this.frame = 0:++this.frame;if(this.frames.length <= frame){this.frames.push(null);}this.frames[frame] = new Frame(ops,component,manager,shadow);};FrameStack.prototype.pop = function pop(){var frames=this.frames;var frame=this.frame;frames[_glimmerUtil.expect(frame,'only pop after pushing')] = null;this.frame = frame === 0?null:frame - 1;};FrameStack.prototype.capture = function capture(){return this.currentFrame.capture();};FrameStack.prototype.restore = function restore(frame){this.currentFrame.restore(frame);};FrameStack.prototype.getOps = function getOps(){return this.currentFrame.ops;};FrameStack.prototype.getCurrent = function getCurrent(){return this.currentFrame.ip;};FrameStack.prototype.setCurrent = function setCurrent(ip){return this.currentFrame.ip = ip;};FrameStack.prototype.getOperand = function getOperand(){return _glimmerUtil.unwrap(this.currentFrame.operand);};FrameStack.prototype.setOperand = function setOperand(operand){return this.currentFrame.operand = operand;};FrameStack.prototype.getImmediate = function getImmediate(){return this.currentFrame.immediate;};FrameStack.prototype.setImmediate = function setImmediate(value){return this.currentFrame.immediate = value;}; // FIXME: These options are required in practice by the existing code, but +// figure out why. +FrameStack.prototype.getArgs = function getArgs(){return this.currentFrame.args;};FrameStack.prototype.setArgs = function setArgs(args){return this.currentFrame.args = args;};FrameStack.prototype.getCondition = function getCondition(){return _glimmerUtil.unwrap(this.currentFrame.condition);};FrameStack.prototype.setCondition = function setCondition(condition){return this.currentFrame.condition = condition;};FrameStack.prototype.getIterator = function getIterator(){return _glimmerUtil.unwrap(this.currentFrame.iterator);};FrameStack.prototype.setIterator = function setIterator(iterator){return this.currentFrame.iterator = iterator;};FrameStack.prototype.getKey = function getKey(){return this.currentFrame.key;};FrameStack.prototype.setKey = function setKey(key){return this.currentFrame.key = key;};FrameStack.prototype.getBlocks = function getBlocks(){return _glimmerUtil.unwrap(this.currentFrame.blocks);};FrameStack.prototype.setBlocks = function setBlocks(blocks){return this.currentFrame.blocks = blocks;};FrameStack.prototype.getCallerScope = function getCallerScope(){return _glimmerUtil.unwrap(this.currentFrame.callerScope);};FrameStack.prototype.setCallerScope = function setCallerScope(callerScope){return this.currentFrame.callerScope = callerScope;};FrameStack.prototype.getComponent = function getComponent(){return _glimmerUtil.unwrap(this.currentFrame.component);};FrameStack.prototype.getManager = function getManager(){return _glimmerUtil.unwrap(this.currentFrame.manager);};FrameStack.prototype.getShadow = function getShadow(){return this.currentFrame.shadow;};FrameStack.prototype.goto = function goto(ip){this.setCurrent(ip);};FrameStack.prototype.hasOpcodes = function hasOpcodes(){return this.frame !== null;};FrameStack.prototype.nextStatement = function nextStatement(env){var ip=this.frames[_glimmerUtil.unwrap(this.frame)].ip;var ops=this.getOps();if(ip <= ops[1]){var program=env.program;this.setCurrent(ip + 4);return program.opcode(ip);}else {this.pop();return null;}};babelHelpers.createClass(FrameStack,[{key:'currentFrame',get:function(){return this.frames[_glimmerUtil.unwrap(this.frame)];}}]);return FrameStack;})();var VM=(function(){function VM(env,scope,dynamicScope,elementStack){this.env = env;this.elementStack = elementStack;this.dynamicScopeStack = new _glimmerUtil.Stack();this.scopeStack = new _glimmerUtil.Stack();this.updatingOpcodeStack = new _glimmerUtil.Stack();this.cacheGroups = new _glimmerUtil.Stack();this.listBlockStack = new _glimmerUtil.Stack();this.frame = new FrameStack();this.env = env;this.constants = env.constants;this.elementStack = elementStack;this.scopeStack.push(scope);this.dynamicScopeStack.push(dynamicScope);}VM.initial = function initial(env,self,dynamicScope,elementStack,size){var scope=Scope.root(self,size);return new VM(env,scope,dynamicScope,elementStack);};VM.prototype.capture = function capture(){return {env:this.env,scope:this.scope(),dynamicScope:this.dynamicScope(),frame:this.frame.capture()};};VM.prototype.goto = function goto(ip){ // assert(this.frame.getOps().contains(op), `Illegal jump to ${op.label}`); +this.frame.goto(ip);};VM.prototype.beginCacheGroup = function beginCacheGroup(){this.cacheGroups.push(this.updating().tail());};VM.prototype.commitCacheGroup = function commitCacheGroup(){ // JumpIfNotModified(END) +// (head) +// (....) +// (tail) +// DidModify +// END: Noop +var END=new LabelOpcode("END");var opcodes=this.updating();var marker=this.cacheGroups.pop();var head=marker?opcodes.nextNode(marker):opcodes.head();var tail=opcodes.tail();var tag=_glimmerReference.combineSlice(new _glimmerUtil.ListSlice(head,tail));var guard=new JumpIfNotModifiedOpcode(tag,END);opcodes.insertBefore(guard,head);opcodes.append(new DidModifyOpcode(guard));opcodes.append(END);};VM.prototype.enter = function enter(sliceId){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var slice=this.constants.getSlice(sliceId);var tryOpcode=new TryOpcode(slice,state,tracker,updating);this.didEnter(tryOpcode,updating);};VM.prototype.enterWithKey = function enterWithKey(key,ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var tryOpcode=new TryOpcode(ops,state,tracker,updating);this.listBlock().map[key] = tryOpcode;this.didEnter(tryOpcode,updating);};VM.prototype.enterList = function enterList(ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushBlockList(updating);var state=this.capture();var artifacts=this.frame.getIterator().artifacts;var opcode=new ListBlockOpcode(ops,state,tracker,updating,artifacts);this.listBlockStack.push(opcode);this.didEnter(opcode,updating);};VM.prototype.didEnter = function didEnter(opcode,updating){this.updateWith(opcode);this.updatingOpcodeStack.push(updating);};VM.prototype.exit = function exit(){this.stack().popBlock();this.updatingOpcodeStack.pop();var parent=this.updating().tail();parent.didInitializeChildren();};VM.prototype.exitList = function exitList(){this.exit();this.listBlockStack.pop();};VM.prototype.updateWith = function updateWith(opcode){this.updating().append(opcode);};VM.prototype.listBlock = function listBlock(){return _glimmerUtil.expect(this.listBlockStack.current,'expected a list block');};VM.prototype.updating = function updating(){return _glimmerUtil.expect(this.updatingOpcodeStack.current,'expected updating opcode on the updating opcode stack');};VM.prototype.stack = function stack(){return this.elementStack;};VM.prototype.scope = function scope(){return _glimmerUtil.expect(this.scopeStack.current,'expected scope on the scope stack');};VM.prototype.dynamicScope = function dynamicScope(){return _glimmerUtil.expect(this.dynamicScopeStack.current,'expected dynamic scope on the dynamic scope stack');};VM.prototype.pushFrame = function pushFrame(block,args,callerScope){this.frame.push(block.slice);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushComponentFrame = function pushComponentFrame(layout,args,callerScope,component,manager,shadow){this.frame.push(layout.slice,component,manager,shadow);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushEvalFrame = function pushEvalFrame(slice){this.frame.push(slice);};VM.prototype.pushChildScope = function pushChildScope(){this.scopeStack.push(this.scope().child());};VM.prototype.pushCallerScope = function pushCallerScope(){this.scopeStack.push(_glimmerUtil.expect(this.scope().getCallerScope(),'pushCallerScope is called when a caller scope is present'));};VM.prototype.pushDynamicScope = function pushDynamicScope(){var child=this.dynamicScope().child();this.dynamicScopeStack.push(child);return child;};VM.prototype.pushRootScope = function pushRootScope(self,size){var scope=Scope.root(self,size);this.scopeStack.push(scope);return scope;};VM.prototype.popScope = function popScope(){this.scopeStack.pop();};VM.prototype.popDynamicScope = function popDynamicScope(){this.dynamicScopeStack.pop();};VM.prototype.newDestroyable = function newDestroyable(d){this.stack().newDestroyable(d);}; /// SCOPE HELPERS +VM.prototype.getSelf = function getSelf(){return this.scope().getSelf();};VM.prototype.referenceForSymbol = function referenceForSymbol(symbol){return this.scope().getSymbol(symbol);};VM.prototype.getArgs = function getArgs(){return this.frame.getArgs();}; /// EXECUTION +VM.prototype.resume = function resume(opcodes,frame){return this.execute(opcodes,function(vm){return vm.frame.restore(frame);});};VM.prototype.execute = function execute(opcodes,initialize){_glimmerUtil.LOGGER.debug("[VM] Begin program execution");var elementStack=this.elementStack;var frame=this.frame;var updatingOpcodeStack=this.updatingOpcodeStack;var env=this.env;elementStack.pushSimpleBlock();updatingOpcodeStack.push(new _glimmerUtil.LinkedList());frame.push(opcodes);if(initialize)initialize(this);var opcode=undefined;while(frame.hasOpcodes()) {if(opcode = frame.nextStatement(this.env)){_glimmerUtil.LOGGER.trace(opcode);APPEND_OPCODES.evaluate(this,opcode);}}_glimmerUtil.LOGGER.debug("[VM] Completed program execution");return new RenderResult(env,_glimmerUtil.expect(updatingOpcodeStack.pop(),'there should be a final updating opcode stack'),elementStack.popBlock());};VM.prototype.evaluateOpcode = function evaluateOpcode(opcode){APPEND_OPCODES.evaluate(this,opcode);}; // Make sure you have opcodes that push and pop a scope around this opcode +// if you need to change the scope. +VM.prototype.invokeBlock = function invokeBlock(block,args){var compiled=block.compile(this.env);this.pushFrame(compiled,args);};VM.prototype.invokePartial = function invokePartial(block){var compiled=block.compile(this.env);this.pushFrame(compiled);};VM.prototype.invokeLayout = function invokeLayout(args,layout,callerScope,component,manager,shadow){this.pushComponentFrame(layout,args,callerScope,component,manager,shadow);};VM.prototype.evaluateOperand = function evaluateOperand(expr){this.frame.setOperand(expr.evaluate(this));};VM.prototype.evaluateArgs = function evaluateArgs(args){var evaledArgs=this.frame.setArgs(args.evaluate(this));this.frame.setOperand(evaledArgs.positional.at(0));};VM.prototype.bindPositionalArgs = function bindPositionalArgs(symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPositionalArgs assumes a previous setArgs');var positional=args.positional;var scope=this.scope();for(var i=0;i < symbols.length;i++) {scope.bindSymbol(symbols[i],positional.at(i));}};VM.prototype.bindNamedArgs = function bindNamedArgs(names,symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindNamedArgs assumes a previous setArgs');var scope=this.scope();var named=args.named;for(var i=0;i < names.length;i++) {var _name2=this.constants.getString(names[i]);scope.bindSymbol(symbols[i],named.get(_name2));}};VM.prototype.bindBlocks = function bindBlocks(names,symbols){var blocks=this.frame.getBlocks();var scope=this.scope();for(var i=0;i < names.length;i++) {var _name3=this.constants.getString(names[i]);scope.bindBlock(symbols[i],blocks && blocks[_name3] || null);}};VM.prototype.bindPartialArgs = function bindPartialArgs(symbol){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPartialArgs assumes a previous setArgs');var scope=this.scope();_glimmerUtil.assert(args,"Cannot bind named args");scope.bindPartialArgs(symbol,args);};VM.prototype.bindCallerScope = function bindCallerScope(){var callerScope=this.frame.getCallerScope();var scope=this.scope();_glimmerUtil.assert(callerScope,"Cannot bind caller scope");scope.bindCallerScope(callerScope);};VM.prototype.bindDynamicScope = function bindDynamicScope(names){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindDynamicScope assumes a previous setArgs');var scope=this.dynamicScope();_glimmerUtil.assert(args,"Cannot bind dynamic scope");for(var i=0;i < names.length;i++) {var _name4=this.constants.getString(names[i]);scope.set(_name4,args.named.get(_name4));}};return VM;})();var UpdatingVM=(function(){function UpdatingVM(env,_ref29){var _ref29$alwaysRevalidate=_ref29.alwaysRevalidate;var alwaysRevalidate=_ref29$alwaysRevalidate === undefined?false:_ref29$alwaysRevalidate;this.frameStack = new _glimmerUtil.Stack();this.env = env;this.constants = env.constants;this.dom = env.getDOM();this.alwaysRevalidate = alwaysRevalidate;}UpdatingVM.prototype.execute = function execute(opcodes,handler){var frameStack=this.frameStack;this.try(opcodes,handler);while(true) {if(frameStack.isEmpty())break;var opcode=this.frame.nextStatement();if(opcode === null){this.frameStack.pop();continue;}_glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type);_glimmerUtil.LOGGER.trace(opcode);opcode.evaluate(this);}};UpdatingVM.prototype.goto = function goto(op){this.frame.goto(op);};UpdatingVM.prototype.try = function _try(ops,handler){this.frameStack.push(new UpdatingVMFrame(this,ops,handler));};UpdatingVM.prototype.throw = function _throw(){this.frame.handleException();this.frameStack.pop();};UpdatingVM.prototype.evaluateOpcode = function evaluateOpcode(opcode){opcode.evaluate(this);};babelHelpers.createClass(UpdatingVM,[{key:'frame',get:function(){return _glimmerUtil.expect(this.frameStack.current,'bug: expected a frame');}}]);return UpdatingVM;})();var BlockOpcode=(function(_UpdatingOpcode8){babelHelpers.inherits(BlockOpcode,_UpdatingOpcode8);function BlockOpcode(ops,state,bounds,children){_UpdatingOpcode8.call(this);this.ops = ops;this.type = "block";this.next = null;this.prev = null;var env=state.env;var scope=state.scope;var dynamicScope=state.dynamicScope;var frame=state.frame;this.children = children;this.env = env;this.scope = scope;this.dynamicScope = dynamicScope;this.frame = frame;this.bounds = bounds;}BlockOpcode.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};BlockOpcode.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};BlockOpcode.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};BlockOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,null);};BlockOpcode.prototype.destroy = function destroy(){this.bounds.destroy();};BlockOpcode.prototype.didDestroy = function didDestroy(){this.env.didDestroy(this.bounds);};BlockOpcode.prototype.toJSON = function toJSON(){var details=_glimmerUtil.dict();details["guid"] = '' + this._guid;return {guid:this._guid,type:this.type,details:details,children:this.children.toArray().map(function(op){return op.toJSON();})};};return BlockOpcode;})(UpdatingOpcode);var TryOpcode=(function(_BlockOpcode){babelHelpers.inherits(TryOpcode,_BlockOpcode);function TryOpcode(ops,state,bounds,children){_BlockOpcode.call(this,ops,state,bounds,children);this.type = "try";this.tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);}TryOpcode.prototype.didInitializeChildren = function didInitializeChildren(){this._tag.update(_glimmerReference.combineSlice(this.children));};TryOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,this);};TryOpcode.prototype.handleException = function handleException(){var env=this.env;var scope=this.scope;var ops=this.ops;var dynamicScope=this.dynamicScope;var frame=this.frame;var elementStack=ElementStack.resume(this.env,this.bounds,this.bounds.reset(env));var vm=new VM(env,scope,dynamicScope,elementStack);var result=vm.resume(ops,frame);this.children = result.opcodes();this.didInitializeChildren();};TryOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode.prototype.toJSON.call(this);var details=json["details"];if(!details){details = json["details"] = {};}return _BlockOpcode.prototype.toJSON.call(this);};return TryOpcode;})(BlockOpcode);var ListRevalidationDelegate=(function(){function ListRevalidationDelegate(opcode,marker){this.opcode = opcode;this.marker = marker;this.didInsert = false;this.didDelete = false;this.map = opcode.map;this.updating = opcode['children'];}ListRevalidationDelegate.prototype.insert = function insert(key,item,memo,before){var map=this.map;var opcode=this.opcode;var updating=this.updating;var nextSibling=null;var reference=null;if(before){reference = map[before];nextSibling = reference['bounds'].firstNode();}else {nextSibling = this.marker;}var vm=opcode.vmForInsertion(nextSibling);var tryOpcode=null;vm.execute(opcode.ops,function(vm){vm.frame.setArgs(EvaluatedArgs.positional([item,memo]));vm.frame.setOperand(item);vm.frame.setCondition(new _glimmerReference.ConstReference(true));vm.frame.setKey(key);var state=vm.capture();var tracker=vm.stack().pushUpdatableBlock();tryOpcode = new TryOpcode(opcode.ops,state,tracker,vm.updating());});tryOpcode.didInitializeChildren();updating.insertBefore(tryOpcode,reference);map[key] = tryOpcode;this.didInsert = true;};ListRevalidationDelegate.prototype.retain = function retain(_key,_item,_memo){};ListRevalidationDelegate.prototype.move = function move(key,_item,_memo,before){var map=this.map;var updating=this.updating;var entry=map[key];var reference=map[before] || null;if(before){moveBounds(entry,reference.firstNode());}else {moveBounds(entry,this.marker);}updating.remove(entry);updating.insertBefore(entry,reference);};ListRevalidationDelegate.prototype.delete = function _delete(key){var map=this.map;var opcode=map[key];opcode.didDestroy();clear(opcode);this.updating.remove(opcode);delete map[key];this.didDelete = true;};ListRevalidationDelegate.prototype.done = function done(){this.opcode.didInitializeChildren(this.didInsert || this.didDelete);};return ListRevalidationDelegate;})();var ListBlockOpcode=(function(_BlockOpcode2){babelHelpers.inherits(ListBlockOpcode,_BlockOpcode2);function ListBlockOpcode(ops,state,bounds,children,artifacts){_BlockOpcode2.call(this,ops,state,bounds,children);this.type = "list-block";this.map = _glimmerUtil.dict();this.lastIterated = _glimmerReference.INITIAL;this.artifacts = artifacts;var _tag=this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([artifacts.tag,_tag]);}ListBlockOpcode.prototype.didInitializeChildren = function didInitializeChildren(){var listDidChange=arguments.length <= 0 || arguments[0] === undefined?true:arguments[0];this.lastIterated = this.artifacts.tag.value();if(listDidChange){this._tag.update(_glimmerReference.combineSlice(this.children));}};ListBlockOpcode.prototype.evaluate = function evaluate(vm){var artifacts=this.artifacts;var lastIterated=this.lastIterated;if(!artifacts.tag.validate(lastIterated)){var bounds=this.bounds;var dom=vm.dom;var marker=dom.createComment('');dom.insertAfter(bounds.parentElement(),marker,_glimmerUtil.expect(bounds.lastNode(),"can't insert after an empty bounds"));var target=new ListRevalidationDelegate(this,marker);var synchronizer=new _glimmerReference.IteratorSynchronizer({target:target,artifacts:artifacts});synchronizer.sync();this.parentElement().removeChild(marker);} // Run now-updated updating opcodes +_BlockOpcode2.prototype.evaluate.call(this,vm);};ListBlockOpcode.prototype.vmForInsertion = function vmForInsertion(nextSibling){var env=this.env;var scope=this.scope;var dynamicScope=this.dynamicScope;var elementStack=ElementStack.forInitialRender(this.env,this.bounds.parentElement(),nextSibling);return new VM(env,scope,dynamicScope,elementStack);};ListBlockOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode2.prototype.toJSON.call(this);var map=this.map;var inner=Object.keys(map).map(function(key){return JSON.stringify(key) + ': ' + map[key]._guid;}).join(", ");var details=json["details"];if(!details){details = json["details"] = {};}details["map"] = '{' + inner + '}';return json;};return ListBlockOpcode;})(BlockOpcode);var UpdatingVMFrame=(function(){function UpdatingVMFrame(vm,ops,exceptionHandler){this.vm = vm;this.ops = ops;this.exceptionHandler = exceptionHandler;this.vm = vm;this.ops = ops;this.current = ops.head();}UpdatingVMFrame.prototype.goto = function goto(op){this.current = op;};UpdatingVMFrame.prototype.nextStatement = function nextStatement(){var current=this.current;var ops=this.ops;if(current)this.current = ops.nextNode(current);return current;};UpdatingVMFrame.prototype.handleException = function handleException(){if(this.exceptionHandler){this.exceptionHandler.handleException();}};return UpdatingVMFrame;})();var CompiledBlock=function CompiledBlock(slice){this.start = slice[0];this.end = slice[1];this.slice = slice;};var CompiledProgram=(function(_CompiledBlock){babelHelpers.inherits(CompiledProgram,_CompiledBlock);function CompiledProgram(slice,symbols){_CompiledBlock.call(this,slice);this.symbols = symbols;}return CompiledProgram;})(CompiledBlock);function entryPoint(meta){return new ProgramSymbolTable(meta);}function layout(meta,wireNamed,wireYields,hasPartials){var _symbols3=symbols(wireNamed,wireYields,hasPartials);var named=_symbols3.named;var yields=_symbols3.yields;var partialSymbol=_symbols3.partialSymbol;var size=_symbols3.size;return new ProgramSymbolTable(meta,named,yields,partialSymbol,size);}function block(parent,locals){var localsMap=null;var program=parent['program'];if(locals.length !== 0){(function(){var map=localsMap = _glimmerUtil.dict();locals.forEach(function(l){return map[l] = program.size++;});})();}return new BlockSymbolTable(parent,program,localsMap);}function symbols(named,yields,hasPartials){var yieldsMap=null;var namedMap=null;var size=1;if(yields.length !== 0){(function(){var map=yieldsMap = _glimmerUtil.dict();yields.forEach(function(y){return map[y] = size++;});})();}if(named.length !== 0){(function(){var map=namedMap = _glimmerUtil.dict();named.forEach(function(y){return map[y] = size++;});})();}var partialSymbol=hasPartials?size++:null;return {named:namedMap,yields:yieldsMap,partialSymbol:partialSymbol,size:size};}var ProgramSymbolTable=(function(){function ProgramSymbolTable(meta){var named=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var yields=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var partialArgs=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var size=arguments.length <= 4 || arguments[4] === undefined?1:arguments[4];this.meta = meta;this.named = named;this.yields = yields;this.partialArgs = partialArgs;this.size = size;this.program = this;}ProgramSymbolTable.prototype.getMeta = function getMeta(){return this.meta;};ProgramSymbolTable.prototype.getSymbols = function getSymbols(){return {named:this.named,yields:this.yields,locals:null,partialArgs:this.partialArgs};};ProgramSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local')return null;return this[kind] && this[kind][name];};ProgramSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.partialArgs || 0;};return ProgramSymbolTable;})();var BlockSymbolTable=(function(){function BlockSymbolTable(parent,program,locals){this.parent = parent;this.program = program;this.locals = locals;}BlockSymbolTable.prototype.getMeta = function getMeta(){return this.program.getMeta();};BlockSymbolTable.prototype.getSymbols = function getSymbols(){return {named:null,yields:null,locals:this.locals,partialArgs:null};};BlockSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local'){return this.getLocal(name);}else {return this.program.getSymbol(kind,name);}};BlockSymbolTable.prototype.getLocal = function getLocal(name){var locals=this.locals;var parent=this.parent;var symbol=locals && locals[name];if(!symbol && parent){symbol = parent.getSymbol('local',name);}return symbol;};BlockSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.program.getPartialArgs();};return BlockSymbolTable;})();var Specialize=(function(){function Specialize(){this.names = _glimmerUtil.dict();this.funcs = [];}Specialize.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Specialize.prototype.specialize = function specialize(sexp,table){var name=sexp[0];var index=this.names[name];if(index === undefined)return sexp;var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected a specialization for ' + sexp[0]);return func(sexp,table);};return Specialize;})();var SPECIALIZE=new Specialize();var E=_glimmerWireFormat.Expressions;SPECIALIZE.add('append',function(sexp,_symbolTable){var path=sexp[1];if(Array.isArray(path) && (E.isUnknown(path) || E.isGet(path))){if(path[1].length !== 1){return ['unoptimized-append',sexp[1],sexp[2]];}}return ['optimized-append',sexp[1],sexp[2]];});SPECIALIZE.add('dynamic-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],false];});SPECIALIZE.add('trusting-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],true];});SPECIALIZE.add('partial',function(sexp,_table){var expression=sexp[1];if(typeof expression === 'string'){return ['static-partial',expression];}else {return ['dynamic-partial',expression];}});function compileStatement(statement,builder){var refined=SPECIALIZE.specialize(statement,builder.symbolTable);STATEMENTS.compile(refined,builder);}var Template=function Template(statements,symbolTable){this.statements = statements;this.symbolTable = symbolTable;};var Layout=(function(_Template){babelHelpers.inherits(Layout,_Template);function Layout(){_Template.apply(this,arguments);}return Layout;})(Template);var EntryPoint=(function(_Template2){babelHelpers.inherits(EntryPoint,_Template2);function EntryPoint(){_Template2.apply(this,arguments);}EntryPoint.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),this.symbolTable.size);};return EntryPoint;})(Template);var InlineBlock=(function(_Template3){babelHelpers.inherits(InlineBlock,_Template3);function InlineBlock(){_Template3.apply(this,arguments);}InlineBlock.prototype.splat = function splat(builder){var table=builder.symbolTable;var locals=table.getSymbols().locals;if(locals){builder.pushChildScope();builder.bindPositionalArgsForLocals(locals);}for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,builder);}if(locals){builder.popScope();}};InlineBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);this.splat(b);return new CompiledBlock(b.toSlice());};return InlineBlock;})(Template);var PartialBlock=(function(_Template4){babelHelpers.inherits(PartialBlock,_Template4);function PartialBlock(){_Template4.apply(this,arguments);}PartialBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),table.size);};return PartialBlock;})(Template);var Scanner=(function(){function Scanner(block,meta,env){this.block = block;this.meta = meta;this.env = env;}Scanner.prototype.scanEntryPoint = function scanEntryPoint(){var block=this.block;var meta=this.meta;var symbolTable=entryPoint(meta);var child=scanBlock(block,symbolTable,this.env);return new EntryPoint(child.statements,symbolTable);};Scanner.prototype.scanLayout = function scanLayout(){var block=this.block;var meta=this.meta;var named=block.named;var yields=block.yields;var hasPartials=block.hasPartials;var symbolTable=layout(meta,named,yields,hasPartials);var child=scanBlock(block,symbolTable,this.env);return new Layout(child.statements,symbolTable);};Scanner.prototype.scanPartial = function scanPartial(symbolTable){var block=this.block;var child=scanBlock(block,symbolTable,this.env);return new PartialBlock(child.statements,symbolTable);};return Scanner;})();function scanBlock(_ref30,symbolTable,env){var statements=_ref30.statements;return new RawInlineBlock(env,symbolTable,statements).scan();}var BaselineSyntax;(function(BaselineSyntax){BaselineSyntax.isScannedComponent = _glimmerWireFormat.is('scanned-component');BaselineSyntax.isPrimitiveElement = _glimmerWireFormat.is('open-primitive-element');BaselineSyntax.isOptimizedAppend = _glimmerWireFormat.is('optimized-append');BaselineSyntax.isUnoptimizedAppend = _glimmerWireFormat.is('unoptimized-append');BaselineSyntax.isAnyAttr = _glimmerWireFormat.is('any-dynamic-attr');BaselineSyntax.isStaticPartial = _glimmerWireFormat.is('static-partial');BaselineSyntax.isDynamicPartial = _glimmerWireFormat.is('dynamic-partial');BaselineSyntax.isFunctionExpression = _glimmerWireFormat.is('function');BaselineSyntax.isNestedBlock = _glimmerWireFormat.is('nested-block');BaselineSyntax.isScannedBlock = _glimmerWireFormat.is('scanned-block');BaselineSyntax.isDebugger = _glimmerWireFormat.is('debugger');var NestedBlock;(function(NestedBlock){function defaultBlock(sexp){return sexp[4];}NestedBlock.defaultBlock = defaultBlock;function inverseBlock(sexp){return sexp[5];}NestedBlock.inverseBlock = inverseBlock;function params(sexp){return sexp[2];}NestedBlock.params = params;function hash(sexp){return sexp[3];}NestedBlock.hash = hash;})(NestedBlock = BaselineSyntax.NestedBlock || (BaselineSyntax.NestedBlock = {}));})(BaselineSyntax || (exports.BaselineSyntax = BaselineSyntax = {}));var RawInlineBlock=(function(){function RawInlineBlock(env,table,statements){this.env = env;this.table = table;this.statements = statements;}RawInlineBlock.prototype.scan = function scan(){var buffer=[];for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];if(_glimmerWireFormat.Statements.isBlock(statement)){buffer.push(this.specializeBlock(statement));}else if(_glimmerWireFormat.Statements.isComponent(statement)){buffer.push.apply(buffer,this.specializeComponent(statement));}else {buffer.push(statement);}}return new InlineBlock(buffer,this.table);};RawInlineBlock.prototype.specializeBlock = function specializeBlock(block$$){var path=block$$[1];var params=block$$[2];var hash=block$$[3];var template=block$$[4];var inverse=block$$[5];return ['scanned-block',path,params,hash,this.child(template),this.child(inverse)];};RawInlineBlock.prototype.specializeComponent = function specializeComponent(sexp){var tag=sexp[1];var component=sexp[2];if(this.env.hasComponentDefinition([tag],this.table)){var child=this.child(component);var attrs=new RawInlineBlock(this.env,this.table,component.attrs);return [['scanned-component',tag,attrs,component.args,child]];}else {var buf=[];buf.push(['open-element',tag,[]]);buf.push.apply(buf,component.attrs);buf.push(['flush-element']);buf.push.apply(buf,component.statements);buf.push(['close-element']);return buf;}};RawInlineBlock.prototype.child = function child(block$$){if(!block$$)return null;var table=block(this.table,block$$.locals);return new RawInlineBlock(this.env,table,block$$.statements);};return RawInlineBlock;})();function compileLayout(compilable,env){var builder=new ComponentLayoutBuilder(env);compilable.compile(builder);return builder.compile();}var ComponentLayoutBuilder=(function(){function ComponentLayoutBuilder(env){this.env = env;}ComponentLayoutBuilder.prototype.wrapLayout = function wrapLayout(layout){this.inner = new WrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.fromLayout = function fromLayout(layout){this.inner = new UnwrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.compile = function compile(){return this.inner.compile();};babelHelpers.createClass(ComponentLayoutBuilder,[{key:'tag',get:function(){return this.inner.tag;}},{key:'attrs',get:function(){return this.inner.attrs;}}]);return ComponentLayoutBuilder;})();var WrappedBuilder=(function(){function WrappedBuilder(env,layout){this.env = env;this.layout = layout;this.tag = new ComponentTagBuilder();this.attrs = new ComponentAttrsBuilder();}WrappedBuilder.prototype.compile = function compile(){ //========DYNAMIC +// PutValue(TagExpr) +// Test +// JumpUnless(BODY) +// OpenDynamicPrimitiveElement +// DidCreateElement +// ...attr statements... +// FlushElement +// BODY: Noop +// ...body statements... +// PutValue(TagExpr) +// Test +// JumpUnless(END) +// CloseElement +// END: Noop +// DidRenderLayout +// Exit +// +//========STATIC +// OpenPrimitiveElementOpcode +// DidCreateElement +// ...attr statements... +// FlushElement +// ...body statements... +// CloseElement +// DidRenderLayout +// Exit +var env=this.env;var layout=this.layout;var symbolTable=layout.symbolTable;var b=builder(env,layout.symbolTable);b.startLabels();var dynamicTag=this.tag.getDynamic();var staticTag=undefined;if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('BODY');b.openDynamicPrimitiveElement();b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();b.label('BODY');}else if(staticTag = this.tag.getStatic()){b.openPrimitiveElement(staticTag);b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();}b.preludeForLayout(layout);layout.statements.forEach(function(statement){return compileStatement(statement,b);});if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('END');b.closeElement();b.label('END');}else if(staticTag){b.closeElement();}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),symbolTable.size);};return WrappedBuilder;})();function isOpenElement(value){var type=value[0];return type === 'open-element' || type === 'open-primitive-element';}var UnwrappedBuilder=(function(){function UnwrappedBuilder(env,layout){this.env = env;this.layout = layout;this.attrs = new ComponentAttrsBuilder();}UnwrappedBuilder.prototype.compile = function compile(){var env=this.env;var layout=this.layout;var b=builder(env,layout.symbolTable);b.startLabels();b.preludeForLayout(layout);var attrs=this.attrs['buffer'];var attrsInserted=false;for(var i=0;i < layout.statements.length;i++) {var statement=layout.statements[i];if(!attrsInserted && isOpenElement(statement)){b.openComponentElement(statement[1]);b.didCreateElement();b.shadowAttributes();attrs.forEach(function(statement){return compileStatement(statement,b);});attrsInserted = true;}else {compileStatement(statement,b);}}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),layout.symbolTable.size);};babelHelpers.createClass(UnwrappedBuilder,[{key:'tag',get:function(){throw new Error('BUG: Cannot call `tag` on an UnwrappedBuilder');}}]);return UnwrappedBuilder;})();var ComponentTagBuilder=(function(){function ComponentTagBuilder(){this.isDynamic = null;this.isStatic = null;this.staticTagName = null;this.dynamicTagName = null;}ComponentTagBuilder.prototype.getDynamic = function getDynamic(){if(this.isDynamic){return this.dynamicTagName;}};ComponentTagBuilder.prototype.getStatic = function getStatic(){if(this.isStatic){return this.staticTagName;}};ComponentTagBuilder.prototype.static = function _static(tagName){this.isStatic = true;this.staticTagName = tagName;};ComponentTagBuilder.prototype.dynamic = function dynamic(tagName){this.isDynamic = true;this.dynamicTagName = ['function',tagName];};return ComponentTagBuilder;})();var ComponentAttrsBuilder=(function(){function ComponentAttrsBuilder(){this.buffer = [];}ComponentAttrsBuilder.prototype.static = function _static(name,value){this.buffer.push(['static-attr',name,value,null]);};ComponentAttrsBuilder.prototype.dynamic = function dynamic(name,value){this.buffer.push(['dynamic-attr',name,['function',value],null]);};return ComponentAttrsBuilder;})();var ComponentBuilder=(function(){function ComponentBuilder(builder){this.builder = builder;this.env = builder.env;}ComponentBuilder.prototype.static = function _static(definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putComponentDefinition(definition);b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();});};ComponentBuilder.prototype.dynamic = function dynamic(definitionArgs,definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putArgs(compileArgs(definitionArgs[0],definitionArgs[1],b));b.putValue(['function',definition]);b.test('simple');b.enter('BEGIN','END');b.label('BEGIN');b.jumpUnless('END');b.putDynamicComponentDefinition();b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();b.label('END');b.exit();});};return ComponentBuilder;})();function builder(env,symbolTable){return new OpcodeBuilder(symbolTable,env);}function appendOpcode(name,op1,op2,op3){return APPEND_OPCODES.construct(name,null,op1,op2,op3);}var Labels=(function(){function Labels(){this.labels = _glimmerUtil.dict();this.jumps = [];this.ranges = [];}Labels.prototype.label = function label(name,index){this.labels[name] = index;};Labels.prototype.jump = function jump(at,Target,target){this.jumps.push({at:at,target:target,Target:Target});};Labels.prototype.range = function range(at,Range,start,end){this.ranges.push({at:at,start:start,end:end,Range:Range});};Labels.prototype.patch = function patch(constants,opcodes){for(var i=0;i < this.jumps.length;i++) {var _jumps$i=this.jumps[i];var at=_jumps$i.at;var target=_jumps$i.target;var Target=_jumps$i.Target;opcodes.set(at,APPEND_OPCODES.construct(Target,null,this.labels[target]));}for(var i=0;i < this.ranges.length;i++) {var _ranges$i=this.ranges[i];var at=_ranges$i.at;var start=_ranges$i.start;var end=_ranges$i.end;var _Range=_ranges$i.Range;var slice=constants.slice([this.labels[start],this.labels[end] - 1]);opcodes.set(at,APPEND_OPCODES.construct(_Range,null,slice));}};return Labels;})();var BasicOpcodeBuilder=(function(){function BasicOpcodeBuilder(symbolTable,env,program){this.symbolTable = symbolTable;this.env = env;this.program = program;this.labelsStack = new _glimmerUtil.Stack();this.constants = env.constants;this.start = program.next;}BasicOpcodeBuilder.prototype.opcode = function opcode(name,op1,op2,op3){this.push(appendOpcode(name,op1,op2,op3));};BasicOpcodeBuilder.prototype.push = function push(op){ // console.log(`pushing ${op && op.type}`); +if(op === null){this.program.push([0,0,0,0]);}else {this.program.push(op);}};BasicOpcodeBuilder.prototype.toSlice = function toSlice(){return [this.start,this.program.current];}; // helpers +BasicOpcodeBuilder.prototype.startLabels = function startLabels(){this.labelsStack.push(new Labels());};BasicOpcodeBuilder.prototype.stopLabels = function stopLabels(){var label=_glimmerUtil.expect(this.labelsStack.pop(),'unbalanced push and pop labels');label.patch(this.constants,this.program);}; // partials +BasicOpcodeBuilder.prototype.putPartialDefinition = function putPartialDefinition(_definition){var definition=this.constants.other(_definition);this.opcode(50, /* PutPartial */definition);};BasicOpcodeBuilder.prototype.putDynamicPartialDefinition = function putDynamicPartialDefinition(){this.opcode(49, /* PutDynamicPartial */this.constants.other(this.symbolTable));};BasicOpcodeBuilder.prototype.evaluatePartial = function evaluatePartial(){this.opcode(51, /* EvaluatePartial */this.constants.other(this.symbolTable),this.constants.other(_glimmerUtil.dict()));}; // components +BasicOpcodeBuilder.prototype.putComponentDefinition = function putComponentDefinition(definition){this.opcode(23, /* PutComponent */this.other(definition));};BasicOpcodeBuilder.prototype.putDynamicComponentDefinition = function putDynamicComponentDefinition(){this.opcode(22 /* PutDynamicComponent */);};BasicOpcodeBuilder.prototype.openComponent = function openComponent(args,shadow){this.opcode(24, /* OpenComponent */this.args(args),shadow?this.block(shadow):0);};BasicOpcodeBuilder.prototype.didCreateElement = function didCreateElement(){this.opcode(25 /* DidCreateElement */);};BasicOpcodeBuilder.prototype.shadowAttributes = function shadowAttributes(){this.opcode(26 /* ShadowAttributes */);this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.didRenderLayout = function didRenderLayout(){this.opcode(27 /* DidRenderLayout */);};BasicOpcodeBuilder.prototype.closeComponent = function closeComponent(){this.opcode(28 /* CloseComponent */);}; // content +BasicOpcodeBuilder.prototype.dynamicContent = function dynamicContent(Opcode){this.opcode(31, /* DynamicContent */this.other(Opcode));};BasicOpcodeBuilder.prototype.cautiousAppend = function cautiousAppend(){this.dynamicContent(new OptimizedCautiousAppendOpcode());};BasicOpcodeBuilder.prototype.trustingAppend = function trustingAppend(){this.dynamicContent(new OptimizedTrustingAppendOpcode());};BasicOpcodeBuilder.prototype.guardedCautiousAppend = function guardedCautiousAppend(expression){this.dynamicContent(new GuardedCautiousAppendOpcode(this.compileExpression(expression),this.symbolTable));};BasicOpcodeBuilder.prototype.guardedTrustingAppend = function guardedTrustingAppend(expression){this.dynamicContent(new GuardedTrustingAppendOpcode(this.compileExpression(expression),this.symbolTable));}; // dom +BasicOpcodeBuilder.prototype.text = function text(_text){this.opcode(29, /* Text */this.constants.string(_text));};BasicOpcodeBuilder.prototype.openPrimitiveElement = function openPrimitiveElement(tag){this.opcode(32, /* OpenElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openComponentElement = function openComponentElement(tag){this.opcode(35, /* OpenComponentElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openDynamicPrimitiveElement = function openDynamicPrimitiveElement(){this.opcode(36 /* OpenDynamicElement */);};BasicOpcodeBuilder.prototype.flushElement = function flushElement(){this.opcode(37 /* FlushElement */);};BasicOpcodeBuilder.prototype.closeElement = function closeElement(){this.opcode(38 /* CloseElement */);};BasicOpcodeBuilder.prototype.staticAttr = function staticAttr(_name,_namespace,_value){var name=this.constants.string(_name);var namespace=_namespace?this.constants.string(_namespace):0;var value=this.constants.string(_value);this.opcode(40, /* StaticAttr */name,value,namespace);};BasicOpcodeBuilder.prototype.dynamicAttrNS = function dynamicAttrNS(_name,_namespace,trusting){var name=this.constants.string(_name);var namespace=this.constants.string(_namespace);this.opcode(42, /* DynamicAttrNS */name,namespace,trusting | 0);};BasicOpcodeBuilder.prototype.dynamicAttr = function dynamicAttr(_name,trusting){var name=this.constants.string(_name);this.opcode(43, /* DynamicAttr */name,trusting | 0);};BasicOpcodeBuilder.prototype.comment = function comment(_comment){var comment=this.constants.string(_comment);this.opcode(30, /* Comment */comment);};BasicOpcodeBuilder.prototype.modifier = function modifier(_name,_args){var args=this.constants.expression(this.compile(_args));var _modifierManager=this.env.lookupModifier([_name],this.symbolTable);var modifierManager=this.constants.other(_modifierManager);var name=this.constants.string(_name);this.opcode(41, /* Modifier */name,modifierManager,args);}; // lists +BasicOpcodeBuilder.prototype.putIterator = function putIterator(){this.opcode(44 /* PutIterator */);};BasicOpcodeBuilder.prototype.enterList = function enterList(start,end){this.push(null);this.labels.range(this.pos,45, /* EnterList */start,end);};BasicOpcodeBuilder.prototype.exitList = function exitList(){this.opcode(46 /* ExitList */);};BasicOpcodeBuilder.prototype.enterWithKey = function enterWithKey(start,end){this.push(null);this.labels.range(this.pos,47, /* EnterWithKey */start,end);};BasicOpcodeBuilder.prototype.nextIter = function nextIter(end){this.push(null);this.labels.jump(this.pos,48, /* NextIter */end);}; // vm +BasicOpcodeBuilder.prototype.openBlock = function openBlock(_args,_inner){var args=this.constants.expression(this.compile(_args));var inner=this.constants.other(_inner);this.opcode(20, /* OpenBlock */inner,args);};BasicOpcodeBuilder.prototype.closeBlock = function closeBlock(){this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.pushRemoteElement = function pushRemoteElement(){this.opcode(33 /* PushRemoteElement */);};BasicOpcodeBuilder.prototype.popRemoteElement = function popRemoteElement(){this.opcode(34 /* PopRemoteElement */);};BasicOpcodeBuilder.prototype.popElement = function popElement(){this.opcode(39 /* PopElement */);};BasicOpcodeBuilder.prototype.label = function label(name){this.labels.label(name,this.nextPos);};BasicOpcodeBuilder.prototype.pushChildScope = function pushChildScope(){this.opcode(0 /* PushChildScope */);};BasicOpcodeBuilder.prototype.popScope = function popScope(){this.opcode(1 /* PopScope */);};BasicOpcodeBuilder.prototype.pushDynamicScope = function pushDynamicScope(){this.opcode(2 /* PushDynamicScope */);};BasicOpcodeBuilder.prototype.popDynamicScope = function popDynamicScope(){this.opcode(3 /* PopDynamicScope */);};BasicOpcodeBuilder.prototype.putNull = function putNull(){this.opcode(4, /* Put */this.constants.NULL_REFERENCE);};BasicOpcodeBuilder.prototype.putValue = function putValue(_expression){var expr=this.constants.expression(this.compileExpression(_expression));this.opcode(5, /* EvaluatePut */expr);};BasicOpcodeBuilder.prototype.putArgs = function putArgs(_args){var args=this.constants.expression(this.compile(_args));this.opcode(6, /* PutArgs */args);};BasicOpcodeBuilder.prototype.bindDynamicScope = function bindDynamicScope(_names){this.opcode(12, /* BindDynamicScope */this.names(_names));};BasicOpcodeBuilder.prototype.bindPositionalArgs = function bindPositionalArgs(_names,_symbols){this.opcode(7, /* BindPositionalArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindNamedArgs = function bindNamedArgs(_names,_symbols){this.opcode(8, /* BindNamedArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindBlocks = function bindBlocks(_names,_symbols){this.opcode(9, /* BindBlocks */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.enter = function enter(_enter,exit){this.push(null);this.labels.range(this.pos,13, /* Enter */_enter,exit);};BasicOpcodeBuilder.prototype.exit = function exit(){this.opcode(14 /* Exit */);};BasicOpcodeBuilder.prototype.evaluate = function evaluate(_block){var block=this.constants.block(_block);this.opcode(15, /* Evaluate */block);};BasicOpcodeBuilder.prototype.test = function test(testFunc){var _func=undefined;if(testFunc === 'const'){_func = ConstTest;}else if(testFunc === 'simple'){_func = SimpleTest;}else if(testFunc === 'environment'){_func = EnvironmentTest;}else if(typeof testFunc === 'function'){_func = testFunc;}else {throw new Error('unreachable');}var func=this.constants.function(_func);this.opcode(19, /* Test */func);};BasicOpcodeBuilder.prototype.jump = function jump(target){this.push(null);this.labels.jump(this.pos,16, /* Jump */target);};BasicOpcodeBuilder.prototype.jumpIf = function jumpIf(target){this.push(null);this.labels.jump(this.pos,17, /* JumpIf */target);};BasicOpcodeBuilder.prototype.jumpUnless = function jumpUnless(target){this.push(null);this.labels.jump(this.pos,18, /* JumpUnless */target);};BasicOpcodeBuilder.prototype.names = function names(_names){var _this=this;var names=_names.map(function(n){return _this.constants.string(n);});return this.constants.array(names);};BasicOpcodeBuilder.prototype.symbols = function symbols(_symbols2){return this.constants.array(_symbols2);};BasicOpcodeBuilder.prototype.other = function other(value){return this.constants.other(value);};BasicOpcodeBuilder.prototype.args = function args(_args2){return this.constants.expression(this.compile(_args2));};BasicOpcodeBuilder.prototype.block = function block(_block3){return this.constants.block(_block3);};babelHelpers.createClass(BasicOpcodeBuilder,[{key:'pos',get:function(){return this.program.current;}},{key:'nextPos',get:function(){return this.program.next;}},{key:'labels',get:function(){return _glimmerUtil.expect(this.labelsStack.current,'bug: not in a label stack');}}]);return BasicOpcodeBuilder;})();function isCompilableExpression(expr){return expr && typeof expr['compile'] === 'function';}var OpcodeBuilder=(function(_BasicOpcodeBuilder){babelHelpers.inherits(OpcodeBuilder,_BasicOpcodeBuilder);function OpcodeBuilder(symbolTable,env){var program=arguments.length <= 2 || arguments[2] === undefined?env.program:arguments[2];return (function(){_BasicOpcodeBuilder.call(this,symbolTable,env,program);this.component = new ComponentBuilder(this);}).apply(this,arguments);}OpcodeBuilder.prototype.compile = function compile(expr){if(isCompilableExpression(expr)){return expr.compile(this);}else {return expr;}};OpcodeBuilder.prototype.compileExpression = function compileExpression(expression){if(expression instanceof CompiledExpression){return expression;}else {return expr(expression,this);}};OpcodeBuilder.prototype.bindPositionalArgsForLocals = function bindPositionalArgsForLocals(locals){var symbols=Object.keys(locals).map(function(name){return locals[name];});this.opcode(7, /* BindPositionalArgs */this.symbols(symbols));};OpcodeBuilder.prototype.preludeForLayout = function preludeForLayout(layout){var _this2=this;var symbols=layout.symbolTable.getSymbols();if(symbols.named){(function(){var named=symbols.named;var namedNames=Object.keys(named);var namedSymbols=namedNames.map(function(n){return named[n];});_this2.opcode(8, /* BindNamedArgs */_this2.names(namedNames),_this2.symbols(namedSymbols));})();}this.opcode(11 /* BindCallerScope */);if(symbols.yields){(function(){var yields=symbols.yields;var yieldNames=Object.keys(yields);var yieldSymbols=yieldNames.map(function(n){return yields[n];});_this2.opcode(9, /* BindBlocks */_this2.names(yieldNames),_this2.symbols(yieldSymbols));})();}if(symbols.partialArgs){this.opcode(10, /* BindPartialArgs */symbols.partialArgs);}};OpcodeBuilder.prototype.yield = function _yield(args,to){var yields=undefined,partial=undefined;var inner=undefined;if(yields = this.symbolTable.getSymbol('yields',to)){inner = new CompiledGetBlockBySymbol(yields,to);}else if(partial = this.symbolTable.getPartialArgs()){inner = new CompiledInPartialGetBlock(partial,to);}else {throw new Error('[BUG] ${to} is not a valid block name.');}this.openBlock(args,inner);this.closeBlock();}; // TODO +// come back to this +OpcodeBuilder.prototype.labelled = function labelled(args,callback){if(args)this.putArgs(args);this.startLabels();this.enter('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.iter = function iter(callback){this.startLabels();this.enterList('BEGIN','END');this.label('ITER');this.nextIter('BREAK');this.enterWithKey('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.jump('ITER');this.label('BREAK');this.exitList();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.unit = function unit(callback){this.startLabels();callback(this);this.stopLabels();};return OpcodeBuilder;})(BasicOpcodeBuilder);APPEND_OPCODES.add(31, /* DynamicContent */function(vm,_ref31){var append=_ref31.op1;var opcode=vm.constants.getOther(append);opcode.evaluate(vm);});function isEmpty(value){return value === null || value === undefined || typeof value['toString'] !== 'function';}function normalizeTextValue(value){if(isEmpty(value)){return '';}return String(value);}function normalizeTrustedValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value)){return value.toHTML();}if(isNode(value)){return value;}return String(value);}function normalizeValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value) || isNode(value)){return value;}return String(value);}var AppendDynamicOpcode=(function(){function AppendDynamicOpcode(){}AppendDynamicOpcode.prototype.evaluate = function evaluate(vm){var reference=vm.frame.getOperand();var normalized=this.normalize(reference);var value=undefined,cache=undefined;if(_glimmerReference.isConst(reference)){value = normalized.value();}else {cache = new _glimmerReference.ReferenceCache(normalized);value = cache.peek();}var stack=vm.stack();var upsert=this.insert(vm.env.getAppendOperations(),stack,value);var bounds=new Fragment(upsert.bounds);stack.newBounds(bounds);if(cache /* i.e. !isConst(reference) */){vm.updateWith(this.updateWith(vm,reference,cache,bounds,upsert));}};return AppendDynamicOpcode;})();var GuardedAppendOpcode=(function(_AppendDynamicOpcode){babelHelpers.inherits(GuardedAppendOpcode,_AppendDynamicOpcode);function GuardedAppendOpcode(expression,symbolTable){_AppendDynamicOpcode.call(this);this.expression = expression;this.symbolTable = symbolTable;this.deopted = null;}GuardedAppendOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.pushEvalFrame(this.deopted);}else {vm.evaluateOperand(this.expression);var value=vm.frame.getOperand().value();if(isComponentDefinition(value)){vm.pushEvalFrame(this.deopt(vm.env));}else {_AppendDynamicOpcode.prototype.evaluate.call(this,vm);}}};GuardedAppendOpcode.prototype.deopt = function deopt(env){var _this3=this; // At compile time, we determined that this append callsite might refer +// to a local variable/property lookup that resolves to a component +// definition at runtime. +// +// We could have eagerly compiled this callsite into something like this: +// +// {{#if (is-component-definition foo)}} +// {{component foo}} +// {{else}} +// {{foo}} +// {{/if}} +// +// However, in practice, there might be a large amout of these callsites +// and most of them would resolve to a simple value lookup. Therefore, we +// tried to be optimistic and assumed that the callsite will resolve to +// appending a simple value. +// +// However, we have reached here because at runtime, the guard conditional +// have detected that this callsite is indeed referring to a component +// definition object. Since this is likely going to be true for other +// instances of the same callsite, it is now appropiate to deopt into the +// expanded version that handles both cases. The compilation would look +// like this: +// +// PutValue(expression) +// Test(is-component-definition) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(VALUE) +// PutDynamicComponentDefinitionOpcode +// OpenComponent +// CloseComponent +// Jump(END) +// VALUE: Noop +// OptimizedAppend +// END: Noop +// Exit +// +// Keep in mind that even if we *don't* reach here at initial render time, +// it is still possible (although quite rare) that the simple value we +// encounter during initial render could later change into a component +// definition object at update time. That is handled by the "lazy deopt" +// code on the update side (scroll down for the next big block of comment). +var dsl=new OpcodeBuilder(this.symbolTable,env);dsl.putValue(this.expression);dsl.test(IsComponentDefinitionReference.create);dsl.labelled(null,function(dsl,_BEGIN,END){dsl.jumpUnless('VALUE');dsl.putDynamicComponentDefinition();dsl.openComponent(CompiledArgs.empty());dsl.closeComponent();dsl.jump(END);dsl.label('VALUE');dsl.dynamicContent(new _this3.AppendOpcode());});var deopted=this.deopted = dsl.toSlice(); // From this point on, we have essentially replaced ourselves with a new set +// of opcodes. Since we will always be executing the new/deopted code, it's +// a good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this.expression = null;return deopted;};return GuardedAppendOpcode;})(AppendDynamicOpcode);var IsComponentDefinitionReference=(function(_ConditionalReference){babelHelpers.inherits(IsComponentDefinitionReference,_ConditionalReference);function IsComponentDefinitionReference(){_ConditionalReference.apply(this,arguments);}IsComponentDefinitionReference.create = function create(inner){return new IsComponentDefinitionReference(inner);};IsComponentDefinitionReference.prototype.toBool = function toBool(value){return isComponentDefinition(value);};return IsComponentDefinitionReference;})(ConditionalReference);var UpdateOpcode=(function(_UpdatingOpcode9){babelHelpers.inherits(UpdateOpcode,_UpdatingOpcode9);function UpdateOpcode(cache,bounds,upsert){_UpdatingOpcode9.call(this);this.cache = cache;this.bounds = bounds;this.upsert = upsert;this.tag = cache.tag;}UpdateOpcode.prototype.evaluate = function evaluate(vm){var value=this.cache.revalidate();if(_glimmerReference.isModified(value)){var bounds=this.bounds;var upsert=this.upsert;var dom=vm.dom;if(!this.upsert.update(dom,value)){var cursor=new Cursor(bounds.parentElement(),clear(bounds));upsert = this.upsert = this.insert(vm.env.getAppendOperations(),cursor,value);}bounds.update(upsert.bounds);}};UpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var cache=this.cache;return {guid:guid,type:type,details:{lastValue:JSON.stringify(cache.peek())}};};return UpdateOpcode;})(UpdatingOpcode);var GuardedUpdateOpcode=(function(_UpdateOpcode){babelHelpers.inherits(GuardedUpdateOpcode,_UpdateOpcode);function GuardedUpdateOpcode(reference,cache,bounds,upsert,appendOpcode,state){_UpdateOpcode.call(this,cache,bounds,upsert);this.reference = reference;this.appendOpcode = appendOpcode;this.state = state;this.deopted = null;this.tag = this._tag = new _glimmerReference.UpdatableTag(this.tag);}GuardedUpdateOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.evaluateOpcode(this.deopted);}else {if(isComponentDefinition(this.reference.value())){this.lazyDeopt(vm);}else {_UpdateOpcode.prototype.evaluate.call(this,vm);}}};GuardedUpdateOpcode.prototype.lazyDeopt = function lazyDeopt(vm){ // Durign initial render, we know that the reference does not contain a +// component definition, so we optimistically assumed that this append +// is just a normal append. However, at update time, we discovered that +// the reference has switched into containing a component definition, so +// we need to do a "lazy deopt", simulating what would have happened if +// we had decided to perform the deopt in the first place during initial +// render. +// +// More concretely, we would have expanded the curly into a if/else, and +// based on whether the value is a component definition or not, we would +// have entered either the dynamic component branch or the simple value +// branch. +// +// Since we rendered a simple value during initial render (and all the +// updates up until this point), we need to pretend that the result is +// produced by the "VALUE" branch of the deopted append opcode: +// +// Try(BEGIN, END) +// Assert(IsComponentDefinition, expected=false) +// OptimizedUpdate +// +// In this case, because the reference has switched from being a simple +// value into a component definition, what would have happened is that +// the assert would throw, causing the Try opcode to teardown the bounds +// and rerun the original append opcode. +// +// Since the Try opcode would have nuked the updating opcodes anyway, we +// wouldn't have to worry about simulating those. All we have to do is to +// execute the Try opcode and immediately throw. +var bounds=this.bounds;var appendOpcode=this.appendOpcode;var state=this.state;var env=vm.env;var slice=appendOpcode.deopt(env);var enter=_glimmerUtil.expect(env.program.opcode(slice[0] + 8),'hardcoded deopt location');var ops=vm.constants.getSlice(enter.op1);var tracker=new UpdatableBlockTracker(bounds.parentElement());tracker.newBounds(this.bounds);var children=new _glimmerUtil.LinkedList();state.frame['condition'] = IsComponentDefinitionReference.create(_glimmerUtil.expect(state.frame['operand'],'operand should be populated'));var deopted=this.deopted = new TryOpcode(ops,state,tracker,children);this._tag.update(deopted.tag);vm.evaluateOpcode(deopted);vm.throw(); // From this point on, we have essentially replaced ourselve with a new +// opcode. Since we will always be executing the new/deopted code, it's a +// good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this._tag = null;this.reference = null;this.cache = null;this.bounds = null;this.upsert = null;this.appendOpcode = null;this.state = null;};GuardedUpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var deopted=this.deopted;if(deopted){return {guid:guid,type:type,deopted:true,children:[deopted.toJSON()]};}else {return _UpdateOpcode.prototype.toJSON.call(this);}};return GuardedUpdateOpcode;})(UpdateOpcode);var OptimizedCautiousAppendOpcode=(function(_AppendDynamicOpcode2){babelHelpers.inherits(OptimizedCautiousAppendOpcode,_AppendDynamicOpcode2);function OptimizedCautiousAppendOpcode(){_AppendDynamicOpcode2.apply(this,arguments);this.type = 'optimized-cautious-append';}OptimizedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};OptimizedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};OptimizedCautiousAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedCautiousUpdateOpcode(cache,bounds,upsert);};return OptimizedCautiousAppendOpcode;})(AppendDynamicOpcode);var OptimizedCautiousUpdateOpcode=(function(_UpdateOpcode2){babelHelpers.inherits(OptimizedCautiousUpdateOpcode,_UpdateOpcode2);function OptimizedCautiousUpdateOpcode(){_UpdateOpcode2.apply(this,arguments);this.type = 'optimized-cautious-update';}OptimizedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return OptimizedCautiousUpdateOpcode;})(UpdateOpcode);var GuardedCautiousAppendOpcode=(function(_GuardedAppendOpcode){babelHelpers.inherits(GuardedCautiousAppendOpcode,_GuardedAppendOpcode);function GuardedCautiousAppendOpcode(){_GuardedAppendOpcode.apply(this,arguments);this.type = 'guarded-cautious-append';this.AppendOpcode = OptimizedCautiousAppendOpcode;}GuardedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};GuardedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};GuardedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedCautiousUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedCautiousAppendOpcode;})(GuardedAppendOpcode);var GuardedCautiousUpdateOpcode=(function(_GuardedUpdateOpcode){babelHelpers.inherits(GuardedCautiousUpdateOpcode,_GuardedUpdateOpcode);function GuardedCautiousUpdateOpcode(){_GuardedUpdateOpcode.apply(this,arguments);this.type = 'guarded-cautious-update';}GuardedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return GuardedCautiousUpdateOpcode;})(GuardedUpdateOpcode);var OptimizedTrustingAppendOpcode=(function(_AppendDynamicOpcode3){babelHelpers.inherits(OptimizedTrustingAppendOpcode,_AppendDynamicOpcode3);function OptimizedTrustingAppendOpcode(){_AppendDynamicOpcode3.apply(this,arguments);this.type = 'optimized-trusting-append';}OptimizedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};OptimizedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};OptimizedTrustingAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedTrustingUpdateOpcode(cache,bounds,upsert);};return OptimizedTrustingAppendOpcode;})(AppendDynamicOpcode);var OptimizedTrustingUpdateOpcode=(function(_UpdateOpcode3){babelHelpers.inherits(OptimizedTrustingUpdateOpcode,_UpdateOpcode3);function OptimizedTrustingUpdateOpcode(){_UpdateOpcode3.apply(this,arguments);this.type = 'optimized-trusting-update';}OptimizedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return OptimizedTrustingUpdateOpcode;})(UpdateOpcode);var GuardedTrustingAppendOpcode=(function(_GuardedAppendOpcode2){babelHelpers.inherits(GuardedTrustingAppendOpcode,_GuardedAppendOpcode2);function GuardedTrustingAppendOpcode(){_GuardedAppendOpcode2.apply(this,arguments);this.type = 'guarded-trusting-append';this.AppendOpcode = OptimizedTrustingAppendOpcode;}GuardedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};GuardedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};GuardedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedTrustingUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedTrustingAppendOpcode;})(GuardedAppendOpcode);var GuardedTrustingUpdateOpcode=(function(_GuardedUpdateOpcode2){babelHelpers.inherits(GuardedTrustingUpdateOpcode,_GuardedUpdateOpcode2);function GuardedTrustingUpdateOpcode(){_GuardedUpdateOpcode2.apply(this,arguments);this.type = 'trusting-update';}GuardedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return GuardedTrustingUpdateOpcode;})(GuardedUpdateOpcode);APPEND_OPCODES.add(49, /* PutDynamicPartial */function(vm,_ref32){var _symbolTable=_ref32.op1;var env=vm.env;var symbolTable=vm.constants.getOther(_symbolTable);function lookupPartial(name){var normalized=String(name);if(!env.hasPartial(normalized,symbolTable)){throw new Error('Could not find a partial named "' + normalized + '"');}return env.lookupPartial(normalized,symbolTable);}var reference=_glimmerReference.map(vm.frame.getOperand(),lookupPartial);var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(50, /* PutPartial */function(vm,_ref33){var _definition=_ref33.op1;var definition=vm.constants.getOther(_definition);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(51, /* EvaluatePartial */function(vm,_ref34){var _symbolTable=_ref34.op1;var _cache=_ref34.op2;var symbolTable=vm.constants.getOther(_symbolTable);var cache=vm.constants.getOther(_cache);var _vm$frame$getImmediate=vm.frame.getImmediate();var template=_vm$frame$getImmediate.template;var block=cache[template.id];if(!block){block = template.asPartial(symbolTable);}vm.invokePartial(block);});var IterablePresenceReference=(function(){function IterablePresenceReference(artifacts){this.tag = artifacts.tag;this.artifacts = artifacts;}IterablePresenceReference.prototype.value = function value(){return !this.artifacts.isEmpty();};return IterablePresenceReference;})();APPEND_OPCODES.add(44, /* PutIterator */function(vm){var listRef=vm.frame.getOperand();var args=_glimmerUtil.expect(vm.frame.getArgs(),'PutIteratorOpcode expects a populated args register');var iterable=vm.env.iterableFor(listRef,args);var iterator=new _glimmerReference.ReferenceIterator(iterable);vm.frame.setIterator(iterator);vm.frame.setCondition(new IterablePresenceReference(iterator.artifacts));});APPEND_OPCODES.add(45, /* EnterList */function(vm,_ref35){var _slice=_ref35.op1;vm.enterList(vm.constants.getSlice(_slice));});APPEND_OPCODES.add(46, /* ExitList */function(vm){return vm.exitList();});APPEND_OPCODES.add(47, /* EnterWithKey */function(vm,_ref36){var _slice=_ref36.op2;var key=_glimmerUtil.expect(vm.frame.getKey(),'EnterWithKeyOpcode expects a populated key register');var slice=vm.constants.getSlice(_slice);vm.enterWithKey(key,slice);});var TRUE_REF=new _glimmerReference.ConstReference(true);var FALSE_REF=new _glimmerReference.ConstReference(false);APPEND_OPCODES.add(48, /* NextIter */function(vm,_ref37){var end=_ref37.op1;var item=vm.frame.getIterator().next();if(item){vm.frame.setCondition(TRUE_REF);vm.frame.setKey(item.key);vm.frame.setOperand(item.value);vm.frame.setArgs(EvaluatedArgs.positional([item.value,item.memo]));}else {vm.frame.setCondition(FALSE_REF);vm.goto(end);}});var clientId=0;function templateFactory(_ref38){var templateId=_ref38.id;var meta=_ref38.meta;var block=_ref38.block;var parsedBlock=undefined;var id=templateId || 'client-' + clientId++;var create=function(env,envMeta){var newMeta=envMeta?_glimmerUtil.assign({},envMeta,meta):meta;if(!parsedBlock){parsedBlock = JSON.parse(block);}return template(parsedBlock,id,newMeta,env);};return {id:id,meta:meta,create:create};}function template(block,id,meta,env){var scanner=new Scanner(block,meta,env);var entryPoint=undefined;var asEntryPoint=function(){if(!entryPoint)entryPoint = scanner.scanEntryPoint();return entryPoint;};var layout=undefined;var asLayout=function(){if(!layout)layout = scanner.scanLayout();return layout;};var asPartial=function(symbols){return scanner.scanPartial(symbols);};var render=function(self,appendTo,dynamicScope){var elementStack=ElementStack.forInitialRender(env,appendTo,null);var compiled=asEntryPoint().compile(env);var vm=VM.initial(env,self,dynamicScope,elementStack,compiled.symbols);return vm.execute(compiled.slice);};return {id:id,meta:meta,_block:block,asEntryPoint:asEntryPoint,asLayout:asLayout,asPartial:asPartial,render:render};}var DynamicVarReference=(function(){function DynamicVarReference(scope,nameRef){this.scope = scope;this.nameRef = nameRef;var varTag=this.varTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([nameRef.tag,varTag]);}DynamicVarReference.prototype.value = function value(){return this.getVar().value();};DynamicVarReference.prototype.get = function get(key){return this.getVar().get(key);};DynamicVarReference.prototype.getVar = function getVar(){var name=String(this.nameRef.value());var ref=this.scope.get(name);this.varTag.update(ref.tag);return ref;};return DynamicVarReference;})();function getDynamicVar(vm,args,_symbolTable){var scope=vm.dynamicScope();var nameRef=args.positional.at(0);return new DynamicVarReference(scope,nameRef);}var PartialDefinition=function PartialDefinition(name,template){this.name = name;this.template = template;};var NodeType;(function(NodeType){NodeType[NodeType["Element"] = 0] = "Element";NodeType[NodeType["Attribute"] = 1] = "Attribute";NodeType[NodeType["Text"] = 2] = "Text";NodeType[NodeType["CdataSection"] = 3] = "CdataSection";NodeType[NodeType["EntityReference"] = 4] = "EntityReference";NodeType[NodeType["Entity"] = 5] = "Entity";NodeType[NodeType["ProcessingInstruction"] = 6] = "ProcessingInstruction";NodeType[NodeType["Comment"] = 7] = "Comment";NodeType[NodeType["Document"] = 8] = "Document";NodeType[NodeType["DocumentType"] = 9] = "DocumentType";NodeType[NodeType["DocumentFragment"] = 10] = "DocumentFragment";NodeType[NodeType["Notation"] = 11] = "Notation";})(NodeType || (NodeType = {}));var Simple=Object.freeze({get NodeType(){return NodeType;}});exports.Simple = Simple;exports.templateFactory = templateFactory;exports.NULL_REFERENCE = NULL_REFERENCE;exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE;exports.PrimitiveReference = PrimitiveReference;exports.ConditionalReference = ConditionalReference;exports.OpcodeBuilderDSL = OpcodeBuilder;exports.compileLayout = compileLayout;exports.CompiledBlock = CompiledBlock;exports.CompiledProgram = CompiledProgram;exports.IAttributeManager = AttributeManager;exports.AttributeManager = AttributeManager;exports.PropertyManager = PropertyManager;exports.INPUT_VALUE_PROPERTY_MANAGER = INPUT_VALUE_PROPERTY_MANAGER;exports.defaultManagers = defaultManagers;exports.defaultAttributeManagers = defaultAttributeManagers;exports.defaultPropertyManagers = defaultPropertyManagers;exports.readDOMAttr = readDOMAttr;exports.normalizeTextValue = normalizeTextValue;exports.CompiledExpression = CompiledExpression;exports.CompiledArgs = CompiledArgs;exports.CompiledNamedArgs = CompiledNamedArgs;exports.CompiledPositionalArgs = CompiledPositionalArgs;exports.EvaluatedArgs = EvaluatedArgs;exports.EvaluatedNamedArgs = EvaluatedNamedArgs;exports.EvaluatedPositionalArgs = EvaluatedPositionalArgs;exports.getDynamicVar = getDynamicVar;exports.BlockMacros = Blocks;exports.InlineMacros = Inlines;exports.compileArgs = compileArgs;exports.setDebuggerCallback = setDebuggerCallback;exports.resetDebuggerCallback = resetDebuggerCallback;exports.BaselineSyntax = BaselineSyntax;exports.Layout = Layout;exports.UpdatingVM = UpdatingVM;exports.RenderResult = RenderResult;exports.isSafeString = isSafeString;exports.Scope = Scope;exports.Environment = Environment;exports.PartialDefinition = PartialDefinition;exports.ComponentDefinition = ComponentDefinition;exports.isComponentDefinition = isComponentDefinition;exports.DOMChanges = helper$1;exports.IDOMChanges = DOMChanges;exports.DOMTreeConstruction = DOMTreeConstruction;exports.isWhitespace = isWhitespace;exports.insertHTMLBefore = _insertHTMLBefore;exports.ElementStack = ElementStack;exports.ConcreteBounds = ConcreteBounds;}); +enifed('@glimmer/util', ['exports'], function (exports) { + // There is a small whitelist of namespaced attributes specially + // enumerated in + // https://www.w3.org/TR/html/syntax.html#attributes-0 + // + // > When a foreign element has one of the namespaced attributes given by + // > the local name and namespace of the first and second cells of a row + // > from the following table, it must be written using the name given by + // > the third cell from the same row. + // + // In all other cases, colons are interpreted as a regular character + // with no special meaning: + // + // > No other namespaced attribute can be expressed in the HTML syntax. + 'use strict'; - this._throttlers.push(throttler); + var XLINK = 'http://www.w3.org/1999/xlink'; + var XML = 'http://www.w3.org/XML/1998/namespace'; + var XMLNS = 'http://www.w3.org/2000/xmlns/'; + var WHITELIST = { + 'xlink:actuate': XLINK, + 'xlink:arcrole': XLINK, + 'xlink:href': XLINK, + 'xlink:role': XLINK, + 'xlink:show': XLINK, + 'xlink:title': XLINK, + 'xlink:type': XLINK, + 'xml:base': XML, + 'xml:lang': XML, + 'xml:space': XML, + 'xmlns': XMLNS, + 'xmlns:xlink': XMLNS + }; + function getAttrNamespace(attrName) { + return WHITELIST[attrName] || null; + } - return throttler; - }, + // tslint:disable-line + function unwrap(val) { + if (val === null || val === undefined) throw new Error('Expected value to be present'); + return val; + } + function expect(val, message) { + if (val === null || val === undefined) throw new Error(message); + return val; + } + function unreachable() { + return new Error('unreachable'); + } - debounce: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; + // import Logger from './logger'; + // let alreadyWarned = false; + // import Logger from './logger'; + function debugAssert(test, msg) { + // if (!alreadyWarned) { + // alreadyWarned = true; + // Logger.warn("Don't leave debug assertions on in public builds"); + // } + if (!test) { + throw new Error(msg || "assertion failure"); + } } - var immediate = args.pop(); - var wait, index, debouncee, timer; + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["Trace"] = 0] = "Trace"; + LogLevel[LogLevel["Debug"] = 1] = "Debug"; + LogLevel[LogLevel["Warn"] = 2] = "Warn"; + LogLevel[LogLevel["Error"] = 3] = "Error"; + })(LogLevel || (exports.LogLevel = LogLevel = {})); - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = false; - } else { - wait = args.pop(); - } + var NullConsole = (function () { + function NullConsole() {} - wait = parseInt(wait, 10); - // Remove debouncee - index = findDebouncee(target, method, this._debouncees); + NullConsole.prototype.log = function log(_message) {}; - if (index > -1) { - debouncee = this._debouncees[index]; - this._debouncees.splice(index, 1); - this._platform.clearTimeout(debouncee[2]); - } + NullConsole.prototype.warn = function warn(_message) {}; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findDebouncee(target, method, backburner._debouncees); - if (index > -1) { - backburner._debouncees.splice(index, 1); - } - }, wait); + NullConsole.prototype.error = function error(_message) {}; - if (immediate && index === -1) { - backburner.run.apply(backburner, args); - } + NullConsole.prototype.trace = function trace() {}; - debouncee = [ - target, - method, - timer - ]; + return NullConsole; + })(); - backburner._debouncees.push(debouncee); + var ALWAYS = undefined; - return debouncee; - }, + var Logger = (function () { + function Logger(_ref) { + var console = _ref.console; + var level = _ref.level; - cancelTimers: function() { - each(this._throttlers, this._boundClearItems); - this._throttlers = []; + this.f = ALWAYS; + this.force = ALWAYS; + this.console = console; + this.level = level; + } - each(this._debouncees, this._boundClearItems); - this._debouncees = []; + Logger.prototype.skipped = function skipped(level) { + return level < this.level; + }; - this._clearTimerTimeout(); - this._timers = []; + Logger.prototype.trace = function trace(message) { + var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (this._autorun) { - this._platform.clearTimeout(this._autorun); - this._autorun = null; - } - }, + var _ref2$stackTrace = _ref2.stackTrace; + var stackTrace = _ref2$stackTrace === undefined ? false : _ref2$stackTrace; - hasTimers: function() { - return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; - }, + if (this.skipped(LogLevel.Trace)) return; + this.console.log(message); + if (stackTrace) this.console.trace(); + }; - cancel: function (timer) { - var timerType = typeof timer; + Logger.prototype.debug = function debug(message) { + var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce - return timer.queue.cancel(timer); - } else if (timerType === 'function') { // we're cancelling a setTimeout - for (var i = 0, l = this._timers.length; i < l; i += 2) { - if (this._timers[i + 1] === timer) { - this._timers.splice(i, 2); // remove the two elements - if (i === 0) { - this._reinstallTimerTimeout(); - } - return true; - } - } - } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce - return this._cancelItem(findThrottler, this._throttlers, timer) || - this._cancelItem(findDebouncee, this._debouncees, timer); - } else { - return; // timer was null or not a timer - } - }, + var _ref3$stackTrace = _ref3.stackTrace; + var stackTrace = _ref3$stackTrace === undefined ? false : _ref3$stackTrace; - _cancelItem: function(findMethod, array, timer){ - var item, index; + if (this.skipped(LogLevel.Debug)) return; + this.console.log(message); + if (stackTrace) this.console.trace(); + }; - if (timer.length < 3) { return false; } + Logger.prototype.warn = function warn(message) { + var _ref4 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - index = findMethod(timer[0], timer[1], array); + var _ref4$stackTrace = _ref4.stackTrace; + var stackTrace = _ref4$stackTrace === undefined ? false : _ref4$stackTrace; - if (index > -1) { + if (this.skipped(LogLevel.Warn)) return; + this.console.warn(message); + if (stackTrace) this.console.trace(); + }; - item = array[index]; + Logger.prototype.error = function error(message) { + if (this.skipped(LogLevel.Error)) return; + this.console.error(message); + }; - if (item[2] === timer[2]) { - array.splice(index, 1); - this._platform.clearTimeout(timer[2]); - return true; - } - } + return Logger; + })(); - return false; - }, + var _console = typeof console === 'undefined' ? new NullConsole() : console; + ALWAYS = new Logger({ console: _console, level: LogLevel.Trace }); + var LOG_LEVEL = LogLevel.Warn; + var logger = new Logger({ console: _console, level: LOG_LEVEL }); - _runExpiredTimers: function () { - this._timerTimeoutId = undefined; - this.run(this, this._scheduleExpiredTimers); - }, + var objKeys = Object.keys; - _scheduleExpiredTimers: function () { - var n = Date.now(); - var timers = this._timers; - var i = 0; - var l = timers.length; - for (; i < l; i += 2) { - var executeAt = timers[i]; - var fn = timers[i+1]; - if (executeAt <= n) { - this.schedule(this.options.defaultQueue, null, fn); - } else { - break; - } + function assign(obj) { + for (var i = 1; i < arguments.length; i++) { + var assignment = arguments[i]; + if (assignment === null || typeof assignment !== 'object') continue; + var keys = objKeys(assignment); + for (var j = 0; j < keys.length; j++) { + var key = keys[j]; + obj[key] = assignment[key]; + } + } + return obj; + } + function fillNulls(count) { + var arr = new Array(count); + for (var i = 0; i < count; i++) { + arr[i] = null; + } + return arr; } - timers.splice(0, i); - this._installTimerTimeout(); - }, - - _reinstallTimerTimeout: function () { - this._clearTimerTimeout(); - this._installTimerTimeout(); - }, - _clearTimerTimeout: function () { - if (!this._timerTimeoutId) { - return; + var GUID = 0; + function initializeGuid(object) { + return object._guid = ++GUID; + } + function ensureGuid(object) { + return object._guid || initializeGuid(object); } - this._platform.clearTimeout(this._timerTimeoutId); - this._timerTimeoutId = undefined; - }, - _installTimerTimeout: function () { - if (!this._timers.length) { - return; + var proto = Object.create(null, { + // without this, we will always still end up with (new + // EmptyObject()).constructor === Object + constructor: { + value: undefined, + enumerable: false, + writable: true + } + }); + function EmptyObject() {} + EmptyObject.prototype = proto; + function dict() { + // let d = Object.create(null); + // d.x = 1; + // delete d.x; + // return d; + return new EmptyObject(); } - var minExpiresAt = this._timers[0]; - var n = Date.now(); - var wait = Math.max(0, minExpiresAt - n); - this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); - } -}; -Backburner.prototype.schedule = Backburner.prototype.defer; -Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; -Backburner.prototype.later = Backburner.prototype.setTimeout; + var DictSet = (function () { + function DictSet() { + this.dict = dict(); + } -function getOnError(options) { - return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); -} + DictSet.prototype.add = function add(obj) { + if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj; + return this; + }; -function createAutorun(backburner) { - var setTimeout = backburner._platform.setTimeout; - backburner.begin(); - backburner._autorun = setTimeout(function() { - backburner._autorun = null; - backburner.end(); - }, 0); -} + DictSet.prototype.delete = function _delete(obj) { + if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; + }; -function findDebouncee(target, method, debouncees) { - return findItem(target, method, debouncees); -} + DictSet.prototype.forEach = function forEach(callback) { + var dict = this.dict; -function findThrottler(target, method, throttlers) { - return findItem(target, method, throttlers); -} + Object.keys(dict).forEach(function (key) { + return callback(dict[key]); + }); + }; -function findItem(target, method, collection) { - var item; - var index = -1; + DictSet.prototype.toArray = function toArray() { + return Object.keys(this.dict); + }; - for (var i = 0, l = collection.length; i < l; i++) { - item = collection[i]; - if (item[0] === target && item[1] === method) { - index = i; - break; - } - } + return DictSet; + })(); - return index; -} + var Stack = (function () { + function Stack() { + this.stack = []; + this.current = null; + } -function clearItems(item) { - this._platform.clearTimeout(item[2]); -} + Stack.prototype.toArray = function toArray() { + return this.stack; + }; -exports['default'] = Backburner; + Stack.prototype.push = function push(item) { + this.current = item; + this.stack.push(item); + }; -Object.defineProperty(exports, '__esModule', { value: true }); + Stack.prototype.pop = function pop() { + var item = this.stack.pop(); + var len = this.stack.length; + this.current = len === 0 ? null : this.stack[len - 1]; + return item === undefined ? null : item; + }; -}); -enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) { - 'use strict'; + Stack.prototype.isEmpty = function isEmpty() { + return this.stack.length === 0; + }; - exports.default = Container; - exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations; + return Stack; + })(); - var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE'); + var ListNode = function ListNode(value) { + this.next = null; + this.prev = null; + this.value = value; + }; - /** - A container used to instantiate and cache objects. - - Every `Container` must be associated with a `Registry`, which is referenced - to determine the factory and options that should be used to instantiate - objects. - - The public API for `Container` is still in flux and should not be considered - stable. - - @private - @class Container - */ + var LinkedList = (function () { + function LinkedList() { + this.clear(); + } - function Container(registry, options) { - this.registry = registry; - this.owner = options && options.owner ? options.owner : null; - this.cache = _emberUtils.dictionary(options && options.cache ? options.cache : null); - this.factoryCache = _emberUtils.dictionary(options && options.factoryCache ? options.factoryCache : null); - this.validationCache = _emberUtils.dictionary(options && options.validationCache ? options.validationCache : null); - this._fakeContainerToInject = buildFakeContainerWithDeprecations(this); - this[CONTAINER_OVERRIDE] = undefined; - this.isDestroyed = false; - } + LinkedList.fromSlice = function fromSlice(slice) { + var list = new LinkedList(); + slice.forEachNode(function (n) { + return list.append(n.clone()); + }); + return list; + }; - Container.prototype = { - /** - @private - @property owner - @type Object - */ - owner: null, + LinkedList.prototype.head = function head() { + return this._head; + }; - /** - @private - @property registry - @type Registry - @since 1.11.0 - */ - registry: null, + LinkedList.prototype.tail = function tail() { + return this._tail; + }; - /** - @private - @property cache - @type InheritingDict - */ - cache: null, + LinkedList.prototype.clear = function clear() { + this._head = this._tail = null; + }; - /** - @private - @property factoryCache - @type InheritingDict - */ - factoryCache: null, + LinkedList.prototype.isEmpty = function isEmpty() { + return this._head === null; + }; - /** - @private - @property validationCache - @type InheritingDict - */ - validationCache: null, + LinkedList.prototype.toArray = function toArray() { + var out = []; + this.forEachNode(function (n) { + return out.push(n); + }); + return out; + }; - /** - Given a fullName return a corresponding instance. - The default behaviour is for lookup to return a singleton instance. - The singleton is scoped to the container, allowing multiple containers - to all have their own locally scoped singletons. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter'); - twitter instanceof Twitter; // => true - // by default the container will return singletons - let twitter2 = container.lookup('api:twitter'); - twitter2 instanceof Twitter; // => true - twitter === twitter2; //=> true - ``` - If singletons are not wanted, an optional flag can be provided at lookup. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter', { singleton: false }); - let twitter2 = container.lookup('api:twitter', { singleton: false }); - twitter === twitter2; //=> false - ``` - @private - @method lookup - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] The fullname of the request source (used for local lookup) - @return {any} - */ - lookup: function (fullName, options) { - _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); - return lookup(this, this.registry.normalize(fullName), options); - }, + LinkedList.prototype.splice = function splice(start, end, reference) { + var before = undefined; + if (reference === null) { + before = this._tail; + this._tail = end; + } else { + before = reference.prev; + end.next = reference; + reference.prev = end; + } + if (before) { + before.next = start; + start.prev = before; + } + }; - /** - Given a fullName, return the corresponding factory. - @private - @method lookupFactory - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] The fullname of the request source (used for local lookup) - @return {any} - */ - lookupFactory: function (fullName, options) { - _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); - return factoryFor(this, this.registry.normalize(fullName), options); - }, + LinkedList.prototype.nextNode = function nextNode(node) { + return node.next; + }; - /** - A depth first traversal, destroying the container, its descendant containers and all - their managed objects. - @private - @method destroy - */ - destroy: function () { - eachDestroyable(this, function (item) { - if (item.destroy) { - item.destroy(); - } - }); + LinkedList.prototype.prevNode = function prevNode(node) { + return node.prev; + }; - this.isDestroyed = true; - }, + LinkedList.prototype.forEachNode = function forEachNode(callback) { + var node = this._head; + while (node !== null) { + callback(node); + node = node.next; + } + }; - /** - Clear either the entire cache or just the cache for a particular key. - @private - @method reset - @param {String} fullName optional key to reset; if missing, resets everything - */ - reset: function (fullName) { - if (arguments.length > 0) { - resetMember(this, this.registry.normalize(fullName)); - } else { - resetCache(this); - } - }, + LinkedList.prototype.contains = function contains(needle) { + var node = this._head; + while (node !== null) { + if (node === needle) return true; + node = node.next; + } + return false; + }; - /** - Returns an object that can be used to provide an owner to a - manually created instance. - @private - @method ownerInjection - @returns { Object } - */ - ownerInjection: function () { - var _ref; + LinkedList.prototype.insertBefore = function insertBefore(node) { + var reference = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; - } - }; + if (reference === null) return this.append(node); + if (reference.prev) reference.prev.next = node;else this._head = node; + node.prev = reference.prev; + node.next = reference; + reference.prev = node; + return node; + }; - function isSingleton(container, fullName) { - return container.registry.getOption(fullName, 'singleton') !== false; - } + LinkedList.prototype.append = function append(node) { + var tail = this._tail; + if (tail) { + tail.next = node; + node.prev = tail; + node.next = null; + } else { + this._head = node; + } + return this._tail = node; + }; - function lookup(container, fullName) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + LinkedList.prototype.pop = function pop() { + if (this._tail) return this.remove(this._tail); + return null; + }; - if (options.source) { - fullName = container.registry.expandLocalLookup(fullName, options); + LinkedList.prototype.prepend = function prepend(node) { + if (this._head) return this.insertBefore(node, this._head); + return this._head = this._tail = node; + }; - // if expandLocalLookup returns falsey, we do not support local lookup - if (!fullName) { - return; - } - } + LinkedList.prototype.remove = function remove(node) { + if (node.prev) node.prev.next = node.next;else this._head = node.next; + if (node.next) node.next.prev = node.prev;else this._tail = node.prev; + return node; + }; - if (container.cache[fullName] !== undefined && options.singleton !== false) { - return container.cache[fullName]; - } + return LinkedList; + })(); - var value = instantiate(container, fullName); + var ListSlice = (function () { + function ListSlice(head, tail) { + this._head = head; + this._tail = tail; + } - if (value === undefined) { - return; - } + ListSlice.toList = function toList(slice) { + var list = new LinkedList(); + slice.forEachNode(function (n) { + return list.append(n.clone()); + }); + return list; + }; - if (isSingleton(container, fullName) && options.singleton !== false) { - container.cache[fullName] = value; - } + ListSlice.prototype.forEachNode = function forEachNode(callback) { + var node = this._head; + while (node !== null) { + callback(node); + node = this.nextNode(node); + } + }; - return value; - } + ListSlice.prototype.contains = function contains(needle) { + var node = this._head; + while (node !== null) { + if (node === needle) return true; + node = node.next; + } + return false; + }; - function markInjectionsAsDynamic(injections) { - injections._dynamic = true; - } + ListSlice.prototype.head = function head() { + return this._head; + }; - function areInjectionsDynamic(injections) { - return !!injections._dynamic; - } + ListSlice.prototype.tail = function tail() { + return this._tail; + }; - function buildInjections() /* container, ...injections */{ - var hash = {}; + ListSlice.prototype.toArray = function toArray() { + var out = []; + this.forEachNode(function (n) { + return out.push(n); + }); + return out; + }; - if (arguments.length > 1) { - var container = arguments[0]; - var injections = []; - var injection = undefined; + ListSlice.prototype.nextNode = function nextNode(node) { + if (node === this._tail) return null; + return node.next; + }; - for (var i = 1; i < arguments.length; i++) { - if (arguments[i]) { - injections = injections.concat(arguments[i]); - } - } + ListSlice.prototype.prevNode = function prevNode(node) { + if (node === this._head) return null; + return node.prev; + }; - container.registry.validateInjections(injections); + ListSlice.prototype.isEmpty = function isEmpty() { + return false; + }; - for (var i = 0; i < injections.length; i++) { - injection = injections[i]; - hash[injection.property] = lookup(container, injection.fullName); - if (!isSingleton(container, injection.fullName)) { - markInjectionsAsDynamic(hash); - } - } - } + return ListSlice; + })(); - return hash; - } + var EMPTY_SLICE = new ListSlice(null, null); - function factoryFor(container, fullName) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + var HAS_TYPED_ARRAYS = typeof Uint32Array !== 'undefined'; + var A = undefined; + if (HAS_TYPED_ARRAYS) { + A = Uint32Array; + } else { + A = Array; + } + var A$1 = A; - var registry = container.registry; + var HAS_NATIVE_WEAKMAP = (function () { + // detect if `WeakMap` is even present + var hasWeakMap = typeof WeakMap === 'function'; + if (!hasWeakMap) { + return false; + } + var instance = new WeakMap(); + // use `Object`'s `.toString` directly to prevent us from detecting + // polyfills as native weakmaps + return Object.prototype.toString.call(instance) === '[object WeakMap]'; + })(); - if (options.source) { - fullName = registry.expandLocalLookup(fullName, options); + exports.getAttrNamespace = getAttrNamespace; + exports.assert = debugAssert; + exports.LOGGER = logger; + exports.Logger = Logger; + exports.LogLevel = LogLevel; + exports.assign = assign; + exports.fillNulls = fillNulls; + exports.ensureGuid = ensureGuid; + exports.initializeGuid = initializeGuid; + exports.Stack = Stack; + exports.DictSet = DictSet; + exports.dict = dict; + exports.EMPTY_SLICE = EMPTY_SLICE; + exports.LinkedList = LinkedList; + exports.ListNode = ListNode; + exports.ListSlice = ListSlice; + exports.A = A$1; + exports.HAS_NATIVE_WEAKMAP = HAS_NATIVE_WEAKMAP; + exports.unwrap = unwrap; + exports.expect = expect; + exports.unreachable = unreachable; +}); +enifed('@glimmer/wire-format', ['exports'], function (exports) { + 'use strict'; - // if expandLocalLookup returns falsey, we do not support local lookup - if (!fullName) { - return; - } + function is(variant) { + return function (value) { + return value[0] === variant; + }; } + var Expressions; + (function (Expressions) { + Expressions.isUnknown = is('unknown'); + Expressions.isArg = is('arg'); + Expressions.isGet = is('get'); + Expressions.isConcat = is('concat'); + Expressions.isHelper = is('helper'); + Expressions.isHasBlock = is('has-block'); + Expressions.isHasBlockParams = is('has-block-params'); + Expressions.isUndefined = is('undefined'); + function isPrimitiveValue(value) { + if (value === null) { + return true; + } + return typeof value !== 'object'; + } + Expressions.isPrimitiveValue = isPrimitiveValue; + })(Expressions || (exports.Expressions = Expressions = {})); + var Statements; + (function (Statements) { + Statements.isText = is('text'); + Statements.isAppend = is('append'); + Statements.isComment = is('comment'); + Statements.isModifier = is('modifier'); + Statements.isBlock = is('block'); + Statements.isComponent = is('component'); + Statements.isOpenElement = is('open-element'); + Statements.isFlushElement = is('flush-element'); + Statements.isCloseElement = is('close-element'); + Statements.isStaticAttr = is('static-attr'); + Statements.isDynamicAttr = is('dynamic-attr'); + Statements.isYield = is('yield'); + Statements.isPartial = is('partial'); + Statements.isDynamicArg = is('dynamic-arg'); + Statements.isStaticArg = is('static-arg'); + Statements.isTrustingAttr = is('trusting-attr'); + Statements.isDebugger = is('debugger'); + function isAttribute(val) { + return val[0] === 'static-attr' || val[0] === 'dynamic-attr'; + } + Statements.isAttribute = isAttribute; + function isArgument(val) { + return val[0] === 'static-arg' || val[0] === 'dynamic-arg'; + } + Statements.isArgument = isArgument; + function isParameter(val) { + return isAttribute(val) || isArgument(val); + } + Statements.isParameter = isParameter; + function getParameterName(s) { + return s[1]; + } + Statements.getParameterName = getParameterName; + })(Statements || (exports.Statements = Statements = {})); - var cache = container.factoryCache; - if (cache[fullName]) { - return cache[fullName]; - } - var factory = registry.resolve(fullName); - if (factory === undefined) { - return; - } + exports.is = is; + exports.Expressions = Expressions; + exports.Statements = Statements; +}); +enifed('backburner', ['exports'], function (exports) { 'use strict'; - var type = fullName.split(':')[0]; - if (!factory || typeof factory.extend !== 'function' || !_emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS && type === 'model') { - if (factory && typeof factory._onLookup === 'function') { - factory._onLookup(fullName); - } +var NUMBER = /\d+/; - // TODO: think about a 'safe' merge style extension - // for now just fallback to create time injection - cache[fullName] = factory; - return factory; - } else { - var injections = injectionsFor(container, fullName); - var factoryInjections = factoryInjectionsFor(container, fullName); - var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); +function each(collection, callback) { + for (var i = 0; i < collection.length; i++) { + callback(collection[i]); + } +} - factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); +function isString(suspect) { + return typeof suspect === 'string'; +} - var injectedFactory = factory.extend(injections); +function isFunction(suspect) { + return typeof suspect === 'function'; +} - // TODO - remove all `container` injections when Ember reaches v3.0.0 - injectDeprecatedContainer(injectedFactory.prototype, container); - injectedFactory.reopenClass(factoryInjections); +function isNumber(suspect) { + return typeof suspect === 'number'; +} - if (factory && typeof factory._onLookup === 'function') { - factory._onLookup(fullName); - } +function isCoercableNumber(number) { + return isNumber(number) || NUMBER.test(number); +} - if (cacheable) { - cache[fullName] = injectedFactory; - } +function binarySearch(time, timers) { + var start = 0; + var end = timers.length - 2; + var middle, l; - return injectedFactory; + while (start < end) { + // since timers is an array of pairs 'l' will always + // be an integer + l = (end - start) / 2; + + // compensate for the index in case even number + // of pairs inside timers + middle = start + l - (l % 2); + + if (time >= timers[middle]) { + start = middle + 2; + } else { + end = middle; } } - function injectionsFor(container, fullName) { - var registry = container.registry; - var splitName = fullName.split(':'); - var type = splitName[0]; + return (time >= timers[start]) ? start + 2 : start; +} - var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); - injections._debugContainerKey = fullName; +function Queue(name, options, globalOptions) { + this.name = name; + this.globalOptions = globalOptions || {}; + this.options = options; + this._queue = []; + this.targetQueues = {}; + this._queueBeingFlushed = undefined; +} - _emberUtils.setOwner(injections, container.owner); +Queue.prototype = { + push: function(target, method, args, stack) { + var queue = this._queue; + queue.push(target, method, args, stack); - return injections; - } + return { + queue: this, + target: target, + method: method + }; + }, - function factoryInjectionsFor(container, fullName) { - var registry = container.registry; - var splitName = fullName.split(':'); - var type = splitName[0]; + pushUniqueWithoutGuid: function(target, method, args, stack) { + var queue = this._queue; - var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); - factoryInjections._debugContainerKey = fullName; + for (var i = 0, l = queue.length; i < l; i += 4) { + var currentTarget = queue[i]; + var currentMethod = queue[i+1]; - return factoryInjections; - } + if (currentTarget === target && currentMethod === method) { + queue[i+2] = args; // replace args + queue[i+3] = stack; // replace stack + return; + } + } - function instantiate(container, fullName) { - var factory = factoryFor(container, fullName); - var lazyInjections = undefined, - validationCache = undefined; + queue.push(target, method, args, stack); + }, - if (container.registry.getOption(fullName, 'instantiate') === false) { - return factory; - } + targetQueue: function(targetQueue, target, method, args, stack) { + var queue = this._queue; - if (factory) { - if (typeof factory.create !== 'function') { - throw new Error('Failed to create an instance of \'' + fullName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); + for (var i = 0, l = targetQueue.length; i < l; i += 2) { + var currentMethod = targetQueue[i]; + var currentIndex = targetQueue[i + 1]; + + if (currentMethod === method) { + queue[currentIndex + 2] = args; // replace args + queue[currentIndex + 3] = stack; // replace stack + return; } + } - validationCache = container.validationCache; + targetQueue.push( + method, + queue.push(target, method, args, stack) - 4 + ); + }, - _emberMetal.runInDebug(function () { - // Ensure that all lazy injections are valid at instantiation time - if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') { - lazyInjections = factory._lazyInjections(); - lazyInjections = container.registry.normalizeInjectionsHash(lazyInjections); + pushUniqueWithGuid: function(guid, target, method, args, stack) { + var hasLocalQueue = this.targetQueues[guid]; - container.registry.validateInjections(lazyInjections); - } - }); + if (hasLocalQueue) { + this.targetQueue(hasLocalQueue, target, method, args, stack); + } else { + this.targetQueues[guid] = [ + method, + this._queue.push(target, method, args, stack) - 4 + ]; + } - validationCache[fullName] = true; + return { + queue: this, + target: target, + method: method + }; + }, - var obj = undefined; + pushUnique: function(target, method, args, stack) { + var KEY = this.globalOptions.GUID_KEY; - if (typeof factory.extend === 'function') { - // assume the factory was extendable and is already injected - obj = factory.create(); - } else { - // assume the factory was extendable - // to create time injections - // TODO: support new'ing for instantiation and merge injections for pure JS Functions - var injections = injectionsFor(container, fullName); + if (target && KEY) { + var guid = target[KEY]; + if (guid) { + return this.pushUniqueWithGuid(guid, target, method, args, stack); + } + } - // Ensure that a container is available to an object during instantiation. - // TODO - remove when Ember reaches v3.0.0 - // This "fake" container will be replaced after instantiation with a - // property that raises deprecations every time it is accessed. - injections.container = container._fakeContainerToInject; - obj = factory.create(injections); + this.pushUniqueWithoutGuid(target, method, args, stack); - // TODO - remove when Ember reaches v3.0.0 - if (!Object.isFrozen(obj) && 'container' in obj) { - injectDeprecatedContainer(obj, container); - } - } + return { + queue: this, + target: target, + method: method + }; + }, - return obj; + invoke: function(target, method, args /*, onError, errorRecordedForStack */) { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); } - } + }, - // TODO - remove when Ember reaches v3.0.0 - function injectDeprecatedContainer(object, container) { - Object.defineProperty(object, 'container', { - configurable: true, - enumerable: false, - get: function () { - _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); - return this[CONTAINER_OVERRIDE] || container; - }, + invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { + try { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); + } + } catch(error) { + onError(error, errorRecordedForStack); + } + }, - set: function (value) { - _emberMetal.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + flush: function(sync) { + var queue = this._queue; + var length = queue.length; - this[CONTAINER_OVERRIDE] = value; + if (length === 0) { + return; + } - return value; - } - }); - } + var globalOptions = this.globalOptions; + var options = this.options; + var before = options && options.before; + var after = options && options.after; + var onError = globalOptions.onError || (globalOptions.onErrorTarget && + globalOptions.onErrorTarget[globalOptions.onErrorMethod]); + var target, method, args, errorRecordedForStack; + var invoke = onError ? this.invokeWithOnError : this.invoke; - function eachDestroyable(container, callback) { - var cache = container.cache; - var keys = Object.keys(cache); + this.targetQueues = Object.create(null); + var queueItems = this._queueBeingFlushed = this._queue.slice(); + this._queue = []; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var value = cache[key]; + if (before) { + before(); + } - if (container.registry.getOption(key, 'instantiate') !== false) { - callback(value); + for (var i = 0; i < length; i += 4) { + target = queueItems[i]; + method = queueItems[i+1]; + args = queueItems[i+2]; + errorRecordedForStack = queueItems[i+3]; // Debugging assistance + + if (isString(method)) { + method = target[method]; } - } - } - function resetCache(container) { - eachDestroyable(container, function (value) { - if (value.destroy) { - value.destroy(); + // method could have been nullified / canceled during flush + if (method) { + // + // ** Attention intrepid developer ** + // + // To find out the stack of this task when it was scheduled onto + // the run loop, add the following to your app.js: + // + // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. + // + // Once that is in place, when you are at a breakpoint and navigate + // here in the stack explorer, you can look at `errorRecordedForStack.stack`, + // which will be the captured stack when this job was scheduled. + // + // One possible long-term solution is the following Chrome issue: + // https://bugs.chromium.org/p/chromium/issues/detail?id=332624 + // + invoke(target, method, args, onError, errorRecordedForStack); } - }); + } - container.cache.dict = _emberUtils.dictionary(null); - } + if (after) { + after(); + } - function resetMember(container, fullName) { - var member = container.cache[fullName]; + this._queueBeingFlushed = undefined; - delete container.factoryCache[fullName]; + if (sync !== false && + this._queue.length > 0) { + // check if new items have been added + this.flush(true); + } + }, - if (member) { - delete container.cache[fullName]; + cancel: function(actionToCancel) { + var queue = this._queue, currentTarget, currentMethod, i, l; + var target = actionToCancel.target; + var method = actionToCancel.method; + var GUID_KEY = this.globalOptions.GUID_KEY; - if (member.destroy) { - member.destroy(); + if (GUID_KEY && this.targetQueues && target) { + var targetQueue = this.targetQueues[target[GUID_KEY]]; + + if (targetQueue) { + for (i = 0, l = targetQueue.length; i < l; i++) { + if (targetQueue[i] === method) { + targetQueue.splice(i, 1); + } + } } } - } - function buildFakeContainerWithDeprecations(container) { - var fakeContainer = {}; - var propertyMappings = { - lookup: 'lookup', - lookupFactory: '_lookupFactory' - }; + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; - for (var containerProperty in propertyMappings) { - fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]); + if (currentTarget === target && + currentMethod === method) { + queue.splice(i, 4); + return true; + } } - return fakeContainer; - } + // if not found in current queue + // could be in the queue that is being flushed + queue = this._queueBeingFlushed; - function buildFakeContainerFunction(container, containerProperty, ownerProperty) { - return function () { - _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `' + ownerProperty + '` instead.', false, { - id: 'ember-application.injected-container', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' - }); - return container[containerProperty].apply(container, arguments); - }; + if (!queue) { + return; + } + + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; + + if (currentTarget === target && + currentMethod === method) { + // don't mess with array during flush + // just nullify the method + queue[i+1] = null; + return true; + } + } } -}); -enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) { - /* - Public API for the container is still in flux. - The public API, specified on the application namespace should be considered the stable API. - // @module container - @private - */ +}; - 'use strict'; +function DeferredActionQueues(queueNames, options) { + var queues = this.queues = {}; + this.queueNames = queueNames = queueNames || []; - exports.Registry = _containerRegistry.default; - exports.privatize = _containerRegistry.privatize; - exports.Container = _containerContainer.default; - exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations; -}); -enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) { - 'use strict'; + this.options = options; - exports.default = Registry; - exports.privatize = privatize; + each(queueNames, function(queueName) { + queues[queueName] = new Queue(queueName, options[queueName], options); + }); +} - var VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/; +function noSuchQueue(name) { + throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist'); +} - /** - A registry used to store factory and option information keyed - by type. - - A `Registry` stores the factory and option information needed by a - `Container` to instantiate and cache objects. - - The API for `Registry` is still in flux and should not be considered stable. - - @private - @class Registry - @since 1.11.0 - */ +function noSuchMethod(name) { + throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist'); +} - function Registry(options) { - this.fallback = options && options.fallback ? options.fallback : null; +DeferredActionQueues.prototype = { + schedule: function(name, target, method, args, onceFlag, stack) { + var queues = this.queues; + var queue = queues[name]; - if (options && options.resolver) { - this.resolver = options.resolver; + if (!queue) { + noSuchQueue(name); + } - if (typeof this.resolver === 'function') { - deprecateResolverFunction(this); - } + if (!method) { + noSuchMethod(name); } - this.registrations = _emberUtils.dictionary(options && options.registrations ? options.registrations : null); + if (onceFlag) { + return queue.pushUnique(target, method, args, stack); + } else { + return queue.push(target, method, args, stack); + } + }, - this._typeInjections = _emberUtils.dictionary(null); - this._injections = _emberUtils.dictionary(null); - this._factoryTypeInjections = _emberUtils.dictionary(null); - this._factoryInjections = _emberUtils.dictionary(null); + flush: function() { + var queues = this.queues; + var queueNames = this.queueNames; + var queueName, queue; + var queueNameIndex = 0; + var numberOfQueues = queueNames.length; - this._localLookupCache = new _emberUtils.EmptyObject(); - this._normalizeCache = _emberUtils.dictionary(null); - this._resolveCache = _emberUtils.dictionary(null); - this._failCache = _emberUtils.dictionary(null); + while (queueNameIndex < numberOfQueues) { + queueName = queueNames[queueNameIndex]; + queue = queues[queueName]; - this._options = _emberUtils.dictionary(null); - this._typeOptions = _emberUtils.dictionary(null); + var numberOfQueueItems = queue._queue.length; + + if (numberOfQueueItems === 0) { + queueNameIndex++; + } else { + queue.flush(false /* async */); + queueNameIndex = 0; + } + } } +}; - Registry.prototype = { - /** - A backup registry for resolving registrations when no matches can be found. - @private - @property fallback - @type Registry - */ - fallback: null, +function Backburner(queueNames, options) { + this.queueNames = queueNames; + this.options = options || {}; + if (!this.options.defaultQueue) { + this.options.defaultQueue = queueNames[0]; + } + this.instanceStack = []; + this._debouncees = []; + this._throttlers = []; + this._eventCallbacks = { + end: [], + begin: [] + }; - /** - An object that has a `resolve` method that resolves a name. - @private - @property resolver - @type Resolver - */ - resolver: null, + var _this = this; + this._boundClearItems = function() { + clearItems(); + }; - /** - @private - @property registrations - @type InheritingDict - */ - registrations: null, + this._timerTimeoutId = undefined; + this._timers = []; - /** - @private - @property _typeInjections - @type InheritingDict - */ - _typeInjections: null, + this._platform = this.options._platform || { + setTimeout: function (fn, ms) { + return setTimeout(fn, ms); + }, + clearTimeout: function (id) { + clearTimeout(id); + } + }; - /** - @private - @property _injections - @type InheritingDict - */ - _injections: null, + this._boundRunExpiredTimers = function () { + _this._runExpiredTimers(); + }; +} - /** - @private - @property _factoryTypeInjections - @type InheritingDict - */ - _factoryTypeInjections: null, +Backburner.prototype = { + begin: function() { + var options = this.options; + var onBegin = options && options.onBegin; + var previousInstance = this.currentInstance; - /** - @private - @property _factoryInjections - @type InheritingDict - */ - _factoryInjections: null, + if (previousInstance) { + this.instanceStack.push(previousInstance); + } - /** - @private - @property _normalizeCache - @type InheritingDict - */ - _normalizeCache: null, + this.currentInstance = new DeferredActionQueues(this.queueNames, options); + this._trigger('begin', this.currentInstance, previousInstance); + if (onBegin) { + onBegin(this.currentInstance, previousInstance); + } + }, - /** - @private - @property _resolveCache - @type InheritingDict - */ - _resolveCache: null, + end: function() { + var options = this.options; + var onEnd = options && options.onEnd; + var currentInstance = this.currentInstance; + var nextInstance = null; - /** - @private - @property _options - @type InheritingDict - */ - _options: null, - - /** - @private - @property _typeOptions - @type InheritingDict - */ - _typeOptions: null, + // Prevent double-finally bug in Safari 6.0.2 and iOS 6 + // This bug appears to be resolved in Safari 6.0.5 and iOS 7 + var finallyAlreadyCalled = false; + try { + currentInstance.flush(); + } finally { + if (!finallyAlreadyCalled) { + finallyAlreadyCalled = true; - /** - Creates a container based on this registry. - @private - @method container - @param {Object} options - @return {Container} created container - */ - container: function (options) { - return new _containerContainer.default(this, options); - }, + this.currentInstance = null; - /** - Registers a factory for later injection. - Example: - ```javascript - let registry = new Registry(); - registry.register('model:user', Person, {singleton: false }); - registry.register('fruit:favorite', Orange); - registry.register('communication:main', Email, {singleton: false}); - ``` - @private - @method register - @param {String} fullName - @param {Function} factory - @param {Object} options - */ - register: function (fullName, factory) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + if (this.instanceStack.length) { + nextInstance = this.instanceStack.pop(); + this.currentInstance = nextInstance; + } + this._trigger('end', currentInstance, nextInstance); + if (onEnd) { + onEnd(currentInstance, nextInstance); + } + } + } + }, - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + /** + Trigger an event. Supports up to two arguments. Designed around + triggering transition events from one run loop instance to the + next, which requires an argument for the first instance and then + an argument for the next instance. - if (factory === undefined) { - throw new TypeError('Attempting to register an unknown factory: \'' + fullName + '\''); + @private + @method _trigger + @param {String} eventName + @param {any} arg1 + @param {any} arg2 + */ + _trigger: function(eventName, arg1, arg2) { + var callbacks = this._eventCallbacks[eventName]; + if (callbacks) { + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](arg1, arg2); } + } + }, - var normalizedName = this.normalize(fullName); + on: function(eventName, callback) { + if (typeof callback !== 'function') { + throw new TypeError('Callback must be a function'); + } + var callbacks = this._eventCallbacks[eventName]; + if (callbacks) { + callbacks.push(callback); + } else { + throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist'); + } + }, - if (this._resolveCache[normalizedName]) { - throw new Error('Cannot re-register: \'' + fullName + '\', as it has already been resolved.'); + off: function(eventName, callback) { + if (eventName) { + var callbacks = this._eventCallbacks[eventName]; + var callbackFound = false; + if (!callbacks) return; + if (callback) { + for (var i = 0; i < callbacks.length; i++) { + if (callbacks[i] === callback) { + callbackFound = true; + callbacks.splice(i, 1); + i--; + } + } + } + if (!callbackFound) { + throw new TypeError('Cannot off() callback that does not exist'); } + } else { + throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist'); + } + }, - delete this._failCache[normalizedName]; - this.registrations[normalizedName] = factory; - this._options[normalizedName] = options; - }, + run: function(/* target, method, args */) { + var length = arguments.length; + var method, target, args; - /** - Unregister a fullName - ```javascript - let registry = new Registry(); - registry.register('model:user', User); - registry.resolve('model:user').create() instanceof User //=> true - registry.unregister('model:user') - registry.resolve('model:user') === undefined //=> true - ``` - @private - @method unregister - @param {String} fullName - */ - unregister: function (fullName) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + if (length === 1) { + method = arguments[0]; + target = null; + } else { + target = arguments[0]; + method = arguments[1]; + } - var normalizedName = this.normalize(fullName); + if (isString(method)) { + method = target[method]; + } - this._localLookupCache = new _emberUtils.EmptyObject(); + if (length > 2) { + args = new Array(length - 2); + for (var i = 0, l = length - 2; i < l; i++) { + args[i] = arguments[i + 2]; + } + } else { + args = []; + } - delete this.registrations[normalizedName]; - delete this._resolveCache[normalizedName]; - delete this._failCache[normalizedName]; - delete this._options[normalizedName]; - }, + var onError = getOnError(this.options); - /** - Given a fullName return the corresponding factory. - By default `resolve` will retrieve the factory from - the registry. - ```javascript - let registry = new Registry(); - registry.register('api:twitter', Twitter); - registry.resolve('api:twitter') // => Twitter - ``` - Optionally the registry can be provided with a custom resolver. - If provided, `resolve` will first provide the custom resolver - the opportunity to resolve the fullName, otherwise it will fallback - to the registry. - ```javascript - let registry = new Registry(); - registry.resolver = function(fullName) { - // lookup via the module system of choice - }; - // the twitter factory is added to the module system - registry.resolve('api:twitter') // => Twitter - ``` - @private - @method resolve - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {Function} fullName's factory - */ - resolve: function (fullName, options) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - var factory = resolve(this, this.normalize(fullName), options); - if (factory === undefined && this.fallback) { - var _fallback; + this.begin(); - factory = (_fallback = this.fallback).resolve.apply(_fallback, arguments); - } - return factory; - }, + // guard against Safari 6's double-finally bug + var didFinally = false; - /** - A hook that can be used to describe how the resolver will - attempt to find the factory. - For example, the default Ember `.describe` returns the full - class name (including namespace) where Ember's resolver expects - to find the `fullName`. - @private - @method describe - @param {String} fullName - @return {string} described fullName - */ - describe: function (fullName) { - if (this.resolver && this.resolver.lookupDescription) { - return this.resolver.lookupDescription(fullName); - } else if (this.fallback) { - return this.fallback.describe(fullName); - } else { - return fullName; + if (onError) { + try { + return method.apply(target, args); + } catch(error) { + onError(error); + } finally { + if (!didFinally) { + didFinally = true; + this.end(); + } } - }, - - /** - A hook to enable custom fullName normalization behaviour - @private - @method normalizeFullName - @param {String} fullName - @return {string} normalized fullName - */ - normalizeFullName: function (fullName) { - if (this.resolver && this.resolver.normalize) { - return this.resolver.normalize(fullName); - } else if (this.fallback) { - return this.fallback.normalizeFullName(fullName); - } else { - return fullName; + } else { + try { + return method.apply(target, args); + } finally { + if (!didFinally) { + didFinally = true; + this.end(); + } } - }, + } + }, - /** - Normalize a fullName based on the application's conventions - @private - @method normalize - @param {String} fullName - @return {string} normalized fullName - */ - normalize: function (fullName) { - return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName)); - }, + /* + Join the passed method with an existing queue and execute immediately, + if there isn't one use `Backburner#run`. - /** - @method makeToString - @private - @param {any} factory - @param {string} fullName - @return {function} toString function - */ - makeToString: function (factory, fullName) { - if (this.resolver && this.resolver.makeToString) { - return this.resolver.makeToString(factory, fullName); - } else if (this.fallback) { - return this.fallback.makeToString(factory, fullName); - } else { - return factory.toString(); - } - }, + The join method is like the run method except that it will schedule into + an existing queue if one already exists. In either case, the join method will + immediately execute the passed in function and return its result. - /** - Given a fullName check if the container is aware of its factory - or singleton instance. - @private - @method has - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {Boolean} - */ - has: function (fullName, options) { - if (!this.isValidFullName(fullName)) { - return false; - } + @method join + @param {Object} target + @param {Function} method The method to be executed + @param {any} args The method arguments + @return method result + */ + join: function(/* target, method, args */) { + if (!this.currentInstance) { + return this.run.apply(this, arguments); + } - var source = options && options.source && this.normalize(options.source); + var length = arguments.length; + var method, target; - return has(this, this.normalize(fullName), source); - }, + if (length === 1) { + method = arguments[0]; + target = null; + } else { + target = arguments[0]; + method = arguments[1]; + } - /** - Allow registering options for all factories of a type. - ```javascript - let registry = new Registry(); - let container = registry.container(); - // if all of type `connection` must not be singletons - registry.optionsForType('connection', { singleton: false }); - registry.register('connection:twitter', TwitterConnection); - registry.register('connection:facebook', FacebookConnection); - let twitter = container.lookup('connection:twitter'); - let twitter2 = container.lookup('connection:twitter'); - twitter === twitter2; // => false - let facebook = container.lookup('connection:facebook'); - let facebook2 = container.lookup('connection:facebook'); - facebook === facebook2; // => false - ``` - @private - @method optionsForType - @param {String} type - @param {Object} options - */ - optionsForType: function (type, options) { - this._typeOptions[type] = options; - }, + if (isString(method)) { + method = target[method]; + } - getOptionsForType: function (type) { - var optionsForType = this._typeOptions[type]; - if (optionsForType === undefined && this.fallback) { - optionsForType = this.fallback.getOptionsForType(type); + if (length === 1) { + return method(); + } else if (length === 2) { + return method.call(target); + } else { + var args = new Array(length - 2); + for (var i = 0, l = length - 2; i < l; i++) { + args[i] = arguments[i + 2]; } - return optionsForType; - }, + return method.apply(target, args); + } + }, - /** - @private - @method options - @param {String} fullName - @param {Object} options - */ - options: function (fullName) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var normalizedName = this.normalize(fullName); - this._options[normalizedName] = options; - }, + /* + Defer the passed function to run inside the specified queue. - getOptions: function (fullName) { - var normalizedName = this.normalize(fullName); - var options = this._options[normalizedName]; + @method defer + @param {String} queueName + @param {Object} target + @param {Function|String} method The method or method name to be executed + @param {any} args The method arguments + @return method result + */ + defer: function(queueName /* , target, method, args */) { + var length = arguments.length; + var method, target, args; - if (options === undefined && this.fallback) { - options = this.fallback.getOptions(fullName); - } - return options; - }, + if (length === 2) { + method = arguments[1]; + target = null; + } else { + target = arguments[1]; + method = arguments[2]; + } - getOption: function (fullName, optionName) { - var options = this._options[fullName]; + if (isString(method)) { + method = target[method]; + } - if (options && options[optionName] !== undefined) { - return options[optionName]; + var stack = this.DEBUG ? new Error() : undefined; + + if (length > 3) { + args = new Array(length - 3); + for (var i = 3; i < length; i++) { + args[i-3] = arguments[i]; } + } else { + args = undefined; + } - var type = fullName.split(':')[0]; - options = this._typeOptions[type]; + if (!this.currentInstance) { createAutorun(this); } + return this.currentInstance.schedule(queueName, target, method, args, false, stack); + }, - if (options && options[optionName] !== undefined) { - return options[optionName]; - } else if (this.fallback) { - return this.fallback.getOption(fullName, optionName); - } - }, + deferOnce: function(queueName /* , target, method, args */) { + var length = arguments.length; + var method, target, args; - /** - Used only via `injection`. - Provides a specialized form of injection, specifically enabling - all objects of one type to be injected with a reference to another - object. - For example, provided each object of type `controller` needed a `router`. - one would do the following: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('router:main', Router); - registry.register('controller:user', UserController); - registry.register('controller:post', PostController); - registry.typeInjection('controller', 'router', 'router:main'); - let user = container.lookup('controller:user'); - let post = container.lookup('controller:post'); - user.router instanceof Router; //=> true - post.router instanceof Router; //=> true - // both controllers share the same router - user.router === post.router; //=> true - ``` - @private - @method typeInjection - @param {String} type - @param {String} property - @param {String} fullName - */ - typeInjection: function (type, property, fullName) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + if (length === 2) { + method = arguments[1]; + target = null; + } else { + target = arguments[1]; + method = arguments[2]; + } - var fullNameType = fullName.split(':')[0]; - if (fullNameType === type) { - throw new Error('Cannot inject a \'' + fullName + '\' on other ' + type + '(s).'); + if (isString(method)) { + method = target[method]; + } + + var stack = this.DEBUG ? new Error() : undefined; + + if (length > 3) { + args = new Array(length - 3); + for (var i = 3; i < length; i++) { + args[i-3] = arguments[i]; } + } else { + args = undefined; + } - var injections = this._typeInjections[type] || (this._typeInjections[type] = []); + if (!this.currentInstance) { + createAutorun(this); + } + return this.currentInstance.schedule(queueName, target, method, args, true, stack); + }, - injections.push({ - property: property, - fullName: fullName - }); - }, + setTimeout: function() { + var l = arguments.length; + var args = new Array(l); - /** - Defines injection rules. - These rules are used to inject dependencies onto objects when they - are instantiated. - Two forms of injections are possible: - * Injecting one fullName on another fullName - * Injecting one fullName on a type - Example: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('source:main', Source); - registry.register('model:user', User); - registry.register('model:post', Post); - // injecting one fullName on another fullName - // eg. each user model gets a post model - registry.injection('model:user', 'post', 'model:post'); - // injecting one fullName on another type - registry.injection('model', 'source', 'source:main'); - let user = container.lookup('model:user'); - let post = container.lookup('model:post'); - user.source instanceof Source; //=> true - post.source instanceof Source; //=> true - user.post instanceof Post; //=> true - // and both models share the same source - user.source === post.source; //=> true - ``` - @private - @method injection - @param {String} factoryName - @param {String} property - @param {String} injectionName - */ - injection: function (fullName, property, injectionName) { - this.validateFullName(injectionName); - var normalizedInjectionName = this.normalize(injectionName); - - if (fullName.indexOf(':') === -1) { - return this.typeInjection(fullName, property, normalizedInjectionName); - } - - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - var normalizedName = this.normalize(fullName); - - var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); + for (var x = 0; x < l; x++) { + args[x] = arguments[x]; + } - injections.push({ - property: property, - fullName: normalizedInjectionName - }); - }, + var length = args.length, + method, wait, target, + methodOrTarget, methodOrWait, methodOrArgs; - /** - Used only via `factoryInjection`. - Provides a specialized form of injection, specifically enabling - all factory of one type to be injected with a reference to another - object. - For example, provided each factory of type `model` needed a `store`. - one would do the following: - ```javascript - let registry = new Registry(); - registry.register('store:main', SomeStore); - registry.factoryTypeInjection('model', 'store', 'store:main'); - let store = registry.lookup('store:main'); - let UserFactory = registry.lookupFactory('model:user'); - UserFactory.store instanceof SomeStore; //=> true - ``` - @private - @method factoryTypeInjection - @param {String} type - @param {String} property - @param {String} fullName - */ - factoryTypeInjection: function (type, property, fullName) { - var injections = this._factoryTypeInjections[type] || (this._factoryTypeInjections[type] = []); + if (length === 0) { + return; + } else if (length === 1) { + method = args.shift(); + wait = 0; + } else if (length === 2) { + methodOrTarget = args[0]; + methodOrWait = args[1]; - injections.push({ - property: property, - fullName: this.normalize(fullName) - }); - }, + if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { + target = args.shift(); + method = args.shift(); + wait = 0; + } else if (isCoercableNumber(methodOrWait)) { + method = args.shift(); + wait = args.shift(); + } else { + method = args.shift(); + wait = 0; + } + } else { + var last = args[args.length - 1]; - /** - Defines factory injection rules. - Similar to regular injection rules, but are run against factories, via - `Registry#lookupFactory`. - These rules are used to inject objects onto factories when they - are looked up. - Two forms of injections are possible: - * Injecting one fullName on another fullName - * Injecting one fullName on a type - Example: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('store:main', Store); - registry.register('store:secondary', OtherStore); - registry.register('model:user', User); - registry.register('model:post', Post); - // injecting one fullName on another type - registry.factoryInjection('model', 'store', 'store:main'); - // injecting one fullName on another fullName - registry.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); - let UserFactory = container.lookupFactory('model:user'); - let PostFactory = container.lookupFactory('model:post'); - let store = container.lookup('store:main'); - UserFactory.store instanceof Store; //=> true - UserFactory.secondaryStore instanceof OtherStore; //=> false - PostFactory.store instanceof Store; //=> true - PostFactory.secondaryStore instanceof OtherStore; //=> true - // and both models share the same source instance - UserFactory.store === PostFactory.store; //=> true - ``` - @private - @method factoryInjection - @param {String} factoryName - @param {String} property - @param {String} injectionName - */ - factoryInjection: function (fullName, property, injectionName) { - var normalizedName = this.normalize(fullName); - var normalizedInjectionName = this.normalize(injectionName); + if (isCoercableNumber(last)) { + wait = args.pop(); + } else { + wait = 0; + } - this.validateFullName(injectionName); + methodOrTarget = args[0]; + methodOrArgs = args[1]; - if (fullName.indexOf(':') === -1) { - return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); + if (isFunction(methodOrArgs) || (isString(methodOrArgs) && + methodOrTarget !== null && + methodOrArgs in methodOrTarget)) { + target = args.shift(); + method = args.shift(); + } else { + method = args.shift(); } + } - var injections = this._factoryInjections[normalizedName] || (this._factoryInjections[normalizedName] = []); - - injections.push({ - property: property, - fullName: normalizedInjectionName - }); - }, + var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); - /** - @private - @method knownForType - @param {String} type the type to iterate over - */ - knownForType: function (type) { - var fallbackKnown = undefined, - resolverKnown = undefined; + if (isString(method)) { + method = target[method]; + } - var localKnown = _emberUtils.dictionary(null); - var registeredNames = Object.keys(this.registrations); - for (var index = 0; index < registeredNames.length; index++) { - var fullName = registeredNames[index]; - var itemType = fullName.split(':')[0]; + var onError = getOnError(this.options); - if (itemType === type) { - localKnown[fullName] = true; + function fn() { + if (onError) { + try { + method.apply(target, args); + } catch (e) { + onError(e); } + } else { + method.apply(target, args); } + } - if (this.fallback) { - fallbackKnown = this.fallback.knownForType(type); - } - - if (this.resolver && this.resolver.knownForType) { - resolverKnown = this.resolver.knownForType(type); - } - - return _emberUtils.assign({}, fallbackKnown, localKnown, resolverKnown); - }, + return this._setTimeout(fn, executeAt); + }, - validateFullName: function (fullName) { - if (!this.isValidFullName(fullName)) { - throw new TypeError('Invalid Fullname, expected: \'type:name\' got: ' + fullName); - } + _setTimeout: function (fn, executeAt) { + if (this._timers.length === 0) { + this._timers.push(executeAt, fn); + this._installTimerTimeout(); + return fn; + } - return true; - }, + // find position to insert + var i = binarySearch(executeAt, this._timers); - isValidFullName: function (fullName) { - return !!VALID_FULL_NAME_REGEXP.test(fullName); - }, + this._timers.splice(i, 0, executeAt, fn); - validateInjections: function (injections) { - if (!injections) { - return; - } + // we should be the new earliest timer if i == 0 + if (i === 0) { + this._reinstallTimerTimeout(); + } - var fullName = undefined; + return fn; + }, - for (var i = 0; i < injections.length; i++) { - fullName = injections[i].fullName; + throttle: function(target, method /* , args, wait, [immediate] */) { + var backburner = this; + var args = new Array(arguments.length); + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + var immediate = args.pop(); + var wait, throttler, index, timer; - if (!this.has(fullName)) { - throw new Error('Attempting to inject an unknown injection: \'' + fullName + '\''); - } - } - }, + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = true; + } else { + wait = args.pop(); + } - normalizeInjectionsHash: function (hash) { - var injections = []; + wait = parseInt(wait, 10); - for (var key in hash) { - if (hash.hasOwnProperty(key)) { - _emberMetal.assert('Expected a proper full name, given \'' + hash[key] + '\'', this.validateFullName(hash[key])); + index = findThrottler(target, method, this._throttlers); + if (index > -1) { return this._throttlers[index]; } // throttled - injections.push({ - property: key, - fullName: hash[key] - }); - } + timer = this._platform.setTimeout(function() { + if (!immediate) { + backburner.run.apply(backburner, args); } - - return injections; - }, - - getInjections: function (fullName) { - var injections = this._injections[fullName] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getInjections(fullName)); + var index = findThrottler(target, method, backburner._throttlers); + if (index > -1) { + backburner._throttlers.splice(index, 1); } - return injections; - }, + }, wait); - getTypeInjections: function (type) { - var injections = this._typeInjections[type] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getTypeInjections(type)); - } - return injections; - }, + if (immediate) { + this.run.apply(this, args); + } - getFactoryInjections: function (fullName) { - var injections = this._factoryInjections[fullName] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getFactoryInjections(fullName)); - } - return injections; - }, + throttler = [target, method, timer]; - getFactoryTypeInjections: function (type) { - var injections = this._factoryTypeInjections[type] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getFactoryTypeInjections(type)); - } - return injections; - } - }; + this._throttlers.push(throttler); - function deprecateResolverFunction(registry) { - _emberMetal.deprecate('Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.', false, { id: 'ember-application.registry-resolver-as-function', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function' }); - registry.resolver = { - resolve: registry.resolver - }; - } + return throttler; + }, - /** - Given a fullName and a source fullName returns the fully resolved - fullName. Used to allow for local lookup. - - ```javascript - let registry = new Registry(); - - // the twitter factory is added to the module system - registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title - ``` - - @private - @method expandLocalLookup - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {String} fullName - */ - Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) { - if (this.resolver && this.resolver.expandLocalLookup) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - _emberMetal.assert('options.source must be provided to expandLocalLookup', options && options.source); - _emberMetal.assert('options.source must be a proper full name', this.validateFullName(options.source)); + debounce: function(target, method /* , args, wait, [immediate] */) { + var backburner = this; + var args = new Array(arguments.length); + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } - var normalizedFullName = this.normalize(fullName); - var normalizedSource = this.normalize(options.source); + var immediate = args.pop(); + var wait, index, debouncee, timer; - return expandLocalLookup(this, normalizedFullName, normalizedSource); - } else if (this.fallback) { - return this.fallback.expandLocalLookup(fullName, options); + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = false; } else { - return null; + wait = args.pop(); } - }; - function expandLocalLookup(registry, normalizedName, normalizedSource) { - var cache = registry._localLookupCache; - var normalizedNameCache = cache[normalizedName]; + wait = parseInt(wait, 10); + // Remove debouncee + index = findDebouncee(target, method, this._debouncees); - if (!normalizedNameCache) { - normalizedNameCache = cache[normalizedName] = new _emberUtils.EmptyObject(); + if (index > -1) { + debouncee = this._debouncees[index]; + this._debouncees.splice(index, 1); + this._platform.clearTimeout(debouncee[2]); } - var cached = normalizedNameCache[normalizedSource]; + timer = this._platform.setTimeout(function() { + if (!immediate) { + backburner.run.apply(backburner, args); + } + var index = findDebouncee(target, method, backburner._debouncees); + if (index > -1) { + backburner._debouncees.splice(index, 1); + } + }, wait); - if (cached !== undefined) { - return cached; + if (immediate && index === -1) { + backburner.run.apply(backburner, args); } - var expanded = registry.resolver.expandLocalLookup(normalizedName, normalizedSource); + debouncee = [ + target, + method, + timer + ]; - return normalizedNameCache[normalizedSource] = expanded; - } + backburner._debouncees.push(debouncee); - function resolve(registry, normalizedName, options) { - if (options && options.source) { - // when `source` is provided expand normalizedName - // and source into the full normalizedName - normalizedName = registry.expandLocalLookup(normalizedName, options); + return debouncee; + }, - // if expandLocalLookup returns falsey, we do not support local lookup - if (!normalizedName) { - return; - } - } + cancelTimers: function() { + each(this._throttlers, this._boundClearItems); + this._throttlers = []; - var cached = registry._resolveCache[normalizedName]; - if (cached !== undefined) { - return cached; - } - if (registry._failCache[normalizedName]) { - return; - } + each(this._debouncees, this._boundClearItems); + this._debouncees = []; - var resolved = undefined; + this._clearTimerTimeout(); + this._timers = []; - if (registry.resolver) { - resolved = registry.resolver.resolve(normalizedName); + if (this._autorun) { + this._platform.clearTimeout(this._autorun); + this._autorun = null; } + }, - if (resolved === undefined) { - resolved = registry.registrations[normalizedName]; - } + hasTimers: function() { + return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; + }, - if (resolved === undefined) { - registry._failCache[normalizedName] = true; + cancel: function (timer) { + var timerType = typeof timer; + + if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce + return timer.queue.cancel(timer); + } else if (timerType === 'function') { // we're cancelling a setTimeout + for (var i = 0, l = this._timers.length; i < l; i += 2) { + if (this._timers[i + 1] === timer) { + this._timers.splice(i, 2); // remove the two elements + if (i === 0) { + this._reinstallTimerTimeout(); + } + return true; + } + } + } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce + return this._cancelItem(findThrottler, this._throttlers, timer) || + this._cancelItem(findDebouncee, this._debouncees, timer); } else { - registry._resolveCache[normalizedName] = resolved; + return; // timer was null or not a timer } + }, - return resolved; - } + _cancelItem: function(findMethod, array, timer){ + var item, index; - function has(registry, fullName, source) { - return registry.resolve(fullName, { source: source }) !== undefined; - } + if (timer.length < 3) { return false; } - var privateNames = _emberUtils.dictionary(null); - var privateSuffix = '' + Math.random() + Date.now(); + index = findMethod(timer[0], timer[1], array); - function privatize(_ref) { - var fullName = _ref[0]; + if (index > -1) { - var name = privateNames[fullName]; - if (name) { - return name; + item = array[index]; + + if (item[2] === timer[2]) { + array.splice(index, 1); + this._platform.clearTimeout(timer[2]); + return true; + } } - var _fullName$split = fullName.split(':'); + return false; + }, - var type = _fullName$split[0]; - var rawName = _fullName$split[1]; + _runExpiredTimers: function () { + this._timerTimeoutId = undefined; + this.run(this, this._scheduleExpiredTimers); + }, - return privateNames[fullName] = _emberUtils.intern(type + ':' + rawName + '-' + privateSuffix); - } -}); -enifed('dag-map', ['exports'], function (exports) { 'use strict'; + _scheduleExpiredTimers: function () { + var n = Date.now(); + var timers = this._timers; + var i = 0; + var l = timers.length; + for (; i < l; i += 2) { + var executeAt = timers[i]; + var fn = timers[i+1]; + if (executeAt <= n) { + this.schedule(this.options.defaultQueue, null, fn); + } else { + break; + } + } + timers.splice(0, i); + this._installTimerTimeout(); + }, -/** - * A map of key/value pairs with dependencies contraints that can be traversed - * in topological order and is checked for cycles. - * - * @class DAG - * @constructor - */ -var DAG = (function () { - function DAG() { - this._vertices = new Vertices(); - } - /** - * Adds a key/value pair with dependencies on other key/value pairs. - * - * @public - * @method addEdges - * @param {string[]} key The key of the vertex to be added. - * @param {any} value The value of that vertex. - * @param {string[]|string|undefined} before A key or array of keys of the vertices that must - * be visited before this vertex. - * @param {string[]|string|undefined} after An string or array of strings with the keys of the - * vertices that must be after this vertex is visited. - */ - DAG.prototype.add = function (key, value, before, after) { - var vertices = this._vertices; - var v = vertices.add(key); - v.val = value; - if (before) { - if (typeof before === "string") { - vertices.addEdge(v, vertices.add(before)); - } - else { - for (var i = 0; i < before.length; i++) { - vertices.addEdge(v, vertices.add(before[i])); - } - } - } - if (after) { - if (typeof after === "string") { - vertices.addEdge(vertices.add(after), v); - } - else { - for (var i = 0; i < after.length; i++) { - vertices.addEdge(vertices.add(after[i]), v); - } - } - } - }; - /** - * Visits key/value pairs in topological order. - * - * @public - * @method topsort - * @param {Function} fn The function to be invoked with each key/value. - */ - DAG.prototype.topsort = function (callback) { - this._vertices.topsort(callback); - }; - return DAG; -}()); -var Vertices = (function () { - function Vertices() { - this.stack = new IntStack(); - this.result = new IntStack(); - this.vertices = []; + _reinstallTimerTimeout: function () { + this._clearTimerTimeout(); + this._installTimerTimeout(); + }, + + _clearTimerTimeout: function () { + if (!this._timerTimeoutId) { + return; } - Vertices.prototype.add = function (key) { - if (!key) - throw new Error("missing key"); - var vertices = this.vertices; - var i = 0; - var vertex; - for (; i < vertices.length; i++) { - vertex = vertices[i]; - if (vertex.key === key) - return vertex; - } - return vertices[i] = { - id: i, - key: key, - val: null, - inc: null, - out: false, - mark: false - }; - }; - Vertices.prototype.addEdge = function (v, w) { - this.check(v, w.key); - var inc = w.inc; - if (!inc) { - w.inc = [v.id]; - } - else { - var i = 0; - for (; i < inc.length; i++) { - if (inc[i] === v.id) - return; - } - inc[i] = v.id; - } - v.out = true; - }; - Vertices.prototype.topsort = function (cb) { - this.reset(); - var vertices = this.vertices; - for (var i = 0; i < vertices.length; i++) { - var vertex = vertices[i]; - if (vertex.out) - continue; - this.visit(vertex, undefined); - } - this.each(cb); - }; - Vertices.prototype.check = function (v, w) { - if (v.key === w) { - throw new Error("cycle detected: " + w + " <- " + w); - } - var inc = v.inc; - // quick check - if (!inc || inc.length === 0) - return; - var vertices = this.vertices; - // shallow check - for (var i = 0; i < inc.length; i++) { - var key = vertices[inc[i]].key; - if (key === w) { - throw new Error("cycle detected: " + w + " <- " + v.key + " <- " + w); - } - } - // deep check - this.reset(); - this.visit(v, w); - if (this.result.len > 0) { - var msg_1 = "cycle detected: " + w; - this.each(function (key) { - msg_1 += " <- " + key; - }); - throw new Error(msg_1); - } - }; - Vertices.prototype.each = function (cb) { - var _a = this, result = _a.result, vertices = _a.vertices; - for (var i = 0; i < result.len; i++) { - var vertex = vertices[result.stack[i]]; - cb(vertex.key, vertex.val); - } - }; - // reuse between cycle check and topsort - Vertices.prototype.reset = function () { - this.stack.len = 0; - this.result.len = 0; - var vertices = this.vertices; - for (var i = 0; i < vertices.length; i++) { - vertices[i].mark = false; - } - }; - Vertices.prototype.visit = function (start, search) { - var _a = this, stack = _a.stack, result = _a.result, vertices = _a.vertices; - stack.push(start.id); - while (stack.len) { - var index = stack.pop(); - if (index < 0) { - index = ~index; - if (search) { - result.pop(); - } - else { - result.push(index); - } - } - else { - var vertex = vertices[index]; - if (vertex.mark) { - continue; - } - if (search) { - result.push(index); - if (search === vertex.key) { - return; - } - } - vertex.mark = true; - stack.push(~index); - var incoming = vertex.inc; - if (incoming) { - var i = incoming.length; - while (i--) { - index = incoming[i]; - if (!vertices[index].mark) { - stack.push(index); - } - } - } - } - } - }; - return Vertices; -}()); -var IntStack = (function () { - function IntStack() { - this.stack = [0, 0, 0, 0, 0, 0]; - this.len = 0; + this._platform.clearTimeout(this._timerTimeoutId); + this._timerTimeoutId = undefined; + }, + + _installTimerTimeout: function () { + if (!this._timers.length) { + return; } - IntStack.prototype.push = function (n) { - this.stack[this.len++] = n; - }; - IntStack.prototype.pop = function () { - return this.stack[--this.len]; - }; - return IntStack; -}()); + var minExpiresAt = this._timers[0]; + var n = Date.now(); + var wait = Math.max(0, minExpiresAt - n); + this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); + } +}; -exports['default'] = DAG; +Backburner.prototype.schedule = Backburner.prototype.defer; +Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; +Backburner.prototype.later = Backburner.prototype.setTimeout; -Object.defineProperty(exports, '__esModule', { value: true }); +function getOnError(options) { + return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); +} -}); -enifed('ember-application/index', ['exports', 'ember-application/initializers/dom-templates', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/resolver', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (exports, _emberApplicationInitializersDomTemplates, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberApplicationSystemResolver, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent) { - /** - @module ember - @submodule ember-application - */ +function createAutorun(backburner) { + var setTimeout = backburner._platform.setTimeout; + backburner.begin(); + backburner._autorun = setTimeout(function() { + backburner._autorun = null; + backburner.end(); + }, 0); +} - 'use strict'; +function findDebouncee(target, method, debouncees) { + return findItem(target, method, debouncees); +} - exports.Application = _emberApplicationSystemApplication.default; - exports.ApplicationInstance = _emberApplicationSystemApplicationInstance.default; - exports.Resolver = _emberApplicationSystemResolver.default; - exports.Engine = _emberApplicationSystemEngine.default; - exports.EngineInstance = _emberApplicationSystemEngineInstance.default; - exports.getEngineParent = _emberApplicationSystemEngineParent.getEngineParent; - exports.setEngineParent = _emberApplicationSystemEngineParent.setEngineParent; +function findThrottler(target, method, throttlers) { + return findItem(target, method, throttlers); +} - // add domTemplates initializer (only does something if `ember-template-compiler` - // is loaded already) -}); -enifed('ember-application/initializers/dom-templates', ['exports', 'require', 'ember-glimmer', 'ember-environment', 'ember-application/system/application'], function (exports, _require, _emberGlimmer, _emberEnvironment, _emberApplicationSystemApplication) { - 'use strict'; +function findItem(target, method, collection) { + var item; + var index = -1; - var bootstrap = function () {}; + for (var i = 0, l = collection.length; i < l; i++) { + item = collection[i]; + if (item[0] === target && item[1] === method) { + index = i; + break; + } + } - _emberApplicationSystemApplication.default.initializer({ - name: 'domTemplates', - initialize: function () { - var bootstrapModuleId = 'ember-template-compiler/system/bootstrap'; - var context = undefined; - if (_emberEnvironment.environment.hasDOM && _require.has(bootstrapModuleId)) { - bootstrap = _require.default(bootstrapModuleId).default; - context = document; - } + return index; +} - bootstrap({ context: context, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); - } - }); -}); -enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberViews, _emberApplicationSystemEngineInstance) { - /** - @module ember - @submodule ember-application - */ +function clearItems(item) { + this._platform.clearTimeout(item[2]); +} + +exports['default'] = Backburner; + +Object.defineProperty(exports, '__esModule', { value: true }); +}); +enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) { + /* globals Proxy */ 'use strict'; - var BootOptions = undefined; + var _Container$prototype; + + exports.default = Container; + exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations; + + var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE'); + var FACTORY_FOR = _emberUtils.symbol('FACTORY_FOR'); + exports.FACTORY_FOR = FACTORY_FOR; + var LOOKUP_FACTORY = _emberUtils.symbol('LOOKUP_FACTORY'); + exports.LOOKUP_FACTORY = LOOKUP_FACTORY; /** - The `ApplicationInstance` encapsulates all of the stateful aspects of a - running `Application`. - - At a high-level, we break application boot into two distinct phases: - - * Definition time, where all of the classes, templates, and other - dependencies are loaded (typically in the browser). - * Run time, where we begin executing the application once everything - has loaded. + A container used to instantiate and cache objects. - Definition time can be expensive and only needs to happen once since it is - an idempotent operation. For example, between test runs and FastBoot - requests, the application stays the same. It is only the state that we want - to reset. + Every `Container` must be associated with a `Registry`, which is referenced + to determine the factory and options that should be used to instantiate + objects. - That state is what the `ApplicationInstance` manages: it is responsible for - creating the container that contains all application state, and disposing of - it once the particular test run or FastBoot request has finished. + The public API for `Container` is still in flux and should not be considered + stable. - @public - @class Ember.ApplicationInstance - @extends Ember.EngineInstance - */ + @private + @class Container + */ - var ApplicationInstance = _emberApplicationSystemEngineInstance.default.extend({ + function Container(registry, options) { + this.registry = registry; + this.owner = options && options.owner ? options.owner : null; + this.cache = _emberUtils.dictionary(options && options.cache ? options.cache : null); + this.factoryCache = _emberUtils.dictionary(options && options.factoryCache ? options.factoryCache : null); + this.validationCache = _emberUtils.dictionary(options && options.validationCache ? options.validationCache : null); + this._fakeContainerToInject = buildFakeContainerWithDeprecations(this); + this[CONTAINER_OVERRIDE] = undefined; + this.isDestroyed = false; + } + + Container.prototype = (_Container$prototype = { /** - The `Application` for which this is an instance. - @property {Ember.Application} application - @private - */ - application: null, + @private + @property owner + @type Object + */ + owner: null, /** - The DOM events for which the event dispatcher should listen. - By default, the application's `Ember.EventDispatcher` listens - for a set of standard DOM events, such as `mousedown` and - `keyup`, and delegates them to your application's `Ember.View` - instances. - @private - @property {Object} customEvents - */ - customEvents: null, + @private + @property registry + @type Registry + @since 1.11.0 + */ + registry: null, /** - The root DOM element of the Application as an element or a - [jQuery-compatible selector - string](http://api.jquery.com/category/selectors/). - @private - @property {String|DOMElement} rootElement - */ - rootElement: null, + @private + @property cache + @type InheritingDict + */ + cache: null, - init: function () { - this._super.apply(this, arguments); + /** + @private + @property factoryCache + @type InheritingDict + */ + factoryCache: null, - // Register this instance in the per-instance registry. - // - // Why do we need to register the instance in the first place? - // Because we need a good way for the root route (a.k.a ApplicationRoute) - // to notify us when it has created the root-most view. That view is then - // appended to the rootElement, in the case of apps, to the fixture harness - // in tests, or rendered to a string in the case of FastBoot. - this.register('-application-instance:main', this, { instantiate: false }); + /** + @private + @property validationCache + @type InheritingDict + */ + validationCache: null, + + /** + Given a fullName return a corresponding instance. + The default behaviour is for lookup to return a singleton instance. + The singleton is scoped to the container, allowing multiple containers + to all have their own locally scoped singletons. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter'); + twitter instanceof Twitter; // => true + // by default the container will return singletons + let twitter2 = container.lookup('api:twitter'); + twitter2 instanceof Twitter; // => true + twitter === twitter2; //=> true + ``` + If singletons are not wanted, an optional flag can be provided at lookup. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter', { singleton: false }); + let twitter2 = container.lookup('api:twitter', { singleton: false }); + twitter === twitter2; //=> false + ``` + @private + @method lookup + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + lookup: function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); + return lookup(this, this.registry.normalize(fullName), options); }, /** - Overrides the base `EngineInstance._bootSync` method with concerns relevant - to booting application (instead of engine) instances. - This method should only contain synchronous boot concerns. Asynchronous - boot concerns should eventually be moved to the `boot` method, which - returns a promise. - Until all boot code has been made asynchronous, we need to continue to - expose this method for use *internally* in places where we need to boot an - instance synchronously. - @private - */ - _bootSync: function (options) { - if (this._booted) { - return this; - } + Given a fullName, return the corresponding factory. + @private + @method lookupFactory + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + lookupFactory: function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); - options = new BootOptions(options); + _emberMetal.deprecate('Using "_lookupFactory" is deprecated. Please use container.factoryFor instead.', !true, { id: 'container-lookupFactory', until: '2.13.0', url: 'TODO' }); - this.setupRegistry(options); + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + } - if (options.rootElement) { - this.rootElement = options.rootElement; - } else { - this.rootElement = this.application.rootElement; - } + }, _Container$prototype[LOOKUP_FACTORY] = function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + }, _Container$prototype[FACTORY_FOR] = function (fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (options.location) { - var router = _emberMetal.get(this, 'router'); - _emberMetal.set(router, 'location', options.location); + if (_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + if (true) { + return this.factoryFor(fullName, options); + } else { + /* This throws in case of a poorly designed build */ + throw new Error('If ember-no-double-extend is enabled, ember-factory-for must also be enabled'); } + } + var factory = this[LOOKUP_FACTORY](fullName, options); + if (factory === undefined) { + return; + } + var manager = new DeprecatedFactoryManager(this, factory, fullName); - this.application.runInstanceInitializers(this); + _emberMetal.runInDebug(function () { + manager = wrapManagerInDeprecationProxy(manager); + }); - if (options.isInteractive) { - this.setupEventDispatcher(); + return manager; + }, _Container$prototype.destroy = function () { + eachDestroyable(this, function (item) { + if (item.destroy) { + item.destroy(); } + }); - this._booted = true; - - return this; - }, + this.isDestroyed = true; + }, _Container$prototype.reset = function (fullName) { + if (arguments.length > 0) { + resetMember(this, this.registry.normalize(fullName)); + } else { + resetCache(this); + } + }, _Container$prototype.ownerInjection = function () { + var _ref; - setupRegistry: function (options) { - this.constructor.setupRegistry(this.__registry__, options); - }, + return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; + }, _Container$prototype); - router: _emberMetal.computed(function () { - return this.lookup('router:main'); - }).readOnly(), + /* + * Wrap a factory manager in a proxy which will not permit properties to be + * set on the manager. + */ + function wrapManagerInDeprecationProxy(manager) { + if (_emberUtils.HAS_NATIVE_PROXY) { + var _ret = (function () { + var validator = { + get: function (obj, prop) { + if (prop !== 'class' && prop !== 'create') { + throw new Error('You attempted to access "' + prop + '" on a factory manager created by container#factoryFor. "' + prop + '" is not a member of a factory manager."'); + } - /** - This hook is called by the root-most Route (a.k.a. the ApplicationRoute) - when it has finished creating the root View. By default, we simply take the - view and append it to the `rootElement` specified on the Application. - In cases like FastBoot and testing, we can override this hook and implement - custom behavior, such as serializing to a string and sending over an HTTP - socket rather than appending to DOM. - @param view {Ember.View} the root-most view - @private - */ - didCreateRootView: function (view) { - view.appendTo(this.rootElement); - }, - - /** - Tells the router to start routing. The router will ask the location for the - current URL of the page to determine the initial URL to start routing to. - To start the app at a specific URL, call `handleURL` instead. - @private - */ - startRouting: function () { - var router = _emberMetal.get(this, 'router'); - router.startRouting(); - this._didSetupRouter = true; - }, + return obj[prop]; + }, + set: function (obj, prop, value) { + throw new Error('You attempted to set "' + prop + '" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.'); + } + }; - /** - @private - Sets up the router, initializing the child router and configuring the - location before routing begins. - Because setup should only occur once, multiple calls to `setupRouter` - beyond the first call have no effect. - */ - setupRouter: function () { - if (this._didSetupRouter) { - return; - } - this._didSetupRouter = true; + // Note: + // We have to proxy access to the manager here so that private property + // access doesn't cause the above errors to occur. + var m = manager; + var proxiedManager = { + class: m.class, + create: function (props) { + return m.create(props); + } + }; - var router = _emberMetal.get(this, 'router'); - router.setupRouter(); - }, + return { + v: new Proxy(proxiedManager, validator) + }; + })(); - /** - Directs the router to route to a particular URL. This is useful in tests, - for example, to tell the app to start at a particular URL. - @param url {String} the URL the router should route to - @private - */ - handleURL: function (url) { - var router = _emberMetal.get(this, 'router'); + if (typeof _ret === 'object') return _ret.v; + } - this.setupRouter(); - return router.handleURL(url); - }, + return manager; + } + if (true) { /** - @private - */ - setupEventDispatcher: function () { - var dispatcher = this.lookup('event_dispatcher:main'); - var applicationCustomEvents = _emberMetal.get(this.application, 'customEvents'); - var instanceCustomEvents = _emberMetal.get(this, 'customEvents'); + Given a fullName, return the corresponding factory. The consumer of the factory + is responsible for the destruction of any factory instances, as there is no + way for the container to ensure instances are destroyed when it itself is + destroyed. + @public + @method factoryFor + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + Container.prototype.factoryFor = function _factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var customEvents = _emberUtils.assign({}, applicationCustomEvents, instanceCustomEvents); - dispatcher.setup(customEvents, this.rootElement); + var normalizedName = this.registry.normalize(fullName); + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(normalizedName)); - return dispatcher; - }, + if (options.source) { + normalizedName = this.registry.expandLocalLookup(fullName, options); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!normalizedName) { + return; + } + } - /** - Returns the current URL of the app instance. This is useful when your - app does not update the browsers URL bar (i.e. it uses the `'none'` - location adapter). - @public - @return {String} the current URL - */ - getURL: function () { - var router = _emberMetal.get(this, 'router'); - return _emberMetal.get(router, 'url'); - }, + var factory = this.registry.resolve(normalizedName); - // `instance.visit(url)` should eventually replace `instance.handleURL()`; - // the test helpers can probably be switched to use this implementation too + if (factory === undefined) { + return; + } - /** - Navigate the instance to a particular URL. This is useful in tests, for - example, or to tell the app to start at a particular URL. This method - returns a promise that resolves with the app instance when the transition - is complete, or rejects if the transion was aborted due to an error. - @public - @param url {String} the destination URL - @return {Promise} - */ - visit: function (url) { - var _this = this; + var manager = new FactoryManager(this, factory, fullName, normalizedName); - this.setupRouter(); + _emberMetal.runInDebug(function () { + manager = wrapManagerInDeprecationProxy(manager); + }); - var bootOptions = this.__container__.lookup('-environment:main'); + return manager; + }; + } - var router = _emberMetal.get(this, 'router'); + function isSingleton(container, fullName) { + return container.registry.getOption(fullName, 'singleton') !== false; + } - var handleTransitionResolve = function () { - if (!bootOptions.options.shouldRender) { - // No rendering is needed, and routing has completed, simply return. - return _this; - } else { - return new _emberRuntime.RSVP.Promise(function (resolve) { - // Resolve once rendering is completed. `router.handleURL` returns the transition (as a thennable) - // which resolves once the transition is completed, but the transition completion only queues up - // a scheduled revalidation (into the `render` queue) in the Renderer. - // - // This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed. - _emberMetal.run.schedule('afterRender', null, resolve, _this); - }); - } - }; + function shouldInstantiate(container, fullName) { + return container.registry.getOption(fullName, 'instantiate') !== false; + } - var handleTransitionReject = function (error) { - if (error.error) { - throw error.error; - } else if (error.name === 'TransitionAborted' && router.router.activeTransition) { - return router.router.activeTransition.then(handleTransitionResolve, handleTransitionReject); - } else if (error.name === 'TransitionAborted') { - throw new Error(error.message); - } else { - throw error; - } - }; + function lookup(container, fullName) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - var location = _emberMetal.get(router, 'location'); + if (options.source) { + fullName = container.registry.expandLocalLookup(fullName, options); - // Keeps the location adapter's internal URL in-sync - location.setURL(url); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!fullName) { + return; + } + } - // getURL returns the set url with the rootURL stripped off - return router.handleURL(location.getURL()).then(handleTransitionResolve, handleTransitionReject); + if (container.cache[fullName] !== undefined && options.singleton !== false) { + return container.cache[fullName]; } - }); - ApplicationInstance.reopenClass({ - /** - @private - @method setupRegistry - @param {Registry} registry - @param {BootOptions} options - */ - setupRegistry: function (registry) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + if (true) { + return instantiateFactory(container, fullName, options); + } else { + var factory = deprecatedFactoryFor(container, fullName); + var value = instantiate(factory, {}, container, fullName); - if (!options.toEnvironment) { - options = new BootOptions(options); + if (value === undefined) { + return; } - registry.register('-environment:main', options.toEnvironment(), { instantiate: false }); - registry.register('service:-document', options.document, { instantiate: false }); + if (isSingleton(container, fullName) && options.singleton !== false) { + container.cache[fullName] = value; + } - this._super(registry, options); + return value; } - }); + } - /** - A list of boot-time configuration options for customizing the behavior of - an `Ember.ApplicationInstance`. - - This is an interface class that exists purely to document the available - options; you do not need to construct it manually. Simply pass a regular - JavaScript object containing the desired options into methods that require - one of these options object: - - ```javascript - MyApp.visit("/", { location: "none", rootElement: "#container" }); - ``` - - Not all combinations of the supported options are valid. See the documentation - on `Ember.Application#visit` for the supported configurations. - - Internal, experimental or otherwise unstable flags are marked as private. - - @class BootOptions - @namespace Ember.ApplicationInstance - @public - */ - BootOptions = function BootOptions() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + function isSingletonClass(container, fullName, _ref2) { + var instantiate = _ref2.instantiate; + var singleton = _ref2.singleton; - /** - Provide a specific instance of jQuery. This is useful in conjunction with - the `document` option, as it allows you to use a copy of `jQuery` that is - appropriately bound to the foreign `document` (e.g. a jsdom). - This is highly experimental and support very incomplete at the moment. - @property jQuery - @type Object - @default auto-detected - @private - */ - this.jQuery = _emberViews.jQuery; // This default is overridable below + return singleton !== false && isSingleton(container, fullName) && !instantiate && !shouldInstantiate(container, fullName); + } - /** - Interactive mode: whether we need to set up event delegation and invoke - lifecycle callbacks on Components. - @property isInteractive - @type boolean - @default auto-detected - @private - */ - this.isInteractive = _emberEnvironment.environment.hasDOM; // This default is overridable below + function isSingletonInstance(container, fullName, _ref3) { + var instantiate = _ref3.instantiate; + var singleton = _ref3.singleton; - /** - Run in a full browser environment. - When this flag is set to `false`, it will disable most browser-specific - and interactive features. Specifically: - * It does not use `jQuery` to append the root view; the `rootElement` - (either specified as a subsequent option or on the application itself) - must already be an `Element` in the given `document` (as opposed to a - string selector). - * It does not set up an `EventDispatcher`. - * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). - * It sets the `location` option to `"none"`. (If you would like to use - the location adapter specified in the app's router instead, you can also - specify `{ location: null }` to specifically opt-out.) - @property isBrowser - @type boolean - @default auto-detected - @public - */ - if (options.isBrowser !== undefined) { - this.isBrowser = !!options.isBrowser; - } else { - this.isBrowser = _emberEnvironment.environment.hasDOM; - } + return singleton !== false && isSingleton(container, fullName) && instantiate !== false && shouldInstantiate(container, fullName); + } - if (!this.isBrowser) { - this.jQuery = null; - this.isInteractive = false; - this.location = 'none'; - } + function isFactoryClass(container, fullname, _ref4) { + var instantiate = _ref4.instantiate; + var singleton = _ref4.singleton; - /** - Disable rendering completely. - When this flag is set to `true`, it will disable the entire rendering - pipeline. Essentially, this puts the app into "routing-only" mode. No - templates will be rendered, and no Components will be created. - @property shouldRender - @type boolean - @default true - @public - */ - if (options.shouldRender !== undefined) { - this.shouldRender = !!options.shouldRender; - } else { - this.shouldRender = true; + return (singleton === false || !isSingleton(container, fullname)) && instantiate === false && !shouldInstantiate(container, fullname); + } + + function isFactoryInstance(container, fullName, _ref5) { + var instantiate = _ref5.instantiate; + var singleton = _ref5.singleton; + + return (singleton !== false || isSingleton(container, fullName)) && instantiate !== false && shouldInstantiate(container, fullName); + } + + function instantiateFactory(container, fullName, options) { + var factoryManager = container[FACTORY_FOR](fullName); + + if (factoryManager === undefined) { + return; } - if (!this.shouldRender) { - this.jQuery = null; - this.isInteractive = false; + // SomeClass { singleton: true, instantiate: true } | { singleton: true } | { instantiate: true } | {} + // By default majority of objects fall into this case + if (isSingletonInstance(container, fullName, options)) { + return container.cache[fullName] = factoryManager.create(); } - /** - If present, render into the given `Document` object instead of the - global `window.document` object. - In practice, this is only useful in non-browser environment or in - non-interactive mode, because Ember's `jQuery` dependency is - implicitly bound to the current document, causing event delegation - to not work properly when the app is rendered into a foreign - document object (such as an iframe's `contentDocument`). - In non-browser mode, this could be a "`Document`-like" object as - Ember only interact with a small subset of the DOM API in non- - interactive mode. While the exact requirements have not yet been - formalized, the `SimpleDOM` library's implementation is known to - work. - @property document - @type Document - @default the global `document` object - @public - */ - if (options.document) { - this.document = options.document; - } else { - this.document = typeof document !== 'undefined' ? document : null; + // SomeClass { singleton: false, instantiate: true } + if (isFactoryInstance(container, fullName, options)) { + return factoryManager.create(); } - /** - If present, overrides the application's `rootElement` property on - the instance. This is useful for testing environment, where you - might want to append the root view to a fixture area. - In non-browser mode, because Ember does not have access to jQuery, - this options must be specified as a DOM `Element` object instead of - a selector string. - See the documentation on `Ember.Applications`'s `rootElement` for - details. - @property rootElement - @type String|Element - @default null - @public - */ - if (options.rootElement) { - this.rootElement = options.rootElement; + // SomeClass { singleton: true, instantiate: false } | { instantiate: false } | { singleton: false, instantiation: false } + if (isSingletonClass(container, fullName, options) || isFactoryClass(container, fullName, options)) { + return factoryManager.class; } - // Set these options last to give the user a chance to override the - // defaults from the "combo" options like `isBrowser` (although in - // practice, the resulting combination is probably invalid) + throw new Error('Could not create factory'); + } - /** - If present, overrides the router's `location` property with this - value. This is useful for environments where trying to modify the - URL would be inappropriate. - @property location - @type string - @default null - @public - */ - if (options.location !== undefined) { - this.location = options.location; + function markInjectionsAsDynamic(injections) { + injections._dynamic = true; + } + + function areInjectionsDynamic(injections) { + return !!injections._dynamic; + } + + function buildInjections() /* container, ...injections */{ + var _arguments = arguments; + + var hash = {}; + + if (arguments.length > 1) { + (function () { + var container = _arguments[0]; + var injections = []; + var injection = undefined; + + for (var i = 1; i < _arguments.length; i++) { + if (_arguments[i]) { + injections = injections.concat(_arguments[i]); + } + } + + _emberMetal.runInDebug(function () { + container.registry.validateInjections(injections); + }); + + for (var i = 0; i < injections.length; i++) { + injection = injections[i]; + hash[injection.property] = lookup(container, injection.fullName); + if (!isSingleton(container, injection.fullName)) { + markInjectionsAsDynamic(hash); + } + } + })(); } - if (options.jQuery !== undefined) { - this.jQuery = options.jQuery; + return hash; + } + + function deprecatedFactoryFor(container, fullName) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + + var registry = container.registry; + + if (options.source) { + fullName = registry.expandLocalLookup(fullName, options); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!fullName) { + return; + } } - if (options.isInteractive !== undefined) { - this.isInteractive = !!options.isInteractive; + var cache = container.factoryCache; + if (cache[fullName]) { + return cache[fullName]; + } + var factory = registry.resolve(fullName); + if (factory === undefined) { + return; } - }; - BootOptions.prototype.toEnvironment = function () { - var env = _emberUtils.assign({}, _emberEnvironment.environment); - // For compatibility with existing code - env.hasDOM = this.isBrowser; - env.isInteractive = this.isInteractive; - env.options = this; - return env; - }; + var type = fullName.split(':')[0]; + if (!factory || typeof factory.extend !== 'function' || !_emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS && type === 'model') { + if (factory && typeof factory._onLookup === 'function') { + factory._onLookup(fullName); + } - Object.defineProperty(ApplicationInstance.prototype, 'container', { - configurable: true, - enumerable: false, - get: function () { - var instance = this; - return { - lookup: function () { - _emberMetal.deprecate('Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead.', false, { - id: 'ember-application.app-instance-container', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container' - }); - return instance.lookup.apply(instance, arguments); - } - }; + // TODO: think about a 'safe' merge style extension + // for now just fallback to create time injection + cache[fullName] = factory; + return factory; + } else { + var injections = injectionsFor(container, fullName); + var factoryInjections = factoryInjectionsFor(container, fullName); + var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); + + factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); + + var injectedFactory = factory.extend(injections); + + // TODO - remove all `container` injections when Ember reaches v3.0.0 + injectDeprecatedContainer(injectedFactory.prototype, container); + injectedFactory.reopenClass(factoryInjections); + + if (factory && typeof factory._onLookup === 'function') { + factory._onLookup(fullName); + } + + if (cacheable) { + cache[fullName] = injectedFactory; + } + + return injectedFactory; } - }); + } - Object.defineProperty(ApplicationInstance.prototype, 'registry', { - configurable: true, - enumerable: false, - get: function () { - return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'ApplicationInstance'); + function injectionsFor(container, fullName) { + var registry = container.registry; + var splitName = fullName.split(':'); + var type = splitName[0]; + + var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); + injections._debugContainerKey = fullName; + + _emberUtils.setOwner(injections, container.owner); + + return injections; + } + + function instantiate(factory, props, container, fullName) { + var lazyInjections = undefined, + validationCache = undefined; + + props = props || {}; + + if (container.registry.getOption(fullName, 'instantiate') === false) { + return factory; } - }); - exports.default = ApplicationInstance; -}); -enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application/system/application-instance', 'container', 'ember-application/system/engine', 'ember-glimmer'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRuntime, _emberViews, _emberRouting, _emberApplicationSystemApplicationInstance, _container, _emberApplicationSystemEngine, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + if (factory) { + if (typeof factory.create !== 'function') { + throw new Error('Failed to create an instance of \'' + fullName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); + } - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + validationCache = container.validationCache; - var librariesRegistered = false; + _emberMetal.runInDebug(function () { + // Ensure that all lazy injections are valid at instantiation time + if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') { + lazyInjections = factory._lazyInjections(); + lazyInjections = container.registry.normalizeInjectionsHash(lazyInjections); - /** - An instance of `Ember.Application` is the starting point for every Ember - application. It helps to instantiate, initialize and coordinate the many - objects that make up your app. - - Each Ember app has one and only one `Ember.Application` object. In fact, the - very first thing you should do in your application is create the instance: - - ```javascript - window.App = Ember.Application.create(); - ``` - - Typically, the application object is the only global variable. All other - classes in your app should be properties on the `Ember.Application` instance, - which highlights its first role: a global namespace. - - For example, if you define a view class, it might look like this: - - ```javascript - App.MyView = Ember.View.extend(); - ``` - - By default, calling `Ember.Application.create()` will automatically initialize - your application by calling the `Ember.Application.initialize()` method. If - you need to delay initialization, you can call your app's `deferReadiness()` - method. When you are ready for your app to be initialized, call its - `advanceReadiness()` method. - - You can define a `ready` method on the `Ember.Application` instance, which - will be run by Ember when the application is initialized. - - Because `Ember.Application` inherits from `Ember.Namespace`, any classes - you create will have useful string representations when calling `toString()`. - See the `Ember.Namespace` documentation for more information. - - While you can think of your `Ember.Application` as a container that holds the - other classes in your application, there are several other responsibilities - going on under-the-hood that you may want to understand. - - ### Event Delegation - - Ember uses a technique called _event delegation_. This allows the framework - to set up a global, shared event listener instead of requiring each view to - do it manually. For example, instead of each view registering its own - `mousedown` listener on its associated element, Ember sets up a `mousedown` - listener on the `body`. - - If a `mousedown` event occurs, Ember will look at the target of the event and - start walking up the DOM node tree, finding corresponding views and invoking - their `mouseDown` method as it goes. - - `Ember.Application` has a number of default events that it listens for, as - well as a mapping from lowercase events to camel-cased view method names. For - example, the `keypress` event causes the `keyPress` method on the view to be - called, the `dblclick` event causes `doubleClick` to be called, and so on. - - If there is a bubbling browser event that Ember does not listen for by - default, you can specify custom events and their corresponding view method - names by setting the application's `customEvents` property: - - ```javascript - let App = Ember.Application.create({ - customEvents: { - // add support for the paste event - paste: 'paste' + container.registry.validateInjections(lazyInjections); + } + }); + + validationCache[fullName] = true; + + var obj = undefined; + + if (typeof factory.extend === 'function') { + // assume the factory was extendable and is already injected + obj = factory.create(props); + } else { + // assume the factory was extendable + // to create time injections + // TODO: support new'ing for instantiation and merge injections for pure JS Functions + var injections = injectionsFor(container, fullName); + + // Ensure that a container is available to an object during instantiation. + // TODO - remove when Ember reaches v3.0.0 + // This "fake" container will be replaced after instantiation with a + // property that raises deprecations every time it is accessed. + injections.container = container._fakeContainerToInject; + obj = factory.create(_emberUtils.assign({}, injections, props)); + + // TODO - remove when Ember reaches v3.0.0 + if (!Object.isFrozen(obj) && 'container' in obj) { + injectDeprecatedContainer(obj, container); + } } - }); - ``` - - To prevent Ember from setting up a listener for a default event, - specify the event name with a `null` value in the `customEvents` - property: - - ```javascript - let App = Ember.Application.create({ - customEvents: { - // prevent listeners for mouseenter/mouseleave events - mouseenter: null, - mouseleave: null + + return obj; + } + } + + function factoryInjectionsFor(container, fullName) { + var registry = container.registry; + var splitName = fullName.split(':'); + var type = splitName[0]; + + var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); + factoryInjections._debugContainerKey = fullName; + + return factoryInjections; + } + + // TODO - remove when Ember reaches v3.0.0 + function injectDeprecatedContainer(object, container) { + Object.defineProperty(object, 'container', { + configurable: true, + enumerable: false, + get: function () { + _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + return this[CONTAINER_OVERRIDE] || container; + }, + + set: function (value) { + _emberMetal.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + + this[CONTAINER_OVERRIDE] = value; + + return value; } }); - ``` - - By default, the application sets up these event listeners on the document - body. However, in cases where you are embedding an Ember application inside - an existing page, you may want it to set up the listeners on an element - inside the body. - - For example, if only events inside a DOM element with the ID of `ember-app` - should be delegated, set your application's `rootElement` property: - - ```javascript - let App = Ember.Application.create({ - rootElement: '#ember-app' - }); - ``` - - The `rootElement` can be either a DOM element or a jQuery-compatible selector - string. Note that *views appended to the DOM outside the root element will - not receive events.* If you specify a custom root element, make sure you only - append views inside it! - - To learn more about the events Ember components use, see - [components/handling-events](https://guides.emberjs.com/v2.6.0/components/handling-events/#toc_event-names). - - ### Initializers - - Libraries on top of Ember can add initializers, like so: - - ```javascript - Ember.Application.initializer({ - name: 'api-adapter', - - initialize: function(application) { - application.register('api-adapter:main', ApiAdapter); + } + + function eachDestroyable(container, callback) { + var cache = container.cache; + var keys = Object.keys(cache); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = cache[key]; + + if (container.registry.getOption(key, 'instantiate') !== false) { + callback(value); + } + } + } + + function resetCache(container) { + eachDestroyable(container, function (value) { + if (value.destroy) { + value.destroy(); } }); - ``` - - Initializers provide an opportunity to access the internal registry, which - organizes the different components of an Ember application. Additionally - they provide a chance to access the instantiated application. Beyond - being used for libraries, initializers are also a great way to organize - dependency injection or setup in your own application. - - ### Routing - - In addition to creating your application's router, `Ember.Application` is - also responsible for telling the router when to start routing. Transitions - between routes can be logged with the `LOG_TRANSITIONS` flag, and more - detailed intra-transition logging can be logged with - the `LOG_TRANSITIONS_INTERNAL` flag: - - ```javascript - let App = Ember.Application.create({ - LOG_TRANSITIONS: true, // basic logging of successful transitions - LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps - }); - ``` - - By default, the router will begin trying to translate the current URL into - application state once the browser emits the `DOMContentReady` event. If you - need to defer routing, you can call the application's `deferReadiness()` - method. Once routing can begin, call the `advanceReadiness()` method. - - If there is any setup required before routing begins, you can implement a - `ready()` method on your app that will be invoked immediately before routing - begins. - - @class Application - @namespace Ember - @extends Ember.Engine - @uses RegistryProxyMixin - @public - */ - var Application = _emberApplicationSystemEngine.default.extend({ - _suppressDeferredDeprecation: true, + container.cache.dict = _emberUtils.dictionary(null); + } - /** - The root DOM element of the Application. This can be specified as an - element or a - [jQuery-compatible selector string](http://api.jquery.com/category/selectors/). - This is the element that will be passed to the Application's, - `eventDispatcher`, which sets up the listeners for event delegation. Every - view in your application should be a child of the element you specify here. - @property rootElement - @type DOMElement - @default 'body' - @public - */ - rootElement: 'body', + function resetMember(container, fullName) { + var member = container.cache[fullName]; - /** - The `Ember.EventDispatcher` responsible for delegating events to this - application's views. - The event dispatcher is created by the application at initialization time - and sets up event listeners on the DOM element described by the - application's `rootElement` property. - See the documentation for `Ember.EventDispatcher` for more information. - @property eventDispatcher - @type Ember.EventDispatcher - @default null - @public - */ - eventDispatcher: null, + delete container.factoryCache[fullName]; - /** - The DOM events for which the event dispatcher should listen. - By default, the application's `Ember.EventDispatcher` listens - for a set of standard DOM events, such as `mousedown` and - `keyup`, and delegates them to your application's `Ember.View` - instances. - If you would like additional bubbling events to be delegated to your - views, set your `Ember.Application`'s `customEvents` property - to a hash containing the DOM event name as the key and the - corresponding view method name as the value. Setting an event to - a value of `null` will prevent a default event listener from being - added for that event. - To add new events to be listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - // add support for the paste event - paste: 'paste' - } - }); - ``` - To prevent default events from being listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - // remove support for mouseenter / mouseleave events - mouseenter: null, - mouseleave: null - } - }); - ``` - @property customEvents - @type Object - @default null - @public - */ - customEvents: null, + if (member) { + delete container.cache[fullName]; - /** - Whether the application should automatically start routing and render - templates to the `rootElement` on DOM ready. While default by true, - other environments such as FastBoot or a testing harness can set this - property to `false` and control the precise timing and behavior of the boot - process. - @property autoboot - @type Boolean - @default true - @private - */ - autoboot: true, + if (member.destroy) { + member.destroy(); + } + } + } - /** - Whether the application should be configured for the legacy "globals mode". - Under this mode, the Application object serves as a global namespace for all - classes. - ```javascript - let App = Ember.Application.create({ - ... - }); - App.Router.reopen({ - location: 'none' - }); - App.Router.map({ - ... - }); - App.MyComponent = Ember.Component.extend({ - ... + function buildFakeContainerWithDeprecations(container) { + var fakeContainer = {}; + var propertyMappings = { + lookup: 'lookup', + lookupFactory: '_lookupFactory' + }; + + for (var containerProperty in propertyMappings) { + fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]); + } + + return fakeContainer; + } + + function buildFakeContainerFunction(container, containerProperty, ownerProperty) { + return function () { + _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `' + ownerProperty + '` instead.', false, { + id: 'ember-application.injected-container', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); - ``` - This flag also exposes other internal APIs that assumes the existence of - a special "default instance", like `App.__container__.lookup(...)`. - This option is currently not configurable, its value is derived from - the `autoboot` flag – disabling `autoboot` also implies opting-out of - globals mode support, although they are ultimately orthogonal concerns. - Some of the global modes features are already deprecated in 1.x. The - existence of this flag is to untangle the globals mode code paths from - the autoboot code paths, so that these legacy features can be reviewed - for deprecation/removal separately. - Forcing the (autoboot=true, _globalsMode=false) here and running the tests - would reveal all the places where we are still relying on these legacy - behavior internally (mostly just tests). - @property _globalsMode - @type Boolean - @default true - @private - */ - _globalsMode: true, + return container[containerProperty].apply(container, arguments); + }; + } - init: function (options) { - this._super.apply(this, arguments); + var DeprecatedFactoryManager = (function () { + function DeprecatedFactoryManager(container, factory, fullName) { + babelHelpers.classCallCheck(this, DeprecatedFactoryManager); - if (!this.$) { - this.$ = _emberViews.jQuery; - } + this.container = container; + this.class = factory; + this.fullName = fullName; + } - registerLibraries(); - logLibraryVersions(); + DeprecatedFactoryManager.prototype.create = function create() { + var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - // Start off the number of deferrals at 1. This will be decremented by - // the Application's own `boot` method. - this._readinessDeferrals = 1; - this._booted = false; + return instantiate(this.class, props, this.container, this.fullName); + }; - this.autoboot = this._globalsMode = !!this.autoboot; + return DeprecatedFactoryManager; + })(); - if (this._globalsMode) { - this._prepareForGlobalsMode(); - } + var FactoryManager = (function () { + function FactoryManager(container, factory, fullName, normalizedName) { + babelHelpers.classCallCheck(this, FactoryManager); - if (this.autoboot) { - this.waitForDOMReady(); - } - }, + this.container = container; + this.class = factory; + this.fullName = fullName; + this.normalizedName = normalizedName; + } + + FactoryManager.prototype.create = function create() { + var _this = this; - /** - Create an ApplicationInstance for this application. - @private - @method buildInstance - @return {Ember.ApplicationInstance} the application instance - */ - buildInstance: function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - options.base = this; - options.application = this; - return _emberApplicationSystemApplicationInstance.default.create(options); - }, + var injections = injectionsFor(this.container, this.normalizedName); + var props = _emberUtils.assign({}, injections, options); - /** - Enable the legacy globals mode by allowing this application to act - as a global namespace. See the docs on the `_globalsMode` property - for details. - Most of these features are already deprecated in 1.x, so we can - stop using them internally and try to remove them. - @private - @method _prepareForGlobalsMode - */ - _prepareForGlobalsMode: function () { - // Create subclass of Ember.Router for this Application instance. - // This is to ensure that someone reopening `App.Router` does not - // tamper with the default `Ember.Router`. - this.Router = (this.Router || _emberRouting.Router).extend(); + props[_emberUtils.NAME_KEY] = this.container.registry.makeToString(this.class, this.fullName); - this._buildDeprecatedInstance(); - }, + _emberMetal.runInDebug(function () { + var lazyInjections = undefined; + var validationCache = _this.container.validationCache; + // Ensure that all lazy injections are valid at instantiation time + if (!validationCache[_this.fullName] && _this.class && typeof _this.class._lazyInjections === 'function') { + lazyInjections = _this.class._lazyInjections(); + lazyInjections = _this.container.registry.normalizeInjectionsHash(lazyInjections); - /* - Build the deprecated instance for legacy globals mode support. - Called when creating and resetting the application. - This is orthogonal to autoboot: the deprecated instance needs to - be created at Application construction (not boot) time to expose - App.__container__. If autoboot sees that this instance exists, - it will continue booting it to avoid doing unncessary work (as - opposed to building a new instance at boot time), but they are - otherwise unrelated. - @private - @method _buildDeprecatedInstance - */ - _buildDeprecatedInstance: function () { - // Build a default instance - var instance = this.buildInstance(); + _this.container.registry.validateInjections(lazyInjections); + } - // Legacy support for App.__container__ and other global methods - // on App that rely on a single, default instance. - this.__deprecatedInstance__ = instance; - this.__container__ = instance.__container__; - }, + validationCache[_this.fullName] = true; + }); - /** - Automatically kick-off the boot process for the application once the - DOM has become ready. - The initialization itself is scheduled on the actions queue which - ensures that code-loading finishes before booting. - If you are asynchronously loading code, you should call `deferReadiness()` - to defer booting, and then call `advanceReadiness()` once all of your code - has finished loading. - @private - @method waitForDOMReady - */ - waitForDOMReady: function () { - if (!this.$ || this.$.isReady) { - _emberMetal.run.schedule('actions', this, 'domReady'); - } else { - this.$().ready(_emberMetal.run.bind(this, 'domReady')); + if (!this.class.create) { + throw new Error('Failed to create an instance of \'' + this.normalizedName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); } - }, - /** - This is the autoboot flow: - 1. Boot the app by calling `this.boot()` - 2. Create an instance (or use the `__deprecatedInstance__` in globals mode) - 3. Boot the instance by calling `instance.boot()` - 4. Invoke the `App.ready()` callback - 5. Kick-off routing on the instance - Ideally, this is all we would need to do: - ```javascript - _autoBoot() { - this.boot().then(() => { - let instance = (this._globalsMode) ? this.__deprecatedInstance__ : this.buildInstance(); - return instance.boot(); - }).then((instance) => { - App.ready(); - instance.startRouting(); - }); - } - ``` - Unfortunately, we cannot actually write this because we need to participate - in the "synchronous" boot process. While the code above would work fine on - the initial boot (i.e. DOM ready), when `App.reset()` is called, we need to - boot a new instance synchronously (see the documentation on `_bootSync()` - for details). - Because of this restriction, the actual logic of this method is located - inside `didBecomeReady()`. - @private - @method domReady - */ - domReady: function () { - if (this.isDestroyed) { - return; + if (this.class.prototype) { + injectDeprecatedContainer(this.class.prototype, this.container); } - this._bootSync(); + return this.class.create(props); + }; - // Continues to `didBecomeReady` - }, + return FactoryManager; + })(); +}); - /** - Use this to defer readiness until some condition is true. - Example: - ```javascript - let App = Ember.Application.create(); - App.deferReadiness(); - // Ember.$ is a reference to the jQuery object/function - Ember.$.getJSON('/auth-token', function(token) { - App.token = token; - App.advanceReadiness(); - }); - ``` - This allows you to perform asynchronous setup logic and defer - booting your application until the setup has finished. - However, if the setup requires a loading UI, it might be better - to use the router for this purpose. - @method deferReadiness - @public - */ - deferReadiness: function () { - _emberMetal.assert('You must call deferReadiness on an instance of Ember.Application', this instanceof Application); - _emberMetal.assert('You cannot defer readiness since the `ready()` hook has already been called.', this._readinessDeferrals > 0); - this._readinessDeferrals++; - }, +/* + * This internal version of factoryFor swaps between the public API for + * factoryFor (class is the registered class) and a transition implementation + * (class is the double-extended class). It is *not* the public API version + * of factoryFor, which always returns the registered class. + */ - /** - Call `advanceReadiness` after any asynchronous setup logic has completed. - Each call to `deferReadiness` must be matched by a call to `advanceReadiness` - or the application will never become ready and routing will not begin. - @method advanceReadiness - @see {Ember.Application#deferReadiness} - @public - */ - advanceReadiness: function () { - _emberMetal.assert('You must call advanceReadiness on an instance of Ember.Application', this instanceof Application); - this._readinessDeferrals--; +/** + A depth first traversal, destroying the container, its descendant containers and all + their managed objects. + @private + @method destroy + */ - if (this._readinessDeferrals === 0) { - _emberMetal.run.once(this, this.didBecomeReady); +/** + Clear either the entire cache or just the cache for a particular key. + @private + @method reset + @param {String} fullName optional key to reset; if missing, resets everything + */ + +/** + Returns an object that can be used to provide an owner to a + manually created instance. + @private + @method ownerInjection + @returns { Object } +*/ +enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) { + /* + Public API for the container is still in flux. + The public API, specified on the application namespace should be considered the stable API. + // @module container + @private + */ + + 'use strict'; + + exports.Registry = _containerRegistry.default; + exports.privatize = _containerRegistry.privatize; + exports.Container = _containerContainer.default; + exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations; + exports.FACTORY_FOR = _containerContainer.FACTORY_FOR; + exports.LOOKUP_FACTORY = _containerContainer.LOOKUP_FACTORY; +}); +enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) { + 'use strict'; + + exports.default = Registry; + exports.privatize = privatize; + + var VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/; + + /** + A registry used to store factory and option information keyed + by type. + + A `Registry` stores the factory and option information needed by a + `Container` to instantiate and cache objects. + + The API for `Registry` is still in flux and should not be considered stable. + + @private + @class Registry + @since 1.11.0 + */ + + function Registry(options) { + this.fallback = options && options.fallback ? options.fallback : null; + + if (options && options.resolver) { + this.resolver = options.resolver; + + if (typeof this.resolver === 'function') { + deprecateResolverFunction(this); } - }, + } + + this.registrations = _emberUtils.dictionary(options && options.registrations ? options.registrations : null); + + this._typeInjections = _emberUtils.dictionary(null); + this._injections = _emberUtils.dictionary(null); + this._factoryTypeInjections = _emberUtils.dictionary(null); + this._factoryInjections = _emberUtils.dictionary(null); + + this._localLookupCache = new _emberUtils.EmptyObject(); + this._normalizeCache = _emberUtils.dictionary(null); + this._resolveCache = _emberUtils.dictionary(null); + this._failCache = _emberUtils.dictionary(null); + + this._options = _emberUtils.dictionary(null); + this._typeOptions = _emberUtils.dictionary(null); + } + Registry.prototype = { /** - Initialize the application and return a promise that resolves with the `Ember.Application` - object when the boot process is complete. - Run any application initializers and run the application load hook. These hooks may - choose to defer readiness. For example, an authentication hook might want to defer - readiness until the auth token has been retrieved. - By default, this method is called automatically on "DOM ready"; however, if autoboot - is disabled, this is automatically called when the first application instance is - created via `visit`. - @private - @method boot - @return {Promise} - */ - boot: function () { - if (this._bootPromise) { - return this._bootPromise; - } + A backup registry for resolving registrations when no matches can be found. + @private + @property fallback + @type Registry + */ + fallback: null, - try { - this._bootSync(); - } catch (_) { - // Ignore th error: in the asynchronous boot path, the error is already reflected - // in the promise rejection - } + /** + An object that has a `resolve` method that resolves a name. + @private + @property resolver + @type Resolver + */ + resolver: null, - return this._bootPromise; - }, + /** + @private + @property registrations + @type InheritingDict + */ + registrations: null, /** - Unfortunately, a lot of existing code assumes the booting process is - "synchronous". Specifically, a lot of tests assumes the last call to - `app.advanceReadiness()` or `app.reset()` will result in the app being - fully-booted when the current runloop completes. - We would like new code (like the `visit` API) to stop making this assumption, - so we created the asynchronous version above that returns a promise. But until - we have migrated all the code, we would have to expose this method for use - *internally* in places where we need to boot an app "synchronously". - @private - */ - _bootSync: function () { - if (this._booted) { - return; - } + @private + @property _typeInjections + @type InheritingDict + */ + _typeInjections: null, - // Even though this returns synchronously, we still need to make sure the - // boot promise exists for book-keeping purposes: if anything went wrong in - // the boot process, we need to store the error as a rejection on the boot - // promise so that a future caller of `boot()` can tell what failed. - var defer = this._bootResolver = new _emberRuntime.RSVP.defer(); - this._bootPromise = defer.promise; + /** + @private + @property _injections + @type InheritingDict + */ + _injections: null, - try { - this.runInitializers(); - _emberRuntime.runLoadHooks('application', this); - this.advanceReadiness(); - // Continues to `didBecomeReady` - } catch (error) { - // For the asynchronous boot path - defer.reject(error); + /** + @private + @property _factoryTypeInjections + @type InheritingDict + */ + _factoryTypeInjections: null, - // For the synchronous boot path - throw error; - } - }, + /** + @private + @property _factoryInjections + @type InheritingDict + */ + _factoryInjections: null, /** - Reset the application. This is typically used only in tests. It cleans up - the application in the following order: - 1. Deactivate existing routes - 2. Destroy all objects in the container - 3. Create a new application container - 4. Re-route to the existing url - Typical Example: - ```javascript - let App; - run(function() { - App = Ember.Application.create(); - }); - module('acceptance test', { - setup: function() { - App.reset(); - } - }); - test('first test', function() { - // App is freshly reset - }); - test('second test', function() { - // App is again freshly reset - }); - ``` - Advanced Example: - Occasionally you may want to prevent the app from initializing during - setup. This could enable extra configuration, or enable asserting prior - to the app becoming ready. - ```javascript - let App; - run(function() { - App = Ember.Application.create(); - }); - module('acceptance test', { - setup: function() { - run(function() { - App.reset(); - App.deferReadiness(); - }); - } - }); - test('first test', function() { - ok(true, 'something before app is initialized'); - run(function() { - App.advanceReadiness(); - }); - ok(true, 'something after app is initialized'); - }); - ``` - @method reset - @public - */ - reset: function () { - _emberMetal.assert('Calling reset() on instances of `Ember.Application` is not\n supported when globals mode is disabled; call `visit()` to\n create new `Ember.ApplicationInstance`s and dispose them\n via their `destroy()` method instead.', this._globalsMode && this.autoboot); + @private + @property _normalizeCache + @type InheritingDict + */ + _normalizeCache: null, - var instance = this.__deprecatedInstance__; + /** + @private + @property _resolveCache + @type InheritingDict + */ + _resolveCache: null, - this._readinessDeferrals = 1; - this._bootPromise = null; - this._bootResolver = null; - this._booted = false; + /** + @private + @property _options + @type InheritingDict + */ + _options: null, - function handleReset() { - _emberMetal.run(instance, 'destroy'); - this._buildDeprecatedInstance(); - _emberMetal.run.schedule('actions', this, '_bootSync'); - } + /** + @private + @property _typeOptions + @type InheritingDict + */ + _typeOptions: null, - _emberMetal.run.join(this, handleReset); + /** + Creates a container based on this registry. + @private + @method container + @param {Object} options + @return {Container} created container + */ + container: function (options) { + return new _containerContainer.default(this, options); }, /** + Registers a factory for later injection. + Example: + ```javascript + let registry = new Registry(); + registry.register('model:user', Person, {singleton: false }); + registry.register('fruit:favorite', Orange); + registry.register('communication:main', Email, {singleton: false}); + ``` @private - @method didBecomeReady - */ - didBecomeReady: function () { - try { - // TODO: Is this still needed for _globalsMode = false? - if (!_emberMetal.isTesting()) { - // Eagerly name all classes that are already loaded - _emberRuntime.Namespace.processAll(); - _emberRuntime.setNamespaceSearchDisabled(true); - } + @method register + @param {String} fullName + @param {Function} factory + @param {Object} options + */ + register: function (fullName, factory) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - // See documentation on `_autoboot()` for details - if (this.autoboot) { - var instance = undefined; + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - if (this._globalsMode) { - // If we already have the __deprecatedInstance__ lying around, boot it to - // avoid unnecessary work - instance = this.__deprecatedInstance__; - } else { - // Otherwise, build an instance and boot it. This is currently unreachable, - // because we forced _globalsMode to === autoboot; but having this branch - // allows us to locally toggle that flag for weeding out legacy globals mode - // dependencies independently - instance = this.buildInstance(); - } + if (factory === undefined) { + throw new TypeError('Attempting to register an unknown factory: \'' + fullName + '\''); + } - instance._bootSync(); + var normalizedName = this.normalize(fullName); - // TODO: App.ready() is not called when autoboot is disabled, is this correct? - this.ready(); + if (this._resolveCache[normalizedName]) { + throw new Error('Cannot re-register: \'' + fullName + '\', as it has already been resolved.'); + } - instance.startRouting(); - } + delete this._failCache[normalizedName]; + this.registrations[normalizedName] = factory; + this._options[normalizedName] = options; + }, - // For the asynchronous boot path - this._bootResolver.resolve(this); + /** + Unregister a fullName + ```javascript + let registry = new Registry(); + registry.register('model:user', User); + registry.resolve('model:user').create() instanceof User //=> true + registry.unregister('model:user') + registry.resolve('model:user') === undefined //=> true + ``` + @private + @method unregister + @param {String} fullName + */ + unregister: function (fullName) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - // For the synchronous boot path - this._booted = true; - } catch (error) { - // For the asynchronous boot path - this._bootResolver.reject(error); + var normalizedName = this.normalize(fullName); - // For the synchronous boot path - throw error; + this._localLookupCache = new _emberUtils.EmptyObject(); + + delete this.registrations[normalizedName]; + delete this._resolveCache[normalizedName]; + delete this._failCache[normalizedName]; + delete this._options[normalizedName]; + }, + + /** + Given a fullName return the corresponding factory. + By default `resolve` will retrieve the factory from + the registry. + ```javascript + let registry = new Registry(); + registry.register('api:twitter', Twitter); + registry.resolve('api:twitter') // => Twitter + ``` + Optionally the registry can be provided with a custom resolver. + If provided, `resolve` will first provide the custom resolver + the opportunity to resolve the fullName, otherwise it will fallback + to the registry. + ```javascript + let registry = new Registry(); + registry.resolver = function(fullName) { + // lookup via the module system of choice + }; + // the twitter factory is added to the module system + registry.resolve('api:twitter') // => Twitter + ``` + @private + @method resolve + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {Function} fullName's factory + */ + resolve: function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + var factory = resolve(this, this.normalize(fullName), options); + if (factory === undefined && this.fallback) { + var _fallback; + + factory = (_fallback = this.fallback).resolve.apply(_fallback, arguments); } + return factory; }, /** - Called when the Application has become ready, immediately before routing - begins. The call will be delayed until the DOM has become ready. - @event ready - @public - */ - ready: function () { - return this; + A hook that can be used to describe how the resolver will + attempt to find the factory. + For example, the default Ember `.describe` returns the full + class name (including namespace) where Ember's resolver expects + to find the `fullName`. + @private + @method describe + @param {String} fullName + @return {string} described fullName + */ + describe: function (fullName) { + if (this.resolver && this.resolver.lookupDescription) { + return this.resolver.lookupDescription(fullName); + } else if (this.fallback) { + return this.fallback.describe(fullName); + } else { + return fullName; + } }, - // This method must be moved to the application instance object - willDestroy: function () { - this._super.apply(this, arguments); - _emberRuntime.setNamespaceSearchDisabled(false); - this._booted = false; - this._bootPromise = null; - this._bootResolver = null; + /** + A hook to enable custom fullName normalization behaviour + @private + @method normalizeFullName + @param {String} fullName + @return {string} normalized fullName + */ + normalizeFullName: function (fullName) { + if (this.resolver && this.resolver.normalize) { + return this.resolver.normalize(fullName); + } else if (this.fallback) { + return this.fallback.normalizeFullName(fullName); + } else { + return fullName; + } + }, - if (_emberRuntime._loaded.application === this) { - _emberRuntime._loaded.application = undefined; + /** + Normalize a fullName based on the application's conventions + @private + @method normalize + @param {String} fullName + @return {string} normalized fullName + */ + normalize: function (fullName) { + return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName)); + }, + + /** + @method makeToString + @private + @param {any} factory + @param {string} fullName + @return {function} toString function + */ + makeToString: function (factory, fullName) { + if (this.resolver && this.resolver.makeToString) { + return this.resolver.makeToString(factory, fullName); + } else if (this.fallback) { + return this.fallback.makeToString(factory, fullName); + } else { + return factory.toString(); } + }, - if (this._globalsMode && this.__deprecatedInstance__) { - this.__deprecatedInstance__.destroy(); + /** + Given a fullName check if the container is aware of its factory + or singleton instance. + @private + @method has + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {Boolean} + */ + has: function (fullName, options) { + if (!this.isValidFullName(fullName)) { + return false; } + + var source = options && options.source && this.normalize(options.source); + + return has(this, this.normalize(fullName), source); }, /** - Boot a new instance of `Ember.ApplicationInstance` for the current - application and navigate it to the given `url`. Returns a `Promise` that - resolves with the instance when the initial routing and rendering is - complete, or rejects with any error that occured during the boot process. - When `autoboot` is disabled, calling `visit` would first cause the - application to boot, which runs the application initializers. - This method also takes a hash of boot-time configuration options for - customizing the instance's behavior. See the documentation on - `Ember.ApplicationInstance.BootOptions` for details. - `Ember.ApplicationInstance.BootOptions` is an interface class that exists - purely to document the available options; you do not need to construct it - manually. Simply pass a regular JavaScript object containing of the - desired options: - ```javascript - MyApp.visit("/", { location: "none", rootElement: "#container" }); - ``` - ### Supported Scenarios - While the `BootOptions` class exposes a large number of knobs, not all - combinations of them are valid; certain incompatible combinations might - result in unexpected behavior. - For example, booting the instance in the full browser environment - while specifying a foriegn `document` object (e.g. `{ isBrowser: true, - document: iframe.contentDocument }`) does not work correctly today, - largely due to Ember's jQuery dependency. - Currently, there are three officially supported scenarios/configurations. - Usages outside of these scenarios are not guaranteed to work, but please - feel free to file bug reports documenting your experience and any issues - you encountered to help expand support. - #### Browser Applications (Manual Boot) - The setup is largely similar to how Ember works out-of-the-box. Normally, - Ember will boot a default instance for your Application on "DOM ready". - However, you can customize this behavior by disabling `autoboot`. - For example, this allows you to render a miniture demo of your application - into a specific area on your marketing website: - ```javascript - import MyApp from 'my-app'; - $(function() { - let App = MyApp.create({ autoboot: false }); - let options = { - // Override the router's location adapter to prevent it from updating - // the URL in the address bar - location: 'none', - // Override the default `rootElement` on the app to render into a - // specific `div` on the page - rootElement: '#demo' - }; - // Start the app at the special demo URL - App.visit('/demo', options); - }); - ```` - Or perhaps you might want to boot two instances of your app on the same - page for a split-screen multiplayer experience: - ```javascript - import MyApp from 'my-app'; - $(function() { - let App = MyApp.create({ autoboot: false }); - let sessionId = MyApp.generateSessionID(); - let player1 = App.visit(`/matches/join?name=Player+1&session=${sessionId}`, { rootElement: '#left', location: 'none' }); - let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#right', location: 'none' }); - Promise.all([player1, player2]).then(() => { - // Both apps have completed the initial render - $('#loading').fadeOut(); - }); - }); - ``` - Do note that each app instance maintains their own registry/container, so - they will run in complete isolation by default. - #### Server-Side Rendering (also known as FastBoot) - This setup allows you to run your Ember app in a server environment using - Node.js and render its content into static HTML for SEO purposes. - ```javascript - const HTMLSerializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); - function renderURL(url) { - let dom = new SimpleDOM.Document(); - let rootElement = dom.body; - let options = { isBrowser: false, document: dom, rootElement: rootElement }; - return MyApp.visit(options).then(instance => { - try { - return HTMLSerializer.serialize(rootElement.firstChild); - } finally { - instance.destroy(); - } - }); - } - ``` - In this scenario, because Ember does not have access to a global `document` - object in the Node.js environment, you must provide one explicitly. In practice, - in the non-browser environment, the stand-in `document` object only need to - implement a limited subset of the full DOM API. The `SimpleDOM` library is known - to work. - Since there is no access to jQuery in the non-browser environment, you must also - specify a DOM `Element` object in the same `document` for the `rootElement` option - (as opposed to a selector string like `"body"`). - See the documentation on the `isBrowser`, `document` and `rootElement` properties - on `Ember.ApplicationInstance.BootOptions` for details. - #### Server-Side Resource Discovery - This setup allows you to run the routing layer of your Ember app in a server - environment using Node.js and completely disable rendering. This allows you - to simulate and discover the resources (i.e. AJAX requests) needed to fufill - a given request and eagerly "push" these resources to the client. - ```app/initializers/network-service.js - import BrowserNetworkService from 'app/services/network/browser'; - import NodeNetworkService from 'app/services/network/node'; - // Inject a (hypothetical) service for abstracting all AJAX calls and use - // the appropiate implementaion on the client/server. This also allows the - // server to log all the AJAX calls made during a particular request and use - // that for resource-discovery purpose. - export function initialize(application) { - if (window) { // browser - application.register('service:network', BrowserNetworkService); - } else { // node - application.register('service:network', NodeNetworkService); - } - application.inject('route', 'network', 'service:network'); - }; - export default { - name: 'network-service', - initialize: initialize - }; - ``` - ```app/routes/post.js - import Ember from 'ember'; - // An example of how the (hypothetical) service is used in routes. - export default Ember.Route.extend({ - model(params) { - return this.network.fetch(`/api/posts/${params.post_id}.json`); - }, - afterModel(post) { - if (post.isExternalContent) { - return this.network.fetch(`/api/external/?url=${post.externalURL}`); - } else { - return post; - } - } - }); - ``` - ```javascript - // Finally, put all the pieces together - function discoverResourcesFor(url) { - return MyApp.visit(url, { isBrowser: false, shouldRender: false }).then(instance => { - let networkService = instance.lookup('service:network'); - return networkService.requests; // => { "/api/posts/123.json": "..." } - }); - } - ``` - @public - @method visit - @param url {String} The initial URL to navigate to - @param options {Ember.ApplicationInstance.BootOptions} - @return {Promise} - */ - visit: function (url, options) { - var _this = this; - - return this.boot().then(function () { - var instance = _this.buildInstance(); - - return instance.boot(options).then(function () { - return instance.visit(url); - }).catch(function (error) { - _emberMetal.run(instance, 'destroy'); - throw error; - }); - }); - } - }); + Allow registering options for all factories of a type. + ```javascript + let registry = new Registry(); + let container = registry.container(); + // if all of type `connection` must not be singletons + registry.optionsForType('connection', { singleton: false }); + registry.register('connection:twitter', TwitterConnection); + registry.register('connection:facebook', FacebookConnection); + let twitter = container.lookup('connection:twitter'); + let twitter2 = container.lookup('connection:twitter'); + twitter === twitter2; // => false + let facebook = container.lookup('connection:facebook'); + let facebook2 = container.lookup('connection:facebook'); + facebook === facebook2; // => false + ``` + @private + @method optionsForType + @param {String} type + @param {Object} options + */ + optionsForType: function (type, options) { + this._typeOptions[type] = options; + }, - Object.defineProperty(Application.prototype, 'registry', { - configurable: true, - enumerable: false, - get: function () { - return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'Application'); - } - }); + getOptionsForType: function (type) { + var optionsForType = this._typeOptions[type]; + if (optionsForType === undefined && this.fallback) { + optionsForType = this.fallback.getOptionsForType(type); + } + return optionsForType; + }, - Application.reopenClass({ /** - This creates a registry with the default Ember naming conventions. - It also configures the registry: - * registered views are created every time they are looked up (they are - not singletons) - * registered templates are not factories; the registered value is - returned directly. - * the router receives the application as its `namespace` property - * all controllers receive the router as their `target` and `controllers` - properties - * all controllers receive the application as their `namespace` property - * the application view receives the application controller as its - `controller` property - * the application view receives the application template as its - `defaultTemplate` property - @method buildRegistry - @static - @param {Ember.Application} namespace the application for which to - build the registry - @return {Ember.Registry} the built registry - @private - */ - buildRegistry: function (application) { + @private + @method options + @param {String} fullName + @param {Object} options + */ + options: function (fullName) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var registry = this._super.apply(this, arguments); - - commonSetupRegistry(registry); - - _emberGlimmer.setupApplicationRegistry(registry); + var normalizedName = this.normalize(fullName); + this._options[normalizedName] = options; + }, - return registry; - } - }); + getOptions: function (fullName) { + var normalizedName = this.normalize(fullName); + var options = this._options[normalizedName]; - function commonSetupRegistry(registry) { - registry.register('-view-registry:main', { create: function () { - return _emberUtils.dictionary(null); - } }); + if (options === undefined && this.fallback) { + options = this.fallback.getOptions(fullName); + } + return options; + }, - registry.register('route:basic', _emberRouting.Route); - registry.register('event_dispatcher:main', _emberViews.EventDispatcher); + getOption: function (fullName, optionName) { + var options = this._options[fullName]; - registry.injection('router:main', 'namespace', 'application:main'); + if (options && options[optionName] !== undefined) { + return options[optionName]; + } - registry.register('location:auto', _emberRouting.AutoLocation); - registry.register('location:hash', _emberRouting.HashLocation); - registry.register('location:history', _emberRouting.HistoryLocation); - registry.register('location:none', _emberRouting.NoneLocation); + var type = fullName.split(':')[0]; + options = this._typeOptions[type]; - registry.register(_container.privatize(_templateObject), _emberRouting.BucketCache); - } + if (options && options[optionName] !== undefined) { + return options[optionName]; + } else if (this.fallback) { + return this.fallback.getOption(fullName, optionName); + } + }, - function registerLibraries() { - if (!librariesRegistered) { - librariesRegistered = true; + /** + Used only via `injection`. + Provides a specialized form of injection, specifically enabling + all objects of one type to be injected with a reference to another + object. + For example, provided each object of type `controller` needed a `router`. + one would do the following: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('router:main', Router); + registry.register('controller:user', UserController); + registry.register('controller:post', PostController); + registry.typeInjection('controller', 'router', 'router:main'); + let user = container.lookup('controller:user'); + let post = container.lookup('controller:post'); + user.router instanceof Router; //=> true + post.router instanceof Router; //=> true + // both controllers share the same router + user.router === post.router; //=> true + ``` + @private + @method typeInjection + @param {String} type + @param {String} property + @param {String} fullName + */ + typeInjection: function (type, property, fullName) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - if (_emberEnvironment.environment.hasDOM && typeof _emberViews.jQuery === 'function') { - _emberMetal.libraries.registerCoreLibrary('jQuery', _emberViews.jQuery().jquery); + var fullNameType = fullName.split(':')[0]; + if (fullNameType === type) { + throw new Error('Cannot inject a \'' + fullName + '\' on other ' + type + '(s).'); } - } - } - function logLibraryVersions() { - if (_emberEnvironment.ENV.LOG_VERSION) { - // we only need to see this once per Application#init - _emberEnvironment.ENV.LOG_VERSION = false; - var libs = _emberMetal.libraries._registry; + var injections = this._typeInjections[type] || (this._typeInjections[type] = []); - var nameLengths = libs.map(function (item) { - return _emberMetal.get(item, 'name.length'); + injections.push({ + property: property, + fullName: fullName }); + }, - var maxNameLength = Math.max.apply(this, nameLengths); + /** + Defines injection rules. + These rules are used to inject dependencies onto objects when they + are instantiated. + Two forms of injections are possible: + * Injecting one fullName on another fullName + * Injecting one fullName on a type + Example: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('source:main', Source); + registry.register('model:user', User); + registry.register('model:post', Post); + // injecting one fullName on another fullName + // eg. each user model gets a post model + registry.injection('model:user', 'post', 'model:post'); + // injecting one fullName on another type + registry.injection('model', 'source', 'source:main'); + let user = container.lookup('model:user'); + let post = container.lookup('model:post'); + user.source instanceof Source; //=> true + post.source instanceof Source; //=> true + user.post instanceof Post; //=> true + // and both models share the same source + user.source === post.source; //=> true + ``` + @private + @method injection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + injection: function (fullName, property, injectionName) { + this.validateFullName(injectionName); + var normalizedInjectionName = this.normalize(injectionName); - _emberMetal.debug('-------------------------------'); - for (var i = 0; i < libs.length; i++) { - var lib = libs[i]; - var spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); - _emberMetal.debug([lib.name, spaces, ' : ', lib.version].join('')); + if (fullName.indexOf(':') === -1) { + return this.typeInjection(fullName, property, normalizedInjectionName); } - _emberMetal.debug('-------------------------------'); - } - } - - exports.default = Application; -}); -enifed('ember-application/system/engine-instance', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'container', 'ember-application/system/engine-parent'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _container, _emberApplicationSystemEngineParent) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + var normalizedName = this.normalize(fullName); - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); - /** - The `EngineInstance` encapsulates all of the stateful aspects of a - running `Engine`. - - @public - @class Ember.EngineInstance - @extends Ember.Object - @uses RegistryProxyMixin - @uses ContainerProxyMixin - */ + injections.push({ + property: property, + fullName: normalizedInjectionName + }); + }, - var EngineInstance = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, { /** - The base `Engine` for which this is an instance. - @property {Ember.Engine} engine + Used only via `factoryInjection`. + Provides a specialized form of injection, specifically enabling + all factory of one type to be injected with a reference to another + object. + For example, provided each factory of type `model` needed a `store`. + one would do the following: + ```javascript + let registry = new Registry(); + registry.register('store:main', SomeStore); + registry.factoryTypeInjection('model', 'store', 'store:main'); + let store = registry.lookup('store:main'); + let UserFactory = registry.lookupFactory('model:user'); + UserFactory.store instanceof SomeStore; //=> true + ``` @private - */ - base: null, + @method factoryTypeInjection + @param {String} type + @param {String} property + @param {String} fullName + */ + factoryTypeInjection: function (type, property, fullName) { + var injections = this._factoryTypeInjections[type] || (this._factoryTypeInjections[type] = []); - init: function () { - this._super.apply(this, arguments); + injections.push({ + property: property, + fullName: this.normalize(fullName) + }); + }, - _emberUtils.guidFor(this); + /** + Defines factory injection rules. + Similar to regular injection rules, but are run against factories, via + `Registry#lookupFactory`. + These rules are used to inject objects onto factories when they + are looked up. + Two forms of injections are possible: + * Injecting one fullName on another fullName + * Injecting one fullName on a type + Example: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('store:main', Store); + registry.register('store:secondary', OtherStore); + registry.register('model:user', User); + registry.register('model:post', Post); + // injecting one fullName on another type + registry.factoryInjection('model', 'store', 'store:main'); + // injecting one fullName on another fullName + registry.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); + let UserFactory = container.lookupFactory('model:user'); + let PostFactory = container.lookupFactory('model:post'); + let store = container.lookup('store:main'); + UserFactory.store instanceof Store; //=> true + UserFactory.secondaryStore instanceof OtherStore; //=> false + PostFactory.store instanceof Store; //=> true + PostFactory.secondaryStore instanceof OtherStore; //=> true + // and both models share the same source instance + UserFactory.store === PostFactory.store; //=> true + ``` + @private + @method factoryInjection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + factoryInjection: function (fullName, property, injectionName) { + var normalizedName = this.normalize(fullName); + var normalizedInjectionName = this.normalize(injectionName); - var base = this.base; + this.validateFullName(injectionName); - if (!base) { - base = this.application; - this.base = base; + if (fullName.indexOf(':') === -1) { + return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); } - // Create a per-instance registry that will use the application's registry - // as a fallback for resolving registrations. - var registry = this.__registry__ = new _container.Registry({ - fallback: base.__registry__ - }); - - // Create a per-instance container from the instance's registry - this.__container__ = registry.container({ owner: this }); + var injections = this._factoryInjections[normalizedName] || (this._factoryInjections[normalizedName] = []); - this._booted = false; + injections.push({ + property: property, + fullName: normalizedInjectionName + }); }, /** - Initialize the `Ember.EngineInstance` and return a promise that resolves - with the instance itself when the boot process is complete. - The primary task here is to run any registered instance initializers. - See the documentation on `BootOptions` for the options it takes. - @private - @method boot - @param options {Object} - @return {Promise} + @private + @method knownForType + @param {String} type the type to iterate over */ - boot: function (options) { - var _this = this; + knownForType: function (type) { + var fallbackKnown = undefined, + resolverKnown = undefined; - if (this._bootPromise) { - return this._bootPromise; + var localKnown = _emberUtils.dictionary(null); + var registeredNames = Object.keys(this.registrations); + for (var index = 0; index < registeredNames.length; index++) { + var fullName = registeredNames[index]; + var itemType = fullName.split(':')[0]; + + if (itemType === type) { + localKnown[fullName] = true; + } } - this._bootPromise = new _emberRuntime.RSVP.Promise(function (resolve) { - return resolve(_this._bootSync(options)); - }); + if (this.fallback) { + fallbackKnown = this.fallback.knownForType(type); + } - return this._bootPromise; + if (this.resolver && this.resolver.knownForType) { + resolverKnown = this.resolver.knownForType(type); + } + + return _emberUtils.assign({}, fallbackKnown, localKnown, resolverKnown); }, - /** - Unfortunately, a lot of existing code assumes booting an instance is - synchronous – specifically, a lot of tests assume the last call to - `app.advanceReadiness()` or `app.reset()` will result in a new instance - being fully-booted when the current runloop completes. - We would like new code (like the `visit` API) to stop making this - assumption, so we created the asynchronous version above that returns a - promise. But until we have migrated all the code, we would have to expose - this method for use *internally* in places where we need to boot an instance - synchronously. - @private - */ - _bootSync: function (options) { - if (this._booted) { - return this; + validateFullName: function (fullName) { + if (!this.isValidFullName(fullName)) { + throw new TypeError('Invalid Fullname, expected: \'type:name\' got: ' + fullName); } - _emberMetal.assert('An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.', _emberApplicationSystemEngineParent.getEngineParent(this)); - - this.cloneParentDependencies(); - - this.setupRegistry(options); - - this.base.runInstanceInitializers(this); - - this._booted = true; - - return this; - }, - - setupRegistry: function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? this.__container__.lookup('-environment:main') : arguments[0]; - - this.constructor.setupRegistry(this.__registry__, options); - }, - - /** - Unregister a factory. - Overrides `RegistryProxy#unregister` in order to clear any cached instances - of the unregistered factory. - @public - @method unregister - @param {String} fullName - */ - unregister: function (fullName) { - this.__container__.reset(fullName); - this._super.apply(this, arguments); + return true; }, - /** - @private - */ - willDestroy: function () { - this._super.apply(this, arguments); - _emberMetal.run(this.__container__, 'destroy'); + isValidFullName: function (fullName) { + return !!VALID_FULL_NAME_REGEXP.test(fullName); }, - /** - Build a new `Ember.EngineInstance` that's a child of this instance. - Engines must be registered by name with their parent engine - (or application). - @private - @method buildChildEngineInstance - @param name {String} the registered name of the engine. - @param options {Object} options provided to the engine instance. - @return {Ember.EngineInstance,Error} - */ - buildChildEngineInstance: function (name) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - var Engine = this.lookup('engine:' + name); - - if (!Engine) { - throw new _emberMetal.Error('You attempted to mount the engine \'' + name + '\', but it is not registered with its parent.'); + validateInjections: function (injections) { + if (!injections) { + return; } - var engineInstance = Engine.buildInstance(options); + var fullName = undefined; - _emberApplicationSystemEngineParent.setEngineParent(engineInstance, this); + for (var i = 0; i < injections.length; i++) { + fullName = injections[i].fullName; - return engineInstance; + _emberMetal.assert('Attempting to inject an unknown injection: \'' + fullName + '\'', this.has(fullName)); + } }, - /** - Clone dependencies shared between an engine instance and its parent. - @private - @method cloneParentDependencies - */ - cloneParentDependencies: function () { - var _this2 = this; - - var parent = _emberApplicationSystemEngineParent.getEngineParent(this); - - var registrations = ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment']; - - registrations.forEach(function (key) { - return _this2.register(key, parent.resolveRegistration(key)); - }); + normalizeInjectionsHash: function (hash) { + var injections = []; - var env = parent.lookup('-environment:main'); - this.register('-environment:main', env, { instantiate: false }); + for (var key in hash) { + if (hash.hasOwnProperty(key)) { + _emberMetal.assert('Expected a proper full name, given \'' + hash[key] + '\'', this.validateFullName(hash[key])); - var singletons = ['router:main', _container.privatize(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert')]; + injections.push({ + property: key, + fullName: hash[key] + }); + } + } - singletons.forEach(function (key) { - return _this2.register(key, parent.lookup(key), { instantiate: false }); - }); + return injections; + }, - this.inject('view', '_environment', '-environment:main'); - this.inject('route', '_environment', '-environment:main'); - } - }); + getInjections: function (fullName) { + var injections = this._injections[fullName] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getInjections(fullName)); + } + return injections; + }, - EngineInstance.reopenClass({ - /** - @private - @method setupRegistry - @param {Registry} registry - @param {BootOptions} options - */ - setupRegistry: function (registry, options) { - // when no options/environment is present, do nothing - if (!options) { - return; + getTypeInjections: function (type) { + var injections = this._typeInjections[type] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getTypeInjections(type)); } + return injections; + }, - registry.injection('view', '_environment', '-environment:main'); - registry.injection('route', '_environment', '-environment:main'); + getFactoryInjections: function (fullName) { + var injections = this._factoryInjections[fullName] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getFactoryInjections(fullName)); + } + return injections; + }, - if (options.isInteractive) { - registry.injection('view', 'renderer', 'renderer:-dom'); - registry.injection('component', 'renderer', 'renderer:-dom'); - } else { - registry.injection('view', 'renderer', 'renderer:-inert'); - registry.injection('component', 'renderer', 'renderer:-inert'); + getFactoryTypeInjections: function (type) { + var injections = this._factoryTypeInjections[type] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getFactoryTypeInjections(type)); } + return injections; } - }); - - exports.default = EngineInstance; -}); -enifed('ember-application/system/engine-parent', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; - - exports.getEngineParent = getEngineParent; - exports.setEngineParent = setEngineParent; - var ENGINE_PARENT = _emberUtils.symbol('ENGINE_PARENT'); - - exports.ENGINE_PARENT = ENGINE_PARENT; - /** - `getEngineParent` retrieves an engine instance's parent instance. - - @method getEngineParent - @param {EngineInstance} engine An engine instance. - @return {EngineInstance} The parent engine instance. - @for Ember - @public - */ + }; - function getEngineParent(engine) { - return engine[ENGINE_PARENT]; + function deprecateResolverFunction(registry) { + _emberMetal.deprecate('Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.', false, { id: 'ember-application.registry-resolver-as-function', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function' }); + registry.resolver = { + resolve: registry.resolver + }; } /** - `setEngineParent` sets an engine instance's parent instance. + Given a fullName and a source fullName returns the fully resolved + fullName. Used to allow for local lookup. - @method setEngineParent - @param {EngineInstance} engine An engine instance. - @param {EngineInstance} parent The parent engine instance. - @private - */ + ```javascript + let registry = new Registry(); + + // the twitter factory is added to the module system + registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title + ``` + + @private + @method expandLocalLookup + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {String} fullName + */ + Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) { + if (this.resolver && this.resolver.expandLocalLookup) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + _emberMetal.assert('options.source must be provided to expandLocalLookup', options && options.source); + _emberMetal.assert('options.source must be a proper full name', this.validateFullName(options.source)); - function setEngineParent(engine, parent) { - engine[ENGINE_PARENT] = parent; - } -}); -enifed('ember-application/system/engine', ['exports', 'ember-utils', 'ember-runtime', 'container', 'dag-map', 'ember-metal', 'ember-application/system/resolver', 'ember-application/system/engine-instance', 'ember-routing', 'ember-extension-support', 'ember-views', 'ember-glimmer'], function (exports, _emberUtils, _emberRuntime, _container, _dagMap, _emberMetal, _emberApplicationSystemResolver, _emberApplicationSystemEngineInstance, _emberRouting, _emberExtensionSupport, _emberViews, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + var normalizedFullName = this.normalize(fullName); + var normalizedSource = this.normalize(options.source); - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + return expandLocalLookup(this, normalizedFullName, normalizedSource); + } else if (this.fallback) { + return this.fallback.expandLocalLookup(fullName, options); + } else { + return null; + } + }; - function props(obj) { - var properties = []; + function expandLocalLookup(registry, normalizedName, normalizedSource) { + var cache = registry._localLookupCache; + var normalizedNameCache = cache[normalizedName]; - for (var key in obj) { - properties.push(key); + if (!normalizedNameCache) { + normalizedNameCache = cache[normalizedName] = new _emberUtils.EmptyObject(); } - return properties; - } + var cached = normalizedNameCache[normalizedSource]; - /** - The `Engine` class contains core functionality for both applications and - engines. - - Each engine manages a registry that's used for dependency injection and - exposed through `RegistryProxy`. - - Engines also manage initializers and instance initializers. - - Engines can spawn `EngineInstance` instances via `buildInstance()`. - - @class Engine - @namespace Ember - @extends Ember.Namespace - @uses RegistryProxy - @public - */ - var Engine = _emberRuntime.Namespace.extend(_emberRuntime.RegistryProxyMixin, { - init: function () { - this._super.apply(this, arguments); + if (cached !== undefined) { + return cached; + } - this.buildRegistry(); - }, + var expanded = registry.resolver.expandLocalLookup(normalizedName, normalizedSource); - /** - A private flag indicating whether an engine's initializers have run yet. - @private - @property _initializersRan - */ - _initializersRan: false, + return normalizedNameCache[normalizedSource] = expanded; + } - /** - Ensure that initializers are run once, and only once, per engine. - @private - @method ensureInitializers - */ - ensureInitializers: function () { - if (!this._initializersRan) { - this.runInitializers(); - this._initializersRan = true; - } - }, + function resolve(registry, normalizedName, options) { + if (options && options.source) { + // when `source` is provided expand normalizedName + // and source into the full normalizedName + normalizedName = registry.expandLocalLookup(normalizedName, options); - /** - Create an EngineInstance for this engine. - @private - @method buildInstance - @return {Ember.EngineInstance} the engine instance - */ - buildInstance: function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + // if expandLocalLookup returns falsey, we do not support local lookup + if (!normalizedName) { + return; + } + } - this.ensureInitializers(); - options.base = this; - return _emberApplicationSystemEngineInstance.default.create(options); - }, + var cached = registry._resolveCache[normalizedName]; + if (cached !== undefined) { + return cached; + } + if (registry._failCache[normalizedName]) { + return; + } - /** - Build and configure the registry for the current engine. - @private - @method buildRegistry - @return {Ember.Registry} the configured registry - */ - buildRegistry: function () { - var registry = this.__registry__ = this.constructor.buildRegistry(this); + var resolved = undefined; - return registry; - }, + if (registry.resolver) { + resolved = registry.resolver.resolve(normalizedName); + } - /** - @private - @method initializer - */ - initializer: function (options) { - this.constructor.initializer(options); - }, + if (resolved === undefined) { + resolved = registry.registrations[normalizedName]; + } - /** - @private - @method instanceInitializer - */ - instanceInitializer: function (options) { - this.constructor.instanceInitializer(options); - }, + if (resolved === undefined) { + registry._failCache[normalizedName] = true; + } else { + registry._resolveCache[normalizedName] = resolved; + } - /** - @private - @method runInitializers - */ - runInitializers: function () { - var _this = this; + return resolved; + } - this._runInitializer('initializers', function (name, initializer) { - _emberMetal.assert('No application initializer named \'' + name + '\'', !!initializer); - if (initializer.initialize.length === 2) { - _emberMetal.deprecate('The `initialize` method for Application initializer \'' + name + '\' should take only one argument - `App`, an instance of an `Application`.', false, { - id: 'ember-application.app-initializer-initialize-arguments', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_initializer-arity' - }); + function has(registry, fullName, source) { + return registry.resolve(fullName, { source: source }) !== undefined; + } - initializer.initialize(_this.__registry__, _this); - } else { - initializer.initialize(_this); - } - }); - }, + var privateNames = _emberUtils.dictionary(null); + var privateSuffix = '' + Math.random() + Date.now(); - /** - @private - @since 1.12.0 - @method runInstanceInitializers - */ - runInstanceInitializers: function (instance) { - this._runInitializer('instanceInitializers', function (name, initializer) { - _emberMetal.assert('No instance initializer named \'' + name + '\'', !!initializer); - initializer.initialize(instance); - }); - }, + function privatize(_ref) { + var fullName = _ref[0]; - _runInitializer: function (bucketName, cb) { - var initializersByName = _emberMetal.get(this.constructor, bucketName); - var initializers = props(initializersByName); - var graph = new _dagMap.default(); - var initializer = undefined; + var name = privateNames[fullName]; + if (name) { + return name; + } - for (var i = 0; i < initializers.length; i++) { - initializer = initializersByName[initializers[i]]; - graph.add(initializer.name, initializer, initializer.before, initializer.after); - } + var _fullName$split = fullName.split(':'); - graph.topsort(cb); - } - }); + var type = _fullName$split[0]; + var rawName = _fullName$split[1]; - Engine.reopenClass({ - initializers: new _emberUtils.EmptyObject(), - instanceInitializers: new _emberUtils.EmptyObject(), + return privateNames[fullName] = _emberUtils.intern(type + ':' + rawName + '-' + privateSuffix); + } +}); +enifed('dag-map', ['exports'], function (exports) { 'use strict'; +/** + * A map of key/value pairs with dependencies contraints that can be traversed + * in topological order and is checked for cycles. + * + * @class DAG + * @constructor + */ +var DAG = (function () { + function DAG() { + this._vertices = new Vertices(); + } /** - The goal of initializers should be to register dependencies and injections. - This phase runs once. Because these initializers may load code, they are - allowed to defer application readiness and advance it. If you need to access - the container or store you should use an InstanceInitializer that will be run - after all initializers and therefore after all code is loaded and the app is - ready. - Initializer receives an object which has the following attributes: - `name`, `before`, `after`, `initialize`. The only required attribute is - `initialize`, all others are optional. - * `name` allows you to specify under which name the initializer is registered. - This must be a unique name, as trying to register two initializers with the - same name will result in an error. - ```javascript - Ember.Application.initializer({ - name: 'namedInitializer', - initialize: function(application) { - Ember.debug('Running namedInitializer!'); - } - }); - ``` - * `before` and `after` are used to ensure that this initializer is ran prior - or after the one identified by the value. This value can be a single string - or an array of strings, referencing the `name` of other initializers. - An example of ordering initializers, we create an initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'first', - initialize: function(application) { - Ember.debug('First initializer!'); + * Adds a key/value pair with dependencies on other key/value pairs. + * + * @public + * @method addEdges + * @param {string[]} key The key of the vertex to be added. + * @param {any} value The value of that vertex. + * @param {string[]|string|undefined} before A key or array of keys of the vertices that must + * be visited before this vertex. + * @param {string[]|string|undefined} after An string or array of strings with the keys of the + * vertices that must be after this vertex is visited. + */ + DAG.prototype.add = function (key, value, before, after) { + var vertices = this._vertices; + var v = vertices.add(key); + v.val = value; + if (before) { + if (typeof before === "string") { + vertices.addEdge(v, vertices.add(before)); + } + else { + for (var i = 0; i < before.length; i++) { + vertices.addEdge(v, vertices.add(before[i])); + } + } } - }); - // DEBUG: First initializer! - ``` - We add another initializer named `second`, specifying that it should run - after the initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'second', - after: 'first', - initialize: function(application) { - Ember.debug('Second initializer!'); + if (after) { + if (typeof after === "string") { + vertices.addEdge(vertices.add(after), v); + } + else { + for (var i = 0; i < after.length; i++) { + vertices.addEdge(vertices.add(after[i]), v); + } + } } - }); - // DEBUG: First initializer! - // DEBUG: Second initializer! - ``` - Afterwards we add a further initializer named `pre`, this time specifying - that it should run before the initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'pre', - before: 'first', - initialize: function(application) { - Ember.debug('Pre initializer!'); + }; + /** + * Visits key/value pairs in topological order. + * + * @public + * @method topsort + * @param {Function} fn The function to be invoked with each key/value. + */ + DAG.prototype.topsort = function (callback) { + this._vertices.topsort(callback); + }; + return DAG; +}()); +var Vertices = (function () { + function Vertices() { + this.stack = new IntStack(); + this.result = new IntStack(); + this.vertices = []; + } + Vertices.prototype.add = function (key) { + if (!key) + throw new Error("missing key"); + var vertices = this.vertices; + var i = 0; + var vertex; + for (; i < vertices.length; i++) { + vertex = vertices[i]; + if (vertex.key === key) + return vertex; } - }); - // DEBUG: Pre initializer! - // DEBUG: First initializer! - // DEBUG: Second initializer! - ``` - Finally we add an initializer named `post`, specifying it should run after - both the `first` and the `second` initializers: - ```javascript - Ember.Application.initializer({ - name: 'post', - after: ['first', 'second'], - initialize: function(application) { - Ember.debug('Post initializer!'); + return vertices[i] = { + id: i, + key: key, + val: null, + inc: null, + out: false, + mark: false + }; + }; + Vertices.prototype.addEdge = function (v, w) { + this.check(v, w.key); + var inc = w.inc; + if (!inc) { + w.inc = [v.id]; } - }); - // DEBUG: Pre initializer! - // DEBUG: First initializer! - // DEBUG: Second initializer! - // DEBUG: Post initializer! - ``` - * `initialize` is a callback function that receives one argument, - `application`, on which you can operate. - Example of using `application` to register an adapter: - ```javascript - Ember.Application.initializer({ - name: 'api-adapter', - initialize: function(application) { - application.register('api-adapter:main', ApiAdapter); + else { + var i = 0; + for (; i < inc.length; i++) { + if (inc[i] === v.id) + return; + } + inc[i] = v.id; } - }); - ``` - @method initializer - @param initializer {Object} - @public - */ - - initializer: buildInitializerMethod('initializers', 'initializer'), - - /** - Instance initializers run after all initializers have run. Because - instance initializers run after the app is fully set up. We have access - to the store, container, and other items. However, these initializers run - after code has loaded and are not allowed to defer readiness. - Instance initializer receives an object which has the following attributes: - `name`, `before`, `after`, `initialize`. The only required attribute is - `initialize`, all others are optional. - * `name` allows you to specify under which name the instanceInitializer is - registered. This must be a unique name, as trying to register two - instanceInitializer with the same name will result in an error. - ```javascript - Ember.Application.instanceInitializer({ - name: 'namedinstanceInitializer', - initialize: function(application) { - Ember.debug('Running namedInitializer!'); + v.out = true; + }; + Vertices.prototype.topsort = function (cb) { + this.reset(); + var vertices = this.vertices; + for (var i = 0; i < vertices.length; i++) { + var vertex = vertices[i]; + if (vertex.out) + continue; + this.visit(vertex, undefined); } - }); - ``` - * `before` and `after` are used to ensure that this initializer is ran prior - or after the one identified by the value. This value can be a single string - or an array of strings, referencing the `name` of other initializers. - * See Ember.Application.initializer for discussion on the usage of before - and after. - Example instanceInitializer to preload data into the store. - ```javascript - Ember.Application.initializer({ - name: 'preload-data', - initialize: function(application) { - var userConfig, userConfigEncoded, store; - // We have a HTML escaped JSON representation of the user's basic - // configuration generated server side and stored in the DOM of the main - // index.html file. This allows the app to have access to a set of data - // without making any additional remote calls. Good for basic data that is - // needed for immediate rendering of the page. Keep in mind, this data, - // like all local models and data can be manipulated by the user, so it - // should not be relied upon for security or authorization. - // - // Grab the encoded data from the meta tag - userConfigEncoded = Ember.$('head meta[name=app-user-config]').attr('content'); - // Unescape the text, then parse the resulting JSON into a real object - userConfig = JSON.parse(unescape(userConfigEncoded)); - // Lookup the store - store = application.lookup('service:store'); - // Push the encoded JSON into the store - store.pushPayload(userConfig); + this.each(cb); + }; + Vertices.prototype.check = function (v, w) { + if (v.key === w) { + throw new Error("cycle detected: " + w + " <- " + w); } - }); - ``` - @method instanceInitializer - @param instanceInitializer - @public - */ - instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer'), + var inc = v.inc; + // quick check + if (!inc || inc.length === 0) + return; + var vertices = this.vertices; + // shallow check + for (var i = 0; i < inc.length; i++) { + var key = vertices[inc[i]].key; + if (key === w) { + throw new Error("cycle detected: " + w + " <- " + v.key + " <- " + w); + } + } + // deep check + this.reset(); + this.visit(v, w); + if (this.result.len > 0) { + var msg_1 = "cycle detected: " + w; + this.each(function (key) { + msg_1 += " <- " + key; + }); + throw new Error(msg_1); + } + }; + Vertices.prototype.each = function (cb) { + var _a = this, result = _a.result, vertices = _a.vertices; + for (var i = 0; i < result.len; i++) { + var vertex = vertices[result.stack[i]]; + cb(vertex.key, vertex.val); + } + }; + // reuse between cycle check and topsort + Vertices.prototype.reset = function () { + this.stack.len = 0; + this.result.len = 0; + var vertices = this.vertices; + for (var i = 0; i < vertices.length; i++) { + vertices[i].mark = false; + } + }; + Vertices.prototype.visit = function (start, search) { + var _a = this, stack = _a.stack, result = _a.result, vertices = _a.vertices; + stack.push(start.id); + while (stack.len) { + var index = stack.pop(); + if (index < 0) { + index = ~index; + if (search) { + result.pop(); + } + else { + result.push(index); + } + } + else { + var vertex = vertices[index]; + if (vertex.mark) { + continue; + } + if (search) { + result.push(index); + if (search === vertex.key) { + return; + } + } + vertex.mark = true; + stack.push(~index); + var incoming = vertex.inc; + if (incoming) { + var i = incoming.length; + while (i--) { + index = incoming[i]; + if (!vertices[index].mark) { + stack.push(index); + } + } + } + } + } + }; + return Vertices; +}()); +var IntStack = (function () { + function IntStack() { + this.stack = [0, 0, 0, 0, 0, 0]; + this.len = 0; + } + IntStack.prototype.push = function (n) { + this.stack[this.len++] = n; + }; + IntStack.prototype.pop = function () { + return this.stack[--this.len]; + }; + return IntStack; +}()); - /** - This creates a registry with the default Ember naming conventions. - It also configures the registry: - * registered views are created every time they are looked up (they are - not singletons) - * registered templates are not factories; the registered value is - returned directly. - * the router receives the application as its `namespace` property - * all controllers receive the router as their `target` and `controllers` - properties - * all controllers receive the application as their `namespace` property - * the application view receives the application controller as its - `controller` property - * the application view receives the application template as its - `defaultTemplate` property - @method buildRegistry - @static - @param {Ember.Application} namespace the application for which to - build the registry - @return {Ember.Registry} the built registry - @private - */ - buildRegistry: function (namespace) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; +exports['default'] = DAG; - var registry = new _container.Registry({ - resolver: resolverFor(namespace) - }); +Object.defineProperty(exports, '__esModule', { value: true }); - registry.set = _emberMetal.set; +}); +enifed('ember-application/index', ['exports', 'ember-application/initializers/dom-templates', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/resolver', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (exports, _emberApplicationInitializersDomTemplates, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberApplicationSystemResolver, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent) { + /** + @module ember + @submodule ember-application + */ - registry.register('application:main', namespace, { instantiate: false }); + 'use strict'; - commonSetupRegistry(registry); - _emberGlimmer.setupEngineRegistry(registry); + exports.Application = _emberApplicationSystemApplication.default; + exports.ApplicationInstance = _emberApplicationSystemApplicationInstance.default; + exports.Resolver = _emberApplicationSystemResolver.default; + exports.Engine = _emberApplicationSystemEngine.default; + exports.EngineInstance = _emberApplicationSystemEngineInstance.default; + exports.getEngineParent = _emberApplicationSystemEngineParent.getEngineParent; + exports.setEngineParent = _emberApplicationSystemEngineParent.setEngineParent; - return registry; - }, + // add domTemplates initializer (only does something if `ember-template-compiler` + // is loaded already) +}); +enifed('ember-application/initializers/dom-templates', ['exports', 'require', 'ember-glimmer', 'ember-environment', 'ember-application/system/application'], function (exports, _require, _emberGlimmer, _emberEnvironment, _emberApplicationSystemApplication) { + 'use strict'; - /** - Set this to provide an alternate class to `Ember.DefaultResolver` - @deprecated Use 'Resolver' instead - @property resolver - @public - */ - resolver: null, + var bootstrap = function () {}; - /** - Set this to provide an alternate class to `Ember.DefaultResolver` - @property resolver - @public - */ - Resolver: null + _emberApplicationSystemApplication.default.initializer({ + name: 'domTemplates', + initialize: function () { + var bootstrapModuleId = 'ember-template-compiler/system/bootstrap'; + var context = undefined; + if (_emberEnvironment.environment.hasDOM && _require.has(bootstrapModuleId)) { + bootstrap = _require.default(bootstrapModuleId).default; + context = document; + } + + bootstrap({ context: context, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + } }); +}); +enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberViews, _emberApplicationSystemEngineInstance) { + /** + @module ember + @submodule ember-application + */ + + 'use strict'; + + var BootOptions = undefined; /** - This function defines the default lookup rules for container lookups: + The `ApplicationInstance` encapsulates all of the stateful aspects of a + running `Application`. - * templates are looked up on `Ember.TEMPLATES` - * other names are looked up on the application after classifying the name. - For example, `controller:post` looks up `App.PostController` by default. - * if the default lookup fails, look for registered classes on the container + At a high-level, we break application boot into two distinct phases: - This allows the application to register default injections in the container - that could be overridden by the normal naming convention. + * Definition time, where all of the classes, templates, and other + dependencies are loaded (typically in the browser). + * Run time, where we begin executing the application once everything + has loaded. - @private - @method resolverFor - @param {Ember.Namespace} namespace the namespace to look for classes - @return {*} the resolved value for a given lookup + Definition time can be expensive and only needs to happen once since it is + an idempotent operation. For example, between test runs and FastBoot + requests, the application stays the same. It is only the state that we want + to reset. + + That state is what the `ApplicationInstance` manages: it is responsible for + creating the container that contains all application state, and disposing of + it once the particular test run or FastBoot request has finished. + + @public + @class Ember.ApplicationInstance + @extends Ember.EngineInstance */ - function resolverFor(namespace) { - var ResolverClass = namespace.get('Resolver') || _emberApplicationSystemResolver.default; - - return ResolverClass.create({ - namespace: namespace - }); - } - - function buildInitializerMethod(bucketName, humanName) { - return function (initializer) { - // If this is the first initializer being added to a subclass, we are going to reopen the class - // to make sure we have a new `initializers` object, which extends from the parent class' using - // prototypal inheritance. Without this, attempting to add initializers to the subclass would - // pollute the parent class as well as other subclasses. - if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) { - var attrs = {}; - attrs[bucketName] = Object.create(this[bucketName]); - this.reopenClass(attrs); - } - _emberMetal.assert('The ' + humanName + ' \'' + initializer.name + '\' has already been registered', !this[bucketName][initializer.name]); - _emberMetal.assert('An ' + humanName + ' cannot be registered without an initialize function', _emberUtils.canInvoke(initializer, 'initialize')); - _emberMetal.assert('An ' + humanName + ' cannot be registered without a name property', initializer.name !== undefined); + var ApplicationInstance = _emberApplicationSystemEngineInstance.default.extend({ + /** + The `Application` for which this is an instance. + @property {Ember.Application} application + @private + */ + application: null, - this[bucketName][initializer.name] = initializer; - }; - } + /** + The DOM events for which the event dispatcher should listen. + By default, the application's `Ember.EventDispatcher` listens + for a set of standard DOM events, such as `mousedown` and + `keyup`, and delegates them to your application's `Ember.View` + instances. + @private + @property {Object} customEvents + */ + customEvents: null, - function commonSetupRegistry(registry) { - registry.optionsForType('component', { singleton: false }); - registry.optionsForType('view', { singleton: false }); + /** + The root DOM element of the Application as an element or a + [jQuery-compatible selector + string](http://api.jquery.com/category/selectors/). + @private + @property {String|DOMElement} rootElement + */ + rootElement: null, - registry.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); + init: function () { + this._super.apply(this, arguments); - registry.injection('view', '_viewRegistry', '-view-registry:main'); - registry.injection('renderer', '_viewRegistry', '-view-registry:main'); - registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); + // Register this instance in the per-instance registry. + // + // Why do we need to register the instance in the first place? + // Because we need a good way for the root route (a.k.a ApplicationRoute) + // to notify us when it has created the root-most view. That view is then + // appended to the rootElement, in the case of apps, to the fixture harness + // in tests, or rendered to a string in the case of FastBoot. + this.register('-application-instance:main', this, { instantiate: false }); + }, - registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); + /** + Overrides the base `EngineInstance._bootSync` method with concerns relevant + to booting application (instead of engine) instances. + This method should only contain synchronous boot concerns. Asynchronous + boot concerns should eventually be moved to the `boot` method, which + returns a promise. + Until all boot code has been made asynchronous, we need to continue to + expose this method for use *internally* in places where we need to boot an + instance synchronously. + @private + */ + _bootSync: function (options) { + if (this._booted) { + return this; + } - registry.injection('view:-outlet', 'namespace', 'application:main'); + options = new BootOptions(options); - registry.injection('controller', 'target', 'router:main'); - registry.injection('controller', 'namespace', 'application:main'); + this.setupRegistry(options); - registry.injection('router', '_bucketCache', _container.privatize(_templateObject)); - registry.injection('route', '_bucketCache', _container.privatize(_templateObject)); + if (options.rootElement) { + this.rootElement = options.rootElement; + } else { + this.rootElement = this.application.rootElement; + } - registry.injection('route', 'router', 'router:main'); + if (options.location) { + var router = _emberMetal.get(this, 'router'); + _emberMetal.set(router, 'location', options.location); + } - // Register the routing service... - registry.register('service:-routing', _emberRouting.RoutingService); - // Then inject the app router into it - registry.injection('service:-routing', 'router', 'router:main'); + this.application.runInstanceInitializers(this); - // DEBUGGING - registry.register('resolver-for-debugging:main', registry.resolver, { instantiate: false }); - registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); - registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); - // Custom resolver authors may want to register their own ContainerDebugAdapter with this key + if (options.isInteractive) { + this.setupEventDispatcher(); + } - registry.register('container-debug-adapter:main', _emberExtensionSupport.ContainerDebugAdapter); + this._booted = true; - registry.register('component-lookup:main', _emberViews.ComponentLookup); - } + return this; + }, - exports.default = Engine; -}); -enifed('ember-application/system/resolver', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application/utils/validate-type', 'ember-glimmer'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplicationUtilsValidateType, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ + setupRegistry: function (options) { + this.constructor.setupRegistry(this.__registry__, options); + }, - 'use strict'; + router: _emberMetal.computed(function () { + return this.lookup('router:main'); + }).readOnly(), - var Resolver = _emberRuntime.Object.extend({ - /* - This will be set to the Application instance when it is - created. - @property namespace + /** + This hook is called by the root-most Route (a.k.a. the ApplicationRoute) + when it has finished creating the root View. By default, we simply take the + view and append it to the `rootElement` specified on the Application. + In cases like FastBoot and testing, we can override this hook and implement + custom behavior, such as serializing to a string and sending over an HTTP + socket rather than appending to DOM. + @param view {Ember.View} the root-most view + @private */ - namespace: null, - normalize: null, // required - resolve: null, // required - parseName: null, // required - lookupDescription: null, // required - makeToString: null, // required - resolveOther: null, // required - _logLookup: null // required - }); - - exports.Resolver = Resolver; - /** - The DefaultResolver defines the default lookup rules to resolve - container lookups before consulting the container for registered - items: - - * templates are looked up on `Ember.TEMPLATES` - * other names are looked up on the application after converting - the name. For example, `controller:post` looks up - `App.PostController` by default. - * there are some nuances (see examples below) - - ### How Resolving Works - - The container calls this object's `resolve` method with the - `fullName` argument. - - It first parses the fullName into an object using `parseName`. - - Then it checks for the presence of a type-specific instance - method of the form `resolve[Type]` and calls it if it exists. - For example if it was resolving 'template:post', it would call - the `resolveTemplate` method. - - Its last resort is to call the `resolveOther` method. - - The methods of this object are designed to be easy to override - in a subclass. For example, you could enhance how a template - is resolved like so: - - ```javascript - App = Ember.Application.create({ - Resolver: Ember.DefaultResolver.extend({ - resolveTemplate: function(parsedName) { - let resolvedTemplate = this._super(parsedName); - if (resolvedTemplate) { return resolvedTemplate; } - return Ember.TEMPLATES['not_found']; - } - }) - }); - ``` - - Some examples of how names are resolved: - - ``` - 'template:post' //=> Ember.TEMPLATES['post'] - 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] - 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] - 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] - // OR - // Ember.TEMPLATES['blog_post'] - 'controller:post' //=> App.PostController - 'controller:posts.index' //=> App.PostsIndexController - 'controller:blog/post' //=> Blog.PostController - 'controller:basic' //=> Ember.Controller - 'route:post' //=> App.PostRoute - 'route:posts.index' //=> App.PostsIndexRoute - 'route:blog/post' //=> Blog.PostRoute - 'route:basic' //=> Ember.Route - 'view:post' //=> App.PostView - 'view:posts.index' //=> App.PostsIndexView - 'view:blog/post' //=> Blog.PostView - 'view:basic' //=> Ember.View - 'foo:post' //=> App.PostFoo - 'model:post' //=> App.Post - ``` - - @class DefaultResolver - @namespace Ember - @extends Ember.Object - @public - */ + didCreateRootView: function (view) { + view.appendTo(this.rootElement); + }, - exports.default = _emberRuntime.Object.extend({ /** - This will be set to the Application instance when it is - created. - @property namespace - @public + Tells the router to start routing. The router will ask the location for the + current URL of the page to determine the initial URL to start routing to. + To start the app at a specific URL, call `handleURL` instead. + @private */ - namespace: null, - - init: function () { - this._parseNameCache = _emberUtils.dictionary(null); + startRouting: function () { + var router = _emberMetal.get(this, 'router'); + router.startRouting(); + this._didSetupRouter = true; }, - normalize: function (fullName) { - var _fullName$split = fullName.split(':', 2); - - var type = _fullName$split[0]; - var name = _fullName$split[1]; - - _emberMetal.assert('Tried to normalize a container name without a colon (:) in it. ' + 'You probably tried to lookup a name that did not contain a type, ' + 'a colon, and a name. A proper lookup name would be `view:post`.', fullName.split(':').length === 2); - - if (type !== 'template') { - var result = name; - - if (result.indexOf('.') > -1) { - result = result.replace(/\.(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } - - if (name.indexOf('_') > -1) { - result = result.replace(/_(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } - - if (name.indexOf('-') > -1) { - result = result.replace(/-(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } - return type + ':' + result; - } else { - return fullName; + /** + @private + Sets up the router, initializing the child router and configuring the + location before routing begins. + Because setup should only occur once, multiple calls to `setupRouter` + beyond the first call have no effect. + */ + setupRouter: function () { + if (this._didSetupRouter) { + return; } + this._didSetupRouter = true; + + var router = _emberMetal.get(this, 'router'); + router.setupRouter(); }, /** - This method is called via the container's resolver method. - It parses the provided `fullName` and then looks up and - returns the appropriate template or class. - @method resolve - @param {String} fullName the lookup string - @return {Object} the resolved factory - @public + Directs the router to route to a particular URL. This is useful in tests, + for example, to tell the app to start at a particular URL. + @param url {String} the URL the router should route to + @private */ - resolve: function (fullName) { - var parsedName = this.parseName(fullName); - var resolveMethodName = parsedName.resolveMethodName; - var resolved; - - if (this[resolveMethodName]) { - resolved = this[resolveMethodName](parsedName); - } + handleURL: function (url) { + var router = _emberMetal.get(this, 'router'); - resolved = resolved || this.resolveOther(parsedName); + this.setupRouter(); + return router.handleURL(url); + }, - if (parsedName.root && parsedName.root.LOG_RESOLVER) { - this._logLookup(resolved, parsedName); - } + /** + @private + */ + setupEventDispatcher: function () { + var dispatcher = this.lookup('event_dispatcher:main'); + var applicationCustomEvents = _emberMetal.get(this.application, 'customEvents'); + var instanceCustomEvents = _emberMetal.get(this, 'customEvents'); - if (resolved) { - _emberApplicationUtilsValidateType.default(resolved, parsedName); - } + var customEvents = _emberUtils.assign({}, applicationCustomEvents, instanceCustomEvents); + dispatcher.setup(customEvents, this.rootElement); - return resolved; + return dispatcher; }, /** - Convert the string name of the form 'type:name' to - a Javascript object with the parsed aspects of the name - broken out. - @param {String} fullName the lookup string - @method parseName - @protected + Returns the current URL of the app instance. This is useful when your + app does not update the browsers URL bar (i.e. it uses the `'none'` + location adapter). + @public + @return {String} the current URL */ - - parseName: function (fullName) { - return this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)); + getURL: function () { + var router = _emberMetal.get(this, 'router'); + return _emberMetal.get(router, 'url'); }, - _parseName: function (fullName) { - var _fullName$split2 = fullName.split(':'); - - var type = _fullName$split2[0]; - var fullNameWithoutType = _fullName$split2[1]; + // `instance.visit(url)` should eventually replace `instance.handleURL()`; + // the test helpers can probably be switched to use this implementation too - var name = fullNameWithoutType; - var namespace = _emberMetal.get(this, 'namespace'); - var root = namespace; - var lastSlashIndex = name.lastIndexOf('/'); - var dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null; + /** + Navigate the instance to a particular URL. This is useful in tests, for + example, or to tell the app to start at a particular URL. This method + returns a promise that resolves with the app instance when the transition + is complete, or rejects if the transion was aborted due to an error. + @public + @param url {String} the destination URL + @return {Promise} + */ + visit: function (url) { + var _this = this; - if (type !== 'template' && lastSlashIndex !== -1) { - var parts = name.split('/'); - name = parts[parts.length - 1]; - var namespaceName = _emberRuntime.String.capitalize(parts.slice(0, -1).join('.')); - root = _emberRuntime.Namespace.byName(namespaceName); + this.setupRouter(); - _emberMetal.assert('You are looking for a ' + name + ' ' + type + ' in the ' + namespaceName + ' namespace, but the namespace could not be found', root); - } + var bootOptions = this.__container__.lookup('-environment:main'); - var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : _emberRuntime.String.classify(type); + var router = _emberMetal.get(this, 'router'); - if (!(name && type)) { - throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); - } + var handleTransitionResolve = function () { + if (!bootOptions.options.shouldRender) { + // No rendering is needed, and routing has completed, simply return. + return _this; + } else { + return new _emberRuntime.RSVP.Promise(function (resolve) { + // Resolve once rendering is completed. `router.handleURL` returns the transition (as a thennable) + // which resolves once the transition is completed, but the transition completion only queues up + // a scheduled revalidation (into the `render` queue) in the Renderer. + // + // This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed. + _emberMetal.run.schedule('afterRender', null, resolve, _this); + }); + } + }; - return { - fullName: fullName, - type: type, - fullNameWithoutType: fullNameWithoutType, - dirname: dirname, - name: name, - root: root, - resolveMethodName: 'resolve' + resolveMethodName + var handleTransitionReject = function (error) { + if (error.error) { + throw error.error; + } else if (error.name === 'TransitionAborted' && router.router.activeTransition) { + return router.router.activeTransition.then(handleTransitionResolve, handleTransitionReject); + } else if (error.name === 'TransitionAborted') { + throw new Error(error.message); + } else { + throw error; + } }; - }, + var location = _emberMetal.get(router, 'location'); + + // Keeps the location adapter's internal URL in-sync + location.setURL(url); + + // getURL returns the set url with the rootURL stripped off + return router.handleURL(location.getURL()).then(handleTransitionResolve, handleTransitionReject); + } + }); + + ApplicationInstance.reopenClass({ /** - Returns a human-readable description for a fullName. Used by the - Application namespace in assertions to describe the - precise name of the class that Ember is looking for, rather than - container keys. - @param {String} fullName the lookup string - @method lookupDescription - @protected + @private + @method setupRegistry + @param {Registry} registry + @param {BootOptions} options */ - lookupDescription: function (fullName) { - var parsedName = this.parseName(fullName); - var description = undefined; + setupRegistry: function (registry) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (parsedName.type === 'template') { - return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + if (!options.toEnvironment) { + options = new BootOptions(options); } - description = parsedName.root + '.' + _emberRuntime.String.classify(parsedName.name).replace(/\./g, ''); - - if (parsedName.type !== 'model') { - description += _emberRuntime.String.classify(parsedName.type); - } + registry.register('-environment:main', options.toEnvironment(), { instantiate: false }); + registry.register('service:-document', options.document, { instantiate: false }); - return description; - }, + this._super(registry, options); + } + }); - makeToString: function (factory, fullName) { - return factory.toString(); - }, + /** + A list of boot-time configuration options for customizing the behavior of + an `Ember.ApplicationInstance`. + + This is an interface class that exists purely to document the available + options; you do not need to construct it manually. Simply pass a regular + JavaScript object containing the desired options into methods that require + one of these options object: + + ```javascript + MyApp.visit("/", { location: "none", rootElement: "#container" }); + ``` + + Not all combinations of the supported options are valid. See the documentation + on `Ember.Application#visit` for the supported configurations. + + Internal, experimental or otherwise unstable flags are marked as private. + + @class BootOptions + @namespace Ember.ApplicationInstance + @public + */ + BootOptions = function BootOptions() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; /** - Given a parseName object (output from `parseName`), apply - the conventions expected by `Ember.Router` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method useRouterNaming - @protected - */ - useRouterNaming: function (parsedName) { - parsedName.name = parsedName.name.replace(/\./g, '_'); - if (parsedName.name === 'basic') { - parsedName.name = ''; - } - }, - /** - Look up the template in Ember.TEMPLATES - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveTemplate - @protected + Provide a specific instance of jQuery. This is useful in conjunction with + the `document` option, as it allows you to use a copy of `jQuery` that is + appropriately bound to the foreign `document` (e.g. a jsdom). + This is highly experimental and support very incomplete at the moment. + @property jQuery + @type Object + @default auto-detected + @private */ - resolveTemplate: function (parsedName) { - var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); - - return _emberGlimmer.getTemplate(templateName) || _emberGlimmer.getTemplate(_emberRuntime.String.decamelize(templateName)); - }, + this.jQuery = _emberViews.jQuery; // This default is overridable below /** - Lookup the view using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveView - @protected + Interactive mode: whether we need to set up event delegation and invoke + lifecycle callbacks on Components. + @property isInteractive + @type boolean + @default auto-detected + @private */ - resolveView: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); - }, + this.isInteractive = _emberEnvironment.environment.hasDOM; // This default is overridable below /** - Lookup the controller using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveController - @protected - */ - resolveController: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); - }, - /** - Lookup the route using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveRoute - @protected + Run in a full browser environment. + When this flag is set to `false`, it will disable most browser-specific + and interactive features. Specifically: + * It does not use `jQuery` to append the root view; the `rootElement` + (either specified as a subsequent option or on the application itself) + must already be an `Element` in the given `document` (as opposed to a + string selector). + * It does not set up an `EventDispatcher`. + * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). + * It sets the `location` option to `"none"`. (If you would like to use + the location adapter specified in the app's router instead, you can also + specify `{ location: null }` to specifically opt-out.) + @property isBrowser + @type boolean + @default auto-detected + @public */ - resolveRoute: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); - }, + if (options.isBrowser !== undefined) { + this.isBrowser = !!options.isBrowser; + } else { + this.isBrowser = _emberEnvironment.environment.hasDOM; + } - /** - Lookup the model on the Application namespace - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveModel - @protected - */ - resolveModel: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.name); - var factory = _emberMetal.get(parsedName.root, className); + if (!this.isBrowser) { + this.jQuery = null; + this.isInteractive = false; + this.location = 'none'; + } - return factory; - }, - /** - Look up the specified object (from parsedName) on the appropriate - namespace (usually on the Application) - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveHelper - @protected - */ - resolveHelper: function (parsedName) { - return this.resolveOther(parsedName); - }, /** - Look up the specified object (from parsedName) on the appropriate - namespace (usually on the Application) - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveOther - @protected + Disable rendering completely. + When this flag is set to `true`, it will disable the entire rendering + pipeline. Essentially, this puts the app into "routing-only" mode. No + templates will be rendered, and no Components will be created. + @property shouldRender + @type boolean + @default true + @public */ - resolveOther: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.name) + _emberRuntime.String.classify(parsedName.type); - var factory = _emberMetal.get(parsedName.root, className); - return factory; - }, + if (options.shouldRender !== undefined) { + this.shouldRender = !!options.shouldRender; + } else { + this.shouldRender = true; + } - resolveMain: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.type); - return _emberMetal.get(parsedName.root, className); - }, + if (!this.shouldRender) { + this.jQuery = null; + this.isInteractive = false; + } /** - @method _logLookup - @param {Boolean} found - @param {Object} parsedName - @private - */ - _logLookup: function (found, parsedName) { - var symbol = undefined, - padding = undefined; - - if (found) { - symbol = '[✓]'; - } else { - symbol = '[ ]'; - } - - if (parsedName.fullName.length > 60) { - padding = '.'; - } else { - padding = new Array(60 - parsedName.fullName.length).join('.'); - } - - _emberMetal.info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); - }, + If present, render into the given `Document` object instead of the + global `window.document` object. + In practice, this is only useful in non-browser environment or in + non-interactive mode, because Ember's `jQuery` dependency is + implicitly bound to the current document, causing event delegation + to not work properly when the app is rendered into a foreign + document object (such as an iframe's `contentDocument`). + In non-browser mode, this could be a "`Document`-like" object as + Ember only interact with a small subset of the DOM API in non- + interactive mode. While the exact requirements have not yet been + formalized, the `SimpleDOM` library's implementation is known to + work. + @property document + @type Document + @default the global `document` object + @public + */ + if (options.document) { + this.document = options.document; + } else { + this.document = typeof document !== 'undefined' ? document : null; + } /** - Used to iterate all items of a given type. - @method knownForType - @param {String} type the type to search for - @private + If present, overrides the application's `rootElement` property on + the instance. This is useful for testing environment, where you + might want to append the root view to a fixture area. + In non-browser mode, because Ember does not have access to jQuery, + this options must be specified as a DOM `Element` object instead of + a selector string. + See the documentation on `Ember.Applications`'s `rootElement` for + details. + @property rootElement + @type String|Element + @default null + @public */ - knownForType: function (type) { - var namespace = _emberMetal.get(this, 'namespace'); - var suffix = _emberRuntime.String.classify(type); - var typeRegexp = new RegExp(suffix + '$'); + if (options.rootElement) { + this.rootElement = options.rootElement; + } - var known = _emberUtils.dictionary(null); - var knownKeys = Object.keys(namespace); - for (var index = 0; index < knownKeys.length; index++) { - var _name = knownKeys[index]; + // Set these options last to give the user a chance to override the + // defaults from the "combo" options like `isBrowser` (although in + // practice, the resulting combination is probably invalid) - if (typeRegexp.test(_name)) { - var containerName = this.translateToContainerFullname(type, _name); + /** + If present, overrides the router's `location` property with this + value. This is useful for environments where trying to modify the + URL would be inappropriate. + @property location + @type string + @default null + @public + */ + if (options.location !== undefined) { + this.location = options.location; + } - known[containerName] = true; - } - } + if (options.jQuery !== undefined) { + this.jQuery = options.jQuery; + } - return known; - }, + if (options.isInteractive !== undefined) { + this.isInteractive = !!options.isInteractive; + } + }; - /** - Converts provided name from the backing namespace into a container lookup name. - Examples: - App.FooBarHelper -> helper:foo-bar - App.THelper -> helper:t - @method translateToContainerFullname - @param {String} type - @param {String} name - @private - */ + BootOptions.prototype.toEnvironment = function () { + var env = _emberUtils.assign({}, _emberEnvironment.environment); + // For compatibility with existing code + env.hasDOM = this.isBrowser; + env.isInteractive = this.isInteractive; + env.options = this; + return env; + }; - translateToContainerFullname: function (type, name) { - var suffix = _emberRuntime.String.classify(type); - var namePrefix = name.slice(0, suffix.length * -1); - var dasherizedName = _emberRuntime.String.dasherize(namePrefix); + Object.defineProperty(ApplicationInstance.prototype, 'container', { + configurable: true, + enumerable: false, + get: function () { + var instance = this; + return { + lookup: function () { + _emberMetal.deprecate('Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead.', false, { + id: 'ember-application.app-instance-container', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container' + }); + return instance.lookup.apply(instance, arguments); + } + }; + } + }); - return type + ':' + dasherizedName; + Object.defineProperty(ApplicationInstance.prototype, 'registry', { + configurable: true, + enumerable: false, + get: function () { + return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'ApplicationInstance'); } }); + + exports.default = ApplicationInstance; }); -enifed('ember-application/utils/validate-type', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application/system/application-instance', 'container', 'ember-application/system/engine', 'ember-glimmer'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRuntime, _emberViews, _emberRouting, _emberApplicationSystemApplicationInstance, _container, _emberApplicationSystemEngine, _emberGlimmer) { /** @module ember @submodule ember-application */ - - 'use strict'; - - exports.default = validateType; - - var VALIDATED_TYPES = { - route: ['assert', 'isRouteFactory', 'Ember.Route'], - component: ['deprecate', 'isComponentFactory', 'Ember.Component'], - view: ['deprecate', 'isViewFactory', 'Ember.View'], - service: ['deprecate', 'isServiceFactory', 'Ember.Service'] - }; - - function validateType(resolvedType, parsedName) { - var validationAttributes = VALIDATED_TYPES[parsedName.type]; - - if (!validationAttributes) { - return; - } - - var action = validationAttributes[0]; - var factoryFlag = validationAttributes[1]; - var expectedType = validationAttributes[2]; - - if (action === 'deprecate') { - _emberMetal.deprecate('In Ember 2.0 ' + parsedName.type + ' factories must have an `' + factoryFlag + '` ' + ('property set to true. You registered ' + resolvedType + ' as a ' + parsedName.type + ' ') + ('factory. Either add the `' + factoryFlag + '` property to this factory or ') + ('extend from ' + expectedType + '.'), !!resolvedType[factoryFlag], { id: 'ember-application.validate-type', until: '3.0.0' }); - } else { - _emberMetal.assert('Expected ' + parsedName.fullName + ' to resolve to an ' + expectedType + ' but ' + ('instead it was ' + resolvedType + '.'), !!resolvedType[factoryFlag]); - } - } -}); -enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { 'use strict'; - function K() {} - - function consoleMethod(name) { - var consoleObj = undefined; - if (_emberEnvironment.context.imports.console) { - consoleObj = _emberEnvironment.context.imports.console; - } else if (typeof console !== 'undefined') { - consoleObj = console; - } - - var method = typeof consoleObj === 'object' ? consoleObj[name] : null; - - if (typeof method !== 'function') { - return; - } - - if (typeof method.bind === 'function') { - return method.bind(consoleObj); - } - - return function () { - method.apply(consoleObj, arguments); - }; - } + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); - function assertPolyfill(test, message) { - if (!test) { - try { - // attempt to preserve the stack - throw new Error('assertion failed: ' + message); - } catch (error) { - setTimeout(function () { - throw error; - }, 0); - } - } - } + var librariesRegistered = false; /** - Inside Ember-Metal, simply uses the methods from `imports.console`. - Override this to provide more robust logging functionality. + An instance of `Ember.Application` is the starting point for every Ember + application. It helps to instantiate, initialize and coordinate the many + objects that make up your app. - @class Logger + Each Ember app has one and only one `Ember.Application` object. In fact, the + very first thing you should do in your application is create the instance: + + ```javascript + window.App = Ember.Application.create(); + ``` + + Typically, the application object is the only global variable. All other + classes in your app should be properties on the `Ember.Application` instance, + which highlights its first role: a global namespace. + + For example, if you define a view class, it might look like this: + + ```javascript + App.MyView = Ember.View.extend(); + ``` + + By default, calling `Ember.Application.create()` will automatically initialize + your application by calling the `Ember.Application.initialize()` method. If + you need to delay initialization, you can call your app's `deferReadiness()` + method. When you are ready for your app to be initialized, call its + `advanceReadiness()` method. + + You can define a `ready` method on the `Ember.Application` instance, which + will be run by Ember when the application is initialized. + + Because `Ember.Application` inherits from `Ember.Namespace`, any classes + you create will have useful string representations when calling `toString()`. + See the `Ember.Namespace` documentation for more information. + + While you can think of your `Ember.Application` as a container that holds the + other classes in your application, there are several other responsibilities + going on under-the-hood that you may want to understand. + + ### Event Delegation + + Ember uses a technique called _event delegation_. This allows the framework + to set up a global, shared event listener instead of requiring each view to + do it manually. For example, instead of each view registering its own + `mousedown` listener on its associated element, Ember sets up a `mousedown` + listener on the `body`. + + If a `mousedown` event occurs, Ember will look at the target of the event and + start walking up the DOM node tree, finding corresponding views and invoking + their `mouseDown` method as it goes. + + `Ember.Application` has a number of default events that it listens for, as + well as a mapping from lowercase events to camel-cased view method names. For + example, the `keypress` event causes the `keyPress` method on the view to be + called, the `dblclick` event causes `doubleClick` to be called, and so on. + + If there is a bubbling browser event that Ember does not listen for by + default, you can specify custom events and their corresponding view method + names by setting the application's `customEvents` property: + + ```javascript + let App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: 'paste' + } + }); + ``` + + To prevent Ember from setting up a listener for a default event, + specify the event name with a `null` value in the `customEvents` + property: + + ```javascript + let App = Ember.Application.create({ + customEvents: { + // prevent listeners for mouseenter/mouseleave events + mouseenter: null, + mouseleave: null + } + }); + ``` + + By default, the application sets up these event listeners on the document + body. However, in cases where you are embedding an Ember application inside + an existing page, you may want it to set up the listeners on an element + inside the body. + + For example, if only events inside a DOM element with the ID of `ember-app` + should be delegated, set your application's `rootElement` property: + + ```javascript + let App = Ember.Application.create({ + rootElement: '#ember-app' + }); + ``` + + The `rootElement` can be either a DOM element or a jQuery-compatible selector + string. Note that *views appended to the DOM outside the root element will + not receive events.* If you specify a custom root element, make sure you only + append views inside it! + + To learn more about the events Ember components use, see + [components/handling-events](https://guides.emberjs.com/v2.6.0/components/handling-events/#toc_event-names). + + ### Initializers + + Libraries on top of Ember can add initializers, like so: + + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + + initialize: function(application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + + Initializers provide an opportunity to access the internal registry, which + organizes the different components of an Ember application. Additionally + they provide a chance to access the instantiated application. Beyond + being used for libraries, initializers are also a great way to organize + dependency injection or setup in your own application. + + ### Routing + + In addition to creating your application's router, `Ember.Application` is + also responsible for telling the router when to start routing. Transitions + between routes can be logged with the `LOG_TRANSITIONS` flag, and more + detailed intra-transition logging can be logged with + the `LOG_TRANSITIONS_INTERNAL` flag: + + ```javascript + let App = Ember.Application.create({ + LOG_TRANSITIONS: true, // basic logging of successful transitions + LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps + }); + ``` + + By default, the router will begin trying to translate the current URL into + application state once the browser emits the `DOMContentReady` event. If you + need to defer routing, you can call the application's `deferReadiness()` + method. Once routing can begin, call the `advanceReadiness()` method. + + If there is any setup required before routing begins, you can implement a + `ready()` method on your app that will be invoked immediately before routing + begins. + + @class Application @namespace Ember + @extends Ember.Engine + @uses RegistryProxyMixin @public */ - exports.default = { + + var Application = _emberApplicationSystemEngine.default.extend({ /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.log('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method log - @for Ember.Logger - @param {*} arguments - @public + The root DOM element of the Application. This can be specified as an + element or a + [jQuery-compatible selector string](http://api.jquery.com/category/selectors/). + This is the element that will be passed to the Application's, + `eventDispatcher`, which sets up the listeners for event delegation. Every + view in your application should be a child of the element you specify here. + @property rootElement + @type DOMElement + @default 'body' + @public */ - log: consoleMethod('log') || K, + rootElement: 'body', /** - Prints the arguments to the console with a warning icon. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - Ember.Logger.warn('Something happened!'); - // "Something happened!" will be printed to the console with a warning icon. - ``` - @method warn - @for Ember.Logger - @param {*} arguments - @public + The `Ember.EventDispatcher` responsible for delegating events to this + application's views. + The event dispatcher is created by the application at initialization time + and sets up event listeners on the DOM element described by the + application's `rootElement` property. + See the documentation for `Ember.EventDispatcher` for more information. + @property eventDispatcher + @type Ember.EventDispatcher + @default null + @public */ - warn: consoleMethod('warn') || K, + eventDispatcher: null, /** - Prints the arguments to the console with an error icon, red text and a stack trace. - You can pass as many arguments as you want and they will be joined together with a space. + The DOM events for which the event dispatcher should listen. + By default, the application's `Ember.EventDispatcher` listens + for a set of standard DOM events, such as `mousedown` and + `keyup`, and delegates them to your application's `Ember.View` + instances. + If you would like additional bubbling events to be delegated to your + views, set your `Ember.Application`'s `customEvents` property + to a hash containing the DOM event name as the key and the + corresponding view method name as the value. Setting an event to + a value of `null` will prevent a default event listener from being + added for that event. + To add new events to be listened to: ```javascript - Ember.Logger.error('Danger! Danger!'); - // "Danger! Danger!" will be printed to the console in red text. + let App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: 'paste' + } + }); ``` - @method error - @for Ember.Logger - @param {*} arguments - @public - */ - error: consoleMethod('error') || K, - - /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. + To prevent default events from being listened to: ```javascript - var foo = 1; - Ember.Logger.info('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console + let App = Ember.Application.create({ + customEvents: { + // remove support for mouseenter / mouseleave events + mouseenter: null, + mouseleave: null + } + }); ``` - @method info - @for Ember.Logger - @param {*} arguments - @public + @property customEvents + @type Object + @default null + @public */ - info: consoleMethod('info') || K, + customEvents: null, /** - Logs the arguments to the console in blue text. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.debug('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method debug - @for Ember.Logger - @param {*} arguments - @public + Whether the application should automatically start routing and render + templates to the `rootElement` on DOM ready. While default by true, + other environments such as FastBoot or a testing harness can set this + property to `false` and control the precise timing and behavior of the boot + process. + @property autoboot + @type Boolean + @default true + @private */ - debug: consoleMethod('debug') || consoleMethod('info') || K, + autoboot: true, /** - If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. + Whether the application should be configured for the legacy "globals mode". + Under this mode, the Application object serves as a global namespace for all + classes. ```javascript - Ember.Logger.assert(true); // undefined - Ember.Logger.assert(true === false); // Throws an Assertion failed error. - Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message. + let App = Ember.Application.create({ + ... + }); + App.Router.reopen({ + location: 'none' + }); + App.Router.map({ + ... + }); + App.MyComponent = Ember.Component.extend({ + ... + }); ``` - @method assert - @for Ember.Logger - @param {Boolean} bool Value to test - @param {String} message Assertion message on failed - @public + This flag also exposes other internal APIs that assumes the existence of + a special "default instance", like `App.__container__.lookup(...)`. + This option is currently not configurable, its value is derived from + the `autoboot` flag – disabling `autoboot` also implies opting-out of + globals mode support, although they are ultimately orthogonal concerns. + Some of the global modes features are already deprecated in 1.x. The + existence of this flag is to untangle the globals mode code paths from + the autoboot code paths, so that these legacy features can be reviewed + for deprecation/removal separately. + Forcing the (autoboot=true, _globalsMode=false) here and running the tests + would reveal all the places where we are still relying on these legacy + behavior internally (mostly just tests). + @property _globalsMode + @type Boolean + @default true + @private */ - assert: consoleMethod('assert') || assertPolyfill - }; -}); -enifed('ember-debug/deprecate', ['exports', 'ember-metal', 'ember-console', 'ember-environment', 'ember-debug/handlers'], function (exports, _emberMetal, _emberConsole, _emberEnvironment, _emberDebugHandlers) { - /*global __fail__*/ + _globalsMode: true, - 'use strict'; + init: function (options) { + this._super.apply(this, arguments); - exports.registerHandler = registerHandler; - exports.default = deprecate; + if (!this.$) { + this.$ = _emberViews.jQuery; + } - function registerHandler(handler) { - _emberDebugHandlers.registerHandler('deprecate', handler); - } + registerLibraries(); + _emberMetal.runInDebug(function () { + return logLibraryVersions(); + }); - function formatMessage(_message, options) { - var message = _message; + // Start off the number of deferrals at 1. This will be decremented by + // the Application's own `boot` method. + this._readinessDeferrals = 1; + this._booted = false; - if (options && options.id) { - message = message + (' [deprecation id: ' + options.id + ']'); - } + this.autoboot = this._globalsMode = !!this.autoboot; - if (options && options.url) { - message += ' See ' + options.url + ' for more details.'; - } + if (this._globalsMode) { + this._prepareForGlobalsMode(); + } - return message; - } + if (this.autoboot) { + this.waitForDOMReady(); + } + }, - registerHandler(function logDeprecationToConsole(message, options) { - var updatedMessage = formatMessage(message, options); + /** + Create an ApplicationInstance for this application. + @private + @method buildInstance + @return {Ember.ApplicationInstance} the application instance + */ + buildInstance: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage); - }); + options.base = this; + options.application = this; + return _emberApplicationSystemApplicationInstance.default.create(options); + }, - var captureErrorForStack = undefined; + /** + Enable the legacy globals mode by allowing this application to act + as a global namespace. See the docs on the `_globalsMode` property + for details. + Most of these features are already deprecated in 1.x, so we can + stop using them internally and try to remove them. + @private + @method _prepareForGlobalsMode + */ + _prepareForGlobalsMode: function () { + // Create subclass of Ember.Router for this Application instance. + // This is to ensure that someone reopening `App.Router` does not + // tamper with the default `Ember.Router`. + this.Router = (this.Router || _emberRouting.Router).extend(); - if (new Error().stack) { - captureErrorForStack = function () { - return new Error(); - }; - } else { - captureErrorForStack = function () { - try { - __fail__.fail(); - } catch (e) { - return e; + this._buildDeprecatedInstance(); + }, + + /* + Build the deprecated instance for legacy globals mode support. + Called when creating and resetting the application. + This is orthogonal to autoboot: the deprecated instance needs to + be created at Application construction (not boot) time to expose + App.__container__. If autoboot sees that this instance exists, + it will continue booting it to avoid doing unncessary work (as + opposed to building a new instance at boot time), but they are + otherwise unrelated. + @private + @method _buildDeprecatedInstance + */ + _buildDeprecatedInstance: function () { + // Build a default instance + var instance = this.buildInstance(); + + // Legacy support for App.__container__ and other global methods + // on App that rely on a single, default instance. + this.__deprecatedInstance__ = instance; + this.__container__ = instance.__container__; + }, + + /** + Automatically kick-off the boot process for the application once the + DOM has become ready. + The initialization itself is scheduled on the actions queue which + ensures that code-loading finishes before booting. + If you are asynchronously loading code, you should call `deferReadiness()` + to defer booting, and then call `advanceReadiness()` once all of your code + has finished loading. + @private + @method waitForDOMReady + */ + waitForDOMReady: function () { + if (!this.$ || this.$.isReady) { + _emberMetal.run.schedule('actions', this, 'domReady'); + } else { + this.$().ready(_emberMetal.run.bind(this, 'domReady')); } - }; - } + }, - registerHandler(function logDeprecationStackTrace(message, options, next) { - if (_emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION) { - var stackStr = ''; - var error = captureErrorForStack(); - var stack = undefined; + /** + This is the autoboot flow: + 1. Boot the app by calling `this.boot()` + 2. Create an instance (or use the `__deprecatedInstance__` in globals mode) + 3. Boot the instance by calling `instance.boot()` + 4. Invoke the `App.ready()` callback + 5. Kick-off routing on the instance + Ideally, this is all we would need to do: + ```javascript + _autoBoot() { + this.boot().then(() => { + let instance = (this._globalsMode) ? this.__deprecatedInstance__ : this.buildInstance(); + return instance.boot(); + }).then((instance) => { + App.ready(); + instance.startRouting(); + }); + } + ``` + Unfortunately, we cannot actually write this because we need to participate + in the "synchronous" boot process. While the code above would work fine on + the initial boot (i.e. DOM ready), when `App.reset()` is called, we need to + boot a new instance synchronously (see the documentation on `_bootSync()` + for details). + Because of this restriction, the actual logic of this method is located + inside `didBecomeReady()`. + @private + @method domReady + */ + domReady: function () { + if (this.isDestroyed) { + return; + } - if (error.stack) { - if (error['arguments']) { - // Chrome - stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); - stack.shift(); - } else { - // Firefox - stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); - } + this._bootSync(); - stackStr = '\n ' + stack.slice(2).join('\n '); + // Continues to `didBecomeReady` + }, + + /** + Use this to defer readiness until some condition is true. + Example: + ```javascript + let App = Ember.Application.create(); + App.deferReadiness(); + // Ember.$ is a reference to the jQuery object/function + Ember.$.getJSON('/auth-token', function(token) { + App.token = token; + App.advanceReadiness(); + }); + ``` + This allows you to perform asynchronous setup logic and defer + booting your application until the setup has finished. + However, if the setup requires a loading UI, it might be better + to use the router for this purpose. + @method deferReadiness + @public + */ + deferReadiness: function () { + _emberMetal.assert('You must call deferReadiness on an instance of Ember.Application', this instanceof Application); + _emberMetal.assert('You cannot defer readiness since the `ready()` hook has already been called.', this._readinessDeferrals > 0); + this._readinessDeferrals++; + }, + + /** + Call `advanceReadiness` after any asynchronous setup logic has completed. + Each call to `deferReadiness` must be matched by a call to `advanceReadiness` + or the application will never become ready and routing will not begin. + @method advanceReadiness + @see {Ember.Application#deferReadiness} + @public + */ + advanceReadiness: function () { + _emberMetal.assert('You must call advanceReadiness on an instance of Ember.Application', this instanceof Application); + this._readinessDeferrals--; + + if (this._readinessDeferrals === 0) { + _emberMetal.run.once(this, this.didBecomeReady); } + }, - var updatedMessage = formatMessage(message, options); + /** + Initialize the application and return a promise that resolves with the `Ember.Application` + object when the boot process is complete. + Run any application initializers and run the application load hook. These hooks may + choose to defer readiness. For example, an authentication hook might want to defer + readiness until the auth token has been retrieved. + By default, this method is called automatically on "DOM ready"; however, if autoboot + is disabled, this is automatically called when the first application instance is + created via `visit`. + @private + @method boot + @return {Promise} + */ + boot: function () { + if (this._bootPromise) { + return this._bootPromise; + } - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage + stackStr); - } else { - next.apply(undefined, arguments); - } - }); + try { + this._bootSync(); + } catch (_) { + // Ignore th error: in the asynchronous boot path, the error is already reflected + // in the promise rejection + } - registerHandler(function raiseOnDeprecation(message, options, next) { - if (_emberEnvironment.ENV.RAISE_ON_DEPRECATION) { - var updatedMessage = formatMessage(message); + return this._bootPromise; + }, - throw new _emberMetal.Error(updatedMessage); - } else { - next.apply(undefined, arguments); - } - }); + /** + Unfortunately, a lot of existing code assumes the booting process is + "synchronous". Specifically, a lot of tests assumes the last call to + `app.advanceReadiness()` or `app.reset()` will result in the app being + fully-booted when the current runloop completes. + We would like new code (like the `visit` API) to stop making this assumption, + so we created the asynchronous version above that returns a promise. But until + we have migrated all the code, we would have to expose this method for use + *internally* in places where we need to boot an app "synchronously". + @private + */ + _bootSync: function () { + if (this._booted) { + return; + } - var missingOptionsDeprecation = 'When calling `Ember.deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; - exports.missingOptionsDeprecation = missingOptionsDeprecation; - var missingOptionsIdDeprecation = 'When calling `Ember.deprecate` you must provide `id` in options.'; - exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; - var missingOptionsUntilDeprecation = 'When calling `Ember.deprecate` you must provide `until` in options.'; + // Even though this returns synchronously, we still need to make sure the + // boot promise exists for book-keeping purposes: if anything went wrong in + // the boot process, we need to store the error as a rejection on the boot + // promise so that a future caller of `boot()` can tell what failed. + var defer = this._bootResolver = new _emberRuntime.RSVP.defer(); + this._bootPromise = defer.promise; - exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation; - /** - @module ember - @submodule ember-debug - */ + try { + this.runInitializers(); + _emberRuntime.runLoadHooks('application', this); + this.advanceReadiness(); + // Continues to `didBecomeReady` + } catch (error) { + // For the asynchronous boot path + defer.reject(error); - /** - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only). - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method deprecate - @param {String} message A description of the deprecation. - @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. - @param {Object} options - @param {String} options.id A unique id for this deprecation. The id can be - used by Ember debugging tools to change the behavior (raise, log or silence) - for that specific deprecation. The id should be namespaced by dots, e.g. - "view.helper.select". - @param {string} options.until The version of Ember when this deprecation - warning will be removed. - @param {String} [options.url] An optional url to the transition guide on the - emberjs.com website. - @for Ember - @public - */ + // For the synchronous boot path + throw error; + } + }, - function deprecate(message, test, options) { - if (!options || !options.id && !options.until) { - deprecate(missingOptionsDeprecation, false, { - id: 'ember-debug.deprecate-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + /** + Reset the application. This is typically used only in tests. It cleans up + the application in the following order: + 1. Deactivate existing routes + 2. Destroy all objects in the container + 3. Create a new application container + 4. Re-route to the existing url + Typical Example: + ```javascript + let App; + run(function() { + App = Ember.Application.create(); }); - } - - if (options && !options.id) { - deprecate(missingOptionsIdDeprecation, false, { - id: 'ember-debug.deprecate-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + module('acceptance test', { + setup: function() { + App.reset(); + } }); - } - - if (options && !options.until) { - deprecate(missingOptionsUntilDeprecation, options && options.until, { - id: 'ember-debug.deprecate-until-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + test('first test', function() { + // App is freshly reset }); - } + test('second test', function() { + // App is again freshly reset + }); + ``` + Advanced Example: + Occasionally you may want to prevent the app from initializing during + setup. This could enable extra configuration, or enable asserting prior + to the app becoming ready. + ```javascript + let App; + run(function() { + App = Ember.Application.create(); + }); + module('acceptance test', { + setup: function() { + run(function() { + App.reset(); + App.deferReadiness(); + }); + } + }); + test('first test', function() { + ok(true, 'something before app is initialized'); + run(function() { + App.advanceReadiness(); + }); + ok(true, 'something after app is initialized'); + }); + ``` + @method reset + @public + */ + reset: function () { + _emberMetal.assert('Calling reset() on instances of `Ember.Application` is not\n supported when globals mode is disabled; call `visit()` to\n create new `Ember.ApplicationInstance`s and dispose them\n via their `destroy()` method instead.', this._globalsMode && this.autoboot); - _emberDebugHandlers.invoke.apply(undefined, ['deprecate'].concat(babelHelpers.slice.call(arguments))); - } -}); -enifed("ember-debug/handlers", ["exports"], function (exports) { - "use strict"; + var instance = this.__deprecatedInstance__; - exports.registerHandler = registerHandler; - exports.invoke = invoke; - var HANDLERS = {}; + this._readinessDeferrals = 1; + this._bootPromise = null; + this._bootResolver = null; + this._booted = false; - exports.HANDLERS = HANDLERS; + function handleReset() { + _emberMetal.run(instance, 'destroy'); + this._buildDeprecatedInstance(); + _emberMetal.run.schedule('actions', this, '_bootSync'); + } - function registerHandler(type, callback) { - var nextHandler = HANDLERS[type] || function () {}; + _emberMetal.run.join(this, handleReset); + }, - HANDLERS[type] = function (message, options) { - callback(message, options, nextHandler); - }; - } + /** + @private + @method didBecomeReady + */ + didBecomeReady: function () { + try { + // TODO: Is this still needed for _globalsMode = false? + if (!_emberMetal.isTesting()) { + // Eagerly name all classes that are already loaded + _emberRuntime.Namespace.processAll(); + _emberRuntime.setNamespaceSearchDisabled(true); + } - function invoke(type, message, test, options) { - if (test) { - return; - } + // See documentation on `_autoboot()` for details + if (this.autoboot) { + var instance = undefined; - var handlerForType = HANDLERS[type]; + if (this._globalsMode) { + // If we already have the __deprecatedInstance__ lying around, boot it to + // avoid unnecessary work + instance = this.__deprecatedInstance__; + } else { + // Otherwise, build an instance and boot it. This is currently unreachable, + // because we forced _globalsMode to === autoboot; but having this branch + // allows us to locally toggle that flag for weeding out legacy globals mode + // dependencies independently + instance = this.buildInstance(); + } - if (!handlerForType) { - return; - } + instance._bootSync(); - if (handlerForType) { - handlerForType(message, options); - } - } -}); -enifed('ember-debug/index', ['exports', 'ember-metal', 'ember-environment', 'ember-console', 'ember-debug/deprecate', 'ember-debug/warn'], function (exports, _emberMetal, _emberEnvironment, _emberConsole, _emberDebugDeprecate, _emberDebugWarn) { - 'use strict'; + // TODO: App.ready() is not called when autoboot is disabled, is this correct? + this.ready(); - exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; + instance.startRouting(); + } - /** - @module ember - @submodule ember-debug - */ + // For the asynchronous boot path + this._bootResolver.resolve(this); - /** - @class Ember - @public - */ + // For the synchronous boot path + this._booted = true; + } catch (error) { + // For the asynchronous boot path + this._bootResolver.reject(error); - /** - Define an assertion that will throw an exception if the condition is not met. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - // Test for truthiness - Ember.assert('Must pass a valid object', obj); - - // Fail unconditionally - Ember.assert('This code path should never be run'); - ``` - - @method assert - @param {String} desc A description of the assertion. This will become - the text of the Error thrown if the assertion fails. - @param {Boolean} test Must be truthy for the assertion to pass. If - falsy, an exception will be thrown. - @public - */ - _emberMetal.setDebugFunction('assert', function assert(desc, test) { - if (!test) { - throw new _emberMetal.Error('Assertion Failed: ' + desc); - } - }); + // For the synchronous boot path + throw error; + } + }, - /** - Display a debug notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.debug('I\'m a debug notice!'); - ``` - - @method debug - @param {String} message A debug message to display. - @public - */ - _emberMetal.setDebugFunction('debug', function debug(message) { - _emberConsole.default.debug('DEBUG: ' + message); - }); + /** + Called when the Application has become ready, immediately before routing + begins. The call will be delayed until the DOM has become ready. + @event ready + @public + */ + ready: function () { + return this; + }, - /** - Display an info notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method info - @private - */ - _emberMetal.setDebugFunction('info', function info() { - _emberConsole.default.info.apply(undefined, arguments); - }); + // This method must be moved to the application instance object + willDestroy: function () { + this._super.apply(this, arguments); + _emberRuntime.setNamespaceSearchDisabled(false); + this._booted = false; + this._bootPromise = null; + this._bootResolver = null; - /** - Alias an old, deprecated method with its new counterpart. - - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only) when the assigned method is called. - - * In a production build, this method is defined as an empty function (NOP). - - ```javascript - Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod); - ``` - - @method deprecateFunc - @param {String} message A description of the deprecation. - @param {Object} [options] The options object for Ember.deprecate. - @param {Function} func The new function called to replace its deprecated counterpart. - @return {Function} A new function that wraps the original function with a deprecation warning - @private - */ - _emberMetal.setDebugFunction('deprecateFunc', function deprecateFunc() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + if (_emberRuntime._loaded.application === this) { + _emberRuntime._loaded.application = undefined; + } - if (args.length === 3) { - var _ret = (function () { - var message = args[0]; - var options = args[1]; - var func = args[2]; + if (this._globalsMode && this.__deprecatedInstance__) { + this.__deprecatedInstance__.destroy(); + } + }, - return { - v: function () { - _emberMetal.deprecate(message, false, options); - return func.apply(this, arguments); - } + /** + Boot a new instance of `Ember.ApplicationInstance` for the current + application and navigate it to the given `url`. Returns a `Promise` that + resolves with the instance when the initial routing and rendering is + complete, or rejects with any error that occured during the boot process. + When `autoboot` is disabled, calling `visit` would first cause the + application to boot, which runs the application initializers. + This method also takes a hash of boot-time configuration options for + customizing the instance's behavior. See the documentation on + `Ember.ApplicationInstance.BootOptions` for details. + `Ember.ApplicationInstance.BootOptions` is an interface class that exists + purely to document the available options; you do not need to construct it + manually. Simply pass a regular JavaScript object containing of the + desired options: + ```javascript + MyApp.visit("/", { location: "none", rootElement: "#container" }); + ``` + ### Supported Scenarios + While the `BootOptions` class exposes a large number of knobs, not all + combinations of them are valid; certain incompatible combinations might + result in unexpected behavior. + For example, booting the instance in the full browser environment + while specifying a foriegn `document` object (e.g. `{ isBrowser: true, + document: iframe.contentDocument }`) does not work correctly today, + largely due to Ember's jQuery dependency. + Currently, there are three officially supported scenarios/configurations. + Usages outside of these scenarios are not guaranteed to work, but please + feel free to file bug reports documenting your experience and any issues + you encountered to help expand support. + #### Browser Applications (Manual Boot) + The setup is largely similar to how Ember works out-of-the-box. Normally, + Ember will boot a default instance for your Application on "DOM ready". + However, you can customize this behavior by disabling `autoboot`. + For example, this allows you to render a miniture demo of your application + into a specific area on your marketing website: + ```javascript + import MyApp from 'my-app'; + $(function() { + let App = MyApp.create({ autoboot: false }); + let options = { + // Override the router's location adapter to prevent it from updating + // the URL in the address bar + location: 'none', + // Override the default `rootElement` on the app to render into a + // specific `div` on the page + rootElement: '#demo' }; - })(); - - if (typeof _ret === 'object') return _ret.v; - } else { - var _ret2 = (function () { - var message = args[0]; - var func = args[1]; - - return { - v: function () { - _emberMetal.deprecate(message); - return func.apply(this, arguments); + // Start the app at the special demo URL + App.visit('/demo', options); + }); + ```` + Or perhaps you might want to boot two instances of your app on the same + page for a split-screen multiplayer experience: + ```javascript + import MyApp from 'my-app'; + $(function() { + let App = MyApp.create({ autoboot: false }); + let sessionId = MyApp.generateSessionID(); + let player1 = App.visit(`/matches/join?name=Player+1&session=${sessionId}`, { rootElement: '#left', location: 'none' }); + let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#right', location: 'none' }); + Promise.all([player1, player2]).then(() => { + // Both apps have completed the initial render + $('#loading').fadeOut(); + }); + }); + ``` + Do note that each app instance maintains their own registry/container, so + they will run in complete isolation by default. + #### Server-Side Rendering (also known as FastBoot) + This setup allows you to run your Ember app in a server environment using + Node.js and render its content into static HTML for SEO purposes. + ```javascript + const HTMLSerializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); + function renderURL(url) { + let dom = new SimpleDOM.Document(); + let rootElement = dom.body; + let options = { isBrowser: false, document: dom, rootElement: rootElement }; + return MyApp.visit(options).then(instance => { + try { + return HTMLSerializer.serialize(rootElement.firstChild); + } finally { + instance.destroy(); } - }; - })(); + }); + } + ``` + In this scenario, because Ember does not have access to a global `document` + object in the Node.js environment, you must provide one explicitly. In practice, + in the non-browser environment, the stand-in `document` object only need to + implement a limited subset of the full DOM API. The `SimpleDOM` library is known + to work. + Since there is no access to jQuery in the non-browser environment, you must also + specify a DOM `Element` object in the same `document` for the `rootElement` option + (as opposed to a selector string like `"body"`). + See the documentation on the `isBrowser`, `document` and `rootElement` properties + on `Ember.ApplicationInstance.BootOptions` for details. + #### Server-Side Resource Discovery + This setup allows you to run the routing layer of your Ember app in a server + environment using Node.js and completely disable rendering. This allows you + to simulate and discover the resources (i.e. AJAX requests) needed to fufill + a given request and eagerly "push" these resources to the client. + ```app/initializers/network-service.js + import BrowserNetworkService from 'app/services/network/browser'; + import NodeNetworkService from 'app/services/network/node'; + // Inject a (hypothetical) service for abstracting all AJAX calls and use + // the appropiate implementaion on the client/server. This also allows the + // server to log all the AJAX calls made during a particular request and use + // that for resource-discovery purpose. + export function initialize(application) { + if (window) { // browser + application.register('service:network', BrowserNetworkService); + } else { // node + application.register('service:network', NodeNetworkService); + } + application.inject('route', 'network', 'service:network'); + }; + export default { + name: 'network-service', + initialize: initialize + }; + ``` + ```app/routes/post.js + import Ember from 'ember'; + // An example of how the (hypothetical) service is used in routes. + export default Ember.Route.extend({ + model(params) { + return this.network.fetch(`/api/posts/${params.post_id}.json`); + }, + afterModel(post) { + if (post.isExternalContent) { + return this.network.fetch(`/api/external/?url=${post.externalURL}`); + } else { + return post; + } + } + }); + ``` + ```javascript + // Finally, put all the pieces together + function discoverResourcesFor(url) { + return MyApp.visit(url, { isBrowser: false, shouldRender: false }).then(instance => { + let networkService = instance.lookup('service:network'); + return networkService.requests; // => { "/api/posts/123.json": "..." } + }); + } + ``` + @public + @method visit + @param url {String} The initial URL to navigate to + @param options {Ember.ApplicationInstance.BootOptions} + @return {Promise} + */ + visit: function (url, options) { + var _this = this; - if (typeof _ret2 === 'object') return _ret2.v; - } - }); + return this.boot().then(function () { + var instance = _this.buildInstance(); - /** - Run a function meant for debugging. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.runInDebug(() => { - Ember.Component.reopen({ - didInsertElement() { - console.log("I'm happy"); - } + return instance.boot(options).then(function () { + return instance.visit(url); + }).catch(function (error) { + _emberMetal.run(instance, 'destroy'); + throw error; + }); }); - }); - ``` - - @method runInDebug - @param {Function} func The function to be executed. - @since 1.5.0 - @public - */ - _emberMetal.setDebugFunction('runInDebug', function runInDebug(func) { - func(); + } }); - _emberMetal.setDebugFunction('debugSeal', function debugSeal(obj) { - Object.seal(obj); + Object.defineProperty(Application.prototype, 'registry', { + configurable: true, + enumerable: false, + get: function () { + return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'Application'); + } }); - _emberMetal.setDebugFunction('debugFreeze', function debugFreeze(obj) { - Object.freeze(obj); + Application.reopenClass({ + /** + This creates a registry with the default Ember naming conventions. + It also configures the registry: + * registered views are created every time they are looked up (they are + not singletons) + * registered templates are not factories; the registered value is + returned directly. + * the router receives the application as its `namespace` property + * all controllers receive the router as their `target` and `controllers` + properties + * all controllers receive the application as their `namespace` property + * the application view receives the application controller as its + `controller` property + * the application view receives the application template as its + `defaultTemplate` property + @method buildRegistry + @static + @param {Ember.Application} namespace the application for which to + build the registry + @return {Ember.Registry} the built registry + @private + */ + buildRegistry: function (application) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var registry = this._super.apply(this, arguments); + + commonSetupRegistry(registry); + + _emberGlimmer.setupApplicationRegistry(registry); + + return registry; + } }); - _emberMetal.setDebugFunction('deprecate', _emberDebugDeprecate.default); + function commonSetupRegistry(registry) { + registry.register('-view-registry:main', { create: function () { + return _emberUtils.dictionary(null); + } }); - _emberMetal.setDebugFunction('warn', _emberDebugWarn.default); + registry.register('route:basic', _emberRouting.Route); + registry.register('event_dispatcher:main', _emberViews.EventDispatcher); - /** - Will call `Ember.warn()` if ENABLE_OPTIONAL_FEATURES or - any specific FEATURES flag is truthy. - - This method is called automatically in debug canary builds. - - @private - @method _warnIfUsingStrippedFeatureFlags - @return {void} - */ + registry.injection('router:main', 'namespace', 'application:main'); - function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featuresWereStripped) { - if (featuresWereStripped) { - _emberMetal.warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + registry.register('location:auto', _emberRouting.AutoLocation); + registry.register('location:hash', _emberRouting.HashLocation); + registry.register('location:history', _emberRouting.HistoryLocation); + registry.register('location:none', _emberRouting.NoneLocation); - var keys = Object.keys(FEATURES || {}); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key === 'isEnabled' || !(key in knownFeatures)) { - continue; - } + registry.register(_container.privatize(_templateObject), _emberRouting.BucketCache); - _emberMetal.warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); - } + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + registry.register('service:router', _emberRouting.RouterService); + registry.injection('service:router', 'router', 'router:main'); } } - if (!_emberMetal.isTesting()) { - (function () { - // Complain if they're using FEATURE flags in builds other than canary - _emberMetal.FEATURES['features-stripped-test'] = true; - var featuresWereStripped = true; + function registerLibraries() { + if (!librariesRegistered) { + librariesRegistered = true; - if (false) { - featuresWereStripped = false; + if (_emberEnvironment.environment.hasDOM && typeof _emberViews.jQuery === 'function') { + _emberMetal.libraries.registerCoreLibrary('jQuery', _emberViews.jQuery().jquery); } + } + } - delete _emberMetal.FEATURES['features-stripped-test']; - _warnIfUsingStrippedFeatureFlags(_emberEnvironment.ENV.FEATURES, _emberMetal.DEFAULT_FEATURES, featuresWereStripped); + function logLibraryVersions() { + var _this2 = this; - // Inform the developer about the Ember Inspector if not installed. - var isFirefox = _emberEnvironment.environment.isFirefox; - var isChrome = _emberEnvironment.environment.isChrome; + _emberMetal.runInDebug(function () { + if (_emberEnvironment.ENV.LOG_VERSION) { + // we only need to see this once per Application#init + _emberEnvironment.ENV.LOG_VERSION = false; + var libs = _emberMetal.libraries._registry; - if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { - window.addEventListener('load', function () { - if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) { - var downloadURL; + var nameLengths = libs.map(function (item) { + return _emberMetal.get(item, 'name.length'); + }); - if (isChrome) { - downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'; - } else if (isFirefox) { - downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; - } + var maxNameLength = Math.max.apply(_this2, nameLengths); - _emberMetal.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); - } - }, false); + _emberMetal.debug('-------------------------------'); + for (var i = 0; i < libs.length; i++) { + var lib = libs[i]; + var spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); + _emberMetal.debug([lib.name, spaces, ' : ', lib.version].join('')); + } + _emberMetal.debug('-------------------------------'); } - })(); + }); } - /** - @public - @class Ember.Debug - */ - _emberMetal.default.Debug = {}; + exports.default = Application; +}); +enifed('ember-application/system/engine-instance', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'container', 'ember-application/system/engine-parent'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _container, _emberApplicationSystemEngineParent) { /** - Allows for runtime registration of handler functions that override the default deprecation behavior. - Deprecations are invoked by calls to [Ember.deprecate](http://emberjs.com/api/classes/Ember.html#method_deprecate). - The following example demonstrates its usage by registering a handler that throws an error if the - message contains the word "should", otherwise defers to the default handler. - - ```javascript - Ember.Debug.registerDeprecationHandler((message, options, next) => { - if (message.indexOf('should') !== -1) { - throw new Error(`Deprecation message with should: ${message}`); - } else { - // defer to whatever handler was registered before this one - next(message, options); - } - }); - ``` - - The handler function takes the following arguments: - -
      -
    • message - The message received from the deprecation call.
    • -
    • options - An object passed in with the deprecation call containing additional information including:
    • -
        -
      • id - An id of the deprecation in the form of package-name.specific-deprecation.
      • -
      • until - The Ember version number the feature and deprecation will be removed in.
      • -
      -
    • next - A function that calls into the previously registered handler.
    • -
    - - @public - @static - @method registerDeprecationHandler - @param handler {Function} A function to handle deprecation calls. - @since 2.1.0 + @module ember + @submodule ember-application */ - _emberMetal.default.Debug.registerDeprecationHandler = _emberDebugDeprecate.registerHandler; + + 'use strict'; + + var _EmberObject$extend; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + /** - Allows for runtime registration of handler functions that override the default warning behavior. - Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). - The following example demonstrates its usage by registering a handler that does nothing overriding Ember's - default warning behavior. - - ```javascript - // next is not called, so no warnings get the default behavior - Ember.Debug.registerWarnHandler(() => {}); - ``` - - The handler function takes the following arguments: - -
      -
    • message - The message received from the warn call.
    • -
    • options - An object passed in with the warn call containing additional information including:
    • -
        -
      • id - An id of the warning in the form of package-name.specific-warning.
      • -
      -
    • next - A function that calls into the previously registered handler.
    • -
    + The `EngineInstance` encapsulates all of the stateful aspects of a + running `Engine`. @public - @static - @method registerWarnHandler - @param handler {Function} A function to handle warnings. - @since 2.1.0 + @class Ember.EngineInstance + @extends Ember.Object + @uses RegistryProxyMixin + @uses ContainerProxyMixin */ - _emberMetal.default.Debug.registerWarnHandler = _emberDebugWarn.registerHandler; - /* - We are transitioning away from `ember.js` to `ember.debug.js` to make - it much clearer that it is only for local development purposes. - - This flag value is changed by the tooling (by a simple string replacement) - so that if `ember.js` (which must be output for backwards compat reasons) is - used a nice helpful warning message will be printed out. - */ - var runningNonEmberDebugJS = false; - exports.runningNonEmberDebugJS = runningNonEmberDebugJS; - if (runningNonEmberDebugJS) { - _emberMetal.warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); - } -}); -// reexports -enifed('ember-debug/warn', ['exports', 'ember-console', 'ember-metal', 'ember-debug/handlers'], function (exports, _emberConsole, _emberMetal, _emberDebugHandlers) { - 'use strict'; + var EngineInstance = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, (_EmberObject$extend = { + /** + The base `Engine` for which this is an instance. + @property {Ember.Engine} engine + @private + */ + base: null, - exports.registerHandler = registerHandler; - exports.default = warn; + init: function () { + this._super.apply(this, arguments); - function registerHandler(handler) { - _emberDebugHandlers.registerHandler('warn', handler); - } + _emberUtils.guidFor(this); - registerHandler(function logWarning(message, options) { - _emberConsole.default.warn('WARNING: ' + message); - if ('trace' in _emberConsole.default) { - _emberConsole.default.trace(); - } - }); + var base = this.base; - var missingOptionsDeprecation = 'When calling `Ember.warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; - exports.missingOptionsDeprecation = missingOptionsDeprecation; - var missingOptionsIdDeprecation = 'When calling `Ember.warn` you must provide `id` in options.'; + if (!base) { + base = this.application; + this.base = base; + } - exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; - /** - @module ember - @submodule ember-debug - */ + // Create a per-instance registry that will use the application's registry + // as a fallback for resolving registrations. + var registry = this.__registry__ = new _container.Registry({ + fallback: base.__registry__ + }); - /** - Display a warning with the provided message. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method warn - @param {String} message A warning to display. - @param {Boolean} test An optional boolean. If falsy, the warning - will be displayed. - @param {Object} options An object that can be used to pass a unique - `id` for this warning. The `id` can be used by Ember debugging tools - to change the behavior (raise, log, or silence) for that specific warning. - The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" - @for Ember - @public - */ + // Create a per-instance container from the instance's registry + this.__container__ = registry.container({ owner: this }); - function warn(message, test, options) { - if (!options) { - _emberMetal.deprecate(missingOptionsDeprecation, false, { - id: 'ember-debug.warn-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + this._booted = false; + }, - if (options && !options.id) { - _emberMetal.deprecate(missingOptionsIdDeprecation, false, { - id: 'ember-debug.warn-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + /** + Initialize the `Ember.EngineInstance` and return a promise that resolves + with the instance itself when the boot process is complete. + The primary task here is to run any registered instance initializers. + See the documentation on `BootOptions` for the options it takes. + @private + @method boot + @param options {Object} + @return {Promise} + */ + boot: function (options) { + var _this = this; + + if (this._bootPromise) { + return this._bootPromise; + } + + this._bootPromise = new _emberRuntime.RSVP.Promise(function (resolve) { + return resolve(_this._bootSync(options)); }); - } - _emberDebugHandlers.invoke.apply(undefined, ['warn'].concat(babelHelpers.slice.call(arguments))); - } -}); -enifed('ember-environment/global', ['exports'], function (exports) { - /* globals global, window, self, mainContext */ + return this._bootPromise; + }, - // from lodash to catch fake globals - 'use strict'; + /** + Unfortunately, a lot of existing code assumes booting an instance is + synchronous – specifically, a lot of tests assume the last call to + `app.advanceReadiness()` or `app.reset()` will result in a new instance + being fully-booted when the current runloop completes. + We would like new code (like the `visit` API) to stop making this + assumption, so we created the asynchronous version above that returns a + promise. But until we have migrated all the code, we would have to expose + this method for use *internally* in places where we need to boot an instance + synchronously. + @private + */ + _bootSync: function (options) { + if (this._booted) { + return this; + } - function checkGlobal(value) { - return value && value.Object === Object ? value : undefined; - } + _emberMetal.assert('An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.', _emberApplicationSystemEngineParent.getEngineParent(this)); - // element ids can ruin global miss checks - function checkElementIdShadowing(value) { - return value && value.nodeType === undefined ? value : undefined; - } + this.cloneParentDependencies(); - // export real global - exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper - new Function('return this')(); - // eval outside of strict mode -}); -enifed('ember-environment/index', ['exports', 'ember-environment/global', 'ember-environment/utils'], function (exports, _emberEnvironmentGlobal, _emberEnvironmentUtils) { - /* globals module */ - 'use strict'; + this.setupRegistry(options); - /** - 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 - backwards compatibility with earlier versions of Ember). The `EmberENV` - hash must be created before loading Ember. - - @class EmberENV - @type Object - @public - */ - var ENV = typeof _emberEnvironmentGlobal.default.EmberENV === 'object' && _emberEnvironmentGlobal.default.EmberENV || typeof _emberEnvironmentGlobal.default.ENV === 'object' && _emberEnvironmentGlobal.default.ENV || {}; + this.base.runInstanceInitializers(this); - exports.ENV = ENV; - // ENABLE_ALL_FEATURES was documented, but you can't actually enable non optional features. - if (ENV.ENABLE_ALL_FEATURES) { - ENV.ENABLE_OPTIONAL_FEATURES = true; - } + this._booted = true; - /** - Determines whether Ember should add to `Array`, `Function`, and `String` - native object prototypes, a few extra methods in order to provide a more - friendly API. - - We generally recommend leaving this option set to true however, if you need - to turn it off, you can add the configuration property - `EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`. - - Note, when disabled (the default configuration for Ember Addons), you will - instead have to access all methods and functions from the Ember - namespace. - - @property EXTEND_PROTOTYPES - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.EXTEND_PROTOTYPES = _emberEnvironmentUtils.normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); + return this; + }, - /** - The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log - a full stack trace during deprecation warnings. - - @property LOG_STACKTRACE_ON_DEPRECATION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_STACKTRACE_ON_DEPRECATION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); + setupRegistry: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? this.__container__.lookup('-environment:main') : arguments[0]; - /** - The `LOG_VERSION` property, when true, tells Ember to log versions of all - dependent libraries in use. - - @property LOG_VERSION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_VERSION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_VERSION); + this.constructor.setupRegistry(this.__registry__, options); + }, - // default false - ENV.MODEL_FACTORY_INJECTIONS = _emberEnvironmentUtils.defaultFalse(ENV.MODEL_FACTORY_INJECTIONS); + /** + Unregister a factory. + Overrides `RegistryProxy#unregister` in order to clear any cached instances + of the unregistered factory. + @public + @method unregister + @param {String} fullName + */ + unregister: function (fullName) { + this.__container__.reset(fullName); + this._super.apply(this, arguments); + }, - /** - Debug parameter you can turn on. This will log all bindings that fire to - the console. This should be disabled in production code. Note that you - can also enable this from the console or temporarily. - - @property LOG_BINDINGS - @for EmberENV - @type Boolean - @default false - @public - */ - ENV.LOG_BINDINGS = _emberEnvironmentUtils.defaultFalse(ENV.LOG_BINDINGS); + /** + @private + */ + willDestroy: function () { + this._super.apply(this, arguments); + _emberMetal.run(this.__container__, 'destroy'); + }, - ENV.RAISE_ON_DEPRECATION = _emberEnvironmentUtils.defaultFalse(ENV.RAISE_ON_DEPRECATION); + /** + Build a new `Ember.EngineInstance` that's a child of this instance. + Engines must be registered by name with their parent engine + (or application). + @private + @method buildChildEngineInstance + @param name {String} the registered name of the engine. + @param options {Object} options provided to the engine instance. + @return {Ember.EngineInstance,Error} + */ + buildChildEngineInstance: function (name) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - // check if window exists and actually is the global - var hasDOM = typeof window !== 'undefined' && window === _emberEnvironmentGlobal.default && window.document && window.document.createElement && !ENV.disableBrowserEnvironment; // is this a public thing? + var Engine = this.lookup('engine:' + name); - // legacy imports/exports/lookup stuff (should we keep this??) - var originalContext = _emberEnvironmentGlobal.default.Ember || {}; + if (!Engine) { + throw new _emberMetal.Error('You attempted to mount the engine \'' + name + '\', but it is not registered with its parent.'); + } - var context = { - // import jQuery - imports: originalContext.imports || _emberEnvironmentGlobal.default, - // export Ember - exports: originalContext.exports || _emberEnvironmentGlobal.default, - // search for Namespaces - lookup: originalContext.lookup || _emberEnvironmentGlobal.default - }; + var engineInstance = Engine.buildInstance(options); - exports.context = context; - // TODO: cleanup single source of truth issues with this stuff - var environment = hasDOM ? { - hasDOM: true, - isChrome: !!window.chrome && !window.opera, - isFirefox: typeof InstallTrigger !== 'undefined', - isPhantom: !!window.callPhantom, - location: window.location, - history: window.history, - userAgent: window.navigator.userAgent, - window: window - } : { - hasDOM: false, - isChrome: false, - isFirefox: false, - isPhantom: false, - location: null, - history: null, - userAgent: 'Lynx (textmode)', - window: null - }; - exports.environment = environment; -}); -enifed("ember-environment/utils", ["exports"], function (exports) { - "use strict"; + _emberApplicationSystemEngineParent.setEngineParent(engineInstance, this); - exports.defaultTrue = defaultTrue; - exports.defaultFalse = defaultFalse; - exports.normalizeExtendPrototypes = normalizeExtendPrototypes; + return engineInstance; + }, - function defaultTrue(v) { - return v === false ? false : true; - } + /** + Clone dependencies shared between an engine instance and its parent. + @private + @method cloneParentDependencies + */ + cloneParentDependencies: function () { + var _this2 = this; - function defaultFalse(v) { - return v === true ? true : false; - } + var parent = _emberApplicationSystemEngineParent.getEngineParent(this); - function normalizeExtendPrototypes(obj) { - if (obj === false) { - return { String: false, Array: false, Function: false }; - } else if (!obj || obj === true) { - return { String: true, Array: true, Function: true }; - } else { - return { - String: defaultTrue(obj.String), - Array: defaultTrue(obj.Array), - Function: defaultTrue(obj.Function) - }; + var registrations = ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment']; + + registrations.forEach(function (key) { + return _this2.register(key, parent.resolveRegistration(key)); + }); + + var env = parent.lookup('-environment:main'); + this.register('-environment:main', env, { instantiate: false }); + + var singletons = ['router:main', _container.privatize(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert')]; + + singletons.forEach(function (key) { + return _this2.register(key, parent.lookup(key), { instantiate: false }); + }); + + this.inject('view', '_environment', '-environment:main'); + this.inject('route', '_environment', '-environment:main'); } - } + + }, _EmberObject$extend[_container.FACTORY_FOR] = function (fullName, options) { + return this.__container__[_container.FACTORY_FOR](fullName, options); + }, _EmberObject$extend[_container.LOOKUP_FACTORY] = function (fullName, options) { + return this.__container__[_container.LOOKUP_FACTORY](fullName, options); + }, _EmberObject$extend)); + + EngineInstance.reopenClass({ + /** + @private + @method setupRegistry + @param {Registry} registry + @param {BootOptions} options + */ + setupRegistry: function (registry, options) { + // when no options/environment is present, do nothing + if (!options) { + return; + } + + registry.injection('view', '_environment', '-environment:main'); + registry.injection('route', '_environment', '-environment:main'); + + if (options.isInteractive) { + registry.injection('view', 'renderer', 'renderer:-dom'); + registry.injection('component', 'renderer', 'renderer:-dom'); + } else { + registry.injection('view', 'renderer', 'renderer:-inert'); + registry.injection('component', 'renderer', 'renderer:-inert'); + } + } + }); + + exports.default = EngineInstance; }); -enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { +enifed('ember-application/system/engine-parent', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; + exports.getEngineParent = getEngineParent; + exports.setEngineParent = setEngineParent; + var ENGINE_PARENT = _emberUtils.symbol('ENGINE_PARENT'); + + exports.ENGINE_PARENT = ENGINE_PARENT; /** - @module ember - @submodule ember-extension-support + `getEngineParent` retrieves an engine instance's parent instance. + + @method getEngineParent + @param {EngineInstance} engine An engine instance. + @return {EngineInstance} The parent engine instance. + @for Ember + @public */ + function getEngineParent(engine) { + return engine[ENGINE_PARENT]; + } + /** - The `ContainerDebugAdapter` helps the container and resolver interface - with tools that debug Ember such as the - [Ember Extension](https://github.com/tildeio/ember-extension) - for Chrome and Firefox. - - This class can be extended by a custom resolver implementer - to override some of the methods with library-specific code. - - The methods likely to be overridden are: - - * `canCatalogEntriesByType` - * `catalogEntriesByType` + `setEngineParent` sets an engine instance's parent instance. - The adapter will need to be registered - in the application's container as `container-debug-adapter:main`. + @method setEngineParent + @param {EngineInstance} engine An engine instance. + @param {EngineInstance} parent The parent engine instance. + @private + */ + + function setEngineParent(engine, parent) { + engine[ENGINE_PARENT] = parent; + } +}); +enifed('ember-application/system/engine', ['exports', 'ember-utils', 'ember-runtime', 'container', 'dag-map', 'ember-metal', 'ember-application/system/resolver', 'ember-application/system/engine-instance', 'ember-routing', 'ember-extension-support', 'ember-views', 'ember-glimmer'], function (exports, _emberUtils, _emberRuntime, _container, _dagMap, _emberMetal, _emberApplicationSystemResolver, _emberApplicationSystemEngineInstance, _emberRouting, _emberExtensionSupport, _emberViews, _emberGlimmer) { + /** + @module ember + @submodule ember-application + */ + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + + function props(obj) { + var properties = []; + + for (var key in obj) { + properties.push(key); + } + + return properties; + } + + /** + The `Engine` class contains core functionality for both applications and + engines. - Example: + Each engine manages a registry that's used for dependency injection and + exposed through `RegistryProxy`. - ```javascript - Application.initializer({ - name: "containerDebugAdapter", + Engines also manage initializers and instance initializers. - initialize(application) { - application.register('container-debug-adapter:main', require('app/container-debug-adapter')); - } - }); - ``` + Engines can spawn `EngineInstance` instances via `buildInstance()`. - @class ContainerDebugAdapter + @class Engine @namespace Ember - @extends Ember.Object - @since 1.5.0 + @extends Ember.Namespace + @uses RegistryProxy @public */ - exports.default = _emberRuntime.Object.extend({ + var Engine = _emberRuntime.Namespace.extend(_emberRuntime.RegistryProxyMixin, { + init: function () { + this._super.apply(this, arguments); + + this.buildRegistry(); + }, + /** - The resolver instance of the application - being debugged. This property will be injected - on creation. - @property resolver - @default null - @public + A private flag indicating whether an engine's initializers have run yet. + @private + @property _initializersRan */ - resolver: null, + _initializersRan: false, /** - Returns true if it is possible to catalog a list of available - classes in the resolver for a given type. - @method canCatalogEntriesByType - @param {String} type The type. e.g. "model", "controller", "route". - @return {boolean} whether a list is available for this type. - @public + Ensure that initializers are run once, and only once, per engine. + @private + @method ensureInitializers */ - canCatalogEntriesByType: function (type) { - if (type === 'model' || type === 'template') { - return false; + ensureInitializers: function () { + if (!this._initializersRan) { + this.runInitializers(); + this._initializersRan = true; } - - return true; }, /** - Returns the available classes a given type. - @method catalogEntriesByType - @param {String} type The type. e.g. "model", "controller", "route". - @return {Array} An array of strings. - @public + Create an EngineInstance for this engine. + @private + @method buildInstance + @return {Ember.EngineInstance} the engine instance */ - catalogEntriesByType: function (type) { - var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); - var types = _emberRuntime.A(); - var typeSuffixRegex = new RegExp(_emberRuntime.String.classify(type) + '$'); + buildInstance: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - namespaces.forEach(function (namespace) { - if (namespace !== _emberMetal.default) { - for (var key in namespace) { - if (!namespace.hasOwnProperty(key)) { - continue; - } - if (typeSuffixRegex.test(key)) { - var klass = namespace[key]; - if (_emberRuntime.typeOf(klass) === 'class') { - types.push(_emberRuntime.String.dasherize(key.replace(typeSuffixRegex, ''))); - } - } - } - } - }); - return types; - } - }); -}); -// Ember as namespace -enifed('ember-extension-support/data_adapter', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplication) { - 'use strict'; - - /** - @module ember - @submodule ember-extension-support - */ - - /** - The `DataAdapter` helps a data persistence library - interface with tools that debug Ember such - as the [Ember Extension](https://github.com/tildeio/ember-extension) - for Chrome and Firefox. - - This class will be extended by a persistence library - which will override some of the methods with - library-specific code. - - The methods likely to be overridden are: - - * `getFilters` - * `detect` - * `columnsForType` - * `getRecords` - * `getRecordColumnValues` - * `getRecordKeywords` - * `getRecordFilterValues` - * `getRecordColor` - * `observeRecord` - - The adapter will need to be registered - in the application's container as `dataAdapter:main`. - - Example: - - ```javascript - Application.initializer({ - name: "data-adapter", - - initialize: function(application) { - application.register('data-adapter:main', DS.DataAdapter); - } - }); - ``` - - @class DataAdapter - @namespace Ember - @extends EmberObject - @public - */ - exports.default = _emberRuntime.Object.extend({ - init: function () { - this._super.apply(this, arguments); - this.releaseMethods = _emberRuntime.A(); + this.ensureInitializers(); + options.base = this; + return _emberApplicationSystemEngineInstance.default.create(options); }, /** - The container-debug-adapter which is used - to list all models. - @property containerDebugAdapter - @default undefined - @since 1.5.0 - @public - **/ - containerDebugAdapter: undefined, - - /** - The number of attributes to send - as columns. (Enough to make the record - identifiable). + Build and configure the registry for the current engine. @private - @property attributeLimit - @default 3 - @since 1.3.0 + @method buildRegistry + @return {Ember.Registry} the configured registry */ - attributeLimit: 3, + buildRegistry: function () { + var registry = this.__registry__ = this.constructor.buildRegistry(this); - /** - Ember Data > v1.0.0-beta.18 - requires string model names to be passed - around instead of the actual factories. - This is a stamp for the Ember Inspector - to differentiate between the versions - to be able to support older versions too. - @public - @property acceptsModelName - */ - acceptsModelName: true, + return registry; + }, /** - Stores all methods that clear observers. - These methods will be called on destruction. - @private - @property releaseMethods - @since 1.3.0 + @private + @method initializer */ - releaseMethods: _emberRuntime.A(), + initializer: function (options) { + this.constructor.initializer(options); + }, /** - Specifies how records can be filtered. - Records returned will need to have a `filterValues` - property with a key for every name in the returned array. - @public - @method getFilters - @return {Array} List of objects defining filters. - The object should have a `name` and `desc` property. + @private + @method instanceInitializer */ - getFilters: function () { - return _emberRuntime.A(); + instanceInitializer: function (options) { + this.constructor.instanceInitializer(options); }, /** - Fetch the model types and observe them for changes. - @public - @method watchModelTypes - @param {Function} typesAdded Callback to call to add types. - Takes an array of objects containing wrapped types (returned from `wrapModelType`). - @param {Function} typesUpdated Callback to call when a type has changed. - Takes an array of objects containing wrapped types. - @return {Function} Method to call to remove all observers + @private + @method runInitializers */ - watchModelTypes: function (typesAdded, typesUpdated) { + runInitializers: function () { var _this = this; - var modelTypes = this.getModelTypes(); - var releaseMethods = _emberRuntime.A(); - var typesToSend = undefined; + this._runInitializer('initializers', function (name, initializer) { + _emberMetal.assert('No application initializer named \'' + name + '\'', !!initializer); + if (initializer.initialize.length === 2) { + _emberMetal.deprecate('The `initialize` method for Application initializer \'' + name + '\' should take only one argument - `App`, an instance of an `Application`.', false, { + id: 'ember-application.app-initializer-initialize-arguments', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_initializer-arity' + }); - typesToSend = modelTypes.map(function (type) { - var klass = type.klass; - var wrapped = _this.wrapModelType(klass, type.name); - releaseMethods.push(_this.observeModelType(type.name, typesUpdated)); - return wrapped; + initializer.initialize(_this.__registry__, _this); + } else { + initializer.initialize(_this); + } }); - - typesAdded(typesToSend); - - var release = function () { - releaseMethods.forEach(function (fn) { - return fn(); - }); - _this.releaseMethods.removeObject(release); - }; - this.releaseMethods.pushObject(release); - return release; - }, - - _nameToClass: function (type) { - if (typeof type === 'string') { - type = _emberUtils.getOwner(this)._lookupFactory('model:' + type); - } - return type; }, /** - Fetch the records of a given type and observe them for changes. - @public - @method watchRecords - @param {String} modelName The model name. - @param {Function} recordsAdded Callback to call to add records. - Takes an array of objects containing wrapped records. - The object should have the following properties: - columnValues: {Object} The key and value of a table cell. - object: {Object} The actual record object. - @param {Function} recordsUpdated Callback to call when a record has changed. - Takes an array of objects containing wrapped records. - @param {Function} recordsRemoved Callback to call when a record has removed. - Takes the following parameters: - index: The array index where the records were removed. - count: The number of records removed. - @return {Function} Method to call to remove all observers. + @private + @since 1.12.0 + @method runInstanceInitializers */ - watchRecords: function (modelName, recordsAdded, recordsUpdated, recordsRemoved) { - var _this2 = this; + runInstanceInitializers: function (instance) { + this._runInitializer('instanceInitializers', function (name, initializer) { + _emberMetal.assert('No instance initializer named \'' + name + '\'', !!initializer); + initializer.initialize(instance); + }); + }, - var releaseMethods = _emberRuntime.A(); - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); - var release = undefined; + _runInitializer: function (bucketName, cb) { + var initializersByName = _emberMetal.get(this.constructor, bucketName); + var initializers = props(initializersByName); + var graph = new _dagMap.default(); + var initializer = undefined; - function recordUpdated(updatedRecord) { - recordsUpdated([updatedRecord]); + for (var i = 0; i < initializers.length; i++) { + initializer = initializersByName[initializers[i]]; + graph.add(initializer.name, initializer, initializer.before, initializer.after); } - var recordsToSend = records.map(function (record) { - releaseMethods.push(_this2.observeRecord(record, recordUpdated)); - return _this2.wrapRecord(record); - }); + graph.topsort(cb); + } + }); - var contentDidChange = function (array, idx, removedCount, addedCount) { - for (var i = idx; i < idx + addedCount; i++) { - var record = _emberRuntime.objectAt(array, i); - var wrapped = _this2.wrapRecord(record); - releaseMethods.push(_this2.observeRecord(record, recordUpdated)); - recordsAdded([wrapped]); - } + Engine.reopenClass({ + initializers: new _emberUtils.EmptyObject(), + instanceInitializers: new _emberUtils.EmptyObject(), - if (removedCount) { - recordsRemoved(idx, removedCount); + /** + The goal of initializers should be to register dependencies and injections. + This phase runs once. Because these initializers may load code, they are + allowed to defer application readiness and advance it. If you need to access + the container or store you should use an InstanceInitializer that will be run + after all initializers and therefore after all code is loaded and the app is + ready. + Initializer receives an object which has the following attributes: + `name`, `before`, `after`, `initialize`. The only required attribute is + `initialize`, all others are optional. + * `name` allows you to specify under which name the initializer is registered. + This must be a unique name, as trying to register two initializers with the + same name will result in an error. + ```javascript + Ember.Application.initializer({ + name: 'namedInitializer', + initialize: function(application) { + Ember.debug('Running namedInitializer!'); } - }; - - var observer = { didChange: contentDidChange, willChange: function () { - return this; - } }; - _emberRuntime.addArrayObserver(records, this, observer); - - release = function () { - releaseMethods.forEach(function (fn) { - return fn(); - }); - _emberRuntime.removeArrayObserver(records, _this2, observer); - _this2.releaseMethods.removeObject(release); - }; + }); + ``` + * `before` and `after` are used to ensure that this initializer is ran prior + or after the one identified by the value. This value can be a single string + or an array of strings, referencing the `name` of other initializers. + An example of ordering initializers, we create an initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'first', + initialize: function(application) { + Ember.debug('First initializer!'); + } + }); + // DEBUG: First initializer! + ``` + We add another initializer named `second`, specifying that it should run + after the initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'second', + after: 'first', + initialize: function(application) { + Ember.debug('Second initializer!'); + } + }); + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + Afterwards we add a further initializer named `pre`, this time specifying + that it should run before the initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'pre', + before: 'first', + initialize: function(application) { + Ember.debug('Pre initializer!'); + } + }); + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + Finally we add an initializer named `post`, specifying it should run after + both the `first` and the `second` initializers: + ```javascript + Ember.Application.initializer({ + name: 'post', + after: ['first', 'second'], + initialize: function(application) { + Ember.debug('Post initializer!'); + } + }); + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + // DEBUG: Post initializer! + ``` + * `initialize` is a callback function that receives one argument, + `application`, on which you can operate. + Example of using `application` to register an adapter: + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + initialize: function(application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + @method initializer + @param initializer {Object} + @public + */ - recordsAdded(recordsToSend); + initializer: buildInitializerMethod('initializers', 'initializer'), - this.releaseMethods.pushObject(release); - return release; - }, + /** + Instance initializers run after all initializers have run. Because + instance initializers run after the app is fully set up. We have access + to the store, container, and other items. However, these initializers run + after code has loaded and are not allowed to defer readiness. + Instance initializer receives an object which has the following attributes: + `name`, `before`, `after`, `initialize`. The only required attribute is + `initialize`, all others are optional. + * `name` allows you to specify under which name the instanceInitializer is + registered. This must be a unique name, as trying to register two + instanceInitializer with the same name will result in an error. + ```javascript + Ember.Application.instanceInitializer({ + name: 'namedinstanceInitializer', + initialize: function(application) { + Ember.debug('Running namedInitializer!'); + } + }); + ``` + * `before` and `after` are used to ensure that this initializer is ran prior + or after the one identified by the value. This value can be a single string + or an array of strings, referencing the `name` of other initializers. + * See Ember.Application.initializer for discussion on the usage of before + and after. + Example instanceInitializer to preload data into the store. + ```javascript + Ember.Application.initializer({ + name: 'preload-data', + initialize: function(application) { + var userConfig, userConfigEncoded, store; + // We have a HTML escaped JSON representation of the user's basic + // configuration generated server side and stored in the DOM of the main + // index.html file. This allows the app to have access to a set of data + // without making any additional remote calls. Good for basic data that is + // needed for immediate rendering of the page. Keep in mind, this data, + // like all local models and data can be manipulated by the user, so it + // should not be relied upon for security or authorization. + // + // Grab the encoded data from the meta tag + userConfigEncoded = Ember.$('head meta[name=app-user-config]').attr('content'); + // Unescape the text, then parse the resulting JSON into a real object + userConfig = JSON.parse(unescape(userConfigEncoded)); + // Lookup the store + store = application.lookup('service:store'); + // Push the encoded JSON into the store + store.pushPayload(userConfig); + } + }); + ``` + @method instanceInitializer + @param instanceInitializer + @public + */ + instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer'), /** - Clear all observers before destruction + This creates a registry with the default Ember naming conventions. + It also configures the registry: + * registered views are created every time they are looked up (they are + not singletons) + * registered templates are not factories; the registered value is + returned directly. + * the router receives the application as its `namespace` property + * all controllers receive the router as their `target` and `controllers` + properties + * all controllers receive the application as their `namespace` property + * the application view receives the application controller as its + `controller` property + * the application view receives the application template as its + `defaultTemplate` property + @method buildRegistry + @static + @param {Ember.Application} namespace the application for which to + build the registry + @return {Ember.Registry} the built registry @private - @method willDestroy */ - willDestroy: function () { - this._super.apply(this, arguments); - this.releaseMethods.forEach(function (fn) { - return fn(); + buildRegistry: function (namespace) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var registry = new _container.Registry({ + resolver: resolverFor(namespace) }); - }, - /** - Detect whether a class is a model. - Test that against the model class - of your persistence library. - @private - @method detect - @param {Class} klass The class to test. - @return boolean Whether the class is a model class or not. - */ - detect: function (klass) { - return false; + registry.set = _emberMetal.set; + + registry.register('application:main', namespace, { instantiate: false }); + + commonSetupRegistry(registry); + _emberGlimmer.setupEngineRegistry(registry); + + return registry; }, /** - Get the columns for a given model type. - @private - @method columnsForType - @param {Class} type The model type. - @return {Array} An array of columns of the following format: - name: {String} The name of the column. - desc: {String} Humanized description (what would show in a table column name). + Set this to provide an alternate class to `Ember.DefaultResolver` + @deprecated Use 'Resolver' instead + @property resolver + @public */ - columnsForType: function (type) { - return _emberRuntime.A(); - }, + resolver: null, /** - Adds observers to a model type class. - @private - @method observeModelType - @param {String} modelName The model type name. - @param {Function} typesUpdated Called when a type is modified. - @return {Function} The function to call to remove observers. + Set this to provide an alternate class to `Ember.DefaultResolver` + @property resolver + @public */ + Resolver: null + }); - observeModelType: function (modelName, typesUpdated) { - var _this3 = this; - - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); + /** + This function defines the default lookup rules for container lookups: + + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after classifying the name. + For example, `controller:post` looks up `App.PostController` by default. + * if the default lookup fails, look for registered classes on the container + + This allows the application to register default injections in the container + that could be overridden by the normal naming convention. + + @private + @method resolverFor + @param {Ember.Namespace} namespace the namespace to look for classes + @return {*} the resolved value for a given lookup + */ + function resolverFor(namespace) { + var ResolverClass = namespace.get('Resolver') || _emberApplicationSystemResolver.default; - function onChange() { - typesUpdated([this.wrapModelType(klass, modelName)]); - } + return ResolverClass.create({ + namespace: namespace + }); + } - var observer = { - didChange: function () { - _emberMetal.run.scheduleOnce('actions', this, onChange); - }, - willChange: function () { - return this; - } - }; - - _emberRuntime.addArrayObserver(records, this, observer); - - var release = function () { - return _emberRuntime.removeArrayObserver(records, _this3, observer); - }; - - return release; - }, - - /** - Wraps a given model type and observes changes to it. - @private - @method wrapModelType - @param {Class} klass A model class. - @param {String} modelName Name of the class. - @return {Object} Contains the wrapped type and the function to remove observers - Format: - type: {Object} The wrapped type. - The wrapped type has the following format: - name: {String} The name of the type. - count: {Integer} The number of records available. - columns: {Columns} An array of columns to describe the record. - object: {Class} The actual Model type class. - release: {Function} The function to remove observers. - */ - wrapModelType: function (klass, name) { - var records = this.getRecords(klass, name); - var typeToSend = undefined; - - typeToSend = { - name: name, - count: _emberMetal.get(records, 'length'), - columns: this.columnsForType(klass), - object: klass - }; - - return typeToSend; - }, - - /** - Fetches all models defined in the application. - @private - @method getModelTypes - @return {Array} Array of model types. - */ - getModelTypes: function () { - var _this4 = this; - - var containerDebugAdapter = this.get('containerDebugAdapter'); - var types = undefined; - - if (containerDebugAdapter.canCatalogEntriesByType('model')) { - types = containerDebugAdapter.catalogEntriesByType('model'); - } else { - types = this._getObjectsOnNamespaces(); + function buildInitializerMethod(bucketName, humanName) { + return function (initializer) { + // If this is the first initializer being added to a subclass, we are going to reopen the class + // to make sure we have a new `initializers` object, which extends from the parent class' using + // prototypal inheritance. Without this, attempting to add initializers to the subclass would + // pollute the parent class as well as other subclasses. + if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) { + var attrs = {}; + attrs[bucketName] = Object.create(this[bucketName]); + this.reopenClass(attrs); } - // New adapters return strings instead of classes. - types = _emberRuntime.A(types).map(function (name) { - return { - klass: _this4._nameToClass(name), - name: name - }; - }); - types = _emberRuntime.A(types).filter(function (type) { - return _this4.detect(type.klass); - }); + _emberMetal.assert('The ' + humanName + ' \'' + initializer.name + '\' has already been registered', !this[bucketName][initializer.name]); + _emberMetal.assert('An ' + humanName + ' cannot be registered without an initialize function', _emberUtils.canInvoke(initializer, 'initialize')); + _emberMetal.assert('An ' + humanName + ' cannot be registered without a name property', initializer.name !== undefined); - return _emberRuntime.A(types); - }, + this[bucketName][initializer.name] = initializer; + }; + } - /** - Loops over all namespaces and all objects - attached to them. - @private - @method _getObjectsOnNamespaces - @return {Array} Array of model type strings. - */ - _getObjectsOnNamespaces: function () { - var _this5 = this; + function commonSetupRegistry(registry) { + registry.optionsForType('component', { singleton: false }); + registry.optionsForType('view', { singleton: false }); - var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); - var types = _emberRuntime.A(); + registry.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); - namespaces.forEach(function (namespace) { - for (var key in namespace) { - if (!namespace.hasOwnProperty(key)) { - continue; - } - // Even though we will filter again in `getModelTypes`, - // we should not call `lookupFactory` on non-models - // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) - if (!_this5.detect(namespace[key])) { - continue; - } - var _name = _emberRuntime.String.dasherize(key); - if (!(namespace instanceof _emberApplication.Application) && namespace.toString()) { - _name = namespace + '/' + _name; - } - types.push(_name); - } - }); - return types; - }, + registry.injection('view', '_viewRegistry', '-view-registry:main'); + registry.injection('renderer', '_viewRegistry', '-view-registry:main'); + registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); - /** - Fetches all loaded records for a given type. - @private - @method getRecords - @return {Array} An array of records. - This array will be observed for changes, - so it should update when new records are added/removed. - */ - getRecords: function (type) { - return _emberRuntime.A(); - }, + registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); - /** - Wraps a record and observers changes to it. - @private - @method wrapRecord - @param {Object} record The record instance. - @return {Object} The wrapped record. Format: - columnValues: {Array} - searchKeywords: {Array} - */ - wrapRecord: function (record) { - var recordToSend = { object: record }; + registry.injection('view:-outlet', 'namespace', 'application:main'); - recordToSend.columnValues = this.getRecordColumnValues(record); - recordToSend.searchKeywords = this.getRecordKeywords(record); - recordToSend.filterValues = this.getRecordFilterValues(record); - recordToSend.color = this.getRecordColor(record); + registry.injection('controller', 'target', 'router:main'); + registry.injection('controller', 'namespace', 'application:main'); - return recordToSend; - }, + registry.injection('router', '_bucketCache', _container.privatize(_templateObject)); + registry.injection('route', '_bucketCache', _container.privatize(_templateObject)); - /** - Gets the values for each column. - @private - @method getRecordColumnValues - @return {Object} Keys should match column names defined - by the model type. - */ - getRecordColumnValues: function (record) { - return {}; - }, + registry.injection('route', 'router', 'router:main'); - /** - Returns keywords to match when searching records. - @private - @method getRecordKeywords - @return {Array} Relevant keywords for search. - */ - getRecordKeywords: function (record) { - return _emberRuntime.A(); - }, + // Register the routing service... + registry.register('service:-routing', _emberRouting.RoutingService); + // Then inject the app router into it + registry.injection('service:-routing', 'router', 'router:main'); - /** - Returns the values of filters defined by `getFilters`. - @private - @method getRecordFilterValues - @param {Object} record The record instance. - @return {Object} The filter values. - */ - getRecordFilterValues: function (record) { - return {}; - }, + // DEBUGGING + registry.register('resolver-for-debugging:main', registry.resolver, { instantiate: false }); + registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); + registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); + // Custom resolver authors may want to register their own ContainerDebugAdapter with this key - /** - Each record can have a color that represents its state. - @private - @method getRecordColor - @param {Object} record The record instance - @return {String} The records color. - Possible options: black, red, blue, green. - */ - getRecordColor: function (record) { - return null; - }, + registry.register('container-debug-adapter:main', _emberExtensionSupport.ContainerDebugAdapter); - /** - Observes all relevant properties and re-sends the wrapped record - when a change occurs. - @private - @method observerRecord - @param {Object} record The record instance. - @param {Function} recordUpdated The callback to call when a record is updated. - @return {Function} The function to call to remove all observers. - */ - observeRecord: function (record, recordUpdated) { - return function () {}; - } - }); + registry.register('component-lookup:main', _emberViews.ComponentLookup); + } + + exports.default = Engine; }); -enifed('ember-extension-support/index', ['exports', 'ember-extension-support/data_adapter', 'ember-extension-support/container_debug_adapter'], function (exports, _emberExtensionSupportData_adapter, _emberExtensionSupportContainer_debug_adapter) { +enifed('ember-application/system/resolver', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application/utils/validate-type', 'ember-glimmer'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplicationUtilsValidateType, _emberGlimmer) { /** @module ember - @submodule ember-extension-support + @submodule ember-application */ 'use strict'; - exports.DataAdapter = _emberExtensionSupportData_adapter.default; - exports.ContainerDebugAdapter = _emberExtensionSupportContainer_debug_adapter.default; -}); -enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'ember-runtime', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference', 'glimmer-runtime'], function (exports, _emberUtils, _emberViews, _emberRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference, _glimmerRuntime) { - 'use strict'; - - var _CoreView$extend; - - var DIRTY_TAG = _emberUtils.symbol('DIRTY_TAG'); - exports.DIRTY_TAG = DIRTY_TAG; - var ARGS = _emberUtils.symbol('ARGS'); - exports.ARGS = ARGS; - var ROOT_REF = _emberUtils.symbol('ROOT_REF'); - exports.ROOT_REF = ROOT_REF; - var IS_DISPATCHING_ATTRS = _emberUtils.symbol('IS_DISPATCHING_ATTRS'); - exports.IS_DISPATCHING_ATTRS = IS_DISPATCHING_ATTRS; - var HAS_BLOCK = _emberUtils.symbol('HAS_BLOCK'); - exports.HAS_BLOCK = HAS_BLOCK; - var BOUNDS = _emberUtils.symbol('BOUNDS'); - - exports.BOUNDS = BOUNDS; - /** - @module ember - @submodule ember-glimmer - */ + var Resolver = _emberRuntime.Object.extend({ + /* + This will be set to the Application instance when it is + created. + @property namespace + */ + namespace: null, + normalize: null, // required + resolve: null, // required + parseName: null, // required + lookupDescription: null, // required + makeToString: null, // required + resolveOther: null, // required + _logLookup: null // required + }); + exports.Resolver = Resolver; /** - An `Ember.Component` is a view that is completely - isolated. Properties accessed in its templates go - to the view object and actions are targeted at - the view object. There is no access to the - surrounding context or outer controller; all - contextual information must be passed in. - - The easiest way to create an `Ember.Component` is via - a template. If you name a template - `components/my-foo`, you will be able to use - `{{my-foo}}` in other templates, which will make - an instance of the isolated component. + The DefaultResolver defines the default lookup rules to resolve + container lookups before consulting the container for registered + items: - ```handlebars - {{app-profile person=currentUser}} - ``` + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after converting + the name. For example, `controller:post` looks up + `App.PostController` by default. + * there are some nuances (see examples below) - ```handlebars - -

    {{person.title}}

    - -

    {{person.signature}}

    - ``` + ### How Resolving Works - You can use `yield` inside a template to - include the **contents** of any block attached to - the component. The block will be executed in the - context of the surrounding context or outer controller: + The container calls this object's `resolve` method with the + `fullName` argument. - ```handlebars - {{#app-profile person=currentUser}} -

    Admin mode

    - {{! Executed in the controller's context. }} - {{/app-profile}} - ``` + It first parses the fullName into an object using `parseName`. - ```handlebars - -

    {{person.title}}

    - {{! Executed in the component's context. }} - {{yield}} {{! block contents }} - ``` + Then it checks for the presence of a type-specific instance + method of the form `resolve[Type]` and calls it if it exists. + For example if it was resolving 'template:post', it would call + the `resolveTemplate` method. - If you want to customize the component, in order to - handle events or actions, you implement a subclass - of `Ember.Component` named after the name of the - component. Note that `Component` needs to be appended to the name of - your subclass like `AppProfileComponent`. + Its last resort is to call the `resolveOther` method. - For example, you could implement the action - `hello` for the `app-profile` component: + The methods of this object are designed to be easy to override + in a subclass. For example, you could enhance how a template + is resolved like so: ```javascript - App.AppProfileComponent = Ember.Component.extend({ - actions: { - hello: function(name) { - console.log("Hello", name); + App = Ember.Application.create({ + Resolver: Ember.DefaultResolver.extend({ + resolveTemplate: function(parsedName) { + let resolvedTemplate = this._super(parsedName); + if (resolvedTemplate) { return resolvedTemplate; } + return Ember.TEMPLATES['not_found']; } - } + }) }); ``` - And then use it in the component's template: + Some examples of how names are resolved: - ```handlebars - -

    {{person.title}}

    - {{yield}} - ``` - Components must have a `-` in their name to avoid - conflicts with built-in controls that wrap HTML - elements. This is consistent with the same - requirement in web components. + 'template:post' //=> Ember.TEMPLATES['post'] + 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] + // OR + // Ember.TEMPLATES['blog_post'] + 'controller:post' //=> App.PostController + 'controller:posts.index' //=> App.PostsIndexController + 'controller:blog/post' //=> Blog.PostController + 'controller:basic' //=> Ember.Controller + 'route:post' //=> App.PostRoute + 'route:posts.index' //=> App.PostsIndexRoute + 'route:blog/post' //=> Blog.PostRoute + 'route:basic' //=> Ember.Route + 'view:post' //=> App.PostView + 'view:posts.index' //=> App.PostsIndexView + 'view:blog/post' //=> Blog.PostView + 'view:basic' //=> Ember.View + 'foo:post' //=> App.PostFoo + 'model:post' //=> App.Post + ``` - @class Component + @class DefaultResolver @namespace Ember - @extends Ember.CoreView - @uses Ember.TargetActionSupport - @uses Ember.ClassNamesSupport - @uses Ember.ActionSupport - @uses Ember.ViewMixin + @extends Ember.Object @public */ - var Component = _emberViews.CoreView.extend(_emberViews.ChildViewsSupport, _emberViews.ViewStateSupport, _emberViews.ClassNamesSupport, _emberRuntime.TargetActionSupport, _emberViews.ActionSupport, _emberViews.ViewMixin, (_CoreView$extend = { - isComponent: true, + + exports.default = _emberRuntime.Object.extend({ + /** + This will be set to the Application instance when it is + created. + @property namespace + @public + */ + namespace: null, init: function () { - var _this = this; + this._parseNameCache = _emberUtils.dictionary(null); + }, + normalize: function (fullName) { + var _fullName$split = fullName.split(':', 2); - this._super.apply(this, arguments); - this[IS_DISPATCHING_ATTRS] = false; - this[DIRTY_TAG] = new _glimmerReference.DirtyableTag(); - this[ROOT_REF] = new _emberGlimmerUtilsReferences.RootReference(this); - this[BOUNDS] = null; + var type = _fullName$split[0]; + var name = _fullName$split[1]; - // If a `defaultLayout` was specified move it to the `layout` prop. - // `layout` is no longer a CP, so this just ensures that the `defaultLayout` - // logic is supported with a deprecation - if (this.defaultLayout && !this.layout) { - _emberMetal.deprecate('Specifying `defaultLayout` to ' + this + ' is deprecated. Please use `layout` instead.', false, { - id: 'ember-views.component.defaultLayout', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-component-defaultlayout' - }); + _emberMetal.assert('Tried to normalize a container name without a colon (:) in it. ' + 'You probably tried to lookup a name that did not contain a type, ' + 'a colon, and a name. A proper lookup name would be `view:post`.', fullName.split(':').length === 2); - this.layout = this.defaultLayout; - } + if (type !== 'template') { + var result = name; - // If in a tagless component, assert that no event handlers are defined - _emberMetal.assert('You can not define a function that handles DOM events in the `' + this + '` tagless component since it doesn\'t have any DOM element.', this.tagName !== '' || !this.renderer._destinedForDOM || !(function () { - var eventDispatcher = _emberUtils.getOwner(_this).lookup('event_dispatcher:main'); - var events = eventDispatcher && eventDispatcher._finalEvents || {}; + if (result.indexOf('.') > -1) { + result = result.replace(/\.(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); + } - for (var key in events) { - var methodName = events[key]; + if (name.indexOf('_') > -1) { + result = result.replace(/_(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); + } - if (typeof _this[methodName] === 'function') { - return true; // indicate that the assertion should be triggered - } + if (name.indexOf('-') > -1) { + result = result.replace(/-(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); } - })()); - }, - rerender: function () { - this[DIRTY_TAG].dirty(); - this._super(); + return type + ':' + result; + } else { + return fullName; + } }, - __defineNonEnumerable: function (property) { - this[property.name] = property.descriptor.value; - } + /** + This method is called via the container's resolver method. + It parses the provided `fullName` and then looks up and + returns the appropriate template or class. + @method resolve + @param {String} fullName the lookup string + @return {Object} the resolved factory + @public + */ + resolve: function (fullName) { + var _this = this; - }, _CoreView$extend[_emberMetal.PROPERTY_DID_CHANGE] = function (key) { - if (this[IS_DISPATCHING_ATTRS]) { - return; - } + var parsedName = this.parseName(fullName); + var resolveMethodName = parsedName.resolveMethodName; + var resolved = undefined; - var args = undefined, - reference = undefined; + if (this[resolveMethodName]) { + resolved = this[resolveMethodName](parsedName); + } - if ((args = this[ARGS]) && (reference = args[key])) { - if (reference[_emberGlimmerUtilsReferences.UPDATE]) { - reference[_emberGlimmerUtilsReferences.UPDATE](_emberMetal.get(this, key)); + resolved = resolved || this.resolveOther(parsedName); + + _emberMetal.runInDebug(function () { + if (parsedName.root && parsedName.root.LOG_RESOLVER) { + _this._logLookup(resolved, parsedName); + } + }); + + if (resolved) { + _emberApplicationUtilsValidateType.default(resolved, parsedName); } - } - }, _CoreView$extend.getAttr = function (key) { - // TODO Intimate API should be deprecated - return this.get(key); - }, _CoreView$extend.readDOMAttr = function (name) { - var element = _emberViews.getViewElement(this); - return _glimmerRuntime.readDOMAttr(element, name); - }, _CoreView$extend)); - /** - The WAI-ARIA role of the control represented by this view. For example, a - button may have a role of type 'button', or a pane may have a role of - type 'alertdialog'. This property is used by assistive software to help - visually challenged users navigate rich web applications. - The full list of valid WAI-ARIA roles is available at: - [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization) - @property ariaRole - @type String - @default null - @public - */ + return resolved; + }, - /** - Enables components to take a list of parameters as arguments. - For example, a component that takes two parameters with the names - `name` and `age`: - ```javascript - let MyComponent = Ember.Component.extend; - MyComponent.reopenClass({ - positionalParams: ['name', 'age'] - }); - ``` - It can then be invoked like this: - ```hbs - {{my-component "John" 38}} - ``` - The parameters can be referred to just like named parameters: - ```hbs - Name: {{attrs.name}}, Age: {{attrs.age}}. - ``` - Using a string instead of an array allows for an arbitrary number of - parameters: - ```javascript - let MyComponent = Ember.Component.extend; - MyComponent.reopenClass({ - positionalParams: 'names' - }); - ``` - It can then be invoked like this: - ```hbs - {{my-component "John" "Michael" "Scott"}} - ``` - The parameters can then be referred to by enumerating over the list: - ```hbs - {{#each attrs.names as |name|}}{{name}}{{/each}} - ``` - @static - @public - @property positionalParams - @since 1.13.0 - */ + /** + Convert the string name of the form 'type:name' to + a Javascript object with the parsed aspects of the name + broken out. + @param {String} fullName the lookup string + @method parseName + @protected + */ - /** - Called when the attributes passed into the component have been updated. - Called both during the initial render of a container and during a rerender. - Can be used in place of an observer; code placed here will be executed - every time any attribute updates. - @method didReceiveAttrs - @public - @since 1.13.0 - */ + parseName: function (fullName) { + return this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)); + }, - /** - Called when the attributes passed into the component have been updated. - Called both during the initial render of a container and during a rerender. - Can be used in place of an observer; code placed here will be executed - every time any attribute updates. - @event didReceiveAttrs - @public - @since 1.13.0 - */ + _parseName: function (fullName) { + var _fullName$split2 = fullName.split(':'); - /** - Called after a component has been rendered, both on initial render and - in subsequent rerenders. - @method didRender - @public - @since 1.13.0 - */ + var type = _fullName$split2[0]; + var fullNameWithoutType = _fullName$split2[1]; - /** - Called after a component has been rendered, both on initial render and - in subsequent rerenders. - @event didRender - @public - @since 1.13.0 - */ + var name = fullNameWithoutType; + var namespace = _emberMetal.get(this, 'namespace'); + var root = namespace; + var lastSlashIndex = name.lastIndexOf('/'); + var dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null; - /** - Called before a component has been rendered, both on initial render and - in subsequent rerenders. - @method willRender - @public - @since 1.13.0 - */ + if (type !== 'template' && lastSlashIndex !== -1) { + var parts = name.split('/'); + name = parts[parts.length - 1]; + var namespaceName = _emberRuntime.String.capitalize(parts.slice(0, -1).join('.')); + root = _emberRuntime.Namespace.byName(namespaceName); - /** - Called before a component has been rendered, both on initial render and - in subsequent rerenders. - @event willRender - @public - @since 1.13.0 - */ + _emberMetal.assert('You are looking for a ' + name + ' ' + type + ' in the ' + namespaceName + ' namespace, but the namespace could not be found', root); + } - /** - Called when the attributes passed into the component have been changed. - Called only during a rerender, not during an initial render. - @method didUpdateAttrs - @public - @since 1.13.0 - */ + var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : _emberRuntime.String.classify(type); - /** - Called when the attributes passed into the component have been changed. - Called only during a rerender, not during an initial render. - @event didUpdateAttrs - @public - @since 1.13.0 - */ + if (!(name && type)) { + throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); + } - /** - Called when the component is about to update and rerender itself. - Called only during a rerender, not during an initial render. - @method willUpdate - @public - @since 1.13.0 - */ + return { + fullName: fullName, + type: type, + fullNameWithoutType: fullNameWithoutType, + dirname: dirname, + name: name, + root: root, + resolveMethodName: 'resolve' + resolveMethodName + }; + }, - /** - Called when the component is about to update and rerender itself. - Called only during a rerender, not during an initial render. - @event willUpdate - @public - @since 1.13.0 - */ + /** + Returns a human-readable description for a fullName. Used by the + Application namespace in assertions to describe the + precise name of the class that Ember is looking for, rather than + container keys. + @param {String} fullName the lookup string + @method lookupDescription + @protected + */ + lookupDescription: function (fullName) { + var parsedName = this.parseName(fullName); + var description = undefined; - /** - Called when the component has updated and rerendered itself. - Called only during a rerender, not during an initial render. - @method didUpdate - @public - @since 1.13.0 - */ + if (parsedName.type === 'template') { + return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + } - /** - Called when the component has updated and rerendered itself. - Called only during a rerender, not during an initial render. - @event didUpdate - @public - @since 1.13.0 - */ + description = parsedName.root + '.' + _emberRuntime.String.classify(parsedName.name).replace(/\./g, ''); - /** - If `false`, the view will appear hidden in DOM. - @property isVisible - @type Boolean - @default null - @public - */ - Component[_emberUtils.NAME_KEY] = 'Ember.Component'; + if (parsedName.type !== 'model') { + description += _emberRuntime.String.classify(parsedName.type); + } - Component.reopenClass({ - isComponentFactory: true, - positionalParams: [] - }); + return description; + }, - exports.default = Component; -}); + makeToString: function (factory, fullName) { + return factory.toString(); + }, -/** - Normally, Ember's component model is "write-only". The component takes a - bunch of attributes that it got passed in, and uses them to render its - template. - One nice thing about this model is that if you try to set a value to the - same thing as last time, Ember (through HTMLBars) will avoid doing any - work on the DOM. - This is not just a performance optimization. If an attribute has not - changed, it is important not to clobber the element's "hidden state". - For example, if you set an input's `value` to the same value as before, - it will clobber selection state and cursor position. In other words, - setting an attribute is not **always** idempotent. - This method provides a way to read an element's attribute and also - update the last value Ember knows about at the same time. This makes - setting an attribute idempotent. - In particular, what this means is that if you get an `` element's - `value` attribute and then re-render the template with the same value, - it will avoid clobbering the cursor and selection position. - Since most attribute sets are idempotent in the browser, you typically - can get away with reading attributes using jQuery, but the most reliable - way to do so is through this method. - @method readDOMAttr - @param {String} name the name of the attribute - @return String - @public - */ -enifed('ember-glimmer/components/checkbox', ['exports', 'ember-metal', 'ember-glimmer/component', 'ember-glimmer/templates/empty'], function (exports, _emberMetal, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty) { - 'use strict'; + /** + Given a parseName object (output from `parseName`), apply + the conventions expected by `Ember.Router` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method useRouterNaming + @protected + */ + useRouterNaming: function (parsedName) { + parsedName.name = parsedName.name.replace(/\./g, '_'); + if (parsedName.name === 'basic') { + parsedName.name = ''; + } + }, + /** + Look up the template in Ember.TEMPLATES + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveTemplate + @protected + */ + resolveTemplate: function (parsedName) { + var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); - /** - @module ember - @submodule ember-views - */ + return _emberGlimmer.getTemplate(templateName) || _emberGlimmer.getTemplate(_emberRuntime.String.decamelize(templateName)); + }, - /** - The internal class used to create text inputs when the `{{input}}` - helper is used with `type` of `checkbox`. - - See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. - - ## Direct manipulation of `checked` - - The `checked` attribute of an `Ember.Checkbox` object should always be set - through the Ember object or by interacting with its rendered element - representation via the mouse, keyboard, or touch. Updating the value of the - checkbox via jQuery will result in the checked value of the object and its - element losing synchronization. - - ## Layout and LayoutName properties - - Because HTML `input` elements are self closing `layout` and `layoutName` - properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. - - @class Checkbox - @namespace Ember - @extends Ember.Component - @public - */ - exports.default = _emberGlimmerComponent.default.extend({ - layout: _emberGlimmerTemplatesEmpty.default, - classNames: ['ember-checkbox'], + /** + Lookup the view using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveView + @protected + */ + resolveView: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, - tagName: 'input', + /** + Lookup the controller using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveController + @protected + */ + resolveController: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, + /** + Lookup the route using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveRoute + @protected + */ + resolveRoute: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, - attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name', 'autofocus', 'required', 'form'], + /** + Lookup the model on the Application namespace + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveModel + @protected + */ + resolveModel: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.name); + var factory = _emberMetal.get(parsedName.root, className); - type: 'checkbox', - checked: false, - disabled: false, - indeterminate: false, + return factory; + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveHelper + @protected + */ + resolveHelper: function (parsedName) { + return this.resolveOther(parsedName); + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveOther + @protected + */ + resolveOther: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.name) + _emberRuntime.String.classify(parsedName.type); + var factory = _emberMetal.get(parsedName.root, className); + return factory; + }, - didInsertElement: function () { - this._super.apply(this, arguments); - _emberMetal.get(this, 'element').indeterminate = !!_emberMetal.get(this, 'indeterminate'); + resolveMain: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.type); + return _emberMetal.get(parsedName.root, className); }, - change: function () { - _emberMetal.set(this, 'checked', this.$().prop('checked')); + /** + @method _logLookup + @param {Boolean} found + @param {Object} parsedName + @private + */ + _logLookup: function (found, parsedName) { + var symbol = undefined, + padding = undefined; + + if (found) { + symbol = '[✓]'; + } else { + symbol = '[ ]'; + } + + if (parsedName.fullName.length > 60) { + padding = '.'; + } else { + padding = new Array(60 - parsedName.fullName.length).join('.'); + } + + _emberMetal.info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); + }, + + /** + Used to iterate all items of a given type. + @method knownForType + @param {String} type the type to search for + @private + */ + knownForType: function (type) { + var namespace = _emberMetal.get(this, 'namespace'); + var suffix = _emberRuntime.String.classify(type); + var typeRegexp = new RegExp(suffix + '$'); + + var known = _emberUtils.dictionary(null); + var knownKeys = Object.keys(namespace); + for (var index = 0; index < knownKeys.length; index++) { + var _name = knownKeys[index]; + + if (typeRegexp.test(_name)) { + var containerName = this.translateToContainerFullname(type, _name); + + known[containerName] = true; + } + } + + return known; + }, + + /** + Converts provided name from the backing namespace into a container lookup name. + Examples: + App.FooBarHelper -> helper:foo-bar + App.THelper -> helper:t + @method translateToContainerFullname + @param {String} type + @param {String} name + @private + */ + + translateToContainerFullname: function (type, name) { + var suffix = _emberRuntime.String.classify(type); + var namePrefix = name.slice(0, suffix.length * -1); + var dasherizedName = _emberRuntime.String.dasherize(namePrefix); + + return type + ':' + dasherizedName; } }); }); -enifed('ember-glimmer/components/link-to', ['exports', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-glimmer/templates/link-to', 'ember-glimmer/component'], function (exports, _emberConsole, _emberMetal, _emberRuntime, _emberViews, _emberGlimmerTemplatesLinkTo, _emberGlimmerComponent) { +enifed('ember-application/utils/validate-type', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** @module ember - @submodule ember-glimmer + @submodule ember-application */ + 'use strict'; + + exports.default = validateType; + + var VALIDATED_TYPES = { + route: ['assert', 'isRouteFactory', 'Ember.Route'], + component: ['deprecate', 'isComponentFactory', 'Ember.Component'], + view: ['deprecate', 'isViewFactory', 'Ember.View'], + service: ['deprecate', 'isServiceFactory', 'Ember.Service'] + }; + + function validateType(resolvedType, parsedName) { + var validationAttributes = VALIDATED_TYPES[parsedName.type]; + + if (!validationAttributes) { + return; + } + + var action = validationAttributes[0]; + var factoryFlag = validationAttributes[1]; + var expectedType = validationAttributes[2]; + + if (action === 'deprecate') { + _emberMetal.deprecate('In Ember 2.0 ' + parsedName.type + ' factories must have an `' + factoryFlag + '` ' + ('property set to true. You registered ' + resolvedType + ' as a ' + parsedName.type + ' ') + ('factory. Either add the `' + factoryFlag + '` property to this factory or ') + ('extend from ' + expectedType + '.'), !!resolvedType[factoryFlag], { id: 'ember-application.validate-type', until: '3.0.0' }); + } else { + _emberMetal.assert('Expected ' + parsedName.fullName + ' to resolve to an ' + expectedType + ' but ' + ('instead it was ' + resolvedType + '.'), !!resolvedType[factoryFlag]); + } + } +}); +enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; + + function K() {} + + function consoleMethod(name) { + var consoleObj = undefined; + if (_emberEnvironment.context.imports.console) { + consoleObj = _emberEnvironment.context.imports.console; + } else if (typeof console !== 'undefined') { + consoleObj = console; + } + + var method = typeof consoleObj === 'object' ? consoleObj[name] : null; + + if (typeof method !== 'function') { + return; + } + + if (typeof method.bind === 'function') { + return method.bind(consoleObj); + } + + return function () { + method.apply(consoleObj, arguments); + }; + } + + function assertPolyfill(test, message) { + if (!test) { + try { + // attempt to preserve the stack + throw new Error('assertion failed: ' + message); + } catch (error) { + setTimeout(function () { + throw error; + }, 0); + } + } + } + /** - The `{{link-to}}` component renders a link to the supplied - `routeName` passing an optionally supplied model to the - route as its `model` context of the route. The block - for `{{link-to}}` becomes the innerHTML of the rendered - element: - - ```handlebars - {{#link-to 'photoGallery'}} - Great Hamster Photos - {{/link-to}} - ``` + Inside Ember-Metal, simply uses the methods from `imports.console`. + Override this to provide more robust logging functionality. - You can also use an inline form of `{{link-to}}` component by - passing the link text as the first argument - to the component: + @class Logger + @namespace Ember + @public + */ + exports.default = { + /** + Logs the arguments to the console. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.log('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method log + @for Ember.Logger + @param {*} arguments + @public + */ + log: consoleMethod('log') || K, + + /** + Prints the arguments to the console with a warning icon. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + Ember.Logger.warn('Something happened!'); + // "Something happened!" will be printed to the console with a warning icon. + ``` + @method warn + @for Ember.Logger + @param {*} arguments + @public + */ + warn: consoleMethod('warn') || K, + + /** + Prints the arguments to the console with an error icon, red text and a stack trace. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + Ember.Logger.error('Danger! Danger!'); + // "Danger! Danger!" will be printed to the console in red text. + ``` + @method error + @for Ember.Logger + @param {*} arguments + @public + */ + error: consoleMethod('error') || K, + + /** + Logs the arguments to the console. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.info('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method info + @for Ember.Logger + @param {*} arguments + @public + */ + info: consoleMethod('info') || K, + + /** + Logs the arguments to the console in blue text. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.debug('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method debug + @for Ember.Logger + @param {*} arguments + @public + */ + debug: consoleMethod('debug') || consoleMethod('info') || K, + + /** + If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. + ```javascript + Ember.Logger.assert(true); // undefined + Ember.Logger.assert(true === false); // Throws an Assertion failed error. + Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message. + ``` + @method assert + @for Ember.Logger + @param {Boolean} bool Value to test + @param {String} message Assertion message on failed + @public + */ + assert: consoleMethod('assert') || assertPolyfill + }; +}); +enifed('ember-debug/deprecate', ['exports', 'ember-metal', 'ember-console', 'ember-environment', 'ember-debug/handlers'], function (exports, _emberMetal, _emberConsole, _emberEnvironment, _emberDebugHandlers) { + /*global __fail__*/ + + 'use strict'; + + exports.registerHandler = registerHandler; + exports.default = deprecate; + + function registerHandler(handler) { + _emberDebugHandlers.registerHandler('deprecate', handler); + } + + function formatMessage(_message, options) { + var message = _message; + + if (options && options.id) { + message = message + (' [deprecation id: ' + options.id + ']'); + } + + if (options && options.url) { + message += ' See ' + options.url + ' for more details.'; + } + + return message; + } + + registerHandler(function logDeprecationToConsole(message, options) { + var updatedMessage = formatMessage(message, options); + + _emberConsole.default.warn('DEPRECATION: ' + updatedMessage); + }); + + var captureErrorForStack = undefined; + + if (new Error().stack) { + captureErrorForStack = function () { + return new Error(); + }; + } else { + captureErrorForStack = function () { + try { + __fail__.fail(); + } catch (e) { + return e; + } + }; + } + + registerHandler(function logDeprecationStackTrace(message, options, next) { + if (_emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION) { + var stackStr = ''; + var error = captureErrorForStack(); + var stack = undefined; + + if (error.stack) { + if (error['arguments']) { + // Chrome + stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); + stack.shift(); + } else { + // Firefox + stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); + } + + stackStr = '\n ' + stack.slice(2).join('\n '); + } + + var updatedMessage = formatMessage(message, options); + + _emberConsole.default.warn('DEPRECATION: ' + updatedMessage + stackStr); + } else { + next.apply(undefined, arguments); + } + }); + + registerHandler(function raiseOnDeprecation(message, options, next) { + if (_emberEnvironment.ENV.RAISE_ON_DEPRECATION) { + var updatedMessage = formatMessage(message); + + throw new _emberMetal.Error(updatedMessage); + } else { + next.apply(undefined, arguments); + } + }); + + var missingOptionsDeprecation = 'When calling `Ember.deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; + exports.missingOptionsDeprecation = missingOptionsDeprecation; + var missingOptionsIdDeprecation = 'When calling `Ember.deprecate` you must provide `id` in options.'; + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; + var missingOptionsUntilDeprecation = 'When calling `Ember.deprecate` you must provide `until` in options.'; + + exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation; + /** + @module ember + @submodule ember-debug + */ + + /** + Display a deprecation warning with the provided message and a stack trace + (Chrome and Firefox only). - ```handlebars - {{link-to 'Great Hamster Photos' 'photoGallery'}} - ``` + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - Both will result in: + @method deprecate + @param {String} message A description of the deprecation. + @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. + @param {Object} options + @param {String} options.id A unique id for this deprecation. The id can be + used by Ember debugging tools to change the behavior (raise, log or silence) + for that specific deprecation. The id should be namespaced by dots, e.g. + "view.helper.select". + @param {string} options.until The version of Ember when this deprecation + warning will be removed. + @param {String} [options.url] An optional url to the transition guide on the + emberjs.com website. + @for Ember + @public + @since 1.0.0 + */ + + function deprecate(message, test, options) { + if (!options || !options.id && !options.until) { + deprecate(missingOptionsDeprecation, false, { + id: 'ember-debug.deprecate-options-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + if (options && !options.id) { + deprecate(missingOptionsIdDeprecation, false, { + id: 'ember-debug.deprecate-id-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + if (options && !options.until) { + deprecate(missingOptionsUntilDeprecation, options && options.until, { + id: 'ember-debug.deprecate-until-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + _emberDebugHandlers.invoke.apply(undefined, ['deprecate'].concat(babelHelpers.slice.call(arguments))); + } +}); +enifed("ember-debug/handlers", ["exports"], function (exports) { + "use strict"; + + exports.registerHandler = registerHandler; + exports.invoke = invoke; + var HANDLERS = {}; + + exports.HANDLERS = HANDLERS; + + function registerHandler(type, callback) { + var nextHandler = HANDLERS[type] || function () {}; + + HANDLERS[type] = function (message, options) { + callback(message, options, nextHandler); + }; + } + + function invoke(type, message, test, options) { + if (test) { + return; + } + + var handlerForType = HANDLERS[type]; + + if (!handlerForType) { + return; + } + + if (handlerForType) { + handlerForType(message, options); + } + } +}); +enifed('ember-debug/index', ['exports', 'ember-metal', 'ember-environment', 'ember-console', 'ember-debug/deprecate', 'ember-debug/warn'], function (exports, _emberMetal, _emberEnvironment, _emberConsole, _emberDebugDeprecate, _emberDebugWarn) { + 'use strict'; + + exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; + + /** + @module ember + @submodule ember-debug + */ + + /** + @class Ember + @public + */ + + /** + Define an assertion that will throw an exception if the condition is not met. - ```html - - Great Hamster Photos - - ``` + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - ### Supplying a tagName - By default `{{link-to}}` renders an `` element. This can - be overridden for a single use of `{{link-to}}` by supplying - a `tagName` option: + ```javascript + // Test for truthiness + Ember.assert('Must pass a valid object', obj); - ```handlebars - {{#link-to 'photoGallery' tagName="li"}} - Great Hamster Photos - {{/link-to}} + // Fail unconditionally + Ember.assert('This code path should never be run'); ``` - ```html -
  • - Great Hamster Photos -
  • - ``` + @method assert + @param {String} desc A description of the assertion. This will become + the text of the Error thrown if the assertion fails. + @param {Boolean} test Must be truthy for the assertion to pass. If + falsy, an exception will be thrown. + @public + @since 1.0.0 + */ + _emberMetal.setDebugFunction('assert', function assert(desc, test) { + if (!test) { + throw new _emberMetal.Error('Assertion Failed: ' + desc); + } + }); + + /** + Display a debug notice. - To override this option for your entire application, see - "Overriding Application-wide Defaults". + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - ### Disabling the `link-to` component - By default `{{link-to}}` is enabled. - any passed value to the `disabled` component property will disable - the `link-to` component. + ```javascript + Ember.debug('I\'m a debug notice!'); + ``` - static use: the `disabled` option: + @method debug + @param {String} message A debug message to display. + @public + */ + _emberMetal.setDebugFunction('debug', function debug(message) { + _emberConsole.default.debug('DEBUG: ' + message); + }); + + /** + Display an info notice. - ```handlebars - {{#link-to 'photoGallery' disabled=true}} - Great Hamster Photos - {{/link-to}} - ``` + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - dynamic use: the `disabledWhen` option: + @method info + @private + */ + _emberMetal.setDebugFunction('info', function info() { + _emberConsole.default.info.apply(undefined, arguments); + }); + + /** + Alias an old, deprecated method with its new counterpart. - ```handlebars - {{#link-to 'photoGallery' disabledWhen=controller.someProperty}} - Great Hamster Photos - {{/link-to}} - ``` + Display a deprecation warning with the provided message and a stack trace + (Chrome and Firefox only) when the assigned method is called. - any passed value to `disabled` will disable it except `undefined`. - to ensure that only `true` disable the `link-to` component you can - override the global behaviour of `Ember.LinkComponent`. + * In a production build, this method is defined as an empty function (NOP). ```javascript - Ember.LinkComponent.reopen({ - disabled: Ember.computed(function(key, value) { - if (value !== undefined) { - this.set('_isDisabled', value === true); - } - return value === true ? get(this, 'disabledClass') : false; - }) - }); + Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod); ``` - see "Overriding Application-wide Defaults" for more. - - ### Handling `href` - `{{link-to}}` will use your application's Router to - fill the element's `href` property with a url that - matches the path to the supplied `routeName` for your - router's configured `Location` scheme, which defaults - to Ember.HashLocation. + @method deprecateFunc + @param {String} message A description of the deprecation. + @param {Object} [options] The options object for Ember.deprecate. + @param {Function} func The new function called to replace its deprecated counterpart. + @return {Function} A new function that wraps the original function with a deprecation warning + @private + */ + _emberMetal.setDebugFunction('deprecateFunc', function deprecateFunc() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 3) { + var _ret = (function () { + var message = args[0]; + var options = args[1]; + var func = args[2]; + + return { + v: function () { + _emberMetal.deprecate(message, false, options); + return func.apply(this, arguments); + } + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + var _ret2 = (function () { + var message = args[0]; + var func = args[1]; + + return { + v: function () { + _emberMetal.deprecate(message); + return func.apply(this, arguments); + } + }; + })(); + + if (typeof _ret2 === 'object') return _ret2.v; + } + }); + + /** + Run a function meant for debugging. - ### Handling current route - `{{link-to}}` will apply a CSS class name of 'active' - when the application's current route matches - the supplied routeName. For example, if the application's - current route is 'photoGallery.recent' the following - use of `{{link-to}}`: + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - ```handlebars - {{#link-to 'photoGallery.recent'}} - Great Hamster Photos - {{/link-to}} + ```javascript + Ember.runInDebug(() => { + Ember.Component.reopen({ + didInsertElement() { + console.log("I'm happy"); + } + }); + }); ``` - will result in + @method runInDebug + @param {Function} func The function to be executed. + @since 1.5.0 + @public + */ + _emberMetal.setDebugFunction('runInDebug', function runInDebug(func) { + func(); + }); + + _emberMetal.setDebugFunction('debugSeal', function debugSeal(obj) { + Object.seal(obj); + }); + + _emberMetal.setDebugFunction('debugFreeze', function debugFreeze(obj) { + Object.freeze(obj); + }); + + _emberMetal.setDebugFunction('deprecate', _emberDebugDeprecate.default); + + _emberMetal.setDebugFunction('warn', _emberDebugWarn.default); + + /** + Will call `Ember.warn()` if ENABLE_OPTIONAL_FEATURES or + any specific FEATURES flag is truthy. - ```html -
    - Great Hamster Photos - - ``` + This method is called automatically in debug canary builds. - The CSS class name used for active classes can be customized - for a single use of `{{link-to}}` by passing an `activeClass` - option: - - ```handlebars - {{#link-to 'photoGallery.recent' activeClass="current-url"}} - Great Hamster Photos - {{/link-to}} - ``` - - ```html - - Great Hamster Photos - - ``` - - To override this option for your entire application, see - "Overriding Application-wide Defaults". - - ### Keeping a link active for other routes - - If you need a link to be 'active' even when it doesn't match - the current route, you can use the `current-when` argument. - - ```handlebars - {{#link-to 'photoGallery' current-when='photos'}} - Photo Gallery - {{/link-to}} - ``` - - This may be helpful for keeping links active for: - - * non-nested routes that are logically related - * some secondary menu approaches - * 'top navigation' with 'sub navigation' scenarios - - A link will be active if `current-when` is `true` or the current - route is the route this link would transition to. - - To match multiple routes 'space-separate' the routes: - - ```handlebars - {{#link-to 'gallery' current-when='photos drawings paintings'}} - Art Gallery - {{/link-to}} - ``` - - ### Supplying a model - An optional model argument can be used for routes whose - paths contain dynamic segments. This argument will become - the model context of the linked route: - - ```javascript - Router.map(function() { - this.route("photoGallery", {path: "hamster-photos/:photo_id"}); - }); - ``` - - ```handlebars - {{#link-to 'photoGallery' aPhoto}} - {{aPhoto.title}} - {{/link-to}} - ``` - - ```html - - Tomster - - ``` - - ### Supplying multiple models - For deep-linking to route paths that contain multiple - dynamic segments, multiple model arguments can be used. - As the router transitions through the route path, each - supplied model argument will become the context for the - route with the dynamic segments: + @private + @method _warnIfUsingStrippedFeatureFlags + @return {void} + */ + + function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featuresWereStripped) { + if (featuresWereStripped) { + _emberMetal.warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + + var keys = Object.keys(FEATURES || {}); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (key === 'isEnabled' || !(key in knownFeatures)) { + continue; + } + + _emberMetal.warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); + } + } + } + + if (!_emberMetal.isTesting()) { + (function () { + // Complain if they're using FEATURE flags in builds other than canary + _emberMetal.FEATURES['features-stripped-test'] = true; + var featuresWereStripped = true; + + if (_emberMetal.isFeatureEnabled('features-stripped-test')) { + featuresWereStripped = false; + } + + delete _emberMetal.FEATURES['features-stripped-test']; + _warnIfUsingStrippedFeatureFlags(_emberEnvironment.ENV.FEATURES, _emberMetal.DEFAULT_FEATURES, featuresWereStripped); + + // Inform the developer about the Ember Inspector if not installed. + var isFirefox = _emberEnvironment.environment.isFirefox; + var isChrome = _emberEnvironment.environment.isChrome; + + if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { + window.addEventListener('load', function () { + if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) { + var downloadURL = undefined; + + if (isChrome) { + downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'; + } else if (isFirefox) { + downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; + } + + _emberMetal.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); + } + }, false); + } + })(); + } + /** + @public + @class Ember.Debug + */ + _emberMetal.default.Debug = {}; + + /** + Allows for runtime registration of handler functions that override the default deprecation behavior. + Deprecations are invoked by calls to [Ember.deprecate](http://emberjs.com/api/classes/Ember.html#method_deprecate). + The following example demonstrates its usage by registering a handler that throws an error if the + message contains the word "should", otherwise defers to the default handler. ```javascript - Router.map(function() { - this.route("photoGallery", { path: "hamster-photos/:photo_id" }, function() { - this.route("comment", {path: "comments/:comment_id"}); - }); + Ember.Debug.registerDeprecationHandler((message, options, next) => { + if (message.indexOf('should') !== -1) { + throw new Error(`Deprecation message with should: ${message}`); + } else { + // defer to whatever handler was registered before this one + next(message, options); + } }); ``` - This argument will become the model context of the linked route: - ```handlebars - {{#link-to 'photoGallery.comment' aPhoto comment}} - {{comment.body}} - {{/link-to}} - ``` + The handler function takes the following arguments: - ```html - - A+++ would snuggle again. - - ``` +
      +
    • message - The message received from the deprecation call.
    • +
    • options - An object passed in with the deprecation call containing additional information including:
    • +
        +
      • id - An id of the deprecation in the form of package-name.specific-deprecation.
      • +
      • until - The Ember version number the feature and deprecation will be removed in.
      • +
      +
    • next - A function that calls into the previously registered handler.
    • +
    - ### Supplying an explicit dynamic segment value - If you don't have a model object available to pass to `{{link-to}}`, - an optional string or integer argument can be passed for routes whose - paths contain dynamic segments. This argument will become the value - of the dynamic segment: + @public + @static + @method registerDeprecationHandler + @param handler {Function} A function to handle deprecation calls. + @since 2.1.0 + */ + _emberMetal.default.Debug.registerDeprecationHandler = _emberDebugDeprecate.registerHandler; + /** + Allows for runtime registration of handler functions that override the default warning behavior. + Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). + The following example demonstrates its usage by registering a handler that does nothing overriding Ember's + default warning behavior. ```javascript - Router.map(function() { - this.route("photoGallery", { path: "hamster-photos/:photo_id" }); - }); - ``` - - ```handlebars - {{#link-to 'photoGallery' aPhotoId}} - {{aPhoto.title}} - {{/link-to}} - ``` - - ```html - - Tomster - - ``` - - When transitioning into the linked route, the `model` hook will - be triggered with parameters including this passed identifier. - - ### Allowing Default Action - - By default the `{{link-to}}` component prevents the default browser action - by calling `preventDefault()` as this sort of action bubbling is normally - handled internally and we do not want to take the browser to a new URL (for - example). - - If you need to override this behavior specify `preventDefault=false` in - your template: - - ```handlebars - {{#link-to 'photoGallery' aPhotoId preventDefault=false}} - {{aPhotoId.title}} - {{/link-to}} - ``` - - ### Overriding attributes - You can override any given property of the `Ember.LinkComponent` - that is generated by the `{{link-to}}` component by passing - key/value pairs, like so: - - ```handlebars - {{#link-to aPhoto tagName='li' title='Following this link will change your life' classNames='pic sweet'}} - Uh-mazing! - {{/link-to}} - ``` - - See [Ember.LinkComponent](/api/classes/Ember.LinkComponent.html) for a - complete list of overrideable properties. Be sure to also - check out inherited properties of `LinkComponent`. - - ### Overriding Application-wide Defaults - ``{{link-to}}`` creates an instance of `Ember.LinkComponent` - for rendering. To override options for your entire - application, reopen `Ember.LinkComponent` and supply the - desired values: - - ``` javascript - Ember.LinkComponent.reopen({ - activeClass: "is-active", - tagName: 'li' - }) + // next is not called, so no warnings get the default behavior + Ember.Debug.registerWarnHandler(() => {}); ``` - It is also possible to override the default event in - this manner: + The handler function takes the following arguments: - ``` javascript - Ember.LinkComponent.reopen({ - eventName: 'customEventName' - }); - ``` +
      +
    • message - The message received from the warn call.
    • +
    • options - An object passed in with the warn call containing additional information including:
    • +
        +
      • id - An id of the warning in the form of package-name.specific-warning.
      • +
      +
    • next - A function that calls into the previously registered handler.
    • +
    - @method link-to - @for Ember.Templates.helpers - @param {String} routeName - @param {Object} [context]* - @param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkComponent - @return {String} HTML string - @see {Ember.LinkComponent} @public + @static + @method registerWarnHandler + @param handler {Function} A function to handle warnings. + @since 2.1.0 */ + _emberMetal.default.Debug.registerWarnHandler = _emberDebugWarn.registerHandler; + /* + We are transitioning away from `ember.js` to `ember.debug.js` to make + it much clearer that it is only for local development purposes. + + This flag value is changed by the tooling (by a simple string replacement) + so that if `ember.js` (which must be output for backwards compat reasons) is + used a nice helpful warning message will be printed out. + */ + var runningNonEmberDebugJS = false; + exports.runningNonEmberDebugJS = runningNonEmberDebugJS; + if (runningNonEmberDebugJS) { + _emberMetal.warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); + } +}); +// reexports +enifed('ember-debug/warn', ['exports', 'ember-console', 'ember-metal', 'ember-debug/handlers'], function (exports, _emberConsole, _emberMetal, _emberDebugHandlers) { 'use strict'; + exports.registerHandler = registerHandler; + exports.default = warn; + + function registerHandler(handler) { + _emberDebugHandlers.registerHandler('warn', handler); + } + + registerHandler(function logWarning(message, options) { + _emberConsole.default.warn('WARNING: ' + message); + if ('trace' in _emberConsole.default) { + _emberConsole.default.trace(); + } + }); + + var missingOptionsDeprecation = 'When calling `Ember.warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; + exports.missingOptionsDeprecation = missingOptionsDeprecation; + var missingOptionsIdDeprecation = 'When calling `Ember.warn` you must provide `id` in options.'; + + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; /** - `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. + @module ember + @submodule ember-debug + */ + + /** + Display a warning with the provided message. - `Ember.LinkComponent` components are invoked with {{#link-to}}. Properties - of this class can be overridden with `reopen` to customize application-wide - behavior. + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - @class LinkComponent - @namespace Ember - @extends Ember.Component - @see {Ember.Templates.helpers.link-to} - @private - **/ - var LinkComponent = _emberGlimmerComponent.default.extend({ - layout: _emberGlimmerTemplatesLinkTo.default, + @method warn + @param {String} message A warning to display. + @param {Boolean} test An optional boolean. If falsy, the warning + will be displayed. + @param {Object} options An object that can be used to pass a unique + `id` for this warning. The `id` can be used by Ember debugging tools + to change the behavior (raise, log, or silence) for that specific warning. + The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" + @for Ember + @public + @since 1.0.0 + */ - tagName: 'a', + function warn(message, test, options) { + if (!options) { + _emberMetal.deprecate(missingOptionsDeprecation, false, { + id: 'ember-debug.warn-options-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } - /** - @deprecated Use current-when instead. - @property currentWhen - @private - */ - currentWhen: _emberRuntime.deprecatingAlias('current-when', { id: 'ember-routing-view.deprecated-current-when', until: '3.0.0' }), + if (options && !options.id) { + _emberMetal.deprecate(missingOptionsIdDeprecation, false, { + id: 'ember-debug.warn-id-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } - /** - Used to determine when this `LinkComponent` is active. - @property currentWhen - @public - */ - 'current-when': null, + _emberDebugHandlers.invoke.apply(undefined, ['warn'].concat(babelHelpers.slice.call(arguments))); + } +}); +enifed('ember-environment/global', ['exports'], function (exports) { + /* globals global, window, self, mainContext */ - /** - Sets the `title` attribute of the `LinkComponent`'s HTML element. - @property title - @default null - @public - **/ - title: null, + // from lodash to catch fake globals + 'use strict'; - /** - Sets the `rel` attribute of the `LinkComponent`'s HTML element. - @property rel - @default null - @public - **/ - rel: null, + function checkGlobal(value) { + return value && value.Object === Object ? value : undefined; + } - /** - Sets the `tabindex` attribute of the `LinkComponent`'s HTML element. - @property tabindex - @default null - @public - **/ - tabindex: null, + // element ids can ruin global miss checks + function checkElementIdShadowing(value) { + return value && value.nodeType === undefined ? value : undefined; + } - /** - Sets the `target` attribute of the `LinkComponent`'s HTML element. - @since 1.8.0 - @property target - @default null - @public - **/ - target: null, + // export real global + exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper + new Function('return this')(); + // eval outside of strict mode +}); +enifed('ember-environment/index', ['exports', 'ember-environment/global', 'ember-environment/utils'], function (exports, _emberEnvironmentGlobal, _emberEnvironmentUtils) { + /* globals module */ + 'use strict'; - /** - The CSS class to apply to `LinkComponent`'s element when its `active` - property is `true`. - @property activeClass - @type String - @default active - @public - **/ - activeClass: 'active', + /** + 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 + backwards compatibility with earlier versions of Ember). The `EmberENV` + hash must be created before loading Ember. + + @class EmberENV + @type Object + @public + */ + var ENV = typeof _emberEnvironmentGlobal.default.EmberENV === 'object' && _emberEnvironmentGlobal.default.EmberENV || typeof _emberEnvironmentGlobal.default.ENV === 'object' && _emberEnvironmentGlobal.default.ENV || {}; - /** - The CSS class to apply to `LinkComponent`'s element when its `loading` - property is `true`. - @property loadingClass - @type String - @default loading - @private - **/ - loadingClass: 'loading', + exports.ENV = ENV; + // ENABLE_ALL_FEATURES was documented, but you can't actually enable non optional features. + if (ENV.ENABLE_ALL_FEATURES) { + ENV.ENABLE_OPTIONAL_FEATURES = true; + } - /** - The CSS class to apply to a `LinkComponent`'s element when its `disabled` - property is `true`. - @property disabledClass - @type String - @default disabled - @private - **/ - disabledClass: 'disabled', - _isDisabled: false, + /** + Determines whether Ember should add to `Array`, `Function`, and `String` + native object prototypes, a few extra methods in order to provide a more + friendly API. + + We generally recommend leaving this option set to true however, if you need + to turn it off, you can add the configuration property + `EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`. + + Note, when disabled (the default configuration for Ember Addons), you will + instead have to access all methods and functions from the Ember + namespace. + + @property EXTEND_PROTOTYPES + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.EXTEND_PROTOTYPES = _emberEnvironmentUtils.normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); - /** - Determines whether the `LinkComponent` will trigger routing via - the `replaceWith` routing strategy. - @property replace - @type Boolean - @default false - @public - **/ - replace: false, + /** + The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log + a full stack trace during deprecation warnings. + + @property LOG_STACKTRACE_ON_DEPRECATION + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.LOG_STACKTRACE_ON_DEPRECATION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); + /** + The `LOG_VERSION` property, when true, tells Ember to log versions of all + dependent libraries in use. + + @property LOG_VERSION + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.LOG_VERSION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_VERSION); + + // default false + ENV.MODEL_FACTORY_INJECTIONS = _emberEnvironmentUtils.defaultFalse(ENV.MODEL_FACTORY_INJECTIONS); + + /** + Debug parameter you can turn on. This will log all bindings that fire to + the console. This should be disabled in production code. Note that you + can also enable this from the console or temporarily. + + @property LOG_BINDINGS + @for EmberENV + @type Boolean + @default false + @public + */ + ENV.LOG_BINDINGS = _emberEnvironmentUtils.defaultFalse(ENV.LOG_BINDINGS); + + ENV.RAISE_ON_DEPRECATION = _emberEnvironmentUtils.defaultFalse(ENV.RAISE_ON_DEPRECATION); + + // check if window exists and actually is the global + var hasDOM = typeof window !== 'undefined' && window === _emberEnvironmentGlobal.default && window.document && window.document.createElement && !ENV.disableBrowserEnvironment; // is this a public thing? + + // legacy imports/exports/lookup stuff (should we keep this??) + var originalContext = _emberEnvironmentGlobal.default.Ember || {}; + + var context = { + // import jQuery + imports: originalContext.imports || _emberEnvironmentGlobal.default, + // export Ember + exports: originalContext.exports || _emberEnvironmentGlobal.default, + // search for Namespaces + lookup: originalContext.lookup || _emberEnvironmentGlobal.default + }; + + exports.context = context; + // TODO: cleanup single source of truth issues with this stuff + var environment = hasDOM ? { + hasDOM: true, + isChrome: !!window.chrome && !window.opera, + isFirefox: typeof InstallTrigger !== 'undefined', + isPhantom: !!window.callPhantom, + location: window.location, + history: window.history, + userAgent: window.navigator.userAgent, + window: window + } : { + hasDOM: false, + isChrome: false, + isFirefox: false, + isPhantom: false, + location: null, + history: null, + userAgent: 'Lynx (textmode)', + window: null + }; + exports.environment = environment; +}); +enifed("ember-environment/utils", ["exports"], function (exports) { + "use strict"; + + exports.defaultTrue = defaultTrue; + exports.defaultFalse = defaultFalse; + exports.normalizeExtendPrototypes = normalizeExtendPrototypes; + + function defaultTrue(v) { + return v === false ? false : true; + } + + function defaultFalse(v) { + return v === true ? true : false; + } + + function normalizeExtendPrototypes(obj) { + if (obj === false) { + return { String: false, Array: false, Function: false }; + } else if (!obj || obj === true) { + return { String: true, Array: true, Function: true }; + } else { + return { + String: defaultTrue(obj.String), + Array: defaultTrue(obj.Array), + Function: defaultTrue(obj.Function) + }; + } + } +}); +enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; + + /** + @module ember + @submodule ember-extension-support + */ + + /** + The `ContainerDebugAdapter` helps the container and resolver interface + with tools that debug Ember such as the + [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class can be extended by a custom resolver implementer + to override some of the methods with library-specific code. + + The methods likely to be overridden are: + + * `canCatalogEntriesByType` + * `catalogEntriesByType` + + The adapter will need to be registered + in the application's container as `container-debug-adapter:main`. + + Example: + + ```javascript + Application.initializer({ + name: "containerDebugAdapter", + + initialize(application) { + application.register('container-debug-adapter:main', require('app/container-debug-adapter')); + } + }); + ``` + + @class ContainerDebugAdapter + @namespace Ember + @extends Ember.Object + @since 1.5.0 + @public + */ + exports.default = _emberRuntime.Object.extend({ /** - By default the `{{link-to}}` component will bind to the `href` and - `title` attributes. It's discouraged that you override these defaults, - however you can push onto the array if needed. - @property attributeBindings - @type Array | String - @default ['title', 'rel', 'tabindex', 'target'] + The resolver instance of the application + being debugged. This property will be injected + on creation. + @property resolver + @default null @public */ - attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'], + resolver: null, /** - By default the `{{link-to}}` component will bind to the `active`, `loading`, - and `disabled` classes. It is discouraged to override these directly. - @property classNameBindings - @type Array - @default ['active', 'loading', 'disabled', 'ember-transitioning-in', 'ember-transitioning-out'] + Returns true if it is possible to catalog a list of available + classes in the resolver for a given type. + @method canCatalogEntriesByType + @param {String} type The type. e.g. "model", "controller", "route". + @return {boolean} whether a list is available for this type. @public */ - classNameBindings: ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'], + canCatalogEntriesByType: function (type) { + if (type === 'model' || type === 'template') { + return false; + } - /** - By default the `{{link-to}}` component responds to the `click` event. You - can override this globally by setting this property to your custom - event name. - This is particularly useful on mobile when one wants to avoid the 300ms - click delay using some sort of custom `tap` event. - @property eventName - @type String - @default click - @private - */ - eventName: 'click', + return true; + }, - // this is doc'ed here so it shows up in the events - // section of the API documentation, which is where - // people will likely go looking for it. /** - Triggers the `LinkComponent`'s routing behavior. If - `eventName` is changed to a value other than `click` - the routing behavior will trigger on that custom event - instead. - @event click - @private + Returns the available classes a given type. + @method catalogEntriesByType + @param {String} type The type. e.g. "model", "controller", "route". + @return {Array} An array of strings. + @public */ + catalogEntriesByType: function (type) { + var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); + var types = _emberRuntime.A(); + var typeSuffixRegex = new RegExp(_emberRuntime.String.classify(type) + '$'); - /** - An overridable method called when `LinkComponent` objects are instantiated. - Example: - ```javascript - App.MyLinkComponent = Ember.LinkComponent.extend({ - init: function() { - this._super(...arguments); - Ember.Logger.log('Event is ' + this.get('eventName')); + namespaces.forEach(function (namespace) { + if (namespace !== _emberMetal.default) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { + continue; + } + if (typeSuffixRegex.test(key)) { + var klass = namespace[key]; + if (_emberRuntime.typeOf(klass) === 'class') { + types.push(_emberRuntime.String.dasherize(key.replace(typeSuffixRegex, ''))); + } + } + } } }); - ``` - NOTE: If you do override `init` for a framework class like `Ember.View`, - be sure to call `this._super(...arguments)` in your - `init` declaration! If you don't, Ember may not have an opportunity to - do important setup work, and you'll see strange behavior in your - application. - @method init - @private - */ + return types; + } + }); +}); +// Ember as namespace +enifed('ember-extension-support/data_adapter', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'container', 'ember-application'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _container, _emberApplication) { + 'use strict'; + + /** + @module ember + @submodule ember-extension-support + */ + + /** + The `DataAdapter` helps a data persistence library + interface with tools that debug Ember such + as the [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class will be extended by a persistence library + which will override some of the methods with + library-specific code. + + The methods likely to be overridden are: + + * `getFilters` + * `detect` + * `columnsForType` + * `getRecords` + * `getRecordColumnValues` + * `getRecordKeywords` + * `getRecordFilterValues` + * `getRecordColor` + * `observeRecord` + + The adapter will need to be registered + in the application's container as `dataAdapter:main`. + + Example: + + ```javascript + Application.initializer({ + name: "data-adapter", + + initialize: function(application) { + application.register('data-adapter:main', DS.DataAdapter); + } + }); + ``` + + @class DataAdapter + @namespace Ember + @extends EmberObject + @public + */ + exports.default = _emberRuntime.Object.extend({ init: function () { this._super.apply(this, arguments); - - // Map desired event name to invoke function - var eventName = _emberMetal.get(this, 'eventName'); - this.on(eventName, this, this._invoke); + this.releaseMethods = _emberRuntime.A(); }, - _routing: _emberRuntime.inject.service('-routing'), + /** + The container-debug-adapter which is used + to list all models. + @property containerDebugAdapter + @default undefined + @since 1.5.0 + @public + **/ + containerDebugAdapter: undefined, /** - Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass` - CSS `class` to the element when the link is disabled. - When `true` interactions with the element will not trigger route changes. - @property disabled - @private + The number of attributes to send + as columns. (Enough to make the record + identifiable). + @private + @property attributeLimit + @default 3 + @since 1.3.0 */ - disabled: _emberMetal.computed({ - get: function (key, value) { - return false; - }, - set: function (key, value) { - if (value !== undefined) { - this.set('_isDisabled', value); - } - - return value ? _emberMetal.get(this, 'disabledClass') : false; - } - }), - - _computeActive: function (routerState) { - if (_emberMetal.get(this, 'loading')) { - return false; - } - - var routing = _emberMetal.get(this, '_routing'); - var models = _emberMetal.get(this, 'models'); - var resolvedQueryParams = _emberMetal.get(this, 'resolvedQueryParams'); + attributeLimit: 3, - var currentWhen = _emberMetal.get(this, 'current-when'); - var isCurrentWhenSpecified = !!currentWhen; - currentWhen = currentWhen || _emberMetal.get(this, 'qualifiedRouteName'); - currentWhen = currentWhen.split(' '); + /** + Ember Data > v1.0.0-beta.18 + requires string model names to be passed + around instead of the actual factories. + This is a stamp for the Ember Inspector + to differentiate between the versions + to be able to support older versions too. + @public + @property acceptsModelName + */ + acceptsModelName: true, - for (var i = 0; i < currentWhen.length; i++) { - if (routing.isActiveForRoute(models, resolvedQueryParams, currentWhen[i], routerState, isCurrentWhenSpecified)) { - return _emberMetal.get(this, 'activeClass'); - } - } + /** + Stores all methods that clear observers. + These methods will be called on destruction. + @private + @property releaseMethods + @since 1.3.0 + */ + releaseMethods: _emberRuntime.A(), - return false; + /** + Specifies how records can be filtered. + Records returned will need to have a `filterValues` + property with a key for every name in the returned array. + @public + @method getFilters + @return {Array} List of objects defining filters. + The object should have a `name` and `desc` property. + */ + getFilters: function () { + return _emberRuntime.A(); }, /** - Accessed as a classname binding to apply the `LinkComponent`'s `activeClass` - CSS `class` to the element when the link is active. - A `LinkComponent` is considered active when its `currentWhen` property is `true` - or the application's current route is the route the `LinkComponent` would trigger - transitions into. - The `currentWhen` property can match against multiple routes by separating - route names using the ` ` (space) character. - @property active - @private + Fetch the model types and observe them for changes. + @public + @method watchModelTypes + @param {Function} typesAdded Callback to call to add types. + Takes an array of objects containing wrapped types (returned from `wrapModelType`). + @param {Function} typesUpdated Callback to call when a type has changed. + Takes an array of objects containing wrapped types. + @return {Function} Method to call to remove all observers */ - active: _emberMetal.computed('attrs.params', '_routing.currentState', function computeLinkToComponentActive() { - var currentState = _emberMetal.get(this, '_routing.currentState'); - if (!currentState) { - return false; - } - - return this._computeActive(currentState); - }), + watchModelTypes: function (typesAdded, typesUpdated) { + var _this = this; - willBeActive: _emberMetal.computed('_routing.targetState', function computeLinkToComponentWillBeActive() { - var routing = _emberMetal.get(this, '_routing'); - var targetState = _emberMetal.get(routing, 'targetState'); - if (_emberMetal.get(routing, 'currentState') === targetState) { - return; - } + var modelTypes = this.getModelTypes(); + var releaseMethods = _emberRuntime.A(); + var typesToSend = undefined; - return !!this._computeActive(targetState); - }), + typesToSend = modelTypes.map(function (type) { + var klass = type.klass; + var wrapped = _this.wrapModelType(klass, type.name); + releaseMethods.push(_this.observeModelType(type.name, typesUpdated)); + return wrapped; + }); - transitioningIn: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningIn() { - var willBeActive = _emberMetal.get(this, 'willBeActive'); - if (typeof willBeActive === 'undefined') { - return false; - } + typesAdded(typesToSend); - return !_emberMetal.get(this, 'active') && willBeActive && 'ember-transitioning-in'; - }), + var release = function () { + releaseMethods.forEach(function (fn) { + return fn(); + }); + _this.releaseMethods.removeObject(release); + }; + this.releaseMethods.pushObject(release); + return release; + }, - transitioningOut: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningOut() { - var willBeActive = _emberMetal.get(this, 'willBeActive'); - if (typeof willBeActive === 'undefined') { - return false; + _nameToClass: function (type) { + if (typeof type === 'string') { + var owner = _emberUtils.getOwner(this); + type = owner[_container.FACTORY_FOR]('model:' + type).class; } - - return _emberMetal.get(this, 'active') && !willBeActive && 'ember-transitioning-out'; - }), + return type; + }, /** - Event handler that invokes the link, activating the associated route. - @method _invoke - @param {Event} event - @private + Fetch the records of a given type and observe them for changes. + @public + @method watchRecords + @param {String} modelName The model name. + @param {Function} recordsAdded Callback to call to add records. + Takes an array of objects containing wrapped records. + The object should have the following properties: + columnValues: {Object} The key and value of a table cell. + object: {Object} The actual record object. + @param {Function} recordsUpdated Callback to call when a record has changed. + Takes an array of objects containing wrapped records. + @param {Function} recordsRemoved Callback to call when a record has removed. + Takes the following parameters: + index: The array index where the records were removed. + count: The number of records removed. + @return {Function} Method to call to remove all observers. */ - _invoke: function (event) { - if (!_emberViews.isSimpleClick(event)) { - return true; - } + watchRecords: function (modelName, recordsAdded, recordsUpdated, recordsRemoved) { + var _this2 = this; - var preventDefault = _emberMetal.get(this, 'preventDefault'); - var targetAttribute = _emberMetal.get(this, 'target'); + var releaseMethods = _emberRuntime.A(); + var klass = this._nameToClass(modelName); + var records = this.getRecords(klass, modelName); + var release = undefined; - if (preventDefault !== false) { - if (!targetAttribute || targetAttribute === '_self') { - event.preventDefault(); - } + function recordUpdated(updatedRecord) { + recordsUpdated([updatedRecord]); } - if (_emberMetal.get(this, 'bubbles') === false) { - event.stopPropagation(); - } + var recordsToSend = records.map(function (record) { + releaseMethods.push(_this2.observeRecord(record, recordUpdated)); + return _this2.wrapRecord(record); + }); - if (_emberMetal.get(this, '_isDisabled')) { - return false; - } + var contentDidChange = function (array, idx, removedCount, addedCount) { + for (var i = idx; i < idx + addedCount; i++) { + var record = _emberRuntime.objectAt(array, i); + var wrapped = _this2.wrapRecord(record); + releaseMethods.push(_this2.observeRecord(record, recordUpdated)); + recordsAdded([wrapped]); + } - if (_emberMetal.get(this, 'loading')) { - _emberConsole.default.warn('This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'); - return false; - } + if (removedCount) { + recordsRemoved(idx, removedCount); + } + }; - if (targetAttribute && targetAttribute !== '_self') { - return false; - } - - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var models = _emberMetal.get(this, 'models'); - var queryParams = _emberMetal.get(this, 'queryParams.values'); - var shouldReplace = _emberMetal.get(this, 'replace'); + var observer = { didChange: contentDidChange, willChange: function () { + return this; + } }; + _emberRuntime.addArrayObserver(records, this, observer); - var payload = { - queryParams: queryParams, - routeName: qualifiedRouteName + release = function () { + releaseMethods.forEach(function (fn) { + return fn(); + }); + _emberRuntime.removeArrayObserver(records, _this2, observer); + _this2.releaseMethods.removeObject(release); }; - _emberMetal.flaggedInstrument('interaction.link-to', payload, this._generateTransition(payload, qualifiedRouteName, models, queryParams, shouldReplace)); - }, + recordsAdded(recordsToSend); - _generateTransition: function (payload, qualifiedRouteName, models, queryParams, shouldReplace) { - var routing = _emberMetal.get(this, '_routing'); - return function () { - payload.transition = routing.transitionTo(qualifiedRouteName, models, queryParams, shouldReplace); - }; + this.releaseMethods.pushObject(release); + return release; }, - queryParams: null, - - qualifiedRouteName: _emberMetal.computed('targetRouteName', '_routing.currentState', function computeLinkToComponentQualifiedRouteName() { - var params = _emberMetal.get(this, 'params').slice(); - var lastParam = params[params.length - 1]; - if (lastParam && lastParam.isQueryParams) { - params.pop(); - } - var onlyQueryParamsSupplied = this[_emberGlimmerComponent.HAS_BLOCK] ? params.length === 0 : params.length === 1; - if (onlyQueryParamsSupplied) { - return _emberMetal.get(this, '_routing.currentRouteName'); - } - return _emberMetal.get(this, 'targetRouteName'); - }), - - resolvedQueryParams: _emberMetal.computed('queryParams', function computeLinkToComponentResolvedQueryParams() { - var resolvedQueryParams = {}; - var queryParams = _emberMetal.get(this, 'queryParams'); - - if (!queryParams) { - return resolvedQueryParams; - } + /** + Clear all observers before destruction + @private + @method willDestroy + */ + willDestroy: function () { + this._super.apply(this, arguments); + this.releaseMethods.forEach(function (fn) { + return fn(); + }); + }, - var values = queryParams.values; - for (var key in values) { - if (!values.hasOwnProperty(key)) { - continue; - } - resolvedQueryParams[key] = values[key]; - } + /** + Detect whether a class is a model. + Test that against the model class + of your persistence library. + @private + @method detect + @param {Class} klass The class to test. + @return boolean Whether the class is a model class or not. + */ + detect: function (klass) { + return false; + }, - return resolvedQueryParams; - }), + /** + Get the columns for a given model type. + @private + @method columnsForType + @param {Class} type The model type. + @return {Array} An array of columns of the following format: + name: {String} The name of the column. + desc: {String} Humanized description (what would show in a table column name). + */ + columnsForType: function (type) { + return _emberRuntime.A(); + }, /** - Sets the element's `href` attribute to the url for - the `LinkComponent`'s targeted route. - If the `LinkComponent`'s `tagName` is changed to a value other - than `a`, this property will be ignored. - @property href - @private + Adds observers to a model type class. + @private + @method observeModelType + @param {String} modelName The model type name. + @param {Function} typesUpdated Called when a type is modified. + @return {Function} The function to call to remove observers. */ - href: _emberMetal.computed('models', 'qualifiedRouteName', function computeLinkToComponentHref() { - if (_emberMetal.get(this, 'tagName') !== 'a') { - return; - } - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var models = _emberMetal.get(this, 'models'); + observeModelType: function (modelName, typesUpdated) { + var _this3 = this; - if (_emberMetal.get(this, 'loading')) { - return _emberMetal.get(this, 'loadingHref'); - } + var klass = this._nameToClass(modelName); + var records = this.getRecords(klass, modelName); - var routing = _emberMetal.get(this, '_routing'); - var queryParams = _emberMetal.get(this, 'queryParams.values'); + function onChange() { + typesUpdated([this.wrapModelType(klass, modelName)]); + } - _emberMetal.runInDebug(function () { - /* - * Unfortunately, to get decent error messages, we need to do this. - * In some future state we should be able to use a "feature flag" - * which allows us to strip this without needing to call it twice. - * - * if (isDebugBuild()) { - * // Do the useful debug thing, probably including try/catch. - * } else { - * // Do the performant thing. - * } - */ - try { - routing.generateURL(qualifiedRouteName, models, queryParams); - } catch (e) { - _emberMetal.assert('You attempted to define a `{{link-to "' + qualifiedRouteName + '"}}` but did not pass the parameters required for generating its dynamic segments. ' + e.message); + var observer = { + didChange: function () { + _emberMetal.run.scheduleOnce('actions', this, onChange); + }, + willChange: function () { + return this; } - }); + }; - return routing.generateURL(qualifiedRouteName, models, queryParams); - }), + _emberRuntime.addArrayObserver(records, this, observer); - loading: _emberMetal.computed('_modelsAreLoaded', 'qualifiedRouteName', function computeLinkToComponentLoading() { - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var modelsAreLoaded = _emberMetal.get(this, '_modelsAreLoaded'); + var release = function () { + return _emberRuntime.removeArrayObserver(records, _this3, observer); + }; - if (!modelsAreLoaded || qualifiedRouteName == null) { - return _emberMetal.get(this, 'loadingClass'); - } - }), + return release; + }, - _modelsAreLoaded: _emberMetal.computed('models', function computeLinkToComponentModelsAreLoaded() { - var models = _emberMetal.get(this, 'models'); - for (var i = 0; i < models.length; i++) { - if (models[i] == null) { - return false; - } - } + /** + Wraps a given model type and observes changes to it. + @private + @method wrapModelType + @param {Class} klass A model class. + @param {String} modelName Name of the class. + @return {Object} Contains the wrapped type and the function to remove observers + Format: + type: {Object} The wrapped type. + The wrapped type has the following format: + name: {String} The name of the type. + count: {Integer} The number of records available. + columns: {Columns} An array of columns to describe the record. + object: {Class} The actual Model type class. + release: {Function} The function to remove observers. + */ + wrapModelType: function (klass, name) { + var records = this.getRecords(klass, name); + var typeToSend = undefined; - return true; - }), + typeToSend = { + name: name, + count: _emberMetal.get(records, 'length'), + columns: this.columnsForType(klass), + object: klass + }; - _getModels: function (params) { - var modelCount = params.length - 1; - var models = new Array(modelCount); + return typeToSend; + }, - for (var i = 0; i < modelCount; i++) { - var value = params[i + 1]; + /** + Fetches all models defined in the application. + @private + @method getModelTypes + @return {Array} Array of model types. + */ + getModelTypes: function () { + var _this4 = this; - while (_emberRuntime.ControllerMixin.detect(value)) { - _emberMetal.deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' + (this.parentView ? 'Please update `' + this.parentView + '` to use `{{link-to "post" someController.model}}` instead.' : ''), false, { id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }); - value = value.get('model'); - } + var containerDebugAdapter = this.get('containerDebugAdapter'); + var types = undefined; - models[i] = value; + if (containerDebugAdapter.canCatalogEntriesByType('model')) { + types = containerDebugAdapter.catalogEntriesByType('model'); + } else { + types = this._getObjectsOnNamespaces(); } - return models; + // New adapters return strings instead of classes. + types = _emberRuntime.A(types).map(function (name) { + return { + klass: _this4._nameToClass(name), + name: name + }; + }); + types = _emberRuntime.A(types).filter(function (type) { + return _this4.detect(type.klass); + }); + + return _emberRuntime.A(types); }, /** - The default href value to use while a link-to is loading. - Only applies when tagName is 'a' - @property loadingHref - @type String - @default # - @private + Loops over all namespaces and all objects + attached to them. + @private + @method _getObjectsOnNamespaces + @return {Array} Array of model type strings. */ - loadingHref: '#', + _getObjectsOnNamespaces: function () { + var _this5 = this; - didReceiveAttrs: function () { - var queryParams = undefined; + var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); + var types = _emberRuntime.A(); - var params = _emberMetal.get(this, 'params'); + namespaces.forEach(function (namespace) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { + continue; + } + // Even though we will filter again in `getModelTypes`, + // we should not call `lookupFactory` on non-models + // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) + if (!_this5.detect(namespace[key])) { + continue; + } + var _name = _emberRuntime.String.dasherize(key); + if (!(namespace instanceof _emberApplication.Application) && namespace.toString()) { + _name = namespace + '/' + _name; + } + types.push(_name); + } + }); + return types; + }, - if (params) { - // Do not mutate params in place - params = params.slice(); - } + /** + Fetches all loaded records for a given type. + @private + @method getRecords + @return {Array} An array of records. + This array will be observed for changes, + so it should update when new records are added/removed. + */ + getRecords: function (type) { + return _emberRuntime.A(); + }, - _emberMetal.assert('You must provide one or more parameters to the link-to component.', (function () { - if (!params) { - return false; - } + /** + Wraps a record and observers changes to it. + @private + @method wrapRecord + @param {Object} record The record instance. + @return {Object} The wrapped record. Format: + columnValues: {Array} + searchKeywords: {Array} + */ + wrapRecord: function (record) { + var recordToSend = { object: record }; - return params.length; - })()); + recordToSend.columnValues = this.getRecordColumnValues(record); + recordToSend.searchKeywords = this.getRecordKeywords(record); + recordToSend.filterValues = this.getRecordFilterValues(record); + recordToSend.color = this.getRecordColor(record); - var disabledWhen = _emberMetal.get(this, 'disabledWhen'); - if (disabledWhen !== undefined) { - this.set('disabled', disabledWhen); - } + return recordToSend; + }, - // Process the positional arguments, in order. - // 1. Inline link title comes first, if present. - if (!this[_emberGlimmerComponent.HAS_BLOCK]) { - this.set('linkTitle', params.shift()); - } + /** + Gets the values for each column. + @private + @method getRecordColumnValues + @return {Object} Keys should match column names defined + by the model type. + */ + getRecordColumnValues: function (record) { + return {}; + }, - // 2. `targetRouteName` is now always at index 0. - this.set('targetRouteName', params[0]); + /** + Returns keywords to match when searching records. + @private + @method getRecordKeywords + @return {Array} Relevant keywords for search. + */ + getRecordKeywords: function (record) { + return _emberRuntime.A(); + }, - // 3. The last argument (if still remaining) is the `queryParams` object. - var lastParam = params[params.length - 1]; + /** + Returns the values of filters defined by `getFilters`. + @private + @method getRecordFilterValues + @param {Object} record The record instance. + @return {Object} The filter values. + */ + getRecordFilterValues: function (record) { + return {}; + }, - if (lastParam && lastParam.isQueryParams) { - queryParams = params.pop(); - } else { - queryParams = { values: {} }; - } - this.set('queryParams', queryParams); + /** + Each record can have a color that represents its state. + @private + @method getRecordColor + @param {Object} record The record instance + @return {String} The records color. + Possible options: black, red, blue, green. + */ + getRecordColor: function (record) { + return null; + }, - // 4. Any remaining indices (excepting `targetRouteName` at 0) are `models`. - if (params.length > 1) { - this.set('models', this._getModels(params)); - } else { - this.set('models', []); - } + /** + Observes all relevant properties and re-sends the wrapped record + when a change occurs. + @private + @method observerRecord + @param {Object} record The record instance. + @param {Function} recordUpdated The callback to call when a record is updated. + @return {Function} The function to call to remove all observers. + */ + observeRecord: function (record, recordUpdated) { + return function () {}; } }); +}); +enifed('ember-extension-support/index', ['exports', 'ember-extension-support/data_adapter', 'ember-extension-support/container_debug_adapter'], function (exports, _emberExtensionSupportData_adapter, _emberExtensionSupportContainer_debug_adapter) { + /** + @module ember + @submodule ember-extension-support + */ - LinkComponent.toString = function () { - return 'LinkComponent'; - }; - - LinkComponent.reopenClass({ - positionalParams: 'params' - }); + 'use strict'; - exports.default = LinkComponent; + exports.DataAdapter = _emberExtensionSupportData_adapter.default; + exports.ContainerDebugAdapter = _emberExtensionSupportContainer_debug_adapter.default; }); -enifed('ember-glimmer/components/text_area', ['exports', 'ember-glimmer/component', 'ember-views', 'ember-glimmer/templates/empty'], function (exports, _emberGlimmerComponent, _emberViews, _emberGlimmerTemplatesEmpty) { +enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'ember-runtime', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference', '@glimmer/runtime'], function (exports, _emberUtils, _emberViews, _emberRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference, _glimmerRuntime) { + 'use strict'; + + var _CoreView$extend; + + var DIRTY_TAG = _emberUtils.symbol('DIRTY_TAG'); + exports.DIRTY_TAG = DIRTY_TAG; + var ARGS = _emberUtils.symbol('ARGS'); + exports.ARGS = ARGS; + var ROOT_REF = _emberUtils.symbol('ROOT_REF'); + exports.ROOT_REF = ROOT_REF; + var IS_DISPATCHING_ATTRS = _emberUtils.symbol('IS_DISPATCHING_ATTRS'); + exports.IS_DISPATCHING_ATTRS = IS_DISPATCHING_ATTRS; + var HAS_BLOCK = _emberUtils.symbol('HAS_BLOCK'); + exports.HAS_BLOCK = HAS_BLOCK; + var BOUNDS = _emberUtils.symbol('BOUNDS'); + + exports.BOUNDS = BOUNDS; /** @module ember @submodule ember-glimmer */ - 'use strict'; /** - `{{textarea}}` inserts a new instance of ` + ```app/components/person-profile.hbs +

    {{person.title}}

    + {{! Executed in the component's context. }} + {{yield}} {{! block contents }} ``` - Bound: + If you want to customize the component, in order to + handle events or actions, you implement a subclass + of `Ember.Component` named after the name of the + component. - In the following example, the `writtenWords` property on `App.ApplicationController` - will be updated live as the user types 'Lots of text that IS bound' into - the text area of their browser's window. + For example, you could implement the action + `hello` for the `person-profile` component: - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound" + ```app/components/person-profile.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + actions: { + hello(name) { + console.log("Hello", name); + } + } }); ``` - ```handlebars - {{textarea value=writtenWords}} - ``` + And then use it in the component's template: - Would result in the following HTML: + ```app/templates/components/person-profile.hbs +

    {{person.title}}

    + {{yield}} + + ``` + + Components must have a `-` in their name to avoid + conflicts with built-in controls that wrap HTML + elements. This is consistent with the same + requirement in web components. + + + ## HTML Tag + + The default HTML tag name used for a component's DOM representation is `div`. + This can be customized by setting the `tagName` property. + The following component class: + + ```app/components/emphasized-paragraph.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'em' + }); + ``` + + Would result in instances with the following HTML: ```html - + ``` - If you wanted a one way binding between the text area and a div tag - somewhere else on your screen, you could use `Ember.computed.oneWay`: - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound", - outputWrittenWords: Ember.computed.oneWay("writtenWords") + ## HTML `class` Attribute + + The HTML `class` attribute of a component's tag can be set by providing a + `classNames` property that is set to an array of strings: + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNames: ['my-class', 'my-other-class'] }); ``` - ```handlebars - {{textarea value=writtenWords}} -
    - {{outputWrittenWords}} -
    + Will result in component instances with an HTML representation of: + + ```html +
    ``` - Would result in the following HTML: + `class` attribute values can also be set by providing a `classNameBindings` + property set to an array of properties names for the component. The return value + of these properties will be added as part of the value for the components's `class` + attribute. These properties can be computed properties: + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['propertyA', 'propertyB'], + propertyA: 'from-a', + propertyB: Ember.computed(function() { + if (someLogic) { return 'from-b'; } + }) + }); + ``` + + Will result in component instances with an HTML representation of: ```html - - <-- the following div will be updated in real time as you type --> -
    - Lots of text that IS bound -
    +
    ``` - Finally, this example really shows the power and ease of Ember when two - properties are bound to eachother via `Ember.computed.alias`. Type into - either text area box and they'll both stay in sync. Note that - `Ember.computed.alias` costs more in terms of performance, so only use it when - your really binding in both directions: + If the value of a class name binding returns a boolean the property name + itself will be used as the class name if the property is true. + The class name will not be added if the value is `false` or `undefined`. - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound", - twoWayWrittenWords: Ember.computed.alias("writtenWords") + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['hovered'], + hovered: true }); ``` - ```handlebars - {{textarea value=writtenWords}} - {{textarea value=twoWayWrittenWords}} + Will result in component instances with an HTML representation of: + + ```html +
    + ``` + + When using boolean class name bindings you can supply a string value other + than the property name for use as the `class` HTML attribute by appending the + preferred value after a ":" character when defining the binding: + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['awesome:so-very-cool'], + awesome: true + }); ``` + Will result in component instances with an HTML representation of: + ```html - - <-- both updated in real time --> - +
    ``` - ### Actions + Boolean value class name bindings whose property names are in a + camelCase-style format will be converted to a dasherized format: - The helper can send multiple actions based on user events. - The action property defines the action which is send when - the user presses the return key. + ```app/components/my-widget.js + import Ember from 'ember'; - ```handlebars - {{input action="submit"}} + export default Ember.Component.extend({ + classNameBindings: ['isUrgent'], + isUrgent: true + }); ``` - The helper allows some user events to send actions. + Will result in component instances with an HTML representation of: - * `enter` - * `insert-newline` - * `escape-press` - * `focus-in` - * `focus-out` - * `key-press` + ```html +
    + ``` - For example, if you desire an action to be sent when the input is blurred, - you only need to setup the action name to the event name property. + Class name bindings can also refer to object values that are found by + traversing a path relative to the component itself: - ```handlebars - {{textarea focus-in="alertMessage"}} + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['messages.empty'], + messages: Ember.Object.create({ + empty: true + }) + }); ``` - See more about [Text Support Actions](/api/classes/Ember.TextArea.html) + Will result in component instances with an HTML representation of: - ### Extension + ```html +
    + ``` - Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing - arguments from the helper to `Ember.TextArea`'s `create` method. You can - extend the capabilities of text areas in your application by reopening this - class. For example, if you are building a Bootstrap project where `data-*` - attributes are used, you can globally add support for a `data-*` attribute - on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or - `Ember.TextSupport` and adding it to the `attributeBindings` concatenated - property: + If you want to add a class name for a property which evaluates to true and + and a different class name if it evaluates to false, you can pass a binding + like this: - ```javascript - Ember.TextArea.reopen({ - attributeBindings: ['data-error'] + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['isEnabled:enabled:disabled'], + isEnabled: true }); ``` - Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` - itself extends `Ember.Component`. Expect isolated component semantics, not - legacy 1.x view semantics (like `controller` being present). + Will result in component instances with an HTML representation of: - See more about [Ember components](/api/classes/Ember.Component.html) + ```html +
    + ``` - @method textarea - @for Ember.Templates.helpers - @param {Hash} options - @public - */ - - /** - The internal class used to create textarea element when the `{{textarea}}` - helper is used. + When isEnabled is `false`, the resulting HTML representation looks like + this: - See [Ember.Templates.helpers.textarea](/api/classes/Ember.Templates.helpers.html#method_textarea) for usage details. + ```html +
    + ``` - ## Layout and LayoutName properties + This syntax offers the convenience to add a class if a property is `false`: - Because HTML `textarea` elements do not contain inner HTML the `layout` and - `layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. + ```app/components/my-widget.js + import Ember from 'ember'; - @class TextArea - @namespace Ember - @extends Ember.Component - @uses Ember.TextSupport - @public - */ - exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { - classNames: ['ember-text-area'], - - layout: _emberGlimmerTemplatesEmpty.default, - - tagName: 'textarea', - attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir', 'value'], - rows: null, - cols: null - }); -}); -enifed('ember-glimmer/components/text_field', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-glimmer/component', 'ember-glimmer/templates/empty', 'ember-views'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty, _emberViews) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; - - var inputTypeTestElement = undefined; - var inputTypes = new _emberUtils.EmptyObject(); - function canSetTypeOfInput(type) { - if (type in inputTypes) { - return inputTypes[type]; - } - - // if running in outside of a browser always return the - // original type - if (!_emberEnvironment.environment.hasDOM) { - inputTypes[type] = type; - - return type; - } - - if (!inputTypeTestElement) { - inputTypeTestElement = document.createElement('input'); - } - - try { - inputTypeTestElement.type = type; - } catch (e) {} - - return inputTypes[type] = inputTypeTestElement.type === type; - } - - /** + // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false + export default Ember.Component.extend({ + classNameBindings: ['isEnabled::disabled'], + isEnabled: true + }); + ``` - The internal class used to create text inputs when the `{{input}}` - helper is used with `type` of `text`. + Will result in component instances with an HTML representation of: - See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. + ```html +
    + ``` - ## Layout and LayoutName properties + When the `isEnabled` property on the component is set to `false`, it will result + in component instances with an HTML representation of: - Because HTML `input` elements are self closing `layout` and `layoutName` - properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. + ```html +
    + ``` - @class TextField + Updates to the value of a class name binding will result in automatic + update of the HTML `class` attribute in the component's rendered HTML + representation. If the value becomes `false` or `undefined` the class name + will be removed. + Both `classNames` and `classNameBindings` are concatenated properties. See + [Ember.Object](/api/classes/Ember.Object.html) documentation for more + information about concatenated properties. + + + ## HTML Attributes + + The HTML attribute section of a component's tag can be set by providing an + `attributeBindings` property set to an array of property names on the component. + The return value of these properties will be used as the value of the component's + HTML associated attribute: + + ```app/components/my-anchor.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'a', + attributeBindings: ['href'], + href: 'http://google.com' + }); + ``` + + Will result in component instances with an HTML representation of: + + ```html + + ``` + + One property can be mapped on to another by placing a ":" between + the source property and the destination property: + + ```app/components/my-anchor.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'a', + attributeBindings: ['url:href'], + url: 'http://google.com' + }); + ``` + + Will result in component instances with an HTML representation of: + + ```html + + ``` + + Namespaced attributes (e.g. `xlink:href`) are supported, but have to be + mapped, since `:` is not a valid character for properties in Javascript: + + ```app/components/my-use.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'use', + attributeBindings: ['xlinkHref:xlink:href'], + xlinkHref: '#triangle' + }); + ``` + + Will result in component instances with an HTML representation of: + + ```html + + ``` + + If the return value of an `attributeBindings` monitored property is a boolean + the attribute will be present or absent depending on the value: + + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: false + }); + ``` + + Will result in a component instance with an HTML representation of: + + ```html + + ``` + + `attributeBindings` can refer to computed properties: + + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: Ember.computed(function() { + if (someLogic) { + return true; + } else { + return false; + } + }) + }); + ``` + + To prevent setting an attribute altogether, use `null` or `undefined` as the + return value of the `attributeBindings` monitored property: + + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'form', + attributeBindings: ['novalidate'], + novalidate: null + }); + ``` + + Updates to the property of an attribute binding will result in automatic + update of the HTML attribute in the component's rendered HTML representation. + `attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html) + documentation for more information about concatenated properties. + + + ## Layouts + + See [Ember.Templates.helpers.yield](/api/classes/Ember.Templates.helpers.html#method_yield) + for more information. + + + ## Responding to Browser Events + + Components can respond to user-initiated events in one of three ways: method + implementation, through an event manager, and through `{{action}}` helper use + in their template or layout. + + + ### Method Implementation + + Components can respond to user-initiated events by implementing a method that + matches the event name. A `jQuery.Event` object will be passed as the + argument to this method. + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + click(event) { + // will be called when an instance's + // rendered element is clicked + } + }); + ``` + + + ### `{{action}}` Helper + + See [Ember.Templates.helpers.action](/api/classes/Ember.Templates.helpers.html#method_action). + + + ### Event Names + + All of the event handling approaches described above respond to the same set + of events. The names of the built-in events are listed below. (The hash of + built-in events exists in `Ember.EventDispatcher`.) Additional, custom events + can be registered by using `Ember.Application.customEvents`. + + Touch events: + + * `touchStart` + * `touchMove` + * `touchEnd` + * `touchCancel` + + Keyboard events: + + * `keyDown` + * `keyUp` + * `keyPress` + + Mouse events: + + * `mouseDown` + * `mouseUp` + * `contextMenu` + * `click` + * `doubleClick` + * `mouseMove` + * `focusIn` + * `focusOut` + * `mouseEnter` + * `mouseLeave` + + Form events: + + * `submit` + * `change` + * `focusIn` + * `focusOut` + * `input` + + HTML5 drag and drop events: + + * `dragStart` + * `drag` + * `dragEnter` + * `dragLeave` + * `dragOver` + * `dragEnd` + * `drop` + + @class Component @namespace Ember - @extends Ember.Component - @uses Ember.TextSupport + @extends Ember.CoreView + @uses Ember.TargetActionSupport + @uses Ember.ClassNamesSupport + @uses Ember.ActionSupport + @uses Ember.ViewMixin + @uses Ember.ViewStateSupport @public */ - exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { - layout: _emberGlimmerTemplatesEmpty.default, - classNames: ['ember-text-field'], - tagName: 'input', - attributeBindings: ['accept', 'autocomplete', 'autosave', 'dir', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'inputmode', 'lang', 'list', 'max', 'min', 'multiple', 'name', 'pattern', 'size', 'step', 'type', 'value', 'width'], - - /** - The `value` attribute of the input element. As the user inputs text, this - property is updated live. - @property value - @type String - @default "" - @public - */ - value: '', + var Component = _emberViews.CoreView.extend(_emberViews.ChildViewsSupport, _emberViews.ViewStateSupport, _emberViews.ClassNamesSupport, _emberRuntime.TargetActionSupport, _emberViews.ActionSupport, _emberViews.ViewMixin, (_CoreView$extend = { + isComponent: true, - /** - The `type` attribute of the input element. - @property type - @type String - @default "text" - @public - */ - type: _emberMetal.computed({ - get: function () { - return 'text'; - }, + init: function () { + var _this = this; - set: function (key, value) { - var type = 'text'; + this._super.apply(this, arguments); + this[IS_DISPATCHING_ATTRS] = false; + this[DIRTY_TAG] = new _glimmerReference.DirtyableTag(); + this[ROOT_REF] = new _emberGlimmerUtilsReferences.RootReference(this); + this[BOUNDS] = null; - if (canSetTypeOfInput(value)) { - type = value; - } + // If a `defaultLayout` was specified move it to the `layout` prop. + // `layout` is no longer a CP, so this just ensures that the `defaultLayout` + // logic is supported with a deprecation + if (this.defaultLayout && !this.layout) { + _emberMetal.deprecate('Specifying `defaultLayout` to ' + this + ' is deprecated. Please use `layout` instead.', false, { + id: 'ember-views.component.defaultLayout', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-component-defaultlayout' + }); - return type; + this.layout = this.defaultLayout; } - }), - - /** - The `size` of the text field in characters. - @property size - @type String - @default null - @public - */ - size: null, - - /** - The `pattern` attribute of input element. - @property pattern - @type String - @default null - @public - */ - pattern: null, - - /** - The `min` attribute of input element used with `type="number"` or `type="range"`. - @property min - @type String - @default null - @since 1.4.0 - @public - */ - min: null, - - /** - The `max` attribute of input element used with `type="number"` or `type="range"`. - @property max - @type String - @default null - @since 1.4.0 - @public - */ - max: null - }); -}); -enifed('ember-glimmer/dom', ['exports', 'glimmer-runtime', 'glimmer-node'], function (exports, _glimmerRuntime, _glimmerNode) { - 'use strict'; - - exports.DOMChanges = _glimmerRuntime.DOMChanges; - exports.DOMTreeConstruction = _glimmerRuntime.DOMTreeConstruction; - exports.NodeDOMTreeConstruction = _glimmerNode.NodeDOMTreeConstruction; -}); -enifed('ember-glimmer/environment', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'glimmer-runtime', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/if-unless', 'ember-glimmer/utils/bindings', 'ember-glimmer/helpers/action', 'ember-glimmer/helpers/component', 'ember-glimmer/helpers/concat', 'ember-glimmer/helpers/debugger', 'ember-glimmer/helpers/get', 'ember-glimmer/helpers/hash', 'ember-glimmer/helpers/loc', 'ember-glimmer/helpers/log', 'ember-glimmer/helpers/mut', 'ember-glimmer/helpers/readonly', 'ember-glimmer/helpers/unbound', 'ember-glimmer/helpers/-class', 'ember-glimmer/helpers/-input-type', 'ember-glimmer/helpers/query-param', 'ember-glimmer/helpers/each-in', 'ember-glimmer/helpers/-normalize-class', 'ember-glimmer/helpers/-html-safe', 'ember-glimmer/protocol-for-url', 'ember-glimmer/modifiers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _glimmerRuntime, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntax, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerHelpersIfUnless, _emberGlimmerUtilsBindings, _emberGlimmerHelpersAction, _emberGlimmerHelpersComponent, _emberGlimmerHelpersConcat, _emberGlimmerHelpersDebugger, _emberGlimmerHelpersGet, _emberGlimmerHelpersHash, _emberGlimmerHelpersLoc, _emberGlimmerHelpersLog, _emberGlimmerHelpersMut, _emberGlimmerHelpersReadonly, _emberGlimmerHelpersUnbound, _emberGlimmerHelpersClass, _emberGlimmerHelpersInputType, _emberGlimmerHelpersQueryParam, _emberGlimmerHelpersEachIn, _emberGlimmerHelpersNormalizeClass, _emberGlimmerHelpersHtmlSafe, _emberGlimmerProtocolForUrl, _emberGlimmerModifiersAction) { - 'use strict'; - - var builtInComponents = { - textarea: '-text-area' - }; - - var Environment = (function (_GlimmerEnvironment) { - babelHelpers.inherits(Environment, _GlimmerEnvironment); - - Environment.create = function create(options) { - return new Environment(options); - }; - - function Environment(_ref) { - var _this = this; - var owner = _ref[_emberUtils.OWNER]; - babelHelpers.classCallCheck(this, Environment); - - _GlimmerEnvironment.apply(this, arguments); - this.owner = owner; - this.isInteractive = owner.lookup('-environment:main').isInteractive; + // If in a tagless component, assert that no event handlers are defined + _emberMetal.assert('You can not define a function that handles DOM events in the `' + this + '` tagless component since it doesn\'t have any DOM element.', this.tagName !== '' || !this.renderer._destinedForDOM || !(function () { + var eventDispatcher = _emberUtils.getOwner(_this).lookup('event_dispatcher:main'); + var events = eventDispatcher && eventDispatcher._finalEvents || {}; - // can be removed once https://github.com/tildeio/glimmer/pull/305 lands - this.destroyedComponents = undefined; + for (var key in events) { + var methodName = events[key]; - _emberGlimmerProtocolForUrl.default(this); + if (typeof _this[methodName] === 'function') { + return true; // indicate that the assertion should be triggered + } + } + })()); - this._definitionCache = new _emberMetal.Cache(2000, function (_ref2) { - var name = _ref2.name; - var source = _ref2.source; - var owner = _ref2.owner; + _emberMetal.assert('You cannot use a computed property for the component\'s `tagName` (' + this + ').', !(this.tagName && this.tagName.isDescriptor)); + }, - var _lookupComponent = _emberViews.lookupComponent(owner, name, { source: source }); + rerender: function () { + this[DIRTY_TAG].dirty(); + this._super(); + }, - var ComponentClass = _lookupComponent.component; - var layout = _lookupComponent.layout; + __defineNonEnumerable: function (property) { + this[property.name] = property.descriptor.value; + } - if (ComponentClass || layout) { - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(name, ComponentClass, layout); - } - }, function (_ref3) { - var name = _ref3.name; - var source = _ref3.source; - var owner = _ref3.owner; + }, _CoreView$extend[_emberMetal.PROPERTY_DID_CHANGE] = function (key) { + if (this[IS_DISPATCHING_ATTRS]) { + return; + } - var expandedName = source && owner._resolveLocalLookupName(name, source) || name; - var ownerGuid = _emberUtils.guidFor(owner); + var args = undefined, + reference = undefined; - return ownerGuid + '|' + expandedName; - }); + if ((args = this[ARGS]) && (reference = args[key])) { + if (reference[_emberGlimmerUtilsReferences.UPDATE]) { + reference[_emberGlimmerUtilsReferences.UPDATE](_emberMetal.get(this, key)); + } + } + }, _CoreView$extend.getAttr = function (key) { + // TODO Intimate API should be deprecated + return this.get(key); + }, _CoreView$extend.readDOMAttr = function (name) { + var element = _emberViews.getViewElement(this); + return _glimmerRuntime.readDOMAttr(element, name); + }, _CoreView$extend)); - this._templateCache = new _emberMetal.Cache(1000, function (_ref4) { - var Template = _ref4.Template; - var owner = _ref4.owner; + /** + The WAI-ARIA role of the control represented by this view. For example, a + button may have a role of type 'button', or a pane may have a role of + type 'alertdialog'. This property is used by assistive software to help + visually challenged users navigate rich web applications. + The full list of valid WAI-ARIA roles is available at: + [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization) + @property ariaRole + @type String + @default null + @public + */ - if (Template.create) { - var _Template$create; - - // we received a factory - return Template.create((_Template$create = { env: _this }, _Template$create[_emberUtils.OWNER] = owner, _Template$create)); - } else { - // we were provided an instance already - return Template; - } - }, function (_ref5) { - var Template = _ref5.Template; - var owner = _ref5.owner; - return _emberUtils.guidFor(owner) + '|' + Template.id; - }); - - this._compilerCache = new _emberMetal.Cache(10, function (Compiler) { - return new _emberMetal.Cache(2000, function (template) { - var compilable = new Compiler(template); - return _glimmerRuntime.compileLayout(compilable, _this); - }, function (template) { - var owner = template.meta.owner; - return _emberUtils.guidFor(owner) + '|' + template.id; - }); - }, function (Compiler) { - return Compiler.id; - }); - - this.builtInModifiers = { - action: new _emberGlimmerModifiersAction.default() - }; - - this.builtInHelpers = { - if: _emberGlimmerHelpersIfUnless.inlineIf, - action: _emberGlimmerHelpersAction.default, - component: _emberGlimmerHelpersComponent.default, - concat: _emberGlimmerHelpersConcat.default, - debugger: _emberGlimmerHelpersDebugger.default, - get: _emberGlimmerHelpersGet.default, - hash: _emberGlimmerHelpersHash.default, - loc: _emberGlimmerHelpersLoc.default, - log: _emberGlimmerHelpersLog.default, - mut: _emberGlimmerHelpersMut.default, - 'query-params': _emberGlimmerHelpersQueryParam.default, - readonly: _emberGlimmerHelpersReadonly.default, - unbound: _emberGlimmerHelpersUnbound.default, - unless: _emberGlimmerHelpersIfUnless.inlineUnless, - '-class': _emberGlimmerHelpersClass.default, - '-each-in': _emberGlimmerHelpersEachIn.default, - '-input-type': _emberGlimmerHelpersInputType.default, - '-normalize-class': _emberGlimmerHelpersNormalizeClass.default, - '-html-safe': _emberGlimmerHelpersHtmlSafe.default, - '-get-dynamic-var': _glimmerRuntime.getDynamicVar - }; - } - - // Hello future traveler, welcome to the world of syntax refinement. - // The method below is called by Glimmer's runtime compiler to allow - // us to take generic statement syntax and refine it to more meaniful - // syntax for Ember's use case. This on the fly switch-a-roo sounds fine - // and dandy, however Ember has precedence on statement refinement that you - // need to be aware of. The presendence for language constructs is as follows: - // - // ------------------------ - // Native & Built-in Syntax - // ------------------------ - // User-land components - // ------------------------ - // User-land helpers - // ------------------------ - // - // The one caveat here is that Ember also allows for dashed references that are - // not a component or helper: - // - // export default Component.extend({ - // 'foo-bar': 'LAME' - // }); - // - // {{foo-bar}} - // - // The heuristic for the above situation is a dashed "key" in inline form - // that does not resolve to a defintion. In this case refine statement simply - // isn't going to return any syntax and the Glimmer engine knows how to handle - // this case. - - Environment.prototype.refineStatement = function refineStatement(statement, symbolTable) { - var _this2 = this; - - // 1. resolve any native syntax – if, unless, with, each, and partial - var nativeSyntax = _GlimmerEnvironment.prototype.refineStatement.call(this, statement, symbolTable); - - if (nativeSyntax) { - return nativeSyntax; - } - - var appendType = statement.appendType; - var isSimple = statement.isSimple; - var isInline = statement.isInline; - var isBlock = statement.isBlock; - var isModifier = statement.isModifier; - var key = statement.key; - var path = statement.path; - var args = statement.args; - - _emberMetal.assert('You attempted to overwrite the built-in helper "' + key + '" which is not allowed. Please rename the helper.', !(this.builtInHelpers[key] && this.owner.hasRegistration('helper:' + key))); - - if (isSimple && (isInline || isBlock) && appendType !== 'get') { - // 2. built-in syntax - - var RefinedSyntax = _emberGlimmerSyntax.findSyntaxBuilder(key); - if (RefinedSyntax) { - return RefinedSyntax.create(this, args, symbolTable); - } - - var internalKey = builtInComponents[key]; - var definition = null; - - if (internalKey) { - definition = this.getComponentDefinition([internalKey], symbolTable); - } else if (key.indexOf('-') >= 0) { - definition = this.getComponentDefinition(path, symbolTable); - } - - if (definition) { - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } - - _emberMetal.assert('A component or helper named "' + key + '" could not be found', !isBlock || this.hasHelper(path, symbolTable)); - } - - if (isInline && !isSimple && appendType !== 'helper') { - return statement.original.deopt(); - } - - if (!isSimple && path) { - return _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax.fromPath(this, path, args, symbolTable); - } - - _emberMetal.assert('Helpers may not be used in the block form, for example {{#' + key + '}}{{/' + key + '}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (' + key + ')}}{{/if}}.', !isBlock || !this.hasHelper(path, symbolTable)); - - _emberMetal.assert('Helpers may not be used in the element form.', (function () { - if (nativeSyntax) { - return true; - } - if (!key) { - return true; - } - - if (isModifier && !_this2.hasModifier(path, symbolTable) && _this2.hasHelper(path, symbolTable)) { - return false; - } - - return true; - })()); - }; - - Environment.prototype.hasComponentDefinition = function hasComponentDefinition() { - return false; - }; - - Environment.prototype.getComponentDefinition = function getComponentDefinition(path, symbolTable) { - var name = path[0]; - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var source = blockMeta.moduleName && 'template:' + blockMeta.moduleName; - - return this._definitionCache.get({ name: name, source: source, owner: owner }); - }; - - // normally templates should be exported at the proper module name - // and cached in the container, but this cache supports templates - // that have been set directly on the component's layout property - - Environment.prototype.getTemplate = function getTemplate(Template, owner) { - return this._templateCache.get({ Template: Template, owner: owner }); - }; - - // a Compiler can wrap the template so it needs its own cache - - Environment.prototype.getCompiledBlock = function getCompiledBlock(Compiler, template) { - var compilerCache = this._compilerCache.get(Compiler); - return compilerCache.get(template); - }; - - Environment.prototype.hasPartial = function hasPartial(name, symbolTable) { - var _symbolTable$getMeta = symbolTable.getMeta(); - - var owner = _symbolTable$getMeta.owner; - - return _emberViews.hasPartial(name, owner); - }; - - Environment.prototype.lookupPartial = function lookupPartial(name, symbolTable) { - var _symbolTable$getMeta2 = symbolTable.getMeta(); - - var owner = _symbolTable$getMeta2.owner; - - var partial = { - template: _emberViews.lookupPartial(name, owner) - }; - - if (partial.template) { - return partial; - } else { - throw new Error(name + ' is not a partial'); - } - }; - - Environment.prototype.hasHelper = function hasHelper(nameParts, symbolTable) { - _emberMetal.assert('The first argument passed into `hasHelper` should be an array', Array.isArray(nameParts)); - - // helpers are not allowed to include a dot in their invocation - if (nameParts.length > 1) { - return false; - } - - var name = nameParts[0]; - - if (this.builtInHelpers[name]) { - return true; - } - - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var options = { source: 'template:' + blockMeta.moduleName }; - - return owner.hasRegistration('helper:' + name, options) || owner.hasRegistration('helper:' + name); - }; - - Environment.prototype.lookupHelper = function lookupHelper(nameParts, symbolTable) { - _emberMetal.assert('The first argument passed into `lookupHelper` should be an array', Array.isArray(nameParts)); - - var name = nameParts[0]; - var helper = this.builtInHelpers[name]; - - if (helper) { - return helper; - } - - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var options = blockMeta.moduleName && { source: 'template:' + blockMeta.moduleName } || {}; - - helper = owner.lookup('helper:' + name, options) || owner.lookup('helper:' + name); - - // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations - if (helper.isHelperInstance) { - return function (vm, args) { - return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helper.compute, args); - }; - } else if (helper.isHelperFactory) { - return function (vm, args) { - return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helper, vm, args); - }; - } else { - throw new Error(nameParts + ' is not a helper'); - } - }; - - Environment.prototype.hasModifier = function hasModifier(nameParts) { - _emberMetal.assert('The first argument passed into `hasModifier` should be an array', Array.isArray(nameParts)); - - // modifiers are not allowed to include a dot in their invocation - if (nameParts.length > 1) { - return false; - } - - return !!this.builtInModifiers[nameParts[0]]; - }; - - Environment.prototype.lookupModifier = function lookupModifier(nameParts) { - _emberMetal.assert('The first argument passed into `lookupModifier` should be an array', Array.isArray(nameParts)); - - var modifier = this.builtInModifiers[nameParts[0]]; - - if (modifier) { - return modifier; - } else { - throw new Error(nameParts + ' is not a modifier'); - } - }; - - Environment.prototype.toConditionalReference = function toConditionalReference(reference) { - return _emberGlimmerUtilsReferences.ConditionalReference.create(reference); - }; - - Environment.prototype.iterableFor = function iterableFor(ref, args) { - var keyPath = args.named.get('key').value(); - return _emberGlimmerUtilsIterable.default(ref, keyPath); - }; + /** + Enables components to take a list of parameters as arguments. + For example, a component that takes two parameters with the names + `name` and `age`: + ```javascript + let MyComponent = Ember.Component.extend; + MyComponent.reopenClass({ + positionalParams: ['name', 'age'] + }); + ``` + It can then be invoked like this: + ```hbs + {{my-component "John" 38}} + ``` + The parameters can be referred to just like named parameters: + ```hbs + Name: {{name}}, Age: {{age}}. + ``` + Using a string instead of an array allows for an arbitrary number of + parameters: + ```javascript + let MyComponent = Ember.Component.extend; + MyComponent.reopenClass({ + positionalParams: 'names' + }); + ``` + It can then be invoked like this: + ```hbs + {{my-component "John" "Michael" "Scott"}} + ``` + The parameters can then be referred to by enumerating over the list: + ```hbs + {{#each names as |name|}}{{name}}{{/each}} + ``` + @static + @public + @property positionalParams + @since 1.13.0 + */ - Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier() { - if (this.isInteractive) { - var _GlimmerEnvironment$prototype$scheduleInstallModifier; + /** + Called when the attributes passed into the component have been updated. + Called both during the initial render of a container and during a rerender. + Can be used in place of an observer; code placed here will be executed + every time any attribute updates. + @method didReceiveAttrs + @public + @since 1.13.0 + */ - (_GlimmerEnvironment$prototype$scheduleInstallModifier = _GlimmerEnvironment.prototype.scheduleInstallModifier).call.apply(_GlimmerEnvironment$prototype$scheduleInstallModifier, [this].concat(babelHelpers.slice.call(arguments))); - } - }; + /** + Called when the attributes passed into the component have been updated. + Called both during the initial render of a container and during a rerender. + Can be used in place of an observer; code placed here will be executed + every time any attribute updates. + @event didReceiveAttrs + @public + @since 1.13.0 + */ - Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier() { - if (this.isInteractive) { - var _GlimmerEnvironment$prototype$scheduleUpdateModifier; + /** + Called after a component has been rendered, both on initial render and + in subsequent rerenders. + @method didRender + @public + @since 1.13.0 + */ - (_GlimmerEnvironment$prototype$scheduleUpdateModifier = _GlimmerEnvironment.prototype.scheduleUpdateModifier).call.apply(_GlimmerEnvironment$prototype$scheduleUpdateModifier, [this].concat(babelHelpers.slice.call(arguments))); - } - }; + /** + Called after a component has been rendered, both on initial render and + in subsequent rerenders. + @event didRender + @public + @since 1.13.0 + */ - Environment.prototype.didDestroy = function didDestroy(destroyable) { - destroyable.destroy(); - }; + /** + Called before a component has been rendered, both on initial render and + in subsequent rerenders. + @method willRender + @public + @since 1.13.0 + */ - Environment.prototype.begin = function begin() { - this.inTransaction = true; + /** + Called before a component has been rendered, both on initial render and + in subsequent rerenders. + @event willRender + @public + @since 1.13.0 + */ - _GlimmerEnvironment.prototype.begin.call(this); + /** + Called when the attributes passed into the component have been changed. + Called only during a rerender, not during an initial render. + @method didUpdateAttrs + @public + @since 1.13.0 + */ - this.destroyedComponents = []; - }; + /** + Called when the attributes passed into the component have been changed. + Called only during a rerender, not during an initial render. + @event didUpdateAttrs + @public + @since 1.13.0 + */ - Environment.prototype.commit = function commit() { - // components queued for destruction must be destroyed before firing - // `didCreate` to prevent errors when removing and adding a component - // with the same name (would throw an error when added to view registry) - for (var i = 0; i < this.destroyedComponents.length; i++) { - this.destroyedComponents[i].destroy(); - } + /** + Called when the component is about to update and rerender itself. + Called only during a rerender, not during an initial render. + @method willUpdate + @public + @since 1.13.0 + */ - _GlimmerEnvironment.prototype.commit.call(this); + /** + Called when the component is about to update and rerender itself. + Called only during a rerender, not during an initial render. + @event willUpdate + @public + @since 1.13.0 + */ - this.inTransaction = false; - }; + /** + Called when the component has updated and rerendered itself. + Called only during a rerender, not during an initial render. + @method didUpdate + @public + @since 1.13.0 + */ - return Environment; - })(_glimmerRuntime.Environment); + /** + Called when the component has updated and rerendered itself. + Called only during a rerender, not during an initial render. + @event didUpdate + @public + @since 1.13.0 + */ - exports.default = Environment; + /** + A component may contain a layout. A layout is a regular template but + supersedes the `template` property during rendering. It is the + responsibility of the layout template to retrieve the `template` + property from the component (or alternatively, call `Handlebars.helpers.yield`, + `{{yield}}`) to render it in the correct location. + This is useful for a component that has a shared wrapper, but which delegates + the rendering of the contents of the wrapper to the `template` property + on a subclass. + @property layout + @type Function + @public + */ - _emberMetal.runInDebug(function () { - var StyleAttributeManager = (function (_AttributeManager) { - babelHelpers.inherits(StyleAttributeManager, _AttributeManager); + /** + The name of the layout to lookup if no layout is provided. + By default `Ember.Component` will lookup a template with this name in + `Ember.TEMPLATES` (a shared global object). + @property layoutName + @type String + @default null + @private + */ - function StyleAttributeManager() { - babelHelpers.classCallCheck(this, StyleAttributeManager); + /** + Returns a jQuery object for this component's element. If you pass in a selector + string, this method will return a jQuery object, using the current element + as its buffer. + For example, calling `component.$('li')` will return a jQuery object containing + all of the `li` elements inside the DOM element of this component. + @method $ + @param {String} [selector] a jQuery-compatible selector string + @return {jQuery} the jQuery object for the DOM node + @public + */ - _AttributeManager.apply(this, arguments); + /** + The HTML `id` of the component's element in the DOM. You can provide this + value yourself but it must be unique (just as in HTML): + ```handlebars + {{my-component elementId="a-really-cool-id"}} + ``` + If not manually set a default value will be provided by the framework. + Once rendered an element's `elementId` is considered immutable and you + should never change it. If you need to compute a dynamic value for the + `elementId`, you should do this when the component or element is being + instantiated: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + var index = this.get('index'); + this.set('elementId', `component-id${index}`); } + }); + ``` + @property elementId + @type String + @public + */ - StyleAttributeManager.prototype.setAttribute = function setAttribute(dom, element, value) { - var _AttributeManager$prototype$setAttribute; - - _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { - if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { - return true; - } - return false; - })(), { id: 'ember-htmlbars.style-xss-warning' }); - (_AttributeManager$prototype$setAttribute = _AttributeManager.prototype.setAttribute).call.apply(_AttributeManager$prototype$setAttribute, [this].concat(babelHelpers.slice.call(arguments))); - }; - - StyleAttributeManager.prototype.updateAttribute = function updateAttribute(dom, element, value) { - var _AttributeManager$prototype$updateAttribute; - - _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { - if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { - return true; - } - return false; - })(), { id: 'ember-htmlbars.style-xss-warning' }); - (_AttributeManager$prototype$updateAttribute = _AttributeManager.prototype.updateAttribute).call.apply(_AttributeManager$prototype$updateAttribute, [this].concat(babelHelpers.slice.call(arguments))); - }; + /** + If `false`, the view will appear hidden in DOM. + @property isVisible + @type Boolean + @default null + @public + */ + Component[_emberUtils.NAME_KEY] = 'Ember.Component'; - return StyleAttributeManager; - })(_glimmerRuntime.AttributeManager); + Component.reopenClass({ + isComponentFactory: true, + positionalParams: [] + }); - var STYLE_ATTRIBUTE_MANANGER = new StyleAttributeManager('style'); + exports.default = Component; +}); - Environment.prototype.attributeFor = function (element, attribute, isTrusting, namespace) { - if (attribute === 'style' && !isTrusting) { - return STYLE_ATTRIBUTE_MANANGER; - } +/** + Normally, Ember's component model is "write-only". The component takes a + bunch of attributes that it got passed in, and uses them to render its + template. + One nice thing about this model is that if you try to set a value to the + same thing as last time, Ember (through HTMLBars) will avoid doing any + work on the DOM. + This is not just a performance optimization. If an attribute has not + changed, it is important not to clobber the element's "hidden state". + For example, if you set an input's `value` to the same value as before, + it will clobber selection state and cursor position. In other words, + setting an attribute is not **always** idempotent. + This method provides a way to read an element's attribute and also + update the last value Ember knows about at the same time. This makes + setting an attribute idempotent. + In particular, what this means is that if you get an `` element's + `value` attribute and then re-render the template with the same value, + it will avoid clobbering the cursor and selection position. + Since most attribute sets are idempotent in the browser, you typically + can get away with reading attributes using jQuery, but the most reliable + way to do so is through this method. + @method readDOMAttr + @param {String} name the name of the attribute + @return String + @public + */ +enifed('ember-glimmer/components/checkbox', ['exports', 'ember-metal', 'ember-glimmer/component', 'ember-glimmer/templates/empty'], function (exports, _emberMetal, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty) { + 'use strict'; - return _glimmerRuntime.Environment.prototype.attributeFor.call(this, element, attribute, isTrusting); - }; - }); -}); -enifed('ember-glimmer/helper', ['exports', 'ember-utils', 'ember-runtime', 'glimmer-reference'], function (exports, _emberUtils, _emberRuntime, _glimmerReference) { /** @module ember - @submodule ember-glimmer + @submodule ember-views */ - 'use strict'; - - exports.helper = helper; - var RECOMPUTE_TAG = _emberUtils.symbol('RECOMPUTE_TAG'); - - exports.RECOMPUTE_TAG = RECOMPUTE_TAG; /** - Ember Helpers are functions that can compute values, and are used in templates. - For example, this code calls a helper named `format-currency`: + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `checkbox`. - ```handlebars -
    {{format-currency cents currency="$"}}
    - ``` + See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. - Additionally a helper can be called as a nested helper (sometimes called a - subexpression). In this example, the computed value of a helper is passed - to a component named `show-money`: + ## Direct manipulation of `checked` - ```handlebars - {{show-money amount=(format-currency cents currency="$")}} - ``` + The `checked` attribute of an `Ember.Checkbox` object should always be set + through the Ember object or by interacting with its rendered element + representation via the mouse, keyboard, or touch. Updating the value of the + checkbox via jQuery will result in the checked value of the object and its + element losing synchronization. - Helpers defined using a class must provide a `compute` function. For example: + ## Layout and LayoutName properties - ```js - export default Ember.Helper.extend({ - compute(params, hash) { - let cents = params[0]; - let currency = hash.currency; - return `${currency}${cents * 0.01}`; - } - }); - ``` - - Each time the input to a helper changes, the `compute` function will be - called again. - - As instances, these helpers also have access to the container an will accept - injected dependencies. - - Additionally, class helpers can call `recompute` to force a new computation. - - @class Ember.Helper - @public - @since 1.13.0 - */ - var Helper = _emberRuntime.FrameworkObject.extend({ - isHelperInstance: true, - - init: function () { - this._super.apply(this, arguments); - this[RECOMPUTE_TAG] = new _glimmerReference.DirtyableTag(); - }, - - /** - On a class-based helper, it may be useful to force a recomputation of that - helpers value. This is akin to `rerender` on a component. - For example, this component will rerender when the `currentUser` on a - session service changes: - ```js - // app/helpers/current-user-email.js - export default Ember.Helper.extend({ - session: Ember.inject.service(), - onNewUser: Ember.observer('session.currentUser', function() { - this.recompute(); - }), - compute() { - return this.get('session.currentUser.email'); - } - }); - ``` - @method recompute - @public - @since 1.13.0 - */ - recompute: function () { - this[RECOMPUTE_TAG].dirty(); - } - - /** - Override this function when writing a class-based helper. - @method compute - @param {Array} params The positional arguments to the helper - @param {Object} hash The named arguments to the helper - @public - @since 1.13.0 - */ - }); - - Helper.reopenClass({ - isHelperFactory: true - }); - - /** - In many cases, the ceremony of a full `Ember.Helper` class is not required. - The `helper` method create pure-function helpers without instances. For - example: - - ```js - // app/helpers/format-currency.js - export default Ember.Helper.helper(function(params, hash) { - let cents = params[0]; - let currency = hash.currency; - return `${currency}${cents * 0.01}`; - }); - ``` + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. - @static - @param {Function} helper The helper function - @method helper + @class Checkbox + @namespace Ember + @extends Ember.Component @public - @since 1.13.0 */ + exports.default = _emberGlimmerComponent.default.extend({ + layout: _emberGlimmerTemplatesEmpty.default, + classNames: ['ember-checkbox'], - function helper(helperFn) { - return { - isHelperInstance: true, - compute: helperFn - }; - } - - exports.default = Helper; -}); -enifed('ember-glimmer/helpers/-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - 'use strict'; - - function classHelper(_ref) { - var positional = _ref.positional; - - var path = positional.at(0); - var args = positional.length; - var value = path.value(); - - if (value === true) { - if (args > 1) { - return _emberRuntime.String.dasherize(positional.at(1).value()); - } - return null; - } - - if (value === false) { - if (args > 2) { - return _emberRuntime.String.dasherize(positional.at(2).value()); - } - return null; - } - - return value; - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(classHelper, args); - }; -}); -enifed('ember-glimmer/helpers/-html-safe', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/utils/string'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerUtilsString) { - 'use strict'; - - function htmlSafe(_ref) { - var positional = _ref.positional; - - var path = positional.at(0); - return new _emberGlimmerUtilsString.SafeString(path.value()); - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(htmlSafe, args); - }; -}); -enifed('ember-glimmer/helpers/-input-type', ['exports', 'ember-glimmer/utils/references'], function (exports, _emberGlimmerUtilsReferences) { - 'use strict'; - - function inputTypeHelper(_ref) { - var positional = _ref.positional; - var named = _ref.named; - - var type = positional.at(0).value(); - if (type === 'checkbox') { - return '-checkbox'; - } - return '-text-field'; - } + tagName: 'input', - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(inputTypeHelper, args); - }; -}); -enifed('ember-glimmer/helpers/-normalize-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - 'use strict'; + attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name', 'autofocus', 'required', 'form'], - function normalizeClass(_ref) { - var positional = _ref.positional; - var named = _ref.named; + type: 'checkbox', + checked: false, + disabled: false, + indeterminate: false, - var classNameParts = positional.at(0).value().split('.'); - var className = classNameParts[classNameParts.length - 1]; - var value = positional.at(1).value(); + didInsertElement: function () { + this._super.apply(this, arguments); + _emberMetal.get(this, 'element').indeterminate = !!_emberMetal.get(this, 'indeterminate'); + }, - if (value === true) { - return _emberRuntime.String.dasherize(className); - } else if (!value && value !== 0) { - return ''; - } else { - return String(value); + change: function () { + _emberMetal.set(this, 'checked', this.$().prop('checked')); } - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(normalizeClass, args); - }; + }); }); -enifed('ember-glimmer/helpers/action', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal) { +enifed('ember-glimmer/components/link-to', ['exports', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-glimmer/templates/link-to', 'ember-glimmer/component'], function (exports, _emberConsole, _emberMetal, _emberRuntime, _emberViews, _emberGlimmerTemplatesLinkTo, _emberGlimmerComponent) { /** @module ember @submodule ember-glimmer */ - 'use strict'; - - exports.createClosureAction = createClosureAction; - var INVOKE = _emberUtils.symbol('INVOKE'); - exports.INVOKE = INVOKE; - var ACTION = _emberUtils.symbol('ACTION'); - exports.ACTION = ACTION; /** - The `{{action}}` helper provides a way to pass triggers for behavior (usually - just a function) between components, and into components from controllers. - - ### Passing functions with the action helper - - There are three contexts an action helper can be used in. The first two - contexts to discuss are attribute context, and Handlebars value context. + The `{{link-to}}` component renders a link to the supplied + `routeName` passing an optionally supplied model to the + route as its `model` context of the route. The block + for `{{link-to}}` becomes the innerHTML of the rendered + element: ```handlebars - {{! An example of attribute context }} -
    - {{! Examples of Handlebars value context }} - {{input on-input=(action "save")}} - {{yield (action "refreshData") andAnotherParam}} + {{#link-to 'photoGallery'}} + Great Hamster Photos + {{/link-to}} ``` - In these contexts, - the helper is called a "closure action" helper. Its behavior is simple: - If passed a function name, read that function off the `actions` property - of the current context. Once that function is read (or if a function was - passed), create a closure over that function and any arguments. - The resulting value of an action helper used this way is simply a function. - - For example, in the attribute context: + You can also use an inline form of `{{link-to}}` component by + passing the link text as the first argument + to the component: ```handlebars - {{! An example of attribute context }} -
    + {{link-to 'Great Hamster Photos' 'photoGallery'}} ``` - The resulting template render logic would be: + Both will result in: - ```js - var div = document.createElement('div'); - var actionFunction = (function(context){ - return function() { - return context.actions.save.apply(context, arguments); - }; - })(context); - div.onclick = actionFunction; + ```html + + Great Hamster Photos + ``` - Thus when the div is clicked, the action on that context is called. - Because the `actionFunction` is just a function, closure actions can be - passed between components and still execute in the correct context. - - Here is an example action handler on a component: + ### Supplying a tagName + By default `{{link-to}}` renders an `` element. This can + be overridden for a single use of `{{link-to}}` by supplying + a `tagName` option: - ```js - export default Ember.Component.extend({ - actions: { - save() { - this.get('model').save(); - } - } - }); + ```handlebars + {{#link-to 'photoGallery' tagName="li"}} + Great Hamster Photos + {{/link-to}} ``` - Actions are always looked up on the `actions` property of the current context. - This avoids collisions in the naming of common actions, such as `destroy`. - Two options can be passed to the `action` helper when it is used in this way. - - * `target=someProperty` will look to `someProperty` instead of the current - context for the `actions` hash. This can be useful when targetting a - service for actions. - * `value="target.value"` will read the path `target.value` off the first - argument to the action when it is called and rewrite the first argument - to be that value. This is useful when attaching actions to event listeners. - - ### Invoking an action - - Closure actions curry both their scope and any arguments. When invoked, any - additional arguments are added to the already curried list. - Actions should be invoked using the [sendAction](/api/classes/Ember.Component.html#method_sendAction) - method. The first argument to `sendAction` is the action to be called, and - additional arguments are passed to the action function. This has interesting - properties combined with currying of arguments. For example: - - ```js - export default Ember.Component.extend({ - actions: { - // Usage {{input on-input=(action (action 'setName' model) value="target.value")}} - setName(model, name) { - model.set('name', name); - } - } - }); + ```html +
  • + Great Hamster Photos +
  • ``` - The first argument (`model`) was curried over, and the run-time argument (`event`) - becomes a second argument. Action calls can be nested this way because each simply - returns a function. Any function can be passed to the `{{action}}` helper, including - other actions. + To override this option for your entire application, see + "Overriding Application-wide Defaults". - Actions invoked with `sendAction` have the same currying behavior as demonstrated - with `on-input` above. For example: + ### Disabling the `link-to` component + By default `{{link-to}}` is enabled. + any passed value to the `disabled` component property will disable + the `link-to` component. - ```js - export default Ember.Component.extend({ - actions: { - setName(model, name) { - model.set('name', name); - } - } - }); - ``` + static use: the `disabled` option: ```handlebars - {{my-input submit=(action 'setName' model)}} - ``` - - ```js - // app/components/my-component.js - export default Ember.Component.extend({ - click() { - // Note that model is not passed, it was curried in the template - this.sendAction('submit', 'bob'); - } - }); + {{#link-to 'photoGallery' disabled=true}} + Great Hamster Photos + {{/link-to}} ``` - ### Attaching actions to DOM elements - - The third context of the `{{action}}` helper can be called "element space". - For example: + dynamic use: the `disabledWhen` option: ```handlebars - {{! An example of element space }} -
    + {{#link-to 'photoGallery' disabledWhen=controller.someProperty}} + Great Hamster Photos + {{/link-to}} ``` - Used this way, the `{{action}}` helper provides a useful shortcut for - registering an HTML element in a template for a single DOM event and - forwarding that interaction to the template's context (controller or component). - If the context of a template is a controller, actions used this way will - bubble to routes when the controller does not implement the specified action. - Once an action hits a route, it will bubble through the route hierarchy. + any passed value to `disabled` will disable it except `undefined`. + to ensure that only `true` disable the `link-to` component you can + override the global behaviour of `Ember.LinkComponent`. - ### Event Propagation + ```javascript + Ember.LinkComponent.reopen({ + disabled: Ember.computed(function(key, value) { + if (value !== undefined) { + this.set('_isDisabled', value === true); + } + return value === true ? get(this, 'disabledClass') : false; + }) + }); + ``` - `{{action}}` helpers called in element space can control event bubbling. Note - that the closure style actions cannot. + see "Overriding Application-wide Defaults" for more. - Events triggered through the action helper will automatically have - `.preventDefault()` called on them. You do not need to do so in your event - handlers. If you need to allow event propagation (to handle file inputs for - example) you can supply the `preventDefault=false` option to the `{{action}}` helper: + ### Handling `href` + `{{link-to}}` will use your application's Router to + fill the element's `href` property with a url that + matches the path to the supplied `routeName` for your + router's configured `Location` scheme, which defaults + to Ember.HashLocation. + + ### Handling current route + `{{link-to}}` will apply a CSS class name of 'active' + when the application's current route matches + the supplied routeName. For example, if the application's + current route is 'photoGallery.recent' the following + use of `{{link-to}}`: ```handlebars -
    - - -
    + {{#link-to 'photoGallery.recent'}} + Great Hamster Photos + {{/link-to}} ``` - To disable bubbling, pass `bubbles=false` to the helper: + will result in - ```handlebars - + ```html +
    + Great Hamster Photos + ``` - To disable bubbling with closure style actions you must create your own - wrapper helper that makes use of `event.stopPropagation()`: + The CSS class name used for active classes can be customized + for a single use of `{{link-to}}` by passing an `activeClass` + option: ```handlebars -
    Hello
    + {{#link-to 'photoGallery.recent' activeClass="current-url"}} + Great Hamster Photos + {{/link-to}} ``` - ```js - // app/helpers/disable-bubbling.js - import Ember from 'ember'; - export function disableBubbling([action]) { - return function(event) { - event.stopPropagation(); - return action(event); - }; - } - export default Ember.Helper.helper(disableBubbling); + ```html + + Great Hamster Photos + ``` - If you need the default handler to trigger you should either register your - own event handler, or use event methods on your view class. See - ["Responding to Browser Events"](/api/classes/Ember.View.html#toc_responding-to-browser-events) - in the documentation for Ember.View for more information. + To override this option for your entire application, see + "Overriding Application-wide Defaults". - ### Specifying DOM event type + ### Keeping a link active for other routes - `{{action}}` helpers called in element space can specify an event type. - By default the `{{action}}` helper registers for DOM `click` events. You can - supply an `on` option to the helper to specify a different DOM event name: + If you need a link to be 'active' even when it doesn't match + the current route, you can use the `current-when` argument. ```handlebars -
    - click me -
    + {{#link-to 'photoGallery' current-when='photos'}} + Photo Gallery + {{/link-to}} ``` - See ["Event Names"](/api/classes/Ember.View.html#toc_event-names) for a list of - acceptable DOM event names. - - ### Specifying whitelisted modifier keys + This may be helpful for keeping links active for: - `{{action}}` helpers called in element space can specify modifier keys. - By default the `{{action}}` helper will ignore click events with pressed modifier - keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. + * non-nested routes that are logically related + * some secondary menu approaches + * 'top navigation' with 'sub navigation' scenarios - ```handlebars -
    - click me -
    - ``` + A link will be active if `current-when` is `true` or the current + route is the route this link would transition to. - This way the action will fire when clicking with the alt key pressed down. - Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. + To match multiple routes 'space-separate' the routes: ```handlebars -
    - click me with any key pressed -
    + {{#link-to 'gallery' current-when='photos drawings paintings'}} + Art Gallery + {{/link-to}} ``` - ### Specifying a Target + ### Supplying a model + An optional model argument can be used for routes whose + paths contain dynamic segments. This argument will become + the model context of the linked route: - A `target` option can be provided to the helper to change - which object will receive the method call. This option must be a path - to an object, accessible in the current context: + ```javascript + Router.map(function() { + this.route("photoGallery", {path: "hamster-photos/:photo_id"}); + }); + ``` ```handlebars - {{! app/templates/application.hbs }} -
    - click me -
    + {{#link-to 'photoGallery' aPhoto}} + {{aPhoto.title}} + {{/link-to}} + ``` + + ```html + + Tomster + ``` + ### Supplying multiple models + For deep-linking to route paths that contain multiple + dynamic segments, multiple model arguments can be used. + As the router transitions through the route path, each + supplied model argument will become the context for the + route with the dynamic segments: + ```javascript - // app/controllers/application.js - export default Ember.Controller.extend({ - someService: Ember.inject.service() + Router.map(function() { + this.route("photoGallery", { path: "hamster-photos/:photo_id" }, function() { + this.route("comment", {path: "comments/:comment_id"}); + }); }); ``` + This argument will become the model context of the linked route: - @method action - @for Ember.Templates.helpers - @public - */ - - var ClosureActionReference = (function (_CachedReference) { - babelHelpers.inherits(ClosureActionReference, _CachedReference); - - ClosureActionReference.create = function create(args) { - // TODO: Const reference optimization. - return new ClosureActionReference(args); - }; - - function ClosureActionReference(args) { - babelHelpers.classCallCheck(this, ClosureActionReference); - - _CachedReference.call(this); - - this.args = args; - this.tag = args.tag; - } - - ClosureActionReference.prototype.compute = function compute() { - var _args = this.args; - var named = _args.named; - var positional = _args.positional; - - var positionalValues = positional.value(); - - var target = positionalValues[0]; - var rawActionRef = positional.at(1); - var rawAction = positionalValues[1]; - - // The first two argument slots are reserved. - // pos[0] is the context (or `this`) - // pos[1] is the action name or function - // Anything else is an action argument. - var actionArgs = positionalValues.slice(2); - - // on-change={{action setName}} - // element-space actions look to "controller" then target. Here we only - // look to "target". - var actionType = typeof rawAction; - var action = rawAction; - - if (rawActionRef[INVOKE]) { - target = rawActionRef; - action = rawActionRef[INVOKE]; - } else if (_emberMetal.isNone(rawAction)) { - throw new _emberMetal.Error('Action passed is null or undefined in (action) from ' + target + '.'); - } else if (actionType === 'string') { - // on-change={{action 'setName'}} - var actionName = rawAction; - - action = null; - - if (named.has('target')) { - // on-change={{action 'setName' target=alternativeComponent}} - target = named.get('target').value(); - } - - if (target['actions']) { - action = target.actions[actionName]; - } - - if (!action) { - throw new _emberMetal.Error('An action named \'' + actionName + '\' was not found in ' + target); - } - } else if (action && typeof action[INVOKE] === 'function') { - target = action; - action = action[INVOKE]; - } else if (actionType !== 'function') { - // TODO: Is there a better way of doing this? - var rawActionLabel = rawActionRef._propertyKey || rawAction; - throw new _emberMetal.Error('An action could not be made for `' + rawActionLabel + '` in ' + target + '. Please confirm that you are using either a quoted action name (i.e. `(action \'' + rawActionLabel + '\')`) or a function available in ' + target + '.'); - } - - var valuePath = named.get('value').value(); - - return createClosureAction(target, action, valuePath, actionArgs); - }; - - return ClosureActionReference; - })(_emberGlimmerUtilsReferences.CachedReference); - - exports.ClosureActionReference = ClosureActionReference; - - exports.default = function (vm, args) { - return ClosureActionReference.create(args); - }; - - function createClosureAction(target, action, valuePath, actionArgs) { - var closureAction = undefined; - var actionArgLength = actionArgs.length; - - if (actionArgLength > 0) { - closureAction = function () { - for (var _len = arguments.length, passedArguments = Array(_len), _key = 0; _key < _len; _key++) { - passedArguments[_key] = arguments[_key]; - } - - var args = new Array(actionArgLength + passedArguments.length); - - for (var i = 0; i < actionArgLength; i++) { - args[i] = actionArgs[i]; - } - - for (var i = 0; i < passedArguments.length; i++) { - args[i + actionArgLength] = passedArguments[i]; - } - - if (valuePath && args.length > 0) { - args[0] = _emberMetal.get(args[0], valuePath); - } - - var payload = { target: target, args: args, label: 'glimmer-closure-action' }; - return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - return _emberMetal.run.join.apply(_emberMetal.run, [target, action].concat(args)); - }); - }; - } else { - closureAction = function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - if (valuePath && args.length > 0) { - args[0] = _emberMetal.get(args[0], valuePath); - } - - var payload = { target: target, args: args, label: 'glimmer-closure-action' }; - return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - return _emberMetal.run.join.apply(_emberMetal.run, [target, action].concat(args)); - }); - }; - } - - closureAction[ACTION] = true; - return closureAction; - } -}); -enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/curly-component', 'glimmer-runtime', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxCurlyComponent, _glimmerRuntime, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - /** - The `{{component}}` helper lets you add instances of `Ember.Component` to a - template. See [Ember.Component](/api/classes/Ember.Component.html) for - additional information on how a `Component` functions. - `{{component}}`'s primary use is for cases where you want to dynamically - change which type of component is rendered as the state of your application - changes. This helper has three modes: inline, block, and nested. - - ### Inline Form - - Given the following template: - - ```app/application.hbs - {{component infographicComponentName}} + ```handlebars + {{#link-to 'photoGallery.comment' aPhoto comment}} + {{comment.body}} + {{/link-to}} ``` - And the following application code: - - ```app/controllers/application.js - export default Ember.Controller.extend({ - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) - }); + ```html + + A+++ would snuggle again. + ``` - The `live-updating-chart` component will be appended when `isMarketOpen` is - `true`, and the `market-close-summary` component will be appended when - `isMarketOpen` is `false`. If the value changes while the app is running, - the component will be automatically swapped out accordingly. - Note: You should not use this helper when you are consistently rendering the same - component. In that case, use standard component syntax, for example: + ### Supplying an explicit dynamic segment value + If you don't have a model object available to pass to `{{link-to}}`, + an optional string or integer argument can be passed for routes whose + paths contain dynamic segments. This argument will become the value + of the dynamic segment: - ```app/templates/application.hbs - {{live-updating-chart}} + ```javascript + Router.map(function() { + this.route("photoGallery", { path: "hamster-photos/:photo_id" }); + }); ``` - ### Block Form - - Using the block form of this helper is similar to using the block form - of a component. Given the following application template: - - ```app/templates/application.hbs - {{#component infographicComponentName}} - Last update: {{lastUpdateTimestamp}} - {{/component}} + ```handlebars + {{#link-to 'photoGallery' aPhotoId}} + {{aPhoto.title}} + {{/link-to}} ``` - The following controller code: - - ```app/controllers/application.js - export default Ember.Controller.extend({ - lastUpdateTimestamp: computed(function() { - return new Date(); - }), - - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) - }); + ```html + + Tomster + ``` - And the following component template: - - ```app/templates/components/live-updating-chart.hbs - {{! chart }} - {{yield}} - ``` + When transitioning into the linked route, the `model` hook will + be triggered with parameters including this passed identifier. - The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. + ### Allowing Default Action - ### Nested Usage + By default the `{{link-to}}` component prevents the default browser action + by calling `preventDefault()` as this sort of action bubbling is normally + handled internally and we do not want to take the browser to a new URL (for + example). - The `component` helper can be used to package a component path with initial attrs. - The included attrs can then be merged during the final invocation. - For example, given a `person-form` component with the following template: + If you need to override this behavior specify `preventDefault=false` in + your template: - ```app/templates/components/person-form.hbs - {{yield (hash - nameInput=(component "my-input-component" value=model.name placeholder="First Name") - )}} + ```handlebars + {{#link-to 'photoGallery' aPhotoId preventDefault=false}} + {{aPhotoId.title}} + {{/link-to}} ``` - When yielding the component via the `hash` helper, the component is invocked directly. - See the following snippet: + ### Overriding attributes + You can override any given property of the `Ember.LinkComponent` + that is generated by the `{{link-to}}` component by passing + key/value pairs, like so: - ``` - {{#person-form as |form|}} - {{form.nameInput placeholder="Username"}} - {{/person-form}} + ```handlebars + {{#link-to aPhoto tagName='li' title='Following this link will change your life' classNames='pic sweet'}} + Uh-mazing! + {{/link-to}} ``` - Which outputs an input whose value is already bound to `model.name` and `placeholder` - is "Username". + See [Ember.LinkComponent](/api/classes/Ember.LinkComponent.html) for a + complete list of overrideable properties. Be sure to also + check out inherited properties of `LinkComponent`. - When yielding the component without the hash helper use the `component` helper. - For example, below is a `full-name` component template: + ### Overriding Application-wide Defaults + ``{{link-to}}`` creates an instance of `Ember.LinkComponent` + for rendering. To override options for your entire + application, reopen `Ember.LinkComponent` and supply the + desired values: - ```handlebars - {{yield (component "my-input-component" value=model.name placeholder="Name")}} + ``` javascript + Ember.LinkComponent.reopen({ + activeClass: "is-active", + tagName: 'li' + }) ``` - ``` - {{#full-name as |field|}} - {{component field placeholder="Full name"}} - {{/full-name}} + It is also possible to override the default event in + this manner: + + ``` javascript + Ember.LinkComponent.reopen({ + eventName: 'customEventName' + }); ``` - @method component - @since 1.11.0 + @method link-to @for Ember.Templates.helpers + @param {String} routeName + @param {Object} [context]* + @param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkComponent + @return {String} HTML string + @see {Ember.LinkComponent} @public */ - var ClosureComponentReference = (function (_CachedReference) { - babelHelpers.inherits(ClosureComponentReference, _CachedReference); + 'use strict'; - ClosureComponentReference.create = function create(args, symbolTable, env) { - return new ClosureComponentReference(args, symbolTable, env); - }; + /** + `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. + + `Ember.LinkComponent` components are invoked with {{#link-to}}. Properties + of this class can be overridden with `reopen` to customize application-wide + behavior. + + @class LinkComponent + @namespace Ember + @extends Ember.Component + @see {Ember.Templates.helpers.link-to} + @public + **/ + var LinkComponent = _emberGlimmerComponent.default.extend({ + layout: _emberGlimmerTemplatesLinkTo.default, - function ClosureComponentReference(args, symbolTable, env) { - babelHelpers.classCallCheck(this, ClosureComponentReference); + tagName: 'a', - _CachedReference.call(this); - this.defRef = args.positional.at(0); - this.env = env; - this.tag = args.positional.at(0).tag; - this.symbolTable = symbolTable; - this.args = args; - this.lastDefinition = undefined; - this.lastName = undefined; - } + /** + @deprecated Use current-when instead. + @property currentWhen + @private + */ + currentWhen: _emberRuntime.deprecatingAlias('current-when', { id: 'ember-routing-view.deprecated-current-when', until: '3.0.0' }), - ClosureComponentReference.prototype.compute = function compute() { - // TODO: Figure out how to extract this because it's nearly identical to - // DynamicComponentReference::compute(). The only differences besides - // currying are in the assertion messages. - var args = this.args; - var defRef = this.defRef; - var env = this.env; - var symbolTable = this.symbolTable; - var lastDefinition = this.lastDefinition; - var lastName = this.lastName; + /** + Used to determine when this `LinkComponent` is active. + @property currentWhen + @public + */ + 'current-when': null, - var nameOrDef = defRef.value(); - var definition = null; + /** + Sets the `title` attribute of the `LinkComponent`'s HTML element. + @property title + @default null + @public + **/ + title: null, - if (nameOrDef && nameOrDef === lastName) { - return lastDefinition; - } + /** + Sets the `rel` attribute of the `LinkComponent`'s HTML element. + @property rel + @default null + @public + **/ + rel: null, - this.lastName = nameOrDef; + /** + Sets the `tabindex` attribute of the `LinkComponent`'s HTML element. + @property tabindex + @default null + @public + **/ + tabindex: null, - if (typeof nameOrDef === 'string') { - definition = env.getComponentDefinition([nameOrDef], symbolTable); - _emberMetal.assert('The component helper cannot be used without a valid component name. You used "' + nameOrDef + '" via (component "' + nameOrDef + '")', definition); - } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { - definition = nameOrDef; - } else { - _emberMetal.assert('You cannot create a component from ' + nameOrDef + ' using the {{component}} helper', nameOrDef); - return null; - } + /** + Sets the `target` attribute of the `LinkComponent`'s HTML element. + @since 1.8.0 + @property target + @default null + @public + **/ + target: null, - var newDef = createCurriedDefinition(definition, args); + /** + The CSS class to apply to `LinkComponent`'s element when its `active` + property is `true`. + @property activeClass + @type String + @default active + @public + **/ + activeClass: 'active', - this.lastDefinition = newDef; + /** + The CSS class to apply to `LinkComponent`'s element when its `loading` + property is `true`. + @property loadingClass + @type String + @default loading + @private + **/ + loadingClass: 'loading', - return newDef; - }; + /** + The CSS class to apply to a `LinkComponent`'s element when its `disabled` + property is `true`. + @property disabledClass + @type String + @default disabled + @private + **/ + disabledClass: 'disabled', + _isDisabled: false, - return ClosureComponentReference; - })(_emberGlimmerUtilsReferences.CachedReference); + /** + Determines whether the `LinkComponent` will trigger routing via + the `replaceWith` routing strategy. + @property replace + @type Boolean + @default false + @public + **/ + replace: false, - exports.ClosureComponentReference = ClosureComponentReference; + /** + By default the `{{link-to}}` component will bind to the `href` and + `title` attributes. It's discouraged that you override these defaults, + however you can push onto the array if needed. + @property attributeBindings + @type Array | String + @default ['title', 'rel', 'tabindex', 'target'] + @public + */ + attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'], - function createCurriedDefinition(definition, args) { - var curriedArgs = curryArgs(definition, args); + /** + By default the `{{link-to}}` component will bind to the `active`, `loading`, + and `disabled` classes. It is discouraged to override these directly. + @property classNameBindings + @type Array + @default ['active', 'loading', 'disabled', 'ember-transitioning-in', 'ember-transitioning-out'] + @public + */ + classNameBindings: ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'], - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(definition.name, definition.ComponentClass, definition.template, curriedArgs); - } + /** + By default the `{{link-to}}` component responds to the `click` event. You + can override this globally by setting this property to your custom + event name. + This is particularly useful on mobile when one wants to avoid the 300ms + click delay using some sort of custom `tap` event. + @property eventName + @type String + @default click + @private + */ + eventName: 'click', - function curryArgs(definition, newArgs) { - var args = definition.args; - var ComponentClass = definition.ComponentClass; - var positionalParams = ComponentClass.positionalParams; + // this is doc'ed here so it shows up in the events + // section of the API documentation, which is where + // people will likely go looking for it. + /** + Triggers the `LinkComponent`'s routing behavior. If + `eventName` is changed to a value other than `click` + the routing behavior will trigger on that custom event + instead. + @event click + @private + */ - // The args being passed in are from the (component ...) invocation, - // so the first positional argument is actually the name or component - // definition. It needs to be dropped in order for any actual positional - // args to coincide with the ComponentClass's positionParams. + /** + An overridable method called when `LinkComponent` objects are instantiated. + Example: + ```javascript + App.MyLinkComponent = Ember.LinkComponent.extend({ + init: function() { + this._super(...arguments); + Ember.Logger.log('Event is ' + this.get('eventName')); + } + }); + ``` + NOTE: If you do override `init` for a framework class like `Ember.View`, + be sure to call `this._super(...arguments)` in your + `init` declaration! If you don't, Ember may not have an opportunity to + do important setup work, and you'll see strange behavior in your + application. + @method init + @private + */ + init: function () { + this._super.apply(this, arguments); - // For "normal" curly components this slicing is done at the syntax layer, - // but we don't have that luxury here. + // Map desired event name to invoke function + var eventName = _emberMetal.get(this, 'eventName'); + this.on(eventName, this, this._invoke); + }, - var _newArgs$positional$values = newArgs.positional.values; + _routing: _emberRuntime.inject.service('-routing'), - var slicedPositionalArgs = _newArgs$positional$values.slice(1); + /** + Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass` + CSS `class` to the element when the link is disabled. + When `true` interactions with the element will not trigger route changes. + @property disabled + @private + */ + disabled: _emberMetal.computed({ + get: function (key, value) { + return false; + }, + set: function (key, value) { + if (value !== undefined) { + this.set('_isDisabled', value); + } - if (positionalParams && slicedPositionalArgs.length) { - _emberGlimmerSyntaxCurlyComponent.validatePositionalParameters(newArgs.named, slicedPositionalArgs, positionalParams); - } + return value ? _emberMetal.get(this, 'disabledClass') : false; + } + }), - var isRest = typeof positionalParams === 'string'; + _computeActive: function (routerState) { + if (_emberMetal.get(this, 'loading')) { + return false; + } - // For non-rest position params, we need to perform the position -> name mapping - // at each layer to avoid a collision later when the args are used to construct - // the component instance (inside of processArgs(), inside of create()). - var positionalToNamedParams = {}; + var routing = _emberMetal.get(this, '_routing'); + var models = _emberMetal.get(this, 'models'); + var resolvedQueryParams = _emberMetal.get(this, 'resolvedQueryParams'); - if (!isRest && positionalParams && positionalParams.length > 0) { - var limit = Math.min(positionalParams.length, slicedPositionalArgs.length); + var currentWhen = _emberMetal.get(this, 'current-when'); + var isCurrentWhenSpecified = !!currentWhen; + currentWhen = currentWhen || _emberMetal.get(this, 'qualifiedRouteName'); + currentWhen = currentWhen.split(' '); - for (var i = 0; i < limit; i++) { - var _name = positionalParams[i]; - positionalToNamedParams[_name] = slicedPositionalArgs[i]; + for (var i = 0; i < currentWhen.length; i++) { + if (routing.isActiveForRoute(models, resolvedQueryParams, currentWhen[i], routerState, isCurrentWhenSpecified)) { + return _emberMetal.get(this, 'activeClass'); + } } - slicedPositionalArgs.length = 0; // Throw them away since you're merged in. - } + return false; + }, - // args (aka 'oldArgs') may be undefined or simply be empty args, so - // we need to fall back to an empty array or object. - var oldNamed = args && args.named && args.named.map || {}; - var oldPositional = args && args.positional && args.positional.values || []; + /** + Accessed as a classname binding to apply the `LinkComponent`'s `activeClass` + CSS `class` to the element when the link is active. + A `LinkComponent` is considered active when its `currentWhen` property is `true` + or the application's current route is the route the `LinkComponent` would trigger + transitions into. + The `currentWhen` property can match against multiple routes by separating + route names using the ` ` (space) character. + @property active + @private + */ + active: _emberMetal.computed('attrs.params', '_routing.currentState', function computeLinkToComponentActive() { + var currentState = _emberMetal.get(this, '_routing.currentState'); + if (!currentState) { + return false; + } - // Merge positional arrays - var mergedPositional = new Array(Math.max(oldPositional.length, slicedPositionalArgs.length)); - mergedPositional.splice.apply(mergedPositional, [0, oldPositional.length].concat(oldPositional)); - mergedPositional.splice.apply(mergedPositional, [0, slicedPositionalArgs.length].concat(slicedPositionalArgs)); + return this._computeActive(currentState); + }), - // Merge named maps - var mergedNamed = _emberUtils.assign({}, oldNamed, positionalToNamedParams, newArgs.named.map); + willBeActive: _emberMetal.computed('_routing.targetState', function computeLinkToComponentWillBeActive() { + var routing = _emberMetal.get(this, '_routing'); + var targetState = _emberMetal.get(routing, 'targetState'); + if (_emberMetal.get(routing, 'currentState') === targetState) { + return; + } - var mergedArgs = _glimmerRuntime.EvaluatedArgs.create(_glimmerRuntime.EvaluatedPositionalArgs.create(mergedPositional), _glimmerRuntime.EvaluatedNamedArgs.create(mergedNamed), _glimmerRuntime.Blocks.empty()); + return !!this._computeActive(targetState); + }), - return mergedArgs; - } + transitioningIn: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningIn() { + var willBeActive = _emberMetal.get(this, 'willBeActive'); + if (typeof willBeActive === 'undefined') { + return false; + } - exports.default = function (vm, args, symbolTable) { - return ClosureComponentReference.create(args, symbolTable, vm.env); - }; -}); -enifed('ember-glimmer/helpers/concat', ['exports', 'ember-glimmer/utils/references', 'glimmer-runtime'], function (exports, _emberGlimmerUtilsReferences, _glimmerRuntime) { - 'use strict'; + return !_emberMetal.get(this, 'active') && willBeActive && 'ember-transitioning-in'; + }), - /** - @module ember - @submodule ember-glimmer - */ + transitioningOut: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningOut() { + var willBeActive = _emberMetal.get(this, 'willBeActive'); + if (typeof willBeActive === 'undefined') { + return false; + } - /** - Concatenates the given arguments into a string. - - Example: - - ```handlebars - {{some-component name=(concat firstName " " lastName)}} - - {{! would pass name=" " to the component}} - ``` - - @public - @method concat - @for Ember.Templates.helpers - @since 1.13.0 - */ - function concat(_ref) { - var positional = _ref.positional; + return _emberMetal.get(this, 'active') && !willBeActive && 'ember-transitioning-out'; + }), - return positional.value().map(_glimmerRuntime.normalizeTextValue).join(''); - } + /** + Event handler that invokes the link, activating the associated route. + @method _invoke + @param {Event} event + @private + */ + _invoke: function (event) { + if (!_emberViews.isSimpleClick(event)) { + return true; + } - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(concat, args); - }; -}); -enifed('ember-glimmer/helpers/debugger', ['exports', 'ember-metal/debug', 'glimmer-runtime'], function (exports, _emberMetalDebug, _glimmerRuntime) { - /*jshint debug:true*/ + var preventDefault = _emberMetal.get(this, 'preventDefault'); + var targetAttribute = _emberMetal.get(this, 'target'); - /** - @module ember - @submodule ember-htmlbars - */ + if (preventDefault !== false) { + if (!targetAttribute || targetAttribute === '_self') { + event.preventDefault(); + } + } - 'use strict'; + if (_emberMetal.get(this, 'bubbles') === false) { + event.stopPropagation(); + } - exports.default = debuggerHelper; - exports.setDebuggerCallback = setDebuggerCallback; - exports.resetDebuggerCallback = resetDebuggerCallback; + if (_emberMetal.get(this, '_isDisabled')) { + return false; + } - /** - Execute the `debugger` statement in the current template's context. - - ```handlebars - {{debugger}} - ``` - - When using the debugger helper you will have access to a `get` function. This - function retrieves values available in the context of the template. - For example, if you're wondering why a value `{{foo}}` isn't rendering as - expected within a template, you could place a `{{debugger}}` statement and, - when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: - - ``` - > get('foo') - ``` - - `get` is also aware of block variables. So in this situation - - ```handlebars - {{#each items as |item|}} - {{debugger}} - {{/each}} - ``` - - You'll be able to get values from the current item: - - ``` - > get('item.name') - ``` - - You can also access the context of the view to make sure it is the object that - you expect: - - ``` - > context - ``` - - @method debugger - @for Ember.Templates.helpers - @public - */ - function defaultCallback(context, get) { - /* jshint debug: true */ + if (_emberMetal.get(this, 'loading')) { + _emberConsole.default.warn('This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'); + return false; + } + + if (targetAttribute && targetAttribute !== '_self') { + return false; + } - _emberMetalDebug.info('Use `context`, and `get()` to debug this template.'); + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var models = _emberMetal.get(this, 'models'); + var queryParams = _emberMetal.get(this, 'queryParams.values'); + var shouldReplace = _emberMetal.get(this, 'replace'); - debugger; - } + var payload = { + queryParams: queryParams, + routeName: qualifiedRouteName + }; - var callback = defaultCallback; + _emberMetal.flaggedInstrument('interaction.link-to', payload, this._generateTransition(payload, qualifiedRouteName, models, queryParams, shouldReplace)); + }, - function debuggerHelper(vm, args, symbolTable) { - var context = vm.getSelf().value(); + _generateTransition: function (payload, qualifiedRouteName, models, queryParams, shouldReplace) { + var routing = _emberMetal.get(this, '_routing'); + return function () { + payload.transition = routing.transitionTo(qualifiedRouteName, models, queryParams, shouldReplace); + }; + }, - // Note: this is totally an overkill since we are only compiling - // expressions, but this is the only kind of SymbolLookup we can - // construct. The symbol table itself should really be sufficient - // here – we should refactor the Glimmer code to make that possible. - var symbolLookup = new _glimmerRuntime.CompileIntoList(vm.env, symbolTable); + queryParams: null, - function get(path) { - // Problem: technically, we are getting a `PublicVM` here, but to - // evaluate an expression it requires the full VM. We happen to know - // that they are the same thing, so this would work for now. However - // this might break in the future. - return _glimmerRuntime.GetSyntax.build(path).compile(symbolLookup).evaluate(vm).value(); - } + qualifiedRouteName: _emberMetal.computed('targetRouteName', '_routing.currentState', function computeLinkToComponentQualifiedRouteName() { + var params = _emberMetal.get(this, 'params').slice(); + var lastParam = params[params.length - 1]; + if (lastParam && lastParam.isQueryParams) { + params.pop(); + } + var onlyQueryParamsSupplied = this[_emberGlimmerComponent.HAS_BLOCK] ? params.length === 0 : params.length === 1; + if (onlyQueryParamsSupplied) { + return _emberMetal.get(this, '_routing.currentRouteName'); + } + return _emberMetal.get(this, 'targetRouteName'); + }), - callback(context, get); + resolvedQueryParams: _emberMetal.computed('queryParams', function computeLinkToComponentResolvedQueryParams() { + var resolvedQueryParams = {}; + var queryParams = _emberMetal.get(this, 'queryParams'); - return _glimmerRuntime.UNDEFINED_REFERENCE; - } + if (!queryParams) { + return resolvedQueryParams; + } - // These are exported for testing + var values = queryParams.values; + for (var key in values) { + if (!values.hasOwnProperty(key)) { + continue; + } + resolvedQueryParams[key] = values[key]; + } - function setDebuggerCallback(newCallback) { - callback = newCallback; - } + return resolvedQueryParams; + }), - function resetDebuggerCallback() { - callback = defaultCallback; - } + /** + Sets the element's `href` attribute to the url for + the `LinkComponent`'s targeted route. + If the `LinkComponent`'s `tagName` is changed to a value other + than `a`, this property will be ignored. + @property href + @private + */ + href: _emberMetal.computed('models', 'qualifiedRouteName', function computeLinkToComponentHref() { + if (_emberMetal.get(this, 'tagName') !== 'a') { + return; + } + + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var models = _emberMetal.get(this, 'models'); + + if (_emberMetal.get(this, 'loading')) { + return _emberMetal.get(this, 'loadingHref'); + } + + var routing = _emberMetal.get(this, '_routing'); + var queryParams = _emberMetal.get(this, 'queryParams.values'); + + _emberMetal.runInDebug(function () { + /* + * Unfortunately, to get decent error messages, we need to do this. + * In some future state we should be able to use a "feature flag" + * which allows us to strip this without needing to call it twice. + * + * if (isDebugBuild()) { + * // Do the useful debug thing, probably including try/catch. + * } else { + * // Do the performant thing. + * } + */ + try { + routing.generateURL(qualifiedRouteName, models, queryParams); + } catch (e) { + _emberMetal.assert('You attempted to define a `{{link-to "' + qualifiedRouteName + '"}}` but did not pass the parameters required for generating its dynamic segments. ' + e.message); + } + }); + + return routing.generateURL(qualifiedRouteName, models, queryParams); + }), + + loading: _emberMetal.computed('_modelsAreLoaded', 'qualifiedRouteName', function computeLinkToComponentLoading() { + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var modelsAreLoaded = _emberMetal.get(this, '_modelsAreLoaded'); + + if (!modelsAreLoaded || qualifiedRouteName == null) { + return _emberMetal.get(this, 'loadingClass'); + } + }), + + _modelsAreLoaded: _emberMetal.computed('models', function computeLinkToComponentModelsAreLoaded() { + var models = _emberMetal.get(this, 'models'); + for (var i = 0; i < models.length; i++) { + if (models[i] == null) { + return false; + } + } + + return true; + }), + + _getModels: function (params) { + var modelCount = params.length - 1; + var models = new Array(modelCount); + + for (var i = 0; i < modelCount; i++) { + var value = params[i + 1]; + + while (_emberRuntime.ControllerMixin.detect(value)) { + _emberMetal.deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' + (this.parentView ? 'Please update `' + this.parentView + '` to use `{{link-to "post" someController.model}}` instead.' : ''), false, { id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }); + value = value.get('model'); + } + + models[i] = value; + } + + return models; + }, + + /** + The default href value to use while a link-to is loading. + Only applies when tagName is 'a' + @property loadingHref + @type String + @default # + @private + */ + loadingHref: '#', + + didReceiveAttrs: function () { + var queryParams = undefined; + + var params = _emberMetal.get(this, 'params'); + + if (params) { + // Do not mutate params in place + params = params.slice(); + } + + _emberMetal.assert('You must provide one or more parameters to the link-to component.', (function () { + if (!params) { + return false; + } + + return params.length; + })()); + + var disabledWhen = _emberMetal.get(this, 'disabledWhen'); + if (disabledWhen !== undefined) { + this.set('disabled', disabledWhen); + } + + // Process the positional arguments, in order. + // 1. Inline link title comes first, if present. + if (!this[_emberGlimmerComponent.HAS_BLOCK]) { + this.set('linkTitle', params.shift()); + } + + // 2. `targetRouteName` is now always at index 0. + this.set('targetRouteName', params[0]); + + // 3. The last argument (if still remaining) is the `queryParams` object. + var lastParam = params[params.length - 1]; + + if (lastParam && lastParam.isQueryParams) { + queryParams = params.pop(); + } else { + queryParams = { values: {} }; + } + this.set('queryParams', queryParams); + + // 4. Any remaining indices (excepting `targetRouteName` at 0) are `models`. + if (params.length > 1) { + this.set('models', this._getModels(params)); + } else { + this.set('models', []); + } + } + }); + + LinkComponent.toString = function () { + return 'LinkComponent'; + }; + + LinkComponent.reopenClass({ + positionalParams: 'params' + }); + + exports.default = LinkComponent; }); -enifed('ember-glimmer/helpers/each-in', ['exports', 'ember-utils'], function (exports, _emberUtils) { +enifed('ember-glimmer/components/text_area', ['exports', 'ember-glimmer/component', 'ember-views', 'ember-glimmer/templates/empty'], function (exports, _emberGlimmerComponent, _emberViews, _emberGlimmerTemplatesEmpty) { /** @module ember @submodule ember-glimmer */ 'use strict'; - exports.isEachIn = isEachIn; - /** - The `{{#each}}` helper loops over elements in a collection. It is an extension - of the base Handlebars `{{#each}}` helper. - The default behavior of `{{#each}}` is to yield its inner block once for every - item in an array passing the item as the first block parameter. + `{{textarea}}` inserts a new instance of ` ``` - ### Specifying Keys + Bound: - The `key` option is used to tell Ember how to determine if the array being - iterated over with `{{#each}}` has changed between renders. By helping Ember - detect that some elements in the array are the same, DOM elements can be - re-used, significantly improving rendering speed. + In the following example, the `writtenWords` property on `App.ApplicationController` + will be updated live as the user types 'Lots of text that IS bound' into + the text area of their browser's window. - For example, here's the `{{#each}}` helper with its `key` set to `id`: + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound" + }); + ``` ```handlebars - {{#each model key="id" as |item|}} - {{/each}} + {{textarea value=writtenWords}} ``` - When this `{{#each}}` re-renders, Ember will match up the previously rendered - items (and reorder the generated DOM elements) based on each item's `id` - property. - By default the item's own reference is used. - - ### {{else}} condition - - `{{#each}}` can have a matching `{{else}}`. The contents of this block will render - if the collection is empty. + Would result in the following HTML: - ```handlebars - {{#each developers as |person|}} - {{person.name}} - {{else}} -

    Sorry, nobody is available for this task.

    - {{/each}} + ```html + ``` - @method each - @for Ember.Templates.helpers - @public - */ - - /** - The `{{each-in}}` helper loops over properties on an object. - - For example, given a `user` object that looks like: + If you wanted a one way binding between the text area and a div tag + somewhere else on your screen, you could use `Ember.computed.oneWay`: ```javascript - { - "name": "Shelly Sails", - "age": 42 - } + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + outputWrittenWords: Ember.computed.oneWay("writtenWords") + }); ``` - This template would display all properties on the `user` - object in a list: - ```handlebars -
      - {{#each-in user as |key value|}} -
    • {{key}}: {{value}}
    • - {{/each-in}} -
    + {{textarea value=writtenWords}} +
    + {{outputWrittenWords}} +
    ``` - Outputting their name and age. + Would result in the following HTML: - @method each-in - @for Ember.Templates.helpers - @public - @since 2.1.0 - */ - var EACH_IN_REFERENCE = _emberUtils.symbol('EACH_IN'); - - function isEachIn(ref) { - return ref && ref[EACH_IN_REFERENCE]; - } - - exports.default = function (vm, args) { - var ref = Object.create(args.positional.at(0)); - ref[EACH_IN_REFERENCE] = true; - return ref; - }; -}); -enifed('ember-glimmer/helpers/get', ['exports', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - 'use strict'; - - /** - @module ember - @submodule ember-glimmer - */ - - /** - Dynamically look up a property on an object. The second argument to `{{get}}` - should have a string value, although it can be bound. + ```html + + <-- the following div will be updated in real time as you type --> +
    + Lots of text that IS bound +
    + ``` - For example, these two usages are equivilent: + Finally, this example really shows the power and ease of Ember when two + properties are bound to eachother via `Ember.computed.alias`. Type into + either text area box and they'll both stay in sync. Note that + `Ember.computed.alias` costs more in terms of performance, so only use it when + your really binding in both directions: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + twoWayWrittenWords: Ember.computed.alias("writtenWords") + }); + ``` ```handlebars - {{person.height}} - {{get person "height"}} + {{textarea value=writtenWords}} + {{textarea value=twoWayWrittenWords}} ``` - If there were several facts about a person, the `{{get}}` helper can dynamically - pick one: + ```html + + <-- both updated in real time --> + + ``` + + ### Actions + + The helper can send multiple actions based on user events. + The action property defines the action which is send when + the user presses the return key. ```handlebars - {{get person factName}} + {{input action="submit"}} ``` - For a more complex example, this template would allow the user to switch - between showing the user's height and weight with a click: + The helper allows some user events to send actions. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. ```handlebars - {{get person factName}} - - + {{textarea focus-in="alertMessage"}} ``` - The `{{get}}` helper can also respect mutable values itself. For example: + See more about [Text Support Actions](/api/classes/Ember.TextArea.html) - ```handlebars - {{input value=(mut (get person factName)) type="text"}} - - + ### Extension + + Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing + arguments from the helper to `Ember.TextArea`'s `create` method. You can + extend the capabilities of text areas in your application by reopening this + class. For example, if you are building a Bootstrap project where `data-*` + attributes are used, you can globally add support for a `data-*` attribute + on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or + `Ember.TextSupport` and adding it to the `attributeBindings` concatenated + property: + + ```javascript + Ember.TextArea.reopen({ + attributeBindings: ['data-error'] + }); ``` - Would allow the user to swap what fact is being displayed, and also edit - that fact via a two-way mutable binding. + Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` + itself extends `Ember.Component`. Expect isolated component semantics, not + legacy 1.x view semantics (like `controller` being present). - @public - @method get + See more about [Ember components](/api/classes/Ember.Component.html) + + @method textarea @for Ember.Templates.helpers - @since 2.1.0 - */ + @param {Hash} options + @public + */ - exports.default = function (vm, args) { - return GetHelperReference.create(args.positional.at(0), args.positional.at(1)); - }; + /** + The internal class used to create textarea element when the `{{textarea}}` + helper is used. + + See [Ember.Templates.helpers.textarea](/api/classes/Ember.Templates.helpers.html#method_textarea) for usage details. + + ## Layout and LayoutName properties + + Because HTML `textarea` elements do not contain inner HTML the `layout` and + `layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextArea + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + @public + */ + exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { + classNames: ['ember-text-area'], - var GetHelperReference = (function (_CachedReference) { - babelHelpers.inherits(GetHelperReference, _CachedReference); + layout: _emberGlimmerTemplatesEmpty.default, - GetHelperReference.create = function create(sourceReference, pathReference) { - if (_glimmerReference.isConst(pathReference)) { - var parts = pathReference.value().split('.'); - return _glimmerReference.referenceFromParts(sourceReference, parts); - } else { - return new GetHelperReference(sourceReference, pathReference); - } - }; + tagName: 'textarea', + attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir', 'value'], + rows: null, + cols: null + }); +}); +enifed('ember-glimmer/components/text_field', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-glimmer/component', 'ember-glimmer/templates/empty', 'ember-views'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty, _emberViews) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - function GetHelperReference(sourceReference, pathReference) { - babelHelpers.classCallCheck(this, GetHelperReference); + var inputTypeTestElement = undefined; + var inputTypes = new _emberUtils.EmptyObject(); + function canSetTypeOfInput(type) { + if (type in inputTypes) { + return inputTypes[type]; + } - _CachedReference.call(this); - this.sourceReference = sourceReference; - this.pathReference = pathReference; + // if running in outside of a browser always return the + // original type + if (!_emberEnvironment.environment.hasDOM) { + inputTypes[type] = type; - this.lastPath = null; - this.innerReference = null; + return type; + } - var innerTag = this.innerTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + if (!inputTypeTestElement) { + inputTypeTestElement = document.createElement('input'); + } - this.tag = _glimmerReference.combine([sourceReference.tag, pathReference.tag, innerTag]); + try { + inputTypeTestElement.type = type; + } catch (e) { + // ignored } - GetHelperReference.prototype.compute = function compute() { - var lastPath = this.lastPath; - var innerReference = this.innerReference; - var innerTag = this.innerTag; + return inputTypes[type] = inputTypeTestElement.type === type; + } - var path = this.lastPath = this.pathReference.value(); + /** + + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `text`. + + See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. + + ## Layout and LayoutName properties + + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextField + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + @public + */ + exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { + layout: _emberGlimmerTemplatesEmpty.default, + classNames: ['ember-text-field'], + tagName: 'input', + attributeBindings: ['accept', 'autocomplete', 'autosave', 'dir', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'inputmode', 'lang', 'list', 'max', 'min', 'multiple', 'name', 'pattern', 'size', 'step', 'type', 'value', 'width'], - if (path !== lastPath) { - if (path) { - var pathType = typeof path; + /** + The `value` attribute of the input element. As the user inputs text, this + property is updated live. + @property value + @type String + @default "" + @public + */ + value: '', - if (pathType === 'string') { - innerReference = this.innerReference = _glimmerReference.referenceFromParts(this.sourceReference, path.split('.')); - } else if (pathType === 'number') { - innerReference = this.innerReference = this.sourceReference.get(path); - } + /** + The `type` attribute of the input element. + @property type + @type String + @default "text" + @public + */ + type: _emberMetal.computed({ + get: function () { + return 'text'; + }, - innerTag.update(innerReference.tag); - } else { - innerReference = this.innerReference = null; - innerTag.update(_glimmerReference.CONSTANT_TAG); - } - } + set: function (key, value) { + var type = 'text'; - return innerReference ? innerReference.value() : null; - }; + if (canSetTypeOfInput(value)) { + type = value; + } - GetHelperReference.prototype[_emberGlimmerUtilsReferences.UPDATE] = function (value) { - _emberMetal.set(this.sourceReference.value(), this.pathReference.value(), value); - }; + return type; + } + }), - return GetHelperReference; - })(_emberGlimmerUtilsReferences.CachedReference); -}); -enifed("ember-glimmer/helpers/hash", ["exports"], function (exports) { - /** - @module ember - @submodule ember-glimmer - */ + /** + The `size` of the text field in characters. + @property size + @type String + @default null + @public + */ + size: null, - /** - Use the `{{hash}}` helper to create a hash to pass as an option to your - components. This is specially useful for contextual components where you can - just yield a hash: - - ```handlebars - {{yield (hash - name='Sarah' - title=office - )}} - ``` - - Would result in an object such as: - - ```js - { name: 'Sarah', title: this.get('office') } - ``` - - Where the `title` is bound to updates of the `office` property. - - @method hash - @for Ember.Templates.helpers - @param {Object} options - @return {Object} Hash + /** + The `pattern` attribute of input element. + @property pattern + @type String + @default null @public */ + pattern: null, - "use strict"; + /** + The `min` attribute of input element used with `type="number"` or `type="range"`. + @property min + @type String + @default null + @since 1.4.0 + @public + */ + min: null, - exports.default = function (vm, args) { - return args.named; - }; + /** + The `max` attribute of input element used with `type="number"` or `type="range"`. + @property max + @type String + @default null + @since 1.4.0 + @public + */ + max: null + }); }); -enifed('ember-glimmer/helpers/if-unless', ['exports', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - /** - @module ember - @submodule ember-glimmer - */ - +enifed('ember-glimmer/dom', ['exports', '@glimmer/runtime', '@glimmer/node'], function (exports, _glimmerRuntime, _glimmerNode) { 'use strict'; - exports.inlineIf = inlineIf; - exports.inlineUnless = inlineUnless; + exports.DOMChanges = _glimmerRuntime.DOMChanges; + exports.DOMTreeConstruction = _glimmerRuntime.DOMTreeConstruction; + exports.NodeDOMTreeConstruction = _glimmerNode.NodeDOMTreeConstruction; +}); +enifed('ember-glimmer/environment', ['exports', 'ember-utils', 'ember-metal', 'ember-views', '@glimmer/runtime', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/utils/debug-stack', 'ember-glimmer/helpers/if-unless', 'ember-glimmer/helpers/action', 'ember-glimmer/helpers/component', 'ember-glimmer/helpers/concat', 'ember-glimmer/helpers/get', 'ember-glimmer/helpers/hash', 'ember-glimmer/helpers/loc', 'ember-glimmer/helpers/log', 'ember-glimmer/helpers/mut', 'ember-glimmer/helpers/readonly', 'ember-glimmer/helpers/unbound', 'ember-glimmer/helpers/-class', 'ember-glimmer/helpers/-input-type', 'ember-glimmer/helpers/query-param', 'ember-glimmer/helpers/each-in', 'ember-glimmer/helpers/-normalize-class', 'ember-glimmer/helpers/-html-safe', 'ember-glimmer/protocol-for-url', 'container', 'ember-glimmer/modifiers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _glimmerRuntime, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntax, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerUtilsDebugStack, _emberGlimmerHelpersIfUnless, _emberGlimmerHelpersAction, _emberGlimmerHelpersComponent, _emberGlimmerHelpersConcat, _emberGlimmerHelpersGet, _emberGlimmerHelpersHash, _emberGlimmerHelpersLoc, _emberGlimmerHelpersLog, _emberGlimmerHelpersMut, _emberGlimmerHelpersReadonly, _emberGlimmerHelpersUnbound, _emberGlimmerHelpersClass, _emberGlimmerHelpersInputType, _emberGlimmerHelpersQueryParam, _emberGlimmerHelpersEachIn, _emberGlimmerHelpersNormalizeClass, _emberGlimmerHelpersHtmlSafe, _emberGlimmerProtocolForUrl, _container, _emberGlimmerModifiersAction) { + 'use strict'; - /** - Use the `if` block helper to conditionally render a block depending on a - property. If the property is "falsey", for example: `false`, `undefined`, - `null`, `""`, `0`, `NaN` or an empty array, the block will not be rendered. - - ```handlebars - {{! will not render if foo is falsey}} - {{#if foo}} - Welcome to the {{foo.bar}} - {{/if}} - ``` - - You can also specify a template to show if the property is falsey by using - the `else` helper. - - ```handlebars - {{! is it raining outside?}} - {{#if isRaining}} - Yes, grab an umbrella! - {{else}} - No, it's lovely outside! - {{/if}} - ``` - - You are also able to combine `else` and `if` helpers to create more complex - conditional logic. - - ```handlebars - {{#if isMorning}} - Good morning - {{else if isAfternoon}} - Good afternoon - {{else}} - Good night - {{/if}} - ``` - - You can use `if` inline to conditionally render a single property or string. - This helper acts like a ternary operator. If the first property is truthy, - the second argument will be displayed, if not, the third argument will be - displayed - - ```handlebars - {{if useLongGreeting "Hello" "Hi"}} Dave - ``` - - Finally, you can use the `if` helper inside another helper as a subexpression. - - ```handlebars - {{some-component height=(if isBig "100" "10")}} - ``` - - @method if - @for Ember.Templates.helpers - @public - */ + var Environment = (function (_GlimmerEnvironment) { + babelHelpers.inherits(Environment, _GlimmerEnvironment); - var ConditionalHelperReference = (function (_CachedReference) { - babelHelpers.inherits(ConditionalHelperReference, _CachedReference); + Environment.create = function create(options) { + return new Environment(options); + }; - ConditionalHelperReference.create = function create(_condRef, _truthyRef, _falsyRef) { - var condRef = _emberGlimmerUtilsReferences.ConditionalReference.create(_condRef); - var truthyRef = _truthyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; - var falsyRef = _falsyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; + function Environment(_ref) { + var _this = this; - if (_glimmerReference.isConst(condRef)) { - return condRef.value() ? truthyRef : falsyRef; - } else { - return new ConditionalHelperReference(condRef, truthyRef, falsyRef); - } - }; + var owner = _ref[_emberUtils.OWNER]; + babelHelpers.classCallCheck(this, Environment); - function ConditionalHelperReference(cond, truthy, falsy) { - babelHelpers.classCallCheck(this, ConditionalHelperReference); + _GlimmerEnvironment.apply(this, arguments); + this.owner = owner; + this.isInteractive = owner.lookup('-environment:main').isInteractive; - _CachedReference.call(this); + // can be removed once https://github.com/tildeio/glimmer/pull/305 lands + this.destroyedComponents = undefined; - this.branchTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([cond.tag, this.branchTag]); + _emberGlimmerProtocolForUrl.default(this); - this.cond = cond; - this.truthy = truthy; - this.falsy = falsy; - } + this._definitionCache = new _emberMetal.Cache(2000, function (_ref2) { + var name = _ref2.name; + var source = _ref2.source; + var owner = _ref2.owner; - /** - The inline `if` helper conditionally renders a single property or string. - This helper acts like a ternary operator. If the first property is truthy, - the second argument will be displayed, otherwise, the third argument will be - displayed - - ```handlebars - {{if useLongGreeting "Hello" "Hi"}} Alex - ``` - - You can use the `if` helper inside another helper as a subexpression. - - ```handlebars - {{some-component height=(if isBig "100" "10")}} - ``` - - @method if - @for Ember.Templates.helpers - @public - */ + var _lookupComponent = _emberViews.lookupComponent(owner, name, { source: source }); - ConditionalHelperReference.prototype.compute = function compute() { - var cond = this.cond; - var truthy = this.truthy; - var falsy = this.falsy; + var componentFactory = _lookupComponent.component; + var layout = _lookupComponent.layout; - var branch = cond.value() ? truthy : falsy; + if (componentFactory || layout) { + return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(name, componentFactory, layout); + } + }, function (_ref3) { + var name = _ref3.name; + var source = _ref3.source; + var owner = _ref3.owner; - this.branchTag.update(branch.tag); + var expandedName = source && owner._resolveLocalLookupName(name, source) || name; + var ownerGuid = _emberUtils.guidFor(owner); - return branch.value(); - }; + return ownerGuid + '|' + expandedName; + }); - return ConditionalHelperReference; - })(_emberGlimmerUtilsReferences.CachedReference); + this._templateCache = new _emberMetal.Cache(1000, function (_ref4) { + var Template = _ref4.Template; + var owner = _ref4.owner; - function inlineIf(vm, _ref) { - var positional = _ref.positional; + if (Template.create) { + var _Template$create; - switch (positional.length) { - case 2: - return ConditionalHelperReference.create(positional.at(0), positional.at(1), null); - case 3: - return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); - default: - _emberMetal.assert('The inline form of the `if` helper expects two or three arguments, e.g. ' + '`{{if trialExpired "Expired" expiryDate}}`.'); - } - } + // we received a factory + return Template.create((_Template$create = { env: _this }, _Template$create[_emberUtils.OWNER] = owner, _Template$create)); + } else { + // we were provided an instance already + return Template; + } + }, function (_ref5) { + var Template = _ref5.Template; + var owner = _ref5.owner; + return _emberUtils.guidFor(owner) + '|' + Template.id; + }); - /** - The inline `unless` helper conditionally renders a single property or string. - This helper acts like a ternary operator. If the first property is falsy, - the second argument will be displayed, otherwise, the third argument will be - displayed - - ```handlebars - {{unless useLongGreeting "Hi" "Hello"}} Ben - ``` - - You can use the `unless` helper inside another helper as a subexpression. - - ```handlebars - {{some-component height=(unless isBig "10" "100")}} - ``` - - @method unless - @for Ember.Templates.helpers - @public - */ + this._compilerCache = new _emberMetal.Cache(10, function (Compiler) { + return new _emberMetal.Cache(2000, function (template) { + var compilable = new Compiler(template); + return _glimmerRuntime.compileLayout(compilable, _this); + }, function (template) { + var owner = template.meta.owner; + return _emberUtils.guidFor(owner) + '|' + template.id; + }); + }, function (Compiler) { + return Compiler.id; + }); - function inlineUnless(vm, _ref2) { - var positional = _ref2.positional; + this.builtInModifiers = { + action: new _emberGlimmerModifiersAction.default() + }; - switch (positional.length) { - case 2: - return ConditionalHelperReference.create(positional.at(0), null, positional.at(1)); - case 3: - return ConditionalHelperReference.create(positional.at(0), positional.at(2), positional.at(1)); - default: - _emberMetal.assert('The inline form of the `unless` helper expects two or three arguments, e.g. ' + '`{{unless isFirstLogin "Welcome back!"}}`.'); + this.builtInHelpers = { + if: _emberGlimmerHelpersIfUnless.inlineIf, + action: _emberGlimmerHelpersAction.default, + component: _emberGlimmerHelpersComponent.default, + concat: _emberGlimmerHelpersConcat.default, + get: _emberGlimmerHelpersGet.default, + hash: _emberGlimmerHelpersHash.default, + loc: _emberGlimmerHelpersLoc.default, + log: _emberGlimmerHelpersLog.default, + mut: _emberGlimmerHelpersMut.default, + 'query-params': _emberGlimmerHelpersQueryParam.default, + readonly: _emberGlimmerHelpersReadonly.default, + unbound: _emberGlimmerHelpersUnbound.default, + unless: _emberGlimmerHelpersIfUnless.inlineUnless, + '-class': _emberGlimmerHelpersClass.default, + '-each-in': _emberGlimmerHelpersEachIn.default, + '-input-type': _emberGlimmerHelpersInputType.default, + '-normalize-class': _emberGlimmerHelpersNormalizeClass.default, + '-html-safe': _emberGlimmerHelpersHtmlSafe.default, + '-get-dynamic-var': _glimmerRuntime.getDynamicVar + }; + + _emberMetal.runInDebug(function () { + return _this.debugStack = new _emberGlimmerUtilsDebugStack.default(); + }); } - } -}); -enifed('ember-glimmer/helpers/loc', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - /** - Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the - provided string. This is a convenient way to localize text within a template. - For example: - - ```javascript - Ember.STRINGS = { - '_welcome_': 'Bonjour' + Environment.prototype.macros = function macros() { + var macros = _GlimmerEnvironment.prototype.macros.call(this); + _emberGlimmerSyntax.populateMacros(macros.blocks, macros.inlines); + return macros; }; - ``` - - ```handlebars -
    - {{loc '_welcome_'}} -
    - ``` - - ```html -
    - Bonjour -
    - ``` - - See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to - set up localized string references. - - @method loc - @for Ember.Templates.helpers - @param {String} str The string to format. - @see {Ember.String#loc} - @public - */ - function locHelper(_ref) { - var positional = _ref.positional; - return _emberRuntime.String.loc.apply(null, positional.value()); - } + Environment.prototype.hasComponentDefinition = function hasComponentDefinition() { + return false; + }; - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(locHelper, args); - }; -}); -enifed('ember-glimmer/helpers/log', ['exports', 'ember-glimmer/utils/references', 'ember-console'], function (exports, _emberGlimmerUtilsReferences, _emberConsole) { - 'use strict'; + Environment.prototype.getComponentDefinition = function getComponentDefinition(path, symbolTable) { + var name = path[0]; + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var source = blockMeta.moduleName && 'template:' + blockMeta.moduleName; - /** - `log` allows you to output the value of variables in the current rendering - context. `log` also accepts primitive types such as strings or numbers. - - ```handlebars - {{log "myVariable:" myVariable }} - ``` - - @method log - @for Ember.Templates.helpers - @param {Array} params - @public - */ - function log(_ref) { - var positional = _ref.positional; + return this._definitionCache.get({ name: name, source: source, owner: owner }); + }; - _emberConsole.default.log.apply(null, positional.value()); - } + // normally templates should be exported at the proper module name + // and cached in the container, but this cache supports templates + // that have been set directly on the component's layout property - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(log, args); - }; -}); + Environment.prototype.getTemplate = function getTemplate(Template, owner) { + return this._templateCache.get({ Template: Template, owner: owner }); + }; -/** -@module ember -@submodule ember-glimmer -*/ -enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerHelpersAction) { + // a Compiler can wrap the template so it needs its own cache + + Environment.prototype.getCompiledBlock = function getCompiledBlock(Compiler, template) { + var compilerCache = this._compilerCache.get(Compiler); + return compilerCache.get(template); + }; + + Environment.prototype.hasPartial = function hasPartial(name, symbolTable) { + var _symbolTable$getMeta = symbolTable.getMeta(); + + var owner = _symbolTable$getMeta.owner; + + return _emberViews.hasPartial(name, owner); + }; + + Environment.prototype.lookupPartial = function lookupPartial(name, symbolTable) { + var _symbolTable$getMeta2 = symbolTable.getMeta(); + + var owner = _symbolTable$getMeta2.owner; + + var partial = { + template: _emberViews.lookupPartial(name, owner) + }; + + if (partial.template) { + return partial; + } else { + throw new Error(name + ' is not a partial'); + } + }; + + Environment.prototype.hasHelper = function hasHelper(nameParts, symbolTable) { + _emberMetal.assert('The first argument passed into `hasHelper` should be an array', Array.isArray(nameParts)); + + // helpers are not allowed to include a dot in their invocation + if (nameParts.length > 1) { + return false; + } + + var name = nameParts[0]; + + if (this.builtInHelpers[name]) { + return true; + } + + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var options = { source: 'template:' + blockMeta.moduleName }; + + return owner.hasRegistration('helper:' + name, options) || owner.hasRegistration('helper:' + name); + }; + + Environment.prototype.lookupHelper = function lookupHelper(nameParts, symbolTable) { + _emberMetal.assert('The first argument passed into `lookupHelper` should be an array', Array.isArray(nameParts)); + + var name = nameParts[0]; + var helper = this.builtInHelpers[name]; + + if (helper) { + return helper; + } + + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var options = blockMeta.moduleName && { source: 'template:' + blockMeta.moduleName } || {}; + + if (true) { + var _ret = (function () { + var helperFactory = owner[_container.FACTORY_FOR]('helper:' + name, options) || owner[_container.FACTORY_FOR]('helper:' + name); + + // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations + if (helperFactory.class.isHelperInstance) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helperFactory.class.compute, args); + } + }; + } else if (helperFactory.class.isHelperFactory) { + if (!_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + helperFactory = helperFactory.create(); + } + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helperFactory, vm, args); + } + }; + } else { + throw new Error(nameParts + ' is not a helper'); + } + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + var _ret2 = (function () { + var helperFactory = owner.lookup('helper:' + name, options) || owner.lookup('helper:' + name); + + // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations + if (helperFactory.isHelperInstance) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helperFactory.compute, args); + } + }; + } else if (helperFactory.isHelperFactory) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helperFactory, vm, args); + } + }; + } else { + throw new Error(nameParts + ' is not a helper'); + } + })(); + + if (typeof _ret2 === 'object') return _ret2.v; + } + }; + + Environment.prototype.hasModifier = function hasModifier(nameParts) { + _emberMetal.assert('The first argument passed into `hasModifier` should be an array', Array.isArray(nameParts)); + + // modifiers are not allowed to include a dot in their invocation + if (nameParts.length > 1) { + return false; + } + + return !!this.builtInModifiers[nameParts[0]]; + }; + + Environment.prototype.lookupModifier = function lookupModifier(nameParts) { + _emberMetal.assert('The first argument passed into `lookupModifier` should be an array', Array.isArray(nameParts)); + + var modifier = this.builtInModifiers[nameParts[0]]; + + if (modifier) { + return modifier; + } else { + throw new Error(nameParts + ' is not a modifier'); + } + }; + + Environment.prototype.toConditionalReference = function toConditionalReference(reference) { + return _emberGlimmerUtilsReferences.ConditionalReference.create(reference); + }; + + Environment.prototype.iterableFor = function iterableFor(ref, args) { + var keyPath = args.named.get('key').value(); + return _emberGlimmerUtilsIterable.default(ref, keyPath); + }; + + Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier() { + if (this.isInteractive) { + var _GlimmerEnvironment$prototype$scheduleInstallModifier; + + (_GlimmerEnvironment$prototype$scheduleInstallModifier = _GlimmerEnvironment.prototype.scheduleInstallModifier).call.apply(_GlimmerEnvironment$prototype$scheduleInstallModifier, [this].concat(babelHelpers.slice.call(arguments))); + } + }; + + Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier() { + if (this.isInteractive) { + var _GlimmerEnvironment$prototype$scheduleUpdateModifier; + + (_GlimmerEnvironment$prototype$scheduleUpdateModifier = _GlimmerEnvironment.prototype.scheduleUpdateModifier).call.apply(_GlimmerEnvironment$prototype$scheduleUpdateModifier, [this].concat(babelHelpers.slice.call(arguments))); + } + }; + + Environment.prototype.didDestroy = function didDestroy(destroyable) { + destroyable.destroy(); + }; + + Environment.prototype.begin = function begin() { + this.inTransaction = true; + + _GlimmerEnvironment.prototype.begin.call(this); + + this.destroyedComponents = []; + }; + + Environment.prototype.commit = function commit() { + // components queued for destruction must be destroyed before firing + // `didCreate` to prevent errors when removing and adding a component + // with the same name (would throw an error when added to view registry) + for (var i = 0; i < this.destroyedComponents.length; i++) { + this.destroyedComponents[i].destroy(); + } + + _GlimmerEnvironment.prototype.commit.call(this); + + this.inTransaction = false; + }; + + return Environment; + })(_glimmerRuntime.Environment); + + exports.default = Environment; + + _emberMetal.runInDebug(function () { + var StyleAttributeManager = (function (_AttributeManager) { + babelHelpers.inherits(StyleAttributeManager, _AttributeManager); + + function StyleAttributeManager() { + babelHelpers.classCallCheck(this, StyleAttributeManager); + + _AttributeManager.apply(this, arguments); + } + + StyleAttributeManager.prototype.setAttribute = function setAttribute(dom, element, value) { + var _AttributeManager$prototype$setAttribute; + + _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { + if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { + return true; + } + return false; + })(), { id: 'ember-htmlbars.style-xss-warning' }); + (_AttributeManager$prototype$setAttribute = _AttributeManager.prototype.setAttribute).call.apply(_AttributeManager$prototype$setAttribute, [this].concat(babelHelpers.slice.call(arguments))); + }; + + StyleAttributeManager.prototype.updateAttribute = function updateAttribute(dom, element, value) { + var _AttributeManager$prototype$updateAttribute; + + _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { + if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { + return true; + } + return false; + })(), { id: 'ember-htmlbars.style-xss-warning' }); + (_AttributeManager$prototype$updateAttribute = _AttributeManager.prototype.updateAttribute).call.apply(_AttributeManager$prototype$updateAttribute, [this].concat(babelHelpers.slice.call(arguments))); + }; + + return StyleAttributeManager; + })(_glimmerRuntime.AttributeManager); + + var STYLE_ATTRIBUTE_MANANGER = new StyleAttributeManager('style'); + + Environment.prototype.attributeFor = function (element, attribute, isTrusting, namespace) { + if (attribute === 'style' && !isTrusting) { + return STYLE_ATTRIBUTE_MANANGER; + } + + return _glimmerRuntime.Environment.prototype.attributeFor.call(this, element, attribute, isTrusting); + }; + }); +}); +enifed('ember-glimmer/helper', ['exports', 'ember-utils', 'ember-runtime', '@glimmer/reference'], function (exports, _emberUtils, _emberRuntime, _glimmerReference) { /** @module ember @submodule ember-glimmer */ + 'use strict'; - exports.isMut = isMut; - exports.unMut = unMut; + exports.helper = helper; + var RECOMPUTE_TAG = _emberUtils.symbol('RECOMPUTE_TAG'); + exports.RECOMPUTE_TAG = RECOMPUTE_TAG; /** - The `mut` helper lets you __clearly specify__ that a child `Component` can update the - (mutable) value passed to it, which will __change the value of the parent component__. - - To specify that a parameter is mutable, when invoking the child `Component`: + Ember Helpers are functions that can compute values, and are used in templates. + For example, this code calls a helper named `format-currency`: ```handlebars - {{my-child childClickCount=(mut totalClicks)}} - ``` - - The child `Component` can then modify the parent's value just by modifying its own - property: - - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.incrementProperty('childClickCount'); - } - }); +
    {{format-currency cents currency="$"}}
    ``` - Note that for curly components (`{{my-component}}`) the bindings are already mutable, - making the `mut` unnecessary. - - Additionally, the `mut` helper can be combined with the `action` helper to - mutate a value. For example: + Additionally a helper can be called as a nested helper (sometimes called a + subexpression). In this example, the computed value of a helper is passed + to a component named `show-money`: ```handlebars - {{my-child childClickCount=totalClicks click-count-change=(action (mut totalClicks))}} + {{show-money amount=(format-currency cents currency="$")}} ``` - The child `Component` would invoke the action with the new click value: + Helpers defined using a class must provide a `compute` function. For example: - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.get('click-count-change')(this.get('childClickCount') + 1); + ```js + export default Ember.Helper.extend({ + compute(params, hash) { + let cents = params[0]; + let currency = hash.currency; + return `${currency}${cents * 0.01}`; } }); ``` - The `mut` helper changes the `totalClicks` value to what was provided as the action argument. - - The `mut` helper, when used with `action`, will return a function that - sets the value passed to `mut` to its first argument. This works like any other - closure action and interacts with the other features `action` provides. - As an example, we can create a button that increments a value passing the value - directly to the `action`: - - ```handlebars - {{! inc helper is not provided by Ember }} - - ``` + Each time the input to a helper changes, the `compute` function will be + called again. - You can also use the `value` option: + As instances, these helpers also have access to the container an will accept + injected dependencies. - ```handlebars - - ``` + Additionally, class helpers can call `recompute` to force a new computation. - @method mut - @param {Object} [attr] the "two-way" attribute that can be modified. - @for Ember.Templates.helpers + @class Ember.Helper @public + @since 1.13.0 */ - var MUT_REFERENCE = _emberUtils.symbol('MUT'); - var SOURCE = _emberUtils.symbol('SOURCE'); + var Helper = _emberRuntime.FrameworkObject.extend({ + isHelperInstance: true, - function isMut(ref) { - return ref && ref[MUT_REFERENCE]; - } + init: function () { + this._super.apply(this, arguments); + this[RECOMPUTE_TAG] = new _glimmerReference.DirtyableTag(); + }, - function unMut(ref) { - return ref[SOURCE] || ref; - } + /** + On a class-based helper, it may be useful to force a recomputation of that + helpers value. This is akin to `rerender` on a component. + For example, this component will rerender when the `currentUser` on a + session service changes: + ```js + // app/helpers/current-user-email.js + export default Ember.Helper.extend({ + session: Ember.inject.service(), + onNewUser: Ember.observer('session.currentUser', function() { + this.recompute(); + }), + compute() { + return this.get('session.currentUser.email'); + } + }); + ``` + @method recompute + @public + @since 1.13.0 + */ + recompute: function () { + this[RECOMPUTE_TAG].dirty(); + } - exports.default = function (vm, args) { - var rawRef = args.positional.at(0); + /** + Override this function when writing a class-based helper. + @method compute + @param {Array} params The positional arguments to the helper + @param {Object} hash The named arguments to the helper + @public + @since 1.13.0 + */ + }); - if (isMut(rawRef)) { - return rawRef; - } + Helper.reopenClass({ + isHelperFactory: true + }); - // TODO: Improve this error message. This covers at least two distinct - // cases: - // - // 1. (mut "not a path") – passing a literal, result from a helper - // invocation, etc - // - // 2. (mut receivedValue) – passing a value received from the caller - // that was originally derived from a literal, result from a helper - // invocation, etc - // - // This message is alright for the first case, but could be quite - // confusing for the second case. - _emberMetal.assert('You can only pass a path to mut', rawRef[_emberGlimmerUtilsReferences.UPDATE]); + /** + In many cases, the ceremony of a full `Ember.Helper` class is not required. + The `helper` method create pure-function helpers without instances. For + example: + + ```js + // app/helpers/format-currency.js + export default Ember.Helper.helper(function(params, hash) { + let cents = params[0]; + let currency = hash.currency; + return `${currency}${cents * 0.01}`; + }); + ``` + + @static + @param {Function} helper The helper function + @method helper + @public + @since 1.13.0 + */ - var wrappedRef = Object.create(rawRef); + function helper(helperFn) { + return { + isHelperInstance: true, + compute: helperFn + }; + } - wrappedRef[SOURCE] = rawRef; - wrappedRef[_emberGlimmerHelpersAction.INVOKE] = rawRef[_emberGlimmerUtilsReferences.UPDATE]; - wrappedRef[MUT_REFERENCE] = true; + exports.default = Helper; +}); +enifed('ember-glimmer/helpers/-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { + 'use strict'; - return wrappedRef; + function classHelper(_ref) { + var positional = _ref.positional; + + var path = positional.at(0); + var args = positional.length; + var value = path.value(); + + if (value === true) { + if (args > 1) { + return _emberRuntime.String.dasherize(positional.at(1).value()); + } + return null; + } + + if (value === false) { + if (args > 2) { + return _emberRuntime.String.dasherize(positional.at(2).value()); + } + return null; + } + + return value; + } + + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(classHelper, args); }; }); -enifed('ember-glimmer/helpers/query-param', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal, _emberRouting) { - /** - @module ember - @submodule ember-glimmer - */ +enifed('ember-glimmer/helpers/-html-safe', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/utils/string'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerUtilsString) { 'use strict'; - /** - This is a helper to be used in conjunction with the link-to helper. - It will supply url query parameters to the target route. - - Example - - ```handlebars - {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} - ``` - - @method query-params - @for Ember.Templates.helpers - @param {Object} hash takes a hash of query parameters - @return {Object} A `QueryParams` object for `{{link-to}}` - @public - */ - function queryParams(_ref) { + function htmlSafe(_ref) { + var positional = _ref.positional; + + var path = positional.at(0); + return new _emberGlimmerUtilsString.SafeString(path.value()); + } + + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(htmlSafe, args); + }; +}); +enifed('ember-glimmer/helpers/-input-type', ['exports', 'ember-glimmer/utils/references'], function (exports, _emberGlimmerUtilsReferences) { + 'use strict'; + + function inputTypeHelper(_ref) { var positional = _ref.positional; var named = _ref.named; - _emberMetal.assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', positional.value().length === 0); + var type = positional.at(0).value(); + if (type === 'checkbox') { + return '-checkbox'; + } + return '-text-field'; + } - return _emberRouting.QueryParams.create({ - values: _emberUtils.assign({}, named.value()) - }); + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(inputTypeHelper, args); + }; +}); +enifed('ember-glimmer/helpers/-normalize-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { + 'use strict'; + + function normalizeClass(_ref) { + var positional = _ref.positional; + var named = _ref.named; + + var classNameParts = positional.at(0).value().split('.'); + var className = classNameParts[classNameParts.length - 1]; + var value = positional.at(1).value(); + + if (value === true) { + return _emberRuntime.String.dasherize(className); + } else if (!value && value !== 0) { + return ''; + } else { + return String(value); + } } exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(queryParams, args); + return new _emberGlimmerUtilsReferences.InternalHelperReference(normalizeClass, args); }; }); -enifed('ember-glimmer/helpers/readonly', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/mut'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerHelpersMut) { +enifed('ember-glimmer/helpers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/runtime', '@glimmer/reference'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _glimmerRuntime, _glimmerReference) { /** @module ember @submodule ember-glimmer */ 'use strict'; + var INVOKE = _emberUtils.symbol('INVOKE'); + exports.INVOKE = INVOKE; + var ACTION = _emberUtils.symbol('ACTION'); + + exports.ACTION = ACTION; /** - The `readonly` helper let's you specify that a binding is one-way only, - instead of two-way. - When you pass a `readonly` binding from an outer context (e.g. parent component), - to to an inner context (e.g. child component), you are saying that changing that - property in the inner context does not change the value in the outer context. + The `{{action}}` helper provides a way to pass triggers for behavior (usually + just a function) between components, and into components from controllers. - To specify that a binding is read-only, when invoking the child `Component`: + ### Passing functions with the action helper - ```app/components/my-parent.js - export default Component.extend({ - totalClicks: 3 - }); - ``` + There are three contexts an action helper can be used in. The first two + contexts to discuss are attribute context, and Handlebars value context. - ```app/templates/components/my-parent.hbs - {{log totalClicks}} // -> 3 - {{my-child childClickCount=(readonly totalClicks)}} + ```handlebars + {{! An example of attribute context }} +
    + {{! Examples of Handlebars value context }} + {{input on-input=(action "save")}} + {{yield (action "refreshData") andAnotherParam}} ``` - Now, when you update `childClickCount`: - - ```app/components/my-child.js - export default Component.extend({ - click() { - this.incrementProperty('childClickCount'); - } - }); - ``` + In these contexts, + the helper is called a "closure action" helper. Its behavior is simple: + If passed a function name, read that function off the `actions` property + of the current context. Once that function is read (or if a function was + passed), create a closure over that function and any arguments. + The resulting value of an action helper used this way is simply a function. - The value updates in the child component, but not the parent component: + For example, in the attribute context: - ```app/templates/components/my-child.hbs - {{log childClickCount}} //-> 4 + ```handlebars + {{! An example of attribute context }} +
    ``` - ```app/templates/components/my-parent.hbs - {{log totalClicks}} //-> 3 - {{my-child childClickCount=(readonly totalClicks)}} - ``` + The resulting template render logic would be: - ### Objects and Arrays + ```js + var div = document.createElement('div'); + var actionFunction = (function(context){ + return function() { + return context.actions.save.apply(context, arguments); + }; + })(context); + div.onclick = actionFunction; + ``` - When passing a property that is a complex object (e.g. object, array) instead of a primitive object (e.g. number, string), - only the reference to the object is protected using the readonly helper. - This means that you can change properties of the object both on the parent component, as well as the child component. - The `readonly` binding behaves similar to the `const` keyword in JavaScript. + Thus when the div is clicked, the action on that context is called. + Because the `actionFunction` is just a function, closure actions can be + passed between components and still execute in the correct context. - Let's look at an example: + Here is an example action handler on a component: - First let's set up the parent component: + ```js + import Ember from 'ember'; - ```app/components/my-parent.js export default Ember.Component.extend({ - clicks: null, - - init() { - this._super(...arguments); - this.set('clicks', { total: 3 }); + actions: { + save() { + this.get('model').save(); + } } }); ``` - ```app/templates/components/my-parent.hbs - {{log clicks.total}} //-> 3 - {{my-child childClicks=(readonly clicks)}} - ``` + Actions are always looked up on the `actions` property of the current context. + This avoids collisions in the naming of common actions, such as `destroy`. + Two options can be passed to the `action` helper when it is used in this way. - Now, if you update the `total` property of `childClicks`: + * `target=someProperty` will look to `someProperty` instead of the current + context for the `actions` hash. This can be useful when targetting a + service for actions. + * `value="target.value"` will read the path `target.value` off the first + argument to the action when it is called and rewrite the first argument + to be that value. This is useful when attaching actions to event listeners. - ```app/components/my-child.js + ### Invoking an action + + Closure actions curry both their scope and any arguments. When invoked, any + additional arguments are added to the already curried list. + Actions should be invoked using the [sendAction](/api/classes/Ember.Component.html#method_sendAction) + method. The first argument to `sendAction` is the action to be called, and + additional arguments are passed to the action function. This has interesting + properties combined with currying of arguments. For example: + + ```js export default Ember.Component.extend({ - click() { - this.get('clicks').incrementProperty('total'); + actions: { + // Usage {{input on-input=(action (action 'setName' model) value="target.value")}} + setName(model, name) { + model.set('name', name); + } } }); ``` - You will see the following happen: - - ```app/templates/components/my-parent.hbs - {{log clicks.total}} //-> 4 - {{my-child childClicks=(readonly clicks)}} - ``` + The first argument (`model`) was curried over, and the run-time argument (`event`) + becomes a second argument. Action calls can be nested this way because each simply + returns a function. Any function can be passed to the `{{action}}` helper, including + other actions. - ```app/templates/components/my-child.hbs - {{log childClicks.total}} //-> 4 - ``` + Actions invoked with `sendAction` have the same currying behavior as demonstrated + with `on-input` above. For example: - @method readonly - @param {Object} [attr] the read-only attribute. - @for Ember.Templates.helpers - @private - */ - - exports.default = function (vm, args) { - var ref = _emberGlimmerHelpersMut.unMut(args.positional.at(0)); - - var wrapped = Object.create(ref); - - wrapped[_emberGlimmerUtilsReferences.UPDATE] = undefined; - - return wrapped; - }; -}); -enifed('ember-glimmer/helpers/unbound', ['exports', 'ember-metal', 'ember-glimmer/utils/references'], function (exports, _emberMetal, _emberGlimmerUtilsReferences) { - /** - @module ember - @submodule ember-glimmer - */ - - 'use strict'; - - /** - The `{{unbound}}` helper disconnects the one-way binding of a property, - essentially freezing its value at the moment of rendering. For example, - in this example the display of the variable `name` will not change even - if it is set with a new value: + ```app/components/my-input.js + import Ember from 'ember'; - ```handlebars - {{unbound name}} + export default Ember.Component.extend({ + actions: { + setName(model, name) { + model.set('name', name); + } + } + }); ``` - Like any helper, the `unbound` helper can accept a nested helper expression. - This allows for custom helpers to be rendered unbound: - ```handlebars - {{unbound (some-custom-helper)}} - {{unbound (capitalize name)}} - {{! You can use any helper, including unbound, in a nested expression }} - {{capitalize (unbound name)}} + {{my-input submit=(action 'setName' model)}} ``` - The `unbound` helper only accepts a single argument, and it return an - unbound value. - - @method unbound - @for Ember.Templates.helpers - @public - */ - - exports.default = function (vm, args) { - _emberMetal.assert('unbound helper cannot be called with multiple params or hash params', args.positional.values.length === 1 && args.named.keys.length === 0); - - return _emberGlimmerUtilsReferences.UnboundReference.create(args.positional.at(0).value()); - }; -}); -enifed('ember-glimmer/index', ['exports', 'ember-glimmer/helpers/action', 'ember-glimmer/templates/root', 'ember-glimmer/syntax', 'ember-glimmer/template', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/helper', 'ember-glimmer/environment', 'ember-glimmer/make-bound-helper', 'ember-glimmer/utils/string', 'ember-glimmer/renderer', 'ember-glimmer/template_registry', 'ember-glimmer/setup-registry', 'ember-glimmer/dom'], function (exports, _emberGlimmerHelpersAction, _emberGlimmerTemplatesRoot, _emberGlimmerSyntax, _emberGlimmerTemplate, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerHelper, _emberGlimmerEnvironment, _emberGlimmerMakeBoundHelper, _emberGlimmerUtilsString, _emberGlimmerRenderer, _emberGlimmerTemplate_registry, _emberGlimmerSetupRegistry, _emberGlimmerDom) { - /** - [Glimmer](https://github.com/tildeio/glimmer) is a [Handlebars](http://handlebarsjs.com/) - compatible templating engine used by Ember.js. - Any valid Handlebars syntax is valid in an Ember template. + ```app/components/my-component.js + import Ember from 'ember'; - ### Showing a property + export default Ember.Component.extend({ + click() { + // Note that model is not passed, it was curried in the template + this.sendAction('submit', 'bob'); + } + }); + ``` - Templates manage the flow of an application's UI, and display state (through - the DOM) to a user. For example, given a component with the property "name", - that component's template can use the name in several ways: + ### Attaching actions to DOM elements - ```javascript - // app/components/person.js - export default Ember.Component.extend({ - name: 'Jill' - }); - ``` + The third context of the `{{action}}` helper can be called "element space". + For example: ```handlebars - {{! app/components/person.hbs }} - {{name}} -
    {{name}}
    - + {{! An example of element space }} +
    ``` - Any time the "name" property on the component changes, the DOM will be - updated. - - Properties can be chained as well: + Used this way, the `{{action}}` helper provides a useful shortcut for + registering an HTML element in a template for a single DOM event and + forwarding that interaction to the template's context (controller or component). + If the context of a template is a controller, actions used this way will + bubble to routes when the controller does not implement the specified action. + Once an action hits a route, it will bubble through the route hierarchy. - ```handlebars - {{aUserModel.name}} -
    {{listOfUsers.firstObject.name}}
    - ``` + ### Event Propagation - ### Using Ember helpers + `{{action}}` helpers called in element space can control event bubbling. Note + that the closure style actions cannot. - When content is passed in mustaches `{{}}`, Ember will first try to find a helper - or component with that name. For example, the `if` helper: + Events triggered through the action helper will automatically have + `.preventDefault()` called on them. You do not need to do so in your event + handlers. If you need to allow event propagation (to handle file inputs for + example) you can supply the `preventDefault=false` option to the `{{action}}` helper: ```handlebars - {{if name "I have a name" "I have no name"}} - +
    + + +
    ``` - The returned value is placed where the `{{}}` is called. The above style is - called "inline". A second style of helper usage is called "block". For example: + To disable bubbling, pass `bubbles=false` to the helper: ```handlebars - {{#if name}} - I have a name - {{else}} - I have no name - {{/if}} + ``` - The block form of helpers allows you to control how the UI is created based - on the values of properties. - A third form of helper is called "nested". For example here the concat - helper will add " Doe" to a displayed name if the person has no last name: + To disable bubbling with closure style actions you must create your own + wrapper helper that makes use of `event.stopPropagation()`: ```handlebars - +
    Hello
    ``` - Ember's built-in helpers are described under the [Ember.Templates.helpers](/api/classes/Ember.Templates.helpers.html) - namespace. Documentation on creating custom helpers can be found under - [Ember.Helper](/api/classes/Ember.Helper.html). + ```app/helpers/disable-bubbling.js + import Ember from 'ember'; - ### Invoking a Component + export function disableBubbling([action]) { + return function(event) { + event.stopPropagation(); + return action(event); + }; + } + export default Ember.Helper.helper(disableBubbling); + ``` - Ember components represent state to the UI of an application. Further - reading on components can be found under [Ember.Component](/api/classes/Ember.Component.html). + If you need the default handler to trigger you should either register your + own event handler, or use event methods on your view class. See + ["Responding to Browser Events"](/api/classes/Ember.View.html#toc_responding-to-browser-events) + in the documentation for Ember.View for more information. - @module ember - @submodule ember-glimmer - @main ember-glimmer - @public - */ - - /** - Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful - for semantic clarity as it allows you to retain default scope or to reference a property from another - `{{with}}` block. + ### Specifying DOM event type - If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0`, NaN or - an empty array, the block will not be rendered. + `{{action}}` helpers called in element space can specify an event type. + By default the `{{action}}` helper registers for DOM `click` events. You can + supply an `on` option to the helper to specify a different DOM event name: ```handlebars - {{! Will only render if user.posts contains items}} - {{#with user.posts as |blogPosts|}} -
    - There are {{blogPosts.length}} blog posts written by {{user.name}}. -
    - {{#each blogPosts as |post|}} -
  • {{post.title}}
  • - {{/each}} - {{/with}} +
    + click me +
    ``` - Without the `as` operator, it would be impossible to reference `user.name` in the example above. - - NOTE: The alias should not reuse a name from the bound property path. + See ["Event Names"](/api/classes/Ember.View.html#toc_event-names) for a list of + acceptable DOM event names. - For example: `{{#with foo.bar as |foo|}}` is not supported because it attempts to alias using - the first part of the property path, `foo`. Instead, use `{{#with foo.bar as |baz|}}`. + ### Specifying whitelisted modifier keys - @method with - @for Ember.Templates.helpers - @param {Object} options - @return {String} HTML string - @public - */ - - /** - Execute the `debugger` statement in the current template's context. + `{{action}}` helpers called in element space can specify modifier keys. + By default the `{{action}}` helper will ignore click events with pressed modifier + keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. ```handlebars - {{debugger}} +
    + click me +
    ``` - When using the debugger helper you will have access to a `get` function. This - function retrieves values available in the context of the template. - For example, if you're wondering why a value `{{foo}}` isn't rendering as - expected within a template, you could place a `{{debugger}}` statement and, - when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: + This way the action will fire when clicking with the alt key pressed down. + Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. - ``` - > get('foo') + ```handlebars +
    + click me with any key pressed +
    ``` - `get` is also aware of keywords. So in this situation + ### Specifying a Target - ```handlebars - {{#each items as |item|}} - {{debugger}} - {{/each}} - ``` - - You'll be able to get values from the current item: + A `target` option can be provided to the helper to change + which object will receive the method call. This option must be a path + to an object, accessible in the current context: - ``` - > get('item.name') + ```app/templates/application.hbs +
    + click me +
    ``` - You can also access the context of the view to make sure it is the object that - you expect: + ```app/controllers/application.js + import Ember from 'ember'; - ``` - > context + export default Ember.Controller.extend({ + someService: Ember.inject.service() + }); ``` - @method debugger + @method action @for Ember.Templates.helpers @public - */ + */ + + exports.default = function (vm, args) { + var named = args.named; + var positional = args.positional; + + // The first two argument slots are reserved. + // pos[0] is the context (or `this`) + // pos[1] is the action name or function + // Anything else is an action argument. + var context = positional.at(0); + var action = positional.at(1); + + // TODO: Is there a better way of doing this? + var debugKey = action._propertyKey; + + var restArgs = undefined; + + if (positional.length === 2) { + restArgs = _glimmerRuntime.EvaluatedPositionalArgs.empty(); + } else { + restArgs = _glimmerRuntime.EvaluatedPositionalArgs.create(positional.values.slice(2)); + } + + var target = named.has('target') ? named.get('target') : context; + var processArgs = makeArgsProcessor(named.has('value') && named.get('value'), restArgs); + + var fn = undefined; + + if (typeof action[INVOKE] === 'function') { + fn = makeClosureAction(action, action, action[INVOKE], processArgs, debugKey); + } else if (_glimmerReference.isConst(target) && _glimmerReference.isConst(action)) { + fn = makeClosureAction(context.value(), target.value(), action.value(), processArgs, debugKey); + } else { + fn = makeDynamicClosureAction(context.value(), target, action, processArgs, debugKey); + } + + fn[ACTION] = true; + + return new _emberGlimmerUtilsReferences.UnboundReference(fn); + }; + + function NOOP(args) { + return args; + } + + function makeArgsProcessor(valuePathRef, actionArgsRef) { + var mergeArgs = null; + + if (actionArgsRef.length > 0) { + mergeArgs = function (args) { + return actionArgsRef.value().concat(args); + }; + } + + var readValue = null; + + if (valuePathRef) { + readValue = function (args) { + var valuePath = valuePathRef.value(); + + if (valuePath && args.length > 0) { + args[0] = _emberMetal.get(args[0], valuePath); + } + + return args; + }; + } + + if (mergeArgs && readValue) { + return function (args) { + return readValue(mergeArgs(args)); + }; + } else { + return mergeArgs || readValue || NOOP; + } + } + + function makeDynamicClosureAction(context, targetRef, actionRef, processArgs, debugKey) { + // We don't allow undefined/null values, so this creates a throw-away action to trigger the assertions + _emberMetal.runInDebug(function () { + makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey); + }); + + return function () { + return makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey).apply(undefined, arguments); + }; + } + + function makeClosureAction(context, target, action, processArgs, debugKey) { + var self = undefined, + fn = undefined; + + _emberMetal.assert('Action passed is null or undefined in (action) from ' + target + '.', !_emberMetal.isNone(action)); + + if (typeof action[INVOKE] === 'function') { + self = action; + fn = action[INVOKE]; + } else { + var typeofAction = typeof action; + + if (typeofAction === 'string') { + self = target; + fn = target.actions && target.actions[action]; + + _emberMetal.assert('An action named \'' + action + '\' was not found in ' + target, fn); + } else if (typeofAction === 'function') { + self = context; + fn = action; + } else { + _emberMetal.assert('An action could not be made for `' + (debugKey || action) + '` in ' + target + '. Please confirm that you are using either a quoted action name (i.e. `(action \'' + (debugKey || 'myAction') + '\')`) or a function available in ' + target + '.', false); + } + } + + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + var payload = { target: self, args: args, label: '@glimmer/closure-action' }; + return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + return _emberMetal.run.join.apply(_emberMetal.run, [self, fn].concat(processArgs(args))); + }); + }; + } +}); +enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/curly-component', '@glimmer/runtime', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxCurlyComponent, _glimmerRuntime, _emberMetal) { /** - The `partial` helper renders another template without - changing the template context: + @module ember + @submodule ember-glimmer + */ + 'use strict'; + + /** + The `{{component}}` helper lets you add instances of `Ember.Component` to a + template. See [Ember.Component](/api/classes/Ember.Component.html) for + additional information on how a `Component` functions. + `{{component}}`'s primary use is for cases where you want to dynamically + change which type of component is rendered as the state of your application + changes. This helper has three modes: inline, block, and nested. - ```handlebars - {{foo}} - {{partial "nav"}} + ### Inline Form + + Given the following template: + + ```app/application.hbs + {{component infographicComponentName}} ``` - The above example template will render a template named - "-nav", which has the same context as the parent template - it's rendered into, so if the "-nav" template also referenced - `{{foo}}`, it would print the same thing as the `{{foo}}` - in the above example. + And the following application code: - If a "-nav" template isn't found, the `partial` helper will - fall back to a template named "nav". + ```app/controllers/application.js + export default Ember.Controller.extend({ + infographicComponentName: computed('isMarketOpen', { + get() { + if (this.get('isMarketOpen')) { + return 'live-updating-chart'; + } else { + return 'market-close-summary'; + } + } + }) + }); + ``` - ### Bound template names + The `live-updating-chart` component will be appended when `isMarketOpen` is + `true`, and the `market-close-summary` component will be appended when + `isMarketOpen` is `false`. If the value changes while the app is running, + the component will be automatically swapped out accordingly. + Note: You should not use this helper when you are consistently rendering the same + component. In that case, use standard component syntax, for example: - The parameter supplied to `partial` can also be a path - to a property containing a template name, e.g.: + ```app/templates/application.hbs + {{live-updating-chart}} + ``` - ```handlebars - {{partial someTemplateName}} + ### Block Form + + Using the block form of this helper is similar to using the block form + of a component. Given the following application template: + + ```app/templates/application.hbs + {{#component infographicComponentName}} + Last update: {{lastUpdateTimestamp}} + {{/component}} ``` - The above example will look up the value of `someTemplateName` - on the template context (e.g. a controller) and use that - value as the name of the template to render. If the resolved - value is falsy, nothing will be rendered. If `someTemplateName` - changes, the partial will be re-rendered using the new template - name. + The following controller code: - @method partial - @for Ember.Templates.helpers - @param {String} partialName The name of the template to render minus the leading underscore. - @public - */ - - 'use strict'; - - exports.INVOKE = _emberGlimmerHelpersAction.INVOKE; - exports.RootTemplate = _emberGlimmerTemplatesRoot.default; - exports.registerSyntax = _emberGlimmerSyntax.registerSyntax; - exports.template = _emberGlimmerTemplate.default; - exports.Checkbox = _emberGlimmerComponentsCheckbox.default; - exports.TextField = _emberGlimmerComponentsText_field.default; - exports.TextArea = _emberGlimmerComponentsText_area.default; - exports.LinkComponent = _emberGlimmerComponentsLinkTo.default; - exports.Component = _emberGlimmerComponent.default; - exports.Helper = _emberGlimmerHelper.default; - exports.helper = _emberGlimmerHelper.helper; - exports.Environment = _emberGlimmerEnvironment.default; - exports.makeBoundHelper = _emberGlimmerMakeBoundHelper.default; - exports.SafeString = _emberGlimmerUtilsString.SafeString; - exports.escapeExpression = _emberGlimmerUtilsString.escapeExpression; - exports.htmlSafe = _emberGlimmerUtilsString.htmlSafe; - exports.isHTMLSafe = _emberGlimmerUtilsString.isHTMLSafe; - exports._getSafeString = _emberGlimmerUtilsString.getSafeString; - exports.Renderer = _emberGlimmerRenderer.Renderer; - exports.InertRenderer = _emberGlimmerRenderer.InertRenderer; - exports.InteractiveRenderer = _emberGlimmerRenderer.InteractiveRenderer; - exports.getTemplate = _emberGlimmerTemplate_registry.getTemplate; - exports.setTemplate = _emberGlimmerTemplate_registry.setTemplate; - exports.hasTemplate = _emberGlimmerTemplate_registry.hasTemplate; - exports.getTemplates = _emberGlimmerTemplate_registry.getTemplates; - exports.setTemplates = _emberGlimmerTemplate_registry.setTemplates; - exports.setupEngineRegistry = _emberGlimmerSetupRegistry.setupEngineRegistry; - exports.setupApplicationRegistry = _emberGlimmerSetupRegistry.setupApplicationRegistry; - exports.DOMChanges = _emberGlimmerDom.DOMChanges; - exports.NodeDOMTreeConstruction = _emberGlimmerDom.NodeDOMTreeConstruction; - exports.DOMTreeConstruction = _emberGlimmerDom.DOMTreeConstruction; -}); -enifed('ember-glimmer/make-bound-helper', ['exports', 'ember-metal', 'ember-glimmer/helper'], function (exports, _emberMetal, _emberGlimmerHelper) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - exports.default = makeBoundHelper; - - /** - Create a bound helper. Accepts a function that receives the ordered and hash parameters - from the template. If a bound property was provided in the template, it will be resolved to its - value and any changes to the bound property cause the helper function to be re-run with the updated - values. + ```app/controllers/application.js + export default Ember.Controller.extend({ + lastUpdateTimestamp: computed(function() { + return new Date(); + }), - * `params` - An array of resolved ordered parameters. - * `hash` - An object containing the hash parameters. + infographicComponentName: computed('isMarketOpen', { + get() { + if (this.get('isMarketOpen')) { + return 'live-updating-chart'; + } else { + return 'market-close-summary'; + } + } + }) + }); + ``` - For example: + And the following component template: - * With an unquoted ordered parameter: + ```app/templates/components/live-updating-chart.hbs + {{! chart }} + {{yield}} + ``` - ```javascript - {{x-capitalize foo}} - ``` + The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. - Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and - an empty hash as its second. + ### Nested Usage - * With a quoted ordered parameter: + The `component` helper can be used to package a component path with initial attrs. + The included attrs can then be merged during the final invocation. + For example, given a `person-form` component with the following template: - ```javascript - {{x-capitalize "foo"}} - ``` + ```app/templates/components/person-form.hbs + {{yield (hash + nameInput=(component "my-input-component" value=model.name placeholder="First Name") + )}} + ``` - The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. + When yielding the component via the `hash` helper, the component is invocked directly. + See the following snippet: - * With an unquoted hash parameter: + ``` + {{#person-form as |form|}} + {{form.nameInput placeholder="Username"}} + {{/person-form}} + ``` - ```javascript - {{x-repeat "foo" count=repeatCount}} - ``` + Which outputs an input whose value is already bound to `model.name` and `placeholder` + is "Username". - Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, - and { count: 2 } as its second. + When yielding the component without the hash helper use the `component` helper. + For example, below is a `full-name` component template: - @private - @method makeBoundHelper - @for Ember.HTMLBars - @param {Function} fn - @since 1.10.0 + ```handlebars + {{yield (component "my-input-component" value=model.name placeholder="Name")}} + ``` + + ``` + {{#full-name as |field|}} + {{component field placeholder="Full name"}} + {{/full-name}} + ``` + + @method component + @since 1.11.0 + @for Ember.Templates.helpers + @public */ - function makeBoundHelper(fn) { - _emberMetal.deprecate('Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.', false, { id: 'ember-htmlbars.make-bound-helper', until: '3.0.0' }); - return _emberGlimmerHelper.helper(fn); - } -}); -enifed('ember-glimmer/modifiers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _emberGlimmerHelpersAction) { - 'use strict'; - - var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; - var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; + var ClosureComponentReference = (function (_CachedReference) { + babelHelpers.inherits(ClosureComponentReference, _CachedReference); - function isAllowedEvent(event, allowedKeys) { - if (allowedKeys === null || typeof allowedKeys === 'undefined') { - if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { - return _emberViews.isSimpleClick(event); - } else { - allowedKeys = ''; - } - } + ClosureComponentReference.create = function create(args, symbolTable, env) { + return new ClosureComponentReference(args, symbolTable, env); + }; - if (allowedKeys.indexOf('any') >= 0) { - return true; - } + function ClosureComponentReference(args, symbolTable, env) { + babelHelpers.classCallCheck(this, ClosureComponentReference); - for (var i = 0; i < MODIFIERS.length; i++) { - if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { - return false; - } + _CachedReference.call(this); + this.defRef = args.positional.at(0); + this.env = env; + this.tag = args.positional.at(0).tag; + this.symbolTable = symbolTable; + this.args = args; + this.lastDefinition = undefined; + this.lastName = undefined; } - return true; - } + ClosureComponentReference.prototype.compute = function compute() { + // TODO: Figure out how to extract this because it's nearly identical to + // DynamicComponentReference::compute(). The only differences besides + // currying are in the assertion messages. + var args = this.args; + var defRef = this.defRef; + var env = this.env; + var symbolTable = this.symbolTable; + var lastDefinition = this.lastDefinition; + var lastName = this.lastName; - var ActionHelper = { - // registeredActions is re-exported for compatibility with older plugins - // that were using this undocumented API. - registeredActions: _emberViews.ActionManager.registeredActions, + var nameOrDef = defRef.value(); + var definition = null; - registerAction: function (actionState) { - var actionId = actionState.actionId; + if (nameOrDef && nameOrDef === lastName) { + return lastDefinition; + } - var actions = _emberViews.ActionManager.registeredActions[actionId]; + this.lastName = nameOrDef; - if (!actions) { - actions = _emberViews.ActionManager.registeredActions[actionId] = []; + if (typeof nameOrDef === 'string') { + _emberMetal.assert('You cannot use the input helper as a contextual helper. Please extend Ember.TextField or Ember.Checkbox to use it as a contextual component.', nameOrDef !== 'input'); + _emberMetal.assert('You cannot use the textarea helper as a contextual helper. Please extend Ember.TextArea to use it as a contextual component.', nameOrDef !== 'textarea'); + definition = env.getComponentDefinition([nameOrDef], symbolTable); + _emberMetal.assert('The component helper cannot be used without a valid component name. You used "' + nameOrDef + '" via (component "' + nameOrDef + '")', definition); + } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { + definition = nameOrDef; + } else { + _emberMetal.assert('You cannot create a component from ' + nameOrDef + ' using the {{component}} helper', nameOrDef); + return null; } - actions.push(actionState); + var newDef = createCurriedDefinition(definition, args); - return actionId; - }, + this.lastDefinition = newDef; - unregisterAction: function (actionState) { - var actionId = actionState.actionId; + return newDef; + }; - var actions = _emberViews.ActionManager.registeredActions[actionId]; + return ClosureComponentReference; + })(_emberGlimmerUtilsReferences.CachedReference); - if (!actions) { - return; - } + exports.ClosureComponentReference = ClosureComponentReference; - var index = actions.indexOf(actionState); + function createCurriedDefinition(definition, args) { + var curriedArgs = curryArgs(definition, args); - if (index !== -1) { - actions.splice(index, 1); - } + return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(definition.name, definition.ComponentClass, definition.template, curriedArgs); + } - if (actions.length === 0) { - delete _emberViews.ActionManager.registeredActions[actionId]; - } - } + var EMPTY_BLOCKS = { + default: null, + inverse: null }; - exports.ActionHelper = ActionHelper; + _emberMetal.runInDebug(function () { + EMPTY_BLOCKS = Object.freeze(EMPTY_BLOCKS); + }); - var ActionState = (function () { - function ActionState(element, actionId, actionName, actionArgs, namedArgs, positionalArgs, implicitTarget, dom) { - babelHelpers.classCallCheck(this, ActionState); + function curryArgs(definition, newArgs) { + var args = definition.args; + var ComponentClass = definition.ComponentClass; - this.element = element; - this.actionId = actionId; - this.actionName = actionName; - this.actionArgs = actionArgs; - this.namedArgs = namedArgs; - this.positional = positionalArgs; - this.implicitTarget = implicitTarget; - this.dom = dom; - this.eventName = this.getEventName(); - } + var positionalParams = ComponentClass.class.positionalParams; - // implements ModifierManager + // The args being passed in are from the (component ...) invocation, + // so the first positional argument is actually the name or component + // definition. It needs to be dropped in order for any actual positional + // args to coincide with the ComponentClass's positionParams. - ActionState.prototype.getEventName = function getEventName() { - return this.namedArgs.get('on').value() || 'click'; - }; + // For "normal" curly components this slicing is done at the syntax layer, + // but we don't have that luxury here. - ActionState.prototype.getActionArgs = function getActionArgs() { - var result = new Array(this.actionArgs.length); + var _newArgs$positional$values = newArgs.positional.values; - for (var i = 0; i < this.actionArgs.length; i++) { - result[i] = this.actionArgs[i].value(); - } + var slicedPositionalArgs = _newArgs$positional$values.slice(1); - return result; - }; + if (positionalParams && slicedPositionalArgs.length) { + _emberGlimmerSyntaxCurlyComponent.validatePositionalParameters(newArgs.named, slicedPositionalArgs, positionalParams); + } - ActionState.prototype.getTarget = function getTarget() { - var implicitTarget = this.implicitTarget; - var namedArgs = this.namedArgs; + var isRest = typeof positionalParams === 'string'; - var target = undefined; + // For non-rest position params, we need to perform the position -> name mapping + // at each layer to avoid a collision later when the args are used to construct + // the component instance (inside of processArgs(), inside of create()). + var positionalToNamedParams = {}; - if (namedArgs.has('target')) { - target = namedArgs.get('target').value(); - } else { - target = implicitTarget.value(); + if (!isRest && positionalParams && positionalParams.length > 0) { + var limit = Math.min(positionalParams.length, slicedPositionalArgs.length); + + for (var i = 0; i < limit; i++) { + var _name = positionalParams[i]; + positionalToNamedParams[_name] = slicedPositionalArgs[i]; } - return target; - }; + slicedPositionalArgs.length = 0; // Throw them away since you're merged in. + } - ActionState.prototype.handler = function handler(event) { - var _this = this; + // args (aka 'oldArgs') may be undefined or simply be empty args, so + // we need to fall back to an empty array or object. + var oldNamed = args && args.named && args.named.map || {}; + var oldPositional = args && args.positional && args.positional.values || []; - var actionName = this.actionName; - var namedArgs = this.namedArgs; + // Merge positional arrays + var mergedPositional = new Array(Math.max(oldPositional.length, slicedPositionalArgs.length)); + mergedPositional.splice.apply(mergedPositional, [0, oldPositional.length].concat(oldPositional)); + mergedPositional.splice.apply(mergedPositional, [0, slicedPositionalArgs.length].concat(slicedPositionalArgs)); - var bubbles = namedArgs.get('bubbles'); - var preventDefault = namedArgs.get('preventDefault'); - var allowedKeys = namedArgs.get('allowedKeys'); - var target = this.getTarget(); + // Merge named maps + var mergedNamed = _emberUtils.assign({}, oldNamed, positionalToNamedParams, newArgs.named.map); - if (!isAllowedEvent(event, allowedKeys.value())) { - return true; - } + var mergedArgs = _glimmerRuntime.EvaluatedArgs.create(_glimmerRuntime.EvaluatedPositionalArgs.create(mergedPositional), _glimmerRuntime.EvaluatedNamedArgs.create(mergedNamed), EMPTY_BLOCKS); - if (preventDefault.value() !== false) { - event.preventDefault(); - } + return mergedArgs; + } - if (bubbles.value() === false) { - event.stopPropagation(); - } + exports.default = function (vm, args, symbolTable) { + return ClosureComponentReference.create(args, symbolTable, vm.env); + }; +}); +enifed('ember-glimmer/helpers/concat', ['exports', 'ember-glimmer/utils/references', '@glimmer/runtime'], function (exports, _emberGlimmerUtilsReferences, _glimmerRuntime) { + 'use strict'; - _emberMetal.run(function () { - var args = _this.getActionArgs(); - var payload = { - args: args, - target: target - }; - if (typeof actionName[_emberGlimmerHelpersAction.INVOKE] === 'function') { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - actionName[_emberGlimmerHelpersAction.INVOKE].apply(actionName, args); - }); - return; - } - if (typeof actionName === 'function') { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - actionName.apply(target, args); - }); - return; - } - payload.name = actionName; - if (target.send) { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - target.send.apply(target, [actionName].concat(args)); - }); - } else { - _emberMetal.assert('The action \'' + actionName + '\' did not exist on ' + target, typeof target[actionName] === 'function'); - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - target[actionName].apply(target, args); - }); - } - }); - }; + /** + @module ember + @submodule ember-glimmer + */ - ActionState.prototype.destroy = function destroy() { - ActionHelper.unregisterAction(this); - }; + /** + Concatenates the given arguments into a string. + + Example: + + ```handlebars + {{some-component name=(concat firstName " " lastName)}} + + {{! would pass name=" " to the component}} + ``` + + @public + @method concat + @for Ember.Templates.helpers + @since 1.13.0 + */ + function concat(_ref) { + var positional = _ref.positional; - return ActionState; - })(); + return positional.value().map(_glimmerRuntime.normalizeTextValue).join(''); + } - exports.ActionState = ActionState; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(concat, args); + }; +}); +enifed('ember-glimmer/helpers/each-in', ['exports', 'ember-utils'], function (exports, _emberUtils) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var ActionModifierManager = (function () { - function ActionModifierManager() { - babelHelpers.classCallCheck(this, ActionModifierManager); - } + exports.isEachIn = isEachIn; - ActionModifierManager.prototype.create = function create(element, args, dynamicScope, dom) { - var named = args.named; - var positional = args.positional; + /** + The `{{#each}}` helper loops over elements in a collection. It is an extension + of the base Handlebars `{{#each}}` helper. + The default behavior of `{{#each}}` is to yield its inner block once for every + item in an array passing the item as the first block parameter. + + ```javascript + var developers = [{ name: 'Yehuda' },{ name: 'Tom' }, { name: 'Paul' }]; + ``` + + ```handlebars + {{#each developers key="name" as |person|}} + {{person.name}} + {{! `this` is whatever it was outside the #each }} + {{/each}} + ``` + + The same rules apply to arrays of primitives. + + ```javascript + var developerNames = ['Yehuda', 'Tom', 'Paul'] + ``` + + ```handlebars + {{#each developerNames key="@index" as |name|}} + {{name}} + {{/each}} + ``` + + During iteration, the index of each item in the array is provided as a second block parameter. + + ```handlebars +
      + {{#each people as |person index|}} +
    • Hello, {{person.name}}! You're number {{index}} in line
    • + {{/each}} +
    + ``` + + ### Specifying Keys + + The `key` option is used to tell Ember how to determine if the array being + iterated over with `{{#each}}` has changed between renders. By helping Ember + detect that some elements in the array are the same, DOM elements can be + re-used, significantly improving rendering speed. + + For example, here's the `{{#each}}` helper with its `key` set to `id`: + + ```handlebars + {{#each model key="id" as |item|}} + {{/each}} + ``` + + When this `{{#each}}` re-renders, Ember will match up the previously rendered + items (and reorder the generated DOM elements) based on each item's `id` + property. + By default the item's own reference is used. + + ### {{else}} condition + + `{{#each}}` can have a matching `{{else}}`. The contents of this block will render + if the collection is empty. + + ```handlebars + {{#each developers as |person|}} + {{person.name}} + {{else}} +

    Sorry, nobody is available for this task.

    + {{/each}} + ``` + + @method each + @for Ember.Templates.helpers + @public + */ - var implicitTarget = undefined; - var actionName = undefined; - var actionNameRef = undefined; - if (positional.length > 1) { - implicitTarget = positional.at(0); - actionNameRef = positional.at(1); + /** + The `{{each-in}}` helper loops over properties on an object. + + For example, given a `user` object that looks like: + + ```javascript + { + "name": "Shelly Sails", + "age": 42 + } + ``` + + This template would display all properties on the `user` + object in a list: + + ```handlebars +
      + {{#each-in user as |key value|}} +
    • {{key}}: {{value}}
    • + {{/each-in}} +
    + ``` + + Outputting their name and age. + + @method each-in + @for Ember.Templates.helpers + @public + @since 2.1.0 + */ + var EACH_IN_REFERENCE = _emberUtils.symbol('EACH_IN'); - if (actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { - actionName = actionNameRef; - } else { - var actionLabel = actionNameRef._propertyKey; - actionName = actionNameRef.value(); + function isEachIn(ref) { + return ref && ref[EACH_IN_REFERENCE]; + } - _emberMetal.assert('You specified a quoteless path, `' + actionLabel + '`, to the ' + '{{action}} helper which did not resolve to an action name (a ' + 'string). Perhaps you meant to use a quoted actionName? (e.g. ' + '{{action "' + actionLabel + '"}}).', typeof actionName === 'string' || typeof actionName === 'function'); - } - } + exports.default = function (vm, args) { + var ref = Object.create(args.positional.at(0)); + ref[EACH_IN_REFERENCE] = true; + return ref; + }; +}); +enifed('ember-glimmer/helpers/get', ['exports', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { + 'use strict'; - var actionArgs = []; - // The first two arguments are (1) `this` and (2) the action name. - // Everything else is a param. - for (var i = 2; i < positional.length; i++) { - actionArgs.push(positional.at(i)); - } + /** + @module ember + @submodule ember-glimmer + */ - var actionId = _emberUtils.uuid(); - return new ActionState(element, actionId, actionName, actionArgs, named, positional, implicitTarget, dom); - }; + /** + Dynamically look up a property on an object. The second argument to `{{get}}` + should have a string value, although it can be bound. + + For example, these two usages are equivilent: + + ```handlebars + {{person.height}} + {{get person "height"}} + ``` + + If there were several facts about a person, the `{{get}}` helper can dynamically + pick one: + + ```handlebars + {{get person factName}} + ``` + + For a more complex example, this template would allow the user to switch + between showing the user's height and weight with a click: + + ```handlebars + {{get person factName}} + + + ``` + + The `{{get}}` helper can also respect mutable values itself. For example: + + ```handlebars + {{input value=(mut (get person factName)) type="text"}} + + + ``` + + Would allow the user to swap what fact is being displayed, and also edit + that fact via a two-way mutable binding. + + @public + @method get + @for Ember.Templates.helpers + @since 2.1.0 + */ - ActionModifierManager.prototype.install = function install(actionState) { - var dom = actionState.dom; - var element = actionState.element; - var actionId = actionState.actionId; + exports.default = function (vm, args) { + return GetHelperReference.create(args.positional.at(0), args.positional.at(1)); + }; - ActionHelper.registerAction(actionState); + var GetHelperReference = (function (_CachedReference) { + babelHelpers.inherits(GetHelperReference, _CachedReference); - dom.setAttribute(element, 'data-ember-action', ''); - dom.setAttribute(element, 'data-ember-action-' + actionId, actionId); + GetHelperReference.create = function create(sourceReference, pathReference) { + if (_glimmerReference.isConst(pathReference)) { + var parts = pathReference.value().split('.'); + return _glimmerReference.referenceFromParts(sourceReference, parts); + } else { + return new GetHelperReference(sourceReference, pathReference); + } }; - ActionModifierManager.prototype.update = function update(actionState) { - var positional = actionState.positional; + function GetHelperReference(sourceReference, pathReference) { + babelHelpers.classCallCheck(this, GetHelperReference); - var actionNameRef = positional.at(1); + _CachedReference.call(this); + this.sourceReference = sourceReference; + this.pathReference = pathReference; - if (!actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { - actionState.actionName = actionNameRef.value(); - } - actionState.eventName = actionState.getEventName(); + this.lastPath = null; + this.innerReference = null; - // Not sure if this is needed? If we mutate the actionState is that good enough? - ActionHelper.unregisterAction(actionState); - ActionHelper.registerAction(actionState); - }; + var innerTag = this.innerTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - ActionModifierManager.prototype.getDestructor = function getDestructor(modifier) { - return modifier; - }; + this.tag = _glimmerReference.combine([sourceReference.tag, pathReference.tag, innerTag]); + } - return ActionModifierManager; - })(); + GetHelperReference.prototype.compute = function compute() { + var lastPath = this.lastPath; + var innerReference = this.innerReference; + var innerTag = this.innerTag; - exports.default = ActionModifierManager; -}); -enifed('ember-glimmer/protocol-for-url', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - /* globals module, URL */ + var path = this.lastPath = this.pathReference.value(); - 'use strict'; + if (path !== lastPath) { + if (path) { + var pathType = typeof path; - exports.default = installProtocolForURL; + if (pathType === 'string') { + innerReference = this.innerReference = _glimmerReference.referenceFromParts(this.sourceReference, path.split('.')); + } else if (pathType === 'number') { + innerReference = this.innerReference = this.sourceReference.get(path); + } - var nodeURL = undefined; - var parsingNode = undefined; + innerTag.update(innerReference.tag); + } else { + innerReference = this.innerReference = null; + innerTag.update(_glimmerReference.CONSTANT_TAG); + } + } - function installProtocolForURL(environment) { - var protocol = undefined; + return innerReference ? innerReference.value() : null; + }; - if (_emberEnvironment.environment.hasDOM) { - protocol = browserProtocolForURL.call(environment, 'foobar:baz'); - } + GetHelperReference.prototype[_emberGlimmerUtilsReferences.UPDATE] = function (value) { + _emberMetal.set(this.sourceReference.value(), this.pathReference.value(), value); + }; - // Test to see if our DOM implementation parses - // and normalizes URLs. - if (protocol === 'foobar:') { - // Swap in the method that doesn't do this test now that - // we know it works. - environment.protocolForURL = browserProtocolForURL; - } else if (typeof URL === 'object') { - // URL globally provided, likely from FastBoot's sandbox - nodeURL = URL; - environment.protocolForURL = nodeProtocolForURL; - } else if (typeof module === 'object' && typeof module.require === 'function') { - // Otherwise, we need to fall back to our own URL parsing. - // Global `require` is shadowed by Ember's loader so we have to use the fully - // qualified `module.require`. - nodeURL = module.require('url'); - environment.protocolForURL = nodeProtocolForURL; - } else { - throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); - } - } + return GetHelperReference; + })(_emberGlimmerUtilsReferences.CachedReference); +}); +enifed("ember-glimmer/helpers/hash", ["exports"], function (exports) { + /** + @module ember + @submodule ember-glimmer + */ - function browserProtocolForURL(url) { - if (!parsingNode) { - parsingNode = document.createElement('a'); - } + /** + Use the `{{hash}}` helper to create a hash to pass as an option to your + components. This is specially useful for contextual components where you can + just yield a hash: + + ```handlebars + {{yield (hash + name='Sarah' + title=office + )}} + ``` + + Would result in an object such as: + + ```js + { name: 'Sarah', title: this.get('office') } + ``` + + Where the `title` is bound to updates of the `office` property. + + @method hash + @for Ember.Templates.helpers + @param {Object} options + @return {Object} Hash + @since 2.3.0 + @public + */ - parsingNode.href = url; - return parsingNode.protocol; - } + "use strict"; - function nodeProtocolForURL(url) { - var protocol = null; - if (typeof url === 'string') { - protocol = nodeURL.parse(url).protocol; - } - return protocol === null ? ':' : protocol; - } + exports.default = function (vm, args) { + return args.named; + }; }); -enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', 'ember-metal', 'glimmer-reference', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/outlet'], function (exports, _emberGlimmerUtilsReferences, _emberMetal, _glimmerReference, _emberViews, _emberGlimmerComponent, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxOutlet) { - 'use strict'; +enifed('ember-glimmer/helpers/if-unless', ['exports', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { + /** + @module ember + @submodule ember-glimmer + */ - var runInTransaction = undefined; + 'use strict'; - if (true || false) { - runInTransaction = _emberMetal.runInTransaction; - } else { - runInTransaction = function (context, methodName) { - context[methodName](); - return false; - }; - } + exports.inlineIf = inlineIf; + exports.inlineUnless = inlineUnless; - var backburner = _emberMetal.run.backburner; + /** + Use the `if` block helper to conditionally render a block depending on a + property. If the property is "falsey", for example: `false`, `undefined`, + `null`, `""`, `0`, `NaN` or an empty array, the block will not be rendered. + + ```handlebars + {{! will not render if foo is falsey}} + {{#if foo}} + Welcome to the {{foo.bar}} + {{/if}} + ``` + + You can also specify a template to show if the property is falsey by using + the `else` helper. + + ```handlebars + {{! is it raining outside?}} + {{#if isRaining}} + Yes, grab an umbrella! + {{else}} + No, it's lovely outside! + {{/if}} + ``` + + You are also able to combine `else` and `if` helpers to create more complex + conditional logic. + + ```handlebars + {{#if isMorning}} + Good morning + {{else if isAfternoon}} + Good afternoon + {{else}} + Good night + {{/if}} + ``` + + You can use `if` inline to conditionally render a single property or string. + This helper acts like a ternary operator. If the first property is truthy, + the second argument will be displayed, if not, the third argument will be + displayed + + ```handlebars + {{if useLongGreeting "Hello" "Hi"}} Dave + ``` + + Finally, you can use the `if` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(if isBig "100" "10")}} + ``` + + @method if + @for Ember.Templates.helpers + @public + */ - var DynamicScope = (function () { - function DynamicScope(view, outletState, rootOutletState, targetObject) { - babelHelpers.classCallCheck(this, DynamicScope); + var ConditionalHelperReference = (function (_CachedReference) { + babelHelpers.inherits(ConditionalHelperReference, _CachedReference); - this.view = view; - this.outletState = outletState; - this.rootOutletState = rootOutletState; - } + ConditionalHelperReference.create = function create(_condRef, _truthyRef, _falsyRef) { + var condRef = _emberGlimmerUtilsReferences.ConditionalReference.create(_condRef); + var truthyRef = _truthyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; + var falsyRef = _falsyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; - DynamicScope.prototype.child = function child() { - return new DynamicScope(this.view, this.outletState, this.rootOutletState); + if (_glimmerReference.isConst(condRef)) { + return condRef.value() ? truthyRef : falsyRef; + } else { + return new ConditionalHelperReference(condRef, truthyRef, falsyRef); + } }; - DynamicScope.prototype.get = function get(key) { - _emberMetal.assert('Using `-get-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); - return this.outletState; - }; + function ConditionalHelperReference(cond, truthy, falsy) { + babelHelpers.classCallCheck(this, ConditionalHelperReference); - DynamicScope.prototype.set = function set(key, value) { - _emberMetal.assert('Using `-with-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); - this.outletState = value; - return value; - }; + _CachedReference.call(this); - return DynamicScope; - })(); + this.branchTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + this.tag = _glimmerReference.combine([cond.tag, this.branchTag]); - var RootState = (function () { - function RootState(root, env, template, self, parentElement, dynamicScope) { - var _this = this; + this.cond = cond; + this.truthy = truthy; + this.falsy = falsy; + } - babelHelpers.classCallCheck(this, RootState); - - _emberMetal.assert('You cannot render `' + self.value() + '` without a template.', template); - - this.id = _emberViews.getViewId(root); - this.env = env; - this.root = root; - this.result = undefined; - this.shouldReflush = false; - this.destroyed = false; - this._removing = false; - - var options = this.options = { - alwaysRevalidate: false - }; - - this.render = function () { - var result = _this.result = template.render(self, parentElement, dynamicScope); - - // override .render function after initial render - _this.render = function () { - result.rerender(options); - }; - }; - } - - RootState.prototype.isFor = function isFor(possibleRoot) { - return this.root === possibleRoot; - }; - - RootState.prototype.destroy = function destroy() { - var result = this.result; - var env = this.env; - - this.destroyed = true; - - this.env = null; - this.root = null; - this.result = null; - this.render = null; + /** + The inline `if` helper conditionally renders a single property or string. + This helper acts like a ternary operator. If the first property is truthy, + the second argument will be displayed, otherwise, the third argument will be + displayed + + ```handlebars + {{if useLongGreeting "Hello" "Hi"}} Alex + ``` + + You can use the `if` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(if isBig "100" "10")}} + ``` + + @method if + @for Ember.Templates.helpers + @public + */ - if (result) { - /* - Handles these scenarios: - * When roots are removed during standard rendering process, a transaction exists already - `.begin()` / `.commit()` are not needed. - * When roots are being destroyed manually (`component.append(); component.destroy() case), no - transaction exists already. - * When roots are being destroyed during `Renderer#destroy`, no transaction exists - */ - var needsTransaction = !env.inTransaction; + ConditionalHelperReference.prototype.compute = function compute() { + var cond = this.cond; + var truthy = this.truthy; + var falsy = this.falsy; - if (needsTransaction) { - env.begin(); - } + var branch = cond.value() ? truthy : falsy; - result.destroy(); + this.branchTag.update(branch.tag); - if (needsTransaction) { - env.commit(); - } - } + return branch.value(); }; - return RootState; - })(); - - var renderers = []; - - _emberMetal.setHasViews(function () { - return renderers.length > 0; - }); - - function register(renderer) { - _emberMetal.assert('Cannot register the same renderer twice', renderers.indexOf(renderer) === -1); - renderers.push(renderer); - } - - function deregister(renderer) { - var index = renderers.indexOf(renderer); - _emberMetal.assert('Cannot deregister unknown unregistered renderer', index !== -1); - renderers.splice(index, 1); - } - - function loopBegin() { - for (var i = 0; i < renderers.length; i++) { - renderers[i]._scheduleRevalidate(); - } - } + return ConditionalHelperReference; + })(_emberGlimmerUtilsReferences.CachedReference); - function K() {} + function inlineIf(vm, _ref) { + var positional = _ref.positional; - var loops = 0; - function loopEnd(current, next) { - for (var i = 0; i < renderers.length; i++) { - if (!renderers[i]._isValid()) { - if (loops > 10) { - loops = 0; - // TODO: do something better - renderers[i].destroy(); - throw new Error('infinite rendering invalidation detected'); - } - loops++; - return backburner.join(null, K); - } + switch (positional.length) { + case 2: + return ConditionalHelperReference.create(positional.at(0), positional.at(1), null); + case 3: + return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); + default: + _emberMetal.assert('The inline form of the `if` helper expects two or three arguments, e.g. ' + '`{{if trialExpired "Expired" expiryDate}}`.'); } - loops = 0; } - backburner.on('begin', loopBegin); - backburner.on('end', loopEnd); - - var Renderer = (function () { - function Renderer(env, rootTemplate) { - var _viewRegistry = arguments.length <= 2 || arguments[2] === undefined ? _emberViews.fallbackViewRegistry : arguments[2]; + /** + The inline `unless` helper conditionally renders a single property or string. + This helper acts like a ternary operator. If the first property is falsy, + the second argument will be displayed, otherwise, the third argument will be + displayed + + ```handlebars + {{unless useLongGreeting "Hi" "Hello"}} Ben + ``` + + You can use the `unless` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(unless isBig "10" "100")}} + ``` + + @method unless + @for Ember.Templates.helpers + @public + */ - var destinedForDOM = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; - babelHelpers.classCallCheck(this, Renderer); + function inlineUnless(vm, _ref2) { + var positional = _ref2.positional; - this._env = env; - this._rootTemplate = rootTemplate; - this._viewRegistry = _viewRegistry; - this._destinedForDOM = destinedForDOM; - this._destroyed = false; - this._roots = []; - this._lastRevision = null; - this._isRenderingRoots = false; - this._removedRoots = []; + switch (positional.length) { + case 2: + return ConditionalHelperReference.create(positional.at(0), null, positional.at(1)); + case 3: + return ConditionalHelperReference.create(positional.at(0), positional.at(2), positional.at(1)); + default: + _emberMetal.assert('The inline form of the `unless` helper expects two or three arguments, e.g. ' + '`{{unless isFirstLogin "Welcome back!"}}`.'); } + } +}); +enifed('ember-glimmer/helpers/loc', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - // renderer HOOKS - - Renderer.prototype.appendOutletView = function appendOutletView(view, target) { - var definition = new _emberGlimmerSyntaxOutlet.TopLevelOutletComponentDefinition(view); - var outletStateReference = view.toReference(); - var targetObject = view.outletState.render.controller; - - this._appendDefinition(view, definition, target, outletStateReference, targetObject); - }; - - Renderer.prototype.appendTo = function appendTo(view, target) { - var rootDef = new _emberGlimmerSyntaxCurlyComponent.RootComponentDefinition(view); - - this._appendDefinition(view, rootDef, target); - }; - - Renderer.prototype._appendDefinition = function _appendDefinition(root, definition, target) { - var outletStateReference = arguments.length <= 3 || arguments[3] === undefined ? _glimmerReference.UNDEFINED_REFERENCE : arguments[3]; - var targetObject = arguments.length <= 4 || arguments[4] === undefined ? null : arguments[4]; - - var self = new _emberGlimmerUtilsReferences.RootReference(definition); - var dynamicScope = new DynamicScope(null, outletStateReference, outletStateReference, true, targetObject); - var rootState = new RootState(root, this._env, this._rootTemplate, self, target, dynamicScope); - - this._renderRoot(rootState); - }; - - Renderer.prototype.rerender = function rerender(view) { - this._scheduleRevalidate(); - }; - - Renderer.prototype.register = function register(view) { - var id = _emberViews.getViewId(view); - _emberMetal.assert('Attempted to register a view with an id already in use: ' + id, !this._viewRegistry[id]); - this._viewRegistry[id] = view; - }; - - Renderer.prototype.unregister = function unregister(view) { - delete this._viewRegistry[_emberViews.getViewId(view)]; + /** + Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the + provided string. This is a convenient way to localize text within a template. + For example: + + ```javascript + Ember.STRINGS = { + '_welcome_': 'Bonjour' }; + ``` + + ```handlebars +
    + {{loc '_welcome_'}} +
    + ``` + + ```html +
    + Bonjour +
    + ``` + + See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to + set up localized string references. + + @method loc + @for Ember.Templates.helpers + @param {String} str The string to format. + @see {Ember.String#loc} + @public + */ + function locHelper(_ref) { + var positional = _ref.positional; - Renderer.prototype.remove = function remove(view) { - view._transitionTo('destroying'); + return _emberRuntime.String.loc.apply(null, positional.value()); + } - this.cleanupRootFor(view); + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(locHelper, args); + }; +}); +enifed('ember-glimmer/helpers/log', ['exports', 'ember-glimmer/utils/references', 'ember-console'], function (exports, _emberGlimmerUtilsReferences, _emberConsole) { + 'use strict'; - _emberViews.setViewElement(view, null); + /** + `log` allows you to output the value of variables in the current rendering + context. `log` also accepts primitive types such as strings or numbers. + + ```handlebars + {{log "myVariable:" myVariable }} + ``` + + @method log + @for Ember.Templates.helpers + @param {Array} params + @public + */ + function log(_ref) { + var positional = _ref.positional; - if (this._destinedForDOM) { - view.trigger('didDestroyElement'); - } + _emberConsole.default.log.apply(null, positional.value()); + } - if (!view.isDestroying) { - view.destroy(); - } - }; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(log, args); + }; +}); - Renderer.prototype.cleanupRootFor = function cleanupRootFor(view) { - // no need to cleanup roots if we have already been destroyed - if (this._destroyed) { - return; - } +/** +@module ember +@submodule ember-glimmer +*/ +enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerHelpersAction) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var roots = this._roots; + exports.isMut = isMut; + exports.unMut = unMut; - // traverse in reverse so we can remove items - // without mucking up the index - var i = this._roots.length; - while (i--) { - var root = roots[i]; - if (root.isFor(view)) { - root.destroy(); - } + /** + The `mut` helper lets you __clearly specify__ that a child `Component` can update the + (mutable) value passed to it, which will __change the value of the parent component__. + + To specify that a parameter is mutable, when invoking the child `Component`: + + ```handlebars + {{my-child childClickCount=(mut totalClicks)}} + ``` + + The child `Component` can then modify the parent's value just by modifying its own + property: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.incrementProperty('childClickCount'); } - }; - - Renderer.prototype.destroy = function destroy() { - if (this._destroyed) { - return; + }); + ``` + + Note that for curly components (`{{my-component}}`) the bindings are already mutable, + making the `mut` unnecessary. + + Additionally, the `mut` helper can be combined with the `action` helper to + mutate a value. For example: + + ```handlebars + {{my-child childClickCount=totalClicks click-count-change=(action (mut totalClicks))}} + ``` + + The child `Component` would invoke the action with the new click value: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.get('click-count-change')(this.get('childClickCount') + 1); } - this._destroyed = true; - this._clearAllRoots(); - }; - - Renderer.prototype.getElement = function getElement(view) { - // overriden in the subclasses - }; - - Renderer.prototype.getBounds = function getBounds(view) { - var bounds = view[_emberGlimmerComponent.BOUNDS]; + }); + ``` + + The `mut` helper changes the `totalClicks` value to what was provided as the action argument. + + The `mut` helper, when used with `action`, will return a function that + sets the value passed to `mut` to its first argument. This works like any other + closure action and interacts with the other features `action` provides. + As an example, we can create a button that increments a value passing the value + directly to the `action`: + + ```handlebars + {{! inc helper is not provided by Ember }} + + ``` + + You can also use the `value` option: + + ```handlebars + + ``` + + @method mut + @param {Object} [attr] the "two-way" attribute that can be modified. + @for Ember.Templates.helpers + @public + */ + var MUT_REFERENCE = _emberUtils.symbol('MUT'); + var SOURCE = _emberUtils.symbol('SOURCE'); - var parentElement = bounds.parentElement(); - var firstNode = bounds.firstNode(); - var lastNode = bounds.lastNode(); + function isMut(ref) { + return ref && ref[MUT_REFERENCE]; + } - return { parentElement: parentElement, firstNode: firstNode, lastNode: lastNode }; - }; + function unMut(ref) { + return ref[SOURCE] || ref; + } - Renderer.prototype.createElement = function createElement(tagName) { - return this._env.getAppendOperations().createElement(tagName); - }; + exports.default = function (vm, args) { + var rawRef = args.positional.at(0); - Renderer.prototype._renderRoot = function _renderRoot(root) { - var roots = this._roots; + if (isMut(rawRef)) { + return rawRef; + } - roots.push(root); + // TODO: Improve this error message. This covers at least two distinct + // cases: + // + // 1. (mut "not a path") – passing a literal, result from a helper + // invocation, etc + // + // 2. (mut receivedValue) – passing a value received from the caller + // that was originally derived from a literal, result from a helper + // invocation, etc + // + // This message is alright for the first case, but could be quite + // confusing for the second case. + _emberMetal.assert('You can only pass a path to mut', rawRef[_emberGlimmerUtilsReferences.UPDATE]); - if (roots.length === 1) { - register(this); - } + var wrappedRef = Object.create(rawRef); - this._renderRootsTransaction(); - }; + wrappedRef[SOURCE] = rawRef; + wrappedRef[_emberGlimmerHelpersAction.INVOKE] = rawRef[_emberGlimmerUtilsReferences.UPDATE]; + wrappedRef[MUT_REFERENCE] = true; - Renderer.prototype._renderRoots = function _renderRoots() { - var roots = this._roots; - var env = this._env; - var removedRoots = this._removedRoots; + return wrappedRef; + }; +}); +enifed('ember-glimmer/helpers/query-param', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal, _emberRouting) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var globalShouldReflush = undefined, - initialRootsLength = undefined; + /** + This is a helper to be used in conjunction with the link-to helper. + It will supply url query parameters to the target route. + + Example + + ```handlebars + {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} + ``` + + @method query-params + @for Ember.Templates.helpers + @param {Object} hash takes a hash of query parameters + @return {Object} A `QueryParams` object for `{{link-to}}` + @public + */ + function queryParams(_ref) { + var positional = _ref.positional; + var named = _ref.named; - do { - env.begin(); + _emberMetal.assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', positional.value().length === 0); - // ensure that for the first iteration of the loop - // each root is processed - initialRootsLength = roots.length; - globalShouldReflush = false; + return _emberRouting.QueryParams.create({ + values: _emberUtils.assign({}, named.value()) + }); + } - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(queryParams, args); + }; +}); +enifed('ember-glimmer/helpers/readonly', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/mut'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerHelpersMut) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - if (root.destroyed) { - // add to the list of roots to be removed - // they will be removed from `this._roots` later - removedRoots.push(root); - - // skip over roots that have been marked as destroyed - continue; - } - - var shouldReflush = root.shouldReflush; - - // when processing non-initial reflush loops, - // do not process more roots than needed - if (i >= initialRootsLength && !shouldReflush) { - continue; - } - - root.options.alwaysRevalidate = shouldReflush; - // track shouldReflush based on this roots render result - shouldReflush = root.shouldReflush = runInTransaction(root, 'render'); - - // globalShouldReflush should be `true` if *any* of - // the roots need to reflush - globalShouldReflush = globalShouldReflush || shouldReflush; - } - - this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - - env.commit(); - } while (globalShouldReflush || roots.length > initialRootsLength); - - // remove any roots that were destroyed during this transaction - while (removedRoots.length) { - var root = removedRoots.pop(); - - var rootIndex = roots.indexOf(root); - roots.splice(rootIndex, 1); - } - - if (this._roots.length === 0) { - deregister(this); - } - }; - - Renderer.prototype._renderRootsTransaction = function _renderRootsTransaction() { - if (this._isRenderingRoots) { - // currently rendering roots, a new root was added and will - // be processed by the existing _renderRoots invocation - return; - } - - // used to prevent calling _renderRoots again (see above) - // while we are actively rendering roots - this._isRenderingRoots = true; - - var completedWithoutError = false; - try { - this._renderRoots(); - completedWithoutError = true; - } finally { - if (!completedWithoutError) { - this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - } - this._isRenderingRoots = false; - } - }; - - Renderer.prototype._clearAllRoots = function _clearAllRoots() { - var roots = this._roots; - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; - root.destroy(); - } - - this._removedRoots.length = 0; - this._roots = null; - - // if roots were present before destroying - // deregister this renderer instance - if (roots.length) { - deregister(this); - } - }; - - Renderer.prototype._scheduleRevalidate = function _scheduleRevalidate() { - backburner.scheduleOnce('render', this, this._revalidate); - }; - - Renderer.prototype._isValid = function _isValid() { - return this._destroyed || this._roots.length === 0 || _glimmerReference.CURRENT_TAG.validate(this._lastRevision); - }; - - Renderer.prototype._revalidate = function _revalidate() { - if (this._isValid()) { - return; - } - this._renderRootsTransaction(); - }; - - return Renderer; - })(); - - var InertRenderer = (function (_Renderer) { - babelHelpers.inherits(InertRenderer, _Renderer); - - function InertRenderer() { - babelHelpers.classCallCheck(this, InertRenderer); - - _Renderer.apply(this, arguments); - } - - InertRenderer.create = function create(_ref) { - var env = _ref.env; - var rootTemplate = _ref.rootTemplate; - var _viewRegistry = _ref._viewRegistry; - - return new this(env, rootTemplate, _viewRegistry, false); - }; - - InertRenderer.prototype.getElement = function getElement(view) { - throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); - }; - - return InertRenderer; - })(Renderer); - - exports.InertRenderer = InertRenderer; - - var InteractiveRenderer = (function (_Renderer2) { - babelHelpers.inherits(InteractiveRenderer, _Renderer2); - - function InteractiveRenderer() { - babelHelpers.classCallCheck(this, InteractiveRenderer); - - _Renderer2.apply(this, arguments); - } - - InteractiveRenderer.create = function create(_ref2) { - var env = _ref2.env; - var rootTemplate = _ref2.rootTemplate; - var _viewRegistry = _ref2._viewRegistry; - - return new this(env, rootTemplate, _viewRegistry, true); - }; - - InteractiveRenderer.prototype.getElement = function getElement(view) { - return _emberViews.getViewElement(view); - }; - - return InteractiveRenderer; - })(Renderer); - - exports.InteractiveRenderer = InteractiveRenderer; -}); -enifed('ember-glimmer/setup-registry', ['exports', 'ember-environment', 'container', 'ember-glimmer/renderer', 'ember-glimmer/dom', 'ember-glimmer/views/outlet', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/templates/component', 'ember-glimmer/templates/root', 'ember-glimmer/templates/outlet', 'ember-glimmer/environment'], function (exports, _emberEnvironment, _container, _emberGlimmerRenderer, _emberGlimmerDom, _emberGlimmerViewsOutlet, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerTemplatesComponent, _emberGlimmerTemplatesRoot, _emberGlimmerTemplatesOutlet, _emberGlimmerEnvironment) { - 'use strict'; - - exports.setupApplicationRegistry = setupApplicationRegistry; - exports.setupEngineRegistry = setupEngineRegistry; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:-root'], ['template:-root']), - _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']), - _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - - function setupApplicationRegistry(registry) { - registry.injection('service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); - registry.injection('renderer', 'env', 'service:-glimmer-environment'); - - registry.register(_container.privatize(_templateObject), _emberGlimmerTemplatesRoot.default); - registry.injection('renderer', 'rootTemplate', _container.privatize(_templateObject)); - - registry.register('renderer:-dom', _emberGlimmerRenderer.InteractiveRenderer); - registry.register('renderer:-inert', _emberGlimmerRenderer.InertRenderer); - - if (_emberEnvironment.environment.hasDOM) { - registry.injection('service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); - } - - registry.register('service:-dom-changes', { - create: function (_ref) { - var document = _ref.document; - return new _emberGlimmerDom.DOMChanges(document); - } - }); - - registry.register('service:-dom-tree-construction', { - create: function (_ref2) { - var document = _ref2.document; - - var Implementation = _emberEnvironment.environment.hasDOM ? _emberGlimmerDom.DOMTreeConstruction : _emberGlimmerDom.NodeDOMTreeConstruction; - return new Implementation(document); - } - }); - } - - function setupEngineRegistry(registry) { - registry.register('view:-outlet', _emberGlimmerViewsOutlet.default); - registry.register('template:-outlet', _emberGlimmerTemplatesOutlet.default); - registry.injection('view:-outlet', 'template', 'template:-outlet'); - - registry.injection('service:-dom-changes', 'document', 'service:-document'); - registry.injection('service:-dom-tree-construction', 'document', 'service:-document'); - - registry.register(_container.privatize(_templateObject2), _emberGlimmerTemplatesComponent.default); - - registry.register('service:-glimmer-environment', _emberGlimmerEnvironment.default); - registry.injection('template', 'env', 'service:-glimmer-environment'); - - registry.optionsForType('helper', { instantiate: false }); - - registry.register('component:-text-field', _emberGlimmerComponentsText_field.default); - registry.register('component:-text-area', _emberGlimmerComponentsText_area.default); - registry.register('component:-checkbox', _emberGlimmerComponentsCheckbox.default); - registry.register('component:link-to', _emberGlimmerComponentsLinkTo.default); - registry.register(_container.privatize(_templateObject3), _emberGlimmerComponent.default); - } -}); -enifed('ember-glimmer/syntax', ['exports', 'ember-glimmer/syntax/render', 'ember-glimmer/syntax/outlet', 'ember-glimmer/syntax/mount', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/syntax/input', 'glimmer-runtime'], function (exports, _emberGlimmerSyntaxRender, _emberGlimmerSyntaxOutlet, _emberGlimmerSyntaxMount, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerSyntaxInput, _glimmerRuntime) { - 'use strict'; - - exports.registerSyntax = registerSyntax; - exports.findSyntaxBuilder = findSyntaxBuilder; - - var syntaxKeys = []; - var syntaxes = []; - - function registerSyntax(key, syntax) { - syntaxKeys.push(key); - syntaxes.push(syntax); - } - - function findSyntaxBuilder(key) { - var index = syntaxKeys.indexOf(key); - - if (index > -1) { - return syntaxes[index]; - } - } - - registerSyntax('render', _emberGlimmerSyntaxRender.RenderSyntax); - registerSyntax('outlet', _emberGlimmerSyntaxOutlet.OutletSyntax); - registerSyntax('mount', _emberGlimmerSyntaxMount.MountSyntax); - registerSyntax('component', _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax); - registerSyntax('input', _emberGlimmerSyntaxInput.InputSyntax); - - registerSyntax('-with-dynamic-vars', (function () { - function _class() { - babelHelpers.classCallCheck(this, _class); - } - - _class.create = function create(environment, args, symbolTable) { - return new _glimmerRuntime.WithDynamicVarsSyntax(args); - }; - - return _class; - })()); - - registerSyntax('-in-element', (function () { - function _class2() { - babelHelpers.classCallCheck(this, _class2); - } - - _class2.create = function create(environment, args, symbolTable) { - return new _glimmerRuntime.InElementSyntax(args); - }; - - return _class2; - })()); -}); -enifed('ember-glimmer/syntax/curly-component', ['exports', 'ember-utils', 'glimmer-runtime', 'ember-glimmer/utils/bindings', 'ember-glimmer/component', 'ember-metal', 'ember-views', 'ember-glimmer/utils/process-args', 'container'], function (exports, _emberUtils, _glimmerRuntime, _emberGlimmerUtilsBindings, _emberGlimmerComponent, _emberMetal, _emberViews, _emberGlimmerUtilsProcessArgs, _container) { - 'use strict'; - - exports.validatePositionalParameters = validatePositionalParameters; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); - - var DEFAULT_LAYOUT = _container.privatize(_templateObject); - - function processComponentInitializationAssertions(component, props) { - _emberMetal.assert('classNameBindings must not have spaces in them: ' + component.toString(), (function () { - var classNameBindings = component.classNameBindings; - - for (var i = 0; i < classNameBindings.length; i++) { - var binding = classNameBindings[i]; - if (binding.split(' ').length > 1) { - return false; - } - } - return true; - })()); - - _emberMetal.assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), (function () { - var classNameBindings = component.classNameBindings; - var tagName = component.tagName; - - return tagName !== '' || !classNameBindings || classNameBindings.length === 0; - })()); - - _emberMetal.assert('You cannot use `elementId` on a tag-less component: ' + component.toString(), (function () { - var elementId = component.elementId; - var tagName = component.tagName; - - return tagName !== '' || props.id === elementId || !elementId && elementId !== ''; - })()); - - _emberMetal.assert('You cannot use `attributeBindings` on a tag-less component: ' + component.toString(), (function () { - var attributeBindings = component.attributeBindings; - var tagName = component.tagName; - - return tagName !== '' || !attributeBindings || attributeBindings.length === 0; - })()); - } - - function validatePositionalParameters(named, positional, positionalParamsDefinition) { - _emberMetal.runInDebug(function () { - if (!named || !positional || !positional.length) { - return; - } - - var paramType = typeof positionalParamsDefinition; - - if (paramType === 'string') { - _emberMetal.assert('You cannot specify positional parameters and the hash argument `' + positionalParamsDefinition + '`.', !named.has(positionalParamsDefinition)); - } else { - if (positional.length < positionalParamsDefinition.length) { - positionalParamsDefinition = positionalParamsDefinition.slice(0, positional.length); - } - - for (var i = 0; i < positionalParamsDefinition.length; i++) { - var _name = positionalParamsDefinition[i]; - - _emberMetal.assert('You cannot specify both a positional param (at position ' + i + ') and the hash argument `' + _name + '`.', !named.has(_name)); - } - } - }); - } - - function aliasIdToElementId(args, props) { - if (args.named.has('id')) { - _emberMetal.assert('You cannot invoke a component with both \'id\' and \'elementId\' at the same time.', !args.named.has('elementId')); - props.elementId = props.id; - } - } - - // We must traverse the attributeBindings in reverse keeping track of - // what has already been applied. This is essentially refining the concated - // properties applying right to left. - function applyAttributeBindings(element, attributeBindings, component, operations) { - var seen = []; - var i = attributeBindings.length - 1; - - while (i !== -1) { - var binding = attributeBindings[i]; - var parsed = _emberGlimmerUtilsBindings.AttributeBinding.parse(binding); - var attribute = parsed[1]; - - if (seen.indexOf(attribute) === -1) { - seen.push(attribute); - _emberGlimmerUtilsBindings.AttributeBinding.install(element, component, parsed, operations); - } - - i--; - } - - if (seen.indexOf('id') === -1) { - operations.addStaticAttribute(element, 'id', component.elementId); - } - - if (seen.indexOf('style') === -1) { - _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); - } - } - - var CurlyComponentSyntax = (function (_StatementSyntax) { -babelHelpers.inherits(CurlyComponentSyntax, _StatementSyntax); - - function CurlyComponentSyntax(args, definition, symbolTable) { -babelHelpers.classCallCheck(this, CurlyComponentSyntax); - - _StatementSyntax.call(this); - this.args = args; - this.definition = definition; - this.symbolTable = symbolTable; - this.shadow = null; - } - - CurlyComponentSyntax.prototype.compile = function compile(builder) { - builder.component.static(this.definition, this.args, this.symbolTable, this.shadow); - }; - - return CurlyComponentSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.CurlyComponentSyntax = CurlyComponentSyntax; - - function NOOP() {} - - var ComponentStateBucket = (function () { - function ComponentStateBucket(environment, component, args, finalizer) { -babelHelpers.classCallCheck(this, ComponentStateBucket); - - this.environment = environment; - this.component = component; - this.classRef = null; - this.args = args; - this.argsRevision = args.tag.value(); - this.finalizer = finalizer; - } - - ComponentStateBucket.prototype.destroy = function destroy() { - var component = this.component; - var environment = this.environment; - - if (environment.isInteractive) { - component.trigger('willDestroyElement'); - component.trigger('willClearRender'); - } - - environment.destroyedComponents.push(component); - }; - - ComponentStateBucket.prototype.finalize = function finalize() { - var finalizer = this.finalizer; - - finalizer(); - this.finalizer = NOOP; - }; - - return ComponentStateBucket; - })(); - - function initialRenderInstrumentDetails(component) { - return component.instrumentDetails({ initialRender: true }); - } - - function rerenderInstrumentDetails(component) { - return component.instrumentDetails({ initialRender: false }); - } - - var CurlyComponentManager = (function () { - function CurlyComponentManager() { -babelHelpers.classCallCheck(this, CurlyComponentManager); - } - - CurlyComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { - validatePositionalParameters(args.named, args.positional.values, definition.ComponentClass.positionalParams); - - return _emberGlimmerUtilsProcessArgs.gatherArgs(args, definition); - }; - - CurlyComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, callerSelfRef, hasBlock) { - var parentView = dynamicScope.view; - - var klass = definition.ComponentClass; - var processedArgs = _emberGlimmerUtilsProcessArgs.ComponentArgs.create(args); - - var _processedArgs$value = processedArgs.value(); - - var props = _processedArgs$value.props; - - aliasIdToElementId(args, props); - - props.parentView = parentView; - props[_emberGlimmerComponent.HAS_BLOCK] = hasBlock; - - props._targetObject = callerSelfRef.value(); - - var component = klass.create(props); - - var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - - dynamicScope.view = component; - - if (parentView !== null) { - parentView.appendChild(component); - } - - // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components - if (component.tagName === '') { - if (environment.isInteractive) { - component.trigger('willRender'); - } - - component._transitionTo('hasElement'); - - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } - } - - var bucket = new ComponentStateBucket(environment, component, processedArgs, finalizer); - - if (args.named.has('class')) { - bucket.classRef = args.named.get('class'); - } - - processComponentInitializationAssertions(component, props); - - if (environment.isInteractive && component.tagName !== '') { - component.trigger('willRender'); - } - - return bucket; - }; - - CurlyComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - var template = definition.template; - if (!template) { - var component = bucket.component; - - template = this.templateFor(component, env); - } - return env.getCompiledBlock(CurlyComponentLayoutCompiler, template); - }; - - CurlyComponentManager.prototype.templateFor = function templateFor(component, env) { - var Template = _emberMetal.get(component, 'layout'); - var owner = component[_emberUtils.OWNER]; - if (Template) { - return env.getTemplate(Template, owner); - } - var layoutName = _emberMetal.get(component, 'layoutName'); - if (layoutName) { - var template = owner.lookup('template:' + layoutName); - if (template) { - return template; - } - } - return owner.lookup(DEFAULT_LAYOUT); - }; - - CurlyComponentManager.prototype.getSelf = function getSelf(_ref) { - var component = _ref.component; - - return component[_emberGlimmerComponent.ROOT_REF]; - }; - - CurlyComponentManager.prototype.didCreateElement = function didCreateElement(_ref2, element, operations) { - var component = _ref2.component; - var classRef = _ref2.classRef; - var environment = _ref2.environment; - - _emberViews.setViewElement(component, element); - - var attributeBindings = component.attributeBindings; - var classNames = component.classNames; - var classNameBindings = component.classNameBindings; - - if (attributeBindings && attributeBindings.length) { - applyAttributeBindings(element, attributeBindings, component, operations); - } else { - operations.addStaticAttribute(element, 'id', component.elementId); - _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); - } - - if (classRef) { - operations.addDynamicAttribute(element, 'class', classRef); - } - - if (classNames && classNames.length) { - classNames.forEach(function (name) { - operations.addStaticAttribute(element, 'class', name); - }); - } - - if (classNameBindings && classNameBindings.length) { - classNameBindings.forEach(function (binding) { - _emberGlimmerUtilsBindings.ClassNameBinding.install(element, component, binding, operations); - }); - } - - component._transitionTo('hasElement'); - - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } - }; - - CurlyComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket, bounds) { - bucket.component[_emberGlimmerComponent.BOUNDS] = bounds; - bucket.finalize(); - }; - - CurlyComponentManager.prototype.getTag = function getTag(_ref3) { - var component = _ref3.component; - - return component[_emberGlimmerComponent.DIRTY_TAG]; - }; - - CurlyComponentManager.prototype.didCreate = function didCreate(_ref4) { - var component = _ref4.component; - var environment = _ref4.environment; - - if (environment.isInteractive) { - component._transitionTo('inDOM'); - component.trigger('didInsertElement'); - component.trigger('didRender'); - } - }; - - CurlyComponentManager.prototype.update = function update(bucket, _, dynamicScope) { - var component = bucket.component; - var args = bucket.args; - var argsRevision = bucket.argsRevision; - var environment = bucket.environment; - - bucket.finalizer = _emberMetal._instrumentStart('render.component', rerenderInstrumentDetails, component); - - if (!args.tag.validate(argsRevision)) { - var _args$value = args.value(); - - var attrs = _args$value.attrs; - var props = _args$value.props; - - bucket.argsRevision = args.tag.value(); - - var oldAttrs = component.attrs; - var newAttrs = attrs; - - component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = true; - component.setProperties(props); - component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = false; - - component.trigger('didUpdateAttrs', { oldAttrs: oldAttrs, newAttrs: newAttrs }); - component.trigger('didReceiveAttrs', { oldAttrs: oldAttrs, newAttrs: newAttrs }); - } - - if (environment.isInteractive) { - component.trigger('willUpdate'); - component.trigger('willRender'); - } - }; - - CurlyComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) { - bucket.finalize(); - }; - - CurlyComponentManager.prototype.didUpdate = function didUpdate(_ref5) { - var component = _ref5.component; - var environment = _ref5.environment; - - if (environment.isInteractive) { - component.trigger('didUpdate'); - component.trigger('didRender'); - } - }; - - CurlyComponentManager.prototype.getDestructor = function getDestructor(stateBucket) { - return stateBucket; - }; - - return CurlyComponentManager; - })(); - - var MANAGER = new CurlyComponentManager(); - - var TopComponentManager = (function (_CurlyComponentManager) { -babelHelpers.inherits(TopComponentManager, _CurlyComponentManager); - - function TopComponentManager() { -babelHelpers.classCallCheck(this, TopComponentManager); - - _CurlyComponentManager.apply(this, arguments); - } - - TopComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, currentScope, hasBlock) { - var component = definition.ComponentClass; - - var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - - dynamicScope.view = component; - - // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components - if (component.tagName === '') { - if (environment.isInteractive) { - component.trigger('willRender'); - } - - component._transitionTo('hasElement'); - - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } - } - - processComponentInitializationAssertions(component, {}); - - return new ComponentStateBucket(environment, component, args, finalizer); - }; - - return TopComponentManager; - })(CurlyComponentManager); - - var ROOT_MANAGER = new TopComponentManager(); - - function tagName(vm) { - var tagName = vm.dynamicScope().view.tagName; - - return _glimmerRuntime.PrimitiveReference.create(tagName === '' ? null : tagName || 'div'); - } - - function ariaRole(vm) { - return vm.getSelf().get('ariaRole'); - } - - var CurlyComponentDefinition = (function (_ComponentDefinition) { -babelHelpers.inherits(CurlyComponentDefinition, _ComponentDefinition); - - function CurlyComponentDefinition(name, ComponentClass, template, args) { -babelHelpers.classCallCheck(this, CurlyComponentDefinition); - - _ComponentDefinition.call(this, name, MANAGER, ComponentClass); - this.template = template; - this.args = args; - } - - return CurlyComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - exports.CurlyComponentDefinition = CurlyComponentDefinition; - - var RootComponentDefinition = (function (_ComponentDefinition2) { -babelHelpers.inherits(RootComponentDefinition, _ComponentDefinition2); - - function RootComponentDefinition(instance) { -babelHelpers.classCallCheck(this, RootComponentDefinition); - - _ComponentDefinition2.call(this, '-root', ROOT_MANAGER, instance); - this.template = undefined; - this.args = undefined; - } - - return RootComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - exports.RootComponentDefinition = RootComponentDefinition; - - var CurlyComponentLayoutCompiler = (function () { - function CurlyComponentLayoutCompiler(template) { -babelHelpers.classCallCheck(this, CurlyComponentLayoutCompiler); - - this.template = template; - } - - CurlyComponentLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - builder.tag.dynamic(tagName); - builder.attrs.dynamic('role', ariaRole); - builder.attrs.static('class', 'ember-view'); - }; - - return CurlyComponentLayoutCompiler; - })(); - - CurlyComponentLayoutCompiler.id = 'curly'; -}); -enifed('ember-glimmer/syntax/dynamic-component', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal) { - 'use strict'; - - function dynamicComponentFor(vm, symbolTable) { - var env = vm.env; - var args = vm.getArgs(); - var nameRef = args.positional.at(0); - - return new DynamicComponentReference({ nameRef: nameRef, env: env, symbolTable: symbolTable }); - } - - var DynamicComponentSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(DynamicComponentSyntax, _StatementSyntax); - - // for {{component componentName}} - - DynamicComponentSyntax.create = function create(environment, args, symbolTable) { - var definitionArgs = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1)); - var invocationArgs = _glimmerRuntime.ArgsSyntax.build(args.positional.slice(1), args.named, args.blocks); - - return new this(definitionArgs, invocationArgs, symbolTable); - }; - - // Transforms {{foo.bar with=args}} or {{#foo.bar with=args}}{{/foo.bar}} - // into {{component foo.bar with=args}} or - // {{#component foo.bar with=args}}{{/component}} - // with all of it's arguments - - DynamicComponentSyntax.fromPath = function fromPath(environment, path, args, symbolTable) { - var positional = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(_glimmerRuntime.PositionalArgsSyntax.build([_glimmerRuntime.GetSyntax.build(path.join('.'))])); - - return new this(positional, args, symbolTable); - }; - - function DynamicComponentSyntax(definitionArgs, args, symbolTable) { - babelHelpers.classCallCheck(this, DynamicComponentSyntax); - - _StatementSyntax.call(this); - this.definition = dynamicComponentFor; - this.definitionArgs = definitionArgs; - this.args = args; - this.symbolTable = symbolTable; - this.shadow = null; - } - - DynamicComponentSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return DynamicComponentSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.DynamicComponentSyntax = DynamicComponentSyntax; - - var DynamicComponentReference = (function () { - function DynamicComponentReference(_ref) { - var nameRef = _ref.nameRef; - var env = _ref.env; - var symbolTable = _ref.symbolTable; - var args = _ref.args; - babelHelpers.classCallCheck(this, DynamicComponentReference); - - this.tag = nameRef.tag; - this.nameRef = nameRef; - this.env = env; - this.symbolTable = symbolTable; - this.args = args; - } - - DynamicComponentReference.prototype.value = function value() { - var env = this.env; - var nameRef = this.nameRef; - var symbolTable = this.symbolTable; - - var nameOrDef = nameRef.value(); - - if (typeof nameOrDef === 'string') { - var definition = env.getComponentDefinition([nameOrDef], symbolTable); - - _emberMetal.assert('Could not find component named "' + nameOrDef + '" (no component or template with that name was found)', definition); - - return definition; - } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { - return nameOrDef; - } else { - return null; - } - }; - - DynamicComponentReference.prototype.get = function get() { - return _glimmerReference.UNDEFINED_REFERENCE; - }; - - return DynamicComponentReference; - })(); -}); -enifed('ember-glimmer/syntax/input', ['exports', 'ember-metal', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/bindings'], function (exports, _emberMetal, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsBindings) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - function buildTextFieldSyntax(args, getDefinition, symbolTable) { - var definition = getDefinition('-text-field'); - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } - - /** - The `{{input}}` helper lets you create an HTML `` component. - It causes an `Ember.TextField` component to be rendered. For more info, - see the [Ember.TextField](/api/classes/Ember.TextField.html) docs and - the [templates guide](http://emberjs.com/guides/templates/input-helpers/). - - ```handlebars - {{input value="987"}} - ``` - - renders as: - - ```HTML - - ``` - - ### Text field - - If no `type` option is specified, a default of type 'text' is used. - Many of the standard HTML attributes may be passed to this helper. - - - - - - - - - - - -
    `readonly``required``autofocus`
    `value``placeholder``disabled`
    `size``tabindex``maxlength`
    `name``min``max`
    `pattern``accept``autocomplete`
    `autosave``formaction``formenctype`
    `formmethod``formnovalidate``formtarget`
    `height``inputmode``multiple`
    `step``width``form`
    `selectionDirection``spellcheck` 
    - When set to a quoted string, these values will be directly applied to the HTML - element. When left unquoted, these values will be bound to a property on the - template's current rendering context (most typically a controller instance). - A very common use of this helper is to bind the `value` of an input to an Object's attribute: - - ```handlebars - Search: - {{input value=searchWord}} - ``` - - In this example, the inital value in the `` will be set to the value of `searchWord`. - If the user changes the text, the value of `searchWord` will also be updated. - - ### Actions - - The helper can send multiple actions based on user events. - The action property defines the action which is sent when - the user presses the return key. - - ```handlebars - {{input action="submit"}} - ``` - - The helper allows some user events to send actions. - - * `enter` - * `insert-newline` - * `escape-press` - * `focus-in` - * `focus-out` - * `key-press` - * `key-up` - - For example, if you desire an action to be sent when the input is blurred, - you only need to setup the action name to the event name property. - - ```handlebars - {{input focus-out="alertMessage"}} - ``` - See more about [Text Support Actions](/api/classes/Ember.TextField.html) - - ### Extending `Ember.TextField` - - Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing - arguments from the helper to `Ember.TextField`'s `create` method. You can extend the - capabilities of text inputs in your applications by reopening this class. For example, - if you are building a Bootstrap project where `data-*` attributes are used, you - can add one to the `TextField`'s `attributeBindings` property: - - ```javascript - Ember.TextField.reopen({ - attributeBindings: ['data-error'] - }); - ``` - - Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` - itself extends `Ember.Component`. Expect isolated component semantics, not - legacy 1.x view semantics (like `controller` being present). - See more about [Ember components](/api/classes/Ember.Component.html) - - ### Checkbox - - Checkboxes are special forms of the `{{input}}` helper. To create a ``: - - ```handlebars - Emberize Everything: - {{input type="checkbox" name="isEmberized" checked=isEmberized}} - ``` - - This will bind checked state of this checkbox to the value of `isEmberized` -- if either one changes, - it will be reflected in the other. - - The following HTML attributes can be set via the helper: - - * `checked` - * `disabled` - * `tabindex` - * `indeterminate` - * `name` - * `autofocus` - * `form` - - ### Extending `Ember.Checkbox` - - Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing - arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the - capablilties of checkbox inputs in your applications by reopening this class. For example, - if you wanted to add a css class to all checkboxes in your application: - - ```javascript - Ember.Checkbox.reopen({ - classNames: ['my-app-checkbox'] - }); - ``` - - @method input - @for Ember.Templates.helpers - @param {Hash} options - @public - */ - var InputSyntax = { - create: function (environment, args, symbolTable) { - var getDefinition = function (path) { - return environment.getComponentDefinition([path], symbolTable); - }; - - if (args.named.has('type')) { - var typeArg = args.named.at('type'); - if (typeArg.type === 'value') { - if (typeArg.value === 'checkbox') { - _emberMetal.assert('{{input type=\'checkbox\'}} does not support setting `value=someBooleanValue`; ' + 'you must use `checked=someBooleanValue` instead.', !args.named.has('value')); - - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - var definition = getDefinition('-checkbox'); - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } else { - return buildTextFieldSyntax(args, getDefinition, symbolTable); - } - } - } else { - return buildTextFieldSyntax(args, getDefinition, symbolTable); - } - - return _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax.create(environment, args, symbolTable); - } - }; - exports.InputSyntax = InputSyntax; -}); -enifed('ember-glimmer/syntax/mount', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - /** - The `{{mount}}` helper lets you embed a routeless engine in a template. - Mounting an engine will cause an instance to be booted and its `application` - template to be rendered. - - For example, the following template mounts the `ember-chat` engine: - - ```handlebars - {{! application.hbs }} - {{mount "ember-chat"}} - ``` - - Currently, the engine name is the only argument that can be passed to - `{{mount}}`. - - @method mount - @for Ember.Templates.helpers - @category ember-application-engines - @public - */ - - var MountSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(MountSyntax, _StatementSyntax); - - MountSyntax.create = function create(env, args, symbolTable) { - _emberMetal.assert('You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.', args.positional.length === 1 && args.named.length === 0); - - _emberMetal.assert('The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}.', args.positional.at(0).type === 'value' && typeof args.positional.at(0).inner() === 'string'); - - var name = args.positional.at(0).inner(); - - _emberMetal.assert('You used `{{mount \'' + name + '\'}}`, but the engine \'' + name + '\' can not be found.', env.owner.hasRegistration('engine:' + name)); - - var definition = new MountDefinition(name, env); - - return new MountSyntax(definition, symbolTable); - }; - - function MountSyntax(definition, symbolTable) { - babelHelpers.classCallCheck(this, MountSyntax); - - _StatementSyntax.call(this); - this.definition = definition; - this.symbolTable = symbolTable; - } - - MountSyntax.prototype.compile = function compile(builder) { - builder.component.static(this.definition, _glimmerRuntime.ArgsSyntax.empty(), null, this.symbolTable, null); - }; - - return MountSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.MountSyntax = MountSyntax; - - var MountManager = (function () { - function MountManager() { - babelHelpers.classCallCheck(this, MountManager); - } - - MountManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - MountManager.prototype.create = function create(environment, _ref, args, dynamicScope) { - var name = _ref.name; - var env = _ref.env; - - dynamicScope.outletState = _glimmerReference.UNDEFINED_REFERENCE; - - var engine = env.owner.buildChildEngineInstance(name); - - engine.boot(); - - return { engine: engine }; - }; - - MountManager.prototype.layoutFor = function layoutFor(definition, _ref2, env) { - var engine = _ref2.engine; - - var template = engine.lookup('template:application'); - return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, template); - }; - - MountManager.prototype.getSelf = function getSelf(_ref3) { - var engine = _ref3.engine; - - var factory = engine._lookupFactory('controller:application') || _emberRouting.generateControllerFactory(engine, 'application'); - return new _emberGlimmerUtilsReferences.RootReference(factory.create()); - }; - - MountManager.prototype.getTag = function getTag() { - return null; - }; - - MountManager.prototype.getDestructor = function getDestructor(_ref4) { - var engine = _ref4.engine; - - return engine; - }; - - MountManager.prototype.didCreateElement = function didCreateElement() {}; - - MountManager.prototype.didRenderLayout = function didRenderLayout() {}; - - MountManager.prototype.didCreate = function didCreate(state) {}; - - MountManager.prototype.update = function update(state, args, dynamicScope) {}; - - MountManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - - MountManager.prototype.didUpdate = function didUpdate(state) {}; - - return MountManager; - })(); - - var MOUNT_MANAGER = new MountManager(); - - var MountDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(MountDefinition, _ComponentDefinition); - - function MountDefinition(name, env) { - babelHelpers.classCallCheck(this, MountDefinition); - - _ComponentDefinition.call(this, name, MOUNT_MANAGER, null); - this.env = env; - } - - return MountDefinition; - })(_glimmerRuntime.ComponentDefinition); -}); -enifed('ember-glimmer/syntax/outlet', ['exports', 'ember-utils', 'glimmer-runtime', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberUtils, _glimmerRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - function outletComponentFor(vm) { - var _vm$dynamicScope = vm.dynamicScope(); - - var outletState = _vm$dynamicScope.outletState; - - var args = vm.getArgs(); - var outletNameRef = undefined; - if (args.positional.length === 0) { - outletNameRef = new _glimmerReference.ConstReference('main'); - } else { - outletNameRef = args.positional.at(0); - } - - return new OutletComponentReference(outletNameRef, outletState); - } - - /** - The `{{outlet}}` helper lets you specify where a child route will render in - your template. An important use of the `{{outlet}}` helper is in your - application's `application.hbs` file: - - ```handlebars - {{! app/templates/application.hbs }} - - {{my-header}} -
    - - {{outlet}} -
    - - {{my-footer}} - ``` - - See [templates guide](http://emberjs.com/guides/templates/the-application-template/) for - additional information on using `{{outlet}}` in `application.hbs`. - You may also specify a name for the `{{outlet}}`, which is useful when using more than one - `{{outlet}}` in a template: - - ```handlebars - {{outlet "menu"}} - {{outlet "sidebar"}} - {{outlet "main"}} - ``` - - Your routes can then render into a specific one of these `outlet`s by specifying the `outlet` - attribute in your `renderTemplate` function: - - ```javascript - // app/routes/menu.js - export default Ember.Route.extend({ - renderTemplate() { - this.render({ outlet: 'menu' }); - } - }); - ``` - - See the [routing guide](http://emberjs.com/guides/routing/rendering-a-template/) for more - information on how your `route` interacts with the `{{outlet}}` helper. - Note: Your content __will not render__ if there isn't an `{{outlet}}` for it. - - @method outlet - @param {String} [name] - @for Ember.Templates.helpers - @public - */ - - var OutletSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(OutletSyntax, _StatementSyntax); - - OutletSyntax.create = function create(environment, args, symbolTable) { - var definitionArgs = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1)); - return new this(environment, definitionArgs, symbolTable); - }; - - function OutletSyntax(environment, args, symbolTable) { - babelHelpers.classCallCheck(this, OutletSyntax); - - _StatementSyntax.call(this); - this.definitionArgs = args; - this.definition = outletComponentFor; - this.args = _glimmerRuntime.ArgsSyntax.empty(); - this.symbolTable = symbolTable; - this.shadow = null; - } - - OutletSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return OutletSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.OutletSyntax = OutletSyntax; - - var OutletComponentReference = (function () { - function OutletComponentReference(outletNameRef, parentOutletStateRef) { - babelHelpers.classCallCheck(this, OutletComponentReference); - - this.outletNameRef = outletNameRef; - this.parentOutletStateRef = parentOutletStateRef; - this.definition = null; - this.lastState = null; - var outletStateTag = this.outletStateTag = new _glimmerReference.UpdatableTag(parentOutletStateRef.tag); - this.tag = _glimmerReference.combine([outletStateTag.tag, outletNameRef.tag]); - } - - OutletComponentReference.prototype.value = function value() { - var outletNameRef = this.outletNameRef; - var parentOutletStateRef = this.parentOutletStateRef; - var definition = this.definition; - var lastState = this.lastState; - - var outletName = outletNameRef.value(); - var outletStateRef = parentOutletStateRef.get('outlets').get(outletName); - var newState = this.lastState = outletStateRef.value(); - - this.outletStateTag.update(outletStateRef.tag); - - definition = revalidate(definition, lastState, newState); - - var hasTemplate = newState && newState.render.template; - - if (definition) { - return definition; - } else if (hasTemplate) { - return this.definition = new OutletComponentDefinition(outletName, newState.render.template); - } else { - return this.definition = null; - } - }; - - return OutletComponentReference; - })(); - - function revalidate(definition, lastState, newState) { - if (!lastState && !newState) { - return definition; - } - - if (!lastState && newState || lastState && !newState) { - return null; - } - - if (newState.render.template === lastState.render.template && newState.render.controller === lastState.render.controller) { - return definition; - } - - return null; - } - - function instrumentationPayload(_ref) { - var _ref$render = _ref.render; - var name = _ref$render.name; - var outlet = _ref$render.outlet; - - return { object: name + ':' + outlet }; - } - - function NOOP() {} - - var StateBucket = (function () { - function StateBucket(outletState) { - babelHelpers.classCallCheck(this, StateBucket); - - this.outletState = outletState; - this.instrument(); - } - - StateBucket.prototype.instrument = function instrument() { - this.finalizer = _emberMetal._instrumentStart('render.outlet', instrumentationPayload, this.outletState); - }; - - StateBucket.prototype.finalize = function finalize() { - var finalizer = this.finalizer; - - finalizer(); - this.finalizer = NOOP; - }; - - return StateBucket; - })(); - - var OutletComponentManager = (function () { - function OutletComponentManager() { - babelHelpers.classCallCheck(this, OutletComponentManager); - } - - OutletComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - OutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var outletStateReference = dynamicScope.outletState = dynamicScope.outletState.get('outlets').get(definition.outletName); - var outletState = outletStateReference.value(); - return new StateBucket(outletState); - }; - - OutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(OutletLayoutCompiler, definition.template); - }; - - OutletComponentManager.prototype.getSelf = function getSelf(_ref2) { - var outletState = _ref2.outletState; - - return new _emberGlimmerUtilsReferences.RootReference(outletState.render.controller); - }; - - OutletComponentManager.prototype.getTag = function getTag() { - return null; - }; - - OutletComponentManager.prototype.getDestructor = function getDestructor() { - return null; - }; - - OutletComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket) { - bucket.finalize(); - }; - - OutletComponentManager.prototype.didCreateElement = function didCreateElement() {}; - - OutletComponentManager.prototype.didCreate = function didCreate(state) {}; - - OutletComponentManager.prototype.update = function update(bucket) {}; - - OutletComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) {}; - - OutletComponentManager.prototype.didUpdate = function didUpdate(state) {}; - - return OutletComponentManager; - })(); - - var MANAGER = new OutletComponentManager(); - - var TopLevelOutletComponentManager = (function (_OutletComponentManager) { - babelHelpers.inherits(TopLevelOutletComponentManager, _OutletComponentManager); - - function TopLevelOutletComponentManager() { - babelHelpers.classCallCheck(this, TopLevelOutletComponentManager); - - _OutletComponentManager.apply(this, arguments); - } - - TopLevelOutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - return new StateBucket(dynamicScope.outletState.value()); - }; - - TopLevelOutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(TopLevelOutletLayoutCompiler, definition.template); - }; - - return TopLevelOutletComponentManager; - })(OutletComponentManager); - - var TOP_LEVEL_MANAGER = new TopLevelOutletComponentManager(); - - var TopLevelOutletComponentDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(TopLevelOutletComponentDefinition, _ComponentDefinition); - - function TopLevelOutletComponentDefinition(instance) { - babelHelpers.classCallCheck(this, TopLevelOutletComponentDefinition); - - _ComponentDefinition.call(this, 'outlet', TOP_LEVEL_MANAGER, instance); - this.template = instance.template; - _emberUtils.generateGuid(this); - } - - return TopLevelOutletComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - exports.TopLevelOutletComponentDefinition = TopLevelOutletComponentDefinition; - - var TopLevelOutletLayoutCompiler = (function () { - function TopLevelOutletLayoutCompiler(template) { - babelHelpers.classCallCheck(this, TopLevelOutletLayoutCompiler); - - this.template = template; - } - - TopLevelOutletLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - builder.tag.static('div'); - builder.attrs.static('id', _emberUtils.guidFor(this)); - builder.attrs.static('class', 'ember-view'); - }; - - return TopLevelOutletLayoutCompiler; - })(); - - TopLevelOutletLayoutCompiler.id = 'top-level-outlet'; - - var OutletComponentDefinition = (function (_ComponentDefinition2) { - babelHelpers.inherits(OutletComponentDefinition, _ComponentDefinition2); - - function OutletComponentDefinition(outletName, template) { - babelHelpers.classCallCheck(this, OutletComponentDefinition); - - _ComponentDefinition2.call(this, 'outlet', MANAGER, null); - this.outletName = outletName; - this.template = template; - _emberUtils.generateGuid(this); - } - - return OutletComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - var OutletLayoutCompiler = (function () { - function OutletLayoutCompiler(template) { - babelHelpers.classCallCheck(this, OutletLayoutCompiler); - - this.template = template; - } - - OutletLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - }; - - return OutletLayoutCompiler; - })(); - - exports.OutletLayoutCompiler = OutletLayoutCompiler; - - OutletLayoutCompiler.id = 'outlet'; -}); -enifed('ember-glimmer/syntax/render', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - function makeComponentDefinition(vm) { - var env = vm.env; - var args = vm.getArgs(); - var nameRef = args.positional.at(0); - - _emberMetal.assert('The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.', _glimmerReference.isConst(nameRef)); - _emberMetal.assert('The second argument of {{render}} must be a path, e.g. {{render "post" post}}.', args.positional.length === 1 || !_glimmerReference.isConst(args.positional.at(1))); - - var templateName = nameRef.value(); - - _emberMetal.assert('You used `{{render \'' + templateName + '\'}}`, but \'' + templateName + '\' can not be found as a template.', env.owner.hasRegistration('template:' + templateName)); - - var template = env.owner.lookup('template:' + templateName); - - var controllerName = undefined; - - if (args.named.has('controller')) { - var controllerNameRef = args.named.get('controller'); - - _emberMetal.assert('The controller argument for {{render}} must be quoted, e.g. {{render "sidebar" controller="foo"}}.', _glimmerReference.isConst(controllerNameRef)); - - controllerName = controllerNameRef.value(); - - _emberMetal.assert('The controller name you supplied \'' + controllerName + '\' did not resolve to a controller.', env.owner.hasRegistration('controller:' + controllerName)); - } else { - controllerName = templateName; - } - - if (args.positional.length === 1) { - return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, SINGLETON_RENDER_MANAGER)); - } else { - return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, NON_SINGLETON_RENDER_MANAGER)); - } - } - - /** - Calling ``{{render}}`` from within a template will insert another - template that matches the provided name. The inserted template will - access its properties on its own controller (rather than the controller - of the parent template). - - If a view class with the same name exists, the view class also will be used. - Note: A given controller may only be used *once* in your app in this manner. - A singleton instance of the controller will be created for you. - - Example: - - ```javascript - App.NavigationController = Ember.Controller.extend({ - who: "world" - }); - ``` - - ```handlebars - - Hello, {{who}}. - ``` - - ```handlebars - -

    My great app

    - {{render "navigation"}} - ``` - - ```html -

    My great app

    -
    - Hello, world. -
    - ``` - - Optionally you may provide a second argument: a property path - that will be bound to the `model` property of the controller. - If a `model` property path is specified, then a new instance of the - controller will be created and `{{render}}` can be used multiple times - with the same name. - - For example if you had this `author` template. - - ```handlebars -
    - Written by {{firstName}} {{lastName}}. - Total Posts: {{postCount}} -
    - ``` - - You could render it inside the `post` template using the `render` helper. - - ```handlebars -
    -

    {{title}}

    -
    {{body}}
    - {{render "author" author}} -
    - ``` - - @method render - @for Ember.Templates.helpers - @param {String} name - @param {Object?} context - @param {Hash} options - @return {String} HTML string - @public - */ - - var RenderSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(RenderSyntax, _StatementSyntax); - - RenderSyntax.create = function create(environment, args, symbolTable) { - return new this(environment, args, symbolTable); - }; - - function RenderSyntax(environment, args, symbolTable) { - babelHelpers.classCallCheck(this, RenderSyntax); - - _StatementSyntax.call(this); - this.definitionArgs = args; - this.definition = makeComponentDefinition; - this.args = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(1, 2)); - this.symbolTable = symbolTable; - this.shadow = null; - } - - RenderSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return RenderSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.RenderSyntax = RenderSyntax; - - var AbstractRenderManager = (function () { - function AbstractRenderManager() { - babelHelpers.classCallCheck(this, AbstractRenderManager); - } - - AbstractRenderManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - /* abstract create(environment, definition, args, dynamicScope); */ - - AbstractRenderManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, definition.template); - }; - - AbstractRenderManager.prototype.getSelf = function getSelf(_ref) { - var controller = _ref.controller; - - return new _emberGlimmerUtilsReferences.RootReference(controller); - }; - - AbstractRenderManager.prototype.getTag = function getTag() { - return null; - }; - - AbstractRenderManager.prototype.getDestructor = function getDestructor() { - return null; - }; - - AbstractRenderManager.prototype.didCreateElement = function didCreateElement() {}; - - AbstractRenderManager.prototype.didRenderLayout = function didRenderLayout() {}; - - AbstractRenderManager.prototype.didCreate = function didCreate() {}; - - AbstractRenderManager.prototype.update = function update() {}; - - AbstractRenderManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - - AbstractRenderManager.prototype.didUpdate = function didUpdate() {}; - - return AbstractRenderManager; - })(); - - var SingletonRenderManager = (function (_AbstractRenderManager) { - babelHelpers.inherits(SingletonRenderManager, _AbstractRenderManager); - - function SingletonRenderManager() { - babelHelpers.classCallCheck(this, SingletonRenderManager); - - _AbstractRenderManager.apply(this, arguments); - } - - SingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var name = definition.name; - var env = definition.env; - - var controller = env.owner.lookup('controller:' + name) || _emberRouting.generateController(env.owner, name); - - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); - } - - return { controller: controller }; - }; - - return SingletonRenderManager; - })(AbstractRenderManager); - - var SINGLETON_RENDER_MANAGER = new SingletonRenderManager(); - - var NonSingletonRenderManager = (function (_AbstractRenderManager2) { - babelHelpers.inherits(NonSingletonRenderManager, _AbstractRenderManager2); - - function NonSingletonRenderManager() { - babelHelpers.classCallCheck(this, NonSingletonRenderManager); - - _AbstractRenderManager2.apply(this, arguments); - } - - NonSingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var name = definition.name; - var env = definition.env; - - var modelRef = args.positional.at(0); - - var factory = env.owner._lookupFactory('controller:' + name) || _emberRouting.generateControllerFactory(env.owner, name); - var controller = factory.create({ model: modelRef.value() }); - - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); - } - - return { controller: controller }; - }; - - NonSingletonRenderManager.prototype.update = function update(_ref2, args, dynamicScope) { - var controller = _ref2.controller; - - controller.set('model', args.positional.at(0).value()); - }; - - NonSingletonRenderManager.prototype.getDestructor = function getDestructor(_ref3) { - var controller = _ref3.controller; - - return controller; - }; - - return NonSingletonRenderManager; - })(AbstractRenderManager); - - var NON_SINGLETON_RENDER_MANAGER = new NonSingletonRenderManager(); - - var RenderDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(RenderDefinition, _ComponentDefinition); - - function RenderDefinition(name, template, env, manager) { - babelHelpers.classCallCheck(this, RenderDefinition); - - _ComponentDefinition.call(this, 'render', manager, null); - - this.name = name; - this.template = template; - this.env = env; - } - - return RenderDefinition; - })(_glimmerRuntime.ComponentDefinition); -}); -enifed('ember-glimmer/template', ['exports', 'ember-utils', 'glimmer-runtime'], function (exports, _emberUtils, _glimmerRuntime) { - 'use strict'; - - exports.default = template; - - function template(json) { - var factory = _glimmerRuntime.templateFactory(json); - - return { - id: factory.id, - meta: factory.meta, - create: function (props) { - return factory.create(props.env, { owner: props[_emberUtils.OWNER] }); - } - }; - } -}); -enifed("ember-glimmer/template_registry", ["exports"], function (exports) { - // STATE within a module is frowned apon, this exists - // to support Ember.TEMPLATES but shield ember internals from this legacy - // global API. - "use strict"; - - exports.setTemplates = setTemplates; - exports.getTemplates = getTemplates; - exports.getTemplate = getTemplate; - exports.hasTemplate = hasTemplate; - exports.setTemplate = setTemplate; - var TEMPLATES = {}; - - function setTemplates(templates) { - TEMPLATES = templates; - } - - function getTemplates() { - return TEMPLATES; - } - - function getTemplate(name) { - if (TEMPLATES.hasOwnProperty(name)) { - return TEMPLATES[name]; - } - } - - function hasTemplate(name) { - return TEMPLATES.hasOwnProperty(name); - } - - function setTemplate(name, template) { - return TEMPLATES[name] = template; - } -}); -enifed("ember-glimmer/templates/component", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "ZoGfVsSJ", "block": "{\"statements\":[[\"yield\",\"default\"]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/component.hbs" } }); -}); -enifed("ember-glimmer/templates/empty", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "qEHL4OLi", "block": "{\"statements\":[],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/empty.hbs" } }); -}); -enifed("ember-glimmer/templates/link-to", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "Ca7iQMR7", "block": "{\"statements\":[[\"block\",[\"if\"],[[\"get\",[\"linkTitle\"]]],null,1,0]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"blocks\":[{\"statements\":[[\"yield\",\"default\"]],\"locals\":[]},{\"statements\":[[\"append\",[\"unknown\",[\"linkTitle\"]],false]],\"locals\":[]}],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/link-to.hbs" } }); -}); -enifed("ember-glimmer/templates/outlet", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "sYQo9vi/", "block": "{\"statements\":[[\"append\",[\"unknown\",[\"outlet\"]],false]],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/outlet.hbs" } }); -}); -enifed("ember-glimmer/templates/root", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "Eaf3RPY3", "block": "{\"statements\":[[\"append\",[\"helper\",[\"component\"],[[\"get\",[null]]],null],false]],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/root.hbs" } }); -}); -enifed('ember-glimmer/utils/bindings', ['exports', 'glimmer-reference', 'glimmer-runtime', 'ember-metal', 'ember-runtime', 'ember-glimmer/component', 'ember-glimmer/utils/string'], function (exports, _glimmerReference, _glimmerRuntime, _emberMetal, _emberRuntime, _emberGlimmerComponent, _emberGlimmerUtilsString) { - 'use strict'; - - exports.wrapComponentClassAttribute = wrapComponentClassAttribute; - - function referenceForKey(component, key) { - return component[_emberGlimmerComponent.ROOT_REF].get(key); - } - - function referenceForParts(component, parts) { - var isAttrs = parts[0] === 'attrs'; - - // TODO deprecate this - if (isAttrs) { - parts.shift(); - - if (parts.length === 1) { - return referenceForKey(component, parts[0]); - } - } - - return _glimmerReference.referenceFromParts(component[_emberGlimmerComponent.ROOT_REF], parts); - } - - // TODO we should probably do this transform at build time - - function wrapComponentClassAttribute(args) { - var named = args.named; - - var index = named.keys.indexOf('class'); - - if (index !== -1) { - var _named$values$index = named.values[index]; - var ref = _named$values$index.ref; - var type = _named$values$index.type; - - if (type === 'get') { - var propName = ref.parts[ref.parts.length - 1]; - named.values[index] = _glimmerRuntime.HelperSyntax.fromSpec(['helper', ['-class'], [['get', ref.parts], propName], null]); - } - } - - return args; - } - - var AttributeBinding = { - parse: function (microsyntax) { - var colonIndex = microsyntax.indexOf(':'); - - if (colonIndex === -1) { - _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', microsyntax !== 'class'); - return [microsyntax, microsyntax, true]; - } else { - var prop = microsyntax.substring(0, colonIndex); - var attribute = microsyntax.substring(colonIndex + 1); - - _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attribute !== 'class'); - - return [prop, attribute, false]; - } - }, - - install: function (element, component, parsed, operations) { - var prop = parsed[0]; - var attribute = parsed[1]; - var isSimple = parsed[2]; - - if (attribute === 'id') { - var elementId = _emberMetal.get(component, prop); - if (elementId === undefined || elementId === null) { - elementId = component.elementId; - } - operations.addStaticAttribute(element, 'id', elementId); - return; - } - - var isPath = prop.indexOf('.') > -1; - var reference = isPath ? referenceForParts(component, prop.split('.')) : referenceForKey(component, prop); - - _emberMetal.assert('Illegal attributeBinding: \'' + prop + '\' is not a valid attribute name.', !(isSimple && isPath)); - - if (attribute === 'style') { - reference = new StyleBindingReference(reference, referenceForKey(component, 'isVisible')); - } - - operations.addDynamicAttribute(element, attribute, reference); - } - }; - - exports.AttributeBinding = AttributeBinding; - var DISPLAY_NONE = 'display: none;'; - var SAFE_DISPLAY_NONE = _emberGlimmerUtilsString.htmlSafe(DISPLAY_NONE); - - var StyleBindingReference = (function (_CachedReference) { - babelHelpers.inherits(StyleBindingReference, _CachedReference); - - function StyleBindingReference(inner, isVisible) { - babelHelpers.classCallCheck(this, StyleBindingReference); - - _CachedReference.call(this); - - this.tag = _glimmerReference.combine([inner.tag, isVisible.tag]); - this.inner = inner; - this.isVisible = isVisible; - } - - StyleBindingReference.prototype.compute = function compute() { - var value = this.inner.value(); - var isVisible = this.isVisible.value(); - - if (isVisible !== false) { - return value; - } else if (!value && value !== 0) { - return SAFE_DISPLAY_NONE; - } else { - var style = value + ' ' + DISPLAY_NONE; - return _emberGlimmerUtilsString.isHTMLSafe(value) ? _emberGlimmerUtilsString.htmlSafe(style) : style; - } - }; - - return StyleBindingReference; - })(_glimmerReference.CachedReference); - - var IsVisibleBinding = { - install: function (element, component, operations) { - operations.addDynamicAttribute(element, 'style', _glimmerReference.map(referenceForKey(component, 'isVisible'), this.mapStyleValue)); - }, - - mapStyleValue: function (isVisible) { - return isVisible === false ? SAFE_DISPLAY_NONE : null; - } - }; - - exports.IsVisibleBinding = IsVisibleBinding; - var ClassNameBinding = { - install: function (element, component, microsyntax, operations) { - var _microsyntax$split = microsyntax.split(':'); - - var prop = _microsyntax$split[0]; - var truthy = _microsyntax$split[1]; - var falsy = _microsyntax$split[2]; - - var isStatic = prop === ''; - - if (isStatic) { - operations.addStaticAttribute(element, 'class', truthy); - } else { - var isPath = prop.indexOf('.') > -1; - var parts = isPath && prop.split('.'); - var value = isPath ? referenceForParts(component, parts) : referenceForKey(component, prop); - var ref = undefined; - - if (truthy === undefined) { - ref = new SimpleClassNameBindingReference(value, isPath ? parts[parts.length - 1] : prop); - } else { - ref = new ColonClassNameBindingReference(value, truthy, falsy); - } - - operations.addDynamicAttribute(element, 'class', ref); - } - } - }; - - exports.ClassNameBinding = ClassNameBinding; - - var SimpleClassNameBindingReference = (function (_CachedReference2) { - babelHelpers.inherits(SimpleClassNameBindingReference, _CachedReference2); - - function SimpleClassNameBindingReference(inner, path) { - babelHelpers.classCallCheck(this, SimpleClassNameBindingReference); - - _CachedReference2.call(this); - - this.tag = inner.tag; - this.inner = inner; - this.path = path; - this.dasherizedPath = null; - } - - SimpleClassNameBindingReference.prototype.compute = function compute() { - var value = this.inner.value(); - - if (value === true) { - var path = this.path; - var dasherizedPath = this.dasherizedPath; - - return dasherizedPath || (this.dasherizedPath = _emberRuntime.String.dasherize(path)); - } else if (value || value === 0) { - return value; - } else { - return null; - } - }; - - return SimpleClassNameBindingReference; - })(_glimmerReference.CachedReference); - - var ColonClassNameBindingReference = (function (_CachedReference3) { - babelHelpers.inherits(ColonClassNameBindingReference, _CachedReference3); - - function ColonClassNameBindingReference(inner, truthy, falsy) { - babelHelpers.classCallCheck(this, ColonClassNameBindingReference); - - _CachedReference3.call(this); - - this.tag = inner.tag; - this.inner = inner; - this.truthy = truthy || null; - this.falsy = falsy || null; - } - - ColonClassNameBindingReference.prototype.compute = function compute() { - var inner = this.inner; - var truthy = this.truthy; - var falsy = this.falsy; - - return inner.value() ? truthy : falsy; - }; - - return ColonClassNameBindingReference; - })(_glimmerReference.CachedReference); -}); -enifed('ember-glimmer/utils/iterable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', 'glimmer-reference'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerReference) { - 'use strict'; - - exports.default = iterableFor; - - var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; - - function iterableFor(ref, keyPath) { - if (_emberGlimmerHelpersEachIn.isEachIn(ref)) { - return new EachInIterable(ref, keyForEachIn(keyPath)); - } else { - return new ArrayIterable(ref, keyForArray(keyPath)); - } - } - - function keyForEachIn(keyPath) { - switch (keyPath) { - case '@index': - case undefined: - case null: - return index; - case '@identity': - return identity; - default: - return function (item) { - return _emberMetal.get(item, keyPath); - }; - } - } - - function keyForArray(keyPath) { - switch (keyPath) { - case '@index': - return index; - case '@identity': - case undefined: - case null: - return identity; - default: - return function (item) { - return _emberMetal.get(item, keyPath); - }; - } - } - - function index(item, index) { - return String(index); - } - - function identity(item) { - switch (typeof item) { - case 'string': - case 'number': - return String(item); - default: - return _emberUtils.guidFor(item); - } - } - - function ensureUniqueKey(seen, key) { - var seenCount = seen[key]; - - if (seenCount) { - seen[key]++; - return '' + key + ITERATOR_KEY_GUID + seenCount; - } else { - seen[key] = 1; - } - - return key; - } - - var ArrayIterator = (function () { - function ArrayIterator(array, keyFor) { - babelHelpers.classCallCheck(this, ArrayIterator); - - this.array = array; - this.length = array.length; - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } - - ArrayIterator.prototype.isEmpty = function isEmpty() { - return false; - }; - - ArrayIterator.prototype.next = function next() { - var array = this.array; - var length = this.length; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; - - if (position >= length) { - return null; - } - - var value = array[position]; - var memo = position; - var key = ensureUniqueKey(seen, keyFor(value, memo)); - - this.position++; - - return { key: key, value: value, memo: memo }; - }; - - return ArrayIterator; - })(); - - var EmberArrayIterator = (function () { - function EmberArrayIterator(array, keyFor) { - babelHelpers.classCallCheck(this, EmberArrayIterator); - - this.array = array; - this.length = _emberMetal.get(array, 'length'); - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } - - EmberArrayIterator.prototype.isEmpty = function isEmpty() { - return this.length === 0; - }; - - EmberArrayIterator.prototype.next = function next() { - var array = this.array; - var length = this.length; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; - - if (position >= length) { - return null; - } - - var value = _emberRuntime.objectAt(array, position); - var memo = position; - var key = ensureUniqueKey(seen, keyFor(value, memo)); - - this.position++; - - return { key: key, value: value, memo: memo }; - }; - - return EmberArrayIterator; - })(); - - var ObjectKeysIterator = (function () { - function ObjectKeysIterator(keys, values, keyFor) { - babelHelpers.classCallCheck(this, ObjectKeysIterator); - - this.keys = keys; - this.values = values; - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } - - ObjectKeysIterator.prototype.isEmpty = function isEmpty() { - return this.keys.length === 0; - }; - - ObjectKeysIterator.prototype.next = function next() { - var keys = this.keys; - var values = this.values; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; - - if (position >= keys.length) { - return null; - } - - var value = values[position]; - var memo = keys[position]; - var key = ensureUniqueKey(seen, keyFor(value, memo)); - - this.position++; - - return { key: key, value: value, memo: memo }; - }; - - return ObjectKeysIterator; - })(); - - var EmptyIterator = (function () { - function EmptyIterator() { - babelHelpers.classCallCheck(this, EmptyIterator); - } - - EmptyIterator.prototype.isEmpty = function isEmpty() { - return true; - }; - - EmptyIterator.prototype.next = function next() { - throw new Error('Cannot call next() on an empty iterator'); - }; - - return EmptyIterator; - })(); - - var EMPTY_ITERATOR = new EmptyIterator(); - - var EachInIterable = (function () { - function EachInIterable(ref, keyFor) { - babelHelpers.classCallCheck(this, EachInIterable); - - this.ref = ref; - this.keyFor = keyFor; - - var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - - this.tag = _glimmerReference.combine([ref.tag, valueTag]); - } - - EachInIterable.prototype.iterate = function iterate() { - var ref = this.ref; - var keyFor = this.keyFor; - var valueTag = this.valueTag; - - var iterable = ref.value(); - - valueTag.update(_emberMetal.tagFor(iterable)); - - if (_emberMetal.isProxy(iterable)) { - iterable = _emberMetal.get(iterable, 'content'); - } - - var typeofIterable = typeof iterable; - - if (iterable && (typeofIterable === 'object' || typeofIterable === 'function')) { - var keys = Object.keys(iterable); - var values = keys.map(function (key) { - return iterable[key]; - }); - return keys.length > 0 ? new ObjectKeysIterator(keys, values, keyFor) : EMPTY_ITERATOR; - } else { - return EMPTY_ITERATOR; - } - }; - - // {{each-in}} yields |key value| instead of |value key|, so the memo and - // value are flipped - - EachInIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); - }; - - EachInIterable.prototype.updateValueReference = function updateValueReference(reference, item) { - reference.update(item.memo); - }; - - EachInIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); - }; - - EachInIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { - reference.update(item.value); - }; - - return EachInIterable; - })(); - - var ArrayIterable = (function () { - function ArrayIterable(ref, keyFor) { - babelHelpers.classCallCheck(this, ArrayIterable); - - this.ref = ref; - this.keyFor = keyFor; - - var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - - this.tag = _glimmerReference.combine([ref.tag, valueTag]); - } - - ArrayIterable.prototype.iterate = function iterate() { - var ref = this.ref; - var keyFor = this.keyFor; - var valueTag = this.valueTag; - - var iterable = ref.value(); - - valueTag.update(_emberMetal.tagForProperty(iterable, '[]')); - - if (!iterable || typeof iterable !== 'object') { - return EMPTY_ITERATOR; - } - - if (Array.isArray(iterable)) { - return iterable.length > 0 ? new ArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; - } else if (_emberRuntime.isEmberArray(iterable)) { - return _emberMetal.get(iterable, 'length') > 0 ? new EmberArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; - } else if (typeof iterable.forEach === 'function') { - var _ret = (function () { - var array = []; - iterable.forEach(function (item) { - array.push(item); - }); - return { - v: array.length > 0 ? new ArrayIterator(array, keyFor) : EMPTY_ITERATOR - }; - })(); - - if (typeof _ret === 'object') return _ret.v; - } else { - return EMPTY_ITERATOR; - } - }; - - ArrayIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); - }; - - ArrayIterable.prototype.updateValueReference = function updateValueReference(reference, item) { - reference.update(item.value); - }; - - ArrayIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); - }; - - ArrayIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { - reference.update(item.memo); - }; - - return ArrayIterable; - })(); -}); -enifed('ember-glimmer/utils/process-args', ['exports', 'ember-utils', 'glimmer-reference', 'ember-glimmer/component', 'ember-glimmer/utils/references', 'ember-views', 'ember-glimmer/helpers/action', 'glimmer-runtime'], function (exports, _emberUtils, _glimmerReference, _emberGlimmerComponent, _emberGlimmerUtilsReferences, _emberViews, _emberGlimmerHelpersAction, _glimmerRuntime) { - 'use strict'; - - exports.gatherArgs = gatherArgs; - - // Maps all variants of positional and dynamically scoped arguments - // into the named arguments. Input `args` and return value are both - // `EvaluatedArgs`. - - function gatherArgs(args, definition) { - var namedMap = gatherNamedMap(args, definition); - var positionalValues = gatherPositionalValues(args, definition); - return mergeArgs(namedMap, positionalValues, args.blocks, definition.ComponentClass); - } - - function gatherNamedMap(args, definition) { - var namedMap = args.named.map; - if (definition.args) { - return _emberUtils.assign({}, definition.args.named.map, namedMap); - } else { - return namedMap; - } - } - - function gatherPositionalValues(args, definition) { - var positionalValues = args.positional.values; - if (definition.args) { - var oldPositional = definition.args.positional.values; - var newPositional = []; - newPositional.push.apply(newPositional, oldPositional); - newPositional.splice.apply(newPositional, [0, positionalValues.length].concat(positionalValues)); - return newPositional; - } else { - return positionalValues; - } - } - - function mergeArgs(namedMap, positionalValues, blocks, componentClass) { - var positionalParamsDefinition = componentClass.positionalParams; - - if (positionalParamsDefinition && positionalParamsDefinition.length > 0 && positionalValues.length > 0) { - if (typeof positionalParamsDefinition === 'string') { - namedMap = mergeRestArg(namedMap, positionalValues, positionalParamsDefinition); - } else { - namedMap = mergePositionalParams(namedMap, positionalValues, positionalParamsDefinition); - } - } - return _glimmerRuntime.EvaluatedArgs.named(namedMap, blocks); - } - - var EMPTY_ARGS = { - tag: _glimmerReference.CONSTANT_TAG, - value: function () { - var _props; - - return { attrs: {}, props: (_props = { attrs: {} }, _props[_emberGlimmerComponent.ARGS] = {}, _props) }; - } - }; - - // ComponentArgs takes EvaluatedNamedArgs and converts them into the - // inputs needed by CurlyComponents (attrs and props, with mutable - // cells, etc). - - var ComponentArgs = (function () { - ComponentArgs.create = function create(args) { - if (args.named.keys.length === 0) { - return EMPTY_ARGS; - } else { - return new ComponentArgs(args.named); - } - }; - - function ComponentArgs(namedArgs) { - babelHelpers.classCallCheck(this, ComponentArgs); - - this.tag = namedArgs.tag; - this.namedArgs = namedArgs; - } - - ComponentArgs.prototype.value = function value() { - var namedArgs = this.namedArgs; - - var keys = namedArgs.keys; - var attrs = namedArgs.value(); - var props = new _emberUtils.EmptyObject(); - var args = new _emberUtils.EmptyObject(); - - props[_emberGlimmerComponent.ARGS] = args; - - for (var i = 0, l = keys.length; i < l; i++) { - var _name = keys[i]; - var ref = namedArgs.get(_name); - var value = attrs[_name]; - - if (typeof value === 'function' && value[_emberGlimmerHelpersAction.ACTION]) { - attrs[_name] = value; - } else if (ref[_emberGlimmerUtilsReferences.UPDATE]) { - attrs[_name] = new MutableCell(ref, value); - } - - args[_name] = ref; - props[_name] = value; - } - - props.attrs = attrs; - - return { attrs: attrs, props: props }; - }; - - return ComponentArgs; - })(); - - exports.ComponentArgs = ComponentArgs; - - function mergeRestArg(namedMap, positionalValues, restArgName) { - var mergedNamed = _emberUtils.assign({}, namedMap); - mergedNamed[restArgName] = _glimmerRuntime.EvaluatedPositionalArgs.create(positionalValues); - return mergedNamed; - } - - function mergePositionalParams(namedMap, values, positionalParamNames) { - var mergedNamed = _emberUtils.assign({}, namedMap); - var length = Math.min(values.length, positionalParamNames.length); - for (var i = 0; i < length; i++) { - var _name2 = positionalParamNames[i]; - mergedNamed[_name2] = values[i]; - } - return mergedNamed; - } - - var REF = _emberUtils.symbol('REF'); - - var MutableCell = (function () { - function MutableCell(ref, value) { - babelHelpers.classCallCheck(this, MutableCell); - - this[_emberViews.MUTABLE_CELL] = true; - this[REF] = ref; - this.value = value; - } - - MutableCell.prototype.update = function update(val) { - this[REF][_emberGlimmerUtilsReferences.UPDATE](val); - }; - - return MutableCell; - })(); -}); -enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal', 'glimmer-reference', 'glimmer-runtime', 'ember-glimmer/utils/to-bool', 'ember-glimmer/helper'], function (exports, _emberUtils, _emberMetal, _glimmerReference, _glimmerRuntime, _emberGlimmerUtilsToBool, _emberGlimmerHelper) { - 'use strict'; - - var UPDATE = _emberUtils.symbol('UPDATE'); - - exports.UPDATE = UPDATE; - exports.NULL_REFERENCE = _glimmerRuntime.NULL_REFERENCE; - exports.UNDEFINED_REFERENCE = _glimmerRuntime.UNDEFINED_REFERENCE; - - // @abstract - // @implements PathReference - - var EmberPathReference = (function () { - function EmberPathReference() { - babelHelpers.classCallCheck(this, EmberPathReference); - } - - // @abstract - - // @abstract get tag() - // @abstract value() - - EmberPathReference.prototype.get = function get(key) { - return PropertyReference.create(this, key); - }; - - return EmberPathReference; - })(); - - var CachedReference = (function (_EmberPathReference) { - babelHelpers.inherits(CachedReference, _EmberPathReference); - - function CachedReference() { - babelHelpers.classCallCheck(this, CachedReference); - - _EmberPathReference.call(this); - this._lastRevision = null; - this._lastValue = null; - } - - // @implements PathReference - - CachedReference.prototype.value = function value() { - var tag = this.tag; - var _lastRevision = this._lastRevision; - var _lastValue = this._lastValue; - - if (!_lastRevision || !tag.validate(_lastRevision)) { - _lastValue = this._lastValue = this.compute(); - this._lastRevision = tag.value(); - } - - return _lastValue; - }; - - // @abstract compute() - return CachedReference; - })(EmberPathReference); - - exports.CachedReference = CachedReference; - - var RootReference = (function (_ConstReference) { - babelHelpers.inherits(RootReference, _ConstReference); - - function RootReference(value) { - babelHelpers.classCallCheck(this, RootReference); - - _ConstReference.call(this, value); - this.children = new _emberUtils.EmptyObject(); - } - - RootReference.prototype.get = function get(propertyKey) { - var ref = this.children[propertyKey]; - - if (!ref) { - ref = this.children[propertyKey] = new RootPropertyReference(this.inner, propertyKey); - } - - return ref; - }; - - return RootReference; - })(_glimmerReference.ConstReference); - - exports.RootReference = RootReference; - - var TwoWayFlushDetectionTag = undefined; - - if (true || false) { - TwoWayFlushDetectionTag = (function () { - function _class(tag, key, ref) { - babelHelpers.classCallCheck(this, _class); - - this.tag = tag; - this.parent = null; - this.key = key; - this.ref = ref; - } - - _class.prototype.value = function value() { - return this.tag.value(); - }; - - _class.prototype.validate = function validate(ticket) { - var parent = this.parent; - var key = this.key; - - var isValid = this.tag.validate(ticket); - - if (isValid && parent) { - _emberMetal.didRender(parent, key, this.ref); - } - - return isValid; - }; - - _class.prototype.didCompute = function didCompute(parent) { - this.parent = parent; - _emberMetal.didRender(parent, this.key, this.ref); - }; - - return _class; - })(); - } - - var PropertyReference = (function (_CachedReference) { - babelHelpers.inherits(PropertyReference, _CachedReference); - - function PropertyReference() { - babelHelpers.classCallCheck(this, PropertyReference); - - _CachedReference.apply(this, arguments); - } - - PropertyReference.create = function create(parentReference, propertyKey) { - if (_glimmerReference.isConst(parentReference)) { - return new RootPropertyReference(parentReference.value(), propertyKey); - } else { - return new NestedPropertyReference(parentReference, propertyKey); - } - }; - - PropertyReference.prototype.get = function get(key) { - return new NestedPropertyReference(this, key); - }; - - return PropertyReference; - })(CachedReference); - - exports.PropertyReference = PropertyReference; - - var RootPropertyReference = (function (_PropertyReference) { - babelHelpers.inherits(RootPropertyReference, _PropertyReference); - - function RootPropertyReference(parentValue, propertyKey) { - babelHelpers.classCallCheck(this, RootPropertyReference); - - _PropertyReference.call(this); - - this._parentValue = parentValue; - this._propertyKey = propertyKey; - - if (true || false) { - this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); - } else { - this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); - } - - if (true) { - _emberMetal.watchKey(parentValue, propertyKey); - } - } - - RootPropertyReference.prototype.compute = function compute() { - var _parentValue = this._parentValue; - var _propertyKey = this._propertyKey; - - if (true || false) { - this.tag.didCompute(_parentValue); - } - - return _emberMetal.get(_parentValue, _propertyKey); - }; - - RootPropertyReference.prototype[UPDATE] = function (value) { - _emberMetal.set(this._parentValue, this._propertyKey, value); - }; - - return RootPropertyReference; - })(PropertyReference); - - exports.RootPropertyReference = RootPropertyReference; - - var NestedPropertyReference = (function (_PropertyReference2) { - babelHelpers.inherits(NestedPropertyReference, _PropertyReference2); - - function NestedPropertyReference(parentReference, propertyKey) { - babelHelpers.classCallCheck(this, NestedPropertyReference); - - _PropertyReference2.call(this); - - var parentReferenceTag = parentReference.tag; - var parentObjectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - - this._parentReference = parentReference; - this._parentObjectTag = parentObjectTag; - this._propertyKey = propertyKey; - - if (true || false) { - var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); - this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); - } else { - this.tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); - } - } - - NestedPropertyReference.prototype.compute = function compute() { - var _parentReference = this._parentReference; - var _parentObjectTag = this._parentObjectTag; - var _propertyKey = this._propertyKey; - - var parentValue = _parentReference.value(); - - _parentObjectTag.update(_emberMetal.tagForProperty(parentValue, _propertyKey)); - - if (typeof parentValue === 'string' && _propertyKey === 'length') { - return parentValue.length; - } - - if (typeof parentValue === 'object' && parentValue) { - if (true) { - _emberMetal.watchKey(parentValue, _propertyKey); - } - - if (true || false) { - this.tag.didCompute(parentValue); - } - - return _emberMetal.get(parentValue, _propertyKey); - } else { - return undefined; - } - }; - - NestedPropertyReference.prototype[UPDATE] = function (value) { - var parent = this._parentReference.value(); - _emberMetal.set(parent, this._propertyKey, value); - }; - - return NestedPropertyReference; - })(PropertyReference); - - exports.NestedPropertyReference = NestedPropertyReference; - - var UpdatableReference = (function (_EmberPathReference2) { - babelHelpers.inherits(UpdatableReference, _EmberPathReference2); - - function UpdatableReference(value) { - babelHelpers.classCallCheck(this, UpdatableReference); - - _EmberPathReference2.call(this); - - this.tag = new _glimmerReference.DirtyableTag(); - this._value = value; - } - - UpdatableReference.prototype.value = function value() { - return this._value; - }; - - UpdatableReference.prototype.update = function update(value) { - var _value = this._value; - - if (value !== _value) { - this.tag.dirty(); - this._value = value; - } - }; - - return UpdatableReference; - })(EmberPathReference); - - exports.UpdatableReference = UpdatableReference; - - var UpdatablePrimitiveReference = (function (_UpdatableReference) { - babelHelpers.inherits(UpdatablePrimitiveReference, _UpdatableReference); - - function UpdatablePrimitiveReference() { - babelHelpers.classCallCheck(this, UpdatablePrimitiveReference); - - _UpdatableReference.apply(this, arguments); - } - - UpdatablePrimitiveReference.prototype.get = function get() { - return _glimmerRuntime.UNDEFINED_REFERENCE; - }; - - return UpdatablePrimitiveReference; - })(UpdatableReference); - - exports.UpdatablePrimitiveReference = UpdatablePrimitiveReference; - - var ConditionalReference = (function (_GlimmerConditionalReference) { - babelHelpers.inherits(ConditionalReference, _GlimmerConditionalReference); - - ConditionalReference.create = function create(reference) { - if (_glimmerReference.isConst(reference)) { - var value = reference.value(); - - if (_emberMetal.isProxy(value)) { - return new RootPropertyReference(value, 'isTruthy'); - } else { - return _glimmerRuntime.PrimitiveReference.create(_emberGlimmerUtilsToBool.default(value)); - } - } - - return new ConditionalReference(reference); - }; - - function ConditionalReference(reference) { - babelHelpers.classCallCheck(this, ConditionalReference); - - _GlimmerConditionalReference.call(this, reference); - - this.objectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([reference.tag, this.objectTag]); - } - - ConditionalReference.prototype.toBool = function toBool(predicate) { - if (_emberMetal.isProxy(predicate)) { - this.objectTag.update(_emberMetal.tagForProperty(predicate, 'isTruthy')); - return _emberMetal.get(predicate, 'isTruthy'); - } else { - this.objectTag.update(_emberMetal.tagFor(predicate)); - return _emberGlimmerUtilsToBool.default(predicate); - } - }; - - return ConditionalReference; - })(_glimmerRuntime.ConditionalReference); - - exports.ConditionalReference = ConditionalReference; - - var SimpleHelperReference = (function (_CachedReference2) { - babelHelpers.inherits(SimpleHelperReference, _CachedReference2); - - SimpleHelperReference.create = function create(helper, args) { - if (_glimmerReference.isConst(args)) { - var _ret = (function () { - var positional = args.positional; - var named = args.named; - - var positionalValue = positional.value(); - var namedValue = named.value(); - - _emberMetal.runInDebug(function () { - Object.freeze(positionalValue); - Object.freeze(namedValue); - }); - - var result = helper(positionalValue, namedValue); - - if (result === null) { - return { - v: _glimmerRuntime.NULL_REFERENCE - }; - } else if (result === undefined) { - return { - v: _glimmerRuntime.UNDEFINED_REFERENCE - }; - } else if (typeof result === 'object') { - return { - v: new RootReference(result) - }; - } else { - return { - v: _glimmerRuntime.PrimitiveReference.create(result) - }; - } - })(); - - if (typeof _ret === 'object') return _ret.v; - } else { - return new SimpleHelperReference(helper, args); - } - }; - - function SimpleHelperReference(helper, args) { - babelHelpers.classCallCheck(this, SimpleHelperReference); - - _CachedReference2.call(this); - - this.tag = args.tag; - this.helper = helper; - this.args = args; - } - - SimpleHelperReference.prototype.compute = function compute() { - var helper = this.helper; - var _args = this.args; - var positional = _args.positional; - var named = _args.named; - - var positionalValue = positional.value(); - var namedValue = named.value(); - - _emberMetal.runInDebug(function () { - Object.freeze(positionalValue); - Object.freeze(namedValue); - }); - - return helper(positionalValue, namedValue); - }; - - return SimpleHelperReference; - })(CachedReference); - - exports.SimpleHelperReference = SimpleHelperReference; - - var ClassBasedHelperReference = (function (_CachedReference3) { - babelHelpers.inherits(ClassBasedHelperReference, _CachedReference3); - - ClassBasedHelperReference.create = function create(helperClass, vm, args) { - var instance = helperClass.create(); - vm.newDestroyable(instance); - return new ClassBasedHelperReference(instance, args); - }; - - function ClassBasedHelperReference(instance, args) { - babelHelpers.classCallCheck(this, ClassBasedHelperReference); - - _CachedReference3.call(this); - - this.tag = _glimmerReference.combine([instance[_emberGlimmerHelper.RECOMPUTE_TAG], args.tag]); - this.instance = instance; - this.args = args; - } - - ClassBasedHelperReference.prototype.compute = function compute() { - var instance = this.instance; - var _args2 = this.args; - var positional = _args2.positional; - var named = _args2.named; - - var positionalValue = positional.value(); - var namedValue = named.value(); - - _emberMetal.runInDebug(function () { - Object.freeze(positionalValue); - Object.freeze(namedValue); - }); - - return instance.compute(positionalValue, namedValue); - }; - - return ClassBasedHelperReference; - })(CachedReference); - - exports.ClassBasedHelperReference = ClassBasedHelperReference; - - var InternalHelperReference = (function (_CachedReference4) { - babelHelpers.inherits(InternalHelperReference, _CachedReference4); - - function InternalHelperReference(helper, args) { - babelHelpers.classCallCheck(this, InternalHelperReference); - - _CachedReference4.call(this); - - this.tag = args.tag; - this.helper = helper; - this.args = args; - } - - // @implements PathReference - - InternalHelperReference.prototype.compute = function compute() { - var helper = this.helper; - var args = this.args; - - return helper(args); - }; - - return InternalHelperReference; - })(CachedReference); - - exports.InternalHelperReference = InternalHelperReference; - - var UnboundReference = (function (_ConstReference2) { - babelHelpers.inherits(UnboundReference, _ConstReference2); - - function UnboundReference() { - babelHelpers.classCallCheck(this, UnboundReference); - - _ConstReference2.apply(this, arguments); - } - - UnboundReference.create = function create(value) { - if (value === null) { - return _glimmerRuntime.NULL_REFERENCE; - } else if (value === undefined) { - return _glimmerRuntime.UNDEFINED_REFERENCE; - } else if (typeof value === 'object') { - return new UnboundReference(value); - } else { - return _glimmerRuntime.PrimitiveReference.create(value); - } - }; - - UnboundReference.prototype.get = function get(key) { - return new UnboundReference(_emberMetal.get(this.inner, key)); - }; - - return UnboundReference; - })(_glimmerReference.ConstReference); - - exports.UnboundReference = UnboundReference; -}); -enifed('ember-glimmer/utils/string', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - - 'use strict'; - - exports.getSafeString = getSafeString; - exports.escapeExpression = escapeExpression; - exports.htmlSafe = htmlSafe; - exports.isHTMLSafe = isHTMLSafe; - - var SafeString = (function () { - function SafeString(string) { - babelHelpers.classCallCheck(this, SafeString); - - this.string = string; - } - - SafeString.prototype.toString = function toString() { - return '' + this.string; - }; - - SafeString.prototype.toHTML = function toHTML() { - return this.toString(); - }; - - return SafeString; - })(); - - exports.SafeString = SafeString; - - function getSafeString() { - _emberMetal.deprecate('Ember.Handlebars.SafeString is deprecated in favor of Ember.String.htmlSafe', !true, { - id: 'ember-htmlbars.ember-handlebars-safestring', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_use-ember-string-htmlsafe-over-ember-handlebars-safestring' - }); - - return SafeString; - } - - var escape = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - // jscs:disable - "'": ''', - // jscs:enable - '`': '`', - '=': '=' - }; - - var possible = /[&<>"'`=]/; - var badChars = /[&<>"'`=]/g; - - function escapeChar(chr) { - return escape[chr]; - } - - function escapeExpression(string) { - if (typeof string !== 'string') { - // don't escape SafeStrings, since they're already safe - if (string && string.toHTML) { - return string.toHTML(); - } else if (string == null) { - return ''; - } else if (!string) { - return string + ''; - } - - // Force a string conversion as this will be done by the append regardless and - // the regex test will do this transparently behind the scenes, causing issues if - // an object's to string has escaped characters in it. - string = '' + string; - } - - if (!possible.test(string)) { - return string; - } - return string.replace(badChars, escapeChar); - } - - /** - Mark a string as safe for unescaped output with Ember templates. If you - return HTML from a helper, use this function to - ensure Ember's rendering layer does not escape the HTML. - - ```javascript - Ember.String.htmlSafe('
    someString
    ') - ``` - - @method htmlSafe - @for Ember.String - @static - @return {Handlebars.SafeString} A string that will not be HTML escaped by Handlebars. - @public - */ - - function htmlSafe(str) { - if (str === null || str === undefined) { - str = ''; - } else if (typeof str !== 'string') { - str = '' + str; - } - return new SafeString(str); - } - - /** - Detects if a string was decorated using `Ember.String.htmlSafe`. - - ```javascript - var plainString = 'plain string', - safeString = Ember.String.htmlSafe('
    someValue
    '); - - Ember.String.isHTMLSafe(plainString); // false - Ember.String.isHTMLSafe(safeString); // true - ``` - - @method isHTMLSafe - @for Ember.String - @static - @return {Boolean} `true` if the string was decorated with `htmlSafe`, `false` otherwise. - @public - */ - - function isHTMLSafe(str) { - return str && typeof str.toHTML === 'function'; - } -}); -enifed('ember-glimmer/utils/to-bool', ['exports', 'ember-runtime', 'ember-metal'], function (exports, _emberRuntime, _emberMetal) { - 'use strict'; - - exports.default = toBool; - - function toBool(predicate) { - if (!predicate) { - return false; - } - - if (predicate === true) { - return true; - } - - if (_emberRuntime.isArray(predicate)) { - return _emberMetal.get(predicate, 'length') !== 0; - } - - return true; - } -}); -enifed('ember-glimmer/views/outlet', ['exports', 'ember-utils', 'glimmer-reference', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _glimmerReference, _emberEnvironment, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - var OutletStateReference = (function () { - function OutletStateReference(outletView) { - babelHelpers.classCallCheck(this, OutletStateReference); - - this.outletView = outletView; - this.tag = outletView._tag; - } - - // So this is a relic of the past that SHOULD go away - // in 3.0. Preferably it is deprecated in the release that - // follows the Glimmer release. - - OutletStateReference.prototype.get = function get(key) { - return new ChildOutletStateReference(this, key); - }; - - OutletStateReference.prototype.value = function value() { - return this.outletView.outletState; - }; - - OutletStateReference.prototype.getOrphan = function getOrphan(name) { - return new OrphanedOutletStateReference(this, name); - }; - - OutletStateReference.prototype.update = function update(state) { - this.outletView.setOutletState(state); - }; - - return OutletStateReference; - })(); - - var OrphanedOutletStateReference = (function (_OutletStateReference) { - babelHelpers.inherits(OrphanedOutletStateReference, _OutletStateReference); - - function OrphanedOutletStateReference(root, name) { - babelHelpers.classCallCheck(this, OrphanedOutletStateReference); - - _OutletStateReference.call(this, root.outletView); - this.root = root; - this.name = name; - } - - OrphanedOutletStateReference.prototype.value = function value() { - var rootState = this.root.value(); - - var orphans = rootState.outlets.main.outlets.__ember_orphans__; - - if (!orphans) { - return null; - } - - var matched = orphans.outlets[this.name]; - - if (!matched) { - return null; - } - - var state = new _emberUtils.EmptyObject(); - state[matched.render.outlet] = matched; - matched.wasUsed = true; - return { outlets: state }; - }; - - return OrphanedOutletStateReference; - })(OutletStateReference); - - var ChildOutletStateReference = (function () { - function ChildOutletStateReference(parent, key) { - babelHelpers.classCallCheck(this, ChildOutletStateReference); - - this.parent = parent; - this.key = key; - this.tag = parent.tag; - } - - ChildOutletStateReference.prototype.get = function get(key) { - return new ChildOutletStateReference(this, key); - }; - - ChildOutletStateReference.prototype.value = function value() { - return this.parent.value()[this.key]; - }; - - return ChildOutletStateReference; - })(); - - var OutletView = (function () { - OutletView.extend = function extend(injections) { - return (function (_OutletView) { - babelHelpers.inherits(_class, _OutletView); - - function _class() { - babelHelpers.classCallCheck(this, _class); - - _OutletView.apply(this, arguments); - } - - _class.create = function create(options) { - if (options) { - return _OutletView.create.call(this, _emberUtils.assign({}, injections, options)); - } else { - return _OutletView.create.call(this, injections); - } - }; - - return _class; - })(OutletView); - }; - - OutletView.reopenClass = function reopenClass(injections) { - _emberUtils.assign(this, injections); - }; - - OutletView.create = function create(options) { - var _environment = options._environment; - var renderer = options.renderer; - var template = options.template; - - var owner = options[_emberUtils.OWNER]; - return new OutletView(_environment, renderer, owner, template); - }; - - function OutletView(_environment, renderer, owner, template) { - babelHelpers.classCallCheck(this, OutletView); - - this._environment = _environment; - this.renderer = renderer; - this.owner = owner; - this.template = template; - this.outletState = null; - this._tag = new _glimmerReference.DirtyableTag(); - } - - OutletView.prototype.appendTo = function appendTo(selector) { - var env = this._environment || _emberEnvironment.environment; - var target = undefined; - - if (env.hasDOM) { - target = typeof selector === 'string' ? document.querySelector(selector) : selector; - } else { - target = selector; - } - - _emberMetal.run.schedule('render', this.renderer, 'appendOutletView', this, target); - }; - - OutletView.prototype.rerender = function rerender() {}; - - OutletView.prototype.setOutletState = function setOutletState(state) { - this.outletState = { - outlets: { - main: state - }, - render: { - owner: undefined, - into: undefined, - outlet: 'main', - name: '-top-level', - controller: undefined, - ViewClass: undefined, - template: undefined - } - }; - this._tag.dirty(); - }; - - OutletView.prototype.toReference = function toReference() { - return new OutletStateReference(this); - }; - - OutletView.prototype.destroy = function destroy() {}; - - return OutletView; - })(); - - exports.default = OutletView; -}); -enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) { - 'use strict'; - - exports.default = alias; - exports.AliasedProperty = AliasedProperty; - - function alias(altKey) { - return new AliasedProperty(altKey); - } - - function AliasedProperty(altKey) { - this.isDescriptor = true; - this.altKey = altKey; - this._dependentKeys = [altKey]; - } - - AliasedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); - - AliasedProperty.prototype.setup = function (obj, keyName) { - _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName); - var meta = _emberMetalMeta.meta(obj); - if (meta.peekWatching(keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; - - AliasedProperty.prototype._addDependentKeyIfMissing = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (!meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; - - AliasedProperty.prototype._removeDependentKeyIfAdded = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; - - AliasedProperty.prototype.willWatch = AliasedProperty.prototype._addDependentKeyIfMissing; - AliasedProperty.prototype.didUnwatch = AliasedProperty.prototype._removeDependentKeyIfAdded; - AliasedProperty.prototype.teardown = AliasedProperty.prototype._removeDependentKeyIfAdded; - - AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) { - this._addDependentKeyIfMissing(obj, keyName); - - return _emberMetalProperty_get.get(obj, this.altKey); - }; - - AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) { - return _emberMetalProperty_set.set(obj, this.altKey, value); - }; - - AliasedProperty.prototype.readOnly = function () { - this.set = AliasedProperty_readOnlySet; - return this; - }; - - function AliasedProperty_readOnlySet(obj, keyName, value) { - throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); - } - - AliasedProperty.prototype.oneWay = function () { - this.set = AliasedProperty_oneWaySet; - return this; - }; - - function AliasedProperty_oneWaySet(obj, keyName, value) { - _emberMetalProperties.defineProperty(obj, keyName, null); - return _emberMetalProperty_set.set(obj, keyName, value); - } - - // Backwards compatibility with Ember Data. - AliasedProperty.prototype._meta = undefined; - AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta; -}); -enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) { - 'use strict'; - - exports.bind = bind; - - /** - @module ember - @submodule ember-metal - */ - - // .......................................................... - // BINDING - // - - function Binding(toPath, fromPath) { - // Configuration - this._from = fromPath; - this._to = toPath; - this._oneWay = undefined; - - // State - this._direction = undefined; - this._readyToSync = undefined; - this._fromObj = undefined; - this._fromPath = undefined; - this._toObj = undefined; - } - - /** - @class Binding - @namespace Ember - @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding - @public - */ - - Binding.prototype = { - /** - This copies the Binding so it can be connected to another object. - @method copy - @return {Ember.Binding} `this` - @public - */ - copy: function () { - var copy = new Binding(this._to, this._from); - if (this._oneWay) { - copy._oneWay = true; - } - return copy; - }, - - // .......................................................... - // CONFIG - // - - /** - This will set `from` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method from - @param {String} path The property path to connect to. - @return {Ember.Binding} `this` - @public - */ - from: function (path) { - this._from = path; - return this; - }, - - /** - This will set the `to` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method to - @param {String|Tuple} path A property path or tuple. - @return {Ember.Binding} `this` - @public - */ - to: function (path) { - this._to = path; - return this; - }, - - /** - Configures the binding as one way. A one-way binding will relay changes - on the `from` side to the `to` side, but not the other way around. This - means that if you change the `to` side directly, the `from` side may have - a different value. - @method oneWay - @return {Ember.Binding} `this` - @public - */ - oneWay: function () { - this._oneWay = true; - return this; - }, - - /** - @method toString - @return {String} string representation of binding - @public - */ - toString: function () { - var oneWay = this._oneWay ? '[oneWay]' : ''; - return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; - }, - - // .......................................................... - // CONNECT AND SYNC - // - - /** - Attempts to connect this binding instance so that it can receive and relay - changes. This method will raise an exception if you have not set the - from/to properties yet. - @method connect - @param {Object} obj The root object for this binding. - @return {Ember.Binding} `this` - @public - */ - connect: function (obj) { - _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.connect()', !!obj); - - var fromObj = undefined, - fromPath = undefined, - possibleGlobal = undefined; - - // If the binding's "from" path could be interpreted as a global, verify - // whether the path refers to a global or not by consulting `Ember.lookup`. - if (_emberMetalPath_cache.isGlobalPath(this._from)) { - var _name = _emberMetalPath_cache.getFirstKey(this._from); - possibleGlobal = _emberEnvironment.context.lookup[_name]; - - if (possibleGlobal) { - fromObj = possibleGlobal; - fromPath = _emberMetalPath_cache.getTailPath(this._from); - } - } - - if (fromObj === undefined) { - fromObj = obj; - fromPath = this._from; - } - - _emberMetalProperty_set.trySet(obj, this._to, _emberMetalProperty_get.get(fromObj, fromPath)); - - // Add an observer on the object to be notified when the binding should be updated. - _emberMetalObserver.addObserver(fromObj, fromPath, this, 'fromDidChange'); - - // If the binding is a two-way binding, also set up an observer on the target. - if (!this._oneWay) { - _emberMetalObserver.addObserver(obj, this._to, this, 'toDidChange'); - } - - _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect'); - - fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); - - this._readyToSync = true; - this._fromObj = fromObj; - this._fromPath = fromPath; - this._toObj = obj; - - return this; - }, - - /** - Disconnects the binding instance. Changes will no longer be relayed. You - will not usually need to call this method. - @method disconnect - @return {Ember.Binding} `this` - @public - */ - disconnect: function () { - _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); - - // Remove an observer on the object so we're no longer notified of - // changes that should update bindings. - _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); - - // If the binding is two-way, remove the observer from the target as well. - if (!this._oneWay) { - _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); - } - - this._readyToSync = false; // Disable scheduled syncs... - return this; - }, - - // .......................................................... - // PRIVATE - // - - /* Called when the from side changes. */ - fromDidChange: function (target) { - this._scheduleSync('fwd'); - }, - - /* Called when the to side changes. */ - toDidChange: function (target) { - this._scheduleSync('back'); - }, - - _scheduleSync: function (dir) { - var existingDir = this._direction; - - // If we haven't scheduled the binding yet, schedule it. - if (existingDir === undefined) { - _emberMetalRun_loop.default.schedule('sync', this, '_sync'); - this._direction = dir; - } - - // If both a 'back' and 'fwd' sync have been scheduled on the same object, - // default to a 'fwd' sync so that it remains deterministic. - if (existingDir === 'back' && dir === 'fwd') { - this._direction = 'fwd'; - } - }, - - _sync: function () { - var log = _emberEnvironment.ENV.LOG_BINDINGS; - - var toObj = this._toObj; - - // Don't synchronize destroyed objects or disconnected bindings. - if (toObj.isDestroyed || !this._readyToSync) { - return; - } - - // Get the direction of the binding for the object we are - // synchronizing from. - var direction = this._direction; - - var fromObj = this._fromObj; - var fromPath = this._fromPath; - - this._direction = undefined; - - // If we're synchronizing from the remote object... - if (direction === 'fwd') { - var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); - if (log) { - _emberConsole.default.log(' ', this.toString(), '->', fromValue, fromObj); - } - if (this._oneWay) { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - } else { - _emberMetalObserver._suspendObserver(toObj, this._to, this, 'toDidChange', function () { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - }); - } - // If we're synchronizing *to* the remote object. - } else if (direction === 'back') { - var toValue = _emberMetalProperty_get.get(toObj, this._to); - if (log) { - _emberConsole.default.log(' ', this.toString(), '<-', toValue, toObj); - } - _emberMetalObserver._suspendObserver(fromObj, fromPath, this, 'fromDidChange', function () { - _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); - }); - } - } - - }; - - function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { - var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; - var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; - var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - - var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; - _emberMetalDebug.deprecate(objectInfo + deprecateGlobalMessage, !deprecateGlobal, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - _emberMetalDebug.deprecate(objectInfo + deprecateOneWayMessage, !deprecateOneWay, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - _emberMetalDebug.deprecate(objectInfo + deprecateAliasMessage, !deprecateAlias, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - } - - function mixinProperties(to, from) { - for (var key in from) { - if (from.hasOwnProperty(key)) { - to[key] = from[key]; - } - } - } - - mixinProperties(Binding, { - - /* - See `Ember.Binding.from`. - @method from - @static - */ - from: function (from) { - var C = this; - return new C(undefined, from); - }, - - /* - See `Ember.Binding.to`. - @method to - @static - */ - to: function (to) { - var C = this; - return new C(to, undefined); - } - }); - /** - An `Ember.Binding` connects the properties of two objects so that whenever - the value of one property changes, the other property will be changed also. - - ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. - - You do not usually create Binding objects directly but instead describe - bindings in your class or object definition using automatic binding - detection. - - Properties ending in a `Binding` suffix will be converted to `Ember.Binding` - instances. The value of this property should be a string representing a path - to another object or a custom binding instance created using Binding helpers - (see "One Way Bindings"): - - ``` - valueBinding: "MyApp.someController.title" - ``` - - This will create a binding from `MyApp.someController.title` to the `value` - property of your object instance automatically. Now the two values will be - kept in sync. - - ## One Way Bindings - - One especially useful binding customization you can use is the `oneWay()` - helper. This helper tells Ember that you are only interested in - receiving changes on the object you are binding from. For example, if you - are binding to a preference and you want to be notified if the preference - has changed, but your object will not be changing the preference itself, you - could do: - - ``` - bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") - ``` - - This way if the value of `MyApp.preferencesController.bigTitles` changes the - `bigTitles` property of your object will change also. However, if you - change the value of your `bigTitles` property, it will not update the - `preferencesController`. - - One way bindings are almost twice as fast to setup and twice as fast to - execute because the binding only has to worry about changes to one side. - - You should consider using one way bindings anytime you have an object that - may be created frequently and you do not intend to change a property; only - to monitor it for changes (such as in the example above). - - ## Adding Bindings Manually - - All of the examples above show you how to configure a custom binding, but the - result of these customizations will be a binding template, not a fully active - Binding instance. The binding will actually become active only when you - instantiate the object the binding belongs to. It is useful, however, to - understand what actually happens when the binding is activated. - - For a binding to function it must have at least a `from` property and a `to` - property. The `from` property path points to the object/key that you want to - bind from while the `to` path points to the object/key you want to bind to. - - When you define a custom binding, you are usually describing the property - you want to bind from (such as `MyApp.someController.value` in the examples - above). When your object is created, it will automatically assign the value - you want to bind `to` based on the name of your binding key. In the - examples above, during init, Ember objects will effectively call - something like this on your binding: - - ```javascript - binding = Ember.Binding.from("valueBinding").to("value"); - ``` - - This creates a new binding instance based on the template you provide, and - sets the to path to the `value` property of the new object. Now that the - binding is fully configured with a `from` and a `to`, it simply needs to be - connected to become active. This is done through the `connect()` method: - - ```javascript - binding.connect(this); - ``` - - Note that when you connect a binding you pass the object you want it to be - connected to. This object will be used as the root for both the from and - to side of the binding when inspecting relative paths. This allows the - binding to be automatically inherited by subclassed objects as well. - - This also allows you to bind between objects using the paths you declare in - `from` and `to`: - - ```javascript - // Example 1 - binding = Ember.Binding.from("App.someObject.value").to("value"); - binding.connect(this); - - // Example 2 - binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); - binding.connect(this); - ``` - - Now that the binding is connected, it will observe both the from and to side - and relay changes. - - If you ever needed to do so (you almost never will, but it is useful to - understand this anyway), you could manually create an active binding by - using the `Ember.bind()` helper method. (This is the same method used by - to setup your bindings on objects): - - ```javascript - Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); - ``` - - Both of these code fragments have the same effect as doing the most friendly - form of binding creation like so: - - ```javascript - MyApp.anotherObject = Ember.Object.create({ - valueBinding: "MyApp.someController.value", - - // OTHER CODE FOR THIS OBJECT... - }); - ``` - - Ember's built in binding creation method makes it easy to automatically - create bindings for you. You should always use the highest-level APIs - available, even if you understand how it works underneath. - - @class Binding - @namespace Ember - @since Ember 0.9 - @public - */ - // Ember.Binding = Binding; ES6TODO: where to put this? - - /** - Global helper method to create a new binding. Just pass the root object - along with a `to` and `from` path to create and connect the binding. - - @method bind - @for Ember - @param {Object} obj The root object of the transform. - @param {String} to The path to the 'to' side of the binding. - Must be relative to obj. - @param {String} from The path to the 'from' side of the binding. - Must be relative to obj or a global path. - @return {Ember.Binding} binding instance - @public - */ - - function bind(obj, to, from) { - return new Binding(to, from).connect(obj); - } - - exports.Binding = Binding; -}); -enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; - - var Cache = (function () { - function Cache(limit, func, key, store) { - babelHelpers.classCallCheck(this, Cache); - - this.size = 0; - this.misses = 0; - this.hits = 0; - this.limit = limit; - this.func = func; - this.key = key; - this.store = store || new DefaultStore(); - } - - Cache.prototype.get = function get(obj) { - var key = this.key === undefined ? obj : this.key(obj); - var value = this.store.get(key); - if (value === undefined) { - this.misses++; - value = this._set(key, this.func(obj)); - } else if (value === _emberMetalMeta.UNDEFINED) { - this.hits++; - value = undefined; - } else { - this.hits++; - // nothing to translate - } - - return value; - }; - - Cache.prototype.set = function set(obj, value) { - var key = this.key === undefined ? obj : this.key(obj); - return this._set(key, value); - }; - - Cache.prototype._set = function _set(key, value) { - if (this.limit > this.size) { - this.size++; - if (value === undefined) { - this.store.set(key, _emberMetalMeta.UNDEFINED); - } else { - this.store.set(key, value); - } - } - - return value; - }; - - Cache.prototype.purge = function purge() { - this.store.clear(); - this.size = 0; - this.hits = 0; - this.misses = 0; - }; - - return Cache; - })(); - - exports.default = Cache; - - var DefaultStore = (function () { - function DefaultStore() { - babelHelpers.classCallCheck(this, DefaultStore); - - this.data = new _emberUtils.EmptyObject(); - } - - DefaultStore.prototype.get = function get(key) { - return this.data[key]; - }; - - DefaultStore.prototype.set = function set(key, value) { - this.data[key] = value; - }; - - DefaultStore.prototype.clear = function clear() { - this.data = new _emberUtils.EmptyObject(); - }; - - return DefaultStore; - })(); -}); -enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalWatch_path) { - 'use strict'; - - exports.finishChains = finishChains; - - var FIRST_KEY = /^([^\.]+)/; - - function firstKey(path) { - return path.match(FIRST_KEY)[0]; - } - - function isObject(obj) { - return typeof obj === 'object' && obj; - } - - function isVolatile(obj) { - return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); - } - - function ChainWatchers() { - // chain nodes that reference a key in this obj by key - // we only create ChainWatchers when we are going to add them - // so create this upfront - this.chains = new _emberUtils.EmptyObject(); - } - - ChainWatchers.prototype = { - add: function (key, node) { - var nodes = this.chains[key]; - if (nodes === undefined) { - this.chains[key] = [node]; - } else { - nodes.push(node); - } - }, - - remove: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - nodes.splice(i, 1); - break; - } - } - } - }, - - has: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - return true; - } - } - } - return false; - }, - - revalidateAll: function () { - for (var key in this.chains) { - this.notify(key, true, undefined); - } - }, - - revalidate: function (key) { - this.notify(key, true, undefined); - }, - - // key: the string key that is part of a path changed - // revalidate: boolean; the chains that are watching this value should revalidate - // callback: function that will be called with the object and path that - // will be/are invalidated by this key change, depending on - // whether the revalidate flag is passed - notify: function (key, revalidate, callback) { - var nodes = this.chains[key]; - if (nodes === undefined || nodes.length === 0) { - return; - } - - var affected = undefined; - - if (callback) { - affected = []; - } - - for (var i = 0; i < nodes.length; i++) { - nodes[i].notify(revalidate, affected); - } - - if (callback === undefined) { - return; - } - - // we gather callbacks so we don't notify them during revalidation - for (var i = 0; i < affected.length; i += 2) { - var obj = affected[i]; - var path = affected[i + 1]; - callback(obj, path); - } - } - }; - - function makeChainWatcher() { - return new ChainWatchers(); - } - - function addChainWatcher(obj, keyName, node) { - var m = _emberMetalMeta.meta(obj); - m.writableChainWatchers(makeChainWatcher).add(keyName, node); - _emberMetalWatch_key.watchKey(obj, keyName, m); - } - - function removeChainWatcher(obj, keyName, node, _meta) { - if (!isObject(obj)) { - return; - } - - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (!meta || !meta.readableChainWatchers()) { - return; - } - - // make meta writable - meta = _emberMetalMeta.meta(obj); - - meta.readableChainWatchers().remove(keyName, node); - - _emberMetalWatch_key.unwatchKey(obj, keyName, meta); - } - - // A ChainNode watches a single key on an object. If you provide a starting - // value for the key then the node won't actually watch it. For a root node - // pass null for parent and key and object for value. - function ChainNode(parent, key, value) { - this._parent = parent; - this._key = key; - - // _watching is true when calling get(this._parent, this._key) will - // return the value of this node. - // - // It is false for the root of a chain (because we have no parent) - // and for global paths (because the parent node is the object with - // the observer on it) - this._watching = value === undefined; - - this._chains = undefined; - this._object = undefined; - this.count = 0; - - this._value = value; - this._paths = {}; - if (this._watching) { - var obj = parent.value(); - - if (!isObject(obj)) { - return; - } - - this._object = obj; - - addChainWatcher(this._object, this._key, this); - } - } - - function lazyGet(obj, key) { - if (!isObject(obj)) { - return; - } - - var meta = _emberMetalMeta.peekMeta(obj); - - // check if object meant only to be a prototype - if (meta && meta.proto === obj) { - return; - } - - // Use `get` if the return value is an EachProxy or an uncacheable value. - if (isVolatile(obj[key])) { - return _emberMetalProperty_get.get(obj, key); - // Otherwise attempt to get the cached value of the computed property - } else { - var cache = meta.readableCache(); - if (cache && key in cache) { - return cache[key]; - } - } - } - - ChainNode.prototype = { - value: function () { - if (this._value === undefined && this._watching) { - var obj = this._parent.value(); - this._value = lazyGet(obj, this._key); - } - return this._value; - }, - - destroy: function () { - if (this._watching) { - var obj = this._object; - if (obj) { - removeChainWatcher(obj, this._key, this); - } - this._watching = false; // so future calls do nothing - } - }, - - // copies a top level object only - copy: function (obj) { - var ret = new ChainNode(null, null, obj); - var paths = this._paths; - var path = undefined; - - for (path in paths) { - // this check will also catch non-number vals. - if (paths[path] <= 0) { - continue; - } - ret.add(path); - } - return ret; - }, - - // called on the root node of a chain to setup watchers on the specified - // path. - add: function (path) { - var paths = this._paths; - paths[path] = (paths[path] || 0) + 1; - - var key = firstKey(path); - var tail = path.slice(key.length + 1); - - this.chain(key, tail); - }, - - // called on the root node of a chain to teardown watcher on the specified - // path - remove: function (path) { - var paths = this._paths; - if (paths[path] > 0) { - paths[path]--; - } - - var key = firstKey(path); - var tail = path.slice(key.length + 1); - - this.unchain(key, tail); - }, - - chain: function (key, path) { - var chains = this._chains; - var node = undefined; - if (chains === undefined) { - chains = this._chains = new _emberUtils.EmptyObject(); - } else { - node = chains[key]; - } - - if (node === undefined) { - node = chains[key] = new ChainNode(this, key, undefined); - } - - node.count++; // count chains... - - // chain rest of path if there is one - if (path) { - key = firstKey(path); - path = path.slice(key.length + 1); - node.chain(key, path); - } - }, - - unchain: function (key, path) { - var chains = this._chains; - var node = chains[key]; - - // unchain rest of path first... - if (path && path.length > 1) { - var nextKey = firstKey(path); - var nextPath = path.slice(nextKey.length + 1); - node.unchain(nextKey, nextPath); - } - - // delete node if needed. - node.count--; - if (node.count <= 0) { - chains[node._key] = undefined; - node.destroy(); - } - }, - - notify: function (revalidate, affected) { - if (revalidate && this._watching) { - var parentValue = this._parent.value(); - - if (parentValue !== this._object) { - if (this._object) { - removeChainWatcher(this._object, this._key, this); - } - - if (isObject(parentValue)) { - this._object = parentValue; - addChainWatcher(parentValue, this._key, this); - } else { - this._object = undefined; - } - } - this._value = undefined; - } - - // then notify chains... - var chains = this._chains; - var node = undefined; - if (chains) { - for (var key in chains) { - node = chains[key]; - if (node !== undefined) { - node.notify(revalidate, affected); - } - } - } - - if (affected && this._parent) { - this._parent.populateAffected(this._key, 1, affected); - } - }, - - populateAffected: function (path, depth, affected) { - if (this._key) { - path = this._key + '.' + path; - } - - if (this._parent) { - this._parent.populateAffected(path, depth + 1, affected); - } else { - if (depth > 1) { - affected.push(this.value(), path); - } - } - } - }; - - function finishChains(obj) { - // We only create meta if we really have to - var m = _emberMetalMeta.peekMeta(obj); - if (m) { - m = _emberMetalMeta.meta(obj); - - // finish any current chains node watchers that reference obj - var chainWatchers = m.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidateAll(); - } - // ensure that if we have inherited any chains they have been - // copied onto our own meta. - if (m.readableChains()) { - m.writableChains(_emberMetalWatch_path.makeChainNode); - } - } - } - - exports.removeChainWatcher = removeChainWatcher; - exports.ChainNode = ChainNode; -}); -enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) { - 'use strict'; - - exports.default = computed; - - /** - @module ember - @submodule ember-metal - */ - - var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; - - /** - A computed property transforms an object literal with object's accessor function(s) 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 - `fullName` - by calling - `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter 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 - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', function() { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }) - }); - - let 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 by providing additional function (`set`) in hash argument. - If you try to set a computed property, it will try to invoke setter accessor function with the key and - value you want to set it to as arguments. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }, - set(key, value) { - let [firstName, lastName] = value.split(' '); - - this.set('firstName', firstName); - this.set('lastName', lastName); - - return value; - } - }) - }); - - let person = Person.create(); - - person.set('fullName', 'Peter Wagenet'); - person.get('firstName'); // 'Peter' - person.get('lastName'); // 'Wagenet' - ``` - - You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined. - - You can also mark computed property as `.readOnly()` and block all attempts to set it. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'); - let lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - } - }).readOnly() - }); - - let person = Person.create(); - person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX> - ``` - - Additional resources: - - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md) - - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax) - - @class ComputedProperty - @namespace Ember - @public - */ - function ComputedProperty(config, opts) { - this.isDescriptor = true; - if (typeof config === 'function') { - this._getter = config; - } else { - _emberMetalDebug.assert('Ember.computed expects a function or an object as last argument.', typeof config === 'object' && !Array.isArray(config)); - _emberMetalDebug.assert('Config object passed to an Ember.computed can only contain `get` or `set` keys.', (function () { - var keys = Object.keys(config); - for (var i = 0; i < keys.length; i++) { - if (keys[i] !== 'get' && keys[i] !== 'set') { - return false; - } - } - return true; - })()); - this._getter = config.get; - this._setter = config.set; - } - _emberMetalDebug.assert('Computed properties must receive a getter or a setter, you passed none.', !!this._getter || !!this._setter); - this._dependentKeys = undefined; - this._suspended = undefined; - this._meta = undefined; - this._volatile = false; - this._dependentKeys = opts && opts.dependentKeys; - this._readOnly = false; - } - - ComputedProperty.prototype = new _emberMetalProperties.Descriptor(); - ComputedProperty.prototype.constructor = ComputedProperty; - - var ComputedPropertyPrototype = ComputedProperty.prototype; - - /** - 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. - - It also does not automatically fire any change events. You must manually notify - any changes if you want to observe this property. - - Dependency keys have no effect on volatile properties as they are for cache - invalidation and notification when cached value is invalidated. - - ```javascript - let outsideService = Ember.Object.extend({ - value: Ember.computed(function() { - return OutsideService.getValue(); - }).volatile() - }).create(); - ``` - - @method volatile - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.volatile = function () { - this._volatile = true; - 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 - let Person = Ember.Object.extend({ - guid: Ember.computed(function() { - return 'guid-guid-guid'; - }).readOnly() - }); - - let person = Person.create(); - - person.set('guid', 'new-guid'); // will throw an exception - ``` - - @method readOnly - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.readOnly = function () { - this._readOnly = true; - _emberMetalDebug.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 - let President = Ember.Object.extend({ - fullName: Ember.computed(function() { - return this.get('firstName') + ' ' + this.get('lastName'); - - // Tell Ember that this computed property depends on firstName - // and lastName - }).property('firstName', 'lastName') - }); - - let 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 = []; - - function addArg(property) { - _emberMetalDebug.warn('Dependent keys containing @each only work one level deep. ' + ('You used the key "' + property + '" which is invalid. ') + 'Please create an intermediary computed property.', DEEP_EACH_REGEX.test(property) === false, { id: 'ember-metal.computed-deep-each' }); - args.push(property); - } - - for (var i = 0; i < arguments.length; 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: Ember.computed(function() { - let personId = this.get('personId'); - return App.Person.create({ id: personId }); - }).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; - } - }; - - // invalidate cache when CP key changes - 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._volatile || this._suspended === obj) { - return; - } - - // don't create objects just to invalidate - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta || meta.source !== obj) { - return; - } - - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - cache[keyName] = undefined; - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; - - ComputedPropertyPrototype.get = function (obj, keyName) { - if (this._volatile) { - return this._getter.call(obj, keyName); - } - - var meta = _emberMetalMeta.meta(obj); - var cache = meta.writableCache(); - - var result = cache[keyName]; - if (result === _emberMetalMeta.UNDEFINED) { - return undefined; - } else if (result !== undefined) { - return result; - } - - var ret = this._getter.call(obj, keyName); - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } - - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - - return ret; - }; - - ComputedPropertyPrototype.set = function computedPropertySetEntry(obj, keyName, value) { - if (this._readOnly) { - this._throwReadOnlyError(obj, keyName); - } - - if (!this._setter) { - return this.clobberSet(obj, keyName, value); - } - - if (this._volatile) { - return this.volatileSet(obj, keyName, value); - } - - return this.setWithSuspend(obj, keyName, value); - }; - - ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) { - throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj)); - }; - - ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) { - var cachedValue = cacheFor(obj, keyName); - _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue); - _emberMetalProperty_set.set(obj, keyName, value); - return value; - }; - - ComputedPropertyPrototype.volatileSet = function computedPropertyVolatileSet(obj, keyName, value) { - return this._setter.call(obj, keyName, value); - }; - - ComputedPropertyPrototype.setWithSuspend = function computedPropertySetWithSuspend(obj, keyName, value) { - var oldSuspended = this._suspended; - this._suspended = obj; - try { - return this._set(obj, keyName, value); - } finally { - this._suspended = oldSuspended; - } - }; - - ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { - // cache requires own meta - var meta = _emberMetalMeta.meta(obj); - // either there is a writable cache or we need one to update - var cache = meta.writableCache(); - var hadCachedValue = false; - var cachedValue = undefined; - if (cache[keyName] !== undefined) { - if (cache[keyName] !== _emberMetalMeta.UNDEFINED) { - cachedValue = cache[keyName]; - } - hadCachedValue = true; - } - - var ret = this._setter.call(obj, keyName, value, cachedValue); - - // allows setter to return the same value that is cached already - if (hadCachedValue && cachedValue === ret) { - return ret; - } - - _emberMetalProperty_events.propertyWillChange(obj, keyName); - - if (hadCachedValue) { - cache[keyName] = undefined; - } - - if (!hadCachedValue) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } - - _emberMetalProperty_events.propertyDidChange(obj, keyName); - - return ret; - }; - - /* called before property is overridden */ - ComputedPropertyPrototype.teardown = function (obj, keyName) { - if (this._volatile) { - return; - } - var meta = _emberMetalMeta.meta(obj); - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - cache[keyName] = undefined; - } - }; - - /** - This helper returns a new property descriptor that wraps the passed - computed property function. You can use this helper to define properties - with mixins or via `Ember.defineProperty()`. - - If you pass a function as an argument, it will be used as a getter. A computed - property defined in this way might look like this: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', function() { - return `${this.get('firstName')} ${this.get('lastName')}`; - }) - }); - - let client = Person.create(); - - client.get('fullName'); // 'Betty Jones' - - client.set('lastName', 'Fuller'); - client.get('fullName'); // 'Betty Fuller' - ``` - - You can pass a hash with two functions, `get` and `set`, as an - argument to provide both a getter and setter: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - return `${this.get('firstName')} ${this.get('lastName')}`; - }, - set(key, value) { - let [firstName, lastName] = value.split(/\s+/); - this.setProperties({ firstName, lastName }); - return value; - } - }); - }) - - let client = Person.create(); - client.get('firstName'); // 'Betty' - - client.set('fullName', 'Carroll Fuller'); - client.get('firstName'); // 'Carroll' - ``` - - The `set` function should accept two parameters, `key` and `value`. The value - returned from `set` will be the new value of the property. - - _Note: This is the preferred way to define computed properties when writing third-party - libraries that depend on or use Ember, since there is no guarantee that the user - will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._ - - The alternative syntax, with prototype extensions, might look like: - - ```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 = undefined; - - 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 = _emberMetalMeta.peekMeta(obj); - var cache = meta && meta.source === obj && meta.readableCache(); - var ret = cache && cache[key]; - - if (ret === _emberMetalMeta.UNDEFINED) { - return undefined; - } - return ret; - } - - cacheFor.set = function (cache, key, value) { - if (value === undefined) { - cache[key] = _emberMetalMeta.UNDEFINED; - } else { - cache[key] = value; - } - }; - - cacheFor.get = function (cache, key) { - var ret = cache[key]; - if (ret === _emberMetalMeta.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', 'ember-environment'], function (exports, _emberEnvironment) { - 'use strict'; - - /** - @module ember - @submodule ember-metal - */ - - /** - This namespace contains all Ember methods and functions. Future versions of - Ember may overwrite this namespace and therefore, you should avoid adding any - new properties. - - At the heart of Ember is Ember-Runtime, a set of core functions that provide - cross-platform compatibility and object property observing. Ember-Runtime is - small and performance-focused so you can use it alongside other - cross-platform libraries such as jQuery. For more details, see - [Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html). - - @class Ember - @static - @public - */ - var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {}; - - // Make sure these are set whether Ember was already defined or not - Ember.isNamespace = true; - Ember.toString = function () { - return 'Ember'; - }; - - // .......................................................... - // BOOTSTRAP - // - - exports.default = Ember; -}); -enifed("ember-metal/debug", ["exports"], function (exports) { - "use strict"; - - exports.getDebugFunction = getDebugFunction; - exports.setDebugFunction = setDebugFunction; - exports.assert = assert; - exports.info = info; - exports.warn = warn; - exports.debug = debug; - exports.deprecate = deprecate; - exports.deprecateFunc = deprecateFunc; - exports.runInDebug = runInDebug; - exports.debugSeal = debugSeal; - exports.debugFreeze = debugFreeze; - var debugFunctions = { - assert: function () {}, - info: function () {}, - warn: function () {}, - debug: function () {}, - deprecate: function () {}, - deprecateFunc: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return args[args.length - 1]; - }, - runInDebug: function () {}, - debugSeal: function () {}, - debugFreeze: function () {} - }; - - exports.debugFunctions = debugFunctions; - - function getDebugFunction(name) { - return debugFunctions[name]; - } - - function setDebugFunction(name, fn) { - debugFunctions[name] = fn; - } - - function assert() { - return debugFunctions.assert.apply(undefined, arguments); - } - - function info() { - return debugFunctions.info.apply(undefined, arguments); - } - - function warn() { - return debugFunctions.warn.apply(undefined, arguments); - } - - function debug() { - return debugFunctions.debug.apply(undefined, arguments); - } - - function deprecate() { - return debugFunctions.deprecate.apply(undefined, arguments); - } - - function deprecateFunc() { - return debugFunctions.deprecateFunc.apply(undefined, arguments); - } - - function runInDebug() { - return debugFunctions.runInDebug.apply(undefined, arguments); - } - - function debugSeal() { - return debugFunctions.debugSeal.apply(undefined, arguments); - } - - function debugFreeze() { - return debugFunctions.debugFreeze.apply(undefined, arguments); - } -}); -enifed('ember-metal/dependent_keys', ['exports', 'ember-metal/watching'], function (exports, _emberMetalWatching) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - exports.addDependentKeys = addDependentKeys; - exports.removeDependentKeys = removeDependentKeys; - - /** - @module ember - @submodule ember-metal - */ - - // .......................................................... - // DEPENDENT KEYS - // - - function addDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // add all of its dependent keys. - var idx = undefined, - depKey = undefined; - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; - } - - for (idx = 0; idx < depKeys.length; idx++) { - depKey = depKeys[idx]; - // Increment the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1); - // Watch the depKey - _emberMetalWatching.watch(obj, depKey, meta); - } - } - - function removeDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // remove all of its dependent keys. - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; - } - - for (var idx = 0; idx < depKeys.length; idx++) { - var depKey = depKeys[idx]; - // Decrement the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1); - // Unwatch the depKey - _emberMetalWatching.unwatch(obj, depKey, meta); - } - } -}); -enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set) { - /** - @module ember - @submodule ember-metal - */ - - 'use strict'; - - exports.deprecateProperty = deprecateProperty; - - /** - Used internally to allow changing properties in a backwards compatible way, and print a helpful - deprecation warning. - - @method deprecateProperty - @param {Object} object The object to add the deprecated property to. - @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). - @param {String} newKey The property that will be aliased. - @private - @since 1.7.0 - */ - - function deprecateProperty(object, deprecatedKey, newKey, options) { - function _deprecate() { - _emberMetalDebug.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.', false, options); - } - - Object.defineProperty(object, deprecatedKey, { - configurable: true, - enumerable: false, - set: function (value) { - _deprecate(); - _emberMetalProperty_set.set(this, newKey, value); - }, - get: function () { - _deprecate(); - return _emberMetalProperty_get.get(this, newKey); - } - }); - } -}); -enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) { - 'use strict'; - - exports.default = descriptor; - - function descriptor(desc) { - return new Descriptor(desc); - } - - /** - A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need - this at all, however, the way we currently flatten/merge our mixins require - a special value to denote a descriptor. - - @class Descriptor - @private - */ - - var Descriptor = (function (_EmberDescriptor) { - babelHelpers.inherits(Descriptor, _EmberDescriptor); - - function Descriptor(desc) { - babelHelpers.classCallCheck(this, Descriptor); - - _EmberDescriptor.call(this); - this.desc = desc; - } - - Descriptor.prototype.setup = function setup(obj, key) { - Object.defineProperty(obj, key, this.desc); - }; - - Descriptor.prototype.teardown = function teardown(obj, key) {}; - - return Descriptor; - })(_emberMetalProperties.Descriptor); -}); -enifed("ember-metal/error", ["exports"], function (exports) { - - /** - A subclass of the JavaScript Error object for use in Ember. - - @class Error - @namespace Ember - @extends Error - @constructor - @public - */ - "use strict"; - - exports.default = EmberError; - - function EmberError(message) { - if (!(this instanceof EmberError)) { - return new EmberError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, EmberError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message; - this.name = error.name; - this.number = error.number; - this.code = error.code; - } - - EmberError.prototype = Object.create(Error.prototype); -}); -enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { - 'use strict'; - - exports.getOnerror = getOnerror; - exports.setOnerror = setOnerror; - exports.dispatchError = dispatchError; - exports.setDispatchOverride = setDispatchOverride; - - // To maintain stacktrace consistency across browsers - var getStack = function (error) { - var stack = error.stack; - var message = error.message; - - if (stack && stack.indexOf(message) === -1) { - stack = message + '\n' + stack; - } - - return stack; - }; - - var onerror = undefined; - // Ember.onerror getter - - function getOnerror() { - return onerror; - } - - // Ember.onerror setter - - function setOnerror(handler) { - onerror = handler; - } - - var dispatchOverride = undefined; - // dispatch error - - function dispatchError(error) { - if (dispatchOverride) { - dispatchOverride(error); - } else { - defaultDispatch(error); - } - } - - // allows testing adapter to override dispatch - - function setDispatchOverride(handler) { - dispatchOverride = handler; - } - - function defaultDispatch(error) { - if (_emberMetalTesting.isTesting()) { - throw error; - } - if (onerror) { - onerror(error); - } else { - _emberConsole.default.error(getStack(error)); - } - } -}); -enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-metal - */ - exports.accumulateListeners = accumulateListeners; - exports.addListener = addListener; - exports.removeListener = removeListener; - exports.suspendListener = suspendListener; - exports.suspendListeners = suspendListeners; - exports.watchedEvents = watchedEvents; - exports.sendEvent = sendEvent; - exports.hasListeners = hasListeners; - exports.listenersFor = listenersFor; - exports.on = on; - - /* - The event system uses a series of nested hashes to store listeners on an - object. When a listener is registered, or when an event arrives, these - hashes are consulted to determine which target and action pair to invoke. - - The hashes are stored in the object's meta hash, and look like this: - - // Object's meta hash - { - listeners: { // variable name: `listenerSet` - "foo:changed": [ // variable name: `actions` - target, method, flags - ] - } - } - - */ - - function indexOf(array, target, method) { - var index = -1; - // hashes are added to the end of the event array - // so it makes sense to start searching at the end - // of the array and search in reverse - for (var i = array.length - 3; i >= 0; i -= 3) { - if (target === array[i] && method === array[i + 1]) { - index = i; - break; - } - } - return index; - } - - function accumulateListeners(obj, eventName, otherActions) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return; - } - var actions = meta.matchingListeners(eventName); - var newActions = []; - - for (var i = actions.length - 3; i >= 0; i -= 3) { - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - var actionIndex = indexOf(otherActions, target, method); - - if (actionIndex === -1) { - otherActions.push(target, method, flags); - newActions.push(target, method, flags); - } - } - - return newActions; - } - - /** - Add an event listener - - @method addListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Boolean} once A flag whether a function should only be called once - @public - */ - - function addListener(obj, eventName, target, method, once) { - _emberMetalDebug.assert('You must pass at least an object and event name to Ember.addListener', !!obj && !!eventName); - - _emberMetalDebug.deprecate('didInitAttrs called in ' + (obj && obj.toString && obj.toString()) + '.', eventName !== 'didInitAttrs', { - id: 'ember-views.did-init-attrs', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' - }); - - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - - var flags = 0; - if (once) { - flags |= _emberMetalMeta_listeners.ONCE; - } - - _emberMetalMeta.meta(obj).addToListeners(eventName, target, method, flags); - - if ('function' === typeof obj.didAddListener) { - obj.didAddListener(eventName, target, method); - } - } - - /** - Remove an event listener - - Arguments should match those passed to `Ember.addListener`. - - @method removeListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @public - */ - - function removeListener(obj, eventName, target, method) { - _emberMetalDebug.assert('You must pass at least an object and event name to Ember.removeListener', !!obj && !!eventName); - - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - - _emberMetalMeta.meta(obj).removeFromListeners(eventName, target, method, function () { - if ('function' === typeof obj.didRemoveListener) { - obj.didRemoveListener.apply(obj, arguments); - } - }); - } - - /** - Suspend listener during callback. - - This should only be used by the target of the event listener - when it is taking an action that would cause the event, e.g. - an object might suspend its property change listener while it is - setting that property. - - @method suspendListener - @for Ember - - @private - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ - - function suspendListener(obj, eventName, target, method, callback) { - return suspendListeners(obj, [eventName], target, method, callback); - } - - /** - Suspends multiple listeners during a callback. - - @method suspendListeners - @for Ember - - @private - @param obj - @param {Array} eventNames Array of event names - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ - - function suspendListeners(obj, eventNames, target, method, callback) { - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - return _emberMetalMeta.meta(obj).suspendListeners(eventNames, target, method, callback); - } - - /** - Return a list of currently watched events - - @private - @method watchedEvents - @for Ember - @param obj - */ - - function watchedEvents(obj) { - return _emberMetalMeta.meta(obj).watchedEvents(); - } - - /** - Send an event. The execution of suspended listeners - is skipped, and once listeners are removed. A listener without - a target is executed on the passed object. If an array of actions - is not passed, the actions stored on the passed object are invoked. - - @method sendEvent - @for Ember - @param obj - @param {String} eventName - @param {Array} params Optional parameters for each listener. - @param {Array} actions Optional array of actions (listeners). - @return true - @public - */ - - function sendEvent(obj, eventName, params, actions) { - if (!actions) { - var meta = _emberMetalMeta.peekMeta(obj); - actions = meta && meta.matchingListeners(eventName); - } - - if (!actions || actions.length === 0) { - return; - } - - for (var i = actions.length - 3; i >= 0; i -= 3) { - // looping in reverse for once listeners - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - - if (!method) { - continue; - } - if (flags & _emberMetalMeta_listeners.SUSPENDED) { - continue; - } - if (flags & _emberMetalMeta_listeners.ONCE) { - removeListener(obj, eventName, target, method); - } - if (!target) { - target = obj; - } - if ('string' === typeof method) { - if (params) { - _emberUtils.applyStr(target, method, params); - } else { - target[method](); - } - } else { - if (params) { - method.apply(target, params); - } else { - method.call(target); - } - } - } - return true; - } - - /** - @private - @method hasListeners - @for Ember - @param obj - @param {String} eventName - */ - - function hasListeners(obj, eventName) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return false; - } - return meta.matchingListeners(eventName).length > 0; - } - - /** - @private - @method listenersFor - @for Ember - @param obj - @param {String} eventName - */ - - function listenersFor(obj, eventName) { - var ret = []; - var meta = _emberMetalMeta.peekMeta(obj); - var actions = meta && meta.matchingListeners(eventName); - - if (!actions) { - return ret; - } - - for (var i = 0; i < actions.length; i += 3) { - var target = actions[i]; - var method = actions[i + 1]; - ret.push([target, method]); - } - - return ret; - } - - /** - Define a property as a function that should be executed when - a specified event or events are triggered. - - - ``` javascript - let Job = Ember.Object.extend({ - logCompleted: Ember.on('completed', function() { - console.log('Job completed!'); - }) - }); - - let job = Job.create(); - - Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' - ``` - - @method on - @for Ember - @param {String} eventNames* - @param {Function} func - @return func - @public - */ - - function on() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var func = args.pop(); - var events = args; - func.__ember_listens__ = events; - return func; - } -}); -enifed('ember-metal/expand_properties', ['exports', 'ember-metal/debug'], function (exports, _emberMetalDebug) { - 'use strict'; - - exports.default = expandProperties; - - /** - @module ember - @submodule ember-metal - */ - - var SPLIT_REGEX = /\{|\}/; - var END_WITH_EACH_REGEX = /\.@each$/; - - /** - Expands `pattern`, invoking `callback` for each expansion. - - The only pattern supported is brace-expansion, anything else will be passed - once to `callback` directly. - - Example - - ```js - function echo(arg){ console.log(arg); } - - Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' - Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' - Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' - Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' - Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' - Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' - Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' - ``` - - @method expandProperties - @for Ember - @private - @param {String} pattern The property pattern to expand. - @param {Function} callback The callback to invoke. It is invoked once per - expansion, and is passed the expansion. - */ - - function expandProperties(pattern, callback) { - _emberMetalDebug.assert('A computed property key must be a string', typeof pattern === 'string'); - _emberMetalDebug.assert('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1); - _emberMetalDebug.assert('Brace expanded properties have to be balanced and cannot be nested, pattern: ' + pattern, (function (str) { - var inBrace = 0; - var char = undefined; - for (var i = 0; i < str.length; i++) { - char = str.charAt(i); - - if (char === '{') { - inBrace++; - } else if (char === '}') { - inBrace--; - } - - if (inBrace > 1 || inBrace < 0) { - return false; - } - } - - return true; - })(pattern)); - - var parts = pattern.split(SPLIT_REGEX); - var properties = [parts]; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part.indexOf(',') >= 0) { - properties = duplicateAndReplace(properties, part.split(','), i); - } - } - - for (var i = 0; i < properties.length; i++) { - callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); - } - } - - function duplicateAndReplace(properties, currentParts, index) { - var all = []; - - properties.forEach(function (property) { - currentParts.forEach(function (part) { - var current = property.slice(0); - current[index] = part; - all.push(current); - }); - }); - - return all; - } -}); -enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) { - 'use strict'; - - exports.default = isEnabled; - - /** - The hash of enabled Canary features. Add to this, any canary features - before creating your application. - - Alternatively (and recommended), you can also define `EmberENV.FEATURES` - if you need to enable features flagged at runtime. - - @class FEATURES - @namespace Ember - @static - @since 1.1.0 - @public - */ - var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES); - - exports.FEATURES = FEATURES; - /** - Determine whether the specified `feature` is enabled. Used by Ember's - build tools to exclude experimental features from beta/stable builds. - - You can define the following configuration options: - - * `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly - enabled/disabled. - - @method isEnabled - @param {String} feature The feature to check - @return {Boolean} - @for Ember.FEATURES - @since 1.1.0 - @public - */ - - function isEnabled(feature) { - var featureValue = FEATURES[feature]; - - if (featureValue === true || featureValue === false || featureValue === undefined) { - return featureValue; - } else if (_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES) { - return true; - } else { - return false; - } - } - - exports.DEFAULT_FEATURES = _emberFeatures.default; -}); -enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; - - exports.default = getProperties; - - /** - To get multiple properties at once, call `Ember.getProperties` - with an object followed by a list of strings or an array: - - ```javascript - Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - is equivalent to: - - ```javascript - Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - @method getProperties - @for Ember - @param {Object} obj - @param {String...|Array} list of keys to get - @return {Object} - @public - */ - - function getProperties(obj) { - var ret = {}; - var propertyNames = arguments; - var i = 1; - - if (arguments.length === 2 && Array.isArray(arguments[1])) { - i = 0; - propertyNames = arguments[1]; - } - for (; i < propertyNames.length; i++) { - ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]); - } - return ret; - } -}); -enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/is_proxy', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalIs_proxy, _emberMetalDescriptor) { - /** - @module ember - @submodule ember-metal - */ - - 'use strict'; - - exports.default = _emberMetalCore.default; - // reexports - exports.computed = _emberMetalComputed.default; - exports.cacheFor = _emberMetalComputed.cacheFor; - exports.ComputedProperty = _emberMetalComputed.ComputedProperty; - exports.alias = _emberMetalAlias.default; - exports.merge = _emberMetalMerge.default; - exports.assert = _emberMetalDebug.assert; - exports.info = _emberMetalDebug.info; - exports.warn = _emberMetalDebug.warn; - exports.debug = _emberMetalDebug.debug; - exports.deprecate = _emberMetalDebug.deprecate; - exports.deprecateFunc = _emberMetalDebug.deprecateFunc; - exports.runInDebug = _emberMetalDebug.runInDebug; - exports.setDebugFunction = _emberMetalDebug.setDebugFunction; - exports.getDebugFunction = _emberMetalDebug.getDebugFunction; - exports.debugSeal = _emberMetalDebug.debugSeal; - exports.debugFreeze = _emberMetalDebug.debugFreeze; - exports.instrument = _emberMetalInstrumentation.instrument; - exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument; - exports._instrumentStart = _emberMetalInstrumentation._instrumentStart; - exports.instrumentationReset = _emberMetalInstrumentation.reset; - exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe; - exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe; - exports.isTesting = _emberMetalTesting.isTesting; - exports.setTesting = _emberMetalTesting.setTesting; - exports.getOnerror = _emberMetalError_handler.getOnerror; - exports.setOnerror = _emberMetalError_handler.setOnerror; - exports.dispatchError = _emberMetalError_handler.dispatchError; - exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride; - exports.META_DESC = _emberMetalMeta.META_DESC; - exports.meta = _emberMetalMeta.meta; - exports.peekMeta = _emberMetalMeta.peekMeta; - exports.Error = _emberMetalError.default; - exports.Cache = _emberMetalCache.default; - exports.isFeatureEnabled = _emberMetalFeatures.default; - exports.FEATURES = _emberMetalFeatures.FEATURES; - exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES; - exports._getPath = _emberMetalProperty_get._getPath; - exports.get = _emberMetalProperty_get.get; - exports.getWithDefault = _emberMetalProperty_get.getWithDefault; - exports.set = _emberMetalProperty_set.set; - exports.trySet = _emberMetalProperty_set.trySet; - exports.WeakMap = _emberMetalWeak_map.default; - exports.accumulateListeners = _emberMetalEvents.accumulateListeners; - exports.addListener = _emberMetalEvents.addListener; - exports.hasListeners = _emberMetalEvents.hasListeners; - exports.listenersFor = _emberMetalEvents.listenersFor; - exports.on = _emberMetalEvents.on; - exports.removeListener = _emberMetalEvents.removeListener; - exports.sendEvent = _emberMetalEvents.sendEvent; - exports.suspendListener = _emberMetalEvents.suspendListener; - exports.suspendListeners = _emberMetalEvents.suspendListeners; - exports.watchedEvents = _emberMetalEvents.watchedEvents; - exports.isNone = _emberMetalIs_none.default; - exports.isEmpty = _emberMetalIs_empty.default; - exports.isBlank = _emberMetalIs_blank.default; - exports.isPresent = _emberMetalIs_present.default; - exports.run = _emberMetalRun_loop.default; - exports.ObserverSet = _emberMetalObserver_set.default; - exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges; - exports.changeProperties = _emberMetalProperty_events.changeProperties; - exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges; - exports.overrideChains = _emberMetalProperty_events.overrideChains; - exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; - exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; - exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; - exports.defineProperty = _emberMetalProperties.defineProperty; - exports.Descriptor = _emberMetalProperties.Descriptor; - exports.watchKey = _emberMetalWatch_key.watchKey; - exports.unwatchKey = _emberMetalWatch_key.unwatchKey; - exports.ChainNode = _emberMetalChains.ChainNode; - exports.finishChains = _emberMetalChains.finishChains; - exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; - exports.watchPath = _emberMetalWatch_path.watchPath; - exports.unwatchPath = _emberMetalWatch_path.unwatchPath; - exports.destroy = _emberMetalWatching.destroy; - exports.isWatching = _emberMetalWatching.isWatching; - exports.unwatch = _emberMetalWatching.unwatch; - exports.watch = _emberMetalWatching.watch; - exports.watcherCount = _emberMetalWatching.watcherCount; - exports.libraries = _emberMetalLibraries.default; - exports.Map = _emberMetalMap.Map; - exports.MapWithDefault = _emberMetalMap.MapWithDefault; - exports.OrderedSet = _emberMetalMap.OrderedSet; - exports.getProperties = _emberMetalGet_properties.default; - exports.setProperties = _emberMetalSet_properties.default; - exports.expandProperties = _emberMetalExpand_properties.default; - exports._suspendObserver = _emberMetalObserver._suspendObserver; - exports._suspendObservers = _emberMetalObserver._suspendObservers; - exports.addObserver = _emberMetalObserver.addObserver; - exports.observersFor = _emberMetalObserver.observersFor; - exports.removeObserver = _emberMetalObserver.removeObserver; - exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; - exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; - exports.Mixin = _emberMetalMixin.Mixin; - exports.aliasMethod = _emberMetalMixin.aliasMethod; - exports._immediateObserver = _emberMetalMixin._immediateObserver; - exports._beforeObserver = _emberMetalMixin._beforeObserver; - exports.mixin = _emberMetalMixin.mixin; - exports.observer = _emberMetalMixin.observer; - exports.required = _emberMetalMixin.required; - exports.REQUIRED = _emberMetalMixin.REQUIRED; - exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins; - exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins; - exports.detectBinding = _emberMetalMixin.detectBinding; - exports.Binding = _emberMetalBinding.Binding; - exports.bind = _emberMetalBinding.bind; - exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath; - exports.InjectedProperty = _emberMetalInjected_property.default; - exports.setHasViews = _emberMetalTags.setHasViews; - exports.tagForProperty = _emberMetalTags.tagForProperty; - exports.tagFor = _emberMetalTags.tagFor; - exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty; - exports.replace = _emberMetalReplace.default; - exports.runInTransaction = _emberMetalTransaction.default; - exports.didRender = _emberMetalTransaction.didRender; - exports.assertNotRendered = _emberMetalTransaction.assertNotRendered; - exports.isProxy = _emberMetalIs_proxy.isProxy; - exports.descriptor = _emberMetalDescriptor.default; - - // TODO: this needs to be deleted once we refactor the build tooling - // do this for side-effects of updating Ember.assert, warn, etc when - // ember-debug is present - // This needs to be called before any deprecateFunc - - if (_require.has('ember-debug')) { - _require.default('ember-debug'); - } -}); -enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) { - 'use strict'; - - exports.default = InjectedProperty; - - /** - Read-only property that returns the result of a container lookup. - - @class InjectedProperty - @namespace Ember - @constructor - @param {String} type The container type the property will lookup - @param {String} name (optional) The name the property will lookup, defaults - to the property's name - @private - */ - - function InjectedProperty(type, name) { - this.type = type; - this.name = name; - - this._super$Constructor(injectedPropertyGet); - AliasedPropertyPrototype.oneWay.call(this); - } - - function injectedPropertyGet(keyName) { - var desc = this[keyName]; - var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat - - _emberMetalDebug.assert('InjectedProperties should be defined with the Ember.inject computed property macros.', desc && desc.isDescriptor && desc.type); - _emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', owner); - - return owner.lookup(desc.type + ':' + (desc.name || keyName)); - } - - InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); - - var InjectedPropertyPrototype = InjectedProperty.prototype; - var ComputedPropertyPrototype = _emberMetalComputed.ComputedProperty.prototype; - var AliasedPropertyPrototype = _emberMetalAlias.AliasedProperty.prototype; - - InjectedPropertyPrototype._super$Constructor = _emberMetalComputed.ComputedProperty; - - InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; - InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; - InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; -}); -enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { - 'use strict'; - - exports.instrument = instrument; - exports._instrumentStart = _instrumentStart; - exports.subscribe = subscribe; - exports.unsubscribe = unsubscribe; - exports.reset = reset; - - /** - The purpose of the Ember Instrumentation module is - to provide efficient, general-purpose instrumentation - for Ember. - - Subscribe to a listener by using `Ember.subscribe`: - - ```javascript - Ember.subscribe("render", { - before(name, timestamp, payload) { - - }, - - after(name, timestamp, payload) { - - } - }); - ``` - - If you return a value from the `before` callback, that same - value will be passed as a fourth parameter to the `after` - callback. - - Instrument a block of code by using `Ember.instrument`: - - ```javascript - Ember.instrument("render.handlebars", payload, function() { - // rendering logic - }, binding); - ``` - - Event names passed to `Ember.instrument` are namespaced - by periods, from more general to more specific. Subscribers - can listen for events by whatever level of granularity they - are interested in. - - In the above example, the event is `render.handlebars`, - and the subscriber listened for all events beginning with - `render`. It would receive callbacks for events named - `render`, `render.handlebars`, `render.container`, or - even `render.handlebars.layout`. - - @class Instrumentation - @namespace Ember - @static - @private - */ - var subscribers = []; - exports.subscribers = subscribers; - var cache = {}; - - function populateListeners(name) { - var listeners = []; - var subscriber = undefined; - - for (var i = 0; i < subscribers.length; i++) { - subscriber = subscribers[i]; - if (subscriber.regex.test(name)) { - listeners.push(subscriber.object); - } - } - - cache[name] = listeners; - return listeners; - } - - var time = (function () { - var perf = 'undefined' !== typeof window ? window.performance || {} : {}; - var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; - // fn.bind will be available in all the browsers that support the advanced window.performance... ;-) - return fn ? fn.bind(perf) : function () { - return +new Date(); - }; - })(); - - /** - Notifies event's subscribers, calls `before` and `after` hooks. - - @method instrument - @namespace Ember.Instrumentation - - @param {String} [name] Namespaced event name. - @param {Object} _payload - @param {Function} callback Function that you're instrumenting. - @param {Object} binding Context that instrument function is called with. - @private - */ - - function instrument(name, _payload, callback, binding) { - if (arguments.length <= 3 && typeof _payload === 'function') { - binding = callback; - callback = _payload; - _payload = undefined; - } - if (subscribers.length === 0) { - return callback.call(binding); - } - var payload = _payload || {}; - var finalizer = _instrumentStart(name, function () { - return payload; - }); - - if (finalizer) { - return withFinalizer(callback, finalizer, payload, binding); - } else { - return callback.call(binding); - } - } - - var flaggedInstrument = undefined; - if (false) { - exports.flaggedInstrument = flaggedInstrument = instrument; - } else { - exports.flaggedInstrument = flaggedInstrument = function (name, payload, callback) { - return callback(); - }; - } - exports.flaggedInstrument = flaggedInstrument; - - function withFinalizer(callback, finalizer, payload, binding) { - var result = undefined; - try { - result = callback.call(binding); - } catch (e) { - payload.exception = e; - result = payload; - } finally { - finalizer(); - return result; - } - } - - function NOOP() {} - - // private for now - - function _instrumentStart(name, _payload, _payloadParam) { - if (subscribers.length === 0) { - return NOOP; - } - - var listeners = cache[name]; - - if (!listeners) { - listeners = populateListeners(name); - } - - if (listeners.length === 0) { - return NOOP; - } - - var payload = _payload(_payloadParam); - - var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE; - var timeName = undefined; - if (STRUCTURED_PROFILE) { - timeName = name + ': ' + payload.object; - console.time(timeName); - } - - var beforeValues = new Array(listeners.length); - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - beforeValues[i] = listener.before(name, timestamp, payload); - } - - return function _instrumentEnd() { - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - if (typeof listener.after === 'function') { - listener.after(name, timestamp, payload, beforeValues[i]); - } - } - - if (STRUCTURED_PROFILE) { - console.timeEnd(timeName); - } - }; - } - - /** - Subscribes to a particular event or instrumented block of code. - - @method subscribe - @namespace Ember.Instrumentation - - @param {String} [pattern] Namespaced event name. - @param {Object} [object] Before and After hooks. - - @return {Subscriber} - @private - */ - - function subscribe(pattern, object) { - var paths = pattern.split('.'); - var path = undefined; - var regex = []; - - for (var i = 0; i < paths.length; i++) { - path = paths[i]; - if (path === '*') { - regex.push('[^\\.]*'); - } else { - regex.push(path); - } - } - - regex = regex.join('\\.'); - regex = regex + '(\\..*)?'; - - var subscriber = { - pattern: pattern, - regex: new RegExp('^' + regex + '$'), - object: object - }; - - subscribers.push(subscriber); - cache = {}; - - return subscriber; - } - - /** - Unsubscribes from a particular event or instrumented block of code. - - @method unsubscribe - @namespace Ember.Instrumentation - - @param {Object} [subscriber] - @private - */ - - function unsubscribe(subscriber) { - var index = undefined; - - for (var i = 0; i < subscribers.length; i++) { - if (subscribers[i] === subscriber) { - index = i; - } - } - - subscribers.splice(index, 1); - cache = {}; - } - - /** - Resets `Ember.Instrumentation` by flushing list of subscribers. - - @method reset - @namespace Ember.Instrumentation - @private - */ - - function reset() { - subscribers.length = 0; - cache = {}; - } -}); -enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, _emberMetalIs_empty) { - 'use strict'; - - exports.default = isBlank; - - /** - A value is blank if it is empty or a whitespace string. - - ```javascript - Ember.isBlank(); // true - Ember.isBlank(null); // true - Ember.isBlank(undefined); // true - Ember.isBlank(''); // true - Ember.isBlank([]); // true - Ember.isBlank('\n\t'); // true - Ember.isBlank(' '); // true - Ember.isBlank({}); // false - Ember.isBlank('\n\t Hello'); // false - Ember.isBlank('Hello world'); // false - Ember.isBlank([1,2,3]); // false - ``` - - @method isBlank - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.5.0 - @public - */ - - function isBlank(obj) { - return _emberMetalIs_empty.default(obj) || typeof obj === 'string' && obj.match(/\S/) === null; - } -}); -enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, _emberMetalProperty_get, _emberMetalIs_none) { - 'use strict'; - - exports.default = isEmpty; - - /** - Verifies that a value is `null` or an empty string, empty array, - or empty function. - - Constrains the rules on `Ember.isNone` by returning true for empty - string and empty arrays. - - ```javascript - Ember.isEmpty(); // true - Ember.isEmpty(null); // true - Ember.isEmpty(undefined); // true - Ember.isEmpty(''); // true - Ember.isEmpty([]); // true - Ember.isEmpty({}); // false - Ember.isEmpty('Adam Hawkins'); // false - Ember.isEmpty([0,1,2]); // false - Ember.isEmpty('\n\t'); // false - Ember.isEmpty(' '); // false - ``` - - @method isEmpty - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ - - function isEmpty(obj) { - var none = _emberMetalIs_none.default(obj); - if (none) { - return none; - } - - if (typeof obj.size === 'number') { - return !obj.size; - } - - var objectType = typeof obj; - - if (objectType === 'object') { - var size = _emberMetalProperty_get.get(obj, 'size'); - if (typeof size === 'number') { - return !size; - } - } - - if (typeof obj.length === 'number' && objectType !== 'function') { - return !obj.length; - } - - if (objectType === 'object') { - var _length = _emberMetalProperty_get.get(obj, 'length'); - if (typeof _length === 'number') { - return !_length; - } - } - - return false; - } -}); -enifed("ember-metal/is_none", ["exports"], function (exports) { - /** - Returns true if the passed value is null or undefined. This avoids errors - from JSLint complaining about use of ==, which can be technically - confusing. - - ```javascript - Ember.isNone(); // true - Ember.isNone(null); // true - Ember.isNone(undefined); // true - Ember.isNone(''); // false - Ember.isNone([]); // false - Ember.isNone(function() {}); // false - ``` - - @method isNone - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ - "use strict"; - - exports.default = isNone; - - function isNone(obj) { - return obj === null || obj === undefined; - } -}); -enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { - 'use strict'; - - exports.default = isPresent; - - /** - A value is present if it not `isBlank`. - - ```javascript - Ember.isPresent(); // false - Ember.isPresent(null); // false - Ember.isPresent(undefined); // false - Ember.isPresent(''); // false - Ember.isPresent(' '); // false - Ember.isPresent('\n\t'); // false - Ember.isPresent([]); // false - Ember.isPresent({ length: 0 }) // false - Ember.isPresent(false); // true - Ember.isPresent(true); // true - Ember.isPresent('string'); // true - Ember.isPresent(0); // true - Ember.isPresent(function() {}) // true - Ember.isPresent({}); // true - Ember.isPresent(false); // true - Ember.isPresent('\n\t Hello'); // true - Ember.isPresent([1,2,3]); // true - ``` - - @method isPresent - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.8.0 - @public - */ - - function isPresent(obj) { - return !_emberMetalIs_blank.default(obj); - } -}); -enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { - 'use strict'; - - exports.isProxy = isProxy; - - function isProxy(value) { - if (typeof value === 'object' && value) { - var meta = _emberMetalMeta.peekMeta(value); - return meta && meta.isProxy(); - } - - return false; - } -}); -enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; - - exports.Libraries = Libraries; - - /** - Helper class that allows you to register your library with Ember. - - Singleton created at `Ember.libraries`. - - @class Libraries - @constructor - @private - */ - - function Libraries() { - this._registry = []; - this._coreLibIndex = 0; - } - - Libraries.prototype = { - constructor: Libraries, - - _getLibraryByName: function (name) { - var libs = this._registry; - var count = libs.length; - - for (var i = 0; i < count; i++) { - if (libs[i].name === name) { - return libs[i]; - } - } - }, - - register: function (name, version, isCoreLibrary) { - var index = this._registry.length; - - if (!this._getLibraryByName(name)) { - if (isCoreLibrary) { - index = this._coreLibIndex++; - } - this._registry.splice(index, 0, { name: name, version: version }); - } else { - _emberMetalDebug.warn('Library "' + name + '" is already registered with Ember.', false, { id: 'ember-metal.libraries-register' }); - } - }, - - registerCoreLibrary: function (name, version) { - this.register(name, version, true); - }, - - deRegister: function (name) { - var lib = this._getLibraryByName(name); - var index = undefined; - - if (lib) { - index = this._registry.indexOf(lib); - this._registry.splice(index, 1); - } - } - }; - - if (false) { - Libraries.prototype.isRegistered = function (name) { - return !!this._getLibraryByName(name); - }; - } - - exports.default = new Libraries(); -}); -enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) { - /** - @module ember - @submodule ember-metal - */ - - /* - JavaScript (before ES6) does not have a Map implementation. Objects, - which are often used as dictionaries, may only have Strings as keys. - - Because Ember has a way to get a unique identifier for every object - via `Ember.guidFor`, we can implement a performant Map with arbitrary - keys. Because it is commonly used in low-level bookkeeping, Map is - implemented as a pure JavaScript object for performance. - - This implementation follows the current iteration of the ES6 proposal for - maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets), - with one exception: as we do not have the luxury of in-VM iteration, we implement a - forEach method for iteration. - - Map is mocked out to look like an Ember object, so you can do - `Ember.Map.create()` for symmetry with other Ember classes. - */ - 'use strict'; - - function missingFunction(fn) { - throw new TypeError(Object.prototype.toString.call(fn) + ' is not a function'); - } - - function missingNew(name) { - throw new TypeError('Constructor ' + name + ' requires \'new\''); - } - - function copyNull(obj) { - var output = new _emberUtils.EmptyObject(); - - for (var prop in obj) { - // hasOwnPropery is not needed because obj is new EmptyObject(); - output[prop] = obj[prop]; - } - - return output; - } - - function copyMap(original, newObject) { - var keys = original._keys.copy(); - var values = copyNull(original._values); - - newObject._keys = keys; - newObject._values = values; - newObject.size = original.size; - - return newObject; - } - - /** - This class is used internally by Ember and Ember Data. - Please do not use it at this time. We plan to clean it up - and add many tests soon. - - @class OrderedSet - @namespace Ember - @constructor - @private - */ - function OrderedSet() { - if (this instanceof OrderedSet) { - this.clear(); - this._silenceRemoveDeprecation = false; - } else { - missingNew('OrderedSet'); - } - } - - /** - @method create - @static - @return {Ember.OrderedSet} - @private - */ - OrderedSet.create = function () { - var Constructor = this; - - return new Constructor(); - }; - - OrderedSet.prototype = { - constructor: OrderedSet, - /** - @method clear - @private - */ - clear: function () { - this.presenceSet = new _emberUtils.EmptyObject(); - this.list = []; - this.size = 0; - }, - - /** - @method add - @param obj - @param guid (optional, and for internal use) - @return {Ember.OrderedSet} - @private - */ - add: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; - - if (presenceSet[guid] !== true) { - presenceSet[guid] = true; - this.size = list.push(obj); - } - - return this; - }, - - /** - @since 1.8.0 - @method delete - @param obj - @param _guid (optional and for internal use only) - @return {Boolean} - @private - */ - delete: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; - - if (presenceSet[guid] === true) { - delete presenceSet[guid]; - var index = list.indexOf(obj); - if (index > -1) { - list.splice(index, 1); - } - this.size = list.length; - return true; - } else { - return false; - } - }, - - /** - @method isEmpty - @return {Boolean} - @private - */ - isEmpty: function () { - return this.size === 0; - }, - - /** - @method has - @param obj - @return {Boolean} - @private - */ - has: function (obj) { - if (this.size === 0) { - return false; - } - - var guid = _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - - return presenceSet[guid] === true; - }, - - /** - @method forEach - @param {Function} fn - @param self - @private - */ - forEach: function (fn /*, ...thisArg*/) { - if (typeof fn !== 'function') { - missingFunction(fn); - } - - if (this.size === 0) { - return; - } - - var list = this.list; - - if (arguments.length === 2) { - for (var i = 0; i < list.length; i++) { - fn.call(arguments[1], list[i]); - } - } else { - for (var i = 0; i < list.length; i++) { - fn(list[i]); - } - } - }, - - /** - @method toArray - @return {Array} - @private - */ - toArray: function () { - return this.list.slice(); - }, - - /** - @method copy - @return {Ember.OrderedSet} - @private - */ - copy: function () { - var Constructor = this.constructor; - var set = new Constructor(); - - set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; - set.presenceSet = copyNull(this.presenceSet); - set.list = this.toArray(); - set.size = this.size; - - return set; - } - }; - - /** - A Map stores values indexed by keys. Unlike JavaScript's - default Objects, the keys of a Map can be any JavaScript - object. - - Internally, a Map has two data structures: - - 1. `keys`: an OrderedSet of all of the existing keys - 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)` - - When a key/value pair is added for the first time, we - add the key to the `keys` OrderedSet, and create or - replace an entry in `values`. When an entry is deleted, - we delete its entry in `keys` and `values`. - - @class Map - @namespace Ember - @private - @constructor - */ - function Map() { - if (this instanceof Map) { - this._keys = OrderedSet.create(); - this._keys._silenceRemoveDeprecation = true; - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - } else { - missingNew('Map'); - } - } - - /** - @method create - @static - @private - */ - Map.create = function () { - var Constructor = this; - return new Constructor(); - }; - - Map.prototype = { - constructor: Map, - - /** - This property will change as the number of objects in the map changes. - @since 1.8.0 - @property size - @type number - @default 0 - @private - */ - size: 0, - - /** - Retrieve the value associated with a given key. - @method get - @param {*} key - @return {*} the value associated with the key, or `undefined` - @private - */ - get: function (key) { - if (this.size === 0) { - return; - } - - var values = this._values; - var guid = _emberUtils.guidFor(key); - - return values[guid]; - }, - - /** - Adds a value to the map. If a value for the given key has already been - provided, the new value will replace the old value. - @method set - @param {*} key - @param {*} value - @return {Ember.Map} - @private - */ - set: function (key, value) { - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); - - // ensure we don't store -0 - var k = key === -0 ? 0 : key; - - keys.add(k, guid); - - values[guid] = value; - - this.size = keys.size; - - return this; - }, - - /** - Removes a value from the map for an associated key. - @since 1.8.0 - @method delete - @param {*} key - @return {Boolean} true if an item was removed, false otherwise - @private - */ - delete: function (key) { - if (this.size === 0) { - return false; - } - // don't use ES6 "delete" because it will be annoying - // to use in browsers that are not ES6 friendly; - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); - - if (keys.delete(key, guid)) { - delete values[guid]; - this.size = keys.size; - return true; - } else { - return false; - } - }, - - /** - Check whether a key is present. - @method has - @param {*} key - @return {Boolean} true if the item was present, false otherwise - @private - */ - has: function (key) { - return this._keys.has(key); - }, - - /** - Iterate over all the keys and values. Calls the function once - for each key, passing in value, key, and the map being iterated over, - in that order. - The keys are guaranteed to be iterated over in insertion order. - @method forEach - @param {Function} callback - @param {*} self if passed, the `this` value inside the - callback. By default, `this` is the map. - @private - */ - forEach: function (callback /*, ...thisArg*/) { - if (typeof callback !== 'function') { - missingFunction(callback); - } - - if (this.size === 0) { - return; - } - - var map = this; - var cb = undefined, - thisArg = undefined; - - if (arguments.length === 2) { - thisArg = arguments[1]; - cb = function (key) { - return callback.call(thisArg, map.get(key), key, map); - }; - } else { - cb = function (key) { - return callback(map.get(key), key, map); - }; - } - - this._keys.forEach(cb); - }, - - /** - @method clear - @private - */ - clear: function () { - this._keys.clear(); - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - }, - - /** - @method copy - @return {Ember.Map} - @private - */ - copy: function () { - return copyMap(this, new Map()); - } - }; - - /** - @class MapWithDefault - @namespace Ember - @extends Ember.Map - @private - @constructor - @param [options] - @param {*} [options.defaultValue] - */ - function MapWithDefault(options) { - this._super$constructor(); - this.defaultValue = options.defaultValue; - } - - /** - @method create - @static - @param [options] - @param {*} [options.defaultValue] - @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns - `Ember.MapWithDefault` otherwise returns `Ember.Map` - @private - */ - MapWithDefault.create = function (options) { - if (options) { - return new MapWithDefault(options); - } else { - return new Map(); - } - }; - - MapWithDefault.prototype = Object.create(Map.prototype); - MapWithDefault.prototype.constructor = MapWithDefault; - MapWithDefault.prototype._super$constructor = Map; - MapWithDefault.prototype._super$get = Map.prototype.get; - - /** - Retrieve the value associated with a given key. - - @method get - @param {*} key - @return {*} the value associated with the key, or the default value - @private - */ - MapWithDefault.prototype.get = function (key) { - var hasValue = this.has(key); - - if (hasValue) { - return this._super$get(key); - } else { - var defaultValue = this.defaultValue(key); - this.set(key, defaultValue); - return defaultValue; - } - }; - - /** - @method copy - @return {Ember.MapWithDefault} - @private - */ - MapWithDefault.prototype.copy = function () { - var Constructor = this.constructor; - return copyMap(this, new Constructor({ - defaultValue: this.defaultValue - })); - }; - - exports.default = Map; - exports.OrderedSet = OrderedSet; - exports.Map = Map; - exports.MapWithDefault = MapWithDefault; -}); -enifed('ember-metal/merge', ['exports'], function (exports) { - /** - Merge the contents of two objects together into the first object. - - ```javascript - Ember.merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' } - var a = { first: 'Yehuda' }; - var b = { last: 'Katz' }; - Ember.merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' } - ``` - - @method merge - @for Ember - @param {Object} original The object to merge into - @param {Object} updates The object to copy properties from - @return {Object} - @public - */ - 'use strict'; - - exports.default = merge; - - function merge(original, updates) { - if (!updates || typeof updates !== 'object') { - return original; - } - - var props = Object.keys(updates); - var prop = undefined; - - for (var i = 0; i < props.length; i++) { - prop = props[i]; - original[prop] = updates[prop]; - } - - return original; - } -}); -enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - exports.Meta = Meta; - exports.deleteMeta = deleteMeta; - exports.meta = meta; - - var counters = { - peekCalls: 0, - peekParentCalls: 0, - peekPrototypeWalks: 0, - setCalls: 0, - deleteCalls: 0, - metaCalls: 0, - metaInstantiated: 0 - }; - - /** - @module ember-metal - */ - - /* - This declares several meta-programmed members on the Meta class. Such - meta! - - In general, the `readable` variants will give you an object (if it - already exists) that you can read but should not modify. The - `writable` variants will give you a mutable object, and they will - create it if it didn't already exist. - - The following methods will get generated metaprogrammatically, and - I'm including them here for greppability: - - writableCache, readableCache, writeWatching, - peekWatching, clearWatching, writeMixins, - peekMixins, clearMixins, writeBindings, - peekBindings, clearBindings, writeValues, - peekValues, clearValues, writeDeps, forEachInDeps - writableChainWatchers, readableChainWatchers, writableChains, - readableChains, writableTag, readableTag, writableTags, - readableTags - */ - var members = { - cache: ownMap, - weak: ownMap, - watching: inheritedMap, - mixins: inheritedMap, - bindings: inheritedMap, - values: inheritedMap, - chainWatchers: ownCustomObject, - chains: inheritedCustomObject, - tag: ownCustomObject, - tags: ownMap - }; - - // FLAGS - var SOURCE_DESTROYING = 1 << 1; - var SOURCE_DESTROYED = 1 << 2; - var META_DESTROYED = 1 << 3; - var IS_PROXY = 1 << 4; - - if (true || false) { - members.lastRendered = ownMap; - members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds - } - - var memberNames = Object.keys(members); - var META_FIELD = '__ember_meta__'; - - function Meta(obj, parentMeta) { - _emberMetalDebug.runInDebug(function () { - return counters.metaInstantiated++; - }); - - this._cache = undefined; - this._weak = undefined; - this._watching = undefined; - this._mixins = undefined; - this._bindings = undefined; - this._values = undefined; - this._deps = undefined; - this._chainWatchers = undefined; - this._chains = undefined; - this._tag = undefined; - this._tags = undefined; - - // initial value for all flags right now is false - // see FLAGS const for detailed list of flags used - this._flags = 0; - - // used only internally - this.source = obj; - - // when meta(obj).proto === obj, the object is intended to be only a - // prototype and doesn't need to actually be observable itself - this.proto = undefined; - - // The next meta in our inheritance chain. We (will) track this - // explicitly instead of using prototypical inheritance because we - // have detailed knowledge of how each property should really be - // inherited, and we can optimize it much better than JS runtimes. - this.parent = parentMeta; - - if (true || false) { - this._lastRendered = undefined; - this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds - } - - this._initializeListeners(); - } - - Meta.prototype.isInitialized = function (obj) { - return this.proto !== obj; - }; - - var NODE_STACK = []; - - Meta.prototype.destroy = function () { - if (this.isMetaDestroyed()) { - return; - } - - // remove chainWatchers to remove circular references that would prevent GC - var node = undefined, - nodes = undefined, - key = undefined, - nodeObject = undefined; - node = this.readableChains(); - if (node) { - NODE_STACK.push(node); - // process tree - while (NODE_STACK.length > 0) { - node = NODE_STACK.pop(); - // push children - nodes = node._chains; - if (nodes) { - for (key in nodes) { - if (nodes[key] !== undefined) { - NODE_STACK.push(nodes[key]); - } - } - } - - // remove chainWatcher in node object - if (node._watching) { - nodeObject = node._object; - if (nodeObject) { - var foreignMeta = peekMeta(nodeObject); - // avoid cleaning up chain watchers when both current and - // foreign objects are being destroyed - // if both are being destroyed manual cleanup is not needed - // as they will be GC'ed and no non-destroyed references will - // be remaining - if (foreignMeta && !foreignMeta.isSourceDestroying()) { - _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); - } - } - } - } - } - - this.setMetaDestroyed(); - }; - - for (var _name in _emberMetalMeta_listeners.protoMethods) { - Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; - } - memberNames.forEach(function (name) { - return members[name](name, Meta); - }); - - Meta.prototype.isSourceDestroying = function isSourceDestroying() { - return (this._flags & SOURCE_DESTROYING) !== 0; - }; - - Meta.prototype.setSourceDestroying = function setSourceDestroying() { - this._flags |= SOURCE_DESTROYING; - }; - - Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { - return (this._flags & SOURCE_DESTROYED) !== 0; - }; - - Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { - this._flags |= SOURCE_DESTROYED; - }; - - Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { - return (this._flags & META_DESTROYED) !== 0; - }; - - Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { - this._flags |= META_DESTROYED; - }; - - Meta.prototype.isProxy = function isProxy() { - return (this._flags & IS_PROXY) !== 0; - }; - - Meta.prototype.setProxy = function setProxy() { - this._flags |= IS_PROXY; - }; - - // Implements a member that is a lazily created, non-inheritable - // POJO. - function ownMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function () { - return this._getOrCreateOwnMap(key); - }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; - }; - } - - Meta.prototype._getOrCreateOwnMap = function (key) { - var ret = this[key]; - if (!ret) { - ret = this[key] = new _emberUtils.EmptyObject(); - } - return ret; - }; - - // Implements a member that is a lazily created POJO with inheritable - // values. - function inheritedMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - - Meta.prototype['write' + capitalized] = function (subkey, value) { - _emberMetalDebug.assert('Cannot call write' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var map = this._getOrCreateOwnMap(key); - map[subkey] = value; - }; - - Meta.prototype['peek' + capitalized] = function (subkey) { - return this._findInherited(key, subkey); - }; - - Meta.prototype['forEach' + capitalized] = function (fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - for (var _key in map) { - if (!seen[_key]) { - seen[_key] = true; - fn(_key, map[_key]); - } - } - } - pointer = pointer.parent; - } - }; - - Meta.prototype['clear' + capitalized] = function () { - _emberMetalDebug.assert('Cannot call clear' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - this[key] = undefined; - }; - - Meta.prototype['deleteFrom' + capitalized] = function (subkey) { - delete this._getOrCreateOwnMap(key)[subkey]; - }; - - Meta.prototype['hasIn' + capitalized] = function (subkey) { - return this._findInherited(key, subkey) !== undefined; - }; - } - - Meta.prototype._getInherited = function (key) { - var pointer = this; - while (pointer !== undefined) { - if (pointer[key]) { - return pointer[key]; - } - pointer = pointer.parent; - } - }; - - Meta.prototype._findInherited = function (key, subkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var value = map[subkey]; - if (value !== undefined) { - return value; - } - } - pointer = pointer.parent; - } - }; - - var UNDEFINED = _emberUtils.symbol('undefined'); - - exports.UNDEFINED = UNDEFINED; - // Implements a member that provides a lazily created map of maps, - // with inheritance at both levels. - Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { - _emberMetalDebug.assert('Cannot call writeDeps after the object is destroyed.', !this.isMetaDestroyed()); - - var outerMap = this._getOrCreateOwnMap('_deps'); - var innerMap = outerMap[subkey]; - if (!innerMap) { - innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); - } - innerMap[itemkey] = value; - }; - - Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer._deps; - if (map) { - var value = map[subkey]; - if (value) { - if (value[itemkey] !== undefined) { - return value[itemkey]; - } - } - } - pointer = pointer.parent; - } - }; - - Meta.prototype.hasDeps = function hasDeps(subkey) { - var pointer = this; - while (pointer !== undefined) { - if (pointer._deps && pointer._deps[subkey]) { - return true; - } - pointer = pointer.parent; - } - return false; - }; - - Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { - return this._forEachIn('_deps', subkey, fn); - }; - - Meta.prototype._forEachIn = function (key, subkey, fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - var calls = []; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var innerMap = map[subkey]; - if (innerMap) { - for (var innerKey in innerMap) { - if (!seen[innerKey]) { - seen[innerKey] = true; - calls.push([innerKey, innerMap[innerKey]]); - } - } - } - } - pointer = pointer.parent; - } - for (var i = 0; i < calls.length; i++) { - var _calls$i = calls[i]; - var innerKey = _calls$i[0]; - var value = _calls$i[1]; - - fn(innerKey, value); - } - }; - - // Implements a member that provides a non-heritable, lazily-created - // object using the method you provide. - function ownCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { - _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var ret = this[key]; - if (!ret) { - ret = this[key] = create(this.source); - } - return ret; - }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; - }; - } - - // Implements a member that provides an inheritable, lazily-created - // object using the method you provide. We will derived children from - // their parents by calling your object's `copy()` method. - function inheritedCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { - _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var ret = this[key]; - if (!ret) { - if (this.parent) { - ret = this[key] = this.parent['writable' + capitalized](create).copy(this.source); - } else { - ret = this[key] = create(this.source); - } - } - return ret; - }; - Meta.prototype['readable' + capitalized] = function () { - return this._getInherited(key); - }; - } - - function memberProperty(name) { - return '_' + name; - } - - // there's a more general-purpose capitalize in ember-runtime, but we - // don't want to make ember-metal depend on ember-runtime. - function capitalize(name) { - return name.replace(/^\w/, function (m) { - return m.toUpperCase(); - }); - } - - var META_DESC = { - writable: true, - configurable: true, - enumerable: false, - value: null - }; - - exports.META_DESC = META_DESC; - var EMBER_META_PROPERTY = { - name: META_FIELD, - descriptor: META_DESC - }; - - if (true) { - Meta.prototype.readInheritedValue = function (key, subkey) { - var internalKey = '_' + key; - - var pointer = this; - - while (pointer !== undefined) { - var map = pointer[internalKey]; - if (map) { - var value = map[subkey]; - if (value !== undefined || subkey in map) { - return map[subkey]; - } - } - pointer = pointer.parent; - } - - return UNDEFINED; - }; - - Meta.prototype.writeValue = function (obj, key, value) { - var descriptor = _emberUtils.lookupDescriptor(obj, key); - var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - - if (isMandatorySetter) { - this.writeValues(key, value); - } else { - obj[key] = value; - } - }; - } - - var HAS_NATIVE_WEAKMAP = (function () { - // detect if `WeakMap` is even present - var hasWeakMap = typeof WeakMap === 'function'; - if (!hasWeakMap) { - return false; - } - - var instance = new WeakMap(); - // use `Object`'s `.toString` directly to prevent us from detecting - // polyfills as native weakmaps - return Object.prototype.toString.call(instance) === '[object WeakMap]'; - })(); - - var setMeta = undefined, - peekMeta = undefined; - - // choose the one appropriate for given platform - if (HAS_NATIVE_WEAKMAP) { - (function () { - var getPrototypeOf = Object.getPrototypeOf; - var metaStore = new WeakMap(); - - exports.setMeta = setMeta = function WeakMap_setMeta(obj, meta) { - _emberMetalDebug.runInDebug(function () { - return counters.setCalls++; - }); - metaStore.set(obj, meta); - }; - - exports.peekMeta = peekMeta = function WeakMap_peekMeta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.peekCalls++; - }); - - return metaStore.get(obj); - }; - - exports.peekMeta = peekMeta = function WeakMap_peekParentMeta(obj) { - var pointer = obj; - var meta = undefined; - while (pointer) { - meta = metaStore.get(pointer); - // jshint loopfunc:true - _emberMetalDebug.runInDebug(function () { - return counters.peekCalls++; - }); - // stop if we find a `null` value, since - // that means the meta was deleted - // any other truthy value is a "real" meta - if (meta === null || meta) { - return meta; - } - - pointer = getPrototypeOf(pointer); - _emberMetalDebug.runInDebug(function () { - return counters.peakPrototypeWalks++; - }); - } - }; - })(); - } else { - exports.setMeta = setMeta = function Fallback_setMeta(obj, meta) { - // if `null` already, just set it to the new value - // otherwise define property first - if (obj[META_FIELD] !== null) { - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(EMBER_META_PROPERTY); - } else { - Object.defineProperty(obj, META_FIELD, META_DESC); - } - } - - obj[META_FIELD] = meta; - }; - - exports.peekMeta = peekMeta = function Fallback_peekMeta(obj) { - return obj[META_FIELD]; - }; - } - - function deleteMeta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.deleteCalls++; - }); - - var meta = peekMeta(obj); - if (meta) { - meta.destroy(); - } - } - - /** - Retrieves the meta hash for an object. If `writable` is true ensures the - hash is writable for this object as well. - - The meta object contains information about computed property descriptors as - well as any watched properties and other information. You generally will - not access this information directly but instead work with higher level - methods that manipulate this hash indirectly. - - @method meta - @for Ember - @private - - @param {Object} obj The object to retrieve meta for - @param {Boolean} [writable=true] Pass `false` if you do not intend to modify - the meta hash, allowing the method to avoid making an unnecessary copy. - @return {Object} the meta hash for an object - */ - - function meta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.metaCalls++; - }); - - var maybeMeta = peekMeta(obj); - var parent = undefined; - - // remove this code, in-favor of explicit parent - if (maybeMeta) { - if (maybeMeta.source === obj) { - return maybeMeta; - } - parent = maybeMeta; - } - - var newMeta = new Meta(obj, parent); - setMeta(obj, newMeta); - return newMeta; - } - - exports.peekMeta = peekMeta; - exports.setMeta = setMeta; - exports.counters = counters; -}); -enifed('ember-metal/meta_listeners', ['exports'], function (exports) { - /* - When we render a rich template hierarchy, the set of events that - *might* happen tends to be much larger than the set of events that - actually happen. This implies that we should make listener creation & - destruction cheap, even at the cost of making event dispatch more - expensive. - - Thus we store a new listener with a single push and no new - allocations, without even bothering to do deduplication -- we can - save that for dispatch time, if an event actually happens. - */ - - /* listener flags */ - 'use strict'; - - var ONCE = 1; - exports.ONCE = ONCE; - var SUSPENDED = 2; - - exports.SUSPENDED = SUSPENDED; - var protoMethods = { - - addToListeners: function (eventName, target, method, flags) { - if (!this._listeners) { - this._listeners = []; - } - this._listeners.push(eventName, target, method, flags); - }, - - _finalizeListeners: function () { - if (this._listenersFinalized) { - return; - } - if (!this._listeners) { - this._listeners = []; - } - var pointer = this.parent; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - this._listeners = this._listeners.concat(listeners); - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - this._listenersFinalized = true; - }, - - removeFromListeners: function (eventName, target, method, didRemove) { - var pointer = this; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = listeners.length - 4; index >= 0; index -= 4) { - if (listeners[index] === eventName && (!method || listeners[index + 1] === target && listeners[index + 2] === method)) { - if (pointer === this) { - // we are modifying our own list, so we edit directly - if (typeof didRemove === 'function') { - didRemove(eventName, target, listeners[index + 2]); - } - listeners.splice(index, 4); - } else { - // we are trying to remove an inherited listener, so we do - // just-in-time copying to detach our own listeners from - // our inheritance chain. - this._finalizeListeners(); - return this.removeFromListeners(eventName, target, method); - } - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - }, - - matchingListeners: function (eventName) { - var pointer = this; - var result = []; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - if (listeners[index] === eventName) { - pushUniqueListener(result, listeners, index); - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - var sus = this._suspendedListeners; - if (sus) { - for (var susIndex = 0; susIndex < sus.length - 2; susIndex += 3) { - if (eventName === sus[susIndex]) { - for (var resultIndex = 0; resultIndex < result.length - 2; resultIndex += 3) { - if (result[resultIndex] === sus[susIndex + 1] && result[resultIndex + 1] === sus[susIndex + 2]) { - result[resultIndex + 2] |= SUSPENDED; - } - } - } - } - } - return result; - }, - - suspendListeners: function (eventNames, target, method, callback) { - var sus = this._suspendedListeners; - if (!sus) { - sus = this._suspendedListeners = []; - } - for (var i = 0; i < eventNames.length; i++) { - sus.push(eventNames[i], target, method); - } - try { - return callback.call(target); - } finally { - if (sus.length === eventNames.length) { - this._suspendedListeners = undefined; - } else { - for (var i = sus.length - 3; i >= 0; i -= 3) { - if (sus[i + 1] === target && sus[i + 2] === method && eventNames.indexOf(sus[i]) !== -1) { - sus.splice(i, 3); - } - } - } - } - }, - - watchedEvents: function () { - var pointer = this; - var names = {}; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - names[listeners[index]] = true; - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - return Object.keys(names); - }, - - _initializeListeners: function () { - this._listeners = undefined; - this._listenersFinalized = undefined; - this._suspendedListeners = undefined; - } - }; - - exports.protoMethods = protoMethods; - function pushUniqueListener(destination, source, index) { - var target = source[index + 1]; - var method = source[index + 2]; - for (var destinationIndex = 0; destinationIndex < destination.length - 2; destinationIndex += 3) { - if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { - return; - } - } - destination.push(target, method, source[index + 3]); - } -}); -enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-metal - */ - exports.detectBinding = detectBinding; - exports.mixin = mixin; - exports.default = Mixin; - exports.hasUnprocessedMixins = hasUnprocessedMixins; - exports.clearUnprocessedMixins = clearUnprocessedMixins; - exports.required = required; - exports.aliasMethod = aliasMethod; - exports.observer = observer; - exports._immediateObserver = _immediateObserver; - exports._beforeObserver = _beforeObserver; - - function ROOT() {} - ROOT.__hasSuper = false; - - var a_slice = [].slice; - - function isMethod(obj) { - return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; - } - - var CONTINUE = {}; - - function mixinProperties(mixinsMeta, mixin) { - var guid = undefined; - - if (mixin instanceof Mixin) { - guid = _emberUtils.guidFor(mixin); - if (mixinsMeta.peekMixins(guid)) { - return CONTINUE; - } - mixinsMeta.writeMixins(guid, mixin); - return mixin.properties; - } else { - return mixin; // apply anonymous mixin properties - } - } - - function concatenatedMixinProperties(concatProp, props, values, base) { - var concats = undefined; - - // reset before adding each new mixin to pickup concats from previous - concats = values[concatProp] || base[concatProp]; - if (props[concatProp]) { - concats = concats ? concats.concat(props[concatProp]) : props[concatProp]; - } - - return concats; - } - - function giveDescriptorSuper(meta, key, property, values, descs, base) { - var superProperty = undefined; - - // Computed properties override methods, and do not call super to them - if (values[key] === undefined) { - // Find the original descriptor in a parent mixin - superProperty = descs[key]; - } - - // If we didn't find the original descriptor in a parent mixin, find - // it on the original object. - if (!superProperty) { - var possibleDesc = base[key]; - var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - superProperty = superDesc; - } - - if (superProperty === undefined || !(superProperty instanceof _emberMetalComputed.ComputedProperty)) { - return property; - } - - // Since multiple mixins may inherit from the same parent, we need - // to clone the computed property so that other mixins do not receive - // the wrapped version. - property = Object.create(property); - property._getter = _emberUtils.wrap(property._getter, superProperty._getter); - if (superProperty._setter) { - if (property._setter) { - property._setter = _emberUtils.wrap(property._setter, superProperty._setter); - } else { - property._setter = superProperty._setter; - } - } - - return property; - } - - function giveMethodSuper(obj, key, method, values, descs) { - var superMethod = undefined; - - // Methods overwrite computed properties, and do not call super to them. - if (descs[key] === undefined) { - // Find the original method in a parent mixin - superMethod = values[key]; - } - - // If we didn't find the original value in a parent mixin, find it in - // the original object - superMethod = superMethod || obj[key]; - - // Only wrap the new method if the original method was a function - if (superMethod === undefined || 'function' !== typeof superMethod) { - return method; - } - - return _emberUtils.wrap(method, superMethod); - } - - function applyConcatenatedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; - var ret = undefined; - - if (baseValue) { - if ('function' === typeof baseValue.concat) { - if (value === null || value === undefined) { - ret = baseValue; - } else { - ret = baseValue.concat(value); - } - } else { - ret = _emberUtils.makeArray(baseValue).concat(value); - } - } else { - ret = _emberUtils.makeArray(value); - } - - _emberMetalDebug.runInDebug(function () { - // it is possible to use concatenatedProperties with strings (which cannot be frozen) - // only freeze objects... - if (typeof ret === 'object' && ret !== null) { - // prevent mutating `concatenatedProperties` array after it is applied - Object.freeze(ret); - } - }); - - return ret; - } - - function applyMergedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; - - _emberMetalDebug.runInDebug(function () { - if (Array.isArray(value)) { - // use conditional to avoid stringifying every time - _emberMetalDebug.assert('You passed in `' + JSON.stringify(value) + '` as the value for `' + key + '` but `' + key + '` cannot be an Array', false); - } - }); - - if (!baseValue) { - return value; - } - - var newBase = _emberUtils.assign({}, baseValue); - var hasFunction = false; - - for (var prop in value) { - if (!value.hasOwnProperty(prop)) { - continue; - } - - var propValue = value[prop]; - if (isMethod(propValue)) { - // TODO: support for Computed Properties, etc? - hasFunction = true; - newBase[prop] = giveMethodSuper(obj, prop, propValue, baseValue, {}); - } else { - newBase[prop] = propValue; - } - } - - if (hasFunction) { - newBase._super = ROOT; - } - - return newBase; - } - - function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { - if (value instanceof _emberMetalProperties.Descriptor) { - if (value === REQUIRED && descs[key]) { - return CONTINUE; - } - - // Wrap descriptor function to implement - // _super() if needed - if (value._getter) { - value = giveDescriptorSuper(meta, key, value, values, descs, base); - } - - descs[key] = value; - values[key] = undefined; - } else { - if (concats && concats.indexOf(key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') { - value = applyConcatenatedProperties(base, key, value, values); - } else if (mergings && mergings.indexOf(key) >= 0) { - value = applyMergedProperties(base, key, value, values); - } else if (isMethod(value)) { - value = giveMethodSuper(base, key, value, values, descs); - } - - descs[key] = undefined; - values[key] = value; - } - } - - function mergeMixins(mixins, m, descs, values, base, keys) { - var currentMixin = undefined, - props = undefined, - key = undefined, - concats = undefined, - mergings = undefined; - - function removeKeys(keyName) { - delete descs[keyName]; - delete values[keyName]; - } - - for (var i = 0; i < mixins.length; i++) { - currentMixin = mixins[i]; - _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - - props = mixinProperties(m, currentMixin); - if (props === CONTINUE) { - continue; - } - - if (props) { - if (base.willMergeMixin) { - base.willMergeMixin(props); - } - concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); - mergings = concatenatedMixinProperties('mergedProperties', props, values, base); - - for (key in props) { - if (!props.hasOwnProperty(key)) { - continue; - } - keys.push(key); - addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings); - } - - // manually copy toString() because some JS engines do not enumerate it - if (props.hasOwnProperty('toString')) { - base.toString = props.toString; - } - } else if (currentMixin.mixins) { - mergeMixins(currentMixin.mixins, m, descs, values, base, keys); - if (currentMixin._without) { - currentMixin._without.forEach(removeKeys); - } - } - } - } - - function detectBinding(key) { - var length = key.length; - - return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; - } - - // warm both paths of above function - detectBinding('notbound'); - detectBinding('fooBinding'); - - function connectBindings(obj, m) { - // TODO Mixin.apply(instance) should disconnect binding if exists - m.forEachBindings(function (key, binding) { - if (binding) { - var to = key.slice(0, -7); // strip Binding off end - if (binding instanceof _emberMetalBinding.Binding) { - binding = binding.copy(); // copy prototypes' instance - binding.to(to); - } else { - // binding is string path - binding = new _emberMetalBinding.Binding(to, binding); - } - binding.connect(obj); - obj[key] = binding; - } - }); - // mark as applied - m.clearBindings(); - } - - function finishPartial(obj, m) { - connectBindings(obj, m || _emberMetalMeta.meta(obj)); - return obj; - } - - function followAlias(obj, desc, m, descs, values) { - var altKey = desc.methodName; - var value = undefined; - var possibleDesc = undefined; - if (descs[altKey] || values[altKey]) { - value = values[altKey]; - desc = descs[altKey]; - } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - value = undefined; - } else { - desc = undefined; - value = obj[altKey]; - } - - return { desc: desc, value: value }; - } - - function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { - var paths = observerOrListener[pathsKey]; - - if (paths) { - for (var i = 0; i < paths.length; i++) { - updateMethod(obj, paths[i], null, key); - } - } - } - - function replaceObserversAndListeners(obj, key, observerOrListener) { - var prev = obj[key]; - - if ('function' === typeof prev) { - updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _emberMetalObserver._removeBeforeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_observes__', _emberMetalObserver.removeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_listens__', _emberMetalEvents.removeListener); - } - - if ('function' === typeof observerOrListener) { - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', _emberMetalObserver._addBeforeObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', _emberMetalObserver.addObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', _emberMetalEvents.addListener); - } - } - - function applyMixin(obj, mixins, partial) { - var descs = {}; - var values = {}; - var m = _emberMetalMeta.meta(obj); - var keys = []; - var key = undefined, - value = undefined, - desc = undefined; - - obj._super = ROOT; - - // Go through all mixins and hashes passed in, and: - // - // * Handle concatenated properties - // * Handle merged properties - // * Set up _super wrapping if necessary - // * Set up computed property descriptors - // * Copying `toString` in broken browsers - mergeMixins(mixins, m, descs, values, obj, keys); - - for (var i = 0; i < keys.length; i++) { - key = keys[i]; - if (key === 'constructor' || !values.hasOwnProperty(key)) { - continue; - } - - desc = descs[key]; - value = values[key]; - - if (desc === REQUIRED) { - continue; - } - - while (desc && desc instanceof Alias) { - var followed = followAlias(obj, desc, m, descs, values); - desc = followed.desc; - value = followed.value; - } - - if (desc === undefined && value === undefined) { - continue; - } - - replaceObserversAndListeners(obj, key, value); - - if (detectBinding(key)) { - m.writeBindings(key, value); - } - - _emberMetalProperties.defineProperty(obj, key, desc, value, m); - } - - if (!partial) { - // don't apply to prototype - finishPartial(obj, m); - } - - return obj; - } - - /** - @method mixin - @for Ember - @param obj - @param mixins* - @return obj - @private - */ - - function mixin(obj) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - applyMixin(obj, args, false); - return obj; - } - - /** - The `Ember.Mixin` class allows you to create mixins, whose properties can be - added to other classes. For instance, - - ```javascript - const EditableMixin = Ember.Mixin.create({ - edit() { - console.log('starting to edit'); - this.set('isEditing', true); - }, - isEditing: false - }); - - // Mix mixins into classes by passing them as the first arguments to - // `.extend.` - const Comment = Ember.Object.extend(EditableMixin, { - post: null - }); - - let comment = Comment.create(post: somePost); - comment.edit(); // outputs 'starting to edit' - ``` - - Note that Mixins are created with `Ember.Mixin.create`, not - `Ember.Mixin.extend`. - - Note that mixins extend a constructor's prototype so arrays and object literals - defined as properties will be shared amongst objects that implement the mixin. - If you want to define a property in a mixin that is not shared, you can define - it either as a computed property or have it be created on initialization of the object. - - ```javascript - // filters array will be shared amongst any object implementing mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.A() - }); - - // filters will be a separate array for every object implementing the mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.computed(function() { - return Ember.A(); - }) - }); - - // filters will be created as a separate array during the object's initialization - const Filterable = Ember.Mixin.create({ - init() { - this._super(...arguments); - this.set("filters", Ember.A()); - } - }); - ``` - - @class Mixin - @namespace Ember - @public - */ - - function Mixin(args, properties) { - this.properties = properties; - - var length = args && args.length; - - if (length > 0) { - var m = new Array(length); - - for (var i = 0; i < length; i++) { - var x = args[i]; - if (x instanceof Mixin) { - m[i] = x; - } else { - m[i] = new Mixin(undefined, x); - } - } - - this.mixins = m; - } else { - this.mixins = undefined; - } - this.ownerConstructor = undefined; - this._without = undefined; - this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; - _emberMetalDebug.debugSeal(this); - } - - Mixin._apply = applyMixin; - - Mixin.applyPartial = function (obj) { - var args = a_slice.call(arguments, 1); - return applyMixin(obj, args, true); - }; - - Mixin.finishPartial = finishPartial; - - var unprocessedFlag = false; - - function hasUnprocessedMixins() { - return unprocessedFlag; - } - - function clearUnprocessedMixins() { - unprocessedFlag = false; - } - - /** - @method create - @static - @param arguments* - @public - */ - Mixin.create = function () { - // ES6TODO: this relies on a global state? - unprocessedFlag = true; - var M = this; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return new M(args, undefined); - }; - - var MixinPrototype = Mixin.prototype; - - /** - @method reopen - @param arguments* - @private - */ - MixinPrototype.reopen = function () { - var currentMixin = undefined; - - if (this.properties) { - currentMixin = new Mixin(undefined, this.properties); - this.properties = undefined; - this.mixins = [currentMixin]; - } else if (!this.mixins) { - this.mixins = []; - } - - var mixins = this.mixins; - var idx = undefined; - - for (idx = 0; idx < arguments.length; idx++) { - currentMixin = arguments[idx]; - _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - - if (currentMixin instanceof Mixin) { - mixins.push(currentMixin); - } else { - mixins.push(new Mixin(undefined, currentMixin)); - } - } - - return this; - }; - - /** - @method apply - @param obj - @return applied object - @private - */ - MixinPrototype.apply = function (obj) { - return applyMixin(obj, [this], false); - }; - - MixinPrototype.applyPartial = function (obj) { - return applyMixin(obj, [this], true); - }; - - MixinPrototype.toString = Object.toString; - - function _detect(curMixin, targetMixin, seen) { - var guid = _emberUtils.guidFor(curMixin); - - if (seen[guid]) { - return false; - } - seen[guid] = true; - - if (curMixin === targetMixin) { - return true; - } - var mixins = curMixin.mixins; - var loc = mixins ? mixins.length : 0; - while (--loc >= 0) { - if (_detect(mixins[loc], targetMixin, seen)) { - return true; - } - } - return false; - } - - /** - @method detect - @param obj - @return {Boolean} - @private - */ - MixinPrototype.detect = function (obj) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - if (obj instanceof Mixin) { - return _detect(obj, this, {}); - } - var m = _emberMetalMeta.peekMeta(obj); - if (!m) { - return false; - } - return !!m.peekMixins(_emberUtils.guidFor(this)); - }; - - MixinPrototype.without = function () { - var ret = new Mixin([this]); - - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - ret._without = args; - return ret; - }; - - function _keys(ret, mixin, seen) { - if (seen[_emberUtils.guidFor(mixin)]) { - return; - } - seen[_emberUtils.guidFor(mixin)] = true; - - if (mixin.properties) { - 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); - }); - } - } - - MixinPrototype.keys = function () { - var keys = {}; - var seen = {}; - - _keys(keys, this, seen); - var ret = Object.keys(keys); - return ret; - }; - - _emberMetalDebug.debugSeal(MixinPrototype); - - // returns the mixins currently applied to the specified object - // TODO: Make Ember.mixin - Mixin.mixins = function (obj) { - var m = _emberMetalMeta.peekMeta(obj); - var ret = []; - if (!m) { - return ret; - } - - m.forEachMixins(function (key, currentMixin) { - // skip primitive mixins since these are always anonymous - if (!currentMixin.properties) { - ret.push(currentMixin); - } - }); - - return ret; - }; - - var REQUIRED = new _emberMetalProperties.Descriptor(); - REQUIRED.toString = function () { - return '(Required Property)'; - }; - - /** - Denotes a required property for a mixin - - @method required - @for Ember - @private - */ - - function required() { - _emberMetalDebug.deprecate('Ember.required is deprecated as its behavior is inconsistent and unreliable.', false, { id: 'ember-metal.required', until: '3.0.0' }); - return REQUIRED; - } - - function Alias(methodName) { - this.isDescriptor = true; - this.methodName = methodName; - } - - Alias.prototype = new _emberMetalProperties.Descriptor(); - - /** - Makes a method available via an additional name. - - ```javascript - App.Person = Ember.Object.extend({ - name: function() { - return 'Tomhuda Katzdale'; - }, - moniker: Ember.aliasMethod('name') - }); - - let goodGuy = App.Person.create(); - - goodGuy.name(); // 'Tomhuda Katzdale' - goodGuy.moniker(); // 'Tomhuda Katzdale' - ``` - - @method aliasMethod - @for Ember - @param {String} methodName name of the method to alias - @public - */ - - function aliasMethod(methodName) { - return new Alias(methodName); - } - - // .......................................................... - // OBSERVER HELPER - // - - /** - Specify a method that observes property changes. - - ```javascript - Ember.Object.extend({ - valueObserver: Ember.observer('value', function() { - // Executes whenever the "value" property changes - }) - }); - ``` - - Also available as `Function.prototype.observes` if prototype extensions are - enabled. - - @method observer - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func - @public - */ - - function observer() { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - _emberMetalDebug.deprecate('Passing the dependentKeys after the callback function in Ember.observer is deprecated. Ensure the callback function is the last argument.', false, { id: 'ember-metal.observer-argument-order', until: '3.0.0' }); - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('Ember.observer called without a function'); - } - - func.__ember_observes__ = paths; - return func; - } - - /** - Specify a method that observes property changes. - - ```javascript - Ember.Object.extend({ - valueObserver: Ember.immediateObserver('value', function() { - // Executes whenever the "value" property changes - }) - }); - ``` - - In the future, `Ember.observer` may become asynchronous. In this event, - `Ember.immediateObserver` will maintain the synchronous behavior. - - Also available as `Function.prototype.observesImmediately` if prototype extensions are - enabled. - - @method _immediateObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @deprecated Use `Ember.observer` instead. - @return func - @private - */ - - function _immediateObserver() { - _emberMetalDebug.deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.', false, { id: 'ember-metal.immediate-observer', until: '3.0.0' }); - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - _emberMetalDebug.assert('Immediate observers must observe internal properties only, not properties on other objects.', typeof arg !== 'string' || arg.indexOf('.') === -1); - } - - return observer.apply(this, arguments); - } - - /** - When observers fire, they are called with the arguments `obj`, `keyName`. - - Note, `@each.property` observer is called per each add or replace of an element - and it's not called with a specific enumeration item. - - A `_beforeObserver` fires before a property changes. - - @method beforeObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func - @deprecated - @private - */ - - function _beforeObserver() { - for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { - args[_key5] = arguments[_key5]; - } - - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('_beforeObserver called without a function'); - } - - func.__ember_observesBefore__ = paths; - return func; - } - - exports.Mixin = Mixin; - exports.required = required; - exports.REQUIRED = REQUIRED; -}); -enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { - 'use strict'; - - exports.addObserver = addObserver; - exports.observersFor = observersFor; - exports.removeObserver = removeObserver; - exports._addBeforeObserver = _addBeforeObserver; - exports._suspendObserver = _suspendObserver; - exports._suspendObservers = _suspendObservers; - exports._removeBeforeObserver = _removeBeforeObserver; - - /** - @module ember-metal - */ - - var AFTER_OBSERVERS = ':change'; - var BEFORE_OBSERVERS = ':before'; - - function changeEvent(keyName) { - return keyName + AFTER_OBSERVERS; - } - - function beforeEvent(keyName) { - return keyName + BEFORE_OBSERVERS; - } - - /** - @method addObserver - @for Ember - @param obj - @param {String} _path - @param {Object|Function} target - @param {Function|String} [method] - @public - */ - - function addObserver(obj, _path, target, method) { - _emberMetalEvents.addListener(obj, changeEvent(_path), target, method); - _emberMetalWatching.watch(obj, _path); - - return this; - } - - function observersFor(obj, path) { - return _emberMetalEvents.listenersFor(obj, changeEvent(path)); - } - - /** - @method removeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @public - */ - - function removeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, changeEvent(path), target, method); - - return this; - } - - /** - @method _addBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _addBeforeObserver(obj, path, target, method) { - _emberMetalEvents.addListener(obj, beforeEvent(path), target, method); - _emberMetalWatching.watch(obj, path); - - return this; - } - - // Suspend observer during callback. - // - // This should only be used by the target of the observer - // while it is setting the observed path. - - function _suspendObserver(obj, path, target, method, callback) { - return _emberMetalEvents.suspendListener(obj, changeEvent(path), target, method, callback); - } - - function _suspendObservers(obj, paths, target, method, callback) { - var events = paths.map(changeEvent); - return _emberMetalEvents.suspendListeners(obj, events, target, method, callback); - } - - /** - @method removeBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _removeBeforeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, beforeEvent(path), target, method); - - return this; - } -}); -enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { - 'use strict'; - - exports.default = ObserverSet; - - /* - this.observerSet = { - [senderGuid]: { // variable name: `keySet` - [keyName]: listIndex - } - }, - this.observers = [ - { - sender: obj, - keyName: keyName, - eventName: eventName, - listeners: [ - [target, method, flags] - ] - }, - ... - ] - */ - - function ObserverSet() { - this.clear(); - } - - ObserverSet.prototype.add = function (sender, keyName, eventName) { - var observerSet = this.observerSet; - var observers = this.observers; - var senderGuid = _emberUtils.guidFor(sender); - var keySet = observerSet[senderGuid]; - var index = undefined; - - 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 = undefined, - observer = undefined, - sender = undefined; - this.clear(); - for (i = 0; i < observers.length; ++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; - exports.hasThis = hasThis; - exports.isPath = isPath; - exports.getFirstKey = getFirstKey; - exports.getTailPath = getTailPath; - - var IS_GLOBAL = /^[A-Z$]/; - var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; - var HAS_THIS = 'this.'; - - var isGlobalCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL.test(key); - }); - var isGlobalPathCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL_PATH.test(key); - }); - var hasThisCache = new _emberMetalCache.default(1000, function (key) { - return key.lastIndexOf(HAS_THIS, 0) === 0; - }); - var firstDotIndexCache = new _emberMetalCache.default(1000, function (key) { - return key.indexOf('.'); - }); - - var firstKeyCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index === -1) { - return path; - } else { - return path.slice(0, index); - } - }); - - var tailPathCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index !== -1) { - return path.slice(index + 1); - } - }); - - var caches = { - isGlobalCache: isGlobalCache, - isGlobalPathCache: isGlobalPathCache, - hasThisCache: hasThisCache, - firstDotIndexCache: firstDotIndexCache, - firstKeyCache: firstKeyCache, - tailPathCache: tailPathCache - }; - - exports.caches = caches; - - function isGlobal(path) { - return isGlobalCache.get(path); - } - - function isGlobalPath(path) { - return isGlobalPathCache.get(path); - } - - function hasThis(path) { - return hasThisCache.get(path); - } - - function isPath(path) { - return firstDotIndexCache.get(path) !== -1; - } - - function getFirstKey(path) { - return firstKeyCache.get(path); - } - - function getTailPath(path) { - return tailPathCache.get(path); - } -}); -enifed('ember-metal/properties', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/property_events'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperty_events) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.Descriptor = Descriptor; - exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; - exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; - exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; - exports.defineProperty = defineProperty; - - // .......................................................... - // DESCRIPTOR - // - - /** - Objects of this type can implement an interface to respond to requests to - get and set. The default implementation handles simple properties. - - @class Descriptor - @private - */ - - function Descriptor() { - this.isDescriptor = true; - } - - var REDEFINE_SUPPORTED = (function () { - // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 - var a = Object.create(Object.prototype, { - prop: { - configurable: true, - value: 1 - } - }); - - Object.defineProperty(a, 'prop', { - configurable: true, - value: 2 - }); - - return a.prop === 2; - })(); - // .......................................................... - // DEFINING PROPERTIES API - // - - function MANDATORY_SETTER_FUNCTION(name) { - function SETTER_FUNCTION(value) { - var m = _emberMetalMeta.peekMeta(this); - if (!m.isInitialized(this)) { - m.writeValues(name, value); - } else { - _emberMetalDebug.assert('You must use Ember.set() to set the `' + name + '` property (of ' + this + ') to `' + value + '`.', false); - } - } - - SETTER_FUNCTION.isMandatorySetter = true; - return SETTER_FUNCTION; - } - - function DEFAULT_GETTER_FUNCTION(name) { - return function GETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - return meta && meta.peekValues(name); - }; - } - - function INHERITING_GETTER_FUNCTION(name) { - function IGETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - var val = meta && meta.readInheritedValue('values', name); - - if (val === _emberMetalMeta.UNDEFINED) { - var proto = Object.getPrototypeOf(this); - return proto && proto[name]; - } else { - return val; - } - } - - IGETTER_FUNCTION.isInheritingGetter = true; - return IGETTER_FUNCTION; - } - - /** - NOTE: This is a low-level method used by other parts of the API. You almost - never want to call this method directly. Instead you should use - `Ember.mixin()` to define new properties. - - Defines a property on an object. This method works much like the ES5 - `Object.defineProperty()` method except that it can also accept computed - properties and other special descriptors. - - Normally this method takes only three parameters. However if you pass an - instance of `Descriptor` as the third param then you can pass an - optional value as the fourth parameter. This is often more efficient than - creating new descriptor hashes for each property. - - ## Examples - - ```javascript - // ES5 compatible mode - Ember.defineProperty(contact, 'firstName', { - writable: true, - configurable: false, - enumerable: true, - value: 'Charles' - }); - - // define a simple property - Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); - - // define a computed property - Ember.defineProperty(contact, 'fullName', Ember.computed('firstName', 'lastName', function() { - return this.firstName+' '+this.lastName; - })); - ``` - - @private - @method defineProperty - @for Ember - @param {Object} obj the object to define this property on. This may be a prototype. - @param {String} keyName the name of the property - @param {Descriptor} [desc] an instance of `Descriptor` (typically a - computed property) or an ES5 descriptor. - You must provide this or `data` but not both. - @param {*} [data] something other than a descriptor, that will - become the explicit value of this property. - */ - - function defineProperty(obj, keyName, desc, data, meta) { - var possibleDesc = undefined, - existingDesc = undefined, - watching = undefined, - value = undefined; - - if (!meta) { - meta = _emberMetalMeta.meta(obj); - } - var watchEntry = meta.peekWatching(keyName); - possibleDesc = obj[keyName]; - existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - watching = watchEntry !== undefined && watchEntry > 0; - - if (existingDesc) { - existingDesc.teardown(obj, keyName); - } - - if (desc instanceof Descriptor) { - value = desc; - if (true) { - if (watching) { - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: true, - writable: true, - value: value - }); - } else { - obj[keyName] = value; - } - } else { - obj[keyName] = value; - } - if (desc.setup) { - desc.setup(obj, keyName); - } - } else { - if (desc == null) { - value = data; - - if (true) { - if (watching) { - meta.writeValues(keyName, data); - - var defaultDescriptor = { - configurable: true, - enumerable: true, - set: MANDATORY_SETTER_FUNCTION(keyName), - get: DEFAULT_GETTER_FUNCTION(keyName) - }; - - if (REDEFINE_SUPPORTED) { - Object.defineProperty(obj, keyName, defaultDescriptor); - } else { - handleBrokenPhantomDefineProperty(obj, keyName, defaultDescriptor); - } - } else { - obj[keyName] = data; - } - } else { - obj[keyName] = data; - } - } else { - value = desc; - - // fallback to ES5 - Object.defineProperty(obj, keyName, desc); - } - } - - // if key is being watched, override chains that - // were initialized with the prototype - if (watching) { - _emberMetalProperty_events.overrideChains(obj, keyName, meta); - } - - // The `value` passed to the `didDefineProperty` hook is - // either the descriptor or data, whichever was passed. - if (obj.didDefineProperty) { - obj.didDefineProperty(obj, keyName, value); - } - - return this; - } - - function handleBrokenPhantomDefineProperty(obj, keyName, desc) { - // https://github.com/ariya/phantomjs/issues/11856 - Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); - Object.defineProperty(obj, keyName, desc); - } -}); -enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) { - 'use strict'; - - var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE'); - - exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; - var beforeObserverSet = new _emberMetalObserver_set.default(); - var observerSet = new _emberMetalObserver_set.default(); - var deferred = 0; - - // .......................................................... - // PROPERTY CHANGES - // - - /** - This function is called just before an object property is about to change. - It will notify any before observers and prepare caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyDidChange()` which you should call just - after the property value changes. - - @method propertyWillChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @return {void} - @private - */ - function propertyWillChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.willChange) { - desc.willChange(obj, keyName); - } - - if (watching) { - dependentKeysWillChange(obj, keyName, meta); - chainsWillChange(obj, keyName, meta); - notifyBeforeObservers(obj, keyName, meta); - } - } - - /** - This function is called just after an object property has changed. - It will notify any observers and clear caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyWillChange()` which you should call just - before the property value changes. - - @method propertyDidChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @param {Meta} meta The objects meta. - @return {void} - @private - */ - function propertyDidChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - // shouldn't this mean that we're watching this key? - if (desc && desc.didChange) { - desc.didChange(obj, keyName); - } - - if (watching) { - if (meta.hasDeps(keyName)) { - dependentKeysDidChange(obj, keyName, meta); - } - - chainsDidChange(obj, keyName, meta, false); - notifyObservers(obj, keyName, meta); - } - - if (obj[PROPERTY_DID_CHANGE]) { - obj[PROPERTY_DID_CHANGE](keyName); - } - - if (meta && meta.isSourceDestroying()) { - return; - } - - _emberMetalTags.markObjectAsDirty(meta, keyName); - - if (true || false) { - _emberMetalTransaction.assertNotRendered(obj, keyName, meta); - } - } - - var WILL_SEEN = undefined, - DID_SEEN = undefined; - // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) - function dependentKeysWillChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = WILL_SEEN; - var _top = !seen; - - if (_top) { - seen = WILL_SEEN = {}; - } - - iterDeps(propertyWillChange, obj, depKey, seen, meta); - - if (_top) { - WILL_SEEN = null; - } - } - } - - // called whenever a property has just changed to update dependent keys - function dependentKeysDidChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = DID_SEEN; - var _top2 = !seen; - - if (_top2) { - seen = DID_SEEN = {}; - } - - iterDeps(propertyDidChange, obj, depKey, seen, meta); - - if (_top2) { - DID_SEEN = null; - } - } - } - - function iterDeps(method, obj, depKey, seen, meta) { - var possibleDesc = undefined, - desc = undefined; - var guid = _emberUtils.guidFor(obj); - var current = seen[guid]; - - if (!current) { - current = seen[guid] = {}; - } - - if (current[depKey]) { - return; - } - - current[depKey] = true; - - meta.forEachInDeps(depKey, function (key, value) { - if (!value) { - return; - } - - possibleDesc = obj[key]; - desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc._suspended === obj) { - return; - } - - method(obj, key, meta); - }); - } - - function chainsWillChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, false, propertyWillChange); - } - } - - function chainsDidChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, true, propertyDidChange); - } - } - - function overrideChains(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - } - - /** - @method beginPropertyChanges - @chainable - @private - */ - function beginPropertyChanges() { - deferred++; - } - - /** - @method endPropertyChanges - @private - */ - function endPropertyChanges() { - deferred--; - if (deferred <= 0) { - beforeObserverSet.clear(); - observerSet.flush(); - } - } - - /** - Make a series of property changes together in an - exception-safe way. - - ```javascript - Ember.changeProperties(function() { - obj1.set('foo', mayBlowUpWhenSet); - obj2.set('bar', baz); - }); - ``` - - @method changeProperties - @param {Function} callback - @param [binding] - @private - */ - function changeProperties(callback, binding) { - beginPropertyChanges(); - try { - callback.call(binding); - } finally { - endPropertyChanges.call(binding); - } - } - - function notifyBeforeObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':before'; - var listeners = undefined, - added = undefined; - if (deferred) { - listeners = beforeObserverSet.add(obj, keyName, eventName); - added = _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName], added); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - function notifyObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':change'; - var listeners = undefined; - if (deferred) { - listeners = observerSet.add(obj, keyName, eventName); - _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - exports.propertyWillChange = propertyWillChange; - exports.propertyDidChange = propertyDidChange; - exports.overrideChains = overrideChains; - exports.beginPropertyChanges = beginPropertyChanges; - exports.endPropertyChanges = endPropertyChanges; - exports.changeProperties = changeProperties; -}); -enifed('ember-metal/property_get', ['exports', 'ember-metal/debug', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalPath_cache) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.get = get; - exports._getPath = _getPath; - exports.getWithDefault = getWithDefault; - - var ALLOWABLE_TYPES = { - object: true, - function: true, - string: true - }; - - // .......................................................... - // GET AND SET - // - // If we are on a platform that supports accessors we can use those. - // Otherwise simulate accessors by looking up the property directly on the - // object. - - /** - Gets the value of a property on an object. If the property is computed, - the function will be invoked. If the property is not defined but the - object implements the `unknownProperty` method then that will be invoked. - - ```javascript - Ember.get(obj, "name"); - ``` - - If you plan to run on IE8 and older browsers then you should use this - method anytime you want to retrieve a property on an object that you don't - know for sure is private. (Properties beginning with an underscore '_' - are considered private.) - - On all newer browsers, you only need to use this method to retrieve - properties if the property might not be defined on the object and you want - to respect the `unknownProperty` handler. Otherwise you can ignore this - method. - - Note that if the object itself is `undefined`, this method will throw - an error. - - @method get - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The property key to retrieve - @return {Object} the property value or `null`. - @public - */ - - function get(obj, keyName) { - _emberMetalDebug.assert('Get must be called with two arguments; an object and a property key', arguments.length === 2); - _emberMetalDebug.assert('Cannot call get with \'' + keyName + '\' on an undefined object.', obj !== undefined && obj !== null); - _emberMetalDebug.assert('The key provided to get must be a string, you passed ' + keyName, typeof keyName === 'string'); - _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); - _emberMetalDebug.assert('Cannot call `Ember.get` with an empty string', keyName !== ''); - - var value = obj[keyName]; - var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined; - var ret = undefined; - - if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) { - return _getPath(obj, keyName); - } - - if (desc) { - return desc.get(obj, keyName); - } else { - ret = value; - - if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { - return obj.unknownProperty(keyName); - } - - return ret; - } - } - - function _getPath(root, path) { - var obj = root; - var parts = path.split('.'); - - for (var i = 0; i < parts.length; i++) { - if (!isGettable(obj)) { - return undefined; - } - - obj = get(obj, parts[i]); - - if (obj && obj.isDestroyed) { - return undefined; - } - } - - return obj; - } - - function isGettable(obj) { - if (obj == null) { - return false; - } - - return ALLOWABLE_TYPES[typeof obj]; - } - - /** - Retrieves the value of a property from an Object, or a default value in the - case that the property returns `undefined`. - - ```javascript - Ember.getWithDefault(person, 'lastName', 'Doe'); - ``` - - @method getWithDefault - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public - */ - - function getWithDefault(root, key, defaultValue) { - var value = get(root, key); - - if (value === undefined) { - return defaultValue; - } - return value; - } - - exports.default = get; -}); -enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) { - 'use strict'; - - exports.set = set; - exports.trySet = trySet; - - /** - Sets the value of a property on an object, respecting computed properties - and notifying observers and other listeners of the change. If the - property is not defined but the object implements the `setUnknownProperty` - method then that will be invoked as well. - - ```javascript - Ember.set(obj, "name", value); - ``` - - @method set - @for Ember - @param {Object} obj The object to modify. - @param {String} keyName The property key to set - @param {Object} value The value to set - @return {Object} the passed value. - @public - */ - - function set(obj, keyName, value, tolerant) { - _emberMetalDebug.assert('Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false', arguments.length === 3 || arguments.length === 4); - _emberMetalDebug.assert('Cannot call set with \'' + keyName + '\' on an undefined object.', obj && typeof obj === 'object' || typeof obj === 'function'); - _emberMetalDebug.assert('The key provided to set must be a string, you passed ' + keyName, typeof keyName === 'string'); - _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); - _emberMetalDebug.assert('calling set on destroyed object: ' + _emberUtils.toString(obj) + '.' + keyName + ' = ' + _emberUtils.toString(value), !obj.isDestroyed); - - if (_emberMetalPath_cache.isPath(keyName)) { - return setPath(obj, keyName, value, tolerant); - } - - var meta = _emberMetalMeta.peekMeta(obj); - var possibleDesc = obj[keyName]; - - var desc = undefined, - currentValue = undefined; - if (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - } else { - currentValue = possibleDesc; - } - - if (desc) { - /* computed property */ - desc.set(obj, keyName, value); - } else if (obj.setUnknownProperty && currentValue === undefined && !(keyName in obj)) { - /* unknown property */ - _emberMetalDebug.assert('setUnknownProperty must be a function', typeof obj.setUnknownProperty === 'function'); - obj.setUnknownProperty(keyName, value); - } else if (currentValue === value) { - /* no change */ - return value; - } else { - _emberMetalProperty_events.propertyWillChange(obj, keyName); - - if (true) { - setWithMandatorySetter(meta, obj, keyName, value); - } else { - obj[keyName] = value; - } - - _emberMetalProperty_events.propertyDidChange(obj, keyName); - } - - return value; - } - - if (true) { - var setWithMandatorySetter = function (meta, obj, keyName, value) { - if (meta && meta.peekWatching(keyName) > 0) { - makeEnumerable(obj, keyName); - meta.writeValue(obj, keyName, value); - } else { - obj[keyName] = value; - } - }; - - var makeEnumerable = function (obj, key) { - var desc = Object.getOwnPropertyDescriptor(obj, key); - - if (desc && desc.set && desc.set.isMandatorySetter) { - desc.enumerable = true; - Object.defineProperty(obj, key, desc); - } - }; - } - - function setPath(root, path, value, tolerant) { - // get the last part of the path - var keyName = path.slice(path.lastIndexOf('.') + 1); - - // get the first part of the part - path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); - - // unless the path is this, look up the first part to - // get the root - if (path !== 'this') { - root = _emberMetalProperty_get._getPath(root, path); - } - - if (!keyName || keyName.length === 0) { - throw new _emberMetalError.default('Property set failed: You passed an empty path'); - } - - if (!root) { - if (tolerant) { - return; - } else { - throw new _emberMetalError.default('Property set failed: object in path "' + path + '" could not be found or was destroyed.'); - } - } - - return set(root, keyName, value); - } - - /** - Error-tolerant form of `Ember.set`. Will not blow up if any part of the - chain is `undefined`, `null`, or destroyed. - - This is primarily used when syncing bindings, which may try to update after - an object has been destroyed. - - @method trySet - @for Ember - @param {Object} root The object to modify. - @param {String} path The property path to set - @param {Object} value The value to set - @public - */ - - function trySet(root, path, value) { - return set(root, path, value, true); - } -}); -enifed("ember-metal/replace", ["exports"], function (exports) { - "use strict"; - - exports.default = replace; - var splice = Array.prototype.splice; - - function replace(array, idx, amt, objects) { - var args = [].concat(objects); - var ret = []; - // https://code.google.com/p/chromium/issues/detail?id=56588 - var size = 60000; - var start = idx; - var ends = amt; - var count = undefined, - chunk = undefined; - - while (args.length) { - count = ends > size ? size : ends; - if (count <= 0) { - count = 0; - } - - chunk = args.splice(0, size); - chunk = [start, count].concat(chunk); - - start += size; - ends -= count; - - ret = ret.concat(splice.apply(array, chunk)); - } - return ret; - } -}); -enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) { - 'use strict'; - - exports.default = run; - - function onBegin(current) { - run.currentRunLoop = current; - } - - function onEnd(current, next) { - run.currentRunLoop = next; - } - - var onErrorTarget = { - get onerror() { - return _emberMetalError_handler.getOnerror(); - }, - set onerror(handler) { - return _emberMetalError_handler.setOnerror(handler); - } - }; - - var backburner = new _backburner.default(['sync', 'actions', 'destroy'], { - GUID_KEY: _emberUtils.GUID_KEY, - sync: { - before: _emberMetalProperty_events.beginPropertyChanges, - after: _emberMetalProperty_events.endPropertyChanges - }, - defaultQueue: 'actions', - onBegin: onBegin, - onEnd: onEnd, - onErrorTarget: onErrorTarget, - onErrorMethod: 'onerror' - }); - - // .......................................................... - // run - this is ideally the only public API the dev sees - // - - /** - Runs the passed target and method inside of a RunLoop, ensuring any - deferred actions including bindings and views updates are flushed at the - end. - - Normally you should not need to invoke this method yourself. However if - you are implementing raw event handlers when interfacing with other - libraries or plugins, you should probably wrap all of your code inside this - call. - - ```javascript - run(function() { - // code to be executed within a RunLoop - }); - ``` - - @class run - @namespace Ember - @static - @constructor - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} return value from invoking the passed function. - @public - */ - - function run() { - return backburner.run.apply(backburner, arguments); - } - - /** - If no run-loop is present, it creates a new one. If a run loop is - present it will queue itself to run on the existing run-loops action - queue. - - Please note: This is not for normal usage, and should be used sparingly. - - If invoked when not within a run loop: - - ```javascript - run.join(function() { - // creates a new run-loop - }); - ``` - - Alternatively, if called within an existing run loop: - - ```javascript - run(function() { - // creates a new run-loop - run.join(function() { - // joins with the existing run-loop, and queues for invocation on - // the existing run-loops action queue. - }); - }); - ``` - - @method join - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} Return value from invoking the passed function. Please note, - when called within an existing loop, no return value is possible. - @public - */ - run.join = function () { - return backburner.join.apply(backburner, arguments); - }; - - /** - Allows you to specify which context to call the specified function in while - adding the execution of that function to the Ember run loop. This ability - makes this method a great way to asynchronously integrate third-party libraries - into your Ember application. - - `run.bind` takes two main arguments, the desired context and the function to - invoke in that context. Any additional arguments will be supplied as arguments - to the function that is passed in. - - Let's use the creation of a TinyMCE component as an example. Currently, - TinyMCE provides a setup configuration option we can use to do some processing - after the TinyMCE instance is initialized but before it is actually rendered. - We can use that setup option to do some additional setup for our component. - The component itself could look something like the following: - - ```javascript - App.RichTextEditorComponent = Ember.Component.extend({ - initializeTinyMCE: Ember.on('didInsertElement', function() { - tinymce.init({ - selector: '#' + this.$().prop('id'), - setup: Ember.run.bind(this, this.setupEditor) - }); - }), - - setupEditor: function(editor) { - this.set('editor', editor); - - editor.on('change', function() { - console.log('content changed!'); - }); - } - }); - ``` - - In this example, we use Ember.run.bind to bind the setupEditor method to the - context of the App.RichTextEditorComponent and to have the invocation of that - method be safely handled and executed by the Ember run loop. - - @method bind - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Function} returns a new function that will always have a particular context - @since 1.4.0 - @public - */ - run.bind = function () { - for (var _len = arguments.length, curried = Array(_len), _key = 0; _key < _len; _key++) { - curried[_key] = arguments[_key]; - } - - return function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return run.join.apply(run, curried.concat(args)); - }; - }; - - run.backburner = backburner; - run.currentRunLoop = null; - run.queues = backburner.queueNames; - - /** - Begins a new RunLoop. Any deferred actions invoked after the begin will - be buffered until you invoke a matching call to `run.end()`. This is - a lower-level way to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method begin - @return {void} - @public - */ - run.begin = function () { - backburner.begin(); - }; - - /** - Ends a RunLoop. This must be called sometime after you call - `run.begin()` to flush any deferred actions. This is a lower-level way - to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method end - @return {void} - @public - */ - run.end = function () { - backburner.end(); - }; - - /** - Array of named queues. This array determines the order in which queues - are flushed at the end of the RunLoop. You can define your own queues by - simply adding the queue name to this array. Normally you should not need - to inspect or modify this property. - - @property queues - @type Array - @default ['sync', 'actions', 'destroy'] - @private - */ - - /** - Adds the passed target/method and any optional arguments to the named - queue to be executed at the end of the RunLoop. If you have not already - started a RunLoop when calling this method one will be started for you - automatically. - - At the end of a RunLoop, any methods scheduled in this way will be invoked. - Methods will be invoked in an order matching the named queues defined in - the `run.queues` property. - - ```javascript - run.schedule('sync', this, function() { - // this will be executed in the first RunLoop queue, when bindings are synced - console.log('scheduled on sync queue'); - }); - - run.schedule('actions', this, function() { - // this will be executed in the 'actions' queue, after bindings have synced. - console.log('scheduled on actions queue'); - }); - - // Note the functions will be run in order based on the run queues order. - // Output would be: - // scheduled on sync queue - // scheduled on actions queue - ``` - - @method schedule - @param {String} queue The name of the queue to schedule against. - Default queues are 'sync' and 'actions' - @param {Object} [target] target object to use as the context when invoking a method. - @param {String|Function} method The method to invoke. If you pass a string it - will be resolved on the target object at the time the scheduled item is - invoked allowing you to change the target function. - @param {Object} [arguments*] Optional arguments to be passed to the queued method. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.schedule = function () /* queue, target, method */{ - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - - return backburner.schedule.apply(backburner, arguments); - }; - - // Used by global test teardown - run.hasScheduledTimers = function () { - return backburner.hasTimers(); - }; - - // Used by global test teardown - run.cancelTimers = function () { - backburner.cancelTimers(); - }; - - /** - Immediately flushes any events scheduled in the 'sync' queue. Bindings - use this queue so this method is a useful way to immediately force all - bindings in the application to sync. - - You should call this method anytime you need any changed state to propagate - throughout the app immediately without repainting the UI (which happens - in the later 'render' queue added by the `ember-views` package). - - ```javascript - run.sync(); - ``` - - @method sync - @return {void} - @private - */ - run.sync = function () { - if (backburner.currentInstance) { - backburner.currentInstance.queues.sync.flush(); - } - }; - - /** - Invokes the passed target/method and optional arguments after a specified - period of time. The last parameter of this method must always be a number - of milliseconds. - - You should use this method whenever you need to run some action after a - period of time instead of using `setTimeout()`. This method will ensure that - items that expire during the same script execution cycle all execute - together, which is often more efficient than using a real setTimeout. - - ```javascript - run.later(myContext, function() { - // code here will execute within a RunLoop in about 500ms with this == myContext - }, 500); - ``` - - @method later - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.later = function () /*target, method*/{ - return backburner.later.apply(backburner, arguments); - }; - - /** - Schedule a function to run one time during the current RunLoop. This is equivalent - to calling `scheduleOnce` with the "actions" queue. - - @method once - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.once = function () { - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - args.unshift('actions'); - return backburner.scheduleOnce.apply(backburner, args); - }; - - /** - Schedules a function to run one time in a given queue of the current RunLoop. - Calling this method with the same queue/target/method combination will have - no effect (past the initial call). - - Note that although you can pass optional arguments these will not be - considered when looking for duplicates. New arguments will replace previous - calls. - - ```javascript - function sayHi() { - console.log('hi'); - } - - run(function() { - run.scheduleOnce('afterRender', myContext, sayHi); - run.scheduleOnce('afterRender', myContext, sayHi); - // sayHi will only be executed once, in the afterRender queue of the RunLoop - }); - ``` - - Also note that passing an anonymous function to `run.scheduleOnce` will - not prevent additional calls with an identical anonymous function from - scheduling the items multiple times, e.g.: - - ```javascript - function scheduleIt() { - run.scheduleOnce('actions', myContext, function() { - console.log('Closure'); - }); - } - - scheduleIt(); - scheduleIt(); - - // "Closure" will print twice, even though we're using `run.scheduleOnce`, - // because the function we pass to it is anonymous and won't match the - // previously scheduled operation. - ``` - - Available queues, and their order, can be found at `run.queues` - - @method scheduleOnce - @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'. - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.scheduleOnce = function () /*queue, target, method*/{ - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - return backburner.scheduleOnce.apply(backburner, arguments); - }; - - /** - Schedules an item to run from within a separate run loop, after - control has been returned to the system. This is equivalent to calling - `run.later` with a wait time of 1ms. - - ```javascript - run.next(myContext, function() { - // code to be executed in the next run loop, - // which will be scheduled after the current one - }); - ``` - - Multiple operations scheduled with `run.next` will coalesce - into the same later run loop, along with any other operations - scheduled by `run.later` that expire right around the same - time that `run.next` operations will fire. - - Note that there are often alternatives to using `run.next`. - For instance, if you'd like to schedule an operation to happen - after all DOM element operations have completed within the current - run loop, you can make use of the `afterRender` run loop queue (added - by the `ember-views` package, along with the preceding `render` queue - where all the DOM element operations happen). - - Example: - - ```javascript - export default Ember.Component.extend({ - didInsertElement() { - this._super(...arguments); - run.scheduleOnce('afterRender', this, 'processChildElements'); - }, - - processChildElements() { - // ... do something with component's child component - // elements after they've finished rendering, which - // can't be done within this component's - // `didInsertElement` hook because that gets run - // before the child elements have been added to the DOM. - } - }); - ``` - - One benefit of the above approach compared to using `run.next` is - that you will be able to perform DOM/CSS operations before unprocessed - elements are rendered to the screen, which may prevent flickering or - other artifacts caused by delaying processing until after rendering. - - The other major benefit to the above approach is that `run.next` - introduces an element of non-determinism, which can make things much - harder to test, due to its reliance on `setTimeout`; it's much harder - to guarantee the order of scheduled operations when they are scheduled - outside of the current run loop, i.e. with `run.next`. - - @method next - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.next = function () { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - args.push(1); - return backburner.later.apply(backburner, args); - }; - - /** - Cancels a scheduled item. Must be a value returned by `run.later()`, - `run.once()`, `run.scheduleOnce()`, `run.next()`, `run.debounce()`, or - `run.throttle()`. - - ```javascript - let runNext = run.next(myContext, function() { - // will not be executed - }); - - run.cancel(runNext); - - let runLater = run.later(myContext, function() { - // will not be executed - }, 500); - - run.cancel(runLater); - - let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { - // will not be executed - }); - - run.cancel(runScheduleOnce); - - let runOnce = run.once(myContext, function() { - // will not be executed - }); - - run.cancel(runOnce); - - let throttle = run.throttle(myContext, function() { - // will not be executed - }, 1, false); - - run.cancel(throttle); - - let debounce = run.debounce(myContext, function() { - // will not be executed - }, 1); - - run.cancel(debounce); - - let debounceImmediate = run.debounce(myContext, function() { - // will be executed since we passed in true (immediate) - }, 100, true); - - // the 100ms delay until this method can be called again will be cancelled - run.cancel(debounceImmediate); - ``` - - @method cancel - @param {Object} timer Timer object to cancel - @return {Boolean} true if cancelled or false/undefined if it wasn't found - @public - */ - run.cancel = function (timer) { - return backburner.cancel(timer); - }; - - /** - Delay calling the target method until the debounce period has elapsed - with no additional debounce calls. If `debounce` is called again before - the specified time has elapsed, the timer is reset and the entire period - must pass again before the target method is called. - - This method should be used when an event may be called multiple times - but the action should only be called once when the event is done firing. - A common example is for scroll events where you only want updates to - happen once scrolling has ceased. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150); - - // less than 150ms passes - run.debounce(myContext, whoRan, 150); - - // 150ms passes - // whoRan is invoked with context myContext - // console logs 'debounce ran.' one time. - ``` - - Immediate allows you to run the function immediately, but debounce - other calls for this function until the wait time has elapsed. If - `debounce` is called again before the specified time has elapsed, - the timer is reset and the entire period must pass again before - the method can be called again. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 100ms passes - run.debounce(myContext, whoRan, 150, true); - - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - - ``` - - @method debounce - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to false. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.debounce = function () { - return backburner.debounce.apply(backburner, arguments); - }; - - /** - Ensure that the target method is never called more frequently than - the specified spacing period. The target method is called immediately. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'throttle' }; - - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 150ms passes - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - ``` - - @method throttle - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} spacing Number of milliseconds to space out requests. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to true. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.throttle = function () { - return backburner.throttle.apply(backburner, arguments); - }; - - /** - Add a new named queue after the specified queue. - - The queue to add will only be added once. - - @method _addQueue - @param {String} name the name of the queue to add. - @param {String} after the name of the queue to add after. - @private - */ - run._addQueue = function (name, after) { - if (run.queues.indexOf(name) === -1) { - run.queues.splice(run.queues.indexOf(after) + 1, 0, name); - } - }; -}); -enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set'], function (exports, _emberMetalProperty_events, _emberMetalProperty_set) { - 'use strict'; - - exports.default = setProperties; - - /** - Set a list of properties on an object. These properties are set inside - a single `beginPropertyChanges` and `endPropertyChanges` batch, so - observers will be buffered. - - ```javascript - let anObject = Ember.Object.create(); - - anObject.setProperties({ - firstName: 'Stanley', - lastName: 'Stuart', - age: 21 - }); - ``` - - @method setProperties - @param obj - @param {Object} properties - @return properties - @public - */ - - function setProperties(obj, properties) { - if (!properties || typeof properties !== 'object') { - return properties; - } - _emberMetalProperty_events.changeProperties(function () { - var props = Object.keys(properties); - var propertyName = undefined; - - for (var i = 0; i < props.length; i++) { - propertyName = props[i]; - - _emberMetalProperty_set.set(obj, propertyName, properties[propertyName]); - } - }); - return properties; - } -}); -enifed('ember-metal/tags', ['exports', 'glimmer-reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { - 'use strict'; - - exports.setHasViews = setHasViews; - exports.tagForProperty = tagForProperty; - exports.tagFor = tagFor; - exports.markObjectAsDirty = markObjectAsDirty; - - var hasViews = function () { - return false; - }; - - function setHasViews(fn) { - hasViews = fn; - } - - function makeTag() { - return new _glimmerReference.DirtyableTag(); - } - - function tagForProperty(object, propertyKey, _meta) { - if (_emberMetalIs_proxy.isProxy(object)) { - return tagFor(object, _meta); - } - - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - var tags = meta.writableTags(); - var tag = tags[propertyKey]; - if (tag) { - return tag; - } - - return tags[propertyKey] = makeTag(); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function tagFor(object, _meta) { - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - return meta.writableTag(makeTag); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function markObjectAsDirty(meta, propertyKey) { - var objectTag = meta && meta.readableTag(); - - if (objectTag) { - objectTag.dirty(); - } - - var tags = meta && meta.readableTags(); - var propertyTag = tags && tags[propertyKey]; - - if (propertyTag) { - propertyTag.dirty(); - } - - if (objectTag || propertyTag) { - ensureRunloop(); - } - } - - var run = undefined; - - function K() {} - - function ensureRunloop() { - if (!run) { - run = _require.default('ember-metal/run_loop').default; - } - - if (hasViews() && !run.backburner.currentInstance) { - run.schedule('actions', K); - } - } -}); -enifed("ember-metal/testing", ["exports"], function (exports) { - "use strict"; - - exports.isTesting = isTesting; - exports.setTesting = setTesting; - var testing = false; - - function isTesting() { - return testing; - } - - function setTesting(value) { - testing = !!value; - } -}); -enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; - - var runInTransaction = undefined, - didRender = undefined, - assertNotRendered = undefined; - - var raise = _emberMetalDebug.assert; - if (false) { - raise = function (message, test) { - _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' }); - }; - } - - var implication = undefined; - if (false) { - implication = 'will be removed in Ember 3.0.'; - } else if (true) { - implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; - } - - if (true || false) { - (function () { - var counter = 0; - var inTransaction = false; - var shouldReflush = undefined; - - exports.default = runInTransaction = function (context, methodName) { - shouldReflush = false; - inTransaction = true; - context[methodName](); - inTransaction = false; - counter++; - return shouldReflush; - }; - - exports.didRender = didRender = function (object, key, reference) { - if (!inTransaction) { - return; - } - var meta = _emberMetalMeta.meta(object); - var lastRendered = meta.writableLastRendered(); - lastRendered[key] = counter; - - _emberMetalDebug.runInDebug(function () { - var lastRenderedFrom = meta.writableLastRenderedFrom(); - lastRenderedFrom[key] = reference; - }); - }; - - exports.assertNotRendered = assertNotRendered = function (object, key, _meta) { - var meta = _meta || _emberMetalMeta.meta(object); - var lastRendered = meta.readableLastRendered(); - - if (lastRendered && lastRendered[key] === counter) { - raise((function () { - var ref = meta.readableLastRenderedFrom(); - var parts = []; - var lastRef = ref[key]; - - var label = undefined; - - if (lastRef) { - while (lastRef && lastRef._propertyKey) { - parts.unshift(lastRef._propertyKey); - lastRef = lastRef._parentReference; - } - - label = parts.join(); - } else { - label = 'the same value'; - } - - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; - })(), false); - - shouldReflush = true; - } - }; - })(); - } else { - exports.default = runInTransaction = function () { - throw new Error('Cannot call runInTransaction without Glimmer'); - }; - - exports.didRender = didRender = function () { - throw new Error('Cannot call didRender without Glimmer'); - }; - - exports.assertNotRendered = assertNotRendered = function () { - throw new Error('Cannot call assertNotRendered without Glimmer'); - }; - } - - exports.default = runInTransaction; - exports.didRender = didRender; - exports.assertNotRendered = assertNotRendered; -}); -enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) { - 'use strict'; - - exports.watchKey = watchKey; - exports.unwatchKey = unwatchKey; - - var handleMandatorySetter = undefined; - - function watchKey(obj, keyName, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - - // activate watching first time - if (!m.peekWatching(keyName)) { - m.writeWatching(keyName, 1); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - if (desc && desc.willWatch) { - desc.willWatch(obj, keyName); - } - - if ('function' === typeof obj.willWatchProperty) { - obj.willWatchProperty(keyName); - } - - if (true) { - // NOTE: this is dropped for prod + minified builds - handleMandatorySetter(m, obj, keyName); - } - } else { - m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1); - } - } - - if (true) { - (function () { - var hasOwnProperty = function (obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - }; - - var propertyIsEnumerable = function (obj, key) { - return Object.prototype.propertyIsEnumerable.call(obj, key); - }; - - // Future traveler, although this code looks scary. It merely exists in - // development to aid in development asertions. Production builds of - // ember strip this entire block out - handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { - var descriptor = _emberUtils.lookupDescriptor(obj, keyName); - var configurable = descriptor ? descriptor.configurable : true; - var isWritable = descriptor ? descriptor.writable : true; - var hasValue = descriptor ? 'value' in descriptor : true; - var possibleDesc = descriptor && descriptor.value; - var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; - - if (isDescriptor) { - return; - } - - // this x in Y deopts, so keeping it in this function is better; - if (configurable && isWritable && hasValue && keyName in obj) { - var desc = { - configurable: true, - set: _emberMetalProperties.MANDATORY_SETTER_FUNCTION(keyName), - enumerable: propertyIsEnumerable(obj, keyName), - get: undefined - }; - - if (hasOwnProperty(obj, keyName)) { - m.writeValues(keyName, obj[keyName]); - desc.get = _emberMetalProperties.DEFAULT_GETTER_FUNCTION(keyName); - } else { - desc.get = _emberMetalProperties.INHERITING_GETTER_FUNCTION(keyName); - } - - Object.defineProperty(obj, keyName, desc); - } - }; - })(); - } - - function unwatchKey(obj, keyName, _meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var meta = _meta || _emberMetalMeta.meta(obj); - - // do nothing of this object has already been destroyed - if (meta.isSourceDestroyed()) { - return; - } - - var count = meta.peekWatching(keyName); - if (count === 1) { - meta.writeWatching(keyName, 0); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.didUnwatch) { - desc.didUnwatch(obj, keyName); - } - - if ('function' === typeof obj.didUnwatchProperty) { - obj.didUnwatchProperty(keyName); - } - - if (true) { - // It is true, the following code looks quite WAT. But have no fear, It - // exists purely to improve development ergonomics and is removed from - // ember.min.js and ember.prod.js builds. - // - // Some further context: Once a property is watched by ember, bypassing `set` - // for mutation, will bypass observation. This code exists to assert when - // that occurs, and attempt to provide more helpful feedback. The alternative - // is tricky to debug partially observable properties. - if (!desc && keyName in obj) { - var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName); - - if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { - if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { - var possibleValue = meta.readInheritedValue('values', keyName); - if (possibleValue === _emberMetalMeta.UNDEFINED) { - delete obj[keyName]; - return; - } - } - - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), - writable: true, - value: meta.peekValues(keyName) - }); - meta.deleteFromValues(keyName); - } - } - } - } else if (count > 1) { - meta.writeWatching(keyName, count - 1); - } - } -}); -enifed('ember-metal/watch_path', ['exports', 'ember-metal/meta', 'ember-metal/chains'], function (exports, _emberMetalMeta, _emberMetalChains) { - 'use strict'; - - exports.makeChainNode = makeChainNode; - exports.watchPath = watchPath; - exports.unwatchPath = unwatchPath; - - // get the chains for the current object. If the current object has - // chains inherited from the proto they will be cloned and reconfigured for - // the current object. - function chainsFor(obj, meta) { - return (meta || _emberMetalMeta.meta(obj)).writableChains(makeChainNode); - } - - function makeChainNode(obj) { - return new _emberMetalChains.ChainNode(null, null, obj); - } - - function watchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - if (!counter) { - // activate watching first time - m.writeWatching(keyPath, 1); - chainsFor(obj, m).add(keyPath); - } else { - m.writeWatching(keyPath, counter + 1); - } - } - - function unwatchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - - if (counter === 1) { - m.writeWatching(keyPath, 0); - chainsFor(obj, m).remove(keyPath); - } else if (counter > 1) { - m.writeWatching(keyPath, counter - 1); - } - } -}); -enifed('ember-metal/watching', ['exports', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.isWatching = isWatching; - exports.watcherCount = watcherCount; - exports.unwatch = unwatch; - exports.destroy = destroy; - - /** - Starts watching a property on an object. Whenever the property changes, - invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the - primitive used by observers and dependent keys; usually you will never call - this method directly but instead use higher level methods like - `Ember.addObserver()` - - @private - @method watch - @for Ember - @param obj - @param {String} _keyPath - */ - function watch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.watchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.watchPath(obj, _keyPath, m); - } - } - - exports.watch = watch; - - function isWatching(obj, key) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - var meta = _emberMetalMeta.peekMeta(obj); - return (meta && meta.peekWatching(key)) > 0; - } - - function watcherCount(obj, key) { - var meta = _emberMetalMeta.peekMeta(obj); - return meta && meta.peekWatching(key) || 0; - } - - function unwatch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.unwatchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.unwatchPath(obj, _keyPath, m); - } - } - - /** - Tears down the meta on an object so that it can be garbage collected. - Multiple calls will have no effect. - - @method destroy - @for Ember - @param {Object} obj the object to destroy - @return {void} - @private - */ - - function destroy(obj) { - _emberMetalMeta.deleteMeta(obj); - } -}); -enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; - - exports.default = WeakMap; - - var id = 0; - - // Returns whether Type(value) is Object according to the terminology in the spec - function isObject(value) { - return typeof value === 'object' && value !== null || typeof value === 'function'; - } - - /* - * @class Ember.WeakMap - * @public - * @category ember-metal-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(iterable) { - if (!(this instanceof WeakMap)) { - throw new TypeError('Constructor WeakMap requires \'new\''); - } - - this._id = _emberUtils.GUID_KEY + id++; - - if (iterable === null || iterable === undefined) { - return; - } else if (Array.isArray(iterable)) { - for (var i = 0; i < iterable.length; i++) { - var _iterable$i = iterable[i]; - var key = _iterable$i[0]; - var value = _iterable$i[1]; - - this.set(key, value); - } - } else { - throw new TypeError('The weak map constructor polyfill only supports an array argument'); - } - } - - /* - * @method get - * @param key {Object | Function} - * @return {Any} stored value - */ - WeakMap.prototype.get = function (obj) { - if (!isObject(obj)) { - return undefined; - } - - var meta = _emberMetalMeta.peekMeta(obj); - if (meta) { - var map = meta.readableWeak(); - if (map) { - if (map[this._id] === _emberMetalMeta.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 (!isObject(obj)) { - throw new TypeError('Invalid value used as weak map key'); - } - - if (value === undefined) { - value = _emberMetalMeta.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) { - if (!isObject(obj)) { - return false; - } - - 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; - } - }; - - /* - * @method toString - * @return {String} - */ - WeakMap.prototype.toString = function () { - return '[object WeakMap]'; - }; -}); -enifed('ember-routing/ext/controller', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/utils'], function (exports, _emberMetal, _emberRuntime, _emberRoutingUtils) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - _emberRuntime.ControllerMixin.reopen({ - concatenatedProperties: ['queryParams'], - - /** - Defines which query parameters the controller accepts. - If you give the names `['category','page']` it will bind - the values of these query parameters to the variables - `this.category` and `this.page` - @property queryParams - @public - */ - queryParams: null, - - /** - This property is updated to various different callback functions depending on - the current "state" of the backing route. It is used by - `Ember.Controller.prototype._qpChanged`. - The methods backing each state can be found in the `Ember.Route.prototype._qp` computed - property return value (the `.states` property). The current values are listed here for - the sanity of future travelers: - * `inactive` - This state is used when this controller instance is not part of the active - route heirarchy. Set in `Ember.Route.prototype._reset` (a `router.js` microlib hook) and - `Ember.Route.prototype.actions.finalizeQueryParamChange`. - * `active` - This state is used when this controller instance is part of the active - route heirarchy. Set in `Ember.Route.prototype.actions.finalizeQueryParamChange`. - * `allowOverrides` - This state is used in `Ember.Route.prototype.setup` (`route.js` microlib hook). - @method _qpDelegate - @private - */ - _qpDelegate: null, // set by route - - /** - During `Ember.Route#setup` observers are created to invoke this method - when any of the query params declared in `Ember.Controller#queryParams` property - are changed. - When invoked this method uses the currently active query param update delegate - (see `Ember.Controller.prototype._qpDelegate` for details) and invokes it with - the QP key/value being changed. - @method _qpChanged - @private - */ - _qpChanged: function (controller, _prop) { - var prop = _prop.substr(0, _prop.length - 3); - - var delegate = controller._qpDelegate; - var value = _emberMetal.get(controller, prop); - delegate(prop, value); - }, - - /** - Transition the application into another route. The route may - be either a single route or route path: - ```javascript - aController.transitionToRoute('blogPosts'); - aController.transitionToRoute('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - aController.transitionToRoute('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - aController.transitionToRoute('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```javascript - App.Router.map(function() { - this.route('blogPost', { path: ':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); - }); - }); - aController.transitionToRoute('blogComment', aPost, aComment); - aController.transitionToRoute('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - aController.transitionToRoute('/'); - aController.transitionToRoute('/blog/post/1/comment/13'); - aController.transitionToRoute('/blog/posts?sort=title'); - ``` - An options hash with a `queryParams` property may be provided as - the final argument to add query parameters to the destination URL. - ```javascript - aController.transitionToRoute('blogPost', 1, { - queryParams: { showComments: 'true' } - }); - // if you just want to transition the query parameters without changing the route - aController.transitionToRoute({ queryParams: { sort: 'date' } }); - ``` - See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). - @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 - @for Ember.ControllerMixin - @method transitionToRoute - @public - */ - transitionToRoute: function () { - // target may be either another controller or a router - var target = _emberMetal.get(this, 'target'); - var method = target.transitionToRoute || target.transitionTo; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(this, args)); - }, - - /** - Transition into another route while replacing the current URL, if possible. - This will replace the current history entry instead of adding a new one. - Beside that, it is identical to `transitionToRoute` in all other respects. - ```javascript - aController.replaceRoute('blogPosts'); - aController.replaceRoute('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - aController.replaceRoute('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - aController.replaceRoute('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```javascript - App.Router.map(function() { - this.route('blogPost', { path: ':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); - }); - }); - aController.replaceRoute('blogComment', aPost, aComment); - aController.replaceRoute('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - aController.replaceRoute('/'); - aController.replaceRoute('/blog/post/1/comment/13'); - ``` - @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. - @for Ember.ControllerMixin - @method replaceRoute - @public - */ - replaceRoute: function () { - // target may be either another controller or a router - var target = _emberMetal.get(this, 'target'); - var method = target.replaceRoute || target.replaceWith; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(target, args)); - } - }); - - exports.default = _emberRuntime.ControllerMixin; -}); -enifed('ember-routing/ext/run_loop', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - /** - @module ember - @submodule ember-views - */ - - // Add a new named queue after the 'actions' queue (where RSVP promises - // resolve), which is used in router transitions to prevent unnecessary - // loading state entry if all context promises resolve on the - // 'actions' queue first. - _emberMetal.run._addQueue('routerTransitions', 'actions'); -}); -enifed('ember-routing/index', ['exports', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route', 'ember-routing/system/query_params', 'ember-routing/services/routing', 'ember-routing/system/cache'], function (exports, _emberRoutingExtRun_loop, _emberRoutingExtController, _emberRoutingLocationApi, _emberRoutingLocationNone_location, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingSystemGenerate_controller, _emberRoutingSystemController_for, _emberRoutingSystemDsl, _emberRoutingSystemRouter, _emberRoutingSystemRoute, _emberRoutingSystemQuery_params, _emberRoutingServicesRouting, _emberRoutingSystemCache) { - /** - @module ember - @submodule ember-routing - */ - - // ES6TODO: Cleanup modules with side-effects below - 'use strict'; - - exports.Location = _emberRoutingLocationApi.default; - exports.NoneLocation = _emberRoutingLocationNone_location.default; - exports.HashLocation = _emberRoutingLocationHash_location.default; - exports.HistoryLocation = _emberRoutingLocationHistory_location.default; - exports.AutoLocation = _emberRoutingLocationAuto_location.default; - exports.generateController = _emberRoutingSystemGenerate_controller.default; - exports.generateControllerFactory = _emberRoutingSystemGenerate_controller.generateControllerFactory; - exports.controllerFor = _emberRoutingSystemController_for.default; - exports.RouterDSL = _emberRoutingSystemDsl.default; - exports.Router = _emberRoutingSystemRouter.default; - exports.Route = _emberRoutingSystemRoute.default; - exports.QueryParams = _emberRoutingSystemQuery_params.default; - exports.RoutingService = _emberRoutingServicesRouting.default; - exports.BucketCache = _emberRoutingSystemCache.default; -}); -enifed('ember-routing/location/api', ['exports', 'ember-metal', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberMetal, _emberEnvironment, _emberRoutingLocationUtil) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - /** - Ember.Location returns an instance of the correct implementation of - the `location` API. - - ## Implementations - - You can pass an implementation name (`hash`, `history`, `none`) to force a - particular implementation to be used in your application. - - ### HashLocation - - Using `HashLocation` results in URLs with a `#` (hash sign) separating the - server side URL portion of the URL from the portion that is used by Ember. - This relies upon the `hashchange` event existing in the browser. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'hash' - }); - ``` - - This will result in a posts.new url of `/#/posts/new`. - - ### HistoryLocation - - Using `HistoryLocation` results in URLs that are indistinguishable from a - standard URL. This relies upon the browser's `history` API. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'history' - }); - ``` - - This will result in a posts.new url of `/posts/new`. - - Keep in mind that your server must serve the Ember app at all the routes you - define. - - ### AutoLocation - - Using `AutoLocation`, the router will use the best Location class supported by - the browser it is running in. - - Browsers that support the `history` API will use `HistoryLocation`, those that - do not, but still support the `hashchange` event will use `HashLocation`, and - in the rare case neither is supported will use `NoneLocation`. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'auto' - }); - ``` - - This will result in a posts.new url of `/posts/new` for modern browsers that - support the `history` api or `/#/posts/new` for older ones, like Internet - Explorer 9 and below. - - When a user visits a link to your application, they will be automatically - upgraded or downgraded to the appropriate `Location` class, with the URL - transformed accordingly, if needed. - - Keep in mind that since some of your users will use `HistoryLocation`, your - server must serve the Ember app at all the routes you define. - - ### NoneLocation - - Using `NoneLocation` causes Ember to not store the applications URL state - in the actual URL. This is generally used for testing purposes, and is one - of the changes made when calling `App.setupForTesting()`. - - ## Location API - - Each location implementation must provide the following methods: - - * implementation: returns the string name used to reference the implementation. - * getURL: returns the current URL. - * setURL(path): sets the current URL. - * replaceURL(path): replace the current URL (optional). - * onUpdateURL(callback): triggers the callback when the URL changes. - * formatURL(url): formats `url` to be placed into `href` attribute. - * detect() (optional): instructs the location to do any feature detection - necessary. If the location needs to redirect to a different URL, it - can cancel routing by setting the `cancelRouterSetup` property on itself - to `false`. - - Calling setURL or replaceURL will not trigger onUpdateURL callbacks. - - ## Custom implementation - - Ember scans `app/locations/*` for extending the Location API. - - Example: - - ```javascript - import Ember from 'ember'; - - export default Ember.HistoryLocation.extend({ - implementation: 'history-url-logging', - - pushState: function (path) { - console.log(path); - this._super.apply(this, arguments); - } - }); - ``` - - @class Location - @namespace Ember - @static - @private - */ - exports.default = { - /** - This is deprecated in favor of using the container to lookup the location - implementation as desired. - For example: - ```javascript - // Given a location registered as follows: - container.register('location:history-test', HistoryTestLocation); - // You could create a new instance via: - container.lookup('location:history-test'); - ``` - @method create - @param {Object} options - @return {Object} an instance of an implementation of the `location` API - @deprecated Use the container to lookup the location implementation that you - need. - @private - */ - create: function (options) { - var implementation = options && options.implementation; - _emberMetal.assert('Ember.Location.create: you must specify a \'implementation\' option', !!implementation); - - var implementationClass = this.implementations[implementation]; - _emberMetal.assert('Ember.Location.create: ' + implementation + ' is not a valid implementation', !!implementationClass); - - return implementationClass.create.apply(implementationClass, arguments); - }, - - implementations: {}, - _location: _emberEnvironment.environment.location, - - /** - Returns the current `location.hash` by parsing location.href since browsers - inconsistently URL-decode `location.hash`. - https://bugzilla.mozilla.org/show_bug.cgi?id=483304 - @private - @method getHash - @since 1.4.0 - */ - _getHash: function () { - return _emberRoutingLocationUtil.getHash(this.location); - } - }; -}); -enifed('ember-routing/location/auto_location', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberRoutingLocationUtil) { - 'use strict'; - - exports.getHistoryPath = getHistoryPath; - exports.getHashPath = getHashPath; - - /** - @module ember - @submodule ember-routing - */ - - /** - Ember.AutoLocation will select the best location option based off browser - support with the priority order: history, hash, none. - - Clean pushState paths accessed by hashchange-only browsers will be redirected - to the hash-equivalent and vice versa so future transitions are consistent. - - Keep in mind that since some of your users will use `HistoryLocation`, your - server must serve the Ember app at all the routes you define. - - @class AutoLocation - @namespace Ember - @static - @private - */ - exports.default = _emberRuntime.Object.extend({ - /** - @private - The browser's `location` object. This is typically equivalent to - `window.location`, but may be overridden for testing. - @property location - @default environment.location - */ - location: _emberEnvironment.environment.location, - - /** - @private - The browser's `history` object. This is typically equivalent to - `window.history`, but may be overridden for testing. - @since 1.5.1 - @property history - @default environment.history - */ - history: _emberEnvironment.environment.history, - - /** - @private - The user agent's global variable. In browsers, this will be `window`. - @since 1.11 - @property global - @default window - */ - global: _emberEnvironment.environment.window, - - /** - @private - The browser's `userAgent`. This is typically equivalent to - `navigator.userAgent`, but may be overridden for testing. - @since 1.5.1 - @property userAgent - @default environment.history - */ - userAgent: _emberEnvironment.environment.userAgent, - - /** - @private - This property is used by the router to know whether to cancel the routing - setup process, which is needed while we redirect the browser. - @since 1.5.1 - @property cancelRouterSetup - @default false - */ - cancelRouterSetup: false, - - /** - @private - Will be pre-pended to path upon state change. - @since 1.5.1 - @property rootURL - @default '/' - */ - rootURL: '/', - - /** - Called by the router to instruct the location to do any feature detection - necessary. In the case of AutoLocation, we detect whether to use history - or hash concrete implementations. - @private - */ - detect: function () { - var rootURL = this.rootURL; - - _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); - - var implementation = detectImplementation({ - location: this.location, - history: this.history, - userAgent: this.userAgent, - rootURL: rootURL, - documentMode: this.documentMode, - global: this.global - }); - - if (implementation === false) { - _emberMetal.set(this, 'cancelRouterSetup', true); - implementation = 'none'; - } - - var concrete = _emberUtils.getOwner(this).lookup('location:' + implementation); - _emberMetal.set(concrete, 'rootURL', rootURL); - - _emberMetal.assert('Could not find location \'' + implementation + '\'.', !!concrete); - - _emberMetal.set(this, 'concreteImplementation', concrete); - }, - - initState: delegateToConcreteImplementation('initState'), - getURL: delegateToConcreteImplementation('getURL'), - setURL: delegateToConcreteImplementation('setURL'), - replaceURL: delegateToConcreteImplementation('replaceURL'), - onUpdateURL: delegateToConcreteImplementation('onUpdateURL'), - formatURL: delegateToConcreteImplementation('formatURL'), - - willDestroy: function () { - var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - - if (concreteImplementation) { - concreteImplementation.destroy(); - } - } - }); - - function delegateToConcreteImplementation(methodName) { - return function () { - var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - _emberMetal.assert('AutoLocation\'s detect() method should be called before calling any other hooks.', !!concreteImplementation); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _emberUtils.tryInvoke(concreteImplementation, methodName, args); - }; - } - - /* - Given the browser's `location`, `history` and `userAgent`, and a configured - root URL, this function detects whether the browser supports the [History - API](https://developer.mozilla.org/en-US/docs/Web/API/History) and returns a - string representing the Location object to use based on its determination. + /** + The `readonly` helper let's you specify that a binding is one-way only, + instead of two-way. + When you pass a `readonly` binding from an outer context (e.g. parent component), + to to an inner context (e.g. child component), you are saying that changing that + property in the inner context does not change the value in the outer context. - For example, if the page loads in an evergreen browser, this function would - return the string "history", meaning the history API and thus HistoryLocation - should be used. If the page is loaded in IE8, it will return the string - "hash," indicating that the History API should be simulated by manipulating the - hash portion of the location. + To specify that a binding is read-only, when invoking the child `Component`: - */ - - function detectImplementation(options) { - var location = options.location; - var userAgent = options.userAgent; - var history = options.history; - var documentMode = options.documentMode; - var global = options.global; - var rootURL = options.rootURL; - - var implementation = 'none'; - var cancelRouterSetup = false; - var currentPath = _emberRoutingLocationUtil.getFullPath(location); - - if (_emberRoutingLocationUtil.supportsHistory(userAgent, history)) { - var historyPath = getHistoryPath(rootURL, location); - - // If the browser supports history and we have a history path, we can use - // the history location with no redirects. - if (currentPath === historyPath) { - return 'history'; - } else { - if (currentPath.substr(0, 2) === '/#') { - history.replaceState({ path: historyPath }, null, historyPath); - implementation = 'history'; - } else { - cancelRouterSetup = true; - _emberRoutingLocationUtil.replacePath(location, historyPath); - } - } - } else if (_emberRoutingLocationUtil.supportsHashChange(documentMode, global)) { - var hashPath = getHashPath(rootURL, location); - - // Be sure we're using a hashed path, otherwise let's switch over it to so - // we start off clean and consistent. We'll count an index path with no - // hash as "good enough" as well. - if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') { - implementation = 'hash'; - } else { - // Our URL isn't in the expected hash-supported format, so we want to - // cancel the router setup and replace the URL to start off clean - cancelRouterSetup = true; - _emberRoutingLocationUtil.replacePath(location, hashPath); - } - } - - if (cancelRouterSetup) { - return false; - } - - return implementation; - } - - /** - @private + ```app/components/my-parent.js + export default Component.extend({ + totalClicks: 3 + }); + ``` - Returns the current path as it should appear for HistoryLocation supported - browsers. This may very well differ from the real current path (e.g. if it - starts off as a hashed URL) - */ - - function getHistoryPath(rootURL, location) { - var path = _emberRoutingLocationUtil.getPath(location); - var hash = _emberRoutingLocationUtil.getHash(location); - var query = _emberRoutingLocationUtil.getQuery(location); - var rootURLIndex = path.indexOf(rootURL); - var routeHash = undefined, - hashParts = undefined; - - _emberMetal.assert('Path ' + path + ' does not start with the provided rootURL ' + rootURL, rootURLIndex === 0); - - // By convention, Ember.js routes using HashLocation are required to start - // with `#/`. Anything else should NOT be considered a route and should - // be passed straight through, without transformation. - if (hash.substr(0, 2) === '#/') { - // There could be extra hash segments after the route - hashParts = hash.substr(1).split('#'); - // The first one is always the route url - routeHash = hashParts.shift(); - - // If the path already has a trailing slash, remove the one - // from the hashed route so we don't double up. - if (path.slice(-1) === '/') { - routeHash = routeHash.substr(1); - } - - // This is the "expected" final order - path = path + routeHash + query; - - if (hashParts.length) { - path += '#' + hashParts.join('#'); - } - } else { - path = path + query + hash; - } - - return path; - } - - /** - @private + ```app/templates/components/my-parent.hbs + {{log totalClicks}} // -> 3 + {{my-child childClickCount=(readonly totalClicks)}} + ``` - Returns the current path as it should appear for HashLocation supported - browsers. This may very well differ from the real current path. + Now, when you update `childClickCount`: - @method _getHashPath - */ - - function getHashPath(rootURL, location) { - var path = rootURL; - var historyPath = getHistoryPath(rootURL, location); - var routePath = historyPath.substr(rootURL.length); - - if (routePath !== '') { - if (routePath.charAt(0) !== '/') { - routePath = '/' + routePath; + ```app/components/my-child.js + export default Component.extend({ + click() { + this.incrementProperty('childClickCount'); } - - path += '#' + routePath; - } - - return path; - } -}); -enifed('ember-routing/location/hash_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - /** - `Ember.HashLocation` implements the location API using the browser's - hash. At present, it relies on a `hashchange` event existing in the - browser. + }); + ``` - @class HashLocation - @namespace Ember - @extends Ember.Object - @private - */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'hash', - - init: function () { - _emberMetal.set(this, 'location', _emberMetal.get(this, '_location') || window.location); - - this._hashchangeHandler = undefined; - }, - - /** - @private - Returns normalized location.hash - @since 1.5.1 - @method getHash - */ - getHash: _emberRoutingLocationApi.default._getHash, - - /** - Returns the normalized URL, constructed from `location.hash`. - e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. - By convention, hashed paths must begin with a forward slash, otherwise they - are not treated as a path so we can distinguish intent. - @private - @method getURL - */ - getURL: function () { - var originalPath = this.getHash().substr(1); - var outPath = originalPath; - - if (outPath.charAt(0) !== '/') { - outPath = '/'; - - // Only add the # if the path isn't empty. - // We do NOT want `/#` since the ampersand - // is only included (conventionally) when - // the location.hash has a value - if (originalPath) { - outPath += '#' + originalPath; - } - } - - return outPath; - }, - - /** - Set the `location.hash` and remembers what was set. This prevents - `onUpdateURL` callbacks from triggering when the hash was set by - `HashLocation`. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - _emberMetal.get(this, 'location').hash = path; - _emberMetal.set(this, 'lastSetURL', path); - }, - - /** - Uses location.replace to update the url without a page reload - or history modification. - @private - @method replaceURL - @param path {String} - */ - replaceURL: function (path) { - _emberMetal.get(this, 'location').replace('#' + path); - _emberMetal.set(this, 'lastSetURL', path); - }, - - /** - Register a callback to be invoked when the hash changes. These - callbacks will execute when the user presses the back or forward - button, but not after `setURL` is invoked. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - var _this = this; - - this._removeEventListener(); - - this._hashchangeHandler = function () { - _emberMetal.run(function () { - var path = _this.getURL(); - if (_emberMetal.get(_this, 'lastSetURL') === path) { - return; - } - - _emberMetal.set(_this, 'lastSetURL', null); - - callback(path); - }); - }; - - window.addEventListener('hashchange', this._hashchangeHandler); - }, - - /** - Given a URL, formats it to be placed into the page as part - of an element's `href` attribute. - This is used, for example, when using the {{action}} helper - to generate a URL based on an event. - @private - @method formatURL - @param url {String} - */ - formatURL: function (url) { - return '#' + url; - }, - - /** - Cleans up the HashLocation event listener. - @private - @method willDestroy - */ - willDestroy: function () { - this._removeEventListener(); - }, - - _removeEventListener: function () { - if (this._hashchangeHandler) { - window.removeEventListener('hashchange', this._hashchangeHandler); - } - } - }); -}); -enifed('ember-routing/location/history_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - var popstateFired = false; - - /** - Ember.HistoryLocation implements the location API using the browser's - history.pushState API. + The value updates in the child component, but not the parent component: - @class HistoryLocation - @namespace Ember - @extends Ember.Object - @private - */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'history', - - init: function () { - this._super.apply(this, arguments); - - var base = document.querySelector('base'); - var baseURL = base ? base.getAttribute('href') : ''; - - _emberMetal.set(this, 'baseURL', baseURL); - _emberMetal.set(this, 'location', _emberMetal.get(this, 'location') || window.location); - - this._popstateHandler = undefined; - }, - - /** - Used to set state on first call to setURL - @private - @method initState - */ - initState: function () { - var history = _emberMetal.get(this, 'history') || window.history; - _emberMetal.set(this, 'history', history); - - if (history && 'state' in history) { - this.supportsHistory = true; - } - - this.replaceState(this.formatURL(this.getURL())); - }, - - /** - Will be pre-pended to path upon state change - @property rootURL - @default '/' - @private - */ - rootURL: '/', - - /** - Returns the current `location.pathname` without `rootURL` or `baseURL` - @private - @method getURL - @return url {String} - */ - getURL: function () { - var location = _emberMetal.get(this, 'location'); - var path = location.pathname; - - var rootURL = _emberMetal.get(this, 'rootURL'); - var baseURL = _emberMetal.get(this, 'baseURL'); - - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - baseURL = baseURL.replace(/\/$/, ''); - - // remove baseURL and rootURL from start of path - var url = path.replace(new RegExp('^' + baseURL + '(?=/|$)'), '').replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - - var search = location.search || ''; - url += search; - url += this.getHash(); - - return url; - }, - - /** - Uses `history.pushState` to update the url without a page reload. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - var state = this.getState(); - path = this.formatURL(path); - - if (!state || state.path !== path) { - this.pushState(path); - } - }, - - /** - Uses `history.replaceState` to update the url without a page reload - or history modification. - @private - @method replaceURL - @param path {String} - */ - replaceURL: function (path) { - var state = this.getState(); - path = this.formatURL(path); - - if (!state || state.path !== path) { - this.replaceState(path); - } - }, - - /** - Get the current `history.state`. Checks for if a polyfill is - required and if so fetches this._historyState. The state returned - from getState may be null if an iframe has changed a window's - history. - @private - @method getState - @return state {Object} - */ - getState: function () { - if (this.supportsHistory) { - return _emberMetal.get(this, 'history').state; + ```app/templates/components/my-child.hbs + {{log childClickCount}} //-> 4 + ``` + + ```app/templates/components/my-parent.hbs + {{log totalClicks}} //-> 3 + {{my-child childClickCount=(readonly totalClicks)}} + ``` + + ### Objects and Arrays + + When passing a property that is a complex object (e.g. object, array) instead of a primitive object (e.g. number, string), + only the reference to the object is protected using the readonly helper. + This means that you can change properties of the object both on the parent component, as well as the child component. + The `readonly` binding behaves similar to the `const` keyword in JavaScript. + + Let's look at an example: + + First let's set up the parent component: + + ```app/components/my-parent.js + export default Ember.Component.extend({ + clicks: null, + + init() { + this._super(...arguments); + this.set('clicks', { total: 3 }); } - - return this._historyState; - }, - - /** - Pushes a new state. - @private - @method pushState - @param path {String} - */ - pushState: function (path) { - var state = { path: path }; - - _emberMetal.get(this, 'history').pushState(state, null, path); - - this._historyState = state; - - // used for webkit workaround - this._previousURL = this.getURL(); - }, - - /** - Replaces the current state. - @private - @method replaceState - @param path {String} - */ - replaceState: function (path) { - var state = { path: path }; - _emberMetal.get(this, 'history').replaceState(state, null, path); - - this._historyState = state; - - // used for webkit workaround - this._previousURL = this.getURL(); - }, - - /** - Register a callback to be invoked whenever the browser - history changes, including using forward and back buttons. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - var _this = this; - - this._removeEventListener(); - - this._popstateHandler = function () { - // Ignore initial page load popstate event in Chrome - if (!popstateFired) { - popstateFired = true; - if (_this.getURL() === _this._previousURL) { - return; - } - } - callback(_this.getURL()); - }; - - window.addEventListener('popstate', this._popstateHandler); - }, - - /** - Used when using `{{action}}` helper. The url is always appended to the rootURL. - @private - @method formatURL - @param url {String} - @return formatted url {String} - */ - formatURL: function (url) { - var rootURL = _emberMetal.get(this, 'rootURL'); - var baseURL = _emberMetal.get(this, 'baseURL'); - - if (url !== '') { - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - baseURL = baseURL.replace(/\/$/, ''); - } else if (baseURL.match(/^\//) && rootURL.match(/^\//)) { - // if baseURL and rootURL both start with a slash - // ... remove trailing slash from baseURL if it exists - baseURL = baseURL.replace(/\/$/, ''); + }); + ``` + + ```app/templates/components/my-parent.hbs + {{log clicks.total}} //-> 3 + {{my-child childClicks=(readonly clicks)}} + ``` + + Now, if you update the `total` property of `childClicks`: + + ```app/components/my-child.js + export default Ember.Component.extend({ + click() { + this.get('clicks').incrementProperty('total'); } + }); + ``` + + You will see the following happen: + + ```app/templates/components/my-parent.hbs + {{log clicks.total}} //-> 4 + {{my-child childClicks=(readonly clicks)}} + ``` + + ```app/templates/components/my-child.hbs + {{log childClicks.total}} //-> 4 + ``` + + @method readonly + @param {Object} [attr] the read-only attribute. + @for Ember.Templates.helpers + @private + */ - return baseURL + rootURL + url; - }, + exports.default = function (vm, args) { + var ref = _emberGlimmerHelpersMut.unMut(args.positional.at(0)); - /** - Cleans up the HistoryLocation event listener. - @private - @method willDestroy - */ - willDestroy: function () { - this._removeEventListener(); - }, + var wrapped = Object.create(ref); - /** - @private - Returns normalized location.hash - @method getHash - */ - getHash: _emberRoutingLocationApi.default._getHash, + wrapped[_emberGlimmerUtilsReferences.UPDATE] = undefined; - _removeEventListener: function () { - if (this._popstateHandler) { - window.removeEventListener('popstate', this._popstateHandler); - } - } - }); + return wrapped; + }; }); -enifed('ember-routing/location/none_location', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { - 'use strict'; - +enifed('ember-glimmer/helpers/unbound', ['exports', 'ember-metal', 'ember-glimmer/utils/references'], function (exports, _emberMetal, _emberGlimmerUtilsReferences) { /** @module ember - @submodule ember-routing + @submodule ember-glimmer */ + 'use strict'; + /** - Ember.NoneLocation does not interact with the browser. It is useful for - testing, or when you need to manage state with your Router, but temporarily - don't want it to muck with the URL (for example when you embed your - application in a larger page). + The `{{unbound}}` helper disconnects the one-way binding of a property, + essentially freezing its value at the moment of rendering. For example, + in this example the display of the variable `name` will not change even + if it is set with a new value: - @class NoneLocation - @namespace Ember - @extends Ember.Object - @private + ```handlebars + {{unbound name}} + ``` + + Like any helper, the `unbound` helper can accept a nested helper expression. + This allows for custom helpers to be rendered unbound: + + ```handlebars + {{unbound (some-custom-helper)}} + {{unbound (capitalize name)}} + {{! You can use any helper, including unbound, in a nested expression }} + {{capitalize (unbound name)}} + ``` + + The `unbound` helper only accepts a single argument, and it return an + unbound value. + + @method unbound + @for Ember.Templates.helpers + @public */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'none', - path: '', - - detect: function () { - var rootURL = this.rootURL; - - _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); - }, - - /** - Will be pre-pended to path. - @private - @property rootURL - @default '/' - */ - rootURL: '/', - - /** - Returns the current path without `rootURL`. - @private - @method getURL - @return {String} path - */ - getURL: function () { - var path = _emberMetal.get(this, 'path'); - var rootURL = _emberMetal.get(this, 'rootURL'); - - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - // remove rootURL from url - return path.replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - }, + exports.default = function (vm, args) { + _emberMetal.assert('unbound helper cannot be called with multiple params or hash params', args.positional.values.length === 1 && args.named.keys.length === 0); - /** - Set the path and remembers what was set. Using this method - to change the path will not invoke the `updateURL` callback. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - _emberMetal.set(this, 'path', path); - }, + return _emberGlimmerUtilsReferences.UnboundReference.create(args.positional.at(0).value()); + }; +}); +enifed('ember-glimmer/index', ['exports', 'ember-glimmer/helpers/action', 'ember-glimmer/templates/root', 'ember-glimmer/template', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/helper', 'ember-glimmer/environment', 'ember-glimmer/make-bound-helper', 'ember-glimmer/utils/string', 'ember-glimmer/renderer', 'ember-glimmer/template_registry', 'ember-glimmer/setup-registry', 'ember-glimmer/dom'], function (exports, _emberGlimmerHelpersAction, _emberGlimmerTemplatesRoot, _emberGlimmerTemplate, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerHelper, _emberGlimmerEnvironment, _emberGlimmerMakeBoundHelper, _emberGlimmerUtilsString, _emberGlimmerRenderer, _emberGlimmerTemplate_registry, _emberGlimmerSetupRegistry, _emberGlimmerDom) { + /** + [Glimmer](https://github.com/tildeio/glimmer) is a [Handlebars](http://handlebarsjs.com/) + compatible templating engine used by Ember.js. + Any valid Handlebars syntax is valid in an Ember template. + + ### Showing a property + + Templates manage the flow of an application's UI, and display state (through + the DOM) to a user. For example, given a component with the property "name", + that component's template can use the name in several ways: + + ```javascript + // app/components/person.js + export default Ember.Component.extend({ + name: 'Jill' + }); + ``` + + ```handlebars + {{! app/components/person.hbs }} + {{name}} +
    {{name}}
    + + ``` + + Any time the "name" property on the component changes, the DOM will be + updated. + + Properties can be chained as well: + + ```handlebars + {{aUserModel.name}} +
    {{listOfUsers.firstObject.name}}
    + ``` + + ### Using Ember helpers + + When content is passed in mustaches `{{}}`, Ember will first try to find a helper + or component with that name. For example, the `if` helper: + + ```handlebars + {{if name "I have a name" "I have no name"}} + + ``` + + The returned value is placed where the `{{}}` is called. The above style is + called "inline". A second style of helper usage is called "block". For example: + + ```handlebars + {{#if name}} + I have a name + {{else}} + I have no name + {{/if}} + ``` + + The block form of helpers allows you to control how the UI is created based + on the values of properties. + A third form of helper is called "nested". For example here the concat + helper will add " Doe" to a displayed name if the person has no last name: + + ```handlebars + + ``` + + Ember's built-in helpers are described under the [Ember.Templates.helpers](/api/classes/Ember.Templates.helpers.html) + namespace. Documentation on creating custom helpers can be found under + [Ember.Helper](/api/classes/Ember.Helper.html). + + ### Invoking a Component + + Ember components represent state to the UI of an application. Further + reading on components can be found under [Ember.Component](/api/classes/Ember.Component.html). + + @module ember + @submodule ember-glimmer + @main ember-glimmer + @public + */ - /** - Register a callback to be invoked when the path changes. These - callbacks will execute when the user presses the back or forward - button, but not after `setURL` is invoked. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - this.updateCallback = callback; - }, + /** + Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful + for semantic clarity as it allows you to retain default scope or to reference a property from another + `{{with}}` block. + + If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0`, NaN or + an empty array, the block will not be rendered. + + ```handlebars + {{! Will only render if user.posts contains items}} + {{#with user.posts as |blogPosts|}} +
    + There are {{blogPosts.length}} blog posts written by {{user.name}}. +
    + {{#each blogPosts as |post|}} +
  • {{post.title}}
  • + {{/each}} + {{/with}} + ``` + + Without the `as` operator, it would be impossible to reference `user.name` in the example above. + + NOTE: The alias should not reuse a name from the bound property path. + + For example: `{{#with foo.bar as |foo|}}` is not supported because it attempts to alias using + the first part of the property path, `foo`. Instead, use `{{#with foo.bar as |baz|}}`. + + @method with + @for Ember.Templates.helpers + @param {Object} options + @return {String} HTML string + @public + */ - /** - Sets the path and calls the `updateURL` callback. - @private - @method handleURL - @param callback {Function} - */ - handleURL: function (url) { - _emberMetal.set(this, 'path', url); - this.updateCallback(url); - }, + /** + Execute the `debugger` statement in the current template's context. + + ```handlebars + {{debugger}} + ``` + + When using the debugger helper you will have access to a `get` function. This + function retrieves values available in the context of the template. + For example, if you're wondering why a value `{{foo}}` isn't rendering as + expected within a template, you could place a `{{debugger}}` statement and, + when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: + + ``` + > get('foo') + ``` + + `get` is also aware of keywords. So in this situation + + ```handlebars + {{#each items as |item|}} + {{debugger}} + {{/each}} + ``` + + You'll be able to get values from the current item: + + ``` + > get('item.name') + ``` + + You can also access the context of the view to make sure it is the object that + you expect: + + ``` + > context + ``` + + @method debugger + @for Ember.Templates.helpers + @public + */ - /** - Given a URL, formats it to be placed into the page as part - of an element's `href` attribute. - This is used, for example, when using the {{action}} helper - to generate a URL based on an event. - @private - @method formatURL - @param url {String} - @return {String} url - */ - formatURL: function (url) { - var rootURL = _emberMetal.get(this, 'rootURL'); + /** + The `partial` helper renders another template without + changing the template context: + + ```handlebars + {{foo}} + {{partial "nav"}} + ``` + + The above example template will render a template named + "-nav", which has the same context as the parent template + it's rendered into, so if the "-nav" template also referenced + `{{foo}}`, it would print the same thing as the `{{foo}}` + in the above example. + + If a "-nav" template isn't found, the `partial` helper will + fall back to a template named "nav". + + ### Bound template names + + The parameter supplied to `partial` can also be a path + to a property containing a template name, e.g.: + + ```handlebars + {{partial someTemplateName}} + ``` + + The above example will look up the value of `someTemplateName` + on the template context (e.g. a controller) and use that + value as the name of the template to render. If the resolved + value is falsy, nothing will be rendered. If `someTemplateName` + changes, the partial will be re-rendered using the new template + name. + + @method partial + @for Ember.Templates.helpers + @param {String} partialName The name of the template to render minus the leading underscore. + @public + */ - if (url !== '') { - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - } + 'use strict'; - return rootURL + url; - } - }); + exports.INVOKE = _emberGlimmerHelpersAction.INVOKE; + exports.RootTemplate = _emberGlimmerTemplatesRoot.default; + exports.template = _emberGlimmerTemplate.default; + exports.Checkbox = _emberGlimmerComponentsCheckbox.default; + exports.TextField = _emberGlimmerComponentsText_field.default; + exports.TextArea = _emberGlimmerComponentsText_area.default; + exports.LinkComponent = _emberGlimmerComponentsLinkTo.default; + exports.Component = _emberGlimmerComponent.default; + exports.Helper = _emberGlimmerHelper.default; + exports.helper = _emberGlimmerHelper.helper; + exports.Environment = _emberGlimmerEnvironment.default; + exports.makeBoundHelper = _emberGlimmerMakeBoundHelper.default; + exports.SafeString = _emberGlimmerUtilsString.SafeString; + exports.escapeExpression = _emberGlimmerUtilsString.escapeExpression; + exports.htmlSafe = _emberGlimmerUtilsString.htmlSafe; + exports.isHTMLSafe = _emberGlimmerUtilsString.isHTMLSafe; + exports._getSafeString = _emberGlimmerUtilsString.getSafeString; + exports.Renderer = _emberGlimmerRenderer.Renderer; + exports.InertRenderer = _emberGlimmerRenderer.InertRenderer; + exports.InteractiveRenderer = _emberGlimmerRenderer.InteractiveRenderer; + exports.getTemplate = _emberGlimmerTemplate_registry.getTemplate; + exports.setTemplate = _emberGlimmerTemplate_registry.setTemplate; + exports.hasTemplate = _emberGlimmerTemplate_registry.hasTemplate; + exports.getTemplates = _emberGlimmerTemplate_registry.getTemplates; + exports.setTemplates = _emberGlimmerTemplate_registry.setTemplates; + exports.setupEngineRegistry = _emberGlimmerSetupRegistry.setupEngineRegistry; + exports.setupApplicationRegistry = _emberGlimmerSetupRegistry.setupApplicationRegistry; + exports.DOMChanges = _emberGlimmerDom.DOMChanges; + exports.NodeDOMTreeConstruction = _emberGlimmerDom.NodeDOMTreeConstruction; + exports.DOMTreeConstruction = _emberGlimmerDom.DOMTreeConstruction; }); -enifed('ember-routing/location/util', ['exports'], function (exports) { +enifed('ember-glimmer/make-bound-helper', ['exports', 'ember-metal', 'ember-glimmer/helper'], function (exports, _emberMetal, _emberGlimmerHelper) { /** - @private - - Returns the current `location.pathname`, normalized for IE inconsistencies. + @module ember + @submodule ember-glimmer */ 'use strict'; - exports.getPath = getPath; - exports.getQuery = getQuery; - exports.getHash = getHash; - exports.getFullPath = getFullPath; - exports.getOrigin = getOrigin; - exports.supportsHashChange = supportsHashChange; - exports.supportsHistory = supportsHistory; - exports.replacePath = replacePath; - - function getPath(location) { - var pathname = location.pathname; - // Various versions of IE/Opera don't always return a leading slash - if (pathname.charAt(0) !== '/') { - pathname = '/' + pathname; - } - - return pathname; - } + exports.default = makeBoundHelper; /** - @private + Create a bound helper. Accepts a function that receives the ordered and hash parameters + from the template. If a bound property was provided in the template, it will be resolved to its + value and any changes to the bound property cause the helper function to be re-run with the updated + values. - Returns the current `location.search`. - */ - - function getQuery(location) { - return location.search; - } - - /** - @private + * `params` - An array of resolved ordered parameters. + * `hash` - An object containing the hash parameters. - Returns the current `location.hash` by parsing location.href since browsers - inconsistently URL-decode `location.hash`. + For example: - Should be passed the browser's `location` object as the first argument. + * With an unquoted ordered parameter: - https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + ```javascript + {{x-capitalize foo}} + ``` + + Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and + an empty hash as its second. + + * With a quoted ordered parameter: + + ```javascript + {{x-capitalize "foo"}} + ``` + + The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. + + * With an unquoted hash parameter: + + ```javascript + {{x-repeat "foo" count=repeatCount}} + ``` + + Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, + and { count: 2 } as its second. + + @private + @method makeBoundHelper + @for Ember.HTMLBars + @param {Function} fn + @since 1.10.0 */ - function getHash(location) { - var href = location.href; - var hashIndex = href.indexOf('#'); - - if (hashIndex === -1) { - return ''; - } else { - return href.substr(hashIndex); - } + function makeBoundHelper(fn) { + _emberMetal.deprecate('Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.', false, { id: 'ember-htmlbars.make-bound-helper', until: '3.0.0' }); + return _emberGlimmerHelper.helper(fn); } +}); +enifed('ember-glimmer/modifiers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _emberGlimmerHelpersAction) { + 'use strict'; - function getFullPath(location) { - return getPath(location) + getQuery(location) + getHash(location); - } + var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; + var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; - function getOrigin(location) { - var origin = location.origin; + function isAllowedEvent(event, allowedKeys) { + if (allowedKeys === null || typeof allowedKeys === 'undefined') { + if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { + return _emberViews.isSimpleClick(event); + } else { + allowedKeys = ''; + } + } - // Older browsers, especially IE, don't have origin - if (!origin) { - origin = location.protocol + '//' + location.hostname; + if (allowedKeys.indexOf('any') >= 0) { + return true; + } - if (location.port) { - origin += ':' + location.port; + for (var i = 0; i < MODIFIERS.length; i++) { + if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { + return false; } } - return origin; + return true; } - /* - `documentMode` only exist in Internet Explorer, and it's tested because IE8 running in - IE7 compatibility mode claims to support `onhashchange` but actually does not. - - `global` is an object that may have an `onhashchange` property. - - @private - @function supportsHashChange - */ + var ActionHelper = { + // registeredActions is re-exported for compatibility with older plugins + // that were using this undocumented API. + registeredActions: _emberViews.ActionManager.registeredActions, - function supportsHashChange(documentMode, global) { - return 'onhashchange' in global && (documentMode === undefined || documentMode > 7); - } + registerAction: function (actionState) { + var actionId = actionState.actionId; - /* - `userAgent` is a user agent string. We use user agent testing here, because - the stock Android browser is known to have buggy versions of the History API, - in some Android versions. - - @private - @function supportsHistory - */ + _emberViews.ActionManager.registeredActions[actionId] = actionState; - function supportsHistory(userAgent, history) { - // Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js - // The stock browser on Android 2.2 & 2.3, and 4.0.x returns positive on history support - // Unfortunately support is really buggy and there is no clean way to detect - // these bugs, so we fall back to a user agent sniff :( + return actionId; + }, - // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies - // itself as 'Mobile Safari' as well, nor Windows Phone. - if ((userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 4.0') !== -1) && userAgent.indexOf('Mobile Safari') !== -1 && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Windows Phone') === -1) { - return false; + unregisterAction: function (actionState) { + var actionId = actionState.actionId; + + delete _emberViews.ActionManager.registeredActions[actionId]; } + }; - return !!(history && 'pushState' in history); - } + exports.ActionHelper = ActionHelper; - /** - Replaces the current location, making sure we explicitly include the origin - to prevent redirecting to a different origin. - - @private - */ + var ActionState = (function () { + function ActionState(element, actionId, actionName, actionArgs, namedArgs, positionalArgs, implicitTarget, dom) { + babelHelpers.classCallCheck(this, ActionState); - function replacePath(location, path) { - location.replace(getOrigin(location) + path); - } -}); -enifed('ember-routing/services/routing', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'ember-routing/utils'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _emberRoutingUtils) { - /** - @module ember - @submodule ember-routing - */ + this.element = element; + this.actionId = actionId; + this.actionName = actionName; + this.actionArgs = actionArgs; + this.namedArgs = namedArgs; + this.positional = positionalArgs; + this.implicitTarget = implicitTarget; + this.dom = dom; + this.eventName = this.getEventName(); + } - 'use strict'; + // implements ModifierManager - /** - The Routing service is used by LinkComponent, and provides facilities for - the component/view layer to interact with the router. - - While still private, this service can eventually be opened up, and provides - the set of API needed for components to control routing without interacting - with router internals. - - @private - @class RoutingService - */ - exports.default = _emberRuntime.Service.extend({ - router: null, + ActionState.prototype.getEventName = function getEventName() { + return this.namedArgs.get('on').value() || 'click'; + }; - targetState: _emberRuntime.readOnly('router.targetState'), - currentState: _emberRuntime.readOnly('router.currentState'), - currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), - currentPath: _emberRuntime.readOnly('router.currentPath'), + ActionState.prototype.getActionArgs = function getActionArgs() { + var result = new Array(this.actionArgs.length); - availableRoutes: function () { - return Object.keys(_emberMetal.get(this, 'router').router.recognizer.names); - }, + for (var i = 0; i < this.actionArgs.length; i++) { + result[i] = this.actionArgs[i].value(); + } - hasRoute: function (routeName) { - return _emberMetal.get(this, 'router').hasRoute(routeName); - }, + return result; + }; - transitionTo: function (routeName, models, queryParams, shouldReplace) { - var router = _emberMetal.get(this, 'router'); + ActionState.prototype.getTarget = function getTarget() { + var implicitTarget = this.implicitTarget; + var namedArgs = this.namedArgs; - var transition = router._doTransition(routeName, models, queryParams); + var target = undefined; - if (shouldReplace) { - transition.method('replace'); + if (namedArgs.has('target')) { + target = namedArgs.get('target').value(); + } else { + target = implicitTarget.value(); } - return transition; - }, + return target; + }; - normalizeQueryParams: function (routeName, models, queryParams) { - var router = _emberMetal.get(this, 'router'); - router._prepareQueryParams(routeName, models, queryParams); - }, + ActionState.prototype.handler = function handler(event) { + var _this = this; - generateURL: function (routeName, models, queryParams) { - var router = _emberMetal.get(this, 'router'); - if (!router.router) { - return; - } + var actionName = this.actionName; + var namedArgs = this.namedArgs; - var visibleQueryParams = {}; - _emberUtils.assign(visibleQueryParams, queryParams); + var bubbles = namedArgs.get('bubbles'); + var preventDefault = namedArgs.get('preventDefault'); + var allowedKeys = namedArgs.get('allowedKeys'); + var target = this.getTarget(); - this.normalizeQueryParams(routeName, models, visibleQueryParams); + if (!isAllowedEvent(event, allowedKeys.value())) { + return true; + } - var args = _emberRoutingUtils.routeArgs(routeName, models, visibleQueryParams); - return router.generate.apply(router, args); - }, + if (preventDefault.value() !== false) { + event.preventDefault(); + } - isActiveForRoute: function (contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { - var router = _emberMetal.get(this, 'router'); + if (bubbles.value() === false) { + event.stopPropagation(); + } - var handlers = router.router.recognizer.handlersFor(routeName); - var leafName = handlers[handlers.length - 1].handler; - var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); + _emberMetal.run(function () { + var args = _this.getActionArgs(); + var payload = { + args: args, + target: target + }; + if (typeof actionName[_emberGlimmerHelpersAction.INVOKE] === 'function') { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + actionName[_emberGlimmerHelpersAction.INVOKE].apply(actionName, args); + }); + return; + } + if (typeof actionName === 'function') { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + actionName.apply(target, args); + }); + return; + } + payload.name = actionName; + if (target.send) { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + target.send.apply(target, [actionName].concat(args)); + }); + } else { + _emberMetal.assert('The action \'' + actionName + '\' did not exist on ' + target, typeof target[actionName] === 'function'); + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + target[actionName].apply(target, args); + }); + } + }); + }; - // NOTE: any ugliness in the calculation of activeness is largely - // due to the fact that we support automatic normalizing of - // `resource` -> `resource.index`, even though there might be - // dynamic segments / query params defined on `resource.index` - // which complicates (and makes somewhat ambiguous) the calculation - // of activeness for links that link to `resource` instead of - // directly to `resource.index`. + ActionState.prototype.destroy = function destroy() { + ActionHelper.unregisterAction(this); + }; - // if we don't have enough contexts revert back to full route name - // this is because the leaf route will use one of the contexts - if (contexts.length > maximumContexts) { - routeName = leafName; - } + return ActionState; + })(); - return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified); - } - }); + exports.ActionState = ActionState; - function numberOfContextsAcceptedByHandler(handler, handlerInfos) { - var req = 0; - for (var i = 0; i < handlerInfos.length; i++) { - req = req + handlerInfos[i].names.length; - if (handlerInfos[i].handler === handler) { - break; - } + var ActionModifierManager = (function () { + function ActionModifierManager() { + babelHelpers.classCallCheck(this, ActionModifierManager); } - return req; - } -}); -enifed('ember-routing/system/cache', ['exports', 'ember-utils', 'ember-runtime'], function (exports, _emberUtils, _emberRuntime) { - 'use strict'; + ActionModifierManager.prototype.create = function create(element, args, dynamicScope, dom) { + var named = args.named; + var positional = args.positional; - /** - A two-tiered cache with support for fallback values when doing lookups. - Uses "buckets" and then "keys" to cache values. - - @private - @class BucketCache - */ - exports.default = _emberRuntime.Object.extend({ - init: function () { - this.cache = new _emberUtils.EmptyObject(); - }, + var implicitTarget = undefined; + var actionName = undefined; + var actionNameRef = undefined; + if (positional.length > 1) { + implicitTarget = positional.at(0); + actionNameRef = positional.at(1); - has: function (bucketKey) { - return !!this.cache[bucketKey]; - }, + if (actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { + actionName = actionNameRef; + } else { + var actionLabel = actionNameRef._propertyKey; + actionName = actionNameRef.value(); - stash: function (bucketKey, key, value) { - var bucket = this.cache[bucketKey]; + _emberMetal.assert('You specified a quoteless path, `' + actionLabel + '`, to the ' + '{{action}} helper which did not resolve to an action name (a ' + 'string). Perhaps you meant to use a quoted actionName? (e.g. ' + '{{action "' + actionLabel + '"}}).', typeof actionName === 'string' || typeof actionName === 'function'); + } + } - if (!bucket) { - bucket = this.cache[bucketKey] = new _emberUtils.EmptyObject(); + var actionArgs = []; + // The first two arguments are (1) `this` and (2) the action name. + // Everything else is a param. + for (var i = 2; i < positional.length; i++) { + actionArgs.push(positional.at(i)); } - bucket[key] = value; - }, + var actionId = _emberUtils.uuid(); + return new ActionState(element, actionId, actionName, actionArgs, named, positional, implicitTarget, dom); + }; - lookup: function (bucketKey, prop, defaultValue) { - var cache = this.cache; - if (!this.has(bucketKey)) { - return defaultValue; - } + ActionModifierManager.prototype.install = function install(actionState) { + var dom = actionState.dom; + var element = actionState.element; + var actionId = actionState.actionId; - var bucket = cache[bucketKey]; - if (prop in bucket && bucket[prop] !== undefined) { - return bucket[prop]; - } else { - return defaultValue; + ActionHelper.registerAction(actionState); + + dom.setAttribute(element, 'data-ember-action', ''); + dom.setAttribute(element, 'data-ember-action-' + actionId, actionId); + }; + + ActionModifierManager.prototype.update = function update(actionState) { + var positional = actionState.positional; + + var actionNameRef = positional.at(1); + + if (!actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { + actionState.actionName = actionNameRef.value(); } - } - }); + actionState.eventName = actionState.getEventName(); + + // Not sure if this is needed? If we mutate the actionState is that good enough? + ActionHelper.unregisterAction(actionState); + ActionHelper.registerAction(actionState); + }; + + ActionModifierManager.prototype.getDestructor = function getDestructor(modifier) { + return modifier; + }; + + return ActionModifierManager; + })(); + + exports.default = ActionModifierManager; }); -enifed("ember-routing/system/controller_for", ["exports"], function (exports) { - /** - @module ember - @submodule ember-routing - */ +enifed('ember-glimmer/protocol-for-url', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + /* globals module, URL */ - /** - Finds a controller instance. - - @for Ember - @method controllerFor - @private - */ - "use strict"; + 'use strict'; - exports.default = controllerFor; + exports.default = installProtocolForURL; - function controllerFor(container, controllerName, lookupOptions) { - return container.lookup("controller:" + controllerName, lookupOptions); + var nodeURL = undefined; + var parsingNode = undefined; + + function installProtocolForURL(environment) { + var protocol = undefined; + + if (_emberEnvironment.environment.hasDOM) { + protocol = browserProtocolForURL.call(environment, 'foobar:baz'); + } + + // Test to see if our DOM implementation parses + // and normalizes URLs. + if (protocol === 'foobar:') { + // Swap in the method that doesn't do this test now that + // we know it works. + environment.protocolForURL = browserProtocolForURL; + } else if (typeof URL === 'object') { + // URL globally provided, likely from FastBoot's sandbox + nodeURL = URL; + environment.protocolForURL = nodeProtocolForURL; + } else if (typeof module === 'object' && typeof module.require === 'function') { + // Otherwise, we need to fall back to our own URL parsing. + // Global `require` is shadowed by Ember's loader so we have to use the fully + // qualified `module.require`. + nodeURL = module.require('url'); + environment.protocolForURL = nodeProtocolForURL; + } else { + throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); + } + } + + function browserProtocolForURL(url) { + if (!parsingNode) { + parsingNode = document.createElement('a'); + } + + parsingNode.href = url; + return parsingNode.protocol; + } + + function nodeProtocolForURL(url) { + var protocol = null; + if (typeof url === 'string') { + protocol = nodeURL.parse(url).protocol; + } + return protocol === null ? ':' : protocol; } }); -enifed('ember-routing/system/dsl', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { +enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', 'ember-metal', '@glimmer/reference', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/outlet'], function (exports, _emberGlimmerUtilsReferences, _emberMetal, _glimmerReference, _emberViews, _emberGlimmerComponent, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxOutlet) { 'use strict'; - /** - @module ember - @submodule ember-routing - */ + var backburner = _emberMetal.run.backburner; + + var DynamicScope = (function () { + function DynamicScope(view, outletState, rootOutletState, targetObject) { + babelHelpers.classCallCheck(this, DynamicScope); - function DSL(name, options) { - this.parent = name; - this.enableLoadingSubstates = options && options.enableLoadingSubstates; - this.matches = []; - this.explicitIndex = undefined; - this.options = options; - } + this.view = view; + this.outletState = outletState; + this.rootOutletState = rootOutletState; + } - exports.default = DSL; + DynamicScope.prototype.child = function child() { + return new DynamicScope(this.view, this.outletState, this.rootOutletState); + }; - DSL.prototype = { - route: function (name, options, callback) { - var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; - if (arguments.length === 2 && typeof options === 'function') { - callback = options; - options = {}; - } + DynamicScope.prototype.get = function get(key) { + _emberMetal.assert('Using `-get-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); + return this.outletState; + }; - if (arguments.length === 1) { - options = {}; - } + DynamicScope.prototype.set = function set(key, value) { + _emberMetal.assert('Using `-with-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); + this.outletState = value; + return value; + }; - _emberMetal.assert('\'' + name + '\' cannot be used as a route name.', (function () { - if (options.overrideNameAssertion === true) { - return true; - } + return DynamicScope; + })(); - return ['array', 'basic', 'object', 'application'].indexOf(name) === -1; - })()); + var RootState = (function () { + function RootState(root, env, template, self, parentElement, dynamicScope) { + var _this = this; - if (this.enableLoadingSubstates) { - createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace }); - createRoute(this, name + '_error', { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); - } + babelHelpers.classCallCheck(this, RootState); - if (callback) { - var fullName = getFullName(this, name, options.resetNamespace); - var dsl = new DSL(fullName, this.options); + _emberMetal.assert('You cannot render `' + self.value() + '` without a template.', template); - createRoute(dsl, 'loading'); - createRoute(dsl, 'error', { path: dummyErrorRoute }); + this.id = _emberViews.getViewId(root); + this.env = env; + this.root = root; + this.result = undefined; + this.shouldReflush = false; + this.destroyed = false; + this._removing = false; - callback.call(dsl); + var options = this.options = { + alwaysRevalidate: false + }; - createRoute(this, name, options, dsl.generate()); - } else { - createRoute(this, name, options); - } - }, + this.render = function () { + var result = _this.result = template.render(self, parentElement, dynamicScope); - push: function (url, name, callback, serialize) { - var parts = name.split('.'); + // override .render function after initial render + _this.render = function () { + result.rerender(options); + }; + }; + } - if (this.options.engineInfo) { - var localFullName = name.slice(this.options.engineInfo.fullName.length + 1); - var routeInfo = _emberUtils.assign({ localFullName: localFullName }, this.options.engineInfo); + RootState.prototype.isFor = function isFor(possibleRoot) { + return this.root === possibleRoot; + }; - if (serialize) { - routeInfo.serializeMethod = serialize; - } + RootState.prototype.destroy = function destroy() { + var result = this.result; + var env = this.env; - this.options.addRouteForEngine(name, routeInfo); - } else if (serialize) { - throw new Error('Defining a route serializer on route \'' + name + '\' outside an Engine is not allowed.'); - } + this.destroyed = true; - if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { - this.explicitIndex = true; - } + this.env = null; + this.root = null; + this.result = null; + this.render = null; - this.matches.push([url, name, callback]); - }, + if (result) { + /* + Handles these scenarios: + * When roots are removed during standard rendering process, a transaction exists already + `.begin()` / `.commit()` are not needed. + * When roots are being destroyed manually (`component.append(); component.destroy() case), no + transaction exists already. + * When roots are being destroyed during `Renderer#destroy`, no transaction exists + */ + var needsTransaction = !env.inTransaction; - resource: function (name, options, callback) { - if (arguments.length === 2 && typeof options === 'function') { - callback = options; - options = {}; - } + if (needsTransaction) { + env.begin(); + } - if (arguments.length === 1) { - options = {}; + result.destroy(); + + if (needsTransaction) { + env.commit(); + } } + }; - options.resetNamespace = true; - _emberMetal.deprecate('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.', false, { id: 'ember-routing.router-resource', until: '3.0.0' }); - this.route(name, options, callback); - }, + return RootState; + })(); - generate: function () { - var dslMatches = this.matches; + var renderers = []; - if (!this.explicitIndex) { - this.route('index', { path: '/' }); - } + _emberMetal.setHasViews(function () { + return renderers.length > 0; + }); - return function (match) { - for (var i = 0; i < dslMatches.length; i++) { - var dslMatch = dslMatches[i]; - match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); - } - }; - } - }; + function register(renderer) { + _emberMetal.assert('Cannot register the same renderer twice', renderers.indexOf(renderer) === -1); + renderers.push(renderer); + } - function canNest(dsl) { - return dsl.parent && dsl.parent !== 'application'; + function deregister(renderer) { + var index = renderers.indexOf(renderer); + _emberMetal.assert('Cannot deregister unknown unregistered renderer', index !== -1); + renderers.splice(index, 1); } - function getFullName(dsl, name, resetNamespace) { - if (canNest(dsl) && resetNamespace !== true) { - return dsl.parent + '.' + name; - } else { - return name; + function loopBegin() { + for (var i = 0; i < renderers.length; i++) { + renderers[i]._scheduleRevalidate(); } } - function createRoute(dsl, name, options, callback) { - options = options || {}; - - var fullName = getFullName(dsl, name, options.resetNamespace); + function K() {} - if (typeof options.path !== 'string') { - options.path = '/' + name; + var loops = 0; + function loopEnd(current, next) { + for (var i = 0; i < renderers.length; i++) { + if (!renderers[i]._isValid()) { + if (loops > 10) { + loops = 0; + // TODO: do something better + renderers[i].destroy(); + throw new Error('infinite rendering invalidation detected'); + } + loops++; + return backburner.join(null, K); + } } - - dsl.push(options.path, fullName, callback, options.serialize); + loops = 0; } - DSL.map = function (callback) { - var dsl = new DSL(); - callback.call(dsl); - return dsl; - }; + backburner.on('begin', loopBegin); + backburner.on('end', loopEnd); - var uuid = 0; + var Renderer = (function () { + function Renderer(env, rootTemplate) { + var _viewRegistry = arguments.length <= 2 || arguments[2] === undefined ? _emberViews.fallbackViewRegistry : arguments[2]; - DSL.prototype.mount = function (_name, _options) { - var options = _options || {}; - var engineRouteMap = this.options.resolveRouteMap(_name); - var name = _name; + var destinedForDOM = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; + babelHelpers.classCallCheck(this, Renderer); - if (options.as) { - name = options.as; + this._env = env; + this._rootTemplate = rootTemplate; + this._viewRegistry = _viewRegistry; + this._destinedForDOM = destinedForDOM; + this._destroyed = false; + this._roots = []; + this._lastRevision = null; + this._isRenderingRoots = false; + this._removedRoots = []; } - var fullName = getFullName(this, name, options.resetNamespace); + // renderer HOOKS + + Renderer.prototype.appendOutletView = function appendOutletView(view, target) { + var definition = new _emberGlimmerSyntaxOutlet.TopLevelOutletComponentDefinition(view); + var outletStateReference = view.toReference(); + var targetObject = view.outletState.render.controller; - var engineInfo = { - name: _name, - instanceId: uuid++, - mountPoint: fullName, - fullName: fullName + this._appendDefinition(view, definition, target, outletStateReference, targetObject); }; - var path = options.path; + Renderer.prototype.appendTo = function appendTo(view, target) { + var rootDef = new _emberGlimmerSyntaxCurlyComponent.RootComponentDefinition(view); - if (typeof path !== 'string') { - path = '/' + name; - } + this._appendDefinition(view, rootDef, target); + }; - var callback = undefined; - var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; - if (engineRouteMap) { - var shouldResetEngineInfo = false; - var oldEngineInfo = this.options.engineInfo; - if (oldEngineInfo) { - shouldResetEngineInfo = true; - this.options.engineInfo = engineInfo; - } + Renderer.prototype._appendDefinition = function _appendDefinition(root, definition, target) { + var outletStateReference = arguments.length <= 3 || arguments[3] === undefined ? _glimmerReference.UNDEFINED_REFERENCE : arguments[3]; + var targetObject = arguments.length <= 4 || arguments[4] === undefined ? null : arguments[4]; - var optionsForChild = _emberUtils.assign({ engineInfo: engineInfo }, this.options); - var childDSL = new DSL(fullName, optionsForChild); + var self = new _emberGlimmerUtilsReferences.RootReference(definition); + var dynamicScope = new DynamicScope(null, outletStateReference, outletStateReference, true, targetObject); + var rootState = new RootState(root, this._env, this._rootTemplate, self, target, dynamicScope); - createRoute(childDSL, 'loading'); - createRoute(childDSL, 'error', { path: dummyErrorRoute }); + this._renderRoot(rootState); + }; - engineRouteMap.call(childDSL); + Renderer.prototype.rerender = function rerender(view) { + this._scheduleRevalidate(); + }; - callback = childDSL.generate(); + Renderer.prototype.register = function register(view) { + var id = _emberViews.getViewId(view); + _emberMetal.assert('Attempted to register a view with an id already in use: ' + id, !this._viewRegistry[id]); + this._viewRegistry[id] = view; + }; - if (shouldResetEngineInfo) { - this.options.engineInfo = oldEngineInfo; - } - } + Renderer.prototype.unregister = function unregister(view) { + delete this._viewRegistry[_emberViews.getViewId(view)]; + }; - var localFullName = 'application'; - var routeInfo = _emberUtils.assign({ localFullName: localFullName }, engineInfo); + Renderer.prototype.remove = function remove(view) { + view._transitionTo('destroying'); - if (this.enableLoadingSubstates) { - // These values are important to register the loading routes under their - // proper names for the Router and within the Engine's registry. - var substateName = name + '_loading'; - var _localFullName = 'application_loading'; - var _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); - createRoute(this, substateName, { resetNamespace: options.resetNamespace }); - this.options.addRouteForEngine(substateName, _routeInfo); + this.cleanupRootFor(view); - substateName = name + '_error'; - _localFullName = 'application_error'; - _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); - createRoute(this, substateName, { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); - this.options.addRouteForEngine(substateName, _routeInfo); - } + _emberViews.setViewElement(view, null); - this.options.addRouteForEngine(fullName, routeInfo); + if (this._destinedForDOM) { + view.trigger('didDestroyElement'); + } - this.push(path, fullName, callback); - }; -}); -enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + if (!view.isDestroying) { + view.destroy(); + } + }; - exports.generateControllerFactory = generateControllerFactory; - exports.default = generateController; + Renderer.prototype.cleanupRootFor = function cleanupRootFor(view) { + // no need to cleanup roots if we have already been destroyed + if (this._destroyed) { + return; + } - /** - @module ember - @submodule ember-routing - */ + var roots = this._roots; - /** - Generates a controller factory - - @for Ember - @method generateControllerFactory - @private - */ + // traverse in reverse so we can remove items + // without mucking up the index + var i = this._roots.length; + while (i--) { + var root = roots[i]; + if (root.isFor(view)) { + root.destroy(); + } + } + }; - function generateControllerFactory(owner, controllerName) { - var Factory = owner._lookupFactory('controller:basic').extend({ - isGenerated: true, - toString: function () { - return '(generated ' + controllerName + ' controller)'; + Renderer.prototype.destroy = function destroy() { + if (this._destroyed) { + return; } - }); + this._destroyed = true; + this._clearAllRoots(); + }; - var fullName = 'controller:' + controllerName; + Renderer.prototype.getElement = function getElement(view) { + // overriden in the subclasses + }; - owner.register(fullName, Factory); + Renderer.prototype.getBounds = function getBounds(view) { + var bounds = view[_emberGlimmerComponent.BOUNDS]; - return Factory; - } + var parentElement = bounds.parentElement(); + var firstNode = bounds.firstNode(); + var lastNode = bounds.lastNode(); - /** - Generates and instantiates a controller extending from `controller:basic` - if present, or `Ember.Controller` if not. - - @for Ember - @method generateController - @private - @since 1.3.0 - */ + return { parentElement: parentElement, firstNode: firstNode, lastNode: lastNode }; + }; - function generateController(owner, controllerName) { - generateControllerFactory(owner, controllerName); + Renderer.prototype.createElement = function createElement(tagName) { + return this._env.getAppendOperations().createElement(tagName); + }; - var fullName = 'controller:' + controllerName; - var instance = owner.lookup(fullName); + Renderer.prototype._renderRoot = function _renderRoot(root) { + var roots = this._roots; - if (_emberMetal.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { - _emberMetal.info('generated -> ' + fullName, { fullName: fullName }); - } + roots.push(root); - return instance; - } -}); -enifed('ember-routing/system/query_params', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { - 'use strict'; + if (roots.length === 1) { + register(this); + } - exports.default = _emberRuntime.Object.extend({ - isQueryParams: true, - values: null - }); -}); -enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-routing/system/generate_controller', 'ember-routing/utils'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberRoutingSystemGenerate_controller, _emberRoutingUtils) { - 'use strict'; + this._renderRootsTransaction(); + }; - exports.defaultSerialize = defaultSerialize; - exports.hasDefaultSerialize = hasDefaultSerialize; - var slice = Array.prototype.slice; + Renderer.prototype._renderRoots = function _renderRoots() { + var roots = this._roots; + var env = this._env; + var removedRoots = this._removedRoots; - function K() { - return this; - } + var globalShouldReflush = undefined, + initialRootsLength = undefined; - function defaultSerialize(model, params) { - if (params.length < 1) { - return; - } - if (!model) { - return; - } + do { + env.begin(); - var name = params[0]; - var object = {}; + // ensure that for the first iteration of the loop + // each root is processed + initialRootsLength = roots.length; + globalShouldReflush = false; - if (params.length === 1) { - if (name in model) { - object[name] = _emberMetal.get(model, name); - } else if (/_id$/.test(name)) { - object[name] = _emberMetal.get(model, 'id'); - } - } else { - object = _emberMetal.getProperties(model, params); - } + for (var i = 0; i < roots.length; i++) { + var root = roots[i]; - return object; - } + if (root.destroyed) { + // add to the list of roots to be removed + // they will be removed from `this._roots` later + removedRoots.push(root); - var DEFAULT_SERIALIZE = _emberUtils.symbol('DEFAULT_SERIALIZE'); + // skip over roots that have been marked as destroyed + continue; + } - defaultSerialize[DEFAULT_SERIALIZE] = true; + var shouldReflush = root.shouldReflush; - function hasDefaultSerialize(route) { - return !!route.serialize[DEFAULT_SERIALIZE]; - } + // when processing non-initial reflush loops, + // do not process more roots than needed + if (i >= initialRootsLength && !shouldReflush) { + continue; + } - /** - @module ember - @submodule ember-routing - */ + root.options.alwaysRevalidate = shouldReflush; + // track shouldReflush based on this roots render result + shouldReflush = root.shouldReflush = _emberMetal.runInTransaction(root, 'render'); - /** - The `Ember.Route` class is used to define individual routes. Refer to - the [routing guide](http://emberjs.com/guides/routing/) for documentation. - - @class Route - @namespace Ember - @extends Ember.Object - @uses Ember.ActionHandler - @uses Ember.Evented - @since 1.0.0 - @public - */ - var Route = _emberRuntime.Object.extend(_emberRuntime.ActionHandler, _emberRuntime.Evented, { - /** - Configuration hash for this route's queryParams. The possible - configuration options and their defaults are as follows - (assuming a query param whose controller property is `page`): - ```javascript - queryParams: { - page: { - // By default, controller query param properties don't - // cause a full transition when they are changed, but - // rather only cause the URL to update. Setting - // `refreshModel` to true will cause an "in-place" - // transition to occur, whereby the model hooks for - // this route (and any child routes) will re-fire, allowing - // you to reload models (e.g., from the server) using the - // updated query param values. - refreshModel: false, - // By default, changes to controller query param properties - // cause the URL to update via `pushState`, which means an - // item will be added to the browser's history, allowing - // you to use the back button to restore the app to the - // previous state before the query param property was changed. - // Setting `replace` to true will use `replaceState` (or its - // hash location equivalent), which causes no browser history - // item to be added. This options name and default value are - // the same as the `link-to` helper's `replace` option. - replace: false, - // By default, the query param URL key is the same name as - // the controller property name. Use `as` to specify a - // different URL key. - as: 'page' + // globalShouldReflush should be `true` if *any* of + // the roots need to reflush + globalShouldReflush = globalShouldReflush || shouldReflush; } - } - ``` - @property queryParams - @for Ember.Route - @type Object - @since 1.6.0 - @public - */ - queryParams: {}, - - /** - The name of the route, dot-delimited. - For example, a route found at `app/routes/posts/post.js` will have - a `routeName` of `posts.post`. - @property routeName - @for Ember.Route - @type String - @since 1.0.0 - @public - */ - /** - Sets the name for this route, including a fully resolved name for routes - inside engines. - @private - @method _setRouteName - @param {String} name - */ - _setRouteName: function (name) { - this.routeName = name; - this.fullRouteName = getEngineRouteName(_emberUtils.getOwner(this), name); - }, - - /** - Populates the QP meta information in the BucketCache. - @private - @method _populateQPMeta - */ - _populateQPMeta: function () { - this._bucketCache.stash('route-meta', this.fullRouteName, this.get('_qp')); - }, - - /** - @private - @property _qp - */ - _qp: _emberMetal.computed(function () { - var _this = this; + this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - var controllerProto = undefined, - combinedQueryParameterConfiguration = undefined; + env.commit(); + } while (globalShouldReflush || roots.length > initialRootsLength); - var controllerName = this.controllerName || this.routeName; - var definedControllerClass = _emberUtils.getOwner(this)._lookupFactory('controller:' + controllerName); - var queryParameterConfiguraton = _emberMetal.get(this, 'queryParams'); - var hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; + // remove any roots that were destroyed during this transaction + while (removedRoots.length) { + var root = removedRoots.pop(); - if (definedControllerClass) { - // the developer has authored a controller class in their application for this route - // access the prototype, find its query params and normalize their object shape - // them merge in the query params for the route. As a mergedProperty, Route#queryParams is always - // at least `{}` - controllerProto = definedControllerClass.proto(); + var rootIndex = roots.indexOf(root); + roots.splice(rootIndex, 1); + } - var controllerDefinedQueryParameterConfiguration = _emberMetal.get(controllerProto, 'queryParams'); - var normalizedControllerQueryParameterConfiguration = _emberRoutingUtils.normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); - combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton); - } else if (hasRouterDefinedQueryParams) { - // the developer has not defined a controller but *has* supplied route query params. - // Generate a class for them so we can later insert default values - var generatedControllerClass = _emberRoutingSystemGenerate_controller.generateControllerFactory(_emberUtils.getOwner(this), controllerName); - controllerProto = generatedControllerClass.proto(); - combinedQueryParameterConfiguration = queryParameterConfiguraton; + if (this._roots.length === 0) { + deregister(this); } + }; - var qps = []; - var map = {}; - var propertyNames = []; + Renderer.prototype._renderRootsTransaction = function _renderRootsTransaction() { + if (this._isRenderingRoots) { + // currently rendering roots, a new root was added and will + // be processed by the existing _renderRoots invocation + return; + } - for (var propName in combinedQueryParameterConfiguration) { - if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { - continue; - } + // used to prevent calling _renderRoots again (see above) + // while we are actively rendering roots + this._isRenderingRoots = true; - // to support the dubious feature of using unknownProperty - // on queryParams configuration - if (propName === 'unknownProperty' || propName === '_super') { - // possible todo: issue deprecation warning? - continue; + var completedWithoutError = false; + try { + this._renderRoots(); + completedWithoutError = true; + } finally { + if (!completedWithoutError) { + this._lastRevision = _glimmerReference.CURRENT_TAG.value(); } + this._isRenderingRoots = false; + } + }; - var desc = combinedQueryParameterConfiguration[propName]; - var scope = desc.scope || 'model'; - var parts = undefined; + Renderer.prototype._clearAllRoots = function _clearAllRoots() { + var roots = this._roots; + for (var i = 0; i < roots.length; i++) { + var root = roots[i]; + root.destroy(); + } - if (scope === 'controller') { - parts = []; - } + this._removedRoots.length = 0; + this._roots = null; - var urlKey = desc.as || this.serializeQueryParamKey(propName); - var defaultValue = _emberMetal.get(controllerProto, propName); + // if roots were present before destroying + // deregister this renderer instance + if (roots.length) { + deregister(this); + } + }; - if (Array.isArray(defaultValue)) { - defaultValue = _emberRuntime.A(defaultValue.slice()); - } + Renderer.prototype._scheduleRevalidate = function _scheduleRevalidate() { + backburner.scheduleOnce('render', this, this._revalidate); + }; - var type = desc.type || _emberRuntime.typeOf(defaultValue); + Renderer.prototype._isValid = function _isValid() { + return this._destroyed || this._roots.length === 0 || _glimmerReference.CURRENT_TAG.validate(this._lastRevision); + }; - var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); - var scopedPropertyName = controllerName + ':' + propName; - var qp = { - undecoratedDefaultValue: _emberMetal.get(controllerProto, propName), - defaultValue: defaultValue, - serializedDefaultValue: defaultValueSerialized, - serializedValue: defaultValueSerialized, + Renderer.prototype._revalidate = function _revalidate() { + if (this._isValid()) { + return; + } + this._renderRootsTransaction(); + }; - type: type, - urlKey: urlKey, - prop: propName, - scopedPropertyName: scopedPropertyName, - controllerName: controllerName, - route: this, - parts: parts, // provided later when stashNames is called if 'model' scope - values: null, // provided later when setup is called. no idea why. - scope: scope - }; + return Renderer; + })(); - map[propName] = map[urlKey] = map[scopedPropertyName] = qp; - qps.push(qp); - propertyNames.push(propName); - } + var InertRenderer = (function (_Renderer) { + babelHelpers.inherits(InertRenderer, _Renderer); - return { - qps: qps, - map: map, - propertyNames: propertyNames, - states: { - /* - Called when a query parameter changes in the URL, this route cares - about that query parameter, but the route is not currently - in the active route hierarchy. - */ - inactive: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - }, - /* - Called when a query parameter changes in the URL, this route cares - about that query parameter, and the route is currently - in the active route hierarchy. - */ - active: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - return _this._activeQPChanged(map[prop], value); - }, - /* - Called when a value of a query parameter this route handles changes in a controller - and the route is currently in the active route hierarchy. - */ - allowOverrides: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - return _this._updatingQPChanged(map[prop]); - } - } - }; - }), + function InertRenderer() { + babelHelpers.classCallCheck(this, InertRenderer); - /** - @private - @property _names - */ - _names: null, + _Renderer.apply(this, arguments); + } - /** - @private - @method _stashNames - */ - _stashNames: function (_handlerInfo, dynamicParent) { - var handlerInfo = _handlerInfo; - if (this._names) { - return; - } - var names = this._names = handlerInfo._names; + InertRenderer.create = function create(_ref) { + var env = _ref.env; + var rootTemplate = _ref.rootTemplate; + var _viewRegistry = _ref._viewRegistry; - if (!names.length) { - handlerInfo = dynamicParent; - names = handlerInfo && handlerInfo._names || []; - } + return new this(env, rootTemplate, _viewRegistry, false); + }; - var qps = _emberMetal.get(this, '_qp.qps'); + InertRenderer.prototype.getElement = function getElement(view) { + throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); + }; - var namePaths = new Array(names.length); - for (var a = 0; a < names.length; ++a) { - namePaths[a] = handlerInfo.name + '.' + names[a]; - } + return InertRenderer; + })(Renderer); - for (var i = 0; i < qps.length; ++i) { - var qp = qps[i]; - if (qp.scope === 'model') { - qp.parts = namePaths; - } - } - }, + exports.InertRenderer = InertRenderer; - /** - @private - @property _activeQPChanged - */ - _activeQPChanged: function (qp, value) { - var router = this.router; - router._activeQPChanged(qp.scopedPropertyName, value); - }, + var InteractiveRenderer = (function (_Renderer2) { + babelHelpers.inherits(InteractiveRenderer, _Renderer2); - /** - @private - @method _updatingQPChanged - */ - _updatingQPChanged: function (qp) { - var router = this.router; - router._updatingQPChanged(qp.urlKey); - }, + function InteractiveRenderer() { + babelHelpers.classCallCheck(this, InteractiveRenderer); - mergedProperties: ['queryParams'], + _Renderer2.apply(this, arguments); + } - /** - Returns a hash containing the parameters of an ancestor route. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('member', { path: ':name' }, function() { - this.route('interest', { path: ':interest' }); - }); - }); - ``` - ```app/routes/member.js - export default Ember.Route.extend({ - queryParams: { - memberQp: { refreshModel: true } - } - }); - ``` - ```app/routes/member/interest.js - export default Ember.Route.extend({ - queryParams: { - interestQp: { refreshModel: true } - }, - model() { - return this.paramsFor('member'); - } - }); - ``` - If we visit `/turing/maths?memberQp=member&interestQp=interest` the model for - the `member.interest` route is hash with: - * `name`: `turing` - * `memberQp`: `member` - @method paramsFor - @param {String} name - @return {Object} hash containing the parameters of the route `name` - @since 1.4.0 - @public - */ - paramsFor: function (name) { - var _this2 = this; + InteractiveRenderer.create = function create(_ref2) { + var env = _ref2.env; + var rootTemplate = _ref2.rootTemplate; + var _viewRegistry = _ref2._viewRegistry; - var route = _emberUtils.getOwner(this).lookup('route:' + name); + return new this(env, rootTemplate, _viewRegistry, true); + }; - if (!route) { - return {}; - } + InteractiveRenderer.prototype.getElement = function getElement(view) { + return _emberViews.getViewElement(view); + }; - var transition = this.router.router.activeTransition; - var state = transition ? transition.state : this.router.router.state; + return InteractiveRenderer; + })(Renderer); - var fullName = route.fullRouteName; - var params = _emberUtils.assign({}, state.params[fullName]); - var queryParams = getQueryParamsFor(route, state); + exports.InteractiveRenderer = InteractiveRenderer; +}); +enifed('ember-glimmer/setup-registry', ['exports', 'ember-environment', 'container', 'ember-glimmer/renderer', 'ember-glimmer/dom', 'ember-glimmer/views/outlet', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/templates/component', 'ember-glimmer/templates/root', 'ember-glimmer/templates/outlet', 'ember-glimmer/environment'], function (exports, _emberEnvironment, _container, _emberGlimmerRenderer, _emberGlimmerDom, _emberGlimmerViewsOutlet, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerTemplatesComponent, _emberGlimmerTemplatesRoot, _emberGlimmerTemplatesOutlet, _emberGlimmerEnvironment) { + 'use strict'; - return Object.keys(queryParams).reduce(function (params, key) { - _emberMetal.assert('The route \'' + _this2.routeName + '\' has both a dynamic segment and query param with name \'' + key + '\'. Please rename one to avoid collisions.', !params[key]); - params[key] = queryParams[key]; - return params; - }, params); - }, + exports.setupApplicationRegistry = setupApplicationRegistry; + exports.setupEngineRegistry = setupEngineRegistry; - /** - Serializes the query parameter key - @method serializeQueryParamKey - @param {String} controllerPropertyName - @private - */ - serializeQueryParamKey: function (controllerPropertyName) { - return controllerPropertyName; - }, + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:-root'], ['template:-root']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - /** - Serializes value of the query parameter based on defaultValueType - @method serializeQueryParam - @param {Object} value - @param {String} urlKey - @param {String} defaultValueType - @private - */ - serializeQueryParam: function (value, urlKey, defaultValueType) { - // urlKey isn't used here, but anyone overriding - // can use it to provide serialization specific - // to a certain query param. - return this.router._serializeQueryParam(value, defaultValueType); - }, + function setupApplicationRegistry(registry) { + registry.injection('service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); + registry.injection('renderer', 'env', 'service:-glimmer-environment'); - /** - Deserializes value of the query parameter based on defaultValueType - @method deserializeQueryParam - @param {Object} value - @param {String} urlKey - @param {String} defaultValueType - @private - */ - deserializeQueryParam: function (value, urlKey, defaultValueType) { - // urlKey isn't used here, but anyone overriding - // can use it to provide deserialization specific - // to a certain query param. - return this.router._deserializeQueryParam(value, defaultValueType); - }, + registry.register(_container.privatize(_templateObject), _emberGlimmerTemplatesRoot.default); + registry.injection('renderer', 'rootTemplate', _container.privatize(_templateObject)); - /** - @private - @property _optionsForQueryParam - */ - _optionsForQueryParam: function (qp) { - return _emberMetal.get(this, 'queryParams.' + qp.urlKey) || _emberMetal.get(this, 'queryParams.' + qp.prop) || {}; - }, + registry.register('renderer:-dom', _emberGlimmerRenderer.InteractiveRenderer); + registry.register('renderer:-inert', _emberGlimmerRenderer.InertRenderer); - /** - A hook you can use to reset controller values either when the model - changes or the route is exiting. - ```app/routes/articles.js - import Ember from 'ember'; - export default Ember.Route.extend({ - resetController(controller, isExiting, transition) { - if (isExiting) { - controller.set('page', 1); - } - } - }); - ``` - @method resetController - @param {Controller} controller instance - @param {Boolean} isExiting - @param {Object} transition - @since 1.7.0 - @public - */ - resetController: K, + if (_emberEnvironment.environment.hasDOM) { + registry.injection('service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); + } - /** - @private - @method exit - */ - exit: function () { - this.deactivate(); - this.trigger('deactivate'); - this.teardownViews(); - }, + registry.register('service:-dom-changes', { + create: function (_ref) { + var document = _ref.document; - /** - @private - @method _reset - @since 1.7.0 - */ - _reset: function (isExiting, transition) { - var controller = this.controller; - controller._qpDelegate = _emberMetal.get(this, '_qp.states.inactive'); + return new _emberGlimmerDom.DOMChanges(document); + } + }); - this.resetController(controller, isExiting, transition); - }, + registry.register('service:-dom-tree-construction', { + create: function (_ref2) { + var document = _ref2.document; - /** - @private - @method enter - */ - enter: function () { - this.connections = []; - this.activate(); - this.trigger('activate'); - }, + var Implementation = _emberEnvironment.environment.hasDOM ? _emberGlimmerDom.DOMTreeConstruction : _emberGlimmerDom.NodeDOMTreeConstruction; + return new Implementation(document); + } + }); + } - /** - The name of the template to use by default when rendering this routes - template. - ```app/routes/posts/list.js - import Ember from 'ember'; - export default Ember.Route.extend({ - templateName: 'posts/list' - }); - ``` - ```app/routes/posts/index.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - ```app/routes/posts/archived.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - @property templateName - @type String - @default null - @since 1.4.0 - @public - */ - templateName: null, + function setupEngineRegistry(registry) { + registry.register('view:-outlet', _emberGlimmerViewsOutlet.default); + registry.register('template:-outlet', _emberGlimmerTemplatesOutlet.default); + registry.injection('view:-outlet', 'template', 'template:-outlet'); - /** - The name of the controller to associate with this route. - By default, Ember will lookup a route's controller that matches the name - of the route (i.e. `App.PostController` for `App.PostRoute`). However, - if you would like to define a specific controller to use, you can do so - using this property. - This is useful in many ways, as the controller specified will be: - * passed to the `setupController` method. - * used as the controller for the template being rendered by the route. - * returned from a call to `controllerFor` for the route. - @property controllerName - @type String - @default null - @since 1.4.0 - @public - */ - controllerName: null, + registry.injection('service:-dom-changes', 'document', 'service:-document'); + registry.injection('service:-dom-tree-construction', 'document', 'service:-document'); - /** - The `willTransition` action is fired at the beginning of any - attempted transition with a `Transition` object as the sole - argument. This action can be used for aborting, redirecting, - or decorating the transition from the currently active routes. - A good example is preventing navigation when a form is - half-filled out: - ```app/routes/contact-form.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - willTransition(transition) { - if (this.controller.get('userHasEnteredData')) { - this.controller.displayNavigationConfirm(); - transition.abort(); - } - } - } - }); - ``` - You can also redirect elsewhere by calling - `this.transitionTo('elsewhere')` from within `willTransition`. - Note that `willTransition` will not be fired for the - redirecting `transitionTo`, since `willTransition` doesn't - fire when there is already a transition underway. If you want - subsequent `willTransition` actions to fire for the redirecting - transition, you must first explicitly call - `transition.abort()`. - To allow the `willTransition` event to continue bubbling to the parent - route, use `return true;`. When the `willTransition` method has a - return value of `true` then the parent route's `willTransition` method - will be fired, enabling "bubbling" behavior for the event. - @event willTransition - @param {Transition} transition - @since 1.0.0 - @public - */ + registry.register(_container.privatize(_templateObject2), _emberGlimmerTemplatesComponent.default); + + registry.register('service:-glimmer-environment', _emberGlimmerEnvironment.default); + registry.injection('template', 'env', 'service:-glimmer-environment'); + + registry.optionsForType('helper', { instantiate: false }); + + registry.register('component:-text-field', _emberGlimmerComponentsText_field.default); + registry.register('component:-text-area', _emberGlimmerComponentsText_area.default); + registry.register('component:-checkbox', _emberGlimmerComponentsCheckbox.default); + registry.register('component:link-to', _emberGlimmerComponentsLinkTo.default); + registry.register(_container.privatize(_templateObject3), _emberGlimmerComponent.default); + } +}); +enifed('ember-glimmer/syntax', ['exports', 'ember-glimmer/syntax/render', 'ember-glimmer/syntax/outlet', 'ember-glimmer/syntax/mount', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/bindings', 'ember-glimmer/syntax/-with-dynamic-vars', 'ember-glimmer/syntax/-in-element', 'ember-glimmer/syntax/input', 'ember-glimmer/syntax/-text-area', 'ember-metal'], function (exports, _emberGlimmerSyntaxRender, _emberGlimmerSyntaxOutlet, _emberGlimmerSyntaxMount, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsBindings, _emberGlimmerSyntaxWithDynamicVars, _emberGlimmerSyntaxInElement, _emberGlimmerSyntaxInput, _emberGlimmerSyntaxTextArea, _emberMetal) { + 'use strict'; - /** - The `didTransition` action is fired after a transition has - successfully been completed. This occurs after the normal model - hooks (`beforeModel`, `model`, `afterModel`, `setupController`) - have resolved. The `didTransition` action has no arguments, - however, it can be useful for tracking page views or resetting - state on the controller. - ```app/routes/login.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - didTransition() { - this.controller.get('errors.base').clear(); - return true; // Bubble the didTransition event - } - } - }); - ``` - @event didTransition - @since 1.2.0 - @public - */ + exports.registerMacros = registerMacros; + exports.populateMacros = populateMacros; - /** - The `loading` action is fired on the route when a route's `model` - hook returns a promise that is not already resolved. The current - `Transition` object is the first parameter and the route that - triggered the loading event is the second parameter. - ```app/routes/application.js - export default Ember.Route.extend({ - actions: { - loading(transition, route) { - let controller = this.controllerFor('foo'); - controller.set('currentlyLoading', true); - transition.finally(function() { - controller.set('currentlyLoading', false); - }); - } - } - }); - ``` - @event loading - @param {Transition} transition - @param {Ember.Route} route The route that triggered the loading event - @since 1.2.0 - @public - */ + function refineInlineSyntax(path, params, hash, builder) { + var name = path[0]; - /** - When attempting to transition into a route, any of the hooks - may return a promise that rejects, at which point an `error` - action will be fired on the partially-entered routes, allowing - for per-route error handling logic, or shared error handling - logic defined on a parent route. - Here is an example of an error handler that will be invoked - for rejected promises from the various hooks on the route, - as well as any unhandled errors from child routes: - ```app/routes/admin.js - import Ember from 'ember'; - export default Ember.Route.extend({ - beforeModel() { - return Ember.RSVP.reject('bad things!'); - }, - actions: { - error(error, transition) { - // Assuming we got here due to the error in `beforeModel`, - // we can expect that error === "bad things!", - // but a promise model rejecting would also - // call this hook, as would any errors encountered - // in `afterModel`. - // The `error` hook is also provided the failed - // `transition`, which can be stored and later - // `.retry()`d if desired. - this.transitionTo('login'); - } - } - }); - ``` - `error` actions that bubble up all the way to `ApplicationRoute` - will fire a default error handler that logs the error. You can - specify your own global default error handler by overriding the - `error` handler on `ApplicationRoute`: - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - error(error, transition) { - this.controllerFor('banner').displayError(error.message); - } - } - }); - ``` - @event error - @param {Error} error - @param {Transition} transition - @since 1.0.0 - @public - */ + _emberMetal.assert('You attempted to overwrite the built-in helper "' + name + '" which is not allowed. Please rename the helper.', !(builder.env.builtInHelpers[name] && builder.env.owner.hasRegistration('helper:' + name))); - /** - This event is triggered when the router enters the route. It is - not executed when the model for the route changes. - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - collectAnalytics: Ember.on('activate', function(){ - collectAnalytics(); - }) - }); - ``` - @event activate - @since 1.9.0 - @public - */ + if (path.length > 1) { + return _emberGlimmerSyntaxDynamicComponent.closureComponentMacro(path, params, hash, null, null, builder); + } - /** - This event is triggered when the router completely exits this - route. It is not executed when the model for the route changes. - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - trackPageLeaveAnalytics: Ember.on('deactivate', function(){ - trackPageLeaveAnalytics(); - }) - }); - ``` - @event deactivate - @since 1.9.0 - @public - */ + var symbolTable = builder.symbolTable; - /** - The controller associated with this route. - Example - ```app/routes/form.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - willTransition(transition) { - if (this.controller.get('userHasEnteredData') && - !confirm('Are you sure you want to abandon progress?')) { - transition.abort(); - } else { - // Bubble the `willTransition` action so that - // parent routes can decide whether or not to abort. - return true; - } - } - } - }); - ``` - @property controller - @type Ember.Controller - @since 1.6.0 - @public - */ + var definition = undefined; + if (name.indexOf('-') > -1) { + definition = builder.env.getComponentDefinition(path, symbolTable); + } - actions: { + if (definition) { + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, null, null], symbolTable); + return true; + } - /** - This action is called when one or more query params have changed. Bubbles. - @method queryParamsDidChange - @param changed {Object} Keys are names of query params that have changed. - @param totalPresent {Object} Keys are names of query params that are currently set. - @param removed {Object} Keys are names of query params that have been removed. - @returns {boolean} - @private - */ - queryParamsDidChange: function (changed, totalPresent, removed) { - var qpMap = _emberMetal.get(this, '_qp').map; + return false; + } - var totalChanged = Object.keys(changed).concat(Object.keys(removed)); - for (var i = 0; i < totalChanged.length; ++i) { - var qp = qpMap[totalChanged[i]]; - if (qp && _emberMetal.get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) { - this.refresh(); - } - } + function refineBlockSyntax(sexp, builder) { + var path = sexp[1]; + var params = sexp[2]; + var hash = sexp[3]; + var _default = sexp[4]; + var inverse = sexp[5]; + var name = path[0]; - return true; - }, + if (path.length > 1) { + return _emberGlimmerSyntaxDynamicComponent.closureComponentMacro(path, params, hash, _default, inverse, builder); + } - finalizeQueryParamChange: function (params, finalParams, transition) { - if (this.fullRouteName !== 'application') { - return true; - } + if (name.indexOf('-') === -1) { + return false; + } - // Transition object is absent for intermediate transitions. - if (!transition) { - return; - } + var symbolTable = builder.symbolTable; - var handlerInfos = transition.state.handlerInfos; - var router = this.router; - var qpMeta = router._queryParamsFor(handlerInfos); - var changes = router._qpUpdates; - var replaceUrl = undefined; + var definition = undefined; + if (name.indexOf('-') > -1) { + definition = builder.env.getComponentDefinition(path, symbolTable); + } - _emberRoutingUtils.stashParamNames(router, handlerInfos); + if (definition) { + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, _default, inverse], symbolTable); + return true; + } - for (var i = 0; i < qpMeta.qps.length; ++i) { - var qp = qpMeta.qps[i]; - var route = qp.route; - var controller = route.controller; - var presentKey = qp.urlKey in params && qp.urlKey; + _emberMetal.assert('A component or helper named "' + name + '" could not be found', builder.env.hasHelper(path, symbolTable)); - // Do a reverse lookup to see if the changed query - // param URL key corresponds to a QP property on - // this controller. - var value = undefined, - svalue = undefined; - if (changes && qp.urlKey in changes) { - // Value updated in/before setupController - value = _emberMetal.get(controller, qp.prop); - svalue = route.serializeQueryParam(value, qp.urlKey, qp.type); - } else { - if (presentKey) { - svalue = params[presentKey]; - value = route.deserializeQueryParam(svalue, qp.urlKey, qp.type); - } else { - // No QP provided; use default value. - svalue = qp.serializedDefaultValue; - value = copyDefaultValue(qp.defaultValue); - } - } + _emberMetal.assert('Helpers may not be used in the block form, for example {{#' + name + '}}{{/' + name + '}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (' + name + ')}}{{/if}}.', !builder.env.hasHelper(path, symbolTable)); - controller._qpDelegate = _emberMetal.get(route, '_qp.states.inactive'); + return false; + } - var thisQueryParamChanged = svalue !== qp.serializedValue; - if (thisQueryParamChanged) { - if (transition.queryParamsOnly && replaceUrl !== false) { - var options = route._optionsForQueryParam(qp); - var replaceConfigValue = _emberMetal.get(options, 'replace'); - if (replaceConfigValue) { - replaceUrl = true; - } else if (replaceConfigValue === false) { - // Explicit pushState wins over any other replaceStates. - replaceUrl = false; - } - } + var experimentalMacros = []; - _emberMetal.set(controller, qp.prop, value); - } + // This is a private API to allow for expiremental macros + // to be created in user space. Registering a macro should + // should be done in an initializer. - // Stash current serialized value of controller. - qp.serializedValue = svalue; + function registerMacros(macro) { + experimentalMacros.push(macro); + } - var thisQueryParamHasDefaultValue = qp.serializedDefaultValue === svalue; - if (!thisQueryParamHasDefaultValue) { - finalParams.push({ - value: svalue, - visible: true, - key: presentKey || qp.urlKey - }); - } - } + function populateMacros(blocks, inlines) { + inlines.add('outlet', _emberGlimmerSyntaxOutlet.outletMacro); + inlines.add('component', _emberGlimmerSyntaxDynamicComponent.inlineComponentMacro); + inlines.add('render', _emberGlimmerSyntaxRender.renderMacro); + inlines.add('mount', _emberGlimmerSyntaxMount.mountMacro); + inlines.add('input', _emberGlimmerSyntaxInput.inputMacro); + inlines.add('textarea', _emberGlimmerSyntaxTextArea.textAreaMacro); + inlines.addMissing(refineInlineSyntax); + blocks.add('component', _emberGlimmerSyntaxDynamicComponent.blockComponentMacro); + blocks.add('-with-dynamic-vars', _emberGlimmerSyntaxWithDynamicVars._withDynamicVarsMacro); + blocks.add('-in-element', _emberGlimmerSyntaxInElement._inElementMacro); + blocks.addMissing(refineBlockSyntax); - if (replaceUrl) { - transition.method('replace'); - } + for (var i = 0; i < experimentalMacros.length; i++) { + var macro = experimentalMacros[i]; + macro(blocks, inlines); + } - qpMeta.qps.forEach(function (qp) { - var routeQpMeta = _emberMetal.get(qp.route, '_qp'); - var finalizedController = qp.route.controller; - finalizedController._qpDelegate = _emberMetal.get(routeQpMeta, 'states.active'); - }); + experimentalMacros = []; - router._qpUpdates = null; - } - }, + return { blocks: blocks, inlines: inlines }; + } +}); +enifed('ember-glimmer/syntax/-in-element', ['exports', '@glimmer/runtime', '@glimmer/util'], function (exports, _glimmerRuntime, _glimmerUtil) { + 'use strict'; - /** - This hook is executed when the router completely exits this route. It is - not executed when the model for the route changes. - @method deactivate - @since 1.0.0 - @public - */ - deactivate: K, + exports._inElementMacro = _inElementMacro; + var _BaselineSyntax$NestedBlock = _glimmerRuntime.BaselineSyntax.NestedBlock; + var defaultBlock = _BaselineSyntax$NestedBlock.defaultBlock; + var params = _BaselineSyntax$NestedBlock.params; + var hash = _BaselineSyntax$NestedBlock.hash; - /** - This hook is executed when the router enters the route. It is not executed - when the model for the route changes. - @method activate - @since 1.0.0 - @public - */ - activate: K, + function _inElementMacro(sexp, builder) { + var block = defaultBlock(sexp); + var args = _glimmerRuntime.compileArgs(params(sexp), hash(sexp), builder); - /** - Transition the application into another route. The route may - be either a single route or route path: - ```javascript - this.transitionTo('blogPosts'); - this.transitionTo('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - this.transitionTo('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - this.transitionTo('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```app/routes.js - // ... - Router.map(function() { - this.route('blogPost', { path:':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId' }); - }); - }); - export default Router; - ``` - ```javascript - this.transitionTo('blogComment', aPost, aComment); - this.transitionTo('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - this.transitionTo('/'); - this.transitionTo('/blog/post/1/comment/13'); - this.transitionTo('/blog/posts?sort=title'); - ``` - An options hash with a `queryParams` property may be provided as - the final argument to add query parameters to the destination URL. - ```javascript - this.transitionTo('blogPost', 1, { - queryParams: { showComments: 'true' } - }); - // if you just want to transition the query parameters without changing the route - this.transitionTo({ queryParams: { sort: 'date' } }); - ``` - See also [replaceWith](#method_replaceWith). - Simple Transition Example - ```app/routes.js - // ... - Router.map(function() { - this.route('index'); - this.route('secret'); - this.route('fourOhFour', { path: '*:' }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember': - export Ember.Route.extend({ - actions: { - moveToSecret(context) { - if (authorized()) { - this.transitionTo('secret', context); - } else { - this.transitionTo('fourOhFour'); - } - } - } - }); - ``` - Transition to a nested route - ```app/router.js - // ... - Router.map(function() { - this.route('articles', { path: '/articles' }, function() { - this.route('new'); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - transitionToNewArticle() { - this.transitionTo('articles.new'); - } - } - }); - ``` - Multiple Models Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('breakfast', { path: ':breakfastId' }, function() { - this.route('cereal', { path: ':cerealId' }); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - moveToChocolateCereal() { - let cereal = { cerealId: 'ChocolateYumminess' }; - let breakfast = { breakfastId: 'CerealAndMilk' }; - this.transitionTo('breakfast.cereal', breakfast, cereal); - } - } - }); - ``` - Nested Route with Query String Example - ```app/routes.js - // ... - Router.map(function() { - this.route('fruits', function() { - this.route('apples'); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - transitionToApples() { - this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); - } - } - }); - ``` - @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 - @since 1.0.0 - @public - */ - transitionTo: function (name, context) { - var router = this.router; - return router.transitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, + builder.putArgs(args); + builder.test('simple'); - /** - Perform a synchronous transition into another route without attempting - to resolve promises, update the URL, or abort any currently active - asynchronous transitions (i.e. regular transitions caused by - `transitionTo` or URL changes). - This method is handy for performing intermediate transitions on the - way to a final destination route, and is called internally by the - default implementations of the `error` and `loading` handlers. - @method intermediateTransitionTo - @param {String} name the name of the route - @param {...Object} models the model(s) to be used while transitioning - to the route. - @since 1.2.0 - @public - */ - intermediateTransitionTo: function () { - var router = this.router; - router.intermediateTransitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, + builder.labelled(null, function (b) { + b.jumpUnless('END'); + b.pushRemoteElement(); + b.evaluate(_glimmerUtil.unwrap(block)); + b.popRemoteElement(); + }); + } +}); +enifed('ember-glimmer/syntax/-text-area', ['exports', 'ember-glimmer/utils/bindings'], function (exports, _emberGlimmerUtilsBindings) { + 'use strict'; - /** - Refresh the model on this route and any child routes, firing the - `beforeModel`, `model`, and `afterModel` hooks in a similar fashion - to how routes are entered when transitioning in from other route. - The current route params (e.g. `article_id`) will be passed in - to the respective model hooks, and if a different model is returned, - `setupController` and associated route hooks will re-fire as well. - An example usage of this method is re-querying the server for the - latest information using the same parameters as when the route - was first entered. - Note that this will cause `model` hooks to fire even on routes - that were provided a model object when the route was initially - entered. - @method refresh - @return {Transition} the transition object associated with this - attempted transition - @since 1.4.0 - @public - */ - refresh: function () { - return this.router.router.refresh(this); - }, + exports.textAreaMacro = textAreaMacro; + + function textAreaMacro(path, params, hash, builder) { + var definition = builder.env.getComponentDefinition(['-text-area'], builder.symbolTable); + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; + } +}); +enifed('ember-glimmer/syntax/-with-dynamic-vars', ['exports', '@glimmer/runtime', '@glimmer/util'], function (exports, _glimmerRuntime, _glimmerUtil) { + 'use strict'; + + exports._withDynamicVarsMacro = _withDynamicVarsMacro; + var _BaselineSyntax$NestedBlock = _glimmerRuntime.BaselineSyntax.NestedBlock; + var defaultBlock = _BaselineSyntax$NestedBlock.defaultBlock; + var params = _BaselineSyntax$NestedBlock.params; + var hash = _BaselineSyntax$NestedBlock.hash; + + function _withDynamicVarsMacro(sexp, builder) { + var block = defaultBlock(sexp); + var args = _glimmerRuntime.compileArgs(params(sexp), hash(sexp), builder); + + builder.unit(function (b) { + b.putArgs(args); + b.pushDynamicScope(); + b.bindDynamicScope(args.named.keys); + b.evaluate(_glimmerUtil.unwrap(block)); + b.popDynamicScope(); + }); + } +}); +enifed('ember-glimmer/syntax/abstract-manager', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; + + var AbstractManager = function AbstractManager() { + babelHelpers.classCallCheck(this, AbstractManager); + }; + + _emberMetal.runInDebug(function () { + AbstractManager.prototype._pushToDebugStack = function (name, environment) { + this.debugStack = environment.debugStack; + this.debugStack.push(name); + }; + + AbstractManager.prototype._pushEngineToDebugStack = function (name, environment) { + this.debugStack = environment.debugStack; + this.debugStack.pushEngine(name); + }; + }); + + exports.default = AbstractManager; +}); +enifed('ember-glimmer/syntax/curly-component', ['exports', 'ember-utils', '@glimmer/runtime', 'ember-glimmer/utils/bindings', 'ember-glimmer/component', 'ember-metal', 'ember-views', 'ember-glimmer/utils/process-args', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _emberUtils, _glimmerRuntime, _emberGlimmerUtilsBindings, _emberGlimmerComponent, _emberMetal, _emberViews, _emberGlimmerUtilsProcessArgs, _container, _emberGlimmerSyntaxAbstractManager) { + 'use strict'; + + exports.validatePositionalParameters = validatePositionalParameters; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); - /** - Transition into another route while replacing the current URL, if possible. - This will replace the current history entry instead of adding a new one. - Beside that, it is identical to `transitionTo` in all other respects. See - 'transitionTo' for additional information regarding multiple models. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('secret'); - }); - export default Router; - ``` - ```app/routes/secret.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { - if (!authorized()){ - this.replaceWith('index'); - } - } - }); - ``` - @method replaceWith - @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. - @return {Transition} the transition object associated with this - attempted transition - @since 1.0.0 - @public - */ - replaceWith: function () { - var router = this.router; - return router.replaceWith.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, + var DEFAULT_LAYOUT = _container.privatize(_templateObject); - /** - Sends an action to the router, which will delegate it to the currently - active route hierarchy per the bubbling rules explained under `actions`. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - }); - export default Router; - ``` - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - track(arg) { - console.log(arg, 'was clicked'); - } - } - }); - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - trackIfDebug(arg) { - if (debug) { - this.send('track', arg); - } - } + function processComponentInitializationAssertions(component, props) { + _emberMetal.assert('classNameBindings must not have spaces in them: ' + component.toString(), (function () { + var classNameBindings = component.classNameBindings; + + for (var i = 0; i < classNameBindings.length; i++) { + var binding = classNameBindings[i]; + if (binding.split(' ').length > 1) { + return false; } - }); - ``` - @method send - @param {String} name the name of the action to trigger - @param {...*} args - @since 1.0.0 - @public - */ - send: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; } + return true; + })()); - if (this.router && this.router.router || !_emberMetal.isTesting()) { - var _router; + _emberMetal.assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), (function () { + var classNameBindings = component.classNameBindings; + var tagName = component.tagName; - (_router = this.router).send.apply(_router, args); - } else { - var _name2 = args[0]; - args = slice.call(args, 1); - var action = this.actions[_name2]; - if (action) { - return this.actions[_name2].apply(this, args); - } - } - }, + return tagName !== '' || !classNameBindings || classNameBindings.length === 0; + })()); - /** - This hook is the entry point for router.js - @private - @method setup - */ - setup: function (context, transition) { - var _this3 = this; + _emberMetal.assert('You cannot use `elementId` on a tag-less component: ' + component.toString(), (function () { + var elementId = component.elementId; + var tagName = component.tagName; - var controller = undefined; + return tagName !== '' || props.id === elementId || !elementId && elementId !== ''; + })()); - var controllerName = this.controllerName || this.routeName; - var definedController = this.controllerFor(controllerName, true); + _emberMetal.assert('You cannot use `attributeBindings` on a tag-less component: ' + component.toString(), (function () { + var attributeBindings = component.attributeBindings; + var tagName = component.tagName; - if (!definedController) { - controller = this.generateController(controllerName); + return tagName !== '' || !attributeBindings || attributeBindings.length === 0; + })()); + } + + function validatePositionalParameters(named, positional, positionalParamsDefinition) { + _emberMetal.runInDebug(function () { + if (!named || !positional || !positional.length) { + return; + } + + var paramType = typeof positionalParamsDefinition; + + if (paramType === 'string') { + _emberMetal.assert('You cannot specify positional parameters and the hash argument `' + positionalParamsDefinition + '`.', !named.has(positionalParamsDefinition)); } else { - controller = definedController; + if (positional.length < positionalParamsDefinition.length) { + positionalParamsDefinition = positionalParamsDefinition.slice(0, positional.length); + } + + for (var i = 0; i < positionalParamsDefinition.length; i++) { + var _name = positionalParamsDefinition[i]; + + _emberMetal.assert('You cannot specify both a positional param (at position ' + i + ') and the hash argument `' + _name + '`.', !named.has(_name)); + } } + }); + } - // Assign the route's controller so that it can more easily be - // referenced in action handlers. Side effects. Side effects everywhere. - if (!this.controller) { - var propNames = _emberMetal.get(this, '_qp.propertyNames'); - addQueryParamsObservers(controller, propNames); - this.controller = controller; + function aliasIdToElementId(args, props) { + if (args.named.has('id')) { + _emberMetal.assert('You cannot invoke a component with both \'id\' and \'elementId\' at the same time.', !args.named.has('elementId')); + props.elementId = props.id; + } + } + + // We must traverse the attributeBindings in reverse keeping track of + // what has already been applied. This is essentially refining the concated + // properties applying right to left. + function applyAttributeBindings(element, attributeBindings, component, operations) { + var seen = []; + var i = attributeBindings.length - 1; + + while (i !== -1) { + var binding = attributeBindings[i]; + var parsed = _emberGlimmerUtilsBindings.AttributeBinding.parse(binding); + var attribute = parsed[1]; + + if (seen.indexOf(attribute) === -1) { + seen.push(attribute); + _emberGlimmerUtilsBindings.AttributeBinding.install(element, component, parsed, operations); } - var queryParams = _emberMetal.get(this, '_qp'); + i--; + } - var states = queryParams.states; + if (seen.indexOf('id') === -1) { + operations.addStaticAttribute(element, 'id', component.elementId); + } - controller._qpDelegate = states.allowOverrides; + if (seen.indexOf('style') === -1) { + _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); + } + } - if (transition) { - (function () { - // Update the model dep values used to calculate cache keys. - _emberRoutingUtils.stashParamNames(_this3.router, transition.state.handlerInfos); + function NOOP() {} - var params = transition.params; - var allParams = queryParams.propertyNames; - var cache = _this3._bucketCache; + var ComponentStateBucket = (function () { + function ComponentStateBucket(environment, component, args, finalizer) { +babelHelpers.classCallCheck(this, ComponentStateBucket); - allParams.forEach(function (prop) { - var aQp = queryParams.map[prop]; + this.environment = environment; + this.component = component; + this.classRef = null; + this.args = args; + this.argsRevision = args.tag.value(); + this.finalizer = finalizer; + } - aQp.values = params; - var cacheKey = _emberRoutingUtils.calculateCacheKey(aQp.controllerName, aQp.parts, aQp.values); + ComponentStateBucket.prototype.destroy = function destroy() { + var component = this.component; + var environment = this.environment; - if (cache) { - var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); - _emberMetal.set(controller, prop, value); - } - }); - })(); + if (environment.isInteractive) { + component.trigger('willDestroyElement'); + component.trigger('willClearRender'); } - if (transition) { - var qpValues = getQueryParamsFor(this, transition.state); - controller.setProperties(qpValues); - } + environment.destroyedComponents.push(component); + }; - this.setupController(controller, context, transition); + ComponentStateBucket.prototype.finalize = function finalize() { + var finalizer = this.finalizer; - if (this._environment.options.shouldRender) { - this.renderTemplate(controller, context); - } - }, + finalizer(); + this.finalizer = NOOP; + }; - /* - Called when a query parameter for this route changes, regardless of whether the route - is currently part of the active route hierarchy. This will update the query parameter's - value in the cache so if this route becomes active, the cache value has been updated. - */ - _qpChanged: function (prop, value, qp) { - if (!qp) { - return; - } + return ComponentStateBucket; + })(); - var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.controllerName, qp.parts, qp.values); + function initialRenderInstrumentDetails(component) { + return component.instrumentDetails({ initialRender: true }); + } - // Update model-dep cache - var cache = this._bucketCache; - if (cache) { - cache.stash(cacheKey, prop, value); - } - }, + function rerenderInstrumentDetails(component) { + return component.instrumentDetails({ initialRender: false }); + } - /** - This hook is the first of the route entry validation hooks - called when an attempt is made to transition into a route - or one of its children. It is called before `model` and - `afterModel`, and is appropriate for cases when: - 1) A decision can be made to redirect elsewhere without - needing to resolve the model first. - 2) Any async operations need to occur first before the - model is attempted to be resolved. - This hook is provided the current `transition` attempt - as a parameter, which can be used to `.abort()` the transition, - save it for a later `.retry()`, or retrieve values set - on it from a previous hook. You can also just call - `this.transitionTo` to another route to implicitly - abort the `transition`. - You can return a promise from this hook to pause the - transition until the promise resolves (or rejects). This could - be useful, for instance, for retrieving async code from - the server that is required to enter a route. - @method beforeModel - @param {Transition} transition - @return {Promise} if the value returned from this hook is - a promise, the transition will pause until the transition - resolves. Otherwise, non-promise return values are not - utilized in any way. - @since 1.0.0 - @public - */ - beforeModel: K, + var CurlyComponentManager = (function (_AbstractManager) { +babelHelpers.inherits(CurlyComponentManager, _AbstractManager); - /** - This hook is called after this route's model has resolved. - It follows identical async/promise semantics to `beforeModel` - but is provided the route's resolved model in addition to - the `transition`, and is therefore suited to performing - logic that can only take place after the model has already - resolved. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel(posts, transition) { - if (posts.get('length') === 1) { - this.transitionTo('post.show', posts.get('firstObject')); - } - } - }); - ``` - Refer to documentation for `beforeModel` for a description - of transition-pausing semantics when a promise is returned - from this hook. - @method afterModel - @param {Object} resolvedModel the value returned from `model`, - or its resolved value if it was a promise - @param {Transition} transition - @return {Promise} if the value returned from this hook is - a promise, the transition will pause until the transition - resolves. Otherwise, non-promise return values are not - utilized in any way. - @since 1.0.0 - @public - */ - afterModel: K, + function CurlyComponentManager() { +babelHelpers.classCallCheck(this, CurlyComponentManager); - /** - A hook you can implement to optionally redirect to another route. - If you call `this.transitionTo` from inside of this hook, this route - will not be entered in favor of the other hook. - `redirect` and `afterModel` behave very similarly and are - called almost at the same time, but they have an important - distinction in the case that, from one of these hooks, a - redirect into a child route of this route occurs: redirects - from `afterModel` essentially invalidate the current attempt - to enter this route, and will result in this route's `beforeModel`, - `model`, and `afterModel` hooks being fired again within - the new, redirecting transition. Redirects that occur within - the `redirect` hook, on the other hand, will _not_ cause - these hooks to be fired again the second time around; in - other words, by the time the `redirect` hook has been called, - both the resolved model and attempted entry into this route - are considered to be fully validated. - @method redirect - @param {Object} model the model for this route - @param {Transition} transition the transition object associated with the current transition - @since 1.0.0 - @public - */ - redirect: K, + _AbstractManager.apply(this, arguments); + } - /** - Called when the context is changed by router.js. - @private - @method contextDidChange - */ - contextDidChange: function () { - this.currentModel = this.context; - }, + CurlyComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { + if (definition.ComponentClass) { + validatePositionalParameters(args.named, args.positional.values, definition.ComponentClass.class.positionalParams); + } - /** - A hook you can implement to convert the URL into the model for - this route. - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - The model for the `post` route is `store.findRecord('post', params.post_id)`. - By default, if your route has a dynamic segment ending in `_id`: - * The model class is determined from the segment (`post_id`'s - class is `App.Post`) - * The find method is called on the model class with the value of - the dynamic segment. - Note that for routes with dynamic segments, this hook is not always - executed. If the route is entered through a transition (e.g. when - using the `link-to` Handlebars helper or the `transitionTo` method - of routes), and a model context is already provided this hook - is not called. - A model context does not include a primitive string or number, - which does cause the model hook to be called. - Routes without dynamic segments will always execute the model hook. - ```javascript - // no dynamic segment, model hook always called - this.transitionTo('posts'); - // model passed in, so model hook not called - thePost = store.findRecord('post', 1); - this.transitionTo('post', thePost); - // integer passed in, model hook is called - this.transitionTo('post', 1); - // model id passed in, model hook is called - // useful for forcing the hook to execute - thePost = store.findRecord('post', 1); - this.transitionTo('post', thePost.id); - ``` - This hook follows the asynchronous/promise semantics - described in the documentation for `beforeModel`. In particular, - if a promise returned from `model` fails, the error will be - handled by the `error` hook on `Ember.Route`. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { - return this.store.findRecord('post', params.post_id); - } + return _emberGlimmerUtilsProcessArgs.gatherArgs(args, definition); + }; + + CurlyComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, callerSelfRef, hasBlock) { + var _this = this; + + _emberMetal.runInDebug(function () { + return _this._pushToDebugStack('component:' + definition.name, environment); }); - ``` - @method model - @param {Object} params the parameters extracted from the URL - @param {Transition} transition - @return {Object|Promise} the model for this route. If - a promise is returned, the transition will pause until - the promise resolves, and the resolved value of the promise - will be used as the model for this route. - @since 1.0.0 - @public - */ - model: function (params, transition) { - var name = undefined, - sawParams = undefined, - value = undefined; - var queryParams = _emberMetal.get(this, '_qp.map'); - for (var prop in params) { - if (prop === 'queryParams' || queryParams && prop in queryParams) { - continue; - } + var parentView = dynamicScope.view; - var match = prop.match(/^(.*)_id$/); - if (match) { - name = match[1]; - value = params[prop]; - } - sawParams = true; - } + var factory = definition.ComponentClass; - if (!name && sawParams) { - return _emberRuntime.copy(params); - } else if (!name) { - if (transition.resolveIndex < 1) { - return; - } + var processedArgs = _emberGlimmerUtilsProcessArgs.ComponentArgs.create(args); - var parentModel = transition.state.handlerInfos[transition.resolveIndex - 1].context; + var _processedArgs$value = processedArgs.value(); - return parentModel; - } + var props = _processedArgs$value.props; - return this.findModel(name, value); - }, + aliasIdToElementId(args, props); - /** - @private - @method deserialize - @param {Object} params the parameters extracted from the URL - @param {Transition} transition - @return {Object|Promise} the model for this route. - Router.js hook. - */ - deserialize: function (params, transition) { - return this.model(this.paramsFor(this.routeName), transition); - }, + props.parentView = parentView; + props[_emberGlimmerComponent.HAS_BLOCK] = hasBlock; - /** - @method findModel - @param {String} type the model type - @param {Object} value the value passed to find - @private - */ - findModel: function () { - var store = _emberMetal.get(this, 'store'); - return store.find.apply(store, arguments); - }, + props._targetObject = callerSelfRef.value(); - /** - Store property provides a hook for data persistence libraries to inject themselves. - By default, this store property provides the exact same functionality previously - in the model hook. - Currently, the required interface is: - `store.find(modelName, findArguments)` - @method store - @param {Object} store - @private - */ - store: _emberMetal.computed(function () { - var owner = _emberUtils.getOwner(this); - var routeName = this.routeName; - var namespace = _emberMetal.get(this, 'router.namespace'); + var component = factory.create(props); - return { - find: function (name, value) { - var modelClass = owner._lookupFactory('model:' + name); + var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - _emberMetal.assert('You used the dynamic segment ' + name + '_id in your route ' + routeName + ', but ' + namespace + '.' + _emberRuntime.String.classify(name) + ' did not exist and you did not override your route\'s `model` hook.', !!modelClass); + dynamicScope.view = component; - if (!modelClass) { - return; - } + if (parentView !== null) { + parentView.appendChild(component); + } + + // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components + if (component.tagName === '') { + if (environment.isInteractive) { + component.trigger('willRender'); + } - _emberMetal.assert(_emberRuntime.String.classify(name) + ' has no method `find`.', typeof modelClass.find === 'function'); + component._transitionTo('hasElement'); - return modelClass.find(value); + if (environment.isInteractive) { + component.trigger('willInsertElement'); } - }; - }), + } - /** - A hook you can implement to convert the route's model into parameters - for the URL. - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { - // the server returns `{ id: 12 }` - return Ember.$.getJSON('/posts/' + params.post_id); - }, - serialize(model) { - // this will make the URL `/posts/12` - return { post_id: model.id }; - } - }); - ``` - The default `serialize` method will insert the model's `id` into the - route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'. - If the route has multiple dynamic segments or does not contain '_id', `serialize` - will return `Ember.getProperties(model, params)` - This method is called when `transitionTo` is called with a context - in order to populate the URL. - @method serialize - @param {Object} model the routes model - @param {Array} params an Array of parameter names for the current - route (in the example, `['post_id']`. - @return {Object} the serialized parameters - @since 1.0.0 - @public - */ - serialize: defaultSerialize, + var bucket = new ComponentStateBucket(environment, component, processedArgs, finalizer); - /** - A hook you can use to setup the controller for the current route. - This method is called with the controller for the current route and the - model supplied by the `model` hook. - By default, the `setupController` hook sets the `model` property of - the controller to the `model`. - If you implement the `setupController` hook in your Route, it will - prevent this default behavior. If you want to preserve that behavior - when implementing your `setupController` function, make sure to call - `_super`: - ```app/routes/photos.js - import Ember from 'ebmer'; - export default Ember.Route.extend({ - model() { - return this.store.findAll('photo'); - }, - setupController(controller, model) { - // Call _super for default behavior - this._super(controller, model); - // Implement your custom setup after - this.controllerFor('application').set('showingPhotos', true); - } - }); - ``` - The provided controller will be one resolved based on the name - of this route. - If no explicit controller is defined, Ember will automatically create one. - As an example, consider the router: - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - For the `post` route, a controller named `App.PostController` would - be used if it is defined. If it is not defined, a basic `Ember.Controller` - instance would be used. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, model) { - controller.set('model', model); - } - }); - ``` - @method setupController - @param {Controller} controller instance - @param {Object} model - @since 1.0.0 - @public - */ - setupController: function (controller, context, transition) { - if (controller && context !== undefined) { - _emberMetal.set(controller, 'model', context); + if (args.named.has('class')) { + bucket.classRef = args.named.get('class'); } - }, - /** - Returns the resolved model of the current route, or a parent (or any ancestor) - route in a route hierarchy. - The controller instance must already have been created, either through entering the - associated route or using `generateController`. - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { - this._super(controller, post); - this.controllerFor('posts').set('currentPost', post); - } - }); - ``` - @method controllerFor - @param {String} name the name of the route or controller - @return {Ember.Controller} - @since 1.0.0 - @public - */ - controllerFor: function (name, _skipAssert) { - var owner = _emberUtils.getOwner(this); - var route = owner.lookup('route:' + name); - var controller = undefined; + processComponentInitializationAssertions(component, props); - if (route && route.controllerName) { - name = route.controllerName; + if (environment.isInteractive && component.tagName !== '') { + component.trigger('willRender'); } - controller = owner.lookup('controller:' + name); + return bucket; + }; - // NOTE: We're specifically checking that skipAssert is true, because according - // to the old API the second parameter was model. We do not want people who - // passed a model to skip the assertion. - _emberMetal.assert('The controller named \'' + name + '\' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.', controller || _skipAssert === true); + CurlyComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + var template = definition.template; + if (!template) { + var component = bucket.component; - return controller; - }, + template = this.templateFor(component, env); + } + return env.getCompiledBlock(CurlyComponentLayoutCompiler, template); + }; - /** - Generates a controller for a route. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { - this._super(controller, post); - this.generateController('posts'); + CurlyComponentManager.prototype.templateFor = function templateFor(component, env) { + var Template = _emberMetal.get(component, 'layout'); + var owner = component[_emberUtils.OWNER]; + if (Template) { + return env.getTemplate(Template, owner); + } + var layoutName = _emberMetal.get(component, 'layoutName'); + if (layoutName) { + var template = owner.lookup('template:' + layoutName); + if (template) { + return template; } - }); - ``` - @method generateController - @param {String} name the name of the controller - @private - */ - generateController: function (name) { - var owner = _emberUtils.getOwner(this); + } + return owner.lookup(DEFAULT_LAYOUT); + }; - return _emberRoutingSystemGenerate_controller.default(owner, name); - }, + CurlyComponentManager.prototype.getSelf = function getSelf(_ref) { + var component = _ref.component; - /** - Returns the resolved model of a parent (or any ancestor) route - in a route hierarchy. During a transition, all routes - must resolve a model object, and if a route - needs access to a parent route's model in order to - resolve a model (or just reuse the model from a parent), - it can call `this.modelFor(theNameOfParentRoute)` to - retrieve it. If the ancestor route's model was a promise, - its resolved result is returned. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/post/:post_id' }, function() { - this.route('comments', { resetNamespace: true }); - }); - }); - export default Router; - ``` - ```app/routes/comments.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { - this.set('post', this.modelFor('post')); - } - }); - ``` - @method modelFor - @param {String} name the name of the route - @return {Object} the model object - @since 1.0.0 - @public - */ - modelFor: function (_name) { - var name = undefined; - var owner = _emberUtils.getOwner(this); + return component[_emberGlimmerComponent.ROOT_REF]; + }; - // Only change the route name when there is an active transition. - // Otherwise, use the passed in route name. - if (owner.routable && this.router && this.router.router.activeTransition) { - name = getEngineRouteName(owner, _name); + CurlyComponentManager.prototype.didCreateElement = function didCreateElement(_ref2, element, operations) { + var component = _ref2.component; + var classRef = _ref2.classRef; + var environment = _ref2.environment; + + _emberViews.setViewElement(component, element); + + var attributeBindings = component.attributeBindings; + var classNames = component.classNames; + var classNameBindings = component.classNameBindings; + + if (attributeBindings && attributeBindings.length) { + applyAttributeBindings(element, attributeBindings, component, operations); } else { - name = _name; + operations.addStaticAttribute(element, 'id', component.elementId); + _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); } - var route = _emberUtils.getOwner(this).lookup('route:' + name); - var transition = this.router ? this.router.router.activeTransition : null; + if (classRef) { + operations.addDynamicAttribute(element, 'class', classRef); + } - // If we are mid-transition, we want to try and look up - // resolved parent contexts on the current transitionEvent. - if (transition) { - var modelLookupName = route && route.routeName || name; - if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { - return transition.resolvedModels[modelLookupName]; - } + if (classNames && classNames.length) { + classNames.forEach(function (name) { + operations.addStaticAttribute(element, 'class', name); + }); } - return route && route.currentModel; - }, + if (classNameBindings && classNameBindings.length) { + classNameBindings.forEach(function (binding) { + _emberGlimmerUtilsBindings.ClassNameBinding.install(element, component, binding, operations); + }); + } - /** - A hook you can use to render the template for the current route. - This method is called with the controller for the current route and the - model supplied by the `model` hook. By default, it renders the route's - template, configured with the controller for the route. - This method can be overridden to set up and render additional or - alternative templates. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model) { - let favController = this.controllerFor('favoritePost'); - // Render the `favoritePost` template into - // the outlet `posts`, and display the `favoritePost` - // controller. - this.render('favoritePost', { - outlet: 'posts', - controller: favController - }); - } - }); - ``` - @method renderTemplate - @param {Object} controller the route's controller - @param {Object} model the route's model - @since 1.0.0 - @public - */ - renderTemplate: function (controller, model) { - this.render(); - }, + component._transitionTo('hasElement'); - /** - `render` is used to render a template into a region of another template - (indicated by an `{{outlet}}`). `render` is used both during the entry - phase of routing (via the `renderTemplate` hook) and later in response to - user interaction. - For example, given the following minimal router and templates: - ```app/router.js - // ... - Router.map(function() { - this.route('photos'); - }); - export default Router; - ``` - ```handlebars - -
    - {{outlet "anOutletName"}} -
    - ``` - ```handlebars - -

    Photos

    - ``` - You can render `photos.hbs` into the `"anOutletName"` outlet of - `application.hbs` by calling `render`: - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { - this.render('photos', { - into: 'application', - outlet: 'anOutletName' - }) - } - }); - ``` - `render` additionally allows you to supply which `controller` and - `model` objects should be loaded and associated with the rendered template. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model){ - this.render('posts', { // the template to render, referenced by name - into: 'application', // the template to render into, referenced by name - outlet: 'anOutletName', // the outlet inside `options.template` to render into. - controller: 'someControllerName', // the controller to use for this template, referenced by name - model: model // the model to set on `options.controller`. - }) - } - }); - ``` - The string values provided for the template name, and controller - will eventually pass through to the resolver for lookup. See - Ember.Resolver for how these are mapped to JavaScript objects in your - application. The template to render into needs to be related to either the - current route or one of its ancestors. - Not all options need to be passed to `render`. Default values will be used - based on the name of the route specified in the router or the Route's - `controllerName` and `templateName` properties. - For example: - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { - this.render(); // all defaults apply - } + if (environment.isInteractive) { + component.trigger('willInsertElement'); + } + }; + + CurlyComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket, bounds) { + var _this2 = this; + + bucket.component[_emberGlimmerComponent.BOUNDS] = bounds; + bucket.finalize(); + + _emberMetal.runInDebug(function () { + return _this2.debugStack.pop(); }); - ``` - The name of the route, defined by the router, is `post`. - The following equivalent default options will be applied when - the Route calls `render`: - ```javascript - this.render('post', { // the template name associated with 'post' Route - into: 'application', // the parent route to 'post' Route - outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, - controller: 'post', // the controller associated with the 'post' Route - }) - ``` - By default the controller's `model` will be the route's model, so it does not - need to be passed unless you wish to change which model is being used. - @method render - @param {String} name the name of the template to render - @param {Object} [options] the options - @param {String} [options.into] the template to render into, - referenced by name. Defaults to the parent template - @param {String} [options.outlet] the outlet inside `options.template` to render into. - Defaults to 'main' - @param {String|Object} [options.controller] the controller to use for this template, - referenced by name or as a controller instance. Defaults to the Route's paired controller - @param {Object} [options.model] the model object to set on `options.controller`. - Defaults to the return value of the Route's model hook - @since 1.0.0 - @public - */ - render: function (_name, options) { - _emberMetal.assert('The name in the given arguments is undefined', arguments.length > 0 ? !_emberMetal.isNone(arguments[0]) : true); + }; - var namePassed = typeof _name === 'string' && !!_name; - var isDefaultRender = arguments.length === 0 || _emberMetal.isEmpty(arguments[0]); - var name = undefined; + CurlyComponentManager.prototype.getTag = function getTag(_ref3) { + var component = _ref3.component; - if (typeof _name === 'object' && !options) { - name = this.templateName || this.routeName; - options = _name; - } else { - name = _name; + return component[_emberGlimmerComponent.DIRTY_TAG]; + }; + + CurlyComponentManager.prototype.didCreate = function didCreate(_ref4) { + var component = _ref4.component; + var environment = _ref4.environment; + + if (environment.isInteractive) { + component._transitionTo('inDOM'); + component.trigger('didInsertElement'); + component.trigger('didRender'); } + }; - var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); - this.connections.push(renderOptions); - _emberMetal.run.once(this.router, '_setOutlets'); - }, + CurlyComponentManager.prototype.update = function update(bucket, _, dynamicScope) { + var _this3 = this; - /** - Disconnects a view that has been rendered into an outlet. - You may pass any or all of the following options to `disconnectOutlet`: - * `outlet`: the name of the outlet to clear (default: 'main') - * `parentView`: the name of the view containing the outlet to clear - (default: the view rendered by the parent route) - Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - this.render(evt.modalName, { - outlet: 'modal', - into: 'application' - }); - }, - hideModal(evt) { - this.disconnectOutlet({ - outlet: 'modal', - parentView: 'application' - }); - } - } - }); - ``` - Alternatively, you can pass the `outlet` name directly as a string. - Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - // ... - }, - hideModal(evt) { - this.disconnectOutlet('modal'); - } - } + var component = bucket.component; + var args = bucket.args; + var argsRevision = bucket.argsRevision; + var environment = bucket.environment; + + _emberMetal.runInDebug(function () { + return _this3._pushToDebugStack(component._debugContainerKey, environment); }); - @method disconnectOutlet - @param {Object|String} options the options hash or outlet name - @since 1.0.0 - @public - */ - disconnectOutlet: function (options) { - var outletName = undefined; - var parentView = undefined; - if (!options || typeof options === 'string') { - outletName = options; - } else { - outletName = options.outlet; - parentView = options.parentView; - if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { - throw new _emberMetal.Error('You passed undefined as the outlet name.'); - } - } - parentView = parentView && parentView.replace(/\//g, '.'); - outletName = outletName || 'main'; - this._disconnectOutlet(outletName, parentView); - for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { - // This non-local state munging is sadly necessary to maintain - // backward compatibility with our existing semantics, which allow - // any route to disconnectOutlet things originally rendered by any - // other route. This should all get cut in 2.0. - this.router.router.currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); + bucket.finalizer = _emberMetal._instrumentStart('render.component', rerenderInstrumentDetails, component); + + if (!args.tag.validate(argsRevision)) { + var _args$value = args.value(); + + var attrs = _args$value.attrs; + var props = _args$value.props; + + bucket.argsRevision = args.tag.value(); + + var oldAttrs = component.attrs; + var newAttrs = attrs; + + component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = true; + component.setProperties(props); + component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = false; + + _emberViews.dispatchLifeCycleHook(component, 'didUpdateAttrs', oldAttrs, newAttrs); + _emberViews.dispatchLifeCycleHook(component, 'didReceiveAttrs', oldAttrs, newAttrs); } - }, - _disconnectOutlet: function (outletName, parentView) { - var parent = parentRoute(this); - if (parent && parentView === parent.routeName) { - parentView = undefined; - } - for (var i = 0; i < this.connections.length; i++) { - var connection = this.connections[i]; - if (connection.outlet === outletName && connection.into === parentView) { - // This neuters the disconnected outlet such that it doesn't - // render anything, but it leaves an entry in the outlet - // hierarchy so that any existing other renders that target it - // don't suddenly blow up. They will still stick themselves - // into its outlets, which won't render anywhere. All of this - // statefulness should get the machete in 2.0. - this.connections[i] = { - owner: connection.owner, - into: connection.into, - outlet: connection.outlet, - name: connection.name, - controller: undefined, - template: undefined, - ViewClass: undefined - }; - _emberMetal.run.once(this.router, '_setOutlets'); - } + if (environment.isInteractive) { + component.trigger('willUpdate'); + component.trigger('willRender'); } - }, + }; - willDestroy: function () { - this.teardownViews(); - }, + CurlyComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) { + var _this4 = this; - /** - @private - @method teardownViews - */ - teardownViews: function () { - if (this.connections && this.connections.length > 0) { - this.connections = []; - _emberMetal.run.once(this.router, '_setOutlets'); + bucket.finalize(); + + _emberMetal.runInDebug(function () { + return _this4.debugStack.pop(); + }); + }; + + CurlyComponentManager.prototype.didUpdate = function didUpdate(_ref5) { + var component = _ref5.component; + var environment = _ref5.environment; + + if (environment.isInteractive) { + component.trigger('didUpdate'); + component.trigger('didRender'); } - } - }); + }; - _emberRuntime.deprecateUnderscoreActions(Route); + CurlyComponentManager.prototype.getDestructor = function getDestructor(stateBucket) { + return stateBucket; + }; - Route.reopenClass({ - isRouteFactory: true - }); + return CurlyComponentManager; + })(_emberGlimmerSyntaxAbstractManager.default); - function parentRoute(route) { - var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); - return handlerInfo && handlerInfo.handler; - } + var MANAGER = new CurlyComponentManager(); - function handlerInfoFor(route, handlerInfos, _offset) { - if (!handlerInfos) { - return; - } + var TopComponentManager = (function (_CurlyComponentManager) { +babelHelpers.inherits(TopComponentManager, _CurlyComponentManager); - var offset = _offset || 0; - var current = undefined; - for (var i = 0; i < handlerInfos.length; i++) { - current = handlerInfos[i].handler; - if (current === route) { - return handlerInfos[i + offset]; - } + function TopComponentManager() { +babelHelpers.classCallCheck(this, TopComponentManager); + + _CurlyComponentManager.apply(this, arguments); } - } - function buildRenderOptions(route, namePassed, isDefaultRender, _name, options) { - var into = options && options.into && options.into.replace(/\//g, '.'); - var outlet = options && options.outlet || 'main'; + TopComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, currentScope, hasBlock) { + var _this5 = this; - var name = undefined, - templateName = undefined; - if (_name) { - name = _name.replace(/\//g, '.'); - templateName = name; - } else { - name = route.routeName; - templateName = route.templateName || name; - } + var component = definition.ComponentClass.create(); - var owner = _emberUtils.getOwner(route); - var controller = options && options.controller; - if (!controller) { - if (namePassed) { - controller = owner.lookup('controller:' + name) || route.controllerName || route.routeName; - } else { - controller = route.controllerName || owner.lookup('controller:' + name); - } - } + _emberMetal.runInDebug(function () { + return _this5._pushToDebugStack(component._debugContainerKey, environment); + }); - if (typeof controller === 'string') { - var controllerName = controller; - controller = owner.lookup('controller:' + controllerName); - if (!controller) { - throw new _emberMetal.Error('You passed `controller: \'' + controllerName + '\'` into the `render` method, but no such controller could be found.'); - } - } + var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { - throw new _emberMetal.Error('You passed undefined as the outlet name.'); - } + dynamicScope.view = component; - if (options && options.model) { - controller.set('model', options.model); - } + // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components + if (component.tagName === '') { + if (environment.isInteractive) { + component.trigger('willRender'); + } - var template = owner.lookup('template:' + templateName); + component._transitionTo('hasElement'); - var parent = undefined; - if (into && (parent = parentRoute(route)) && into === parent.routeName) { - into = undefined; - } + if (environment.isInteractive) { + component.trigger('willInsertElement'); + } + } - var renderOptions = { - owner: owner, - into: into, - outlet: outlet, - name: name, - controller: controller, - template: template || route._topLevelViewTemplate, - ViewClass: undefined + processComponentInitializationAssertions(component, {}); + + return new ComponentStateBucket(environment, component, args, finalizer); }; - _emberMetal.assert('Could not find "' + name + '" template, view, or component.', isDefaultRender || template); + return TopComponentManager; + })(CurlyComponentManager); - var LOG_VIEW_LOOKUPS = _emberMetal.get(route.router, 'namespace.LOG_VIEW_LOOKUPS'); - if (LOG_VIEW_LOOKUPS && !template) { - _emberMetal.info('Could not find "' + name + '" template. Nothing will be rendered', { fullName: 'template:' + name }); - } + var ROOT_MANAGER = new TopComponentManager(); - return renderOptions; + function tagName(vm) { + var tagName = vm.dynamicScope().view.tagName; + + return _glimmerRuntime.PrimitiveReference.create(tagName === '' ? null : tagName || 'div'); } - function getFullQueryParams(router, state) { - if (state.fullQueryParams) { - return state.fullQueryParams; + function ariaRole(vm) { + return vm.getSelf().get('ariaRole'); + } + + var CurlyComponentDefinition = (function (_ComponentDefinition) { +babelHelpers.inherits(CurlyComponentDefinition, _ComponentDefinition); + + function CurlyComponentDefinition(name, ComponentClass, template, args) { +babelHelpers.classCallCheck(this, CurlyComponentDefinition); + + _ComponentDefinition.call(this, name, MANAGER, ComponentClass); + this.template = template; + this.args = args; } - state.fullQueryParams = {}; - _emberUtils.assign(state.fullQueryParams, state.queryParams); + return CurlyComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - router._deserializeQueryParams(state.handlerInfos, state.fullQueryParams); - return state.fullQueryParams; - } + exports.CurlyComponentDefinition = CurlyComponentDefinition; - function getQueryParamsFor(route, state) { - state.queryParamsFor = state.queryParamsFor || {}; - var name = route.fullRouteName; + var RootComponentDefinition = (function (_ComponentDefinition2) { +babelHelpers.inherits(RootComponentDefinition, _ComponentDefinition2); - if (state.queryParamsFor[name]) { - return state.queryParamsFor[name]; + function RootComponentDefinition(instance) { +babelHelpers.classCallCheck(this, RootComponentDefinition); + + _ComponentDefinition2.call(this, '-root', ROOT_MANAGER, { + class: instance.constructor, + create: function () { + return instance; + } + }); + this.template = undefined; + this.args = undefined; } - var fullQueryParams = getFullQueryParams(route.router, state); + return RootComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - var params = state.queryParamsFor[name] = {}; + exports.RootComponentDefinition = RootComponentDefinition; - // Copy over all the query params for this route/controller into params hash. - var qpMeta = _emberMetal.get(route, '_qp'); - var qps = qpMeta.qps; - for (var i = 0; i < qps.length; ++i) { - // Put deserialized qp on params hash. - var qp = qps[i]; + var CurlyComponentLayoutCompiler = (function () { + function CurlyComponentLayoutCompiler(template) { +babelHelpers.classCallCheck(this, CurlyComponentLayoutCompiler); - var qpValueWasPassedIn = (qp.prop in fullQueryParams); - params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.defaultValue); + this.template = template; } - return params; + CurlyComponentLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + builder.tag.dynamic(tagName); + builder.attrs.dynamic('role', ariaRole); + builder.attrs.static('class', 'ember-view'); + }; + + return CurlyComponentLayoutCompiler; + })(); + + CurlyComponentLayoutCompiler.id = 'curly'; +}); +enifed('ember-glimmer/syntax/dynamic-component', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal) { + 'use strict'; + + exports.closureComponentMacro = closureComponentMacro; + exports.dynamicComponentMacro = dynamicComponentMacro; + exports.blockComponentMacro = blockComponentMacro; + exports.inlineComponentMacro = inlineComponentMacro; + + function dynamicComponentFor(vm, symbolTable) { + var env = vm.env; + var args = vm.getArgs(); + var nameRef = args.positional.at(0); + + return new DynamicComponentReference({ nameRef: nameRef, env: env, symbolTable: symbolTable }); } - function copyDefaultValue(value) { - if (Array.isArray(value)) { - return _emberRuntime.A(value.slice()); - } - return value; + function closureComponentMacro(path, params, hash, _default, inverse, builder) { + var definitionArgs = [[['get', path]], hash, _default, inverse]; + var args = [params, hash, _default, inverse]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; } - /* - Merges all query parameters from a controller with those from - a route, returning a new object and avoiding any mutations to - the existing objects. - */ - function mergeEachQueryParams(controllerQP, routeQP) { - var keysAlreadyMergedOrSkippable = undefined; - var qps = {}; + function dynamicComponentMacro(params, hash, _default, inverse, builder) { + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - keysAlreadyMergedOrSkippable = { - defaultValue: true, - type: true, - scope: true, - as: true - }; + function blockComponentMacro(sexp, builder) { + var params = sexp[2]; + var hash = sexp[3]; + var _default = sexp[4]; + var inverse = sexp[5]; - // first loop over all controller qps, merging them with any matching route qps - // into a new empty object to avoid mutating. - for (var cqpName in controllerQP) { - if (!controllerQP.hasOwnProperty(cqpName)) { - continue; - } + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, _default, inverse]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - var newControllerParameterConfiguration = {}; - _emberUtils.assign(newControllerParameterConfiguration, controllerQP[cqpName]); - _emberUtils.assign(newControllerParameterConfiguration, routeQP[cqpName]); + function inlineComponentMacro(path, params, hash, builder) { + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - qps[cqpName] = newControllerParameterConfiguration; + var DynamicComponentReference = (function () { + function DynamicComponentReference(_ref) { + var nameRef = _ref.nameRef; + var env = _ref.env; + var symbolTable = _ref.symbolTable; + var args = _ref.args; + babelHelpers.classCallCheck(this, DynamicComponentReference); - // allows us to skip this QP when we check route QPs. - keysAlreadyMergedOrSkippable[cqpName] = true; + this.tag = nameRef.tag; + this.nameRef = nameRef; + this.env = env; + this.symbolTable = symbolTable; + this.args = args; } - // loop over all route qps, skipping those that were merged in the first pass - // because they also appear in controller qps - for (var rqpName in routeQP) { - if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { - continue; + DynamicComponentReference.prototype.value = function value() { + var env = this.env; + var nameRef = this.nameRef; + var symbolTable = this.symbolTable; + + var nameOrDef = nameRef.value(); + + if (typeof nameOrDef === 'string') { + var definition = env.getComponentDefinition([nameOrDef], symbolTable); + + _emberMetal.assert('Could not find component named "' + nameOrDef + '" (no component or template with that name was found)', definition); + + return definition; + } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { + return nameOrDef; + } else { + return null; } + }; - var newRouteParameterConfiguration = {}; - _emberUtils.assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); - qps[rqpName] = newRouteParameterConfiguration; - } + DynamicComponentReference.prototype.get = function get() { + return _glimmerReference.UNDEFINED_REFERENCE; + }; - return qps; + return DynamicComponentReference; + })(); +}); +enifed('ember-glimmer/syntax/input', ['exports', 'ember-metal', 'ember-glimmer/utils/bindings', 'ember-glimmer/syntax/dynamic-component'], function (exports, _emberMetal, _emberGlimmerUtilsBindings, _emberGlimmerSyntaxDynamicComponent) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; + + exports.inputMacro = inputMacro; + + function buildTextFieldSyntax(params, hash, builder) { + var definition = builder.env.getComponentDefinition(['-text-field'], builder.symbolTable); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; } - function addQueryParamsObservers(controller, propNames) { - propNames.forEach(function (prop) { - controller.addObserver(prop + '.[]', controller, controller._qpChanged); + /** + The `{{input}}` helper lets you create an HTML `` component. + It causes an `Ember.TextField` component to be rendered. For more info, + see the [Ember.TextField](/api/classes/Ember.TextField.html) docs and + the [templates guide](http://emberjs.com/guides/templates/input-helpers/). + + ```handlebars + {{input value="987"}} + ``` + + renders as: + + ```HTML + + ``` + + ### Text field + + If no `type` option is specified, a default of type 'text' is used. + Many of the standard HTML attributes may be passed to this helper. + + + + + + + + + + + +
    `readonly``required``autofocus`
    `value``placeholder``disabled`
    `size``tabindex``maxlength`
    `name``min``max`
    `pattern``accept``autocomplete`
    `autosave``formaction``formenctype`
    `formmethod``formnovalidate``formtarget`
    `height``inputmode``multiple`
    `step``width``form`
    `selectionDirection``spellcheck` 
    + When set to a quoted string, these values will be directly applied to the HTML + element. When left unquoted, these values will be bound to a property on the + template's current rendering context (most typically a controller instance). + A very common use of this helper is to bind the `value` of an input to an Object's attribute: + + ```handlebars + Search: + {{input value=searchWord}} + ``` + + In this example, the inital value in the `` will be set to the value of `searchWord`. + If the user changes the text, the value of `searchWord` will also be updated. + + ### Actions + + The helper can send multiple actions based on user events. + The action property defines the action which is sent when + the user presses the return key. + + ```handlebars + {{input action="submit"}} + ``` + + The helper allows some user events to send actions. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + * `key-up` + + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. + + ```handlebars + {{input focus-out="alertMessage"}} + ``` + See more about [Text Support Actions](/api/classes/Ember.TextField.html) + + ### Extending `Ember.TextField` + + Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing + arguments from the helper to `Ember.TextField`'s `create` method. You can extend the + capabilities of text inputs in your applications by reopening this class. For example, + if you are building a Bootstrap project where `data-*` attributes are used, you + can add one to the `TextField`'s `attributeBindings` property: + + ```javascript + Ember.TextField.reopen({ + attributeBindings: ['data-error'] }); - } + ``` + + Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` + itself extends `Ember.Component`. Expect isolated component semantics, not + legacy 1.x view semantics (like `controller` being present). + See more about [Ember components](/api/classes/Ember.Component.html) + + ### Checkbox + + Checkboxes are special forms of the `{{input}}` helper. To create a ``: + + ```handlebars + Emberize Everything: + {{input type="checkbox" name="isEmberized" checked=isEmberized}} + ``` + + This will bind checked state of this checkbox to the value of `isEmberized` -- if either one changes, + it will be reflected in the other. + + The following HTML attributes can be set via the helper: + + * `checked` + * `disabled` + * `tabindex` + * `indeterminate` + * `name` + * `autofocus` + * `form` + + ### Extending `Ember.Checkbox` + + Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing + arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the + capablilties of checkbox inputs in your applications by reopening this class. For example, + if you wanted to add a css class to all checkboxes in your application: + + ```javascript + Ember.Checkbox.reopen({ + classNames: ['my-app-checkbox'] + }); + ``` + + @method input + @for Ember.Templates.helpers + @param {Hash} options + @public + */ - function getEngineRouteName(engine, routeName) { - if (engine.routable) { - var prefix = engine.mountPoint; + function inputMacro(path, params, hash, builder) { + var keys = undefined; + var values = undefined; + var typeIndex = -1; + var valueIndex = -1; - if (routeName === 'application') { - return prefix; - } else { - return prefix + '.' + routeName; - } + if (hash) { + keys = hash[0]; + values = hash[1]; + typeIndex = keys.indexOf('type'); + valueIndex = keys.indexOf('value'); } - return routeName; - } + if (!params) { + params = []; + } - exports.default = Route; -}); -enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-routing/system/route', 'ember-routing/system/dsl', 'ember-routing/location/api', 'ember-routing/utils', 'ember-routing/system/router_state', 'router'], function (exports, _emberUtils, _emberConsole, _emberMetal, _emberRuntime, _emberRoutingSystemRoute, _emberRoutingSystemDsl, _emberRoutingLocationApi, _emberRoutingUtils, _emberRoutingSystemRouter_state, _router4) { - 'use strict'; + if (typeIndex > -1) { + var typeArg = values[typeIndex]; + if (!Array.isArray(typeArg)) { + if (typeArg === 'checkbox') { + _emberMetal.assert('{{input type=\'checkbox\'}} does not support setting `value=someBooleanValue`; ' + 'you must use `checked=someBooleanValue` instead.', valueIndex === -1); - exports.triggerEvent = triggerEvent; + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); - function K() { - return this; + var definition = builder.env.getComponentDefinition(['-checkbox'], builder.symbolTable); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; + } else { + return buildTextFieldSyntax(params, hash, builder); + } + } + } else { + return buildTextFieldSyntax(params, hash, builder); + } + + return _emberGlimmerSyntaxDynamicComponent.dynamicComponentMacro(params, hash, null, null, builder); } +}); +enifed('ember-glimmer/syntax/mount', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet, _container, _emberGlimmerSyntaxAbstractManager) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var slice = Array.prototype.slice; + exports.mountMacro = mountMacro; /** - The `Ember.Router` class manages the application state and URLs. Refer to - the [routing guide](http://emberjs.com/guides/routing/) for documentation. + The `{{mount}}` helper lets you embed a routeless engine in a template. + Mounting an engine will cause an instance to be booted and its `application` + template to be rendered. - @class Router - @namespace Ember - @extends Ember.Object - @uses Ember.Evented + For example, the following template mounts the `ember-chat` engine: + + ```handlebars + {{! application.hbs }} + {{mount "ember-chat"}} + ``` + + Currently, the engine name is the only argument that can be passed to + `{{mount}}`. + + @method mount + @for Ember.Templates.helpers + @category ember-application-engines @public */ - var EmberRouter = _emberRuntime.Object.extend(_emberRuntime.Evented, { - /** - The `location` property determines the type of URL's that your - application will use. - The following location types are currently available: - * `history` - use the browser's history API to make the URLs look just like any standard URL - * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new` - * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing) - * `auto` - use the best option based on browser capabilites: `history` if possible, then `hash` if possible, otherwise `none` - Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js` - @property location - @default 'hash' - @see {Ember.Location} - @public - */ - location: 'hash', - - /** - Represents the URL of the root of the application, often '/'. This prefix is - assumed on all routes defined on this router. - @property rootURL - @default '/' - @public - */ - rootURL: '/', - - _initRouterJs: function () { - var router = this.router = new _router4.default(); - router.triggerEvent = triggerEvent; - - router._triggerWillChangeContext = K; - router._triggerWillLeave = K; - var dslCallbacks = this.constructor.dslCallbacks || [K]; - var dsl = this._buildDSL(); + function mountMacro(path, params, hash, builder) { + _emberMetal.assert('You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.', params.length === 1 && hash === null); - dsl.route('application', { path: '/', resetNamespace: true, overrideNameAssertion: true }, function () { - for (var i = 0; i < dslCallbacks.length; i++) { - dslCallbacks[i].call(this); - } - }); + var name = params[0]; - if (_emberMetal.get(this, 'namespace.LOG_TRANSITIONS_INTERNAL')) { - router.log = _emberConsole.default.debug; - } + _emberMetal.assert('The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}.', typeof name === 'string'); - router.map(dsl.generate()); - }, + _emberMetal.assert('You used `{{mount \'' + name + '\'}}`, but the engine \'' + name + '\' can not be found.', builder.env.owner.hasRegistration('engine:' + name)); - _buildDSL: function () { - var moduleBasedResolver = this._hasModuleBasedResolver(); - var options = { - enableLoadingSubstates: !!moduleBasedResolver - }; + builder.component.static(new MountDefinition(name, builder.env), [params, hash, null, null], builder.symbolTable); + return true; + } - var owner = _emberUtils.getOwner(this); - var router = this; + var MountManager = (function (_AbstractManager) { + babelHelpers.inherits(MountManager, _AbstractManager); - options.resolveRouteMap = function (name) { - return owner._lookupFactory('route-map:' + name); - }; + function MountManager() { + babelHelpers.classCallCheck(this, MountManager); - options.addRouteForEngine = function (name, engineInfo) { - if (!router._engineInfoByRoute[name]) { - router._engineInfoByRoute[name] = engineInfo; - } - }; + _AbstractManager.apply(this, arguments); + } - return new _emberRoutingSystemDsl.default(null, options); - }, + MountManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - init: function () { - this._super.apply(this, arguments); + MountManager.prototype.create = function create(environment, _ref, args, dynamicScope) { + var name = _ref.name; + var env = _ref.env; - this._qpCache = new _emberUtils.EmptyObject(); - this._resetQueuedQueryParameterChanges(); - this._handledErrors = _emberUtils.dictionary(null); - this._engineInstances = new _emberUtils.EmptyObject(); - this._engineInfoByRoute = new _emberUtils.EmptyObject(); - }, + var _this = this; - /* - Resets all pending query paramter changes. - Called after transitioning to a new route - based on query parameter changes. - */ - _resetQueuedQueryParameterChanges: function () { - this._queuedQPChanges = {}; - }, + _emberMetal.runInDebug(function () { + return _this._pushEngineToDebugStack('engine:' + name, env); + }); - /** - Represents the current URL. - @method url - @return {String} The current URL. - @private - */ - url: _emberMetal.computed(function () { - return _emberMetal.get(this, 'location').getURL(); - }), + dynamicScope.outletState = _glimmerReference.UNDEFINED_REFERENCE; - _hasModuleBasedResolver: function () { - var owner = _emberUtils.getOwner(this); + var engine = env.owner.buildChildEngineInstance(name); - if (!owner) { - return false; - } + engine.boot(); - var resolver = owner.application && owner.application.__registry__ && owner.application.__registry__.resolver; + return { engine: engine }; + }; - if (!resolver) { - return false; - } + MountManager.prototype.layoutFor = function layoutFor(definition, _ref2, env) { + var engine = _ref2.engine; - return !!resolver.moduleBasedResolver; - }, + var template = engine.lookup('template:application'); + return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, template); + }; - /** - Initializes the current router instance and sets up the change handling - event listeners used by the instances `location` implementation. - A property named `initialURL` will be used to determine the initial URL. - If no value is found `/` will be used. - @method startRouting - @private - */ - startRouting: function () { - var initialURL = _emberMetal.get(this, 'initialURL'); + MountManager.prototype.getSelf = function getSelf(_ref3) { + var engine = _ref3.engine; - if (this.setupRouter()) { - if (typeof initialURL === 'undefined') { - initialURL = _emberMetal.get(this, 'location').getURL(); - } - var initialTransition = this.handleURL(initialURL); - if (initialTransition && initialTransition.error) { - throw initialTransition.error; - } - } - }, + var applicationFactory = engine[_container.FACTORY_FOR]('controller:application'); + var factory = applicationFactory || _emberRouting.generateControllerFactory(engine, 'application'); + return new _emberGlimmerUtilsReferences.RootReference(factory.create()); + }; - setupRouter: function () { - var _this = this; + MountManager.prototype.getTag = function getTag() { + return null; + }; - this._initRouterJs(); - this._setupLocation(); + MountManager.prototype.getDestructor = function getDestructor(_ref4) { + var engine = _ref4.engine; - var router = this.router; - var location = _emberMetal.get(this, 'location'); + return engine; + }; - // Allow the Location class to cancel the router setup while it refreshes - // the page - if (_emberMetal.get(location, 'cancelRouterSetup')) { - return false; - } + MountManager.prototype.didCreateElement = function didCreateElement() {}; - this._setupRouter(router, location); + MountManager.prototype.didRenderLayout = function didRenderLayout() { + var _this2 = this; - location.onUpdateURL(function (url) { - _this.handleURL(url); + _emberMetal.runInDebug(function () { + return _this2.debugStack.pop(); }); + }; - return true; - }, + MountManager.prototype.didCreate = function didCreate(state) {}; - /** - Handles updating the paths and notifying any listeners of the URL - change. - Triggers the router level `didTransition` hook. - For example, to notify google analytics when the route changes, - you could use this hook. (Note: requires also including GA scripts, etc.) - ```javascript - let Router = Ember.Router.extend({ - location: config.locationType, - didTransition: function() { - this._super(...arguments); - return ga('send', 'pageview', { - 'page': this.get('url'), - 'title': this.get('url') - }); - } - }); - ``` - @method didTransition - @public - @since 1.2.0 - */ - didTransition: function (infos) { - updatePaths(this); + MountManager.prototype.update = function update(state, args, dynamicScope) {}; - this._cancelSlowTransitionTimer(); + MountManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - this.notifyPropertyChange('url'); - this.set('currentState', this.targetState); + MountManager.prototype.didUpdate = function didUpdate(state) {}; - // Put this in the runloop so url will be accurate. Seems - // less surprising than didTransition being out of sync. - _emberMetal.run.once(this, this.trigger, 'didTransition'); + return MountManager; + })(_emberGlimmerSyntaxAbstractManager.default); - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Transitioned into \'' + EmberRouter._routePath(infos) + '\''); - } - }, + var MOUNT_MANAGER = new MountManager(); - _setOutlets: function () { - // This is triggered async during Ember.Route#willDestroy. - // If the router is also being destroyed we do not want to - // to create another this._toplevelView (and leak the renderer) - if (this.isDestroying || this.isDestroyed) { - return; - } + var MountDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(MountDefinition, _ComponentDefinition); - var handlerInfos = this.router.currentHandlerInfos; - var route = undefined; - var defaultParentState = undefined; - var liveRoutes = null; + function MountDefinition(name, env) { + babelHelpers.classCallCheck(this, MountDefinition); - if (!handlerInfos) { - return; - } + _ComponentDefinition.call(this, name, MOUNT_MANAGER, null); + this.env = env; + } - for (var i = 0; i < handlerInfos.length; i++) { - route = handlerInfos[i].handler; - var connections = route.connections; - var ownState = undefined; - for (var j = 0; j < connections.length; j++) { - var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); - liveRoutes = appended.liveRoutes; - if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { - ownState = appended.ownState; - } - } - if (connections.length === 0) { - ownState = representEmptyRoute(liveRoutes, defaultParentState, route); - } - defaultParentState = ownState; - } + return MountDefinition; + })(_glimmerRuntime.ComponentDefinition); +}); +enifed('ember-glimmer/syntax/outlet', ['exports', 'ember-utils', '@glimmer/runtime', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/abstract-manager', '@glimmer/reference'], function (exports, _emberUtils, _glimmerRuntime, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxAbstractManager, _glimmerReference) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - // when a transitionTo happens after the validation phase - // during the initial transition _setOutlets is called - // when no routes are active. However, it will get called - // again with the correct values during the next turn of - // the runloop - if (!liveRoutes) { - return; - } + exports.outletMacro = outletMacro; - if (!this._toplevelView) { - var owner = _emberUtils.getOwner(this); - var OutletView = owner._lookupFactory('view:-outlet'); - this._toplevelView = OutletView.create(); - this._toplevelView.setOutletState(liveRoutes); - var instance = owner.lookup('-application-instance:main'); - instance.didCreateRootView(this._toplevelView); - } else { - this._toplevelView.setOutletState(liveRoutes); - } - }, + function outletComponentFor(vm) { + var _vm$dynamicScope = vm.dynamicScope(); - /** - Handles notifying any listeners of an impending URL - change. - Triggers the router level `willTransition` hook. - @method willTransition - @public - @since 1.11.0 - */ - willTransition: function (oldInfos, newInfos, transition) { - _emberMetal.run.once(this, this.trigger, 'willTransition', transition); + var outletState = _vm$dynamicScope.outletState; - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Preparing to transition from \'' + EmberRouter._routePath(oldInfos) + '\' to \'' + EmberRouter._routePath(newInfos) + '\''); - } - }, + var args = vm.getArgs(); + var outletNameRef = undefined; + if (args.positional.length === 0) { + outletNameRef = new _glimmerReference.ConstReference('main'); + } else { + outletNameRef = args.positional.at(0); + } - handleURL: function (url) { - // Until we have an ember-idiomatic way of accessing #hashes, we need to - // remove it because router.js doesn't know how to handle it. - url = url.split(/#(.+)?/)[0]; - return this._doURLTransition('handleURL', url); - }, + return new OutletComponentReference(outletNameRef, outletState); + } - _doURLTransition: function (routerJsMethod, url) { - var transition = this.router[routerJsMethod](url || '/'); - didBeginTransition(transition, this); - return transition; - }, + /** + The `{{outlet}}` helper lets you specify where a child route will render in + your template. An important use of the `{{outlet}}` helper is in your + application's `application.hbs` file: + + ```handlebars + {{! app/templates/application.hbs }} + + {{my-header}} +
    + + {{outlet}} +
    + + {{my-footer}} + ``` + + See [templates guide](http://emberjs.com/guides/templates/the-application-template/) for + additional information on using `{{outlet}}` in `application.hbs`. + You may also specify a name for the `{{outlet}}`, which is useful when using more than one + `{{outlet}}` in a template: + + ```handlebars + {{outlet "menu"}} + {{outlet "sidebar"}} + {{outlet "main"}} + ``` + + Your routes can then render into a specific one of these `outlet`s by specifying the `outlet` + attribute in your `renderTemplate` function: + + ```javascript + // app/routes/menu.js + export default Ember.Route.extend({ + renderTemplate() { + this.render({ outlet: 'menu' }); + } + }); + ``` + + See the [routing guide](http://emberjs.com/guides/routing/rendering-a-template/) for more + information on how your `route` interacts with the `{{outlet}}` helper. + Note: Your content __will not render__ if there isn't an `{{outlet}}` for it. + + @method outlet + @param {String} [name] + @for Ember.Templates.helpers + @public + */ - /** - 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 - @public - */ - transitionTo: function () { - var queryParams = undefined; + function outletMacro(path, params, hash, builder) { + if (!params) { + params = []; + } + var definitionArgs = [params.slice(0, 1), null, null, null]; + builder.component.dynamic(definitionArgs, outletComponentFor, _glimmerRuntime.CompiledArgs.empty(), builder.symbolTable, null); + return true; + } - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + var OutletComponentReference = (function () { + function OutletComponentReference(outletNameRef, parentOutletStateRef) { + babelHelpers.classCallCheck(this, OutletComponentReference); - if (resemblesURL(args[0])) { - return this._doURLTransition('transitionTo', args[0]); - } + this.outletNameRef = outletNameRef; + this.parentOutletStateRef = parentOutletStateRef; + this.definition = null; + this.lastState = null; + var outletStateTag = this.outletStateTag = new _glimmerReference.UpdatableTag(parentOutletStateRef.tag); + this.tag = _glimmerReference.combine([outletStateTag.tag, outletNameRef.tag]); + } - var possibleQueryParams = args[args.length - 1]; - if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { - queryParams = args.pop().queryParams; - } else { - queryParams = {}; - } + OutletComponentReference.prototype.value = function value() { + var outletNameRef = this.outletNameRef; + var parentOutletStateRef = this.parentOutletStateRef; + var definition = this.definition; + var lastState = this.lastState; - var targetRouteName = args.shift(); - return this._doTransition(targetRouteName, args, queryParams); - }, + var outletName = outletNameRef.value(); + var outletStateRef = parentOutletStateRef.get('outlets').get(outletName); + var newState = this.lastState = outletStateRef.value(); - intermediateTransitionTo: function () { - var _router; + this.outletStateTag.update(outletStateRef.tag); - (_router = this.router).intermediateTransitionTo.apply(_router, arguments); + definition = revalidate(definition, lastState, newState); - updatePaths(this); + var hasTemplate = newState && newState.render.template; - var infos = this.router.currentHandlerInfos; - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Intermediate-transitioned into \'' + EmberRouter._routePath(infos) + '\''); + if (definition) { + return definition; + } else if (hasTemplate) { + return this.definition = new OutletComponentDefinition(outletName, newState.render.template); + } else { + return this.definition = null; } - }, - - replaceWith: function () { - return this.transitionTo.apply(this, arguments).method('replace'); - }, + }; - generate: function () { - var _router2; + return OutletComponentReference; + })(); - var url = (_router2 = this.router).generate.apply(_router2, arguments); - return this.location.formatURL(url); - }, + function revalidate(definition, lastState, newState) { + if (!lastState && !newState) { + return definition; + } - /** - Determines if the supplied route is currently active. - @method isActive - @param routeName - @return {Boolean} - @private - */ - isActive: function (routeName) { - var router = this.router; - return router.isActive.apply(router, arguments); - }, + if (!lastState && newState || lastState && !newState) { + return null; + } - /** - An alternative form of `isActive` that doesn't require - manual concatenation of the arguments into a single - array. - @method isActiveIntent - @param routeName - @param models - @param queryParams - @return {Boolean} - @private - @since 1.7.0 - */ - isActiveIntent: function (routeName, models, queryParams) { - return this.currentState.isActiveIntent(routeName, models, queryParams); - }, + if (newState.render.template === lastState.render.template && newState.render.controller === lastState.render.controller) { + return definition; + } - send: function (name, context) { - var _router3; + return null; + } - (_router3 = this.router).trigger.apply(_router3, arguments); - }, + function instrumentationPayload(_ref) { + var _ref$render = _ref.render; + var name = _ref$render.name; + var outlet = _ref$render.outlet; - /** - Does this router instance have the given route. - @method hasRoute - @return {Boolean} - @private - */ - hasRoute: function (route) { - return this.router.hasRoute(route); - }, + return { object: name + ':' + outlet }; + } - /** - Resets the state of the router by clearing the current route - handlers and deactivating them. - @private - @method reset - */ - reset: function () { - if (this.router) { - this.router.reset(); - } - }, + function NOOP() {} - willDestroy: function () { - if (this._toplevelView) { - this._toplevelView.destroy(); - this._toplevelView = null; - } + var StateBucket = (function () { + function StateBucket(outletState) { + babelHelpers.classCallCheck(this, StateBucket); - this._super.apply(this, arguments); + this.outletState = outletState; + this.instrument(); + } - this.reset(); + StateBucket.prototype.instrument = function instrument() { + this.finalizer = _emberMetal._instrumentStart('render.outlet', instrumentationPayload, this.outletState); + }; - var instances = this._engineInstances; - for (var _name in instances) { - for (var id in instances[_name]) { - _emberMetal.run(instances[_name][id], 'destroy'); - } - } - }, + StateBucket.prototype.finalize = function finalize() { + var finalizer = this.finalizer; - /* - Called when an active route's query parameter has changed. - These changes are batched into a runloop run and trigger - a single transition. - */ - _activeQPChanged: function (queryParameterName, newValue) { - this._queuedQPChanges[queryParameterName] = newValue; - _emberMetal.run.once(this, this._fireQueryParamTransition); - }, + finalizer(); + this.finalizer = NOOP; + }; - _updatingQPChanged: function (queryParameterName) { - if (!this._qpUpdates) { - this._qpUpdates = {}; - } - this._qpUpdates[queryParameterName] = true; - }, + return StateBucket; + })(); - /* - Triggers a transition to a route based on query parameter changes. - This is called once per runloop, to batch changes. - e.g. - if these methods are called in succession: - this._activeQPChanged('foo', '10'); - // results in _queuedQPChanges = { foo: '10' } - this._activeQPChanged('bar', false); - // results in _queuedQPChanges = { foo: '10', bar: false } - _queuedQPChanges will represent both of these changes - and the transition using `transitionTo` will be triggered - once. - */ - _fireQueryParamTransition: function () { - this.transitionTo({ queryParams: this._queuedQPChanges }); - this._resetQueuedQueryParameterChanges(); - }, + var OutletComponentManager = (function (_AbstractManager) { + babelHelpers.inherits(OutletComponentManager, _AbstractManager); - _setupLocation: function () { - var location = _emberMetal.get(this, 'location'); - var rootURL = _emberMetal.get(this, 'rootURL'); - var owner = _emberUtils.getOwner(this); + function OutletComponentManager() { + babelHelpers.classCallCheck(this, OutletComponentManager); - if ('string' === typeof location && owner) { - var resolvedLocation = owner.lookup('location:' + location); + _AbstractManager.apply(this, arguments); + } - if ('undefined' !== typeof resolvedLocation) { - location = _emberMetal.set(this, 'location', resolvedLocation); - } else { - // Allow for deprecated registration of custom location API's - var options = { - implementation: location - }; + OutletComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - location = _emberMetal.set(this, 'location', _emberRoutingLocationApi.default.create(options)); - } - } + OutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this = this; - if (location !== null && typeof location === 'object') { - if (rootURL) { - _emberMetal.set(location, 'rootURL', rootURL); - } + _emberMetal.runInDebug(function () { + return _this._pushToDebugStack('template:' + definition.template.meta.moduleName, environment); + }); - // Allow the location to do any feature detection, such as AutoLocation - // detecting history support. This gives it a chance to set its - // `cancelRouterSetup` property which aborts routing. - if (typeof location.detect === 'function') { - location.detect(); - } + var outletStateReference = dynamicScope.outletState = dynamicScope.outletState.get('outlets').get(definition.outletName); + var outletState = outletStateReference.value(); + return new StateBucket(outletState); + }; - // ensure that initState is called AFTER the rootURL is set on - // the location instance - if (typeof location.initState === 'function') { - location.initState(); - } - } - }, + OutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(OutletLayoutCompiler, definition.template); + }; - _getHandlerFunction: function () { - var _this2 = this; + OutletComponentManager.prototype.getSelf = function getSelf(_ref2) { + var outletState = _ref2.outletState; - var seen = new _emberUtils.EmptyObject(); - var owner = _emberUtils.getOwner(this); + return new _emberGlimmerUtilsReferences.RootReference(outletState.render.controller); + }; - return function (name) { - var routeName = name; - var routeOwner = owner; - var engineInfo = _this2._engineInfoByRoute[routeName]; + OutletComponentManager.prototype.getTag = function getTag() { + return null; + }; - if (engineInfo) { - var engineInstance = _this2._getEngineInstance(engineInfo); + OutletComponentManager.prototype.getDestructor = function getDestructor() { + return null; + }; - routeOwner = engineInstance; - routeName = engineInfo.localFullName; - } + OutletComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket) { + var _this2 = this; - var fullRouteName = 'route:' + routeName; + bucket.finalize(); - var handler = routeOwner.lookup(fullRouteName); + _emberMetal.runInDebug(function () { + return _this2.debugStack.pop(); + }); + }; - if (seen[name]) { - return handler; - } + OutletComponentManager.prototype.didCreateElement = function didCreateElement() {}; - seen[name] = true; + OutletComponentManager.prototype.didCreate = function didCreate(state) {}; - if (!handler) { - var DefaultRoute = routeOwner._lookupFactory('route:basic'); + OutletComponentManager.prototype.update = function update(bucket) {}; - routeOwner.register(fullRouteName, DefaultRoute.extend()); - handler = routeOwner.lookup(fullRouteName); + OutletComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) {}; - if (_emberMetal.get(_this2, 'namespace.LOG_ACTIVE_GENERATION')) { - _emberMetal.info('generated -> ' + fullRouteName, { fullName: fullRouteName }); - } - } + OutletComponentManager.prototype.didUpdate = function didUpdate(state) {}; - handler._setRouteName(routeName); - handler._populateQPMeta(); + return OutletComponentManager; + })(_emberGlimmerSyntaxAbstractManager.default); - if (engineInfo && !_emberRoutingSystemRoute.hasDefaultSerialize(handler)) { - throw new Error('Defining a custom serialize method on an Engine route is not supported.'); - } + var MANAGER = new OutletComponentManager(); - return handler; - }; - }, + var TopLevelOutletComponentManager = (function (_OutletComponentManager) { + babelHelpers.inherits(TopLevelOutletComponentManager, _OutletComponentManager); - _getSerializerFunction: function () { - var _this3 = this; + function TopLevelOutletComponentManager() { + babelHelpers.classCallCheck(this, TopLevelOutletComponentManager); - return function (name) { - var engineInfo = _this3._engineInfoByRoute[name]; + _OutletComponentManager.apply(this, arguments); + } - // If this is not an Engine route, we fall back to the handler for serialization - if (!engineInfo) { - return; - } + TopLevelOutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this3 = this; - return engineInfo.serializeMethod || _emberRoutingSystemRoute.defaultSerialize; - }; - }, + _emberMetal.runInDebug(function () { + return _this3._pushToDebugStack('template:' + definition.template.meta.moduleName, environment); + }); - _setupRouter: function (router, location) { - var lastURL = undefined; - var emberRouter = this; + return new StateBucket(dynamicScope.outletState.value()); + }; - router.getHandler = this._getHandlerFunction(); - router.getSerializer = this._getSerializerFunction(); + TopLevelOutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(TopLevelOutletLayoutCompiler, definition.template); + }; - var doUpdateURL = function () { - location.setURL(lastURL); - }; + return TopLevelOutletComponentManager; + })(OutletComponentManager); - router.updateURL = function (path) { - lastURL = path; - _emberMetal.run.once(doUpdateURL); - }; + var TOP_LEVEL_MANAGER = new TopLevelOutletComponentManager(); - if (location.replaceURL) { - (function () { - var doReplaceURL = function () { - location.replaceURL(lastURL); - }; + var TopLevelOutletComponentDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(TopLevelOutletComponentDefinition, _ComponentDefinition); - router.replaceURL = function (path) { - lastURL = path; - _emberMetal.run.once(doReplaceURL); - }; - })(); - } + function TopLevelOutletComponentDefinition(instance) { + babelHelpers.classCallCheck(this, TopLevelOutletComponentDefinition); - router.didTransition = function (infos) { - emberRouter.didTransition(infos); - }; + _ComponentDefinition.call(this, 'outlet', TOP_LEVEL_MANAGER, instance); + this.template = instance.template; + _emberUtils.generateGuid(this); + } - router.willTransition = function (oldInfos, newInfos, transition) { - emberRouter.willTransition(oldInfos, newInfos, transition); - }; - }, + return TopLevelOutletComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - /** - Serializes the given query params according to their QP meta information. - @private - @method _serializeQueryParams - @param {Arrray} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _serializeQueryParams: function (handlerInfos, queryParams) { - var _this4 = this; + exports.TopLevelOutletComponentDefinition = TopLevelOutletComponentDefinition; - forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { - if (qp) { - delete queryParams[key]; - queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); - } else if (value === undefined) { - return; // We don't serialize undefined values - } else { - queryParams[key] = _this4._serializeQueryParam(value, _emberRuntime.typeOf(value)); - } - }); - }, + var TopLevelOutletLayoutCompiler = (function () { + function TopLevelOutletLayoutCompiler(template) { + babelHelpers.classCallCheck(this, TopLevelOutletLayoutCompiler); - /** - Serializes the value of a query parameter based on a type - @private - @method _serializeQueryParam - @param {Object} value - @param {String} type - */ - _serializeQueryParam: function (value, type) { - if (type === 'array') { - return JSON.stringify(value); - } + this.template = template; + } - return '' + value; - }, + TopLevelOutletLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + builder.tag.static('div'); + builder.attrs.static('id', _emberUtils.guidFor(this)); + builder.attrs.static('class', 'ember-view'); + }; - /** - Deserializes the given query params according to their QP meta information. - @private - @method _deserializeQueryParams - @param {Array} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _deserializeQueryParams: function (handlerInfos, queryParams) { - forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { - // If we don't have QP meta info for a given key, then we do nothing - // because all values will be treated as strings - if (qp) { - delete queryParams[key]; - queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); - } - }); - }, + return TopLevelOutletLayoutCompiler; + })(); - /** - Deserializes the value of a query parameter based on a default type - @private - @method _deserializeQueryParam - @param {Object} value - @param {String} defaultType - */ - _deserializeQueryParam: function (value, defaultType) { - if (defaultType === 'boolean') { - return value === 'true' ? true : false; - } else if (defaultType === 'number') { - return Number(value).valueOf(); - } else if (defaultType === 'array') { - return _emberRuntime.A(JSON.parse(value)); - } + TopLevelOutletLayoutCompiler.id = 'top-level-outlet'; - return value; - }, + var OutletComponentDefinition = (function (_ComponentDefinition2) { + babelHelpers.inherits(OutletComponentDefinition, _ComponentDefinition2); - /** - Removes (prunes) any query params with default values from the given QP - object. Default values are determined from the QP meta information per key. - @private - @method _pruneDefaultQueryParamValues - @param {Array} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _pruneDefaultQueryParamValues: function (handlerInfos, queryParams) { - var qps = this._queryParamsFor(handlerInfos); - for (var key in queryParams) { - var qp = qps.map[key]; - if (qp && qp.serializedDefaultValue === queryParams[key]) { - delete queryParams[key]; - } - } - }, + function OutletComponentDefinition(outletName, template) { + babelHelpers.classCallCheck(this, OutletComponentDefinition); - _doTransition: function (_targetRouteName, models, _queryParams) { - var targetRouteName = _targetRouteName || _emberRoutingUtils.getActiveTargetName(this.router); - _emberMetal.assert('The route ' + targetRouteName + ' was not found', targetRouteName && this.router.hasRoute(targetRouteName)); + _ComponentDefinition2.call(this, 'outlet', MANAGER, null); + this.outletName = outletName; + this.template = template; + _emberUtils.generateGuid(this); + } - var queryParams = {}; + return OutletComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); + var OutletLayoutCompiler = (function () { + function OutletLayoutCompiler(template) { + babelHelpers.classCallCheck(this, OutletLayoutCompiler); - _emberUtils.assign(queryParams, _queryParams); - this._prepareQueryParams(targetRouteName, models, queryParams); + this.template = template; + } - var transitionArgs = _emberRoutingUtils.routeArgs(targetRouteName, models, queryParams); - var transition = this.router.transitionTo.apply(this.router, transitionArgs); + OutletLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + }; - didBeginTransition(transition, this); + return OutletLayoutCompiler; + })(); - return transition; - }, + exports.OutletLayoutCompiler = OutletLayoutCompiler; - _processActiveTransitionQueryParams: function (targetRouteName, models, queryParams, _queryParams) { - // merge in any queryParams from the active transition which could include - // queryParams from the url on initial load. - if (!this.router.activeTransition) { - return; - } + OutletLayoutCompiler.id = 'outlet'; +}); +enifed('ember-glimmer/syntax/render', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet, _container, _emberGlimmerSyntaxAbstractManager) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var unchangedQPs = {}; - var qpUpdates = this._qpUpdates || {}; - for (var key in this.router.activeTransition.queryParams) { - if (!qpUpdates[key]) { - unchangedQPs[key] = this.router.activeTransition.queryParams[key]; - } - } + exports.renderMacro = renderMacro; - // We need to fully scope queryParams so that we can create one object - // that represents both pased in queryParams and ones that aren't changed - // from the active transition. - this._fullyScopeQueryParams(targetRouteName, models, _queryParams); - this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs); - _emberUtils.assign(queryParams, unchangedQPs); - }, + function makeComponentDefinition(vm) { + var env = vm.env; + var args = vm.getArgs(); + var nameRef = args.positional.at(0); - /** - Prepares the query params for a URL or Transition. Restores any undefined QP - keys/values, serializes all values, and then prunes any default values. - @private - @method _prepareQueryParams - @param {String} targetRouteName - @param {Array} models - @param {Object} queryParams - @return {Void} - */ - _prepareQueryParams: function (targetRouteName, models, queryParams) { - var state = calculatePostTransitionState(this, targetRouteName, models); - this._hydrateUnsuppliedQueryParams(state, queryParams); - this._serializeQueryParams(state.handlerInfos, queryParams); - this._pruneDefaultQueryParamValues(state.handlerInfos, queryParams); - }, + _emberMetal.assert('The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.', _glimmerReference.isConst(nameRef)); + _emberMetal.assert('The second argument of {{render}} must be a path, e.g. {{render "post" post}}.', args.positional.length === 1 || !_glimmerReference.isConst(args.positional.at(1))); - /** - Returns the meta information for the query params of a given route. This - will be overriden to allow support for lazy routes. - @private - @method _getQPMeta - @param {HandlerInfo} handlerInfo - @return {Object} - */ - _getQPMeta: function (handlerInfo) { - var route = handlerInfo.handler; - return route && _emberMetal.get(route, '_qp'); - }, + var templateName = nameRef.value(); - /** - Returns a merged query params meta object for a given set of handlerInfos. - Useful for knowing what query params are available for a given route hierarchy. - @private - @method _queryParamsFor - @param {Array} handlerInfos - @return {Object} - */ - _queryParamsFor: function (handlerInfos) { - var leafRouteName = handlerInfos[handlerInfos.length - 1].name; - if (this._qpCache[leafRouteName]) { - return this._qpCache[leafRouteName]; - } + _emberMetal.assert('You used `{{render \'' + templateName + '\'}}`, but \'' + templateName + '\' can not be found as a template.', env.owner.hasRegistration('template:' + templateName)); - var shouldCache = true; - var qpsByUrlKey = {}; - var map = {}; - var qps = []; + var template = env.owner.lookup('template:' + templateName); - for (var i = 0; i < handlerInfos.length; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); + var controllerName = undefined; - if (!qpMeta) { - shouldCache = false; - continue; - } + if (args.named.has('controller')) { + var controllerNameRef = args.named.get('controller'); - // Loop over each QP to make sure we don't have any collisions by urlKey - for (var _i = 0; _i < qpMeta.qps.length; _i++) { - var qp = qpMeta.qps[_i]; - var urlKey = qp.urlKey; + _emberMetal.assert('The controller argument for {{render}} must be quoted, e.g. {{render "sidebar" controller="foo"}}.', _glimmerReference.isConst(controllerNameRef)); - if (qpsByUrlKey[urlKey]) { - var otherQP = qpsByUrlKey[urlKey]; - _emberMetal.assert('You\'re not allowed to have more than one controller property map to the same query param key, but both `' + otherQP.scopedPropertyName + '` and `' + qp.scopedPropertyName + '` map to `' + urlKey + '`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `' + otherQP.prop + ': { as: \'other-' + otherQP.prop + '\' }`', false); - } + controllerName = controllerNameRef.value(); - qpsByUrlKey[urlKey] = qp; - qps.push(qp); - } + _emberMetal.assert('The controller name you supplied \'' + controllerName + '\' did not resolve to a controller.', env.owner.hasRegistration('controller:' + controllerName)); + } else { + controllerName = templateName; + } - _emberUtils.assign(map, qpMeta.map); - } + if (args.positional.length === 1) { + return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, SINGLETON_RENDER_MANAGER)); + } else { + return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, NON_SINGLETON_RENDER_MANAGER)); + } + } + + /** + Calling ``{{render}}`` from within a template will insert another + template that matches the provided name. The inserted template will + access its properties on its own controller (rather than the controller + of the parent template). + + If a view class with the same name exists, the view class also will be used. + Note: A given controller may only be used *once* in your app in this manner. + A singleton instance of the controller will be created for you. + + Example: + + ```javascript + App.NavigationController = Ember.Controller.extend({ + who: "world" + }); + ``` + + ```handlebars + + Hello, {{who}}. + ``` + + ```handlebars + +

    My great app

    + {{render "navigation"}} + ``` + + ```html +

    My great app

    +
    + Hello, world. +
    + ``` + + Optionally you may provide a second argument: a property path + that will be bound to the `model` property of the controller. + If a `model` property path is specified, then a new instance of the + controller will be created and `{{render}}` can be used multiple times + with the same name. + + For example if you had this `author` template. + + ```handlebars +
    + Written by {{firstName}} {{lastName}}. + Total Posts: {{postCount}} +
    + ``` + + You could render it inside the `post` template using the `render` helper. + + ```handlebars +
    +

    {{title}}

    +
    {{body}}
    + {{render "author" author}} +
    + ``` + + @method render + @for Ember.Templates.helpers + @param {String} name + @param {Object?} context + @param {Hash} options + @return {String} HTML string + @public + */ - var finalQPMeta = { - qps: qps, - map: map - }; + function renderMacro(path, params, hash, builder) { + if (!params) { + params = []; + } + var definitionArgs = [params.slice(0), hash, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, makeComponentDefinition, args, builder.symbolTable); + return true; + } - if (shouldCache) { - this._qpCache[leafRouteName] = finalQPMeta; - } + var AbstractRenderManager = (function (_AbstractManager) { + babelHelpers.inherits(AbstractRenderManager, _AbstractManager); - return finalQPMeta; - }, + function AbstractRenderManager() { + babelHelpers.classCallCheck(this, AbstractRenderManager); - /** - Maps all query param keys to their fully scoped property name of the form - `controllerName:propName`. - @private - @method _fullyScopeQueryParams - @param {String} leafRouteName - @param {Array} contexts - @param {Object} queryParams - @return {Void} - */ - _fullyScopeQueryParams: function (leafRouteName, contexts, queryParams) { - var state = calculatePostTransitionState(this, leafRouteName, contexts); - var handlerInfos = state.handlerInfos; + _AbstractManager.apply(this, arguments); + } - for (var i = 0, len = handlerInfos.length; i < len; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); + AbstractRenderManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - if (!qpMeta) { - continue; - } + /* abstract create(environment, definition, args, dynamicScope); */ - for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { - var qp = qpMeta.qps[j]; + AbstractRenderManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, definition.template); + }; - var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; + AbstractRenderManager.prototype.getSelf = function getSelf(_ref) { + var controller = _ref.controller; - if (presentProp) { - if (presentProp !== qp.scopedPropertyName) { - queryParams[qp.scopedPropertyName] = queryParams[presentProp]; - delete queryParams[presentProp]; - } - } - } - } - }, + return new _emberGlimmerUtilsReferences.RootReference(controller); + }; - /** - Hydrates (adds/restores) any query params that have pre-existing values into - the given queryParams hash. This is what allows query params to be "sticky" - and restore their last known values for their scope. - @private - @method _hydrateUnsuppliedQueryParams - @param {TransitionState} state - @param {Object} queryParams - @return {Void} - */ - _hydrateUnsuppliedQueryParams: function (state, queryParams) { - var handlerInfos = state.handlerInfos; - var appCache = this._bucketCache; + AbstractRenderManager.prototype.getTag = function getTag() { + return null; + }; - for (var i = 0; i < handlerInfos.length; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); + AbstractRenderManager.prototype.getDestructor = function getDestructor() { + return null; + }; - if (!qpMeta) { - continue; - } + AbstractRenderManager.prototype.didCreateElement = function didCreateElement() {}; - for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { - var qp = qpMeta.qps[j]; + AbstractRenderManager.prototype.didRenderLayout = function didRenderLayout() {}; - var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; + AbstractRenderManager.prototype.didCreate = function didCreate() {}; - if (presentProp) { - if (presentProp !== qp.scopedPropertyName) { - queryParams[qp.scopedPropertyName] = queryParams[presentProp]; - delete queryParams[presentProp]; - } - } else { - var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.controllerName, qp.parts, state.params); - queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); - } - } - } - }, + AbstractRenderManager.prototype.update = function update() {}; - _scheduleLoadingEvent: function (transition, originRoute) { - this._cancelSlowTransitionTimer(); - this._slowTransitionTimer = _emberMetal.run.scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute); - }, + AbstractRenderManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - currentState: null, - targetState: null, + AbstractRenderManager.prototype.didUpdate = function didUpdate() {}; - _handleSlowTransition: function (transition, originRoute) { - if (!this.router.activeTransition) { - // Don't fire an event if we've since moved on from - // the transition that put us in a loading state. - return; - } + return AbstractRenderManager; + })(_emberGlimmerSyntaxAbstractManager.default); - this.set('targetState', _emberRoutingSystemRouter_state.default.create({ - emberRouter: this, - routerJs: this.router, - routerJsState: this.router.activeTransition.state - })); + _emberMetal.runInDebug(function () { + AbstractRenderManager.prototype.didRenderLayout = function () { + this.debugStack.pop(); + }; + }); - transition.trigger(true, 'loading', transition, originRoute); - }, + var SingletonRenderManager = (function (_AbstractRenderManager) { + babelHelpers.inherits(SingletonRenderManager, _AbstractRenderManager); - _cancelSlowTransitionTimer: function () { - if (this._slowTransitionTimer) { - _emberMetal.run.cancel(this._slowTransitionTimer); - } - this._slowTransitionTimer = null; - }, + function SingletonRenderManager() { + babelHelpers.classCallCheck(this, SingletonRenderManager); - // These three helper functions are used to ensure errors aren't - // re-raised if they're handled in a route's error action. - _markErrorAsHandled: function (errorGuid) { - this._handledErrors[errorGuid] = true; - }, + _AbstractRenderManager.apply(this, arguments); + } - _isErrorHandled: function (errorGuid) { - return this._handledErrors[errorGuid]; - }, + SingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this = this; - _clearHandledError: function (errorGuid) { - delete this._handledErrors[errorGuid]; - }, + var name = definition.name; + var env = definition.env; - _getEngineInstance: function (_ref) { - var name = _ref.name; - var instanceId = _ref.instanceId; - var mountPoint = _ref.mountPoint; + var controller = env.owner.lookup('controller:' + name) || _emberRouting.generateController(env.owner, name); - var engineInstances = this._engineInstances; + _emberMetal.runInDebug(function () { + return _this._pushToDebugStack('controller:' + name + ' (with the render helper)', environment); + }); - if (!engineInstances[name]) { - engineInstances[name] = new _emberUtils.EmptyObject(); + if (dynamicScope.rootOutletState) { + dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); } - var engineInstance = engineInstances[name][instanceId]; - - if (!engineInstance) { - var owner = _emberUtils.getOwner(this); + return { controller: controller }; + }; - _emberMetal.assert('You attempted to mount the engine \'' + name + '\' in your router map, but the engine can not be found.', owner.hasRegistration('engine:' + name)); + return SingletonRenderManager; + })(AbstractRenderManager); - engineInstance = owner.buildChildEngineInstance(name, { - routable: true, - mountPoint: mountPoint - }); + var SINGLETON_RENDER_MANAGER = new SingletonRenderManager(); - engineInstance.boot(); + var NonSingletonRenderManager = (function (_AbstractRenderManager2) { + babelHelpers.inherits(NonSingletonRenderManager, _AbstractRenderManager2); - engineInstances[name][instanceId] = engineInstance; - } + function NonSingletonRenderManager() { + babelHelpers.classCallCheck(this, NonSingletonRenderManager); - return engineInstance; + _AbstractRenderManager2.apply(this, arguments); } - }); - /* - Helper function for iterating over routes in a set of handlerInfos that are - at or above the given origin route. Example: if `originRoute` === 'foo.bar' - and the handlerInfos given were for 'foo.bar.baz', then the given callback - will be invoked with the routes for 'foo.bar', 'foo', and 'application' - individually. - - If the callback returns anything other than `true`, then iteration will stop. - - @private - @param {Route} originRoute - @param {Array} handlerInfos - @param {Function} callback - @return {Void} - */ - function forEachRouteAbove(originRoute, handlerInfos, callback) { - var originRouteFound = false; + NonSingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this2 = this; - for (var i = handlerInfos.length - 1; i >= 0; --i) { - var handlerInfo = handlerInfos[i]; - var route = handlerInfo.handler; + var name = definition.name; + var env = definition.env; - if (originRoute === route) { - originRouteFound = true; - } + var modelRef = args.positional.at(0); + var controllerFactory = env.owner[_container.FACTORY_FOR]('controller:' + name); - if (!originRouteFound) { - continue; - } + var factory = controllerFactory || _emberRouting.generateControllerFactory(env.owner, name); + var controller = factory.create({ model: modelRef.value() }); - if (callback(route) !== true) { - return; + _emberMetal.runInDebug(function () { + return _this2._pushToDebugStack('controller:' + name + ' (with the render helper)', environment); + }); + + if (dynamicScope.rootOutletState) { + dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); } - } - } - // These get invoked when an action bubbles above ApplicationRoute - // and are not meant to be overridable. - var defaultActionHandlers = { + return { controller: controller }; + }; - willResolveModel: function (transition, originRoute) { - originRoute.router._scheduleLoadingEvent(transition, originRoute); - }, + NonSingletonRenderManager.prototype.update = function update(_ref2, args, dynamicScope) { + var controller = _ref2.controller; - // Attempt to find an appropriate error route or substate to enter. - error: function (error, transition, originRoute) { - var handlerInfos = transition.state.handlerInfos; - var router = originRoute.router; + controller.set('model', args.positional.at(0).value()); + }; - forEachRouteAbove(originRoute, handlerInfos, function (route) { - // Check for the existence of an 'error' route. - // We don't check for an 'error' route on the originRoute, since that would - // technically be below where we're at in the route hierarchy. - if (originRoute !== route) { - var errorRouteName = findRouteStateName(route, 'error'); - if (errorRouteName) { - router.intermediateTransitionTo(errorRouteName, error); - return false; - } - } + NonSingletonRenderManager.prototype.getDestructor = function getDestructor(_ref3) { + var controller = _ref3.controller; - // Check for an 'error' substate route - var errorSubstateName = findRouteSubstateName(route, 'error'); - if (errorSubstateName) { - router.intermediateTransitionTo(errorSubstateName, error); - return false; - } + return controller; + }; - return true; - }); + return NonSingletonRenderManager; + })(AbstractRenderManager); - logError(error, 'Error while processing route: ' + transition.targetName); - }, + var NON_SINGLETON_RENDER_MANAGER = new NonSingletonRenderManager(); - // Attempt to find an appropriate loading route or substate to enter. - loading: function (transition, originRoute) { - var handlerInfos = transition.state.handlerInfos; - var router = originRoute.router; + var RenderDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(RenderDefinition, _ComponentDefinition); - forEachRouteAbove(originRoute, handlerInfos, function (route) { - // Check for the existence of a 'loading' route. - // We don't check for a 'loading' route on the originRoute, since that would - // technically be below where we're at in the route hierarchy. - if (originRoute !== route) { - var loadingRouteName = findRouteStateName(route, 'loading'); - if (loadingRouteName) { - router.intermediateTransitionTo(loadingRouteName); - return false; - } - } + function RenderDefinition(name, template, env, manager) { + babelHelpers.classCallCheck(this, RenderDefinition); - // Check for loading substate - var loadingSubstateName = findRouteSubstateName(route, 'loading'); - if (loadingSubstateName) { - router.intermediateTransitionTo(loadingSubstateName); - return false; - } + _ComponentDefinition.call(this, 'render', manager, null); - // Don't bubble above pivot route. - return transition.pivotHandler !== route; - }); + this.name = name; + this.template = template; + this.env = env; } - }; - function logError(_error, initialMessage) { - var errorArgs = []; - var error = undefined; - if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { - error = _error.errorThrown; - } else { - error = _error; - } + return RenderDefinition; + })(_glimmerRuntime.ComponentDefinition); +}); +enifed('ember-glimmer/template', ['exports', 'ember-utils', '@glimmer/runtime'], function (exports, _emberUtils, _glimmerRuntime) { + 'use strict'; - if (initialMessage) { - errorArgs.push(initialMessage); - } + exports.default = template; - if (error) { - if (error.message) { - errorArgs.push(error.message); - } - if (error.stack) { - errorArgs.push(error.stack); - } + function template(json) { + var factory = _glimmerRuntime.templateFactory(json); - if (typeof error === 'string') { - errorArgs.push(error); + return { + id: factory.id, + meta: factory.meta, + create: function (props) { + return factory.create(props.env, { owner: props[_emberUtils.OWNER] }); } - } - - _emberConsole.default.error.apply(this, errorArgs); + }; } +}); +enifed("ember-glimmer/template_registry", ["exports"], function (exports) { + // STATE within a module is frowned apon, this exists + // to support Ember.TEMPLATES but shield ember internals from this legacy + // global API. + "use strict"; - /** - Finds the name of the substate route if it exists for the given route. A - substate route is of the form `route_state`, such as `foo_loading`. - - @private - @param {Route} route - @param {String} state - @return {String} - */ - function findRouteSubstateName(route, state) { - var router = route.router; - var owner = _emberUtils.getOwner(route); - - var routeName = route.routeName; - var substateName = routeName + '_' + state; - - var routeNameFull = route.fullRouteName; - var substateNameFull = routeNameFull + '_' + state; + exports.setTemplates = setTemplates; + exports.getTemplates = getTemplates; + exports.getTemplate = getTemplate; + exports.hasTemplate = hasTemplate; + exports.setTemplate = setTemplate; + var TEMPLATES = {}; - return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; + function setTemplates(templates) { + TEMPLATES = templates; } - /** - Finds the name of the state route if it exists for the given route. A state - route is of the form `route.state`, such as `foo.loading`. Properly Handles - `application` named routes. - - @private - @param {Route} route - @param {String} state - @return {String} - */ - function findRouteStateName(route, state) { - var router = route.router; - var owner = _emberUtils.getOwner(route); - - var routeName = route.routeName; - var stateName = routeName === 'application' ? state : routeName + '.' + state; - - var routeNameFull = route.fullRouteName; - var stateNameFull = routeNameFull === 'application' ? state : routeNameFull + '.' + state; + function getTemplates() { + return TEMPLATES; + } - return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; + function getTemplate(name) { + if (TEMPLATES.hasOwnProperty(name)) { + return TEMPLATES[name]; + } } - /** - Determines whether or not a route has been defined by checking that the route - is in the Router's map and the owner has a registration for that route. - - @private - @param {Owner} owner - @param {Ember.Router} router - @param {String} localName - @param {String} fullName - @return {Boolean} - */ - function routeHasBeenDefined(owner, router, localName, fullName) { - var routerHasRoute = router.hasRoute(fullName); - var ownerHasRoute = owner.hasRegistration('template:' + localName) || owner.hasRegistration('route:' + localName); - return routerHasRoute && ownerHasRoute; + function hasTemplate(name) { + return TEMPLATES.hasOwnProperty(name); } - function triggerEvent(handlerInfos, ignoreFailure, args) { - var name = args.shift(); + function setTemplate(name, template) { + return TEMPLATES[name] = template; + } +}); +enifed("ember-glimmer/templates/component", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - if (!handlerInfos) { - if (ignoreFailure) { - return; - } - throw new _emberMetal.Error('Can\'t trigger action \'' + name + '\' because your app hasn\'t finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.'); - } + exports.default = _emberGlimmerTemplate.default({ "id": "2aYM5QYc", "block": "{\"statements\":[[\"yield\",\"default\"]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/component.hbs" } }); +}); +enifed("ember-glimmer/templates/empty", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - var eventWasHandled = false; - var handlerInfo = undefined, - handler = undefined; + exports.default = _emberGlimmerTemplate.default({ "id": "5QJJjniM", "block": "{\"statements\":[],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/empty.hbs" } }); +}); +enifed("ember-glimmer/templates/link-to", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - for (var i = handlerInfos.length - 1; i >= 0; i--) { - handlerInfo = handlerInfos[i]; - handler = handlerInfo.handler; + exports.default = _emberGlimmerTemplate.default({ "id": "Y2DX6qHQ", "block": "{\"statements\":[[\"block\",[\"if\"],[[\"get\",[\"linkTitle\"]]],null,{\"statements\":[[\"append\",[\"unknown\",[\"linkTitle\"]],false]],\"locals\":[]},{\"statements\":[[\"yield\",\"default\"]],\"locals\":[]}]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/link-to.hbs" } }); +}); +enifed("ember-glimmer/templates/outlet", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - if (handler && handler.actions && handler.actions[name]) { - if (handler.actions[name].apply(handler, args) === true) { - eventWasHandled = true; - } else { - // Should only hit here if a non-bubbling error action is triggered on a route. - if (name === 'error') { - var errorId = _emberUtils.guidFor(args[0]); - handler.router._markErrorAsHandled(errorId); - } - return; - } - } - } + exports.default = _emberGlimmerTemplate.default({ "id": "xyZMyWzn", "block": "{\"statements\":[[\"append\",[\"unknown\",[\"outlet\"]],false]],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/outlet.hbs" } }); +}); +enifed("ember-glimmer/templates/root", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - if (defaultActionHandlers[name]) { - defaultActionHandlers[name].apply(null, args); - return; - } + exports.default = _emberGlimmerTemplate.default({ "id": "/KBRNPqv", "block": "{\"statements\":[[\"append\",[\"helper\",[\"component\"],[[\"get\",[null]]],null],false]],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/root.hbs" } }); +}); +enifed('ember-glimmer/utils/bindings', ['exports', '@glimmer/reference', 'ember-metal', 'ember-runtime', 'ember-glimmer/component', 'ember-glimmer/utils/string'], function (exports, _glimmerReference, _emberMetal, _emberRuntime, _emberGlimmerComponent, _emberGlimmerUtilsString) { + 'use strict'; - if (!eventWasHandled && !ignoreFailure) { - throw new _emberMetal.Error('Nothing handled the action \'' + name + '\'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.'); - } + exports.wrapComponentClassAttribute = wrapComponentClassAttribute; + + function referenceForKey(component, key) { + return component[_emberGlimmerComponent.ROOT_REF].get(key); } - function calculatePostTransitionState(emberRouter, leafRouteName, contexts) { - var routerjs = emberRouter.router; - var state = routerjs.applyIntent(leafRouteName, contexts); - var handlerInfos = state.handlerInfos; - var params = state.params; + function referenceForParts(component, parts) { + var isAttrs = parts[0] === 'attrs'; - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; + // TODO deprecate this + if (isAttrs) { + parts.shift(); - // If the handlerInfo is not resolved, we serialize the context into params - if (!handlerInfo.isResolved) { - params[handlerInfo.name] = handlerInfo.serialize(handlerInfo.context); - } else { - params[handlerInfo.name] = handlerInfo.params; + if (parts.length === 1) { + return referenceForKey(component, parts[0]); } } - return state; - } - - function updatePaths(router) { - var infos = router.router.currentHandlerInfos; - if (infos.length === 0) { - return; - } - - var path = EmberRouter._routePath(infos); - var currentRouteName = infos[infos.length - 1].name; - _emberMetal.set(router, 'currentPath', path); - _emberMetal.set(router, 'currentRouteName', currentRouteName); + return _glimmerReference.referenceFromParts(component[_emberGlimmerComponent.ROOT_REF], parts); + } - var appController = _emberUtils.getOwner(router).lookup('controller:application'); + // TODO we should probably do this transform at build time - if (!appController) { - // appController might not exist when top-level loading/error - // substates have been entered since ApplicationRoute hasn't - // actually been entered at that point. - return; + function wrapComponentClassAttribute(hash) { + if (!hash) { + return hash; } - if (!('currentPath' in appController)) { - _emberMetal.defineProperty(appController, 'currentPath'); - } + var keys = hash[0]; + var values = hash[1]; - _emberMetal.set(appController, 'currentPath', path); + var index = keys.indexOf('class'); - if (!('currentRouteName' in appController)) { - _emberMetal.defineProperty(appController, 'currentRouteName'); + if (index !== -1) { + var _values$index = values[index]; + var type = _values$index[0]; + + if (type === 'get') { + var getExp = values[index]; + var path = getExp[1]; + var propName = path[path.length - 1]; + hash[1][index] = ['helper', ['-class'], [getExp, propName]]; + } } - _emberMetal.set(appController, 'currentRouteName', currentRouteName); + return hash; } - EmberRouter.reopenClass({ - router: null, + var AttributeBinding = { + parse: function (microsyntax) { + var colonIndex = microsyntax.indexOf(':'); - /** - The `Router.map` function allows you to define mappings from URLs to routes - in your application. These mappings are defined within the - supplied callback function using `this.route`. - The first parameter is the name of the route which is used by default as the - path name as well. - The second parameter is the optional options hash. Available options are: - * `path`: allows you to provide your own path as well as mark dynamic - segments. - * `resetNamespace`: false by default; when nesting routes, ember will - combine the route names to form the fully-qualified route name, which is - used with `{{link-to}}` or manually transitioning to routes. Setting - `resetNamespace: true` will cause the route not to inherit from its - parent route's names. This is handy for preventing extremely long route names. - Keep in mind that the actual URL path behavior is still retained. - The third parameter is a function, which can be used to nest routes. - Nested routes, by default, will have the parent route tree's route name and - path prepended to it's own. - ```javascript - App.Router.map(function(){ - this.route('post', { path: '/post/:post_id' }, function() { - this.route('edit'); - this.route('comments', { resetNamespace: true }, function() { - this.route('new'); - }); - }); - }); - ``` - For more detailed documentation and examples please see - [the guides](http://emberjs.com/guides/routing/defining-your-routes/). - @method map - @param callback - @public - */ - map: function (callback) { - if (!this.dslCallbacks) { - this.dslCallbacks = []; - this.reopenClass({ dslCallbacks: this.dslCallbacks }); - } + if (colonIndex === -1) { + _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', microsyntax !== 'class'); + return [microsyntax, microsyntax, true]; + } else { + var prop = microsyntax.substring(0, colonIndex); + var attribute = microsyntax.substring(colonIndex + 1); - this.dslCallbacks.push(callback); + _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attribute !== 'class'); - return this; + return [prop, attribute, false]; + } }, - _routePath: function (handlerInfos) { - var path = []; - - // We have to handle coalescing resource names that - // are prefixed with their parent's names, e.g. - // ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz' + install: function (element, component, parsed, operations) { + var prop = parsed[0]; + var attribute = parsed[1]; + var isSimple = parsed[2]; - function intersectionMatches(a1, a2) { - for (var i = 0; i < a1.length; ++i) { - if (a1[i] !== a2[i]) { - return false; - } + if (attribute === 'id') { + var elementId = _emberMetal.get(component, prop); + if (elementId === undefined || elementId === null) { + elementId = component.elementId; } - return true; + operations.addStaticAttribute(element, 'id', elementId); + return; } - var name = undefined, - nameParts = undefined, - oldNameParts = undefined; - for (var i = 1; i < handlerInfos.length; i++) { - name = handlerInfos[i].name; - nameParts = name.split('.'); - oldNameParts = slice.call(path); + var isPath = prop.indexOf('.') > -1; + var reference = isPath ? referenceForParts(component, prop.split('.')) : referenceForKey(component, prop); - while (oldNameParts.length) { - if (intersectionMatches(oldNameParts, nameParts)) { - break; - } - oldNameParts.shift(); - } + _emberMetal.assert('Illegal attributeBinding: \'' + prop + '\' is not a valid attribute name.', !(isSimple && isPath)); - path.push.apply(path, nameParts.slice(oldNameParts.length)); + if (attribute === 'style') { + reference = new StyleBindingReference(reference, referenceForKey(component, 'isVisible')); } - return path.join('.'); - } - }); - - function didBeginTransition(transition, router) { - var routerState = _emberRoutingSystemRouter_state.default.create({ - emberRouter: router, - routerJs: router.router, - routerJsState: transition.state - }); - - if (!router.currentState) { - router.set('currentState', routerState); + operations.addDynamicAttribute(element, attribute, reference); } - router.set('targetState', routerState); - - transition.promise = transition.catch(function (error) { - var errorId = _emberUtils.guidFor(error); - - if (router._isErrorHandled(errorId)) { - router._clearHandledError(errorId); - } else { - throw error; - } - }); - } + }; - function resemblesURL(str) { - return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); - } + exports.AttributeBinding = AttributeBinding; + var DISPLAY_NONE = 'display: none;'; + var SAFE_DISPLAY_NONE = _emberGlimmerUtilsString.htmlSafe(DISPLAY_NONE); - function forEachQueryParam(router, handlerInfos, queryParams, callback) { - var qpCache = router._queryParamsFor(handlerInfos); + var StyleBindingReference = (function (_CachedReference) { + babelHelpers.inherits(StyleBindingReference, _CachedReference); - for (var key in queryParams) { - if (!queryParams.hasOwnProperty(key)) { - continue; - } - var value = queryParams[key]; - var qp = qpCache.map[key]; + function StyleBindingReference(inner, isVisible) { + babelHelpers.classCallCheck(this, StyleBindingReference); - callback(key, value, qp); - } - } + _CachedReference.call(this); - function findLiveRoute(liveRoutes, name) { - if (!liveRoutes) { - return; - } - var stack = [liveRoutes]; - while (stack.length > 0) { - var test = stack.shift(); - if (test.render.name === name) { - return test; - } - var outlets = test.outlets; - for (var outletName in outlets) { - stack.push(outlets[outletName]); - } + this.tag = _glimmerReference.combine([inner.tag, isVisible.tag]); + this.inner = inner; + this.isVisible = isVisible; } - } - function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { - var target = undefined; - var myState = { - render: renderOptions, - outlets: new _emberUtils.EmptyObject(), - wasUsed: false - }; - if (renderOptions.into) { - target = findLiveRoute(liveRoutes, renderOptions.into); - } else { - target = defaultParentState; - } - if (target) { - _emberMetal.set(target.outlets, renderOptions.outlet, myState); - } else { - if (renderOptions.into) { - _emberMetal.deprecate('Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated.', false, { - id: 'ember-routing.top-level-render-helper', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' - }); + StyleBindingReference.prototype.compute = function compute() { + var value = this.inner.value(); + var isVisible = this.isVisible.value(); - // Megahax time. Post-3.0-breaking-changes, we will just assert - // right here that the user tried to target a nonexistent - // thing. But for now we still need to support the `render` - // helper, and people are allowed to target templates rendered - // by the render helper. So instead we defer doing anyting with - // these orphan renders until afterRender. - appendOrphan(liveRoutes, renderOptions.into, myState); + if (isVisible !== false) { + return value; + } else if (!value && value !== 0) { + return SAFE_DISPLAY_NONE; } else { - liveRoutes = myState; + var style = value + ' ' + DISPLAY_NONE; + return _emberGlimmerUtilsString.isHTMLSafe(value) ? _emberGlimmerUtilsString.htmlSafe(style) : style; } - } - return { - liveRoutes: liveRoutes, - ownState: myState }; - } - - function appendOrphan(liveRoutes, into, myState) { - if (!liveRoutes.outlets.__ember_orphans__) { - liveRoutes.outlets.__ember_orphans__ = { - render: { - name: '__ember_orphans__' - }, - outlets: new _emberUtils.EmptyObject() - }; - } - liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; - _emberMetal.run.schedule('afterRender', function () { - // `wasUsed` gets set by the render helper. - _emberMetal.assert('You attempted to render into \'' + into + '\' but it was not found', liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed); - }); - } - - function representEmptyRoute(liveRoutes, defaultParentState, route) { - // the route didn't render anything - var alreadyAppended = findLiveRoute(liveRoutes, route.routeName); - if (alreadyAppended) { - // But some other route has already rendered our default - // template, so that becomes the default target for any - // children we may have. - return alreadyAppended; - } else { - // Create an entry to represent our default template name, - // just so other routes can target it and inherit its place - // in the outlet hierarchy. - defaultParentState.outlets.main = { - render: { - name: route.routeName, - outlet: 'main' - }, - outlets: {} - }; - return defaultParentState; - } - } - exports.default = EmberRouter; -}); + return StyleBindingReference; + })(_glimmerReference.CachedReference); -/** -@module ember -@submodule ember-routing -*/ -enifed('ember-routing/system/router_state', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime'], function (exports, _emberUtils, _emberMetal, _emberRuntime) { - 'use strict'; + var IsVisibleBinding = { + install: function (element, component, operations) { + operations.addDynamicAttribute(element, 'style', _glimmerReference.map(referenceForKey(component, 'isVisible'), this.mapStyleValue)); + }, - exports.default = _emberRuntime.Object.extend({ - emberRouter: null, - routerJs: null, - routerJsState: null, + mapStyleValue: function (isVisible) { + return isVisible === false ? SAFE_DISPLAY_NONE : null; + } + }; - isActiveIntent: function (routeName, models, queryParams, queryParamsMustMatch) { - var state = this.routerJsState; - if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { - return false; - } + exports.IsVisibleBinding = IsVisibleBinding; + var ClassNameBinding = { + install: function (element, component, microsyntax, operations) { + var _microsyntax$split = microsyntax.split(':'); - var emptyQueryParams = _emberMetal.isEmpty(Object.keys(queryParams)); + var prop = _microsyntax$split[0]; + var truthy = _microsyntax$split[1]; + var falsy = _microsyntax$split[2]; - if (queryParamsMustMatch && !emptyQueryParams) { - var visibleQueryParams = {}; - _emberUtils.assign(visibleQueryParams, queryParams); + var isStatic = prop === ''; - this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); - return shallowEqual(visibleQueryParams, state.queryParams); - } + if (isStatic) { + operations.addStaticAttribute(element, 'class', truthy); + } else { + var isPath = prop.indexOf('.') > -1; + var parts = isPath && prop.split('.'); + var value = isPath ? referenceForParts(component, parts) : referenceForKey(component, prop); + var ref = undefined; - return true; - } - }); + if (truthy === undefined) { + ref = new SimpleClassNameBindingReference(value, isPath ? parts[parts.length - 1] : prop); + } else { + ref = new ColonClassNameBindingReference(value, truthy, falsy); + } - function shallowEqual(a, b) { - var k = undefined; - for (k in a) { - if (a.hasOwnProperty(k) && a[k] !== b[k]) { - return false; - } - } - for (k in b) { - if (b.hasOwnProperty(k) && a[k] !== b[k]) { - return false; + operations.addDynamicAttribute(element, 'class', ref); } } - return true; - } -}); -enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { - 'use strict'; + }; - exports.routeArgs = routeArgs; - exports.getActiveTargetName = getActiveTargetName; - exports.stashParamNames = stashParamNames; - exports.calculateCacheKey = calculateCacheKey; - exports.normalizeControllerQueryParams = normalizeControllerQueryParams; - exports.prefixRouteNameArg = prefixRouteNameArg; + exports.ClassNameBinding = ClassNameBinding; - var ALL_PERIODS_REGEX = /\./g; + var SimpleClassNameBindingReference = (function (_CachedReference2) { + babelHelpers.inherits(SimpleClassNameBindingReference, _CachedReference2); - function routeArgs(targetRouteName, models, queryParams) { - var args = []; - if (typeof targetRouteName === 'string') { - args.push('' + targetRouteName); - } - args.push.apply(args, models); - args.push({ queryParams: queryParams }); - return args; - } + function SimpleClassNameBindingReference(inner, path) { + babelHelpers.classCallCheck(this, SimpleClassNameBindingReference); - function getActiveTargetName(router) { - var handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; - return handlerInfos[handlerInfos.length - 1].name; - } + _CachedReference2.call(this); - function stashParamNames(router, handlerInfos) { - if (handlerInfos._namesStashed) { - return; + this.tag = inner.tag; + this.inner = inner; + this.path = path; + this.dasherizedPath = null; } - // This helper exists because router.js/route-recognizer.js awkwardly - // keeps separate a handlerInfo's list of parameter names depending - // on whether a URL transition or named transition is happening. - // Hopefully we can remove this in the future. - var targetRouteName = handlerInfos[handlerInfos.length - 1].name; - var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); - var dynamicParent = null; + SimpleClassNameBindingReference.prototype.compute = function compute() { + var value = this.inner.value(); - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; - var names = recogHandlers[i].names; + if (value === true) { + var path = this.path; + var dasherizedPath = this.dasherizedPath; - if (names.length) { - dynamicParent = handlerInfo; + return dasherizedPath || (this.dasherizedPath = _emberRuntime.String.dasherize(path)); + } else if (value || value === 0) { + return value; + } else { + return null; } + }; - handlerInfo._names = names; + return SimpleClassNameBindingReference; + })(_glimmerReference.CachedReference); - var route = handlerInfo.handler; - route._stashNames(handlerInfo, dynamicParent); + var ColonClassNameBindingReference = (function (_CachedReference3) { + babelHelpers.inherits(ColonClassNameBindingReference, _CachedReference3); + + function ColonClassNameBindingReference(inner, truthy, falsy) { + babelHelpers.classCallCheck(this, ColonClassNameBindingReference); + + _CachedReference3.call(this); + + this.tag = inner.tag; + this.inner = inner; + this.truthy = truthy || null; + this.falsy = falsy || null; } - handlerInfos._namesStashed = true; - } + ColonClassNameBindingReference.prototype.compute = function compute() { + var inner = this.inner; + var truthy = this.truthy; + var falsy = this.falsy; - function _calculateCacheValuePrefix(prefix, part) { - // calculates the dot seperated sections from prefix that are also - // at the start of part - which gives us the route name + return inner.value() ? truthy : falsy; + }; - // given : prefix = site.article.comments, part = site.article.id - // - returns: site.article (use get(values[site.article], 'id') to get the dynamic part - used below) + return ColonClassNameBindingReference; + })(_glimmerReference.CachedReference); +}); +enifed('ember-glimmer/utils/debug-stack', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - // given : prefix = site.article, part = site.article.id - // - returns: site.article. (use get(values[site.article], 'id') to get the dynamic part - used below) + var DebugStack = undefined; - var prefixParts = prefix.split('.'); - var currPrefix = ''; + _emberMetal.runInDebug(function () { + var Element = function Element(name) { + babelHelpers.classCallCheck(this, Element); - for (var i = 0; i < prefixParts.length; i++) { - var currPart = prefixParts.slice(0, i + 1).join('.'); - if (part.indexOf(currPart) !== 0) { - break; - } - currPrefix = currPart; - } + this.name = name; + }; - return currPrefix; - } + var TemplateElement = (function (_Element) { + babelHelpers.inherits(TemplateElement, _Element); - /* - Stolen from Controller - */ + function TemplateElement() { + babelHelpers.classCallCheck(this, TemplateElement); - function calculateCacheKey(prefix, _parts, values) { - var parts = _parts || []; - var suffixes = ''; - for (var i = 0; i < parts.length; ++i) { - var part = parts[i]; - var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); - var value = undefined; - if (values) { - if (cacheValuePrefix && cacheValuePrefix in values) { - var partRemovedPrefix = part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part; - value = _emberMetal.get(values[cacheValuePrefix], partRemovedPrefix); - } else { - value = _emberMetal.get(values, part); - } + _Element.apply(this, arguments); + } + + return TemplateElement; + })(Element); + + var EngineElement = (function (_Element2) { + babelHelpers.inherits(EngineElement, _Element2); + + function EngineElement() { + babelHelpers.classCallCheck(this, EngineElement); + + _Element2.apply(this, arguments); } - suffixes += '::' + part + ':' + value; - } - return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); - } - /* - Controller-defined query parameters can come in three shapes: - - Array - queryParams: ['foo', 'bar'] - Array of simple objects where value is an alias - queryParams: [ - { - 'foo': 'rename_foo_to_this' - }, - { - 'bar': 'call_bar_this_instead' + return EngineElement; + })(Element); + + DebugStack = (function () { + function DebugStack() { + babelHelpers.classCallCheck(this, DebugStack); + + this._stack = []; + } + + DebugStack.prototype.push = function push(name) { + this._stack.push(new TemplateElement(name)); + }; + + DebugStack.prototype.pushEngine = function pushEngine(name) { + this._stack.push(new EngineElement(name)); + }; + + DebugStack.prototype.pop = function pop() { + var element = this._stack.pop(); + + if (element) { + return element.name; } - ] - Array of fully defined objects - queryParams: [ - { - 'foo': { - as: 'rename_foo_to_this' - }, + }; + + DebugStack.prototype.peek = function peek() { + var template = this._currentTemplate(); + var engine = this._currentEngine(); + + if (engine) { + return '"' + template + '" (in "' + engine + '")'; + } else if (template) { + return '"' + template + '"'; } - { - 'bar': { - as: 'call_bar_this_instead', - scope: 'controller' + }; + + DebugStack.prototype._currentTemplate = function _currentTemplate() { + return this._getCurrentByType(TemplateElement); + }; + + DebugStack.prototype._currentEngine = function _currentEngine() { + return this._getCurrentByType(EngineElement); + }; + + DebugStack.prototype._getCurrentByType = function _getCurrentByType(type) { + for (var i = this._stack.length; i >= 0; i--) { + var element = this._stack[i]; + if (element instanceof type) { + return element.name; } } - ] - - This helper normalizes all three possible styles into the - 'Array of fully defined objects' style. - */ + }; - function normalizeControllerQueryParams(queryParams) { - var qpMap = {}; + return DebugStack; + })(); + }); - for (var i = 0; i < queryParams.length; ++i) { - accumulateQueryParamDescriptors(queryParams[i], qpMap); + exports.default = DebugStack; +}); +enifed('ember-glimmer/utils/iterable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', '@glimmer/reference'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerReference) { + 'use strict'; + + exports.default = iterableFor; + + var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; + + function iterableFor(ref, keyPath) { + if (_emberGlimmerHelpersEachIn.isEachIn(ref)) { + return new EachInIterable(ref, keyForEachIn(keyPath)); + } else { + return new ArrayIterable(ref, keyForArray(keyPath)); } + } - return qpMap; + function keyForEachIn(keyPath) { + switch (keyPath) { + case '@index': + case undefined: + case null: + return index; + case '@identity': + return identity; + default: + return function (item) { + return _emberMetal.get(item, keyPath); + }; + } } - function accumulateQueryParamDescriptors(_desc, accum) { - var desc = _desc; - var tmp = undefined; - if (typeof desc === 'string') { - tmp = {}; - tmp[desc] = { as: null }; - desc = tmp; + function keyForArray(keyPath) { + switch (keyPath) { + case '@index': + return index; + case '@identity': + case undefined: + case null: + return identity; + default: + return function (item) { + return _emberMetal.get(item, keyPath); + }; } + } - for (var key in desc) { - if (!desc.hasOwnProperty(key)) { - return; - } + function index(item, index) { + return String(index); + } - var singleDesc = desc[key]; - if (typeof singleDesc === 'string') { - singleDesc = { as: singleDesc }; - } + function identity(item) { + switch (typeof item) { + case 'string': + case 'number': + return String(item); + default: + return _emberUtils.guidFor(item); + } + } - tmp = accum[key] || { as: null, scope: 'model' }; - _emberUtils.assign(tmp, singleDesc); + function ensureUniqueKey(seen, key) { + var seenCount = seen[key]; - accum[key] = tmp; + if (seenCount) { + seen[key]++; + return '' + key + ITERATOR_KEY_GUID + seenCount; + } else { + seen[key] = 1; } - } - /* - Check if a routeName resembles a url instead - - @private - */ - function resemblesURL(str) { - return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); + return key; } - /* - Returns an arguments array where the route name arg is prefixed based on the mount point - - @private - */ + var ArrayIterator = (function () { + function ArrayIterator(array, keyFor) { + babelHelpers.classCallCheck(this, ArrayIterator); - function prefixRouteNameArg(route, args) { - var routeName = args[0]; - var owner = _emberUtils.getOwner(route); - var prefix = owner.mountPoint; + this.array = array; + this.length = array.length; + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); + } - // only alter the routeName if it's actually referencing a route. - if (owner.routable && typeof routeName === 'string') { - if (resemblesURL(routeName)) { - throw new _emberMetal.Error('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'); - } else { - routeName = prefix + '.' + routeName; - args[0] = routeName; + ArrayIterator.prototype.isEmpty = function isEmpty() { + return false; + }; + + ArrayIterator.prototype.next = function next() { + var array = this.array; + var length = this.length; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; + + if (position >= length) { + return null; } - } - return args; - } -}); -enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeMixinsComparable) { - 'use strict'; + var value = array[position]; + var memo = position; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - exports.default = compare; + this.position++; - var TYPE_ORDER = { - 'undefined': 0, - 'null': 1, - 'boolean': 2, - 'number': 3, - 'string': 4, - 'array': 5, - 'object': 6, - 'instance': 7, - 'function': 8, - 'class': 9, - 'date': 10 - }; + return { key: key, value: value, memo: memo }; + }; - // - // the spaceship operator - // - // `. ___ - // __,' __`. _..----....____ - // __...--.'``;. ,. ;``--..__ .' ,-._ _.-' - // _..-''-------' `' `' `' O ``-''._ (,;') _,' - // ,'________________ \`-._`-',' - // `._ ```````````------...___ '-.._'-: - // ```--.._ ,. ````--...__\-. - // `.--. `-` "INFINITY IS LESS ____ | |` - // `. `. THAN BEYOND" ,'`````. ; ;` - // `._`. __________ `. \'__/` - // `-:._____/______/___/____`. \ ` - // | `._ `. \ - // `._________`-. `. `.___ - // SSt `------'` - function spaceship(a, b) { - var diff = a - b; - return (diff > 0) - (diff < 0); - } + return ArrayIterator; + })(); - /** - Compares two javascript values and returns: - - - -1 if the first is smaller than the second, - - 0 if both are equal, - - 1 if the first is greater than the second. - - ```javascript - Ember.compare('hello', 'hello'); // 0 - Ember.compare('abc', 'dfg'); // -1 - Ember.compare(2, 1); // 1 - ``` - - If the types of the two objects are different precedence occurs in the - following order, with types earlier in the list considered `<` types - later in the list: - - - undefined - - null - - boolean - - number - - string - - array - - object - - instance - - function - - class - - date - - ```javascript - Ember.compare('hello', 50); // 1 - Ember.compare(50, 'hello'); // -1 - ``` - - @method compare - @for Ember - @param {Object} v First value to compare - @param {Object} w Second value to compare - @return {Number} -1 if v < w, 0 if v = w and 1 if v > w. - @public - */ + var EmberArrayIterator = (function () { + function EmberArrayIterator(array, keyFor) { + babelHelpers.classCallCheck(this, EmberArrayIterator); - function compare(v, w) { - if (v === w) { - return 0; + this.array = array; + this.length = _emberMetal.get(array, 'length'); + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); } - var type1 = _emberRuntimeUtils.typeOf(v); - var type2 = _emberRuntimeUtils.typeOf(w); + EmberArrayIterator.prototype.isEmpty = function isEmpty() { + return this.length === 0; + }; - if (_emberRuntimeMixinsComparable.default) { - if (type1 === 'instance' && _emberRuntimeMixinsComparable.default.detect(v) && v.constructor.compare) { - return v.constructor.compare(v, w); - } + EmberArrayIterator.prototype.next = function next() { + var array = this.array; + var length = this.length; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; - if (type2 === 'instance' && _emberRuntimeMixinsComparable.default.detect(w) && w.constructor.compare) { - return w.constructor.compare(w, v) * -1; + if (position >= length) { + return null; } - } - var res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); + var value = _emberRuntime.objectAt(array, position); + var memo = position; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - if (res !== 0) { - return res; - } + this.position++; - // types are equal - so we have to check values now - switch (type1) { - case 'boolean': - case 'number': - return spaceship(v, w); + return { key: key, value: value, memo: memo }; + }; - case 'string': - return spaceship(v.localeCompare(w), 0); + return EmberArrayIterator; + })(); - case 'array': - var vLen = v.length; - var wLen = w.length; - var len = Math.min(vLen, wLen); - - for (var i = 0; i < len; i++) { - var r = compare(v[i], w[i]); - if (r !== 0) { - return r; - } - } + var ObjectKeysIterator = (function () { + function ObjectKeysIterator(keys, values, keyFor) { + babelHelpers.classCallCheck(this, ObjectKeysIterator); - // all elements are equal now - // shorter array should be ordered first - return spaceship(vLen, wLen); + this.keys = keys; + this.values = values; + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); + } - case 'instance': - if (_emberRuntimeMixinsComparable.default && _emberRuntimeMixinsComparable.default.detect(v)) { - return v.compare(v, w); - } - return 0; + ObjectKeysIterator.prototype.isEmpty = function isEmpty() { + return this.keys.length === 0; + }; - case 'date': - return spaceship(v.getTime(), w.getTime()); + ObjectKeysIterator.prototype.next = function next() { + var keys = this.keys; + var values = this.values; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; - default: - return 0; - } - } -}); -enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + if (position >= keys.length) { + return null; + } - exports.empty = empty; - exports.notEmpty = notEmpty; - exports.none = none; - exports.not = not; - exports.bool = bool; - exports.match = match; - exports.equal = equal; - exports.gt = gt; - exports.gte = gte; - exports.lt = lt; - exports.lte = lte; - exports.oneWay = oneWay; - exports.readOnly = readOnly; - exports.deprecatingAlias = deprecatingAlias; + var value = values[position]; + var memo = keys[position]; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - /** - @module ember - @submodule ember-metal - */ + this.position++; - function expandPropertiesToArray(predicateName, properties) { - var expandedProperties = []; + return { key: key, value: value, memo: memo }; + }; - function extractProperty(entry) { - expandedProperties.push(entry); + return ObjectKeysIterator; + })(); + + var EmptyIterator = (function () { + function EmptyIterator() { + babelHelpers.classCallCheck(this, EmptyIterator); } - for (var i = 0; i < properties.length; i++) { - var property = properties[i]; - _emberMetal.assert('Dependent keys passed to Ember.computed.' + predicateName + '() can\'t have spaces.', property.indexOf(' ') < 0); + EmptyIterator.prototype.isEmpty = function isEmpty() { + return true; + }; - _emberMetal.expandProperties(property, extractProperty); - } + EmptyIterator.prototype.next = function next() { + throw new Error('Cannot call next() on an empty iterator'); + }; - return expandedProperties; - } + return EmptyIterator; + })(); - function generateComputedWithPredicate(name, predicate) { - return function () { - for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) { - properties[_key] = arguments[_key]; - } + var EMPTY_ITERATOR = new EmptyIterator(); - var expandedProperties = expandPropertiesToArray(name, properties); + var EachInIterable = (function () { + function EachInIterable(ref, keyFor) { + babelHelpers.classCallCheck(this, EachInIterable); - var computedFunc = _emberMetal.computed(function () { - var lastIdx = expandedProperties.length - 1; + this.ref = ref; + this.keyFor = keyFor; - for (var i = 0; i < lastIdx; i++) { - var value = _emberMetal.get(this, expandedProperties[i]); - if (!predicate(value)) { - return value; - } - } + var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - return _emberMetal.get(this, expandedProperties[lastIdx]); - }); + this.tag = _glimmerReference.combine([ref.tag, valueTag]); + } - return computedFunc.property.apply(computedFunc, expandedProperties); - }; - } + EachInIterable.prototype.iterate = function iterate() { + var ref = this.ref; + var keyFor = this.keyFor; + var valueTag = this.valueTag; - /** - A computed property that returns true if the value of the dependent - property is null, an empty string, empty array, or empty function. - - Example - - ```javascript - let ToDoList = Ember.Object.extend({ - isDone: Ember.computed.empty('todos') - }); - - let todoList = ToDoList.create({ - todos: ['Unit Test', 'Documentation', 'Release'] - }); - - todoList.get('isDone'); // false - todoList.get('todos').clear(); - todoList.get('isDone'); // true - ``` - - @since 1.6.0 - @method empty - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which negate - the original value for property - @public - */ + var iterable = ref.value(); - function empty(dependentKey) { - return _emberMetal.computed(dependentKey + '.length', function () { - return _emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); - }); - } + valueTag.update(_emberMetal.tagFor(iterable)); - /** - A computed property that returns true if the value of the dependent - property is NOT null, an empty string, empty array, or empty function. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasStuff: Ember.computed.notEmpty('backpack') - }); - - let hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); - - hamster.get('hasStuff'); // true - hamster.get('backpack').clear(); // [] - hamster.get('hasStuff'); // false - ``` - - @method notEmpty - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which returns true if - original value for property is not empty. - @public - */ + if (_emberMetal.isProxy(iterable)) { + iterable = _emberMetal.get(iterable, 'content'); + } - function notEmpty(dependentKey) { - return _emberMetal.computed(dependentKey + '.length', function () { - return !_emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); - }); - } + var typeofIterable = typeof iterable; - /** - A computed property that returns true if the value of the dependent - property is null or undefined. This avoids errors from JSLint complaining - about use of ==, which can be technically confusing. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - isHungry: Ember.computed.none('food') - }); - - let hamster = Hamster.create(); - - hamster.get('isHungry'); // true - hamster.set('food', 'Banana'); - hamster.get('isHungry'); // false - hamster.set('food', null); - hamster.get('isHungry'); // true - ``` - - @method none - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which - returns true if original value for property is null or undefined. - @public - */ + if (iterable && (typeofIterable === 'object' || typeofIterable === 'function')) { + var keys = Object.keys(iterable); + var values = keys.map(function (key) { + return iterable[key]; + }); + return keys.length > 0 ? new ObjectKeysIterator(keys, values, keyFor) : EMPTY_ITERATOR; + } else { + return EMPTY_ITERATOR; + } + }; - function none(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.isNone(_emberMetal.get(this, dependentKey)); - }); - } + // {{each-in}} yields |key value| instead of |value key|, so the memo and + // value are flipped - /** - A computed property that returns the inverse boolean value - of the original value for the dependent property. - - Example - - ```javascript - let User = Ember.Object.extend({ - isAnonymous: Ember.computed.not('loggedIn') - }); - - let user = User.create({loggedIn: false}); - - user.get('isAnonymous'); // true - user.set('loggedIn', true); - user.get('isAnonymous'); // false - ``` - - @method not - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which returns - inverse of the original value for property - @public - */ + EachInIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); + }; - function not(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return !_emberMetal.get(this, dependentKey); - }); - } + EachInIterable.prototype.updateValueReference = function updateValueReference(reference, item) { + reference.update(item.memo); + }; - /** - A computed property that converts the provided dependent property - into a boolean value. - - ```javascript - let Hamster = Ember.Object.extend({ - hasBananas: Ember.computed.bool('numBananas') - }); - - let hamster = Hamster.create(); - - hamster.get('hasBananas'); // false - hamster.set('numBananas', 0); - hamster.get('hasBananas'); // false - hamster.set('numBananas', 1); - hamster.get('hasBananas'); // true - hamster.set('numBananas', null); - hamster.get('hasBananas'); // false - ``` - - @method bool - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which converts - to boolean the original value for property - @public - */ + EachInIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); + }; - function bool(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return !!_emberMetal.get(this, dependentKey); - }); - } + EachInIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { + reference.update(item.value); + }; - /** - A computed property which matches the original value for the - dependent property against a given RegExp, returning `true` - if the value matches the RegExp and `false` if it does not. - - Example - - ```javascript - let User = Ember.Object.extend({ - hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) - }); - - let user = User.create({loggedIn: false}); - - user.get('hasValidEmail'); // false - user.set('email', ''); - user.get('hasValidEmail'); // false - user.set('email', 'ember_hamster@example.com'); - user.get('hasValidEmail'); // true - ``` - - @method match - @for Ember.computed - @param {String} dependentKey - @param {RegExp} regexp - @return {Ember.ComputedProperty} computed property which match - the original value for property against a given RegExp - @public - */ + return EachInIterable; + })(); - function match(dependentKey, regexp) { - return _emberMetal.computed(dependentKey, function () { - var value = _emberMetal.get(this, dependentKey); + var ArrayIterable = (function () { + function ArrayIterable(ref, keyFor) { + babelHelpers.classCallCheck(this, ArrayIterable); - return typeof value === 'string' ? regexp.test(value) : false; - }); - } + this.ref = ref; + this.keyFor = keyFor; - /** - A computed property that returns true if the provided dependent property - is equal to the given value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - napTime: Ember.computed.equal('state', 'sleepy') - }); - - let hamster = Hamster.create(); - - hamster.get('napTime'); // false - hamster.set('state', 'sleepy'); - hamster.get('napTime'); // true - hamster.set('state', 'hungry'); - hamster.get('napTime'); // false - ``` - - @method equal - @for Ember.computed - @param {String} dependentKey - @param {String|Number|Object} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is equal to the given value. - @public - */ + var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - function equal(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) === value; - }); - } + this.tag = _glimmerReference.combine([ref.tag, valueTag]); + } - /** - A computed property that returns true if the provided dependent property - is greater than the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasTooManyBananas: Ember.computed.gt('numBananas', 10) - }); - - let hamster = Hamster.create(); - - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 3); - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 11); - hamster.get('hasTooManyBananas'); // true - ``` - - @method gt - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is greater than given value. - @public - */ + ArrayIterable.prototype.iterate = function iterate() { + var ref = this.ref; + var keyFor = this.keyFor; + var valueTag = this.valueTag; - function gt(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) > value; - }); - } + var iterable = ref.value(); - /** - A computed property that returns true if the provided dependent property - is greater than or equal to the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasTooManyBananas: Ember.computed.gte('numBananas', 10) - }); - - let hamster = Hamster.create(); - - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 3); - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 10); - hamster.get('hasTooManyBananas'); // true - ``` - - @method gte - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is greater or equal then given value. - @public - */ + valueTag.update(_emberMetal.tagForProperty(iterable, '[]')); - function gte(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) >= value; - }); - } + if (!iterable || typeof iterable !== 'object') { + return EMPTY_ITERATOR; + } - /** - A computed property that returns true if the provided dependent property - is less than the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - needsMoreBananas: Ember.computed.lt('numBananas', 3) - }); - - let hamster = Hamster.create(); - - hamster.get('needsMoreBananas'); // true - hamster.set('numBananas', 3); - hamster.get('needsMoreBananas'); // false - hamster.set('numBananas', 2); - hamster.get('needsMoreBananas'); // true - ``` - - @method lt - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is less then given value. - @public - */ + if (Array.isArray(iterable)) { + return iterable.length > 0 ? new ArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; + } else if (_emberRuntime.isEmberArray(iterable)) { + return _emberMetal.get(iterable, 'length') > 0 ? new EmberArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; + } else if (typeof iterable.forEach === 'function') { + var _ret = (function () { + var array = []; + iterable.forEach(function (item) { + array.push(item); + }); + return { + v: array.length > 0 ? new ArrayIterator(array, keyFor) : EMPTY_ITERATOR + }; + })(); - function lt(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) < value; - }); - } + if (typeof _ret === 'object') return _ret.v; + } else { + return EMPTY_ITERATOR; + } + }; - /** - A computed property that returns true if the provided dependent property - is less than or equal to the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - needsMoreBananas: Ember.computed.lte('numBananas', 3) - }); - - let hamster = Hamster.create(); - - hamster.get('needsMoreBananas'); // true - hamster.set('numBananas', 5); - hamster.get('needsMoreBananas'); // false - hamster.set('numBananas', 3); - hamster.get('needsMoreBananas'); // true - ``` - - @method lte - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is less or equal than given value. - @public - */ + ArrayIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); + }; - function lte(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) <= value; - }); - } + ArrayIterable.prototype.updateValueReference = function updateValueReference(reference, item) { + reference.update(item.value); + }; - /** - A computed property that performs a logical `and` on the - original values for the provided dependent properties. - - You may pass in more than two properties and even use - property brace expansion. The computed property will - return the first falsy value or last truthy value - just like JavaScript's `&&` operator. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), - readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') - }); - - let tomster = Hamster.create(); - - tomster.get('readyForCamp'); // false - tomster.set('hasTent', true); - tomster.get('readyForCamp'); // false - tomster.set('hasBackpack', true); - tomster.get('readyForCamp'); // true - tomster.set('hasBackpack', 'Yes'); - tomster.get('readyForCamp'); // 'Yes' - tomster.set('hasWalkingStick', null); - tomster.get('readyForHike'); // null - ``` - - @method and - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which performs - a logical `and` on the values of all the original values for properties. - @public - */ - var and = generateComputedWithPredicate('and', function (value) { - return value; - }); + ArrayIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); + }; - exports.and = and; - /** - A computed property which performs a logical `or` on the - original values for the provided dependent properties. - - You may pass in more than two properties and even use - property brace expansion. The computed property will - return the first truthy value or last falsy value just - like JavaScript's `||` operator. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'), - readyForBeach: Ember.computed.or('{hasSunscreen,hasUmbrella}') - }); - - let tomster = Hamster.create(); - - tomster.get('readyForRain'); // undefined - tomster.set('hasUmbrella', true); - tomster.get('readyForRain'); // true - tomster.set('hasJacket', 'Yes'); - tomster.get('readyForRain'); // 'Yes' - tomster.set('hasSunscreen', 'Check'); - tomster.get('readyForBeach'); // 'Check' - ``` - - @method or - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which performs - a logical `or` on the values of all the original values for properties. - @public - */ - var or = generateComputedWithPredicate('or', function (value) { - return !value; - }); + ArrayIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { + reference.update(item.memo); + }; - exports.or = or; - /** - Creates a new property that is an alias for another property - on an object. Calls to `get` or `set` this property behave as - though they were called on the original property. - - ```javascript - let Person = Ember.Object.extend({ - name: 'Alex Matchneer', - nomen: Ember.computed.alias('name') - }); - - let alex = Person.create(); - - alex.get('nomen'); // 'Alex Matchneer' - alex.get('name'); // 'Alex Matchneer' - - alex.set('nomen', '@machty'); - alex.get('name'); // '@machty' - ``` - - @method alias - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates an - alias to the original value for property. - @public - */ + return ArrayIterable; + })(); +}); +enifed('ember-glimmer/utils/process-args', ['exports', 'ember-utils', '@glimmer/reference', 'ember-glimmer/component', 'ember-glimmer/utils/references', 'ember-views', 'ember-glimmer/helpers/action', '@glimmer/runtime'], function (exports, _emberUtils, _glimmerReference, _emberGlimmerComponent, _emberGlimmerUtilsReferences, _emberViews, _emberGlimmerHelpersAction, _glimmerRuntime) { + 'use strict'; - /** - Where `computed.alias` aliases `get` and `set`, and allows for bidirectional - data flow, `computed.oneWay` only provides an aliased `get`. The `set` will - not mutate the upstream property, rather causes the current property to - become the value set. This causes the downstream property to permanently - diverge from the upstream property. - - Example - - ```javascript - let User = Ember.Object.extend({ - firstName: null, - lastName: null, - nickName: Ember.computed.oneWay('firstName') - }); - - let teddy = User.create({ - firstName: 'Teddy', - lastName: 'Zeenny' - }); - - teddy.get('nickName'); // 'Teddy' - teddy.set('nickName', 'TeddyBear'); // 'TeddyBear' - teddy.get('firstName'); // 'Teddy' - ``` - - @method oneWay - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @public - */ + exports.gatherArgs = gatherArgs; + + // Maps all variants of positional and dynamically scoped arguments + // into the named arguments. Input `args` and return value are both + // `EvaluatedArgs`. - function oneWay(dependentKey) { - return _emberMetal.alias(dependentKey).oneWay(); + function gatherArgs(args, definition) { + var namedMap = gatherNamedMap(args, definition); + var positionalValues = gatherPositionalValues(args, definition); + return mergeArgs(namedMap, positionalValues, args.blocks, definition.ComponentClass.class); } - /** - This is a more semantically meaningful alias of `computed.oneWay`, - whose name is somewhat ambiguous as to which direction the data flows. - - @method reads - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @public - */ - - /** - Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides - a readOnly one way binding. Very often when using `computed.oneWay` one does - not also want changes to propagate back up, as they will replace the value. - - This prevents the reverse flow, and also throws an exception when it occurs. - - Example - - ```javascript - let User = Ember.Object.extend({ - firstName: null, - lastName: null, - nickName: Ember.computed.readOnly('firstName') - }); - - let teddy = User.create({ - firstName: 'Teddy', - lastName: 'Zeenny' - }); - - teddy.get('nickName'); // 'Teddy' - teddy.set('nickName', 'TeddyBear'); // throws Exception - // throw new Ember.Error('Cannot Set: nickName on: ' );` - teddy.get('firstName'); // 'Teddy' - ``` - - @method readOnly - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @since 1.5.0 - @public - */ + function gatherNamedMap(args, definition) { + var namedMap = args.named.map; + if (definition.args) { + return _emberUtils.assign({}, definition.args.named.map, namedMap); + } else { + return namedMap; + } + } - function readOnly(dependentKey) { - return _emberMetal.alias(dependentKey).readOnly(); + function gatherPositionalValues(args, definition) { + var positionalValues = args.positional.values; + if (definition.args) { + var oldPositional = definition.args.positional.values; + var newPositional = []; + newPositional.push.apply(newPositional, oldPositional); + newPositional.splice.apply(newPositional, [0, positionalValues.length].concat(positionalValues)); + return newPositional; + } else { + return positionalValues; + } } - /** - Creates a new property that is an alias for another property - on an object. Calls to `get` or `set` this property behave as - though they were called on the original property, but also - print a deprecation warning. - - ```javascript - let Hamster = Ember.Object.extend({ - bananaCount: Ember.computed.deprecatingAlias('cavendishCount', { - id: 'hamster.deprecate-banana', - until: '3.0.0' - }) - }); - - let hamster = Hamster.create(); - - hamster.set('bananaCount', 5); // Prints a deprecation warning. - hamster.get('cavendishCount'); // 5 - ``` - - @method deprecatingAlias - @for Ember.computed - @param {String} dependentKey - @param {Object} options Options for `Ember.deprecate`. - @return {Ember.ComputedProperty} computed property which creates an - alias with a deprecation to the original value for property. - @since 1.7.0 - @public - */ + function mergeArgs(namedMap, positionalValues, blocks, componentClass) { + var positionalParamsDefinition = componentClass.positionalParams; - function deprecatingAlias(dependentKey, options) { - return _emberMetal.computed(dependentKey, { - get: function (key) { - _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); - return _emberMetal.get(this, dependentKey); - }, - set: function (key, value) { - _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); - _emberMetal.set(this, dependentKey, value); - return value; + if (positionalParamsDefinition && positionalParamsDefinition.length > 0 && positionalValues.length > 0) { + if (typeof positionalParamsDefinition === 'string') { + namedMap = mergeRestArg(namedMap, positionalValues, positionalParamsDefinition); + } else { + namedMap = mergePositionalParams(namedMap, positionalValues, positionalParamsDefinition); } - }); + } + return _glimmerRuntime.EvaluatedArgs.named(namedMap, blocks); } -}); -enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) { - /** - @module ember - @submodule ember-runtime - */ - 'use strict'; - - exports.sum = sum; - exports.max = max; - exports.min = min; - exports.map = map; - exports.mapBy = mapBy; - exports.filter = filter; - exports.filterBy = filterBy; - exports.uniq = uniq; - exports.uniqBy = uniqBy; - exports.intersect = intersect; - exports.setDiff = setDiff; - exports.collect = collect; - exports.sort = sort; + var EMPTY_ARGS = { + tag: _glimmerReference.CONSTANT_TAG, + value: function () { + var _props; - function reduceMacro(dependentKey, callback, initialValue) { - return _emberMetal.computed(dependentKey + '.[]', function () { - var _this = this; + return { attrs: {}, props: (_props = { attrs: {} }, _props[_emberGlimmerComponent.ARGS] = {}, _props) }; + } + }; - var arr = _emberMetal.get(this, dependentKey); + // ComponentArgs takes EvaluatedNamedArgs and converts them into the + // inputs needed by CurlyComponents (attrs and props, with mutable + // cells, etc). - if (arr === null || typeof arr !== 'object') { - return initialValue; + var ComponentArgs = (function () { + ComponentArgs.create = function create(args) { + if (args.named.keys.length === 0) { + return EMPTY_ARGS; + } else { + return new ComponentArgs(args.named); } + }; - return arr.reduce(function (previousValue, currentValue, index, array) { - return callback.call(_this, previousValue, currentValue, index, array); - }, initialValue); - }).readOnly(); - } + function ComponentArgs(namedArgs) { + babelHelpers.classCallCheck(this, ComponentArgs); - function arrayMacro(dependentKey, callback) { - // This is a bit ugly - var propertyName = undefined; - if (/@each/.test(dependentKey)) { - propertyName = dependentKey.replace(/\.@each.*$/, ''); - } else { - propertyName = dependentKey; - dependentKey += '.[]'; + this.tag = namedArgs.tag; + this.namedArgs = namedArgs; } - return _emberMetal.computed(dependentKey, function () { - var value = _emberMetal.get(this, propertyName); - if (_emberRuntimeUtils.isArray(value)) { - return _emberRuntimeSystemNative_array.A(callback.call(this, value)); - } else { - return _emberRuntimeSystemNative_array.A(); + ComponentArgs.prototype.value = function value() { + var namedArgs = this.namedArgs; + + var keys = namedArgs.keys; + var attrs = namedArgs.value(); + var props = new _emberUtils.EmptyObject(); + var args = new _emberUtils.EmptyObject(); + + props[_emberGlimmerComponent.ARGS] = args; + + for (var i = 0, l = keys.length; i < l; i++) { + var _name = keys[i]; + var ref = namedArgs.get(_name); + var value = attrs[_name]; + + if (typeof value === 'function' && value[_emberGlimmerHelpersAction.ACTION]) { + attrs[_name] = value; + } else if (ref[_emberGlimmerUtilsReferences.UPDATE]) { + attrs[_name] = new MutableCell(ref, value); + } + + args[_name] = ref; + props[_name] = value; } - }).readOnly(); - } - function multiArrayMacro(dependentKeys, callback) { - var args = dependentKeys.map(function (key) { - return key + '.[]'; - }); + props.attrs = attrs; - args.push(function () { - return _emberRuntimeSystemNative_array.A(callback.call(this, dependentKeys)); - }); + return { attrs: attrs, props: props }; + }; - return _emberMetal.computed.apply(this, args).readOnly(); - } + return ComponentArgs; + })(); - /** - A computed property that returns the sum of the values - in the dependent array. - - @method sum - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the sum of all values in the dependentKey's array - @since 1.4.0 - @public - */ + exports.ComponentArgs = ComponentArgs; - function sum(dependentKey) { - return reduceMacro(dependentKey, function (sum, item) { - return sum + item; - }, 0); + function mergeRestArg(namedMap, positionalValues, restArgName) { + var mergedNamed = _emberUtils.assign({}, namedMap); + mergedNamed[restArgName] = _glimmerRuntime.EvaluatedPositionalArgs.create(positionalValues); + return mergedNamed; } - /** - A computed property that calculates the maximum value in the - dependent array. This will return `-Infinity` when the dependent - array is empty. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age'), - maxChildAge: Ember.computed.max('childAges') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('maxChildAge'); // -Infinity - lordByron.get('children').pushObject({ - name: 'Augusta Ada Byron', age: 7 - }); - lordByron.get('maxChildAge'); // 7 - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('maxChildAge'); // 8 - ``` - - If the types of the arguments are not numbers, - they will be converted to numbers and the type - of the return value will always be `Number`. - For example, the max of a list of Date objects will be - the highest timestamp as a `Number`. - This behavior is consistent with `Math.max`. - - @method max - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array - @public - */ - - function max(dependentKey) { - return reduceMacro(dependentKey, function (max, item) { - return Math.max(max, item); - }, -Infinity); + function mergePositionalParams(namedMap, values, positionalParamNames) { + var mergedNamed = _emberUtils.assign({}, namedMap); + var length = Math.min(values.length, positionalParamNames.length); + for (var i = 0; i < length; i++) { + var _name2 = positionalParamNames[i]; + mergedNamed[_name2] = values[i]; + } + return mergedNamed; } - /** - A computed property that calculates the minimum value in the - dependent array. This will return `Infinity` when the dependent - array is empty. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age'), - minChildAge: Ember.computed.min('childAges') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('minChildAge'); // Infinity - lordByron.get('children').pushObject({ - name: 'Augusta Ada Byron', age: 7 - }); - lordByron.get('minChildAge'); // 7 - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('minChildAge'); // 5 - ``` - - If the types of the arguments are not numbers, - they will be converted to numbers and the type - of the return value will always be `Number`. - For example, the min of a list of Date objects will be - the lowest timestamp as a `Number`. - This behavior is consistent with `Math.min`. - - @method min - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array - @public - */ + var REF = _emberUtils.symbol('REF'); - function min(dependentKey) { - return reduceMacro(dependentKey, function (min, item) { - return Math.min(min, item); - }, Infinity); - } + var MutableCell = (function () { + function MutableCell(ref, value) { + babelHelpers.classCallCheck(this, MutableCell); - /** - Returns an array mapped via the callback - - The callback method you provide should have the following signature. - `item` is the current item in the iteration. - `index` is the integer index of the current item in the iteration. - - ```javascript - function(item, index); - ``` - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - excitingChores: Ember.computed.map('chores', function(chore, index) { - return chore.toUpperCase() + '!'; - }) - }); - - let hamster = Hamster.create({ - chores: ['clean', 'write more unit tests'] - }); - - hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] - ``` - - @method map - @for Ember.computed - @param {String} dependentKey - @param {Function} callback - @return {Ember.ComputedProperty} an array mapped via the callback - @public - */ + this[_emberViews.MUTABLE_CELL] = true; + this[REF] = ref; + this.value = value; + } - function map(dependentKey, callback) { - return arrayMacro(dependentKey, function (value) { - return value.map(callback, this); - }); - } + MutableCell.prototype.update = function update(val) { + this[REF][_emberGlimmerUtilsReferences.UPDATE](val); + }; - /** - Returns an array mapped to the specified key. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('childAges'); // [] - lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); - lordByron.get('childAges'); // [7] - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('childAges'); // [7, 5, 8] - ``` - - @method mapBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @return {Ember.ComputedProperty} an array mapped to the specified key - @public - */ + return MutableCell; + })(); +}); +enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal', '@glimmer/reference', '@glimmer/runtime', 'ember-glimmer/utils/to-bool', 'ember-glimmer/helper'], function (exports, _emberUtils, _emberMetal, _glimmerReference, _glimmerRuntime, _emberGlimmerUtilsToBool, _emberGlimmerHelper) { + 'use strict'; + + var UPDATE = _emberUtils.symbol('UPDATE'); + + exports.UPDATE = UPDATE; + exports.NULL_REFERENCE = _glimmerRuntime.NULL_REFERENCE; + exports.UNDEFINED_REFERENCE = _glimmerRuntime.UNDEFINED_REFERENCE; + + // @abstract + // @implements PathReference + + var EmberPathReference = (function () { + function EmberPathReference() { + babelHelpers.classCallCheck(this, EmberPathReference); + } + + // @abstract + + // @abstract get tag() + // @abstract value() + + EmberPathReference.prototype.get = function get(key) { + return PropertyReference.create(this, key); + }; + + return EmberPathReference; + })(); + + var CachedReference = (function (_EmberPathReference) { + babelHelpers.inherits(CachedReference, _EmberPathReference); + + function CachedReference() { + babelHelpers.classCallCheck(this, CachedReference); + + _EmberPathReference.call(this); + this._lastRevision = null; + this._lastValue = null; + } + + // @implements PathReference + + CachedReference.prototype.value = function value() { + var tag = this.tag; + var _lastRevision = this._lastRevision; + var _lastValue = this._lastValue; + + if (!_lastRevision || !tag.validate(_lastRevision)) { + _lastValue = this._lastValue = this.compute(); + this._lastRevision = tag.value(); + } + + return _lastValue; + }; + + // @abstract compute() + return CachedReference; + })(EmberPathReference); + + exports.CachedReference = CachedReference; + + var RootReference = (function (_ConstReference) { + babelHelpers.inherits(RootReference, _ConstReference); + + function RootReference(value) { + babelHelpers.classCallCheck(this, RootReference); + + _ConstReference.call(this, value); + this.children = new _emberUtils.EmptyObject(); + } + + RootReference.prototype.get = function get(propertyKey) { + var ref = this.children[propertyKey]; + + if (!ref) { + ref = this.children[propertyKey] = new RootPropertyReference(this.inner, propertyKey); + } + + return ref; + }; + + return RootReference; + })(_glimmerReference.ConstReference); - function mapBy(dependentKey, propertyKey) { - _emberMetal.assert('Ember.computed.mapBy expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string'); + exports.RootReference = RootReference; - return map(dependentKey + '.@each.' + propertyKey, function (item) { - return _emberMetal.get(item, propertyKey); - }); - } + var TwoWayFlushDetectionTag = undefined; - /** - Filters the array by the callback. - - The callback method you provide should have the following signature. - `item` is the current item in the iteration. - `index` is the integer index of the current item in the iteration. - `array` is the dependant array itself. - - ```javascript - function(item, index, array); - ``` - - ```javascript - let Hamster = Ember.Object.extend({ - remainingChores: Ember.computed.filter('chores', function(chore, index, array) { - return !chore.done; - }) - }); - - let hamster = Hamster.create({ - chores: [ - { name: 'cook', done: true }, - { name: 'clean', done: true }, - { name: 'write more unit tests', done: false } - ] - }); - - hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] - ``` - - @method filter - @for Ember.computed - @param {String} dependentKey - @param {Function} callback - @return {Ember.ComputedProperty} the filtered array - @public - */ + if (true || false) { + TwoWayFlushDetectionTag = (function () { + function _class(tag, key, ref) { + babelHelpers.classCallCheck(this, _class); - function filter(dependentKey, callback) { - return arrayMacro(dependentKey, function (value) { - return value.filter(callback, this); - }); - } + this.tag = tag; + this.parent = null; + this.key = key; + this.ref = ref; + } - /** - Filters the array by the property and value - - ```javascript - let Hamster = Ember.Object.extend({ - remainingChores: Ember.computed.filterBy('chores', 'done', false) - }); - - let hamster = Hamster.create({ - chores: [ - { name: 'cook', done: true }, - { name: 'clean', done: true }, - { name: 'write more unit tests', done: false } - ] - }); - - hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] - ``` - - @method filterBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @param {*} value - @return {Ember.ComputedProperty} the filtered array - @public - */ + _class.prototype.value = function value() { + return this.tag.value(); + }; - function filterBy(dependentKey, propertyKey, value) { - var callback = undefined; + _class.prototype.validate = function validate(ticket) { + var parent = this.parent; + var key = this.key; - if (arguments.length === 2) { - callback = function (item) { - return _emberMetal.get(item, propertyKey); + var isValid = this.tag.validate(ticket); + + if (isValid && parent) { + _emberMetal.didRender(parent, key, this.ref); + } + + return isValid; }; - } else { - callback = function (item) { - return _emberMetal.get(item, propertyKey) === value; + + _class.prototype.didCompute = function didCompute(parent) { + this.parent = parent; + _emberMetal.didRender(parent, this.key, this.ref); }; - } - return filter(dependentKey + '.@each.' + propertyKey, callback); + return _class; + })(); } - /** - A computed property which returns a new array with all the unique - elements from one or more dependent arrays. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - uniqueFruits: Ember.computed.uniq('fruits') - }); - - let hamster = Hamster.create({ - fruits: [ - 'banana', - 'grape', - 'kale', - 'banana' - ] - }); - - hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale'] - ``` - - @method uniq - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ + var PropertyReference = (function (_CachedReference) { + babelHelpers.inherits(PropertyReference, _CachedReference); - function uniq() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + function PropertyReference() { + babelHelpers.classCallCheck(this, PropertyReference); + + _CachedReference.apply(this, arguments); } - return multiArrayMacro(args, function (dependentKeys) { - var _this2 = this; + PropertyReference.create = function create(parentReference, propertyKey) { + if (_glimmerReference.isConst(parentReference)) { + return new RootPropertyReference(parentReference.value(), propertyKey); + } else { + return new NestedPropertyReference(parentReference, propertyKey); + } + }; - var uniq = _emberRuntimeSystemNative_array.A(); + PropertyReference.prototype.get = function get(key) { + return new NestedPropertyReference(this, key); + }; - dependentKeys.forEach(function (dependentKey) { - var value = _emberMetal.get(_this2, dependentKey); - if (_emberRuntimeUtils.isArray(value)) { - value.forEach(function (item) { - if (uniq.indexOf(item) === -1) { - uniq.push(item); - } - }); - } - }); + return PropertyReference; + })(CachedReference); - return uniq; - }); - } + exports.PropertyReference = PropertyReference; - /** - A computed property which returns a new array with all the unique - elements from an array, with uniqueness determined by specific key. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - uniqueFruits: Ember.computed.uniqBy('fruits', 'id') - }); - let hamster = Hamster.create({ - fruits: [ - { id: 1, 'banana' }, - { id: 2, 'grape' }, - { id: 3, 'peach' }, - { id: 1, 'banana' } - ] - }); - hamster.get('uniqueFruits'); // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }] - ``` - - @method uniqBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ + var RootPropertyReference = (function (_PropertyReference) { + babelHelpers.inherits(RootPropertyReference, _PropertyReference); - function uniqBy(dependentKey, propertyKey) { - return _emberMetal.computed(dependentKey + '.[]', function () { - var uniq = _emberRuntimeSystemNative_array.A(); - var seen = new _emberUtils.EmptyObject(); - var list = _emberMetal.get(this, dependentKey); - if (_emberRuntimeUtils.isArray(list)) { - list.forEach(function (item) { - var guid = _emberUtils.guidFor(_emberMetal.get(item, propertyKey)); - if (!(guid in seen)) { - seen[guid] = true; - uniq.push(item); - } - }); - } - return uniq; - }).readOnly(); - } + function RootPropertyReference(parentValue, propertyKey) { + babelHelpers.classCallCheck(this, RootPropertyReference); - /** - Alias for [Ember.computed.uniq](/api/#method_computed_uniq). - - @method union - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ - var union = uniq; + _PropertyReference.call(this); - exports.union = union; - /** - A computed property which returns a new array with all the duplicated - elements from two or more dependent arrays. - - Example - - ```javascript - let obj = Ember.Object.extend({ - friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') - }).create({ - adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], - charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'] - }); - - obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] - ``` - - @method intersect - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - duplicated elements from the dependent arrays - @public - */ + this._parentValue = parentValue; + this._propertyKey = propertyKey; - function intersect() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + if (true || false) { + this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); + } else { + this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); + } + + if (true) { + _emberMetal.watchKey(parentValue, propertyKey); + } } - return multiArrayMacro(args, function (dependentKeys) { - var _this3 = this; + RootPropertyReference.prototype.compute = function compute() { + var _parentValue = this._parentValue; + var _propertyKey = this._propertyKey; - var arrays = dependentKeys.map(function (dependentKey) { - var array = _emberMetal.get(_this3, dependentKey); + if (true || false) { + this.tag.didCompute(_parentValue); + } - return _emberRuntimeUtils.isArray(array) ? array : []; - }); + return _emberMetal.get(_parentValue, _propertyKey); + }; - var results = arrays.pop().filter(function (candidate) { - for (var i = 0; i < arrays.length; i++) { - var found = false; - var array = arrays[i]; - for (var j = 0; j < array.length; j++) { - if (array[j] === candidate) { - found = true; - break; - } - } + RootPropertyReference.prototype[UPDATE] = function (value) { + _emberMetal.set(this._parentValue, this._propertyKey, value); + }; - if (found === false) { - return false; - } - } + return RootPropertyReference; + })(PropertyReference); - return true; - }); + exports.RootPropertyReference = RootPropertyReference; - return _emberRuntimeSystemNative_array.A(results); - }); - } + var NestedPropertyReference = (function (_PropertyReference2) { + babelHelpers.inherits(NestedPropertyReference, _PropertyReference2); - /** - A computed property which returns a new array with all the - properties from the first dependent array that are not in the second - dependent array. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - likes: ['banana', 'grape', 'kale'], - wants: Ember.computed.setDiff('likes', 'fruits') - }); - - let hamster = Hamster.create({ - fruits: [ - 'grape', - 'kale', - ] - }); - - hamster.get('wants'); // ['banana'] - ``` - - @method setDiff - @for Ember.computed - @param {String} setAProperty - @param {String} setBProperty - @return {Ember.ComputedProperty} computes a new array with all the - items from the first dependent array that are not in the second - dependent array - @public - */ + function NestedPropertyReference(parentReference, propertyKey) { + babelHelpers.classCallCheck(this, NestedPropertyReference); - function setDiff(setAProperty, setBProperty) { - if (arguments.length !== 2) { - throw new _emberMetal.Error('setDiff requires exactly two dependent arrays.'); - } + _PropertyReference2.call(this); - return _emberMetal.computed(setAProperty + '.[]', setBProperty + '.[]', function () { - var setA = this.get(setAProperty); - var setB = this.get(setBProperty); + var parentReferenceTag = parentReference.tag; + var parentObjectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - if (!_emberRuntimeUtils.isArray(setA)) { - return _emberRuntimeSystemNative_array.A(); - } - if (!_emberRuntimeUtils.isArray(setB)) { - return _emberRuntimeSystemNative_array.A(setA); + this._parentReference = parentReference; + this._parentObjectTag = parentObjectTag; + this._propertyKey = propertyKey; + + if (true || false) { + var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); + this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); + } else { + this.tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); } + } - return setA.filter(function (x) { - return setB.indexOf(x) === -1; - }); - }).readOnly(); - } + NestedPropertyReference.prototype.compute = function compute() { + var _parentReference = this._parentReference; + var _parentObjectTag = this._parentObjectTag; + var _propertyKey = this._propertyKey; - /** - A computed property that returns the array of values - for the provided dependent properties. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - clothes: Ember.computed.collect('hat', 'shirt') - }); - - let hamster = Hamster.create(); - - hamster.get('clothes'); // [null, null] - hamster.set('hat', 'Camp Hat'); - hamster.set('shirt', 'Camp Shirt'); - hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] - ``` - - @method collect - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which maps - values of all passed in properties to an array. - @public - */ + var parentValue = _parentReference.value(); - function collect() { - for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - dependentKeys[_key3] = arguments[_key3]; - } + _parentObjectTag.update(_emberMetal.tagForProperty(parentValue, _propertyKey)); - return multiArrayMacro(dependentKeys, function () { - var properties = _emberMetal.getProperties(this, dependentKeys); - var res = _emberRuntimeSystemNative_array.A(); - for (var key in properties) { - if (properties.hasOwnProperty(key)) { - if (_emberMetal.isNone(properties[key])) { - res.push(null); - } else { - res.push(properties[key]); - } - } + if (typeof parentValue === 'string' && _propertyKey === 'length') { + return parentValue.length; } - return res; - }); - } - /** - A computed property which returns a new array with all the - properties from the first dependent array sorted based on a property - or sort function. - - The callback method you provide should have the following signature: - - ```javascript - function(itemA, itemB); - ``` - - - `itemA` the first item to compare. - - `itemB` the second item to compare. - - This function should return negative number (e.g. `-1`) when `itemA` should come before - `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after - `itemB`. If the `itemA` and `itemB` are equal this function should return `0`. - - Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or - `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`. - - Example - - ```javascript - let ToDoList = Ember.Object.extend({ - // using standard ascending sort - todosSorting: ['name'], - sortedTodos: Ember.computed.sort('todos', 'todosSorting'), - - // using descending sort - todosSortingDesc: ['name:desc'], - sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), - - // using a custom sort function - priorityTodos: Ember.computed.sort('todos', function(a, b){ - if (a.priority > b.priority) { - return 1; - } else if (a.priority < b.priority) { - return -1; + if (typeof parentValue === 'object' && parentValue) { + if (true) { + _emberMetal.watchKey(parentValue, _propertyKey); + } + + if (true || false) { + this.tag.didCompute(parentValue); } - - return 0; - }) - }); - - let todoList = ToDoList.create({todos: [ - { name: 'Unit Test', priority: 2 }, - { name: 'Documentation', priority: 3 }, - { name: 'Release', priority: 1 } - ]}); - - todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }] - todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }] - todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }] - ``` - - @method sort - @for Ember.computed - @param {String} itemsKey - @param {String or Function} sortDefinition a dependent key to an - array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting - @return {Ember.ComputedProperty} computes a new sorted array based - on the sort property array or callback function - @public - */ - function sort(itemsKey, sortDefinition) { - _emberMetal.assert('Ember.computed.sort requires two arguments: an array key to sort and ' + 'either a sort properties key or sort function', arguments.length === 2); + return _emberMetal.get(parentValue, _propertyKey); + } else { + return undefined; + } + }; - if (typeof sortDefinition === 'function') { - return customSort(itemsKey, sortDefinition); - } else { - return propertySort(itemsKey, sortDefinition); - } - } + NestedPropertyReference.prototype[UPDATE] = function (value) { + var parent = this._parentReference.value(); + _emberMetal.set(parent, this._propertyKey, value); + }; - function customSort(itemsKey, comparator) { - return arrayMacro(itemsKey, function (value) { - var _this4 = this; + return NestedPropertyReference; + })(PropertyReference); - return value.slice().sort(function (x, y) { - return comparator.call(_this4, x, y); - }); - }); - } + exports.NestedPropertyReference = NestedPropertyReference; - // This one needs to dynamically set up and tear down observers on the itemsKey - // depending on the sortProperties - function propertySort(itemsKey, sortPropertiesKey) { - var cp = new _emberMetal.ComputedProperty(function (key) { - var _this5 = this; + var UpdatableReference = (function (_EmberPathReference2) { + babelHelpers.inherits(UpdatableReference, _EmberPathReference2); - var itemsKeyIsAtThis = itemsKey === '@this'; - var sortProperties = _emberMetal.get(this, sortPropertiesKey); + function UpdatableReference(value) { + babelHelpers.classCallCheck(this, UpdatableReference); - _emberMetal.assert('The sort definition for \'' + key + '\' on ' + this + ' must be a function or an array of strings', _emberRuntimeUtils.isArray(sortProperties) && sortProperties.every(function (s) { - return typeof s === 'string'; - })); + _EmberPathReference2.call(this); - var normalizedSortProperties = normalizeSortProperties(sortProperties); + this.tag = new _glimmerReference.DirtyableTag(); + this._value = value; + } - // Add/remove property observers as required. - var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetal.WeakMap()); - var activeObservers = activeObserversMap.get(this); + UpdatableReference.prototype.value = function value() { + return this._value; + }; - if (activeObservers) { - activeObservers.forEach(function (args) { - return _emberMetal.removeObserver.apply(null, args); - }); + UpdatableReference.prototype.update = function update(value) { + var _value = this._value; + + if (value !== _value) { + this.tag.dirty(); + this._value = value; } + }; - function sortPropertyDidChange() { - this.notifyPropertyChange(key); + return UpdatableReference; + })(EmberPathReference); + + exports.UpdatableReference = UpdatableReference; + + var UpdatablePrimitiveReference = (function (_UpdatableReference) { + babelHelpers.inherits(UpdatablePrimitiveReference, _UpdatableReference); + + function UpdatablePrimitiveReference() { + babelHelpers.classCallCheck(this, UpdatablePrimitiveReference); + + _UpdatableReference.apply(this, arguments); + } + + UpdatablePrimitiveReference.prototype.get = function get() { + return _glimmerRuntime.UNDEFINED_REFERENCE; + }; + + return UpdatablePrimitiveReference; + })(UpdatableReference); + + exports.UpdatablePrimitiveReference = UpdatablePrimitiveReference; + + var ConditionalReference = (function (_GlimmerConditionalReference) { + babelHelpers.inherits(ConditionalReference, _GlimmerConditionalReference); + + ConditionalReference.create = function create(reference) { + if (_glimmerReference.isConst(reference)) { + var value = reference.value(); + + if (_emberMetal.isProxy(value)) { + return new RootPropertyReference(value, 'isTruthy'); + } else { + return _glimmerRuntime.PrimitiveReference.create(_emberGlimmerUtilsToBool.default(value)); + } } - activeObservers = normalizedSortProperties.map(function (_ref) { - var prop = _ref[0]; + return new ConditionalReference(reference); + }; - var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; - var args = [_this5, path, sortPropertyDidChange]; - _emberMetal.addObserver.apply(null, args); - return args; - }); + function ConditionalReference(reference) { + babelHelpers.classCallCheck(this, ConditionalReference); - activeObserversMap.set(this, activeObservers); + _GlimmerConditionalReference.call(this, reference); - // Sort and return the array. - var items = itemsKeyIsAtThis ? this : _emberMetal.get(this, itemsKey); + this.objectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + this.tag = _glimmerReference.combine([reference.tag, this.objectTag]); + } - if (_emberRuntimeUtils.isArray(items)) { - return sortByNormalizedSortProperties(items, normalizedSortProperties); + ConditionalReference.prototype.toBool = function toBool(predicate) { + if (_emberMetal.isProxy(predicate)) { + this.objectTag.update(_emberMetal.tagForProperty(predicate, 'isTruthy')); + return _emberMetal.get(predicate, 'isTruthy'); } else { - return _emberRuntimeSystemNative_array.A(); + this.objectTag.update(_emberMetal.tagFor(predicate)); + return _emberGlimmerUtilsToBool.default(predicate); } - }); + }; - cp._activeObserverMap = undefined; + return ConditionalReference; + })(_glimmerRuntime.ConditionalReference); - return cp.property(sortPropertiesKey + '.[]').readOnly(); - } + exports.ConditionalReference = ConditionalReference; - function normalizeSortProperties(sortProperties) { - return sortProperties.map(function (p) { - var _p$split = p.split(':'); + var SimpleHelperReference = (function (_CachedReference2) { + babelHelpers.inherits(SimpleHelperReference, _CachedReference2); - var prop = _p$split[0]; - var direction = _p$split[1]; + SimpleHelperReference.create = function create(helper, args) { + if (_glimmerReference.isConst(args)) { + var _ret = (function () { + var positional = args.positional; + var named = args.named; - direction = direction || 'asc'; + var positionalValue = positional.value(); + var namedValue = named.value(); - return [prop, direction]; - }); - } + _emberMetal.runInDebug(function () { + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + Object.freeze(positionalValue); + Object.freeze(namedValue); + } + }); - 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 = helper(positionalValue, namedValue); - var result = _emberRuntimeCompare.default(_emberMetal.get(itemA, prop), _emberMetal.get(itemB, prop)); - if (result !== 0) { - return direction === 'desc' ? -1 * result : result; - } + if (result === null) { + return { + v: _glimmerRuntime.NULL_REFERENCE + }; + } else if (result === undefined) { + return { + v: _glimmerRuntime.UNDEFINED_REFERENCE + }; + } else if (typeof result === 'object') { + return { + v: new RootReference(result) + }; + } else { + return { + v: _glimmerRuntime.PrimitiveReference.create(result) + }; + } + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return new SimpleHelperReference(helper, args); } + }; - return 0; - })); - } -}); -enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) { - 'use strict'; + function SimpleHelperReference(helper, args) { + babelHelpers.classCallCheck(this, SimpleHelperReference); - /** - @module ember - @submodule ember-runtime - */ + _CachedReference2.call(this); - /** - @class Controller - @namespace Ember - @extends Ember.Object - @uses Ember.ControllerMixin - @public - */ - var Controller = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsController.default); + this.tag = args.tag; + this.helper = helper; + this.args = args; + } - _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions(Controller); + SimpleHelperReference.prototype.compute = function compute() { + var helper = this.helper; + var _args = this.args; + var positional = _args.positional; + var named = _args.named; - function controllerInjectionHelper(factory) { - _emberMetal.assert('Defining an injected controller property on a ' + 'non-controller is not allowed.', _emberRuntimeMixinsController.default.detect(factory.PrototypeMixin)); - } + var positionalValue = positional.value(); + var namedValue = named.value(); - /** - Creates a property that lazily looks up another controller in the container. - Can only be used when defining another controller. - - Example: - - ```javascript - App.PostController = Ember.Controller.extend({ - posts: Ember.inject.controller() - }); - ``` - - This example will create a `posts` property on the `post` controller that - looks up the `posts` controller in the container, making it easy to - reference other controllers. This is functionally equivalent to: - - ```javascript - App.PostController = Ember.Controller.extend({ - needs: 'posts', - posts: Ember.computed.alias('controllers.posts') - }); - ``` - - @method controller - @since 1.10.0 - @for Ember.inject - @param {String} name (optional) name of the controller to inject, defaults - to the property's name - @return {Ember.InjectedProperty} injection descriptor instance - @public - */ - _emberRuntimeInject.createInjectionHelper('controller', controllerInjectionHelper); + _emberMetal.runInDebug(function () { + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + Object.freeze(positionalValue); + Object.freeze(namedValue); + } + }); - exports.default = Controller; -}); -enifed('ember-runtime/copy', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) { - 'use strict'; + return helper(positionalValue, namedValue); + }; - exports.default = copy; + return SimpleHelperReference; + })(CachedReference); - function _copy(obj, deep, seen, copies) { - var ret = undefined, - loc = undefined, - key = undefined; + exports.SimpleHelperReference = SimpleHelperReference; - // primitive data types are immutable, just return them. - if (typeof obj !== 'object' || obj === null) { - return obj; - } + var ClassBasedHelperReference = (function (_CachedReference3) { + babelHelpers.inherits(ClassBasedHelperReference, _CachedReference3); - // avoid cyclical loops - if (deep && (loc = seen.indexOf(obj)) >= 0) { - return copies[loc]; - } + ClassBasedHelperReference.create = function create(helperClass, vm, args) { + var instance = helperClass.create(); + vm.newDestroyable(instance); + return new ClassBasedHelperReference(instance, args); + }; - _emberMetal.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof _emberRuntimeSystemObject.default) || _emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)); + function ClassBasedHelperReference(instance, args) { + babelHelpers.classCallCheck(this, ClassBasedHelperReference); - // IMPORTANT: this specific test will detect a native array only. Any other - // object will need to implement Copyable. - if (Array.isArray(obj)) { - ret = obj.slice(); + _CachedReference3.call(this); - if (deep) { - loc = ret.length; + this.tag = _glimmerReference.combine([instance[_emberGlimmerHelper.RECOMPUTE_TAG], args.tag]); + this.instance = instance; + this.args = args; + } - while (--loc >= 0) { - ret[loc] = _copy(ret[loc], deep, seen, copies); - } - } - } else if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { - ret = obj.copy(deep, seen, copies); - } else if (obj instanceof Date) { - ret = new Date(obj.getTime()); - } else { - ret = {}; + ClassBasedHelperReference.prototype.compute = function compute() { + var instance = this.instance; + var _args2 = this.args; + var positional = _args2.positional; + var named = _args2.named; - for (key in obj) { - // support Null prototype - if (!Object.prototype.hasOwnProperty.call(obj, key)) { - continue; - } + var positionalValue = positional.value(); + var namedValue = named.value(); - // Prevents browsers that don't respect non-enumerability from - // copying internal Ember properties - if (key.substring(0, 2) === '__') { - continue; + _emberMetal.runInDebug(function () { + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + Object.freeze(positionalValue); + Object.freeze(namedValue); } + }); - ret[key] = deep ? _copy(obj[key], deep, seen, copies) : obj[key]; - } - } + return instance.compute(positionalValue, namedValue); + }; - if (deep) { - seen.push(obj); - copies.push(ret); - } + return ClassBasedHelperReference; + })(CachedReference); - return ret; - } + exports.ClassBasedHelperReference = ClassBasedHelperReference; - /** - Creates a shallow copy of the passed object. A deep copy of the object is - returned if the optional `deep` argument is `true`. - - If the passed object implements the `Ember.Copyable` interface, then this - function will delegate to the object's `copy()` method and return the - result. See `Ember.Copyable` for further details. - - For primitive values (which are immutable in JavaScript), the passed object - is simply returned. - - @method copy - @for Ember - @param {Object} obj The object to clone - @param {Boolean} [deep=false] If true, a deep copy of the object is made. - @return {Object} The copied object - @public - */ + var InternalHelperReference = (function (_CachedReference4) { + babelHelpers.inherits(InternalHelperReference, _CachedReference4); - function copy(obj, deep) { - // fast paths - if ('object' !== typeof obj || obj === null) { - return obj; // can't copy primitives + function InternalHelperReference(helper, args) { + babelHelpers.classCallCheck(this, InternalHelperReference); + + _CachedReference4.call(this); + + this.tag = args.tag; + this.helper = helper; + this.args = args; } - if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { - return obj.copy(deep); + // @implements PathReference + + InternalHelperReference.prototype.compute = function compute() { + var helper = this.helper; + var args = this.args; + + return helper(args); + }; + + return InternalHelperReference; + })(CachedReference); + + exports.InternalHelperReference = InternalHelperReference; + + var UnboundReference = (function (_ConstReference2) { + babelHelpers.inherits(UnboundReference, _ConstReference2); + + function UnboundReference() { + babelHelpers.classCallCheck(this, UnboundReference); + + _ConstReference2.apply(this, arguments); } - return _copy(obj, deep, deep ? [] : null, deep ? [] : null); - } + UnboundReference.create = function create(value) { + if (value === null) { + return _glimmerRuntime.NULL_REFERENCE; + } else if (value === undefined) { + return _glimmerRuntime.UNDEFINED_REFERENCE; + } else if (typeof value === 'object') { + return new UnboundReference(value); + } else { + return _glimmerRuntime.PrimitiveReference.create(value); + } + }; + + UnboundReference.prototype.get = function get(key) { + return new UnboundReference(_emberMetal.get(this.inner, key)); + }; + + return UnboundReference; + })(_glimmerReference.ConstReference); + + exports.UnboundReference = UnboundReference; }); -enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { +enifed('ember-glimmer/utils/string', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** @module ember - @submodule ember-runtime + @submodule ember-glimmer */ 'use strict'; - var a_slice = Array.prototype.slice; - var FunctionPrototype = Function.prototype; - - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { - /** - The `property` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - `true`, which is the default. - Computed properties allow you to treat a function like a property: - ```javascript - MyApp.President = Ember.Object.extend({ - firstName: '', - lastName: '', - fullName: function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }.property() // Call this flag to mark the function as a property - }); - let president = MyApp.President.create({ - firstName: 'Barack', - lastName: 'Obama' - }); - president.get('fullName'); // 'Barack Obama' - ``` - Treating a function like a property is useful because they can work with - bindings, just like any other property. - Many computed properties have dependencies on other properties. For - example, in the above example, the `fullName` property depends on - `firstName` and `lastName` to determine its value. You can tell Ember - about these dependencies like this: - ```javascript - MyApp.President = Ember.Object.extend({ - firstName: '', - lastName: '', - fullName: function() { - return this.get('firstName') + ' ' + this.get('lastName'); - // Tell Ember.js that this computed property depends on firstName - // and lastName - }.property('firstName', 'lastName') - }); - ``` - Make sure you list these dependencies so Ember knows when to update - bindings that connect to a computed property. Changing a dependency - will not immediately trigger an update of the computed property, but - will instead clear the cache so that it is updated when the next `get` - is called on the property. - See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/classes/Ember.computed.html). - @method property - @for Function - @public - */ - FunctionPrototype.property = function () { - var ret = _emberMetal.computed(this); - // ComputedProperty.prototype.property expands properties; no need for us to - // do so here. - return ret.property.apply(ret, arguments); - }; - - /** - The `observes` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - true, which is the default. - You can observe property changes simply by adding the `observes` - call to the end of your method declarations in classes that you write. - For example: - ```javascript - Ember.Object.extend({ - valueObserver: function() { - // Executes whenever the "value" property changes - }.observes('value') - }); - ``` - In the future this method may become asynchronous. - See `Ember.observer`. - @method observes - @for Function - @public - */ - FunctionPrototype.observes = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + exports.getSafeString = getSafeString; + exports.escapeExpression = escapeExpression; + exports.htmlSafe = htmlSafe; + exports.isHTMLSafe = isHTMLSafe; - args.push(this); - return _emberMetal.observer.apply(this, args); - }; + var SafeString = (function () { + function SafeString(string) { + babelHelpers.classCallCheck(this, SafeString); - FunctionPrototype._observesImmediately = function () { - _emberMetal.assert('Immediate observers must observe internal properties only, ' + 'not properties on other objects.', function checkIsInternalProperty() { - for (var i = 0; i < arguments.length; i++) { - if (arguments[i].indexOf('.') !== -1) { - return false; - } - } - return true; - }); + this.string = string; + } - // observes handles property expansion - return this.observes.apply(this, arguments); + SafeString.prototype.toString = function toString() { + return '' + this.string; }; - /** - The `observesImmediately` extension of Javascript's Function prototype is - available when `EmberENV.EXTEND_PROTOTYPES` or - `EmberENV.EXTEND_PROTOTYPES.Function` is true, which is the default. - You can observe property changes simply by adding the `observesImmediately` - call to the end of your method declarations in classes that you write. - For example: - ```javascript - Ember.Object.extend({ - valueObserver: function() { - // Executes immediately after the "value" property changes - }.observesImmediately('value') - }); - ``` - In the future, `observes` may become asynchronous. In this event, - `observesImmediately` will maintain the synchronous behavior. - See `Ember.immediateObserver`. - @method observesImmediately - @for Function - @deprecated - @private - */ - FunctionPrototype.observesImmediately = _emberMetal.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately); - - /** - The `on` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - true, which is the default. - You can listen for events simply by adding the `on` call to the end of - your method declarations in classes or mixins that you write. For example: - ```javascript - Ember.Mixin.create({ - doSomethingWithElement: function() { - // Executes whenever the "didInsertElement" event fires - }.on('didInsertElement') - }); - ``` - See `Ember.on`. - @method on - @for Function - @public - */ - FunctionPrototype.on = function () { - var events = a_slice.call(arguments); - this.__ember_listens__ = events; - return this; + SafeString.prototype.toHTML = function toHTML() { + return this.toString(); }; - } -}); -enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal'], function (exports, _rsvp, _emberMetal) { - 'use strict'; - exports.onerrorDefault = onerrorDefault; + return SafeString; + })(); - var backburner = _emberMetal.run.backburner; - _emberMetal.run._addQueue('rsvpAfter', 'destroy'); + exports.SafeString = SafeString; - _rsvp.configure('async', function (callback, promise) { - backburner.schedule('actions', null, callback, promise); - }); + function getSafeString() { + _emberMetal.deprecate('Ember.Handlebars.SafeString is deprecated in favor of Ember.String.htmlSafe', false, { + id: 'ember-htmlbars.ember-handlebars-safestring', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_use-ember-string-htmlsafe-over-ember-handlebars-safestring' + }); - _rsvp.configure('after', function (cb) { - backburner.schedule('rsvpAfter', null, cb); - }); + return SafeString; + } - _rsvp.on('error', onerrorDefault); + var escape = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + // jscs:disable + "'": ''', + // jscs:enable + '`': '`', + '=': '=' + }; - function onerrorDefault(reason) { - var error = errorFor(reason); - if (error) { - _emberMetal.dispatchError(error); - } + var possible = /[&<>"'`=]/; + var badChars = /[&<>"'`=]/g; + + function escapeChar(chr) { + return escape[chr]; } - function errorFor(reason) { - if (!reason) return; + function escapeExpression(string) { + if (typeof string !== 'string') { + // don't escape SafeStrings, since they're already safe + if (string && string.toHTML) { + return string.toHTML(); + } else if (string == null) { + return ''; + } else if (!string) { + return string + ''; + } - if (reason.errorThrown) { - return unwrapErrorThrown(reason); + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = '' + string; } - if (reason.name === 'UnrecognizedURLError') { - _emberMetal.assert('The URL \'' + reason.message + '\' did not match any routes in your application', false); - return; + if (!possible.test(string)) { + return string; } + return string.replace(badChars, escapeChar); + } - if (reason.name === 'TransitionAborted') { - return; + /** + Mark a string as safe for unescaped output with Ember templates. If you + return HTML from a helper, use this function to + ensure Ember's rendering layer does not escape the HTML. + + ```javascript + Ember.String.htmlSafe('
    someString
    ') + ``` + + @method htmlSafe + @for Ember.String + @static + @return {Handlebars.SafeString} A string that will not be HTML escaped by Handlebars. + @public + */ + + function htmlSafe(str) { + if (str === null || str === undefined) { + str = ''; + } else if (typeof str !== 'string') { + str = '' + str; } + return new SafeString(str); + } - return reason; + /** + Detects if a string was decorated using `Ember.String.htmlSafe`. + + ```javascript + var plainString = 'plain string', + safeString = Ember.String.htmlSafe('
    someValue
    '); + + Ember.String.isHTMLSafe(plainString); // false + Ember.String.isHTMLSafe(safeString); // true + ``` + + @method isHTMLSafe + @for Ember.String + @static + @return {Boolean} `true` if the string was decorated with `htmlSafe`, `false` otherwise. + @public + */ + + function isHTMLSafe(str) { + return str && typeof str.toHTML === 'function'; } +}); +enifed('ember-glimmer/utils/to-bool', ['exports', 'ember-runtime', 'ember-metal'], function (exports, _emberRuntime, _emberMetal) { + 'use strict'; - function unwrapErrorThrown(reason) { - var error = reason.errorThrown; - if (typeof error === 'string') { - error = new Error(error); + exports.default = toBool; + + function toBool(predicate) { + if (!predicate) { + return false; } - Object.defineProperty(error, '__reason_with_error_thrown__', { - value: reason, - enumerable: false - }); - return error; - } - exports.default = _rsvp; + if (predicate === true) { + return true; + } + + if (_emberRuntime.isArray(predicate)) { + return _emberMetal.get(predicate, 'length') !== 0; + } + + return true; + } }); -enifed('ember-runtime/ext/string', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { +enifed('ember-glimmer/views/outlet', ['exports', 'ember-utils', '@glimmer/reference', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _glimmerReference, _emberEnvironment, _emberMetal) { /** @module ember - @submodule ember-runtime + @submodule ember-glimmer */ - 'use strict'; - var StringPrototype = String.prototype; + var OutletStateReference = (function () { + function OutletStateReference(outletView) { + babelHelpers.classCallCheck(this, OutletStateReference); - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { - /** - See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt). - @method fmt - @for String - @private - @deprecated - */ - StringPrototype.fmt = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + this.outletView = outletView; + this.tag = outletView._tag; + } - return _emberRuntimeSystemString.fmt(this, args); - }; + // So this is a relic of the past that SHOULD go away + // in 3.0. Preferably it is deprecated in the release that + // follows the Glimmer release. - /** - See [Ember.String.w](/api/classes/Ember.String.html#method_w). - @method w - @for String - @private - */ - StringPrototype.w = function () { - return _emberRuntimeSystemString.w(this); + OutletStateReference.prototype.get = function get(key) { + return new ChildOutletStateReference(this, key); }; - /** - See [Ember.String.loc](/api/classes/Ember.String.html#method_loc). - @method loc - @for String - @private - */ - StringPrototype.loc = function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return _emberRuntimeSystemString.loc(this, args); + OutletStateReference.prototype.value = function value() { + return this.outletView.outletState; }; - /** - See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize). - @method camelize - @for String - @private - */ - StringPrototype.camelize = function () { - return _emberRuntimeSystemString.camelize(this); + OutletStateReference.prototype.getOrphan = function getOrphan(name) { + return new OrphanedOutletStateReference(this, name); }; - /** - See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize). - @method decamelize - @for String - @private - */ - StringPrototype.decamelize = function () { - return _emberRuntimeSystemString.decamelize(this); + OutletStateReference.prototype.update = function update(state) { + this.outletView.setOutletState(state); }; - /** - See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize). - @method dasherize - @for String - @private - */ - StringPrototype.dasherize = function () { - return _emberRuntimeSystemString.dasherize(this); - }; + return OutletStateReference; + })(); - /** - See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore). - @method underscore - @for String - @private - */ - StringPrototype.underscore = function () { - return _emberRuntimeSystemString.underscore(this); - }; + var OrphanedOutletStateReference = (function (_OutletStateReference) { + babelHelpers.inherits(OrphanedOutletStateReference, _OutletStateReference); - /** - See [Ember.String.classify](/api/classes/Ember.String.html#method_classify). - @method classify - @for String - @private - */ - StringPrototype.classify = function () { - return _emberRuntimeSystemString.classify(this); - }; + function OrphanedOutletStateReference(root, name) { + babelHelpers.classCallCheck(this, OrphanedOutletStateReference); - /** - See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize). - @method capitalize - @for String - @private - */ - StringPrototype.capitalize = function () { - return _emberRuntimeSystemString.capitalize(this); + _OutletStateReference.call(this, root.outletView); + this.root = root; + this.name = name; + } + + OrphanedOutletStateReference.prototype.value = function value() { + var rootState = this.root.value(); + + var orphans = rootState.outlets.main.outlets.__ember_orphans__; + + if (!orphans) { + return null; + } + + var matched = orphans.outlets[this.name]; + + if (!matched) { + return null; + } + + var state = new _emberUtils.EmptyObject(); + state[matched.render.outlet] = matched; + matched.wasUsed = true; + return { outlets: state }; }; - } -}); -enifed('ember-runtime/index', ['exports', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/system/object', 'ember-runtime/system/string', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/compare', 'ember-runtime/is-equal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/system/namespace', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeSystemObject, _emberRuntimeSystemString, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeCompare, _emberRuntimeIsEqual, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeSystemNamespace, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsObservable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeUtils, _emberRuntimeString_registry) { - /** - @module ember - @submodule ember-runtime - */ - 'use strict'; + return OrphanedOutletStateReference; + })(OutletStateReference); - exports.Object = _emberRuntimeSystemObject.default; - exports.FrameworkObject = _emberRuntimeSystemObject.FrameworkObject; - exports.String = _emberRuntimeSystemString.default; - exports.RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default; - exports.buildFakeRegistryWithDeprecations = _emberRuntimeMixinsRegistry_proxy.buildFakeRegistryWithDeprecations; - exports.ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default; - exports.copy = _emberRuntimeCopy.default; - exports.inject = _emberRuntimeInject.default; - exports.compare = _emberRuntimeCompare.default; - exports.isEqual = _emberRuntimeIsEqual.default; - exports.Array = _emberRuntimeMixinsArray.default; - exports.objectAt = _emberRuntimeMixinsArray.objectAt; - exports.isEmberArray = _emberRuntimeMixinsArray.isEmberArray; - exports.addArrayObserver = _emberRuntimeMixinsArray.addArrayObserver; - exports.removeArrayObserver = _emberRuntimeMixinsArray.removeArrayObserver; - exports.Comparable = _emberRuntimeMixinsComparable.default; - exports.Namespace = _emberRuntimeSystemNamespace.default; - exports.isNamespaceSearchDisabled = _emberRuntimeSystemNamespace.isSearchDisabled; - exports.setNamespaceSearchDisabled = _emberRuntimeSystemNamespace.setSearchDisabled; - exports.ArrayProxy = _emberRuntimeSystemArray_proxy.default; - exports.ObjectProxy = _emberRuntimeSystemObject_proxy.default; - exports.CoreObject = _emberRuntimeSystemCore_object.default; - exports.NativeArray = _emberRuntimeSystemNative_array.default; - exports.A = _emberRuntimeSystemNative_array.A; - exports.ActionHandler = _emberRuntimeMixinsAction_handler.default; - exports.deprecateUnderscoreActions = _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions; - exports.Copyable = _emberRuntimeMixinsCopyable.default; - exports.Enumerable = _emberRuntimeMixinsEnumerable.default; - exports.Freezable = _emberRuntimeMixinsFreezable.Freezable; - exports.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR; - exports._ProxyMixin = _emberRuntimeMixinsProxy.default; - exports.onLoad = _emberRuntimeSystemLazy_load.onLoad; - exports.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks; - exports._loaded = _emberRuntimeSystemLazy_load._loaded; - exports.Observable = _emberRuntimeMixinsObservable.default; - exports.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default; - exports.MutableArray = _emberRuntimeMixinsMutable_array.default; - exports.removeAt = _emberRuntimeMixinsMutable_array.removeAt; - exports.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default; - exports.Evented = _emberRuntimeMixinsEvented.default; - exports.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default; - exports.empty = _emberRuntimeComputedComputed_macros.empty; - exports.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty; - exports.none = _emberRuntimeComputedComputed_macros.none; - exports.not = _emberRuntimeComputedComputed_macros.not; - exports.bool = _emberRuntimeComputedComputed_macros.bool; - exports.match = _emberRuntimeComputedComputed_macros.match; - exports.equal = _emberRuntimeComputedComputed_macros.equal; - exports.gt = _emberRuntimeComputedComputed_macros.gt; - exports.gte = _emberRuntimeComputedComputed_macros.gte; - exports.lt = _emberRuntimeComputedComputed_macros.lt; - exports.lte = _emberRuntimeComputedComputed_macros.lte; - exports.oneWay = _emberRuntimeComputedComputed_macros.oneWay; - exports.readOnly = _emberRuntimeComputedComputed_macros.readOnly; - exports.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias; - exports.and = _emberRuntimeComputedComputed_macros.and; - exports.or = _emberRuntimeComputedComputed_macros.or; - exports.sum = _emberRuntimeComputedReduce_computed_macros.sum; - exports.min = _emberRuntimeComputedReduce_computed_macros.min; - exports.max = _emberRuntimeComputedReduce_computed_macros.max; - exports.map = _emberRuntimeComputedReduce_computed_macros.map; - exports.sort = _emberRuntimeComputedReduce_computed_macros.sort; - exports.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff; - exports.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy; - exports.filter = _emberRuntimeComputedReduce_computed_macros.filter; - exports.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy; - exports.uniq = _emberRuntimeComputedReduce_computed_macros.uniq; - exports.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy; - exports.union = _emberRuntimeComputedReduce_computed_macros.union; - exports.intersect = _emberRuntimeComputedReduce_computed_macros.intersect; - exports.collect = _emberRuntimeComputedReduce_computed_macros.collect; - exports.Controller = _emberRuntimeControllersController.default; - exports.ControllerMixin = _emberRuntimeMixinsController.default; - exports.Service = _emberRuntimeSystemService.default; - exports.RSVP = _emberRuntimeExtRsvp.default; - exports.onerrorDefault = _emberRuntimeExtRsvp.onerrorDefault; - // just for side effect of extending Ember.RSVP - exports.isArray = _emberRuntimeUtils.isArray; - exports.typeOf = _emberRuntimeUtils.typeOf; - exports.getStrings = _emberRuntimeString_registry.getStrings; - exports.setStrings = _emberRuntimeString_registry.setStrings; -}); -// just for side effect of extending String.prototype -// just for side effect of extending Function.prototype -enifed('ember-runtime/inject', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + var ChildOutletStateReference = (function () { + function ChildOutletStateReference(parent, key) { + babelHelpers.classCallCheck(this, ChildOutletStateReference); - exports.default = inject; - exports.createInjectionHelper = createInjectionHelper; - exports.validatePropertyInjections = validatePropertyInjections; + this.parent = parent; + this.key = key; + this.tag = parent.tag; + } - /** - Namespace for injection helper methods. - - @class inject - @namespace Ember - @static - @public - */ + ChildOutletStateReference.prototype.get = function get(key) { + return new ChildOutletStateReference(this, key); + }; - function inject() { - _emberMetal.assert('Injected properties must be created through helpers, see \'' + Object.keys(inject).join('"', '"') + '\''); - } + ChildOutletStateReference.prototype.value = function value() { + return this.parent.value()[this.key]; + }; - // Dictionary of injection validations by type, added to by `createInjectionHelper` - var typeValidators = {}; + return ChildOutletStateReference; + })(); - /** - This method allows other Ember modules to register injection helpers for a - given container type. Helpers are exported to the `inject` namespace as the - container type itself. - - @private - @method createInjectionHelper - @since 1.10.0 - @for Ember - @param {String} type The container type the helper will inject - @param {Function} validator A validation callback that is executed at mixin-time - */ + var OutletView = (function () { + OutletView.extend = function extend(injections) { + return (function (_OutletView) { + babelHelpers.inherits(_class, _OutletView); - function createInjectionHelper(type, validator) { - typeValidators[type] = validator; + function _class() { + babelHelpers.classCallCheck(this, _class); + + _OutletView.apply(this, arguments); + } + + _class.create = function create(options) { + if (options) { + return _OutletView.create.call(this, _emberUtils.assign({}, injections, options)); + } else { + return _OutletView.create.call(this, injections); + } + }; + + return _class; + })(OutletView); + }; - inject[type] = function (name) { - return new _emberMetal.InjectedProperty(type, name); + OutletView.reopenClass = function reopenClass(injections) { + _emberUtils.assign(this, injections); }; - } - /** - Validation function that runs per-type validation functions once for each - injected type encountered. - - @private - @method validatePropertyInjections - @since 1.10.0 - @for Ember - @param {Object} factory The factory object - */ + OutletView.create = function create(options) { + var _environment = options._environment; + var renderer = options.renderer; + var template = options.template; - function validatePropertyInjections(factory) { - var proto = factory.proto(); - var types = []; + var owner = options[_emberUtils.OWNER]; + return new OutletView(_environment, renderer, owner, template); + }; - for (var key in proto) { - var desc = proto[key]; - if (desc instanceof _emberMetal.InjectedProperty && types.indexOf(desc.type) === -1) { - types.push(desc.type); - } + function OutletView(_environment, renderer, owner, template) { + babelHelpers.classCallCheck(this, OutletView); + + this._environment = _environment; + this.renderer = renderer; + this.owner = owner; + this.template = template; + this.outletState = null; + this._tag = new _glimmerReference.DirtyableTag(); } - if (types.length) { - for (var i = 0; i < types.length; i++) { - var validator = typeValidators[types[i]]; + OutletView.prototype.appendTo = function appendTo(selector) { + var env = this._environment || _emberEnvironment.environment; + var target = undefined; - if (typeof validator === 'function') { - validator(factory); - } + if (env.hasDOM) { + target = typeof selector === 'string' ? document.querySelector(selector) : selector; + } else { + target = selector; } - } - return true; - } -}); -enifed('ember-runtime/is-equal', ['exports'], function (exports) { - /** - Compares two objects, returning true if they are equal. - - ```javascript - Ember.isEqual('hello', 'hello'); // true - Ember.isEqual(1, 2); // false - ``` - - `isEqual` is a more specific comparison than a triple equal comparison. - It will call the `isEqual` instance method on the objects being - compared, allowing finer control over when objects should be considered - equal to each other. - - ```javascript - let Person = Ember.Object.extend({ - isEqual(other) { return this.ssn == other.ssn; } - }); - - let personA = Person.create({name: 'Muhammad Ali', ssn: '123-45-6789'}); - let personB = Person.create({name: 'Cassius Clay', ssn: '123-45-6789'}); - - Ember.isEqual(personA, personB); // true - ``` - - Due to the expense of array comparisons, collections will never be equal to - each other even if each of their items are equal to each other. - - ```javascript - Ember.isEqual([4, 2], [4, 2]); // false - ``` - - @method isEqual - @for Ember - @param {Object} a first object to compare - @param {Object} b second object to compare - @return {Boolean} - @public - */ - 'use strict'; + _emberMetal.run.schedule('render', this.renderer, 'appendOutletView', this, target); + }; - exports.default = isEqual; + OutletView.prototype.rerender = function rerender() {}; - function isEqual(a, b) { - if (a && typeof a.isEqual === 'function') { - return a.isEqual(b); - } + OutletView.prototype.setOutletState = function setOutletState(state) { + this.outletState = { + outlets: { + main: state + }, + render: { + owner: undefined, + into: undefined, + outlet: 'main', + name: '-top-level', + controller: undefined, + ViewClass: undefined, + template: undefined + } + }; + this._tag.dirty(); + }; - if (a instanceof Date && b instanceof Date) { - return a.getTime() === b.getTime(); - } + OutletView.prototype.toReference = function toReference() { + return new OutletStateReference(this); + }; - return a === b; - } -}); -enifed('ember-runtime/mixins/-proxy', ['exports', 'glimmer-reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { - /** - @module ember - @submodule ember-runtime - */ + OutletView.prototype.destroy = function destroy() {}; - 'use strict'; + return OutletView; + })(); - function contentPropertyWillChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { - return; - } // if shadowed in proxy - _emberMetal.propertyWillChange(this, key); - } + exports.default = OutletView; +}); +enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) { + 'use strict'; - function contentPropertyDidChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { - return; - } // if shadowed in proxy - _emberMetal.propertyDidChange(this, key); - } + exports.default = alias; - var ProxyTag = (function (_CachedTag) { - babelHelpers.inherits(ProxyTag, _CachedTag); + var CONSUMED = {}; - function ProxyTag(proxy) { - babelHelpers.classCallCheck(this, ProxyTag); + function alias(altKey) { + return new AliasedProperty(altKey); + } - _CachedTag.call(this); + var AliasedProperty = (function (_Descriptor) { + babelHelpers.inherits(AliasedProperty, _Descriptor); - var content = _emberMetal.get(proxy, 'content'); + function AliasedProperty(altKey) { + babelHelpers.classCallCheck(this, AliasedProperty); - this.proxy = proxy; - this.proxyWrapperTag = new _glimmerReference.DirtyableTag(); - this.proxyContentTag = new _glimmerReference.UpdatableTag(_emberMetal.tagFor(content)); + _Descriptor.call(this); + this.isDescriptor = true; + this.altKey = altKey; + this._dependentKeys = [altKey]; } - /** - `Ember.ProxyMixin` forwards all properties not defined by the proxy itself - to a proxied `content` object. See Ember.ObjectProxy for more details. - - @class ProxyMixin - @namespace Ember - @private - */ - - ProxyTag.prototype.compute = function compute() { - return Math.max(this.proxyWrapperTag.value(), this.proxyContentTag.value()); + AliasedProperty.prototype.setup = function setup(obj, keyName) { + _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName); + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } }; - ProxyTag.prototype.dirty = function dirty() { - this.proxyWrapperTag.dirty(); + AliasedProperty.prototype.teardown = function teardown(obj, keyName) { + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + } }; - ProxyTag.prototype.contentDidChange = function contentDidChange() { - var content = _emberMetal.get(this.proxy, 'content'); - this.proxyContentTag.update(_emberMetal.tagFor(content)); + AliasedProperty.prototype.willWatch = function willWatch(obj, keyName) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); }; - return ProxyTag; - })(_glimmerReference.CachedTag); - - exports.default = _emberMetal.Mixin.create({ - /** - The object whose properties will be forwarded. - @property content - @type Ember.Object - @default null - @private - */ - content: null, + AliasedProperty.prototype.didUnwatch = function didUnwatch(obj, keyName) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); + }; - init: function () { - this._super.apply(this, arguments); - _emberMetal.meta(this).setProxy(); - }, + AliasedProperty.prototype.get = function get(obj, keyName) { + var ret = _emberMetalProperty_get.get(obj, this.altKey); + var meta = _emberMetalMeta.meta(obj); + var cache = meta.writableCache(); + if (cache[keyName] !== CONSUMED) { + cache[keyName] = CONSUMED; + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } + return ret; + }; - _initializeTag: _emberMetal.on('init', function () { - _emberMetal.meta(this)._tag = new ProxyTag(this); - }), + AliasedProperty.prototype.set = function set(obj, keyName, value) { + return _emberMetalProperty_set.set(obj, this.altKey, value); + }; - _contentDidChange: _emberMetal.observer('content', function () { - _emberMetal.assert('Can\'t set Proxy\'s content to itself', _emberMetal.get(this, 'content') !== this); - _emberMetal.tagFor(this).contentDidChange(); - }), + AliasedProperty.prototype.readOnly = function readOnly() { + this.set = AliasedProperty_readOnlySet; + return this; + }; - isTruthy: _emberRuntimeComputedComputed_macros.bool('content'), + AliasedProperty.prototype.oneWay = function oneWay() { + this.set = AliasedProperty_oneWaySet; + return this; + }; - _debugContainerKey: null, + return AliasedProperty; + })(_emberMetalProperties.Descriptor); - willWatchProperty: function (key) { - var contentKey = 'content.' + key; - _emberMetal._addBeforeObserver(this, contentKey, null, contentPropertyWillChange); - _emberMetal.addObserver(this, contentKey, null, contentPropertyDidChange); - }, + exports.AliasedProperty = AliasedProperty; - didUnwatchProperty: function (key) { - var contentKey = 'content.' + key; - _emberMetal._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); - _emberMetal.removeObserver(this, contentKey, null, contentPropertyDidChange); - }, + function AliasedProperty_readOnlySet(obj, keyName, value) { + throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); + } - unknownProperty: function (key) { - var content = _emberMetal.get(this, 'content'); - if (content) { - _emberMetal.deprecate('You attempted to access `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); - return _emberMetal.get(content, key); - } - }, + function AliasedProperty_oneWaySet(obj, keyName, value) { + _emberMetalProperties.defineProperty(obj, keyName, null); + return _emberMetalProperty_set.set(obj, keyName, value); + } - setUnknownProperty: function (key, value) { - var m = _emberMetal.meta(this); - if (m.proto === this) { - // if marked as prototype then just defineProperty - // rather than delegate - _emberMetal.defineProperty(this, key, null, value); - return value; - } + // Backwards compatibility with Ember Data. + AliasedProperty.prototype._meta = undefined; + AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta; +}); +enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) { + 'use strict'; - var content = _emberMetal.get(this, 'content'); - _emberMetal.assert('Cannot delegate set(\'' + key + '\', ' + value + ') to the \'content\' property of object proxy ' + this + ': its \'content\' is undefined.', content); + exports.bind = bind; - _emberMetal.deprecate('You attempted to set `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); - return _emberMetal.set(content, key, value); - } - }); -}); -enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** @module ember - @submodule ember-runtime + @submodule ember-metal */ - 'use strict'; + // .......................................................... + // BINDING + // - exports.deprecateUnderscoreActions = deprecateUnderscoreActions; + var Binding = (function () { + function Binding(toPath, fromPath) { + babelHelpers.classCallCheck(this, Binding); - /** - `Ember.ActionHandler` is available on some familiar classes including - `Ember.Route`, `Ember.Component`, and `Ember.Controller`. - (Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`, - and `Ember.Route` and available to the above classes through - inheritance.) - - @class ActionHandler - @namespace Ember - @private - */ - var ActionHandler = _emberMetal.Mixin.create({ - mergedProperties: ['actions'], + // Configuration + this._from = fromPath; + this._to = toPath; + this._oneWay = undefined; + + // State + this._direction = undefined; + this._readyToSync = undefined; + this._fromObj = undefined; + this._fromPath = undefined; + this._toObj = undefined; + } /** - The collection of functions, keyed by name, available on this - `ActionHandler` as action targets. - These functions will be invoked when a matching `{{action}}` is triggered - from within a template and the application's current route is this route. - Actions can also be invoked from other parts of your application - via `ActionHandler#send`. - The `actions` hash will inherit action handlers from - the `actions` hash defined on extended parent classes - or mixins rather than just replace the entire hash, e.g.: - ```js - App.CanDisplayBanner = Ember.Mixin.create({ - actions: { - displayBanner(msg) { - // ... - } - } - }); - App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { - actions: { - playMusic() { - // ... - } - } - }); - // `WelcomeRoute`, when active, will be able to respond - // to both actions, since the actions hash is merged rather - // then replaced when extending mixins / parent classes. - this.send('displayBanner'); - this.send('playMusic'); - ``` - Within a Controller, Route or Component's action handler, - the value of the `this` context is the Controller, Route or - Component object: - ```js - App.SongRoute = Ember.Route.extend({ - actions: { - myAction() { - this.controllerFor("song"); - this.transitionTo("other.route"); - ... - } - } - }); - ``` - It is also possible to call `this._super(...arguments)` from within an - action handler if it overrides a handler defined on a parent - class or mixin: - Take for example the following routes: - ```js - App.DebugRoute = Ember.Mixin.create({ - actions: { - debugRouteInformation() { - console.debug("trololo"); - } - } - }); - App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { - actions: { - debugRouteInformation() { - // also call the debugRouteInformation of mixed in App.DebugRoute - this._super(...arguments); - // show additional annoyance - window.alert(...); - } - } - }); - ``` - ## Bubbling - By default, an action will stop bubbling once a handler defined - on the `actions` hash handles it. To continue bubbling the action, - you must return `true` from the handler: - ```js - App.Router.map(function() { - this.route("album", function() { - this.route("song"); - }); - }); - App.AlbumRoute = Ember.Route.extend({ - actions: { - startPlaying: function() { - } - } - }); - App.AlbumSongRoute = Ember.Route.extend({ - actions: { - startPlaying() { - // ... - if (actionShouldAlsoBeTriggeredOnParentRoute) { - return true; - } - } - } - }); - ``` - @property actions - @type Object - @default null + @class Binding + @namespace Ember + @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding @public */ /** - Triggers a named action on the `ActionHandler`. Any parameters - supplied after the `actionName` string will be passed as arguments - to the action target function. - If the `ActionHandler` has its `target` property set, actions may - bubble to the `target`. Bubbling happens when an `actionName` can - not be found in the `ActionHandler`'s `actions` hash or if the - action target function returns `true`. - Example - ```js - App.WelcomeRoute = Ember.Route.extend({ - actions: { - playTheme() { - this.send('playMusic', 'theme.mp3'); - }, - playMusic(track) { - // ... - } - } - }); - ``` - @method send - @param {String} actionName The action to trigger - @param {*} context a context to send with the action + This copies the Binding so it can be connected to another object. + @method copy + @return {Ember.Binding} `this` @public */ - send: function (actionName) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + + Binding.prototype.copy = function copy() { + var copy = new Binding(this._to, this._from); + if (this._oneWay) { + copy._oneWay = true; } + return copy; + }; + + // .......................................................... + // CONFIG + // + + /** + This will set `from` property path to the specified value. It will not + attempt to resolve this property path to an actual object until you + connect the binding. + The binding will search for the property path starting at the root object + you pass when you `connect()` the binding. It follows the same rules as + `get()` - see that method for more information. + @method from + @param {String} path The property path to connect to. + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.from = function from(path) { + this._from = path; + return this; + }; + + /** + This will set the `to` property path to the specified value. It will not + attempt to resolve this property path to an actual object until you + connect the binding. + The binding will search for the property path starting at the root object + you pass when you `connect()` the binding. It follows the same rules as + `get()` - see that method for more information. + @method to + @param {String|Tuple} path A property path or tuple. + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.to = function to(path) { + this._to = path; + return this; + }; + + /** + Configures the binding as one way. A one-way binding will relay changes + on the `from` side to the `to` side, but not the other way around. This + means that if you change the `to` side directly, the `from` side may have + a different value. + @method oneWay + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.oneWay = function oneWay() { + this._oneWay = true; + return this; + }; + + /** + @method toString + @return {String} string representation of binding + @public + */ + + Binding.prototype.toString = function toString() { + var oneWay = this._oneWay ? '[oneWay]' : ''; + return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; + }; + + // .......................................................... + // CONNECT AND SYNC + // + + /** + Attempts to connect this binding instance so that it can receive and relay + changes. This method will raise an exception if you have not set the + from/to properties yet. + @method connect + @param {Object} obj The root object for this binding. + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.connect = function connect(obj) { + _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.connect()', !!obj); + + var fromObj = undefined, + fromPath = undefined, + possibleGlobal = undefined; + + // If the binding's "from" path could be interpreted as a global, verify + // whether the path refers to a global or not by consulting `Ember.lookup`. + if (_emberMetalPath_cache.isGlobalPath(this._from)) { + var _name = _emberMetalPath_cache.getFirstKey(this._from); + possibleGlobal = _emberEnvironment.context.lookup[_name]; - if (this.actions && this.actions[actionName]) { - var shouldBubble = this.actions[actionName].apply(this, args) === true; - if (!shouldBubble) { - return; + if (possibleGlobal) { + fromObj = possibleGlobal; + fromPath = _emberMetalPath_cache.getTailPath(this._from); } } - var target = _emberMetal.get(this, 'target'); - if (target) { - _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); + if (fromObj === undefined) { + fromObj = obj; + fromPath = this._from; } - }, - willMergeMixin: function (props) { - _emberMetal.assert('Specifying `_actions` and `actions` in the same mixin is not supported.', !props.actions || !props._actions); + _emberMetalProperty_set.trySet(obj, this._to, _emberMetalProperty_get.get(fromObj, fromPath)); - if (props._actions) { - _emberMetal.deprecate('Specifying actions in `_actions` is deprecated, please use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); + // Add an observer on the object to be notified when the binding should be updated. + _emberMetalObserver.addObserver(fromObj, fromPath, this, 'fromDidChange'); - props.actions = props._actions; - delete props._actions; + // If the binding is a two-way binding, also set up an observer on the target. + if (!this._oneWay) { + _emberMetalObserver.addObserver(obj, this._to, this, 'toDidChange'); } - } - }); - exports.default = ActionHandler; + _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect'); - function deprecateUnderscoreActions(factory) { - Object.defineProperty(factory.prototype, '_actions', { - configurable: true, - enumerable: false, - set: function (value) { - _emberMetal.assert('You cannot set `_actions` on ' + this + ', please use `actions` instead.'); - }, - get: function () { - _emberMetal.deprecate('Usage of `_actions` is deprecated, use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); - return _emberMetal.get(this, 'actions'); - } - }); - } -}); -enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/each_proxy'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsEnumerable, _emberRuntimeSystemEach_proxy) { - /** - @module ember - @submodule ember-runtime - */ + fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); - // .......................................................... - // HELPERS - // - 'use strict'; + this._readyToSync = true; + this._fromObj = fromObj; + this._fromPath = fromPath; + this._toObj = obj; - var _Mixin$create; + return this; + }; - exports.addArrayObserver = addArrayObserver; - exports.removeArrayObserver = removeArrayObserver; - exports.objectAt = objectAt; - exports.arrayContentWillChange = arrayContentWillChange; - exports.arrayContentDidChange = arrayContentDidChange; - exports.isEmberArray = isEmberArray; + /** + Disconnects the binding instance. Changes will no longer be relayed. You + will not usually need to call this method. + @method disconnect + @return {Ember.Binding} `this` + @public + */ - function arrayObserversHelper(obj, target, opts, operation, notify) { - var willChange = opts && opts.willChange || 'arrayWillChange'; - var didChange = opts && opts.didChange || 'arrayDidChange'; - var hasObservers = _emberMetal.get(obj, 'hasArrayObservers'); + Binding.prototype.disconnect = function disconnect() { + _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); - if (hasObservers === notify) { - _emberMetal.propertyWillChange(obj, 'hasArrayObservers'); - } + // Remove an observer on the object so we're no longer notified of + // changes that should update bindings. + _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); - operation(obj, '@array:before', target, willChange); - operation(obj, '@array:change', target, didChange); + // If the binding is two-way, remove the observer from the target as well. + if (!this._oneWay) { + _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); + } - if (hasObservers === notify) { - _emberMetal.propertyDidChange(obj, 'hasArrayObservers'); - } + this._readyToSync = false; // Disable scheduled syncs... + return this; + }; - return obj; - } + // .......................................................... + // PRIVATE + // - function addArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, _emberMetal.addListener, false); - } + /* Called when the from side changes. */ - function removeArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, _emberMetal.removeListener, true); - } + Binding.prototype.fromDidChange = function fromDidChange(target) { + this._scheduleSync('fwd'); + }; - function objectAt(content, idx) { - if (content.objectAt) { - return content.objectAt(idx); - } + /* Called when the to side changes. */ - return content[idx]; - } + Binding.prototype.toDidChange = function toDidChange(target) { + this._scheduleSync('back'); + }; - function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { - var removing = undefined, - lim = undefined; + Binding.prototype._scheduleSync = function _scheduleSync(dir) { + var existingDir = this._direction; - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; + // If we haven't scheduled the binding yet, schedule it. + if (existingDir === undefined) { + _emberMetalRun_loop.default.schedule('sync', this, '_sync'); + this._direction = dir; } - if (addAmt === undefined) { - addAmt = -1; + // If both a 'back' and 'fwd' sync have been scheduled on the same object, + // default to a 'fwd' sync so that it remains deterministic. + if (existingDir === 'back' && dir === 'fwd') { + this._direction = 'fwd'; } - } - - if (array.__each) { - array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt); - } - - _emberMetal.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); - - if (startIdx >= 0 && removeAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { - removing = []; - lim = startIdx + removeAmt; + }; - for (var idx = startIdx; idx < lim; idx++) { - removing.push(objectAt(array, idx)); - } - } else { - removing = removeAmt; - } + Binding.prototype._sync = function _sync() { + var _this = this; - array.enumerableContentWillChange(removing, addAmt); + var log = _emberEnvironment.ENV.LOG_BINDINGS; - return array; - } + var toObj = this._toObj; - function arrayContentDidChange(array, startIdx, removeAmt, addAmt) { - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; + // Don't synchronize destroyed objects or disconnected bindings. + if (toObj.isDestroyed || !this._readyToSync) { + return; } - if (addAmt === undefined) { - addAmt = -1; - } - } + // Get the direction of the binding for the object we are + // synchronizing from. + var direction = this._direction; - var adding = undefined; - if (startIdx >= 0 && addAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { - adding = []; - var lim = startIdx + addAmt; + var fromObj = this._fromObj; + var fromPath = this._fromPath; - for (var idx = startIdx; idx < lim; idx++) { - adding.push(objectAt(array, idx)); - } - } else { - adding = addAmt; - } + this._direction = undefined; - array.enumerableContentDidChange(removeAmt, adding); + // If we're synchronizing from the remote object... + if (direction === 'fwd') { + (function () { + var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); + if (log) { + _emberConsole.default.log(' ', _this.toString(), '->', fromValue, fromObj); + } + if (_this._oneWay) { + _emberMetalProperty_set.trySet(toObj, _this._to, fromValue); + } else { + _emberMetalObserver._suspendObserver(toObj, _this._to, _this, 'toDidChange', function () { + _emberMetalProperty_set.trySet(toObj, this._to, fromValue); + }); + } + // If we're synchronizing *to* the remote object. + })(); + } else if (direction === 'back') { + (function () { + var toValue = _emberMetalProperty_get.get(toObj, _this._to); + if (log) { + _emberConsole.default.log(' ', _this.toString(), '<-', toValue, toObj); + } + _emberMetalObserver._suspendObserver(fromObj, fromPath, _this, 'fromDidChange', function () { + _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); + }); + })(); + } + }; - if (array.__each) { - array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt); - } + return Binding; + })(); - _emberMetal.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); + function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { + var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; + var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; + var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - var meta = _emberMetal.peekMeta(array); - var cache = meta && meta.readableCache(); + var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; + _emberMetalDebug.deprecate(objectInfo + deprecateGlobalMessage, !deprecateGlobal, { + id: 'ember-metal.binding', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' + }); + _emberMetalDebug.deprecate(objectInfo + deprecateOneWayMessage, !deprecateOneWay, { + id: 'ember-metal.binding', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' + }); + _emberMetalDebug.deprecate(objectInfo + deprecateAliasMessage, !deprecateAlias, { + id: 'ember-metal.binding', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' + }); + } - if (cache) { - if (cache.firstObject !== undefined && objectAt(array, 0) !== _emberMetal.cacheFor.get(cache, 'firstObject')) { - _emberMetal.propertyWillChange(array, 'firstObject'); - _emberMetal.propertyDidChange(array, 'firstObject'); - } - if (cache.lastObject !== undefined && objectAt(array, _emberMetal.get(array, 'length') - 1) !== _emberMetal.cacheFor.get(cache, 'lastObject')) { - _emberMetal.propertyWillChange(array, 'lastObject'); - _emberMetal.propertyDidChange(array, 'lastObject'); + function mixinProperties(to, from) { + for (var key in from) { + if (from.hasOwnProperty(key)) { + to[key] = from[key]; } } - return array; } - var EMBER_ARRAY = _emberUtils.symbol('EMBER_ARRAY'); + mixinProperties(Binding, { - function isEmberArray(obj) { - return obj && !!obj[EMBER_ARRAY]; - } + /* + See `Ember.Binding.from`. + @method from + @static + */ + from: function (from) { + var C = this; + return new C(undefined, from); + }, - // .......................................................... - // ARRAY - // + /* + See `Ember.Binding.to`. + @method to + @static + */ + to: function (to) { + var C = this; + return new C(to, undefined); + } + }); /** - This mixin implements Observer-friendly Array-like behavior. It is not a - concrete implementation, but it can be used up by other classes that want - to appear like arrays. + An `Ember.Binding` connects the properties of two objects so that whenever + the value of one property changes, the other property will be changed also. - For example, ArrayProxy is a concrete classes that can - be instantiated to implement array-like behavior. Both of these classes use - the Array Mixin by way of the MutableArray mixin, which allows observable - changes to be made to the underlying array. + ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. - Unlike `Ember.Enumerable,` this mixin defines methods specifically for - collections that provide index-ordered access to their contents. When you - are designing code that needs to accept any kind of Array-like object, you - should use these methods instead of Array primitives because these will - properly notify observers of changes to the array. + You do not usually create Binding objects directly but instead describe + bindings in your class or object definition using automatic binding + detection. - Although these methods are efficient, they do add a layer of indirection to - your application so it is a good idea to use them only when you need the - flexibility of using both true JavaScript arrays and "virtual" arrays such - as controllers and collections. + Properties ending in a `Binding` suffix will be converted to `Ember.Binding` + instances. The value of this property should be a string representing a path + to another object or a custom binding instance created using Binding helpers + (see "One Way Bindings"): - You can use the methods defined in this module to access and modify array - contents in a KVO-friendly way. You can also be notified whenever the - membership of an array changes by using `.observes('myArray.[]')`. + ``` + valueBinding: "MyApp.someController.title" + ``` - To support `Ember.Array` in your own class, you must override two - primitives to use it: `length()` and `objectAt()`. + This will create a binding from `MyApp.someController.title` to the `value` + property of your object instance automatically. Now the two values will be + kept in sync. - Note that the Ember.Array mixin also incorporates the `Ember.Enumerable` - mixin. All `Ember.Array`-like objects are also enumerable. + ## One Way Bindings - @class Array + One especially useful binding customization you can use is the `oneWay()` + helper. This helper tells Ember that you are only interested in + receiving changes on the object you are binding from. For example, if you + are binding to a preference and you want to be notified if the preference + has changed, but your object will not be changing the preference itself, you + could do: + + ``` + bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") + ``` + + This way if the value of `MyApp.preferencesController.bigTitles` changes the + `bigTitles` property of your object will change also. However, if you + change the value of your `bigTitles` property, it will not update the + `preferencesController`. + + One way bindings are almost twice as fast to setup and twice as fast to + execute because the binding only has to worry about changes to one side. + + You should consider using one way bindings anytime you have an object that + may be created frequently and you do not intend to change a property; only + to monitor it for changes (such as in the example above). + + ## Adding Bindings Manually + + All of the examples above show you how to configure a custom binding, but the + result of these customizations will be a binding template, not a fully active + Binding instance. The binding will actually become active only when you + instantiate the object the binding belongs to. It is useful, however, to + understand what actually happens when the binding is activated. + + For a binding to function it must have at least a `from` property and a `to` + property. The `from` property path points to the object/key that you want to + bind from while the `to` path points to the object/key you want to bind to. + + When you define a custom binding, you are usually describing the property + you want to bind from (such as `MyApp.someController.value` in the examples + above). When your object is created, it will automatically assign the value + you want to bind `to` based on the name of your binding key. In the + examples above, during init, Ember objects will effectively call + something like this on your binding: + + ```javascript + binding = Ember.Binding.from("valueBinding").to("value"); + ``` + + This creates a new binding instance based on the template you provide, and + sets the to path to the `value` property of the new object. Now that the + binding is fully configured with a `from` and a `to`, it simply needs to be + connected to become active. This is done through the `connect()` method: + + ```javascript + binding.connect(this); + ``` + + Note that when you connect a binding you pass the object you want it to be + connected to. This object will be used as the root for both the from and + to side of the binding when inspecting relative paths. This allows the + binding to be automatically inherited by subclassed objects as well. + + This also allows you to bind between objects using the paths you declare in + `from` and `to`: + + ```javascript + // Example 1 + binding = Ember.Binding.from("App.someObject.value").to("value"); + binding.connect(this); + + // Example 2 + binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); + binding.connect(this); + ``` + + Now that the binding is connected, it will observe both the from and to side + and relay changes. + + If you ever needed to do so (you almost never will, but it is useful to + understand this anyway), you could manually create an active binding by + using the `Ember.bind()` helper method. (This is the same method used by + to setup your bindings on objects): + + ```javascript + Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); + ``` + + Both of these code fragments have the same effect as doing the most friendly + form of binding creation like so: + + ```javascript + MyApp.anotherObject = Ember.Object.create({ + valueBinding: "MyApp.someController.value", + + // OTHER CODE FOR THIS OBJECT... + }); + ``` + + Ember's built in binding creation method makes it easy to automatically + create bindings for you. You should always use the highest-level APIs + available, even if you understand how it works underneath. + + @class Binding @namespace Ember - @uses Ember.Enumerable - @since Ember 0.9.0 + @since Ember 0.9 @public */ - var ArrayMixin = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) { - if (idx < 0 || idx >= _emberMetal.get(this, 'length')) { - return undefined; + // Ember.Binding = Binding; ES6TODO: where to put this? + + /** + Global helper method to create a new binding. Just pass the root object + along with a `to` and `from` path to create and connect the binding. + + @method bind + @for Ember + @param {Object} obj The root object of the transform. + @param {String} to The path to the 'to' side of the binding. + Must be relative to obj. + @param {String} from The path to the 'from' side of the binding. + Must be relative to obj or a global path. + @return {Ember.Binding} binding instance + @public + */ + + function bind(obj, to, from) { + return new Binding(to, from).connect(obj); + } + + exports.Binding = Binding; +}); +enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { + 'use strict'; + + var Cache = (function () { + function Cache(limit, func, key, store) { + babelHelpers.classCallCheck(this, Cache); + + this.size = 0; + this.misses = 0; + this.hits = 0; + this.limit = limit; + this.func = func; + this.key = key; + this.store = store || new DefaultStore(); } - return _emberMetal.get(this, idx); - }, _Mixin$create.objectsAt = function (indexes) { - var _this = this; + Cache.prototype.get = function get(obj) { + var key = this.key === undefined ? obj : this.key(obj); + var value = this.store.get(key); + if (value === undefined) { + this.misses++; + value = this._set(key, this.func(obj)); + } else if (value === _emberMetalMeta.UNDEFINED) { + this.hits++; + value = undefined; + } else { + this.hits++; + // nothing to translate + } + + return value; + }; + + Cache.prototype.set = function set(obj, value) { + var key = this.key === undefined ? obj : this.key(obj); + return this._set(key, value); + }; + + Cache.prototype._set = function _set(key, value) { + if (this.limit > this.size) { + this.size++; + if (value === undefined) { + this.store.set(key, _emberMetalMeta.UNDEFINED); + } else { + this.store.set(key, value); + } + } + + return value; + }; + + Cache.prototype.purge = function purge() { + this.store.clear(); + this.size = 0; + this.hits = 0; + this.misses = 0; + }; + + return Cache; + })(); + + exports.default = Cache; - return indexes.map(function (idx) { - return objectAt(_this, idx); - }); - }, _Mixin$create.nextObject = function (idx) { - return objectAt(this, idx); - }, _Mixin$create['[]'] = _emberMetal.computed({ - get: function (key) { - return this; - }, - set: function (key, value) { - this.replace(0, _emberMetal.get(this, 'length'), value); - return this; - } - }), _Mixin$create.firstObject = _emberMetal.computed(function () { - return objectAt(this, 0); - }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () { - return objectAt(this, _emberMetal.get(this, 'length') - 1); - }).readOnly(), _Mixin$create.contains = function (obj) { - if (true) { - _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); + var DefaultStore = (function () { + function DefaultStore() { + babelHelpers.classCallCheck(this, DefaultStore); + + this.data = new _emberUtils.EmptyObject(); } - return this.indexOf(obj) >= 0; - }, _Mixin$create.slice = function (beginIndex, endIndex) { - var ret = _emberMetal.default.A(); - var length = _emberMetal.get(this, 'length'); + DefaultStore.prototype.get = function get(key) { + return this.data[key]; + }; - if (_emberMetal.isNone(beginIndex)) { - beginIndex = 0; - } + DefaultStore.prototype.set = function set(key, value) { + this.data[key] = value; + }; - if (_emberMetal.isNone(endIndex) || endIndex > length) { - endIndex = length; - } + DefaultStore.prototype.clear = function clear() { + this.data = new _emberUtils.EmptyObject(); + }; - if (beginIndex < 0) { - beginIndex = length + beginIndex; - } + return DefaultStore; + })(); +}); +enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/computed', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalComputed, _emberMetalWatch_path) { + 'use strict'; - if (endIndex < 0) { - endIndex = length + endIndex; - } + exports.finishChains = finishChains; - while (beginIndex < endIndex) { - ret[ret.length] = objectAt(this, beginIndex++); - } + var FIRST_KEY = /^([^\.]+)/; - return ret; - }, _Mixin$create.indexOf = function (object, startAt) { - var len = _emberMetal.get(this, 'length'); + function firstKey(path) { + return path.match(FIRST_KEY)[0]; + } - if (startAt === undefined) { - startAt = 0; - } + function isObject(obj) { + return typeof obj === 'object' && obj; + } - if (startAt < 0) { - startAt += len; - } + function isVolatile(obj) { + return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); + } - for (var idx = startAt; idx < len; idx++) { - if (objectAt(this, idx) === object) { - return idx; - } + var ChainWatchers = (function () { + function ChainWatchers() { + babelHelpers.classCallCheck(this, ChainWatchers); + + // chain nodes that reference a key in this obj by key + // we only create ChainWatchers when we are going to add them + // so create this upfront + this.chains = new _emberUtils.EmptyObject(); } - return -1; - }, _Mixin$create.lastIndexOf = function (object, startAt) { - var len = _emberMetal.get(this, 'length'); + ChainWatchers.prototype.add = function add(key, node) { + var nodes = this.chains[key]; + if (nodes === undefined) { + this.chains[key] = [node]; + } else { + nodes.push(node); + } + }; - if (startAt === undefined || startAt >= len) { - startAt = len - 1; - } + ChainWatchers.prototype.remove = function remove(key, node) { + var nodes = this.chains[key]; + if (nodes) { + for (var i = 0; i < nodes.length; i++) { + if (nodes[i] === node) { + nodes.splice(i, 1); + break; + } + } + } + }; - if (startAt < 0) { - startAt += len; - } + ChainWatchers.prototype.has = function has(key, node) { + var nodes = this.chains[key]; + if (nodes) { + for (var i = 0; i < nodes.length; i++) { + if (nodes[i] === node) { + return true; + } + } + } + return false; + }; - for (var idx = startAt; idx >= 0; idx--) { - if (objectAt(this, idx) === object) { - return idx; + ChainWatchers.prototype.revalidateAll = function revalidateAll() { + for (var key in this.chains) { + this.notify(key, true, undefined); } - } + }; - return -1; - }, _Mixin$create.addArrayObserver = function (target, opts) { - return addArrayObserver(this, target, opts); - }, _Mixin$create.removeArrayObserver = function (target, opts) { - return removeArrayObserver(this, target, opts); - }, _Mixin$create.hasArrayObservers = _emberMetal.computed(function () { - return _emberMetal.hasListeners(this, '@array:change') || _emberMetal.hasListeners(this, '@array:before'); - }), _Mixin$create.arrayContentWillChange = function (startIdx, removeAmt, addAmt) { - return arrayContentWillChange(this, startIdx, removeAmt, addAmt); - }, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) { - return arrayContentDidChange(this, startIdx, removeAmt, addAmt); - }, _Mixin$create['@each'] = _emberMetal.computed(function () { - // TODO use Symbol or add to meta - if (!this.__each) { - this.__each = new _emberRuntimeSystemEach_proxy.default(this); - } + ChainWatchers.prototype.revalidate = function revalidate(key) { + this.notify(key, true, undefined); + }; - return this.__each; - }).volatile().readOnly(), _Mixin$create)); + // key: the string key that is part of a path changed + // revalidate: boolean; the chains that are watching this value should revalidate + // callback: function that will be called with the object and path that + // will be/are invalidated by this key change, depending on + // whether the revalidate flag is passed - if (true) { - ArrayMixin.reopen({ - /** - Returns `true` if the passed object can be found in the array. - This method is a Polyfill for ES 2016 Array.includes. - If no `startAt` argument is given, the starting location to - search is 0. If it's negative, searches from the index of - `this.length + startAt` by asc. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, 3].includes(3, 2); // true - [1, 2, 3].includes(3, 3); // false - [1, 2, 3].includes(3, -1); // true - [1, 2, 3].includes(1, -1); // false - [1, 2, 3].includes(1, -4); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @param {Number} startAt optional starting location to search, default 0 - @return {Boolean} `true` if object is found in the array. - @public - */ - includes: function (obj, startAt) { - var len = _emberMetal.get(this, 'length'); + ChainWatchers.prototype.notify = function notify(key, revalidate, callback) { + var nodes = this.chains[key]; + if (nodes === undefined || nodes.length === 0) { + return; + } - if (startAt === undefined) { - startAt = 0; - } + var affected = undefined; - if (startAt < 0) { - startAt += len; - } + if (callback) { + affected = []; + } - for (var idx = startAt; idx < len; idx++) { - var currentObj = objectAt(this, idx); + for (var i = 0; i < nodes.length; i++) { + nodes[i].notify(revalidate, affected); + } - // SameValueZero comparison (NaN !== NaN) - if (obj === currentObj || obj !== obj && currentObj !== currentObj) { - return true; - } - } + if (callback === undefined) { + return; + } - return false; + // we gather callbacks so we don't notify them during revalidation + for (var i = 0; i < affected.length; i += 2) { + var obj = affected[i]; + var path = affected[i + 1]; + callback(obj, path); } - }); + }; + + return ChainWatchers; + })(); + + function makeChainWatcher() { + return new ChainWatchers(); } - exports.default = ArrayMixin; -}); -// ES6TODO: Ember.A + function addChainWatcher(obj, keyName, node) { + var m = _emberMetalMeta.meta(obj); + m.writableChainWatchers(makeChainWatcher).add(keyName, node); + _emberMetalWatch_key.watchKey(obj, keyName, m); + } -/** - __Required.__ You must implement this method to apply this mixin. - Your array must support the `length` property. Your replace methods should - set this property whenever it changes. - @property {Number} length - @public -*/ + function removeChainWatcher(obj, keyName, node, _meta) { + if (!isObject(obj)) { + return; + } -/** - Returns the object at the given `index`. If the given `index` is negative - or is greater or equal than the array length, returns `undefined`. - This is one of the primitives you must implement to support `Ember.Array`. - If your object supports retrieving the value of an array item using `get()` - (i.e. `myArray.get(0)`), then you do not need to implement this method - yourself. - ```javascript - let arr = ['a', 'b', 'c', 'd']; - arr.objectAt(0); // 'a' - arr.objectAt(3); // 'd' - arr.objectAt(-1); // undefined - arr.objectAt(4); // undefined - arr.objectAt(5); // undefined - ``` - @method objectAt - @param {Number} idx The index of the item to return. - @return {*} item at index or undefined - @public -*/ + var meta = _meta || _emberMetalMeta.peekMeta(obj); -/** - This returns the objects at the specified indexes, using `objectAt`. - ```javascript - let arr = ['a', 'b', 'c', 'd']; - arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] - arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] - ``` - @method objectsAt - @param {Array} indexes An array of indexes of items to return. - @return {Array} - @public - */ + if (!meta || !meta.readableChainWatchers()) { + return; + } -// overrides Ember.Enumerable version + // make meta writable + meta = _emberMetalMeta.meta(obj); -/** - 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 - array, it will replace the current content. - This property overrides the default property defined in `Ember.Enumerable`. - @property [] - @return this - @public -*/ + meta.readableChainWatchers().remove(keyName, node); -// optimized version from Enumerable + _emberMetalWatch_key.unwatchKey(obj, keyName, meta); + } -// Add any extra methods to Ember.Array that are native to the built-in Array. -/** - Returns a new array that is a slice of the receiver. This implementation - uses the observable array methods to retrieve the objects for the new - slice. - ```javascript - let arr = ['red', 'green', 'blue']; - arr.slice(0); // ['red', 'green', 'blue'] - arr.slice(0, 2); // ['red', 'green'] - arr.slice(1, 100); // ['green', 'blue'] - ``` - @method slice - @param {Number} beginIndex (Optional) index to begin slicing from. - @param {Number} endIndex (Optional) index to end the slice at (but not included). - @return {Array} New array with specified slice - @public -*/ + // A ChainNode watches a single key on an object. If you provide a starting + // value for the key then the node won't actually watch it. For a root node + // pass null for parent and key and object for value. -/** - Returns the index of the given object's first occurrence. - If no `startAt` argument is given, the starting location to - search is 0. If it's negative, will count backward from - the end of the array. Returns -1 if no match is found. - ```javascript - let arr = ['a', 'b', 'c', 'd', 'a']; - arr.indexOf('a'); // 0 - arr.indexOf('z'); // -1 - arr.indexOf('a', 2); // 4 - arr.indexOf('a', -1); // 4 - arr.indexOf('b', 3); // -1 - arr.indexOf('a', 100); // -1 - ``` - @method indexOf - @param {Object} object the item to search for - @param {Number} startAt optional starting location to search, default 0 - @return {Number} index or -1 if not found - @public -*/ + var ChainNode = (function () { + function ChainNode(parent, key, value) { + babelHelpers.classCallCheck(this, ChainNode); -/** - Returns the index of the given object's last occurrence. - If no `startAt` argument is given, the search starts from - the last position. If it's negative, will count backward - from the end of the array. Returns -1 if no match is found. - ```javascript - let arr = ['a', 'b', 'c', 'd', 'a']; - arr.lastIndexOf('a'); // 4 - arr.lastIndexOf('z'); // -1 - arr.lastIndexOf('a', 2); // 0 - arr.lastIndexOf('a', -1); // 4 - arr.lastIndexOf('b', 3); // 1 - arr.lastIndexOf('a', 100); // 4 - ``` - @method lastIndexOf - @param {Object} object the item to search for - @param {Number} startAt optional starting location to search, default 0 - @return {Number} index or -1 if not found - @public -*/ + this._parent = parent; + this._key = key; -// .......................................................... -// ARRAY OBSERVERS -// + // _watching is true when calling get(this._parent, this._key) will + // return the value of this node. + // + // It is false for the root of a chain (because we have no parent) + // and for global paths (because the parent node is the object with + // the observer on it) + this._watching = value === undefined; -/** - Adds an array observer to the receiving array. The array observer object - normally must implement two methods: - * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be - called just before the array is modified. - * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be - called just after the array is modified. - Both callbacks will be passed the observed object, starting index of the - change as well as a count of the items to be removed and added. You can use - these callbacks to optionally inspect the array during the change, clear - caches, or do any other bookkeeping necessary. - In addition to passing a target, you can also include an options hash - which you can use to override the method names that will be invoked on the - target. - @method addArrayObserver - @param {Object} target The observer object. - @param {Object} opts Optional hash of configuration options including - `willChange` and `didChange` option. - @return {Ember.Array} receiver - @public -*/ + this._chains = undefined; + this._object = undefined; + this.count = 0; -/** - Removes an array observer from the object if the observer is current - registered. Calling this method multiple times with the same object will - have no effect. - @method removeArrayObserver - @param {Object} target The object observing the array. - @param {Object} opts Optional hash of configuration options including - `willChange` and `didChange` option. - @return {Ember.Array} receiver - @public -*/ + this._value = value; + this._paths = {}; + if (this._watching) { + var obj = parent.value(); -/** - Becomes true whenever the array currently has observers watching changes - on the array. - @property {Boolean} hasArrayObservers - @public -*/ + if (!isObject(obj)) { + return; + } -/** - If you are implementing an object that supports `Ember.Array`, call this - method just before the array content changes to notify any observers and - invalidate any related properties. Pass the starting index of the change - as well as a delta of the amounts to change. - @method arrayContentWillChange - @param {Number} startIdx The starting index in the array that will change. - @param {Number} removeAmt The number of items that will be removed. If you - pass `null` assumes 0 - @param {Number} addAmt The number of items that will be added. If you - pass `null` assumes 0. - @return {Ember.Array} receiver - @public -*/ + this._object = obj; -/** - If you are implementing an object that supports `Ember.Array`, call this - method just after the array content changes to notify any observers and - invalidate any related properties. Pass the starting index of the change - as well as a delta of the amounts to change. - @method arrayContentDidChange - @param {Number} startIdx The starting index in the array that did change. - @param {Number} removeAmt The number of items that were removed. If you - pass `null` assumes 0 - @param {Number} addAmt The number of items that were added. If you - pass `null` assumes 0. - @return {Ember.Array} receiver - @public -*/ + addChainWatcher(this._object, this._key, this); + } + } -/** - Returns a special object that can be used to observe individual properties - on the array. Just get an equivalent property on this object and it will - return an enumerable that maps automatically to the named key on the - member objects. - `@each` should only be used in a non-terminal context. Example: - ```javascript - myMethod: computed('posts.@each.author', function(){ - ... - }); - ``` - If you merely want to watch for the array being changed, like an object being - replaced, added or removed, use `[]` instead of `@each`. - ```javascript - myMethod: computed('posts.[]', function(){ - ... - }); - ``` - @property @each - @public -*/ -enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + ChainNode.prototype.value = function value() { + if (this._value === undefined && this._watching) { + var obj = this._parent.value(); + this._value = lazyGet(obj, this._key); + } + return this._value; + }; - /** - @module ember - @submodule ember-runtime - */ + ChainNode.prototype.destroy = function destroy() { + if (this._watching) { + var obj = this._object; + if (obj) { + removeChainWatcher(obj, this._key, this); + } + this._watching = false; // so future calls do nothing + } + }; - /** - Implements some standard methods for comparing objects. Add this mixin to - any class you create that can compare its instances. - - You should implement the `compare()` method. - - @class Comparable - @namespace Ember - @since Ember 0.9 - @private - */ - exports.default = _emberMetal.Mixin.create({ + // copies a top level object only - /** - __Required.__ You must implement this method to apply this mixin. - Override to return the result of the comparison of the two parameters. The - compare method should return: - - `-1` if `a < b` - - `0` if `a == b` - - `1` if `a > b` - Default implementation raises an exception. - @method compare - @param a {Object} the first object to compare - @param b {Object} the second object to compare - @return {Number} the result of the comparison - @private - */ - compare: null - }); -}); -enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ - 'use strict'; + ChainNode.prototype.copy = function copy(obj) { + var ret = new ChainNode(null, null, obj); + var paths = this._paths; + var path = undefined; + + for (path in paths) { + // this check will also catch non-number vals. + if (paths[path] <= 0) { + continue; + } + ret.add(path); + } + return ret; + }; + + // called on the root node of a chain to setup watchers on the specified + // path. + + ChainNode.prototype.add = function add(path) { + var paths = this._paths; + paths[path] = (paths[path] || 0) + 1; + + var key = firstKey(path); + var tail = path.slice(key.length + 1); + + this.chain(key, tail); + }; + + // called on the root node of a chain to teardown watcher on the specified + // path + + ChainNode.prototype.remove = function remove(path) { + var paths = this._paths; + if (paths[path] > 0) { + paths[path]--; + } + + var key = firstKey(path); + var tail = path.slice(key.length + 1); + + this.unchain(key, tail); + }; - /** - ContainerProxyMixin is used to provide public access to specific - container functionality. - - @class ContainerProxyMixin - @private - */ - exports.default = _emberMetal.Mixin.create({ - /** - The container stores state. - @private - @property {Ember.Container} __container__ - */ - __container__: null, + ChainNode.prototype.chain = function chain(key, path) { + var chains = this._chains; + var node = undefined; + if (chains === undefined) { + chains = this._chains = new _emberUtils.EmptyObject(); + } else { + node = chains[key]; + } - /** - Returns an object that can be used to provide an owner to a - manually created instance. - Example: - ``` - let owner = Ember.getOwner(this); - User.create( - owner.ownerInjection(), - { username: 'rwjblue' } - ) - ``` - @public - @method ownerInjection - @return {Object} - */ - ownerInjection: function () { - return this.__container__.ownerInjection(); - }, + if (node === undefined) { + node = chains[key] = new ChainNode(this, key, undefined); + } - /** - Given a fullName return a corresponding instance. - The default behaviour is for lookup to return a singleton instance. - The singleton is scoped to the container, allowing multiple containers - to all have their own locally scoped singletons. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter'); - twitter instanceof Twitter; // => true - // by default the container will return singletons - let twitter2 = container.lookup('api:twitter'); - twitter2 instanceof Twitter; // => true - twitter === twitter2; //=> true - ``` - If singletons are not wanted an optional flag can be provided at lookup. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter', { singleton: false }); - let twitter2 = container.lookup('api:twitter', { singleton: false }); - twitter === twitter2; //=> false - ``` - @public - @method lookup - @param {String} fullName - @param {Object} options - @return {any} - */ - lookup: function (fullName, options) { - return this.__container__.lookup(fullName, options); - }, + node.count++; // count chains... - /** - Given a fullName return the corresponding factory. - @private - @method _lookupFactory - @param {String} fullName - @return {any} - */ - _lookupFactory: function (fullName, options) { - return this.__container__.lookupFactory(fullName, options); - }, + // chain rest of path if there is one + if (path) { + key = firstKey(path); + path = path.slice(key.length + 1); + node.chain(key, path); + } + }; - /** - Given a name and a source path, resolve the fullName - @private - @method _resolveLocalLookupName - @param {String} fullName - @param {String} source - @return {String} - */ - _resolveLocalLookupName: function (name, source) { - return this.__container__.registry.expandLocalLookup('component:' + name, { - source: source - }); - }, + ChainNode.prototype.unchain = function unchain(key, path) { + var chains = this._chains; + var node = chains[key]; - /** - @private - */ - willDestroy: function () { - this._super.apply(this, arguments); + // unchain rest of path first... + if (path && path.length > 1) { + var nextKey = firstKey(path); + var nextPath = path.slice(nextKey.length + 1); + node.unchain(nextKey, nextPath); + } - if (this.__container__) { - _emberMetal.run(this.__container__, 'destroy'); + // delete node if needed. + node.count--; + if (node.count <= 0) { + chains[node._key] = undefined; + node.destroy(); } - } - }); -}); -enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) { - 'use strict'; + }; - /** - @class ControllerMixin - @namespace Ember - @uses Ember.ActionHandler - @private - */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, { - /* ducktype as a controller */ - isController: true, + ChainNode.prototype.notify = function notify(revalidate, affected) { + if (revalidate && this._watching) { + var parentValue = this._parent.value(); - /** - The object to which actions from the view should be sent. - For example, when a Handlebars template uses the `{{action}}` helper, - it will attempt to send the action to the view's controller's `target`. - By default, the value of the target property is set to the router, and - is injected when a controller is instantiated. This injection is applied - as part of the application's initialization process. In most cases the - `target` property will automatically be set to the logical consumer of - actions for the controller. - @property target - @default null - @public - */ - target: null, + if (parentValue !== this._object) { + if (this._object) { + removeChainWatcher(this._object, this._key, this); + } - store: null, + if (isObject(parentValue)) { + this._object = parentValue; + addChainWatcher(parentValue, this._key, this); + } else { + this._object = undefined; + } + } + this._value = undefined; + } - /** - The controller's current model. When retrieving or modifying a controller's - model, this property should be used instead of the `content` property. - @property model - @public - */ - model: null, + // then notify chains... + var chains = this._chains; + var node = undefined; + if (chains) { + for (var key in chains) { + node = chains[key]; + if (node !== undefined) { + node.notify(revalidate, affected); + } + } + } - /** - @private - */ - content: _emberMetal.alias('model') + if (affected && this._parent) { + this._parent.populateAffected(this._key, 1, affected); + } + }; - }); -}); -enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + ChainNode.prototype.populateAffected = function populateAffected(path, depth, affected) { + if (this._key) { + path = this._key + '.' + path; + } - /* - The ControllerContentModelAliasDeprecation mixin is used to provide a useful - deprecation warning when specifying `content` directly on a `Ember.Controller` - (without also specifying `model`). - - Ember versions prior to 1.7 used `model` as an alias of `content`, but due to - much confusion this alias was reversed (so `content` is now an alias of `model). - - This change reduces many caveats with model/content, and also sets a - simple ground rule: Never set a controllers content, rather always set - its model and ember will do the right thing. - - Used internally by Ember in `Ember.Controller`. - */ - exports.default = _emberMetal.Mixin.create({ - /** - @private - Moves `content` to `model` at extend time if a `model` is not also specified. - Note that this currently modifies the mixin themselves, which is technically - dubious but is practically of little consequence. This may change in the - future. - @method willMergeMixin - @since 1.4.0 - */ - willMergeMixin: function (props) { - // Calling super is only OK here since we KNOW that - // there is another Mixin loaded first. - this._super.apply(this, arguments); + if (this._parent) { + this._parent.populateAffected(path, depth + 1, affected); + } else { + if (depth > 1) { + affected.push(this.value(), path); + } + } + }; - var modelSpecified = !!props.model; + return ChainNode; + })(); - if (props.content && !modelSpecified) { - props.model = props.content; - delete props['content']; + function lazyGet(obj, key) { + if (!isObject(obj)) { + return; + } - _emberMetal.deprecate('Do not specify `content` on a Controller, use `model` instead.', false, { id: 'ember-runtime.will-merge-mixin', until: '3.0.0' }); + var meta = _emberMetalMeta.peekMeta(obj); + + // check if object meant only to be a prototype + if (meta && meta.proto === obj) { + return; + } + + // Use `get` if the return value is an EachProxy or an uncacheable value. + if (isVolatile(obj[key])) { + return _emberMetalProperty_get.get(obj, key); + // Otherwise attempt to get the cached value of the computed property + } else { + var cache = meta.readableCache(); + if (cache) { + return _emberMetalComputed.cacheFor.get(cache, key); + } + } + } + + function finishChains(obj) { + // We only create meta if we really have to + var m = _emberMetalMeta.peekMeta(obj); + if (m) { + m = _emberMetalMeta.meta(obj); + + // finish any current chains node watchers that reference obj + var chainWatchers = m.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidateAll(); + } + // ensure that if we have inherited any chains they have been + // copied onto our own meta. + if (m.readableChains()) { + m.writableChains(_emberMetalWatch_path.makeChainNode); } } - }); + } + + exports.removeChainWatcher = removeChainWatcher; + exports.ChainNode = ChainNode; }); -enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal', 'ember-runtime/mixins/freezable'], function (exports, _emberMetal, _emberRuntimeMixinsFreezable) { +enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) { + 'use strict'; + + exports.default = computed; + /** @module ember - @submodule ember-runtime + @submodule ember-metal */ - 'use strict'; + var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; /** - Implements some standard methods for copying an object. Add this mixin to - any object you create that can create a copy of itself. This mixin is - added automatically to the built-in array. + A computed property transforms an object literal with object's accessor function(s) into a property. - You should generally implement the `copy()` method to return a copy of the - receiver. + 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. - Note that `frozenCopy()` will only work if you also implement - `Ember.Freezable`. + In the following example we declare a computed property - `fullName` - by calling + `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter 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. - @class Copyable + ```javascript + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', function() { + let firstName = this.get('firstName'), + lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + }) + }); + + let 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 by providing additional function (`set`) in hash argument. + If you try to set a computed property, it will try to invoke setter accessor function with the key and + value you want to set it to as arguments. + + ```javascript + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + let firstName = this.get('firstName'), + lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + }, + set(key, value) { + let [firstName, lastName] = value.split(' '); + + this.set('firstName', firstName); + this.set('lastName', lastName); + + return value; + } + }) + }); + + let person = Person.create(); + + person.set('fullName', 'Peter Wagenet'); + person.get('firstName'); // 'Peter' + person.get('lastName'); // 'Wagenet' + ``` + + You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined. + + You can also mark computed property as `.readOnly()` and block all attempts to set it. + + ```javascript + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + let firstName = this.get('firstName'); + let lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + } + }).readOnly() + }); + + let person = Person.create(); + person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX> + ``` + + Additional resources: + - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md) + - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax) + + @class ComputedProperty @namespace Ember - @since Ember 0.9 - @private + @public */ - exports.default = _emberMetal.Mixin.create({ - /** - __Required.__ You must implement this method to apply this mixin. - Override to return a copy of the receiver. Default implementation raises - an exception. - @method copy - @param {Boolean} deep if `true`, a deep copy of the object should be made - @return {Object} copy of receiver - @private - */ - copy: null, - - /** - If the object implements `Ember.Freezable`, then this will return a new - copy if the object is not frozen and the receiver if the object is frozen. - Raises an exception if you try to call this method on a object that does - not support freezing. - You should use this method whenever you want a copy of a freezable object - since a freezable object can simply return itself without actually - consuming more memory. - @method frozenCopy - @return {Object} copy of receiver or receiver - @deprecated Use `Object.freeze` instead. - @private - */ - frozenCopy: function () { - _emberMetal.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.frozen-copy', until: '3.0.0' }); - if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) { - return _emberMetal.get(this, 'isFrozen') ? this : this.copy().freeze(); - } else { - throw new _emberMetal.Error(this + ' does not support freezing'); - } + function ComputedProperty(config, opts) { + this.isDescriptor = true; + if (typeof config === 'function') { + this._getter = config; + } else { + _emberMetalDebug.assert('Ember.computed expects a function or an object as last argument.', typeof config === 'object' && !Array.isArray(config)); + _emberMetalDebug.assert('Config object passed to an Ember.computed can only contain `get` or `set` keys.', (function () { + var keys = Object.keys(config); + for (var i = 0; i < keys.length; i++) { + if (keys[i] !== 'get' && keys[i] !== 'set') { + return false; + } + } + return true; + })()); + this._getter = config.get; + this._setter = config.set; } - }); -}); -enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'require'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _require) { - /** - @module ember - @submodule ember-runtime - */ - - // .......................................................... - // HELPERS - // - - 'use strict'; - - var _emberA = undefined; - - function emberA() { - return (_emberA || (_emberA = _require.default('ember-runtime/system/native_array').A))(); - } - - var contexts = []; - - function popCtx() { - return contexts.length === 0 ? {} : contexts.pop(); + _emberMetalDebug.assert('Computed properties must receive a getter or a setter, you passed none.', !!this._getter || !!this._setter); + this._dependentKeys = undefined; + this._suspended = undefined; + this._meta = undefined; + this._volatile = false; + this._dependentKeys = opts && opts.dependentKeys; + this._readOnly = false; } - function pushCtx(ctx) { - contexts.push(ctx); - return null; - } + ComputedProperty.prototype = new _emberMetalProperties.Descriptor(); + ComputedProperty.prototype.constructor = ComputedProperty; - function iter(key, value) { - var valueProvided = arguments.length === 2; + var ComputedPropertyPrototype = ComputedProperty.prototype; - function i(item) { - var cur = _emberMetal.get(item, key); - return valueProvided ? value === cur : !!cur; - } + /** + 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. + + It also does not automatically fire any change events. You must manually notify + any changes if you want to observe this property. + + Dependency keys have no effect on volatile properties as they are for cache + invalidation and notification when cached value is invalidated. + + ```javascript + let outsideService = Ember.Object.extend({ + value: Ember.computed(function() { + return OutsideService.getValue(); + }).volatile() + }).create(); + ``` + + @method volatile + @return {Ember.ComputedProperty} this + @chainable + @public + */ + ComputedPropertyPrototype.volatile = function () { + this._volatile = true; + return this; + }; - return i; - } + /** + 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 + let Person = Ember.Object.extend({ + guid: Ember.computed(function() { + return 'guid-guid-guid'; + }).readOnly() + }); + + let person = Person.create(); + + person.set('guid', 'new-guid'); // will throw an exception + ``` + + @method readOnly + @return {Ember.ComputedProperty} this + @chainable + @public + */ + ComputedPropertyPrototype.readOnly = function () { + this._readOnly = true; + _emberMetalDebug.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; + }; /** - This mixin defines the common interface implemented by enumerable objects - in Ember. Most of these methods follow the standard Array iteration - API defined up to JavaScript 1.8 (excluding language-specific features that - cannot be emulated in older versions of JavaScript). + Sets the dependent keys on this computed property. Pass any number of + arguments containing key paths that this computed property depends on. - This mixin is applied automatically to the Array class on page load, so you - can use any of these methods on simple arrays. If Array already implements - one of these methods, the mixin will not override them. + ```javascript + let President = Ember.Object.extend({ + fullName: Ember.computed(function() { + return this.get('firstName') + ' ' + this.get('lastName'); - ## Writing Your Own Enumerable + // Tell Ember that this computed property depends on firstName + // and lastName + }).property('firstName', 'lastName') + }); - To make your own custom class enumerable, you need two items: + let president = President.create({ + firstName: 'Barack', + lastName: 'Obama' + }); - 1. You must have a length property. This property should change whenever - the number of items in your enumerable object changes. If you use this - with an `Ember.Object` subclass, you should be sure to change the length - property using `set().` + president.get('fullName'); // 'Barack Obama' + ``` - 2. You must implement `nextObject().` See documentation. + @method property + @param {String} path* zero or more property paths + @return {Ember.ComputedProperty} this + @chainable + @public + */ + ComputedPropertyPrototype.property = function () { + var args = []; + + function addArg(property) { + _emberMetalDebug.warn('Dependent keys containing @each only work one level deep. ' + ('You used the key "' + property + '" which is invalid. ') + 'Please create an intermediary computed property.', DEEP_EACH_REGEX.test(property) === false, { id: 'ember-metal.computed-deep-each' }); + args.push(property); + } + + for (var i = 0; i < arguments.length; 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. - Once you have these two methods implemented, apply the `Ember.Enumerable` mixin - to your class and you will be able to enumerate the contents of your object - like any other collection. + You can pass a hash of these values to a computed property like this: - ## Using Ember Enumeration with Other Libraries + ``` + person: Ember.computed(function() { + let personId = this.get('personId'); + return App.Person.create({ id: personId }); + }).meta({ type: App.Person }) + ``` - Many other libraries provide some kind of iterator or enumeration like - facility. This is often where the most common API conflicts occur. - Ember's API is designed to be as friendly as possible with other - libraries by implementing only methods that mostly correspond to the - JavaScript 1.8 API. + 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. - @class Enumerable - @namespace Ember - @since Ember 0.9 - @private + @method meta + @param {Object} meta + @chainable + @public */ - var Enumerable = _emberMetal.Mixin.create({ + ComputedPropertyPrototype.meta = function (meta) { + if (arguments.length === 0) { + return this._meta || {}; + } else { + this._meta = meta; + return this; + } + }; - /** - __Required.__ You must implement this method to apply this mixin. - Implement this method to make your class enumerable. - This method will be called repeatedly during enumeration. The index value - will always begin with 0 and increment monotonically. You don't have to - rely on the index value to determine what object to return, but you should - always check the value and start from the beginning when you see the - requested index is 0. - The `previousObject` is the object that was returned from the last call - to `nextObject` for the current iteration. This is a useful way to - manage iteration if you are tracing a linked list, for example. - Finally the context parameter will always contain a hash you can use as - a "scratchpad" to maintain any other state you need in order to iterate - properly. The context object is reused and is not reset between - iterations so make sure you setup the context with a fresh state whenever - the index parameter is 0. - Generally iterators will continue to call `nextObject` until the index - reaches the current length-1. If you run out of data before this - time for some reason, you should simply return undefined. - The default implementation of this method simply looks up the index. - This works great on any Array-like objects. - @method nextObject - @param {Number} index the current index of the iteration - @param {Object} previousObject the value returned by the last call to - `nextObject`. - @param {Object} context a context object you can use to maintain state. - @return {Object} the next object in the iteration or undefined - @private - */ - nextObject: null, + // invalidate cache when CP key changes + 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._volatile || this._suspended === obj) { + return; + } - /** - Helper method returns the first object from a collection. This is usually - used by bindings and other parts of the framework to extract a single - object if the enumerable contains only one item. - If you override this method, you should implement it so that it will - always return the same value each time it is called. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - ```javascript - let arr = ['a', 'b', 'c']; - arr.get('firstObject'); // 'a' - let arr = []; - arr.get('firstObject'); // undefined - ``` - @property firstObject - @return {Object} the object or undefined - @readOnly - @public - */ - firstObject: _emberMetal.computed('[]', function () { - if (_emberMetal.get(this, 'length') === 0) { - return undefined; - } + // don't create objects just to invalidate + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta || meta.source !== obj) { + return; + } - // handle generic enumerables - var context = popCtx(); - var ret = this.nextObject(0, null, context); + var cache = meta.readableCache(); + if (cache && cache[keyName] !== undefined) { + cache[keyName] = undefined; + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + } + }; - pushCtx(context); + ComputedPropertyPrototype.get = function (obj, keyName) { + if (this._volatile) { + return this._getter.call(obj, keyName); + } - return ret; - }).readOnly(), + var meta = _emberMetalMeta.meta(obj); + var cache = meta.writableCache(); - /** - Helper method returns the last object from a collection. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - ```javascript - let arr = ['a', 'b', 'c']; - arr.get('lastObject'); // 'c' - let arr = []; - arr.get('lastObject'); // undefined - ``` - @property lastObject - @return {Object} the last object or undefined - @readOnly - @public - */ - lastObject: _emberMetal.computed('[]', function () { - var len = _emberMetal.get(this, 'length'); + var result = cache[keyName]; + if (result === _emberMetalMeta.UNDEFINED) { + return undefined; + } else if (result !== undefined) { + return result; + } - if (len === 0) { - return undefined; - } + var ret = this._getter.call(obj, keyName); + if (ret === undefined) { + cache[keyName] = _emberMetalMeta.UNDEFINED; + } else { + cache[keyName] = ret; + } - var context = popCtx(); - var idx = 0; - var last = null; - var cur = undefined; + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidate(keyName); + } + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - do { - last = cur; - cur = this.nextObject(idx++, last, context); - } while (cur !== undefined); + return ret; + }; - pushCtx(context); + ComputedPropertyPrototype.set = function computedPropertySetEntry(obj, keyName, value) { + if (this._readOnly) { + this._throwReadOnlyError(obj, keyName); + } - return last; - }).readOnly(), + if (!this._setter) { + return this.clobberSet(obj, keyName, value); + } - /** - Returns `true` if the passed object can be found in the receiver. The - default version will iterate through the enumerable until the object - is found. You may want to override this with a more efficient version. - ```javascript - let arr = ['a', 'b', 'c']; - arr.contains('a'); // true - arr.contains('z'); // false - ``` - @method contains - @deprecated Use `Enumerable#includes` instead. See http://emberjs.com/deprecations/v2.x#toc_enumerable-contains - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in enumerable. - @public - */ - contains: function (obj) { - if (true) { - _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - } + if (this._volatile) { + return this.volatileSet(obj, keyName, value); + } - var found = this.find(function (item) { - return item === obj; - }); + return this.setWithSuspend(obj, keyName, value); + }; - return found !== undefined; - }, + ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) { + throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj)); + }; - /** - Iterates through the enumerable, calling the passed function on each - item. This method corresponds to the `forEach()` method defined in - JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method forEach - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Object} receiver - @public - */ - forEach: function (callback, target) { - if (typeof callback !== 'function') { - throw new TypeError(); - } + ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) { + var cachedValue = cacheFor(obj, keyName); + _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue); + _emberMetalProperty_set.set(obj, keyName, value); + return value; + }; - var context = popCtx(); - var len = _emberMetal.get(this, 'length'); - var last = null; + ComputedPropertyPrototype.volatileSet = function computedPropertyVolatileSet(obj, keyName, value) { + return this._setter.call(obj, keyName, value); + }; - if (target === undefined) { - target = null; - } + ComputedPropertyPrototype.setWithSuspend = function computedPropertySetWithSuspend(obj, keyName, value) { + var oldSuspended = this._suspended; + this._suspended = obj; + try { + return this._set(obj, keyName, value); + } finally { + this._suspended = oldSuspended; + } + }; - for (var idx = 0; idx < len; idx++) { - var next = this.nextObject(idx, last, context); - callback.call(target, next, idx, this); - last = next; + ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { + // cache requires own meta + var meta = _emberMetalMeta.meta(obj); + // either there is a writable cache or we need one to update + var cache = meta.writableCache(); + var hadCachedValue = false; + var cachedValue = undefined; + if (cache[keyName] !== undefined) { + if (cache[keyName] !== _emberMetalMeta.UNDEFINED) { + cachedValue = cache[keyName]; } + hadCachedValue = true; + } - last = null; - context = pushCtx(context); + var ret = this._setter.call(obj, keyName, value, cachedValue); - return this; - }, + // allows setter to return the same value that is cached already + if (hadCachedValue && cachedValue === ret) { + return ret; + } - /** - Alias for `mapBy` - @method getEach - @param {String} key name of the property - @return {Array} The mapped array. - @public - */ - getEach: _emberMetal.aliasMethod('mapBy'), + _emberMetalProperty_events.propertyWillChange(obj, keyName); - /** - Sets the value on the named property for each member. This is more - ergonomic than using other methods defined on this helper. If the object - implements Ember.Observable, the value will be changed to `set(),` otherwise - it will be set directly. `null` objects are skipped. - @method setEach - @param {String} key The key to set - @param {Object} value The object to set - @return {Object} receiver - @public - */ - setEach: function (key, value) { - return this.forEach(function (item) { - return _emberMetal.set(item, key, value); - }); - }, + if (hadCachedValue) { + cache[keyName] = undefined; + } - /** - Maps all of the items in the enumeration to another value, returning - a new array. This method corresponds to `map()` defined in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the mapped value. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method map - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} The mapped array. - @public - */ - map: function (callback, target) { - var ret = emberA(); + if (!hadCachedValue) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } - this.forEach(function (x, idx, i) { - return ret[idx] = callback.call(target, x, idx, i); - }); + if (ret === undefined) { + cache[keyName] = _emberMetalMeta.UNDEFINED; + } else { + cache[keyName] = ret; + } - return ret; - }, + _emberMetalProperty_events.propertyDidChange(obj, keyName); - /** - Similar to map, this specialized function returns the value of the named - property on all items in the enumeration. - @method mapBy - @param {String} key name of the property - @return {Array} The mapped array. - @public - */ - mapBy: function (key) { - return this.map(function (next) { - return _emberMetal.get(next, key); - }); - }, + return ret; + }; - /** - Returns an array with all of the items in the enumeration that the passed - function returns true for. This method corresponds to `filter()` defined in - JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method filter - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} A filtered array. - @public - */ - filter: function (callback, target) { - var ret = emberA(); + /* called before property is overridden */ + ComputedPropertyPrototype.teardown = function (obj, keyName) { + if (this._volatile) { + return; + } + var meta = _emberMetalMeta.meta(obj); + var cache = meta.readableCache(); + if (cache && cache[keyName] !== undefined) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + cache[keyName] = undefined; + } + }; - this.forEach(function (x, idx, i) { - if (callback.call(target, x, idx, i)) { - ret.push(x); + /** + This helper returns a new property descriptor that wraps the passed + computed property function. You can use this helper to define properties + with mixins or via `Ember.defineProperty()`. + + If you pass a function as an argument, it will be used as a getter. A computed + property defined in this way might look like this: + + ```js + let Person = Ember.Object.extend({ + init() { + this._super(...arguments); + + this.firstName = 'Betty'; + this.lastName = 'Jones'; + }, + + fullName: Ember.computed('firstName', 'lastName', function() { + return `${this.get('firstName')} ${this.get('lastName')}`; + }) + }); + + let client = Person.create(); + + client.get('fullName'); // 'Betty Jones' + + client.set('lastName', 'Fuller'); + client.get('fullName'); // 'Betty Fuller' + ``` + + You can pass a hash with two functions, `get` and `set`, as an + argument to provide both a getter and setter: + + ```js + let Person = Ember.Object.extend({ + init() { + this._super(...arguments); + + this.firstName = 'Betty'; + this.lastName = 'Jones'; + }, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + return `${this.get('firstName')} ${this.get('lastName')}`; + }, + set(key, value) { + let [firstName, lastName] = value.split(/\s+/); + this.setProperties({ firstName, lastName }); + return value; } - }); - - return ret; - }, - - /** - Returns an array with all of the items in the enumeration where the passed - function returns false. This method is the inverse of filter(). - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - *item* is the current item in the iteration. - - *index* is the current index in the iteration - - *enumerable* is the enumerable object itself. - It should return a falsey value to include the item in the results. - Note that in addition to a callback, you can also pass an optional target - object that will be set as "this" on the context. This is a good way - to give your iterator function access to the current object. - @method reject - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} A rejected array. - @public - */ - reject: function (callback, target) { - return this.filter(function () { - return !callback.apply(target, arguments); - }); - }, + }) + }); + + let client = Person.create(); + client.get('firstName'); // 'Betty' + + client.set('fullName', 'Carroll Fuller'); + client.get('firstName'); // 'Carroll' + ``` + + The `set` function should accept two parameters, `key` and `value`. The value + returned from `set` will be the new value of the property. + + _Note: This is the preferred way to define computed properties when writing third-party + libraries that depend on or use Ember, since there is no guarantee that the user + will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._ + + The alternative syntax, with prototype extensions, might look like: + + ```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 + */ - /** - Returns an array with just the items with the matched property. You - can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to `true`. - @method filterBy - @param {String} key the property to test - @param {*} [value] optional value to test against. - @return {Array} filtered array - @public - */ - filterBy: function (key, value) { - return this.filter(iter.apply(this, arguments)); - }, + function computed(func) { + var args = undefined; - /** - Returns an array with the items that do not have truthy values for - key. You can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to false. - @method rejectBy - @param {String} key the property to test - @param {String} [value] optional value to test against. - @return {Array} rejected array - @public - */ - rejectBy: function (key, value) { - var exactValue = function (item) { - return _emberMetal.get(item, key) === value; - }; - var hasValue = function (item) { - return !!_emberMetal.get(item, key); - }; - var use = arguments.length === 2 ? exactValue : hasValue; + if (arguments.length > 1) { + args = [].slice.call(arguments); + func = args.pop(); + } - return this.reject(use); - }, + var cp = new ComputedProperty(func); - /** - Returns the first item in the array for which the callback returns true. - This method works similar to the `filter()` method defined in JavaScript 1.6 - except that it will stop working on the array once a match is found. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method find - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Object} Found item or `undefined`. - @public - */ - find: function (callback, target) { - var len = _emberMetal.get(this, 'length'); + if (args) { + cp.property.apply(cp, args); + } - if (target === undefined) { - target = null; - } + return cp; + } - var context = popCtx(); - var found = false; - var last = null; - var next = undefined, - ret = undefined; + /** + 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 = _emberMetalMeta.peekMeta(obj); + var cache = meta && meta.source === obj && meta.readableCache(); + var ret = cache && cache[key]; - for (var idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); + if (ret === _emberMetalMeta.UNDEFINED) { + return undefined; + } + return ret; + } - found = callback.call(target, next, idx, this); - if (found) { - ret = next; - } + cacheFor.set = function (cache, key, value) { + if (value === undefined) { + cache[key] = _emberMetalMeta.UNDEFINED; + } else { + cache[key] = value; + } + }; - last = next; - } + cacheFor.get = function (cache, key) { + var ret = cache[key]; + if (ret === _emberMetalMeta.UNDEFINED) { + return undefined; + } + return ret; + }; - next = last = null; - context = pushCtx(context); + cacheFor.remove = function (cache, key) { + cache[key] = undefined; + }; - return ret; - }, + exports.ComputedProperty = ComputedProperty; + exports.computed = computed; + exports.cacheFor = cacheFor; +}); +enifed('ember-metal/core', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; - /** - Returns the first item with a property matching the passed value. You - can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to `true`. - This method works much like the more generic `find()` method. - @method findBy - @param {String} key the property to test - @param {String} [value] optional value to test against. - @return {Object} found item or `undefined` - @public - */ - findBy: function (key, value) { - return this.find(iter.apply(this, arguments)); - }, + /** + @module ember + @submodule ember-metal + */ - /** - Returns `true` if the passed function returns true for every item in the - enumeration. This corresponds with the `every()` method in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` or `false`. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - Example Usage: - ```javascript - if (people.every(isEngineer)) { - Paychecks.addBigBonus(); - } - ``` - @method every - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Boolean} - @public - */ - every: function (callback, target) { - return !this.find(function (x, idx, i) { - return !callback.call(target, x, idx, i); - }); - }, + /** + This namespace contains all Ember methods and functions. Future versions of + Ember may overwrite this namespace and therefore, you should avoid adding any + new properties. + + At the heart of Ember is Ember-Runtime, a set of core functions that provide + cross-platform compatibility and object property observing. Ember-Runtime is + small and performance-focused so you can use it alongside other + cross-platform libraries such as jQuery. For more details, see + [Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html). + + @class Ember + @static + @public + */ + var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {}; - /** - Returns `true` if the passed property resolves to the value of the second - argument for all items in the enumerable. This method is often simpler/faster - than using a callback. - @method isEvery - @param {String} key the property to test - @param {String} [value] optional value to test against. Defaults to `true` - @return {Boolean} - @since 1.3.0 - @public - */ - isEvery: function (key, value) { - return this.every(iter.apply(this, arguments)); - }, + // Make sure these are set whether Ember was already defined or not + Ember.isNamespace = true; + Ember.toString = function () { + return 'Ember'; + }; - /** - Returns `true` if the passed function returns true for any item in the - enumeration. This corresponds with the `some()` method in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - Usage Example: - ```javascript - if (people.any(isManager)) { - Paychecks.addBiggerBonus(); - } - ``` - @method any - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Boolean} `true` if the passed function returns `true` for any item - @public - */ - any: function (callback, target) { - var len = _emberMetal.get(this, 'length'); - var context = popCtx(); - var found = false; - var last = null; - var next = undefined; + // .......................................................... + // BOOTSTRAP + // - if (target === undefined) { - target = null; - } + exports.default = Ember; +}); +enifed("ember-metal/debug", ["exports"], function (exports) { + "use strict"; - for (var idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); - found = callback.call(target, next, idx, this); - last = next; + exports.getDebugFunction = getDebugFunction; + exports.setDebugFunction = setDebugFunction; + exports.assert = assert; + exports.info = info; + exports.warn = warn; + exports.debug = debug; + exports.deprecate = deprecate; + exports.deprecateFunc = deprecateFunc; + exports.runInDebug = runInDebug; + exports.debugSeal = debugSeal; + exports.debugFreeze = debugFreeze; + var debugFunctions = { + assert: function () {}, + info: function () {}, + warn: function () {}, + debug: function () {}, + deprecate: function () {}, + deprecateFunc: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - next = last = null; - context = pushCtx(context); - return found; + return args[args.length - 1]; }, + runInDebug: function () {}, + debugSeal: function () {}, + debugFreeze: function () {} + }; - /** - Returns `true` if the passed property resolves to the value of the second - argument for any item in 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. Defaults to `true` - @return {Boolean} - @since 1.3.0 - @public - */ - isAny: function (key, value) { - return this.any(iter.apply(this, arguments)); - }, + exports.debugFunctions = debugFunctions; - /** - This will combine the values of the enumerator into a single value. It - is a useful way to collect a summary value from an enumeration. This - corresponds to the `reduce()` method defined in JavaScript 1.8. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(previousValue, item, index, enumerable); - ``` - - `previousValue` is the value returned by the last call to the iterator. - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - Return the new cumulative value. - In addition to the callback you can also pass an `initialValue`. An error - will be raised if you do not pass an initial value and the enumerator is - empty. - Note that unlike the other methods, this method does not allow you to - pass a target object to set as this for the callback. It's part of the - spec. Sorry. - @method reduce - @param {Function} callback The callback to execute - @param {Object} initialValue Initial value for the reduce - @param {String} reducerProperty internal use only. - @return {Object} The reduced value. - @public - */ - reduce: function (callback, initialValue, reducerProperty) { - if (typeof callback !== 'function') { - throw new TypeError(); - } + function getDebugFunction(name) { + return debugFunctions[name]; + } - var ret = initialValue; + function setDebugFunction(name, fn) { + debugFunctions[name] = fn; + } - this.forEach(function (item, i) { - ret = callback(ret, item, i, this, reducerProperty); - }, this); + function assert() { + return debugFunctions.assert.apply(undefined, arguments); + } - return ret; - }, + function info() { + return debugFunctions.info.apply(undefined, arguments); + } - /** - Invokes the named method on every object in the receiver that - implements it. This method corresponds to the implementation in - Prototype 1.6. - @method invoke - @param {String} methodName the name of the method - @param {Object...} args optional arguments to pass as well. - @return {Array} return values from calling invoke. - @public - */ - invoke: function (methodName) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } + function warn() { + return debugFunctions.warn.apply(undefined, arguments); + } - var ret = emberA(); + function debug() { + return debugFunctions.debug.apply(undefined, arguments); + } - this.forEach(function (x, idx) { - var method = x && x[methodName]; + function deprecate() { + return debugFunctions.deprecate.apply(undefined, arguments); + } - if ('function' === typeof method) { - ret[idx] = args ? method.apply(x, args) : x[methodName](); - } - }, this); + function deprecateFunc() { + return debugFunctions.deprecateFunc.apply(undefined, arguments); + } - return ret; - }, + function runInDebug() { + return debugFunctions.runInDebug.apply(undefined, arguments); + } - /** - Simply converts the enumerable into a genuine array. The order is not - guaranteed. Corresponds to the method implemented by Prototype. - @method toArray - @return {Array} the enumerable as an array. - @public - */ - toArray: function () { - var ret = emberA(); + function debugSeal() { + return debugFunctions.debugSeal.apply(undefined, arguments); + } + + function debugFreeze() { + return debugFunctions.debugFreeze.apply(undefined, arguments); + } +}); +enifed('ember-metal/dependent_keys', ['exports', 'ember-metal/watching'], function (exports, _emberMetalWatching) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - this.forEach(function (o, idx) { - return ret[idx] = o; - }); + exports.addDependentKeys = addDependentKeys; + exports.removeDependentKeys = removeDependentKeys; - return ret; - }, + /** + @module ember + @submodule ember-metal + */ - /** - Returns a copy of the array with all `null` and `undefined` elements removed. - ```javascript - let arr = ['a', null, 'c', undefined]; - arr.compact(); // ['a', 'c'] - ``` - @method compact - @return {Array} the array without null and undefined elements. - @public - */ - compact: function () { - return this.filter(function (value) { - return value != null; - }); - }, + // .......................................................... + // DEPENDENT KEYS + // - /** - Returns a new enumerable that excludes the passed value. The default - implementation returns an array regardless of the receiver type. - If the receiver does not contain the value it returns the original enumerable. - ```javascript - let arr = ['a', 'b', 'a', 'c']; - arr.without('a'); // ['b', 'c'] - ``` - @method without - @param {Object} value - @return {Ember.Enumerable} - @public - */ - without: function (value) { - if (!this.contains(value)) { - return this; // nothing to do - } + function addDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // add all of its dependent keys. + var idx = undefined, + depKey = undefined; + var depKeys = desc._dependentKeys; + if (!depKeys) { + return; + } - var ret = emberA(); + for (idx = 0; idx < depKeys.length; idx++) { + depKey = depKeys[idx]; + // Increment the number of times depKey depends on keyName. + meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1); + // Watch the depKey + _emberMetalWatching.watch(obj, depKey, meta); + } + } - this.forEach(function (k) { - if (k !== value) { - ret[ret.length] = k; - } - }); + function removeDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // remove all of its dependent keys. + var depKeys = desc._dependentKeys; + if (!depKeys) { + return; + } - return ret; - }, + for (var idx = 0; idx < depKeys.length; idx++) { + var depKey = depKeys[idx]; + // Decrement the number of times depKey depends on keyName. + meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1); + // Unwatch the depKey + _emberMetalWatching.unwatch(obj, depKey, meta); + } + } +}); +enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set) { + /** + @module ember + @submodule ember-metal + */ - /** - Returns a new enumerable that contains only unique values. The default - implementation returns an array regardless of the receiver type. - ```javascript - let arr = ['a', 'a', 'b', 'b']; - arr.uniq(); // ['a', 'b'] - ``` - This only works on primitive data types, e.g. Strings, Numbers, etc. - @method uniq - @return {Ember.Enumerable} - @public - */ - uniq: function () { - var ret = emberA(); + 'use strict'; - this.forEach(function (k) { - if (ret.indexOf(k) < 0) { - ret.push(k); - } - }); + exports.deprecateProperty = deprecateProperty; - return ret; - }, + /** + Used internally to allow changing properties in a backwards compatible way, and print a helpful + deprecation warning. + + @method deprecateProperty + @param {Object} object The object to add the deprecated property to. + @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). + @param {String} newKey The property that will be aliased. + @private + @since 1.7.0 + */ - /** - This property will trigger anytime the enumerable's content changes. - You can observe this property to be notified of changes to the enumerable's - content. - For plain enumerables, this property is read only. `Array` overrides - this method. - @property [] - @type Array - @return this - @private - */ - '[]': _emberMetal.computed({ - get: function (key) { - return this; - } - }), + function deprecateProperty(object, deprecatedKey, newKey, options) { + function _deprecate() { + _emberMetalDebug.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.', false, options); + } - // .......................................................... - // ENUMERABLE OBSERVERS - // + Object.defineProperty(object, deprecatedKey, { + configurable: true, + enumerable: false, + set: function (value) { + _deprecate(); + _emberMetalProperty_set.set(this, newKey, value); + }, + get: function () { + _deprecate(); + return _emberMetalProperty_get.get(this, newKey); + } + }); + } +}); +enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) { + 'use strict'; - /** - Registers an enumerable observer. Must implement `Ember.EnumerableObserver` - mixin. - @method addEnumerableObserver - @param {Object} target - @param {Object} [opts] - @return this - @private - */ - addEnumerableObserver: function (target, opts) { - var willChange = opts && opts.willChange || 'enumerableWillChange'; - var didChange = opts && opts.didChange || 'enumerableDidChange'; - var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); + exports.default = descriptor; - if (!hasObservers) { - _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); - } + function descriptor(desc) { + return new Descriptor(desc); + } - _emberMetal.addListener(this, '@enumerable:before', target, willChange); - _emberMetal.addListener(this, '@enumerable:change', target, didChange); + /** + A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need + this at all, however, the way we currently flatten/merge our mixins require + a special value to denote a descriptor. + + @class Descriptor + @private + */ - if (!hasObservers) { - _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); - } + var Descriptor = (function (_EmberDescriptor) { + babelHelpers.inherits(Descriptor, _EmberDescriptor); - return this; - }, + function Descriptor(desc) { + babelHelpers.classCallCheck(this, Descriptor); - /** - Removes a registered enumerable observer. - @method removeEnumerableObserver - @param {Object} target - @param {Object} [opts] - @return this - @private - */ - removeEnumerableObserver: function (target, opts) { - var willChange = opts && opts.willChange || 'enumerableWillChange'; - var didChange = opts && opts.didChange || 'enumerableDidChange'; - var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); + _EmberDescriptor.call(this); + this.desc = desc; + } - if (hasObservers) { - _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); - } + Descriptor.prototype.setup = function setup(obj, key) { + Object.defineProperty(obj, key, this.desc); + }; - _emberMetal.removeListener(this, '@enumerable:before', target, willChange); - _emberMetal.removeListener(this, '@enumerable:change', target, didChange); + Descriptor.prototype.teardown = function teardown(obj, key) {}; - if (hasObservers) { - _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); - } + return Descriptor; + })(_emberMetalProperties.Descriptor); +}); +enifed("ember-metal/error", ["exports"], function (exports) { - return this; - }, + /** + A subclass of the JavaScript Error object for use in Ember. + + @class Error + @namespace Ember + @extends Error + @constructor + @public + */ + "use strict"; - /** - Becomes true whenever the array currently has observers watching changes - on the array. - @property hasEnumerableObservers - @type Boolean - @private - */ - hasEnumerableObservers: _emberMetal.computed(function () { - return _emberMetal.hasListeners(this, '@enumerable:change') || _emberMetal.hasListeners(this, '@enumerable:before'); - }), + var EmberError = (function (_Error) { + babelHelpers.inherits(EmberError, _Error); - /** - Invoke this method just before the contents of your enumerable will - change. You can either omit the parameters completely or pass the objects - to be removed or added if available or just a count. - @method enumerableContentWillChange - @param {Ember.Enumerable|Number} removing An enumerable of the objects to - be removed or the number of items to be removed. - @param {Ember.Enumerable|Number} adding An enumerable of the objects to be - added or the number of items to be added. - @chainable - @private - */ - enumerableContentWillChange: function (removing, adding) { - var removeCnt = undefined, - addCnt = undefined, - hasDelta = undefined; + function EmberError(message) { + babelHelpers.classCallCheck(this, EmberError); - if ('number' === typeof removing) { - removeCnt = removing; - } else if (removing) { - removeCnt = _emberMetal.get(removing, 'length'); - } else { - removeCnt = removing = -1; - } + _Error.call(this); - if ('number' === typeof adding) { - addCnt = adding; - } else if (adding) { - addCnt = _emberMetal.get(adding, 'length'); - } else { - addCnt = adding = -1; + if (!(this instanceof EmberError)) { + return new EmberError(message); } - hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; + var error = Error.call(this, message); - if (removing === -1) { - removing = null; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, EmberError); + } else { + this.stack = error.stack; } - if (adding === -1) { - adding = null; - } + this.description = error.description; + this.fileName = error.fileName; + this.lineNumber = error.lineNumber; + this.message = error.message; + this.name = error.name; + this.number = error.number; + this.code = error.code; + } - _emberMetal.propertyWillChange(this, '[]'); + return EmberError; + })(Error); - if (hasDelta) { - _emberMetal.propertyWillChange(this, 'length'); - } + exports.default = EmberError; +}); +enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { + 'use strict'; - _emberMetal.sendEvent(this, '@enumerable:before', [this, removing, adding]); + exports.getOnerror = getOnerror; + exports.setOnerror = setOnerror; + exports.dispatchError = dispatchError; + exports.setDispatchOverride = setDispatchOverride; - return this; - }, + // To maintain stacktrace consistency across browsers + var getStack = function (error) { + var stack = error.stack; + var message = error.message; - /** - Invoke this method when the contents of your enumerable has changed. - This will notify any observers watching for content changes. If you are - implementing an ordered enumerable (such as an array), also pass the - start and end values where the content changed so that it can be used to - notify range observers. - @method enumerableContentDidChange - @param {Ember.Enumerable|Number} removing An enumerable of the objects to - be removed or the number of items to be removed. - @param {Ember.Enumerable|Number} adding An enumerable of the objects to - be added or the number of items to be added. - @chainable - @private - */ - enumerableContentDidChange: function (removing, adding) { - var removeCnt = undefined, - addCnt = undefined, - hasDelta = undefined; + if (stack && !stack.includes(message)) { + stack = message + '\n' + stack; + } - if ('number' === typeof removing) { - removeCnt = removing; - } else if (removing) { - removeCnt = _emberMetal.get(removing, 'length'); - } else { - removeCnt = removing = -1; - } + return stack; + }; - if ('number' === typeof adding) { - addCnt = adding; - } else if (adding) { - addCnt = _emberMetal.get(adding, 'length'); - } else { - addCnt = adding = -1; - } + var onerror = undefined; + // Ember.onerror getter - hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; + function getOnerror() { + return onerror; + } - if (removing === -1) { - removing = null; - } + // Ember.onerror setter - if (adding === -1) { - adding = null; - } + function setOnerror(handler) { + onerror = handler; + } - _emberMetal.sendEvent(this, '@enumerable:change', [this, removing, adding]); + var dispatchOverride = undefined; + // dispatch error - if (hasDelta) { - _emberMetal.propertyDidChange(this, 'length'); - } + function dispatchError(error) { + if (dispatchOverride) { + dispatchOverride(error); + } else { + defaultDispatch(error); + } + } - _emberMetal.propertyDidChange(this, '[]'); + // allows testing adapter to override dispatch - return this; - }, + function setDispatchOverride(handler) { + dispatchOverride = handler; + } - /** - Converts the enumerable into an array and sorts by the keys - specified in the argument. - You may provide multiple arguments to sort by multiple properties. - @method sortBy - @param {String} property name(s) to sort on - @return {Array} The sorted array. - @since 1.2.0 - @public - */ - sortBy: function () { - var sortKeys = arguments; + function defaultDispatch(error) { + if (_emberMetalTesting.isTesting()) { + throw error; + } + if (onerror) { + onerror(error); + } else { + _emberConsole.default.error(getStack(error)); + } + } +}); +enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - return this.toArray().sort(function (a, b) { - for (var i = 0; i < sortKeys.length; i++) { - var key = sortKeys[i]; - var propA = _emberMetal.get(a, key); - var propB = _emberMetal.get(b, key); - // return 1 or -1 else continue to the next sortKey - var compareValue = _emberRuntimeCompare.default(propA, propB); + /** + @module ember + @submodule ember-metal + */ + exports.accumulateListeners = accumulateListeners; + exports.addListener = addListener; + exports.removeListener = removeListener; + exports.suspendListener = suspendListener; + exports.suspendListeners = suspendListeners; + exports.watchedEvents = watchedEvents; + exports.sendEvent = sendEvent; + exports.hasListeners = hasListeners; + exports.listenersFor = listenersFor; + exports.on = on; - if (compareValue) { - return compareValue; + /* + The event system uses a series of nested hashes to store listeners on an + object. When a listener is registered, or when an event arrives, these + hashes are consulted to determine which target and action pair to invoke. + + The hashes are stored in the object's meta hash, and look like this: + + // Object's meta hash + { + listeners: { // variable name: `listenerSet` + "foo:changed": [ // variable name: `actions` + target, method, flags + ] } } - return 0; - }); - } - }); + + */ - if (true) { - Enumerable.reopen({ - /** - Returns a new enumerable that contains only items containing a unique property value. - The default implementation returns an array regardless of the receiver type. - ```javascript - let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; - arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] - ``` - @method uniqBy - @return {Ember.Enumerable} - @public - */ + function indexOf(array, target, method) { + var index = -1; + // hashes are added to the end of the event array + // so it makes sense to start searching at the end + // of the array and search in reverse + for (var i = array.length - 3; i >= 0; i -= 3) { + if (target === array[i] && method === array[i + 1]) { + index = i; + break; + } + } + return index; + } - uniqBy: function (key) { - var ret = emberA(); - var seen = new _emberUtils.EmptyObject(); + function accumulateListeners(obj, eventName, otherActions) { + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta) { + return; + } + var actions = meta.matchingListeners(eventName); + var newActions = []; - this.forEach(function (item) { - var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); - if (!(guid in seen)) { - seen[guid] = true; - ret.push(item); - } - }); + for (var i = actions.length - 3; i >= 0; i -= 3) { + var target = actions[i]; + var method = actions[i + 1]; + var flags = actions[i + 2]; + var actionIndex = indexOf(otherActions, target, method); - return ret; + if (actionIndex === -1) { + otherActions.push(target, method, flags); + newActions.push(target, method, flags); } - }); - } + } - if (true) { - Enumerable.reopen({ - /** - Returns `true` if the passed object can be found in the enumerable. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, undefined].includes(undefined); // true - [1, 2, null].includes(null); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in the enumerable. - @public - */ - includes: function (obj) { - _emberMetal.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1); + return newActions; + } - var len = _emberMetal.get(this, 'length'); - var idx = undefined, - next = undefined; - var last = null; - var found = false; + /** + Add an event listener + + @method addListener + @for Ember + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Boolean} once A flag whether a function should only be called once + @public + */ - var context = popCtx(); + function addListener(obj, eventName, target, method, once) { + _emberMetalDebug.assert('You must pass at least an object and event name to Ember.addListener', !!obj && !!eventName); - for (idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); + _emberMetalDebug.deprecate('didInitAttrs called in ' + (obj && obj.toString && obj.toString()) + '.', eventName !== 'didInitAttrs', { + id: 'ember-views.did-init-attrs', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' + }); - found = obj === next || obj !== obj && next !== next; + if (!method && 'function' === typeof target) { + method = target; + target = null; + } - last = next; - } + var flags = 0; + if (once) { + flags |= _emberMetalMeta_listeners.ONCE; + } - next = last = null; - context = pushCtx(context); + _emberMetalMeta.meta(obj).addToListeners(eventName, target, method, flags); - return found; - }, + if ('function' === typeof obj.didAddListener) { + obj.didAddListener(eventName, target, method); + } + } - without: function (value) { - if (!this.includes(value)) { - return this; // nothing to do - } + /** + Remove an event listener + + Arguments should match those passed to `Ember.addListener`. + + @method removeListener + @for Ember + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @public + */ - var ret = emberA(); + function removeListener(obj, eventName, target, method) { + _emberMetalDebug.assert('You must pass at least an object and event name to Ember.removeListener', !!obj && !!eventName); - this.forEach(function (k) { - // SameValueZero comparison (NaN !== NaN) - if (!(k === value || k !== k && value !== value)) { - ret[ret.length] = k; - } - }); + if (!method && 'function' === typeof target) { + method = target; + target = null; + } - return ret; + _emberMetalMeta.meta(obj).removeFromListeners(eventName, target, method, function () { + if ('function' === typeof obj.didRemoveListener) { + obj.didRemoveListener.apply(obj, arguments); } }); } - exports.default = Enumerable; -}); -enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - /** - @module ember - @submodule ember-runtime - */ - /** - This mixin allows for Ember objects to subscribe to and emit events. - - ```javascript - App.Person = Ember.Object.extend(Ember.Evented, { - greet: function() { - // ... - this.trigger('greet'); - } - }); + Suspend listener during callback. - var person = App.Person.create(); + This should only be used by the target of the event listener + when it is taking an action that would cause the event, e.g. + an object might suspend its property change listener while it is + setting that property. - person.on('greet', function() { - console.log('Our person has greeted'); - }); + @method suspendListener + @for Ember - person.greet(); + @private + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Function} callback + */ + + function suspendListener(obj, eventName, target, method, callback) { + return suspendListeners(obj, [eventName], target, method, callback); + } + + /** + Suspends multiple listeners during a callback. - // outputs: 'Our person has greeted' - ``` + @method suspendListeners + @for Ember - You can also chain multiple event subscriptions: + @private + @param obj + @param {Array} eventNames Array of event names + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Function} callback + */ + + function suspendListeners(obj, eventNames, target, method, callback) { + if (!method && 'function' === typeof target) { + method = target; + target = null; + } + return _emberMetalMeta.meta(obj).suspendListeners(eventNames, target, method, callback); + } + + /** + Return a list of currently watched events - ```javascript - person.on('greet', function() { - console.log('Our person has greeted'); - }).one('greet', function() { - console.log('Offer one-time special'); - }).off('event', this, forgetThis); - ``` + @private + @method watchedEvents + @for Ember + @param obj + */ + + function watchedEvents(obj) { + return _emberMetalMeta.meta(obj).watchedEvents(); + } + + /** + Send an event. The execution of suspended listeners + is skipped, and once listeners are removed. A listener without + a target is executed on the passed object. If an array of actions + is not passed, the actions stored on the passed object are invoked. - @class Evented - @namespace Ember + @method sendEvent + @for Ember + @param obj + @param {String} eventName + @param {Array} params Optional parameters for each listener. + @param {Array} actions Optional array of actions (listeners). + @return true @public - */ - exports.default = _emberMetal.Mixin.create({ + */ - /** - Subscribes to a named event with given function. - ```javascript - person.on('didLoad', function() { - // fired once the person has loaded - }); - ``` - An optional target can be passed in as the 2nd argument that will - be set as the "this" for the callback. This is a good way to give your - function access to the object triggering the event. When the target - parameter is used the callback becomes the third argument. - @method on - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - @public - */ - on: function (name, target, method) { - _emberMetal.addListener(this, name, target, method); - return this; - }, + function sendEvent(obj, eventName, params, actions) { + if (!actions) { + var meta = _emberMetalMeta.peekMeta(obj); + actions = meta && meta.matchingListeners(eventName); + } - /** - Subscribes a function to a named event and then cancels the subscription - after the first time the event is triggered. It is good to use ``one`` when - you only care about the first time an event has taken place. - This function takes an optional 2nd argument that will become the "this" - value for the callback. If this argument is passed then the 3rd argument - becomes the function. - @method one - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - @public - */ - one: function (name, target, method) { - if (!method) { - method = target; - target = null; - } + if (!actions || actions.length === 0) { + return; + } - _emberMetal.addListener(this, name, target, method, true); - return this; - }, + for (var i = actions.length - 3; i >= 0; i -= 3) { + // looping in reverse for once listeners + var target = actions[i]; + var method = actions[i + 1]; + var flags = actions[i + 2]; - /** - Triggers a named event for the object. Any additional arguments - will be passed as parameters to the functions that are subscribed to the - event. - ```javascript - person.on('didEat', function(food) { - console.log('person ate some ' + food); - }); - person.trigger('didEat', 'broccoli'); - // outputs: person ate some broccoli - ``` - @method trigger - @param {String} name The name of the event - @param {Object...} args Optional arguments to pass on - @public - */ - trigger: function (name) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + if (!method) { + continue; } + if (flags & _emberMetalMeta_listeners.SUSPENDED) { + continue; + } + if (flags & _emberMetalMeta_listeners.ONCE) { + removeListener(obj, eventName, target, method); + } + if (!target) { + target = obj; + } + if ('string' === typeof method) { + if (params) { + _emberUtils.applyStr(target, method, params); + } else { + target[method](); + } + } else { + if (params) { + method.apply(target, params); + } else { + method.call(target); + } + } + } + return true; + } - _emberMetal.sendEvent(this, name, args); - }, - - /** - Cancels subscription for given name, target, and method. - @method off - @param {String} name The name of the event - @param {Object} target The target of the subscription - @param {Function} method The function of the subscription - @return this - @public - */ - off: function (name, target, method) { - _emberMetal.removeListener(this, name, target, method); - return this; - }, + /** + @private + @method hasListeners + @for Ember + @param obj + @param {String} eventName + */ - /** - Checks to see if object has any subscriptions for named event. - @method has - @param {String} name The name of the event - @return {Boolean} does the object have a subscription for event - @public - */ - has: function (name) { - return _emberMetal.hasListeners(this, name); + function hasListeners(obj, eventName) { + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta) { + return false; } - }); -}); -enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + return meta.matchingListeners(eventName).length > 0; + } + /** - @module ember - @submodule ember-runtime + @private + @method listenersFor + @for Ember + @param obj + @param {String} eventName */ - 'use strict'; + function listenersFor(obj, eventName) { + var ret = []; + var meta = _emberMetalMeta.peekMeta(obj); + var actions = meta && meta.matchingListeners(eventName); + + if (!actions) { + return ret; + } + + for (var i = 0; i < actions.length; i += 3) { + var target = actions[i]; + var method = actions[i + 1]; + ret.push([target, method]); + } + + return ret; + } /** - The `Ember.Freezable` mixin implements some basic methods for marking an - object as frozen. Once an object is frozen it should be read only. No changes - may be made the internal state of the object. - - ## Enforcement - - To fully support freezing in your subclass, you must include this mixin and - override any method that might alter any property on the object to instead - raise an exception. You can check the state of an object by checking the - `isFrozen` property. - - Although future versions of JavaScript may support language-level freezing - object objects, that is not the case today. Even if an object is freezable, - it is still technically possible to modify the object, even though it could - break other parts of your application that do not expect a frozen object to - change. It is, therefore, very important that you always respect the - `isFrozen` property on all freezable objects. - - ## Example Usage - - The example below shows a simple object that implement the `Ember.Freezable` - protocol. - - ```javascript - Contact = Ember.Object.extend(Ember.Freezable, { - firstName: null, - lastName: null, + Define a property as a function that should be executed when + a specified event or events are triggered. - // swaps the names - swapNames: function() { - if (this.get('isFrozen')) throw Ember.FROZEN_ERROR; - var tmp = this.get('firstName'); - this.set('firstName', this.get('lastName')); - this.set('lastName', tmp); - return this; - } + ``` javascript + let Job = Ember.Object.extend({ + logCompleted: Ember.on('completed', function() { + console.log('Job completed!'); + }) }); - c = Contact.create({ firstName: "John", lastName: "Doe" }); - c.swapNames(); // returns c - c.freeze(); - c.swapNames(); // EXCEPTION - ``` - - ## Copying + let job = Job.create(); - Usually the `Ember.Freezable` protocol is implemented in cooperation with the - `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will - return a frozen object, if the object implements this method as well. + Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' + ``` - @class Freezable - @namespace Ember - @since Ember 0.9 - @deprecated Use `Object.freeze` instead. - @private + @method on + @for Ember + @param {String} eventNames* + @param {Function} func + @return func + @public */ - var Freezable = _emberMetal.Mixin.create({ - - init: function () { - _emberMetal.deprecate('`Ember.Freezable` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.freezable-init', until: '3.0.0' }); - this._super.apply(this, arguments); - }, - - /** - Set to `true` when the object is frozen. Use this property to detect - whether your object is frozen or not. - @property isFrozen - @type Boolean - @private - */ - isFrozen: false, - - /** - Freezes the object. Once this method has been called the object should - no longer allow any properties to be edited. - @method freeze - @return {Object} receiver - @private - */ - freeze: function () { - if (_emberMetal.get(this, 'isFrozen')) { - return this; - } - _emberMetal.set(this, 'isFrozen', true); - return this; + function on() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - }); - - exports.Freezable = Freezable; - var FROZEN_ERROR = 'Frozen object cannot be modified.'; - exports.FROZEN_ERROR = FROZEN_ERROR; + var func = args.pop(); + var events = args; + func.__ember_listens__ = events; + return func; + } }); -enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable'], function (exports, _emberMetal, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable) { - /** - @module ember - @submodule ember-runtime - */ - +enifed('ember-metal/expand_properties', ['exports', 'ember-metal/debug'], function (exports, _emberMetalDebug) { 'use strict'; - exports.removeAt = removeAt; - var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; - var EMPTY = []; - - // .......................................................... - // HELPERS - // - - function removeAt(array, start, len) { - if ('number' === typeof start) { - if (start < 0 || start >= _emberMetal.get(array, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } - - // fast case - if (len === undefined) { - len = 1; - } + exports.default = expandProperties; - array.replace(start, len, EMPTY); - } + /** + @module ember + @submodule ember-metal + */ - return array; - } + var SPLIT_REGEX = /\{|\}/; + var END_WITH_EACH_REGEX = /\.@each$/; /** - This mixin defines the API for modifying array-like objects. These methods - can be applied only to a collection that keeps its items in an ordered set. - It builds upon the Array mixin and adds methods to modify the array. - One concrete implementations of this class include ArrayProxy. + Expands `pattern`, invoking `callback` for each expansion. - It is important to use the methods in this class to modify arrays so that - changes are observable. This allows the binding system in Ember to function - correctly. + The only pattern supported is brace-expansion, anything else will be passed + once to `callback` directly. + Example - Note that an Array can change even if it does not implement this mixin. - For example, one might implement a SparseArray that cannot be directly - modified, but if its underlying enumerable changes, it will change also. + ```js + function echo(arg){ console.log(arg); } - @class MutableArray - @namespace Ember - @uses Ember.Array - @uses Ember.MutableEnumerable - @public - */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, { - - /** - __Required.__ You must implement this method to apply this mixin. - This is one of the primitives you must implement to support `Ember.Array`. - You should replace amt objects started at idx with the objects in the - passed array. You should also call `this.enumerableContentDidChange()` - @method replace - @param {Number} idx Starting index in the array to replace. If - idx >= length, then append to the end of the array. - @param {Number} amt Number of elements that should be removed from - the array, starting at *idx*. - @param {Array} objects An array of zero or more objects that should be - inserted into the array at *idx* - @public - */ - replace: null, + Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' + Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' + Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' + Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' + Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' + Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' + Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' + ``` + + @method expandProperties + @for Ember + @private + @param {String} pattern The property pattern to expand. + @param {Function} callback The callback to invoke. It is invoked once per + expansion, and is passed the expansion. + */ - /** - Remove all elements from the array. This is useful if you - want to reuse an existing array without having to recreate it. - ```javascript - let colors = ['red', 'green', 'blue']; - color.length(); // 3 - colors.clear(); // [] - colors.length(); // 0 - ``` - @method clear - @return {Ember.Array} An empty Array. - @public - */ - clear: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return this; - } + function expandProperties(pattern, callback) { + _emberMetalDebug.assert('A computed property key must be a string', typeof pattern === 'string'); + _emberMetalDebug.assert('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1); + _emberMetalDebug.assert('Brace expanded properties have to be balanced and cannot be nested, pattern: ' + pattern, (function (str) { + var inBrace = 0; + var char = undefined; + for (var i = 0; i < str.length; i++) { + char = str.charAt(i); - this.replace(0, len, EMPTY); - return this; - }, + if (char === '{') { + inBrace++; + } else if (char === '}') { + inBrace--; + } - /** - This will use the primitive `replace()` method to insert an object at the - specified index. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue'] - colors.insertAt(5, 'orange'); // Error: Index out of range - ``` - @method insertAt - @param {Number} idx index of insert the object at. - @param {Object} object object to insert - @return {Ember.Array} receiver - @public - */ - insertAt: function (idx, object) { - if (idx > _emberMetal.get(this, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + if (inBrace > 1 || inBrace < 0) { + return false; + } } - this.replace(idx, 0, [object]); - return this; - }, - - /** - Remove an object at the specified index using the `replace()` primitive - method. You can pass either a single index, or a start and a length. - If you pass a start and length that is beyond the - length this method will throw an `OUT_OF_RANGE_EXCEPTION`. - ```javascript - let colors = ['red', 'green', 'blue', 'yellow', 'orange']; - colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] - colors.removeAt(2, 2); // ['green', 'blue'] - colors.removeAt(4, 2); // Error: Index out of range - ``` - @method removeAt - @param {Number} start index, start of range - @param {Number} len length of passing range - @return {Ember.Array} receiver - @public - */ - removeAt: function (start, len) { - return removeAt(this, start, len); - }, + return true; + })(pattern)); - /** - Push the object onto the end of the array. Works just like `push()` but it - is KVO-compliant. - ```javascript - let colors = ['red', 'green']; - colors.pushObject('black'); // ['red', 'green', 'black'] - colors.pushObject(['yellow']); // ['red', 'green', ['yellow']] - ``` - @method pushObject - @param {*} obj object to push - @return object same object passed as a param - @public - */ - pushObject: function (obj) { - this.insertAt(_emberMetal.get(this, 'length'), obj); - return obj; - }, + var parts = pattern.split(SPLIT_REGEX); + var properties = [parts]; - /** - Add the objects in the passed numerable to the end of the array. Defers - notifying observers of the change until all objects are added. - ```javascript - let colors = ['red']; - colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange'] - ``` - @method pushObjects - @param {Ember.Enumerable} objects the objects to add - @return {Ember.Array} receiver - @public - */ - pushObjects: function (objects) { - if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || Array.isArray(objects))) { - throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part.indexOf(',') >= 0) { + properties = duplicateAndReplace(properties, part.split(','), i); } - this.replace(_emberMetal.get(this, 'length'), 0, objects); - return this; - }, + } - /** - Pop object from array or nil if none are left. Works just like `pop()` but - it is KVO-compliant. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.popObject(); // 'blue' - console.log(colors); // ['red', 'green'] - ``` - @method popObject - @return object - @public - */ - popObject: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return null; - } + for (var i = 0; i < properties.length; i++) { + callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); + } + } - var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1); - this.removeAt(len - 1, 1); - return ret; - }, + function duplicateAndReplace(properties, currentParts, index) { + var all = []; - /** - Shift an object from start of array or nil if none are left. Works just - like `shift()` but it is KVO-compliant. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.shiftObject(); // 'red' - console.log(colors); // ['green', 'blue'] - ``` - @method shiftObject - @return object - @public - */ - shiftObject: function () { - if (_emberMetal.get(this, 'length') === 0) { - return null; - } + properties.forEach(function (property) { + currentParts.forEach(function (part) { + var current = property.slice(0); + current[index] = part; + all.push(current); + }); + }); - var ret = _emberRuntimeMixinsArray.objectAt(this, 0); - this.removeAt(0); - return ret; - }, + return all; + } +}); +enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) { + 'use strict'; - /** - Unshift an object to start of array. Works just like `unshift()` but it is - KVO-compliant. - ```javascript - let colors = ['red']; - colors.unshiftObject('yellow'); // ['yellow', 'red'] - colors.unshiftObject(['black']); // [['black'], 'yellow', 'red'] - ``` - @method unshiftObject - @param {*} obj object to unshift - @return object same object passed as a param - @public - */ - unshiftObject: function (obj) { - this.insertAt(0, obj); - return obj; - }, + exports.default = isEnabled; - /** - Adds the named objects to the beginning of the array. Defers notifying - observers until all objects have been added. - ```javascript - let colors = ['red']; - colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red'] - colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function - ``` - @method unshiftObjects - @param {Ember.Enumerable} objects the objects to add - @return {Ember.Array} receiver - @public - */ - unshiftObjects: function (objects) { - this.replace(0, 0, objects); - return this; - }, + /** + The hash of enabled Canary features. Add to this, any canary features + before creating your application. + + Alternatively (and recommended), you can also define `EmberENV.FEATURES` + if you need to enable features flagged at runtime. + + @class FEATURES + @namespace Ember + @static + @since 1.1.0 + @public + */ + var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES); - /** - Reverse objects in the array. Works just like `reverse()` but it is - KVO-compliant. - @method reverseObjects - @return {Ember.Array} receiver - @public - */ - reverseObjects: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return this; - } + exports.FEATURES = FEATURES; + /** + Determine whether the specified `feature` is enabled. Used by Ember's + build tools to exclude experimental features from beta/stable builds. + + You can define the following configuration options: + + * `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly + enabled/disabled. + + @method isEnabled + @param {String} feature The feature to check + @return {Boolean} + @for Ember.FEATURES + @since 1.1.0 + @public + */ - var objects = this.toArray().reverse(); - this.replace(0, len, objects); - return this; - }, + function isEnabled(feature) { + var featureValue = FEATURES[feature]; - /** - Replace all the receiver's content with content of the argument. - If argument is an empty array receiver will be cleared. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.setObjects(['black', 'white']); // ['black', 'white'] - colors.setObjects([]); // [] - ``` - @method setObjects - @param {Ember.Array} objects array whose content will be used for replacing - the content of the receiver - @return {Ember.Array} receiver with the new content - @public - */ - setObjects: function (objects) { - if (objects.length === 0) { - return this.clear(); - } + if (featureValue === true || featureValue === false || featureValue === undefined) { + return featureValue; + } else if (_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES) { + return true; + } else { + return false; + } + } - var len = _emberMetal.get(this, 'length'); - this.replace(0, len, objects); - return this; - }, + exports.DEFAULT_FEATURES = _emberFeatures.default; +}); +enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; - // .......................................................... - // IMPLEMENT Ember.MutableEnumerable - // + exports.default = getProperties; - /** - Remove all occurrences of an object in the array. - ```javascript - let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; - cities.removeObject('Chicago'); // ['Berlin', 'Lima'] - cities.removeObject('Lima'); // ['Berlin'] - cities.removeObject('Tokyo') // ['Berlin'] - ``` - @method removeObject - @param {*} obj object to remove - @return {Ember.Array} receiver - @public - */ - removeObject: function (obj) { - var loc = _emberMetal.get(this, 'length') || 0; - while (--loc >= 0) { - var curObject = _emberRuntimeMixinsArray.objectAt(this, loc); + /** + To get multiple properties at once, call `Ember.getProperties` + with an object followed by a list of strings or an array: + + ```javascript + Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + + is equivalent to: + + ```javascript + Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + + @method getProperties + @for Ember + @param {Object} obj + @param {String...|Array} list of keys to get + @return {Object} + @public + */ - if (curObject === obj) { - this.removeAt(loc); - } - } - return this; - }, + function getProperties(obj) { + var ret = {}; + var propertyNames = arguments; + var i = 1; - /** - Push the object onto the end of the array if it is not already - present in the array. - ```javascript - let cities = ['Chicago', 'Berlin']; - cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] - cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] - ``` - @method addObject - @param {*} obj object to add, if not already present - @return {Ember.Array} receiver - @public - */ - addObject: function (obj) { - var included = undefined; + if (arguments.length === 2 && Array.isArray(arguments[1])) { + i = 0; + propertyNames = arguments[1]; + } + for (; i < propertyNames.length; i++) { + ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]); + } + return ret; + } +}); +enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/is_proxy', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalIs_proxy, _emberMetalDescriptor) { + /** + @module ember + @submodule ember-metal + */ - if (true) { - included = this.includes(obj); - } else { - included = this.contains(obj); - } + 'use strict'; + + exports.default = _emberMetalCore.default; + // reexports + exports.computed = _emberMetalComputed.default; + exports.cacheFor = _emberMetalComputed.cacheFor; + exports.ComputedProperty = _emberMetalComputed.ComputedProperty; + exports.alias = _emberMetalAlias.default; + exports.merge = _emberMetalMerge.default; + exports.assert = _emberMetalDebug.assert; + exports.info = _emberMetalDebug.info; + exports.warn = _emberMetalDebug.warn; + exports.debug = _emberMetalDebug.debug; + exports.deprecate = _emberMetalDebug.deprecate; + exports.deprecateFunc = _emberMetalDebug.deprecateFunc; + exports.runInDebug = _emberMetalDebug.runInDebug; + exports.setDebugFunction = _emberMetalDebug.setDebugFunction; + exports.getDebugFunction = _emberMetalDebug.getDebugFunction; + exports.debugSeal = _emberMetalDebug.debugSeal; + exports.debugFreeze = _emberMetalDebug.debugFreeze; + exports.instrument = _emberMetalInstrumentation.instrument; + exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument; + exports._instrumentStart = _emberMetalInstrumentation._instrumentStart; + exports.instrumentationReset = _emberMetalInstrumentation.reset; + exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe; + exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe; + exports.isTesting = _emberMetalTesting.isTesting; + exports.setTesting = _emberMetalTesting.setTesting; + exports.getOnerror = _emberMetalError_handler.getOnerror; + exports.setOnerror = _emberMetalError_handler.setOnerror; + exports.dispatchError = _emberMetalError_handler.dispatchError; + exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride; + exports.META_DESC = _emberMetalMeta.META_DESC; + exports.meta = _emberMetalMeta.meta; + exports.peekMeta = _emberMetalMeta.peekMeta; + exports.Error = _emberMetalError.default; + exports.Cache = _emberMetalCache.default; + exports.isFeatureEnabled = _emberMetalFeatures.default; + exports.FEATURES = _emberMetalFeatures.FEATURES; + exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES; + exports._getPath = _emberMetalProperty_get._getPath; + exports.get = _emberMetalProperty_get.get; + exports.getWithDefault = _emberMetalProperty_get.getWithDefault; + exports.set = _emberMetalProperty_set.set; + exports.trySet = _emberMetalProperty_set.trySet; + exports.WeakMap = _emberMetalWeak_map.default; + exports.accumulateListeners = _emberMetalEvents.accumulateListeners; + exports.addListener = _emberMetalEvents.addListener; + exports.hasListeners = _emberMetalEvents.hasListeners; + exports.listenersFor = _emberMetalEvents.listenersFor; + exports.on = _emberMetalEvents.on; + exports.removeListener = _emberMetalEvents.removeListener; + exports.sendEvent = _emberMetalEvents.sendEvent; + exports.suspendListener = _emberMetalEvents.suspendListener; + exports.suspendListeners = _emberMetalEvents.suspendListeners; + exports.watchedEvents = _emberMetalEvents.watchedEvents; + exports.isNone = _emberMetalIs_none.default; + exports.isEmpty = _emberMetalIs_empty.default; + exports.isBlank = _emberMetalIs_blank.default; + exports.isPresent = _emberMetalIs_present.default; + exports.run = _emberMetalRun_loop.default; + exports.ObserverSet = _emberMetalObserver_set.default; + exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges; + exports.changeProperties = _emberMetalProperty_events.changeProperties; + exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges; + exports.overrideChains = _emberMetalProperty_events.overrideChains; + exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; + exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; + exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; + exports.defineProperty = _emberMetalProperties.defineProperty; + exports.Descriptor = _emberMetalProperties.Descriptor; + exports.watchKey = _emberMetalWatch_key.watchKey; + exports.unwatchKey = _emberMetalWatch_key.unwatchKey; + exports.ChainNode = _emberMetalChains.ChainNode; + exports.finishChains = _emberMetalChains.finishChains; + exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; + exports.watchPath = _emberMetalWatch_path.watchPath; + exports.unwatchPath = _emberMetalWatch_path.unwatchPath; + exports.destroy = _emberMetalWatching.destroy; + exports.isWatching = _emberMetalWatching.isWatching; + exports.unwatch = _emberMetalWatching.unwatch; + exports.watch = _emberMetalWatching.watch; + exports.watcherCount = _emberMetalWatching.watcherCount; + exports.libraries = _emberMetalLibraries.default; + exports.Map = _emberMetalMap.Map; + exports.MapWithDefault = _emberMetalMap.MapWithDefault; + exports.OrderedSet = _emberMetalMap.OrderedSet; + exports.getProperties = _emberMetalGet_properties.default; + exports.setProperties = _emberMetalSet_properties.default; + exports.expandProperties = _emberMetalExpand_properties.default; + exports._suspendObserver = _emberMetalObserver._suspendObserver; + exports._suspendObservers = _emberMetalObserver._suspendObservers; + exports.addObserver = _emberMetalObserver.addObserver; + exports.observersFor = _emberMetalObserver.observersFor; + exports.removeObserver = _emberMetalObserver.removeObserver; + exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; + exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.Mixin = _emberMetalMixin.Mixin; + exports.aliasMethod = _emberMetalMixin.aliasMethod; + exports._immediateObserver = _emberMetalMixin._immediateObserver; + exports._beforeObserver = _emberMetalMixin._beforeObserver; + exports.mixin = _emberMetalMixin.mixin; + exports.observer = _emberMetalMixin.observer; + exports.required = _emberMetalMixin.required; + exports.REQUIRED = _emberMetalMixin.REQUIRED; + exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins; + exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins; + exports.detectBinding = _emberMetalMixin.detectBinding; + exports.Binding = _emberMetalBinding.Binding; + exports.bind = _emberMetalBinding.bind; + exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath; + exports.InjectedProperty = _emberMetalInjected_property.default; + exports.setHasViews = _emberMetalTags.setHasViews; + exports.tagForProperty = _emberMetalTags.tagForProperty; + exports.tagFor = _emberMetalTags.tagFor; + exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty; + exports.replace = _emberMetalReplace.default; + exports.runInTransaction = _emberMetalTransaction.default; + exports.didRender = _emberMetalTransaction.didRender; + exports.assertNotRendered = _emberMetalTransaction.assertNotRendered; + exports.isProxy = _emberMetalIs_proxy.isProxy; + exports.descriptor = _emberMetalDescriptor.default; - if (!included) { - this.pushObject(obj); - } + // TODO: this needs to be deleted once we refactor the build tooling + // do this for side-effects of updating Ember.assert, warn, etc when + // ember-debug is present + // This needs to be called before any deprecateFunc - return this; - } - }); + if (_require.has('ember-debug')) { + _require.default('ember-debug'); + } }); -enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetal) { +enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) { 'use strict'; - /** - @module ember - @submodule ember-runtime - */ + exports.default = InjectedProperty; /** - This mixin defines the API for modifying generic enumerables. These methods - can be applied to an object regardless of whether it is ordered or - unordered. - - Note that an Enumerable can change even if it does not implement this mixin. - For example, a MappedEnumerable cannot be directly modified but if its - underlying enumerable changes, it will change also. - - ## Adding Objects - - To add an object to an enumerable, use the `addObject()` method. This - method will only add the object to the enumerable if the object is not - already present and is of a type supported by the enumerable. - - ```javascript - set.addObject(contact); - ``` - - ## Removing Objects - - To remove an object from an enumerable, use the `removeObject()` method. This - will only remove the object if it is present in the enumerable, otherwise - this method has no effect. - - ```javascript - set.removeObject(contact); - ``` - - ## Implementing In Your Own Code - - If you are implementing an object and want to support this API, just include - this mixin in your class and implement the required methods. In your unit - tests, be sure to apply the Ember.MutableEnumerableTests to your object. + Read-only property that returns the result of a container lookup. - @class MutableEnumerable + @class InjectedProperty @namespace Ember - @uses Ember.Enumerable - @public + @constructor + @param {String} type The container type the property will lookup + @param {String} name (optional) The name the property will lookup, defaults + to the property's name + @private */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, { - /** - __Required.__ You must implement this method to apply this mixin. - Attempts to add the passed object to the receiver if the object is not - already present in the collection. If the object is present, this method - has no effect. - If the passed object is of a type not supported by the receiver, - then this method should raise an exception. - @method addObject - @param {Object} object The object to add to the enumerable. - @return {Object} the passed object - @public - */ - addObject: null, + function InjectedProperty(type, name) { + this.type = type; + this.name = name; - /** - Adds each object in the passed enumerable to the receiver. - @method addObjects - @param {Ember.Enumerable} objects the objects to add. - @return {Object} receiver - @public - */ - addObjects: function (objects) { - var _this = this; + this._super$Constructor(injectedPropertyGet); + AliasedPropertyPrototype.oneWay.call(this); + } - _emberMetal.beginPropertyChanges(this); - objects.forEach(function (obj) { - return _this.addObject(obj); - }); - _emberMetal.endPropertyChanges(this); - return this; - }, + function injectedPropertyGet(keyName) { + var desc = this[keyName]; + var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat - /** - __Required.__ You must implement this method to apply this mixin. - Attempts to remove the passed object from the receiver collection if the - object is present in the collection. If the object is not present, - this method has no effect. - If the passed object is of a type not supported by the receiver, - then this method should raise an exception. - @method removeObject - @param {Object} object The object to remove from the enumerable. - @return {Object} the passed object - @public - */ - removeObject: null, + _emberMetalDebug.assert('InjectedProperties should be defined with the Ember.inject computed property macros.', desc && desc.isDescriptor && desc.type); + _emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', owner); - /** - Removes each object in the passed enumerable from the receiver. - @method removeObjects - @param {Ember.Enumerable} objects the objects to remove - @return {Object} receiver - @public - */ - removeObjects: function (objects) { - _emberMetal.beginPropertyChanges(this); - for (var i = objects.length - 1; i >= 0; i--) { - this.removeObject(objects[i]); - } - _emberMetal.endPropertyChanges(this); - return this; - } - }); + return owner.lookup(desc.type + ':' + (desc.name || keyName)); + } + + InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); + + var InjectedPropertyPrototype = InjectedProperty.prototype; + var ComputedPropertyPrototype = _emberMetalComputed.ComputedProperty.prototype; + var AliasedPropertyPrototype = _emberMetalAlias.AliasedProperty.prototype; + + InjectedPropertyPrototype._super$Constructor = _emberMetalComputed.ComputedProperty; + + InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; + InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; + InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; }); -enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ +enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { + /* eslint no-console:off */ + /* global console */ 'use strict'; + exports.instrument = instrument; + exports._instrumentStart = _instrumentStart; + exports.subscribe = subscribe; + exports.unsubscribe = unsubscribe; + exports.reset = reset; + /** - ## Overview - - This mixin provides properties and property observing functionality, core - features of the Ember object model. - - Properties and observers allow one object to observe changes to a - property on another object. This is one of the fundamental ways that - models, controllers and views communicate with each other in an Ember - application. - - Any object that has this mixin applied can be used in observer - operations. That includes `Ember.Object` and most objects you will - interact with as you write your Ember application. - - Note that you will not generally apply this mixin to classes yourself, - but you will use the features provided by this module frequently, so it - is important to understand how to use it. - - ## Using `get()` and `set()` - - Because of Ember's support for bindings and observers, you will always - access properties using the get method, and set properties using the - set method. This allows the observing objects to be notified and - computed properties to be handled properly. + The purpose of the Ember Instrumentation module is + to provide efficient, general-purpose instrumentation + for Ember. - More documentation about `get` and `set` are below. + Subscribe to a listener by using `Ember.subscribe`: - ## Observing Property Changes + ```javascript + Ember.subscribe("render", { + before(name, timestamp, payload) { - You typically observe property changes simply by using the `Ember.observer` - function in classes that you write. + }, - For example: + after(name, timestamp, payload) { - ```javascript - Ember.Object.extend({ - valueObserver: Ember.observer('value', function(sender, key, value, rev) { - // Executes whenever the "value" property changes - // See the addObserver method for more information about the callback arguments - }) + } }); ``` - Although this is the most common way to add an observer, this capability - is actually built into the `Ember.Object` class on top of two methods - defined in this mixin: `addObserver` and `removeObserver`. You can use - these two methods to add and remove observers yourself if you need to - do so at runtime. + If you return a value from the `before` callback, that same + value will be passed as a fourth parameter to the `after` + callback. - To add an observer for a property, call: + Instrument a block of code by using `Ember.instrument`: ```javascript - object.addObserver('propertyKey', targetObject, targetAction) + Ember.instrument("render.handlebars", payload, function() { + // rendering logic + }, binding); ``` - This will call the `targetAction` method on the `targetObject` whenever - the value of the `propertyKey` changes. + Event names passed to `Ember.instrument` are namespaced + by periods, from more general to more specific. Subscribers + can listen for events by whatever level of granularity they + are interested in. - Note that if `propertyKey` is a computed property, the observer will be - called when any of the property dependencies are changed, even if the - resulting value of the computed property is unchanged. This is necessary - because computed properties are not computed until `get` is called. + In the above example, the event is `render.handlebars`, + and the subscriber listened for all events beginning with + `render`. It would receive callbacks for events named + `render`, `render.handlebars`, `render.container`, or + even `render.handlebars.layout`. - @class Observable + @class Instrumentation @namespace Ember - @public + @static + @private */ - exports.default = _emberMetal.Mixin.create({ + var subscribers = []; + exports.subscribers = subscribers; + var cache = {}; - /** - Retrieves the value of a property from the object. - This method is usually similar to using `object[keyName]` or `object.keyName`, - however it supports both computed properties and the unknownProperty - handler. - Because `get` unifies the syntax for accessing all these kinds - of properties, it can make many refactorings easier, such as replacing a - simple property with a computed property, or vice versa. - ### Computed Properties - Computed properties are methods defined with the `property` modifier - declared at the end, such as: - ```javascript - fullName: Ember.computed('firstName', 'lastName', function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }) - ``` - When you call `get` on a computed property, the function will be - called and the return value will be returned instead of the function - itself. - ### Unknown Properties - Likewise, if you try to call `get` on a property whose value is - `undefined`, the `unknownProperty()` method will be called on the object. - If this method returns any value other than `undefined`, it will be returned - instead. This allows you to implement "virtual" properties that are - not defined upfront. - @method get - @param {String} keyName The property to retrieve - @return {Object} The property value or undefined. - @public - */ - get: function (keyName) { - return _emberMetal.get(this, keyName); - }, + function populateListeners(name) { + var listeners = []; + var subscriber = undefined; - /** - To get the values of multiple properties at once, call `getProperties` - with a list of strings or an array: - ```javascript - record.getProperties('firstName', 'lastName', 'zipCode'); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - is equivalent to: - ```javascript - record.getProperties(['firstName', 'lastName', 'zipCode']); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - @method getProperties - @param {String...|Array} list of keys to get - @return {Object} - @public - */ - getProperties: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var i = 0; i < subscribers.length; i++) { + subscriber = subscribers[i]; + if (subscriber.regex.test(name)) { + listeners.push(subscriber.object); } + } - return _emberMetal.getProperties.apply(null, [this].concat(args)); - }, - - /** - Sets the provided key or path to the value. - ```javascript - record.set("key", value); - ``` - This method is generally very similar to calling `object["key"] = value` or - `object.key = value`, except that it provides support for computed - properties, the `setUnknownProperty()` method and property observers. - ### Computed Properties - If you try to set a value on a key that has a computed property handler - defined (see the `get()` method for an example), then `set()` will call - that method, passing both the value and key instead of simply changing - the value itself. This is useful for those times when you need to - implement a property that is composed of one or more member - properties. - ### Unknown Properties - If you try to set a value on a key that is undefined in the target - object, then the `setUnknownProperty()` handler will be called instead. This - gives you an opportunity to implement complex "virtual" properties that - are not predefined on the object. If `setUnknownProperty()` returns - undefined, then `set()` will simply set the value on the object. - ### Property Observers - In addition to changing the property, `set()` will also register a property - change with the object. Unless you have placed this call inside of a - `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers - (i.e. observer methods declared on the same object), will be called - immediately. Any "remote" observers (i.e. observer methods declared on - another object) will be placed in a queue and called at a later time in a - coalesced manner. - @method set - @param {String} keyName The property to set - @param {Object} value The value to set or `null`. - @return {Object} The passed value - @public - */ - set: function (keyName, value) { - return _emberMetal.set(this, keyName, value); - }, - - /** - Sets a list of properties at once. These properties are set inside - a single `beginPropertyChanges` and `endPropertyChanges` batch, so - observers will be buffered. - ```javascript - record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); - ``` - @method setProperties - @param {Object} hash the hash of keys and values to set - @return {Object} The passed in hash - @public - */ - setProperties: function (hash) { - return _emberMetal.setProperties(this, hash); - }, - - /** - Begins a grouping of property changes. - You can use this method to group property changes so that notifications - will not be sent until the changes are finished. If you plan to make a - large number of changes to an object at one time, you should call this - method at the beginning of the changes to begin deferring change - notifications. When you are done making changes, call - `endPropertyChanges()` to deliver the deferred change notifications and end - deferring. - @method beginPropertyChanges - @return {Ember.Observable} - @private - */ - beginPropertyChanges: function () { - _emberMetal.beginPropertyChanges(); - return this; - }, - - /** - Ends a grouping of property changes. - You can use this method to group property changes so that notifications - will not be sent until the changes are finished. If you plan to make a - large number of changes to an object at one time, you should call - `beginPropertyChanges()` at the beginning of the changes to defer change - notifications. When you are done making changes, call this method to - deliver the deferred change notifications and end deferring. - @method endPropertyChanges - @return {Ember.Observable} - @private - */ - endPropertyChanges: function () { - _emberMetal.endPropertyChanges(); - return this; - }, + cache[name] = listeners; + return listeners; + } - /** - Notify the observer system that a property is about to change. - Sometimes you need to change a value directly or indirectly without - actually calling `get()` or `set()` on it. In this case, you can use this - method and `propertyDidChange()` instead. Calling these two methods - together will notify all observers that the property has potentially - changed value. - Note that you must always call `propertyWillChange` and `propertyDidChange` - as a pair. If you do not, it may get the property change groups out of - order and cause notifications to be delivered more often than you would - like. - @method propertyWillChange - @param {String} keyName The property key that is about to change. - @return {Ember.Observable} - @private - */ - propertyWillChange: function (keyName) { - _emberMetal.propertyWillChange(this, keyName); - return this; - }, + var time = (function () { + var perf = 'undefined' !== typeof window ? window.performance || {} : {}; + var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; + // fn.bind will be available in all the browsers that support the advanced window.performance... ;-) + return fn ? fn.bind(perf) : function () { + return +new Date(); + }; + })(); - /** - Notify the observer system that a property has just changed. - Sometimes you need to change a value directly or indirectly without - actually calling `get()` or `set()` on it. In this case, you can use this - method and `propertyWillChange()` instead. Calling these two methods - together will notify all observers that the property has potentially - changed value. - Note that you must always call `propertyWillChange` and `propertyDidChange` - as a pair. If you do not, it may get the property change groups out of - order and cause notifications to be delivered more often than you would - like. - @method propertyDidChange - @param {String} keyName The property key that has just changed. - @return {Ember.Observable} - @private - */ - propertyDidChange: function (keyName) { - _emberMetal.propertyDidChange(this, keyName); - return this; - }, + /** + Notifies event's subscribers, calls `before` and `after` hooks. + + @method instrument + @namespace Ember.Instrumentation + + @param {String} [name] Namespaced event name. + @param {Object} _payload + @param {Function} callback Function that you're instrumenting. + @param {Object} binding Context that instrument function is called with. + @private + */ - /** - Convenience method to call `propertyWillChange` and `propertyDidChange` in - succession. - @method notifyPropertyChange - @param {String} keyName The property key to be notified about. - @return {Ember.Observable} - @public - */ - notifyPropertyChange: function (keyName) { - this.propertyWillChange(keyName); - this.propertyDidChange(keyName); - return this; - }, + function instrument(name, _payload, callback, binding) { + if (arguments.length <= 3 && typeof _payload === 'function') { + binding = callback; + callback = _payload; + _payload = undefined; + } + if (subscribers.length === 0) { + return callback.call(binding); + } + var payload = _payload || {}; + var finalizer = _instrumentStart(name, function () { + return payload; + }); - /** - Adds an observer on a property. - This is the core method used to register an observer for a property. - Once you call this method, any time the key's value is set, your observer - will be notified. Note that the observers are triggered any time the - value is set, regardless of whether it has actually changed. Your - observer should be prepared to handle that. - You can also pass an optional context parameter to this method. The - context will be passed to your observer method whenever it is triggered. - Note that if you add the same target/method pair on a key multiple times - with different context parameters, your observer will only be called once - with the last context you passed. - ### Observer Methods - Observer methods you pass should generally have the following signature if - you do not pass a `context` parameter: - ```javascript - fooDidChange: function(sender, key, value, rev) { }; - ``` - The sender is the object that changed. The key is the property that - changes. The value property is currently reserved and unused. The rev - is the last property revision of the object when it changed, which you can - use to detect if the key value has really changed or not. - If you pass a `context` parameter, the context will be passed before the - revision like so: - ```javascript - fooDidChange: function(sender, key, value, context, rev) { }; - ``` - Usually you will not need the value, context or revision parameters at - the end. In this case, it is common to write observer methods that take - only a sender and key value as parameters or, if you aren't interested in - any of these values, to write an observer that has no parameters at all. - @method addObserver - @param {String} key The key to observer - @param {Object} target The target object to invoke - @param {String|Function} method The method to invoke. - @public - */ - addObserver: function (key, target, method) { - _emberMetal.addObserver(this, key, target, method); - }, + if (finalizer) { + return withFinalizer(callback, finalizer, payload, binding); + } else { + return callback.call(binding); + } + } - /** - Remove an observer you have previously registered on this object. Pass - the same key, target, and method you passed to `addObserver()` and your - target will no longer receive notifications. - @method removeObserver - @param {String} key The key to observer - @param {Object} target The target object to invoke - @param {String|Function} method The method to invoke. - @public - */ - removeObserver: function (key, target, method) { - _emberMetal.removeObserver(this, key, target, method); - }, + var flaggedInstrument = undefined; + if (_emberMetalFeatures.default('ember-improved-instrumentation')) { + exports.flaggedInstrument = flaggedInstrument = instrument; + } else { + exports.flaggedInstrument = flaggedInstrument = function (name, payload, callback) { + return callback(); + }; + } + exports.flaggedInstrument = flaggedInstrument; - /** - Returns `true` if the object currently has observers registered for a - particular key. You can use this method to potentially defer performing - an expensive action until someone begins observing a particular property - on the object. - @method hasObserverFor - @param {String} key Key to check - @return {Boolean} - @private - */ - hasObserverFor: function (key) { - return _emberMetal.hasListeners(this, key + ':change'); - }, + function withFinalizer(callback, finalizer, payload, binding) { + var result = undefined; + try { + result = callback.call(binding); + } catch (e) { + payload.exception = e; + result = payload; + } finally { + finalizer(); + } + return result; + } - /** - Retrieves the value of a property, or a default value in the case that the - property returns `undefined`. - ```javascript - person.getWithDefault('lastName', 'Doe'); - ``` - @method getWithDefault - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public - */ - getWithDefault: function (keyName, defaultValue) { - return _emberMetal.getWithDefault(this, keyName, defaultValue); - }, + function NOOP() {} - /** - Set the value of a property to the current value plus some amount. - ```javascript - person.incrementProperty('age'); - team.incrementProperty('score', 2); - ``` - @method incrementProperty - @param {String} keyName The name of the property to increment - @param {Number} increment The amount to increment by. Defaults to 1 - @return {Number} The new property value - @public - */ - incrementProperty: function (keyName, increment) { - if (_emberMetal.isNone(increment)) { - increment = 1; - } - _emberMetal.assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment)); - return _emberMetal.set(this, keyName, (parseFloat(_emberMetal.get(this, keyName)) || 0) + increment); - }, + // private for now - /** - Set the value of a property to the current value minus some amount. - ```javascript - player.decrementProperty('lives'); - orc.decrementProperty('health', 5); - ``` - @method decrementProperty - @param {String} keyName The name of the property to decrement - @param {Number} decrement The amount to decrement by. Defaults to 1 - @return {Number} The new property value - @public - */ - decrementProperty: function (keyName, decrement) { - if (_emberMetal.isNone(decrement)) { - decrement = 1; - } - _emberMetal.assert('Must pass a numeric value to decrementProperty', !isNaN(parseFloat(decrement)) && isFinite(decrement)); - return _emberMetal.set(this, keyName, (_emberMetal.get(this, keyName) || 0) - decrement); - }, + function _instrumentStart(name, _payload, _payloadParam) { + if (subscribers.length === 0) { + return NOOP; + } - /** - Set the value of a boolean property to the opposite of its - current value. - ```javascript - starship.toggleProperty('warpDriveEngaged'); - ``` - @method toggleProperty - @param {String} keyName The name of the property to toggle - @return {Boolean} The new property value - @public - */ - toggleProperty: function (keyName) { - return _emberMetal.set(this, keyName, !_emberMetal.get(this, keyName)); - }, + var listeners = cache[name]; - /** - Returns the cached value of a computed property, if it exists. - This allows you to inspect the value of a computed property - without accidentally invoking it if it is intended to be - generated lazily. - @method cacheFor - @param {String} keyName - @return {Object} The cached value of the computed property, if any - @public - */ - cacheFor: function (keyName) { - return _emberMetal.cacheFor(this, keyName); - }, + if (!listeners) { + listeners = populateListeners(name); + } - // intended for debugging purposes - observersForKey: function (keyName) { - return _emberMetal.observersFor(this, keyName); + if (listeners.length === 0) { + return NOOP; } - }); -}); -enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros) { - 'use strict'; - /** - @module ember - @submodule ember-runtime - */ + var payload = _payload(_payloadParam); - function tap(proxy, promise) { - _emberMetal.setProperties(proxy, { - isFulfilled: false, - isRejected: false - }); + var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE; + var timeName = undefined; + if (STRUCTURED_PROFILE) { + timeName = name + ': ' + payload.object; + console.time(timeName); + } - return promise.then(function (value) { - if (!proxy.isDestroyed && !proxy.isDestroying) { - _emberMetal.setProperties(proxy, { - content: value, - isFulfilled: true - }); + var beforeValues = new Array(listeners.length); + var i = undefined, + listener = undefined; + var timestamp = time(); + for (i = 0; i < listeners.length; i++) { + listener = listeners[i]; + beforeValues[i] = listener.before(name, timestamp, payload); + } + + return function _instrumentEnd() { + var i = undefined, + listener = undefined; + var timestamp = time(); + for (i = 0; i < listeners.length; i++) { + listener = listeners[i]; + if (typeof listener.after === 'function') { + listener.after(name, timestamp, payload, beforeValues[i]); + } } - return value; - }, function (reason) { - if (!proxy.isDestroyed && !proxy.isDestroying) { - _emberMetal.setProperties(proxy, { - reason: reason, - isRejected: true - }); + + if (STRUCTURED_PROFILE) { + console.timeEnd(timeName); } - throw reason; - }, 'Ember: PromiseProxy'); + }; } /** - A low level mixin making ObjectProxy promise-aware. + Subscribes to a particular event or instrumented block of code. - ```javascript - let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); + @method subscribe + @namespace Ember.Instrumentation - let proxy = ObjectPromiseProxy.create({ - promise: Ember.RSVP.cast($.getJSON('/some/remote/data.json')) - }); + @param {String} [pattern] Namespaced event name. + @param {Object} [object] Before and After hooks. - proxy.then(function(json){ - // the json - }, function(reason) { - // the reason why you have no json - }); - ``` + @return {Subscriber} + @private + */ + + function subscribe(pattern, object) { + var paths = pattern.split('.'); + var path = undefined; + var regex = []; + + for (var i = 0; i < paths.length; i++) { + path = paths[i]; + if (path === '*') { + regex.push('[^\\.]*'); + } else { + regex.push(path); + } + } + + regex = regex.join('\\.'); + regex = regex + '(\\..*)?'; + + var subscriber = { + pattern: pattern, + regex: new RegExp('^' + regex + '$'), + object: object + }; + + subscribers.push(subscriber); + cache = {}; + + return subscriber; + } + + /** + Unsubscribes from a particular event or instrumented block of code. - the proxy has bindable attributes which - track the promises life cycle + @method unsubscribe + @namespace Ember.Instrumentation - ```javascript - proxy.get('isPending') //=> true - proxy.get('isSettled') //=> false - proxy.get('isRejected') //=> false - proxy.get('isFulfilled') //=> false - ``` + @param {Object} [subscriber] + @private + */ + + function unsubscribe(subscriber) { + var index = undefined; + + for (var i = 0; i < subscribers.length; i++) { + if (subscribers[i] === subscriber) { + index = i; + } + } + + subscribers.splice(index, 1); + cache = {}; + } + + /** + Resets `Ember.Instrumentation` by flushing list of subscribers. - When the $.getJSON completes, and the promise is fulfilled - with json, the life cycle attributes will update accordingly. - Note that $.getJSON doesn't return an ECMA specified promise, - it is useful to wrap this with an `RSVP.cast` so that it behaves - as a spec compliant promise. + @method reset + @namespace Ember.Instrumentation + @private + */ + + function reset() { + subscribers.length = 0; + cache = {}; + } +}); +enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, _emberMetalIs_empty) { + 'use strict'; + + exports.default = isBlank; + + /** + A value is blank if it is empty or a whitespace string. ```javascript - proxy.get('isPending') //=> false - proxy.get('isSettled') //=> true - proxy.get('isRejected') //=> false - proxy.get('isFulfilled') //=> true + Ember.isBlank(); // true + Ember.isBlank(null); // true + Ember.isBlank(undefined); // true + Ember.isBlank(''); // true + Ember.isBlank([]); // true + Ember.isBlank('\n\t'); // true + Ember.isBlank(' '); // true + Ember.isBlank({}); // false + Ember.isBlank('\n\t Hello'); // false + Ember.isBlank('Hello world'); // false + Ember.isBlank([1,2,3]); // false ``` - As the proxy is an ObjectProxy, and the json now its content, - all the json properties will be available directly from the proxy. + @method isBlank + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @since 1.5.0 + @public + */ + + function isBlank(obj) { + return _emberMetalIs_empty.default(obj) || typeof obj === 'string' && obj.match(/\S/) === null; + } +}); +enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, _emberMetalProperty_get, _emberMetalIs_none) { + 'use strict'; + + exports.default = isEmpty; + + /** + Verifies that a value is `null` or an empty string, empty array, + or empty function. - ```javascript - // Assuming the following json: - { - firstName: 'Stefan', - lastName: 'Penner' - } + Constrains the rules on `Ember.isNone` by returning true for empty + string and empty arrays. - // both properties will accessible on the proxy - proxy.get('firstName') //=> 'Stefan' - proxy.get('lastName') //=> 'Penner' + ```javascript + Ember.isEmpty(); // true + Ember.isEmpty(null); // true + Ember.isEmpty(undefined); // true + Ember.isEmpty(''); // true + Ember.isEmpty([]); // true + Ember.isEmpty({}); // false + Ember.isEmpty('Adam Hawkins'); // false + Ember.isEmpty([0,1,2]); // false + Ember.isEmpty('\n\t'); // false + Ember.isEmpty(' '); // false ``` - @class Ember.PromiseProxyMixin + @method isEmpty + @for Ember + @param {Object} obj Value to test + @return {Boolean} @public */ - exports.default = _emberMetal.Mixin.create({ - /** - If the proxied promise is rejected this will contain the reason - provided. - @property reason - @default null - @public - */ - reason: null, - - /** - Once the proxied promise has settled this will become `false`. - @property isPending - @default true - @public - */ - isPending: _emberRuntimeComputedComputed_macros.not('isSettled').readOnly(), - /** - Once the proxied promise has settled this will become `true`. - @property isSettled - @default false - @public - */ - isSettled: _emberRuntimeComputedComputed_macros.or('isRejected', 'isFulfilled').readOnly(), + function isEmpty(obj) { + var none = _emberMetalIs_none.default(obj); + if (none) { + return none; + } - /** - Will become `true` if the proxied promise is rejected. - @property isRejected - @default false - @public - */ - isRejected: false, + if (typeof obj.size === 'number') { + return !obj.size; + } - /** - Will become `true` if the proxied promise is fulfilled. - @property isFulfilled - @default false - @public - */ - isFulfilled: false, + var objectType = typeof obj; - /** - The promise whose fulfillment value is being proxied by this object. - This property must be specified upon creation, and should not be - changed once created. - Example: - ```javascript - Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({ - promise: - }); - ``` - @property promise - @public - */ - promise: _emberMetal.computed({ - get: function () { - throw new _emberMetal.Error('PromiseProxy\'s promise must be set'); - }, - set: function (key, promise) { - return tap(this, promise); + if (objectType === 'object') { + var size = _emberMetalProperty_get.get(obj, 'size'); + if (typeof size === 'number') { + return !size; } - }), + } - /** - An alias to the proxied promise's `then`. - See RSVP.Promise.then. - @method then - @param {Function} callback - @return {RSVP.Promise} - @public - */ - then: promiseAlias('then'), + if (typeof obj.length === 'number' && objectType !== 'function') { + return !obj.length; + } - /** - An alias to the proxied promise's `catch`. - See RSVP.Promise.catch. - @method catch - @param {Function} callback - @return {RSVP.Promise} - @since 1.3.0 - @public - */ - 'catch': promiseAlias('catch'), + if (objectType === 'object') { + var _length = _emberMetalProperty_get.get(obj, 'length'); + if (typeof _length === 'number') { + return !_length; + } + } - /** - An alias to the proxied promise's `finally`. - See RSVP.Promise.finally. - @method finally - @param {Function} callback - @return {RSVP.Promise} - @since 1.3.0 - @public - */ - 'finally': promiseAlias('finally') + return false; + } +}); +enifed("ember-metal/is_none", ["exports"], function (exports) { + /** + Returns true if the passed value is null or undefined. This avoids errors + from JSLint complaining about use of ==, which can be technically + confusing. + + ```javascript + Ember.isNone(); // true + Ember.isNone(null); // true + Ember.isNone(undefined); // true + Ember.isNone(''); // false + Ember.isNone([]); // false + Ember.isNone(function() {}); // false + ``` + + @method isNone + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @public + */ + "use strict"; - }); + exports.default = isNone; - function promiseAlias(name) { - return function () { - var promise = _emberMetal.get(this, 'promise'); - return promise[name].apply(promise, arguments); - }; + function isNone(obj) { + return obj === null || obj === undefined; } }); -enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { + 'use strict'; + + exports.default = isPresent; + /** - @module ember - @submodule ember-runtime + A value is present if it not `isBlank`. + + ```javascript + Ember.isPresent(); // false + Ember.isPresent(null); // false + Ember.isPresent(undefined); // false + Ember.isPresent(''); // false + Ember.isPresent(' '); // false + Ember.isPresent('\n\t'); // false + Ember.isPresent([]); // false + Ember.isPresent({ length: 0 }) // false + Ember.isPresent(false); // true + Ember.isPresent(true); // true + Ember.isPresent('string'); // true + Ember.isPresent(0); // true + Ember.isPresent(function() {}) // true + Ember.isPresent({}); // true + Ember.isPresent(false); // true + Ember.isPresent('\n\t Hello'); // true + Ember.isPresent([1,2,3]); // true + ``` + + @method isPresent + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @since 1.8.0 + @public */ + function isPresent(obj) { + return !_emberMetalIs_blank.default(obj); + } +}); +enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { 'use strict'; - exports.buildFakeRegistryWithDeprecations = buildFakeRegistryWithDeprecations; + exports.isProxy = isProxy; + + function isProxy(value) { + if (typeof value === 'object' && value) { + var meta = _emberMetalMeta.peekMeta(value); + return meta && meta.isProxy(); + } + + return false; + } +}); +enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { + 'use strict'; /** - RegistryProxyMixin is used to provide public access to specific - registry functionality. + Helper class that allows you to register your library with Ember. - @class RegistryProxyMixin + Singleton created at `Ember.libraries`. + + @class Libraries + @constructor @private */ - exports.default = _emberMetal.Mixin.create({ - __registry__: null, - - /** - Given a fullName return the corresponding factory. - @public - @method resolveRegistration - @param {String} fullName - @return {Function} fullName's factory - */ - resolveRegistration: registryAlias('resolve'), - - /** - Registers a factory that can be used for dependency injection (with - `inject`) or for service lookup. Each factory is registered with - a full name including two parts: `type:name`. - A simple example: - ```javascript - let App = Ember.Application.create(); - App.Orange = Ember.Object.extend(); - App.register('fruit:favorite', App.Orange); - ``` - Ember will resolve factories from the `App` namespace automatically. - For example `App.CarsController` will be discovered and returned if - an application requests `controller:cars`. - An example of registering a controller with a non-standard name: - ```javascript - let App = Ember.Application.create(); - let Session = Ember.Controller.extend(); - App.register('controller:session', Session); - // The Session controller can now be treated like a normal controller, - // despite its non-standard name. - App.ApplicationController = Ember.Controller.extend({ - needs: ['session'] - }); - ``` - Registered factories are **instantiated** by having `create` - called on them. Additionally they are **singletons**, each time - they are looked up they return the same instance. - Some examples modifying that default behavior: - ```javascript - let App = Ember.Application.create(); - App.Person = Ember.Object.extend(); - App.Orange = Ember.Object.extend(); - App.Email = Ember.Object.extend(); - App.session = Ember.Object.create(); - App.register('model:user', App.Person, { singleton: false }); - App.register('fruit:favorite', App.Orange); - App.register('communication:main', App.Email, { singleton: false }); - App.register('session', App.session, { instantiate: false }); - ``` - @method register - @param fullName {String} type:name (e.g., 'model:user') - @param factory {Function} (e.g., App.Person) - @param options {Object} (optional) disable instantiation or singleton usage - @public - */ - register: registryAlias('register'), - /** - Unregister a factory. - ```javascript - let App = Ember.Application.create(); - let User = Ember.Object.extend(); - App.register('model:user', User); - App.resolveRegistration('model:user').create() instanceof User //=> true - App.unregister('model:user') - App.resolveRegistration('model:user') === undefined //=> true - ``` - @public - @method unregister - @param {String} fullName - */ - unregister: registryAlias('unregister'), + var Libraries = (function () { + function Libraries() { + babelHelpers.classCallCheck(this, Libraries); - /** - Check if a factory is registered. - @public - @method hasRegistration - @param {String} fullName - @return {Boolean} - */ - hasRegistration: registryAlias('has'), + this._registry = []; + this._coreLibIndex = 0; + } - /** - Register an option for a particular factory. - @public - @method registerOption - @param {String} fullName - @param {String} optionName - @param {Object} options - */ - registerOption: registryAlias('option'), + Libraries.prototype.isRegistered = function isRegistered(name) { + return !!this._getLibraryByName(name); + }; - /** - Return a specific registered option for a particular factory. - @public - @method registeredOption - @param {String} fullName - @param {String} optionName - @return {Object} options - */ - registeredOption: registryAlias('getOption'), + return Libraries; + })(); - /** - Register options for a particular factory. - @public - @method registerOptions - @param {String} fullName - @param {Object} options - */ - registerOptions: registryAlias('options'), + exports.Libraries = Libraries; - /** - Return registered options for a particular factory. - @public - @method registeredOptions - @param {String} fullName - @return {Object} options - */ - registeredOptions: registryAlias('getOptions'), + Libraries.prototype = { + constructor: Libraries, - /** - Allow registering options for all factories of a type. - ```javascript - let App = Ember.Application.create(); - let appInstance = App.buildInstance(); - // if all of type `connection` must not be singletons - appInstance.optionsForType('connection', { singleton: false }); - appInstance.register('connection:twitter', TwitterConnection); - appInstance.register('connection:facebook', FacebookConnection); - let twitter = appInstance.lookup('connection:twitter'); - let twitter2 = appInstance.lookup('connection:twitter'); - twitter === twitter2; // => false - let facebook = appInstance.lookup('connection:facebook'); - let facebook2 = appInstance.lookup('connection:facebook'); - facebook === facebook2; // => false - ``` - @public - @method registerOptionsForType - @param {String} type - @param {Object} options - */ - registerOptionsForType: registryAlias('optionsForType'), + _getLibraryByName: function (name) { + var libs = this._registry; + var count = libs.length; - /** - Return the registered options for all factories of a type. - @public - @method registeredOptionsForType - @param {String} type - @return {Object} options - */ - registeredOptionsForType: registryAlias('getOptionsForType'), + for (var i = 0; i < count; i++) { + if (libs[i].name === name) { + return libs[i]; + } + } + }, - /** - Define a dependency injection onto a specific factory or all factories - of a type. - When Ember instantiates a controller, view, or other framework component - it can attach a dependency to that component. This is often used to - provide services to a set of framework components. - An example of providing a session object to all controllers: - ```javascript - let App = Ember.Application.create(); - let Session = Ember.Object.extend({ isAuthenticated: false }); - // A factory must be registered before it can be injected - App.register('session:main', Session); - // Inject 'session:main' onto all factories of the type 'controller' - // with the name 'session' - App.inject('controller', 'session', 'session:main'); - App.IndexController = Ember.Controller.extend({ - isLoggedIn: Ember.computed.alias('session.isAuthenticated') - }); - ``` - Injections can also be performed on specific factories. - ```javascript - App.inject(, , ) - App.inject('route', 'source', 'source:main') - App.inject('route:application', 'email', 'model:email') - ``` - It is important to note that injections can only be performed on - classes that are instantiated by Ember itself. Instantiating a class - directly (via `create` or `new`) bypasses the dependency injection - system. - **Note:** Ember-Data instantiates its models in a unique manner, and consequently - injections onto models (or all models) will not work as expected. Injections - on models can be enabled by setting `EmberENV.MODEL_FACTORY_INJECTIONS` - to `true`. - @public - @method inject - @param factoryNameOrType {String} - @param property {String} - @param injectionName {String} - **/ - inject: registryAlias('injection') - }); + register: function (name, version, isCoreLibrary) { + var index = this._registry.length; - function registryAlias(name) { - return function () { - var _registry__; + if (!this._getLibraryByName(name)) { + if (isCoreLibrary) { + index = this._coreLibIndex++; + } + this._registry.splice(index, 0, { name: name, version: version }); + } else { + _emberMetalDebug.warn('Library "' + name + '" is already registered with Ember.', false, { id: 'ember-metal.libraries-register' }); + } + }, - return (_registry__ = this.__registry__)[name].apply(_registry__, arguments); - }; - } + registerCoreLibrary: function (name, version) { + this.register(name, version, true); + }, - function buildFakeRegistryWithDeprecations(instance, typeForMessage) { - var fakeRegistry = {}; - var registryProps = { - resolve: 'resolveRegistration', - register: 'register', - unregister: 'unregister', - has: 'hasRegistration', - option: 'registerOption', - options: 'registerOptions', - getOptions: 'registeredOptions', - optionsForType: 'registerOptionsForType', - getOptionsForType: 'registeredOptionsForType', - injection: 'inject' - }; + deRegister: function (name) { + var lib = this._getLibraryByName(name); + var index = undefined; - for (var deprecatedProperty in registryProps) { - fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]); + if (lib) { + index = this._registry.indexOf(lib); + this._registry.splice(index, 1); + } } + }; - return fakeRegistry; - } - - function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) { - return function () { - _emberMetal.deprecate('Using `' + typeForMessage + '.registry.' + deprecatedProperty + '` is deprecated. Please use `' + typeForMessage + '.' + nonDeprecatedProperty + '` instead.', false, { - id: 'ember-application.app-instance-registry', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-application-registry-ember-applicationinstance-registry' - }); - return instance[nonDeprecatedProperty].apply(instance, arguments); + if (_emberMetalFeatures.default('ember-libraries-isregistered')) { + Libraries.prototype.isRegistered = function (name) { + return !!this._getLibraryByName(name); }; } + + exports.default = new Libraries(); }); -enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { +enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) { /** @module ember - @submodule ember-runtime + @submodule ember-metal */ + /* + JavaScript (before ES6) does not have a Map implementation. Objects, + which are often used as dictionaries, may only have Strings as keys. + + Because Ember has a way to get a unique identifier for every object + via `Ember.guidFor`, we can implement a performant Map with arbitrary + keys. Because it is commonly used in low-level bookkeeping, Map is + implemented as a pure JavaScript object for performance. + + This implementation follows the current iteration of the ES6 proposal for + maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets), + with one exception: as we do not have the luxury of in-VM iteration, we implement a + forEach method for iteration. + + Map is mocked out to look like an Ember object, so you can do + `Ember.Map.create()` for symmetry with other Ember classes. + */ 'use strict'; + function missingFunction(fn) { + throw new TypeError(Object.prototype.toString.call(fn) + ' is not a function'); + } + + function missingNew(name) { + throw new TypeError('Constructor ' + name + ' requires \'new\''); + } + + function copyNull(obj) { + var output = new _emberUtils.EmptyObject(); + + for (var prop in obj) { + // hasOwnPropery is not needed because obj is new EmptyObject(); + output[prop] = obj[prop]; + } + + return output; + } + + function copyMap(original, newObject) { + var keys = original._keys.copy(); + var values = copyNull(original._values); + + newObject._keys = keys; + newObject._values = values; + newObject.size = original.size; + + return newObject; + } + /** - `Ember.TargetActionSupport` is a mixin that can be included in a class - to add a `triggerAction` method with semantics similar to the Handlebars - `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is - usually the best choice. This mixin is most often useful when you are - doing more complex event handling in Components. + This class is used internally by Ember and Ember Data. + Please do not use it at this time. We plan to clean it up + and add many tests soon. - @class TargetActionSupport - @namespace Ember - @extends Ember.Mixin - @private + @class OrderedSet + @namespace Ember + @constructor + @private */ - exports.default = _emberMetal.Mixin.create({ - target: null, - action: null, - actionContext: null, + function OrderedSet() { + if (this instanceof OrderedSet) { + this.clear(); + this._silenceRemoveDeprecation = false; + } else { + missingNew('OrderedSet'); + } + } - actionContextObject: _emberMetal.computed('actionContext', function () { - var actionContext = _emberMetal.get(this, 'actionContext'); + /** + @method create + @static + @return {Ember.OrderedSet} + @private + */ + OrderedSet.create = function () { + var Constructor = this; - if (typeof actionContext === 'string') { - var value = _emberMetal.get(this, actionContext); - if (value === undefined) { - value = _emberMetal.get(_emberEnvironment.context.lookup, actionContext); - } - return value; - } else { - return actionContext; - } - }), + return new Constructor(); + }; + OrderedSet.prototype = { + constructor: OrderedSet, /** - Send an `action` with an `actionContext` to a `target`. The action, actionContext - and target will be retrieved from properties of the object. For example: - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - target: Ember.computed.alias('controller'), - action: 'save', - actionContext: Ember.computed.alias('context'), - click() { - this.triggerAction(); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - The `target`, `action`, and `actionContext` can be provided as properties of - an optional object argument to `triggerAction` as well. - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - click() { - this.triggerAction({ - action: 'save', - target: this.get('controller'), - actionContext: this.get('context') - }); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. - But `target` and `action` must be specified either as properties or with the argument - to `triggerAction`, or a combination: - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - target: Ember.computed.alias('controller'), - click() { - this.triggerAction({ - action: 'save' - }); // Sends the `save` action, along with a reference to `this`, - // to the current controller - } - }); - ``` - @method triggerAction - @param opts {Object} (optional, with the optional keys action, target and/or actionContext) - @return {Boolean} true if the action was sent successfully and did not return false - @private + @method clear + @private */ - triggerAction: function () { - var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - var action = opts.action || _emberMetal.get(this, 'action'); - var target = opts.target; - - if (!target) { - target = getTarget(this); - } - - var actionContext = opts.actionContext; - - function args(options, actionName) { - var ret = []; - if (actionName) { - ret.push(actionName); - } + clear: function () { + this.presenceSet = new _emberUtils.EmptyObject(); + this.list = []; + this.size = 0; + }, - return ret.concat(options); - } + /** + @method add + @param obj + @param guid (optional, and for internal use) + @return {Ember.OrderedSet} + @private + */ + add: function (obj, _guid) { + var guid = _guid || _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; + var list = this.list; - if (typeof actionContext === 'undefined') { - actionContext = _emberMetal.get(this, 'actionContextObject') || this; + if (presenceSet[guid] !== true) { + presenceSet[guid] = true; + this.size = list.push(obj); } - if (target && action) { - var ret = undefined; + return this; + }, - if (target.send) { - ret = target.send.apply(target, args(actionContext, action)); - } else { - _emberMetal.assert('The action \'' + action + '\' did not exist on ' + target, typeof target[action] === 'function'); - ret = target[action].apply(target, args(actionContext)); - } + /** + @since 1.8.0 + @method delete + @param obj + @param _guid (optional and for internal use only) + @return {Boolean} + @private + */ + delete: function (obj, _guid) { + var guid = _guid || _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; + var list = this.list; - if (ret !== false) { - ret = true; + if (presenceSet[guid] === true) { + delete presenceSet[guid]; + var index = list.indexOf(obj); + if (index > -1) { + list.splice(index, 1); } - - return ret; + this.size = list.length; + return true; } else { return false; } - } - }); + }, - function getTarget(instance) { - // TODO: Deprecate specifying `targetObject` - var target = _emberMetal.get(instance, 'targetObject'); + /** + @method isEmpty + @return {Boolean} + @private + */ + isEmpty: function () { + return this.size === 0; + }, - // if a `targetObject` CP was provided, use it - if (target) { - return target; - } + /** + @method has + @param obj + @return {Boolean} + @private + */ + has: function (obj) { + if (this.size === 0) { + return false; + } - // if _targetObject use it - if (instance._targetObject) { - return instance._targetObject; - } + var guid = _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; - target = _emberMetal.get(instance, 'target'); - if (target) { - if (typeof target === 'string') { - var value = _emberMetal.get(instance, target); - if (value === undefined) { - value = _emberMetal.get(_emberEnvironment.context.lookup, target); - } + return presenceSet[guid] === true; + }, - return value; - } else { - return target; + /** + @method forEach + @param {Function} fn + @param self + @private + */ + forEach: function (fn /*, ...thisArg*/) { + if (typeof fn !== 'function') { + missingFunction(fn); } - } - - return null; - } -}); -enifed("ember-runtime/string_registry", ["exports"], function (exports) { - // STATE within a module is frowned apon, this exists - // to support Ember.STRINGS but shield ember internals from this legacy global - // API. - "use strict"; - - exports.setStrings = setStrings; - exports.getStrings = getStrings; - exports.get = get; - var STRINGS = {}; - function setStrings(strings) { - STRINGS = strings; - } + if (this.size === 0) { + return; + } - function getStrings() { - return STRINGS; - } + var list = this.list; - function get(name) { - return STRINGS[name]; - } -}); -enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) { - 'use strict'; + if (arguments.length === 2) { + for (var i = 0; i < list.length; i++) { + fn.call(arguments[1], list[i]); + } + } else { + for (var i = 0; i < list.length; i++) { + fn(list[i]); + } + } + }, - exports.default = _emberRuntimeSystemNamespace.default.extend(); -}); -enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray) { - 'use strict'; + /** + @method toArray + @return {Array} + @private + */ + toArray: function () { + return this.list.slice(); + }, - /** - @module ember - @submodule ember-runtime - */ + /** + @method copy + @return {Ember.OrderedSet} + @private + */ + copy: function () { + var Constructor = this.constructor; + var set = new Constructor(); - var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; - var EMPTY = []; + set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; + set.presenceSet = copyNull(this.presenceSet); + set.list = this.toArray(); + set.size = this.size; - function K() { - return this; - } + return set; + } + }; /** - An ArrayProxy wraps any other object that implements `Ember.Array` and/or - `Ember.MutableArray,` forwarding all requests. This makes it very useful for - a number of binding use cases or other cases where being able to swap - out the underlying array is useful. - - A simple example of usage: - - ```javascript - let pets = ['dog', 'cat', 'fish']; - let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); - - ap.get('firstObject'); // 'dog' - ap.set('content', ['amoeba', 'paramecium']); - ap.get('firstObject'); // 'amoeba' - ``` + A Map stores values indexed by keys. Unlike JavaScript's + default Objects, the keys of a Map can be any JavaScript + object. - This class can also be useful as a layer to transform the contents of - an array, as they are accessed. This can be done by overriding - `objectAtContent`: + Internally, a Map has two data structures: - ```javascript - let pets = ['dog', 'cat', 'fish']; - let ap = Ember.ArrayProxy.create({ - content: Ember.A(pets), - objectAtContent: function(idx) { - return this.get('content').objectAt(idx).toUpperCase(); - } - }); + 1. `keys`: an OrderedSet of all of the existing keys + 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)` - ap.get('firstObject'); // . 'DOG' - ``` + When a key/value pair is added for the first time, we + add the key to the `keys` OrderedSet, and create or + replace an entry in `values`. When an entry is deleted, + we delete its entry in `keys` and `values`. - @class ArrayProxy + @class Map @namespace Ember - @extends Ember.Object - @uses Ember.MutableArray - @public + @private + @constructor */ - exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { + function Map() { + if (this instanceof Map) { + this._keys = OrderedSet.create(); + this._keys._silenceRemoveDeprecation = true; + this._values = new _emberUtils.EmptyObject(); + this.size = 0; + } else { + missingNew('Map'); + } + } + + /** + @method create + @static + @private + */ + Map.create = function () { + var Constructor = this; + return new Constructor(); + }; + + Map.prototype = { + constructor: Map, /** - The content array. Must be an object that implements `Ember.Array` and/or - `Ember.MutableArray.` - @property content - @type Ember.Array + This property will change as the number of objects in the map changes. + @since 1.8.0 + @property size + @type number + @default 0 @private */ - content: null, + size: 0, /** - The array that the proxy pretends to be. In the default `ArrayProxy` - implementation, this and `content` are the same. Subclasses of `ArrayProxy` - can override this property to provide things like sorting and filtering. - @property arrangedContent - @private + Retrieve the value associated with a given key. + @method get + @param {*} key + @return {*} the value associated with the key, or `undefined` + @private */ - arrangedContent: _emberMetal.alias('content'), + get: function (key) { + if (this.size === 0) { + return; + } + + var values = this._values; + var guid = _emberUtils.guidFor(key); + + return values[guid]; + }, /** - Should actually retrieve the object at the specified index from the - content. You can override this method in subclasses to transform the - content item to something new. - This method will only be called if content is non-`null`. - @method objectAtContent - @param {Number} idx The index to retrieve. - @return {Object} the value or undefined if none found - @public + Adds a value to the map. If a value for the given key has already been + provided, the new value will replace the old value. + @method set + @param {*} key + @param {*} value + @return {Ember.Map} + @private */ - objectAtContent: function (idx) { - return _emberRuntimeMixinsArray.objectAt(_emberMetal.get(this, 'arrangedContent'), idx); + set: function (key, value) { + var keys = this._keys; + var values = this._values; + var guid = _emberUtils.guidFor(key); + + // ensure we don't store -0 + var k = key === -0 ? 0 : key; + + keys.add(k, guid); + + values[guid] = value; + + this.size = keys.size; + + return this; }, /** - Should actually replace the specified objects on the content array. - You can override this method in subclasses to transform the content item - into something new. - This method will only be called if content is non-`null`. - @method replaceContent - @param {Number} idx The starting index - @param {Number} amt The number of items to remove from the content. - @param {Array} objects Optional array of objects to insert or null if no - objects. - @return {void} + Removes a value from the map for an associated key. + @since 1.8.0 + @method delete + @param {*} key + @return {Boolean} true if an item was removed, false otherwise @private */ - replaceContent: function (idx, amt, objects) { - _emberMetal.get(this, 'content').replace(idx, amt, objects); + delete: function (key) { + if (this.size === 0) { + return false; + } + // don't use ES6 "delete" because it will be annoying + // to use in browsers that are not ES6 friendly; + var keys = this._keys; + var values = this._values; + var guid = _emberUtils.guidFor(key); + + if (keys.delete(key, guid)) { + delete values[guid]; + this.size = keys.size; + return true; + } else { + return false; + } }, /** - Invoked when the content property is about to change. Notifies observers that the - entire array content will change. - @private - @method _contentWillChange + Check whether a key is present. + @method has + @param {*} key + @return {Boolean} true if the item was present, false otherwise + @private */ - _contentWillChange: _emberMetal._beforeObserver('content', function () { - this._teardownContent(); - }), + has: function (key) { + return this._keys.has(key); + }, - _teardownContent: function () { - var content = _emberMetal.get(this, 'content'); + /** + Iterate over all the keys and values. Calls the function once + for each key, passing in value, key, and the map being iterated over, + in that order. + The keys are guaranteed to be iterated over in insertion order. + @method forEach + @param {Function} callback + @param {*} self if passed, the `this` value inside the + callback. By default, `this` is the map. + @private + */ + forEach: function (callback /*, ...thisArg*/) { + if (typeof callback !== 'function') { + missingFunction(callback); + } - if (content) { - _emberRuntimeMixinsArray.removeArrayObserver(content, this, { - willChange: 'contentArrayWillChange', - didChange: 'contentArrayDidChange' - }); + if (this.size === 0) { + return; + } + + var map = this; + var cb = undefined, + thisArg = undefined; + + if (arguments.length === 2) { + thisArg = arguments[1]; + cb = function (key) { + return callback.call(thisArg, map.get(key), key, map); + }; + } else { + cb = function (key) { + return callback(map.get(key), key, map); + }; } + + this._keys.forEach(cb); }, /** - Override to implement content array `willChange` observer. - @method contentArrayWillChange - @param {Ember.Array} contentArray the content array - @param {Number} start starting index of the change - @param {Number} removeCount count of items removed - @param {Number} addCount count of items added + @method clear @private */ - contentArrayWillChange: K, + clear: function () { + this._keys.clear(); + this._values = new _emberUtils.EmptyObject(); + this.size = 0; + }, + /** - Override to implement content array `didChange` observer. - @method contentArrayDidChange - @param {Ember.Array} contentArray the content array - @param {Number} start starting index of the change - @param {Number} removeCount count of items removed - @param {Number} addCount count of items added + @method copy + @return {Ember.Map} @private */ - contentArrayDidChange: K, + copy: function () { + return copyMap(this, new Map()); + } + }; - /** - Invoked when the content property changes. Notifies observers that the - entire array content has changed. - @private - @method _contentDidChange - */ - _contentDidChange: _emberMetal.observer('content', function () { - var content = _emberMetal.get(this, 'content'); + /** + @class MapWithDefault + @namespace Ember + @extends Ember.Map + @private + @constructor + @param [options] + @param {*} [options.defaultValue] + */ + function MapWithDefault(options) { + this._super$constructor(); + this.defaultValue = options.defaultValue; + } + + /** + @method create + @static + @param [options] + @param {*} [options.defaultValue] + @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns + `Ember.MapWithDefault` otherwise returns `Ember.Map` + @private + */ + MapWithDefault.create = function (options) { + if (options) { + return new MapWithDefault(options); + } else { + return new Map(); + } + }; + + MapWithDefault.prototype = Object.create(Map.prototype); + MapWithDefault.prototype.constructor = MapWithDefault; + MapWithDefault.prototype._super$constructor = Map; + MapWithDefault.prototype._super$get = Map.prototype.get; + + /** + Retrieve the value associated with a given key. + + @method get + @param {*} key + @return {*} the value associated with the key, or the default value + @private + */ + MapWithDefault.prototype.get = function (key) { + var hasValue = this.has(key); + + if (hasValue) { + return this._super$get(key); + } else { + var defaultValue = this.defaultValue(key); + this.set(key, defaultValue); + return defaultValue; + } + }; + + /** + @method copy + @return {Ember.MapWithDefault} + @private + */ + MapWithDefault.prototype.copy = function () { + var Constructor = this.constructor; + return copyMap(this, new Constructor({ + defaultValue: this.defaultValue + })); + }; + + exports.default = Map; + exports.OrderedSet = OrderedSet; + exports.Map = Map; + exports.MapWithDefault = MapWithDefault; +}); +enifed('ember-metal/merge', ['exports'], function (exports) { + /** + Merge the contents of two objects together into the first object. + + ```javascript + Ember.merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' } + var a = { first: 'Yehuda' }; + var b = { last: 'Katz' }; + Ember.merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' } + ``` + + @method merge + @for Ember + @param {Object} original The object to merge into + @param {Object} updates The object to copy properties from + @return {Object} + @public + */ + 'use strict'; - _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', content !== this); + exports.default = merge; - this._setupContent(); - }), + function merge(original, updates) { + if (!updates || typeof updates !== 'object') { + return original; + } - _setupContent: function () { - var content = _emberMetal.get(this, 'content'); + var props = Object.keys(updates); + var prop = undefined; - if (content) { - _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof content, _emberRuntimeUtils.isArray(content) || content.isDestroyed); + for (var i = 0; i < props.length; i++) { + prop = props[i]; + original[prop] = updates[prop]; + } - _emberRuntimeMixinsArray.addArrayObserver(content, this, { - willChange: 'contentArrayWillChange', - didChange: 'contentArrayDidChange' - }); - } - }, + return original; + } +}); +enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains', 'require'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains, _require) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - _arrangedContentWillChange: _emberMetal._beforeObserver('arrangedContent', function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + exports.deleteMeta = deleteMeta; + exports.meta = meta; - this.arrangedContentArrayWillChange(this, 0, len, undefined); - this.arrangedContentWillChange(this); + var counters = { + peekCalls: 0, + peekParentCalls: 0, + peekPrototypeWalks: 0, + setCalls: 0, + deleteCalls: 0, + metaCalls: 0, + metaInstantiated: 0 + }; - this._teardownArrangedContent(arrangedContent); - }), + /** + @module ember-metal + */ - _arrangedContentDidChange: _emberMetal.observer('arrangedContent', function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + /* + This declares several meta-programmed members on the Meta class. Such + meta! + + In general, the `readable` variants will give you an object (if it + already exists) that you can read but should not modify. The + `writable` variants will give you a mutable object, and they will + create it if it didn't already exist. + + The following methods will get generated metaprogrammatically, and + I'm including them here for greppability: + + writableCache, readableCache, writeWatching, + peekWatching, clearWatching, writeMixins, + peekMixins, clearMixins, writeBindings, + peekBindings, clearBindings, writeValues, + peekValues, clearValues, writeDeps, forEachInDeps + writableChainWatchers, readableChainWatchers, writableChains, + readableChains, writableTag, readableTag, writableTags, + readableTags + */ + var members = { + cache: ownMap, + weak: ownMap, + watching: inheritedMap, + mixins: inheritedMap, + bindings: inheritedMap, + values: inheritedMap, + chainWatchers: ownCustomObject, + chains: inheritedCustomObject, + tag: ownCustomObject, + tags: ownMap + }; - _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this); + // FLAGS + var SOURCE_DESTROYING = 1 << 1; + var SOURCE_DESTROYED = 1 << 2; + var META_DESTROYED = 1 << 3; + var IS_PROXY = 1 << 4; - this._setupArrangedContent(); + if (true || false) { + members.lastRendered = ownMap; + if (_require.has('ember-debug')) { + //https://github.com/emberjs/ember.js/issues/14732 + members.lastRenderedReferenceMap = ownMap; + members.lastRenderedTemplateMap = ownMap; + } + } - this.arrangedContentDidChange(this); - this.arrangedContentArrayDidChange(this, 0, undefined, len); - }), + var memberNames = Object.keys(members); + var META_FIELD = '__ember_meta__'; - _setupArrangedContent: function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var Meta = (function () { + function Meta(obj, parentMeta) { + var _this = this; - if (arrangedContent) { - _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof arrangedContent, _emberRuntimeUtils.isArray(arrangedContent) || arrangedContent.isDestroyed); + babelHelpers.classCallCheck(this, Meta); - _emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, { - willChange: 'arrangedContentArrayWillChange', - didChange: 'arrangedContentArrayDidChange' - }); - } - }, + _emberMetalDebug.runInDebug(function () { + return counters.metaInstantiated++; + }); - _teardownArrangedContent: function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + this._cache = undefined; + this._weak = undefined; + this._watching = undefined; + this._mixins = undefined; + this._bindings = undefined; + this._values = undefined; + this._deps = undefined; + this._chainWatchers = undefined; + this._chains = undefined; + this._tag = undefined; + this._tags = undefined; + + // initial value for all flags right now is false + // see FLAGS const for detailed list of flags used + this._flags = 0; + + // used only internally + this.source = obj; + + // when meta(obj).proto === obj, the object is intended to be only a + // prototype and doesn't need to actually be observable itself + this.proto = undefined; + + // The next meta in our inheritance chain. We (will) track this + // explicitly instead of using prototypical inheritance because we + // have detailed knowledge of how each property should really be + // inherited, and we can optimize it much better than JS runtimes. + this.parent = parentMeta; - if (arrangedContent) { - _emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, { - willChange: 'arrangedContentArrayWillChange', - didChange: 'arrangedContentArrayDidChange' + if (true || false) { + this._lastRendered = undefined; + _emberMetalDebug.runInDebug(function () { + _this._lastRenderedReferenceMap = undefined; + _this._lastRenderedTemplateMap = undefined; }); } - }, - - arrangedContentWillChange: K, - arrangedContentDidChange: K, - objectAt: function (idx) { - return _emberMetal.get(this, 'content') && this.objectAtContent(idx); - }, + this._initializeListeners(); + } - length: _emberMetal.computed(function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - return arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - // No dependencies since Enumerable notifies length of change - }), + Meta.prototype.isInitialized = function isInitialized(obj) { + return this.proto !== obj; + }; - _replace: function (idx, amt, objects) { - var content = _emberMetal.get(this, 'content'); - _emberMetal.assert('The content property of ' + this.constructor + ' should be set before modifying it', content); - if (content) { - this.replaceContent(idx, amt, objects); + Meta.prototype.destroy = function destroy() { + if (this.isMetaDestroyed()) { + return; } - return this; - }, - - replace: function () { - if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { - this._replace.apply(this, arguments); - } else { - throw new _emberMetal.Error('Using replace on an arranged ArrayProxy is not allowed.'); - } - }, + // remove chainWatchers to remove circular references that would prevent GC + var nodes = undefined, + key = undefined, + nodeObject = undefined; + var node = this.readableChains(); + if (node) { + NODE_STACK.push(node); + // process tree + while (NODE_STACK.length > 0) { + node = NODE_STACK.pop(); + // push children + nodes = node._chains; + if (nodes) { + for (key in nodes) { + if (nodes[key] !== undefined) { + NODE_STACK.push(nodes[key]); + } + } + } - _insertAt: function (idx, object) { - if (idx > _emberMetal.get(this, 'content.length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + // remove chainWatcher in node object + if (node._watching) { + nodeObject = node._object; + if (nodeObject) { + var foreignMeta = peekMeta(nodeObject); + // avoid cleaning up chain watchers when both current and + // foreign objects are being destroyed + // if both are being destroyed manual cleanup is not needed + // as they will be GC'ed and no non-destroyed references will + // be remaining + if (foreignMeta && !foreignMeta.isSourceDestroying()) { + _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); + } + } + } + } } - this._replace(idx, 0, [object]); - return this; - }, + this.setMetaDestroyed(); + }; - insertAt: function (idx, object) { - if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { - return this._insertAt(idx, object); - } else { - throw new _emberMetal.Error('Using insertAt on an arranged ArrayProxy is not allowed.'); - } - }, + Meta.prototype.isSourceDestroying = function isSourceDestroying() { + return (this._flags & SOURCE_DESTROYING) !== 0; + }; - removeAt: function (start, len) { - if ('number' === typeof start) { - var content = _emberMetal.get(this, 'content'); - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var indices = []; + Meta.prototype.setSourceDestroying = function setSourceDestroying() { + this._flags |= SOURCE_DESTROYING; + }; - if (start < 0 || start >= _emberMetal.get(this, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } + Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { + return (this._flags & SOURCE_DESTROYED) !== 0; + }; - if (len === undefined) { - len = 1; - } + Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { + this._flags |= SOURCE_DESTROYED; + }; - // Get a list of indices in original content to remove - for (var i = start; i < start + len; i++) { - // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent - indices.push(content.indexOf(_emberRuntimeMixinsArray.objectAt(arrangedContent, i))); - } + Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { + return (this._flags & META_DESTROYED) !== 0; + }; - // Replace in reverse order since indices will change - indices.sort(function (a, b) { - return b - a; - }); + Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { + this._flags |= META_DESTROYED; + }; - _emberMetal.beginPropertyChanges(); - for (var i = 0; i < indices.length; i++) { - this._replace(indices[i], 1, EMPTY); - } - _emberMetal.endPropertyChanges(); - } + Meta.prototype.isProxy = function isProxy() { + return (this._flags & IS_PROXY) !== 0; + }; - return this; - }, + Meta.prototype.setProxy = function setProxy() { + this._flags |= IS_PROXY; + }; - pushObject: function (obj) { - this._insertAt(_emberMetal.get(this, 'content.length'), obj); - return obj; - }, + Meta.prototype._getOrCreateOwnMap = function _getOrCreateOwnMap(key) { + return this[key] || (this[key] = new _emberUtils.EmptyObject()); + }; - pushObjects: function (objects) { - if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || _emberRuntimeUtils.isArray(objects))) { - throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + Meta.prototype._getInherited = function _getInherited(key) { + var pointer = this; + while (pointer !== undefined) { + if (pointer[key]) { + return pointer[key]; + } + pointer = pointer.parent; } - this._replace(_emberMetal.get(this, 'length'), 0, objects); - return this; - }, + }; - setObjects: function (objects) { - if (objects.length === 0) { - return this.clear(); + Meta.prototype._findInherited = function _findInherited(key, subkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var value = map[subkey]; + if (value !== undefined) { + return value; + } + } + pointer = pointer.parent; } + }; - var len = _emberMetal.get(this, 'length'); - this._replace(0, len, objects); - return this; - }, - - unshiftObject: function (obj) { - this._insertAt(0, obj); - return obj; - }, - - unshiftObjects: function (objects) { - this._replace(0, 0, objects); - return this; - }, - - slice: function () { - var arr = this.toArray(); - return arr.slice.apply(arr, arguments); - }, - - arrangedContentArrayWillChange: function (item, idx, removedCnt, addedCnt) { - this.arrayContentWillChange(idx, removedCnt, addedCnt); - }, - - arrangedContentArrayDidChange: function (item, idx, removedCnt, addedCnt) { - this.arrayContentDidChange(idx, removedCnt, addedCnt); - }, - - init: function () { - this._super.apply(this, arguments); - this._setupContent(); - this._setupArrangedContent(); - }, - - willDestroy: function () { - this._teardownArrangedContent(); - this._teardownContent(); - } - }); -}); -enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/inject'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeInject) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-runtime - */ - - // using ember-metal/lib/main here to ensure that ember-debug is setup - // if present - - var _Mixin$create, _ClassMixinProps; + // Implements a member that provides a lazily created map of maps, + // with inheritance at both levels. - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['.'], ['.']); + Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { + _emberMetalDebug.assert('Cannot call writeDeps after the object is destroyed.', !this.isMetaDestroyed()); - var schedule = _emberMetal.run.schedule; - var applyMixin = _emberMetal.Mixin._apply; - var finishPartial = _emberMetal.Mixin.finishPartial; - var reopen = _emberMetal.Mixin.prototype.reopen; - var hasCachedComputedProperties = false; + var outerMap = this._getOrCreateOwnMap('_deps'); + var innerMap = outerMap[subkey]; + if (!innerMap) { + innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); + } + innerMap[itemkey] = value; + }; - var POST_INIT = _emberUtils.symbol('POST_INIT'); + Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer._deps; + if (map) { + var value = map[subkey]; + if (value) { + if (value[itemkey] !== undefined) { + return value[itemkey]; + } + } + } + pointer = pointer.parent; + } + }; - exports.POST_INIT = POST_INIT; - function makeCtor() { - // Note: avoid accessing any properties on the object since it makes the - // method a lot faster. This is glue code so we want it to be as fast as - // possible. + Meta.prototype.hasDeps = function hasDeps(subkey) { + var pointer = this; + while (pointer !== undefined) { + if (pointer._deps && pointer._deps[subkey]) { + return true; + } + pointer = pointer.parent; + } + return false; + }; - var wasApplied = false; - var initProperties; + Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { + return this._forEachIn('_deps', subkey, fn); + }; - var Class = function () { - if (!wasApplied) { - Class.proto(); // prepare prototype... + Meta.prototype._forEachIn = function _forEachIn(key, subkey, fn) { + var pointer = this; + var seen = new _emberUtils.EmptyObject(); + var calls = []; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var innerMap = map[subkey]; + if (innerMap) { + for (var innerKey in innerMap) { + if (!seen[innerKey]) { + seen[innerKey] = true; + calls.push([innerKey, innerMap[innerKey]]); + } + } + } + } + pointer = pointer.parent; } + for (var i = 0; i < calls.length; i++) { + var _calls$i = calls[i]; + var innerKey = _calls$i[0]; + var value = _calls$i[1]; - if (arguments.length > 0) { - initProperties = [arguments[0]]; + fn(innerKey, value); } + }; - this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); - var m = _emberMetal.meta(this); - var proto = m.proto; - m.proto = this; - if (initProperties) { - // capture locally so we can clear the closed over variable - var props = initProperties; - initProperties = null; + Meta.prototype.readInheritedValue = function readInheritedValue(key, subkey) { + var internalKey = '_' + key; - var concatenatedProperties = this.concatenatedProperties; - var mergedProperties = this.mergedProperties; + var pointer = this; - for (var i = 0; i < props.length; i++) { - var properties = props[i]; + while (pointer !== undefined) { + var map = pointer[internalKey]; + if (map) { + var value = map[subkey]; + if (value !== undefined || subkey in map) { + return map[subkey]; + } + } + pointer = pointer.parent; + } - _emberMetal.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetal.Mixin)); + return UNDEFINED; + }; - if (typeof properties !== 'object' && properties !== undefined) { - throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); - } + Meta.prototype.writeValue = function writeValue(obj, key, value) { + var descriptor = _emberUtils.lookupDescriptor(obj, key); + var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - if (!properties) { - continue; - } + if (isMandatorySetter) { + this.writeValues(key, value); + } else { + obj[key] = value; + } + }; - var keyNames = Object.keys(properties); + return Meta; + })(); - for (var j = 0; j < keyNames.length; j++) { - var keyName = keyNames[j]; - var value = properties[keyName]; + exports.Meta = Meta; - if (_emberMetal.detectBinding(keyName)) { - m.writeBindings(keyName, value); - } + var NODE_STACK = []; - var possibleDesc = this[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + for (var _name in _emberMetalMeta_listeners.protoMethods) { + Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; + } + memberNames.forEach(function (name) { + return members[name](name, Meta); + }); - _emberMetal.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty)); - _emberMetal.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1)); - _emberMetal.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this))); + // Implements a member that is a lazily created, non-inheritable + // POJO. + function ownMap(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function () { + return this._getOrCreateOwnMap(key); + }; + Meta.prototype['readable' + capitalized] = function () { + return this[key]; + }; + } - if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { - var baseValue = this[keyName]; + // Implements a member that is a lazily created POJO with inheritable + // values. + function inheritedMap(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); - if (baseValue) { - if ('function' === typeof baseValue.concat) { - value = baseValue.concat(value); - } else { - value = _emberUtils.makeArray(baseValue).concat(value); - } - } else { - value = _emberUtils.makeArray(value); - } - } + Meta.prototype['write' + capitalized] = function (subkey, value) { + _emberMetalDebug.assert('Cannot call write' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { - var originalValue = this[keyName]; + var map = this._getOrCreateOwnMap(key); + map[subkey] = value; + }; - value = _emberUtils.assign({}, originalValue, value); - } + Meta.prototype['peek' + capitalized] = function (subkey) { + return this._findInherited(key, subkey); + }; - if (desc) { - desc.set(this, keyName, value); - } else { - if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { - this.setUnknownProperty(keyName, value); - } else { - if (true) { - _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter - } else { - this[keyName] = value; - } - } + Meta.prototype['forEach' + capitalized] = function (fn) { + var pointer = this; + var seen = new _emberUtils.EmptyObject(); + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + for (var _key in map) { + if (!seen[_key]) { + seen[_key] = true; + fn(_key, map[_key]); } } } + pointer = pointer.parent; } - - finishPartial(this, m); - - this.init.apply(this, arguments); - - this[POST_INIT](); - - m.proto = proto; - _emberMetal.finishChains(this); - _emberMetal.sendEvent(this, 'init'); }; - Class.toString = _emberMetal.Mixin.prototype.toString; - Class.willReopen = function () { - if (wasApplied) { - Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); - } + Meta.prototype['clear' + capitalized] = function () { + _emberMetalDebug.assert('Cannot call clear' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - wasApplied = false; + this[key] = undefined; }; - Class._initProperties = function (args) { - initProperties = args; + Meta.prototype['deleteFrom' + capitalized] = function (subkey) { + delete this._getOrCreateOwnMap(key)[subkey]; }; - Class.proto = function () { - var superclass = Class.superclass; - if (superclass) { - superclass.proto(); - } - - if (!wasApplied) { - wasApplied = true; - Class.PrototypeMixin.applyPartial(Class.prototype); - } - - return this.prototype; + Meta.prototype['hasIn' + capitalized] = function (subkey) { + return this._findInherited(key, subkey) !== undefined; }; - - return Class; } - /** - @class CoreObject - @namespace Ember - @public - */ - var CoreObject = makeCtor(); - CoreObject.toString = function () { - return 'Ember.CoreObject'; - }; - CoreObject.PrototypeMixin = _emberMetal.Mixin.create((_Mixin$create = { - reopen: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - applyMixin(this, args, true); - return this; - }, - - /** - An overridable method called when objects are instantiated. By default, - does nothing unless it is overridden during class definition. - Example: - ```javascript - const Person = Ember.Object.extend({ - init() { - alert(`Name is ${this.get('name')}`); - } - }); - let steve = Person.create({ - name: "Steve" - }); - // alerts 'Name is Steve'. - ``` - NOTE: If you do override `init` for a framework class like `Ember.View`, - be sure to call `this._super(...arguments)` in your - `init` declaration! If you don't, Ember may not have an opportunity to - do important setup work, and you'll see strange behavior in your - application. - @method init - @public - */ - init: function () {} - - }, _Mixin$create[POST_INIT] = function () {}, _Mixin$create.__defineNonEnumerable = function (property) { - Object.defineProperty(this, property.name, property.descriptor); - //this[property.name] = property.descriptor.value; - }, _Mixin$create.concatenatedProperties = null, _Mixin$create.mergedProperties = null, _Mixin$create.isDestroyed = _emberMetal.descriptor({ - get: function () { - return _emberMetal.meta(this).isSourceDestroyed(); - }, - - set: function (value) { - // prevent setting while applying mixins - if (typeof value === 'object' && value !== null && value.isDescriptor) { - return; - } + var UNDEFINED = _emberUtils.symbol('undefined'); - _emberMetal.assert(('You cannot set `' + this + '.isDestroyed` directly, please use ').destroy()(_templateObject), false); - } - }), _Mixin$create.isDestroying = _emberMetal.descriptor({ - get: function () { - return _emberMetal.meta(this).isSourceDestroying(); - }, + exports.UNDEFINED = UNDEFINED; + // Implements a member that provides a non-heritable, lazily-created + // object using the method you provide. + function ownCustomObject(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function (create) { + _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - set: function (value) { - // prevent setting while applying mixins - if (typeof value === 'object' && value !== null && value.isDescriptor) { - return; + var ret = this[key]; + if (!ret) { + ret = this[key] = create(this.source); } + return ret; + }; + Meta.prototype['readable' + capitalized] = function () { + return this[key]; + }; + } - _emberMetal.assert(('You cannot set `' + this + '.isDestroying` directly, please use ').destroy()(_templateObject), false); - } - }), _Mixin$create.destroy = function () { - var m = _emberMetal.meta(this); - if (m.isSourceDestroying()) { - return; - } + // Implements a member that provides an inheritable, lazily-created + // object using the method you provide. We will derived children from + // their parents by calling your object's `copy()` method. + function inheritedCustomObject(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function (create) { + _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - m.setSourceDestroying(); + var ret = this[key]; + if (!ret) { + if (this.parent) { + ret = this[key] = this.parent['writable' + capitalized](create).copy(this.source); + } else { + ret = this[key] = create(this.source); + } + } + return ret; + }; + Meta.prototype['readable' + capitalized] = function () { + return this._getInherited(key); + }; + } - schedule('actions', this, this.willDestroy); - schedule('destroy', this, this._scheduledDestroy, m); + function memberProperty(name) { + return '_' + name; + } - return this; - }, _Mixin$create.willDestroy = function () {}, _Mixin$create._scheduledDestroy = function (m) { - if (m.isSourceDestroyed()) { - return; - } - _emberMetal.destroy(this); - m.setSourceDestroyed(); - }, _Mixin$create.bind = function (to, from) { - if (!(from instanceof _emberMetal.Binding)) { - from = _emberMetal.Binding.from(from); - } - from.to(to).connect(this); - return from; - }, _Mixin$create.toString = function () { - var hasToStringExtension = typeof this.toStringExtension === 'function'; - var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; - var ret = '<' + this.constructor.toString() + ':' + _emberUtils.guidFor(this) + extension + '>'; + // there's a more general-purpose capitalize in ember-runtime, but we + // don't want to make ember-metal depend on ember-runtime. + function capitalize(name) { + return name.replace(/^\w/, function (m) { + return m.toUpperCase(); + }); + } - return ret; - }, _Mixin$create)); + var META_DESC = { + writable: true, + configurable: true, + enumerable: false, + value: null + }; - CoreObject.PrototypeMixin.ownerConstructor = CoreObject; + exports.META_DESC = META_DESC; + var EMBER_META_PROPERTY = { + name: META_FIELD, + descriptor: META_DESC + }; - CoreObject.__super__ = null; + if (true) { + Meta.prototype.readInheritedValue = function (key, subkey) { + var internalKey = '_' + key; - var ClassMixinProps = (_ClassMixinProps = { + var pointer = this; - ClassMixin: _emberMetal.REQUIRED, + while (pointer !== undefined) { + var map = pointer[internalKey]; + if (map) { + var value = map[subkey]; + if (value !== undefined || subkey in map) { + return map[subkey]; + } + } + pointer = pointer.parent; + } - PrototypeMixin: _emberMetal.REQUIRED, + return UNDEFINED; + }; - isClass: true, + Meta.prototype.writeValue = function (obj, key, value) { + var descriptor = _emberUtils.lookupDescriptor(obj, key); + var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - isMethod: false - }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { - var Class = makeCtor(); - var proto; - Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); - Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); + if (isMandatorySetter) { + this.writeValues(key, value); + } else { + obj[key] = value; + } + }; + } - Class.ClassMixin.ownerConstructor = Class; - Class.PrototypeMixin.ownerConstructor = Class; + var setMeta = undefined, + peekMeta = undefined; - reopen.apply(Class.PrototypeMixin, arguments); + // choose the one appropriate for given platform + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + (function () { + var getPrototypeOf = Object.getPrototypeOf; + var metaStore = new WeakMap(); - Class.superclass = this; - Class.__super__ = this.prototype; + exports.setMeta = setMeta = function WeakMap_setMeta(obj, meta) { + _emberMetalDebug.runInDebug(function () { + return counters.setCalls++; + }); + metaStore.set(obj, meta); + }; - proto = Class.prototype = Object.create(this.prototype); - proto.constructor = Class; - _emberUtils.generateGuid(proto); - _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype + exports.peekMeta = peekMeta = function WeakMap_peekMeta(obj) { + _emberMetalDebug.runInDebug(function () { + return counters.peekCalls++; + }); - Class.ClassMixin.apply(Class); - return Class; - }, _ClassMixinProps.create = function () { - var C = this; + return metaStore.get(obj); + }; - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + exports.peekMeta = peekMeta = function WeakMap_peekParentMeta(obj) { + var pointer = obj; + var meta = undefined; + while (pointer) { + meta = metaStore.get(pointer); + // jshint loopfunc:true + _emberMetalDebug.runInDebug(function () { + return counters.peekCalls++; + }); + // stop if we find a `null` value, since + // that means the meta was deleted + // any other truthy value is a "real" meta + if (meta === null || meta) { + return meta; + } - if (args.length > 0) { - this._initProperties(args); - } - return new C(); - }, _ClassMixinProps.reopen = function () { - this.willReopen(); - reopen.apply(this.PrototypeMixin, arguments); - return this; - }, _ClassMixinProps.reopenClass = function () { - reopen.apply(this.ClassMixin, arguments); - applyMixin(this, arguments, false); - return this; - }, _ClassMixinProps.detect = function (obj) { - if ('function' !== typeof obj) { - return false; - } - while (obj) { - if (obj === this) { - return true; + pointer = getPrototypeOf(pointer); + _emberMetalDebug.runInDebug(function () { + return counters.peakPrototypeWalks++; + }); + } + }; + })(); + } else { + exports.setMeta = setMeta = function Fallback_setMeta(obj, meta) { + // if `null` already, just set it to the new value + // otherwise define property first + if (obj[META_FIELD] !== null) { + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(EMBER_META_PROPERTY); + } else { + Object.defineProperty(obj, META_FIELD, META_DESC); + } } - obj = obj.superclass; - } - return false; - }, _ClassMixinProps.detectInstance = function (obj) { - return obj instanceof this; - }, _ClassMixinProps.metaForProperty = function (key) { - var proto = this.proto(); - var possibleDesc = proto[key]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); - return desc._meta || {}; - }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; - var proto = this.proto(); - var property; - var properties = []; - for (var name in proto) { - property = proto[name]; + obj[META_FIELD] = meta; + }; - if (property && property.isDescriptor) { - properties.push({ - name: name, - meta: property._meta - }); - } - } - return properties; - }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; - var empty = {}; + exports.peekMeta = peekMeta = function Fallback_peekMeta(obj) { + return obj[META_FIELD]; + }; + } - var properties = _emberMetal.get(this, '_computedProperties'); + function deleteMeta(obj) { + _emberMetalDebug.runInDebug(function () { + return counters.deleteCalls++; + }); - for (var i = 0; i < properties.length; i++) { - property = properties[i]; - callback.call(binding || this, property.name, property.meta || empty); + var meta = peekMeta(obj); + if (meta) { + meta.destroy(); } - }, _ClassMixinProps); - - function injectedPropertyAssertion() { - _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this)); } - _emberMetal.runInDebug(function () { - /** - Provides lookup-time type validation for injected properties. - @private - @method _onLookup - */ - ClassMixinProps._onLookup = injectedPropertyAssertion; - }); - /** - Returns a hash of property names and container names that injected - properties will lookup on the container lazily. + Retrieves the meta hash for an object. If `writable` is true ensures the + hash is writable for this object as well. - @method _lazyInjections - @return {Object} Hash of all lazy injected property keys to container names + The meta object contains information about computed property descriptors as + well as any watched properties and other information. You generally will + not access this information directly but instead work with higher level + methods that manipulate this hash indirectly. + + @method meta + @for Ember @private + + @param {Object} obj The object to retrieve meta for + @param {Boolean} [writable=true] Pass `false` if you do not intend to modify + the meta hash, allowing the method to avoid making an unnecessary copy. + @return {Object} the meta hash for an object */ - ClassMixinProps._lazyInjections = function () { - var injections = {}; - var proto = this.proto(); - var key, desc; - for (key in proto) { - desc = proto[key]; - if (desc instanceof _emberMetal.InjectedProperty) { - injections[key] = desc.type + ':' + (desc.name || key); + function meta(obj) { + _emberMetalDebug.runInDebug(function () { + return counters.metaCalls++; + }); + + var maybeMeta = peekMeta(obj); + var parent = undefined; + + // remove this code, in-favor of explicit parent + if (maybeMeta) { + if (maybeMeta.source === obj) { + return maybeMeta; } + parent = maybeMeta; } - return injections; - }; + var newMeta = new Meta(obj, parent); + setMeta(obj, newMeta); + return newMeta; + } - var ClassMixin = _emberMetal.Mixin.create(ClassMixinProps); + exports.peekMeta = peekMeta; + exports.setMeta = setMeta; + exports.counters = counters; +}); +enifed('ember-metal/meta_listeners', ['exports'], function (exports) { + /* + When we render a rich template hierarchy, the set of events that + *might* happen tends to be much larger than the set of events that + actually happen. This implies that we should make listener creation & + destruction cheap, even at the cost of making event dispatch more + expensive. + + Thus we store a new listener with a single push and no new + allocations, without even bothering to do deduplication -- we can + save that for dispatch time, if an event actually happens. + */ - ClassMixin.ownerConstructor = CoreObject; + /* listener flags */ + 'use strict'; - CoreObject.ClassMixin = ClassMixin; + var ONCE = 1; + exports.ONCE = ONCE; + var SUSPENDED = 2; - ClassMixin.apply(CoreObject); + exports.SUSPENDED = SUSPENDED; + var protoMethods = { - CoreObject.reopen({ - didDefineProperty: function (proto, key, value) { - if (hasCachedComputedProperties === false) { - return; + addToListeners: function (eventName, target, method, flags) { + if (!this._listeners) { + this._listeners = []; } - if (value instanceof _emberMetal.ComputedProperty) { - var cache = _emberMetal.meta(this.constructor).readableCache(); + this._listeners.push(eventName, target, method, flags); + }, - if (cache && cache._computedProperties !== undefined) { - cache._computedProperties = undefined; + _finalizeListeners: function () { + if (this._listenersFinalized) { + return; + } + if (!this._listeners) { + this._listeners = []; + } + var pointer = this.parent; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + this._listeners = this._listeners.concat(listeners); + } + if (pointer._listenersFinalized) { + break; } + pointer = pointer.parent; } - } - }); + this._listenersFinalized = true; + }, - exports.default = CoreObject; -}); -// Private, and only for didInitAttrs willRecieveAttrs + removeFromListeners: function (eventName, target, method, didRemove) { + var pointer = this; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = listeners.length - 4; index >= 0; index -= 4) { + if (listeners[index] === eventName && (!method || listeners[index + 1] === target && listeners[index + 2] === method)) { + if (pointer === this) { + // we are modifying our own list, so we edit directly + if (typeof didRemove === 'function') { + didRemove(eventName, target, listeners[index + 2]); + } + listeners.splice(index, 4); + } else { + // we are trying to remove an inherited listener, so we do + // just-in-time copying to detach our own listeners from + // our inheritance chain. + this._finalizeListeners(); + return this.removeFromListeners(eventName, target, method); + } + } + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + }, -/** - Defines the properties that will be concatenated from the superclass - (instead of overridden). - By default, when you extend an Ember class a property defined in - the subclass overrides a property with the same name that is defined - in the superclass. However, there are some cases where it is preferable - to build up a property's value by combining the superclass' property - value with the subclass' value. An example of this in use within Ember - is the `classNames` property of `Ember.View`. - Here is some sample code showing the difference between a concatenated - property and a normal one: - ```javascript - const Bar = Ember.Object.extend({ - // Configure which properties to concatenate - concatenatedProperties: ['concatenatedProperty'], - someNonConcatenatedProperty: ['bar'], - concatenatedProperty: ['bar'] - }); - const FooBar = Bar.extend({ - someNonConcatenatedProperty: ['foo'], - concatenatedProperty: ['foo'] - }); - let fooBar = FooBar.create(); - fooBar.get('someNonConcatenatedProperty'); // ['foo'] - fooBar.get('concatenatedProperty'); // ['bar', 'foo'] - ``` - This behavior extends to object creation as well. Continuing the - above example: - ```javascript - let fooBar = FooBar.create({ - someNonConcatenatedProperty: ['baz'], - concatenatedProperty: ['baz'] - }) - fooBar.get('someNonConcatenatedProperty'); // ['baz'] - fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] - ``` - Adding a single property that is not an array will just add it in the array: - ```javascript - let fooBar = FooBar.create({ - concatenatedProperty: 'baz' - }) - view.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] - ``` - Using the `concatenatedProperties` property, we can tell Ember to mix the - content of the properties. - In `Ember.Component` the `classNames`, `classNameBindings` and - `attributeBindings` properties are concatenated. - This feature is available for you to use throughout the Ember object model, - although typical app developers are likely to use it infrequently. Since - it changes expectations about behavior of properties, you should properly - document its usage in each individual concatenated property (to not - mislead your users to think they can override the property in a subclass). - @property concatenatedProperties - @type Array - @default null - @public -*/ + matchingListeners: function (eventName) { + var pointer = this; + var result = []; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = 0; index < listeners.length - 3; index += 4) { + if (listeners[index] === eventName) { + pushUniqueListener(result, listeners, index); + } + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + var sus = this._suspendedListeners; + if (sus) { + for (var susIndex = 0; susIndex < sus.length - 2; susIndex += 3) { + if (eventName === sus[susIndex]) { + for (var resultIndex = 0; resultIndex < result.length - 2; resultIndex += 3) { + if (result[resultIndex] === sus[susIndex + 1] && result[resultIndex + 1] === sus[susIndex + 2]) { + result[resultIndex + 2] |= SUSPENDED; + } + } + } + } + } + return result; + }, -/** - Defines the properties that will be merged from the superclass - (instead of overridden). - By default, when you extend an Ember class a property defined in - the subclass overrides a property with the same name that is defined - in the superclass. However, there are some cases where it is preferable - to build up a property's value by merging the superclass property value - with the subclass property's value. An example of this in use within Ember - is the `queryParams` property of routes. - Here is some sample code showing the difference between a merged - property and a normal one: - ```javascript - const Bar = Ember.Object.extend({ - // Configure which properties are to be merged - mergedProperties: ['mergedProperty'], - someNonMergedProperty: { - nonMerged: 'superclass value of nonMerged' + suspendListeners: function (eventNames, target, method, callback) { + var sus = this._suspendedListeners; + if (!sus) { + sus = this._suspendedListeners = []; + } + for (var i = 0; i < eventNames.length; i++) { + sus.push(eventNames[i], target, method); + } + try { + return callback.call(target); + } finally { + if (sus.length === eventNames.length) { + this._suspendedListeners = undefined; + } else { + for (var i = sus.length - 3; i >= 0; i -= 3) { + if (sus[i + 1] === target && sus[i + 2] === method && eventNames.indexOf(sus[i]) !== -1) { + sus.splice(i, 3); + } + } + } + } }, - mergedProperty: { - page: {replace: false}, - limit: {replace: true} - } - }); - const FooBar = Bar.extend({ - someNonMergedProperty: { - completelyNonMerged: 'subclass value of nonMerged' + + watchedEvents: function () { + var pointer = this; + var names = {}; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = 0; index < listeners.length - 3; index += 4) { + names[listeners[index]] = true; + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + return Object.keys(names); }, - mergedProperty: { - limit: {replace: false} + + _initializeListeners: function () { + this._listeners = undefined; + this._listenersFinalized = undefined; + this._suspendedListeners = undefined; } - }); - let fooBar = FooBar.create(); - fooBar.get('someNonMergedProperty'); - // => { completelyNonMerged: 'subclass value of nonMerged' } - // - // Note the entire object, including the nonMerged property of - // the superclass object, has been replaced - fooBar.get('mergedProperty'); - // => { - // page: {replace: false}, - // limit: {replace: false} - // } - // - // Note the page remains from the superclass, and the - // `limit` property's value of `false` has been merged from - // the subclass. - ``` - This behavior is not available during object `create` calls. It is only - available at `extend` time. - In `Ember.Route` the `queryParams` property is merged. - This feature is available for you to use throughout the Ember object model, - although typical app developers are likely to use it infrequently. Since - it changes expectations about behavior of properties, you should properly - document its usage in each individual merged property (to not - mislead your users to think they can override the property in a subclass). - @property mergedProperties - @type Array - @default null - @public -*/ + }; -/** - Destroyed object property flag. - if this property is `true` the observers and bindings were already - removed by the effect of calling the `destroy()` method. - @property isDestroyed - @default false - @public -*/ + exports.protoMethods = protoMethods; + function pushUniqueListener(destination, source, index) { + var target = source[index + 1]; + var method = source[index + 2]; + for (var destinationIndex = 0; destinationIndex < destination.length - 2; destinationIndex += 3) { + if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { + return; + } + } + destination.push(target, method, source[index + 3]); + } +}); +enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -/** - Destruction scheduled flag. The `destroy()` method has been called. - The object stays intact until the end of the run loop at which point - the `isDestroyed` flag is set. - @property isDestroying - @default false - @public -*/ + /** + @module ember + @submodule ember-metal + */ + exports.detectBinding = detectBinding; + exports.mixin = mixin; + exports.hasUnprocessedMixins = hasUnprocessedMixins; + exports.clearUnprocessedMixins = clearUnprocessedMixins; + exports.required = required; + exports.aliasMethod = aliasMethod; + exports.observer = observer; + exports._immediateObserver = _immediateObserver; + exports._beforeObserver = _beforeObserver; -/** - Destroys an object by setting the `isDestroyed` flag and removing its - metadata, which effectively destroys observers and bindings. - If you try to set a property on a destroyed object, an exception will be - raised. - Note that destruction is scheduled for the end of the run loop and does not - happen immediately. It will set an isDestroying flag immediately. - @method destroy - @return {Ember.Object} receiver - @public -*/ + function ROOT() {} + ROOT.__hasSuper = false; -/** - Override to implement teardown. - @method willDestroy - @public -*/ + var a_slice = Array.prototype.slice; + var a_concat = Array.prototype.concat; + var isArray = Array.isArray; -/** - Invoked by the run loop to actually destroy the object. This is - scheduled for execution by the `destroy` method. - @private - @method _scheduledDestroy -*/ + function isMethod(obj) { + return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; + } -/** - Returns a string representation which attempts to provide more information - than Javascript's `toString` typically does, in a generic way for all Ember - objects. - ```javascript - const Person = Ember.Object.extend() - person = Person.create() - person.toString() //=> "" - ``` - If the object's class is not defined on an Ember namespace, it will - indicate it is a subclass of the registered superclass: - ```javascript - const Student = Person.extend() - let student = Student.create() - student.toString() //=> "<(subclass of Person):ember1025>" - ``` - If the method `toStringExtension` is defined, its return value will be - included in the output. - ```javascript - const Teacher = Person.extend({ - toStringExtension() { - return this.get('fullName'); - } - }); - teacher = Teacher.create() - teacher.toString(); //=> "" - ``` - @method toString - @return {String} string representation - @public -*/ + var CONTINUE = {}; -/** - Creates a new subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(thing); - } - }); - ``` - This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. - You can also create a subclass from any existing class by calling its `extend()` method. - For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: - ```javascript - const PersonComponent = Ember.Component.extend({ - tagName: 'li', - classNameBindings: ['isAdministrator'] - }); - ``` - When defining a subclass, you can override methods but still access the - implementation of your parent class by calling the special `_super()` method: - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - var name = this.get('name'); - alert(`${name} says: ${thing}`); - } - }); - const Soldier = Person.extend({ - say(thing) { - this._super(`${thing}, sir!`); - }, - march(numberOfHours) { - alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + function mixinProperties(mixinsMeta, mixin) { + var guid = undefined; + + if (mixin instanceof Mixin) { + guid = _emberUtils.guidFor(mixin); + if (mixinsMeta.peekMixins(guid)) { + return CONTINUE; + } + mixinsMeta.writeMixins(guid, mixin); + return mixin.properties; + } else { + return mixin; // apply anonymous mixin properties } - }); - let yehuda = Soldier.create({ - name: "Yehuda Katz" - }); - yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" - ``` - The `create()` on line #17 creates an *instance* of the `Soldier` class. - The `extend()` on line #8 creates a *subclass* of `Person`. Any instance - of the `Person` class will *not* have the `march()` method. - You can also pass `Mixin` classes to add additional properties to the subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(`${this.get('name')} says: ${thing}`); + } + + function concatenatedMixinProperties(concatProp, props, values, base) { + // reset before adding each new mixin to pickup concats from previous + var concats = values[concatProp] || base[concatProp]; + if (props[concatProp]) { + concats = concats ? a_concat.call(concats, props[concatProp]) : props[concatProp]; } - }); - const SingingMixin = Mixin.create({ - sing(thing){ - alert(`${this.get('name')} sings: la la la ${thing}`); + return concats; + } + + function giveDescriptorSuper(meta, key, property, values, descs, base) { + var superProperty = undefined; + + // Computed properties override methods, and do not call super to them + if (values[key] === undefined) { + // Find the original descriptor in a parent mixin + superProperty = descs[key]; } - }); - const BroadwayStar = Person.extend(SingingMixin, { - dance() { - alert(`${this.get('name')} dances: tap tap tap tap `); + + // If we didn't find the original descriptor in a parent mixin, find + // it on the original object. + if (!superProperty) { + var possibleDesc = base[key]; + var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + superProperty = superDesc; } - }); - ``` - The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. - @method extend - @static - @param {Mixin} [mixins]* One or more Mixin classes - @param {Object} [arguments]* Object containing values to use within the new class - @public -*/ -/** - Creates an instance of a class. Accepts either no arguments, or an object - containing values to initialize the newly instantiated object with. - ```javascript - const Person = Ember.Object.extend({ - helloWorld() { - alert(`Hi, my name is ${this.get('name')}`); + if (superProperty === undefined || !(superProperty instanceof _emberMetalComputed.ComputedProperty)) { + return property; } - }); - let tom = Person.create({ - name: 'Tom Dale' - }); - tom.helloWorld(); // alerts "Hi, my name is Tom Dale". - ``` - `create` will call the `init` function if defined during - `Ember.AnyObject.extend` - If no arguments are passed to `create`, it will not set values to the new - instance during initialization: - ```javascript - let noName = Person.create(); - noName.helloWorld(); // alerts undefined - ``` - NOTE: For performance reasons, you cannot declare methods or computed - properties during `create`. You should instead declare methods and computed - properties when using `extend`. - @method create - @static - @param [arguments]* - @public -*/ -/** - Augments a constructor's prototype with additional - properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - o = MyObject.create(); - o.get('name'); // 'an object' - MyObject.reopen({ - say(msg){ - console.log(msg); + // Since multiple mixins may inherit from the same parent, we need + // to clone the computed property so that other mixins do not receive + // the wrapped version. + property = Object.create(property); + property._getter = _emberUtils.wrap(property._getter, superProperty._getter); + if (superProperty._setter) { + if (property._setter) { + property._setter = _emberUtils.wrap(property._setter, superProperty._setter); + } else { + property._setter = superProperty._setter; + } } - }) - o2 = MyObject.create(); - o2.say("hello"); // logs "hello" - o.say("goodbye"); // logs "goodbye" - ``` - To add functions and properties to the constructor itself, - see `reopenClass` - @method reopen - @public -*/ -/** - Augments a constructor's own properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - MyObject.reopenClass({ - canBuild: false - }); - MyObject.canBuild; // false - o = MyObject.create(); - ``` - In other words, this creates static properties and functions for the class. - These are only available on the class and not on any instance of that class. - ```javascript - const Person = Ember.Object.extend({ - name: "", - sayHello() { - alert("Hello. My name is " + this.get('name')); + return property; + } + + function giveMethodSuper(obj, key, method, values, descs) { + var superMethod = undefined; + + // Methods overwrite computed properties, and do not call super to them. + if (descs[key] === undefined) { + // Find the original method in a parent mixin + superMethod = values[key]; } - }); - Person.reopenClass({ - species: "Homo sapiens", - createPerson(newPersonsName){ - return Person.create({ - name:newPersonsName - }); + + // If we didn't find the original value in a parent mixin, find it in + // the original object + superMethod = superMethod || obj[key]; + + // Only wrap the new method if the original method was a function + if (superMethod === undefined || 'function' !== typeof superMethod) { + return method; } - }); - let tom = Person.create({ - name: "Tom Dale" - }); - let yehuda = Person.createPerson("Yehuda Katz"); - tom.sayHello(); // "Hello. My name is Tom Dale" - yehuda.sayHello(); // "Hello. My name is Yehuda Katz" - alert(Person.species); // "Homo sapiens" - ``` - Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` - variables. They are only valid on `Person`. - To add functions and properties to instances of - a constructor by extending the constructor's prototype - see `reopen` - @method reopenClass - @public -*/ -/** - 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: - ```javascript - person: Ember.computed(function() { - var personId = this.get('personId'); - return Person.create({ id: personId }); - }).meta({ type: Person }) - ``` - Once you've done this, you can retrieve the values saved to the computed - property from your class like this: - ```javascript - MyClass.metaForProperty('person'); - ``` - This will return the original hash that was passed to `meta()`. - @static - @method metaForProperty - @param key {String} property name - @private -*/ + return _emberUtils.wrap(method, superMethod); + } -/** - Iterate over each computed property for the class, passing its name - and any associated metadata (see `metaForProperty`) to the callback. - @static - @method eachComputedProperty - @param {Function} callback - @param {Object} binding - @private -*/ -enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { - 'use strict'; + function applyConcatenatedProperties(obj, key, value, values) { + var baseValue = values[key] || obj[key]; + var ret = undefined; - exports.default = EachProxy; + if (baseValue === null || baseValue === undefined) { + ret = _emberUtils.makeArray(value); + } else { + if (isArray(baseValue)) { + if (value === null || value === undefined) { + ret = baseValue; + } else { + ret = a_concat.call(baseValue, value); + } + } else { + ret = a_concat.call(_emberUtils.makeArray(baseValue), value); + } + } - /** - This is the object instance returned when you get the `@each` property on an - array. It uses the unknownProperty handler to automatically create - EachArray instances for property names. - @class EachProxy - @private - */ + _emberMetalDebug.runInDebug(function () { + // it is possible to use concatenatedProperties with strings (which cannot be frozen) + // only freeze objects... + if (typeof ret === 'object' && ret !== null) { + // prevent mutating `concatenatedProperties` array after it is applied + Object.freeze(ret); + } + }); - function EachProxy(content) { - this._content = content; - this._keys = undefined; - this.__ember_meta__ = null; + return ret; } - EachProxy.prototype = { - __defineNonEnumerable: function (property) { - this[property.name] = property.descriptor.value; - }, + function applyMergedProperties(obj, key, value, values) { + var baseValue = values[key] || obj[key]; + + _emberMetalDebug.runInDebug(function () { + if (isArray(value)) { + // use conditional to avoid stringifying every time + _emberMetalDebug.assert('You passed in `' + JSON.stringify(value) + '` as the value for `' + key + '` but `' + key + '` cannot be an Array', false); + } + }); + + if (!baseValue) { + return value; + } + + var newBase = _emberUtils.assign({}, baseValue); + var hasFunction = false; + + for (var prop in value) { + if (!value.hasOwnProperty(prop)) { + continue; + } + + var propValue = value[prop]; + if (isMethod(propValue)) { + // TODO: support for Computed Properties, etc? + hasFunction = true; + newBase[prop] = giveMethodSuper(obj, prop, propValue, baseValue, {}); + } else { + newBase[prop] = propValue; + } + } + + if (hasFunction) { + newBase._super = ROOT; + } + + return newBase; + } - // .......................................................... - // ARRAY CHANGES - // Invokes whenever the content array itself changes. + function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { + if (value instanceof _emberMetalProperties.Descriptor) { + if (value === REQUIRED && descs[key]) { + return CONTINUE; + } - arrayWillChange: function (content, idx, removedCnt, addedCnt) { - var keys = this._keys; - var lim = removedCnt > 0 ? idx + removedCnt : -1; - for (var key in keys) { - if (lim > 0) { - removeObserverForContentKey(content, key, this, idx, lim); - } - _emberMetal.propertyWillChange(this, key); + // Wrap descriptor function to implement + // _super() if needed + if (value._getter) { + value = giveDescriptorSuper(meta, key, value, values, descs, base); } - }, - arrayDidChange: function (content, idx, removedCnt, addedCnt) { - var keys = this._keys; - var lim = addedCnt > 0 ? idx + addedCnt : -1; - for (var key in keys) { - if (lim > 0) { - addObserverForContentKey(content, key, this, idx, lim); - } - _emberMetal.propertyDidChange(this, key); + descs[key] = value; + values[key] = undefined; + } else { + if (concats && concats.indexOf(key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') { + value = applyConcatenatedProperties(base, key, value, values); + } else if (mergings && mergings.indexOf(key) >= 0) { + value = applyMergedProperties(base, key, value, values); + } else if (isMethod(value)) { + value = giveMethodSuper(base, key, value, values, descs); } - }, - // .......................................................... - // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS - // Start monitoring keys based on who is listening... + descs[key] = undefined; + values[key] = value; + } + } - willWatchProperty: function (property) { - this.beginObservingContentKey(property); - }, + function mergeMixins(mixins, m, descs, values, base, keys) { + var currentMixin = undefined, + props = undefined, + key = undefined, + concats = undefined, + mergings = undefined; - didUnwatchProperty: function (property) { - this.stopObservingContentKey(property); - }, + function removeKeys(keyName) { + delete descs[keyName]; + delete values[keyName]; + } - // .......................................................... - // CONTENT KEY OBSERVING - // Actual watch keys on the source content. + for (var i = 0; i < mixins.length; i++) { + currentMixin = mixins[i]; + _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - beginObservingContentKey: function (keyName) { - var keys = this._keys; - if (!keys) { - keys = this._keys = new _emberUtils.EmptyObject(); + props = mixinProperties(m, currentMixin); + if (props === CONTINUE) { + continue; } - if (!keys[keyName]) { - keys[keyName] = 1; - var content = this._content; - var len = _emberMetal.get(content, 'length'); + if (props) { + if (base.willMergeMixin) { + base.willMergeMixin(props); + } + concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); + mergings = concatenatedMixinProperties('mergedProperties', props, values, base); - addObserverForContentKey(content, keyName, this, 0, len); - } else { - keys[keyName]++; + for (key in props) { + if (!props.hasOwnProperty(key)) { + continue; + } + keys.push(key); + addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings); + } + + // manually copy toString() because some JS engines do not enumerate it + if (props.hasOwnProperty('toString')) { + base.toString = props.toString; + } + } else if (currentMixin.mixins) { + mergeMixins(currentMixin.mixins, m, descs, values, base, keys); + if (currentMixin._without) { + currentMixin._without.forEach(removeKeys); + } } - }, + } + } - stopObservingContentKey: function (keyName) { - var keys = this._keys; - if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) { - var content = this._content; - var len = _emberMetal.get(content, 'length'); + function detectBinding(key) { + var length = key.length; - removeObserverForContentKey(content, keyName, this, 0, len); + return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; + } + + // warm both paths of above function + detectBinding('notbound'); + detectBinding('fooBinding'); + + function connectBindings(obj, m) { + // TODO Mixin.apply(instance) should disconnect binding if exists + m.forEachBindings(function (key, binding) { + if (binding) { + var to = key.slice(0, -7); // strip Binding off end + if (binding instanceof _emberMetalBinding.Binding) { + binding = binding.copy(); // copy prototypes' instance + binding.to(to); + } else { + // binding is string path + binding = new _emberMetalBinding.Binding(to, binding); + } + binding.connect(obj); + obj[key] = binding; } - }, + }); + // mark as applied + m.clearBindings(); + } - contentKeyWillChange: function (obj, keyName) { - _emberMetal.propertyWillChange(this, keyName); - }, + function finishPartial(obj, m) { + connectBindings(obj, m || _emberMetalMeta.meta(obj)); + return obj; + } - contentKeyDidChange: function (obj, keyName) { - _emberMetal.propertyDidChange(this, keyName); + function followAlias(obj, desc, m, descs, values) { + var altKey = desc.methodName; + var value = undefined; + var possibleDesc = undefined; + if (descs[altKey] || values[altKey]) { + value = values[altKey]; + desc = descs[altKey]; + } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { + desc = possibleDesc; + value = undefined; + } else { + desc = undefined; + value = obj[altKey]; } - }; - function addObserverForContentKey(content, keyName, proxy, idx, loc) { - while (--loc >= idx) { - var item = _emberRuntimeMixinsArray.objectAt(content, loc); - if (item) { - _emberMetal.assert('When using @each to observe the array ' + content + ', the array must return an object', typeof item === 'object'); - _emberMetal._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); - _emberMetal.addObserver(item, keyName, proxy, 'contentKeyDidChange'); + return { desc: desc, value: value }; + } + + function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { + var paths = observerOrListener[pathsKey]; + + if (paths) { + for (var i = 0; i < paths.length; i++) { + updateMethod(obj, paths[i], null, key); } } } - function removeObserverForContentKey(content, keyName, proxy, idx, loc) { - while (--loc >= idx) { - var item = _emberRuntimeMixinsArray.objectAt(content, loc); - if (item) { - _emberMetal._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); - _emberMetal.removeObserver(item, keyName, proxy, 'contentKeyDidChange'); - } + function replaceObserversAndListeners(obj, key, observerOrListener) { + var prev = obj[key]; + + if ('function' === typeof prev) { + updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _emberMetalObserver._removeBeforeObserver); + updateObserversAndListeners(obj, key, prev, '__ember_observes__', _emberMetalObserver.removeObserver); + updateObserversAndListeners(obj, key, prev, '__ember_listens__', _emberMetalEvents.removeListener); + } + + if ('function' === typeof observerOrListener) { + updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', _emberMetalObserver._addBeforeObserver); + updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', _emberMetalObserver.addObserver); + updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', _emberMetalEvents.addListener); } } -}); -enifed('ember-runtime/system/lazy_load', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - /*globals CustomEvent */ - 'use strict'; + function applyMixin(obj, mixins, partial) { + var descs = {}; + var values = {}; + var m = _emberMetalMeta.meta(obj); + var keys = []; + var key = undefined, + value = undefined, + desc = undefined; - exports.onLoad = onLoad; - exports.runLoadHooks = runLoadHooks; + obj._super = ROOT; - /** - @module ember - @submodule ember-runtime - */ + // Go through all mixins and hashes passed in, and: + // + // * Handle concatenated properties + // * Handle merged properties + // * Set up _super wrapping if necessary + // * Set up computed property descriptors + // * Copying `toString` in broken browsers + mergeMixins(mixins, m, descs, values, obj, keys); - var loadHooks = _emberEnvironment.ENV.EMBER_LOAD_HOOKS || {}; - var loaded = {}; - var _loaded = loaded; + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + if (key === 'constructor' || !values.hasOwnProperty(key)) { + continue; + } - exports._loaded = _loaded; - /** - Detects when a specific package of Ember (e.g. 'Ember.Application') - has fully loaded and is available for extension. - - The provided `callback` will be called with the `name` passed - resolved from a string into the object: - - ``` javascript - Ember.onLoad('Ember.Application' function(hbars) { - hbars.registerHelper(...); - }); - ``` - - @method onLoad - @for Ember - @param name {String} name of hook - @param callback {Function} callback to be called - @private - */ + desc = descs[key]; + value = values[key]; - function onLoad(name, callback) { - var object = loaded[name]; + if (desc === REQUIRED) { + continue; + } - loadHooks[name] = loadHooks[name] || []; - loadHooks[name].push(callback); + while (desc && desc instanceof Alias) { + var followed = followAlias(obj, desc, m, descs, values); + desc = followed.desc; + value = followed.value; + } - if (object) { - callback(object); - } - } + if (desc === undefined && value === undefined) { + continue; + } - /** - Called when an Ember.js package (e.g Ember.Application) has finished - loading. Triggers any callbacks registered for this event. - - @method runLoadHooks - @for Ember - @param name {String} name of hook - @param object {Object} object to pass to callbacks - @private - */ + replaceObserversAndListeners(obj, key, value); - function runLoadHooks(name, object) { - loaded[name] = object; - var window = _emberEnvironment.environment.window; + if (detectBinding(key)) { + m.writeBindings(key, value); + } - if (window && typeof CustomEvent === 'function') { - var _event = new CustomEvent(name, { detail: object, name: name }); - window.dispatchEvent(_event); + _emberMetalProperties.defineProperty(obj, key, desc, value, m); } - if (loadHooks[name]) { - loadHooks[name].forEach(function (callback) { - return callback(object); - }); + if (!partial) { + // don't apply to prototype + finishPartial(obj, m); } + + return obj; } -}); -enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-runtime/system/object'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberRuntimeSystemObject) { + /** - @module ember - @submodule ember-runtime + @method mixin + @for Ember + @param obj + @param mixins* + @return obj + @private */ - 'use strict'; - - exports.isSearchDisabled = isSearchDisabled; - exports.setSearchDisabled = setSearchDisabled; - var searchDisabled = false; - - function isSearchDisabled() { - return searchDisabled; - } + function mixin(obj) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - function setSearchDisabled(flag) { - searchDisabled = !!flag; + applyMixin(obj, args, false); + return obj; } /** - A Namespace is an object usually used to contain other objects or methods - such as an application or framework. Create a namespace anytime you want - to define one of these new containers. + The `Ember.Mixin` class allows you to create mixins, whose properties can be + added to other classes. For instance, - # Example Usage + ```javascript + const EditableMixin = Ember.Mixin.create({ + edit() { + console.log('starting to edit'); + this.set('isEditing', true); + }, + isEditing: false + }); + + // Mix mixins into classes by passing them as the first arguments to + // `.extend.` + const Comment = Ember.Object.extend(EditableMixin, { + post: null + }); + + let comment = Comment.create(post: somePost); + comment.edit(); // outputs 'starting to edit' + ``` + + Note that Mixins are created with `Ember.Mixin.create`, not + `Ember.Mixin.extend`. + + Note that mixins extend a constructor's prototype so arrays and object literals + defined as properties will be shared amongst objects that implement the mixin. + If you want to define a property in a mixin that is not shared, you can define + it either as a computed property or have it be created on initialization of the object. ```javascript - MyFramework = Ember.Namespace.create({ - VERSION: '1.0.0' + // filters array will be shared amongst any object implementing mixin + const FilterableMixin = Ember.Mixin.create({ + filters: Ember.A() + }); + + // filters will be a separate array for every object implementing the mixin + const FilterableMixin = Ember.Mixin.create({ + filters: Ember.computed(function() { + return Ember.A(); + }) + }); + + // filters will be created as a separate array during the object's initialization + const Filterable = Ember.Mixin.create({ + init() { + this._super(...arguments); + this.set("filters", Ember.A()); + } }); ``` - @class Namespace + @class Mixin @namespace Ember - @extends Ember.Object @public */ - var Namespace = _emberRuntimeSystemObject.default.extend({ - isNamespace: true, - - init: function () { - Namespace.NAMESPACES.push(this); - Namespace.PROCESSED = false; - }, - - toString: function () { - var name = _emberMetal.get(this, 'name') || _emberMetal.get(this, 'modulePrefix'); - if (name) { - return name; - } - - findNamespaces(); - return this[_emberUtils.NAME_KEY]; - }, - - nameClasses: function () { - processNamespace([this.toString()], this, {}); - }, - - destroy: function () { - var namespaces = Namespace.NAMESPACES; - var toString = this.toString(); - - if (toString) { - _emberEnvironment.context.lookup[toString] = undefined; - delete Namespace.NAMESPACES_BY_ID[toString]; - } - namespaces.splice(namespaces.indexOf(this), 1); - this._super.apply(this, arguments); - } - }); - - Namespace.reopenClass({ - NAMESPACES: [_emberMetal.default], - NAMESPACES_BY_ID: { - Ember: _emberMetal.default - }, - PROCESSED: false, - processAll: processAllNamespaces, - byName: function (name) { - if (!searchDisabled) { - processAllNamespaces(); - } - - return NAMESPACES_BY_ID[name]; - } - }); - - var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; - - var hasOwnProp = ({}).hasOwnProperty; - - function processNamespace(paths, root, seen) { - var idx = paths.length; - NAMESPACES_BY_ID[paths.join('.')] = root; + var Mixin = (function () { + function Mixin(args, properties) { + babelHelpers.classCallCheck(this, Mixin); - // Loop over all of the keys in the namespace, looking for classes - for (var key in root) { - if (!hasOwnProp.call(root, key)) { - continue; - } - var obj = root[key]; + this.properties = properties; - // If we are processing the `Ember` namespace, for example, the - // `paths` will start with `["Ember"]`. Every iteration through - // the loop will update the **second** element of this list with - // the key, so processing `Ember.View` will make the Array - // `['Ember', 'View']`. - paths[idx] = key; + var length = args && args.length; - // If we have found an unprocessed class - if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { - // Replace the class' `toString` with the dot-separated path - // and set its `NAME_KEY` - obj[_emberUtils.NAME_KEY] = paths.join('.'); + if (length > 0) { + var m = new Array(length); - // Support nested namespaces - } else if (obj && obj.isNamespace) { - // Skip aliased namespaces - if (seen[_emberUtils.guidFor(obj)]) { - continue; + for (var i = 0; i < length; i++) { + var x = args[i]; + if (x instanceof Mixin) { + m[i] = x; + } else { + m[i] = new Mixin(undefined, x); } - seen[_emberUtils.guidFor(obj)] = true; - - // Process the child namespace - processNamespace(paths, obj, seen); } - } - - paths.length = idx; // cut out last item - } - - function isUppercase(code) { - return code >= 65 && // A - code <= 90; // Z - } - - function tryIsNamespace(lookup, prop) { - try { - var obj = lookup[prop]; - return obj && obj.isNamespace && obj; - } catch (e) { - // continue - } - } - function findNamespaces() { - if (Namespace.PROCESSED) { - return; - } - var lookup = _emberEnvironment.context.lookup; - var keys = Object.keys(lookup); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - // Only process entities that start with uppercase A-Z - if (!isUppercase(key.charCodeAt(0))) { - continue; - } - var obj = tryIsNamespace(lookup, key); - if (obj) { - obj[_emberUtils.NAME_KEY] = key; + this.mixins = m; + } else { + this.mixins = undefined; } + this.ownerConstructor = undefined; + this._without = undefined; + this[_emberUtils.GUID_KEY] = null; + this[_emberUtils.NAME_KEY] = null; + _emberMetalDebug.debugSeal(this); } - } - function superClassString(mixin) { - var superclass = mixin.superclass; - if (superclass) { - if (superclass[_emberUtils.NAME_KEY]) { - return superclass[_emberUtils.NAME_KEY]; + Mixin.applyPartial = function applyPartial(obj) { + var args = a_slice.call(arguments, 1); + return applyMixin(obj, args, true); + }; + + /** + @method create + @static + @param arguments* + @public + */ + + Mixin.create = function create() { + // ES6TODO: this relies on a global state? + unprocessedFlag = true; + var M = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - return superClassString(superclass); - } - } - function calculateToString(target) { - var str = undefined; + return new M(args, undefined); + }; - if (!searchDisabled) { - processAllNamespaces(); - // can also be set by processAllNamespaces - str = target[_emberUtils.NAME_KEY]; - if (str) { - return str; - } else { - str = superClassString(target); - str = str ? '(subclass of ' + str + ')' : str; + // returns the mixins currently applied to the specified object + // TODO: Make Ember.mixin + + Mixin.mixins = function mixins(obj) { + var m = _emberMetalMeta.peekMeta(obj); + var ret = []; + if (!m) { + return ret; } - } - if (str) { - return str; - } else { - return '(unknown mixin)'; - } - } - function classToString() { - var name = this[_emberUtils.NAME_KEY]; - if (name) { - return name; - } + m.forEachMixins(function (key, currentMixin) { + // skip primitive mixins since these are always anonymous + if (!currentMixin.properties) { + ret.push(currentMixin); + } + }); - return this[_emberUtils.NAME_KEY] = calculateToString(this); - } + return ret; + }; - function processAllNamespaces() { - var unprocessedNamespaces = !Namespace.PROCESSED; - var unprocessedMixins = _emberMetal.hasUnprocessedMixins(); + return Mixin; + })(); - if (unprocessedNamespaces) { - findNamespaces(); - Namespace.PROCESSED = true; - } + exports.default = Mixin; - if (unprocessedNamespaces || unprocessedMixins) { - var namespaces = Namespace.NAMESPACES; - var namespace = undefined; + Mixin._apply = applyMixin; - for (var i = 0; i < namespaces.length; i++) { - namespace = namespaces[i]; - processNamespace([namespace.toString()], namespace, {}); - } + Mixin.finishPartial = finishPartial; - _emberMetal.clearUnprocessedMixins(); - } + var unprocessedFlag = false; + + function hasUnprocessedMixins() { + return unprocessedFlag; } - _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. + function clearUnprocessedMixins() { + unprocessedFlag = false; + } + + var MixinPrototype = Mixin.prototype; - exports.default = Namespace; -}); -// Preloaded into namespaces -enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) { /** - @module ember - @submodule ember-runtime + @method reopen + @param arguments* + @private */ - 'use strict'; + MixinPrototype.reopen = function () { + var currentMixin = undefined; - // Add Ember.Array to Array.prototype. Remove methods with native - // implementations and supply some more optimized versions of generic methods - // because they are so common. + if (this.properties) { + currentMixin = new Mixin(undefined, this.properties); + this.properties = undefined; + this.mixins = [currentMixin]; + } else if (!this.mixins) { + this.mixins = []; + } - /** - The NativeArray mixin contains the properties needed to make the native - Array support Ember.MutableArray and all of its dependent APIs. Unless you - have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to - false, this will be applied automatically. Otherwise you can apply the mixin - at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. - - @class NativeArray - @namespace Ember - @uses Ember.MutableArray - @uses Ember.Observable - @uses Ember.Copyable - @public - */ - var NativeArray = _emberMetal.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, { + var mixins = this.mixins; + var idx = undefined; - // because length is a built-in property we need to know to just get the - // original property. - get: function (key) { - if ('number' === typeof key) { - return this[key]; + for (idx = 0; idx < arguments.length; idx++) { + currentMixin = arguments[idx]; + _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); + + if (currentMixin instanceof Mixin) { + mixins.push(currentMixin); } else { - return this._super(key); + mixins.push(new Mixin(undefined, currentMixin)); } - }, - - objectAt: function (idx) { - return this[idx]; - }, + } - // primitive for array support. - replace: function (idx, amt, objects) { - if (this.isFrozen) { - throw _emberRuntimeMixinsFreezable.FROZEN_ERROR; - } + return this; + }; - // if we replaced exactly the same number of items, then pass only the - // replaced range. Otherwise, pass the full remaining array length - // since everything has shifted - var len = objects ? _emberMetal.get(objects, 'length') : 0; - _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, amt, len); + /** + @method apply + @param obj + @return applied object + @private + */ + MixinPrototype.apply = function (obj) { + return applyMixin(obj, [this], false); + }; - if (len === 0) { - this.splice(idx, amt); - } else { - _emberMetal.replace(this, idx, amt, objects); - } + MixinPrototype.applyPartial = function (obj) { + return applyMixin(obj, [this], true); + }; - _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, amt, len); - return this; - }, + MixinPrototype.toString = Object.toString; - // If you ask for an unknown property, then try to collect the value - // from member items. - unknownProperty: function (key, value) { - var ret = undefined; // = this.reducedProperty(key, value); - if (value !== undefined && ret === undefined) { - ret = this[key] = value; - } - return ret; - }, + function _detect(curMixin, targetMixin, seen) { + var guid = _emberUtils.guidFor(curMixin); - indexOf: Array.prototype.indexOf, - lastIndexOf: Array.prototype.lastIndexOf, + if (seen[guid]) { + return false; + } + seen[guid] = true; - copy: function (deep) { - if (deep) { - return this.map(function (item) { - return _emberRuntimeCopy.default(item, true); - }); + if (curMixin === targetMixin) { + return true; + } + var mixins = curMixin.mixins; + var loc = mixins ? mixins.length : 0; + while (--loc >= 0) { + if (_detect(mixins[loc], targetMixin, seen)) { + return true; } + } + return false; + } - return this.slice(); + /** + @method detect + @param obj + @return {Boolean} + @private + */ + MixinPrototype.detect = function (obj) { + if (typeof obj !== 'object' || obj === null) { + return false; } - }); + if (obj instanceof Mixin) { + return _detect(obj, this, {}); + } + var m = _emberMetalMeta.peekMeta(obj); + if (!m) { + return false; + } + return !!m.peekMixins(_emberUtils.guidFor(this)); + }; - // Remove any methods implemented natively so we don't override them - var ignore = ['length']; - NativeArray.keys().forEach(function (methodName) { - if (Array.prototype[methodName]) { - ignore.push(methodName); + MixinPrototype.without = function () { + var ret = new Mixin([this]); + + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; } - }); - exports.NativeArray // TODO: only use default export - = NativeArray = NativeArray.without.apply(NativeArray, ignore); + ret._without = args; + return ret; + }; - /** - Creates an `Ember.NativeArray` from an Array like object. - Does not modify the original object. Ember.A is not needed if - `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However, - it is recommended that you use Ember.A when creating addons for - ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES` - will be `true`. - - Example - - ```js - export default Ember.Component.extend({ - tagName: 'ul', - classNames: ['pagination'], - - init() { - this._super(...arguments); - - if (!this.get('content')) { - this.set('content', Ember.A()); - } - } - }); - ``` - - @method A - @for Ember - @return {Ember.NativeArray} - @public - */ - var A = undefined; + function _keys(ret, mixin, seen) { + if (seen[_emberUtils.guidFor(mixin)]) { + return; + } + seen[_emberUtils.guidFor(mixin)] = true; - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Array) { - NativeArray.apply(Array.prototype); - exports.A = A = function (arr) { - return arr || []; - }; - } else { - exports.A = A = function (arr) { - if (!arr) { - arr = []; + if (mixin.properties) { + var props = Object.keys(mixin.properties); + for (var i = 0; i < props.length; i++) { + var key = props[i]; + ret[key] = true; } - return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr); - }; + } else if (mixin.mixins) { + mixin.mixins.forEach(function (x) { + return _keys(ret, x, seen); + }); + } } - _emberMetal.default.A = A; - exports.A = A; - exports.NativeArray = NativeArray; - exports.default = NativeArray; -}); -// Ember.A circular -enifed('ember-runtime/system/object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberUtils, _emberMetal, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; + MixinPrototype.keys = function () { + var keys = {}; + var seen = {}; - /** - `Ember.Object` is the main base class for all Ember objects. It is a subclass - of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, - see the documentation for each of these. - - @class Object - @namespace Ember - @extends Ember.CoreObject - @uses Ember.Observable - @public - */ - var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default); - EmberObject.toString = function () { - return 'Ember.Object'; + _keys(keys, this, seen); + var ret = Object.keys(keys); + return ret; }; - var FrameworkObject = EmberObject; + _emberMetalDebug.debugSeal(MixinPrototype); - exports.FrameworkObject = FrameworkObject; - _emberMetal.runInDebug(function () { - var _EmberObject$extend; + var REQUIRED = new _emberMetalProperties.Descriptor(); + REQUIRED.toString = function () { + return '(Required Property)'; + }; - var INIT_WAS_CALLED = _emberUtils.symbol('INIT_WAS_CALLED'); - var ASSERT_INIT_WAS_CALLED = _emberUtils.symbol('ASSERT_INIT_WAS_CALLED'); + /** + Denotes a required property for a mixin + + @method required + @for Ember + @private + */ - exports.FrameworkObject = FrameworkObject = EmberObject.extend((_EmberObject$extend = { - init: function () { - this._super.apply(this, arguments); - this[INIT_WAS_CALLED] = true; - } + function required() { + _emberMetalDebug.deprecate('Ember.required is deprecated as its behavior is inconsistent and unreliable.', false, { id: 'ember-metal.required', until: '3.0.0' }); + return REQUIRED; + } - }, _EmberObject$extend[ASSERT_INIT_WAS_CALLED] = _emberMetal.on('init', function () { - _emberMetal.assert('You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update ' + this + ' to call `this._super(...arguments);` from `init`.', this[INIT_WAS_CALLED]); - }), _EmberObject$extend)); - }); + function Alias(methodName) { + this.isDescriptor = true; + this.methodName = methodName; + } - exports.default = EmberObject; -}); -enifed('ember-runtime/system/object_proxy', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/-proxy'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsProxy) { - 'use strict'; + Alias.prototype = new _emberMetalProperties.Descriptor(); /** - `Ember.ObjectProxy` forwards all properties not defined by the proxy itself - to a proxied `content` object. + Makes a method available via an additional name. ```javascript - object = Ember.Object.create({ - name: 'Foo' - }); - - proxy = Ember.ObjectProxy.create({ - content: object + App.Person = Ember.Object.extend({ + name: function() { + return 'Tomhuda Katzdale'; + }, + moniker: Ember.aliasMethod('name') }); - // Access and change existing properties - proxy.get('name') // 'Foo' - proxy.set('name', 'Bar'); - object.get('name') // 'Bar' - - // Create new 'description' property on `object` - proxy.set('description', 'Foo is a whizboo baz'); - object.get('description') // 'Foo is a whizboo baz' - ``` - - While `content` is unset, setting a property to be delegated will throw an - Error. + let goodGuy = App.Person.create(); - ```javascript - proxy = Ember.ObjectProxy.create({ - content: null, - flag: null - }); - proxy.set('flag', true); - proxy.get('flag'); // true - proxy.get('foo'); // undefined - proxy.set('foo', 'data'); // throws Error + goodGuy.name(); // 'Tomhuda Katzdale' + goodGuy.moniker(); // 'Tomhuda Katzdale' ``` - Delegated properties can be bound to and will change when content is updated. - - Computed properties on the proxy itself can depend on delegated properties. + @method aliasMethod + @for Ember + @param {String} methodName name of the method to alias + @public + */ + + function aliasMethod(methodName) { + return new Alias(methodName); + } + + // .......................................................... + // OBSERVER HELPER + // + + /** + Specify a method that observes property changes. ```javascript - ProxyWithComputedProperty = Ember.ObjectProxy.extend({ - fullName: Ember.computed('firstName', 'lastName', function() { - var firstName = this.get('firstName'), - lastName = this.get('lastName'); - if (firstName && lastName) { - return firstName + ' ' + lastName; - } - return firstName || lastName; + Ember.Object.extend({ + valueObserver: Ember.observer('value', function() { + // Executes whenever the "value" property changes }) }); - - proxy = ProxyWithComputedProperty.create(); - - proxy.get('fullName'); // undefined - proxy.set('content', { - firstName: 'Tom', lastName: 'Dale' - }); // triggers property change for fullName on proxy - - proxy.get('fullName'); // 'Tom Dale' ``` - @class ObjectProxy - @namespace Ember - @extends Ember.Object - @extends Ember._ProxyMixin + Also available as `Function.prototype.observes` if prototype extensions are + enabled. + + @method observer + @for Ember + @param {String} propertyNames* + @param {Function} func + @return func @public */ - exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsProxy.default); -}); -enifed('ember-runtime/system/service', ['exports', 'ember-runtime/system/object', 'ember-runtime/inject'], function (exports, _emberRuntimeSystemObject, _emberRuntimeInject) { - 'use strict'; + function observer() { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + var func = args.slice(-1)[0]; + var paths = undefined; + + var addWatchedProperty = function (path) { + paths.push(path); + }; + var _paths = args.slice(0, -1); + + if (typeof func !== 'function') { + // revert to old, soft-deprecated argument ordering + _emberMetalDebug.deprecate('Passing the dependentKeys after the callback function in Ember.observer is deprecated. Ensure the callback function is the last argument.', false, { id: 'ember-metal.observer-argument-order', until: '3.0.0' }); + + func = args[0]; + _paths = args.slice(1); + } + + paths = []; + + for (var i = 0; i < _paths.length; ++i) { + _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); + } + + if (typeof func !== 'function') { + throw new _emberMetalError.default('Ember.observer called without a function'); + } + + func.__ember_observes__ = paths; + return func; + } /** - Creates a property that lazily looks up a service in the container. There - are no restrictions as to what objects a service can be injected into. - - Example: + Specify a method that observes property changes. ```javascript - App.ApplicationRoute = Ember.Route.extend({ - authManager: Ember.inject.service('auth'), - - model: function() { - return this.get('authManager').findCurrentUser(); - } + Ember.Object.extend({ + valueObserver: Ember.immediateObserver('value', function() { + // Executes whenever the "value" property changes + }) }); ``` - This example will create an `authManager` property on the application route - that looks up the `auth` service in the container, making it easily - accessible in the `model` hook. + In the future, `Ember.observer` may become asynchronous. In this event, + `Ember.immediateObserver` will maintain the synchronous behavior. - @method service - @since 1.10.0 - @for Ember.inject - @param {String} name (optional) name of the service to inject, defaults to - the property's name - @return {Ember.InjectedProperty} injection descriptor instance - @public + Also available as `Function.prototype.observesImmediately` if prototype extensions are + enabled. + + @method _immediateObserver + @for Ember + @param {String} propertyNames* + @param {Function} func + @deprecated Use `Ember.observer` instead. + @return func + @private */ - _emberRuntimeInject.createInjectionHelper('service'); - /** - @class Service - @namespace Ember - @extends Ember.Object - @since 1.10.0 - @public - */ - var Service = _emberRuntimeSystemObject.default.extend(); + function _immediateObserver() { + _emberMetalDebug.deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.', false, { id: 'ember-metal.immediate-observer', until: '3.0.0' }); - Service.reopenClass({ - isServiceFactory: true - }); + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + _emberMetalDebug.assert('Immediate observers must observe internal properties only, not properties on other objects.', typeof arg !== 'string' || arg.indexOf('.') === -1); + } + + return observer.apply(this, arguments); + } - exports.default = Service; -}); -enifed('ember-runtime/system/string', ['exports', 'ember-metal', 'ember-utils', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberUtils, _emberRuntimeUtils, _emberRuntimeString_registry) { /** - @module ember - @submodule ember-runtime + When observers fire, they are called with the arguments `obj`, `keyName`. + + Note, `@each.property` observer is called per each add or replace of an element + and it's not called with a specific enumeration item. + + A `_beforeObserver` fires before a property changes. + + @method beforeObserver + @for Ember + @param {String} propertyNames* + @param {Function} func + @return func + @deprecated + @private */ - 'use strict'; - var STRING_DASHERIZE_REGEXP = /[ _]/g; + function _beforeObserver() { + for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; + } - var STRING_DASHERIZE_CACHE = new _emberMetal.Cache(1000, function (key) { - return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-'); - }); + var func = args.slice(-1)[0]; + var paths = undefined; - var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; - var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; + var addWatchedProperty = function (path) { + paths.push(path); + }; - var CAMELIZE_CACHE = new _emberMetal.Cache(1000, function (key) { - return key.replace(STRING_CAMELIZE_REGEXP_1, function (match, separator, chr) { - return chr ? chr.toUpperCase() : ''; - }).replace(STRING_CAMELIZE_REGEXP_2, function (match, separator, chr) { - return match.toLowerCase(); - }); - }); + var _paths = args.slice(0, -1); - var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; - var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; - var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; + if (typeof func !== 'function') { + // revert to old, soft-deprecated argument ordering - var CLASSIFY_CACHE = new _emberMetal.Cache(1000, function (str) { - var replace1 = function (match, separator, chr) { - return chr ? '_' + chr.toUpperCase() : ''; - }; - var replace2 = function (match, initialChar, separator, chr) { - return initialChar + (chr ? chr.toUpperCase() : ''); - }; - var parts = str.split('/'); - for (var i = 0; i < parts.length; i++) { - parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); + func = args[0]; + _paths = args.slice(1); } - return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, function (match, separator, chr) { - return match.toUpperCase(); - }); - }); - - var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; - var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; - var UNDERSCORE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase(); - }); + paths = []; - var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z])/g; + for (var i = 0; i < _paths.length; ++i) { + _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); + } - var CAPITALIZE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_CAPITALIZE_REGEXP, function (match, separator, chr) { - return match.toUpperCase(); - }); - }); + if (typeof func !== 'function') { + throw new _emberMetalError.default('_beforeObserver called without a function'); + } - var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; + func.__ember_observesBefore__ = paths; + return func; + } - var DECAMELIZE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase(); - }); + exports.Mixin = Mixin; + exports.REQUIRED = REQUIRED; +}); +enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { + 'use strict'; - function _fmt(str, formats) { - var cachedFormats = formats; + exports.addObserver = addObserver; + exports.observersFor = observersFor; + exports.removeObserver = removeObserver; + exports._addBeforeObserver = _addBeforeObserver; + exports._suspendObserver = _suspendObserver; + exports._suspendObservers = _suspendObservers; + exports._removeBeforeObserver = _removeBeforeObserver; - if (!_emberRuntimeUtils.isArray(cachedFormats) || arguments.length > 2) { - cachedFormats = new Array(arguments.length - 1); + /** + @module ember-metal + */ - for (var i = 1; i < arguments.length; i++) { - cachedFormats[i - 1] = arguments[i]; - } - } + var AFTER_OBSERVERS = ':change'; + var BEFORE_OBSERVERS = ':before'; - // first, replace any ORDERED replacements. - var idx = 0; // the current index for non-numerical replacements - return str.replace(/%@([0-9]+)?/g, function (s, argIndex) { - argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++; - s = cachedFormats[argIndex]; - return s === null ? '(null)' : s === undefined ? '' : _emberUtils.inspect(s); - }); + function changeEvent(keyName) { + return keyName + AFTER_OBSERVERS; } - function fmt(str, formats) { - _emberMetal.deprecate('Ember.String.fmt is deprecated, use ES6 template strings instead.', false, { id: 'ember-string-utils.fmt', until: '3.0.0', url: 'http://babeljs.io/docs/learn-es2015/#template-strings' }); - return _fmt.apply(undefined, arguments); + function beforeEvent(keyName) { + return keyName + BEFORE_OBSERVERS; } - function loc(str, formats) { - if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) { - formats = Array.prototype.slice.call(arguments, 1); - } + /** + @method addObserver + @for Ember + @param obj + @param {String} _path + @param {Object|Function} target + @param {Function|String} [method] + @public + */ - str = _emberRuntimeString_registry.get(str) || str; - return _fmt(str, formats); - } + function addObserver(obj, _path, target, method) { + _emberMetalEvents.addListener(obj, changeEvent(_path), target, method); + _emberMetalWatching.watch(obj, _path); - function w(str) { - return str.split(/\s+/); + return this; } - function decamelize(str) { - return DECAMELIZE_CACHE.get(str); + function observersFor(obj, path) { + return _emberMetalEvents.listenersFor(obj, changeEvent(path)); } - function dasherize(str) { - return STRING_DASHERIZE_CACHE.get(str); - } + /** + @method removeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @public + */ - function camelize(str) { - return CAMELIZE_CACHE.get(str); + function removeObserver(obj, path, target, method) { + _emberMetalWatching.unwatch(obj, path); + _emberMetalEvents.removeListener(obj, changeEvent(path), target, method); + + return this; } - function classify(str) { - return CLASSIFY_CACHE.get(str); + /** + @method _addBeforeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @deprecated + @private + */ + + function _addBeforeObserver(obj, path, target, method) { + _emberMetalEvents.addListener(obj, beforeEvent(path), target, method); + _emberMetalWatching.watch(obj, path); + + return this; } - function underscore(str) { - return UNDERSCORE_CACHE.get(str); + // Suspend observer during callback. + // + // This should only be used by the target of the observer + // while it is setting the observed path. + + function _suspendObserver(obj, path, target, method, callback) { + return _emberMetalEvents.suspendListener(obj, changeEvent(path), target, method, callback); } - function capitalize(str) { - return CAPITALIZE_CACHE.get(str); + function _suspendObservers(obj, paths, target, method, callback) { + var events = paths.map(changeEvent); + return _emberMetalEvents.suspendListeners(obj, events, target, method, callback); } /** - Defines string helper methods including string formatting and localization. - Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be - added to the `String.prototype` as well. - - @class String - @namespace Ember - @static - @public + @method removeBeforeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @deprecated + @private */ - exports.default = { - /** - Apply formatting options to the string. This will look for occurrences - of "%@" in your string and substitute them with the arguments you pass into - this method. If you want to control the specific order of replacement, - you can add a number after the key as well to indicate which argument - you want to insert. - Ordered insertions are most useful when building loc strings where values - you need to insert may appear in different orders. - ```javascript - "Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe" - "Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John" - ``` - @method fmt - @param {String} str The string to format - @param {Array} formats An array of parameters to interpolate into string. - @return {String} formatted string - @public - @deprecated Use ES6 template strings instead: http://babeljs.io/docs/learn-es2015/#template-strings - */ - fmt: fmt, - /** - Formats the passed string, but first looks up the string in the localized - strings hash. This is a convenient way to localize text. See - `Ember.String.fmt()` for more information on formatting. - Note that it is traditional but not required to prefix localized string - keys with an underscore or other character so you can easily identify - localized strings. - ```javascript - Ember.STRINGS = { - '_Hello World': 'Bonjour le monde', - '_Hello %@ %@': 'Bonjour %@ %@' - }; - Ember.String.loc("_Hello World"); // 'Bonjour le monde'; - Ember.String.loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; - ``` - @method loc - @param {String} str The string to format - @param {Array} formats Optional array of parameters to interpolate into string. - @return {String} formatted string - @public - */ - loc: loc, + function _removeBeforeObserver(obj, path, target, method) { + _emberMetalWatching.unwatch(obj, path); + _emberMetalEvents.removeListener(obj, beforeEvent(path), target, method); - /** - Splits a string into separate units separated by spaces, eliminating any - empty strings in the process. This is a convenience method for split that - is mostly useful when applied to the `String.prototype`. - ```javascript - Ember.String.w("alpha beta gamma").forEach(function(key) { - console.log(key); - }); - // > alpha - // > beta - // > gamma - ``` - @method w - @param {String} str The string to split - @return {Array} array containing the split strings - @public - */ - w: w, + return this; + } +}); +enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { + 'use strict'; - /** - Converts a camelized string into all lower case separated by underscores. - ```javascript - 'innerHTML'.decamelize(); // 'inner_html' - 'action_name'.decamelize(); // 'action_name' - 'css-class-name'.decamelize(); // 'css-class-name' - 'my favorite items'.decamelize(); // 'my favorite items' - ``` - @method decamelize - @param {String} str The string to decamelize. - @return {String} the decamelized string. - @public - */ - decamelize: decamelize, + /* + this.observerSet = { + [senderGuid]: { // variable name: `keySet` + [keyName]: listIndex + } + }, + this.observers = [ + { + sender: obj, + keyName: keyName, + eventName: eventName, + listeners: [ + [target, method, flags] + ] + }, + ... + ] + */ - /** - Replaces underscores, spaces, or camelCase with dashes. - ```javascript - 'innerHTML'.dasherize(); // 'inner-html' - 'action_name'.dasherize(); // 'action-name' - 'css-class-name'.dasherize(); // 'css-class-name' - 'my favorite items'.dasherize(); // 'my-favorite-items' - 'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice' - ``` - @method dasherize - @param {String} str The string to dasherize. - @return {String} the dasherized string. - @public - */ - dasherize: dasherize, + var ObserverSet = (function () { + function ObserverSet() { + babelHelpers.classCallCheck(this, ObserverSet); - /** - Returns the lowerCamelCase form of a string. - ```javascript - 'innerHTML'.camelize(); // 'innerHTML' - 'action_name'.camelize(); // 'actionName' - 'css-class-name'.camelize(); // 'cssClassName' - 'my favorite items'.camelize(); // 'myFavoriteItems' - 'My Favorite Items'.camelize(); // 'myFavoriteItems' - 'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice' - ``` - @method camelize - @param {String} str The string to camelize. - @return {String} the camelized string. - @public - */ - camelize: camelize, + this.clear(); + } - /** - Returns the UpperCamelCase form of a string. - ```javascript - 'innerHTML'.classify(); // 'InnerHTML' - 'action_name'.classify(); // 'ActionName' - 'css-class-name'.classify(); // 'CssClassName' - 'my favorite items'.classify(); // 'MyFavoriteItems' - 'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice' - ``` - @method classify - @param {String} str the string to classify - @return {String} the classified string - @public - */ - classify: classify, + ObserverSet.prototype.add = function add(sender, keyName, eventName) { + var observerSet = this.observerSet; + var observers = this.observers; + var senderGuid = _emberUtils.guidFor(sender); + var keySet = observerSet[senderGuid]; + var index = undefined; - /** - More general than decamelize. Returns the lower\_case\_and\_underscored - form of a string. - ```javascript - 'innerHTML'.underscore(); // 'inner_html' - 'action_name'.underscore(); // 'action_name' - 'css-class-name'.underscore(); // 'css_class_name' - 'my favorite items'.underscore(); // 'my_favorite_items' - 'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice' - ``` - @method underscore - @param {String} str The string to underscore. - @return {String} the underscored string. - @public - */ - underscore: underscore, + 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; + }; - /** - Returns the Capitalized form of a string - ```javascript - 'innerHTML'.capitalize() // 'InnerHTML' - 'action_name'.capitalize() // 'Action_name' - 'css-class-name'.capitalize() // 'Css-class-name' - 'my favorite items'.capitalize() // 'My favorite items' - 'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice' - ``` - @method capitalize - @param {String} str The string to capitalize. - @return {String} The capitalized string. - @public - */ - capitalize: capitalize + ObserverSet.prototype.flush = function flush() { + var observers = this.observers; + var i = undefined, + observer = undefined, + sender = undefined; + this.clear(); + for (i = 0; i < observers.length; ++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 clear() { + this.observerSet = {}; + this.observers = []; + }; + + return ObserverSet; + })(); + + exports.default = ObserverSet; +}); +enifed('ember-metal/path_cache', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) { + 'use strict'; + + exports.isGlobal = isGlobal; + exports.isGlobalPath = isGlobalPath; + exports.hasThis = hasThis; + exports.isPath = isPath; + exports.getFirstKey = getFirstKey; + exports.getTailPath = getTailPath; + + var IS_GLOBAL = /^[A-Z$]/; + var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; + var HAS_THIS = 'this.'; + + var isGlobalCache = new _emberMetalCache.default(1000, function (key) { + return IS_GLOBAL.test(key); + }); + var isGlobalPathCache = new _emberMetalCache.default(1000, function (key) { + return IS_GLOBAL_PATH.test(key); + }); + var hasThisCache = new _emberMetalCache.default(1000, function (key) { + return key.lastIndexOf(HAS_THIS, 0) === 0; + }); + var firstDotIndexCache = new _emberMetalCache.default(1000, function (key) { + return key.indexOf('.'); + }); + + var firstKeyCache = new _emberMetalCache.default(1000, function (path) { + var index = firstDotIndexCache.get(path); + if (index === -1) { + return path; + } else { + return path.slice(0, index); + } + }); + + var tailPathCache = new _emberMetalCache.default(1000, function (path) { + var index = firstDotIndexCache.get(path); + if (index !== -1) { + return path.slice(index + 1); + } + }); + + var caches = { + isGlobalCache: isGlobalCache, + isGlobalPathCache: isGlobalPathCache, + hasThisCache: hasThisCache, + firstDotIndexCache: firstDotIndexCache, + firstKeyCache: firstKeyCache, + tailPathCache: tailPathCache }; - exports.fmt = fmt; - exports.loc = loc; - exports.w = w; - exports.decamelize = decamelize; - exports.dasherize = dasherize; - exports.camelize = camelize; - exports.classify = classify; - exports.underscore = underscore; - exports.capitalize = capitalize; + + exports.caches = caches; + + function isGlobal(path) { + return isGlobalCache.get(path); + } + + function isGlobalPath(path) { + return isGlobalPathCache.get(path); + } + + function hasThis(path) { + return hasThisCache.get(path); + } + + function isPath(path) { + return firstDotIndexCache.get(path) !== -1; + } + + function getFirstKey(path) { + return firstKeyCache.get(path); + } + + function getTailPath(path) { + return tailPathCache.get(path); + } }); -enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemObject) { +enifed('ember-metal/properties', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/property_events'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperty_events) { + /** + @module ember-metal + */ + 'use strict'; - exports.isArray = isArray; - exports.typeOf = typeOf; + exports.Descriptor = Descriptor; + exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; + exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; + exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; + exports.defineProperty = defineProperty; - // ........................................ - // TYPING & ARRAY MESSAGING + // .......................................................... + // DESCRIPTOR // - var TYPE_MAP = { - '[object Boolean]': 'boolean', - '[object Number]': 'number', - '[object String]': 'string', - '[object Function]': 'function', - '[object Array]': 'array', - '[object Date]': 'date', - '[object RegExp]': 'regexp', - '[object Object]': 'object', - '[object FileList]': 'filelist' - }; - - var toString = Object.prototype.toString; /** - Returns true if the passed object is an array or Array-like. - - Objects are considered Array-like if any of the following are true: - - - the object is a native Array - - the object has an objectAt property - - the object is an Object, and has a length property - - Unlike `Ember.typeOf` this method returns true even if the passed object is - not formally an array but appears to be array-like (i.e. implements `Ember.Array`) - - ```javascript - Ember.isArray(); // false - Ember.isArray([]); // true - Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true - ``` + Objects of this type can implement an interface to respond to requests to + get and set. The default implementation handles simple properties. - @method isArray - @for Ember - @param {Object} obj The object to test - @return {Boolean} true if the passed object is an array or Array-like - @public + @class Descriptor + @private */ - function isArray(obj) { - if (!obj || obj.setInterval) { - return false; - } - if (Array.isArray(obj)) { - return true; - } - if (_emberRuntimeMixinsArray.default.detect(obj)) { - return true; - } + function Descriptor() { + this.isDescriptor = true; + } - var type = typeOf(obj); - if ('array' === type) { - return true; + var REDEFINE_SUPPORTED = (function () { + // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 + var a = Object.create(Object.prototype, { + prop: { + configurable: true, + value: 1 + } + }); + + Object.defineProperty(a, 'prop', { + configurable: true, + value: 2 + }); + + return a.prop === 2; + })(); + // .......................................................... + // DEFINING PROPERTIES API + // + + function MANDATORY_SETTER_FUNCTION(name) { + function SETTER_FUNCTION(value) { + var m = _emberMetalMeta.peekMeta(this); + if (!m.isInitialized(this)) { + m.writeValues(name, value); + } else { + _emberMetalDebug.assert('You must use Ember.set() to set the `' + name + '` property (of ' + this + ') to `' + value + '`.', false); + } } - if (obj.length !== undefined && 'object' === type) { - return true; + + SETTER_FUNCTION.isMandatorySetter = true; + return SETTER_FUNCTION; + } + + function DEFAULT_GETTER_FUNCTION(name) { + return function GETTER_FUNCTION() { + var meta = _emberMetalMeta.peekMeta(this); + return meta && meta.peekValues(name); + }; + } + + function INHERITING_GETTER_FUNCTION(name) { + function IGETTER_FUNCTION() { + var meta = _emberMetalMeta.peekMeta(this); + var val = meta && meta.readInheritedValue('values', name); + + if (val === _emberMetalMeta.UNDEFINED) { + var proto = Object.getPrototypeOf(this); + return proto && proto[name]; + } else { + return val; + } } - return false; + + IGETTER_FUNCTION.isInheritingGetter = true; + return IGETTER_FUNCTION; } /** - Returns a consistent type for the passed object. + NOTE: This is a low-level method used by other parts of the API. You almost + never want to call this method directly. Instead you should use + `Ember.mixin()` to define new properties. - Use this instead of the built-in `typeof` to get the type of an item. - It will return the same result across all browsers and includes a bit - more detail. Here is what will be returned: + Defines a property on an object. This method works much like the ES5 + `Object.defineProperty()` method except that it can also accept computed + properties and other special descriptors. - | Return Value | Meaning | - |---------------|------------------------------------------------------| - | 'string' | String primitive or String object. | - | 'number' | Number primitive or Number object. | - | 'boolean' | Boolean primitive or Boolean object. | - | 'null' | Null value | - | 'undefined' | Undefined value | - | 'function' | A function | - | 'array' | An instance of Array | - | 'regexp' | An instance of RegExp | - | 'date' | An instance of Date | - | 'filelist' | An instance of FileList | - | 'class' | An Ember class (created using Ember.Object.extend()) | - | 'instance' | An Ember object instance | - | 'error' | An instance of the Error object | - | 'object' | A JavaScript object not inheriting from Ember.Object | + Normally this method takes only three parameters. However if you pass an + instance of `Descriptor` as the third param then you can pass an + optional value as the fourth parameter. This is often more efficient than + creating new descriptor hashes for each property. - Examples: + ## Examples ```javascript - Ember.typeOf(); // 'undefined' - Ember.typeOf(null); // 'null' - Ember.typeOf(undefined); // 'undefined' - Ember.typeOf('michael'); // 'string' - Ember.typeOf(new String('michael')); // 'string' - Ember.typeOf(101); // 'number' - Ember.typeOf(new Number(101)); // 'number' - Ember.typeOf(true); // 'boolean' - Ember.typeOf(new Boolean(true)); // 'boolean' - Ember.typeOf(Ember.makeArray); // 'function' - Ember.typeOf([1, 2, 90]); // 'array' - Ember.typeOf(/abc/); // 'regexp' - Ember.typeOf(new Date()); // 'date' - Ember.typeOf(event.target.files); // 'filelist' - Ember.typeOf(Ember.Object.extend()); // 'class' - Ember.typeOf(Ember.Object.create()); // 'instance' - Ember.typeOf(new Error('teamocil')); // 'error' + // ES5 compatible mode + Ember.defineProperty(contact, 'firstName', { + writable: true, + configurable: false, + enumerable: true, + value: 'Charles' + }); - // 'normal' JavaScript object - Ember.typeOf({ a: 'b' }); // 'object' + // define a simple property + Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); + + // define a computed property + Ember.defineProperty(contact, 'fullName', Ember.computed('firstName', 'lastName', function() { + return this.firstName+' '+this.lastName; + })); ``` - @method typeOf + @private + @method defineProperty @for Ember - @param {Object} item the item to check - @return {String} the type - @public + @param {Object} obj the object to define this property on. This may be a prototype. + @param {String} keyName the name of the property + @param {Descriptor} [desc] an instance of `Descriptor` (typically a + computed property) or an ES5 descriptor. + You must provide this or `data` but not both. + @param {*} [data] something other than a descriptor, that will + become the explicit value of this property. */ - function typeOf(item) { - if (item === null) { - return 'null'; + function defineProperty(obj, keyName, desc, data, meta) { + var possibleDesc = undefined, + existingDesc = undefined, + watching = undefined, + value = undefined; + + if (!meta) { + meta = _emberMetalMeta.meta(obj); } - if (item === undefined) { - return 'undefined'; + var watchEntry = meta.peekWatching(keyName); + possibleDesc = obj[keyName]; + existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + watching = watchEntry !== undefined && watchEntry > 0; + + if (existingDesc) { + existingDesc.teardown(obj, keyName); } - var ret = TYPE_MAP[toString.call(item)] || 'object'; - if (ret === 'function') { - if (_emberRuntimeSystemObject.default.detect(item)) { - ret = 'class'; + if (desc instanceof Descriptor) { + value = desc; + if (true) { + if (watching) { + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable: true, + writable: true, + value: value + }); + } else { + obj[keyName] = value; + } + } else { + obj[keyName] = value; } - } else if (ret === 'object') { - if (item instanceof Error) { - ret = 'error'; - } else if (item instanceof _emberRuntimeSystemObject.default) { - ret = 'instance'; - } else if (item instanceof Date) { - ret = 'date'; + if (desc.setup) { + desc.setup(obj, keyName); } - } - - return ret; - } -}); -enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { - 'use strict'; + } else { + if (desc == null) { + value = data; - function K() { - return this; - } + if (true) { + if (watching) { + meta.writeValues(keyName, data); - /** - @module ember - @submodule ember-testing - */ + var defaultDescriptor = { + configurable: true, + enumerable: true, + set: MANDATORY_SETTER_FUNCTION(keyName), + get: DEFAULT_GETTER_FUNCTION(keyName) + }; - /** - The primary purpose of this class is to create hooks that can be implemented - by an adapter for various test frameworks. - - @class Adapter - @namespace Ember.Test - @public - */ - exports.default = _emberRuntime.Object.extend({ - /** - This callback will be called whenever an async operation is about to start. - Override this to call your framework's methods that handle async - operations. - @public - @method asyncStart - */ - asyncStart: K, + if (REDEFINE_SUPPORTED) { + Object.defineProperty(obj, keyName, defaultDescriptor); + } else { + handleBrokenPhantomDefineProperty(obj, keyName, defaultDescriptor); + } + } else { + obj[keyName] = data; + } + } else { + obj[keyName] = data; + } + } else { + value = desc; - /** - This callback will be called whenever an async operation has completed. - @public - @method asyncEnd - */ - asyncEnd: K, + // fallback to ES5 + Object.defineProperty(obj, keyName, desc); + } + } - /** - Override this method with your testing framework's false assertion. - This function is called whenever an exception occurs causing the testing - promise to fail. - QUnit example: - ```javascript - exception: function(error) { - ok(false, error); - }; - ``` - @public - @method exception - @param {String} error The exception to be raised. - */ - exception: function (error) { - throw error; + // if key is being watched, override chains that + // were initialized with the prototype + if (watching) { + _emberMetalProperty_events.overrideChains(obj, keyName, meta); } - }); -}); -enifed('ember-testing/adapters/qunit', ['exports', 'ember-utils', 'ember-testing/adapters/adapter'], function (exports, _emberUtils, _emberTestingAdaptersAdapter) { - 'use strict'; - /** - This class implements the methods defined by Ember.Test.Adapter for the - QUnit testing framework. - - @class QUnitAdapter - @namespace Ember.Test - @extends Ember.Test.Adapter - @public - */ - exports.default = _emberTestingAdaptersAdapter.default.extend({ - asyncStart: function () { - QUnit.stop(); - }, - asyncEnd: function () { - QUnit.start(); - }, - exception: function (error) { - ok(false, _emberUtils.inspect(error)); + // The `value` passed to the `didDefineProperty` hook is + // either the descriptor or data, whichever was passed. + if (obj.didDefineProperty) { + obj.didDefineProperty(obj, keyName, value); } - }); + + return this; + } + + function handleBrokenPhantomDefineProperty(obj, keyName, desc) { + // https://github.com/ariya/phantomjs/issues/11856 + Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); + Object.defineProperty(obj, keyName, desc); + } }); -enifed('ember-testing/events', ['exports', 'ember-views', 'ember-metal'], function (exports, _emberViews, _emberMetal) { +enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) { 'use strict'; - exports.focus = focus; - exports.fireEvent = fireEvent; - - var DEFAULT_EVENT_OPTIONS = { canBubble: true, cancelable: true }; - var KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup']; - var MOUSE_EVENT_TYPES = ['click', 'mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover']; + var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE'); - function focus(el) { - if (!el) { - return; - } - var $el = _emberViews.jQuery(el); - if ($el.is(':input, [contenteditable=true]')) { - var type = $el.prop('type'); - if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') { - _emberMetal.run(null, function () { - // Firefox does not trigger the `focusin` event if the window - // does not have focus. If the document doesn't have focus just - // use trigger('focusin') instead. + exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; + var beforeObserverSet = new _emberMetalObserver_set.default(); + var observerSet = new _emberMetalObserver_set.default(); + var deferred = 0; - if (!document.hasFocus || document.hasFocus()) { - el.focus(); - } else { - $el.trigger('focusin'); - } - }); - } - } - } + // .......................................................... + // PROPERTY CHANGES + // - function fireEvent(element, type) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + /** + This function is called just before an object property is about to change. + It will notify any before observers and prepare caches among other things. + + Normally you will not need to call this method directly but if for some + reason you can't directly watch a property you can invoke this method + manually along with `Ember.propertyDidChange()` which you should call just + after the property value changes. + + @method propertyWillChange + @for Ember + @param {Object} obj The object with the property that will change + @param {String} keyName The property key (or path) that will change. + @return {void} + @private + */ + function propertyWillChange(obj, keyName, _meta) { + var meta = _meta || _emberMetalMeta.peekMeta(obj); - if (!element) { + if (meta && !meta.isInitialized(obj)) { return; } - var event = undefined; - if (KEYBOARD_EVENT_TYPES.indexOf(type) > -1) { - event = buildKeyboardEvent(type, options); - } else if (MOUSE_EVENT_TYPES.indexOf(type) > -1) { - var rect = element.getBoundingClientRect(); - var x = rect.left + 1; - var y = rect.top + 1; - var simulatedCoordinates = { - screenX: x + 5, - screenY: y + 95, - clientX: x, - clientY: y - }; - event = buildMouseEvent(type, _emberViews.jQuery.extend(simulatedCoordinates, options)); - } else { - event = buildBasicEvent(type, options); - } - element.dispatchEvent(event); - } - - function buildBasicEvent(type) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - var event = document.createEvent('Events'); - event.initEvent(type, true, true); - _emberViews.jQuery.extend(event, options); - return event; - } - function buildMouseEvent(type) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var watching = meta && meta.peekWatching(keyName) > 0; + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - var event = undefined; - try { - event = document.createEvent('MouseEvents'); - var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); - event.initMouseEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.detail, eventOpts.screenX, eventOpts.screenY, eventOpts.clientX, eventOpts.clientY, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.button, eventOpts.relatedTarget); - } catch (e) { - event = buildBasicEvent(type, options); + if (desc && desc.willChange) { + desc.willChange(obj, keyName); + } + + if (watching) { + dependentKeysWillChange(obj, keyName, meta); + chainsWillChange(obj, keyName, meta); + notifyBeforeObservers(obj, keyName, meta); } - return event; } - function buildKeyboardEvent(type) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + /** + This function is called just after an object property has changed. + It will notify any observers and clear caches among other things. + + Normally you will not need to call this method directly but if for some + reason you can't directly watch a property you can invoke this method + manually along with `Ember.propertyWillChange()` which you should call just + before the property value changes. + + @method propertyDidChange + @for Ember + @param {Object} obj The object with the property that will change + @param {String} keyName The property key (or path) that will change. + @param {Meta} meta The objects meta. + @return {void} + @private + */ + function propertyDidChange(obj, keyName, _meta) { + var meta = _meta || _emberMetalMeta.peekMeta(obj); - var event = undefined; - try { - event = document.createEvent('KeyEvents'); - var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); - event.initKeyEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.keyCode, eventOpts.charCode); - } catch (e) { - event = buildBasicEvent(type, options); + if (meta && !meta.isInitialized(obj)) { + return; } - return event; - } -}); -enifed('ember-testing/ext/application', ['exports', 'ember-application', 'ember-testing/setup_for_testing', 'ember-testing/test/helpers', 'ember-testing/test/promise', 'ember-testing/test/run', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/adapter'], function (exports, _emberApplication, _emberTestingSetup_for_testing, _emberTestingTestHelpers, _emberTestingTestPromise, _emberTestingTestRun, _emberTestingTestOn_inject_helpers, _emberTestingTestAdapter) { - 'use strict'; - _emberApplication.Application.reopen({ - /** - This property contains the testing helpers for the current application. These - are created once you call `injectTestHelpers` on your `Ember.Application` - instance. The included helpers are also available on the `window` object by - default, but can be used from this object on the individual application also. - @property testHelpers - @type {Object} - @default {} - @public - */ - testHelpers: {}, + var watching = meta && meta.peekWatching(keyName) > 0; + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - /** - This property will contain the original methods that were registered - on the `helperContainer` before `injectTestHelpers` is called. - When `removeTestHelpers` is called, these methods are restored to the - `helperContainer`. - @property originalMethods - @type {Object} - @default {} - @private - @since 1.3.0 - */ - originalMethods: {}, + // shouldn't this mean that we're watching this key? + if (desc && desc.didChange) { + desc.didChange(obj, keyName); + } - /** - This property indicates whether or not this application is currently in - testing mode. This is set when `setupForTesting` is called on the current - application. - @property testing - @type {Boolean} - @default false - @since 1.3.0 - @public - */ - testing: false, + if (watching) { + if (meta.hasDeps(keyName)) { + dependentKeysDidChange(obj, keyName, meta); + } - /** - This hook defers the readiness of the application, so that you can start - the app when your tests are ready to run. It also sets the router's - location to 'none', so that the window's location will not be modified - (preventing both accidental leaking of state between tests and interference - with your testing framework). - Example: - ``` - App.setupForTesting(); - ``` - @method setupForTesting - @public - */ - setupForTesting: function () { - _emberTestingSetup_for_testing.default(); + chainsDidChange(obj, keyName, meta, false); + notifyObservers(obj, keyName, meta); + } - this.testing = true; + if (obj[PROPERTY_DID_CHANGE]) { + obj[PROPERTY_DID_CHANGE](keyName); + } - this.Router.reopen({ - location: 'none' - }); - }, + if (meta && meta.isSourceDestroying()) { + return; + } - /** - This will be used as the container to inject the test helpers into. By - default the helpers are injected into `window`. - @property helperContainer - @type {Object} The object to be used for test helpers. - @default window - @since 1.2.0 - @private - */ - helperContainer: null, + _emberMetalTags.markObjectAsDirty(meta, keyName); - /** - This injects the test helpers into the `helperContainer` object. If an object is provided - it will be used as the helperContainer. If `helperContainer` is not set it will default - to `window`. If a function of the same name has already been defined it will be cached - (so that it can be reset if the helper is removed with `unregisterHelper` or - `removeTestHelpers`). - Any callbacks registered with `onInjectHelpers` will be called once the - helpers have been injected. - Example: - ``` - App.injectTestHelpers(); - ``` - @method injectTestHelpers - @public - */ - injectTestHelpers: function (helperContainer) { - if (helperContainer) { - this.helperContainer = helperContainer; - } else { - this.helperContainer = window; - } + if (true || false) { + _emberMetalTransaction.assertNotRendered(obj, keyName, meta); + } + } - this.reopen({ - willDestroy: function () { - this._super.apply(this, arguments); - this.removeTestHelpers(); - } - }); + var WILL_SEEN = undefined, + DID_SEEN = undefined; + // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) + function dependentKeysWillChange(obj, depKey, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - this.testHelpers = {}; - for (var _name in _emberTestingTestHelpers.helpers) { - this.originalMethods[_name] = this.helperContainer[_name]; - this.testHelpers[_name] = this.helperContainer[_name] = helper(this, _name); - protoWrap(_emberTestingTestPromise.default.prototype, _name, helper(this, _name), _emberTestingTestHelpers.helpers[_name].meta.wait); + if (meta && meta.hasDeps(depKey)) { + var seen = WILL_SEEN; + var _top = !seen; + + if (_top) { + seen = WILL_SEEN = {}; } - _emberTestingTestOn_inject_helpers.invokeInjectHelpersCallbacks(this); - }, + iterDeps(propertyWillChange, obj, depKey, seen, meta); - /** - This removes all helpers that have been registered, and resets and functions - that were overridden by the helpers. - Example: - ```javascript - App.removeTestHelpers(); - ``` - @public - @method removeTestHelpers - */ - removeTestHelpers: function () { - if (!this.helperContainer) { - return; + if (_top) { + WILL_SEEN = null; } + } + } - for (var _name2 in _emberTestingTestHelpers.helpers) { - this.helperContainer[_name2] = this.originalMethods[_name2]; - delete _emberTestingTestPromise.default.prototype[_name2]; - delete this.testHelpers[_name2]; - delete this.originalMethods[_name2]; - } + // called whenever a property has just changed to update dependent keys + function dependentKeysDidChange(obj, depKey, meta) { + if (meta && meta.isSourceDestroying()) { + return; } - }); - // This method is no longer needed - // But still here for backwards compatibility - // of helper chaining - function protoWrap(proto, name, callback, isAsync) { - proto[name] = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + if (meta && meta.hasDeps(depKey)) { + var seen = DID_SEEN; + var _top2 = !seen; + + if (_top2) { + seen = DID_SEEN = {}; } - if (isAsync) { - return callback.apply(this, args); - } else { - return this.then(function () { - return callback.apply(this, args); - }); + iterDeps(propertyDidChange, obj, depKey, seen, meta); + + if (_top2) { + DID_SEEN = null; } - }; + } } - function helper(app, name) { - var fn = _emberTestingTestHelpers.helpers[name].method; - var meta = _emberTestingTestHelpers.helpers[name].meta; - if (!meta.wait) { - return function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + function iterDeps(method, obj, depKey, seen, meta) { + var possibleDesc = undefined, + desc = undefined; + var guid = _emberUtils.guidFor(obj); + var current = seen[guid]; - return fn.apply(app, [app].concat(args)); - }; + if (!current) { + current = seen[guid] = {}; } - return function () { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; + if (current[depKey]) { + return; + } + + current[depKey] = true; + + meta.forEachInDeps(depKey, function (key, value) { + if (!value) { + return; } - var lastPromise = _emberTestingTestRun.default(function () { - return _emberTestingTestPromise.resolve(_emberTestingTestPromise.getLastPromise()); - }); + possibleDesc = obj[key]; + desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - // wait for last helper's promise to resolve and then - // execute. To be safe, we need to tell the adapter we're going - // asynchronous here, because fn may not be invoked before we - // return. - _emberTestingTestAdapter.asyncStart(); - return lastPromise.then(function () { - return fn.apply(app, [app].concat(args)); - }).finally(_emberTestingTestAdapter.asyncEnd); - }; + if (desc && desc._suspended === obj) { + return; + } + + method(obj, key, meta); + }); } -}); -enifed('ember-testing/ext/rsvp', ['exports', 'ember-runtime', 'ember-metal', 'ember-testing/test/adapter'], function (exports, _emberRuntime, _emberMetal, _emberTestingTestAdapter) { - 'use strict'; - _emberRuntime.RSVP.configure('async', function (callback, promise) { - // if schedule will cause autorun, we need to inform adapter - if (_emberMetal.isTesting() && !_emberMetal.run.backburner.currentInstance) { - _emberTestingTestAdapter.asyncStart(); - _emberMetal.run.backburner.schedule('actions', function () { - _emberTestingTestAdapter.asyncEnd(); - callback(promise); - }); - } else { - _emberMetal.run.backburner.schedule('actions', function () { - return callback(promise); - }); + function chainsWillChange(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.notify(keyName, false, propertyWillChange); } - }); - - exports.default = _emberRuntime.RSVP; -}); -enifed('ember-testing/helpers', ['exports', 'ember-metal', 'ember-testing/test/helpers', 'ember-testing/helpers/and_then', 'ember-testing/helpers/click', 'ember-testing/helpers/current_path', 'ember-testing/helpers/current_route_name', 'ember-testing/helpers/current_url', 'ember-testing/helpers/fill_in', 'ember-testing/helpers/find', 'ember-testing/helpers/find_with_assert', 'ember-testing/helpers/key_event', 'ember-testing/helpers/pause_test', 'ember-testing/helpers/trigger_event', 'ember-testing/helpers/visit', 'ember-testing/helpers/wait'], function (exports, _emberMetal, _emberTestingTestHelpers, _emberTestingHelpersAnd_then, _emberTestingHelpersClick, _emberTestingHelpersCurrent_path, _emberTestingHelpersCurrent_route_name, _emberTestingHelpersCurrent_url, _emberTestingHelpersFill_in, _emberTestingHelpersFind, _emberTestingHelpersFind_with_assert, _emberTestingHelpersKey_event, _emberTestingHelpersPause_test, _emberTestingHelpersTrigger_event, _emberTestingHelpersVisit, _emberTestingHelpersWait) { - 'use strict'; - - _emberTestingTestHelpers.registerAsyncHelper('visit', _emberTestingHelpersVisit.default); - _emberTestingTestHelpers.registerAsyncHelper('click', _emberTestingHelpersClick.default); - _emberTestingTestHelpers.registerAsyncHelper('keyEvent', _emberTestingHelpersKey_event.default); - _emberTestingTestHelpers.registerAsyncHelper('fillIn', _emberTestingHelpersFill_in.default); - _emberTestingTestHelpers.registerAsyncHelper('wait', _emberTestingHelpersWait.default); - _emberTestingTestHelpers.registerAsyncHelper('andThen', _emberTestingHelpersAnd_then.default); - _emberTestingTestHelpers.registerAsyncHelper('pauseTest', _emberTestingHelpersPause_test.pauseTest); - _emberTestingTestHelpers.registerAsyncHelper('triggerEvent', _emberTestingHelpersTrigger_event.default); + } - _emberTestingTestHelpers.registerHelper('find', _emberTestingHelpersFind.default); - _emberTestingTestHelpers.registerHelper('findWithAssert', _emberTestingHelpersFind_with_assert.default); - _emberTestingTestHelpers.registerHelper('currentRouteName', _emberTestingHelpersCurrent_route_name.default); - _emberTestingTestHelpers.registerHelper('currentPath', _emberTestingHelpersCurrent_path.default); - _emberTestingTestHelpers.registerHelper('currentURL', _emberTestingHelpersCurrent_url.default); + function chainsDidChange(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.notify(keyName, true, propertyDidChange); + } + } - if (false) { - _emberTestingTestHelpers.registerHelper('resumeTest', _emberTestingHelpersPause_test.resumeTest); + function overrideChains(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidate(keyName); + } } -}); -enifed("ember-testing/helpers/and_then", ["exports"], function (exports) { + /** - @module ember - @submodule ember-testing + @method beginPropertyChanges + @chainable + @private */ - "use strict"; - - exports.default = andThen; - - function andThen(app, callback) { - return app.testHelpers.wait(callback(app)); + function beginPropertyChanges() { + deferred++; } -}); -enifed('ember-testing/helpers/click', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** - @module ember - @submodule ember-testing + @method endPropertyChanges + @private */ - 'use strict'; - - exports.default = click; + function endPropertyChanges() { + deferred--; + if (deferred <= 0) { + beforeObserverSet.clear(); + observerSet.flush(); + } + } /** - Clicks an element and triggers any actions triggered by the element's `click` - event. - - Example: + Make a series of property changes together in an + exception-safe way. ```javascript - click('.some-jQuery-selector').then(function() { - // assert something + Ember.changeProperties(function() { + obj1.set('foo', mayBlowUpWhenSet); + obj2.set('bar', baz); }); ``` - @method click - @param {String} selector jQuery selector for finding element on the DOM - @param {Object} context A DOM Element, Document, or jQuery to use as context - @return {RSVP.Promise} - @public - */ - - function click(app, selector, context) { - var $el = app.testHelpers.findWithAssert(selector, context); - var el = $el[0]; - - _emberTestingEvents.fireEvent(el, 'mousedown'); - - _emberTestingEvents.focus(el); - - _emberTestingEvents.fireEvent(el, 'mouseup'); - _emberTestingEvents.fireEvent(el, 'click'); - - return app.testHelpers.wait(); - } -}); -enifed('ember-testing/helpers/current_path', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - - exports.default = currentPath; - - /** - Returns the current path. - - Example: - - ```javascript - function validateURL() { - equal(currentPath(), 'some.path.index', "correct path was transitioned into."); - } - - click('#some-link-id').then(validateURL); - ``` - - @method currentPath - @return {Object} The currently active path. - @since 1.5.0 - @public + @method changeProperties + @param {Function} callback + @param [binding] + @private */ - - function currentPath(app) { - var routingService = app.__container__.lookup('service:-routing'); - return _emberMetal.get(routingService, 'currentPath'); + function changeProperties(callback, binding) { + beginPropertyChanges(); + try { + callback.call(binding); + } finally { + endPropertyChanges.call(binding); + } } -}); -enifed('ember-testing/helpers/current_route_name', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.default = currentRouteName; - - /** - Returns the currently active route name. - Example: - ```javascript - function validateRouteName() { - equal(currentRouteName(), 'some.path', "correct route was transitioned into."); - } - visit('/some/path').then(validateRouteName) - ``` - @method currentRouteName - @return {Object} The name of the currently active route. - @since 1.5.0 - @public - */ + function notifyBeforeObservers(obj, keyName, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - function currentRouteName(app) { - var routingService = app.__container__.lookup('service:-routing'); - return _emberMetal.get(routingService, 'currentRouteName'); + var eventName = keyName + ':before'; + var listeners = undefined, + added = undefined; + if (deferred) { + listeners = beforeObserverSet.add(obj, keyName, eventName); + added = _emberMetalEvents.accumulateListeners(obj, eventName, listeners); + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName], added); + } else { + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); + } } -}); -enifed('ember-testing/helpers/current_url', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.default = currentURL; - - /** - Returns the current URL. - - Example: - - ```javascript - function validateURL() { - equal(currentURL(), '/some/path', "correct URL was transitioned into."); - } - - click('#some-link-id').then(validateURL); - ``` - - @method currentURL - @return {Object} The currently active URL. - @since 1.5.0 - @public - */ + function notifyObservers(obj, keyName, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - function currentURL(app) { - var router = app.__container__.lookup('router:main'); - return _emberMetal.get(router, 'location').getURL(); + var eventName = keyName + ':change'; + var listeners = undefined; + if (deferred) { + listeners = observerSet.add(obj, keyName, eventName); + _emberMetalEvents.accumulateListeners(obj, eventName, listeners); + } else { + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); + } } + + exports.propertyWillChange = propertyWillChange; + exports.propertyDidChange = propertyDidChange; + exports.overrideChains = overrideChains; + exports.beginPropertyChanges = beginPropertyChanges; + exports.endPropertyChanges = endPropertyChanges; + exports.changeProperties = changeProperties; }); -enifed('ember-testing/helpers/fill_in', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { +enifed('ember-metal/property_get', ['exports', 'ember-metal/debug', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalPath_cache) { /** - @module ember - @submodule ember-testing + @module ember-metal */ + 'use strict'; - exports.default = fillIn; + exports.get = get; + exports._getPath = _getPath; + exports.getWithDefault = getWithDefault; + + var ALLOWABLE_TYPES = { + object: true, + function: true, + string: true + }; + + // .......................................................... + // GET AND SET + // + // If we are on a platform that supports accessors we can use those. + // Otherwise simulate accessors by looking up the property directly on the + // object. /** - Fills in an input element with some text. - - Example: + Gets the value of a property on an object. If the property is computed, + the function will be invoked. If the property is not defined but the + object implements the `unknownProperty` method then that will be invoked. ```javascript - fillIn('#email', 'you@example.com').then(function() { - // assert something - }); + Ember.get(obj, "name"); ``` - @method fillIn - @param {String} selector jQuery selector finding an input element on the DOM - to fill text with - @param {String} text text to place inside the input element - @return {RSVP.Promise} + If you plan to run on IE8 and older browsers then you should use this + method anytime you want to retrieve a property on an object that you don't + know for sure is private. (Properties beginning with an underscore '_' + are considered private.) + + On all newer browsers, you only need to use this method to retrieve + properties if the property might not be defined on the object and you want + to respect the `unknownProperty` handler. Otherwise you can ignore this + method. + + Note that if the object itself is `undefined`, this method will throw + an error. + + @method get + @for Ember + @param {Object} obj The object to retrieve from. + @param {String} keyName The property key to retrieve + @return {Object} the property value or `null`. @public */ - function fillIn(app, selector, contextOrText, text) { - var $el = undefined, - el = undefined, - context = undefined; - if (typeof text === 'undefined') { - text = contextOrText; + function get(obj, keyName) { + _emberMetalDebug.assert('Get must be called with two arguments; an object and a property key', arguments.length === 2); + _emberMetalDebug.assert('Cannot call get with \'' + keyName + '\' on an undefined object.', obj !== undefined && obj !== null); + _emberMetalDebug.assert('The key provided to get must be a string, you passed ' + keyName, typeof keyName === 'string'); + _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); + _emberMetalDebug.assert('Cannot call `Ember.get` with an empty string', keyName !== ''); + + var value = obj[keyName]; + var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined; + var ret = undefined; + + if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) { + return _getPath(obj, keyName); + } + + if (desc) { + return desc.get(obj, keyName); } else { - context = contextOrText; + ret = value; + + if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { + return obj.unknownProperty(keyName); + } + + return ret; } - $el = app.testHelpers.findWithAssert(selector, context); - el = $el[0]; - _emberTestingEvents.focus(el); + } - $el.eq(0).val(text); - _emberTestingEvents.fireEvent(el, 'input'); - _emberTestingEvents.fireEvent(el, 'change'); + function _getPath(root, path) { + var obj = root; + var parts = path.split('.'); - return app.testHelpers.wait(); + for (var i = 0; i < parts.length; i++) { + if (!isGettable(obj)) { + return undefined; + } + + obj = get(obj, parts[i]); + + if (obj && obj.isDestroyed) { + return undefined; + } + } + + return obj; } -}); -enifed('ember-testing/helpers/find', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.default = find; + function isGettable(obj) { + if (obj == null) { + return false; + } + + return ALLOWABLE_TYPES[typeof obj]; + } /** - Finds an element in the context of the app's container element. A simple alias - for `app.$(selector)`. - - Example: - - ```javascript - var $el = find('.my-selector'); - ``` - - With the `context` param: + Retrieves the value of a property from an Object, or a default value in the + case that the property returns `undefined`. ```javascript - var $el = find('.my-selector', '.parent-element-class'); + Ember.getWithDefault(person, 'lastName', 'Doe'); ``` - @method find - @param {String} selector jQuery string selector for element lookup - @param {String} [context] (optional) jQuery selector that will limit the selector - argument to find only within the context's children - @return {Object} jQuery object representing the results of the query + @method getWithDefault + @for Ember + @param {Object} obj The object to retrieve from. + @param {String} keyName The name of the property to retrieve + @param {Object} defaultValue The value to return if the property value is undefined + @return {Object} The property value or the defaultValue. @public */ - function find(app, selector, context) { - var $el = undefined; - context = context || _emberMetal.get(app, 'rootElement'); - $el = app.$(selector, context); - return $el; + function getWithDefault(root, key, defaultValue) { + var value = get(root, key); + + if (value === undefined) { + return defaultValue; + } + return value; } + + exports.default = get; }); -enifed('ember-testing/helpers/find_with_assert', ['exports'], function (exports) { - /** - @module ember - @submodule ember-testing - */ +enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) { + 'use strict'; + + exports.set = set; + exports.trySet = trySet; + /** - Like `find`, but throws an error if the element selector returns no results. - - Example: - - ```javascript - var $el = findWithAssert('.doesnt-exist'); // throws error - ``` - - With the `context` param: + Sets the value of a property on an object, respecting computed properties + and notifying observers and other listeners of the change. If the + property is not defined but the object implements the `setUnknownProperty` + method then that will be invoked as well. ```javascript - var $el = findWithAssert('.selector-id', '.parent-element-class'); // assert will pass + Ember.set(obj, "name", value); ``` - @method findWithAssert - @param {String} selector jQuery selector string for finding an element within - the DOM - @param {String} [context] (optional) jQuery selector that will limit the - selector argument to find only within the context's children - @return {Object} jQuery object representing the results of the query - @throws {Error} throws error if jQuery object returned has a length of 0 + @method set + @for Ember + @param {Object} obj The object to modify. + @param {String} keyName The property key to set + @param {Object} value The value to set + @return {Object} the passed value. @public */ - 'use strict'; - exports.default = findWithAssert; + function set(obj, keyName, value, tolerant) { + _emberMetalDebug.assert('Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false', arguments.length === 3 || arguments.length === 4); + _emberMetalDebug.assert('Cannot call set with \'' + keyName + '\' on an undefined object.', obj && typeof obj === 'object' || typeof obj === 'function'); + _emberMetalDebug.assert('The key provided to set must be a string, you passed ' + keyName, typeof keyName === 'string'); + _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); + _emberMetalDebug.assert('calling set on destroyed object: ' + _emberUtils.toString(obj) + '.' + keyName + ' = ' + _emberUtils.toString(value), !obj.isDestroyed); - function findWithAssert(app, selector, context) { - var $el = app.testHelpers.find(selector, context); - if ($el.length === 0) { - throw new Error('Element ' + selector + ' not found.'); + if (_emberMetalPath_cache.isPath(keyName)) { + return setPath(obj, keyName, value, tolerant); } - return $el; - } -}); -enifed('ember-testing/helpers/key_event', ['exports'], function (exports) { - /** - @module ember - @submodule ember-testing - */ - /** - Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode - Example: - ```javascript - keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() { - // assert something - }); - ``` - @method keyEvent - @param {String} selector jQuery selector for finding element on the DOM - @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup` - @param {Number} keyCode the keyCode of the simulated key event - @return {RSVP.Promise} - @since 1.5.0 - @public - */ - 'use strict'; - exports.default = keyEvent; + var meta = _emberMetalMeta.peekMeta(obj); + var possibleDesc = obj[keyName]; - function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { - var context = undefined, - type = undefined; + var desc = undefined, + currentValue = undefined; + if (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { + desc = possibleDesc; + } else { + currentValue = possibleDesc; + } - if (typeof keyCode === 'undefined') { - context = null; - keyCode = typeOrKeyCode; - type = contextOrType; + if (desc) { + /* computed property */ + desc.set(obj, keyName, value); + } else if (obj.setUnknownProperty && currentValue === undefined && !(keyName in obj)) { + /* unknown property */ + _emberMetalDebug.assert('setUnknownProperty must be a function', typeof obj.setUnknownProperty === 'function'); + obj.setUnknownProperty(keyName, value); + } else if (currentValue === value) { + /* no change */ + return value; } else { - context = contextOrType; - type = typeOrKeyCode; + _emberMetalProperty_events.propertyWillChange(obj, keyName); + + if (true) { + setWithMandatorySetter(meta, obj, keyName, value); + } else { + obj[keyName] = value; + } + + _emberMetalProperty_events.propertyDidChange(obj, keyName); } - return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode }); + return value; } -}); -enifed('ember-testing/helpers/pause_test', ['exports', 'ember-runtime', 'ember-console', 'ember-metal'], function (exports, _emberRuntime, _emberConsole, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.resumeTest = resumeTest; - exports.pauseTest = pauseTest; - - var resume = undefined; + if (true) { + var setWithMandatorySetter = function (meta, obj, keyName, value) { + if (meta && meta.peekWatching(keyName) > 0) { + makeEnumerable(obj, keyName); + meta.writeValue(obj, keyName, value); + } else { + obj[keyName] = value; + } + }; - /** - Resumes a test paused by `pauseTest`. - - @method resumeTest - @return {void} - @public - */ + var makeEnumerable = function (obj, key) { + var desc = Object.getOwnPropertyDescriptor(obj, key); - function resumeTest() { - _emberMetal.assert('Testing has not been paused. There is nothing to resume.', resume); - resume(); - resume = undefined; + if (desc && desc.set && desc.set.isMandatorySetter) { + desc.enumerable = true; + Object.defineProperty(obj, key, desc); + } + }; } - /** - Pauses the current test - this is useful for debugging while testing or for test-driving. - It allows you to inspect the state of your application at any point. - Example (The test will pause before clicking the button): - - ```javascript - visit('/') - return pauseTest(); - click('.btn'); - ``` - @since 1.9.0 - @method pauseTest - @return {Object} A promise that will never resolve - @public - */ + function setPath(root, path, value, tolerant) { + // get the last part of the path + var keyName = path.slice(path.lastIndexOf('.') + 1); - function pauseTest() { - if (false) { - _emberConsole.default.info('Testing paused. Use `resumeTest()` to continue.'); + // get the first part of the part + path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); + + // unless the path is this, look up the first part to + // get the root + if (path !== 'this') { + root = _emberMetalProperty_get._getPath(root, path); } - return new _emberRuntime.RSVP.Promise(function (resolve) { - if (false) { - resume = resolve; + if (!keyName || keyName.length === 0) { + throw new _emberMetalError.default('Property set failed: You passed an empty path'); + } + + if (!root) { + if (tolerant) { + return; + } else { + throw new _emberMetalError.default('Property set failed: object in path "' + path + '" could not be found or was destroyed.'); } - }, 'TestAdapter paused promise'); + } + + return set(root, keyName, value); } -}); -enifed('ember-testing/helpers/trigger_event', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** - @module ember - @submodule ember-testing + Error-tolerant form of `Ember.set`. Will not blow up if any part of the + chain is `undefined`, `null`, or destroyed. + + This is primarily used when syncing bindings, which may try to update after + an object has been destroyed. + + @method trySet + @for Ember + @param {Object} root The object to modify. + @param {String} path The property path to set + @param {Object} value The value to set + @public */ - 'use strict'; - exports.default = triggerEvent; + function trySet(root, path, value) { + return set(root, path, value, true); + } +}); +enifed("ember-metal/replace", ["exports"], function (exports) { + "use strict"; - /** - Triggers the given DOM event on the element identified by the provided selector. - Example: - ```javascript - triggerEvent('#some-elem-id', 'blur'); - ``` - This is actually used internally by the `keyEvent` helper like so: - ```javascript - triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 }); - ``` - @method triggerEvent - @param {String} selector jQuery selector for finding element on the DOM - @param {String} [context] jQuery selector that will limit the selector - argument to find only within the context's children - @param {String} type The event type to be triggered. - @param {Object} [options] The options to be passed to jQuery.Event. - @return {RSVP.Promise} - @since 1.5.0 - @public - */ + exports.default = replace; + var splice = Array.prototype.splice; - function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { - var arity = arguments.length; - var context = undefined, - type = undefined, - options = undefined; + function replace(array, idx, amt, objects) { + var args = [].concat(objects); + var ret = []; + // https://code.google.com/p/chromium/issues/detail?id=56588 + var size = 60000; + var start = idx; + var ends = amt; + var count = undefined, + chunk = undefined; - if (arity === 3) { - // context and options are optional, so this is - // app, selector, type - context = null; - type = contextOrType; - options = {}; - } else if (arity === 4) { - // context and options are optional, so this is - if (typeof typeOrOptions === 'object') { - // either - // app, selector, type, options - context = null; - type = contextOrType; - options = typeOrOptions; - } else { - // or - // app, selector, context, type - context = contextOrType; - type = typeOrOptions; - options = {}; + while (args.length) { + count = ends > size ? size : ends; + if (count <= 0) { + count = 0; } - } else { - context = contextOrType; - type = typeOrOptions; - options = possibleOptions; - } - var $el = app.testHelpers.findWithAssert(selector, context); - var el = $el[0]; + chunk = args.splice(0, size); + chunk = [start, count].concat(chunk); - _emberTestingEvents.fireEvent(el, type, options); + start += size; + ends -= count; - return app.testHelpers.wait(); + ret = ret.concat(splice.apply(array, chunk)); + } + return ret; } }); -enifed('ember-testing/helpers/visit', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ +enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) { 'use strict'; - exports.default = visit; + exports.default = run; + + function onBegin(current) { + run.currentRunLoop = current; + } + + function onEnd(current, next) { + run.currentRunLoop = next; + } + + var onErrorTarget = { + get onerror() { + return _emberMetalError_handler.getOnerror(); + }, + set onerror(handler) { + return _emberMetalError_handler.setOnerror(handler); + } + }; + + var backburner = new _backburner.default(['sync', 'actions', 'destroy'], { + GUID_KEY: _emberUtils.GUID_KEY, + sync: { + before: _emberMetalProperty_events.beginPropertyChanges, + after: _emberMetalProperty_events.endPropertyChanges + }, + defaultQueue: 'actions', + onBegin: onBegin, + onEnd: onEnd, + onErrorTarget: onErrorTarget, + onErrorMethod: 'onerror' + }); + + // .......................................................... + // run - this is ideally the only public API the dev sees + // /** - Loads a route, sets up any controllers, and renders any templates associated - with the route as though a real user had triggered the route change while - using your app. + Runs the passed target and method inside of a RunLoop, ensuring any + deferred actions including bindings and views updates are flushed at the + end. - Example: + Normally you should not need to invoke this method yourself. However if + you are implementing raw event handlers when interfacing with other + libraries or plugins, you should probably wrap all of your code inside this + call. ```javascript - visit('posts/index').then(function() { - // assert something + run(function() { + // code to be executed within a RunLoop }); ``` - @method visit - @param {String} url the name of the route - @return {RSVP.Promise} + @class run + @namespace Ember + @static + @constructor + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Object} return value from invoking the passed function. @public */ - function visit(app, url) { - var router = app.__container__.lookup('router:main'); - var shouldHandleURL = false; - - app.boot().then(function () { - router.location.setURL(url); - - if (shouldHandleURL) { - _emberMetal.run(app.__deprecatedInstance__, 'handleURL', url); - } - }); - - if (app._readinessDeferrals > 0) { - router['initialURL'] = url; - _emberMetal.run(app, 'advanceReadiness'); - delete router['initialURL']; - } else { - shouldHandleURL = true; - } - - return app.testHelpers.wait(); + function run() { + return backburner.run.apply(backburner, arguments); } -}); -enifed('ember-testing/helpers/wait', ['exports', 'ember-testing/test/waiters', 'ember-runtime', 'ember-metal', 'ember-testing/test/pending_requests'], function (exports, _emberTestingTestWaiters, _emberRuntime, _emberMetal, _emberTestingTestPending_requests) { + /** - @module ember - @submodule ember-testing + If no run-loop is present, it creates a new one. If a run loop is + present it will queue itself to run on the existing run-loops action + queue. + + Please note: This is not for normal usage, and should be used sparingly. + + If invoked when not within a run loop: + + ```javascript + run.join(function() { + // creates a new run-loop + }); + ``` + + Alternatively, if called within an existing run loop: + + ```javascript + run(function() { + // creates a new run-loop + run.join(function() { + // joins with the existing run-loop, and queues for invocation on + // the existing run-loops action queue. + }); + }); + ``` + + @method join + @namespace Ember + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Object} Return value from invoking the passed function. Please note, + when called within an existing loop, no return value is possible. + @public */ - 'use strict'; - - exports.default = wait; + run.join = function () { + return backburner.join.apply(backburner, arguments); + }; /** - Causes the run loop to process any pending events. This is used to ensure that - any async operations from other helpers (or your assertions) have been processed. - - This is most often used as the return value for the helper functions (see 'click', - 'fillIn','visit',etc). However, there is a method to register a test helper which - utilizes this method without the need to actually call `wait()` in your helpers. + Allows you to specify which context to call the specified function in while + adding the execution of that function to the Ember run loop. This ability + makes this method a great way to asynchronously integrate third-party libraries + into your Ember application. - The `wait` helper is built into `registerAsyncHelper` by default. You will not need - to `return app.testHelpers.wait();` - the wait behavior is provided for you. + `run.bind` takes two main arguments, the desired context and the function to + invoke in that context. Any additional arguments will be supplied as arguments + to the function that is passed in. - Example: + Let's use the creation of a TinyMCE component as an example. Currently, + TinyMCE provides a setup configuration option we can use to do some processing + after the TinyMCE instance is initialized but before it is actually rendered. + We can use that setup option to do some additional setup for our component. + The component itself could look something like the following: ```javascript - Ember.Test.registerAsyncHelper('loginUser', function(app, username, password) { - visit('secured/path/here') - .fillIn('#username', username) - .fillIn('#password', password) - .click('.submit'); + App.RichTextEditorComponent = Ember.Component.extend({ + initializeTinyMCE: Ember.on('didInsertElement', function() { + tinymce.init({ + selector: '#' + this.$().prop('id'), + setup: Ember.run.bind(this, this.setupEditor) + }); + }), + + setupEditor: function(editor) { + this.set('editor', editor); + + editor.on('change', function() { + console.log('content changed!'); + }); + } }); + ``` - @method wait - @param {Object} value The value to be returned. - @return {RSVP.Promise} + In this example, we use Ember.run.bind to bind the setupEditor method to the + context of the App.RichTextEditorComponent and to have the invocation of that + method be safely handled and executed by the Ember run loop. + + @method bind + @namespace Ember + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Function} returns a new function that will always have a particular context + @since 1.4.0 @public */ + run.bind = function () { + for (var _len = arguments.length, curried = Array(_len), _key = 0; _key < _len; _key++) { + curried[_key] = arguments[_key]; + } - function wait(app, value) { - return new _emberRuntime.RSVP.Promise(function (resolve) { - var router = app.__container__.lookup('router:main'); + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - // Every 10ms, poll for the async thing to have finished - var watcher = setInterval(function () { - // 1. If the router is loading, keep polling - var routerIsLoading = router.router && !!router.router.activeTransition; - if (routerIsLoading) { - return; - } + return run.join.apply(run, curried.concat(args)); + }; + }; - // 2. If there are pending Ajax requests, keep polling - if (_emberTestingTestPending_requests.pendingRequests()) { - return; - } + run.backburner = backburner; + run.currentRunLoop = null; + run.queues = backburner.queueNames; - // 3. If there are scheduled timers or we are inside of a run loop, keep polling - if (_emberMetal.run.hasScheduledTimers() || _emberMetal.run.currentRunLoop) { - return; - } + /** + Begins a new RunLoop. Any deferred actions invoked after the begin will + be buffered until you invoke a matching call to `run.end()`. This is + a lower-level way to use a RunLoop instead of using `run()`. + + ```javascript + run.begin(); + // code to be executed within a RunLoop + run.end(); + ``` + + @method begin + @return {void} + @public + */ + run.begin = function () { + backburner.begin(); + }; - if (_emberTestingTestWaiters.checkWaiters()) { - return; - } + /** + Ends a RunLoop. This must be called sometime after you call + `run.begin()` to flush any deferred actions. This is a lower-level way + to use a RunLoop instead of using `run()`. + + ```javascript + run.begin(); + // code to be executed within a RunLoop + run.end(); + ``` + + @method end + @return {void} + @public + */ + run.end = function () { + backburner.end(); + }; - // Stop polling - clearInterval(watcher); + /** + Array of named queues. This array determines the order in which queues + are flushed at the end of the RunLoop. You can define your own queues by + simply adding the queue name to this array. Normally you should not need + to inspect or modify this property. + + @property queues + @type Array + @default ['sync', 'actions', 'destroy'] + @private + */ - // Synchronously resolve the promise - _emberMetal.run(null, resolve, value); - }, 10); + /** + Adds the passed target/method and any optional arguments to the named + queue to be executed at the end of the RunLoop. If you have not already + started a RunLoop when calling this method one will be started for you + automatically. + + At the end of a RunLoop, any methods scheduled in this way will be invoked. + Methods will be invoked in an order matching the named queues defined in + the `run.queues` property. + + ```javascript + run.schedule('sync', this, function() { + // this will be executed in the first RunLoop queue, when bindings are synced + console.log('scheduled on sync queue'); }); - } -}); -enifed('ember-testing/index', ['exports', 'ember-testing/support', 'ember-testing/ext/application', 'ember-testing/ext/rsvp', 'ember-testing/helpers', 'ember-testing/initializers', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/setup_for_testing', 'ember-testing/adapters/qunit'], function (exports, _emberTestingSupport, _emberTestingExtApplication, _emberTestingExtRsvp, _emberTestingHelpers, _emberTestingInitializers, _emberTestingTest, _emberTestingAdaptersAdapter, _emberTestingSetup_for_testing, _emberTestingAdaptersQunit) { - 'use strict'; - - exports.Test = _emberTestingTest.default; - exports.Adapter = _emberTestingAdaptersAdapter.default; - exports.setupForTesting = _emberTestingSetup_for_testing.default; - exports.QUnitAdapter = _emberTestingAdaptersQunit.default; -}); -// to handle various edge cases -// setup RSVP + run loop integration -// adds helpers to helpers object in Test -// to setup initializer - -/** - @module ember - @submodule ember-testing -*/ -enifed('ember-testing/initializers', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { - 'use strict'; - - var name = 'deferReadiness in `testing` mode'; - - _emberRuntime.onLoad('Ember.Application', function (Application) { - if (!Application.initializers[name]) { - Application.initializer({ - name: name, + + run.schedule('actions', this, function() { + // this will be executed in the 'actions' queue, after bindings have synced. + console.log('scheduled on actions queue'); + }); + + // Note the functions will be run in order based on the run queues order. + // Output would be: + // scheduled on sync queue + // scheduled on actions queue + ``` + + @method schedule + @param {String} queue The name of the queue to schedule against. + Default queues are 'sync' and 'actions' + @param {Object} [target] target object to use as the context when invoking a method. + @param {String|Function} method The method to invoke. If you pass a string it + will be resolved on the target object at the time the scheduled item is + invoked allowing you to change the target function. + @param {Object} [arguments*] Optional arguments to be passed to the queued method. + @return {*} Timer information for use in cancelling, see `run.cancel`. + @public + */ + run.schedule = function () /* queue, target, method */{ + _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - initialize: function (application) { - if (application.testing) { - application.deferReadiness(); - } - } - }); - } - }); -}); -enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit) { - /* global self */ + return backburner.schedule.apply(backburner, arguments); + }; - 'use strict'; + // Used by global test teardown + run.hasScheduledTimers = function () { + return backburner.hasTimers(); + }; - exports.default = setupForTesting; + // Used by global test teardown + run.cancelTimers = function () { + backburner.cancelTimers(); + }; /** - Sets Ember up for testing. This is useful to perform - basic setup steps in order to unit test. + Immediately flushes any events scheduled in the 'sync' queue. Bindings + use this queue so this method is a useful way to immediately force all + bindings in the application to sync. - Use `App.setupForTesting` to perform integration tests (full - application testing). + You should call this method anytime you need any changed state to propagate + throughout the app immediately without repainting the UI (which happens + in the later 'render' queue added by the `ember-views` package). - @method setupForTesting - @namespace Ember - @since 1.5.0 + ```javascript + run.sync(); + ``` + + @method sync + @return {void} @private */ - - function setupForTesting() { - _emberMetal.setTesting(true); - - var adapter = _emberTestingTestAdapter.getAdapter(); - // if adapter is not manually set default to QUnit - if (!adapter) { - _emberTestingTestAdapter.setAdapter(typeof self.QUnit === 'undefined' ? new _emberTestingAdaptersAdapter.default() : new _emberTestingAdaptersQunit.default()); + run.sync = function () { + if (backburner.currentInstance) { + backburner.currentInstance.queues.sync.flush(); } - - _emberViews.jQuery(document).off('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); - _emberViews.jQuery(document).off('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); - - _emberTestingTestPending_requests.clearPendingRequests(); - - _emberViews.jQuery(document).on('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); - _emberViews.jQuery(document).on('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); - } -}); -enifed('ember-testing/support', ['exports', 'ember-metal', 'ember-views', 'ember-environment'], function (exports, _emberMetal, _emberViews, _emberEnvironment) { - 'use strict'; + }; /** - @module ember - @submodule ember-testing + Invokes the passed target/method and optional arguments after a specified + period of time. The last parameter of this method must always be a number + of milliseconds. + + You should use this method whenever you need to run some action after a + period of time instead of using `setTimeout()`. This method will ensure that + items that expire during the same script execution cycle all execute + together, which is often more efficient than using a real setTimeout. + + ```javascript + run.later(myContext, function() { + // code here will execute within a RunLoop in about 500ms with this == myContext + }, 500); + ``` + + @method later + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} wait Number of milliseconds to wait. + @return {*} Timer information for use in cancelling, see `run.cancel`. + @public */ - - var $ = _emberViews.jQuery; + run.later = function () /*target, method*/{ + return backburner.later.apply(backburner, arguments); + }; /** - This method creates a checkbox and triggers the click event to fire the - passed in handler. It is used to correct for a bug in older versions - of jQuery (e.g 1.8.3). + Schedule a function to run one time during the current RunLoop. This is equivalent + to calling `scheduleOnce` with the "actions" queue. - @private - @method testCheckboxClick + @method once + @param {Object} [target] The target of the method to invoke. + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. + @public */ - function testCheckboxClick(handler) { - var input = document.createElement('input'); - $(input).attr('type', 'checkbox').css({ position: 'absolute', left: '-1000px', top: '-1000px' }).appendTo('body').on('click', handler).trigger('click').remove(); - } + run.once = function () { + _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - if (_emberEnvironment.environment.hasDOM && typeof $ === 'function') { - $(function () { - /* - Determine whether a checkbox checked using jQuery's "click" method will have - the correct value for its checked property. - If we determine that the current jQuery version exhibits this behavior, - patch it to work correctly as in the commit for the actual fix: - https://github.com/jquery/jquery/commit/1fb2f92. - */ - testCheckboxClick(function () { - if (!this.checked && !$.event.special.click) { - $.event.special.click = { - // For checkbox, fire native event so checked state will be right - trigger: function () { - if ($.nodeName(this, 'input') && this.type === 'checkbox' && this.click) { - this.click(); - return false; - } - } - }; - } - }); + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } - // Try again to verify that the patch took effect or blow up. - testCheckboxClick(function () { - _emberMetal.warn('clicked checkboxes should be checked! the jQuery patch didn\'t work', this.checked, { id: 'ember-testing.test-checkbox-click' }); - }); - }); - } -}); -enifed('ember-testing/test', ['exports', 'ember-testing/test/helpers', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/promise', 'ember-testing/test/waiters', 'ember-testing/test/adapter', 'ember-metal'], function (exports, _emberTestingTestHelpers, _emberTestingTestOn_inject_helpers, _emberTestingTestPromise, _emberTestingTestWaiters, _emberTestingTestAdapter, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; + args.unshift('actions'); + return backburner.scheduleOnce.apply(backburner, args); + }; /** - This is a container for an assortment of testing related functionality: + Schedules a function to run one time in a given queue of the current RunLoop. + Calling this method with the same queue/target/method combination will have + no effect (past the initial call). + + Note that although you can pass optional arguments these will not be + considered when looking for duplicates. New arguments will replace previous + calls. + + ```javascript + function sayHi() { + console.log('hi'); + } + + run(function() { + run.scheduleOnce('afterRender', myContext, sayHi); + run.scheduleOnce('afterRender', myContext, sayHi); + // sayHi will only be executed once, in the afterRender queue of the RunLoop + }); + ``` + + Also note that passing an anonymous function to `run.scheduleOnce` will + not prevent additional calls with an identical anonymous function from + scheduling the items multiple times, e.g.: + + ```javascript + function scheduleIt() { + run.scheduleOnce('actions', myContext, function() { + console.log('Closure'); + }); + } + + scheduleIt(); + scheduleIt(); - * Choose your default test adapter (for your framework of choice). - * Register/Unregister additional test helpers. - * Setup callbacks to be fired when the test helpers are injected into - your application. + // "Closure" will print twice, even though we're using `run.scheduleOnce`, + // because the function we pass to it is anonymous and won't match the + // previously scheduled operation. + ``` - @class Test - @namespace Ember + Available queues, and their order, can be found at `run.queues` + + @method scheduleOnce + @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'. + @param {Object} [target] The target of the method to invoke. + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. @public */ - var Test = { - /** - Hash containing all known test helpers. - @property _helpers - @private - @since 1.7.0 - */ - _helpers: _emberTestingTestHelpers.helpers, - - registerHelper: _emberTestingTestHelpers.registerHelper, - registerAsyncHelper: _emberTestingTestHelpers.registerAsyncHelper, - unregisterHelper: _emberTestingTestHelpers.unregisterHelper, - onInjectHelpers: _emberTestingTestOn_inject_helpers.onInjectHelpers, - Promise: _emberTestingTestPromise.default, - promise: _emberTestingTestPromise.promise, - resolve: _emberTestingTestPromise.resolve, - registerWaiter: _emberTestingTestWaiters.registerWaiter, - unregisterWaiter: _emberTestingTestWaiters.unregisterWaiter + run.scheduleOnce = function () /*queue, target, method*/{ + _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); + return backburner.scheduleOnce.apply(backburner, arguments); }; - if (true) { - Test.checkWaiters = _emberTestingTestWaiters.checkWaiters; - } - /** - Used to allow ember-testing to communicate with a specific testing - framework. + Schedules an item to run from within a separate run loop, after + control has been returned to the system. This is equivalent to calling + `run.later` with a wait time of 1ms. - You can manually set it before calling `App.setupForTesting()`. + ```javascript + run.next(myContext, function() { + // code to be executed in the next run loop, + // which will be scheduled after the current one + }); + ``` - Example: + Multiple operations scheduled with `run.next` will coalesce + into the same later run loop, along with any other operations + scheduled by `run.later` that expire right around the same + time that `run.next` operations will fire. - ```javascript - Ember.Test.adapter = MyCustomAdapter.create() - ``` + Note that there are often alternatives to using `run.next`. + For instance, if you'd like to schedule an operation to happen + after all DOM element operations have completed within the current + run loop, you can make use of the `afterRender` run loop queue (added + by the `ember-views` package, along with the preceding `render` queue + where all the DOM element operations happen). - If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`. + Example: - @public - @for Ember.Test - @property adapter - @type {Class} The adapter to be used. - @default Ember.Test.QUnitAdapter + ```javascript + export default Ember.Component.extend({ + didInsertElement() { + this._super(...arguments); + run.scheduleOnce('afterRender', this, 'processChildElements'); + }, + + processChildElements() { + // ... do something with component's child component + // elements after they've finished rendering, which + // can't be done within this component's + // `didInsertElement` hook because that gets run + // before the child elements have been added to the DOM. + } + }); + ``` + + One benefit of the above approach compared to using `run.next` is + that you will be able to perform DOM/CSS operations before unprocessed + elements are rendered to the screen, which may prevent flickering or + other artifacts caused by delaying processing until after rendering. + + The other major benefit to the above approach is that `run.next` + introduces an element of non-determinism, which can make things much + harder to test, due to its reliance on `setTimeout`; it's much harder + to guarantee the order of scheduled operations when they are scheduled + outside of the current run loop, i.e. with `run.next`. + + @method next + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. + @public */ - Object.defineProperty(Test, 'adapter', { - get: _emberTestingTestAdapter.getAdapter, - set: _emberTestingTestAdapter.setAdapter - }); - - Object.defineProperty(Test, 'waiters', { - get: _emberTestingTestWaiters.generateDeprecatedWaitersArray - }); - - exports.default = Test; -}); -enifed('ember-testing/test/adapter', ['exports', 'ember-console', 'ember-metal'], function (exports, _emberConsole, _emberMetal) { - 'use strict'; - - exports.getAdapter = getAdapter; - exports.setAdapter = setAdapter; - exports.asyncStart = asyncStart; - exports.asyncEnd = asyncEnd; - - var adapter = undefined; - - function getAdapter() { - return adapter; - } - - function setAdapter(value) { - adapter = value; - if (value) { - _emberMetal.setDispatchOverride(adapterDispatch); - } else { - _emberMetal.setDispatchOverride(null); - } - } - - function asyncStart() { - if (adapter) { - adapter.asyncStart(); - } - } - - function asyncEnd() { - if (adapter) { - adapter.asyncEnd(); + run.next = function () { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; } - } - - function adapterDispatch(error) { - adapter.exception(error); - _emberConsole.default.error(error.stack); - } -}); -enifed('ember-testing/test/helpers', ['exports', 'ember-testing/test/promise'], function (exports, _emberTestingTestPromise) { - 'use strict'; - exports.registerHelper = registerHelper; - exports.registerAsyncHelper = registerAsyncHelper; - exports.unregisterHelper = unregisterHelper; - var helpers = {}; + args.push(1); + return backburner.later.apply(backburner, args); + }; - exports.helpers = helpers; /** - `registerHelper` is used to register a test helper that will be injected - when `App.injectTestHelpers` is called. + Cancels a scheduled item. Must be a value returned by `run.later()`, + `run.once()`, `run.scheduleOnce()`, `run.next()`, `run.debounce()`, or + `run.throttle()`. - The helper method will always be called with the current Application as - the first parameter. + ```javascript + let runNext = run.next(myContext, function() { + // will not be executed + }); - For example: + run.cancel(runNext); - ```javascript - Ember.Test.registerHelper('boot', function(app) { - Ember.run(app, app.advanceReadiness); + let runLater = run.later(myContext, function() { + // will not be executed + }, 500); + + run.cancel(runLater); + + let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { + // will not be executed }); - ``` - This helper can later be called without arguments because it will be - called with `app` as the first parameter. + run.cancel(runScheduleOnce); - ```javascript - App = Ember.Application.create(); - App.injectTestHelpers(); - boot(); + let runOnce = run.once(myContext, function() { + // will not be executed + }); + + run.cancel(runOnce); + + let throttle = run.throttle(myContext, function() { + // will not be executed + }, 1, false); + + run.cancel(throttle); + + let debounce = run.debounce(myContext, function() { + // will not be executed + }, 1); + + run.cancel(debounce); + + let debounceImmediate = run.debounce(myContext, function() { + // will be executed since we passed in true (immediate) + }, 100, true); + + // the 100ms delay until this method can be called again will be cancelled + run.cancel(debounceImmediate); ``` + @method cancel + @param {Object} timer Timer object to cancel + @return {Boolean} true if cancelled or false/undefined if it wasn't found @public - @for Ember.Test - @method registerHelper - @param {String} name The name of the helper method to add. - @param {Function} helperMethod - @param options {Object} */ - - function registerHelper(name, helperMethod) { - helpers[name] = { - method: helperMethod, - meta: { wait: false } - }; - } + run.cancel = function (timer) { + return backburner.cancel(timer); + }; /** - `registerAsyncHelper` is used to register an async test helper that will be injected - when `App.injectTestHelpers` is called. - - The helper method will always be called with the current Application as - the first parameter. + Delay calling the target method until the debounce period has elapsed + with no additional debounce calls. If `debounce` is called again before + the specified time has elapsed, the timer is reset and the entire period + must pass again before the target method is called. - For example: + This method should be used when an event may be called multiple times + but the action should only be called once when the event is done firing. + A common example is for scroll events where you only want updates to + happen once scrolling has ceased. ```javascript - Ember.Test.registerAsyncHelper('boot', function(app) { - Ember.run(app, app.advanceReadiness); - }); - ``` + function whoRan() { + console.log(this.name + ' ran.'); + } - The advantage of an async helper is that it will not run - until the last async helper has completed. All async helpers - after it will wait for it complete before running. + let myContext = { name: 'debounce' }; + run.debounce(myContext, whoRan, 150); - For example: + // less than 150ms passes + run.debounce(myContext, whoRan, 150); + + // 150ms passes + // whoRan is invoked with context myContext + // console logs 'debounce ran.' one time. + ``` + + Immediate allows you to run the function immediately, but debounce + other calls for this function until the wait time has elapsed. If + `debounce` is called again before the specified time has elapsed, + the timer is reset and the entire period must pass again before + the method can be called again. ```javascript - Ember.Test.registerAsyncHelper('deletePost', function(app, postId) { - click('.delete-' + postId); - }); + function whoRan() { + console.log(this.name + ' ran.'); + } + + let myContext = { name: 'debounce' }; + + run.debounce(myContext, whoRan, 150, true); + + // console logs 'debounce ran.' one time immediately. + // 100ms passes + run.debounce(myContext, whoRan, 150, true); + + // 150ms passes and nothing else is logged to the console and + // the debouncee is no longer being watched + run.debounce(myContext, whoRan, 150, true); + + // console logs 'debounce ran.' one time immediately. + // 150ms passes and nothing else is logged to the console and + // the debouncee is no longer being watched - // ... in your test - visit('/post/2'); - deletePost(2); - visit('/post/3'); - deletePost(3); ``` + @method debounce + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} wait Number of milliseconds to wait. + @param {Boolean} immediate Trigger the function on the leading instead + of the trailing edge of the wait interval. Defaults to false. + @return {Array} Timer information for use in cancelling, see `run.cancel`. @public - @for Ember.Test - @method registerAsyncHelper - @param {String} name The name of the helper method to add. - @param {Function} helperMethod - @since 1.2.0 */ - - function registerAsyncHelper(name, helperMethod) { - helpers[name] = { - method: helperMethod, - meta: { wait: true } - }; - } + run.debounce = function () { + return backburner.debounce.apply(backburner, arguments); + }; /** - Remove a previously added helper method. - - Example: + Ensure that the target method is never called more frequently than + the specified spacing period. The target method is called immediately. ```javascript - Ember.Test.unregisterHelper('wait'); + function whoRan() { + console.log(this.name + ' ran.'); + } + + let myContext = { name: 'throttle' }; + + run.throttle(myContext, whoRan, 150); + // whoRan is invoked with context myContext + // console logs 'throttle ran.' + + // 50ms passes + run.throttle(myContext, whoRan, 150); + + // 50ms passes + run.throttle(myContext, whoRan, 150); + + // 150ms passes + run.throttle(myContext, whoRan, 150); + // whoRan is invoked with context myContext + // console logs 'throttle ran.' ``` + @method throttle + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} spacing Number of milliseconds to space out requests. + @param {Boolean} immediate Trigger the function on the leading instead + of the trailing edge of the wait interval. Defaults to true. + @return {Array} Timer information for use in cancelling, see `run.cancel`. @public - @method unregisterHelper - @param {String} name The helper to remove. */ + run.throttle = function () { + return backburner.throttle.apply(backburner, arguments); + }; - function unregisterHelper(name) { - delete helpers[name]; - delete _emberTestingTestPromise.default.prototype[name]; - } + /** + Add a new named queue after the specified queue. + + The queue to add will only be added once. + + @method _addQueue + @param {String} name the name of the queue to add. + @param {String} after the name of the queue to add after. + @private + */ + run._addQueue = function (name, after) { + if (run.queues.indexOf(name) === -1) { + run.queues.splice(run.queues.indexOf(after) + 1, 0, name); + } + }; }); -enifed("ember-testing/test/on_inject_helpers", ["exports"], function (exports) { - "use strict"; +enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set'], function (exports, _emberMetalProperty_events, _emberMetalProperty_set) { + 'use strict'; - exports.onInjectHelpers = onInjectHelpers; - exports.invokeInjectHelpersCallbacks = invokeInjectHelpersCallbacks; - var callbacks = []; + exports.default = setProperties; - exports.callbacks = callbacks; /** - Used to register callbacks to be fired whenever `App.injectTestHelpers` - is called. - - The callback will receive the current application as an argument. - - Example: + Set a list of properties on an object. These properties are set inside + a single `beginPropertyChanges` and `endPropertyChanges` batch, so + observers will be buffered. ```javascript - Ember.Test.onInjectHelpers(function() { - Ember.$(document).ajaxSend(function() { - Test.pendingRequests++; - }); + let anObject = Ember.Object.create(); - Ember.$(document).ajaxComplete(function() { - Test.pendingRequests--; - }); + anObject.setProperties({ + firstName: 'Stanley', + lastName: 'Stuart', + age: 21 }); ``` + @method setProperties + @param obj + @param {Object} properties + @return properties @public - @for Ember.Test - @method onInjectHelpers - @param {Function} callback The function to be called. */ - function onInjectHelpers(callback) { - callbacks.push(callback); - } + function setProperties(obj, properties) { + if (!properties || typeof properties !== 'object') { + return properties; + } + _emberMetalProperty_events.changeProperties(function () { + var props = Object.keys(properties); + var propertyName = undefined; + + for (var i = 0; i < props.length; i++) { + propertyName = props[i]; + + _emberMetalProperty_set.set(obj, propertyName, properties[propertyName]); + } + }); + return properties; + } +}); +enifed('ember-metal/tags', ['exports', '@glimmer/reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { + 'use strict'; + + exports.setHasViews = setHasViews; + exports.tagForProperty = tagForProperty; + exports.tagFor = tagFor; + exports.markObjectAsDirty = markObjectAsDirty; + + var hasViews = function () { + return false; + }; + + function setHasViews(fn) { + hasViews = fn; + } + + function makeTag() { + return new _glimmerReference.DirtyableTag(); + } + + function tagForProperty(object, propertyKey, _meta) { + if (_emberMetalIs_proxy.isProxy(object)) { + return tagFor(object, _meta); + } + + if (typeof object === 'object' && object) { + var meta = _meta || _emberMetalMeta.meta(object); + var tags = meta.writableTags(); + var tag = tags[propertyKey]; + if (tag) { + return tag; + } + + return tags[propertyKey] = makeTag(); + } else { + return _glimmerReference.CONSTANT_TAG; + } + } + + function tagFor(object, _meta) { + if (typeof object === 'object' && object) { + var meta = _meta || _emberMetalMeta.meta(object); + return meta.writableTag(makeTag); + } else { + return _glimmerReference.CONSTANT_TAG; + } + } + + function markObjectAsDirty(meta, propertyKey) { + var objectTag = meta && meta.readableTag(); + + if (objectTag) { + objectTag.dirty(); + } + + var tags = meta && meta.readableTags(); + var propertyTag = tags && tags[propertyKey]; + + if (propertyTag) { + propertyTag.dirty(); + } - function invokeInjectHelpersCallbacks(app) { - for (var i = 0; i < callbacks.length; i++) { - callbacks[i](app); + if (objectTag || propertyTag) { + ensureRunloop(); } } -}); -enifed("ember-testing/test/pending_requests", ["exports"], function (exports) { - "use strict"; - exports.pendingRequests = pendingRequests; - exports.clearPendingRequests = clearPendingRequests; - exports.incrementPendingRequests = incrementPendingRequests; - exports.decrementPendingRequests = decrementPendingRequests; - var requests = []; + var run = undefined; - function pendingRequests() { - return requests.length; - } + function K() {} - function clearPendingRequests() { - requests.length = 0; + function ensureRunloop() { + if (!run) { + run = _require.default('ember-metal/run_loop').default; + } + + if (hasViews() && !run.backburner.currentInstance) { + run.schedule('actions', K); + } } +}); +enifed("ember-metal/testing", ["exports"], function (exports) { + "use strict"; - function incrementPendingRequests(_, xhr) { - requests.push(xhr); + exports.isTesting = isTesting; + exports.setTesting = setTesting; + var testing = false; + + function isTesting() { + return testing; } - function decrementPendingRequests(_, xhr) { - for (var i = 0; i < requests.length; i++) { - if (xhr === requests[i]) { - requests.splice(i, 1); - break; - } - } + function setTesting(value) { + testing = !!value; } }); -enifed('ember-testing/test/promise', ['exports', 'ember-runtime', 'ember-testing/test/run'], function (exports, _emberRuntime, _emberTestingTestRun) { +enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) { 'use strict'; - exports.promise = promise; - exports.resolve = resolve; - exports.getLastPromise = getLastPromise; - - var lastPromise = undefined; + var runInTransaction = undefined, + didRender = undefined, + assertNotRendered = undefined; - var TestPromise = (function (_RSVP$Promise) { - babelHelpers.inherits(TestPromise, _RSVP$Promise); + // detect-backtracking-rerender by default is debug build only + // detect-glimmer-allow-backtracking-rerender can be enabled in custom builds + if (true || false) { + (function () { + var counter = 0; + var inTransaction = false; + var shouldReflush = undefined; + var debugStack = undefined; - function TestPromise() { - babelHelpers.classCallCheck(this, TestPromise); + exports.default = runInTransaction = function (context, methodName) { + shouldReflush = false; + inTransaction = true; + _emberMetalDebug.runInDebug(function () { + debugStack = context.env.debugStack; + }); + context[methodName](); + inTransaction = false; + counter++; + return shouldReflush; + }; - _RSVP$Promise.apply(this, arguments); - lastPromise = this; - } + exports.didRender = didRender = function (object, key, reference) { + if (!inTransaction) { + return; + } + var meta = _emberMetalMeta.meta(object); + var lastRendered = meta.writableLastRendered(); + lastRendered[key] = counter; - /** - This returns a thenable tailored for testing. It catches failed - `onSuccess` callbacks and invokes the `Ember.Test.adapter.exception` - callback in the last chained then. - - This method should be returned by async helpers such as `wait`. - - @public - @for Ember.Test - @method promise - @param {Function} resolver The function used to resolve the promise. - @param {String} label An optional string for identifying the promise. - */ + _emberMetalDebug.runInDebug(function () { + var referenceMap = meta.writableLastRenderedReferenceMap(); + referenceMap[key] = reference; - TestPromise.prototype.then = function then(onFulfillment) { - var _RSVP$Promise$prototype$then; + var templateMap = meta.writableLastRenderedTemplateMap(); + if (templateMap[key] === undefined) { + templateMap[key] = debugStack.peek(); + } + }); + }; - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } + exports.assertNotRendered = assertNotRendered = function (object, key, _meta) { + var meta = _meta || _emberMetalMeta.meta(object); + var lastRendered = meta.readableLastRendered(); - return (_RSVP$Promise$prototype$then = _RSVP$Promise.prototype.then).call.apply(_RSVP$Promise$prototype$then, [this, function (result) { - return isolate(onFulfillment, result); - }].concat(args)); - }; + if (lastRendered && lastRendered[key] === counter) { + _emberMetalDebug.runInDebug(function () { + var templateMap = meta.readableLastRenderedTemplateMap(); + var lastRenderedIn = templateMap[key]; + var currentlyIn = debugStack.peek(); - return TestPromise; - })(_emberRuntime.RSVP.Promise); + var referenceMap = meta.readableLastRenderedReferenceMap(); + var lastRef = referenceMap[key]; + var parts = []; + var label = undefined; - exports.default = TestPromise; + if (lastRef) { + while (lastRef && lastRef._propertyKey) { + parts.unshift(lastRef._propertyKey); + lastRef = lastRef._parentReference; + } - function promise(resolver, label) { - var fullLabel = 'Ember.Test.promise: ' + (label || ''); - return new TestPromise(resolver, fullLabel); - } + label = parts.join('.'); + } else { + label = 'the same value'; + } - /** - Replacement for `Ember.RSVP.resolve` - The only difference is this uses - an instance of `Ember.Test.Promise` - - @public - @for Ember.Test - @method resolve - @param {Mixed} The value to resolve - @since 1.2.0 - */ + var message = 'You modified "' + label + '" twice on ' + object + ' in a single render. It was rendered in ' + lastRenderedIn + ' and modified in ' + currentlyIn + '. This was unreliable and slow in Ember 1.x and'; - function resolve(result, label) { - return TestPromise.resolve(result, label); - } + if (false) { + _emberMetalDebug.deprecate(message + ' will be removed in Ember 3.0.', false, { id: 'ember-views.render-double-modify', until: '3.0.0' }); + } else { + _emberMetalDebug.assert(message + ' is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.', false); + } + }); - function getLastPromise() { - return lastPromise; + shouldReflush = true; + } + }; + })(); + } else { + // in production do nothing to detect reflushes + exports.default = runInTransaction = function (context, methodName) { + context[methodName](); + return false; + }; } - // This method isolates nested async methods - // so that they don't conflict with other last promises. - // - // 1. Set `Ember.Test.lastPromise` to null - // 2. Invoke method - // 3. Return the last promise created during method - function isolate(onFulfillment, result) { - // Reset lastPromise for nested helpers - lastPromise = null; + exports.default = runInTransaction; + exports.didRender = didRender; + exports.assertNotRendered = assertNotRendered; +}); +enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) { + 'use strict'; - var value = onFulfillment(result); + exports.watchKey = watchKey; + exports.unwatchKey = unwatchKey; - var promise = lastPromise; - lastPromise = null; + var handleMandatorySetter = undefined; - // If the method returned a promise - // return that promise. If not, - // return the last async helper's promise - if (value && value instanceof TestPromise || !promise) { - return value; - } else { - return _emberTestingTestRun.default(function () { - return resolve(promise).then(function () { - return value; - }); - }); + function watchKey(obj, keyName, meta) { + if (typeof obj !== 'object' || obj === null) { + return; } - } -}); -enifed('ember-testing/test/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + var m = meta || _emberMetalMeta.meta(obj); - exports.default = run; + // activate watching first time + if (!m.peekWatching(keyName)) { + m.writeWatching(keyName, 1); - function run(fn) { - if (!_emberMetal.run.currentRunLoop) { - return _emberMetal.run(fn); + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + if (desc && desc.willWatch) { + desc.willWatch(obj, keyName); + } + + if ('function' === typeof obj.willWatchProperty) { + obj.willWatchProperty(keyName); + } + + if (true) { + // NOTE: this is dropped for prod + minified builds + handleMandatorySetter(m, obj, keyName); + } } else { - return fn(); + m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1); } } -}); -enifed('ember-testing/test/waiters', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - exports.registerWaiter = registerWaiter; - exports.unregisterWaiter = unregisterWaiter; - exports.checkWaiters = checkWaiters; - exports.generateDeprecatedWaitersArray = generateDeprecatedWaitersArray; + if (true) { + (function () { + var hasOwnProperty = function (obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + }; - var contexts = []; - var callbacks = []; + var propertyIsEnumerable = function (obj, key) { + return Object.prototype.propertyIsEnumerable.call(obj, key); + }; - /** - This allows ember-testing to play nicely with other asynchronous - events, such as an application that is waiting for a CSS3 - transition or an IndexDB transaction. The waiter runs periodically - after each async helper (i.e. `click`, `andThen`, `visit`, etc) has executed, - until the returning result is truthy. After the waiters finish, the next async helper - is executed and the process repeats. - - For example: - - ```javascript - Ember.Test.registerWaiter(function() { - return myPendingTransactions() == 0; - }); - ``` - The `context` argument allows you to optionally specify the `this` - with which your callback will be invoked. - - For example: - - ```javascript - Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions); - ``` - - @public - @for Ember.Test - @method registerWaiter - @param {Object} context (optional) - @param {Function} callback - @since 1.2.0 - */ + // Future traveler, although this code looks scary. It merely exists in + // development to aid in development asertions. Production builds of + // ember strip this entire block out + handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { + var descriptor = _emberUtils.lookupDescriptor(obj, keyName); + var configurable = descriptor ? descriptor.configurable : true; + var isWritable = descriptor ? descriptor.writable : true; + var hasValue = descriptor ? 'value' in descriptor : true; + var possibleDesc = descriptor && descriptor.value; + var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; - function registerWaiter(context, callback) { - if (arguments.length === 1) { - callback = context; - context = null; - } - if (indexOf(context, callback) > -1) { - return; - } - contexts.push(context); - callbacks.push(callback); - } + if (isDescriptor) { + return; + } - /** - `unregisterWaiter` is used to unregister a callback that was - registered with `registerWaiter`. - - @public - @for Ember.Test - @method unregisterWaiter - @param {Object} context (optional) - @param {Function} callback - @since 1.2.0 - */ + // this x in Y deopts, so keeping it in this function is better; + if (configurable && isWritable && hasValue && keyName in obj) { + var desc = { + configurable: true, + set: _emberMetalProperties.MANDATORY_SETTER_FUNCTION(keyName), + enumerable: propertyIsEnumerable(obj, keyName), + get: undefined + }; - function unregisterWaiter(context, callback) { - if (!callbacks.length) { + if (hasOwnProperty(obj, keyName)) { + m.writeValues(keyName, obj[keyName]); + desc.get = _emberMetalProperties.DEFAULT_GETTER_FUNCTION(keyName); + } else { + desc.get = _emberMetalProperties.INHERITING_GETTER_FUNCTION(keyName); + } + + Object.defineProperty(obj, keyName, desc); + } + }; + })(); + } + + function unwatchKey(obj, keyName, _meta) { + if (typeof obj !== 'object' || obj === null) { return; } - if (arguments.length === 1) { - callback = context; - context = null; - } - var i = indexOf(context, callback); - if (i === -1) { + var meta = _meta || _emberMetalMeta.meta(obj); + + // do nothing of this object has already been destroyed + if (meta.isSourceDestroyed()) { return; } - contexts.splice(i, 1); - callbacks.splice(i, 1); - } - /** - Iterates through each registered test waiter, and invokes - its callback. If any waiter returns false, this method will return - true indicating that the waiters have not settled yet. - - This is generally used internally from the acceptance/integration test - infrastructure. - - @public - @for Ember.Test - @static - @method checkWaiters - */ + var count = meta.peekWatching(keyName); + if (count === 1) { + meta.writeWatching(keyName, 0); - function checkWaiters() { - if (!callbacks.length) { - return false; - } - for (var i = 0; i < callbacks.length; i++) { - var context = contexts[i]; - var callback = callbacks[i]; - if (!callback.call(context)) { - return true; - } - } - return false; - } + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - function indexOf(context, callback) { - for (var i = 0; i < callbacks.length; i++) { - if (callbacks[i] === callback && contexts[i] === context) { - return i; + if (desc && desc.didUnwatch) { + desc.didUnwatch(obj, keyName); } - } - return -1; - } - - function generateDeprecatedWaitersArray() { - _emberMetal.deprecate('Usage of `Ember.Test.waiters` is deprecated. Please refactor to `Ember.Test.checkWaiters`.', !true, { until: '2.8.0', id: 'ember-testing.test-waiters' }); - - var array = new Array(callbacks.length); - for (var i = 0; i < callbacks.length; i++) { - var context = contexts[i]; - var callback = callbacks[i]; - array[i] = [context, callback]; - } + if ('function' === typeof obj.didUnwatchProperty) { + obj.didUnwatchProperty(keyName); + } - return array; - } -}); -enifed("ember-utils/apply-str", ["exports"], function (exports) { - /** - @param {Object} t target - @param {String} m method - @param {Array} a args - @private - */ - "use strict"; + if (true) { + // It is true, the following code looks quite WAT. But have no fear, It + // exists purely to improve development ergonomics and is removed from + // ember.min.js and ember.prod.js builds. + // + // Some further context: Once a property is watched by ember, bypassing `set` + // for mutation, will bypass observation. This code exists to assert when + // that occurs, and attempt to provide more helpful feedback. The alternative + // is tricky to debug partially observable properties. + if (!desc && keyName in obj) { + var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName); - exports.default = applyStr; + if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { + if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { + var possibleValue = meta.readInheritedValue('values', keyName); + if (possibleValue === _emberMetalMeta.UNDEFINED) { + delete obj[keyName]; + return; + } + } - function applyStr(t, m, a) { - var l = a && a.length; - if (!a || !l) { - return t[m](); - } - switch (l) { - case 1: - return t[m](a[0]); - case 2: - return t[m](a[0], a[1]); - case 3: - return t[m](a[0], a[1], a[2]); - case 4: - return t[m](a[0], a[1], a[2], a[3]); - case 5: - return t[m](a[0], a[1], a[2], a[3], a[4]); - default: - return t[m].apply(t, a); + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), + writable: true, + value: meta.peekValues(keyName) + }); + meta.deleteFromValues(keyName); + } + } + } + } else if (count > 1) { + meta.writeWatching(keyName, count - 1); } } }); -enifed("ember-utils/assign", ["exports"], function (exports) { - /** - Copy properties from a source object to a target object. - - ```javascript - var a = { first: 'Yehuda' }; - var b = { last: 'Katz' }; - var c = { company: 'Tilde Inc.' }; - Ember.assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' } - ``` - - @method assign - @for Ember - @param {Object} original The object to assign into - @param {Object} ...args The objects to copy properties from - @return {Object} - @public - */ - "use strict"; - - exports.default = assign; - - function assign(original) { - for (var i = 1; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) { - continue; - } - - var updates = Object.keys(arg); +enifed('ember-metal/watch_path', ['exports', 'ember-metal/meta', 'ember-metal/chains'], function (exports, _emberMetalMeta, _emberMetalChains) { + 'use strict'; - for (var _i = 0; _i < updates.length; _i++) { - var prop = updates[_i]; - original[prop] = arg[prop]; - } - } + exports.makeChainNode = makeChainNode; + exports.watchPath = watchPath; + exports.unwatchPath = unwatchPath; - return original; + // get the chains for the current object. If the current object has + // chains inherited from the proto they will be cloned and reconfigured for + // the current object. + function chainsFor(obj, meta) { + return (meta || _emberMetalMeta.meta(obj)).writableChains(makeChainNode); } -}); -enifed('ember-utils/dictionary', ['exports', 'ember-utils/empty-object'], function (exports, _emberUtilsEmptyObject) { - 'use strict'; - exports.default = makeDictionary; - - // the delete is meant to hint at runtimes that this object should remain in - // dictionary mode. This is clearly a runtime specific hack, but currently it - // appears worthwhile in some usecases. Please note, these deletes do increase - // the cost of creation dramatically over a plain Object.create. And as this - // only makes sense for long-lived dictionaries that aren't instantiated often. + function makeChainNode(obj) { + return new _emberMetalChains.ChainNode(null, null, obj); + } - function makeDictionary(parent) { - var dict = undefined; - if (parent === null) { - dict = new _emberUtilsEmptyObject.default(); + function watchPath(obj, keyPath, meta) { + if (typeof obj !== 'object' || obj === null) { + return; + } + var m = meta || _emberMetalMeta.meta(obj); + var counter = m.peekWatching(keyPath) || 0; + if (!counter) { + // activate watching first time + m.writeWatching(keyPath, 1); + chainsFor(obj, m).add(keyPath); } else { - dict = Object.create(parent); + m.writeWatching(keyPath, counter + 1); } - dict['_dict'] = null; - delete dict['_dict']; - return dict; } -}); -enifed("ember-utils/empty-object", ["exports"], function (exports) { - // This exists because `Object.create(null)` is absurdly slow compared - // to `new EmptyObject()`. In either case, you want a null prototype - // when you're treating the object instances as arbitrary dictionaries - // and don't want your keys colliding with build-in methods on the - // default object prototype. - "use strict"; - - var proto = Object.create(null, { - // without this, we will always still end up with (new - // EmptyObject()).constructor === Object - constructor: { - value: undefined, - enumerable: false, - writable: true + function unwatchPath(obj, keyPath, meta) { + if (typeof obj !== 'object' || obj === null) { + return; } - }); + var m = meta || _emberMetalMeta.meta(obj); + var counter = m.peekWatching(keyPath) || 0; - function EmptyObject() {} - EmptyObject.prototype = proto; - exports.default = EmptyObject; + if (counter === 1) { + m.writeWatching(keyPath, 0); + chainsFor(obj, m).remove(keyPath); + } else if (counter > 1) { + m.writeWatching(keyPath, counter - 1); + } + } }); -enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, _emberUtilsIntern) { +enifed('ember-metal/watching', ['exports', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) { + /** + @module ember-metal + */ + 'use strict'; - exports.uuid = uuid; - exports.generateGuid = generateGuid; - exports.guidFor = guidFor; + exports.isWatching = isWatching; + exports.watcherCount = watcherCount; + exports.unwatch = unwatch; + exports.destroy = destroy; /** - Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from - jQuery master. We'll just bootstrap our own uuid now. + Starts watching a property on an object. Whenever the property changes, + invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the + primitive used by observers and dependent keys; usually you will never call + this method directly but instead use higher level methods like + `Ember.addObserver()` - @private - @return {Number} the uuid - */ - var _uuid = 0; + @private + @method watch + @for Ember + @param obj + @param {String} _keyPath + */ + function watch(obj, _keyPath, m) { + if (!_emberMetalPath_cache.isPath(_keyPath)) { + _emberMetalWatch_key.watchKey(obj, _keyPath, m); + } else { + _emberMetalWatch_path.watchPath(obj, _keyPath, m); + } + } - /** - Generates a universally unique identifier. This method - is used internally by Ember for assisting with - the generation of GUID's and other unique identifiers. - - @public - @return {Number} [description] - */ + exports.watch = watch; - function uuid() { - return ++_uuid; + function isWatching(obj, key) { + if (typeof obj !== 'object' || obj === null) { + return false; + } + var meta = _emberMetalMeta.peekMeta(obj); + return (meta && meta.peekWatching(key)) > 0; } - /** - Prefix used for guids through out Ember. - @private - @property GUID_PREFIX - @for Ember - @type String - @final - */ - var GUID_PREFIX = 'ember'; + function watcherCount(obj, key) { + var meta = _emberMetalMeta.peekMeta(obj); + return meta && meta.peekWatching(key) || 0; + } - // Used for guid generation... - var numberCache = []; - var stringCache = {}; + function unwatch(obj, _keyPath, m) { + if (!_emberMetalPath_cache.isPath(_keyPath)) { + _emberMetalWatch_key.unwatchKey(obj, _keyPath, m); + } else { + _emberMetalWatch_path.unwatchPath(obj, _keyPath, m); + } + } /** - A unique key used to assign guids and other private metadata to objects. - If you inspect an object in your browser debugger you will often see these. - They can be safely ignored. - - On browsers that support it, these properties are added with enumeration - disabled so they won't show up when you iterate over your properties. + Tears down the meta on an object so that it can be garbage collected. + Multiple calls will have no effect. - @private - @property GUID_KEY + @method destroy @for Ember - @type String - @final + @param {Object} obj the object to destroy + @return {void} + @private */ - var GUID_KEY = _emberUtilsIntern.default('__ember' + +new Date()); - exports.GUID_KEY = GUID_KEY; - var GUID_DESC = { - writable: true, - configurable: true, - enumerable: false, - value: null - }; + function destroy(obj) { + _emberMetalMeta.deleteMeta(obj); + } +}); +enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { + 'use strict'; - exports.GUID_DESC = GUID_DESC; - var nullDescriptor = { - configurable: true, - writable: true, - enumerable: false, - value: null - }; + exports.default = WeakMap; - var GUID_KEY_PROPERTY = { - name: GUID_KEY, - descriptor: nullDescriptor - }; + var id = 0; - exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY; - /** - Generates a new guid, optionally saving the guid to the object that you - pass in. You will rarely need to use this method. Instead you should - call `Ember.guidFor(obj)`, which return an existing guid if available. - - @private - @method generateGuid - @for Ember - @param {Object} [obj] Object the guid will be used for. If passed in, the guid will - be saved on the object and reused whenever you pass the same object - again. - - If no object is passed, just generate a new guid. - @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to - separate the guid into separate namespaces. - @return {String} the guid - */ + // Returns whether Type(value) is Object according to the terminology in the spec + function isObject(value) { + return typeof value === 'object' && value !== null || typeof value === 'function'; + } - function generateGuid(obj, prefix) { - if (!prefix) { - prefix = GUID_PREFIX; + /* + * @class Ember.WeakMap + * @public + * @category ember-metal-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(iterable) { + if (!(this instanceof WeakMap)) { + throw new TypeError('Constructor WeakMap requires \'new\''); } - var ret = prefix + uuid(); - if (obj) { - if (obj[GUID_KEY] === null) { - obj[GUID_KEY] = ret; - } else { - GUID_DESC.value = ret; - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(GUID_KEY_PROPERTY); - } else { - Object.defineProperty(obj, GUID_KEY, GUID_DESC); - } + this._id = _emberUtils.GUID_KEY + id++; + + if (iterable === null || iterable === undefined) { + return; + } else if (Array.isArray(iterable)) { + for (var i = 0; i < iterable.length; i++) { + var _iterable$i = iterable[i]; + var key = _iterable$i[0]; + var value = _iterable$i[1]; + + this.set(key, value); } + } else { + throw new TypeError('The weak map constructor polyfill only supports an array argument'); } - return ret; } - /** - Returns a unique id for the object. If the object does not yet have a guid, - one will be assigned to it. You can call this on any object, - `Ember.Object`-based or not, but be aware that it will add a `_guid` - property. - - You can also use this method on DOM Element objects. - - @public - @method guidFor - @for Ember - @param {Object} obj any object, string, number, Element, or primitive - @return {String} the unique guid for this instance. - */ + /* + * @method get + * @param key {Object | Function} + * @return {Any} stored value + */ + WeakMap.prototype.get = function (obj) { + if (!isObject(obj)) { + return undefined; + } - function guidFor(obj) { - var type = typeof obj; - var isObject = type === 'object' && obj !== null; - var isFunction = type === 'function'; + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + if (map[this._id] === _emberMetalMeta.UNDEFINED) { + return undefined; + } - if ((isObject || isFunction) && obj[GUID_KEY]) { - return obj[GUID_KEY]; + return map[this._id]; + } } + }; - // special cases where we don't want to add a key to object - if (obj === undefined) { - return '(undefined)'; + /* + * @method set + * @param key {Object | Function} + * @param value {Any} + * @return {WeakMap} the weak map + */ + WeakMap.prototype.set = function (obj, value) { + if (!isObject(obj)) { + throw new TypeError('Invalid value used as weak map key'); } - if (obj === null) { - return '(null)'; + if (value === undefined) { + value = _emberMetalMeta.UNDEFINED; } - var ret = undefined; + _emberMetalMeta.meta(obj).writableWeak()[this._id] = value; - // Don't allow prototype changes to String etc. to change the guidFor - switch (type) { - case 'number': - ret = numberCache[obj]; + return this; + }; - if (!ret) { - ret = numberCache[obj] = 'nu' + obj; - } + /* + * @method has + * @param key {Object | Function} + * @return {boolean} if the key exists + */ + WeakMap.prototype.has = function (obj) { + if (!isObject(obj)) { + return false; + } - return ret; + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + return map[this._id] !== undefined; + } + } - case 'string': - ret = stringCache[obj]; + return false; + }; - if (!ret) { - ret = stringCache[obj] = 'st' + uuid(); - } + /* + * @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; + } + }; - return ret; + /* + * @method toString + * @return {String} + */ + WeakMap.prototype.toString = function () { + return '[object WeakMap]'; + }; +}); +enifed('ember-routing/ext/controller', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/utils'], function (exports, _emberMetal, _emberRuntime, _emberRoutingUtils) { + 'use strict'; - case 'boolean': - return obj ? '(true)' : '(false)'; + /** + @module ember + @submodule ember-routing + */ + + _emberRuntime.ControllerMixin.reopen({ + concatenatedProperties: ['queryParams'], + + /** + Defines which query parameters the controller accepts. + If you give the names `['category','page']` it will bind + the values of these query parameters to the variables + `this.category` and `this.page` + @property queryParams + @public + */ + queryParams: null, + + /** + This property is updated to various different callback functions depending on + the current "state" of the backing route. It is used by + `Ember.Controller.prototype._qpChanged`. + The methods backing each state can be found in the `Ember.Route.prototype._qp` computed + property return value (the `.states` property). The current values are listed here for + the sanity of future travelers: + * `inactive` - This state is used when this controller instance is not part of the active + route heirarchy. Set in `Ember.Route.prototype._reset` (a `router.js` microlib hook) and + `Ember.Route.prototype.actions.finalizeQueryParamChange`. + * `active` - This state is used when this controller instance is part of the active + route heirarchy. Set in `Ember.Route.prototype.actions.finalizeQueryParamChange`. + * `allowOverrides` - This state is used in `Ember.Route.prototype.setup` (`route.js` microlib hook). + @method _qpDelegate + @private + */ + _qpDelegate: null, // set by route + + /** + During `Ember.Route#setup` observers are created to invoke this method + when any of the query params declared in `Ember.Controller#queryParams` property + are changed. + When invoked this method uses the currently active query param update delegate + (see `Ember.Controller.prototype._qpDelegate` for details) and invokes it with + the QP key/value being changed. + @method _qpChanged + @private + */ + _qpChanged: function (controller, _prop) { + var prop = _prop.substr(0, _prop.length - 3); + + var delegate = controller._qpDelegate; + var value = _emberMetal.get(controller, prop); + delegate(prop, value); + }, + + /** + Transition the application into another route. The route may + be either a single route or route path: + ```javascript + aController.transitionToRoute('blogPosts'); + aController.transitionToRoute('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + aController.transitionToRoute('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + aController.transitionToRoute('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```javascript + App.Router.map(function() { + this.route('blogPost', { path: ':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); + }); + }); + aController.transitionToRoute('blogComment', aPost, aComment); + aController.transitionToRoute('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + aController.transitionToRoute('/'); + aController.transitionToRoute('/blog/post/1/comment/13'); + aController.transitionToRoute('/blog/posts?sort=title'); + ``` + An options hash with a `queryParams` property may be provided as + the final argument to add query parameters to the destination URL. + ```javascript + aController.transitionToRoute('blogPost', 1, { + queryParams: { showComments: 'true' } + }); + // if you just want to transition the query parameters without changing the route + aController.transitionToRoute({ queryParams: { sort: 'date' } }); + ``` + See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). + @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 + @for Ember.ControllerMixin + @method transitionToRoute + @public + */ + transitionToRoute: function () { + // target may be either another controller or a router + var target = _emberMetal.get(this, 'target'); + var method = target.transitionToRoute || target.transitionTo; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(this, args)); + }, + + /** + Transition into another route while replacing the current URL, if possible. + This will replace the current history entry instead of adding a new one. + Beside that, it is identical to `transitionToRoute` in all other respects. + ```javascript + aController.replaceRoute('blogPosts'); + aController.replaceRoute('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + aController.replaceRoute('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + aController.replaceRoute('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```javascript + App.Router.map(function() { + this.route('blogPost', { path: ':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); + }); + }); + aController.replaceRoute('blogComment', aPost, aComment); + aController.replaceRoute('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + aController.replaceRoute('/'); + aController.replaceRoute('/blog/post/1/comment/13'); + ``` + @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. + @for Ember.ControllerMixin + @method replaceRoute + @public + */ + replaceRoute: function () { + // target may be either another controller or a router + var target = _emberMetal.get(this, 'target'); + var method = target.replaceRoute || target.replaceWith; - default: - if (obj === Object) { - return '(Object)'; - } + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - if (obj === Array) { - return '(Array)'; - } + return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(target, args)); + } + }); - ret = GUID_PREFIX + uuid(); + exports.default = _emberRuntime.ControllerMixin; +}); +enifed('ember-routing/ext/run_loop', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - if (obj[GUID_KEY] === null) { - obj[GUID_KEY] = ret; - } else { - GUID_DESC.value = ret; + /** + @module ember + @submodule ember-views + */ - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(GUID_KEY_PROPERTY); - } else { - Object.defineProperty(obj, GUID_KEY, GUID_DESC); - } - } - return ret; - } - } + // Add a new named queue after the 'actions' queue (where RSVP promises + // resolve), which is used in router transitions to prevent unnecessary + // loading state entry if all context promises resolve on the + // 'actions' queue first. + _emberMetal.run._addQueue('routerTransitions', 'actions'); }); -enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString) { - /* - This package will be eagerly parsed and should have no dependencies on external - packages. - - It is intended to be used to share utility methods that will be needed - by every Ember application (and is **not** a dumping ground of useful utilities). - - Utility methods that are needed in < 80% of cases should be placed - elsewhere (so they can be lazily evaluated / parsed). +enifed('ember-routing/index', ['exports', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route', 'ember-routing/system/query_params', 'ember-routing/services/routing', 'ember-routing/services/router', 'ember-routing/system/cache'], function (exports, _emberRoutingExtRun_loop, _emberRoutingExtController, _emberRoutingLocationApi, _emberRoutingLocationNone_location, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingSystemGenerate_controller, _emberRoutingSystemController_for, _emberRoutingSystemDsl, _emberRoutingSystemRouter, _emberRoutingSystemRoute, _emberRoutingSystemQuery_params, _emberRoutingServicesRouting, _emberRoutingServicesRouter, _emberRoutingSystemCache) { + /** + @module ember + @submodule ember-routing */ + + // ES6TODO: Cleanup modules with side-effects below 'use strict'; - exports.symbol = _emberUtilsSymbol.default; - exports.getOwner = _emberUtilsOwner.getOwner; - exports.setOwner = _emberUtilsOwner.setOwner; - exports.OWNER = _emberUtilsOwner.OWNER; - exports.assign = _emberUtilsAssign.default; - exports.EmptyObject = _emberUtilsEmptyObject.default; - exports.dictionary = _emberUtilsDictionary.default; - exports.uuid = _emberUtilsGuid.uuid; - exports.GUID_KEY = _emberUtilsGuid.GUID_KEY; - exports.GUID_DESC = _emberUtilsGuid.GUID_DESC; - exports.GUID_KEY_PROPERTY = _emberUtilsGuid.GUID_KEY_PROPERTY; - exports.generateGuid = _emberUtilsGuid.generateGuid; - exports.guidFor = _emberUtilsGuid.guidFor; - exports.intern = _emberUtilsIntern.default; - exports.checkHasSuper = _emberUtilsSuper.checkHasSuper; - exports.ROOT = _emberUtilsSuper.ROOT; - exports.wrap = _emberUtilsSuper.wrap; - exports.inspect = _emberUtilsInspect.default; - exports.lookupDescriptor = _emberUtilsLookupDescriptor.default; - exports.canInvoke = _emberUtilsInvoke.canInvoke; - exports.tryInvoke = _emberUtilsInvoke.tryInvoke; - exports.makeArray = _emberUtilsMakeArray.default; - exports.applyStr = _emberUtilsApplyStr.default; - exports.NAME_KEY = _emberUtilsName.default; - exports.toString = _emberUtilsToString.default; + exports.Location = _emberRoutingLocationApi.default; + exports.NoneLocation = _emberRoutingLocationNone_location.default; + exports.HashLocation = _emberRoutingLocationHash_location.default; + exports.HistoryLocation = _emberRoutingLocationHistory_location.default; + exports.AutoLocation = _emberRoutingLocationAuto_location.default; + exports.generateController = _emberRoutingSystemGenerate_controller.default; + exports.generateControllerFactory = _emberRoutingSystemGenerate_controller.generateControllerFactory; + exports.controllerFor = _emberRoutingSystemController_for.default; + exports.RouterDSL = _emberRoutingSystemDsl.default; + exports.Router = _emberRoutingSystemRouter.default; + exports.Route = _emberRoutingSystemRoute.default; + exports.QueryParams = _emberRoutingSystemQuery_params.default; + exports.RoutingService = _emberRoutingServicesRouting.default; + exports.RouterService = _emberRoutingServicesRouter.default; + exports.BucketCache = _emberRoutingSystemCache.default; }); -enifed('ember-utils/inspect', ['exports'], function (exports) { +enifed('ember-routing/location/api', ['exports', 'ember-metal', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberMetal, _emberEnvironment, _emberRoutingLocationUtil) { 'use strict'; - exports.default = inspect; - var objectToString = Object.prototype.toString; - /** - Convenience method to inspect an object. This method will attempt to - convert the object into a useful string description. - - It is a pretty simple implementation. If you want something more robust, - use something like JSDump: https://github.com/NV/jsDump - - @method inspect - @for Ember - @param {Object} obj The object you want to inspect. - @return {String} A description of the object - @since 1.4.0 - @private + @module ember + @submodule ember-routing */ - function inspect(obj) { - if (obj === null) { - return 'null'; - } - if (obj === undefined) { - return 'undefined'; - } - if (Array.isArray(obj)) { - return '[' + obj + ']'; - } - // for non objects - var type = typeof obj; - if (type !== 'object' && type !== 'symbol') { - return '' + obj; - } - // overridden toString - if (typeof obj.toString === 'function' && obj.toString !== objectToString) { - return obj.toString(); - } - - // Object.prototype.toString === {}.toString - var v = undefined; - var ret = []; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - v = obj[key]; - if (v === 'toString') { - continue; - } // ignore useless items - if (typeof v === 'function') { - v = 'function() { ... }'; - } - - if (v && typeof v.toString !== 'function') { - ret.push(key + ': ' + objectToString.call(v)); - } else { - ret.push(key + ': ' + v); - } - } - } - return '{' + ret.join(', ') + '}'; - } -}); -enifed("ember-utils/intern", ["exports"], function (exports) { /** - Strongly hint runtimes to intern the provided string. + Ember.Location returns an instance of the correct implementation of + the `location` API. - When do I need to use this function? + ## Implementations - For the most part, never. Pre-mature optimization is bad, and often the - runtime does exactly what you need it to, and more often the trade-off isn't - worth it. + You can pass an implementation name (`hash`, `history`, `none`) to force a + particular implementation to be used in your application. - Why? + ### HashLocation - Runtimes store strings in at least 2 different representations: - Ropes and Symbols (interned strings). The Rope provides a memory efficient - data-structure for strings created from concatenation or some other string - manipulation like splitting. + Using `HashLocation` results in URLs with a `#` (hash sign) separating the + server side URL portion of the URL from the portion that is used by Ember. + This relies upon the `hashchange` event existing in the browser. - Unfortunately checking equality of different ropes can be quite costly as - runtimes must resort to clever string comparison algorithms. These - algorithms typically cost in proportion to the length of the string. - Luckily, this is where the Symbols (interned strings) shine. As Symbols are - unique by their string content, equality checks can be done by pointer - comparison. + Example: - How do I know if my string is a rope or symbol? + ```javascript + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); - Typically (warning general sweeping statement, but truthy in runtimes at - present) static strings created as part of the JS source are interned. - Strings often used for comparisons can be interned at runtime if some - criteria are met. One of these criteria can be the size of the entire rope. - For example, in chrome 38 a rope longer then 12 characters will not - intern, nor will segments of that rope. + App.Router.reopen({ + location: 'hash' + }); + ``` - Some numbers: http://jsperf.com/eval-vs-keys/8 + This will result in a posts.new url of `/#/posts/new`. - Known Trick™ + ### HistoryLocation - @private - @return {String} interned version of the provided string - */ - "use strict"; - - exports.default = intern; - - function intern(str) { - var obj = {}; - obj[str] = 1; - for (var key in obj) { - if (key === str) { - return key; - } - } - return str; - } -}); -enifed('ember-utils/invoke', ['exports', 'ember-utils/apply-str'], function (exports, _emberUtilsApplyStr) { - 'use strict'; - - exports.canInvoke = canInvoke; - exports.tryInvoke = tryInvoke; - - /** - Checks to see if the `methodName` exists on the `obj`. + Using `HistoryLocation` results in URLs that are indistinguishable from a + standard URL. This relies upon the browser's `history` API. + + Example: ```javascript - let foo = { bar: function() { return 'bar'; }, baz: null }; + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); - Ember.canInvoke(foo, 'bar'); // true - Ember.canInvoke(foo, 'baz'); // false - Ember.canInvoke(foo, 'bat'); // false + App.Router.reopen({ + location: 'history' + }); ``` - @method canInvoke - @for Ember - @param {Object} obj The object to check for the method - @param {String} methodName The method name to check for - @return {Boolean} - @private - */ - - function canInvoke(obj, methodName) { - return !!(obj && typeof obj[methodName] === 'function'); - } - - /** - Checks to see if the `methodName` exists on the `obj`, - and if it does, invokes it with the arguments passed. + This will result in a posts.new url of `/posts/new`. + + Keep in mind that your server must serve the Ember app at all the routes you + define. + + ### AutoLocation + + Using `AutoLocation`, the router will use the best Location class supported by + the browser it is running in. + + Browsers that support the `history` API will use `HistoryLocation`, those that + do not, but still support the `hashchange` event will use `HashLocation`, and + in the rare case neither is supported will use `NoneLocation`. + + Example: ```javascript - let d = new Date('03/15/2013'); + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); - Ember.tryInvoke(d, 'getTime'); // 1363320000000 - Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 - Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined + App.Router.reopen({ + location: 'auto' + }); ``` - @method tryInvoke - @for Ember - @param {Object} obj The object to check for the method - @param {String} methodName The method name to check for - @param {Array} [args] The arguments to pass to the method - @return {*} the return value of the invoked method or undefined if it cannot be invoked - @public - */ - - function tryInvoke(obj, methodName, args) { - if (canInvoke(obj, methodName)) { - return args ? _emberUtilsApplyStr.default(obj, methodName, args) : _emberUtilsApplyStr.default(obj, methodName); - } - } -}); -enifed("ember-utils/lookup-descriptor", ["exports"], function (exports) { - "use strict"; - - exports.default = lookupDescriptor; - - function lookupDescriptor(obj, keyName) { - var current = obj; - while (current) { - var descriptor = Object.getOwnPropertyDescriptor(current, keyName); - - if (descriptor) { - return descriptor; - } - - current = Object.getPrototypeOf(current); - } - - return null; - } -}); -enifed("ember-utils/make-array", ["exports"], function (exports) { - /** - Forces the passed object to be part of an array. If the object is already - an array, it will return the object. Otherwise, it will add the object to - an array. If obj is `null` or `undefined`, it will return an empty array. + This will result in a posts.new url of `/posts/new` for modern browsers that + support the `history` api or `/#/posts/new` for older ones, like Internet + Explorer 9 and below. - ```javascript - Ember.makeArray(); // [] - Ember.makeArray(null); // [] - Ember.makeArray(undefined); // [] - Ember.makeArray('lindsay'); // ['lindsay'] - Ember.makeArray([1, 2, 42]); // [1, 2, 42] + When a user visits a link to your application, they will be automatically + upgraded or downgraded to the appropriate `Location` class, with the URL + transformed accordingly, if needed. - let controller = Ember.ArrayProxy.create({ content: [] }); + Keep in mind that since some of your users will use `HistoryLocation`, your + server must serve the Ember app at all the routes you define. - Ember.makeArray(controller) === controller; // true - ``` + ### NoneLocation - @method makeArray - @for Ember - @param {Object} obj the object - @return {Array} - @private - */ - "use strict"; - - exports.default = makeArray; - - function makeArray(obj) { - if (obj === null || obj === undefined) { - return []; - } - return Array.isArray(obj) ? obj : [obj]; - } -}); -enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - 'use strict'; - - exports.default = _emberUtilsSymbol.default('NAME_KEY'); -}); -enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - exports.getOwner = getOwner; - exports.setOwner = setOwner; - var OWNER = _emberUtilsSymbol.default('OWNER'); - - exports.OWNER = OWNER; - /** - Framework objects in an Ember application (components, services, routes, etc.) - are created via a factory and dependency injection system. Each of these - objects is the responsibility of an "owner", which handled its - instantiation and manages its lifetime. + Using `NoneLocation` causes Ember to not store the applications URL state + in the actual URL. This is generally used for testing purposes, and is one + of the changes made when calling `App.setupForTesting()`. - `getOwner` fetches the owner object responsible for an instance. This can - be used to lookup or resolve other class instances, or register new factories - into the owner. + ## Location API - For example, this component dynamically looks up a service based on the - `audioType` passed as an attribute: + Each location implementation must provide the following methods: - ``` - // app/components/play-audio.js + * implementation: returns the string name used to reference the implementation. + * getURL: returns the current URL. + * setURL(path): sets the current URL. + * replaceURL(path): replace the current URL (optional). + * onUpdateURL(callback): triggers the callback when the URL changes. + * formatURL(url): formats `url` to be placed into `href` attribute. + * detect() (optional): instructs the location to do any feature detection + necessary. If the location needs to redirect to a different URL, it + can cancel routing by setting the `cancelRouterSetup` property on itself + to `false`. + + Calling setURL or replaceURL will not trigger onUpdateURL callbacks. + + ## Custom implementation + + Ember scans `app/locations/*` for extending the Location API. + + Example: + + ```javascript import Ember from 'ember'; - // Usage: - // - // {{play-audio audioType=model.audioType audioFile=model.file}} - // - export default Ember.Component.extend({ - audioService: Ember.computed('audioType', function() { - let owner = Ember.getOwner(this); - return owner.lookup(`service:${this.get('audioType')}`); - }), - click() { - let player = this.get('audioService'); - player.play(this.get('audioFile')); + export default Ember.HistoryLocation.extend({ + implementation: 'history-url-logging', + + pushState: function (path) { + console.log(path); + this._super.apply(this, arguments); } }); ``` - @method getOwner - @for Ember - @param {Object} object An object with an owner. - @return {Object} An owner object. - @since 2.3.0 - @public - */ - - function getOwner(object) { - return object[OWNER]; - } - - /** - `setOwner` forces a new owner on a given object instance. This is primarily - useful in some testing cases. - - @method setOwner - @for Ember - @param {Object} object An object with an owner. - @return {Object} An owner object. - @since 2.3.0 - @public + @class Location + @namespace Ember + @static + @private */ + exports.default = { + /** + This is deprecated in favor of using the container to lookup the location + implementation as desired. + For example: + ```javascript + // Given a location registered as follows: + container.register('location:history-test', HistoryTestLocation); + // You could create a new instance via: + container.lookup('location:history-test'); + ``` + @method create + @param {Object} options + @return {Object} an instance of an implementation of the `location` API + @deprecated Use the container to lookup the location implementation that you + need. + @private + */ + create: function (options) { + var implementation = options && options.implementation; + _emberMetal.assert('Ember.Location.create: you must specify a \'implementation\' option', !!implementation); - function setOwner(object, owner) { - object[OWNER] = owner; - } -}); -enifed('ember-utils/super', ['exports'], function (exports) { - 'use strict'; - - exports.wrap = wrap; - var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/; - var fnToString = Function.prototype.toString; + var implementationClass = this.implementations[implementation]; + _emberMetal.assert('Ember.Location.create: ' + implementation + ' is not a valid implementation', !!implementationClass); - var checkHasSuper = (function () { - var sourceAvailable = fnToString.call(function () { - return this; - }).indexOf('return this') > -1; + return implementationClass.create.apply(implementationClass, arguments); + }, - if (sourceAvailable) { - return function checkHasSuper(func) { - return HAS_SUPER_PATTERN.test(fnToString.call(func)); - }; - } + implementations: {}, + _location: _emberEnvironment.environment.location, - return function checkHasSuper() { - return true; - }; - })(); + /** + Returns the current `location.hash` by parsing location.href since browsers + inconsistently URL-decode `location.hash`. + https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + @private + @method getHash + @since 1.4.0 + */ + _getHash: function () { + return _emberRoutingLocationUtil.getHash(this.location); + } + }; +}); +enifed('ember-routing/location/auto_location', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberRoutingLocationUtil) { + 'use strict'; - exports.checkHasSuper = checkHasSuper; - function ROOT() {} - ROOT.__hasSuper = false; + exports.getHistoryPath = getHistoryPath; + exports.getHashPath = getHashPath; - function hasSuper(func) { - if (func.__hasSuper === undefined) { - func.__hasSuper = checkHasSuper(func); - } - return func.__hasSuper; - } + /** + @module ember + @submodule ember-routing + */ /** - Wraps the passed function so that `this._super` will point to the superFunc - when the function is invoked. This is the primitive we use to implement - calls to super. + Ember.AutoLocation will select the best location option based off browser + support with the priority order: history, hash, none. + + Clean pushState paths accessed by hashchange-only browsers will be redirected + to the hash-equivalent and vice versa so future transitions are consistent. + Keep in mind that since some of your users will use `HistoryLocation`, your + server must serve the Ember app at all the routes you define. + + @class AutoLocation + @namespace Ember + @static @private - @method wrap - @for Ember - @param {Function} func The function to call - @param {Function} superFunc The super function. - @return {Function} wrapped function. */ + exports.default = _emberRuntime.Object.extend({ + /** + @private + The browser's `location` object. This is typically equivalent to + `window.location`, but may be overridden for testing. + @property location + @default environment.location + */ + location: _emberEnvironment.environment.location, - function wrap(func, superFunc) { - if (!hasSuper(func)) { - return func; - } - // ensure an unwrapped super that calls _super is wrapped with a terminal _super - if (!superFunc.wrappedFunction && hasSuper(superFunc)) { - return _wrap(func, _wrap(superFunc, ROOT)); - } - return _wrap(func, superFunc); - } - - function _wrap(func, superFunc) { - function superWrapper() { - var orig = this._super; - this._super = superFunc; - var ret = func.apply(this, arguments); - this._super = orig; - return ret; - } - - superWrapper.wrappedFunction = func; - superWrapper.__ember_observes__ = func.__ember_observes__; - superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__; - superWrapper.__ember_listens__ = func.__ember_listens__; + /** + @private + The browser's `history` object. This is typically equivalent to + `window.history`, but may be overridden for testing. + @since 1.5.1 + @property history + @default environment.history + */ + history: _emberEnvironment.environment.history, - return superWrapper; - } -}); -enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern'], function (exports, _emberUtilsGuid, _emberUtilsIntern) { - 'use strict'; + /** + @private + The user agent's global variable. In browsers, this will be `window`. + @since 1.11 + @property global + @default window + */ + global: _emberEnvironment.environment.window, - exports.default = symbol; + /** + @private + The browser's `userAgent`. This is typically equivalent to + `navigator.userAgent`, but may be overridden for testing. + @since 1.5.1 + @property userAgent + @default environment.history + */ + userAgent: _emberEnvironment.environment.userAgent, - function symbol(debugName) { - // TODO: Investigate using platform symbols, but we do not - // want to require non-enumerability for this API, which - // would introduce a large cost. + /** + @private + This property is used by the router to know whether to cancel the routing + setup process, which is needed while we redirect the browser. + @since 1.5.1 + @property cancelRouterSetup + @default false + */ + cancelRouterSetup: false, - return _emberUtilsIntern.default(debugName + ' [id=' + _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()) + ']'); - } -}); -enifed('ember-utils/to-string', ['exports'], function (exports) { - 'use strict'; + /** + @private + Will be pre-pended to path upon state change. + @since 1.5.1 + @property rootURL + @default '/' + */ + rootURL: '/', - exports.default = toString; - var objectToString = Object.prototype.toString; + /** + Called by the router to instruct the location to do any feature detection + necessary. In the case of AutoLocation, we detect whether to use history + or hash concrete implementations. + @private + */ + detect: function () { + var rootURL = this.rootURL; - /* - A `toString` util function that supports objects without a `toString` - method, e.g. an object created with `Object.create(null)`. - */ + _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); - function toString(obj) { - if (obj && typeof obj.toString === 'function') { - return obj.toString(); - } else { - return objectToString.call(obj); - } - } -}); -enifed('ember-views/compat/attrs', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + var implementation = detectImplementation({ + location: this.location, + history: this.history, + userAgent: this.userAgent, + rootURL: rootURL, + documentMode: this.documentMode, + global: this.global + }); - var MUTABLE_CELL = _emberUtils.symbol('MUTABLE_CELL'); - exports.MUTABLE_CELL = MUTABLE_CELL; -}); -enifed('ember-views/compat/fallback-view-registry', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + if (implementation === false) { + _emberMetal.set(this, 'cancelRouterSetup', true); + implementation = 'none'; + } - exports.default = _emberUtils.dictionary(null); -}); -enifed('ember-views/component_lookup', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { - 'use strict'; + var concrete = _emberUtils.getOwner(this).lookup('location:' + implementation); + _emberMetal.set(concrete, 'rootURL', rootURL); - exports.default = _emberRuntime.Object.extend({ - componentFor: function (name, owner, options) { - _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); + _emberMetal.assert('Could not find location \'' + implementation + '\'.', !!concrete); - var fullName = 'component:' + name; - return owner._lookupFactory(fullName, options); + _emberMetal.set(this, 'concreteImplementation', concrete); }, - layoutFor: function (name, owner, options) { - _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); + initState: delegateToConcreteImplementation('initState'), + getURL: delegateToConcreteImplementation('getURL'), + setURL: delegateToConcreteImplementation('setURL'), + replaceURL: delegateToConcreteImplementation('replaceURL'), + onUpdateURL: delegateToConcreteImplementation('onUpdateURL'), + formatURL: delegateToConcreteImplementation('formatURL'), - var templateFullName = 'template:components/' + name; - return owner.lookup(templateFullName, options); + willDestroy: function () { + var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); + + if (concreteImplementation) { + concreteImplementation.destroy(); + } } }); -}); -enifed('ember-views/index', ['exports', 'ember-views/system/ext', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/system/event_dispatcher', 'ember-views/component_lookup', 'ember-views/mixins/text_support', 'ember-views/views/core_view', 'ember-views/mixins/class_names_support', 'ember-views/mixins/child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/view_support', 'ember-views/mixins/action_support', 'ember-views/compat/attrs', 'ember-views/system/lookup_partial', 'ember-views/utils/lookup-component', 'ember-views/system/action_manager', 'ember-views/compat/fallback-view-registry'], function (exports, _emberViewsSystemExt, _emberViewsSystemJquery, _emberViewsSystemUtils, _emberViewsSystemEvent_dispatcher, _emberViewsComponent_lookup, _emberViewsMixinsText_support, _emberViewsViewsCore_view, _emberViewsMixinsClass_names_support, _emberViewsMixinsChild_views_support, _emberViewsMixinsView_state_support, _emberViewsMixinsView_support, _emberViewsMixinsAction_support, _emberViewsCompatAttrs, _emberViewsSystemLookup_partial, _emberViewsUtilsLookupComponent, _emberViewsSystemAction_manager, _emberViewsCompatFallbackViewRegistry) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; + function delegateToConcreteImplementation(methodName) { + return function () { + var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); + _emberMetal.assert('AutoLocation\'s detect() method should be called before calling any other hooks.', !!concreteImplementation); - exports.jQuery = _emberViewsSystemJquery.default; - exports.isSimpleClick = _emberViewsSystemUtils.isSimpleClick; - exports.getViewBounds = _emberViewsSystemUtils.getViewBounds; - exports.getViewClientRects = _emberViewsSystemUtils.getViewClientRects; - exports.getViewBoundingClientRect = _emberViewsSystemUtils.getViewBoundingClientRect; - exports.getRootViews = _emberViewsSystemUtils.getRootViews; - exports.getChildViews = _emberViewsSystemUtils.getChildViews; - exports.getViewId = _emberViewsSystemUtils.getViewId; - exports.getViewElement = _emberViewsSystemUtils.getViewElement; - exports.setViewElement = _emberViewsSystemUtils.setViewElement; - exports.STYLE_WARNING = _emberViewsSystemUtils.STYLE_WARNING; - exports.EventDispatcher = _emberViewsSystemEvent_dispatcher.default; - exports.ComponentLookup = _emberViewsComponent_lookup.default; - exports.TextSupport = _emberViewsMixinsText_support.default; - exports.CoreView = _emberViewsViewsCore_view.default; - exports.ClassNamesSupport = _emberViewsMixinsClass_names_support.default; - exports.ChildViewsSupport = _emberViewsMixinsChild_views_support.default; - exports.ViewStateSupport = _emberViewsMixinsView_state_support.default; - exports.ViewMixin = _emberViewsMixinsView_support.default; - exports.ActionSupport = _emberViewsMixinsAction_support.default; - exports.MUTABLE_CELL = _emberViewsCompatAttrs.MUTABLE_CELL; - exports.lookupPartial = _emberViewsSystemLookup_partial.default; - exports.hasPartial = _emberViewsSystemLookup_partial.hasPartial; - exports.lookupComponent = _emberViewsUtilsLookupComponent.default; - exports.ActionManager = _emberViewsSystemAction_manager.default; - exports.fallbackViewRegistry = _emberViewsCompatFallbackViewRegistry.default; -}); -// for the side effect of extending Ember.run.queues -enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/compat/attrs'], function (exports, _emberUtils, _emberMetal, _emberViewsCompatAttrs) { - /** - @module ember - @submodule ember-views + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _emberUtils.tryInvoke(concreteImplementation, methodName, args); + }; + } + + /* + Given the browser's `location`, `history` and `userAgent`, and a configured + root URL, this function detects whether the browser supports the [History + API](https://developer.mozilla.org/en-US/docs/Web/API/History) and returns a + string representing the Location object to use based on its determination. + + For example, if the page loads in an evergreen browser, this function would + return the string "history", meaning the history API and thus HistoryLocation + should be used. If the page is loaded in IE8, it will return the string + "hash," indicating that the History API should be simulated by manipulating the + hash portion of the location. + */ - 'use strict'; - function validateAction(component, actionName) { - if (actionName && actionName[_emberViewsCompatAttrs.MUTABLE_CELL]) { - actionName = actionName.value; + function detectImplementation(options) { + var location = options.location; + var userAgent = options.userAgent; + var history = options.history; + var documentMode = options.documentMode; + var global = options.global; + var rootURL = options.rootURL; + + var implementation = 'none'; + var cancelRouterSetup = false; + var currentPath = _emberRoutingLocationUtil.getFullPath(location); + + if (_emberRoutingLocationUtil.supportsHistory(userAgent, history)) { + var historyPath = getHistoryPath(rootURL, location); + + // If the browser supports history and we have a history path, we can use + // the history location with no redirects. + if (currentPath === historyPath) { + return 'history'; + } else { + if (currentPath.substr(0, 2) === '/#') { + history.replaceState({ path: historyPath }, null, historyPath); + implementation = 'history'; + } else { + cancelRouterSetup = true; + _emberRoutingLocationUtil.replacePath(location, historyPath); + } + } + } else if (_emberRoutingLocationUtil.supportsHashChange(documentMode, global)) { + var hashPath = getHashPath(rootURL, location); + + // Be sure we're using a hashed path, otherwise let's switch over it to so + // we start off clean and consistent. We'll count an index path with no + // hash as "good enough" as well. + if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') { + implementation = 'hash'; + } else { + // Our URL isn't in the expected hash-supported format, so we want to + // cancel the router setup and replace the URL to start off clean + cancelRouterSetup = true; + _emberRoutingLocationUtil.replacePath(location, hashPath); + } } - _emberMetal.assert('The default action was triggered on the component ' + component.toString() + ', but the action name (' + actionName + ') was not a string.', _emberMetal.isNone(actionName) || typeof actionName === 'string' || typeof actionName === 'function'); - return actionName; + if (cancelRouterSetup) { + return false; + } + + return implementation; } /** - @class ActionSupport - @namespace Ember - @private + @private + + Returns the current path as it should appear for HistoryLocation supported + browsers. This may very well differ from the real current path (e.g. if it + starts off as a hashed URL) */ - exports.default = _emberMetal.Mixin.create({ - /** - Calls an action passed to a component. - For example a component for playing or pausing music may translate click events - into action notifications of "play" or "stop" depending on some internal state - of the component: - ```javascript - // app/components/play-button.js - export default Ember.Component.extend({ - click() { - if (this.get('isPlaying')) { - this.sendAction('play'); - } else { - this.sendAction('stop'); - } - } - }); - ``` - The actions "play" and "stop" must be passed to this `play-button` component: - ```handlebars - {{! app/templates/application.hbs }} - {{play-button play=(action "musicStarted") stop=(action "musicStopped")}} - ``` - When the component receives a browser `click` event it translate this - interaction into application-specific semantics ("play" or "stop") and - calls the specified action. - ```javascript - // app/controller/application.js - export default Ember.Controller.extend({ - actions: { - musicStarted() { - // called when the play button is clicked - // and the music started playing - }, - musicStopped() { - // called when the play button is clicked - // and the music stopped playing - } - } - }); - ``` - If no action is passed to `sendAction` a default name of "action" - is assumed. - ```javascript - // app/components/next-button.js - export default Ember.Component.extend({ - click() { - this.sendAction(); - } - }); - ``` - ```handlebars - {{! app/templates/application.hbs }} - {{next-button action=(action "playNextSongInAlbum")}} - ``` - ```javascript - // app/controllers/application.js - App.ApplicationController = Ember.Controller.extend({ - actions: { - playNextSongInAlbum() { - ... - } - } - }); - ``` - @method sendAction - @param [action] {String} the action to call - @param [params] {*} arguments for the action - @public - */ - sendAction: function (action) { - for (var _len = arguments.length, contexts = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - contexts[_key - 1] = arguments[_key]; - } - var actionName = undefined; + function getHistoryPath(rootURL, location) { + var path = _emberRoutingLocationUtil.getPath(location); + var hash = _emberRoutingLocationUtil.getHash(location); + var query = _emberRoutingLocationUtil.getQuery(location); + var rootURLIndex = path.indexOf(rootURL); + var routeHash = undefined, + hashParts = undefined; - // Send the default action - if (action === undefined) { - action = 'action'; - } - actionName = _emberMetal.get(this, 'attrs.' + action) || _emberMetal.get(this, action); - actionName = validateAction(this, actionName); + _emberMetal.assert('Path ' + path + ' does not start with the provided rootURL ' + rootURL, rootURLIndex === 0); - // If no action name for that action could be found, just abort. - if (actionName === undefined) { - return; - } + // By convention, Ember.js routes using HashLocation are required to start + // with `#/`. Anything else should NOT be considered a route and should + // be passed straight through, without transformation. + if (hash.substr(0, 2) === '#/') { + // There could be extra hash segments after the route + hashParts = hash.substr(1).split('#'); + // The first one is always the route url + routeHash = hashParts.shift(); - if (typeof actionName === 'function') { - actionName.apply(undefined, contexts); - } else { - this.triggerAction({ - action: actionName, - actionContext: contexts - }); + // If the path already has a trailing slash, remove the one + // from the hashed route so we don't double up. + if (path.charAt(path.length - 1) === '/') { + routeHash = routeHash.substr(1); } - }, - send: function (actionName) { - for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - args[_key2 - 1] = arguments[_key2]; + // This is the "expected" final order + path += routeHash + query; + + if (hashParts.length) { + path += '#' + hashParts.join('#'); } + } else { + path += query + hash; + } - var action = this.actions && this.actions[actionName]; + return path; + } - if (action) { - var shouldBubble = action.apply(this, args) === true; - if (!shouldBubble) { - return; - } - } + /** + @private + + Returns the current path as it should appear for HashLocation supported + browsers. This may very well differ from the real current path. + + @method _getHashPath + */ - var target = _emberMetal.get(this, 'target'); - if (target) { - _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); - } else { - _emberMetal.assert(_emberUtils.inspect(this) + ' had no action handler for: ' + actionName, action); + function getHashPath(rootURL, location) { + var path = rootURL; + var historyPath = getHistoryPath(rootURL, location); + var routePath = historyPath.substr(rootURL.length); + + if (routePath !== '') { + if (routePath[0] !== '/') { + routePath = '/' + routePath; } + + path += '#' + routePath; } - }); + + return path; + } }); -enifed('ember-views/mixins/child_views_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/system/utils'], function (exports, _emberUtils, _emberMetal, _emberViewsSystemUtils) { +enifed('ember-routing/location/hash_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { + 'use strict'; + /** @module ember - @submodule ember-views + @submodule ember-routing */ - 'use strict'; - exports.default = _emberMetal.Mixin.create({ + /** + `Ember.HashLocation` implements the location API using the browser's + hash. At present, it relies on a `hashchange` event existing in the + browser. + + @class HashLocation + @namespace Ember + @extends Ember.Object + @private + */ + exports.default = _emberRuntime.Object.extend({ + implementation: 'hash', + init: function () { - this._super.apply(this, arguments); - _emberViewsSystemUtils.initChildViews(this); + _emberMetal.set(this, 'location', _emberMetal.get(this, '_location') || window.location); + + this._hashchangeHandler = undefined; }, /** - Array of child views. You should never edit this array directly. - @property childViews - @type Array - @default [] @private + Returns normalized location.hash + @since 1.5.1 + @method getHash */ - childViews: _emberMetal.descriptor({ - configurable: false, - enumerable: false, - get: function () { - return _emberViewsSystemUtils.getChildViews(this); + getHash: _emberRoutingLocationApi.default._getHash, + + /** + Returns the normalized URL, constructed from `location.hash`. + e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. + By convention, hashed paths must begin with a forward slash, otherwise they + are not treated as a path so we can distinguish intent. + @private + @method getURL + */ + getURL: function () { + var originalPath = this.getHash().substr(1); + var outPath = originalPath; + + if (outPath[0] !== '/') { + outPath = '/'; + + // Only add the # if the path isn't empty. + // We do NOT want `/#` since the ampersand + // is only included (conventionally) when + // the location.hash has a value + if (originalPath) { + outPath += '#' + originalPath; + } } - }), - appendChild: function (view) { - this.linkChild(view); - _emberViewsSystemUtils.addChildView(this, view); + return outPath; }, - linkChild: function (instance) { - if (!_emberUtils.getOwner(instance)) { - _emberUtils.setOwner(instance, _emberUtils.getOwner(this)); - } - } - }); -}); -enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-views - */ + /** + Set the `location.hash` and remembers what was set. This prevents + `onUpdateURL` callbacks from triggering when the hash was set by + `HashLocation`. + @private + @method setURL + @param path {String} + */ + setURL: function (path) { + _emberMetal.get(this, 'location').hash = path; + _emberMetal.set(this, 'lastSetURL', path); + }, - 'use strict'; + /** + Uses location.replace to update the url without a page reload + or history modification. + @private + @method replaceURL + @param path {String} + */ + replaceURL: function (path) { + _emberMetal.get(this, 'location').replace('#' + path); + _emberMetal.set(this, 'lastSetURL', path); + }, - var EMPTY_ARRAY = Object.freeze([]); + /** + Register a callback to be invoked when the hash changes. These + callbacks will execute when the user presses the back or forward + button, but not after `setURL` is invoked. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + var _this = this; - /** - @class ClassNamesSupport - @namespace Ember - @private - */ - exports.default = _emberMetal.Mixin.create({ - concatenatedProperties: ['classNames', 'classNameBindings'], + this._removeEventListener(); - init: function () { - this._super.apply(this, arguments); + this._hashchangeHandler = function () { + _emberMetal.run(function () { + var path = _this.getURL(); + if (_emberMetal.get(_this, 'lastSetURL') === path) { + return; + } - _emberMetal.assert('Only arrays are allowed for \'classNameBindings\'', Array.isArray(this.classNameBindings)); - _emberMetal.assert('Only arrays of static class strings are allowed for \'classNames\'. For dynamic classes, use \'classNameBindings\'.', Array.isArray(this.classNames)); + _emberMetal.set(_this, 'lastSetURL', null); + + callback(path); + }); + }; + + window.addEventListener('hashchange', this._hashchangeHandler); }, /** - Standard CSS class names to apply to the view's outer element. This - property automatically inherits any class names defined by the view's - superclasses as well. - @property classNames - @type Array - @default ['ember-view'] - @public + Given a URL, formats it to be placed into the page as part + of an element's `href` attribute. + This is used, for example, when using the {{action}} helper + to generate a URL based on an event. + @private + @method formatURL + @param url {String} */ - classNames: EMPTY_ARRAY, + formatURL: function (url) { + return '#' + url; + }, /** - A list of properties of the view to apply as class names. If the property - is a string value, the value of that string will be applied as a class - name. - ```javascript - // Applies the 'high' class to the view element - Ember.Component.extend({ - classNameBindings: ['priority'], - priority: 'high' - }); - ``` - If the value of the property is a Boolean, the name of that property is - added as a dasherized class name. - ```javascript - // Applies the 'is-urgent' class to the view element - Ember.Component.extend({ - classNameBindings: ['isUrgent'], - isUrgent: true - }); - ``` - If you would prefer to use a custom value instead of the dasherized - property name, you can pass a binding like this: - ```javascript - // Applies the 'urgent' class to the view element - Ember.Component.extend({ - classNameBindings: ['isUrgent:urgent'], - isUrgent: true - }); - ``` - This list of properties is inherited from the component's superclasses as well. - @property classNameBindings - @type Array - @default [] - @public + Cleans up the HashLocation event listener. + @private + @method willDestroy */ - classNameBindings: EMPTY_ARRAY + willDestroy: function () { + this._removeEventListener(); + }, + + _removeEventListener: function () { + if (this._hashchangeHandler) { + window.removeEventListener('hashchange', this._hashchangeHandler); + } + } }); }); -enifed('ember-views/mixins/text_support', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { +enifed('ember-routing/location/history_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { + 'use strict'; + /** @module ember - @submodule ember-views + @submodule ember-routing */ - 'use strict'; + var popstateFired = false; - var KEY_EVENTS = { - 13: 'insertNewline', - 27: 'cancel' - }; + var _uuid = undefined; + + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + _uuid = function _uuid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r, v; + r = Math.random() * 16 | 0; + v = c === 'x' ? r : r & 3 | 8; + return v.toString(16); + }); + }; + } /** - `TextSupport` is a shared mixin used by both `Ember.TextField` and - `Ember.TextArea`. `TextSupport` adds a number of methods that allow you to - specify a controller action to invoke when a certain event is fired on your - text field or textarea. The specifed controller action would get the current - value of the field passed in as the only argument unless the value of - the field is empty. In that case, the instance of the field itself is passed - in as the only argument. - - Let's use the pressing of the escape key as an example. If you wanted to - invoke a controller action when a user presses the escape key while on your - field, you would use the `escape-press` attribute on your field like so: - - ```handlebars - {{! application.hbs}} - - {{input escape-press='alertUser'}} - ``` - - ```javascript - App = Ember.Application.create(); - - App.ApplicationController = Ember.Controller.extend({ - actions: { - alertUser: function ( currentValue ) { - alert( 'escape pressed, current value: ' + currentValue ); - } - } - }); - ``` - - The following chart is a visual representation of what takes place when the - escape key is pressed in this scenario: - - ``` - The Template - +---------------------------+ - | | - | escape-press='alertUser' | - | | TextSupport Mixin - +----+----------------------+ +-------------------------------+ - | | cancel method | - | escape button pressed | | - +-------------------------------> | checks for the `escape-press` | - | attribute and pulls out the | - +-------------------------------+ | `alertUser` value | - | action name 'alertUser' +-------------------------------+ - | sent to controller - v - Controller - +------------------------------------------ + - | | - | actions: { | - | alertUser: function( currentValue ){ | - | alert( 'the esc key was pressed!' ) | - | } | - | } | - | | - +-------------------------------------------+ - ``` - - Here are the events that we currently support along with the name of the - attribute you would need to use on your field. To reiterate, you would use the - attribute name like so: - - ```handlebars - {{input attribute-name='controllerAction'}} - ``` - - ``` - +--------------------+----------------+ - | | | - | event | attribute name | - +--------------------+----------------+ - | new line inserted | insert-newline | - | | | - | enter key pressed | insert-newline | - | | | - | cancel key pressed | escape-press | - | | | - | focusin | focus-in | - | | | - | focusout | focus-out | - | | | - | keypress | key-press | - | | | - | keyup | key-up | - | | | - | keydown | key-down | - +--------------------+----------------+ - ``` + Ember.HistoryLocation implements the location API using the browser's + history.pushState API. - @class TextSupport + @class HistoryLocation @namespace Ember - @uses Ember.TargetActionSupport - @extends Ember.Mixin + @extends Ember.Object @private */ - exports.default = _emberMetal.Mixin.create(_emberRuntime.TargetActionSupport, { - value: '', - - attributeBindings: ['autocapitalize', 'autocorrect', 'autofocus', 'disabled', 'form', 'maxlength', 'placeholder', 'readonly', 'required', 'selectionDirection', 'spellcheck', 'tabindex', 'title'], - placeholder: null, - disabled: false, - maxlength: null, + exports.default = _emberRuntime.Object.extend({ + implementation: 'history', init: function () { this._super.apply(this, arguments); - this.on('paste', this, this._elementValueDidChange); - this.on('cut', this, this._elementValueDidChange); - this.on('input', this, this._elementValueDidChange); + + var base = document.querySelector('base'); + var baseURL = ''; + if (base) { + baseURL = base.getAttribute('href'); + } + + _emberMetal.set(this, 'baseURL', baseURL); + _emberMetal.set(this, 'location', _emberMetal.get(this, 'location') || window.location); + + this._popstateHandler = undefined; }, /** - The action to be sent when the user presses the return key. - This is similar to the `{{action}}` helper, but is fired when - the user presses the return key when editing a text field, and sends - the value of the field as the context. - @property action - @type String - @default null - @private + Used to set state on first call to setURL + @private + @method initState */ - action: null, + initState: function () { + var history = _emberMetal.get(this, 'history') || window.history; + _emberMetal.set(this, 'history', history); + + if (history && 'state' in history) { + this.supportsHistory = true; + } + + this.replaceState(this.formatURL(this.getURL())); + }, /** - The event that should send the action. - Options are: - * `enter`: the user pressed enter - * `keyPress`: the user pressed a key - @property onEvent - @type String - @default enter + Will be pre-pended to path upon state change + @property rootURL + @default '/' @private */ - onEvent: 'enter', + rootURL: '/', /** - Whether the `keyUp` event that triggers an `action` to be sent continues - propagating to other views. - By default, when the user presses the return key on their keyboard and - the text field has an `action` set, the action will be sent to the view's - controller and the key event will stop propagating. - If you would like parent views to receive the `keyUp` event even after an - action has been dispatched, set `bubbles` to true. - @property bubbles - @type Boolean - @default false - @private + Returns the current `location.pathname` without `rootURL` or `baseURL` + @private + @method getURL + @return url {String} */ - bubbles: false, + getURL: function () { + var location = _emberMetal.get(this, 'location'); + var path = location.pathname; - interpretKeyEvents: function (event) { - var map = KEY_EVENTS; - var method = map[event.keyCode]; + var rootURL = _emberMetal.get(this, 'rootURL'); + var baseURL = _emberMetal.get(this, 'baseURL'); - this._elementValueDidChange(); - if (method) { - return this[method](event); - } - }, + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); + baseURL = baseURL.replace(/\/$/, ''); - _elementValueDidChange: function () { - _emberMetal.set(this, 'value', this.element.value); - }, + // remove baseURL and rootURL from start of path + var url = path.replace(new RegExp('^' + baseURL + '(?=/|$)'), '').replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - change: function (event) { - this._elementValueDidChange(event); - }, + var search = location.search || ''; + url += search + this.getHash(); - /** - Allows you to specify a controller action to invoke when either the `enter` - key is pressed or, in the case of the field being a textarea, when a newline - is inserted. To use this method, give your field an `insert-newline` - attribute. The value of that attribute should be the name of the action - in your controller that you wish to invoke. - For an example on how to use the `insert-newline` attribute, please - reference the example near the top of this file. - @method insertNewline - @param {Event} event - @private - */ - insertNewline: function (event) { - sendAction('enter', this, event); - sendAction('insert-newline', this, event); + return url; }, /** - Allows you to specify a controller action to invoke when the escape button - is pressed. To use this method, give your field an `escape-press` - attribute. The value of that attribute should be the name of the action - in your controller that you wish to invoke. - For an example on how to use the `escape-press` attribute, please reference - the example near the top of this file. - @method cancel - @param {Event} event - @private + Uses `history.pushState` to update the url without a page reload. + @private + @method setURL + @param path {String} */ - cancel: function (event) { - sendAction('escape-press', this, event); - }, + setURL: function (path) { + var state = this.getState(); + path = this.formatURL(path); - /** - Allows you to specify a controller action to invoke when a field receives - focus. To use this method, give your field a `focus-in` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `focus-in` attribute, please reference the - example near the top of this file. - @method focusIn - @param {Event} event - @private - */ - focusIn: function (event) { - sendAction('focus-in', this, event); + if (!state || state.path !== path) { + this.pushState(path); + } }, /** - Allows you to specify a controller action to invoke when a field loses - focus. To use this method, give your field a `focus-out` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `focus-out` attribute, please reference the - example near the top of this file. - @method focusOut - @param {Event} event - @private + Uses `history.replaceState` to update the url without a page reload + or history modification. + @private + @method replaceURL + @param path {String} */ - focusOut: function (event) { - this._elementValueDidChange(event); - sendAction('focus-out', this, event); - }, + replaceURL: function (path) { + var state = this.getState(); + path = this.formatURL(path); - /** - Allows you to specify a controller action to invoke when a key is pressed. - To use this method, give your field a `key-press` attribute. The value of - that attribute should be the name of the action in your controller you - that wish to invoke. - For an example on how to use the `key-press` attribute, please reference the - example near the top of this file. - @method keyPress - @param {Event} event - @private - */ - keyPress: function (event) { - sendAction('key-press', this, event); + if (!state || state.path !== path) { + this.replaceState(path); + } }, /** - Allows you to specify a controller action to invoke when a key-up event is - fired. To use this method, give your field a `key-up` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `key-up` attribute, please reference the - example near the top of this file. - @method keyUp - @param {Event} event - @private + Get the current `history.state`. Checks for if a polyfill is + required and if so fetches this._historyState. The state returned + from getState may be null if an iframe has changed a window's + history. + The object returned will contain a `path` for the given state as well + as a unique state `id`. The state index will allow the app to distinguish + between two states with similar paths but should be unique from one another. + @private + @method getState + @return state {Object} */ - keyUp: function (event) { - this.interpretKeyEvents(event); + getState: function () { + if (this.supportsHistory) { + return _emberMetal.get(this, 'history').state; + } - this.sendAction('key-up', _emberMetal.get(this, 'value'), event); + return this._historyState; }, /** - Allows you to specify a controller action to invoke when a key-down event is - fired. To use this method, give your field a `key-down` attribute. The value - of that attribute should be the name of the action in your controller that - you wish to invoke. - For an example on how to use the `key-down` attribute, please reference the - example near the top of this file. - @method keyDown - @param {Event} event + Pushes a new state. @private + @method pushState + @param path {String} */ - keyDown: function (event) { - this.sendAction('key-down', _emberMetal.get(this, 'value'), event); - } - }); - - // In principle, this shouldn't be necessary, but the legacy - // sendAction semantics for TextField are different from - // the component semantics so this method normalizes them. - function sendAction(eventName, view, event) { - var action = _emberMetal.get(view, 'attrs.' + eventName) || _emberMetal.get(view, eventName); - var on = _emberMetal.get(view, 'onEvent'); - var value = _emberMetal.get(view, 'value'); - - // back-compat support for keyPress as an event name even though - // it's also a method name that consumes the event (and therefore - // incompatible with sendAction semantics). - if (on === eventName || on === 'keyPress' && eventName === 'key-press') { - view.sendAction('action', value); - } + pushState: function (path) { + var state = { path: path }; + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + state.uuid = _uuid(); + } - view.sendAction(eventName, value); + _emberMetal.get(this, 'history').pushState(state, null, path); - if (action || on === eventName) { - if (!_emberMetal.get(view, 'bubbles')) { - event.stopPropagation(); - } - } - } -}); -enifed('ember-views/mixins/view_state_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; + this._historyState = state; - exports.default = _emberMetal.Mixin.create({ - _transitionTo: function (state) { - var priorState = this._currentState; - var currentState = this._currentState = this._states[state]; - this._state = state; + // used for webkit workaround + this._previousURL = this.getURL(); + }, - if (priorState && priorState.exit) { - priorState.exit(this); - } - if (currentState.enter) { - currentState.enter(this); + /** + Replaces the current state. + @private + @method replaceState + @param path {String} + */ + replaceState: function (path) { + var state = { path: path }; + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + state.uuid = _uuid(); } - } - }); -}); -enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-views/system/utils', 'ember-runtime/system/core_object', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberViewsSystemUtils, _emberRuntimeSystemCore_object, _emberViewsSystemJquery) { - 'use strict'; - var _Mixin$create; - - function K() { - return this; - } + _emberMetal.get(this, 'history').replaceState(state, null, path); - /** - @class ViewMixin - @namespace Ember - @private - */ - exports.default = _emberMetal.Mixin.create((_Mixin$create = { - concatenatedProperties: ['attributeBindings'] - }, _Mixin$create[_emberRuntimeSystemCore_object.POST_INIT] = function () { - this.trigger('didInitAttrs', { attrs: this.attrs }); - this.trigger('didReceiveAttrs', { newAttrs: this.attrs }); - }, _Mixin$create.nearestOfType = function (klass) { - var view = this.parentView; - var isOfType = klass instanceof _emberMetal.Mixin ? function (view) { - return klass.detect(view); - } : function (view) { - return klass.detect(view.constructor); - }; + this._historyState = state; - while (view) { - if (isOfType(view)) { - return view; - } - view = view.parentView; - } - }, _Mixin$create.nearestWithProperty = function (property) { - var view = this.parentView; + // used for webkit workaround + this._previousURL = this.getURL(); + }, - while (view) { - if (property in view) { - return view; - } - view = view.parentView; - } - }, _Mixin$create.rerender = function () { - return this._currentState.rerender(this); - }, _Mixin$create.element = _emberMetal.descriptor({ - configurable: false, - enumerable: false, - get: function () { - return this.renderer.getElement(this); - } - }), _Mixin$create.$ = function (sel) { - _emberMetal.assert('You cannot access this.$() on a component with `tagName: \'\'` specified.', this.tagName !== ''); - return this._currentState.$(this, sel); - }, _Mixin$create.appendTo = function (selector) { - var env = this._environment || _emberEnvironment.environment; - var target = undefined; + /** + Register a callback to be invoked whenever the browser + history changes, including using forward and back buttons. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + var _this = this; - if (env.hasDOM) { - target = typeof selector === 'string' ? document.querySelector(selector) : selector; + this._removeEventListener(); - _emberMetal.assert('You tried to append to (' + selector + ') but that isn\'t in the DOM', target); - _emberMetal.assert('You cannot append to an existing Ember.View.', !_emberViewsSystemUtils.matches(target, '.ember-view')); - _emberMetal.assert('You cannot append to an existing Ember.View.', (function () { - var node = target.parentNode; - while (node) { - if (node.nodeType !== 9 && _emberViewsSystemUtils.matches(node, '.ember-view')) { - return false; + this._popstateHandler = function () { + // Ignore initial page load popstate event in Chrome + if (!popstateFired) { + popstateFired = true; + if (_this.getURL() === _this._previousURL) { + return; } - - node = node.parentNode; } + callback(_this.getURL()); + }; - return true; - })()); - } else { - target = selector; - - _emberMetal.assert('You tried to append to a selector string (' + selector + ') in an environment without jQuery', typeof target !== 'string'); - _emberMetal.assert('You tried to append to a non-Element (' + selector + ') in an environment without jQuery', typeof selector.appendChild === 'function'); - } - - this.renderer.appendTo(this, target); - - return this; - }, _Mixin$create.renderToElement = function (tagName) { - tagName = tagName || 'body'; - - _emberMetal.deprecate('Using the `renderToElement` is deprecated in favor of `appendTo`. Called in ' + this.toString(), false, { - id: 'ember-views.render-to-element', - until: '2.12.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_code-rendertoelement-code' - }); + window.addEventListener('popstate', this._popstateHandler); + }, - var element = this.renderer.createElement(tagName); + /** + Used when using `{{action}}` helper. The url is always appended to the rootURL. + @private + @method formatURL + @param url {String} + @return formatted url {String} + */ + formatURL: function (url) { + var rootURL = _emberMetal.get(this, 'rootURL'); + var baseURL = _emberMetal.get(this, 'baseURL'); - this.renderer.appendTo(this, element); - return element; - }, _Mixin$create.replaceIn = function (selector) { - var target = _emberViewsSystemJquery.default(selector); + if (url !== '') { + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); + baseURL = baseURL.replace(/\/$/, ''); + } else if (baseURL[0] === '/' && rootURL[0] === '/') { + // if baseURL and rootURL both start with a slash + // ... remove trailing slash from baseURL if it exists + baseURL = baseURL.replace(/\/$/, ''); + } - _emberMetal.assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0); - _emberMetal.assert('You cannot replace an existing Ember.View.', !target.is('.ember-view') && !target.parents().is('.ember-view')); + return baseURL + rootURL + url; + }, - this.renderer.replaceIn(this, target[0]); + /** + Cleans up the HistoryLocation event listener. + @private + @method willDestroy + */ + willDestroy: function () { + this._removeEventListener(); + }, - return this; - }, _Mixin$create.append = function () { - return this.appendTo(document.body); - }, _Mixin$create.elementId = null, _Mixin$create.findElementInParentElement = function (parentElem) { - var id = '#' + this.elementId; - return _emberViewsSystemJquery.default(id)[0] || _emberViewsSystemJquery.default(id, parentElem)[0]; - }, _Mixin$create.willInsertElement = K, _Mixin$create.didInsertElement = K, _Mixin$create.willClearRender = K, _Mixin$create.destroy = function () { - this._super.apply(this, arguments); - this._currentState.destroy(this); - }, _Mixin$create.willDestroyElement = K, _Mixin$create.parentViewDidChange = K, _Mixin$create.tagName = null, _Mixin$create.init = function () { - this._super.apply(this, arguments); + /** + @private + Returns normalized location.hash + @method getHash + */ + getHash: _emberRoutingLocationApi.default._getHash, - if (!this.elementId && this.tagName !== '') { - this.elementId = _emberUtils.guidFor(this); + _removeEventListener: function () { + if (this._popstateHandler) { + window.removeEventListener('popstate', this._popstateHandler); + } } - - _emberMetal.deprecate('[DEPRECATED] didInitAttrs called in ' + this.toString() + '.', typeof this.didInitAttrs !== 'function', { - id: 'ember-views.did-init-attrs', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' - }); - - _emberMetal.assert('Using a custom `.render` function is no longer supported.', !this.render); - }, _Mixin$create.__defineNonEnumerable = function (property) { - this[property.name] = property.descriptor.value; - }, _Mixin$create.handleEvent = function (eventName, evt) { - return this._currentState.handleEvent(this, eventName, evt); - }, _Mixin$create)); + }); }); +enifed('ember-routing/location/none_location', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; -// .......................................................... -// TEMPLATE SUPPORT -// + /** + @module ember + @submodule ember-routing + */ -/** - Return the nearest ancestor that is an instance of the provided - class or mixin. - @method nearestOfType - @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself), - or an instance of Ember.Mixin. - @return Ember.View - @deprecated use `yield` and contextual components for composition instead. - @private -*/ + /** + Ember.NoneLocation does not interact with the browser. It is useful for + testing, or when you need to manage state with your Router, but temporarily + don't want it to muck with the URL (for example when you embed your + application in a larger page). + + @class NoneLocation + @namespace Ember + @extends Ember.Object + @private + */ + exports.default = _emberRuntime.Object.extend({ + implementation: 'none', + path: '', -/** - Return the nearest ancestor that has a given property. - @method nearestWithProperty - @param {String} property A property name - @return Ember.View - @deprecated use `yield` and contextual components for composition instead. - @private -*/ + detect: function () { + var rootURL = this.rootURL; -/** - Renders the view again. This will work regardless of whether the - view is already in the DOM or not. If the view is in the DOM, the - rendering process will be deferred to give bindings a chance - to synchronize. - If children were added during the rendering process using `appendChild`, - `rerender` will remove them, because they will be added again - if needed by the next `render`. - In general, if the display of your view changes, you should modify - the DOM element directly instead of manually calling `rerender`, which can - be slow. - @method rerender - @public -*/ + _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); + }, -// .......................................................... -// ELEMENT SUPPORT -// + /** + Will be pre-pended to path. + @private + @property rootURL + @default '/' + */ + rootURL: '/', -/** - Returns the current DOM element for the view. - @property element - @type DOMElement - @public -*/ + /** + Returns the current path without `rootURL`. + @private + @method getURL + @return {String} path + */ + getURL: function () { + var path = _emberMetal.get(this, 'path'); + var rootURL = _emberMetal.get(this, 'rootURL'); -/** - Returns a jQuery object for this view's element. If you pass in a selector - string, this method will return a jQuery object, using the current element - as its buffer. - For example, calling `view.$('li')` will return a jQuery object containing - all of the `li` elements inside the DOM element of this view. - @method $ - @param {String} [selector] a jQuery-compatible selector string - @return {jQuery} the jQuery object for the DOM node - @public -*/ + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); -/** - Appends the view's element to the specified parent element. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the given element until all bindings have - finished synchronizing. - This is not typically a function that you will need to call directly when - building your application. If you do need to use `appendTo`, be sure that - the target element you are providing is associated with an `Ember.Application` - and does not have an ancestor element that is associated with an Ember view. - @method appendTo - @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object - @return {Ember.View} receiver - @private -*/ + // remove rootURL from url + return path.replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); + }, -/** - Creates a new DOM element, renders the view into it, then returns the - element. - By default, the element created and rendered into will be a `BODY` element, - since this is the default context that views are rendered into when being - inserted directly into the DOM. - ```js - let element = view.renderToElement(); - element.tagName; // => "BODY" - ``` - You can override the kind of element rendered into and returned by - specifying an optional tag name as the first argument. - ```js - let element = view.renderToElement('table'); - element.tagName; // => "TABLE" - ``` - This method is useful if you want to render the view into an element that - is not in the document's body. Instead, a new `body` element, detached from - the DOM is returned. FastBoot uses this to serialize the rendered view into - a string for transmission over the network. - ```js - app.visit('/').then(function(instance) { - let element; - Ember.run(function() { - element = renderToElement(instance); - }); - res.send(serialize(element)); - }); - ``` - @method renderToElement - @param {String} tagName The tag of the element to create and render into. Defaults to "body". - @return {HTMLBodyElement} element - @deprecated Use appendTo instead. - @private -*/ + /** + Set the path and remembers what was set. Using this method + to change the path will not invoke the `updateURL` callback. + @private + @method setURL + @param path {String} + */ + setURL: function (path) { + _emberMetal.set(this, 'path', path); + }, -/** - Replaces the content of the specified parent element with this view's - element. If the view does not have an HTML representation yet, - the element will be generated automatically. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the given element until all bindings have - finished synchronizing - @method replaceIn - @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object - @return {Ember.View} received - @private -*/ + /** + Register a callback to be invoked when the path changes. These + callbacks will execute when the user presses the back or forward + button, but not after `setURL` is invoked. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + this.updateCallback = callback; + }, -/** - Appends the view's element to the document body. If the view does - not have an HTML representation yet - the element will be generated automatically. - If your application uses the `rootElement` property, you must append - the view within that element. Rendering views outside of the `rootElement` - is not supported. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the document body until all bindings have - finished synchronizing. - @method append - @return {Ember.View} receiver - @private -*/ + /** + Sets the path and calls the `updateURL` callback. + @private + @method handleURL + @param callback {Function} + */ + handleURL: function (url) { + _emberMetal.set(this, 'path', url); + this.updateCallback(url); + }, -/** - The HTML `id` of the view's element in the DOM. You can provide this - value yourself but it must be unique (just as in HTML): - ```handlebars - {{my-component elementId="a-really-cool-id"}} - ``` - If not manually set a default value will be provided by the framework. - Once rendered an element's `elementId` is considered immutable and you - should never change it. If you need to compute a dynamic value for the - `elementId`, you should do this when the component or element is being - instantiated: - ```javascript - export default Ember.Component.extend({ - init() { - this._super(...arguments); - let index = this.get('index'); - this.set('elementId', 'component-id' + index); + /** + Given a URL, formats it to be placed into the page as part + of an element's `href` attribute. + This is used, for example, when using the {{action}} helper + to generate a URL based on an event. + @private + @method formatURL + @param url {String} + @return {String} url + */ + formatURL: function (url) { + var rootURL = _emberMetal.get(this, 'rootURL'); + + if (url !== '') { + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); } - }); - ``` - @property elementId - @type String - @public -*/ -/** - Attempts to discover the element in the parent element. The default - implementation looks for an element with an ID of `elementId` (or the - view's guid if `elementId` is null). You can override this method to - provide your own form of lookup. For example, if you want to discover your - element using a CSS class name instead of an ID. - @method findElementInParentElement - @param {DOMElement} parentElement The parent's DOM element - @return {DOMElement} The discovered element - @private -*/ + return rootURL + url; + } + }); +}); +enifed('ember-routing/location/util', ['exports'], function (exports) { + /** + @private + + Returns the current `location.pathname`, normalized for IE inconsistencies. + */ + 'use strict'; + + exports.getPath = getPath; + exports.getQuery = getQuery; + exports.getHash = getHash; + exports.getFullPath = getFullPath; + exports.getOrigin = getOrigin; + exports.supportsHashChange = supportsHashChange; + exports.supportsHistory = supportsHistory; + exports.replacePath = replacePath; -/** - Called when a view is going to insert an element into the DOM. - @event willInsertElement - @public -*/ + function getPath(location) { + var pathname = location.pathname; + // Various versions of IE/Opera don't always return a leading slash + if (pathname[0] !== '/') { + pathname = '/' + pathname; + } -/** - Called when the element of the view has been inserted into the DOM. - Override this function to do any set up that requires an element - in the document body. - When a view has children, didInsertElement will be called on the - child view(s) first and on itself afterwards. - @event didInsertElement - @public -*/ + return pathname; + } -/** - Called when the view is about to rerender, but before anything has - been torn down. This is a good opportunity to tear down any manual - observers you have installed based on the DOM state - @event willClearRender - @public -*/ + /** + @private + + Returns the current `location.search`. + */ -/** - You must call `destroy` on a view to destroy the view (and all of its - child views). This will remove the view from any parent node, then make - sure that the DOM element managed by the view can be released by the - memory manager. - @method destroy - @private -*/ + function getQuery(location) { + return location.search; + } -/** - Called when the element of the view is going to be destroyed. Override - this function to do any teardown that requires an element, like removing - event listeners. - Please note: any property changes made during this event will have no - effect on object observers. - @event willDestroyElement - @public -*/ + /** + @private + + Returns the current `location.hash` by parsing location.href since browsers + inconsistently URL-decode `location.hash`. + + Should be passed the browser's `location` object as the first argument. + + https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + */ -/** - Called when the parentView property has changed. - @event parentViewDidChange - @private -*/ + function getHash(location) { + var href = location.href; + var hashIndex = href.indexOf('#'); -// .......................................................... -// STANDARD RENDER PROPERTIES -// + if (hashIndex === -1) { + return ''; + } else { + return href.substr(hashIndex); + } + } -/** - Tag name for the view's outer element. The tag name is only used when an - element is first created. If you change the `tagName` for an element, you - must destroy and recreate the view element. - By default, the render buffer will use a `
    ` tag for views. - @property tagName - @type String - @default null - @public -*/ + function getFullPath(location) { + return getPath(location) + getQuery(location) + getHash(location); + } -// We leave this null by default so we can tell the difference between -// the default case and a user-specified tag. + function getOrigin(location) { + var origin = location.origin; -// ....................................................... -// CORE DISPLAY METHODS -// + // Older browsers, especially IE, don't have origin + if (!origin) { + origin = location.protocol + '//' + location.hostname; -/** - Setup a view, but do not finish waking it up. - * configure `childViews` - * register the view with the global views hash, which is used for event - dispatch - @method init - @private -*/ + if (location.port) { + origin += ':' + location.port; + } + } -// ....................................................... -// EVENT HANDLING -// + return origin; + } -/** - Handle events from `Ember.EventDispatcher` - @method handleEvent - @param eventName {String} - @param evt {Event} - @private -*/ -enifed("ember-views/system/action_manager", ["exports"], function (exports) { - /** - @module ember - @submodule ember-views + /* + `documentMode` only exist in Internet Explorer, and it's tested because IE8 running in + IE7 compatibility mode claims to support `onhashchange` but actually does not. + + `global` is an object that may have an `onhashchange` property. + + @private + @function supportsHashChange */ - "use strict"; + function supportsHashChange(documentMode, global) { + return 'onhashchange' in global && (documentMode === undefined || documentMode > 7); + } - exports.default = ActionManager; + /* + `userAgent` is a user agent string. We use user agent testing here, because + the stock Android browser is known to have buggy versions of the History API, + in some Android versions. + + @private + @function supportsHistory + */ - function ActionManager() {} + function supportsHistory(userAgent, history) { + // Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + // The stock browser on Android 2.2 & 2.3, and 4.0.x returns positive on history support + // Unfortunately support is really buggy and there is no clean way to detect + // these bugs, so we fall back to a user agent sniff :( + + // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies + // itself as 'Mobile Safari' as well, nor Windows Phone. + if ((userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 4.0') !== -1) && userAgent.indexOf('Mobile Safari') !== -1 && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Windows Phone') === -1) { + return false; + } + + return !!(history && 'pushState' in history); + } /** - Global action id hash. + Replaces the current location, making sure we explicitly include the origin + to prevent redirecting to a different origin. @private - @property registeredActions - @type Object */ - ActionManager.registeredActions = {}; + + function replacePath(location, path) { + location.replace(getOrigin(location) + path); + } }); -enifed('ember-views/system/event_dispatcher', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-environment', 'ember-views/compat/fallback-view-registry'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberViewsSystemJquery, _emberViewsSystemAction_manager, _emberEnvironment, _emberViewsCompatFallbackViewRegistry) { +enifed('ember-routing/services/router', ['exports', 'ember-runtime', 'ember-metal', 'ember-routing/system/dsl'], function (exports, _emberRuntime, _emberMetal, _emberRoutingSystemDsl) { /** @module ember - @submodule ember-views + @submodule ember-routing */ 'use strict'; - var ROOT_ELEMENT_CLASS = 'ember-application'; - var ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; - /** - `Ember.EventDispatcher` handles delegating browser events to their - corresponding `Ember.Views.` For example, when you click on a view, - `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets - called. + The Router service is the public API that provides component/view layer + access to the router. - @class EventDispatcher - @namespace Ember - @private - @extends Ember.Object - */ - exports.default = _emberRuntime.Object.extend({ + @public + @class RouterService + @category ember-routing-router-service + */ + var RouterService = _emberRuntime.Service.extend({ + currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), + currentURL: _emberRuntime.readOnly('router.currentURL'), + location: _emberRuntime.readOnly('router.location'), + rootURL: _emberRuntime.readOnly('router.rootURL'), /** - The set of events names (and associated handler function names) to be setup - and dispatched by the `EventDispatcher`. Modifications to this list can be done - at setup time, generally via the `Ember.Application.customEvents` hash. - To add new events to be listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - paste: 'paste' - } - }); - ``` - To prevent default events from being listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - mouseenter: null, - mouseleave: null - } - }); - ``` - @property events - @type Object - @private - */ - events: { - touchstart: 'touchStart', - touchmove: 'touchMove', - touchend: 'touchEnd', - touchcancel: 'touchCancel', - keydown: 'keyDown', - keyup: 'keyUp', - keypress: 'keyPress', - mousedown: 'mouseDown', - mouseup: 'mouseUp', - contextmenu: 'contextMenu', - click: 'click', - dblclick: 'doubleClick', - mousemove: 'mouseMove', - focusin: 'focusIn', - focusout: 'focusOut', - mouseenter: 'mouseEnter', - mouseleave: 'mouseLeave', - submit: 'submit', - input: 'input', - change: 'change', - dragstart: 'dragStart', - drag: 'drag', - dragenter: 'dragEnter', - dragleave: 'dragLeave', - dragover: 'dragOver', - drop: 'drop', - dragend: 'dragEnd' + 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 + @category ember-routing-router-service + @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 + @public + */ + transitionTo: function () { + var _router; + + return (_router = this.router).transitionTo.apply(_router, arguments); }, /** - The root DOM element to which event listeners should be attached. Event - listeners will be attached to the document unless this is overridden. - Can be specified as a DOMElement or a selector string. - The default body is a string since this may be evaluated before document.body - exists in the DOM. - @private - @property rootElement - @type DOMElement - @default 'body' - */ - rootElement: 'body', + Transition into another route while replacing the current URL, if possible. + The route may be either a single route or route path: + See [Route.replaceWith](http://emberjs.com/api/classes/Ember.Route.html#method_replaceWith) for more info. + @method replaceWith + @category ember-routing-router-service + @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 + @public + */ + replaceWith: function () { + var _router2; - /** - It enables events to be dispatched to the view's `eventManager.` When present, - this object takes precedence over handling of events on the view itself. - Note that most Ember applications do not use this feature. If your app also - does not use it, consider setting this property to false to gain some performance - improvement by allowing the EventDispatcher to skip the search for the - `eventManager` on the view tree. - ```javascript - let EventDispatcher = Em.EventDispatcher.extend({ - events: { - click : 'click', - focusin : 'focusIn', - focusout : 'focusOut', - change : 'change' - }, - canDispatchToEventManager: false - }); - container.register('event_dispatcher:main', EventDispatcher); - ``` - @property canDispatchToEventManager - @type boolean - @default 'true' - @since 1.7.0 - @private - */ - canDispatchToEventManager: true, + return (_router2 = this.router).replaceWith.apply(_router2, arguments); + } + }); - init: function () { - this._super(); - _emberMetal.assert('EventDispatcher should never be instantiated in fastboot mode. Please report this as an Ember bug.', _emberEnvironment.environment.hasDOM); - }, + exports.default = RouterService; +}); +enifed('ember-routing/services/routing', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'ember-routing/utils'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _emberRoutingUtils) { + /** + @module ember + @submodule ember-routing + */ - /** - Sets up event listeners for standard browser events. - This will be called after the browser sends a `DOMContentReady` event. By - default, it will set up all of the listeners on the document body. If you - would like to register the listeners on a different element, set the event - dispatcher's `root` property. - @private - @method setup - @param addedEvents {Object} - */ - setup: function (addedEvents, rootElement) { - var event = undefined; - var events = this._finalEvents = _emberUtils.assign({}, _emberMetal.get(this, 'events'), addedEvents); + 'use strict'; - if (!_emberMetal.isNone(rootElement)) { - _emberMetal.set(this, 'rootElement', rootElement); - } + /** + The Routing service is used by LinkComponent, and provides facilities for + the component/view layer to interact with the router. + + While still private, this service can eventually be opened up, and provides + the set of API needed for components to control routing without interacting + with router internals. + + @private + @class RoutingService + */ + exports.default = _emberRuntime.Service.extend({ + router: null, - rootElement = _emberViewsSystemJquery.default(_emberMetal.get(this, 'rootElement')); + targetState: _emberRuntime.readOnly('router.targetState'), + currentState: _emberRuntime.readOnly('router.currentState'), + currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), + currentPath: _emberRuntime.readOnly('router.currentPath'), - _emberMetal.assert('You cannot use the same root element (' + (rootElement.selector || rootElement[0].tagName) + ') multiple times in an Ember.Application', !rootElement.is(ROOT_ELEMENT_SELECTOR)); - _emberMetal.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length); - _emberMetal.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find(ROOT_ELEMENT_SELECTOR).length); + availableRoutes: function () { + return Object.keys(_emberMetal.get(this, 'router').router.recognizer.names); + }, - rootElement.addClass(ROOT_ELEMENT_CLASS); + hasRoute: function (routeName) { + return _emberMetal.get(this, 'router').hasRoute(routeName); + }, - if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) { - throw new TypeError('Unable to add \'' + ROOT_ELEMENT_CLASS + '\' class to root element (' + (rootElement.selector || rootElement[0].tagName) + '). Make sure you set rootElement to the body or an element in the body.'); - } + transitionTo: function (routeName, models, queryParams, shouldReplace) { + var router = _emberMetal.get(this, 'router'); - for (event in events) { - if (events.hasOwnProperty(event)) { - this.setupHandler(rootElement, event, events[event]); - } + var transition = router._doTransition(routeName, models, queryParams); + + if (shouldReplace) { + transition.method('replace'); } - }, - /** - Registers an event listener on the rootElement. If the given event is - triggered, the provided event handler will be triggered on the target view. - If the target view does not implement the event handler, or if the handler - returns `false`, the parent view will be called. The event will continue to - bubble to each successive parent view until it reaches the top. - @private - @method setupHandler - @param {Element} rootElement - @param {String} event the browser-originated event to listen to - @param {String} eventName the name of the method to call on the view - */ - setupHandler: function (rootElement, event, eventName) { - var self = this; + return transition; + }, - var owner = _emberUtils.getOwner(this); - var viewRegistry = owner && owner.lookup('-view-registry:main') || _emberViewsCompatFallbackViewRegistry.default; + normalizeQueryParams: function (routeName, models, queryParams) { + var router = _emberMetal.get(this, 'router'); + router._prepareQueryParams(routeName, models, queryParams); + }, - if (eventName === null) { + generateURL: function (routeName, models, queryParams) { + var router = _emberMetal.get(this, 'router'); + if (!router.router) { return; } - rootElement.on(event + '.ember', '.ember-view', function (evt, triggeringManager) { - var view = viewRegistry[this.id]; - var result = true; - - var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; + var visibleQueryParams = {}; + _emberUtils.assign(visibleQueryParams, queryParams); - if (manager && manager !== triggeringManager) { - result = self._dispatchEvent(manager, evt, eventName, view); - } else if (view) { - result = self._bubbleEvent(view, evt, eventName); - } + this.normalizeQueryParams(routeName, models, visibleQueryParams); - return result; - }); + var args = _emberRoutingUtils.routeArgs(routeName, models, visibleQueryParams); + return router.generate.apply(router, args); + }, - rootElement.on(event + '.ember', '[data-ember-action]', function (evt) { - var actionId = _emberViewsSystemJquery.default(evt.currentTarget).attr('data-ember-action'); - var actions = _emberViewsSystemAction_manager.default.registeredActions[actionId]; + isActiveForRoute: function (contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { + var router = _emberMetal.get(this, 'router'); - // In Glimmer2 this attribute is set to an empty string and an additional - // attribute it set for each action on a given element. In this case, the - // attributes need to be read so that a proper set of action handlers can - // be coalesced. - if (actionId === '') { - var attributes = evt.currentTarget.attributes; - var attributeCount = attributes.length; + var handlers = router.router.recognizer.handlersFor(routeName); + var leafName = handlers[handlers.length - 1].handler; + var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); - actions = []; + // NOTE: any ugliness in the calculation of activeness is largely + // due to the fact that we support automatic normalizing of + // `resource` -> `resource.index`, even though there might be + // dynamic segments / query params defined on `resource.index` + // which complicates (and makes somewhat ambiguous) the calculation + // of activeness for links that link to `resource` instead of + // directly to `resource.index`. - for (var i = 0; i < attributeCount; i++) { - var attr = attributes.item(i); - var attrName = attr.name; + // if we don't have enough contexts revert back to full route name + // this is because the leaf route will use one of the contexts + if (contexts.length > maximumContexts) { + routeName = leafName; + } - if (attrName.indexOf('data-ember-action-') === 0) { - actions = actions.concat(_emberViewsSystemAction_manager.default.registeredActions[attr.value]); - } - } - } + return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified); + } + }); - // We have to check for actions here since in some cases, jQuery will trigger - // an event on `removeChild` (i.e. focusout) after we've already torn down the - // action handlers for the view. - if (!actions) { - return; - } + function numberOfContextsAcceptedByHandler(handler, handlerInfos) { + var req = 0; + for (var i = 0; i < handlerInfos.length; i++) { + req += handlerInfos[i].names.length; + if (handlerInfos[i].handler === handler) { + break; + } + } - for (var index = 0; index < actions.length; index++) { - var action = actions[index]; + return req; + } +}); +enifed('ember-routing/system/cache', ['exports', 'ember-utils', 'ember-runtime'], function (exports, _emberUtils, _emberRuntime) { + 'use strict'; - if (action && action.eventName === eventName) { - return action.handler(evt); - } - } - }); + /** + A two-tiered cache with support for fallback values when doing lookups. + Uses "buckets" and then "keys" to cache values. + + @private + @class BucketCache + */ + exports.default = _emberRuntime.Object.extend({ + init: function () { + this.cache = new _emberUtils.EmptyObject(); }, - _findNearestEventManager: function (view, eventName) { - var manager = null; - - while (view) { - manager = _emberMetal.get(view, 'eventManager'); - if (manager && manager[eventName]) { - break; - } - - view = _emberMetal.get(view, 'parentView'); - } - - return manager; + has: function (bucketKey) { + return !!this.cache[bucketKey]; }, - _dispatchEvent: function (object, evt, eventName, view) { - var result = true; + stash: function (bucketKey, key, value) { + var bucket = this.cache[bucketKey]; - var handler = object[eventName]; - if (typeof handler === 'function') { - result = _emberMetal.run(object, handler, evt, view); - // Do not preventDefault in eventManagers. - evt.stopPropagation(); - } else { - result = this._bubbleEvent(view, evt, eventName); + if (!bucket) { + bucket = this.cache[bucketKey] = new _emberUtils.EmptyObject(); } - return result; - }, - - _bubbleEvent: function (view, evt, eventName) { - return view.handleEvent(eventName, evt); + bucket[key] = value; }, - destroy: function () { - var rootElement = _emberMetal.get(this, 'rootElement'); - _emberViewsSystemJquery.default(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); - return this._super.apply(this, arguments); - }, + lookup: function (bucketKey, prop, defaultValue) { + var cache = this.cache; + if (!this.has(bucketKey)) { + return defaultValue; + } - toString: function () { - return '(EventDispatcher)'; + var bucket = cache[bucketKey]; + if (prop in bucket && bucket[prop] !== undefined) { + return bucket[prop]; + } else { + return defaultValue; + } } }); }); -enifed('ember-views/system/ext', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed("ember-routing/system/controller_for", ["exports"], function (exports) { /** @module ember - @submodule ember-views + @submodule ember-routing */ - 'use strict'; + /** + Finds a controller instance. + + @for Ember + @method controllerFor + @private + */ + "use strict"; - // Add a new named queue for rendering views that happens - // after bindings have synced, and a queue for scheduling actions - // that should occur after view rendering. - _emberMetal.run._addQueue('render', 'actions'); - _emberMetal.run._addQueue('afterRender', 'render'); + exports.default = controllerFor; + + function controllerFor(container, controllerName, lookupOptions) { + return container.lookup("controller:" + controllerName, lookupOptions); + } }); -enifed('ember-views/system/jquery', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { +enifed('ember-routing/system/dsl', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { 'use strict'; - var jQuery = undefined; + /** + @module ember + @submodule ember-routing + */ - if (_emberEnvironment.environment.hasDOM) { - jQuery = _emberEnvironment.context.imports.jQuery; + var uuid = 0; - if (jQuery) { - if (jQuery.event.addProp) { - jQuery.event.addProp('dataTransfer'); - } else { - // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents - ['dragstart', 'drag', 'dragenter', 'dragleave', 'dragover', 'drop', 'dragend'].forEach(function (eventName) { - jQuery.event.fixHooks[eventName] = { - props: ['dataTransfer'] - }; - }); - } + var DSL = (function () { + function DSL(name, options) { + babelHelpers.classCallCheck(this, DSL); + + this.parent = name; + this.enableLoadingSubstates = options && options.enableLoadingSubstates; + this.matches = []; + this.explicitIndex = undefined; + this.options = options; } - } - exports.default = jQuery; -}); -enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + DSL.prototype.route = function route(name, options, callback) { + if (options === undefined) options = {}; - exports.default = lookupPartial; - exports.hasPartial = hasPartial; + var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; + if (arguments.length === 2 && typeof options === 'function') { + callback = options; + options = {}; + } - function parseUnderscoredName(templateName) { - var nameParts = templateName.split('/'); - var lastPart = nameParts[nameParts.length - 1]; + _emberMetal.assert('\'' + name + '\' cannot be used as a route name.', (function () { + if (options.overrideNameAssertion === true) { + return true; + } - nameParts[nameParts.length - 1] = '_' + lastPart; + return ['array', 'basic', 'object', 'application'].indexOf(name) === -1; + })()); - return nameParts.join('/'); - } + if (this.enableLoadingSubstates) { + createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace }); + createRoute(this, name + '_error', { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); + } - function lookupPartial(templateName, owner) { - if (templateName == null) { - return; - } + if (callback) { + var fullName = getFullName(this, name, options.resetNamespace); + var dsl = new DSL(fullName, this.options); - var template = templateFor(owner, parseUnderscoredName(templateName), templateName); + createRoute(dsl, 'loading'); + createRoute(dsl, 'error', { path: dummyErrorRoute }); - _emberMetal.assert('Unable to find partial with name "' + templateName + '"', !!template); + callback.call(dsl); - return template; - } + createRoute(this, name, options, dsl.generate()); + } else { + createRoute(this, name, options); + } + }; - function hasPartial(name, owner) { - if (!owner) { - throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); - } + DSL.prototype.push = function push(url, name, callback, serialize) { + var parts = name.split('.'); - return owner.hasRegistration('template:' + parseUnderscoredName(name)) || owner.hasRegistration('template:' + name); - } + if (this.options.engineInfo) { + var localFullName = name.slice(this.options.engineInfo.fullName.length + 1); + var routeInfo = _emberUtils.assign({ localFullName: localFullName }, this.options.engineInfo); - function templateFor(owner, underscored, name) { - if (!name) { - return; - } - _emberMetal.assert('templateNames are not allowed to contain periods: ' + name, name.indexOf('.') === -1); + if (serialize) { + routeInfo.serializeMethod = serialize; + } - if (!owner) { - throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); - } + this.options.addRouteForEngine(name, routeInfo); + } else if (serialize) { + throw new Error('Defining a route serializer on route \'' + name + '\' outside an Engine is not allowed.'); + } - return owner.lookup('template:' + underscored) || owner.lookup('template:' + name); - } -}); -enifed('ember-views/system/utils', ['exports', 'ember-utils'], function (exports, _emberUtils) { - /* globals Element */ - 'use strict'; + if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { + this.explicitIndex = true; + } - exports.isSimpleClick = isSimpleClick; - exports.getRootViews = getRootViews; - exports.getViewId = getViewId; - exports.getViewElement = getViewElement; - exports.initViewElement = initViewElement; - exports.setViewElement = setViewElement; - exports.getChildViews = getChildViews; - exports.initChildViews = initChildViews; - exports.addChildView = addChildView; - exports.collectChildViews = collectChildViews; - exports.getViewBounds = getViewBounds; - exports.getViewRange = getViewRange; - exports.getViewClientRects = getViewClientRects; - exports.getViewBoundingClientRect = getViewBoundingClientRect; - exports.matches = matches; + this.matches.push([url, name, callback]); + }; - /** - @module ember - @submodule ember-views - */ + DSL.prototype.resource = function resource(name, options, callback) { + if (options === undefined) options = {}; - function isSimpleClick(event) { - var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; - var secondaryClick = event.which > 1; // IE9 may return undefined + if (arguments.length === 2 && typeof options === 'function') { + callback = options; + options = {}; + } - return !modifier && !secondaryClick; - } + options.resetNamespace = true; + _emberMetal.deprecate('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.', false, { id: 'ember-routing.router-resource', until: '3.0.0' }); + this.route(name, options, callback); + }; - var STYLE_WARNING = '' + 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + 'please ensure that values being bound are properly escaped. For more information, ' + 'including how to disable this warning, see ' + 'http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.'; + DSL.prototype.generate = function generate() { + var dslMatches = this.matches; - exports.STYLE_WARNING = STYLE_WARNING; - /** - @private - @method getRootViews - @param {Object} owner - */ + if (!this.explicitIndex) { + this.route('index', { path: '/' }); + } - function getRootViews(owner) { - var registry = owner.lookup('-view-registry:main'); + return function (match) { + for (var i = 0; i < dslMatches.length; i++) { + var dslMatch = dslMatches[i]; + match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); + } + }; + }; - var rootViews = []; + DSL.prototype.mount = function mount(_name) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - Object.keys(registry).forEach(function (id) { - var view = registry[id]; + var engineRouteMap = this.options.resolveRouteMap(_name); + var name = _name; - if (view.parentView === null) { - rootViews.push(view); + if (options.as) { + name = options.as; } - }); - return rootViews; - } + var fullName = getFullName(this, name, options.resetNamespace); - /** - @private - @method getViewId - @param {Ember.View} view - */ + var engineInfo = { + name: _name, + instanceId: uuid++, + mountPoint: fullName, + fullName: fullName + }; - function getViewId(view) { - if (view.tagName === '') { - return _emberUtils.guidFor(view); - } else { - return view.elementId || _emberUtils.guidFor(view); - } - } + var path = options.path; - var VIEW_ELEMENT = _emberUtils.symbol('VIEW_ELEMENT'); + if (typeof path !== 'string') { + path = '/' + name; + } - /** - @private - @method getViewElement - @param {Ember.View} view - */ + var callback = undefined; + var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; + if (engineRouteMap) { + var shouldResetEngineInfo = false; + var oldEngineInfo = this.options.engineInfo; + if (oldEngineInfo) { + shouldResetEngineInfo = true; + this.options.engineInfo = engineInfo; + } - function getViewElement(view) { - return view[VIEW_ELEMENT]; - } + var optionsForChild = _emberUtils.assign({ engineInfo: engineInfo }, this.options); + var childDSL = new DSL(fullName, optionsForChild); - function initViewElement(view) { - view[VIEW_ELEMENT] = null; - } + createRoute(childDSL, 'loading'); + createRoute(childDSL, 'error', { path: dummyErrorRoute }); - function setViewElement(view, element) { - return view[VIEW_ELEMENT] = element; - } + engineRouteMap.class.call(childDSL); - var CHILD_VIEW_IDS = _emberUtils.symbol('CHILD_VIEW_IDS'); + callback = childDSL.generate(); - /** - @private - @method getChildViews - @param {Ember.View} view - */ + if (shouldResetEngineInfo) { + this.options.engineInfo = oldEngineInfo; + } + } - function getChildViews(view) { - var owner = _emberUtils.getOwner(view); - var registry = owner.lookup('-view-registry:main'); - return collectChildViews(view, registry); - } + var localFullName = 'application'; + var routeInfo = _emberUtils.assign({ localFullName: localFullName }, engineInfo); - function initChildViews(view) { - view[CHILD_VIEW_IDS] = []; - } + if (this.enableLoadingSubstates) { + // These values are important to register the loading routes under their + // proper names for the Router and within the Engine's registry. + var substateName = name + '_loading'; + var _localFullName = 'application_loading'; + var _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); + createRoute(this, substateName, { resetNamespace: options.resetNamespace }); + this.options.addRouteForEngine(substateName, _routeInfo); - function addChildView(parent, child) { - parent[CHILD_VIEW_IDS].push(getViewId(child)); - } + substateName = name + '_error'; + _localFullName = 'application_error'; + _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); + createRoute(this, substateName, { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); + this.options.addRouteForEngine(substateName, _routeInfo); + } - function collectChildViews(view, registry) { - var ids = []; - var views = []; + this.options.addRouteForEngine(fullName, routeInfo); - view[CHILD_VIEW_IDS].forEach(function (id) { - var view = registry[id]; + this.push(path, fullName, callback); + }; - if (view && !view.isDestroying && !view.isDestroyed && ids.indexOf(id) === -1) { - ids.push(id); - views.push(view); - } - }); + return DSL; + })(); - view[CHILD_VIEW_IDS] = ids; + exports.default = DSL; - return views; + function canNest(dsl) { + return dsl.parent && dsl.parent !== 'application'; } - /** - @private - @method getViewBounds - @param {Ember.View} view - */ - - function getViewBounds(view) { - return view.renderer.getBounds(view); + function getFullName(dsl, name, resetNamespace) { + if (canNest(dsl) && resetNamespace !== true) { + return dsl.parent + '.' + name; + } else { + return name; + } } - /** - @private - @method getViewRange - @param {Ember.View} view - */ + function createRoute(dsl, name, options, callback) { + if (options === undefined) options = {}; - function getViewRange(view) { - var bounds = getViewBounds(view); + var fullName = getFullName(dsl, name, options.resetNamespace); - var range = document.createRange(); - range.setStartBefore(bounds.firstNode); - range.setEndAfter(bounds.lastNode); + if (typeof options.path !== 'string') { + options.path = '/' + name; + } - return range; + dsl.push(options.path, fullName, callback, options.serialize); } - /** - `getViewClientRects` provides information about the position of the border - box edges of a view relative to the viewport. - - It is only intended to be used by development tools like the Ember Inspector - and may not work on older browsers. - - @private - @method getViewClientRects - @param {Ember.View} view - */ + DSL.map = function (callback) { + var dsl = new DSL(); + callback.call(dsl); + return dsl; + }; +}); +enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal', 'container'], function (exports, _emberMetal, _container) { + 'use strict'; - function getViewClientRects(view) { - var range = getViewRange(view); - return range.getClientRects(); - } + exports.generateControllerFactory = generateControllerFactory; + exports.default = generateController; /** - `getViewBoundingClientRect` provides information about the position of the - bounding border box edges of a view relative to the viewport. - - It is only intended to be used by development tools like the Ember Inpsector - and may not work on older browsers. - - @private - @method getViewBoundingClientRect - @param {Ember.View} view + @module ember + @submodule ember-routing */ - function getViewBoundingClientRect(view) { - var range = getViewRange(view); - return range.getBoundingClientRect(); - } - /** - Determines if the element matches the specified selector. + Generates a controller factory + @for Ember + @method generateControllerFactory @private - @method matches - @param {DOMElement} el - @param {String} selector */ - var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector); - - exports.elMatches = elMatches; - - function matches(el, selector) { - return elMatches.call(el, selector); - } -}); -enifed('ember-views/utils/lookup-component', ['exports', 'container'], function (exports, _container) { - 'use strict'; - - exports.default = lookupComponent; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - - function lookupComponentPair(componentLookup, owner, name, options) { - var component = componentLookup.componentFor(name, owner, options); - var layout = componentLookup.layoutFor(name, owner, options); - - var result = { layout: layout, component: component }; - - if (layout && !component) { - result.component = owner._lookupFactory(_container.privatize(_templateObject)); - } - - return result; - } - function lookupComponent(owner, name, options) { - var componentLookup = owner.lookup('component-lookup:main'); + function generateControllerFactory(owner, controllerName, context) { + var Factory = owner[_container.FACTORY_FOR]('controller:basic').class; - var source = options && options.source; + Factory = Factory.extend({ + toString: function () { + return '(generated ' + controllerName + ' controller)'; + } + }); - if (source) { - var localResult = lookupComponentPair(componentLookup, owner, name, options); + var fullName = 'controller:' + controllerName; - if (localResult.component || localResult.layout) { - return localResult; - } - } + owner.register(fullName, Factory); - return lookupComponentPair(componentLookup, owner, name); + return Factory; } -}); -enifed('ember-views/views/core_view', ['exports', 'ember-runtime', 'ember-views/system/utils', 'ember-views/views/states'], function (exports, _emberRuntime, _emberViewsSystemUtils, _emberViewsViewsStates) { - 'use strict'; /** - `Ember.CoreView` is an abstract class that exists to give view-like behavior - to both Ember's main view class `Ember.Component` and other classes that don't need - the full functionality of `Ember.Component`. - - Unless you have specific needs for `CoreView`, you will use `Ember.Component` - in your applications. + Generates and instantiates a controller extending from `controller:basic` + if present, or `Ember.Controller` if not. - @class CoreView - @namespace Ember - @extends Ember.Object - @deprecated Use `Ember.Component` instead. - @uses Ember.Evented - @uses Ember.ActionHandler + @for Ember + @method generateController @private + @since 1.3.0 */ - var CoreView = _emberRuntime.FrameworkObject.extend(_emberRuntime.Evented, _emberRuntime.ActionHandler, { - isView: true, - - _states: _emberViewsViewsStates.cloneStates(_emberViewsViewsStates.states), - - init: function () { - this._super.apply(this, arguments); - this._state = 'preRender'; - this._currentState = this._states.preRender; - - _emberViewsSystemUtils.initViewElement(this); - - if (!this.renderer) { - throw new Error('Cannot instantiate a component without a renderer. Please ensure that you are creating ' + this + ' with a proper container/registry.'); - } - }, - /** - If the view is currently inserted into the DOM of a parent view, this - property will point to the parent of the view. - @property parentView - @type Ember.View - @default null - @private - */ - parentView: null, + function generateController(owner, controllerName) { + generateControllerFactory(owner, controllerName); - instrumentDetails: function (hash) { - hash.object = this.toString(); - hash.containerKey = this._debugContainerKey; - hash.view = this; - return hash; - }, + var fullName = 'controller:' + controllerName; + var instance = owner.lookup(fullName); - /** - Override the default event firing from `Ember.Evented` to - also call methods with the given name. - @method trigger - @param name {String} - @private - */ - trigger: function () { - this._super.apply(this, arguments); - var name = arguments[0]; - var method = this[name]; - if (method) { - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - return method.apply(this, args); + _emberMetal.runInDebug(function () { + if (_emberMetal.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { + _emberMetal.info('generated -> ' + fullName, { fullName: fullName }); } - }, - - has: function (name) { - return _emberRuntime.typeOf(this[name]) === 'function' || this._super(name); - } - }); + }); - _emberRuntime.deprecateUnderscoreActions(CoreView); + return instance; + } +}); +enifed('ember-routing/system/query_params', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { + 'use strict'; - CoreView.reopenClass({ - isViewFactory: true + exports.default = _emberRuntime.Object.extend({ + isQueryParams: true, + values: null }); - - exports.default = CoreView; }); -enifed('ember-views/views/states', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberViewsViewsStatesPre_render, _emberViewsViewsStatesHas_element, _emberViewsViewsStatesIn_dom, _emberViewsViewsStatesDestroying) { +enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-routing/system/generate_controller', 'ember-routing/utils', 'container'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberRoutingSystemGenerate_controller, _emberRoutingUtils, _container) { 'use strict'; - exports.cloneStates = cloneStates; + exports.defaultSerialize = defaultSerialize; + exports.hasDefaultSerialize = hasDefaultSerialize; + var slice = Array.prototype.slice; - function cloneStates(from) { - var into = {}; + function K() { + return this; + } + + function defaultSerialize(model, params) { + if (params.length < 1 || !model) { + return; + } - into._default = {}; - into.preRender = Object.create(into._default); - into.destroying = Object.create(into._default); - into.hasElement = Object.create(into._default); - into.inDOM = Object.create(into.hasElement); + var name = params[0]; + var object = {}; - for (var stateName in from) { - if (!from.hasOwnProperty(stateName)) { - continue; + if (params.length === 1) { + if (name in model) { + object[name] = _emberMetal.get(model, name); + } else if (/_id$/.test(name)) { + object[name] = _emberMetal.get(model, 'id'); } - _emberUtils.assign(into[stateName], from[stateName]); + } else { + object = _emberMetal.getProperties(model, params); } - return into; + return object; } - /* - Describe how the specified actions should behave in the various - states that a view can exist in. Possible states: - - * preRender: when a view is first instantiated, and after its - element was destroyed, it is in the preRender state - * hasElement: the DOM representation of the view is created, - and is ready to be inserted - * inDOM: once a view has been inserted into the DOM it is in - the inDOM state. A view spends the vast majority of its - existence in this state. - * destroyed: once a view has been destroyed (using the destroy - method), it is in this state. No further actions can be invoked - on a destroyed view. - */ - var states = { - _default: _emberViewsViewsStatesDefault.default, - preRender: _emberViewsViewsStatesPre_render.default, - inDOM: _emberViewsViewsStatesIn_dom.default, - hasElement: _emberViewsViewsStatesHas_element.default, - destroying: _emberViewsViewsStatesDestroying.default - }; - exports.states = states; -}); -enifed('ember-views/views/states/default', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + var DEFAULT_SERIALIZE = _emberUtils.symbol('DEFAULT_SERIALIZE'); + + defaultSerialize[DEFAULT_SERIALIZE] = true; + + function hasDefaultSerialize(route) { + return !!route.serialize[DEFAULT_SERIALIZE]; + } /** @module ember - @submodule ember-views + @submodule ember-routing */ - exports.default = { - // appendChild is only legal while rendering the buffer. - appendChild: function () { - throw new _emberMetal.Error('You can\'t use appendChild outside of the rendering process'); - }, - - $: function () { - return undefined; - }, - - // Handle events from `Ember.EventDispatcher` - handleEvent: function () { - return true; // continue event propagation - }, - - rerender: function () {}, - - destroy: function () {} - }; -}); -enifed('ember-views/views/states/destroying', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/default'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesDefault) { - 'use strict'; /** - @module ember - @submodule ember-views + The `Ember.Route` class is used to define individual routes. Refer to + the [routing guide](http://emberjs.com/guides/routing/) for documentation. + + @class Route + @namespace Ember + @extends Ember.Object + @uses Ember.ActionHandler + @uses Ember.Evented + @since 1.0.0 + @public */ + var Route = _emberRuntime.Object.extend(_emberRuntime.ActionHandler, _emberRuntime.Evented, { + /** + Configuration hash for this route's queryParams. The possible + configuration options and their defaults are as follows + (assuming a query param whose controller property is `page`): + ```javascript + queryParams: { + page: { + // By default, controller query param properties don't + // cause a full transition when they are changed, but + // rather only cause the URL to update. Setting + // `refreshModel` to true will cause an "in-place" + // transition to occur, whereby the model hooks for + // this route (and any child routes) will re-fire, allowing + // you to reload models (e.g., from the server) using the + // updated query param values. + refreshModel: false, + // By default, changes to controller query param properties + // cause the URL to update via `pushState`, which means an + // item will be added to the browser's history, allowing + // you to use the back button to restore the app to the + // previous state before the query param property was changed. + // Setting `replace` to true will use `replaceState` (or its + // hash location equivalent), which causes no browser history + // item to be added. This options name and default value are + // the same as the `link-to` helper's `replace` option. + replace: false, + // By default, the query param URL key is the same name as + // the controller property name. Use `as` to specify a + // different URL key. + as: 'page' + } + } + ``` + @property queryParams + @for Ember.Route + @type Object + @since 1.6.0 + @public + */ + queryParams: {}, - var destroying = Object.create(_emberViewsViewsStatesDefault.default); + /** + The name of the route, dot-delimited. + For example, a route found at `app/routes/posts/post.js` will have + a `routeName` of `posts.post`. + @property routeName + @for Ember.Route + @type String + @since 1.0.0 + @public + */ - _emberUtils.assign(destroying, { - appendChild: function () { - throw new _emberMetal.Error('You can\'t call appendChild on a view being destroyed'); + /** + Sets the name for this route, including a fully resolved name for routes + inside engines. + @private + @method _setRouteName + @param {String} name + */ + _setRouteName: function (name) { + this.routeName = name; + this.fullRouteName = getEngineRouteName(_emberUtils.getOwner(this), name); }, - rerender: function () { - throw new _emberMetal.Error('You can\'t call rerender on a view being destroyed'); - } - }); - exports.default = destroying; -}); -enifed('ember-views/views/states/has_element', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-metal', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberMetal, _emberViewsSystemJquery) { - 'use strict'; + /** + Populates the QP meta information in the BucketCache. + @private + @method _populateQPMeta + */ + _populateQPMeta: function () { + this._bucketCache.stash('route-meta', this.fullRouteName, this.get('_qp')); + }, - var hasElement = Object.create(_emberViewsViewsStatesDefault.default); + /** + @private + @property _qp + */ + _qp: _emberMetal.computed(function () { + var _this = this; - _emberUtils.assign(hasElement, { - $: function (view, sel) { - var elem = view.element; - return sel ? _emberViewsSystemJquery.default(sel, elem) : _emberViewsSystemJquery.default(elem); - }, + var controllerProto = undefined, + combinedQueryParameterConfiguration = undefined; - rerender: function (view) { - view.renderer.rerender(view); - }, + var controllerName = this.controllerName || this.routeName; + var owner = _emberUtils.getOwner(this); + var definedControllerClass = owner[_container.LOOKUP_FACTORY]('controller:' + controllerName); + var queryParameterConfiguraton = _emberMetal.get(this, 'queryParams'); + var hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; - destroy: function (view) { - view.renderer.remove(view); - }, + if (definedControllerClass) { + // the developer has authored a controller class in their application for this route + // access the prototype, find its query params and normalize their object shape + // them merge in the query params for the route. As a mergedProperty, Route#queryParams is always + // at least `{}` + controllerProto = definedControllerClass.proto(); - // Handle events from `Ember.EventDispatcher` - handleEvent: function (view, eventName, event) { - if (view.has(eventName)) { - // Handler should be able to re-dispatch events, so we don't - // preventDefault or stopPropagation. - return _emberMetal.flaggedInstrument('interaction.' + eventName, { event: event, view: view }, function () { - return _emberMetal.run.join(view, view.trigger, eventName, event); - }); - } else { - return true; // continue event propagation + var controllerDefinedQueryParameterConfiguration = _emberMetal.get(controllerProto, 'queryParams'); + var normalizedControllerQueryParameterConfiguration = _emberRoutingUtils.normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); + combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton); + } else if (hasRouterDefinedQueryParams) { + // the developer has not defined a controller but *has* supplied route query params. + // Generate a class for them so we can later insert default values + var generatedControllerClass = _emberRoutingSystemGenerate_controller.generateControllerFactory(_emberUtils.getOwner(this), controllerName); + controllerProto = generatedControllerClass.proto(); + combinedQueryParameterConfiguration = queryParameterConfiguraton; } - } - }); - exports.default = hasElement; -}); -enifed('ember-views/views/states/in_dom', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/has_element'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesHas_element) { - 'use strict'; + var qps = []; + var map = {}; + var propertyNames = []; - /** - @module ember - @submodule ember-views - */ + for (var propName in combinedQueryParameterConfiguration) { + if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { + continue; + } - var inDOM = Object.create(_emberViewsViewsStatesHas_element.default); + // to support the dubious feature of using unknownProperty + // on queryParams configuration + if (propName === 'unknownProperty' || propName === '_super') { + // possible todo: issue deprecation warning? + continue; + } - _emberUtils.assign(inDOM, { - enter: function (view) { - // Register the view for event handling. This hash is used by - // Ember.EventDispatcher to dispatch incoming events. - view.renderer.register(view); + var desc = combinedQueryParameterConfiguration[propName]; + var scope = desc.scope || 'model'; + var parts = undefined; - _emberMetal.runInDebug(function () { - _emberMetal._addBeforeObserver(view, 'elementId', function () { - throw new _emberMetal.Error('Changing a view\'s elementId after creation is not allowed'); - }); - }); - }, + if (scope === 'controller') { + parts = []; + } - exit: function (view) { - view.renderer.unregister(view); - } - }); + var urlKey = desc.as || this.serializeQueryParamKey(propName); + var defaultValue = _emberMetal.get(controllerProto, propName); - exports.default = inDOM; -}); -enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default'], function (exports, _emberViewsViewsStatesDefault) { - 'use strict'; + if (Array.isArray(defaultValue)) { + defaultValue = _emberRuntime.A(defaultValue.slice()); + } - /** - @module ember - @submodule ember-views - */ + var type = desc.type || _emberRuntime.typeOf(defaultValue); - exports.default = Object.create(_emberViewsViewsStatesDefault.default); -}); -enifed("ember-views/views/view", ["exports"], function (exports) { - "use strict"; -}); -/** -@module ember -@submodule ember-views -*/ + var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); + var scopedPropertyName = controllerName + ':' + propName; + var qp = { + undecoratedDefaultValue: _emberMetal.get(controllerProto, propName), + defaultValue: defaultValue, + serializedDefaultValue: defaultValueSerialized, + serializedValue: defaultValueSerialized, -/** - `Ember.View` is the class in Ember responsible for encapsulating templates of - HTML content, combining templates with data to render as sections of a page's - DOM, and registering and responding to user-initiated events. + type: type, + urlKey: urlKey, + prop: propName, + scopedPropertyName: scopedPropertyName, + controllerName: controllerName, + route: this, + parts: parts, // provided later when stashNames is called if 'model' scope + values: null, // provided later when setup is called. no idea why. + scope: scope + }; - ## HTML Tag + map[propName] = map[urlKey] = map[scopedPropertyName] = qp; + qps.push(qp); + propertyNames.push(propName); + } - The default HTML tag name used for a view's DOM representation is `div`. This - can be customized by setting the `tagName` property. The following view - class: + return { + qps: qps, + map: map, + propertyNames: propertyNames, + states: { + /* + Called when a query parameter changes in the URL, this route cares + about that query parameter, but the route is not currently + in the active route hierarchy. + */ + inactive: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + }, + /* + Called when a query parameter changes in the URL, this route cares + about that query parameter, and the route is currently + in the active route hierarchy. + */ + active: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + return _this._activeQPChanged(map[prop], value); + }, + /* + Called when a value of a query parameter this route handles changes in a controller + and the route is currently in the active route hierarchy. + */ + allowOverrides: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + return _this._updatingQPChanged(map[prop]); + } + } + }; + }), - ```javascript - ParagraphView = Ember.View.extend({ - tagName: 'em' - }); - ``` + /** + @private + @property _names + */ + _names: null, - Would result in instances with the following HTML: + /** + @private + @method _stashNames + */ + _stashNames: function (handlerInfo, dynamicParent) { + if (this._names) { + return; + } + var names = this._names = handlerInfo._names; - ```html - - ``` + if (!names.length) { + handlerInfo = dynamicParent; + names = handlerInfo && handlerInfo._names || []; + } - ## HTML `class` Attribute + var qps = _emberMetal.get(this, '_qp.qps'); - The HTML `class` attribute of a view's tag can be set by providing a - `classNames` property that is set to an array of strings: + var namePaths = new Array(names.length); + for (var a = 0; a < names.length; ++a) { + namePaths[a] = handlerInfo.name + '.' + names[a]; + } - ```javascript - MyView = Ember.View.extend({ - classNames: ['my-class', 'my-other-class'] - }); - ``` + for (var i = 0; i < qps.length; ++i) { + var qp = qps[i]; + if (qp.scope === 'model') { + qp.parts = namePaths; + } + } + }, - Will result in view instances with an HTML representation of: + /** + @private + @property _activeQPChanged + */ + _activeQPChanged: function (qp, value) { + var router = this.router; + router._activeQPChanged(qp.scopedPropertyName, value); + }, - ```html -
    - ``` + /** + @private + @method _updatingQPChanged + */ + _updatingQPChanged: function (qp) { + var router = this.router; + router._updatingQPChanged(qp.urlKey); + }, - `class` attribute values can also be set by providing a `classNameBindings` - property set to an array of properties names for the view. The return value - of these properties will be added as part of the value for the view's `class` - attribute. These properties can be computed properties: + mergedProperties: ['queryParams'], - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['propertyA', 'propertyB'], - propertyA: 'from-a', - propertyB: Ember.computed(function() { - if (someLogic) { return 'from-b'; } - }) - }); - ``` + /** + Returns a hash containing the parameters of an ancestor route. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('member', { path: ':name' }, function() { + this.route('interest', { path: ':interest' }); + }); + }); + ``` + ```app/routes/member.js + export default Ember.Route.extend({ + queryParams: { + memberQp: { refreshModel: true } + } + }); + ``` + ```app/routes/member/interest.js + export default Ember.Route.extend({ + queryParams: { + interestQp: { refreshModel: true } + }, + model() { + return this.paramsFor('member'); + } + }); + ``` + If we visit `/turing/maths?memberQp=member&interestQp=interest` the model for + the `member.interest` route is hash with: + * `name`: `turing` + * `memberQp`: `member` + @method paramsFor + @param {String} name + @return {Object} hash containing the parameters of the route `name` + @since 1.4.0 + @public + */ + paramsFor: function (name) { + var _this2 = this; - Will result in view instances with an HTML representation of: + var route = _emberUtils.getOwner(this).lookup('route:' + name); - ```html -
    - ``` + if (!route) { + return {}; + } - If the value of a class name binding returns a boolean the property name - itself will be used as the class name if the property is true. The class name - will not be added if the value is `false` or `undefined`. + var transition = this.router.router.activeTransition; + var state = transition ? transition.state : this.router.router.state; - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['hovered'], - hovered: true - }); - ``` + var fullName = route.fullRouteName; + var params = _emberUtils.assign({}, state.params[fullName]); + var queryParams = getQueryParamsFor(route, state); - Will result in view instances with an HTML representation of: + return Object.keys(queryParams).reduce(function (params, key) { + _emberMetal.assert('The route \'' + _this2.routeName + '\' has both a dynamic segment and query param with name \'' + key + '\'. Please rename one to avoid collisions.', !params[key]); + params[key] = queryParams[key]; + return params; + }, params); + }, - ```html -
    - ``` + /** + Serializes the query parameter key + @method serializeQueryParamKey + @param {String} controllerPropertyName + @private + */ + serializeQueryParamKey: function (controllerPropertyName) { + return controllerPropertyName; + }, - When using boolean class name bindings you can supply a string value other - than the property name for use as the `class` HTML attribute by appending the - preferred value after a ":" character when defining the binding: + /** + Serializes value of the query parameter based on defaultValueType + @method serializeQueryParam + @param {Object} value + @param {String} urlKey + @param {String} defaultValueType + @private + */ + serializeQueryParam: function (value, urlKey, defaultValueType) { + // urlKey isn't used here, but anyone overriding + // can use it to provide serialization specific + // to a certain query param. + return this.router._serializeQueryParam(value, defaultValueType); + }, - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['awesome:so-very-cool'], - awesome: true - }); - ``` + /** + Deserializes value of the query parameter based on defaultValueType + @method deserializeQueryParam + @param {Object} value + @param {String} urlKey + @param {String} defaultValueType + @private + */ + deserializeQueryParam: function (value, urlKey, defaultValueType) { + // urlKey isn't used here, but anyone overriding + // can use it to provide deserialization specific + // to a certain query param. + return this.router._deserializeQueryParam(value, defaultValueType); + }, - Will result in view instances with an HTML representation of: + /** + @private + @property _optionsForQueryParam + */ + _optionsForQueryParam: function (qp) { + return _emberMetal.get(this, 'queryParams.' + qp.urlKey) || _emberMetal.get(this, 'queryParams.' + qp.prop) || {}; + }, - ```html -
    - ``` + /** + A hook you can use to reset controller values either when the model + changes or the route is exiting. + ```app/routes/articles.js + import Ember from 'ember'; + export default Ember.Route.extend({ + resetController(controller, isExiting, transition) { + if (isExiting) { + controller.set('page', 1); + } + } + }); + ``` + @method resetController + @param {Controller} controller instance + @param {Boolean} isExiting + @param {Object} transition + @since 1.7.0 + @public + */ + resetController: K, - Boolean value class name bindings whose property names are in a - camelCase-style format will be converted to a dasherized format: + /** + @private + @method exit + */ + exit: function () { + this.deactivate(); + this.trigger('deactivate'); + this.teardownViews(); + }, - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['isUrgent'], - isUrgent: true - }); - ``` + /** + @private + @method _reset + @since 1.7.0 + */ + _reset: function (isExiting, transition) { + var controller = this.controller; + controller._qpDelegate = _emberMetal.get(this, '_qp.states.inactive'); - Will result in view instances with an HTML representation of: + this.resetController(controller, isExiting, transition); + }, - ```html -
    - ``` + /** + @private + @method enter + */ + enter: function () { + this.connections = []; + this.activate(); + this.trigger('activate'); + }, - Class name bindings can also refer to object values that are found by - traversing a path relative to the view itself: + /** + The name of the template to use by default when rendering this routes + template. + ```app/routes/posts/list.js + import Ember from 'ember'; + export default Ember.Route.extend({ + templateName: 'posts/list' + }); + ``` + ```app/routes/posts/index.js + import PostsList from '../posts/list'; + export default PostsList.extend(); + ``` + ```app/routes/posts/archived.js + import PostsList from '../posts/list'; + export default PostsList.extend(); + ``` + @property templateName + @type String + @default null + @since 1.4.0 + @public + */ + templateName: null, - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['messages.empty'] - messages: Ember.Object.create({ - empty: true - }) - }); - ``` + /** + The name of the controller to associate with this route. + By default, Ember will lookup a route's controller that matches the name + of the route (i.e. `App.PostController` for `App.PostRoute`). However, + if you would like to define a specific controller to use, you can do so + using this property. + This is useful in many ways, as the controller specified will be: + * passed to the `setupController` method. + * used as the controller for the template being rendered by the route. + * returned from a call to `controllerFor` for the route. + @property controllerName + @type String + @default null + @since 1.4.0 + @public + */ + controllerName: null, - Will result in view instances with an HTML representation of: + /** + The `willTransition` action is fired at the beginning of any + attempted transition with a `Transition` object as the sole + argument. This action can be used for aborting, redirecting, + or decorating the transition from the currently active routes. + A good example is preventing navigation when a form is + half-filled out: + ```app/routes/contact-form.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + willTransition(transition) { + if (this.controller.get('userHasEnteredData')) { + this.controller.displayNavigationConfirm(); + transition.abort(); + } + } + } + }); + ``` + You can also redirect elsewhere by calling + `this.transitionTo('elsewhere')` from within `willTransition`. + Note that `willTransition` will not be fired for the + redirecting `transitionTo`, since `willTransition` doesn't + fire when there is already a transition underway. If you want + subsequent `willTransition` actions to fire for the redirecting + transition, you must first explicitly call + `transition.abort()`. + To allow the `willTransition` event to continue bubbling to the parent + route, use `return true;`. When the `willTransition` method has a + return value of `true` then the parent route's `willTransition` method + will be fired, enabling "bubbling" behavior for the event. + @event willTransition + @param {Transition} transition + @since 1.0.0 + @public + */ - ```html -
    - ``` + /** + The `didTransition` action is fired after a transition has + successfully been completed. This occurs after the normal model + hooks (`beforeModel`, `model`, `afterModel`, `setupController`) + have resolved. The `didTransition` action has no arguments, + however, it can be useful for tracking page views or resetting + state on the controller. + ```app/routes/login.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + didTransition() { + this.controller.get('errors.base').clear(); + return true; // Bubble the didTransition event + } + } + }); + ``` + @event didTransition + @since 1.2.0 + @public + */ - If you want to add a class name for a property which evaluates to true and - and a different class name if it evaluates to false, you can pass a binding - like this: + /** + The `loading` action is fired on the route when a route's `model` + hook returns a promise that is not already resolved. The current + `Transition` object is the first parameter and the route that + triggered the loading event is the second parameter. + ```app/routes/application.js + export default Ember.Route.extend({ + actions: { + loading(transition, route) { + let controller = this.controllerFor('foo'); + controller.set('currentlyLoading', true); + transition.finally(function() { + controller.set('currentlyLoading', false); + }); + } + } + }); + ``` + @event loading + @param {Transition} transition + @param {Ember.Route} route The route that triggered the loading event + @since 1.2.0 + @public + */ - ```javascript - // Applies 'enabled' class when isEnabled is true and 'disabled' when isEnabled is false - Ember.View.extend({ - classNameBindings: ['isEnabled:enabled:disabled'] - isEnabled: true - }); - ``` + /** + When attempting to transition into a route, any of the hooks + may return a promise that rejects, at which point an `error` + action will be fired on the partially-entered routes, allowing + for per-route error handling logic, or shared error handling + logic defined on a parent route. + Here is an example of an error handler that will be invoked + for rejected promises from the various hooks on the route, + as well as any unhandled errors from child routes: + ```app/routes/admin.js + import Ember from 'ember'; + export default Ember.Route.extend({ + beforeModel() { + return Ember.RSVP.reject('bad things!'); + }, + actions: { + error(error, transition) { + // Assuming we got here due to the error in `beforeModel`, + // we can expect that error === "bad things!", + // but a promise model rejecting would also + // call this hook, as would any errors encountered + // in `afterModel`. + // The `error` hook is also provided the failed + // `transition`, which can be stored and later + // `.retry()`d if desired. + this.transitionTo('login'); + } + } + }); + ``` + `error` actions that bubble up all the way to `ApplicationRoute` + will fire a default error handler that logs the error. You can + specify your own global default error handler by overriding the + `error` handler on `ApplicationRoute`: + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + error(error, transition) { + this.controllerFor('banner').displayError(error.message); + } + } + }); + ``` + @event error + @param {Error} error + @param {Transition} transition + @since 1.0.0 + @public + */ - Will result in view instances with an HTML representation of: + /** + This event is triggered when the router enters the route. It is + not executed when the model for the route changes. + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + collectAnalytics: Ember.on('activate', function(){ + collectAnalytics(); + }) + }); + ``` + @event activate + @since 1.9.0 + @public + */ - ```html -
    - ``` + /** + This event is triggered when the router completely exits this + route. It is not executed when the model for the route changes. + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + trackPageLeaveAnalytics: Ember.on('deactivate', function(){ + trackPageLeaveAnalytics(); + }) + }); + ``` + @event deactivate + @since 1.9.0 + @public + */ - When isEnabled is `false`, the resulting HTML representation looks like - this: + /** + The controller associated with this route. + Example + ```app/routes/form.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + willTransition(transition) { + if (this.controller.get('userHasEnteredData') && + !confirm('Are you sure you want to abandon progress?')) { + transition.abort(); + } else { + // Bubble the `willTransition` action so that + // parent routes can decide whether or not to abort. + return true; + } + } + } + }); + ``` + @property controller + @type Ember.Controller + @since 1.6.0 + @public + */ - ```html -
    - ``` + actions: { - This syntax offers the convenience to add a class if a property is `false`: + /** + This action is called when one or more query params have changed. Bubbles. + @method queryParamsDidChange + @param changed {Object} Keys are names of query params that have changed. + @param totalPresent {Object} Keys are names of query params that are currently set. + @param removed {Object} Keys are names of query params that have been removed. + @returns {boolean} + @private + */ + queryParamsDidChange: function (changed, totalPresent, removed) { + var qpMap = _emberMetal.get(this, '_qp').map; - ```javascript - // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false - Ember.View.extend({ - classNameBindings: ['isEnabled::disabled'] - isEnabled: true - }); - ``` + var totalChanged = Object.keys(changed).concat(Object.keys(removed)); + for (var i = 0; i < totalChanged.length; ++i) { + var qp = qpMap[totalChanged[i]]; + if (qp && _emberMetal.get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) { + this.refresh(); + break; + } + } - Will result in view instances with an HTML representation of: + return true; + }, - ```html -
    - ``` + finalizeQueryParamChange: function (params, finalParams, transition) { + if (this.fullRouteName !== 'application') { + return true; + } - When the `isEnabled` property on the view is set to `false`, it will result - in view instances with an HTML representation of: + // Transition object is absent for intermediate transitions. + if (!transition) { + return; + } - ```html -
    - ``` + var handlerInfos = transition.state.handlerInfos; + var router = this.router; + var qpMeta = router._queryParamsFor(handlerInfos); + var changes = router._qpUpdates; + var replaceUrl = undefined; - Updates to the value of a class name binding will result in automatic - update of the HTML `class` attribute in the view's rendered HTML - representation. If the value becomes `false` or `undefined` the class name - will be removed. + _emberRoutingUtils.stashParamNames(router, handlerInfos); - Both `classNames` and `classNameBindings` are concatenated properties. See - [Ember.Object](/api/classes/Ember.Object.html) documentation for more - information about concatenated properties. + for (var i = 0; i < qpMeta.qps.length; ++i) { + var qp = qpMeta.qps[i]; + var route = qp.route; + var controller = route.controller; + var presentKey = qp.urlKey in params && qp.urlKey; - ## HTML Attributes + // Do a reverse lookup to see if the changed query + // param URL key corresponds to a QP property on + // this controller. + var value = undefined, + svalue = undefined; + if (changes && qp.urlKey in changes) { + // Value updated in/before setupController + value = _emberMetal.get(controller, qp.prop); + svalue = route.serializeQueryParam(value, qp.urlKey, qp.type); + } else { + if (presentKey) { + svalue = params[presentKey]; + value = route.deserializeQueryParam(svalue, qp.urlKey, qp.type); + } else { + // No QP provided; use default value. + svalue = qp.serializedDefaultValue; + value = copyDefaultValue(qp.defaultValue); + } + } - The HTML attribute section of a view's tag can be set by providing an - `attributeBindings` property set to an array of property names on the view. - The return value of these properties will be used as the value of the view's - HTML associated attribute: + controller._qpDelegate = _emberMetal.get(route, '_qp.states.inactive'); - ```javascript - AnchorView = Ember.View.extend({ - tagName: 'a', - attributeBindings: ['href'], - href: 'http://google.com' - }); - ``` + var thisQueryParamChanged = svalue !== qp.serializedValue; + if (thisQueryParamChanged) { + if (transition.queryParamsOnly && replaceUrl !== false) { + var options = route._optionsForQueryParam(qp); + var replaceConfigValue = _emberMetal.get(options, 'replace'); + if (replaceConfigValue) { + replaceUrl = true; + } else if (replaceConfigValue === false) { + // Explicit pushState wins over any other replaceStates. + replaceUrl = false; + } + } - Will result in view instances with an HTML representation of: + _emberMetal.set(controller, qp.prop, value); + } - ```html - - ``` + // Stash current serialized value of controller. + qp.serializedValue = svalue; - One property can be mapped on to another by placing a ":" between - the source property and the destination property: + var thisQueryParamHasDefaultValue = qp.serializedDefaultValue === svalue; + if (!thisQueryParamHasDefaultValue) { + finalParams.push({ + value: svalue, + visible: true, + key: presentKey || qp.urlKey + }); + } + } - ```javascript - AnchorView = Ember.View.extend({ - tagName: 'a', - attributeBindings: ['url:href'], - url: 'http://google.com' - }); - ``` + if (replaceUrl) { + transition.method('replace'); + } - Will result in view instances with an HTML representation of: + qpMeta.qps.forEach(function (qp) { + var routeQpMeta = _emberMetal.get(qp.route, '_qp'); + var finalizedController = qp.route.controller; + finalizedController._qpDelegate = _emberMetal.get(routeQpMeta, 'states.active'); + }); - ```html - - ``` + router._qpUpdates = null; + } + }, - Namespaced attributes (e.g. `xlink:href`) are supported, but have to be - mapped, since `:` is not a valid character for properties in Javascript: + /** + This hook is executed when the router completely exits this route. It is + not executed when the model for the route changes. + @method deactivate + @since 1.0.0 + @public + */ + deactivate: K, - ```javascript - UseView = Ember.View.extend({ - tagName: 'use', - attributeBindings: ['xlinkHref:xlink:href'], - xlinkHref: '#triangle' - }); - ``` - Will result in view instances with an HTML representation of: + /** + This hook is executed when the router enters the route. It is not executed + when the model for the route changes. + @method activate + @since 1.0.0 + @public + */ + activate: K, - ```html - - ``` + /** + Transition the application into another route. The route may + be either a single route or route path: + ```javascript + this.transitionTo('blogPosts'); + this.transitionTo('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + this.transitionTo('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + this.transitionTo('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```app/routes.js + // ... + Router.map(function() { + this.route('blogPost', { path:':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId' }); + }); + }); + export default Router; + ``` + ```javascript + this.transitionTo('blogComment', aPost, aComment); + this.transitionTo('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + this.transitionTo('/'); + this.transitionTo('/blog/post/1/comment/13'); + this.transitionTo('/blog/posts?sort=title'); + ``` + An options hash with a `queryParams` property may be provided as + the final argument to add query parameters to the destination URL. + ```javascript + this.transitionTo('blogPost', 1, { + queryParams: { showComments: 'true' } + }); + // if you just want to transition the query parameters without changing the route + this.transitionTo({ queryParams: { sort: 'date' } }); + ``` + See also [replaceWith](#method_replaceWith). + Simple Transition Example + ```app/routes.js + // ... + Router.map(function() { + this.route('index'); + this.route('secret'); + this.route('fourOhFour', { path: '*:' }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember': + export Ember.Route.extend({ + actions: { + moveToSecret(context) { + if (authorized()) { + this.transitionTo('secret', context); + } else { + this.transitionTo('fourOhFour'); + } + } + } + }); + ``` + Transition to a nested route + ```app/router.js + // ... + Router.map(function() { + this.route('articles', { path: '/articles' }, function() { + this.route('new'); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + transitionToNewArticle() { + this.transitionTo('articles.new'); + } + } + }); + ``` + Multiple Models Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('breakfast', { path: ':breakfastId' }, function() { + this.route('cereal', { path: ':cerealId' }); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + moveToChocolateCereal() { + let cereal = { cerealId: 'ChocolateYumminess' }; + let breakfast = { breakfastId: 'CerealAndMilk' }; + this.transitionTo('breakfast.cereal', breakfast, cereal); + } + } + }); + ``` + Nested Route with Query String Example + ```app/routes.js + // ... + Router.map(function() { + this.route('fruits', function() { + this.route('apples'); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + transitionToApples() { + this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); + } + } + }); + ``` + @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 + @since 1.0.0 + @public + */ + transitionTo: function (name, context) { + var router = this.router; + return router.transitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - If the return value of an `attributeBindings` monitored property is a boolean - the attribute will be present or absent depending on the value: + /** + Perform a synchronous transition into another route without attempting + to resolve promises, update the URL, or abort any currently active + asynchronous transitions (i.e. regular transitions caused by + `transitionTo` or URL changes). + This method is handy for performing intermediate transitions on the + way to a final destination route, and is called internally by the + default implementations of the `error` and `loading` handlers. + @method intermediateTransitionTo + @param {String} name the name of the route + @param {...Object} models the model(s) to be used while transitioning + to the route. + @since 1.2.0 + @public + */ + intermediateTransitionTo: function () { + var router = this.router; + router.intermediateTransitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'input', - attributeBindings: ['disabled'], - disabled: false - }); - ``` + /** + Refresh the model on this route and any child routes, firing the + `beforeModel`, `model`, and `afterModel` hooks in a similar fashion + to how routes are entered when transitioning in from other route. + The current route params (e.g. `article_id`) will be passed in + to the respective model hooks, and if a different model is returned, + `setupController` and associated route hooks will re-fire as well. + An example usage of this method is re-querying the server for the + latest information using the same parameters as when the route + was first entered. + Note that this will cause `model` hooks to fire even on routes + that were provided a model object when the route was initially + entered. + @method refresh + @return {Transition} the transition object associated with this + attempted transition + @since 1.4.0 + @public + */ + refresh: function () { + return this.router.router.refresh(this); + }, - Will result in a view instance with an HTML representation of: + /** + Transition into another route while replacing the current URL, if possible. + This will replace the current history entry instead of adding a new one. + Beside that, it is identical to `transitionTo` in all other respects. See + 'transitionTo' for additional information regarding multiple models. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('secret'); + }); + export default Router; + ``` + ```app/routes/secret.js + import Ember from 'ember'; + export default Ember.Route.extend({ + afterModel() { + if (!authorized()){ + this.replaceWith('index'); + } + } + }); + ``` + @method replaceWith + @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. + @return {Transition} the transition object associated with this + attempted transition + @since 1.0.0 + @public + */ + replaceWith: function () { + var router = this.router; + return router.replaceWith.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - ```html - - ``` + /** + Sends an action to the router, which will delegate it to the currently + active route hierarchy per the bubbling rules explained under `actions`. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + }); + export default Router; + ``` + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + track(arg) { + console.log(arg, 'was clicked'); + } + } + }); + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + trackIfDebug(arg) { + if (debug) { + this.send('track', arg); + } + } + } + }); + ``` + @method send + @param {String} name the name of the action to trigger + @param {...*} args + @since 1.0.0 + @public + */ + send: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - `attributeBindings` can refer to computed properties: + if (this.router && this.router.router || !_emberMetal.isTesting()) { + var _router; - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'input', - attributeBindings: ['disabled'], - disabled: Ember.computed(function() { - if (someLogic) { - return true; + (_router = this.router).send.apply(_router, args); } else { - return false; + var _name2 = args[0]; + args = slice.call(args, 1); + var action = this.actions[_name2]; + if (action) { + return this.actions[_name2].apply(this, args); + } } - }) - }); - ``` - - To prevent setting an attribute altogether, use `null` or `undefined` as the - return value of the `attributeBindings` monitored property: - - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'form', - attributeBindings: ['novalidate'], - novalidate: null - }); - ``` - - Updates to the property of an attribute binding will result in automatic - update of the HTML attribute in the view's rendered HTML representation. - - `attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html) - documentation for more information about concatenated properties. - - ## Layouts - - Views can have a secondary template that wraps their main template. Like - primary templates, layouts can be any function that accepts an optional - context parameter and returns a string of HTML that will be inserted inside - view's tag. Views whose HTML element is self closing (e.g. ``) - cannot have a layout and this property will be ignored. - - Most typically in Ember a layout will be a compiled template. - - A view's layout can be set directly with the `layout` property or reference - an existing template by name with the `layoutName` property. + }, - A template used as a layout must contain a single use of the - `{{yield}}` helper. The HTML contents of a view's rendered `template` will be - inserted at this location: + /** + This hook is the entry point for router.js + @private + @method setup + */ + setup: function (context, transition) { + var _this3 = this; - ```javascript - AViewWithLayout = Ember.View.extend({ - layout: Ember.HTMLBars.compile("
    {{yield}}
    "), - template: Ember.HTMLBars.compile("I got wrapped") - }); - ``` + var controller = undefined; - Will result in view instances with an HTML representation of: + var controllerName = this.controllerName || this.routeName; + var definedController = this.controllerFor(controllerName, true); - ```html -
    -
    - I got wrapped -
    -
    - ``` + if (!definedController) { + controller = this.generateController(controllerName); + } else { + controller = definedController; + } - See [Ember.Templates.helpers.yield](/api/classes/Ember.Templates.helpers.html#method_yield) - for more information. + // Assign the route's controller so that it can more easily be + // referenced in action handlers. Side effects. Side effects everywhere. + if (!this.controller) { + var propNames = _emberMetal.get(this, '_qp.propertyNames'); + addQueryParamsObservers(controller, propNames); + this.controller = controller; + } - ## Responding to Browser Events + var queryParams = _emberMetal.get(this, '_qp'); - Views can respond to user-initiated events in one of three ways: method - implementation, through an event manager, and through `{{action}}` helper use - in their template or layout. + var states = queryParams.states; - ### Method Implementation + controller._qpDelegate = states.allowOverrides; - Views can respond to user-initiated events by implementing a method that - matches the event name. A `jQuery.Event` object will be passed as the - argument to this method. + if (transition) { + (function () { + // Update the model dep values used to calculate cache keys. + _emberRoutingUtils.stashParamNames(_this3.router, transition.state.handlerInfos); - ```javascript - AView = Ember.View.extend({ - click: function(event) { - // will be called when an instance's - // rendered element is clicked - } - }); - ``` + var params = transition.params; + var allParams = queryParams.propertyNames; + var cache = _this3._bucketCache; - ### Event Managers + allParams.forEach(function (prop) { + var aQp = queryParams.map[prop]; - Views can define an object as their `eventManager` property. This object can - then implement methods that match the desired event names. Matching events - that occur on the view's rendered HTML or the rendered HTML of any of its DOM - descendants will trigger this method. A `jQuery.Event` object will be passed - as the first argument to the method and an `Ember.View` object as the - second. The `Ember.View` will be the view whose rendered HTML was interacted - with. This may be the view with the `eventManager` property or one of its - descendant views. + aQp.values = params; + var cacheKey = _emberRoutingUtils.calculateCacheKey(aQp.route.fullRouteName, aQp.parts, aQp.values); - ```javascript - AView = Ember.View.extend({ - eventManager: Ember.Object.create({ - doubleClick: function(event, view) { - // will be called when an instance's - // rendered element or any rendering - // of this view's descendant - // elements is clicked + if (cache) { + var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); + _emberMetal.set(controller, prop, value); + } + }); + })(); } - }) - }); - ``` - - An event defined for an event manager takes precedence over events of the - same name handled through methods on the view. - ```javascript - AView = Ember.View.extend({ - mouseEnter: function(event) { - // will never trigger. - }, - eventManager: Ember.Object.create({ - mouseEnter: function(event, view) { - // takes precedence over AView#mouseEnter + if (transition) { + var qpValues = getQueryParamsFor(this, transition.state); + controller.setProperties(qpValues); } - }) - }); - ``` - Similarly a view's event manager will take precedence for events of any views - rendered as a descendant. A method name that matches an event name will not - be called if the view instance was rendered inside the HTML representation of - a view that has an `eventManager` property defined that handles events of the - name. Events not handled by the event manager will still trigger method calls - on the descendant. + this.setupController(controller, context, transition); - ```javascript - var App = Ember.Application.create(); - App.OuterView = Ember.View.extend({ - template: Ember.HTMLBars.compile("outer {{#view 'inner'}}inner{{/view}} outer"), - eventManager: Ember.Object.create({ - mouseEnter: function(event, view) { - // view might be instance of either - // OuterView or InnerView depending on - // where on the page the user interaction occurred + if (this._environment.options.shouldRender) { + this.renderTemplate(controller, context); } - }) - }); - - App.InnerView = Ember.View.extend({ - click: function(event) { - // will be called if rendered inside - // an OuterView because OuterView's - // eventManager doesn't handle click events }, - mouseEnter: function(event) { - // will never be called if rendered inside - // an OuterView. - } - }); - ``` - - ### `{{action}}` Helper - - See [Ember.Templates.helpers.action](/api/classes/Ember.Templates.helpers.html#method_action). - - ### Event Names - - All of the event handling approaches described above respond to the same set - of events. The names of the built-in events are listed below. (The hash of - built-in events exists in `Ember.EventDispatcher`.) Additional, custom events - can be registered by using `Ember.Application.customEvents`. - - Touch events: - - * `touchStart` - * `touchMove` - * `touchEnd` - * `touchCancel` - - Keyboard events - - * `keyDown` - * `keyUp` - * `keyPress` - - Mouse events - - * `mouseDown` - * `mouseUp` - * `contextMenu` - * `click` - * `doubleClick` - * `mouseMove` - * `focusIn` - * `focusOut` - * `mouseEnter` - * `mouseLeave` - - Form events: - - * `submit` - * `change` - * `focusIn` - * `focusOut` - * `input` - - HTML5 drag and drop events: - - * `dragStart` - * `drag` - * `dragEnter` - * `dragLeave` - * `dragOver` - * `dragEnd` - * `drop` - - @class View - @namespace Ember - @extends Ember.CoreView - @deprecated See http://emberjs.com/deprecations/v1.x/#toc_ember-view - @uses Ember.ViewSupport - @uses Ember.ChildViewsSupport - @uses Ember.ClassNamesSupport - @uses Ember.AttributeBindingsSupport - @private -*/ -enifed("ember/features", ["exports"], function (exports) { - "use strict"; - - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; -}); -enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { - 'use strict'; - - // ember-utils exports - _emberMetal.default.getOwner = _emberUtils.getOwner; - _emberMetal.default.setOwner = _emberUtils.setOwner; - _emberMetal.default.generateGuid = _emberUtils.generateGuid; - _emberMetal.default.GUID_KEY = _emberUtils.GUID_KEY; - _emberMetal.default.guidFor = _emberUtils.guidFor; - _emberMetal.default.inspect = _emberUtils.inspect; - _emberMetal.default.makeArray = _emberUtils.makeArray; - _emberMetal.default.canInvoke = _emberUtils.canInvoke; - _emberMetal.default.tryInvoke = _emberUtils.tryInvoke; - _emberMetal.default.wrap = _emberUtils.wrap; - _emberMetal.default.applyStr = _emberUtils.applyStr; - _emberMetal.default.uuid = _emberUtils.uuid; - _emberMetal.default.assign = Object.assign || _emberUtils.assign; - - // container exports - _emberMetal.default.Container = _container.Container; - _emberMetal.default.Registry = _container.Registry; - - // need to import this directly, to ensure the babel feature - // flag plugin works properly - - var computed = _emberMetal.computed; - computed.alias = _emberMetal.alias; - _emberMetal.default.computed = computed; - _emberMetal.default.ComputedProperty = _emberMetal.ComputedProperty; - _emberMetal.default.cacheFor = _emberMetal.cacheFor; - - _emberMetal.default.assert = _emberMetal.assert; - _emberMetal.default.warn = _emberMetal.warn; - _emberMetal.default.debug = _emberMetal.debug; - _emberMetal.default.deprecate = _emberMetal.deprecate; - _emberMetal.default.deprecateFunc = _emberMetal.deprecateFunc; - _emberMetal.default.runInDebug = _emberMetal.runInDebug; - _emberMetal.default.merge = _emberMetal.merge; - - _emberMetal.default.instrument = _emberMetal.instrument; - _emberMetal.default.subscribe = _emberMetal.instrumentationSubscribe; - _emberMetal.default.Instrumentation = { - instrument: _emberMetal.instrument, - subscribe: _emberMetal.instrumentationSubscribe, - unsubscribe: _emberMetal.instrumentationUnsubscribe, - reset: _emberMetal.instrumentationReset - }; - - _emberMetal.default.Error = _emberMetal.Error; - _emberMetal.default.META_DESC = _emberMetal.META_DESC; - _emberMetal.default.meta = _emberMetal.meta; - _emberMetal.default.get = _emberMetal.get; - _emberMetal.default.getWithDefault = _emberMetal.getWithDefault; - _emberMetal.default._getPath = _emberMetal._getPath; - _emberMetal.default.set = _emberMetal.set; - _emberMetal.default.trySet = _emberMetal.trySet; - _emberMetal.default.FEATURES = _emberMetal.FEATURES; - _emberMetal.default.FEATURES.isEnabled = _emberMetal.isFeatureEnabled; - _emberMetal.default._Cache = _emberMetal.Cache; - _emberMetal.default.on = _emberMetal.on; - _emberMetal.default.addListener = _emberMetal.addListener; - _emberMetal.default.removeListener = _emberMetal.removeListener; - _emberMetal.default._suspendListener = _emberMetal.suspendListener; - _emberMetal.default._suspendListeners = _emberMetal.suspendListeners; - _emberMetal.default.sendEvent = _emberMetal.sendEvent; - _emberMetal.default.hasListeners = _emberMetal.hasListeners; - _emberMetal.default.watchedEvents = _emberMetal.watchedEvents; - _emberMetal.default.listenersFor = _emberMetal.listenersFor; - _emberMetal.default.accumulateListeners = _emberMetal.accumulateListeners; - _emberMetal.default.isNone = _emberMetal.isNone; - _emberMetal.default.isEmpty = _emberMetal.isEmpty; - _emberMetal.default.isBlank = _emberMetal.isBlank; - _emberMetal.default.isPresent = _emberMetal.isPresent; - _emberMetal.default.run = _emberMetal.run; - _emberMetal.default._ObserverSet = _emberMetal.ObserverSet; - _emberMetal.default.propertyWillChange = _emberMetal.propertyWillChange; - _emberMetal.default.propertyDidChange = _emberMetal.propertyDidChange; - _emberMetal.default.overrideChains = _emberMetal.overrideChains; - _emberMetal.default.beginPropertyChanges = _emberMetal.beginPropertyChanges; - _emberMetal.default.endPropertyChanges = _emberMetal.endPropertyChanges; - _emberMetal.default.changeProperties = _emberMetal.changeProperties; - _emberMetal.default.platform = { - defineProperty: true, - hasPropertyAccessors: true - }; - _emberMetal.default.defineProperty = _emberMetal.defineProperty; - _emberMetal.default.watchKey = _emberMetal.watchKey; - _emberMetal.default.unwatchKey = _emberMetal.unwatchKey; - _emberMetal.default.removeChainWatcher = _emberMetal.removeChainWatcher; - _emberMetal.default._ChainNode = _emberMetal.ChainNode; - _emberMetal.default.finishChains = _emberMetal.finishChains; - _emberMetal.default.watchPath = _emberMetal.watchPath; - _emberMetal.default.unwatchPath = _emberMetal.unwatchPath; - _emberMetal.default.watch = _emberMetal.watch; - _emberMetal.default.isWatching = _emberMetal.isWatching; - _emberMetal.default.unwatch = _emberMetal.unwatch; - _emberMetal.default.destroy = _emberMetal.destroy; - _emberMetal.default.libraries = _emberMetal.libraries; - _emberMetal.default.OrderedSet = _emberMetal.OrderedSet; - _emberMetal.default.Map = _emberMetal.Map; - _emberMetal.default.MapWithDefault = _emberMetal.MapWithDefault; - _emberMetal.default.getProperties = _emberMetal.getProperties; - _emberMetal.default.setProperties = _emberMetal.setProperties; - _emberMetal.default.expandProperties = _emberMetal.expandProperties; - _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; - _emberMetal.default.addObserver = _emberMetal.addObserver; - _emberMetal.default.observersFor = _emberMetal.observersFor; - _emberMetal.default.removeObserver = _emberMetal.removeObserver; - _emberMetal.default._suspendObserver = _emberMetal._suspendObserver; - _emberMetal.default._suspendObservers = _emberMetal._suspendObservers; - _emberMetal.default.required = _emberMetal.required; - _emberMetal.default.aliasMethod = _emberMetal.aliasMethod; - _emberMetal.default.observer = _emberMetal.observer; - _emberMetal.default.immediateObserver = _emberMetal._immediateObserver; - _emberMetal.default.mixin = _emberMetal.mixin; - _emberMetal.default.Mixin = _emberMetal.Mixin; - _emberMetal.default.bind = _emberMetal.bind; - _emberMetal.default.Binding = _emberMetal.Binding; - _emberMetal.default.isGlobalPath = _emberMetal.isGlobalPath; - if (false) { - _emberMetal.default.WeakMap = _emberMetal.WeakMap; - } + /* + Called when a query parameter for this route changes, regardless of whether the route + is currently part of the active route hierarchy. This will update the query parameter's + value in the cache so if this route becomes active, the cache value has been updated. + */ + _qpChanged: function (prop, value, qp) { + if (!qp) { + return; + } - Object.defineProperty(_emberMetal.default, 'ENV', { - get: function () { - return _emberEnvironment.ENV; - }, - enumerable: false - }); + var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.route.fullRouteName, qp.parts, qp.values); - /** - The context that Ember searches for namespace instances on. - - @private - */ - Object.defineProperty(_emberMetal.default, 'lookup', { - get: function () { - return _emberEnvironment.context.lookup; - }, - set: function (value) { - _emberEnvironment.context.lookup = value; + // Update model-dep cache + var cache = this._bucketCache; + if (cache) { + cache.stash(cacheKey, prop, value); + } }, - enumerable: false - }); - - _emberMetal.default.EXTEND_PROTOTYPES = _emberEnvironment.ENV.EXTEND_PROTOTYPES; - // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS - Object.defineProperty(_emberMetal.default, 'LOG_STACKTRACE_ON_DEPRECATION', { - get: function () { - return _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; - }, - enumerable: false - }); + /** + This hook is the first of the route entry validation hooks + called when an attempt is made to transition into a route + or one of its children. It is called before `model` and + `afterModel`, and is appropriate for cases when: + 1) A decision can be made to redirect elsewhere without + needing to resolve the model first. + 2) Any async operations need to occur first before the + model is attempted to be resolved. + This hook is provided the current `transition` attempt + as a parameter, which can be used to `.abort()` the transition, + save it for a later `.retry()`, or retrieve values set + on it from a previous hook. You can also just call + `this.transitionTo` to another route to implicitly + abort the `transition`. + You can return a promise from this hook to pause the + transition until the promise resolves (or rejects). This could + be useful, for instance, for retrieving async code from + the server that is required to enter a route. + @method beforeModel + @param {Transition} transition + @return {Promise} if the value returned from this hook is + a promise, the transition will pause until the transition + resolves. Otherwise, non-promise return values are not + utilized in any way. + @since 1.0.0 + @public + */ + beforeModel: K, - Object.defineProperty(_emberMetal.default, 'LOG_VERSION', { - get: function () { - return _emberEnvironment.ENV.LOG_VERSION; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_VERSION = !!value; - }, - enumerable: false - }); + /** + This hook is called after this route's model has resolved. + It follows identical async/promise semantics to `beforeModel` + but is provided the route's resolved model in addition to + the `transition`, and is therefore suited to performing + logic that can only take place after the model has already + resolved. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + afterModel(posts, transition) { + if (posts.get('length') === 1) { + this.transitionTo('post.show', posts.get('firstObject')); + } + } + }); + ``` + Refer to documentation for `beforeModel` for a description + of transition-pausing semantics when a promise is returned + from this hook. + @method afterModel + @param {Object} resolvedModel the value returned from `model`, + or its resolved value if it was a promise + @param {Transition} transition + @return {Promise} if the value returned from this hook is + a promise, the transition will pause until the transition + resolves. Otherwise, non-promise return values are not + utilized in any way. + @since 1.0.0 + @public + */ + afterModel: K, - Object.defineProperty(_emberMetal.default, 'MODEL_FACTORY_INJECTIONS', { - get: function () { - return _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; - }, - set: function (value) { - _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = !!value; - }, - enumerable: false - }); + /** + A hook you can implement to optionally redirect to another route. + If you call `this.transitionTo` from inside of this hook, this route + will not be entered in favor of the other hook. + `redirect` and `afterModel` behave very similarly and are + called almost at the same time, but they have an important + distinction in the case that, from one of these hooks, a + redirect into a child route of this route occurs: redirects + from `afterModel` essentially invalidate the current attempt + to enter this route, and will result in this route's `beforeModel`, + `model`, and `afterModel` hooks being fired again within + the new, redirecting transition. Redirects that occur within + the `redirect` hook, on the other hand, will _not_ cause + these hooks to be fired again the second time around; in + other words, by the time the `redirect` hook has been called, + both the resolved model and attempted entry into this route + are considered to be fully validated. + @method redirect + @param {Object} model the model for this route + @param {Transition} transition the transition object associated with the current transition + @since 1.0.0 + @public + */ + redirect: K, - Object.defineProperty(_emberMetal.default, 'LOG_BINDINGS', { - get: function () { - return _emberEnvironment.ENV.LOG_BINDINGS; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_BINDINGS = !!value; + /** + Called when the context is changed by router.js. + @private + @method contextDidChange + */ + contextDidChange: function () { + this.currentModel = this.context; }, - enumerable: false - }); - /** - A function may be assigned to `Ember.onerror` to be called when Ember - internals encounter an error. This is useful for specialized error handling - and reporting code. - - ```javascript - Ember.onerror = function(error) { - Em.$.ajax('/report-error', 'POST', { - stack: error.stack, - otherInformation: 'whatever app state you want to provide' + /** + A hook you can implement to convert the URL into the model for + this route. + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); }); - }; - ``` - - Internally, `Ember.onerror` is used as Backburner's error handler. - - @event onerror - @for Ember - @param {Exception} error the error object - @public - */ - Object.defineProperty(_emberMetal.default, 'onerror', { - get: _emberMetal.getOnerror, - set: _emberMetal.setOnerror, - enumerable: false - }); + export default Router; + ``` + The model for the `post` route is `store.findRecord('post', params.post_id)`. + By default, if your route has a dynamic segment ending in `_id`: + * The model class is determined from the segment (`post_id`'s + class is `App.Post`) + * The find method is called on the model class with the value of + the dynamic segment. + Note that for routes with dynamic segments, this hook is not always + executed. If the route is entered through a transition (e.g. when + using the `link-to` Handlebars helper or the `transitionTo` method + of routes), and a model context is already provided this hook + is not called. + A model context does not include a primitive string or number, + which does cause the model hook to be called. + Routes without dynamic segments will always execute the model hook. + ```javascript + // no dynamic segment, model hook always called + this.transitionTo('posts'); + // model passed in, so model hook not called + thePost = store.findRecord('post', 1); + this.transitionTo('post', thePost); + // integer passed in, model hook is called + this.transitionTo('post', 1); + // model id passed in, model hook is called + // useful for forcing the hook to execute + thePost = store.findRecord('post', 1); + this.transitionTo('post', thePost.id); + ``` + This hook follows the asynchronous/promise semantics + described in the documentation for `beforeModel`. In particular, + if a promise returned from `model` fails, the error will be + handled by the `error` hook on `Ember.Route`. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model(params) { + return this.store.findRecord('post', params.post_id); + } + }); + ``` + @method model + @param {Object} params the parameters extracted from the URL + @param {Transition} transition + @return {Object|Promise} the model for this route. If + a promise is returned, the transition will pause until + the promise resolves, and the resolved value of the promise + will be used as the model for this route. + @since 1.0.0 + @public + */ + model: function (params, transition) { + var name = undefined, + sawParams = undefined, + value = undefined; + var queryParams = _emberMetal.get(this, '_qp.map'); - /** - An empty function useful for some operations. Always returns `this`. - - @method K - @return {Object} - @public - */ - _emberMetal.default.K = function K() { - return this; - }; + for (var prop in params) { + if (prop === 'queryParams' || queryParams && prop in queryParams) { + continue; + } - Object.defineProperty(_emberMetal.default, 'testing', { - get: _emberMetal.isTesting, - set: _emberMetal.setTesting, - enumerable: false - }); + var match = prop.match(/^(.*)_id$/); + if (match) { + name = match[1]; + value = params[prop]; + } + sawParams = true; + } - if (!_require.has('ember-debug')) { - _emberMetal.default.Debug = { - registerDeprecationHandler: function () {}, - registerWarnHandler: function () {} - }; - } + if (!name && sawParams) { + return _emberRuntime.copy(params); + } else if (!name) { + if (transition.resolveIndex < 1) { + return; + } - /** - @class Backburner - @for Ember - @private - */ - _emberMetal.default.Backburner = function () { - _emberMetal.deprecate('Usage of Ember.Backburner is deprecated.', false, { - id: 'ember-metal.ember-backburner', - until: '2.8.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-backburner' - }); + return transition.state.handlerInfos[transition.resolveIndex - 1].context; + } - function BackburnerAlias(args) { - return _backburner.default.apply(this, args); - } + return this.findModel(name, value); + }, - BackburnerAlias.prototype = _backburner.default.prototype; + /** + @private + @method deserialize + @param {Object} params the parameters extracted from the URL + @param {Transition} transition + @return {Object|Promise} the model for this route. + Router.js hook. + */ + deserialize: function (params, transition) { + return this.model(this.paramsFor(this.routeName), transition); + }, - return new BackburnerAlias(arguments); - }; + /** + @method findModel + @param {String} type the model type + @param {Object} value the value passed to find + @private + */ + findModel: function () { + var store = _emberMetal.get(this, 'store'); + return store.find.apply(store, arguments); + }, - _emberMetal.default._Backburner = _backburner.default; + /** + Store property provides a hook for data persistence libraries to inject themselves. + By default, this store property provides the exact same functionality previously + in the model hook. + Currently, the required interface is: + `store.find(modelName, findArguments)` + @method store + @param {Object} store + @private + */ + store: _emberMetal.computed(function () { + var owner = _emberUtils.getOwner(this); + var routeName = this.routeName; + var namespace = _emberMetal.get(this, 'router.namespace'); - _emberMetal.default.Logger = _emberConsole.default; + return { + find: function (name, value) { + var modelClass = owner[_container.FACTORY_FOR]('model:' + name); - // ****ember-runtime**** + _emberMetal.assert('You used the dynamic segment ' + name + '_id in your route ' + routeName + ', but ' + namespace + '.' + _emberRuntime.String.classify(name) + ' did not exist and you did not override your route\'s `model` hook.', !!modelClass); - _emberMetal.default.String = _emberRuntime.String; - _emberMetal.default.Object = _emberRuntime.Object; - _emberMetal.default._RegistryProxyMixin = _emberRuntime.RegistryProxyMixin; - _emberMetal.default._ContainerProxyMixin = _emberRuntime.ContainerProxyMixin; - _emberMetal.default.compare = _emberRuntime.compare; - _emberMetal.default.copy = _emberRuntime.copy; - _emberMetal.default.isEqual = _emberRuntime.isEqual; - _emberMetal.default.inject = _emberRuntime.inject; - _emberMetal.default.Array = _emberRuntime.Array; - _emberMetal.default.Comparable = _emberRuntime.Comparable; - _emberMetal.default.Enumerable = _emberRuntime.Enumerable; - _emberMetal.default.ArrayProxy = _emberRuntime.ArrayProxy; - _emberMetal.default.ObjectProxy = _emberRuntime.ObjectProxy; - _emberMetal.default.ActionHandler = _emberRuntime.ActionHandler; - _emberMetal.default.CoreObject = _emberRuntime.CoreObject; - _emberMetal.default.NativeArray = _emberRuntime.NativeArray; - _emberMetal.default.Copyable = _emberRuntime.Copyable; - _emberMetal.default.Freezable = _emberRuntime.Freezable; - _emberMetal.default.FROZEN_ERROR = _emberRuntime.FROZEN_ERROR; - _emberMetal.default.MutableEnumerable = _emberRuntime.MutableEnumerable; - _emberMetal.default.MutableArray = _emberRuntime.MutableArray; - _emberMetal.default.TargetActionSupport = _emberRuntime.TargetActionSupport; - _emberMetal.default.Evented = _emberRuntime.Evented; - _emberMetal.default.PromiseProxyMixin = _emberRuntime.PromiseProxyMixin; - _emberMetal.default.Observable = _emberRuntime.Observable; - _emberMetal.default.typeOf = _emberRuntime.typeOf; - _emberMetal.default.isArray = _emberRuntime.isArray; - _emberMetal.default.Object = _emberRuntime.Object; - _emberMetal.default.onLoad = _emberRuntime.onLoad; - _emberMetal.default.runLoadHooks = _emberRuntime.runLoadHooks; - _emberMetal.default.Controller = _emberRuntime.Controller; - _emberMetal.default.ControllerMixin = _emberRuntime.ControllerMixin; - _emberMetal.default.Service = _emberRuntime.Service; - _emberMetal.default._ProxyMixin = _emberRuntime._ProxyMixin; - _emberMetal.default.RSVP = _emberRuntime.RSVP; - _emberMetal.default.Namespace = _emberRuntime.Namespace; + if (!modelClass) { + return; + } - // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed - computed.empty = _emberRuntime.empty; - computed.notEmpty = _emberRuntime.notEmpty; - computed.none = _emberRuntime.none; - computed.not = _emberRuntime.not; - computed.bool = _emberRuntime.bool; - computed.match = _emberRuntime.match; - computed.equal = _emberRuntime.equal; - computed.gt = _emberRuntime.gt; - computed.gte = _emberRuntime.gte; - computed.lt = _emberRuntime.lt; - computed.lte = _emberRuntime.lte; - computed.oneWay = _emberRuntime.oneWay; - computed.reads = _emberRuntime.oneWay; - computed.readOnly = _emberRuntime.readOnly; - computed.deprecatingAlias = _emberRuntime.deprecatingAlias; - computed.and = _emberRuntime.and; - computed.or = _emberRuntime.or; - computed.any = _emberRuntime.any; + modelClass = modelClass.class; - computed.sum = _emberRuntime.sum; - computed.min = _emberRuntime.min; - computed.max = _emberRuntime.max; - computed.map = _emberRuntime.map; - computed.sort = _emberRuntime.sort; - computed.setDiff = _emberRuntime.setDiff; - computed.mapBy = _emberRuntime.mapBy; - computed.filter = _emberRuntime.filter; - computed.filterBy = _emberRuntime.filterBy; - computed.uniq = _emberRuntime.uniq; + _emberMetal.assert(_emberRuntime.String.classify(name) + ' has no method `find`.', typeof modelClass.find === 'function'); - if (true) { - computed.uniqBy = _emberRuntime.uniqBy; - } - computed.union = _emberRuntime.union; - computed.intersect = _emberRuntime.intersect; - computed.collect = _emberRuntime.collect; + return modelClass.find(value); + } + }; + }), - /** - Defines the hash of localized strings for the current language. Used by - the `Ember.String.loc()` helper. To localize, add string values to this - hash. - - @property STRINGS - @for Ember - @type Object - @private - */ - Object.defineProperty(_emberMetal.default, 'STRINGS', { - configurable: false, - get: _emberRuntime.getStrings, - set: _emberRuntime.setStrings - }); + /** + A hook you can implement to convert the route's model into parameters + for the URL. + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); + }); + ``` + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model(params) { + // the server returns `{ id: 12 }` + return Ember.$.getJSON('/posts/' + params.post_id); + }, + serialize(model) { + // this will make the URL `/posts/12` + return { post_id: model.id }; + } + }); + ``` + The default `serialize` method will insert the model's `id` into the + route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'. + If the route has multiple dynamic segments or does not contain '_id', `serialize` + will return `Ember.getProperties(model, params)` + This method is called when `transitionTo` is called with a context + in order to populate the URL. + @method serialize + @param {Object} model the routes model + @param {Array} params an Array of parameter names for the current + route (in the example, `['post_id']`. + @return {Object} the serialized parameters + @since 1.0.0 + @public + */ + serialize: defaultSerialize, - /** - Whether searching on the global for new Namespace instances is enabled. - - This is only exported here as to not break any addons. Given the new - visit API, you will have issues if you treat this as a indicator of - booted. - - Internally this is only exposing a flag in Namespace. - - @property BOOTED - @for Ember - @type Boolean - @private - */ - Object.defineProperty(_emberMetal.default, 'BOOTED', { - configurable: false, - enumerable: false, - get: _emberRuntime.isNamespaceSearchDisabled, - set: _emberRuntime.setNamespaceSearchDisabled - }); + /** + A hook you can use to setup the controller for the current route. + This method is called with the controller for the current route and the + model supplied by the `model` hook. + By default, the `setupController` hook sets the `model` property of + the controller to the `model`. + If you implement the `setupController` hook in your Route, it will + prevent this default behavior. If you want to preserve that behavior + when implementing your `setupController` function, make sure to call + `_super`: + ```app/routes/photos.js + import Ember from 'ebmer'; + export default Ember.Route.extend({ + model() { + return this.store.findAll('photo'); + }, + setupController(controller, model) { + // Call _super for default behavior + this._super(controller, model); + // Implement your custom setup after + this.controllerFor('application').set('showingPhotos', true); + } + }); + ``` + The provided controller will be one resolved based on the name + of this route. + If no explicit controller is defined, Ember will automatically create one. + As an example, consider the router: + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); + }); + export default Router; + ``` + For the `post` route, a controller named `App.PostController` would + be used if it is defined. If it is not defined, a basic `Ember.Controller` + instance would be used. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, model) { + controller.set('model', model); + } + }); + ``` + @method setupController + @param {Controller} controller instance + @param {Object} model + @since 1.0.0 + @public + */ + setupController: function (controller, context, transition) { + if (controller && context !== undefined) { + _emberMetal.set(controller, 'model', context); + } + }, + + /** + Returns the resolved model of the current route, or a parent (or any ancestor) + route in a route hierarchy. + The controller instance must already have been created, either through entering the + associated route or using `generateController`. + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, post) { + this._super(controller, post); + this.controllerFor('posts').set('currentPost', post); + } + }); + ``` + @method controllerFor + @param {String} name the name of the route or controller + @return {Ember.Controller} + @since 1.0.0 + @public + */ + controllerFor: function (name, _skipAssert) { + var owner = _emberUtils.getOwner(this); + var route = owner.lookup('route:' + name); + var controller = undefined; + + if (route && route.controllerName) { + name = route.controllerName; + } - _emberMetal.default.Component = _emberGlimmer.Component; - _emberGlimmer.Helper.helper = _emberGlimmer.helper; - _emberMetal.default.Helper = _emberGlimmer.Helper; - _emberMetal.default.Checkbox = _emberGlimmer.Checkbox; - _emberMetal.default.TextField = _emberGlimmer.TextField; - _emberMetal.default.TextArea = _emberGlimmer.TextArea; - _emberMetal.default.LinkComponent = _emberGlimmer.LinkComponent; + controller = owner.lookup('controller:' + name); - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { - String.prototype.htmlSafe = function () { - return _emberGlimmer.htmlSafe(this); - }; - } + // NOTE: We're specifically checking that skipAssert is true, because according + // to the old API the second parameter was model. We do not want people who + // passed a model to skip the assertion. + _emberMetal.assert('The controller named \'' + name + '\' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.', controller || _skipAssert === true); - var EmberHandlebars = _emberMetal.default.Handlebars = _emberMetal.default.Handlebars || {}; - var EmberHTMLBars = _emberMetal.default.HTMLBars = _emberMetal.default.HTMLBars || {}; - var EmberHandleBarsUtils = EmberHandlebars.Utils = EmberHandlebars.Utils || {}; + return controller; + }, - Object.defineProperty(EmberHandlebars, 'SafeString', { - get: _emberGlimmer._getSafeString - }); + /** + Generates a controller for a route. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, post) { + this._super(controller, post); + this.generateController('posts'); + } + }); + ``` + @method generateController + @param {String} name the name of the controller + @private + */ + generateController: function (name) { + var owner = _emberUtils.getOwner(this); - EmberHTMLBars.template = EmberHandlebars.template = _emberGlimmer.template; - EmberHandleBarsUtils.escapeExpression = _emberGlimmer.escapeExpression; - _emberRuntime.String.htmlSafe = _emberGlimmer.htmlSafe; + return _emberRoutingSystemGenerate_controller.default(owner, name); + }, - if (true) { - _emberRuntime.String.isHTMLSafe = _emberGlimmer.isHTMLSafe; - } - EmberHTMLBars.makeBoundHelper = _emberGlimmer.makeBoundHelper; + /** + Returns the resolved model of a parent (or any ancestor) route + in a route hierarchy. During a transition, all routes + must resolve a model object, and if a route + needs access to a parent route's model in order to + resolve a model (or just reuse the model from a parent), + it can call `this.modelFor(theNameOfParentRoute)` to + retrieve it. If the ancestor route's model was a promise, + its resolved result is returned. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }, function() { + this.route('comments'); + }); + }); + export default Router; + ``` + ```app/routes/comments.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model() { + let post = this.modelFor('post'); + return post.get('comments'); + } + }); + ``` + @method modelFor + @param {String} name the name of the route + @return {Object} the model object + @since 1.0.0 + @public + */ + modelFor: function (_name) { + var name = undefined; + var owner = _emberUtils.getOwner(this); - /** - Global hash of shared templates. This will automatically be populated - by the build tools so that you can store your Handlebars templates in - separate files that get loaded into JavaScript at buildtime. - - @property TEMPLATES - @for Ember - @type Object - @private - */ - Object.defineProperty(_emberMetal.default, 'TEMPLATES', { - get: _emberGlimmer.getTemplates, - set: _emberGlimmer.setTemplates, - configurable: false, - enumerable: false - }); + // Only change the route name when there is an active transition. + // Otherwise, use the passed in route name. + if (owner.routable && this.router && this.router.router.activeTransition) { + name = getEngineRouteName(owner, _name); + } else { + name = _name; + } - exports.VERSION = _emberVersion.default; + var route = _emberUtils.getOwner(this).lookup('route:' + name); + var transition = this.router ? this.router.router.activeTransition : null; - /** - The semantic version - @property VERSION - @type String - @public - */ - _emberMetal.default.VERSION = _emberVersion.default; + // If we are mid-transition, we want to try and look up + // resolved parent contexts on the current transitionEvent. + if (transition) { + var modelLookupName = route && route.routeName || name; + if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { + return transition.resolvedModels[modelLookupName]; + } + } - _emberMetal.libraries.registerCoreLibrary('Ember', _emberVersion.default); + return route && route.currentModel; + }, - _emberMetal.default.create = _emberMetal.deprecateFunc('Ember.create is deprecated in favor of Object.create', { id: 'ember-metal.ember-create', until: '3.0.0' }, Object.create); - _emberMetal.default.keys = _emberMetal.deprecateFunc('Ember.keys is deprecated in favor of Object.keys', { id: 'ember-metal.ember.keys', until: '3.0.0' }, Object.keys); + /** + A hook you can use to render the template for the current route. + This method is called with the controller for the current route and the + model supplied by the `model` hook. By default, it renders the route's + template, configured with the controller for the route. + This method can be overridden to set up and render additional or + alternative templates. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate(controller, model) { + let favController = this.controllerFor('favoritePost'); + // Render the `favoritePost` template into + // the outlet `posts`, and display the `favoritePost` + // controller. + this.render('favoritePost', { + outlet: 'posts', + controller: favController + }); + } + }); + ``` + @method renderTemplate + @param {Object} controller the route's controller + @param {Object} model the route's model + @since 1.0.0 + @public + */ + renderTemplate: function (controller, model) { + this.render(); + }, - // require the main entry points for each of these packages - // this is so that the global exports occur properly + /** + `render` is used to render a template into a region of another template + (indicated by an `{{outlet}}`). `render` is used both during the entry + phase of routing (via the `renderTemplate` hook) and later in response to + user interaction. + For example, given the following minimal router and templates: + ```app/router.js + // ... + Router.map(function() { + this.route('photos'); + }); + export default Router; + ``` + ```handlebars + +
    + {{outlet "anOutletName"}} +
    + ``` + ```handlebars + +

    Photos

    + ``` + You can render `photos.hbs` into the `"anOutletName"` outlet of + `application.hbs` by calling `render`: + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate() { + this.render('photos', { + into: 'application', + outlet: 'anOutletName' + }) + } + }); + ``` + `render` additionally allows you to supply which `controller` and + `model` objects should be loaded and associated with the rendered template. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate(controller, model){ + this.render('posts', { // the template to render, referenced by name + into: 'application', // the template to render into, referenced by name + outlet: 'anOutletName', // the outlet inside `options.template` to render into. + controller: 'someControllerName', // the controller to use for this template, referenced by name + model: model // the model to set on `options.controller`. + }) + } + }); + ``` + The string values provided for the template name, and controller + will eventually pass through to the resolver for lookup. See + Ember.Resolver for how these are mapped to JavaScript objects in your + application. The template to render into needs to be related to either the + current route or one of its ancestors. + Not all options need to be passed to `render`. Default values will be used + based on the name of the route specified in the router or the Route's + `controllerName` and `templateName` properties. + For example: + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('post', { path: '/posts/:post_id' }); + }); + export default Router; + ``` + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate() { + this.render(); // all defaults apply + } + }); + ``` + The name of the route, defined by the router, is `post`. + The following equivalent default options will be applied when + the Route calls `render`: + ```javascript + this.render('post', { // the template name associated with 'post' Route + into: 'application', // the parent route to 'post' Route + outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, + controller: 'post', // the controller associated with the 'post' Route + }) + ``` + By default the controller's `model` will be the route's model, so it does not + need to be passed unless you wish to change which model is being used. + @method render + @param {String} name the name of the template to render + @param {Object} [options] the options + @param {String} [options.into] the template to render into, + referenced by name. Defaults to the parent template + @param {String} [options.outlet] the outlet inside `options.template` to render into. + Defaults to 'main' + @param {String|Object} [options.controller] the controller to use for this template, + referenced by name or as a controller instance. Defaults to the Route's paired controller + @param {Object} [options.model] the model object to set on `options.controller`. + Defaults to the return value of the Route's model hook + @since 1.0.0 + @public + */ + render: function (_name, options) { + _emberMetal.assert('The name in the given arguments is undefined', arguments.length > 0 ? !_emberMetal.isNone(arguments[0]) : true); - /** - Alias for jQuery - - @method $ - @for Ember - @public - */ - _emberMetal.default.$ = _emberViews.jQuery; + var namePassed = typeof _name === 'string' && !!_name; + var isDefaultRender = arguments.length === 0 || _emberMetal.isEmpty(arguments[0]); + var name = undefined; - _emberMetal.default.ViewTargetActionSupport = _emberViews.ViewTargetActionSupport; + if (typeof _name === 'object' && !options) { + name = this.templateName || this.routeName; + options = _name; + } else { + name = _name; + } - _emberMetal.default.ViewUtils = { - isSimpleClick: _emberViews.isSimpleClick, - getViewElement: _emberViews.getViewElement, - getViewBounds: _emberViews.getViewBounds, - getViewClientRects: _emberViews.getViewClientRects, - getViewBoundingClientRect: _emberViews.getViewBoundingClientRect, - getRootViews: _emberViews.getRootViews, - getChildViews: _emberViews.getChildViews - }; + var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); + this.connections.push(renderOptions); + _emberMetal.run.once(this.router, '_setOutlets'); + }, - _emberMetal.default.TextSupport = _emberViews.TextSupport; - _emberMetal.default.ComponentLookup = _emberViews.ComponentLookup; - _emberMetal.default.EventDispatcher = _emberViews.EventDispatcher; + /** + Disconnects a view that has been rendered into an outlet. + You may pass any or all of the following options to `disconnectOutlet`: + * `outlet`: the name of the outlet to clear (default: 'main') + * `parentView`: the name of the view containing the outlet to clear + (default: the view rendered by the parent route) + Example: + ```app/routes/application.js + import Ember from 'ember'; + export default App.Route.extend({ + actions: { + showModal(evt) { + this.render(evt.modalName, { + outlet: 'modal', + into: 'application' + }); + }, + hideModal(evt) { + this.disconnectOutlet({ + outlet: 'modal', + parentView: 'application' + }); + } + } + }); + ``` + Alternatively, you can pass the `outlet` name directly as a string. + Example: + ```app/routes/application.js + import Ember from 'ember'; + export default App.Route.extend({ + actions: { + showModal(evt) { + // ... + }, + hideModal(evt) { + this.disconnectOutlet('modal'); + } + } + }); + @method disconnectOutlet + @param {Object|String} options the options hash or outlet name + @since 1.0.0 + @public + */ + disconnectOutlet: function (options) { + var outletName = undefined; + var parentView = undefined; + if (!options || typeof options === 'string') { + outletName = options; + } else { + outletName = options.outlet; + parentView = options.parentView; - _emberMetal.default.Location = _emberRouting.Location; - _emberMetal.default.AutoLocation = _emberRouting.AutoLocation; - _emberMetal.default.HashLocation = _emberRouting.HashLocation; - _emberMetal.default.HistoryLocation = _emberRouting.HistoryLocation; - _emberMetal.default.NoneLocation = _emberRouting.NoneLocation; - _emberMetal.default.controllerFor = _emberRouting.controllerFor; - _emberMetal.default.generateControllerFactory = _emberRouting.generateControllerFactory; - _emberMetal.default.generateController = _emberRouting.generateController; - _emberMetal.default.RouterDSL = _emberRouting.RouterDSL; - _emberMetal.default.Router = _emberRouting.Router; - _emberMetal.default.Route = _emberRouting.Route; + if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { + throw new _emberMetal.Error('You passed undefined as the outlet name.'); + } + } + parentView = parentView && parentView.replace(/\//g, '.'); + outletName = outletName || 'main'; + this._disconnectOutlet(outletName, parentView); + for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { + // This non-local state munging is sadly necessary to maintain + // backward compatibility with our existing semantics, which allow + // any route to disconnectOutlet things originally rendered by any + // other route. This should all get cut in 2.0. + this.router.router.currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); + } + }, - _emberMetal.default.Application = _emberApplication.Application; - _emberMetal.default.ApplicationInstance = _emberApplication.ApplicationInstance; - _emberMetal.default.Engine = _emberApplication.Engine; - _emberMetal.default.EngineInstance = _emberApplication.EngineInstance; - _emberMetal.default.DefaultResolver = _emberMetal.default.Resolver = _emberApplication.Resolver; + _disconnectOutlet: function (outletName, parentView) { + var parent = parentRoute(this); + if (parent && parentView === parent.routeName) { + parentView = undefined; + } + for (var i = 0; i < this.connections.length; i++) { + var connection = this.connections[i]; + if (connection.outlet === outletName && connection.into === parentView) { + // This neuters the disconnected outlet such that it doesn't + // render anything, but it leaves an entry in the outlet + // hierarchy so that any existing other renders that target it + // don't suddenly blow up. They will still stick themselves + // into its outlets, which won't render anywhere. All of this + // statefulness should get the machete in 2.0. + this.connections[i] = { + owner: connection.owner, + into: connection.into, + outlet: connection.outlet, + name: connection.name, + controller: undefined, + template: undefined, + ViewClass: undefined + }; + _emberMetal.run.once(this.router, '_setOutlets'); + } + } + }, - _emberRuntime.runLoadHooks('Ember.Application', _emberApplication.Application); + willDestroy: function () { + this.teardownViews(); + }, - _emberMetal.default.DataAdapter = _emberExtensionSupport.DataAdapter; - _emberMetal.default.ContainerDebugAdapter = _emberExtensionSupport.ContainerDebugAdapter; + /** + @private + @method teardownViews + */ + teardownViews: function () { + if (this.connections && this.connections.length > 0) { + this.connections = []; + _emberMetal.run.once(this.router, '_setOutlets'); + } + } + }); - if (_require.has('ember-template-compiler')) { - _require.default('ember-template-compiler'); - } + _emberRuntime.deprecateUnderscoreActions(Route); - // do this to ensure that Ember.Test is defined properly on the global - // if it is present. - if (_require.has('ember-testing')) { - var testing = _require.default('ember-testing'); + Route.reopenClass({ + isRouteFactory: true + }); - _emberMetal.default.Test = testing.Test; - _emberMetal.default.Test.Adapter = testing.Adapter; - _emberMetal.default.Test.QUnitAdapter = testing.QUnitAdapter; - _emberMetal.default.setupForTesting = testing.setupForTesting; + function parentRoute(route) { + var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); + return handlerInfo && handlerInfo.handler; } - _emberRuntime.runLoadHooks('Ember'); + function handlerInfoFor(route, handlerInfos) { + var offset = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2]; - /** - @module ember - */ - exports.default = _emberMetal.default; + if (!handlerInfos) { + return; + } - /* globals module */ - if (typeof module === 'object' && module.exports) { - module.exports = _emberMetal.default; - } else { - _emberEnvironment.context.exports.Ember = _emberEnvironment.context.exports.Em = _emberMetal.default; + var current = undefined; + for (var i = 0; i < handlerInfos.length; i++) { + current = handlerInfos[i].handler; + if (current === route) { + return handlerInfos[i + offset]; + } + } } -}); -// ****ember-environment**** + function buildRenderOptions(route, namePassed, isDefaultRender, _name, options) { + var into = options && options.into && options.into.replace(/\//g, '.'); + var outlet = options && options.outlet || 'main'; -// ****ember-metal**** + var name = undefined, + templateName = undefined; + if (_name) { + name = _name.replace(/\//g, '.'); + templateName = name; + } else { + name = route.routeName; + templateName = route.templateName || name; + } -// computed macros + var owner = _emberUtils.getOwner(route); + var controller = options && options.controller; + if (!controller) { + if (namePassed) { + controller = owner.lookup('controller:' + name) || route.controllerName || route.routeName; + } else { + controller = route.controllerName || owner.lookup('controller:' + name); + } + } -// reduced computed macros -enifed("ember/version", ["exports"], function (exports) { - "use strict"; + if (typeof controller === 'string') { + var controllerName = controller; + controller = owner.lookup('controller:' + controllerName); + if (!controller) { + throw new _emberMetal.Error('You passed `controller: \'' + controllerName + '\'` into the `render` method, but no such controller could be found.'); + } + } - exports.default = "2.11.0-beta.2"; -}); -enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { + throw new _emberMetal.Error('You passed undefined as the outlet name.'); + } - exports.default = applyMixins; + if (options && options.model) { + controller.set('model', options.model); + } - function isGenerator(mixin) { - return Array.isArray(mixin.cases) && typeof mixin.generate === 'function'; - } + var template = owner.lookup('template:' + templateName); - function applyMixins(TestClass) { - for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - mixins[_key - 1] = arguments[_key]; + var parent = undefined; + if (into && (parent = parentRoute(route)) && into === parent.routeName) { + into = undefined; } - mixins.forEach(function (mixinOrGenerator) { - var mixin = undefined; + var renderOptions = { + owner: owner, + into: into, + outlet: outlet, + name: name, + controller: controller, + template: template || route._topLevelViewTemplate, + ViewClass: undefined + }; - if (isGenerator(mixinOrGenerator)) { - (function () { - var generator = mixinOrGenerator; - mixin = {}; + _emberMetal.assert('Could not find "' + name + '" template, view, or component.', isDefaultRender || template); - generator.cases.forEach(function (value, idx) { - _emberUtils.assign(mixin, generator.generate(value, idx)); - }); - })(); - } else { - mixin = mixinOrGenerator; + _emberMetal.runInDebug(function () { + var LOG_VIEW_LOOKUPS = _emberMetal.get(route.router, 'namespace.LOG_VIEW_LOOKUPS'); + if (LOG_VIEW_LOOKUPS && !template) { + _emberMetal.info('Could not find "' + name + '" template. Nothing will be rendered', { fullName: 'template:' + name }); } - - _emberUtils.assign(TestClass.prototype, mixin); }); - return TestClass; + return renderOptions; } -}); -enifed('internal-test-helpers/build-owner', ['exports', 'container', 'ember-routing', 'ember-application', 'ember-runtime'], function (exports, _container, _emberRouting, _emberApplication, _emberRuntime) { - 'use strict'; - exports.default = buildOwner; + function getFullQueryParams(router, state) { + if (state.fullQueryParams) { + return state.fullQueryParams; + } - function buildOwner() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + state.fullQueryParams = {}; + _emberUtils.assign(state.fullQueryParams, state.queryParams); - var ownerOptions = options.ownerOptions || {}; - var resolver = options.resolver; - var bootOptions = options.bootOptions || {}; + router._deserializeQueryParams(state.handlerInfos, state.fullQueryParams); + return state.fullQueryParams; + } - var Owner = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin); + function getQueryParamsFor(route, state) { + state.queryParamsFor = state.queryParamsFor || {}; + var name = route.fullRouteName; - var namespace = _emberRuntime.Object.create({ - Resolver: { create: function () { - return resolver; - } } - }); + if (state.queryParamsFor[name]) { + return state.queryParamsFor[name]; + } - var fallbackRegistry = _emberApplication.Application.buildRegistry(namespace); - fallbackRegistry.register('router:main', _emberRouting.Router); + var fullQueryParams = getFullQueryParams(route.router, state); - var registry = new _container.Registry({ - fallback: fallbackRegistry - }); + var params = state.queryParamsFor[name] = {}; - _emberApplication.ApplicationInstance.setupRegistry(registry, bootOptions); + // Copy over all the query params for this route/controller into params hash. + var qpMeta = _emberMetal.get(route, '_qp'); + var qps = qpMeta.qps; + for (var i = 0; i < qps.length; ++i) { + // Put deserialized qp on params hash. + var qp = qps[i]; - var owner = Owner.create({ - __registry__: registry, - __container__: null - }, ownerOptions); + var qpValueWasPassedIn = (qp.prop in fullQueryParams); + params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.defaultValue); + } - var container = registry.container({ owner: owner }); - owner.__container__ = container; + return params; + } - return owner; + function copyDefaultValue(value) { + if (Array.isArray(value)) { + return _emberRuntime.A(value.slice()); + } + return value; } -}); -enifed('internal-test-helpers/confirm-export', ['exports', 'require'], function (exports, _require) { - 'use strict'; - exports.default = confirmExport; + /* + Merges all query parameters from a controller with those from + a route, returning a new object and avoiding any mutations to + the existing objects. + */ + function mergeEachQueryParams(controllerQP, routeQP) { + var keysAlreadyMergedOrSkippable = undefined; + var qps = {}; - function getDescriptor(obj, path) { - var parts = path.split('.'); - var value = obj; - for (var i = 0; i < parts.length - 1; i++) { - var part = parts[i]; - value = value[part]; - if (!value) { - return undefined; + keysAlreadyMergedOrSkippable = { + defaultValue: true, + type: true, + scope: true, + as: true + }; + + // first loop over all controller qps, merging them with any matching route qps + // into a new empty object to avoid mutating. + for (var cqpName in controllerQP) { + if (!controllerQP.hasOwnProperty(cqpName)) { + continue; } - } - var last = parts[parts.length - 1]; - return Object.getOwnPropertyDescriptor(value, last); - } - function confirmExport(Ember, assert, path, moduleId, exportName) { - var desc = getDescriptor(Ember, path); - assert.ok(desc, 'the property exists on the global'); + var newControllerParameterConfiguration = {}; + _emberUtils.assign(newControllerParameterConfiguration, controllerQP[cqpName]); + _emberUtils.assign(newControllerParameterConfiguration, routeQP[cqpName]); - var mod = _require.default(moduleId); - if (typeof exportName === 'string') { - assert.equal(desc.value, mod[exportName], 'Ember.' + path + ' is exported correctly'); - assert.notEqual(mod[exportName], undefined, 'Ember.' + path + ' is not `undefined`'); - } else { - assert.equal(desc.get, mod[exportName.get], 'Ember.' + path + ' getter is exported correctly'); - assert.notEqual(desc.get, undefined, 'Ember.' + path + ' getter is not undefined'); + qps[cqpName] = newControllerParameterConfiguration; - if (exportName.set) { - assert.equal(desc.set, mod[exportName.set], 'Ember.' + path + ' setter is exported correctly'); - assert.notEqual(desc.set, undefined, 'Ember.' + path + ' setter is not undefined'); + // allows us to skip this QP when we check route QPs. + keysAlreadyMergedOrSkippable[cqpName] = true; + } + + // loop over all route qps, skipping those that were merged in the first pass + // because they also appear in controller qps + for (var rqpName in routeQP) { + if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { + continue; } + + var newRouteParameterConfiguration = {}; + _emberUtils.assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); + qps[rqpName] = newRouteParameterConfiguration; } + + return qps; } -}); -enifed('internal-test-helpers/equal-inner-html', ['exports'], function (exports) { - // detect side-effects of cloning svg elements in IE9-11 - 'use strict'; - exports.default = equalInnerHTML; - var ieSVGInnerHTML = (function () { - if (!document.createElementNS) { - return false; - } - var div = document.createElement('div'); - var node = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - div.appendChild(node); - var clone = div.cloneNode(true); - return clone.innerHTML === ''; - })(); + function addQueryParamsObservers(controller, propNames) { + propNames.forEach(function (prop) { + controller.addObserver(prop + '.[]', controller, controller._qpChanged); + }); + } - function normalizeInnerHTML(actualHTML) { - if (ieSVGInnerHTML) { - // Replace `` with ``, etc. - // drop namespace attribute - actualHTML = actualHTML.replace(/ xmlns="[^"]+"/, ''); - // replace self-closing elements - actualHTML = actualHTML.replace(/<([^ >]+) [^\/>]*\/>/gi, function (tag, tagName) { - return tag.slice(0, tag.length - 3) + '>'; - }); + function getEngineRouteName(engine, routeName) { + if (engine.routable) { + var prefix = engine.mountPoint; + + if (routeName === 'application') { + return prefix; + } else { + return prefix + '.' + routeName; + } } - return actualHTML; + return routeName; } - function equalInnerHTML(fragment, html) { - var actualHTML = normalizeInnerHTML(fragment.innerHTML); - QUnit.push(actualHTML === html, actualHTML, html); - } + exports.default = Route; }); -enifed('internal-test-helpers/equal-tokens', ['exports', 'simple-html-tokenizer'], function (exports, _simpleHtmlTokenizer) { +enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-routing/system/route', 'ember-routing/system/dsl', 'ember-routing/location/api', 'ember-routing/utils', 'ember-routing/system/router_state', 'container', 'router'], function (exports, _emberUtils, _emberConsole, _emberMetal, _emberRuntime, _emberRoutingSystemRoute, _emberRoutingSystemDsl, _emberRoutingLocationApi, _emberRoutingUtils, _emberRoutingSystemRouter_state, _container, _router5) { 'use strict'; - exports.default = equalTokens; + exports.triggerEvent = triggerEvent; - function generateTokens(containerOrHTML) { - if (typeof containerOrHTML === 'string') { - return { - tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML), - html: containerOrHTML - }; - } else { - return { - tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML.innerHTML), - html: containerOrHTML.innerHTML - }; - } + function K() { + return this; } - function normalizeTokens(tokens) { - tokens.forEach(function (token) { - if (token.type === 'StartTag') { - token.attributes = token.attributes.sort(function (a, b) { - if (a[0] > b[0]) { - return 1; - } - if (a[0] < b[0]) { - return -1; - } - return 0; - }); - } - }); - } + var slice = Array.prototype.slice; - function equalTokens(actualContainer, expectedHTML) { - var message = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + /** + The `Ember.Router` class manages the application state and URLs. Refer to + the [routing guide](http://emberjs.com/guides/routing/) for documentation. + + @class Router + @namespace Ember + @extends Ember.Object + @uses Ember.Evented + @public + */ + var EmberRouter = _emberRuntime.Object.extend(_emberRuntime.Evented, { + /** + The `location` property determines the type of URL's that your + application will use. + The following location types are currently available: + * `history` - use the browser's history API to make the URLs look just like any standard URL + * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new` + * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing) + * `auto` - use the best option based on browser capabilites: `history` if possible, then `hash` if possible, otherwise `none` + Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js` + @property location + @default 'hash' + @see {Ember.Location} + @public + */ + location: 'hash', - var actual = generateTokens(actualContainer); - var expected = generateTokens(expectedHTML); + /** + Represents the URL of the root of the application, often '/'. This prefix is + assumed on all routes defined on this router. + @property rootURL + @default '/' + @public + */ + rootURL: '/', - normalizeTokens(actual.tokens); - normalizeTokens(expected.tokens); + _initRouterJs: function () { + var _this = this; - var equiv = QUnit.equiv(actual.tokens, expected.tokens); + var router = this.router = new _router5.default(); + router.triggerEvent = triggerEvent; - if (equiv && expected.html !== actual.html) { - deepEqual(actual.tokens, expected.tokens, message); - } else { - QUnit.push(QUnit.equiv(actual.tokens, expected.tokens), actual.html, expected.html, message); - } - } -}); -enifed('internal-test-helpers/factory', ['exports'], function (exports) { - 'use strict'; + router._triggerWillChangeContext = K; + router._triggerWillLeave = K; - exports.default = factory; - function setProperties(object, properties) { - for (var key in properties) { - if (properties.hasOwnProperty(key)) { - object[key] = properties[key]; - } - } - } + var dslCallbacks = this.constructor.dslCallbacks || [K]; + var dsl = this._buildDSL(); - var guids = 0; + dsl.route('application', { path: '/', resetNamespace: true, overrideNameAssertion: true }, function () { + for (var i = 0; i < dslCallbacks.length; i++) { + dslCallbacks[i].call(this); + } + }); - function factory() { - /*jshint validthis: true */ + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this, 'namespace.LOG_TRANSITIONS_INTERNAL')) { + router.log = _emberConsole.default.debug; + } + }); - function Klass(options) { - setProperties(this, options); - this._guid = guids++; - this.isDestroyed = false; - } + router.map(dsl.generate()); + }, - Klass.prototype.constructor = Klass; - Klass.prototype.destroy = function () { - this.isDestroyed = true; - }; + _buildDSL: function () { + var moduleBasedResolver = this._hasModuleBasedResolver(); + var options = { + enableLoadingSubstates: !!moduleBasedResolver + }; - Klass.prototype.toString = function () { - return ''; - }; + var owner = _emberUtils.getOwner(this); + var router = this; - Klass.create = create; - Klass.extend = extend; - Klass.reopen = extend; - Klass.reopenClass = reopenClass; + options.resolveRouteMap = function (name) { + return owner[_container.FACTORY_FOR]('route-map:' + name); + }; - return Klass; + options.addRouteForEngine = function (name, engineInfo) { + if (!router._engineInfoByRoute[name]) { + router._engineInfoByRoute[name] = engineInfo; + } + }; - function create(options) { - return new this.prototype.constructor(options); - } + return new _emberRoutingSystemDsl.default(null, options); + }, - function reopenClass(options) { - setProperties(this, options); - } + init: function () { + this._super.apply(this, arguments); - function extend(options) { - function Child(options) { - Klass.call(this, options); + this.currentURL = null; + this.currentRouteName = null; + this.currentPath = null; + + this._qpCache = new _emberUtils.EmptyObject(); + this._resetQueuedQueryParameterChanges(); + this._handledErrors = _emberUtils.dictionary(null); + this._engineInstances = new _emberUtils.EmptyObject(); + this._engineInfoByRoute = new _emberUtils.EmptyObject(); + }, + + /* + Resets all pending query paramter changes. + Called after transitioning to a new route + based on query parameter changes. + */ + _resetQueuedQueryParameterChanges: function () { + this._queuedQPChanges = {}; + }, + + /** + Represents the current URL. + @method url + @return {String} The current URL. + @private + */ + url: _emberMetal.computed(function () { + return _emberMetal.get(this, 'location').getURL(); + }), + + _hasModuleBasedResolver: function () { + var owner = _emberUtils.getOwner(this); + + if (!owner) { + return false; } - var Parent = this; + var resolver = owner.application && owner.application.__registry__ && owner.application.__registry__.resolver; - Child.prototype = new Parent(); - Child.prototype.constructor = Child; + if (!resolver) { + return false; + } - setProperties(Child, Klass); - setProperties(Child.prototype, options); + return !!resolver.moduleBasedResolver; + }, - Child.create = create; - Child.extend = extend; - Child.reopen = extend; + /** + Initializes the current router instance and sets up the change handling + event listeners used by the instances `location` implementation. + A property named `initialURL` will be used to determine the initial URL. + If no value is found `/` will be used. + @method startRouting + @private + */ + startRouting: function () { + var initialURL = _emberMetal.get(this, 'initialURL'); - Child.reopenClass = reopenClass; + if (this.setupRouter()) { + if (typeof initialURL === 'undefined') { + initialURL = _emberMetal.get(this, 'location').getURL(); + } + var initialTransition = this.handleURL(initialURL); + if (initialTransition && initialTransition.error) { + throw initialTransition.error; + } + } + }, - return Child; - } - } -}); -enifed('internal-test-helpers/index', ['exports', 'internal-test-helpers/factory', 'internal-test-helpers/build-owner', 'internal-test-helpers/confirm-export', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/module-for', 'internal-test-helpers/strip', 'internal-test-helpers/apply-mixins', 'internal-test-helpers/matchers', 'internal-test-helpers/run', 'internal-test-helpers/test-groups', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/test-cases/abstract-application', 'internal-test-helpers/test-cases/application', 'internal-test-helpers/test-cases/query-param', 'internal-test-helpers/test-cases/abstract-rendering', 'internal-test-helpers/test-cases/rendering'], function (exports, _internalTestHelpersFactory, _internalTestHelpersBuildOwner, _internalTestHelpersConfirmExport, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersModuleFor, _internalTestHelpersStrip, _internalTestHelpersApplyMixins, _internalTestHelpersMatchers, _internalTestHelpersRun, _internalTestHelpersTestGroups, _internalTestHelpersTestCasesAbstract, _internalTestHelpersTestCasesAbstractApplication, _internalTestHelpersTestCasesApplication, _internalTestHelpersTestCasesQueryParam, _internalTestHelpersTestCasesAbstractRendering, _internalTestHelpersTestCasesRendering) { - 'use strict'; + setupRouter: function () { + var _this2 = this; - exports.factory = _internalTestHelpersFactory.default; - exports.buildOwner = _internalTestHelpersBuildOwner.default; - exports.confirmExport = _internalTestHelpersConfirmExport.default; - exports.equalInnerHTML = _internalTestHelpersEqualInnerHtml.default; - exports.equalTokens = _internalTestHelpersEqualTokens.default; - exports.moduleFor = _internalTestHelpersModuleFor.default; - exports.strip = _internalTestHelpersStrip.default; - exports.applyMixins = _internalTestHelpersApplyMixins.default; - exports.equalsElement = _internalTestHelpersMatchers.equalsElement; - exports.classes = _internalTestHelpersMatchers.classes; - exports.styles = _internalTestHelpersMatchers.styles; - exports.regex = _internalTestHelpersMatchers.regex; - exports.runAppend = _internalTestHelpersRun.runAppend; - exports.runDestroy = _internalTestHelpersRun.runDestroy; - exports.testBoth = _internalTestHelpersTestGroups.testBoth; - exports.testWithDefault = _internalTestHelpersTestGroups.testWithDefault; - exports.AbstractTestCase = _internalTestHelpersTestCasesAbstract.default; - exports.AbstractApplicationTestCase = _internalTestHelpersTestCasesAbstractApplication.default; - exports.ApplicationTestCase = _internalTestHelpersTestCasesApplication.default; - exports.QueryParamTestCase = _internalTestHelpersTestCasesQueryParam.default; - exports.AbstractRenderingTestCase = _internalTestHelpersTestCasesAbstractRendering.default; - exports.RenderingTestCase = _internalTestHelpersTestCasesRendering.default; -}); -enifed('internal-test-helpers/matchers', ['exports'], function (exports) { - 'use strict'; + this._initRouterJs(); + this._setupLocation(); - exports.regex = regex; - exports.classes = classes; - exports.styles = styles; - exports.equalsElement = equalsElement; - var HTMLElement = window.HTMLElement; - var MATCHER_BRAND = '3d4ef194-13be-4ccf-8dc7-862eea02c93e'; + var router = this.router; + var location = _emberMetal.get(this, 'location'); - function isMatcher(obj) { - return typeof obj === 'object' && obj !== null && MATCHER_BRAND in obj; - } + // Allow the Location class to cancel the router setup while it refreshes + // the page + if (_emberMetal.get(location, 'cancelRouterSetup')) { + return false; + } - function equalsAttr(expected) { - var _ref; + this._setupRouter(router, location); + + location.onUpdateURL(function (url) { + _this2.handleURL(url); + }); + + return true; + }, + + /** + Handles updating the paths and notifying any listeners of the URL + change. + Triggers the router level `didTransition` hook. + For example, to notify google analytics when the route changes, + you could use this hook. (Note: requires also including GA scripts, etc.) + ```javascript + let Router = Ember.Router.extend({ + location: config.locationType, + didTransition: function() { + this._super(...arguments); + return ga('send', 'pageview', { + 'page': this.get('url'), + 'title': this.get('url') + }); + } + }); + ``` + @method didTransition + @public + @since 1.2.0 + */ + didTransition: function (infos) { + var _this3 = this; - return _ref = {}, _ref[MATCHER_BRAND] = true, _ref.match = function (actual) { - return expected === actual; - }, _ref.expected = function () { - return expected; - }, _ref.message = function () { - return 'should equal ' + this.expected(); - }, _ref; - } + updatePaths(this); - function regex(r) { - var _ref2; + this._cancelSlowTransitionTimer(); - return _ref2 = {}, _ref2[MATCHER_BRAND] = true, _ref2.match = function (v) { - return r.test(v); - }, _ref2.expected = function () { - return r.toString(); - }, _ref2.message = function () { - return 'should match ' + this.expected(); - }, _ref2; - } + this.notifyPropertyChange('url'); + this.set('currentState', this.targetState); - function classes(expected) { - var _ref3; + // Put this in the runloop so url will be accurate. Seems + // less surprising than didTransition being out of sync. + _emberMetal.run.once(this, this.trigger, 'didTransition'); - return _ref3 = {}, _ref3[MATCHER_BRAND] = true, _ref3.match = function (actual) { - actual = actual.trim(); - return actual && expected.split(/\s+/).sort().join(' ') === actual.trim().split(/\s+/).sort().join(' '); - }, _ref3.expected = function () { - return expected; - }, _ref3.message = function () { - return 'should match ' + this.expected(); - }, _ref3; - } + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this3, 'namespace').LOG_TRANSITIONS) { + _emberConsole.default.log('Transitioned into \'' + EmberRouter._routePath(infos) + '\''); + } + }); + }, - function styles(expected) { - var _ref4; + _setOutlets: function () { + // This is triggered async during Ember.Route#willDestroy. + // If the router is also being destroyed we do not want to + // to create another this._toplevelView (and leak the renderer) + if (this.isDestroying || this.isDestroyed) { + return; + } - return _ref4 = {}, _ref4[MATCHER_BRAND] = true, _ref4.match = function (actual) { - // coerce `null` or `undefined` to an empty string - // needed for matching empty styles on IE9 - IE11 - actual = actual || ''; - actual = actual.trim(); + var handlerInfos = this.router.currentHandlerInfos; + var route = undefined; + var defaultParentState = undefined; + var liveRoutes = null; - return expected.split(';').map(function (s) { - return s.trim(); - }).filter(function (s) { - return s; - }).sort().join('; ') === actual.split(';').map(function (s) { - return s.trim(); - }).filter(function (s) { - return s; - }).sort().join('; '); - }, _ref4.expected = function () { - return expected; - }, _ref4.message = function () { - return 'should match ' + this.expected(); - }, _ref4; - } + if (!handlerInfos) { + return; + } - function equalsElement(element, tagName, attributes, content) { - QUnit.push(element.tagName === tagName.toUpperCase(), element.tagName.toLowerCase(), tagName, 'expect tagName to be ' + tagName); + for (var i = 0; i < handlerInfos.length; i++) { + route = handlerInfos[i].handler; + var connections = route.connections; + var ownState = undefined; + for (var j = 0; j < connections.length; j++) { + var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); + liveRoutes = appended.liveRoutes; + if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { + ownState = appended.ownState; + } + } + if (connections.length === 0) { + ownState = representEmptyRoute(liveRoutes, defaultParentState, route); + } + defaultParentState = ownState; + } - var expectedAttrs = {}; - var expectedCount = 0; + // when a transitionTo happens after the validation phase + // during the initial transition _setOutlets is called + // when no routes are active. However, it will get called + // again with the correct values during the next turn of + // the runloop + if (!liveRoutes) { + return; + } - for (var _name in attributes) { - var expected = attributes[_name]; - if (expected !== null) { - expectedCount++; + if (!this._toplevelView) { + var owner = _emberUtils.getOwner(this); + var OutletView = owner[_container.FACTORY_FOR]('view:-outlet'); + this._toplevelView = OutletView.create(); + this._toplevelView.setOutletState(liveRoutes); + var instance = owner.lookup('-application-instance:main'); + instance.didCreateRootView(this._toplevelView); + } else { + this._toplevelView.setOutletState(liveRoutes); } + }, - var matcher = isMatcher(expected) ? expected : equalsAttr(expected); + /** + Handles notifying any listeners of an impending URL + change. + Triggers the router level `willTransition` hook. + @method willTransition + @public + @since 1.11.0 + */ + willTransition: function (oldInfos, newInfos, transition) { + var _this4 = this; - expectedAttrs[_name] = matcher; + _emberMetal.run.once(this, this.trigger, 'willTransition', transition); - QUnit.push(expectedAttrs[_name].match(element.getAttribute(_name)), element.getAttribute(_name), matcher.expected(), 'Element\'s ' + _name + ' attribute ' + matcher.message()); - } + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this4, 'namespace').LOG_TRANSITIONS) { + _emberConsole.default.log('Preparing to transition from \'' + EmberRouter._routePath(oldInfos) + '\' to \'' + EmberRouter._routePath(newInfos) + '\''); + } + }); + }, - var actualAttributes = {}; + handleURL: function (url) { + // Until we have an ember-idiomatic way of accessing #hashes, we need to + // remove it because router.js doesn't know how to handle it. + url = url.split(/#(.+)?/)[0]; + return this._doURLTransition('handleURL', url); + }, - for (var i = 0, l = element.attributes.length; i < l; i++) { - actualAttributes[element.attributes[i].name] = element.attributes[i].value; - } + _doURLTransition: function (routerJsMethod, url) { + var transition = this.router[routerJsMethod](url || '/'); + didBeginTransition(transition, this); + return transition; + }, - if (!(element instanceof HTMLElement)) { - QUnit.push(element instanceof HTMLElement, null, null, 'Element must be an HTML Element, not an SVG Element'); - } else { - QUnit.push(element.attributes.length === expectedCount || !attributes, element.attributes.length, expectedCount, 'Expected ' + expectedCount + ' attributes; got ' + element.outerHTML); + /** + 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 + @public + */ + transitionTo: function () { + var queryParams = undefined; - if (content !== null) { - QUnit.push(element.innerHTML === content, element.innerHTML, content, 'The element had \'' + content + '\' as its content'); + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - } - } -}); -enifed('internal-test-helpers/module-for', ['exports', 'internal-test-helpers/apply-mixins'], function (exports, _internalTestHelpersApplyMixins) { - 'use strict'; - exports.default = moduleFor; - - function moduleFor(description, TestClass) { - var context = undefined; - - QUnit.module(description, { - setup: function () { - context = new TestClass(); - }, + if (resemblesURL(args[0])) { + return this._doURLTransition('transitionTo', args[0]); + } - teardown: function () { - context.teardown(); + var possibleQueryParams = args[args.length - 1]; + if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { + queryParams = args.pop().queryParams; + } else { + queryParams = {}; } - }); - for (var _len = arguments.length, mixins = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - mixins[_key - 2] = arguments[_key]; - } + var targetRouteName = args.shift(); + return this._doTransition(targetRouteName, args, queryParams); + }, - _internalTestHelpersApplyMixins.default(TestClass, mixins); + intermediateTransitionTo: function () { + var _router, + _this5 = this; - var proto = TestClass.prototype; + (_router = this.router).intermediateTransitionTo.apply(_router, arguments); - while (proto !== Object.prototype) { - Object.keys(proto).forEach(generateTest); - proto = Object.getPrototypeOf(proto); - } + updatePaths(this); - function generateTest(name) { - if (name.indexOf('@test ') === 0) { - QUnit.test(name.slice(5), function (assert) { - return context[name](assert); - }); - } else if (name.indexOf('@skip ') === 0) { - QUnit.skip(name.slice(5), function (assert) { - return context[name](assert); - }); - } - } - } -}); -enifed('internal-test-helpers/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + _emberMetal.runInDebug(function () { + var infos = _this5.router.currentHandlerInfos; + if (_emberMetal.get(_this5, 'namespace').LOG_TRANSITIONS) { + _emberConsole.default.log('Intermediate-transitioned into \'' + EmberRouter._routePath(infos) + '\''); + } + }); + }, - exports.runAppend = runAppend; - exports.runDestroy = runDestroy; + replaceWith: function () { + return this.transitionTo.apply(this, arguments).method('replace'); + }, - function runAppend(view) { - _emberMetal.run(view, 'appendTo', '#qunit-fixture'); - } + generate: function () { + var _router2; - function runDestroy(toDestroy) { - if (toDestroy) { - _emberMetal.run(toDestroy, 'destroy'); - } - } -}); -enifed('internal-test-helpers/strip', ['exports'], function (exports) { - 'use strict'; + var url = (_router2 = this.router).generate.apply(_router2, arguments); + return this.location.formatURL(url); + }, - exports.default = strip; + /** + Determines if the supplied route is currently active. + @method isActive + @param routeName + @return {Boolean} + @private + */ + isActive: function (routeName) { + var router = this.router; + return router.isActive.apply(router, arguments); + }, - function strip(_ref) { - for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - values[_key - 1] = arguments[_key]; - } + /** + An alternative form of `isActive` that doesn't require + manual concatenation of the arguments into a single + array. + @method isActiveIntent + @param routeName + @param models + @param queryParams + @return {Boolean} + @private + @since 1.7.0 + */ + isActiveIntent: function (routeName, models, queryParams) { + return this.currentState.isActiveIntent(routeName, models, queryParams); + }, - var strings = _ref; + send: function (name, context) { + var _router3; - var str = strings.map(function (string, index) { - var interpolated = values[index]; - return string + (interpolated !== undefined ? interpolated : ''); - }).join(''); - return str.split('\n').map(function (s) { - return s.trim(); - }).join(''); - } -}); -enifed('internal-test-helpers/test-cases/abstract-application', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-routing', 'ember-template-compiler', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/run'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberRouting, _emberTemplateCompiler, _internalTestHelpersTestCasesAbstract, _internalTestHelpersRun) { - 'use strict'; + (_router3 = this.router).trigger.apply(_router3, arguments); + }, - var AbstractApplicationTestCase = (function (_AbstractTestCase) { - babelHelpers.inherits(AbstractApplicationTestCase, _AbstractTestCase); + /** + Does this router instance have the given route. + @method hasRoute + @return {Boolean} + @private + */ + hasRoute: function (route) { + return this.router.hasRoute(route); + }, - function AbstractApplicationTestCase() { - babelHelpers.classCallCheck(this, AbstractApplicationTestCase); + /** + Resets the state of the router by clearing the current route + handlers and deactivating them. + @private + @method reset + */ + reset: function () { + if (this.router) { + this.router.reset(); + } + }, - _AbstractTestCase.call(this); + willDestroy: function () { + if (this._toplevelView) { + this._toplevelView.destroy(); + this._toplevelView = null; + } - this.element = _emberViews.jQuery('#qunit-fixture')[0]; + this._super.apply(this, arguments); - this.application = _emberMetal.run(_emberApplication.Application, 'create', this.applicationOptions); + this.reset(); - this.router = this.application.Router = _emberRouting.Router.extend(this.routerOptions); + var instances = this._engineInstances; + for (var _name in instances) { + for (var id in instances[_name]) { + _emberMetal.run(instances[_name][id], 'destroy'); + } + } + }, - this.applicationInstance = null; - } + /* + Called when an active route's query parameter has changed. + These changes are batched into a runloop run and trigger + a single transition. + */ + _activeQPChanged: function (queryParameterName, newValue) { + this._queuedQPChanges[queryParameterName] = newValue; + _emberMetal.run.once(this, this._fireQueryParamTransition); + }, - AbstractApplicationTestCase.prototype.teardown = function teardown() { - if (this.applicationInstance) { - _internalTestHelpersRun.runDestroy(this.applicationInstance); + _updatingQPChanged: function (queryParameterName) { + if (!this._qpUpdates) { + this._qpUpdates = {}; } + this._qpUpdates[queryParameterName] = true; + }, - _internalTestHelpersRun.runDestroy(this.application); - }; + /* + Triggers a transition to a route based on query parameter changes. + This is called once per runloop, to batch changes. + e.g. + if these methods are called in succession: + this._activeQPChanged('foo', '10'); + // results in _queuedQPChanges = { foo: '10' } + this._activeQPChanged('bar', false); + // results in _queuedQPChanges = { foo: '10', bar: false } + _queuedQPChanges will represent both of these changes + and the transition using `transitionTo` will be triggered + once. + */ + _fireQueryParamTransition: function () { + this.transitionTo({ queryParams: this._queuedQPChanges }); + this._resetQueuedQueryParameterChanges(); + }, - AbstractApplicationTestCase.prototype.visit = function visit(url, options) { - var _this = this; + _setupLocation: function () { + var location = _emberMetal.get(this, 'location'); + var rootURL = _emberMetal.get(this, 'rootURL'); + var owner = _emberUtils.getOwner(this); - var applicationInstance = this.applicationInstance; + if ('string' === typeof location && owner) { + var resolvedLocation = owner.lookup('location:' + location); - if (applicationInstance) { - return _emberMetal.run(applicationInstance, 'visit', url, options); - } else { - return _emberMetal.run(this.application, 'visit', url, options).then(function (instance) { - _this.applicationInstance = instance; - }); + if ('undefined' !== typeof resolvedLocation) { + location = _emberMetal.set(this, 'location', resolvedLocation); + } else { + // Allow for deprecated registration of custom location API's + var options = { + implementation: location + }; + + location = _emberMetal.set(this, 'location', _emberRoutingLocationApi.default.create(options)); + } } - }; - AbstractApplicationTestCase.prototype.transitionTo = function transitionTo() { - return _emberMetal.run.apply(undefined, [this.appRouter, 'transitionTo'].concat(babelHelpers.slice.call(arguments))); - }; + if (location !== null && typeof location === 'object') { + if (rootURL) { + _emberMetal.set(location, 'rootURL', rootURL); + } - AbstractApplicationTestCase.prototype.compile = function compile(string, options) { - return _emberTemplateCompiler.compile.apply(undefined, arguments); - }; + // Allow the location to do any feature detection, such as AutoLocation + // detecting history support. This gives it a chance to set its + // `cancelRouterSetup` property which aborts routing. + if (typeof location.detect === 'function') { + location.detect(); + } - AbstractApplicationTestCase.prototype.registerRoute = function registerRoute(name, route) { - this.application.register('route:' + name, route); - }; + // ensure that initState is called AFTER the rootURL is set on + // the location instance + if (typeof location.initState === 'function') { + location.initState(); + } + } + }, - AbstractApplicationTestCase.prototype.registerTemplate = function registerTemplate(name, template) { - this.application.register('template:' + name, this.compile(template, { - moduleName: name - })); - }; + _getHandlerFunction: function () { + var _this6 = this; - AbstractApplicationTestCase.prototype.registerComponent = function registerComponent(name, _ref) { - var _ref$ComponentClass = _ref.ComponentClass; - var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; - var _ref$template = _ref.template; - var template = _ref$template === undefined ? null : _ref$template; + var seen = new _emberUtils.EmptyObject(); + var owner = _emberUtils.getOwner(this); - if (ComponentClass) { - this.application.register('component:' + name, ComponentClass); - } + return function (name) { + var routeName = name; + var routeOwner = owner; + var engineInfo = _this6._engineInfoByRoute[routeName]; - if (typeof template === 'string') { - this.application.register('template:components/' + name, this.compile(template, { - moduleName: 'components/' + name - })); - } - }; + if (engineInfo) { + var engineInstance = _this6._getEngineInstance(engineInfo); - AbstractApplicationTestCase.prototype.registerController = function registerController(name, controller) { - this.application.register('controller:' + name, controller); - }; + routeOwner = engineInstance; + routeName = engineInfo.localFullName; + } - AbstractApplicationTestCase.prototype.registerEngine = function registerEngine(name, engine) { - this.application.register('engine:' + name, engine); - }; + var fullRouteName = 'route:' + routeName; - babelHelpers.createClass(AbstractApplicationTestCase, [{ - key: 'applicationOptions', - get: function () { - return { - rootElement: '#qunit-fixture', - autoboot: false - }; - } - }, { - key: 'routerOptions', - get: function () { - return { - location: 'none' - }; - } - }, { - key: 'appRouter', - get: function () { - return this.applicationInstance.lookup('router:main'); - } - }]); - return AbstractApplicationTestCase; - })(_internalTestHelpersTestCasesAbstract.default); + var handler = routeOwner.lookup(fullRouteName); + + if (seen[name]) { + return handler; + } + + seen[name] = true; + + if (!handler) { + var DefaultRoute = routeOwner[_container.FACTORY_FOR]('route:basic').class; + routeOwner.register(fullRouteName, DefaultRoute.extend()); + handler = routeOwner.lookup(fullRouteName); + + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this6, 'namespace.LOG_ACTIVE_GENERATION')) { + _emberMetal.info('generated -> ' + fullRouteName, { fullName: fullRouteName }); + } + }); + } - exports.default = AbstractApplicationTestCase; -}); -enifed('internal-test-helpers/test-cases/abstract-rendering', ['exports', 'ember-utils', 'ember-template-compiler', 'ember-views', 'ember-glimmer', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/build-owner', 'internal-test-helpers/run'], function (exports, _emberUtils, _emberTemplateCompiler, _emberViews, _emberGlimmer, _internalTestHelpersTestCasesAbstract, _internalTestHelpersBuildOwner, _internalTestHelpersRun) { - 'use strict'; + handler._setRouteName(routeName); + handler._populateQPMeta(); - var TextNode = window.Text; + if (engineInfo && !_emberRoutingSystemRoute.hasDefaultSerialize(handler)) { + throw new Error('Defining a custom serialize method on an Engine route is not supported.'); + } - var AbstractRenderingTestCase = (function (_AbstractTestCase) { - babelHelpers.inherits(AbstractRenderingTestCase, _AbstractTestCase); + return handler; + }; + }, - function AbstractRenderingTestCase() { - babelHelpers.classCallCheck(this, AbstractRenderingTestCase); + _getSerializerFunction: function () { + var _this7 = this; - _AbstractTestCase.call(this); - var owner = this.owner = _internalTestHelpersBuildOwner.default({ - ownerOptions: this.getOwnerOptions(), - bootOptions: this.getBootOptions(), - resolver: this.getResolver() - }); + return function (name) { + var engineInfo = _this7._engineInfoByRoute[name]; - this.renderer = this.owner.lookup('renderer:-dom'); - this.element = _emberViews.jQuery('#qunit-fixture')[0]; - this.component = null; + // If this is not an Engine route, we fall back to the handler for serialization + if (!engineInfo) { + return; + } - owner.register('event_dispatcher:main', _emberViews.EventDispatcher); - owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); - owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); - } + return engineInfo.serializeMethod || _emberRoutingSystemRoute.defaultSerialize; + }; + }, - AbstractRenderingTestCase.prototype.compile = function compile() { - return _emberTemplateCompiler.compile.apply(undefined, arguments); - }; + _setupRouter: function (router, location) { + var lastURL = undefined; + var emberRouter = this; - AbstractRenderingTestCase.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { - return {}; - }; + router.getHandler = this._getHandlerFunction(); + router.getSerializer = this._getSerializerFunction(); - AbstractRenderingTestCase.prototype.getOwnerOptions = function getOwnerOptions() {}; + var doUpdateURL = function () { + location.setURL(lastURL); + _emberMetal.set(emberRouter, 'currentURL', lastURL); + }; - AbstractRenderingTestCase.prototype.getBootOptions = function getBootOptions() {}; + router.updateURL = function (path) { + lastURL = path; + _emberMetal.run.once(doUpdateURL); + }; - AbstractRenderingTestCase.prototype.getResolver = function getResolver() {}; + if (location.replaceURL) { + (function () { + var doReplaceURL = function () { + location.replaceURL(lastURL); + _emberMetal.set(emberRouter, 'currentURL', lastURL); + }; - AbstractRenderingTestCase.prototype.teardown = function teardown() { - if (this.component) { - _internalTestHelpersRun.runDestroy(this.component); - } - if (this.owner) { - _internalTestHelpersRun.runDestroy(this.owner); + router.replaceURL = function (path) { + lastURL = path; + _emberMetal.run.once(doReplaceURL); + }; + })(); } - }; - AbstractRenderingTestCase.prototype.render = function render(templateStr) { - var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var owner = this.owner; + router.didTransition = function (infos) { + emberRouter.didTransition(infos); + }; - owner.register('template:-top-level', this.compile(templateStr, { - moduleName: '-top-level' - })); + router.willTransition = function (oldInfos, newInfos, transition) { + emberRouter.willTransition(oldInfos, newInfos, transition); + }; + }, - var attrs = _emberUtils.assign({}, context, { - tagName: '', - layoutName: '-top-level' + /** + Serializes the given query params according to their QP meta information. + @private + @method _serializeQueryParams + @param {Arrray} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _serializeQueryParams: function (handlerInfos, queryParams) { + var _this8 = this; + + forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { + if (qp) { + delete queryParams[key]; + queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); + } else if (value === undefined) { + return; // We don't serialize undefined values + } else { + queryParams[key] = _this8._serializeQueryParam(value, _emberRuntime.typeOf(value)); + } }); + }, - owner.register('component:-top-level', _emberGlimmer.Component.extend(attrs)); + /** + Serializes the value of a query parameter based on a type + @private + @method _serializeQueryParam + @param {Object} value + @param {String} type + */ + _serializeQueryParam: function (value, type) { + if (type === 'array') { + return JSON.stringify(value); + } - this.component = owner.lookup('component:-top-level'); + return '' + value; + }, - _internalTestHelpersRun.runAppend(this.component); - }; + /** + Deserializes the given query params according to their QP meta information. + @private + @method _deserializeQueryParams + @param {Array} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _deserializeQueryParams: function (handlerInfos, queryParams) { + forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { + // If we don't have QP meta info for a given key, then we do nothing + // because all values will be treated as strings + if (qp) { + delete queryParams[key]; + queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); + } + }); + }, - AbstractRenderingTestCase.prototype.rerender = function rerender() { - this.component.rerender(); - }; + /** + Deserializes the value of a query parameter based on a default type + @private + @method _deserializeQueryParam + @param {Object} value + @param {String} defaultType + */ + _deserializeQueryParam: function (value, defaultType) { + if (defaultType === 'boolean') { + return value === 'true' ? true : false; + } else if (defaultType === 'number') { + return Number(value).valueOf(); + } else if (defaultType === 'array') { + return _emberRuntime.A(JSON.parse(value)); + } - AbstractRenderingTestCase.prototype.registerHelper = function registerHelper(name, funcOrClassBody) { - var type = typeof funcOrClassBody; + return value; + }, - if (type === 'function') { - this.owner.register('helper:' + name, _emberGlimmer.helper(funcOrClassBody)); - } else if (type === 'object' && type !== null) { - this.owner.register('helper:' + name, _emberGlimmer.Helper.extend(funcOrClassBody)); - } else { - throw new Error('Cannot register ' + funcOrClassBody + ' as a helper'); + /** + Removes (prunes) any query params with default values from the given QP + object. Default values are determined from the QP meta information per key. + @private + @method _pruneDefaultQueryParamValues + @param {Array} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _pruneDefaultQueryParamValues: function (handlerInfos, queryParams) { + var qps = this._queryParamsFor(handlerInfos); + for (var key in queryParams) { + var qp = qps.map[key]; + if (qp && qp.serializedDefaultValue === queryParams[key]) { + delete queryParams[key]; + } } - }; + }, - AbstractRenderingTestCase.prototype.registerPartial = function registerPartial(name, template) { - var owner = this.env.owner || this.owner; - if (typeof template === 'string') { - var moduleName = 'template:' + name; - owner.register(moduleName, this.compile(template, { moduleName: moduleName })); - } - }; + _doTransition: function (_targetRouteName, models, _queryParams) { + var _router4; - AbstractRenderingTestCase.prototype.registerComponent = function registerComponent(name, _ref) { - var _ref$ComponentClass = _ref.ComponentClass; - var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; - var _ref$template = _ref.template; - var template = _ref$template === undefined ? null : _ref$template; - var owner = this.owner; + var targetRouteName = _targetRouteName || _emberRoutingUtils.getActiveTargetName(this.router); + _emberMetal.assert('The route ' + targetRouteName + ' was not found', targetRouteName && this.router.hasRoute(targetRouteName)); - if (ComponentClass) { - owner.register('component:' + name, ComponentClass); - } + var queryParams = {}; - if (typeof template === 'string') { - owner.register('template:components/' + name, this.compile(template, { - moduleName: 'components/' + name - })); - } - }; + this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); - AbstractRenderingTestCase.prototype.registerTemplate = function registerTemplate(name, template) { - var owner = this.owner; + _emberUtils.assign(queryParams, _queryParams); + this._prepareQueryParams(targetRouteName, models, queryParams); - if (typeof template === 'string') { - owner.register('template:' + name, this.compile(template, { - moduleName: name - })); - } else { - throw new Error('Registered template "' + name + '" must be a string'); - } - }; + var transitionArgs = _emberRoutingUtils.routeArgs(targetRouteName, models, queryParams); + var transition = (_router4 = this.router).transitionTo.apply(_router4, transitionArgs); - AbstractRenderingTestCase.prototype.registerService = function registerService(name, klass) { - this.owner.register('service:' + name, klass); - }; + didBeginTransition(transition, this); - AbstractRenderingTestCase.prototype.assertTextNode = function assertTextNode(node, text) { - if (!(node instanceof TextNode)) { - throw new Error('Expecting a text node, but got ' + node); + return transition; + }, + + _processActiveTransitionQueryParams: function (targetRouteName, models, queryParams, _queryParams) { + // merge in any queryParams from the active transition which could include + // queryParams from the url on initial load. + if (!this.router.activeTransition) { + return; } - this.assert.strictEqual(node.textContent, text, 'node.textContent'); - }; + var unchangedQPs = {}; + var qpUpdates = this._qpUpdates || {}; + for (var key in this.router.activeTransition.queryParams) { + if (!qpUpdates[key]) { + unchangedQPs[key] = this.router.activeTransition.queryParams[key]; + } + } - babelHelpers.createClass(AbstractRenderingTestCase, [{ - key: 'context', - get: function () { - return this.component; + // We need to fully scope queryParams so that we can create one object + // that represents both pased in queryParams and ones that aren't changed + // from the active transition. + this._fullyScopeQueryParams(targetRouteName, models, _queryParams); + this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs); + _emberUtils.assign(queryParams, unchangedQPs); + }, + + /** + Prepares the query params for a URL or Transition. Restores any undefined QP + keys/values, serializes all values, and then prunes any default values. + @private + @method _prepareQueryParams + @param {String} targetRouteName + @param {Array} models + @param {Object} queryParams + @return {Void} + */ + _prepareQueryParams: function (targetRouteName, models, queryParams) { + var state = calculatePostTransitionState(this, targetRouteName, models); + this._hydrateUnsuppliedQueryParams(state, queryParams); + this._serializeQueryParams(state.handlerInfos, queryParams); + this._pruneDefaultQueryParamValues(state.handlerInfos, queryParams); + }, + + /** + Returns the meta information for the query params of a given route. This + will be overriden to allow support for lazy routes. + @private + @method _getQPMeta + @param {HandlerInfo} handlerInfo + @return {Object} + */ + _getQPMeta: function (handlerInfo) { + var route = handlerInfo.handler; + return route && _emberMetal.get(route, '_qp'); + }, + + /** + Returns a merged query params meta object for a given set of handlerInfos. + Useful for knowing what query params are available for a given route hierarchy. + @private + @method _queryParamsFor + @param {Array} handlerInfos + @return {Object} + */ + _queryParamsFor: function (handlerInfos) { + var leafRouteName = handlerInfos[handlerInfos.length - 1].name; + if (this._qpCache[leafRouteName]) { + return this._qpCache[leafRouteName]; } - }]); - return AbstractRenderingTestCase; - })(_internalTestHelpersTestCasesAbstract.default); - exports.default = AbstractRenderingTestCase; -}); -enifed('internal-test-helpers/test-cases/abstract', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/matchers'], function (exports, _emberUtils, _emberMetal, _emberViews, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersMatchers) { - 'use strict'; + var shouldCache = true; + var qpsByUrlKey = {}; + var map = {}; + var qps = []; - var TextNode = window.Text; - var HTMLElement = window.HTMLElement; - var Comment = window.Comment; + for (var i = 0; i < handlerInfos.length; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - function isMarker(node) { - if (node instanceof Comment && node.textContent === '') { - return true; - } + if (!qpMeta) { + shouldCache = false; + continue; + } - if (node instanceof TextNode && node.textContent === '') { - return true; - } + // Loop over each QP to make sure we don't have any collisions by urlKey + for (var _i = 0; _i < qpMeta.qps.length; _i++) { + var qp = qpMeta.qps[_i]; + var urlKey = qp.urlKey; + var qpOther = qpsByUrlKey[urlKey]; - return false; - } + if (qpOther && qpOther.controllerName !== qp.controllerName) { + var otherQP = qpsByUrlKey[urlKey]; + _emberMetal.assert('You\'re not allowed to have more than one controller property map to the same query param key, but both `' + otherQP.scopedPropertyName + '` and `' + qp.scopedPropertyName + '` map to `' + urlKey + '`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `' + otherQP.prop + ': { as: \'other-' + otherQP.prop + '\' }`', false); + } - var AbstractTestCase = (function () { - function AbstractTestCase() { - babelHelpers.classCallCheck(this, AbstractTestCase); + qpsByUrlKey[urlKey] = qp; + qps.push(qp); + } - this.element = null; - this.snapshot = null; - this.assert = QUnit.config.current.assert; - } + _emberUtils.assign(map, qpMeta.map); + } - AbstractTestCase.prototype.teardown = function teardown() {}; + var finalQPMeta = { + qps: qps, + map: map + }; - AbstractTestCase.prototype.runTask = function runTask(callback) { - _emberMetal.run(callback); - }; + if (shouldCache) { + this._qpCache[leafRouteName] = finalQPMeta; + } - AbstractTestCase.prototype.runTaskNext = function runTaskNext(callback) { - _emberMetal.run.next(callback); - }; + return finalQPMeta; + }, - // The following methods require `this.element` to work + /** + Maps all query param keys to their fully scoped property name of the form + `controllerName:propName`. + @private + @method _fullyScopeQueryParams + @param {String} leafRouteName + @param {Array} contexts + @param {Object} queryParams + @return {Void} + */ + _fullyScopeQueryParams: function (leafRouteName, contexts, queryParams) { + var state = calculatePostTransitionState(this, leafRouteName, contexts); + var handlerInfos = state.handlerInfos; - AbstractTestCase.prototype.nthChild = function nthChild(n) { - var i = 0; - var node = this.element.firstChild; + for (var i = 0, len = handlerInfos.length; i < len; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - while (node) { - if (!isMarker(node)) { - i++; + if (!qpMeta) { + continue; } - if (i > n) { - break; - } else { - node = node.nextSibling; + for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { + var qp = qpMeta.qps[j]; + + var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; + + if (presentProp) { + if (presentProp !== qp.scopedPropertyName) { + queryParams[qp.scopedPropertyName] = queryParams[presentProp]; + delete queryParams[presentProp]; + } + } } } + }, - return node; - }; + /** + Hydrates (adds/restores) any query params that have pre-existing values into + the given queryParams hash. This is what allows query params to be "sticky" + and restore their last known values for their scope. + @private + @method _hydrateUnsuppliedQueryParams + @param {TransitionState} state + @param {Object} queryParams + @return {Void} + */ + _hydrateUnsuppliedQueryParams: function (state, queryParams) { + var handlerInfos = state.handlerInfos; + var appCache = this._bucketCache; - AbstractTestCase.prototype.$ = function $(sel) { - return sel ? _emberViews.jQuery(sel, this.element) : _emberViews.jQuery(this.element); - }; + for (var i = 0; i < handlerInfos.length; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - AbstractTestCase.prototype.textValue = function textValue() { - return this.$().text(); - }; + if (!qpMeta) { + continue; + } - AbstractTestCase.prototype.takeSnapshot = function takeSnapshot() { - var snapshot = this.snapshot = []; + for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { + var qp = qpMeta.qps[j]; - var node = this.element.firstChild; + var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; - while (node) { - if (!isMarker(node)) { - snapshot.push(node); + if (presentProp) { + if (presentProp !== qp.scopedPropertyName) { + queryParams[qp.scopedPropertyName] = queryParams[presentProp]; + delete queryParams[presentProp]; + } + } else { + var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.route.fullRouteName, qp.parts, state.params); + queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); + } } - - node = node.nextSibling; } + }, - return snapshot; - }; + _scheduleLoadingEvent: function (transition, originRoute) { + this._cancelSlowTransitionTimer(); + this._slowTransitionTimer = _emberMetal.run.scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute); + }, - AbstractTestCase.prototype.assertText = function assertText(text) { - this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content should be: `' + text + '`'); - }; + currentState: null, + targetState: null, - AbstractTestCase.prototype.assertInnerHTML = function assertInnerHTML(html) { - _internalTestHelpersEqualInnerHtml.default(this.element, html); - }; + _handleSlowTransition: function (transition, originRoute) { + if (!this.router.activeTransition) { + // Don't fire an event if we've since moved on from + // the transition that put us in a loading state. + return; + } - AbstractTestCase.prototype.assertHTML = function assertHTML(html) { - _internalTestHelpersEqualTokens.default(this.element, html, '#qunit-fixture content should be: `' + html + '`'); - }; + this.set('targetState', _emberRoutingSystemRouter_state.default.create({ + emberRouter: this, + routerJs: this.router, + routerJsState: this.router.activeTransition.state + })); - AbstractTestCase.prototype.assertElement = function assertElement(node, _ref) { - var _ref$ElementType = _ref.ElementType; - var ElementType = _ref$ElementType === undefined ? HTMLElement : _ref$ElementType; - var tagName = _ref.tagName; - var _ref$attrs = _ref.attrs; - var attrs = _ref$attrs === undefined ? null : _ref$attrs; - var _ref$content = _ref.content; - var content = _ref$content === undefined ? null : _ref$content; + transition.trigger(true, 'loading', transition, originRoute); + }, - if (!(node instanceof ElementType)) { - throw new Error('Expecting a ' + ElementType.name + ', but got ' + node); + _cancelSlowTransitionTimer: function () { + if (this._slowTransitionTimer) { + _emberMetal.run.cancel(this._slowTransitionTimer); } + this._slowTransitionTimer = null; + }, + + // These three helper functions are used to ensure errors aren't + // re-raised if they're handled in a route's error action. + _markErrorAsHandled: function (errorGuid) { + this._handledErrors[errorGuid] = true; + }, - _internalTestHelpersMatchers.equalsElement(node, tagName, attrs, content); - }; + _isErrorHandled: function (errorGuid) { + return this._handledErrors[errorGuid]; + }, - AbstractTestCase.prototype.assertComponentElement = function assertComponentElement(node, _ref2) { - var _ref2$ElementType = _ref2.ElementType; - var ElementType = _ref2$ElementType === undefined ? HTMLElement : _ref2$ElementType; - var _ref2$tagName = _ref2.tagName; - var tagName = _ref2$tagName === undefined ? 'div' : _ref2$tagName; - var _ref2$attrs = _ref2.attrs; - var attrs = _ref2$attrs === undefined ? null : _ref2$attrs; - var _ref2$content = _ref2.content; - var content = _ref2$content === undefined ? null : _ref2$content; + _clearHandledError: function (errorGuid) { + delete this._handledErrors[errorGuid]; + }, - attrs = _emberUtils.assign({}, { id: _internalTestHelpersMatchers.regex(/^ember\d*$/), class: _internalTestHelpersMatchers.classes('ember-view') }, attrs || {}); - this.assertElement(node, { ElementType: ElementType, tagName: tagName, attrs: attrs, content: content }); - }; + _getEngineInstance: function (_ref) { + var name = _ref.name; + var instanceId = _ref.instanceId; + var mountPoint = _ref.mountPoint; - AbstractTestCase.prototype.assertSameNode = function assertSameNode(actual, expected) { - this.assert.strictEqual(actual, expected, 'DOM node stability'); - }; + var engineInstances = this._engineInstances; - AbstractTestCase.prototype.assertInvariants = function assertInvariants(oldSnapshot, newSnapshot) { - oldSnapshot = oldSnapshot || this.snapshot; - newSnapshot = newSnapshot || this.takeSnapshot(); + if (!engineInstances[name]) { + engineInstances[name] = new _emberUtils.EmptyObject(); + } - this.assert.strictEqual(newSnapshot.length, oldSnapshot.length, 'Same number of nodes'); + var engineInstance = engineInstances[name][instanceId]; - for (var i = 0; i < oldSnapshot.length; i++) { - this.assertSameNode(newSnapshot[i], oldSnapshot[i]); - } - }; + if (!engineInstance) { + var owner = _emberUtils.getOwner(this); - AbstractTestCase.prototype.assertPartialInvariants = function assertPartialInvariants(start, end) { - this.assertInvariants(this.snapshot, this.takeSnapshot().slice(start, end)); - }; + _emberMetal.assert('You attempted to mount the engine \'' + name + '\' in your router map, but the engine can not be found.', owner.hasRegistration('engine:' + name)); - AbstractTestCase.prototype.assertStableRerender = function assertStableRerender() { - var _this = this; + engineInstance = owner.buildChildEngineInstance(name, { + routable: true, + mountPoint: mountPoint + }); - this.takeSnapshot(); - this.runTask(function () { - return _this.rerender(); - }); - this.assertInvariants(); - }; + engineInstance.boot(); - babelHelpers.createClass(AbstractTestCase, [{ - key: 'firstChild', - get: function () { - return this.nthChild(0); + engineInstances[name][instanceId] = engineInstance; } - }, { - key: 'nodesCount', - get: function () { - var count = 0; - var node = this.element.firstChild; - while (node) { - if (!isMarker(node)) { - count++; - } + return engineInstance; + } + }); - node = node.nextSibling; - } + /* + Helper function for iterating over routes in a set of handlerInfos that are + at or above the given origin route. Example: if `originRoute` === 'foo.bar' + and the handlerInfos given were for 'foo.bar.baz', then the given callback + will be invoked with the routes for 'foo.bar', 'foo', and 'application' + individually. + + If the callback returns anything other than `true`, then iteration will stop. + + @private + @param {Route} originRoute + @param {Array} handlerInfos + @param {Function} callback + @return {Void} + */ + function forEachRouteAbove(originRoute, handlerInfos, callback) { + var originRouteFound = false; - return count; + for (var i = handlerInfos.length - 1; i >= 0; --i) { + var handlerInfo = handlerInfos[i]; + var route = handlerInfo.handler; + + if (originRoute === route) { + originRouteFound = true; } - }]); - return AbstractTestCase; - })(); - exports.default = AbstractTestCase; -}); -enifed('internal-test-helpers/test-cases/application', ['exports', 'internal-test-helpers/test-cases/abstract-application'], function (exports, _internalTestHelpersTestCasesAbstractApplication) { - 'use strict'; + if (!originRouteFound) { + continue; + } - var ApplicationTestCase = (function (_AbstractApplicationTestCase) { - babelHelpers.inherits(ApplicationTestCase, _AbstractApplicationTestCase); + if (callback(route) !== true) { + return; + } + } + } - function ApplicationTestCase() { - babelHelpers.classCallCheck(this, ApplicationTestCase); + // These get invoked when an action bubbles above ApplicationRoute + // and are not meant to be overridable. + var defaultActionHandlers = { - _AbstractApplicationTestCase.apply(this, arguments); - } + willResolveModel: function (transition, originRoute) { + originRoute.router._scheduleLoadingEvent(transition, originRoute); + }, - return ApplicationTestCase; - })(_internalTestHelpersTestCasesAbstractApplication.default); + // Attempt to find an appropriate error route or substate to enter. + error: function (error, transition, originRoute) { + var handlerInfos = transition.state.handlerInfos; + var router = originRoute.router; - exports.default = ApplicationTestCase; -}); -enifed('internal-test-helpers/test-cases/query-param', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers/test-cases/application'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpersTestCasesApplication) { - 'use strict'; + forEachRouteAbove(originRoute, handlerInfos, function (route) { + // Check for the existence of an 'error' route. + // We don't check for an 'error' route on the originRoute, since that would + // technically be below where we're at in the route hierarchy. + if (originRoute !== route) { + var errorRouteName = findRouteStateName(route, 'error'); + if (errorRouteName) { + router.intermediateTransitionTo(errorRouteName, error); + return false; + } + } - var QueryParamTestCase = (function (_ApplicationTestCase) { - babelHelpers.inherits(QueryParamTestCase, _ApplicationTestCase); + // Check for an 'error' substate route + var errorSubstateName = findRouteSubstateName(route, 'error'); + if (errorSubstateName) { + router.intermediateTransitionTo(errorSubstateName, error); + return false; + } - function QueryParamTestCase() { - babelHelpers.classCallCheck(this, QueryParamTestCase); + return true; + }); - _ApplicationTestCase.call(this); + logError(error, 'Error while processing route: ' + transition.targetName); + }, - var testCase = this; - testCase.expectedPushURL = null; - testCase.expectedReplaceURL = null; - this.application.register('location:test', _emberRouting.NoneLocation.extend({ - setURL: function (path) { - if (testCase.expectedReplaceURL) { - testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); - } + // Attempt to find an appropriate loading route or substate to enter. + loading: function (transition, originRoute) { + var handlerInfos = transition.state.handlerInfos; + var router = originRoute.router; - if (testCase.expectedPushURL) { - testCase.assert.equal(path, testCase.expectedPushURL, 'an expected pushState occurred'); - testCase.expectedPushURL = null; + forEachRouteAbove(originRoute, handlerInfos, function (route) { + // Check for the existence of a 'loading' route. + // We don't check for a 'loading' route on the originRoute, since that would + // technically be below where we're at in the route hierarchy. + if (originRoute !== route) { + var loadingRouteName = findRouteStateName(route, 'loading'); + if (loadingRouteName) { + router.intermediateTransitionTo(loadingRouteName); + return false; } + } - this.set('path', path); - }, + // Check for loading substate + var loadingSubstateName = findRouteSubstateName(route, 'loading'); + if (loadingSubstateName) { + router.intermediateTransitionTo(loadingSubstateName); + return false; + } - replaceURL: function (path) { - if (testCase.expectedPushURL) { - testCase.assert.ok(false, 'replaceState occurred but a pushState was expected'); - } + // Don't bubble above pivot route. + return transition.pivotHandler !== route; + }); + } + }; - if (testCase.expectedReplaceURL) { - testCase.assert.equal(path, testCase.expectedReplaceURL, 'an expected replaceState occurred'); - testCase.expectedReplaceURL = null; - } + function logError(_error, initialMessage) { + var errorArgs = []; + var error = undefined; + if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { + error = _error.errorThrown; + } else { + error = _error; + } - this.set('path', path); - } - })); + if (initialMessage) { + errorArgs.push(initialMessage); } - QueryParamTestCase.prototype.visitAndAssert = function visitAndAssert(path) { - var _this = this; + if (error) { + if (error.message) { + errorArgs.push(error.message); + } + if (error.stack) { + errorArgs.push(error.stack); + } - return this.visit.apply(this, arguments).then(function () { - _this.assertCurrentPath(path); - }); - }; + if (typeof error === 'string') { + errorArgs.push(error); + } + } - QueryParamTestCase.prototype.getController = function getController(name) { - return this.applicationInstance.lookup('controller:' + name); - }; + _emberConsole.default.error.apply(this, errorArgs); + } - QueryParamTestCase.prototype.getRoute = function getRoute(name) { - return this.applicationInstance.lookup('route:' + name); - }; + /** + Finds the name of the substate route if it exists for the given route. A + substate route is of the form `route_state`, such as `foo_loading`. + + @private + @param {Route} route + @param {String} state + @return {String} + */ + function findRouteSubstateName(route, state) { + var router = route.router; + var owner = _emberUtils.getOwner(route); - QueryParamTestCase.prototype.setAndFlush = function setAndFlush(obj, prop, value) { - return _emberMetal.run(obj, 'set', prop, value); - }; + var routeName = route.routeName; + var substateName = routeName + '_' + state; - QueryParamTestCase.prototype.assertCurrentPath = function assertCurrentPath(path) { - var message = arguments.length <= 1 || arguments[1] === undefined ? 'current path equals \'' + path + '\'' : arguments[1]; - return (function () { - this.assert.equal(this.appRouter.get('location.path'), path, message); - }).apply(this, arguments); - }; + var routeNameFull = route.fullRouteName; + var substateNameFull = routeNameFull + '_' + state; - /** - Sets up a Controller for a given route with a single query param and default - value. Can optionally extend the controller with an object. - @public - @method setSingleQPController - */ + return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; + } - QueryParamTestCase.prototype.setSingleQPController = function setSingleQPController(routeName) { - var param = arguments.length <= 1 || arguments[1] === undefined ? 'foo' : arguments[1]; - var defaultValue = arguments.length <= 2 || arguments[2] === undefined ? 'bar' : arguments[2]; + /** + Finds the name of the state route if it exists for the given route. A state + route is of the form `route.state`, such as `foo.loading`. Properly Handles + `application` named routes. + + @private + @param {Route} route + @param {String} state + @return {String} + */ + function findRouteStateName(route, state) { + var router = route.router; + var owner = _emberUtils.getOwner(route); - var _Controller$extend; + var routeName = route.routeName; + var stateName = routeName === 'application' ? state : routeName + '.' + state; - var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; + var routeNameFull = route.fullRouteName; + var stateNameFull = routeNameFull === 'application' ? state : routeNameFull + '.' + state; - this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend = { - queryParams: [param] - }, _Controller$extend[param] = defaultValue, _Controller$extend), options)); - }; + return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; + } - /** - Sets up a Controller for a given route with a custom property/url key mapping. - @public - @method setMappedQPController - */ + /** + Determines whether or not a route has been defined by checking that the route + is in the Router's map and the owner has a registration for that route. + + @private + @param {Owner} owner + @param {Ember.Router} router + @param {String} localName + @param {String} fullName + @return {Boolean} + */ + function routeHasBeenDefined(owner, router, localName, fullName) { + var routerHasRoute = router.hasRoute(fullName); + var ownerHasRoute = owner.hasRegistration('template:' + localName) || owner.hasRegistration('route:' + localName); + return routerHasRoute && ownerHasRoute; + } - QueryParamTestCase.prototype.setMappedQPController = function setMappedQPController(routeName) { - var prop = arguments.length <= 1 || arguments[1] === undefined ? 'page' : arguments[1]; - var urlKey = arguments.length <= 2 || arguments[2] === undefined ? 'parentPage' : arguments[2]; - var defaultValue = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3]; + function triggerEvent(handlerInfos, ignoreFailure, args) { + var name = args.shift(); - var _queryParams, _Controller$extend2; + if (!handlerInfos) { + if (ignoreFailure) { + return; + } + throw new _emberMetal.Error('Can\'t trigger action \'' + name + '\' because your app hasn\'t finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.'); + } - var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; + var eventWasHandled = false; + var handlerInfo = undefined, + handler = undefined; - this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend2 = { - queryParams: (_queryParams = {}, _queryParams[prop] = urlKey, _queryParams) - }, _Controller$extend2[prop] = defaultValue, _Controller$extend2), options)); - }; + for (var i = handlerInfos.length - 1; i >= 0; i--) { + handlerInfo = handlerInfos[i]; + handler = handlerInfo.handler; - babelHelpers.createClass(QueryParamTestCase, [{ - key: 'routerOptions', - get: function () { - return { - location: 'test' - }; + if (handler && handler.actions && handler.actions[name]) { + if (handler.actions[name].apply(handler, args) === true) { + eventWasHandled = true; + } else { + // Should only hit here if a non-bubbling error action is triggered on a route. + if (name === 'error') { + var errorId = _emberUtils.guidFor(args[0]); + handler.router._markErrorAsHandled(errorId); + } + return; + } } - }]); - return QueryParamTestCase; - })(_internalTestHelpersTestCasesApplication.default); + } - exports.default = QueryParamTestCase; -}); -enifed('internal-test-helpers/test-cases/rendering', ['exports', 'ember-views', 'internal-test-helpers/test-cases/abstract-rendering'], function (exports, _emberViews, _internalTestHelpersTestCasesAbstractRendering) { - 'use strict'; + if (defaultActionHandlers[name]) { + defaultActionHandlers[name].apply(null, args); + return; + } - var RenderingTestCase = (function (_AbstractRenderingTestCase) { - babelHelpers.inherits(RenderingTestCase, _AbstractRenderingTestCase); + if (!eventWasHandled && !ignoreFailure) { + throw new _emberMetal.Error('Nothing handled the action \'' + name + '\'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.'); + } + } - function RenderingTestCase() { - babelHelpers.classCallCheck(this, RenderingTestCase); + function calculatePostTransitionState(emberRouter, leafRouteName, contexts) { + var routerjs = emberRouter.router; + var state = routerjs.applyIntent(leafRouteName, contexts); + var handlerInfos = state.handlerInfos; + var params = state.params; - _AbstractRenderingTestCase.call(this); - var owner = this.owner; + for (var i = 0; i < handlerInfos.length; ++i) { + var handlerInfo = handlerInfos[i]; - this.env = owner.lookup('service:-glimmer-environment'); - owner.register('component-lookup:main', _emberViews.ComponentLookup); - owner.registerOptionsForType('helper', { instantiate: false }); - owner.registerOptionsForType('component', { singleton: false }); + // If the handlerInfo is not resolved, we serialize the context into params + if (!handlerInfo.isResolved) { + params[handlerInfo.name] = handlerInfo.serialize(handlerInfo.context); + } else { + params[handlerInfo.name] = handlerInfo.params; + } } + return state; + } - return RenderingTestCase; - })(_internalTestHelpersTestCasesAbstractRendering.default); + function updatePaths(router) { + var infos = router.router.currentHandlerInfos; + if (infos.length === 0) { + return; + } - exports.default = RenderingTestCase; -}); -enifed('internal-test-helpers/test-groups', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { - 'use strict'; + var path = EmberRouter._routePath(infos); + var currentRouteName = infos[infos.length - 1].name; + var currentURL = router.get('location').getURL(); - exports.testBoth = testBoth; - exports.testWithDefault = testWithDefault; + _emberMetal.set(router, 'currentPath', path); + _emberMetal.set(router, 'currentRouteName', currentRouteName); + _emberMetal.set(router, 'currentURL', currentURL); - // used by unit tests to test both accessor mode and non-accessor mode + var appController = _emberUtils.getOwner(router).lookup('controller:application'); - function testBoth(testname, callback) { - function emberget(x, y) { - return _emberMetal.get(x, y); - } - function emberset(x, y, z) { - return _emberMetal.set(x, y, z); + if (!appController) { + // appController might not exist when top-level loading/error + // substates have been entered since ApplicationRoute hasn't + // actually been entered at that point. + return; } - function aget(x, y) { - return x[y]; + + if (!('currentPath' in appController)) { + _emberMetal.defineProperty(appController, 'currentPath'); } - function aset(x, y, z) { - return x[y] = z; + + _emberMetal.set(appController, 'currentPath', path); + + if (!('currentRouteName' in appController)) { + _emberMetal.defineProperty(appController, 'currentRouteName'); } - QUnit.test(testname + ' using getFromEmberMetal()/Ember.set()', function () { - callback(emberget, emberset); - }); + _emberMetal.set(appController, 'currentRouteName', currentRouteName); + } + + EmberRouter.reopenClass({ + router: null, + + /** + The `Router.map` function allows you to define mappings from URLs to routes + in your application. These mappings are defined within the + supplied callback function using `this.route`. + The first parameter is the name of the route which is used by default as the + path name as well. + The second parameter is the optional options hash. Available options are: + * `path`: allows you to provide your own path as well as mark dynamic + segments. + * `resetNamespace`: false by default; when nesting routes, ember will + combine the route names to form the fully-qualified route name, which is + used with `{{link-to}}` or manually transitioning to routes. Setting + `resetNamespace: true` will cause the route not to inherit from its + parent route's names. This is handy for preventing extremely long route names. + Keep in mind that the actual URL path behavior is still retained. + The third parameter is a function, which can be used to nest routes. + Nested routes, by default, will have the parent route tree's route name and + path prepended to it's own. + ```javascript + App.Router.map(function(){ + this.route('post', { path: '/post/:post_id' }, function() { + this.route('edit'); + this.route('comments', { resetNamespace: true }, function() { + this.route('new'); + }); + }); + }); + ``` + For more detailed documentation and examples please see + [the guides](http://emberjs.com/guides/routing/defining-your-routes/). + @method map + @param callback + @public + */ + map: function (callback) { + if (!this.dslCallbacks) { + this.dslCallbacks = []; + this.reopenClass({ dslCallbacks: this.dslCallbacks }); + } + + this.dslCallbacks.push(callback); + + return this; + }, + + _routePath: function (handlerInfos) { + var path = []; + + // We have to handle coalescing resource names that + // are prefixed with their parent's names, e.g. + // ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz' + + function intersectionMatches(a1, a2) { + for (var i = 0; i < a1.length; ++i) { + if (a1[i] !== a2[i]) { + return false; + } + } + return true; + } - QUnit.test(testname + ' using accessors', function () { - if (_emberEnvironment.ENV.USES_ACCESSORS) { - callback(aget, aset); - } else { - ok('SKIPPING ACCESSORS'); + var name = undefined, + nameParts = undefined, + oldNameParts = undefined; + for (var i = 1; i < handlerInfos.length; i++) { + name = handlerInfos[i].name; + nameParts = name.split('.'); + oldNameParts = slice.call(path); + + while (oldNameParts.length) { + if (intersectionMatches(oldNameParts, nameParts)) { + break; + } + oldNameParts.shift(); + } + + path.push.apply(path, nameParts.slice(oldNameParts.length)); } - }); - } - function testWithDefault(testname, callback) { - function emberget(x, y) { - return _emberMetal.get(x, y); - } - function embergetwithdefault(x, y, z) { - return _emberMetal.getWithDefault(x, y, z); - } - function getwithdefault(x, y, z) { - return x.getWithDefault(y, z); - } - function emberset(x, y, z) { - return _emberMetal.set(x, y, z); - } - function aget(x, y) { - return x[y]; - } - function aset(x, y, z) { - return x[y] = z; + return path.join('.'); } + }); - QUnit.test(testname + ' using obj.get()', function () { - callback(emberget, emberset); - }); - - QUnit.test(testname + ' using obj.getWithDefault()', function () { - callback(getwithdefault, emberset); + function didBeginTransition(transition, router) { + var routerState = _emberRoutingSystemRouter_state.default.create({ + emberRouter: router, + routerJs: router.router, + routerJsState: transition.state }); - QUnit.test(testname + ' using getFromEmberMetal()', function () { - callback(emberget, emberset); - }); + if (!router.currentState) { + router.set('currentState', routerState); + } + router.set('targetState', routerState); - QUnit.test(testname + ' using Ember.getWithDefault()', function () { - callback(embergetwithdefault, emberset); - }); + transition.promise = transition.catch(function (error) { + var errorId = _emberUtils.guidFor(error); - QUnit.test(testname + ' using accessors', function () { - if (_emberEnvironment.ENV.USES_ACCESSORS) { - callback(aget, aset); + if (router._isErrorHandled(errorId)) { + router._clearHandledError(errorId); } else { - ok('SKIPPING ACCESSORS'); + throw error; } }); } -}); -enifed('glimmer-node/index', ['exports', 'glimmer-node/lib/node-dom-helper'], function (exports, _glimmerNodeLibNodeDomHelper) { - 'use strict'; - exports.NodeDOMTreeConstruction = _glimmerNodeLibNodeDomHelper.default; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItbm9kZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFBb0IsdUJBQXVCLGdDQUFsQyxPQUFPIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBOb2RlRE9NVHJlZUNvbnN0cnVjdGlvbiB9IGZyb20gJy4vbGliL25vZGUtZG9tLWhlbHBlcic7XG4iXX0= -enifed('glimmer-node/lib/node-dom-helper', ['exports', 'glimmer-runtime'], function (exports, _glimmerRuntime) { - 'use strict'; - - var NodeDOMTreeConstruction = (function (_DOMTreeConstruction) { - babelHelpers.inherits(NodeDOMTreeConstruction, _DOMTreeConstruction); - - function NodeDOMTreeConstruction(doc) { - _DOMTreeConstruction.call(this, doc); - } + function resemblesURL(str) { + return typeof str === 'string' && (str === '' || str[0] === '/'); + } - // override to prevent usage of `this.document` until after the constructor + function forEachQueryParam(router, handlerInfos, queryParams, callback) { + var qpCache = router._queryParamsFor(handlerInfos); - NodeDOMTreeConstruction.prototype.setupUselessElement = function setupUselessElement() {}; + for (var key in queryParams) { + if (!queryParams.hasOwnProperty(key)) { + continue; + } + var value = queryParams[key]; + var qp = qpCache.map[key]; - NodeDOMTreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - var prev = reference ? reference.previousSibling : parent.lastChild; - var raw = this.document.createRawHTMLSection(html); - parent.insertBefore(raw, reference); - var first = prev ? prev.nextSibling : parent.firstChild; - var last = reference ? reference.previousSibling : parent.lastChild; - return new _glimmerRuntime.ConcreteBounds(parent, first, last); - }; + callback(key, value, qp); + } + } - // override to avoid SVG detection/work when in node (this is not needed in SSR) + function findLiveRoute(liveRoutes, name) { + if (!liveRoutes) { + return; + } + var stack = [liveRoutes]; + while (stack.length > 0) { + var test = stack.shift(); + if (test.render.name === name) { + return test; + } + var outlets = test.outlets; + for (var outletName in outlets) { + stack.push(outlets[outletName]); + } + } + } - NodeDOMTreeConstruction.prototype.createElement = function createElement(tag) { - return this.document.createElement(tag); - }; + function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { + var target = undefined; + var myState = { + render: renderOptions, + outlets: new _emberUtils.EmptyObject(), + wasUsed: false + }; + if (renderOptions.into) { + target = findLiveRoute(liveRoutes, renderOptions.into); + } else { + target = defaultParentState; + } + if (target) { + _emberMetal.set(target.outlets, renderOptions.outlet, myState); + } else { + if (renderOptions.into) { + _emberMetal.deprecate('Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated.', false, { + id: 'ember-routing.top-level-render-helper', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' + }); - // override to avoid namespace shenanigans when in node (this is not needed in SSR) + // Megahax time. Post-3.0-breaking-changes, we will just assert + // right here that the user tried to target a nonexistent + // thing. But for now we still need to support the `render` + // helper, and people are allowed to target templates rendered + // by the render helper. So instead we defer doing anyting with + // these orphan renders until afterRender. + appendOrphan(liveRoutes, renderOptions.into, myState); + } else { + liveRoutes = myState; + } + } + return { + liveRoutes: liveRoutes, + ownState: myState + }; + } - NodeDOMTreeConstruction.prototype.setAttribute = function setAttribute(element, name, value) { - element.setAttribute(name, value); - }; + function appendOrphan(liveRoutes, into, myState) { + if (!liveRoutes.outlets.__ember_orphans__) { + liveRoutes.outlets.__ember_orphans__ = { + render: { + name: '__ember_orphans__' + }, + outlets: new _emberUtils.EmptyObject() + }; + } + liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; + _emberMetal.run.schedule('afterRender', function () { + // `wasUsed` gets set by the render helper. + _emberMetal.assert('You attempted to render into \'' + into + '\' but it was not found', liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed); + }); + } - return NodeDOMTreeConstruction; - })(_glimmerRuntime.DOMTreeConstruction); + function representEmptyRoute(liveRoutes, defaultParentState, route) { + // the route didn't render anything + var alreadyAppended = findLiveRoute(liveRoutes, route.routeName); + if (alreadyAppended) { + // But some other route has already rendered our default + // template, so that becomes the default target for any + // children we may have. + return alreadyAppended; + } else { + // Create an entry to represent our default template name, + // just so other routes can target it and inherit its place + // in the outlet hierarchy. + defaultParentState.outlets.main = { + render: { + name: route.routeName, + outlet: 'main' + }, + outlets: {} + }; + return defaultParentState; + } + } - exports.default = NodeDOMTreeConstruction; + exports.default = EmberRouter; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItbm9kZS9saWIvbm9kZS1kb20taGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQUlBLHVCQUFBOzhCQUFBLHVCQUFBOztBQUVFLGlCQUZGLHVCQUFBLENBRWMsR0FBb0IsRUFBQTtBQUM5Qiw0Q0FBTSxHQUFHLENBQUMsQ0FBQztTQUNaOzs7O0FBSkgsK0JBQUEsV0FPWSxtQkFBbUIsR0FBQSwrQkFBQSxFQUFNOztBQVByQywrQkFBQSxXQVNFLGdCQUFnQixHQUFBLDBCQUFDLE1BQXNCLEVBQUUsSUFBWSxFQUFFLFNBQXNCLEVBQUE7QUFDM0UsZ0JBQUksSUFBSSxHQUFHLFNBQVMsR0FBRyxTQUFTLENBQUMsZUFBZSxHQUFHLE1BQU0sQ0FBQyxTQUFTLENBQUM7QUFFcEUsZ0JBQUksR0FBRyxHQUFHLElBQUksQ0FBQyxRQUFRLENBQUMsb0JBQW9CLENBQUMsSUFBSSxDQUFDLENBQUM7QUFDbkQsa0JBQU0sQ0FBQyxZQUFZLENBQUMsR0FBRyxFQUFFLFNBQVMsQ0FBQyxDQUFDO0FBRXBDLGdCQUFJLEtBQUssR0FBRyxJQUFJLEdBQUcsSUFBSSxDQUFDLFdBQVcsR0FBRyxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ3hELGdCQUFJLElBQUksR0FBRyxTQUFTLEdBQUcsU0FBUyxDQUFDLGVBQWUsR0FBRyxNQUFNLENBQUMsU0FBUyxDQUFDO0FBRXBFLG1CQUFPLG9CQXJCRixjQUF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W1lbnQsIG5hbWU6IHN0cmluZywgdmFsdWU6IHN0cmluZykge1xuICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKG5hbWUsIHZhbHVlKTtcbiAgfVxufVxuIl19 -enifed('glimmer-reference/index', ['exports', 'glimmer-reference/lib/reference', 'glimmer-reference/lib/const', 'glimmer-reference/lib/validators', 'glimmer-reference/lib/utils', 'glimmer-reference/lib/iterable'], function (exports, _glimmerReferenceLibReference, _glimmerReferenceLibConst, _glimmerReferenceLibValidators, _glimmerReferenceLibUtils, _glimmerReferenceLibIterable) { + +/** +@module ember +@submodule ember-routing +*/ +enifed('ember-routing/system/router_state', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime'], function (exports, _emberUtils, _emberMetal, _emberRuntime) { 'use strict'; - exports.BasicReference = _glimmerReferenceLibReference.Reference; - exports.BasicPathReference = _glimmerReferenceLibReference.PathReference; - exports.ConstReference = _glimmerReferenceLibConst.ConstReference; - exports.isConst = _glimmerReferenceLibConst.isConst; - babelHelpers.defaults(exports, babelHelpers.interopExportWildcard(_glimmerReferenceLibValidators, babelHelpers.defaults)); - exports.Reference = _glimmerReferenceLibValidators.VersionedReference; - exports.PathReference = _glimmerReferenceLibValidators.VersionedPathReference; - exports.referenceFromParts = _glimmerReferenceLibUtils.referenceFromParts; - exports.IterationItem = _glimmerReferenceLibIterable.IterationItem; - exports.Iterator = _glimmerReferenceLibIterable.Iterator; - exports.Iterable = _glimmerReferenceLibIterable.Iterable; - exports.OpaqueIterator = _glimmerReferenceLibIterable.OpaqueIterator; - exports.OpaqueIterable = _glimmerReferenceLibIterable.OpaqueIterable; - exports.AbstractIterator = _glimmerReferenceLibIterable.AbstractIterator; - exports.AbstractIterable = _glimmerReferenceLibIterable.AbstractIterable; - exports.IterationArtifacts = _glimmerReferenceLibIterable.IterationArtifacts; - exports.ReferenceIterator = _glimmerReferenceLibIterable.ReferenceIterator; - exports.IteratorSynchronizer = _glimmerReferenceLibIterable.IteratorSynchronizer; - exports.Iterator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cG9ydCAqIGZyb20gJy4vbGliL3ZhbGlkYXRvcnMnO1xuXG5leHBvcnQge1xuICBWZXJzaW9uZWRSZWZlcmVuY2UgYXMgUmVmZXJlbmNlLFxuICBWZXJzaW9uZWRQYXRoUmVmZXJlbmNlIGFzIFBhdGhSZWZlcmVuY2Vcbn0gZnJvbSAnLi9saWIvdmFsaWRhdG9ycyc7XG5cbmV4cG9ydCB7XG4gIHJlZmVyZW5jZUZyb21QYXJ0c1xufSBmcm9tICcuL2xpYi91dGlscyc7XG5cbmV4cG9ydCB7XG4gIEl0ZXJhdGlvbkl0ZW0sXG4gIEl0ZXJhdG9yLFxuICBJdGVyYWJsZSxcbiAgT3BhcXVlSXRlcmF0b3IsXG4gIE9wYXF1ZUl0ZXJhYmxlLFxuICBBYnN0cmFjdEl0ZXJhdG9yLFxuICBBYnN0cmFjdEl0ZXJhYmxlLFxuICBJdGVyYXRpb25BcnRpZmFjdHMsXG4gIFJlZmVyZW5jZUl0ZXJhdG9yLFxuICBJdGVyYXRvclN5bmNocm9uaXplcixcbiAgSXRlcmF0b3JTeW5jaHJvbml6ZXJEZWxlZ2F0ZVxufSBmcm9tICcuL2xpYi9pdGVyYWJsZSc7XG4iXX0= -enifed('glimmer-reference/lib/const', ['exports', 'glimmer-reference/lib/validators'], function (exports, _glimmerReferenceLibValidators) { - 'use strict'; + exports.default = _emberRuntime.Object.extend({ + emberRouter: null, + routerJs: null, + routerJsState: null, - exports.isConst = isConst; + isActiveIntent: function (routeName, models, queryParams, queryParamsMustMatch) { + var state = this.routerJsState; + if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { + return false; + } - var ConstReference = (function () { - function ConstReference(inner) { - this.inner = inner; - this.tag = _glimmerReferenceLibValidators.CONSTANT_TAG; - } + var emptyQueryParams = _emberMetal.isEmpty(Object.keys(queryParams)); - ConstReference.prototype.value = function value() { - return this.inner; - }; + if (queryParamsMustMatch && !emptyQueryParams) { + var visibleQueryParams = {}; + _emberUtils.assign(visibleQueryParams, queryParams); - return ConstReference; - })(); + this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); + return shallowEqual(visibleQueryParams, state.queryParams); + } - exports.ConstReference = ConstReference; + return true; + } + }); - function isConst(reference) { - return reference.tag === _glimmerReferenceLibValidators.CONSTANT_TAG; + function shallowEqual(a, b) { + var k = undefined; + for (k in a) { + if (a.hasOwnProperty(k) && a[k] !== b[k]) { + return false; + } + } + for (k in b) { + if (b.hasOwnProperty(k) && a[k] !== b[k]) { + return false; + } } + return true; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9jb25zdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztRQUdBLGNBQUE7QUFHRSxpQkFIRixjQUFBLENBR3dCLEtBQVEsRUFBQTtBQUFSLGdCQUFBLENBQUEsS0FBSyxHQUFMLEtBQUssQ0FBRztBQUZ2QixnQkFBQSxDQUFBLEdBQUcsa0NBSkgsWUFBWSxBQUltQixDQUFDO1NBRUo7O0FBSHJDLHNCQUFBLFdBS0UsS0FBSyxHQUFBLGlCQUFBO0FBQVEsbUJBQU8sSUFBSSxDQUFDLEtBQUssQ0FBQztTQUFFOztlQUxuQyxjQUFBOzs7OztBQVFBLGFBQUEsT0FBQSxDQUF3QixTQUFxQyxFQUFBO0FBQzNELGVBQU8sU0FBUyxDQUFDLEdBQUcsb0NBWmIsWUFBWSxBQVlrQixDQUFDO0tBQ3ZDIiwiZmlsZSI6ImNvbnN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ09OU1RBTlRfVEFHLCBWZXJzaW9uZWRSZWZlcmVuY2UsIFJldmlzaW9uVGFnIH0gZnJvbSAnLi92YWxpZGF0b3JzJztcbmltcG9ydCB7IE9wYXF1ZSB9IGZyb20gJ2dsaW1tZXItdXRpbCc7XG5cbmV4cG9ydCBjbGFzcyBDb25zdFJlZmVyZW5jZTxUPiBpbXBsZW1lbnRzIFZlcnNpb25lZFJlZmVyZW5jZTxUPiB7XG4gIHB1YmxpYyB0YWc6IFJldmlzaW9uVGFnID0gQ09OU1RBTlRfVEFHO1xuXG4gIGNvbnN0cnVjdG9yKHByb3RlY3RlZCBpbm5lcjogVCkgeyB9XG5cbiAgdmFsdWUoKTogVCB7IHJldHVybiB0aGlzLmlubmVyOyB9XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBpc0NvbnN0KHJlZmVyZW5jZTogVmVyc2lvbmVkUmVmZXJlbmNlPE9wYXF1ZT4pOiBib29sZWFuIHtcbiAgcmV0dXJuIHJlZmVyZW5jZS50YWcgPT09IENPTlNUQU5UX1RBRztcbn1cbiJdfQ== -enifed("glimmer-reference/lib/iterable", ["exports", "glimmer-util"], function (exports, _glimmerUtil) { - "use strict"; - - var ListItem = (function (_ListNode) { - babelHelpers.inherits(ListItem, _ListNode); - - function ListItem(iterable, result) { - _ListNode.call(this, iterable.valueReferenceFor(result)); - this.retained = false; - this.seen = false; - this.key = result.key; - this.iterable = iterable; - this.memo = iterable.memoReferenceFor(result); - } +enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { + 'use strict'; - ListItem.prototype.update = function update(item) { - this.retained = true; - this.iterable.updateValueReference(this.value, item); - this.iterable.updateMemoReference(this.memo, item); - }; + exports.routeArgs = routeArgs; + exports.getActiveTargetName = getActiveTargetName; + exports.stashParamNames = stashParamNames; + exports.calculateCacheKey = calculateCacheKey; + exports.normalizeControllerQueryParams = normalizeControllerQueryParams; + exports.prefixRouteNameArg = prefixRouteNameArg; - ListItem.prototype.shouldRemove = function shouldRemove() { - return !this.retained; - }; + var ALL_PERIODS_REGEX = /\./g; - ListItem.prototype.reset = function reset() { - this.retained = false; - this.seen = false; - }; + function routeArgs(targetRouteName, models, queryParams) { + var args = []; + if (typeof targetRouteName === 'string') { + args.push('' + targetRouteName); + } + args.push.apply(args, models); + args.push({ queryParams: queryParams }); + return args; + } - return ListItem; - })(_glimmerUtil.ListNode); + function getActiveTargetName(router) { + var handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; + return handlerInfos[handlerInfos.length - 1].name; + } - exports.ListItem = ListItem; + function stashParamNames(router, handlerInfos) { + if (handlerInfos._namesStashed) { + return; + } - var IterationArtifacts = (function () { - function IterationArtifacts(iterable) { - this.map = _glimmerUtil.dict(); - this.list = new _glimmerUtil.LinkedList(); - this.tag = iterable.tag; - this.iterable = iterable; - } + // This helper exists because router.js/route-recognizer.js awkwardly + // keeps separate a handlerInfo's list of parameter names depending + // on whether a URL transition or named transition is happening. + // Hopefully we can remove this in the future. + var targetRouteName = handlerInfos[handlerInfos.length - 1].name; + var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); + var dynamicParent = null; - IterationArtifacts.prototype.isEmpty = function isEmpty() { - var iterator = this.iterator = this.iterable.iterate(); - return iterator.isEmpty(); - }; + for (var i = 0; i < handlerInfos.length; ++i) { + var handlerInfo = handlerInfos[i]; + var names = recogHandlers[i].names; - IterationArtifacts.prototype.iterate = function iterate() { - var iterator = this.iterator || this.iterable.iterate(); - this.iterator = null; - return iterator; - }; + if (names.length) { + dynamicParent = handlerInfo; + } - IterationArtifacts.prototype.has = function has(key) { - return !!this.map[key]; - }; + handlerInfo._names = names; - IterationArtifacts.prototype.get = function get(key) { - return this.map[key]; - }; + var route = handlerInfo.handler; + route._stashNames(handlerInfo, dynamicParent); + } - IterationArtifacts.prototype.wasSeen = function wasSeen(key) { - var node = this.map[key]; - return node && node.seen; - }; + handlerInfos._namesStashed = true; + } - IterationArtifacts.prototype.append = function append(item) { - var map = this.map; - var list = this.list; - var iterable = this.iterable; + function _calculateCacheValuePrefix(prefix, part) { + // calculates the dot seperated sections from prefix that are also + // at the start of part - which gives us the route name - var node = map[item.key] = new ListItem(iterable, item); - list.append(node); - return node; - }; + // given : prefix = site.article.comments, part = site.article.id + // - returns: site.article (use get(values[site.article], 'id') to get the dynamic part - used below) - IterationArtifacts.prototype.insertBefore = function insertBefore(item, reference) { - var map = this.map; - var list = this.list; - var iterable = this.iterable; + // given : prefix = site.article, part = site.article.id + // - returns: site.article. (use get(values[site.article], 'id') to get the dynamic part - used below) - var node = map[item.key] = new ListItem(iterable, item); - node.retained = true; - list.insertBefore(node, reference); - return node; - }; + var prefixParts = prefix.split('.'); + var currPrefix = ''; - IterationArtifacts.prototype.move = function move(item, reference) { - var list = this.list; + for (var i = 0; i < prefixParts.length; i++) { + var currPart = prefixParts.slice(0, i + 1).join('.'); + if (part.indexOf(currPart) !== 0) { + break; + } + currPrefix = currPart; + } - item.retained = true; - list.remove(item); - list.insertBefore(item, reference); - }; + return currPrefix; + } - IterationArtifacts.prototype.remove = function remove(item) { - var list = this.list; + /* + Stolen from Controller + */ - list.remove(item); - delete this.map[item.key]; - }; + function calculateCacheKey(prefix, parts, values) { + if (parts === undefined) parts = []; - IterationArtifacts.prototype.nextNode = function nextNode(item) { - return this.list.nextNode(item); - }; + var suffixes = ''; + for (var i = 0; i < parts.length; ++i) { + var part = parts[i]; + var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); + var value = undefined; + if (values) { + if (cacheValuePrefix && cacheValuePrefix in values) { + var partRemovedPrefix = part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part; + value = _emberMetal.get(values[cacheValuePrefix], partRemovedPrefix); + } else { + value = _emberMetal.get(values, part); + } + } + suffixes += '::' + part + ':' + value; + } + return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); + } - IterationArtifacts.prototype.head = function head() { - return this.list.head(); - }; + /* + Controller-defined query parameters can come in three shapes: + + Array + queryParams: ['foo', 'bar'] + Array of simple objects where value is an alias + queryParams: [ + { + 'foo': 'rename_foo_to_this' + }, + { + 'bar': 'call_bar_this_instead' + } + ] + Array of fully defined objects + queryParams: [ + { + 'foo': { + as: 'rename_foo_to_this' + }, + } + { + 'bar': { + as: 'call_bar_this_instead', + scope: 'controller' + } + } + ] + + This helper normalizes all three possible styles into the + 'Array of fully defined objects' style. + */ - return IterationArtifacts; - })(); + function normalizeControllerQueryParams(queryParams) { + var qpMap = {}; - exports.IterationArtifacts = IterationArtifacts; + for (var i = 0; i < queryParams.length; ++i) { + accumulateQueryParamDescriptors(queryParams[i], qpMap); + } - var ReferenceIterator = (function () { - // if anyone needs to construct this object with something other than - // an iterable, let @wycats know. + return qpMap; + } - function ReferenceIterator(iterable) { - this.iterator = null; - var artifacts = new IterationArtifacts(iterable); - this.artifacts = artifacts; - } + function accumulateQueryParamDescriptors(_desc, accum) { + var desc = _desc; + var tmp = undefined; + if (typeof desc === 'string') { + tmp = {}; + tmp[desc] = { as: null }; + desc = tmp; + } - ReferenceIterator.prototype.next = function next() { - var artifacts = this.artifacts; + for (var key in desc) { + if (!desc.hasOwnProperty(key)) { + return; + } - var iterator = this.iterator = this.iterator || artifacts.iterate(); - var item = iterator.next(); - if (!item) return null; - return artifacts.append(item); - }; + var singleDesc = desc[key]; + if (typeof singleDesc === 'string') { + singleDesc = { as: singleDesc }; + } - return ReferenceIterator; - })(); + tmp = accum[key] || { as: null, scope: 'model' }; + _emberUtils.assign(tmp, singleDesc); - exports.ReferenceIterator = ReferenceIterator; + accum[key] = tmp; + } + } - var Phase; - (function (Phase) { - Phase[Phase["Append"] = 0] = "Append"; - Phase[Phase["Prune"] = 1] = "Prune"; - Phase[Phase["Done"] = 2] = "Done"; - })(Phase || (Phase = {})); + /* + Check if a routeName resembles a url instead + + @private + */ + function resemblesURL(str) { + return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); + } - var IteratorSynchronizer = (function () { - function IteratorSynchronizer(_ref) { - var target = _ref.target; - var artifacts = _ref.artifacts; + /* + Returns an arguments array where the route name arg is prefixed based on the mount point + + @private + */ - this.target = target; - this.artifacts = artifacts; - this.iterator = artifacts.iterate(); - this.current = artifacts.head(); - } + function prefixRouteNameArg(route, args) { + var routeName = args[0]; + var owner = _emberUtils.getOwner(route); + var prefix = owner.mountPoint; - IteratorSynchronizer.prototype.sync = function sync() { - var phase = Phase.Append; - while (true) { - switch (phase) { - case Phase.Append: - phase = this.nextAppend(); - break; - case Phase.Prune: - phase = this.nextPrune(); - break; - case Phase.Done: - this.nextDone(); - return; - } - } - }; + // only alter the routeName if it's actually referencing a route. + if (owner.routable && typeof routeName === 'string') { + if (resemblesURL(routeName)) { + throw new _emberMetal.Error('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'); + } else { + routeName = prefix + '.' + routeName; + args[0] = routeName; + } + } - IteratorSynchronizer.prototype.advanceToKey = function advanceToKey(key) { - var current = this.current; - var artifacts = this.artifacts; + return args; + } +}); +enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeMixinsComparable) { + 'use strict'; - var seek = current; - while (seek && seek.key !== key) { - seek.seen = true; - seek = artifacts.nextNode(seek); - } - this.current = seek && artifacts.nextNode(seek); - }; + exports.default = compare; - IteratorSynchronizer.prototype.nextAppend = function nextAppend() { - var iterator = this.iterator; - var current = this.current; - var artifacts = this.artifacts; + var TYPE_ORDER = { + 'undefined': 0, + 'null': 1, + 'boolean': 2, + 'number': 3, + 'string': 4, + 'array': 5, + 'object': 6, + 'instance': 7, + 'function': 8, + 'class': 9, + 'date': 10 + }; - var item = iterator.next(); - if (item === null) { - return this.startPrune(); - } - var key = item.key; + // + // the spaceship operator + // + // `. ___ + // __,' __`. _..----....____ + // __...--.'``;. ,. ;``--..__ .' ,-._ _.-' + // _..-''-------' `' `' `' O ``-''._ (,;') _,' + // ,'________________ \`-._`-',' + // `._ ```````````------...___ '-.._'-: + // ```--.._ ,. ````--...__\-. + // `.--. `-` "INFINITY IS LESS ____ | |` + // `. `. THAN BEYOND" ,'`````. ; ;` + // `._`. __________ `. \'__/` + // `-:._____/______/___/____`. \ ` + // | `._ `. \ + // `._________`-. `. `.___ + // SSt `------'` + function spaceship(a, b) { + var diff = a - b; + return (diff > 0) - (diff < 0); + } - if (current && current.key === key) { - this.nextRetain(item); - } else if (artifacts.has(key)) { - this.nextMove(item); - } else { - this.nextInsert(item); - } - return Phase.Append; - }; + /** + Compares two javascript values and returns: + + - -1 if the first is smaller than the second, + - 0 if both are equal, + - 1 if the first is greater than the second. + + ```javascript + Ember.compare('hello', 'hello'); // 0 + Ember.compare('abc', 'dfg'); // -1 + Ember.compare(2, 1); // 1 + ``` + + If the types of the two objects are different precedence occurs in the + following order, with types earlier in the list considered `<` types + later in the list: + + - undefined + - null + - boolean + - number + - string + - array + - object + - instance + - function + - class + - date + + ```javascript + Ember.compare('hello', 50); // 1 + Ember.compare(50, 'hello'); // -1 + ``` + + @method compare + @for Ember + @param {Object} v First value to compare + @param {Object} w Second value to compare + @return {Number} -1 if v < w, 0 if v = w and 1 if v > w. + @public + */ - IteratorSynchronizer.prototype.nextRetain = function nextRetain(item) { - var artifacts = this.artifacts; - var current = this.current; + function compare(v, w) { + if (v === w) { + return 0; + } - current.update(item); - this.current = artifacts.nextNode(current); - this.target.retain(item.key, current.value, current.memo); - }; + var type1 = _emberRuntimeUtils.typeOf(v); + var type2 = _emberRuntimeUtils.typeOf(w); - IteratorSynchronizer.prototype.nextMove = function nextMove(item) { - var current = this.current; - var artifacts = this.artifacts; - var target = this.target; - var key = item.key; + if (_emberRuntimeMixinsComparable.default) { + if (type1 === 'instance' && _emberRuntimeMixinsComparable.default.detect(v) && v.constructor.compare) { + return v.constructor.compare(v, w); + } - var found = artifacts.get(item.key); - found.update(item); - if (artifacts.wasSeen(item.key)) { - artifacts.move(found, current); - target.move(found.key, found.value, found.memo, current ? current.key : null); - } else { - this.advanceToKey(key); - } - }; + if (type2 === 'instance' && _emberRuntimeMixinsComparable.default.detect(w) && w.constructor.compare) { + return w.constructor.compare(w, v) * -1; + } + } - IteratorSynchronizer.prototype.nextInsert = function nextInsert(item) { - var artifacts = this.artifacts; - var target = this.target; - var current = this.current; + var res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); - var node = artifacts.insertBefore(item, current); - target.insert(node.key, node.value, node.memo, current ? current.key : null); - }; + if (res !== 0) { + return res; + } - IteratorSynchronizer.prototype.startPrune = function startPrune() { - this.current = this.artifacts.head(); - return Phase.Prune; - }; + // types are equal - so we have to check values now + switch (type1) { + case 'boolean': + case 'number': + return spaceship(v, w); - IteratorSynchronizer.prototype.nextPrune = function nextPrune() { - var artifacts = this.artifacts; - var target = this.target; - var current = this.current; + case 'string': + return spaceship(v.localeCompare(w), 0); - if (current === null) { - return Phase.Done; - } - var node = current; - this.current = artifacts.nextNode(node); - if (node.shouldRemove()) { - artifacts.remove(node); - target.delete(node.key); - } else { - node.reset(); + case 'array': + { + var vLen = v.length; + var wLen = w.length; + var len = Math.min(vLen, wLen); + + for (var i = 0; i < len; i++) { + var r = compare(v[i], w[i]); + if (r !== 0) { + return r; } - return Phase.Prune; - }; + } - IteratorSynchronizer.prototype.nextDone = function nextDone() { - this.target.done(); - }; + // all elements are equal now + // shorter array should be ordered first + return spaceship(vLen, wLen); + } + case 'instance': + if (_emberRuntimeMixinsComparable.default && _emberRuntimeMixinsComparable.default.detect(v)) { + return v.compare(v, w); + } + return 0; - return IteratorSynchronizer; - })(); + case 'date': + return spaceship(v.getTime(), w.getTime()); - exports.IteratorSynchronizer = IteratorSynchronizer; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9pdGVyYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFrQ0EsUUFBQTs4QkFBQSxRQUFBOztBQU9FLGlCQVBGLFFBQUEsQ0FPYyxRQUF3QixFQUFFLE1BQTJCLEVBQUE7QUFDL0QsaUNBQU0sUUFBUSxDQUFDLGlCQUFpQixDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7QUFMckMsZ0JBQUEsQ0FBQSxRQUFRLEdBQVksS0FBSyxD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QgfSA9IHRoaXM7XG5cbiAgICBpZiAoY3VycmVudCA9PT0gbnVsbCkge1xuICAgICAgcmV0dXJuIFBoYXNlLkRvbmU7XG4gICAgfVxuXG4gICAgbGV0IG5vZGUgPSBjdXJyZW50O1xuICAgIHRoaXMuY3VycmVudCA9IGFydGlmYWN0cy5uZXh0Tm9kZShub2RlKTtcblxuICAgIGlmIChub2RlLnNob3VsZFJlbW92ZSgpKSB7XG4gICAgICBhcnRpZmFjdHMucmVtb3ZlKG5vZGUpO1xuICAgICAgdGFyZ2V0LmRlbGV0ZShub2RlLmtleSk7XG4gICAgfSBlbHNlIHtcbiAgICAgIG5vZGUucmVzZXQoKTtcbiAgICB9XG5cbiAgICByZXR1cm4gUGhhc2UuUHJ1bmU7XG4gIH1cblxuICBwcml2YXRlIG5leHREb25lKCkge1xuICAgIHRoaXMudGFyZ2V0LmRvbmUoKTtcbiAgfVxufVxuIl19 -enifed("glimmer-reference/lib/reference", ["exports"], function (exports) { - "use strict"; + default: + return 0; + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9yZWZlcmVuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJyZWZlcmVuY2UuanMiLCJzb3VyY2VzQ29udGVudCI6W119 -enifed("glimmer-reference/lib/utils", ["exports"], function (exports) { - "use strict"; +enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - exports.referenceFromParts = referenceFromParts; + exports.empty = empty; + exports.notEmpty = notEmpty; + exports.none = none; + exports.not = not; + exports.bool = bool; + exports.match = match; + exports.equal = equal; + exports.gt = gt; + exports.gte = gte; + exports.lt = lt; + exports.lte = lte; + exports.oneWay = oneWay; + exports.readOnly = readOnly; + exports.deprecatingAlias = deprecatingAlias; - function referenceFromParts(root, parts) { - var reference = root; - for (var i = 0; i < parts.length; i++) { - reference = reference.get(parts[i]); - } - return reference; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUdBLGFBQUEsa0JBQUEsQ0FBbUMsSUFBb0MsRUFBRSxLQUFlLEVBQUE7QUFDdEYsWUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDO0FBRXJCLGFBQUssSUFBSSxDQUFDLEdBQUMsQ0FBQyxFQUFFLENBQUMsR0FBQyxLQUFLLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO0FBQ2pDLHFCQUFTLEdBQUcsU0FBUyxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUNyQztBQUVELGVBQU8sU0FBUyxDQUFDO0tBQ2xCIiwiZmlsZSI6InV0aWxzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgVmVyc2lvbmVkUGF0aFJlZmVyZW5jZSB9IGZyb20gJy4vdmFsaWRhdG9ycyc7XG5pbXBvcnQgeyBPcGFxdWUgfSBmcm9tICdnbGltbWVyLXV0aWwnO1xuXG5leHBvcnQgZnVuY3Rpb24gcmVmZXJlbmNlRnJvbVBhcnRzKHJvb3Q6IFZlcnNpb25lZFBhdGhSZWZlcmVuY2U8T3BhcXVlPiwgcGFydHM6IHN0cmluZ1tdKTogVmVyc2lvbmVkUGF0aFJlZmVyZW5jZTxPcGFxdWU+IHtcbiAgbGV0IHJlZmVyZW5jZSA9IHJvb3Q7XG5cbiAgZm9yIChsZXQgaT0wOyBpPHBhcnRzLmxlbmd0aDsgaSsrKSB7XG4gICAgcmVmZXJlbmNlID0gcmVmZXJlbmNlLmdldChwYXJ0c1tpXSk7XG4gIH1cblxuICByZXR1cm4gcmVmZXJlbmNlO1xufVxuIl19 -enifed("glimmer-reference/lib/validators", ["exports"], function (exports) { - "use strict"; + /** + @module ember + @submodule ember-metal + */ - exports.combineTagged = combineTagged; - exports.combineSlice = combineSlice; - exports.combine = combine; - exports.map = map; - exports.isModified = isModified; - var CONSTANT = 0; - exports.CONSTANT = CONSTANT; - var INITIAL = 1; - exports.INITIAL = INITIAL; - var VOLATILE = NaN; - exports.VOLATILE = VOLATILE; + function expandPropertiesToArray(predicateName, properties) { + var expandedProperties = []; - var RevisionTag = (function () { - function RevisionTag() {} + function extractProperty(entry) { + expandedProperties.push(entry); + } - RevisionTag.prototype.validate = function validate(snapshot) { - return this.value() === snapshot; - }; + for (var i = 0; i < properties.length; i++) { + var property = properties[i]; + _emberMetal.assert('Dependent keys passed to Ember.computed.' + predicateName + '() can\'t have spaces.', property.indexOf(' ') < 0); - return RevisionTag; - })(); + _emberMetal.expandProperties(property, extractProperty); + } - exports.RevisionTag = RevisionTag; + return expandedProperties; + } - var $REVISION = INITIAL; + function generateComputedWithPredicate(name, predicate) { + return function () { + for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) { + properties[_key] = arguments[_key]; + } - var DirtyableTag = (function (_RevisionTag) { - babelHelpers.inherits(DirtyableTag, _RevisionTag); + var expandedProperties = expandPropertiesToArray(name, properties); - function DirtyableTag() { - var revision = arguments.length <= 0 || arguments[0] === undefined ? $REVISION : arguments[0]; + var computedFunc = _emberMetal.computed(function () { + var lastIdx = expandedProperties.length - 1; - _RevisionTag.call(this); - this.revision = revision; + for (var i = 0; i < lastIdx; i++) { + var value = _emberMetal.get(this, expandedProperties[i]); + if (!predicate(value)) { + return value; + } } - DirtyableTag.prototype.value = function value() { - return this.revision; - }; + return _emberMetal.get(this, expandedProperties[lastIdx]); + }); - DirtyableTag.prototype.dirty = function dirty() { - this.revision = ++$REVISION; - }; + return computedFunc.property.apply(computedFunc, expandedProperties); + }; + } - return DirtyableTag; - })(RevisionTag); + /** + A computed property that returns true if the value of the dependent + property is null, an empty string, empty array, or empty function. + + Example + + ```javascript + let ToDoList = Ember.Object.extend({ + isDone: Ember.computed.empty('todos') + }); + + let todoList = ToDoList.create({ + todos: ['Unit Test', 'Documentation', 'Release'] + }); + + todoList.get('isDone'); // false + todoList.get('todos').clear(); + todoList.get('isDone'); // true + ``` + + @since 1.6.0 + @method empty + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which negate + the original value for property + @public + */ - exports.DirtyableTag = DirtyableTag; + function empty(dependentKey) { + return _emberMetal.computed(dependentKey + '.length', function () { + return _emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); + }); + } - function combineTagged(tagged) { - var optimized = []; - for (var i = 0, l = tagged.length; i < l; i++) { - var tag = tagged[i].tag; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); - } - return _combine(optimized); - } + /** + A computed property that returns true if the value of the dependent + property is NOT null, an empty string, empty array, or empty function. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasStuff: Ember.computed.notEmpty('backpack') + }); + + let hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); + + hamster.get('hasStuff'); // true + hamster.get('backpack').clear(); // [] + hamster.get('hasStuff'); // false + ``` + + @method notEmpty + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which returns true if + original value for property is not empty. + @public + */ - function combineSlice(slice) { - var optimized = []; - var node = slice.head(); - while (node !== null) { - var tag = node.tag; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag !== CONSTANT_TAG) optimized.push(tag); - node = slice.nextNode(node); - } - return _combine(optimized); - } + function notEmpty(dependentKey) { + return _emberMetal.computed(dependentKey + '.length', function () { + return !_emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); + }); + } - function combine(tags) { - var optimized = []; - for (var i = 0, l = tags.length; i < l; i++) { - var tag = tags[i]; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); - } - return _combine(optimized); - } + /** + A computed property that returns true if the value of the dependent + property is null or undefined. This avoids errors from JSLint complaining + about use of ==, which can be technically confusing. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + isHungry: Ember.computed.none('food') + }); + + let hamster = Hamster.create(); + + hamster.get('isHungry'); // true + hamster.set('food', 'Banana'); + hamster.get('isHungry'); // false + hamster.set('food', null); + hamster.get('isHungry'); // true + ``` + + @method none + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which + returns true if original value for property is null or undefined. + @public + */ - function _combine(tags) { - switch (tags.length) { - case 0: - return CONSTANT_TAG; - case 1: - return tags[0]; - case 2: - return new TagsPair(tags[0], tags[1]); - default: - return new TagsCombinator(tags); - } - ; - } + function none(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.isNone(_emberMetal.get(this, dependentKey)); + }); + } + + /** + A computed property that returns the inverse boolean value + of the original value for the dependent property. + + Example + + ```javascript + let User = Ember.Object.extend({ + isAnonymous: Ember.computed.not('loggedIn') + }); + + let user = User.create({loggedIn: false}); + + user.get('isAnonymous'); // true + user.set('loggedIn', true); + user.get('isAnonymous'); // false + ``` + + @method not + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which returns + inverse of the original value for property + @public + */ - var CachedTag = (function (_RevisionTag2) { - babelHelpers.inherits(CachedTag, _RevisionTag2); + function not(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return !_emberMetal.get(this, dependentKey); + }); + } - function CachedTag() { - _RevisionTag2.apply(this, arguments); - this.lastChecked = null; - this.lastValue = null; - } + /** + A computed property that converts the provided dependent property + into a boolean value. + + ```javascript + let Hamster = Ember.Object.extend({ + hasBananas: Ember.computed.bool('numBananas') + }); + + let hamster = Hamster.create(); + + hamster.get('hasBananas'); // false + hamster.set('numBananas', 0); + hamster.get('hasBananas'); // false + hamster.set('numBananas', 1); + hamster.get('hasBananas'); // true + hamster.set('numBananas', null); + hamster.get('hasBananas'); // false + ``` + + @method bool + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which converts + to boolean the original value for property + @public + */ - CachedTag.prototype.value = function value() { - var lastChecked = this.lastChecked; - var lastValue = this.lastValue; + function bool(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return !!_emberMetal.get(this, dependentKey); + }); + } - if (lastChecked !== $REVISION) { - this.lastChecked = $REVISION; - this.lastValue = lastValue = this.compute(); - } - return this.lastValue; - }; + /** + A computed property which matches the original value for the + dependent property against a given RegExp, returning `true` + if the value matches the RegExp and `false` if it does not. + + Example + + ```javascript + let User = Ember.Object.extend({ + hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) + }); + + let user = User.create({loggedIn: false}); + + user.get('hasValidEmail'); // false + user.set('email', ''); + user.get('hasValidEmail'); // false + user.set('email', 'ember_hamster@example.com'); + user.get('hasValidEmail'); // true + ``` + + @method match + @for Ember.computed + @param {String} dependentKey + @param {RegExp} regexp + @return {Ember.ComputedProperty} computed property which match + the original value for property against a given RegExp + @public + */ - CachedTag.prototype.invalidate = function invalidate() { - this.lastChecked = null; - }; + function match(dependentKey, regexp) { + return _emberMetal.computed(dependentKey, function () { + var value = _emberMetal.get(this, dependentKey); - return CachedTag; - })(RevisionTag); + return typeof value === 'string' ? regexp.test(value) : false; + }); + } - exports.CachedTag = CachedTag; + /** + A computed property that returns true if the provided dependent property + is equal to the given value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + satisfied: Ember.computed.equal('percentCarrotsEaten', 100) + }); + + let hamster = Hamster.create(); + + hamster.get('satisfied'); // false + hamster.set('percentCarrotsEaten', 100); + hamster.get('satisfied'); // true + hamster.set('percentCarrotsEaten', 50); + hamster.get('satisfied'); // false + ``` + + @method equal + @for Ember.computed + @param {String} dependentKey + @param {String|Number|Object} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is equal to the given value. + @public + */ - var TagsPair = (function (_CachedTag) { - babelHelpers.inherits(TagsPair, _CachedTag); + function equal(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) === value; + }); + } - function TagsPair(first, second) { - _CachedTag.call(this); - this.first = first; - this.second = second; - } + /** + A computed property that returns true if the provided dependent property + is greater than the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasTooManyBananas: Ember.computed.gt('numBananas', 10) + }); + + let hamster = Hamster.create(); + + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 3); + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 11); + hamster.get('hasTooManyBananas'); // true + ``` + + @method gt + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is greater than given value. + @public + */ - TagsPair.prototype.compute = function compute() { - return Math.max(this.first.value(), this.second.value()); - }; + function gt(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) > value; + }); + } - return TagsPair; - })(CachedTag); + /** + A computed property that returns true if the provided dependent property + is greater than or equal to the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasTooManyBananas: Ember.computed.gte('numBananas', 10) + }); + + let hamster = Hamster.create(); + + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 3); + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 10); + hamster.get('hasTooManyBananas'); // true + ``` + + @method gte + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is greater or equal then given value. + @public + */ - var TagsCombinator = (function (_CachedTag2) { - babelHelpers.inherits(TagsCombinator, _CachedTag2); + function gte(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) >= value; + }); + } - function TagsCombinator(tags) { - _CachedTag2.call(this); - this.tags = tags; - } + /** + A computed property that returns true if the provided dependent property + is less than the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + needsMoreBananas: Ember.computed.lt('numBananas', 3) + }); + + let hamster = Hamster.create(); + + hamster.get('needsMoreBananas'); // true + hamster.set('numBananas', 3); + hamster.get('needsMoreBananas'); // false + hamster.set('numBananas', 2); + hamster.get('needsMoreBananas'); // true + ``` + + @method lt + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is less then given value. + @public + */ - TagsCombinator.prototype.compute = function compute() { - var tags = this.tags; + function lt(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) < value; + }); + } - var max = -1; - for (var i = 0; i < tags.length; i++) { - var value = tags[i].value(); - max = Math.max(value, max); - } - return max; - }; + /** + A computed property that returns true if the provided dependent property + is less than or equal to the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + needsMoreBananas: Ember.computed.lte('numBananas', 3) + }); + + let hamster = Hamster.create(); + + hamster.get('needsMoreBananas'); // true + hamster.set('numBananas', 5); + hamster.get('needsMoreBananas'); // false + hamster.set('numBananas', 3); + hamster.get('needsMoreBananas'); // true + ``` + + @method lte + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is less or equal than given value. + @public + */ - return TagsCombinator; - })(CachedTag); + function lte(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) <= value; + }); + } - var UpdatableTag = (function (_CachedTag3) { - babelHelpers.inherits(UpdatableTag, _CachedTag3); + /** + A computed property that performs a logical `and` on the + original values for the provided dependent properties. + + You may pass in more than two properties and even use + property brace expansion. The computed property will + return the first falsy value or last truthy value + just like JavaScript's `&&` operator. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), + readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') + }); + + let tomster = Hamster.create(); + + tomster.get('readyForCamp'); // false + tomster.set('hasTent', true); + tomster.get('readyForCamp'); // false + tomster.set('hasBackpack', true); + tomster.get('readyForCamp'); // true + tomster.set('hasBackpack', 'Yes'); + tomster.get('readyForCamp'); // 'Yes' + tomster.set('hasWalkingStick', null); + tomster.get('readyForHike'); // null + ``` + + @method and + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which performs + a logical `and` on the values of all the original values for properties. + @public + */ + var and = generateComputedWithPredicate('and', function (value) { + return value; + }); - function UpdatableTag(tag) { - _CachedTag3.call(this); - this.tag = tag; - this.lastUpdated = INITIAL; - } + exports.and = and; + /** + A computed property which performs a logical `or` on the + original values for the provided dependent properties. + + You may pass in more than two properties and even use + property brace expansion. The computed property will + return the first truthy value or last falsy value just + like JavaScript's `||` operator. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'), + readyForBeach: Ember.computed.or('{hasSunscreen,hasUmbrella}') + }); + + let tomster = Hamster.create(); + + tomster.get('readyForRain'); // undefined + tomster.set('hasUmbrella', true); + tomster.get('readyForRain'); // true + tomster.set('hasJacket', 'Yes'); + tomster.get('readyForRain'); // 'Yes' + tomster.set('hasSunscreen', 'Check'); + tomster.get('readyForBeach'); // 'Check' + ``` + + @method or + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which performs + a logical `or` on the values of all the original values for properties. + @public + */ + var or = generateComputedWithPredicate('or', function (value) { + return !value; + }); - ////////// + exports.or = or; + /** + Creates a new property that is an alias for another property + on an object. Calls to `get` or `set` this property behave as + though they were called on the original property. + + ```javascript + let Person = Ember.Object.extend({ + name: 'Alex Matchneer', + nomen: Ember.computed.alias('name') + }); + + let alex = Person.create(); + + alex.get('nomen'); // 'Alex Matchneer' + alex.get('name'); // 'Alex Matchneer' + + alex.set('nomen', '@machty'); + alex.get('name'); // '@machty' + ``` + + @method alias + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates an + alias to the original value for property. + @public + */ - UpdatableTag.prototype.compute = function compute() { - return Math.max(this.lastUpdated, this.tag.value()); - }; + /** + Where `computed.alias` aliases `get` and `set`, and allows for bidirectional + data flow, `computed.oneWay` only provides an aliased `get`. The `set` will + not mutate the upstream property, rather causes the current property to + become the value set. This causes the downstream property to permanently + diverge from the upstream property. + + Example + + ```javascript + let User = Ember.Object.extend({ + firstName: null, + lastName: null, + nickName: Ember.computed.oneWay('firstName') + }); + + let teddy = User.create({ + firstName: 'Teddy', + lastName: 'Zeenny' + }); + + teddy.get('nickName'); // 'Teddy' + teddy.set('nickName', 'TeddyBear'); // 'TeddyBear' + teddy.get('firstName'); // 'Teddy' + ``` + + @method oneWay + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @public + */ - UpdatableTag.prototype.update = function update(tag) { - if (tag !== this.tag) { - this.tag = tag; - this.lastUpdated = $REVISION; - this.invalidate(); - } - }; + function oneWay(dependentKey) { + return _emberMetal.alias(dependentKey).oneWay(); + } - return UpdatableTag; - })(CachedTag); + /** + This is a more semantically meaningful alias of `computed.oneWay`, + whose name is somewhat ambiguous as to which direction the data flows. + + @method reads + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @public + */ - exports.UpdatableTag = UpdatableTag; - var CONSTANT_TAG = new ((function (_RevisionTag3) { - babelHelpers.inherits(ConstantTag, _RevisionTag3); + /** + Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides + a readOnly one way binding. Very often when using `computed.oneWay` one does + not also want changes to propagate back up, as they will replace the value. + + This prevents the reverse flow, and also throws an exception when it occurs. + + Example + + ```javascript + let User = Ember.Object.extend({ + firstName: null, + lastName: null, + nickName: Ember.computed.readOnly('firstName') + }); + + let teddy = User.create({ + firstName: 'Teddy', + lastName: 'Zeenny' + }); + + teddy.get('nickName'); // 'Teddy' + teddy.set('nickName', 'TeddyBear'); // throws Exception + // throw new Ember.Error('Cannot Set: nickName on: ' );` + teddy.get('firstName'); // 'Teddy' + ``` + + @method readOnly + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @since 1.5.0 + @public + */ - function ConstantTag() { - _RevisionTag3.apply(this, arguments); - } + function readOnly(dependentKey) { + return _emberMetal.alias(dependentKey).readOnly(); + } - ConstantTag.prototype.value = function value() { - return CONSTANT; - }; + /** + Creates a new property that is an alias for another property + on an object. Calls to `get` or `set` this property behave as + though they were called on the original property, but also + print a deprecation warning. + + ```javascript + let Hamster = Ember.Object.extend({ + bananaCount: Ember.computed.deprecatingAlias('cavendishCount', { + id: 'hamster.deprecate-banana', + until: '3.0.0' + }) + }); + + let hamster = Hamster.create(); + + hamster.set('bananaCount', 5); // Prints a deprecation warning. + hamster.get('cavendishCount'); // 5 + ``` + + @method deprecatingAlias + @for Ember.computed + @param {String} dependentKey + @param {Object} options Options for `Ember.deprecate`. + @return {Ember.ComputedProperty} computed property which creates an + alias with a deprecation to the original value for property. + @since 1.7.0 + @public + */ - return ConstantTag; - })(RevisionTag))(); - exports.CONSTANT_TAG = CONSTANT_TAG; - var VOLATILE_TAG = new ((function (_RevisionTag4) { - babelHelpers.inherits(VolatileTag, _RevisionTag4); + function deprecatingAlias(dependentKey, options) { + return _emberMetal.computed(dependentKey, { + get: function (key) { + _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); + return _emberMetal.get(this, dependentKey); + }, + set: function (key, value) { + _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); + _emberMetal.set(this, dependentKey, value); + return value; + } + }); + } +}); +enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) { + /** + @module ember + @submodule ember-runtime + */ - function VolatileTag() { - _RevisionTag4.apply(this, arguments); - } + 'use strict'; - VolatileTag.prototype.value = function value() { - return VOLATILE; - }; + exports.sum = sum; + exports.max = max; + exports.min = min; + exports.map = map; + exports.mapBy = mapBy; + exports.filter = filter; + exports.filterBy = filterBy; + exports.uniq = uniq; + exports.uniqBy = uniqBy; + exports.intersect = intersect; + exports.setDiff = setDiff; + exports.collect = collect; + exports.sort = sort; - return VolatileTag; - })(RevisionTag))(); - exports.VOLATILE_TAG = VOLATILE_TAG; - var CURRENT_TAG = new ((function (_DirtyableTag) { - babelHelpers.inherits(CurrentTag, _DirtyableTag); + function reduceMacro(dependentKey, callback, initialValue) { + return _emberMetal.computed(dependentKey + '.[]', function () { + var _this = this; - function CurrentTag() { - _DirtyableTag.apply(this, arguments); - } + var arr = _emberMetal.get(this, dependentKey); - CurrentTag.prototype.value = function value() { - return $REVISION; - }; + if (arr === null || typeof arr !== 'object') { + return initialValue; + } - return CurrentTag; - })(DirtyableTag))(); - exports.CURRENT_TAG = CURRENT_TAG; + return arr.reduce(function (previousValue, currentValue, index, array) { + return callback.call(_this, previousValue, currentValue, index, array); + }, initialValue); + }).readOnly(); + } - var CachedReference = (function () { - function CachedReference() { - this.lastRevision = null; - this.lastValue = null; - } + function arrayMacro(dependentKey, callback) { + // This is a bit ugly + var propertyName = undefined; + if (/@each/.test(dependentKey)) { + propertyName = dependentKey.replace(/\.@each.*$/, ''); + } else { + propertyName = dependentKey; + dependentKey += '.[]'; + } - CachedReference.prototype.value = function value() { - var tag = this.tag; - var lastRevision = this.lastRevision; - var lastValue = this.lastValue; + return _emberMetal.computed(dependentKey, function () { + var value = _emberMetal.get(this, propertyName); + if (_emberRuntimeUtils.isArray(value)) { + return _emberRuntimeSystemNative_array.A(callback.call(this, value)); + } else { + return _emberRuntimeSystemNative_array.A(); + } + }).readOnly(); + } - if (!lastRevision || !tag.validate(lastRevision)) { - lastValue = this.lastValue = this.compute(); - this.lastRevision = tag.value(); - } - return lastValue; - }; + function multiArrayMacro(dependentKeys, callback) { + var args = dependentKeys.map(function (key) { + return key + '.[]'; + }); - CachedReference.prototype.invalidate = function invalidate() { - this.lastRevision = null; - }; + args.push(function () { + return _emberRuntimeSystemNative_array.A(callback.call(this, dependentKeys)); + }); - return CachedReference; - })(); + return _emberMetal.computed.apply(this, args).readOnly(); + } - exports.CachedReference = CachedReference; + /** + A computed property that returns the sum of the values + in the dependent array. + + @method sum + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the sum of all values in the dependentKey's array + @since 1.4.0 + @public + */ - var MapperReference = (function (_CachedReference) { - babelHelpers.inherits(MapperReference, _CachedReference); + function sum(dependentKey) { + return reduceMacro(dependentKey, function (sum, item) { + return sum + item; + }, 0); + } - function MapperReference(reference, mapper) { - _CachedReference.call(this); - this.tag = reference.tag; - this.reference = reference; - this.mapper = mapper; - } + /** + A computed property that calculates the maximum value in the + dependent array. This will return `-Infinity` when the dependent + array is empty. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age'), + maxChildAge: Ember.computed.max('childAges') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('maxChildAge'); // -Infinity + lordByron.get('children').pushObject({ + name: 'Augusta Ada Byron', age: 7 + }); + lordByron.get('maxChildAge'); // 7 + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('maxChildAge'); // 8 + ``` + + If the types of the arguments are not numbers, + they will be converted to numbers and the type + of the return value will always be `Number`. + For example, the max of a list of Date objects will be + the highest timestamp as a `Number`. + This behavior is consistent with `Math.max`. + + @method max + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array + @public + */ - MapperReference.prototype.compute = function compute() { - var reference = this.reference; - var mapper = this.mapper; + function max(dependentKey) { + return reduceMacro(dependentKey, function (max, item) { + return Math.max(max, item); + }, -Infinity); + } - return mapper(reference.value()); - }; + /** + A computed property that calculates the minimum value in the + dependent array. This will return `Infinity` when the dependent + array is empty. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age'), + minChildAge: Ember.computed.min('childAges') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('minChildAge'); // Infinity + lordByron.get('children').pushObject({ + name: 'Augusta Ada Byron', age: 7 + }); + lordByron.get('minChildAge'); // 7 + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('minChildAge'); // 5 + ``` + + If the types of the arguments are not numbers, + they will be converted to numbers and the type + of the return value will always be `Number`. + For example, the min of a list of Date objects will be + the lowest timestamp as a `Number`. + This behavior is consistent with `Math.min`. + + @method min + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array + @public + */ - return MapperReference; - })(CachedReference); + function min(dependentKey) { + return reduceMacro(dependentKey, function (min, item) { + return Math.min(min, item); + }, Infinity); + } - function map(reference, mapper) { - return new MapperReference(reference, mapper); - } + /** + Returns an array mapped via the callback + + The callback method you provide should have the following signature. + `item` is the current item in the iteration. + `index` is the integer index of the current item in the iteration. + + ```javascript + function(item, index); + ``` + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + excitingChores: Ember.computed.map('chores', function(chore, index) { + return chore.toUpperCase() + '!'; + }) + }); + + let hamster = Hamster.create({ + chores: ['clean', 'write more unit tests'] + }); + + hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] + ``` + + @method map + @for Ember.computed + @param {String} dependentKey + @param {Function} callback + @return {Ember.ComputedProperty} an array mapped via the callback + @public + */ - ////////// + function map(dependentKey, callback) { + return arrayMacro(dependentKey, function (value) { + return value.map(callback, this); + }); + } - var ReferenceCache = (function () { - function ReferenceCache(reference) { - this.lastValue = null; - this.lastRevision = null; - this.initialized = false; - this.tag = reference.tag; - this.reference = reference; - } + /** + Returns an array mapped to the specified key. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('childAges'); // [] + lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); + lordByron.get('childAges'); // [7] + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('childAges'); // [7, 5, 8] + ``` + + @method mapBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @return {Ember.ComputedProperty} an array mapped to the specified key + @public + */ - ReferenceCache.prototype.peek = function peek() { - if (!this.initialized) { - return this.initialize(); - } - return this.lastValue; - }; + function mapBy(dependentKey, propertyKey) { + _emberMetal.assert('Ember.computed.mapBy expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string'); - ReferenceCache.prototype.revalidate = function revalidate() { - if (!this.initialized) { - return this.initialize(); - } - var reference = this.reference; - var lastRevision = this.lastRevision; + return map(dependentKey + '.@each.' + propertyKey, function (item) { + return _emberMetal.get(item, propertyKey); + }); + } - var tag = reference.tag; - if (tag.validate(lastRevision)) return NOT_MODIFIED; - this.lastRevision = tag.value(); - var lastValue = this.lastValue; + /** + Filters the array by the callback. + + The callback method you provide should have the following signature. + `item` is the current item in the iteration. + `index` is the integer index of the current item in the iteration. + `array` is the dependant array itself. + + ```javascript + function(item, index, array); + ``` + + ```javascript + let Hamster = Ember.Object.extend({ + remainingChores: Ember.computed.filter('chores', function(chore, index, array) { + return !chore.done; + }) + }); + + let hamster = Hamster.create({ + chores: [ + { name: 'cook', done: true }, + { name: 'clean', done: true }, + { name: 'write more unit tests', done: false } + ] + }); + + hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] + ``` + + @method filter + @for Ember.computed + @param {String} dependentKey + @param {Function} callback + @return {Ember.ComputedProperty} the filtered array + @public + */ - var value = reference.value(); - if (value === lastValue) return NOT_MODIFIED; - this.lastValue = value; - return value; - }; + function filter(dependentKey, callback) { + return arrayMacro(dependentKey, function (value) { + return value.filter(callback, this); + }); + } - ReferenceCache.prototype.initialize = function initialize() { - var reference = this.reference; + /** + Filters the array by the property and value + + ```javascript + let Hamster = Ember.Object.extend({ + remainingChores: Ember.computed.filterBy('chores', 'done', false) + }); + + let hamster = Hamster.create({ + chores: [ + { name: 'cook', done: true }, + { name: 'clean', done: true }, + { name: 'write more unit tests', done: false } + ] + }); + + hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] + ``` + + @method filterBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @param {*} value + @return {Ember.ComputedProperty} the filtered array + @public + */ - var value = this.lastValue = reference.value(); - this.lastRevision = reference.tag.value(); - this.initialized = true; - return value; - }; + function filterBy(dependentKey, propertyKey, value) { + var callback = undefined; - return ReferenceCache; - })(); + if (arguments.length === 2) { + callback = function (item) { + return _emberMetal.get(item, propertyKey); + }; + } else { + callback = function (item) { + return _emberMetal.get(item, propertyKey) === value; + }; + } - exports.ReferenceCache = ReferenceCache; + return filter(dependentKey + '.@each.' + propertyKey, callback); + } - var NOT_MODIFIED = "adb3b78e-3d22-4e4b-877a-6317c2c5c145"; + /** + A computed property which returns a new array with all the unique + elements from one or more dependent arrays. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + uniqueFruits: Ember.computed.uniq('fruits') + }); + + let hamster = Hamster.create({ + fruits: [ + 'banana', + 'grape', + 'kale', + 'banana' + ] + }); + + hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale'] + ``` + + @method uniq + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ - function isModified(value) { - return value !== NOT_MODIFIED; + function uniq() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi92YWxpZGF0b3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3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UoKTtcblxuICAgIGxldCB7IGxhc3RWYWx1ZSB9ID0gdGhpcztcbiAgICBsZXQgdmFsdWUgPSByZWZlcmVuY2UudmFsdWUoKTtcbiAgICBpZiAodmFsdWUgPT09IGxhc3RWYWx1ZSkgcmV0dXJuIE5PVF9NT0RJRklFRDtcbiAgICB0aGlzLmxhc3RWYWx1ZSA9IHZhbHVlO1xuXG4gICAgcmV0dXJuIHZhbHVlO1xuICB9XG5cbiAgcHJpdmF0ZSBpbml0aWFsaXplKCk6IFQge1xuICAgIGxldCB7IHJlZmVyZW5jZSB9ID0gdGhpcztcblxuICAgIGxldCB2YWx1ZSA9IHRoaXMubGFzdFZhbHVlID0gcmVmZXJlbmNlLnZhbHVlKCk7XG4gICAgdGhpcy5sYXN0UmV2aXNpb24gPSByZWZlcmVuY2UudGFnLnZhbHVlKCk7XG4gICAgdGhpcy5pbml0aWFsaXplZCA9IHRydWU7XG5cbiAgICByZXR1cm4gdmFsdWU7XG4gIH1cbn1cblxuZXhwb3J0IHR5cGUgVmFsaWRhdGlvbjxUPiA9IFQgfCBOb3RNb2RpZmllZDtcblxuZXhwb3J0IHR5cGUgTm90TW9kaWZpZWQgPSBcImFkYjNiNzhlLTNkMjItNGU0Yi04NzdhLTYzMTdjMmM1YzE0NVwiO1xuXG5jb25zdCBOT1RfTU9ESUZJRUQ6IE5vdE1vZGlmaWVkID0gXCJhZGIzYjc4ZS0zZDIyLTRlNGItODc3YS02MzE3YzJjNWMxNDVcIjtcblxuZXhwb3J0IGZ1bmN0aW9uIGlzTW9kaWZpZWQ8VD4odmFsdWU6IFZhbGlkYXRpb248VD4pOiB2YWx1ZSBpcyBUIHtcbiAgcmV0dXJuIHZhbHVlICE9PSBOT1RfTU9ESUZJRUQ7XG59XG4iXX0= -enifed('glimmer-runtime/index', ['exports', 'glimmer-runtime/lib/dom/interfaces', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/template', 'glimmer-runtime/lib/symbol-table', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/compiled/opcodes/builder', 'glimmer-runtime/lib/compiler', 'glimmer-runtime/lib/opcode-builder', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-runtime/lib/dom/attribute-managers', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/compiled/expressions/function', 'glimmer-runtime/lib/helpers/get-dynamic-var', 'glimmer-runtime/lib/syntax/builtins/with-dynamic-vars', 'glimmer-runtime/lib/syntax/builtins/in-element', 'glimmer-runtime/lib/vm', 'glimmer-runtime/lib/upsert', 'glimmer-runtime/lib/environment', 'glimmer-runtime/lib/partial', 'glimmer-runtime/lib/component/interfaces', 'glimmer-runtime/lib/modifier/interfaces', 'glimmer-runtime/lib/dom/helper', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/bounds'], function (exports, _glimmerRuntimeLibDomInterfaces, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibTemplate, _glimmerRuntimeLibSymbolTable, _glimmerRuntimeLibReferences, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibCompiledOpcodesBuilder, _glimmerRuntimeLibCompiler, _glimmerRuntimeLibOpcodeBuilder, _glimmerRuntimeLibCompiledBlocks, _glimmerRuntimeLibDomAttributeManagers, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibCompiledExpressionsFunction, _glimmerRuntimeLibHelpersGetDynamicVar, _glimmerRuntimeLibSyntaxBuiltinsWithDynamicVars, _glimmerRuntimeLibSyntaxBuiltinsInElement, _glimmerRuntimeLibVm, _glimmerRuntimeLibUpsert, _glimmerRuntimeLibEnvironment, _glimmerRuntimeLibPartial, _glimmerRuntimeLibComponentInterfaces, _glimmerRuntimeLibModifierInterfaces, _glimmerRuntimeLibDomHelper, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibBounds) { - 'use strict'; - - exports.ATTRIBUTE_SYNTAX = _glimmerRuntimeLibSyntax.ATTRIBUTE; - exports.StatementSyntax = _glimmerRuntimeLibSyntax.Statement; - exports.ExpressionSyntax = _glimmerRuntimeLibSyntax.Expression; - exports.AttributeSyntax = _glimmerRuntimeLibSyntax.Attribute; - exports.StatementCompilationBuffer = _glimmerRuntimeLibSyntax.StatementCompilationBuffer; - exports.SymbolLookup = _glimmerRuntimeLibSyntax.SymbolLookup; - exports.CompileInto = _glimmerRuntimeLibSyntax.CompileInto; - exports.isAttribute = _glimmerRuntimeLibSyntax.isAttribute; - exports.templateFactory = _glimmerRuntimeLibTemplate.default; - exports.TemplateFactory = _glimmerRuntimeLibTemplate.TemplateFactory; - exports.Template = _glimmerRuntimeLibTemplate.Template; - exports.SymbolTable = _glimmerRuntimeLibSymbolTable.default; - exports.NULL_REFERENCE = _glimmerRuntimeLibReferences.NULL_REFERENCE; - exports.UNDEFINED_REFERENCE = _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - exports.PrimitiveReference = _glimmerRuntimeLibReferences.PrimitiveReference; - exports.ConditionalReference = _glimmerRuntimeLibReferences.ConditionalReference; - exports.Blocks = _glimmerRuntimeLibSyntaxCore.Blocks; - exports.OptimizedAppend = _glimmerRuntimeLibSyntaxCore.OptimizedAppend; - exports.UnoptimizedAppend = _glimmerRuntimeLibSyntaxCore.UnoptimizedAppend; - exports.Unknown = _glimmerRuntimeLibSyntaxCore.Unknown; - exports.StaticAttr = _glimmerRuntimeLibSyntaxCore.StaticAttr; - exports.DynamicAttr = _glimmerRuntimeLibSyntaxCore.DynamicAttr; - exports.ArgsSyntax = _glimmerRuntimeLibSyntaxCore.Args; - exports.NamedArgsSyntax = _glimmerRuntimeLibSyntaxCore.NamedArgs; - exports.PositionalArgsSyntax = _glimmerRuntimeLibSyntaxCore.PositionalArgs; - exports.RefSyntax = _glimmerRuntimeLibSyntaxCore.Ref; - exports.GetNamedParameterSyntax = _glimmerRuntimeLibSyntaxCore.GetArgument; - exports.GetSyntax = _glimmerRuntimeLibSyntaxCore.Get; - exports.ValueSyntax = _glimmerRuntimeLibSyntaxCore.Value; - exports.OpenElement = _glimmerRuntimeLibSyntaxCore.OpenElement; - exports.HelperSyntax = _glimmerRuntimeLibSyntaxCore.Helper; - exports.BlockSyntax = _glimmerRuntimeLibSyntaxCore.Block; - exports.OpenPrimitiveElementSyntax = _glimmerRuntimeLibSyntaxCore.OpenPrimitiveElement; - exports.CloseElementSyntax = _glimmerRuntimeLibSyntaxCore.CloseElement; - exports.OpcodeBuilderDSL = _glimmerRuntimeLibCompiledOpcodesBuilder.default; - exports.Compiler = _glimmerRuntimeLibCompiler.default; - exports.Compilable = _glimmerRuntimeLibCompiler.Compilable; - exports.CompileIntoList = _glimmerRuntimeLibCompiler.CompileIntoList; - exports.compileLayout = _glimmerRuntimeLibCompiler.compileLayout; - exports.ComponentBuilder = _glimmerRuntimeLibOpcodeBuilder.ComponentBuilder; - exports.StaticDefinition = _glimmerRuntimeLibOpcodeBuilder.StaticDefinition; - exports.DynamicDefinition = _glimmerRuntimeLibOpcodeBuilder.DynamicDefinition; - exports.Block = _glimmerRuntimeLibCompiledBlocks.Block; - exports.CompiledBlock = _glimmerRuntimeLibCompiledBlocks.CompiledBlock; - exports.Layout = _glimmerRuntimeLibCompiledBlocks.Layout; - exports.InlineBlock = _glimmerRuntimeLibCompiledBlocks.InlineBlock; - exports.EntryPoint = _glimmerRuntimeLibCompiledBlocks.EntryPoint; - exports.IAttributeManager = _glimmerRuntimeLibDomAttributeManagers.AttributeManager; - exports.AttributeManager = _glimmerRuntimeLibDomAttributeManagers.AttributeManager; - exports.PropertyManager = _glimmerRuntimeLibDomAttributeManagers.PropertyManager; - exports.INPUT_VALUE_PROPERTY_MANAGER = _glimmerRuntimeLibDomAttributeManagers.INPUT_VALUE_PROPERTY_MANAGER; - exports.defaultManagers = _glimmerRuntimeLibDomAttributeManagers.defaultManagers; - exports.defaultAttributeManagers = _glimmerRuntimeLibDomAttributeManagers.defaultAttributeManagers; - exports.defaultPropertyManagers = _glimmerRuntimeLibDomAttributeManagers.defaultPropertyManagers; - exports.readDOMAttr = _glimmerRuntimeLibDomAttributeManagers.readDOMAttr; - exports.normalizeTextValue = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue; - exports.CompiledExpression = _glimmerRuntimeLibCompiledExpressions.CompiledExpression; - exports.CompiledArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs; - exports.CompiledNamedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs; - exports.CompiledPositionalArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs; - exports.EvaluatedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs; - exports.EvaluatedNamedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedNamedArgs; - exports.EvaluatedPositionalArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedPositionalArgs; - exports.FunctionExpression = _glimmerRuntimeLibCompiledExpressionsFunction.FunctionExpression; - exports.getDynamicVar = _glimmerRuntimeLibHelpersGetDynamicVar.default; - exports.WithDynamicVarsSyntax = _glimmerRuntimeLibSyntaxBuiltinsWithDynamicVars.default; - exports.InElementSyntax = _glimmerRuntimeLibSyntaxBuiltinsInElement.default; - exports.VM = _glimmerRuntimeLibVm.PublicVM; - exports.UpdatingVM = _glimmerRuntimeLibVm.UpdatingVM; - exports.RenderResult = _glimmerRuntimeLibVm.RenderResult; - exports.SafeString = _glimmerRuntimeLibUpsert.SafeString; - exports.isSafeString = _glimmerRuntimeLibUpsert.isSafeString; - exports.Scope = _glimmerRuntimeLibEnvironment.Scope; - exports.Environment = _glimmerRuntimeLibEnvironment.default; - exports.Helper = _glimmerRuntimeLibEnvironment.Helper; - exports.ParsedStatement = _glimmerRuntimeLibEnvironment.ParsedStatement; - exports.DynamicScope = _glimmerRuntimeLibEnvironment.DynamicScope; - exports.PartialDefinition = _glimmerRuntimeLibPartial.PartialDefinition; - exports.Component = _glimmerRuntimeLibComponentInterfaces.Component; - exports.ComponentClass = _glimmerRuntimeLibComponentInterfaces.ComponentClass; - exports.ComponentManager = _glimmerRuntimeLibComponentInterfaces.ComponentManager; - exports.ComponentDefinition = _glimmerRuntimeLibComponentInterfaces.ComponentDefinition; - exports.ComponentLayoutBuilder = _glimmerRuntimeLibComponentInterfaces.ComponentLayoutBuilder; - exports.ComponentAttrsBuilder = _glimmerRuntimeLibComponentInterfaces.ComponentAttrsBuilder; - exports.isComponentDefinition = _glimmerRuntimeLibComponentInterfaces.isComponentDefinition; - exports.ModifierManager = _glimmerRuntimeLibModifierInterfaces.ModifierManager; - exports.DOMChanges = _glimmerRuntimeLibDomHelper.default; - exports.IDOMChanges = _glimmerRuntimeLibDomHelper.DOMChanges; - exports.DOMTreeConstruction = _glimmerRuntimeLibDomHelper.DOMTreeConstruction; - exports.isWhitespace = _glimmerRuntimeLibDomHelper.isWhitespace; - exports.insertHTMLBefore = _glimmerRuntimeLibDomHelper.insertHTMLBefore; - exports.Simple = _glimmerRuntimeLibDomInterfaces; - exports.ElementStack = _glimmerRuntimeLibBuilder.ElementStack; - exports.ElementOperations = _glimmerRuntimeLibBuilder.ElementOperations; - exports.Bounds = _glimmerRuntimeLibBounds.default; - exports.ConcreteBounds = _glimmerRuntimeLibBounds.ConcreteBounds; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFDZSxnQkFBZ0IsNEJBQTdCLFNBQVM7VUFDSSxlQUFlLDRCQUE1QixTQUFTO1VBQ0ssZ0JBQWdCLDRCQUE5QixVQUFVO1VBQ0csZUFBZSw0QkFBNUIsU0FBUztVQUNULDBCQUEwQiw0QkFBMUIsMEJBQTBCO1VBQzFCLFlBQVksNEJBQVosWUFBWT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0aWFsRGVmaW5pdGlvblxufSBmcm9tICcuL2xpYi9wYXJ0aWFsJztcblxuZXhwb3J0IHtcbiAgQ29tcG9uZW50LFxuICBDb21wb25lbnRDbGFzcyxcbiAgQ29tcG9uZW50TWFuYWdlcixcbiAgQ29tcG9uZW50RGVmaW5pdGlvbixcbiAgQ29tcG9uZW50TGF5b3V0QnVpbGRlcixcbiAgQ29tcG9uZW50QXR0cnNCdWlsZGVyLFxuICBpc0NvbXBvbmVudERlZmluaXRpb25cbn0gZnJvbSAnLi9saWIvY29tcG9uZW50L2ludGVyZmFjZXMnO1xuXG5leHBvcnQge1xuICBNb2RpZmllck1hbmFnZXJcbn0gZnJvbSAnLi9saWIvbW9kaWZpZXIvaW50ZXJmYWNlcyc7XG5cbmV4cG9ydCB7IGRlZmF1bHQgYXMgRE9NQ2hhbmdlcywgRE9NQ2hhbmdlcyBhcyBJRE9NQ2hhbmdlcywgRE9NVHJlZUNvbnN0cnVjdGlvbiwgaXNXaGl0ZXNwYWNlLCBpbnNlcnRIVE1MQmVmb3JlIH0gZnJvbSAnLi9saWIvZG9tL2hlbHBlcic7XG5pbXBvcnQgICogYXMgU2ltcGxlIGZyb20gJy4vbGliL2RvbS9pbnRlcmZhY2VzJztcbmV4cG9ydCB7IFNpbXBsZSB9O1xuZXhwb3J0IHsgRWxlbWVudFN0YWNrLCBFbGVtZW50T3BlcmF0aW9ucyB9IGZyb20gJy4vbGliL2J1aWxkZXInO1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBCb3VuZHMsIENvbmNyZXRlQm91bmRzIH0gZnJvbSAnLi9saWIvYm91bmRzJztcbiJdfQ== -enifed("glimmer-runtime/lib/bounds", ["exports"], function (exports) { - "use strict"; - - exports.bounds = bounds; - exports.single = single; - exports.move = move; - exports.clear = clear; - var Cursor = function Cursor(element, nextSibling) { - this.element = element; - this.nextSibling = nextSibling; - }; + return multiArrayMacro(args, function (dependentKeys) { + var _this2 = this; - exports.Cursor = Cursor; + var uniq = _emberRuntimeSystemNative_array.A(); - var RealDOMBounds = (function () { - function RealDOMBounds(bounds) { - this.bounds = bounds; + dependentKeys.forEach(function (dependentKey) { + var value = _emberMetal.get(_this2, dependentKey); + if (_emberRuntimeUtils.isArray(value)) { + value.forEach(function (item) { + if (uniq.indexOf(item) === -1) { + uniq.push(item); + } + }); } + }); - RealDOMBounds.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; - - RealDOMBounds.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + return uniq; + }); + } - RealDOMBounds.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + /** + A computed property which returns a new array with all the unique + elements from an array, with uniqueness determined by specific key. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + uniqueFruits: Ember.computed.uniqBy('fruits', 'id') + }); + let hamster = Hamster.create({ + fruits: [ + { id: 1, 'banana' }, + { id: 2, 'grape' }, + { id: 3, 'peach' }, + { id: 1, 'banana' } + ] + }); + hamster.get('uniqueFruits'); // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }] + ``` + + @method uniqBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ - return RealDOMBounds; - })(); + function uniqBy(dependentKey, propertyKey) { + return _emberMetal.computed(dependentKey + '.[]', function () { + var uniq = _emberRuntimeSystemNative_array.A(); + var seen = new _emberUtils.EmptyObject(); + var list = _emberMetal.get(this, dependentKey); + if (_emberRuntimeUtils.isArray(list)) { + list.forEach(function (item) { + var guid = _emberUtils.guidFor(_emberMetal.get(item, propertyKey)); + if (!(guid in seen)) { + seen[guid] = true; + uniq.push(item); + } + }); + } + return uniq; + }).readOnly(); + } - exports.RealDOMBounds = RealDOMBounds; + /** + Alias for [Ember.computed.uniq](/api/#method_computed_uniq). + + @method union + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ + var union = uniq; - var ConcreteBounds = (function () { - function ConcreteBounds(parentNode, first, last) { - this.parentNode = parentNode; - this.first = first; - this.last = last; - } + exports.union = union; + /** + A computed property which returns a new array with all the duplicated + elements from two or more dependent arrays. + + Example + + ```javascript + let obj = Ember.Object.extend({ + friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') + }).create({ + adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], + charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'] + }); + + obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] + ``` + + @method intersect + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + duplicated elements from the dependent arrays + @public + */ - ConcreteBounds.prototype.parentElement = function parentElement() { - return this.parentNode; - }; + function intersect() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - ConcreteBounds.prototype.firstNode = function firstNode() { - return this.first; - }; + return multiArrayMacro(args, function (dependentKeys) { + var _this3 = this; - ConcreteBounds.prototype.lastNode = function lastNode() { - return this.last; - }; + var arrays = dependentKeys.map(function (dependentKey) { + var array = _emberMetal.get(_this3, dependentKey); - return ConcreteBounds; - })(); + return _emberRuntimeUtils.isArray(array) ? array : []; + }); - exports.ConcreteBounds = ConcreteBounds; + var results = arrays.pop().filter(function (candidate) { + for (var i = 0; i < arrays.length; i++) { + var found = false; + var array = arrays[i]; + for (var j = 0; j < array.length; j++) { + if (array[j] === candidate) { + found = true; + break; + } + } - var SingleNodeBounds = (function () { - function SingleNodeBounds(parentNode, node) { - this.parentNode = parentNode; - this.node = node; + if (found === false) { + return false; + } } - SingleNodeBounds.prototype.parentElement = function parentElement() { - return this.parentNode; - }; + return true; + }); - SingleNodeBounds.prototype.firstNode = function firstNode() { - return this.node; - }; + return _emberRuntimeSystemNative_array.A(results); + }); + } - SingleNodeBounds.prototype.lastNode = function lastNode() { - return this.node; - }; + /** + A computed property which returns a new array with all the + properties from the first dependent array that are not in the second + dependent array. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + likes: ['banana', 'grape', 'kale'], + wants: Ember.computed.setDiff('likes', 'fruits') + }); + + let hamster = Hamster.create({ + fruits: [ + 'grape', + 'kale', + ] + }); + + hamster.get('wants'); // ['banana'] + ``` + + @method setDiff + @for Ember.computed + @param {String} setAProperty + @param {String} setBProperty + @return {Ember.ComputedProperty} computes a new array with all the + items from the first dependent array that are not in the second + dependent array + @public + */ - return SingleNodeBounds; - })(); + function setDiff(setAProperty, setBProperty) { + if (arguments.length !== 2) { + throw new _emberMetal.Error('setDiff requires exactly two dependent arrays.'); + } - exports.SingleNodeBounds = SingleNodeBounds; + return _emberMetal.computed(setAProperty + '.[]', setBProperty + '.[]', function () { + var setA = this.get(setAProperty); + var setB = this.get(setBProperty); - function bounds(parent, first, last) { - return new ConcreteBounds(parent, first, last); - } + if (!_emberRuntimeUtils.isArray(setA)) { + return _emberRuntimeSystemNative_array.A(); + } + if (!_emberRuntimeUtils.isArray(setB)) { + return _emberRuntimeSystemNative_array.A(setA); + } - function single(parent, node) { - return new SingleNodeBounds(parent, node); - } + return setA.filter(function (x) { + return setB.indexOf(x) === -1; + }); + }).readOnly(); + } - function move(bounds, reference) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var node = first; - while (node) { - var next = node.nextSibling; - parent.insertBefore(node, reference); - if (node === last) return next; - node = next; - } - return null; - } + /** + A computed property that returns the array of values + for the provided dependent properties. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + clothes: Ember.computed.collect('hat', 'shirt') + }); + + let hamster = Hamster.create(); + + hamster.get('clothes'); // [null, null] + hamster.set('hat', 'Camp Hat'); + hamster.set('shirt', 'Camp Shirt'); + hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] + ``` + + @method collect + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which maps + values of all passed in properties to an array. + @public + */ - function clear(bounds) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var node = first; - while (node) { - var next = node.nextSibling; - parent.removeChild(node); - if (node === last) return next; - node = next; - } - return null; + function collect() { + for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + dependentKeys[_key3] = arguments[_key3]; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvYm91bmRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O1FBVUEsTUFBQSxHQUNFLFNBREYsTUFBQSxDQUNxQixPQUF1QixFQUFTLFdBQXdCLEVBQUE7QUFBeEQsWUFBQSxDQUFBLE9BQU8sR0FBUCxPQUFPLENBQWdCO0FBQVMsWUFBQSxDQUFBLFdBQVcsR0FBWCxXQUFXLENBQWE7S0FBSTs7OztRQU9qRixhQUFBO0FBQ0UsaUJBREYsYUFBQSxDQUNzQixNQUFjLEVBQUE7QUFBZCxnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQVE7U0FBSTs7QUFEeEMscUJBQUEsV0FHRSxhQUFhLEdBQUEseUJBQUE7QUFBSyxtQkFBTyxJQUFJLENBQUMsTUFBTSxDQUFDLGFBQWEsRUFBYSxDQUFDO1NBQUU7O0FBSHBFLHFCQUFBLFdBSUUsU0FBUyxHQUFBLHFCQUFBO0FBQUssbUJBQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxTQUFTLEVBQVUsQ0FBQztTQUFFOztBQUp6RCxxQkFBQSxXQUtFLFFBQVEsR0FBQSxvQkFBQTtBQUFLLG1CQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsUUFBUSxFQUFVLENBQUM7U0FBRTs7ZUFMdkQsYUFBQTs7Ozs7UUFRQSxjQUFBO0FBQ0UsaUJBREYsY0FBQSxDQUNxQixVQUEwQixFQUFVLEtBQ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aW1wbGUuTm9kZSB7XG4gIGxldCBwYXJlbnQgPSBib3VuZHMucGFyZW50RWxlbWVudCgpO1xuICBsZXQgZmlyc3QgPSBib3VuZHMuZmlyc3ROb2RlKCk7XG4gIGxldCBsYXN0ID0gYm91bmRzLmxhc3ROb2RlKCk7XG5cbiAgbGV0IG5vZGUgPSBmaXJzdDtcblxuICB3aGlsZSAobm9kZSkge1xuICAgIGxldCBuZXh0ID0gbm9kZS5uZXh0U2libGluZztcbiAgICBwYXJlbnQucmVtb3ZlQ2hpbGQobm9kZSk7XG4gICAgaWYgKG5vZGUgPT09IGxhc3QpIHJldHVybiBuZXh0O1xuICAgIG5vZGUgPSBuZXh0O1xuICB9XG5cbiAgcmV0dXJuIG51bGw7XG59XG4iXX0= -enifed('glimmer-runtime/lib/builder', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-util', 'glimmer-runtime/lib/compiled/opcodes/dom'], function (exports, _glimmerRuntimeLibBounds, _glimmerUtil, _glimmerRuntimeLibCompiledOpcodesDom) { - 'use strict'; - var First = (function () { - function First(node) { - this.node = node; + return multiArrayMacro(dependentKeys, function () { + var properties = _emberMetal.getProperties(this, dependentKeys); + var res = _emberRuntimeSystemNative_array.A(); + for (var key in properties) { + if (properties.hasOwnProperty(key)) { + if (_emberMetal.isNone(properties[key])) { + res.push(null); + } else { + res.push(properties[key]); + } } + } + return res; + }); + } - First.prototype.firstNode = function firstNode() { - return this.node; - }; - - return First; - })(); - - var Last = (function () { - function Last(node) { - this.node = node; + /** + A computed property which returns a new array with all the + properties from the first dependent array sorted based on a property + or sort function. + + The callback method you provide should have the following signature: + + ```javascript + function(itemA, itemB); + ``` + + - `itemA` the first item to compare. + - `itemB` the second item to compare. + + This function should return negative number (e.g. `-1`) when `itemA` should come before + `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after + `itemB`. If the `itemA` and `itemB` are equal this function should return `0`. + + Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or + `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`. + + Example + + ```javascript + let ToDoList = Ember.Object.extend({ + // using standard ascending sort + todosSorting: ['name'], + sortedTodos: Ember.computed.sort('todos', 'todosSorting'), + + // using descending sort + todosSortingDesc: ['name:desc'], + sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), + + // using a custom sort function + priorityTodos: Ember.computed.sort('todos', function(a, b){ + if (a.priority > b.priority) { + return 1; + } else if (a.priority < b.priority) { + return -1; } + + return 0; + }) + }); + + let todoList = ToDoList.create({todos: [ + { name: 'Unit Test', priority: 2 }, + { name: 'Documentation', priority: 3 }, + { name: 'Release', priority: 1 } + ]}); + + todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }] + todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }] + todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }] + ``` + + @method sort + @for Ember.computed + @param {String} itemsKey + @param {String or Function} sortDefinition a dependent key to an + array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting + @return {Ember.ComputedProperty} computes a new sorted array based + on the sort property array or callback function + @public + */ - Last.prototype.lastNode = function lastNode() { - return this.node; - }; + function sort(itemsKey, sortDefinition) { + _emberMetal.assert('Ember.computed.sort requires two arguments: an array key to sort and ' + 'either a sort properties key or sort function', arguments.length === 2); - return Last; - })(); + if (typeof sortDefinition === 'function') { + return customSort(itemsKey, sortDefinition); + } else { + return propertySort(itemsKey, sortDefinition); + } + } - var Fragment = (function () { - function Fragment(bounds) { - this.bounds = bounds; - } + function customSort(itemsKey, comparator) { + return arrayMacro(itemsKey, function (value) { + var _this4 = this; - Fragment.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + return value.slice().sort(function (x, y) { + return comparator.call(_this4, x, y); + }); + }); + } - Fragment.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + // This one needs to dynamically set up and tear down observers on the itemsKey + // depending on the sortProperties + function propertySort(itemsKey, sortPropertiesKey) { + var cp = new _emberMetal.ComputedProperty(function (key) { + var _this5 = this; - Fragment.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + var itemsKeyIsAtThis = itemsKey === '@this'; + var sortProperties = _emberMetal.get(this, sortPropertiesKey); - Fragment.prototype.update = function update(bounds) { - this.bounds = bounds; - }; + _emberMetal.assert('The sort definition for \'' + key + '\' on ' + this + ' must be a function or an array of strings', _emberRuntimeUtils.isArray(sortProperties) && sortProperties.every(function (s) { + return typeof s === 'string'; + })); - return Fragment; - })(); + var normalizedSortProperties = normalizeSortProperties(sortProperties); - exports.Fragment = Fragment; - - var ElementStack = (function () { - function ElementStack(env, parentNode, nextSibling) { - this.constructing = null; - this.operations = null; - this.elementStack = new _glimmerUtil.Stack(); - this.nextSiblingStack = new _glimmerUtil.Stack(); - this.blockStack = new _glimmerUtil.Stack(); - this.env = env; - this.dom = env.getAppendOperations(); - this.updateOperations = env.getDOM(); - this.element = parentNode; - this.nextSibling = nextSibling; - this.defaultOperations = new _glimmerRuntimeLibCompiledOpcodesDom.SimpleElementOperations(env); - this.elementStack.push(this.element); - this.nextSiblingStack.push(this.nextSibling); - } - - ElementStack.forInitialRender = function forInitialRender(env, parentNode, nextSibling) { - return new ElementStack(env, parentNode, nextSibling); - }; + // Add/remove property observers as required. + var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetal.WeakMap()); + var activeObservers = activeObserversMap.get(this); - ElementStack.resume = function resume(env, tracker, nextSibling) { - var parentNode = tracker.parentElement(); - var stack = new ElementStack(env, parentNode, nextSibling); - stack.pushBlockTracker(tracker); - return stack; - }; + if (activeObservers) { + activeObservers.forEach(function (args) { + return _emberMetal.removeObserver.apply(undefined, args); + }); + } - ElementStack.prototype.block = function block() { - return this.blockStack.current; - }; + function sortPropertyDidChange() { + this.notifyPropertyChange(key); + } - ElementStack.prototype.popElement = function popElement() { - var elementStack = this.elementStack; - var nextSiblingStack = this.nextSiblingStack; + activeObservers = normalizedSortProperties.map(function (_ref) { + var prop = _ref[0]; - var topElement = elementStack.pop(); - nextSiblingStack.pop(); - this.element = elementStack.current; - this.nextSibling = nextSiblingStack.current; - return topElement; - }; + var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; + var args = [_this5, path, sortPropertyDidChange]; + _emberMetal.addObserver.apply(undefined, args); + return args; + }); - ElementStack.prototype.pushSimpleBlock = function pushSimpleBlock() { - var tracker = new SimpleBlockTracker(this.element); - this.pushBlockTracker(tracker); - return tracker; - }; + activeObserversMap.set(this, activeObservers); - ElementStack.prototype.pushUpdatableBlock = function pushUpdatableBlock() { - var tracker = new UpdatableBlockTracker(this.element); - this.pushBlockTracker(tracker); - return tracker; - }; + // Sort and return the array. + var items = itemsKeyIsAtThis ? this : _emberMetal.get(this, itemsKey); - ElementStack.prototype.pushBlockTracker = function pushBlockTracker(tracker) { - var isRemote = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + if (_emberRuntimeUtils.isArray(items)) { + return sortByNormalizedSortProperties(items, normalizedSortProperties); + } else { + return _emberRuntimeSystemNative_array.A(); + } + }); - var current = this.blockStack.current; - if (current !== null) { - current.newDestroyable(tracker); - if (!isRemote) { - current.newBounds(tracker); - } - } - this.blockStack.push(tracker); - return tracker; - }; + cp._activeObserverMap = undefined; - ElementStack.prototype.pushBlockList = function pushBlockList(list) { - var tracker = new BlockListTracker(this.element, list); - var current = this.blockStack.current; - if (current !== null) { - current.newDestroyable(tracker); - current.newBounds(tracker); - } - this.blockStack.push(tracker); - return tracker; - }; + return cp.property(sortPropertiesKey + '.[]').readOnly(); + } - ElementStack.prototype.popBlock = function popBlock() { - this.blockStack.current.finalize(this); - return this.blockStack.pop(); - }; + function normalizeSortProperties(sortProperties) { + return sortProperties.map(function (p) { + var _p$split = p.split(':'); - ElementStack.prototype.openElement = function openElement(tag) { - var operations = arguments.length <= 1 || arguments[1] === undefined ? this.defaultOperations : arguments[1]; + var prop = _p$split[0]; + var direction = _p$split[1]; - var element = this.dom.createElement(tag, this.element); - this.constructing = element; - this.operations = operations; - return element; - }; + direction = direction || 'asc'; - ElementStack.prototype.flushElement = function flushElement() { - var parent = this.element; - var element = this.constructing; - this.dom.insertBefore(parent, element, this.nextSibling); - this.constructing = null; - this.operations = null; - this.pushElement(element); - this.blockStack.current.openElement(element); - }; + return [prop, direction]; + }); + } - ElementStack.prototype.pushRemoteElement = function pushRemoteElement(element) { - this.pushElement(element); - var tracker = new RemoteBlockTracker(element); - this.pushBlockTracker(tracker, true); - }; + 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]; - ElementStack.prototype.popRemoteElement = function popRemoteElement() { - this.popBlock(); - this.popElement(); - }; + var result = _emberRuntimeCompare.default(_emberMetal.get(itemA, prop), _emberMetal.get(itemB, prop)); + if (result !== 0) { + return direction === 'desc' ? -1 * result : result; + } + } - ElementStack.prototype.pushElement = function pushElement(element) { - this.element = element; - this.elementStack.push(element); - this.nextSibling = null; - this.nextSiblingStack.push(null); - }; + return 0; + })); + } +}); +enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) { + 'use strict'; - ElementStack.prototype.newDestroyable = function newDestroyable(d) { - this.blockStack.current.newDestroyable(d); - }; + /** + @module ember + @submodule ember-runtime + */ - ElementStack.prototype.newBounds = function newBounds(bounds) { - this.blockStack.current.newBounds(bounds); - }; + /** + @class Controller + @namespace Ember + @extends Ember.Object + @uses Ember.ControllerMixin + @public + */ + var Controller = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsController.default); - ElementStack.prototype.appendText = function appendText(string) { - var dom = this.dom; + _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions(Controller); - var text = dom.createTextNode(string); - dom.insertBefore(this.element, text, this.nextSibling); - this.blockStack.current.newNode(text); - return text; - }; + function controllerInjectionHelper(factory) { + _emberMetal.assert('Defining an injected controller property on a ' + 'non-controller is not allowed.', _emberRuntimeMixinsController.default.detect(factory.PrototypeMixin)); + } - ElementStack.prototype.appendComment = function appendComment(string) { - var dom = this.dom; + /** + Creates a property that lazily looks up another controller in the container. + Can only be used when defining another controller. + + Example: + + ```javascript + App.PostController = Ember.Controller.extend({ + posts: Ember.inject.controller() + }); + ``` + + This example will create a `posts` property on the `post` controller that + looks up the `posts` controller in the container, making it easy to + reference other controllers. This is functionally equivalent to: + + ```javascript + App.PostController = Ember.Controller.extend({ + needs: 'posts', + posts: Ember.computed.alias('controllers.posts') + }); + ``` + + @method controller + @since 1.10.0 + @for Ember.inject + @param {String} name (optional) name of the controller to inject, defaults + to the property's name + @return {Ember.InjectedProperty} injection descriptor instance + @public + */ + _emberRuntimeInject.createInjectionHelper('controller', controllerInjectionHelper); - var comment = dom.createComment(string); - dom.insertBefore(this.element, comment, this.nextSibling); - this.blockStack.current.newNode(comment); - return comment; - }; + exports.default = Controller; +}); +enifed('ember-runtime/copy', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) { + 'use strict'; - ElementStack.prototype.setStaticAttribute = function setStaticAttribute(name, value) { - this.operations.addStaticAttribute(this.constructing, name, value); - }; + exports.default = copy; - ElementStack.prototype.setStaticAttributeNS = function setStaticAttributeNS(namespace, name, value) { - this.operations.addStaticAttributeNS(this.constructing, namespace, name, value); - }; + function _copy(obj, deep, seen, copies) { + var ret = undefined, + loc = undefined, + key = undefined; - ElementStack.prototype.setDynamicAttribute = function setDynamicAttribute(name, reference, isTrusting) { - this.operations.addDynamicAttribute(this.constructing, name, reference, isTrusting); - }; + // primitive data types are immutable, just return them. + if (typeof obj !== 'object' || obj === null) { + return obj; + } - ElementStack.prototype.setDynamicAttributeNS = function setDynamicAttributeNS(namespace, name, reference, isTrusting) { - this.operations.addDynamicAttributeNS(this.constructing, namespace, name, reference, isTrusting); - }; + // avoid cyclical loops + if (deep && (loc = seen.indexOf(obj)) >= 0) { + return copies[loc]; + } - ElementStack.prototype.closeElement = function closeElement() { - this.blockStack.current.closeElement(); - this.popElement(); - }; + _emberMetal.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof _emberRuntimeSystemObject.default) || _emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)); - return ElementStack; - })(); + // IMPORTANT: this specific test will detect a native array only. Any other + // object will need to implement Copyable. + if (Array.isArray(obj)) { + ret = obj.slice(); - exports.ElementStack = ElementStack; + if (deep) { + loc = ret.length; - var SimpleBlockTracker = (function () { - function SimpleBlockTracker(parent) { - this.parent = parent; - this.first = null; - this.last = null; - this.destroyables = null; - this.nesting = 0; + while (--loc >= 0) { + ret[loc] = _copy(ret[loc], deep, seen, copies); } + } + } else if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { + ret = obj.copy(deep, seen, copies); + } else if (obj instanceof Date) { + ret = new Date(obj.getTime()); + } else { + ret = {}; - SimpleBlockTracker.prototype.destroy = function destroy() { - var destroyables = this.destroyables; + for (key in obj) { + // support Null prototype + if (!Object.prototype.hasOwnProperty.call(obj, key)) { + continue; + } - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - destroyables[i].destroy(); - } - } - }; + // Prevents browsers that don't respect non-enumerability from + // copying internal Ember properties + if (key.substring(0, 2) === '__') { + continue; + } - SimpleBlockTracker.prototype.parentElement = function parentElement() { - return this.parent; - }; + ret[key] = deep ? _copy(obj[key], deep, seen, copies) : obj[key]; + } + } - SimpleBlockTracker.prototype.firstNode = function firstNode() { - return this.first && this.first.firstNode(); - }; + if (deep) { + seen.push(obj); + copies.push(ret); + } - SimpleBlockTracker.prototype.lastNode = function lastNode() { - return this.last && this.last.lastNode(); - }; + return ret; + } - SimpleBlockTracker.prototype.openElement = function openElement(element) { - this.newNode(element); - this.nesting++; - }; + /** + Creates a shallow copy of the passed object. A deep copy of the object is + returned if the optional `deep` argument is `true`. + + If the passed object implements the `Ember.Copyable` interface, then this + function will delegate to the object's `copy()` method and return the + result. See `Ember.Copyable` for further details. + + For primitive values (which are immutable in JavaScript), the passed object + is simply returned. + + @method copy + @for Ember + @param {Object} obj The object to clone + @param {Boolean} [deep=false] If true, a deep copy of the object is made. + @return {Object} The copied object + @public + */ - SimpleBlockTracker.prototype.closeElement = function closeElement() { - this.nesting--; - }; + function copy(obj, deep) { + // fast paths + if ('object' !== typeof obj || obj === null) { + return obj; // can't copy primitives + } - SimpleBlockTracker.prototype.newNode = function newNode(node) { - if (this.nesting !== 0) return; - if (!this.first) { - this.first = new First(node); - } - this.last = new Last(node); - }; + if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { + return obj.copy(deep); + } - SimpleBlockTracker.prototype.newBounds = function newBounds(bounds) { - if (this.nesting !== 0) return; - if (!this.first) { - this.first = bounds; - } - this.last = bounds; - }; + return _copy(obj, deep, deep ? [] : null, deep ? [] : null); + } +}); +enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - SimpleBlockTracker.prototype.newDestroyable = function newDestroyable(d) { - this.destroyables = this.destroyables || []; - this.destroyables.push(d); - }; + 'use strict'; - SimpleBlockTracker.prototype.finalize = function finalize(stack) { - if (!this.first) { - stack.appendComment(''); - } - }; + var a_slice = Array.prototype.slice; + var FunctionPrototype = Function.prototype; - return SimpleBlockTracker; - })(); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + /** + The `property` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + `true`, which is the default. + Computed properties allow you to treat a function like a property: + ```javascript + MyApp.President = Ember.Object.extend({ + firstName: '', + lastName: '', + fullName: function() { + return this.get('firstName') + ' ' + this.get('lastName'); + }.property() // Call this flag to mark the function as a property + }); + let president = MyApp.President.create({ + firstName: 'Barack', + lastName: 'Obama' + }); + president.get('fullName'); // 'Barack Obama' + ``` + Treating a function like a property is useful because they can work with + bindings, just like any other property. + Many computed properties have dependencies on other properties. For + example, in the above example, the `fullName` property depends on + `firstName` and `lastName` to determine its value. You can tell Ember + about these dependencies like this: + ```javascript + MyApp.President = Ember.Object.extend({ + firstName: '', + lastName: '', + fullName: function() { + return this.get('firstName') + ' ' + this.get('lastName'); + // Tell Ember.js that this computed property depends on firstName + // and lastName + }.property('firstName', 'lastName') + }); + ``` + Make sure you list these dependencies so Ember knows when to update + bindings that connect to a computed property. Changing a dependency + will not immediately trigger an update of the computed property, but + will instead clear the cache so that it is updated when the next `get` + is called on the property. + See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/classes/Ember.computed.html). + @method property + @for Function + @public + */ + FunctionPrototype.property = function () { + var ret = _emberMetal.computed(this); + // ComputedProperty.prototype.property expands properties; no need for us to + // do so here. + return ret.property.apply(ret, arguments); + }; - exports.SimpleBlockTracker = SimpleBlockTracker; + /** + The `observes` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + true, which is the default. + You can observe property changes simply by adding the `observes` + call to the end of your method declarations in classes that you write. + For example: + ```javascript + Ember.Object.extend({ + valueObserver: function() { + // Executes whenever the "value" property changes + }.observes('value') + }); + ``` + In the future this method may become asynchronous. + See `Ember.observer`. + @method observes + @for Function + @public + */ + FunctionPrototype.observes = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - var RemoteBlockTracker = (function (_SimpleBlockTracker) { - babelHelpers.inherits(RemoteBlockTracker, _SimpleBlockTracker); + args.push(this); + return _emberMetal.observer.apply(this, args); + }; - function RemoteBlockTracker() { - _SimpleBlockTracker.apply(this, arguments); + FunctionPrototype._observesImmediately = function () { + _emberMetal.assert('Immediate observers must observe internal properties only, ' + 'not properties on other objects.', function checkIsInternalProperty() { + for (var i = 0; i < arguments.length; i++) { + if (arguments[i].indexOf('.') !== -1) { + return false; + } } + return true; + }); - RemoteBlockTracker.prototype.destroy = function destroy() { - _SimpleBlockTracker.prototype.destroy.call(this); - _glimmerRuntimeLibBounds.clear(this); - }; + // observes handles property expansion + return this.observes.apply(this, arguments); + }; + /** + The `observesImmediately` extension of Javascript's Function prototype is + available when `EmberENV.EXTEND_PROTOTYPES` or + `EmberENV.EXTEND_PROTOTYPES.Function` is true, which is the default. + You can observe property changes simply by adding the `observesImmediately` + call to the end of your method declarations in classes that you write. + For example: + ```javascript + Ember.Object.extend({ + valueObserver: function() { + // Executes immediately after the "value" property changes + }.observesImmediately('value') + }); + ``` + In the future, `observes` may become asynchronous. In this event, + `observesImmediately` will maintain the synchronous behavior. + See `Ember.immediateObserver`. + @method observesImmediately + @for Function + @deprecated + @private + */ + FunctionPrototype.observesImmediately = _emberMetal.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately); - return RemoteBlockTracker; - })(SimpleBlockTracker); + /** + The `on` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + true, which is the default. + You can listen for events simply by adding the `on` call to the end of + your method declarations in classes or mixins that you write. For example: + ```javascript + Ember.Mixin.create({ + doSomethingWithElement: function() { + // Executes whenever the "didInsertElement" event fires + }.on('didInsertElement') + }); + ``` + See `Ember.on`. + @method on + @for Function + @public + */ + FunctionPrototype.on = function () { + var events = a_slice.call(arguments); + this.__ember_listens__ = events; - var UpdatableBlockTracker = (function (_SimpleBlockTracker2) { - babelHelpers.inherits(UpdatableBlockTracker, _SimpleBlockTracker2); + return this; + }; + } +}); +enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal'], function (exports, _rsvp, _emberMetal) { + 'use strict'; - function UpdatableBlockTracker() { - _SimpleBlockTracker2.apply(this, arguments); - } + exports.onerrorDefault = onerrorDefault; - UpdatableBlockTracker.prototype.reset = function reset(env) { - var destroyables = this.destroyables; + var backburner = _emberMetal.run.backburner; + _emberMetal.run._addQueue('rsvpAfter', 'destroy'); - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - env.didDestroy(destroyables[i]); - } - } - var nextSibling = _glimmerRuntimeLibBounds.clear(this); - this.destroyables = null; - this.first = null; - this.last = null; - return nextSibling; - }; + _rsvp.configure('async', function (callback, promise) { + backburner.schedule('actions', null, callback, promise); + }); - return UpdatableBlockTracker; - })(SimpleBlockTracker); + _rsvp.configure('after', function (cb) { + backburner.schedule('rsvpAfter', null, cb); + }); - exports.UpdatableBlockTracker = UpdatableBlockTracker; + _rsvp.on('error', onerrorDefault); - var BlockListTracker = (function () { - function BlockListTracker(parent, boundList) { - this.parent = parent; - this.boundList = boundList; - this.parent = parent; - this.boundList = boundList; - } + function onerrorDefault(reason) { + var error = errorFor(reason); + if (error) { + _emberMetal.dispatchError(error); + } + } - BlockListTracker.prototype.destroy = function destroy() { - this.boundList.forEachNode(function (node) { - return node.destroy(); - }); - }; + function errorFor(reason) { + if (!reason) return; - BlockListTracker.prototype.parentElement = function parentElement() { - return this.parent; - }; + if (reason.errorThrown) { + return unwrapErrorThrown(reason); + } - BlockListTracker.prototype.firstNode = function firstNode() { - return this.boundList.head().firstNode(); - }; + if (reason.name === 'UnrecognizedURLError') { + _emberMetal.assert('The URL \'' + reason.message + '\' did not match any routes in your application', false); + return; + } - BlockListTracker.prototype.lastNode = function lastNode() { - return this.boundList.tail().lastNode(); - }; + if (reason.name === 'TransitionAborted') { + return; + } - BlockListTracker.prototype.openElement = function openElement(element) { - _glimmerUtil.assert(false, 'Cannot openElement directly inside a block list'); - }; + return reason; + } - BlockListTracker.prototype.closeElement = function closeElement() { - _glimmerUtil.assert(false, 'Cannot closeElement directly inside a block list'); - }; + function unwrapErrorThrown(reason) { + var error = reason.errorThrown; + if (typeof error === 'string') { + error = new Error(error); + } + Object.defineProperty(error, '__reason_with_error_thrown__', { + value: reason, + enumerable: false + }); + return error; + } - BlockListTracker.prototype.newNode = function newNode(node) { - _glimmerUtil.assert(false, 'Cannot create a new node directly inside a block list'); - }; + exports.default = _rsvp; +}); +enifed('ember-runtime/ext/string', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + /** + @module ember + @submodule ember-runtime + */ - BlockListTracker.prototype.newBounds = function newBounds(bounds) {}; + 'use strict'; - BlockListTracker.prototype.newDestroyable = function newDestroyable(d) {}; + var StringPrototype = String.prototype; - BlockListTracker.prototype.finalize = function finalize(stack) {}; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + /** + See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt). + @method fmt + @for String + @private + @deprecated + */ + StringPrototype.fmt = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - return BlockListTracker; - })(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvYnVpbGRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUE0QkEsS0FBQTtBQUNFLGlCQURGLEtBQUEsQ0FDc0IsSUFBVSxFQUFBO0FBQVYsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFNO1N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m5vdCBjbG9zZUVsZW1lbnQgZGlyZWN0bHkgaW5zaWRlIGEgYmxvY2sgbGlzdCcpO1xuICB9XG5cbiAgbmV3Tm9kZShub2RlOiBOb2RlKSB7XG4gICAgYXNzZXJ0KGZhbHNlLCAnQ2Fubm90IGNyZWF0ZSBhIG5ldyBub2RlIGRpcmVjdGx5IGluc2lkZSBhIGJsb2NrIGxpc3QnKTtcbiAgfVxuXG4gIG5ld0JvdW5kcyhib3VuZHM6IEJvdW5kcykge1xuICB9XG5cbiAgbmV3RGVzdHJveWFibGUoZDogRGVzdHJveWFibGUpIHtcbiAgfVxuXG4gIGZpbmFsaXplKHN0YWNrOiBFbGVtZW50U3RhY2spIHtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compat/inner-html-fix', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/dom/helper'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibDomHelper) { - 'use strict'; + return _emberRuntimeSystemString.fmt(this, args); + }; - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; - - var innerHTMLWrapper = { - colgroup: { depth: 2, before: '', after: '
    ' }, - table: { depth: 1, before: '', after: '
    ' }, - tbody: { depth: 2, before: '', after: '
    ' }, - tfoot: { depth: 2, before: '', after: '
    ' }, - thead: { depth: 2, before: '', after: '
    ' }, - tr: { depth: 3, before: '', after: '
    ' } - }; - // Patch: innerHTML Fix - // Browsers: IE9 - // Reason: IE9 don't allow us to set innerHTML on col, colgroup, frameset, - // html, style, table, tbody, tfoot, thead, title, tr. - // Fix: Wrap the innerHTML we are about to set in its parents, apply the - // wrapped innerHTML on a div, then move the unwrapped nodes into the - // target position. - - function domChanges(document, DOMChangesClass) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document)) { - return DOMChangesClass; - } - var div = document.createElement('div'); - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithInnerHTMLFix, _DOMChangesClass); - - function DOMChangesWithInnerHTMLFix() { - _DOMChangesClass.apply(this, arguments); - } + /** + See [Ember.String.w](/api/classes/Ember.String.html#method_w). + @method w + @for String + @private + */ + StringPrototype.w = function () { + return _emberRuntimeSystemString.w(this); + }; - DOMChangesWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null || html === '') { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - var parentTag = parent.tagName.toLowerCase(); - var wrapper = innerHTMLWrapper[parentTag]; - if (wrapper === undefined) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - return fixInnerHTML(parent, wrapper, div, html, nextSibling); - }; + /** + See [Ember.String.loc](/api/classes/Ember.String.html#method_loc). + @method loc + @for String + @private + */ + StringPrototype.loc = function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - return DOMChangesWithInnerHTMLFix; - })(DOMChangesClass); - } + return _emberRuntimeSystemString.loc(this, args); + }; - function treeConstruction(document, DOMTreeConstructionClass) { - if (!document) return DOMTreeConstructionClass; - if (!shouldApplyFix(document)) { - return DOMTreeConstructionClass; - } - var div = document.createElement('div'); - return (function (_DOMTreeConstructionClass) { - babelHelpers.inherits(DOMTreeConstructionWithInnerHTMLFix, _DOMTreeConstructionClass); + /** + See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize). + @method camelize + @for String + @private + */ + StringPrototype.camelize = function () { + return _emberRuntimeSystemString.camelize(this); + }; - function DOMTreeConstructionWithInnerHTMLFix() { - _DOMTreeConstructionClass.apply(this, arguments); - } + /** + See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize). + @method decamelize + @for String + @private + */ + StringPrototype.decamelize = function () { + return _emberRuntimeSystemString.decamelize(this); + }; - DOMTreeConstructionWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null || html === '') { - return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - var parentTag = parent.tagName.toLowerCase(); - var wrapper = innerHTMLWrapper[parentTag]; - if (wrapper === undefined) { - return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - return fixInnerHTML(parent, wrapper, div, html, reference); - }; + /** + See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize). + @method dasherize + @for String + @private + */ + StringPrototype.dasherize = function () { + return _emberRuntimeSystemString.dasherize(this); + }; - return DOMTreeConstructionWithInnerHTMLFix; - })(DOMTreeConstructionClass); - } + /** + See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore). + @method underscore + @for String + @private + */ + StringPrototype.underscore = function () { + return _emberRuntimeSystemString.underscore(this); + }; - function fixInnerHTML(parent, wrapper, div, html, reference) { - var wrappedHtml = wrapper.before + html + wrapper.after; - div.innerHTML = wrappedHtml; - var parentNode = div; - for (var i = 0; i < wrapper.depth; i++) { - parentNode = parentNode.childNodes[0]; - } + /** + See [Ember.String.classify](/api/classes/Ember.String.html#method_classify). + @method classify + @for String + @private + */ + StringPrototype.classify = function () { + return _emberRuntimeSystemString.classify(this); + }; - var _moveNodesBefore = _glimmerRuntimeLibDomHelper.moveNodesBefore(parentNode, parent, reference); + /** + See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize). + @method capitalize + @for String + @private + */ + StringPrototype.capitalize = function () { + return _emberRuntimeSystemString.capitalize(this); + }; + } +}); +enifed('ember-runtime/index', ['exports', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/system/object', 'ember-runtime/system/string', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/compare', 'ember-runtime/is-equal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/system/namespace', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeSystemObject, _emberRuntimeSystemString, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeCompare, _emberRuntimeIsEqual, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeSystemNamespace, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsObservable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeUtils, _emberRuntimeString_registry) { + /** + @module ember + @submodule ember-runtime + */ - var first = _moveNodesBefore[0]; - var last = _moveNodesBefore[1]; + 'use strict'; - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - function shouldApplyFix(document) { - var table = document.createElement('table'); - try { - table.innerHTML = ''; - } catch (e) {} finally { - if (table.childNodes.length !== 0) { - // It worked as expected, no fix required - return false; - } - } - return true; - } + exports.Object = _emberRuntimeSystemObject.default; + exports.FrameworkObject = _emberRuntimeSystemObject.FrameworkObject; + exports.String = _emberRuntimeSystemString.default; + exports.RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default; + exports.buildFakeRegistryWithDeprecations = _emberRuntimeMixinsRegistry_proxy.buildFakeRegistryWithDeprecations; + exports.ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default; + exports.copy = _emberRuntimeCopy.default; + exports.inject = _emberRuntimeInject.default; + exports.compare = _emberRuntimeCompare.default; + exports.isEqual = _emberRuntimeIsEqual.default; + exports.Array = _emberRuntimeMixinsArray.default; + exports.objectAt = _emberRuntimeMixinsArray.objectAt; + exports.isEmberArray = _emberRuntimeMixinsArray.isEmberArray; + exports.addArrayObserver = _emberRuntimeMixinsArray.addArrayObserver; + exports.removeArrayObserver = _emberRuntimeMixinsArray.removeArrayObserver; + exports.Comparable = _emberRuntimeMixinsComparable.default; + exports.Namespace = _emberRuntimeSystemNamespace.default; + exports.isNamespaceSearchDisabled = _emberRuntimeSystemNamespace.isSearchDisabled; + exports.setNamespaceSearchDisabled = _emberRuntimeSystemNamespace.setSearchDisabled; + exports.ArrayProxy = _emberRuntimeSystemArray_proxy.default; + exports.ObjectProxy = _emberRuntimeSystemObject_proxy.default; + exports.CoreObject = _emberRuntimeSystemCore_object.default; + exports.NativeArray = _emberRuntimeSystemNative_array.default; + exports.A = _emberRuntimeSystemNative_array.A; + exports.ActionHandler = _emberRuntimeMixinsAction_handler.default; + exports.deprecateUnderscoreActions = _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions; + exports.Copyable = _emberRuntimeMixinsCopyable.default; + exports.Enumerable = _emberRuntimeMixinsEnumerable.default; + exports.Freezable = _emberRuntimeMixinsFreezable.Freezable; + exports.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR; + exports._ProxyMixin = _emberRuntimeMixinsProxy.default; + exports.onLoad = _emberRuntimeSystemLazy_load.onLoad; + exports.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks; + exports._loaded = _emberRuntimeSystemLazy_load._loaded; + exports.Observable = _emberRuntimeMixinsObservable.default; + exports.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default; + exports.MutableArray = _emberRuntimeMixinsMutable_array.default; + exports.removeAt = _emberRuntimeMixinsMutable_array.removeAt; + exports.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default; + exports.Evented = _emberRuntimeMixinsEvented.default; + exports.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default; + exports.empty = _emberRuntimeComputedComputed_macros.empty; + exports.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty; + exports.none = _emberRuntimeComputedComputed_macros.none; + exports.not = _emberRuntimeComputedComputed_macros.not; + exports.bool = _emberRuntimeComputedComputed_macros.bool; + exports.match = _emberRuntimeComputedComputed_macros.match; + exports.equal = _emberRuntimeComputedComputed_macros.equal; + exports.gt = _emberRuntimeComputedComputed_macros.gt; + exports.gte = _emberRuntimeComputedComputed_macros.gte; + exports.lt = _emberRuntimeComputedComputed_macros.lt; + exports.lte = _emberRuntimeComputedComputed_macros.lte; + exports.oneWay = _emberRuntimeComputedComputed_macros.oneWay; + exports.readOnly = _emberRuntimeComputedComputed_macros.readOnly; + exports.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias; + exports.and = _emberRuntimeComputedComputed_macros.and; + exports.or = _emberRuntimeComputedComputed_macros.or; + exports.sum = _emberRuntimeComputedReduce_computed_macros.sum; + exports.min = _emberRuntimeComputedReduce_computed_macros.min; + exports.max = _emberRuntimeComputedReduce_computed_macros.max; + exports.map = _emberRuntimeComputedReduce_computed_macros.map; + exports.sort = _emberRuntimeComputedReduce_computed_macros.sort; + exports.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff; + exports.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy; + exports.filter = _emberRuntimeComputedReduce_computed_macros.filter; + exports.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy; + exports.uniq = _emberRuntimeComputedReduce_computed_macros.uniq; + exports.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy; + exports.union = _emberRuntimeComputedReduce_computed_macros.union; + exports.intersect = _emberRuntimeComputedReduce_computed_macros.intersect; + exports.collect = _emberRuntimeComputedReduce_computed_macros.collect; + exports.Controller = _emberRuntimeControllersController.default; + exports.ControllerMixin = _emberRuntimeMixinsController.default; + exports.Service = _emberRuntimeSystemService.default; + exports.RSVP = _emberRuntimeExtRsvp.default; + exports.onerrorDefault = _emberRuntimeExtRsvp.onerrorDefault; + // just for side effect of extending Ember.RSVP + exports.isArray = _emberRuntimeUtils.isArray; + exports.typeOf = _emberRuntimeUtils.typeOf; + exports.getStrings = _emberRuntimeString_registry.getStrings; + exports.setStrings = _emberRuntimeString_registry.setStrings; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L2lubmVyLWh0bWwtZml4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQVNBLFFBQUksZ0JBQWdCLEdBQUc7QUFDckIsZ0JBQVEsRUFBRSxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsTUFBTSxFQUFFLG1CQUFtQixFQUFFLEtBQUssRUFBRSxxQkFBcUIsRUFBRTtBQUNqRixhQUFLLEVBQUssRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFFLFVBQVUsRUFBRTtBQUM1RCxhQUFLLEVBQUssRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxnQkFBZ0IsRUFBRSxLQUFLLEVBQUU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UTUxFbGVtZW50LCBodG1sOiBzdHJpbmcsIHJlZmVyZW5jZTogTm9kZSk6IEJvdW5kcyB7XG4gIGxldCB3cmFwcGVkSHRtbCA9IHdyYXBwZXIuYmVmb3JlICsgaHRtbCArIHdyYXBwZXIuYWZ0ZXI7XG5cbiAgZGl2LmlubmVySFRNTCA9IHdyYXBwZWRIdG1sO1xuXG4gIGxldCBwYXJlbnROb2RlOiBOb2RlID0gZGl2O1xuXG4gIGZvciAobGV0IGk9MDsgaTx3cmFwcGVyLmRlcHRoOyBpKyspIHtcbiAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5jaGlsZE5vZGVzWzBdO1xuICB9XG5cbiAgbGV0IFtmaXJzdCwgbGFzdF0gPSBtb3ZlTm9kZXNCZWZvcmUocGFyZW50Tm9kZSwgcGFyZW50LCByZWZlcmVuY2UpO1xuICByZXR1cm4gbmV3IENvbmNyZXRlQm91bmRzKHBhcmVudCwgZmlyc3QsIGxhc3QpO1xufVxuXG5mdW5jdGlvbiBzaG91bGRBcHBseUZpeChkb2N1bWVudCkge1xuICBsZXQgdGFibGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCd0YWJsZScpO1xuICB0cnkge1xuICAgIHRhYmxlLmlubmVySFRNTCA9ICc8dGJvZHk+PC90Ym9keT4nO1xuICB9IGNhdGNoIChlKSB7XG4gIH0gZmluYWxseSB7XG4gICAgaWYgKHRhYmxlLmNoaWxkTm9kZXMubGVuZ3RoICE9PSAwKSB7XG4gICAgICAvLyBJdCB3b3JrZWQgYXMgZXhwZWN0ZWQsIG5vIGZpeCByZXF1aXJlZFxuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgfVxuXG4gIHJldHVybiB0cnVlO1xufVxuIl19 -enifed('glimmer-runtime/lib/compat/svg-inner-html-fix', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/dom/helper'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibDomHelper) { - 'use strict'; - - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; - - var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - // Patch: insertAdjacentHTML on SVG Fix - // Browsers: Safari, IE, Edge, Firefox ~33-34 - // Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is - // present but throws an exception on IE and Edge. Old versions of - // Firefox create nodes in the incorrect namespace. - // Fix: Since IE and Edge silently fail to create SVG nodes using - // innerHTML, and because Firefox may create nodes in the incorrect - // namespace using innerHTML on SVG elements, an HTML-string wrapping - // approach is used. A pre/post SVG tag is added to the string, then - // that whole string is added to a div. The created nodes are plucked - // out and applied to the target location on DOM. - - function domChanges(document, DOMChangesClass, svgNamespace) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document, svgNamespace)) { - return DOMChangesClass; - } - var div = document.createElement('div'); - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithSVGInnerHTMLFix, _DOMChangesClass); - - function DOMChangesWithSVGInnerHTMLFix() { - _DOMChangesClass.apply(this, arguments); - } +// just for side effect of extending String.prototype +// just for side effect of extending Function.prototype +enifed('ember-runtime/inject', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - DOMChangesWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null || html === '') { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - if (parent.namespaceURI !== svgNamespace) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - return fixSVG(parent, div, html, nextSibling); - }; + exports.default = inject; + exports.createInjectionHelper = createInjectionHelper; + exports.validatePropertyInjections = validatePropertyInjections; - return DOMChangesWithSVGInnerHTMLFix; - })(DOMChangesClass); - } + /** + Namespace for injection helper methods. + + @class inject + @namespace Ember + @static + @public + */ - function treeConstruction(document, TreeConstructionClass, svgNamespace) { - if (!document) return TreeConstructionClass; - if (!shouldApplyFix(document, svgNamespace)) { - return TreeConstructionClass; - } - var div = document.createElement('div'); - return (function (_TreeConstructionClass) { - babelHelpers.inherits(TreeConstructionWithSVGInnerHTMLFix, _TreeConstructionClass); + function inject() { + _emberMetal.assert('Injected properties must be created through helpers, see \'' + Object.keys(inject).join('"', '"') + '\''); + } - function TreeConstructionWithSVGInnerHTMLFix() { - _TreeConstructionClass.apply(this, arguments); - } + // Dictionary of injection validations by type, added to by `createInjectionHelper` + var typeValidators = {}; - TreeConstructionWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null || html === '') { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - if (parent.namespaceURI !== svgNamespace) { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - return fixSVG(parent, div, html, reference); - }; + /** + This method allows other Ember modules to register injection helpers for a + given container type. Helpers are exported to the `inject` namespace as the + container type itself. + + @private + @method createInjectionHelper + @since 1.10.0 + @for Ember + @param {String} type The container type the helper will inject + @param {Function} validator A validation callback that is executed at mixin-time + */ - return TreeConstructionWithSVGInnerHTMLFix; - })(TreeConstructionClass); - } + function createInjectionHelper(type, validator) { + typeValidators[type] = validator; - function fixSVG(parent, div, html, reference) { - // IE, Edge: also do not correctly support using `innerHTML` on SVG - // namespaced elements. So here a wrapper is used. - var wrappedHtml = '' + html + ''; - div.innerHTML = wrappedHtml; + inject[type] = function (name) { + return new _emberMetal.InjectedProperty(type, name); + }; + } - var _moveNodesBefore = _glimmerRuntimeLibDomHelper.moveNodesBefore(div.firstChild, parent, reference); + /** + Validation function that runs per-type validation functions once for each + injected type encountered. + + @private + @method validatePropertyInjections + @since 1.10.0 + @for Ember + @param {Object} factory The factory object + */ - var first = _moveNodesBefore[0]; - var last = _moveNodesBefore[1]; + function validatePropertyInjections(factory) { + var proto = factory.proto(); + var types = []; - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - function shouldApplyFix(document, svgNamespace) { - var svg = document.createElementNS(svgNamespace, 'svg'); - try { - svg['insertAdjacentHTML']('beforeEnd', ''); - } catch (e) {} finally { - // FF: Old versions will create a node in the wrong namespace - if (svg.childNodes.length === 1 && svg.firstChild.namespaceURI === SVG_NAMESPACE) { - // The test worked as expected, no fix required - return false; - } - svg = null; - return true; - } + for (var key in proto) { + var desc = proto[key]; + if (desc instanceof _emberMetal.InjectedProperty && types.indexOf(desc.type) === -1) { + types.push(desc.type); + } } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L3N2Zy1pbm5lci1odG1sLWZpeC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFHQSxRQUFNLGFBQWEsR0FBRyw0QkFBNEIsQ0FBQzs7Ozs7Ozs7Ozs7OztBQWFuRCxhQUFBLFVBQUEsQ0FBMkIsUUFBa0IsRUFBRSxlQUFrQyxFQUFFLFlBQW9CLEVBQUE7QUFDckcsWUFBSSxDQUFDLFFBQVEsRUFBRSxPQUFPLGVBQWUsQ0FBQztBQUV0QyxZQUFJLENBQUMsY0FBYyxDQUFDLFFBQVEsRUFBRSxZQUFZLENBQUMsRUFBRTtBQUMzQyxtQkFBTyxlQUFlLENBQUM7U0FDeEI7QUFFRCxZQUFJLEdBQUcsR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFDO0FBRXhDO2tDQUFPLDZCQUFBOztxQkFBQSw2QkFBQTs7OztBQUFBLHlDQUFBLFdBQ0wsZ0JBQWdCLEdBQUEsMEJBQUMsTUFBbUIsRUFBRSxXQUFpQixFQUFFLElBQVksRUFBQTtBQUNuRSxvQkFBSSxJQUFJLEtBQUssSUFBSSxJQUFJLElBQUksS0FBSyxFQUFFLEVBQUU7QUFDaEMsMkJBQU8sMkJBQU0sZ0JBQWdCLEtBQUEsT0FBQyxNQUFNLEVBQUUsV0FBVyxFQUFFLElBQU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W1lc3BhY2UsICdzdmcnKTtcblxuICB0cnkge1xuICAgIHN2Z1snaW5zZXJ0QWRqYWNlbnRIVE1MJ10oJ2JlZm9yZUVuZCcsICc8Y2lyY2xlPjwvY2lyY2xlPicpO1xuICB9IGNhdGNoIChlKSB7XG4gICAgLy8gSUUsIEVkZ2U6IFdpbGwgdGhyb3csIGluc2VydEFkamFjZW50SFRNTCBpcyB1bnN1cHBvcnRlZCBvbiBTVkdcbiAgICAvLyBTYWZhcmk6IFdpbGwgdGhyb3csIGluc2VydEFkamFjZW50SFRNTCBpcyBub3QgcHJlc2VudCBvbiBTVkdcbiAgfSBmaW5hbGx5IHtcbiAgICAvLyBGRjogT2xkIHZlcnNpb25zIHdpbGwgY3JlYXRlIGEgbm9kZSBpbiB0aGUgd3JvbmcgbmFtZXNwYWNlXG4gICAgaWYgKHN2Zy5jaGlsZE5vZGVzLmxlbmd0aCA9PT0gMSAmJiBzdmcuZmlyc3RDaGlsZC5uYW1lc3BhY2VVUkkgPT09IFNWR19OQU1FU1BBQ0UpIHtcbiAgICAgIC8vIFRoZSB0ZXN0IHdvcmtlZCBhcyBleHBlY3RlZCwgbm8gZml4IHJlcXVpcmVkXG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIHN2ZyA9IG51bGw7XG5cbiAgICByZXR1cm4gdHJ1ZTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compat/text-node-merging-fix', ['exports'], function (exports) { - // Patch: Adjacent text node merging fix - // Browsers: IE, Edge, Firefox w/o inspector open - // Reason: These browsers will merge adjacent text nodes. For exmaple given - //
    Hello
    with div.insertAdjacentHTML(' world') browsers - // with proper behavior will populate div.childNodes with two items. - // These browsers will populate it with one merged node instead. - // Fix: Add these nodes to a wrapper element, then iterate the childNodes - // of that wrapper and move the nodes to their target location. Note - // that potential SVG bugs will have been handled before this fix. - // Note that this fix must only apply to the previous text node, as - // the base implementation of `insertHTMLBefore` already handles - // following text nodes correctly. - 'use strict'; - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; + if (types.length) { + for (var i = 0; i < types.length; i++) { + var validator = typeValidators[types[i]]; - function domChanges(document, DOMChangesClass) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document)) { - return DOMChangesClass; + if (typeof validator === 'function') { + validator(factory); } - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithTextNodeMergingFix, _DOMChangesClass); - - function DOMChangesWithTextNodeMergingFix(document) { - _DOMChangesClass.call(this, document); - this.uselessComment = document.createComment(''); - } - - DOMChangesWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - var didSetUselessComment = false; - var nextPrevious = nextSibling ? nextSibling.previousSibling : parent.lastChild; - if (nextPrevious && nextPrevious instanceof Text) { - didSetUselessComment = true; - parent.insertBefore(this.uselessComment, nextSibling); - } - var bounds = _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - if (didSetUselessComment) { - parent.removeChild(this.uselessComment); - } - return bounds; - }; - - return DOMChangesWithTextNodeMergingFix; - })(DOMChangesClass); + } } - function treeConstruction(document, TreeConstructionClass) { - if (!document) return TreeConstructionClass; - if (!shouldApplyFix(document)) { - return TreeConstructionClass; - } - return (function (_TreeConstructionClass) { - babelHelpers.inherits(TreeConstructionWithTextNodeMergingFix, _TreeConstructionClass); - - function TreeConstructionWithTextNodeMergingFix(document) { - _TreeConstructionClass.call(this, document); - this.uselessComment = this.createComment(''); - } + return true; + } +}); +enifed('ember-runtime/is-equal', ['exports'], function (exports) { + /** + Compares two objects, returning true if they are equal. + + ```javascript + Ember.isEqual('hello', 'hello'); // true + Ember.isEqual(1, 2); // false + ``` + + `isEqual` is a more specific comparison than a triple equal comparison. + It will call the `isEqual` instance method on the objects being + compared, allowing finer control over when objects should be considered + equal to each other. + + ```javascript + let Person = Ember.Object.extend({ + isEqual(other) { return this.ssn == other.ssn; } + }); + + let personA = Person.create({name: 'Muhammad Ali', ssn: '123-45-6789'}); + let personB = Person.create({name: 'Cassius Clay', ssn: '123-45-6789'}); + + Ember.isEqual(personA, personB); // true + ``` + + Due to the expense of array comparisons, collections will never be equal to + each other even if each of their items are equal to each other. + + ```javascript + Ember.isEqual([4, 2], [4, 2]); // false + ``` + + @method isEqual + @for Ember + @param {Object} a first object to compare + @param {Object} b second object to compare + @return {Boolean} + @public + */ + 'use strict'; - TreeConstructionWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null) { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - var didSetUselessComment = false; - var nextPrevious = reference ? reference.previousSibling : parent.lastChild; - if (nextPrevious && nextPrevious instanceof Text) { - didSetUselessComment = true; - parent.insertBefore(this.uselessComment, reference); - } - var bounds = _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - if (didSetUselessComment) { - parent.removeChild(this.uselessComment); - } - return bounds; - }; + exports.default = isEqual; - return TreeConstructionWithTextNodeMergingFix; - })(TreeConstructionClass); + function isEqual(a, b) { + if (a && typeof a.isEqual === 'function') { + return a.isEqual(b); } - function shouldApplyFix(document) { - var mergingTextDiv = document.createElement('div'); - mergingTextDiv.innerHTML = 'first'; - mergingTextDiv.insertAdjacentHTML('beforeEnd', 'second'); - if (mergingTextDiv.childNodes.length === 2) { - mergingTextDiv = null; - // It worked as expected, no fix required - return false; - } - mergingTextDiv = null; - return true; + if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime(); } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L3RleHQtbm9kZS1tZXJnaW5nLWZpeC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFlQSxhQUFBLFVBQUEsQ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b2N1bWVudCkge1xuICBsZXQgbWVyZ2luZ1RleHREaXYgPSA8SFRNTEVsZW1lbnQ+IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpO1xuXG4gIG1lcmdpbmdUZXh0RGl2LmlubmVySFRNTCA9ICdmaXJzdCc7XG4gIG1lcmdpbmdUZXh0RGl2Lmluc2VydEFkamFjZW50SFRNTCgnYmVmb3JlRW5kJywgJ3NlY29uZCcpO1xuXG4gIGlmIChtZXJnaW5nVGV4dERpdi5jaGlsZE5vZGVzLmxlbmd0aCA9PT0gMikge1xuICAgIG1lcmdpbmdUZXh0RGl2ID0gbnVsbDtcbiAgICAvLyBJdCB3b3JrZWQgYXMgZXhwZWN0ZWQsIG5vIGZpeCByZXF1aXJlZFxuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuXG4gIG1lcmdpbmdUZXh0RGl2ID0gbnVsbDtcblxuICByZXR1cm4gdHJ1ZTtcbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/blocks', ['exports', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/compiler'], function (exports, _glimmerRuntimeLibUtils, _glimmerRuntimeLibCompiler) { - 'use strict'; - - var CompiledBlock = function CompiledBlock(ops, symbols) { - this.ops = ops; - this.symbols = symbols; - }; - - exports.CompiledBlock = CompiledBlock; - var Block = function Block(program, symbolTable) { - this.program = program; - this.symbolTable = symbolTable; - this.compiled = null; - }; + return a === b; + } +}); +enifed('ember-runtime/mixins/-proxy', ['exports', '@glimmer/reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { + /** + @module ember + @submodule ember-runtime + */ - exports.Block = Block; + 'use strict'; - var InlineBlock = (function (_Block) { - babelHelpers.inherits(InlineBlock, _Block); + function contentPropertyWillChange(content, contentKey) { + var key = contentKey.slice(8); // remove "content." + if (key in this) { + return; + } // if shadowed in proxy + _emberMetal.propertyWillChange(this, key); + } - function InlineBlock(program, symbolTable) { - var locals = arguments.length <= 2 || arguments[2] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[2]; + function contentPropertyDidChange(content, contentKey) { + var key = contentKey.slice(8); // remove "content." + if (key in this) { + return; + } // if shadowed in proxy + _emberMetal.propertyDidChange(this, key); + } - _Block.call(this, program, symbolTable); - this.locals = locals; - } + var ProxyTag = (function (_CachedTag) { + babelHelpers.inherits(ProxyTag, _CachedTag); - InlineBlock.prototype.hasPositionalParameters = function hasPositionalParameters() { - return !!this.locals.length; - }; + function ProxyTag(proxy) { + babelHelpers.classCallCheck(this, ProxyTag); - InlineBlock.prototype.compile = function compile(env) { - var compiled = this.compiled; - if (compiled) return compiled; - var ops = new _glimmerRuntimeLibCompiler.InlineBlockCompiler(this, env).compile(); - return this.compiled = new CompiledBlock(ops, this.symbolTable.size); - }; + _CachedTag.call(this); - return InlineBlock; - })(Block); + var content = _emberMetal.get(proxy, 'content'); - exports.InlineBlock = InlineBlock; + this.proxy = proxy; + this.proxyWrapperTag = new _glimmerReference.DirtyableTag(); + this.proxyContentTag = new _glimmerReference.UpdatableTag(_emberMetal.tagFor(content)); + } - var PartialBlock = (function (_InlineBlock) { - babelHelpers.inherits(PartialBlock, _InlineBlock); + /** + `Ember.ProxyMixin` forwards all properties not defined by the proxy itself + to a proxied `content` object. See Ember.ObjectProxy for more details. + + @class ProxyMixin + @namespace Ember + @private + */ - function PartialBlock() { - _InlineBlock.apply(this, arguments); - } + ProxyTag.prototype.compute = function compute() { + return Math.max(this.proxyWrapperTag.value(), this.proxyContentTag.value()); + }; - return PartialBlock; - })(InlineBlock); + ProxyTag.prototype.dirty = function dirty() { + this.proxyWrapperTag.dirty(); + }; - exports.PartialBlock = PartialBlock; + ProxyTag.prototype.contentDidChange = function contentDidChange() { + var content = _emberMetal.get(this.proxy, 'content'); + this.proxyContentTag.update(_emberMetal.tagFor(content)); + }; - var TopLevelTemplate = (function (_Block2) { - babelHelpers.inherits(TopLevelTemplate, _Block2); + return ProxyTag; + })(_glimmerReference.CachedTag); - function TopLevelTemplate() { - _Block2.apply(this, arguments); - } + exports.default = _emberMetal.Mixin.create({ + /** + The object whose properties will be forwarded. + @property content + @type Ember.Object + @default null + @private + */ + content: null, - return TopLevelTemplate; - })(Block); + init: function () { + this._super.apply(this, arguments); + _emberMetal.meta(this).setProxy(); + }, - exports.TopLevelTemplate = TopLevelTemplate; + _initializeTag: _emberMetal.on('init', function () { + _emberMetal.meta(this)._tag = new ProxyTag(this); + }), - var EntryPoint = (function (_TopLevelTemplate) { - babelHelpers.inherits(EntryPoint, _TopLevelTemplate); + _contentDidChange: _emberMetal.observer('content', function () { + _emberMetal.assert('Can\'t set Proxy\'s content to itself', _emberMetal.get(this, 'content') !== this); + _emberMetal.tagFor(this).contentDidChange(); + }), - function EntryPoint() { - _TopLevelTemplate.apply(this, arguments); - } + isTruthy: _emberRuntimeComputedComputed_macros.bool('content'), - EntryPoint.prototype.compile = function compile(env) { - var compiled = this.compiled; - if (compiled) return compiled; - var ops = new _glimmerRuntimeLibCompiler.EntryPointCompiler(this, env).compile(); - return this.compiled = new CompiledBlock(ops, this.symbolTable.size); - }; + _debugContainerKey: null, - return EntryPoint; - })(TopLevelTemplate); + willWatchProperty: function (key) { + var contentKey = 'content.' + key; + _emberMetal._addBeforeObserver(this, contentKey, null, contentPropertyWillChange); + _emberMetal.addObserver(this, contentKey, null, contentPropertyDidChange); + }, - exports.EntryPoint = EntryPoint; + didUnwatchProperty: function (key) { + var contentKey = 'content.' + key; + _emberMetal._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); + _emberMetal.removeObserver(this, contentKey, null, contentPropertyDidChange); + }, - var Layout = (function (_TopLevelTemplate2) { - babelHelpers.inherits(Layout, _TopLevelTemplate2); + unknownProperty: function (key) { + var content = _emberMetal.get(this, 'content'); + if (content) { + _emberMetal.deprecate('You attempted to access `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); + return _emberMetal.get(content, key); + } + }, - function Layout(program, symbolTable, named, yields, hasPartials) { - _TopLevelTemplate2.call(this, program, symbolTable); - this.named = named; - this.yields = yields; - this.hasPartials = hasPartials; - this.hasNamedParameters = !!this.named.length; - this.hasYields = !!this.yields.length; - ; - } + setUnknownProperty: function (key, value) { + var m = _emberMetal.meta(this); + if (m.proto === this) { + // if marked as prototype then just defineProperty + // rather than delegate + _emberMetal.defineProperty(this, key, null, value); + return value; + } - return Layout; - })(TopLevelTemplate); + var content = _emberMetal.get(this, 'content'); + _emberMetal.assert('Cannot delegate set(\'' + key + '\', ' + value + ') to the \'content\' property of object proxy ' + this + ': its \'content\' is undefined.', content); - exports.Layout = Layout; + _emberMetal.deprecate('You attempted to set `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); + return _emberMetal.set(content, key, value); + } + }); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvYmxvY2tzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVdBLGFBQUEsR0FJRSxTQUpGLGFBQUEsQ0FJYyxHQUFVLEVBQUUsT0FBZSxFQUFBO0FBQ3JDLFlBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO0FBQ2YsWUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUM7S0FDeEI7Ozs7UUFHSCxLQUFBLEdBR0UsU0FIRixLQUFBLENBR3FCLE9BQWdCLEVBQVMsV0FBd0IsRUFBQTtBQUFqRCxZQUFBLENBQUEsT0FBTyxHQUFQLE9BQU8sQ0FBUztBQUFTLFlBQUEsQ0FBQSxXQUFXLEdBQVgsV0FBVyxDQUFhO0FBRjFELFlBQUEsQ0FBQSxRQUFRLEdBQWtCLElBQUksQ0FBQztL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kUGFyYW1ldGVyczogYm9vbGVhbjtcbiAgcHVibGljIGhhc1lpZWxkczogYm9vbGVhbjtcbiAgY29uc3RydWN0b3IocHJvZ3JhbTogUHJvZ3JhbSwgc3ltYm9sVGFibGU6IFN5bWJvbFRhYmxlLCBwdWJsaWMgbmFtZWQ6IHN0cmluZ1tdLCBwdWJsaWMgeWllbGRzOiBzdHJpbmdbXSwgcHVibGljIGhhc1BhcnRpYWxzOiBib29sZWFuKSB7XG4gICAgc3VwZXIocHJvZ3JhbSwgc3ltYm9sVGFibGUpO1xuICAgIHRoaXMuaGFzTmFtZWRQYXJhbWV0ZXJzID0gISF0aGlzLm5hbWVkLmxlbmd0aDtcbiAgICB0aGlzLmhhc1lpZWxkcyA9ICEhdGhpcy55aWVsZHMubGVuZ3RoOztcbiAgfVxufVxuIl19 -enifed("glimmer-runtime/lib/compiled/expressions", ["exports"], function (exports) { - "use strict"; - - var CompiledExpression = (function () { - function CompiledExpression() {} +enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - CompiledExpression.prototype.toJSON = function toJSON() { - return "UNIMPL: " + this.type.toUpperCase(); - }; + 'use strict'; - return CompiledExpression; - })(); + exports.deprecateUnderscoreActions = deprecateUnderscoreActions; - exports.CompiledExpression = CompiledExpression; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBR0Esa0JBQUE7aUJBQUEsa0JBQUE7O0FBQUEsMEJBQUEsV0FJRSxNQUFNLEdBQUEsa0JBQUE7QUFDSixnQ0FBa0IsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBRztTQUM3Qzs7ZUFOSCxrQkFBQSIsImZpbGUiOiJleHByZXNzaW9ucy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBWTSBmcm9tICcuLi92bS9hcHBlbmQnO1xuaW1wb3J0IHsgUGF0aFJlZmVyZW5jZSB9IGZyb20gJ2dsaW1tZXItcmVmZXJlbmNlJztcblxuZXhwb3J0IGFic3RyYWN0IGNsYXNzIENvbXBpbGVkRXhwcmVzc2lvbjxUPiB7XG4gIHR5cGU6IHN0cmluZztcbiAgYWJzdHJhY3QgZXZhbHVhdGUodm06IFZNKTogUGF0aFJlZmVyZW5jZTxUPjtcblxuICB0b0pTT04oKTogc3RyaW5nIHtcbiAgICByZXR1cm4gYFVOSU1QTDogJHt0aGlzLnR5cGUudG9VcHBlckNhc2UoKX1gO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/args', ['exports', 'glimmer-runtime/lib/compiled/expressions/positional-args', 'glimmer-runtime/lib/compiled/expressions/named-args', 'glimmer-runtime/lib/syntax/core', 'glimmer-reference'], function (exports, _glimmerRuntimeLibCompiledExpressionsPositionalArgs, _glimmerRuntimeLibCompiledExpressionsNamedArgs, _glimmerRuntimeLibSyntaxCore, _glimmerReference) { - 'use strict'; + /** + `Ember.ActionHandler` is available on some familiar classes including + `Ember.Route`, `Ember.Component`, and `Ember.Controller`. + (Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`, + and `Ember.Route` and available to the above classes through + inheritance.) + + @class ActionHandler + @namespace Ember + @private + */ + var ActionHandler = _emberMetal.Mixin.create({ + mergedProperties: ['actions'], - var CompiledArgs = (function () { - function CompiledArgs(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; + /** + The collection of functions, keyed by name, available on this + `ActionHandler` as action targets. + These functions will be invoked when a matching `{{action}}` is triggered + from within a template and the application's current route is this route. + Actions can also be invoked from other parts of your application + via `ActionHandler#send`. + The `actions` hash will inherit action handlers from + the `actions` hash defined on extended parent classes + or mixins rather than just replace the entire hash, e.g.: + ```js + App.CanDisplayBanner = Ember.Mixin.create({ + actions: { + displayBanner(msg) { + // ... + } } - - CompiledArgs.create = function create(positional, named, blocks) { - if (positional === _glimmerRuntimeLibCompiledExpressionsPositionalArgs.COMPILED_EMPTY_POSITIONAL_ARGS && named === _glimmerRuntimeLibCompiledExpressionsNamedArgs.COMPILED_EMPTY_NAMED_ARGS && blocks === _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS) { - return this.empty(); - } else { - return new this(positional, named, blocks); - } - }; - - CompiledArgs.empty = function empty() { - return COMPILED_EMPTY_ARGS; - }; - - CompiledArgs.prototype.evaluate = function evaluate(vm) { - var positional = this.positional; - var named = this.named; - var blocks = this.blocks; - - return EvaluatedArgs.create(positional.evaluate(vm), named.evaluate(vm), blocks); - }; - - return CompiledArgs; - })(); - - exports.CompiledArgs = CompiledArgs; - - var COMPILED_EMPTY_ARGS = new ((function (_CompiledArgs) { - babelHelpers.inherits(_class, _CompiledArgs); - - function _class() { - _CompiledArgs.call(this, _glimmerRuntimeLibCompiledExpressionsPositionalArgs.COMPILED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.COMPILED_EMPTY_NAMED_ARGS, _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS); + }); + App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { + actions: { + playMusic() { + // ... + } } - - _class.prototype.evaluate = function evaluate(vm) { - return EMPTY_EVALUATED_ARGS; - }; - - return _class; - })(CompiledArgs))(); - - var EvaluatedArgs = (function () { - function EvaluatedArgs(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; - this.tag = _glimmerReference.combineTagged([positional, named]); + }); + // `WelcomeRoute`, when active, will be able to respond + // to both actions, since the actions hash is merged rather + // then replaced when extending mixins / parent classes. + this.send('displayBanner'); + this.send('playMusic'); + ``` + Within a Controller, Route or Component's action handler, + the value of the `this` context is the Controller, Route or + Component object: + ```js + App.SongRoute = Ember.Route.extend({ + actions: { + myAction() { + this.controllerFor("song"); + this.transitionTo("other.route"); + ... + } } - - EvaluatedArgs.empty = function empty() { - return EMPTY_EVALUATED_ARGS; - }; - - EvaluatedArgs.create = function create(positional, named, blocks) { - return new this(positional, named, blocks); - }; - - EvaluatedArgs.positional = function positional(values) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS : arguments[1]; - - return new this(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EvaluatedPositionalArgs.create(values), _glimmerRuntimeLibCompiledExpressionsNamedArgs.EVALUATED_EMPTY_NAMED_ARGS, blocks); - }; - - EvaluatedArgs.named = function named(map) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS : arguments[1]; - - return new this(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EVALUATED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.EvaluatedNamedArgs.create(map), blocks); - }; - - return EvaluatedArgs; - })(); - - exports.EvaluatedArgs = EvaluatedArgs; - - var EMPTY_EVALUATED_ARGS = new EvaluatedArgs(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EVALUATED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.EVALUATED_EMPTY_NAMED_ARGS, _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS); - exports.CompiledPositionalArgs = _glimmerRuntimeLibCompiledExpressionsPositionalArgs.CompiledPositionalArgs; - exports.EvaluatedPositionalArgs = _glimmerRuntimeLibCompiledExpressionsPositionalArgs.EvaluatedPositionalArgs; - exports.CompiledNamedArgs = _glimmerRuntimeLibCompiledExpressionsNamedArgs.CompiledNamedArgs; - exports.EvaluatedNamedArgs = _glimmerRuntimeLibCompiledExpressionsNamedArgs.EvaluatedNamedArgs; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWI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5hbWVkQXJncywgRXZhbHVhdGVkTmFtZWRBcmdzIH07XG4iXX0= -enifed("glimmer-runtime/lib/compiled/expressions/concat", ["exports", "glimmer-reference"], function (exports, _glimmerReference) { - "use strict"; - - var CompiledConcat = (function () { - function CompiledConcat(parts) { - this.parts = parts; - this.type = "concat"; + }); + ``` + It is also possible to call `this._super(...arguments)` from within an + action handler if it overrides a handler defined on a parent + class or mixin: + Take for example the following routes: + ```js + App.DebugRoute = Ember.Mixin.create({ + actions: { + debugRouteInformation() { + console.debug("trololo"); + } } - - CompiledConcat.prototype.evaluate = function evaluate(vm) { - var parts = new Array(this.parts.length); - for (var i = 0; i < this.parts.length; i++) { - parts[i] = this.parts[i].evaluate(vm); + }); + App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { + actions: { + debugRouteInformation() { + // also call the debugRouteInformation of mixed in App.DebugRoute + this._super(...arguments); + // show additional annoyance + window.alert(...); + } + } + }); + ``` + ## Bubbling + By default, an action will stop bubbling once a handler defined + on the `actions` hash handles it. To continue bubbling the action, + you must return `true` from the handler: + ```js + App.Router.map(function() { + this.route("album", function() { + this.route("song"); + }); + }); + App.AlbumRoute = Ember.Route.extend({ + actions: { + startPlaying: function() { + } + } + }); + App.AlbumSongRoute = Ember.Route.extend({ + actions: { + startPlaying() { + // ... + if (actionShouldAlsoBeTriggeredOnParentRoute) { + return true; } - return new ConcatReference(parts); - }; + } + } + }); + ``` + @property actions + @type Object + @default null + @public + */ - CompiledConcat.prototype.toJSON = function toJSON() { - return "concat(" + this.parts.map(function (expr) { - return expr.toJSON(); - }).join(", ") + ")"; - }; + /** + Triggers a named action on the `ActionHandler`. Any parameters + supplied after the `actionName` string will be passed as arguments + to the action target function. + If the `ActionHandler` has its `target` property set, actions may + bubble to the `target`. Bubbling happens when an `actionName` can + not be found in the `ActionHandler`'s `actions` hash or if the + action target function returns `true`. + Example + ```js + App.WelcomeRoute = Ember.Route.extend({ + actions: { + playTheme() { + this.send('playMusic', 'theme.mp3'); + }, + playMusic(track) { + // ... + } + } + }); + ``` + @method send + @param {String} actionName The action to trigger + @param {*} context a context to send with the action + @public + */ + send: function (actionName) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - return CompiledConcat; - })(); + if (this.actions && this.actions[actionName]) { + var shouldBubble = this.actions[actionName].apply(this, args) === true; + if (!shouldBubble) { + return; + } + } - exports.default = CompiledConcat; + var target = _emberMetal.get(this, 'target'); + if (target) { + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); + target.send.apply(target, arguments); + } + }, - var ConcatReference = (function (_CachedReference) { - babelHelpers.inherits(ConcatReference, _CachedReference); + willMergeMixin: function (props) { + _emberMetal.assert('Specifying `_actions` and `actions` in the same mixin is not supported.', !props.actions || !props._actions); - function ConcatReference(parts) { - _CachedReference.call(this); - this.parts = parts; - this.tag = _glimmerReference.combineTagged(parts); - } + if (props._actions) { + _emberMetal.deprecate('Specifying actions in `_actions` is deprecated, please use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); - ConcatReference.prototype.compute = function compute() { - var parts = new Array(); - for (var i = 0; i < this.parts.length; i++) { - var value = this.parts[i].value(); - if (value !== null && value !== undefined) { - parts[i] = castToString(this.parts[i].value()); - } - } - if (parts.length > 0) { - return parts.join(''); - } - return null; - }; + props.actions = props._actions; + delete props._actions; + } + } + }); - return ConcatReference; - })(_glimmerReference.CachedReference); + exports.default = ActionHandler; - function castToString(value) { - if (typeof value['toString'] !== 'function') { - return ''; - } - return String(value); - } + function deprecateUnderscoreActions(factory) { + Object.defineProperty(factory.prototype, '_actions', { + configurable: true, + enumerable: false, + set: function (value) { + _emberMetal.assert('You cannot set `_actions` on ' + this + ', please use `actions` instead.'); + }, + get: function () { + _emberMetal.deprecate('Usage of `_actions` is deprecated, use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); + return _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vZiB2YWx1ZVsndG9TdHJpbmcnXSAhPT0gJ2Z1bmN0aW9uJykge1xuICAgIHJldHVybiAnJztcbiAgfVxuXG4gIHJldHVybiBTdHJpbmcodmFsdWUpO1xufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/function', ['exports', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/compiled/expressions'], function (exports, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibCompiledExpressions) { - 'use strict'; - - exports.default = make; +enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/each_proxy'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsEnumerable, _emberRuntimeSystemEach_proxy) { + /** + @module ember + @submodule ember-runtime + */ - function make(func) { - return new FunctionExpressionSyntax(func); - } + // .......................................................... + // HELPERS + // + 'use strict'; - var FunctionExpressionSyntax = (function (_ExpressionSyntax) { - babelHelpers.inherits(FunctionExpressionSyntax, _ExpressionSyntax); + var _Mixin$create; - function FunctionExpressionSyntax(func) { - _ExpressionSyntax.call(this); - this.type = "function-expression"; - this.func = func; - } + exports.addArrayObserver = addArrayObserver; + exports.removeArrayObserver = removeArrayObserver; + exports.objectAt = objectAt; + exports.arrayContentWillChange = arrayContentWillChange; + exports.arrayContentDidChange = arrayContentDidChange; + exports.isEmberArray = isEmberArray; - FunctionExpressionSyntax.prototype.compile = function compile(lookup, env, symbolTable) { - return new CompiledFunctionExpression(this.func, symbolTable); - }; + function arrayObserversHelper(obj, target, opts, operation, notify) { + var willChange = opts && opts.willChange || 'arrayWillChange'; + var didChange = opts && opts.didChange || 'arrayDidChange'; + var hasObservers = _emberMetal.get(obj, 'hasArrayObservers'); - return FunctionExpressionSyntax; - })(_glimmerRuntimeLibSyntax.Expression); + if (hasObservers === notify) { + _emberMetal.propertyWillChange(obj, 'hasArrayObservers'); + } - var CompiledFunctionExpression = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledFunctionExpression, _CompiledExpression); + operation(obj, '@array:before', target, willChange); + operation(obj, '@array:change', target, didChange); - function CompiledFunctionExpression(func, symbolTable) { - _CompiledExpression.call(this); - this.func = func; - this.symbolTable = symbolTable; - this.type = "function"; - this.func = func; - } + if (hasObservers === notify) { + _emberMetal.propertyDidChange(obj, 'hasArrayObservers'); + } - CompiledFunctionExpression.prototype.evaluate = function evaluate(vm) { - var func = this.func; - var symbolTable = this.symbolTable; + return obj; + } - return func(vm, symbolTable); - }; + function addArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetal.addListener, false); + } - CompiledFunctionExpression.prototype.toJSON = function toJSON() { - var func = this.func; + function removeArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetal.removeListener, true); + } - if (func.name) { - return '`' + func.name + '(...)`'; - } else { - return "`func(...)`"; - } - }; + function objectAt(content, idx) { + if (content.objectAt) { + return content.objectAt(idx); + } - return CompiledFunctionExpression; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O3NCQVFBLElBQUE7O0FBQUEsYUFBQSxJQUFBLENBQWdDLElBQTJCLEVBQUE7QUFDekQsZUFBTyxJQUFJLHdCQUF3QixDQUFDLElBQUksQ0FBQyxDQUFDO0tBQzNDOztRQUVELHdCQUFBOzhCQUFBLHdCQUFBOztBQUlFLGlCQUpGLHdCQUFBLENBSWMsSUFBMkIsRUFBQTtBQUNyQyx3Q0FBTyxDQUFDO0FBSkgsZ0JBQUEsQ0FBQSxJQUFJLEdBQUcscUJBQXFCLENBQUM7QUFLbEMsZ0JBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1NBQ2xCOztBQVBILGdDQUFBLFdBU0U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npb248VD4ge1xuICAgIHJldHVybiBuZXcgQ29tcGlsZWRGdW5jdGlvbkV4cHJlc3Npb24odGhpcy5mdW5jLCBzeW1ib2xUYWJsZSk7XG4gIH1cbn1cblxuY2xhc3MgQ29tcGlsZWRGdW5jdGlvbkV4cHJlc3Npb248VD4gZXh0ZW5kcyBDb21waWxlZEV4cHJlc3Npb248VD4ge1xuICBwdWJsaWMgdHlwZSA9IFwiZnVuY3Rpb25cIjtcblxuICBjb25zdHJ1Y3Rvcihwcml2YXRlIGZ1bmM6IEZ1bmN0aW9uRXhwcmVzc2lvbjxUPiwgcHJpdmF0ZSBzeW1ib2xUYWJsZTogU3ltYm9sVGFibGUpIHtcbiAgICBzdXBlcigpO1xuICAgIHRoaXMuZnVuYyA9IGZ1bmM7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPFQ+IHtcbiAgICBsZXQgeyBmdW5jLCBzeW1ib2xUYWJsZSB9ID0gdGhpcztcbiAgICByZXR1cm4gZnVuYyh2bSwgc3ltYm9sVGFibGUpO1xuICB9XG5cbiAgdG9KU09OKCk6IHN0cmluZyB7XG4gICAgbGV0IHsgZnVuYyB9ID0gdGhpcztcblxuICAgIGlmIChmdW5jLm5hbWUpIHtcbiAgICAgIHJldHVybiBgXFxgJHtmdW5jLm5hbWV9KC4uLilcXGBgO1xuICAgIH0gZWxzZSB7XG4gICAgICByZXR1cm4gXCJgZnVuYyguLi4pYFwiO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/has-block', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/references'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibReferences) { - 'use strict'; + return content[idx]; + } - var CompiledHasBlock = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledHasBlock, _CompiledExpression); + function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { + var removing = undefined, + lim = undefined; - function CompiledHasBlock(inner) { - _CompiledExpression.call(this); - this.inner = inner; - this.type = "has-block"; - } + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; + } else { + if (removeAmt === undefined) { + removeAmt = -1; + } - CompiledHasBlock.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - return _glimmerRuntimeLibReferences.PrimitiveReference.create(!!block); - }; + if (addAmt === undefined) { + addAmt = -1; + } + } - CompiledHasBlock.prototype.toJSON = function toJSON() { - return 'has-block(' + this.inner.toJSON() + ')'; - }; + if (array.__each) { + array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt); + } - return CompiledHasBlock; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + _emberMetal.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); - exports.default = CompiledHasBlock; + if (startIdx >= 0 && removeAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { + removing = []; + lim = startIdx + removeAmt; - var CompiledHasBlockParams = (function (_CompiledExpression2) { - babelHelpers.inherits(CompiledHasBlockParams, _CompiledExpression2); + for (var idx = startIdx; idx < lim; idx++) { + removing.push(objectAt(array, idx)); + } + } else { + removing = removeAmt; + } - function CompiledHasBlockParams(inner) { - _CompiledExpression2.call(this); - this.inner = inner; - this.type = "has-block-params"; - } + array.enumerableContentWillChange(removing, addAmt); - CompiledHasBlockParams.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - return _glimmerRuntimeLibReferences.PrimitiveReference.create(!!(block && block.locals.length > 0)); - }; + return array; + } - CompiledHasBlockParams.prototype.toJSON = function toJSON() { - return 'has-block-params(' + this.inner.toJSON() + ')'; - }; + function arrayContentDidChange(array, startIdx, removeAmt, addAmt) { + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; + } else { + if (removeAmt === undefined) { + removeAmt = -1; + } - return CompiledHasBlockParams; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + if (addAmt === undefined) { + addAmt = -1; + } + } - exports.CompiledHasBlockParams = CompiledHasBlockParams; + var adding = undefined; + if (startIdx >= 0 && addAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { + adding = []; + var lim = startIdx + addAmt; - var CompiledGetBlockBySymbol = (function () { - function CompiledGetBlockBySymbol(symbol, debug) { - this.symbol = symbol; - this.debug = debug; - } + for (var idx = startIdx; idx < lim; idx++) { + adding.push(objectAt(array, idx)); + } + } else { + adding = addAmt; + } - CompiledGetBlockBySymbol.prototype.evaluate = function evaluate(vm) { - return vm.scope().getBlock(this.symbol); - }; + array.enumerableContentDidChange(removeAmt, adding); - CompiledGetBlockBySymbol.prototype.toJSON = function toJSON() { - return 'get-block($' + this.symbol + '(' + this.debug + '))'; - }; + if (array.__each) { + array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt); + } - return CompiledGetBlockBySymbol; - })(); + _emberMetal.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); - exports.CompiledGetBlockBySymbol = CompiledGetBlockBySymbol; + var meta = _emberMetal.peekMeta(array); + var cache = meta && meta.readableCache(); - var CompiledInPartialGetBlock = (function () { - function CompiledInPartialGetBlock(symbol, name) { - this.symbol = symbol; - this.name = name; - } + if (cache) { + if (cache.firstObject !== undefined && objectAt(array, 0) !== _emberMetal.cacheFor.get(cache, 'firstObject')) { + _emberMetal.propertyWillChange(array, 'firstObject'); + _emberMetal.propertyDidChange(array, 'firstObject'); + } + if (cache.lastObject !== undefined && objectAt(array, _emberMetal.get(array, 'length') - 1) !== _emberMetal.cacheFor.get(cache, 'lastObject')) { + _emberMetal.propertyWillChange(array, 'lastObject'); + _emberMetal.propertyDidChange(array, 'lastObject'); + } + } + return array; + } - CompiledInPartialGetBlock.prototype.evaluate = function evaluate(vm) { - var symbol = this.symbol; - var name = this.name; + var EMBER_ARRAY = _emberUtils.symbol('EMBER_ARRAY'); - var args = vm.scope().getPartialArgs(symbol); - return args.blocks[name]; - }; + function isEmberArray(obj) { + return obj && !!obj[EMBER_ARRAY]; + } - CompiledInPartialGetBlock.prototype.toJSON = function toJSON() { - return 'get-block($' + this.symbol + '($ARGS).' + this.name + '))'; - }; + // .......................................................... + // ARRAY + // + /** + This mixin implements Observer-friendly Array-like behavior. It is not a + concrete implementation, but it can be used up by other classes that want + to appear like arrays. + + For example, ArrayProxy is a concrete classes that can + be instantiated to implement array-like behavior. Both of these classes use + the Array Mixin by way of the MutableArray mixin, which allows observable + changes to be made to the underlying array. + + Unlike `Ember.Enumerable,` this mixin defines methods specifically for + collections that provide index-ordered access to their contents. When you + are designing code that needs to accept any kind of Array-like object, you + should use these methods instead of Array primitives because these will + properly notify observers of changes to the array. + + Although these methods are efficient, they do add a layer of indirection to + your application so it is a good idea to use them only when you need the + flexibility of using both true JavaScript arrays and "virtual" arrays such + as controllers and collections. + + You can use the methods defined in this module to access and modify array + contents in a KVO-friendly way. You can also be notified whenever the + membership of an array changes by using `.observes('myArray.[]')`. + + To support `Ember.Array` in your own class, you must override two + primitives to use it: `length()` and `objectAt()`. + + Note that the Ember.Array mixin also incorporates the `Ember.Enumerable` + mixin. All `Ember.Array`-like objects are also enumerable. + + @class Array + @namespace Ember + @uses Ember.Enumerable + @since Ember 0.9.0 + @public + */ + var ArrayMixin = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) { + if (idx < 0 || idx >= _emberMetal.get(this, 'length')) { + return undefined; + } - return CompiledInPartialGetBlock; - })(); + return _emberMetal.get(this, idx); + }, _Mixin$create.objectsAt = function (indexes) { + var _this = this; - exports.CompiledInPartialGetBlock = CompiledInPartialGetBlock; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvaGFzLWJsb2NrLnRzIl0s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VidWc6IHN0cmluZykge1xuICB9XG5cbiAgZXZhbHVhdGUodm06IFZNKTogSW5saW5lQmxvY2sge1xuICAgIHJldHVybiB2bS5zY29wZSgpLmdldEJsb2NrKHRoaXMuc3ltYm9sKTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgZ2V0LWJsb2NrKCQke3RoaXMuc3ltYm9sfSgke3RoaXMuZGVidWd9KSlgO1xuICB9XG59XG5cbmV4cG9ydCBjbGFzcyBDb21waWxlZEluUGFydGlhbEdldEJsb2NrIGltcGxlbWVudHMgQ29tcGlsZWRHZXRCbG9jayB7XG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgc3ltYm9sOiBudW1iZXIsIHByaXZhdGUgbmFtZTogc3RyaW5nKSB7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBJbmxpbmVCbG9jayB7XG4gICAgbGV0IHsgc3ltYm9sLCBuYW1lIH0gPSB0aGlzO1xuICAgIGxldCBhcmdzID0gdm0uc2NvcGUoKS5nZXRQYXJ0aWFsQXJncyhzeW1ib2wpO1xuICAgIHJldHVybiBhcmdzLmJsb2Nrc1tuYW1lXTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgZ2V0LWJsb2NrKCQke3RoaXMuc3ltYm9sfSgkQVJHUykuJHt0aGlzLm5hbWV9KSlgO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/helper', ['exports', 'glimmer-runtime/lib/compiled/expressions'], function (exports, _glimmerRuntimeLibCompiledExpressions) { - 'use strict'; + return indexes.map(function (idx) { + return objectAt(_this, idx); + }); + }, _Mixin$create.nextObject = function (idx) { + return objectAt(this, idx); + }, _Mixin$create['[]'] = _emberMetal.computed({ + get: function (key) { + return this; + }, + set: function (key, value) { + this.replace(0, _emberMetal.get(this, 'length'), value); + return this; + } + }), _Mixin$create.firstObject = _emberMetal.computed(function () { + return objectAt(this, 0); + }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () { + return objectAt(this, _emberMetal.get(this, 'length') - 1); + }).readOnly(), _Mixin$create.contains = function (obj) { + _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - var CompiledHelper = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledHelper, _CompiledExpression); + return this.indexOf(obj) >= 0; + }, _Mixin$create.slice = function (beginIndex, endIndex) { + var ret = _emberMetal.default.A(); + var length = _emberMetal.get(this, 'length'); - function CompiledHelper(name, helper, args, symbolTable) { - _CompiledExpression.call(this); - this.name = name; - this.helper = helper; - this.args = args; - this.symbolTable = symbolTable; - this.type = "helper"; - } + if (_emberMetal.isNone(beginIndex)) { + beginIndex = 0; + } - CompiledHelper.prototype.evaluate = function evaluate(vm) { - var helper = this.helper; + if (_emberMetal.isNone(endIndex) || endIndex > length) { + endIndex = length; + } - return helper(vm, this.args.evaluate(vm), this.symbolTable); - }; + if (beginIndex < 0) { + beginIndex = length + beginIndex; + } - CompiledHelper.prototype.toJSON = function toJSON() { - return '`' + this.name.join('.') + '($ARGS)`'; - }; + if (endIndex < 0) { + endIndex = length + endIndex; + } - return CompiledHelper; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + while (beginIndex < endIndex) { + ret[ret.length] = objectAt(this, beginIndex++); + } - exports.default = CompiledHelper; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvaGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLGNBQUE7OEJBQUEsY0FBQTs7QUFHRSxpQkFIRixjQUFBLENBR3FCLElBQWMsRUFBUyxNQUFjLEVBQVMsSUFBa0IsRUFBUyxXQUF3Q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BQYXRoUmVmZXJlbmNlIH0gZnJvbSAnZ2xpbW1lci1yZWZlcmVuY2UnO1xuaW1wb3J0IHsgT3BhcXVlIH0gZnJvbSAnZ2xpbW1lci11dGlsJztcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgQ29tcGlsZWRIZWxwZXIgZXh0ZW5kcyBDb21waWxlZEV4cHJlc3Npb248T3BhcXVlPiB7XG4gIHB1YmxpYyB0eXBlID0gXCJoZWxwZXJcIjtcblxuICBjb25zdHJ1Y3RvcihwdWJsaWMgbmFtZTogc3RyaW5nW10sIHB1YmxpYyBoZWxwZXI6IEhlbHBlciwgcHVibGljIGFyZ3M6IENvbXBpbGVkQXJncywgcHVibGljIHN5bWJvbFRhYmxlOiBTeW1ib2xUYWJsZSkge1xuICAgIHN1cGVyKCk7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIGxldCB7IGhlbHBlciB9ID0gdGhpcztcbiAgICByZXR1cm4gaGVscGVyKHZtLCB0aGlzLmFyZ3MuZXZhbHVhdGUodm0pLCB0aGlzLnN5bWJvbFRhYmxlKTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgXFxgJHt0aGlzLm5hbWUuam9pbignLicpfSgkQVJHUylcXGBgO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/lookups', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-reference'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerReference) { - 'use strict'; + return ret; + }, _Mixin$create.indexOf = function (object, startAt) { + var len = _emberMetal.get(this, 'length'); - var CompiledLookup = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledLookup, _CompiledExpression); + if (startAt === undefined) { + startAt = 0; + } - function CompiledLookup(base, path) { - _CompiledExpression.call(this); - this.base = base; - this.path = path; - this.type = "lookup"; - } + if (startAt < 0) { + startAt += len; + } - CompiledLookup.create = function create(base, path) { - if (path.length === 0) { - return base; - } else { - return new this(base, path); - } - }; + for (var idx = startAt; idx < len; idx++) { + if (objectAt(this, idx) === object) { + return idx; + } + } - CompiledLookup.prototype.evaluate = function evaluate(vm) { - var base = this.base; - var path = this.path; + return -1; + }, _Mixin$create.lastIndexOf = function (object, startAt) { + var len = _emberMetal.get(this, 'length'); - return _glimmerReference.referenceFromParts(base.evaluate(vm), path); - }; + if (startAt === undefined || startAt >= len) { + startAt = len - 1; + } - CompiledLookup.prototype.toJSON = function toJSON() { - return this.base.toJSON() + '.' + this.path.join('.'); - }; + if (startAt < 0) { + startAt += len; + } - return CompiledLookup; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + for (var idx = startAt; idx >= 0; idx--) { + if (objectAt(this, idx) === object) { + return idx; + } + } - exports.default = CompiledLookup; + return -1; + }, _Mixin$create.addArrayObserver = function (target, opts) { + return addArrayObserver(this, target, opts); + }, _Mixin$create.removeArrayObserver = function (target, opts) { + return removeArrayObserver(this, target, opts); + }, _Mixin$create.hasArrayObservers = _emberMetal.computed(function () { + return _emberMetal.hasListeners(this, '@array:change') || _emberMetal.hasListeners(this, '@array:before'); + }), _Mixin$create.arrayContentWillChange = function (startIdx, removeAmt, addAmt) { + return arrayContentWillChange(this, startIdx, removeAmt, addAmt); + }, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) { + return arrayContentDidChange(this, startIdx, removeAmt, addAmt); + }, _Mixin$create.includes = function (obj, startAt) { + var len = _emberMetal.get(this, 'length'); - var CompiledSelf = (function (_CompiledExpression2) { - babelHelpers.inherits(CompiledSelf, _CompiledExpression2); + if (startAt === undefined) { + startAt = 0; + } - function CompiledSelf() { - _CompiledExpression2.apply(this, arguments); - } + if (startAt < 0) { + startAt += len; + } - CompiledSelf.prototype.evaluate = function evaluate(vm) { - return vm.getSelf(); - }; + for (var idx = startAt; idx < len; idx++) { + var currentObj = objectAt(this, idx); - CompiledSelf.prototype.toJSON = function toJSON() { - return 'self'; - }; + // SameValueZero comparison (NaN !== NaN) + if (obj === currentObj || obj !== obj && currentObj !== currentObj) { + return true; + } + } - return CompiledSelf; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + return false; + }, _Mixin$create['@each'] = _emberMetal.computed(function () { + // TODO use Symbol or add to meta + if (!this.__each) { + this.__each = new _emberRuntimeSystemEach_proxy.default(this); + } - exports.CompiledSelf = CompiledSelf; + return this.__each; + }).volatile().readOnly(), _Mixin$create)); - var CompiledSymbol = (function (_CompiledExpression3) { - babelHelpers.inherits(CompiledSymbol, _CompiledExpression3); + exports.default = ArrayMixin; +}); +// ES6TODO: Ember.A - function CompiledSymbol(symbol, debug) { - _CompiledExpression3.call(this); - this.symbol = symbol; - this.debug = debug; - } +/** + __Required.__ You must implement this method to apply this mixin. + Your array must support the `length` property. Your replace methods should + set this property whenever it changes. + @property {Number} length + @public +*/ - CompiledSymbol.prototype.evaluate = function evaluate(vm) { - return vm.referenceForSymbol(this.symbol); - }; +/** + Returns the object at the given `index`. If the given `index` is negative + or is greater or equal than the array length, returns `undefined`. + This is one of the primitives you must implement to support `Ember.Array`. + If your object supports retrieving the value of an array item using `get()` + (i.e. `myArray.get(0)`), then you do not need to implement this method + yourself. + ```javascript + let arr = ['a', 'b', 'c', 'd']; + arr.objectAt(0); // 'a' + arr.objectAt(3); // 'd' + arr.objectAt(-1); // undefined + arr.objectAt(4); // undefined + arr.objectAt(5); // undefined + ``` + @method objectAt + @param {Number} idx The index of the item to return. + @return {*} item at index or undefined + @public +*/ - CompiledSymbol.prototype.toJSON = function toJSON() { - return '$' + this.symbol + '(' + this.debug + ')'; - }; +/** + This returns the objects at the specified indexes, using `objectAt`. + ```javascript + let arr = ['a', 'b', 'c', 'd']; + arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] + arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] + ``` + @method objectsAt + @param {Array} indexes An array of indexes of items to return. + @return {Array} + @public + */ - return CompiledSymbol; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); +// overrides Ember.Enumerable version - exports.CompiledSymbol = CompiledSymbol; +/** + 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 + array, it will replace the current content. + This property overrides the default property defined in `Ember.Enumerable`. + @property [] + @return this + @public +*/ - var CompiledInPartialName = (function (_CompiledExpression4) { - babelHelpers.inherits(CompiledInPartialName, _CompiledExpression4); +// optimized version from Enumerable - function CompiledInPartialName(symbol, name) { - _CompiledExpression4.call(this); - this.symbol = symbol; - this.name = name; - } +// Add any extra methods to Ember.Array that are native to the built-in Array. +/** + Returns a new array that is a slice of the receiver. This implementation + uses the observable array methods to retrieve the objects for the new + slice. + ```javascript + let arr = ['red', 'green', 'blue']; + arr.slice(0); // ['red', 'green', 'blue'] + arr.slice(0, 2); // ['red', 'green'] + arr.slice(1, 100); // ['green', 'blue'] + ``` + @method slice + @param {Number} beginIndex (Optional) index to begin slicing from. + @param {Number} endIndex (Optional) index to end the slice at (but not included). + @return {Array} New array with specified slice + @public +*/ - CompiledInPartialName.prototype.evaluate = function evaluate(vm) { - var symbol = this.symbol; - var name = this.name; +/** + Returns the index of the given object's first occurrence. + If no `startAt` argument is given, the starting location to + search is 0. If it's negative, will count backward from + the end of the array. Returns -1 if no match is found. + ```javascript + let arr = ['a', 'b', 'c', 'd', 'a']; + arr.indexOf('a'); // 0 + arr.indexOf('z'); // -1 + arr.indexOf('a', 2); // 4 + arr.indexOf('a', -1); // 4 + arr.indexOf('b', 3); // -1 + arr.indexOf('a', 100); // -1 + ``` + @method indexOf + @param {Object} object the item to search for + @param {Number} startAt optional starting location to search, default 0 + @return {Number} index or -1 if not found + @public +*/ - var args = vm.scope().getPartialArgs(symbol); - return args.named.get(name); - }; +/** + Returns the index of the given object's last occurrence. + If no `startAt` argument is given, the search starts from + the last position. If it's negative, will count backward + from the end of the array. Returns -1 if no match is found. + ```javascript + let arr = ['a', 'b', 'c', 'd', 'a']; + arr.lastIndexOf('a'); // 4 + arr.lastIndexOf('z'); // -1 + arr.lastIndexOf('a', 2); // 0 + arr.lastIndexOf('a', -1); // 4 + arr.lastIndexOf('b', 3); // 1 + arr.lastIndexOf('a', 100); // 4 + ``` + @method lastIndexOf + @param {Object} object the item to search for + @param {Number} startAt optional starting location to search, default 0 + @return {Number} index or -1 if not found + @public +*/ - CompiledInPartialName.prototype.toJSON = function toJSON() { - return '$' + this.symbol + '($ARGS).' + this.name; - }; +// .......................................................... +// ARRAY OBSERVERS +// - return CompiledInPartialName; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); +/** + Adds an array observer to the receiving array. The array observer object + normally must implement two methods: + * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be + called just before the array is modified. + * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be + called just after the array is modified. + Both callbacks will be passed the observed object, starting index of the + change as well as a count of the items to be removed and added. You can use + these callbacks to optionally inspect the array during the change, clear + caches, or do any other bookkeeping necessary. + In addition to passing a target, you can also include an options hash + which you can use to override the method names that will be invoked on the + target. + @method addArrayObserver + @param {Object} target The observer object. + @param {Object} opts Optional hash of configuration options including + `willChange` and `didChange` option. + @return {Ember.Array} receiver + @public +*/ - exports.CompiledInPartialName = CompiledInPartialName; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvbG9va3Vwcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFNQSxjQUFBOzhCQUFBLGNBQUE7O0FBV0UsaUJBWEYsY0FBQSxDQVlZLElBQWdDLEVBQ2hDLElBQWMsRUFBQTtBQUV0QiwwQ0FBTyxDQUFDO0FBSEEsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUE0QjtBQUNoQyxnQkFBQSxDQUFBLElBQUksR0FBSixJQUFJLENBQVU7QUFaakIsZ0JBQUEsQ0FBQSxJQU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xuXG5leHBvcnQgY2xhc3MgQ29tcGlsZWRJblBhcnRpYWxOYW1lIGV4dGVuZHMgQ29tcGlsZWRFeHByZXNzaW9uPE9wYXF1ZT4ge1xuICBjb25zdHJ1Y3Rvcihwcml2YXRlIHN5bWJvbDogbnVtYmVyLCBwcml2YXRlIG5hbWU6IHN0cmluZykge1xuICAgIHN1cGVyKCk7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIGxldCB7IHN5bWJvbCwgbmFtZSB9ID0gdGhpcztcbiAgICBsZXQgYXJncyA9IHZtLnNjb3BlKCkuZ2V0UGFydGlhbEFyZ3Moc3ltYm9sKTtcbiAgICByZXR1cm4gYXJncy5uYW1lZC5nZXQobmFtZSk7XG4gIH1cblxuICB0b0pTT04oKTogc3RyaW5nIHtcbiAgICByZXR1cm4gYCQke3RoaXMuc3ltYm9sfSgkQVJHUykuJHt0aGlzLm5hbWV9YDtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/named-args', ['exports', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/utils', 'glimmer-reference', 'glimmer-util'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibUtils, _glimmerReference, _glimmerUtil) { - 'use strict'; +/** + Removes an array observer from the object if the observer is current + registered. Calling this method multiple times with the same object will + have no effect. + @method removeArrayObserver + @param {Object} target The object observing the array. + @param {Object} opts Optional hash of configuration options including + `willChange` and `didChange` option. + @return {Ember.Array} receiver + @public +*/ - var CompiledNamedArgs = (function () { - function CompiledNamedArgs(keys, values) { - this.keys = keys; - this.values = values; - this.length = keys.length; - _glimmerUtil.assert(keys.length === values.length, 'Keys and values do not have the same length'); - } +/** + Becomes true whenever the array currently has observers watching changes + on the array. + @property {Boolean} hasArrayObservers + @public +*/ - CompiledNamedArgs.empty = function empty() { - return COMPILED_EMPTY_NAMED_ARGS; - }; +/** + If you are implementing an object that supports `Ember.Array`, call this + method just before the array content changes to notify any observers and + invalidate any related properties. Pass the starting index of the change + as well as a delta of the amounts to change. + @method arrayContentWillChange + @param {Number} startIdx The starting index in the array that will change. + @param {Number} removeAmt The number of items that will be removed. If you + pass `null` assumes 0 + @param {Number} addAmt The number of items that will be added. If you + pass `null` assumes 0. + @return {Ember.Array} receiver + @public +*/ - CompiledNamedArgs.create = function create(map) { - var keys = Object.keys(map); - var length = keys.length; - if (length > 0) { - var values = []; - for (var i = 0; i < length; i++) { - values[i] = map[keys[i]]; - } - return new this(keys, values); - } else { - return COMPILED_EMPTY_NAMED_ARGS; - } - }; +/** + If you are implementing an object that supports `Ember.Array`, call this + method just after the array content changes to notify any observers and + invalidate any related properties. Pass the starting index of the change + as well as a delta of the amounts to change. + @method arrayContentDidChange + @param {Number} startIdx The starting index in the array that did change. + @param {Number} removeAmt The number of items that were removed. If you + pass `null` assumes 0 + @param {Number} addAmt The number of items that were added. If you + pass `null` assumes 0. + @return {Ember.Array} receiver + @public +*/ - CompiledNamedArgs.prototype.evaluate = function evaluate(vm) { - var keys = this.keys; - var values = this.values; - var length = this.length; +/** + Returns `true` if the passed object can be found in the array. + This method is a Polyfill for ES 2016 Array.includes. + If no `startAt` argument is given, the starting location to + search is 0. If it's negative, searches from the index of + `this.length + startAt` by asc. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, 3].includes(3, 2); // true + [1, 2, 3].includes(3, 3); // false + [1, 2, 3].includes(3, -1); // true + [1, 2, 3].includes(1, -1); // false + [1, 2, 3].includes(1, -4); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @param {Number} startAt optional starting location to search, default 0 + @return {Boolean} `true` if object is found in the array. + @public +*/ - var evaluated = new Array(length); - for (var i = 0; i < length; i++) { - evaluated[i] = values[i].evaluate(vm); - } - return new EvaluatedNamedArgs(keys, evaluated); - }; +/** + Returns a special object that can be used to observe individual properties + on the array. Just get an equivalent property on this object and it will + return an enumerable that maps automatically to the named key on the + member objects. + `@each` should only be used in a non-terminal context. Example: + ```javascript + myMethod: computed('posts.@each.author', function(){ + ... + }); + ``` + If you merely want to watch for the array being changed, like an object being + replaced, added or removed, use `[]` instead of `@each`. + ```javascript + myMethod: computed('posts.[]', function(){ + ... + }); + ``` + @property @each + @public +*/ +enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - CompiledNamedArgs.prototype.toJSON = function toJSON() { - var keys = this.keys; - var values = this.values; + /** + @module ember + @submodule ember-runtime + */ - var inner = keys.map(function (key, i) { - return key + ': ' + values[i].toJSON(); - }).join(", "); - return '{' + inner + '}'; - }; + /** + Implements some standard methods for comparing objects. Add this mixin to + any class you create that can compare its instances. + + You should implement the `compare()` method. + + @class Comparable + @namespace Ember + @since Ember 0.9 + @private + */ + exports.default = _emberMetal.Mixin.create({ - return CompiledNamedArgs; - })(); + /** + __Required.__ You must implement this method to apply this mixin. + Override to return the result of the comparison of the two parameters. The + compare method should return: + - `-1` if `a < b` + - `0` if `a == b` + - `1` if `a > b` + Default implementation raises an exception. + @method compare + @param a {Object} the first object to compare + @param b {Object} the second object to compare + @return {Number} the result of the comparison + @private + */ + compare: null + }); +}); +enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal', 'container'], function (exports, _emberMetal, _container) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - exports.CompiledNamedArgs = CompiledNamedArgs; - var COMPILED_EMPTY_NAMED_ARGS = new ((function (_CompiledNamedArgs) { - babelHelpers.inherits(_class, _CompiledNamedArgs); + var _containerProxyMixin; - function _class() { - _CompiledNamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + /** + ContainerProxyMixin is used to provide public access to specific + container functionality. + + @class ContainerProxyMixin + @private + */ + var containerProxyMixin = (_containerProxyMixin = { + /** + The container stores state. + @private + @property {Ember.Container} __container__ + */ + __container__: null, - _class.prototype.evaluate = function evaluate(vm) { - return EVALUATED_EMPTY_NAMED_ARGS; - }; + /** + Returns an object that can be used to provide an owner to a + manually created instance. + Example: + ``` + let owner = Ember.getOwner(this); + User.create( + owner.ownerInjection(), + { username: 'rwjblue' } + ) + ``` + @public + @method ownerInjection + @since 2.3.0 + @return {Object} + */ + ownerInjection: function () { + return this.__container__.ownerInjection(); + }, - _class.prototype.toJSON = function toJSON() { - return ''; - }; + /** + Given a fullName return a corresponding instance. + The default behaviour is for lookup to return a singleton instance. + The singleton is scoped to the container, allowing multiple containers + to all have their own locally scoped singletons. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter'); + twitter instanceof Twitter; // => true + // by default the container will return singletons + let twitter2 = container.lookup('api:twitter'); + twitter2 instanceof Twitter; // => true + twitter === twitter2; //=> true + ``` + If singletons are not wanted an optional flag can be provided at lookup. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter', { singleton: false }); + let twitter2 = container.lookup('api:twitter', { singleton: false }); + twitter === twitter2; //=> false + ``` + @public + @method lookup + @param {String} fullName + @param {Object} options + @return {any} + */ + lookup: function (fullName, options) { + return this.__container__.lookup(fullName, options); + }, - return _class; - })(CompiledNamedArgs))(); - exports.COMPILED_EMPTY_NAMED_ARGS = COMPILED_EMPTY_NAMED_ARGS; - - var EvaluatedNamedArgs = (function () { - function EvaluatedNamedArgs(keys, values) { - var _map = arguments.length <= 2 || arguments[2] === undefined ? undefined : arguments[2]; - - this.keys = keys; - this.values = values; - this._map = _map; - this.tag = _glimmerReference.combineTagged(values); - this.length = keys.length; - _glimmerUtil.assert(keys.length === values.length, 'Keys and values do not have the same length'); - } - - EvaluatedNamedArgs.create = function create(map) { - var keys = Object.keys(map); - var length = keys.length; - if (length > 0) { - var values = new Array(length); - for (var i = 0; i < length; i++) { - values[i] = map[keys[i]]; - } - return new this(keys, values, map); - } else { - return EVALUATED_EMPTY_NAMED_ARGS; - } - }; + /** + Given a fullName return the corresponding factory. + @private + @method _lookupFactory + @param {String} fullName + @return {any} + */ + _lookupFactory: function (fullName, options) { + return this.__container__.lookupFactory(fullName, options); + } - EvaluatedNamedArgs.empty = function empty() { - return EVALUATED_EMPTY_NAMED_ARGS; - }; + }, _containerProxyMixin[_container.FACTORY_FOR] = function () { + var _container__; - EvaluatedNamedArgs.prototype.get = function get(key) { - var keys = this.keys; - var values = this.values; + return (_container__ = this.__container__)[_container.FACTORY_FOR].apply(_container__, arguments); + }, _containerProxyMixin[_container.LOOKUP_FACTORY] = function () { + var _container__2; - var index = keys.indexOf(key); - return index === -1 ? _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE : values[index]; - }; + return (_container__2 = this.__container__)[_container.LOOKUP_FACTORY].apply(_container__2, arguments); + }, _containerProxyMixin._resolveLocalLookupName = function (name, source) { + return this.__container__.registry.expandLocalLookup('component:' + name, { + source: source + }); + }, _containerProxyMixin.willDestroy = function () { + this._super.apply(this, arguments); - EvaluatedNamedArgs.prototype.has = function has(key) { - return this.keys.indexOf(key) !== -1; - }; + if (this.__container__) { + _emberMetal.run(this.__container__, 'destroy'); + } + }, _containerProxyMixin); - EvaluatedNamedArgs.prototype.value = function value() { - var keys = this.keys; - var values = this.values; + if (true) { + containerProxyMixin.factoryFor = function ContainerProxyMixin_factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var out = _glimmerUtil.dict(); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var ref = values[i]; - out[key] = ref.value(); - } - return out; - }; + return this.__container__.factoryFor(fullName, options); + }; + } - babelHelpers.createClass(EvaluatedNamedArgs, [{ - key: 'map', - get: function () { - var map = this._map; + exports.default = _emberMetal.Mixin.create(containerProxyMixin); +}); - if (map) { - return map; - } - map = this._map = _glimmerUtil.dict(); - var keys = this.keys; - var values = this.values; - var length = this.length; +/** + Given a name and a source path, resolve the fullName + @private + @method _resolveLocalLookupName + @param {String} fullName + @param {String} source + @return {String} + */ - for (var i = 0; i < length; i++) { - map[keys[i]] = values[i]; - } - return map; - } - }]); - return EvaluatedNamedArgs; - })(); +/** + @private + */ +enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) { + 'use strict'; - exports.EvaluatedNamedArgs = EvaluatedNamedArgs; - var EVALUATED_EMPTY_NAMED_ARGS = new ((function (_EvaluatedNamedArgs) { - babelHelpers.inherits(_class2, _EvaluatedNamedArgs); + /** + @class ControllerMixin + @namespace Ember + @uses Ember.ActionHandler + @private + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, { + /* ducktype as a controller */ + isController: true, - function _class2() { - _EvaluatedNamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_DICT); - } + /** + The object to which actions from the view should be sent. + For example, when a Handlebars template uses the `{{action}}` helper, + it will attempt to send the action to the view's controller's `target`. + By default, the value of the target property is set to the router, and + is injected when a controller is instantiated. This injection is applied + as part of the application's initialization process. In most cases the + `target` property will automatically be set to the logical consumer of + actions for the controller. + @property target + @default null + @public + */ + target: null, - _class2.prototype.get = function get() { - return _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + store: null, - _class2.prototype.has = function has(key) { - return false; - }; + /** + The controller's current model. When retrieving or modifying a controller's + model, this property should be used instead of the `content` property. + @property model + @public + */ + model: null, - _class2.prototype.value = function value() { - return _glimmerRuntimeLibUtils.EMPTY_DICT; - }; + /** + @private + */ + content: _emberMetal.alias('model') - return _class2; - })(EvaluatedNamedArgs))(); - exports.EVALUATED_EMPTY_NAMED_ARGS = EVALUATED_EMPTY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XNbaV07XG4gICAgICBvdXRba2V5XSA9IHJlZi52YWx1ZSgpO1xuICAgIH1cblxuICAgIHJldHVybiBvdXQ7XG4gIH1cbn1cblxuZXhwb3J0IGNvbnN0IEVWQUxVQVRFRF9FTVBUWV9OQU1FRF9BUkdTOiBFdmFsdWF0ZWROYW1lZEFyZ3MgPSBuZXcgKGNsYXNzIGV4dGVuZHMgRXZhbHVhdGVkTmFtZWRBcmdzIHtcbiAgY29uc3RydWN0b3IoKSB7XG4gICAgc3VwZXIoRU1QVFlfQVJSQVksIEVNUFRZX0FSUkFZLCBFTVBUWV9ESUNUKTtcbiAgfVxuXG4gIGdldCgpOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIHJldHVybiBVTkRFRklORURfUkVGRVJFTkNFO1xuICB9XG5cbiAgaGFzKGtleTogc3RyaW5nKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuIGZhbHNlO1xuICB9XG5cbiAgdmFsdWUoKTogRGljdDxPcGFxdWU+IHtcbiAgICByZXR1cm4gRU1QVFlfRElDVDtcbiAgfVxufSk7XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/positional-args', ['exports', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/utils', 'glimmer-reference'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibUtils, _glimmerReference) { - 'use strict'; +enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - var CompiledPositionalArgs = (function () { - function CompiledPositionalArgs(values) { - this.values = values; - this.length = values.length; - } + /* + The ControllerContentModelAliasDeprecation mixin is used to provide a useful + deprecation warning when specifying `content` directly on a `Ember.Controller` + (without also specifying `model`). + + Ember versions prior to 1.7 used `model` as an alias of `content`, but due to + much confusion this alias was reversed (so `content` is now an alias of `model). + + This change reduces many caveats with model/content, and also sets a + simple ground rule: Never set a controllers content, rather always set + its model and ember will do the right thing. + + Used internally by Ember in `Ember.Controller`. + */ + exports.default = _emberMetal.Mixin.create({ + /** + @private + Moves `content` to `model` at extend time if a `model` is not also specified. + Note that this currently modifies the mixin themselves, which is technically + dubious but is practically of little consequence. This may change in the + future. + @method willMergeMixin + @since 1.4.0 + */ + willMergeMixin: function (props) { + // Calling super is only OK here since we KNOW that + // there is another Mixin loaded first. + this._super.apply(this, arguments); - CompiledPositionalArgs.create = function create(values) { - if (values.length) { - return new this(values); - } else { - return COMPILED_EMPTY_POSITIONAL_ARGS; - } - }; + var modelSpecified = !!props.model; - CompiledPositionalArgs.empty = function empty() { - return COMPILED_EMPTY_POSITIONAL_ARGS; - }; + if (props.content && !modelSpecified) { + props.model = props.content; + delete props['content']; - CompiledPositionalArgs.prototype.evaluate = function evaluate(vm) { - var values = this.values; - var length = this.length; + _emberMetal.deprecate('Do not specify `content` on a Controller, use `model` instead.', false, { id: 'ember-runtime.will-merge-mixin', until: '3.0.0' }); + } + } + }); +}); +enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal', 'ember-runtime/mixins/freezable'], function (exports, _emberMetal, _emberRuntimeMixinsFreezable) { + /** + @module ember + @submodule ember-runtime + */ - var references = new Array(length); - for (var i = 0; i < length; i++) { - references[i] = values[i].evaluate(vm); - } - return EvaluatedPositionalArgs.create(references); - }; + 'use strict'; - CompiledPositionalArgs.prototype.toJSON = function toJSON() { - return '[' + this.values.map(function (value) { - return value.toJSON(); - }).join(", ") + ']'; - }; + /** + Implements some standard methods for copying an object. Add this mixin to + any object you create that can create a copy of itself. This mixin is + added automatically to the built-in array. + + You should generally implement the `copy()` method to return a copy of the + receiver. + + Note that `frozenCopy()` will only work if you also implement + `Ember.Freezable`. + + @class Copyable + @namespace Ember + @since Ember 0.9 + @private + */ + exports.default = _emberMetal.Mixin.create({ + /** + __Required.__ You must implement this method to apply this mixin. + Override to return a copy of the receiver. Default implementation raises + an exception. + @method copy + @param {Boolean} deep if `true`, a deep copy of the object should be made + @return {Object} copy of receiver + @private + */ + copy: null, - return CompiledPositionalArgs; - })(); + /** + If the object implements `Ember.Freezable`, then this will return a new + copy if the object is not frozen and the receiver if the object is frozen. + Raises an exception if you try to call this method on a object that does + not support freezing. + You should use this method whenever you want a copy of a freezable object + since a freezable object can simply return itself without actually + consuming more memory. + @method frozenCopy + @return {Object} copy of receiver or receiver + @deprecated Use `Object.freeze` instead. + @private + */ + frozenCopy: function () { + _emberMetal.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.frozen-copy', until: '3.0.0' }); + if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) { + return _emberMetal.get(this, 'isFrozen') ? this : this.copy().freeze(); + } else { + throw new _emberMetal.Error(this + ' does not support freezing'); + } + } + }); +}); +enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'require'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _require) { + /** + @module ember + @submodule ember-runtime + */ - exports.CompiledPositionalArgs = CompiledPositionalArgs; - var COMPILED_EMPTY_POSITIONAL_ARGS = new ((function (_CompiledPositionalArgs) { - babelHelpers.inherits(_class, _CompiledPositionalArgs); + // .......................................................... + // HELPERS + // - function _class() { - _CompiledPositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + 'use strict'; - _class.prototype.evaluate = function evaluate(vm) { - return EVALUATED_EMPTY_POSITIONAL_ARGS; - }; + var _emberA = undefined; - _class.prototype.toJSON = function toJSON() { - return ''; - }; + function emberA() { + return (_emberA || (_emberA = _require.default('ember-runtime/system/native_array').A))(); + } - return _class; - })(CompiledPositionalArgs))(); - exports.COMPILED_EMPTY_POSITIONAL_ARGS = COMPILED_EMPTY_POSITIONAL_ARGS; + var contexts = []; - var EvaluatedPositionalArgs = (function () { - function EvaluatedPositionalArgs(values) { - this.values = values; - this.tag = _glimmerReference.combineTagged(values); - this.length = values.length; - } + function popCtx() { + return contexts.length === 0 ? {} : contexts.pop(); + } - EvaluatedPositionalArgs.create = function create(values) { - return new this(values); - }; + function pushCtx(ctx) { + contexts.push(ctx); + return null; + } - EvaluatedPositionalArgs.empty = function empty() { - return EVALUATED_EMPTY_POSITIONAL_ARGS; - }; + function iter(key, value) { + var valueProvided = arguments.length === 2; - EvaluatedPositionalArgs.prototype.at = function at(index) { - var values = this.values; - var length = this.length; + function i(item) { + var cur = _emberMetal.get(item, key); + return valueProvided ? value === cur : !!cur; + } - return index < length ? values[index] : _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + return i; + } - EvaluatedPositionalArgs.prototype.value = function value() { - var values = this.values; - var length = this.length; + /** + This mixin defines the common interface implemented by enumerable objects + in Ember. Most of these methods follow the standard Array iteration + API defined up to JavaScript 1.8 (excluding language-specific features that + cannot be emulated in older versions of JavaScript). + + This mixin is applied automatically to the Array class on page load, so you + can use any of these methods on simple arrays. If Array already implements + one of these methods, the mixin will not override them. + + ## Writing Your Own Enumerable + + To make your own custom class enumerable, you need two items: + + 1. You must have a length property. This property should change whenever + the number of items in your enumerable object changes. If you use this + with an `Ember.Object` subclass, you should be sure to change the length + property using `set().` + + 2. You must implement `nextObject().` See documentation. + + Once you have these two methods implemented, apply the `Ember.Enumerable` mixin + to your class and you will be able to enumerate the contents of your object + like any other collection. + + ## Using Ember Enumeration with Other Libraries + + Many other libraries provide some kind of iterator or enumeration like + facility. This is often where the most common API conflicts occur. + Ember's API is designed to be as friendly as possible with other + libraries by implementing only methods that mostly correspond to the + JavaScript 1.8 API. + + @class Enumerable + @namespace Ember + @since Ember 0.9 + @private + */ + var Enumerable = _emberMetal.Mixin.create({ - var ret = new Array(length); - for (var i = 0; i < length; i++) { - ret[i] = values[i].value(); - } - return ret; - }; + /** + __Required.__ You must implement this method to apply this mixin. + Implement this method to make your class enumerable. + This method will be called repeatedly during enumeration. The index value + will always begin with 0 and increment monotonically. You don't have to + rely on the index value to determine what object to return, but you should + always check the value and start from the beginning when you see the + requested index is 0. + The `previousObject` is the object that was returned from the last call + to `nextObject` for the current iteration. This is a useful way to + manage iteration if you are tracing a linked list, for example. + Finally the context parameter will always contain a hash you can use as + a "scratchpad" to maintain any other state you need in order to iterate + properly. The context object is reused and is not reset between + iterations so make sure you setup the context with a fresh state whenever + the index parameter is 0. + Generally iterators will continue to call `nextObject` until the index + reaches the current length-1. If you run out of data before this + time for some reason, you should simply return undefined. + The default implementation of this method simply looks up the index. + This works great on any Array-like objects. + @method nextObject + @param {Number} index the current index of the iteration + @param {Object} previousObject the value returned by the last call to + `nextObject`. + @param {Object} context a context object you can use to maintain state. + @return {Object} the next object in the iteration or undefined + @private + */ + nextObject: null, - return EvaluatedPositionalArgs; - })(); + /** + Helper method returns the first object from a collection. This is usually + used by bindings and other parts of the framework to extract a single + object if the enumerable contains only one item. + If you override this method, you should implement it so that it will + always return the same value each time it is called. If your enumerable + contains only one object, this method should always return that object. + If your enumerable is empty, this method should return `undefined`. + ```javascript + let arr = ['a', 'b', 'c']; + arr.get('firstObject'); // 'a' + let arr = []; + arr.get('firstObject'); // undefined + ``` + @property firstObject + @return {Object} the object or undefined + @readOnly + @public + */ + firstObject: _emberMetal.computed('[]', function () { + if (_emberMetal.get(this, 'length') === 0) { + return undefined; + } - exports.EvaluatedPositionalArgs = EvaluatedPositionalArgs; - var EVALUATED_EMPTY_POSITIONAL_ARGS = new ((function (_EvaluatedPositionalArgs) { - babelHelpers.inherits(_class2, _EvaluatedPositionalArgs); + // handle generic enumerables + var context = popCtx(); + var ret = this.nextObject(0, null, context); - function _class2() { - _EvaluatedPositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + pushCtx(context); - _class2.prototype.at = function at() { - return _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + return ret; + }).readOnly(), - _class2.prototype.value = function value() { - return this.values; - }; + /** + Helper method returns the last object from a collection. If your enumerable + contains only one object, this method should always return that object. + If your enumerable is empty, this method should return `undefined`. + ```javascript + let arr = ['a', 'b', 'c']; + arr.get('lastObject'); // 'c' + let arr = []; + arr.get('lastObject'); // undefined + ``` + @property lastObject + @return {Object} the last object or undefined + @readOnly + @public + */ + lastObject: _emberMetal.computed('[]', function () { + var len = _emberMetal.get(this, 'length'); - return _class2; - })(EvaluatedPositionalArgs))(); - exports.EVALUATED_EMPTY_POSITIONAL_ARGS = EVALUATED_EMPTY_POSITIONAL_ARGS; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvcG9zaXRpb25hbC1hcmdzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQU9BLHNCQUFBO0FBZUUsaUJBZkYsc0JBQUEsQ0FlcUIsTUFBb0MsRUFBQTtBQUFwQyxnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQThCO0FBQ3JELGdCQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUM7U0FDN0I7O0FBakJILDhCQUFBLENBQ1MsTUFBTSxHQUFBLGdCQUFDLE1BQW9DLEVBQUE7QUFDaEQsZ0JBQUksTUFBTSxDQUFDLE1BQU0sRUFBRTtBQUNqQix1QkFBTyxJQUFJLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQzthQUN6QixNQUFNO0FBQ0wsdUJBQU8sOEJBQThCLENBQUM7YUFDdkM7U0FDRjs7QUFQSCw4QkFBQSxDQVNTLEtBQUssR0FBQSxpQkFBQTtBQUNWLG1CQUFPLDhCQUE4QixDQUFDO1NBQ3ZDOztBQVhILDhCQUFBLFdBbUJFLFFBQVEsR0FBQSxrQkFBQyxFQUFNLEVBQUE7Z0JBQ1AsTUFBTSxHQUFhLElBQUksQ0FBdkIsTUFBTTtnQkFBRSxNQUFNLEdBQUssSUFBSSxDQUFmLE1BQU07O0FBQ3BCLGdCQUFJLFVBQVUsR0FBNEIsSUFBSSxLQUFLLENBQUMsTUFBTS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HtcbiAgICAgIHJldFtpXSA9IHZhbHVlc1tpXS52YWx1ZSgpO1xuICAgIH1cblxuICAgIHJldHVybiByZXQ7XG4gIH1cbn1cblxuZXhwb3J0IGNvbnN0IEVWQUxVQVRFRF9FTVBUWV9QT1NJVElPTkFMX0FSR1M6IEV2YWx1YXRlZFBvc2l0aW9uYWxBcmdzID0gbmV3IChjbGFzcyBleHRlbmRzIEV2YWx1YXRlZFBvc2l0aW9uYWxBcmdzIHtcbiAgY29uc3RydWN0b3IoKSB7XG4gICAgc3VwZXIoRU1QVFlfQVJSQVkpO1xuICB9XG5cbiAgYXQoKTogUGF0aFJlZmVyZW5jZTxPcGFxdWU+IHtcbiAgICByZXR1cm4gVU5ERUZJTkVEX1JFRkVSRU5DRTtcbiAgfVxuXG4gIHZhbHVlKCk6IE9wYXF1ZVtdIHtcbiAgICByZXR1cm4gdGhpcy52YWx1ZXM7XG4gIH1cbn0pO1xuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/value', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/references'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibReferences) { - 'use strict'; + if (len === 0) { + return undefined; + } - var CompiledValue = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledValue, _CompiledExpression); + var context = popCtx(); + var idx = 0; + var last = null; + var cur = undefined; - function CompiledValue(value) { - _CompiledExpression.call(this); - this.type = "value"; - this.reference = _glimmerRuntimeLibReferences.PrimitiveReference.create(value); - } + do { + last = cur; + cur = this.nextObject(idx++, last, context); + } while (cur !== undefined); - CompiledValue.prototype.evaluate = function evaluate(vm) { - return this.reference; - }; + pushCtx(context); - CompiledValue.prototype.toJSON = function toJSON() { - return JSON.stringify(this.reference.value()); - }; + return last; + }).readOnly(), - return CompiledValue; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + /** + Returns `true` if the passed object can be found in the receiver. The + default version will iterate through the enumerable until the object + is found. You may want to override this with a more efficient version. + ```javascript + let arr = ['a', 'b', 'c']; + arr.contains('a'); // true + arr.contains('z'); // false + ``` + @method contains + @deprecated Use `Enumerable#includes` instead. See http://emberjs.com/deprecations/v2.x#toc_enumerable-contains + @param {Object} obj The object to search for. + @return {Boolean} `true` if object is found in enumerable. + @public + */ + contains: function (obj) { + _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - exports.default = CompiledValue; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvdmFsdWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBSUEsYUFBQTs4QkFBQSxhQUFBOztBQUlFLGlCQUpGLGFBQUEsQ0FJYyxLQUFRLEVBQUE7QUFDbEIsMENBQU8sQ0FBQztBQUpILGdCQUFBLENBQUEsSUFBSSxHQUFHLE9BQU8sQ0FBQztBQUtwQixnQkFBSSxDQUFDLFNBQVMsR0FBRyw2QkFSRCxrQkFBa0IsQ0FRRSxNQUFNLENBQUMsS0FBWSxDQUFDLENBQUM7U0FDMUQ7O0FBUEgscUJBQUEsV0FTRSxRQUFRLEdBQUEsa0JBQUMsRUFBTSxFQUFBO0FBQ2IsbUJBQU8sSUFBSSxDQUFDLFNBQVMsQ0FBQztTQUN2Qjs7QUFYSCxxQkFBQSxXQWFFLE1BQU0sR0FBQSxrQkFBQTtBQUNKLG1CQUFPLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxLQUFLLEVBQUUsQ0FBQyxDQUFDO1NBQy9DOztlQWZILGFBQUE7NkNBSFMsa0JBQWtCOztzQkFHM0IsYUFBQSIsImZpbGUiOiJ2YWx1ZS5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFZNIH0gZnJvbSAnLi4vLi4vdm0nO1xuaW1wb3J0IHsgQ29tcGlsZWRFeHByZXNzaW9uIH0gZnJvbSAnLi4vZXhwcmVzc2lvbnMnO1xuaW1wb3J0IHsgUHJpbWl0aXZlLCBQcmltaXRpdmVSZWZlcmVuY2UgfSBmcm9tICcuLi8uLi9yZWZlcmVuY2VzJztcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgQ29tcGlsZWRWYWx1ZTxUIGV4dGVuZHMgUHJpbWl0aXZlPiBleHRlbmRzIENvbXBpbGVkRXhwcmVzc2lvbjxUPiB7XG4gIHB1YmxpYyB0eXBlID0gXCJ2YWx1ZVwiO1xuICBwcml2YXRlIHJlZmVyZW5jZTogUHJpbWl0aXZlUmVmZXJlbmNlPFQ+O1xuXG4gIGNvbnN0cnVjdG9yKHZhbHVlOiBUKSB7XG4gICAgc3VwZXIoKTtcbiAgICB0aGlzLnJlZmVyZW5jZSA9IFByaW1pdGl2ZVJlZmVyZW5jZS5jcmVhdGUodmFsdWUgYXMgYW55KTtcbiAgfVxuXG4gIGV2YWx1YXRlKHZtOiBWTSk6IFByaW1pdGl2ZVJlZmVyZW5jZTxUPiB7XG4gICAgcmV0dXJuIHRoaXMucmVmZXJlbmNlO1xuICB9XG5cbiAgdG9KU09OKCk6IHN0cmluZyB7XG4gICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHRoaXMucmVmZXJlbmNlLnZhbHVlKCkpO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/opcodes/builder', ['exports', 'glimmer-runtime/lib/compiled/opcodes/component', 'glimmer-runtime/lib/compiled/opcodes/partial', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/compiled/opcodes/dom', 'glimmer-runtime/lib/compiled/opcodes/lists', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-util', 'glimmer-runtime/lib/utils'], function (exports, _glimmerRuntimeLibCompiledOpcodesComponent, _glimmerRuntimeLibCompiledOpcodesPartial, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibCompiledOpcodesDom, _glimmerRuntimeLibCompiledOpcodesLists, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerUtil, _glimmerRuntimeLibUtils) { - 'use strict'; + var found = this.find(function (item) { + return item === obj; + }); - var StatementCompilationBufferProxy = (function () { - function StatementCompilationBufferProxy(inner) { - this.inner = inner; - } + return found !== undefined; + }, - StatementCompilationBufferProxy.prototype.toOpSeq = function toOpSeq() { - return this.inner.toOpSeq(); - }; + /** + Iterates through the enumerable, calling the passed function on each + item. This method corresponds to the `forEach()` method defined in + JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method forEach + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Object} receiver + @public + */ + forEach: function (callback, target) { + if (typeof callback !== 'function') { + throw new TypeError(); + } - StatementCompilationBufferProxy.prototype.append = function append(opcode) { - this.inner.append(opcode); - }; + var context = popCtx(); + var len = _emberMetal.get(this, 'length'); + var last = null; - StatementCompilationBufferProxy.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.inner.getLocalSymbol(name); - }; + if (target === undefined) { + target = null; + } - StatementCompilationBufferProxy.prototype.hasLocalSymbol = function hasLocalSymbol(name) { - return this.inner.hasLocalSymbol(name); - }; + for (var idx = 0; idx < len; idx++) { + var next = this.nextObject(idx, last, context); + callback.call(target, next, idx, this); + last = next; + } - StatementCompilationBufferProxy.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.inner.getNamedSymbol(name); - }; + last = null; + context = pushCtx(context); - StatementCompilationBufferProxy.prototype.hasNamedSymbol = function hasNamedSymbol(name) { - return this.inner.hasNamedSymbol(name); - }; + return this; + }, - StatementCompilationBufferProxy.prototype.getBlockSymbol = function getBlockSymbol(name) { - return this.inner.getBlockSymbol(name); - }; + /** + Alias for `mapBy` + @method getEach + @param {String} key name of the property + @return {Array} The mapped array. + @public + */ + getEach: _emberMetal.aliasMethod('mapBy'), - StatementCompilationBufferProxy.prototype.hasBlockSymbol = function hasBlockSymbol(name) { - return this.inner.hasBlockSymbol(name); - }; + /** + Sets the value on the named property for each member. This is more + ergonomic than using other methods defined on this helper. If the object + implements Ember.Observable, the value will be changed to `set(),` otherwise + it will be set directly. `null` objects are skipped. + @method setEach + @param {String} key The key to set + @param {Object} value The object to set + @return {Object} receiver + @public + */ + setEach: function (key, value) { + return this.forEach(function (item) { + return _emberMetal.set(item, key, value); + }); + }, - StatementCompilationBufferProxy.prototype.getPartialArgsSymbol = function getPartialArgsSymbol() { - return this.inner.getPartialArgsSymbol(); - }; + /** + Maps all of the items in the enumeration to another value, returning + a new array. This method corresponds to `map()` defined in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the mapped value. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method map + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} The mapped array. + @public + */ + map: function (callback, target) { + var ret = emberA(); - StatementCompilationBufferProxy.prototype.hasPartialArgsSymbol = function hasPartialArgsSymbol() { - return this.inner.hasPartialArgsSymbol(); - }; + this.forEach(function (x, idx, i) { + return ret[idx] = callback.call(target, x, idx, i); + }); - babelHelpers.createClass(StatementCompilationBufferProxy, [{ - key: 'component', - get: function () { - return this.inner.component; - } - }]); - return StatementCompilationBufferProxy; - })(); + return ret; + }, - exports.StatementCompilationBufferProxy = StatementCompilationBufferProxy; + /** + Similar to map, this specialized function returns the value of the named + property on all items in the enumeration. + @method mapBy + @param {String} key name of the property + @return {Array} The mapped array. + @public + */ + mapBy: function (key) { + return this.map(function (next) { + return _emberMetal.get(next, key); + }); + }, - var BasicOpcodeBuilder = (function (_StatementCompilationBufferProxy) { - babelHelpers.inherits(BasicOpcodeBuilder, _StatementCompilationBufferProxy); + /** + Returns an array with all of the items in the enumeration that the passed + function returns true for. This method corresponds to `filter()` defined in + JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method filter + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} A filtered array. + @public + */ + filter: function (callback, target) { + var ret = emberA(); - function BasicOpcodeBuilder(inner, symbolTable, env) { - _StatementCompilationBufferProxy.call(this, inner); - this.symbolTable = symbolTable; - this.env = env; - this.labelsStack = new _glimmerUtil.Stack(); + this.forEach(function (x, idx, i) { + if (callback.call(target, x, idx, i)) { + ret.push(x); } + }); - // helpers + return ret; + }, - BasicOpcodeBuilder.prototype.startLabels = function startLabels() { - this.labelsStack.push(_glimmerUtil.dict()); - }; + /** + Returns an array with all of the items in the enumeration where the passed + function returns false. This method is the inverse of filter(). + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - *item* is the current item in the iteration. + - *index* is the current index in the iteration + - *enumerable* is the enumerable object itself. + It should return a falsey value to include the item in the results. + Note that in addition to a callback, you can also pass an optional target + object that will be set as "this" on the context. This is a good way + to give your iterator function access to the current object. + @method reject + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} A rejected array. + @public + */ + reject: function (callback, target) { + return this.filter(function () { + return !callback.apply(target, arguments); + }); + }, - BasicOpcodeBuilder.prototype.stopLabels = function stopLabels() { - this.labelsStack.pop(); - }; + /** + Returns an array with just the items with the matched property. You + can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to `true`. + @method filterBy + @param {String} key the property to test + @param {*} [value] optional value to test against. + @return {Array} filtered array + @public + */ + filterBy: function (key, value) { + return this.filter(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.labelFor = function labelFor(name) { - var labels = this.labels; - var label = labels[name]; - if (!label) { - label = labels[name] = new _glimmerRuntimeLibCompiledOpcodesVm.LabelOpcode(name); - } - return label; - }; + /** + Returns an array with the items that do not have truthy values for + key. You can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to false. + @method rejectBy + @param {String} key the property to test + @param {String} [value] optional value to test against. + @return {Array} rejected array + @public + */ + rejectBy: function (key, value) { + var exactValue = function (item) { + return _emberMetal.get(item, key) === value; + }; + var hasValue = function (item) { + return !!_emberMetal.get(item, key); + }; + var use = arguments.length === 2 ? exactValue : hasValue; - // partials + return this.reject(use); + }, - BasicOpcodeBuilder.prototype.putPartialDefinition = function putPartialDefinition(definition) { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.PutPartialDefinitionOpcode(definition)); - }; + /** + Returns the first item in the array for which the callback returns true. + This method works similar to the `filter()` method defined in JavaScript 1.6 + except that it will stop working on the array once a match is found. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method find + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Object} Found item or `undefined`. + @public + */ + find: function (callback, target) { + var len = _emberMetal.get(this, 'length'); - BasicOpcodeBuilder.prototype.putDynamicPartialDefinition = function putDynamicPartialDefinition() { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.PutDynamicPartialDefinitionOpcode(this.symbolTable)); - }; + if (target === undefined) { + target = null; + } - BasicOpcodeBuilder.prototype.evaluatePartial = function evaluatePartial() { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.EvaluatePartialOpcode(this.symbolTable)); - }; + var context = popCtx(); + var found = false; + var last = null; + var next = undefined, + ret = undefined; - // components + for (var idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); - BasicOpcodeBuilder.prototype.putComponentDefinition = function putComponentDefinition(definition) { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutComponentDefinitionOpcode(definition)); - }; + found = callback.call(target, next, idx, this); + if (found) { + ret = next; + } - BasicOpcodeBuilder.prototype.putDynamicComponentDefinition = function putDynamicComponentDefinition() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutDynamicComponentDefinitionOpcode()); - }; + last = next; + } - BasicOpcodeBuilder.prototype.openComponent = function openComponent(args) { - var shadow = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[1]; + next = last = null; + context = pushCtx(context); - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.OpenComponentOpcode(this.compile(args), shadow)); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.didCreateElement = function didCreateElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.DidCreateElementOpcode()); - }; + /** + Returns the first item with a property matching the passed value. You + can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to `true`. + This method works much like the more generic `find()` method. + @method findBy + @param {String} key the property to test + @param {String} [value] optional value to test against. + @return {Object} found item or `undefined` + @public + */ + findBy: function (key, value) { + return this.find(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.shadowAttributes = function shadowAttributes() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.ShadowAttributesOpcode()); - }; + /** + Returns `true` if the passed function returns true for every item in the + enumeration. This corresponds with the `every()` method in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` or `false`. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + Example Usage: + ```javascript + if (people.every(isEngineer)) { + Paychecks.addBigBonus(); + } + ``` + @method every + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Boolean} + @public + */ + every: function (callback, target) { + return !this.find(function (x, idx, i) { + return !callback.call(target, x, idx, i); + }); + }, - BasicOpcodeBuilder.prototype.didRenderLayout = function didRenderLayout() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.DidRenderLayoutOpcode()); - }; + /** + Returns `true` if the passed property resolves to the value of the second + argument for all items in the enumerable. This method is often simpler/faster + than using a callback. + @method isEvery + @param {String} key the property to test + @param {String} [value] optional value to test against. Defaults to `true` + @return {Boolean} + @since 1.3.0 + @public + */ + isEvery: function (key, value) { + return this.every(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.closeComponent = function closeComponent() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.CloseComponentOpcode()); - }; + /** + Returns `true` if the passed function returns true for any item in the + enumeration. This corresponds with the `some()` method in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + Usage Example: + ```javascript + if (people.any(isManager)) { + Paychecks.addBiggerBonus(); + } + ``` + @method any + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Boolean} `true` if the passed function returns `true` for any item + @public + */ + any: function (callback, target) { + var len = _emberMetal.get(this, 'length'); + var context = popCtx(); + var found = false; + var last = null; + var next = undefined; - // content + if (target === undefined) { + target = null; + } - BasicOpcodeBuilder.prototype.cautiousAppend = function cautiousAppend() { - this.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedCautiousAppendOpcode()); - }; + for (var idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); + found = callback.call(target, next, idx, this); + last = next; + } - BasicOpcodeBuilder.prototype.trustingAppend = function trustingAppend() { - this.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedTrustingAppendOpcode()); - }; + next = last = null; + context = pushCtx(context); + return found; + }, - // dom + /** + Returns `true` if the passed property resolves to the value of the second + argument for any item in 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. Defaults to `true` + @return {Boolean} + @since 1.3.0 + @public + */ + isAny: function (key, value) { + return this.any(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.text = function text(_text) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.TextOpcode(_text)); - }; + /** + This will combine the values of the enumerator into a single value. It + is a useful way to collect a summary value from an enumeration. This + corresponds to the `reduce()` method defined in JavaScript 1.8. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(previousValue, item, index, enumerable); + ``` + - `previousValue` is the value returned by the last call to the iterator. + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + Return the new cumulative value. + In addition to the callback you can also pass an `initialValue`. An error + will be raised if you do not pass an initial value and the enumerator is + empty. + Note that unlike the other methods, this method does not allow you to + pass a target object to set as this for the callback. It's part of the + spec. Sorry. + @method reduce + @param {Function} callback The callback to execute + @param {Object} initialValue Initial value for the reduce + @param {String} reducerProperty internal use only. + @return {Object} The reduced value. + @public + */ + reduce: function (callback, initialValue, reducerProperty) { + if (typeof callback !== 'function') { + throw new TypeError(); + } - BasicOpcodeBuilder.prototype.openPrimitiveElement = function openPrimitiveElement(tag) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(tag)); - }; + var ret = initialValue; - BasicOpcodeBuilder.prototype.openComponentElement = function openComponentElement(tag) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenComponentElementOpcode(tag)); - }; + this.forEach(function (item, i) { + ret = callback(ret, item, i, this, reducerProperty); + }, this); - BasicOpcodeBuilder.prototype.openDynamicPrimitiveElement = function openDynamicPrimitiveElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenDynamicPrimitiveElementOpcode()); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.flushElement = function flushElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.FlushElementOpcode()); - }; + /** + Invokes the named method on every object in the receiver that + implements it. This method corresponds to the implementation in + Prototype 1.6. + @method invoke + @param {String} methodName the name of the method + @param {Object...} args optional arguments to pass as well. + @return {Array} return values from calling invoke. + @public + */ + invoke: function (methodName) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - BasicOpcodeBuilder.prototype.closeElement = function closeElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.CloseElementOpcode()); - }; + var ret = emberA(); - BasicOpcodeBuilder.prototype.staticAttr = function staticAttr(name, namespace, value) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.StaticAttrOpcode(name, namespace, value)); - }; + this.forEach(function (x, idx) { + var method = x && x[methodName]; - BasicOpcodeBuilder.prototype.dynamicAttrNS = function dynamicAttrNS(name, namespace, isTrusting) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrNSOpcode(name, namespace, isTrusting)); - }; + if ('function' === typeof method) { + ret[idx] = args ? method.apply(x, args) : x[methodName](); + } + }, this); - BasicOpcodeBuilder.prototype.dynamicAttr = function dynamicAttr(name, isTrusting) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrOpcode(name, isTrusting)); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.comment = function comment(_comment) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.CommentOpcode(_comment)); - }; + /** + Simply converts the enumerable into a genuine array. The order is not + guaranteed. Corresponds to the method implemented by Prototype. + @method toArray + @return {Array} the enumerable as an array. + @public + */ + toArray: function () { + var ret = emberA(); - // lists + this.forEach(function (o, idx) { + return ret[idx] = o; + }); - BasicOpcodeBuilder.prototype.putIterator = function putIterator() { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.PutIteratorOpcode()); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.enterList = function enterList(start, end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.EnterListOpcode(this.labelFor(start), this.labelFor(end))); - }; + /** + Returns a copy of the array with all `null` and `undefined` elements removed. + ```javascript + let arr = ['a', null, 'c', undefined]; + arr.compact(); // ['a', 'c'] + ``` + @method compact + @return {Array} the array without null and undefined elements. + @public + */ + compact: function () { + return this.filter(function (value) { + return value != null; + }); + }, - BasicOpcodeBuilder.prototype.exitList = function exitList() { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.ExitListOpcode()); - }; + /** + Returns a new enumerable that excludes the passed value. The default + implementation returns an array regardless of the receiver type. + If the receiver does not contain the value it returns the original enumerable. + ```javascript + let arr = ['a', 'b', 'a', 'c']; + arr.without('a'); // ['b', 'c'] + ``` + @method without + @param {Object} value + @return {Ember.Enumerable} + @public + */ + without: function (value) { + if (!this.includes(value)) { + return this; // nothing to do + } - BasicOpcodeBuilder.prototype.enterWithKey = function enterWithKey(start, end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.EnterWithKeyOpcode(this.labelFor(start), this.labelFor(end))); - }; + var ret = emberA(); - BasicOpcodeBuilder.prototype.nextIter = function nextIter(end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.NextIterOpcode(this.labelFor(end))); - }; + this.forEach(function (k) { + // SameValueZero comparison (NaN !== NaN) + if (!(k === value || k !== k && value !== value)) { + ret[ret.length] = k; + } + }); - // vm + return ret; + }, - BasicOpcodeBuilder.prototype.pushRemoteElement = function pushRemoteElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PushRemoteElementOpcode()); - }; + /** + Returns a new enumerable that contains only unique values. The default + implementation returns an array regardless of the receiver type. + ```javascript + let arr = ['a', 'a', 'b', 'b']; + arr.uniq(); // ['a', 'b'] + ``` + This only works on primitive data types, e.g. Strings, Numbers, etc. + @method uniq + @return {Ember.Enumerable} + @public + */ + uniq: function () { + var ret = emberA(); + + this.forEach(function (k) { + if (ret.indexOf(k) < 0) { + ret.push(k); + } + }); - BasicOpcodeBuilder.prototype.popRemoteElement = function popRemoteElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PopRemoteElementOpcode()); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.popElement = function popElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PopElementOpcode()); - }; + /** + This property will trigger anytime the enumerable's content changes. + You can observe this property to be notified of changes to the enumerable's + content. + For plain enumerables, this property is read only. `Array` overrides + this method. + @property [] + @type Array + @return this + @private + */ + '[]': _emberMetal.computed({ + get: function (key) { + return this; + } + }), - BasicOpcodeBuilder.prototype.label = function label(name) { - this.append(this.labelFor(name)); - }; + // .......................................................... + // ENUMERABLE OBSERVERS + // - BasicOpcodeBuilder.prototype.pushChildScope = function pushChildScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PushChildScopeOpcode()); - }; + /** + Registers an enumerable observer. Must implement `Ember.EnumerableObserver` + mixin. + @method addEnumerableObserver + @param {Object} target + @param {Object} [opts] + @return this + @private + */ + addEnumerableObserver: function (target, opts) { + var willChange = opts && opts.willChange || 'enumerableWillChange'; + var didChange = opts && opts.didChange || 'enumerableDidChange'; + var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); - BasicOpcodeBuilder.prototype.popScope = function popScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PopScopeOpcode()); - }; + if (!hasObservers) { + _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.pushDynamicScope = function pushDynamicScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PushDynamicScopeOpcode()); - }; + _emberMetal.addListener(this, '@enumerable:before', target, willChange); + _emberMetal.addListener(this, '@enumerable:change', target, didChange); - BasicOpcodeBuilder.prototype.popDynamicScope = function popDynamicScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PopDynamicScopeOpcode()); - }; + if (!hasObservers) { + _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.putNull = function putNull() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutNullOpcode()); - }; + return this; + }, - BasicOpcodeBuilder.prototype.putValue = function putValue(expression) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(this.compile(expression))); - }; + /** + Removes a registered enumerable observer. + @method removeEnumerableObserver + @param {Object} target + @param {Object} [opts] + @return this + @private + */ + removeEnumerableObserver: function (target, opts) { + var willChange = opts && opts.willChange || 'enumerableWillChange'; + var didChange = opts && opts.didChange || 'enumerableDidChange'; + var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); - BasicOpcodeBuilder.prototype.putArgs = function putArgs(args) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutArgsOpcode(this.compile(args))); - }; + if (hasObservers) { + _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.bindDynamicScope = function bindDynamicScope(names) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindDynamicScopeOpcode(names)); - }; + _emberMetal.removeListener(this, '@enumerable:before', target, willChange); + _emberMetal.removeListener(this, '@enumerable:change', target, didChange); - BasicOpcodeBuilder.prototype.bindPositionalArgs = function bindPositionalArgs(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindPositionalArgsOpcode(names, symbols)); - }; + if (hasObservers) { + _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.bindNamedArgs = function bindNamedArgs(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindNamedArgsOpcode(names, symbols)); - }; + return this; + }, - BasicOpcodeBuilder.prototype.bindBlocks = function bindBlocks(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindBlocksOpcode(names, symbols)); - }; + /** + Becomes true whenever the array currently has observers watching changes + on the array. + @property hasEnumerableObservers + @type Boolean + @private + */ + hasEnumerableObservers: _emberMetal.computed(function () { + return _emberMetal.hasListeners(this, '@enumerable:change') || _emberMetal.hasListeners(this, '@enumerable:before'); + }), - BasicOpcodeBuilder.prototype.enter = function enter(_enter, exit) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.EnterOpcode(this.labelFor(_enter), this.labelFor(exit))); - }; + /** + Invoke this method just before the contents of your enumerable will + change. You can either omit the parameters completely or pass the objects + to be removed or added if available or just a count. + @method enumerableContentWillChange + @param {Ember.Enumerable|Number} removing An enumerable of the objects to + be removed or the number of items to be removed. + @param {Ember.Enumerable|Number} adding An enumerable of the objects to be + added or the number of items to be added. + @chainable + @private + */ + enumerableContentWillChange: function (removing, adding) { + var removeCnt = undefined, + addCnt = undefined, + hasDelta = undefined; - BasicOpcodeBuilder.prototype.exit = function exit() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.ExitOpcode()); - }; + if ('number' === typeof removing) { + removeCnt = removing; + } else if (removing) { + removeCnt = _emberMetal.get(removing, 'length'); + } else { + removeCnt = removing = -1; + } - BasicOpcodeBuilder.prototype.evaluate = function evaluate(name, block) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.EvaluateOpcode(name, block)); - }; + if ('number' === typeof adding) { + addCnt = adding; + } else if (adding) { + addCnt = _emberMetal.get(adding, 'length'); + } else { + addCnt = adding = -1; + } - BasicOpcodeBuilder.prototype.test = function test(testFunc) { - if (testFunc === 'const') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.ConstTest)); - } else if (testFunc === 'simple') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.SimpleTest)); - } else if (testFunc === 'environment') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.EnvironmentTest)); - } else if (typeof testFunc === 'function') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(testFunc)); - } else { - throw new Error('unreachable'); - } - }; + hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; - BasicOpcodeBuilder.prototype.jump = function jump(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpOpcode(this.labelFor(target))); - }; + if (removing === -1) { + removing = null; + } - BasicOpcodeBuilder.prototype.jumpIf = function jumpIf(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpIfOpcode(this.labelFor(target))); - }; + if (adding === -1) { + adding = null; + } - BasicOpcodeBuilder.prototype.jumpUnless = function jumpUnless(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpUnlessOpcode(this.labelFor(target))); - }; + _emberMetal.propertyWillChange(this, '[]'); - babelHelpers.createClass(BasicOpcodeBuilder, [{ - key: 'labels', - get: function () { - return this.labelsStack.current; - } - }]); - return BasicOpcodeBuilder; - })(StatementCompilationBufferProxy); + if (hasDelta) { + _emberMetal.propertyWillChange(this, 'length'); + } - exports.BasicOpcodeBuilder = BasicOpcodeBuilder; + _emberMetal.sendEvent(this, '@enumerable:before', [this, removing, adding]); - function isCompilableExpression(expr) { - return expr && typeof expr['compile'] === 'function'; - } + return this; + }, - var OpcodeBuilder = (function (_BasicOpcodeBuilder) { - babelHelpers.inherits(OpcodeBuilder, _BasicOpcodeBuilder); + /** + Invoke this method when the contents of your enumerable has changed. + This will notify any observers watching for content changes. If you are + implementing an ordered enumerable (such as an array), also pass the + start and end values where the content changed so that it can be used to + notify range observers. + @method enumerableContentDidChange + @param {Ember.Enumerable|Number} removing An enumerable of the objects to + be removed or the number of items to be removed. + @param {Ember.Enumerable|Number} adding An enumerable of the objects to + be added or the number of items to be added. + @chainable + @private + */ + enumerableContentDidChange: function (removing, adding) { + var removeCnt = undefined, + addCnt = undefined, + hasDelta = undefined; - function OpcodeBuilder() { - _BasicOpcodeBuilder.apply(this, arguments); - } + if ('number' === typeof removing) { + removeCnt = removing; + } else if (removing) { + removeCnt = _emberMetal.get(removing, 'length'); + } else { + removeCnt = removing = -1; + } - OpcodeBuilder.prototype.compile = function compile(expr) { - if (isCompilableExpression(expr)) { - return expr.compile(this, this.env, this.symbolTable); - } else { - return expr; - } - }; + if ('number' === typeof adding) { + addCnt = adding; + } else if (adding) { + addCnt = _emberMetal.get(adding, 'length'); + } else { + addCnt = adding = -1; + } - OpcodeBuilder.prototype.bindPositionalArgsForBlock = function bindPositionalArgsForBlock(block) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindPositionalArgsOpcode.create(block)); - }; + hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; - OpcodeBuilder.prototype.preludeForLayout = function preludeForLayout(layout) { - if (layout.hasNamedParameters) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindNamedArgsOpcode.create(layout)); - } - if (layout.hasYields || layout.hasPartials) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindCallerScopeOpcode()); - } - if (layout.hasYields) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindBlocksOpcode.create(layout)); - } - if (layout.hasPartials) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindPartialArgsOpcode.create(layout)); - } - }; + if (removing === -1) { + removing = null; + } - // TODO - // come back to this - - OpcodeBuilder.prototype.block = function block(args, callback) { - if (args) this.putArgs(args); - this.startLabels(); - this.enter('BEGIN', 'END'); - this.label('BEGIN'); - callback(this, 'BEGIN', 'END'); - this.label('END'); - this.exit(); - this.stopLabels(); - }; + if (adding === -1) { + adding = null; + } - // TODO - // come back to this - - OpcodeBuilder.prototype.iter = function iter(callback) { - this.startLabels(); - this.enterList('BEGIN', 'END'); - this.label('ITER'); - this.nextIter('BREAK'); - this.enterWithKey('BEGIN', 'END'); - this.label('BEGIN'); - callback(this, 'BEGIN', 'END'); - this.label('END'); - this.exit(); - this.jump('ITER'); - this.label('BREAK'); - this.exitList(); - this.stopLabels(); - }; + _emberMetal.sendEvent(this, '@enumerable:change', [this, removing, adding]); - // TODO - // come back to this + if (hasDelta) { + _emberMetal.propertyDidChange(this, 'length'); + } - OpcodeBuilder.prototype.unit = function unit(callback) { - this.startLabels(); - callback(this); - this.stopLabels(); - }; + _emberMetal.propertyDidChange(this, '[]'); - return OpcodeBuilder; - })(BasicOpcodeBuilder); + return this; + }, - exports.default = OpcodeBuilder; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQXlCQSwrQkFBQTtBQUVFLGlCQUZGLCtCQUFBLENBRXdCLEtBQWlDLEVBQUE7QUFBakMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUE0QjtTQUFJOztBQUY3RCx1Q0FBQSxXQVFFLE9BQU8sR0FBQSxtQkFBQTtBQUNMLG1CQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsT0FBTyxFQUFFLENBQUM7U0FDN0I7O0FBVkgsdUNBQUEsV0FZRSxNQUFNLEdBQUEsZ0JBQW1CLE1BQVMsRUFBQTtBQUNoQyxnQkFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUM7U0FDM0I7O0FBZEgsdUNBQUEsV0FnQkUsY0FBYyxHQUFBLHdCQUFDLElBQVksRUFBQTtBQUN6QixtQkFBTyxJQUFJLENBQUMsS0FBSyxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsQ0FBQztTQUN4Qzs7QUFsQkgsdUNBQUE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2RlQnVpbGRlciwgQkVHSU46IExhYmVsLCBFTkQ6IExhYmVsKSA9PiB2b2lkO1xuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/component', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-reference'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerReference) { - 'use strict'; + /** + Converts the enumerable into an array and sorts by the keys + specified in the argument. + You may provide multiple arguments to sort by multiple properties. + @method sortBy + @param {String} property name(s) to sort on + @return {Array} The sorted array. + @since 1.2.0 + @public + */ + sortBy: function () { + var sortKeys = arguments; - var PutDynamicComponentDefinitionOpcode = (function (_Opcode) { - babelHelpers.inherits(PutDynamicComponentDefinitionOpcode, _Opcode); + return this.toArray().sort(function (a, b) { + for (var i = 0; i < sortKeys.length; i++) { + var key = sortKeys[i]; + var propA = _emberMetal.get(a, key); + var propB = _emberMetal.get(b, key); + // return 1 or -1 else continue to the next sortKey + var compareValue = _emberRuntimeCompare.default(propA, propB); - function PutDynamicComponentDefinitionOpcode() { - _Opcode.apply(this, arguments); - this.type = "put-dynamic-component-definition"; + if (compareValue) { + return compareValue; + } } + return 0; + }); + }, - PutDynamicComponentDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var definition = cache ? cache.peek() : reference.value(); - vm.frame.setImmediate(definition); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; - - PutDynamicComponentDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + /** + Returns a new enumerable that contains only items containing a unique property value. + The default implementation returns an array regardless of the receiver type. + ```javascript + let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; + arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] + ``` + @method uniqBy + @return {Ember.Enumerable} + @public + */ - return PutDynamicComponentDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + uniqBy: function (key) { + var ret = emberA(); + var seen = new _emberUtils.EmptyObject(); - exports.PutDynamicComponentDefinitionOpcode = PutDynamicComponentDefinitionOpcode; + this.forEach(function (item) { + var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); + if (!(guid in seen)) { + seen[guid] = true; + ret.push(item); + } + }); - var PutComponentDefinitionOpcode = (function (_Opcode2) { - babelHelpers.inherits(PutComponentDefinitionOpcode, _Opcode2); + return ret; + }, - function PutComponentDefinitionOpcode(definition) { - _Opcode2.call(this); - this.definition = definition; - this.type = "put-component-definition"; - } + /** + Returns `true` if the passed object can be found in the enumerable. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, undefined].includes(undefined); // true + [1, 2, null].includes(null); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @return {Boolean} `true` if object is found in the enumerable. + @public + */ + includes: function (obj) { + _emberMetal.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1); - PutComponentDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setImmediate(this.definition); - }; + var len = _emberMetal.get(this, 'length'); + var idx = undefined, + next = undefined; + var last = null; + var found = false; - PutComponentDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.definition.name)] - }; - }; + var context = popCtx(); - return PutComponentDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PutComponentDefinitionOpcode = PutComponentDefinitionOpcode; - - var OpenComponentOpcode = (function (_Opcode3) { - babelHelpers.inherits(OpenComponentOpcode, _Opcode3); - - function OpenComponentOpcode(args, shadow) { - _Opcode3.call(this); - this.args = args; - this.shadow = shadow; - this.type = "open-component"; - } - - OpenComponentOpcode.prototype.evaluate = function evaluate(vm) { - var rawArgs = this.args; - var shadow = this.shadow; - - var definition = vm.frame.getImmediate(); - var dynamicScope = vm.pushDynamicScope(); - var callerScope = vm.scope(); - var manager = definition.manager; - var args = manager.prepareArgs(definition, rawArgs.evaluate(vm), dynamicScope); - var hasDefaultBlock = !!args.blocks.default; // TODO Cleanup? - var component = manager.create(vm.env, definition, args, dynamicScope, vm.getSelf(), hasDefaultBlock); - var destructor = manager.getDestructor(component); - if (destructor) vm.newDestroyable(destructor); - var layout = manager.layoutFor(definition, component, vm.env); - var selfRef = manager.getSelf(component); - vm.beginCacheGroup(); - vm.stack().pushSimpleBlock(); - vm.pushRootScope(selfRef, layout.symbols); - vm.invokeLayout(args, layout, callerScope, component, manager, shadow); - vm.updateWith(new UpdateComponentOpcode(definition.name, component, manager, args, dynamicScope)); - }; + for (idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); - OpenComponentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + found = obj === next || obj !== obj && next !== next; - return OpenComponentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.OpenComponentOpcode = OpenComponentOpcode; - - var UpdateComponentOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateComponentOpcode, _UpdatingOpcode); - - function UpdateComponentOpcode(name, component, manager, args, dynamicScope) { - _UpdatingOpcode.call(this); - this.name = name; - this.component = component; - this.manager = manager; - this.args = args; - this.dynamicScope = dynamicScope; - this.type = "update-component"; - var componentTag = manager.getTag(component); - if (componentTag) { - this.tag = _glimmerReference.combine([args.tag, componentTag]); - } else { - this.tag = args.tag; - } - } + last = next; + } - UpdateComponentOpcode.prototype.evaluate = function evaluate(vm) { - var component = this.component; - var manager = this.manager; - var args = this.args; - var dynamicScope = this.dynamicScope; + next = last = null; + context = pushCtx(context); - manager.update(component, args, dynamicScope); - }; + return found; + } + }); - UpdateComponentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.name)] - }; - }; + exports.default = Enumerable; +}); +enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - return UpdateComponentOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + @module ember + @submodule ember-runtime + */ - exports.UpdateComponentOpcode = UpdateComponentOpcode; + /** + This mixin allows for Ember objects to subscribe to and emit events. + + ```javascript + App.Person = Ember.Object.extend(Ember.Evented, { + greet: function() { + // ... + this.trigger('greet'); + } + }); + + var person = App.Person.create(); + + person.on('greet', function() { + console.log('Our person has greeted'); + }); + + person.greet(); + + // outputs: 'Our person has greeted' + ``` + + You can also chain multiple event subscriptions: + + ```javascript + person.on('greet', function() { + console.log('Our person has greeted'); + }).one('greet', function() { + console.log('Offer one-time special'); + }).off('event', this, forgetThis); + ``` + + @class Evented + @namespace Ember + @public + */ + exports.default = _emberMetal.Mixin.create({ - var DidCreateElementOpcode = (function (_Opcode4) { - babelHelpers.inherits(DidCreateElementOpcode, _Opcode4); + /** + Subscribes to a named event with given function. + ```javascript + person.on('didLoad', function() { + // fired once the person has loaded + }); + ``` + An optional target can be passed in as the 2nd argument that will + be set as the "this" for the callback. This is a good way to give your + function access to the object triggering the event. When the target + parameter is used the callback becomes the third argument. + @method on + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute + @return this + @public + */ + on: function (name, target, method) { + _emberMetal.addListener(this, name, target, method); + return this; + }, - function DidCreateElementOpcode() { - _Opcode4.apply(this, arguments); - this.type = "did-create-element"; - } + /** + Subscribes a function to a named event and then cancels the subscription + after the first time the event is triggered. It is good to use ``one`` when + you only care about the first time an event has taken place. + This function takes an optional 2nd argument that will become the "this" + value for the callback. If this argument is passed then the 3rd argument + becomes the function. + @method one + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute + @return this + @public + */ + one: function (name, target, method) { + if (!method) { + method = target; + target = null; + } - // Slow path for non-specialized component invocations. Uses an internal - // named lookup on the args. + _emberMetal.addListener(this, name, target, method, true); + return this; + }, - DidCreateElementOpcode.prototype.evaluate = function evaluate(vm) { - var manager = vm.frame.getManager(); - var component = vm.frame.getComponent(); - manager.didCreateElement(component, vm.stack().constructing, vm.stack().operations); - }; + /** + Triggers a named event for the object. Any additional arguments + will be passed as parameters to the functions that are subscribed to the + event. + ```javascript + person.on('didEat', function(food) { + console.log('person ate some ' + food); + }); + person.trigger('didEat', 'broccoli'); + // outputs: person ate some broccoli + ``` + @method trigger + @param {String} name The name of the event + @param {Object...} args Optional arguments to pass on + @public + */ + trigger: function (name) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - DidCreateElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$ARGS"] - }; - }; + _emberMetal.sendEvent(this, name, args); + }, - return DidCreateElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Cancels subscription for given name, target, and method. + @method off + @param {String} name The name of the event + @param {Object} target The target of the subscription + @param {Function} method The function of the subscription + @return this + @public + */ + off: function (name, target, method) { + _emberMetal.removeListener(this, name, target, method); + return this; + }, - exports.DidCreateElementOpcode = DidCreateElementOpcode; + /** + Checks to see if object has any subscriptions for named event. + @method has + @param {String} name The name of the event + @return {Boolean} does the object have a subscription for event + @public + */ + has: function (name) { + return _emberMetal.hasListeners(this, name); + } + }); +}); +enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - var ShadowAttributesOpcode = (function (_Opcode5) { - babelHelpers.inherits(ShadowAttributesOpcode, _Opcode5); + 'use strict'; - function ShadowAttributesOpcode() { - _Opcode5.apply(this, arguments); - this.type = "shadow-attributes"; - } + /** + The `Ember.Freezable` mixin implements some basic methods for marking an + object as frozen. Once an object is frozen it should be read only. No changes + may be made the internal state of the object. + + ## Enforcement + + To fully support freezing in your subclass, you must include this mixin and + override any method that might alter any property on the object to instead + raise an exception. You can check the state of an object by checking the + `isFrozen` property. + + Although future versions of JavaScript may support language-level freezing + object objects, that is not the case today. Even if an object is freezable, + it is still technically possible to modify the object, even though it could + break other parts of your application that do not expect a frozen object to + change. It is, therefore, very important that you always respect the + `isFrozen` property on all freezable objects. + + ## Example Usage + + The example below shows a simple object that implement the `Ember.Freezable` + protocol. + + ```javascript + Contact = Ember.Object.extend(Ember.Freezable, { + firstName: null, + lastName: null, + + // swaps the names + swapNames: function() { + if (this.get('isFrozen')) throw Ember.FROZEN_ERROR; + var tmp = this.get('firstName'); + this.set('firstName', this.get('lastName')); + this.set('lastName', tmp); + return this; + } + + }); + + c = Contact.create({ firstName: "John", lastName: "Doe" }); + c.swapNames(); // returns c + c.freeze(); + c.swapNames(); // EXCEPTION + ``` + + ## Copying + + Usually the `Ember.Freezable` protocol is implemented in cooperation with the + `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will + return a frozen object, if the object implements this method as well. + + @class Freezable + @namespace Ember + @since Ember 0.9 + @deprecated Use `Object.freeze` instead. + @private + */ + var Freezable = _emberMetal.Mixin.create({ - ShadowAttributesOpcode.prototype.evaluate = function evaluate(vm) { - var shadow = vm.frame.getShadow(); - if (!shadow) return; + init: function () { + _emberMetal.deprecate('`Ember.Freezable` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.freezable-init', until: '3.0.0' }); + this._super.apply(this, arguments); + }, - var _vm$frame$getArgs = vm.frame.getArgs(); + /** + Set to `true` when the object is frozen. Use this property to detect + whether your object is frozen or not. + @property isFrozen + @type Boolean + @private + */ + isFrozen: false, - var named = _vm$frame$getArgs.named; + /** + Freezes the object. Once this method has been called the object should + no longer allow any properties to be edited. + @method freeze + @return {Object} receiver + @private + */ + freeze: function () { + if (_emberMetal.get(this, 'isFrozen')) { + return this; + } - shadow.forEach(function (name) { - vm.stack().setDynamicAttribute(name, named.get(name), false); - }); - }; + _emberMetal.set(this, 'isFrozen', true); + return this; + } - ShadowAttributesOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$ARGS"] - }; - }; + }); - return ShadowAttributesOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + exports.Freezable = Freezable; + var FROZEN_ERROR = 'Frozen object cannot be modified.'; + exports.FROZEN_ERROR = FROZEN_ERROR; +}); +enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable'], function (exports, _emberMetal, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable) { + /** + @module ember + @submodule ember-runtime + */ - exports.ShadowAttributesOpcode = ShadowAttributesOpcode; + 'use strict'; - var DidRenderLayoutOpcode = (function (_Opcode6) { - babelHelpers.inherits(DidRenderLayoutOpcode, _Opcode6); + exports.removeAt = removeAt; + var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; + var EMPTY = []; - function DidRenderLayoutOpcode() { - _Opcode6.apply(this, arguments); - this.type = "did-render-layout"; - } + // .......................................................... + // HELPERS + // - DidRenderLayoutOpcode.prototype.evaluate = function evaluate(vm) { - var manager = vm.frame.getManager(); - var component = vm.frame.getComponent(); - var bounds = vm.stack().popBlock(); - manager.didRenderLayout(component, bounds); - vm.env.didCreate(component, manager); - vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); - }; + function removeAt(array, start, len) { + if ('number' === typeof start) { + if (start < 0 || start >= _emberMetal.get(array, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - return DidRenderLayoutOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + // fast case + if (len === undefined) { + len = 1; + } - exports.DidRenderLayoutOpcode = DidRenderLayoutOpcode; + array.replace(start, len, EMPTY); + } - var DidUpdateLayoutOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(DidUpdateLayoutOpcode, _UpdatingOpcode2); + return array; + } - function DidUpdateLayoutOpcode(manager, component, bounds) { - _UpdatingOpcode2.call(this); - this.manager = manager; - this.component = component; - this.bounds = bounds; - this.type = "did-update-layout"; - this.tag = _glimmerReference.CONSTANT_TAG; - } + /** + This mixin defines the API for modifying array-like objects. These methods + can be applied only to a collection that keeps its items in an ordered set. + It builds upon the Array mixin and adds methods to modify the array. + One concrete implementations of this class include ArrayProxy. + + It is important to use the methods in this class to modify arrays so that + changes are observable. This allows the binding system in Ember to function + correctly. + + + Note that an Array can change even if it does not implement this mixin. + For example, one might implement a SparseArray that cannot be directly + modified, but if its underlying enumerable changes, it will change also. + + @class MutableArray + @namespace Ember + @uses Ember.Array + @uses Ember.MutableEnumerable + @public + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, { - DidUpdateLayoutOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; - var component = this.component; - var bounds = this.bounds; + /** + __Required.__ You must implement this method to apply this mixin. + This is one of the primitives you must implement to support `Ember.Array`. + You should replace amt objects started at idx with the objects in the + passed array. You should also call `this.enumerableContentDidChange()` + @method replace + @param {Number} idx Starting index in the array to replace. If + idx >= length, then append to the end of the array. + @param {Number} amt Number of elements that should be removed from + the array, starting at *idx*. + @param {Array} objects An array of zero or more objects that should be + inserted into the array at *idx* + @public + */ + replace: null, - manager.didUpdateLayout(component, bounds); - vm.env.didUpdate(component, manager); - }; + /** + Remove all elements from the array. This is useful if you + want to reuse an existing array without having to recreate it. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.length; // 3 + colors.clear(); // [] + colors.length; // 0 + ``` + @method clear + @return {Ember.Array} An empty Array. + @public + */ + clear: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return this; + } - return DidUpdateLayoutOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + this.replace(0, len, EMPTY); + return this; + }, - exports.DidUpdateLayoutOpcode = DidUpdateLayoutOpcode; + /** + This will use the primitive `replace()` method to insert an object at the + specified index. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue'] + colors.insertAt(5, 'orange'); // Error: Index out of range + ``` + @method insertAt + @param {Number} idx index of insert the object at. + @param {Object} object object to insert + @return {Ember.Array} receiver + @public + */ + insertAt: function (idx, object) { + if (idx > _emberMetal.get(this, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - var CloseComponentOpcode = (function (_Opcode7) { - babelHelpers.inherits(CloseComponentOpcode, _Opcode7); + this.replace(idx, 0, [object]); + return this; + }, - function CloseComponentOpcode() { - _Opcode7.apply(this, arguments); - this.type = "close-component"; - } + /** + Remove an object at the specified index using the `replace()` primitive + method. You can pass either a single index, or a start and a length. + If you pass a start and length that is beyond the + length this method will throw an `OUT_OF_RANGE_EXCEPTION`. + ```javascript + let colors = ['red', 'green', 'blue', 'yellow', 'orange']; + colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] + colors.removeAt(2, 2); // ['green', 'blue'] + colors.removeAt(4, 2); // Error: Index out of range + ``` + @method removeAt + @param {Number} start index, start of range + @param {Number} len length of passing range + @return {Ember.Array} receiver + @public + */ + removeAt: function (start, len) { + return removeAt(this, start, len); + }, - CloseComponentOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - vm.popDynamicScope(); - vm.commitCacheGroup(); - }; + /** + Push the object onto the end of the array. Works just like `push()` but it + is KVO-compliant. + ```javascript + let colors = ['red', 'green']; + colors.pushObject('black'); // ['red', 'green', 'black'] + colors.pushObject(['yellow']); // ['red', 'green', ['yellow']] + ``` + @method pushObject + @param {*} obj object to push + @return object same object passed as a param + @public + */ + pushObject: function (obj) { + this.insertAt(_emberMetal.get(this, 'length'), obj); + return obj; + }, - return CloseComponentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Add the objects in the passed numerable to the end of the array. Defers + notifying observers of the change until all objects are added. + ```javascript + let colors = ['red']; + colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange'] + ``` + @method pushObjects + @param {Ember.Enumerable} objects the objects to add + @return {Ember.Array} receiver + @public + */ + pushObjects: function (objects) { + if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || Array.isArray(objects))) { + throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + } + this.replace(_emberMetal.get(this, 'length'), 0, objects); + return this; + }, - exports.CloseComponentOpcode = CloseComponentOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBVUEsbUNBQUE7OEJBQUEsbUNBQUE7O0FBQUEsaUJBQUEsbUNBQUEsR0FBQTtBQUF5RCxnQ0FBQSxTQUFBLENBQUEsQ0FBTTtBQUN0RCxnQkFBQSxDQUFBLElBQUksR0FBRyxrQ0FBa0MsQ0FBQztTQXFCbEQ7O0FBdEJELDJDQUFBLFdBR0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGdCQUFJLFNBQVMsR0FBRyxFQUFFLENBQUMsS0FBSyxDQUFDLFVBQVUsRUFBa0MsQ0FBQztBQUN0RSxnQkFBSSxLQUFLLEdBQUcsa0JBUitDLE9BQU8sQ0FROUMsU0FBUyxDQUFDLEdBQUcsU0FBUyxHQUFHLHNCQVJYLGNBQWMsQ0FRZ0IsU0FBUyxDQUFDLENBQUM7QUFDM0UsZ0JBQUksVUFBVSxHQUFHLEtBQUssR0FBRyxLQUFLLENBQUMsSUFBSSxFQUFFLEdBQUcsU0FBUyxDQUFDLEtBQUssRUFBRSxDQUFDO0FBRTFELGNBQUUsQ0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLFVBQVUsQ0FBQyxDQU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TtcbiAgfVxufVxuXG5leHBvcnQgY2xhc3MgQ2xvc2VDb21wb25lbnRPcGNvZGUgZXh0ZW5kcyBPcGNvZGUge1xuICBwdWJsaWMgdHlwZSA9IFwiY2xvc2UtY29tcG9uZW50XCI7XG5cbiAgZXZhbHVhdGUodm06IFZNKSB7XG4gICAgdm0ucG9wU2NvcGUoKTtcbiAgICB2bS5wb3BEeW5hbWljU2NvcGUoKTtcbiAgICB2bS5jb21taXRDYWNoZUdyb3VwKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/opcodes/content', ['exports', 'glimmer-runtime/lib/upsert', 'glimmer-runtime/lib/component/interfaces', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/vm/update', 'glimmer-reference', 'glimmer-util', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/compiler', 'glimmer-runtime/lib/compiled/opcodes/builder', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/syntax/core'], function (exports, _glimmerRuntimeLibUpsert, _glimmerRuntimeLibComponentInterfaces, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibVmUpdate, _glimmerReference, _glimmerUtil, _glimmerRuntimeLibBounds, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibCompiler, _glimmerRuntimeLibCompiledOpcodesBuilder, _glimmerRuntimeLibReferences, _glimmerRuntimeLibSyntaxCore) { - 'use strict'; + /** + Pop object from array or nil if none are left. Works just like `pop()` but + it is KVO-compliant. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.popObject(); // 'blue' + console.log(colors); // ['red', 'green'] + ``` + @method popObject + @return object + @public + */ + popObject: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return null; + } - exports.normalizeTextValue = normalizeTextValue; + var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1); + this.removeAt(len - 1, 1); + return ret; + }, - function isEmpty(value) { - return value === null || value === undefined || typeof value['toString'] !== 'function'; - } + /** + Shift an object from start of array or nil if none are left. Works just + like `shift()` but it is KVO-compliant. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.shiftObject(); // 'red' + console.log(colors); // ['green', 'blue'] + ``` + @method shiftObject + @return object + @public + */ + shiftObject: function () { + if (_emberMetal.get(this, 'length') === 0) { + return null; + } - function normalizeTextValue(value) { - if (isEmpty(value)) { - return ''; - } - return String(value); - } + var ret = _emberRuntimeMixinsArray.objectAt(this, 0); + this.removeAt(0); + return ret; + }, - function normalizeTrustedValue(value) { - if (isEmpty(value)) { - return ''; - } - if (_glimmerRuntimeLibUpsert.isString(value)) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value)) { - return value.toHTML(); - } - if (_glimmerRuntimeLibUpsert.isNode(value)) { - return value; - } - return String(value); - } - function normalizeValue(value) { - if (isEmpty(value)) { - return ''; - } - if (_glimmerRuntimeLibUpsert.isString(value)) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value) || _glimmerRuntimeLibUpsert.isNode(value)) { - return value; - } - return String(value); - } + /** + Unshift an object to start of array. Works just like `unshift()` but it is + KVO-compliant. + ```javascript + let colors = ['red']; + colors.unshiftObject('yellow'); // ['yellow', 'red'] + colors.unshiftObject(['black']); // [['black'], 'yellow', 'red'] + ``` + @method unshiftObject + @param {*} obj object to unshift + @return object same object passed as a param + @public + */ + unshiftObject: function (obj) { + this.insertAt(0, obj); + return obj; + }, - var AppendOpcode = (function (_Opcode) { - babelHelpers.inherits(AppendOpcode, _Opcode); + /** + Adds the named objects to the beginning of the array. Defers notifying + observers until all objects have been added. + ```javascript + let colors = ['red']; + colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red'] + colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function + ``` + @method unshiftObjects + @param {Ember.Enumerable} objects the objects to add + @return {Ember.Array} receiver + @public + */ + unshiftObjects: function (objects) { + this.replace(0, 0, objects); + return this; + }, - function AppendOpcode() { - _Opcode.apply(this, arguments); - } + /** + Reverse objects in the array. Works just like `reverse()` but it is + KVO-compliant. + @method reverseObjects + @return {Ember.Array} receiver + @public + */ + reverseObjects: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return this; + } - AppendOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var normalized = this.normalize(reference); - var value = undefined, - cache = undefined; - if (_glimmerReference.isConst(reference)) { - value = normalized.value(); - } else { - cache = new _glimmerReference.ReferenceCache(normalized); - value = cache.peek(); - } - var stack = vm.stack(); - var upsert = this.insert(vm.env.getAppendOperations(), stack, value); - var bounds = new _glimmerRuntimeLibBuilder.Fragment(upsert.bounds); - stack.newBounds(bounds); - if (cache /* i.e. !isConst(reference) */) { - vm.updateWith(this.updateWith(vm, reference, cache, bounds, upsert)); - } - }; + var objects = this.toArray().reverse(); + this.replace(0, len, objects); + return this; + }, - AppendOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + /** + Replace all the receiver's content with content of the argument. + If argument is an empty array receiver will be cleared. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.setObjects(['black', 'white']); // ['black', 'white'] + colors.setObjects([]); // [] + ``` + @method setObjects + @param {Ember.Array} objects array whose content will be used for replacing + the content of the receiver + @return {Ember.Array} receiver with the new content + @public + */ + setObjects: function (objects) { + if (objects.length === 0) { + return this.clear(); + } - return AppendOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var len = _emberMetal.get(this, 'length'); + this.replace(0, len, objects); + return this; + }, - exports.AppendOpcode = AppendOpcode; + // .......................................................... + // IMPLEMENT Ember.MutableEnumerable + // - var GuardedAppendOpcode = (function (_AppendOpcode) { - babelHelpers.inherits(GuardedAppendOpcode, _AppendOpcode); + /** + Remove all occurrences of an object in the array. + ```javascript + let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; + cities.removeObject('Chicago'); // ['Berlin', 'Lima'] + cities.removeObject('Lima'); // ['Berlin'] + cities.removeObject('Tokyo') // ['Berlin'] + ``` + @method removeObject + @param {*} obj object to remove + @return {Ember.Array} receiver + @public + */ + removeObject: function (obj) { + var loc = _emberMetal.get(this, 'length') || 0; + while (--loc >= 0) { + var curObject = _emberRuntimeMixinsArray.objectAt(this, loc); - function GuardedAppendOpcode(expression, symbolTable) { - _AppendOpcode.call(this); - this.expression = expression; - this.symbolTable = symbolTable; - this.deopted = null; + if (curObject === obj) { + this.removeAt(loc); } + } + return this; + }, - GuardedAppendOpcode.prototype.evaluate = function evaluate(vm) { - if (this.deopted) { - vm.pushEvalFrame(this.deopted); - } else { - vm.evaluateOperand(this.expression); - var value = vm.frame.getOperand().value(); - if (_glimmerRuntimeLibComponentInterfaces.isComponentDefinition(value)) { - vm.pushEvalFrame(this.deopt(vm.env)); - } else { - _AppendOpcode.prototype.evaluate.call(this, vm); - } - } - }; - - GuardedAppendOpcode.prototype.deopt = function deopt(env) { - var _this = this; - - // At compile time, we determined that this append callsite might refer - // to a local variable/property lookup that resolves to a component - // definition at runtime. - // - // We could have eagerly compiled this callsite into something like this: - // - // {{#if (is-component-definition foo)}} - // {{component foo}} - // {{else}} - // {{foo}} - // {{/if}} - // - // However, in practice, there might be a large amout of these callsites - // and most of them would resolve to a simple value lookup. Therefore, we - // tried to be optimistic and assumed that the callsite will resolve to - // appending a simple value. - // - // However, we have reached here because at runtime, the guard conditional - // have detected that this callsite is indeed referring to a component - // definition object. Since this is likely going to be true for other - // instances of the same callsite, it is now appropiate to deopt into the - // expanded version that handles both cases. The compilation would look - // like this: - // - // PutValue(expression) - // Test(is-component-definition) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(VALUE) - // PutDynamicComponentDefinitionOpcode - // OpenComponent - // CloseComponent - // Jump(END) - // VALUE: Noop - // OptimizedAppend - // END: Noop - // Exit - // - // Keep in mind that even if we *don't* reach here at initial render time, - // it is still possible (although quite rare) that the simple value we - // encounter during initial render could later change into a component - // definition object at update time. That is handled by the "lazy deopt" - // code on the update side (scroll down for the next big block of comment). - var buffer = new _glimmerRuntimeLibCompiler.CompileIntoList(env, null); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, this.symbolTable, env); - dsl.putValue(this.expression); - dsl.test(IsComponentDefinitionReference.create); - dsl.block(null, function (dsl, BEGIN, END) { - dsl.jumpUnless('VALUE'); - dsl.putDynamicComponentDefinition(); - dsl.openComponent(_glimmerRuntimeLibSyntaxCore.Args.empty()); - dsl.closeComponent(); - dsl.jump(END); - dsl.label('VALUE'); - dsl.append(new _this.AppendOpcode()); - }); - var deopted = this.deopted = dsl.toOpSeq(); - // From this point on, we have essentially replaced ourselve with a new set - // of opcodes. Since we will always be executing the new/deopted code, it's - // a good idea (as a pattern) to null out any unneeded fields here to avoid - // holding on to unneeded/stale objects: - this.expression = null; - return deopted; - }; - - GuardedAppendOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var deopted = this.deopted; - - if (deopted) { - return { - guid: guid, - type: type, - deopted: true, - children: deopted.toArray().map(function (op) { - return op.toJSON(); - }) - }; - } else { - return { - guid: guid, - type: type, - args: [this.expression.toJSON()] - }; - } - }; + /** + Push the object onto the end of the array if it is not already + present in the array. + ```javascript + let cities = ['Chicago', 'Berlin']; + cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] + cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] + ``` + @method addObject + @param {*} obj object to add, if not already present + @return {Ember.Array} receiver + @public + */ + addObject: function (obj) { + var included = this.includes(obj); - return GuardedAppendOpcode; - })(AppendOpcode); + if (!included) { + this.pushObject(obj); + } - exports.GuardedAppendOpcode = GuardedAppendOpcode; + return this; + } + }); +}); +enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetal) { + 'use strict'; - var IsComponentDefinitionReference = (function (_ConditionalReference) { - babelHelpers.inherits(IsComponentDefinitionReference, _ConditionalReference); + /** + @module ember + @submodule ember-runtime + */ - function IsComponentDefinitionReference() { - _ConditionalReference.apply(this, arguments); - } + /** + This mixin defines the API for modifying generic enumerables. These methods + can be applied to an object regardless of whether it is ordered or + unordered. + + Note that an Enumerable can change even if it does not implement this mixin. + For example, a MappedEnumerable cannot be directly modified but if its + underlying enumerable changes, it will change also. + + ## Adding Objects + + To add an object to an enumerable, use the `addObject()` method. This + method will only add the object to the enumerable if the object is not + already present and is of a type supported by the enumerable. + + ```javascript + set.addObject(contact); + ``` + + ## Removing Objects + + To remove an object from an enumerable, use the `removeObject()` method. This + will only remove the object if it is present in the enumerable, otherwise + this method has no effect. + + ```javascript + set.removeObject(contact); + ``` + + ## Implementing In Your Own Code + + If you are implementing an object and want to support this API, just include + this mixin in your class and implement the required methods. In your unit + tests, be sure to apply the Ember.MutableEnumerableTests to your object. + + @class MutableEnumerable + @namespace Ember + @uses Ember.Enumerable + @public + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, { - IsComponentDefinitionReference.create = function create(inner) { - return new IsComponentDefinitionReference(inner); - }; + /** + __Required.__ You must implement this method to apply this mixin. + Attempts to add the passed object to the receiver if the object is not + already present in the collection. If the object is present, this method + has no effect. + If the passed object is of a type not supported by the receiver, + then this method should raise an exception. + @method addObject + @param {Object} object The object to add to the enumerable. + @return {Object} the passed object + @public + */ + addObject: null, - IsComponentDefinitionReference.prototype.toBool = function toBool(value) { - return _glimmerRuntimeLibComponentInterfaces.isComponentDefinition(value); - }; + /** + Adds each object in the passed enumerable to the receiver. + @method addObjects + @param {Ember.Enumerable} objects the objects to add. + @return {Object} receiver + @public + */ + addObjects: function (objects) { + var _this = this; - return IsComponentDefinitionReference; - })(_glimmerRuntimeLibReferences.ConditionalReference); + _emberMetal.beginPropertyChanges(this); + objects.forEach(function (obj) { + return _this.addObject(obj); + }); + _emberMetal.endPropertyChanges(this); + return this; + }, - var UpdateOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateOpcode, _UpdatingOpcode); + /** + __Required.__ You must implement this method to apply this mixin. + Attempts to remove the passed object from the receiver collection if the + object is present in the collection. If the object is not present, + this method has no effect. + If the passed object is of a type not supported by the receiver, + then this method should raise an exception. + @method removeObject + @param {Object} object The object to remove from the enumerable. + @return {Object} the passed object + @public + */ + removeObject: null, - function UpdateOpcode(cache, bounds, upsert) { - _UpdatingOpcode.call(this); - this.cache = cache; - this.bounds = bounds; - this.upsert = upsert; - this.tag = cache.tag; - } + /** + Removes each object in the passed enumerable from the receiver. + @method removeObjects + @param {Ember.Enumerable} objects the objects to remove + @return {Object} receiver + @public + */ + removeObjects: function (objects) { + _emberMetal.beginPropertyChanges(this); + for (var i = objects.length - 1; i >= 0; i--) { + this.removeObject(objects[i]); + } + _emberMetal.endPropertyChanges(this); + return this; + } + }); +}); +enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - UpdateOpcode.prototype.evaluate = function evaluate(vm) { - var value = this.cache.revalidate(); - if (_glimmerReference.isModified(value)) { - var bounds = this.bounds; - var upsert = this.upsert; - var dom = vm.dom; + 'use strict'; - if (!this.upsert.update(dom, value)) { - var cursor = new _glimmerRuntimeLibBounds.Cursor(bounds.parentElement(), _glimmerRuntimeLibBounds.clear(bounds)); - upsert = this.upsert = this.insert(vm.env.getAppendOperations(), cursor, value); - } - bounds.update(upsert.bounds); - } - }; + /** + ## Overview + + This mixin provides properties and property observing functionality, core + features of the Ember object model. + + Properties and observers allow one object to observe changes to a + property on another object. This is one of the fundamental ways that + models, controllers and views communicate with each other in an Ember + application. + + Any object that has this mixin applied can be used in observer + operations. That includes `Ember.Object` and most objects you will + interact with as you write your Ember application. + + Note that you will not generally apply this mixin to classes yourself, + but you will use the features provided by this module frequently, so it + is important to understand how to use it. + + ## Using `get()` and `set()` + + Because of Ember's support for bindings and observers, you will always + access properties using the get method, and set properties using the + set method. This allows the observing objects to be notified and + computed properties to be handled properly. + + More documentation about `get` and `set` are below. + + ## Observing Property Changes + + 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) { + // Executes whenever the "value" property changes + // See the addObserver method for more information about the callback arguments + }) + }); + ``` + + Although this is the most common way to add an observer, this capability + is actually built into the `Ember.Object` class on top of two methods + defined in this mixin: `addObserver` and `removeObserver`. You can use + these two methods to add and remove observers yourself if you need to + do so at runtime. + + To add an observer for a property, call: + + ```javascript + object.addObserver('propertyKey', targetObject, targetAction) + ``` + + This will call the `targetAction` method on the `targetObject` whenever + the value of the `propertyKey` changes. + + Note that if `propertyKey` is a computed property, the observer will be + called when any of the property dependencies are changed, even if the + resulting value of the computed property is unchanged. This is necessary + because computed properties are not computed until `get` is called. + + @class Observable + @namespace Ember + @public + */ + exports.default = _emberMetal.Mixin.create({ - UpdateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var cache = this.cache; + /** + Retrieves the value of a property from the object. + This method is usually similar to using `object[keyName]` or `object.keyName`, + however it supports both computed properties and the unknownProperty + handler. + Because `get` unifies the syntax for accessing all these kinds + of properties, it can make many refactorings easier, such as replacing a + simple property with a computed property, or vice versa. + ### Computed Properties + Computed properties are methods defined with the `property` modifier + declared at the end, such as: + ```javascript + fullName: Ember.computed('firstName', 'lastName', function() { + return this.get('firstName') + ' ' + this.get('lastName'); + }) + ``` + When you call `get` on a computed property, the function will be + called and the return value will be returned instead of the function + itself. + ### Unknown Properties + Likewise, if you try to call `get` on a property whose value is + `undefined`, the `unknownProperty()` method will be called on the object. + If this method returns any value other than `undefined`, it will be returned + instead. This allows you to implement "virtual" properties that are + not defined upfront. + @method get + @param {String} keyName The property to retrieve + @return {Object} The property value or undefined. + @public + */ + get: function (keyName) { + return _emberMetal.get(this, keyName); + }, - return { - guid: guid, - type: type, - details: { lastValue: JSON.stringify(cache.peek()) } - }; - }; + /** + To get the values of multiple properties at once, call `getProperties` + with a list of strings or an array: + ```javascript + record.getProperties('firstName', 'lastName', 'zipCode'); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + is equivalent to: + ```javascript + record.getProperties(['firstName', 'lastName', 'zipCode']); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + @method getProperties + @param {String...|Array} list of keys to get + @return {Object} + @public + */ + getProperties: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - return UpdateOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + return _emberMetal.getProperties.apply(undefined, [this].concat(args)); + }, - var GuardedUpdateOpcode = (function (_UpdateOpcode) { - babelHelpers.inherits(GuardedUpdateOpcode, _UpdateOpcode); + /** + Sets the provided key or path to the value. + ```javascript + record.set("key", value); + ``` + This method is generally very similar to calling `object["key"] = value` or + `object.key = value`, except that it provides support for computed + properties, the `setUnknownProperty()` method and property observers. + ### Computed Properties + If you try to set a value on a key that has a computed property handler + defined (see the `get()` method for an example), then `set()` will call + that method, passing both the value and key instead of simply changing + the value itself. This is useful for those times when you need to + implement a property that is composed of one or more member + properties. + ### Unknown Properties + If you try to set a value on a key that is undefined in the target + object, then the `setUnknownProperty()` handler will be called instead. This + gives you an opportunity to implement complex "virtual" properties that + are not predefined on the object. If `setUnknownProperty()` returns + undefined, then `set()` will simply set the value on the object. + ### Property Observers + In addition to changing the property, `set()` will also register a property + change with the object. Unless you have placed this call inside of a + `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers + (i.e. observer methods declared on the same object), will be called + immediately. Any "remote" observers (i.e. observer methods declared on + another object) will be placed in a queue and called at a later time in a + coalesced manner. + @method set + @param {String} keyName The property to set + @param {Object} value The value to set or `null`. + @return {Object} The passed value + @public + */ + set: function (keyName, value) { + return _emberMetal.set(this, keyName, value); + }, - function GuardedUpdateOpcode(reference, cache, bounds, upsert, appendOpcode, state) { - _UpdateOpcode.call(this, cache, bounds, upsert); - this.reference = reference; - this.appendOpcode = appendOpcode; - this.state = state; - this.deopted = null; - this.tag = this._tag = new _glimmerReference.UpdatableTag(this.tag); - } + /** + Sets a list of properties at once. These properties are set inside + a single `beginPropertyChanges` and `endPropertyChanges` batch, so + observers will be buffered. + ```javascript + record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); + ``` + @method setProperties + @param {Object} hash the hash of keys and values to set + @return {Object} The passed in hash + @public + */ + setProperties: function (hash) { + return _emberMetal.setProperties(this, hash); + }, - GuardedUpdateOpcode.prototype.evaluate = function evaluate(vm) { - if (this.deopted) { - vm.evaluateOpcode(this.deopted); - } else { - if (_glimmerRuntimeLibComponentInterfaces.isComponentDefinition(this.reference.value())) { - this.lazyDeopt(vm); - } else { - _UpdateOpcode.prototype.evaluate.call(this, vm); - } - } - }; + /** + Begins a grouping of property changes. + You can use this method to group property changes so that notifications + will not be sent until the changes are finished. If you plan to make a + large number of changes to an object at one time, you should call this + method at the beginning of the changes to begin deferring change + notifications. When you are done making changes, call + `endPropertyChanges()` to deliver the deferred change notifications and end + deferring. + @method beginPropertyChanges + @return {Ember.Observable} + @private + */ + beginPropertyChanges: function () { + _emberMetal.beginPropertyChanges(); + return this; + }, - GuardedUpdateOpcode.prototype.lazyDeopt = function lazyDeopt(vm) { - // Durign initial render, we know that the reference does not contain a - // component definition, so we optimistically assumed that this append - // is just a normal append. However, at update time, we discovered that - // the reference has switched into containing a component definition, so - // we need to do a "lazy deopt", simulating what would have happened if - // we had decided to perform the deopt in the first place during initial - // render. - // - // More concretely, we would have expanded the curly into a if/else, and - // based on whether the value is a component definition or not, we would - // have entered either the dynamic component branch or the simple value - // branch. - // - // Since we rendered a simple value during initial render (and all the - // updates up until this point), we need to pretend that the result is - // produced by the "VALUE" branch of the deopted append opcode: - // - // Try(BEGIN, END) - // Assert(IsComponentDefinition, expected=false) - // OptimizedUpdate - // - // In this case, because the reference has switched from being a simple - // value into a component definition, what would have happened is that - // the assert would throw, causing the Try opcode to teardown the bounds - // and rerun the original append opcode. - // - // Since the Try opcode would have nuked the updating opcodes anyway, we - // wouldn't have to worry about simulating those. All we have to do is to - // execute the Try opcode and immediately throw. - var bounds = this.bounds; - var appendOpcode = this.appendOpcode; - var state = this.state; - - var appendOps = appendOpcode.deopt(vm.env); - var enter = appendOps.head().next.next; - var ops = enter.slice; - var tracker = new _glimmerRuntimeLibBuilder.UpdatableBlockTracker(bounds.parentElement()); - tracker.newBounds(this.bounds); - var children = new _glimmerUtil.LinkedList(); - state.frame['condition'] = IsComponentDefinitionReference.create(state.frame['operand']); - var deopted = this.deopted = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, children); - this._tag.update(deopted.tag); - vm.evaluateOpcode(deopted); - vm.throw(); - // From this point on, we have essentially replaced ourselve with a new - // opcode. Since we will always be executing the new/deopted code, it's a - // good idea (as a pattern) to null out any unneeded fields here to avoid - // holding on to unneeded/stale objects: - this._tag = null; - this.reference = null; - this.cache = null; - this.bounds = null; - this.upsert = null; - this.appendOpcode = null; - this.state = null; - }; + /** + Ends a grouping of property changes. + You can use this method to group property changes so that notifications + will not be sent until the changes are finished. If you plan to make a + large number of changes to an object at one time, you should call + `beginPropertyChanges()` at the beginning of the changes to defer change + notifications. When you are done making changes, call this method to + deliver the deferred change notifications and end deferring. + @method endPropertyChanges + @return {Ember.Observable} + @private + */ + endPropertyChanges: function () { + _emberMetal.endPropertyChanges(); + return this; + }, - GuardedUpdateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var deopted = this.deopted; - - if (deopted) { - return { - guid: guid, - type: type, - deopted: true, - children: [deopted.toJSON()] - }; - } else { - return _UpdateOpcode.prototype.toJSON.call(this); - } - }; + /** + Notify the observer system that a property is about to change. + Sometimes you need to change a value directly or indirectly without + actually calling `get()` or `set()` on it. In this case, you can use this + method and `propertyDidChange()` instead. Calling these two methods + together will notify all observers that the property has potentially + changed value. + Note that you must always call `propertyWillChange` and `propertyDidChange` + as a pair. If you do not, it may get the property change groups out of + order and cause notifications to be delivered more often than you would + like. + @method propertyWillChange + @param {String} keyName The property key that is about to change. + @return {Ember.Observable} + @private + */ + propertyWillChange: function (keyName) { + _emberMetal.propertyWillChange(this, keyName); + return this; + }, - return GuardedUpdateOpcode; - })(UpdateOpcode); + /** + Notify the observer system that a property has just changed. + Sometimes you need to change a value directly or indirectly without + actually calling `get()` or `set()` on it. In this case, you can use this + method and `propertyWillChange()` instead. Calling these two methods + together will notify all observers that the property has potentially + changed value. + Note that you must always call `propertyWillChange` and `propertyDidChange` + as a pair. If you do not, it may get the property change groups out of + order and cause notifications to be delivered more often than you would + like. + @method propertyDidChange + @param {String} keyName The property key that has just changed. + @return {Ember.Observable} + @private + */ + propertyDidChange: function (keyName) { + _emberMetal.propertyDidChange(this, keyName); + return this; + }, - var OptimizedCautiousAppendOpcode = (function (_AppendOpcode2) { - babelHelpers.inherits(OptimizedCautiousAppendOpcode, _AppendOpcode2); + /** + Convenience method to call `propertyWillChange` and `propertyDidChange` in + succession. + @method notifyPropertyChange + @param {String} keyName The property key to be notified about. + @return {Ember.Observable} + @public + */ + notifyPropertyChange: function (keyName) { + this.propertyWillChange(keyName); + this.propertyDidChange(keyName); + return this; + }, - function OptimizedCautiousAppendOpcode() { - _AppendOpcode2.apply(this, arguments); - this.type = 'optimized-cautious-append'; + /** + Adds an observer on a property. + This is the core method used to register an observer for a property. + Once you call this method, any time the key's value is set, your observer + will be notified. Note that the observers are triggered any time the + value is set, regardless of whether it has actually changed. Your + observer should be prepared to handle that. + ### Observer Methods + Observer methods have the following signature: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + this.addObserver('foo', this, 'fooDidChange'); + }, + fooDidChange(sender, key, value, rev) { + // your code } + }); + ``` + The `sender` is the object that changed. The `key` is the property that + changes. The `value` property is currently reserved and unused. The `rev` + is the last property revision of the object when it changed, which you can + use to detect if the key value has really changed or not. + Usually you will not need the value or revision parameters at + the end. In this case, it is common to write observer methods that take + only a sender and key value as parameters or, if you aren't interested in + any of these values, to write an observer that has no parameters at all. + @method addObserver + @param {String} key The key to observer + @param {Object} target The target object to invoke + @param {String|Function} method The method to invoke. + @public + */ + addObserver: function (key, target, method) { + _emberMetal.addObserver(this, key, target, method); + }, - OptimizedCautiousAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeValue); - }; + /** + Remove an observer you have previously registered on this object. Pass + the same key, target, and method you passed to `addObserver()` and your + target will no longer receive notifications. + @method removeObserver + @param {String} key The key to observer + @param {Object} target The target object to invoke + @param {String|Function} method The method to invoke. + @public + */ + removeObserver: function (key, target, method) { + _emberMetal.removeObserver(this, key, target, method); + }, - OptimizedCautiousAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + /** + Returns `true` if the object currently has observers registered for a + particular key. You can use this method to potentially defer performing + an expensive action until someone begins observing a particular property + on the object. + @method hasObserverFor + @param {String} key Key to check + @return {Boolean} + @private + */ + hasObserverFor: function (key) { + return _emberMetal.hasListeners(this, key + ':change'); + }, - OptimizedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new OptimizedCautiousUpdateOpcode(cache, bounds, upsert); - }; + /** + Retrieves the value of a property, or a default value in the case that the + property returns `undefined`. + ```javascript + person.getWithDefault('lastName', 'Doe'); + ``` + @method getWithDefault + @param {String} keyName The name of the property to retrieve + @param {Object} defaultValue The value to return if the property value is undefined + @return {Object} The property value or the defaultValue. + @public + */ + getWithDefault: function (keyName, defaultValue) { + return _emberMetal.getWithDefault(this, keyName, defaultValue); + }, - return OptimizedCautiousAppendOpcode; - })(AppendOpcode); + /** + Set the value of a property to the current value plus some amount. + ```javascript + person.incrementProperty('age'); + team.incrementProperty('score', 2); + ``` + @method incrementProperty + @param {String} keyName The name of the property to increment + @param {Number} increment The amount to increment by. Defaults to 1 + @return {Number} The new property value + @public + */ + incrementProperty: function (keyName, increment) { + if (_emberMetal.isNone(increment)) { + increment = 1; + } + _emberMetal.assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment)); + return _emberMetal.set(this, keyName, (parseFloat(_emberMetal.get(this, keyName)) || 0) + increment); + }, - exports.OptimizedCautiousAppendOpcode = OptimizedCautiousAppendOpcode; + /** + Set the value of a property to the current value minus some amount. + ```javascript + player.decrementProperty('lives'); + orc.decrementProperty('health', 5); + ``` + @method decrementProperty + @param {String} keyName The name of the property to decrement + @param {Number} decrement The amount to decrement by. Defaults to 1 + @return {Number} The new property value + @public + */ + decrementProperty: function (keyName, decrement) { + if (_emberMetal.isNone(decrement)) { + decrement = 1; + } + _emberMetal.assert('Must pass a numeric value to decrementProperty', !isNaN(parseFloat(decrement)) && isFinite(decrement)); + return _emberMetal.set(this, keyName, (_emberMetal.get(this, keyName) || 0) - decrement); + }, - var OptimizedCautiousUpdateOpcode = (function (_UpdateOpcode2) { - babelHelpers.inherits(OptimizedCautiousUpdateOpcode, _UpdateOpcode2); + /** + Set the value of a boolean property to the opposite of its + current value. + ```javascript + starship.toggleProperty('warpDriveEngaged'); + ``` + @method toggleProperty + @param {String} keyName The name of the property to toggle + @return {Boolean} The new property value + @public + */ + toggleProperty: function (keyName) { + return _emberMetal.set(this, keyName, !_emberMetal.get(this, keyName)); + }, - function OptimizedCautiousUpdateOpcode() { - _UpdateOpcode2.apply(this, arguments); - this.type = 'optimized-cautious-update'; - } + /** + Returns the cached value of a computed property, if it exists. + This allows you to inspect the value of a computed property + without accidentally invoking it if it is intended to be + generated lazily. + @method cacheFor + @param {String} keyName + @return {Object} The cached value of the computed property, if any + @public + */ + cacheFor: function (keyName) { + return _emberMetal.cacheFor(this, keyName); + }, - OptimizedCautiousUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + // intended for debugging purposes + observersForKey: function (keyName) { + return _emberMetal.observersFor(this, keyName); + } + }); +}); +enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros) { + 'use strict'; - return OptimizedCautiousUpdateOpcode; - })(UpdateOpcode); + /** + @module ember + @submodule ember-runtime + */ - var GuardedCautiousAppendOpcode = (function (_GuardedAppendOpcode) { - babelHelpers.inherits(GuardedCautiousAppendOpcode, _GuardedAppendOpcode); + function tap(proxy, promise) { + _emberMetal.setProperties(proxy, { + isFulfilled: false, + isRejected: false + }); - function GuardedCautiousAppendOpcode() { - _GuardedAppendOpcode.apply(this, arguments); - this.type = 'guarded-cautious-append'; - this.AppendOpcode = OptimizedCautiousAppendOpcode; - } + return promise.then(function (value) { + if (!proxy.isDestroyed && !proxy.isDestroying) { + _emberMetal.setProperties(proxy, { + content: value, + isFulfilled: true + }); + } + return value; + }, function (reason) { + if (!proxy.isDestroyed && !proxy.isDestroying) { + _emberMetal.setProperties(proxy, { + reason: reason, + isRejected: true + }); + } + throw reason; + }, 'Ember: PromiseProxy'); + } - GuardedCautiousAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeValue); - }; + /** + A low level mixin making ObjectProxy promise-aware. + + ```javascript + let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); + + let proxy = ObjectPromiseProxy.create({ + promise: Ember.RSVP.cast($.getJSON('/some/remote/data.json')) + }); + + proxy.then(function(json){ + // the json + }, function(reason) { + // the reason why you have no json + }); + ``` + + the proxy has bindable attributes which + track the promises life cycle + + ```javascript + proxy.get('isPending') //=> true + proxy.get('isSettled') //=> false + proxy.get('isRejected') //=> false + proxy.get('isFulfilled') //=> false + ``` + + When the $.getJSON completes, and the promise is fulfilled + with json, the life cycle attributes will update accordingly. + Note that $.getJSON doesn't return an ECMA specified promise, + it is useful to wrap this with an `RSVP.cast` so that it behaves + as a spec compliant promise. + + ```javascript + proxy.get('isPending') //=> false + proxy.get('isSettled') //=> true + proxy.get('isRejected') //=> false + proxy.get('isFulfilled') //=> true + ``` + + As the proxy is an ObjectProxy, and the json now its content, + all the json properties will be available directly from the proxy. + + ```javascript + // Assuming the following json: + { + firstName: 'Stefan', + lastName: 'Penner' + } + + // both properties will accessible on the proxy + proxy.get('firstName') //=> 'Stefan' + proxy.get('lastName') //=> 'Penner' + ``` + + @class Ember.PromiseProxyMixin + @public + */ + exports.default = _emberMetal.Mixin.create({ + /** + If the proxied promise is rejected this will contain the reason + provided. + @property reason + @default null + @public + */ + reason: null, - GuardedCautiousAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + /** + Once the proxied promise has settled this will become `false`. + @property isPending + @default true + @public + */ + isPending: _emberRuntimeComputedComputed_macros.not('isSettled').readOnly(), - GuardedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new GuardedCautiousUpdateOpcode(reference, cache, bounds, upsert, this, vm.capture()); - }; + /** + Once the proxied promise has settled this will become `true`. + @property isSettled + @default false + @public + */ + isSettled: _emberRuntimeComputedComputed_macros.or('isRejected', 'isFulfilled').readOnly(), - return GuardedCautiousAppendOpcode; - })(GuardedAppendOpcode); + /** + Will become `true` if the proxied promise is rejected. + @property isRejected + @default false + @public + */ + isRejected: false, - exports.GuardedCautiousAppendOpcode = GuardedCautiousAppendOpcode; + /** + Will become `true` if the proxied promise is fulfilled. + @property isFulfilled + @default false + @public + */ + isFulfilled: false, - var GuardedCautiousUpdateOpcode = (function (_GuardedUpdateOpcode) { - babelHelpers.inherits(GuardedCautiousUpdateOpcode, _GuardedUpdateOpcode); + /** + The promise whose fulfillment value is being proxied by this object. + This property must be specified upon creation, and should not be + changed once created. + Example: + ```javascript + Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({ + promise: + }); + ``` + @property promise + @public + */ + promise: _emberMetal.computed({ + get: function () { + throw new _emberMetal.Error('PromiseProxy\'s promise must be set'); + }, + set: function (key, promise) { + return tap(this, promise); + } + }), - function GuardedCautiousUpdateOpcode() { - _GuardedUpdateOpcode.apply(this, arguments); - this.type = 'guarded-cautious-update'; - } + /** + An alias to the proxied promise's `then`. + See RSVP.Promise.then. + @method then + @param {Function} callback + @return {RSVP.Promise} + @public + */ + then: promiseAlias('then'), - GuardedCautiousUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + /** + An alias to the proxied promise's `catch`. + See RSVP.Promise.catch. + @method catch + @param {Function} callback + @return {RSVP.Promise} + @since 1.3.0 + @public + */ + 'catch': promiseAlias('catch'), - return GuardedCautiousUpdateOpcode; - })(GuardedUpdateOpcode); + /** + An alias to the proxied promise's `finally`. + See RSVP.Promise.finally. + @method finally + @param {Function} callback + @return {RSVP.Promise} + @since 1.3.0 + @public + */ + 'finally': promiseAlias('finally') - var OptimizedTrustingAppendOpcode = (function (_AppendOpcode3) { - babelHelpers.inherits(OptimizedTrustingAppendOpcode, _AppendOpcode3); + }); - function OptimizedTrustingAppendOpcode() { - _AppendOpcode3.apply(this, arguments); - this.type = 'optimized-trusting-append'; - } + function promiseAlias(name) { + return function () { + var promise = _emberMetal.get(this, 'promise'); + return promise[name].apply(promise, arguments); + }; + } +}); +enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - OptimizedTrustingAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeTrustedValue); - }; + 'use strict'; - OptimizedTrustingAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + exports.buildFakeRegistryWithDeprecations = buildFakeRegistryWithDeprecations; - OptimizedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new OptimizedTrustingUpdateOpcode(cache, bounds, upsert); - }; + /** + RegistryProxyMixin is used to provide public access to specific + registry functionality. + + @class RegistryProxyMixin + @private + */ + exports.default = _emberMetal.Mixin.create({ + __registry__: null, - return OptimizedTrustingAppendOpcode; - })(AppendOpcode); + /** + Given a fullName return the corresponding factory. + @public + @method resolveRegistration + @param {String} fullName + @return {Function} fullName's factory + */ + resolveRegistration: registryAlias('resolve'), - exports.OptimizedTrustingAppendOpcode = OptimizedTrustingAppendOpcode; + /** + Registers a factory that can be used for dependency injection (with + `inject`) or for service lookup. Each factory is registered with + a full name including two parts: `type:name`. + A simple example: + ```javascript + let App = Ember.Application.create(); + App.Orange = Ember.Object.extend(); + App.register('fruit:favorite', App.Orange); + ``` + Ember will resolve factories from the `App` namespace automatically. + For example `App.CarsController` will be discovered and returned if + an application requests `controller:cars`. + An example of registering a controller with a non-standard name: + ```javascript + let App = Ember.Application.create(); + let Session = Ember.Controller.extend(); + App.register('controller:session', Session); + // The Session controller can now be treated like a normal controller, + // despite its non-standard name. + App.ApplicationController = Ember.Controller.extend({ + needs: ['session'] + }); + ``` + Registered factories are **instantiated** by having `create` + called on them. Additionally they are **singletons**, each time + they are looked up they return the same instance. + Some examples modifying that default behavior: + ```javascript + let App = Ember.Application.create(); + App.Person = Ember.Object.extend(); + App.Orange = Ember.Object.extend(); + App.Email = Ember.Object.extend(); + App.session = Ember.Object.create(); + App.register('model:user', App.Person, { singleton: false }); + App.register('fruit:favorite', App.Orange); + App.register('communication:main', App.Email, { singleton: false }); + App.register('session', App.session, { instantiate: false }); + ``` + @method register + @param fullName {String} type:name (e.g., 'model:user') + @param factory {Function} (e.g., App.Person) + @param options {Object} (optional) disable instantiation or singleton usage + @public + */ + register: registryAlias('register'), - var OptimizedTrustingUpdateOpcode = (function (_UpdateOpcode3) { - babelHelpers.inherits(OptimizedTrustingUpdateOpcode, _UpdateOpcode3); + /** + Unregister a factory. + ```javascript + let App = Ember.Application.create(); + let User = Ember.Object.extend(); + App.register('model:user', User); + App.resolveRegistration('model:user').create() instanceof User //=> true + App.unregister('model:user') + App.resolveRegistration('model:user') === undefined //=> true + ``` + @public + @method unregister + @param {String} fullName + */ + unregister: registryAlias('unregister'), - function OptimizedTrustingUpdateOpcode() { - _UpdateOpcode3.apply(this, arguments); - this.type = 'optimized-trusting-update'; - } + /** + Check if a factory is registered. + @public + @method hasRegistration + @param {String} fullName + @return {Boolean} + */ + hasRegistration: registryAlias('has'), - OptimizedTrustingUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + /** + Register an option for a particular factory. + @public + @method registerOption + @param {String} fullName + @param {String} optionName + @param {Object} options + */ + registerOption: registryAlias('option'), - return OptimizedTrustingUpdateOpcode; - })(UpdateOpcode); + /** + Return a specific registered option for a particular factory. + @public + @method registeredOption + @param {String} fullName + @param {String} optionName + @return {Object} options + */ + registeredOption: registryAlias('getOption'), - var GuardedTrustingAppendOpcode = (function (_GuardedAppendOpcode2) { - babelHelpers.inherits(GuardedTrustingAppendOpcode, _GuardedAppendOpcode2); + /** + Register options for a particular factory. + @public + @method registerOptions + @param {String} fullName + @param {Object} options + */ + registerOptions: registryAlias('options'), - function GuardedTrustingAppendOpcode() { - _GuardedAppendOpcode2.apply(this, arguments); - this.type = 'guarded-trusting-append'; - this.AppendOpcode = OptimizedTrustingAppendOpcode; - } + /** + Return registered options for a particular factory. + @public + @method registeredOptions + @param {String} fullName + @return {Object} options + */ + registeredOptions: registryAlias('getOptions'), - GuardedTrustingAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeTrustedValue); - }; + /** + Allow registering options for all factories of a type. + ```javascript + let App = Ember.Application.create(); + let appInstance = App.buildInstance(); + // if all of type `connection` must not be singletons + appInstance.registerOptionsForType('connection', { singleton: false }); + appInstance.register('connection:twitter', TwitterConnection); + appInstance.register('connection:facebook', FacebookConnection); + let twitter = appInstance.lookup('connection:twitter'); + let twitter2 = appInstance.lookup('connection:twitter'); + twitter === twitter2; // => false + let facebook = appInstance.lookup('connection:facebook'); + let facebook2 = appInstance.lookup('connection:facebook'); + facebook === facebook2; // => false + ``` + @public + @method registerOptionsForType + @param {String} type + @param {Object} options + */ + registerOptionsForType: registryAlias('optionsForType'), - GuardedTrustingAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + /** + Return the registered options for all factories of a type. + @public + @method registeredOptionsForType + @param {String} type + @return {Object} options + */ + registeredOptionsForType: registryAlias('getOptionsForType'), - GuardedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new GuardedTrustingUpdateOpcode(reference, cache, bounds, upsert, this, vm.capture()); - }; + /** + Define a dependency injection onto a specific factory or all factories + of a type. + When Ember instantiates a controller, view, or other framework component + it can attach a dependency to that component. This is often used to + provide services to a set of framework components. + An example of providing a session object to all controllers: + ```javascript + let App = Ember.Application.create(); + let Session = Ember.Object.extend({ isAuthenticated: false }); + // A factory must be registered before it can be injected + App.register('session:main', Session); + // Inject 'session:main' onto all factories of the type 'controller' + // with the name 'session' + App.inject('controller', 'session', 'session:main'); + App.IndexController = Ember.Controller.extend({ + isLoggedIn: Ember.computed.alias('session.isAuthenticated') + }); + ``` + Injections can also be performed on specific factories. + ```javascript + App.inject(, , ) + App.inject('route', 'source', 'source:main') + App.inject('route:application', 'email', 'model:email') + ``` + It is important to note that injections can only be performed on + classes that are instantiated by Ember itself. Instantiating a class + directly (via `create` or `new`) bypasses the dependency injection + system. + **Note:** Ember-Data instantiates its models in a unique manner, and consequently + injections onto models (or all models) will not work as expected. Injections + on models can be enabled by setting `EmberENV.MODEL_FACTORY_INJECTIONS` + to `true`. + @public + @method inject + @param factoryNameOrType {String} + @param property {String} + @param injectionName {String} + **/ + inject: registryAlias('injection') + }); - return GuardedTrustingAppendOpcode; - })(GuardedAppendOpcode); + function registryAlias(name) { + return function () { + var _registry__; - exports.GuardedTrustingAppendOpcode = GuardedTrustingAppendOpcode; + return (_registry__ = this.__registry__)[name].apply(_registry__, arguments); + }; + } - var GuardedTrustingUpdateOpcode = (function (_GuardedUpdateOpcode2) { - babelHelpers.inherits(GuardedTrustingUpdateOpcode, _GuardedUpdateOpcode2); + function buildFakeRegistryWithDeprecations(instance, typeForMessage) { + var fakeRegistry = {}; + var registryProps = { + resolve: 'resolveRegistration', + register: 'register', + unregister: 'unregister', + has: 'hasRegistration', + option: 'registerOption', + options: 'registerOptions', + getOptions: 'registeredOptions', + optionsForType: 'registerOptionsForType', + getOptionsForType: 'registeredOptionsForType', + injection: 'inject' + }; - function GuardedTrustingUpdateOpcode() { - _GuardedUpdateOpcode2.apply(this, arguments); - this.type = 'trusting-update'; - } + for (var deprecatedProperty in registryProps) { + fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]); + } - GuardedTrustingUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + return fakeRegistry; + } - return GuardedTrustingUpdateOpcode; - })(GuardedUpdateOpcode); + function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) { + return function () { + _emberMetal.deprecate('Using `' + typeForMessage + '.registry.' + deprecatedProperty + '` is deprecated. Please use `' + typeForMessage + '.' + nonDeprecatedProperty + '` instead.', false, { + id: 'ember-application.app-instance-registry', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-application-registry-ember-applicationinstance-registry' + }); + return instance[nonDeprecatedProperty].apply(instance, arguments); + }; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9jb250ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBK0JBLGFBQUEsT0FBQSxDQUFpQixLQUFhLEVBQUE7QUFDNUIsZUFBTyxLQUFLLEtBQUssSUFBSSxJQUFJLEtBQUssS0FBSyxTQUFTLElBQUksT0FBTyxLQUF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JkZWRUcnVzdGluZ1VwZGF0ZU9wY29kZSBleHRlbmRzIEd1YXJkZWRVcGRhdGVPcGNvZGU8VHJ1c3RpbmdJbnNlcnRpb24+IHtcbiAgdHlwZSA9ICd0cnVzdGluZy11cGRhdGUnO1xuXG4gIHByb3RlY3RlZCBpbnNlcnQoZG9tOiBET01UcmVlQ29uc3RydWN0aW9uLCBjdXJzb3I6IEN1cnNvciwgdmFsdWU6IFRydXN0aW5nSW5zZXJ0aW9uKTogVXBzZXJ0IHtcbiAgICByZXR1cm4gdHJ1c3RpbmdJbnNlcnQoZG9tLCBjdXJzb3IsIHZhbHVlKTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/dom', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/compiled/opcodes/vm'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibReferences, _glimmerRuntimeLibCompiledOpcodesVm) { - 'use strict'; - - var TextOpcode = (function (_Opcode) { - babelHelpers.inherits(TextOpcode, _Opcode); - - function TextOpcode(text) { - _Opcode.call(this); - this.text = text; - this.type = "text"; - } - - TextOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().appendText(this.text); - }; - - TextOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.text)] - }; - }; +enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - return TextOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + 'use strict'; - exports.TextOpcode = TextOpcode; + /** + `Ember.TargetActionSupport` is a mixin that can be included in a class + to add a `triggerAction` method with semantics similar to the Handlebars + `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is + usually the best choice. This mixin is most often useful when you are + doing more complex event handling in Components. + + @class TargetActionSupport + @namespace Ember + @extends Ember.Mixin + @private + */ + exports.default = _emberMetal.Mixin.create({ + target: null, + action: null, + actionContext: null, - var OpenPrimitiveElementOpcode = (function (_Opcode2) { - babelHelpers.inherits(OpenPrimitiveElementOpcode, _Opcode2); + actionContextObject: _emberMetal.computed('actionContext', function () { + var actionContext = _emberMetal.get(this, 'actionContext'); - function OpenPrimitiveElementOpcode(tag) { - _Opcode2.call(this); - this.tag = tag; - this.type = "open-primitive-element"; + if (typeof actionContext === 'string') { + var value = _emberMetal.get(this, actionContext); + if (value === undefined) { + value = _emberMetal.get(_emberEnvironment.context.lookup, actionContext); } + return value; + } else { + return actionContext; + } + }), - OpenPrimitiveElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().openElement(this.tag); - }; - - OpenPrimitiveElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.tag)] - }; - }; + /** + Send an `action` with an `actionContext` to a `target`. The action, actionContext + and target will be retrieved from properties of the object. For example: + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + action: 'save', + actionContext: Ember.computed.alias('context'), + click() { + this.triggerAction(); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + The `target`, `action`, and `actionContext` can be provided as properties of + an optional object argument to `triggerAction` as well. + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + click() { + this.triggerAction({ + action: 'save', + target: this.get('controller'), + actionContext: this.get('context') + }); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. + But `target` and `action` must be specified either as properties or with the argument + to `triggerAction`, or a combination: + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + click() { + this.triggerAction({ + action: 'save' + }); // Sends the `save` action, along with a reference to `this`, + // to the current controller + } + }); + ``` + @method triggerAction + @param opts {Object} (optional, with the optional keys action, target and/or actionContext) + @return {Boolean} true if the action was sent successfully and did not return false + @private + */ + triggerAction: function () { + var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - return OpenPrimitiveElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var action = opts.action || _emberMetal.get(this, 'action'); + var target = opts.target; - exports.OpenPrimitiveElementOpcode = OpenPrimitiveElementOpcode; + if (!target) { + target = getTarget(this); + } - var PushRemoteElementOpcode = (function (_Opcode3) { - babelHelpers.inherits(PushRemoteElementOpcode, _Opcode3); + var actionContext = opts.actionContext; - function PushRemoteElementOpcode() { - _Opcode3.apply(this, arguments); - this.type = "push-remote-element"; + function args(options, actionName) { + var ret = []; + if (actionName) { + ret.push(actionName); } - PushRemoteElementOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var element = cache ? cache.peek() : reference.value(); - vm.stack().pushRemoteElement(element); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; + return ret.concat(options); + } - PushRemoteElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ['$OPERAND'] - }; - }; + if (typeof actionContext === 'undefined') { + actionContext = _emberMetal.get(this, 'actionContextObject') || this; + } - return PushRemoteElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (target && action) { + var ret = undefined; - exports.PushRemoteElementOpcode = PushRemoteElementOpcode; + if (target.send) { + var _target; - var PopRemoteElementOpcode = (function (_Opcode4) { - babelHelpers.inherits(PopRemoteElementOpcode, _Opcode4); + ret = (_target = target).send.apply(_target, args(actionContext, action)); + } else { + var _target2; - function PopRemoteElementOpcode() { - _Opcode4.apply(this, arguments); - this.type = "pop-remote-element"; + _emberMetal.assert('The action \'' + action + '\' did not exist on ' + target, typeof target[action] === 'function'); + ret = (_target2 = target)[action].apply(_target2, args(actionContext)); } - PopRemoteElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().popRemoteElement(); - }; - - return PopRemoteElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PopRemoteElementOpcode = PopRemoteElementOpcode; - - var OpenComponentElementOpcode = (function (_Opcode5) { - babelHelpers.inherits(OpenComponentElementOpcode, _Opcode5); - - function OpenComponentElementOpcode(tag) { - _Opcode5.call(this); - this.tag = tag; - this.type = "open-component-element"; + if (ret !== false) { + ret = true; } - OpenComponentElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().openElement(this.tag, new ComponentElementOperations(vm.env)); - }; - - OpenComponentElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.tag)] - }; - }; + return ret; + } else { + return false; + } + } + }); - return OpenComponentElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function getTarget(instance) { + // TODO: Deprecate specifying `targetObject` + var target = _emberMetal.get(instance, 'targetObject'); - exports.OpenComponentElementOpcode = OpenComponentElementOpcode; + // if a `targetObject` CP was provided, use it + if (target) { + return target; + } - var OpenDynamicPrimitiveElementOpcode = (function (_Opcode6) { - babelHelpers.inherits(OpenDynamicPrimitiveElementOpcode, _Opcode6); + // if _targetObject use it + if (instance._targetObject) { + return instance._targetObject; + } - function OpenDynamicPrimitiveElementOpcode() { - _Opcode6.apply(this, arguments); - this.type = "open-dynamic-primitive-element"; + target = _emberMetal.get(instance, 'target'); + if (target) { + if (typeof target === 'string') { + var value = _emberMetal.get(instance, target); + if (value === undefined) { + value = _emberMetal.get(_emberEnvironment.context.lookup, target); } - OpenDynamicPrimitiveElementOpcode.prototype.evaluate = function evaluate(vm) { - var tagName = vm.frame.getOperand().value(); - vm.stack().openElement(tagName); - }; - - OpenDynamicPrimitiveElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + return value; + } else { + return target; + } + } - return OpenDynamicPrimitiveElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + return null; + } +}); +enifed("ember-runtime/string_registry", ["exports"], function (exports) { + // STATE within a module is frowned apon, this exists + // to support Ember.STRINGS but shield ember internals from this legacy global + // API. + "use strict"; - exports.OpenDynamicPrimitiveElementOpcode = OpenDynamicPrimitiveElementOpcode; + exports.setStrings = setStrings; + exports.getStrings = getStrings; + exports.get = get; + var STRINGS = {}; - var ClassList = (function () { - function ClassList() { - this.list = null; - this.isConst = true; - } + function setStrings(strings) { + STRINGS = strings; + } - ClassList.prototype.append = function append(reference) { - var list = this.list; - var isConst = this.isConst; + function getStrings() { + return STRINGS; + } - if (list === null) list = this.list = []; - list.push(reference); - this.isConst = isConst && _glimmerReference.isConst(reference); - }; + function get(name) { + return STRINGS[name]; + } +}); +enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) { + 'use strict'; - ClassList.prototype.toReference = function toReference() { - var list = this.list; - var isConst = this.isConst; + exports.default = _emberRuntimeSystemNamespace.default.extend(); +}); +enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray) { + 'use strict'; - if (!list) return _glimmerRuntimeLibReferences.NULL_REFERENCE; - if (isConst) return _glimmerRuntimeLibReferences.PrimitiveReference.create(toClassName(list)); - return new ClassListReference(list); - }; + /** + @module ember + @submodule ember-runtime + */ - return ClassList; - })(); + var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; + var EMPTY = []; - var ClassListReference = (function (_CachedReference) { - babelHelpers.inherits(ClassListReference, _CachedReference); + function K() { + return this; + } - function ClassListReference(list) { - _CachedReference.call(this); - this.list = []; - this.tag = _glimmerReference.combineTagged(list); - this.list = list; + /** + An ArrayProxy wraps any other object that implements `Ember.Array` and/or + `Ember.MutableArray,` forwarding all requests. This makes it very useful for + a number of binding use cases or other cases where being able to swap + out the underlying array is useful. + + A simple example of usage: + + ```javascript + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); + + ap.get('firstObject'); // 'dog' + ap.set('content', ['amoeba', 'paramecium']); + ap.get('firstObject'); // 'amoeba' + ``` + + This class can also be useful as a layer to transform the contents of + an array, as they are accessed. This can be done by overriding + `objectAtContent`: + + ```javascript + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ + content: Ember.A(pets), + objectAtContent: function(idx) { + return this.get('content').objectAt(idx).toUpperCase(); } + }); + + ap.get('firstObject'); // . 'DOG' + ``` + + @class ArrayProxy + @namespace Ember + @extends Ember.Object + @uses Ember.MutableArray + @public + */ + exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { - ClassListReference.prototype.compute = function compute() { - return toClassName(this.list); - }; + /** + The content array. Must be an object that implements `Ember.Array` and/or + `Ember.MutableArray.` + @property content + @type Ember.Array + @private + */ + content: null, - return ClassListReference; - })(_glimmerReference.CachedReference); + /** + The array that the proxy pretends to be. In the default `ArrayProxy` + implementation, this and `content` are the same. Subclasses of `ArrayProxy` + can override this property to provide things like sorting and filtering. + @property arrangedContent + @private + */ + arrangedContent: _emberMetal.alias('content'), - function toClassName(list) { - var ret = []; - for (var i = 0; i < list.length; i++) { - var value = list[i].value(); - if (value !== false && value !== null && value !== undefined) ret.push(value); - } - return ret.length === 0 ? null : ret.join(' '); - } + /** + Should actually retrieve the object at the specified index from the + content. You can override this method in subclasses to transform the + content item to something new. + This method will only be called if content is non-`null`. + @method objectAtContent + @param {Number} idx The index to retrieve. + @return {Object} the value or undefined if none found + @public + */ + objectAtContent: function (idx) { + return _emberRuntimeMixinsArray.objectAt(_emberMetal.get(this, 'arrangedContent'), idx); + }, - var SimpleElementOperations = (function () { - function SimpleElementOperations(env) { - this.env = env; - this.opcodes = null; - this.classList = null; - } + /** + Should actually replace the specified objects on the content array. + You can override this method in subclasses to transform the content item + into something new. + This method will only be called if content is non-`null`. + @method replaceContent + @param {Number} idx The starting index + @param {Number} amt The number of items to remove from the content. + @param {Array} objects Optional array of objects to insert or null if no + objects. + @return {void} + @private + */ + replaceContent: function (idx, amt, objects) { + _emberMetal.get(this, 'content').replace(idx, amt, objects); + }, - SimpleElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element, name, value) { - if (name === 'class') { - this.addClass(_glimmerRuntimeLibReferences.PrimitiveReference.create(value)); - } else { - this.env.getAppendOperations().setAttribute(element, name, value); - } - }; + /** + Invoked when the content property is about to change. Notifies observers that the + entire array content will change. + @private + @method _contentWillChange + */ + _contentWillChange: _emberMetal._beforeObserver('content', function () { + this._teardownContent(); + }), - SimpleElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element, namespace, name, value) { - this.env.getAppendOperations().setAttribute(element, name, value, namespace); - }; + _teardownContent: function () { + var content = _emberMetal.get(this, 'content'); - SimpleElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element, name, reference, isTrusting) { - if (name === 'class') { - this.addClass(reference); - } else { - var attributeManager = this.env.attributeFor(element, name, isTrusting); - var attribute = new DynamicAttribute(element, attributeManager, name, reference); - this.addAttribute(attribute); - } - }; + if (content) { + _emberRuntimeMixinsArray.removeArrayObserver(content, this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + } + }, - SimpleElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element, namespace, name, reference, isTrusting) { - var attributeManager = this.env.attributeFor(element, name, isTrusting, namespace); - var nsAttribute = new DynamicAttribute(element, attributeManager, name, reference, namespace); - this.addAttribute(nsAttribute); - }; + /** + Override to implement content array `willChange` observer. + @method contentArrayWillChange + @param {Ember.Array} contentArray the content array + @param {Number} start starting index of the change + @param {Number} removeCount count of items removed + @param {Number} addCount count of items added + @private + */ + contentArrayWillChange: K, + /** + Override to implement content array `didChange` observer. + @method contentArrayDidChange + @param {Ember.Array} contentArray the content array + @param {Number} start starting index of the change + @param {Number} removeCount count of items removed + @param {Number} addCount count of items added + @private + */ + contentArrayDidChange: K, - SimpleElementOperations.prototype.flush = function flush(element, vm) { - var env = vm.env; - var opcodes = this.opcodes; - var classList = this.classList; + /** + Invoked when the content property changes. Notifies observers that the + entire array content has changed. + @private + @method _contentDidChange + */ + _contentDidChange: _emberMetal.observer('content', function () { + var content = _emberMetal.get(this, 'content'); - for (var i = 0; opcodes && i < opcodes.length; i++) { - vm.updateWith(opcodes[i]); - } - if (classList) { - var attributeManager = env.attributeFor(element, 'class', false); - var attribute = new DynamicAttribute(element, attributeManager, 'class', classList.toReference()); - var opcode = attribute.flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - this.opcodes = null; - this.classList = null; - }; + _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', content !== this); - SimpleElementOperations.prototype.addClass = function addClass(reference) { - var classList = this.classList; + this._setupContent(); + }), - if (!classList) { - classList = this.classList = new ClassList(); - } - classList.append(reference); - }; + _setupContent: function () { + var content = _emberMetal.get(this, 'content'); - SimpleElementOperations.prototype.addAttribute = function addAttribute(attribute) { - var opcode = attribute.flush(this.env); - if (opcode) { - var opcodes = this.opcodes; + if (content) { + _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof content, _emberRuntimeUtils.isArray(content) || content.isDestroyed); - if (!opcodes) { - opcodes = this.opcodes = []; - } - opcodes.push(opcode); - } - }; + _emberRuntimeMixinsArray.addArrayObserver(content, this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + } + }, - return SimpleElementOperations; - })(); + _arrangedContentWillChange: _emberMetal._beforeObserver('arrangedContent', function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - exports.SimpleElementOperations = SimpleElementOperations; + this.arrangedContentArrayWillChange(this, 0, len, undefined); + this.arrangedContentWillChange(this); - var ComponentElementOperations = (function () { - function ComponentElementOperations(env) { - this.env = env; - this.attributeNames = null; - this.attributes = null; - this.classList = null; - } + this._teardownArrangedContent(arrangedContent); + }), - ComponentElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element, name, value) { - if (name === 'class') { - this.addClass(_glimmerRuntimeLibReferences.PrimitiveReference.create(value)); - } else if (this.shouldAddAttribute(name)) { - this.addAttribute(name, new StaticAttribute(element, name, value)); - } - }; + _arrangedContentDidChange: _emberMetal.observer('arrangedContent', function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - ComponentElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element, namespace, name, value) { - if (this.shouldAddAttribute(name)) { - this.addAttribute(name, new StaticAttribute(element, name, value, namespace)); - } - }; + _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this); - ComponentElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element, name, reference, isTrusting) { - if (name === 'class') { - this.addClass(reference); - } else if (this.shouldAddAttribute(name)) { - var attributeManager = this.env.attributeFor(element, name, isTrusting); - var attribute = new DynamicAttribute(element, attributeManager, name, reference); - this.addAttribute(name, attribute); - } - }; + this._setupArrangedContent(); - ComponentElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element, namespace, name, reference, isTrusting) { - if (this.shouldAddAttribute(name)) { - var attributeManager = this.env.attributeFor(element, name, isTrusting, namespace); - var nsAttribute = new DynamicAttribute(element, attributeManager, name, reference, namespace); - this.addAttribute(name, nsAttribute); - } - }; + this.arrangedContentDidChange(this); + this.arrangedContentArrayDidChange(this, 0, undefined, len); + }), - ComponentElementOperations.prototype.flush = function flush(element, vm) { - var env = this.env; - var attributes = this.attributes; - var classList = this.classList; + _setupArrangedContent: function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - for (var i = 0; attributes && i < attributes.length; i++) { - var opcode = attributes[i].flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - if (classList) { - var attributeManager = env.attributeFor(element, 'class', false); - var attribute = new DynamicAttribute(element, attributeManager, 'class', classList.toReference()); - var opcode = attribute.flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - }; + if (arrangedContent) { + _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof arrangedContent, _emberRuntimeUtils.isArray(arrangedContent) || arrangedContent.isDestroyed); - ComponentElementOperations.prototype.shouldAddAttribute = function shouldAddAttribute(name) { - return !this.attributeNames || this.attributeNames.indexOf(name) === -1; - }; + _emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, { + willChange: 'arrangedContentArrayWillChange', + didChange: 'arrangedContentArrayDidChange' + }); + } + }, - ComponentElementOperations.prototype.addClass = function addClass(reference) { - var classList = this.classList; + _teardownArrangedContent: function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - if (!classList) { - classList = this.classList = new ClassList(); - } - classList.append(reference); - }; + if (arrangedContent) { + _emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, { + willChange: 'arrangedContentArrayWillChange', + didChange: 'arrangedContentArrayDidChange' + }); + } + }, - ComponentElementOperations.prototype.addAttribute = function addAttribute(name, attribute) { - var attributeNames = this.attributeNames; - var attributes = this.attributes; + arrangedContentWillChange: K, + arrangedContentDidChange: K, - if (!attributeNames) { - attributeNames = this.attributeNames = []; - attributes = this.attributes = []; - } - attributeNames.push(name); - attributes.push(attribute); - }; + objectAt: function (idx) { + return _emberMetal.get(this, 'content') && this.objectAtContent(idx); + }, - return ComponentElementOperations; - })(); + length: _emberMetal.computed(function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + return arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + // No dependencies since Enumerable notifies length of change + }), - exports.ComponentElementOperations = ComponentElementOperations; + _replace: function (idx, amt, objects) { + var content = _emberMetal.get(this, 'content'); + _emberMetal.assert('The content property of ' + this.constructor + ' should be set before modifying it', content); + if (content) { + this.replaceContent(idx, amt, objects); + } - var FlushElementOpcode = (function (_Opcode7) { - babelHelpers.inherits(FlushElementOpcode, _Opcode7); + return this; + }, - function FlushElementOpcode() { - _Opcode7.apply(this, arguments); - this.type = "flush-element"; - } + replace: function () { + if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { + this._replace.apply(this, arguments); + } else { + throw new _emberMetal.Error('Using replace on an arranged ArrayProxy is not allowed.'); + } + }, - FlushElementOpcode.prototype.evaluate = function evaluate(vm) { - var stack = vm.stack(); - stack.operations.flush(stack.constructing, vm); - stack.flushElement(); - }; + _insertAt: function (idx, object) { + if (idx > _emberMetal.get(this, 'content.length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - return FlushElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + this._replace(idx, 0, [object]); + return this; + }, - exports.FlushElementOpcode = FlushElementOpcode; + insertAt: function (idx, object) { + if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { + return this._insertAt(idx, object); + } else { + throw new _emberMetal.Error('Using insertAt on an arranged ArrayProxy is not allowed.'); + } + }, - var CloseElementOpcode = (function (_Opcode8) { - babelHelpers.inherits(CloseElementOpcode, _Opcode8); + removeAt: function (start, len) { + if ('number' === typeof start) { + var content = _emberMetal.get(this, 'content'); + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var indices = []; - function CloseElementOpcode() { - _Opcode8.apply(this, arguments); - this.type = "close-element"; + if (start < 0 || start >= _emberMetal.get(this, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); } - CloseElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().closeElement(); - }; - - return CloseElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.CloseElementOpcode = CloseElementOpcode; - - var PopElementOpcode = (function (_Opcode9) { - babelHelpers.inherits(PopElementOpcode, _Opcode9); - - function PopElementOpcode() { - _Opcode9.apply(this, arguments); - this.type = "pop-element"; + if (len === undefined) { + len = 1; } - PopElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().popElement(); - }; - - return PopElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PopElementOpcode = PopElementOpcode; + // Get a list of indices in original content to remove + for (var i = start; i < start + len; i++) { + // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent + indices.push(content.indexOf(_emberRuntimeMixinsArray.objectAt(arrangedContent, i))); + } - var StaticAttrOpcode = (function (_Opcode10) { - babelHelpers.inherits(StaticAttrOpcode, _Opcode10); + // Replace in reverse order since indices will change + indices.sort(function (a, b) { + return b - a; + }); - function StaticAttrOpcode(namespace, name, value) { - _Opcode10.call(this); - this.namespace = namespace; - this.name = name; - this.value = value; - this.type = "static-attr"; + _emberMetal.beginPropertyChanges(); + for (var i = 0; i < indices.length; i++) { + this._replace(indices[i], 1, EMPTY); } + _emberMetal.endPropertyChanges(); + } - StaticAttrOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var value = this.value; - var namespace = this.namespace; + return this; + }, - if (namespace) { - vm.stack().setStaticAttributeNS(namespace, name, value); - } else { - vm.stack().setStaticAttribute(name, value); - } - }; + pushObject: function (obj) { + this._insertAt(_emberMetal.get(this, 'content.length'), obj); + return obj; + }, - StaticAttrOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var namespace = this.namespace; - var name = this.name; - var value = this.value; + pushObjects: function (objects) { + if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || _emberRuntimeUtils.isArray(objects))) { + throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + } + this._replace(_emberMetal.get(this, 'length'), 0, objects); + return this; + }, - var details = _glimmerUtil.dict(); - if (namespace) { - details["namespace"] = JSON.stringify(namespace); - } - details["name"] = JSON.stringify(name); - details["value"] = JSON.stringify(value); - return { guid: guid, type: type, details: details }; - }; + setObjects: function (objects) { + if (objects.length === 0) { + return this.clear(); + } - return StaticAttrOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var len = _emberMetal.get(this, 'length'); + this._replace(0, len, objects); + return this; + }, - exports.StaticAttrOpcode = StaticAttrOpcode; + unshiftObject: function (obj) { + this._insertAt(0, obj); + return obj; + }, - var ModifierOpcode = (function (_Opcode11) { - babelHelpers.inherits(ModifierOpcode, _Opcode11); + unshiftObjects: function (objects) { + this._replace(0, 0, objects); + return this; + }, - function ModifierOpcode(name, manager, args) { - _Opcode11.call(this); - this.name = name; - this.manager = manager; - this.args = args; - this.type = "modifier"; - } + slice: function () { + var arr = this.toArray(); + return arr.slice.apply(arr, arguments); + }, - ModifierOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; + arrangedContentArrayWillChange: function (item, idx, removedCnt, addedCnt) { + this.arrayContentWillChange(idx, removedCnt, addedCnt); + }, - var stack = vm.stack(); - var element = stack.constructing; - var updateOperations = stack.updateOperations; + arrangedContentArrayDidChange: function (item, idx, removedCnt, addedCnt) { + this.arrayContentDidChange(idx, removedCnt, addedCnt); + }, - var args = this.args.evaluate(vm); - var dynamicScope = vm.dynamicScope(); - var modifier = manager.create(element, args, dynamicScope, updateOperations); - vm.env.scheduleInstallModifier(modifier, manager); - var destructor = manager.getDestructor(modifier); - if (destructor) { - vm.newDestroyable(destructor); - } - vm.updateWith(new UpdateModifierOpcode(manager, modifier, args)); - }; + init: function () { + this._super.apply(this, arguments); + this._setupContent(); + this._setupArrangedContent(); + }, - ModifierOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; - var args = this.args; - - var details = _glimmerUtil.dict(); - details["type"] = JSON.stringify(type); - details["name"] = JSON.stringify(name); - details["args"] = JSON.stringify(args); - return { guid: guid, type: type, details: details }; - }; + willDestroy: function () { + this._teardownArrangedContent(); + this._teardownContent(); + } + }); +}); +enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/inject'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeInject) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - return ModifierOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + @module ember + @submodule ember-runtime + */ - exports.ModifierOpcode = ModifierOpcode; + // using ember-metal/lib/main here to ensure that ember-debug is setup + // if present - var UpdateModifierOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateModifierOpcode, _UpdatingOpcode); + var _Mixin$create, _ClassMixinProps; - function UpdateModifierOpcode(manager, modifier, args) { - _UpdatingOpcode.call(this); - this.manager = manager; - this.modifier = modifier; - this.args = args; - this.type = "update-modifier"; - this.tag = args.tag; - this.lastUpdated = args.tag.value(); - } + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['.'], ['.']); - UpdateModifierOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; - var modifier = this.modifier; - var tag = this.tag; - var lastUpdated = this.lastUpdated; + var schedule = _emberMetal.run.schedule; + var applyMixin = _emberMetal.Mixin._apply; + var finishPartial = _emberMetal.Mixin.finishPartial; + var reopen = _emberMetal.Mixin.prototype.reopen; + var hasCachedComputedProperties = false; - if (!tag.validate(lastUpdated)) { - vm.env.scheduleUpdateModifier(modifier, manager); - this.lastUpdated = tag.value(); - } - }; + var POST_INIT = _emberUtils.symbol('POST_INIT'); - UpdateModifierOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.args)] - }; - }; + exports.POST_INIT = POST_INIT; + function makeCtor() { + // Note: avoid accessing any properties on the object since it makes the + // method a lot faster. This is glue code so we want it to be as fast as + // possible. - return UpdateModifierOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + var wasApplied = false; + var initProperties = undefined; - exports.UpdateModifierOpcode = UpdateModifierOpcode; + var Class = (function () { + function Class() { +babelHelpers.classCallCheck(this, Class); - var StaticAttribute = (function () { - function StaticAttribute(element, name, value, namespace) { - this.element = element; - this.name = name; - this.value = value; - this.namespace = namespace; + if (!wasApplied) { + Class.proto(); // prepare prototype... } - StaticAttribute.prototype.flush = function flush(env) { - env.getAppendOperations().setAttribute(this.element, this.name, this.value, this.namespace); - return null; - }; - - return StaticAttribute; - })(); - - exports.StaticAttribute = StaticAttribute; - - var DynamicAttribute = (function () { - function DynamicAttribute(element, attributeManager, name, reference, namespace) { - this.element = element; - this.attributeManager = attributeManager; - this.name = name; - this.reference = reference; - this.namespace = namespace; - this.tag = reference.tag; - this.cache = null; + if (arguments.length > 0) { + initProperties = [arguments[0]]; } - DynamicAttribute.prototype.patch = function patch(env) { - var element = this.element; - var cache = this.cache; + this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); + var m = _emberMetal.meta(this); + var proto = m.proto; + m.proto = this; + if (initProperties) { + // capture locally so we can clear the closed over variable + var props = initProperties; + initProperties = null; - var value = cache.revalidate(); - if (_glimmerReference.isModified(value)) { - this.attributeManager.updateAttribute(env, element, value, this.namespace); - } - }; + var concatenatedProperties = this.concatenatedProperties; + var mergedProperties = this.mergedProperties; - DynamicAttribute.prototype.flush = function flush(env) { - var reference = this.reference; - var element = this.element; + for (var i = 0; i < props.length; i++) { + var properties = props[i]; + _emberMetal.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetal.Mixin)); - if (_glimmerReference.isConst(reference)) { - var value = reference.value(); - this.attributeManager.setAttribute(env, element, value, this.namespace); - return null; - } else { - var cache = this.cache = new _glimmerReference.ReferenceCache(reference); - var value = cache.peek(); - this.attributeManager.setAttribute(env, element, value, this.namespace); - return new PatchElementOpcode(this); + if (typeof properties !== 'object' && properties !== undefined) { + throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); } - }; - DynamicAttribute.prototype.toJSON = function toJSON() { - var element = this.element; - var namespace = this.namespace; - var name = this.name; - var cache = this.cache; - - var formattedElement = formatElement(element); - var lastValue = cache.peek(); - if (namespace) { - return { - element: formattedElement, - type: 'attribute', - namespace: namespace, - name: name, - lastValue: lastValue - }; + if (!properties) { + continue; } - return { - element: formattedElement, - type: 'attribute', - namespace: namespace, - name: name, - lastValue: lastValue - }; - }; - - return DynamicAttribute; - })(); - - exports.DynamicAttribute = DynamicAttribute; - function formatElement(element) { - return JSON.stringify('<' + element.tagName.toLowerCase() + ' />'); - } + var keyNames = Object.keys(properties); - var DynamicAttrNSOpcode = (function (_Opcode12) { - babelHelpers.inherits(DynamicAttrNSOpcode, _Opcode12); + for (var j = 0; j < keyNames.length; j++) { + var keyName = keyNames[j]; + var value = properties[keyName]; - function DynamicAttrNSOpcode(name, namespace, isTrusting) { - _Opcode12.call(this); - this.name = name; - this.namespace = namespace; - this.isTrusting = isTrusting; - this.type = "dynamic-attr"; - } + if (_emberMetal.detectBinding(keyName)) { + m.writeBindings(keyName, value); + } - DynamicAttrNSOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var namespace = this.namespace; - var isTrusting = this.isTrusting; + var possibleDesc = this[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - var reference = vm.frame.getOperand(); - vm.stack().setDynamicAttributeNS(namespace, name, reference, isTrusting); - }; + _emberMetal.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty)); + _emberMetal.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1)); + _emberMetal.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this))); - DynamicAttrNSOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; - var namespace = this.namespace; - - var details = _glimmerUtil.dict(); - details["name"] = JSON.stringify(name); - details["value"] = "$OPERAND"; - if (namespace) { - details["namespace"] = JSON.stringify(namespace); - } - return { guid: guid, type: type, details: details }; - }; + if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { + var baseValue = this[keyName]; - return DynamicAttrNSOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (baseValue) { + if ('function' === typeof baseValue.concat) { + value = baseValue.concat(value); + } else { + value = _emberUtils.makeArray(baseValue).concat(value); + } + } else { + value = _emberUtils.makeArray(value); + } + } - exports.DynamicAttrNSOpcode = DynamicAttrNSOpcode; + if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { + var originalValue = this[keyName]; - var DynamicAttrOpcode = (function (_Opcode13) { - babelHelpers.inherits(DynamicAttrOpcode, _Opcode13); + value = _emberUtils.assign({}, originalValue, value); + } - function DynamicAttrOpcode(name, isTrusting) { - _Opcode13.call(this); - this.name = name; - this.isTrusting = isTrusting; - this.type = "dynamic-attr"; + if (desc) { + desc.set(this, keyName, value); + } else { + if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { + this.setUnknownProperty(keyName, value); + } else { + if (true) { + _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter + } else { + this[keyName] = value; + } + } + } + } + } } - DynamicAttrOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var isTrusting = this.isTrusting; + finishPartial(this, m); - var reference = vm.frame.getOperand(); - vm.stack().setDynamicAttribute(name, reference, isTrusting); - }; + this.init.apply(this, arguments); - DynamicAttrOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; + this[POST_INIT](); - var details = _glimmerUtil.dict(); - details["name"] = JSON.stringify(name); - details["value"] = "$OPERAND"; - return { guid: guid, type: type, details: details }; - }; + m.proto = proto; + _emberMetal.finishChains(this); + _emberMetal.sendEvent(this, 'init'); + } + + Class.willReopen = function willReopen() { + if (wasApplied) { + Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); + } - return DynamicAttrOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + wasApplied = false; + }; - exports.DynamicAttrOpcode = DynamicAttrOpcode; + Class._initProperties = function _initProperties(args) { + initProperties = args; + }; - var PatchElementOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(PatchElementOpcode, _UpdatingOpcode2); + Class.proto = function proto() { + var superclass = Class.superclass; + if (superclass) { + superclass.proto(); + } - function PatchElementOpcode(operation) { - _UpdatingOpcode2.call(this); - this.type = "patch-element"; - this.tag = operation.tag; - this.operation = operation; + if (!wasApplied) { + wasApplied = true; + Class.PrototypeMixin.applyPartial(Class.prototype); } - PatchElementOpcode.prototype.evaluate = function evaluate(vm) { - this.operation.patch(vm.env); - }; + return this.prototype; + }; - PatchElementOpcode.prototype.toJSON = function toJSON() { - var _guid = this._guid; - var type = this.type; - var operation = this.operation; + return Class; + })(); - return { - guid: _guid, - type: type, - details: operation.toJSON() - }; - }; + Class.toString = _emberMetal.Mixin.prototype.toString; - return PatchElementOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + return Class; + } - exports.PatchElementOpcode = PatchElementOpcode; + /** + @class CoreObject + @namespace Ember + @public + */ + var CoreObject = makeCtor(); + CoreObject.toString = function () { + return 'Ember.CoreObject'; + }; + CoreObject.PrototypeMixin = _emberMetal.Mixin.create((_Mixin$create = { + reopen: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - var CommentOpcode = (function (_Opcode14) { - babelHelpers.inherits(CommentOpcode, _Opcode14); + applyMixin(this, args, true); + return this; + }, - function CommentOpcode(comment) { - _Opcode14.call(this); - this.comment = comment; - this.type = "comment"; + /** + An overridable method called when objects are instantiated. By default, + does nothing unless it is overridden during class definition. + Example: + ```javascript + const Person = Ember.Object.extend({ + init() { + alert(`Name is ${this.get('name')}`); } + }); + let steve = Person.create({ + name: "Steve" + }); + // alerts 'Name is Steve'. + ``` + NOTE: If you do override `init` for a framework class like `Ember.View`, + be sure to call `this._super(...arguments)` in your + `init` declaration! If you don't, Ember may not have an opportunity to + do important setup work, and you'll see strange behavior in your + application. + @method init + @public + */ + init: function () {} - CommentOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().appendComment(this.comment); - }; + }, _Mixin$create[POST_INIT] = function () {}, _Mixin$create.__defineNonEnumerable = function (property) { + Object.defineProperty(this, property.name, property.descriptor); + //this[property.name] = property.descriptor.value; + }, _Mixin$create.concatenatedProperties = null, _Mixin$create.mergedProperties = null, _Mixin$create.isDestroyed = _emberMetal.descriptor({ + get: function () { + return _emberMetal.meta(this).isSourceDestroyed(); + }, - CommentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.comment)] - }; - }; + set: function (value) { + // prevent setting while applying mixins + if (typeof value === 'object' && value !== null && value.isDescriptor) { + return; + } - return CommentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberMetal.assert(('You cannot set `' + this + '.isDestroyed` directly, please use ').destroy()(_templateObject), false); + } + }), _Mixin$create.isDestroying = _emberMetal.descriptor({ + get: function () { + return _emberMetal.meta(this).isSourceDestroying(); + }, - exports.CommentOpcode = CommentOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9kb20udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBd0JBLFVBQUE7OEJBQUEsVUFBQTs7QUFHRSxpQkFIRixVQUFBLENBR3NCLElBQVksRUFBQTtBQUM5Qiw4QkFBTyxDQUFDO0FBRFUsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFRO0FBRnpCLGdCQUFBLENBQUEsSUFBSSxHQUFHLE1BQU0sQ0FBQztTQUlwQjs7QUFMSCxrQkFBQSxXQU9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gfVxuXG4gIGV2YWx1YXRlKHZtOiBWTSkge1xuICAgIHZtLnN0YWNrKCkuYXBwZW5kQ29tbWVudCh0aGlzLmNvbW1lbnQpO1xuICB9XG5cbiAgdG9KU09OKCk6IE9wY29kZUpTT04ge1xuICAgIHJldHVybiB7XG4gICAgICBndWlkOiB0aGlzLl9ndWlkLFxuICAgICAgdHlwZTogdGhpcy50eXBlLFxuICAgICAgYXJnczogW0pTT04uc3RyaW5naWZ5KHRoaXMuY29tbWVudCldXG4gICAgfTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/lists', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-util', 'glimmer-reference'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerUtil, _glimmerReference) { - 'use strict'; + set: function (value) { + // prevent setting while applying mixins + if (typeof value === 'object' && value !== null && value.isDescriptor) { + return; + } - var IterablePresenceReference = (function () { - function IterablePresenceReference(artifacts) { - this.tag = artifacts.tag; - this.artifacts = artifacts; - } + _emberMetal.assert(('You cannot set `' + this + '.isDestroying` directly, please use ').destroy()(_templateObject), false); + } + }), _Mixin$create.destroy = function () { + var m = _emberMetal.meta(this); + if (m.isSourceDestroying()) { + return; + } - IterablePresenceReference.prototype.value = function value() { - return !this.artifacts.isEmpty(); - }; + m.setSourceDestroying(); - return IterablePresenceReference; - })(); + schedule('actions', this, this.willDestroy); + schedule('destroy', this, this._scheduledDestroy, m); - var PutIteratorOpcode = (function (_Opcode) { - babelHelpers.inherits(PutIteratorOpcode, _Opcode); + return this; + }, _Mixin$create.willDestroy = function () {}, _Mixin$create._scheduledDestroy = function (m) { + if (m.isSourceDestroyed()) { + return; + } + _emberMetal.destroy(this); + m.setSourceDestroyed(); + }, _Mixin$create.bind = function (to, from) { + if (!(from instanceof _emberMetal.Binding)) { + from = _emberMetal.Binding.from(from); + } + from.to(to).connect(this); + return from; + }, _Mixin$create.toString = function () { + var hasToStringExtension = typeof this.toStringExtension === 'function'; + var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; + var ret = '<' + (this[_emberUtils.NAME_KEY] || this.constructor.toString()) + ':' + _emberUtils.guidFor(this) + extension + '>'; - function PutIteratorOpcode() { - _Opcode.apply(this, arguments); - this.type = "put-iterator"; - } + return ret; + }, _Mixin$create)); - PutIteratorOpcode.prototype.evaluate = function evaluate(vm) { - var listRef = vm.frame.getOperand(); - var args = vm.frame.getArgs(); - var iterable = vm.env.iterableFor(listRef, args); - var iterator = new _glimmerReference.ReferenceIterator(iterable); - vm.frame.setIterator(iterator); - vm.frame.setCondition(new IterablePresenceReference(iterator.artifacts)); - }; + CoreObject.PrototypeMixin.ownerConstructor = CoreObject; - return PutIteratorOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + CoreObject.__super__ = null; - exports.PutIteratorOpcode = PutIteratorOpcode; + var ClassMixinProps = (_ClassMixinProps = { - var EnterListOpcode = (function (_Opcode2) { - babelHelpers.inherits(EnterListOpcode, _Opcode2); + ClassMixin: _emberMetal.REQUIRED, - function EnterListOpcode(start, end) { - _Opcode2.call(this); - this.type = "enter-list"; - this.slice = new _glimmerUtil.ListSlice(start, end); - } + PrototypeMixin: _emberMetal.REQUIRED, - EnterListOpcode.prototype.evaluate = function evaluate(vm) { - vm.enterList(this.slice); - }; + isClass: true, - EnterListOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var type = this.type; - var _guid = this._guid; + isMethod: false + }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { + var Class = makeCtor(); + var proto = undefined; + Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); + Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + Class.ClassMixin.ownerConstructor = Class; + Class.PrototypeMixin.ownerConstructor = Class; - return EnterListOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + reopen.apply(Class.PrototypeMixin, arguments); - exports.EnterListOpcode = EnterListOpcode; + Class.superclass = this; + Class.__super__ = this.prototype; - var ExitListOpcode = (function (_Opcode3) { - babelHelpers.inherits(ExitListOpcode, _Opcode3); + proto = Class.prototype = Object.create(this.prototype); + proto.constructor = Class; + _emberUtils.generateGuid(proto); + _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype - function ExitListOpcode() { - _Opcode3.apply(this, arguments); - this.type = "exit-list"; - } + Class.ClassMixin.apply(Class); + return Class; + }, _ClassMixinProps.create = function () { + var C = this; - ExitListOpcode.prototype.evaluate = function evaluate(vm) { - vm.exitList(); - }; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - return ExitListOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (args.length > 0) { + this._initProperties(args); + } + return new C(); + }, _ClassMixinProps.reopen = function () { + this.willReopen(); + reopen.apply(this.PrototypeMixin, arguments); + return this; + }, _ClassMixinProps.reopenClass = function () { + reopen.apply(this.ClassMixin, arguments); + applyMixin(this, arguments, false); + return this; + }, _ClassMixinProps.detect = function (obj) { + if ('function' !== typeof obj) { + return false; + } + while (obj) { + if (obj === this) { + return true; + } + obj = obj.superclass; + } + return false; + }, _ClassMixinProps.detectInstance = function (obj) { + return obj instanceof this; + }, _ClassMixinProps.metaForProperty = function (key) { + var proto = this.proto(); + var possibleDesc = proto[key]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - exports.ExitListOpcode = ExitListOpcode; + _emberMetal.assert('metaForProperty() could not find a computed property with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); + return desc._meta || {}; + }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { + hasCachedComputedProperties = true; + var proto = this.proto(); + var property = undefined; + var properties = []; - var EnterWithKeyOpcode = (function (_Opcode4) { - babelHelpers.inherits(EnterWithKeyOpcode, _Opcode4); + for (var _name in proto) { + property = proto[_name]; - function EnterWithKeyOpcode(start, end) { - _Opcode4.call(this); - this.type = "enter-with-key"; - this.slice = new _glimmerUtil.ListSlice(start, end); - } + if (property && property.isDescriptor) { + properties.push({ + name: _name, + meta: property._meta + }); + } + } + return properties; + }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { + var property = undefined; + var empty = {}; - EnterWithKeyOpcode.prototype.evaluate = function evaluate(vm) { - vm.enterWithKey(vm.frame.getKey(), this.slice); - }; + var properties = _emberMetal.get(this, '_computedProperties'); - EnterWithKeyOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var _guid = this._guid; - var type = this.type; + for (var i = 0; i < properties.length; i++) { + property = properties[i]; + callback.call(binding || this, property.name, property.meta || empty); + } + }, _ClassMixinProps); - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + function injectedPropertyAssertion() { + _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this)); + } - return EnterWithKeyOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberMetal.runInDebug(function () { + /** + Provides lookup-time type validation for injected properties. + @private + @method _onLookup + */ + ClassMixinProps._onLookup = injectedPropertyAssertion; + }); - exports.EnterWithKeyOpcode = EnterWithKeyOpcode; + /** + Returns a hash of property names and container names that injected + properties will lookup on the container lazily. + + @method _lazyInjections + @return {Object} Hash of all lazy injected property keys to container names + @private + */ + ClassMixinProps._lazyInjections = function () { + var injections = {}; + var proto = this.proto(); + var key = undefined; + var desc = undefined; - var TRUE_REF = new _glimmerReference.ConstReference(true); - var FALSE_REF = new _glimmerReference.ConstReference(false); + for (key in proto) { + desc = proto[key]; + if (desc instanceof _emberMetal.InjectedProperty) { + injections[key] = desc.type + ':' + (desc.name || key); + } + } - var NextIterOpcode = (function (_Opcode5) { - babelHelpers.inherits(NextIterOpcode, _Opcode5); + return injections; + }; - function NextIterOpcode(end) { - _Opcode5.call(this); - this.type = "next-iter"; - this.end = end; - } + var ClassMixin = _emberMetal.Mixin.create(ClassMixinProps); - NextIterOpcode.prototype.evaluate = function evaluate(vm) { - var item = vm.frame.getIterator().next(); - if (item) { - vm.frame.setCondition(TRUE_REF); - vm.frame.setKey(item.key); - vm.frame.setOperand(item.value); - vm.frame.setArgs(_glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs.positional([item.value, item.memo])); - } else { - vm.frame.setCondition(FALSE_REF); - vm.goto(this.end); - } - }; + ClassMixin.ownerConstructor = CoreObject; - return NextIterOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + CoreObject.ClassMixin = ClassMixin; - exports.NextIterOpcode = NextIterOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9saXN0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFPQSx5QkFBQTtBQUlFLGlCQUpGLHlCQUFBLENBSWMsU0FBNkIsRUFBQTtBQUN2QyxnQkFBSSxDQUFDLEdBQUcsR0FBRyxTQUFTLENBQUMsR0FBRyxDQUFDO0FBQ3pCLGdCQUFJLENBQUMsU0FBUyxHQUFHLFNBQVMsQ0FBQztTQUM1Qjs7QUFQSCxpQ0FBQSxXQVNFLEtBQUssR0FBQSxpQkFBQTtBQUNILG1CQUFPLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztTQUNsQzs7ZUFYSCx5QkFBQTs7O1FBY0EsaUJBQUE7OEJBQUEsaUJBQUE7O0FBQUEsaUJBQUEsaUJBQUEsR0FBQTtBQUF1QyxnQ0FBQSxTQUFBLENB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', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm'], function (exports, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm) { - 'use strict'; + ClassMixin.apply(CoreObject); - var PutDynamicPartialDefinitionOpcode = (function (_Opcode) { - babelHelpers.inherits(PutDynamicPartialDefinitionOpcode, _Opcode); + CoreObject.reopen({ + didDefineProperty: function (proto, key, value) { + if (hasCachedComputedProperties === false) { + return; + } + if (value instanceof _emberMetal.ComputedProperty) { + var cache = _emberMetal.meta(this.constructor).readableCache(); - function PutDynamicPartialDefinitionOpcode(symbolTable) { - _Opcode.call(this); - this.symbolTable = symbolTable; - this.type = "put-dynamic-partial-definition"; + if (cache && cache._computedProperties !== undefined) { + cache._computedProperties = undefined; } + } + } + }); - PutDynamicPartialDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - var env = vm.env; - var symbolTable = this.symbolTable; + exports.default = CoreObject; +}); +// Private, and only for didInitAttrs willRecieveAttrs - function lookupPartial(name) { - var normalized = String(name); - if (!env.hasPartial(normalized, symbolTable)) { - throw new Error('Could not find a partial named "' + normalized + '"'); - } - return env.lookupPartial(normalized, symbolTable); - } - var reference = _glimmerReference.map(vm.frame.getOperand(), lookupPartial); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var definition = cache ? cache.peek() : reference.value(); - vm.frame.setImmediate(definition); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; +/** + Defines the properties that will be concatenated from the superclass + (instead of overridden). + By default, when you extend an Ember class a property defined in + the subclass overrides a property with the same name that is defined + in the superclass. However, there are some cases where it is preferable + to build up a property's value by combining the superclass' property + value with the subclass' value. An example of this in use within Ember + is the `classNames` property of `Ember.View`. + Here is some sample code showing the difference between a concatenated + property and a normal one: + ```javascript + const Bar = Ember.Object.extend({ + // Configure which properties to concatenate + concatenatedProperties: ['concatenatedProperty'], + someNonConcatenatedProperty: ['bar'], + concatenatedProperty: ['bar'] + }); + const FooBar = Bar.extend({ + someNonConcatenatedProperty: ['foo'], + concatenatedProperty: ['foo'] + }); + let fooBar = FooBar.create(); + fooBar.get('someNonConcatenatedProperty'); // ['foo'] + fooBar.get('concatenatedProperty'); // ['bar', 'foo'] + ``` + This behavior extends to object creation as well. Continuing the + above example: + ```javascript + let fooBar = FooBar.create({ + someNonConcatenatedProperty: ['baz'], + concatenatedProperty: ['baz'] + }) + fooBar.get('someNonConcatenatedProperty'); // ['baz'] + fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] + ``` + Adding a single property that is not an array will just add it in the array: + ```javascript + let fooBar = FooBar.create({ + concatenatedProperty: 'baz' + }) + view.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] + ``` + Using the `concatenatedProperties` property, we can tell Ember to mix the + content of the properties. + In `Ember.Component` the `classNames`, `classNameBindings` and + `attributeBindings` properties are concatenated. + This feature is available for you to use throughout the Ember object model, + although typical app developers are likely to use it infrequently. Since + it changes expectations about behavior of properties, you should properly + document its usage in each individual concatenated property (to not + mislead your users to think they can override the property in a subclass). + @property concatenatedProperties + @type Array + @default null + @public +*/ - PutDynamicPartialDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; +/** + Defines the properties that will be merged from the superclass + (instead of overridden). + By default, when you extend an Ember class a property defined in + the subclass overrides a property with the same name that is defined + in the superclass. However, there are some cases where it is preferable + to build up a property's value by merging the superclass property value + with the subclass property's value. An example of this in use within Ember + is the `queryParams` property of routes. + Here is some sample code showing the difference between a merged + property and a normal one: + ```javascript + const Bar = Ember.Object.extend({ + // Configure which properties are to be merged + mergedProperties: ['mergedProperty'], + someNonMergedProperty: { + nonMerged: 'superclass value of nonMerged' + }, + mergedProperty: { + page: {replace: false}, + limit: {replace: true} + } + }); + const FooBar = Bar.extend({ + someNonMergedProperty: { + completelyNonMerged: 'subclass value of nonMerged' + }, + mergedProperty: { + limit: {replace: false} + } + }); + let fooBar = FooBar.create(); + fooBar.get('someNonMergedProperty'); + // => { completelyNonMerged: 'subclass value of nonMerged' } + // + // Note the entire object, including the nonMerged property of + // the superclass object, has been replaced + fooBar.get('mergedProperty'); + // => { + // page: {replace: false}, + // limit: {replace: false} + // } + // + // Note the page remains from the superclass, and the + // `limit` property's value of `false` has been merged from + // the subclass. + ``` + This behavior is not available during object `create` calls. It is only + available at `extend` time. + In `Ember.Route` the `queryParams` property is merged. + This feature is available for you to use throughout the Ember object model, + although typical app developers are likely to use it infrequently. Since + it changes expectations about behavior of properties, you should properly + document its usage in each individual merged property (to not + mislead your users to think they can override the property in a subclass). + @property mergedProperties + @type Array + @default null + @public +*/ - return PutDynamicPartialDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); +/** + Destroyed object property flag. + if this property is `true` the observers and bindings were already + removed by the effect of calling the `destroy()` method. + @property isDestroyed + @default false + @public +*/ - exports.PutDynamicPartialDefinitionOpcode = PutDynamicPartialDefinitionOpcode; +/** + Destruction scheduled flag. The `destroy()` method has been called. + The object stays intact until the end of the run loop at which point + the `isDestroyed` flag is set. + @property isDestroying + @default false + @public +*/ - var PutPartialDefinitionOpcode = (function (_Opcode2) { - babelHelpers.inherits(PutPartialDefinitionOpcode, _Opcode2); +/** + Destroys an object by setting the `isDestroyed` flag and removing its + metadata, which effectively destroys observers and bindings. + If you try to set a property on a destroyed object, an exception will be + raised. + Note that destruction is scheduled for the end of the run loop and does not + happen immediately. It will set an isDestroying flag immediately. + @method destroy + @return {Ember.Object} receiver + @public +*/ - function PutPartialDefinitionOpcode(definition) { - _Opcode2.call(this); - this.definition = definition; - this.type = "put-partial-definition"; - } +/** + Override to implement teardown. + @method willDestroy + @public +*/ - PutPartialDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setImmediate(this.definition); - }; +/** + Invoked by the run loop to actually destroy the object. This is + scheduled for execution by the `destroy` method. + @private + @method _scheduledDestroy +*/ - PutPartialDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.definition.name)] - }; - }; +/** + Returns a string representation which attempts to provide more information + than Javascript's `toString` typically does, in a generic way for all Ember + objects. + ```javascript + const Person = Ember.Object.extend() + person = Person.create() + person.toString() //=> "" + ``` + If the object's class is not defined on an Ember namespace, it will + indicate it is a subclass of the registered superclass: + ```javascript + const Student = Person.extend() + let student = Student.create() + student.toString() //=> "<(subclass of Person):ember1025>" + ``` + If the method `toStringExtension` is defined, its return value will be + included in the output. + ```javascript + const Teacher = Person.extend({ + toStringExtension() { + return this.get('fullName'); + } + }); + teacher = Teacher.create() + teacher.toString(); //=> "" + ``` + @method toString + @return {String} string representation + @public +*/ - return PutPartialDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); +/** + Creates a new subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(thing); + } + }); + ``` + This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. + You can also create a subclass from any existing class by calling its `extend()` method. + For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: + ```javascript + const PersonComponent = Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isAdministrator'] + }); + ``` + When defining a subclass, you can override methods but still access the + implementation of your parent class by calling the special `_super()` method: + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + let name = this.get('name'); + alert(`${name} says: ${thing}`); + } + }); + const Soldier = Person.extend({ + say(thing) { + this._super(`${thing}, sir!`); + }, + march(numberOfHours) { + alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + } + }); + let yehuda = Soldier.create({ + name: "Yehuda Katz" + }); + yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" + ``` + The `create()` on line #17 creates an *instance* of the `Soldier` class. + The `extend()` on line #8 creates a *subclass* of `Person`. Any instance + of the `Person` class will *not* have the `march()` method. + You can also pass `Mixin` classes to add additional properties to the subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(`${this.get('name')} says: ${thing}`); + } + }); + const SingingMixin = Mixin.create({ + sing(thing){ + alert(`${this.get('name')} sings: la la la ${thing}`); + } + }); + const BroadwayStar = Person.extend(SingingMixin, { + dance() { + alert(`${this.get('name')} dances: tap tap tap tap `); + } + }); + ``` + The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. + @method extend + @static + @param {Mixin} [mixins]* One or more Mixin classes + @param {Object} [arguments]* Object containing values to use within the new class + @public +*/ - exports.PutPartialDefinitionOpcode = PutPartialDefinitionOpcode; +/** + Creates an instance of a class. Accepts either no arguments, or an object + containing values to initialize the newly instantiated object with. + ```javascript + const Person = Ember.Object.extend({ + helloWorld() { + alert(`Hi, my name is ${this.get('name')}`); + } + }); + let tom = Person.create({ + name: 'Tom Dale' + }); + tom.helloWorld(); // alerts "Hi, my name is Tom Dale". + ``` + `create` will call the `init` function if defined during + `Ember.AnyObject.extend` + If no arguments are passed to `create`, it will not set values to the new + instance during initialization: + ```javascript + let noName = Person.create(); + noName.helloWorld(); // alerts undefined + ``` + NOTE: For performance reasons, you cannot declare methods or computed + properties during `create`. You should instead declare methods and computed + properties when using `extend`. + @method create + @static + @param [arguments]* + @public +*/ - var EvaluatePartialOpcode = (function (_Opcode3) { - babelHelpers.inherits(EvaluatePartialOpcode, _Opcode3); +/** + Augments a constructor's prototype with additional + properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + o = MyObject.create(); + o.get('name'); // 'an object' + MyObject.reopen({ + say(msg){ + console.log(msg); + } + }) + o2 = MyObject.create(); + o2.say("hello"); // logs "hello" + o.say("goodbye"); // logs "goodbye" + ``` + To add functions and properties to the constructor itself, + see `reopenClass` + @method reopen + @public +*/ - function EvaluatePartialOpcode(symbolTable) { - _Opcode3.call(this); - this.symbolTable = symbolTable; - this.type = "evaluate-partial"; - this.cache = _glimmerUtil.dict(); - } +/** + Augments a constructor's own properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + MyObject.reopenClass({ + canBuild: false + }); + MyObject.canBuild; // false + o = MyObject.create(); + ``` + In other words, this creates static properties and functions for the class. + These are only available on the class and not on any instance of that class. + ```javascript + const Person = Ember.Object.extend({ + name: "", + sayHello() { + alert("Hello. My name is " + this.get('name')); + } + }); + Person.reopenClass({ + species: "Homo sapiens", + createPerson(newPersonsName){ + return Person.create({ + name:newPersonsName + }); + } + }); + let tom = Person.create({ + name: "Tom Dale" + }); + let yehuda = Person.createPerson("Yehuda Katz"); + tom.sayHello(); // "Hello. My name is Tom Dale" + yehuda.sayHello(); // "Hello. My name is Yehuda Katz" + alert(Person.species); // "Homo sapiens" + ``` + Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` + variables. They are only valid on `Person`. + To add functions and properties to instances of + a constructor by extending the constructor's prototype + see `reopen` + @method reopenClass + @public +*/ - EvaluatePartialOpcode.prototype.evaluate = function evaluate(vm) { - var _vm$frame$getImmediate = vm.frame.getImmediate(); +/** + 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: + ```javascript + person: Ember.computed(function() { + let personId = this.get('personId'); + return Person.create({ id: personId }); + }).meta({ type: Person }) + ``` + Once you've done this, you can retrieve the values saved to the computed + property from your class like this: + ```javascript + MyClass.metaForProperty('person'); + ``` + This will return the original hash that was passed to `meta()`. + @static + @method metaForProperty + @param key {String} property name + @private +*/ - var template = _vm$frame$getImmediate.template; +/** + Iterate over each computed property for the class, passing its name + and any associated metadata (see `metaForProperty`) to the callback. + @static + @method eachComputedProperty + @param {Function} callback + @param {Object} binding + @private +*/ +enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { + 'use strict'; - var block = this.cache[template.id]; - if (!block) { - block = template.asPartial(this.symbolTable); - } - vm.invokePartial(block); - }; + exports.default = EachProxy; - EvaluatePartialOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + /** + This is the object instance returned when you get the `@each` property on an + array. It uses the unknownProperty handler to automatically create + EachArray instances for property names. + @class EachProxy + @private + */ - return EvaluatePartialOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function EachProxy(content) { + this._content = content; + this._keys = undefined; + this.__ember_meta__ = null; + } - exports.EvaluatePartialOpcode = EvaluatePartialOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9wYXJ0aWFsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVNBLGlDQUFBOzhCQUFBLGlDQUFBOztBQUdFLGlCQUhGLGlDQUFBLENBR3NCLFdBQXdCLEVBQUE7QUFDMUMsOEJBQU8sQ0FBQztBQURVLGdCQUFBLENBQUEsV0FBVyxHQUFYLFdBQVcsQ0FBYTtBQUZyQyxnQkFBQSxDQUFBLElBQUksR0FBRyxnQ0FBZ0MsQ0FBQztTQUk5Qzs7QUFMSCx5Q0FBQSxXQU9FLFFBQVEsR0FBQSxrQkFBQyxFQUFNLEVBQUE7QUFDYixnQkFBSSxHQUFHLEdBQUcsRUFBRSxDQUFDLEdBQUcsQ0FBQztnQkFDWCxXQUFXLEdBQUssSUFBSSxDQUFwQixXQUFXOztBQUVqQixxQkFBQSxhQUFBLENBQXVCLElBQVksRUFBQTtBQUNqQyxvQkFBSSxVQUFVLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBRTlCLG9CQUFJLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxVQUFVLEVBQUUsV0FBVyxDQUFDLEVBQUU7QUFDNUMsMEJBQU0sSUFBSSxLQUFLLHNDQUFvQyxVQUFVLE9BQUksQ0FBQztpQkFDbkU7QUFFR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mcmFtZS5nZXRJbW1lZGlhdGU8UGFydGlhbERlZmluaXRpb248T3BhcXVlPj4oKTtcblxuICAgIGxldCBibG9jayA9IHRoaXMuY2FjaGVbdGVtcGxhdGUuaWRdO1xuXG4gICAgaWYgKCFibG9jaykge1xuICAgICAgYmxvY2sgPSB0ZW1wbGF0ZS5hc1BhcnRpYWwodGhpcy5zeW1ib2xUYWJsZSk7XG4gICAgfVxuXG4gICAgdm0uaW52b2tlUGFydGlhbChibG9jayk7XG4gIH1cblxuICB0b0pTT04oKTogT3Bjb2RlSlNPTiB7XG4gICAgcmV0dXJuIHtcbiAgICAgIGd1aWQ6IHRoaXMuX2d1aWQsXG4gICAgICB0eXBlOiB0aGlzLnR5cGUsXG4gICAgICBhcmdzOiBbXCIkT1BFUkFORFwiXVxuICAgIH07XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/opcodes/vm', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/references', 'glimmer-reference', 'glimmer-util'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibReferences, _glimmerReference, _glimmerUtil) { - 'use strict'; + EachProxy.prototype = { + __defineNonEnumerable: function (property) { + this[property.name] = property.descriptor.value; + }, - var PushChildScopeOpcode = (function (_Opcode) { - babelHelpers.inherits(PushChildScopeOpcode, _Opcode); + // .......................................................... + // ARRAY CHANGES + // Invokes whenever the content array itself changes. - function PushChildScopeOpcode() { - _Opcode.apply(this, arguments); - this.type = "push-child-scope"; + arrayWillChange: function (content, idx, removedCnt, addedCnt) { + var keys = this._keys; + var lim = removedCnt > 0 ? idx + removedCnt : -1; + for (var key in keys) { + if (lim > 0) { + removeObserverForContentKey(content, key, this, idx, lim); } + _emberMetal.propertyWillChange(this, key); + } + }, - PushChildScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.pushChildScope(); - }; - - return PushChildScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PushChildScopeOpcode = PushChildScopeOpcode; - - var PopScopeOpcode = (function (_Opcode2) { - babelHelpers.inherits(PopScopeOpcode, _Opcode2); - - function PopScopeOpcode() { - _Opcode2.apply(this, arguments); - this.type = "pop-scope"; + arrayDidChange: function (content, idx, removedCnt, addedCnt) { + var keys = this._keys; + var lim = addedCnt > 0 ? idx + addedCnt : -1; + for (var key in keys) { + if (lim > 0) { + addObserverForContentKey(content, key, this, idx, lim); } + _emberMetal.propertyDidChange(this, key); + } + }, - PopScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - }; + // .......................................................... + // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS + // Start monitoring keys based on who is listening... - return PopScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + willWatchProperty: function (property) { + this.beginObservingContentKey(property); + }, - exports.PopScopeOpcode = PopScopeOpcode; + didUnwatchProperty: function (property) { + this.stopObservingContentKey(property); + }, - var PushDynamicScopeOpcode = (function (_Opcode3) { - babelHelpers.inherits(PushDynamicScopeOpcode, _Opcode3); + // .......................................................... + // CONTENT KEY OBSERVING + // Actual watch keys on the source content. - function PushDynamicScopeOpcode() { - _Opcode3.apply(this, arguments); - this.type = "push-dynamic-scope"; - } + beginObservingContentKey: function (keyName) { + var keys = this._keys; + if (!keys) { + keys = this._keys = new _emberUtils.EmptyObject(); + } - PushDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.pushDynamicScope(); - }; + if (!keys[keyName]) { + keys[keyName] = 1; + var content = this._content; + var len = _emberMetal.get(content, 'length'); - return PushDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + addObserverForContentKey(content, keyName, this, 0, len); + } else { + keys[keyName]++; + } + }, - exports.PushDynamicScopeOpcode = PushDynamicScopeOpcode; + stopObservingContentKey: function (keyName) { + var keys = this._keys; + if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) { + var content = this._content; + var len = _emberMetal.get(content, 'length'); - var PopDynamicScopeOpcode = (function (_Opcode4) { - babelHelpers.inherits(PopDynamicScopeOpcode, _Opcode4); + removeObserverForContentKey(content, keyName, this, 0, len); + } + }, - function PopDynamicScopeOpcode() { - _Opcode4.apply(this, arguments); - this.type = "pop-dynamic-scope"; - } + contentKeyWillChange: function (obj, keyName) { + _emberMetal.propertyWillChange(this, keyName); + }, - PopDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.popDynamicScope(); - }; + contentKeyDidChange: function (obj, keyName) { + _emberMetal.propertyDidChange(this, keyName); + } + }; - return PopDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function addObserverForContentKey(content, keyName, proxy, idx, loc) { + while (--loc >= idx) { + var item = _emberRuntimeMixinsArray.objectAt(content, loc); + if (item) { + _emberMetal.assert('When using @each to observe the array ' + content + ', the array must return an object', typeof item === 'object'); + _emberMetal._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); + _emberMetal.addObserver(item, keyName, proxy, 'contentKeyDidChange'); + } + } + } - exports.PopDynamicScopeOpcode = PopDynamicScopeOpcode; + function removeObserverForContentKey(content, keyName, proxy, idx, loc) { + while (--loc >= idx) { + var item = _emberRuntimeMixinsArray.objectAt(content, loc); + if (item) { + _emberMetal._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); + _emberMetal.removeObserver(item, keyName, proxy, 'contentKeyDidChange'); + } + } + } +}); +enifed('ember-runtime/system/lazy_load', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + /*globals CustomEvent */ - var PutNullOpcode = (function (_Opcode5) { - babelHelpers.inherits(PutNullOpcode, _Opcode5); + 'use strict'; - function PutNullOpcode() { - _Opcode5.apply(this, arguments); - this.type = "put-null"; - } + exports.onLoad = onLoad; + exports.runLoadHooks = runLoadHooks; - PutNullOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setOperand(_glimmerRuntimeLibReferences.NULL_REFERENCE); - }; + /** + @module ember + @submodule ember-runtime + */ - return PutNullOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var loadHooks = _emberEnvironment.ENV.EMBER_LOAD_HOOKS || {}; + var loaded = {}; + var _loaded = loaded; - exports.PutNullOpcode = PutNullOpcode; + exports._loaded = _loaded; + /** + Detects when a specific package of Ember (e.g. 'Ember.Application') + has fully loaded and is available for extension. + + The provided `callback` will be called with the `name` passed + resolved from a string into the object: + + ``` javascript + Ember.onLoad('Ember.Application' function(hbars) { + hbars.registerHelper(...); + }); + ``` + + @method onLoad + @for Ember + @param name {String} name of hook + @param callback {Function} callback to be called + @private + */ - var PutValueOpcode = (function (_Opcode6) { - babelHelpers.inherits(PutValueOpcode, _Opcode6); + function onLoad(name, callback) { + var object = loaded[name]; - function PutValueOpcode(expression) { - _Opcode6.call(this); - this.expression = expression; - this.type = "put-value"; - } + loadHooks[name] = loadHooks[name] || []; + loadHooks[name].push(callback); - PutValueOpcode.prototype.evaluate = function evaluate(vm) { - vm.evaluateOperand(this.expression); - }; + if (object) { + callback(object); + } + } - PutValueOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [this.expression.toJSON()] - }; - }; + /** + Called when an Ember.js package (e.g Ember.Application) has finished + loading. Triggers any callbacks registered for this event. + + @method runLoadHooks + @for Ember + @param name {String} name of hook + @param object {Object} object to pass to callbacks + @private + */ - return PutValueOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function runLoadHooks(name, object) { + loaded[name] = object; + var window = _emberEnvironment.environment.window; - exports.PutValueOpcode = PutValueOpcode; + if (window && typeof CustomEvent === 'function') { + var _event = new CustomEvent(name, { detail: object, name: name }); + window.dispatchEvent(_event); + } - var PutArgsOpcode = (function (_Opcode7) { - babelHelpers.inherits(PutArgsOpcode, _Opcode7); + if (loadHooks[name]) { + loadHooks[name].forEach(function (callback) { + return callback(object); + }); + } + } +}); +enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-runtime/system/object'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberRuntimeSystemObject) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - function PutArgsOpcode(args) { - _Opcode7.call(this); - this.args = args; - this.type = "put-args"; - } + exports.isSearchDisabled = isSearchDisabled; + exports.setSearchDisabled = setSearchDisabled; - PutArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.evaluateArgs(this.args); - }; + var searchDisabled = false; - PutArgsOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - details: { - "positional": this.args.positional.toJSON(), - "named": this.args.named.toJSON() - } - }; - }; + function isSearchDisabled() { + return searchDisabled; + } - return PutArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function setSearchDisabled(flag) { + searchDisabled = !!flag; + } - exports.PutArgsOpcode = PutArgsOpcode; + /** + A Namespace is an object usually used to contain other objects or methods + such as an application or framework. Create a namespace anytime you want + to define one of these new containers. + + # Example Usage + + ```javascript + MyFramework = Ember.Namespace.create({ + VERSION: '1.0.0' + }); + ``` + + @class Namespace + @namespace Ember + @extends Ember.Object + @public + */ + var Namespace = _emberRuntimeSystemObject.default.extend({ + isNamespace: true, - var BindPositionalArgsOpcode = (function (_Opcode8) { - babelHelpers.inherits(BindPositionalArgsOpcode, _Opcode8); + init: function () { + Namespace.NAMESPACES.push(this); + Namespace.PROCESSED = false; + }, - function BindPositionalArgsOpcode(names, symbols) { - _Opcode8.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-positional-args"; - } + toString: function () { + var name = _emberMetal.get(this, 'name') || _emberMetal.get(this, 'modulePrefix'); + if (name) { + return name; + } - BindPositionalArgsOpcode.create = function create(block) { - var names = block.locals; - var symbols = names.map(function (name) { - return block.symbolTable.getLocal(name); - }); - return new this(names, symbols); - }; + findNamespaces(); + return this[_emberUtils.NAME_KEY]; + }, - BindPositionalArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindPositionalArgs(this.symbols); - }; + nameClasses: function () { + processNamespace([this.toString()], this, {}); + }, - BindPositionalArgsOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ['[' + this.names.map(function (name) { - return JSON.stringify(name); - }).join(", ") + ']'] - }; - }; + destroy: function () { + var namespaces = Namespace.NAMESPACES; + var toString = this.toString(); - return BindPositionalArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (toString) { + _emberEnvironment.context.lookup[toString] = undefined; + delete Namespace.NAMESPACES_BY_ID[toString]; + } + namespaces.splice(namespaces.indexOf(this), 1); + this._super.apply(this, arguments); + } + }); - exports.BindPositionalArgsOpcode = BindPositionalArgsOpcode; + Namespace.reopenClass({ + NAMESPACES: [_emberMetal.default], + NAMESPACES_BY_ID: { + Ember: _emberMetal.default + }, + PROCESSED: false, + processAll: processAllNamespaces, + byName: function (name) { + if (!searchDisabled) { + processAllNamespaces(); + } - var BindNamedArgsOpcode = (function (_Opcode9) { - babelHelpers.inherits(BindNamedArgsOpcode, _Opcode9); + return NAMESPACES_BY_ID[name]; + } + }); - function BindNamedArgsOpcode(names, symbols) { - _Opcode9.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-named-args"; - } + var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; - BindNamedArgsOpcode.create = function create(layout) { - var names = layout.named; - var symbols = names.map(function (name) { - return layout.symbolTable.getNamed(name); - }); - return new this(names, symbols); - }; + var hasOwnProp = ({}).hasOwnProperty; - BindNamedArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindNamedArgs(this.names, this.symbols); - }; + function processNamespace(paths, root, seen) { + var idx = paths.length; - BindNamedArgsOpcode.prototype.toJSON = function toJSON() { - var names = this.names; - var symbols = this.symbols; + NAMESPACES_BY_ID[paths.join('.')] = root; - var args = names.map(function (name, i) { - return '$' + symbols[i] + ': $ARGS[' + name + ']'; - }); - return { - guid: this._guid, - type: this.type, - args: args - }; - }; + // Loop over all of the keys in the namespace, looking for classes + for (var key in root) { + if (!hasOwnProp.call(root, key)) { + continue; + } + var obj = root[key]; - return BindNamedArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + // If we are processing the `Ember` namespace, for example, the + // `paths` will start with `["Ember"]`. Every iteration through + // the loop will update the **second** element of this list with + // the key, so processing `Ember.View` will make the Array + // `['Ember', 'View']`. + paths[idx] = key; - exports.BindNamedArgsOpcode = BindNamedArgsOpcode; + // If we have found an unprocessed class + if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { + // Replace the class' `toString` with the dot-separated path + // and set its `NAME_KEY` + obj[_emberUtils.NAME_KEY] = paths.join('.'); - var BindBlocksOpcode = (function (_Opcode10) { - babelHelpers.inherits(BindBlocksOpcode, _Opcode10); + // Support nested namespaces + } else if (obj && obj.isNamespace) { + // Skip aliased namespaces + if (seen[_emberUtils.guidFor(obj)]) { + continue; + } + seen[_emberUtils.guidFor(obj)] = true; - function BindBlocksOpcode(names, symbols) { - _Opcode10.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-blocks"; + // Process the child namespace + processNamespace(paths, obj, seen); } + } - BindBlocksOpcode.create = function create(layout) { - var names = layout.yields; - var symbols = names.map(function (name) { - return layout.symbolTable.getYield(name); - }); - return new this(names, symbols); - }; - - BindBlocksOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindBlocks(this.names, this.symbols); - }; - - BindBlocksOpcode.prototype.toJSON = function toJSON() { - var names = this.names; - var symbols = this.symbols; - - var args = names.map(function (name, i) { - return '$' + symbols[i] + ': $BLOCKS[' + name + ']'; - }); - return { - guid: this._guid, - type: this.type, - args: args - }; - }; - - return BindBlocksOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + paths.length = idx; // cut out last item + } - exports.BindBlocksOpcode = BindBlocksOpcode; + function isUppercase(code) { + return code >= 65 && // A + code <= 90; // Z + } - var BindPartialArgsOpcode = (function (_Opcode11) { - babelHelpers.inherits(BindPartialArgsOpcode, _Opcode11); + function tryIsNamespace(lookup, prop) { + try { + var obj = lookup[prop]; + return obj && obj.isNamespace && obj; + } catch (e) { + // continue + } + } - function BindPartialArgsOpcode(symbol) { - _Opcode11.call(this); - this.symbol = symbol; - this.type = "bind-partial-args"; - } + function findNamespaces() { + if (Namespace.PROCESSED) { + return; + } + var lookup = _emberEnvironment.context.lookup; + var keys = Object.keys(lookup); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + // Only process entities that start with uppercase A-Z + if (!isUppercase(key.charCodeAt(0))) { + continue; + } + var obj = tryIsNamespace(lookup, key); + if (obj) { + obj[_emberUtils.NAME_KEY] = key; + } + } + } - BindPartialArgsOpcode.create = function create(layout) { - return new this(layout.symbolTable.getPartialArgs()); - }; + function superClassString(mixin) { + var superclass = mixin.superclass; + if (superclass) { + if (superclass[_emberUtils.NAME_KEY]) { + return superclass[_emberUtils.NAME_KEY]; + } + return superClassString(superclass); + } + } - BindPartialArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindPartialArgs(this.symbol); - }; + function calculateToString(target) { + var str = undefined; - return BindPartialArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (!searchDisabled) { + processAllNamespaces(); + // can also be set by processAllNamespaces + str = target[_emberUtils.NAME_KEY]; + if (str) { + return str; + } else { + str = superClassString(target); + str = str ? '(subclass of ' + str + ')' : str; + } + } + if (str) { + return str; + } else { + return '(unknown mixin)'; + } + } - exports.BindPartialArgsOpcode = BindPartialArgsOpcode; + function classToString() { + var name = this[_emberUtils.NAME_KEY]; + if (name) { + return name; + } - var BindCallerScopeOpcode = (function (_Opcode12) { - babelHelpers.inherits(BindCallerScopeOpcode, _Opcode12); + return this[_emberUtils.NAME_KEY] = calculateToString(this); + } - function BindCallerScopeOpcode() { - _Opcode12.apply(this, arguments); - this.type = "bind-caller-scope"; - } + function processAllNamespaces() { + var unprocessedNamespaces = !Namespace.PROCESSED; + var unprocessedMixins = _emberMetal.hasUnprocessedMixins(); - BindCallerScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindCallerScope(); - }; + if (unprocessedNamespaces) { + findNamespaces(); + Namespace.PROCESSED = true; + } - return BindCallerScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (unprocessedNamespaces || unprocessedMixins) { + var namespaces = Namespace.NAMESPACES; + var namespace = undefined; - exports.BindCallerScopeOpcode = BindCallerScopeOpcode; + for (var i = 0; i < namespaces.length; i++) { + namespace = namespaces[i]; + processNamespace([namespace.toString()], namespace, {}); + } - var BindDynamicScopeOpcode = (function (_Opcode13) { - babelHelpers.inherits(BindDynamicScopeOpcode, _Opcode13); + _emberMetal.clearUnprocessedMixins(); + } + } - function BindDynamicScopeOpcode(names) { - _Opcode13.call(this); - this.names = names; - this.type = "bind-dynamic-scope"; - } + _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. - BindDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindDynamicScope(this.names); - }; + exports.default = Namespace; +}); +// Preloaded into namespaces +enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - return BindDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var _NativeArray; - exports.BindDynamicScopeOpcode = BindDynamicScopeOpcode; + // Add Ember.Array to Array.prototype. Remove methods with native + // implementations and supply some more optimized versions of generic methods + // because they are so common. - var EnterOpcode = (function (_Opcode14) { - babelHelpers.inherits(EnterOpcode, _Opcode14); + /** + The NativeArray mixin contains the properties needed to make the native + Array support Ember.MutableArray and all of its dependent APIs. Unless you + have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to + false, this will be applied automatically. Otherwise you can apply the mixin + at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. + + @class NativeArray + @namespace Ember + @uses Ember.MutableArray + @uses Ember.Observable + @uses Ember.Copyable + @public + */ + var NativeArray = _emberMetal.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, { - function EnterOpcode(begin, end) { - _Opcode14.call(this); - this.type = "enter"; - this.slice = new _glimmerUtil.ListSlice(begin, end); - } + // because length is a built-in property we need to know to just get the + // original property. + get: function (key) { + if ('number' === typeof key) { + return this[key]; + } else { + return this._super(key); + } + }, - EnterOpcode.prototype.evaluate = function evaluate(vm) { - vm.enter(this.slice); - }; + objectAt: function (idx) { + return this[idx]; + }, - EnterOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var type = this.type; - var _guid = this._guid; + // primitive for array support. + replace: function (idx, amt, objects) { + if (this.isFrozen) { + throw _emberRuntimeMixinsFreezable.FROZEN_ERROR; + } - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + // if we replaced exactly the same number of items, then pass only the + // replaced range. Otherwise, pass the full remaining array length + // since everything has shifted + var len = objects ? _emberMetal.get(objects, 'length') : 0; + _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, amt, len); - return EnterOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (len === 0) { + this.splice(idx, amt); + } else { + _emberMetal.replace(this, idx, amt, objects); + } - exports.EnterOpcode = EnterOpcode; + _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, amt, len); + return this; + }, - var ExitOpcode = (function (_Opcode15) { - babelHelpers.inherits(ExitOpcode, _Opcode15); + // If you ask for an unknown property, then try to collect the value + // from member items. + unknownProperty: function (key, value) { + var ret = undefined; // = this.reducedProperty(key, value); + if (value !== undefined && ret === undefined) { + ret = this[key] = value; + } + return ret; + }, - function ExitOpcode() { - _Opcode15.apply(this, arguments); - this.type = "exit"; - } + indexOf: Array.prototype.indexOf, + lastIndexOf: Array.prototype.lastIndexOf, - ExitOpcode.prototype.evaluate = function evaluate(vm) { - vm.exit(); - }; + copy: function (deep) { + if (deep) { + return this.map(function (item) { + return _emberRuntimeCopy.default(item, true); + }); + } - return ExitOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + return this.slice(); + } + }); - exports.ExitOpcode = ExitOpcode; + // Remove any methods implemented natively so we don't override them + var ignore = ['length']; + NativeArray.keys().forEach(function (methodName) { + if (Array.prototype[methodName]) { + ignore.push(methodName); + } + }); - var LabelOpcode = (function (_Opcode16) { - babelHelpers.inherits(LabelOpcode, _Opcode16); + exports.NativeArray // TODO: only use default export + = NativeArray = (_NativeArray = NativeArray).without.apply(_NativeArray, ignore); - function LabelOpcode(label) { - _Opcode16.call(this); - this.tag = _glimmerReference.CONSTANT_TAG; - this.type = "label"; - this.label = null; - this.prev = null; - this.next = null; - if (label) this.label = label; + /** + Creates an `Ember.NativeArray` from an Array like object. + Does not modify the original object. Ember.A is not needed if + `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However, + it is recommended that you use Ember.A when creating addons for + ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES` + will be `true`. + + Example + + ```js + export default Ember.Component.extend({ + tagName: 'ul', + classNames: ['pagination'], + + init() { + this._super(...arguments); + + if (!this.get('content')) { + this.set('content', Ember.A()); } + } + }); + ``` + + @method A + @for Ember + @return {Ember.NativeArray} + @public + */ + var A = undefined; - LabelOpcode.prototype.evaluate = function evaluate() {}; - - LabelOpcode.prototype.inspect = function inspect() { - return this.label + ' [' + this._guid + ']'; - }; - - LabelOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.inspect())] - }; - }; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Array) { + NativeArray.apply(Array.prototype); + exports.A = A = function (arr) { + return arr || []; + }; + } else { + exports.A = A = function (arr) { + if (!arr) { + arr = []; + } + return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr); + }; + } - return LabelOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberMetal.default.A = A; + exports.A = A; + exports.NativeArray = NativeArray; + exports.default = NativeArray; +}); +// Ember.A circular +enifed('ember-runtime/system/object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberUtils, _emberMetal, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) { + /** + @module ember + @submodule ember-runtime + */ - exports.LabelOpcode = LabelOpcode; + 'use strict'; - var EvaluateOpcode = (function (_Opcode17) { - babelHelpers.inherits(EvaluateOpcode, _Opcode17); + /** + `Ember.Object` is the main base class for all Ember objects. It is a subclass + of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, + see the documentation for each of these. + + @class Object + @namespace Ember + @extends Ember.CoreObject + @uses Ember.Observable + @public + */ + var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default); + EmberObject.toString = function () { + return 'Ember.Object'; + }; - function EvaluateOpcode(debug, block) { - _Opcode17.call(this); - this.debug = debug; - this.block = block; - this.type = "evaluate"; - } + var FrameworkObject = EmberObject; - EvaluateOpcode.prototype.evaluate = function evaluate(vm) { - vm.invokeBlock(this.block, vm.frame.getArgs()); - }; + exports.FrameworkObject = FrameworkObject; + _emberMetal.runInDebug(function () { + var _EmberObject$extend; - EvaluateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var debug = this.debug; - var block = this.block; - - var compiled = block['compiled']; - var children = undefined; - if (compiled) { - children = compiled.ops.toArray().map(function (op) { - return op.toJSON(); - }); - } else { - children = [{ guid: null, type: '[ UNCOMPILED BLOCK ]' }]; - } - return { - guid: guid, - type: type, - args: [debug], - children: children - }; - }; + var INIT_WAS_CALLED = _emberUtils.symbol('INIT_WAS_CALLED'); + var ASSERT_INIT_WAS_CALLED = _emberUtils.symbol('ASSERT_INIT_WAS_CALLED'); - return EvaluateOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + exports.FrameworkObject = FrameworkObject = EmberObject.extend((_EmberObject$extend = { + init: function () { + this._super.apply(this, arguments); + this[INIT_WAS_CALLED] = true; + } - exports.EvaluateOpcode = EvaluateOpcode; - var ConstTest = function (ref, env) { - return new _glimmerReference.ConstReference(!!ref.value()); - }; - exports.ConstTest = ConstTest; - var SimpleTest = function (ref, env) { - return ref; - }; - exports.SimpleTest = SimpleTest; - var EnvironmentTest = function (ref, env) { - return env.toConditionalReference(ref); - }; - exports.EnvironmentTest = EnvironmentTest; + }, _EmberObject$extend[ASSERT_INIT_WAS_CALLED] = _emberMetal.on('init', function () { + _emberMetal.assert('You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update ' + this + ' to call `this._super(...arguments);` from `init`.', this[INIT_WAS_CALLED]); + }), _EmberObject$extend)); + }); - var TestOpcode = (function (_Opcode18) { - babelHelpers.inherits(TestOpcode, _Opcode18); + exports.default = EmberObject; +}); +enifed('ember-runtime/system/object_proxy', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/-proxy'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsProxy) { + 'use strict'; - function TestOpcode(testFunc) { - _Opcode18.call(this); - this.testFunc = testFunc; - this.type = "test"; + /** + `Ember.ObjectProxy` forwards all properties not defined by the proxy itself + to a proxied `content` object. + + ```javascript + object = Ember.Object.create({ + name: 'Foo' + }); + + proxy = Ember.ObjectProxy.create({ + content: object + }); + + // Access and change existing properties + proxy.get('name') // 'Foo' + proxy.set('name', 'Bar'); + object.get('name') // 'Bar' + + // Create new 'description' property on `object` + proxy.set('description', 'Foo is a whizboo baz'); + object.get('description') // 'Foo is a whizboo baz' + ``` + + While `content` is unset, setting a property to be delegated will throw an + Error. + + ```javascript + proxy = Ember.ObjectProxy.create({ + content: null, + flag: null + }); + proxy.set('flag', true); + proxy.get('flag'); // true + proxy.get('foo'); // undefined + proxy.set('foo', 'data'); // throws Error + ``` + + Delegated properties can be bound to and will change when content is updated. + + Computed properties on the proxy itself can depend on delegated properties. + + ```javascript + ProxyWithComputedProperty = Ember.ObjectProxy.extend({ + fullName: Ember.computed('firstName', 'lastName', function() { + var firstName = this.get('firstName'), + lastName = this.get('lastName'); + if (firstName && lastName) { + return firstName + ' ' + lastName; } + return firstName || lastName; + }) + }); + + proxy = ProxyWithComputedProperty.create(); + + proxy.get('fullName'); // undefined + proxy.set('content', { + firstName: 'Tom', lastName: 'Dale' + }); // triggers property change for fullName on proxy + + proxy.get('fullName'); // 'Tom Dale' + ``` + + @class ObjectProxy + @namespace Ember + @extends Ember.Object + @extends Ember._ProxyMixin + @public + */ - TestOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setCondition(this.testFunc(vm.frame.getOperand(), vm.env)); - }; - - TestOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND", this.testFunc.name] - }; - }; + exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsProxy.default); +}); +enifed('ember-runtime/system/service', ['exports', 'ember-runtime/system/object', 'ember-runtime/inject'], function (exports, _emberRuntimeSystemObject, _emberRuntimeInject) { + 'use strict'; - return TestOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Creates a property that lazily looks up a service in the container. There + are no restrictions as to what objects a service can be injected into. + + Example: + + ```javascript + App.ApplicationRoute = Ember.Route.extend({ + authManager: Ember.inject.service('auth'), + + model: function() { + return this.get('authManager').findCurrentUser(); + } + }); + ``` + + This example will create an `authManager` property on the application route + that looks up the `auth` service in the container, making it easily + accessible in the `model` hook. + + @method service + @since 1.10.0 + @for Ember.inject + @param {String} name (optional) name of the service to inject, defaults to + the property's name + @return {Ember.InjectedProperty} injection descriptor instance + @public + */ + _emberRuntimeInject.createInjectionHelper('service'); - exports.TestOpcode = TestOpcode; + /** + @class Service + @namespace Ember + @extends Ember.Object + @since 1.10.0 + @public + */ + var Service = _emberRuntimeSystemObject.default.extend(); - var JumpOpcode = (function (_Opcode19) { - babelHelpers.inherits(JumpOpcode, _Opcode19); + Service.reopenClass({ + isServiceFactory: true + }); - function JumpOpcode(target) { - _Opcode19.call(this); - this.target = target; - this.type = "jump"; - } + exports.default = Service; +}); +enifed('ember-runtime/system/string', ['exports', 'ember-metal', 'ember-utils', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberUtils, _emberRuntimeUtils, _emberRuntimeString_registry) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - JumpOpcode.prototype.evaluate = function evaluate(vm) { - vm.goto(this.target); - }; + var STRING_DASHERIZE_REGEXP = /[ _]/g; - JumpOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.target.inspect())] - }; - }; + var STRING_DASHERIZE_CACHE = new _emberMetal.Cache(1000, function (key) { + return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-'); + }); - return JumpOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; + var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; - exports.JumpOpcode = JumpOpcode; + var CAMELIZE_CACHE = new _emberMetal.Cache(1000, function (key) { + return key.replace(STRING_CAMELIZE_REGEXP_1, function (match, separator, chr) { + return chr ? chr.toUpperCase() : ''; + }).replace(STRING_CAMELIZE_REGEXP_2, function (match, separator, chr) { + return match.toLowerCase(); + }); + }); - var JumpIfOpcode = (function (_JumpOpcode) { - babelHelpers.inherits(JumpIfOpcode, _JumpOpcode); + var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; + var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; + var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; - function JumpIfOpcode() { - _JumpOpcode.apply(this, arguments); - this.type = "jump-if"; - } + var CLASSIFY_CACHE = new _emberMetal.Cache(1000, function (str) { + var replace1 = function (match, separator, chr) { + return chr ? '_' + chr.toUpperCase() : ''; + }; + var replace2 = function (match, initialChar, separator, chr) { + return initialChar + (chr ? chr.toUpperCase() : ''); + }; + var parts = str.split('/'); + for (var i = 0; i < parts.length; i++) { + parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); + } + return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, function (match, separator, chr) { + return match.toUpperCase(); + }); + }); - JumpIfOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getCondition(); - if (_glimmerReference.isConst(reference)) { - if (reference.value()) { - _JumpOpcode.prototype.evaluate.call(this, vm); - } - } else { - var cache = new _glimmerReference.ReferenceCache(reference); - if (cache.peek()) { - _JumpOpcode.prototype.evaluate.call(this, vm); - } - vm.updateWith(new Assert(cache)); - } - }; + var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; + var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; - return JumpIfOpcode; - })(JumpOpcode); + var UNDERSCORE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase(); + }); - exports.JumpIfOpcode = JumpIfOpcode; + var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z])/g; - var JumpUnlessOpcode = (function (_JumpOpcode2) { - babelHelpers.inherits(JumpUnlessOpcode, _JumpOpcode2); + var CAPITALIZE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_CAPITALIZE_REGEXP, function (match, separator, chr) { + return match.toUpperCase(); + }); + }); - function JumpUnlessOpcode() { - _JumpOpcode2.apply(this, arguments); - this.type = "jump-unless"; - } + var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; - JumpUnlessOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getCondition(); - if (_glimmerReference.isConst(reference)) { - if (!reference.value()) { - _JumpOpcode2.prototype.evaluate.call(this, vm); - } - } else { - var cache = new _glimmerReference.ReferenceCache(reference); - if (!cache.peek()) { - _JumpOpcode2.prototype.evaluate.call(this, vm); - } - vm.updateWith(new Assert(cache)); - } - }; + var DECAMELIZE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase(); + }); - return JumpUnlessOpcode; - })(JumpOpcode); + function _fmt(str, formats) { + var cachedFormats = formats; - exports.JumpUnlessOpcode = JumpUnlessOpcode; + if (!_emberRuntimeUtils.isArray(cachedFormats) || arguments.length > 2) { + cachedFormats = new Array(arguments.length - 1); - var Assert = (function (_UpdatingOpcode) { - babelHelpers.inherits(Assert, _UpdatingOpcode); + for (var i = 1; i < arguments.length; i++) { + cachedFormats[i - 1] = arguments[i]; + } + } - function Assert(cache) { - _UpdatingOpcode.call(this); - this.type = "assert"; - this.tag = cache.tag; - this.cache = cache; - } + // first, replace any ORDERED replacements. + var idx = 0; // the current index for non-numerical replacements + return str.replace(/%@([0-9]+)?/g, function (s, argIndex) { + argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++; + s = cachedFormats[argIndex]; + return s === null ? '(null)' : s === undefined ? '' : _emberUtils.inspect(s); + }); + } - Assert.prototype.evaluate = function evaluate(vm) { - var cache = this.cache; + function fmt(str, formats) { + _emberMetal.deprecate('Ember.String.fmt is deprecated, use ES6 template strings instead.', false, { id: 'ember-string-utils.fmt', until: '3.0.0', url: 'http://babeljs.io/docs/learn-es2015/#template-strings' }); + return _fmt.apply(undefined, arguments); + } - if (_glimmerReference.isModified(cache.revalidate())) { - vm.throw(); - } - }; + function loc(str, formats) { + if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) { + formats = Array.prototype.slice.call(arguments, 1); + } - Assert.prototype.toJSON = function toJSON() { - var type = this.type; - var _guid = this._guid; - var cache = this.cache; + str = _emberRuntimeString_registry.get(str) || str; + return _fmt(str, formats); + } - var expected = undefined; - try { - expected = JSON.stringify(cache.peek()); - } catch (e) { - expected = String(cache.peek()); - } - return { - guid: _guid, - type: type, - args: [], - details: { expected: expected } - }; - }; + function w(str) { + return str.split(/\s+/); + } - return Assert; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + function decamelize(str) { + return DECAMELIZE_CACHE.get(str); + } - exports.Assert = Assert; + function dasherize(str) { + return STRING_DASHERIZE_CACHE.get(str); + } - var JumpIfNotModifiedOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(JumpIfNotModifiedOpcode, _UpdatingOpcode2); + function camelize(str) { + return CAMELIZE_CACHE.get(str); + } - function JumpIfNotModifiedOpcode(tag, target) { - _UpdatingOpcode2.call(this); - this.target = target; - this.type = "jump-if-not-modified"; - this.tag = tag; - this.lastRevision = tag.value(); - } + function classify(str) { + return CLASSIFY_CACHE.get(str); + } - JumpIfNotModifiedOpcode.prototype.evaluate = function evaluate(vm) { - var tag = this.tag; - var target = this.target; - var lastRevision = this.lastRevision; + function underscore(str) { + return UNDERSCORE_CACHE.get(str); + } - if (!vm.alwaysRevalidate && tag.validate(lastRevision)) { - vm.goto(target); - } - }; + function capitalize(str) { + return CAPITALIZE_CACHE.get(str); + } - JumpIfNotModifiedOpcode.prototype.didModify = function didModify() { - this.lastRevision = this.tag.value(); - }; + /** + Defines string helper methods including string formatting and localization. + Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be + added to the `String.prototype` as well. + + @class String + @namespace Ember + @static + @public + */ + exports.default = { + /** + Apply formatting options to the string. This will look for occurrences + of "%@" in your string and substitute them with the arguments you pass into + this method. If you want to control the specific order of replacement, + you can add a number after the key as well to indicate which argument + you want to insert. + Ordered insertions are most useful when building loc strings where values + you need to insert may appear in different orders. + ```javascript + "Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe" + "Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John" + ``` + @method fmt + @param {String} str The string to format + @param {Array} formats An array of parameters to interpolate into string. + @return {String} formatted string + @public + @deprecated Use ES6 template strings instead: http://babeljs.io/docs/learn-es2015/#template-strings + */ + fmt: fmt, - JumpIfNotModifiedOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.target.inspect())] - }; - }; + /** + Formats the passed string, but first looks up the string in the localized + strings hash. This is a convenient way to localize text. See + `Ember.String.fmt()` for more information on formatting. + Note that it is traditional but not required to prefix localized string + keys with an underscore or other character so you can easily identify + localized strings. + ```javascript + Ember.STRINGS = { + '_Hello World': 'Bonjour le monde', + '_Hello %@ %@': 'Bonjour %@ %@' + }; + Ember.String.loc("_Hello World"); // 'Bonjour le monde'; + Ember.String.loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; + ``` + @method loc + @param {String} str The string to format + @param {Array} formats Optional array of parameters to interpolate into string. + @return {String} formatted string + @public + */ + loc: loc, - return JumpIfNotModifiedOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + Splits a string into separate units separated by spaces, eliminating any + empty strings in the process. This is a convenience method for split that + is mostly useful when applied to the `String.prototype`. + ```javascript + Ember.String.w("alpha beta gamma").forEach(function(key) { + console.log(key); + }); + // > alpha + // > beta + // > gamma + ``` + @method w + @param {String} str The string to split + @return {Array} array containing the split strings + @public + */ + w: w, - exports.JumpIfNotModifiedOpcode = JumpIfNotModifiedOpcode; + /** + Converts a camelized string into all lower case separated by underscores. + ```javascript + 'innerHTML'.decamelize(); // 'inner_html' + 'action_name'.decamelize(); // 'action_name' + 'css-class-name'.decamelize(); // 'css-class-name' + 'my favorite items'.decamelize(); // 'my favorite items' + ``` + @method decamelize + @param {String} str The string to decamelize. + @return {String} the decamelized string. + @public + */ + decamelize: decamelize, - var DidModifyOpcode = (function (_UpdatingOpcode3) { - babelHelpers.inherits(DidModifyOpcode, _UpdatingOpcode3); + /** + Replaces underscores, spaces, or camelCase with dashes. + ```javascript + 'innerHTML'.dasherize(); // 'inner-html' + 'action_name'.dasherize(); // 'action-name' + 'css-class-name'.dasherize(); // 'css-class-name' + 'my favorite items'.dasherize(); // 'my-favorite-items' + 'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice' + ``` + @method dasherize + @param {String} str The string to dasherize. + @return {String} the dasherized string. + @public + */ + dasherize: dasherize, - function DidModifyOpcode(target) { - _UpdatingOpcode3.call(this); - this.target = target; - this.type = "did-modify"; - this.tag = _glimmerReference.CONSTANT_TAG; - } + /** + Returns the lowerCamelCase form of a string. + ```javascript + 'innerHTML'.camelize(); // 'innerHTML' + 'action_name'.camelize(); // 'actionName' + 'css-class-name'.camelize(); // 'cssClassName' + 'my favorite items'.camelize(); // 'myFavoriteItems' + 'My Favorite Items'.camelize(); // 'myFavoriteItems' + 'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice' + ``` + @method camelize + @param {String} str The string to camelize. + @return {String} the camelized string. + @public + */ + camelize: camelize, - DidModifyOpcode.prototype.evaluate = function evaluate() { - this.target.didModify(); - }; + /** + Returns the UpperCamelCase form of a string. + ```javascript + 'innerHTML'.classify(); // 'InnerHTML' + 'action_name'.classify(); // 'ActionName' + 'css-class-name'.classify(); // 'CssClassName' + 'my favorite items'.classify(); // 'MyFavoriteItems' + 'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice' + ``` + @method classify + @param {String} str the string to classify + @return {String} the classified string + @public + */ + classify: classify, - return DidModifyOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + More general than decamelize. Returns the lower\_case\_and\_underscored + form of a string. + ```javascript + 'innerHTML'.underscore(); // 'inner_html' + 'action_name'.underscore(); // 'action_name' + 'css-class-name'.underscore(); // 'css_class_name' + 'my favorite items'.underscore(); // 'my_favorite_items' + 'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice' + ``` + @method underscore + @param {String} str The string to underscore. + @return {String} the underscored string. + @public + */ + underscore: underscore, - exports.DidModifyOpcode = DidModifyOpcode; + /** + Returns the Capitalized form of a string + ```javascript + 'innerHTML'.capitalize() // 'InnerHTML' + 'action_name'.capitalize() // 'Action_name' + 'css-class-name'.capitalize() // 'Css-class-name' + 'my favorite items'.capitalize() // 'My favorite items' + 'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice' + ``` + @method capitalize + @param {String} str The string to capitalize. + @return {String} The capitalized string. + @public + */ + capitalize: capitalize + }; + exports.fmt = fmt; + exports.loc = loc; + exports.w = w; + exports.decamelize = decamelize; + exports.dasherize = dasherize; + exports.camelize = camelize; + exports.classify = classify; + exports.underscore = underscore; + exports.capitalize = capitalize; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy92bS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFXQSxvQkFBQTs4QkFBQSxvQkFBQTs7QUFBQSxpQkFBQSxvQkFBQSxHQUFBO0FBQTBDLGdDQUFBLFNBQUEsQ0FBQSxDQUFNO0FBQ3ZDLGdCQUFBLENBQUEsSUFBSSxHQUFHLGtCQUFrQixDQUFDO1NBS2xDOztBQU5ELDRCQUFBLFdBR0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGNBQUUsQ0FBQyxjQUFjLEVBQUUsQ0FBQztTQUNyQjs7ZUFMSCxvQkFBQTtpQ0FYUyxNQUFNOzs7O1FBbUJmLGNBQUE7OEJBQUEsY0FBQTs7QUFBQSxpQkFBQSxjQUFBLEdBQUE7QUFBb0MsaUNBQUEsU0FBQSxDQUFBLENBQU07QUFDakMsZ0JBQUEsQ0FBQSxJQUFJLEdBQUcsV0FBVyxDQUFDO1NBSzNCOztBQU5ELHNCQUFBLFdBR0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGNBQUUsQ0FBQyxRQ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24pKSB7XG4gICAgICB2bS5nb3RvKHRhcmdldCk7XG4gICAgfVxuICB9XG5cbiAgZGlkTW9kaWZ5KCkge1xuICAgIHRoaXMubGFzdFJldmlzaW9uID0gdGhpcy50YWcudmFsdWUoKTtcbiAgfVxuXG4gIHRvSlNPTigpOiBPcGNvZGVKU09OIHtcbiAgICByZXR1cm4ge1xuICAgICAgZ3VpZDogdGhpcy5fZ3VpZCxcbiAgICAgIHR5cGU6IHRoaXMudHlwZSxcbiAgICAgIGFyZ3M6IFtKU09OLnN0cmluZ2lmeSh0aGlzLnRhcmdldC5pbnNwZWN0KCkpXVxuICAgIH07XG4gIH1cbn1cblxuZXhwb3J0IGNsYXNzIERpZE1vZGlmeU9wY29kZSBleHRlbmRzIFVwZGF0aW5nT3Bjb2RlIHtcbiAgcHVibGljIHR5cGUgPSBcImRpZC1tb2RpZnlcIjtcblxuICBjb25zdHJ1Y3Rvcihwcml2YXRlIHRhcmdldDogSnVtcElmTm90TW9kaWZpZWRPcGNvZGUpIHtcbiAgICBzdXBlcigpO1xuICAgIHRoaXMudGFnID0gQ09OU1RBTlRfVEFHO1xuICB9XG5cbiAgZXZhbHVhdGUoKSB7XG4gICAgdGhpcy50YXJnZXQuZGlkTW9kaWZ5KCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiler', ['exports', 'glimmer-util', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-runtime/lib/compiled/expressions/function', 'glimmer-runtime/lib/compiled/opcodes/builder'], function (exports, _glimmerUtil, _glimmerRuntimeLibUtils, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibCompiledBlocks, _glimmerRuntimeLibCompiledExpressionsFunction, _glimmerRuntimeLibCompiledOpcodesBuilder) { - 'use strict'; +enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemObject) { + 'use strict'; - exports.compileLayout = compileLayout; + exports.isArray = isArray; + exports.typeOf = typeOf; - var Compiler = (function () { - function Compiler(block, env) { - this.block = block; - this.env = env; - this.current = block.program.head(); - this.symbolTable = block.symbolTable; - } + // ........................................ + // TYPING & ARRAY MESSAGING + // + var TYPE_MAP = { + '[object Boolean]': 'boolean', + '[object Number]': 'number', + '[object String]': 'string', + '[object Function]': 'function', + '[object Array]': 'array', + '[object Date]': 'date', + '[object RegExp]': 'regexp', + '[object Object]': 'object', + '[object FileList]': 'filelist' + }; - Compiler.prototype.compileStatement = function compileStatement(statement, ops) { - this.env.statement(statement, this.symbolTable).compile(ops, this.env, this.symbolTable); - }; + var toString = Object.prototype.toString; - return Compiler; - })(); + /** + Returns true if the passed object is an array or Array-like. + + Objects are considered Array-like if any of the following are true: + + - the object is a native Array + - the object has an objectAt property + - the object is an Object, and has a length property + + Unlike `Ember.typeOf` this method returns true even if the passed object is + not formally an array but appears to be array-like (i.e. implements `Ember.Array`) + + ```javascript + Ember.isArray(); // false + Ember.isArray([]); // true + Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true + ``` + + @method isArray + @for Ember + @param {Object} obj The object to test + @return {Boolean} true if the passed object is an array or Array-like + @public + */ - function compileStatement(env, statement, ops, layout) { - env.statement(statement, layout.symbolTable).compile(ops, env, layout.symbolTable); + function isArray(obj) { + if (!obj || obj.setInterval) { + return false; + } + if (Array.isArray(obj)) { + return true; + } + if (_emberRuntimeMixinsArray.default.detect(obj)) { + return true; } - exports.default = Compiler; - - var EntryPointCompiler = (function (_Compiler) { - babelHelpers.inherits(EntryPointCompiler, _Compiler); - - function EntryPointCompiler(template, env) { - _Compiler.call(this, template, env); - var list = new CompileIntoList(env, template.symbolTable); - this.ops = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(list, template.symbolTable, env); - } - - EntryPointCompiler.prototype.compile = function compile() { - var block = this.block; - var ops = this.ops; - var program = block.program; - - var current = program.head(); - while (current) { - var next = program.nextNode(current); - this.compileStatement(current, ops); - current = next; - } - return ops.toOpSeq(); - }; - EntryPointCompiler.prototype.append = function append(op) { - this.ops.append(op); - }; + var type = typeOf(obj); + if ('array' === type) { + return true; + } + if (obj.length !== undefined && 'object' === type) { + return true; + } + return false; + } - EntryPointCompiler.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.symbolTable.getLocal(name); - }; + /** + Returns a consistent type for the passed object. + + Use this instead of the built-in `typeof` to get the type of an item. + It will return the same result across all browsers and includes a bit + more detail. Here is what will be returned: + + | Return Value | Meaning | + |---------------|------------------------------------------------------| + | 'string' | String primitive or String object. | + | 'number' | Number primitive or Number object. | + | 'boolean' | Boolean primitive or Boolean object. | + | 'null' | Null value | + | 'undefined' | Undefined value | + | 'function' | A function | + | 'array' | An instance of Array | + | 'regexp' | An instance of RegExp | + | 'date' | An instance of Date | + | 'filelist' | An instance of FileList | + | 'class' | An Ember class (created using Ember.Object.extend()) | + | 'instance' | An Ember object instance | + | 'error' | An instance of the Error object | + | 'object' | A JavaScript object not inheriting from Ember.Object | + + Examples: + + ```javascript + Ember.typeOf(); // 'undefined' + Ember.typeOf(null); // 'null' + Ember.typeOf(undefined); // 'undefined' + Ember.typeOf('michael'); // 'string' + Ember.typeOf(new String('michael')); // 'string' + Ember.typeOf(101); // 'number' + Ember.typeOf(new Number(101)); // 'number' + Ember.typeOf(true); // 'boolean' + Ember.typeOf(new Boolean(true)); // 'boolean' + Ember.typeOf(Ember.makeArray); // 'function' + Ember.typeOf([1, 2, 90]); // 'array' + Ember.typeOf(/abc/); // 'regexp' + Ember.typeOf(new Date()); // 'date' + Ember.typeOf(event.target.files); // 'filelist' + Ember.typeOf(Ember.Object.extend()); // 'class' + Ember.typeOf(Ember.Object.create()); // 'instance' + Ember.typeOf(new Error('teamocil')); // 'error' + + // 'normal' JavaScript object + Ember.typeOf({ a: 'b' }); // 'object' + ``` + + @method typeOf + @for Ember + @param {Object} item the item to check + @return {String} the type + @public + */ - EntryPointCompiler.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.symbolTable.getNamed(name); - }; + function typeOf(item) { + if (item === null) { + return 'null'; + } + if (item === undefined) { + return 'undefined'; + } + var ret = TYPE_MAP[toString.call(item)] || 'object'; - EntryPointCompiler.prototype.getYieldSymbol = function getYieldSymbol(name) { - return this.symbolTable.getYield(name); - }; + if (ret === 'function') { + if (_emberRuntimeSystemObject.default.detect(item)) { + ret = 'class'; + } + } else if (ret === 'object') { + if (item instanceof Error) { + ret = 'error'; + } else if (item instanceof _emberRuntimeSystemObject.default) { + ret = 'instance'; + } else if (item instanceof Date) { + ret = 'date'; + } + } - return EntryPointCompiler; - })(Compiler); + return ret; + } +}); +enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { + 'use strict'; - exports.EntryPointCompiler = EntryPointCompiler; + function K() { + return this; + } - var InlineBlockCompiler = (function (_Compiler2) { - babelHelpers.inherits(InlineBlockCompiler, _Compiler2); + /** + @module ember + @submodule ember-testing + */ - function InlineBlockCompiler(block, env) { - _Compiler2.call(this, block, env); - this.block = block; - var list = new CompileIntoList(env, block.symbolTable); - this.ops = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(list, block.symbolTable, env); - } + /** + The primary purpose of this class is to create hooks that can be implemented + by an adapter for various test frameworks. + + @class Adapter + @namespace Ember.Test + @public + */ + exports.default = _emberRuntime.Object.extend({ + /** + This callback will be called whenever an async operation is about to start. + Override this to call your framework's methods that handle async + operations. + @public + @method asyncStart + */ + asyncStart: K, - InlineBlockCompiler.prototype.compile = function compile() { - var block = this.block; - var ops = this.ops; - var program = block.program; + /** + This callback will be called whenever an async operation has completed. + @public + @method asyncEnd + */ + asyncEnd: K, - var hasPositionalParameters = block.hasPositionalParameters(); - if (hasPositionalParameters) { - ops.pushChildScope(); - ops.bindPositionalArgsForBlock(block); - } - var current = program.head(); - while (current) { - var next = program.nextNode(current); - this.compileStatement(current, ops); - current = next; - } - if (hasPositionalParameters) { - ops.popScope(); - } - return ops.toOpSeq(); + /** + Override this method with your testing framework's false assertion. + This function is called whenever an exception occurs causing the testing + promise to fail. + QUnit example: + ```javascript + exception: function(error) { + ok(false, error); }; + ``` + @public + @method exception + @param {String} error The exception to be raised. + */ + exception: function (error) { + throw error; + } + }); +}); +enifed('ember-testing/adapters/qunit', ['exports', 'ember-utils', 'ember-testing/adapters/adapter'], function (exports, _emberUtils, _emberTestingAdaptersAdapter) { + 'use strict'; - return InlineBlockCompiler; - })(Compiler); - - exports.InlineBlockCompiler = InlineBlockCompiler; - - function compileLayout(compilable, env) { - var builder = new ComponentLayoutBuilder(env); - compilable.compile(builder); - return builder.compile(); + /** + This class implements the methods defined by Ember.Test.Adapter for the + QUnit testing framework. + + @class QUnitAdapter + @namespace Ember.Test + @extends Ember.Test.Adapter + @public + */ + exports.default = _emberTestingAdaptersAdapter.default.extend({ + asyncStart: function () { + QUnit.stop(); + }, + asyncEnd: function () { + QUnit.start(); + }, + exception: function (error) { + ok(false, _emberUtils.inspect(error)); } + }); +}); +enifed('ember-testing/events', ['exports', 'ember-views', 'ember-metal'], function (exports, _emberViews, _emberMetal) { + 'use strict'; - var ComponentLayoutBuilder = (function () { - function ComponentLayoutBuilder(env) { - this.env = env; - } + exports.focus = focus; + exports.fireEvent = fireEvent; - ComponentLayoutBuilder.prototype.empty = function empty() { - this.inner = new EmptyBuilder(this.env); - }; + var DEFAULT_EVENT_OPTIONS = { canBubble: true, cancelable: true }; + var KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup']; + var MOUSE_EVENT_TYPES = ['click', 'mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover']; - ComponentLayoutBuilder.prototype.wrapLayout = function wrapLayout(layout) { - this.inner = new WrappedBuilder(this.env, layout); - }; + function focus(el) { + if (!el) { + return; + } + var $el = _emberViews.jQuery(el); + if ($el.is(':input, [contenteditable=true]')) { + var type = $el.prop('type'); + if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') { + _emberMetal.run(null, function () { + // Firefox does not trigger the `focusin` event if the window + // does not have focus. If the document doesn't have focus just + // use trigger('focusin') instead. - ComponentLayoutBuilder.prototype.fromLayout = function fromLayout(layout) { - this.inner = new UnwrappedBuilder(this.env, layout); - }; + if (!document.hasFocus || document.hasFocus()) { + el.focus(); + } else { + $el.trigger('focusin'); + } + }); + } + } + } - ComponentLayoutBuilder.prototype.compile = function compile() { - return this.inner.compile(); - }; + function fireEvent(element, type) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - babelHelpers.createClass(ComponentLayoutBuilder, [{ - key: 'tag', - get: function () { - return this.inner.tag; - } - }, { - key: 'attrs', - get: function () { - return this.inner.attrs; - } - }]); - return ComponentLayoutBuilder; - })(); + if (!element) { + return; + } + var event = undefined; + if (KEYBOARD_EVENT_TYPES.indexOf(type) > -1) { + event = buildKeyboardEvent(type, options); + } else if (MOUSE_EVENT_TYPES.indexOf(type) > -1) { + var rect = element.getBoundingClientRect(); + var x = rect.left + 1; + var y = rect.top + 1; + var simulatedCoordinates = { + screenX: x + 5, + screenY: y + 95, + clientX: x, + clientY: y + }; + event = buildMouseEvent(type, _emberViews.jQuery.extend(simulatedCoordinates, options)); + } else { + event = buildBasicEvent(type, options); + } + element.dispatchEvent(event); + } - var EmptyBuilder = (function () { - function EmptyBuilder(env) { - this.env = env; - } + function buildBasicEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - EmptyBuilder.prototype.compile = function compile() { - var env = this.env; + var event = document.createEvent('Events'); + event.initEvent(type, true, true); + _emberViews.jQuery.extend(event, options); + return event; + } - var list = new CompileIntoList(env, null); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(list, 0); - }; + function buildMouseEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - babelHelpers.createClass(EmptyBuilder, [{ - key: 'tag', - get: function () { - throw new Error('Nope'); - } - }, { - key: 'attrs', - get: function () { - throw new Error('Nope'); - } - }]); - return EmptyBuilder; - })(); + var event = undefined; + try { + event = document.createEvent('MouseEvents'); + var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); + event.initMouseEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.detail, eventOpts.screenX, eventOpts.screenY, eventOpts.clientX, eventOpts.clientY, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.button, eventOpts.relatedTarget); + } catch (e) { + event = buildBasicEvent(type, options); + } + return event; + } - var WrappedBuilder = (function () { - function WrappedBuilder(env, layout) { - this.env = env; - this.layout = layout; - this.tag = new ComponentTagBuilder(); - this.attrs = new ComponentAttrsBuilder(); - } - - WrappedBuilder.prototype.compile = function compile() { - //========DYNAMIC - // PutValue(TagExpr) - // Test - // JumpUnless(BODY) - // OpenDynamicPrimitiveElement - // DidCreateElement - // ...attr statements... - // FlushElement - // BODY: Noop - // ...body statements... - // PutValue(TagExpr) - // Test - // JumpUnless(END) - // CloseElement - // END: Noop - // DidRenderLayout - // Exit - // - //========STATIC - // OpenPrimitiveElementOpcode - // DidCreateElement - // ...attr statements... - // FlushElement - // ...body statements... - // CloseElement - // DidRenderLayout - // Exit - var env = this.env; - var layout = this.layout; - - var symbolTable = layout.symbolTable; - var buffer = new CompileIntoList(env, layout.symbolTable); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, layout.symbolTable, env); - dsl.startLabels(); - if (this.tag.isDynamic) { - dsl.putValue(this.tag.dynamicTagName); - dsl.test('simple'); - dsl.jumpUnless('BODY'); - dsl.openDynamicPrimitiveElement(); - dsl.didCreateElement(); - this.attrs['buffer'].forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - dsl.flushElement(); - dsl.label('BODY'); - } else if (this.tag.isStatic) { - var tag = this.tag.staticTagName; - dsl.openPrimitiveElement(tag); - dsl.didCreateElement(); - this.attrs['buffer'].forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - dsl.flushElement(); - } - dsl.preludeForLayout(layout); - layout.program.forEachNode(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - if (this.tag.isDynamic) { - dsl.putValue(this.tag.dynamicTagName); - dsl.test('simple'); - dsl.jumpUnless('END'); - dsl.closeElement(); - dsl.label('END'); - } else if (this.tag.isStatic) { - dsl.closeElement(); - } - dsl.didRenderLayout(); - dsl.stopLabels(); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(dsl.toOpSeq(), symbolTable.size); - }; + function buildKeyboardEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - return WrappedBuilder; - })(); + var event = undefined; + try { + event = document.createEvent('KeyEvents'); + var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); + event.initKeyEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.keyCode, eventOpts.charCode); + } catch (e) { + event = buildBasicEvent(type, options); + } + return event; + } +}); +enifed('ember-testing/ext/application', ['exports', 'ember-application', 'ember-testing/setup_for_testing', 'ember-testing/test/helpers', 'ember-testing/test/promise', 'ember-testing/test/run', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/adapter'], function (exports, _emberApplication, _emberTestingSetup_for_testing, _emberTestingTestHelpers, _emberTestingTestPromise, _emberTestingTestRun, _emberTestingTestOn_inject_helpers, _emberTestingTestAdapter) { + 'use strict'; - var UnwrappedBuilder = (function () { - function UnwrappedBuilder(env, layout) { - this.env = env; - this.layout = layout; - this.attrs = new ComponentAttrsBuilder(); - } - - UnwrappedBuilder.prototype.compile = function compile() { - var env = this.env; - var layout = this.layout; - - var buffer = new CompileIntoList(env, layout.symbolTable); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, layout.symbolTable, env); - dsl.startLabels(); - dsl.preludeForLayout(layout); - var attrs = this.attrs['buffer']; - var attrsInserted = false; - this.layout.program.forEachNode(function (statement) { - if (!attrsInserted && isOpenElement(statement)) { - dsl.openComponentElement(statement.tag); - dsl.didCreateElement(); - dsl.shadowAttributes(); - attrs.forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - attrsInserted = true; - } else { - compileStatement(env, statement, dsl, layout); - } - }); - dsl.didRenderLayout(); - dsl.stopLabels(); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(dsl.toOpSeq(), layout.symbolTable.size); - }; + _emberApplication.Application.reopen({ + /** + This property contains the testing helpers for the current application. These + are created once you call `injectTestHelpers` on your `Ember.Application` + instance. The included helpers are also available on the `window` object by + default, but can be used from this object on the individual application also. + @property testHelpers + @type {Object} + @default {} + @public + */ + testHelpers: {}, - babelHelpers.createClass(UnwrappedBuilder, [{ - key: 'tag', - get: function () { - throw new Error('BUG: Cannot call `tag` on an UnwrappedBuilder'); - } - }]); - return UnwrappedBuilder; - })(); + /** + This property will contain the original methods that were registered + on the `helperContainer` before `injectTestHelpers` is called. + When `removeTestHelpers` is called, these methods are restored to the + `helperContainer`. + @property originalMethods + @type {Object} + @default {} + @private + @since 1.3.0 + */ + originalMethods: {}, - function isOpenElement(syntax) { - return syntax instanceof _glimmerRuntimeLibSyntaxCore.OpenElement || syntax instanceof _glimmerRuntimeLibSyntaxCore.OpenPrimitiveElement; - } + /** + This property indicates whether or not this application is currently in + testing mode. This is set when `setupForTesting` is called on the current + application. + @property testing + @type {Boolean} + @default false + @since 1.3.0 + @public + */ + testing: false, + + /** + This hook defers the readiness of the application, so that you can start + the app when your tests are ready to run. It also sets the router's + location to 'none', so that the window's location will not be modified + (preventing both accidental leaking of state between tests and interference + with your testing framework). + Example: + ``` + App.setupForTesting(); + ``` + @method setupForTesting + @public + */ + setupForTesting: function () { + _emberTestingSetup_for_testing.default(); - var ComponentTagBuilder = (function () { - function ComponentTagBuilder() { - this.isDynamic = null; - this.isStatic = null; - this.staticTagName = null; - this.dynamicTagName = null; - } + this.testing = true; - ComponentTagBuilder.prototype.static = function _static(tagName) { - this.isStatic = true; - this.staticTagName = tagName; - }; + this.Router.reopen({ + location: 'none' + }); + }, - ComponentTagBuilder.prototype.dynamic = function dynamic(tagName) { - this.isDynamic = true; - this.dynamicTagName = _glimmerRuntimeLibCompiledExpressionsFunction.default(tagName); - }; + /** + This will be used as the container to inject the test helpers into. By + default the helpers are injected into `window`. + @property helperContainer + @type {Object} The object to be used for test helpers. + @default window + @since 1.2.0 + @private + */ + helperContainer: null, - return ComponentTagBuilder; - })(); + /** + This injects the test helpers into the `helperContainer` object. If an object is provided + it will be used as the helperContainer. If `helperContainer` is not set it will default + to `window`. If a function of the same name has already been defined it will be cached + (so that it can be reset if the helper is removed with `unregisterHelper` or + `removeTestHelpers`). + Any callbacks registered with `onInjectHelpers` will be called once the + helpers have been injected. + Example: + ``` + App.injectTestHelpers(); + ``` + @method injectTestHelpers + @public + */ + injectTestHelpers: function (helperContainer) { + if (helperContainer) { + this.helperContainer = helperContainer; + } else { + this.helperContainer = window; + } - var ComponentAttrsBuilder = (function () { - function ComponentAttrsBuilder() { - this.buffer = []; + this.reopen({ + willDestroy: function () { + this._super.apply(this, arguments); + this.removeTestHelpers(); } + }); - ComponentAttrsBuilder.prototype.static = function _static(name, value) { - this.buffer.push(new _glimmerRuntimeLibSyntaxCore.StaticAttr(name, value, null)); - }; + this.testHelpers = {}; + for (var _name in _emberTestingTestHelpers.helpers) { + this.originalMethods[_name] = this.helperContainer[_name]; + this.testHelpers[_name] = this.helperContainer[_name] = helper(this, _name); + protoWrap(_emberTestingTestPromise.default.prototype, _name, helper(this, _name), _emberTestingTestHelpers.helpers[_name].meta.wait); + } - ComponentAttrsBuilder.prototype.dynamic = function dynamic(name, value) { - this.buffer.push(new _glimmerRuntimeLibSyntaxCore.DynamicAttr(name, _glimmerRuntimeLibCompiledExpressionsFunction.default(value), null, false)); - }; + _emberTestingTestOn_inject_helpers.invokeInjectHelpersCallbacks(this); + }, - return ComponentAttrsBuilder; - })(); + /** + This removes all helpers that have been registered, and resets and functions + that were overridden by the helpers. + Example: + ```javascript + App.removeTestHelpers(); + ``` + @public + @method removeTestHelpers + */ + removeTestHelpers: function () { + if (!this.helperContainer) { + return; + } - var ComponentBuilder = (function () { - function ComponentBuilder(dsl) { - this.dsl = dsl; - this.env = dsl.env; - } + for (var _name2 in _emberTestingTestHelpers.helpers) { + this.helperContainer[_name2] = this.originalMethods[_name2]; + delete _emberTestingTestPromise.default.prototype[_name2]; + delete this.testHelpers[_name2]; + delete this.originalMethods[_name2]; + } + } + }); - ComponentBuilder.prototype.static = function _static(definition, args, symbolTable) { - var shadow = arguments.length <= 3 || arguments[3] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[3]; + // This method is no longer needed + // But still here for backwards compatibility + // of helper chaining + function protoWrap(proto, name, callback, isAsync) { + proto[name] = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - this.dsl.unit(function (dsl) { - dsl.putComponentDefinition(definition); - dsl.openComponent(args, shadow); - dsl.closeComponent(); - }); - }; + if (isAsync) { + return callback.apply(this, args); + } else { + return this.then(function () { + return callback.apply(this, args); + }); + } + }; + } - ComponentBuilder.prototype.dynamic = function dynamic(definitionArgs, definition, args, symbolTable) { - var shadow = arguments.length <= 4 || arguments[4] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[4]; - - this.dsl.unit(function (dsl) { - dsl.putArgs(definitionArgs); - dsl.putValue(_glimmerRuntimeLibCompiledExpressionsFunction.default(definition)); - dsl.test('simple'); - dsl.enter('BEGIN', 'END'); - dsl.label('BEGIN'); - dsl.jumpUnless('END'); - dsl.putDynamicComponentDefinition(); - dsl.openComponent(args, shadow); - dsl.closeComponent(); - dsl.label('END'); - dsl.exit(); - }); - }; + function helper(app, name) { + var fn = _emberTestingTestHelpers.helpers[name].method; + var meta = _emberTestingTestHelpers.helpers[name].meta; + if (!meta.wait) { + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - return ComponentBuilder; - })(); + return fn.apply(app, [app].concat(args)); + }; + } - var CompileIntoList = (function (_LinkedList) { - babelHelpers.inherits(CompileIntoList, _LinkedList); + return function () { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } - function CompileIntoList(env, symbolTable) { - _LinkedList.call(this); - this.env = env; - this.symbolTable = symbolTable; - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(this, symbolTable, env); - this.component = new ComponentBuilder(dsl); - } + var lastPromise = _emberTestingTestRun.default(function () { + return _emberTestingTestPromise.resolve(_emberTestingTestPromise.getLastPromise()); + }); - CompileIntoList.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.symbolTable.getLocal(name); - }; + // wait for last helper's promise to resolve and then + // execute. To be safe, we need to tell the adapter we're going + // asynchronous here, because fn may not be invoked before we + // return. + _emberTestingTestAdapter.asyncStart(); + return lastPromise.then(function () { + return fn.apply(app, [app].concat(args)); + }).finally(_emberTestingTestAdapter.asyncEnd); + }; + } +}); +enifed('ember-testing/ext/rsvp', ['exports', 'ember-runtime', 'ember-metal', 'ember-testing/test/adapter'], function (exports, _emberRuntime, _emberMetal, _emberTestingTestAdapter) { + 'use strict'; - CompileIntoList.prototype.hasLocalSymbol = function hasLocalSymbol(name) { - return typeof this.symbolTable.getLocal(name) === 'number'; - }; + _emberRuntime.RSVP.configure('async', function (callback, promise) { + // if schedule will cause autorun, we need to inform adapter + if (_emberMetal.isTesting() && !_emberMetal.run.backburner.currentInstance) { + _emberTestingTestAdapter.asyncStart(); + _emberMetal.run.backburner.schedule('actions', function () { + _emberTestingTestAdapter.asyncEnd(); + callback(promise); + }); + } else { + _emberMetal.run.backburner.schedule('actions', function () { + return callback(promise); + }); + } + }); - CompileIntoList.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.symbolTable.getNamed(name); - }; + exports.default = _emberRuntime.RSVP; +}); +enifed('ember-testing/helpers', ['exports', 'ember-metal', 'ember-testing/test/helpers', 'ember-testing/helpers/and_then', 'ember-testing/helpers/click', 'ember-testing/helpers/current_path', 'ember-testing/helpers/current_route_name', 'ember-testing/helpers/current_url', 'ember-testing/helpers/fill_in', 'ember-testing/helpers/find', 'ember-testing/helpers/find_with_assert', 'ember-testing/helpers/key_event', 'ember-testing/helpers/pause_test', 'ember-testing/helpers/trigger_event', 'ember-testing/helpers/visit', 'ember-testing/helpers/wait'], function (exports, _emberMetal, _emberTestingTestHelpers, _emberTestingHelpersAnd_then, _emberTestingHelpersClick, _emberTestingHelpersCurrent_path, _emberTestingHelpersCurrent_route_name, _emberTestingHelpersCurrent_url, _emberTestingHelpersFill_in, _emberTestingHelpersFind, _emberTestingHelpersFind_with_assert, _emberTestingHelpersKey_event, _emberTestingHelpersPause_test, _emberTestingHelpersTrigger_event, _emberTestingHelpersVisit, _emberTestingHelpersWait) { + 'use strict'; - CompileIntoList.prototype.hasNamedSymbol = function hasNamedSymbol(name) { - return typeof this.symbolTable.getNamed(name) === 'number'; - }; + _emberTestingTestHelpers.registerAsyncHelper('visit', _emberTestingHelpersVisit.default); + _emberTestingTestHelpers.registerAsyncHelper('click', _emberTestingHelpersClick.default); + _emberTestingTestHelpers.registerAsyncHelper('keyEvent', _emberTestingHelpersKey_event.default); + _emberTestingTestHelpers.registerAsyncHelper('fillIn', _emberTestingHelpersFill_in.default); + _emberTestingTestHelpers.registerAsyncHelper('wait', _emberTestingHelpersWait.default); + _emberTestingTestHelpers.registerAsyncHelper('andThen', _emberTestingHelpersAnd_then.default); + _emberTestingTestHelpers.registerAsyncHelper('pauseTest', _emberTestingHelpersPause_test.pauseTest); + _emberTestingTestHelpers.registerAsyncHelper('triggerEvent', _emberTestingHelpersTrigger_event.default); - CompileIntoList.prototype.getBlockSymbol = function getBlockSymbol(name) { - return this.symbolTable.getYield(name); - }; + _emberTestingTestHelpers.registerHelper('find', _emberTestingHelpersFind.default); + _emberTestingTestHelpers.registerHelper('findWithAssert', _emberTestingHelpersFind_with_assert.default); + _emberTestingTestHelpers.registerHelper('currentRouteName', _emberTestingHelpersCurrent_route_name.default); + _emberTestingTestHelpers.registerHelper('currentPath', _emberTestingHelpersCurrent_path.default); + _emberTestingTestHelpers.registerHelper('currentURL', _emberTestingHelpersCurrent_url.default); - CompileIntoList.prototype.hasBlockSymbol = function hasBlockSymbol(name) { - return typeof this.symbolTable.getYield(name) === 'number'; - }; + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + _emberTestingTestHelpers.registerHelper('resumeTest', _emberTestingHelpersPause_test.resumeTest); + } +}); +enifed("ember-testing/helpers/and_then", ["exports"], function (exports) { + /** + @module ember + @submodule ember-testing + */ + "use strict"; - CompileIntoList.prototype.getPartialArgsSymbol = function getPartialArgsSymbol() { - return this.symbolTable.getPartialArgs(); - }; + exports.default = andThen; - CompileIntoList.prototype.hasPartialArgsSymbol = function hasPartialArgsSymbol() { - return typeof this.symbolTable.getPartialArgs() === 'number'; - }; + function andThen(app, callback) { + return app.testHelpers.wait(callback(app)); + } +}); +enifed('ember-testing/helpers/click', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - CompileIntoList.prototype.toOpSeq = function toOpSeq() { - return this; - }; + exports.default = click; - return CompileIntoList; - })(_glimmerUtil.LinkedList); + /** + Clicks an element and triggers any actions triggered by the element's `click` + event. + + Example: + + ```javascript + click('.some-jQuery-selector').then(function() { + // assert something + }); + ``` + + @method click + @param {String} selector jQuery selector for finding element on the DOM + @param {Object} context A DOM Element, Document, or jQuery to use as context + @return {RSVP.Promise} + @public + */ - exports.CompileIntoList = CompileIntoList; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7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JldHVybiB0eXBlb2YgdGhpcy5zeW1ib2xUYWJsZS5nZXRZaWVsZChuYW1lKSA9PT0gJ251bWJlcic7XG4gIH1cblxuICBnZXRQYXJ0aWFsQXJnc1N5bWJvbCgpOiBudW1iZXIge1xuICAgIHJldHVybiB0aGlzLnN5bWJvbFRhYmxlLmdldFBhcnRpYWxBcmdzKCk7XG4gIH1cblxuICBoYXNQYXJ0aWFsQXJnc1N5bWJvbCgpOiBib29sZWFuIHtcbiAgICByZXR1cm4gdHlwZW9mIHRoaXMuc3ltYm9sVGFibGUuZ2V0UGFydGlhbEFyZ3MoKSA9PT0gJ251bWJlcic7XG4gIH1cblxuICB0b09wU2VxKCk6IE9wU2VxIHtcbiAgICByZXR1cm4gdGhpcztcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/component/interfaces', ['exports'], function (exports) { - 'use strict'; + function click(app, selector, context) { + var $el = app.testHelpers.findWithAssert(selector, context); + var el = $el[0]; - exports.isComponentDefinition = isComponentDefinition; - var COMPONENT_DEFINITION_BRAND = 'COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]'; + _emberTestingEvents.fireEvent(el, 'mousedown'); - function isComponentDefinition(obj) { - return typeof obj === 'object' && obj && obj[COMPONENT_DEFINITION_BRAND]; - } + _emberTestingEvents.focus(el); - var ComponentDefinition = function ComponentDefinition(name, manager, ComponentClass) { - this['COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]'] = true; - this.name = name; - this.manager = manager; - this.ComponentClass = ComponentClass; - }; + _emberTestingEvents.fireEvent(el, 'mouseup'); + _emberTestingEvents.fireEvent(el, 'click'); - exports.ComponentDefinition = ComponentDefinition; + return app.testHelpers.wait(); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcG9uZW50L2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwa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XNzID0gQ29tcG9uZW50Q2xhc3M7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/dom/attribute-managers', ['exports', 'glimmer-runtime/lib/dom/sanitized-values', 'glimmer-runtime/lib/dom/props', 'glimmer-runtime/lib/dom/helper', 'glimmer-runtime/lib/compiled/opcodes/content'], function (exports, _glimmerRuntimeLibDomSanitizedValues, _glimmerRuntimeLibDomProps, _glimmerRuntimeLibDomHelper, _glimmerRuntimeLibCompiledOpcodesContent) { - 'use strict'; +enifed('ember-testing/helpers/current_path', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - exports.defaultManagers = defaultManagers; - exports.defaultPropertyManagers = defaultPropertyManagers; - exports.defaultAttributeManagers = defaultAttributeManagers; - exports.readDOMAttr = readDOMAttr; + exports.default = currentPath; - function defaultManagers(element, attr, isTrusting, namespace) { - var tagName = element.tagName; - var isSVG = element.namespaceURI === _glimmerRuntimeLibDomHelper.SVG_NAMESPACE; - if (isSVG) { - return defaultAttributeManagers(tagName, attr); - } + /** + Returns the current path. + + Example: + + ```javascript + function validateURL() { + equal(currentPath(), 'some.path.index', "correct path was transitioned into."); + } + + click('#some-link-id').then(validateURL); + ``` + + @method currentPath + @return {Object} The currently active path. + @since 1.5.0 + @public + */ - var _normalizeProperty = _glimmerRuntimeLibDomProps.normalizeProperty(element, attr); + function currentPath(app) { + var routingService = app.__container__.lookup('service:-routing'); + return _emberMetal.get(routingService, 'currentPath'); + } +}); +enifed('ember-testing/helpers/current_route_name', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - var type = _normalizeProperty.type; - var normalized = _normalizeProperty.normalized; + exports.default = currentRouteName; - if (type === 'attr') { - return defaultAttributeManagers(tagName, normalized); - } else { - return defaultPropertyManagers(tagName, normalized); - } - } + /** + Returns the currently active route name. + Example: + ```javascript + function validateRouteName() { + equal(currentRouteName(), 'some.path', "correct route was transitioned into."); + } + visit('/some/path').then(validateRouteName) + ``` + @method currentRouteName + @return {Object} The name of the currently active route. + @since 1.5.0 + @public + */ - function defaultPropertyManagers(tagName, attr) { - if (_glimmerRuntimeLibDomSanitizedValues.requiresSanitization(tagName, attr)) { - return new SafePropertyManager(attr); - } - if (isUserInputValue(tagName, attr)) { - return INPUT_VALUE_PROPERTY_MANAGER; - } - if (isOptionSelected(tagName, attr)) { - return OPTION_SELECTED_MANAGER; - } - return new PropertyManager(attr); - } + function currentRouteName(app) { + var routingService = app.__container__.lookup('service:-routing'); + return _emberMetal.get(routingService, 'currentRouteName'); + } +}); +enifed('ember-testing/helpers/current_url', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - function defaultAttributeManagers(tagName, attr) { - if (_glimmerRuntimeLibDomSanitizedValues.requiresSanitization(tagName, attr)) { - return new SafeAttributeManager(attr); - } - return new AttributeManager(attr); - } + exports.default = currentURL; + + /** + Returns the current URL. + + Example: + + ```javascript + function validateURL() { + equal(currentURL(), '/some/path', "correct URL was transitioned into."); + } + + click('#some-link-id').then(validateURL); + ``` + + @method currentURL + @return {Object} The currently active URL. + @since 1.5.0 + @public + */ - function readDOMAttr(element, attr) { - var isSVG = element.namespaceURI === _glimmerRuntimeLibDomHelper.SVG_NAMESPACE; + function currentURL(app) { + var router = app.__container__.lookup('router:main'); + return _emberMetal.get(router, 'location').getURL(); + } +}); +enifed('ember-testing/helpers/fill_in', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - var _normalizeProperty2 = _glimmerRuntimeLibDomProps.normalizeProperty(element, attr); + exports.default = fillIn; - var type = _normalizeProperty2.type; - var normalized = _normalizeProperty2.normalized; + /** + Fills in an input element with some text. + + Example: + + ```javascript + fillIn('#email', 'you@example.com').then(function() { + // assert something + }); + ``` + + @method fillIn + @param {String} selector jQuery selector finding an input element on the DOM + to fill text with + @param {String} text text to place inside the input element + @return {RSVP.Promise} + @public + */ - if (isSVG) { - return element.getAttribute(normalized); - } - if (type === 'attr') { - return element.getAttribute(normalized); - } - { - return element[normalized]; - } + function fillIn(app, selector, contextOrText, text) { + var $el = undefined, + el = undefined, + context = undefined; + if (typeof text === 'undefined') { + text = contextOrText; + } else { + context = contextOrText; } + $el = app.testHelpers.findWithAssert(selector, context); + el = $el[0]; + _emberTestingEvents.focus(el); - ; + $el.eq(0).val(text); + _emberTestingEvents.fireEvent(el, 'input'); + _emberTestingEvents.fireEvent(el, 'change'); - var AttributeManager = (function () { - function AttributeManager(attr) { - this.attr = attr; - } + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/find', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - AttributeManager.prototype.setAttribute = function setAttribute(env, element, value, namespace) { - var dom = env.getAppendOperations(); - var normalizedValue = normalizeAttributeValue(value); - if (!isAttrRemovalValue(normalizedValue)) { - dom.setAttribute(element, this.attr, normalizedValue, namespace); - } - }; + exports.default = find; - AttributeManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - if (value === null || value === undefined || value === false) { - if (namespace) { - env.getDOM().removeAttributeNS(element, namespace, this.attr); - } else { - env.getDOM().removeAttribute(element, this.attr); - } - } else { - this.setAttribute(env, element, value); - } - }; + /** + Finds an element in the context of the app's container element. A simple alias + for `app.$(selector)`. + + Example: + + ```javascript + var $el = find('.my-selector'); + ``` + + With the `context` param: + + ```javascript + var $el = find('.my-selector', '.parent-element-class'); + ``` + + @method find + @param {String} selector jQuery string selector for element lookup + @param {String} [context] (optional) jQuery selector that will limit the selector + argument to find only within the context's children + @return {Object} jQuery object representing the results of the query + @public + */ - return AttributeManager; - })(); + function find(app, selector, context) { + var $el = undefined; + context = context || _emberMetal.get(app, 'rootElement'); + $el = app.$(selector, context); + return $el; + } +}); +enifed('ember-testing/helpers/find_with_assert', ['exports'], function (exports) { + /** + @module ember + @submodule ember-testing + */ + /** + Like `find`, but throws an error if the element selector returns no results. + + Example: + + ```javascript + var $el = findWithAssert('.doesnt-exist'); // throws error + ``` + + With the `context` param: + + ```javascript + var $el = findWithAssert('.selector-id', '.parent-element-class'); // assert will pass + ``` + + @method findWithAssert + @param {String} selector jQuery selector string for finding an element within + the DOM + @param {String} [context] (optional) jQuery selector that will limit the + selector argument to find only within the context's children + @return {Object} jQuery object representing the results of the query + @throws {Error} throws error if jQuery object returned has a length of 0 + @public + */ + 'use strict'; - exports.AttributeManager = AttributeManager; + exports.default = findWithAssert; - ; + function findWithAssert(app, selector, context) { + var $el = app.testHelpers.find(selector, context); + if ($el.length === 0) { + throw new Error('Element ' + selector + ' not found.'); + } + return $el; + } +}); +enifed('ember-testing/helpers/key_event', ['exports'], function (exports) { + /** + @module ember + @submodule ember-testing + */ + /** + Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode + Example: + ```javascript + keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() { + // assert something + }); + ``` + @method keyEvent + @param {String} selector jQuery selector for finding element on the DOM + @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup` + @param {Number} keyCode the keyCode of the simulated key event + @return {RSVP.Promise} + @since 1.5.0 + @public + */ + 'use strict'; - var PropertyManager = (function (_AttributeManager) { - babelHelpers.inherits(PropertyManager, _AttributeManager); + exports.default = keyEvent; - function PropertyManager() { - _AttributeManager.apply(this, arguments); - } + function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { + var context = undefined, + type = undefined; - PropertyManager.prototype.setAttribute = function setAttribute(env, element, value, namespace) { - if (!isAttrRemovalValue(value)) { - element[this.attr] = value; - } - }; + if (typeof keyCode === 'undefined') { + context = null; + keyCode = typeOrKeyCode; + type = contextOrType; + } else { + context = contextOrType; + type = typeOrKeyCode; + } - PropertyManager.prototype.removeAttribute = function removeAttribute(env, element, namespace) { - // TODO this sucks but to preserve properties first and to meet current - // semantics we must do this. - var attr = this.attr; + return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode }); + } +}); +enifed('ember-testing/helpers/pause_test', ['exports', 'ember-runtime', 'ember-console', 'ember-metal'], function (exports, _emberRuntime, _emberConsole, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - if (namespace) { - env.getDOM().removeAttributeNS(element, namespace, attr); - } else { - env.getDOM().removeAttribute(element, attr); - } - }; + exports.resumeTest = resumeTest; + exports.pauseTest = pauseTest; - PropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - // ensure the property is always updated - element[this.attr] = value; - if (isAttrRemovalValue(value)) { - this.removeAttribute(env, element, namespace); - } - }; + var resume = undefined; - return PropertyManager; - })(AttributeManager); + /** + Resumes a test paused by `pauseTest`. + + @method resumeTest + @return {void} + @public + */ - exports.PropertyManager = PropertyManager; + function resumeTest() { + _emberMetal.assert('Testing has not been paused. There is nothing to resume.', resume); + resume(); + resume = undefined; + } - ; - function normalizeAttributeValue(value) { - if (value === false || value === undefined || value === null) { - return null; - } - if (value === true) { - return ''; - } - // onclick function etc in SSR - if (typeof value === 'function') { - return null; - } - return String(value); - } - function isAttrRemovalValue(value) { - return value === null || value === undefined; - } + /** + Pauses the current test - this is useful for debugging while testing or for test-driving. + It allows you to inspect the state of your application at any point. + Example (The test will pause before clicking the button): + + ```javascript + visit('/') + return pauseTest(); + click('.btn'); + ``` + @since 1.9.0 + @method pauseTest + @return {Object} A promise that will never resolve + @public + */ - var SafePropertyManager = (function (_PropertyManager) { - babelHelpers.inherits(SafePropertyManager, _PropertyManager); + function pauseTest() { + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + _emberConsole.default.info('Testing paused. Use `resumeTest()` to continue.'); + } - function SafePropertyManager() { - _PropertyManager.apply(this, arguments); - } + return new _emberRuntime.RSVP.Promise(function (resolve) { + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + resume = resolve; + } + }, 'TestAdapter paused promise'); + } +}); +enifed('ember-testing/helpers/trigger_event', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - SafePropertyManager.prototype.setAttribute = function setAttribute(env, element, value) { - _PropertyManager.prototype.setAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + exports.default = triggerEvent; - SafePropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - _PropertyManager.prototype.updateAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + /** + Triggers the given DOM event on the element identified by the provided selector. + Example: + ```javascript + triggerEvent('#some-elem-id', 'blur'); + ``` + This is actually used internally by the `keyEvent` helper like so: + ```javascript + triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 }); + ``` + @method triggerEvent + @param {String} selector jQuery selector for finding element on the DOM + @param {String} [context] jQuery selector that will limit the selector + argument to find only within the context's children + @param {String} type The event type to be triggered. + @param {Object} [options] The options to be passed to jQuery.Event. + @return {RSVP.Promise} + @since 1.5.0 + @public + */ - return SafePropertyManager; - })(PropertyManager); + function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { + var arity = arguments.length; + var context = undefined, + type = undefined, + options = undefined; - function isUserInputValue(tagName, attribute) { - return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value'; + if (arity === 3) { + // context and options are optional, so this is + // app, selector, type + context = null; + type = contextOrType; + options = {}; + } else if (arity === 4) { + // context and options are optional, so this is + if (typeof typeOrOptions === 'object') { + // either + // app, selector, type, options + context = null; + type = contextOrType; + options = typeOrOptions; + } else { + // or + // app, selector, context, type + context = contextOrType; + type = typeOrOptions; + options = {}; + } + } else { + context = contextOrType; + type = typeOrOptions; + options = possibleOptions; } - var InputValuePropertyManager = (function (_AttributeManager2) { - babelHelpers.inherits(InputValuePropertyManager, _AttributeManager2); + var $el = app.testHelpers.findWithAssert(selector, context); + var el = $el[0]; - function InputValuePropertyManager() { - _AttributeManager2.apply(this, arguments); - } + _emberTestingEvents.fireEvent(el, type, options); - InputValuePropertyManager.prototype.setAttribute = function setAttribute(env, element, value) { - var input = element; - input.value = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - }; + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/visit', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - InputValuePropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - var input = element; - var currentValue = input.value; - var normalizedValue = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - if (currentValue !== normalizedValue) { - input.value = normalizedValue; - } - }; + exports.default = visit; - return InputValuePropertyManager; - })(AttributeManager); + /** + Loads a route, sets up any controllers, and renders any templates associated + with the route as though a real user had triggered the route change while + using your app. + + Example: + + ```javascript + visit('posts/index').then(function() { + // assert something + }); + ``` + + @method visit + @param {String} url the name of the route + @return {RSVP.Promise} + @public + */ - var INPUT_VALUE_PROPERTY_MANAGER = new InputValuePropertyManager('value'); - exports.INPUT_VALUE_PROPERTY_MANAGER = INPUT_VALUE_PROPERTY_MANAGER; - function isOptionSelected(tagName, attribute) { - return tagName === 'OPTION' && attribute === 'selected'; - } + function visit(app, url) { + var router = app.__container__.lookup('router:main'); + var shouldHandleURL = false; - var OptionSelectedManager = (function (_PropertyManager2) { - babelHelpers.inherits(OptionSelectedManager, _PropertyManager2); + app.boot().then(function () { + router.location.setURL(url); - function OptionSelectedManager() { - _PropertyManager2.apply(this, arguments); - } + if (shouldHandleURL) { + _emberMetal.run(app.__deprecatedInstance__, 'handleURL', url); + } + }); - OptionSelectedManager.prototype.setAttribute = function setAttribute(env, element, value) { - if (value !== null && value !== undefined && value !== false) { - var option = element; - option.selected = true; - } - }; + if (app._readinessDeferrals > 0) { + router['initialURL'] = url; + _emberMetal.run(app, 'advanceReadiness'); + delete router['initialURL']; + } else { + shouldHandleURL = true; + } - OptionSelectedManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - var option = element; - if (value) { - option.selected = true; - } else { - option.selected = false; - } - }; + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/wait', ['exports', 'ember-testing/test/waiters', 'ember-runtime', 'ember-metal', 'ember-testing/test/pending_requests'], function (exports, _emberTestingTestWaiters, _emberRuntime, _emberMetal, _emberTestingTestPending_requests) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - return OptionSelectedManager; - })(PropertyManager); + exports.default = wait; - var OPTION_SELECTED_MANAGER = new OptionSelectedManager('selected'); - exports.OPTION_SELECTED_MANAGER = OPTION_SELECTED_MANAGER; + /** + Causes the run loop to process any pending events. This is used to ensure that + any async operations from other helpers (or your assertions) have been processed. + + This is most often used as the return value for the helper functions (see 'click', + 'fillIn','visit',etc). However, there is a method to register a test helper which + utilizes this method without the need to actually call `wait()` in your helpers. + + The `wait` helper is built into `registerAsyncHelper` by default. You will not need + to `return app.testHelpers.wait();` - the wait behavior is provided for you. + + Example: + + ```javascript + Ember.Test.registerAsyncHelper('loginUser', function(app, username, password) { + visit('secured/path/here') + .fillIn('#username', username) + .fillIn('#password', password) + .click('.submit'); + }); + + @method wait + @param {Object} value The value to be returned. + @return {RSVP.Promise} + @public + @since 1.0.0 + */ - var SafeAttributeManager = (function (_AttributeManager3) { - babelHelpers.inherits(SafeAttributeManager, _AttributeManager3); + function wait(app, value) { + return new _emberRuntime.RSVP.Promise(function (resolve) { + var router = app.__container__.lookup('router:main'); - function SafeAttributeManager() { - _AttributeManager3.apply(this, arguments); + // Every 10ms, poll for the async thing to have finished + var watcher = setInterval(function () { + // 1. If the router is loading, keep polling + var routerIsLoading = router.router && !!router.router.activeTransition; + if (routerIsLoading) { + return; } - SafeAttributeManager.prototype.setAttribute = function setAttribute(env, element, value) { - _AttributeManager3.prototype.setAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + // 2. If there are pending Ajax requests, keep polling + if (_emberTestingTestPending_requests.pendingRequests()) { + return; + } - SafeAttributeManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - _AttributeManager3.prototype.updateAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + // 3. If there are scheduled timers or we are inside of a run loop, keep polling + if (_emberMetal.run.hasScheduledTimers() || _emberMetal.run.currentRunLoop) { + return; + } - return SafeAttributeManager; - })(AttributeManager); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2F0dHJpYnV0ZS1tYW5hZ2Vycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7OztBQVlBLGFBQUEsZUFBQSxDQUFnQyxPQUF1QixFQUFFLElBQVksRUFBRSxVQUFtQixFQUFFLFNBQWlCLEVBQUE7QUFDM0csWUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQztBQUM5QixZQUFJLEtBQUssR0FBRyxPQUFPLENBQUMsWUFBWSxpQ0FOekIsYUFBYSxBQU04QixDQUFDO0FBRW5ELFlBQUksS0FBSyxFQUFFO0FBQ1QsbUJBQU8sd0JBQXdCLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxDQUFDO1NBQ2hEOztpQ0FFMEIsMkJBYnBCLGlCQUFpQixDQWFxQixPQUFPLEVBQUUsSUFBSSxDQUFDOztZQUFyRCxJQUFJLHNCQUFKLElBQUk7WUFBRSxVQUFVLHNCQUFWLFVBQVU7O0FBRXRCLFlBQUksSUFBSSxLQUFLLE1BQU0sRUFBRTtBQUNuQixtQkFBTyx3QkFBd0IsQ0FBQyxPQUFPLEVBQUUsVUFBVSxDQUFDLENBQUM7U0FDdEQsTUFBTTtBQUNMLG1CQUFPLHVCQUF1QixDQUFDLE9BQU8sRUFBRSxVQUFVLENBQUMsQ0FBQztTQUNyRDtLQUNGOztBQUVELG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iXX0= -enifed('glimmer-runtime/lib/dom/helper', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/compat/inner-html-fix', 'glimmer-runtime/lib/compat/svg-inner-html-fix', 'glimmer-runtime/lib/compat/text-node-merging-fix', 'glimmer-runtime/lib/dom/interfaces'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibCompatInnerHtmlFix, _glimmerRuntimeLibCompatSvgInnerHtmlFix, _glimmerRuntimeLibCompatTextNodeMergingFix, _glimmerRuntimeLibDomInterfaces) { - 'use strict'; + if (_emberTestingTestWaiters.checkWaiters()) { + return; + } - exports.isWhitespace = isWhitespace; - exports.moveNodesBefore = moveNodesBefore; - exports.insertHTMLBefore = _insertHTMLBefore; - var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - exports.SVG_NAMESPACE = SVG_NAMESPACE; - // http://www.w3.org/TR/html/syntax.html#html-integration-point - var SVG_INTEGRATION_POINTS = { foreignObject: 1, desc: 1, title: 1 }; - // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes - // TODO: Adjust SVG attributes - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - // TODO: Adjust SVG elements - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - var BLACKLIST_TABLE = Object.create(null); - exports.BLACKLIST_TABLE = BLACKLIST_TABLE; - ["b", "big", "blockquote", "body", "br", "center", "code", "dd", "div", "dl", "dt", "em", "embed", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "i", "img", "li", "listing", "main", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", "span", "strong", "strike", "sub", "sup", "table", "tt", "u", "ul", "var"].forEach(function (tag) { - return BLACKLIST_TABLE[tag] = 1; - }); - var WHITESPACE = /[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/; - var doc = typeof document === 'undefined' ? undefined : document; - - function isWhitespace(string) { - return WHITESPACE.test(string); - } - - function moveNodesBefore(source, target, nextSibling) { - var first = source.firstChild; - var last = null; - var current = first; - while (current) { - last = current; - current = current.nextSibling; - target.insertBefore(last, nextSibling); - } - return [first, last]; - } - - var DOM; - exports.DOM = DOM; - (function (DOM) { - var TreeConstruction = (function () { - function TreeConstruction(document) { - this.document = document; - this.uselessElement = null; - this.setupUselessElement(); - } + // Stop polling + clearInterval(watcher); - TreeConstruction.prototype.setupUselessElement = function setupUselessElement() { - this.uselessElement = this.document.createElement('div'); - }; + // Synchronously resolve the promise + _emberMetal.run(null, resolve, value); + }, 10); + }); + } +}); +enifed('ember-testing/index', ['exports', 'ember-testing/support', 'ember-testing/ext/application', 'ember-testing/ext/rsvp', 'ember-testing/helpers', 'ember-testing/initializers', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/setup_for_testing', 'ember-testing/adapters/qunit'], function (exports, _emberTestingSupport, _emberTestingExtApplication, _emberTestingExtRsvp, _emberTestingHelpers, _emberTestingInitializers, _emberTestingTest, _emberTestingAdaptersAdapter, _emberTestingSetup_for_testing, _emberTestingAdaptersQunit) { + 'use strict'; - TreeConstruction.prototype.createElement = function createElement(tag, context) { - var isElementInSVGNamespace = undefined, - isHTMLIntegrationPoint = undefined; - if (context) { - isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg'; - isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName]; - } else { - isElementInSVGNamespace = tag === 'svg'; - isHTMLIntegrationPoint = false; - } - if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { - // FIXME: This does not properly handle with color, face, or - // size attributes, which is also disallowed by the spec. We should fix - // this. - if (BLACKLIST_TABLE[tag]) { - throw new Error('Cannot create a ' + tag + ' inside an SVG context'); - } - return this.document.createElementNS(SVG_NAMESPACE, tag); - } else { - return this.document.createElement(tag); - } - }; + exports.Test = _emberTestingTest.default; + exports.Adapter = _emberTestingAdaptersAdapter.default; + exports.setupForTesting = _emberTestingSetup_for_testing.default; + exports.QUnitAdapter = _emberTestingAdaptersQunit.default; +}); +// to handle various edge cases +// setup RSVP + run loop integration +// adds helpers to helpers object in Test +// to setup initializer - TreeConstruction.prototype.createElementNS = function createElementNS(namespace, tag) { - return this.document.createElementNS(namespace, tag); - }; +/** + @module ember + @submodule ember-testing +*/ +enifed('ember-testing/initializers', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { + 'use strict'; - TreeConstruction.prototype.setAttribute = function setAttribute(element, name, value, namespace) { - if (namespace) { - element.setAttributeNS(namespace, name, value); - } else { - element.setAttribute(name, value); - } - }; + var name = 'deferReadiness in `testing` mode'; - TreeConstruction.prototype.createTextNode = function createTextNode(text) { - return this.document.createTextNode(text); - }; + _emberRuntime.onLoad('Ember.Application', function (Application) { + if (!Application.initializers[name]) { + Application.initializer({ + name: name, - TreeConstruction.prototype.createComment = function createComment(data) { - return this.document.createComment(data); - }; + initialize: function (application) { + if (application.testing) { + application.deferReadiness(); + } + } + }); + } + }); +}); +enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit) { + /* global self */ - TreeConstruction.prototype.insertBefore = function insertBefore(parent, node, reference) { - parent.insertBefore(node, reference); - }; + 'use strict'; - TreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - return _insertHTMLBefore(this.uselessElement, parent, reference, html); - }; + exports.default = setupForTesting; - return TreeConstruction; - })(); + /** + Sets Ember up for testing. This is useful to perform + basic setup steps in order to unit test. + + Use `App.setupForTesting` to perform integration tests (full + application testing). + + @method setupForTesting + @namespace Ember + @since 1.5.0 + @private + */ - DOM.TreeConstruction = TreeConstruction; - var appliedTreeContruction = TreeConstruction; - appliedTreeContruction = _glimmerRuntimeLibCompatTextNodeMergingFix.treeConstruction(doc, appliedTreeContruction); - appliedTreeContruction = _glimmerRuntimeLibCompatInnerHtmlFix.treeConstruction(doc, appliedTreeContruction); - appliedTreeContruction = _glimmerRuntimeLibCompatSvgInnerHtmlFix.treeConstruction(doc, appliedTreeContruction, SVG_NAMESPACE); - DOM.DOMTreeConstruction = appliedTreeContruction; - })(DOM || (exports.DOM = DOM = {})); + function setupForTesting() { + _emberMetal.setTesting(true); - var DOMChanges = (function () { - function DOMChanges(document) { - this.document = document; - this.uselessElement = null; - this.namespace = null; - this.uselessElement = this.document.createElement('div'); - } + var adapter = _emberTestingTestAdapter.getAdapter(); + // if adapter is not manually set default to QUnit + if (!adapter) { + _emberTestingTestAdapter.setAdapter(typeof self.QUnit === 'undefined' ? new _emberTestingAdaptersAdapter.default() : new _emberTestingAdaptersQunit.default()); + } - DOMChanges.prototype.setAttribute = function setAttribute(element, name, value) { - element.setAttribute(name, value); - }; + _emberViews.jQuery(document).off('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); + _emberViews.jQuery(document).off('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); - DOMChanges.prototype.setAttributeNS = function setAttributeNS(element, namespace, name, value) { - element.setAttributeNS(namespace, name, value); - }; + _emberTestingTestPending_requests.clearPendingRequests(); - DOMChanges.prototype.removeAttribute = function removeAttribute(element, name) { - element.removeAttribute(name); - }; + _emberViews.jQuery(document).on('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); + _emberViews.jQuery(document).on('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); + } +}); +enifed('ember-testing/support', ['exports', 'ember-metal', 'ember-views', 'ember-environment'], function (exports, _emberMetal, _emberViews, _emberEnvironment) { + 'use strict'; - DOMChanges.prototype.removeAttributeNS = function removeAttributeNS(element, namespace, name) { - element.removeAttributeNS(namespace, name); - }; + /** + @module ember + @submodule ember-testing + */ - DOMChanges.prototype.createTextNode = function createTextNode(text) { - return this.document.createTextNode(text); - }; + var $ = _emberViews.jQuery; - DOMChanges.prototype.createComment = function createComment(data) { - return this.document.createComment(data); - }; + /** + This method creates a checkbox and triggers the click event to fire the + passed in handler. It is used to correct for a bug in older versions + of jQuery (e.g 1.8.3). + + @private + @method testCheckboxClick + */ + function testCheckboxClick(handler) { + var input = document.createElement('input'); + $(input).attr('type', 'checkbox').css({ position: 'absolute', left: '-1000px', top: '-1000px' }).appendTo('body').on('click', handler).trigger('click').remove(); + } - DOMChanges.prototype.createElement = function createElement(tag, context) { - var isElementInSVGNamespace = undefined, - isHTMLIntegrationPoint = undefined; - if (context) { - isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg'; - isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName]; - } else { - isElementInSVGNamespace = tag === 'svg'; - isHTMLIntegrationPoint = false; - } - if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { - // FIXME: This does not properly handle with color, face, or - // size attributes, which is also disallowed by the spec. We should fix - // this. - if (BLACKLIST_TABLE[tag]) { - throw new Error('Cannot create a ' + tag + ' inside an SVG context'); - } - return this.document.createElementNS(SVG_NAMESPACE, tag); - } else { - return this.document.createElement(tag); + if (_emberEnvironment.environment.hasDOM && typeof $ === 'function') { + $(function () { + /* + Determine whether a checkbox checked using jQuery's "click" method will have + the correct value for its checked property. + If we determine that the current jQuery version exhibits this behavior, + patch it to work correctly as in the commit for the actual fix: + https://github.com/jquery/jquery/commit/1fb2f92. + */ + testCheckboxClick(function () { + if (!this.checked && !$.event.special.click) { + $.event.special.click = { + // For checkbox, fire native event so checked state will be right + trigger: function () { + if ($.nodeName(this, 'input') && this.type === 'checkbox' && this.click) { + this.click(); + return false; + } } - }; - - DOMChanges.prototype.insertHTMLBefore = function insertHTMLBefore(_parent, nextSibling, html) { - return _insertHTMLBefore(this.uselessElement, _parent, nextSibling, html); - }; - - DOMChanges.prototype.insertNodeBefore = function insertNodeBefore(parent, node, reference) { - if (isDocumentFragment(node)) { - var firstChild = node.firstChild; - var lastChild = node.lastChild; + }; + } + }); - this.insertBefore(parent, node, reference); - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, firstChild, lastChild); - } else { - this.insertBefore(parent, node, reference); - return new _glimmerRuntimeLibBounds.SingleNodeBounds(parent, node); - } - }; + // Try again to verify that the patch took effect or blow up. + testCheckboxClick(function () { + _emberMetal.warn('clicked checkboxes should be checked! the jQuery patch didn\'t work', this.checked, { id: 'ember-testing.test-checkbox-click' }); + }); + }); + } +}); +enifed('ember-testing/test', ['exports', 'ember-testing/test/helpers', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/promise', 'ember-testing/test/waiters', 'ember-testing/test/adapter'], function (exports, _emberTestingTestHelpers, _emberTestingTestOn_inject_helpers, _emberTestingTestPromise, _emberTestingTestWaiters, _emberTestingTestAdapter) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - DOMChanges.prototype.insertTextBefore = function insertTextBefore(parent, nextSibling, text) { - var textNode = this.createTextNode(text); - this.insertBefore(parent, textNode, nextSibling); - return textNode; - }; + /** + This is a container for an assortment of testing related functionality: + + * Choose your default test adapter (for your framework of choice). + * Register/Unregister additional test helpers. + * Setup callbacks to be fired when the test helpers are injected into + your application. + + @class Test + @namespace Ember + @public + */ + var Test = { + /** + Hash containing all known test helpers. + @property _helpers + @private + @since 1.7.0 + */ + _helpers: _emberTestingTestHelpers.helpers, - DOMChanges.prototype.insertBefore = function insertBefore(element, node, reference) { - element.insertBefore(node, reference); - }; + registerHelper: _emberTestingTestHelpers.registerHelper, + registerAsyncHelper: _emberTestingTestHelpers.registerAsyncHelper, + unregisterHelper: _emberTestingTestHelpers.unregisterHelper, + onInjectHelpers: _emberTestingTestOn_inject_helpers.onInjectHelpers, + Promise: _emberTestingTestPromise.default, + promise: _emberTestingTestPromise.promise, + resolve: _emberTestingTestPromise.resolve, + registerWaiter: _emberTestingTestWaiters.registerWaiter, + unregisterWaiter: _emberTestingTestWaiters.unregisterWaiter, + checkWaiters: _emberTestingTestWaiters.checkWaiters + }; - DOMChanges.prototype.insertAfter = function insertAfter(element, node, reference) { - this.insertBefore(element, node, reference.nextSibling); - }; + /** + Used to allow ember-testing to communicate with a specific testing + framework. + + You can manually set it before calling `App.setupForTesting()`. + + Example: + + ```javascript + Ember.Test.adapter = MyCustomAdapter.create() + ``` + + If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`. + + @public + @for Ember.Test + @property adapter + @type {Class} The adapter to be used. + @default Ember.Test.QUnitAdapter + */ + Object.defineProperty(Test, 'adapter', { + get: _emberTestingTestAdapter.getAdapter, + set: _emberTestingTestAdapter.setAdapter + }); - return DOMChanges; - })(); + Object.defineProperty(Test, 'waiters', { + get: _emberTestingTestWaiters.generateDeprecatedWaitersArray + }); - exports.DOMChanges = DOMChanges; - - function _insertHTMLBefore(_useless, _parent, _nextSibling, html) { - // TypeScript vendored an old version of the DOM spec where `insertAdjacentHTML` - // only exists on `HTMLElement` but not on `Element`. We actually work with the - // newer version of the DOM API here (and monkey-patch this method in `./compat` - // when we detect older browsers). This is a hack to work around this limitation. - var parent = _parent; - var useless = _useless; - var nextSibling = _nextSibling; - var prev = nextSibling ? nextSibling.previousSibling : parent.lastChild; - var last = undefined; - if (html === null || html === '') { - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, null, null); - } - if (nextSibling === null) { - parent.insertAdjacentHTML('beforeEnd', html); - last = parent.lastChild; - } else if (nextSibling instanceof HTMLElement) { - nextSibling.insertAdjacentHTML('beforeBegin', html); - last = nextSibling.previousSibling; - } else { - // Non-element nodes do not support insertAdjacentHTML, so add an - // element and call it on that element. Then remove the element. - // - // This also protects Edge, IE and Firefox w/o the inspector open - // from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts - parent.insertBefore(useless, nextSibling); - useless.insertAdjacentHTML('beforeBegin', html); - last = useless.previousSibling; - parent.removeChild(useless); - } - var first = prev ? prev.nextSibling : parent.firstChild; - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - - function isDocumentFragment(node) { - return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE; - } - var helper = DOMChanges; - helper = _glimmerRuntimeLibCompatTextNodeMergingFix.domChanges(doc, helper); - helper = _glimmerRuntimeLibCompatInnerHtmlFix.domChanges(doc, helper); - helper = _glimmerRuntimeLibCompatSvgInnerHtmlFix.domChanges(doc, helper, SVG_NAMESPACE); - exports.default = helper; - var DOMTreeConstruction = DOM.DOMTreeConstruction; - exports.DOMTreeConstruction = DOMTreeConstruction; - exports.DOMNamespace = _glimmerRuntimeLibDomInterfaces.Namespace; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2hlbHBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFlTyxRQUFNLGFBQWEsR0FBRyw0QkFBNEIsQ0FBQzs7O0FBRzFELFFBQU0sc0JBQXNCLEdBQUcsRUFBRSxhQUFhLEVBQUUsQ0FBQyxFQUFFLElBQUksRUFBRSxDQUFDLEVBQUUsS0FBSyxFQUFFLENBQUMsRUFBRSxDQUFDOzs7Ozs7QUFTaEUsUUFBTSxlQUFlLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQzs7QUFFbkQsQUFBQyxLQUNDLEdBQUcsRUFBRSxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsUUFBUSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFDaEcsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxHQUFHLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxTQUFTLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxNQUFNLEV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cgQ29uY3JldGVCb3VuZHMocGFyZW50LCBmaXJzdCwgbGFzdCk7XG59XG5cbmZ1bmN0aW9uIGlzRG9jdW1lbnRGcmFnbWVudChub2RlOiBTaW1wbGUuTm9kZSk6IG5vZGUgaXMgRG9jdW1lbnRGcmFnbWVudCB7XG4gIHJldHVybiBub2RlLm5vZGVUeXBlID09PSBOb2RlLkRPQ1VNRU5UX0ZSQUdNRU5UX05PREU7XG59XG5cbmxldCBoZWxwZXIgPSBET01DaGFuZ2VzO1xuXG5oZWxwZXIgPSBkb21DaGFuZ2VzTm9kZU1lcmdpbmdGaXgoZG9jLCBoZWxwZXIpO1xuaGVscGVyID0gZG9tQ2hhbmdlc1RhYmxlRWxlbWVudEZpeChkb2MsIGhlbHBlcik7XG5oZWxwZXIgPSBkb21DaGFuZ2VzU3ZnRWxlbWVudEZpeChkb2MsIGhlbHBlciwgU1ZHX05BTUVTUEFDRSk7XG5cbmV4cG9ydCBkZWZhdWx0IGhlbHBlcjtcbmV4cG9ydCBjb25zdCBET01UcmVlQ29uc3RydWN0aW9uID0gRE9NLkRPTVRyZWVDb25zdHJ1Y3Rpb247XG5leHBvcnQgdHlwZSBET01UcmVlQ29uc3RydWN0aW9uID0gRE9NLkRPTVRyZWVDb25zdHJ1Y3Rpb247XG5leHBvcnQgeyBOYW1lc3BhY2UgYXMgRE9NTmFtZXNwYWNlIH0gZnJvbSAnLi9pbnRlcmZhY2VzJztcbiJdfQ== -enifed("glimmer-runtime/lib/dom/interfaces", ["exports"], function (exports) { - "use strict"; + exports.default = Test; +}); +enifed('ember-testing/test/adapter', ['exports', 'ember-console', 'ember-metal'], function (exports, _emberConsole, _emberMetal) { + 'use strict'; - var NodeType; - exports.NodeType = NodeType; - (function (NodeType) { - NodeType[NodeType["Element"] = 0] = "Element"; - NodeType[NodeType["Attribute"] = 1] = "Attribute"; - NodeType[NodeType["Text"] = 2] = "Text"; - NodeType[NodeType["CdataSection"] = 3] = "CdataSection"; - NodeType[NodeType["EntityReference"] = 4] = "EntityReference"; - NodeType[NodeType["Entity"] = 5] = "Entity"; - NodeType[NodeType["ProcessingInstruction"] = 6] = "ProcessingInstruction"; - NodeType[NodeType["Comment"] = 7] = "Comment"; - NodeType[NodeType["Document"] = 8] = "Document"; - NodeType[NodeType["DocumentType"] = 9] = "DocumentType"; - NodeType[NodeType["DocumentFragment"] = 10] = "DocumentFragment"; - NodeType[NodeType["Notation"] = 11] = "Notation"; - })(NodeType || (exports.NodeType = NodeType = {})); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBV0EsUUFBWSxRQWFYLENBQUE7O0FBYkQsS0FBQSxVQUFZLFFBQVEsRUFBQTtBQUNsQixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxTQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxTQUFPLENBQUE7QUFDUCxnQkFBQSxDQUFBLFFBQUEsQ0FBQSxXQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxXQUFTLENBQUE7QUFDVCxnQkFBQSxDQUFBLFFBQUEsQ0FBQSxNQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxNQUFJLENBQUE7QUFDSixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxjQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxjQUFZLENBQUE7QUFDWixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxpQkFBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsaUJBQWUsQ0FBQTtBQUNmLGdCQUFBLENBQUEsUUFBQSxDQUFBLFFBQUEsQ0FBQSxHQUFBLENBQUEsQ0FBQSxHQUFBLFFBQU0sQ0FBQTtBQUNOLGdCQUFBLENBQUEsUUFBQSxDQUFBLHVCQUFBLENBQUEsR0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IHt9XG4iXX0= -enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { - /* - * @method normalizeProperty - * @param element {HTMLElement} - * @param slotName {String} - * @returns {Object} { name, type } - */ - 'use strict'; + exports.getAdapter = getAdapter; + exports.setAdapter = setAdapter; + exports.asyncStart = asyncStart; + exports.asyncEnd = asyncEnd; - exports.normalizeProperty = normalizeProperty; - exports.normalizePropertyValue = normalizePropertyValue; + var adapter = undefined; - function normalizeProperty(element, slotName) { - var type = undefined, - normalized = undefined; - if (slotName in element) { - normalized = slotName; - type = 'prop'; - } else { - var lower = slotName.toLowerCase(); - if (lower in element) { - type = 'prop'; - normalized = lower; - } else { - type = 'attr'; - normalized = slotName; - } - } - if (type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName, normalized))) { - type = 'attr'; - } - return { normalized: normalized, type: type }; - } + function getAdapter() { + return adapter; + } - function normalizePropertyValue(value) { - if (value === '') { - return true; - } - return value; + function setAdapter(value) { + adapter = value; + if (value) { + _emberMetal.setDispatchOverride(adapterDispatch); + } else { + _emberMetal.setDispatchOverride(null); } + } - // properties that MUST be set as attributes, due to: - // * browser bug - // * strange spec outlier - var ATTR_OVERRIDES = { - // phantomjs < 2.0 lets you set it as a prop but won't reflect it - // back to the attribute. button.getAttribute('type') === null - BUTTON: { type: true, form: true }, - INPUT: { - // Some version of IE (like IE9) actually throw an exception - // if you set input.type = 'something-unknown' - type: true, - form: true, - // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false - // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false - // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true - }, - // element.form is actually a legitimate readOnly property, that is to be - // mutated, but must be mutated by setAttribute... - SELECT: { form: true }, - OPTION: { form: true }, - TEXTAREA: { form: true }, - LABEL: { form: true }, - FIELDSET: { form: true }, - LEGEND: { form: true }, - OBJECT: { form: true } - }; - function preferAttr(tagName, propName) { - var tag = ATTR_OVERRIDES[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ydHksIHRoYXQgaXMgdG8gYmVcbiAgLy8gbXV0YXRlZCwgYnV0IG11c3QgYmUgbXV0YXRlZCBieSBzZXRBdHRyaWJ1dGUuLi5cbiAgU0VMRUNUOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPUFRJT046ICAgeyBmb3JtOiB0cnVlIH0sXG4gIFRFWFRBUkVBOiB7IGZvcm06IHRydWUgfSxcbiAgTEFCRUw6ICAgIHsgZm9ybTogdHJ1ZSB9LFxuICBGSUVMRFNFVDogeyBmb3JtOiB0cnVlIH0sXG4gIExFR0VORDogICB7IGZvcm06IHRydWUgfSxcbiAgT0JKRUNUOiAgIHsgZm9ybTogdHJ1ZSB9XG59O1xuXG5mdW5jdGlvbiBwcmVmZXJBdHRyKHRhZ05hbWUsIHByb3BOYW1lKSB7XG4gIGxldCB0YWcgPSBBVFRSX09WRVJSSURFU1t0YWdOYW1lLnRvVXBwZXJDYXNlKCldO1xuICByZXR1cm4gdGFnICYmIHRhZ1twcm9wTmFtZS50b0xvd2VyQ2FzZSgpXSB8fCBmYWxzZTtcbn1cbiJdfQ== -enifed('glimmer-runtime/lib/dom/sanitized-values', ['exports', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/upsert'], function (exports, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibUpsert) { - 'use strict'; - - exports.requiresSanitization = requiresSanitization; - exports.sanitizeAttributeValue = sanitizeAttributeValue; - - var badProtocols = ['javascript:', 'vbscript:']; - var badTags = ['A', 'BODY', 'LINK', 'IMG', 'IFRAME', 'BASE', 'FORM']; - var badTagsForDataURI = ['EMBED']; - var badAttributes = ['href', 'src', 'background', 'action']; - var badAttributesForDataURI = ['src']; - function has(array, item) { - return array.indexOf(item) !== -1; - } - function checkURI(tagName, attribute) { - return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute); - } - function checkDataURI(tagName, attribute) { - return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute); + function asyncStart() { + if (adapter) { + adapter.asyncStart(); } + } - function requiresSanitization(tagName, attribute) { - return checkURI(tagName, attribute) || checkDataURI(tagName, attribute); + function asyncEnd() { + if (adapter) { + adapter.asyncEnd(); } + } - function sanitizeAttributeValue(env, element, attribute, value) { - var tagName = undefined; - if (value === null || value === undefined) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value)) { - return value.toHTML(); - } - if (!element) { - tagName = null; - } else { - tagName = element.tagName.toUpperCase(); - } - var str = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - if (checkURI(tagName, attribute)) { - var protocol = env.protocolForURL(str); - if (has(badProtocols, protocol)) { - return 'unsafe:' + str; - } - } - if (checkDataURI(tagName, attribute)) { - return 'unsafe:' + str; - } - return str; - } + function adapterDispatch(error) { + adapter.exception(error); + _emberConsole.default.error(error.stack); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Nhbml0aXplZC12YWx1ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBTUEsUUFBTSxZQUFZLEdBQUcsQ0FDbkIsYUFBYSxFQUNiLFdBQVcsQ0FDWixDQUFDO0FBRUYsUUFBTSxPQUFPLEdBQUcsQ0FDZCxHQUFHLEVBQ0gsTUFBTSxFQUNOLE1BQU0sRUFDTixLQUFLLEVBQ0wsUUFBUSxFQUNSLE1BQU0sRUFDTixNQUFNLENBQ1AsQ0FBQztBQUVGLFFBQU0saUJBQWlCLEdBQUcsQ0FDeEIsT0FBTyxDQUNSLENBQUM7QUFFRixRQUFNLGFBQWEsR0FBRyxDQUNwQixNQUFNLEVBQ04sS0FBSyxFQUNMLFlBQVksRUFDWixRQUFRLENBQ1QsQ0FBQztBQUVGLFFBQU0sdUJBQXVCLEdBQUcsQ0FDOUIsS0FBSyxDQUNOLENBQUM7QUFFRixhQUFBLEdBQUEsQ0FBYSxLQUFvQixF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immer-runtime/lib/dom/attribute-managers', 'glimmer-util', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/syntax/builtins/if', 'glimmer-runtime/lib/syntax/builtins/unless', 'glimmer-runtime/lib/syntax/builtins/with', 'glimmer-runtime/lib/syntax/builtins/each'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibDomAttributeManagers, _glimmerUtil, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibSyntaxBuiltinsIf, _glimmerRuntimeLibSyntaxBuiltinsUnless, _glimmerRuntimeLibSyntaxBuiltinsWith, _glimmerRuntimeLibSyntaxBuiltinsEach) { - 'use strict'; - - var Scope = (function () { - function Scope(references) { - var callerScope = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; +enifed('ember-testing/test/helpers', ['exports', 'ember-testing/test/promise'], function (exports, _emberTestingTestPromise) { + 'use strict'; - this.callerScope = null; - this.slots = references; - this.callerScope = callerScope; - } + exports.registerHelper = registerHelper; + exports.registerAsyncHelper = registerAsyncHelper; + exports.unregisterHelper = unregisterHelper; + var helpers = {}; - Scope.root = function root(self) { - var size = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; + exports.helpers = helpers; + /** + `registerHelper` is used to register a test helper that will be injected + when `App.injectTestHelpers` is called. + + The helper method will always be called with the current Application as + the first parameter. + + For example: + + ```javascript + Ember.Test.registerHelper('boot', function(app) { + Ember.run(app, app.advanceReadiness); + }); + ``` + + This helper can later be called without arguments because it will be + called with `app` as the first parameter. + + ```javascript + App = Ember.Application.create(); + App.injectTestHelpers(); + boot(); + ``` + + @public + @for Ember.Test + @method registerHelper + @param {String} name The name of the helper method to add. + @param {Function} helperMethod + @param options {Object} + */ - var refs = new Array(size + 1); - for (var i = 0; i <= size; i++) { - refs[i] = _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - } - return new Scope(refs).init({ self: self }); - }; + function registerHelper(name, helperMethod) { + helpers[name] = { + method: helperMethod, + meta: { wait: false } + }; + } - Scope.prototype.init = function init(_ref) { - var self = _ref.self; + /** + `registerAsyncHelper` is used to register an async test helper that will be injected + when `App.injectTestHelpers` is called. + + The helper method will always be called with the current Application as + the first parameter. + + For example: + + ```javascript + Ember.Test.registerAsyncHelper('boot', function(app) { + Ember.run(app, app.advanceReadiness); + }); + ``` + + The advantage of an async helper is that it will not run + until the last async helper has completed. All async helpers + after it will wait for it complete before running. + + + For example: + + ```javascript + Ember.Test.registerAsyncHelper('deletePost', function(app, postId) { + click('.delete-' + postId); + }); + + // ... in your test + visit('/post/2'); + deletePost(2); + visit('/post/3'); + deletePost(3); + ``` + + @public + @for Ember.Test + @method registerAsyncHelper + @param {String} name The name of the helper method to add. + @param {Function} helperMethod + @since 1.2.0 + */ - this.slots[0] = self; - return this; - }; + function registerAsyncHelper(name, helperMethod) { + helpers[name] = { + method: helperMethod, + meta: { wait: true } + }; + } - Scope.prototype.getSelf = function getSelf() { - return this.slots[0]; - }; + /** + Remove a previously added helper method. + + Example: + + ```javascript + Ember.Test.unregisterHelper('wait'); + ``` + + @public + @method unregisterHelper + @param {String} name The helper to remove. + */ - Scope.prototype.getSymbol = function getSymbol(symbol) { - return this.slots[symbol]; - }; + function unregisterHelper(name) { + delete helpers[name]; + delete _emberTestingTestPromise.default.prototype[name]; + } +}); +enifed("ember-testing/test/on_inject_helpers", ["exports"], function (exports) { + "use strict"; - Scope.prototype.getBlock = function getBlock(symbol) { - return this.slots[symbol]; - }; + exports.onInjectHelpers = onInjectHelpers; + exports.invokeInjectHelpersCallbacks = invokeInjectHelpersCallbacks; + var callbacks = []; - Scope.prototype.getPartialArgs = function getPartialArgs(symbol) { - return this.slots[symbol]; - }; + exports.callbacks = callbacks; + /** + Used to register callbacks to be fired whenever `App.injectTestHelpers` + is called. + + The callback will receive the current application as an argument. + + Example: + + ```javascript + Ember.Test.onInjectHelpers(function() { + Ember.$(document).ajaxSend(function() { + Test.pendingRequests++; + }); + + Ember.$(document).ajaxComplete(function() { + Test.pendingRequests--; + }); + }); + ``` + + @public + @for Ember.Test + @method onInjectHelpers + @param {Function} callback The function to be called. + */ - Scope.prototype.bindSymbol = function bindSymbol(symbol, value) { - this.slots[symbol] = value; - }; + function onInjectHelpers(callback) { + callbacks.push(callback); + } - Scope.prototype.bindBlock = function bindBlock(symbol, value) { - this.slots[symbol] = value; - }; + function invokeInjectHelpersCallbacks(app) { + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](app); + } + } +}); +enifed("ember-testing/test/pending_requests", ["exports"], function (exports) { + "use strict"; - Scope.prototype.bindPartialArgs = function bindPartialArgs(symbol, value) { - this.slots[symbol] = value; - }; + exports.pendingRequests = pendingRequests; + exports.clearPendingRequests = clearPendingRequests; + exports.incrementPendingRequests = incrementPendingRequests; + exports.decrementPendingRequests = decrementPendingRequests; + var requests = []; - Scope.prototype.bindCallerScope = function bindCallerScope(scope) { - this.callerScope = scope; - }; + function pendingRequests() { + return requests.length; + } - Scope.prototype.getCallerScope = function getCallerScope() { - return this.callerScope; - }; + function clearPendingRequests() { + requests.length = 0; + } - Scope.prototype.child = function child() { - return new Scope(this.slots.slice(), this.callerScope); - }; + function incrementPendingRequests(_, xhr) { + requests.push(xhr); + } - return Scope; - })(); + function decrementPendingRequests(_, xhr) { + for (var i = 0; i < requests.length; i++) { + if (xhr === requests[i]) { + requests.splice(i, 1); + break; + } + } + } +}); +enifed('ember-testing/test/promise', ['exports', 'ember-runtime', 'ember-testing/test/run'], function (exports, _emberRuntime, _emberTestingTestRun) { + 'use strict'; - exports.Scope = Scope; + exports.promise = promise; + exports.resolve = resolve; + exports.getLastPromise = getLastPromise; - var Environment = (function () { - function Environment(_ref2) { - var appendOperations = _ref2.appendOperations; - var updateOperations = _ref2.updateOperations; + var lastPromise = undefined; - this.scheduledInstallManagers = null; - this.scheduledInstallModifiers = null; - this.scheduledUpdateModifierManagers = null; - this.scheduledUpdateModifiers = null; - this.createdComponents = null; - this.createdManagers = null; - this.updatedComponents = null; - this.updatedManagers = null; - this.destructors = null; - this.appendOperations = appendOperations; - this.updateOperations = updateOperations; - } + var TestPromise = (function (_RSVP$Promise) { + babelHelpers.inherits(TestPromise, _RSVP$Promise); - Environment.prototype.toConditionalReference = function toConditionalReference(reference) { - return new _glimmerRuntimeLibReferences.ConditionalReference(reference); - }; + function TestPromise() { + babelHelpers.classCallCheck(this, TestPromise); - Environment.prototype.getAppendOperations = function getAppendOperations() { - return this.appendOperations; - }; + _RSVP$Promise.apply(this, arguments); + lastPromise = this; + } - Environment.prototype.getDOM = function getDOM() { - return this.updateOperations; - }; + /** + This returns a thenable tailored for testing. It catches failed + `onSuccess` callbacks and invokes the `Ember.Test.adapter.exception` + callback in the last chained then. + + This method should be returned by async helpers such as `wait`. + + @public + @for Ember.Test + @method promise + @param {Function} resolver The function used to resolve the promise. + @param {String} label An optional string for identifying the promise. + */ - Environment.prototype.getIdentity = function getIdentity(object) { - return _glimmerUtil.ensureGuid(object) + ''; - }; + TestPromise.prototype.then = function then(onFulfillment) { + var _RSVP$Promise$prototype$then; - Environment.prototype.statement = function statement(_statement, symbolTable) { - return this.refineStatement(parseStatement(_statement), symbolTable) || _statement; - }; + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - Environment.prototype.refineStatement = function refineStatement(statement, symbolTable) { - var isSimple = statement.isSimple; - var isBlock = statement.isBlock; - var key = statement.key; - var args = statement.args; - - if (isSimple && isBlock) { - switch (key) { - case 'each': - return new _glimmerRuntimeLibSyntaxBuiltinsEach.default(args); - case 'if': - return new _glimmerRuntimeLibSyntaxBuiltinsIf.default(args); - case 'with': - return new _glimmerRuntimeLibSyntaxBuiltinsWith.default(args); - case 'unless': - return new _glimmerRuntimeLibSyntaxBuiltinsUnless.default(args); - } - } - }; + return (_RSVP$Promise$prototype$then = _RSVP$Promise.prototype.then).call.apply(_RSVP$Promise$prototype$then, [this, function (result) { + return isolate(onFulfillment, result); + }].concat(args)); + }; - Environment.prototype.begin = function begin() { - this.createdComponents = []; - this.createdManagers = []; - this.updatedComponents = []; - this.updatedManagers = []; - this.destructors = []; - this.scheduledInstallManagers = []; - this.scheduledInstallModifiers = []; - this.scheduledUpdateModifierManagers = []; - this.scheduledUpdateModifiers = []; - }; + return TestPromise; + })(_emberRuntime.RSVP.Promise); - Environment.prototype.didCreate = function didCreate(component, manager) { - this.createdComponents.push(component); - this.createdManagers.push(manager); - }; + exports.default = TestPromise; - Environment.prototype.didUpdate = function didUpdate(component, manager) { - this.updatedComponents.push(component); - this.updatedManagers.push(manager); - }; + function promise(resolver, label) { + var fullLabel = 'Ember.Test.promise: ' + (label || ''); + return new TestPromise(resolver, fullLabel); + } - Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier, manager) { - this.scheduledInstallManagers.push(manager); - this.scheduledInstallModifiers.push(modifier); - }; + /** + Replacement for `Ember.RSVP.resolve` + The only difference is this uses + an instance of `Ember.Test.Promise` + + @public + @for Ember.Test + @method resolve + @param {Mixed} The value to resolve + @since 1.2.0 + */ - Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier, manager) { - this.scheduledUpdateModifierManagers.push(manager); - this.scheduledUpdateModifiers.push(modifier); - }; + function resolve(result, label) { + return TestPromise.resolve(result, label); + } - Environment.prototype.didDestroy = function didDestroy(d) { - this.destructors.push(d); - }; + function getLastPromise() { + return lastPromise; + } - Environment.prototype.commit = function commit() { - for (var i = 0; i < this.createdComponents.length; i++) { - var component = this.createdComponents[i]; - var manager = this.createdManagers[i]; - manager.didCreate(component); - } - for (var i = 0; i < this.updatedComponents.length; i++) { - var component = this.updatedComponents[i]; - var manager = this.updatedManagers[i]; - manager.didUpdate(component); - } - for (var i = 0; i < this.destructors.length; i++) { - this.destructors[i].destroy(); - } - for (var i = 0; i < this.scheduledInstallManagers.length; i++) { - var manager = this.scheduledInstallManagers[i]; - var modifier = this.scheduledInstallModifiers[i]; - manager.install(modifier); - } - for (var i = 0; i < this.scheduledUpdateModifierManagers.length; i++) { - var manager = this.scheduledUpdateModifierManagers[i]; - var modifier = this.scheduledUpdateModifiers[i]; - manager.update(modifier); - } - this.createdComponents = null; - this.createdManagers = null; - this.updatedComponents = null; - this.updatedManagers = null; - this.destructors = null; - this.scheduledInstallManagers = null; - this.scheduledInstallModifiers = null; - this.scheduledUpdateModifierManagers = null; - this.scheduledUpdateModifiers = null; - }; + // This method isolates nested async methods + // so that they don't conflict with other last promises. + // + // 1. Set `Ember.Test.lastPromise` to null + // 2. Invoke method + // 3. Return the last promise created during method + function isolate(onFulfillment, result) { + // Reset lastPromise for nested helpers + lastPromise = null; - Environment.prototype.attributeFor = function attributeFor(element, attr, isTrusting, namespace) { - return _glimmerRuntimeLibDomAttributeManagers.defaultManagers(element, attr, isTrusting, namespace); - }; + var value = onFulfillment(result); - return Environment; - })(); + var promise = lastPromise; + lastPromise = null; - exports.Environment = Environment; - exports.default = Environment; - - function parseStatement(statement) { - var type = statement.type; - var block = type === 'block' ? statement : null; - var append = type === 'optimized-append' ? statement : null; - var modifier = type === 'modifier' ? statement : null; - var appendType = append && append.value.type; - var args = undefined; - var path = undefined; - if (block) { - args = block.args; - path = block.path; - } else if (append && (appendType === 'unknown' || appendType === 'get')) { - var appendValue = append.value; - args = _glimmerRuntimeLibSyntaxCore.Args.empty(); - path = appendValue.ref.parts; - } else if (append && append.value.type === 'helper') { - var helper = append.value; - args = helper.args; - path = helper.ref.parts; - } else if (modifier) { - path = modifier.path; - args = modifier.args; - } - var key = undefined, - isSimple = undefined; - if (path) { - isSimple = path.length === 1; - key = path[0]; - } - return { - isSimple: isSimple, - path: path, - key: key, - args: args, - appendType: appendType, - original: statement, - isInline: !!append, - isBlock: !!block, - isModifier: !!modifier - }; + // If the method returned a promise + // return that promise. If not, + // return the last async helper's promise + if (value && value instanceof TestPromise || !promise) { + return value; + } else { + return _emberTestingTestRun.default(function () { + return resolve(promise).then(function () { + return value; + }); + }); } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJ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ydHM7XG4gICAgfSBlbHNlIGlmIChtb2RpZmllcikge1xuICAgICAgcGF0aCA9IG1vZGlmaWVyLnBhdGg7XG4gICAgICBhcmdzID0gbW9kaWZpZXIuYXJncztcbiAgICB9XG5cbiAgICBsZXQga2V5OiBzdHJpbmcsIGlzU2ltcGxlOiBib29sZWFuO1xuXG4gICAgaWYgKHBhdGgpIHtcbiAgICAgIGlzU2ltcGxlID0gcGF0aC5sZW5ndGggPT09IDE7XG4gICAgICBrZXkgPSBwYXRoWzBdO1xuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICBpc1NpbXBsZSxcbiAgICAgIHBhdGgsXG4gICAgICBrZXksXG4gICAgICBhcmdzLFxuICAgICAgYXBwZW5kVHlwZSxcbiAgICAgIG9yaWdpbmFsOiBzdGF0ZW1lbnQsXG4gICAgICBpc0lubGluZTogISFhcHBlbmQsXG4gICAgICBpc0Jsb2NrOiAhIWJsb2NrLFxuICAgICAgaXNNb2RpZmllcjogISFtb2RpZmllclxuICAgIH07XG59XG4iXX0= -enifed('glimmer-runtime/lib/helpers/get-dynamic-var', ['exports', 'glimmer-reference'], function (exports, _glimmerReference) { - 'use strict'; - - var DynamicVarReference = (function () { - function DynamicVarReference(scope, nameRef) { - this.scope = scope; - this.nameRef = nameRef; - var varTag = this.varTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([nameRef.tag, varTag]); - } - - DynamicVarReference.prototype.value = function value() { - return this.getVar().value(); - }; - - DynamicVarReference.prototype.get = function get(key) { - return this.getVar().get(key); - }; - - DynamicVarReference.prototype.getVar = function getVar() { - var name = String(this.nameRef.value()); - var ref = this.scope.get(name); - this.varTag.update(ref.tag); - return ref; - }; +enifed('ember-testing/test/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - return DynamicVarReference; - })(); + exports.default = run; - function getDynamicVar(vm, args, symbolTable) { - var scope = vm.dynamicScope(); - var nameRef = args.positional.at(0); - return new DynamicVarReference(scope, nameRef); + function run(fn) { + if (!_emberMetal.run.currentRunLoop) { + return _emberMetal.run(fn); + } else { + return fn(); } - exports.default = getDynamicVar; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvaGVscGVycy9nZXQtZHluYW1pYy12YXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBT0EsbUJBQUE7QUFJRSxpQkFKRixtQkFBQSxDQUlzQixLQUFtQixFQUFVLE9BQThCLEVBQUE7QUFBM0QsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUFjO0FBQVUsZ0JBQUEsQ0FBQSxPQUFPLEdBQVAsT0FBTyxDQUF1QjtBQUM3RSxnQkFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLE1BQU0sR0FBRyxzQkFSb0IsWUFBWSxtQkFBdEQsWUFBWSxDQVF3QyxDQUFDO0FBQzFELGdCQUFJLENBQUMsR0FBRyxHQUFHLGtCQVRrRCxPQUFPLENBU2pELENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDO1NBQzNDOztBQVBILDJCQUFBLFdBU0UsS0FBSyxHQUFBLGlCQUFBO0FBQ0gsbUJBQU8sSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDO1NBQzlCOztBQVhILDJCQUFBLFdBYUUsR0FBRyxHQUFBLGFBQUMsR0FBVyxFQUFBO0FBQ2IsbUJBQU8sSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztTQUMvQjs7QUFmSCwyQkFBQSxXQWlCVSxNQUFNLEdBQUEsa0JBQUE7QUFDWixnQkFBSSxJQUFJLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FB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b3BlID0gdm0uZHluYW1pY1Njb3BlKCk7XG4gIGxldCBuYW1lUmVmID0gYXJncy5wb3NpdGlvbmFsLmF0KDApO1xuXG4gIHJldHVybiBuZXcgRHluYW1pY1ZhclJlZmVyZW5jZShzY29wZSwgbmFtZVJlZik7XG59XG5cbmV4cG9ydCBkZWZhdWx0IChnZXREeW5hbWljVmFyIGFzIEhlbHBlcik7XG4iXX0= -enifed("glimmer-runtime/lib/modifier/interfaces", ["exports"], function (exports) { - "use strict"; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvbW9kaWZpZXIvaW50ZXJmYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwiZmlsZSI6ImludGVyZmFjZXMuanMiLCJzb3VyY2VzQ29udGVudCI6W119 -enifed("glimmer-runtime/lib/opcode-builder", ["exports"], function (exports) { - "use strict"; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvb3Bjb2RlLWJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJvcGNvZGUtYnVpbGRlci5qcyIsInNvdXJjZXNDb250ZW50IjpbXX0= -enifed('glimmer-runtime/lib/opcodes', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; - - exports.inspect = inspect; - - var AbstractOpcode = (function () { - function AbstractOpcode() { - _glimmerUtil.initializeGuid(this); - } +enifed('ember-testing/test/waiters', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - AbstractOpcode.prototype.toJSON = function toJSON() { - return { guid: this._guid, type: this.type }; - }; + exports.registerWaiter = registerWaiter; + exports.unregisterWaiter = unregisterWaiter; + exports.checkWaiters = checkWaiters; + exports.generateDeprecatedWaitersArray = generateDeprecatedWaitersArray; - return AbstractOpcode; - })(); + var contexts = []; + var callbacks = []; - exports.AbstractOpcode = AbstractOpcode; + /** + This allows ember-testing to play nicely with other asynchronous + events, such as an application that is waiting for a CSS3 + transition or an IndexDB transaction. The waiter runs periodically + after each async helper (i.e. `click`, `andThen`, `visit`, etc) has executed, + until the returning result is truthy. After the waiters finish, the next async helper + is executed and the process repeats. + + For example: + + ```javascript + Ember.Test.registerWaiter(function() { + return myPendingTransactions() == 0; + }); + ``` + The `context` argument allows you to optionally specify the `this` + with which your callback will be invoked. + + For example: + + ```javascript + Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions); + ``` + + @public + @for Ember.Test + @method registerWaiter + @param {Object} context (optional) + @param {Function} callback + @since 1.2.0 + */ - var Opcode = (function (_AbstractOpcode) { - babelHelpers.inherits(Opcode, _AbstractOpcode); + function registerWaiter(context, callback) { + if (arguments.length === 1) { + callback = context; + context = null; + } + if (indexOf(context, callback) > -1) { + return; + } + contexts.push(context); + callbacks.push(callback); + } - function Opcode() { - _AbstractOpcode.apply(this, arguments); - this.next = null; - this.prev = null; - } + /** + `unregisterWaiter` is used to unregister a callback that was + registered with `registerWaiter`. + + @public + @for Ember.Test + @method unregisterWaiter + @param {Object} context (optional) + @param {Function} callback + @since 1.2.0 + */ - return Opcode; - })(AbstractOpcode); + function unregisterWaiter(context, callback) { + if (!callbacks.length) { + return; + } + if (arguments.length === 1) { + callback = context; + context = null; + } + var i = indexOf(context, callback); + if (i === -1) { + return; + } + contexts.splice(i, 1); + callbacks.splice(i, 1); + } - exports.Opcode = Opcode; + /** + Iterates through each registered test waiter, and invokes + its callback. If any waiter returns false, this method will return + true indicating that the waiters have not settled yet. + + This is generally used internally from the acceptance/integration test + infrastructure. + + @public + @for Ember.Test + @static + @method checkWaiters + */ - var UpdatingOpcode = (function (_AbstractOpcode2) { - babelHelpers.inherits(UpdatingOpcode, _AbstractOpcode2); + function checkWaiters() { + if (!callbacks.length) { + return false; + } + for (var i = 0; i < callbacks.length; i++) { + var context = contexts[i]; + var callback = callbacks[i]; + if (!callback.call(context)) { + return true; + } + } + return false; + } - function UpdatingOpcode() { - _AbstractOpcode2.apply(this, arguments); - this.next = null; - this.prev = null; - } + function indexOf(context, callback) { + for (var i = 0; i < callbacks.length; i++) { + if (callbacks[i] === callback && contexts[i] === context) { + return i; + } + } + return -1; + } - return UpdatingOpcode; - })(AbstractOpcode); + function generateDeprecatedWaitersArray() { + _emberMetal.deprecate('Usage of `Ember.Test.waiters` is deprecated. Please refactor to `Ember.Test.checkWaiters`.', false, { until: '2.8.0', id: 'ember-testing.test-waiters' }); - exports.UpdatingOpcode = UpdatingOpcode; + var array = new Array(callbacks.length); + for (var i = 0; i < callbacks.length; i++) { + var context = contexts[i]; + var callback = callbacks[i]; - function inspect(opcodes) { - var buffer = []; - opcodes.toArray().forEach(function (opcode, i) { - _inspect(opcode.toJSON(), buffer, 0, i); - }); - return buffer.join(''); + array[i] = [context, callback]; } - function _inspect(opcode, buffer, level, index) { - var indentation = []; - for (var i = 0; i < level; i++) { - indentation.push(' '); - } - buffer.push.apply(buffer, indentation); - buffer.push(index + 1 + '. ' + opcode.type.toUpperCase()); - if (opcode.args || opcode.details) { - buffer.push('('); - if (opcode.args) { - buffer.push(opcode.args.join(', ')); - } - if (opcode.details) { - var keys = Object.keys(opcode.details); - if (keys.length) { - if (opcode.args && opcode.args.length) { - buffer.push(', '); - } - buffer.push(keys.map(function (key) { - return key + '=' + opcode.details[key]; - }).join(', ')); - } - } - buffer.push(')'); - } - buffer.push('\n'); - if (opcode.children && opcode.children.length) { - for (var i = 0; i < opcode.children.length; i++) { - _inspect(opcode.children[i], buffer, level + 1, i); - } - } - } + return array; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvb3Bjb2Rlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztRQWFBLGNBQUE7QUFPRSxpQkFQRixjQUFBLEdBT0U7QUFDR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B7XG4gICAgICBidWZmZXIucHVzaChvcGNvZGUuYXJncy5qb2luKCcsICcpKTtcbiAgICB9XG5cbiAgICBpZiAob3Bjb2RlLmRldGFpbHMpIHtcbiAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob3Bjb2RlLmRldGFpbHMpO1xuXG4gICAgICBpZiAoa2V5cy5sZW5ndGgpIHtcbiAgICAgICAgaWYgKG9wY29kZS5hcmdzICYmIG9wY29kZS5hcmdzLmxlbmd0aCkge1xuICAgICAgICAgIGJ1ZmZlci5wdXNoKCcsICcpO1xuICAgICAgICB9XG5cbiAgICAgICAgYnVmZmVyLnB1c2goa2V5cy5tYXAoa2V5ID0+IGAke2tleX09JHtvcGNvZGUuZGV0YWlsc1trZXldfWApLmpvaW4oJywgJykpO1xuICAgICAgfVxuICAgIH1cblxuICAgIGJ1ZmZlci5wdXNoKCcpJyk7XG4gIH1cblxuICBidWZmZXIucHVzaCgnXFxuJyk7XG5cbiAgaWYgKG9wY29kZS5jaGlsZHJlbiAmJiBvcGNvZGUuY2hpbGRyZW4ubGVuZ3RoKSB7XG4gICAgZm9yIChsZXQgaT0wOyBpPG9wY29kZS5jaGlsZHJlbi5sZW5ndGg7IGkrKykge1xuICAgICAgX2luc3BlY3Qob3Bjb2RlLmNoaWxkcmVuW2ldLCBidWZmZXIsIGxldmVsKzEsIGkpO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed("glimmer-runtime/lib/partial", ["exports"], function (exports) { - "use strict"; +enifed("ember-utils/apply-str", ["exports"], function (exports) { + /** + @param {Object} t target + @param {String} m method + @param {Array} a args + @private + */ + "use strict"; - var PartialDefinition = function PartialDefinition(name, template) { - this.name = name; - this.template = template; - }; + exports.default = applyStr; - exports.PartialDefinition = PartialDefinition; + function applyStr(t, m, a) { + var l = a && a.length; + if (!a || !l) { + return t[m](); + } + switch (l) { + case 1: + return t[m](a[0]); + case 2: + return t[m](a[0], a[1]); + case 3: + return t[m](a[0], a[1], a[2]); + case 4: + return t[m](a[0], a[1], a[2], a[3]); + case 5: + return t[m](a[0], a[1], a[2], a[3], a[4]); + default: + return t[m].apply(t, a); + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvcGFydGlhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFFQSxpQkFBQSxHQUlFLFNBSkYsaUJBQUEsQ0FJYyxJQUFZLEVBQUUsUUFBcUIsRUFBQTtBQUM3QyxZQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztBQUNqQixZQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztLQUMxQiIsImZpbGUiOiJwYXJ0aWFsLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgVGVtcGxhdGUgfSBmcm9tICcuL3RlbXBsYXRlJztcblxuZXhwb3J0IGNsYXNzIFBhcnRpYWxEZWZpbml0aW9uPFQ+IHtcbiAgbmFtZTogc3RyaW5nOyAvLyBmb3IgZGVidWdnaW5nXG4gIHRlbXBsYXRlOiBUZW1wbGF0ZTxUPjtcblxuICBjb25zdHJ1Y3RvcihuYW1lOiBzdHJpbmcsIHRlbXBsYXRlOiBUZW1wbGF0ZTxUPikge1xuICAgIHRoaXMubmFtZSA9IG5hbWU7XG4gICAgdGhpcy50ZW1wbGF0ZSA9IHRlbXBsYXRlO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/references', ['exports', 'glimmer-reference'], function (exports, _glimmerReference) { - 'use strict'; - - var PrimitiveReference = (function (_ConstReference) { - babelHelpers.inherits(PrimitiveReference, _ConstReference); - - function PrimitiveReference(value) { - _ConstReference.call(this, value); - } - - PrimitiveReference.create = function create(value) { - if (value === undefined) { - return UNDEFINED_REFERENCE; - } else if (value === null) { - return NULL_REFERENCE; - } else if (value === true) { - return TRUE_REFERENCE; - } else if (value === false) { - return FALSE_REFERENCE; - } else if (typeof value === 'number') { - return new ValueReference(value); - } else { - return new StringReference(value); - } - }; - - PrimitiveReference.prototype.get = function get(key) { - return UNDEFINED_REFERENCE; - }; - - return PrimitiveReference; - })(_glimmerReference.ConstReference); - - exports.PrimitiveReference = PrimitiveReference; - - var StringReference = (function (_PrimitiveReference) { - babelHelpers.inherits(StringReference, _PrimitiveReference); +enifed("ember-utils/assign", ["exports"], function (exports) { + /** + Copy properties from a source object to a target object. + + ```javascript + var a = { first: 'Yehuda' }; + var b = { last: 'Katz' }; + var c = { company: 'Tilde Inc.' }; + Ember.assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' } + ``` + + @method assign + @for Ember + @param {Object} original The object to assign into + @param {Object} ...args The objects to copy properties from + @return {Object} + @public + */ + "use strict"; - function StringReference() { - _PrimitiveReference.apply(this, arguments); - this.lengthReference = null; - } + exports.default = assign; - StringReference.prototype.get = function get(key) { - if (key === 'length') { - var lengthReference = this.lengthReference; + function assign(original) { + for (var i = 1; i < arguments.length; i++) { + var arg = arguments[i]; + if (!arg) { + continue; + } - if (lengthReference === null) { - lengthReference = this.lengthReference = new ValueReference(this.inner.length); - } - return lengthReference; - } else { - return _PrimitiveReference.prototype.get.call(this, key); - } - }; + var updates = Object.keys(arg); - return StringReference; - })(PrimitiveReference); + for (var _i = 0; _i < updates.length; _i++) { + var prop = updates[_i]; + original[prop] = arg[prop]; + } + } - var ValueReference = (function (_PrimitiveReference2) { - babelHelpers.inherits(ValueReference, _PrimitiveReference2); + return original; + } +}); +enifed('ember-utils/dictionary', ['exports', 'ember-utils/empty-object'], function (exports, _emberUtilsEmptyObject) { + 'use strict'; - function ValueReference(value) { - _PrimitiveReference2.call(this, value); - } + exports.default = makeDictionary; - return ValueReference; - })(PrimitiveReference); + // the delete is meant to hint at runtimes that this object should remain in + // dictionary mode. This is clearly a runtime specific hack, but currently it + // appears worthwhile in some usecases. Please note, these deletes do increase + // the cost of creation dramatically over a plain Object.create. And as this + // only makes sense for long-lived dictionaries that aren't instantiated often. - var UNDEFINED_REFERENCE = new ValueReference(undefined); - exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE; - var NULL_REFERENCE = new ValueReference(null); - exports.NULL_REFERENCE = NULL_REFERENCE; - var TRUE_REFERENCE = new ValueReference(true); - var FALSE_REFERENCE = new ValueReference(false); + function makeDictionary(parent) { + var dict = undefined; + if (parent === null) { + dict = new _emberUtilsEmptyObject.default(); + } else { + dict = Object.create(parent); + } + dict['_dict'] = null; + delete dict['_dict']; + return dict; + } +}); +enifed("ember-utils/empty-object", ["exports"], function (exports) { + // This exists because `Object.create(null)` is absurdly slow compared + // to `new EmptyObject()`. In either case, you want a null prototype + // when you're treating the object instances as arbitrary dictionaries + // and don't want your keys colliding with build-in methods on the + // default object prototype. - var ConditionalReference = (function () { - function ConditionalReference(inner) { - this.inner = inner; - this.tag = inner.tag; - } + "use strict"; - ConditionalReference.prototype.value = function value() { - return this.toBool(this.inner.value()); - }; + var proto = Object.create(null, { + // without this, we will always still end up with (new + // EmptyObject()).constructor === Object + constructor: { + value: undefined, + enumerable: false, + writable: true + } + }); - ConditionalReference.prototype.toBool = function toBool(value) { - return !!value; - }; + function EmptyObject() {} + EmptyObject.prototype = proto; + exports.default = EmptyObject; +}); +enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, _emberUtilsIntern) { + 'use strict'; - return ConditionalReference; - })(); + exports.uuid = uuid; + exports.generateGuid = generateGuid; + exports.guidFor = guidFor; - exports.ConditionalReference = ConditionalReference; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvcmVmZXJlbmNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFLQSxrQkFBQTs4QkFBQSxrQkFBQTs7QUFzQkUsaUJBdEJGLGtCQUFBLENBc0J3QixLQUFRLEVBQUE7QUFDNUIs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ID0gbmV3IFZhbHVlUmVmZXJlbmNlKGZhbHNlKTtcblxuZXhwb3J0IGNsYXNzIENvbmRpdGlvbmFsUmVmZXJlbmNlIGltcGxlbWVudHMgUmVmZXJlbmNlPGJvb2xlYW4+IHtcbiAgcHVibGljIHRhZzogUmV2aXNpb25UYWc7XG5cbiAgY29uc3RydWN0b3IocHJpdmF0ZSBpbm5lcjogUmVmZXJlbmNlPE9wYXF1ZT4pIHtcbiAgICB0aGlzLnRhZyA9IGlubmVyLnRhZztcbiAgfVxuXG4gIHZhbHVlKCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLnRvQm9vbCh0aGlzLmlubmVyLnZhbHVlKCkpO1xuICB9XG5cbiAgcHJvdGVjdGVkIHRvQm9vbCh2YWx1ZTogT3BhcXVlKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuICEhdmFsdWU7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/scanner', ['exports', 'glimmer-runtime/lib/syntax/statements', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-util', 'glimmer-runtime/lib/symbol-table'], function (exports, _glimmerRuntimeLibSyntaxStatements, _glimmerRuntimeLibCompiledBlocks, _glimmerUtil, _glimmerRuntimeLibSymbolTable) { - 'use strict'; + /** + Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from + jQuery master. We'll just bootstrap our own uuid now. + + @private + @return {Number} the uuid + */ + var _uuid = 0; - var Scanner = (function () { - function Scanner(block, meta, env) { - this.block = block; - this.meta = meta; - this.env = env; - } + /** + Generates a universally unique identifier. This method + is used internally by Ember for assisting with + the generation of GUID's and other unique identifiers. + + @public + @return {Number} [description] + */ - Scanner.prototype.scanEntryPoint = function scanEntryPoint() { - var block = this.block; - var meta = this.meta; + function uuid() { + return ++_uuid; + } - var symbolTable = _glimmerRuntimeLibSymbolTable.default.forEntryPoint(meta); - var program = buildStatements(block, block.blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.EntryPoint(program, symbolTable); - }; + /** + Prefix used for guids through out Ember. + @private + @property GUID_PREFIX + @for Ember + @type String + @final + */ + var GUID_PREFIX = 'ember'; - Scanner.prototype.scanLayout = function scanLayout() { - var block = this.block; - var meta = this.meta; - var blocks = block.blocks; - var named = block.named; - var yields = block.yields; - var hasPartials = block.hasPartials; - - var symbolTable = _glimmerRuntimeLibSymbolTable.default.forLayout(named, yields, hasPartials, meta); - var program = buildStatements(block, blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.Layout(program, symbolTable, named, yields, hasPartials); - }; + // Used for guid generation... + var numberCache = []; + var stringCache = {}; - Scanner.prototype.scanPartial = function scanPartial(symbolTable) { - var block = this.block; - var blocks = block.blocks; - var locals = block.locals; + /** + A unique key used to assign guids and other private metadata to objects. + If you inspect an object in your browser debugger you will often see these. + They can be safely ignored. + + On browsers that support it, these properties are added with enumeration + disabled so they won't show up when you iterate over your properties. + + @private + @property GUID_KEY + @for Ember + @type String + @final + */ + var GUID_KEY = _emberUtilsIntern.default('__ember' + +new Date()); - var program = buildStatements(block, blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.PartialBlock(program, symbolTable, locals); - }; + exports.GUID_KEY = GUID_KEY; + var GUID_DESC = { + writable: true, + configurable: true, + enumerable: false, + value: null + }; - return Scanner; - })(); + exports.GUID_DESC = GUID_DESC; + var nullDescriptor = { + configurable: true, + writable: true, + enumerable: false, + value: null + }; - exports.default = Scanner; + var GUID_KEY_PROPERTY = { + name: GUID_KEY, + descriptor: nullDescriptor + }; - function buildStatements(_ref, blocks, symbolTable, env) { - var statements = _ref.statements; + exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY; + /** + Generates a new guid, optionally saving the guid to the object that you + pass in. You will rarely need to use this method. Instead you should + call `Ember.guidFor(obj)`, which return an existing guid if available. + + @private + @method generateGuid + @for Ember + @param {Object} [obj] Object the guid will be used for. If passed in, the guid will + be saved on the object and reused whenever you pass the same object + again. + + If no object is passed, just generate a new guid. + @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to + separate the guid into separate namespaces. + @return {String} the guid + */ - if (statements.length === 0) return EMPTY_PROGRAM; - return new BlockScanner(statements, blocks, symbolTable, env).scan(); + function generateGuid(obj, prefix) { + if (!prefix) { + prefix = GUID_PREFIX; } - var EMPTY_PROGRAM = _glimmerUtil.EMPTY_SLICE; - var BlockScanner = (function () { - function BlockScanner(statements, blocks, symbolTable, env) { - this.blocks = blocks; - this.symbolTable = symbolTable; - this.stack = new _glimmerUtil.Stack(); - this.stack.push(new ChildBlockScanner(symbolTable)); - this.reader = new SyntaxReader(statements, symbolTable, this); - this.env = env; + var ret = prefix + uuid(); + if (obj) { + if (obj[GUID_KEY] === null) { + obj[GUID_KEY] = ret; + } else { + GUID_DESC.value = ret; + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(GUID_KEY_PROPERTY); + } else { + Object.defineProperty(obj, GUID_KEY, GUID_DESC); } + } + } + return ret; + } - BlockScanner.prototype.scan = function scan() { - var statement = undefined; - while (statement = this.reader.next()) { - this.addStatement(statement); - } - return this.stack.current.program; - }; - - BlockScanner.prototype.blockFor = function blockFor(symbolTable, id) { - var block = this.blocks[id]; - var childTable = _glimmerRuntimeLibSymbolTable.default.forBlock(this.symbolTable, block.locals); - var program = buildStatements(block, this.blocks, childTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.InlineBlock(program, childTable, block.locals); - }; - - BlockScanner.prototype.startBlock = function startBlock(locals) { - var childTable = _glimmerRuntimeLibSymbolTable.default.forBlock(this.symbolTable, locals); - this.stack.push(new ChildBlockScanner(childTable)); - }; - - BlockScanner.prototype.endBlock = function endBlock(locals) { - var _stack$pop = this.stack.pop(); - - var program = _stack$pop.program; - var symbolTable = _stack$pop.symbolTable; + /** + Returns a unique id for the object. If the object does not yet have a guid, + one will be assigned to it. You can call this on any object, + `Ember.Object`-based or not, but be aware that it will add a `_guid` + property. + + You can also use this method on DOM Element objects. + + @public + @method guidFor + @for Ember + @param {Object} obj any object, string, number, Element, or primitive + @return {String} the unique guid for this instance. + */ - var block = new _glimmerRuntimeLibCompiledBlocks.InlineBlock(program, symbolTable, locals); - this.addChild(block); - return block; - }; + function guidFor(obj) { + var type = typeof obj; + var isObject = type === 'object' && obj !== null; + var isFunction = type === 'function'; - BlockScanner.prototype.addChild = function addChild(block) { - this.stack.current.addChild(block); - }; + if ((isObject || isFunction) && obj[GUID_KEY]) { + return obj[GUID_KEY]; + } - BlockScanner.prototype.addStatement = function addStatement(statement) { - this.stack.current.addStatement(statement.scan(this)); - }; + // special cases where we don't want to add a key to object + if (obj === undefined) { + return '(undefined)'; + } - BlockScanner.prototype.next = function next() { - return this.reader.next(); - }; + if (obj === null) { + return '(null)'; + } - return BlockScanner; - })(); + var ret = undefined; - exports.BlockScanner = BlockScanner; + // Don't allow prototype changes to String etc. to change the guidFor + switch (type) { + case 'number': + ret = numberCache[obj]; - var ChildBlockScanner = (function () { - function ChildBlockScanner(symbolTable) { - this.symbolTable = symbolTable; - this.children = []; - this.program = new _glimmerUtil.LinkedList(); + if (!ret) { + ret = numberCache[obj] = 'nu' + obj; } - ChildBlockScanner.prototype.addChild = function addChild(block) { - this.children.push(block); - }; - - ChildBlockScanner.prototype.addStatement = function addStatement(statement) { - this.program.append(statement); - }; - - return ChildBlockScanner; - })(); - - var SyntaxReader = (function () { - function SyntaxReader(statements, symbolTable, scanner) { - this.statements = statements; - this.symbolTable = symbolTable; - this.scanner = scanner; - this.current = 0; - this.last = null; - } - - SyntaxReader.prototype.next = function next() { - var last = this.last; - if (last) { - this.last = null; - return last; - } else if (this.current === this.statements.length) { - return null; - } - var sexp = this.statements[this.current++]; - return _glimmerRuntimeLibSyntaxStatements.default(sexp, this.symbolTable, this.scanner); - }; - - return SyntaxReader; - })(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc2Nhbm5lci50cyJdLCJuYW1lcyI6W10sI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4gICAgcmV0dXJuIGJ1aWxkU3RhdGVtZW50KHNleHAsIHRoaXMuc3ltYm9sVGFibGUsIHRoaXMuc2Nhbm5lcik7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/symbol-table', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; + return ret; - var SymbolTable = (function () { - function SymbolTable(parent) { - var meta = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + case 'string': + ret = stringCache[obj]; - this.parent = parent; - this.meta = meta; - this.locals = _glimmerUtil.dict(); - this.named = _glimmerUtil.dict(); - this.yields = _glimmerUtil.dict(); - this.partialArgs = null; - this.size = 1; - this.top = parent ? parent.top : this; + if (!ret) { + ret = stringCache[obj] = 'st' + uuid(); } - SymbolTable.forEntryPoint = function forEntryPoint(meta) { - return new SymbolTable(null, meta).initEntryPoint(); - }; - - SymbolTable.forLayout = function forLayout(named, yields, hasPartials, meta) { - return new SymbolTable(null, meta).initLayout(named, yields, hasPartials); - }; - - SymbolTable.forBlock = function forBlock(parent, locals) { - return new SymbolTable(parent, null).initBlock(locals); - }; - - SymbolTable.prototype.initEntryPoint = function initEntryPoint() { - return this; - }; - - SymbolTable.prototype.initBlock = function initBlock(locals) { - this.initPositionals(locals); - return this; - }; - - SymbolTable.prototype.initLayout = function initLayout(named, yields, hasPartials) { - this.initNamed(named); - this.initYields(yields); - this.initPartials(hasPartials); - return this; - }; - - SymbolTable.prototype.initPositionals = function initPositionals(positionals) { - var _this = this; - - if (positionals) positionals.forEach(function (s) { - return _this.locals[s] = _this.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initNamed = function initNamed(named) { - var _this2 = this; - - if (named) named.forEach(function (s) { - return _this2.named[s] = _this2.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initYields = function initYields(yields) { - var _this3 = this; - - if (yields) yields.forEach(function (b) { - return _this3.yields[b] = _this3.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initPartials = function initPartials(hasPartials) { - if (hasPartials) this.top.partialArgs = this.top.size++; - return this; - }; - - SymbolTable.prototype.getMeta = function getMeta() { - var meta = this.meta; - var parent = this.parent; - - if (!meta && parent) { - meta = parent.getMeta(); - } - return meta; - }; - - SymbolTable.prototype.getYield = function getYield(name) { - var yields = this.yields; - var parent = this.parent; - - var symbol = yields[name]; - if (!symbol && parent) { - symbol = parent.getYield(name); - } - return symbol; - }; - - SymbolTable.prototype.getNamed = function getNamed(name) { - var named = this.named; - var parent = this.parent; + return ret; - var symbol = named[name]; - if (!symbol && parent) { - symbol = parent.getNamed(name); - } - return symbol; - }; + case 'boolean': + return obj ? '(true)' : '(false)'; - SymbolTable.prototype.getLocal = function getLocal(name) { - var locals = this.locals; - var parent = this.parent; + default: + if (obj === Object) { + return '(Object)'; + } - var symbol = locals[name]; - if (!symbol && parent) { - symbol = parent.getLocal(name); - } - return symbol; - }; + if (obj === Array) { + return '(Array)'; + } - SymbolTable.prototype.getPartialArgs = function getPartialArgs() { - return this.top.partialArgs; - }; + ret = GUID_PREFIX + uuid(); - SymbolTable.prototype.isTop = function isTop() { - return this.top === this; - }; + if (obj[GUID_KEY] === null) { + obj[GUID_KEY] = ret; + } else { + GUID_DESC.value = ret; - return SymbolTable; - })(); + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(GUID_KEY_PROPERTY); + } else { + Object.defineProperty(obj, GUID_KEY, GUID_DESC); + } + } + return ret; + } + } +}); +enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string', 'ember-utils/weak-map-utils', 'ember-utils/proxy-utils'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString, _emberUtilsWeakMapUtils, _emberUtilsProxyUtils) { + /* + This package will be eagerly parsed and should have no dependencies on external + packages. + + It is intended to be used to share utility methods that will be needed + by every Ember application (and is **not** a dumping ground of useful utilities). + + Utility methods that are needed in < 80% of cases should be placed + elsewhere (so they can be lazily evaluated / parsed). + */ + 'use strict'; - exports.default = SymbolTable; + exports.symbol = _emberUtilsSymbol.default; + exports.getOwner = _emberUtilsOwner.getOwner; + exports.setOwner = _emberUtilsOwner.setOwner; + exports.OWNER = _emberUtilsOwner.OWNER; + exports.assign = _emberUtilsAssign.default; + exports.EmptyObject = _emberUtilsEmptyObject.default; + exports.dictionary = _emberUtilsDictionary.default; + exports.uuid = _emberUtilsGuid.uuid; + exports.GUID_KEY = _emberUtilsGuid.GUID_KEY; + exports.GUID_DESC = _emberUtilsGuid.GUID_DESC; + exports.GUID_KEY_PROPERTY = _emberUtilsGuid.GUID_KEY_PROPERTY; + exports.generateGuid = _emberUtilsGuid.generateGuid; + exports.guidFor = _emberUtilsGuid.guidFor; + exports.intern = _emberUtilsIntern.default; + exports.checkHasSuper = _emberUtilsSuper.checkHasSuper; + exports.ROOT = _emberUtilsSuper.ROOT; + exports.wrap = _emberUtilsSuper.wrap; + exports.inspect = _emberUtilsInspect.default; + exports.lookupDescriptor = _emberUtilsLookupDescriptor.default; + exports.canInvoke = _emberUtilsInvoke.canInvoke; + exports.tryInvoke = _emberUtilsInvoke.tryInvoke; + exports.makeArray = _emberUtilsMakeArray.default; + exports.applyStr = _emberUtilsApplyStr.default; + exports.NAME_KEY = _emberUtilsName.default; + exports.toString = _emberUtilsToString.default; + exports.HAS_NATIVE_WEAKMAP = _emberUtilsWeakMapUtils.HAS_NATIVE_WEAKMAP; + exports.HAS_NATIVE_PROXY = _emberUtilsProx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lKTtcbiAgICB9XG5cbiAgICByZXR1cm4gc3ltYm9sO1xuICB9XG5cbiAgZ2V0TmFtZWQobmFtZTogc3RyaW5nKTogbnVtYmVyIHtcbiAgICBsZXQgeyBuYW1lZCwgcGFyZW50IH0gPSB0aGlzO1xuXG4gICAgbGV0IHN5bWJvbCA9IG5hbWVkW25hbWVdO1xuXG4gICAgaWYgKCFzeW1ib2wgJiYgcGFyZW50KSB7XG4gICAgICBzeW1ib2wgPSBwYXJlbnQuZ2V0TmFtZWQobmFtZSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHN5bWJvbDtcbiAgfVxuXG4gIGdldExvY2FsKG5hbWU6IHN0cmluZyk6IG51bWJlciB7XG4gICAgbGV0IHsgbG9jYWxzLCBwYXJlbnQgfSA9IHRoaXM7XG5cbiAgICBsZXQgc3ltYm9sID0gbG9jYWxzW25hbWVdO1xuXG4gICAgaWYgKCFzeW1ib2wgJiYgcGFyZW50KSB7XG4gICAgICBzeW1ib2wgPSBwYXJlbnQuZ2V0TG9jYWwobmFtZSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHN5bWJvbDtcbiAgfVxuXG4gIGdldFBhcnRpYWxBcmdzKCk6IG51bWJlciB7XG4gICAgcmV0dXJuIHRoaXMudG9wLnBhcnRpYWxBcmdzO1xuICB9XG5cbiAgaXNUb3AoKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuIHRoaXMudG9wID09PSB0aGlzO1xuICB9XG59XG4iXX0= -enifed("glimmer-runtime/lib/syntax", ["exports"], function (exports) { - "use strict"; +enifed('ember-utils/inspect', ['exports'], function (exports) { + 'use strict'; - exports.isAttribute = isAttribute; + exports.default = inspect; + var objectToString = Object.prototype.toString; - var Statement = (function () { - function Statement() { - this.next = null; - this.prev = null; - } + /** + Convenience method to inspect an object. This method will attempt to + convert the object into a useful string description. + + It is a pretty simple implementation. If you want something more robust, + use something like JSDump: https://github.com/NV/jsDump + + @method inspect + @for Ember + @param {Object} obj The object you want to inspect. + @return {String} A description of the object + @since 1.4.0 + @private + */ - Statement.fromSpec = function fromSpec(spec, symbolTable, scanner) { - throw new Error("You need to implement fromSpec on " + this); - }; + function inspect(obj) { + if (obj === null) { + return 'null'; + } + if (obj === undefined) { + return 'undefined'; + } + if (Array.isArray(obj)) { + return '[' + obj + ']'; + } + // for non objects + var type = typeof obj; + if (type !== 'object' && type !== 'symbol') { + return '' + obj; + } + // overridden toString + if (typeof obj.toString === 'function' && obj.toString !== objectToString) { + return obj.toString(); + } - Statement.prototype.clone = function clone() { - // not type safe but the alternative is extreme boilerplate per - // syntax subclass. - return new this.constructor(this); - }; + // Object.prototype.toString === {}.toString + var v = undefined; + var ret = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + v = obj[key]; + if (v === 'toString') { + continue; + } // ignore useless items + if (typeof v === 'function') { + v = 'function() { ... }'; + } - Statement.prototype.scan = function scan(scanner) { - return this; - }; + if (v && typeof v.toString !== 'function') { + ret.push(key + ': ' + objectToString.call(v)); + } else { + ret.push(key + ': ' + v); + } + } + } + return '{' + ret.join(', ') + '}'; + } +}); +enifed("ember-utils/intern", ["exports"], function (exports) { + /** + Strongly hint runtimes to intern the provided string. + + When do I need to use this function? + + For the most part, never. Pre-mature optimization is bad, and often the + runtime does exactly what you need it to, and more often the trade-off isn't + worth it. + + Why? + + Runtimes store strings in at least 2 different representations: + Ropes and Symbols (interned strings). The Rope provides a memory efficient + data-structure for strings created from concatenation or some other string + manipulation like splitting. + + Unfortunately checking equality of different ropes can be quite costly as + runtimes must resort to clever string comparison algorithms. These + algorithms typically cost in proportion to the length of the string. + Luckily, this is where the Symbols (interned strings) shine. As Symbols are + unique by their string content, equality checks can be done by pointer + comparison. + + How do I know if my string is a rope or symbol? + + Typically (warning general sweeping statement, but truthy in runtimes at + present) static strings created as part of the JS source are interned. + Strings often used for comparisons can be interned at runtime if some + criteria are met. One of these criteria can be the size of the entire rope. + For example, in chrome 38 a rope longer then 12 characters will not + intern, nor will segments of that rope. + + Some numbers: http://jsperf.com/eval-vs-keys/8 + + Known Trick™ + + @private + @return {String} interned version of the provided string + */ + "use strict"; - return Statement; - })(); + exports.default = intern; - exports.Statement = Statement; + function intern(str) { + var obj = {}; + obj[str] = 1; + for (var key in obj) { + if (key === str) { + return key; + } + } + return str; + } +}); +enifed('ember-utils/invoke', ['exports', 'ember-utils/apply-str'], function (exports, _emberUtilsApplyStr) { + 'use strict'; - var Expression = (function () { - function Expression() {} + exports.canInvoke = canInvoke; + exports.tryInvoke = tryInvoke; - Expression.fromSpec = function fromSpec(spec, blocks) { - throw new Error("You need to implement fromSpec on " + this); - }; + /** + Checks to see if the `methodName` exists on the `obj`. + + ```javascript + let foo = { bar: function() { return 'bar'; }, baz: null }; + + Ember.canInvoke(foo, 'bar'); // true + Ember.canInvoke(foo, 'baz'); // false + Ember.canInvoke(foo, 'bat'); // false + ``` + + @method canInvoke + @for Ember + @param {Object} obj The object to check for the method + @param {String} methodName The method name to check for + @return {Boolean} + @private + */ - return Expression; - })(); + function canInvoke(obj, methodName) { + return !!(obj && typeof obj[methodName] === 'function'); + } - exports.Expression = Expression; - var ATTRIBUTE = "e1185d30-7cac-4b12-b26a-35327d905d92"; - exports.ATTRIBUTE = ATTRIBUTE; - var ARGUMENT = "0f3802314-d747-bbc5-0168-97875185c3rt"; - exports.ARGUMENT = ARGUMENT; + /** + Checks to see if the `methodName` exists on the `obj`, + and if it does, invokes it with the arguments passed. + + ```javascript + let d = new Date('03/15/2013'); + + Ember.tryInvoke(d, 'getTime'); // 1363320000000 + Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 + Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined + ``` + + @method tryInvoke + @for Ember + @param {Object} obj The object to check for the method + @param {String} methodName The method name to check for + @param {Array} [args] The arguments to pass to the method + @return {*} the return value of the invoked method or undefined if it cannot be invoked + @public + */ - var Attribute = (function (_Statement) { - babelHelpers.inherits(Attribute, _Statement); + function tryInvoke(obj, methodName, args) { + if (canInvoke(obj, methodName)) { + return args ? _emberUtilsApplyStr.default(obj, methodName, args) : _emberUtilsApplyStr.default(obj, methodName); + } + } +}); +enifed("ember-utils/lookup-descriptor", ["exports"], function (exports) { + "use strict"; - function Attribute() { - _Statement.apply(this, arguments); - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - } + exports.default = lookupDescriptor; - return Attribute; - })(Statement); + function lookupDescriptor(obj, keyName) { + var current = obj; + while (current) { + var descriptor = Object.getOwnPropertyDescriptor(current, keyName); - exports.Attribute = Attribute; + if (descriptor) { + return descriptor; + } - var Argument = (function (_Statement2) { - babelHelpers.inherits(Argument, _Statement2); + current = Object.getPrototypeOf(current); + } - function Argument() { - _Statement2.apply(this, arguments); - this["0f3802314-d747-bbc5-0168-97875185c3rt"] = true; - } + return null; + } +}); +enifed("ember-utils/make-array", ["exports"], function (exports) { + "use strict"; - return Argument; - })(Statement); + exports.default = makeArray; + var isArray = Array.isArray; - exports.Argument = Argument; + /** + Forces the passed object to be part of an array. If the object is already + an array, it will return the object. Otherwise, it will add the object to + an array. If obj is `null` or `undefined`, it will return an empty array. + + ```javascript + Ember.makeArray(); // [] + Ember.makeArray(null); // [] + Ember.makeArray(undefined); // [] + Ember.makeArray('lindsay'); // ['lindsay'] + Ember.makeArray([1, 2, 42]); // [1, 2, 42] + + let controller = Ember.ArrayProxy.create({ content: [] }); + + Ember.makeArray(controller) === controller; // true + ``` + + @method makeArray + @for Ember + @param {Object} obj the object + @return {Array} + @private + */ - function isAttribute(value) { - return value && value[ATTRIBUTE] === true; + function makeArray(obj) { + if (obj === null || obj === undefined) { + return []; } + return isArray(obj) ? obj : [obj]; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O1FBbUJBLFNBQUE7QUFBQSxpQkFBQSxTQUFBLEdBQUE7QUFNUyxnQk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IGFic3RyYWN0IHZhbHVlU3ludGF4KCk6IEV4cHJlc3Npb248VD47XG59XG5cbmV4cG9ydCBhYnN0cmFjdCBjbGFzcyBBcmd1bWVudDxUPiBleHRlbmRzIFN0YXRlbWVudCB7XG4gIFwiMGYzODAyMzE0LWQ3NDctYmJjNS0wMTY4LTk3ODc1MTg1YzNydFwiID0gdHJ1ZTtcbiAgbmFtZTogc3RyaW5nO1xuICBuYW1lc3BhY2U6IHN0cmluZztcbiAgYWJzdHJhY3QgdmFsdWVTeW50YXgoKTogRXhwcmVzc2lvbjxUPjtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGlzQXR0cmlidXRlKHZhbHVlOiBTdGF0ZW1lbnQpOiB2YWx1ZSBpcyBBdHRyaWJ1dGU8YW55PiB7XG4gIHJldHVybiB2YWx1ZSAmJiB2YWx1ZVtBVFRSSUJVVEVdID09PSB0cnVlO1xufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/each', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var EachSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(EachSyntax, _StatementSyntax); - - function EachSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "each-statement"; - } - - EachSyntax.prototype.compile = function compile(dsl, env) { - // Enter(BEGIN, END) - // BEGIN: Noop - // PutArgs - // PutIterable - // JumpUnless(ELSE) - // EnterList(BEGIN2, END2) - // ITER: Noop - // NextIter(BREAK) - // EnterWithKey(BEGIN2, END2) - // BEGIN2: Noop - // PushChildScope - // Evaluate(default) - // PopScope - // END2: Noop - // Exit - // Jump(ITER) - // BREAK: Noop - // ExitList - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.block(args, function (dsl, BEGIN, END) { - dsl.putIterator(); - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - } else { - dsl.jumpUnless(END); - } - dsl.iter(function (dsl, BEGIN, END) { - dsl.evaluate('default', blocks.default); - }); - if (blocks.inverse) { - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } - }); - }; - - return EachSyntax; - })(_glimmerRuntimeLibSyntax.Statement); +enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { + 'use strict'; - exports.default = EachSyntax; + exports.default = _emberUtilsSymbol.default('NAME_KEY'); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL2VhY2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBVUEsVUFBQTs4QkFBQSxVQUFBOztBQUdFLGlCQUhGLFVBQUEsQ0FHcUIsSUFBaUIsRUFBQTtBQUNsQyx1Q0FBTyxDQUFDO0FBRFMsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFhO0FBRnBDLGdCQUFBLENBQUEsSUFBSSxHQUFHLGdCQUFnQixDQUFDO1NBSXZCOztBQUxILGtCQUFBLFdBT0UsT0FBTyxHQUFBLGlCQUFDLEdBQXFCLEVBQUUsR0FBZ0IsRUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O2dCQXlCdkMsSUFBSSxHQUF1QixJQUFJLENBQS9CLElBQUk7Z0JBQVUsTUFBTSxHQUFPLElBQUksQ0FBekIsSUFBSSxDQUFJLE1BQU07O0FBRTFCLGVBQUcsQ0FBQyxLQUFLLENBQUMsSUFBSSxFQUFFLFVBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxHQUFHLEVBQUE7QUFDOUIsbUJBQUcsQ0FBQyxXQUFXLEVBQUUsQ0FBQztBQUVsQixvQkFBSSxNQUFNLENBQUMsT0FBTyxFQUFFO0FBQ2xCLHVCQUFHLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFD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ydWN0b3IocHVibGljIGFyZ3M6IFN5bnRheC5BcmdzKSB7XG4gICAgc3VwZXIoKTtcbiAgfVxuXG4gIGNvbXBpbGUoZHNsOiBPcGNvZGVCdWlsZGVyRFNMLCBlbnY6IEVudmlyb25tZW50KSB7XG4gICAgLy8gICAgICAgICBFbnRlcihCRUdJTiwgRU5EKVxuICAgIC8vIEJFR0lOOiAgTm9vcFxuICAgIC8vICAgICAgICAgUHV0QXJnc1xuICAgIC8vICAgICAgICAgUHV0SXRlcmFibGVcbiAgICAvLyAgICAgICAgIEp1bXBVbmxlc3MoRUxTRSlcbiAgICAvLyAgICAgICAgIEVudGVyTGlzdChCRUdJTjIsIEVORDIpXG4gICAgLy8gSVRFUjogICBOb29wXG4gICAgLy8gICAgICAgICBOZXh0SXRlcihCUkVBSylcbiAgICAvLyAgICAgICAgIEVudGVyV2l0aEtleShCRUdJTjIsIEVORDIpXG4gICAgLy8gQkVHSU4yOiBOb29wXG4gICAgLy8gICAgICAgICBQdXNoQ2hpbGRTY29wZVxuICAgIC8vICAgICAgICAgRXZhbHVhdGUoZGVmYXVsdClcbiAgICAvLyAgICAgICAgIFBvcFNjb3BlXG4gICAgLy8gRU5EMjogICBOb29wXG4gICAgLy8gICAgICAgICBFeGl0XG4gICAgLy8gICAgICAgICBKdW1wKElURVIpXG4gICAgLy8gQlJFQUs6ICBOb29wXG4gICAgLy8gICAgICAgICBFeGl0TGlzdFxuICAgIC8vICAgICAgICAgSnVtcChFTkQpXG4gICAgLy8gRUxTRTogICBOb29wXG4gICAgLy8gICAgICAgICBFdmFsdWxhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgIE5vb3BcbiAgICAvLyAgICAgICAgIEV4aXRcblxuICAgIGxldCB7IGFyZ3MsIGFyZ3M6IHsgYmxvY2tzIH0gfSA9IHRoaXM7XG5cbiAgICBkc2wuYmxvY2soYXJncywgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgZHNsLnB1dEl0ZXJhdG9yKCk7XG5cbiAgICAgIGlmIChibG9ja3MuaW52ZXJzZSkge1xuICAgICAgICBkc2wuanVtcFVubGVzcygnRUxTRScpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgZHNsLmp1bXBVbmxlc3MoRU5EKTtcbiAgICAgIH1cblxuICAgICAgZHNsLml0ZXIoKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgICBkc2wuZXZhbHVhdGUoJ2RlZmF1bHQnLCBibG9ja3MuZGVmYXVsdCk7XG4gICAgICB9KTtcblxuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wKEVORCk7XG4gICAgICAgIGRzbC5sYWJlbCgnRUxTRScpO1xuICAgICAgICBkc2wuZXZhbHVhdGUoJ2ludmVyc2UnLCBibG9ja3MuaW52ZXJzZSk7XG4gICAgICB9XG4gICAgfSk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/syntax/builtins/if', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var IfSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(IfSyntax, _StatementSyntax); - - function IfSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "if-statement"; - } - - IfSyntax.prototype.compile = function compile(dsl) { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl, BEGIN, END) { - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpUnless(END); - dsl.evaluate('default', blocks.default); - } - }); - }; - - return IfSyntax; - })(_glimmerRuntimeLibSyntax.Statement); +enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { + /** + @module ember + @submodule ember-runtime + */ - exports.default = IfSyntax; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL2lmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLFFBQUE7OEJBQUEsUUFBQTs7QUFHRSxpQkFIRixRQUFBLENBR3FCLElBQWlCLEVBQUE7QUFDbEMsdUNBQU8sQ0FBQztBQURTLGdCQUFBLENBQUEsSUFBSSxHQUFKLElBQUksQ0FBYTtBQUZwQyxnQkFBQSxDQUFBLElBQUksR0FBRyxjQUFjLENBQUM7U0FJckI7O0FBTEgsZ0JBQUEsV0FPRSxPQUFPLEdBQUEsaUJBQUMsR0FBcUIsRUFBQTs7Ozs7Ozs7Ozs7O2dCQWFyQixJQUFJLEdBQXVCLElBQUksQ0FBL0IsSUFBSTtnQkFBVSxNQUFNLEdBQU8sSUFBSSxDQUF6QixJQUFJLENBQUksTUFBTTs7QUFFMUIsZUFBRyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUNsQixlQUFHLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxDQUFDO0FBRXhCLGVBQUcsQ0FBQyxLQUFLLENBQUMsSUFBSSxFQUFFLFVBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxHQUFHLEVBQUE7QUFDOUIsb0JBQUksTUFBTSxDQUFDLE9BQU8sRUFBRTtBQUNsQix1QkFBRyxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUN2Qix1QkFBRyxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUUsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQ3hDLHVCQUFHLENBQUMsSUFBSSxDQU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LyAgICAgICAgSnVtcFVubGVzcyhFTFNFKVxuICAgIC8vICAgICAgICBFdmFsdWF0ZShkZWZhdWx0KVxuICAgIC8vICAgICAgICBKdW1wKEVORClcbiAgICAvLyBFTFNFOiAgTm9vcFxuICAgIC8vICAgICAgICBFdmFsdWxhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgTm9vcFxuICAgIC8vICAgICAgICBFeGl0XG5cbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoRU5EKTtcbiAgICAgICAgZHNsLmxhYmVsKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnaW52ZXJzZScsIGJsb2Nrcy5pbnZlcnNlKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/in-element', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; + 'use strict'; - var InElementSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(InElementSyntax, _StatementSyntax); + exports.getOwner = getOwner; + exports.setOwner = setOwner; + var OWNER = _emberUtilsSymbol.default('OWNER'); - function InElementSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "in-element-statement"; - } + exports.OWNER = OWNER; + /** + Framework objects in an Ember application (components, services, routes, etc.) + are created via a factory and dependency injection system. Each of these + objects is the responsibility of an "owner", which handled its + instantiation and manages its lifetime. + + `getOwner` fetches the owner object responsible for an instance. This can + be used to lookup or resolve other class instances, or register new factories + into the owner. + + For example, this component dynamically looks up a service based on the + `audioType` passed as an attribute: + + ``` + // app/components/play-audio.js + import Ember from 'ember'; + + // Usage: + // + // {{play-audio audioType=model.audioType audioFile=model.file}} + // + export default Ember.Component.extend({ + audioService: Ember.computed('audioType', function() { + let owner = Ember.getOwner(this); + return owner.lookup(`service:${this.get('audioType')}`); + }), + click() { + let player = this.get('audioService'); + player.play(this.get('audioFile')); + } + }); + ``` + + @method getOwner + @for Ember + @param {Object} object An object with an owner. + @return {Object} An owner object. + @since 2.3.0 + @public + */ - InElementSyntax.prototype.compile = function compile(dsl, env) { - var args = this.args; - var blocks = this.args.blocks; + function getOwner(object) { + return object[OWNER]; + } - dsl.putArgs(args); - dsl.test('simple'); - dsl.block(null, function (dsl, BEGIN, END) { - dsl.jumpUnless(END); - dsl.pushRemoteElement(); - dsl.evaluate('default', blocks.default); - dsl.popRemoteElement(); - }); - }; + /** + `setOwner` forces a new owner on a given object instance. This is primarily + useful in some testing cases. + + @method setOwner + @for Ember + @param {Object} object An object instance. + @param {Object} object The new owner object of the object instance. + @since 2.3.0 + @public + */ - return InElementSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + function setOwner(object, owner) { + object[OWNER] = owner; + } +}); +enifed('ember-utils/proxy-utils', ['exports'], function (exports) { + 'use strict'; - exports.default = InElementSyntax; + var HAS_NATIVE_PROXY = typeof Proxy === 'function'; + exports.HAS_NATIVE_PROXY = HAS_NATIVE_PROXY; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVud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ICBTdGF0ZW1lbnQgYXMgU3RhdGVtZW50U3ludGF4XG59IGZyb20gJy4uLy4uL3N5bnRheCc7XG5cbmltcG9ydCBPcGNvZGVCdWlsZGVyRFNMIGZyb20gJy4uLy4uL2NvbXBpbGVkL29wY29kZXMvYnVpbGRlcic7XG5pbXBvcnQgKiBhcyBTeW50YXggZnJvbSAnLi4vY29yZSc7XG5pbXBvcnQgRW52aXJvbm1lbnQgZnJvbSAnLi4vLi4vZW52aXJvbm1lbnQnO1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBJbkVsZW1lbnRTeW50YXggZXh0ZW5kcyBTdGF0ZW1lbnRTeW50YXgge1xuICB0eXBlID0gXCJpbi1lbGVtZW50LXN0YXRlbWVudFwiO1xuXG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgYXJnczogU3ludGF4LkFyZ3MpIHtcbiAgICBzdXBlcigpO1xuICB9XG5cbiAgY29tcGlsZShkc2w6IE9wY29kZUJ1aWxkZXJEU0wsIGVudjogRW52aXJvbm1lbnQpIHtcbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ3NpbXBsZScpO1xuXG4gICAgZHNsLmJsb2NrKG51bGwsIChkc2wsIEJFR0lOLCBFTkQpID0+IHtcbiAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICBkc2wucHVzaFJlbW90ZUVsZW1lbnQoKTtcbiAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIGRzbC5wb3BSZW1vdGVFbGVtZW50KCk7XG4gICAgfSk7XG4gIH1cbn1cbiJdfQ== -enifed("glimmer-runtime/lib/syntax/builtins/partial", ["exports", "glimmer-runtime/lib/syntax"], function (exports, _glimmerRuntimeLibSyntax) { - "use strict"; +enifed('ember-utils/super', ['exports'], function (exports) { + 'use strict'; - var StaticPartialSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(StaticPartialSyntax, _StatementSyntax); + exports.wrap = wrap; + var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/; + var fnToString = Function.prototype.toString; - function StaticPartialSyntax(name) { - _StatementSyntax.call(this); - this.name = name; - this.type = "static-partial"; - } + var checkHasSuper = (function () { + var sourceAvailable = fnToString.call(function () { + return this; + }).indexOf('return this') > -1; - StaticPartialSyntax.prototype.compile = function compile(dsl, env, symbolTable) { - var name = String(this.name.inner()); - if (!env.hasPartial(name, symbolTable)) { - throw new Error("Compile Error: " + name + " is not a partial"); - } - var definition = env.lookupPartial(name, symbolTable); - dsl.putPartialDefinition(definition); - dsl.evaluatePartial(); - }; + if (sourceAvailable) { + return function checkHasSuper(func) { + return HAS_SUPER_PATTERN.test(fnToString.call(func)); + }; + } - return StaticPartialSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + return function checkHasSuper() { + return true; + }; + })(); - exports.StaticPartialSyntax = StaticPartialSyntax; + exports.checkHasSuper = checkHasSuper; + function ROOT() {} + ROOT.__hasSuper = false; - var DynamicPartialSyntax = (function (_StatementSyntax2) { - babelHelpers.inherits(DynamicPartialSyntax, _StatementSyntax2); + function hasSuper(func) { + if (func.__hasSuper === undefined) { + func.__hasSuper = checkHasSuper(func); + } + return func.__hasSuper; + } - function DynamicPartialSyntax(name) { - _StatementSyntax2.call(this); - this.name = name; - this.type = "dynamic-partial"; - } + /** + Wraps the passed function so that `this._super` will point to the superFunc + when the function is invoked. This is the primitive we use to implement + calls to super. + + @private + @method wrap + @for Ember + @param {Function} func The function to call + @param {Function} superFunc The super function. + @return {Function} wrapped function. + */ - DynamicPartialSyntax.prototype.compile = function compile(dsl) { - var name = this.name; + function wrap(func, superFunc) { + if (!hasSuper(func)) { + return func; + } + // ensure an unwrapped super that calls _super is wrapped with a terminal _super + if (!superFunc.wrappedFunction && hasSuper(superFunc)) { + return _wrap(func, _wrap(superFunc, ROOT)); + } + return _wrap(func, superFunc); + } - dsl.startLabels(); - dsl.putValue(name); - dsl.test('simple'); - dsl.enter('BEGIN', 'END'); - dsl.label('BEGIN'); - dsl.jumpUnless('END'); - dsl.putDynamicPartialDefinition(); - dsl.evaluatePartial(); - dsl.label('END'); - dsl.exit(); - dsl.stopLabels(); - }; + function _wrap(func, superFunc) { + function superWrapper() { + var orig = this._super; + this._super = superFunc; + var ret = func.apply(this, arguments); + this._super = orig; + return ret; + } - return DynamicPartialSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + superWrapper.wrappedFunction = func; + superWrapper.__ember_observes__ = func.__ember_observes__; + superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__; + superWrapper.__ember_listens__ = func.__ember_listens__; - exports.DynamicPartialSyntax = DynamicPartialSyntax; + return superWrapper; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3BhcnRpYWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBY0EsbUJBQUE7OEJBQUEsbUJBQUE7O0FBR0UsaUJBSEYsbUJBQUEsQ0FHc0IsSUFBdUIsRUFBQTtBQUN6Qyx1Q0FBTyxDQUFDO0FBRFUsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFtQjtBQUZwQyxnQkFBQSxDQUFBLElBQUksR0FBRyxnQkFBZ0IsQ0FBQztTQUk5Qjs7QUFMSCwyQkFBQSxXQU9FLE9BQU8sR0FBQSxpQkFBQyxHQUFxQixFQUFFLEdBQWdCLEVBQUUsV0FBd0IsRUFBQTtBQUN2RSxnQkFBSSxJQUFJLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQztBQUVyQyxnQkFBSSxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsSUF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zKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/syntax/builtins/unless', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var UnlessSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(UnlessSyntax, _StatementSyntax); - - function UnlessSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "unless-statement"; - } - - UnlessSyntax.prototype.compile = function compile(dsl, env) { - // PutArgs - // Enter(BEGIN, END) - // BEGIN: Noop - // Test(Environment) - // JumpIf(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl) { - if (blocks.inverse) { - dsl.jumpIf('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump('END'); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpIf('END'); - dsl.evaluate('default', blocks.default); - } - }); - }; +enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern'], function (exports, _emberUtilsGuid, _emberUtilsIntern) { + 'use strict'; - return UnlessSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + exports.default = symbol; - exports.default = UnlessSyntax; + function symbol(debugName) { + // TODO: Investigate using platform symbols, but we do not + // want to require non-enumerability for this API, which + // would introduce a large cost. + var id = _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()); + return _emberUtilsIntern.default('__' + debugName + '__ [id=' + id + ']'); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3VubGVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFVQSxZQUFBOzhCQUFBLFlBQUE7O0FBR0UsaUJBSEYsWUFBQSxDQ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0XG5cbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgZHNsID0+IHtcbiAgICAgIGlmIChibG9ja3MuaW52ZXJzZSkge1xuICAgICAgICBkc2wuanVtcElmKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoJ0VORCcpO1xuICAgICAgICBkc2wubGFiZWwoJ0VMU0UnKTtcbiAgICAgICAgZHNsLmV2YWx1YXRlKCdpbnZlcnNlJywgYmxvY2tzLmludmVyc2UpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgZHNsLmp1bXBJZignRU5EJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/with-dynamic-vars', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var WithDynamicVarsSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(WithDynamicVarsSyntax, _StatementSyntax); - - function WithDynamicVarsSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "with-dynamic-vars-statement"; - } - - WithDynamicVarsSyntax.prototype.compile = function compile(dsl, env) { - var args = this.args; - var blocks = this.args.blocks; +enifed('ember-utils/to-string', ['exports'], function (exports) { + 'use strict'; - dsl.unit(function (dsl) { - dsl.putArgs(args); - dsl.pushDynamicScope(); - dsl.bindDynamicScope(args.named.keys); - dsl.evaluate('default', blocks.default); - dsl.popDynamicScope(); - }); - }; + exports.default = toString; + var objectToString = Object.prototype.toString; - return WithDynamicVarsSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + /* + A `toString` util function that supports objects without a `toString` + method, e.g. an object created with `Object.create(null)`. + */ - exports.default = WithDynamicVarsSyntax; + function toString(obj) { + if (obj && typeof obj.toString === 'function') { + return obj.toString(); + } else { + return objectToString.call(obj); + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3dpdGgtZHluYW1pYy12YXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLHFCQUFBOzhCQUFBLHFCQUFBOztBQUdFLGlCQUhGLHFCQUFBLENBR3NCLElBQWlCLEVBQUE7QUFDbkMsdUNBQU8sQ0FBQztBQURVLGdCQUFBLENBQUEsSUFBSSxHQUFKLElBQUksQ0FBYTtBQUZyQyxnQkFBQSxDQUFBLElBQUksR0FBRyw2QkFBNkIsQ0FBQztTQUlwQzs7QUFMSCw2QkFBQSxXQU9FLE9BQU8sR0FBQSxpQkFBQyxHQUFxQixFQUFFLEdBQWdCLEVBQUE7Z0JBQ3ZDLElBQUksR0FBdUIsSUFBSSxDQUEvQixJQUFJO2dCQUFVLE1BQU0sR0FBTyxJQUFJLENBQXpCLElBQUksQ0FBSSxNQUFNOztBQUUxQixlQUFHLENBQUMsSUFBSSxDQUFDLFVBQUEsR0FBRyxFQUFBO0FBQ1YsbUJBQUcsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7QUFDbEIsbUJBQUcsQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDO0FBQ3ZCLG1CQUFHLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUN0QyxtQkFBRyxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUUsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQ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IGRzbC5wb3BEeW5hbWljU2NvcGUoKTtcbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/with', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var WithSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(WithSyntax, _StatementSyntax); - - function WithSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "with-statement"; - } - - WithSyntax.prototype.compile = function compile(dsl, env) { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evaluate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl, BEGIN, END) { - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpUnless(END); - dsl.evaluate('default', blocks.default); - } - }); - }; +enifed('ember-utils/weak-map-utils', ['exports'], function (exports) { + 'use strict'; - return WithSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + var HAS_NATIVE_WEAKMAP = (function () { + // detect if `WeakMap` is even present + var hasWeakMap = typeof WeakMap === 'function'; + if (!hasWeakMap) { + return false; + } - exports.default = WithSyntax; + var instance = new WeakMap(); + // use `Object`'s `.toString` directly to prevent us from detecting + // polyfills as native weakmaps + return Object.prototype.toString.call(instance) === '[object WeakMap]'; + })(); + exports.HAS_NATIVE_WEAKMAP = HAS_NATIVE_WEAKMAP; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3dpdGgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBU0EsVU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AvLyAgICAgICAgRXZhbHVhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgTm9vcFxuICAgIC8vICAgICAgICBFeGl0XG5cbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoRU5EKTtcbiAgICAgICAgZHNsLmxhYmVsKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnaW52ZXJzZScsIGJsb2Nrcy5pbnZlcnNlKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/core', ['exports', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/syntax/builtins/partial', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-runtime/lib/compiled/opcodes/component', 'glimmer-runtime/lib/compiled/opcodes/dom', 'glimmer-runtime/lib/syntax/expressions', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/compiled/expressions/value', 'glimmer-runtime/lib/compiled/expressions/lookups', 'glimmer-runtime/lib/compiled/expressions/has-block', 'glimmer-runtime/lib/compiled/expressions/helper', 'glimmer-runtime/lib/compiled/expressions/concat', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/compiled/opcodes/content'], function (exports, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibSyntaxBuiltinsPartial, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerRuntimeLibCompiledOpcodesComponent, _glimmerRuntimeLibCompiledOpcodesDom, _glimmerRuntimeLibSyntaxExpressions, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibCompiledExpressionsValue, _glimmerRuntimeLibCompiledExpressionsLookups, _glimmerRuntimeLibCompiledExpressionsHasBlock, _glimmerRuntimeLibCompiledExpressionsHelper, _glimmerRuntimeLibCompiledExpressionsConcat, _glimmerRuntimeLibUtils, _glimmerRuntimeLibCompiledOpcodesContent) { - 'use strict'; - - var Block = (function (_StatementSyntax) { - babelHelpers.inherits(Block, _StatementSyntax); - - function Block(path, args) { - _StatementSyntax.call(this); - this.path = path; - this.args = args; - this.type = "block"; - } - - Block.fromSpec = function fromSpec(sexp, symbolTable, scanner) { - var path = sexp[1]; - var params = sexp[2]; - var hash = sexp[3]; - var templateId = sexp[4]; - var inverseId = sexp[5]; +enifed('ember-views/compat/attrs', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; - var template = scanner.blockFor(symbolTable, templateId); - var inverse = typeof inverseId === 'number' ? scanner.blockFor(symbolTable, inverseId) : null; - var blocks = Blocks.fromSpec(template, inverse); - return new Block(path, Args.fromSpec(params, hash, blocks)); - }; + var MUTABLE_CELL = _emberUtils.symbol('MUTABLE_CELL'); + exports.MUTABLE_CELL = MUTABLE_CELL; +}); +enifed('ember-views/compat/fallback-view-registry', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; - Block.build = function build(path, args) { - return new this(path, args); - }; + exports.default = _emberUtils.dictionary(null); +}); +enifed('ember-views/component_lookup', ['exports', 'ember-metal', 'ember-runtime', 'container'], function (exports, _emberMetal, _emberRuntime, _container) { + 'use strict'; - Block.prototype.scan = function scan(scanner) { - var _args$blocks = this.args.blocks; - var _default = _args$blocks.default; - var inverse = _args$blocks.inverse; + exports.default = _emberRuntime.Object.extend({ + componentFor: function (name, owner, options) { + _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); + var fullName = 'component:' + name; + return owner[_container.FACTORY_FOR](fullName, options); + }, - if (_default) scanner.addChild(_default); - if (inverse) scanner.addChild(inverse); - return this; - }; + layoutFor: function (name, owner, options) { + _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); - Block.prototype.compile = function compile(ops) { - throw new Error("SyntaxError"); - }; + var templateFullName = 'template:components/' + name; + return owner.lookup(templateFullName, options); + } + }); +}); +enifed('ember-views/index', ['exports', 'ember-views/system/ext', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/system/event_dispatcher', 'ember-views/component_lookup', 'ember-views/mixins/text_support', 'ember-views/views/core_view', 'ember-views/mixins/class_names_support', 'ember-views/mixins/child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/view_support', 'ember-views/mixins/action_support', 'ember-views/compat/attrs', 'ember-views/system/lookup_partial', 'ember-views/utils/lookup-component', 'ember-views/system/action_manager', 'ember-views/compat/fallback-view-registry'], function (exports, _emberViewsSystemExt, _emberViewsSystemJquery, _emberViewsSystemUtils, _emberViewsSystemEvent_dispatcher, _emberViewsComponent_lookup, _emberViewsMixinsText_support, _emberViewsViewsCore_view, _emberViewsMixinsClass_names_support, _emberViewsMixinsChild_views_support, _emberViewsMixinsView_state_support, _emberViewsMixinsView_support, _emberViewsMixinsAction_support, _emberViewsCompatAttrs, _emberViewsSystemLookup_partial, _emberViewsUtilsLookupComponent, _emberViewsSystemAction_manager, _emberViewsCompatFallbackViewRegistry) { + /** + @module ember + @submodule ember-views + */ - return Block; - })(_glimmerRuntimeLibSyntax.Statement); + 'use strict'; - exports.Block = Block; + exports.jQuery = _emberViewsSystemJquery.default; + exports.isSimpleClick = _emberViewsSystemUtils.isSimpleClick; + exports.getViewBounds = _emberViewsSystemUtils.getViewBounds; + exports.getViewClientRects = _emberViewsSystemUtils.getViewClientRects; + exports.getViewBoundingClientRect = _emberViewsSystemUtils.getViewBoundingClientRect; + exports.getRootViews = _emberViewsSystemUtils.getRootViews; + exports.getChildViews = _emberViewsSystemUtils.getChildViews; + exports.getViewId = _emberViewsSystemUtils.getViewId; + exports.getViewElement = _emberViewsSystemUtils.getViewElement; + exports.setViewElement = _emberViewsSystemUtils.setViewElement; + exports.STYLE_WARNING = _emberViewsSystemUtils.STYLE_WARNING; + exports.EventDispatcher = _emberViewsSystemEvent_dispatcher.default; + exports.ComponentLookup = _emberViewsComponent_lookup.default; + exports.TextSupport = _emberViewsMixinsText_support.default; + exports.CoreView = _emberViewsViewsCore_view.default; + exports.ClassNamesSupport = _emberViewsMixinsClass_names_support.default; + exports.ChildViewsSupport = _emberViewsMixinsChild_views_support.default; + exports.ViewStateSupport = _emberViewsMixinsView_state_support.default; + exports.ViewMixin = _emberViewsMixinsView_support.default; + exports.dispatchLifeCycleHook = _emberViewsMixinsView_support.dispatchLifeCycleHook; + exports.ActionSupport = _emberViewsMixinsAction_support.default; + exports.MUTABLE_CELL = _emberViewsCompatAttrs.MUTABLE_CELL; + exports.lookupPartial = _emberViewsSystemLookup_partial.default; + exports.hasPartial = _emberViewsSystemLookup_partial.hasPartial; + exports.lookupComponent = _emberViewsUtilsLookupComponent.default; + exports.ActionManager = _emberViewsSystemAction_manager.default; + exports.fallbackViewRegistry = _emberViewsCompatFallbackViewRegistry.default; +}); +// for the side effect of extending Ember.run.queues +enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/compat/attrs'], function (exports, _emberUtils, _emberMetal, _emberViewsCompatAttrs) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - var Append = (function (_StatementSyntax2) { - babelHelpers.inherits(Append, _StatementSyntax2); + function validateAction(component, actionName) { + if (actionName && actionName[_emberViewsCompatAttrs.MUTABLE_CELL]) { + actionName = actionName.value; + } - function Append(_ref) { - var value = _ref.value; - var trustingMorph = _ref.trustingMorph; + _emberMetal.assert('The default action was triggered on the component ' + component.toString() + ', but the action name (' + actionName + ') was not a string.', _emberMetal.isNone(actionName) || typeof actionName === 'string' || typeof actionName === 'function'); + return actionName; + } - _StatementSyntax2.call(this); - this.value = value; - this.trustingMorph = trustingMorph; + /** + @class ActionSupport + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create({ + /** + Calls an action passed to a component. + For example a component for playing or pausing music may translate click events + into action notifications of "play" or "stop" depending on some internal state + of the component: + ```javascript + // app/components/play-button.js + export default Ember.Component.extend({ + click() { + if (this.get('isPlaying')) { + this.sendAction('play'); + } else { + this.sendAction('stop'); + } } - - Append.fromSpec = function fromSpec(sexp) { - var value = sexp[1]; - var trustingMorph = sexp[2]; - - return new OptimizedAppend({ value: _glimmerRuntimeLibSyntaxExpressions.default(value), trustingMorph: trustingMorph }); - }; - - return Append; - })(_glimmerRuntimeLibSyntax.Statement); - - exports.Append = Append; - - var OptimizedAppend = (function (_Append) { - babelHelpers.inherits(OptimizedAppend, _Append); - - function OptimizedAppend() { - _Append.apply(this, arguments); - this.type = "optimized-append"; + }); + ``` + The actions "play" and "stop" must be passed to this `play-button` component: + ```handlebars + {{! app/templates/application.hbs }} + {{play-button play=(action "musicStarted") stop=(action "musicStopped")}} + ``` + When the component receives a browser `click` event it translate this + interaction into application-specific semantics ("play" or "stop") and + calls the specified action. + ```javascript + // app/controller/application.js + export default Ember.Controller.extend({ + actions: { + musicStarted() { + // called when the play button is clicked + // and the music started playing + }, + musicStopped() { + // called when the play button is clicked + // and the music stopped playing + } + } + }); + ``` + If no action is passed to `sendAction` a default name of "action" + is assumed. + ```javascript + // app/components/next-button.js + export default Ember.Component.extend({ + click() { + this.sendAction(); + } + }); + ``` + ```handlebars + {{! app/templates/application.hbs }} + {{next-button action=(action "playNextSongInAlbum")}} + ``` + ```javascript + // app/controllers/application.js + App.ApplicationController = Ember.Controller.extend({ + actions: { + playNextSongInAlbum() { + ... + } } + }); + ``` + @method sendAction + @param [action] {String} the action to call + @param [params] {*} arguments for the action + @public + */ + sendAction: function (action) { + for (var _len = arguments.length, contexts = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + contexts[_key - 1] = arguments[_key]; + } - OptimizedAppend.prototype.deopt = function deopt() { - return new UnoptimizedAppend(this); - }; + var actionName = undefined; - OptimizedAppend.prototype.compile = function compile(compiler, env, symbolTable) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(this.value.compile(compiler, env, symbolTable))); - if (this.trustingMorph) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedTrustingAppendOpcode()); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedCautiousAppendOpcode()); - } - }; + // Send the default action + if (action === undefined) { + action = 'action'; + } + actionName = _emberMetal.get(this, 'attrs.' + action) || _emberMetal.get(this, action); + actionName = validateAction(this, actionName); + + // If no action name for that action could be found, just abort. + if (actionName === undefined) { + return; + } - return OptimizedAppend; - })(Append); + if (typeof actionName === 'function') { + actionName.apply(undefined, contexts); + } else { + this.triggerAction({ + action: actionName, + actionContext: contexts + }); + } + }, - exports.OptimizedAppend = OptimizedAppend; + send: function (actionName) { + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } - var UnoptimizedAppend = (function (_Append2) { - babelHelpers.inherits(UnoptimizedAppend, _Append2); + var action = this.actions && this.actions[actionName]; - function UnoptimizedAppend() { - _Append2.apply(this, arguments); - this.type = "unoptimized-append"; + if (action) { + var shouldBubble = action.apply(this, args) === true; + if (!shouldBubble) { + return; } + } - UnoptimizedAppend.prototype.compile = function compile(compiler, env, symbolTable) { - var expression = this.value.compile(compiler, env, symbolTable); - if (this.trustingMorph) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.GuardedTrustingAppendOpcode(expression, symbolTable)); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.GuardedCautiousAppendOpcode(expression, symbolTable)); - } - }; + var target = _emberMetal.get(this, 'target'); + if (target) { + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); + target.send.apply(target, arguments); + } else { + _emberMetal.assert(_emberUtils.inspect(this) + ' had no action handler for: ' + actionName, action); + } + } + }); +}); +enifed('ember-views/mixins/child_views_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/system/utils'], function (exports, _emberUtils, _emberMetal, _emberViewsSystemUtils) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; + + exports.default = _emberMetal.Mixin.create({ + init: function () { + this._super.apply(this, arguments); + _emberViewsSystemUtils.initChildViews(this); + }, - return UnoptimizedAppend; - })(Append); + /** + Array of child views. You should never edit this array directly. + @property childViews + @type Array + @default [] + @private + */ + childViews: _emberMetal.descriptor({ + configurable: false, + enumerable: false, + get: function () { + return _emberViewsSystemUtils.getChildViews(this); + } + }), - exports.UnoptimizedAppend = UnoptimizedAppend; + appendChild: function (view) { + this.linkChild(view); + _emberViewsSystemUtils.addChildView(this, view); + }, - var MODIFIER_SYNTAX = "c0420397-8ff1-4241-882b-4b7a107c9632"; + linkChild: function (instance) { + if (!_emberUtils.getOwner(instance)) { + _emberUtils.setOwner(instance, _emberUtils.getOwner(this)); + } + } + }); +}); +enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ - var Modifier = (function (_StatementSyntax3) { - babelHelpers.inherits(Modifier, _StatementSyntax3); + 'use strict'; - function Modifier(options) { - _StatementSyntax3.call(this); - this["c0420397-8ff1-4241-882b-4b7a107c9632"] = true; - this.type = "modifier"; - this.path = options.path; - this.args = options.args; - } + var EMPTY_ARRAY = Object.freeze([]); - Modifier.fromSpec = function fromSpec(node) { - var path = node[1]; - var params = node[2]; - var hash = node[3]; + /** + @class ClassNamesSupport + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create({ + concatenatedProperties: ['classNames', 'classNameBindings'], - return new Modifier({ - path: path, - args: Args.fromSpec(params, hash, EMPTY_BLOCKS) - }); - }; + init: function () { + this._super.apply(this, arguments); - Modifier.build = function build(path, options) { - return new Modifier({ - path: path, - params: options.params, - hash: options.hash - }); - }; + _emberMetal.assert('Only arrays are allowed for \'classNameBindings\'', Array.isArray(this.classNameBindings)); + _emberMetal.assert('Only arrays of static class strings are allowed for \'classNames\'. For dynamic classes, use \'classNameBindings\'.', Array.isArray(this.classNames)); + }, - Modifier.prototype.compile = function compile(compiler, env, symbolTable) { - var args = this.args.compile(compiler, env, symbolTable); - if (env.hasModifier(this.path, symbolTable)) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.ModifierOpcode(this.path[0], env.lookupModifier(this.path, symbolTable), args)); - } else { - throw new Error('Compile Error: ' + this.path.join('.') + ' is not a modifier'); - } - }; + /** + Standard CSS class names to apply to the view's outer element. This + property automatically inherits any class names defined by the view's + superclasses as well. + @property classNames + @type Array + @default ['ember-view'] + @public + */ + classNames: EMPTY_ARRAY, - return Modifier; - })(_glimmerRuntimeLibSyntax.Statement); + /** + A list of properties of the view to apply as class names. If the property + is a string value, the value of that string will be applied as a class + name. + ```javascript + // Applies the 'high' class to the view element + Ember.Component.extend({ + classNameBindings: ['priority'], + priority: 'high' + }); + ``` + If the value of the property is a Boolean, the name of that property is + added as a dasherized class name. + ```javascript + // Applies the 'is-urgent' class to the view element + Ember.Component.extend({ + classNameBindings: ['isUrgent'], + isUrgent: true + }); + ``` + If you would prefer to use a custom value instead of the dasherized + property name, you can pass a binding like this: + ```javascript + // Applies the 'urgent' class to the view element + Ember.Component.extend({ + classNameBindings: ['isUrgent:urgent'], + isUrgent: true + }); + ``` + This list of properties is inherited from the component's superclasses as well. + @property classNameBindings + @type Array + @default [] + @public + */ + classNameBindings: EMPTY_ARRAY + }); +}); +enifed('ember-views/mixins/text_support', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + /** + @module ember + @submodule ember-views + */ - exports.Modifier = Modifier; + 'use strict'; - var StaticArg = (function (_ArgumentSyntax) { - babelHelpers.inherits(StaticArg, _ArgumentSyntax); + var KEY_EVENTS = { + 13: 'insertNewline', + 27: 'cancel' + }; - function StaticArg(name, value) { - _ArgumentSyntax.call(this); - this.name = name; - this.value = value; - this.type = "static-arg"; - } + /** + `TextSupport` is a shared mixin used by both `Ember.TextField` and + `Ember.TextArea`. `TextSupport` adds a number of methods that allow you to + specify a controller action to invoke when a certain event is fired on your + text field or textarea. The specifed controller action would get the current + value of the field passed in as the only argument unless the value of + the field is empty. In that case, the instance of the field itself is passed + in as the only argument. + + Let's use the pressing of the escape key as an example. If you wanted to + invoke a controller action when a user presses the escape key while on your + field, you would use the `escape-press` attribute on your field like so: + + ```handlebars + {{! application.hbs}} + + {{input escape-press='alertUser'}} + ``` + + ```javascript + App = Ember.Application.create(); + + App.ApplicationController = Ember.Controller.extend({ + actions: { + alertUser: function ( currentValue ) { + alert( 'escape pressed, current value: ' + currentValue ); + } + } + }); + ``` + + The following chart is a visual representation of what takes place when the + escape key is pressed in this scenario: + + ``` + The Template + +---------------------------+ + | | + | escape-press='alertUser' | + | | TextSupport Mixin + +----+----------------------+ +-------------------------------+ + | | cancel method | + | escape button pressed | | + +-------------------------------> | checks for the `escape-press` | + | attribute and pulls out the | + +-------------------------------+ | `alertUser` value | + | action name 'alertUser' +-------------------------------+ + | sent to controller + v + Controller + +------------------------------------------ + + | | + | actions: { | + | alertUser: function( currentValue ){ | + | alert( 'the esc key was pressed!' ) | + | } | + | } | + | | + +-------------------------------------------+ + ``` + + Here are the events that we currently support along with the name of the + attribute you would need to use on your field. To reiterate, you would use the + attribute name like so: + + ```handlebars + {{input attribute-name='controllerAction'}} + ``` + + ``` + +--------------------+----------------+ + | | | + | event | attribute name | + +--------------------+----------------+ + | new line inserted | insert-newline | + | | | + | enter key pressed | insert-newline | + | | | + | cancel key pressed | escape-press | + | | | + | focusin | focus-in | + | | | + | focusout | focus-out | + | | | + | keypress | key-press | + | | | + | keyup | key-up | + | | | + | keydown | key-down | + +--------------------+----------------+ + ``` + + @class TextSupport + @namespace Ember + @uses Ember.TargetActionSupport + @extends Ember.Mixin + @private + */ + exports.default = _emberMetal.Mixin.create(_emberRuntime.TargetActionSupport, { + value: '', - StaticArg.fromSpec = function fromSpec(node) { - var name = node[1]; - var value = node[2]; + attributeBindings: ['autocapitalize', 'autocorrect', 'autofocus', 'disabled', 'form', 'maxlength', 'placeholder', 'readonly', 'required', 'selectionDirection', 'spellcheck', 'tabindex', 'title'], + placeholder: null, + disabled: false, + maxlength: null, - return new StaticArg(name, value); - }; + init: function () { + this._super.apply(this, arguments); + this.on('paste', this, this._elementValueDidChange); + this.on('cut', this, this._elementValueDidChange); + this.on('input', this, this._elementValueDidChange); + }, - StaticArg.build = function build(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + /** + The action to be sent when the user presses the return key. + This is similar to the `{{action}}` helper, but is fired when + the user presses the return key when editing a text field, and sends + the value of the field as the context. + @property action + @type String + @default null + @private + */ + action: null, - return new this(name, value); - }; + /** + The event that should send the action. + Options are: + * `enter`: the user pressed enter + * `keyPress`: the user pressed a key + @property onEvent + @type String + @default enter + @private + */ + onEvent: 'enter', - StaticArg.prototype.compile = function compile() { - throw new Error('Cannot compiler StaticArg "' + this.name + '" as it is a delegate for ValueSyntax.'); - }; + /** + Whether the `keyUp` event that triggers an `action` to be sent continues + propagating to other views. + By default, when the user presses the return key on their keyboard and + the text field has an `action` set, the action will be sent to the view's + controller and the key event will stop propagating. + If you would like parent views to receive the `keyUp` event even after an + action has been dispatched, set `bubbles` to true. + @property bubbles + @type Boolean + @default false + @private + */ + bubbles: false, - StaticArg.prototype.valueSyntax = function valueSyntax() { - return Value.build(this.value); - }; + interpretKeyEvents: function (event) { + var map = KEY_EVENTS; + var method = map[event.keyCode]; - return StaticArg; - })(_glimmerRuntimeLibSyntax.Argument); + this._elementValueDidChange(); + if (method) { + return this[method](event); + } + }, - exports.StaticArg = StaticArg; + _elementValueDidChange: function () { + _emberMetal.set(this, 'value', this.element.value); + }, - var DynamicArg = (function (_ArgumentSyntax2) { - babelHelpers.inherits(DynamicArg, _ArgumentSyntax2); + change: function (event) { + this._elementValueDidChange(event); + }, - function DynamicArg(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + /** + Allows you to specify a controller action to invoke when either the `enter` + key is pressed or, in the case of the field being a textarea, when a newline + is inserted. To use this method, give your field an `insert-newline` + attribute. The value of that attribute should be the name of the action + in your controller that you wish to invoke. + For an example on how to use the `insert-newline` attribute, please + reference the example near the top of this file. + @method insertNewline + @param {Event} event + @private + */ + insertNewline: function (event) { + sendAction('enter', this, event); + sendAction('insert-newline', this, event); + }, - _ArgumentSyntax2.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this.type = 'dynamic-arg'; - } + /** + Allows you to specify a controller action to invoke when the escape button + is pressed. To use this method, give your field an `escape-press` + attribute. The value of that attribute should be the name of the action + in your controller that you wish to invoke. + For an example on how to use the `escape-press` attribute, please reference + the example near the top of this file. + @method cancel + @param {Event} event + @private + */ + cancel: function (event) { + sendAction('escape-press', this, event); + }, - DynamicArg.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; + /** + Allows you to specify a controller action to invoke when a field receives + focus. To use this method, give your field a `focus-in` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `focus-in` attribute, please reference the + example near the top of this file. + @method focusIn + @param {Event} event + @private + */ + focusIn: function (event) { + sendAction('focus-in', this, event); + }, - return new DynamicArg(name, _glimmerRuntimeLibSyntaxExpressions.default(value)); - }; + /** + Allows you to specify a controller action to invoke when a field loses + focus. To use this method, give your field a `focus-out` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `focus-out` attribute, please reference the + example near the top of this file. + @method focusOut + @param {Event} event + @private + */ + focusOut: function (event) { + this._elementValueDidChange(event); + sendAction('focus-out', this, event); + }, - DynamicArg.build = function build(name, value) { - return new this(name, value); - }; + /** + Allows you to specify a controller action to invoke when a key is pressed. + To use this method, give your field a `key-press` attribute. The value of + that attribute should be the name of the action in your controller you + that wish to invoke. + For an example on how to use the `key-press` attribute, please reference the + example near the top of this file. + @method keyPress + @param {Event} event + @private + */ + keyPress: function (event) { + sendAction('key-press', this, event); + }, - DynamicArg.prototype.compile = function compile() { - throw new Error('Cannot compile DynamicArg for "' + this.name + '" as it is delegate for ExpressionSyntax.'); - }; + /** + Allows you to specify a controller action to invoke when a key-up event is + fired. To use this method, give your field a `key-up` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `key-up` attribute, please reference the + example near the top of this file. + @method keyUp + @param {Event} event + @private + */ + keyUp: function (event) { + this.interpretKeyEvents(event); - DynamicArg.prototype.valueSyntax = function valueSyntax() { - return this.value; - }; + this.sendAction('key-up', _emberMetal.get(this, 'value'), event); + }, - return DynamicArg; - })(_glimmerRuntimeLibSyntax.Argument); + /** + Allows you to specify a controller action to invoke when a key-down event is + fired. To use this method, give your field a `key-down` attribute. The value + of that attribute should be the name of the action in your controller that + you wish to invoke. + For an example on how to use the `key-down` attribute, please reference the + example near the top of this file. + @method keyDown + @param {Event} event + @private + */ + keyDown: function (event) { + this.sendAction('key-down', _emberMetal.get(this, 'value'), event); + } + }); - exports.DynamicArg = DynamicArg; + // In principle, this shouldn't be necessary, but the legacy + // sendAction semantics for TextField are different from + // the component semantics so this method normalizes them. + function sendAction(eventName, view, event) { + var action = _emberMetal.get(view, 'attrs.' + eventName) || _emberMetal.get(view, eventName); + var on = _emberMetal.get(view, 'onEvent'); + var value = _emberMetal.get(view, 'value'); - var TrustingAttr = (function () { - function TrustingAttr() {} + // back-compat support for keyPress as an event name even though + // it's also a method name that consumes the event (and therefore + // incompatible with sendAction semantics). + if (on === eventName || on === 'keyPress' && eventName === 'key-press') { + view.sendAction('action', value); + } - TrustingAttr.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; - var namespace = sexp[3]; + view.sendAction(eventName, value); - return new DynamicAttr(name, _glimmerRuntimeLibSyntaxExpressions.default(value), namespace, true); - }; + if (action || on === eventName) { + if (!_emberMetal.get(view, 'bubbles')) { + event.stopPropagation(); + } + } + } +}); +enifed('ember-views/mixins/view_state_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - TrustingAttr.build = function build(name, value, isTrusting) { - var namespace = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + exports.default = _emberMetal.Mixin.create({ + _transitionTo: function (state) { + var priorState = this._currentState; + var currentState = this._currentState = this._states[state]; + this._state = state; - return new DynamicAttr(name, value, namespace, isTrusting); - }; + if (priorState && priorState.exit) { + priorState.exit(this); + } + if (currentState.enter) { + currentState.enter(this); + } + } + }); +}); +enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-views/system/utils', 'ember-runtime/system/core_object', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberViewsSystemUtils, _emberRuntimeSystemCore_object, _emberViewsSystemJquery) { + 'use strict'; - TrustingAttr.prototype.compile = function compile() { - throw new Error('Attempting to compile a TrustingAttr which is just a delegate for DynamicAttr.'); - }; + var _Mixin$create; - return TrustingAttr; - })(); + function K() { + return this; + } - exports.TrustingAttr = TrustingAttr; + var dispatchLifeCycleHook = function (component, hook, oldAttrs, newAttrs) { + component.trigger(hook, { attrs: newAttrs, oldAttrs: oldAttrs, newAttrs: newAttrs }); + }; - var StaticAttr = (function (_AttributeSyntax) { - babelHelpers.inherits(StaticAttr, _AttributeSyntax); + exports.dispatchLifeCycleHook = dispatchLifeCycleHook; + _emberMetal.runInDebug(function () { + var Attrs = (function () { + function Attrs(oldAttrs, newAttrs, message) { + babelHelpers.classCallCheck(this, Attrs); + + this._oldAttrs = oldAttrs; + this._newAttrs = newAttrs; + this._message = message; + } + + babelHelpers.createClass(Attrs, [{ + key: 'attrs', + get: function () { + return this.newAttrs; + } + }, { + key: 'oldAttrs', + get: function () { + _emberMetal.deprecate(this._message, false, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - function StaticAttr(name, value, namespace) { - _AttributeSyntax.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - this.type = "static-attr"; - this.isTrusting = false; + return this._oldAttrs; } + }, { + key: 'newAttrs', + get: function () { + _emberMetal.deprecate(this._message, false, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - StaticAttr.fromSpec = function fromSpec(node) { - var name = node[1]; - var value = node[2]; - var namespace = node[3]; - - return new StaticAttr(name, value, namespace); - }; - - StaticAttr.build = function build(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - - return new this(name, value, namespace); - }; + return this._newAttrs; + } + }]); + return Attrs; + })(); - StaticAttr.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.StaticAttrOpcode(this.namespace, this.name, this.value)); - }; + exports.dispatchLifeCycleHook = dispatchLifeCycleHook = function (component, hook, oldAttrs, newAttrs) { + if (typeof component[hook] === 'function' && component[hook].length !== 0) { + // Already warned in init + component.trigger(hook, { attrs: newAttrs, oldAttrs: oldAttrs, newAttrs: newAttrs }); + } else { + component.trigger(hook, new Attrs(oldAttrs, newAttrs, '[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + component.toString() + '#' + hook + '` to stop taking arguments.')); + } + }; + }); - StaticAttr.prototype.valueSyntax = function valueSyntax() { - return Value.build(this.value); - }; + /** + @class ViewMixin + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create((_Mixin$create = { + concatenatedProperties: ['attributeBindings'] + }, _Mixin$create[_emberRuntimeSystemCore_object.POST_INIT] = function () { + dispatchLifeCycleHook(this, 'didInitAttrs', undefined, this.attrs); + dispatchLifeCycleHook(this, 'didReceiveAttrs', undefined, this.attrs); + }, _Mixin$create.nearestOfType = function (klass) { + var view = this.parentView; + var isOfType = klass instanceof _emberMetal.Mixin ? function (view) { + return klass.detect(view); + } : function (view) { + return klass.detect(view.constructor); + }; - return StaticAttr; - })(_glimmerRuntimeLibSyntax.Attribute); + while (view) { + if (isOfType(view)) { + return view; + } + view = view.parentView; + } + }, _Mixin$create.nearestWithProperty = function (property) { + var view = this.parentView; - exports.StaticAttr = StaticAttr; + while (view) { + if (property in view) { + return view; + } + view = view.parentView; + } + }, _Mixin$create.rerender = function () { + return this._currentState.rerender(this); + }, _Mixin$create.element = _emberMetal.descriptor({ + configurable: false, + enumerable: false, + get: function () { + return this.renderer.getElement(this); + } + }), _Mixin$create.$ = function (sel) { + _emberMetal.assert('You cannot access this.$() on a component with `tagName: \'\'` specified.', this.tagName !== ''); + if (this.element) { + return sel ? _emberViewsSystemJquery.default(sel, this.element) : _emberViewsSystemJquery.default(this.element); + } + }, _Mixin$create.appendTo = function (selector) { + var env = this._environment || _emberEnvironment.environment; + var target = undefined; - var DynamicAttr = (function (_AttributeSyntax2) { - babelHelpers.inherits(DynamicAttr, _AttributeSyntax2); + if (env.hasDOM) { + target = typeof selector === 'string' ? document.querySelector(selector) : selector; - function DynamicAttr(name, value, namespace, isTrusting) { - if (namespace === undefined) namespace = undefined; + _emberMetal.assert('You tried to append to (' + selector + ') but that isn\'t in the DOM', target); + _emberMetal.assert('You cannot append to an existing Ember.View.', !_emberViewsSystemUtils.matches(target, '.ember-view')); + _emberMetal.assert('You cannot append to an existing Ember.View.', (function () { + var node = target.parentNode; + while (node) { + if (node.nodeType !== 9 && _emberViewsSystemUtils.matches(node, '.ember-view')) { + return false; + } - _AttributeSyntax2.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this.isTrusting = isTrusting; - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - this.type = "dynamic-attr"; + node = node.parentNode; } - DynamicAttr.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; - var namespace = sexp[3]; + return true; + })()); + } else { + target = selector; - return new DynamicAttr(name, _glimmerRuntimeLibSyntaxExpressions.default(value), namespace); - }; + _emberMetal.assert('You tried to append to a selector string (' + selector + ') in an environment without jQuery', typeof target !== 'string'); + _emberMetal.assert('You tried to append to a non-Element (' + selector + ') in an environment without jQuery', typeof selector.appendChild === 'function'); + } - DynamicAttr.build = function build(name, value) { - var isTrusting = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; - var namespace = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + this.renderer.appendTo(this, target); - return new this(name, value, namespace, isTrusting); - }; + return this; + }, _Mixin$create.renderToElement = function () { + var tagName = arguments.length <= 0 || arguments[0] === undefined ? 'body' : arguments[0]; + + _emberMetal.deprecate('Using the `renderToElement` is deprecated in favor of `appendTo`. Called in ' + this.toString(), false, { + id: 'ember-views.render-to-element', + until: '2.12.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_code-rendertoelement-code' + }); - DynamicAttr.prototype.compile = function compile(compiler, env, symbolTable) { - var namespace = this.namespace; - var value = this.value; + var element = this.renderer.createElement(tagName); - compiler.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(value.compile(compiler, env, symbolTable))); - if (namespace) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrNSOpcode(this.name, this.namespace, this.isTrusting)); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrOpcode(this.name, this.isTrusting)); - } - }; + this.renderer.appendTo(this, element); + return element; + }, _Mixin$create.replaceIn = function (selector) { + var target = _emberViewsSystemJquery.default(selector); - DynamicAttr.prototype.valueSyntax = function valueSyntax() { - return this.value; - }; + _emberMetal.assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0); + _emberMetal.assert('You cannot replace an existing Ember.View.', !target.is('.ember-view') && !target.parents().is('.ember-view')); - return DynamicAttr; - })(_glimmerRuntimeLibSyntax.Attribute); + this.renderer.replaceIn(this, target[0]); - exports.DynamicAttr = DynamicAttr; + return this; + }, _Mixin$create.append = function () { + return this.appendTo(document.body); + }, _Mixin$create.elementId = null, _Mixin$create.findElementInParentElement = function (parentElem) { + var id = '#' + this.elementId; + return _emberViewsSystemJquery.default(id)[0] || _emberViewsSystemJquery.default(id, parentElem)[0]; + }, _Mixin$create.willInsertElement = K, _Mixin$create.didInsertElement = K, _Mixin$create.willClearRender = K, _Mixin$create.destroy = function () { + this._super.apply(this, arguments); + this._currentState.destroy(this); + }, _Mixin$create.willDestroyElement = K, _Mixin$create.parentViewDidChange = K, _Mixin$create.tagName = null, _Mixin$create.init = function () { + this._super.apply(this, arguments); - var FlushElement = (function (_StatementSyntax4) { - babelHelpers.inherits(FlushElement, _StatementSyntax4); + if (!this.elementId && this.tagName !== '') { + this.elementId = _emberUtils.guidFor(this); + } - function FlushElement() { - _StatementSyntax4.apply(this, arguments); - this.type = "flush-element"; - } + // if we find an `eventManager` property, deopt the + // `EventDispatcher`'s `canDispatchToEventManager` property + // if `null` + if (this.eventManager) { + var owner = _emberUtils.getOwner(this); + var dispatcher = owner && owner.lookup('event_dispatcher:main'); - FlushElement.fromSpec = function fromSpec() { - return new FlushElement(); - }; + if (dispatcher && dispatcher.canDispatchToEventManager === null) { + dispatcher.canDispatchToEventManager = true; + } + } - FlushElement.build = function build() { - return new this(); - }; + _emberMetal.deprecate('[DEPRECATED] didInitAttrs called in ' + this.toString() + '.', typeof this.didInitAttrs !== 'function', { + id: 'ember-views.did-init-attrs', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' + }); - FlushElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.FlushElementOpcode()); - }; + _emberMetal.deprecate('[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + this.toString() + '#didInitAttrs` to stop taking arguments.', typeof this.didInitAttrs !== 'function' || this.didInitAttrs.length === 0, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - return FlushElement; - })(_glimmerRuntimeLibSyntax.Statement); + _emberMetal.deprecate('[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + this.toString() + '#didReceiveAttrs` to stop taking arguments.', typeof this.didReceiveAttrs !== 'function' || this.didReceiveAttrs.length === 0, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - exports.FlushElement = FlushElement; + _emberMetal.deprecate('[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + this.toString() + '#didUpdateAttrs` to stop taking arguments.', typeof this.didUpdateAttrs !== 'function' || this.didUpdateAttrs.length === 0, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - var CloseElement = (function (_StatementSyntax5) { - babelHelpers.inherits(CloseElement, _StatementSyntax5); + _emberMetal.assert('Using a custom `.render` function is no longer supported.', !this.render); + }, _Mixin$create.__defineNonEnumerable = function (property) { + this[property.name] = property.descriptor.value; + }, _Mixin$create.handleEvent = function (eventName, evt) { + return this._currentState.handleEvent(this, eventName, evt); + }, _Mixin$create)); +}); - function CloseElement() { - _StatementSyntax5.apply(this, arguments); - this.type = "close-element"; - } +// .......................................................... +// TEMPLATE SUPPORT +// - CloseElement.fromSpec = function fromSpec() { - return new CloseElement(); - }; +/** + Return the nearest ancestor that is an instance of the provided + class or mixin. + @method nearestOfType + @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself), + or an instance of Ember.Mixin. + @return Ember.View + @deprecated use `yield` and contextual components for composition instead. + @private +*/ - CloseElement.build = function build() { - return new this(); - }; +/** + Return the nearest ancestor that has a given property. + @method nearestWithProperty + @param {String} property A property name + @return Ember.View + @deprecated use `yield` and contextual components for composition instead. + @private +*/ - CloseElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.CloseElementOpcode()); - }; +/** + Renders the view again. This will work regardless of whether the + view is already in the DOM or not. If the view is in the DOM, the + rendering process will be deferred to give bindings a chance + to synchronize. + If children were added during the rendering process using `appendChild`, + `rerender` will remove them, because they will be added again + if needed by the next `render`. + In general, if the display of your view changes, you should modify + the DOM element directly instead of manually calling `rerender`, which can + be slow. + @method rerender + @public +*/ - return CloseElement; - })(_glimmerRuntimeLibSyntax.Statement); +// .......................................................... +// ELEMENT SUPPORT +// - exports.CloseElement = CloseElement; +/** + Returns the current DOM element for the view. + @property element + @type DOMElement + @public +*/ - var Text = (function (_StatementSyntax6) { - babelHelpers.inherits(Text, _StatementSyntax6); +/** + Returns a jQuery object for this view's element. If you pass in a selector + string, this method will return a jQuery object, using the current element + as its buffer. + For example, calling `view.$('li')` will return a jQuery object containing + all of the `li` elements inside the DOM element of this view. + @method $ + @param {String} [selector] a jQuery-compatible selector string + @return {jQuery} the jQuery object for the DOM node + @public +*/ - function Text(content) { - _StatementSyntax6.call(this); - this.content = content; - this.type = "text"; - } +/** + Appends the view's element to the specified parent element. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing. + This is not typically a function that you will need to call directly when + building your application. If you do need to use `appendTo`, be sure that + the target element you are providing is associated with an `Ember.Application` + and does not have an ancestor element that is associated with an Ember view. + @method appendTo + @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object + @return {Ember.View} receiver + @private +*/ - Text.fromSpec = function fromSpec(node) { - var content = node[1]; +/** + Creates a new DOM element, renders the view into it, then returns the + element. + By default, the element created and rendered into will be a `BODY` element, + since this is the default context that views are rendered into when being + inserted directly into the DOM. + ```js + let element = view.renderToElement(); + element.tagName; // => "BODY" + ``` + You can override the kind of element rendered into and returned by + specifying an optional tag name as the first argument. + ```js + let element = view.renderToElement('table'); + element.tagName; // => "TABLE" + ``` + This method is useful if you want to render the view into an element that + is not in the document's body. Instead, a new `body` element, detached from + the DOM is returned. FastBoot uses this to serialize the rendered view into + a string for transmission over the network. + ```js + app.visit('/').then(function(instance) { + let element; + Ember.run(function() { + element = renderToElement(instance); + }); + res.send(serialize(element)); + }); + ``` + @method renderToElement + @param {String} tagName The tag of the element to create and render into. Defaults to "body". + @return {HTMLBodyElement} element + @deprecated Use appendTo instead. + @private +*/ - return new Text(content); - }; +/** + Replaces the content of the specified parent element with this view's + element. If the view does not have an HTML representation yet, + the element will be generated automatically. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing + @method replaceIn + @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object + @return {Ember.View} received + @private +*/ - Text.build = function build(content) { - return new this(content); - }; +/** + Appends the view's element to the document body. If the view does + not have an HTML representation yet + the element will be generated automatically. + If your application uses the `rootElement` property, you must append + the view within that element. Rendering views outside of the `rootElement` + is not supported. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the document body until all bindings have + finished synchronizing. + @method append + @return {Ember.View} receiver + @private +*/ - Text.prototype.compile = function compile(dsl) { - dsl.text(this.content); - }; +/** + The HTML `id` of the view's element in the DOM. You can provide this + value yourself but it must be unique (just as in HTML): + ```handlebars + {{my-component elementId="a-really-cool-id"}} + ``` + If not manually set a default value will be provided by the framework. + Once rendered an element's `elementId` is considered immutable and you + should never change it. If you need to compute a dynamic value for the + `elementId`, you should do this when the component or element is being + instantiated: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + let index = this.get('index'); + this.set('elementId', 'component-id' + index); + } + }); + ``` + @property elementId + @type String + @public +*/ - return Text; - })(_glimmerRuntimeLibSyntax.Statement); +/** + Attempts to discover the element in the parent element. The default + implementation looks for an element with an ID of `elementId` (or the + view's guid if `elementId` is null). You can override this method to + provide your own form of lookup. For example, if you want to discover your + element using a CSS class name instead of an ID. + @method findElementInParentElement + @param {DOMElement} parentElement The parent's DOM element + @return {DOMElement} The discovered element + @private +*/ - exports.Text = Text; +/** + Called when a view is going to insert an element into the DOM. + @event willInsertElement + @public +*/ - var Comment = (function (_StatementSyntax7) { - babelHelpers.inherits(Comment, _StatementSyntax7); +/** + Called when the element of the view has been inserted into the DOM. + Override this function to do any set up that requires an element + in the document body. + When a view has children, didInsertElement will be called on the + child view(s) first and on itself afterwards. + @event didInsertElement + @public +*/ - function Comment(comment) { - _StatementSyntax7.call(this); - this.comment = comment; - this.type = "comment"; - } +/** + Called when the view is about to rerender, but before anything has + been torn down. This is a good opportunity to tear down any manual + observers you have installed based on the DOM state + @event willClearRender + @public +*/ - Comment.fromSpec = function fromSpec(sexp) { - var value = sexp[1]; +/** + You must call `destroy` on a view to destroy the view (and all of its + child views). This will remove the view from any parent node, then make + sure that the DOM element managed by the view can be released by the + memory manager. + @method destroy + @private +*/ - return new Comment(value); - }; +/** + Called when the element of the view is going to be destroyed. Override + this function to do any teardown that requires an element, like removing + event listeners. + Please note: any property changes made during this event will have no + effect on object observers. + @event willDestroyElement + @public +*/ - Comment.build = function build(value) { - return new this(value); - }; +/** + Called when the parentView property has changed. + @event parentViewDidChange + @private +*/ - Comment.prototype.compile = function compile(dsl) { - dsl.comment(this.comment); - }; +// .......................................................... +// STANDARD RENDER PROPERTIES +// - return Comment; - })(_glimmerRuntimeLibSyntax.Statement); +/** + Tag name for the view's outer element. The tag name is only used when an + element is first created. If you change the `tagName` for an element, you + must destroy and recreate the view element. + By default, the render buffer will use a `
    ` tag for views. + @property tagName + @type String + @default null + @public +*/ - exports.Comment = Comment; +// We leave this null by default so we can tell the difference between +// the default case and a user-specified tag. - var OpenElement = (function (_StatementSyntax8) { - babelHelpers.inherits(OpenElement, _StatementSyntax8); +// ....................................................... +// CORE DISPLAY METHODS +// - function OpenElement(tag, blockParams, symbolTable) { - _StatementSyntax8.call(this); - this.tag = tag; - this.blockParams = blockParams; - this.symbolTable = symbolTable; - this.type = "open-element"; - } +/** + Setup a view, but do not finish waking it up. + * configure `childViews` + * register the view with the global views hash, which is used for event + dispatch + @method init + @private +*/ - OpenElement.fromSpec = function fromSpec(sexp, symbolTable) { - var tag = sexp[1]; - var blockParams = sexp[2]; +// ....................................................... +// EVENT HANDLING +// - return new OpenElement(tag, blockParams, symbolTable); - }; +/** + Handle events from `Ember.EventDispatcher` + @method handleEvent + @param eventName {String} + @param evt {Event} + @private +*/ +enifed("ember-views/system/action_manager", ["exports"], function (exports) { + /** + @module ember + @submodule ember-views + */ - OpenElement.build = function build(tag, blockParams, symbolTable) { - return new this(tag, blockParams, symbolTable); - }; + "use strict"; - OpenElement.prototype.scan = function scan(scanner) { - var tag = this.tag; + exports.default = ActionManager; - if (scanner.env.hasComponentDefinition([tag], this.symbolTable)) { - var _parameters = this.parameters(scanner); + function ActionManager() {} - var args = _parameters.args; - var attrs = _parameters.attrs; + /** + Global action id hash. + + @private + @property registeredActions + @type Object + */ + ActionManager.registeredActions = {}; +}); +enifed('ember-views/system/event_dispatcher', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-environment', 'ember-views/compat/fallback-view-registry'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberViewsSystemJquery, _emberViewsSystemAction_manager, _emberEnvironment, _emberViewsCompatFallbackViewRegistry) { + /** + @module ember + @submodule ember-views + */ - scanner.startBlock(this.blockParams); - this.tagContents(scanner); - var template = scanner.endBlock(this.blockParams); - args.blocks = Blocks.fromSpec(template); - return new Component(tag, attrs, args); - } else { - return new OpenPrimitiveElement(tag); - } - }; + 'use strict'; - OpenElement.prototype.compile = function compile(list, env) { - list.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(this.tag)); - }; + var ROOT_ELEMENT_CLASS = 'ember-application'; + var ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; - OpenElement.prototype.toIdentity = function toIdentity() { - var tag = this.tag; + /** + `Ember.EventDispatcher` handles delegating browser events to their + corresponding `Ember.Views.` For example, when you click on a view, + `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets + called. + + @class EventDispatcher + @namespace Ember + @private + @extends Ember.Object + */ + exports.default = _emberRuntime.Object.extend({ - return new OpenPrimitiveElement(tag); - }; + /** + The set of events names (and associated handler function names) to be setup + and dispatched by the `EventDispatcher`. Modifications to this list can be done + at setup time, generally via the `Ember.Application.customEvents` hash. + To add new events to be listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + paste: 'paste' + } + }); + ``` + To prevent default events from being listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + mouseenter: null, + mouseleave: null + } + }); + ``` + @property events + @type Object + @private + */ + events: { + touchstart: 'touchStart', + touchmove: 'touchMove', + touchend: 'touchEnd', + touchcancel: 'touchCancel', + keydown: 'keyDown', + keyup: 'keyUp', + keypress: 'keyPress', + mousedown: 'mouseDown', + mouseup: 'mouseUp', + contextmenu: 'contextMenu', + click: 'click', + dblclick: 'doubleClick', + mousemove: 'mouseMove', + focusin: 'focusIn', + focusout: 'focusOut', + mouseenter: 'mouseEnter', + mouseleave: 'mouseLeave', + submit: 'submit', + input: 'input', + change: 'change', + dragstart: 'dragStart', + drag: 'drag', + dragenter: 'dragEnter', + dragleave: 'dragLeave', + dragover: 'dragOver', + drop: 'drop', + dragend: 'dragEnd' + }, - OpenElement.prototype.parameters = function parameters(scanner) { - var current = scanner.next(); - var attrs = []; - var argKeys = []; - var argValues = []; - while (!(current instanceof FlushElement)) { - if (current[MODIFIER_SYNTAX]) { - throw new Error('Compile Error: Element modifiers are not allowed in components'); - } - var param = current; - if (current[_glimmerRuntimeLibSyntax.ATTRIBUTE]) { - attrs.push(param.name); - // REMOVE ME: attributes should not be treated as args - argKeys.push(param.name); - argValues.push(param.valueSyntax()); - } else if (current[_glimmerRuntimeLibSyntax.ARGUMENT]) { - argKeys.push(param.name); - argValues.push(param.valueSyntax()); - } else { - throw new Error("Expected FlushElement, but got ${current}"); - } - current = scanner.next(); - } - return { args: Args.fromNamedArgs(NamedArgs.build(argKeys, argValues)), attrs: attrs }; - }; + /** + The root DOM element to which event listeners should be attached. Event + listeners will be attached to the document unless this is overridden. + Can be specified as a DOMElement or a selector string. + The default body is a string since this may be evaluated before document.body + exists in the DOM. + @private + @property rootElement + @type DOMElement + @default 'body' + */ + rootElement: 'body', - OpenElement.prototype.tagContents = function tagContents(scanner) { - var nesting = 1; - while (true) { - var current = scanner.next(); - if (current instanceof CloseElement && --nesting === 0) { - break; - } - scanner.addStatement(current); - if (current instanceof OpenElement || current instanceof OpenPrimitiveElement) { - nesting++; - } - } - }; + /** + It enables events to be dispatched to the view's `eventManager.` When present, + this object takes precedence over handling of events on the view itself. + Note that most Ember applications do not use this feature. If your app also + does not use it, consider setting this property to false to gain some performance + improvement by allowing the EventDispatcher to skip the search for the + `eventManager` on the view tree. + ```javascript + let EventDispatcher = Em.EventDispatcher.extend({ + events: { + click : 'click', + focusin : 'focusIn', + focusout : 'focusOut', + change : 'change' + }, + canDispatchToEventManager: false + }); + container.register('event_dispatcher:main', EventDispatcher); + ``` + @property canDispatchToEventManager + @type boolean + @default false + @since 1.7.0 + @private + */ + canDispatchToEventManager: null, - return OpenElement; - })(_glimmerRuntimeLibSyntax.Statement); + init: function () { + this._super(); + _emberMetal.assert('EventDispatcher should never be instantiated in fastboot mode. Please report this as an Ember bug.', _emberEnvironment.environment.hasDOM); + }, - exports.OpenElement = OpenElement; + /** + Sets up event listeners for standard browser events. + This will be called after the browser sends a `DOMContentReady` event. By + default, it will set up all of the listeners on the document body. If you + would like to register the listeners on a different element, set the event + dispatcher's `root` property. + @private + @method setup + @param addedEvents {Object} + */ + setup: function (addedEvents, rootElement) { + var event = undefined; + var events = this._finalEvents = _emberUtils.assign({}, _emberMetal.get(this, 'events'), addedEvents); - var Component = (function (_StatementSyntax9) { - babelHelpers.inherits(Component, _StatementSyntax9); + if (_emberMetal.isNone(rootElement)) { + rootElement = _emberMetal.get(this, 'rootElement'); + } else { + _emberMetal.set(this, 'rootElement', rootElement); + } - function Component(tag, attrs, args) { - _StatementSyntax9.call(this); - this.tag = tag; - this.attrs = attrs; - this.args = args; - this.type = 'component'; - } - - Component.prototype.compile = function compile(list, env, symbolTable) { - var definition = env.getComponentDefinition([this.tag], symbolTable); - var args = this.args.compile(list, env, symbolTable); - var shadow = this.attrs; - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutComponentDefinitionOpcode(definition)); - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.OpenComponentOpcode(args, shadow)); - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.CloseComponentOpcode()); - }; + rootElement = _emberViewsSystemJquery.default(rootElement); - return Component; - })(_glimmerRuntimeLibSyntax.Statement); + _emberMetal.assert('You cannot use the same root element (' + (rootElement.selector || rootElement[0].tagName) + ') multiple times in an Ember.Application', !rootElement.is(ROOT_ELEMENT_SELECTOR)); + _emberMetal.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length); + _emberMetal.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find(ROOT_ELEMENT_SELECTOR).length); - exports.Component = Component; + rootElement.addClass(ROOT_ELEMENT_CLASS); - var OpenPrimitiveElement = (function (_StatementSyntax10) { - babelHelpers.inherits(OpenPrimitiveElement, _StatementSyntax10); + if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) { + throw new TypeError('Unable to add \'' + ROOT_ELEMENT_CLASS + '\' class to root element (' + (rootElement.selector || rootElement[0].tagName) + '). Make sure you set rootElement to the body or an element in the body.'); + } - function OpenPrimitiveElement(tag) { - _StatementSyntax10.call(this); - this.tag = tag; - this.type = "open-primitive-element"; + for (event in events) { + if (events.hasOwnProperty(event)) { + this.setupHandler(rootElement, event, events[event]); } + } + }, - OpenPrimitiveElement.build = function build(tag) { - return new this(tag); - }; + /** + Registers an event listener on the rootElement. If the given event is + triggered, the provided event handler will be triggered on the target view. + If the target view does not implement the event handler, or if the handler + returns `false`, the parent view will be called. The event will continue to + bubble to each successive parent view until it reaches the top. + @private + @method setupHandler + @param {Element} rootElement + @param {String} event the browser-originated event to listen to + @param {String} eventName the name of the method to call on the view + */ + setupHandler: function (rootElement, event, eventName) { + var self = this; - OpenPrimitiveElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(this.tag)); - }; + var owner = _emberUtils.getOwner(this); + var viewRegistry = owner && owner.lookup('-view-registry:main') || _emberViewsCompatFallbackViewRegistry.default; - return OpenPrimitiveElement; - })(_glimmerRuntimeLibSyntax.Statement); + if (eventName === null) { + return; + } - exports.OpenPrimitiveElement = OpenPrimitiveElement; + rootElement.on(event + '.ember', '.ember-view', function (evt, triggeringManager) { + var view = viewRegistry[this.id]; + var result = true; - var Yield = (function (_StatementSyntax11) { - babelHelpers.inherits(Yield, _StatementSyntax11); + var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; - function Yield(to, args) { - _StatementSyntax11.call(this); - this.to = to; - this.args = args; - this.type = "yield"; + if (manager && manager !== triggeringManager) { + result = self._dispatchEvent(manager, evt, eventName, view); + } else if (view) { + result = self._bubbleEvent(view, evt, eventName); } - Yield.fromSpec = function fromSpec(sexp) { - var to = sexp[1]; - var params = sexp[2]; - - var args = Args.fromSpec(params, null, EMPTY_BLOCKS); - return new Yield(to, args); - }; - - Yield.build = function build(params, to) { - var args = Args.fromPositionalArgs(PositionalArgs.build(params)); - return new this(to, args); - }; + return result; + }); - Yield.prototype.compile = function compile(dsl, env, symbolTable) { - var to = this.to; - - var args = this.args.compile(dsl, env, symbolTable); - if (dsl.hasBlockSymbol(to)) { - var symbol = dsl.getBlockSymbol(to); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, to); - dsl.append(new OpenBlockOpcode(inner, args)); - dsl.append(new CloseBlockOpcode()); - } else if (dsl.hasPartialArgsSymbol()) { - var symbol = dsl.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, to); - dsl.append(new OpenBlockOpcode(inner, args)); - dsl.append(new CloseBlockOpcode()); - } else { - throw new Error('[BUG] ${to} is not a valid block name.'); - } - }; + rootElement.on(event + '.ember', '[data-ember-action]', function (evt) { + var attributes = evt.currentTarget.attributes; - return Yield; - })(_glimmerRuntimeLibSyntax.Statement); + for (var i = 0; i < attributes.length; i++) { + var attr = attributes.item(i); + var attrName = attr.name; - exports.Yield = Yield; + if (attrName.lastIndexOf('data-ember-action-', 0) !== -1) { + var action = _emberViewsSystemAction_manager.default.registeredActions[attr.value]; - function isStaticPartialName(exp) { - return exp.type === 'value'; - } + if (action.eventName === eventName) { + action.handler(evt); + } + } + } + }); + }, - var Partial = (function (_StatementSyntax12) { - babelHelpers.inherits(Partial, _StatementSyntax12); + _findNearestEventManager: function (view, eventName) { + var manager = null; - function Partial() { - _StatementSyntax12.apply(this, arguments); + while (view) { + manager = _emberMetal.get(view, 'eventManager'); + if (manager && manager[eventName]) { + break; } - Partial.fromSpec = function fromSpec(sexp) { - var exp = sexp[1]; - - var name = _glimmerRuntimeLibSyntaxExpressions.default(exp); - if (isStaticPartialName(name)) { - return new _glimmerRuntimeLibSyntaxBuiltinsPartial.StaticPartialSyntax(name); - } else { - return new _glimmerRuntimeLibSyntaxBuiltinsPartial.DynamicPartialSyntax(name); - } - }; + view = _emberMetal.get(view, 'parentView'); + } - return Partial; - })(_glimmerRuntimeLibSyntax.Statement); + return manager; + }, - exports.Partial = Partial; + _dispatchEvent: function (object, evt, eventName, view) { + var result = true; - var OpenBlockOpcode = (function (_Opcode) { - babelHelpers.inherits(OpenBlockOpcode, _Opcode); + var handler = object[eventName]; + if (typeof handler === 'function') { + result = _emberMetal.run(object, handler, evt, view); + // Do not preventDefault in eventManagers. + evt.stopPropagation(); + } else { + result = this._bubbleEvent(view, evt, eventName); + } - function OpenBlockOpcode(inner, args) { - _Opcode.call(this); - this.inner = inner; - this.args = args; - this.type = "open-block"; - } + return result; + }, - OpenBlockOpcode.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - var args = undefined; - if (block) { - args = this.args.evaluate(vm); - } - // FIXME: can we avoid doing this when we don't have a block? - vm.pushCallerScope(); - if (block) { - vm.invokeBlock(block, args); - } - }; + _bubbleEvent: function (view, evt, eventName) { + return view.handleEvent(eventName, evt); + }, - OpenBlockOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - details: { - "block": this.inner.toJSON(), - "positional": this.args.positional.toJSON(), - "named": this.args.named.toJSON() - } - }; - }; + destroy: function () { + var rootElement = _emberMetal.get(this, 'rootElement'); + _emberViewsSystemJquery.default(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); + return this._super.apply(this, arguments); + }, - return OpenBlockOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + toString: function () { + return '(EventDispatcher)'; + } + }); +}); +enifed('ember-views/system/ext', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ - var CloseBlockOpcode = (function (_Opcode2) { - babelHelpers.inherits(CloseBlockOpcode, _Opcode2); + 'use strict'; - function CloseBlockOpcode() { - _Opcode2.apply(this, arguments); - this.type = "close-block"; - } + // Add a new named queue for rendering views that happens + // after bindings have synced, and a queue for scheduling actions + // that should occur after view rendering. + _emberMetal.run._addQueue('render', 'actions'); + _emberMetal.run._addQueue('afterRender', 'render'); +}); +enifed('ember-views/system/jquery', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; - CloseBlockOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - }; + var jQuery = undefined; - return CloseBlockOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (_emberEnvironment.environment.hasDOM) { + jQuery = _emberEnvironment.context.imports.jQuery; - exports.CloseBlockOpcode = CloseBlockOpcode; + if (jQuery) { + if (jQuery.event.addProp) { + jQuery.event.addProp('dataTransfer'); + } else { + // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents + ['dragstart', 'drag', 'dragenter', 'dragleave', 'dragover', 'drop', 'dragend'].forEach(function (eventName) { + jQuery.event.fixHooks[eventName] = { + props: ['dataTransfer'] + }; + }); + } + } + } - var Value = (function (_ExpressionSyntax) { - babelHelpers.inherits(Value, _ExpressionSyntax); + exports.default = jQuery; +}); +enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - function Value(value) { - _ExpressionSyntax.call(this); - this.value = value; - this.type = "value"; - } + exports.default = lookupPartial; + exports.hasPartial = hasPartial; - Value.fromSpec = function fromSpec(value) { - return new Value(value); - }; + function parseUnderscoredName(templateName) { + var nameParts = templateName.split('/'); + var lastPart = nameParts[nameParts.length - 1]; - Value.build = function build(value) { - return new this(value); - }; + nameParts[nameParts.length - 1] = '_' + lastPart; - Value.prototype.inner = function inner() { - return this.value; - }; + return nameParts.join('/'); + } - Value.prototype.compile = function compile(compiler) { - return new _glimmerRuntimeLibCompiledExpressionsValue.default(this.value); - }; + function lookupPartial(templateName, owner) { + if (templateName == null) { + return; + } - return Value; - })(_glimmerRuntimeLibSyntax.Expression); + var template = templateFor(owner, parseUnderscoredName(templateName), templateName); - exports.Value = Value; + _emberMetal.assert('Unable to find partial with name "' + templateName + '"', !!template); - var GetArgument = (function (_ExpressionSyntax2) { - babelHelpers.inherits(GetArgument, _ExpressionSyntax2); + return template; + } - function GetArgument(parts) { - _ExpressionSyntax2.call(this); - this.parts = parts; - this.type = "get-argument"; - } + function hasPartial(name, owner) { + if (!owner) { + throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); + } - // this is separated out from Get because Unknown also has a ref, but it - // may turn out to be a helper + return owner.hasRegistration('template:' + parseUnderscoredName(name)) || owner.hasRegistration('template:' + name); + } - GetArgument.fromSpec = function fromSpec(sexp) { - var parts = sexp[1]; + function templateFor(owner, underscored, name) { + if (!name) { + return; + } + _emberMetal.assert('templateNames are not allowed to contain periods: ' + name, name.indexOf('.') === -1); - return new GetArgument(parts); - }; + if (!owner) { + throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); + } - GetArgument.build = function build(path) { - return new this(path.split('.')); - }; + return owner.lookup('template:' + underscored) || owner.lookup('template:' + name); + } +}); +enifed('ember-views/system/utils', ['exports', 'ember-utils'], function (exports, _emberUtils) { + /* globals Element */ + 'use strict'; - GetArgument.prototype.compile = function compile(lookup) { - var parts = this.parts; - - var head = parts[0]; - if (lookup.hasNamedSymbol(head)) { - var symbol = lookup.getNamedSymbol(head); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSymbol(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else if (lookup.hasPartialArgsSymbol()) { - var symbol = lookup.getPartialArgsSymbol(); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledInPartialName(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else { - throw new Error('[BUG] @' + this.parts.join('.') + ' is not a valid lookup path.'); - } - }; + exports.isSimpleClick = isSimpleClick; + exports.getRootViews = getRootViews; + exports.getViewId = getViewId; + exports.getViewElement = getViewElement; + exports.initViewElement = initViewElement; + exports.setViewElement = setViewElement; + exports.getChildViews = getChildViews; + exports.initChildViews = initChildViews; + exports.addChildView = addChildView; + exports.collectChildViews = collectChildViews; + exports.getViewBounds = getViewBounds; + exports.getViewRange = getViewRange; + exports.getViewClientRects = getViewClientRects; + exports.getViewBoundingClientRect = getViewBoundingClientRect; + exports.matches = matches; - return GetArgument; - })(_glimmerRuntimeLibSyntax.Expression); + /** + @module ember + @submodule ember-views + */ - exports.GetArgument = GetArgument; + function isSimpleClick(event) { + var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; + var secondaryClick = event.which > 1; // IE9 may return undefined - var Ref = (function (_ExpressionSyntax3) { - babelHelpers.inherits(Ref, _ExpressionSyntax3); + return !modifier && !secondaryClick; + } - function Ref(parts) { - _ExpressionSyntax3.call(this); - this.parts = parts; - this.type = "ref"; - } + var STYLE_WARNING = '' + 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + 'please ensure that values being bound are properly escaped. For more information, ' + 'including how to disable this warning, see ' + 'http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.'; - Ref.build = function build(path) { - var parts = path.split('.'); - if (parts[0] === 'this') { - parts[0] = null; - } - return new this(parts); - }; + exports.STYLE_WARNING = STYLE_WARNING; + /** + @private + @method getRootViews + @param {Object} owner + */ - Ref.prototype.compile = function compile(lookup) { - var parts = this.parts; - - var head = parts[0]; - if (head === null) { - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSelf(); - var path = parts.slice(1); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else if (lookup.hasLocalSymbol(head)) { - var symbol = lookup.getLocalSymbol(head); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSymbol(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else { - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSelf(); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, parts); - } - }; + function getRootViews(owner) { + var registry = owner.lookup('-view-registry:main'); - return Ref; - })(_glimmerRuntimeLibSyntax.Expression); + var rootViews = []; - exports.Ref = Ref; + Object.keys(registry).forEach(function (id) { + var view = registry[id]; - var Get = (function (_ExpressionSyntax4) { - babelHelpers.inherits(Get, _ExpressionSyntax4); + if (view.parentView === null) { + rootViews.push(view); + } + }); - function Get(ref) { - _ExpressionSyntax4.call(this); - this.ref = ref; - this.type = "get"; - } + return rootViews; + } - Get.fromSpec = function fromSpec(sexp) { - var parts = sexp[1]; + /** + @private + @method getViewId + @param {Ember.View} view + */ - return new this(new Ref(parts)); - }; + function getViewId(view) { + if (view.tagName === '') { + return _emberUtils.guidFor(view); + } else { + return view.elementId || _emberUtils.guidFor(view); + } + } - Get.build = function build(path) { - return new this(Ref.build(path)); - }; + var VIEW_ELEMENT = _emberUtils.symbol('VIEW_ELEMENT'); - Get.prototype.compile = function compile(compiler) { - return this.ref.compile(compiler); - }; + /** + @private + @method getViewElement + @param {Ember.View} view + */ - return Get; - })(_glimmerRuntimeLibSyntax.Expression); + function getViewElement(view) { + return view[VIEW_ELEMENT]; + } - exports.Get = Get; + function initViewElement(view) { + view[VIEW_ELEMENT] = null; + } - var Unknown = (function (_ExpressionSyntax5) { - babelHelpers.inherits(Unknown, _ExpressionSyntax5); + function setViewElement(view, element) { + return view[VIEW_ELEMENT] = element; + } - function Unknown(ref) { - _ExpressionSyntax5.call(this); - this.ref = ref; - this.type = "unknown"; - } + var CHILD_VIEW_IDS = _emberUtils.symbol('CHILD_VIEW_IDS'); - Unknown.fromSpec = function fromSpec(sexp) { - var path = sexp[1]; + /** + @private + @method getChildViews + @param {Ember.View} view + */ - return new this(new Ref(path)); - }; + function getChildViews(view) { + var owner = _emberUtils.getOwner(view); + var registry = owner.lookup('-view-registry:main'); + return collectChildViews(view, registry); + } - Unknown.build = function build(path) { - return new this(Ref.build(path)); - }; + function initChildViews(view) { + view[CHILD_VIEW_IDS] = []; + } - Unknown.prototype.compile = function compile(compiler, env, symbolTable) { - var ref = this.ref; + function addChildView(parent, child) { + parent[CHILD_VIEW_IDS].push(getViewId(child)); + } - if (env.hasHelper(ref.parts, symbolTable)) { - return new _glimmerRuntimeLibCompiledExpressionsHelper.default(ref.parts, env.lookupHelper(ref.parts, symbolTable), _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.empty(), symbolTable); - } else { - return this.ref.compile(compiler); - } - }; + function collectChildViews(view, registry) { + var ids = []; + var views = []; - return Unknown; - })(_glimmerRuntimeLibSyntax.Expression); + view[CHILD_VIEW_IDS].forEach(function (id) { + var view = registry[id]; - exports.Unknown = Unknown; + if (view && !view.isDestroying && !view.isDestroyed && ids.indexOf(id) === -1) { + ids.push(id); + views.push(view); + } + }); - var Helper = (function (_ExpressionSyntax6) { - babelHelpers.inherits(Helper, _ExpressionSyntax6); + view[CHILD_VIEW_IDS] = ids; - function Helper(ref, args) { - _ExpressionSyntax6.call(this); - this.ref = ref; - this.args = args; - this.type = "helper"; - } + return views; + } - Helper.fromSpec = function fromSpec(sexp) { - var path = sexp[1]; - var params = sexp[2]; - var hash = sexp[3]; + /** + @private + @method getViewBounds + @param {Ember.View} view + */ - return new Helper(new Ref(path), Args.fromSpec(params, hash, EMPTY_BLOCKS)); - }; + function getViewBounds(view) { + return view.renderer.getBounds(view); + } - Helper.build = function build(path, positional, named) { - return new this(Ref.build(path), Args.build(positional, named, EMPTY_BLOCKS)); - }; + /** + @private + @method getViewRange + @param {Ember.View} view + */ - Helper.prototype.compile = function compile(compiler, env, symbolTable) { - if (env.hasHelper(this.ref.parts, symbolTable)) { - var args = this.args; - var ref = this.ref; + function getViewRange(view) { + var bounds = getViewBounds(view); - return new _glimmerRuntimeLibCompiledExpressionsHelper.default(ref.parts, env.lookupHelper(ref.parts, symbolTable), args.compile(compiler, env, symbolTable), symbolTable); - } else { - throw new Error('Compile Error: ' + this.ref.parts.join('.') + ' is not a helper'); - } - }; + var range = document.createRange(); + range.setStartBefore(bounds.firstNode); + range.setEndAfter(bounds.lastNode); - return Helper; - })(_glimmerRuntimeLibSyntax.Expression); + return range; + } - exports.Helper = Helper; + /** + `getViewClientRects` provides information about the position of the border + box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inspector + and may not work on older browsers. + + @private + @method getViewClientRects + @param {Ember.View} view + */ - var HasBlock = (function (_ExpressionSyntax7) { - babelHelpers.inherits(HasBlock, _ExpressionSyntax7); + function getViewClientRects(view) { + var range = getViewRange(view); + return range.getClientRects(); + } - function HasBlock(blockName) { - _ExpressionSyntax7.call(this); - this.blockName = blockName; - this.type = "has-block"; - } + /** + `getViewBoundingClientRect` provides information about the position of the + bounding border box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inpsector + and may not work on older browsers. + + @private + @method getViewBoundingClientRect + @param {Ember.View} view + */ - HasBlock.fromSpec = function fromSpec(sexp) { - var blockName = sexp[1]; + function getViewBoundingClientRect(view) { + var range = getViewRange(view); + return range.getBoundingClientRect(); + } - return new HasBlock(blockName); - }; + /** + Determines if the element matches the specified selector. + + @private + @method matches + @param {DOMElement} el + @param {String} selector + */ + var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector); - HasBlock.build = function build(blockName) { - return new this(blockName); - }; + exports.elMatches = elMatches; - HasBlock.prototype.compile = function compile(compiler, env) { - var blockName = this.blockName; - - if (compiler.hasBlockSymbol(blockName)) { - var symbol = compiler.getBlockSymbol(blockName); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.default(inner); - } else if (compiler.hasPartialArgsSymbol()) { - var symbol = compiler.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.default(inner); - } else { - throw new Error('[BUG] ${blockName} is not a valid block name.'); - } - }; + function matches(el, selector) { + return elMatches.call(el, selector); + } +}); +enifed('ember-views/utils/lookup-component', ['exports', 'container'], function (exports, _container) { + 'use strict'; - return HasBlock; - })(_glimmerRuntimeLibSyntax.Expression); + exports.default = lookupComponent; - exports.HasBlock = HasBlock; + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - var HasBlockParams = (function (_ExpressionSyntax8) { - babelHelpers.inherits(HasBlockParams, _ExpressionSyntax8); + function lookupComponentPair(componentLookup, owner, name, options) { + var component = componentLookup.componentFor(name, owner, options); + var layout = componentLookup.layoutFor(name, owner, options); - function HasBlockParams(blockName) { - _ExpressionSyntax8.call(this); - this.blockName = blockName; - this.type = "has-block-params"; - } + var result = { layout: layout, component: component }; - HasBlockParams.fromSpec = function fromSpec(sexp) { - var blockName = sexp[1]; + if (layout && !component) { + result.component = owner[_container.FACTORY_FOR](_container.privatize(_templateObject)); + } - return new HasBlockParams(blockName); - }; + return result; + } - HasBlockParams.build = function build(blockName) { - return new this(blockName); - }; + function lookupComponent(owner, name, options) { + var componentLookup = owner.lookup('component-lookup:main'); - HasBlockParams.prototype.compile = function compile(compiler, env) { - var blockName = this.blockName; - - if (compiler.hasBlockSymbol(blockName)) { - var symbol = compiler.getBlockSymbol(blockName); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledHasBlockParams(inner); - } else if (compiler.hasPartialArgsSymbol()) { - var symbol = compiler.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledHasBlockParams(inner); - } else { - throw new Error('[BUG] ${blockName} is not a valid block name.'); - } - }; + var source = options && options.source; - return HasBlockParams; - })(_glimmerRuntimeLibSyntax.Expression); + if (source) { + var localResult = lookupComponentPair(componentLookup, owner, name, options); - exports.HasBlockParams = HasBlockParams; + if (localResult.component || localResult.layout) { + return localResult; + } + } - var Concat = (function () { - function Concat(parts) { - this.parts = parts; - this.type = "concat"; - } + return lookupComponentPair(componentLookup, owner, name); + } +}); +enifed('ember-views/views/core_view', ['exports', 'ember-runtime', 'ember-views/system/utils', 'ember-views/views/states'], function (exports, _emberRuntime, _emberViewsSystemUtils, _emberViewsViewsStates) { + 'use strict'; - Concat.fromSpec = function fromSpec(sexp) { - var params = sexp[1]; + /** + `Ember.CoreView` is an abstract class that exists to give view-like behavior + to both Ember's main view class `Ember.Component` and other classes that don't need + the full functionality of `Ember.Component`. + + Unless you have specific needs for `CoreView`, you will use `Ember.Component` + in your applications. + + @class CoreView + @namespace Ember + @extends Ember.Object + @deprecated Use `Ember.Component` instead. + @uses Ember.Evented + @uses Ember.ActionHandler + @private + */ + var CoreView = _emberRuntime.FrameworkObject.extend(_emberRuntime.Evented, _emberRuntime.ActionHandler, { + isView: true, - return new Concat(params.map(_glimmerRuntimeLibSyntaxExpressions.default)); - }; + _states: _emberViewsViewsStates.cloneStates(_emberViewsViewsStates.states), - Concat.build = function build(parts) { - return new this(parts); - }; + init: function () { + this._super.apply(this, arguments); + this._state = 'preRender'; + this._currentState = this._states.preRender; - Concat.prototype.compile = function compile(compiler, env, symbolTable) { - return new _glimmerRuntimeLibCompiledExpressionsConcat.default(this.parts.map(function (p) { - return p.compile(compiler, env, symbolTable); - })); - }; + _emberViewsSystemUtils.initViewElement(this); - return Concat; - })(); + if (!this.renderer) { + throw new Error('Cannot instantiate a component without a renderer. Please ensure that you are creating ' + this + ' with a proper container/registry.'); + } + }, - exports.Concat = Concat; + /** + If the view is currently inserted into the DOM of a parent view, this + property will point to the parent of the view. + @property parentView + @type Ember.View + @default null + @private + */ + parentView: null, - var Blocks = (function () { - function Blocks(_default) { - var inverse = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + instrumentDetails: function (hash) { + hash.object = this.toString(); + hash.containerKey = this._debugContainerKey; + hash.view = this; + return hash; + }, - this.type = "blocks"; - this.default = _default; - this.inverse = inverse; + /** + Override the default event firing from `Ember.Evented` to + also call methods with the given name. + @method trigger + @param name {String} + @private + */ + trigger: function () { + this._super.apply(this, arguments); + var name = arguments[0]; + var method = this[name]; + if (method) { + var args = new Array(arguments.length - 1); + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; } + return method.apply(this, args); + } + }, - Blocks.fromSpec = function fromSpec(_default) { - var inverse = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + has: function (name) { + return _emberRuntime.typeOf(this[name]) === 'function' || this._super(name); + } + }); - return new Blocks(_default, inverse); - }; + _emberRuntime.deprecateUnderscoreActions(CoreView); - Blocks.empty = function empty() { - return EMPTY_BLOCKS; - }; + CoreView.reopenClass({ + isViewFactory: true + }); - return Blocks; - })(); + exports.default = CoreView; +}); +enifed('ember-views/views/states', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberViewsViewsStatesPre_render, _emberViewsViewsStatesHas_element, _emberViewsViewsStatesIn_dom, _emberViewsViewsStatesDestroying) { + 'use strict'; - exports.Blocks = Blocks; - var EMPTY_BLOCKS = new ((function (_Blocks) { - babelHelpers.inherits(_class, _Blocks); + exports.cloneStates = cloneStates; - function _class() { - _Blocks.call(this, null, null); - } + function cloneStates(from) { + var into = {}; - return _class; - })(Blocks))(); - exports.EMPTY_BLOCKS = EMPTY_BLOCKS; + into._default = {}; + into.preRender = Object.create(into._default); + into.destroying = Object.create(into._default); + into.hasElement = Object.create(into._default); + into.inDOM = Object.create(into.hasElement); - var Args = (function () { - function Args(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; - this.type = "args"; - } + for (var stateName in from) { + if (!from.hasOwnProperty(stateName)) { + continue; + } + _emberUtils.assign(into[stateName], from[stateName]); + } - Args.empty = function empty() { - return EMPTY_ARGS; - }; + return into; + } - Args.fromSpec = function fromSpec(positional, named, blocks) { - return new Args(PositionalArgs.fromSpec(positional), NamedArgs.fromSpec(named), blocks); - }; + /* + Describe how the specified actions should behave in the various + states that a view can exist in. Possible states: + + * preRender: when a view is first instantiated, and after its + element was destroyed, it is in the preRender state + * hasElement: the DOM representation of the view is created, + and is ready to be inserted + * inDOM: once a view has been inserted into the DOM it is in + the inDOM state. A view spends the vast majority of its + existence in this state. + * destroyed: once a view has been destroyed (using the destroy + method), it is in this state. No further actions can be invoked + on a destroyed view. + */ + var states = { + _default: _emberViewsViewsStatesDefault.default, + preRender: _emberViewsViewsStatesPre_render.default, + inDOM: _emberViewsViewsStatesIn_dom.default, + hasElement: _emberViewsViewsStatesHas_element.default, + destroying: _emberViewsViewsStatesDestroying.default + }; + exports.states = states; +}); +enifed('ember-views/views/states/default', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; + + /** + @module ember + @submodule ember-views + */ + exports.default = { + // appendChild is only legal while rendering the buffer. + appendChild: function () { + throw new _emberMetal.Error('You can\'t use appendChild outside of the rendering process'); + }, - Args.fromPositionalArgs = function fromPositionalArgs(positional) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? EMPTY_BLOCKS : arguments[1]; + // Handle events from `Ember.EventDispatcher` + handleEvent: function () { + return true; // continue event propagation + }, - return new Args(positional, EMPTY_NAMED_ARGS, blocks); - }; + rerender: function () {}, - Args.fromNamedArgs = function fromNamedArgs(named) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? EMPTY_BLOCKS : arguments[1]; + destroy: function () {} + }; +}); +enifed('ember-views/views/states/destroying', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/default'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesDefault) { + 'use strict'; - return new Args(EMPTY_POSITIONAL_ARGS, named, blocks); - }; + /** + @module ember + @submodule ember-views + */ - Args.build = function build(positional, named, blocks) { - if (positional === EMPTY_POSITIONAL_ARGS && named === EMPTY_NAMED_ARGS && blocks === EMPTY_BLOCKS) { - return EMPTY_ARGS; - } else { - return new this(positional, named, blocks); - } - }; + var destroying = Object.create(_emberViewsViewsStatesDefault.default); - Args.prototype.compile = function compile(compiler, env, symbolTable) { - var positional = this.positional; - var named = this.named; - var blocks = this.blocks; + _emberUtils.assign(destroying, { + appendChild: function () { + throw new _emberMetal.Error('You can\'t call appendChild on a view being destroyed'); + }, + rerender: function () { + throw new _emberMetal.Error('You can\'t call rerender on a view being destroyed'); + } + }); - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.create(positional.compile(compiler, env, symbolTable), named.compile(compiler, env, symbolTable), blocks); - }; + exports.default = destroying; +}); +enifed('ember-views/views/states/has_element', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-metal'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberMetal) { + 'use strict'; - return Args; - })(); + var hasElement = Object.create(_emberViewsViewsStatesDefault.default); - exports.Args = Args; + _emberUtils.assign(hasElement, { - var PositionalArgs = (function () { - function PositionalArgs(values) { - this.values = values; - this.type = "positional"; - this.length = values.length; - } + rerender: function (view) { + view.renderer.rerender(view); + }, - PositionalArgs.empty = function empty() { - return EMPTY_POSITIONAL_ARGS; - }; + destroy: function (view) { + view.renderer.remove(view); + }, - PositionalArgs.fromSpec = function fromSpec(sexp) { - if (!sexp || sexp.length === 0) return EMPTY_POSITIONAL_ARGS; - return new PositionalArgs(sexp.map(_glimmerRuntimeLibSyntaxExpressions.default)); - }; + // Handle events from `Ember.EventDispatcher` + handleEvent: function (view, eventName, event) { + if (view.has(eventName)) { + // Handler should be able to re-dispatch events, so we don't + // preventDefault or stopPropagation. + return _emberMetal.flaggedInstrument('interaction.' + eventName, { event: event, view: view }, function () { + return _emberMetal.run.join(view, view.trigger, eventName, event); + }); + } else { + return true; // continue event propagation + } + } + }); - PositionalArgs.build = function build(exprs) { - if (exprs.length === 0) { - return EMPTY_POSITIONAL_ARGS; - } else { - return new this(exprs); - } - }; + exports.default = hasElement; +}); +enifed('ember-views/views/states/in_dom', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/has_element'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesHas_element) { + 'use strict'; - PositionalArgs.prototype.slice = function slice(start, end) { - return PositionalArgs.build(this.values.slice(start, end)); - }; + /** + @module ember + @submodule ember-views + */ - PositionalArgs.prototype.at = function at(index) { - return this.values[index]; - }; + var inDOM = Object.create(_emberViewsViewsStatesHas_element.default); - PositionalArgs.prototype.compile = function compile(compiler, env, symbolTable) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs.create(this.values.map(function (v) { - return v.compile(compiler, env, symbolTable); - })); - }; + _emberUtils.assign(inDOM, { + enter: function (view) { + // Register the view for event handling. This hash is used by + // Ember.EventDispatcher to dispatch incoming events. + view.renderer.register(view); - return PositionalArgs; - })(); + _emberMetal.runInDebug(function () { + _emberMetal._addBeforeObserver(view, 'elementId', function () { + throw new _emberMetal.Error('Changing a view\'s elementId after creation is not allowed'); + }); + }); + }, - exports.PositionalArgs = PositionalArgs; + exit: function (view) { + view.renderer.unregister(view); + } + }); - var EMPTY_POSITIONAL_ARGS = new ((function (_PositionalArgs) { - babelHelpers.inherits(_class2, _PositionalArgs); + exports.default = inDOM; +}); +enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default'], function (exports, _emberViewsViewsStatesDefault) { + 'use strict'; - function _class2() { - _PositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + /** + @module ember + @submodule ember-views + */ - _class2.prototype.slice = function slice(start, end) { - return this; - }; + exports.default = Object.create(_emberViewsViewsStatesDefault.default); +}); +enifed("ember-views/views/view", ["exports"], function (exports) { + "use strict"; +}); +/** +@module ember +@submodule ember-views +*/ - _class2.prototype.at = function at(index) { - return undefined; // ??! - }; +/** + @class View + @namespace Ember + @extends Ember.CoreView + @deprecated See http://emberjs.com/deprecations/v1.x/#toc_ember-view + @uses Ember.ViewSupport + @uses Ember.ChildViewsSupport + @uses Ember.ClassNamesSupport + @uses Ember.AttributeBindingsSupport + @private +*/ +enifed("ember/features", ["exports"], function (exports) { + "use strict"; - _class2.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs.empty(); - }; + exports.default = { "features-stripped-test": null, "ember-libraries-isregistered": null, "ember-improved-instrumentation": null, "ember-metal-weakmap": null, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": null, "ember-factory-for": true, "ember-no-double-extend": null, "ember-routing-router-service": null, "ember-unique-location-history-state": null, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; +}); +enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { + 'use strict'; - return _class2; - })(PositionalArgs))(); + // ember-utils exports + _emberMetal.default.getOwner = _emberUtils.getOwner; + _emberMetal.default.setOwner = _emberUtils.setOwner; + _emberMetal.default.generateGuid = _emberUtils.generateGuid; + _emberMetal.default.GUID_KEY = _emberUtils.GUID_KEY; + _emberMetal.default.guidFor = _emberUtils.guidFor; + _emberMetal.default.inspect = _emberUtils.inspect; + _emberMetal.default.makeArray = _emberUtils.makeArray; + _emberMetal.default.canInvoke = _emberUtils.canInvoke; + _emberMetal.default.tryInvoke = _emberUtils.tryInvoke; + _emberMetal.default.wrap = _emberUtils.wrap; + _emberMetal.default.applyStr = _emberUtils.applyStr; + _emberMetal.default.uuid = _emberUtils.uuid; + _emberMetal.default.assign = Object.assign || _emberUtils.assign; - var NamedArgs = (function () { - function NamedArgs(keys, values) { - this.keys = keys; - this.values = values; - this.type = "named"; - this.length = keys.length; - } + // container exports + _emberMetal.default.Container = _container.Container; + _emberMetal.default.Registry = _container.Registry; - NamedArgs.empty = function empty() { - return EMPTY_NAMED_ARGS; - }; + // need to import this directly, to ensure the babel feature + // flag plugin works properly - NamedArgs.fromSpec = function fromSpec(sexp) { - if (sexp === null || sexp === undefined) { - return EMPTY_NAMED_ARGS; - } - var keys = sexp[0]; - var exprs = sexp[1]; + var computed = _emberMetal.computed; + computed.alias = _emberMetal.alias; + _emberMetal.default.computed = computed; + _emberMetal.default.ComputedProperty = _emberMetal.ComputedProperty; + _emberMetal.default.cacheFor = _emberMetal.cacheFor; - if (keys.length === 0) { - return EMPTY_NAMED_ARGS; - } - return new this(keys, exprs.map(function (expr) { - return _glimmerRuntimeLibSyntaxExpressions.default(expr); - })); - }; + _emberMetal.default.assert = _emberMetal.assert; + _emberMetal.default.warn = _emberMetal.warn; + _emberMetal.default.debug = _emberMetal.debug; + _emberMetal.default.deprecate = _emberMetal.deprecate; + _emberMetal.default.deprecateFunc = _emberMetal.deprecateFunc; + _emberMetal.default.runInDebug = _emberMetal.runInDebug; + _emberMetal.default.merge = _emberMetal.merge; - NamedArgs.build = function build(keys, values) { - if (keys.length === 0) { - return EMPTY_NAMED_ARGS; - } else { - return new this(keys, values); - } - }; + _emberMetal.default.instrument = _emberMetal.instrument; + _emberMetal.default.subscribe = _emberMetal.instrumentationSubscribe; + _emberMetal.default.Instrumentation = { + instrument: _emberMetal.instrument, + subscribe: _emberMetal.instrumentationSubscribe, + unsubscribe: _emberMetal.instrumentationUnsubscribe, + reset: _emberMetal.instrumentationReset + }; - NamedArgs.prototype.at = function at(key) { - var keys = this.keys; - var values = this.values; + _emberMetal.default.Error = _emberMetal.Error; + _emberMetal.default.META_DESC = _emberMetal.META_DESC; + _emberMetal.default.meta = _emberMetal.meta; + _emberMetal.default.get = _emberMetal.get; + _emberMetal.default.getWithDefault = _emberMetal.getWithDefault; + _emberMetal.default._getPath = _emberMetal._getPath; + _emberMetal.default.set = _emberMetal.set; + _emberMetal.default.trySet = _emberMetal.trySet; + _emberMetal.default.FEATURES = _emberMetal.FEATURES; + _emberMetal.default.FEATURES.isEnabled = _emberMetal.isFeatureEnabled; + _emberMetal.default._Cache = _emberMetal.Cache; + _emberMetal.default.on = _emberMetal.on; + _emberMetal.default.addListener = _emberMetal.addListener; + _emberMetal.default.removeListener = _emberMetal.removeListener; + _emberMetal.default._suspendListener = _emberMetal.suspendListener; + _emberMetal.default._suspendListeners = _emberMetal.suspendListeners; + _emberMetal.default.sendEvent = _emberMetal.sendEvent; + _emberMetal.default.hasListeners = _emberMetal.hasListeners; + _emberMetal.default.watchedEvents = _emberMetal.watchedEvents; + _emberMetal.default.listenersFor = _emberMetal.listenersFor; + _emberMetal.default.accumulateListeners = _emberMetal.accumulateListeners; + _emberMetal.default.isNone = _emberMetal.isNone; + _emberMetal.default.isEmpty = _emberMetal.isEmpty; + _emberMetal.default.isBlank = _emberMetal.isBlank; + _emberMetal.default.isPresent = _emberMetal.isPresent; + _emberMetal.default.run = _emberMetal.run; + _emberMetal.default._ObserverSet = _emberMetal.ObserverSet; + _emberMetal.default.propertyWillChange = _emberMetal.propertyWillChange; + _emberMetal.default.propertyDidChange = _emberMetal.propertyDidChange; + _emberMetal.default.overrideChains = _emberMetal.overrideChains; + _emberMetal.default.beginPropertyChanges = _emberMetal.beginPropertyChanges; + _emberMetal.default.endPropertyChanges = _emberMetal.endPropertyChanges; + _emberMetal.default.changeProperties = _emberMetal.changeProperties; + _emberMetal.default.platform = { + defineProperty: true, + hasPropertyAccessors: true + }; + _emberMetal.default.defineProperty = _emberMetal.defineProperty; + _emberMetal.default.watchKey = _emberMetal.watchKey; + _emberMetal.default.unwatchKey = _emberMetal.unwatchKey; + _emberMetal.default.removeChainWatcher = _emberMetal.removeChainWatcher; + _emberMetal.default._ChainNode = _emberMetal.ChainNode; + _emberMetal.default.finishChains = _emberMetal.finishChains; + _emberMetal.default.watchPath = _emberMetal.watchPath; + _emberMetal.default.unwatchPath = _emberMetal.unwatchPath; + _emberMetal.default.watch = _emberMetal.watch; + _emberMetal.default.isWatching = _emberMetal.isWatching; + _emberMetal.default.unwatch = _emberMetal.unwatch; + _emberMetal.default.destroy = _emberMetal.destroy; + _emberMetal.default.libraries = _emberMetal.libraries; + _emberMetal.default.OrderedSet = _emberMetal.OrderedSet; + _emberMetal.default.Map = _emberMetal.Map; + _emberMetal.default.MapWithDefault = _emberMetal.MapWithDefault; + _emberMetal.default.getProperties = _emberMetal.getProperties; + _emberMetal.default.setProperties = _emberMetal.setProperties; + _emberMetal.default.expandProperties = _emberMetal.expandProperties; + _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; + _emberMetal.default.addObserver = _emberMetal.addObserver; + _emberMetal.default.observersFor = _emberMetal.observersFor; + _emberMetal.default.removeObserver = _emberMetal.removeObserver; + _emberMetal.default._suspendObserver = _emberMetal._suspendObserver; + _emberMetal.default._suspendObservers = _emberMetal._suspendObservers; + _emberMetal.default.required = _emberMetal.required; + _emberMetal.default.aliasMethod = _emberMetal.aliasMethod; + _emberMetal.default.observer = _emberMetal.observer; + _emberMetal.default.immediateObserver = _emberMetal._immediateObserver; + _emberMetal.default.mixin = _emberMetal.mixin; + _emberMetal.default.Mixin = _emberMetal.Mixin; + _emberMetal.default.bind = _emberMetal.bind; + _emberMetal.default.Binding = _emberMetal.Binding; + _emberMetal.default.isGlobalPath = _emberMetal.isGlobalPath; - var index = keys.indexOf(key); - return values[index]; - }; + if (_emberMetal.isFeatureEnabled('ember-metal-weakmap')) { + _emberMetal.default.WeakMap = _emberMetal.WeakMap; + } - NamedArgs.prototype.has = function has(key) { - return this.keys.indexOf(key) !== -1; - }; + Object.defineProperty(_emberMetal.default, 'ENV', { + get: function () { + return _emberEnvironment.ENV; + }, + enumerable: false + }); - NamedArgs.prototype.compile = function compile(compiler, env, symbolTable) { - var keys = this.keys; - var values = this.values; + /** + The context that Ember searches for namespace instances on. + + @private + */ + Object.defineProperty(_emberMetal.default, 'lookup', { + get: function () { + return _emberEnvironment.context.lookup; + }, + set: function (value) { + _emberEnvironment.context.lookup = value; + }, + enumerable: false + }); - return new _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs(keys, values.map(function (value) { - return value.compile(compiler, env, symbolTable); - })); - }; + _emberMetal.default.EXTEND_PROTOTYPES = _emberEnvironment.ENV.EXTEND_PROTOTYPES; - return NamedArgs; - })(); + // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS + Object.defineProperty(_emberMetal.default, 'LOG_STACKTRACE_ON_DEPRECATION', { + get: function () { + return _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; + }, + enumerable: false + }); - exports.NamedArgs = NamedArgs; + Object.defineProperty(_emberMetal.default, 'LOG_VERSION', { + get: function () { + return _emberEnvironment.ENV.LOG_VERSION; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_VERSION = !!value; + }, + enumerable: false + }); - var EMPTY_NAMED_ARGS = new ((function (_NamedArgs) { - babelHelpers.inherits(_class3, _NamedArgs); + Object.defineProperty(_emberMetal.default, 'MODEL_FACTORY_INJECTIONS', { + get: function () { + return _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; + }, + set: function (value) { + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = !!value; + }, + enumerable: false + }); - function _class3() { - _NamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + Object.defineProperty(_emberMetal.default, 'LOG_BINDINGS', { + get: function () { + return _emberEnvironment.ENV.LOG_BINDINGS; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_BINDINGS = !!value; + }, + enumerable: false + }); - _class3.prototype.at = function at(key) { - return undefined; // ??! - }; + /** + A function may be assigned to `Ember.onerror` to be called when Ember + internals encounter an error. This is useful for specialized error handling + and reporting code. + + ```javascript + Ember.onerror = function(error) { + Em.$.ajax('/report-error', 'POST', { + stack: error.stack, + otherInformation: 'whatever app state you want to provide' + }); + }; + ``` + + Internally, `Ember.onerror` is used as Backburner's error handler. + + @event onerror + @for Ember + @param {Exception} error the error object + @public + */ + Object.defineProperty(_emberMetal.default, 'onerror', { + get: _emberMetal.getOnerror, + set: _emberMetal.setOnerror, + enumerable: false + }); - _class3.prototype.has = function has(key) { - return false; - }; + /** + An empty function useful for some operations. Always returns `this`. + + @method K + @return {Object} + @public + */ + function deprecatedEmberK() { + return this; + } - _class3.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs.empty(); - }; + Object.defineProperty(_emberMetal.default, 'K', { + get: function () { + _emberMetal.deprecate('Ember.K is deprecated in favor of defining a function inline.', false, { + id: 'ember-metal.ember-k', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_code-ember-k-code' + }); - return _class3; - })(NamedArgs))(); - var EMPTY_ARGS = new ((function (_Args) { - babelHelpers.inherits(_class4, _Args); + return deprecatedEmberK; + } + }); - function _class4() { - _Args.call(this, EMPTY_POSITIONAL_ARGS, EMPTY_NAMED_ARGS, EMPTY_BLOCKS); - } + Object.defineProperty(_emberMetal.default, 'testing', { + get: _emberMetal.isTesting, + set: _emberMetal.setTesting, + enumerable: false + }); - _class4.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.empty(); - }; + if (!_require.has('ember-debug')) { + _emberMetal.default.Debug = { + registerDeprecationHandler: function () {}, + registerWarnHandler: function () {} + }; + } - return _class4; - })(Args))(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2NvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBMEdBLEtBQUE7OEJBQUEsS0FBQTs7QUFxQkUsaUJBckJGLEtBQ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BFbnZpcm9ubWVudCk6IENvbXBpbGVkTmFtZWRBcmdzIHtcbiAgICByZXR1cm4gQ29tcGlsZWROYW1lZEFyZ3MuZW1wdHkoKTtcbiAgfVxufSk7XG5cbmNvbnN0IEVNUFRZX0FSR1M6IEFyZ3MgPSBuZXcgKGNsYXNzIGV4dGVuZHMgQXJncyB7XG4gIGNvbnN0cnVjdG9yKCkge1xuICAgIHN1cGVyKEVNUFRZX1BPU0lUSU9OQUxfQVJHUywgRU1QVFlfTkFNRURfQVJHUywgRU1QVFlfQkxPQ0tTKTtcbiAgfVxuXG4gIGNvbXBpbGUoY29tcGlsZXI6IFN5bWJvbExvb2t1cCwgZW52OiBFbnZpcm9ubWVudCk6IENvbXBpbGVkQXJncyB7XG4gICAgcmV0dXJuIENvbXBpbGVkQXJncy5lbXB0eSgpO1xuICB9XG59KTtcbiJdfQ== -enifed('glimmer-runtime/lib/syntax/expressions', ['exports', 'glimmer-runtime/lib/syntax/core', 'glimmer-wire-format'], function (exports, _glimmerRuntimeLibSyntaxCore, _glimmerWireFormat) { - 'use strict'; + /** + @class Backburner + @for Ember + @private + */ + _emberMetal.default.Backburner = function () { + _emberMetal.deprecate('Usage of Ember.Backburner is deprecated.', false, { + id: 'ember-metal.ember-backburner', + until: '2.8.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-backburner' + }); - var isArg = _glimmerWireFormat.Expressions.isArg; - var isConcat = _glimmerWireFormat.Expressions.isConcat; - var isGet = _glimmerWireFormat.Expressions.isGet; - var isHasBlock = _glimmerWireFormat.Expressions.isHasBlock; - var isHasBlockParams = _glimmerWireFormat.Expressions.isHasBlockParams; - var isHelper = _glimmerWireFormat.Expressions.isHelper; - var isUnknown = _glimmerWireFormat.Expressions.isUnknown; - var isPrimitiveValue = _glimmerWireFormat.Expressions.isPrimitiveValue; - var isUndefined = _glimmerWireFormat.Expressions.isUndefined; - - exports.default = function (sexp) { - if (isPrimitiveValue(sexp)) return _glimmerRuntimeLibSyntaxCore.Value.fromSpec(sexp); - if (isUndefined(sexp)) return _glimmerRuntimeLibSyntaxCore.Value.build(undefined); - if (isArg(sexp)) return _glimmerRuntimeLibSyntaxCore.GetArgument.fromSpec(sexp); - if (isConcat(sexp)) return _glimmerRuntimeLibSyntaxCore.Concat.fromSpec(sexp); - if (isGet(sexp)) return _glimmerRuntimeLibSyntaxCore.Get.fromSpec(sexp); - if (isHelper(sexp)) return _glimmerRuntimeLibSyntaxCore.Helper.fromSpec(sexp); - if (isUnknown(sexp)) return _glimmerRuntimeLibSyntaxCore.Unknown.fromSpec(sexp); - if (isHasBlock(sexp)) return _glimmerRuntimeLibSyntaxCore.HasBlock.fromSpec(sexp); - if (isHasBlockParams(sexp)) return _glimmerRuntimeLibSyntaxCore.HasBlockParams.fromSpec(sexp); - throw new Error('Unexpected wire format: ' + JSON.stringify(sexp)); - }; + function BackburnerAlias(args) { + return _backburner.default.apply(this, args); + } - ; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2V4cHJlc3Npb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQWlCRSxLQUFLLHNCQUxMLFdBQVcsQ0FLWCxLQUFLO1FBQ0wsUUFBUSxzQkFOUixXQUFXLENBTVgsUUFBUTtRQUNSLEtBQUssc0JBUEwsV0FBVyxDQU9YLEtBQUs7UUFDTCxVQUFVLHNCQVJWLFdBQVcsQ0FRWCxVQUFVO1FBQ1YsZ0JBQWdCLHNCQVRoQixXQUFXLENBU1gsZ0JBQWdCO1FBQ2hCLFFBQVEsc0JBVlIsV0FBVyxDQVVYLFFBQVE7UUFDUixTQUFTLHNCQVhULFdBQVcsQ0FXWCxTQUFTO1FBQ1QsZ0JBQWdCLHNCQVpoQixXQUFXLENBWVgsZ0JBQWdCO1FBQ2hCLFdBQVcsc0JBYlgsV0FBVyxDQWFYLFdBQVc7O3NCQUdiLFVBQXd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pZiAoaXNVbmRlZmluZWQoc2V4cCkpIHJldHVybiBWYWx1ZVN5bnRheC5idWlsZCh1bmRlZmluZWQpO1xuICBpZiAoaXNBcmcoc2V4cCkpIHJldHVybiBBcmdTeW50YXguZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc0NvbmNhdChzZXhwKSkgcmV0dXJuIENvbmNhdFN5bnRheC5mcm9tU3BlYyhzZXhwKTtcbiAgaWYgKGlzR2V0KHNleHApKSByZXR1cm4gR2V0U3ludGF4LmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNIZWxwZXIoc2V4cCkpIHJldHVybiBIZWxwZXJTeW50YXguZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc1Vua25vd24oc2V4cCkpIHJldHVybiBVbmtub3duU3ludGF4LmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNIYXNCbG9jayhzZXhwKSkgcmV0dXJuIEhhc0Jsb2NrU3ludGF4LmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNIYXNCbG9ja1BhcmFtcyhzZXhwKSkgcmV0dXJuIEhhc0Jsb2NrUGFyYW1zU3ludGF4LmZyb21TcGVjKHNleHApO1xuXG4gIHRocm93IG5ldyBFcnJvcihgVW5leHBlY3RlZCB3aXJlIGZvcm1hdDogJHtKU09OLnN0cmluZ2lmeShzZXhwKX1gKTtcbn07XG4iXX0= -enifed('glimmer-runtime/lib/syntax/statements', ['exports', 'glimmer-runtime/lib/syntax/core', 'glimmer-wire-format'], function (exports, _glimmerRuntimeLibSyntaxCore, _glimmerWireFormat) { - 'use strict'; + BackburnerAlias.prototype = _backburner.default.prototype; - var isYield = _glimmerWireFormat.Statements.isYield; - var isBlock = _glimmerWireFormat.Statements.isBlock; - var isPartial = _glimmerWireFormat.Statements.isPartial; - var isAppend = _glimmerWireFormat.Statements.isAppend; - var isDynamicAttr = _glimmerWireFormat.Statements.isDynamicAttr; - var isText = _glimmerWireFormat.Statements.isText; - var isComment = _glimmerWireFormat.Statements.isComment; - var isOpenElement = _glimmerWireFormat.Statements.isOpenElement; - var isFlushElement = _glimmerWireFormat.Statements.isFlushElement; - var isCloseElement = _glimmerWireFormat.Statements.isCloseElement; - var isStaticAttr = _glimmerWireFormat.Statements.isStaticAttr; - var isModifier = _glimmerWireFormat.Statements.isModifier; - var isDynamicArg = _glimmerWireFormat.Statements.isDynamicArg; - var isStaticArg = _glimmerWireFormat.Statements.isStaticArg; - var isTrustingAttr = _glimmerWireFormat.Statements.isTrustingAttr; - - exports.default = function (sexp, symbolTable, scanner) { - if (isYield(sexp)) return _glimmerRuntimeLibSyntaxCore.Yield.fromSpec(sexp); - if (isPartial(sexp)) return _glimmerRuntimeLibSyntaxCore.Partial.fromSpec(sexp); - if (isBlock(sexp)) return _glimmerRuntimeLibSyntaxCore.Block.fromSpec(sexp, symbolTable, scanner); - if (isAppend(sexp)) return _glimmerRuntimeLibSyntaxCore.OptimizedAppend.fromSpec(sexp); - if (isDynamicAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.DynamicAttr.fromSpec(sexp); - if (isDynamicArg(sexp)) return _glimmerRuntimeLibSyntaxCore.DynamicArg.fromSpec(sexp); - if (isTrustingAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.TrustingAttr.fromSpec(sexp); - if (isText(sexp)) return _glimmerRuntimeLibSyntaxCore.Text.fromSpec(sexp); - if (isComment(sexp)) return _glimmerRuntimeLibSyntaxCore.Comment.fromSpec(sexp); - if (isOpenElement(sexp)) return _glimmerRuntimeLibSyntaxCore.OpenElement.fromSpec(sexp, symbolTable); - if (isFlushElement(sexp)) return _glimmerRuntimeLibSyntaxCore.FlushElement.fromSpec(); - if (isCloseElement(sexp)) return _glimmerRuntimeLibSyntaxCore.CloseElement.fromSpec(); - if (isStaticAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.StaticAttr.fromSpec(sexp); - if (isStaticArg(sexp)) return _glimmerRuntimeLibSyntaxCore.StaticArg.fromSpec(sexp); - if (isModifier(sexp)) return _glimmerRuntimeLibSyntaxCore.Modifier.fromSpec(sexp); - }; + return new BackburnerAlias(arguments); + }; - ; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L3N0YXRlbWVudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBMkJFLE9BQU8sc0JBTlAsVUFBVSxDQU1WLE9BQU87UUFDUCxPQUFPLHNCQVBQLFVBQVUsQ0FPVixPQUFPO1FBQ1AsU0FBUyxzQkFSVCxVQUFVLENBUVYsU0FBUztRQUNULFFBQVEsc0JBVFIsVUFBVSxDQVNWLFFBQVE7UUFDUixhQUFhLHNCQVZiLFVBQVUsQ0FVVixhQUFhO1FBQ2IsTUFBTSxzQkFYTixVQUFVLENBV1YsTUFBTTtRQUNOLFNBQVMsc0JBWlQsVUFBVSxDQVlWLFNBQVM7UUFDVCxhQUFhLHNCQWJiLFVBQVUsQ0FhVixhQUFhO1FBQ2IsY0FBYyxzQkFkZCxVQUFVLENBY1YsY0FBYztRQUNkLGNBQWMsc0JBZmQsVUFBVSxDQWVWLGNBQWM7UUFDZCxZQUFZLHNCQWhCWixVQUFVLENBZ0JWLFlBQVk7UUFDWixVQUFVLHNCQWpCVixVQUFVLENBaUJWLFVBQVU7UUFDVixZQUFZLHNCQWxCWixVQUFVLENBa0JWLFlBQVk7UUFDWixXQUFXLHNCQW5CWCxVQUFVLENBbUJWLFdBQVc7UUFDWCxjQUFjLHNCQXBCZCxVQUFVLENBb0JWLGNBQWM7O3NCQUdoQixVQUF3QixJQUF5QixFQUFFLFdBQXdCLEVBQUUsT0FBcUIsRUFBQTtBQUNoRyxZQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsRUFBRSxPQUFPLDZCQTVDMUIsS0FBSyxDQTRDMkIsUUFBUSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQy9DLFlBQUksU0FBUyxDQUFDLElBQUksQ0FBQyxFQUF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iAoaXNEeW5hbWljQXR0cihzZXhwKSkgcmV0dXJuIER5bmFtaWNBdHRyLmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNEeW5hbWljQXJnKHNleHApKSByZXR1cm4gRHluYW1pY0FyZy5mcm9tU3BlYyhzZXhwKTtcbiAgaWYgKGlzVHJ1c3RpbmdBdHRyKHNleHApKSByZXR1cm4gVHJ1c3RpbmdBdHRyLmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNUZXh0KHNleHApKSByZXR1cm4gVGV4dC5mcm9tU3BlYyhzZXhwKTtcbiAgaWYgKGlzQ29tbWVudChzZXhwKSkgcmV0dXJuIENvbW1lbnQuZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc09wZW5FbGVtZW50KHNleHApKSByZXR1cm4gT3BlbkVsZW1lbnQuZnJvbVNwZWMoc2V4cCwgc3ltYm9sVGFibGUpO1xuICBpZiAoaXNGbHVzaEVsZW1lbnQoc2V4cCkpIHJldHVybiBGbHVzaEVsZW1lbnQuZnJvbVNwZWMoKTtcbiAgaWYgKGlzQ2xvc2VFbGVtZW50KHNleHApKSByZXR1cm4gQ2xvc2VFbGVtZW50LmZyb21TcGVjKCk7XG4gIGlmIChpc1N0YXRpY0F0dHIoc2V4cCkpIHJldHVybiBTdGF0aWNBdHRyLmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNTdGF0aWNBcmcoc2V4cCkpIHJldHVybiBTdGF0aWNBcmcuZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc01vZGlmaWVyKHNleHApKSByZXR1cm4gTW9kaWZpZXIuZnJvbVNwZWMoc2V4cCk7XG59O1xuIl19 -enifed('glimmer-runtime/lib/template', ['exports', 'glimmer-util', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/vm', 'glimmer-runtime/lib/scanner'], function (exports, _glimmerUtil, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibVm, _glimmerRuntimeLibScanner) { - 'use strict'; + _emberMetal.default._Backburner = _backburner.default; - exports.default = templateFactory; + _emberMetal.default.Logger = _emberConsole.default; - var clientId = 0; + // ****ember-runtime**** - function templateFactory(_ref) { - var id = _ref.id; - var meta = _ref.meta; - var block = _ref.block; + _emberMetal.default.String = _emberRuntime.String; + _emberMetal.default.Object = _emberRuntime.Object; + _emberMetal.default._RegistryProxyMixin = _emberRuntime.RegistryProxyMixin; + _emberMetal.default._ContainerProxyMixin = _emberRuntime.ContainerProxyMixin; + _emberMetal.default.compare = _emberRuntime.compare; + _emberMetal.default.copy = _emberRuntime.copy; + _emberMetal.default.isEqual = _emberRuntime.isEqual; + _emberMetal.default.inject = _emberRuntime.inject; + _emberMetal.default.Array = _emberRuntime.Array; + _emberMetal.default.Comparable = _emberRuntime.Comparable; + _emberMetal.default.Enumerable = _emberRuntime.Enumerable; + _emberMetal.default.ArrayProxy = _emberRuntime.ArrayProxy; + _emberMetal.default.ObjectProxy = _emberRuntime.ObjectProxy; + _emberMetal.default.ActionHandler = _emberRuntime.ActionHandler; + _emberMetal.default.CoreObject = _emberRuntime.CoreObject; + _emberMetal.default.NativeArray = _emberRuntime.NativeArray; + _emberMetal.default.Copyable = _emberRuntime.Copyable; + _emberMetal.default.Freezable = _emberRuntime.Freezable; + _emberMetal.default.FROZEN_ERROR = _emberRuntime.FROZEN_ERROR; + _emberMetal.default.MutableEnumerable = _emberRuntime.MutableEnumerable; + _emberMetal.default.MutableArray = _emberRuntime.MutableArray; + _emberMetal.default.TargetActionSupport = _emberRuntime.TargetActionSupport; + _emberMetal.default.Evented = _emberRuntime.Evented; + _emberMetal.default.PromiseProxyMixin = _emberRuntime.PromiseProxyMixin; + _emberMetal.default.Observable = _emberRuntime.Observable; + _emberMetal.default.typeOf = _emberRuntime.typeOf; + _emberMetal.default.isArray = _emberRuntime.isArray; + _emberMetal.default.Object = _emberRuntime.Object; + _emberMetal.default.onLoad = _emberRuntime.onLoad; + _emberMetal.default.runLoadHooks = _emberRuntime.runLoadHooks; + _emberMetal.default.Controller = _emberRuntime.Controller; + _emberMetal.default.ControllerMixin = _emberRuntime.ControllerMixin; + _emberMetal.default.Service = _emberRuntime.Service; + _emberMetal.default._ProxyMixin = _emberRuntime._ProxyMixin; + _emberMetal.default.RSVP = _emberRuntime.RSVP; + _emberMetal.default.Namespace = _emberRuntime.Namespace; - var parsedBlock = undefined; - if (!id) { - id = 'client-' + clientId++; - } - var create = function (env, envMeta) { - var newMeta = envMeta ? _glimmerUtil.assign({}, envMeta, meta) : meta; - if (!parsedBlock) { - parsedBlock = JSON.parse(block); - } - return template(parsedBlock, id, newMeta, env); - }; - return { id: id, meta: meta, create: create }; - } + // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed + computed.empty = _emberRuntime.empty; + computed.notEmpty = _emberRuntime.notEmpty; + computed.none = _emberRuntime.none; + computed.not = _emberRuntime.not; + computed.bool = _emberRuntime.bool; + computed.match = _emberRuntime.match; + computed.equal = _emberRuntime.equal; + computed.gt = _emberRuntime.gt; + computed.gte = _emberRuntime.gte; + computed.lt = _emberRuntime.lt; + computed.lte = _emberRuntime.lte; + computed.oneWay = _emberRuntime.oneWay; + computed.reads = _emberRuntime.oneWay; + computed.readOnly = _emberRuntime.readOnly; + computed.deprecatingAlias = _emberRuntime.deprecatingAlias; + computed.and = _emberRuntime.and; + computed.or = _emberRuntime.or; + computed.any = _emberRuntime.any; - function template(block, id, meta, env) { - var scanner = new _glimmerRuntimeLibScanner.default(block, meta, env); - var entryPoint = undefined; - var asEntryPoint = function () { - if (!entryPoint) entryPoint = scanner.scanEntryPoint(); - return entryPoint; - }; - var layout = undefined; - var asLayout = function () { - if (!layout) layout = scanner.scanLayout(); - return layout; - }; - var asPartial = function (symbols) { - return scanner.scanPartial(symbols); - }; - var render = function (self, appendTo, dynamicScope) { - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.forInitialRender(env, appendTo, null); - var compiled = asEntryPoint().compile(env); - var vm = _glimmerRuntimeLibVm.VM.initial(env, self, dynamicScope, elementStack, compiled.symbols); - return vm.execute(compiled.ops); - }; - return { id: id, meta: meta, _block: block, asEntryPoint: asEntryPoint, asLayout: asLayout, asPartial: asPartial, render: render }; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdGVtcGxhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O3NCQWtGQSxlQUFBOztBQVRBLFFBQUksUUFBUSxHQUFHLENBQUMsQ0FBQzs7QUFTakIsYUFBQSxlQUFBLENBQXdDLElBQXlELEVBQUE7WUFBdkQsRUFBRSxHQUFKLElBQXlELENBQXZELEVBQUU7WUFBRSxJQUFJLEdBQVYsSUFBeUQsQ0FBbkQsSUFBSTtZQUFFLEtBQUssR0FBakIsSUFBeUQsQ0FBN0MsS0FBSzs7QUFDdkQsWUFBSSxXQUFvQyxZQUFBLENBQUM7QUFDekMsWUFBSSxDQUFDLEVBQUUsRUFBRTtBQUNQLGNBQUUsZUFBYSxRQUFRLEVBQUcsQUFBRSxDQUFDO1NBQzlCO0FBQ0QsWUFBSSxNQUFNLEdBQUcsVUFBQyxHQUFnQixFQUFFLE9BQVksRUFBQTtBQUMxQyxnQkFBSSxPQUFPLEdBQUcsT0FBTyxHQUFHLGFBbkZuQixNQUFNLENBbUZvQixFQUFFLEVBQUUsT0FBTyxFQUFFLElBQUksQ0FBQyxHQUFHLElBQUksQ0FBQztBQUN6RCxnQkFBSSxDQUFDLFdBQVcsRUFBRTtBQUNoQiwyQkFBVyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLENBQUM7YUFDakM7QUFDRCxtQkFBTyxRQUFRLENBQUMsV0FBVyxFQUFFLEVBQUUsRUFBRSxPQUFPLEVBQUUsR0FBRyxDQUFDLENBQUM7U0FDaEQsQ0FBQztBQUNGLGVBQU8sRUFBRSxFQUFFLEVBQUYsRUFBRSxFQUFFLElBQUksRUFBSixJQUFJLEVBQUUsTUFBTSxFQUFOLE1B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VkLnN5bWJvbHMpO1xuICAgIHJldHVybiB2bS5leGVjdXRlKGNvbXBpbGVkLm9wcyk7XG4gIH07XG4gIHJldHVybiB7IGlkLCBtZXRhLCBfYmxvY2s6IGJsb2NrLCBhc0VudHJ5UG9pbnQsIGFzTGF5b3V0LCBhc1BhcnRpYWwsIHJlbmRlciB9O1xufVxuIl19 -enifed('glimmer-runtime/lib/upsert', ['exports', 'glimmer-runtime/lib/bounds'], function (exports, _glimmerRuntimeLibBounds) { - 'use strict'; + computed.sum = _emberRuntime.sum; + computed.min = _emberRuntime.min; + computed.max = _emberRuntime.max; + computed.map = _emberRuntime.map; + computed.sort = _emberRuntime.sort; + computed.setDiff = _emberRuntime.setDiff; + computed.mapBy = _emberRuntime.mapBy; + computed.filter = _emberRuntime.filter; + computed.filterBy = _emberRuntime.filterBy; + computed.uniq = _emberRuntime.uniq; - exports.isSafeString = isSafeString; - exports.isNode = isNode; - exports.isString = isString; - exports.cautiousInsert = cautiousInsert; - exports.trustingInsert = trustingInsert; + computed.uniqBy = _emberRuntime.uniqBy; + computed.union = _emberRuntime.union; + computed.intersect = _emberRuntime.intersect; + computed.collect = _emberRuntime.collect; - function isSafeString(value) { - return value && typeof value['toHTML'] === 'function'; - } + /** + Defines the hash of localized strings for the current language. Used by + the `Ember.String.loc()` helper. To localize, add string values to this + hash. + + @property STRINGS + @for Ember + @type Object + @private + */ + Object.defineProperty(_emberMetal.default, 'STRINGS', { + configurable: false, + get: _emberRuntime.getStrings, + set: _emberRuntime.setStrings + }); - function isNode(value) { - return value !== null && typeof value === 'object' && typeof value['nodeType'] === 'number'; - } + /** + Whether searching on the global for new Namespace instances is enabled. + + This is only exported here as to not break any addons. Given the new + visit API, you will have issues if you treat this as a indicator of + booted. + + Internally this is only exposing a flag in Namespace. + + @property BOOTED + @for Ember + @type Boolean + @private + */ + Object.defineProperty(_emberMetal.default, 'BOOTED', { + configurable: false, + enumerable: false, + get: _emberRuntime.isNamespaceSearchDisabled, + set: _emberRuntime.setNamespaceSearchDisabled + }); - function isString(value) { - return typeof value === 'string'; - } + _emberMetal.default.Component = _emberGlimmer.Component; + _emberGlimmer.Helper.helper = _emberGlimmer.helper; + _emberMetal.default.Helper = _emberGlimmer.Helper; + _emberMetal.default.Checkbox = _emberGlimmer.Checkbox; + _emberMetal.default.TextField = _emberGlimmer.TextField; + _emberMetal.default.TextArea = _emberGlimmer.TextArea; + _emberMetal.default.LinkComponent = _emberGlimmer.LinkComponent; - var Upsert = function Upsert(bounds) { - this.bounds = bounds; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + String.prototype.htmlSafe = function () { + return _emberGlimmer.htmlSafe(this); }; + } - exports.default = Upsert; - - function cautiousInsert(dom, cursor, value) { - if (isString(value)) { - return TextUpsert.insert(dom, cursor, value); - } - if (isSafeString(value)) { - return SafeStringUpsert.insert(dom, cursor, value); - } - if (isNode(value)) { - return NodeUpsert.insert(dom, cursor, value); - } - } - - function trustingInsert(dom, cursor, value) { - if (isString(value)) { - return HTMLUpsert.insert(dom, cursor, value); - } - if (isNode(value)) { - return NodeUpsert.insert(dom, cursor, value); - } - } - - var TextUpsert = (function (_Upsert) { - babelHelpers.inherits(TextUpsert, _Upsert); + var EmberHandlebars = _emberMetal.default.Handlebars = _emberMetal.default.Handlebars || {}; + var EmberHTMLBars = _emberMetal.default.HTMLBars = _emberMetal.default.HTMLBars || {}; + var EmberHandleBarsUtils = EmberHandlebars.Utils = EmberHandlebars.Utils || {}; - function TextUpsert(bounds, textNode) { - _Upsert.call(this, bounds); - this.textNode = textNode; - } + Object.defineProperty(EmberHandlebars, 'SafeString', { + get: _emberGlimmer._getSafeString + }); - TextUpsert.insert = function insert(dom, cursor, value) { - var textNode = dom.createTextNode(value); - dom.insertBefore(cursor.element, textNode, cursor.nextSibling); - var bounds = new _glimmerRuntimeLibBounds.SingleNodeBounds(cursor.element, textNode); - return new TextUpsert(bounds, textNode); - }; + EmberHTMLBars.template = EmberHandlebars.template = _emberGlimmer.template; + EmberHandleBarsUtils.escapeExpression = _emberGlimmer.escapeExpression; + _emberRuntime.String.htmlSafe = _emberGlimmer.htmlSafe; - TextUpsert.prototype.update = function update(dom, value) { - if (isString(value)) { - var textNode = this.textNode; + _emberRuntime.String.isHTMLSafe = _emberGlimmer.isHTMLSafe; + EmberHTMLBars.makeBoundHelper = _emberGlimmer.makeBoundHelper; - textNode.nodeValue = value; - return true; - } else { - return false; - } - }; + /** + Global hash of shared templates. This will automatically be populated + by the build tools so that you can store your Handlebars templates in + separate files that get loaded into JavaScript at buildtime. + + @property TEMPLATES + @for Ember + @type Object + @private + */ + Object.defineProperty(_emberMetal.default, 'TEMPLATES', { + get: _emberGlimmer.getTemplates, + set: _emberGlimmer.setTemplates, + configurable: false, + enumerable: false + }); - return TextUpsert; - })(Upsert); + exports.VERSION = _emberVersion.default; - var HTMLUpsert = (function (_Upsert2) { - babelHelpers.inherits(HTMLUpsert, _Upsert2); + /** + The semantic version + @property VERSION + @type String + @public + */ + _emberMetal.default.VERSION = _emberVersion.default; - function HTMLUpsert() { - _Upsert2.apply(this, arguments); - } + _emberMetal.libraries.registerCoreLibrary('Ember', _emberVersion.default); - HTMLUpsert.insert = function insert(dom, cursor, value) { - var bounds = dom.insertHTMLBefore(cursor.element, value, cursor.nextSibling); - return new HTMLUpsert(bounds); - }; + _emberMetal.default.create = _emberMetal.deprecateFunc('Ember.create is deprecated in favor of Object.create', { id: 'ember-metal.ember-create', until: '3.0.0' }, Object.create); + _emberMetal.default.keys = _emberMetal.deprecateFunc('Ember.keys is deprecated in favor of Object.keys', { id: 'ember-metal.ember.keys', until: '3.0.0' }, Object.keys); - HTMLUpsert.prototype.update = function update(dom, value) { - if (isString(value)) { - var bounds = this.bounds; + // require the main entry points for each of these packages + // this is so that the global exports occur properly - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertHTMLBefore(parentElement, nextSibling, value); - return true; - } else { - return false; - } - }; + /** + Alias for jQuery + + @method $ + @for Ember + @public + */ + _emberMetal.default.$ = _emberViews.jQuery; - return HTMLUpsert; - })(Upsert); + _emberMetal.default.ViewTargetActionSupport = _emberViews.ViewTargetActionSupport; - var SafeStringUpsert = (function (_Upsert3) { - babelHelpers.inherits(SafeStringUpsert, _Upsert3); + _emberMetal.default.ViewUtils = { + isSimpleClick: _emberViews.isSimpleClick, + getViewElement: _emberViews.getViewElement, + getViewBounds: _emberViews.getViewBounds, + getViewClientRects: _emberViews.getViewClientRects, + getViewBoundingClientRect: _emberViews.getViewBoundingClientRect, + getRootViews: _emberViews.getRootViews, + getChildViews: _emberViews.getChildViews + }; - function SafeStringUpsert(bounds, lastStringValue) { - _Upsert3.call(this, bounds); - this.lastStringValue = lastStringValue; - } + _emberMetal.default.TextSupport = _emberViews.TextSupport; + _emberMetal.default.ComponentLookup = _emberViews.ComponentLookup; + _emberMetal.default.EventDispatcher = _emberViews.EventDispatcher; - SafeStringUpsert.insert = function insert(dom, cursor, value) { - var stringValue = value.toHTML(); - var bounds = dom.insertHTMLBefore(cursor.element, stringValue, cursor.nextSibling); - return new SafeStringUpsert(bounds, stringValue); - }; + _emberMetal.default.Location = _emberRouting.Location; + _emberMetal.default.AutoLocation = _emberRouting.AutoLocation; + _emberMetal.default.HashLocation = _emberRouting.HashLocation; + _emberMetal.default.HistoryLocation = _emberRouting.HistoryLocation; + _emberMetal.default.NoneLocation = _emberRouting.NoneLocation; + _emberMetal.default.controllerFor = _emberRouting.controllerFor; + _emberMetal.default.generateControllerFactory = _emberRouting.generateControllerFactory; + _emberMetal.default.generateController = _emberRouting.generateController; + _emberMetal.default.RouterDSL = _emberRouting.RouterDSL; + _emberMetal.default.Router = _emberRouting.Router; + _emberMetal.default.Route = _emberRouting.Route; - SafeStringUpsert.prototype.update = function update(dom, value) { - if (isSafeString(value)) { - var stringValue = value.toHTML(); - if (stringValue !== this.lastStringValue) { - var bounds = this.bounds; + _emberMetal.default.Application = _emberApplication.Application; + _emberMetal.default.ApplicationInstance = _emberApplication.ApplicationInstance; + _emberMetal.default.Engine = _emberApplication.Engine; + _emberMetal.default.EngineInstance = _emberApplication.EngineInstance; + _emberMetal.default.DefaultResolver = _emberMetal.default.Resolver = _emberApplication.Resolver; - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertHTMLBefore(parentElement, nextSibling, stringValue); - this.lastStringValue = stringValue; - } - return true; - } else { - return false; - } - }; + _emberRuntime.runLoadHooks('Ember.Application', _emberApplication.Application); - return SafeStringUpsert; - })(Upsert); + _emberMetal.default.DataAdapter = _emberExtensionSupport.DataAdapter; + _emberMetal.default.ContainerDebugAdapter = _emberExtensionSupport.ContainerDebugAdapter; - var NodeUpsert = (function (_Upsert4) { - babelHelpers.inherits(NodeUpsert, _Upsert4); + if (_require.has('ember-template-compiler')) { + _require.default('ember-template-compiler'); + } - function NodeUpsert() { - _Upsert4.apply(this, arguments); - } + // do this to ensure that Ember.Test is defined properly on the global + // if it is present. + if (_require.has('ember-testing')) { + var testing = _require.default('ember-testing'); - NodeUpsert.insert = function insert(dom, cursor, node) { - dom.insertBefore(cursor.element, node, cursor.nextSibling); - return new NodeUpsert(_glimmerRuntimeLibBounds.single(cursor.element, node)); - }; + _emberMetal.default.Test = testing.Test; + _emberMetal.default.Test.Adapter = testing.Adapter; + _emberMetal.default.Test.QUnitAdapter = testing.QUnitAdapter; + _emberMetal.default.setupForTesting = testing.setupForTesting; + } - NodeUpsert.prototype.update = function update(dom, value) { - if (isNode(value)) { - var bounds = this.bounds; + _emberRuntime.runLoadHooks('Ember'); - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertNodeBefore(parentElement, value, nextSibling); - return true; - } else { - return false; - } - }; + /** + @module ember + */ + exports.default = _emberMetal.default; - return NodeUpsert; - })(Upsert); + /* globals module */ + if (typeof module === 'object' && module.exports) { + module.exports = _emberMetal.default; + } else { + _emberEnvironment.context.exports.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AgICAgIGxldCBuZXh0U2libGluZyA9IGNsZWFyKGJvdW5kcyk7XG5cbiAgICAgIHRoaXMuYm91bmRzID0gZG9tLmluc2VydE5vZGVCZWZvcmUocGFyZW50RWxlbWVudCBhcyBGSVhfUkVJRklDQVRJT048RWxlbWVudD4sIHZhbHVlLCBuZXh0U2libGluZyBhcyBGSVhfUkVJRklDQVRJT048Tm9kZT4pO1xuXG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9IGVsc2Uge1xuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/utils', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; - - var EMPTY_ARRAY = Object.freeze([]); - exports.EMPTY_ARRAY = EMPTY_ARRAY; - var EMPTY_DICT = Object.freeze(_glimmerUtil.dict()); - exports.EMPTY_DICT = EMPTY_DICT; - - var ListRange = (function () { - function ListRange(list, start, end) { - this.list = list; - this.start = start; - this.end = end; - } - ListRange.prototype.at = function at(index) { - if (index >= this.list.length) return null; - return this.list[index]; - }; +// ****ember-environment**** - ListRange.prototype.min = function min() { - return this.start; - }; +// ****ember-metal**** - ListRange.prototype.max = function max() { - return this.end; - }; +// computed macros - return ListRange; - })(); +// reduced computed macros +enifed("ember/version", ["exports"], function (exports) { + "use strict"; - exports.ListRange = ListRange; + exports.default = "2.12.0-canary"; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRU8sUUFBTSxXQUFXLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQzs7QUFDdEMsUUFBTSxVQUFVLEdBQWMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxhQUhwQyxJQUFJLEVBRzJDLENBQUMsQ0FBQzs7O1FBb0JoR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RWFjaChjYWxsYmFjazogRW51bWVyYWJsZUNhbGxiYWNrPFQ+KTtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBEZXN0cm95YWJsZSB7XG4gIGRlc3Ryb3koKTtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBSYW5nZTxUPiB7XG4gIG1pbigpOiBudW1iZXI7XG4gIG1heCgpOiBudW1iZXI7XG4gIGF0KGluZGV4OiBudW1iZXIpOiBUO1xufVxuXG5leHBvcnQgY2xhc3MgTGlzdFJhbmdlPFQ+IGltcGxlbWVudHMgUmFuZ2U8VD4ge1xuICBwcml2YXRlIGxpc3Q6IFRbXTtcblxuICAvLyBbc3RhcnQsIGVuZF1cbiAgcHJpdmF0ZSBzdGFydDogbnVtYmVyO1xuICBwcml2YXRlIGVuZDogbnVtYmVyO1xuXG4gIGNvbnN0cnVjdG9yKGxpc3Q6IFRbXSwgc3RhcnQ6IG51bWJlciwgZW5kOiBudW1iZXIpIHtcbiAgICB0aGlzLmxpc3QgPSBsaXN0O1xuICAgIHRoaXMuc3RhcnQgPSBzdGFydDtcbiAgICB0aGlzLmVuZCA9IGVuZDtcbiAgfVxuXG4gIGF0KGluZGV4OiBudW1iZXIpOiBUIHtcbiAgICBpZiAoaW5kZXggPj0gdGhpcy5saXN0Lmxlbmd0aCkgcmV0dXJuIG51bGw7XG4gICAgcmV0dXJuIHRoaXMubGlzdFtpbmRleF07XG4gIH1cblxuICBtaW4oKTogbnVtYmVyIHtcbiAgICByZXR1cm4gdGhpcy5zdGFydDtcbiAgfVxuXG4gIG1heCgpOiBudW1iZXIge1xuICAgIHJldHVybiB0aGlzLmVuZDtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/vm', ['exports', 'glimmer-runtime/lib/vm/append', 'glimmer-runtime/lib/vm/update', 'glimmer-runtime/lib/vm/render-result'], function (exports, _glimmerRuntimeLibVmAppend, _glimmerRuntimeLibVmUpdate, _glimmerRuntimeLibVmRenderResult) { +enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; - exports.VM = _glimmerRuntimeLibVmAppend.default; - exports.PublicVM = _glimmerRuntimeLibVmAppend.PublicVM; - exports.UpdatingVM = _glimmerRuntimeLibVmUpdate.default; - exports.RenderResult = _glimmerRuntimeLibVmRenderResult.default; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1VBQW9CLEVBQUUsOEJBQWIsT0FBTztVQUFRLFFBQVEsOEJBQVIsUUFBUTtVQUNaLFVBQVUsOEJBQXJCLE9BQU87VUFDSSxZQUFZLG9DQUF2QixPQUFPIiwiZmlsZSI6InZtLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBWTSwgUHVibGljVk0gfSBmcm9tICcuL3ZtL2FwcGVuZCc7XG5leHBvcnQgeyBkZWZhdWx0IGFzIFVwZGF0aW5nVk0gfSBmcm9tICcuL3ZtL3VwZGF0ZSc7XG5leHBvcnQgeyBkZWZhdWx0IGFzIFJlbmRlclJlc3VsdCB9IGZyb20gJy4vdm0vcmVuZGVyLXJlc3VsdCc7XG4iXX0= -enifed('glimmer-runtime/lib/vm/append', ['exports', 'glimmer-runtime/lib/environment', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-runtime/lib/vm/update', 'glimmer-runtime/lib/vm/render-result', 'glimmer-runtime/lib/vm/frame'], function (exports, _glimmerRuntimeLibEnvironment, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerRuntimeLibVmUpdate, _glimmerRuntimeLibVmRenderResult, _glimmerRuntimeLibVmFrame) { - 'use strict'; - - var VM = (function () { - function VM(env, scope, dynamicScope, elementStack) { - this.env = env; - this.elementStack = elementStack; - this.dynamicScopeStack = new _glimmerUtil.Stack(); - this.scopeStack = new _glimmerUtil.Stack(); - this.updatingOpcodeStack = new _glimmerUtil.Stack(); - this.cacheGroups = new _glimmerUtil.Stack(); - this.listBlockStack = new _glimmerUtil.Stack(); - this.frame = new _glimmerRuntimeLibVmFrame.FrameStack(); - this.env = env; - this.elementStack = elementStack; - this.scopeStack.push(scope); - this.dynamicScopeStack.push(dynamicScope); - } - - VM.initial = function initial(env, self, dynamicScope, elementStack, size) { - var scope = _glimmerRuntimeLibEnvironment.Scope.root(self, size); - return new VM(env, scope, dynamicScope, elementStack); - }; - - VM.prototype.capture = function capture() { - return { - env: this.env, - scope: this.scope(), - dynamicScope: this.dynamicScope(), - frame: this.frame.capture() - }; - }; - - VM.prototype.goto = function goto(op) { - // assert(this.frame.getOps().contains(op), `Illegal jump to ${op.label}`); - this.frame.goto(op); - }; - - VM.prototype.beginCacheGroup = function beginCacheGroup() { - this.cacheGroups.push(this.updatingOpcodeStack.current.tail()); - }; - - VM.prototype.commitCacheGroup = function commitCacheGroup() { - // JumpIfNotModified(END) - // (head) - // (....) - // (tail) - // DidModify - // END: Noop - var END = new _glimmerRuntimeLibCompiledOpcodesVm.LabelOpcode("END"); - var opcodes = this.updatingOpcodeStack.current; - var marker = this.cacheGroups.pop(); - var head = marker ? opcodes.nextNode(marker) : opcodes.head(); - var tail = opcodes.tail(); - var tag = _glimmerReference.combineSlice(new _glimmerUtil.ListSlice(head, tail)); - var guard = new _glimmerRuntimeLibCompiledOpcodesVm.JumpIfNotModifiedOpcode(tag, END); - opcodes.insertBefore(guard, head); - opcodes.append(new _glimmerRuntimeLibCompiledOpcodesVm.DidModifyOpcode(guard)); - opcodes.append(END); - }; - - VM.prototype.enter = function enter(ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushUpdatableBlock(); - var state = this.capture(); - var tryOpcode = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, updating); - this.didEnter(tryOpcode, updating); - }; - - VM.prototype.enterWithKey = function enterWithKey(key, ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushUpdatableBlock(); - var state = this.capture(); - var tryOpcode = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, updating); - this.listBlockStack.current.map[key] = tryOpcode; - this.didEnter(tryOpcode, updating); - }; - - VM.prototype.enterList = function enterList(ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushBlockList(updating); - var state = this.capture(); - var artifacts = this.frame.getIterator().artifacts; - var opcode = new _glimmerRuntimeLibVmUpdate.ListBlockOpcode(ops, state, tracker, updating, artifacts); - this.listBlockStack.push(opcode); - this.didEnter(opcode, updating); - }; - - VM.prototype.didEnter = function didEnter(opcode, updating) { - this.updateWith(opcode); - this.updatingOpcodeStack.push(updating); - }; - - VM.prototype.exit = function exit() { - this.stack().popBlock(); - this.updatingOpcodeStack.pop(); - var parent = this.updatingOpcodeStack.current.tail(); - parent.didInitializeChildren(); - }; - - VM.prototype.exitList = function exitList() { - this.exit(); - this.listBlockStack.pop(); - }; - - VM.prototype.updateWith = function updateWith(opcode) { - this.updatingOpcodeStack.current.append(opcode); - }; - - VM.prototype.stack = function stack() { - return this.elementStack; - }; - - VM.prototype.scope = function scope() { - return this.scopeStack.current; - }; - - VM.prototype.dynamicScope = function dynamicScope() { - return this.dynamicScopeStack.current; - }; - - VM.prototype.pushFrame = function pushFrame(block, args, callerScope) { - this.frame.push(block.ops); - if (args) this.frame.setArgs(args); - if (args && args.blocks) this.frame.setBlocks(args.blocks); - if (callerScope) this.frame.setCallerScope(callerScope); - }; - - VM.prototype.pushComponentFrame = function pushComponentFrame(layout, args, callerScope, component, manager, shadow) { - this.frame.push(layout.ops, component, manager, shadow); - if (args) this.frame.setArgs(args); - if (args && args.blocks) this.frame.setBlocks(args.blocks); - if (callerScope) this.frame.setCallerScope(callerScope); - }; + exports.default = applyMixins; - VM.prototype.pushEvalFrame = function pushEvalFrame(ops) { - this.frame.push(ops); - }; + function isGenerator(mixin) { + return Array.isArray(mixin.cases) && typeof mixin.generate === 'function'; + } - VM.prototype.pushChildScope = function pushChildScope() { - this.scopeStack.push(this.scopeStack.current.child()); - }; + function applyMixins(TestClass) { + for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + mixins[_key - 1] = arguments[_key]; + } - VM.prototype.pushCallerScope = function pushCallerScope() { - this.scopeStack.push(this.scope().getCallerScope()); - }; + mixins.forEach(function (mixinOrGenerator) { + var mixin = undefined; - VM.prototype.pushDynamicScope = function pushDynamicScope() { - var child = this.dynamicScopeStack.current.child(); - this.dynamicScopeStack.push(child); - return child; - }; + if (isGenerator(mixinOrGenerator)) { + (function () { + var generator = mixinOrGenerator; + mixin = {}; - VM.prototype.pushRootScope = function pushRootScope(self, size) { - var scope = _glimmerRuntimeLibEnvironment.Scope.root(self, size); - this.scopeStack.push(scope); - return scope; - }; + generator.cases.forEach(function (value, idx) { + _emberUtils.assign(mixin, generator.generate(value, idx)); + }); + })(); + } else { + mixin = mixinOrGenerator; + } - VM.prototype.popScope = function popScope() { - this.scopeStack.pop(); - }; + _emberUtils.assign(TestClass.prototype, mixin); + }); - VM.prototype.popDynamicScope = function popDynamicScope() { - this.dynamicScopeStack.pop(); - }; + return TestClass; + } +}); +enifed('internal-test-helpers/build-owner', ['exports', 'container', 'ember-routing', 'ember-application', 'ember-metal', 'ember-runtime'], function (exports, _container, _emberRouting, _emberApplication, _emberMetal, _emberRuntime) { + 'use strict'; - VM.prototype.newDestroyable = function newDestroyable(d) { - this.stack().newDestroyable(d); - }; + exports.default = buildOwner; - /// SCOPE HELPERS + function buildOwner() { + var _EmberObject$extend; - VM.prototype.getSelf = function getSelf() { - return this.scope().getSelf(); - }; + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - VM.prototype.referenceForSymbol = function referenceForSymbol(symbol) { - return this.scope().getSymbol(symbol); - }; + var ownerOptions = options.ownerOptions || {}; + var resolver = options.resolver; + var bootOptions = options.bootOptions || {}; - VM.prototype.getArgs = function getArgs() { - return this.frame.getArgs(); - }; + var Owner = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, (_EmberObject$extend = {}, _EmberObject$extend[_container.FACTORY_FOR] = function () { + var _container__; - /// EXECUTION + return (_container__ = this.__container__)[_container.FACTORY_FOR].apply(_container__, arguments); + }, _EmberObject$extend[_container.LOOKUP_FACTORY] = function () { + var _container__2; - VM.prototype.resume = function resume(opcodes, frame) { - return this.execute(opcodes, function (vm) { - return vm.frame.restore(frame); - }); - }; + return (_container__2 = this.__container__)[_container.LOOKUP_FACTORY].apply(_container__2, arguments); + }, _EmberObject$extend)); - VM.prototype.execute = function execute(opcodes, initialize) { - _glimmerUtil.LOGGER.debug("[VM] Begin program execution"); - var elementStack = this.elementStack; - var frame = this.frame; - var updatingOpcodeStack = this.updatingOpcodeStack; - var env = this.env; - - elementStack.pushSimpleBlock(); - updatingOpcodeStack.push(new _glimmerUtil.LinkedList()); - frame.push(opcodes); - if (initialize) initialize(this); - var opcode = undefined; - while (frame.hasOpcodes()) { - if (opcode = frame.nextStatement()) { - _glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type); - _glimmerUtil.LOGGER.trace(opcode); - opcode.evaluate(this); - } - } - _glimmerUtil.LOGGER.debug("[VM] Completed program execution"); - return new _glimmerRuntimeLibVmRenderResult.default(env, updatingOpcodeStack.pop(), elementStack.popBlock()); - }; + if (true) { + Owner.reopen({ + factoryFor: function () { + var _container__3; - VM.prototype.evaluateOpcode = function evaluateOpcode(opcode) { - opcode.evaluate(this); - }; + return (_container__3 = this.__container__).factoryFor.apply(_container__3, arguments); + } + }); + } - // Make sure you have opcodes that push and pop a scope around this opcode - // if you need to change the scope. + var namespace = _emberRuntime.Object.create({ + Resolver: { create: function () { + return resolver; + } } + }); - VM.prototype.invokeBlock = function invokeBlock(block, args) { - var compiled = block.compile(this.env); - this.pushFrame(compiled, args); - }; + var fallbackRegistry = _emberApplication.Application.buildRegistry(namespace); + fallbackRegistry.register('router:main', _emberRouting.Router); - VM.prototype.invokePartial = function invokePartial(block) { - var compiled = block.compile(this.env); - this.pushFrame(compiled); - }; + var registry = new _container.Registry({ + fallback: fallbackRegistry + }); - VM.prototype.invokeLayout = function invokeLayout(args, layout, callerScope, component, manager, shadow) { - this.pushComponentFrame(layout, args, callerScope, component, manager, shadow); - }; + _emberApplication.ApplicationInstance.setupRegistry(registry, bootOptions); - VM.prototype.evaluateOperand = function evaluateOperand(expr) { - this.frame.setOperand(expr.evaluate(this)); - }; + var owner = Owner.create({ + __registry__: registry, + __container__: null + }, ownerOptions); - VM.prototype.evaluateArgs = function evaluateArgs(args) { - var evaledArgs = this.frame.setArgs(args.evaluate(this)); - this.frame.setOperand(evaledArgs.positional.at(0)); - }; + var container = registry.container({ owner: owner }); + owner.__container__ = container; - VM.prototype.bindPositionalArgs = function bindPositionalArgs(symbols) { - var args = this.frame.getArgs(); - _glimmerUtil.assert(args, "Cannot bind positional args"); - var positional = args.positional; + return owner; + } +}); +enifed('internal-test-helpers/confirm-export', ['exports', 'require'], function (exports, _require) { + 'use strict'; - var scope = this.scope(); - for (var i = 0; i < symbols.length; i++) { - scope.bindSymbol(symbols[i], positional.at(i)); - } - }; + exports.default = confirmExport; - VM.prototype.bindNamedArgs = function bindNamedArgs(names, symbols) { - var args = this.frame.getArgs(); - var scope = this.scope(); - _glimmerUtil.assert(args, "Cannot bind named args"); - var named = args.named; + function getDescriptor(obj, path) { + var parts = path.split('.'); + var value = obj; + for (var i = 0; i < parts.length - 1; i++) { + var part = parts[i]; + value = value[part]; + if (!value) { + return undefined; + } + } + var last = parts[parts.length - 1]; + return Object.getOwnPropertyDescriptor(value, last); + } - for (var i = 0; i < names.length; i++) { - scope.bindSymbol(symbols[i], named.get(names[i])); - } - }; + function confirmExport(Ember, assert, path, moduleId, exportName) { + var desc = getDescriptor(Ember, path); + assert.ok(desc, 'the property exists on the global'); - VM.prototype.bindBlocks = function bindBlocks(names, symbols) { - var blocks = this.frame.getBlocks(); - var scope = this.scope(); - for (var i = 0; i < names.length; i++) { - scope.bindBlock(symbols[i], blocks && blocks[names[i]] || null); - } - }; + var mod = _require.default(moduleId); + if (typeof exportName === 'string') { + assert.equal(desc.value, mod[exportName], 'Ember.' + path + ' is exported correctly'); + assert.notEqual(mod[exportName], undefined, 'Ember.' + path + ' is not `undefined`'); + } else { + assert.equal(desc.get, mod[exportName.get], 'Ember.' + path + ' getter is exported correctly'); + assert.notEqual(desc.get, undefined, 'Ember.' + path + ' getter is not undefined'); - VM.prototype.bindPartialArgs = function bindPartialArgs(symbol) { - var args = this.frame.getArgs(); - var scope = this.scope(); - _glimmerUtil.assert(args, "Cannot bind named args"); - scope.bindPartialArgs(symbol, args); - }; + if (exportName.set) { + assert.equal(desc.set, mod[exportName.set], 'Ember.' + path + ' setter is exported correctly'); + assert.notEqual(desc.set, undefined, 'Ember.' + path + ' setter is not undefined'); + } + } + } +}); +enifed('internal-test-helpers/equal-inner-html', ['exports'], function (exports) { + // detect side-effects of cloning svg elements in IE9-11 + 'use strict'; - VM.prototype.bindCallerScope = function bindCallerScope() { - var callerScope = this.frame.getCallerScope(); - var scope = this.scope(); - _glimmerUtil.assert(callerScope, "Cannot bind caller scope"); - scope.bindCallerScope(callerScope); - }; + exports.default = equalInnerHTML; + var ieSVGInnerHTML = (function () { + if (!document.createElementNS) { + return false; + } + var div = document.createElement('div'); + var node = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + div.appendChild(node); + var clone = div.cloneNode(true); + return clone.innerHTML === ''; + })(); - VM.prototype.bindDynamicScope = function bindDynamicScope(names) { - var args = this.frame.getArgs(); - var scope = this.dynamicScope(); - _glimmerUtil.assert(args, "Cannot bind dynamic scope"); - for (var i = 0; i < names.length; i++) { - scope.set(names[i], args.named.get(names[i])); - } - }; + function normalizeInnerHTML(actualHTML) { + if (ieSVGInnerHTML) { + // Replace `` with ``, etc. + // drop namespace attribute + actualHTML = actualHTML.replace(/ xmlns="[^"]+"/, ''); + // replace self-closing elements + actualHTML = actualHTML.replace(/<([^ >]+) [^\/>]*\/>/gi, function (tag, tagName) { + return tag.slice(0, tag.length - 3) + '>'; + }); + } - return VM; - })(); + return actualHTML; + } - exports.default = VM; + function equalInnerHTML(fragment, html) { + var actualHTML = normalizeInnerHTML(fragment.innerHTML); + QUnit.push(actualHTML === html, actualHTML, html); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vYXBwZW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQXlCQSxFQUFBO0FBbUJFLGlCQW5CRixFQUFBLENBb0JXLEdBQWdCLEVBQ3ZCLEtBQVksRUFDWixZQUEwQixFQUNsQixZQUEwQixFQUFBO0FBSDNCLGdCQUFBLENBQUEsR0FBRyxHQUFILEdBQUcsQ0FBYTtBQUdmLGdCQUFBLENBQUEsWUFBWSxHQUFaLFlBQVksQ0FBYztBQXRCNUIsZ0JBQUEsQ0FBQSxpQkFBaUIsR0FBRyxpQkF4QlIsS0FBSyxFQXdCNEIsQ0FBQztBQUM5QyxnQkFBQSxDQUFBLFVBQVUsR0FBRyxpQkF6QkQsS0FBSyxFQXlCYyxDQUFDO0FBQ2pDLGdCQUFBLENBQUEsbUJBQW1CLEdBQUcsaUJBMUJULEtBQUssRUEwQjJDLENBQUM7QUFDOUQsZ0JBQUEsQ0FBQSxXQUFXLEdBQUcsaUJBM0JELEtBQUssRUEyQnVCLENBQUM7QUFDMUMsZ0JBQUEsQ0FBQSxjQUFjLEdBQUcsaUJBNUJKLEtBQUssRUE0QjJCLENBQUM7QUFDOUMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUcsOEJBbEJPLFVBQVUsRUFrQkQsQ0FBQztBQW1COUIsZ0JBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO0FBQ2YsZ0JBQUksQ0FBQyxZQUFZLE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GxlclNjb3BlKGNhbGxlclNjb3BlKTtcbiAgfVxuXG4gIGJpbmREeW5hbWljU2NvcGUobmFtZXM6IHN0cmluZ1tdKSB7XG4gICAgbGV0IGFyZ3MgPSB0aGlzLmZyYW1lLmdldEFyZ3MoKTtcbiAgICBsZXQgc2NvcGUgPSB0aGlzLmR5bmFtaWNTY29wZSgpO1xuXG4gICAgYXNzZXJ0KGFyZ3MsIFwiQ2Fubm90IGJpbmQgZHluYW1pYyBzY29wZVwiKTtcblxuICAgIGZvcihsZXQgaT0wOyBpIDwgbmFtZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgIHNjb3BlLnNldChuYW1lc1tpXSwgYXJncy5uYW1lZC5nZXQobmFtZXNbaV0pKTtcbiAgICB9XG4gIH1cbn1cblxuaW50ZXJmYWNlIEV4Y2VwdGlvbkhhbmRsZXIge1xuICBoYW5kbGVFeGNlcHRpb24oaW5pdGlhbGl6ZT86ICh2bTogVk0pID0+IHZvaWQpO1xufVxuXG5pbnRlcmZhY2UgUmV0dXJuSGFuZGxlciB7XG4gIHNldFJlbmRlclJlc3VsdChyZW5kZXJSZXN1bHQ6IFJlbmRlclJlc3VsdCk7XG59XG4iXX0= -enifed('glimmer-runtime/lib/vm/frame', ['exports'], function (exports) { - 'use strict'; - - var CapturedFrame = function CapturedFrame(operand, args, condition) { - this.operand = operand; - this.args = args; - this.condition = condition; - }; - - exports.CapturedFrame = CapturedFrame; - - var Frame = (function () { - function Frame(ops) { - var component = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - var manager = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - var shadow = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; - - this.component = component; - this.manager = manager; - this.shadow = shadow; - this.operand = null; - this.immediate = null; - this.args = null; - this.callerScope = null; - this.blocks = null; - this.condition = null; - this.iterator = null; - this.key = null; - this.ops = ops; - this.op = ops.head(); - } - - Frame.prototype.capture = function capture() { - return new CapturedFrame(this.operand, this.args, this.condition); - }; - - Frame.prototype.restore = function restore(frame) { - this.operand = frame['operand']; - this.args = frame['args']; - this.condition = frame['condition']; - }; +enifed('internal-test-helpers/equal-tokens', ['exports', 'simple-html-tokenizer'], function (exports, _simpleHtmlTokenizer) { + 'use strict'; - return Frame; - })(); + exports.default = equalTokens; - var FrameStack = (function () { - function FrameStack() { - this.frames = []; - this.frame = undefined; - } + function generateTokens(containerOrHTML) { + if (typeof containerOrHTML === 'string') { + return { + tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML), + html: containerOrHTML + }; + } else { + return { + tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML.innerHTML), + html: containerOrHTML.innerHTML + }; + } + } - FrameStack.prototype.push = function push(ops) { - var component = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - var manager = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - var shadow = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + function normalizeTokens(tokens) { + tokens.forEach(function (token) { + if (token.type === 'StartTag') { + token.attributes = token.attributes.sort(function (a, b) { + if (a[0] > b[0]) { + return 1; + } + if (a[0] < b[0]) { + return -1; + } + return 0; + }); + } + }); + } - var frame = this.frame === undefined ? this.frame = 0 : ++this.frame; - if (this.frames.length <= frame) { - this.frames.push(null); - } - this.frames[frame] = new Frame(ops, component, manager, shadow); - }; + function equalTokens(actualContainer, expectedHTML) { + var message = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - FrameStack.prototype.pop = function pop() { - var frames = this.frames; - var frame = this.frame; + var actual = generateTokens(actualContainer); + var expected = generateTokens(expectedHTML); - frames[frame] = null; - this.frame = frame === 0 ? undefined : frame - 1; - }; + normalizeTokens(actual.tokens); + normalizeTokens(expected.tokens); - FrameStack.prototype.capture = function capture() { - return this.frames[this.frame].capture(); - }; + var equiv = QUnit.equiv(actual.tokens, expected.tokens); - FrameStack.prototype.restore = function restore(frame) { - this.frames[this.frame].restore(frame); - }; + if (equiv && expected.html !== actual.html) { + deepEqual(actual.tokens, expected.tokens, message); + } else { + QUnit.push(QUnit.equiv(actual.tokens, expected.tokens), actual.html, expected.html, message); + } + } +}); +enifed('internal-test-helpers/factory', ['exports'], function (exports) { + 'use strict'; - FrameStack.prototype.getOps = function getOps() { - return this.frames[this.frame].ops; - }; + exports.default = factory; + function setProperties(object, properties) { + for (var key in properties) { + if (properties.hasOwnProperty(key)) { + object[key] = properties[key]; + } + } + } - FrameStack.prototype.getCurrent = function getCurrent() { - return this.frames[this.frame].op; - }; + var guids = 0; - FrameStack.prototype.setCurrent = function setCurrent(op) { - return this.frames[this.frame].op = op; - }; + function factory() { + /*jshint validthis: true */ - FrameStack.prototype.getOperand = function getOperand() { - return this.frames[this.frame].operand; - }; + function Klass(options) { + setProperties(this, options); + this._guid = guids++; + this.isDestroyed = false; + } - FrameStack.prototype.setOperand = function setOperand(operand) { - return this.frames[this.frame].operand = operand; - }; + Klass.prototype.constructor = Klass; + Klass.prototype.destroy = function () { + this.isDestroyed = true; + }; - FrameStack.prototype.getImmediate = function getImmediate() { - return this.frames[this.frame].immediate; - }; + Klass.prototype.toString = function () { + return ''; + }; - FrameStack.prototype.setImmediate = function setImmediate(value) { - return this.frames[this.frame].immediate = value; - }; + Klass.create = create; + Klass.extend = extend; + Klass.reopen = extend; + Klass.reopenClass = reopenClass; - FrameStack.prototype.getArgs = function getArgs() { - return this.frames[this.frame].args; - }; + return Klass; - FrameStack.prototype.setArgs = function setArgs(args) { - var frame = this.frames[this.frame]; - return frame.args = args; - }; + function create(options) { + return new this.prototype.constructor(options); + } - FrameStack.prototype.getCondition = function getCondition() { - return this.frames[this.frame].condition; - }; + function reopenClass(options) { + setProperties(this, options); + } - FrameStack.prototype.setCondition = function setCondition(condition) { - return this.frames[this.frame].condition = condition; - }; + function extend(options) { + function Child(options) { + Klass.call(this, options); + } - FrameStack.prototype.getIterator = function getIterator() { - return this.frames[this.frame].iterator; - }; + var Parent = this; - FrameStack.prototype.setIterator = function setIterator(iterator) { - return this.frames[this.frame].iterator = iterator; - }; + Child.prototype = new Parent(); + Child.prototype.constructor = Child; - FrameStack.prototype.getKey = function getKey() { - return this.frames[this.frame].key; - }; + setProperties(Child, Klass); + setProperties(Child.prototype, options); - FrameStack.prototype.setKey = function setKey(key) { - return this.frames[this.frame].key = key; - }; + Child.create = create; + Child.extend = extend; + Child.reopen = extend; - FrameStack.prototype.getBlocks = function getBlocks() { - return this.frames[this.frame].blocks; - }; + Child.reopenClass = reopenClass; - FrameStack.prototype.setBlocks = function setBlocks(blocks) { - return this.frames[this.frame].blocks = blocks; - }; + return Child; + } + } +}); +enifed('internal-test-helpers/index', ['exports', 'internal-test-helpers/factory', 'internal-test-helpers/build-owner', 'internal-test-helpers/confirm-export', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/module-for', 'internal-test-helpers/strip', 'internal-test-helpers/apply-mixins', 'internal-test-helpers/matchers', 'internal-test-helpers/run', 'internal-test-helpers/test-groups', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/test-cases/abstract-application', 'internal-test-helpers/test-cases/application', 'internal-test-helpers/test-cases/query-param', 'internal-test-helpers/test-cases/abstract-rendering', 'internal-test-helpers/test-cases/rendering', 'internal-test-helpers/test-cases/router'], function (exports, _internalTestHelpersFactory, _internalTestHelpersBuildOwner, _internalTestHelpersConfirmExport, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersModuleFor, _internalTestHelpersStrip, _internalTestHelpersApplyMixins, _internalTestHelpersMatchers, _internalTestHelpersRun, _internalTestHelpersTestGroups, _internalTestHelpersTestCasesAbstract, _internalTestHelpersTestCasesAbstractApplication, _internalTestHelpersTestCasesApplication, _internalTestHelpersTestCasesQueryParam, _internalTestHelpersTestCasesAbstractRendering, _internalTestHelpersTestCasesRendering, _internalTestHelpersTestCasesRouter) { + 'use strict'; - FrameStack.prototype.getCallerScope = function getCallerScope() { - return this.frames[this.frame].callerScope; - }; + exports.factory = _internalTestHelpersFactory.default; + exports.buildOwner = _internalTestHelpersBuildOwner.default; + exports.confirmExport = _internalTestHelpersConfirmExport.default; + exports.equalInnerHTML = _internalTestHelpersEqualInnerHtml.default; + exports.equalTokens = _internalTestHelpersEqualTokens.default; + exports.moduleFor = _internalTestHelpersModuleFor.default; + exports.strip = _internalTestHelpersStrip.default; + exports.applyMixins = _internalTestHelpersApplyMixins.default; + exports.equalsElement = _internalTestHelpersMatchers.equalsElement; + exports.classes = _internalTestHelpersMatchers.classes; + exports.styles = _internalTestHelpersMatchers.styles; + exports.regex = _internalTestHelpersMatchers.regex; + exports.runAppend = _internalTestHelpersRun.runAppend; + exports.runDestroy = _internalTestHelpersRun.runDestroy; + exports.testBoth = _internalTestHelpersTestGroups.testBoth; + exports.testWithDefault = _internalTestHelpersTestGroups.testWithDefault; + exports.AbstractTestCase = _internalTestHelpersTestCasesAbstract.default; + exports.AbstractApplicationTestCase = _internalTestHelpersTestCasesAbstractApplication.default; + exports.ApplicationTestCase = _internalTestHelpersTestCasesApplication.default; + exports.QueryParamTestCase = _internalTestHelpersTestCasesQueryParam.default; + exports.AbstractRenderingTestCase = _internalTestHelpersTestCasesAbstractRendering.default; + exports.RenderingTestCase = _internalTestHelpersTestCasesRendering.default; + exports.RouterTestCase = _internalTestHelpersTestCasesRouter.default; +}); +enifed('internal-test-helpers/matchers', ['exports'], function (exports) { + 'use strict'; - FrameStack.prototype.setCallerScope = function setCallerScope(callerScope) { - return this.frames[this.frame].callerScope = callerScope; - }; + exports.regex = regex; + exports.classes = classes; + exports.styles = styles; + exports.equalsElement = equalsElement; + var HTMLElement = window.HTMLElement; + var MATCHER_BRAND = '3d4ef194-13be-4ccf-8dc7-862eea02c93e'; - FrameStack.prototype.getComponent = function getComponent() { - return this.frames[this.frame].component; - }; + function isMatcher(obj) { + return typeof obj === 'object' && obj !== null && MATCHER_BRAND in obj; + } - FrameStack.prototype.getManager = function getManager() { - return this.frames[this.frame].manager; - }; + function equalsAttr(expected) { + var _ref; - FrameStack.prototype.getShadow = function getShadow() { - return this.frames[this.frame].shadow; - }; + return _ref = {}, _ref[MATCHER_BRAND] = true, _ref.match = function (actual) { + return expected === actual; + }, _ref.expected = function () { + return expected; + }, _ref.message = function () { + return 'should equal ' + this.expected(); + }, _ref; + } - FrameStack.prototype.goto = function goto(op) { - this.setCurrent(op); - }; + function regex(r) { + var _ref2; - FrameStack.prototype.hasOpcodes = function hasOpcodes() { - return this.frame !== undefined; - }; + return _ref2 = {}, _ref2[MATCHER_BRAND] = true, _ref2.match = function (v) { + return r.test(v); + }, _ref2.expected = function () { + return r.toString(); + }, _ref2.message = function () { + return 'should match ' + this.expected(); + }, _ref2; + } - FrameStack.prototype.nextStatement = function nextStatement() { - var op = this.frames[this.frame].op; - var ops = this.getOps(); - if (op) { - this.setCurrent(ops.nextNode(op)); - return op; - } else { - this.pop(); - return null; - } - }; + function classes(expected) { + var _ref3; - return FrameStack; - })(); + return _ref3 = {}, _ref3[MATCHER_BRAND] = true, _ref3.match = function (actual) { + actual = actual.trim(); + return actual && expected.split(/\s+/).sort().join(' ') === actual.trim().split(/\s+/).sort().join(' '); + }, _ref3.expected = function () { + return expected; + }, _ref3.message = function () { + return 'should match ' + this.expected(); + }, _ref3; + } - exports.FrameStack = FrameStack; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vZnJhbWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBUUEsYUFBQSxHQUNFLFNBREYsYUFBQSxDQUVZLE9BQTJCLEVBQzNCLElBQW1CLEVBQ25CLFNBQTZCLEVBQUE7QUFGN0IsWUFBQSxDQUFBLE9BQU8sR0FBUCxPQUFPLENBQW9CO0FBQzNCLFlBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFlO0FBQ25CLFlBQUEsQ0FBQSxTQUFTLEdBQVQsU0FBUyxDQUFvQjtLQUNuQzs7Ozt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ICBoYXNPcGNvZGVzKCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLmZyYW1lICE9PSB1bmRlZmluZWQ7XG4gIH1cblxuICBuZXh0U3RhdGVtZW50KCk6IE9wY29kZSB7XG4gICAgbGV0IG9wID0gdGhpcy5mcmFtZXNbdGhpcy5mcmFtZV0ub3A7XG4gICAgbGV0IG9wcyA9IHRoaXMuZ2V0T3BzKCk7XG5cbiAgICBpZiAob3ApIHtcbiAgICAgIHRoaXMuc2V0Q3VycmVudChvcHMubmV4dE5vZGUob3ApKTtcbiAgICAgIHJldHVybiBvcDtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhpcy5wb3AoKTtcbiAgICAgIHJldHVybiBudWxsO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/vm/render-result', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/vm/update'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibVmUpdate) { - 'use strict'; + function styles(expected) { + var _ref4; - var RenderResult = (function () { - function RenderResult(env, updating, bounds) { - this.env = env; - this.updating = updating; - this.bounds = bounds; - } + return _ref4 = {}, _ref4[MATCHER_BRAND] = true, _ref4.match = function (actual) { + // coerce `null` or `undefined` to an empty string + // needed for matching empty styles on IE9 - IE11 + actual = actual || ''; + actual = actual.trim(); - RenderResult.prototype.rerender = function rerender() { - var _ref = arguments.length <= 0 || arguments[0] === undefined ? { alwaysRevalidate: false } : arguments[0]; + return expected.split(';').map(function (s) { + return s.trim(); + }).filter(function (s) { + return s; + }).sort().join('; ') === actual.split(';').map(function (s) { + return s.trim(); + }).filter(function (s) { + return s; + }).sort().join('; '); + }, _ref4.expected = function () { + return expected; + }, _ref4.message = function () { + return 'should match ' + this.expected(); + }, _ref4; + } - var _ref$alwaysRevalidate = _ref.alwaysRevalidate; - var alwaysRevalidate = _ref$alwaysRevalidate === undefined ? false : _ref$alwaysRevalidate; - var env = this.env; - var updating = this.updating; + function equalsElement(element, tagName, attributes, content) { + QUnit.push(element.tagName === tagName.toUpperCase(), element.tagName.toLowerCase(), tagName, 'expect tagName to be ' + tagName); - var vm = new _glimmerRuntimeLibVmUpdate.default(env, { alwaysRevalidate: alwaysRevalidate }); - vm.execute(updating, this); - }; + var expectedAttrs = {}; + var expectedCount = 0; - RenderResult.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + for (var _name in attributes) { + var expected = attributes[_name]; + if (expected !== null) { + expectedCount++; + } - RenderResult.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + var matcher = isMatcher(expected) ? expected : equalsAttr(expected); - RenderResult.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + expectedAttrs[_name] = matcher; - RenderResult.prototype.opcodes = function opcodes() { - return this.updating; - }; + QUnit.push(expectedAttrs[_name].match(element.getAttribute(_name)), element.getAttribute(_name), matcher.expected(), 'Element\'s ' + _name + ' attribute ' + matcher.message()); + } - RenderResult.prototype.handleException = function handleException() { - throw "this should never happen"; - }; + var actualAttributes = {}; - RenderResult.prototype.destroy = function destroy() { - this.bounds.destroy(); - _glimmerRuntimeLibBounds.clear(this.bounds); - }; + for (var i = 0, l = element.attributes.length; i < l; i++) { + actualAttributes[element.attributes[i].name] = element.attributes[i].value; + } - return RenderResult; - })(); + if (!(element instanceof HTMLElement)) { + QUnit.push(element instanceof HTMLElement, null, null, 'Element must be an HTML Element, not an SVG Element'); + } else { + QUnit.push(element.attributes.length === expectedCount || !attributes, element.attributes.length, expectedCount, 'Expected ' + expectedCount + ' attributes; got ' + element.outerHTML); - exports.default = RenderResult; + if (content !== null) { + QUnit.push(element.innerHTML === content, element.innerHTML, content, 'The element had \'' + content + '\' as its content'); + } + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vcmVuZGVyLXJlc3VsdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs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29kZT4sXG4gICAgcHJpdmF0ZSBib3VuZHM6IERlc3Ryb3lhYmxlQm91bmRzXG4gICkge31cblxuICByZXJlbmRlcih7IGFsd2F5c1JldmFsaWRhdGUgPSBmYWxzZSB9ID0geyBhbHdheXNSZXZhbGlkYXRlOiBmYWxzZSB9KSB7XG4gICAgbGV0IHsgZW52LCB1cGRhdGluZyB9ID0gdGhpcztcbiAgICBsZXQgdm0gPSBuZXcgVXBkYXRpbmdWTShlbnYsIHsgYWx3YXlzUmV2YWxpZGF0ZSB9KTtcbiAgICB2bS5leGVjdXRlKHVwZGF0aW5nLCB0aGlzKTtcbiAgfVxuXG4gIHBhcmVudEVsZW1lbnQoKTogU2ltcGxlLkVsZW1lbnQge1xuICAgIHJldHVybiB0aGlzLmJvdW5kcy5wYXJlbnRFbGVtZW50KCk7XG4gIH1cblxuICBmaXJzdE5vZGUoKTogU2ltcGxlLk5vZGUge1xuICAgIHJldHVybiB0aGlzLmJvdW5kcy5maXJzdE5vZGUoKTtcbiAgfVxuXG4gIGxhc3ROb2RlKCk6IFNpbXBsZS5Ob2RlIHtcbiAgICByZXR1cm4gdGhpcy5ib3VuZHMubGFzdE5vZGUoKTtcbiAgfVxuXG4gIG9wY29kZXMoKTogTGlua2VkTGlzdDxVcGRhdGluZ09wY29kZT4ge1xuICAgIHJldHVybiB0aGlzLnVwZGF0aW5nO1xuICB9XG5cbiAgaGFuZGxlRXhjZXB0aW9uKCkge1xuICAgIHRocm93IFwidGhpcyBzaG91bGQgbmV2ZXIgaGFwcGVuXCI7XG4gIH1cblxuICBkZXN0cm95KCkge1xuICAgIHRoaXMuYm91bmRzLmRlc3Ryb3koKTtcbiAgICBjbGVhcih0aGlzLmJvdW5kcyk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/vm/update', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/builder', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/vm/append'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibBuilder, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibVmAppend) { - 'use strict'; +enifed('internal-test-helpers/module-for', ['exports', 'internal-test-helpers/apply-mixins'], function (exports, _internalTestHelpersApplyMixins) { + 'use strict'; - var UpdatingVM = (function () { - function UpdatingVM(env, _ref) { - var _ref$alwaysRevalidate = _ref.alwaysRevalidate; - var alwaysRevalidate = _ref$alwaysRevalidate === undefined ? false : _ref$alwaysRevalidate; + exports.default = moduleFor; - this.frameStack = new _glimmerUtil.Stack(); - this.env = env; - this.dom = env.getDOM(); - this.alwaysRevalidate = alwaysRevalidate; - } + function moduleFor(description, TestClass) { + var context = undefined; - UpdatingVM.prototype.execute = function execute(opcodes, handler) { - var frameStack = this.frameStack; + QUnit.module(description, { + setup: function () { + context = new TestClass(); + }, - this.try(opcodes, handler); - while (true) { - if (frameStack.isEmpty()) break; - var opcode = this.frameStack.current.nextStatement(); - if (opcode === null) { - this.frameStack.pop(); - continue; - } - _glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type); - _glimmerUtil.LOGGER.trace(opcode); - opcode.evaluate(this); - } - }; + teardown: function () { + context.teardown(); + } + }); - UpdatingVM.prototype.goto = function goto(op) { - this.frameStack.current.goto(op); - }; + for (var _len = arguments.length, mixins = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + mixins[_key - 2] = arguments[_key]; + } - UpdatingVM.prototype.try = function _try(ops, handler) { - this.frameStack.push(new UpdatingVMFrame(this, ops, handler)); - }; + _internalTestHelpersApplyMixins.default(TestClass, mixins); - UpdatingVM.prototype.throw = function _throw() { - this.frameStack.current.handleException(); - this.frameStack.pop(); - }; + var proto = TestClass.prototype; - UpdatingVM.prototype.evaluateOpcode = function evaluateOpcode(opcode) { - opcode.evaluate(this); - }; + while (proto !== Object.prototype) { + Object.keys(proto).forEach(generateTest); + proto = Object.getPrototypeOf(proto); + } - return UpdatingVM; - })(); + function generateTest(name) { + if (name.indexOf('@test ') === 0) { + QUnit.test(name.slice(5), function (assert) { + return context[name](assert); + }); + } else if (name.indexOf('@skip ') === 0) { + QUnit.skip(name.slice(5), function (assert) { + return context[name](assert); + }); + } + } + } +}); +enifed('internal-test-helpers/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - exports.default = UpdatingVM; + exports.runAppend = runAppend; + exports.runDestroy = runDestroy; - var BlockOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(BlockOpcode, _UpdatingOpcode); + function runAppend(view) { + _emberMetal.run(view, 'appendTo', '#qunit-fixture'); + } - function BlockOpcode(ops, state, bounds, children) { - _UpdatingOpcode.call(this); - this.type = "block"; - this.next = null; - this.prev = null; - var env = state.env; - var scope = state.scope; - var dynamicScope = state.dynamicScope; - var frame = state.frame; + function runDestroy(toDestroy) { + if (toDestroy) { + _emberMetal.run(toDestroy, 'destroy'); + } + } +}); +enifed('internal-test-helpers/strip', ['exports'], function (exports) { + 'use strict'; - this.ops = ops; - this.children = children; - this.env = env; - this.scope = scope; - this.dynamicScope = dynamicScope; - this.frame = frame; - this.bounds = bounds; - } + exports.default = strip; - BlockOpcode.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + function strip(_ref) { + for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + values[_key - 1] = arguments[_key]; + } - BlockOpcode.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + var strings = _ref; - BlockOpcode.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + var str = strings.map(function (string, index) { + var interpolated = values[index]; + return string + (interpolated !== undefined ? interpolated : ''); + }).join(''); + return str.split('\n').map(function (s) { + return s.trim(); + }).join(''); + } +}); +enifed('internal-test-helpers/test-cases/abstract-application', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-routing', 'ember-template-compiler', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/run'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberRouting, _emberTemplateCompiler, _internalTestHelpersTestCasesAbstract, _internalTestHelpersRun) { + 'use strict'; - BlockOpcode.prototype.evaluate = function evaluate(vm) { - vm.try(this.children, null); - }; + var AbstractApplicationTestCase = (function (_AbstractTestCase) { + babelHelpers.inherits(AbstractApplicationTestCase, _AbstractTestCase); - BlockOpcode.prototype.destroy = function destroy() { - this.bounds.destroy(); - }; + function AbstractApplicationTestCase() { + babelHelpers.classCallCheck(this, AbstractApplicationTestCase); - BlockOpcode.prototype.didDestroy = function didDestroy() { - this.env.didDestroy(this.bounds); - }; + _AbstractTestCase.call(this); - BlockOpcode.prototype.toJSON = function toJSON() { - var begin = this.ops.head(); - var end = this.ops.tail(); - var details = _glimmerUtil.dict(); - details["guid"] = '' + this._guid; - details["begin"] = begin.inspect(); - details["end"] = end.inspect(); - return { - guid: this._guid, - type: this.type, - details: details, - children: this.children.toArray().map(function (op) { - return op.toJSON(); - }) - }; - }; + this.element = _emberViews.jQuery('#qunit-fixture')[0]; - return BlockOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + this.application = _emberMetal.run(_emberApplication.Application, 'create', this.applicationOptions); - exports.BlockOpcode = BlockOpcode; + this.router = this.application.Router = _emberRouting.Router.extend(this.routerOptions); - var TryOpcode = (function (_BlockOpcode) { - babelHelpers.inherits(TryOpcode, _BlockOpcode); + this.applicationInstance = null; + } - function TryOpcode(ops, state, bounds, children) { - _BlockOpcode.call(this, ops, state, bounds, children); - this.type = "try"; - this.tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - } + AbstractApplicationTestCase.prototype.teardown = function teardown() { + if (this.applicationInstance) { + _internalTestHelpersRun.runDestroy(this.applicationInstance); + } - TryOpcode.prototype.didInitializeChildren = function didInitializeChildren() { - this._tag.update(_glimmerReference.combineSlice(this.children)); - }; + _internalTestHelpersRun.runDestroy(this.application); + }; - TryOpcode.prototype.evaluate = function evaluate(vm) { - vm.try(this.children, this); - }; + AbstractApplicationTestCase.prototype.visit = function visit(url, options) { + var _this = this; - TryOpcode.prototype.handleException = function handleException() { - var env = this.env; - var scope = this.scope; - var ops = this.ops; - var dynamicScope = this.dynamicScope; - var frame = this.frame; - - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.resume(this.env, this.bounds, this.bounds.reset(env)); - var vm = new _glimmerRuntimeLibVmAppend.default(env, scope, dynamicScope, elementStack); - var result = vm.resume(ops, frame); - this.children = result.opcodes(); - this.didInitializeChildren(); - }; + var applicationInstance = this.applicationInstance; - TryOpcode.prototype.toJSON = function toJSON() { - var json = _BlockOpcode.prototype.toJSON.call(this); - var begin = this.ops.head(); - var end = this.ops.tail(); - json["details"]["begin"] = JSON.stringify(begin.inspect()); - json["details"]["end"] = JSON.stringify(end.inspect()); - return _BlockOpcode.prototype.toJSON.call(this); - }; + if (applicationInstance) { + return _emberMetal.run(applicationInstance, 'visit', url, options); + } else { + return _emberMetal.run(this.application, 'visit', url, options).then(function (instance) { + _this.applicationInstance = instance; + }); + } + }; - return TryOpcode; - })(BlockOpcode); + AbstractApplicationTestCase.prototype.transitionTo = function transitionTo() { + return _emberMetal.run.apply(undefined, [this.appRouter, 'transitionTo'].concat(babelHelpers.slice.call(arguments))); + }; - exports.TryOpcode = TryOpcode; + AbstractApplicationTestCase.prototype.compile = function compile(string, options) { + return _emberTemplateCompiler.compile.apply(undefined, arguments); + }; - var ListRevalidationDelegate = (function () { - function ListRevalidationDelegate(opcode, marker) { - this.opcode = opcode; - this.marker = marker; - this.didInsert = false; - this.didDelete = false; - this.map = opcode.map; - this.updating = opcode['children']; - } + AbstractApplicationTestCase.prototype.registerRoute = function registerRoute(name, route) { + this.application.register('route:' + name, route); + }; - ListRevalidationDelegate.prototype.insert = function insert(key, item, memo, before) { - var map = this.map; - var opcode = this.opcode; - var updating = this.updating; + AbstractApplicationTestCase.prototype.registerTemplate = function registerTemplate(name, template) { + this.application.register('template:' + name, this.compile(template, { + moduleName: name + })); + }; - var nextSibling = null; - var reference = null; - if (before) { - reference = map[before]; - nextSibling = reference.bounds.firstNode(); - } else { - nextSibling = this.marker; - } - var vm = opcode.vmForInsertion(nextSibling); - var tryOpcode = undefined; - vm.execute(opcode.ops, function (vm) { - vm.frame.setArgs(_glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs.positional([item, memo])); - vm.frame.setOperand(item); - vm.frame.setCondition(new _glimmerReference.ConstReference(true)); - vm.frame.setKey(key); - var state = vm.capture(); - var tracker = vm.stack().pushUpdatableBlock(); - tryOpcode = new TryOpcode(opcode.ops, state, tracker, vm.updatingOpcodeStack.current); - }); - tryOpcode.didInitializeChildren(); - updating.insertBefore(tryOpcode, reference); - map[key] = tryOpcode; - this.didInsert = true; - }; + AbstractApplicationTestCase.prototype.registerComponent = function registerComponent(name, _ref) { + var _ref$ComponentClass = _ref.ComponentClass; + var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; - ListRevalidationDelegate.prototype.retain = function retain(key, item, memo) {}; + if (ComponentClass) { + this.application.register('component:' + name, ComponentClass); + } - ListRevalidationDelegate.prototype.move = function move(key, item, memo, before) { - var map = this.map; - var updating = this.updating; + if (typeof template === 'string') { + this.application.register('template:components/' + name, this.compile(template, { + moduleName: 'components/' + name + })); + } + }; - var entry = map[key]; - var reference = map[before] || null; - if (before) { - _glimmerRuntimeLibBounds.move(entry, reference.firstNode()); - } else { - _glimmerRuntimeLibBounds.move(entry, this.marker); - } - updating.remove(entry); - updating.insertBefore(entry, reference); - }; + AbstractApplicationTestCase.prototype.registerController = function registerController(name, controller) { + this.application.register('controller:' + name, controller); + }; - ListRevalidationDelegate.prototype.delete = function _delete(key) { - var map = this.map; + AbstractApplicationTestCase.prototype.registerEngine = function registerEngine(name, engine) { + this.application.register('engine:' + name, engine); + }; - var opcode = map[key]; - opcode.didDestroy(); - _glimmerRuntimeLibBounds.clear(opcode); - this.updating.remove(opcode); - delete map[key]; - this.didDelete = true; + babelHelpers.createClass(AbstractApplicationTestCase, [{ + key: 'applicationOptions', + get: function () { + return { + rootElement: '#qunit-fixture', + autoboot: false }; - - ListRevalidationDelegate.prototype.done = function done() { - this.opcode.didInitializeChildren(this.didInsert || this.didDelete); + } + }, { + key: 'routerOptions', + get: function () { + return { + location: 'none' }; + } + }, { + key: 'appRouter', + get: function () { + return this.applicationInstance.lookup('router:main'); + } + }]); + return AbstractApplicationTestCase; + })(_internalTestHelpersTestCasesAbstract.default); - return ListRevalidationDelegate; - })(); - - var ListBlockOpcode = (function (_BlockOpcode2) { - babelHelpers.inherits(ListBlockOpcode, _BlockOpcode2); - - function ListBlockOpcode(ops, state, bounds, children, artifacts) { - _BlockOpcode2.call(this, ops, state, bounds, children); - this.type = "list-block"; - this.map = _glimmerUtil.dict(); - this.lastIterated = _glimmerReference.INITIAL; - this.artifacts = artifacts; - var _tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([artifacts.tag, _tag]); - } + exports.default = AbstractApplicationTestCase; +}); +enifed('internal-test-helpers/test-cases/abstract-rendering', ['exports', 'ember-utils', 'ember-template-compiler', 'ember-views', 'ember-glimmer', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/build-owner', 'internal-test-helpers/run'], function (exports, _emberUtils, _emberTemplateCompiler, _emberViews, _emberGlimmer, _internalTestHelpersTestCasesAbstract, _internalTestHelpersBuildOwner, _internalTestHelpersRun) { + 'use strict'; - ListBlockOpcode.prototype.didInitializeChildren = function didInitializeChildren() { - var listDidChange = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; + var TextNode = window.Text; - this.lastIterated = this.artifacts.tag.value(); - if (listDidChange) { - this._tag.update(_glimmerReference.combineSlice(this.children)); - } - }; + var AbstractRenderingTestCase = (function (_AbstractTestCase) { + babelHelpers.inherits(AbstractRenderingTestCase, _AbstractTestCase); - ListBlockOpcode.prototype.evaluate = function evaluate(vm) { - var artifacts = this.artifacts; - var lastIterated = this.lastIterated; - - if (!artifacts.tag.validate(lastIterated)) { - var bounds = this.bounds; - var dom = vm.dom; - - var marker = dom.createComment(''); - dom.insertAfter(bounds.parentElement(), marker, bounds.lastNode()); - var target = new ListRevalidationDelegate(this, marker); - var synchronizer = new _glimmerReference.IteratorSynchronizer({ target: target, artifacts: artifacts }); - synchronizer.sync(); - this.parentElement().removeChild(marker); - } - // Run now-updated updating opcodes - _BlockOpcode2.prototype.evaluate.call(this, vm); - }; + function AbstractRenderingTestCase() { + babelHelpers.classCallCheck(this, AbstractRenderingTestCase); - ListBlockOpcode.prototype.vmForInsertion = function vmForInsertion(nextSibling) { - var env = this.env; - var scope = this.scope; - var dynamicScope = this.dynamicScope; + _AbstractTestCase.call(this); + var owner = this.owner = _internalTestHelpersBuildOwner.default({ + ownerOptions: this.getOwnerOptions(), + bootOptions: this.getBootOptions(), + resolver: this.getResolver() + }); - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.forInitialRender(this.env, this.bounds.parentElement(), nextSibling); - return new _glimmerRuntimeLibVmAppend.default(env, scope, dynamicScope, elementStack); - }; + this.renderer = this.owner.lookup('renderer:-dom'); + this.element = _emberViews.jQuery('#qunit-fixture')[0]; + this.component = null; - ListBlockOpcode.prototype.toJSON = function toJSON() { - var json = _BlockOpcode2.prototype.toJSON.call(this); - var map = this.map; - var inner = Object.keys(map).map(function (key) { - return JSON.stringify(key) + ': ' + map[key]._guid; - }).join(", "); - json["details"]["map"] = '{' + inner + '}'; - return json; - }; + owner.register('event_dispatcher:main', _emberViews.EventDispatcher); + owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); + owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); + } - return ListBlockOpcode; - })(BlockOpcode); + AbstractRenderingTestCase.prototype.compile = function compile() { + return _emberTemplateCompiler.compile.apply(undefined, arguments); + }; - exports.ListBlockOpcode = ListBlockOpcode; + AbstractRenderingTestCase.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { + return {}; + }; - var UpdatingVMFrame = (function () { - function UpdatingVMFrame(vm, ops, handler) { - this.vm = vm; - this.ops = ops; - this.current = ops.head(); - this.exceptionHandler = handler; - } + AbstractRenderingTestCase.prototype.getOwnerOptions = function getOwnerOptions() {}; - UpdatingVMFrame.prototype.goto = function goto(op) { - this.current = op; - }; + AbstractRenderingTestCase.prototype.getBootOptions = function getBootOptions() {}; - UpdatingVMFrame.prototype.nextStatement = function nextStatement() { - var current = this.current; - var ops = this.ops; + AbstractRenderingTestCase.prototype.getResolver = function getResolver() {}; - if (current) this.current = ops.nextNode(current); - return current; - }; + AbstractRenderingTestCase.prototype.teardown = function teardown() { + if (this.component) { + _internalTestHelpersRun.runDestroy(this.component); + } + if (this.owner) { + _internalTestHelpersRun.runDestroy(this.owner); + } + }; - UpdatingVMFrame.prototype.handleException = function handleException() { - this.exceptionHandler.handleException(); - }; + AbstractRenderingTestCase.prototype.render = function render(templateStr) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var owner = this.owner; - return UpdatingVMFrame; - })(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vdXBkYXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQTRCQSxVQUFBO0FBTUUsaUJBTkYsVUFBQSxDQU1jLEdBQWdCLEVBQUUsSUFBNEIsRUFBQTt3Q0FBNUIsSUFBNEIsQ0FBMUIsZ0JBQWdCO2dCQUFoQixnQkFBZ0IseUNBQUcsS0FBSzs7QUFGaEQsZ0JBQUEsQ0FBQSxVQUFVLEdBQTJCLGlCQTdCdEIsS0FBSyxFQTZCNkMsQ0FBQztBQUd4RSxnQkFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHL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aXM7XG4gICAgaWYgKGN1cnJlbnQpIHRoaXMuY3VycmVudCA9IG9wcy5uZXh0Tm9kZShjdXJyZW50KTtcbiAgICByZXR1cm4gY3VycmVudDtcbiAgfVxuXG4gIGhhbmRsZUV4Y2VwdGlvbigpIHtcbiAgICB0aGlzLmV4Y2VwdGlvbkhhbmRsZXIuaGFuZGxlRXhjZXB0aW9uKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-util/index', ['exports', 'glimmer-util/lib/namespaces', 'glimmer-util/lib/platform-utils', 'glimmer-util/lib/assert', 'glimmer-util/lib/logger', 'glimmer-util/lib/object-utils', 'glimmer-util/lib/guid', 'glimmer-util/lib/collections', 'glimmer-util/lib/list-utils'], function (exports, _glimmerUtilLibNamespaces, _glimmerUtilLibPlatformUtils, _glimmerUtilLibAssert, _glimmerUtilLibLogger, _glimmerUtilLibObjectUtils, _glimmerUtilLibGuid, _glimmerUtilLibCollections, _glimmerUtilLibListUtils) { - 'use strict'; + owner.register('template:-top-level', this.compile(templateStr, { + moduleName: '-top-level' + })); - exports.getAttrNamespace = _glimmerUtilLibNamespaces.getAttrNamespace; - exports.Option = _glimmerUtilLibPlatformUtils.Option; - exports.Maybe = _glimmerUtilLibPlatformUtils.Maybe; - exports.Opaque = _glimmerUtilLibPlatformUtils.Opaque; - exports.assert = _glimmerUtilLibAssert.default; - exports.LOGGER = _glimmerUtilLibLogger.default; - exports.Logger = _glimmerUtilLibLogger.Logger; - exports.LogLevel = _glimmerUtilLibLogger.LogLevel; - exports.assign = _glimmerUtilLibObjectUtils.assign; - exports.ensureGuid = _glimmerUtilLibGuid.ensureGuid; - exports.initializeGuid = _glimmerUtilLibGuid.initializeGuid; - exports.HasGuid = _glimmerUtilLibGuid.HasGuid; - exports.Stack = _glimmerUtilLibCollections.Stack; - exports.Dict = _glimmerUtilLibCollections.Dict; - exports.Set = _glimmerUtilLibCollections.Set; - exports.DictSet = _glimmerUtilLibCollections.DictSet; - exports.dict = _glimmerUtilLibCollections.dict; - exports.EMPTY_SLICE = _glimmerUtilLibListUtils.EMPTY_SLICE; - exports.LinkedList = _glimmerUtilLibListUtils.LinkedList; - exports.LinkedListNode = _glimmerUtilLibListUtils.LinkedListNode; - exports.ListNode = _glimmerUtilLibListUtils.ListNode; - exports.CloneableListNode = _glimmerUtilLibListUtils.CloneableListNode; - exports.ListSlice = _glimmerUtilLibListUtils.ListSlice; - exports.Slice = _glimmerUtilLibListUtils.Slice; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFJUyxnQkFBZ0IsNkJBQWhCLGdCQUFnQjtVQUNoQixNQUFNLGdDQUFOLE1BQU07VUFBRSxLQUFLLGdDQUFMLEtBQUs7VUFBRSxNQUFNLGdDQUFOLE1BQU07VUFDVixNQUFNLHlCQUFqQixPQUFPO1VBQ0ksTUFBTSx5QkFBakIsT0FBTztVQUFZLE1BQU0seUJBQU4sTUFBTTtVQUFFLFFBQVEseUJBQVIsUUFBUTtVQUVuQyxNQUFNLDhCQUFOLE1BQU07VUFDTixVQUFVLHVCQUFWLFVBQVU7VUFBRSxjQUFjLHVCQUFkLGNBQWM7VUFBRSxPQUFPLHVCQUFQLE9BQU87VUFFbkMsS0FBSyw4QkFBTCxLQUFLO1VBQUUsSUFBSSw4QkFBSixJQUFJO1VBQUUsR0FBRyw4QkFBSCxHQUFHO1VBQUUsT0FBTyw4QkFBUCxPQUFPO1VBQUUsSUFBSSw4QkFBSixJQUFJO1VBQy9CLFdBQVcsNEJBQVgsV0FBVztVQUFFLFVBQVUsNEJBQVYsVUFBVTtVQUFFLGNBQWMsNEJBQWQsY0FBYztVQUFFLFFBQVEsNEJBQVIsUUFBUTtVQUFFLGlCQUFpQiw0QkFBakIsaUJBQWlCO1VBQUUsU0FBUyw0QkFBVCxTQUFTO1VBQUUsS0FBSyw0QkFBTCxLQUFLIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGludGVyZmFjZSBEZXN0cm95YWJsZSB7XG4gIGRlc3Ryb3koKTtcbn1cblxuZXhwb3J0IHsgZ2V0QXR0ck5hbWVzcGFjZSB9IGZyb20gJy4vbGliL25hbWVzcGFjZXMnO1xuZXhwb3J0IHsgT3B0aW9uLCBNYXliZSwgT3BhcXVlIH0gZnJvbSAnLi9saWIvcGxhdGZvcm0tdXRpbHMnO1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBhc3NlcnQgfSBmcm9tICcuL2xpYi9hc3NlcnQnO1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBMT0dHRVIsIExvZ2dlciwgTG9nTGV2ZWwgfSBmcm9tICcuL2xpYi9sb2dnZXInO1xuXG5leHBvcnQgeyBhc3NpZ24gfSBmcm9tICcuL2xpYi9vYmplY3QtdXRpbHMnO1xuZXhwb3J0IHsgZW5zdXJlR3VpZCwgaW5pdGlhbGl6ZUd1aWQsIEhhc0d1aWQgfSBmcm9tICcuL2xpYi9ndWlkJztcblxuZXhwb3J0IHsgU3RhY2ssIERpY3QsIFNldCwgRGljdFNldCwgZGljdCB9IGZyb20gJy4vbGliL2NvbGxlY3Rpb25zJztcbmV4cG9ydCB7IEVNUFRZX1NMSUNFLCBMaW5rZWRMaXN0LCBMaW5rZWRMaXN0Tm9kZSwgTGlzdE5vZGUsIENsb25lYWJsZUxpc3ROb2RlLCBMaXN0U2xpY2UsIFNsaWNlIH0gZnJvbSAnLi9saWIvbGlzdC11dGlscyc7XG5cbmV4cG9ydCB0eXBlIEZJWE1FPFQsIHN0cmluZz4gPSBUO1xuIl19 -enifed("glimmer-util/lib/assert", ["exports"], function (exports) { - // import Logger from './logger'; - // let alreadyWarned = false; - "use strict"; + var attrs = _emberUtils.assign({}, context, { + tagName: '', + layoutName: '-top-level' + }); - exports.debugAssert = debugAssert; - exports.prodAssert = prodAssert; + owner.register('component:-top-level', _emberGlimmer.Component.extend(attrs)); - function debugAssert(test, msg) { - // if (!alreadyWarned) { - // alreadyWarned = true; - // Logger.warn("Don't leave debug assertions on in public builds"); - // } - if (!test) { - throw new Error(msg || "assertion failure"); - } - } + this.component = owner.lookup('component:-top-level'); - function prodAssert() {} + _internalTestHelpersRun.runAppend(this.component); + }; - exports.default = debugAssert; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvYXNzZXJ0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBSUEsYUFBQSxXQUFBLENBQTRCLElBQUksRUFBRSxHQUFHLEVBQUE7Ozs7O0FBTW5DLFlBQUksQ0FBQyxJQUFJLEVBQUU7QUFDVCxrQkFBTSxJQUFJLEtBQUssQ0FBQyxHQUFHLElBQUksbUJBQW1CLENBQUMsQ0FBQztTQUM3QztLQUNGOztBQUVELGFBQUEsVUFBQSxHQUFBLEVBQStCOztzQkFFaEIsV0FBVyIsImZpbGUiOiJhc3NlcnQuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBpbXBvcnQgTG9nZ2VyIGZyb20gJy4vbG9nZ2VyJztcblxuLy8gbGV0IGFscmVhZHlXYXJuZWQgPSBmYWxzZTtcblxuZXhwb3J0IGZ1bmN0aW9uIGRlYnVnQXNzZXJ0KHRlc3QsIG1zZykge1xuICAvLyBpZiAoIWFscmVhZHlXYXJuZWQpIHtcbiAgLy8gICBhbHJlYWR5V2FybmVkID0gdHJ1ZTtcbiAgLy8gICBMb2dnZXIud2FybihcIkRvbid0IGxlYXZlIGRlYnVnIGFzc2VydGlvbnMgb24gaW4gcHVibGljIGJ1aWxkc1wiKTtcbiAgLy8gfVxuXG4gIGlmICghdGVzdCkge1xuICAgIHRocm93IG5ldyBFcnJvcihtc2cgfHwgXCJhc3NlcnRpb24gZmFpbHVyZVwiKTtcbiAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gcHJvZEFzc2VydCgpIHt9XG5cbmV4cG9ydCBkZWZhdWx0IGRlYnVnQXNzZXJ0O1xuIl19 -enifed('glimmer-util/lib/collections', ['exports', 'glimmer-util/lib/guid'], function (exports, _glimmerUtilLibGuid) { - 'use strict'; + AbstractRenderingTestCase.prototype.rerender = function rerender() { + this.component.rerender(); + }; - exports.dict = dict; + AbstractRenderingTestCase.prototype.registerHelper = function registerHelper(name, funcOrClassBody) { + var type = typeof funcOrClassBody; - var proto = Object.create(null, { - // without this, we will always still end up with (new - // EmptyObject()).constructor === Object - constructor: { - value: undefined, - enumerable: false, - writable: true - } - }); - function EmptyObject() {} - EmptyObject.prototype = proto; + if (type === 'function') { + this.owner.register('helper:' + name, _emberGlimmer.helper(funcOrClassBody)); + } else if (type === 'object' && type !== null) { + this.owner.register('helper:' + name, _emberGlimmer.Helper.extend(funcOrClassBody)); + } else { + throw new Error('Cannot register ' + funcOrClassBody + ' as a helper'); + } + }; - function dict() { - // let d = Object.create(null); - // d.x = 1; - // delete d.x; - // return d; - return new EmptyObject(); - } + AbstractRenderingTestCase.prototype.registerPartial = function registerPartial(name, template) { + var owner = this.env.owner || this.owner; + if (typeof template === 'string') { + var moduleName = 'template:' + name; + owner.register(moduleName, this.compile(template, { moduleName: moduleName })); + } + }; - var DictSet = (function () { - function DictSet() { - this.dict = dict(); - } + AbstractRenderingTestCase.prototype.registerComponent = function registerComponent(name, _ref) { + var _ref$ComponentClass = _ref.ComponentClass; + var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; + var owner = this.owner; - DictSet.prototype.add = function add(obj) { - if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[_glimmerUtilLibGuid.ensureGuid(obj)] = obj; - return this; - }; + if (ComponentClass) { + owner.register('component:' + name, ComponentClass); + } - DictSet.prototype.delete = function _delete(obj) { - if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; - }; + if (typeof template === 'string') { + owner.register('template:components/' + name, this.compile(template, { + moduleName: 'components/' + name + })); + } + }; - DictSet.prototype.forEach = function forEach(callback) { - var dict = this.dict; + AbstractRenderingTestCase.prototype.registerTemplate = function registerTemplate(name, template) { + var owner = this.owner; - Object.keys(dict).forEach(function (key) { - return callback(dict[key]); - }); - }; + if (typeof template === 'string') { + owner.register('template:' + name, this.compile(template, { + moduleName: name + })); + } else { + throw new Error('Registered template "' + name + '" must be a string'); + } + }; - DictSet.prototype.toArray = function toArray() { - return Object.keys(this.dict); - }; + AbstractRenderingTestCase.prototype.registerService = function registerService(name, klass) { + this.owner.register('service:' + name, klass); + }; - return DictSet; - })(); + AbstractRenderingTestCase.prototype.assertTextNode = function assertTextNode(node, text) { + if (!(node instanceof TextNode)) { + throw new Error('Expecting a text node, but got ' + node); + } - exports.DictSet = DictSet; + this.assert.strictEqual(node.textContent, text, 'node.textContent'); + }; - var Stack = (function () { - function Stack() { - this.stack = []; - this.current = null; - } + babelHelpers.createClass(AbstractRenderingTestCase, [{ + key: 'context', + get: function () { + return this.component; + } + }]); + return AbstractRenderingTestCase; + })(_internalTestHelpersTestCasesAbstract.default); - Stack.prototype.push = function push(item) { - this.current = item; - this.stack.push(item); - }; + exports.default = AbstractRenderingTestCase; +}); +enifed('internal-test-helpers/test-cases/abstract', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/matchers'], function (exports, _emberUtils, _emberMetal, _emberViews, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersMatchers) { + 'use strict'; - Stack.prototype.pop = function pop() { - var item = this.stack.pop(); - var len = this.stack.length; - this.current = len === 0 ? null : this.stack[len - 1]; - return item; - }; + var TextNode = window.Text; + var HTMLElement = window.HTMLElement; + var Comment = window.Comment; - Stack.prototype.isEmpty = function isEmpty() { - return this.stack.length === 0; - }; + function isMarker(node) { + if (node instanceof Comment && node.textContent === '') { + return true; + } - return Stack; - })(); + if (node instanceof TextNode && node.textContent === '') { + return true; + } - exports.Stack = Stack; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvY29sbGVjdGlvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFZQSxRQUFJLEtBQUssR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRTs7O0FBRzlCLG1CQUFXLEVBQUU7QUFDWCxpQkFBSyxFQUFFLFNBQVM7QUFDaEIsc0JBQVUsRUFBRSxLQUFLO0FBQ2pCLG9CQUFRLEVBQUUsSUFBSTtTQUNmO0tBQ0YsQ0FBQyxDQUFDO0FBRUgsYUFBQSxXQUFBLEdBQUEsRUFBeUI7QUFDekIsZUFBVyxDQUFDLFNBQVMsR0FBRyxLQUFLLENBQUM7O0FBRTlCLGFBQUEsSUFBQSxHQUFBOzs7OztBQUtFLGVBQU8sSUFBSSxXQUFXLEVBQUUsQ0FBQztLQUMxQjs7UUFJRCxPQUFBO0FBR0UsaUJBSEYsT0FBQSxHQUdFO0FBQ0UsZ0JBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxFQUFLLENBQUM7U0FDdkI7O0FBTEgsZUFBQSxXQU9FLEdBQUcsR0FBQSxhQUFDLEdBQU0sRUFBQTtBQUNSLGdCQUFJLE9BQU8sR0FBRyxLQUFLLFFBQVEsRUFBRSxJQUFJLENBQUMsSUFBSSxDQUFNLEdBQUcsQ0FBQyxHQUFHLEdBQUcsQ0FBQyxLQUNsRCxJQUFJLENBQUMsSUFBSSxDQUFDLG9CQTVDRCxVQUFVLENBNENPLEdBQUcsQ0FBQyxDQUFDLEdBQUcsR0FBRyxDQUFDO0FBQzNDLG1CQUFPLElBQUksQ0FBQztTQUNiOztBQVhILGVBQUEsV0FhRSxNQUFNLEdBQUEsaUJBQUMs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B0aGlzO1xuICAgIE9iamVjdC5rZXlzKGRpY3QpLmZvckVhY2goa2V5ID0+IGNhbGxiYWNrKGRpY3Rba2V5XSkpO1xuICB9XG5cbiAgdG9BcnJheSgpOiBzdHJpbmdbXSB7XG4gICAgcmV0dXJuIE9iamVjdC5rZXlzKHRoaXMuZGljdCk7XG4gIH1cbn1cblxuZXhwb3J0IGNsYXNzIFN0YWNrPFQ+IHtcbiAgcHJpdmF0ZSBzdGFjazogVFtdID0gW107XG4gIHB1YmxpYyBjdXJyZW50OiBUID0gbnVsbDtcblxuICBwdXNoKGl0ZW06IFQpIHtcbiAgICB0aGlzLmN1cnJlbnQgPSBpdGVtO1xuICAgIHRoaXMuc3RhY2sucHVzaChpdGVtKTtcbiAgfVxuXG4gIHBvcCgpOiBUIHtcbiAgICBsZXQgaXRlbSA9IHRoaXMuc3RhY2sucG9wKCk7XG4gICAgbGV0IGxlbiA9IHRoaXMuc3RhY2subGVuZ3RoO1xuICAgIHRoaXMuY3VycmVudCA9IGxlbiA9PT0gMCA/IG51bGwgOiB0aGlzLnN0YWNrW2xlbiAtIDFdO1xuXG4gICAgcmV0dXJuIGl0ZW07XG4gIH1cblxuICBpc0VtcHR5KCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLnN0YWNrLmxlbmd0aCA9PT0gMDtcbiAgfVxufVxuIl19 -enifed("glimmer-util/lib/guid", ["exports"], function (exports) { - "use strict"; + return false; + } - exports.initializeGuid = initializeGuid; - exports.ensureGuid = ensureGuid; - var GUID = 0; + var AbstractTestCase = (function () { + function AbstractTestCase() { + babelHelpers.classCallCheck(this, AbstractTestCase); - function initializeGuid(object) { - return object._guid = ++GUID; + this.element = null; + this.snapshot = null; + this.assert = QUnit.config.current.assert; } - function ensureGuid(object) { - return object._guid || initializeGuid(object); - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvZ3VpZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLFFBQUksSUFBSSxHQUFHLENBQUMsQ0FBQzs7QUFNYixhQUFBLGNBQUEsQ0FBK0IsTUFBZSxFQUFBO0FBQzVDLGVBQVEsTUFBTSxDQUFDLEtBQUssR0FBRyxFQUFFLElBQUksQ0FBRTtLQUNoQzs7QUFFRCxhQUFBLFVBQUEsQ0FBMkIsTUFBZSxFQUFBO0FBQ3hDLGVBQU8sTUFBTSxDQUFDLEtBQUssSUFBSSxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7S0FDL0MiLCJmaWxlIjoiZ3VpZC5qcyIsInNvdXJjZXNDb250ZW50IjpbImxldCBHVUlEID0gMDtcblxuZXhwb3J0IGludGVyZmFjZSBIYXNHdWlkIHtcbiAgX2d1aWQ6IG51bWJlcjtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGluaXRpYWxpemVHdWlkKG9iamVjdDogSGFzR3VpZCk6IG51bWJlciB7XG4gIHJldHVybiAob2JqZWN0Ll9ndWlkID0gKytHVUlEKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGVuc3VyZUd1aWQob2JqZWN0OiBIYXNHdWlkKTogbnVtYmVyIHtcbiAgcmV0dXJuIG9iamVjdC5fZ3VpZCB8fCBpbml0aWFsaXplR3VpZChvYmplY3QpO1xufSJdfQ== -enifed("glimmer-util/lib/list-utils", ["exports"], function (exports) { - "use strict"; + AbstractTestCase.prototype.teardown = function teardown() {}; - var ListNode = function ListNode(value) { - this.next = null; - this.prev = null; - this.value = value; + AbstractTestCase.prototype.runTask = function runTask(callback) { + _emberMetal.run(callback); }; - exports.ListNode = ListNode; + AbstractTestCase.prototype.runTaskNext = function runTaskNext(callback) { + _emberMetal.run.next(callback); + }; - var LinkedList = (function () { - function LinkedList() { - this.clear(); - } + // The following methods require `this.element` to work - LinkedList.fromSlice = function fromSlice(slice) { - var list = new LinkedList(); - slice.forEachNode(function (n) { - return list.append(n.clone()); - }); - return list; - }; + AbstractTestCase.prototype.nthChild = function nthChild(n) { + var i = 0; + var node = this.element.firstChild; - LinkedList.prototype.head = function head() { - return this._head; - }; + while (node) { + if (!isMarker(node)) { + i++; + } - LinkedList.prototype.tail = function tail() { - return this._tail; - }; + if (i > n) { + break; + } else { + node = node.nextSibling; + } + } - LinkedList.prototype.clear = function clear() { - this._head = this._tail = null; - }; + return node; + }; - LinkedList.prototype.isEmpty = function isEmpty() { - return this._head === null; - }; + AbstractTestCase.prototype.$ = function $(sel) { + return sel ? _emberViews.jQuery(sel, this.element) : _emberViews.jQuery(this.element); + }; - LinkedList.prototype.toArray = function toArray() { - var out = []; - this.forEachNode(function (n) { - return out.push(n); - }); - return out; - }; + AbstractTestCase.prototype.textValue = function textValue() { + return this.$().text(); + }; - LinkedList.prototype.splice = function splice(start, end, reference) { - var before = undefined; - if (reference === null) { - before = this._tail; - this._tail = end; - } else { - before = reference.prev; - end.next = reference; - reference.prev = end; - } - if (before) { - before.next = start; - start.prev = before; - } - }; + AbstractTestCase.prototype.takeSnapshot = function takeSnapshot() { + var snapshot = this.snapshot = []; - LinkedList.prototype.spliceList = function spliceList(list, reference) { - if (list.isEmpty()) return; - this.splice(list.head(), list.tail(), reference); - }; + var node = this.element.firstChild; - LinkedList.prototype.nextNode = function nextNode(node) { - return node.next; - }; + while (node) { + if (!isMarker(node)) { + snapshot.push(node); + } - LinkedList.prototype.prevNode = function prevNode(node) { - return node.prev; - }; + node = node.nextSibling; + } - LinkedList.prototype.forEachNode = function forEachNode(callback) { - var node = this._head; - while (node !== null) { - callback(node); - node = node.next; - } - }; + return snapshot; + }; - LinkedList.prototype.contains = function contains(needle) { - var node = this._head; - while (node !== null) { - if (node === needle) return true; - node = node.next; - } - return false; - }; + AbstractTestCase.prototype.assertText = function assertText(text) { + this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content should be: `' + text + '`'); + }; - LinkedList.prototype.insertBefore = function insertBefore(node) { - var reference = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + AbstractTestCase.prototype.assertInnerHTML = function assertInnerHTML(html) { + _internalTestHelpersEqualInnerHtml.default(this.element, html); + }; - if (reference === null) return this.append(node); - if (reference.prev) reference.prev.next = node;else this._head = node; - node.prev = reference.prev; - node.next = reference; - reference.prev = node; - return node; - }; + AbstractTestCase.prototype.assertHTML = function assertHTML(html) { + _internalTestHelpersEqualTokens.default(this.element, html, '#qunit-fixture content should be: `' + html + '`'); + }; - LinkedList.prototype.append = function append(node) { - var tail = this._tail; - if (tail) { - tail.next = node; - node.prev = tail; - node.next = null; - } else { - this._head = node; - } - return this._tail = node; - }; + AbstractTestCase.prototype.assertElement = function assertElement(node, _ref) { + var _ref$ElementType = _ref.ElementType; + var ElementType = _ref$ElementType === undefined ? HTMLElement : _ref$ElementType; + var tagName = _ref.tagName; + var _ref$attrs = _ref.attrs; + var attrs = _ref$attrs === undefined ? null : _ref$attrs; + var _ref$content = _ref.content; + var content = _ref$content === undefined ? null : _ref$content; - LinkedList.prototype.pop = function pop() { - if (this._tail) return this.remove(this._tail); - return null; - }; + if (!(node instanceof ElementType)) { + throw new Error('Expecting a ' + ElementType.name + ', but got ' + node); + } - LinkedList.prototype.prepend = function prepend(node) { - if (this._head) return this.insertBefore(node, this._head); - return this._head = this._tail = node; - }; + _internalTestHelpersMatchers.equalsElement(node, tagName, attrs, content); + }; - LinkedList.prototype.remove = function remove(node) { - if (node.prev) node.prev.next = node.next;else this._head = node.next; - if (node.next) node.next.prev = node.prev;else this._tail = node.prev; - return node; - }; + AbstractTestCase.prototype.assertComponentElement = function assertComponentElement(node, _ref2) { + var _ref2$ElementType = _ref2.ElementType; + var ElementType = _ref2$ElementType === undefined ? HTMLElement : _ref2$ElementType; + var _ref2$tagName = _ref2.tagName; + var tagName = _ref2$tagName === undefined ? 'div' : _ref2$tagName; + var _ref2$attrs = _ref2.attrs; + var attrs = _ref2$attrs === undefined ? null : _ref2$attrs; + var _ref2$content = _ref2.content; + var content = _ref2$content === undefined ? null : _ref2$content; - return LinkedList; - })(); + attrs = _emberUtils.assign({}, { id: _internalTestHelpersMatchers.regex(/^ember\d*$/), class: _internalTestHelpersMatchers.classes('ember-view') }, attrs || {}); + this.assertElement(node, { ElementType: ElementType, tagName: tagName, attrs: attrs, content: content }); + }; - exports.LinkedList = LinkedList; + AbstractTestCase.prototype.assertSameNode = function assertSameNode(actual, expected) { + this.assert.strictEqual(actual, expected, 'DOM node stability'); + }; - var LinkedListRemover = (function () { - function LinkedListRemover(node) { - this.node = node; - } + AbstractTestCase.prototype.assertInvariants = function assertInvariants(oldSnapshot, newSnapshot) { + oldSnapshot = oldSnapshot || this.snapshot; + newSnapshot = newSnapshot || this.takeSnapshot(); - LinkedListRemover.prototype.destroy = function destroy() { - var _node = this.node; - var prev = _node.prev; - var next = _node.next; + this.assert.strictEqual(newSnapshot.length, oldSnapshot.length, 'Same number of nodes'); - prev.next = next; - next.prev = prev; - }; + for (var i = 0; i < oldSnapshot.length; i++) { + this.assertSameNode(newSnapshot[i], oldSnapshot[i]); + } + }; - return LinkedListRemover; - })(); + AbstractTestCase.prototype.assertPartialInvariants = function assertPartialInvariants(start, end) { + this.assertInvariants(this.snapshot, this.takeSnapshot().slice(start, end)); + }; - var ListSlice = (function () { - function ListSlice(head, tail) { - this._head = head; - this._tail = tail; - } + AbstractTestCase.prototype.assertStableRerender = function assertStableRerender() { + var _this = this; - ListSlice.toList = function toList(slice) { - var list = new LinkedList(); - slice.forEachNode(function (n) { - return list.append(n.clone()); - }); - return list; - }; + this.takeSnapshot(); + this.runTask(function () { + return _this.rerender(); + }); + this.assertInvariants(); + }; - ListSlice.prototype.forEachNode = function forEachNode(callback) { - var node = this._head; - while (node !== null) { - callback(node); - node = this.nextNode(node); - } - }; + babelHelpers.createClass(AbstractTestCase, [{ + key: 'firstChild', + get: function () { + return this.nthChild(0); + } + }, { + key: 'nodesCount', + get: function () { + var count = 0; + var node = this.element.firstChild; - ListSlice.prototype.contains = function contains(needle) { - var node = this._head; - while (node !== null) { - if (node === needle) return true; - node = node.next; - } - return false; - }; + while (node) { + if (!isMarker(node)) { + count++; + } - ListSlice.prototype.head = function head() { - return this._head; - }; + node = node.nextSibling; + } - ListSlice.prototype.tail = function tail() { - return this._tail; - }; + return count; + } + }]); + return AbstractTestCase; + })(); - ListSlice.prototype.toArray = function toArray() { - var out = []; - this.forEachNode(function (n) { - return out.push(n); - }); - return out; - }; + exports.default = AbstractTestCase; +}); +enifed('internal-test-helpers/test-cases/application', ['exports', 'internal-test-helpers/test-cases/abstract-application'], function (exports, _internalTestHelpersTestCasesAbstractApplication) { + 'use strict'; - ListSlice.prototype.nextNode = function nextNode(node) { - if (node === this._tail) return null; - return node.next; - }; + var ApplicationTestCase = (function (_AbstractApplicationTestCase) { + babelHelpers.inherits(ApplicationTestCase, _AbstractApplicationTestCase); - ListSlice.prototype.prevNode = function prevNode(node) { - if (node === this._head) return null; - return node.prev; - }; + function ApplicationTestCase() { + babelHelpers.classCallCheck(this, ApplicationTestCase); - ListSlice.prototype.isEmpty = function isEmpty() { - return false; - }; + _AbstractApplicationTestCase.apply(this, arguments); + } - return ListSlice; - })(); + return ApplicationTestCase; + })(_internalTestHelpersTestCasesAbstractApplication.default); - exports.ListSlice = ListSlice; - var EMPTY_SLICE = new ListSlice(null, null); - exports.EMPTY_SLICE = EMPTY_SLICE; + exports.default = ApplicationTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbGlzdC11dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFTQSxRQUFBLEdBS0UsU0FMRixRQUFBLENBS2MsS0FBUSxFQUFBO0FBSmIsWUFBQSxDQUFBLElBQUksR0FBZ0IsSUFBSSxDQUFDO0FBQ3pCLFlBQUEsQ0FBQSxJQUFJLEdBQWdCLElBQUksQ0FBQztBQUk5QixZQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQztLQU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gICAgIG5vZGUgPSB0aGlzLm5leHROb2RlKG5vZGUpO1xuICAgIH1cbiAgfVxuXG4gIGNvbnRhaW5zKG5lZWRsZTogVCk6IGJvb2xlYW4ge1xuICAgIGxldCBub2RlID0gdGhpcy5faGVhZDtcblxuICAgIHdoaWxlIChub2RlICE9PSBudWxsKSB7XG4gICAgICBpZiAobm9kZSA9PT0gbmVlZGxlKSByZXR1cm4gdHJ1ZTtcbiAgICAgIG5vZGUgPSA8dHJ1c3Q+bm9kZS5uZXh0O1xuICAgIH1cblxuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuXG4gIGhlYWQoKTogVCB7XG4gICAgcmV0dXJuIHRoaXMuX2hlYWQ7XG4gIH1cblxuICB0YWlsKCk6IFQge1xuICAgIHJldHVybiB0aGlzLl90YWlsO1xuICB9XG5cbiAgdG9BcnJheSgpOiBUW10ge1xuICAgIGxldCBvdXQgPSBbXTtcbiAgICB0aGlzLmZvckVhY2hOb2RlKG4gPT4gb3V0LnB1c2gobikpO1xuICAgIHJldHVybiBvdXQ7XG4gIH1cblxuICBuZXh0Tm9kZShub2RlOiBUKTogVCB7XG4gICAgaWYgKG5vZGUgPT09IHRoaXMuX3RhaWwpIHJldHVybiBudWxsO1xuICAgIHJldHVybiA8VD5ub2RlLm5leHQ7XG4gIH1cblxuICBwcmV2Tm9kZShub2RlOiBUKTogVCB7XG4gICAgaWYgKG5vZGUgPT09IHRoaXMuX2hlYWQpIHJldHVybiBudWxsO1xuICAgIHJldHVybiA8VD5ub2RlLnByZXY7XG4gIH1cblxuICBpc0VtcHR5KCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxufVxuXG5leHBvcnQgY29uc3QgRU1QVFlfU0xJQ0UgPSBuZXcgTGlzdFNsaWNlKG51bGwsIG51bGwpO1xuIl19 -enifed("glimmer-util/lib/logger", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-cases/query-param', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers/test-cases/application'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpersTestCasesApplication) { + 'use strict'; - var LogLevel; - exports.LogLevel = LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["Trace"] = 0] = "Trace"; - LogLevel[LogLevel["Debug"] = 1] = "Debug"; - LogLevel[LogLevel["Warn"] = 2] = "Warn"; - LogLevel[LogLevel["Error"] = 3] = "Error"; - })(LogLevel || (exports.LogLevel = LogLevel = {})); + var QueryParamTestCase = (function (_ApplicationTestCase) { + babelHelpers.inherits(QueryParamTestCase, _ApplicationTestCase); - var NullConsole = (function () { - function NullConsole() {} + function QueryParamTestCase() { + babelHelpers.classCallCheck(this, QueryParamTestCase); - NullConsole.prototype.log = function log(message) {}; + _ApplicationTestCase.call(this); - NullConsole.prototype.warn = function warn(message) {}; + var testCase = this; + testCase.expectedPushURL = null; + testCase.expectedReplaceURL = null; + this.application.register('location:test', _emberRouting.NoneLocation.extend({ + setURL: function (path) { + if (testCase.expectedReplaceURL) { + testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); + } - NullConsole.prototype.error = function error(message) {}; + if (testCase.expectedPushURL) { + testCase.assert.equal(path, testCase.expectedPushURL, 'an expected pushState occurred'); + testCase.expectedPushURL = null; + } - NullConsole.prototype.trace = function trace() {}; + this.set('path', path); + }, - return NullConsole; - })(); + replaceURL: function (path) { + if (testCase.expectedPushURL) { + testCase.assert.ok(false, 'replaceState occurred but a pushState was expected'); + } - var Logger = (function () { - function Logger(_ref) { - var console = _ref.console; - var level = _ref.level; + if (testCase.expectedReplaceURL) { + testCase.assert.equal(path, testCase.expectedReplaceURL, 'an expected replaceState occurred'); + testCase.expectedReplaceURL = null; + } - this.f = ALWAYS; - this.force = ALWAYS; - this.console = console; - this.level = level; + this.set('path', path); } + })); + } - Logger.prototype.skipped = function skipped(level) { - return level < this.level; - }; + QueryParamTestCase.prototype.visitAndAssert = function visitAndAssert(path) { + var _this = this; - Logger.prototype.trace = function trace(message) { - var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + return this.visit.apply(this, arguments).then(function () { + _this.assertCurrentPath(path); + }); + }; - var _ref2$stackTrace = _ref2.stackTrace; - var stackTrace = _ref2$stackTrace === undefined ? false : _ref2$stackTrace; + QueryParamTestCase.prototype.getController = function getController(name) { + return this.applicationInstance.lookup('controller:' + name); + }; - if (this.skipped(LogLevel.Trace)) return; - this.console.log(message); - if (stackTrace) this.console.trace(); - }; + QueryParamTestCase.prototype.getRoute = function getRoute(name) { + return this.applicationInstance.lookup('route:' + name); + }; - Logger.prototype.debug = function debug(message) { - var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + QueryParamTestCase.prototype.setAndFlush = function setAndFlush(obj, prop, value) { + return _emberMetal.run(obj, 'set', prop, value); + }; - var _ref3$stackTrace = _ref3.stackTrace; - var stackTrace = _ref3$stackTrace === undefined ? false : _ref3$stackTrace; + QueryParamTestCase.prototype.assertCurrentPath = function assertCurrentPath(path) { + var message = arguments.length <= 1 || arguments[1] === undefined ? 'current path equals \'' + path + '\'' : arguments[1]; + return (function () { + this.assert.equal(this.appRouter.get('location.path'), path, message); + }).apply(this, arguments); + }; - if (this.skipped(LogLevel.Debug)) return; - this.console.log(message); - if (stackTrace) this.console.trace(); - }; + /** + Sets up a Controller for a given route with a single query param and default + value. Can optionally extend the controller with an object. + @public + @method setSingleQPController + */ - Logger.prototype.warn = function warn(message) { - var _ref4 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + QueryParamTestCase.prototype.setSingleQPController = function setSingleQPController(routeName) { + var param = arguments.length <= 1 || arguments[1] === undefined ? 'foo' : arguments[1]; + var defaultValue = arguments.length <= 2 || arguments[2] === undefined ? 'bar' : arguments[2]; - var _ref4$stackTrace = _ref4.stackTrace; - var stackTrace = _ref4$stackTrace === undefined ? false : _ref4$stackTrace; + var _Controller$extend; - if (this.skipped(LogLevel.Warn)) return; - this.console.warn(message); - if (stackTrace) this.console.trace(); - }; + var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; - Logger.prototype.error = function error(message) { - if (this.skipped(LogLevel.Error)) return; - this.console.error(message); - }; + this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend = { + queryParams: [param] + }, _Controller$extend[param] = defaultValue, _Controller$extend), options)); + }; - return Logger; - })(); + /** + Sets up a Controller for a given route with a custom property/url key mapping. + @public + @method setMappedQPController + */ - exports.Logger = Logger; + QueryParamTestCase.prototype.setMappedQPController = function setMappedQPController(routeName) { + var prop = arguments.length <= 1 || arguments[1] === undefined ? 'page' : arguments[1]; + var urlKey = arguments.length <= 2 || arguments[2] === undefined ? 'parentPage' : arguments[2]; + var defaultValue = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3]; - var _console = typeof console === 'undefined' ? new NullConsole() : console; - var ALWAYS = new Logger({ console: _console, level: LogLevel.Trace }); - var LOG_LEVEL = LogLevel.Warn; - exports.default = new Logger({ console: _console, level: LOG_LEVEL }); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbG9nZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLFFBQVksUUFLWCxDQUFBOztBQUxELEtBQUEsVUFBWSxRQUFRLEVBQUE7QUFDbEIsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsT0FBSyxDQUFBO0FBQ0wsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsT0FBSyxDQUFBO0FBQ0wsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsTUFBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsTUFBSSxDQUFBO0FBQ0osZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEs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xuICB9XG5cbiAgZXJyb3IobWVzc2FnZTogYW55IHwgYW55W10pIHtcbiAgICBpZiAodGhpcy5za2lwcGVkKExvZ0xldmVsLkVycm9yKSkgcmV0dXJuO1xuICAgIHRoaXMuY29uc29sZS5lcnJvcihtZXNzYWdlKTtcbiAgfVxufVxuXG5sZXQgX2NvbnNvbGUgPSAodHlwZW9mIGNvbnNvbGUgPT09ICd1bmRlZmluZWQnKSA/IG5ldyBOdWxsQ29uc29sZSgpIDogY29uc29sZTtcblxuY29uc3QgQUxXQVlTID0gbmV3IExvZ2dlcih7IGNvbnNvbGU6IF9jb25zb2xlLCBsZXZlbDogTG9nTGV2ZWwuVHJhY2UgfSk7XG5jb25zdCBMT0dfTEVWRUwgPSBMb2dMZXZlbC5XYXJuO1xuXG5leHBvcnQgZGVmYXVsdCBuZXcgTG9nZ2VyKHsgY29uc29sZTogX2NvbnNvbGUsIGxldmVsOiBMT0dfTEVWRUwgfSk7XG4iXX0= -enifed('glimmer-util/lib/namespaces', ['exports'], function (exports) { - // There is a small whitelist of namespaced attributes specially - // enumerated in - // https://www.w3.org/TR/html/syntax.html#attributes-0 - // - // > When a foreign element has one of the namespaced attributes given by - // > the local name and namespace of the first and second cells of a row - // > from the following table, it must be written using the name given by - // > the third cell from the same row. - // - // In all other cases, colons are interpreted as a regular character - // with no special meaning: - // - // > No other namespaced attribute can be expressed in the HTML syntax. - 'use strict'; + var _queryParams, _Controller$extend2; - exports.getAttrNamespace = getAttrNamespace; - var XLINK = 'http://www.w3.org/1999/xlink'; - var XML = 'http://www.w3.org/XML/1998/namespace'; - var XMLNS = 'http://www.w3.org/2000/xmlns/'; - var WHITELIST = { - 'xlink:actuate': XLINK, - 'xlink:arcrole': XLINK, - 'xlink:href': XLINK, - 'xlink:role': XLINK, - 'xlink:show': XLINK, - 'xlink:title': XLINK, - 'xlink:type': XLINK, - 'xml:base': XML, - 'xml:lang': XML, - 'xml:space': XML, - 'xmlns': XMLNS, - 'xmlns:xlink': XMLNS + var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; + + this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend2 = { + queryParams: (_queryParams = {}, _queryParams[prop] = urlKey, _queryParams) + }, _Controller$extend2[prop] = defaultValue, _Controller$extend2), options)); }; - function getAttrNamespace(attrName) { - return WHITELIST[attrName] || null; - } + babelHelpers.createClass(QueryParamTestCase, [{ + key: 'routerOptions', + get: function () { + return { + location: 'test' + }; + } + }]); + return QueryParamTestCase; + })(_internalTestHelpersTestCasesApplication.default); + + exports.default = QueryParamTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbmFtZXNwYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7OztBQWNBLFFBQU0sS0FBSyxHQUFHLDhCQUE4QixDQUFDO0FBQzdDLFFBQU0sR0FBRyxHQUFHLHNDQUFzQyxDQUFDO0FBQ25ELFFBQU0sS0FBSyxHQUFHLCtCQUErQixDQUFDO0FBRTlDLFFBQU0sU0FBUyxHQUFHO0FBQ2hCLHVCQUFlLEVBQUUsS0FBSztBQUN0Qix1QkFBZSxFQUFFLEtBQUs7QUFDdEIsb0JBQVksRUFBRSxLQUFLO0FBQ25CLG9CQUFZLEVBQUUsS0FBSztBQUNuQixvQkFBWSxFQUFFLEtBQUs7QUFDbkIscUJBQWEsRUFBRSxLQUFLO0FBQ3BCLG9CQUFZLEVBQUUsS0FBSztBQUNuQixrQkFBVSxFQUFFLEdBQUc7QUFDZixrQkFBVSxFQUFFLEdBQUc7QUFDZixtQkFBVyxFQUFFLEdBQUc7QUFDaEIsZUFBTyxFQUFFLEtBQUs7QUFDZCxxQkFBYSxFQUFFLEtBQUs7S0FDckIsQ0FBQzs7QUFFRixhQUFBLGdCQUFBLENBQWlDLFFBQVEsRUFBQTtBQUN2QyxlQUFPLFNBQVMsQ0F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nLzIwMDAveG1sbnMvJztcblxuY29uc3QgV0hJVEVMSVNUID0ge1xuICAneGxpbms6YWN0dWF0ZSc6IFhMSU5LLFxuICAneGxpbms6YXJjcm9sZSc6IFhMSU5LLFxuICAneGxpbms6aHJlZic6IFhMSU5LLFxuICAneGxpbms6cm9sZSc6IFhMSU5LLFxuICAneGxpbms6c2hvdyc6IFhMSU5LLFxuICAneGxpbms6dGl0bGUnOiBYTElOSyxcbiAgJ3hsaW5rOnR5cGUnOiBYTElOSyxcbiAgJ3htbDpiYXNlJzogWE1MLFxuICAneG1sOmxhbmcnOiBYTUwsXG4gICd4bWw6c3BhY2UnOiBYTUwsXG4gICd4bWxucyc6IFhNTE5TLFxuICAneG1sbnM6eGxpbmsnOiBYTUxOU1xufTtcblxuZXhwb3J0IGZ1bmN0aW9uIGdldEF0dHJOYW1lc3BhY2UoYXR0ck5hbWUpIHtcbiAgcmV0dXJuIFdISVRFTElTVFthdHRyTmFtZV0gfHwgbnVsbDtcbn0iXX0= -enifed('glimmer-util/lib/object-utils', ['exports'], function (exports) { - 'use strict'; +enifed('internal-test-helpers/test-cases/rendering', ['exports', 'ember-views', 'internal-test-helpers/test-cases/abstract-rendering'], function (exports, _emberViews, _internalTestHelpersTestCasesAbstractRendering) { + 'use strict'; - exports.assign = assign; - var objKeys = Object.keys; + var RenderingTestCase = (function (_AbstractRenderingTestCase) { + babelHelpers.inherits(RenderingTestCase, _AbstractRenderingTestCase); - function assign(obj) { - for (var i = 1; i < arguments.length; i++) { - var assignment = arguments[i]; - if (assignment === null || typeof assignment !== 'object') continue; - var keys = objKeys(assignment); - for (var j = 0; j < keys.length; j++) { - var key = keys[j]; - obj[key] = assignment[key]; - } - } - return obj; + function RenderingTestCase() { + babelHelpers.classCallCheck(this, RenderingTestCase); + + _AbstractRenderingTestCase.call(this); + var owner = this.owner; + + this.env = owner.lookup('service:-glimmer-environment'); + owner.register('component-lookup:main', _emberViews.ComponentLookup); + owner.registerOptionsForType('helper', { instantiate: false }); + owner.registerOptionsForType('component', { singleton: false }); } + + return RenderingTestCase; + })(_internalTestHelpersTestCasesAbstractRendering.default); + + exports.default = RenderingTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvb2JqZWN0LXV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7UUFBYyxPQUFPLEdBQUssTUFBTSxDQUF4QixJQUFJOztBQVNaLGFBQUEsTUFBQSxDQUF1QixHQUFHLEVBQUE7QUFDeEIsYUFBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxFQUFFLEVBQUU7QUFDekMsZ0JBQUksVUFBVSxHQUFHLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUM5QixnQkFBSSxVQUFVLEtBQUssSUFBSSxJQUFJLE9BQU8sVUFBVSxLQUFLLFFBQVEsRUFBRSxTQUFTO0FBQ3BFLGdCQUFJLElBQUksR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7QUFDL0IsaUJBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO0FBQ3BDLG9CQUFJLEdBQUcsR0FBRyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDbEIsbUJBQUcsQ0FBQyxHQUFHLENBQUMsR0FBRyxVQUFVLENBQUMsR0FBRyxDQUFDLENBQUM7YUFDNUI7U0FDRjtBQUNELGVBQU8sR0FBRyxDQUFDO0tBQ1oiLCJmaWxlIjoib2JqZWN0LXV0aWxzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY29uc3QgeyBrZXlzOiBvYmpLZXlzIH0gPSBPYmplY3Q7XG5cbmV4cG9ydCBmdW5jdGlvb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isrKSB7XG4gICAgICBsZXQga2V5ID0ga2V5c1tqXTtcbiAgICAgIG9ialtrZXldID0gYXNzaWdubWVudFtrZXldO1xuICAgIH1cbiAgfVxuICByZXR1cm4gb2JqO1xufVxuIl19 -enifed("glimmer-util/lib/platform-utils", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-cases/router', ['exports', 'internal-test-helpers/test-cases/application'], function (exports, _internalTestHelpersTestCasesApplication) { + 'use strict'; - exports.unwrap = unwrap; + var RouterTestCase = (function (_ApplicationTestCase) { + babelHelpers.inherits(RouterTestCase, _ApplicationTestCase); - function unwrap(val) { - if (val === null || val === undefined) throw new Error("Expected value to be present"); - return val; + function RouterTestCase() { + babelHelpers.classCallCheck(this, RouterTestCase); + + _ApplicationTestCase.call(this); + + this.router.map(function () { + this.route('parent', { path: '/' }, function () { + this.route('child'); + this.route('sister'); + this.route('brother'); + }); + this.route('dynamic', { path: '/dynamic/:post_id' }); + }); } + + babelHelpers.createClass(RouterTestCase, [{ + key: 'routerService', + get: function () { + return this.applicationInstance.lookup('service:router'); + } + }]); + return RouterTestCase; + })(_internalTestHelpersTestCasesApplication.default); + + exports.default = RouterTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvcGxhdGZvcm0tdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFJQSxhQUFBLE1BQUEsQ0FBMEIsR0FBYSxFQUFBO0FBQ3JDLFlBQUksR0FBRyxLQUFLLElBQUksSUFBSSxHQUFHLEtBQUssU0FBUyxFQUFFLE1BQU0sSUFBSSxLQUFLLGdDQUFnQyxDQUFDO0FBQ3ZGLGVBQU8sR0FBRyxDQUFDO0tBQ1oiLCJmaWxlIjoicGxhdGZvcm0tdXRpbHMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgdHlwZSBPcGFxdWUgPSB7fSB8IHZvaWQ7XG5leHBvcnQgdHlwZSBPcHRpb248VD4gPSBUIHwgbnVsbDsgLy8gdHNsaW50OmRpc2FibGUtbGluZVxuZXhwb3J0IHR5cGUgTWF5YmU8VD4gPSBPcHRpb248VD4gfCB1bmRlZmluZWQ7IC8vIHRzbGludDpkaXNhYmxlLWxpbmVcblxuZXhwb3J0IGZ1bmN0aW9uIHVud3JhcDxUPih2YWw6IE1heWJlPFQ+KTogVCB7XG4gIGlmICh2YWwgPT09IG51bGwgfHwgdmFsID09PSB1bmRlZmluZWQpIHRocm93IG5ldyBFcnJvcihgRXhwZWN0ZWQgdmFsdWUgdG8gYmUgcHJlc2VudGApO1xuICByZXR1cm4gdmFsO1xufVxuIl19 -enifed("glimmer-util/lib/quoting", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-groups', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + 'use strict'; - exports.hash = hash; - exports.repeat = repeat; - function escapeString(str) { - str = str.replace(/\\/g, "\\\\"); - str = str.replace(/"/g, '\\"'); - str = str.replace(/\n/g, "\\n"); - return str; - } - exports.escapeString = escapeString; + exports.testBoth = testBoth; + exports.testWithDefault = testWithDefault; - function string(str) { - return '"' + escapeString(str) + '"'; - } - exports.string = string; + // used by unit tests to test both accessor mode and non-accessor mode - function array(a) { - return "[" + a + "]"; + function testBoth(testname, callback) { + function emberget(x, y) { + return _emberMetal.get(x, y); } - exports.array = array; - - function hash(pairs) { - return "{" + pairs.join(", ") + "}"; + function emberset(x, y, z) { + return _emberMetal.set(x, y, z); } - - function repeat(chars, times) { - var str = ""; - while (times--) { - str += chars; - } - return str; + function aget(x, y) { + return x[y]; + } + function aset(x, y, z) { + return x[y] = z; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvcXVvdGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLGFB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KHN0cikge1xuICBzdHIgPSBzdHIucmVwbGFjZSgvXFxcXC9nLCBcIlxcXFxcXFxcXCIpO1xuICBzdHIgPSBzdHIucmVwbGFjZSgvXCIvZywgJ1xcXFxcIicpO1xuICBzdHIgPSBzdHIucmVwbGFjZSgvXFxuL2csIFwiXFxcXG5cIik7XG4gIHJldHVybiBzdHI7XG59XG5cbmV4cG9ydCB7IGVzY2FwZVN0cmluZyB9O1xuXG5mdW5jdGlvbiBzdHJpbmcoc3RyKSB7XG4gIHJldHVybiAnXCInICsgZXNjYXBlU3RyaW5nKHN0cikgKyAnXCInO1xufVxuXG5leHBvcnQgeyBzdHJpbmcgfTtcblxuZnVuY3Rpb24gYXJyYXkoYSkge1xuICByZXR1cm4gXCJbXCIgKyBhICsgXCJdXCI7XG59XG5cbmV4cG9ydCB7IGFycmF5IH07XG5cbmV4cG9ydCBmdW5jdGlvbiBoYXNoKHBhaXJzKSB7XG4gIHJldHVybiBcIntcIiArIHBhaXJzLmpvaW4oXCIsIFwiKSArIFwifVwiO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gcmVwZWF0KGNoYXJzLCB0aW1lcykge1xuICBsZXQgc3RyID0gXCJcIjtcbiAgd2hpbGUgKHRpbWVzLS0pIHtcbiAgICBzdHIgKz0gY2hhcnM7XG4gIH1cbiAgcmV0dXJuIHN0cjtcbn1cbiJdfQ== -enifed('glimmer-wire-format/index', ['exports'], function (exports) { - 'use strict'; - function is(variant) { - return function (value) { - return value[0] === variant; - }; + QUnit.test(testname + ' using getFromEmberMetal()/Ember.set()', function () { + callback(emberget, emberset); + }); + + QUnit.test(testname + ' using accessors', function () { + if (_emberEnvironment.ENV.USES_ACCESSORS) { + callback(aget, aset); + } else { + ok('SKIPPING ACCESSORS'); + } + }); + } + + function testWithDefault(testname, callback) { + function emberget(x, y) { + return _emberMetal.get(x, y); } - var Expressions; - exports.Expressions = Expressions; - (function (Expressions) { - Expressions.isUnknown = is('unknown'); - Expressions.isArg = is('arg'); - Expressions.isGet = is('get'); - Expressions.isConcat = is('concat'); - Expressions.isHelper = is('helper'); - Expressions.isHasBlock = is('has-block'); - Expressions.isHasBlockParams = is('has-block-params'); - Expressions.isUndefined = is('undefined'); - function isPrimitiveValue(value) { - if (value === null) { - return true; - } - return typeof value !== 'object'; - } - Expressions.isPrimitiveValue = isPrimitiveValue; - })(Expressions || (exports.Expressions = Expressions = {})); - var Statements; - exports.Statements = Statements; - (function (Statements) { - Statements.isText = is('text'); - Statements.isAppend = is('append'); - Statements.isComment = is('comment'); - Statements.isModifier = is('modifier'); - Statements.isBlock = is('block'); - Statements.isOpenElement = is('open-element'); - Statements.isFlushElement = is('flush-element'); - Statements.isCloseElement = is('close-element'); - Statements.isStaticAttr = is('static-attr'); - Statements.isDynamicAttr = is('dynamic-attr'); - Statements.isYield = is('yield'); - Statements.isPartial = is('partial'); - Statements.isDynamicArg = is('dynamic-arg'); - Statements.isStaticArg = is('static-arg'); - Statements.isTrustingAttr = is('trusting-attr'); - })(Statements || (exports.Statements = Statements = {})); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItd2lyZS1mb3JtYXQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBbUJBLGFBQUEsRUFBQSxDQUE2QixPQUFlLEVBQUE7QUFDMUMsZUFBTyxVQUFTLEtBQVksRUFBQTtBQUMxQixtQkFBTyxLQUFLLENBQUMsQ0FBQyxDQUFDLEtBQUssT0FBTyxDQUFDO1NBQzdCLENBQUM7S0FDSDtBQVVELFFBQWlCLFdBQVcsQ0FvRDNCOztBQXBERCxLQUFBLFVBQWlCLFdBQVcsRUFBQztBQXFDZCxtQkFBQSxDQUFBLFNBQVMsR0FBVSxFQUFFLENBQVUsU0FBUyxDQUFDLENBQUM7QUFDMUMsbUJBQUEsQ0FBQSxLQUFLLEdBQWMsRUFBRSxDQUFNLEtBQUssQ0FBQyxDQUFDO0FBQ2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ZFRlbXBsYXRlQmxvY2sgYXMgSlNPTiBhbmQgVGVtcGxhdGVNZXRhLlxuICovXG5leHBvcnQgaW50ZXJmYWNlIFNlcmlhbGl6ZWRUZW1wbGF0ZVdpdGhMYXp5QmxvY2s8VCBleHRlbmRzIFRlbXBsYXRlTWV0YT4ge1xuICBpZD86IHN0cmluZztcbiAgYmxvY2s6IFNlcmlhbGl6ZWRUZW1wbGF0ZUJsb2NrSlNPTjtcbiAgbWV0YTogVDtcbn1cblxuLyoqXG4gKiBBIHN0cmluZyBvZiBKYXZhc2NyaXB0IGNvbnRhaW5pbmcgYSBTZXJpYWxpemVkVGVtcGxhdGVXaXRoTGF6eUJsb2NrIHRvIGJlXG4gKiBjb25jYXRlbmF0ZWQgaW50byBhIEphdmFzY3JpcHQgbW9kdWxlLlxuICogQHR5cGVkZWYge3N0cmluZ30gVGVtcGxhdGVKYXZhc2NyaXB0XG4gKi9cbmV4cG9ydCB0eXBlIFRlbXBsYXRlSmF2YXNjcmlwdCA9IHN0cmluZztcbiJdfQ== -enifed('glimmer/index', ['exports', 'glimmer-compiler'], function (exports, _glimmerCompiler) { - /* - * @overview Glimmer - * @copyright Copyright 2011-2015 Tilde Inc. and contributors - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/tildeio/glimmer/master/LICENSE - * @version VERSION_STRING_PLACEHOLDER - */ - 'use strict'; + function embergetwithdefault(x, y, z) { + return _emberMetal.getWithDefault(x, y, z); + } + function getwithdefault(x, y, z) { + return x.getWithDefault(y, z); + } + function emberset(x, y, z) { + return _emberMetal.set(x, y, z); + } + function aget(x, y) { + return x[y]; + } + function aset(x, y, z) { + return x[y] = z; + } + + QUnit.test(testname + ' using obj.get()', function () { + callback(emberget, emberset); + }); + + QUnit.test(testname + ' using obj.getWithDefault()', function () { + callback(getwithdefault, emberset); + }); + + QUnit.test(testname + ' using getFromEmberMetal()', function () { + callback(emberget, emberset); + }); - exports.precompile = _glimmerCompiler.precompile; + QUnit.test(testname + ' using Ember.getWithDefault()', function () { + callback(embergetwithdefault, emberset); + }); + + QUnit.test(testname + ' using accessors', function () { + if (_emberEnvironment.ENV.USES_ACCESSORS) { + callback(aget, aset); + } else { + ok('SKIPPING ACCESSORS'); + } + }); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztVQU9TLFVBQVUsb0JBQVYsVUFBVSIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBAb3ZlcnZpZXcgIEdsaW1tZXJcbiAqIEBjb3B5cmlnaHQgQ29weXJpZ2h0IDIwMTEtMjAxNSBUaWxkZSBJbmMuIGFuZCBjb250cmlidXRvcnNcbiAqIEBsaWNlbnNlICAgTGljZW5zZWQgdW5kZXIgTUlUIGxpY2Vuc2VcbiAqICAgICAgICAgICAgU2VlIGh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS90aWxkZWlvL2dsaW1tZXIvbWFzdGVyL0xJQ0VOU0VcbiAqIEB2ZXJzaW9uICAgVkVSU0lPTl9TVFJJTkdfUExBQ0VIT0xERVJcbiAqL1xuZXhwb3J0IHsgcHJlY29tcGlsZSB9IGZyb20gJ2dsaW1tZXItY29tcGlsZXInO1xuIl19 enifed('route-recognizer', ['exports'], function (exports) { 'use strict'; -function Target(path, matcher, delegate) { - this.path = path; - this.matcher = matcher; - this.delegate = delegate; +var createObject = Object.create; +function createMap() { + var map = createObject(null); + map["__"] = undefined; + delete map["__"]; + return map; } -Target.prototype = { - to: function(target, callback) { +var Target = function Target(path, matcher, delegate) { + this.path = path; + this.matcher = matcher; + this.delegate = delegate; +}; +Target.prototype.to = function to (target, callback) { var delegate = this.delegate; - if (delegate && delegate.willAddRoute) { - target = delegate.willAddRoute(this.matcher.target, target); + target = delegate.willAddRoute(this.matcher.target, target); } - this.matcher.add(this.path, target); - if (callback) { - if (callback.length === 0) { throw new Error("You must have an argument in the function passed to `to`"); } - this.matcher.addChild(this.path, target, callback, this.delegate); + if (callback.length === 0) { + throw new Error("You must have an argument in the function passed to `to`"); + } + this.matcher.addChild(this.path, target, callback, this.delegate); } - return this; - } }; - -function Matcher(target) { - this.routes = {}; - this.children = {}; - this.target = target; -} - -Matcher.prototype = { - add: function(path, handler) { - this.routes[path] = handler; - }, - - addChild: function(path, target, callback, delegate) { +var Matcher = function Matcher(target) { + this.routes = createMap(); + this.children = createMap(); + this.target = target; +}; +Matcher.prototype.add = function add (path, target) { + this.routes[path] = target; +}; +Matcher.prototype.addChild = function addChild (path, target, callback, delegate) { var matcher = new Matcher(target); this.children[path] = matcher; - var match = generateMatch(path, matcher, delegate); - if (delegate && delegate.contextEntered) { - delegate.contextEntered(target, match); + delegate.contextEntered(target, match); } - callback(match); - } }; - function generateMatch(startingPath, matcher, delegate) { - return function(path, nestedCallback) { - var fullPath = startingPath + path; - - if (nestedCallback) { - nestedCallback(generateMatch(fullPath, matcher, delegate)); - } else { - return new Target(startingPath + path, matcher, delegate); + function match(path, callback) { + var fullPath = startingPath + path; + if (callback) { + callback(generateMatch(fullPath, matcher, delegate)); + } + else { + return new Target(fullPath, matcher, delegate); + } } - }; + ; + return match; } - function addRoute(routeArray, path, handler) { - var len = 0; - for (var i=0; i 0 && route.charCodeAt(0) === 47 /* SLASH */) { + route = route.substr(1); + } + var parts = route.split("/"); + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + var flags = 0; + var type = 0; + if (part === "") { + type = 4 /* Epsilon */; + } + else if (part.charCodeAt(0) === 58 /* COLON */) { + type = 1 /* Dynamic */; + } + else if (part.charCodeAt(0) === 42 /* STAR */) { + type = 2 /* Star */; + } + else { + type = 0 /* Static */; + } + flags = 2 << type; + if (flags & 12 /* Named */) { + part = part.slice(1); + names.push(part); + shouldDecodes.push((flags & 4 /* Decoded */) !== 0); + } + if (flags & 14 /* Counted */) { + types[type]++; + } + segments.push({ type: type, value: normalizeSegment(part) }); } - } - - return results; } - -function isEqualCharSpec(specA, specB) { - return specA.validChars === specB.validChars && - specA.invalidChars === specB.invalidChars; +function isEqualCharSpec(spec, char, negate) { + return spec.char === char && spec.negate === negate; } - // A State has a character specification and (`charSpec`) and a list of possible // subsequent states (`nextStates`). // @@ -55153,75 +46501,95 @@ function isEqualCharSpec(specA, specB) { // Currently, State is implemented naively by looping over `nextStates` and // comparing a character specification against a character. A more efficient // implementation would use a hash of keys pointing at one or more next states. +var State = function State(states, id, char, negate, repeat) { + this.states = states; + this.id = id; + this.char = char; + this.negate = negate; + this.nextStates = repeat ? id : null; + this.pattern = ""; + this._regex = undefined; + this.handlers = undefined; + this.types = undefined; +}; +State.prototype.regex = function regex$1 () { + if (!this._regex) { + this._regex = new RegExp(this.pattern); + } + return this._regex; +}; +State.prototype.get = function get (char, negate) { + var this$1 = this; -function State(charSpec) { - this.charSpec = charSpec; - this.nextStates = []; - this.regex = undefined; - this.handlers = undefined; - this.specificity = undefined; -} - -State.prototype = { - get: function(charSpec) { var nextStates = this.nextStates; - - for (var i=0; i 2 && key.slice(keyLength -2) === '[]') { - isArray = true; - key = key.slice(0, keyLength - 2); - if(!queryParams[key]) { - queryParams[key] = []; - } +}; +RouteRecognizer.prototype.parseQueryString = function parseQueryString (queryString) { + var pairs = queryString.split("&"); + var queryParams = {}; + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i].split("="), key = decodeQueryParamPart(pair[0]), keyLength = key.length, isArray = false, value = (void 0); + if (pair.length === 1) { + value = "true"; + } + else { + // Handle arrays + if (keyLength > 2 && key.slice(keyLength - 2) === "[]") { + isArray = true; + key = key.slice(0, keyLength - 2); + if (!queryParams[key]) { + queryParams[key] = []; + } + } + value = pair[1] ? decodeQueryParamPart(pair[1]) : ""; + } + if (isArray) { + queryParams[key].push(value); + } + else { + queryParams[key] = value; } - value = pair[1] ? decodeQueryParamPart(pair[1]) : ''; - } - if (isArray) { - queryParams[key].push(value); - } else { - queryParams[key] = value; - } } return queryParams; - }, - - recognize: function(path) { - var states = [ this.rootState ], - pathLen, i, queryStart, queryParams = {}, - hashStart, - isSlashDropped = false; - - hashStart = path.indexOf('#'); +}; +RouteRecognizer.prototype.recognize = function recognize (path) { + var results; + var states = [this.rootState]; + var queryParams = {}; + var isSlashDropped = false; + var hashStart = path.indexOf("#"); if (hashStart !== -1) { - path = path.substr(0, hashStart); + path = path.substr(0, hashStart); } - - queryStart = path.indexOf('?'); + var queryStart = path.indexOf("?"); if (queryStart !== -1) { - var queryString = path.substr(queryStart + 1, path.length); - path = path.substr(0, queryStart); - queryParams = this.parseQueryString(queryString); + var queryString = path.substr(queryStart + 1, path.length); + path = path.substr(0, queryStart); + queryParams = this.parseQueryString(queryString); + } + if (path.charAt(0) !== "/") { + path = "/" + path; } - - if (path.charAt(0) !== "/") { path = "/" + path; } var originalPath = path; - if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) { - path = normalizePath(path); - } else { - path = decodeURI(path); - originalPath = decodeURI(originalPath); + path = normalizePath(path); } - - pathLen = path.length; + else { + path = decodeURI(path); + originalPath = decodeURI(originalPath); + } + var pathLen = path.length; if (pathLen > 1 && path.charAt(pathLen - 1) === "/") { - path = path.substr(0, pathLen - 1); - originalPath = originalPath.substr(0, originalPath.length - 1); - isSlashDropped = true; + path = path.substr(0, pathLen - 1); + originalPath = originalPath.substr(0, originalPath.length - 1); + isSlashDropped = true; } - - for (i=0; i= timers[middle]) { - start = middle + 2; - } else { - end = middle; - } - } + NodeDOMTreeConstruction.prototype.setAttribute = function setAttribute(element, name, value) { + element.setAttribute(name, value); + }; - return (time >= timers[start]) ? start + 2 : start; -} + return NodeDOMTreeConstruction; + })(_glimmerRuntime.DOMTreeConstruction); -function Queue(name, options, globalOptions) { - this.name = name; - this.globalOptions = globalOptions || {}; - this.options = options; - this._queue = []; - this.targetQueues = {}; - this._queueBeingFlushed = undefined; -} + exports.NodeDOMTreeConstruction = NodeDOMTreeConstruction; +}); +enifed("@glimmer/reference", ["exports", "@glimmer/util"], function (exports, _glimmerUtil) { + "use strict"; -Queue.prototype = { - push: function(target, method, args, stack) { - var queue = this._queue; - queue.push(target, method, args, stack); + var CONSTANT = 0; + var INITIAL = 1; + var VOLATILE = NaN; - return { - queue: this, - target: target, - method: method - }; - }, + var RevisionTag = (function () { + function RevisionTag() {} - pushUniqueWithoutGuid: function(target, method, args, stack) { - var queue = this._queue; + RevisionTag.prototype.validate = function validate(snapshot) { + return this.value() === snapshot; + }; - for (var i = 0, l = queue.length; i < l; i += 4) { - var currentTarget = queue[i]; - var currentMethod = queue[i+1]; + return RevisionTag; + })(); - if (currentTarget === target && currentMethod === method) { - queue[i+2] = args; // replace args - queue[i+3] = stack; // replace stack - return; - } - } + var $REVISION = INITIAL; - queue.push(target, method, args, stack); - }, + var DirtyableTag = (function (_RevisionTag) { + babelHelpers.inherits(DirtyableTag, _RevisionTag); - targetQueue: function(targetQueue, target, method, args, stack) { - var queue = this._queue; + function DirtyableTag() { + var revision = arguments.length <= 0 || arguments[0] === undefined ? $REVISION : arguments[0]; - for (var i = 0, l = targetQueue.length; i < l; i += 2) { - var currentMethod = targetQueue[i]; - var currentIndex = targetQueue[i + 1]; + _RevisionTag.call(this); + this.revision = revision; + } - if (currentMethod === method) { - queue[currentIndex + 2] = args; // replace args - queue[currentIndex + 3] = stack; // replace stack - return; - } - } + DirtyableTag.prototype.value = function value() { + return this.revision; + }; - targetQueue.push( - method, - queue.push(target, method, args, stack) - 4 - ); - }, + DirtyableTag.prototype.dirty = function dirty() { + this.revision = ++$REVISION; + }; - pushUniqueWithGuid: function(guid, target, method, args, stack) { - var hasLocalQueue = this.targetQueues[guid]; + return DirtyableTag; + })(RevisionTag); - if (hasLocalQueue) { - this.targetQueue(hasLocalQueue, target, method, args, stack); - } else { - this.targetQueues[guid] = [ - method, - this._queue.push(target, method, args, stack) - 4 - ]; + function combineTagged(tagged) { + var optimized = []; + for (var i = 0, l = tagged.length; i < l; i++) { + var tag = tagged[i].tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function combineSlice(slice) { + var optimized = []; + var node = slice.head(); + while (node !== null) { + var tag = node.tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag !== CONSTANT_TAG) optimized.push(tag); + node = slice.nextNode(node); + } + return _combine(optimized); + } + function combine(tags) { + var optimized = []; + for (var i = 0, l = tags.length; i < l; i++) { + var tag = tags[i]; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function _combine(tags) { + switch (tags.length) { + case 0: + return CONSTANT_TAG; + case 1: + return tags[0]; + case 2: + return new TagsPair(tags[0], tags[1]); + default: + return new TagsCombinator(tags); + } + ; } - return { - queue: this, - target: target, - method: method - }; - }, + var CachedTag = (function (_RevisionTag2) { + babelHelpers.inherits(CachedTag, _RevisionTag2); - pushUnique: function(target, method, args, stack) { - var KEY = this.globalOptions.GUID_KEY; + function CachedTag() { + _RevisionTag2.apply(this, arguments); + this.lastChecked = null; + this.lastValue = null; + } - if (target && KEY) { - var guid = target[KEY]; - if (guid) { - return this.pushUniqueWithGuid(guid, target, method, args, stack); - } - } + CachedTag.prototype.value = function value() { + var lastChecked = this.lastChecked; + var lastValue = this.lastValue; - this.pushUniqueWithoutGuid(target, method, args, stack); + if (lastChecked !== $REVISION) { + this.lastChecked = $REVISION; + this.lastValue = lastValue = this.compute(); + } + return this.lastValue; + }; - return { - queue: this, - target: target, - method: method - }; - }, + CachedTag.prototype.invalidate = function invalidate() { + this.lastChecked = null; + }; - invoke: function(target, method, args /*, onError, errorRecordedForStack */) { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - }, + return CachedTag; + })(RevisionTag); - invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { - try { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - } catch(error) { - onError(error, errorRecordedForStack); - } - }, + var TagsPair = (function (_CachedTag) { + babelHelpers.inherits(TagsPair, _CachedTag); - flush: function(sync) { - var queue = this._queue; - var length = queue.length; + function TagsPair(first, second) { + _CachedTag.call(this); + this.first = first; + this.second = second; + } - if (length === 0) { - return; - } + TagsPair.prototype.compute = function compute() { + return Math.max(this.first.value(), this.second.value()); + }; - var globalOptions = this.globalOptions; - var options = this.options; - var before = options && options.before; - var after = options && options.after; - var onError = globalOptions.onError || (globalOptions.onErrorTarget && - globalOptions.onErrorTarget[globalOptions.onErrorMethod]); - var target, method, args, errorRecordedForStack; - var invoke = onError ? this.invokeWithOnError : this.invoke; + return TagsPair; + })(CachedTag); - this.targetQueues = Object.create(null); - var queueItems = this._queueBeingFlushed = this._queue.slice(); - this._queue = []; + var TagsCombinator = (function (_CachedTag2) { + babelHelpers.inherits(TagsCombinator, _CachedTag2); - if (before) { - before(); - } + function TagsCombinator(tags) { + _CachedTag2.call(this); + this.tags = tags; + } - for (var i = 0; i < length; i += 4) { - target = queueItems[i]; - method = queueItems[i+1]; - args = queueItems[i+2]; - errorRecordedForStack = queueItems[i+3]; // Debugging assistance + TagsCombinator.prototype.compute = function compute() { + var tags = this.tags; - if (isString(method)) { - method = target[method]; - } + var max = -1; + for (var i = 0; i < tags.length; i++) { + var value = tags[i].value(); + max = Math.max(value, max); + } + return max; + }; - // method could have been nullified / canceled during flush - if (method) { - // - // ** Attention intrepid developer ** - // - // To find out the stack of this task when it was scheduled onto - // the run loop, add the following to your app.js: - // - // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. - // - // Once that is in place, when you are at a breakpoint and navigate - // here in the stack explorer, you can look at `errorRecordedForStack.stack`, - // which will be the captured stack when this job was scheduled. - // - // One possible long-term solution is the following Chrome issue: - // https://bugs.chromium.org/p/chromium/issues/detail?id=332624 - // - invoke(target, method, args, onError, errorRecordedForStack); - } - } + return TagsCombinator; + })(CachedTag); - if (after) { - after(); - } + var UpdatableTag = (function (_CachedTag3) { + babelHelpers.inherits(UpdatableTag, _CachedTag3); - this._queueBeingFlushed = undefined; + function UpdatableTag(tag) { + _CachedTag3.call(this); + this.tag = tag; + this.lastUpdated = INITIAL; + } - if (sync !== false && - this._queue.length > 0) { - // check if new items have been added - this.flush(true); - } - }, + ////////// - cancel: function(actionToCancel) { - var queue = this._queue, currentTarget, currentMethod, i, l; - var target = actionToCancel.target; - var method = actionToCancel.method; - var GUID_KEY = this.globalOptions.GUID_KEY; + UpdatableTag.prototype.compute = function compute() { + return Math.max(this.lastUpdated, this.tag.value()); + }; - if (GUID_KEY && this.targetQueues && target) { - var targetQueue = this.targetQueues[target[GUID_KEY]]; + UpdatableTag.prototype.update = function update(tag) { + if (tag !== this.tag) { + this.tag = tag; + this.lastUpdated = $REVISION; + this.invalidate(); + } + }; - if (targetQueue) { - for (i = 0, l = targetQueue.length; i < l; i++) { - if (targetQueue[i] === method) { - targetQueue.splice(i, 1); - } + return UpdatableTag; + })(CachedTag); + + var CONSTANT_TAG = new ((function (_RevisionTag3) { + babelHelpers.inherits(ConstantTag, _RevisionTag3); + + function ConstantTag() { + _RevisionTag3.apply(this, arguments); } - } - } - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; + ConstantTag.prototype.value = function value() { + return CONSTANT; + }; - if (currentTarget === target && - currentMethod === method) { - queue.splice(i, 4); - return true; - } - } + return ConstantTag; + })(RevisionTag))(); + var VOLATILE_TAG = new ((function (_RevisionTag4) { + babelHelpers.inherits(VolatileTag, _RevisionTag4); - // if not found in current queue - // could be in the queue that is being flushed - queue = this._queueBeingFlushed; + function VolatileTag() { + _RevisionTag4.apply(this, arguments); + } - if (!queue) { - return; - } + VolatileTag.prototype.value = function value() { + return VOLATILE; + }; - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; + return VolatileTag; + })(RevisionTag))(); + var CURRENT_TAG = new ((function (_DirtyableTag) { + babelHelpers.inherits(CurrentTag, _DirtyableTag); - if (currentTarget === target && - currentMethod === method) { - // don't mess with array during flush - // just nullify the method - queue[i+1] = null; - return true; - } - } - } -}; + function CurrentTag() { + _DirtyableTag.apply(this, arguments); + } -function DeferredActionQueues(queueNames, options) { - var queues = this.queues = {}; - this.queueNames = queueNames = queueNames || []; + CurrentTag.prototype.value = function value() { + return $REVISION; + }; - this.options = options; + return CurrentTag; + })(DirtyableTag))(); - each(queueNames, function(queueName) { - queues[queueName] = new Queue(queueName, options[queueName], options); - }); -} + var CachedReference = (function () { + function CachedReference() { + this.lastRevision = null; + this.lastValue = null; + } -function noSuchQueue(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist'); -} + CachedReference.prototype.value = function value() { + var tag = this.tag; + var lastRevision = this.lastRevision; + var lastValue = this.lastValue; -function noSuchMethod(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist'); -} + if (!lastRevision || !tag.validate(lastRevision)) { + lastValue = this.lastValue = this.compute(); + this.lastRevision = tag.value(); + } + return lastValue; + }; -DeferredActionQueues.prototype = { - schedule: function(name, target, method, args, onceFlag, stack) { - var queues = this.queues; - var queue = queues[name]; + CachedReference.prototype.invalidate = function invalidate() { + this.lastRevision = null; + }; - if (!queue) { - noSuchQueue(name); - } + return CachedReference; + })(); - if (!method) { - noSuchMethod(name); - } + var MapperReference = (function (_CachedReference) { + babelHelpers.inherits(MapperReference, _CachedReference); - if (onceFlag) { - return queue.pushUnique(target, method, args, stack); - } else { - return queue.push(target, method, args, stack); - } - }, + function MapperReference(reference, mapper) { + _CachedReference.call(this); + this.tag = reference.tag; + this.reference = reference; + this.mapper = mapper; + } - flush: function() { - var queues = this.queues; - var queueNames = this.queueNames; - var queueName, queue; - var queueNameIndex = 0; - var numberOfQueues = queueNames.length; + MapperReference.prototype.compute = function compute() { + var reference = this.reference; + var mapper = this.mapper; - while (queueNameIndex < numberOfQueues) { - queueName = queueNames[queueNameIndex]; - queue = queues[queueName]; + return mapper(reference.value()); + }; - var numberOfQueueItems = queue._queue.length; + return MapperReference; + })(CachedReference); - if (numberOfQueueItems === 0) { - queueNameIndex++; - } else { - queue.flush(false /* async */); - queueNameIndex = 0; - } + function map(reference, mapper) { + return new MapperReference(reference, mapper); } - } -}; - -function Backburner(queueNames, options) { - this.queueNames = queueNames; - this.options = options || {}; - if (!this.options.defaultQueue) { - this.options.defaultQueue = queueNames[0]; - } - this.instanceStack = []; - this._debouncees = []; - this._throttlers = []; - this._eventCallbacks = { - end: [], - begin: [] - }; - - var _this = this; - this._boundClearItems = function() { - clearItems(); - }; - - this._timerTimeoutId = undefined; - this._timers = []; + ////////// - this._platform = this.options._platform || { - setTimeout: function (fn, ms) { - return setTimeout(fn, ms); - }, - clearTimeout: function (id) { - clearTimeout(id); - } - }; + var ReferenceCache = (function () { + function ReferenceCache(reference) { + this.lastValue = null; + this.lastRevision = null; + this.initialized = false; + this.tag = reference.tag; + this.reference = reference; + } - this._boundRunExpiredTimers = function () { - _this._runExpiredTimers(); - }; -} + ReferenceCache.prototype.peek = function peek() { + if (!this.initialized) { + return this.initialize(); + } + return this.lastValue; + }; -Backburner.prototype = { - begin: function() { - var options = this.options; - var onBegin = options && options.onBegin; - var previousInstance = this.currentInstance; + ReferenceCache.prototype.revalidate = function revalidate() { + if (!this.initialized) { + return this.initialize(); + } + var reference = this.reference; + var lastRevision = this.lastRevision; - if (previousInstance) { - this.instanceStack.push(previousInstance); - } + var tag = reference.tag; + if (tag.validate(lastRevision)) return NOT_MODIFIED; + this.lastRevision = tag.value(); + var lastValue = this.lastValue; - this.currentInstance = new DeferredActionQueues(this.queueNames, options); - this._trigger('begin', this.currentInstance, previousInstance); - if (onBegin) { - onBegin(this.currentInstance, previousInstance); - } - }, + var value = reference.value(); + if (value === lastValue) return NOT_MODIFIED; + this.lastValue = value; + return value; + }; - end: function() { - var options = this.options; - var onEnd = options && options.onEnd; - var currentInstance = this.currentInstance; - var nextInstance = null; + ReferenceCache.prototype.initialize = function initialize() { + var reference = this.reference; - // Prevent double-finally bug in Safari 6.0.2 and iOS 6 - // This bug appears to be resolved in Safari 6.0.5 and iOS 7 - var finallyAlreadyCalled = false; - try { - currentInstance.flush(); - } finally { - if (!finallyAlreadyCalled) { - finallyAlreadyCalled = true; + var value = this.lastValue = reference.value(); + this.lastRevision = reference.tag.value(); + this.initialized = true; + return value; + }; - this.currentInstance = null; + return ReferenceCache; + })(); - if (this.instanceStack.length) { - nextInstance = this.instanceStack.pop(); - this.currentInstance = nextInstance; - } - this._trigger('end', currentInstance, nextInstance); - if (onEnd) { - onEnd(currentInstance, nextInstance); - } - } + var NOT_MODIFIED = "adb3b78e-3d22-4e4b-877a-6317c2c5c145"; + function isModified(value) { + return value !== NOT_MODIFIED; } - }, - /** - Trigger an event. Supports up to two arguments. Designed around - triggering transition events from one run loop instance to the - next, which requires an argument for the first instance and then - an argument for the next instance. + var ConstReference = (function () { + function ConstReference(inner) { + this.inner = inner; + this.tag = CONSTANT_TAG; + } - @private - @method _trigger - @param {String} eventName - @param {any} arg1 - @param {any} arg2 - */ - _trigger: function(eventName, arg1, arg2) { - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - for (var i = 0; i < callbacks.length; i++) { - callbacks[i](arg1, arg2); - } - } - }, + ConstReference.prototype.value = function value() { + return this.inner; + }; - on: function(eventName, callback) { - if (typeof callback !== 'function') { - throw new TypeError('Callback must be a function'); - } - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - callbacks.push(callback); - } else { - throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist'); - } - }, + return ConstReference; + })(); - off: function(eventName, callback) { - if (eventName) { - var callbacks = this._eventCallbacks[eventName]; - var callbackFound = false; - if (!callbacks) return; - if (callback) { - for (var i = 0; i < callbacks.length; i++) { - if (callbacks[i] === callback) { - callbackFound = true; - callbacks.splice(i, 1); - i--; - } - } - } - if (!callbackFound) { - throw new TypeError('Cannot off() callback that does not exist'); - } - } else { - throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist'); + function isConst(reference) { + return reference.tag === CONSTANT_TAG; } - }, - - run: function(/* target, method, args */) { - var length = arguments.length; - var method, target, args; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + var ListItem = (function (_ListNode) { + babelHelpers.inherits(ListItem, _ListNode); - if (isString(method)) { - method = target[method]; - } + function ListItem(iterable, result) { + _ListNode.call(this, iterable.valueReferenceFor(result)); + this.retained = false; + this.seen = false; + this.key = result.key; + this.iterable = iterable; + this.memo = iterable.memoReferenceFor(result); + } - if (length > 2) { - args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - } else { - args = []; - } + ListItem.prototype.update = function update(item) { + this.retained = true; + this.iterable.updateValueReference(this.value, item); + this.iterable.updateMemoReference(this.memo, item); + }; - var onError = getOnError(this.options); + ListItem.prototype.shouldRemove = function shouldRemove() { + return !this.retained; + }; - this.begin(); + ListItem.prototype.reset = function reset() { + this.retained = false; + this.seen = false; + }; - // guard against Safari 6's double-finally bug - var didFinally = false; + return ListItem; + })(_glimmerUtil.ListNode); - if (onError) { - try { - return method.apply(target, args); - } catch(error) { - onError(error); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); - } - } - } else { - try { - return method.apply(target, args); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); + var IterationArtifacts = (function () { + function IterationArtifacts(iterable) { + this.map = _glimmerUtil.dict(); + this.list = new _glimmerUtil.LinkedList(); + this.tag = iterable.tag; + this.iterable = iterable; } - } - } - }, - /* - Join the passed method with an existing queue and execute immediately, - if there isn't one use `Backburner#run`. + IterationArtifacts.prototype.isEmpty = function isEmpty() { + var iterator = this.iterator = this.iterable.iterate(); + return iterator.isEmpty(); + }; - The join method is like the run method except that it will schedule into - an existing queue if one already exists. In either case, the join method will - immediately execute the passed in function and return its result. + IterationArtifacts.prototype.iterate = function iterate() { + var iterator = this.iterator || this.iterable.iterate(); + this.iterator = null; + return iterator; + }; - @method join - @param {Object} target - @param {Function} method The method to be executed - @param {any} args The method arguments - @return method result - */ - join: function(/* target, method, args */) { - if (!this.currentInstance) { - return this.run.apply(this, arguments); - } + IterationArtifacts.prototype.has = function has(key) { + return !!this.map[key]; + }; - var length = arguments.length; - var method, target; + IterationArtifacts.prototype.get = function get(key) { + return this.map[key]; + }; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + IterationArtifacts.prototype.wasSeen = function wasSeen(key) { + var node = this.map[key]; + return node && node.seen; + }; - if (isString(method)) { - method = target[method]; - } + IterationArtifacts.prototype.append = function append(item) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - if (length === 1) { - return method(); - } else if (length === 2) { - return method.call(target); - } else { - var args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - return method.apply(target, args); - } - }, + var node = map[item.key] = new ListItem(iterable, item); + list.append(node); + return node; + }; + IterationArtifacts.prototype.insertBefore = function insertBefore(item, reference) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - /* - Defer the passed function to run inside the specified queue. + var node = map[item.key] = new ListItem(iterable, item); + node.retained = true; + list.insertBefore(node, reference); + return node; + }; - @method defer - @param {String} queueName - @param {Object} target - @param {Function|String} method The method or method name to be executed - @param {any} args The method arguments - @return method result - */ - defer: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + IterationArtifacts.prototype.move = function move(item, reference) { + var list = this.list; - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; - } + item.retained = true; + list.remove(item); + list.insertBefore(item, reference); + }; - if (isString(method)) { - method = target[method]; - } + IterationArtifacts.prototype.remove = function remove(item) { + var list = this.list; - var stack = this.DEBUG ? new Error() : undefined; + list.remove(item); + delete this.map[item.key]; + }; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + IterationArtifacts.prototype.nextNode = function nextNode(item) { + return this.list.nextNode(item); + }; - if (!this.currentInstance) { createAutorun(this); } - return this.currentInstance.schedule(queueName, target, method, args, false, stack); - }, + IterationArtifacts.prototype.head = function head() { + return this.list.head(); + }; - deferOnce: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + return IterationArtifacts; + })(); - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; - } + var ReferenceIterator = (function () { + // if anyone needs to construct this object with something other than + // an iterable, let @wycats know. - if (isString(method)) { - method = target[method]; - } + function ReferenceIterator(iterable) { + this.iterator = null; + var artifacts = new IterationArtifacts(iterable); + this.artifacts = artifacts; + } - var stack = this.DEBUG ? new Error() : undefined; + ReferenceIterator.prototype.next = function next() { + var artifacts = this.artifacts; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + var iterator = this.iterator = this.iterator || artifacts.iterate(); + var item = iterator.next(); + if (!item) return null; + return artifacts.append(item); + }; - if (!this.currentInstance) { - createAutorun(this); - } - return this.currentInstance.schedule(queueName, target, method, args, true, stack); - }, + return ReferenceIterator; + })(); - setTimeout: function() { - var l = arguments.length; - var args = new Array(l); + var Phase; + (function (Phase) { + Phase[Phase["Append"] = 0] = "Append"; + Phase[Phase["Prune"] = 1] = "Prune"; + Phase[Phase["Done"] = 2] = "Done"; + })(Phase || (Phase = {})); - for (var x = 0; x < l; x++) { - args[x] = arguments[x]; - } + var IteratorSynchronizer = (function () { + function IteratorSynchronizer(_ref) { + var target = _ref.target; + var artifacts = _ref.artifacts; - var length = args.length, - method, wait, target, - methodOrTarget, methodOrWait, methodOrArgs; + this.target = target; + this.artifacts = artifacts; + this.iterator = artifacts.iterate(); + this.current = artifacts.head(); + } - if (length === 0) { - return; - } else if (length === 1) { - method = args.shift(); - wait = 0; - } else if (length === 2) { - methodOrTarget = args[0]; - methodOrWait = args[1]; + IteratorSynchronizer.prototype.sync = function sync() { + var phase = Phase.Append; + while (true) { + switch (phase) { + case Phase.Append: + phase = this.nextAppend(); + break; + case Phase.Prune: + phase = this.nextPrune(); + break; + case Phase.Done: + this.nextDone(); + return; + } + } + }; - if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { - target = args.shift(); - method = args.shift(); - wait = 0; - } else if (isCoercableNumber(methodOrWait)) { - method = args.shift(); - wait = args.shift(); - } else { - method = args.shift(); - wait = 0; - } - } else { - var last = args[args.length - 1]; + IteratorSynchronizer.prototype.advanceToKey = function advanceToKey(key) { + var current = this.current; + var artifacts = this.artifacts; - if (isCoercableNumber(last)) { - wait = args.pop(); - } else { - wait = 0; - } + var seek = current; + while (seek && seek.key !== key) { + seek.seen = true; + seek = artifacts.nextNode(seek); + } + this.current = seek && artifacts.nextNode(seek); + }; - methodOrTarget = args[0]; - methodOrArgs = args[1]; + IteratorSynchronizer.prototype.nextAppend = function nextAppend() { + var iterator = this.iterator; + var current = this.current; + var artifacts = this.artifacts; - if (isFunction(methodOrArgs) || (isString(methodOrArgs) && - methodOrTarget !== null && - methodOrArgs in methodOrTarget)) { - target = args.shift(); - method = args.shift(); - } else { - method = args.shift(); - } - } - - var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); - - if (isString(method)) { - method = target[method]; - } - - var onError = getOnError(this.options); + var item = iterator.next(); + if (item === null) { + return this.startPrune(); + } + var key = item.key; - function fn() { - if (onError) { - try { - method.apply(target, args); - } catch (e) { - onError(e); - } - } else { - method.apply(target, args); - } - } + if (current && current.key === key) { + this.nextRetain(item); + } else if (artifacts.has(key)) { + this.nextMove(item); + } else { + this.nextInsert(item); + } + return Phase.Append; + }; - return this._setTimeout(fn, executeAt); - }, + IteratorSynchronizer.prototype.nextRetain = function nextRetain(item) { + var artifacts = this.artifacts; + var current = this.current; - _setTimeout: function (fn, executeAt) { - if (this._timers.length === 0) { - this._timers.push(executeAt, fn); - this._installTimerTimeout(); - return fn; - } + current = _glimmerUtil.expect(current, 'BUG: current is empty'); + current.update(item); + this.current = artifacts.nextNode(current); + this.target.retain(item.key, current.value, current.memo); + }; - // find position to insert - var i = binarySearch(executeAt, this._timers); + IteratorSynchronizer.prototype.nextMove = function nextMove(item) { + var current = this.current; + var artifacts = this.artifacts; + var target = this.target; + var key = item.key; - this._timers.splice(i, 0, executeAt, fn); + var found = artifacts.get(item.key); + found.update(item); + if (artifacts.wasSeen(item.key)) { + artifacts.move(found, current); + target.move(found.key, found.value, found.memo, current ? current.key : null); + } else { + this.advanceToKey(key); + } + }; - // we should be the new earliest timer if i == 0 - if (i === 0) { - this._reinstallTimerTimeout(); - } + IteratorSynchronizer.prototype.nextInsert = function nextInsert(item) { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - return fn; - }, + var node = artifacts.insertBefore(item, current); + target.insert(node.key, node.value, node.memo, current ? current.key : null); + }; - throttle: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } - var immediate = args.pop(); - var wait, throttler, index, timer; + IteratorSynchronizer.prototype.startPrune = function startPrune() { + this.current = this.artifacts.head(); + return Phase.Prune; + }; - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = true; - } else { - wait = args.pop(); - } + IteratorSynchronizer.prototype.nextPrune = function nextPrune() { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - wait = parseInt(wait, 10); + if (current === null) { + return Phase.Done; + } + var node = current; + this.current = artifacts.nextNode(node); + if (node.shouldRemove()) { + artifacts.remove(node); + target.delete(node.key); + } else { + node.reset(); + } + return Phase.Prune; + }; - index = findThrottler(target, method, this._throttlers); - if (index > -1) { return this._throttlers[index]; } // throttled + IteratorSynchronizer.prototype.nextDone = function nextDone() { + this.target.done(); + }; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findThrottler(target, method, backburner._throttlers); - if (index > -1) { - backburner._throttlers.splice(index, 1); - } - }, wait); + return IteratorSynchronizer; + })(); - if (immediate) { - this.run.apply(this, args); + function referenceFromParts(root, parts) { + var reference = root; + for (var i = 0; i < parts.length; i++) { + reference = reference.get(parts[i]); + } + return reference; } - throttler = [target, method, timer]; + exports.ConstReference = ConstReference; + exports.isConst = isConst; + exports.ListItem = ListItem; + exports.referenceFromParts = referenceFromParts; + exports.IterationArtifacts = IterationArtifacts; + exports.ReferenceIterator = ReferenceIterator; + exports.IteratorSynchronizer = IteratorSynchronizer; + exports.CONSTANT = CONSTANT; + exports.INITIAL = INITIAL; + exports.VOLATILE = VOLATILE; + exports.RevisionTag = RevisionTag; + exports.DirtyableTag = DirtyableTag; + exports.combineTagged = combineTagged; + exports.combineSlice = combineSlice; + exports.combine = combine; + exports.CachedTag = CachedTag; + exports.UpdatableTag = UpdatableTag; + exports.CONSTANT_TAG = CONSTANT_TAG; + exports.VOLATILE_TAG = VOLATILE_TAG; + exports.CURRENT_TAG = CURRENT_TAG; + exports.CachedReference = CachedReference; + exports.map = map; + exports.ReferenceCache = ReferenceCache; + exports.isModified = isModified; +}); +enifed('@glimmer/runtime',['exports','@glimmer/util','@glimmer/reference','@glimmer/wire-format'],function(exports,_glimmerUtil,_glimmerReference,_glimmerWireFormat){'use strict';var PrimitiveReference=(function(_ConstReference){babelHelpers.inherits(PrimitiveReference,_ConstReference);function PrimitiveReference(value){_ConstReference.call(this,value);}PrimitiveReference.create = function create(value){if(value === undefined){return UNDEFINED_REFERENCE;}else if(value === null){return NULL_REFERENCE;}else if(value === true){return TRUE_REFERENCE;}else if(value === false){return FALSE_REFERENCE;}else if(typeof value === 'number'){return new ValueReference(value);}else {return new StringReference(value);}};PrimitiveReference.prototype.get = function get(_key){return UNDEFINED_REFERENCE;};return PrimitiveReference;})(_glimmerReference.ConstReference);var StringReference=(function(_PrimitiveReference){babelHelpers.inherits(StringReference,_PrimitiveReference);function StringReference(){_PrimitiveReference.apply(this,arguments);this.lengthReference = null;}StringReference.prototype.get = function get(key){if(key === 'length'){var lengthReference=this.lengthReference;if(lengthReference === null){lengthReference = this.lengthReference = new ValueReference(this.inner.length);}return lengthReference;}else {return _PrimitiveReference.prototype.get.call(this,key);}};return StringReference;})(PrimitiveReference);var ValueReference=(function(_PrimitiveReference2){babelHelpers.inherits(ValueReference,_PrimitiveReference2);function ValueReference(value){_PrimitiveReference2.call(this,value);}return ValueReference;})(PrimitiveReference);var UNDEFINED_REFERENCE=new ValueReference(undefined);var NULL_REFERENCE=new ValueReference(null);var TRUE_REFERENCE=new ValueReference(true);var FALSE_REFERENCE=new ValueReference(false);var ConditionalReference=(function(){function ConditionalReference(inner){this.inner = inner;this.tag = inner.tag;}ConditionalReference.prototype.value = function value(){return this.toBool(this.inner.value());};ConditionalReference.prototype.toBool = function toBool(value){return !!value;};return ConditionalReference;})();var Constants=(function(){function Constants(){ // `0` means NULL +this.references = [];this.strings = [];this.expressions = [];this.arrays = [];this.slices = [];this.blocks = [];this.functions = [];this.others = [];this.NULL_REFERENCE = this.reference(NULL_REFERENCE);this.UNDEFINED_REFERENCE = this.reference(UNDEFINED_REFERENCE);}Constants.prototype.getReference = function getReference(value){return this.references[value - 1];};Constants.prototype.reference = function reference(value){var index=this.references.length;this.references.push(value);return index + 1;};Constants.prototype.getString = function getString(value){return this.strings[value - 1];};Constants.prototype.string = function string(value){var index=this.strings.length;this.strings.push(value);return index + 1;};Constants.prototype.getExpression = function getExpression(value){return this.expressions[value - 1];};Constants.prototype.expression = function expression(value){var index=this.expressions.length;this.expressions.push(value);return index + 1;};Constants.prototype.getArray = function getArray(value){return this.arrays[value - 1];};Constants.prototype.array = function array(values){var index=this.arrays.length;this.arrays.push(values);return index + 1;};Constants.prototype.getSlice = function getSlice(value){return this.slices[value - 1];};Constants.prototype.slice = function slice(_slice2){ // TODO: Put the entire program in one big array +var index=this.slices.length;this.slices.push(_slice2);return index + 1;};Constants.prototype.getBlock = function getBlock(value){return this.blocks[value - 1];};Constants.prototype.block = function block(_block2){var index=this.blocks.length;this.blocks.push(_block2);return index + 1;};Constants.prototype.getFunction = function getFunction(value){return this.functions[value - 1];};Constants.prototype.function = function _function(f){var index=this.functions.length;this.functions.push(f);return index + 1;};Constants.prototype.getOther = function getOther(value){return this.others[value - 1];};Constants.prototype.other = function other(_other){var index=this.others.length;this.others.push(_other);return index + 1;};return Constants;})();var AppendOpcodes=(function(){function AppendOpcodes(){this.evaluateOpcode = _glimmerUtil.fillNulls(51 /* EvaluatePartial */ + 1);}AppendOpcodes.prototype.add = function add(name,evaluate){this.evaluateOpcode[name] = evaluate;};AppendOpcodes.prototype.construct = function construct(name,_debug,op1,op2,op3){return [name | 0,(op1 || 0) | 0,(op2 || 0) | 0,(op3 || 0) | 0];};AppendOpcodes.prototype.evaluate = function evaluate(vm,opcode){_glimmerUtil.LOGGER.debug('[VM] OPCODE: ' + opcode.type);var func=this.evaluateOpcode[opcode.type];func(vm,opcode);};return AppendOpcodes;})();var APPEND_OPCODES=new AppendOpcodes();var AbstractOpcode=(function(){function AbstractOpcode(){_glimmerUtil.initializeGuid(this);}AbstractOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type};};return AbstractOpcode;})();var UpdatingOpcode=(function(_AbstractOpcode){babelHelpers.inherits(UpdatingOpcode,_AbstractOpcode);function UpdatingOpcode(){_AbstractOpcode.apply(this,arguments);this.next = null;this.prev = null;}return UpdatingOpcode;})(AbstractOpcode);APPEND_OPCODES.add(20, /* OpenBlock */function(vm,_ref){var _getBlock=_ref.op1;var _args=_ref.op2;var inner=vm.constants.getOther(_getBlock);var rawArgs=vm.constants.getExpression(_args);var args=null;var block=inner.evaluate(vm);if(block){args = rawArgs.evaluate(vm);} // FIXME: can we avoid doing this when we don't have a block? +vm.pushCallerScope();if(block){vm.invokeBlock(block,args || null);}});APPEND_OPCODES.add(21, /* CloseBlock */function(vm){return vm.popScope();});APPEND_OPCODES.add(0, /* PushChildScope */function(vm){return vm.pushChildScope();});APPEND_OPCODES.add(1, /* PopScope */function(vm){return vm.popScope();});APPEND_OPCODES.add(2, /* PushDynamicScope */function(vm){return vm.pushDynamicScope();});APPEND_OPCODES.add(3, /* PopDynamicScope */function(vm){return vm.popDynamicScope();});APPEND_OPCODES.add(4, /* Put */function(vm,_ref2){var reference=_ref2.op1;vm.frame.setOperand(vm.constants.getReference(reference));});APPEND_OPCODES.add(5, /* EvaluatePut */function(vm,_ref3){var expression=_ref3.op1;var expr=vm.constants.getExpression(expression);vm.evaluateOperand(expr);});APPEND_OPCODES.add(6, /* PutArgs */function(vm,_ref4){var args=_ref4.op1;vm.evaluateArgs(vm.constants.getExpression(args));});APPEND_OPCODES.add(7, /* BindPositionalArgs */function(vm,_ref5){var _symbols=_ref5.op1;var symbols=vm.constants.getArray(_symbols);vm.bindPositionalArgs(symbols);});APPEND_OPCODES.add(8, /* BindNamedArgs */function(vm,_ref6){var _names=_ref6.op1;var _symbols=_ref6.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindNamedArgs(names,symbols);});APPEND_OPCODES.add(9, /* BindBlocks */function(vm,_ref7){var _names=_ref7.op1;var _symbols=_ref7.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindBlocks(names,symbols);});APPEND_OPCODES.add(10, /* BindPartialArgs */function(vm,_ref8){var symbol=_ref8.op1;vm.bindPartialArgs(symbol);});APPEND_OPCODES.add(11, /* BindCallerScope */function(vm){return vm.bindCallerScope();});APPEND_OPCODES.add(12, /* BindDynamicScope */function(vm,_ref9){var _names=_ref9.op1;var names=vm.constants.getArray(_names);vm.bindDynamicScope(names);});APPEND_OPCODES.add(13, /* Enter */function(vm,_ref10){var slice=_ref10.op1;return vm.enter(slice);});APPEND_OPCODES.add(14, /* Exit */function(vm){return vm.exit();});APPEND_OPCODES.add(15, /* Evaluate */function(vm,_ref11){var _block=_ref11.op1;var block=vm.constants.getBlock(_block);var args=vm.frame.getArgs();vm.invokeBlock(block,args);});APPEND_OPCODES.add(16, /* Jump */function(vm,_ref12){var target=_ref12.op1;return vm.goto(target);});APPEND_OPCODES.add(17, /* JumpIf */function(vm,_ref13){var target=_ref13.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(18, /* JumpUnless */function(vm,_ref14){var target=_ref14.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(!reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(!cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});var ConstTest=function(ref,_env){return new _glimmerReference.ConstReference(!!ref.value());};var SimpleTest=function(ref,_env){return ref;};var EnvironmentTest=function(ref,env){return env.toConditionalReference(ref);};APPEND_OPCODES.add(19, /* Test */function(vm,_ref15){var _func=_ref15.op1;var operand=vm.frame.getOperand();var func=vm.constants.getFunction(_func);vm.frame.setCondition(func(operand,vm.env));});var Assert=(function(_UpdatingOpcode){babelHelpers.inherits(Assert,_UpdatingOpcode);function Assert(cache){_UpdatingOpcode.call(this);this.type = "assert";this.tag = cache.tag;this.cache = cache;}Assert.prototype.evaluate = function evaluate(vm){var cache=this.cache;if(_glimmerReference.isModified(cache.revalidate())){vm.throw();}};Assert.prototype.toJSON = function toJSON(){var type=this.type;var _guid=this._guid;var cache=this.cache;var expected=undefined;try{expected = JSON.stringify(cache.peek());}catch(e) {expected = String(cache.peek());}return {guid:_guid,type:type,args:[],details:{expected:expected}};};return Assert;})(UpdatingOpcode);var JumpIfNotModifiedOpcode=(function(_UpdatingOpcode2){babelHelpers.inherits(JumpIfNotModifiedOpcode,_UpdatingOpcode2);function JumpIfNotModifiedOpcode(tag,target){_UpdatingOpcode2.call(this);this.target = target;this.type = "jump-if-not-modified";this.tag = tag;this.lastRevision = tag.value();}JumpIfNotModifiedOpcode.prototype.evaluate = function evaluate(vm){var tag=this.tag;var target=this.target;var lastRevision=this.lastRevision;if(!vm.alwaysRevalidate && tag.validate(lastRevision)){vm.goto(target);}};JumpIfNotModifiedOpcode.prototype.didModify = function didModify(){this.lastRevision = this.tag.value();};JumpIfNotModifiedOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.target.inspect())]};};return JumpIfNotModifiedOpcode;})(UpdatingOpcode);var DidModifyOpcode=(function(_UpdatingOpcode3){babelHelpers.inherits(DidModifyOpcode,_UpdatingOpcode3);function DidModifyOpcode(target){_UpdatingOpcode3.call(this);this.target = target;this.type = "did-modify";this.tag = _glimmerReference.CONSTANT_TAG;}DidModifyOpcode.prototype.evaluate = function evaluate(){this.target.didModify();};return DidModifyOpcode;})(UpdatingOpcode);var LabelOpcode=(function(){function LabelOpcode(label){this.tag = _glimmerReference.CONSTANT_TAG;this.type = "label";this.label = null;this.prev = null;this.next = null;_glimmerUtil.initializeGuid(this);if(label)this.label = label;}LabelOpcode.prototype.evaluate = function evaluate(){};LabelOpcode.prototype.inspect = function inspect(){return this.label + ' [' + this._guid + ']';};LabelOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.inspect())]};};return LabelOpcode;})();var EMPTY_ARRAY=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze([]):[];var EMPTY_DICT=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze(_glimmerUtil.dict()):_glimmerUtil.dict();var CompiledPositionalArgs=(function(){function CompiledPositionalArgs(values){this.values = values;this.length = values.length;}CompiledPositionalArgs.create = function create(values){if(values.length){return new this(values);}else {return COMPILED_EMPTY_POSITIONAL_ARGS;}};CompiledPositionalArgs.empty = function empty(){return COMPILED_EMPTY_POSITIONAL_ARGS;};CompiledPositionalArgs.prototype.evaluate = function evaluate(vm){var values=this.values;var length=this.length;var references=new Array(length);for(var i=0;i < length;i++) {references[i] = values[i].evaluate(vm);}return EvaluatedPositionalArgs.create(references);};CompiledPositionalArgs.prototype.toJSON = function toJSON(){return '[' + this.values.map(function(value){return value.toJSON();}).join(", ") + ']';};return CompiledPositionalArgs;})();var COMPILED_EMPTY_POSITIONAL_ARGS=new ((function(_CompiledPositionalArgs){babelHelpers.inherits(_class,_CompiledPositionalArgs);function _class(){_CompiledPositionalArgs.call(this,EMPTY_ARRAY);}_class.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_POSITIONAL_ARGS;};_class.prototype.toJSON = function toJSON(){return '';};return _class;})(CompiledPositionalArgs))();var EvaluatedPositionalArgs=(function(){function EvaluatedPositionalArgs(values){this.values = values;this.tag = _glimmerReference.combineTagged(values);this.length = values.length;}EvaluatedPositionalArgs.create = function create(values){return new this(values);};EvaluatedPositionalArgs.empty = function empty(){return EVALUATED_EMPTY_POSITIONAL_ARGS;};EvaluatedPositionalArgs.prototype.at = function at(index){var values=this.values;var length=this.length;return index < length?values[index]:UNDEFINED_REFERENCE;};EvaluatedPositionalArgs.prototype.value = function value(){var values=this.values;var length=this.length;var ret=new Array(length);for(var i=0;i < length;i++) {ret[i] = values[i].value();}return ret;};return EvaluatedPositionalArgs;})();var EVALUATED_EMPTY_POSITIONAL_ARGS=new ((function(_EvaluatedPositionalArgs){babelHelpers.inherits(_class2,_EvaluatedPositionalArgs);function _class2(){_EvaluatedPositionalArgs.call(this,EMPTY_ARRAY);}_class2.prototype.at = function at(){return UNDEFINED_REFERENCE;};_class2.prototype.value = function value(){return this.values;};return _class2;})(EvaluatedPositionalArgs))();var CompiledNamedArgs=(function(){function CompiledNamedArgs(keys,values){this.keys = keys;this.values = values;this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}CompiledNamedArgs.empty = function empty(){return COMPILED_EMPTY_NAMED_ARGS;};CompiledNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=[];for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values);}else {return COMPILED_EMPTY_NAMED_ARGS;}};CompiledNamedArgs.prototype.evaluate = function evaluate(vm){var keys=this.keys;var values=this.values;var length=this.length;var evaluated=new Array(length);for(var i=0;i < length;i++) {evaluated[i] = values[i].evaluate(vm);}return new EvaluatedNamedArgs(keys,evaluated);};CompiledNamedArgs.prototype.toJSON = function toJSON(){var keys=this.keys;var values=this.values;var inner=keys.map(function(key,i){return key + ': ' + values[i].toJSON();}).join(", ");return '{' + inner + '}';};return CompiledNamedArgs;})();var COMPILED_EMPTY_NAMED_ARGS=new ((function(_CompiledNamedArgs){babelHelpers.inherits(_class3,_CompiledNamedArgs);function _class3(){_CompiledNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY);}_class3.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_NAMED_ARGS;};_class3.prototype.toJSON = function toJSON(){return '';};return _class3;})(CompiledNamedArgs))();var EvaluatedNamedArgs=(function(){function EvaluatedNamedArgs(keys,values){var _map=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];this.keys = keys;this.values = values;this._map = _map;this.tag = _glimmerReference.combineTagged(values);this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}EvaluatedNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=new Array(length);for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values,map);}else {return EVALUATED_EMPTY_NAMED_ARGS;}};EvaluatedNamedArgs.empty = function empty(){return EVALUATED_EMPTY_NAMED_ARGS;};EvaluatedNamedArgs.prototype.get = function get(key){var keys=this.keys;var values=this.values;var index=keys.indexOf(key);return index === -1?UNDEFINED_REFERENCE:values[index];};EvaluatedNamedArgs.prototype.has = function has(key){return this.keys.indexOf(key) !== -1;};EvaluatedNamedArgs.prototype.value = function value(){var keys=this.keys;var values=this.values;var out=_glimmerUtil.dict();for(var i=0;i < keys.length;i++) {var key=keys[i];var ref=values[i];out[key] = ref.value();}return out;};babelHelpers.createClass(EvaluatedNamedArgs,[{key:'map',get:function(){var map=this._map;if(map){return map;}map = this._map = _glimmerUtil.dict();var keys=this.keys;var values=this.values;var length=this.length;for(var i=0;i < length;i++) {map[keys[i]] = values[i];}return map;}}]);return EvaluatedNamedArgs;})();var EVALUATED_EMPTY_NAMED_ARGS=new ((function(_EvaluatedNamedArgs){babelHelpers.inherits(_class4,_EvaluatedNamedArgs);function _class4(){_EvaluatedNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY,EMPTY_DICT);}_class4.prototype.get = function get(){return UNDEFINED_REFERENCE;};_class4.prototype.has = function has(_key){return false;};_class4.prototype.value = function value(){return EMPTY_DICT;};return _class4;})(EvaluatedNamedArgs))();var EMPTY_BLOCKS={default:null,inverse:null};var CompiledArgs=(function(){function CompiledArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.type = "compiled-args";}CompiledArgs.create = function create(positional,named,blocks){if(positional === COMPILED_EMPTY_POSITIONAL_ARGS && named === COMPILED_EMPTY_NAMED_ARGS && blocks === EMPTY_BLOCKS){return this.empty();}else {return new this(positional,named,blocks);}};CompiledArgs.empty = function empty(){return COMPILED_EMPTY_ARGS;};CompiledArgs.prototype.evaluate = function evaluate(vm){var positional=this.positional;var named=this.named;var blocks=this.blocks;return EvaluatedArgs.create(positional.evaluate(vm),named.evaluate(vm),blocks);};return CompiledArgs;})();var COMPILED_EMPTY_ARGS=new ((function(_CompiledArgs){babelHelpers.inherits(_class5,_CompiledArgs);function _class5(){_CompiledArgs.call(this,COMPILED_EMPTY_POSITIONAL_ARGS,COMPILED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);}_class5.prototype.evaluate = function evaluate(_vm){return EMPTY_EVALUATED_ARGS;};return _class5;})(CompiledArgs))();var EvaluatedArgs=(function(){function EvaluatedArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.tag = _glimmerReference.combineTagged([positional,named]);}EvaluatedArgs.empty = function empty(){return EMPTY_EVALUATED_ARGS;};EvaluatedArgs.create = function create(positional,named,blocks){return new this(positional,named,blocks);};EvaluatedArgs.positional = function positional(values){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EvaluatedPositionalArgs.create(values),EVALUATED_EMPTY_NAMED_ARGS,blocks);};EvaluatedArgs.named = function named(map){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EVALUATED_EMPTY_POSITIONAL_ARGS,EvaluatedNamedArgs.create(map),blocks);};return EvaluatedArgs;})();var EMPTY_EVALUATED_ARGS=new EvaluatedArgs(EVALUATED_EMPTY_POSITIONAL_ARGS,EVALUATED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);APPEND_OPCODES.add(22, /* PutDynamicComponent */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(23, /* PutComponent */function(vm,_ref16){var _component=_ref16.op1;var definition=vm.constants.getOther(_component);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(24, /* OpenComponent */function(vm,_ref17){var _args=_ref17.op1;var _shadow=_ref17.op2;var rawArgs=vm.constants.getExpression(_args);var shadow=vm.constants.getBlock(_shadow);var definition=vm.frame.getImmediate();var dynamicScope=vm.pushDynamicScope();var callerScope=vm.scope();var manager=definition.manager;var args=manager.prepareArgs(definition,rawArgs.evaluate(vm),dynamicScope);var hasDefaultBlock=!!args.blocks.default; // TODO Cleanup? +var component=manager.create(vm.env,definition,args,dynamicScope,vm.getSelf(),hasDefaultBlock);var destructor=manager.getDestructor(component);if(destructor)vm.newDestroyable(destructor);var layout=manager.layoutFor(definition,component,vm.env);var selfRef=manager.getSelf(component);vm.beginCacheGroup();vm.stack().pushSimpleBlock();vm.pushRootScope(selfRef,layout.symbols);vm.invokeLayout(args,layout,callerScope,component,manager,shadow);vm.updateWith(new UpdateComponentOpcode(definition.name,component,manager,args,dynamicScope));}); // export class DidCreateElementOpcode extends Opcode { +// public type = "did-create-element"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let action = 'DidCreateElementOpcode#evaluate'; +// manager.didCreateElement(component, vm.stack().expectConstructing(action), vm.stack().expectOperations(action)); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +APPEND_OPCODES.add(25, /* DidCreateElement */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var action='DidCreateElementOpcode#evaluate';manager.didCreateElement(component,vm.stack().expectConstructing(action),vm.stack().expectOperations(action));}); // export class ShadowAttributesOpcode extends Opcode { +// public type = "shadow-attributes"; +// evaluate(vm: VM) { +// let shadow = vm.frame.getShadow(); +// vm.pushCallerScope(); +// if (!shadow) return; +// vm.invokeBlock(shadow, EvaluatedArgs.empty()); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +// Slow path for non-specialized component invocations. Uses an internal +// named lookup on the args. +APPEND_OPCODES.add(26, /* ShadowAttributes */function(vm){var shadow=vm.frame.getShadow();vm.pushCallerScope();if(!shadow)return;vm.invokeBlock(shadow,EvaluatedArgs.empty());}); // export class DidRenderLayoutOpcode extends Opcode { +// public type = "did-render-layout"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let bounds = vm.stack().popBlock(); +// manager.didRenderLayout(component, bounds); +// vm.env.didCreate(component, manager); +// vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); +// } +// } +APPEND_OPCODES.add(27, /* DidRenderLayout */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var bounds=vm.stack().popBlock();manager.didRenderLayout(component,bounds);vm.env.didCreate(component,manager);vm.updateWith(new DidUpdateLayoutOpcode(manager,component,bounds));}); // export class CloseComponentOpcode extends Opcode { +// public type = "close-component"; +// evaluate(vm: VM) { +// vm.popScope(); +// vm.popDynamicScope(); +// vm.commitCacheGroup(); +// } +// } +APPEND_OPCODES.add(28, /* CloseComponent */function(vm){vm.popScope();vm.popDynamicScope();vm.commitCacheGroup();});var UpdateComponentOpcode=(function(_UpdatingOpcode4){babelHelpers.inherits(UpdateComponentOpcode,_UpdatingOpcode4);function UpdateComponentOpcode(name,component,manager,args,dynamicScope){_UpdatingOpcode4.call(this);this.name = name;this.component = component;this.manager = manager;this.args = args;this.dynamicScope = dynamicScope;this.type = "update-component";var componentTag=manager.getTag(component);if(componentTag){this.tag = _glimmerReference.combine([args.tag,componentTag]);}else {this.tag = args.tag;}}UpdateComponentOpcode.prototype.evaluate = function evaluate(_vm){var component=this.component;var manager=this.manager;var args=this.args;var dynamicScope=this.dynamicScope;manager.update(component,args,dynamicScope);};UpdateComponentOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.name)]};};return UpdateComponentOpcode;})(UpdatingOpcode);var DidUpdateLayoutOpcode=(function(_UpdatingOpcode5){babelHelpers.inherits(DidUpdateLayoutOpcode,_UpdatingOpcode5);function DidUpdateLayoutOpcode(manager,component,bounds){_UpdatingOpcode5.call(this);this.manager = manager;this.component = component;this.bounds = bounds;this.type = "did-update-layout";this.tag = _glimmerReference.CONSTANT_TAG;}DidUpdateLayoutOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var component=this.component;var bounds=this.bounds;manager.didUpdateLayout(component,bounds);vm.env.didUpdate(component,manager);};return DidUpdateLayoutOpcode;})(UpdatingOpcode);var Cursor=function Cursor(element,nextSibling){this.element = element;this.nextSibling = nextSibling;};var ConcreteBounds=(function(){function ConcreteBounds(parentNode,first,last){this.parentNode = parentNode;this.first = first;this.last = last;}ConcreteBounds.prototype.parentElement = function parentElement(){return this.parentNode;};ConcreteBounds.prototype.firstNode = function firstNode(){return this.first;};ConcreteBounds.prototype.lastNode = function lastNode(){return this.last;};return ConcreteBounds;})();var SingleNodeBounds=(function(){function SingleNodeBounds(parentNode,node){this.parentNode = parentNode;this.node = node;}SingleNodeBounds.prototype.parentElement = function parentElement(){return this.parentNode;};SingleNodeBounds.prototype.firstNode = function firstNode(){return this.node;};SingleNodeBounds.prototype.lastNode = function lastNode(){return this.node;};return SingleNodeBounds;})();function single(parent,node){return new SingleNodeBounds(parent,node);}function moveBounds(bounds,reference){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.insertBefore(node,reference);if(node === last)return next;node = next;}return null;}function clear(bounds){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.removeChild(node);if(node === last)return next;node = next;}return null;}function isSafeString(value){return !!value && typeof value['toHTML'] === 'function';}function isNode(value){return value !== null && typeof value === 'object' && typeof value['nodeType'] === 'number';}function isString(value){return typeof value === 'string';}var Upsert=function Upsert(bounds){this.bounds = bounds;};function cautiousInsert(dom,cursor,value){if(isString(value)){return TextUpsert.insert(dom,cursor,value);}if(isSafeString(value)){return SafeStringUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}function trustingInsert(dom,cursor,value){if(isString(value)){return HTMLUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}var TextUpsert=(function(_Upsert){babelHelpers.inherits(TextUpsert,_Upsert);TextUpsert.insert = function insert(dom,cursor,value){var textNode=dom.createTextNode(value);dom.insertBefore(cursor.element,textNode,cursor.nextSibling);var bounds=new SingleNodeBounds(cursor.element,textNode);return new TextUpsert(bounds,textNode);};function TextUpsert(bounds,textNode){_Upsert.call(this,bounds);this.textNode = textNode;}TextUpsert.prototype.update = function update(_dom,value){if(isString(value)){var textNode=this.textNode;textNode.nodeValue = value;return true;}else {return false;}};return TextUpsert;})(Upsert);var HTMLUpsert=(function(_Upsert2){babelHelpers.inherits(HTMLUpsert,_Upsert2);function HTMLUpsert(){_Upsert2.apply(this,arguments);}HTMLUpsert.insert = function insert(dom,cursor,value){var bounds=dom.insertHTMLBefore(cursor.element,value,cursor.nextSibling);return new HTMLUpsert(bounds);};HTMLUpsert.prototype.update = function update(dom,value){if(isString(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,value);return true;}else {return false;}};return HTMLUpsert;})(Upsert);var SafeStringUpsert=(function(_Upsert3){babelHelpers.inherits(SafeStringUpsert,_Upsert3);function SafeStringUpsert(bounds,lastStringValue){_Upsert3.call(this,bounds);this.lastStringValue = lastStringValue;}SafeStringUpsert.insert = function insert(dom,cursor,value){var stringValue=value.toHTML();var bounds=dom.insertHTMLBefore(cursor.element,stringValue,cursor.nextSibling);return new SafeStringUpsert(bounds,stringValue);};SafeStringUpsert.prototype.update = function update(dom,value){if(isSafeString(value)){var stringValue=value.toHTML();if(stringValue !== this.lastStringValue){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,stringValue);this.lastStringValue = stringValue;}return true;}else {return false;}};return SafeStringUpsert;})(Upsert);var NodeUpsert=(function(_Upsert4){babelHelpers.inherits(NodeUpsert,_Upsert4);function NodeUpsert(){_Upsert4.apply(this,arguments);}NodeUpsert.insert = function insert(dom,cursor,node){dom.insertBefore(cursor.element,node,cursor.nextSibling);return new NodeUpsert(single(cursor.element,node));};NodeUpsert.prototype.update = function update(dom,value){if(isNode(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertNodeBefore(parentElement,value,nextSibling);return true;}else {return false;}};return NodeUpsert;})(Upsert);var COMPONENT_DEFINITION_BRAND='COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]';function isComponentDefinition(obj){return typeof obj === 'object' && obj && obj[COMPONENT_DEFINITION_BRAND];}var ComponentDefinition=function ComponentDefinition(name,manager,ComponentClass){this[COMPONENT_DEFINITION_BRAND] = true;this.name = name;this.manager = manager;this.ComponentClass = ComponentClass;};var CompiledExpression=(function(){function CompiledExpression(){}CompiledExpression.prototype.toJSON = function toJSON(){return 'UNIMPL: ' + this.type.toUpperCase();};return CompiledExpression;})();APPEND_OPCODES.add(29, /* Text */function(vm,_ref18){var text=_ref18.op1;vm.stack().appendText(vm.constants.getString(text));});APPEND_OPCODES.add(30, /* Comment */function(vm,_ref19){var text=_ref19.op1;vm.stack().appendComment(vm.constants.getString(text));});APPEND_OPCODES.add(32, /* OpenElement */function(vm,_ref20){var tag=_ref20.op1;vm.stack().openElement(vm.constants.getString(tag));});APPEND_OPCODES.add(33, /* PushRemoteElement */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var element=cache?cache.peek():reference.value();vm.stack().pushRemoteElement(element);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(34, /* PopRemoteElement */function(vm){return vm.stack().popRemoteElement();});APPEND_OPCODES.add(35, /* OpenComponentElement */function(vm,_ref21){var _tag=_ref21.op1;var tag=vm.constants.getString(_tag);vm.stack().openElement(tag,new ComponentElementOperations(vm.env));});APPEND_OPCODES.add(36, /* OpenDynamicElement */function(vm){var tagName=vm.frame.getOperand().value();vm.stack().openElement(tagName);});var ClassList=(function(){function ClassList(){this.list = null;this.isConst = true;}ClassList.prototype.append = function append(reference){var list=this.list;var isConst$$=this.isConst;if(list === null)list = this.list = [];list.push(reference);this.isConst = isConst$$ && _glimmerReference.isConst(reference);};ClassList.prototype.toReference = function toReference(){var list=this.list;var isConst$$=this.isConst;if(!list)return NULL_REFERENCE;if(isConst$$)return PrimitiveReference.create(toClassName(list));return new ClassListReference(list);};return ClassList;})();var ClassListReference=(function(_CachedReference){babelHelpers.inherits(ClassListReference,_CachedReference);function ClassListReference(list){_CachedReference.call(this);this.list = [];this.tag = _glimmerReference.combineTagged(list);this.list = list;}ClassListReference.prototype.compute = function compute(){return toClassName(this.list);};return ClassListReference;})(_glimmerReference.CachedReference);function toClassName(list){var ret=[];for(var i=0;i < list.length;i++) {var value=list[i].value();if(value !== false && value !== null && value !== undefined)ret.push(value);}return ret.length === 0?null:ret.join(' ');}var SimpleElementOperations=(function(){function SimpleElementOperations(env){this.env = env;this.opcodes = null;this.classList = null;}SimpleElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else {this.env.getAppendOperations().setAttribute(element,name,value);}};SimpleElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){this.env.getAppendOperations().setAttribute(element,name,value,namespace);};SimpleElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else {var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(attribute);}};SimpleElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(nsAttribute);};SimpleElementOperations.prototype.flush = function flush(element,vm){var env=vm.env;var opcodes=this.opcodes;var classList=this.classList;for(var i=0;opcodes && i < opcodes.length;i++) {vm.updateWith(opcodes[i]);}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}this.opcodes = null;this.classList = null;};SimpleElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};SimpleElementOperations.prototype.addAttribute = function addAttribute(attribute){var opcode=attribute.flush(this.env);if(opcode){var opcodes=this.opcodes;if(!opcodes){opcodes = this.opcodes = [];}opcodes.push(opcode);}};return SimpleElementOperations;})();var ComponentElementOperations=(function(){function ComponentElementOperations(env){this.env = env;this.attributeNames = null;this.attributes = null;this.classList = null;}ComponentElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value));}};ComponentElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value,namespace));}};ComponentElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(name,attribute);}};ComponentElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(name,nsAttribute);}};ComponentElementOperations.prototype.flush = function flush(element,vm){var env=this.env;var attributes=this.attributes;var classList=this.classList;for(var i=0;attributes && i < attributes.length;i++) {var opcode=attributes[i].flush(env);if(opcode){vm.updateWith(opcode);}}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}};ComponentElementOperations.prototype.shouldAddAttribute = function shouldAddAttribute(name){return !this.attributeNames || this.attributeNames.indexOf(name) === -1;};ComponentElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};ComponentElementOperations.prototype.addAttribute = function addAttribute(name,attribute){var attributeNames=this.attributeNames;var attributes=this.attributes;if(!attributeNames){attributeNames = this.attributeNames = [];attributes = this.attributes = [];}attributeNames.push(name);_glimmerUtil.unwrap(attributes).push(attribute);};return ComponentElementOperations;})();APPEND_OPCODES.add(37, /* FlushElement */function(vm){var stack=vm.stack();var action='FlushElementOpcode#evaluate';stack.expectOperations(action).flush(stack.expectConstructing(action),vm);stack.flushElement();});APPEND_OPCODES.add(38, /* CloseElement */function(vm){return vm.stack().closeElement();});APPEND_OPCODES.add(39, /* PopElement */function(vm){return vm.stack().popElement();});APPEND_OPCODES.add(40, /* StaticAttr */function(vm,_ref22){var _name=_ref22.op1;var _value=_ref22.op2;var _namespace=_ref22.op3;var name=vm.constants.getString(_name);var value=vm.constants.getString(_value);if(_namespace){var namespace=vm.constants.getString(_namespace);vm.stack().setStaticAttributeNS(namespace,name,value);}else {vm.stack().setStaticAttribute(name,value);}});APPEND_OPCODES.add(41, /* Modifier */function(vm,_ref23){var _name=_ref23.op1;var _manager=_ref23.op2;var _args=_ref23.op3;var manager=vm.constants.getOther(_manager);var rawArgs=vm.constants.getExpression(_args);var stack=vm.stack();var element=stack.constructing;var updateOperations=stack.updateOperations;var args=rawArgs.evaluate(vm);var dynamicScope=vm.dynamicScope();var modifier=manager.create(element,args,dynamicScope,updateOperations);vm.env.scheduleInstallModifier(modifier,manager);var destructor=manager.getDestructor(modifier);if(destructor){vm.newDestroyable(destructor);}vm.updateWith(new UpdateModifierOpcode(manager,modifier,args));});var UpdateModifierOpcode=(function(_UpdatingOpcode6){babelHelpers.inherits(UpdateModifierOpcode,_UpdatingOpcode6);function UpdateModifierOpcode(manager,modifier,args){_UpdatingOpcode6.call(this);this.manager = manager;this.modifier = modifier;this.args = args;this.type = "update-modifier";this.tag = args.tag;this.lastUpdated = args.tag.value();}UpdateModifierOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var modifier=this.modifier;var tag=this.tag;var lastUpdated=this.lastUpdated;if(!tag.validate(lastUpdated)){vm.env.scheduleUpdateModifier(modifier,manager);this.lastUpdated = tag.value();}};UpdateModifierOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.args)]};};return UpdateModifierOpcode;})(UpdatingOpcode);var StaticAttribute=(function(){function StaticAttribute(element,name,value,namespace){this.element = element;this.name = name;this.value = value;this.namespace = namespace;}StaticAttribute.prototype.flush = function flush(env){env.getAppendOperations().setAttribute(this.element,this.name,this.value,this.namespace);return null;};return StaticAttribute;})();var DynamicAttribute=(function(){function DynamicAttribute(element,attributeManager,name,reference,namespace){this.element = element;this.attributeManager = attributeManager;this.name = name;this.reference = reference;this.namespace = namespace;this.cache = null;this.tag = reference.tag;}DynamicAttribute.prototype.patch = function patch(env){var element=this.element;var cache=this.cache;var value=_glimmerUtil.expect(cache,'must patch after flush').revalidate();if(_glimmerReference.isModified(value)){this.attributeManager.updateAttribute(env,element,value,this.namespace);}};DynamicAttribute.prototype.flush = function flush(env){var reference=this.reference;var element=this.element;if(_glimmerReference.isConst(reference)){var value=reference.value();this.attributeManager.setAttribute(env,element,value,this.namespace);return null;}else {var cache=this.cache = new _glimmerReference.ReferenceCache(reference);var value=cache.peek();this.attributeManager.setAttribute(env,element,value,this.namespace);return new PatchElementOpcode(this);}};DynamicAttribute.prototype.toJSON = function toJSON(){var element=this.element;var namespace=this.namespace;var name=this.name;var cache=this.cache;var formattedElement=formatElement(element);var lastValue=_glimmerUtil.expect(cache,'must serialize after flush').peek();if(namespace){return {element:formattedElement,type:'attribute',namespace:namespace,name:name,lastValue:lastValue};}return {element:formattedElement,type:'attribute',namespace:namespace === undefined?null:namespace,name:name,lastValue:lastValue};};return DynamicAttribute;})();function formatElement(element){return JSON.stringify('<' + element.tagName.toLowerCase() + ' />');}APPEND_OPCODES.add(42, /* DynamicAttrNS */function(vm,_ref24){var _name=_ref24.op1;var _namespace=_ref24.op2;var trusting=_ref24.op3;var name=vm.constants.getString(_name);var namespace=vm.constants.getString(_namespace);var reference=vm.frame.getOperand();vm.stack().setDynamicAttributeNS(namespace,name,reference,!!trusting);});APPEND_OPCODES.add(43, /* DynamicAttr */function(vm,_ref25){var _name=_ref25.op1;var trusting=_ref25.op2;var name=vm.constants.getString(_name);var reference=vm.frame.getOperand();vm.stack().setDynamicAttribute(name,reference,!!trusting);});var PatchElementOpcode=(function(_UpdatingOpcode7){babelHelpers.inherits(PatchElementOpcode,_UpdatingOpcode7);function PatchElementOpcode(operation){_UpdatingOpcode7.call(this);this.type = "patch-element";this.tag = operation.tag;this.operation = operation;}PatchElementOpcode.prototype.evaluate = function evaluate(vm){this.operation.patch(vm.env);};PatchElementOpcode.prototype.toJSON = function toJSON(){var _guid=this._guid;var type=this.type;var operation=this.operation;return {guid:_guid,type:type,details:operation.toJSON()};};return PatchElementOpcode;})(UpdatingOpcode);var First=(function(){function First(node){this.node = node;}First.prototype.firstNode = function firstNode(){return this.node;};return First;})();var Last=(function(){function Last(node){this.node = node;}Last.prototype.lastNode = function lastNode(){return this.node;};return Last;})();var Fragment=(function(){function Fragment(bounds){this.bounds = bounds;}Fragment.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};Fragment.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};Fragment.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};Fragment.prototype.update = function update(bounds){this.bounds = bounds;};return Fragment;})();var ElementStack=(function(){function ElementStack(env,parentNode,nextSibling){this.constructing = null;this.operations = null;this.elementStack = new _glimmerUtil.Stack();this.nextSiblingStack = new _glimmerUtil.Stack();this.blockStack = new _glimmerUtil.Stack();this.env = env;this.dom = env.getAppendOperations();this.updateOperations = env.getDOM();this.element = parentNode;this.nextSibling = nextSibling;this.defaultOperations = new SimpleElementOperations(env);this.elementStack.push(this.element);this.nextSiblingStack.push(this.nextSibling);}ElementStack.forInitialRender = function forInitialRender(env,parentNode,nextSibling){return new ElementStack(env,parentNode,nextSibling);};ElementStack.resume = function resume(env,tracker,nextSibling){var parentNode=tracker.parentElement();var stack=new ElementStack(env,parentNode,nextSibling);stack.pushBlockTracker(tracker);return stack;};ElementStack.prototype.expectConstructing = function expectConstructing(method){return _glimmerUtil.expect(this.constructing,method + ' should only be called while constructing an element');};ElementStack.prototype.expectOperations = function expectOperations(method){return _glimmerUtil.expect(this.operations,method + ' should only be called while constructing an element');};ElementStack.prototype.block = function block(){return _glimmerUtil.expect(this.blockStack.current,"Expected a current block tracker");};ElementStack.prototype.popElement = function popElement(){var elementStack=this.elementStack;var nextSiblingStack=this.nextSiblingStack;var topElement=elementStack.pop();nextSiblingStack.pop();_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.element = _glimmerUtil.expect(elementStack.current,"can't pop past the last element");this.nextSibling = nextSiblingStack.current;return topElement;};ElementStack.prototype.pushSimpleBlock = function pushSimpleBlock(){var tracker=new SimpleBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushUpdatableBlock = function pushUpdatableBlock(){var tracker=new UpdatableBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushBlockTracker = function pushBlockTracker(tracker){var isRemote=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);if(!isRemote){current.newBounds(tracker);}}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.pushBlockList = function pushBlockList(list){var tracker=new BlockListTracker(this.element,list);var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);current.newBounds(tracker);}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.popBlock = function popBlock(){this.block().finalize(this);return _glimmerUtil.expect(this.blockStack.pop(),"Expected popBlock to return a block");};ElementStack.prototype.openElement = function openElement(tag){var operations=arguments.length <= 1 || arguments[1] === undefined?this.defaultOperations:arguments[1];var element=this.dom.createElement(tag,this.element);this.constructing = element;this.operations = operations;return element;};ElementStack.prototype.flushElement = function flushElement(){var parent=this.element;var element=_glimmerUtil.expect(this.constructing,'flushElement should only be called when constructing an element');this.dom.insertBefore(parent,element,this.nextSibling);this.constructing = null;this.operations = null;this.pushElement(element);this.block().openElement(element);};ElementStack.prototype.pushRemoteElement = function pushRemoteElement(element){this.pushElement(element);var tracker=new RemoteBlockTracker(element);this.pushBlockTracker(tracker,true);};ElementStack.prototype.popRemoteElement = function popRemoteElement(){this.popBlock();this.popElement();};ElementStack.prototype.pushElement = function pushElement(element){this.element = element;this.elementStack.push(element);_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.nextSibling = null;this.nextSiblingStack.push(null);};ElementStack.prototype.newDestroyable = function newDestroyable(d){this.block().newDestroyable(d);};ElementStack.prototype.newBounds = function newBounds(bounds){this.block().newBounds(bounds);};ElementStack.prototype.appendText = function appendText(string){var dom=this.dom;var text=dom.createTextNode(string);dom.insertBefore(this.element,text,this.nextSibling);this.block().newNode(text);return text;};ElementStack.prototype.appendComment = function appendComment(string){var dom=this.dom;var comment=dom.createComment(string);dom.insertBefore(this.element,comment,this.nextSibling);this.block().newNode(comment);return comment;};ElementStack.prototype.setStaticAttribute = function setStaticAttribute(name,value){this.expectOperations('setStaticAttribute').addStaticAttribute(this.expectConstructing('setStaticAttribute'),name,value);};ElementStack.prototype.setStaticAttributeNS = function setStaticAttributeNS(namespace,name,value){this.expectOperations('setStaticAttributeNS').addStaticAttributeNS(this.expectConstructing('setStaticAttributeNS'),namespace,name,value);};ElementStack.prototype.setDynamicAttribute = function setDynamicAttribute(name,reference,isTrusting){this.expectOperations('setDynamicAttribute').addDynamicAttribute(this.expectConstructing('setDynamicAttribute'),name,reference,isTrusting);};ElementStack.prototype.setDynamicAttributeNS = function setDynamicAttributeNS(namespace,name,reference,isTrusting){this.expectOperations('setDynamicAttributeNS').addDynamicAttributeNS(this.expectConstructing('setDynamicAttributeNS'),namespace,name,reference,isTrusting);};ElementStack.prototype.closeElement = function closeElement(){this.block().closeElement();this.popElement();};return ElementStack;})();var SimpleBlockTracker=(function(){function SimpleBlockTracker(parent){this.parent = parent;this.first = null;this.last = null;this.destroyables = null;this.nesting = 0;}SimpleBlockTracker.prototype.destroy = function destroy(){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {destroyables[i].destroy();}}};SimpleBlockTracker.prototype.parentElement = function parentElement(){return this.parent;};SimpleBlockTracker.prototype.firstNode = function firstNode(){return this.first && this.first.firstNode();};SimpleBlockTracker.prototype.lastNode = function lastNode(){return this.last && this.last.lastNode();};SimpleBlockTracker.prototype.openElement = function openElement(element){this.newNode(element);this.nesting++;};SimpleBlockTracker.prototype.closeElement = function closeElement(){this.nesting--;};SimpleBlockTracker.prototype.newNode = function newNode(node){if(this.nesting !== 0)return;if(!this.first){this.first = new First(node);}this.last = new Last(node);};SimpleBlockTracker.prototype.newBounds = function newBounds(bounds){if(this.nesting !== 0)return;if(!this.first){this.first = bounds;}this.last = bounds;};SimpleBlockTracker.prototype.newDestroyable = function newDestroyable(d){this.destroyables = this.destroyables || [];this.destroyables.push(d);};SimpleBlockTracker.prototype.finalize = function finalize(stack){if(!this.first){stack.appendComment('');}};return SimpleBlockTracker;})();var RemoteBlockTracker=(function(_SimpleBlockTracker){babelHelpers.inherits(RemoteBlockTracker,_SimpleBlockTracker);function RemoteBlockTracker(){_SimpleBlockTracker.apply(this,arguments);}RemoteBlockTracker.prototype.destroy = function destroy(){_SimpleBlockTracker.prototype.destroy.call(this);clear(this);};return RemoteBlockTracker;})(SimpleBlockTracker);var UpdatableBlockTracker=(function(_SimpleBlockTracker2){babelHelpers.inherits(UpdatableBlockTracker,_SimpleBlockTracker2);function UpdatableBlockTracker(){_SimpleBlockTracker2.apply(this,arguments);}UpdatableBlockTracker.prototype.reset = function reset(env){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {env.didDestroy(destroyables[i]);}}var nextSibling=clear(this);this.destroyables = null;this.first = null;this.last = null;return nextSibling;};return UpdatableBlockTracker;})(SimpleBlockTracker);var BlockListTracker=(function(){function BlockListTracker(parent,boundList){this.parent = parent;this.boundList = boundList;this.parent = parent;this.boundList = boundList;}BlockListTracker.prototype.destroy = function destroy(){this.boundList.forEachNode(function(node){return node.destroy();});};BlockListTracker.prototype.parentElement = function parentElement(){return this.parent;};BlockListTracker.prototype.firstNode = function firstNode(){var head=this.boundList.head();return head && head.firstNode();};BlockListTracker.prototype.lastNode = function lastNode(){var tail=this.boundList.tail();return tail && tail.lastNode();};BlockListTracker.prototype.openElement = function openElement(_element){_glimmerUtil.assert(false,'Cannot openElement directly inside a block list');};BlockListTracker.prototype.closeElement = function closeElement(){_glimmerUtil.assert(false,'Cannot closeElement directly inside a block list');};BlockListTracker.prototype.newNode = function newNode(_node){_glimmerUtil.assert(false,'Cannot create a new node directly inside a block list');};BlockListTracker.prototype.newBounds = function newBounds(_bounds){};BlockListTracker.prototype.newDestroyable = function newDestroyable(_d){};BlockListTracker.prototype.finalize = function finalize(_stack){};return BlockListTracker;})();var CompiledValue=(function(_CompiledExpression){babelHelpers.inherits(CompiledValue,_CompiledExpression);function CompiledValue(value){_CompiledExpression.call(this);this.type = "value";this.reference = PrimitiveReference.create(value);}CompiledValue.prototype.evaluate = function evaluate(_vm){return this.reference;};CompiledValue.prototype.toJSON = function toJSON(){return JSON.stringify(this.reference.value());};return CompiledValue;})(CompiledExpression);var CompiledHasBlock=(function(_CompiledExpression2){babelHelpers.inherits(CompiledHasBlock,_CompiledExpression2);function CompiledHasBlock(inner){_CompiledExpression2.call(this);this.inner = inner;this.type = "has-block";}CompiledHasBlock.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);return PrimitiveReference.create(!!block);};CompiledHasBlock.prototype.toJSON = function toJSON(){return 'has-block(' + this.inner.toJSON() + ')';};return CompiledHasBlock;})(CompiledExpression);var CompiledHasBlockParams=(function(_CompiledExpression3){babelHelpers.inherits(CompiledHasBlockParams,_CompiledExpression3);function CompiledHasBlockParams(inner){_CompiledExpression3.call(this);this.inner = inner;this.type = "has-block-params";}CompiledHasBlockParams.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);var hasLocals=block && block.symbolTable.getSymbols().locals;return PrimitiveReference.create(!!hasLocals);};CompiledHasBlockParams.prototype.toJSON = function toJSON(){return 'has-block-params(' + this.inner.toJSON() + ')';};return CompiledHasBlockParams;})(CompiledExpression);var CompiledGetBlockBySymbol=(function(){function CompiledGetBlockBySymbol(symbol,debug){this.symbol = symbol;this.debug = debug;}CompiledGetBlockBySymbol.prototype.evaluate = function evaluate(vm){return vm.scope().getBlock(this.symbol);};CompiledGetBlockBySymbol.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '(' + this.debug + '))';};return CompiledGetBlockBySymbol;})();var CompiledInPartialGetBlock=(function(){function CompiledInPartialGetBlock(symbol,name){this.symbol = symbol;this.name = name;}CompiledInPartialGetBlock.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.blocks[name];};CompiledInPartialGetBlock.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '($ARGS).' + this.name + '))';};return CompiledInPartialGetBlock;})();var CompiledLookup=(function(_CompiledExpression4){babelHelpers.inherits(CompiledLookup,_CompiledExpression4);function CompiledLookup(base,path){_CompiledExpression4.call(this);this.base = base;this.path = path;this.type = "lookup";}CompiledLookup.create = function create(base,path){if(path.length === 0){return base;}else {return new this(base,path);}};CompiledLookup.prototype.evaluate = function evaluate(vm){var base=this.base;var path=this.path;return _glimmerReference.referenceFromParts(base.evaluate(vm),path);};CompiledLookup.prototype.toJSON = function toJSON(){return this.base.toJSON() + '.' + this.path.join('.');};return CompiledLookup;})(CompiledExpression);var CompiledSelf=(function(_CompiledExpression5){babelHelpers.inherits(CompiledSelf,_CompiledExpression5);function CompiledSelf(){_CompiledExpression5.apply(this,arguments);}CompiledSelf.prototype.evaluate = function evaluate(vm){return vm.getSelf();};CompiledSelf.prototype.toJSON = function toJSON(){return 'self';};return CompiledSelf;})(CompiledExpression);var CompiledSymbol=(function(_CompiledExpression6){babelHelpers.inherits(CompiledSymbol,_CompiledExpression6);function CompiledSymbol(symbol,debug){_CompiledExpression6.call(this);this.symbol = symbol;this.debug = debug;}CompiledSymbol.prototype.evaluate = function evaluate(vm){return vm.referenceForSymbol(this.symbol);};CompiledSymbol.prototype.toJSON = function toJSON(){return '$' + this.symbol + '(' + this.debug + ')';};return CompiledSymbol;})(CompiledExpression);var CompiledInPartialName=(function(_CompiledExpression7){babelHelpers.inherits(CompiledInPartialName,_CompiledExpression7);function CompiledInPartialName(symbol,name){_CompiledExpression7.call(this);this.symbol = symbol;this.name = name;}CompiledInPartialName.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.named.get(name);};CompiledInPartialName.prototype.toJSON = function toJSON(){return '$' + this.symbol + '($ARGS).' + this.name;};return CompiledInPartialName;})(CompiledExpression);var CompiledHelper=(function(_CompiledExpression8){babelHelpers.inherits(CompiledHelper,_CompiledExpression8);function CompiledHelper(name,helper,args,symbolTable){_CompiledExpression8.call(this);this.name = name;this.helper = helper;this.args = args;this.symbolTable = symbolTable;this.type = "helper";}CompiledHelper.prototype.evaluate = function evaluate(vm){var helper=this.helper;return helper(vm,this.args.evaluate(vm),this.symbolTable);};CompiledHelper.prototype.toJSON = function toJSON(){return '`' + this.name.join('.') + '($ARGS)`';};return CompiledHelper;})(CompiledExpression);var CompiledConcat=(function(){function CompiledConcat(parts){this.parts = parts;this.type = "concat";}CompiledConcat.prototype.evaluate = function evaluate(vm){var parts=new Array(this.parts.length);for(var i=0;i < this.parts.length;i++) {parts[i] = this.parts[i].evaluate(vm);}return new ConcatReference(parts);};CompiledConcat.prototype.toJSON = function toJSON(){return 'concat(' + this.parts.map(function(expr){return expr.toJSON();}).join(", ") + ')';};return CompiledConcat;})();var ConcatReference=(function(_CachedReference2){babelHelpers.inherits(ConcatReference,_CachedReference2);function ConcatReference(parts){_CachedReference2.call(this);this.parts = parts;this.tag = _glimmerReference.combineTagged(parts);}ConcatReference.prototype.compute = function compute(){var parts=new Array();for(var i=0;i < this.parts.length;i++) {var value=this.parts[i].value();if(value !== null && value !== undefined){parts[i] = castToString(value);}}if(parts.length > 0){return parts.join('');}return null;};return ConcatReference;})(_glimmerReference.CachedReference);function castToString(value){if(typeof value['toString'] !== 'function'){return '';}return String(value);}var CompiledFunctionExpression=(function(_CompiledExpression9){babelHelpers.inherits(CompiledFunctionExpression,_CompiledExpression9);function CompiledFunctionExpression(func,symbolTable){_CompiledExpression9.call(this);this.func = func;this.symbolTable = symbolTable;this.type = "function";this.func = func;}CompiledFunctionExpression.prototype.evaluate = function evaluate(vm){var func=this.func;var symbolTable=this.symbolTable;return func(vm,symbolTable);};CompiledFunctionExpression.prototype.toJSON = function toJSON(){var func=this.func;if(func.name){return '`' + func.name + '(...)`';}else {return "`func(...)`";}};return CompiledFunctionExpression;})(CompiledExpression);function debugCallback(context,get){console.info('Use `context`, and `get()` to debug this template.'); /* tslint:disable */debugger; /* tslint:enable */return {context:context,get:get};}function getter(vm,builder){return function(path){var parts=path.split('.');if(parts[0] === 'this'){parts[0] = null;}return compileRef(parts,builder).evaluate(vm);};}var callback=debugCallback; // For testing purposes +function setDebuggerCallback(cb){callback = cb;}function resetDebuggerCallback(){callback = debugCallback;}var Compilers=(function(){function Compilers(){this.names = _glimmerUtil.dict();this.funcs = [];}Compilers.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Compilers.prototype.compile = function compile(sexp,builder){var name=sexp[0];var index=this.names[name];var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected an implementation for ' + sexp[0]);return func(sexp,builder);};return Compilers;})();var STATEMENTS=new Compilers();STATEMENTS.add('text',function(sexp,builder){builder.text(sexp[1]);});STATEMENTS.add('comment',function(sexp,builder){builder.comment(sexp[1]);});STATEMENTS.add('close-element',function(_sexp,builder){_glimmerUtil.LOGGER.trace('close-element statement');builder.closeElement();});STATEMENTS.add('flush-element',function(_sexp,builder){builder.flushElement();});STATEMENTS.add('modifier',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var args=compileArgs(params,hash,builder);if(builder.env.hasModifier(path,builder.symbolTable)){builder.modifier(path[0],args);}else {throw new Error('Compile Error ' + path.join('.') + ' is not a modifier: Helpers may not be used in the element form.');}});STATEMENTS.add('static-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];builder.staticAttr(name,namespace,value);});STATEMENTS.add('any-dynamic-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];var trusting=sexp[4];builder.putValue(value);if(namespace){builder.dynamicAttrNS(name,namespace,trusting);}else {builder.dynamicAttr(name,trusting);}});STATEMENTS.add('open-element',function(sexp,builder){_glimmerUtil.LOGGER.trace('open-element statement');builder.openPrimitiveElement(sexp[1]);});STATEMENTS.add('optimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros=builder.env.macros();var inlines=_builder$env$macros.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;builder.putValue(returned[1]);if(trustingMorph){builder.trustingAppend();}else {builder.cautiousAppend();}});STATEMENTS.add('unoptimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros2=builder.env.macros();var inlines=_builder$env$macros2.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;if(trustingMorph){builder.guardedTrustingAppend(returned[1]);}else {builder.guardedCautiousAppend(returned[1]);}});STATEMENTS.add('nested-block',function(sexp,builder){var _builder$env$macros3=builder.env.macros();var blocks=_builder$env$macros3.blocks;blocks.compile(sexp,builder);});STATEMENTS.add('scanned-block',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var template=sexp[4];var inverse=sexp[5];var templateBlock=template && template.scan();var inverseBlock=inverse && inverse.scan();var _builder$env$macros4=builder.env.macros();var blocks=_builder$env$macros4.blocks;blocks.compile(['nested-block',path,params,hash,templateBlock,inverseBlock],builder);});STATEMENTS.add('scanned-component',function(sexp,builder){var tag=sexp[1];var attrs=sexp[2];var rawArgs=sexp[3];var rawBlock=sexp[4];var block=rawBlock && rawBlock.scan();var args=compileBlockArgs(null,rawArgs,{default:block,inverse:null},builder);var definition=builder.env.getComponentDefinition([tag],builder.symbolTable);builder.putComponentDefinition(definition);builder.openComponent(args,attrs.scan());builder.closeComponent();});STATEMENTS.add('static-partial',function(sexp,builder){var name=sexp[1];if(!builder.env.hasPartial(name,builder.symbolTable)){throw new Error('Compile Error: Could not find a partial named "' + name + '"');}var definition=builder.env.lookupPartial(name,builder.symbolTable);builder.putPartialDefinition(definition);builder.evaluatePartial();});STATEMENTS.add('dynamic-partial',function(sexp,builder){var name=sexp[1];builder.startLabels();builder.putValue(name);builder.test('simple');builder.enter('BEGIN','END');builder.label('BEGIN');builder.jumpUnless('END');builder.putDynamicPartialDefinition();builder.evaluatePartial();builder.label('END');builder.exit();builder.stopLabels();});STATEMENTS.add('yield',function(sexp,builder){var to=sexp[1];var params=sexp[2];var args=compileArgs(params,null,builder);builder.yield(args,to);});STATEMENTS.add('debugger',function(sexp,builder){builder.putValue(['function',function(vm){var context=vm.getSelf().value();var get=function(path){return getter(vm,builder)(path).value();};callback(context,get);}]);return sexp;});var EXPRESSIONS=new Compilers();function expr(expression,builder){if(Array.isArray(expression)){return EXPRESSIONS.compile(expression,builder);}else {return new CompiledValue(expression);}}EXPRESSIONS.add('unknown',function(sexp,builder){var path=sexp[1];if(builder.env.hasHelper(path,builder.symbolTable)){return new CompiledHelper(path,builder.env.lookupHelper(path,builder.symbolTable),CompiledArgs.empty(),builder.symbolTable);}else {return compileRef(path,builder);}});EXPRESSIONS.add('concat',function(sexp,builder){var params=sexp[1].map(function(p){return expr(p,builder);});return new CompiledConcat(params);});EXPRESSIONS.add('function',function(sexp,builder){return new CompiledFunctionExpression(sexp[1],builder.symbolTable);});EXPRESSIONS.add('helper',function(sexp,builder){var env=builder.env;var symbolTable=builder.symbolTable;var path=sexp[1];var params=sexp[2];var hash=sexp[3];if(env.hasHelper(path,symbolTable)){var args=compileArgs(params,hash,builder);return new CompiledHelper(path,env.lookupHelper(path,symbolTable),args,symbolTable);}else {throw new Error('Compile Error: ' + path.join('.') + ' is not a helper');}});EXPRESSIONS.add('get',function(sexp,builder){return compileRef(sexp[1],builder);});EXPRESSIONS.add('undefined',function(_sexp,_builder){return new CompiledValue(undefined);});EXPRESSIONS.add('arg',function(sexp,builder){var parts=sexp[1];var head=parts[0];var named=undefined,partial=undefined;if(named = builder.symbolTable.getSymbol('named',head)){var path=parts.slice(1);var inner=new CompiledSymbol(named,head);return CompiledLookup.create(inner,path);}else if(partial = builder.symbolTable.getPartialArgs()){var path=parts.slice(1);var inner=new CompiledInPartialName(partial,head);return CompiledLookup.create(inner,path);}else {throw new Error('[BUG] @' + parts.join('.') + ' is not a valid lookup path.');}});EXPRESSIONS.add('has-block',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlock(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlock(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});EXPRESSIONS.add('has-block-params',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlockParams(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlockParams(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});function compileArgs(params,hash,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,EMPTY_BLOCKS);}function compileBlockArgs(params,hash,blocks,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,blocks);}function compileBaselineArgs(args,builder){var params=args[0];var hash=args[1];var _default=args[2];var inverse=args[3];return CompiledArgs.create(compileParams(params,builder),compileHash(hash,builder),{default:_default,inverse:inverse});}function compileParams(params,builder){if(!params || params.length === 0)return COMPILED_EMPTY_POSITIONAL_ARGS;var compiled=params.map(function(p){return expr(p,builder);});return CompiledPositionalArgs.create(compiled);}function compileHash(hash,builder){if(!hash)return COMPILED_EMPTY_NAMED_ARGS;var keys=hash[0];var values=hash[1];if(keys.length === 0)return COMPILED_EMPTY_NAMED_ARGS;var compiled=values.map(function(p){return expr(p,builder);});return new CompiledNamedArgs(keys,compiled);}function compileRef(parts,builder){var head=parts[0];var local=undefined;if(head === null){var inner=new CompiledSelf();var path=parts.slice(1);return CompiledLookup.create(inner,path);}else if(local = builder.symbolTable.getSymbol('local',head)){var path=parts.slice(1);var inner=new CompiledSymbol(local,head);return CompiledLookup.create(inner,path);}else {var inner=new CompiledSelf();return CompiledLookup.create(inner,parts);}}var Blocks=(function(){function Blocks(){this.names = _glimmerUtil.dict();this.funcs = [];}Blocks.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Blocks.prototype.addMissing = function addMissing(func){this.missing = func;};Blocks.prototype.compile = function compile(sexp,builder){ // assert(sexp[1].length === 1, 'paths in blocks are not supported'); +var name=sexp[1][0];var index=this.names[name];if(index === undefined){_glimmerUtil.assert(!!this.missing,name + ' not found, and no catch-all block handler was registered');var func=this.missing;var handled=func(sexp,builder);_glimmerUtil.assert(!!handled,name + ' not found, and the catch-all block handler didn\'t handle it');}else {var func=this.funcs[index];func(sexp,builder);}};return Blocks;})();var BLOCKS=new Blocks();var Inlines=(function(){function Inlines(){this.names = _glimmerUtil.dict();this.funcs = [];}Inlines.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Inlines.prototype.addMissing = function addMissing(func){this.missing = func;};Inlines.prototype.compile = function compile(sexp,builder){var value=sexp[1]; // TODO: Fix this so that expression macros can return +// things like components, so that {{component foo}} +// is the same as {{(component foo)}} +if(!Array.isArray(value))return ['expr',value];var path=undefined;var params=undefined;var hash=undefined;if(value[0] === 'helper'){path = value[1];params = value[2];hash = value[3];}else if(value[0] === 'unknown'){path = value[1];params = hash = null;}else {return ['expr',value];}if(path.length > 1 && !params && !hash){return ['expr',value];}var name=path[0];var index=this.names[name];if(index === undefined && this.missing){var func=this.missing;var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else if(index !== undefined){var func=this.funcs[index];var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else {return ['expr',value];}};return Inlines;})();var INLINES=new Inlines();populateBuiltins(BLOCKS,INLINES);function populateBuiltins(){var blocks=arguments.length <= 0 || arguments[0] === undefined?new Blocks():arguments[0];var inlines=arguments.length <= 1 || arguments[1] === undefined?new Inlines():arguments[1];blocks.add('if',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('unless',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpIf('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpIf('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('with',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('each',function(sexp,builder){ // Enter(BEGIN, END) +// BEGIN: Noop +// PutArgs +// PutIterable +// JumpUnless(ELSE) +// EnterList(BEGIN2, END2) +// ITER: Noop +// NextIter(BREAK) +// EnterWithKey(BEGIN2, END2) +// BEGIN2: Noop +// PushChildScope +// Evaluate(default) +// PopScope +// END2: Noop +// Exit +// Jump(ITER) +// BREAK: Noop +// ExitList +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.labelled(args,function(b){b.putIterator();if(inverse){b.jumpUnless('ELSE');}else {b.jumpUnless('END');}b.iter(function(b){b.evaluate(_glimmerUtil.unwrap(_default));});if(inverse){b.jump('END');b.label('ELSE');b.evaluate(inverse);}});});return {blocks:blocks,inlines:inlines};}var badProtocols=['javascript:','vbscript:'];var badTags=['A','BODY','LINK','IMG','IFRAME','BASE','FORM'];var badTagsForDataURI=['EMBED'];var badAttributes=['href','src','background','action'];var badAttributesForDataURI=['src'];function has(array,item){return array.indexOf(item) !== -1;}function checkURI(tagName,attribute){return (tagName === null || has(badTags,tagName)) && has(badAttributes,attribute);}function checkDataURI(tagName,attribute){if(tagName === null)return false;return has(badTagsForDataURI,tagName) && has(badAttributesForDataURI,attribute);}function requiresSanitization(tagName,attribute){return checkURI(tagName,attribute) || checkDataURI(tagName,attribute);}function sanitizeAttributeValue(env,element,attribute,value){var tagName=null;if(value === null || value === undefined){return value;}if(isSafeString(value)){return value.toHTML();}if(!element){tagName = null;}else {tagName = element.tagName.toUpperCase();}var str=normalizeTextValue(value);if(checkURI(tagName,attribute)){var protocol=env.protocolForURL(str);if(has(badProtocols,protocol)){return 'unsafe:' + str;}}if(checkDataURI(tagName,attribute)){return 'unsafe:' + str;}return str;} /* + * @method normalizeProperty + * @param element {HTMLElement} + * @param slotName {String} + * @returns {Object} { name, type } + */function normalizeProperty(element,slotName){var type=undefined,normalized=undefined;if(slotName in element){normalized = slotName;type = 'prop';}else {var lower=slotName.toLowerCase();if(lower in element){type = 'prop';normalized = lower;}else {type = 'attr';normalized = slotName;}}if(type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName,normalized))){type = 'attr';}return {normalized:normalized,type:type};} // properties that MUST be set as attributes, due to: +// * browser bug +// * strange spec outlier +var ATTR_OVERRIDES={ // phantomjs < 2.0 lets you set it as a prop but won't reflect it +// back to the attribute. button.getAttribute('type') === null +BUTTON:{type:true,form:true},INPUT:{ // Some version of IE (like IE9) actually throw an exception +// if you set input.type = 'something-unknown' +type:true,form:true, // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false +// Safari 8.0.7: 'autocorrect' in document.createElement('input') === false +// Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true +autocorrect:true, // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true +// Safari 9.1.3: 'list' in document.createElement('input') === false +list:true}, // element.form is actually a legitimate readOnly property, that is to be +// mutated, but must be mutated by setAttribute... +SELECT:{form:true},OPTION:{form:true},TEXTAREA:{form:true},LABEL:{form:true},FIELDSET:{form:true},LEGEND:{form:true},OBJECT:{form:true}};function preferAttr(tagName,propName){var tag=ATTR_OVERRIDES[tagName.toUpperCase()];return tag && tag[propName.toLowerCase()] || false;}var innerHTMLWrapper={colgroup:{depth:2,before:'',after:'
    '},table:{depth:1,before:'',after:'
    '},tbody:{depth:2,before:'',after:'
    '},tfoot:{depth:2,before:'',after:'
    '},thead:{depth:2,before:'',after:'
    '},tr:{depth:3,before:'',after:'
    '}}; // Patch: innerHTML Fix +// Browsers: IE9 +// Reason: IE9 don't allow us to set innerHTML on col, colgroup, frameset, +// html, style, table, tbody, tfoot, thead, title, tr. +// Fix: Wrap the innerHTML we are about to set in its parents, apply the +// wrapped innerHTML on a div, then move the unwrapped nodes into the +// target position. +function domChanges(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix(document)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass){babelHelpers.inherits(DOMChangesWithInnerHTMLFix,_DOMChangesClass);function DOMChangesWithInnerHTMLFix(){_DOMChangesClass.apply(this,arguments);}DOMChangesWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixInnerHTML(parent,wrapper,div,html,nextSibling);};return DOMChangesWithInnerHTMLFix;})(DOMChangesClass);}function treeConstruction(document,DOMTreeConstructionClass){if(!document)return DOMTreeConstructionClass;if(!shouldApplyFix(document)){return DOMTreeConstructionClass;}var div=document.createElement('div');return (function(_DOMTreeConstructionClass){babelHelpers.inherits(DOMTreeConstructionWithInnerHTMLFix,_DOMTreeConstructionClass);function DOMTreeConstructionWithInnerHTMLFix(){_DOMTreeConstructionClass.apply(this,arguments);}DOMTreeConstructionWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixInnerHTML(parent,wrapper,div,html,reference);};return DOMTreeConstructionWithInnerHTMLFix;})(DOMTreeConstructionClass);}function fixInnerHTML(parent,wrapper,div,html,reference){var wrappedHtml=wrapper.before + html + wrapper.after;div.innerHTML = wrappedHtml;var parentNode=div;for(var i=0;i < wrapper.depth;i++) {parentNode = parentNode.childNodes[0];}var _moveNodesBefore=moveNodesBefore(parentNode,parent,reference);var first=_moveNodesBefore[0];var last=_moveNodesBefore[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix(document){var table=document.createElement('table');try{table.innerHTML = '';}catch(e) {}finally {if(table.childNodes.length !== 0){ // It worked as expected, no fix required +return false;}}return true;}var SVG_NAMESPACE$1='http://www.w3.org/2000/svg'; // Patch: insertAdjacentHTML on SVG Fix +// Browsers: Safari, IE, Edge, Firefox ~33-34 +// Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is +// present but throws an exception on IE and Edge. Old versions of +// Firefox create nodes in the incorrect namespace. +// Fix: Since IE and Edge silently fail to create SVG nodes using +// innerHTML, and because Firefox may create nodes in the incorrect +// namespace using innerHTML on SVG elements, an HTML-string wrapping +// approach is used. A pre/post SVG tag is added to the string, then +// that whole string is added to a div. The created nodes are plucked +// out and applied to the target location on DOM. +function domChanges$1(document,DOMChangesClass,svgNamespace){if(!document)return DOMChangesClass;if(!shouldApplyFix$1(document,svgNamespace)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass2){babelHelpers.inherits(DOMChangesWithSVGInnerHTMLFix,_DOMChangesClass2);function DOMChangesWithSVGInnerHTMLFix(){_DOMChangesClass2.apply(this,arguments);}DOMChangesWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}if(parent.namespaceURI !== svgNamespace){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixSVG(parent,div,html,nextSibling);};return DOMChangesWithSVGInnerHTMLFix;})(DOMChangesClass);}function treeConstruction$1(document,TreeConstructionClass,svgNamespace){if(!document)return TreeConstructionClass;if(!shouldApplyFix$1(document,svgNamespace)){return TreeConstructionClass;}var div=document.createElement('div');return (function(_TreeConstructionClass){babelHelpers.inherits(TreeConstructionWithSVGInnerHTMLFix,_TreeConstructionClass);function TreeConstructionWithSVGInnerHTMLFix(){_TreeConstructionClass.apply(this,arguments);}TreeConstructionWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}if(parent.namespaceURI !== svgNamespace){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixSVG(parent,div,html,reference);};return TreeConstructionWithSVGInnerHTMLFix;})(TreeConstructionClass);}function fixSVG(parent,div,html,reference){ // IE, Edge: also do not correctly support using `innerHTML` on SVG +// namespaced elements. So here a wrapper is used. +var wrappedHtml='' + html + '';div.innerHTML = wrappedHtml;var _moveNodesBefore2=moveNodesBefore(div.firstChild,parent,reference);var first=_moveNodesBefore2[0];var last=_moveNodesBefore2[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix$1(document,svgNamespace){var svg=document.createElementNS(svgNamespace,'svg');try{svg['insertAdjacentHTML']('beforeEnd','');}catch(e) {}finally { // FF: Old versions will create a node in the wrong namespace +if(svg.childNodes.length === 1 && _glimmerUtil.unwrap(svg.firstChild).namespaceURI === SVG_NAMESPACE$1){ // The test worked as expected, no fix required +return false;}return true;}} // Patch: Adjacent text node merging fix +// Browsers: IE, Edge, Firefox w/o inspector open +// Reason: These browsers will merge adjacent text nodes. For exmaple given +//
    Hello
    with div.insertAdjacentHTML(' world') browsers +// with proper behavior will populate div.childNodes with two items. +// These browsers will populate it with one merged node instead. +// Fix: Add these nodes to a wrapper element, then iterate the childNodes +// of that wrapper and move the nodes to their target location. Note +// that potential SVG bugs will have been handled before this fix. +// Note that this fix must only apply to the previous text node, as +// the base implementation of `insertHTMLBefore` already handles +// following text nodes correctly. +function domChanges$2(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix$2(document)){return DOMChangesClass;}return (function(_DOMChangesClass3){babelHelpers.inherits(DOMChangesWithTextNodeMergingFix,_DOMChangesClass3);function DOMChangesWithTextNodeMergingFix(document){_DOMChangesClass3.call(this,document);this.uselessComment = document.createComment('');}DOMChangesWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null){return _DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var didSetUselessComment=false;var nextPrevious=nextSibling?nextSibling.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,nextSibling);}var bounds=_DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return DOMChangesWithTextNodeMergingFix;})(DOMChangesClass);}function treeConstruction$2(document,TreeConstructionClass){if(!document)return TreeConstructionClass;if(!shouldApplyFix$2(document)){return TreeConstructionClass;}return (function(_TreeConstructionClass2){babelHelpers.inherits(TreeConstructionWithTextNodeMergingFix,_TreeConstructionClass2);function TreeConstructionWithTextNodeMergingFix(document){_TreeConstructionClass2.call(this,document);this.uselessComment = this.createComment('');}TreeConstructionWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null){return _TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);}var didSetUselessComment=false;var nextPrevious=reference?reference.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,reference);}var bounds=_TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return TreeConstructionWithTextNodeMergingFix;})(TreeConstructionClass);}function shouldApplyFix$2(document){var mergingTextDiv=document.createElement('div');mergingTextDiv.innerHTML = 'first';mergingTextDiv.insertAdjacentHTML('beforeEnd','second');if(mergingTextDiv.childNodes.length === 2){ // It worked as expected, no fix required +return false;}return true;}var SVG_NAMESPACE='http://www.w3.org/2000/svg'; // http://www.w3.org/TR/html/syntax.html#html-integration-point +var SVG_INTEGRATION_POINTS={foreignObject:1,desc:1,title:1}; // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes +// TODO: Adjust SVG attributes +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +// TODO: Adjust SVG elements +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +var BLACKLIST_TABLE=Object.create(null);["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach(function(tag){return BLACKLIST_TABLE[tag] = 1;});var WHITESPACE=/[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;var doc=typeof document === 'undefined'?null:document;function isWhitespace(string){return WHITESPACE.test(string);}function moveNodesBefore(source,target,nextSibling){var first=source.firstChild;var last=null;var current=first;while(current) {last = current;current = current.nextSibling;target.insertBefore(last,nextSibling);}return [first,last];}var DOM;(function(DOM){var TreeConstruction=(function(){function TreeConstruction(document){this.document = document;this.setupUselessElement();}TreeConstruction.prototype.setupUselessElement = function setupUselessElement(){this.uselessElement = this.document.createElement('div');};TreeConstruction.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};TreeConstruction.prototype.createElementNS = function createElementNS(namespace,tag){return this.document.createElementNS(namespace,tag);};TreeConstruction.prototype.setAttribute = function setAttribute(element,name,value,namespace){if(namespace){element.setAttributeNS(namespace,name,value);}else {element.setAttribute(name,value);}};TreeConstruction.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};TreeConstruction.prototype.createComment = function createComment(data){return this.document.createComment(data);};TreeConstruction.prototype.insertBefore = function insertBefore(parent,node,reference){parent.insertBefore(node,reference);};TreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){return _insertHTMLBefore(this.uselessElement,parent,reference,html);};return TreeConstruction;})();DOM.TreeConstruction = TreeConstruction;var appliedTreeContruction=TreeConstruction;appliedTreeContruction = treeConstruction$2(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction$1(doc,appliedTreeContruction,SVG_NAMESPACE);DOM.DOMTreeConstruction = appliedTreeContruction;})(DOM || (DOM = {}));var DOMChanges=(function(){function DOMChanges(document){this.document = document;this.namespace = null;this.uselessElement = this.document.createElement('div');}DOMChanges.prototype.setAttribute = function setAttribute(element,name,value){element.setAttribute(name,value);};DOMChanges.prototype.setAttributeNS = function setAttributeNS(element,namespace,name,value){element.setAttributeNS(namespace,name,value);};DOMChanges.prototype.removeAttribute = function removeAttribute(element,name){element.removeAttribute(name);};DOMChanges.prototype.removeAttributeNS = function removeAttributeNS(element,namespace,name){element.removeAttributeNS(namespace,name);};DOMChanges.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};DOMChanges.prototype.createComment = function createComment(data){return this.document.createComment(data);};DOMChanges.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};DOMChanges.prototype.insertHTMLBefore = function insertHTMLBefore(_parent,nextSibling,html){return _insertHTMLBefore(this.uselessElement,_parent,nextSibling,html);};DOMChanges.prototype.insertNodeBefore = function insertNodeBefore(parent,node,reference){if(isDocumentFragment(node)){var firstChild=node.firstChild;var lastChild=node.lastChild;this.insertBefore(parent,node,reference);return new ConcreteBounds(parent,firstChild,lastChild);}else {this.insertBefore(parent,node,reference);return new SingleNodeBounds(parent,node);}};DOMChanges.prototype.insertTextBefore = function insertTextBefore(parent,nextSibling,text){var textNode=this.createTextNode(text);this.insertBefore(parent,textNode,nextSibling);return textNode;};DOMChanges.prototype.insertBefore = function insertBefore(element,node,reference){element.insertBefore(node,reference);};DOMChanges.prototype.insertAfter = function insertAfter(element,node,reference){this.insertBefore(element,node,reference.nextSibling);};return DOMChanges;})();function _insertHTMLBefore(_useless,_parent,_nextSibling,html){ // TypeScript vendored an old version of the DOM spec where `insertAdjacentHTML` +// only exists on `HTMLElement` but not on `Element`. We actually work with the +// newer version of the DOM API here (and monkey-patch this method in `./compat` +// when we detect older browsers). This is a hack to work around this limitation. +var parent=_parent;var useless=_useless;var nextSibling=_nextSibling;var prev=nextSibling?nextSibling.previousSibling:parent.lastChild;var last=undefined;if(html === null || html === ''){return new ConcreteBounds(parent,null,null);}if(nextSibling === null){parent.insertAdjacentHTML('beforeEnd',html);last = parent.lastChild;}else if(nextSibling instanceof HTMLElement){nextSibling.insertAdjacentHTML('beforeBegin',html);last = nextSibling.previousSibling;}else { // Non-element nodes do not support insertAdjacentHTML, so add an +// element and call it on that element. Then remove the element. +// +// This also protects Edge, IE and Firefox w/o the inspector open +// from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts +parent.insertBefore(useless,nextSibling);useless.insertAdjacentHTML('beforeBegin',html);last = useless.previousSibling;parent.removeChild(useless);}var first=prev?prev.nextSibling:parent.firstChild;return new ConcreteBounds(parent,first,last);}function isDocumentFragment(node){return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;}var helper=DOMChanges;helper = domChanges$2(doc,helper);helper = domChanges(doc,helper);helper = domChanges$1(doc,helper,SVG_NAMESPACE);var helper$1=helper;var DOMTreeConstruction=DOM.DOMTreeConstruction;function defaultManagers(element,attr,_isTrusting,_namespace){var tagName=element.tagName;var isSVG=element.namespaceURI === SVG_NAMESPACE;if(isSVG){return defaultAttributeManagers(tagName,attr);}var _normalizeProperty=normalizeProperty(element,attr);var type=_normalizeProperty.type;var normalized=_normalizeProperty.normalized;if(type === 'attr'){return defaultAttributeManagers(tagName,normalized);}else {return defaultPropertyManagers(tagName,normalized);}}function defaultPropertyManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafePropertyManager(attr);}if(isUserInputValue(tagName,attr)){return INPUT_VALUE_PROPERTY_MANAGER;}if(isOptionSelected(tagName,attr)){return OPTION_SELECTED_MANAGER;}return new PropertyManager(attr);}function defaultAttributeManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafeAttributeManager(attr);}return new AttributeManager(attr);}function readDOMAttr(element,attr){var isSVG=element.namespaceURI === SVG_NAMESPACE;var _normalizeProperty2=normalizeProperty(element,attr);var type=_normalizeProperty2.type;var normalized=_normalizeProperty2.normalized;if(isSVG){return element.getAttribute(normalized);}if(type === 'attr'){return element.getAttribute(normalized);}{return element[normalized];}};var AttributeManager=(function(){function AttributeManager(attr){this.attr = attr;}AttributeManager.prototype.setAttribute = function setAttribute(env,element,value,namespace){var dom=env.getAppendOperations();var normalizedValue=normalizeAttributeValue(value);if(!isAttrRemovalValue(normalizedValue)){dom.setAttribute(element,this.attr,normalizedValue,namespace);}};AttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){if(value === null || value === undefined || value === false){if(namespace){env.getDOM().removeAttributeNS(element,namespace,this.attr);}else {env.getDOM().removeAttribute(element,this.attr);}}else {this.setAttribute(env,element,value);}};return AttributeManager;})();;var PropertyManager=(function(_AttributeManager){babelHelpers.inherits(PropertyManager,_AttributeManager);function PropertyManager(){_AttributeManager.apply(this,arguments);}PropertyManager.prototype.setAttribute = function setAttribute(_env,element,value,_namespace){if(!isAttrRemovalValue(value)){element[this.attr] = value;}};PropertyManager.prototype.removeAttribute = function removeAttribute(env,element,namespace){ // TODO this sucks but to preserve properties first and to meet current +// semantics we must do this. +var attr=this.attr;if(namespace){env.getDOM().removeAttributeNS(element,namespace,attr);}else {env.getDOM().removeAttribute(element,attr);}};PropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){ // ensure the property is always updated +element[this.attr] = value;if(isAttrRemovalValue(value)){this.removeAttribute(env,element,namespace);}};return PropertyManager;})(AttributeManager);;function normalizeAttributeValue(value){if(value === false || value === undefined || value === null){return null;}if(value === true){return '';} // onclick function etc in SSR +if(typeof value === 'function'){return null;}return String(value);}function isAttrRemovalValue(value){return value === null || value === undefined;}var SafePropertyManager=(function(_PropertyManager){babelHelpers.inherits(SafePropertyManager,_PropertyManager);function SafePropertyManager(){_PropertyManager.apply(this,arguments);}SafePropertyManager.prototype.setAttribute = function setAttribute(env,element,value){_PropertyManager.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafePropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value){_PropertyManager.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafePropertyManager;})(PropertyManager);function isUserInputValue(tagName,attribute){return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value';}var InputValuePropertyManager=(function(_AttributeManager2){babelHelpers.inherits(InputValuePropertyManager,_AttributeManager2);function InputValuePropertyManager(){_AttributeManager2.apply(this,arguments);}InputValuePropertyManager.prototype.setAttribute = function setAttribute(_env,element,value){var input=element;input.value = normalizeTextValue(value);};InputValuePropertyManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var input=element;var currentValue=input.value;var normalizedValue=normalizeTextValue(value);if(currentValue !== normalizedValue){input.value = normalizedValue;}};return InputValuePropertyManager;})(AttributeManager);var INPUT_VALUE_PROPERTY_MANAGER=new InputValuePropertyManager('value');function isOptionSelected(tagName,attribute){return tagName === 'OPTION' && attribute === 'selected';}var OptionSelectedManager=(function(_PropertyManager2){babelHelpers.inherits(OptionSelectedManager,_PropertyManager2);function OptionSelectedManager(){_PropertyManager2.apply(this,arguments);}OptionSelectedManager.prototype.setAttribute = function setAttribute(_env,element,value){if(value !== null && value !== undefined && value !== false){var option=element;option.selected = true;}};OptionSelectedManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var option=element;if(value){option.selected = true;}else {option.selected = false;}};return OptionSelectedManager;})(PropertyManager);var OPTION_SELECTED_MANAGER=new OptionSelectedManager('selected');var SafeAttributeManager=(function(_AttributeManager3){babelHelpers.inherits(SafeAttributeManager,_AttributeManager3);function SafeAttributeManager(){_AttributeManager3.apply(this,arguments);}SafeAttributeManager.prototype.setAttribute = function setAttribute(env,element,value){_AttributeManager3.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafeAttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,_namespace){_AttributeManager3.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafeAttributeManager;})(AttributeManager);var Scope=(function(){function Scope(references){var callerScope=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];this.callerScope = null;this.slots = references;this.callerScope = callerScope;}Scope.root = function root(self){var size=arguments.length <= 1 || arguments[1] === undefined?0:arguments[1];var refs=new Array(size + 1);for(var i=0;i <= size;i++) {refs[i] = UNDEFINED_REFERENCE;}return new Scope(refs).init({self:self});};Scope.prototype.init = function init(_ref26){var self=_ref26.self;this.slots[0] = self;return this;};Scope.prototype.getSelf = function getSelf(){return this.slots[0];};Scope.prototype.getSymbol = function getSymbol(symbol){return this.slots[symbol];};Scope.prototype.getBlock = function getBlock(symbol){return this.slots[symbol];};Scope.prototype.getPartialArgs = function getPartialArgs(symbol){return this.slots[symbol];};Scope.prototype.bindSymbol = function bindSymbol(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindBlock = function bindBlock(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindPartialArgs = function bindPartialArgs(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindCallerScope = function bindCallerScope(scope){this.callerScope = scope;};Scope.prototype.getCallerScope = function getCallerScope(){return this.callerScope;};Scope.prototype.child = function child(){return new Scope(this.slots.slice(),this.callerScope);};return Scope;})();var Transaction=(function(){function Transaction(){this.scheduledInstallManagers = [];this.scheduledInstallModifiers = [];this.scheduledUpdateModifierManagers = [];this.scheduledUpdateModifiers = [];this.createdComponents = [];this.createdManagers = [];this.updatedComponents = [];this.updatedManagers = [];this.destructors = [];}Transaction.prototype.didCreate = function didCreate(component,manager){this.createdComponents.push(component);this.createdManagers.push(manager);};Transaction.prototype.didUpdate = function didUpdate(component,manager){this.updatedComponents.push(component);this.updatedManagers.push(manager);};Transaction.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.scheduledInstallManagers.push(manager);this.scheduledInstallModifiers.push(modifier);};Transaction.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.scheduledUpdateModifierManagers.push(manager);this.scheduledUpdateModifiers.push(modifier);};Transaction.prototype.didDestroy = function didDestroy(d){this.destructors.push(d);};Transaction.prototype.commit = function commit(){var createdComponents=this.createdComponents;var createdManagers=this.createdManagers;for(var i=0;i < createdComponents.length;i++) {var component=createdComponents[i];var manager=createdManagers[i];manager.didCreate(component);}var updatedComponents=this.updatedComponents;var updatedManagers=this.updatedManagers;for(var i=0;i < updatedComponents.length;i++) {var component=updatedComponents[i];var manager=updatedManagers[i];manager.didUpdate(component);}var destructors=this.destructors;for(var i=0;i < destructors.length;i++) {destructors[i].destroy();}var scheduledInstallManagers=this.scheduledInstallManagers;var scheduledInstallModifiers=this.scheduledInstallModifiers;for(var i=0;i < scheduledInstallManagers.length;i++) {var manager=scheduledInstallManagers[i];var modifier=scheduledInstallModifiers[i];manager.install(modifier);}var scheduledUpdateModifierManagers=this.scheduledUpdateModifierManagers;var scheduledUpdateModifiers=this.scheduledUpdateModifiers;for(var i=0;i < scheduledUpdateModifierManagers.length;i++) {var manager=scheduledUpdateModifierManagers[i];var modifier=scheduledUpdateModifiers[i];manager.update(modifier);}};return Transaction;})();var Opcode=(function(){function Opcode(array){this.array = array;this.offset = 0;}babelHelpers.createClass(Opcode,[{key:'type',get:function(){return this.array[this.offset];}},{key:'op1',get:function(){return this.array[this.offset + 1];}},{key:'op2',get:function(){return this.array[this.offset + 2];}},{key:'op3',get:function(){return this.array[this.offset + 3];}}]);return Opcode;})();var Program=(function(){function Program(){this.opcodes = new _glimmerUtil.A(0x100000);this._offset = 0;this._opcode = new Opcode(this.opcodes);}Program.prototype.opcode = function opcode(offset){this._opcode.offset = offset;return this._opcode;};Program.prototype.set = function set(pos,opcode){var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[pos] = type;this.opcodes[pos + 1] = op1;this.opcodes[pos + 2] = op2;this.opcodes[pos + 3] = op3;};Program.prototype.push = function push(opcode){var offset=this._offset;var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[this._offset++] = type;this.opcodes[this._offset++] = op1;this.opcodes[this._offset++] = op2;this.opcodes[this._offset++] = op3;return offset;};babelHelpers.createClass(Program,[{key:'next',get:function(){return this._offset;}},{key:'current',get:function(){return this._offset - 4;}}]);return Program;})();var Environment=(function(){function Environment(_ref27){var appendOperations=_ref27.appendOperations;var updateOperations=_ref27.updateOperations;this._macros = null;this._transaction = null;this.constants = new Constants();this.program = new Program();this.appendOperations = appendOperations;this.updateOperations = updateOperations;}Environment.prototype.toConditionalReference = function toConditionalReference(reference){return new ConditionalReference(reference);};Environment.prototype.getAppendOperations = function getAppendOperations(){return this.appendOperations;};Environment.prototype.getDOM = function getDOM(){return this.updateOperations;};Environment.prototype.getIdentity = function getIdentity(object){return _glimmerUtil.ensureGuid(object) + '';};Environment.prototype.begin = function begin(){_glimmerUtil.assert(!this._transaction,'Cannot start a nested transaction');this._transaction = new Transaction();};Environment.prototype.didCreate = function didCreate(component,manager){this.transaction.didCreate(component,manager);};Environment.prototype.didUpdate = function didUpdate(component,manager){this.transaction.didUpdate(component,manager);};Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.transaction.scheduleInstallModifier(modifier,manager);};Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.transaction.scheduleUpdateModifier(modifier,manager);};Environment.prototype.didDestroy = function didDestroy(d){this.transaction.didDestroy(d);};Environment.prototype.commit = function commit(){this.transaction.commit();this._transaction = null;};Environment.prototype.attributeFor = function attributeFor(element,attr,isTrusting,namespace){return defaultManagers(element,attr,isTrusting,namespace === undefined?null:namespace);};Environment.prototype.macros = function macros(){var macros=this._macros;if(!macros){this._macros = macros = populateBuiltins();}return macros;};babelHelpers.createClass(Environment,[{key:'transaction',get:function(){return _glimmerUtil.expect(this._transaction,'must be in a transaction');}}]);return Environment;})();var RenderResult=(function(){function RenderResult(env,updating,bounds){this.env = env;this.updating = updating;this.bounds = bounds;}RenderResult.prototype.rerender = function rerender(){var _ref28=arguments.length <= 0 || arguments[0] === undefined?{alwaysRevalidate:false}:arguments[0];var _ref28$alwaysRevalidate=_ref28.alwaysRevalidate;var alwaysRevalidate=_ref28$alwaysRevalidate === undefined?false:_ref28$alwaysRevalidate;var env=this.env;var updating=this.updating;var vm=new UpdatingVM(env,{alwaysRevalidate:alwaysRevalidate});vm.execute(updating,this);};RenderResult.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};RenderResult.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};RenderResult.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};RenderResult.prototype.opcodes = function opcodes(){return this.updating;};RenderResult.prototype.handleException = function handleException(){throw "this should never happen";};RenderResult.prototype.destroy = function destroy(){this.bounds.destroy();clear(this.bounds);};return RenderResult;})();var CapturedFrame=function CapturedFrame(operand,args,condition){this.operand = operand;this.args = args;this.condition = condition;};var Frame=(function(){function Frame(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];this.ops = ops;this.component = component;this.manager = manager;this.shadow = shadow;this.operand = null;this.immediate = null;this.args = null;this.callerScope = null;this.blocks = null;this.condition = null;this.iterator = null;this.key = null;this.ip = ops[0];}Frame.prototype.capture = function capture(){return new CapturedFrame(this.operand,this.args,this.condition);};Frame.prototype.restore = function restore(frame){this.operand = frame['operand'];this.args = frame['args'];this.condition = frame['condition'];};return Frame;})();var FrameStack=(function(){function FrameStack(){this.frames = [];this.frame = null;}FrameStack.prototype.push = function push(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var frame=this.frame === null?this.frame = 0:++this.frame;if(this.frames.length <= frame){this.frames.push(null);}this.frames[frame] = new Frame(ops,component,manager,shadow);};FrameStack.prototype.pop = function pop(){var frames=this.frames;var frame=this.frame;frames[_glimmerUtil.expect(frame,'only pop after pushing')] = null;this.frame = frame === 0?null:frame - 1;};FrameStack.prototype.capture = function capture(){return this.currentFrame.capture();};FrameStack.prototype.restore = function restore(frame){this.currentFrame.restore(frame);};FrameStack.prototype.getOps = function getOps(){return this.currentFrame.ops;};FrameStack.prototype.getCurrent = function getCurrent(){return this.currentFrame.ip;};FrameStack.prototype.setCurrent = function setCurrent(ip){return this.currentFrame.ip = ip;};FrameStack.prototype.getOperand = function getOperand(){return _glimmerUtil.unwrap(this.currentFrame.operand);};FrameStack.prototype.setOperand = function setOperand(operand){return this.currentFrame.operand = operand;};FrameStack.prototype.getImmediate = function getImmediate(){return this.currentFrame.immediate;};FrameStack.prototype.setImmediate = function setImmediate(value){return this.currentFrame.immediate = value;}; // FIXME: These options are required in practice by the existing code, but +// figure out why. +FrameStack.prototype.getArgs = function getArgs(){return this.currentFrame.args;};FrameStack.prototype.setArgs = function setArgs(args){return this.currentFrame.args = args;};FrameStack.prototype.getCondition = function getCondition(){return _glimmerUtil.unwrap(this.currentFrame.condition);};FrameStack.prototype.setCondition = function setCondition(condition){return this.currentFrame.condition = condition;};FrameStack.prototype.getIterator = function getIterator(){return _glimmerUtil.unwrap(this.currentFrame.iterator);};FrameStack.prototype.setIterator = function setIterator(iterator){return this.currentFrame.iterator = iterator;};FrameStack.prototype.getKey = function getKey(){return this.currentFrame.key;};FrameStack.prototype.setKey = function setKey(key){return this.currentFrame.key = key;};FrameStack.prototype.getBlocks = function getBlocks(){return _glimmerUtil.unwrap(this.currentFrame.blocks);};FrameStack.prototype.setBlocks = function setBlocks(blocks){return this.currentFrame.blocks = blocks;};FrameStack.prototype.getCallerScope = function getCallerScope(){return _glimmerUtil.unwrap(this.currentFrame.callerScope);};FrameStack.prototype.setCallerScope = function setCallerScope(callerScope){return this.currentFrame.callerScope = callerScope;};FrameStack.prototype.getComponent = function getComponent(){return _glimmerUtil.unwrap(this.currentFrame.component);};FrameStack.prototype.getManager = function getManager(){return _glimmerUtil.unwrap(this.currentFrame.manager);};FrameStack.prototype.getShadow = function getShadow(){return this.currentFrame.shadow;};FrameStack.prototype.goto = function goto(ip){this.setCurrent(ip);};FrameStack.prototype.hasOpcodes = function hasOpcodes(){return this.frame !== null;};FrameStack.prototype.nextStatement = function nextStatement(env){var ip=this.frames[_glimmerUtil.unwrap(this.frame)].ip;var ops=this.getOps();if(ip <= ops[1]){var program=env.program;this.setCurrent(ip + 4);return program.opcode(ip);}else {this.pop();return null;}};babelHelpers.createClass(FrameStack,[{key:'currentFrame',get:function(){return this.frames[_glimmerUtil.unwrap(this.frame)];}}]);return FrameStack;})();var VM=(function(){function VM(env,scope,dynamicScope,elementStack){this.env = env;this.elementStack = elementStack;this.dynamicScopeStack = new _glimmerUtil.Stack();this.scopeStack = new _glimmerUtil.Stack();this.updatingOpcodeStack = new _glimmerUtil.Stack();this.cacheGroups = new _glimmerUtil.Stack();this.listBlockStack = new _glimmerUtil.Stack();this.frame = new FrameStack();this.env = env;this.constants = env.constants;this.elementStack = elementStack;this.scopeStack.push(scope);this.dynamicScopeStack.push(dynamicScope);}VM.initial = function initial(env,self,dynamicScope,elementStack,size){var scope=Scope.root(self,size);return new VM(env,scope,dynamicScope,elementStack);};VM.prototype.capture = function capture(){return {env:this.env,scope:this.scope(),dynamicScope:this.dynamicScope(),frame:this.frame.capture()};};VM.prototype.goto = function goto(ip){ // assert(this.frame.getOps().contains(op), `Illegal jump to ${op.label}`); +this.frame.goto(ip);};VM.prototype.beginCacheGroup = function beginCacheGroup(){this.cacheGroups.push(this.updating().tail());};VM.prototype.commitCacheGroup = function commitCacheGroup(){ // JumpIfNotModified(END) +// (head) +// (....) +// (tail) +// DidModify +// END: Noop +var END=new LabelOpcode("END");var opcodes=this.updating();var marker=this.cacheGroups.pop();var head=marker?opcodes.nextNode(marker):opcodes.head();var tail=opcodes.tail();var tag=_glimmerReference.combineSlice(new _glimmerUtil.ListSlice(head,tail));var guard=new JumpIfNotModifiedOpcode(tag,END);opcodes.insertBefore(guard,head);opcodes.append(new DidModifyOpcode(guard));opcodes.append(END);};VM.prototype.enter = function enter(sliceId){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var slice=this.constants.getSlice(sliceId);var tryOpcode=new TryOpcode(slice,state,tracker,updating);this.didEnter(tryOpcode,updating);};VM.prototype.enterWithKey = function enterWithKey(key,ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var tryOpcode=new TryOpcode(ops,state,tracker,updating);this.listBlock().map[key] = tryOpcode;this.didEnter(tryOpcode,updating);};VM.prototype.enterList = function enterList(ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushBlockList(updating);var state=this.capture();var artifacts=this.frame.getIterator().artifacts;var opcode=new ListBlockOpcode(ops,state,tracker,updating,artifacts);this.listBlockStack.push(opcode);this.didEnter(opcode,updating);};VM.prototype.didEnter = function didEnter(opcode,updating){this.updateWith(opcode);this.updatingOpcodeStack.push(updating);};VM.prototype.exit = function exit(){this.stack().popBlock();this.updatingOpcodeStack.pop();var parent=this.updating().tail();parent.didInitializeChildren();};VM.prototype.exitList = function exitList(){this.exit();this.listBlockStack.pop();};VM.prototype.updateWith = function updateWith(opcode){this.updating().append(opcode);};VM.prototype.listBlock = function listBlock(){return _glimmerUtil.expect(this.listBlockStack.current,'expected a list block');};VM.prototype.updating = function updating(){return _glimmerUtil.expect(this.updatingOpcodeStack.current,'expected updating opcode on the updating opcode stack');};VM.prototype.stack = function stack(){return this.elementStack;};VM.prototype.scope = function scope(){return _glimmerUtil.expect(this.scopeStack.current,'expected scope on the scope stack');};VM.prototype.dynamicScope = function dynamicScope(){return _glimmerUtil.expect(this.dynamicScopeStack.current,'expected dynamic scope on the dynamic scope stack');};VM.prototype.pushFrame = function pushFrame(block,args,callerScope){this.frame.push(block.slice);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushComponentFrame = function pushComponentFrame(layout,args,callerScope,component,manager,shadow){this.frame.push(layout.slice,component,manager,shadow);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushEvalFrame = function pushEvalFrame(slice){this.frame.push(slice);};VM.prototype.pushChildScope = function pushChildScope(){this.scopeStack.push(this.scope().child());};VM.prototype.pushCallerScope = function pushCallerScope(){this.scopeStack.push(_glimmerUtil.expect(this.scope().getCallerScope(),'pushCallerScope is called when a caller scope is present'));};VM.prototype.pushDynamicScope = function pushDynamicScope(){var child=this.dynamicScope().child();this.dynamicScopeStack.push(child);return child;};VM.prototype.pushRootScope = function pushRootScope(self,size){var scope=Scope.root(self,size);this.scopeStack.push(scope);return scope;};VM.prototype.popScope = function popScope(){this.scopeStack.pop();};VM.prototype.popDynamicScope = function popDynamicScope(){this.dynamicScopeStack.pop();};VM.prototype.newDestroyable = function newDestroyable(d){this.stack().newDestroyable(d);}; /// SCOPE HELPERS +VM.prototype.getSelf = function getSelf(){return this.scope().getSelf();};VM.prototype.referenceForSymbol = function referenceForSymbol(symbol){return this.scope().getSymbol(symbol);};VM.prototype.getArgs = function getArgs(){return this.frame.getArgs();}; /// EXECUTION +VM.prototype.resume = function resume(opcodes,frame){return this.execute(opcodes,function(vm){return vm.frame.restore(frame);});};VM.prototype.execute = function execute(opcodes,initialize){_glimmerUtil.LOGGER.debug("[VM] Begin program execution");var elementStack=this.elementStack;var frame=this.frame;var updatingOpcodeStack=this.updatingOpcodeStack;var env=this.env;elementStack.pushSimpleBlock();updatingOpcodeStack.push(new _glimmerUtil.LinkedList());frame.push(opcodes);if(initialize)initialize(this);var opcode=undefined;while(frame.hasOpcodes()) {if(opcode = frame.nextStatement(this.env)){_glimmerUtil.LOGGER.trace(opcode);APPEND_OPCODES.evaluate(this,opcode);}}_glimmerUtil.LOGGER.debug("[VM] Completed program execution");return new RenderResult(env,_glimmerUtil.expect(updatingOpcodeStack.pop(),'there should be a final updating opcode stack'),elementStack.popBlock());};VM.prototype.evaluateOpcode = function evaluateOpcode(opcode){APPEND_OPCODES.evaluate(this,opcode);}; // Make sure you have opcodes that push and pop a scope around this opcode +// if you need to change the scope. +VM.prototype.invokeBlock = function invokeBlock(block,args){var compiled=block.compile(this.env);this.pushFrame(compiled,args);};VM.prototype.invokePartial = function invokePartial(block){var compiled=block.compile(this.env);this.pushFrame(compiled);};VM.prototype.invokeLayout = function invokeLayout(args,layout,callerScope,component,manager,shadow){this.pushComponentFrame(layout,args,callerScope,component,manager,shadow);};VM.prototype.evaluateOperand = function evaluateOperand(expr){this.frame.setOperand(expr.evaluate(this));};VM.prototype.evaluateArgs = function evaluateArgs(args){var evaledArgs=this.frame.setArgs(args.evaluate(this));this.frame.setOperand(evaledArgs.positional.at(0));};VM.prototype.bindPositionalArgs = function bindPositionalArgs(symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPositionalArgs assumes a previous setArgs');var positional=args.positional;var scope=this.scope();for(var i=0;i < symbols.length;i++) {scope.bindSymbol(symbols[i],positional.at(i));}};VM.prototype.bindNamedArgs = function bindNamedArgs(names,symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindNamedArgs assumes a previous setArgs');var scope=this.scope();var named=args.named;for(var i=0;i < names.length;i++) {var _name2=this.constants.getString(names[i]);scope.bindSymbol(symbols[i],named.get(_name2));}};VM.prototype.bindBlocks = function bindBlocks(names,symbols){var blocks=this.frame.getBlocks();var scope=this.scope();for(var i=0;i < names.length;i++) {var _name3=this.constants.getString(names[i]);scope.bindBlock(symbols[i],blocks && blocks[_name3] || null);}};VM.prototype.bindPartialArgs = function bindPartialArgs(symbol){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPartialArgs assumes a previous setArgs');var scope=this.scope();_glimmerUtil.assert(args,"Cannot bind named args");scope.bindPartialArgs(symbol,args);};VM.prototype.bindCallerScope = function bindCallerScope(){var callerScope=this.frame.getCallerScope();var scope=this.scope();_glimmerUtil.assert(callerScope,"Cannot bind caller scope");scope.bindCallerScope(callerScope);};VM.prototype.bindDynamicScope = function bindDynamicScope(names){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindDynamicScope assumes a previous setArgs');var scope=this.dynamicScope();_glimmerUtil.assert(args,"Cannot bind dynamic scope");for(var i=0;i < names.length;i++) {var _name4=this.constants.getString(names[i]);scope.set(_name4,args.named.get(_name4));}};return VM;})();var UpdatingVM=(function(){function UpdatingVM(env,_ref29){var _ref29$alwaysRevalidate=_ref29.alwaysRevalidate;var alwaysRevalidate=_ref29$alwaysRevalidate === undefined?false:_ref29$alwaysRevalidate;this.frameStack = new _glimmerUtil.Stack();this.env = env;this.constants = env.constants;this.dom = env.getDOM();this.alwaysRevalidate = alwaysRevalidate;}UpdatingVM.prototype.execute = function execute(opcodes,handler){var frameStack=this.frameStack;this.try(opcodes,handler);while(true) {if(frameStack.isEmpty())break;var opcode=this.frame.nextStatement();if(opcode === null){this.frameStack.pop();continue;}_glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type);_glimmerUtil.LOGGER.trace(opcode);opcode.evaluate(this);}};UpdatingVM.prototype.goto = function goto(op){this.frame.goto(op);};UpdatingVM.prototype.try = function _try(ops,handler){this.frameStack.push(new UpdatingVMFrame(this,ops,handler));};UpdatingVM.prototype.throw = function _throw(){this.frame.handleException();this.frameStack.pop();};UpdatingVM.prototype.evaluateOpcode = function evaluateOpcode(opcode){opcode.evaluate(this);};babelHelpers.createClass(UpdatingVM,[{key:'frame',get:function(){return _glimmerUtil.expect(this.frameStack.current,'bug: expected a frame');}}]);return UpdatingVM;})();var BlockOpcode=(function(_UpdatingOpcode8){babelHelpers.inherits(BlockOpcode,_UpdatingOpcode8);function BlockOpcode(ops,state,bounds,children){_UpdatingOpcode8.call(this);this.ops = ops;this.type = "block";this.next = null;this.prev = null;var env=state.env;var scope=state.scope;var dynamicScope=state.dynamicScope;var frame=state.frame;this.children = children;this.env = env;this.scope = scope;this.dynamicScope = dynamicScope;this.frame = frame;this.bounds = bounds;}BlockOpcode.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};BlockOpcode.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};BlockOpcode.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};BlockOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,null);};BlockOpcode.prototype.destroy = function destroy(){this.bounds.destroy();};BlockOpcode.prototype.didDestroy = function didDestroy(){this.env.didDestroy(this.bounds);};BlockOpcode.prototype.toJSON = function toJSON(){var details=_glimmerUtil.dict();details["guid"] = '' + this._guid;return {guid:this._guid,type:this.type,details:details,children:this.children.toArray().map(function(op){return op.toJSON();})};};return BlockOpcode;})(UpdatingOpcode);var TryOpcode=(function(_BlockOpcode){babelHelpers.inherits(TryOpcode,_BlockOpcode);function TryOpcode(ops,state,bounds,children){_BlockOpcode.call(this,ops,state,bounds,children);this.type = "try";this.tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);}TryOpcode.prototype.didInitializeChildren = function didInitializeChildren(){this._tag.update(_glimmerReference.combineSlice(this.children));};TryOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,this);};TryOpcode.prototype.handleException = function handleException(){var env=this.env;var scope=this.scope;var ops=this.ops;var dynamicScope=this.dynamicScope;var frame=this.frame;var elementStack=ElementStack.resume(this.env,this.bounds,this.bounds.reset(env));var vm=new VM(env,scope,dynamicScope,elementStack);var result=vm.resume(ops,frame);this.children = result.opcodes();this.didInitializeChildren();};TryOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode.prototype.toJSON.call(this);var details=json["details"];if(!details){details = json["details"] = {};}return _BlockOpcode.prototype.toJSON.call(this);};return TryOpcode;})(BlockOpcode);var ListRevalidationDelegate=(function(){function ListRevalidationDelegate(opcode,marker){this.opcode = opcode;this.marker = marker;this.didInsert = false;this.didDelete = false;this.map = opcode.map;this.updating = opcode['children'];}ListRevalidationDelegate.prototype.insert = function insert(key,item,memo,before){var map=this.map;var opcode=this.opcode;var updating=this.updating;var nextSibling=null;var reference=null;if(before){reference = map[before];nextSibling = reference['bounds'].firstNode();}else {nextSibling = this.marker;}var vm=opcode.vmForInsertion(nextSibling);var tryOpcode=null;vm.execute(opcode.ops,function(vm){vm.frame.setArgs(EvaluatedArgs.positional([item,memo]));vm.frame.setOperand(item);vm.frame.setCondition(new _glimmerReference.ConstReference(true));vm.frame.setKey(key);var state=vm.capture();var tracker=vm.stack().pushUpdatableBlock();tryOpcode = new TryOpcode(opcode.ops,state,tracker,vm.updating());});tryOpcode.didInitializeChildren();updating.insertBefore(tryOpcode,reference);map[key] = tryOpcode;this.didInsert = true;};ListRevalidationDelegate.prototype.retain = function retain(_key,_item,_memo){};ListRevalidationDelegate.prototype.move = function move(key,_item,_memo,before){var map=this.map;var updating=this.updating;var entry=map[key];var reference=map[before] || null;if(before){moveBounds(entry,reference.firstNode());}else {moveBounds(entry,this.marker);}updating.remove(entry);updating.insertBefore(entry,reference);};ListRevalidationDelegate.prototype.delete = function _delete(key){var map=this.map;var opcode=map[key];opcode.didDestroy();clear(opcode);this.updating.remove(opcode);delete map[key];this.didDelete = true;};ListRevalidationDelegate.prototype.done = function done(){this.opcode.didInitializeChildren(this.didInsert || this.didDelete);};return ListRevalidationDelegate;})();var ListBlockOpcode=(function(_BlockOpcode2){babelHelpers.inherits(ListBlockOpcode,_BlockOpcode2);function ListBlockOpcode(ops,state,bounds,children,artifacts){_BlockOpcode2.call(this,ops,state,bounds,children);this.type = "list-block";this.map = _glimmerUtil.dict();this.lastIterated = _glimmerReference.INITIAL;this.artifacts = artifacts;var _tag=this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([artifacts.tag,_tag]);}ListBlockOpcode.prototype.didInitializeChildren = function didInitializeChildren(){var listDidChange=arguments.length <= 0 || arguments[0] === undefined?true:arguments[0];this.lastIterated = this.artifacts.tag.value();if(listDidChange){this._tag.update(_glimmerReference.combineSlice(this.children));}};ListBlockOpcode.prototype.evaluate = function evaluate(vm){var artifacts=this.artifacts;var lastIterated=this.lastIterated;if(!artifacts.tag.validate(lastIterated)){var bounds=this.bounds;var dom=vm.dom;var marker=dom.createComment('');dom.insertAfter(bounds.parentElement(),marker,_glimmerUtil.expect(bounds.lastNode(),"can't insert after an empty bounds"));var target=new ListRevalidationDelegate(this,marker);var synchronizer=new _glimmerReference.IteratorSynchronizer({target:target,artifacts:artifacts});synchronizer.sync();this.parentElement().removeChild(marker);} // Run now-updated updating opcodes +_BlockOpcode2.prototype.evaluate.call(this,vm);};ListBlockOpcode.prototype.vmForInsertion = function vmForInsertion(nextSibling){var env=this.env;var scope=this.scope;var dynamicScope=this.dynamicScope;var elementStack=ElementStack.forInitialRender(this.env,this.bounds.parentElement(),nextSibling);return new VM(env,scope,dynamicScope,elementStack);};ListBlockOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode2.prototype.toJSON.call(this);var map=this.map;var inner=Object.keys(map).map(function(key){return JSON.stringify(key) + ': ' + map[key]._guid;}).join(", ");var details=json["details"];if(!details){details = json["details"] = {};}details["map"] = '{' + inner + '}';return json;};return ListBlockOpcode;})(BlockOpcode);var UpdatingVMFrame=(function(){function UpdatingVMFrame(vm,ops,exceptionHandler){this.vm = vm;this.ops = ops;this.exceptionHandler = exceptionHandler;this.vm = vm;this.ops = ops;this.current = ops.head();}UpdatingVMFrame.prototype.goto = function goto(op){this.current = op;};UpdatingVMFrame.prototype.nextStatement = function nextStatement(){var current=this.current;var ops=this.ops;if(current)this.current = ops.nextNode(current);return current;};UpdatingVMFrame.prototype.handleException = function handleException(){if(this.exceptionHandler){this.exceptionHandler.handleException();}};return UpdatingVMFrame;})();var CompiledBlock=function CompiledBlock(slice){this.start = slice[0];this.end = slice[1];this.slice = slice;};var CompiledProgram=(function(_CompiledBlock){babelHelpers.inherits(CompiledProgram,_CompiledBlock);function CompiledProgram(slice,symbols){_CompiledBlock.call(this,slice);this.symbols = symbols;}return CompiledProgram;})(CompiledBlock);function entryPoint(meta){return new ProgramSymbolTable(meta);}function layout(meta,wireNamed,wireYields,hasPartials){var _symbols3=symbols(wireNamed,wireYields,hasPartials);var named=_symbols3.named;var yields=_symbols3.yields;var partialSymbol=_symbols3.partialSymbol;var size=_symbols3.size;return new ProgramSymbolTable(meta,named,yields,partialSymbol,size);}function block(parent,locals){var localsMap=null;var program=parent['program'];if(locals.length !== 0){(function(){var map=localsMap = _glimmerUtil.dict();locals.forEach(function(l){return map[l] = program.size++;});})();}return new BlockSymbolTable(parent,program,localsMap);}function symbols(named,yields,hasPartials){var yieldsMap=null;var namedMap=null;var size=1;if(yields.length !== 0){(function(){var map=yieldsMap = _glimmerUtil.dict();yields.forEach(function(y){return map[y] = size++;});})();}if(named.length !== 0){(function(){var map=namedMap = _glimmerUtil.dict();named.forEach(function(y){return map[y] = size++;});})();}var partialSymbol=hasPartials?size++:null;return {named:namedMap,yields:yieldsMap,partialSymbol:partialSymbol,size:size};}var ProgramSymbolTable=(function(){function ProgramSymbolTable(meta){var named=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var yields=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var partialArgs=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var size=arguments.length <= 4 || arguments[4] === undefined?1:arguments[4];this.meta = meta;this.named = named;this.yields = yields;this.partialArgs = partialArgs;this.size = size;this.program = this;}ProgramSymbolTable.prototype.getMeta = function getMeta(){return this.meta;};ProgramSymbolTable.prototype.getSymbols = function getSymbols(){return {named:this.named,yields:this.yields,locals:null,partialArgs:this.partialArgs};};ProgramSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local')return null;return this[kind] && this[kind][name];};ProgramSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.partialArgs || 0;};return ProgramSymbolTable;})();var BlockSymbolTable=(function(){function BlockSymbolTable(parent,program,locals){this.parent = parent;this.program = program;this.locals = locals;}BlockSymbolTable.prototype.getMeta = function getMeta(){return this.program.getMeta();};BlockSymbolTable.prototype.getSymbols = function getSymbols(){return {named:null,yields:null,locals:this.locals,partialArgs:null};};BlockSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local'){return this.getLocal(name);}else {return this.program.getSymbol(kind,name);}};BlockSymbolTable.prototype.getLocal = function getLocal(name){var locals=this.locals;var parent=this.parent;var symbol=locals && locals[name];if(!symbol && parent){symbol = parent.getSymbol('local',name);}return symbol;};BlockSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.program.getPartialArgs();};return BlockSymbolTable;})();var Specialize=(function(){function Specialize(){this.names = _glimmerUtil.dict();this.funcs = [];}Specialize.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Specialize.prototype.specialize = function specialize(sexp,table){var name=sexp[0];var index=this.names[name];if(index === undefined)return sexp;var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected a specialization for ' + sexp[0]);return func(sexp,table);};return Specialize;})();var SPECIALIZE=new Specialize();var E=_glimmerWireFormat.Expressions;SPECIALIZE.add('append',function(sexp,_symbolTable){var path=sexp[1];if(Array.isArray(path) && (E.isUnknown(path) || E.isGet(path))){if(path[1].length !== 1){return ['unoptimized-append',sexp[1],sexp[2]];}}return ['optimized-append',sexp[1],sexp[2]];});SPECIALIZE.add('dynamic-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],false];});SPECIALIZE.add('trusting-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],true];});SPECIALIZE.add('partial',function(sexp,_table){var expression=sexp[1];if(typeof expression === 'string'){return ['static-partial',expression];}else {return ['dynamic-partial',expression];}});function compileStatement(statement,builder){var refined=SPECIALIZE.specialize(statement,builder.symbolTable);STATEMENTS.compile(refined,builder);}var Template=function Template(statements,symbolTable){this.statements = statements;this.symbolTable = symbolTable;};var Layout=(function(_Template){babelHelpers.inherits(Layout,_Template);function Layout(){_Template.apply(this,arguments);}return Layout;})(Template);var EntryPoint=(function(_Template2){babelHelpers.inherits(EntryPoint,_Template2);function EntryPoint(){_Template2.apply(this,arguments);}EntryPoint.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),this.symbolTable.size);};return EntryPoint;})(Template);var InlineBlock=(function(_Template3){babelHelpers.inherits(InlineBlock,_Template3);function InlineBlock(){_Template3.apply(this,arguments);}InlineBlock.prototype.splat = function splat(builder){var table=builder.symbolTable;var locals=table.getSymbols().locals;if(locals){builder.pushChildScope();builder.bindPositionalArgsForLocals(locals);}for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,builder);}if(locals){builder.popScope();}};InlineBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);this.splat(b);return new CompiledBlock(b.toSlice());};return InlineBlock;})(Template);var PartialBlock=(function(_Template4){babelHelpers.inherits(PartialBlock,_Template4);function PartialBlock(){_Template4.apply(this,arguments);}PartialBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),table.size);};return PartialBlock;})(Template);var Scanner=(function(){function Scanner(block,meta,env){this.block = block;this.meta = meta;this.env = env;}Scanner.prototype.scanEntryPoint = function scanEntryPoint(){var block=this.block;var meta=this.meta;var symbolTable=entryPoint(meta);var child=scanBlock(block,symbolTable,this.env);return new EntryPoint(child.statements,symbolTable);};Scanner.prototype.scanLayout = function scanLayout(){var block=this.block;var meta=this.meta;var named=block.named;var yields=block.yields;var hasPartials=block.hasPartials;var symbolTable=layout(meta,named,yields,hasPartials);var child=scanBlock(block,symbolTable,this.env);return new Layout(child.statements,symbolTable);};Scanner.prototype.scanPartial = function scanPartial(symbolTable){var block=this.block;var child=scanBlock(block,symbolTable,this.env);return new PartialBlock(child.statements,symbolTable);};return Scanner;})();function scanBlock(_ref30,symbolTable,env){var statements=_ref30.statements;return new RawInlineBlock(env,symbolTable,statements).scan();}var BaselineSyntax;(function(BaselineSyntax){BaselineSyntax.isScannedComponent = _glimmerWireFormat.is('scanned-component');BaselineSyntax.isPrimitiveElement = _glimmerWireFormat.is('open-primitive-element');BaselineSyntax.isOptimizedAppend = _glimmerWireFormat.is('optimized-append');BaselineSyntax.isUnoptimizedAppend = _glimmerWireFormat.is('unoptimized-append');BaselineSyntax.isAnyAttr = _glimmerWireFormat.is('any-dynamic-attr');BaselineSyntax.isStaticPartial = _glimmerWireFormat.is('static-partial');BaselineSyntax.isDynamicPartial = _glimmerWireFormat.is('dynamic-partial');BaselineSyntax.isFunctionExpression = _glimmerWireFormat.is('function');BaselineSyntax.isNestedBlock = _glimmerWireFormat.is('nested-block');BaselineSyntax.isScannedBlock = _glimmerWireFormat.is('scanned-block');BaselineSyntax.isDebugger = _glimmerWireFormat.is('debugger');var NestedBlock;(function(NestedBlock){function defaultBlock(sexp){return sexp[4];}NestedBlock.defaultBlock = defaultBlock;function inverseBlock(sexp){return sexp[5];}NestedBlock.inverseBlock = inverseBlock;function params(sexp){return sexp[2];}NestedBlock.params = params;function hash(sexp){return sexp[3];}NestedBlock.hash = hash;})(NestedBlock = BaselineSyntax.NestedBlock || (BaselineSyntax.NestedBlock = {}));})(BaselineSyntax || (exports.BaselineSyntax = BaselineSyntax = {}));var RawInlineBlock=(function(){function RawInlineBlock(env,table,statements){this.env = env;this.table = table;this.statements = statements;}RawInlineBlock.prototype.scan = function scan(){var buffer=[];for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];if(_glimmerWireFormat.Statements.isBlock(statement)){buffer.push(this.specializeBlock(statement));}else if(_glimmerWireFormat.Statements.isComponent(statement)){buffer.push.apply(buffer,this.specializeComponent(statement));}else {buffer.push(statement);}}return new InlineBlock(buffer,this.table);};RawInlineBlock.prototype.specializeBlock = function specializeBlock(block$$){var path=block$$[1];var params=block$$[2];var hash=block$$[3];var template=block$$[4];var inverse=block$$[5];return ['scanned-block',path,params,hash,this.child(template),this.child(inverse)];};RawInlineBlock.prototype.specializeComponent = function specializeComponent(sexp){var tag=sexp[1];var component=sexp[2];if(this.env.hasComponentDefinition([tag],this.table)){var child=this.child(component);var attrs=new RawInlineBlock(this.env,this.table,component.attrs);return [['scanned-component',tag,attrs,component.args,child]];}else {var buf=[];buf.push(['open-element',tag,[]]);buf.push.apply(buf,component.attrs);buf.push(['flush-element']);buf.push.apply(buf,component.statements);buf.push(['close-element']);return buf;}};RawInlineBlock.prototype.child = function child(block$$){if(!block$$)return null;var table=block(this.table,block$$.locals);return new RawInlineBlock(this.env,table,block$$.statements);};return RawInlineBlock;})();function compileLayout(compilable,env){var builder=new ComponentLayoutBuilder(env);compilable.compile(builder);return builder.compile();}var ComponentLayoutBuilder=(function(){function ComponentLayoutBuilder(env){this.env = env;}ComponentLayoutBuilder.prototype.wrapLayout = function wrapLayout(layout){this.inner = new WrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.fromLayout = function fromLayout(layout){this.inner = new UnwrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.compile = function compile(){return this.inner.compile();};babelHelpers.createClass(ComponentLayoutBuilder,[{key:'tag',get:function(){return this.inner.tag;}},{key:'attrs',get:function(){return this.inner.attrs;}}]);return ComponentLayoutBuilder;})();var WrappedBuilder=(function(){function WrappedBuilder(env,layout){this.env = env;this.layout = layout;this.tag = new ComponentTagBuilder();this.attrs = new ComponentAttrsBuilder();}WrappedBuilder.prototype.compile = function compile(){ //========DYNAMIC +// PutValue(TagExpr) +// Test +// JumpUnless(BODY) +// OpenDynamicPrimitiveElement +// DidCreateElement +// ...attr statements... +// FlushElement +// BODY: Noop +// ...body statements... +// PutValue(TagExpr) +// Test +// JumpUnless(END) +// CloseElement +// END: Noop +// DidRenderLayout +// Exit +// +//========STATIC +// OpenPrimitiveElementOpcode +// DidCreateElement +// ...attr statements... +// FlushElement +// ...body statements... +// CloseElement +// DidRenderLayout +// Exit +var env=this.env;var layout=this.layout;var symbolTable=layout.symbolTable;var b=builder(env,layout.symbolTable);b.startLabels();var dynamicTag=this.tag.getDynamic();var staticTag=undefined;if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('BODY');b.openDynamicPrimitiveElement();b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();b.label('BODY');}else if(staticTag = this.tag.getStatic()){b.openPrimitiveElement(staticTag);b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();}b.preludeForLayout(layout);layout.statements.forEach(function(statement){return compileStatement(statement,b);});if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('END');b.closeElement();b.label('END');}else if(staticTag){b.closeElement();}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),symbolTable.size);};return WrappedBuilder;})();function isOpenElement(value){var type=value[0];return type === 'open-element' || type === 'open-primitive-element';}var UnwrappedBuilder=(function(){function UnwrappedBuilder(env,layout){this.env = env;this.layout = layout;this.attrs = new ComponentAttrsBuilder();}UnwrappedBuilder.prototype.compile = function compile(){var env=this.env;var layout=this.layout;var b=builder(env,layout.symbolTable);b.startLabels();b.preludeForLayout(layout);var attrs=this.attrs['buffer'];var attrsInserted=false;for(var i=0;i < layout.statements.length;i++) {var statement=layout.statements[i];if(!attrsInserted && isOpenElement(statement)){b.openComponentElement(statement[1]);b.didCreateElement();b.shadowAttributes();attrs.forEach(function(statement){return compileStatement(statement,b);});attrsInserted = true;}else {compileStatement(statement,b);}}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),layout.symbolTable.size);};babelHelpers.createClass(UnwrappedBuilder,[{key:'tag',get:function(){throw new Error('BUG: Cannot call `tag` on an UnwrappedBuilder');}}]);return UnwrappedBuilder;})();var ComponentTagBuilder=(function(){function ComponentTagBuilder(){this.isDynamic = null;this.isStatic = null;this.staticTagName = null;this.dynamicTagName = null;}ComponentTagBuilder.prototype.getDynamic = function getDynamic(){if(this.isDynamic){return this.dynamicTagName;}};ComponentTagBuilder.prototype.getStatic = function getStatic(){if(this.isStatic){return this.staticTagName;}};ComponentTagBuilder.prototype.static = function _static(tagName){this.isStatic = true;this.staticTagName = tagName;};ComponentTagBuilder.prototype.dynamic = function dynamic(tagName){this.isDynamic = true;this.dynamicTagName = ['function',tagName];};return ComponentTagBuilder;})();var ComponentAttrsBuilder=(function(){function ComponentAttrsBuilder(){this.buffer = [];}ComponentAttrsBuilder.prototype.static = function _static(name,value){this.buffer.push(['static-attr',name,value,null]);};ComponentAttrsBuilder.prototype.dynamic = function dynamic(name,value){this.buffer.push(['dynamic-attr',name,['function',value],null]);};return ComponentAttrsBuilder;})();var ComponentBuilder=(function(){function ComponentBuilder(builder){this.builder = builder;this.env = builder.env;}ComponentBuilder.prototype.static = function _static(definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putComponentDefinition(definition);b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();});};ComponentBuilder.prototype.dynamic = function dynamic(definitionArgs,definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putArgs(compileArgs(definitionArgs[0],definitionArgs[1],b));b.putValue(['function',definition]);b.test('simple');b.enter('BEGIN','END');b.label('BEGIN');b.jumpUnless('END');b.putDynamicComponentDefinition();b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();b.label('END');b.exit();});};return ComponentBuilder;})();function builder(env,symbolTable){return new OpcodeBuilder(symbolTable,env);}function appendOpcode(name,op1,op2,op3){return APPEND_OPCODES.construct(name,null,op1,op2,op3);}var Labels=(function(){function Labels(){this.labels = _glimmerUtil.dict();this.jumps = [];this.ranges = [];}Labels.prototype.label = function label(name,index){this.labels[name] = index;};Labels.prototype.jump = function jump(at,Target,target){this.jumps.push({at:at,target:target,Target:Target});};Labels.prototype.range = function range(at,Range,start,end){this.ranges.push({at:at,start:start,end:end,Range:Range});};Labels.prototype.patch = function patch(constants,opcodes){for(var i=0;i < this.jumps.length;i++) {var _jumps$i=this.jumps[i];var at=_jumps$i.at;var target=_jumps$i.target;var Target=_jumps$i.Target;opcodes.set(at,APPEND_OPCODES.construct(Target,null,this.labels[target]));}for(var i=0;i < this.ranges.length;i++) {var _ranges$i=this.ranges[i];var at=_ranges$i.at;var start=_ranges$i.start;var end=_ranges$i.end;var _Range=_ranges$i.Range;var slice=constants.slice([this.labels[start],this.labels[end] - 1]);opcodes.set(at,APPEND_OPCODES.construct(_Range,null,slice));}};return Labels;})();var BasicOpcodeBuilder=(function(){function BasicOpcodeBuilder(symbolTable,env,program){this.symbolTable = symbolTable;this.env = env;this.program = program;this.labelsStack = new _glimmerUtil.Stack();this.constants = env.constants;this.start = program.next;}BasicOpcodeBuilder.prototype.opcode = function opcode(name,op1,op2,op3){this.push(appendOpcode(name,op1,op2,op3));};BasicOpcodeBuilder.prototype.push = function push(op){ // console.log(`pushing ${op && op.type}`); +if(op === null){this.program.push([0,0,0,0]);}else {this.program.push(op);}};BasicOpcodeBuilder.prototype.toSlice = function toSlice(){return [this.start,this.program.current];}; // helpers +BasicOpcodeBuilder.prototype.startLabels = function startLabels(){this.labelsStack.push(new Labels());};BasicOpcodeBuilder.prototype.stopLabels = function stopLabels(){var label=_glimmerUtil.expect(this.labelsStack.pop(),'unbalanced push and pop labels');label.patch(this.constants,this.program);}; // partials +BasicOpcodeBuilder.prototype.putPartialDefinition = function putPartialDefinition(_definition){var definition=this.constants.other(_definition);this.opcode(50, /* PutPartial */definition);};BasicOpcodeBuilder.prototype.putDynamicPartialDefinition = function putDynamicPartialDefinition(){this.opcode(49, /* PutDynamicPartial */this.constants.other(this.symbolTable));};BasicOpcodeBuilder.prototype.evaluatePartial = function evaluatePartial(){this.opcode(51, /* EvaluatePartial */this.constants.other(this.symbolTable),this.constants.other(_glimmerUtil.dict()));}; // components +BasicOpcodeBuilder.prototype.putComponentDefinition = function putComponentDefinition(definition){this.opcode(23, /* PutComponent */this.other(definition));};BasicOpcodeBuilder.prototype.putDynamicComponentDefinition = function putDynamicComponentDefinition(){this.opcode(22 /* PutDynamicComponent */);};BasicOpcodeBuilder.prototype.openComponent = function openComponent(args,shadow){this.opcode(24, /* OpenComponent */this.args(args),shadow?this.block(shadow):0);};BasicOpcodeBuilder.prototype.didCreateElement = function didCreateElement(){this.opcode(25 /* DidCreateElement */);};BasicOpcodeBuilder.prototype.shadowAttributes = function shadowAttributes(){this.opcode(26 /* ShadowAttributes */);this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.didRenderLayout = function didRenderLayout(){this.opcode(27 /* DidRenderLayout */);};BasicOpcodeBuilder.prototype.closeComponent = function closeComponent(){this.opcode(28 /* CloseComponent */);}; // content +BasicOpcodeBuilder.prototype.dynamicContent = function dynamicContent(Opcode){this.opcode(31, /* DynamicContent */this.other(Opcode));};BasicOpcodeBuilder.prototype.cautiousAppend = function cautiousAppend(){this.dynamicContent(new OptimizedCautiousAppendOpcode());};BasicOpcodeBuilder.prototype.trustingAppend = function trustingAppend(){this.dynamicContent(new OptimizedTrustingAppendOpcode());};BasicOpcodeBuilder.prototype.guardedCautiousAppend = function guardedCautiousAppend(expression){this.dynamicContent(new GuardedCautiousAppendOpcode(this.compileExpression(expression),this.symbolTable));};BasicOpcodeBuilder.prototype.guardedTrustingAppend = function guardedTrustingAppend(expression){this.dynamicContent(new GuardedTrustingAppendOpcode(this.compileExpression(expression),this.symbolTable));}; // dom +BasicOpcodeBuilder.prototype.text = function text(_text){this.opcode(29, /* Text */this.constants.string(_text));};BasicOpcodeBuilder.prototype.openPrimitiveElement = function openPrimitiveElement(tag){this.opcode(32, /* OpenElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openComponentElement = function openComponentElement(tag){this.opcode(35, /* OpenComponentElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openDynamicPrimitiveElement = function openDynamicPrimitiveElement(){this.opcode(36 /* OpenDynamicElement */);};BasicOpcodeBuilder.prototype.flushElement = function flushElement(){this.opcode(37 /* FlushElement */);};BasicOpcodeBuilder.prototype.closeElement = function closeElement(){this.opcode(38 /* CloseElement */);};BasicOpcodeBuilder.prototype.staticAttr = function staticAttr(_name,_namespace,_value){var name=this.constants.string(_name);var namespace=_namespace?this.constants.string(_namespace):0;var value=this.constants.string(_value);this.opcode(40, /* StaticAttr */name,value,namespace);};BasicOpcodeBuilder.prototype.dynamicAttrNS = function dynamicAttrNS(_name,_namespace,trusting){var name=this.constants.string(_name);var namespace=this.constants.string(_namespace);this.opcode(42, /* DynamicAttrNS */name,namespace,trusting | 0);};BasicOpcodeBuilder.prototype.dynamicAttr = function dynamicAttr(_name,trusting){var name=this.constants.string(_name);this.opcode(43, /* DynamicAttr */name,trusting | 0);};BasicOpcodeBuilder.prototype.comment = function comment(_comment){var comment=this.constants.string(_comment);this.opcode(30, /* Comment */comment);};BasicOpcodeBuilder.prototype.modifier = function modifier(_name,_args){var args=this.constants.expression(this.compile(_args));var _modifierManager=this.env.lookupModifier([_name],this.symbolTable);var modifierManager=this.constants.other(_modifierManager);var name=this.constants.string(_name);this.opcode(41, /* Modifier */name,modifierManager,args);}; // lists +BasicOpcodeBuilder.prototype.putIterator = function putIterator(){this.opcode(44 /* PutIterator */);};BasicOpcodeBuilder.prototype.enterList = function enterList(start,end){this.push(null);this.labels.range(this.pos,45, /* EnterList */start,end);};BasicOpcodeBuilder.prototype.exitList = function exitList(){this.opcode(46 /* ExitList */);};BasicOpcodeBuilder.prototype.enterWithKey = function enterWithKey(start,end){this.push(null);this.labels.range(this.pos,47, /* EnterWithKey */start,end);};BasicOpcodeBuilder.prototype.nextIter = function nextIter(end){this.push(null);this.labels.jump(this.pos,48, /* NextIter */end);}; // vm +BasicOpcodeBuilder.prototype.openBlock = function openBlock(_args,_inner){var args=this.constants.expression(this.compile(_args));var inner=this.constants.other(_inner);this.opcode(20, /* OpenBlock */inner,args);};BasicOpcodeBuilder.prototype.closeBlock = function closeBlock(){this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.pushRemoteElement = function pushRemoteElement(){this.opcode(33 /* PushRemoteElement */);};BasicOpcodeBuilder.prototype.popRemoteElement = function popRemoteElement(){this.opcode(34 /* PopRemoteElement */);};BasicOpcodeBuilder.prototype.popElement = function popElement(){this.opcode(39 /* PopElement */);};BasicOpcodeBuilder.prototype.label = function label(name){this.labels.label(name,this.nextPos);};BasicOpcodeBuilder.prototype.pushChildScope = function pushChildScope(){this.opcode(0 /* PushChildScope */);};BasicOpcodeBuilder.prototype.popScope = function popScope(){this.opcode(1 /* PopScope */);};BasicOpcodeBuilder.prototype.pushDynamicScope = function pushDynamicScope(){this.opcode(2 /* PushDynamicScope */);};BasicOpcodeBuilder.prototype.popDynamicScope = function popDynamicScope(){this.opcode(3 /* PopDynamicScope */);};BasicOpcodeBuilder.prototype.putNull = function putNull(){this.opcode(4, /* Put */this.constants.NULL_REFERENCE);};BasicOpcodeBuilder.prototype.putValue = function putValue(_expression){var expr=this.constants.expression(this.compileExpression(_expression));this.opcode(5, /* EvaluatePut */expr);};BasicOpcodeBuilder.prototype.putArgs = function putArgs(_args){var args=this.constants.expression(this.compile(_args));this.opcode(6, /* PutArgs */args);};BasicOpcodeBuilder.prototype.bindDynamicScope = function bindDynamicScope(_names){this.opcode(12, /* BindDynamicScope */this.names(_names));};BasicOpcodeBuilder.prototype.bindPositionalArgs = function bindPositionalArgs(_names,_symbols){this.opcode(7, /* BindPositionalArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindNamedArgs = function bindNamedArgs(_names,_symbols){this.opcode(8, /* BindNamedArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindBlocks = function bindBlocks(_names,_symbols){this.opcode(9, /* BindBlocks */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.enter = function enter(_enter,exit){this.push(null);this.labels.range(this.pos,13, /* Enter */_enter,exit);};BasicOpcodeBuilder.prototype.exit = function exit(){this.opcode(14 /* Exit */);};BasicOpcodeBuilder.prototype.evaluate = function evaluate(_block){var block=this.constants.block(_block);this.opcode(15, /* Evaluate */block);};BasicOpcodeBuilder.prototype.test = function test(testFunc){var _func=undefined;if(testFunc === 'const'){_func = ConstTest;}else if(testFunc === 'simple'){_func = SimpleTest;}else if(testFunc === 'environment'){_func = EnvironmentTest;}else if(typeof testFunc === 'function'){_func = testFunc;}else {throw new Error('unreachable');}var func=this.constants.function(_func);this.opcode(19, /* Test */func);};BasicOpcodeBuilder.prototype.jump = function jump(target){this.push(null);this.labels.jump(this.pos,16, /* Jump */target);};BasicOpcodeBuilder.prototype.jumpIf = function jumpIf(target){this.push(null);this.labels.jump(this.pos,17, /* JumpIf */target);};BasicOpcodeBuilder.prototype.jumpUnless = function jumpUnless(target){this.push(null);this.labels.jump(this.pos,18, /* JumpUnless */target);};BasicOpcodeBuilder.prototype.names = function names(_names){var _this=this;var names=_names.map(function(n){return _this.constants.string(n);});return this.constants.array(names);};BasicOpcodeBuilder.prototype.symbols = function symbols(_symbols2){return this.constants.array(_symbols2);};BasicOpcodeBuilder.prototype.other = function other(value){return this.constants.other(value);};BasicOpcodeBuilder.prototype.args = function args(_args2){return this.constants.expression(this.compile(_args2));};BasicOpcodeBuilder.prototype.block = function block(_block3){return this.constants.block(_block3);};babelHelpers.createClass(BasicOpcodeBuilder,[{key:'pos',get:function(){return this.program.current;}},{key:'nextPos',get:function(){return this.program.next;}},{key:'labels',get:function(){return _glimmerUtil.expect(this.labelsStack.current,'bug: not in a label stack');}}]);return BasicOpcodeBuilder;})();function isCompilableExpression(expr){return expr && typeof expr['compile'] === 'function';}var OpcodeBuilder=(function(_BasicOpcodeBuilder){babelHelpers.inherits(OpcodeBuilder,_BasicOpcodeBuilder);function OpcodeBuilder(symbolTable,env){var program=arguments.length <= 2 || arguments[2] === undefined?env.program:arguments[2];return (function(){_BasicOpcodeBuilder.call(this,symbolTable,env,program);this.component = new ComponentBuilder(this);}).apply(this,arguments);}OpcodeBuilder.prototype.compile = function compile(expr){if(isCompilableExpression(expr)){return expr.compile(this);}else {return expr;}};OpcodeBuilder.prototype.compileExpression = function compileExpression(expression){if(expression instanceof CompiledExpression){return expression;}else {return expr(expression,this);}};OpcodeBuilder.prototype.bindPositionalArgsForLocals = function bindPositionalArgsForLocals(locals){var symbols=Object.keys(locals).map(function(name){return locals[name];});this.opcode(7, /* BindPositionalArgs */this.symbols(symbols));};OpcodeBuilder.prototype.preludeForLayout = function preludeForLayout(layout){var _this2=this;var symbols=layout.symbolTable.getSymbols();if(symbols.named){(function(){var named=symbols.named;var namedNames=Object.keys(named);var namedSymbols=namedNames.map(function(n){return named[n];});_this2.opcode(8, /* BindNamedArgs */_this2.names(namedNames),_this2.symbols(namedSymbols));})();}this.opcode(11 /* BindCallerScope */);if(symbols.yields){(function(){var yields=symbols.yields;var yieldNames=Object.keys(yields);var yieldSymbols=yieldNames.map(function(n){return yields[n];});_this2.opcode(9, /* BindBlocks */_this2.names(yieldNames),_this2.symbols(yieldSymbols));})();}if(symbols.partialArgs){this.opcode(10, /* BindPartialArgs */symbols.partialArgs);}};OpcodeBuilder.prototype.yield = function _yield(args,to){var yields=undefined,partial=undefined;var inner=undefined;if(yields = this.symbolTable.getSymbol('yields',to)){inner = new CompiledGetBlockBySymbol(yields,to);}else if(partial = this.symbolTable.getPartialArgs()){inner = new CompiledInPartialGetBlock(partial,to);}else {throw new Error('[BUG] ${to} is not a valid block name.');}this.openBlock(args,inner);this.closeBlock();}; // TODO +// come back to this +OpcodeBuilder.prototype.labelled = function labelled(args,callback){if(args)this.putArgs(args);this.startLabels();this.enter('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.iter = function iter(callback){this.startLabels();this.enterList('BEGIN','END');this.label('ITER');this.nextIter('BREAK');this.enterWithKey('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.jump('ITER');this.label('BREAK');this.exitList();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.unit = function unit(callback){this.startLabels();callback(this);this.stopLabels();};return OpcodeBuilder;})(BasicOpcodeBuilder);APPEND_OPCODES.add(31, /* DynamicContent */function(vm,_ref31){var append=_ref31.op1;var opcode=vm.constants.getOther(append);opcode.evaluate(vm);});function isEmpty(value){return value === null || value === undefined || typeof value['toString'] !== 'function';}function normalizeTextValue(value){if(isEmpty(value)){return '';}return String(value);}function normalizeTrustedValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value)){return value.toHTML();}if(isNode(value)){return value;}return String(value);}function normalizeValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value) || isNode(value)){return value;}return String(value);}var AppendDynamicOpcode=(function(){function AppendDynamicOpcode(){}AppendDynamicOpcode.prototype.evaluate = function evaluate(vm){var reference=vm.frame.getOperand();var normalized=this.normalize(reference);var value=undefined,cache=undefined;if(_glimmerReference.isConst(reference)){value = normalized.value();}else {cache = new _glimmerReference.ReferenceCache(normalized);value = cache.peek();}var stack=vm.stack();var upsert=this.insert(vm.env.getAppendOperations(),stack,value);var bounds=new Fragment(upsert.bounds);stack.newBounds(bounds);if(cache /* i.e. !isConst(reference) */){vm.updateWith(this.updateWith(vm,reference,cache,bounds,upsert));}};return AppendDynamicOpcode;})();var GuardedAppendOpcode=(function(_AppendDynamicOpcode){babelHelpers.inherits(GuardedAppendOpcode,_AppendDynamicOpcode);function GuardedAppendOpcode(expression,symbolTable){_AppendDynamicOpcode.call(this);this.expression = expression;this.symbolTable = symbolTable;this.deopted = null;}GuardedAppendOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.pushEvalFrame(this.deopted);}else {vm.evaluateOperand(this.expression);var value=vm.frame.getOperand().value();if(isComponentDefinition(value)){vm.pushEvalFrame(this.deopt(vm.env));}else {_AppendDynamicOpcode.prototype.evaluate.call(this,vm);}}};GuardedAppendOpcode.prototype.deopt = function deopt(env){var _this3=this; // At compile time, we determined that this append callsite might refer +// to a local variable/property lookup that resolves to a component +// definition at runtime. +// +// We could have eagerly compiled this callsite into something like this: +// +// {{#if (is-component-definition foo)}} +// {{component foo}} +// {{else}} +// {{foo}} +// {{/if}} +// +// However, in practice, there might be a large amout of these callsites +// and most of them would resolve to a simple value lookup. Therefore, we +// tried to be optimistic and assumed that the callsite will resolve to +// appending a simple value. +// +// However, we have reached here because at runtime, the guard conditional +// have detected that this callsite is indeed referring to a component +// definition object. Since this is likely going to be true for other +// instances of the same callsite, it is now appropiate to deopt into the +// expanded version that handles both cases. The compilation would look +// like this: +// +// PutValue(expression) +// Test(is-component-definition) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(VALUE) +// PutDynamicComponentDefinitionOpcode +// OpenComponent +// CloseComponent +// Jump(END) +// VALUE: Noop +// OptimizedAppend +// END: Noop +// Exit +// +// Keep in mind that even if we *don't* reach here at initial render time, +// it is still possible (although quite rare) that the simple value we +// encounter during initial render could later change into a component +// definition object at update time. That is handled by the "lazy deopt" +// code on the update side (scroll down for the next big block of comment). +var dsl=new OpcodeBuilder(this.symbolTable,env);dsl.putValue(this.expression);dsl.test(IsComponentDefinitionReference.create);dsl.labelled(null,function(dsl,_BEGIN,END){dsl.jumpUnless('VALUE');dsl.putDynamicComponentDefinition();dsl.openComponent(CompiledArgs.empty());dsl.closeComponent();dsl.jump(END);dsl.label('VALUE');dsl.dynamicContent(new _this3.AppendOpcode());});var deopted=this.deopted = dsl.toSlice(); // From this point on, we have essentially replaced ourselves with a new set +// of opcodes. Since we will always be executing the new/deopted code, it's +// a good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this.expression = null;return deopted;};return GuardedAppendOpcode;})(AppendDynamicOpcode);var IsComponentDefinitionReference=(function(_ConditionalReference){babelHelpers.inherits(IsComponentDefinitionReference,_ConditionalReference);function IsComponentDefinitionReference(){_ConditionalReference.apply(this,arguments);}IsComponentDefinitionReference.create = function create(inner){return new IsComponentDefinitionReference(inner);};IsComponentDefinitionReference.prototype.toBool = function toBool(value){return isComponentDefinition(value);};return IsComponentDefinitionReference;})(ConditionalReference);var UpdateOpcode=(function(_UpdatingOpcode9){babelHelpers.inherits(UpdateOpcode,_UpdatingOpcode9);function UpdateOpcode(cache,bounds,upsert){_UpdatingOpcode9.call(this);this.cache = cache;this.bounds = bounds;this.upsert = upsert;this.tag = cache.tag;}UpdateOpcode.prototype.evaluate = function evaluate(vm){var value=this.cache.revalidate();if(_glimmerReference.isModified(value)){var bounds=this.bounds;var upsert=this.upsert;var dom=vm.dom;if(!this.upsert.update(dom,value)){var cursor=new Cursor(bounds.parentElement(),clear(bounds));upsert = this.upsert = this.insert(vm.env.getAppendOperations(),cursor,value);}bounds.update(upsert.bounds);}};UpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var cache=this.cache;return {guid:guid,type:type,details:{lastValue:JSON.stringify(cache.peek())}};};return UpdateOpcode;})(UpdatingOpcode);var GuardedUpdateOpcode=(function(_UpdateOpcode){babelHelpers.inherits(GuardedUpdateOpcode,_UpdateOpcode);function GuardedUpdateOpcode(reference,cache,bounds,upsert,appendOpcode,state){_UpdateOpcode.call(this,cache,bounds,upsert);this.reference = reference;this.appendOpcode = appendOpcode;this.state = state;this.deopted = null;this.tag = this._tag = new _glimmerReference.UpdatableTag(this.tag);}GuardedUpdateOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.evaluateOpcode(this.deopted);}else {if(isComponentDefinition(this.reference.value())){this.lazyDeopt(vm);}else {_UpdateOpcode.prototype.evaluate.call(this,vm);}}};GuardedUpdateOpcode.prototype.lazyDeopt = function lazyDeopt(vm){ // Durign initial render, we know that the reference does not contain a +// component definition, so we optimistically assumed that this append +// is just a normal append. However, at update time, we discovered that +// the reference has switched into containing a component definition, so +// we need to do a "lazy deopt", simulating what would have happened if +// we had decided to perform the deopt in the first place during initial +// render. +// +// More concretely, we would have expanded the curly into a if/else, and +// based on whether the value is a component definition or not, we would +// have entered either the dynamic component branch or the simple value +// branch. +// +// Since we rendered a simple value during initial render (and all the +// updates up until this point), we need to pretend that the result is +// produced by the "VALUE" branch of the deopted append opcode: +// +// Try(BEGIN, END) +// Assert(IsComponentDefinition, expected=false) +// OptimizedUpdate +// +// In this case, because the reference has switched from being a simple +// value into a component definition, what would have happened is that +// the assert would throw, causing the Try opcode to teardown the bounds +// and rerun the original append opcode. +// +// Since the Try opcode would have nuked the updating opcodes anyway, we +// wouldn't have to worry about simulating those. All we have to do is to +// execute the Try opcode and immediately throw. +var bounds=this.bounds;var appendOpcode=this.appendOpcode;var state=this.state;var env=vm.env;var slice=appendOpcode.deopt(env);var enter=_glimmerUtil.expect(env.program.opcode(slice[0] + 8),'hardcoded deopt location');var ops=vm.constants.getSlice(enter.op1);var tracker=new UpdatableBlockTracker(bounds.parentElement());tracker.newBounds(this.bounds);var children=new _glimmerUtil.LinkedList();state.frame['condition'] = IsComponentDefinitionReference.create(_glimmerUtil.expect(state.frame['operand'],'operand should be populated'));var deopted=this.deopted = new TryOpcode(ops,state,tracker,children);this._tag.update(deopted.tag);vm.evaluateOpcode(deopted);vm.throw(); // From this point on, we have essentially replaced ourselve with a new +// opcode. Since we will always be executing the new/deopted code, it's a +// good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this._tag = null;this.reference = null;this.cache = null;this.bounds = null;this.upsert = null;this.appendOpcode = null;this.state = null;};GuardedUpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var deopted=this.deopted;if(deopted){return {guid:guid,type:type,deopted:true,children:[deopted.toJSON()]};}else {return _UpdateOpcode.prototype.toJSON.call(this);}};return GuardedUpdateOpcode;})(UpdateOpcode);var OptimizedCautiousAppendOpcode=(function(_AppendDynamicOpcode2){babelHelpers.inherits(OptimizedCautiousAppendOpcode,_AppendDynamicOpcode2);function OptimizedCautiousAppendOpcode(){_AppendDynamicOpcode2.apply(this,arguments);this.type = 'optimized-cautious-append';}OptimizedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};OptimizedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};OptimizedCautiousAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedCautiousUpdateOpcode(cache,bounds,upsert);};return OptimizedCautiousAppendOpcode;})(AppendDynamicOpcode);var OptimizedCautiousUpdateOpcode=(function(_UpdateOpcode2){babelHelpers.inherits(OptimizedCautiousUpdateOpcode,_UpdateOpcode2);function OptimizedCautiousUpdateOpcode(){_UpdateOpcode2.apply(this,arguments);this.type = 'optimized-cautious-update';}OptimizedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return OptimizedCautiousUpdateOpcode;})(UpdateOpcode);var GuardedCautiousAppendOpcode=(function(_GuardedAppendOpcode){babelHelpers.inherits(GuardedCautiousAppendOpcode,_GuardedAppendOpcode);function GuardedCautiousAppendOpcode(){_GuardedAppendOpcode.apply(this,arguments);this.type = 'guarded-cautious-append';this.AppendOpcode = OptimizedCautiousAppendOpcode;}GuardedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};GuardedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};GuardedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedCautiousUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedCautiousAppendOpcode;})(GuardedAppendOpcode);var GuardedCautiousUpdateOpcode=(function(_GuardedUpdateOpcode){babelHelpers.inherits(GuardedCautiousUpdateOpcode,_GuardedUpdateOpcode);function GuardedCautiousUpdateOpcode(){_GuardedUpdateOpcode.apply(this,arguments);this.type = 'guarded-cautious-update';}GuardedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return GuardedCautiousUpdateOpcode;})(GuardedUpdateOpcode);var OptimizedTrustingAppendOpcode=(function(_AppendDynamicOpcode3){babelHelpers.inherits(OptimizedTrustingAppendOpcode,_AppendDynamicOpcode3);function OptimizedTrustingAppendOpcode(){_AppendDynamicOpcode3.apply(this,arguments);this.type = 'optimized-trusting-append';}OptimizedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};OptimizedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};OptimizedTrustingAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedTrustingUpdateOpcode(cache,bounds,upsert);};return OptimizedTrustingAppendOpcode;})(AppendDynamicOpcode);var OptimizedTrustingUpdateOpcode=(function(_UpdateOpcode3){babelHelpers.inherits(OptimizedTrustingUpdateOpcode,_UpdateOpcode3);function OptimizedTrustingUpdateOpcode(){_UpdateOpcode3.apply(this,arguments);this.type = 'optimized-trusting-update';}OptimizedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return OptimizedTrustingUpdateOpcode;})(UpdateOpcode);var GuardedTrustingAppendOpcode=(function(_GuardedAppendOpcode2){babelHelpers.inherits(GuardedTrustingAppendOpcode,_GuardedAppendOpcode2);function GuardedTrustingAppendOpcode(){_GuardedAppendOpcode2.apply(this,arguments);this.type = 'guarded-trusting-append';this.AppendOpcode = OptimizedTrustingAppendOpcode;}GuardedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};GuardedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};GuardedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedTrustingUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedTrustingAppendOpcode;})(GuardedAppendOpcode);var GuardedTrustingUpdateOpcode=(function(_GuardedUpdateOpcode2){babelHelpers.inherits(GuardedTrustingUpdateOpcode,_GuardedUpdateOpcode2);function GuardedTrustingUpdateOpcode(){_GuardedUpdateOpcode2.apply(this,arguments);this.type = 'trusting-update';}GuardedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return GuardedTrustingUpdateOpcode;})(GuardedUpdateOpcode);APPEND_OPCODES.add(49, /* PutDynamicPartial */function(vm,_ref32){var _symbolTable=_ref32.op1;var env=vm.env;var symbolTable=vm.constants.getOther(_symbolTable);function lookupPartial(name){var normalized=String(name);if(!env.hasPartial(normalized,symbolTable)){throw new Error('Could not find a partial named "' + normalized + '"');}return env.lookupPartial(normalized,symbolTable);}var reference=_glimmerReference.map(vm.frame.getOperand(),lookupPartial);var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(50, /* PutPartial */function(vm,_ref33){var _definition=_ref33.op1;var definition=vm.constants.getOther(_definition);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(51, /* EvaluatePartial */function(vm,_ref34){var _symbolTable=_ref34.op1;var _cache=_ref34.op2;var symbolTable=vm.constants.getOther(_symbolTable);var cache=vm.constants.getOther(_cache);var _vm$frame$getImmediate=vm.frame.getImmediate();var template=_vm$frame$getImmediate.template;var block=cache[template.id];if(!block){block = template.asPartial(symbolTable);}vm.invokePartial(block);});var IterablePresenceReference=(function(){function IterablePresenceReference(artifacts){this.tag = artifacts.tag;this.artifacts = artifacts;}IterablePresenceReference.prototype.value = function value(){return !this.artifacts.isEmpty();};return IterablePresenceReference;})();APPEND_OPCODES.add(44, /* PutIterator */function(vm){var listRef=vm.frame.getOperand();var args=_glimmerUtil.expect(vm.frame.getArgs(),'PutIteratorOpcode expects a populated args register');var iterable=vm.env.iterableFor(listRef,args);var iterator=new _glimmerReference.ReferenceIterator(iterable);vm.frame.setIterator(iterator);vm.frame.setCondition(new IterablePresenceReference(iterator.artifacts));});APPEND_OPCODES.add(45, /* EnterList */function(vm,_ref35){var _slice=_ref35.op1;vm.enterList(vm.constants.getSlice(_slice));});APPEND_OPCODES.add(46, /* ExitList */function(vm){return vm.exitList();});APPEND_OPCODES.add(47, /* EnterWithKey */function(vm,_ref36){var _slice=_ref36.op2;var key=_glimmerUtil.expect(vm.frame.getKey(),'EnterWithKeyOpcode expects a populated key register');var slice=vm.constants.getSlice(_slice);vm.enterWithKey(key,slice);});var TRUE_REF=new _glimmerReference.ConstReference(true);var FALSE_REF=new _glimmerReference.ConstReference(false);APPEND_OPCODES.add(48, /* NextIter */function(vm,_ref37){var end=_ref37.op1;var item=vm.frame.getIterator().next();if(item){vm.frame.setCondition(TRUE_REF);vm.frame.setKey(item.key);vm.frame.setOperand(item.value);vm.frame.setArgs(EvaluatedArgs.positional([item.value,item.memo]));}else {vm.frame.setCondition(FALSE_REF);vm.goto(end);}});var clientId=0;function templateFactory(_ref38){var templateId=_ref38.id;var meta=_ref38.meta;var block=_ref38.block;var parsedBlock=undefined;var id=templateId || 'client-' + clientId++;var create=function(env,envMeta){var newMeta=envMeta?_glimmerUtil.assign({},envMeta,meta):meta;if(!parsedBlock){parsedBlock = JSON.parse(block);}return template(parsedBlock,id,newMeta,env);};return {id:id,meta:meta,create:create};}function template(block,id,meta,env){var scanner=new Scanner(block,meta,env);var entryPoint=undefined;var asEntryPoint=function(){if(!entryPoint)entryPoint = scanner.scanEntryPoint();return entryPoint;};var layout=undefined;var asLayout=function(){if(!layout)layout = scanner.scanLayout();return layout;};var asPartial=function(symbols){return scanner.scanPartial(symbols);};var render=function(self,appendTo,dynamicScope){var elementStack=ElementStack.forInitialRender(env,appendTo,null);var compiled=asEntryPoint().compile(env);var vm=VM.initial(env,self,dynamicScope,elementStack,compiled.symbols);return vm.execute(compiled.slice);};return {id:id,meta:meta,_block:block,asEntryPoint:asEntryPoint,asLayout:asLayout,asPartial:asPartial,render:render};}var DynamicVarReference=(function(){function DynamicVarReference(scope,nameRef){this.scope = scope;this.nameRef = nameRef;var varTag=this.varTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([nameRef.tag,varTag]);}DynamicVarReference.prototype.value = function value(){return this.getVar().value();};DynamicVarReference.prototype.get = function get(key){return this.getVar().get(key);};DynamicVarReference.prototype.getVar = function getVar(){var name=String(this.nameRef.value());var ref=this.scope.get(name);this.varTag.update(ref.tag);return ref;};return DynamicVarReference;})();function getDynamicVar(vm,args,_symbolTable){var scope=vm.dynamicScope();var nameRef=args.positional.at(0);return new DynamicVarReference(scope,nameRef);}var PartialDefinition=function PartialDefinition(name,template){this.name = name;this.template = template;};var NodeType;(function(NodeType){NodeType[NodeType["Element"] = 0] = "Element";NodeType[NodeType["Attribute"] = 1] = "Attribute";NodeType[NodeType["Text"] = 2] = "Text";NodeType[NodeType["CdataSection"] = 3] = "CdataSection";NodeType[NodeType["EntityReference"] = 4] = "EntityReference";NodeType[NodeType["Entity"] = 5] = "Entity";NodeType[NodeType["ProcessingInstruction"] = 6] = "ProcessingInstruction";NodeType[NodeType["Comment"] = 7] = "Comment";NodeType[NodeType["Document"] = 8] = "Document";NodeType[NodeType["DocumentType"] = 9] = "DocumentType";NodeType[NodeType["DocumentFragment"] = 10] = "DocumentFragment";NodeType[NodeType["Notation"] = 11] = "Notation";})(NodeType || (NodeType = {}));var Simple=Object.freeze({get NodeType(){return NodeType;}});exports.Simple = Simple;exports.templateFactory = templateFactory;exports.NULL_REFERENCE = NULL_REFERENCE;exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE;exports.PrimitiveReference = PrimitiveReference;exports.ConditionalReference = ConditionalReference;exports.OpcodeBuilderDSL = OpcodeBuilder;exports.compileLayout = compileLayout;exports.CompiledBlock = CompiledBlock;exports.CompiledProgram = CompiledProgram;exports.IAttributeManager = AttributeManager;exports.AttributeManager = AttributeManager;exports.PropertyManager = PropertyManager;exports.INPUT_VALUE_PROPERTY_MANAGER = INPUT_VALUE_PROPERTY_MANAGER;exports.defaultManagers = defaultManagers;exports.defaultAttributeManagers = defaultAttributeManagers;exports.defaultPropertyManagers = defaultPropertyManagers;exports.readDOMAttr = readDOMAttr;exports.normalizeTextValue = normalizeTextValue;exports.CompiledExpression = CompiledExpression;exports.CompiledArgs = CompiledArgs;exports.CompiledNamedArgs = CompiledNamedArgs;exports.CompiledPositionalArgs = CompiledPositionalArgs;exports.EvaluatedArgs = EvaluatedArgs;exports.EvaluatedNamedArgs = EvaluatedNamedArgs;exports.EvaluatedPositionalArgs = EvaluatedPositionalArgs;exports.getDynamicVar = getDynamicVar;exports.BlockMacros = Blocks;exports.InlineMacros = Inlines;exports.compileArgs = compileArgs;exports.setDebuggerCallback = setDebuggerCallback;exports.resetDebuggerCallback = resetDebuggerCallback;exports.BaselineSyntax = BaselineSyntax;exports.Layout = Layout;exports.UpdatingVM = UpdatingVM;exports.RenderResult = RenderResult;exports.isSafeString = isSafeString;exports.Scope = Scope;exports.Environment = Environment;exports.PartialDefinition = PartialDefinition;exports.ComponentDefinition = ComponentDefinition;exports.isComponentDefinition = isComponentDefinition;exports.DOMChanges = helper$1;exports.IDOMChanges = DOMChanges;exports.DOMTreeConstruction = DOMTreeConstruction;exports.isWhitespace = isWhitespace;exports.insertHTMLBefore = _insertHTMLBefore;exports.ElementStack = ElementStack;exports.ConcreteBounds = ConcreteBounds;}); +enifed('@glimmer/util', ['exports'], function (exports) { + // There is a small whitelist of namespaced attributes specially + // enumerated in + // https://www.w3.org/TR/html/syntax.html#attributes-0 + // + // > When a foreign element has one of the namespaced attributes given by + // > the local name and namespace of the first and second cells of a row + // > from the following table, it must be written using the name given by + // > the third cell from the same row. + // + // In all other cases, colons are interpreted as a regular character + // with no special meaning: + // + // > No other namespaced attribute can be expressed in the HTML syntax. + 'use strict'; - this._throttlers.push(throttler); + var XLINK = 'http://www.w3.org/1999/xlink'; + var XML = 'http://www.w3.org/XML/1998/namespace'; + var XMLNS = 'http://www.w3.org/2000/xmlns/'; + var WHITELIST = { + 'xlink:actuate': XLINK, + 'xlink:arcrole': XLINK, + 'xlink:href': XLINK, + 'xlink:role': XLINK, + 'xlink:show': XLINK, + 'xlink:title': XLINK, + 'xlink:type': XLINK, + 'xml:base': XML, + 'xml:lang': XML, + 'xml:space': XML, + 'xmlns': XMLNS, + 'xmlns:xlink': XMLNS + }; + function getAttrNamespace(attrName) { + return WHITELIST[attrName] || null; + } - return throttler; - }, + // tslint:disable-line + function unwrap(val) { + if (val === null || val === undefined) throw new Error('Expected value to be present'); + return val; + } + function expect(val, message) { + if (val === null || val === undefined) throw new Error(message); + return val; + } + function unreachable() { + return new Error('unreachable'); + } - debounce: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; + // import Logger from './logger'; + // let alreadyWarned = false; + // import Logger from './logger'; + function debugAssert(test, msg) { + // if (!alreadyWarned) { + // alreadyWarned = true; + // Logger.warn("Don't leave debug assertions on in public builds"); + // } + if (!test) { + throw new Error(msg || "assertion failure"); + } } - var immediate = args.pop(); - var wait, index, debouncee, timer; + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["Trace"] = 0] = "Trace"; + LogLevel[LogLevel["Debug"] = 1] = "Debug"; + LogLevel[LogLevel["Warn"] = 2] = "Warn"; + LogLevel[LogLevel["Error"] = 3] = "Error"; + })(LogLevel || (exports.LogLevel = LogLevel = {})); - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = false; - } else { - wait = args.pop(); - } + var NullConsole = (function () { + function NullConsole() {} - wait = parseInt(wait, 10); - // Remove debouncee - index = findDebouncee(target, method, this._debouncees); + NullConsole.prototype.log = function log(_message) {}; - if (index > -1) { - debouncee = this._debouncees[index]; - this._debouncees.splice(index, 1); - this._platform.clearTimeout(debouncee[2]); - } + NullConsole.prototype.warn = function warn(_message) {}; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findDebouncee(target, method, backburner._debouncees); - if (index > -1) { - backburner._debouncees.splice(index, 1); - } - }, wait); + NullConsole.prototype.error = function error(_message) {}; - if (immediate && index === -1) { - backburner.run.apply(backburner, args); - } + NullConsole.prototype.trace = function trace() {}; - debouncee = [ - target, - method, - timer - ]; + return NullConsole; + })(); - backburner._debouncees.push(debouncee); + var ALWAYS = undefined; - return debouncee; - }, + var Logger = (function () { + function Logger(_ref) { + var console = _ref.console; + var level = _ref.level; - cancelTimers: function() { - each(this._throttlers, this._boundClearItems); - this._throttlers = []; + this.f = ALWAYS; + this.force = ALWAYS; + this.console = console; + this.level = level; + } - each(this._debouncees, this._boundClearItems); - this._debouncees = []; + Logger.prototype.skipped = function skipped(level) { + return level < this.level; + }; - this._clearTimerTimeout(); - this._timers = []; + Logger.prototype.trace = function trace(message) { + var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (this._autorun) { - this._platform.clearTimeout(this._autorun); - this._autorun = null; - } - }, + var _ref2$stackTrace = _ref2.stackTrace; + var stackTrace = _ref2$stackTrace === undefined ? false : _ref2$stackTrace; - hasTimers: function() { - return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; - }, + if (this.skipped(LogLevel.Trace)) return; + this.console.log(message); + if (stackTrace) this.console.trace(); + }; - cancel: function (timer) { - var timerType = typeof timer; + Logger.prototype.debug = function debug(message) { + var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce - return timer.queue.cancel(timer); - } else if (timerType === 'function') { // we're cancelling a setTimeout - for (var i = 0, l = this._timers.length; i < l; i += 2) { - if (this._timers[i + 1] === timer) { - this._timers.splice(i, 2); // remove the two elements - if (i === 0) { - this._reinstallTimerTimeout(); - } - return true; - } - } - } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce - return this._cancelItem(findThrottler, this._throttlers, timer) || - this._cancelItem(findDebouncee, this._debouncees, timer); - } else { - return; // timer was null or not a timer - } - }, + var _ref3$stackTrace = _ref3.stackTrace; + var stackTrace = _ref3$stackTrace === undefined ? false : _ref3$stackTrace; - _cancelItem: function(findMethod, array, timer){ - var item, index; + if (this.skipped(LogLevel.Debug)) return; + this.console.log(message); + if (stackTrace) this.console.trace(); + }; - if (timer.length < 3) { return false; } + Logger.prototype.warn = function warn(message) { + var _ref4 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - index = findMethod(timer[0], timer[1], array); + var _ref4$stackTrace = _ref4.stackTrace; + var stackTrace = _ref4$stackTrace === undefined ? false : _ref4$stackTrace; - if (index > -1) { + if (this.skipped(LogLevel.Warn)) return; + this.console.warn(message); + if (stackTrace) this.console.trace(); + }; - item = array[index]; + Logger.prototype.error = function error(message) { + if (this.skipped(LogLevel.Error)) return; + this.console.error(message); + }; - if (item[2] === timer[2]) { - array.splice(index, 1); - this._platform.clearTimeout(timer[2]); - return true; - } - } + return Logger; + })(); - return false; - }, + var _console = typeof console === 'undefined' ? new NullConsole() : console; + ALWAYS = new Logger({ console: _console, level: LogLevel.Trace }); + var LOG_LEVEL = LogLevel.Warn; + var logger = new Logger({ console: _console, level: LOG_LEVEL }); - _runExpiredTimers: function () { - this._timerTimeoutId = undefined; - this.run(this, this._scheduleExpiredTimers); - }, + var objKeys = Object.keys; - _scheduleExpiredTimers: function () { - var n = Date.now(); - var timers = this._timers; - var i = 0; - var l = timers.length; - for (; i < l; i += 2) { - var executeAt = timers[i]; - var fn = timers[i+1]; - if (executeAt <= n) { - this.schedule(this.options.defaultQueue, null, fn); - } else { - break; - } + function assign(obj) { + for (var i = 1; i < arguments.length; i++) { + var assignment = arguments[i]; + if (assignment === null || typeof assignment !== 'object') continue; + var keys = objKeys(assignment); + for (var j = 0; j < keys.length; j++) { + var key = keys[j]; + obj[key] = assignment[key]; + } + } + return obj; + } + function fillNulls(count) { + var arr = new Array(count); + for (var i = 0; i < count; i++) { + arr[i] = null; + } + return arr; } - timers.splice(0, i); - this._installTimerTimeout(); - }, - - _reinstallTimerTimeout: function () { - this._clearTimerTimeout(); - this._installTimerTimeout(); - }, - _clearTimerTimeout: function () { - if (!this._timerTimeoutId) { - return; + var GUID = 0; + function initializeGuid(object) { + return object._guid = ++GUID; + } + function ensureGuid(object) { + return object._guid || initializeGuid(object); } - this._platform.clearTimeout(this._timerTimeoutId); - this._timerTimeoutId = undefined; - }, - _installTimerTimeout: function () { - if (!this._timers.length) { - return; + var proto = Object.create(null, { + // without this, we will always still end up with (new + // EmptyObject()).constructor === Object + constructor: { + value: undefined, + enumerable: false, + writable: true + } + }); + function EmptyObject() {} + EmptyObject.prototype = proto; + function dict() { + // let d = Object.create(null); + // d.x = 1; + // delete d.x; + // return d; + return new EmptyObject(); } - var minExpiresAt = this._timers[0]; - var n = Date.now(); - var wait = Math.max(0, minExpiresAt - n); - this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); - } -}; -Backburner.prototype.schedule = Backburner.prototype.defer; -Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; -Backburner.prototype.later = Backburner.prototype.setTimeout; + var DictSet = (function () { + function DictSet() { + this.dict = dict(); + } -function getOnError(options) { - return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); -} + DictSet.prototype.add = function add(obj) { + if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj; + return this; + }; -function createAutorun(backburner) { - var setTimeout = backburner._platform.setTimeout; - backburner.begin(); - backburner._autorun = setTimeout(function() { - backburner._autorun = null; - backburner.end(); - }, 0); -} + DictSet.prototype.delete = function _delete(obj) { + if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; + }; -function findDebouncee(target, method, debouncees) { - return findItem(target, method, debouncees); -} + DictSet.prototype.forEach = function forEach(callback) { + var dict = this.dict; -function findThrottler(target, method, throttlers) { - return findItem(target, method, throttlers); -} + Object.keys(dict).forEach(function (key) { + return callback(dict[key]); + }); + }; -function findItem(target, method, collection) { - var item; - var index = -1; + DictSet.prototype.toArray = function toArray() { + return Object.keys(this.dict); + }; - for (var i = 0, l = collection.length; i < l; i++) { - item = collection[i]; - if (item[0] === target && item[1] === method) { - index = i; - break; - } - } + return DictSet; + })(); - return index; -} + var Stack = (function () { + function Stack() { + this.stack = []; + this.current = null; + } -function clearItems(item) { - this._platform.clearTimeout(item[2]); -} + Stack.prototype.toArray = function toArray() { + return this.stack; + }; -exports['default'] = Backburner; + Stack.prototype.push = function push(item) { + this.current = item; + this.stack.push(item); + }; -Object.defineProperty(exports, '__esModule', { value: true }); + Stack.prototype.pop = function pop() { + var item = this.stack.pop(); + var len = this.stack.length; + this.current = len === 0 ? null : this.stack[len - 1]; + return item === undefined ? null : item; + }; -}); -enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) { - 'use strict'; + Stack.prototype.isEmpty = function isEmpty() { + return this.stack.length === 0; + }; - exports.default = Container; - exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations; + return Stack; + })(); - var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE'); + var ListNode = function ListNode(value) { + this.next = null; + this.prev = null; + this.value = value; + }; - /** - A container used to instantiate and cache objects. - - Every `Container` must be associated with a `Registry`, which is referenced - to determine the factory and options that should be used to instantiate - objects. - - The public API for `Container` is still in flux and should not be considered - stable. - - @private - @class Container - */ + var LinkedList = (function () { + function LinkedList() { + this.clear(); + } - function Container(registry, options) { - this.registry = registry; - this.owner = options && options.owner ? options.owner : null; - this.cache = _emberUtils.dictionary(options && options.cache ? options.cache : null); - this.factoryCache = _emberUtils.dictionary(options && options.factoryCache ? options.factoryCache : null); - this.validationCache = _emberUtils.dictionary(options && options.validationCache ? options.validationCache : null); - this._fakeContainerToInject = buildFakeContainerWithDeprecations(this); - this[CONTAINER_OVERRIDE] = undefined; - this.isDestroyed = false; - } + LinkedList.fromSlice = function fromSlice(slice) { + var list = new LinkedList(); + slice.forEachNode(function (n) { + return list.append(n.clone()); + }); + return list; + }; - Container.prototype = { - /** - @private - @property owner - @type Object - */ - owner: null, + LinkedList.prototype.head = function head() { + return this._head; + }; - /** - @private - @property registry - @type Registry - @since 1.11.0 - */ - registry: null, + LinkedList.prototype.tail = function tail() { + return this._tail; + }; - /** - @private - @property cache - @type InheritingDict - */ - cache: null, + LinkedList.prototype.clear = function clear() { + this._head = this._tail = null; + }; - /** - @private - @property factoryCache - @type InheritingDict - */ - factoryCache: null, + LinkedList.prototype.isEmpty = function isEmpty() { + return this._head === null; + }; - /** - @private - @property validationCache - @type InheritingDict - */ - validationCache: null, + LinkedList.prototype.toArray = function toArray() { + var out = []; + this.forEachNode(function (n) { + return out.push(n); + }); + return out; + }; - /** - Given a fullName return a corresponding instance. - The default behaviour is for lookup to return a singleton instance. - The singleton is scoped to the container, allowing multiple containers - to all have their own locally scoped singletons. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter'); - twitter instanceof Twitter; // => true - // by default the container will return singletons - let twitter2 = container.lookup('api:twitter'); - twitter2 instanceof Twitter; // => true - twitter === twitter2; //=> true - ``` - If singletons are not wanted, an optional flag can be provided at lookup. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter', { singleton: false }); - let twitter2 = container.lookup('api:twitter', { singleton: false }); - twitter === twitter2; //=> false - ``` - @private - @method lookup - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] The fullname of the request source (used for local lookup) - @return {any} - */ - lookup: function (fullName, options) { - _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); - return lookup(this, this.registry.normalize(fullName), options); - }, + LinkedList.prototype.splice = function splice(start, end, reference) { + var before = undefined; + if (reference === null) { + before = this._tail; + this._tail = end; + } else { + before = reference.prev; + end.next = reference; + reference.prev = end; + } + if (before) { + before.next = start; + start.prev = before; + } + }; - /** - Given a fullName, return the corresponding factory. - @private - @method lookupFactory - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] The fullname of the request source (used for local lookup) - @return {any} - */ - lookupFactory: function (fullName, options) { - _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); - return factoryFor(this, this.registry.normalize(fullName), options); - }, + LinkedList.prototype.nextNode = function nextNode(node) { + return node.next; + }; - /** - A depth first traversal, destroying the container, its descendant containers and all - their managed objects. - @private - @method destroy - */ - destroy: function () { - eachDestroyable(this, function (item) { - if (item.destroy) { - item.destroy(); - } - }); + LinkedList.prototype.prevNode = function prevNode(node) { + return node.prev; + }; - this.isDestroyed = true; - }, + LinkedList.prototype.forEachNode = function forEachNode(callback) { + var node = this._head; + while (node !== null) { + callback(node); + node = node.next; + } + }; - /** - Clear either the entire cache or just the cache for a particular key. - @private - @method reset - @param {String} fullName optional key to reset; if missing, resets everything - */ - reset: function (fullName) { - if (arguments.length > 0) { - resetMember(this, this.registry.normalize(fullName)); - } else { - resetCache(this); - } - }, + LinkedList.prototype.contains = function contains(needle) { + var node = this._head; + while (node !== null) { + if (node === needle) return true; + node = node.next; + } + return false; + }; - /** - Returns an object that can be used to provide an owner to a - manually created instance. - @private - @method ownerInjection - @returns { Object } - */ - ownerInjection: function () { - var _ref; + LinkedList.prototype.insertBefore = function insertBefore(node) { + var reference = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; - } - }; + if (reference === null) return this.append(node); + if (reference.prev) reference.prev.next = node;else this._head = node; + node.prev = reference.prev; + node.next = reference; + reference.prev = node; + return node; + }; - function isSingleton(container, fullName) { - return container.registry.getOption(fullName, 'singleton') !== false; - } + LinkedList.prototype.append = function append(node) { + var tail = this._tail; + if (tail) { + tail.next = node; + node.prev = tail; + node.next = null; + } else { + this._head = node; + } + return this._tail = node; + }; - function lookup(container, fullName) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + LinkedList.prototype.pop = function pop() { + if (this._tail) return this.remove(this._tail); + return null; + }; - if (options.source) { - fullName = container.registry.expandLocalLookup(fullName, options); + LinkedList.prototype.prepend = function prepend(node) { + if (this._head) return this.insertBefore(node, this._head); + return this._head = this._tail = node; + }; - // if expandLocalLookup returns falsey, we do not support local lookup - if (!fullName) { - return; - } - } + LinkedList.prototype.remove = function remove(node) { + if (node.prev) node.prev.next = node.next;else this._head = node.next; + if (node.next) node.next.prev = node.prev;else this._tail = node.prev; + return node; + }; - if (container.cache[fullName] !== undefined && options.singleton !== false) { - return container.cache[fullName]; - } + return LinkedList; + })(); - var value = instantiate(container, fullName); + var ListSlice = (function () { + function ListSlice(head, tail) { + this._head = head; + this._tail = tail; + } - if (value === undefined) { - return; - } + ListSlice.toList = function toList(slice) { + var list = new LinkedList(); + slice.forEachNode(function (n) { + return list.append(n.clone()); + }); + return list; + }; - if (isSingleton(container, fullName) && options.singleton !== false) { - container.cache[fullName] = value; - } + ListSlice.prototype.forEachNode = function forEachNode(callback) { + var node = this._head; + while (node !== null) { + callback(node); + node = this.nextNode(node); + } + }; - return value; - } + ListSlice.prototype.contains = function contains(needle) { + var node = this._head; + while (node !== null) { + if (node === needle) return true; + node = node.next; + } + return false; + }; - function markInjectionsAsDynamic(injections) { - injections._dynamic = true; - } + ListSlice.prototype.head = function head() { + return this._head; + }; - function areInjectionsDynamic(injections) { - return !!injections._dynamic; - } + ListSlice.prototype.tail = function tail() { + return this._tail; + }; - function buildInjections() /* container, ...injections */{ - var hash = {}; + ListSlice.prototype.toArray = function toArray() { + var out = []; + this.forEachNode(function (n) { + return out.push(n); + }); + return out; + }; - if (arguments.length > 1) { - var container = arguments[0]; - var injections = []; - var injection = undefined; + ListSlice.prototype.nextNode = function nextNode(node) { + if (node === this._tail) return null; + return node.next; + }; - for (var i = 1; i < arguments.length; i++) { - if (arguments[i]) { - injections = injections.concat(arguments[i]); - } - } + ListSlice.prototype.prevNode = function prevNode(node) { + if (node === this._head) return null; + return node.prev; + }; - container.registry.validateInjections(injections); + ListSlice.prototype.isEmpty = function isEmpty() { + return false; + }; - for (var i = 0; i < injections.length; i++) { - injection = injections[i]; - hash[injection.property] = lookup(container, injection.fullName); - if (!isSingleton(container, injection.fullName)) { - markInjectionsAsDynamic(hash); - } - } - } + return ListSlice; + })(); - return hash; - } + var EMPTY_SLICE = new ListSlice(null, null); - function factoryFor(container, fullName) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + var HAS_TYPED_ARRAYS = typeof Uint32Array !== 'undefined'; + var A = undefined; + if (HAS_TYPED_ARRAYS) { + A = Uint32Array; + } else { + A = Array; + } + var A$1 = A; - var registry = container.registry; + var HAS_NATIVE_WEAKMAP = (function () { + // detect if `WeakMap` is even present + var hasWeakMap = typeof WeakMap === 'function'; + if (!hasWeakMap) { + return false; + } + var instance = new WeakMap(); + // use `Object`'s `.toString` directly to prevent us from detecting + // polyfills as native weakmaps + return Object.prototype.toString.call(instance) === '[object WeakMap]'; + })(); - if (options.source) { - fullName = registry.expandLocalLookup(fullName, options); + exports.getAttrNamespace = getAttrNamespace; + exports.assert = debugAssert; + exports.LOGGER = logger; + exports.Logger = Logger; + exports.LogLevel = LogLevel; + exports.assign = assign; + exports.fillNulls = fillNulls; + exports.ensureGuid = ensureGuid; + exports.initializeGuid = initializeGuid; + exports.Stack = Stack; + exports.DictSet = DictSet; + exports.dict = dict; + exports.EMPTY_SLICE = EMPTY_SLICE; + exports.LinkedList = LinkedList; + exports.ListNode = ListNode; + exports.ListSlice = ListSlice; + exports.A = A$1; + exports.HAS_NATIVE_WEAKMAP = HAS_NATIVE_WEAKMAP; + exports.unwrap = unwrap; + exports.expect = expect; + exports.unreachable = unreachable; +}); +enifed('@glimmer/wire-format', ['exports'], function (exports) { + 'use strict'; - // if expandLocalLookup returns falsey, we do not support local lookup - if (!fullName) { - return; - } + function is(variant) { + return function (value) { + return value[0] === variant; + }; } + var Expressions; + (function (Expressions) { + Expressions.isUnknown = is('unknown'); + Expressions.isArg = is('arg'); + Expressions.isGet = is('get'); + Expressions.isConcat = is('concat'); + Expressions.isHelper = is('helper'); + Expressions.isHasBlock = is('has-block'); + Expressions.isHasBlockParams = is('has-block-params'); + Expressions.isUndefined = is('undefined'); + function isPrimitiveValue(value) { + if (value === null) { + return true; + } + return typeof value !== 'object'; + } + Expressions.isPrimitiveValue = isPrimitiveValue; + })(Expressions || (exports.Expressions = Expressions = {})); + var Statements; + (function (Statements) { + Statements.isText = is('text'); + Statements.isAppend = is('append'); + Statements.isComment = is('comment'); + Statements.isModifier = is('modifier'); + Statements.isBlock = is('block'); + Statements.isComponent = is('component'); + Statements.isOpenElement = is('open-element'); + Statements.isFlushElement = is('flush-element'); + Statements.isCloseElement = is('close-element'); + Statements.isStaticAttr = is('static-attr'); + Statements.isDynamicAttr = is('dynamic-attr'); + Statements.isYield = is('yield'); + Statements.isPartial = is('partial'); + Statements.isDynamicArg = is('dynamic-arg'); + Statements.isStaticArg = is('static-arg'); + Statements.isTrustingAttr = is('trusting-attr'); + Statements.isDebugger = is('debugger'); + function isAttribute(val) { + return val[0] === 'static-attr' || val[0] === 'dynamic-attr'; + } + Statements.isAttribute = isAttribute; + function isArgument(val) { + return val[0] === 'static-arg' || val[0] === 'dynamic-arg'; + } + Statements.isArgument = isArgument; + function isParameter(val) { + return isAttribute(val) || isArgument(val); + } + Statements.isParameter = isParameter; + function getParameterName(s) { + return s[1]; + } + Statements.getParameterName = getParameterName; + })(Statements || (exports.Statements = Statements = {})); - var cache = container.factoryCache; - if (cache[fullName]) { - return cache[fullName]; - } - var factory = registry.resolve(fullName); - if (factory === undefined) { - return; - } + exports.is = is; + exports.Expressions = Expressions; + exports.Statements = Statements; +}); +enifed('backburner', ['exports'], function (exports) { 'use strict'; - var type = fullName.split(':')[0]; - if (!factory || typeof factory.extend !== 'function' || !_emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS && type === 'model') { - if (factory && typeof factory._onLookup === 'function') { - factory._onLookup(fullName); - } +var NUMBER = /\d+/; - // TODO: think about a 'safe' merge style extension - // for now just fallback to create time injection - cache[fullName] = factory; - return factory; - } else { - var injections = injectionsFor(container, fullName); - var factoryInjections = factoryInjectionsFor(container, fullName); - var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); +function each(collection, callback) { + for (var i = 0; i < collection.length; i++) { + callback(collection[i]); + } +} - factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); +function isString(suspect) { + return typeof suspect === 'string'; +} - var injectedFactory = factory.extend(injections); +function isFunction(suspect) { + return typeof suspect === 'function'; +} - // TODO - remove all `container` injections when Ember reaches v3.0.0 - injectDeprecatedContainer(injectedFactory.prototype, container); - injectedFactory.reopenClass(factoryInjections); +function isNumber(suspect) { + return typeof suspect === 'number'; +} - if (factory && typeof factory._onLookup === 'function') { - factory._onLookup(fullName); - } +function isCoercableNumber(number) { + return isNumber(number) || NUMBER.test(number); +} - if (cacheable) { - cache[fullName] = injectedFactory; - } +function binarySearch(time, timers) { + var start = 0; + var end = timers.length - 2; + var middle, l; - return injectedFactory; + while (start < end) { + // since timers is an array of pairs 'l' will always + // be an integer + l = (end - start) / 2; + + // compensate for the index in case even number + // of pairs inside timers + middle = start + l - (l % 2); + + if (time >= timers[middle]) { + start = middle + 2; + } else { + end = middle; } } - function injectionsFor(container, fullName) { - var registry = container.registry; - var splitName = fullName.split(':'); - var type = splitName[0]; + return (time >= timers[start]) ? start + 2 : start; +} - var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); - injections._debugContainerKey = fullName; +function Queue(name, options, globalOptions) { + this.name = name; + this.globalOptions = globalOptions || {}; + this.options = options; + this._queue = []; + this.targetQueues = {}; + this._queueBeingFlushed = undefined; +} - _emberUtils.setOwner(injections, container.owner); +Queue.prototype = { + push: function(target, method, args, stack) { + var queue = this._queue; + queue.push(target, method, args, stack); - return injections; - } + return { + queue: this, + target: target, + method: method + }; + }, - function factoryInjectionsFor(container, fullName) { - var registry = container.registry; - var splitName = fullName.split(':'); - var type = splitName[0]; + pushUniqueWithoutGuid: function(target, method, args, stack) { + var queue = this._queue; - var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); - factoryInjections._debugContainerKey = fullName; + for (var i = 0, l = queue.length; i < l; i += 4) { + var currentTarget = queue[i]; + var currentMethod = queue[i+1]; - return factoryInjections; - } + if (currentTarget === target && currentMethod === method) { + queue[i+2] = args; // replace args + queue[i+3] = stack; // replace stack + return; + } + } - function instantiate(container, fullName) { - var factory = factoryFor(container, fullName); - var lazyInjections = undefined, - validationCache = undefined; + queue.push(target, method, args, stack); + }, - if (container.registry.getOption(fullName, 'instantiate') === false) { - return factory; - } + targetQueue: function(targetQueue, target, method, args, stack) { + var queue = this._queue; - if (factory) { - if (typeof factory.create !== 'function') { - throw new Error('Failed to create an instance of \'' + fullName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); + for (var i = 0, l = targetQueue.length; i < l; i += 2) { + var currentMethod = targetQueue[i]; + var currentIndex = targetQueue[i + 1]; + + if (currentMethod === method) { + queue[currentIndex + 2] = args; // replace args + queue[currentIndex + 3] = stack; // replace stack + return; } + } - validationCache = container.validationCache; + targetQueue.push( + method, + queue.push(target, method, args, stack) - 4 + ); + }, - _emberMetal.runInDebug(function () { - // Ensure that all lazy injections are valid at instantiation time - if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') { - lazyInjections = factory._lazyInjections(); - lazyInjections = container.registry.normalizeInjectionsHash(lazyInjections); + pushUniqueWithGuid: function(guid, target, method, args, stack) { + var hasLocalQueue = this.targetQueues[guid]; - container.registry.validateInjections(lazyInjections); - } - }); + if (hasLocalQueue) { + this.targetQueue(hasLocalQueue, target, method, args, stack); + } else { + this.targetQueues[guid] = [ + method, + this._queue.push(target, method, args, stack) - 4 + ]; + } - validationCache[fullName] = true; + return { + queue: this, + target: target, + method: method + }; + }, - var obj = undefined; + pushUnique: function(target, method, args, stack) { + var KEY = this.globalOptions.GUID_KEY; - if (typeof factory.extend === 'function') { - // assume the factory was extendable and is already injected - obj = factory.create(); - } else { - // assume the factory was extendable - // to create time injections - // TODO: support new'ing for instantiation and merge injections for pure JS Functions - var injections = injectionsFor(container, fullName); + if (target && KEY) { + var guid = target[KEY]; + if (guid) { + return this.pushUniqueWithGuid(guid, target, method, args, stack); + } + } - // Ensure that a container is available to an object during instantiation. - // TODO - remove when Ember reaches v3.0.0 - // This "fake" container will be replaced after instantiation with a - // property that raises deprecations every time it is accessed. - injections.container = container._fakeContainerToInject; - obj = factory.create(injections); + this.pushUniqueWithoutGuid(target, method, args, stack); - // TODO - remove when Ember reaches v3.0.0 - if (!Object.isFrozen(obj) && 'container' in obj) { - injectDeprecatedContainer(obj, container); - } - } + return { + queue: this, + target: target, + method: method + }; + }, - return obj; + invoke: function(target, method, args /*, onError, errorRecordedForStack */) { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); } - } + }, - // TODO - remove when Ember reaches v3.0.0 - function injectDeprecatedContainer(object, container) { - Object.defineProperty(object, 'container', { - configurable: true, - enumerable: false, - get: function () { - _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); - return this[CONTAINER_OVERRIDE] || container; - }, + invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { + try { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); + } + } catch(error) { + onError(error, errorRecordedForStack); + } + }, - set: function (value) { - _emberMetal.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + flush: function(sync) { + var queue = this._queue; + var length = queue.length; - this[CONTAINER_OVERRIDE] = value; + if (length === 0) { + return; + } - return value; - } - }); - } + var globalOptions = this.globalOptions; + var options = this.options; + var before = options && options.before; + var after = options && options.after; + var onError = globalOptions.onError || (globalOptions.onErrorTarget && + globalOptions.onErrorTarget[globalOptions.onErrorMethod]); + var target, method, args, errorRecordedForStack; + var invoke = onError ? this.invokeWithOnError : this.invoke; - function eachDestroyable(container, callback) { - var cache = container.cache; - var keys = Object.keys(cache); + this.targetQueues = Object.create(null); + var queueItems = this._queueBeingFlushed = this._queue.slice(); + this._queue = []; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var value = cache[key]; + if (before) { + before(); + } - if (container.registry.getOption(key, 'instantiate') !== false) { - callback(value); + for (var i = 0; i < length; i += 4) { + target = queueItems[i]; + method = queueItems[i+1]; + args = queueItems[i+2]; + errorRecordedForStack = queueItems[i+3]; // Debugging assistance + + if (isString(method)) { + method = target[method]; } - } - } - function resetCache(container) { - eachDestroyable(container, function (value) { - if (value.destroy) { - value.destroy(); + // method could have been nullified / canceled during flush + if (method) { + // + // ** Attention intrepid developer ** + // + // To find out the stack of this task when it was scheduled onto + // the run loop, add the following to your app.js: + // + // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. + // + // Once that is in place, when you are at a breakpoint and navigate + // here in the stack explorer, you can look at `errorRecordedForStack.stack`, + // which will be the captured stack when this job was scheduled. + // + // One possible long-term solution is the following Chrome issue: + // https://bugs.chromium.org/p/chromium/issues/detail?id=332624 + // + invoke(target, method, args, onError, errorRecordedForStack); } - }); + } - container.cache.dict = _emberUtils.dictionary(null); - } + if (after) { + after(); + } - function resetMember(container, fullName) { - var member = container.cache[fullName]; + this._queueBeingFlushed = undefined; - delete container.factoryCache[fullName]; + if (sync !== false && + this._queue.length > 0) { + // check if new items have been added + this.flush(true); + } + }, - if (member) { - delete container.cache[fullName]; + cancel: function(actionToCancel) { + var queue = this._queue, currentTarget, currentMethod, i, l; + var target = actionToCancel.target; + var method = actionToCancel.method; + var GUID_KEY = this.globalOptions.GUID_KEY; - if (member.destroy) { - member.destroy(); + if (GUID_KEY && this.targetQueues && target) { + var targetQueue = this.targetQueues[target[GUID_KEY]]; + + if (targetQueue) { + for (i = 0, l = targetQueue.length; i < l; i++) { + if (targetQueue[i] === method) { + targetQueue.splice(i, 1); + } + } } } - } - function buildFakeContainerWithDeprecations(container) { - var fakeContainer = {}; - var propertyMappings = { - lookup: 'lookup', - lookupFactory: '_lookupFactory' - }; + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; - for (var containerProperty in propertyMappings) { - fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]); + if (currentTarget === target && + currentMethod === method) { + queue.splice(i, 4); + return true; + } } - return fakeContainer; - } + // if not found in current queue + // could be in the queue that is being flushed + queue = this._queueBeingFlushed; - function buildFakeContainerFunction(container, containerProperty, ownerProperty) { - return function () { - _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `' + ownerProperty + '` instead.', false, { - id: 'ember-application.injected-container', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' - }); - return container[containerProperty].apply(container, arguments); - }; + if (!queue) { + return; + } + + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; + + if (currentTarget === target && + currentMethod === method) { + // don't mess with array during flush + // just nullify the method + queue[i+1] = null; + return true; + } + } } -}); -enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) { - /* - Public API for the container is still in flux. - The public API, specified on the application namespace should be considered the stable API. - // @module container - @private - */ +}; - 'use strict'; +function DeferredActionQueues(queueNames, options) { + var queues = this.queues = {}; + this.queueNames = queueNames = queueNames || []; - exports.Registry = _containerRegistry.default; - exports.privatize = _containerRegistry.privatize; - exports.Container = _containerContainer.default; - exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations; -}); -enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) { - 'use strict'; + this.options = options; - exports.default = Registry; - exports.privatize = privatize; + each(queueNames, function(queueName) { + queues[queueName] = new Queue(queueName, options[queueName], options); + }); +} - var VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/; +function noSuchQueue(name) { + throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist'); +} - /** - A registry used to store factory and option information keyed - by type. - - A `Registry` stores the factory and option information needed by a - `Container` to instantiate and cache objects. - - The API for `Registry` is still in flux and should not be considered stable. - - @private - @class Registry - @since 1.11.0 - */ +function noSuchMethod(name) { + throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist'); +} - function Registry(options) { - this.fallback = options && options.fallback ? options.fallback : null; +DeferredActionQueues.prototype = { + schedule: function(name, target, method, args, onceFlag, stack) { + var queues = this.queues; + var queue = queues[name]; - if (options && options.resolver) { - this.resolver = options.resolver; + if (!queue) { + noSuchQueue(name); + } - if (typeof this.resolver === 'function') { - deprecateResolverFunction(this); - } + if (!method) { + noSuchMethod(name); } - this.registrations = _emberUtils.dictionary(options && options.registrations ? options.registrations : null); + if (onceFlag) { + return queue.pushUnique(target, method, args, stack); + } else { + return queue.push(target, method, args, stack); + } + }, - this._typeInjections = _emberUtils.dictionary(null); - this._injections = _emberUtils.dictionary(null); - this._factoryTypeInjections = _emberUtils.dictionary(null); - this._factoryInjections = _emberUtils.dictionary(null); + flush: function() { + var queues = this.queues; + var queueNames = this.queueNames; + var queueName, queue; + var queueNameIndex = 0; + var numberOfQueues = queueNames.length; - this._localLookupCache = new _emberUtils.EmptyObject(); - this._normalizeCache = _emberUtils.dictionary(null); - this._resolveCache = _emberUtils.dictionary(null); - this._failCache = _emberUtils.dictionary(null); + while (queueNameIndex < numberOfQueues) { + queueName = queueNames[queueNameIndex]; + queue = queues[queueName]; - this._options = _emberUtils.dictionary(null); - this._typeOptions = _emberUtils.dictionary(null); + var numberOfQueueItems = queue._queue.length; + + if (numberOfQueueItems === 0) { + queueNameIndex++; + } else { + queue.flush(false /* async */); + queueNameIndex = 0; + } + } } +}; - Registry.prototype = { - /** - A backup registry for resolving registrations when no matches can be found. - @private - @property fallback - @type Registry - */ - fallback: null, +function Backburner(queueNames, options) { + this.queueNames = queueNames; + this.options = options || {}; + if (!this.options.defaultQueue) { + this.options.defaultQueue = queueNames[0]; + } + this.instanceStack = []; + this._debouncees = []; + this._throttlers = []; + this._eventCallbacks = { + end: [], + begin: [] + }; - /** - An object that has a `resolve` method that resolves a name. - @private - @property resolver - @type Resolver - */ - resolver: null, + var _this = this; + this._boundClearItems = function() { + clearItems(); + }; - /** - @private - @property registrations - @type InheritingDict - */ - registrations: null, + this._timerTimeoutId = undefined; + this._timers = []; - /** - @private - @property _typeInjections - @type InheritingDict - */ - _typeInjections: null, + this._platform = this.options._platform || { + setTimeout: function (fn, ms) { + return setTimeout(fn, ms); + }, + clearTimeout: function (id) { + clearTimeout(id); + } + }; - /** - @private - @property _injections - @type InheritingDict - */ - _injections: null, + this._boundRunExpiredTimers = function () { + _this._runExpiredTimers(); + }; +} - /** - @private - @property _factoryTypeInjections - @type InheritingDict - */ - _factoryTypeInjections: null, +Backburner.prototype = { + begin: function() { + var options = this.options; + var onBegin = options && options.onBegin; + var previousInstance = this.currentInstance; - /** - @private - @property _factoryInjections - @type InheritingDict - */ - _factoryInjections: null, + if (previousInstance) { + this.instanceStack.push(previousInstance); + } - /** - @private - @property _normalizeCache - @type InheritingDict - */ - _normalizeCache: null, + this.currentInstance = new DeferredActionQueues(this.queueNames, options); + this._trigger('begin', this.currentInstance, previousInstance); + if (onBegin) { + onBegin(this.currentInstance, previousInstance); + } + }, - /** - @private - @property _resolveCache - @type InheritingDict - */ - _resolveCache: null, + end: function() { + var options = this.options; + var onEnd = options && options.onEnd; + var currentInstance = this.currentInstance; + var nextInstance = null; - /** - @private - @property _options - @type InheritingDict - */ - _options: null, - - /** - @private - @property _typeOptions - @type InheritingDict - */ - _typeOptions: null, + // Prevent double-finally bug in Safari 6.0.2 and iOS 6 + // This bug appears to be resolved in Safari 6.0.5 and iOS 7 + var finallyAlreadyCalled = false; + try { + currentInstance.flush(); + } finally { + if (!finallyAlreadyCalled) { + finallyAlreadyCalled = true; - /** - Creates a container based on this registry. - @private - @method container - @param {Object} options - @return {Container} created container - */ - container: function (options) { - return new _containerContainer.default(this, options); - }, + this.currentInstance = null; - /** - Registers a factory for later injection. - Example: - ```javascript - let registry = new Registry(); - registry.register('model:user', Person, {singleton: false }); - registry.register('fruit:favorite', Orange); - registry.register('communication:main', Email, {singleton: false}); - ``` - @private - @method register - @param {String} fullName - @param {Function} factory - @param {Object} options - */ - register: function (fullName, factory) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + if (this.instanceStack.length) { + nextInstance = this.instanceStack.pop(); + this.currentInstance = nextInstance; + } + this._trigger('end', currentInstance, nextInstance); + if (onEnd) { + onEnd(currentInstance, nextInstance); + } + } + } + }, - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + /** + Trigger an event. Supports up to two arguments. Designed around + triggering transition events from one run loop instance to the + next, which requires an argument for the first instance and then + an argument for the next instance. - if (factory === undefined) { - throw new TypeError('Attempting to register an unknown factory: \'' + fullName + '\''); + @private + @method _trigger + @param {String} eventName + @param {any} arg1 + @param {any} arg2 + */ + _trigger: function(eventName, arg1, arg2) { + var callbacks = this._eventCallbacks[eventName]; + if (callbacks) { + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](arg1, arg2); } + } + }, - var normalizedName = this.normalize(fullName); + on: function(eventName, callback) { + if (typeof callback !== 'function') { + throw new TypeError('Callback must be a function'); + } + var callbacks = this._eventCallbacks[eventName]; + if (callbacks) { + callbacks.push(callback); + } else { + throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist'); + } + }, - if (this._resolveCache[normalizedName]) { - throw new Error('Cannot re-register: \'' + fullName + '\', as it has already been resolved.'); + off: function(eventName, callback) { + if (eventName) { + var callbacks = this._eventCallbacks[eventName]; + var callbackFound = false; + if (!callbacks) return; + if (callback) { + for (var i = 0; i < callbacks.length; i++) { + if (callbacks[i] === callback) { + callbackFound = true; + callbacks.splice(i, 1); + i--; + } + } + } + if (!callbackFound) { + throw new TypeError('Cannot off() callback that does not exist'); } + } else { + throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist'); + } + }, - delete this._failCache[normalizedName]; - this.registrations[normalizedName] = factory; - this._options[normalizedName] = options; - }, + run: function(/* target, method, args */) { + var length = arguments.length; + var method, target, args; - /** - Unregister a fullName - ```javascript - let registry = new Registry(); - registry.register('model:user', User); - registry.resolve('model:user').create() instanceof User //=> true - registry.unregister('model:user') - registry.resolve('model:user') === undefined //=> true - ``` - @private - @method unregister - @param {String} fullName - */ - unregister: function (fullName) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + if (length === 1) { + method = arguments[0]; + target = null; + } else { + target = arguments[0]; + method = arguments[1]; + } - var normalizedName = this.normalize(fullName); + if (isString(method)) { + method = target[method]; + } - this._localLookupCache = new _emberUtils.EmptyObject(); + if (length > 2) { + args = new Array(length - 2); + for (var i = 0, l = length - 2; i < l; i++) { + args[i] = arguments[i + 2]; + } + } else { + args = []; + } - delete this.registrations[normalizedName]; - delete this._resolveCache[normalizedName]; - delete this._failCache[normalizedName]; - delete this._options[normalizedName]; - }, + var onError = getOnError(this.options); - /** - Given a fullName return the corresponding factory. - By default `resolve` will retrieve the factory from - the registry. - ```javascript - let registry = new Registry(); - registry.register('api:twitter', Twitter); - registry.resolve('api:twitter') // => Twitter - ``` - Optionally the registry can be provided with a custom resolver. - If provided, `resolve` will first provide the custom resolver - the opportunity to resolve the fullName, otherwise it will fallback - to the registry. - ```javascript - let registry = new Registry(); - registry.resolver = function(fullName) { - // lookup via the module system of choice - }; - // the twitter factory is added to the module system - registry.resolve('api:twitter') // => Twitter - ``` - @private - @method resolve - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {Function} fullName's factory - */ - resolve: function (fullName, options) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - var factory = resolve(this, this.normalize(fullName), options); - if (factory === undefined && this.fallback) { - var _fallback; + this.begin(); - factory = (_fallback = this.fallback).resolve.apply(_fallback, arguments); - } - return factory; - }, + // guard against Safari 6's double-finally bug + var didFinally = false; - /** - A hook that can be used to describe how the resolver will - attempt to find the factory. - For example, the default Ember `.describe` returns the full - class name (including namespace) where Ember's resolver expects - to find the `fullName`. - @private - @method describe - @param {String} fullName - @return {string} described fullName - */ - describe: function (fullName) { - if (this.resolver && this.resolver.lookupDescription) { - return this.resolver.lookupDescription(fullName); - } else if (this.fallback) { - return this.fallback.describe(fullName); - } else { - return fullName; + if (onError) { + try { + return method.apply(target, args); + } catch(error) { + onError(error); + } finally { + if (!didFinally) { + didFinally = true; + this.end(); + } } - }, - - /** - A hook to enable custom fullName normalization behaviour - @private - @method normalizeFullName - @param {String} fullName - @return {string} normalized fullName - */ - normalizeFullName: function (fullName) { - if (this.resolver && this.resolver.normalize) { - return this.resolver.normalize(fullName); - } else if (this.fallback) { - return this.fallback.normalizeFullName(fullName); - } else { - return fullName; + } else { + try { + return method.apply(target, args); + } finally { + if (!didFinally) { + didFinally = true; + this.end(); + } } - }, + } + }, - /** - Normalize a fullName based on the application's conventions - @private - @method normalize - @param {String} fullName - @return {string} normalized fullName - */ - normalize: function (fullName) { - return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName)); - }, + /* + Join the passed method with an existing queue and execute immediately, + if there isn't one use `Backburner#run`. - /** - @method makeToString - @private - @param {any} factory - @param {string} fullName - @return {function} toString function - */ - makeToString: function (factory, fullName) { - if (this.resolver && this.resolver.makeToString) { - return this.resolver.makeToString(factory, fullName); - } else if (this.fallback) { - return this.fallback.makeToString(factory, fullName); - } else { - return factory.toString(); - } - }, + The join method is like the run method except that it will schedule into + an existing queue if one already exists. In either case, the join method will + immediately execute the passed in function and return its result. - /** - Given a fullName check if the container is aware of its factory - or singleton instance. - @private - @method has - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {Boolean} - */ - has: function (fullName, options) { - if (!this.isValidFullName(fullName)) { - return false; - } + @method join + @param {Object} target + @param {Function} method The method to be executed + @param {any} args The method arguments + @return method result + */ + join: function(/* target, method, args */) { + if (!this.currentInstance) { + return this.run.apply(this, arguments); + } - var source = options && options.source && this.normalize(options.source); + var length = arguments.length; + var method, target; - return has(this, this.normalize(fullName), source); - }, + if (length === 1) { + method = arguments[0]; + target = null; + } else { + target = arguments[0]; + method = arguments[1]; + } - /** - Allow registering options for all factories of a type. - ```javascript - let registry = new Registry(); - let container = registry.container(); - // if all of type `connection` must not be singletons - registry.optionsForType('connection', { singleton: false }); - registry.register('connection:twitter', TwitterConnection); - registry.register('connection:facebook', FacebookConnection); - let twitter = container.lookup('connection:twitter'); - let twitter2 = container.lookup('connection:twitter'); - twitter === twitter2; // => false - let facebook = container.lookup('connection:facebook'); - let facebook2 = container.lookup('connection:facebook'); - facebook === facebook2; // => false - ``` - @private - @method optionsForType - @param {String} type - @param {Object} options - */ - optionsForType: function (type, options) { - this._typeOptions[type] = options; - }, + if (isString(method)) { + method = target[method]; + } - getOptionsForType: function (type) { - var optionsForType = this._typeOptions[type]; - if (optionsForType === undefined && this.fallback) { - optionsForType = this.fallback.getOptionsForType(type); + if (length === 1) { + return method(); + } else if (length === 2) { + return method.call(target); + } else { + var args = new Array(length - 2); + for (var i = 0, l = length - 2; i < l; i++) { + args[i] = arguments[i + 2]; } - return optionsForType; - }, + return method.apply(target, args); + } + }, - /** - @private - @method options - @param {String} fullName - @param {Object} options - */ - options: function (fullName) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var normalizedName = this.normalize(fullName); - this._options[normalizedName] = options; - }, + /* + Defer the passed function to run inside the specified queue. - getOptions: function (fullName) { - var normalizedName = this.normalize(fullName); - var options = this._options[normalizedName]; + @method defer + @param {String} queueName + @param {Object} target + @param {Function|String} method The method or method name to be executed + @param {any} args The method arguments + @return method result + */ + defer: function(queueName /* , target, method, args */) { + var length = arguments.length; + var method, target, args; - if (options === undefined && this.fallback) { - options = this.fallback.getOptions(fullName); - } - return options; - }, + if (length === 2) { + method = arguments[1]; + target = null; + } else { + target = arguments[1]; + method = arguments[2]; + } - getOption: function (fullName, optionName) { - var options = this._options[fullName]; + if (isString(method)) { + method = target[method]; + } - if (options && options[optionName] !== undefined) { - return options[optionName]; + var stack = this.DEBUG ? new Error() : undefined; + + if (length > 3) { + args = new Array(length - 3); + for (var i = 3; i < length; i++) { + args[i-3] = arguments[i]; } + } else { + args = undefined; + } - var type = fullName.split(':')[0]; - options = this._typeOptions[type]; + if (!this.currentInstance) { createAutorun(this); } + return this.currentInstance.schedule(queueName, target, method, args, false, stack); + }, - if (options && options[optionName] !== undefined) { - return options[optionName]; - } else if (this.fallback) { - return this.fallback.getOption(fullName, optionName); - } - }, + deferOnce: function(queueName /* , target, method, args */) { + var length = arguments.length; + var method, target, args; - /** - Used only via `injection`. - Provides a specialized form of injection, specifically enabling - all objects of one type to be injected with a reference to another - object. - For example, provided each object of type `controller` needed a `router`. - one would do the following: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('router:main', Router); - registry.register('controller:user', UserController); - registry.register('controller:post', PostController); - registry.typeInjection('controller', 'router', 'router:main'); - let user = container.lookup('controller:user'); - let post = container.lookup('controller:post'); - user.router instanceof Router; //=> true - post.router instanceof Router; //=> true - // both controllers share the same router - user.router === post.router; //=> true - ``` - @private - @method typeInjection - @param {String} type - @param {String} property - @param {String} fullName - */ - typeInjection: function (type, property, fullName) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + if (length === 2) { + method = arguments[1]; + target = null; + } else { + target = arguments[1]; + method = arguments[2]; + } - var fullNameType = fullName.split(':')[0]; - if (fullNameType === type) { - throw new Error('Cannot inject a \'' + fullName + '\' on other ' + type + '(s).'); + if (isString(method)) { + method = target[method]; + } + + var stack = this.DEBUG ? new Error() : undefined; + + if (length > 3) { + args = new Array(length - 3); + for (var i = 3; i < length; i++) { + args[i-3] = arguments[i]; } + } else { + args = undefined; + } - var injections = this._typeInjections[type] || (this._typeInjections[type] = []); + if (!this.currentInstance) { + createAutorun(this); + } + return this.currentInstance.schedule(queueName, target, method, args, true, stack); + }, - injections.push({ - property: property, - fullName: fullName - }); - }, + setTimeout: function() { + var l = arguments.length; + var args = new Array(l); - /** - Defines injection rules. - These rules are used to inject dependencies onto objects when they - are instantiated. - Two forms of injections are possible: - * Injecting one fullName on another fullName - * Injecting one fullName on a type - Example: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('source:main', Source); - registry.register('model:user', User); - registry.register('model:post', Post); - // injecting one fullName on another fullName - // eg. each user model gets a post model - registry.injection('model:user', 'post', 'model:post'); - // injecting one fullName on another type - registry.injection('model', 'source', 'source:main'); - let user = container.lookup('model:user'); - let post = container.lookup('model:post'); - user.source instanceof Source; //=> true - post.source instanceof Source; //=> true - user.post instanceof Post; //=> true - // and both models share the same source - user.source === post.source; //=> true - ``` - @private - @method injection - @param {String} factoryName - @param {String} property - @param {String} injectionName - */ - injection: function (fullName, property, injectionName) { - this.validateFullName(injectionName); - var normalizedInjectionName = this.normalize(injectionName); - - if (fullName.indexOf(':') === -1) { - return this.typeInjection(fullName, property, normalizedInjectionName); - } - - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - var normalizedName = this.normalize(fullName); - - var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); + for (var x = 0; x < l; x++) { + args[x] = arguments[x]; + } - injections.push({ - property: property, - fullName: normalizedInjectionName - }); - }, + var length = args.length, + method, wait, target, + methodOrTarget, methodOrWait, methodOrArgs; - /** - Used only via `factoryInjection`. - Provides a specialized form of injection, specifically enabling - all factory of one type to be injected with a reference to another - object. - For example, provided each factory of type `model` needed a `store`. - one would do the following: - ```javascript - let registry = new Registry(); - registry.register('store:main', SomeStore); - registry.factoryTypeInjection('model', 'store', 'store:main'); - let store = registry.lookup('store:main'); - let UserFactory = registry.lookupFactory('model:user'); - UserFactory.store instanceof SomeStore; //=> true - ``` - @private - @method factoryTypeInjection - @param {String} type - @param {String} property - @param {String} fullName - */ - factoryTypeInjection: function (type, property, fullName) { - var injections = this._factoryTypeInjections[type] || (this._factoryTypeInjections[type] = []); + if (length === 0) { + return; + } else if (length === 1) { + method = args.shift(); + wait = 0; + } else if (length === 2) { + methodOrTarget = args[0]; + methodOrWait = args[1]; - injections.push({ - property: property, - fullName: this.normalize(fullName) - }); - }, + if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { + target = args.shift(); + method = args.shift(); + wait = 0; + } else if (isCoercableNumber(methodOrWait)) { + method = args.shift(); + wait = args.shift(); + } else { + method = args.shift(); + wait = 0; + } + } else { + var last = args[args.length - 1]; - /** - Defines factory injection rules. - Similar to regular injection rules, but are run against factories, via - `Registry#lookupFactory`. - These rules are used to inject objects onto factories when they - are looked up. - Two forms of injections are possible: - * Injecting one fullName on another fullName - * Injecting one fullName on a type - Example: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('store:main', Store); - registry.register('store:secondary', OtherStore); - registry.register('model:user', User); - registry.register('model:post', Post); - // injecting one fullName on another type - registry.factoryInjection('model', 'store', 'store:main'); - // injecting one fullName on another fullName - registry.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); - let UserFactory = container.lookupFactory('model:user'); - let PostFactory = container.lookupFactory('model:post'); - let store = container.lookup('store:main'); - UserFactory.store instanceof Store; //=> true - UserFactory.secondaryStore instanceof OtherStore; //=> false - PostFactory.store instanceof Store; //=> true - PostFactory.secondaryStore instanceof OtherStore; //=> true - // and both models share the same source instance - UserFactory.store === PostFactory.store; //=> true - ``` - @private - @method factoryInjection - @param {String} factoryName - @param {String} property - @param {String} injectionName - */ - factoryInjection: function (fullName, property, injectionName) { - var normalizedName = this.normalize(fullName); - var normalizedInjectionName = this.normalize(injectionName); + if (isCoercableNumber(last)) { + wait = args.pop(); + } else { + wait = 0; + } - this.validateFullName(injectionName); + methodOrTarget = args[0]; + methodOrArgs = args[1]; - if (fullName.indexOf(':') === -1) { - return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); + if (isFunction(methodOrArgs) || (isString(methodOrArgs) && + methodOrTarget !== null && + methodOrArgs in methodOrTarget)) { + target = args.shift(); + method = args.shift(); + } else { + method = args.shift(); } + } - var injections = this._factoryInjections[normalizedName] || (this._factoryInjections[normalizedName] = []); - - injections.push({ - property: property, - fullName: normalizedInjectionName - }); - }, + var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); - /** - @private - @method knownForType - @param {String} type the type to iterate over - */ - knownForType: function (type) { - var fallbackKnown = undefined, - resolverKnown = undefined; + if (isString(method)) { + method = target[method]; + } - var localKnown = _emberUtils.dictionary(null); - var registeredNames = Object.keys(this.registrations); - for (var index = 0; index < registeredNames.length; index++) { - var fullName = registeredNames[index]; - var itemType = fullName.split(':')[0]; + var onError = getOnError(this.options); - if (itemType === type) { - localKnown[fullName] = true; + function fn() { + if (onError) { + try { + method.apply(target, args); + } catch (e) { + onError(e); } + } else { + method.apply(target, args); } + } - if (this.fallback) { - fallbackKnown = this.fallback.knownForType(type); - } - - if (this.resolver && this.resolver.knownForType) { - resolverKnown = this.resolver.knownForType(type); - } - - return _emberUtils.assign({}, fallbackKnown, localKnown, resolverKnown); - }, + return this._setTimeout(fn, executeAt); + }, - validateFullName: function (fullName) { - if (!this.isValidFullName(fullName)) { - throw new TypeError('Invalid Fullname, expected: \'type:name\' got: ' + fullName); - } + _setTimeout: function (fn, executeAt) { + if (this._timers.length === 0) { + this._timers.push(executeAt, fn); + this._installTimerTimeout(); + return fn; + } - return true; - }, + // find position to insert + var i = binarySearch(executeAt, this._timers); - isValidFullName: function (fullName) { - return !!VALID_FULL_NAME_REGEXP.test(fullName); - }, + this._timers.splice(i, 0, executeAt, fn); - validateInjections: function (injections) { - if (!injections) { - return; - } + // we should be the new earliest timer if i == 0 + if (i === 0) { + this._reinstallTimerTimeout(); + } - var fullName = undefined; + return fn; + }, - for (var i = 0; i < injections.length; i++) { - fullName = injections[i].fullName; + throttle: function(target, method /* , args, wait, [immediate] */) { + var backburner = this; + var args = new Array(arguments.length); + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + var immediate = args.pop(); + var wait, throttler, index, timer; - if (!this.has(fullName)) { - throw new Error('Attempting to inject an unknown injection: \'' + fullName + '\''); - } - } - }, + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = true; + } else { + wait = args.pop(); + } - normalizeInjectionsHash: function (hash) { - var injections = []; + wait = parseInt(wait, 10); - for (var key in hash) { - if (hash.hasOwnProperty(key)) { - _emberMetal.assert('Expected a proper full name, given \'' + hash[key] + '\'', this.validateFullName(hash[key])); + index = findThrottler(target, method, this._throttlers); + if (index > -1) { return this._throttlers[index]; } // throttled - injections.push({ - property: key, - fullName: hash[key] - }); - } + timer = this._platform.setTimeout(function() { + if (!immediate) { + backburner.run.apply(backburner, args); } - - return injections; - }, - - getInjections: function (fullName) { - var injections = this._injections[fullName] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getInjections(fullName)); + var index = findThrottler(target, method, backburner._throttlers); + if (index > -1) { + backburner._throttlers.splice(index, 1); } - return injections; - }, + }, wait); - getTypeInjections: function (type) { - var injections = this._typeInjections[type] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getTypeInjections(type)); - } - return injections; - }, + if (immediate) { + this.run.apply(this, args); + } - getFactoryInjections: function (fullName) { - var injections = this._factoryInjections[fullName] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getFactoryInjections(fullName)); - } - return injections; - }, + throttler = [target, method, timer]; - getFactoryTypeInjections: function (type) { - var injections = this._factoryTypeInjections[type] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getFactoryTypeInjections(type)); - } - return injections; - } - }; + this._throttlers.push(throttler); - function deprecateResolverFunction(registry) { - _emberMetal.deprecate('Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.', false, { id: 'ember-application.registry-resolver-as-function', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function' }); - registry.resolver = { - resolve: registry.resolver - }; - } + return throttler; + }, - /** - Given a fullName and a source fullName returns the fully resolved - fullName. Used to allow for local lookup. - - ```javascript - let registry = new Registry(); - - // the twitter factory is added to the module system - registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title - ``` - - @private - @method expandLocalLookup - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {String} fullName - */ - Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) { - if (this.resolver && this.resolver.expandLocalLookup) { - _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - _emberMetal.assert('options.source must be provided to expandLocalLookup', options && options.source); - _emberMetal.assert('options.source must be a proper full name', this.validateFullName(options.source)); + debounce: function(target, method /* , args, wait, [immediate] */) { + var backburner = this; + var args = new Array(arguments.length); + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } - var normalizedFullName = this.normalize(fullName); - var normalizedSource = this.normalize(options.source); + var immediate = args.pop(); + var wait, index, debouncee, timer; - return expandLocalLookup(this, normalizedFullName, normalizedSource); - } else if (this.fallback) { - return this.fallback.expandLocalLookup(fullName, options); + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = false; } else { - return null; + wait = args.pop(); } - }; - function expandLocalLookup(registry, normalizedName, normalizedSource) { - var cache = registry._localLookupCache; - var normalizedNameCache = cache[normalizedName]; + wait = parseInt(wait, 10); + // Remove debouncee + index = findDebouncee(target, method, this._debouncees); - if (!normalizedNameCache) { - normalizedNameCache = cache[normalizedName] = new _emberUtils.EmptyObject(); + if (index > -1) { + debouncee = this._debouncees[index]; + this._debouncees.splice(index, 1); + this._platform.clearTimeout(debouncee[2]); } - var cached = normalizedNameCache[normalizedSource]; + timer = this._platform.setTimeout(function() { + if (!immediate) { + backburner.run.apply(backburner, args); + } + var index = findDebouncee(target, method, backburner._debouncees); + if (index > -1) { + backburner._debouncees.splice(index, 1); + } + }, wait); - if (cached !== undefined) { - return cached; + if (immediate && index === -1) { + backburner.run.apply(backburner, args); } - var expanded = registry.resolver.expandLocalLookup(normalizedName, normalizedSource); + debouncee = [ + target, + method, + timer + ]; - return normalizedNameCache[normalizedSource] = expanded; - } + backburner._debouncees.push(debouncee); - function resolve(registry, normalizedName, options) { - if (options && options.source) { - // when `source` is provided expand normalizedName - // and source into the full normalizedName - normalizedName = registry.expandLocalLookup(normalizedName, options); + return debouncee; + }, - // if expandLocalLookup returns falsey, we do not support local lookup - if (!normalizedName) { - return; - } - } + cancelTimers: function() { + each(this._throttlers, this._boundClearItems); + this._throttlers = []; - var cached = registry._resolveCache[normalizedName]; - if (cached !== undefined) { - return cached; - } - if (registry._failCache[normalizedName]) { - return; - } + each(this._debouncees, this._boundClearItems); + this._debouncees = []; - var resolved = undefined; + this._clearTimerTimeout(); + this._timers = []; - if (registry.resolver) { - resolved = registry.resolver.resolve(normalizedName); + if (this._autorun) { + this._platform.clearTimeout(this._autorun); + this._autorun = null; } + }, - if (resolved === undefined) { - resolved = registry.registrations[normalizedName]; - } + hasTimers: function() { + return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; + }, - if (resolved === undefined) { - registry._failCache[normalizedName] = true; + cancel: function (timer) { + var timerType = typeof timer; + + if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce + return timer.queue.cancel(timer); + } else if (timerType === 'function') { // we're cancelling a setTimeout + for (var i = 0, l = this._timers.length; i < l; i += 2) { + if (this._timers[i + 1] === timer) { + this._timers.splice(i, 2); // remove the two elements + if (i === 0) { + this._reinstallTimerTimeout(); + } + return true; + } + } + } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce + return this._cancelItem(findThrottler, this._throttlers, timer) || + this._cancelItem(findDebouncee, this._debouncees, timer); } else { - registry._resolveCache[normalizedName] = resolved; + return; // timer was null or not a timer } + }, - return resolved; - } + _cancelItem: function(findMethod, array, timer){ + var item, index; - function has(registry, fullName, source) { - return registry.resolve(fullName, { source: source }) !== undefined; - } + if (timer.length < 3) { return false; } - var privateNames = _emberUtils.dictionary(null); - var privateSuffix = '' + Math.random() + Date.now(); + index = findMethod(timer[0], timer[1], array); - function privatize(_ref) { - var fullName = _ref[0]; + if (index > -1) { - var name = privateNames[fullName]; - if (name) { - return name; + item = array[index]; + + if (item[2] === timer[2]) { + array.splice(index, 1); + this._platform.clearTimeout(timer[2]); + return true; + } } - var _fullName$split = fullName.split(':'); + return false; + }, - var type = _fullName$split[0]; - var rawName = _fullName$split[1]; + _runExpiredTimers: function () { + this._timerTimeoutId = undefined; + this.run(this, this._scheduleExpiredTimers); + }, - return privateNames[fullName] = _emberUtils.intern(type + ':' + rawName + '-' + privateSuffix); - } -}); -enifed('dag-map', ['exports'], function (exports) { 'use strict'; + _scheduleExpiredTimers: function () { + var n = Date.now(); + var timers = this._timers; + var i = 0; + var l = timers.length; + for (; i < l; i += 2) { + var executeAt = timers[i]; + var fn = timers[i+1]; + if (executeAt <= n) { + this.schedule(this.options.defaultQueue, null, fn); + } else { + break; + } + } + timers.splice(0, i); + this._installTimerTimeout(); + }, -/** - * A map of key/value pairs with dependencies contraints that can be traversed - * in topological order and is checked for cycles. - * - * @class DAG - * @constructor - */ -var DAG = (function () { - function DAG() { - this._vertices = new Vertices(); - } - /** - * Adds a key/value pair with dependencies on other key/value pairs. - * - * @public - * @method addEdges - * @param {string[]} key The key of the vertex to be added. - * @param {any} value The value of that vertex. - * @param {string[]|string|undefined} before A key or array of keys of the vertices that must - * be visited before this vertex. - * @param {string[]|string|undefined} after An string or array of strings with the keys of the - * vertices that must be after this vertex is visited. - */ - DAG.prototype.add = function (key, value, before, after) { - var vertices = this._vertices; - var v = vertices.add(key); - v.val = value; - if (before) { - if (typeof before === "string") { - vertices.addEdge(v, vertices.add(before)); - } - else { - for (var i = 0; i < before.length; i++) { - vertices.addEdge(v, vertices.add(before[i])); - } - } - } - if (after) { - if (typeof after === "string") { - vertices.addEdge(vertices.add(after), v); - } - else { - for (var i = 0; i < after.length; i++) { - vertices.addEdge(vertices.add(after[i]), v); - } - } - } - }; - /** - * Visits key/value pairs in topological order. - * - * @public - * @method topsort - * @param {Function} fn The function to be invoked with each key/value. - */ - DAG.prototype.topsort = function (callback) { - this._vertices.topsort(callback); - }; - return DAG; -}()); -var Vertices = (function () { - function Vertices() { - this.stack = new IntStack(); - this.result = new IntStack(); - this.vertices = []; + _reinstallTimerTimeout: function () { + this._clearTimerTimeout(); + this._installTimerTimeout(); + }, + + _clearTimerTimeout: function () { + if (!this._timerTimeoutId) { + return; } - Vertices.prototype.add = function (key) { - if (!key) - throw new Error("missing key"); - var vertices = this.vertices; - var i = 0; - var vertex; - for (; i < vertices.length; i++) { - vertex = vertices[i]; - if (vertex.key === key) - return vertex; - } - return vertices[i] = { - id: i, - key: key, - val: null, - inc: null, - out: false, - mark: false - }; - }; - Vertices.prototype.addEdge = function (v, w) { - this.check(v, w.key); - var inc = w.inc; - if (!inc) { - w.inc = [v.id]; - } - else { - var i = 0; - for (; i < inc.length; i++) { - if (inc[i] === v.id) - return; - } - inc[i] = v.id; - } - v.out = true; - }; - Vertices.prototype.topsort = function (cb) { - this.reset(); - var vertices = this.vertices; - for (var i = 0; i < vertices.length; i++) { - var vertex = vertices[i]; - if (vertex.out) - continue; - this.visit(vertex, undefined); - } - this.each(cb); - }; - Vertices.prototype.check = function (v, w) { - if (v.key === w) { - throw new Error("cycle detected: " + w + " <- " + w); - } - var inc = v.inc; - // quick check - if (!inc || inc.length === 0) - return; - var vertices = this.vertices; - // shallow check - for (var i = 0; i < inc.length; i++) { - var key = vertices[inc[i]].key; - if (key === w) { - throw new Error("cycle detected: " + w + " <- " + v.key + " <- " + w); - } - } - // deep check - this.reset(); - this.visit(v, w); - if (this.result.len > 0) { - var msg_1 = "cycle detected: " + w; - this.each(function (key) { - msg_1 += " <- " + key; - }); - throw new Error(msg_1); - } - }; - Vertices.prototype.each = function (cb) { - var _a = this, result = _a.result, vertices = _a.vertices; - for (var i = 0; i < result.len; i++) { - var vertex = vertices[result.stack[i]]; - cb(vertex.key, vertex.val); - } - }; - // reuse between cycle check and topsort - Vertices.prototype.reset = function () { - this.stack.len = 0; - this.result.len = 0; - var vertices = this.vertices; - for (var i = 0; i < vertices.length; i++) { - vertices[i].mark = false; - } - }; - Vertices.prototype.visit = function (start, search) { - var _a = this, stack = _a.stack, result = _a.result, vertices = _a.vertices; - stack.push(start.id); - while (stack.len) { - var index = stack.pop(); - if (index < 0) { - index = ~index; - if (search) { - result.pop(); - } - else { - result.push(index); - } - } - else { - var vertex = vertices[index]; - if (vertex.mark) { - continue; - } - if (search) { - result.push(index); - if (search === vertex.key) { - return; - } - } - vertex.mark = true; - stack.push(~index); - var incoming = vertex.inc; - if (incoming) { - var i = incoming.length; - while (i--) { - index = incoming[i]; - if (!vertices[index].mark) { - stack.push(index); - } - } - } - } - } - }; - return Vertices; -}()); -var IntStack = (function () { - function IntStack() { - this.stack = [0, 0, 0, 0, 0, 0]; - this.len = 0; + this._platform.clearTimeout(this._timerTimeoutId); + this._timerTimeoutId = undefined; + }, + + _installTimerTimeout: function () { + if (!this._timers.length) { + return; } - IntStack.prototype.push = function (n) { - this.stack[this.len++] = n; - }; - IntStack.prototype.pop = function () { - return this.stack[--this.len]; - }; - return IntStack; -}()); + var minExpiresAt = this._timers[0]; + var n = Date.now(); + var wait = Math.max(0, minExpiresAt - n); + this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); + } +}; -exports['default'] = DAG; +Backburner.prototype.schedule = Backburner.prototype.defer; +Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; +Backburner.prototype.later = Backburner.prototype.setTimeout; -Object.defineProperty(exports, '__esModule', { value: true }); +function getOnError(options) { + return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); +} -}); -enifed('ember-application/index', ['exports', 'ember-application/initializers/dom-templates', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/resolver', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (exports, _emberApplicationInitializersDomTemplates, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberApplicationSystemResolver, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent) { - /** - @module ember - @submodule ember-application - */ +function createAutorun(backburner) { + var setTimeout = backburner._platform.setTimeout; + backburner.begin(); + backburner._autorun = setTimeout(function() { + backburner._autorun = null; + backburner.end(); + }, 0); +} - 'use strict'; +function findDebouncee(target, method, debouncees) { + return findItem(target, method, debouncees); +} - exports.Application = _emberApplicationSystemApplication.default; - exports.ApplicationInstance = _emberApplicationSystemApplicationInstance.default; - exports.Resolver = _emberApplicationSystemResolver.default; - exports.Engine = _emberApplicationSystemEngine.default; - exports.EngineInstance = _emberApplicationSystemEngineInstance.default; - exports.getEngineParent = _emberApplicationSystemEngineParent.getEngineParent; - exports.setEngineParent = _emberApplicationSystemEngineParent.setEngineParent; +function findThrottler(target, method, throttlers) { + return findItem(target, method, throttlers); +} - // add domTemplates initializer (only does something if `ember-template-compiler` - // is loaded already) -}); -enifed('ember-application/initializers/dom-templates', ['exports', 'require', 'ember-glimmer', 'ember-environment', 'ember-application/system/application'], function (exports, _require, _emberGlimmer, _emberEnvironment, _emberApplicationSystemApplication) { - 'use strict'; +function findItem(target, method, collection) { + var item; + var index = -1; - var bootstrap = function () {}; + for (var i = 0, l = collection.length; i < l; i++) { + item = collection[i]; + if (item[0] === target && item[1] === method) { + index = i; + break; + } + } - _emberApplicationSystemApplication.default.initializer({ - name: 'domTemplates', - initialize: function () { - var bootstrapModuleId = 'ember-template-compiler/system/bootstrap'; - var context = undefined; - if (_emberEnvironment.environment.hasDOM && _require.has(bootstrapModuleId)) { - bootstrap = _require.default(bootstrapModuleId).default; - context = document; - } + return index; +} - bootstrap({ context: context, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); - } - }); -}); -enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberViews, _emberApplicationSystemEngineInstance) { - /** - @module ember - @submodule ember-application - */ +function clearItems(item) { + this._platform.clearTimeout(item[2]); +} + +exports['default'] = Backburner; + +Object.defineProperty(exports, '__esModule', { value: true }); +}); +enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) { + /* globals Proxy */ 'use strict'; - var BootOptions = undefined; + var _Container$prototype; + + exports.default = Container; + exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations; + + var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE'); + var FACTORY_FOR = _emberUtils.symbol('FACTORY_FOR'); + exports.FACTORY_FOR = FACTORY_FOR; + var LOOKUP_FACTORY = _emberUtils.symbol('LOOKUP_FACTORY'); + exports.LOOKUP_FACTORY = LOOKUP_FACTORY; /** - The `ApplicationInstance` encapsulates all of the stateful aspects of a - running `Application`. - - At a high-level, we break application boot into two distinct phases: - - * Definition time, where all of the classes, templates, and other - dependencies are loaded (typically in the browser). - * Run time, where we begin executing the application once everything - has loaded. + A container used to instantiate and cache objects. - Definition time can be expensive and only needs to happen once since it is - an idempotent operation. For example, between test runs and FastBoot - requests, the application stays the same. It is only the state that we want - to reset. + Every `Container` must be associated with a `Registry`, which is referenced + to determine the factory and options that should be used to instantiate + objects. - That state is what the `ApplicationInstance` manages: it is responsible for - creating the container that contains all application state, and disposing of - it once the particular test run or FastBoot request has finished. + The public API for `Container` is still in flux and should not be considered + stable. - @public - @class Ember.ApplicationInstance - @extends Ember.EngineInstance - */ + @private + @class Container + */ - var ApplicationInstance = _emberApplicationSystemEngineInstance.default.extend({ + function Container(registry, options) { + this.registry = registry; + this.owner = options && options.owner ? options.owner : null; + this.cache = _emberUtils.dictionary(options && options.cache ? options.cache : null); + this.factoryCache = _emberUtils.dictionary(options && options.factoryCache ? options.factoryCache : null); + this.validationCache = _emberUtils.dictionary(options && options.validationCache ? options.validationCache : null); + this._fakeContainerToInject = buildFakeContainerWithDeprecations(this); + this[CONTAINER_OVERRIDE] = undefined; + this.isDestroyed = false; + } + + Container.prototype = (_Container$prototype = { /** - The `Application` for which this is an instance. - @property {Ember.Application} application - @private - */ - application: null, + @private + @property owner + @type Object + */ + owner: null, /** - The DOM events for which the event dispatcher should listen. - By default, the application's `Ember.EventDispatcher` listens - for a set of standard DOM events, such as `mousedown` and - `keyup`, and delegates them to your application's `Ember.View` - instances. - @private - @property {Object} customEvents - */ - customEvents: null, + @private + @property registry + @type Registry + @since 1.11.0 + */ + registry: null, /** - The root DOM element of the Application as an element or a - [jQuery-compatible selector - string](http://api.jquery.com/category/selectors/). - @private - @property {String|DOMElement} rootElement - */ - rootElement: null, + @private + @property cache + @type InheritingDict + */ + cache: null, - init: function () { - this._super.apply(this, arguments); + /** + @private + @property factoryCache + @type InheritingDict + */ + factoryCache: null, - // Register this instance in the per-instance registry. - // - // Why do we need to register the instance in the first place? - // Because we need a good way for the root route (a.k.a ApplicationRoute) - // to notify us when it has created the root-most view. That view is then - // appended to the rootElement, in the case of apps, to the fixture harness - // in tests, or rendered to a string in the case of FastBoot. - this.register('-application-instance:main', this, { instantiate: false }); + /** + @private + @property validationCache + @type InheritingDict + */ + validationCache: null, + + /** + Given a fullName return a corresponding instance. + The default behaviour is for lookup to return a singleton instance. + The singleton is scoped to the container, allowing multiple containers + to all have their own locally scoped singletons. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter'); + twitter instanceof Twitter; // => true + // by default the container will return singletons + let twitter2 = container.lookup('api:twitter'); + twitter2 instanceof Twitter; // => true + twitter === twitter2; //=> true + ``` + If singletons are not wanted, an optional flag can be provided at lookup. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter', { singleton: false }); + let twitter2 = container.lookup('api:twitter', { singleton: false }); + twitter === twitter2; //=> false + ``` + @private + @method lookup + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + lookup: function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); + return lookup(this, this.registry.normalize(fullName), options); }, /** - Overrides the base `EngineInstance._bootSync` method with concerns relevant - to booting application (instead of engine) instances. - This method should only contain synchronous boot concerns. Asynchronous - boot concerns should eventually be moved to the `boot` method, which - returns a promise. - Until all boot code has been made asynchronous, we need to continue to - expose this method for use *internally* in places where we need to boot an - instance synchronously. - @private - */ - _bootSync: function (options) { - if (this._booted) { - return this; - } + Given a fullName, return the corresponding factory. + @private + @method lookupFactory + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + lookupFactory: function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); - options = new BootOptions(options); + _emberMetal.deprecate('Using "_lookupFactory" is deprecated. Please use container.factoryFor instead.', !true, { id: 'container-lookupFactory', until: '2.13.0', url: 'TODO' }); - this.setupRegistry(options); + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + } - if (options.rootElement) { - this.rootElement = options.rootElement; - } else { - this.rootElement = this.application.rootElement; - } + }, _Container$prototype[LOOKUP_FACTORY] = function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + }, _Container$prototype[FACTORY_FOR] = function (fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (options.location) { - var router = _emberMetal.get(this, 'router'); - _emberMetal.set(router, 'location', options.location); + if (_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + if (true) { + return this.factoryFor(fullName, options); + } else { + /* This throws in case of a poorly designed build */ + throw new Error('If ember-no-double-extend is enabled, ember-factory-for must also be enabled'); } + } + var factory = this[LOOKUP_FACTORY](fullName, options); + if (factory === undefined) { + return; + } + var manager = new DeprecatedFactoryManager(this, factory, fullName); - this.application.runInstanceInitializers(this); + _emberMetal.runInDebug(function () { + manager = wrapManagerInDeprecationProxy(manager); + }); - if (options.isInteractive) { - this.setupEventDispatcher(); + return manager; + }, _Container$prototype.destroy = function () { + eachDestroyable(this, function (item) { + if (item.destroy) { + item.destroy(); } + }); - this._booted = true; - - return this; - }, + this.isDestroyed = true; + }, _Container$prototype.reset = function (fullName) { + if (arguments.length > 0) { + resetMember(this, this.registry.normalize(fullName)); + } else { + resetCache(this); + } + }, _Container$prototype.ownerInjection = function () { + var _ref; - setupRegistry: function (options) { - this.constructor.setupRegistry(this.__registry__, options); - }, + return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; + }, _Container$prototype); - router: _emberMetal.computed(function () { - return this.lookup('router:main'); - }).readOnly(), + /* + * Wrap a factory manager in a proxy which will not permit properties to be + * set on the manager. + */ + function wrapManagerInDeprecationProxy(manager) { + if (_emberUtils.HAS_NATIVE_PROXY) { + var _ret = (function () { + var validator = { + get: function (obj, prop) { + if (prop !== 'class' && prop !== 'create') { + throw new Error('You attempted to access "' + prop + '" on a factory manager created by container#factoryFor. "' + prop + '" is not a member of a factory manager."'); + } - /** - This hook is called by the root-most Route (a.k.a. the ApplicationRoute) - when it has finished creating the root View. By default, we simply take the - view and append it to the `rootElement` specified on the Application. - In cases like FastBoot and testing, we can override this hook and implement - custom behavior, such as serializing to a string and sending over an HTTP - socket rather than appending to DOM. - @param view {Ember.View} the root-most view - @private - */ - didCreateRootView: function (view) { - view.appendTo(this.rootElement); - }, - - /** - Tells the router to start routing. The router will ask the location for the - current URL of the page to determine the initial URL to start routing to. - To start the app at a specific URL, call `handleURL` instead. - @private - */ - startRouting: function () { - var router = _emberMetal.get(this, 'router'); - router.startRouting(); - this._didSetupRouter = true; - }, + return obj[prop]; + }, + set: function (obj, prop, value) { + throw new Error('You attempted to set "' + prop + '" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.'); + } + }; - /** - @private - Sets up the router, initializing the child router and configuring the - location before routing begins. - Because setup should only occur once, multiple calls to `setupRouter` - beyond the first call have no effect. - */ - setupRouter: function () { - if (this._didSetupRouter) { - return; - } - this._didSetupRouter = true; + // Note: + // We have to proxy access to the manager here so that private property + // access doesn't cause the above errors to occur. + var m = manager; + var proxiedManager = { + class: m.class, + create: function (props) { + return m.create(props); + } + }; - var router = _emberMetal.get(this, 'router'); - router.setupRouter(); - }, + return { + v: new Proxy(proxiedManager, validator) + }; + })(); - /** - Directs the router to route to a particular URL. This is useful in tests, - for example, to tell the app to start at a particular URL. - @param url {String} the URL the router should route to - @private - */ - handleURL: function (url) { - var router = _emberMetal.get(this, 'router'); + if (typeof _ret === 'object') return _ret.v; + } - this.setupRouter(); - return router.handleURL(url); - }, + return manager; + } + if (true) { /** - @private - */ - setupEventDispatcher: function () { - var dispatcher = this.lookup('event_dispatcher:main'); - var applicationCustomEvents = _emberMetal.get(this.application, 'customEvents'); - var instanceCustomEvents = _emberMetal.get(this, 'customEvents'); + Given a fullName, return the corresponding factory. The consumer of the factory + is responsible for the destruction of any factory instances, as there is no + way for the container to ensure instances are destroyed when it itself is + destroyed. + @public + @method factoryFor + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + Container.prototype.factoryFor = function _factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var customEvents = _emberUtils.assign({}, applicationCustomEvents, instanceCustomEvents); - dispatcher.setup(customEvents, this.rootElement); + var normalizedName = this.registry.normalize(fullName); + _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(normalizedName)); - return dispatcher; - }, + if (options.source) { + normalizedName = this.registry.expandLocalLookup(fullName, options); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!normalizedName) { + return; + } + } - /** - Returns the current URL of the app instance. This is useful when your - app does not update the browsers URL bar (i.e. it uses the `'none'` - location adapter). - @public - @return {String} the current URL - */ - getURL: function () { - var router = _emberMetal.get(this, 'router'); - return _emberMetal.get(router, 'url'); - }, + var factory = this.registry.resolve(normalizedName); - // `instance.visit(url)` should eventually replace `instance.handleURL()`; - // the test helpers can probably be switched to use this implementation too + if (factory === undefined) { + return; + } - /** - Navigate the instance to a particular URL. This is useful in tests, for - example, or to tell the app to start at a particular URL. This method - returns a promise that resolves with the app instance when the transition - is complete, or rejects if the transion was aborted due to an error. - @public - @param url {String} the destination URL - @return {Promise} - */ - visit: function (url) { - var _this = this; + var manager = new FactoryManager(this, factory, fullName, normalizedName); - this.setupRouter(); + _emberMetal.runInDebug(function () { + manager = wrapManagerInDeprecationProxy(manager); + }); - var bootOptions = this.__container__.lookup('-environment:main'); + return manager; + }; + } - var router = _emberMetal.get(this, 'router'); + function isSingleton(container, fullName) { + return container.registry.getOption(fullName, 'singleton') !== false; + } - var handleTransitionResolve = function () { - if (!bootOptions.options.shouldRender) { - // No rendering is needed, and routing has completed, simply return. - return _this; - } else { - return new _emberRuntime.RSVP.Promise(function (resolve) { - // Resolve once rendering is completed. `router.handleURL` returns the transition (as a thennable) - // which resolves once the transition is completed, but the transition completion only queues up - // a scheduled revalidation (into the `render` queue) in the Renderer. - // - // This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed. - _emberMetal.run.schedule('afterRender', null, resolve, _this); - }); - } - }; + function shouldInstantiate(container, fullName) { + return container.registry.getOption(fullName, 'instantiate') !== false; + } - var handleTransitionReject = function (error) { - if (error.error) { - throw error.error; - } else if (error.name === 'TransitionAborted' && router.router.activeTransition) { - return router.router.activeTransition.then(handleTransitionResolve, handleTransitionReject); - } else if (error.name === 'TransitionAborted') { - throw new Error(error.message); - } else { - throw error; - } - }; + function lookup(container, fullName) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - var location = _emberMetal.get(router, 'location'); + if (options.source) { + fullName = container.registry.expandLocalLookup(fullName, options); - // Keeps the location adapter's internal URL in-sync - location.setURL(url); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!fullName) { + return; + } + } - // getURL returns the set url with the rootURL stripped off - return router.handleURL(location.getURL()).then(handleTransitionResolve, handleTransitionReject); + if (container.cache[fullName] !== undefined && options.singleton !== false) { + return container.cache[fullName]; } - }); - ApplicationInstance.reopenClass({ - /** - @private - @method setupRegistry - @param {Registry} registry - @param {BootOptions} options - */ - setupRegistry: function (registry) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + if (true) { + return instantiateFactory(container, fullName, options); + } else { + var factory = deprecatedFactoryFor(container, fullName); + var value = instantiate(factory, {}, container, fullName); - if (!options.toEnvironment) { - options = new BootOptions(options); + if (value === undefined) { + return; } - registry.register('-environment:main', options.toEnvironment(), { instantiate: false }); - registry.register('service:-document', options.document, { instantiate: false }); + if (isSingleton(container, fullName) && options.singleton !== false) { + container.cache[fullName] = value; + } - this._super(registry, options); + return value; } - }); + } - /** - A list of boot-time configuration options for customizing the behavior of - an `Ember.ApplicationInstance`. - - This is an interface class that exists purely to document the available - options; you do not need to construct it manually. Simply pass a regular - JavaScript object containing the desired options into methods that require - one of these options object: - - ```javascript - MyApp.visit("/", { location: "none", rootElement: "#container" }); - ``` - - Not all combinations of the supported options are valid. See the documentation - on `Ember.Application#visit` for the supported configurations. - - Internal, experimental or otherwise unstable flags are marked as private. - - @class BootOptions - @namespace Ember.ApplicationInstance - @public - */ - BootOptions = function BootOptions() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + function isSingletonClass(container, fullName, _ref2) { + var instantiate = _ref2.instantiate; + var singleton = _ref2.singleton; - /** - Provide a specific instance of jQuery. This is useful in conjunction with - the `document` option, as it allows you to use a copy of `jQuery` that is - appropriately bound to the foreign `document` (e.g. a jsdom). - This is highly experimental and support very incomplete at the moment. - @property jQuery - @type Object - @default auto-detected - @private - */ - this.jQuery = _emberViews.jQuery; // This default is overridable below + return singleton !== false && isSingleton(container, fullName) && !instantiate && !shouldInstantiate(container, fullName); + } - /** - Interactive mode: whether we need to set up event delegation and invoke - lifecycle callbacks on Components. - @property isInteractive - @type boolean - @default auto-detected - @private - */ - this.isInteractive = _emberEnvironment.environment.hasDOM; // This default is overridable below + function isSingletonInstance(container, fullName, _ref3) { + var instantiate = _ref3.instantiate; + var singleton = _ref3.singleton; - /** - Run in a full browser environment. - When this flag is set to `false`, it will disable most browser-specific - and interactive features. Specifically: - * It does not use `jQuery` to append the root view; the `rootElement` - (either specified as a subsequent option or on the application itself) - must already be an `Element` in the given `document` (as opposed to a - string selector). - * It does not set up an `EventDispatcher`. - * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). - * It sets the `location` option to `"none"`. (If you would like to use - the location adapter specified in the app's router instead, you can also - specify `{ location: null }` to specifically opt-out.) - @property isBrowser - @type boolean - @default auto-detected - @public - */ - if (options.isBrowser !== undefined) { - this.isBrowser = !!options.isBrowser; - } else { - this.isBrowser = _emberEnvironment.environment.hasDOM; - } + return singleton !== false && isSingleton(container, fullName) && instantiate !== false && shouldInstantiate(container, fullName); + } - if (!this.isBrowser) { - this.jQuery = null; - this.isInteractive = false; - this.location = 'none'; - } + function isFactoryClass(container, fullname, _ref4) { + var instantiate = _ref4.instantiate; + var singleton = _ref4.singleton; - /** - Disable rendering completely. - When this flag is set to `true`, it will disable the entire rendering - pipeline. Essentially, this puts the app into "routing-only" mode. No - templates will be rendered, and no Components will be created. - @property shouldRender - @type boolean - @default true - @public - */ - if (options.shouldRender !== undefined) { - this.shouldRender = !!options.shouldRender; - } else { - this.shouldRender = true; + return (singleton === false || !isSingleton(container, fullname)) && instantiate === false && !shouldInstantiate(container, fullname); + } + + function isFactoryInstance(container, fullName, _ref5) { + var instantiate = _ref5.instantiate; + var singleton = _ref5.singleton; + + return (singleton !== false || isSingleton(container, fullName)) && instantiate !== false && shouldInstantiate(container, fullName); + } + + function instantiateFactory(container, fullName, options) { + var factoryManager = container[FACTORY_FOR](fullName); + + if (factoryManager === undefined) { + return; } - if (!this.shouldRender) { - this.jQuery = null; - this.isInteractive = false; + // SomeClass { singleton: true, instantiate: true } | { singleton: true } | { instantiate: true } | {} + // By default majority of objects fall into this case + if (isSingletonInstance(container, fullName, options)) { + return container.cache[fullName] = factoryManager.create(); } - /** - If present, render into the given `Document` object instead of the - global `window.document` object. - In practice, this is only useful in non-browser environment or in - non-interactive mode, because Ember's `jQuery` dependency is - implicitly bound to the current document, causing event delegation - to not work properly when the app is rendered into a foreign - document object (such as an iframe's `contentDocument`). - In non-browser mode, this could be a "`Document`-like" object as - Ember only interact with a small subset of the DOM API in non- - interactive mode. While the exact requirements have not yet been - formalized, the `SimpleDOM` library's implementation is known to - work. - @property document - @type Document - @default the global `document` object - @public - */ - if (options.document) { - this.document = options.document; - } else { - this.document = typeof document !== 'undefined' ? document : null; + // SomeClass { singleton: false, instantiate: true } + if (isFactoryInstance(container, fullName, options)) { + return factoryManager.create(); } - /** - If present, overrides the application's `rootElement` property on - the instance. This is useful for testing environment, where you - might want to append the root view to a fixture area. - In non-browser mode, because Ember does not have access to jQuery, - this options must be specified as a DOM `Element` object instead of - a selector string. - See the documentation on `Ember.Applications`'s `rootElement` for - details. - @property rootElement - @type String|Element - @default null - @public - */ - if (options.rootElement) { - this.rootElement = options.rootElement; + // SomeClass { singleton: true, instantiate: false } | { instantiate: false } | { singleton: false, instantiation: false } + if (isSingletonClass(container, fullName, options) || isFactoryClass(container, fullName, options)) { + return factoryManager.class; } - // Set these options last to give the user a chance to override the - // defaults from the "combo" options like `isBrowser` (although in - // practice, the resulting combination is probably invalid) + throw new Error('Could not create factory'); + } - /** - If present, overrides the router's `location` property with this - value. This is useful for environments where trying to modify the - URL would be inappropriate. - @property location - @type string - @default null - @public - */ - if (options.location !== undefined) { - this.location = options.location; + function markInjectionsAsDynamic(injections) { + injections._dynamic = true; + } + + function areInjectionsDynamic(injections) { + return !!injections._dynamic; + } + + function buildInjections() /* container, ...injections */{ + var _arguments = arguments; + + var hash = {}; + + if (arguments.length > 1) { + (function () { + var container = _arguments[0]; + var injections = []; + var injection = undefined; + + for (var i = 1; i < _arguments.length; i++) { + if (_arguments[i]) { + injections = injections.concat(_arguments[i]); + } + } + + _emberMetal.runInDebug(function () { + container.registry.validateInjections(injections); + }); + + for (var i = 0; i < injections.length; i++) { + injection = injections[i]; + hash[injection.property] = lookup(container, injection.fullName); + if (!isSingleton(container, injection.fullName)) { + markInjectionsAsDynamic(hash); + } + } + })(); } - if (options.jQuery !== undefined) { - this.jQuery = options.jQuery; + return hash; + } + + function deprecatedFactoryFor(container, fullName) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + + var registry = container.registry; + + if (options.source) { + fullName = registry.expandLocalLookup(fullName, options); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!fullName) { + return; + } } - if (options.isInteractive !== undefined) { - this.isInteractive = !!options.isInteractive; + var cache = container.factoryCache; + if (cache[fullName]) { + return cache[fullName]; + } + var factory = registry.resolve(fullName); + if (factory === undefined) { + return; } - }; - BootOptions.prototype.toEnvironment = function () { - var env = _emberUtils.assign({}, _emberEnvironment.environment); - // For compatibility with existing code - env.hasDOM = this.isBrowser; - env.isInteractive = this.isInteractive; - env.options = this; - return env; - }; + var type = fullName.split(':')[0]; + if (!factory || typeof factory.extend !== 'function' || !_emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS && type === 'model') { + if (factory && typeof factory._onLookup === 'function') { + factory._onLookup(fullName); + } - Object.defineProperty(ApplicationInstance.prototype, 'container', { - configurable: true, - enumerable: false, - get: function () { - var instance = this; - return { - lookup: function () { - _emberMetal.deprecate('Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead.', false, { - id: 'ember-application.app-instance-container', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container' - }); - return instance.lookup.apply(instance, arguments); - } - }; + // TODO: think about a 'safe' merge style extension + // for now just fallback to create time injection + cache[fullName] = factory; + return factory; + } else { + var injections = injectionsFor(container, fullName); + var factoryInjections = factoryInjectionsFor(container, fullName); + var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); + + factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); + + var injectedFactory = factory.extend(injections); + + // TODO - remove all `container` injections when Ember reaches v3.0.0 + injectDeprecatedContainer(injectedFactory.prototype, container); + injectedFactory.reopenClass(factoryInjections); + + if (factory && typeof factory._onLookup === 'function') { + factory._onLookup(fullName); + } + + if (cacheable) { + cache[fullName] = injectedFactory; + } + + return injectedFactory; } - }); + } - Object.defineProperty(ApplicationInstance.prototype, 'registry', { - configurable: true, - enumerable: false, - get: function () { - return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'ApplicationInstance'); + function injectionsFor(container, fullName) { + var registry = container.registry; + var splitName = fullName.split(':'); + var type = splitName[0]; + + var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); + injections._debugContainerKey = fullName; + + _emberUtils.setOwner(injections, container.owner); + + return injections; + } + + function instantiate(factory, props, container, fullName) { + var lazyInjections = undefined, + validationCache = undefined; + + props = props || {}; + + if (container.registry.getOption(fullName, 'instantiate') === false) { + return factory; } - }); - exports.default = ApplicationInstance; -}); -enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application/system/application-instance', 'container', 'ember-application/system/engine', 'ember-glimmer'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRuntime, _emberViews, _emberRouting, _emberApplicationSystemApplicationInstance, _container, _emberApplicationSystemEngine, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + if (factory) { + if (typeof factory.create !== 'function') { + throw new Error('Failed to create an instance of \'' + fullName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); + } - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + validationCache = container.validationCache; - var librariesRegistered = false; + _emberMetal.runInDebug(function () { + // Ensure that all lazy injections are valid at instantiation time + if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') { + lazyInjections = factory._lazyInjections(); + lazyInjections = container.registry.normalizeInjectionsHash(lazyInjections); - /** - An instance of `Ember.Application` is the starting point for every Ember - application. It helps to instantiate, initialize and coordinate the many - objects that make up your app. - - Each Ember app has one and only one `Ember.Application` object. In fact, the - very first thing you should do in your application is create the instance: - - ```javascript - window.App = Ember.Application.create(); - ``` - - Typically, the application object is the only global variable. All other - classes in your app should be properties on the `Ember.Application` instance, - which highlights its first role: a global namespace. - - For example, if you define a view class, it might look like this: - - ```javascript - App.MyView = Ember.View.extend(); - ``` - - By default, calling `Ember.Application.create()` will automatically initialize - your application by calling the `Ember.Application.initialize()` method. If - you need to delay initialization, you can call your app's `deferReadiness()` - method. When you are ready for your app to be initialized, call its - `advanceReadiness()` method. - - You can define a `ready` method on the `Ember.Application` instance, which - will be run by Ember when the application is initialized. - - Because `Ember.Application` inherits from `Ember.Namespace`, any classes - you create will have useful string representations when calling `toString()`. - See the `Ember.Namespace` documentation for more information. - - While you can think of your `Ember.Application` as a container that holds the - other classes in your application, there are several other responsibilities - going on under-the-hood that you may want to understand. - - ### Event Delegation - - Ember uses a technique called _event delegation_. This allows the framework - to set up a global, shared event listener instead of requiring each view to - do it manually. For example, instead of each view registering its own - `mousedown` listener on its associated element, Ember sets up a `mousedown` - listener on the `body`. - - If a `mousedown` event occurs, Ember will look at the target of the event and - start walking up the DOM node tree, finding corresponding views and invoking - their `mouseDown` method as it goes. - - `Ember.Application` has a number of default events that it listens for, as - well as a mapping from lowercase events to camel-cased view method names. For - example, the `keypress` event causes the `keyPress` method on the view to be - called, the `dblclick` event causes `doubleClick` to be called, and so on. - - If there is a bubbling browser event that Ember does not listen for by - default, you can specify custom events and their corresponding view method - names by setting the application's `customEvents` property: - - ```javascript - let App = Ember.Application.create({ - customEvents: { - // add support for the paste event - paste: 'paste' + container.registry.validateInjections(lazyInjections); + } + }); + + validationCache[fullName] = true; + + var obj = undefined; + + if (typeof factory.extend === 'function') { + // assume the factory was extendable and is already injected + obj = factory.create(props); + } else { + // assume the factory was extendable + // to create time injections + // TODO: support new'ing for instantiation and merge injections for pure JS Functions + var injections = injectionsFor(container, fullName); + + // Ensure that a container is available to an object during instantiation. + // TODO - remove when Ember reaches v3.0.0 + // This "fake" container will be replaced after instantiation with a + // property that raises deprecations every time it is accessed. + injections.container = container._fakeContainerToInject; + obj = factory.create(_emberUtils.assign({}, injections, props)); + + // TODO - remove when Ember reaches v3.0.0 + if (!Object.isFrozen(obj) && 'container' in obj) { + injectDeprecatedContainer(obj, container); + } } - }); - ``` - - To prevent Ember from setting up a listener for a default event, - specify the event name with a `null` value in the `customEvents` - property: - - ```javascript - let App = Ember.Application.create({ - customEvents: { - // prevent listeners for mouseenter/mouseleave events - mouseenter: null, - mouseleave: null + + return obj; + } + } + + function factoryInjectionsFor(container, fullName) { + var registry = container.registry; + var splitName = fullName.split(':'); + var type = splitName[0]; + + var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); + factoryInjections._debugContainerKey = fullName; + + return factoryInjections; + } + + // TODO - remove when Ember reaches v3.0.0 + function injectDeprecatedContainer(object, container) { + Object.defineProperty(object, 'container', { + configurable: true, + enumerable: false, + get: function () { + _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + return this[CONTAINER_OVERRIDE] || container; + }, + + set: function (value) { + _emberMetal.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + + this[CONTAINER_OVERRIDE] = value; + + return value; } }); - ``` - - By default, the application sets up these event listeners on the document - body. However, in cases where you are embedding an Ember application inside - an existing page, you may want it to set up the listeners on an element - inside the body. - - For example, if only events inside a DOM element with the ID of `ember-app` - should be delegated, set your application's `rootElement` property: - - ```javascript - let App = Ember.Application.create({ - rootElement: '#ember-app' - }); - ``` - - The `rootElement` can be either a DOM element or a jQuery-compatible selector - string. Note that *views appended to the DOM outside the root element will - not receive events.* If you specify a custom root element, make sure you only - append views inside it! - - To learn more about the events Ember components use, see - [components/handling-events](https://guides.emberjs.com/v2.6.0/components/handling-events/#toc_event-names). - - ### Initializers - - Libraries on top of Ember can add initializers, like so: - - ```javascript - Ember.Application.initializer({ - name: 'api-adapter', - - initialize: function(application) { - application.register('api-adapter:main', ApiAdapter); + } + + function eachDestroyable(container, callback) { + var cache = container.cache; + var keys = Object.keys(cache); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = cache[key]; + + if (container.registry.getOption(key, 'instantiate') !== false) { + callback(value); + } + } + } + + function resetCache(container) { + eachDestroyable(container, function (value) { + if (value.destroy) { + value.destroy(); } }); - ``` - - Initializers provide an opportunity to access the internal registry, which - organizes the different components of an Ember application. Additionally - they provide a chance to access the instantiated application. Beyond - being used for libraries, initializers are also a great way to organize - dependency injection or setup in your own application. - - ### Routing - - In addition to creating your application's router, `Ember.Application` is - also responsible for telling the router when to start routing. Transitions - between routes can be logged with the `LOG_TRANSITIONS` flag, and more - detailed intra-transition logging can be logged with - the `LOG_TRANSITIONS_INTERNAL` flag: - - ```javascript - let App = Ember.Application.create({ - LOG_TRANSITIONS: true, // basic logging of successful transitions - LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps - }); - ``` - - By default, the router will begin trying to translate the current URL into - application state once the browser emits the `DOMContentReady` event. If you - need to defer routing, you can call the application's `deferReadiness()` - method. Once routing can begin, call the `advanceReadiness()` method. - - If there is any setup required before routing begins, you can implement a - `ready()` method on your app that will be invoked immediately before routing - begins. - - @class Application - @namespace Ember - @extends Ember.Engine - @uses RegistryProxyMixin - @public - */ - var Application = _emberApplicationSystemEngine.default.extend({ - _suppressDeferredDeprecation: true, + container.cache.dict = _emberUtils.dictionary(null); + } - /** - The root DOM element of the Application. This can be specified as an - element or a - [jQuery-compatible selector string](http://api.jquery.com/category/selectors/). - This is the element that will be passed to the Application's, - `eventDispatcher`, which sets up the listeners for event delegation. Every - view in your application should be a child of the element you specify here. - @property rootElement - @type DOMElement - @default 'body' - @public - */ - rootElement: 'body', + function resetMember(container, fullName) { + var member = container.cache[fullName]; - /** - The `Ember.EventDispatcher` responsible for delegating events to this - application's views. - The event dispatcher is created by the application at initialization time - and sets up event listeners on the DOM element described by the - application's `rootElement` property. - See the documentation for `Ember.EventDispatcher` for more information. - @property eventDispatcher - @type Ember.EventDispatcher - @default null - @public - */ - eventDispatcher: null, + delete container.factoryCache[fullName]; - /** - The DOM events for which the event dispatcher should listen. - By default, the application's `Ember.EventDispatcher` listens - for a set of standard DOM events, such as `mousedown` and - `keyup`, and delegates them to your application's `Ember.View` - instances. - If you would like additional bubbling events to be delegated to your - views, set your `Ember.Application`'s `customEvents` property - to a hash containing the DOM event name as the key and the - corresponding view method name as the value. Setting an event to - a value of `null` will prevent a default event listener from being - added for that event. - To add new events to be listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - // add support for the paste event - paste: 'paste' - } - }); - ``` - To prevent default events from being listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - // remove support for mouseenter / mouseleave events - mouseenter: null, - mouseleave: null - } - }); - ``` - @property customEvents - @type Object - @default null - @public - */ - customEvents: null, + if (member) { + delete container.cache[fullName]; - /** - Whether the application should automatically start routing and render - templates to the `rootElement` on DOM ready. While default by true, - other environments such as FastBoot or a testing harness can set this - property to `false` and control the precise timing and behavior of the boot - process. - @property autoboot - @type Boolean - @default true - @private - */ - autoboot: true, + if (member.destroy) { + member.destroy(); + } + } + } - /** - Whether the application should be configured for the legacy "globals mode". - Under this mode, the Application object serves as a global namespace for all - classes. - ```javascript - let App = Ember.Application.create({ - ... - }); - App.Router.reopen({ - location: 'none' - }); - App.Router.map({ - ... - }); - App.MyComponent = Ember.Component.extend({ - ... + function buildFakeContainerWithDeprecations(container) { + var fakeContainer = {}; + var propertyMappings = { + lookup: 'lookup', + lookupFactory: '_lookupFactory' + }; + + for (var containerProperty in propertyMappings) { + fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]); + } + + return fakeContainer; + } + + function buildFakeContainerFunction(container, containerProperty, ownerProperty) { + return function () { + _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `' + ownerProperty + '` instead.', false, { + id: 'ember-application.injected-container', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); - ``` - This flag also exposes other internal APIs that assumes the existence of - a special "default instance", like `App.__container__.lookup(...)`. - This option is currently not configurable, its value is derived from - the `autoboot` flag – disabling `autoboot` also implies opting-out of - globals mode support, although they are ultimately orthogonal concerns. - Some of the global modes features are already deprecated in 1.x. The - existence of this flag is to untangle the globals mode code paths from - the autoboot code paths, so that these legacy features can be reviewed - for deprecation/removal separately. - Forcing the (autoboot=true, _globalsMode=false) here and running the tests - would reveal all the places where we are still relying on these legacy - behavior internally (mostly just tests). - @property _globalsMode - @type Boolean - @default true - @private - */ - _globalsMode: true, + return container[containerProperty].apply(container, arguments); + }; + } - init: function (options) { - this._super.apply(this, arguments); + var DeprecatedFactoryManager = (function () { + function DeprecatedFactoryManager(container, factory, fullName) { + babelHelpers.classCallCheck(this, DeprecatedFactoryManager); - if (!this.$) { - this.$ = _emberViews.jQuery; - } + this.container = container; + this.class = factory; + this.fullName = fullName; + } - registerLibraries(); - logLibraryVersions(); + DeprecatedFactoryManager.prototype.create = function create() { + var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - // Start off the number of deferrals at 1. This will be decremented by - // the Application's own `boot` method. - this._readinessDeferrals = 1; - this._booted = false; + return instantiate(this.class, props, this.container, this.fullName); + }; - this.autoboot = this._globalsMode = !!this.autoboot; + return DeprecatedFactoryManager; + })(); - if (this._globalsMode) { - this._prepareForGlobalsMode(); - } + var FactoryManager = (function () { + function FactoryManager(container, factory, fullName, normalizedName) { + babelHelpers.classCallCheck(this, FactoryManager); - if (this.autoboot) { - this.waitForDOMReady(); - } - }, + this.container = container; + this.class = factory; + this.fullName = fullName; + this.normalizedName = normalizedName; + } + + FactoryManager.prototype.create = function create() { + var _this = this; - /** - Create an ApplicationInstance for this application. - @private - @method buildInstance - @return {Ember.ApplicationInstance} the application instance - */ - buildInstance: function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - options.base = this; - options.application = this; - return _emberApplicationSystemApplicationInstance.default.create(options); - }, + var injections = injectionsFor(this.container, this.normalizedName); + var props = _emberUtils.assign({}, injections, options); - /** - Enable the legacy globals mode by allowing this application to act - as a global namespace. See the docs on the `_globalsMode` property - for details. - Most of these features are already deprecated in 1.x, so we can - stop using them internally and try to remove them. - @private - @method _prepareForGlobalsMode - */ - _prepareForGlobalsMode: function () { - // Create subclass of Ember.Router for this Application instance. - // This is to ensure that someone reopening `App.Router` does not - // tamper with the default `Ember.Router`. - this.Router = (this.Router || _emberRouting.Router).extend(); + props[_emberUtils.NAME_KEY] = this.container.registry.makeToString(this.class, this.fullName); - this._buildDeprecatedInstance(); - }, + _emberMetal.runInDebug(function () { + var lazyInjections = undefined; + var validationCache = _this.container.validationCache; + // Ensure that all lazy injections are valid at instantiation time + if (!validationCache[_this.fullName] && _this.class && typeof _this.class._lazyInjections === 'function') { + lazyInjections = _this.class._lazyInjections(); + lazyInjections = _this.container.registry.normalizeInjectionsHash(lazyInjections); - /* - Build the deprecated instance for legacy globals mode support. - Called when creating and resetting the application. - This is orthogonal to autoboot: the deprecated instance needs to - be created at Application construction (not boot) time to expose - App.__container__. If autoboot sees that this instance exists, - it will continue booting it to avoid doing unncessary work (as - opposed to building a new instance at boot time), but they are - otherwise unrelated. - @private - @method _buildDeprecatedInstance - */ - _buildDeprecatedInstance: function () { - // Build a default instance - var instance = this.buildInstance(); + _this.container.registry.validateInjections(lazyInjections); + } - // Legacy support for App.__container__ and other global methods - // on App that rely on a single, default instance. - this.__deprecatedInstance__ = instance; - this.__container__ = instance.__container__; - }, + validationCache[_this.fullName] = true; + }); - /** - Automatically kick-off the boot process for the application once the - DOM has become ready. - The initialization itself is scheduled on the actions queue which - ensures that code-loading finishes before booting. - If you are asynchronously loading code, you should call `deferReadiness()` - to defer booting, and then call `advanceReadiness()` once all of your code - has finished loading. - @private - @method waitForDOMReady - */ - waitForDOMReady: function () { - if (!this.$ || this.$.isReady) { - _emberMetal.run.schedule('actions', this, 'domReady'); - } else { - this.$().ready(_emberMetal.run.bind(this, 'domReady')); + if (!this.class.create) { + throw new Error('Failed to create an instance of \'' + this.normalizedName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); } - }, - /** - This is the autoboot flow: - 1. Boot the app by calling `this.boot()` - 2. Create an instance (or use the `__deprecatedInstance__` in globals mode) - 3. Boot the instance by calling `instance.boot()` - 4. Invoke the `App.ready()` callback - 5. Kick-off routing on the instance - Ideally, this is all we would need to do: - ```javascript - _autoBoot() { - this.boot().then(() => { - let instance = (this._globalsMode) ? this.__deprecatedInstance__ : this.buildInstance(); - return instance.boot(); - }).then((instance) => { - App.ready(); - instance.startRouting(); - }); - } - ``` - Unfortunately, we cannot actually write this because we need to participate - in the "synchronous" boot process. While the code above would work fine on - the initial boot (i.e. DOM ready), when `App.reset()` is called, we need to - boot a new instance synchronously (see the documentation on `_bootSync()` - for details). - Because of this restriction, the actual logic of this method is located - inside `didBecomeReady()`. - @private - @method domReady - */ - domReady: function () { - if (this.isDestroyed) { - return; + if (this.class.prototype) { + injectDeprecatedContainer(this.class.prototype, this.container); } - this._bootSync(); + return this.class.create(props); + }; - // Continues to `didBecomeReady` - }, + return FactoryManager; + })(); +}); - /** - Use this to defer readiness until some condition is true. - Example: - ```javascript - let App = Ember.Application.create(); - App.deferReadiness(); - // Ember.$ is a reference to the jQuery object/function - Ember.$.getJSON('/auth-token', function(token) { - App.token = token; - App.advanceReadiness(); - }); - ``` - This allows you to perform asynchronous setup logic and defer - booting your application until the setup has finished. - However, if the setup requires a loading UI, it might be better - to use the router for this purpose. - @method deferReadiness - @public - */ - deferReadiness: function () { - _emberMetal.assert('You must call deferReadiness on an instance of Ember.Application', this instanceof Application); - _emberMetal.assert('You cannot defer readiness since the `ready()` hook has already been called.', this._readinessDeferrals > 0); - this._readinessDeferrals++; - }, +/* + * This internal version of factoryFor swaps between the public API for + * factoryFor (class is the registered class) and a transition implementation + * (class is the double-extended class). It is *not* the public API version + * of factoryFor, which always returns the registered class. + */ - /** - Call `advanceReadiness` after any asynchronous setup logic has completed. - Each call to `deferReadiness` must be matched by a call to `advanceReadiness` - or the application will never become ready and routing will not begin. - @method advanceReadiness - @see {Ember.Application#deferReadiness} - @public - */ - advanceReadiness: function () { - _emberMetal.assert('You must call advanceReadiness on an instance of Ember.Application', this instanceof Application); - this._readinessDeferrals--; +/** + A depth first traversal, destroying the container, its descendant containers and all + their managed objects. + @private + @method destroy + */ - if (this._readinessDeferrals === 0) { - _emberMetal.run.once(this, this.didBecomeReady); +/** + Clear either the entire cache or just the cache for a particular key. + @private + @method reset + @param {String} fullName optional key to reset; if missing, resets everything + */ + +/** + Returns an object that can be used to provide an owner to a + manually created instance. + @private + @method ownerInjection + @returns { Object } +*/ +enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) { + /* + Public API for the container is still in flux. + The public API, specified on the application namespace should be considered the stable API. + // @module container + @private + */ + + 'use strict'; + + exports.Registry = _containerRegistry.default; + exports.privatize = _containerRegistry.privatize; + exports.Container = _containerContainer.default; + exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations; + exports.FACTORY_FOR = _containerContainer.FACTORY_FOR; + exports.LOOKUP_FACTORY = _containerContainer.LOOKUP_FACTORY; +}); +enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) { + 'use strict'; + + exports.default = Registry; + exports.privatize = privatize; + + var VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/; + + /** + A registry used to store factory and option information keyed + by type. + + A `Registry` stores the factory and option information needed by a + `Container` to instantiate and cache objects. + + The API for `Registry` is still in flux and should not be considered stable. + + @private + @class Registry + @since 1.11.0 + */ + + function Registry(options) { + this.fallback = options && options.fallback ? options.fallback : null; + + if (options && options.resolver) { + this.resolver = options.resolver; + + if (typeof this.resolver === 'function') { + deprecateResolverFunction(this); } - }, + } + + this.registrations = _emberUtils.dictionary(options && options.registrations ? options.registrations : null); + + this._typeInjections = _emberUtils.dictionary(null); + this._injections = _emberUtils.dictionary(null); + this._factoryTypeInjections = _emberUtils.dictionary(null); + this._factoryInjections = _emberUtils.dictionary(null); + + this._localLookupCache = new _emberUtils.EmptyObject(); + this._normalizeCache = _emberUtils.dictionary(null); + this._resolveCache = _emberUtils.dictionary(null); + this._failCache = _emberUtils.dictionary(null); + + this._options = _emberUtils.dictionary(null); + this._typeOptions = _emberUtils.dictionary(null); + } + Registry.prototype = { /** - Initialize the application and return a promise that resolves with the `Ember.Application` - object when the boot process is complete. - Run any application initializers and run the application load hook. These hooks may - choose to defer readiness. For example, an authentication hook might want to defer - readiness until the auth token has been retrieved. - By default, this method is called automatically on "DOM ready"; however, if autoboot - is disabled, this is automatically called when the first application instance is - created via `visit`. - @private - @method boot - @return {Promise} - */ - boot: function () { - if (this._bootPromise) { - return this._bootPromise; - } + A backup registry for resolving registrations when no matches can be found. + @private + @property fallback + @type Registry + */ + fallback: null, - try { - this._bootSync(); - } catch (_) { - // Ignore th error: in the asynchronous boot path, the error is already reflected - // in the promise rejection - } + /** + An object that has a `resolve` method that resolves a name. + @private + @property resolver + @type Resolver + */ + resolver: null, - return this._bootPromise; - }, + /** + @private + @property registrations + @type InheritingDict + */ + registrations: null, /** - Unfortunately, a lot of existing code assumes the booting process is - "synchronous". Specifically, a lot of tests assumes the last call to - `app.advanceReadiness()` or `app.reset()` will result in the app being - fully-booted when the current runloop completes. - We would like new code (like the `visit` API) to stop making this assumption, - so we created the asynchronous version above that returns a promise. But until - we have migrated all the code, we would have to expose this method for use - *internally* in places where we need to boot an app "synchronously". - @private - */ - _bootSync: function () { - if (this._booted) { - return; - } + @private + @property _typeInjections + @type InheritingDict + */ + _typeInjections: null, - // Even though this returns synchronously, we still need to make sure the - // boot promise exists for book-keeping purposes: if anything went wrong in - // the boot process, we need to store the error as a rejection on the boot - // promise so that a future caller of `boot()` can tell what failed. - var defer = this._bootResolver = new _emberRuntime.RSVP.defer(); - this._bootPromise = defer.promise; + /** + @private + @property _injections + @type InheritingDict + */ + _injections: null, - try { - this.runInitializers(); - _emberRuntime.runLoadHooks('application', this); - this.advanceReadiness(); - // Continues to `didBecomeReady` - } catch (error) { - // For the asynchronous boot path - defer.reject(error); + /** + @private + @property _factoryTypeInjections + @type InheritingDict + */ + _factoryTypeInjections: null, - // For the synchronous boot path - throw error; - } - }, + /** + @private + @property _factoryInjections + @type InheritingDict + */ + _factoryInjections: null, /** - Reset the application. This is typically used only in tests. It cleans up - the application in the following order: - 1. Deactivate existing routes - 2. Destroy all objects in the container - 3. Create a new application container - 4. Re-route to the existing url - Typical Example: - ```javascript - let App; - run(function() { - App = Ember.Application.create(); - }); - module('acceptance test', { - setup: function() { - App.reset(); - } - }); - test('first test', function() { - // App is freshly reset - }); - test('second test', function() { - // App is again freshly reset - }); - ``` - Advanced Example: - Occasionally you may want to prevent the app from initializing during - setup. This could enable extra configuration, or enable asserting prior - to the app becoming ready. - ```javascript - let App; - run(function() { - App = Ember.Application.create(); - }); - module('acceptance test', { - setup: function() { - run(function() { - App.reset(); - App.deferReadiness(); - }); - } - }); - test('first test', function() { - ok(true, 'something before app is initialized'); - run(function() { - App.advanceReadiness(); - }); - ok(true, 'something after app is initialized'); - }); - ``` - @method reset - @public - */ - reset: function () { - _emberMetal.assert('Calling reset() on instances of `Ember.Application` is not\n supported when globals mode is disabled; call `visit()` to\n create new `Ember.ApplicationInstance`s and dispose them\n via their `destroy()` method instead.', this._globalsMode && this.autoboot); + @private + @property _normalizeCache + @type InheritingDict + */ + _normalizeCache: null, - var instance = this.__deprecatedInstance__; + /** + @private + @property _resolveCache + @type InheritingDict + */ + _resolveCache: null, - this._readinessDeferrals = 1; - this._bootPromise = null; - this._bootResolver = null; - this._booted = false; + /** + @private + @property _options + @type InheritingDict + */ + _options: null, - function handleReset() { - _emberMetal.run(instance, 'destroy'); - this._buildDeprecatedInstance(); - _emberMetal.run.schedule('actions', this, '_bootSync'); - } + /** + @private + @property _typeOptions + @type InheritingDict + */ + _typeOptions: null, - _emberMetal.run.join(this, handleReset); + /** + Creates a container based on this registry. + @private + @method container + @param {Object} options + @return {Container} created container + */ + container: function (options) { + return new _containerContainer.default(this, options); }, /** + Registers a factory for later injection. + Example: + ```javascript + let registry = new Registry(); + registry.register('model:user', Person, {singleton: false }); + registry.register('fruit:favorite', Orange); + registry.register('communication:main', Email, {singleton: false}); + ``` @private - @method didBecomeReady - */ - didBecomeReady: function () { - try { - // TODO: Is this still needed for _globalsMode = false? - if (!_emberMetal.isTesting()) { - // Eagerly name all classes that are already loaded - _emberRuntime.Namespace.processAll(); - _emberRuntime.setNamespaceSearchDisabled(true); - } + @method register + @param {String} fullName + @param {Function} factory + @param {Object} options + */ + register: function (fullName, factory) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - // See documentation on `_autoboot()` for details - if (this.autoboot) { - var instance = undefined; + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - if (this._globalsMode) { - // If we already have the __deprecatedInstance__ lying around, boot it to - // avoid unnecessary work - instance = this.__deprecatedInstance__; - } else { - // Otherwise, build an instance and boot it. This is currently unreachable, - // because we forced _globalsMode to === autoboot; but having this branch - // allows us to locally toggle that flag for weeding out legacy globals mode - // dependencies independently - instance = this.buildInstance(); - } + if (factory === undefined) { + throw new TypeError('Attempting to register an unknown factory: \'' + fullName + '\''); + } - instance._bootSync(); + var normalizedName = this.normalize(fullName); - // TODO: App.ready() is not called when autoboot is disabled, is this correct? - this.ready(); + if (this._resolveCache[normalizedName]) { + throw new Error('Cannot re-register: \'' + fullName + '\', as it has already been resolved.'); + } - instance.startRouting(); - } + delete this._failCache[normalizedName]; + this.registrations[normalizedName] = factory; + this._options[normalizedName] = options; + }, - // For the asynchronous boot path - this._bootResolver.resolve(this); + /** + Unregister a fullName + ```javascript + let registry = new Registry(); + registry.register('model:user', User); + registry.resolve('model:user').create() instanceof User //=> true + registry.unregister('model:user') + registry.resolve('model:user') === undefined //=> true + ``` + @private + @method unregister + @param {String} fullName + */ + unregister: function (fullName) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - // For the synchronous boot path - this._booted = true; - } catch (error) { - // For the asynchronous boot path - this._bootResolver.reject(error); + var normalizedName = this.normalize(fullName); - // For the synchronous boot path - throw error; + this._localLookupCache = new _emberUtils.EmptyObject(); + + delete this.registrations[normalizedName]; + delete this._resolveCache[normalizedName]; + delete this._failCache[normalizedName]; + delete this._options[normalizedName]; + }, + + /** + Given a fullName return the corresponding factory. + By default `resolve` will retrieve the factory from + the registry. + ```javascript + let registry = new Registry(); + registry.register('api:twitter', Twitter); + registry.resolve('api:twitter') // => Twitter + ``` + Optionally the registry can be provided with a custom resolver. + If provided, `resolve` will first provide the custom resolver + the opportunity to resolve the fullName, otherwise it will fallback + to the registry. + ```javascript + let registry = new Registry(); + registry.resolver = function(fullName) { + // lookup via the module system of choice + }; + // the twitter factory is added to the module system + registry.resolve('api:twitter') // => Twitter + ``` + @private + @method resolve + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {Function} fullName's factory + */ + resolve: function (fullName, options) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + var factory = resolve(this, this.normalize(fullName), options); + if (factory === undefined && this.fallback) { + var _fallback; + + factory = (_fallback = this.fallback).resolve.apply(_fallback, arguments); } + return factory; }, /** - Called when the Application has become ready, immediately before routing - begins. The call will be delayed until the DOM has become ready. - @event ready - @public - */ - ready: function () { - return this; + A hook that can be used to describe how the resolver will + attempt to find the factory. + For example, the default Ember `.describe` returns the full + class name (including namespace) where Ember's resolver expects + to find the `fullName`. + @private + @method describe + @param {String} fullName + @return {string} described fullName + */ + describe: function (fullName) { + if (this.resolver && this.resolver.lookupDescription) { + return this.resolver.lookupDescription(fullName); + } else if (this.fallback) { + return this.fallback.describe(fullName); + } else { + return fullName; + } }, - // This method must be moved to the application instance object - willDestroy: function () { - this._super.apply(this, arguments); - _emberRuntime.setNamespaceSearchDisabled(false); - this._booted = false; - this._bootPromise = null; - this._bootResolver = null; + /** + A hook to enable custom fullName normalization behaviour + @private + @method normalizeFullName + @param {String} fullName + @return {string} normalized fullName + */ + normalizeFullName: function (fullName) { + if (this.resolver && this.resolver.normalize) { + return this.resolver.normalize(fullName); + } else if (this.fallback) { + return this.fallback.normalizeFullName(fullName); + } else { + return fullName; + } + }, - if (_emberRuntime._loaded.application === this) { - _emberRuntime._loaded.application = undefined; + /** + Normalize a fullName based on the application's conventions + @private + @method normalize + @param {String} fullName + @return {string} normalized fullName + */ + normalize: function (fullName) { + return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName)); + }, + + /** + @method makeToString + @private + @param {any} factory + @param {string} fullName + @return {function} toString function + */ + makeToString: function (factory, fullName) { + if (this.resolver && this.resolver.makeToString) { + return this.resolver.makeToString(factory, fullName); + } else if (this.fallback) { + return this.fallback.makeToString(factory, fullName); + } else { + return factory.toString(); } + }, - if (this._globalsMode && this.__deprecatedInstance__) { - this.__deprecatedInstance__.destroy(); + /** + Given a fullName check if the container is aware of its factory + or singleton instance. + @private + @method has + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {Boolean} + */ + has: function (fullName, options) { + if (!this.isValidFullName(fullName)) { + return false; } + + var source = options && options.source && this.normalize(options.source); + + return has(this, this.normalize(fullName), source); }, /** - Boot a new instance of `Ember.ApplicationInstance` for the current - application and navigate it to the given `url`. Returns a `Promise` that - resolves with the instance when the initial routing and rendering is - complete, or rejects with any error that occured during the boot process. - When `autoboot` is disabled, calling `visit` would first cause the - application to boot, which runs the application initializers. - This method also takes a hash of boot-time configuration options for - customizing the instance's behavior. See the documentation on - `Ember.ApplicationInstance.BootOptions` for details. - `Ember.ApplicationInstance.BootOptions` is an interface class that exists - purely to document the available options; you do not need to construct it - manually. Simply pass a regular JavaScript object containing of the - desired options: - ```javascript - MyApp.visit("/", { location: "none", rootElement: "#container" }); - ``` - ### Supported Scenarios - While the `BootOptions` class exposes a large number of knobs, not all - combinations of them are valid; certain incompatible combinations might - result in unexpected behavior. - For example, booting the instance in the full browser environment - while specifying a foriegn `document` object (e.g. `{ isBrowser: true, - document: iframe.contentDocument }`) does not work correctly today, - largely due to Ember's jQuery dependency. - Currently, there are three officially supported scenarios/configurations. - Usages outside of these scenarios are not guaranteed to work, but please - feel free to file bug reports documenting your experience and any issues - you encountered to help expand support. - #### Browser Applications (Manual Boot) - The setup is largely similar to how Ember works out-of-the-box. Normally, - Ember will boot a default instance for your Application on "DOM ready". - However, you can customize this behavior by disabling `autoboot`. - For example, this allows you to render a miniture demo of your application - into a specific area on your marketing website: - ```javascript - import MyApp from 'my-app'; - $(function() { - let App = MyApp.create({ autoboot: false }); - let options = { - // Override the router's location adapter to prevent it from updating - // the URL in the address bar - location: 'none', - // Override the default `rootElement` on the app to render into a - // specific `div` on the page - rootElement: '#demo' - }; - // Start the app at the special demo URL - App.visit('/demo', options); - }); - ```` - Or perhaps you might want to boot two instances of your app on the same - page for a split-screen multiplayer experience: - ```javascript - import MyApp from 'my-app'; - $(function() { - let App = MyApp.create({ autoboot: false }); - let sessionId = MyApp.generateSessionID(); - let player1 = App.visit(`/matches/join?name=Player+1&session=${sessionId}`, { rootElement: '#left', location: 'none' }); - let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#right', location: 'none' }); - Promise.all([player1, player2]).then(() => { - // Both apps have completed the initial render - $('#loading').fadeOut(); - }); - }); - ``` - Do note that each app instance maintains their own registry/container, so - they will run in complete isolation by default. - #### Server-Side Rendering (also known as FastBoot) - This setup allows you to run your Ember app in a server environment using - Node.js and render its content into static HTML for SEO purposes. - ```javascript - const HTMLSerializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); - function renderURL(url) { - let dom = new SimpleDOM.Document(); - let rootElement = dom.body; - let options = { isBrowser: false, document: dom, rootElement: rootElement }; - return MyApp.visit(options).then(instance => { - try { - return HTMLSerializer.serialize(rootElement.firstChild); - } finally { - instance.destroy(); - } - }); - } - ``` - In this scenario, because Ember does not have access to a global `document` - object in the Node.js environment, you must provide one explicitly. In practice, - in the non-browser environment, the stand-in `document` object only need to - implement a limited subset of the full DOM API. The `SimpleDOM` library is known - to work. - Since there is no access to jQuery in the non-browser environment, you must also - specify a DOM `Element` object in the same `document` for the `rootElement` option - (as opposed to a selector string like `"body"`). - See the documentation on the `isBrowser`, `document` and `rootElement` properties - on `Ember.ApplicationInstance.BootOptions` for details. - #### Server-Side Resource Discovery - This setup allows you to run the routing layer of your Ember app in a server - environment using Node.js and completely disable rendering. This allows you - to simulate and discover the resources (i.e. AJAX requests) needed to fufill - a given request and eagerly "push" these resources to the client. - ```app/initializers/network-service.js - import BrowserNetworkService from 'app/services/network/browser'; - import NodeNetworkService from 'app/services/network/node'; - // Inject a (hypothetical) service for abstracting all AJAX calls and use - // the appropiate implementaion on the client/server. This also allows the - // server to log all the AJAX calls made during a particular request and use - // that for resource-discovery purpose. - export function initialize(application) { - if (window) { // browser - application.register('service:network', BrowserNetworkService); - } else { // node - application.register('service:network', NodeNetworkService); - } - application.inject('route', 'network', 'service:network'); - }; - export default { - name: 'network-service', - initialize: initialize - }; - ``` - ```app/routes/post.js - import Ember from 'ember'; - // An example of how the (hypothetical) service is used in routes. - export default Ember.Route.extend({ - model(params) { - return this.network.fetch(`/api/posts/${params.post_id}.json`); - }, - afterModel(post) { - if (post.isExternalContent) { - return this.network.fetch(`/api/external/?url=${post.externalURL}`); - } else { - return post; - } - } - }); - ``` - ```javascript - // Finally, put all the pieces together - function discoverResourcesFor(url) { - return MyApp.visit(url, { isBrowser: false, shouldRender: false }).then(instance => { - let networkService = instance.lookup('service:network'); - return networkService.requests; // => { "/api/posts/123.json": "..." } - }); - } - ``` - @public - @method visit - @param url {String} The initial URL to navigate to - @param options {Ember.ApplicationInstance.BootOptions} - @return {Promise} - */ - visit: function (url, options) { - var _this = this; - - return this.boot().then(function () { - var instance = _this.buildInstance(); - - return instance.boot(options).then(function () { - return instance.visit(url); - }).catch(function (error) { - _emberMetal.run(instance, 'destroy'); - throw error; - }); - }); - } - }); + Allow registering options for all factories of a type. + ```javascript + let registry = new Registry(); + let container = registry.container(); + // if all of type `connection` must not be singletons + registry.optionsForType('connection', { singleton: false }); + registry.register('connection:twitter', TwitterConnection); + registry.register('connection:facebook', FacebookConnection); + let twitter = container.lookup('connection:twitter'); + let twitter2 = container.lookup('connection:twitter'); + twitter === twitter2; // => false + let facebook = container.lookup('connection:facebook'); + let facebook2 = container.lookup('connection:facebook'); + facebook === facebook2; // => false + ``` + @private + @method optionsForType + @param {String} type + @param {Object} options + */ + optionsForType: function (type, options) { + this._typeOptions[type] = options; + }, - Object.defineProperty(Application.prototype, 'registry', { - configurable: true, - enumerable: false, - get: function () { - return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'Application'); - } - }); + getOptionsForType: function (type) { + var optionsForType = this._typeOptions[type]; + if (optionsForType === undefined && this.fallback) { + optionsForType = this.fallback.getOptionsForType(type); + } + return optionsForType; + }, - Application.reopenClass({ /** - This creates a registry with the default Ember naming conventions. - It also configures the registry: - * registered views are created every time they are looked up (they are - not singletons) - * registered templates are not factories; the registered value is - returned directly. - * the router receives the application as its `namespace` property - * all controllers receive the router as their `target` and `controllers` - properties - * all controllers receive the application as their `namespace` property - * the application view receives the application controller as its - `controller` property - * the application view receives the application template as its - `defaultTemplate` property - @method buildRegistry - @static - @param {Ember.Application} namespace the application for which to - build the registry - @return {Ember.Registry} the built registry - @private - */ - buildRegistry: function (application) { + @private + @method options + @param {String} fullName + @param {Object} options + */ + options: function (fullName) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var registry = this._super.apply(this, arguments); - - commonSetupRegistry(registry); - - _emberGlimmer.setupApplicationRegistry(registry); + var normalizedName = this.normalize(fullName); + this._options[normalizedName] = options; + }, - return registry; - } - }); + getOptions: function (fullName) { + var normalizedName = this.normalize(fullName); + var options = this._options[normalizedName]; - function commonSetupRegistry(registry) { - registry.register('-view-registry:main', { create: function () { - return _emberUtils.dictionary(null); - } }); + if (options === undefined && this.fallback) { + options = this.fallback.getOptions(fullName); + } + return options; + }, - registry.register('route:basic', _emberRouting.Route); - registry.register('event_dispatcher:main', _emberViews.EventDispatcher); + getOption: function (fullName, optionName) { + var options = this._options[fullName]; - registry.injection('router:main', 'namespace', 'application:main'); + if (options && options[optionName] !== undefined) { + return options[optionName]; + } - registry.register('location:auto', _emberRouting.AutoLocation); - registry.register('location:hash', _emberRouting.HashLocation); - registry.register('location:history', _emberRouting.HistoryLocation); - registry.register('location:none', _emberRouting.NoneLocation); + var type = fullName.split(':')[0]; + options = this._typeOptions[type]; - registry.register(_container.privatize(_templateObject), _emberRouting.BucketCache); - } + if (options && options[optionName] !== undefined) { + return options[optionName]; + } else if (this.fallback) { + return this.fallback.getOption(fullName, optionName); + } + }, - function registerLibraries() { - if (!librariesRegistered) { - librariesRegistered = true; + /** + Used only via `injection`. + Provides a specialized form of injection, specifically enabling + all objects of one type to be injected with a reference to another + object. + For example, provided each object of type `controller` needed a `router`. + one would do the following: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('router:main', Router); + registry.register('controller:user', UserController); + registry.register('controller:post', PostController); + registry.typeInjection('controller', 'router', 'router:main'); + let user = container.lookup('controller:user'); + let post = container.lookup('controller:post'); + user.router instanceof Router; //=> true + post.router instanceof Router; //=> true + // both controllers share the same router + user.router === post.router; //=> true + ``` + @private + @method typeInjection + @param {String} type + @param {String} property + @param {String} fullName + */ + typeInjection: function (type, property, fullName) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); - if (_emberEnvironment.environment.hasDOM && typeof _emberViews.jQuery === 'function') { - _emberMetal.libraries.registerCoreLibrary('jQuery', _emberViews.jQuery().jquery); + var fullNameType = fullName.split(':')[0]; + if (fullNameType === type) { + throw new Error('Cannot inject a \'' + fullName + '\' on other ' + type + '(s).'); } - } - } - function logLibraryVersions() { - if (_emberEnvironment.ENV.LOG_VERSION) { - // we only need to see this once per Application#init - _emberEnvironment.ENV.LOG_VERSION = false; - var libs = _emberMetal.libraries._registry; + var injections = this._typeInjections[type] || (this._typeInjections[type] = []); - var nameLengths = libs.map(function (item) { - return _emberMetal.get(item, 'name.length'); + injections.push({ + property: property, + fullName: fullName }); + }, - var maxNameLength = Math.max.apply(this, nameLengths); + /** + Defines injection rules. + These rules are used to inject dependencies onto objects when they + are instantiated. + Two forms of injections are possible: + * Injecting one fullName on another fullName + * Injecting one fullName on a type + Example: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('source:main', Source); + registry.register('model:user', User); + registry.register('model:post', Post); + // injecting one fullName on another fullName + // eg. each user model gets a post model + registry.injection('model:user', 'post', 'model:post'); + // injecting one fullName on another type + registry.injection('model', 'source', 'source:main'); + let user = container.lookup('model:user'); + let post = container.lookup('model:post'); + user.source instanceof Source; //=> true + post.source instanceof Source; //=> true + user.post instanceof Post; //=> true + // and both models share the same source + user.source === post.source; //=> true + ``` + @private + @method injection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + injection: function (fullName, property, injectionName) { + this.validateFullName(injectionName); + var normalizedInjectionName = this.normalize(injectionName); - _emberMetal.debug('-------------------------------'); - for (var i = 0; i < libs.length; i++) { - var lib = libs[i]; - var spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); - _emberMetal.debug([lib.name, spaces, ' : ', lib.version].join('')); + if (fullName.indexOf(':') === -1) { + return this.typeInjection(fullName, property, normalizedInjectionName); } - _emberMetal.debug('-------------------------------'); - } - } - - exports.default = Application; -}); -enifed('ember-application/system/engine-instance', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'container', 'ember-application/system/engine-parent'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _container, _emberApplicationSystemEngineParent) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + var normalizedName = this.normalize(fullName); - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); - /** - The `EngineInstance` encapsulates all of the stateful aspects of a - running `Engine`. - - @public - @class Ember.EngineInstance - @extends Ember.Object - @uses RegistryProxyMixin - @uses ContainerProxyMixin - */ + injections.push({ + property: property, + fullName: normalizedInjectionName + }); + }, - var EngineInstance = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, { /** - The base `Engine` for which this is an instance. - @property {Ember.Engine} engine + Used only via `factoryInjection`. + Provides a specialized form of injection, specifically enabling + all factory of one type to be injected with a reference to another + object. + For example, provided each factory of type `model` needed a `store`. + one would do the following: + ```javascript + let registry = new Registry(); + registry.register('store:main', SomeStore); + registry.factoryTypeInjection('model', 'store', 'store:main'); + let store = registry.lookup('store:main'); + let UserFactory = registry.lookupFactory('model:user'); + UserFactory.store instanceof SomeStore; //=> true + ``` @private - */ - base: null, + @method factoryTypeInjection + @param {String} type + @param {String} property + @param {String} fullName + */ + factoryTypeInjection: function (type, property, fullName) { + var injections = this._factoryTypeInjections[type] || (this._factoryTypeInjections[type] = []); - init: function () { - this._super.apply(this, arguments); + injections.push({ + property: property, + fullName: this.normalize(fullName) + }); + }, - _emberUtils.guidFor(this); + /** + Defines factory injection rules. + Similar to regular injection rules, but are run against factories, via + `Registry#lookupFactory`. + These rules are used to inject objects onto factories when they + are looked up. + Two forms of injections are possible: + * Injecting one fullName on another fullName + * Injecting one fullName on a type + Example: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('store:main', Store); + registry.register('store:secondary', OtherStore); + registry.register('model:user', User); + registry.register('model:post', Post); + // injecting one fullName on another type + registry.factoryInjection('model', 'store', 'store:main'); + // injecting one fullName on another fullName + registry.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); + let UserFactory = container.lookupFactory('model:user'); + let PostFactory = container.lookupFactory('model:post'); + let store = container.lookup('store:main'); + UserFactory.store instanceof Store; //=> true + UserFactory.secondaryStore instanceof OtherStore; //=> false + PostFactory.store instanceof Store; //=> true + PostFactory.secondaryStore instanceof OtherStore; //=> true + // and both models share the same source instance + UserFactory.store === PostFactory.store; //=> true + ``` + @private + @method factoryInjection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + factoryInjection: function (fullName, property, injectionName) { + var normalizedName = this.normalize(fullName); + var normalizedInjectionName = this.normalize(injectionName); - var base = this.base; + this.validateFullName(injectionName); - if (!base) { - base = this.application; - this.base = base; + if (fullName.indexOf(':') === -1) { + return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); } - // Create a per-instance registry that will use the application's registry - // as a fallback for resolving registrations. - var registry = this.__registry__ = new _container.Registry({ - fallback: base.__registry__ - }); - - // Create a per-instance container from the instance's registry - this.__container__ = registry.container({ owner: this }); + var injections = this._factoryInjections[normalizedName] || (this._factoryInjections[normalizedName] = []); - this._booted = false; + injections.push({ + property: property, + fullName: normalizedInjectionName + }); }, /** - Initialize the `Ember.EngineInstance` and return a promise that resolves - with the instance itself when the boot process is complete. - The primary task here is to run any registered instance initializers. - See the documentation on `BootOptions` for the options it takes. - @private - @method boot - @param options {Object} - @return {Promise} + @private + @method knownForType + @param {String} type the type to iterate over */ - boot: function (options) { - var _this = this; + knownForType: function (type) { + var fallbackKnown = undefined, + resolverKnown = undefined; - if (this._bootPromise) { - return this._bootPromise; + var localKnown = _emberUtils.dictionary(null); + var registeredNames = Object.keys(this.registrations); + for (var index = 0; index < registeredNames.length; index++) { + var fullName = registeredNames[index]; + var itemType = fullName.split(':')[0]; + + if (itemType === type) { + localKnown[fullName] = true; + } } - this._bootPromise = new _emberRuntime.RSVP.Promise(function (resolve) { - return resolve(_this._bootSync(options)); - }); + if (this.fallback) { + fallbackKnown = this.fallback.knownForType(type); + } - return this._bootPromise; + if (this.resolver && this.resolver.knownForType) { + resolverKnown = this.resolver.knownForType(type); + } + + return _emberUtils.assign({}, fallbackKnown, localKnown, resolverKnown); }, - /** - Unfortunately, a lot of existing code assumes booting an instance is - synchronous – specifically, a lot of tests assume the last call to - `app.advanceReadiness()` or `app.reset()` will result in a new instance - being fully-booted when the current runloop completes. - We would like new code (like the `visit` API) to stop making this - assumption, so we created the asynchronous version above that returns a - promise. But until we have migrated all the code, we would have to expose - this method for use *internally* in places where we need to boot an instance - synchronously. - @private - */ - _bootSync: function (options) { - if (this._booted) { - return this; + validateFullName: function (fullName) { + if (!this.isValidFullName(fullName)) { + throw new TypeError('Invalid Fullname, expected: \'type:name\' got: ' + fullName); } - _emberMetal.assert('An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.', _emberApplicationSystemEngineParent.getEngineParent(this)); - - this.cloneParentDependencies(); - - this.setupRegistry(options); - - this.base.runInstanceInitializers(this); - - this._booted = true; - - return this; - }, - - setupRegistry: function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? this.__container__.lookup('-environment:main') : arguments[0]; - - this.constructor.setupRegistry(this.__registry__, options); - }, - - /** - Unregister a factory. - Overrides `RegistryProxy#unregister` in order to clear any cached instances - of the unregistered factory. - @public - @method unregister - @param {String} fullName - */ - unregister: function (fullName) { - this.__container__.reset(fullName); - this._super.apply(this, arguments); + return true; }, - /** - @private - */ - willDestroy: function () { - this._super.apply(this, arguments); - _emberMetal.run(this.__container__, 'destroy'); + isValidFullName: function (fullName) { + return !!VALID_FULL_NAME_REGEXP.test(fullName); }, - /** - Build a new `Ember.EngineInstance` that's a child of this instance. - Engines must be registered by name with their parent engine - (or application). - @private - @method buildChildEngineInstance - @param name {String} the registered name of the engine. - @param options {Object} options provided to the engine instance. - @return {Ember.EngineInstance,Error} - */ - buildChildEngineInstance: function (name) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - var Engine = this.lookup('engine:' + name); - - if (!Engine) { - throw new _emberMetal.Error('You attempted to mount the engine \'' + name + '\', but it is not registered with its parent.'); + validateInjections: function (injections) { + if (!injections) { + return; } - var engineInstance = Engine.buildInstance(options); + var fullName = undefined; - _emberApplicationSystemEngineParent.setEngineParent(engineInstance, this); + for (var i = 0; i < injections.length; i++) { + fullName = injections[i].fullName; - return engineInstance; + _emberMetal.assert('Attempting to inject an unknown injection: \'' + fullName + '\'', this.has(fullName)); + } }, - /** - Clone dependencies shared between an engine instance and its parent. - @private - @method cloneParentDependencies - */ - cloneParentDependencies: function () { - var _this2 = this; - - var parent = _emberApplicationSystemEngineParent.getEngineParent(this); - - var registrations = ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment']; - - registrations.forEach(function (key) { - return _this2.register(key, parent.resolveRegistration(key)); - }); + normalizeInjectionsHash: function (hash) { + var injections = []; - var env = parent.lookup('-environment:main'); - this.register('-environment:main', env, { instantiate: false }); + for (var key in hash) { + if (hash.hasOwnProperty(key)) { + _emberMetal.assert('Expected a proper full name, given \'' + hash[key] + '\'', this.validateFullName(hash[key])); - var singletons = ['router:main', _container.privatize(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert')]; + injections.push({ + property: key, + fullName: hash[key] + }); + } + } - singletons.forEach(function (key) { - return _this2.register(key, parent.lookup(key), { instantiate: false }); - }); + return injections; + }, - this.inject('view', '_environment', '-environment:main'); - this.inject('route', '_environment', '-environment:main'); - } - }); + getInjections: function (fullName) { + var injections = this._injections[fullName] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getInjections(fullName)); + } + return injections; + }, - EngineInstance.reopenClass({ - /** - @private - @method setupRegistry - @param {Registry} registry - @param {BootOptions} options - */ - setupRegistry: function (registry, options) { - // when no options/environment is present, do nothing - if (!options) { - return; + getTypeInjections: function (type) { + var injections = this._typeInjections[type] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getTypeInjections(type)); } + return injections; + }, - registry.injection('view', '_environment', '-environment:main'); - registry.injection('route', '_environment', '-environment:main'); + getFactoryInjections: function (fullName) { + var injections = this._factoryInjections[fullName] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getFactoryInjections(fullName)); + } + return injections; + }, - if (options.isInteractive) { - registry.injection('view', 'renderer', 'renderer:-dom'); - registry.injection('component', 'renderer', 'renderer:-dom'); - } else { - registry.injection('view', 'renderer', 'renderer:-inert'); - registry.injection('component', 'renderer', 'renderer:-inert'); + getFactoryTypeInjections: function (type) { + var injections = this._factoryTypeInjections[type] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getFactoryTypeInjections(type)); } + return injections; } - }); - - exports.default = EngineInstance; -}); -enifed('ember-application/system/engine-parent', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; - - exports.getEngineParent = getEngineParent; - exports.setEngineParent = setEngineParent; - var ENGINE_PARENT = _emberUtils.symbol('ENGINE_PARENT'); - - exports.ENGINE_PARENT = ENGINE_PARENT; - /** - `getEngineParent` retrieves an engine instance's parent instance. - - @method getEngineParent - @param {EngineInstance} engine An engine instance. - @return {EngineInstance} The parent engine instance. - @for Ember - @public - */ + }; - function getEngineParent(engine) { - return engine[ENGINE_PARENT]; + function deprecateResolverFunction(registry) { + _emberMetal.deprecate('Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.', false, { id: 'ember-application.registry-resolver-as-function', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function' }); + registry.resolver = { + resolve: registry.resolver + }; } /** - `setEngineParent` sets an engine instance's parent instance. + Given a fullName and a source fullName returns the fully resolved + fullName. Used to allow for local lookup. - @method setEngineParent - @param {EngineInstance} engine An engine instance. - @param {EngineInstance} parent The parent engine instance. - @private - */ + ```javascript + let registry = new Registry(); + + // the twitter factory is added to the module system + registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title + ``` + + @private + @method expandLocalLookup + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {String} fullName + */ + Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) { + if (this.resolver && this.resolver.expandLocalLookup) { + _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName)); + _emberMetal.assert('options.source must be provided to expandLocalLookup', options && options.source); + _emberMetal.assert('options.source must be a proper full name', this.validateFullName(options.source)); - function setEngineParent(engine, parent) { - engine[ENGINE_PARENT] = parent; - } -}); -enifed('ember-application/system/engine', ['exports', 'ember-utils', 'ember-runtime', 'container', 'dag-map', 'ember-metal', 'ember-application/system/resolver', 'ember-application/system/engine-instance', 'ember-routing', 'ember-extension-support', 'ember-views', 'ember-glimmer'], function (exports, _emberUtils, _emberRuntime, _container, _dagMap, _emberMetal, _emberApplicationSystemResolver, _emberApplicationSystemEngineInstance, _emberRouting, _emberExtensionSupport, _emberViews, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + var normalizedFullName = this.normalize(fullName); + var normalizedSource = this.normalize(options.source); - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + return expandLocalLookup(this, normalizedFullName, normalizedSource); + } else if (this.fallback) { + return this.fallback.expandLocalLookup(fullName, options); + } else { + return null; + } + }; - function props(obj) { - var properties = []; + function expandLocalLookup(registry, normalizedName, normalizedSource) { + var cache = registry._localLookupCache; + var normalizedNameCache = cache[normalizedName]; - for (var key in obj) { - properties.push(key); + if (!normalizedNameCache) { + normalizedNameCache = cache[normalizedName] = new _emberUtils.EmptyObject(); } - return properties; - } + var cached = normalizedNameCache[normalizedSource]; - /** - The `Engine` class contains core functionality for both applications and - engines. - - Each engine manages a registry that's used for dependency injection and - exposed through `RegistryProxy`. - - Engines also manage initializers and instance initializers. - - Engines can spawn `EngineInstance` instances via `buildInstance()`. - - @class Engine - @namespace Ember - @extends Ember.Namespace - @uses RegistryProxy - @public - */ - var Engine = _emberRuntime.Namespace.extend(_emberRuntime.RegistryProxyMixin, { - init: function () { - this._super.apply(this, arguments); + if (cached !== undefined) { + return cached; + } - this.buildRegistry(); - }, + var expanded = registry.resolver.expandLocalLookup(normalizedName, normalizedSource); - /** - A private flag indicating whether an engine's initializers have run yet. - @private - @property _initializersRan - */ - _initializersRan: false, + return normalizedNameCache[normalizedSource] = expanded; + } - /** - Ensure that initializers are run once, and only once, per engine. - @private - @method ensureInitializers - */ - ensureInitializers: function () { - if (!this._initializersRan) { - this.runInitializers(); - this._initializersRan = true; - } - }, + function resolve(registry, normalizedName, options) { + if (options && options.source) { + // when `source` is provided expand normalizedName + // and source into the full normalizedName + normalizedName = registry.expandLocalLookup(normalizedName, options); - /** - Create an EngineInstance for this engine. - @private - @method buildInstance - @return {Ember.EngineInstance} the engine instance - */ - buildInstance: function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + // if expandLocalLookup returns falsey, we do not support local lookup + if (!normalizedName) { + return; + } + } - this.ensureInitializers(); - options.base = this; - return _emberApplicationSystemEngineInstance.default.create(options); - }, + var cached = registry._resolveCache[normalizedName]; + if (cached !== undefined) { + return cached; + } + if (registry._failCache[normalizedName]) { + return; + } - /** - Build and configure the registry for the current engine. - @private - @method buildRegistry - @return {Ember.Registry} the configured registry - */ - buildRegistry: function () { - var registry = this.__registry__ = this.constructor.buildRegistry(this); + var resolved = undefined; - return registry; - }, + if (registry.resolver) { + resolved = registry.resolver.resolve(normalizedName); + } - /** - @private - @method initializer - */ - initializer: function (options) { - this.constructor.initializer(options); - }, + if (resolved === undefined) { + resolved = registry.registrations[normalizedName]; + } - /** - @private - @method instanceInitializer - */ - instanceInitializer: function (options) { - this.constructor.instanceInitializer(options); - }, + if (resolved === undefined) { + registry._failCache[normalizedName] = true; + } else { + registry._resolveCache[normalizedName] = resolved; + } - /** - @private - @method runInitializers - */ - runInitializers: function () { - var _this = this; + return resolved; + } - this._runInitializer('initializers', function (name, initializer) { - _emberMetal.assert('No application initializer named \'' + name + '\'', !!initializer); - if (initializer.initialize.length === 2) { - _emberMetal.deprecate('The `initialize` method for Application initializer \'' + name + '\' should take only one argument - `App`, an instance of an `Application`.', false, { - id: 'ember-application.app-initializer-initialize-arguments', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_initializer-arity' - }); + function has(registry, fullName, source) { + return registry.resolve(fullName, { source: source }) !== undefined; + } - initializer.initialize(_this.__registry__, _this); - } else { - initializer.initialize(_this); - } - }); - }, + var privateNames = _emberUtils.dictionary(null); + var privateSuffix = '' + Math.random() + Date.now(); - /** - @private - @since 1.12.0 - @method runInstanceInitializers - */ - runInstanceInitializers: function (instance) { - this._runInitializer('instanceInitializers', function (name, initializer) { - _emberMetal.assert('No instance initializer named \'' + name + '\'', !!initializer); - initializer.initialize(instance); - }); - }, + function privatize(_ref) { + var fullName = _ref[0]; - _runInitializer: function (bucketName, cb) { - var initializersByName = _emberMetal.get(this.constructor, bucketName); - var initializers = props(initializersByName); - var graph = new _dagMap.default(); - var initializer = undefined; + var name = privateNames[fullName]; + if (name) { + return name; + } - for (var i = 0; i < initializers.length; i++) { - initializer = initializersByName[initializers[i]]; - graph.add(initializer.name, initializer, initializer.before, initializer.after); - } + var _fullName$split = fullName.split(':'); - graph.topsort(cb); - } - }); + var type = _fullName$split[0]; + var rawName = _fullName$split[1]; - Engine.reopenClass({ - initializers: new _emberUtils.EmptyObject(), - instanceInitializers: new _emberUtils.EmptyObject(), + return privateNames[fullName] = _emberUtils.intern(type + ':' + rawName + '-' + privateSuffix); + } +}); +enifed('dag-map', ['exports'], function (exports) { 'use strict'; +/** + * A map of key/value pairs with dependencies contraints that can be traversed + * in topological order and is checked for cycles. + * + * @class DAG + * @constructor + */ +var DAG = (function () { + function DAG() { + this._vertices = new Vertices(); + } /** - The goal of initializers should be to register dependencies and injections. - This phase runs once. Because these initializers may load code, they are - allowed to defer application readiness and advance it. If you need to access - the container or store you should use an InstanceInitializer that will be run - after all initializers and therefore after all code is loaded and the app is - ready. - Initializer receives an object which has the following attributes: - `name`, `before`, `after`, `initialize`. The only required attribute is - `initialize`, all others are optional. - * `name` allows you to specify under which name the initializer is registered. - This must be a unique name, as trying to register two initializers with the - same name will result in an error. - ```javascript - Ember.Application.initializer({ - name: 'namedInitializer', - initialize: function(application) { - Ember.debug('Running namedInitializer!'); - } - }); - ``` - * `before` and `after` are used to ensure that this initializer is ran prior - or after the one identified by the value. This value can be a single string - or an array of strings, referencing the `name` of other initializers. - An example of ordering initializers, we create an initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'first', - initialize: function(application) { - Ember.debug('First initializer!'); + * Adds a key/value pair with dependencies on other key/value pairs. + * + * @public + * @method addEdges + * @param {string[]} key The key of the vertex to be added. + * @param {any} value The value of that vertex. + * @param {string[]|string|undefined} before A key or array of keys of the vertices that must + * be visited before this vertex. + * @param {string[]|string|undefined} after An string or array of strings with the keys of the + * vertices that must be after this vertex is visited. + */ + DAG.prototype.add = function (key, value, before, after) { + var vertices = this._vertices; + var v = vertices.add(key); + v.val = value; + if (before) { + if (typeof before === "string") { + vertices.addEdge(v, vertices.add(before)); + } + else { + for (var i = 0; i < before.length; i++) { + vertices.addEdge(v, vertices.add(before[i])); + } + } } - }); - // DEBUG: First initializer! - ``` - We add another initializer named `second`, specifying that it should run - after the initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'second', - after: 'first', - initialize: function(application) { - Ember.debug('Second initializer!'); + if (after) { + if (typeof after === "string") { + vertices.addEdge(vertices.add(after), v); + } + else { + for (var i = 0; i < after.length; i++) { + vertices.addEdge(vertices.add(after[i]), v); + } + } } - }); - // DEBUG: First initializer! - // DEBUG: Second initializer! - ``` - Afterwards we add a further initializer named `pre`, this time specifying - that it should run before the initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'pre', - before: 'first', - initialize: function(application) { - Ember.debug('Pre initializer!'); + }; + /** + * Visits key/value pairs in topological order. + * + * @public + * @method topsort + * @param {Function} fn The function to be invoked with each key/value. + */ + DAG.prototype.topsort = function (callback) { + this._vertices.topsort(callback); + }; + return DAG; +}()); +var Vertices = (function () { + function Vertices() { + this.stack = new IntStack(); + this.result = new IntStack(); + this.vertices = []; + } + Vertices.prototype.add = function (key) { + if (!key) + throw new Error("missing key"); + var vertices = this.vertices; + var i = 0; + var vertex; + for (; i < vertices.length; i++) { + vertex = vertices[i]; + if (vertex.key === key) + return vertex; } - }); - // DEBUG: Pre initializer! - // DEBUG: First initializer! - // DEBUG: Second initializer! - ``` - Finally we add an initializer named `post`, specifying it should run after - both the `first` and the `second` initializers: - ```javascript - Ember.Application.initializer({ - name: 'post', - after: ['first', 'second'], - initialize: function(application) { - Ember.debug('Post initializer!'); + return vertices[i] = { + id: i, + key: key, + val: null, + inc: null, + out: false, + mark: false + }; + }; + Vertices.prototype.addEdge = function (v, w) { + this.check(v, w.key); + var inc = w.inc; + if (!inc) { + w.inc = [v.id]; } - }); - // DEBUG: Pre initializer! - // DEBUG: First initializer! - // DEBUG: Second initializer! - // DEBUG: Post initializer! - ``` - * `initialize` is a callback function that receives one argument, - `application`, on which you can operate. - Example of using `application` to register an adapter: - ```javascript - Ember.Application.initializer({ - name: 'api-adapter', - initialize: function(application) { - application.register('api-adapter:main', ApiAdapter); + else { + var i = 0; + for (; i < inc.length; i++) { + if (inc[i] === v.id) + return; + } + inc[i] = v.id; } - }); - ``` - @method initializer - @param initializer {Object} - @public - */ - - initializer: buildInitializerMethod('initializers', 'initializer'), - - /** - Instance initializers run after all initializers have run. Because - instance initializers run after the app is fully set up. We have access - to the store, container, and other items. However, these initializers run - after code has loaded and are not allowed to defer readiness. - Instance initializer receives an object which has the following attributes: - `name`, `before`, `after`, `initialize`. The only required attribute is - `initialize`, all others are optional. - * `name` allows you to specify under which name the instanceInitializer is - registered. This must be a unique name, as trying to register two - instanceInitializer with the same name will result in an error. - ```javascript - Ember.Application.instanceInitializer({ - name: 'namedinstanceInitializer', - initialize: function(application) { - Ember.debug('Running namedInitializer!'); + v.out = true; + }; + Vertices.prototype.topsort = function (cb) { + this.reset(); + var vertices = this.vertices; + for (var i = 0; i < vertices.length; i++) { + var vertex = vertices[i]; + if (vertex.out) + continue; + this.visit(vertex, undefined); } - }); - ``` - * `before` and `after` are used to ensure that this initializer is ran prior - or after the one identified by the value. This value can be a single string - or an array of strings, referencing the `name` of other initializers. - * See Ember.Application.initializer for discussion on the usage of before - and after. - Example instanceInitializer to preload data into the store. - ```javascript - Ember.Application.initializer({ - name: 'preload-data', - initialize: function(application) { - var userConfig, userConfigEncoded, store; - // We have a HTML escaped JSON representation of the user's basic - // configuration generated server side and stored in the DOM of the main - // index.html file. This allows the app to have access to a set of data - // without making any additional remote calls. Good for basic data that is - // needed for immediate rendering of the page. Keep in mind, this data, - // like all local models and data can be manipulated by the user, so it - // should not be relied upon for security or authorization. - // - // Grab the encoded data from the meta tag - userConfigEncoded = Ember.$('head meta[name=app-user-config]').attr('content'); - // Unescape the text, then parse the resulting JSON into a real object - userConfig = JSON.parse(unescape(userConfigEncoded)); - // Lookup the store - store = application.lookup('service:store'); - // Push the encoded JSON into the store - store.pushPayload(userConfig); + this.each(cb); + }; + Vertices.prototype.check = function (v, w) { + if (v.key === w) { + throw new Error("cycle detected: " + w + " <- " + w); } - }); - ``` - @method instanceInitializer - @param instanceInitializer - @public - */ - instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer'), + var inc = v.inc; + // quick check + if (!inc || inc.length === 0) + return; + var vertices = this.vertices; + // shallow check + for (var i = 0; i < inc.length; i++) { + var key = vertices[inc[i]].key; + if (key === w) { + throw new Error("cycle detected: " + w + " <- " + v.key + " <- " + w); + } + } + // deep check + this.reset(); + this.visit(v, w); + if (this.result.len > 0) { + var msg_1 = "cycle detected: " + w; + this.each(function (key) { + msg_1 += " <- " + key; + }); + throw new Error(msg_1); + } + }; + Vertices.prototype.each = function (cb) { + var _a = this, result = _a.result, vertices = _a.vertices; + for (var i = 0; i < result.len; i++) { + var vertex = vertices[result.stack[i]]; + cb(vertex.key, vertex.val); + } + }; + // reuse between cycle check and topsort + Vertices.prototype.reset = function () { + this.stack.len = 0; + this.result.len = 0; + var vertices = this.vertices; + for (var i = 0; i < vertices.length; i++) { + vertices[i].mark = false; + } + }; + Vertices.prototype.visit = function (start, search) { + var _a = this, stack = _a.stack, result = _a.result, vertices = _a.vertices; + stack.push(start.id); + while (stack.len) { + var index = stack.pop(); + if (index < 0) { + index = ~index; + if (search) { + result.pop(); + } + else { + result.push(index); + } + } + else { + var vertex = vertices[index]; + if (vertex.mark) { + continue; + } + if (search) { + result.push(index); + if (search === vertex.key) { + return; + } + } + vertex.mark = true; + stack.push(~index); + var incoming = vertex.inc; + if (incoming) { + var i = incoming.length; + while (i--) { + index = incoming[i]; + if (!vertices[index].mark) { + stack.push(index); + } + } + } + } + } + }; + return Vertices; +}()); +var IntStack = (function () { + function IntStack() { + this.stack = [0, 0, 0, 0, 0, 0]; + this.len = 0; + } + IntStack.prototype.push = function (n) { + this.stack[this.len++] = n; + }; + IntStack.prototype.pop = function () { + return this.stack[--this.len]; + }; + return IntStack; +}()); - /** - This creates a registry with the default Ember naming conventions. - It also configures the registry: - * registered views are created every time they are looked up (they are - not singletons) - * registered templates are not factories; the registered value is - returned directly. - * the router receives the application as its `namespace` property - * all controllers receive the router as their `target` and `controllers` - properties - * all controllers receive the application as their `namespace` property - * the application view receives the application controller as its - `controller` property - * the application view receives the application template as its - `defaultTemplate` property - @method buildRegistry - @static - @param {Ember.Application} namespace the application for which to - build the registry - @return {Ember.Registry} the built registry - @private - */ - buildRegistry: function (namespace) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; +exports['default'] = DAG; - var registry = new _container.Registry({ - resolver: resolverFor(namespace) - }); +Object.defineProperty(exports, '__esModule', { value: true }); - registry.set = _emberMetal.set; +}); +enifed('ember-application/index', ['exports', 'ember-application/initializers/dom-templates', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/resolver', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (exports, _emberApplicationInitializersDomTemplates, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberApplicationSystemResolver, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent) { + /** + @module ember + @submodule ember-application + */ - registry.register('application:main', namespace, { instantiate: false }); + 'use strict'; - commonSetupRegistry(registry); - _emberGlimmer.setupEngineRegistry(registry); + exports.Application = _emberApplicationSystemApplication.default; + exports.ApplicationInstance = _emberApplicationSystemApplicationInstance.default; + exports.Resolver = _emberApplicationSystemResolver.default; + exports.Engine = _emberApplicationSystemEngine.default; + exports.EngineInstance = _emberApplicationSystemEngineInstance.default; + exports.getEngineParent = _emberApplicationSystemEngineParent.getEngineParent; + exports.setEngineParent = _emberApplicationSystemEngineParent.setEngineParent; - return registry; - }, + // add domTemplates initializer (only does something if `ember-template-compiler` + // is loaded already) +}); +enifed('ember-application/initializers/dom-templates', ['exports', 'require', 'ember-glimmer', 'ember-environment', 'ember-application/system/application'], function (exports, _require, _emberGlimmer, _emberEnvironment, _emberApplicationSystemApplication) { + 'use strict'; - /** - Set this to provide an alternate class to `Ember.DefaultResolver` - @deprecated Use 'Resolver' instead - @property resolver - @public - */ - resolver: null, + var bootstrap = function () {}; - /** - Set this to provide an alternate class to `Ember.DefaultResolver` - @property resolver - @public - */ - Resolver: null + _emberApplicationSystemApplication.default.initializer({ + name: 'domTemplates', + initialize: function () { + var bootstrapModuleId = 'ember-template-compiler/system/bootstrap'; + var context = undefined; + if (_emberEnvironment.environment.hasDOM && _require.has(bootstrapModuleId)) { + bootstrap = _require.default(bootstrapModuleId).default; + context = document; + } + + bootstrap({ context: context, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + } }); +}); +enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberViews, _emberApplicationSystemEngineInstance) { + /** + @module ember + @submodule ember-application + */ + + 'use strict'; + + var BootOptions = undefined; /** - This function defines the default lookup rules for container lookups: + The `ApplicationInstance` encapsulates all of the stateful aspects of a + running `Application`. - * templates are looked up on `Ember.TEMPLATES` - * other names are looked up on the application after classifying the name. - For example, `controller:post` looks up `App.PostController` by default. - * if the default lookup fails, look for registered classes on the container + At a high-level, we break application boot into two distinct phases: - This allows the application to register default injections in the container - that could be overridden by the normal naming convention. + * Definition time, where all of the classes, templates, and other + dependencies are loaded (typically in the browser). + * Run time, where we begin executing the application once everything + has loaded. - @private - @method resolverFor - @param {Ember.Namespace} namespace the namespace to look for classes - @return {*} the resolved value for a given lookup + Definition time can be expensive and only needs to happen once since it is + an idempotent operation. For example, between test runs and FastBoot + requests, the application stays the same. It is only the state that we want + to reset. + + That state is what the `ApplicationInstance` manages: it is responsible for + creating the container that contains all application state, and disposing of + it once the particular test run or FastBoot request has finished. + + @public + @class Ember.ApplicationInstance + @extends Ember.EngineInstance */ - function resolverFor(namespace) { - var ResolverClass = namespace.get('Resolver') || _emberApplicationSystemResolver.default; - - return ResolverClass.create({ - namespace: namespace - }); - } - - function buildInitializerMethod(bucketName, humanName) { - return function (initializer) { - // If this is the first initializer being added to a subclass, we are going to reopen the class - // to make sure we have a new `initializers` object, which extends from the parent class' using - // prototypal inheritance. Without this, attempting to add initializers to the subclass would - // pollute the parent class as well as other subclasses. - if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) { - var attrs = {}; - attrs[bucketName] = Object.create(this[bucketName]); - this.reopenClass(attrs); - } - _emberMetal.assert('The ' + humanName + ' \'' + initializer.name + '\' has already been registered', !this[bucketName][initializer.name]); - _emberMetal.assert('An ' + humanName + ' cannot be registered without an initialize function', _emberUtils.canInvoke(initializer, 'initialize')); - _emberMetal.assert('An ' + humanName + ' cannot be registered without a name property', initializer.name !== undefined); + var ApplicationInstance = _emberApplicationSystemEngineInstance.default.extend({ + /** + The `Application` for which this is an instance. + @property {Ember.Application} application + @private + */ + application: null, - this[bucketName][initializer.name] = initializer; - }; - } + /** + The DOM events for which the event dispatcher should listen. + By default, the application's `Ember.EventDispatcher` listens + for a set of standard DOM events, such as `mousedown` and + `keyup`, and delegates them to your application's `Ember.View` + instances. + @private + @property {Object} customEvents + */ + customEvents: null, - function commonSetupRegistry(registry) { - registry.optionsForType('component', { singleton: false }); - registry.optionsForType('view', { singleton: false }); + /** + The root DOM element of the Application as an element or a + [jQuery-compatible selector + string](http://api.jquery.com/category/selectors/). + @private + @property {String|DOMElement} rootElement + */ + rootElement: null, - registry.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); + init: function () { + this._super.apply(this, arguments); - registry.injection('view', '_viewRegistry', '-view-registry:main'); - registry.injection('renderer', '_viewRegistry', '-view-registry:main'); - registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); + // Register this instance in the per-instance registry. + // + // Why do we need to register the instance in the first place? + // Because we need a good way for the root route (a.k.a ApplicationRoute) + // to notify us when it has created the root-most view. That view is then + // appended to the rootElement, in the case of apps, to the fixture harness + // in tests, or rendered to a string in the case of FastBoot. + this.register('-application-instance:main', this, { instantiate: false }); + }, - registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); + /** + Overrides the base `EngineInstance._bootSync` method with concerns relevant + to booting application (instead of engine) instances. + This method should only contain synchronous boot concerns. Asynchronous + boot concerns should eventually be moved to the `boot` method, which + returns a promise. + Until all boot code has been made asynchronous, we need to continue to + expose this method for use *internally* in places where we need to boot an + instance synchronously. + @private + */ + _bootSync: function (options) { + if (this._booted) { + return this; + } - registry.injection('view:-outlet', 'namespace', 'application:main'); + options = new BootOptions(options); - registry.injection('controller', 'target', 'router:main'); - registry.injection('controller', 'namespace', 'application:main'); + this.setupRegistry(options); - registry.injection('router', '_bucketCache', _container.privatize(_templateObject)); - registry.injection('route', '_bucketCache', _container.privatize(_templateObject)); + if (options.rootElement) { + this.rootElement = options.rootElement; + } else { + this.rootElement = this.application.rootElement; + } - registry.injection('route', 'router', 'router:main'); + if (options.location) { + var router = _emberMetal.get(this, 'router'); + _emberMetal.set(router, 'location', options.location); + } - // Register the routing service... - registry.register('service:-routing', _emberRouting.RoutingService); - // Then inject the app router into it - registry.injection('service:-routing', 'router', 'router:main'); + this.application.runInstanceInitializers(this); - // DEBUGGING - registry.register('resolver-for-debugging:main', registry.resolver, { instantiate: false }); - registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); - registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); - // Custom resolver authors may want to register their own ContainerDebugAdapter with this key + if (options.isInteractive) { + this.setupEventDispatcher(); + } - registry.register('container-debug-adapter:main', _emberExtensionSupport.ContainerDebugAdapter); + this._booted = true; - registry.register('component-lookup:main', _emberViews.ComponentLookup); - } + return this; + }, - exports.default = Engine; -}); -enifed('ember-application/system/resolver', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application/utils/validate-type', 'ember-glimmer'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplicationUtilsValidateType, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ + setupRegistry: function (options) { + this.constructor.setupRegistry(this.__registry__, options); + }, - 'use strict'; + router: _emberMetal.computed(function () { + return this.lookup('router:main'); + }).readOnly(), - var Resolver = _emberRuntime.Object.extend({ - /* - This will be set to the Application instance when it is - created. - @property namespace + /** + This hook is called by the root-most Route (a.k.a. the ApplicationRoute) + when it has finished creating the root View. By default, we simply take the + view and append it to the `rootElement` specified on the Application. + In cases like FastBoot and testing, we can override this hook and implement + custom behavior, such as serializing to a string and sending over an HTTP + socket rather than appending to DOM. + @param view {Ember.View} the root-most view + @private */ - namespace: null, - normalize: null, // required - resolve: null, // required - parseName: null, // required - lookupDescription: null, // required - makeToString: null, // required - resolveOther: null, // required - _logLookup: null // required - }); - - exports.Resolver = Resolver; - /** - The DefaultResolver defines the default lookup rules to resolve - container lookups before consulting the container for registered - items: - - * templates are looked up on `Ember.TEMPLATES` - * other names are looked up on the application after converting - the name. For example, `controller:post` looks up - `App.PostController` by default. - * there are some nuances (see examples below) - - ### How Resolving Works - - The container calls this object's `resolve` method with the - `fullName` argument. - - It first parses the fullName into an object using `parseName`. - - Then it checks for the presence of a type-specific instance - method of the form `resolve[Type]` and calls it if it exists. - For example if it was resolving 'template:post', it would call - the `resolveTemplate` method. - - Its last resort is to call the `resolveOther` method. - - The methods of this object are designed to be easy to override - in a subclass. For example, you could enhance how a template - is resolved like so: - - ```javascript - App = Ember.Application.create({ - Resolver: Ember.DefaultResolver.extend({ - resolveTemplate: function(parsedName) { - let resolvedTemplate = this._super(parsedName); - if (resolvedTemplate) { return resolvedTemplate; } - return Ember.TEMPLATES['not_found']; - } - }) - }); - ``` - - Some examples of how names are resolved: - - ``` - 'template:post' //=> Ember.TEMPLATES['post'] - 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] - 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] - 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] - // OR - // Ember.TEMPLATES['blog_post'] - 'controller:post' //=> App.PostController - 'controller:posts.index' //=> App.PostsIndexController - 'controller:blog/post' //=> Blog.PostController - 'controller:basic' //=> Ember.Controller - 'route:post' //=> App.PostRoute - 'route:posts.index' //=> App.PostsIndexRoute - 'route:blog/post' //=> Blog.PostRoute - 'route:basic' //=> Ember.Route - 'view:post' //=> App.PostView - 'view:posts.index' //=> App.PostsIndexView - 'view:blog/post' //=> Blog.PostView - 'view:basic' //=> Ember.View - 'foo:post' //=> App.PostFoo - 'model:post' //=> App.Post - ``` - - @class DefaultResolver - @namespace Ember - @extends Ember.Object - @public - */ + didCreateRootView: function (view) { + view.appendTo(this.rootElement); + }, - exports.default = _emberRuntime.Object.extend({ /** - This will be set to the Application instance when it is - created. - @property namespace - @public + Tells the router to start routing. The router will ask the location for the + current URL of the page to determine the initial URL to start routing to. + To start the app at a specific URL, call `handleURL` instead. + @private */ - namespace: null, - - init: function () { - this._parseNameCache = _emberUtils.dictionary(null); + startRouting: function () { + var router = _emberMetal.get(this, 'router'); + router.startRouting(); + this._didSetupRouter = true; }, - normalize: function (fullName) { - var _fullName$split = fullName.split(':', 2); - - var type = _fullName$split[0]; - var name = _fullName$split[1]; - - _emberMetal.assert('Tried to normalize a container name without a colon (:) in it. ' + 'You probably tried to lookup a name that did not contain a type, ' + 'a colon, and a name. A proper lookup name would be `view:post`.', fullName.split(':').length === 2); - - if (type !== 'template') { - var result = name; - - if (result.indexOf('.') > -1) { - result = result.replace(/\.(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } - - if (name.indexOf('_') > -1) { - result = result.replace(/_(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } - - if (name.indexOf('-') > -1) { - result = result.replace(/-(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } - return type + ':' + result; - } else { - return fullName; + /** + @private + Sets up the router, initializing the child router and configuring the + location before routing begins. + Because setup should only occur once, multiple calls to `setupRouter` + beyond the first call have no effect. + */ + setupRouter: function () { + if (this._didSetupRouter) { + return; } + this._didSetupRouter = true; + + var router = _emberMetal.get(this, 'router'); + router.setupRouter(); }, /** - This method is called via the container's resolver method. - It parses the provided `fullName` and then looks up and - returns the appropriate template or class. - @method resolve - @param {String} fullName the lookup string - @return {Object} the resolved factory - @public + Directs the router to route to a particular URL. This is useful in tests, + for example, to tell the app to start at a particular URL. + @param url {String} the URL the router should route to + @private */ - resolve: function (fullName) { - var parsedName = this.parseName(fullName); - var resolveMethodName = parsedName.resolveMethodName; - var resolved; - - if (this[resolveMethodName]) { - resolved = this[resolveMethodName](parsedName); - } + handleURL: function (url) { + var router = _emberMetal.get(this, 'router'); - resolved = resolved || this.resolveOther(parsedName); + this.setupRouter(); + return router.handleURL(url); + }, - if (parsedName.root && parsedName.root.LOG_RESOLVER) { - this._logLookup(resolved, parsedName); - } + /** + @private + */ + setupEventDispatcher: function () { + var dispatcher = this.lookup('event_dispatcher:main'); + var applicationCustomEvents = _emberMetal.get(this.application, 'customEvents'); + var instanceCustomEvents = _emberMetal.get(this, 'customEvents'); - if (resolved) { - _emberApplicationUtilsValidateType.default(resolved, parsedName); - } + var customEvents = _emberUtils.assign({}, applicationCustomEvents, instanceCustomEvents); + dispatcher.setup(customEvents, this.rootElement); - return resolved; + return dispatcher; }, /** - Convert the string name of the form 'type:name' to - a Javascript object with the parsed aspects of the name - broken out. - @param {String} fullName the lookup string - @method parseName - @protected + Returns the current URL of the app instance. This is useful when your + app does not update the browsers URL bar (i.e. it uses the `'none'` + location adapter). + @public + @return {String} the current URL */ - - parseName: function (fullName) { - return this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)); + getURL: function () { + var router = _emberMetal.get(this, 'router'); + return _emberMetal.get(router, 'url'); }, - _parseName: function (fullName) { - var _fullName$split2 = fullName.split(':'); - - var type = _fullName$split2[0]; - var fullNameWithoutType = _fullName$split2[1]; + // `instance.visit(url)` should eventually replace `instance.handleURL()`; + // the test helpers can probably be switched to use this implementation too - var name = fullNameWithoutType; - var namespace = _emberMetal.get(this, 'namespace'); - var root = namespace; - var lastSlashIndex = name.lastIndexOf('/'); - var dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null; + /** + Navigate the instance to a particular URL. This is useful in tests, for + example, or to tell the app to start at a particular URL. This method + returns a promise that resolves with the app instance when the transition + is complete, or rejects if the transion was aborted due to an error. + @public + @param url {String} the destination URL + @return {Promise} + */ + visit: function (url) { + var _this = this; - if (type !== 'template' && lastSlashIndex !== -1) { - var parts = name.split('/'); - name = parts[parts.length - 1]; - var namespaceName = _emberRuntime.String.capitalize(parts.slice(0, -1).join('.')); - root = _emberRuntime.Namespace.byName(namespaceName); + this.setupRouter(); - _emberMetal.assert('You are looking for a ' + name + ' ' + type + ' in the ' + namespaceName + ' namespace, but the namespace could not be found', root); - } + var bootOptions = this.__container__.lookup('-environment:main'); - var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : _emberRuntime.String.classify(type); + var router = _emberMetal.get(this, 'router'); - if (!(name && type)) { - throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); - } + var handleTransitionResolve = function () { + if (!bootOptions.options.shouldRender) { + // No rendering is needed, and routing has completed, simply return. + return _this; + } else { + return new _emberRuntime.RSVP.Promise(function (resolve) { + // Resolve once rendering is completed. `router.handleURL` returns the transition (as a thennable) + // which resolves once the transition is completed, but the transition completion only queues up + // a scheduled revalidation (into the `render` queue) in the Renderer. + // + // This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed. + _emberMetal.run.schedule('afterRender', null, resolve, _this); + }); + } + }; - return { - fullName: fullName, - type: type, - fullNameWithoutType: fullNameWithoutType, - dirname: dirname, - name: name, - root: root, - resolveMethodName: 'resolve' + resolveMethodName + var handleTransitionReject = function (error) { + if (error.error) { + throw error.error; + } else if (error.name === 'TransitionAborted' && router.router.activeTransition) { + return router.router.activeTransition.then(handleTransitionResolve, handleTransitionReject); + } else if (error.name === 'TransitionAborted') { + throw new Error(error.message); + } else { + throw error; + } }; - }, + var location = _emberMetal.get(router, 'location'); + + // Keeps the location adapter's internal URL in-sync + location.setURL(url); + + // getURL returns the set url with the rootURL stripped off + return router.handleURL(location.getURL()).then(handleTransitionResolve, handleTransitionReject); + } + }); + + ApplicationInstance.reopenClass({ /** - Returns a human-readable description for a fullName. Used by the - Application namespace in assertions to describe the - precise name of the class that Ember is looking for, rather than - container keys. - @param {String} fullName the lookup string - @method lookupDescription - @protected + @private + @method setupRegistry + @param {Registry} registry + @param {BootOptions} options */ - lookupDescription: function (fullName) { - var parsedName = this.parseName(fullName); - var description = undefined; + setupRegistry: function (registry) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (parsedName.type === 'template') { - return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + if (!options.toEnvironment) { + options = new BootOptions(options); } - description = parsedName.root + '.' + _emberRuntime.String.classify(parsedName.name).replace(/\./g, ''); - - if (parsedName.type !== 'model') { - description += _emberRuntime.String.classify(parsedName.type); - } + registry.register('-environment:main', options.toEnvironment(), { instantiate: false }); + registry.register('service:-document', options.document, { instantiate: false }); - return description; - }, + this._super(registry, options); + } + }); - makeToString: function (factory, fullName) { - return factory.toString(); - }, + /** + A list of boot-time configuration options for customizing the behavior of + an `Ember.ApplicationInstance`. + + This is an interface class that exists purely to document the available + options; you do not need to construct it manually. Simply pass a regular + JavaScript object containing the desired options into methods that require + one of these options object: + + ```javascript + MyApp.visit("/", { location: "none", rootElement: "#container" }); + ``` + + Not all combinations of the supported options are valid. See the documentation + on `Ember.Application#visit` for the supported configurations. + + Internal, experimental or otherwise unstable flags are marked as private. + + @class BootOptions + @namespace Ember.ApplicationInstance + @public + */ + BootOptions = function BootOptions() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; /** - Given a parseName object (output from `parseName`), apply - the conventions expected by `Ember.Router` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method useRouterNaming - @protected - */ - useRouterNaming: function (parsedName) { - parsedName.name = parsedName.name.replace(/\./g, '_'); - if (parsedName.name === 'basic') { - parsedName.name = ''; - } - }, - /** - Look up the template in Ember.TEMPLATES - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveTemplate - @protected + Provide a specific instance of jQuery. This is useful in conjunction with + the `document` option, as it allows you to use a copy of `jQuery` that is + appropriately bound to the foreign `document` (e.g. a jsdom). + This is highly experimental and support very incomplete at the moment. + @property jQuery + @type Object + @default auto-detected + @private */ - resolveTemplate: function (parsedName) { - var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); - - return _emberGlimmer.getTemplate(templateName) || _emberGlimmer.getTemplate(_emberRuntime.String.decamelize(templateName)); - }, + this.jQuery = _emberViews.jQuery; // This default is overridable below /** - Lookup the view using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveView - @protected + Interactive mode: whether we need to set up event delegation and invoke + lifecycle callbacks on Components. + @property isInteractive + @type boolean + @default auto-detected + @private */ - resolveView: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); - }, + this.isInteractive = _emberEnvironment.environment.hasDOM; // This default is overridable below /** - Lookup the controller using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveController - @protected - */ - resolveController: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); - }, - /** - Lookup the route using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveRoute - @protected + Run in a full browser environment. + When this flag is set to `false`, it will disable most browser-specific + and interactive features. Specifically: + * It does not use `jQuery` to append the root view; the `rootElement` + (either specified as a subsequent option or on the application itself) + must already be an `Element` in the given `document` (as opposed to a + string selector). + * It does not set up an `EventDispatcher`. + * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). + * It sets the `location` option to `"none"`. (If you would like to use + the location adapter specified in the app's router instead, you can also + specify `{ location: null }` to specifically opt-out.) + @property isBrowser + @type boolean + @default auto-detected + @public */ - resolveRoute: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); - }, + if (options.isBrowser !== undefined) { + this.isBrowser = !!options.isBrowser; + } else { + this.isBrowser = _emberEnvironment.environment.hasDOM; + } - /** - Lookup the model on the Application namespace - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveModel - @protected - */ - resolveModel: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.name); - var factory = _emberMetal.get(parsedName.root, className); + if (!this.isBrowser) { + this.jQuery = null; + this.isInteractive = false; + this.location = 'none'; + } - return factory; - }, - /** - Look up the specified object (from parsedName) on the appropriate - namespace (usually on the Application) - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveHelper - @protected - */ - resolveHelper: function (parsedName) { - return this.resolveOther(parsedName); - }, /** - Look up the specified object (from parsedName) on the appropriate - namespace (usually on the Application) - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveOther - @protected + Disable rendering completely. + When this flag is set to `true`, it will disable the entire rendering + pipeline. Essentially, this puts the app into "routing-only" mode. No + templates will be rendered, and no Components will be created. + @property shouldRender + @type boolean + @default true + @public */ - resolveOther: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.name) + _emberRuntime.String.classify(parsedName.type); - var factory = _emberMetal.get(parsedName.root, className); - return factory; - }, + if (options.shouldRender !== undefined) { + this.shouldRender = !!options.shouldRender; + } else { + this.shouldRender = true; + } - resolveMain: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.type); - return _emberMetal.get(parsedName.root, className); - }, + if (!this.shouldRender) { + this.jQuery = null; + this.isInteractive = false; + } /** - @method _logLookup - @param {Boolean} found - @param {Object} parsedName - @private - */ - _logLookup: function (found, parsedName) { - var symbol = undefined, - padding = undefined; - - if (found) { - symbol = '[✓]'; - } else { - symbol = '[ ]'; - } - - if (parsedName.fullName.length > 60) { - padding = '.'; - } else { - padding = new Array(60 - parsedName.fullName.length).join('.'); - } - - _emberMetal.info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); - }, + If present, render into the given `Document` object instead of the + global `window.document` object. + In practice, this is only useful in non-browser environment or in + non-interactive mode, because Ember's `jQuery` dependency is + implicitly bound to the current document, causing event delegation + to not work properly when the app is rendered into a foreign + document object (such as an iframe's `contentDocument`). + In non-browser mode, this could be a "`Document`-like" object as + Ember only interact with a small subset of the DOM API in non- + interactive mode. While the exact requirements have not yet been + formalized, the `SimpleDOM` library's implementation is known to + work. + @property document + @type Document + @default the global `document` object + @public + */ + if (options.document) { + this.document = options.document; + } else { + this.document = typeof document !== 'undefined' ? document : null; + } /** - Used to iterate all items of a given type. - @method knownForType - @param {String} type the type to search for - @private + If present, overrides the application's `rootElement` property on + the instance. This is useful for testing environment, where you + might want to append the root view to a fixture area. + In non-browser mode, because Ember does not have access to jQuery, + this options must be specified as a DOM `Element` object instead of + a selector string. + See the documentation on `Ember.Applications`'s `rootElement` for + details. + @property rootElement + @type String|Element + @default null + @public */ - knownForType: function (type) { - var namespace = _emberMetal.get(this, 'namespace'); - var suffix = _emberRuntime.String.classify(type); - var typeRegexp = new RegExp(suffix + '$'); + if (options.rootElement) { + this.rootElement = options.rootElement; + } - var known = _emberUtils.dictionary(null); - var knownKeys = Object.keys(namespace); - for (var index = 0; index < knownKeys.length; index++) { - var _name = knownKeys[index]; + // Set these options last to give the user a chance to override the + // defaults from the "combo" options like `isBrowser` (although in + // practice, the resulting combination is probably invalid) - if (typeRegexp.test(_name)) { - var containerName = this.translateToContainerFullname(type, _name); + /** + If present, overrides the router's `location` property with this + value. This is useful for environments where trying to modify the + URL would be inappropriate. + @property location + @type string + @default null + @public + */ + if (options.location !== undefined) { + this.location = options.location; + } - known[containerName] = true; - } - } + if (options.jQuery !== undefined) { + this.jQuery = options.jQuery; + } - return known; - }, + if (options.isInteractive !== undefined) { + this.isInteractive = !!options.isInteractive; + } + }; - /** - Converts provided name from the backing namespace into a container lookup name. - Examples: - App.FooBarHelper -> helper:foo-bar - App.THelper -> helper:t - @method translateToContainerFullname - @param {String} type - @param {String} name - @private - */ + BootOptions.prototype.toEnvironment = function () { + var env = _emberUtils.assign({}, _emberEnvironment.environment); + // For compatibility with existing code + env.hasDOM = this.isBrowser; + env.isInteractive = this.isInteractive; + env.options = this; + return env; + }; - translateToContainerFullname: function (type, name) { - var suffix = _emberRuntime.String.classify(type); - var namePrefix = name.slice(0, suffix.length * -1); - var dasherizedName = _emberRuntime.String.dasherize(namePrefix); + Object.defineProperty(ApplicationInstance.prototype, 'container', { + configurable: true, + enumerable: false, + get: function () { + var instance = this; + return { + lookup: function () { + _emberMetal.deprecate('Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead.', false, { + id: 'ember-application.app-instance-container', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container' + }); + return instance.lookup.apply(instance, arguments); + } + }; + } + }); - return type + ':' + dasherizedName; + Object.defineProperty(ApplicationInstance.prototype, 'registry', { + configurable: true, + enumerable: false, + get: function () { + return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'ApplicationInstance'); } }); + + exports.default = ApplicationInstance; }); -enifed('ember-application/utils/validate-type', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application/system/application-instance', 'container', 'ember-application/system/engine', 'ember-glimmer'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRuntime, _emberViews, _emberRouting, _emberApplicationSystemApplicationInstance, _container, _emberApplicationSystemEngine, _emberGlimmer) { /** @module ember @submodule ember-application */ - - 'use strict'; - - exports.default = validateType; - - var VALIDATED_TYPES = { - route: ['assert', 'isRouteFactory', 'Ember.Route'], - component: ['deprecate', 'isComponentFactory', 'Ember.Component'], - view: ['deprecate', 'isViewFactory', 'Ember.View'], - service: ['deprecate', 'isServiceFactory', 'Ember.Service'] - }; - - function validateType(resolvedType, parsedName) { - var validationAttributes = VALIDATED_TYPES[parsedName.type]; - - if (!validationAttributes) { - return; - } - - var action = validationAttributes[0]; - var factoryFlag = validationAttributes[1]; - var expectedType = validationAttributes[2]; - - if (action === 'deprecate') { - _emberMetal.deprecate('In Ember 2.0 ' + parsedName.type + ' factories must have an `' + factoryFlag + '` ' + ('property set to true. You registered ' + resolvedType + ' as a ' + parsedName.type + ' ') + ('factory. Either add the `' + factoryFlag + '` property to this factory or ') + ('extend from ' + expectedType + '.'), !!resolvedType[factoryFlag], { id: 'ember-application.validate-type', until: '3.0.0' }); - } else { - _emberMetal.assert('Expected ' + parsedName.fullName + ' to resolve to an ' + expectedType + ' but ' + ('instead it was ' + resolvedType + '.'), !!resolvedType[factoryFlag]); - } - } -}); -enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { 'use strict'; - function K() {} - - function consoleMethod(name) { - var consoleObj = undefined; - if (_emberEnvironment.context.imports.console) { - consoleObj = _emberEnvironment.context.imports.console; - } else if (typeof console !== 'undefined') { - consoleObj = console; - } - - var method = typeof consoleObj === 'object' ? consoleObj[name] : null; - - if (typeof method !== 'function') { - return; - } - - if (typeof method.bind === 'function') { - return method.bind(consoleObj); - } - - return function () { - method.apply(consoleObj, arguments); - }; - } + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); - function assertPolyfill(test, message) { - if (!test) { - try { - // attempt to preserve the stack - throw new Error('assertion failed: ' + message); - } catch (error) { - setTimeout(function () { - throw error; - }, 0); - } - } - } + var librariesRegistered = false; /** - Inside Ember-Metal, simply uses the methods from `imports.console`. - Override this to provide more robust logging functionality. + An instance of `Ember.Application` is the starting point for every Ember + application. It helps to instantiate, initialize and coordinate the many + objects that make up your app. - @class Logger + Each Ember app has one and only one `Ember.Application` object. In fact, the + very first thing you should do in your application is create the instance: + + ```javascript + window.App = Ember.Application.create(); + ``` + + Typically, the application object is the only global variable. All other + classes in your app should be properties on the `Ember.Application` instance, + which highlights its first role: a global namespace. + + For example, if you define a view class, it might look like this: + + ```javascript + App.MyView = Ember.View.extend(); + ``` + + By default, calling `Ember.Application.create()` will automatically initialize + your application by calling the `Ember.Application.initialize()` method. If + you need to delay initialization, you can call your app's `deferReadiness()` + method. When you are ready for your app to be initialized, call its + `advanceReadiness()` method. + + You can define a `ready` method on the `Ember.Application` instance, which + will be run by Ember when the application is initialized. + + Because `Ember.Application` inherits from `Ember.Namespace`, any classes + you create will have useful string representations when calling `toString()`. + See the `Ember.Namespace` documentation for more information. + + While you can think of your `Ember.Application` as a container that holds the + other classes in your application, there are several other responsibilities + going on under-the-hood that you may want to understand. + + ### Event Delegation + + Ember uses a technique called _event delegation_. This allows the framework + to set up a global, shared event listener instead of requiring each view to + do it manually. For example, instead of each view registering its own + `mousedown` listener on its associated element, Ember sets up a `mousedown` + listener on the `body`. + + If a `mousedown` event occurs, Ember will look at the target of the event and + start walking up the DOM node tree, finding corresponding views and invoking + their `mouseDown` method as it goes. + + `Ember.Application` has a number of default events that it listens for, as + well as a mapping from lowercase events to camel-cased view method names. For + example, the `keypress` event causes the `keyPress` method on the view to be + called, the `dblclick` event causes `doubleClick` to be called, and so on. + + If there is a bubbling browser event that Ember does not listen for by + default, you can specify custom events and their corresponding view method + names by setting the application's `customEvents` property: + + ```javascript + let App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: 'paste' + } + }); + ``` + + To prevent Ember from setting up a listener for a default event, + specify the event name with a `null` value in the `customEvents` + property: + + ```javascript + let App = Ember.Application.create({ + customEvents: { + // prevent listeners for mouseenter/mouseleave events + mouseenter: null, + mouseleave: null + } + }); + ``` + + By default, the application sets up these event listeners on the document + body. However, in cases where you are embedding an Ember application inside + an existing page, you may want it to set up the listeners on an element + inside the body. + + For example, if only events inside a DOM element with the ID of `ember-app` + should be delegated, set your application's `rootElement` property: + + ```javascript + let App = Ember.Application.create({ + rootElement: '#ember-app' + }); + ``` + + The `rootElement` can be either a DOM element or a jQuery-compatible selector + string. Note that *views appended to the DOM outside the root element will + not receive events.* If you specify a custom root element, make sure you only + append views inside it! + + To learn more about the events Ember components use, see + [components/handling-events](https://guides.emberjs.com/v2.6.0/components/handling-events/#toc_event-names). + + ### Initializers + + Libraries on top of Ember can add initializers, like so: + + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + + initialize: function(application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + + Initializers provide an opportunity to access the internal registry, which + organizes the different components of an Ember application. Additionally + they provide a chance to access the instantiated application. Beyond + being used for libraries, initializers are also a great way to organize + dependency injection or setup in your own application. + + ### Routing + + In addition to creating your application's router, `Ember.Application` is + also responsible for telling the router when to start routing. Transitions + between routes can be logged with the `LOG_TRANSITIONS` flag, and more + detailed intra-transition logging can be logged with + the `LOG_TRANSITIONS_INTERNAL` flag: + + ```javascript + let App = Ember.Application.create({ + LOG_TRANSITIONS: true, // basic logging of successful transitions + LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps + }); + ``` + + By default, the router will begin trying to translate the current URL into + application state once the browser emits the `DOMContentReady` event. If you + need to defer routing, you can call the application's `deferReadiness()` + method. Once routing can begin, call the `advanceReadiness()` method. + + If there is any setup required before routing begins, you can implement a + `ready()` method on your app that will be invoked immediately before routing + begins. + + @class Application @namespace Ember + @extends Ember.Engine + @uses RegistryProxyMixin @public */ - exports.default = { + + var Application = _emberApplicationSystemEngine.default.extend({ /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.log('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method log - @for Ember.Logger - @param {*} arguments - @public + The root DOM element of the Application. This can be specified as an + element or a + [jQuery-compatible selector string](http://api.jquery.com/category/selectors/). + This is the element that will be passed to the Application's, + `eventDispatcher`, which sets up the listeners for event delegation. Every + view in your application should be a child of the element you specify here. + @property rootElement + @type DOMElement + @default 'body' + @public */ - log: consoleMethod('log') || K, + rootElement: 'body', /** - Prints the arguments to the console with a warning icon. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - Ember.Logger.warn('Something happened!'); - // "Something happened!" will be printed to the console with a warning icon. - ``` - @method warn - @for Ember.Logger - @param {*} arguments - @public + The `Ember.EventDispatcher` responsible for delegating events to this + application's views. + The event dispatcher is created by the application at initialization time + and sets up event listeners on the DOM element described by the + application's `rootElement` property. + See the documentation for `Ember.EventDispatcher` for more information. + @property eventDispatcher + @type Ember.EventDispatcher + @default null + @public */ - warn: consoleMethod('warn') || K, + eventDispatcher: null, /** - Prints the arguments to the console with an error icon, red text and a stack trace. - You can pass as many arguments as you want and they will be joined together with a space. + The DOM events for which the event dispatcher should listen. + By default, the application's `Ember.EventDispatcher` listens + for a set of standard DOM events, such as `mousedown` and + `keyup`, and delegates them to your application's `Ember.View` + instances. + If you would like additional bubbling events to be delegated to your + views, set your `Ember.Application`'s `customEvents` property + to a hash containing the DOM event name as the key and the + corresponding view method name as the value. Setting an event to + a value of `null` will prevent a default event listener from being + added for that event. + To add new events to be listened to: ```javascript - Ember.Logger.error('Danger! Danger!'); - // "Danger! Danger!" will be printed to the console in red text. + let App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: 'paste' + } + }); ``` - @method error - @for Ember.Logger - @param {*} arguments - @public - */ - error: consoleMethod('error') || K, - - /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. + To prevent default events from being listened to: ```javascript - var foo = 1; - Ember.Logger.info('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console + let App = Ember.Application.create({ + customEvents: { + // remove support for mouseenter / mouseleave events + mouseenter: null, + mouseleave: null + } + }); ``` - @method info - @for Ember.Logger - @param {*} arguments - @public + @property customEvents + @type Object + @default null + @public */ - info: consoleMethod('info') || K, + customEvents: null, /** - Logs the arguments to the console in blue text. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.debug('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method debug - @for Ember.Logger - @param {*} arguments - @public + Whether the application should automatically start routing and render + templates to the `rootElement` on DOM ready. While default by true, + other environments such as FastBoot or a testing harness can set this + property to `false` and control the precise timing and behavior of the boot + process. + @property autoboot + @type Boolean + @default true + @private */ - debug: consoleMethod('debug') || consoleMethod('info') || K, + autoboot: true, /** - If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. + Whether the application should be configured for the legacy "globals mode". + Under this mode, the Application object serves as a global namespace for all + classes. ```javascript - Ember.Logger.assert(true); // undefined - Ember.Logger.assert(true === false); // Throws an Assertion failed error. - Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message. + let App = Ember.Application.create({ + ... + }); + App.Router.reopen({ + location: 'none' + }); + App.Router.map({ + ... + }); + App.MyComponent = Ember.Component.extend({ + ... + }); ``` - @method assert - @for Ember.Logger - @param {Boolean} bool Value to test - @param {String} message Assertion message on failed - @public + This flag also exposes other internal APIs that assumes the existence of + a special "default instance", like `App.__container__.lookup(...)`. + This option is currently not configurable, its value is derived from + the `autoboot` flag – disabling `autoboot` also implies opting-out of + globals mode support, although they are ultimately orthogonal concerns. + Some of the global modes features are already deprecated in 1.x. The + existence of this flag is to untangle the globals mode code paths from + the autoboot code paths, so that these legacy features can be reviewed + for deprecation/removal separately. + Forcing the (autoboot=true, _globalsMode=false) here and running the tests + would reveal all the places where we are still relying on these legacy + behavior internally (mostly just tests). + @property _globalsMode + @type Boolean + @default true + @private */ - assert: consoleMethod('assert') || assertPolyfill - }; -}); -enifed('ember-debug/deprecate', ['exports', 'ember-metal', 'ember-console', 'ember-environment', 'ember-debug/handlers'], function (exports, _emberMetal, _emberConsole, _emberEnvironment, _emberDebugHandlers) { - /*global __fail__*/ + _globalsMode: true, - 'use strict'; + init: function (options) { + this._super.apply(this, arguments); - exports.registerHandler = registerHandler; - exports.default = deprecate; + if (!this.$) { + this.$ = _emberViews.jQuery; + } - function registerHandler(handler) { - _emberDebugHandlers.registerHandler('deprecate', handler); - } + registerLibraries(); + _emberMetal.runInDebug(function () { + return logLibraryVersions(); + }); - function formatMessage(_message, options) { - var message = _message; + // Start off the number of deferrals at 1. This will be decremented by + // the Application's own `boot` method. + this._readinessDeferrals = 1; + this._booted = false; - if (options && options.id) { - message = message + (' [deprecation id: ' + options.id + ']'); - } + this.autoboot = this._globalsMode = !!this.autoboot; - if (options && options.url) { - message += ' See ' + options.url + ' for more details.'; - } + if (this._globalsMode) { + this._prepareForGlobalsMode(); + } - return message; - } + if (this.autoboot) { + this.waitForDOMReady(); + } + }, - registerHandler(function logDeprecationToConsole(message, options) { - var updatedMessage = formatMessage(message, options); + /** + Create an ApplicationInstance for this application. + @private + @method buildInstance + @return {Ember.ApplicationInstance} the application instance + */ + buildInstance: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage); - }); + options.base = this; + options.application = this; + return _emberApplicationSystemApplicationInstance.default.create(options); + }, - var captureErrorForStack = undefined; + /** + Enable the legacy globals mode by allowing this application to act + as a global namespace. See the docs on the `_globalsMode` property + for details. + Most of these features are already deprecated in 1.x, so we can + stop using them internally and try to remove them. + @private + @method _prepareForGlobalsMode + */ + _prepareForGlobalsMode: function () { + // Create subclass of Ember.Router for this Application instance. + // This is to ensure that someone reopening `App.Router` does not + // tamper with the default `Ember.Router`. + this.Router = (this.Router || _emberRouting.Router).extend(); - if (new Error().stack) { - captureErrorForStack = function () { - return new Error(); - }; - } else { - captureErrorForStack = function () { - try { - __fail__.fail(); - } catch (e) { - return e; + this._buildDeprecatedInstance(); + }, + + /* + Build the deprecated instance for legacy globals mode support. + Called when creating and resetting the application. + This is orthogonal to autoboot: the deprecated instance needs to + be created at Application construction (not boot) time to expose + App.__container__. If autoboot sees that this instance exists, + it will continue booting it to avoid doing unncessary work (as + opposed to building a new instance at boot time), but they are + otherwise unrelated. + @private + @method _buildDeprecatedInstance + */ + _buildDeprecatedInstance: function () { + // Build a default instance + var instance = this.buildInstance(); + + // Legacy support for App.__container__ and other global methods + // on App that rely on a single, default instance. + this.__deprecatedInstance__ = instance; + this.__container__ = instance.__container__; + }, + + /** + Automatically kick-off the boot process for the application once the + DOM has become ready. + The initialization itself is scheduled on the actions queue which + ensures that code-loading finishes before booting. + If you are asynchronously loading code, you should call `deferReadiness()` + to defer booting, and then call `advanceReadiness()` once all of your code + has finished loading. + @private + @method waitForDOMReady + */ + waitForDOMReady: function () { + if (!this.$ || this.$.isReady) { + _emberMetal.run.schedule('actions', this, 'domReady'); + } else { + this.$().ready(_emberMetal.run.bind(this, 'domReady')); } - }; - } + }, - registerHandler(function logDeprecationStackTrace(message, options, next) { - if (_emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION) { - var stackStr = ''; - var error = captureErrorForStack(); - var stack = undefined; + /** + This is the autoboot flow: + 1. Boot the app by calling `this.boot()` + 2. Create an instance (or use the `__deprecatedInstance__` in globals mode) + 3. Boot the instance by calling `instance.boot()` + 4. Invoke the `App.ready()` callback + 5. Kick-off routing on the instance + Ideally, this is all we would need to do: + ```javascript + _autoBoot() { + this.boot().then(() => { + let instance = (this._globalsMode) ? this.__deprecatedInstance__ : this.buildInstance(); + return instance.boot(); + }).then((instance) => { + App.ready(); + instance.startRouting(); + }); + } + ``` + Unfortunately, we cannot actually write this because we need to participate + in the "synchronous" boot process. While the code above would work fine on + the initial boot (i.e. DOM ready), when `App.reset()` is called, we need to + boot a new instance synchronously (see the documentation on `_bootSync()` + for details). + Because of this restriction, the actual logic of this method is located + inside `didBecomeReady()`. + @private + @method domReady + */ + domReady: function () { + if (this.isDestroyed) { + return; + } - if (error.stack) { - if (error['arguments']) { - // Chrome - stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); - stack.shift(); - } else { - // Firefox - stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); - } + this._bootSync(); - stackStr = '\n ' + stack.slice(2).join('\n '); + // Continues to `didBecomeReady` + }, + + /** + Use this to defer readiness until some condition is true. + Example: + ```javascript + let App = Ember.Application.create(); + App.deferReadiness(); + // Ember.$ is a reference to the jQuery object/function + Ember.$.getJSON('/auth-token', function(token) { + App.token = token; + App.advanceReadiness(); + }); + ``` + This allows you to perform asynchronous setup logic and defer + booting your application until the setup has finished. + However, if the setup requires a loading UI, it might be better + to use the router for this purpose. + @method deferReadiness + @public + */ + deferReadiness: function () { + _emberMetal.assert('You must call deferReadiness on an instance of Ember.Application', this instanceof Application); + _emberMetal.assert('You cannot defer readiness since the `ready()` hook has already been called.', this._readinessDeferrals > 0); + this._readinessDeferrals++; + }, + + /** + Call `advanceReadiness` after any asynchronous setup logic has completed. + Each call to `deferReadiness` must be matched by a call to `advanceReadiness` + or the application will never become ready and routing will not begin. + @method advanceReadiness + @see {Ember.Application#deferReadiness} + @public + */ + advanceReadiness: function () { + _emberMetal.assert('You must call advanceReadiness on an instance of Ember.Application', this instanceof Application); + this._readinessDeferrals--; + + if (this._readinessDeferrals === 0) { + _emberMetal.run.once(this, this.didBecomeReady); } + }, - var updatedMessage = formatMessage(message, options); + /** + Initialize the application and return a promise that resolves with the `Ember.Application` + object when the boot process is complete. + Run any application initializers and run the application load hook. These hooks may + choose to defer readiness. For example, an authentication hook might want to defer + readiness until the auth token has been retrieved. + By default, this method is called automatically on "DOM ready"; however, if autoboot + is disabled, this is automatically called when the first application instance is + created via `visit`. + @private + @method boot + @return {Promise} + */ + boot: function () { + if (this._bootPromise) { + return this._bootPromise; + } - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage + stackStr); - } else { - next.apply(undefined, arguments); - } - }); + try { + this._bootSync(); + } catch (_) { + // Ignore th error: in the asynchronous boot path, the error is already reflected + // in the promise rejection + } - registerHandler(function raiseOnDeprecation(message, options, next) { - if (_emberEnvironment.ENV.RAISE_ON_DEPRECATION) { - var updatedMessage = formatMessage(message); + return this._bootPromise; + }, - throw new _emberMetal.Error(updatedMessage); - } else { - next.apply(undefined, arguments); - } - }); + /** + Unfortunately, a lot of existing code assumes the booting process is + "synchronous". Specifically, a lot of tests assumes the last call to + `app.advanceReadiness()` or `app.reset()` will result in the app being + fully-booted when the current runloop completes. + We would like new code (like the `visit` API) to stop making this assumption, + so we created the asynchronous version above that returns a promise. But until + we have migrated all the code, we would have to expose this method for use + *internally* in places where we need to boot an app "synchronously". + @private + */ + _bootSync: function () { + if (this._booted) { + return; + } - var missingOptionsDeprecation = 'When calling `Ember.deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; - exports.missingOptionsDeprecation = missingOptionsDeprecation; - var missingOptionsIdDeprecation = 'When calling `Ember.deprecate` you must provide `id` in options.'; - exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; - var missingOptionsUntilDeprecation = 'When calling `Ember.deprecate` you must provide `until` in options.'; + // Even though this returns synchronously, we still need to make sure the + // boot promise exists for book-keeping purposes: if anything went wrong in + // the boot process, we need to store the error as a rejection on the boot + // promise so that a future caller of `boot()` can tell what failed. + var defer = this._bootResolver = new _emberRuntime.RSVP.defer(); + this._bootPromise = defer.promise; - exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation; - /** - @module ember - @submodule ember-debug - */ + try { + this.runInitializers(); + _emberRuntime.runLoadHooks('application', this); + this.advanceReadiness(); + // Continues to `didBecomeReady` + } catch (error) { + // For the asynchronous boot path + defer.reject(error); - /** - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only). - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method deprecate - @param {String} message A description of the deprecation. - @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. - @param {Object} options - @param {String} options.id A unique id for this deprecation. The id can be - used by Ember debugging tools to change the behavior (raise, log or silence) - for that specific deprecation. The id should be namespaced by dots, e.g. - "view.helper.select". - @param {string} options.until The version of Ember when this deprecation - warning will be removed. - @param {String} [options.url] An optional url to the transition guide on the - emberjs.com website. - @for Ember - @public - */ + // For the synchronous boot path + throw error; + } + }, - function deprecate(message, test, options) { - if (!options || !options.id && !options.until) { - deprecate(missingOptionsDeprecation, false, { - id: 'ember-debug.deprecate-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + /** + Reset the application. This is typically used only in tests. It cleans up + the application in the following order: + 1. Deactivate existing routes + 2. Destroy all objects in the container + 3. Create a new application container + 4. Re-route to the existing url + Typical Example: + ```javascript + let App; + run(function() { + App = Ember.Application.create(); }); - } - - if (options && !options.id) { - deprecate(missingOptionsIdDeprecation, false, { - id: 'ember-debug.deprecate-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + module('acceptance test', { + setup: function() { + App.reset(); + } }); - } - - if (options && !options.until) { - deprecate(missingOptionsUntilDeprecation, options && options.until, { - id: 'ember-debug.deprecate-until-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + test('first test', function() { + // App is freshly reset }); - } + test('second test', function() { + // App is again freshly reset + }); + ``` + Advanced Example: + Occasionally you may want to prevent the app from initializing during + setup. This could enable extra configuration, or enable asserting prior + to the app becoming ready. + ```javascript + let App; + run(function() { + App = Ember.Application.create(); + }); + module('acceptance test', { + setup: function() { + run(function() { + App.reset(); + App.deferReadiness(); + }); + } + }); + test('first test', function() { + ok(true, 'something before app is initialized'); + run(function() { + App.advanceReadiness(); + }); + ok(true, 'something after app is initialized'); + }); + ``` + @method reset + @public + */ + reset: function () { + _emberMetal.assert('Calling reset() on instances of `Ember.Application` is not\n supported when globals mode is disabled; call `visit()` to\n create new `Ember.ApplicationInstance`s and dispose them\n via their `destroy()` method instead.', this._globalsMode && this.autoboot); - _emberDebugHandlers.invoke.apply(undefined, ['deprecate'].concat(babelHelpers.slice.call(arguments))); - } -}); -enifed("ember-debug/handlers", ["exports"], function (exports) { - "use strict"; + var instance = this.__deprecatedInstance__; - exports.registerHandler = registerHandler; - exports.invoke = invoke; - var HANDLERS = {}; + this._readinessDeferrals = 1; + this._bootPromise = null; + this._bootResolver = null; + this._booted = false; - exports.HANDLERS = HANDLERS; + function handleReset() { + _emberMetal.run(instance, 'destroy'); + this._buildDeprecatedInstance(); + _emberMetal.run.schedule('actions', this, '_bootSync'); + } - function registerHandler(type, callback) { - var nextHandler = HANDLERS[type] || function () {}; + _emberMetal.run.join(this, handleReset); + }, - HANDLERS[type] = function (message, options) { - callback(message, options, nextHandler); - }; - } + /** + @private + @method didBecomeReady + */ + didBecomeReady: function () { + try { + // TODO: Is this still needed for _globalsMode = false? + if (!_emberMetal.isTesting()) { + // Eagerly name all classes that are already loaded + _emberRuntime.Namespace.processAll(); + _emberRuntime.setNamespaceSearchDisabled(true); + } - function invoke(type, message, test, options) { - if (test) { - return; - } + // See documentation on `_autoboot()` for details + if (this.autoboot) { + var instance = undefined; - var handlerForType = HANDLERS[type]; + if (this._globalsMode) { + // If we already have the __deprecatedInstance__ lying around, boot it to + // avoid unnecessary work + instance = this.__deprecatedInstance__; + } else { + // Otherwise, build an instance and boot it. This is currently unreachable, + // because we forced _globalsMode to === autoboot; but having this branch + // allows us to locally toggle that flag for weeding out legacy globals mode + // dependencies independently + instance = this.buildInstance(); + } - if (!handlerForType) { - return; - } + instance._bootSync(); - if (handlerForType) { - handlerForType(message, options); - } - } -}); -enifed('ember-debug/index', ['exports', 'ember-metal', 'ember-environment', 'ember-console', 'ember-debug/deprecate', 'ember-debug/warn'], function (exports, _emberMetal, _emberEnvironment, _emberConsole, _emberDebugDeprecate, _emberDebugWarn) { - 'use strict'; + // TODO: App.ready() is not called when autoboot is disabled, is this correct? + this.ready(); - exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; + instance.startRouting(); + } - /** - @module ember - @submodule ember-debug - */ + // For the asynchronous boot path + this._bootResolver.resolve(this); - /** - @class Ember - @public - */ + // For the synchronous boot path + this._booted = true; + } catch (error) { + // For the asynchronous boot path + this._bootResolver.reject(error); - /** - Define an assertion that will throw an exception if the condition is not met. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - // Test for truthiness - Ember.assert('Must pass a valid object', obj); - - // Fail unconditionally - Ember.assert('This code path should never be run'); - ``` - - @method assert - @param {String} desc A description of the assertion. This will become - the text of the Error thrown if the assertion fails. - @param {Boolean} test Must be truthy for the assertion to pass. If - falsy, an exception will be thrown. - @public - */ - _emberMetal.setDebugFunction('assert', function assert(desc, test) { - if (!test) { - throw new _emberMetal.Error('Assertion Failed: ' + desc); - } - }); + // For the synchronous boot path + throw error; + } + }, - /** - Display a debug notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.debug('I\'m a debug notice!'); - ``` - - @method debug - @param {String} message A debug message to display. - @public - */ - _emberMetal.setDebugFunction('debug', function debug(message) { - _emberConsole.default.debug('DEBUG: ' + message); - }); + /** + Called when the Application has become ready, immediately before routing + begins. The call will be delayed until the DOM has become ready. + @event ready + @public + */ + ready: function () { + return this; + }, - /** - Display an info notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method info - @private - */ - _emberMetal.setDebugFunction('info', function info() { - _emberConsole.default.info.apply(undefined, arguments); - }); + // This method must be moved to the application instance object + willDestroy: function () { + this._super.apply(this, arguments); + _emberRuntime.setNamespaceSearchDisabled(false); + this._booted = false; + this._bootPromise = null; + this._bootResolver = null; - /** - Alias an old, deprecated method with its new counterpart. - - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only) when the assigned method is called. - - * In a production build, this method is defined as an empty function (NOP). - - ```javascript - Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod); - ``` - - @method deprecateFunc - @param {String} message A description of the deprecation. - @param {Object} [options] The options object for Ember.deprecate. - @param {Function} func The new function called to replace its deprecated counterpart. - @return {Function} A new function that wraps the original function with a deprecation warning - @private - */ - _emberMetal.setDebugFunction('deprecateFunc', function deprecateFunc() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + if (_emberRuntime._loaded.application === this) { + _emberRuntime._loaded.application = undefined; + } - if (args.length === 3) { - var _ret = (function () { - var message = args[0]; - var options = args[1]; - var func = args[2]; + if (this._globalsMode && this.__deprecatedInstance__) { + this.__deprecatedInstance__.destroy(); + } + }, - return { - v: function () { - _emberMetal.deprecate(message, false, options); - return func.apply(this, arguments); - } + /** + Boot a new instance of `Ember.ApplicationInstance` for the current + application and navigate it to the given `url`. Returns a `Promise` that + resolves with the instance when the initial routing and rendering is + complete, or rejects with any error that occured during the boot process. + When `autoboot` is disabled, calling `visit` would first cause the + application to boot, which runs the application initializers. + This method also takes a hash of boot-time configuration options for + customizing the instance's behavior. See the documentation on + `Ember.ApplicationInstance.BootOptions` for details. + `Ember.ApplicationInstance.BootOptions` is an interface class that exists + purely to document the available options; you do not need to construct it + manually. Simply pass a regular JavaScript object containing of the + desired options: + ```javascript + MyApp.visit("/", { location: "none", rootElement: "#container" }); + ``` + ### Supported Scenarios + While the `BootOptions` class exposes a large number of knobs, not all + combinations of them are valid; certain incompatible combinations might + result in unexpected behavior. + For example, booting the instance in the full browser environment + while specifying a foriegn `document` object (e.g. `{ isBrowser: true, + document: iframe.contentDocument }`) does not work correctly today, + largely due to Ember's jQuery dependency. + Currently, there are three officially supported scenarios/configurations. + Usages outside of these scenarios are not guaranteed to work, but please + feel free to file bug reports documenting your experience and any issues + you encountered to help expand support. + #### Browser Applications (Manual Boot) + The setup is largely similar to how Ember works out-of-the-box. Normally, + Ember will boot a default instance for your Application on "DOM ready". + However, you can customize this behavior by disabling `autoboot`. + For example, this allows you to render a miniture demo of your application + into a specific area on your marketing website: + ```javascript + import MyApp from 'my-app'; + $(function() { + let App = MyApp.create({ autoboot: false }); + let options = { + // Override the router's location adapter to prevent it from updating + // the URL in the address bar + location: 'none', + // Override the default `rootElement` on the app to render into a + // specific `div` on the page + rootElement: '#demo' }; - })(); - - if (typeof _ret === 'object') return _ret.v; - } else { - var _ret2 = (function () { - var message = args[0]; - var func = args[1]; - - return { - v: function () { - _emberMetal.deprecate(message); - return func.apply(this, arguments); + // Start the app at the special demo URL + App.visit('/demo', options); + }); + ```` + Or perhaps you might want to boot two instances of your app on the same + page for a split-screen multiplayer experience: + ```javascript + import MyApp from 'my-app'; + $(function() { + let App = MyApp.create({ autoboot: false }); + let sessionId = MyApp.generateSessionID(); + let player1 = App.visit(`/matches/join?name=Player+1&session=${sessionId}`, { rootElement: '#left', location: 'none' }); + let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#right', location: 'none' }); + Promise.all([player1, player2]).then(() => { + // Both apps have completed the initial render + $('#loading').fadeOut(); + }); + }); + ``` + Do note that each app instance maintains their own registry/container, so + they will run in complete isolation by default. + #### Server-Side Rendering (also known as FastBoot) + This setup allows you to run your Ember app in a server environment using + Node.js and render its content into static HTML for SEO purposes. + ```javascript + const HTMLSerializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); + function renderURL(url) { + let dom = new SimpleDOM.Document(); + let rootElement = dom.body; + let options = { isBrowser: false, document: dom, rootElement: rootElement }; + return MyApp.visit(options).then(instance => { + try { + return HTMLSerializer.serialize(rootElement.firstChild); + } finally { + instance.destroy(); } - }; - })(); + }); + } + ``` + In this scenario, because Ember does not have access to a global `document` + object in the Node.js environment, you must provide one explicitly. In practice, + in the non-browser environment, the stand-in `document` object only need to + implement a limited subset of the full DOM API. The `SimpleDOM` library is known + to work. + Since there is no access to jQuery in the non-browser environment, you must also + specify a DOM `Element` object in the same `document` for the `rootElement` option + (as opposed to a selector string like `"body"`). + See the documentation on the `isBrowser`, `document` and `rootElement` properties + on `Ember.ApplicationInstance.BootOptions` for details. + #### Server-Side Resource Discovery + This setup allows you to run the routing layer of your Ember app in a server + environment using Node.js and completely disable rendering. This allows you + to simulate and discover the resources (i.e. AJAX requests) needed to fufill + a given request and eagerly "push" these resources to the client. + ```app/initializers/network-service.js + import BrowserNetworkService from 'app/services/network/browser'; + import NodeNetworkService from 'app/services/network/node'; + // Inject a (hypothetical) service for abstracting all AJAX calls and use + // the appropiate implementaion on the client/server. This also allows the + // server to log all the AJAX calls made during a particular request and use + // that for resource-discovery purpose. + export function initialize(application) { + if (window) { // browser + application.register('service:network', BrowserNetworkService); + } else { // node + application.register('service:network', NodeNetworkService); + } + application.inject('route', 'network', 'service:network'); + }; + export default { + name: 'network-service', + initialize: initialize + }; + ``` + ```app/routes/post.js + import Ember from 'ember'; + // An example of how the (hypothetical) service is used in routes. + export default Ember.Route.extend({ + model(params) { + return this.network.fetch(`/api/posts/${params.post_id}.json`); + }, + afterModel(post) { + if (post.isExternalContent) { + return this.network.fetch(`/api/external/?url=${post.externalURL}`); + } else { + return post; + } + } + }); + ``` + ```javascript + // Finally, put all the pieces together + function discoverResourcesFor(url) { + return MyApp.visit(url, { isBrowser: false, shouldRender: false }).then(instance => { + let networkService = instance.lookup('service:network'); + return networkService.requests; // => { "/api/posts/123.json": "..." } + }); + } + ``` + @public + @method visit + @param url {String} The initial URL to navigate to + @param options {Ember.ApplicationInstance.BootOptions} + @return {Promise} + */ + visit: function (url, options) { + var _this = this; - if (typeof _ret2 === 'object') return _ret2.v; - } - }); + return this.boot().then(function () { + var instance = _this.buildInstance(); - /** - Run a function meant for debugging. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.runInDebug(() => { - Ember.Component.reopen({ - didInsertElement() { - console.log("I'm happy"); - } + return instance.boot(options).then(function () { + return instance.visit(url); + }).catch(function (error) { + _emberMetal.run(instance, 'destroy'); + throw error; + }); }); - }); - ``` - - @method runInDebug - @param {Function} func The function to be executed. - @since 1.5.0 - @public - */ - _emberMetal.setDebugFunction('runInDebug', function runInDebug(func) { - func(); + } }); - _emberMetal.setDebugFunction('debugSeal', function debugSeal(obj) { - Object.seal(obj); + Object.defineProperty(Application.prototype, 'registry', { + configurable: true, + enumerable: false, + get: function () { + return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'Application'); + } }); - _emberMetal.setDebugFunction('debugFreeze', function debugFreeze(obj) { - Object.freeze(obj); + Application.reopenClass({ + /** + This creates a registry with the default Ember naming conventions. + It also configures the registry: + * registered views are created every time they are looked up (they are + not singletons) + * registered templates are not factories; the registered value is + returned directly. + * the router receives the application as its `namespace` property + * all controllers receive the router as their `target` and `controllers` + properties + * all controllers receive the application as their `namespace` property + * the application view receives the application controller as its + `controller` property + * the application view receives the application template as its + `defaultTemplate` property + @method buildRegistry + @static + @param {Ember.Application} namespace the application for which to + build the registry + @return {Ember.Registry} the built registry + @private + */ + buildRegistry: function (application) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var registry = this._super.apply(this, arguments); + + commonSetupRegistry(registry); + + _emberGlimmer.setupApplicationRegistry(registry); + + return registry; + } }); - _emberMetal.setDebugFunction('deprecate', _emberDebugDeprecate.default); + function commonSetupRegistry(registry) { + registry.register('-view-registry:main', { create: function () { + return _emberUtils.dictionary(null); + } }); - _emberMetal.setDebugFunction('warn', _emberDebugWarn.default); + registry.register('route:basic', _emberRouting.Route); + registry.register('event_dispatcher:main', _emberViews.EventDispatcher); - /** - Will call `Ember.warn()` if ENABLE_OPTIONAL_FEATURES or - any specific FEATURES flag is truthy. - - This method is called automatically in debug canary builds. - - @private - @method _warnIfUsingStrippedFeatureFlags - @return {void} - */ + registry.injection('router:main', 'namespace', 'application:main'); - function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featuresWereStripped) { - if (featuresWereStripped) { - _emberMetal.warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + registry.register('location:auto', _emberRouting.AutoLocation); + registry.register('location:hash', _emberRouting.HashLocation); + registry.register('location:history', _emberRouting.HistoryLocation); + registry.register('location:none', _emberRouting.NoneLocation); - var keys = Object.keys(FEATURES || {}); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key === 'isEnabled' || !(key in knownFeatures)) { - continue; - } + registry.register(_container.privatize(_templateObject), _emberRouting.BucketCache); - _emberMetal.warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); - } + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + registry.register('service:router', _emberRouting.RouterService); + registry.injection('service:router', 'router', 'router:main'); } } - if (!_emberMetal.isTesting()) { - (function () { - // Complain if they're using FEATURE flags in builds other than canary - _emberMetal.FEATURES['features-stripped-test'] = true; - var featuresWereStripped = true; + function registerLibraries() { + if (!librariesRegistered) { + librariesRegistered = true; - if (false) { - featuresWereStripped = false; + if (_emberEnvironment.environment.hasDOM && typeof _emberViews.jQuery === 'function') { + _emberMetal.libraries.registerCoreLibrary('jQuery', _emberViews.jQuery().jquery); } + } + } - delete _emberMetal.FEATURES['features-stripped-test']; - _warnIfUsingStrippedFeatureFlags(_emberEnvironment.ENV.FEATURES, _emberMetal.DEFAULT_FEATURES, featuresWereStripped); + function logLibraryVersions() { + var _this2 = this; - // Inform the developer about the Ember Inspector if not installed. - var isFirefox = _emberEnvironment.environment.isFirefox; - var isChrome = _emberEnvironment.environment.isChrome; + _emberMetal.runInDebug(function () { + if (_emberEnvironment.ENV.LOG_VERSION) { + // we only need to see this once per Application#init + _emberEnvironment.ENV.LOG_VERSION = false; + var libs = _emberMetal.libraries._registry; - if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { - window.addEventListener('load', function () { - if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) { - var downloadURL; + var nameLengths = libs.map(function (item) { + return _emberMetal.get(item, 'name.length'); + }); - if (isChrome) { - downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'; - } else if (isFirefox) { - downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; - } + var maxNameLength = Math.max.apply(_this2, nameLengths); - _emberMetal.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); - } - }, false); + _emberMetal.debug('-------------------------------'); + for (var i = 0; i < libs.length; i++) { + var lib = libs[i]; + var spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); + _emberMetal.debug([lib.name, spaces, ' : ', lib.version].join('')); + } + _emberMetal.debug('-------------------------------'); } - })(); + }); } - /** - @public - @class Ember.Debug - */ - _emberMetal.default.Debug = {}; + exports.default = Application; +}); +enifed('ember-application/system/engine-instance', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'container', 'ember-application/system/engine-parent'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _container, _emberApplicationSystemEngineParent) { /** - Allows for runtime registration of handler functions that override the default deprecation behavior. - Deprecations are invoked by calls to [Ember.deprecate](http://emberjs.com/api/classes/Ember.html#method_deprecate). - The following example demonstrates its usage by registering a handler that throws an error if the - message contains the word "should", otherwise defers to the default handler. - - ```javascript - Ember.Debug.registerDeprecationHandler((message, options, next) => { - if (message.indexOf('should') !== -1) { - throw new Error(`Deprecation message with should: ${message}`); - } else { - // defer to whatever handler was registered before this one - next(message, options); - } - }); - ``` - - The handler function takes the following arguments: - -
      -
    • message - The message received from the deprecation call.
    • -
    • options - An object passed in with the deprecation call containing additional information including:
    • -
        -
      • id - An id of the deprecation in the form of package-name.specific-deprecation.
      • -
      • until - The Ember version number the feature and deprecation will be removed in.
      • -
      -
    • next - A function that calls into the previously registered handler.
    • -
    - - @public - @static - @method registerDeprecationHandler - @param handler {Function} A function to handle deprecation calls. - @since 2.1.0 + @module ember + @submodule ember-application */ - _emberMetal.default.Debug.registerDeprecationHandler = _emberDebugDeprecate.registerHandler; + + 'use strict'; + + var _EmberObject$extend; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + /** - Allows for runtime registration of handler functions that override the default warning behavior. - Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). - The following example demonstrates its usage by registering a handler that does nothing overriding Ember's - default warning behavior. - - ```javascript - // next is not called, so no warnings get the default behavior - Ember.Debug.registerWarnHandler(() => {}); - ``` - - The handler function takes the following arguments: - -
      -
    • message - The message received from the warn call.
    • -
    • options - An object passed in with the warn call containing additional information including:
    • -
        -
      • id - An id of the warning in the form of package-name.specific-warning.
      • -
      -
    • next - A function that calls into the previously registered handler.
    • -
    + The `EngineInstance` encapsulates all of the stateful aspects of a + running `Engine`. @public - @static - @method registerWarnHandler - @param handler {Function} A function to handle warnings. - @since 2.1.0 + @class Ember.EngineInstance + @extends Ember.Object + @uses RegistryProxyMixin + @uses ContainerProxyMixin */ - _emberMetal.default.Debug.registerWarnHandler = _emberDebugWarn.registerHandler; - /* - We are transitioning away from `ember.js` to `ember.debug.js` to make - it much clearer that it is only for local development purposes. - - This flag value is changed by the tooling (by a simple string replacement) - so that if `ember.js` (which must be output for backwards compat reasons) is - used a nice helpful warning message will be printed out. - */ - var runningNonEmberDebugJS = true; - exports.runningNonEmberDebugJS = runningNonEmberDebugJS; - if (runningNonEmberDebugJS) { - _emberMetal.warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); - } -}); -// reexports -enifed('ember-debug/warn', ['exports', 'ember-console', 'ember-metal', 'ember-debug/handlers'], function (exports, _emberConsole, _emberMetal, _emberDebugHandlers) { - 'use strict'; + var EngineInstance = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, (_EmberObject$extend = { + /** + The base `Engine` for which this is an instance. + @property {Ember.Engine} engine + @private + */ + base: null, - exports.registerHandler = registerHandler; - exports.default = warn; + init: function () { + this._super.apply(this, arguments); - function registerHandler(handler) { - _emberDebugHandlers.registerHandler('warn', handler); - } + _emberUtils.guidFor(this); - registerHandler(function logWarning(message, options) { - _emberConsole.default.warn('WARNING: ' + message); - if ('trace' in _emberConsole.default) { - _emberConsole.default.trace(); - } - }); + var base = this.base; - var missingOptionsDeprecation = 'When calling `Ember.warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; - exports.missingOptionsDeprecation = missingOptionsDeprecation; - var missingOptionsIdDeprecation = 'When calling `Ember.warn` you must provide `id` in options.'; + if (!base) { + base = this.application; + this.base = base; + } - exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; - /** - @module ember - @submodule ember-debug - */ + // Create a per-instance registry that will use the application's registry + // as a fallback for resolving registrations. + var registry = this.__registry__ = new _container.Registry({ + fallback: base.__registry__ + }); - /** - Display a warning with the provided message. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method warn - @param {String} message A warning to display. - @param {Boolean} test An optional boolean. If falsy, the warning - will be displayed. - @param {Object} options An object that can be used to pass a unique - `id` for this warning. The `id` can be used by Ember debugging tools - to change the behavior (raise, log, or silence) for that specific warning. - The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" - @for Ember - @public - */ + // Create a per-instance container from the instance's registry + this.__container__ = registry.container({ owner: this }); - function warn(message, test, options) { - if (!options) { - _emberMetal.deprecate(missingOptionsDeprecation, false, { - id: 'ember-debug.warn-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + this._booted = false; + }, - if (options && !options.id) { - _emberMetal.deprecate(missingOptionsIdDeprecation, false, { - id: 'ember-debug.warn-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + /** + Initialize the `Ember.EngineInstance` and return a promise that resolves + with the instance itself when the boot process is complete. + The primary task here is to run any registered instance initializers. + See the documentation on `BootOptions` for the options it takes. + @private + @method boot + @param options {Object} + @return {Promise} + */ + boot: function (options) { + var _this = this; + + if (this._bootPromise) { + return this._bootPromise; + } + + this._bootPromise = new _emberRuntime.RSVP.Promise(function (resolve) { + return resolve(_this._bootSync(options)); }); - } - _emberDebugHandlers.invoke.apply(undefined, ['warn'].concat(babelHelpers.slice.call(arguments))); - } -}); -enifed('ember-environment/global', ['exports'], function (exports) { - /* globals global, window, self, mainContext */ + return this._bootPromise; + }, - // from lodash to catch fake globals - 'use strict'; + /** + Unfortunately, a lot of existing code assumes booting an instance is + synchronous – specifically, a lot of tests assume the last call to + `app.advanceReadiness()` or `app.reset()` will result in a new instance + being fully-booted when the current runloop completes. + We would like new code (like the `visit` API) to stop making this + assumption, so we created the asynchronous version above that returns a + promise. But until we have migrated all the code, we would have to expose + this method for use *internally* in places where we need to boot an instance + synchronously. + @private + */ + _bootSync: function (options) { + if (this._booted) { + return this; + } - function checkGlobal(value) { - return value && value.Object === Object ? value : undefined; - } + _emberMetal.assert('An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.', _emberApplicationSystemEngineParent.getEngineParent(this)); - // element ids can ruin global miss checks - function checkElementIdShadowing(value) { - return value && value.nodeType === undefined ? value : undefined; - } + this.cloneParentDependencies(); - // export real global - exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper - new Function('return this')(); - // eval outside of strict mode -}); -enifed('ember-environment/index', ['exports', 'ember-environment/global', 'ember-environment/utils'], function (exports, _emberEnvironmentGlobal, _emberEnvironmentUtils) { - /* globals module */ - 'use strict'; + this.setupRegistry(options); - /** - 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 - backwards compatibility with earlier versions of Ember). The `EmberENV` - hash must be created before loading Ember. - - @class EmberENV - @type Object - @public - */ - var ENV = typeof _emberEnvironmentGlobal.default.EmberENV === 'object' && _emberEnvironmentGlobal.default.EmberENV || typeof _emberEnvironmentGlobal.default.ENV === 'object' && _emberEnvironmentGlobal.default.ENV || {}; + this.base.runInstanceInitializers(this); - exports.ENV = ENV; - // ENABLE_ALL_FEATURES was documented, but you can't actually enable non optional features. - if (ENV.ENABLE_ALL_FEATURES) { - ENV.ENABLE_OPTIONAL_FEATURES = true; - } + this._booted = true; - /** - Determines whether Ember should add to `Array`, `Function`, and `String` - native object prototypes, a few extra methods in order to provide a more - friendly API. - - We generally recommend leaving this option set to true however, if you need - to turn it off, you can add the configuration property - `EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`. - - Note, when disabled (the default configuration for Ember Addons), you will - instead have to access all methods and functions from the Ember - namespace. - - @property EXTEND_PROTOTYPES - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.EXTEND_PROTOTYPES = _emberEnvironmentUtils.normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); + return this; + }, - /** - The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log - a full stack trace during deprecation warnings. - - @property LOG_STACKTRACE_ON_DEPRECATION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_STACKTRACE_ON_DEPRECATION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); + setupRegistry: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? this.__container__.lookup('-environment:main') : arguments[0]; - /** - The `LOG_VERSION` property, when true, tells Ember to log versions of all - dependent libraries in use. - - @property LOG_VERSION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_VERSION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_VERSION); + this.constructor.setupRegistry(this.__registry__, options); + }, - // default false - ENV.MODEL_FACTORY_INJECTIONS = _emberEnvironmentUtils.defaultFalse(ENV.MODEL_FACTORY_INJECTIONS); + /** + Unregister a factory. + Overrides `RegistryProxy#unregister` in order to clear any cached instances + of the unregistered factory. + @public + @method unregister + @param {String} fullName + */ + unregister: function (fullName) { + this.__container__.reset(fullName); + this._super.apply(this, arguments); + }, - /** - Debug parameter you can turn on. This will log all bindings that fire to - the console. This should be disabled in production code. Note that you - can also enable this from the console or temporarily. - - @property LOG_BINDINGS - @for EmberENV - @type Boolean - @default false - @public - */ - ENV.LOG_BINDINGS = _emberEnvironmentUtils.defaultFalse(ENV.LOG_BINDINGS); + /** + @private + */ + willDestroy: function () { + this._super.apply(this, arguments); + _emberMetal.run(this.__container__, 'destroy'); + }, - ENV.RAISE_ON_DEPRECATION = _emberEnvironmentUtils.defaultFalse(ENV.RAISE_ON_DEPRECATION); + /** + Build a new `Ember.EngineInstance` that's a child of this instance. + Engines must be registered by name with their parent engine + (or application). + @private + @method buildChildEngineInstance + @param name {String} the registered name of the engine. + @param options {Object} options provided to the engine instance. + @return {Ember.EngineInstance,Error} + */ + buildChildEngineInstance: function (name) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - // check if window exists and actually is the global - var hasDOM = typeof window !== 'undefined' && window === _emberEnvironmentGlobal.default && window.document && window.document.createElement && !ENV.disableBrowserEnvironment; // is this a public thing? + var Engine = this.lookup('engine:' + name); - // legacy imports/exports/lookup stuff (should we keep this??) - var originalContext = _emberEnvironmentGlobal.default.Ember || {}; + if (!Engine) { + throw new _emberMetal.Error('You attempted to mount the engine \'' + name + '\', but it is not registered with its parent.'); + } - var context = { - // import jQuery - imports: originalContext.imports || _emberEnvironmentGlobal.default, - // export Ember - exports: originalContext.exports || _emberEnvironmentGlobal.default, - // search for Namespaces - lookup: originalContext.lookup || _emberEnvironmentGlobal.default - }; + var engineInstance = Engine.buildInstance(options); - exports.context = context; - // TODO: cleanup single source of truth issues with this stuff - var environment = hasDOM ? { - hasDOM: true, - isChrome: !!window.chrome && !window.opera, - isFirefox: typeof InstallTrigger !== 'undefined', - isPhantom: !!window.callPhantom, - location: window.location, - history: window.history, - userAgent: window.navigator.userAgent, - window: window - } : { - hasDOM: false, - isChrome: false, - isFirefox: false, - isPhantom: false, - location: null, - history: null, - userAgent: 'Lynx (textmode)', - window: null - }; - exports.environment = environment; -}); -enifed("ember-environment/utils", ["exports"], function (exports) { - "use strict"; + _emberApplicationSystemEngineParent.setEngineParent(engineInstance, this); - exports.defaultTrue = defaultTrue; - exports.defaultFalse = defaultFalse; - exports.normalizeExtendPrototypes = normalizeExtendPrototypes; + return engineInstance; + }, - function defaultTrue(v) { - return v === false ? false : true; - } + /** + Clone dependencies shared between an engine instance and its parent. + @private + @method cloneParentDependencies + */ + cloneParentDependencies: function () { + var _this2 = this; - function defaultFalse(v) { - return v === true ? true : false; - } + var parent = _emberApplicationSystemEngineParent.getEngineParent(this); - function normalizeExtendPrototypes(obj) { - if (obj === false) { - return { String: false, Array: false, Function: false }; - } else if (!obj || obj === true) { - return { String: true, Array: true, Function: true }; - } else { - return { - String: defaultTrue(obj.String), - Array: defaultTrue(obj.Array), - Function: defaultTrue(obj.Function) - }; + var registrations = ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment']; + + registrations.forEach(function (key) { + return _this2.register(key, parent.resolveRegistration(key)); + }); + + var env = parent.lookup('-environment:main'); + this.register('-environment:main', env, { instantiate: false }); + + var singletons = ['router:main', _container.privatize(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert')]; + + singletons.forEach(function (key) { + return _this2.register(key, parent.lookup(key), { instantiate: false }); + }); + + this.inject('view', '_environment', '-environment:main'); + this.inject('route', '_environment', '-environment:main'); } - } + + }, _EmberObject$extend[_container.FACTORY_FOR] = function (fullName, options) { + return this.__container__[_container.FACTORY_FOR](fullName, options); + }, _EmberObject$extend[_container.LOOKUP_FACTORY] = function (fullName, options) { + return this.__container__[_container.LOOKUP_FACTORY](fullName, options); + }, _EmberObject$extend)); + + EngineInstance.reopenClass({ + /** + @private + @method setupRegistry + @param {Registry} registry + @param {BootOptions} options + */ + setupRegistry: function (registry, options) { + // when no options/environment is present, do nothing + if (!options) { + return; + } + + registry.injection('view', '_environment', '-environment:main'); + registry.injection('route', '_environment', '-environment:main'); + + if (options.isInteractive) { + registry.injection('view', 'renderer', 'renderer:-dom'); + registry.injection('component', 'renderer', 'renderer:-dom'); + } else { + registry.injection('view', 'renderer', 'renderer:-inert'); + registry.injection('component', 'renderer', 'renderer:-inert'); + } + } + }); + + exports.default = EngineInstance; }); -enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { +enifed('ember-application/system/engine-parent', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; + exports.getEngineParent = getEngineParent; + exports.setEngineParent = setEngineParent; + var ENGINE_PARENT = _emberUtils.symbol('ENGINE_PARENT'); + + exports.ENGINE_PARENT = ENGINE_PARENT; /** - @module ember - @submodule ember-extension-support + `getEngineParent` retrieves an engine instance's parent instance. + + @method getEngineParent + @param {EngineInstance} engine An engine instance. + @return {EngineInstance} The parent engine instance. + @for Ember + @public */ + function getEngineParent(engine) { + return engine[ENGINE_PARENT]; + } + /** - The `ContainerDebugAdapter` helps the container and resolver interface - with tools that debug Ember such as the - [Ember Extension](https://github.com/tildeio/ember-extension) - for Chrome and Firefox. - - This class can be extended by a custom resolver implementer - to override some of the methods with library-specific code. - - The methods likely to be overridden are: - - * `canCatalogEntriesByType` - * `catalogEntriesByType` + `setEngineParent` sets an engine instance's parent instance. - The adapter will need to be registered - in the application's container as `container-debug-adapter:main`. + @method setEngineParent + @param {EngineInstance} engine An engine instance. + @param {EngineInstance} parent The parent engine instance. + @private + */ + + function setEngineParent(engine, parent) { + engine[ENGINE_PARENT] = parent; + } +}); +enifed('ember-application/system/engine', ['exports', 'ember-utils', 'ember-runtime', 'container', 'dag-map', 'ember-metal', 'ember-application/system/resolver', 'ember-application/system/engine-instance', 'ember-routing', 'ember-extension-support', 'ember-views', 'ember-glimmer'], function (exports, _emberUtils, _emberRuntime, _container, _dagMap, _emberMetal, _emberApplicationSystemResolver, _emberApplicationSystemEngineInstance, _emberRouting, _emberExtensionSupport, _emberViews, _emberGlimmer) { + /** + @module ember + @submodule ember-application + */ + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + + function props(obj) { + var properties = []; + + for (var key in obj) { + properties.push(key); + } + + return properties; + } + + /** + The `Engine` class contains core functionality for both applications and + engines. - Example: + Each engine manages a registry that's used for dependency injection and + exposed through `RegistryProxy`. - ```javascript - Application.initializer({ - name: "containerDebugAdapter", + Engines also manage initializers and instance initializers. - initialize(application) { - application.register('container-debug-adapter:main', require('app/container-debug-adapter')); - } - }); - ``` + Engines can spawn `EngineInstance` instances via `buildInstance()`. - @class ContainerDebugAdapter + @class Engine @namespace Ember - @extends Ember.Object - @since 1.5.0 + @extends Ember.Namespace + @uses RegistryProxy @public */ - exports.default = _emberRuntime.Object.extend({ + var Engine = _emberRuntime.Namespace.extend(_emberRuntime.RegistryProxyMixin, { + init: function () { + this._super.apply(this, arguments); + + this.buildRegistry(); + }, + /** - The resolver instance of the application - being debugged. This property will be injected - on creation. - @property resolver - @default null - @public + A private flag indicating whether an engine's initializers have run yet. + @private + @property _initializersRan */ - resolver: null, + _initializersRan: false, /** - Returns true if it is possible to catalog a list of available - classes in the resolver for a given type. - @method canCatalogEntriesByType - @param {String} type The type. e.g. "model", "controller", "route". - @return {boolean} whether a list is available for this type. - @public + Ensure that initializers are run once, and only once, per engine. + @private + @method ensureInitializers */ - canCatalogEntriesByType: function (type) { - if (type === 'model' || type === 'template') { - return false; + ensureInitializers: function () { + if (!this._initializersRan) { + this.runInitializers(); + this._initializersRan = true; } - - return true; }, /** - Returns the available classes a given type. - @method catalogEntriesByType - @param {String} type The type. e.g. "model", "controller", "route". - @return {Array} An array of strings. - @public + Create an EngineInstance for this engine. + @private + @method buildInstance + @return {Ember.EngineInstance} the engine instance */ - catalogEntriesByType: function (type) { - var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); - var types = _emberRuntime.A(); - var typeSuffixRegex = new RegExp(_emberRuntime.String.classify(type) + '$'); + buildInstance: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - namespaces.forEach(function (namespace) { - if (namespace !== _emberMetal.default) { - for (var key in namespace) { - if (!namespace.hasOwnProperty(key)) { - continue; - } - if (typeSuffixRegex.test(key)) { - var klass = namespace[key]; - if (_emberRuntime.typeOf(klass) === 'class') { - types.push(_emberRuntime.String.dasherize(key.replace(typeSuffixRegex, ''))); - } - } - } - } - }); - return types; - } - }); -}); -// Ember as namespace -enifed('ember-extension-support/data_adapter', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplication) { - 'use strict'; - - /** - @module ember - @submodule ember-extension-support - */ - - /** - The `DataAdapter` helps a data persistence library - interface with tools that debug Ember such - as the [Ember Extension](https://github.com/tildeio/ember-extension) - for Chrome and Firefox. - - This class will be extended by a persistence library - which will override some of the methods with - library-specific code. - - The methods likely to be overridden are: - - * `getFilters` - * `detect` - * `columnsForType` - * `getRecords` - * `getRecordColumnValues` - * `getRecordKeywords` - * `getRecordFilterValues` - * `getRecordColor` - * `observeRecord` - - The adapter will need to be registered - in the application's container as `dataAdapter:main`. - - Example: - - ```javascript - Application.initializer({ - name: "data-adapter", - - initialize: function(application) { - application.register('data-adapter:main', DS.DataAdapter); - } - }); - ``` - - @class DataAdapter - @namespace Ember - @extends EmberObject - @public - */ - exports.default = _emberRuntime.Object.extend({ - init: function () { - this._super.apply(this, arguments); - this.releaseMethods = _emberRuntime.A(); + this.ensureInitializers(); + options.base = this; + return _emberApplicationSystemEngineInstance.default.create(options); }, /** - The container-debug-adapter which is used - to list all models. - @property containerDebugAdapter - @default undefined - @since 1.5.0 - @public - **/ - containerDebugAdapter: undefined, - - /** - The number of attributes to send - as columns. (Enough to make the record - identifiable). + Build and configure the registry for the current engine. @private - @property attributeLimit - @default 3 - @since 1.3.0 + @method buildRegistry + @return {Ember.Registry} the configured registry */ - attributeLimit: 3, + buildRegistry: function () { + var registry = this.__registry__ = this.constructor.buildRegistry(this); - /** - Ember Data > v1.0.0-beta.18 - requires string model names to be passed - around instead of the actual factories. - This is a stamp for the Ember Inspector - to differentiate between the versions - to be able to support older versions too. - @public - @property acceptsModelName - */ - acceptsModelName: true, + return registry; + }, /** - Stores all methods that clear observers. - These methods will be called on destruction. - @private - @property releaseMethods - @since 1.3.0 + @private + @method initializer */ - releaseMethods: _emberRuntime.A(), + initializer: function (options) { + this.constructor.initializer(options); + }, /** - Specifies how records can be filtered. - Records returned will need to have a `filterValues` - property with a key for every name in the returned array. - @public - @method getFilters - @return {Array} List of objects defining filters. - The object should have a `name` and `desc` property. + @private + @method instanceInitializer */ - getFilters: function () { - return _emberRuntime.A(); + instanceInitializer: function (options) { + this.constructor.instanceInitializer(options); }, /** - Fetch the model types and observe them for changes. - @public - @method watchModelTypes - @param {Function} typesAdded Callback to call to add types. - Takes an array of objects containing wrapped types (returned from `wrapModelType`). - @param {Function} typesUpdated Callback to call when a type has changed. - Takes an array of objects containing wrapped types. - @return {Function} Method to call to remove all observers + @private + @method runInitializers */ - watchModelTypes: function (typesAdded, typesUpdated) { + runInitializers: function () { var _this = this; - var modelTypes = this.getModelTypes(); - var releaseMethods = _emberRuntime.A(); - var typesToSend = undefined; + this._runInitializer('initializers', function (name, initializer) { + _emberMetal.assert('No application initializer named \'' + name + '\'', !!initializer); + if (initializer.initialize.length === 2) { + _emberMetal.deprecate('The `initialize` method for Application initializer \'' + name + '\' should take only one argument - `App`, an instance of an `Application`.', false, { + id: 'ember-application.app-initializer-initialize-arguments', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_initializer-arity' + }); - typesToSend = modelTypes.map(function (type) { - var klass = type.klass; - var wrapped = _this.wrapModelType(klass, type.name); - releaseMethods.push(_this.observeModelType(type.name, typesUpdated)); - return wrapped; + initializer.initialize(_this.__registry__, _this); + } else { + initializer.initialize(_this); + } }); - - typesAdded(typesToSend); - - var release = function () { - releaseMethods.forEach(function (fn) { - return fn(); - }); - _this.releaseMethods.removeObject(release); - }; - this.releaseMethods.pushObject(release); - return release; - }, - - _nameToClass: function (type) { - if (typeof type === 'string') { - type = _emberUtils.getOwner(this)._lookupFactory('model:' + type); - } - return type; }, /** - Fetch the records of a given type and observe them for changes. - @public - @method watchRecords - @param {String} modelName The model name. - @param {Function} recordsAdded Callback to call to add records. - Takes an array of objects containing wrapped records. - The object should have the following properties: - columnValues: {Object} The key and value of a table cell. - object: {Object} The actual record object. - @param {Function} recordsUpdated Callback to call when a record has changed. - Takes an array of objects containing wrapped records. - @param {Function} recordsRemoved Callback to call when a record has removed. - Takes the following parameters: - index: The array index where the records were removed. - count: The number of records removed. - @return {Function} Method to call to remove all observers. + @private + @since 1.12.0 + @method runInstanceInitializers */ - watchRecords: function (modelName, recordsAdded, recordsUpdated, recordsRemoved) { - var _this2 = this; + runInstanceInitializers: function (instance) { + this._runInitializer('instanceInitializers', function (name, initializer) { + _emberMetal.assert('No instance initializer named \'' + name + '\'', !!initializer); + initializer.initialize(instance); + }); + }, - var releaseMethods = _emberRuntime.A(); - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); - var release = undefined; + _runInitializer: function (bucketName, cb) { + var initializersByName = _emberMetal.get(this.constructor, bucketName); + var initializers = props(initializersByName); + var graph = new _dagMap.default(); + var initializer = undefined; - function recordUpdated(updatedRecord) { - recordsUpdated([updatedRecord]); + for (var i = 0; i < initializers.length; i++) { + initializer = initializersByName[initializers[i]]; + graph.add(initializer.name, initializer, initializer.before, initializer.after); } - var recordsToSend = records.map(function (record) { - releaseMethods.push(_this2.observeRecord(record, recordUpdated)); - return _this2.wrapRecord(record); - }); + graph.topsort(cb); + } + }); - var contentDidChange = function (array, idx, removedCount, addedCount) { - for (var i = idx; i < idx + addedCount; i++) { - var record = _emberRuntime.objectAt(array, i); - var wrapped = _this2.wrapRecord(record); - releaseMethods.push(_this2.observeRecord(record, recordUpdated)); - recordsAdded([wrapped]); - } + Engine.reopenClass({ + initializers: new _emberUtils.EmptyObject(), + instanceInitializers: new _emberUtils.EmptyObject(), - if (removedCount) { - recordsRemoved(idx, removedCount); + /** + The goal of initializers should be to register dependencies and injections. + This phase runs once. Because these initializers may load code, they are + allowed to defer application readiness and advance it. If you need to access + the container or store you should use an InstanceInitializer that will be run + after all initializers and therefore after all code is loaded and the app is + ready. + Initializer receives an object which has the following attributes: + `name`, `before`, `after`, `initialize`. The only required attribute is + `initialize`, all others are optional. + * `name` allows you to specify under which name the initializer is registered. + This must be a unique name, as trying to register two initializers with the + same name will result in an error. + ```javascript + Ember.Application.initializer({ + name: 'namedInitializer', + initialize: function(application) { + Ember.debug('Running namedInitializer!'); } - }; - - var observer = { didChange: contentDidChange, willChange: function () { - return this; - } }; - _emberRuntime.addArrayObserver(records, this, observer); - - release = function () { - releaseMethods.forEach(function (fn) { - return fn(); - }); - _emberRuntime.removeArrayObserver(records, _this2, observer); - _this2.releaseMethods.removeObject(release); - }; + }); + ``` + * `before` and `after` are used to ensure that this initializer is ran prior + or after the one identified by the value. This value can be a single string + or an array of strings, referencing the `name` of other initializers. + An example of ordering initializers, we create an initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'first', + initialize: function(application) { + Ember.debug('First initializer!'); + } + }); + // DEBUG: First initializer! + ``` + We add another initializer named `second`, specifying that it should run + after the initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'second', + after: 'first', + initialize: function(application) { + Ember.debug('Second initializer!'); + } + }); + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + Afterwards we add a further initializer named `pre`, this time specifying + that it should run before the initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'pre', + before: 'first', + initialize: function(application) { + Ember.debug('Pre initializer!'); + } + }); + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + Finally we add an initializer named `post`, specifying it should run after + both the `first` and the `second` initializers: + ```javascript + Ember.Application.initializer({ + name: 'post', + after: ['first', 'second'], + initialize: function(application) { + Ember.debug('Post initializer!'); + } + }); + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + // DEBUG: Post initializer! + ``` + * `initialize` is a callback function that receives one argument, + `application`, on which you can operate. + Example of using `application` to register an adapter: + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + initialize: function(application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + @method initializer + @param initializer {Object} + @public + */ - recordsAdded(recordsToSend); + initializer: buildInitializerMethod('initializers', 'initializer'), - this.releaseMethods.pushObject(release); - return release; - }, + /** + Instance initializers run after all initializers have run. Because + instance initializers run after the app is fully set up. We have access + to the store, container, and other items. However, these initializers run + after code has loaded and are not allowed to defer readiness. + Instance initializer receives an object which has the following attributes: + `name`, `before`, `after`, `initialize`. The only required attribute is + `initialize`, all others are optional. + * `name` allows you to specify under which name the instanceInitializer is + registered. This must be a unique name, as trying to register two + instanceInitializer with the same name will result in an error. + ```javascript + Ember.Application.instanceInitializer({ + name: 'namedinstanceInitializer', + initialize: function(application) { + Ember.debug('Running namedInitializer!'); + } + }); + ``` + * `before` and `after` are used to ensure that this initializer is ran prior + or after the one identified by the value. This value can be a single string + or an array of strings, referencing the `name` of other initializers. + * See Ember.Application.initializer for discussion on the usage of before + and after. + Example instanceInitializer to preload data into the store. + ```javascript + Ember.Application.initializer({ + name: 'preload-data', + initialize: function(application) { + var userConfig, userConfigEncoded, store; + // We have a HTML escaped JSON representation of the user's basic + // configuration generated server side and stored in the DOM of the main + // index.html file. This allows the app to have access to a set of data + // without making any additional remote calls. Good for basic data that is + // needed for immediate rendering of the page. Keep in mind, this data, + // like all local models and data can be manipulated by the user, so it + // should not be relied upon for security or authorization. + // + // Grab the encoded data from the meta tag + userConfigEncoded = Ember.$('head meta[name=app-user-config]').attr('content'); + // Unescape the text, then parse the resulting JSON into a real object + userConfig = JSON.parse(unescape(userConfigEncoded)); + // Lookup the store + store = application.lookup('service:store'); + // Push the encoded JSON into the store + store.pushPayload(userConfig); + } + }); + ``` + @method instanceInitializer + @param instanceInitializer + @public + */ + instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer'), /** - Clear all observers before destruction + This creates a registry with the default Ember naming conventions. + It also configures the registry: + * registered views are created every time they are looked up (they are + not singletons) + * registered templates are not factories; the registered value is + returned directly. + * the router receives the application as its `namespace` property + * all controllers receive the router as their `target` and `controllers` + properties + * all controllers receive the application as their `namespace` property + * the application view receives the application controller as its + `controller` property + * the application view receives the application template as its + `defaultTemplate` property + @method buildRegistry + @static + @param {Ember.Application} namespace the application for which to + build the registry + @return {Ember.Registry} the built registry @private - @method willDestroy */ - willDestroy: function () { - this._super.apply(this, arguments); - this.releaseMethods.forEach(function (fn) { - return fn(); + buildRegistry: function (namespace) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var registry = new _container.Registry({ + resolver: resolverFor(namespace) }); - }, - /** - Detect whether a class is a model. - Test that against the model class - of your persistence library. - @private - @method detect - @param {Class} klass The class to test. - @return boolean Whether the class is a model class or not. - */ - detect: function (klass) { - return false; + registry.set = _emberMetal.set; + + registry.register('application:main', namespace, { instantiate: false }); + + commonSetupRegistry(registry); + _emberGlimmer.setupEngineRegistry(registry); + + return registry; }, /** - Get the columns for a given model type. - @private - @method columnsForType - @param {Class} type The model type. - @return {Array} An array of columns of the following format: - name: {String} The name of the column. - desc: {String} Humanized description (what would show in a table column name). + Set this to provide an alternate class to `Ember.DefaultResolver` + @deprecated Use 'Resolver' instead + @property resolver + @public */ - columnsForType: function (type) { - return _emberRuntime.A(); - }, + resolver: null, /** - Adds observers to a model type class. - @private - @method observeModelType - @param {String} modelName The model type name. - @param {Function} typesUpdated Called when a type is modified. - @return {Function} The function to call to remove observers. + Set this to provide an alternate class to `Ember.DefaultResolver` + @property resolver + @public */ + Resolver: null + }); - observeModelType: function (modelName, typesUpdated) { - var _this3 = this; - - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); + /** + This function defines the default lookup rules for container lookups: + + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after classifying the name. + For example, `controller:post` looks up `App.PostController` by default. + * if the default lookup fails, look for registered classes on the container + + This allows the application to register default injections in the container + that could be overridden by the normal naming convention. + + @private + @method resolverFor + @param {Ember.Namespace} namespace the namespace to look for classes + @return {*} the resolved value for a given lookup + */ + function resolverFor(namespace) { + var ResolverClass = namespace.get('Resolver') || _emberApplicationSystemResolver.default; - function onChange() { - typesUpdated([this.wrapModelType(klass, modelName)]); - } + return ResolverClass.create({ + namespace: namespace + }); + } - var observer = { - didChange: function () { - _emberMetal.run.scheduleOnce('actions', this, onChange); - }, - willChange: function () { - return this; - } - }; - - _emberRuntime.addArrayObserver(records, this, observer); - - var release = function () { - return _emberRuntime.removeArrayObserver(records, _this3, observer); - }; - - return release; - }, - - /** - Wraps a given model type and observes changes to it. - @private - @method wrapModelType - @param {Class} klass A model class. - @param {String} modelName Name of the class. - @return {Object} Contains the wrapped type and the function to remove observers - Format: - type: {Object} The wrapped type. - The wrapped type has the following format: - name: {String} The name of the type. - count: {Integer} The number of records available. - columns: {Columns} An array of columns to describe the record. - object: {Class} The actual Model type class. - release: {Function} The function to remove observers. - */ - wrapModelType: function (klass, name) { - var records = this.getRecords(klass, name); - var typeToSend = undefined; - - typeToSend = { - name: name, - count: _emberMetal.get(records, 'length'), - columns: this.columnsForType(klass), - object: klass - }; - - return typeToSend; - }, - - /** - Fetches all models defined in the application. - @private - @method getModelTypes - @return {Array} Array of model types. - */ - getModelTypes: function () { - var _this4 = this; - - var containerDebugAdapter = this.get('containerDebugAdapter'); - var types = undefined; - - if (containerDebugAdapter.canCatalogEntriesByType('model')) { - types = containerDebugAdapter.catalogEntriesByType('model'); - } else { - types = this._getObjectsOnNamespaces(); + function buildInitializerMethod(bucketName, humanName) { + return function (initializer) { + // If this is the first initializer being added to a subclass, we are going to reopen the class + // to make sure we have a new `initializers` object, which extends from the parent class' using + // prototypal inheritance. Without this, attempting to add initializers to the subclass would + // pollute the parent class as well as other subclasses. + if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) { + var attrs = {}; + attrs[bucketName] = Object.create(this[bucketName]); + this.reopenClass(attrs); } - // New adapters return strings instead of classes. - types = _emberRuntime.A(types).map(function (name) { - return { - klass: _this4._nameToClass(name), - name: name - }; - }); - types = _emberRuntime.A(types).filter(function (type) { - return _this4.detect(type.klass); - }); + _emberMetal.assert('The ' + humanName + ' \'' + initializer.name + '\' has already been registered', !this[bucketName][initializer.name]); + _emberMetal.assert('An ' + humanName + ' cannot be registered without an initialize function', _emberUtils.canInvoke(initializer, 'initialize')); + _emberMetal.assert('An ' + humanName + ' cannot be registered without a name property', initializer.name !== undefined); - return _emberRuntime.A(types); - }, + this[bucketName][initializer.name] = initializer; + }; + } - /** - Loops over all namespaces and all objects - attached to them. - @private - @method _getObjectsOnNamespaces - @return {Array} Array of model type strings. - */ - _getObjectsOnNamespaces: function () { - var _this5 = this; + function commonSetupRegistry(registry) { + registry.optionsForType('component', { singleton: false }); + registry.optionsForType('view', { singleton: false }); - var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); - var types = _emberRuntime.A(); + registry.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); - namespaces.forEach(function (namespace) { - for (var key in namespace) { - if (!namespace.hasOwnProperty(key)) { - continue; - } - // Even though we will filter again in `getModelTypes`, - // we should not call `lookupFactory` on non-models - // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) - if (!_this5.detect(namespace[key])) { - continue; - } - var _name = _emberRuntime.String.dasherize(key); - if (!(namespace instanceof _emberApplication.Application) && namespace.toString()) { - _name = namespace + '/' + _name; - } - types.push(_name); - } - }); - return types; - }, + registry.injection('view', '_viewRegistry', '-view-registry:main'); + registry.injection('renderer', '_viewRegistry', '-view-registry:main'); + registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); - /** - Fetches all loaded records for a given type. - @private - @method getRecords - @return {Array} An array of records. - This array will be observed for changes, - so it should update when new records are added/removed. - */ - getRecords: function (type) { - return _emberRuntime.A(); - }, + registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); - /** - Wraps a record and observers changes to it. - @private - @method wrapRecord - @param {Object} record The record instance. - @return {Object} The wrapped record. Format: - columnValues: {Array} - searchKeywords: {Array} - */ - wrapRecord: function (record) { - var recordToSend = { object: record }; + registry.injection('view:-outlet', 'namespace', 'application:main'); - recordToSend.columnValues = this.getRecordColumnValues(record); - recordToSend.searchKeywords = this.getRecordKeywords(record); - recordToSend.filterValues = this.getRecordFilterValues(record); - recordToSend.color = this.getRecordColor(record); + registry.injection('controller', 'target', 'router:main'); + registry.injection('controller', 'namespace', 'application:main'); - return recordToSend; - }, + registry.injection('router', '_bucketCache', _container.privatize(_templateObject)); + registry.injection('route', '_bucketCache', _container.privatize(_templateObject)); - /** - Gets the values for each column. - @private - @method getRecordColumnValues - @return {Object} Keys should match column names defined - by the model type. - */ - getRecordColumnValues: function (record) { - return {}; - }, + registry.injection('route', 'router', 'router:main'); - /** - Returns keywords to match when searching records. - @private - @method getRecordKeywords - @return {Array} Relevant keywords for search. - */ - getRecordKeywords: function (record) { - return _emberRuntime.A(); - }, + // Register the routing service... + registry.register('service:-routing', _emberRouting.RoutingService); + // Then inject the app router into it + registry.injection('service:-routing', 'router', 'router:main'); - /** - Returns the values of filters defined by `getFilters`. - @private - @method getRecordFilterValues - @param {Object} record The record instance. - @return {Object} The filter values. - */ - getRecordFilterValues: function (record) { - return {}; - }, + // DEBUGGING + registry.register('resolver-for-debugging:main', registry.resolver, { instantiate: false }); + registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); + registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); + // Custom resolver authors may want to register their own ContainerDebugAdapter with this key - /** - Each record can have a color that represents its state. - @private - @method getRecordColor - @param {Object} record The record instance - @return {String} The records color. - Possible options: black, red, blue, green. - */ - getRecordColor: function (record) { - return null; - }, + registry.register('container-debug-adapter:main', _emberExtensionSupport.ContainerDebugAdapter); - /** - Observes all relevant properties and re-sends the wrapped record - when a change occurs. - @private - @method observerRecord - @param {Object} record The record instance. - @param {Function} recordUpdated The callback to call when a record is updated. - @return {Function} The function to call to remove all observers. - */ - observeRecord: function (record, recordUpdated) { - return function () {}; - } - }); + registry.register('component-lookup:main', _emberViews.ComponentLookup); + } + + exports.default = Engine; }); -enifed('ember-extension-support/index', ['exports', 'ember-extension-support/data_adapter', 'ember-extension-support/container_debug_adapter'], function (exports, _emberExtensionSupportData_adapter, _emberExtensionSupportContainer_debug_adapter) { +enifed('ember-application/system/resolver', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application/utils/validate-type', 'ember-glimmer'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplicationUtilsValidateType, _emberGlimmer) { /** @module ember - @submodule ember-extension-support + @submodule ember-application */ 'use strict'; - exports.DataAdapter = _emberExtensionSupportData_adapter.default; - exports.ContainerDebugAdapter = _emberExtensionSupportContainer_debug_adapter.default; -}); -enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'ember-runtime', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference', 'glimmer-runtime'], function (exports, _emberUtils, _emberViews, _emberRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference, _glimmerRuntime) { - 'use strict'; - - var _CoreView$extend; - - var DIRTY_TAG = _emberUtils.symbol('DIRTY_TAG'); - exports.DIRTY_TAG = DIRTY_TAG; - var ARGS = _emberUtils.symbol('ARGS'); - exports.ARGS = ARGS; - var ROOT_REF = _emberUtils.symbol('ROOT_REF'); - exports.ROOT_REF = ROOT_REF; - var IS_DISPATCHING_ATTRS = _emberUtils.symbol('IS_DISPATCHING_ATTRS'); - exports.IS_DISPATCHING_ATTRS = IS_DISPATCHING_ATTRS; - var HAS_BLOCK = _emberUtils.symbol('HAS_BLOCK'); - exports.HAS_BLOCK = HAS_BLOCK; - var BOUNDS = _emberUtils.symbol('BOUNDS'); - - exports.BOUNDS = BOUNDS; - /** - @module ember - @submodule ember-glimmer - */ + var Resolver = _emberRuntime.Object.extend({ + /* + This will be set to the Application instance when it is + created. + @property namespace + */ + namespace: null, + normalize: null, // required + resolve: null, // required + parseName: null, // required + lookupDescription: null, // required + makeToString: null, // required + resolveOther: null, // required + _logLookup: null // required + }); + exports.Resolver = Resolver; /** - An `Ember.Component` is a view that is completely - isolated. Properties accessed in its templates go - to the view object and actions are targeted at - the view object. There is no access to the - surrounding context or outer controller; all - contextual information must be passed in. - - The easiest way to create an `Ember.Component` is via - a template. If you name a template - `components/my-foo`, you will be able to use - `{{my-foo}}` in other templates, which will make - an instance of the isolated component. + The DefaultResolver defines the default lookup rules to resolve + container lookups before consulting the container for registered + items: - ```handlebars - {{app-profile person=currentUser}} - ``` + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after converting + the name. For example, `controller:post` looks up + `App.PostController` by default. + * there are some nuances (see examples below) - ```handlebars - -

    {{person.title}}

    - -

    {{person.signature}}

    - ``` + ### How Resolving Works - You can use `yield` inside a template to - include the **contents** of any block attached to - the component. The block will be executed in the - context of the surrounding context or outer controller: + The container calls this object's `resolve` method with the + `fullName` argument. - ```handlebars - {{#app-profile person=currentUser}} -

    Admin mode

    - {{! Executed in the controller's context. }} - {{/app-profile}} - ``` + It first parses the fullName into an object using `parseName`. - ```handlebars - -

    {{person.title}}

    - {{! Executed in the component's context. }} - {{yield}} {{! block contents }} - ``` + Then it checks for the presence of a type-specific instance + method of the form `resolve[Type]` and calls it if it exists. + For example if it was resolving 'template:post', it would call + the `resolveTemplate` method. - If you want to customize the component, in order to - handle events or actions, you implement a subclass - of `Ember.Component` named after the name of the - component. Note that `Component` needs to be appended to the name of - your subclass like `AppProfileComponent`. + Its last resort is to call the `resolveOther` method. - For example, you could implement the action - `hello` for the `app-profile` component: + The methods of this object are designed to be easy to override + in a subclass. For example, you could enhance how a template + is resolved like so: ```javascript - App.AppProfileComponent = Ember.Component.extend({ - actions: { - hello: function(name) { - console.log("Hello", name); + App = Ember.Application.create({ + Resolver: Ember.DefaultResolver.extend({ + resolveTemplate: function(parsedName) { + let resolvedTemplate = this._super(parsedName); + if (resolvedTemplate) { return resolvedTemplate; } + return Ember.TEMPLATES['not_found']; } - } + }) }); ``` - And then use it in the component's template: + Some examples of how names are resolved: - ```handlebars - -

    {{person.title}}

    - {{yield}} - ``` - Components must have a `-` in their name to avoid - conflicts with built-in controls that wrap HTML - elements. This is consistent with the same - requirement in web components. + 'template:post' //=> Ember.TEMPLATES['post'] + 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] + // OR + // Ember.TEMPLATES['blog_post'] + 'controller:post' //=> App.PostController + 'controller:posts.index' //=> App.PostsIndexController + 'controller:blog/post' //=> Blog.PostController + 'controller:basic' //=> Ember.Controller + 'route:post' //=> App.PostRoute + 'route:posts.index' //=> App.PostsIndexRoute + 'route:blog/post' //=> Blog.PostRoute + 'route:basic' //=> Ember.Route + 'view:post' //=> App.PostView + 'view:posts.index' //=> App.PostsIndexView + 'view:blog/post' //=> Blog.PostView + 'view:basic' //=> Ember.View + 'foo:post' //=> App.PostFoo + 'model:post' //=> App.Post + ``` - @class Component + @class DefaultResolver @namespace Ember - @extends Ember.CoreView - @uses Ember.TargetActionSupport - @uses Ember.ClassNamesSupport - @uses Ember.ActionSupport - @uses Ember.ViewMixin + @extends Ember.Object @public */ - var Component = _emberViews.CoreView.extend(_emberViews.ChildViewsSupport, _emberViews.ViewStateSupport, _emberViews.ClassNamesSupport, _emberRuntime.TargetActionSupport, _emberViews.ActionSupport, _emberViews.ViewMixin, (_CoreView$extend = { - isComponent: true, + + exports.default = _emberRuntime.Object.extend({ + /** + This will be set to the Application instance when it is + created. + @property namespace + @public + */ + namespace: null, init: function () { - var _this = this; + this._parseNameCache = _emberUtils.dictionary(null); + }, + normalize: function (fullName) { + var _fullName$split = fullName.split(':', 2); - this._super.apply(this, arguments); - this[IS_DISPATCHING_ATTRS] = false; - this[DIRTY_TAG] = new _glimmerReference.DirtyableTag(); - this[ROOT_REF] = new _emberGlimmerUtilsReferences.RootReference(this); - this[BOUNDS] = null; + var type = _fullName$split[0]; + var name = _fullName$split[1]; - // If a `defaultLayout` was specified move it to the `layout` prop. - // `layout` is no longer a CP, so this just ensures that the `defaultLayout` - // logic is supported with a deprecation - if (this.defaultLayout && !this.layout) { - _emberMetal.deprecate('Specifying `defaultLayout` to ' + this + ' is deprecated. Please use `layout` instead.', false, { - id: 'ember-views.component.defaultLayout', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-component-defaultlayout' - }); + _emberMetal.assert('Tried to normalize a container name without a colon (:) in it. ' + 'You probably tried to lookup a name that did not contain a type, ' + 'a colon, and a name. A proper lookup name would be `view:post`.', fullName.split(':').length === 2); - this.layout = this.defaultLayout; - } + if (type !== 'template') { + var result = name; - // If in a tagless component, assert that no event handlers are defined - _emberMetal.assert('You can not define a function that handles DOM events in the `' + this + '` tagless component since it doesn\'t have any DOM element.', this.tagName !== '' || !this.renderer._destinedForDOM || !(function () { - var eventDispatcher = _emberUtils.getOwner(_this).lookup('event_dispatcher:main'); - var events = eventDispatcher && eventDispatcher._finalEvents || {}; + if (result.indexOf('.') > -1) { + result = result.replace(/\.(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); + } - for (var key in events) { - var methodName = events[key]; + if (name.indexOf('_') > -1) { + result = result.replace(/_(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); + } - if (typeof _this[methodName] === 'function') { - return true; // indicate that the assertion should be triggered - } + if (name.indexOf('-') > -1) { + result = result.replace(/-(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); } - })()); - }, - rerender: function () { - this[DIRTY_TAG].dirty(); - this._super(); + return type + ':' + result; + } else { + return fullName; + } }, - __defineNonEnumerable: function (property) { - this[property.name] = property.descriptor.value; - } + /** + This method is called via the container's resolver method. + It parses the provided `fullName` and then looks up and + returns the appropriate template or class. + @method resolve + @param {String} fullName the lookup string + @return {Object} the resolved factory + @public + */ + resolve: function (fullName) { + var _this = this; - }, _CoreView$extend[_emberMetal.PROPERTY_DID_CHANGE] = function (key) { - if (this[IS_DISPATCHING_ATTRS]) { - return; - } + var parsedName = this.parseName(fullName); + var resolveMethodName = parsedName.resolveMethodName; + var resolved = undefined; - var args = undefined, - reference = undefined; + if (this[resolveMethodName]) { + resolved = this[resolveMethodName](parsedName); + } - if ((args = this[ARGS]) && (reference = args[key])) { - if (reference[_emberGlimmerUtilsReferences.UPDATE]) { - reference[_emberGlimmerUtilsReferences.UPDATE](_emberMetal.get(this, key)); + resolved = resolved || this.resolveOther(parsedName); + + _emberMetal.runInDebug(function () { + if (parsedName.root && parsedName.root.LOG_RESOLVER) { + _this._logLookup(resolved, parsedName); + } + }); + + if (resolved) { + _emberApplicationUtilsValidateType.default(resolved, parsedName); } - } - }, _CoreView$extend.getAttr = function (key) { - // TODO Intimate API should be deprecated - return this.get(key); - }, _CoreView$extend.readDOMAttr = function (name) { - var element = _emberViews.getViewElement(this); - return _glimmerRuntime.readDOMAttr(element, name); - }, _CoreView$extend)); - /** - The WAI-ARIA role of the control represented by this view. For example, a - button may have a role of type 'button', or a pane may have a role of - type 'alertdialog'. This property is used by assistive software to help - visually challenged users navigate rich web applications. - The full list of valid WAI-ARIA roles is available at: - [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization) - @property ariaRole - @type String - @default null - @public - */ + return resolved; + }, - /** - Enables components to take a list of parameters as arguments. - For example, a component that takes two parameters with the names - `name` and `age`: - ```javascript - let MyComponent = Ember.Component.extend; - MyComponent.reopenClass({ - positionalParams: ['name', 'age'] - }); - ``` - It can then be invoked like this: - ```hbs - {{my-component "John" 38}} - ``` - The parameters can be referred to just like named parameters: - ```hbs - Name: {{attrs.name}}, Age: {{attrs.age}}. - ``` - Using a string instead of an array allows for an arbitrary number of - parameters: - ```javascript - let MyComponent = Ember.Component.extend; - MyComponent.reopenClass({ - positionalParams: 'names' - }); - ``` - It can then be invoked like this: - ```hbs - {{my-component "John" "Michael" "Scott"}} - ``` - The parameters can then be referred to by enumerating over the list: - ```hbs - {{#each attrs.names as |name|}}{{name}}{{/each}} - ``` - @static - @public - @property positionalParams - @since 1.13.0 - */ + /** + Convert the string name of the form 'type:name' to + a Javascript object with the parsed aspects of the name + broken out. + @param {String} fullName the lookup string + @method parseName + @protected + */ - /** - Called when the attributes passed into the component have been updated. - Called both during the initial render of a container and during a rerender. - Can be used in place of an observer; code placed here will be executed - every time any attribute updates. - @method didReceiveAttrs - @public - @since 1.13.0 - */ + parseName: function (fullName) { + return this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)); + }, - /** - Called when the attributes passed into the component have been updated. - Called both during the initial render of a container and during a rerender. - Can be used in place of an observer; code placed here will be executed - every time any attribute updates. - @event didReceiveAttrs - @public - @since 1.13.0 - */ + _parseName: function (fullName) { + var _fullName$split2 = fullName.split(':'); - /** - Called after a component has been rendered, both on initial render and - in subsequent rerenders. - @method didRender - @public - @since 1.13.0 - */ + var type = _fullName$split2[0]; + var fullNameWithoutType = _fullName$split2[1]; - /** - Called after a component has been rendered, both on initial render and - in subsequent rerenders. - @event didRender - @public - @since 1.13.0 - */ + var name = fullNameWithoutType; + var namespace = _emberMetal.get(this, 'namespace'); + var root = namespace; + var lastSlashIndex = name.lastIndexOf('/'); + var dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null; - /** - Called before a component has been rendered, both on initial render and - in subsequent rerenders. - @method willRender - @public - @since 1.13.0 - */ + if (type !== 'template' && lastSlashIndex !== -1) { + var parts = name.split('/'); + name = parts[parts.length - 1]; + var namespaceName = _emberRuntime.String.capitalize(parts.slice(0, -1).join('.')); + root = _emberRuntime.Namespace.byName(namespaceName); - /** - Called before a component has been rendered, both on initial render and - in subsequent rerenders. - @event willRender - @public - @since 1.13.0 - */ + _emberMetal.assert('You are looking for a ' + name + ' ' + type + ' in the ' + namespaceName + ' namespace, but the namespace could not be found', root); + } - /** - Called when the attributes passed into the component have been changed. - Called only during a rerender, not during an initial render. - @method didUpdateAttrs - @public - @since 1.13.0 - */ + var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : _emberRuntime.String.classify(type); - /** - Called when the attributes passed into the component have been changed. - Called only during a rerender, not during an initial render. - @event didUpdateAttrs - @public - @since 1.13.0 - */ + if (!(name && type)) { + throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); + } - /** - Called when the component is about to update and rerender itself. - Called only during a rerender, not during an initial render. - @method willUpdate - @public - @since 1.13.0 - */ + return { + fullName: fullName, + type: type, + fullNameWithoutType: fullNameWithoutType, + dirname: dirname, + name: name, + root: root, + resolveMethodName: 'resolve' + resolveMethodName + }; + }, - /** - Called when the component is about to update and rerender itself. - Called only during a rerender, not during an initial render. - @event willUpdate - @public - @since 1.13.0 - */ + /** + Returns a human-readable description for a fullName. Used by the + Application namespace in assertions to describe the + precise name of the class that Ember is looking for, rather than + container keys. + @param {String} fullName the lookup string + @method lookupDescription + @protected + */ + lookupDescription: function (fullName) { + var parsedName = this.parseName(fullName); + var description = undefined; - /** - Called when the component has updated and rerendered itself. - Called only during a rerender, not during an initial render. - @method didUpdate - @public - @since 1.13.0 - */ + if (parsedName.type === 'template') { + return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + } - /** - Called when the component has updated and rerendered itself. - Called only during a rerender, not during an initial render. - @event didUpdate - @public - @since 1.13.0 - */ + description = parsedName.root + '.' + _emberRuntime.String.classify(parsedName.name).replace(/\./g, ''); - /** - If `false`, the view will appear hidden in DOM. - @property isVisible - @type Boolean - @default null - @public - */ - Component[_emberUtils.NAME_KEY] = 'Ember.Component'; + if (parsedName.type !== 'model') { + description += _emberRuntime.String.classify(parsedName.type); + } - Component.reopenClass({ - isComponentFactory: true, - positionalParams: [] - }); + return description; + }, - exports.default = Component; -}); + makeToString: function (factory, fullName) { + return factory.toString(); + }, -/** - Normally, Ember's component model is "write-only". The component takes a - bunch of attributes that it got passed in, and uses them to render its - template. - One nice thing about this model is that if you try to set a value to the - same thing as last time, Ember (through HTMLBars) will avoid doing any - work on the DOM. - This is not just a performance optimization. If an attribute has not - changed, it is important not to clobber the element's "hidden state". - For example, if you set an input's `value` to the same value as before, - it will clobber selection state and cursor position. In other words, - setting an attribute is not **always** idempotent. - This method provides a way to read an element's attribute and also - update the last value Ember knows about at the same time. This makes - setting an attribute idempotent. - In particular, what this means is that if you get an `` element's - `value` attribute and then re-render the template with the same value, - it will avoid clobbering the cursor and selection position. - Since most attribute sets are idempotent in the browser, you typically - can get away with reading attributes using jQuery, but the most reliable - way to do so is through this method. - @method readDOMAttr - @param {String} name the name of the attribute - @return String - @public - */ -enifed('ember-glimmer/components/checkbox', ['exports', 'ember-metal', 'ember-glimmer/component', 'ember-glimmer/templates/empty'], function (exports, _emberMetal, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty) { - 'use strict'; + /** + Given a parseName object (output from `parseName`), apply + the conventions expected by `Ember.Router` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method useRouterNaming + @protected + */ + useRouterNaming: function (parsedName) { + parsedName.name = parsedName.name.replace(/\./g, '_'); + if (parsedName.name === 'basic') { + parsedName.name = ''; + } + }, + /** + Look up the template in Ember.TEMPLATES + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveTemplate + @protected + */ + resolveTemplate: function (parsedName) { + var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); - /** - @module ember - @submodule ember-views - */ + return _emberGlimmer.getTemplate(templateName) || _emberGlimmer.getTemplate(_emberRuntime.String.decamelize(templateName)); + }, - /** - The internal class used to create text inputs when the `{{input}}` - helper is used with `type` of `checkbox`. - - See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. - - ## Direct manipulation of `checked` - - The `checked` attribute of an `Ember.Checkbox` object should always be set - through the Ember object or by interacting with its rendered element - representation via the mouse, keyboard, or touch. Updating the value of the - checkbox via jQuery will result in the checked value of the object and its - element losing synchronization. - - ## Layout and LayoutName properties - - Because HTML `input` elements are self closing `layout` and `layoutName` - properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. - - @class Checkbox - @namespace Ember - @extends Ember.Component - @public - */ - exports.default = _emberGlimmerComponent.default.extend({ - layout: _emberGlimmerTemplatesEmpty.default, - classNames: ['ember-checkbox'], + /** + Lookup the view using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveView + @protected + */ + resolveView: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, - tagName: 'input', + /** + Lookup the controller using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveController + @protected + */ + resolveController: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, + /** + Lookup the route using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveRoute + @protected + */ + resolveRoute: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, - attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name', 'autofocus', 'required', 'form'], + /** + Lookup the model on the Application namespace + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveModel + @protected + */ + resolveModel: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.name); + var factory = _emberMetal.get(parsedName.root, className); - type: 'checkbox', - checked: false, - disabled: false, - indeterminate: false, + return factory; + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveHelper + @protected + */ + resolveHelper: function (parsedName) { + return this.resolveOther(parsedName); + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveOther + @protected + */ + resolveOther: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.name) + _emberRuntime.String.classify(parsedName.type); + var factory = _emberMetal.get(parsedName.root, className); + return factory; + }, - didInsertElement: function () { - this._super.apply(this, arguments); - _emberMetal.get(this, 'element').indeterminate = !!_emberMetal.get(this, 'indeterminate'); + resolveMain: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.type); + return _emberMetal.get(parsedName.root, className); }, - change: function () { - _emberMetal.set(this, 'checked', this.$().prop('checked')); + /** + @method _logLookup + @param {Boolean} found + @param {Object} parsedName + @private + */ + _logLookup: function (found, parsedName) { + var symbol = undefined, + padding = undefined; + + if (found) { + symbol = '[✓]'; + } else { + symbol = '[ ]'; + } + + if (parsedName.fullName.length > 60) { + padding = '.'; + } else { + padding = new Array(60 - parsedName.fullName.length).join('.'); + } + + _emberMetal.info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); + }, + + /** + Used to iterate all items of a given type. + @method knownForType + @param {String} type the type to search for + @private + */ + knownForType: function (type) { + var namespace = _emberMetal.get(this, 'namespace'); + var suffix = _emberRuntime.String.classify(type); + var typeRegexp = new RegExp(suffix + '$'); + + var known = _emberUtils.dictionary(null); + var knownKeys = Object.keys(namespace); + for (var index = 0; index < knownKeys.length; index++) { + var _name = knownKeys[index]; + + if (typeRegexp.test(_name)) { + var containerName = this.translateToContainerFullname(type, _name); + + known[containerName] = true; + } + } + + return known; + }, + + /** + Converts provided name from the backing namespace into a container lookup name. + Examples: + App.FooBarHelper -> helper:foo-bar + App.THelper -> helper:t + @method translateToContainerFullname + @param {String} type + @param {String} name + @private + */ + + translateToContainerFullname: function (type, name) { + var suffix = _emberRuntime.String.classify(type); + var namePrefix = name.slice(0, suffix.length * -1); + var dasherizedName = _emberRuntime.String.dasherize(namePrefix); + + return type + ':' + dasherizedName; } }); }); -enifed('ember-glimmer/components/link-to', ['exports', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-glimmer/templates/link-to', 'ember-glimmer/component'], function (exports, _emberConsole, _emberMetal, _emberRuntime, _emberViews, _emberGlimmerTemplatesLinkTo, _emberGlimmerComponent) { +enifed('ember-application/utils/validate-type', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** @module ember - @submodule ember-glimmer + @submodule ember-application */ + 'use strict'; + + exports.default = validateType; + + var VALIDATED_TYPES = { + route: ['assert', 'isRouteFactory', 'Ember.Route'], + component: ['deprecate', 'isComponentFactory', 'Ember.Component'], + view: ['deprecate', 'isViewFactory', 'Ember.View'], + service: ['deprecate', 'isServiceFactory', 'Ember.Service'] + }; + + function validateType(resolvedType, parsedName) { + var validationAttributes = VALIDATED_TYPES[parsedName.type]; + + if (!validationAttributes) { + return; + } + + var action = validationAttributes[0]; + var factoryFlag = validationAttributes[1]; + var expectedType = validationAttributes[2]; + + if (action === 'deprecate') { + _emberMetal.deprecate('In Ember 2.0 ' + parsedName.type + ' factories must have an `' + factoryFlag + '` ' + ('property set to true. You registered ' + resolvedType + ' as a ' + parsedName.type + ' ') + ('factory. Either add the `' + factoryFlag + '` property to this factory or ') + ('extend from ' + expectedType + '.'), !!resolvedType[factoryFlag], { id: 'ember-application.validate-type', until: '3.0.0' }); + } else { + _emberMetal.assert('Expected ' + parsedName.fullName + ' to resolve to an ' + expectedType + ' but ' + ('instead it was ' + resolvedType + '.'), !!resolvedType[factoryFlag]); + } + } +}); +enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; + + function K() {} + + function consoleMethod(name) { + var consoleObj = undefined; + if (_emberEnvironment.context.imports.console) { + consoleObj = _emberEnvironment.context.imports.console; + } else if (typeof console !== 'undefined') { + consoleObj = console; + } + + var method = typeof consoleObj === 'object' ? consoleObj[name] : null; + + if (typeof method !== 'function') { + return; + } + + if (typeof method.bind === 'function') { + return method.bind(consoleObj); + } + + return function () { + method.apply(consoleObj, arguments); + }; + } + + function assertPolyfill(test, message) { + if (!test) { + try { + // attempt to preserve the stack + throw new Error('assertion failed: ' + message); + } catch (error) { + setTimeout(function () { + throw error; + }, 0); + } + } + } + /** - The `{{link-to}}` component renders a link to the supplied - `routeName` passing an optionally supplied model to the - route as its `model` context of the route. The block - for `{{link-to}}` becomes the innerHTML of the rendered - element: - - ```handlebars - {{#link-to 'photoGallery'}} - Great Hamster Photos - {{/link-to}} - ``` + Inside Ember-Metal, simply uses the methods from `imports.console`. + Override this to provide more robust logging functionality. - You can also use an inline form of `{{link-to}}` component by - passing the link text as the first argument - to the component: + @class Logger + @namespace Ember + @public + */ + exports.default = { + /** + Logs the arguments to the console. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.log('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method log + @for Ember.Logger + @param {*} arguments + @public + */ + log: consoleMethod('log') || K, + + /** + Prints the arguments to the console with a warning icon. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + Ember.Logger.warn('Something happened!'); + // "Something happened!" will be printed to the console with a warning icon. + ``` + @method warn + @for Ember.Logger + @param {*} arguments + @public + */ + warn: consoleMethod('warn') || K, + + /** + Prints the arguments to the console with an error icon, red text and a stack trace. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + Ember.Logger.error('Danger! Danger!'); + // "Danger! Danger!" will be printed to the console in red text. + ``` + @method error + @for Ember.Logger + @param {*} arguments + @public + */ + error: consoleMethod('error') || K, + + /** + Logs the arguments to the console. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.info('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method info + @for Ember.Logger + @param {*} arguments + @public + */ + info: consoleMethod('info') || K, + + /** + Logs the arguments to the console in blue text. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.debug('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method debug + @for Ember.Logger + @param {*} arguments + @public + */ + debug: consoleMethod('debug') || consoleMethod('info') || K, + + /** + If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. + ```javascript + Ember.Logger.assert(true); // undefined + Ember.Logger.assert(true === false); // Throws an Assertion failed error. + Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message. + ``` + @method assert + @for Ember.Logger + @param {Boolean} bool Value to test + @param {String} message Assertion message on failed + @public + */ + assert: consoleMethod('assert') || assertPolyfill + }; +}); +enifed('ember-debug/deprecate', ['exports', 'ember-metal', 'ember-console', 'ember-environment', 'ember-debug/handlers'], function (exports, _emberMetal, _emberConsole, _emberEnvironment, _emberDebugHandlers) { + /*global __fail__*/ + + 'use strict'; + + exports.registerHandler = registerHandler; + exports.default = deprecate; + + function registerHandler(handler) { + _emberDebugHandlers.registerHandler('deprecate', handler); + } + + function formatMessage(_message, options) { + var message = _message; + + if (options && options.id) { + message = message + (' [deprecation id: ' + options.id + ']'); + } + + if (options && options.url) { + message += ' See ' + options.url + ' for more details.'; + } + + return message; + } + + registerHandler(function logDeprecationToConsole(message, options) { + var updatedMessage = formatMessage(message, options); + + _emberConsole.default.warn('DEPRECATION: ' + updatedMessage); + }); + + var captureErrorForStack = undefined; + + if (new Error().stack) { + captureErrorForStack = function () { + return new Error(); + }; + } else { + captureErrorForStack = function () { + try { + __fail__.fail(); + } catch (e) { + return e; + } + }; + } + + registerHandler(function logDeprecationStackTrace(message, options, next) { + if (_emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION) { + var stackStr = ''; + var error = captureErrorForStack(); + var stack = undefined; + + if (error.stack) { + if (error['arguments']) { + // Chrome + stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); + stack.shift(); + } else { + // Firefox + stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); + } + + stackStr = '\n ' + stack.slice(2).join('\n '); + } + + var updatedMessage = formatMessage(message, options); + + _emberConsole.default.warn('DEPRECATION: ' + updatedMessage + stackStr); + } else { + next.apply(undefined, arguments); + } + }); + + registerHandler(function raiseOnDeprecation(message, options, next) { + if (_emberEnvironment.ENV.RAISE_ON_DEPRECATION) { + var updatedMessage = formatMessage(message); + + throw new _emberMetal.Error(updatedMessage); + } else { + next.apply(undefined, arguments); + } + }); + + var missingOptionsDeprecation = 'When calling `Ember.deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; + exports.missingOptionsDeprecation = missingOptionsDeprecation; + var missingOptionsIdDeprecation = 'When calling `Ember.deprecate` you must provide `id` in options.'; + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; + var missingOptionsUntilDeprecation = 'When calling `Ember.deprecate` you must provide `until` in options.'; + + exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation; + /** + @module ember + @submodule ember-debug + */ + + /** + Display a deprecation warning with the provided message and a stack trace + (Chrome and Firefox only). - ```handlebars - {{link-to 'Great Hamster Photos' 'photoGallery'}} - ``` + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - Both will result in: + @method deprecate + @param {String} message A description of the deprecation. + @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. + @param {Object} options + @param {String} options.id A unique id for this deprecation. The id can be + used by Ember debugging tools to change the behavior (raise, log or silence) + for that specific deprecation. The id should be namespaced by dots, e.g. + "view.helper.select". + @param {string} options.until The version of Ember when this deprecation + warning will be removed. + @param {String} [options.url] An optional url to the transition guide on the + emberjs.com website. + @for Ember + @public + @since 1.0.0 + */ + + function deprecate(message, test, options) { + if (!options || !options.id && !options.until) { + deprecate(missingOptionsDeprecation, false, { + id: 'ember-debug.deprecate-options-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + if (options && !options.id) { + deprecate(missingOptionsIdDeprecation, false, { + id: 'ember-debug.deprecate-id-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + if (options && !options.until) { + deprecate(missingOptionsUntilDeprecation, options && options.until, { + id: 'ember-debug.deprecate-until-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + _emberDebugHandlers.invoke.apply(undefined, ['deprecate'].concat(babelHelpers.slice.call(arguments))); + } +}); +enifed("ember-debug/handlers", ["exports"], function (exports) { + "use strict"; + + exports.registerHandler = registerHandler; + exports.invoke = invoke; + var HANDLERS = {}; + + exports.HANDLERS = HANDLERS; + + function registerHandler(type, callback) { + var nextHandler = HANDLERS[type] || function () {}; + + HANDLERS[type] = function (message, options) { + callback(message, options, nextHandler); + }; + } + + function invoke(type, message, test, options) { + if (test) { + return; + } + + var handlerForType = HANDLERS[type]; + + if (!handlerForType) { + return; + } + + if (handlerForType) { + handlerForType(message, options); + } + } +}); +enifed('ember-debug/index', ['exports', 'ember-metal', 'ember-environment', 'ember-console', 'ember-debug/deprecate', 'ember-debug/warn'], function (exports, _emberMetal, _emberEnvironment, _emberConsole, _emberDebugDeprecate, _emberDebugWarn) { + 'use strict'; + + exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; + + /** + @module ember + @submodule ember-debug + */ + + /** + @class Ember + @public + */ + + /** + Define an assertion that will throw an exception if the condition is not met. - ```html - - Great Hamster Photos - - ``` + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - ### Supplying a tagName - By default `{{link-to}}` renders an `` element. This can - be overridden for a single use of `{{link-to}}` by supplying - a `tagName` option: + ```javascript + // Test for truthiness + Ember.assert('Must pass a valid object', obj); - ```handlebars - {{#link-to 'photoGallery' tagName="li"}} - Great Hamster Photos - {{/link-to}} + // Fail unconditionally + Ember.assert('This code path should never be run'); ``` - ```html -
  • - Great Hamster Photos -
  • - ``` + @method assert + @param {String} desc A description of the assertion. This will become + the text of the Error thrown if the assertion fails. + @param {Boolean} test Must be truthy for the assertion to pass. If + falsy, an exception will be thrown. + @public + @since 1.0.0 + */ + _emberMetal.setDebugFunction('assert', function assert(desc, test) { + if (!test) { + throw new _emberMetal.Error('Assertion Failed: ' + desc); + } + }); + + /** + Display a debug notice. - To override this option for your entire application, see - "Overriding Application-wide Defaults". + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - ### Disabling the `link-to` component - By default `{{link-to}}` is enabled. - any passed value to the `disabled` component property will disable - the `link-to` component. + ```javascript + Ember.debug('I\'m a debug notice!'); + ``` - static use: the `disabled` option: + @method debug + @param {String} message A debug message to display. + @public + */ + _emberMetal.setDebugFunction('debug', function debug(message) { + _emberConsole.default.debug('DEBUG: ' + message); + }); + + /** + Display an info notice. - ```handlebars - {{#link-to 'photoGallery' disabled=true}} - Great Hamster Photos - {{/link-to}} - ``` + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - dynamic use: the `disabledWhen` option: + @method info + @private + */ + _emberMetal.setDebugFunction('info', function info() { + _emberConsole.default.info.apply(undefined, arguments); + }); + + /** + Alias an old, deprecated method with its new counterpart. - ```handlebars - {{#link-to 'photoGallery' disabledWhen=controller.someProperty}} - Great Hamster Photos - {{/link-to}} - ``` + Display a deprecation warning with the provided message and a stack trace + (Chrome and Firefox only) when the assigned method is called. - any passed value to `disabled` will disable it except `undefined`. - to ensure that only `true` disable the `link-to` component you can - override the global behaviour of `Ember.LinkComponent`. + * In a production build, this method is defined as an empty function (NOP). ```javascript - Ember.LinkComponent.reopen({ - disabled: Ember.computed(function(key, value) { - if (value !== undefined) { - this.set('_isDisabled', value === true); - } - return value === true ? get(this, 'disabledClass') : false; - }) - }); + Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod); ``` - see "Overriding Application-wide Defaults" for more. - - ### Handling `href` - `{{link-to}}` will use your application's Router to - fill the element's `href` property with a url that - matches the path to the supplied `routeName` for your - router's configured `Location` scheme, which defaults - to Ember.HashLocation. + @method deprecateFunc + @param {String} message A description of the deprecation. + @param {Object} [options] The options object for Ember.deprecate. + @param {Function} func The new function called to replace its deprecated counterpart. + @return {Function} A new function that wraps the original function with a deprecation warning + @private + */ + _emberMetal.setDebugFunction('deprecateFunc', function deprecateFunc() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 3) { + var _ret = (function () { + var message = args[0]; + var options = args[1]; + var func = args[2]; + + return { + v: function () { + _emberMetal.deprecate(message, false, options); + return func.apply(this, arguments); + } + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + var _ret2 = (function () { + var message = args[0]; + var func = args[1]; + + return { + v: function () { + _emberMetal.deprecate(message); + return func.apply(this, arguments); + } + }; + })(); + + if (typeof _ret2 === 'object') return _ret2.v; + } + }); + + /** + Run a function meant for debugging. - ### Handling current route - `{{link-to}}` will apply a CSS class name of 'active' - when the application's current route matches - the supplied routeName. For example, if the application's - current route is 'photoGallery.recent' the following - use of `{{link-to}}`: + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - ```handlebars - {{#link-to 'photoGallery.recent'}} - Great Hamster Photos - {{/link-to}} + ```javascript + Ember.runInDebug(() => { + Ember.Component.reopen({ + didInsertElement() { + console.log("I'm happy"); + } + }); + }); ``` - will result in + @method runInDebug + @param {Function} func The function to be executed. + @since 1.5.0 + @public + */ + _emberMetal.setDebugFunction('runInDebug', function runInDebug(func) { + func(); + }); + + _emberMetal.setDebugFunction('debugSeal', function debugSeal(obj) { + Object.seal(obj); + }); + + _emberMetal.setDebugFunction('debugFreeze', function debugFreeze(obj) { + Object.freeze(obj); + }); + + _emberMetal.setDebugFunction('deprecate', _emberDebugDeprecate.default); + + _emberMetal.setDebugFunction('warn', _emberDebugWarn.default); + + /** + Will call `Ember.warn()` if ENABLE_OPTIONAL_FEATURES or + any specific FEATURES flag is truthy. - ```html -
    - Great Hamster Photos - - ``` + This method is called automatically in debug canary builds. - The CSS class name used for active classes can be customized - for a single use of `{{link-to}}` by passing an `activeClass` - option: - - ```handlebars - {{#link-to 'photoGallery.recent' activeClass="current-url"}} - Great Hamster Photos - {{/link-to}} - ``` - - ```html - - Great Hamster Photos - - ``` - - To override this option for your entire application, see - "Overriding Application-wide Defaults". - - ### Keeping a link active for other routes - - If you need a link to be 'active' even when it doesn't match - the current route, you can use the `current-when` argument. - - ```handlebars - {{#link-to 'photoGallery' current-when='photos'}} - Photo Gallery - {{/link-to}} - ``` - - This may be helpful for keeping links active for: - - * non-nested routes that are logically related - * some secondary menu approaches - * 'top navigation' with 'sub navigation' scenarios - - A link will be active if `current-when` is `true` or the current - route is the route this link would transition to. - - To match multiple routes 'space-separate' the routes: - - ```handlebars - {{#link-to 'gallery' current-when='photos drawings paintings'}} - Art Gallery - {{/link-to}} - ``` - - ### Supplying a model - An optional model argument can be used for routes whose - paths contain dynamic segments. This argument will become - the model context of the linked route: - - ```javascript - Router.map(function() { - this.route("photoGallery", {path: "hamster-photos/:photo_id"}); - }); - ``` - - ```handlebars - {{#link-to 'photoGallery' aPhoto}} - {{aPhoto.title}} - {{/link-to}} - ``` - - ```html - - Tomster - - ``` - - ### Supplying multiple models - For deep-linking to route paths that contain multiple - dynamic segments, multiple model arguments can be used. - As the router transitions through the route path, each - supplied model argument will become the context for the - route with the dynamic segments: + @private + @method _warnIfUsingStrippedFeatureFlags + @return {void} + */ + + function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featuresWereStripped) { + if (featuresWereStripped) { + _emberMetal.warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + + var keys = Object.keys(FEATURES || {}); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (key === 'isEnabled' || !(key in knownFeatures)) { + continue; + } + + _emberMetal.warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); + } + } + } + + if (!_emberMetal.isTesting()) { + (function () { + // Complain if they're using FEATURE flags in builds other than canary + _emberMetal.FEATURES['features-stripped-test'] = true; + var featuresWereStripped = true; + + if (_emberMetal.isFeatureEnabled('features-stripped-test')) { + featuresWereStripped = false; + } + + delete _emberMetal.FEATURES['features-stripped-test']; + _warnIfUsingStrippedFeatureFlags(_emberEnvironment.ENV.FEATURES, _emberMetal.DEFAULT_FEATURES, featuresWereStripped); + + // Inform the developer about the Ember Inspector if not installed. + var isFirefox = _emberEnvironment.environment.isFirefox; + var isChrome = _emberEnvironment.environment.isChrome; + + if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { + window.addEventListener('load', function () { + if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) { + var downloadURL = undefined; + + if (isChrome) { + downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'; + } else if (isFirefox) { + downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; + } + + _emberMetal.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); + } + }, false); + } + })(); + } + /** + @public + @class Ember.Debug + */ + _emberMetal.default.Debug = {}; + + /** + Allows for runtime registration of handler functions that override the default deprecation behavior. + Deprecations are invoked by calls to [Ember.deprecate](http://emberjs.com/api/classes/Ember.html#method_deprecate). + The following example demonstrates its usage by registering a handler that throws an error if the + message contains the word "should", otherwise defers to the default handler. ```javascript - Router.map(function() { - this.route("photoGallery", { path: "hamster-photos/:photo_id" }, function() { - this.route("comment", {path: "comments/:comment_id"}); - }); + Ember.Debug.registerDeprecationHandler((message, options, next) => { + if (message.indexOf('should') !== -1) { + throw new Error(`Deprecation message with should: ${message}`); + } else { + // defer to whatever handler was registered before this one + next(message, options); + } }); ``` - This argument will become the model context of the linked route: - ```handlebars - {{#link-to 'photoGallery.comment' aPhoto comment}} - {{comment.body}} - {{/link-to}} - ``` + The handler function takes the following arguments: - ```html - - A+++ would snuggle again. - - ``` +
      +
    • message - The message received from the deprecation call.
    • +
    • options - An object passed in with the deprecation call containing additional information including:
    • +
        +
      • id - An id of the deprecation in the form of package-name.specific-deprecation.
      • +
      • until - The Ember version number the feature and deprecation will be removed in.
      • +
      +
    • next - A function that calls into the previously registered handler.
    • +
    - ### Supplying an explicit dynamic segment value - If you don't have a model object available to pass to `{{link-to}}`, - an optional string or integer argument can be passed for routes whose - paths contain dynamic segments. This argument will become the value - of the dynamic segment: + @public + @static + @method registerDeprecationHandler + @param handler {Function} A function to handle deprecation calls. + @since 2.1.0 + */ + _emberMetal.default.Debug.registerDeprecationHandler = _emberDebugDeprecate.registerHandler; + /** + Allows for runtime registration of handler functions that override the default warning behavior. + Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). + The following example demonstrates its usage by registering a handler that does nothing overriding Ember's + default warning behavior. ```javascript - Router.map(function() { - this.route("photoGallery", { path: "hamster-photos/:photo_id" }); - }); - ``` - - ```handlebars - {{#link-to 'photoGallery' aPhotoId}} - {{aPhoto.title}} - {{/link-to}} - ``` - - ```html - - Tomster - - ``` - - When transitioning into the linked route, the `model` hook will - be triggered with parameters including this passed identifier. - - ### Allowing Default Action - - By default the `{{link-to}}` component prevents the default browser action - by calling `preventDefault()` as this sort of action bubbling is normally - handled internally and we do not want to take the browser to a new URL (for - example). - - If you need to override this behavior specify `preventDefault=false` in - your template: - - ```handlebars - {{#link-to 'photoGallery' aPhotoId preventDefault=false}} - {{aPhotoId.title}} - {{/link-to}} - ``` - - ### Overriding attributes - You can override any given property of the `Ember.LinkComponent` - that is generated by the `{{link-to}}` component by passing - key/value pairs, like so: - - ```handlebars - {{#link-to aPhoto tagName='li' title='Following this link will change your life' classNames='pic sweet'}} - Uh-mazing! - {{/link-to}} - ``` - - See [Ember.LinkComponent](/api/classes/Ember.LinkComponent.html) for a - complete list of overrideable properties. Be sure to also - check out inherited properties of `LinkComponent`. - - ### Overriding Application-wide Defaults - ``{{link-to}}`` creates an instance of `Ember.LinkComponent` - for rendering. To override options for your entire - application, reopen `Ember.LinkComponent` and supply the - desired values: - - ``` javascript - Ember.LinkComponent.reopen({ - activeClass: "is-active", - tagName: 'li' - }) + // next is not called, so no warnings get the default behavior + Ember.Debug.registerWarnHandler(() => {}); ``` - It is also possible to override the default event in - this manner: + The handler function takes the following arguments: - ``` javascript - Ember.LinkComponent.reopen({ - eventName: 'customEventName' - }); - ``` +
      +
    • message - The message received from the warn call.
    • +
    • options - An object passed in with the warn call containing additional information including:
    • +
        +
      • id - An id of the warning in the form of package-name.specific-warning.
      • +
      +
    • next - A function that calls into the previously registered handler.
    • +
    - @method link-to - @for Ember.Templates.helpers - @param {String} routeName - @param {Object} [context]* - @param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkComponent - @return {String} HTML string - @see {Ember.LinkComponent} @public + @static + @method registerWarnHandler + @param handler {Function} A function to handle warnings. + @since 2.1.0 */ + _emberMetal.default.Debug.registerWarnHandler = _emberDebugWarn.registerHandler; + /* + We are transitioning away from `ember.js` to `ember.debug.js` to make + it much clearer that it is only for local development purposes. + + This flag value is changed by the tooling (by a simple string replacement) + so that if `ember.js` (which must be output for backwards compat reasons) is + used a nice helpful warning message will be printed out. + */ + var runningNonEmberDebugJS = true; + exports.runningNonEmberDebugJS = runningNonEmberDebugJS; + if (runningNonEmberDebugJS) { + _emberMetal.warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); + } +}); +// reexports +enifed('ember-debug/warn', ['exports', 'ember-console', 'ember-metal', 'ember-debug/handlers'], function (exports, _emberConsole, _emberMetal, _emberDebugHandlers) { 'use strict'; + exports.registerHandler = registerHandler; + exports.default = warn; + + function registerHandler(handler) { + _emberDebugHandlers.registerHandler('warn', handler); + } + + registerHandler(function logWarning(message, options) { + _emberConsole.default.warn('WARNING: ' + message); + if ('trace' in _emberConsole.default) { + _emberConsole.default.trace(); + } + }); + + var missingOptionsDeprecation = 'When calling `Ember.warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; + exports.missingOptionsDeprecation = missingOptionsDeprecation; + var missingOptionsIdDeprecation = 'When calling `Ember.warn` you must provide `id` in options.'; + + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; /** - `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. + @module ember + @submodule ember-debug + */ + + /** + Display a warning with the provided message. - `Ember.LinkComponent` components are invoked with {{#link-to}}. Properties - of this class can be overridden with `reopen` to customize application-wide - behavior. + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. - @class LinkComponent - @namespace Ember - @extends Ember.Component - @see {Ember.Templates.helpers.link-to} - @private - **/ - var LinkComponent = _emberGlimmerComponent.default.extend({ - layout: _emberGlimmerTemplatesLinkTo.default, + @method warn + @param {String} message A warning to display. + @param {Boolean} test An optional boolean. If falsy, the warning + will be displayed. + @param {Object} options An object that can be used to pass a unique + `id` for this warning. The `id` can be used by Ember debugging tools + to change the behavior (raise, log, or silence) for that specific warning. + The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" + @for Ember + @public + @since 1.0.0 + */ - tagName: 'a', + function warn(message, test, options) { + if (!options) { + _emberMetal.deprecate(missingOptionsDeprecation, false, { + id: 'ember-debug.warn-options-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } - /** - @deprecated Use current-when instead. - @property currentWhen - @private - */ - currentWhen: _emberRuntime.deprecatingAlias('current-when', { id: 'ember-routing-view.deprecated-current-when', until: '3.0.0' }), + if (options && !options.id) { + _emberMetal.deprecate(missingOptionsIdDeprecation, false, { + id: 'ember-debug.warn-id-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } - /** - Used to determine when this `LinkComponent` is active. - @property currentWhen - @public - */ - 'current-when': null, + _emberDebugHandlers.invoke.apply(undefined, ['warn'].concat(babelHelpers.slice.call(arguments))); + } +}); +enifed('ember-environment/global', ['exports'], function (exports) { + /* globals global, window, self, mainContext */ - /** - Sets the `title` attribute of the `LinkComponent`'s HTML element. - @property title - @default null - @public - **/ - title: null, + // from lodash to catch fake globals + 'use strict'; - /** - Sets the `rel` attribute of the `LinkComponent`'s HTML element. - @property rel - @default null - @public - **/ - rel: null, + function checkGlobal(value) { + return value && value.Object === Object ? value : undefined; + } - /** - Sets the `tabindex` attribute of the `LinkComponent`'s HTML element. - @property tabindex - @default null - @public - **/ - tabindex: null, + // element ids can ruin global miss checks + function checkElementIdShadowing(value) { + return value && value.nodeType === undefined ? value : undefined; + } - /** - Sets the `target` attribute of the `LinkComponent`'s HTML element. - @since 1.8.0 - @property target - @default null - @public - **/ - target: null, + // export real global + exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper + new Function('return this')(); + // eval outside of strict mode +}); +enifed('ember-environment/index', ['exports', 'ember-environment/global', 'ember-environment/utils'], function (exports, _emberEnvironmentGlobal, _emberEnvironmentUtils) { + /* globals module */ + 'use strict'; - /** - The CSS class to apply to `LinkComponent`'s element when its `active` - property is `true`. - @property activeClass - @type String - @default active - @public - **/ - activeClass: 'active', + /** + 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 + backwards compatibility with earlier versions of Ember). The `EmberENV` + hash must be created before loading Ember. + + @class EmberENV + @type Object + @public + */ + var ENV = typeof _emberEnvironmentGlobal.default.EmberENV === 'object' && _emberEnvironmentGlobal.default.EmberENV || typeof _emberEnvironmentGlobal.default.ENV === 'object' && _emberEnvironmentGlobal.default.ENV || {}; - /** - The CSS class to apply to `LinkComponent`'s element when its `loading` - property is `true`. - @property loadingClass - @type String - @default loading - @private - **/ - loadingClass: 'loading', + exports.ENV = ENV; + // ENABLE_ALL_FEATURES was documented, but you can't actually enable non optional features. + if (ENV.ENABLE_ALL_FEATURES) { + ENV.ENABLE_OPTIONAL_FEATURES = true; + } - /** - The CSS class to apply to a `LinkComponent`'s element when its `disabled` - property is `true`. - @property disabledClass - @type String - @default disabled - @private - **/ - disabledClass: 'disabled', - _isDisabled: false, + /** + Determines whether Ember should add to `Array`, `Function`, and `String` + native object prototypes, a few extra methods in order to provide a more + friendly API. + + We generally recommend leaving this option set to true however, if you need + to turn it off, you can add the configuration property + `EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`. + + Note, when disabled (the default configuration for Ember Addons), you will + instead have to access all methods and functions from the Ember + namespace. + + @property EXTEND_PROTOTYPES + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.EXTEND_PROTOTYPES = _emberEnvironmentUtils.normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); - /** - Determines whether the `LinkComponent` will trigger routing via - the `replaceWith` routing strategy. - @property replace - @type Boolean - @default false - @public - **/ - replace: false, + /** + The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log + a full stack trace during deprecation warnings. + + @property LOG_STACKTRACE_ON_DEPRECATION + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.LOG_STACKTRACE_ON_DEPRECATION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); + /** + The `LOG_VERSION` property, when true, tells Ember to log versions of all + dependent libraries in use. + + @property LOG_VERSION + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.LOG_VERSION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_VERSION); + + // default false + ENV.MODEL_FACTORY_INJECTIONS = _emberEnvironmentUtils.defaultFalse(ENV.MODEL_FACTORY_INJECTIONS); + + /** + Debug parameter you can turn on. This will log all bindings that fire to + the console. This should be disabled in production code. Note that you + can also enable this from the console or temporarily. + + @property LOG_BINDINGS + @for EmberENV + @type Boolean + @default false + @public + */ + ENV.LOG_BINDINGS = _emberEnvironmentUtils.defaultFalse(ENV.LOG_BINDINGS); + + ENV.RAISE_ON_DEPRECATION = _emberEnvironmentUtils.defaultFalse(ENV.RAISE_ON_DEPRECATION); + + // check if window exists and actually is the global + var hasDOM = typeof window !== 'undefined' && window === _emberEnvironmentGlobal.default && window.document && window.document.createElement && !ENV.disableBrowserEnvironment; // is this a public thing? + + // legacy imports/exports/lookup stuff (should we keep this??) + var originalContext = _emberEnvironmentGlobal.default.Ember || {}; + + var context = { + // import jQuery + imports: originalContext.imports || _emberEnvironmentGlobal.default, + // export Ember + exports: originalContext.exports || _emberEnvironmentGlobal.default, + // search for Namespaces + lookup: originalContext.lookup || _emberEnvironmentGlobal.default + }; + + exports.context = context; + // TODO: cleanup single source of truth issues with this stuff + var environment = hasDOM ? { + hasDOM: true, + isChrome: !!window.chrome && !window.opera, + isFirefox: typeof InstallTrigger !== 'undefined', + isPhantom: !!window.callPhantom, + location: window.location, + history: window.history, + userAgent: window.navigator.userAgent, + window: window + } : { + hasDOM: false, + isChrome: false, + isFirefox: false, + isPhantom: false, + location: null, + history: null, + userAgent: 'Lynx (textmode)', + window: null + }; + exports.environment = environment; +}); +enifed("ember-environment/utils", ["exports"], function (exports) { + "use strict"; + + exports.defaultTrue = defaultTrue; + exports.defaultFalse = defaultFalse; + exports.normalizeExtendPrototypes = normalizeExtendPrototypes; + + function defaultTrue(v) { + return v === false ? false : true; + } + + function defaultFalse(v) { + return v === true ? true : false; + } + + function normalizeExtendPrototypes(obj) { + if (obj === false) { + return { String: false, Array: false, Function: false }; + } else if (!obj || obj === true) { + return { String: true, Array: true, Function: true }; + } else { + return { + String: defaultTrue(obj.String), + Array: defaultTrue(obj.Array), + Function: defaultTrue(obj.Function) + }; + } + } +}); +enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; + + /** + @module ember + @submodule ember-extension-support + */ + + /** + The `ContainerDebugAdapter` helps the container and resolver interface + with tools that debug Ember such as the + [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class can be extended by a custom resolver implementer + to override some of the methods with library-specific code. + + The methods likely to be overridden are: + + * `canCatalogEntriesByType` + * `catalogEntriesByType` + + The adapter will need to be registered + in the application's container as `container-debug-adapter:main`. + + Example: + + ```javascript + Application.initializer({ + name: "containerDebugAdapter", + + initialize(application) { + application.register('container-debug-adapter:main', require('app/container-debug-adapter')); + } + }); + ``` + + @class ContainerDebugAdapter + @namespace Ember + @extends Ember.Object + @since 1.5.0 + @public + */ + exports.default = _emberRuntime.Object.extend({ /** - By default the `{{link-to}}` component will bind to the `href` and - `title` attributes. It's discouraged that you override these defaults, - however you can push onto the array if needed. - @property attributeBindings - @type Array | String - @default ['title', 'rel', 'tabindex', 'target'] + The resolver instance of the application + being debugged. This property will be injected + on creation. + @property resolver + @default null @public */ - attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'], + resolver: null, /** - By default the `{{link-to}}` component will bind to the `active`, `loading`, - and `disabled` classes. It is discouraged to override these directly. - @property classNameBindings - @type Array - @default ['active', 'loading', 'disabled', 'ember-transitioning-in', 'ember-transitioning-out'] + Returns true if it is possible to catalog a list of available + classes in the resolver for a given type. + @method canCatalogEntriesByType + @param {String} type The type. e.g. "model", "controller", "route". + @return {boolean} whether a list is available for this type. @public */ - classNameBindings: ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'], + canCatalogEntriesByType: function (type) { + if (type === 'model' || type === 'template') { + return false; + } - /** - By default the `{{link-to}}` component responds to the `click` event. You - can override this globally by setting this property to your custom - event name. - This is particularly useful on mobile when one wants to avoid the 300ms - click delay using some sort of custom `tap` event. - @property eventName - @type String - @default click - @private - */ - eventName: 'click', + return true; + }, - // this is doc'ed here so it shows up in the events - // section of the API documentation, which is where - // people will likely go looking for it. /** - Triggers the `LinkComponent`'s routing behavior. If - `eventName` is changed to a value other than `click` - the routing behavior will trigger on that custom event - instead. - @event click - @private + Returns the available classes a given type. + @method catalogEntriesByType + @param {String} type The type. e.g. "model", "controller", "route". + @return {Array} An array of strings. + @public */ + catalogEntriesByType: function (type) { + var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); + var types = _emberRuntime.A(); + var typeSuffixRegex = new RegExp(_emberRuntime.String.classify(type) + '$'); - /** - An overridable method called when `LinkComponent` objects are instantiated. - Example: - ```javascript - App.MyLinkComponent = Ember.LinkComponent.extend({ - init: function() { - this._super(...arguments); - Ember.Logger.log('Event is ' + this.get('eventName')); + namespaces.forEach(function (namespace) { + if (namespace !== _emberMetal.default) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { + continue; + } + if (typeSuffixRegex.test(key)) { + var klass = namespace[key]; + if (_emberRuntime.typeOf(klass) === 'class') { + types.push(_emberRuntime.String.dasherize(key.replace(typeSuffixRegex, ''))); + } + } + } } }); - ``` - NOTE: If you do override `init` for a framework class like `Ember.View`, - be sure to call `this._super(...arguments)` in your - `init` declaration! If you don't, Ember may not have an opportunity to - do important setup work, and you'll see strange behavior in your - application. - @method init - @private - */ + return types; + } + }); +}); +// Ember as namespace +enifed('ember-extension-support/data_adapter', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'container', 'ember-application'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _container, _emberApplication) { + 'use strict'; + + /** + @module ember + @submodule ember-extension-support + */ + + /** + The `DataAdapter` helps a data persistence library + interface with tools that debug Ember such + as the [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class will be extended by a persistence library + which will override some of the methods with + library-specific code. + + The methods likely to be overridden are: + + * `getFilters` + * `detect` + * `columnsForType` + * `getRecords` + * `getRecordColumnValues` + * `getRecordKeywords` + * `getRecordFilterValues` + * `getRecordColor` + * `observeRecord` + + The adapter will need to be registered + in the application's container as `dataAdapter:main`. + + Example: + + ```javascript + Application.initializer({ + name: "data-adapter", + + initialize: function(application) { + application.register('data-adapter:main', DS.DataAdapter); + } + }); + ``` + + @class DataAdapter + @namespace Ember + @extends EmberObject + @public + */ + exports.default = _emberRuntime.Object.extend({ init: function () { this._super.apply(this, arguments); - - // Map desired event name to invoke function - var eventName = _emberMetal.get(this, 'eventName'); - this.on(eventName, this, this._invoke); + this.releaseMethods = _emberRuntime.A(); }, - _routing: _emberRuntime.inject.service('-routing'), + /** + The container-debug-adapter which is used + to list all models. + @property containerDebugAdapter + @default undefined + @since 1.5.0 + @public + **/ + containerDebugAdapter: undefined, /** - Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass` - CSS `class` to the element when the link is disabled. - When `true` interactions with the element will not trigger route changes. - @property disabled - @private + The number of attributes to send + as columns. (Enough to make the record + identifiable). + @private + @property attributeLimit + @default 3 + @since 1.3.0 */ - disabled: _emberMetal.computed({ - get: function (key, value) { - return false; - }, - set: function (key, value) { - if (value !== undefined) { - this.set('_isDisabled', value); - } - - return value ? _emberMetal.get(this, 'disabledClass') : false; - } - }), - - _computeActive: function (routerState) { - if (_emberMetal.get(this, 'loading')) { - return false; - } - - var routing = _emberMetal.get(this, '_routing'); - var models = _emberMetal.get(this, 'models'); - var resolvedQueryParams = _emberMetal.get(this, 'resolvedQueryParams'); + attributeLimit: 3, - var currentWhen = _emberMetal.get(this, 'current-when'); - var isCurrentWhenSpecified = !!currentWhen; - currentWhen = currentWhen || _emberMetal.get(this, 'qualifiedRouteName'); - currentWhen = currentWhen.split(' '); + /** + Ember Data > v1.0.0-beta.18 + requires string model names to be passed + around instead of the actual factories. + This is a stamp for the Ember Inspector + to differentiate between the versions + to be able to support older versions too. + @public + @property acceptsModelName + */ + acceptsModelName: true, - for (var i = 0; i < currentWhen.length; i++) { - if (routing.isActiveForRoute(models, resolvedQueryParams, currentWhen[i], routerState, isCurrentWhenSpecified)) { - return _emberMetal.get(this, 'activeClass'); - } - } + /** + Stores all methods that clear observers. + These methods will be called on destruction. + @private + @property releaseMethods + @since 1.3.0 + */ + releaseMethods: _emberRuntime.A(), - return false; + /** + Specifies how records can be filtered. + Records returned will need to have a `filterValues` + property with a key for every name in the returned array. + @public + @method getFilters + @return {Array} List of objects defining filters. + The object should have a `name` and `desc` property. + */ + getFilters: function () { + return _emberRuntime.A(); }, /** - Accessed as a classname binding to apply the `LinkComponent`'s `activeClass` - CSS `class` to the element when the link is active. - A `LinkComponent` is considered active when its `currentWhen` property is `true` - or the application's current route is the route the `LinkComponent` would trigger - transitions into. - The `currentWhen` property can match against multiple routes by separating - route names using the ` ` (space) character. - @property active - @private + Fetch the model types and observe them for changes. + @public + @method watchModelTypes + @param {Function} typesAdded Callback to call to add types. + Takes an array of objects containing wrapped types (returned from `wrapModelType`). + @param {Function} typesUpdated Callback to call when a type has changed. + Takes an array of objects containing wrapped types. + @return {Function} Method to call to remove all observers */ - active: _emberMetal.computed('attrs.params', '_routing.currentState', function computeLinkToComponentActive() { - var currentState = _emberMetal.get(this, '_routing.currentState'); - if (!currentState) { - return false; - } - - return this._computeActive(currentState); - }), + watchModelTypes: function (typesAdded, typesUpdated) { + var _this = this; - willBeActive: _emberMetal.computed('_routing.targetState', function computeLinkToComponentWillBeActive() { - var routing = _emberMetal.get(this, '_routing'); - var targetState = _emberMetal.get(routing, 'targetState'); - if (_emberMetal.get(routing, 'currentState') === targetState) { - return; - } + var modelTypes = this.getModelTypes(); + var releaseMethods = _emberRuntime.A(); + var typesToSend = undefined; - return !!this._computeActive(targetState); - }), + typesToSend = modelTypes.map(function (type) { + var klass = type.klass; + var wrapped = _this.wrapModelType(klass, type.name); + releaseMethods.push(_this.observeModelType(type.name, typesUpdated)); + return wrapped; + }); - transitioningIn: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningIn() { - var willBeActive = _emberMetal.get(this, 'willBeActive'); - if (typeof willBeActive === 'undefined') { - return false; - } + typesAdded(typesToSend); - return !_emberMetal.get(this, 'active') && willBeActive && 'ember-transitioning-in'; - }), + var release = function () { + releaseMethods.forEach(function (fn) { + return fn(); + }); + _this.releaseMethods.removeObject(release); + }; + this.releaseMethods.pushObject(release); + return release; + }, - transitioningOut: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningOut() { - var willBeActive = _emberMetal.get(this, 'willBeActive'); - if (typeof willBeActive === 'undefined') { - return false; + _nameToClass: function (type) { + if (typeof type === 'string') { + var owner = _emberUtils.getOwner(this); + type = owner[_container.FACTORY_FOR]('model:' + type).class; } - - return _emberMetal.get(this, 'active') && !willBeActive && 'ember-transitioning-out'; - }), + return type; + }, /** - Event handler that invokes the link, activating the associated route. - @method _invoke - @param {Event} event - @private + Fetch the records of a given type and observe them for changes. + @public + @method watchRecords + @param {String} modelName The model name. + @param {Function} recordsAdded Callback to call to add records. + Takes an array of objects containing wrapped records. + The object should have the following properties: + columnValues: {Object} The key and value of a table cell. + object: {Object} The actual record object. + @param {Function} recordsUpdated Callback to call when a record has changed. + Takes an array of objects containing wrapped records. + @param {Function} recordsRemoved Callback to call when a record has removed. + Takes the following parameters: + index: The array index where the records were removed. + count: The number of records removed. + @return {Function} Method to call to remove all observers. */ - _invoke: function (event) { - if (!_emberViews.isSimpleClick(event)) { - return true; - } + watchRecords: function (modelName, recordsAdded, recordsUpdated, recordsRemoved) { + var _this2 = this; - var preventDefault = _emberMetal.get(this, 'preventDefault'); - var targetAttribute = _emberMetal.get(this, 'target'); + var releaseMethods = _emberRuntime.A(); + var klass = this._nameToClass(modelName); + var records = this.getRecords(klass, modelName); + var release = undefined; - if (preventDefault !== false) { - if (!targetAttribute || targetAttribute === '_self') { - event.preventDefault(); - } + function recordUpdated(updatedRecord) { + recordsUpdated([updatedRecord]); } - if (_emberMetal.get(this, 'bubbles') === false) { - event.stopPropagation(); - } + var recordsToSend = records.map(function (record) { + releaseMethods.push(_this2.observeRecord(record, recordUpdated)); + return _this2.wrapRecord(record); + }); - if (_emberMetal.get(this, '_isDisabled')) { - return false; - } + var contentDidChange = function (array, idx, removedCount, addedCount) { + for (var i = idx; i < idx + addedCount; i++) { + var record = _emberRuntime.objectAt(array, i); + var wrapped = _this2.wrapRecord(record); + releaseMethods.push(_this2.observeRecord(record, recordUpdated)); + recordsAdded([wrapped]); + } - if (_emberMetal.get(this, 'loading')) { - _emberConsole.default.warn('This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'); - return false; - } + if (removedCount) { + recordsRemoved(idx, removedCount); + } + }; - if (targetAttribute && targetAttribute !== '_self') { - return false; - } - - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var models = _emberMetal.get(this, 'models'); - var queryParams = _emberMetal.get(this, 'queryParams.values'); - var shouldReplace = _emberMetal.get(this, 'replace'); + var observer = { didChange: contentDidChange, willChange: function () { + return this; + } }; + _emberRuntime.addArrayObserver(records, this, observer); - var payload = { - queryParams: queryParams, - routeName: qualifiedRouteName + release = function () { + releaseMethods.forEach(function (fn) { + return fn(); + }); + _emberRuntime.removeArrayObserver(records, _this2, observer); + _this2.releaseMethods.removeObject(release); }; - _emberMetal.flaggedInstrument('interaction.link-to', payload, this._generateTransition(payload, qualifiedRouteName, models, queryParams, shouldReplace)); - }, + recordsAdded(recordsToSend); - _generateTransition: function (payload, qualifiedRouteName, models, queryParams, shouldReplace) { - var routing = _emberMetal.get(this, '_routing'); - return function () { - payload.transition = routing.transitionTo(qualifiedRouteName, models, queryParams, shouldReplace); - }; + this.releaseMethods.pushObject(release); + return release; }, - queryParams: null, - - qualifiedRouteName: _emberMetal.computed('targetRouteName', '_routing.currentState', function computeLinkToComponentQualifiedRouteName() { - var params = _emberMetal.get(this, 'params').slice(); - var lastParam = params[params.length - 1]; - if (lastParam && lastParam.isQueryParams) { - params.pop(); - } - var onlyQueryParamsSupplied = this[_emberGlimmerComponent.HAS_BLOCK] ? params.length === 0 : params.length === 1; - if (onlyQueryParamsSupplied) { - return _emberMetal.get(this, '_routing.currentRouteName'); - } - return _emberMetal.get(this, 'targetRouteName'); - }), - - resolvedQueryParams: _emberMetal.computed('queryParams', function computeLinkToComponentResolvedQueryParams() { - var resolvedQueryParams = {}; - var queryParams = _emberMetal.get(this, 'queryParams'); - - if (!queryParams) { - return resolvedQueryParams; - } + /** + Clear all observers before destruction + @private + @method willDestroy + */ + willDestroy: function () { + this._super.apply(this, arguments); + this.releaseMethods.forEach(function (fn) { + return fn(); + }); + }, - var values = queryParams.values; - for (var key in values) { - if (!values.hasOwnProperty(key)) { - continue; - } - resolvedQueryParams[key] = values[key]; - } + /** + Detect whether a class is a model. + Test that against the model class + of your persistence library. + @private + @method detect + @param {Class} klass The class to test. + @return boolean Whether the class is a model class or not. + */ + detect: function (klass) { + return false; + }, - return resolvedQueryParams; - }), + /** + Get the columns for a given model type. + @private + @method columnsForType + @param {Class} type The model type. + @return {Array} An array of columns of the following format: + name: {String} The name of the column. + desc: {String} Humanized description (what would show in a table column name). + */ + columnsForType: function (type) { + return _emberRuntime.A(); + }, /** - Sets the element's `href` attribute to the url for - the `LinkComponent`'s targeted route. - If the `LinkComponent`'s `tagName` is changed to a value other - than `a`, this property will be ignored. - @property href - @private + Adds observers to a model type class. + @private + @method observeModelType + @param {String} modelName The model type name. + @param {Function} typesUpdated Called when a type is modified. + @return {Function} The function to call to remove observers. */ - href: _emberMetal.computed('models', 'qualifiedRouteName', function computeLinkToComponentHref() { - if (_emberMetal.get(this, 'tagName') !== 'a') { - return; - } - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var models = _emberMetal.get(this, 'models'); + observeModelType: function (modelName, typesUpdated) { + var _this3 = this; - if (_emberMetal.get(this, 'loading')) { - return _emberMetal.get(this, 'loadingHref'); - } + var klass = this._nameToClass(modelName); + var records = this.getRecords(klass, modelName); - var routing = _emberMetal.get(this, '_routing'); - var queryParams = _emberMetal.get(this, 'queryParams.values'); + function onChange() { + typesUpdated([this.wrapModelType(klass, modelName)]); + } - _emberMetal.runInDebug(function () { - /* - * Unfortunately, to get decent error messages, we need to do this. - * In some future state we should be able to use a "feature flag" - * which allows us to strip this without needing to call it twice. - * - * if (isDebugBuild()) { - * // Do the useful debug thing, probably including try/catch. - * } else { - * // Do the performant thing. - * } - */ - try { - routing.generateURL(qualifiedRouteName, models, queryParams); - } catch (e) { - _emberMetal.assert('You attempted to define a `{{link-to "' + qualifiedRouteName + '"}}` but did not pass the parameters required for generating its dynamic segments. ' + e.message); + var observer = { + didChange: function () { + _emberMetal.run.scheduleOnce('actions', this, onChange); + }, + willChange: function () { + return this; } - }); + }; - return routing.generateURL(qualifiedRouteName, models, queryParams); - }), + _emberRuntime.addArrayObserver(records, this, observer); - loading: _emberMetal.computed('_modelsAreLoaded', 'qualifiedRouteName', function computeLinkToComponentLoading() { - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var modelsAreLoaded = _emberMetal.get(this, '_modelsAreLoaded'); + var release = function () { + return _emberRuntime.removeArrayObserver(records, _this3, observer); + }; - if (!modelsAreLoaded || qualifiedRouteName == null) { - return _emberMetal.get(this, 'loadingClass'); - } - }), + return release; + }, - _modelsAreLoaded: _emberMetal.computed('models', function computeLinkToComponentModelsAreLoaded() { - var models = _emberMetal.get(this, 'models'); - for (var i = 0; i < models.length; i++) { - if (models[i] == null) { - return false; - } - } + /** + Wraps a given model type and observes changes to it. + @private + @method wrapModelType + @param {Class} klass A model class. + @param {String} modelName Name of the class. + @return {Object} Contains the wrapped type and the function to remove observers + Format: + type: {Object} The wrapped type. + The wrapped type has the following format: + name: {String} The name of the type. + count: {Integer} The number of records available. + columns: {Columns} An array of columns to describe the record. + object: {Class} The actual Model type class. + release: {Function} The function to remove observers. + */ + wrapModelType: function (klass, name) { + var records = this.getRecords(klass, name); + var typeToSend = undefined; - return true; - }), + typeToSend = { + name: name, + count: _emberMetal.get(records, 'length'), + columns: this.columnsForType(klass), + object: klass + }; - _getModels: function (params) { - var modelCount = params.length - 1; - var models = new Array(modelCount); + return typeToSend; + }, - for (var i = 0; i < modelCount; i++) { - var value = params[i + 1]; + /** + Fetches all models defined in the application. + @private + @method getModelTypes + @return {Array} Array of model types. + */ + getModelTypes: function () { + var _this4 = this; - while (_emberRuntime.ControllerMixin.detect(value)) { - _emberMetal.deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' + (this.parentView ? 'Please update `' + this.parentView + '` to use `{{link-to "post" someController.model}}` instead.' : ''), false, { id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }); - value = value.get('model'); - } + var containerDebugAdapter = this.get('containerDebugAdapter'); + var types = undefined; - models[i] = value; + if (containerDebugAdapter.canCatalogEntriesByType('model')) { + types = containerDebugAdapter.catalogEntriesByType('model'); + } else { + types = this._getObjectsOnNamespaces(); } - return models; + // New adapters return strings instead of classes. + types = _emberRuntime.A(types).map(function (name) { + return { + klass: _this4._nameToClass(name), + name: name + }; + }); + types = _emberRuntime.A(types).filter(function (type) { + return _this4.detect(type.klass); + }); + + return _emberRuntime.A(types); }, /** - The default href value to use while a link-to is loading. - Only applies when tagName is 'a' - @property loadingHref - @type String - @default # - @private + Loops over all namespaces and all objects + attached to them. + @private + @method _getObjectsOnNamespaces + @return {Array} Array of model type strings. */ - loadingHref: '#', + _getObjectsOnNamespaces: function () { + var _this5 = this; - didReceiveAttrs: function () { - var queryParams = undefined; + var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); + var types = _emberRuntime.A(); - var params = _emberMetal.get(this, 'params'); + namespaces.forEach(function (namespace) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { + continue; + } + // Even though we will filter again in `getModelTypes`, + // we should not call `lookupFactory` on non-models + // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) + if (!_this5.detect(namespace[key])) { + continue; + } + var _name = _emberRuntime.String.dasherize(key); + if (!(namespace instanceof _emberApplication.Application) && namespace.toString()) { + _name = namespace + '/' + _name; + } + types.push(_name); + } + }); + return types; + }, - if (params) { - // Do not mutate params in place - params = params.slice(); - } + /** + Fetches all loaded records for a given type. + @private + @method getRecords + @return {Array} An array of records. + This array will be observed for changes, + so it should update when new records are added/removed. + */ + getRecords: function (type) { + return _emberRuntime.A(); + }, - _emberMetal.assert('You must provide one or more parameters to the link-to component.', (function () { - if (!params) { - return false; - } + /** + Wraps a record and observers changes to it. + @private + @method wrapRecord + @param {Object} record The record instance. + @return {Object} The wrapped record. Format: + columnValues: {Array} + searchKeywords: {Array} + */ + wrapRecord: function (record) { + var recordToSend = { object: record }; - return params.length; - })()); + recordToSend.columnValues = this.getRecordColumnValues(record); + recordToSend.searchKeywords = this.getRecordKeywords(record); + recordToSend.filterValues = this.getRecordFilterValues(record); + recordToSend.color = this.getRecordColor(record); - var disabledWhen = _emberMetal.get(this, 'disabledWhen'); - if (disabledWhen !== undefined) { - this.set('disabled', disabledWhen); - } + return recordToSend; + }, - // Process the positional arguments, in order. - // 1. Inline link title comes first, if present. - if (!this[_emberGlimmerComponent.HAS_BLOCK]) { - this.set('linkTitle', params.shift()); - } + /** + Gets the values for each column. + @private + @method getRecordColumnValues + @return {Object} Keys should match column names defined + by the model type. + */ + getRecordColumnValues: function (record) { + return {}; + }, - // 2. `targetRouteName` is now always at index 0. - this.set('targetRouteName', params[0]); + /** + Returns keywords to match when searching records. + @private + @method getRecordKeywords + @return {Array} Relevant keywords for search. + */ + getRecordKeywords: function (record) { + return _emberRuntime.A(); + }, - // 3. The last argument (if still remaining) is the `queryParams` object. - var lastParam = params[params.length - 1]; + /** + Returns the values of filters defined by `getFilters`. + @private + @method getRecordFilterValues + @param {Object} record The record instance. + @return {Object} The filter values. + */ + getRecordFilterValues: function (record) { + return {}; + }, - if (lastParam && lastParam.isQueryParams) { - queryParams = params.pop(); - } else { - queryParams = { values: {} }; - } - this.set('queryParams', queryParams); + /** + Each record can have a color that represents its state. + @private + @method getRecordColor + @param {Object} record The record instance + @return {String} The records color. + Possible options: black, red, blue, green. + */ + getRecordColor: function (record) { + return null; + }, - // 4. Any remaining indices (excepting `targetRouteName` at 0) are `models`. - if (params.length > 1) { - this.set('models', this._getModels(params)); - } else { - this.set('models', []); - } + /** + Observes all relevant properties and re-sends the wrapped record + when a change occurs. + @private + @method observerRecord + @param {Object} record The record instance. + @param {Function} recordUpdated The callback to call when a record is updated. + @return {Function} The function to call to remove all observers. + */ + observeRecord: function (record, recordUpdated) { + return function () {}; } }); +}); +enifed('ember-extension-support/index', ['exports', 'ember-extension-support/data_adapter', 'ember-extension-support/container_debug_adapter'], function (exports, _emberExtensionSupportData_adapter, _emberExtensionSupportContainer_debug_adapter) { + /** + @module ember + @submodule ember-extension-support + */ - LinkComponent.toString = function () { - return 'LinkComponent'; - }; - - LinkComponent.reopenClass({ - positionalParams: 'params' - }); + 'use strict'; - exports.default = LinkComponent; + exports.DataAdapter = _emberExtensionSupportData_adapter.default; + exports.ContainerDebugAdapter = _emberExtensionSupportContainer_debug_adapter.default; }); -enifed('ember-glimmer/components/text_area', ['exports', 'ember-glimmer/component', 'ember-views', 'ember-glimmer/templates/empty'], function (exports, _emberGlimmerComponent, _emberViews, _emberGlimmerTemplatesEmpty) { +enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'ember-runtime', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference', '@glimmer/runtime'], function (exports, _emberUtils, _emberViews, _emberRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference, _glimmerRuntime) { + 'use strict'; + + var _CoreView$extend; + + var DIRTY_TAG = _emberUtils.symbol('DIRTY_TAG'); + exports.DIRTY_TAG = DIRTY_TAG; + var ARGS = _emberUtils.symbol('ARGS'); + exports.ARGS = ARGS; + var ROOT_REF = _emberUtils.symbol('ROOT_REF'); + exports.ROOT_REF = ROOT_REF; + var IS_DISPATCHING_ATTRS = _emberUtils.symbol('IS_DISPATCHING_ATTRS'); + exports.IS_DISPATCHING_ATTRS = IS_DISPATCHING_ATTRS; + var HAS_BLOCK = _emberUtils.symbol('HAS_BLOCK'); + exports.HAS_BLOCK = HAS_BLOCK; + var BOUNDS = _emberUtils.symbol('BOUNDS'); + + exports.BOUNDS = BOUNDS; /** @module ember @submodule ember-glimmer */ - 'use strict'; /** - `{{textarea}}` inserts a new instance of ` + ```app/components/person-profile.hbs +

    {{person.title}}

    + {{! Executed in the component's context. }} + {{yield}} {{! block contents }} ``` - Bound: + If you want to customize the component, in order to + handle events or actions, you implement a subclass + of `Ember.Component` named after the name of the + component. - In the following example, the `writtenWords` property on `App.ApplicationController` - will be updated live as the user types 'Lots of text that IS bound' into - the text area of their browser's window. + For example, you could implement the action + `hello` for the `person-profile` component: - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound" + ```app/components/person-profile.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + actions: { + hello(name) { + console.log("Hello", name); + } + } }); ``` - ```handlebars - {{textarea value=writtenWords}} - ``` + And then use it in the component's template: - Would result in the following HTML: + ```app/templates/components/person-profile.hbs +

    {{person.title}}

    + {{yield}} + + ``` + + Components must have a `-` in their name to avoid + conflicts with built-in controls that wrap HTML + elements. This is consistent with the same + requirement in web components. + + + ## HTML Tag + + The default HTML tag name used for a component's DOM representation is `div`. + This can be customized by setting the `tagName` property. + The following component class: + + ```app/components/emphasized-paragraph.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'em' + }); + ``` + + Would result in instances with the following HTML: ```html - + ``` - If you wanted a one way binding between the text area and a div tag - somewhere else on your screen, you could use `Ember.computed.oneWay`: - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound", - outputWrittenWords: Ember.computed.oneWay("writtenWords") + ## HTML `class` Attribute + + The HTML `class` attribute of a component's tag can be set by providing a + `classNames` property that is set to an array of strings: + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNames: ['my-class', 'my-other-class'] }); ``` - ```handlebars - {{textarea value=writtenWords}} -
    - {{outputWrittenWords}} -
    + Will result in component instances with an HTML representation of: + + ```html +
    ``` - Would result in the following HTML: + `class` attribute values can also be set by providing a `classNameBindings` + property set to an array of properties names for the component. The return value + of these properties will be added as part of the value for the components's `class` + attribute. These properties can be computed properties: + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['propertyA', 'propertyB'], + propertyA: 'from-a', + propertyB: Ember.computed(function() { + if (someLogic) { return 'from-b'; } + }) + }); + ``` + + Will result in component instances with an HTML representation of: ```html - - <-- the following div will be updated in real time as you type --> -
    - Lots of text that IS bound -
    +
    ``` - Finally, this example really shows the power and ease of Ember when two - properties are bound to eachother via `Ember.computed.alias`. Type into - either text area box and they'll both stay in sync. Note that - `Ember.computed.alias` costs more in terms of performance, so only use it when - your really binding in both directions: + If the value of a class name binding returns a boolean the property name + itself will be used as the class name if the property is true. + The class name will not be added if the value is `false` or `undefined`. - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound", - twoWayWrittenWords: Ember.computed.alias("writtenWords") + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['hovered'], + hovered: true }); ``` - ```handlebars - {{textarea value=writtenWords}} - {{textarea value=twoWayWrittenWords}} + Will result in component instances with an HTML representation of: + + ```html +
    + ``` + + When using boolean class name bindings you can supply a string value other + than the property name for use as the `class` HTML attribute by appending the + preferred value after a ":" character when defining the binding: + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['awesome:so-very-cool'], + awesome: true + }); ``` + Will result in component instances with an HTML representation of: + ```html - - <-- both updated in real time --> - +
    ``` - ### Actions + Boolean value class name bindings whose property names are in a + camelCase-style format will be converted to a dasherized format: - The helper can send multiple actions based on user events. - The action property defines the action which is send when - the user presses the return key. + ```app/components/my-widget.js + import Ember from 'ember'; - ```handlebars - {{input action="submit"}} + export default Ember.Component.extend({ + classNameBindings: ['isUrgent'], + isUrgent: true + }); ``` - The helper allows some user events to send actions. + Will result in component instances with an HTML representation of: - * `enter` - * `insert-newline` - * `escape-press` - * `focus-in` - * `focus-out` - * `key-press` + ```html +
    + ``` - For example, if you desire an action to be sent when the input is blurred, - you only need to setup the action name to the event name property. + Class name bindings can also refer to object values that are found by + traversing a path relative to the component itself: - ```handlebars - {{textarea focus-in="alertMessage"}} + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['messages.empty'], + messages: Ember.Object.create({ + empty: true + }) + }); ``` - See more about [Text Support Actions](/api/classes/Ember.TextArea.html) + Will result in component instances with an HTML representation of: - ### Extension + ```html +
    + ``` - Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing - arguments from the helper to `Ember.TextArea`'s `create` method. You can - extend the capabilities of text areas in your application by reopening this - class. For example, if you are building a Bootstrap project where `data-*` - attributes are used, you can globally add support for a `data-*` attribute - on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or - `Ember.TextSupport` and adding it to the `attributeBindings` concatenated - property: + If you want to add a class name for a property which evaluates to true and + and a different class name if it evaluates to false, you can pass a binding + like this: - ```javascript - Ember.TextArea.reopen({ - attributeBindings: ['data-error'] + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['isEnabled:enabled:disabled'], + isEnabled: true }); ``` - Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` - itself extends `Ember.Component`. Expect isolated component semantics, not - legacy 1.x view semantics (like `controller` being present). + Will result in component instances with an HTML representation of: - See more about [Ember components](/api/classes/Ember.Component.html) + ```html +
    + ``` - @method textarea - @for Ember.Templates.helpers - @param {Hash} options - @public - */ - - /** - The internal class used to create textarea element when the `{{textarea}}` - helper is used. + When isEnabled is `false`, the resulting HTML representation looks like + this: - See [Ember.Templates.helpers.textarea](/api/classes/Ember.Templates.helpers.html#method_textarea) for usage details. + ```html +
    + ``` - ## Layout and LayoutName properties + This syntax offers the convenience to add a class if a property is `false`: - Because HTML `textarea` elements do not contain inner HTML the `layout` and - `layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. + ```app/components/my-widget.js + import Ember from 'ember'; - @class TextArea - @namespace Ember - @extends Ember.Component - @uses Ember.TextSupport - @public - */ - exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { - classNames: ['ember-text-area'], - - layout: _emberGlimmerTemplatesEmpty.default, - - tagName: 'textarea', - attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir', 'value'], - rows: null, - cols: null - }); -}); -enifed('ember-glimmer/components/text_field', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-glimmer/component', 'ember-glimmer/templates/empty', 'ember-views'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty, _emberViews) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; - - var inputTypeTestElement = undefined; - var inputTypes = new _emberUtils.EmptyObject(); - function canSetTypeOfInput(type) { - if (type in inputTypes) { - return inputTypes[type]; - } - - // if running in outside of a browser always return the - // original type - if (!_emberEnvironment.environment.hasDOM) { - inputTypes[type] = type; - - return type; - } - - if (!inputTypeTestElement) { - inputTypeTestElement = document.createElement('input'); - } - - try { - inputTypeTestElement.type = type; - } catch (e) {} - - return inputTypes[type] = inputTypeTestElement.type === type; - } - - /** + // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false + export default Ember.Component.extend({ + classNameBindings: ['isEnabled::disabled'], + isEnabled: true + }); + ``` - The internal class used to create text inputs when the `{{input}}` - helper is used with `type` of `text`. + Will result in component instances with an HTML representation of: - See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. + ```html +
    + ``` - ## Layout and LayoutName properties + When the `isEnabled` property on the component is set to `false`, it will result + in component instances with an HTML representation of: - Because HTML `input` elements are self closing `layout` and `layoutName` - properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. + ```html +
    + ``` - @class TextField + Updates to the value of a class name binding will result in automatic + update of the HTML `class` attribute in the component's rendered HTML + representation. If the value becomes `false` or `undefined` the class name + will be removed. + Both `classNames` and `classNameBindings` are concatenated properties. See + [Ember.Object](/api/classes/Ember.Object.html) documentation for more + information about concatenated properties. + + + ## HTML Attributes + + The HTML attribute section of a component's tag can be set by providing an + `attributeBindings` property set to an array of property names on the component. + The return value of these properties will be used as the value of the component's + HTML associated attribute: + + ```app/components/my-anchor.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'a', + attributeBindings: ['href'], + href: 'http://google.com' + }); + ``` + + Will result in component instances with an HTML representation of: + + ```html + + ``` + + One property can be mapped on to another by placing a ":" between + the source property and the destination property: + + ```app/components/my-anchor.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'a', + attributeBindings: ['url:href'], + url: 'http://google.com' + }); + ``` + + Will result in component instances with an HTML representation of: + + ```html + + ``` + + Namespaced attributes (e.g. `xlink:href`) are supported, but have to be + mapped, since `:` is not a valid character for properties in Javascript: + + ```app/components/my-use.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'use', + attributeBindings: ['xlinkHref:xlink:href'], + xlinkHref: '#triangle' + }); + ``` + + Will result in component instances with an HTML representation of: + + ```html + + ``` + + If the return value of an `attributeBindings` monitored property is a boolean + the attribute will be present or absent depending on the value: + + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: false + }); + ``` + + Will result in a component instance with an HTML representation of: + + ```html + + ``` + + `attributeBindings` can refer to computed properties: + + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: Ember.computed(function() { + if (someLogic) { + return true; + } else { + return false; + } + }) + }); + ``` + + To prevent setting an attribute altogether, use `null` or `undefined` as the + return value of the `attributeBindings` monitored property: + + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'form', + attributeBindings: ['novalidate'], + novalidate: null + }); + ``` + + Updates to the property of an attribute binding will result in automatic + update of the HTML attribute in the component's rendered HTML representation. + `attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html) + documentation for more information about concatenated properties. + + + ## Layouts + + See [Ember.Templates.helpers.yield](/api/classes/Ember.Templates.helpers.html#method_yield) + for more information. + + + ## Responding to Browser Events + + Components can respond to user-initiated events in one of three ways: method + implementation, through an event manager, and through `{{action}}` helper use + in their template or layout. + + + ### Method Implementation + + Components can respond to user-initiated events by implementing a method that + matches the event name. A `jQuery.Event` object will be passed as the + argument to this method. + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + click(event) { + // will be called when an instance's + // rendered element is clicked + } + }); + ``` + + + ### `{{action}}` Helper + + See [Ember.Templates.helpers.action](/api/classes/Ember.Templates.helpers.html#method_action). + + + ### Event Names + + All of the event handling approaches described above respond to the same set + of events. The names of the built-in events are listed below. (The hash of + built-in events exists in `Ember.EventDispatcher`.) Additional, custom events + can be registered by using `Ember.Application.customEvents`. + + Touch events: + + * `touchStart` + * `touchMove` + * `touchEnd` + * `touchCancel` + + Keyboard events: + + * `keyDown` + * `keyUp` + * `keyPress` + + Mouse events: + + * `mouseDown` + * `mouseUp` + * `contextMenu` + * `click` + * `doubleClick` + * `mouseMove` + * `focusIn` + * `focusOut` + * `mouseEnter` + * `mouseLeave` + + Form events: + + * `submit` + * `change` + * `focusIn` + * `focusOut` + * `input` + + HTML5 drag and drop events: + + * `dragStart` + * `drag` + * `dragEnter` + * `dragLeave` + * `dragOver` + * `dragEnd` + * `drop` + + @class Component @namespace Ember - @extends Ember.Component - @uses Ember.TextSupport + @extends Ember.CoreView + @uses Ember.TargetActionSupport + @uses Ember.ClassNamesSupport + @uses Ember.ActionSupport + @uses Ember.ViewMixin + @uses Ember.ViewStateSupport @public */ - exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { - layout: _emberGlimmerTemplatesEmpty.default, - classNames: ['ember-text-field'], - tagName: 'input', - attributeBindings: ['accept', 'autocomplete', 'autosave', 'dir', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'inputmode', 'lang', 'list', 'max', 'min', 'multiple', 'name', 'pattern', 'size', 'step', 'type', 'value', 'width'], - - /** - The `value` attribute of the input element. As the user inputs text, this - property is updated live. - @property value - @type String - @default "" - @public - */ - value: '', + var Component = _emberViews.CoreView.extend(_emberViews.ChildViewsSupport, _emberViews.ViewStateSupport, _emberViews.ClassNamesSupport, _emberRuntime.TargetActionSupport, _emberViews.ActionSupport, _emberViews.ViewMixin, (_CoreView$extend = { + isComponent: true, - /** - The `type` attribute of the input element. - @property type - @type String - @default "text" - @public - */ - type: _emberMetal.computed({ - get: function () { - return 'text'; - }, + init: function () { + var _this = this; - set: function (key, value) { - var type = 'text'; + this._super.apply(this, arguments); + this[IS_DISPATCHING_ATTRS] = false; + this[DIRTY_TAG] = new _glimmerReference.DirtyableTag(); + this[ROOT_REF] = new _emberGlimmerUtilsReferences.RootReference(this); + this[BOUNDS] = null; - if (canSetTypeOfInput(value)) { - type = value; - } + // If a `defaultLayout` was specified move it to the `layout` prop. + // `layout` is no longer a CP, so this just ensures that the `defaultLayout` + // logic is supported with a deprecation + if (this.defaultLayout && !this.layout) { + _emberMetal.deprecate('Specifying `defaultLayout` to ' + this + ' is deprecated. Please use `layout` instead.', false, { + id: 'ember-views.component.defaultLayout', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-component-defaultlayout' + }); - return type; + this.layout = this.defaultLayout; } - }), - - /** - The `size` of the text field in characters. - @property size - @type String - @default null - @public - */ - size: null, - - /** - The `pattern` attribute of input element. - @property pattern - @type String - @default null - @public - */ - pattern: null, - - /** - The `min` attribute of input element used with `type="number"` or `type="range"`. - @property min - @type String - @default null - @since 1.4.0 - @public - */ - min: null, - - /** - The `max` attribute of input element used with `type="number"` or `type="range"`. - @property max - @type String - @default null - @since 1.4.0 - @public - */ - max: null - }); -}); -enifed('ember-glimmer/dom', ['exports', 'glimmer-runtime', 'glimmer-node'], function (exports, _glimmerRuntime, _glimmerNode) { - 'use strict'; - - exports.DOMChanges = _glimmerRuntime.DOMChanges; - exports.DOMTreeConstruction = _glimmerRuntime.DOMTreeConstruction; - exports.NodeDOMTreeConstruction = _glimmerNode.NodeDOMTreeConstruction; -}); -enifed('ember-glimmer/environment', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'glimmer-runtime', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/if-unless', 'ember-glimmer/utils/bindings', 'ember-glimmer/helpers/action', 'ember-glimmer/helpers/component', 'ember-glimmer/helpers/concat', 'ember-glimmer/helpers/debugger', 'ember-glimmer/helpers/get', 'ember-glimmer/helpers/hash', 'ember-glimmer/helpers/loc', 'ember-glimmer/helpers/log', 'ember-glimmer/helpers/mut', 'ember-glimmer/helpers/readonly', 'ember-glimmer/helpers/unbound', 'ember-glimmer/helpers/-class', 'ember-glimmer/helpers/-input-type', 'ember-glimmer/helpers/query-param', 'ember-glimmer/helpers/each-in', 'ember-glimmer/helpers/-normalize-class', 'ember-glimmer/helpers/-html-safe', 'ember-glimmer/protocol-for-url', 'ember-glimmer/modifiers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _glimmerRuntime, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntax, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerHelpersIfUnless, _emberGlimmerUtilsBindings, _emberGlimmerHelpersAction, _emberGlimmerHelpersComponent, _emberGlimmerHelpersConcat, _emberGlimmerHelpersDebugger, _emberGlimmerHelpersGet, _emberGlimmerHelpersHash, _emberGlimmerHelpersLoc, _emberGlimmerHelpersLog, _emberGlimmerHelpersMut, _emberGlimmerHelpersReadonly, _emberGlimmerHelpersUnbound, _emberGlimmerHelpersClass, _emberGlimmerHelpersInputType, _emberGlimmerHelpersQueryParam, _emberGlimmerHelpersEachIn, _emberGlimmerHelpersNormalizeClass, _emberGlimmerHelpersHtmlSafe, _emberGlimmerProtocolForUrl, _emberGlimmerModifiersAction) { - 'use strict'; - - var builtInComponents = { - textarea: '-text-area' - }; - - var Environment = (function (_GlimmerEnvironment) { - babelHelpers.inherits(Environment, _GlimmerEnvironment); - - Environment.create = function create(options) { - return new Environment(options); - }; - - function Environment(_ref) { - var _this = this; - var owner = _ref[_emberUtils.OWNER]; - babelHelpers.classCallCheck(this, Environment); - - _GlimmerEnvironment.apply(this, arguments); - this.owner = owner; - this.isInteractive = owner.lookup('-environment:main').isInteractive; + // If in a tagless component, assert that no event handlers are defined + _emberMetal.assert('You can not define a function that handles DOM events in the `' + this + '` tagless component since it doesn\'t have any DOM element.', this.tagName !== '' || !this.renderer._destinedForDOM || !(function () { + var eventDispatcher = _emberUtils.getOwner(_this).lookup('event_dispatcher:main'); + var events = eventDispatcher && eventDispatcher._finalEvents || {}; - // can be removed once https://github.com/tildeio/glimmer/pull/305 lands - this.destroyedComponents = undefined; + for (var key in events) { + var methodName = events[key]; - _emberGlimmerProtocolForUrl.default(this); + if (typeof _this[methodName] === 'function') { + return true; // indicate that the assertion should be triggered + } + } + })()); - this._definitionCache = new _emberMetal.Cache(2000, function (_ref2) { - var name = _ref2.name; - var source = _ref2.source; - var owner = _ref2.owner; + _emberMetal.assert('You cannot use a computed property for the component\'s `tagName` (' + this + ').', !(this.tagName && this.tagName.isDescriptor)); + }, - var _lookupComponent = _emberViews.lookupComponent(owner, name, { source: source }); + rerender: function () { + this[DIRTY_TAG].dirty(); + this._super(); + }, - var ComponentClass = _lookupComponent.component; - var layout = _lookupComponent.layout; + __defineNonEnumerable: function (property) { + this[property.name] = property.descriptor.value; + } - if (ComponentClass || layout) { - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(name, ComponentClass, layout); - } - }, function (_ref3) { - var name = _ref3.name; - var source = _ref3.source; - var owner = _ref3.owner; + }, _CoreView$extend[_emberMetal.PROPERTY_DID_CHANGE] = function (key) { + if (this[IS_DISPATCHING_ATTRS]) { + return; + } - var expandedName = source && owner._resolveLocalLookupName(name, source) || name; - var ownerGuid = _emberUtils.guidFor(owner); + var args = undefined, + reference = undefined; - return ownerGuid + '|' + expandedName; - }); + if ((args = this[ARGS]) && (reference = args[key])) { + if (reference[_emberGlimmerUtilsReferences.UPDATE]) { + reference[_emberGlimmerUtilsReferences.UPDATE](_emberMetal.get(this, key)); + } + } + }, _CoreView$extend.getAttr = function (key) { + // TODO Intimate API should be deprecated + return this.get(key); + }, _CoreView$extend.readDOMAttr = function (name) { + var element = _emberViews.getViewElement(this); + return _glimmerRuntime.readDOMAttr(element, name); + }, _CoreView$extend)); - this._templateCache = new _emberMetal.Cache(1000, function (_ref4) { - var Template = _ref4.Template; - var owner = _ref4.owner; + /** + The WAI-ARIA role of the control represented by this view. For example, a + button may have a role of type 'button', or a pane may have a role of + type 'alertdialog'. This property is used by assistive software to help + visually challenged users navigate rich web applications. + The full list of valid WAI-ARIA roles is available at: + [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization) + @property ariaRole + @type String + @default null + @public + */ - if (Template.create) { - var _Template$create; - - // we received a factory - return Template.create((_Template$create = { env: _this }, _Template$create[_emberUtils.OWNER] = owner, _Template$create)); - } else { - // we were provided an instance already - return Template; - } - }, function (_ref5) { - var Template = _ref5.Template; - var owner = _ref5.owner; - return _emberUtils.guidFor(owner) + '|' + Template.id; - }); - - this._compilerCache = new _emberMetal.Cache(10, function (Compiler) { - return new _emberMetal.Cache(2000, function (template) { - var compilable = new Compiler(template); - return _glimmerRuntime.compileLayout(compilable, _this); - }, function (template) { - var owner = template.meta.owner; - return _emberUtils.guidFor(owner) + '|' + template.id; - }); - }, function (Compiler) { - return Compiler.id; - }); - - this.builtInModifiers = { - action: new _emberGlimmerModifiersAction.default() - }; - - this.builtInHelpers = { - if: _emberGlimmerHelpersIfUnless.inlineIf, - action: _emberGlimmerHelpersAction.default, - component: _emberGlimmerHelpersComponent.default, - concat: _emberGlimmerHelpersConcat.default, - debugger: _emberGlimmerHelpersDebugger.default, - get: _emberGlimmerHelpersGet.default, - hash: _emberGlimmerHelpersHash.default, - loc: _emberGlimmerHelpersLoc.default, - log: _emberGlimmerHelpersLog.default, - mut: _emberGlimmerHelpersMut.default, - 'query-params': _emberGlimmerHelpersQueryParam.default, - readonly: _emberGlimmerHelpersReadonly.default, - unbound: _emberGlimmerHelpersUnbound.default, - unless: _emberGlimmerHelpersIfUnless.inlineUnless, - '-class': _emberGlimmerHelpersClass.default, - '-each-in': _emberGlimmerHelpersEachIn.default, - '-input-type': _emberGlimmerHelpersInputType.default, - '-normalize-class': _emberGlimmerHelpersNormalizeClass.default, - '-html-safe': _emberGlimmerHelpersHtmlSafe.default, - '-get-dynamic-var': _glimmerRuntime.getDynamicVar - }; - } - - // Hello future traveler, welcome to the world of syntax refinement. - // The method below is called by Glimmer's runtime compiler to allow - // us to take generic statement syntax and refine it to more meaniful - // syntax for Ember's use case. This on the fly switch-a-roo sounds fine - // and dandy, however Ember has precedence on statement refinement that you - // need to be aware of. The presendence for language constructs is as follows: - // - // ------------------------ - // Native & Built-in Syntax - // ------------------------ - // User-land components - // ------------------------ - // User-land helpers - // ------------------------ - // - // The one caveat here is that Ember also allows for dashed references that are - // not a component or helper: - // - // export default Component.extend({ - // 'foo-bar': 'LAME' - // }); - // - // {{foo-bar}} - // - // The heuristic for the above situation is a dashed "key" in inline form - // that does not resolve to a defintion. In this case refine statement simply - // isn't going to return any syntax and the Glimmer engine knows how to handle - // this case. - - Environment.prototype.refineStatement = function refineStatement(statement, symbolTable) { - var _this2 = this; - - // 1. resolve any native syntax – if, unless, with, each, and partial - var nativeSyntax = _GlimmerEnvironment.prototype.refineStatement.call(this, statement, symbolTable); - - if (nativeSyntax) { - return nativeSyntax; - } - - var appendType = statement.appendType; - var isSimple = statement.isSimple; - var isInline = statement.isInline; - var isBlock = statement.isBlock; - var isModifier = statement.isModifier; - var key = statement.key; - var path = statement.path; - var args = statement.args; - - _emberMetal.assert('You attempted to overwrite the built-in helper "' + key + '" which is not allowed. Please rename the helper.', !(this.builtInHelpers[key] && this.owner.hasRegistration('helper:' + key))); - - if (isSimple && (isInline || isBlock) && appendType !== 'get') { - // 2. built-in syntax - - var RefinedSyntax = _emberGlimmerSyntax.findSyntaxBuilder(key); - if (RefinedSyntax) { - return RefinedSyntax.create(this, args, symbolTable); - } - - var internalKey = builtInComponents[key]; - var definition = null; - - if (internalKey) { - definition = this.getComponentDefinition([internalKey], symbolTable); - } else if (key.indexOf('-') >= 0) { - definition = this.getComponentDefinition(path, symbolTable); - } - - if (definition) { - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } - - _emberMetal.assert('A component or helper named "' + key + '" could not be found', !isBlock || this.hasHelper(path, symbolTable)); - } - - if (isInline && !isSimple && appendType !== 'helper') { - return statement.original.deopt(); - } - - if (!isSimple && path) { - return _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax.fromPath(this, path, args, symbolTable); - } - - _emberMetal.assert('Helpers may not be used in the block form, for example {{#' + key + '}}{{/' + key + '}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (' + key + ')}}{{/if}}.', !isBlock || !this.hasHelper(path, symbolTable)); - - _emberMetal.assert('Helpers may not be used in the element form.', (function () { - if (nativeSyntax) { - return true; - } - if (!key) { - return true; - } - - if (isModifier && !_this2.hasModifier(path, symbolTable) && _this2.hasHelper(path, symbolTable)) { - return false; - } - - return true; - })()); - }; - - Environment.prototype.hasComponentDefinition = function hasComponentDefinition() { - return false; - }; - - Environment.prototype.getComponentDefinition = function getComponentDefinition(path, symbolTable) { - var name = path[0]; - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var source = blockMeta.moduleName && 'template:' + blockMeta.moduleName; - - return this._definitionCache.get({ name: name, source: source, owner: owner }); - }; - - // normally templates should be exported at the proper module name - // and cached in the container, but this cache supports templates - // that have been set directly on the component's layout property - - Environment.prototype.getTemplate = function getTemplate(Template, owner) { - return this._templateCache.get({ Template: Template, owner: owner }); - }; - - // a Compiler can wrap the template so it needs its own cache - - Environment.prototype.getCompiledBlock = function getCompiledBlock(Compiler, template) { - var compilerCache = this._compilerCache.get(Compiler); - return compilerCache.get(template); - }; - - Environment.prototype.hasPartial = function hasPartial(name, symbolTable) { - var _symbolTable$getMeta = symbolTable.getMeta(); - - var owner = _symbolTable$getMeta.owner; - - return _emberViews.hasPartial(name, owner); - }; - - Environment.prototype.lookupPartial = function lookupPartial(name, symbolTable) { - var _symbolTable$getMeta2 = symbolTable.getMeta(); - - var owner = _symbolTable$getMeta2.owner; - - var partial = { - template: _emberViews.lookupPartial(name, owner) - }; - - if (partial.template) { - return partial; - } else { - throw new Error(name + ' is not a partial'); - } - }; - - Environment.prototype.hasHelper = function hasHelper(nameParts, symbolTable) { - _emberMetal.assert('The first argument passed into `hasHelper` should be an array', Array.isArray(nameParts)); - - // helpers are not allowed to include a dot in their invocation - if (nameParts.length > 1) { - return false; - } - - var name = nameParts[0]; - - if (this.builtInHelpers[name]) { - return true; - } - - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var options = { source: 'template:' + blockMeta.moduleName }; - - return owner.hasRegistration('helper:' + name, options) || owner.hasRegistration('helper:' + name); - }; - - Environment.prototype.lookupHelper = function lookupHelper(nameParts, symbolTable) { - _emberMetal.assert('The first argument passed into `lookupHelper` should be an array', Array.isArray(nameParts)); - - var name = nameParts[0]; - var helper = this.builtInHelpers[name]; - - if (helper) { - return helper; - } - - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var options = blockMeta.moduleName && { source: 'template:' + blockMeta.moduleName } || {}; - - helper = owner.lookup('helper:' + name, options) || owner.lookup('helper:' + name); - - // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations - if (helper.isHelperInstance) { - return function (vm, args) { - return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helper.compute, args); - }; - } else if (helper.isHelperFactory) { - return function (vm, args) { - return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helper, vm, args); - }; - } else { - throw new Error(nameParts + ' is not a helper'); - } - }; - - Environment.prototype.hasModifier = function hasModifier(nameParts) { - _emberMetal.assert('The first argument passed into `hasModifier` should be an array', Array.isArray(nameParts)); - - // modifiers are not allowed to include a dot in their invocation - if (nameParts.length > 1) { - return false; - } - - return !!this.builtInModifiers[nameParts[0]]; - }; - - Environment.prototype.lookupModifier = function lookupModifier(nameParts) { - _emberMetal.assert('The first argument passed into `lookupModifier` should be an array', Array.isArray(nameParts)); - - var modifier = this.builtInModifiers[nameParts[0]]; - - if (modifier) { - return modifier; - } else { - throw new Error(nameParts + ' is not a modifier'); - } - }; - - Environment.prototype.toConditionalReference = function toConditionalReference(reference) { - return _emberGlimmerUtilsReferences.ConditionalReference.create(reference); - }; - - Environment.prototype.iterableFor = function iterableFor(ref, args) { - var keyPath = args.named.get('key').value(); - return _emberGlimmerUtilsIterable.default(ref, keyPath); - }; + /** + Enables components to take a list of parameters as arguments. + For example, a component that takes two parameters with the names + `name` and `age`: + ```javascript + let MyComponent = Ember.Component.extend; + MyComponent.reopenClass({ + positionalParams: ['name', 'age'] + }); + ``` + It can then be invoked like this: + ```hbs + {{my-component "John" 38}} + ``` + The parameters can be referred to just like named parameters: + ```hbs + Name: {{name}}, Age: {{age}}. + ``` + Using a string instead of an array allows for an arbitrary number of + parameters: + ```javascript + let MyComponent = Ember.Component.extend; + MyComponent.reopenClass({ + positionalParams: 'names' + }); + ``` + It can then be invoked like this: + ```hbs + {{my-component "John" "Michael" "Scott"}} + ``` + The parameters can then be referred to by enumerating over the list: + ```hbs + {{#each names as |name|}}{{name}}{{/each}} + ``` + @static + @public + @property positionalParams + @since 1.13.0 + */ - Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier() { - if (this.isInteractive) { - var _GlimmerEnvironment$prototype$scheduleInstallModifier; + /** + Called when the attributes passed into the component have been updated. + Called both during the initial render of a container and during a rerender. + Can be used in place of an observer; code placed here will be executed + every time any attribute updates. + @method didReceiveAttrs + @public + @since 1.13.0 + */ - (_GlimmerEnvironment$prototype$scheduleInstallModifier = _GlimmerEnvironment.prototype.scheduleInstallModifier).call.apply(_GlimmerEnvironment$prototype$scheduleInstallModifier, [this].concat(babelHelpers.slice.call(arguments))); - } - }; + /** + Called when the attributes passed into the component have been updated. + Called both during the initial render of a container and during a rerender. + Can be used in place of an observer; code placed here will be executed + every time any attribute updates. + @event didReceiveAttrs + @public + @since 1.13.0 + */ - Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier() { - if (this.isInteractive) { - var _GlimmerEnvironment$prototype$scheduleUpdateModifier; + /** + Called after a component has been rendered, both on initial render and + in subsequent rerenders. + @method didRender + @public + @since 1.13.0 + */ - (_GlimmerEnvironment$prototype$scheduleUpdateModifier = _GlimmerEnvironment.prototype.scheduleUpdateModifier).call.apply(_GlimmerEnvironment$prototype$scheduleUpdateModifier, [this].concat(babelHelpers.slice.call(arguments))); - } - }; + /** + Called after a component has been rendered, both on initial render and + in subsequent rerenders. + @event didRender + @public + @since 1.13.0 + */ - Environment.prototype.didDestroy = function didDestroy(destroyable) { - destroyable.destroy(); - }; + /** + Called before a component has been rendered, both on initial render and + in subsequent rerenders. + @method willRender + @public + @since 1.13.0 + */ - Environment.prototype.begin = function begin() { - this.inTransaction = true; + /** + Called before a component has been rendered, both on initial render and + in subsequent rerenders. + @event willRender + @public + @since 1.13.0 + */ - _GlimmerEnvironment.prototype.begin.call(this); + /** + Called when the attributes passed into the component have been changed. + Called only during a rerender, not during an initial render. + @method didUpdateAttrs + @public + @since 1.13.0 + */ - this.destroyedComponents = []; - }; + /** + Called when the attributes passed into the component have been changed. + Called only during a rerender, not during an initial render. + @event didUpdateAttrs + @public + @since 1.13.0 + */ - Environment.prototype.commit = function commit() { - // components queued for destruction must be destroyed before firing - // `didCreate` to prevent errors when removing and adding a component - // with the same name (would throw an error when added to view registry) - for (var i = 0; i < this.destroyedComponents.length; i++) { - this.destroyedComponents[i].destroy(); - } + /** + Called when the component is about to update and rerender itself. + Called only during a rerender, not during an initial render. + @method willUpdate + @public + @since 1.13.0 + */ - _GlimmerEnvironment.prototype.commit.call(this); + /** + Called when the component is about to update and rerender itself. + Called only during a rerender, not during an initial render. + @event willUpdate + @public + @since 1.13.0 + */ - this.inTransaction = false; - }; + /** + Called when the component has updated and rerendered itself. + Called only during a rerender, not during an initial render. + @method didUpdate + @public + @since 1.13.0 + */ - return Environment; - })(_glimmerRuntime.Environment); + /** + Called when the component has updated and rerendered itself. + Called only during a rerender, not during an initial render. + @event didUpdate + @public + @since 1.13.0 + */ - exports.default = Environment; + /** + A component may contain a layout. A layout is a regular template but + supersedes the `template` property during rendering. It is the + responsibility of the layout template to retrieve the `template` + property from the component (or alternatively, call `Handlebars.helpers.yield`, + `{{yield}}`) to render it in the correct location. + This is useful for a component that has a shared wrapper, but which delegates + the rendering of the contents of the wrapper to the `template` property + on a subclass. + @property layout + @type Function + @public + */ - _emberMetal.runInDebug(function () { - var StyleAttributeManager = (function (_AttributeManager) { - babelHelpers.inherits(StyleAttributeManager, _AttributeManager); + /** + The name of the layout to lookup if no layout is provided. + By default `Ember.Component` will lookup a template with this name in + `Ember.TEMPLATES` (a shared global object). + @property layoutName + @type String + @default null + @private + */ - function StyleAttributeManager() { - babelHelpers.classCallCheck(this, StyleAttributeManager); + /** + Returns a jQuery object for this component's element. If you pass in a selector + string, this method will return a jQuery object, using the current element + as its buffer. + For example, calling `component.$('li')` will return a jQuery object containing + all of the `li` elements inside the DOM element of this component. + @method $ + @param {String} [selector] a jQuery-compatible selector string + @return {jQuery} the jQuery object for the DOM node + @public + */ - _AttributeManager.apply(this, arguments); + /** + The HTML `id` of the component's element in the DOM. You can provide this + value yourself but it must be unique (just as in HTML): + ```handlebars + {{my-component elementId="a-really-cool-id"}} + ``` + If not manually set a default value will be provided by the framework. + Once rendered an element's `elementId` is considered immutable and you + should never change it. If you need to compute a dynamic value for the + `elementId`, you should do this when the component or element is being + instantiated: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + var index = this.get('index'); + this.set('elementId', `component-id${index}`); } + }); + ``` + @property elementId + @type String + @public + */ - StyleAttributeManager.prototype.setAttribute = function setAttribute(dom, element, value) { - var _AttributeManager$prototype$setAttribute; - - _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { - if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { - return true; - } - return false; - })(), { id: 'ember-htmlbars.style-xss-warning' }); - (_AttributeManager$prototype$setAttribute = _AttributeManager.prototype.setAttribute).call.apply(_AttributeManager$prototype$setAttribute, [this].concat(babelHelpers.slice.call(arguments))); - }; - - StyleAttributeManager.prototype.updateAttribute = function updateAttribute(dom, element, value) { - var _AttributeManager$prototype$updateAttribute; - - _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { - if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { - return true; - } - return false; - })(), { id: 'ember-htmlbars.style-xss-warning' }); - (_AttributeManager$prototype$updateAttribute = _AttributeManager.prototype.updateAttribute).call.apply(_AttributeManager$prototype$updateAttribute, [this].concat(babelHelpers.slice.call(arguments))); - }; + /** + If `false`, the view will appear hidden in DOM. + @property isVisible + @type Boolean + @default null + @public + */ + Component[_emberUtils.NAME_KEY] = 'Ember.Component'; - return StyleAttributeManager; - })(_glimmerRuntime.AttributeManager); + Component.reopenClass({ + isComponentFactory: true, + positionalParams: [] + }); - var STYLE_ATTRIBUTE_MANANGER = new StyleAttributeManager('style'); + exports.default = Component; +}); - Environment.prototype.attributeFor = function (element, attribute, isTrusting, namespace) { - if (attribute === 'style' && !isTrusting) { - return STYLE_ATTRIBUTE_MANANGER; - } +/** + Normally, Ember's component model is "write-only". The component takes a + bunch of attributes that it got passed in, and uses them to render its + template. + One nice thing about this model is that if you try to set a value to the + same thing as last time, Ember (through HTMLBars) will avoid doing any + work on the DOM. + This is not just a performance optimization. If an attribute has not + changed, it is important not to clobber the element's "hidden state". + For example, if you set an input's `value` to the same value as before, + it will clobber selection state and cursor position. In other words, + setting an attribute is not **always** idempotent. + This method provides a way to read an element's attribute and also + update the last value Ember knows about at the same time. This makes + setting an attribute idempotent. + In particular, what this means is that if you get an `` element's + `value` attribute and then re-render the template with the same value, + it will avoid clobbering the cursor and selection position. + Since most attribute sets are idempotent in the browser, you typically + can get away with reading attributes using jQuery, but the most reliable + way to do so is through this method. + @method readDOMAttr + @param {String} name the name of the attribute + @return String + @public + */ +enifed('ember-glimmer/components/checkbox', ['exports', 'ember-metal', 'ember-glimmer/component', 'ember-glimmer/templates/empty'], function (exports, _emberMetal, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty) { + 'use strict'; - return _glimmerRuntime.Environment.prototype.attributeFor.call(this, element, attribute, isTrusting); - }; - }); -}); -enifed('ember-glimmer/helper', ['exports', 'ember-utils', 'ember-runtime', 'glimmer-reference'], function (exports, _emberUtils, _emberRuntime, _glimmerReference) { /** @module ember - @submodule ember-glimmer + @submodule ember-views */ - 'use strict'; - - exports.helper = helper; - var RECOMPUTE_TAG = _emberUtils.symbol('RECOMPUTE_TAG'); - - exports.RECOMPUTE_TAG = RECOMPUTE_TAG; /** - Ember Helpers are functions that can compute values, and are used in templates. - For example, this code calls a helper named `format-currency`: + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `checkbox`. - ```handlebars -
    {{format-currency cents currency="$"}}
    - ``` + See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. - Additionally a helper can be called as a nested helper (sometimes called a - subexpression). In this example, the computed value of a helper is passed - to a component named `show-money`: + ## Direct manipulation of `checked` - ```handlebars - {{show-money amount=(format-currency cents currency="$")}} - ``` + The `checked` attribute of an `Ember.Checkbox` object should always be set + through the Ember object or by interacting with its rendered element + representation via the mouse, keyboard, or touch. Updating the value of the + checkbox via jQuery will result in the checked value of the object and its + element losing synchronization. - Helpers defined using a class must provide a `compute` function. For example: + ## Layout and LayoutName properties - ```js - export default Ember.Helper.extend({ - compute(params, hash) { - let cents = params[0]; - let currency = hash.currency; - return `${currency}${cents * 0.01}`; - } - }); - ``` - - Each time the input to a helper changes, the `compute` function will be - called again. - - As instances, these helpers also have access to the container an will accept - injected dependencies. - - Additionally, class helpers can call `recompute` to force a new computation. - - @class Ember.Helper - @public - @since 1.13.0 - */ - var Helper = _emberRuntime.FrameworkObject.extend({ - isHelperInstance: true, - - init: function () { - this._super.apply(this, arguments); - this[RECOMPUTE_TAG] = new _glimmerReference.DirtyableTag(); - }, - - /** - On a class-based helper, it may be useful to force a recomputation of that - helpers value. This is akin to `rerender` on a component. - For example, this component will rerender when the `currentUser` on a - session service changes: - ```js - // app/helpers/current-user-email.js - export default Ember.Helper.extend({ - session: Ember.inject.service(), - onNewUser: Ember.observer('session.currentUser', function() { - this.recompute(); - }), - compute() { - return this.get('session.currentUser.email'); - } - }); - ``` - @method recompute - @public - @since 1.13.0 - */ - recompute: function () { - this[RECOMPUTE_TAG].dirty(); - } - - /** - Override this function when writing a class-based helper. - @method compute - @param {Array} params The positional arguments to the helper - @param {Object} hash The named arguments to the helper - @public - @since 1.13.0 - */ - }); - - Helper.reopenClass({ - isHelperFactory: true - }); - - /** - In many cases, the ceremony of a full `Ember.Helper` class is not required. - The `helper` method create pure-function helpers without instances. For - example: - - ```js - // app/helpers/format-currency.js - export default Ember.Helper.helper(function(params, hash) { - let cents = params[0]; - let currency = hash.currency; - return `${currency}${cents * 0.01}`; - }); - ``` + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. - @static - @param {Function} helper The helper function - @method helper + @class Checkbox + @namespace Ember + @extends Ember.Component @public - @since 1.13.0 */ + exports.default = _emberGlimmerComponent.default.extend({ + layout: _emberGlimmerTemplatesEmpty.default, + classNames: ['ember-checkbox'], - function helper(helperFn) { - return { - isHelperInstance: true, - compute: helperFn - }; - } - - exports.default = Helper; -}); -enifed('ember-glimmer/helpers/-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - 'use strict'; - - function classHelper(_ref) { - var positional = _ref.positional; - - var path = positional.at(0); - var args = positional.length; - var value = path.value(); - - if (value === true) { - if (args > 1) { - return _emberRuntime.String.dasherize(positional.at(1).value()); - } - return null; - } - - if (value === false) { - if (args > 2) { - return _emberRuntime.String.dasherize(positional.at(2).value()); - } - return null; - } - - return value; - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(classHelper, args); - }; -}); -enifed('ember-glimmer/helpers/-html-safe', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/utils/string'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerUtilsString) { - 'use strict'; - - function htmlSafe(_ref) { - var positional = _ref.positional; - - var path = positional.at(0); - return new _emberGlimmerUtilsString.SafeString(path.value()); - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(htmlSafe, args); - }; -}); -enifed('ember-glimmer/helpers/-input-type', ['exports', 'ember-glimmer/utils/references'], function (exports, _emberGlimmerUtilsReferences) { - 'use strict'; - - function inputTypeHelper(_ref) { - var positional = _ref.positional; - var named = _ref.named; - - var type = positional.at(0).value(); - if (type === 'checkbox') { - return '-checkbox'; - } - return '-text-field'; - } + tagName: 'input', - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(inputTypeHelper, args); - }; -}); -enifed('ember-glimmer/helpers/-normalize-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - 'use strict'; + attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name', 'autofocus', 'required', 'form'], - function normalizeClass(_ref) { - var positional = _ref.positional; - var named = _ref.named; + type: 'checkbox', + checked: false, + disabled: false, + indeterminate: false, - var classNameParts = positional.at(0).value().split('.'); - var className = classNameParts[classNameParts.length - 1]; - var value = positional.at(1).value(); + didInsertElement: function () { + this._super.apply(this, arguments); + _emberMetal.get(this, 'element').indeterminate = !!_emberMetal.get(this, 'indeterminate'); + }, - if (value === true) { - return _emberRuntime.String.dasherize(className); - } else if (!value && value !== 0) { - return ''; - } else { - return String(value); + change: function () { + _emberMetal.set(this, 'checked', this.$().prop('checked')); } - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(normalizeClass, args); - }; + }); }); -enifed('ember-glimmer/helpers/action', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal) { +enifed('ember-glimmer/components/link-to', ['exports', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-glimmer/templates/link-to', 'ember-glimmer/component'], function (exports, _emberConsole, _emberMetal, _emberRuntime, _emberViews, _emberGlimmerTemplatesLinkTo, _emberGlimmerComponent) { /** @module ember @submodule ember-glimmer */ - 'use strict'; - - exports.createClosureAction = createClosureAction; - var INVOKE = _emberUtils.symbol('INVOKE'); - exports.INVOKE = INVOKE; - var ACTION = _emberUtils.symbol('ACTION'); - exports.ACTION = ACTION; /** - The `{{action}}` helper provides a way to pass triggers for behavior (usually - just a function) between components, and into components from controllers. - - ### Passing functions with the action helper - - There are three contexts an action helper can be used in. The first two - contexts to discuss are attribute context, and Handlebars value context. + The `{{link-to}}` component renders a link to the supplied + `routeName` passing an optionally supplied model to the + route as its `model` context of the route. The block + for `{{link-to}}` becomes the innerHTML of the rendered + element: ```handlebars - {{! An example of attribute context }} -
    - {{! Examples of Handlebars value context }} - {{input on-input=(action "save")}} - {{yield (action "refreshData") andAnotherParam}} + {{#link-to 'photoGallery'}} + Great Hamster Photos + {{/link-to}} ``` - In these contexts, - the helper is called a "closure action" helper. Its behavior is simple: - If passed a function name, read that function off the `actions` property - of the current context. Once that function is read (or if a function was - passed), create a closure over that function and any arguments. - The resulting value of an action helper used this way is simply a function. - - For example, in the attribute context: + You can also use an inline form of `{{link-to}}` component by + passing the link text as the first argument + to the component: ```handlebars - {{! An example of attribute context }} -
    + {{link-to 'Great Hamster Photos' 'photoGallery'}} ``` - The resulting template render logic would be: + Both will result in: - ```js - var div = document.createElement('div'); - var actionFunction = (function(context){ - return function() { - return context.actions.save.apply(context, arguments); - }; - })(context); - div.onclick = actionFunction; + ```html + + Great Hamster Photos + ``` - Thus when the div is clicked, the action on that context is called. - Because the `actionFunction` is just a function, closure actions can be - passed between components and still execute in the correct context. - - Here is an example action handler on a component: + ### Supplying a tagName + By default `{{link-to}}` renders an `` element. This can + be overridden for a single use of `{{link-to}}` by supplying + a `tagName` option: - ```js - export default Ember.Component.extend({ - actions: { - save() { - this.get('model').save(); - } - } - }); + ```handlebars + {{#link-to 'photoGallery' tagName="li"}} + Great Hamster Photos + {{/link-to}} ``` - Actions are always looked up on the `actions` property of the current context. - This avoids collisions in the naming of common actions, such as `destroy`. - Two options can be passed to the `action` helper when it is used in this way. - - * `target=someProperty` will look to `someProperty` instead of the current - context for the `actions` hash. This can be useful when targetting a - service for actions. - * `value="target.value"` will read the path `target.value` off the first - argument to the action when it is called and rewrite the first argument - to be that value. This is useful when attaching actions to event listeners. - - ### Invoking an action - - Closure actions curry both their scope and any arguments. When invoked, any - additional arguments are added to the already curried list. - Actions should be invoked using the [sendAction](/api/classes/Ember.Component.html#method_sendAction) - method. The first argument to `sendAction` is the action to be called, and - additional arguments are passed to the action function. This has interesting - properties combined with currying of arguments. For example: - - ```js - export default Ember.Component.extend({ - actions: { - // Usage {{input on-input=(action (action 'setName' model) value="target.value")}} - setName(model, name) { - model.set('name', name); - } - } - }); + ```html +
  • + Great Hamster Photos +
  • ``` - The first argument (`model`) was curried over, and the run-time argument (`event`) - becomes a second argument. Action calls can be nested this way because each simply - returns a function. Any function can be passed to the `{{action}}` helper, including - other actions. + To override this option for your entire application, see + "Overriding Application-wide Defaults". - Actions invoked with `sendAction` have the same currying behavior as demonstrated - with `on-input` above. For example: + ### Disabling the `link-to` component + By default `{{link-to}}` is enabled. + any passed value to the `disabled` component property will disable + the `link-to` component. - ```js - export default Ember.Component.extend({ - actions: { - setName(model, name) { - model.set('name', name); - } - } - }); - ``` + static use: the `disabled` option: ```handlebars - {{my-input submit=(action 'setName' model)}} - ``` - - ```js - // app/components/my-component.js - export default Ember.Component.extend({ - click() { - // Note that model is not passed, it was curried in the template - this.sendAction('submit', 'bob'); - } - }); + {{#link-to 'photoGallery' disabled=true}} + Great Hamster Photos + {{/link-to}} ``` - ### Attaching actions to DOM elements - - The third context of the `{{action}}` helper can be called "element space". - For example: + dynamic use: the `disabledWhen` option: ```handlebars - {{! An example of element space }} -
    + {{#link-to 'photoGallery' disabledWhen=controller.someProperty}} + Great Hamster Photos + {{/link-to}} ``` - Used this way, the `{{action}}` helper provides a useful shortcut for - registering an HTML element in a template for a single DOM event and - forwarding that interaction to the template's context (controller or component). - If the context of a template is a controller, actions used this way will - bubble to routes when the controller does not implement the specified action. - Once an action hits a route, it will bubble through the route hierarchy. + any passed value to `disabled` will disable it except `undefined`. + to ensure that only `true` disable the `link-to` component you can + override the global behaviour of `Ember.LinkComponent`. - ### Event Propagation + ```javascript + Ember.LinkComponent.reopen({ + disabled: Ember.computed(function(key, value) { + if (value !== undefined) { + this.set('_isDisabled', value === true); + } + return value === true ? get(this, 'disabledClass') : false; + }) + }); + ``` - `{{action}}` helpers called in element space can control event bubbling. Note - that the closure style actions cannot. + see "Overriding Application-wide Defaults" for more. - Events triggered through the action helper will automatically have - `.preventDefault()` called on them. You do not need to do so in your event - handlers. If you need to allow event propagation (to handle file inputs for - example) you can supply the `preventDefault=false` option to the `{{action}}` helper: + ### Handling `href` + `{{link-to}}` will use your application's Router to + fill the element's `href` property with a url that + matches the path to the supplied `routeName` for your + router's configured `Location` scheme, which defaults + to Ember.HashLocation. + + ### Handling current route + `{{link-to}}` will apply a CSS class name of 'active' + when the application's current route matches + the supplied routeName. For example, if the application's + current route is 'photoGallery.recent' the following + use of `{{link-to}}`: ```handlebars -
    - - -
    + {{#link-to 'photoGallery.recent'}} + Great Hamster Photos + {{/link-to}} ``` - To disable bubbling, pass `bubbles=false` to the helper: + will result in - ```handlebars - + ```html +
    + Great Hamster Photos + ``` - To disable bubbling with closure style actions you must create your own - wrapper helper that makes use of `event.stopPropagation()`: + The CSS class name used for active classes can be customized + for a single use of `{{link-to}}` by passing an `activeClass` + option: ```handlebars -
    Hello
    + {{#link-to 'photoGallery.recent' activeClass="current-url"}} + Great Hamster Photos + {{/link-to}} ``` - ```js - // app/helpers/disable-bubbling.js - import Ember from 'ember'; - export function disableBubbling([action]) { - return function(event) { - event.stopPropagation(); - return action(event); - }; - } - export default Ember.Helper.helper(disableBubbling); + ```html + + Great Hamster Photos + ``` - If you need the default handler to trigger you should either register your - own event handler, or use event methods on your view class. See - ["Responding to Browser Events"](/api/classes/Ember.View.html#toc_responding-to-browser-events) - in the documentation for Ember.View for more information. + To override this option for your entire application, see + "Overriding Application-wide Defaults". - ### Specifying DOM event type + ### Keeping a link active for other routes - `{{action}}` helpers called in element space can specify an event type. - By default the `{{action}}` helper registers for DOM `click` events. You can - supply an `on` option to the helper to specify a different DOM event name: + If you need a link to be 'active' even when it doesn't match + the current route, you can use the `current-when` argument. ```handlebars -
    - click me -
    + {{#link-to 'photoGallery' current-when='photos'}} + Photo Gallery + {{/link-to}} ``` - See ["Event Names"](/api/classes/Ember.View.html#toc_event-names) for a list of - acceptable DOM event names. - - ### Specifying whitelisted modifier keys + This may be helpful for keeping links active for: - `{{action}}` helpers called in element space can specify modifier keys. - By default the `{{action}}` helper will ignore click events with pressed modifier - keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. + * non-nested routes that are logically related + * some secondary menu approaches + * 'top navigation' with 'sub navigation' scenarios - ```handlebars -
    - click me -
    - ``` + A link will be active if `current-when` is `true` or the current + route is the route this link would transition to. - This way the action will fire when clicking with the alt key pressed down. - Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. + To match multiple routes 'space-separate' the routes: ```handlebars -
    - click me with any key pressed -
    + {{#link-to 'gallery' current-when='photos drawings paintings'}} + Art Gallery + {{/link-to}} ``` - ### Specifying a Target + ### Supplying a model + An optional model argument can be used for routes whose + paths contain dynamic segments. This argument will become + the model context of the linked route: - A `target` option can be provided to the helper to change - which object will receive the method call. This option must be a path - to an object, accessible in the current context: + ```javascript + Router.map(function() { + this.route("photoGallery", {path: "hamster-photos/:photo_id"}); + }); + ``` ```handlebars - {{! app/templates/application.hbs }} -
    - click me -
    + {{#link-to 'photoGallery' aPhoto}} + {{aPhoto.title}} + {{/link-to}} + ``` + + ```html + + Tomster + ``` + ### Supplying multiple models + For deep-linking to route paths that contain multiple + dynamic segments, multiple model arguments can be used. + As the router transitions through the route path, each + supplied model argument will become the context for the + route with the dynamic segments: + ```javascript - // app/controllers/application.js - export default Ember.Controller.extend({ - someService: Ember.inject.service() + Router.map(function() { + this.route("photoGallery", { path: "hamster-photos/:photo_id" }, function() { + this.route("comment", {path: "comments/:comment_id"}); + }); }); ``` + This argument will become the model context of the linked route: - @method action - @for Ember.Templates.helpers - @public - */ - - var ClosureActionReference = (function (_CachedReference) { - babelHelpers.inherits(ClosureActionReference, _CachedReference); - - ClosureActionReference.create = function create(args) { - // TODO: Const reference optimization. - return new ClosureActionReference(args); - }; - - function ClosureActionReference(args) { - babelHelpers.classCallCheck(this, ClosureActionReference); - - _CachedReference.call(this); - - this.args = args; - this.tag = args.tag; - } - - ClosureActionReference.prototype.compute = function compute() { - var _args = this.args; - var named = _args.named; - var positional = _args.positional; - - var positionalValues = positional.value(); - - var target = positionalValues[0]; - var rawActionRef = positional.at(1); - var rawAction = positionalValues[1]; - - // The first two argument slots are reserved. - // pos[0] is the context (or `this`) - // pos[1] is the action name or function - // Anything else is an action argument. - var actionArgs = positionalValues.slice(2); - - // on-change={{action setName}} - // element-space actions look to "controller" then target. Here we only - // look to "target". - var actionType = typeof rawAction; - var action = rawAction; - - if (rawActionRef[INVOKE]) { - target = rawActionRef; - action = rawActionRef[INVOKE]; - } else if (_emberMetal.isNone(rawAction)) { - throw new _emberMetal.Error('Action passed is null or undefined in (action) from ' + target + '.'); - } else if (actionType === 'string') { - // on-change={{action 'setName'}} - var actionName = rawAction; - - action = null; - - if (named.has('target')) { - // on-change={{action 'setName' target=alternativeComponent}} - target = named.get('target').value(); - } - - if (target['actions']) { - action = target.actions[actionName]; - } - - if (!action) { - throw new _emberMetal.Error('An action named \'' + actionName + '\' was not found in ' + target); - } - } else if (action && typeof action[INVOKE] === 'function') { - target = action; - action = action[INVOKE]; - } else if (actionType !== 'function') { - // TODO: Is there a better way of doing this? - var rawActionLabel = rawActionRef._propertyKey || rawAction; - throw new _emberMetal.Error('An action could not be made for `' + rawActionLabel + '` in ' + target + '. Please confirm that you are using either a quoted action name (i.e. `(action \'' + rawActionLabel + '\')`) or a function available in ' + target + '.'); - } - - var valuePath = named.get('value').value(); - - return createClosureAction(target, action, valuePath, actionArgs); - }; - - return ClosureActionReference; - })(_emberGlimmerUtilsReferences.CachedReference); - - exports.ClosureActionReference = ClosureActionReference; - - exports.default = function (vm, args) { - return ClosureActionReference.create(args); - }; - - function createClosureAction(target, action, valuePath, actionArgs) { - var closureAction = undefined; - var actionArgLength = actionArgs.length; - - if (actionArgLength > 0) { - closureAction = function () { - for (var _len = arguments.length, passedArguments = Array(_len), _key = 0; _key < _len; _key++) { - passedArguments[_key] = arguments[_key]; - } - - var args = new Array(actionArgLength + passedArguments.length); - - for (var i = 0; i < actionArgLength; i++) { - args[i] = actionArgs[i]; - } - - for (var i = 0; i < passedArguments.length; i++) { - args[i + actionArgLength] = passedArguments[i]; - } - - if (valuePath && args.length > 0) { - args[0] = _emberMetal.get(args[0], valuePath); - } - - var payload = { target: target, args: args, label: 'glimmer-closure-action' }; - return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - return _emberMetal.run.join.apply(_emberMetal.run, [target, action].concat(args)); - }); - }; - } else { - closureAction = function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - if (valuePath && args.length > 0) { - args[0] = _emberMetal.get(args[0], valuePath); - } - - var payload = { target: target, args: args, label: 'glimmer-closure-action' }; - return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - return _emberMetal.run.join.apply(_emberMetal.run, [target, action].concat(args)); - }); - }; - } - - closureAction[ACTION] = true; - return closureAction; - } -}); -enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/curly-component', 'glimmer-runtime', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxCurlyComponent, _glimmerRuntime, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - /** - The `{{component}}` helper lets you add instances of `Ember.Component` to a - template. See [Ember.Component](/api/classes/Ember.Component.html) for - additional information on how a `Component` functions. - `{{component}}`'s primary use is for cases where you want to dynamically - change which type of component is rendered as the state of your application - changes. This helper has three modes: inline, block, and nested. - - ### Inline Form - - Given the following template: - - ```app/application.hbs - {{component infographicComponentName}} + ```handlebars + {{#link-to 'photoGallery.comment' aPhoto comment}} + {{comment.body}} + {{/link-to}} ``` - And the following application code: - - ```app/controllers/application.js - export default Ember.Controller.extend({ - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) - }); + ```html + + A+++ would snuggle again. + ``` - The `live-updating-chart` component will be appended when `isMarketOpen` is - `true`, and the `market-close-summary` component will be appended when - `isMarketOpen` is `false`. If the value changes while the app is running, - the component will be automatically swapped out accordingly. - Note: You should not use this helper when you are consistently rendering the same - component. In that case, use standard component syntax, for example: + ### Supplying an explicit dynamic segment value + If you don't have a model object available to pass to `{{link-to}}`, + an optional string or integer argument can be passed for routes whose + paths contain dynamic segments. This argument will become the value + of the dynamic segment: - ```app/templates/application.hbs - {{live-updating-chart}} + ```javascript + Router.map(function() { + this.route("photoGallery", { path: "hamster-photos/:photo_id" }); + }); ``` - ### Block Form - - Using the block form of this helper is similar to using the block form - of a component. Given the following application template: - - ```app/templates/application.hbs - {{#component infographicComponentName}} - Last update: {{lastUpdateTimestamp}} - {{/component}} + ```handlebars + {{#link-to 'photoGallery' aPhotoId}} + {{aPhoto.title}} + {{/link-to}} ``` - The following controller code: - - ```app/controllers/application.js - export default Ember.Controller.extend({ - lastUpdateTimestamp: computed(function() { - return new Date(); - }), - - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) - }); + ```html + + Tomster + ``` - And the following component template: - - ```app/templates/components/live-updating-chart.hbs - {{! chart }} - {{yield}} - ``` + When transitioning into the linked route, the `model` hook will + be triggered with parameters including this passed identifier. - The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. + ### Allowing Default Action - ### Nested Usage + By default the `{{link-to}}` component prevents the default browser action + by calling `preventDefault()` as this sort of action bubbling is normally + handled internally and we do not want to take the browser to a new URL (for + example). - The `component` helper can be used to package a component path with initial attrs. - The included attrs can then be merged during the final invocation. - For example, given a `person-form` component with the following template: + If you need to override this behavior specify `preventDefault=false` in + your template: - ```app/templates/components/person-form.hbs - {{yield (hash - nameInput=(component "my-input-component" value=model.name placeholder="First Name") - )}} + ```handlebars + {{#link-to 'photoGallery' aPhotoId preventDefault=false}} + {{aPhotoId.title}} + {{/link-to}} ``` - When yielding the component via the `hash` helper, the component is invocked directly. - See the following snippet: + ### Overriding attributes + You can override any given property of the `Ember.LinkComponent` + that is generated by the `{{link-to}}` component by passing + key/value pairs, like so: - ``` - {{#person-form as |form|}} - {{form.nameInput placeholder="Username"}} - {{/person-form}} + ```handlebars + {{#link-to aPhoto tagName='li' title='Following this link will change your life' classNames='pic sweet'}} + Uh-mazing! + {{/link-to}} ``` - Which outputs an input whose value is already bound to `model.name` and `placeholder` - is "Username". + See [Ember.LinkComponent](/api/classes/Ember.LinkComponent.html) for a + complete list of overrideable properties. Be sure to also + check out inherited properties of `LinkComponent`. - When yielding the component without the hash helper use the `component` helper. - For example, below is a `full-name` component template: + ### Overriding Application-wide Defaults + ``{{link-to}}`` creates an instance of `Ember.LinkComponent` + for rendering. To override options for your entire + application, reopen `Ember.LinkComponent` and supply the + desired values: - ```handlebars - {{yield (component "my-input-component" value=model.name placeholder="Name")}} + ``` javascript + Ember.LinkComponent.reopen({ + activeClass: "is-active", + tagName: 'li' + }) ``` - ``` - {{#full-name as |field|}} - {{component field placeholder="Full name"}} - {{/full-name}} + It is also possible to override the default event in + this manner: + + ``` javascript + Ember.LinkComponent.reopen({ + eventName: 'customEventName' + }); ``` - @method component - @since 1.11.0 + @method link-to @for Ember.Templates.helpers + @param {String} routeName + @param {Object} [context]* + @param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkComponent + @return {String} HTML string + @see {Ember.LinkComponent} @public */ - var ClosureComponentReference = (function (_CachedReference) { - babelHelpers.inherits(ClosureComponentReference, _CachedReference); + 'use strict'; - ClosureComponentReference.create = function create(args, symbolTable, env) { - return new ClosureComponentReference(args, symbolTable, env); - }; + /** + `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. + + `Ember.LinkComponent` components are invoked with {{#link-to}}. Properties + of this class can be overridden with `reopen` to customize application-wide + behavior. + + @class LinkComponent + @namespace Ember + @extends Ember.Component + @see {Ember.Templates.helpers.link-to} + @public + **/ + var LinkComponent = _emberGlimmerComponent.default.extend({ + layout: _emberGlimmerTemplatesLinkTo.default, - function ClosureComponentReference(args, symbolTable, env) { - babelHelpers.classCallCheck(this, ClosureComponentReference); + tagName: 'a', - _CachedReference.call(this); - this.defRef = args.positional.at(0); - this.env = env; - this.tag = args.positional.at(0).tag; - this.symbolTable = symbolTable; - this.args = args; - this.lastDefinition = undefined; - this.lastName = undefined; - } + /** + @deprecated Use current-when instead. + @property currentWhen + @private + */ + currentWhen: _emberRuntime.deprecatingAlias('current-when', { id: 'ember-routing-view.deprecated-current-when', until: '3.0.0' }), - ClosureComponentReference.prototype.compute = function compute() { - // TODO: Figure out how to extract this because it's nearly identical to - // DynamicComponentReference::compute(). The only differences besides - // currying are in the assertion messages. - var args = this.args; - var defRef = this.defRef; - var env = this.env; - var symbolTable = this.symbolTable; - var lastDefinition = this.lastDefinition; - var lastName = this.lastName; + /** + Used to determine when this `LinkComponent` is active. + @property currentWhen + @public + */ + 'current-when': null, - var nameOrDef = defRef.value(); - var definition = null; + /** + Sets the `title` attribute of the `LinkComponent`'s HTML element. + @property title + @default null + @public + **/ + title: null, - if (nameOrDef && nameOrDef === lastName) { - return lastDefinition; - } + /** + Sets the `rel` attribute of the `LinkComponent`'s HTML element. + @property rel + @default null + @public + **/ + rel: null, - this.lastName = nameOrDef; + /** + Sets the `tabindex` attribute of the `LinkComponent`'s HTML element. + @property tabindex + @default null + @public + **/ + tabindex: null, - if (typeof nameOrDef === 'string') { - definition = env.getComponentDefinition([nameOrDef], symbolTable); - _emberMetal.assert('The component helper cannot be used without a valid component name. You used "' + nameOrDef + '" via (component "' + nameOrDef + '")', definition); - } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { - definition = nameOrDef; - } else { - _emberMetal.assert('You cannot create a component from ' + nameOrDef + ' using the {{component}} helper', nameOrDef); - return null; - } + /** + Sets the `target` attribute of the `LinkComponent`'s HTML element. + @since 1.8.0 + @property target + @default null + @public + **/ + target: null, - var newDef = createCurriedDefinition(definition, args); + /** + The CSS class to apply to `LinkComponent`'s element when its `active` + property is `true`. + @property activeClass + @type String + @default active + @public + **/ + activeClass: 'active', - this.lastDefinition = newDef; + /** + The CSS class to apply to `LinkComponent`'s element when its `loading` + property is `true`. + @property loadingClass + @type String + @default loading + @private + **/ + loadingClass: 'loading', - return newDef; - }; + /** + The CSS class to apply to a `LinkComponent`'s element when its `disabled` + property is `true`. + @property disabledClass + @type String + @default disabled + @private + **/ + disabledClass: 'disabled', + _isDisabled: false, - return ClosureComponentReference; - })(_emberGlimmerUtilsReferences.CachedReference); + /** + Determines whether the `LinkComponent` will trigger routing via + the `replaceWith` routing strategy. + @property replace + @type Boolean + @default false + @public + **/ + replace: false, - exports.ClosureComponentReference = ClosureComponentReference; + /** + By default the `{{link-to}}` component will bind to the `href` and + `title` attributes. It's discouraged that you override these defaults, + however you can push onto the array if needed. + @property attributeBindings + @type Array | String + @default ['title', 'rel', 'tabindex', 'target'] + @public + */ + attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'], - function createCurriedDefinition(definition, args) { - var curriedArgs = curryArgs(definition, args); + /** + By default the `{{link-to}}` component will bind to the `active`, `loading`, + and `disabled` classes. It is discouraged to override these directly. + @property classNameBindings + @type Array + @default ['active', 'loading', 'disabled', 'ember-transitioning-in', 'ember-transitioning-out'] + @public + */ + classNameBindings: ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'], - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(definition.name, definition.ComponentClass, definition.template, curriedArgs); - } + /** + By default the `{{link-to}}` component responds to the `click` event. You + can override this globally by setting this property to your custom + event name. + This is particularly useful on mobile when one wants to avoid the 300ms + click delay using some sort of custom `tap` event. + @property eventName + @type String + @default click + @private + */ + eventName: 'click', - function curryArgs(definition, newArgs) { - var args = definition.args; - var ComponentClass = definition.ComponentClass; - var positionalParams = ComponentClass.positionalParams; + // this is doc'ed here so it shows up in the events + // section of the API documentation, which is where + // people will likely go looking for it. + /** + Triggers the `LinkComponent`'s routing behavior. If + `eventName` is changed to a value other than `click` + the routing behavior will trigger on that custom event + instead. + @event click + @private + */ - // The args being passed in are from the (component ...) invocation, - // so the first positional argument is actually the name or component - // definition. It needs to be dropped in order for any actual positional - // args to coincide with the ComponentClass's positionParams. + /** + An overridable method called when `LinkComponent` objects are instantiated. + Example: + ```javascript + App.MyLinkComponent = Ember.LinkComponent.extend({ + init: function() { + this._super(...arguments); + Ember.Logger.log('Event is ' + this.get('eventName')); + } + }); + ``` + NOTE: If you do override `init` for a framework class like `Ember.View`, + be sure to call `this._super(...arguments)` in your + `init` declaration! If you don't, Ember may not have an opportunity to + do important setup work, and you'll see strange behavior in your + application. + @method init + @private + */ + init: function () { + this._super.apply(this, arguments); - // For "normal" curly components this slicing is done at the syntax layer, - // but we don't have that luxury here. + // Map desired event name to invoke function + var eventName = _emberMetal.get(this, 'eventName'); + this.on(eventName, this, this._invoke); + }, - var _newArgs$positional$values = newArgs.positional.values; + _routing: _emberRuntime.inject.service('-routing'), - var slicedPositionalArgs = _newArgs$positional$values.slice(1); + /** + Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass` + CSS `class` to the element when the link is disabled. + When `true` interactions with the element will not trigger route changes. + @property disabled + @private + */ + disabled: _emberMetal.computed({ + get: function (key, value) { + return false; + }, + set: function (key, value) { + if (value !== undefined) { + this.set('_isDisabled', value); + } - if (positionalParams && slicedPositionalArgs.length) { - _emberGlimmerSyntaxCurlyComponent.validatePositionalParameters(newArgs.named, slicedPositionalArgs, positionalParams); - } + return value ? _emberMetal.get(this, 'disabledClass') : false; + } + }), - var isRest = typeof positionalParams === 'string'; + _computeActive: function (routerState) { + if (_emberMetal.get(this, 'loading')) { + return false; + } - // For non-rest position params, we need to perform the position -> name mapping - // at each layer to avoid a collision later when the args are used to construct - // the component instance (inside of processArgs(), inside of create()). - var positionalToNamedParams = {}; + var routing = _emberMetal.get(this, '_routing'); + var models = _emberMetal.get(this, 'models'); + var resolvedQueryParams = _emberMetal.get(this, 'resolvedQueryParams'); - if (!isRest && positionalParams && positionalParams.length > 0) { - var limit = Math.min(positionalParams.length, slicedPositionalArgs.length); + var currentWhen = _emberMetal.get(this, 'current-when'); + var isCurrentWhenSpecified = !!currentWhen; + currentWhen = currentWhen || _emberMetal.get(this, 'qualifiedRouteName'); + currentWhen = currentWhen.split(' '); - for (var i = 0; i < limit; i++) { - var _name = positionalParams[i]; - positionalToNamedParams[_name] = slicedPositionalArgs[i]; + for (var i = 0; i < currentWhen.length; i++) { + if (routing.isActiveForRoute(models, resolvedQueryParams, currentWhen[i], routerState, isCurrentWhenSpecified)) { + return _emberMetal.get(this, 'activeClass'); + } } - slicedPositionalArgs.length = 0; // Throw them away since you're merged in. - } + return false; + }, - // args (aka 'oldArgs') may be undefined or simply be empty args, so - // we need to fall back to an empty array or object. - var oldNamed = args && args.named && args.named.map || {}; - var oldPositional = args && args.positional && args.positional.values || []; + /** + Accessed as a classname binding to apply the `LinkComponent`'s `activeClass` + CSS `class` to the element when the link is active. + A `LinkComponent` is considered active when its `currentWhen` property is `true` + or the application's current route is the route the `LinkComponent` would trigger + transitions into. + The `currentWhen` property can match against multiple routes by separating + route names using the ` ` (space) character. + @property active + @private + */ + active: _emberMetal.computed('attrs.params', '_routing.currentState', function computeLinkToComponentActive() { + var currentState = _emberMetal.get(this, '_routing.currentState'); + if (!currentState) { + return false; + } - // Merge positional arrays - var mergedPositional = new Array(Math.max(oldPositional.length, slicedPositionalArgs.length)); - mergedPositional.splice.apply(mergedPositional, [0, oldPositional.length].concat(oldPositional)); - mergedPositional.splice.apply(mergedPositional, [0, slicedPositionalArgs.length].concat(slicedPositionalArgs)); + return this._computeActive(currentState); + }), - // Merge named maps - var mergedNamed = _emberUtils.assign({}, oldNamed, positionalToNamedParams, newArgs.named.map); + willBeActive: _emberMetal.computed('_routing.targetState', function computeLinkToComponentWillBeActive() { + var routing = _emberMetal.get(this, '_routing'); + var targetState = _emberMetal.get(routing, 'targetState'); + if (_emberMetal.get(routing, 'currentState') === targetState) { + return; + } - var mergedArgs = _glimmerRuntime.EvaluatedArgs.create(_glimmerRuntime.EvaluatedPositionalArgs.create(mergedPositional), _glimmerRuntime.EvaluatedNamedArgs.create(mergedNamed), _glimmerRuntime.Blocks.empty()); + return !!this._computeActive(targetState); + }), - return mergedArgs; - } + transitioningIn: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningIn() { + var willBeActive = _emberMetal.get(this, 'willBeActive'); + if (typeof willBeActive === 'undefined') { + return false; + } - exports.default = function (vm, args, symbolTable) { - return ClosureComponentReference.create(args, symbolTable, vm.env); - }; -}); -enifed('ember-glimmer/helpers/concat', ['exports', 'ember-glimmer/utils/references', 'glimmer-runtime'], function (exports, _emberGlimmerUtilsReferences, _glimmerRuntime) { - 'use strict'; + return !_emberMetal.get(this, 'active') && willBeActive && 'ember-transitioning-in'; + }), - /** - @module ember - @submodule ember-glimmer - */ + transitioningOut: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningOut() { + var willBeActive = _emberMetal.get(this, 'willBeActive'); + if (typeof willBeActive === 'undefined') { + return false; + } - /** - Concatenates the given arguments into a string. - - Example: - - ```handlebars - {{some-component name=(concat firstName " " lastName)}} - - {{! would pass name=" " to the component}} - ``` - - @public - @method concat - @for Ember.Templates.helpers - @since 1.13.0 - */ - function concat(_ref) { - var positional = _ref.positional; + return _emberMetal.get(this, 'active') && !willBeActive && 'ember-transitioning-out'; + }), - return positional.value().map(_glimmerRuntime.normalizeTextValue).join(''); - } + /** + Event handler that invokes the link, activating the associated route. + @method _invoke + @param {Event} event + @private + */ + _invoke: function (event) { + if (!_emberViews.isSimpleClick(event)) { + return true; + } - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(concat, args); - }; -}); -enifed('ember-glimmer/helpers/debugger', ['exports', 'ember-metal/debug', 'glimmer-runtime'], function (exports, _emberMetalDebug, _glimmerRuntime) { - /*jshint debug:true*/ + var preventDefault = _emberMetal.get(this, 'preventDefault'); + var targetAttribute = _emberMetal.get(this, 'target'); - /** - @module ember - @submodule ember-htmlbars - */ + if (preventDefault !== false) { + if (!targetAttribute || targetAttribute === '_self') { + event.preventDefault(); + } + } - 'use strict'; + if (_emberMetal.get(this, 'bubbles') === false) { + event.stopPropagation(); + } - exports.default = debuggerHelper; - exports.setDebuggerCallback = setDebuggerCallback; - exports.resetDebuggerCallback = resetDebuggerCallback; + if (_emberMetal.get(this, '_isDisabled')) { + return false; + } - /** - Execute the `debugger` statement in the current template's context. - - ```handlebars - {{debugger}} - ``` - - When using the debugger helper you will have access to a `get` function. This - function retrieves values available in the context of the template. - For example, if you're wondering why a value `{{foo}}` isn't rendering as - expected within a template, you could place a `{{debugger}}` statement and, - when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: - - ``` - > get('foo') - ``` - - `get` is also aware of block variables. So in this situation - - ```handlebars - {{#each items as |item|}} - {{debugger}} - {{/each}} - ``` - - You'll be able to get values from the current item: - - ``` - > get('item.name') - ``` - - You can also access the context of the view to make sure it is the object that - you expect: - - ``` - > context - ``` - - @method debugger - @for Ember.Templates.helpers - @public - */ - function defaultCallback(context, get) { - /* jshint debug: true */ + if (_emberMetal.get(this, 'loading')) { + _emberConsole.default.warn('This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'); + return false; + } + + if (targetAttribute && targetAttribute !== '_self') { + return false; + } - _emberMetalDebug.info('Use `context`, and `get()` to debug this template.'); + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var models = _emberMetal.get(this, 'models'); + var queryParams = _emberMetal.get(this, 'queryParams.values'); + var shouldReplace = _emberMetal.get(this, 'replace'); - debugger; - } + var payload = { + queryParams: queryParams, + routeName: qualifiedRouteName + }; - var callback = defaultCallback; + _emberMetal.flaggedInstrument('interaction.link-to', payload, this._generateTransition(payload, qualifiedRouteName, models, queryParams, shouldReplace)); + }, - function debuggerHelper(vm, args, symbolTable) { - var context = vm.getSelf().value(); + _generateTransition: function (payload, qualifiedRouteName, models, queryParams, shouldReplace) { + var routing = _emberMetal.get(this, '_routing'); + return function () { + payload.transition = routing.transitionTo(qualifiedRouteName, models, queryParams, shouldReplace); + }; + }, - // Note: this is totally an overkill since we are only compiling - // expressions, but this is the only kind of SymbolLookup we can - // construct. The symbol table itself should really be sufficient - // here – we should refactor the Glimmer code to make that possible. - var symbolLookup = new _glimmerRuntime.CompileIntoList(vm.env, symbolTable); + queryParams: null, - function get(path) { - // Problem: technically, we are getting a `PublicVM` here, but to - // evaluate an expression it requires the full VM. We happen to know - // that they are the same thing, so this would work for now. However - // this might break in the future. - return _glimmerRuntime.GetSyntax.build(path).compile(symbolLookup).evaluate(vm).value(); - } + qualifiedRouteName: _emberMetal.computed('targetRouteName', '_routing.currentState', function computeLinkToComponentQualifiedRouteName() { + var params = _emberMetal.get(this, 'params').slice(); + var lastParam = params[params.length - 1]; + if (lastParam && lastParam.isQueryParams) { + params.pop(); + } + var onlyQueryParamsSupplied = this[_emberGlimmerComponent.HAS_BLOCK] ? params.length === 0 : params.length === 1; + if (onlyQueryParamsSupplied) { + return _emberMetal.get(this, '_routing.currentRouteName'); + } + return _emberMetal.get(this, 'targetRouteName'); + }), - callback(context, get); + resolvedQueryParams: _emberMetal.computed('queryParams', function computeLinkToComponentResolvedQueryParams() { + var resolvedQueryParams = {}; + var queryParams = _emberMetal.get(this, 'queryParams'); - return _glimmerRuntime.UNDEFINED_REFERENCE; - } + if (!queryParams) { + return resolvedQueryParams; + } - // These are exported for testing + var values = queryParams.values; + for (var key in values) { + if (!values.hasOwnProperty(key)) { + continue; + } + resolvedQueryParams[key] = values[key]; + } - function setDebuggerCallback(newCallback) { - callback = newCallback; - } + return resolvedQueryParams; + }), - function resetDebuggerCallback() { - callback = defaultCallback; - } + /** + Sets the element's `href` attribute to the url for + the `LinkComponent`'s targeted route. + If the `LinkComponent`'s `tagName` is changed to a value other + than `a`, this property will be ignored. + @property href + @private + */ + href: _emberMetal.computed('models', 'qualifiedRouteName', function computeLinkToComponentHref() { + if (_emberMetal.get(this, 'tagName') !== 'a') { + return; + } + + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var models = _emberMetal.get(this, 'models'); + + if (_emberMetal.get(this, 'loading')) { + return _emberMetal.get(this, 'loadingHref'); + } + + var routing = _emberMetal.get(this, '_routing'); + var queryParams = _emberMetal.get(this, 'queryParams.values'); + + _emberMetal.runInDebug(function () { + /* + * Unfortunately, to get decent error messages, we need to do this. + * In some future state we should be able to use a "feature flag" + * which allows us to strip this without needing to call it twice. + * + * if (isDebugBuild()) { + * // Do the useful debug thing, probably including try/catch. + * } else { + * // Do the performant thing. + * } + */ + try { + routing.generateURL(qualifiedRouteName, models, queryParams); + } catch (e) { + _emberMetal.assert('You attempted to define a `{{link-to "' + qualifiedRouteName + '"}}` but did not pass the parameters required for generating its dynamic segments. ' + e.message); + } + }); + + return routing.generateURL(qualifiedRouteName, models, queryParams); + }), + + loading: _emberMetal.computed('_modelsAreLoaded', 'qualifiedRouteName', function computeLinkToComponentLoading() { + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var modelsAreLoaded = _emberMetal.get(this, '_modelsAreLoaded'); + + if (!modelsAreLoaded || qualifiedRouteName == null) { + return _emberMetal.get(this, 'loadingClass'); + } + }), + + _modelsAreLoaded: _emberMetal.computed('models', function computeLinkToComponentModelsAreLoaded() { + var models = _emberMetal.get(this, 'models'); + for (var i = 0; i < models.length; i++) { + if (models[i] == null) { + return false; + } + } + + return true; + }), + + _getModels: function (params) { + var modelCount = params.length - 1; + var models = new Array(modelCount); + + for (var i = 0; i < modelCount; i++) { + var value = params[i + 1]; + + while (_emberRuntime.ControllerMixin.detect(value)) { + _emberMetal.deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. ' + (this.parentView ? 'Please update `' + this.parentView + '` to use `{{link-to "post" someController.model}}` instead.' : ''), false, { id: 'ember-routing-views.controller-wrapped-param', until: '3.0.0' }); + value = value.get('model'); + } + + models[i] = value; + } + + return models; + }, + + /** + The default href value to use while a link-to is loading. + Only applies when tagName is 'a' + @property loadingHref + @type String + @default # + @private + */ + loadingHref: '#', + + didReceiveAttrs: function () { + var queryParams = undefined; + + var params = _emberMetal.get(this, 'params'); + + if (params) { + // Do not mutate params in place + params = params.slice(); + } + + _emberMetal.assert('You must provide one or more parameters to the link-to component.', (function () { + if (!params) { + return false; + } + + return params.length; + })()); + + var disabledWhen = _emberMetal.get(this, 'disabledWhen'); + if (disabledWhen !== undefined) { + this.set('disabled', disabledWhen); + } + + // Process the positional arguments, in order. + // 1. Inline link title comes first, if present. + if (!this[_emberGlimmerComponent.HAS_BLOCK]) { + this.set('linkTitle', params.shift()); + } + + // 2. `targetRouteName` is now always at index 0. + this.set('targetRouteName', params[0]); + + // 3. The last argument (if still remaining) is the `queryParams` object. + var lastParam = params[params.length - 1]; + + if (lastParam && lastParam.isQueryParams) { + queryParams = params.pop(); + } else { + queryParams = { values: {} }; + } + this.set('queryParams', queryParams); + + // 4. Any remaining indices (excepting `targetRouteName` at 0) are `models`. + if (params.length > 1) { + this.set('models', this._getModels(params)); + } else { + this.set('models', []); + } + } + }); + + LinkComponent.toString = function () { + return 'LinkComponent'; + }; + + LinkComponent.reopenClass({ + positionalParams: 'params' + }); + + exports.default = LinkComponent; }); -enifed('ember-glimmer/helpers/each-in', ['exports', 'ember-utils'], function (exports, _emberUtils) { +enifed('ember-glimmer/components/text_area', ['exports', 'ember-glimmer/component', 'ember-views', 'ember-glimmer/templates/empty'], function (exports, _emberGlimmerComponent, _emberViews, _emberGlimmerTemplatesEmpty) { /** @module ember @submodule ember-glimmer */ 'use strict'; - exports.isEachIn = isEachIn; - /** - The `{{#each}}` helper loops over elements in a collection. It is an extension - of the base Handlebars `{{#each}}` helper. - The default behavior of `{{#each}}` is to yield its inner block once for every - item in an array passing the item as the first block parameter. + `{{textarea}}` inserts a new instance of ` ``` - ### Specifying Keys + Bound: - The `key` option is used to tell Ember how to determine if the array being - iterated over with `{{#each}}` has changed between renders. By helping Ember - detect that some elements in the array are the same, DOM elements can be - re-used, significantly improving rendering speed. + In the following example, the `writtenWords` property on `App.ApplicationController` + will be updated live as the user types 'Lots of text that IS bound' into + the text area of their browser's window. - For example, here's the `{{#each}}` helper with its `key` set to `id`: + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound" + }); + ``` ```handlebars - {{#each model key="id" as |item|}} - {{/each}} + {{textarea value=writtenWords}} ``` - When this `{{#each}}` re-renders, Ember will match up the previously rendered - items (and reorder the generated DOM elements) based on each item's `id` - property. - By default the item's own reference is used. - - ### {{else}} condition - - `{{#each}}` can have a matching `{{else}}`. The contents of this block will render - if the collection is empty. + Would result in the following HTML: - ```handlebars - {{#each developers as |person|}} - {{person.name}} - {{else}} -

    Sorry, nobody is available for this task.

    - {{/each}} + ```html + ``` - @method each - @for Ember.Templates.helpers - @public - */ - - /** - The `{{each-in}}` helper loops over properties on an object. - - For example, given a `user` object that looks like: + If you wanted a one way binding between the text area and a div tag + somewhere else on your screen, you could use `Ember.computed.oneWay`: ```javascript - { - "name": "Shelly Sails", - "age": 42 - } + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + outputWrittenWords: Ember.computed.oneWay("writtenWords") + }); ``` - This template would display all properties on the `user` - object in a list: - ```handlebars -
      - {{#each-in user as |key value|}} -
    • {{key}}: {{value}}
    • - {{/each-in}} -
    + {{textarea value=writtenWords}} +
    + {{outputWrittenWords}} +
    ``` - Outputting their name and age. + Would result in the following HTML: - @method each-in - @for Ember.Templates.helpers - @public - @since 2.1.0 - */ - var EACH_IN_REFERENCE = _emberUtils.symbol('EACH_IN'); - - function isEachIn(ref) { - return ref && ref[EACH_IN_REFERENCE]; - } - - exports.default = function (vm, args) { - var ref = Object.create(args.positional.at(0)); - ref[EACH_IN_REFERENCE] = true; - return ref; - }; -}); -enifed('ember-glimmer/helpers/get', ['exports', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - 'use strict'; - - /** - @module ember - @submodule ember-glimmer - */ - - /** - Dynamically look up a property on an object. The second argument to `{{get}}` - should have a string value, although it can be bound. + ```html + + <-- the following div will be updated in real time as you type --> +
    + Lots of text that IS bound +
    + ``` - For example, these two usages are equivilent: + Finally, this example really shows the power and ease of Ember when two + properties are bound to eachother via `Ember.computed.alias`. Type into + either text area box and they'll both stay in sync. Note that + `Ember.computed.alias` costs more in terms of performance, so only use it when + your really binding in both directions: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + twoWayWrittenWords: Ember.computed.alias("writtenWords") + }); + ``` ```handlebars - {{person.height}} - {{get person "height"}} + {{textarea value=writtenWords}} + {{textarea value=twoWayWrittenWords}} ``` - If there were several facts about a person, the `{{get}}` helper can dynamically - pick one: + ```html + + <-- both updated in real time --> + + ``` + + ### Actions + + The helper can send multiple actions based on user events. + The action property defines the action which is send when + the user presses the return key. ```handlebars - {{get person factName}} + {{input action="submit"}} ``` - For a more complex example, this template would allow the user to switch - between showing the user's height and weight with a click: + The helper allows some user events to send actions. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. ```handlebars - {{get person factName}} - - + {{textarea focus-in="alertMessage"}} ``` - The `{{get}}` helper can also respect mutable values itself. For example: + See more about [Text Support Actions](/api/classes/Ember.TextArea.html) - ```handlebars - {{input value=(mut (get person factName)) type="text"}} - - + ### Extension + + Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing + arguments from the helper to `Ember.TextArea`'s `create` method. You can + extend the capabilities of text areas in your application by reopening this + class. For example, if you are building a Bootstrap project where `data-*` + attributes are used, you can globally add support for a `data-*` attribute + on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or + `Ember.TextSupport` and adding it to the `attributeBindings` concatenated + property: + + ```javascript + Ember.TextArea.reopen({ + attributeBindings: ['data-error'] + }); ``` - Would allow the user to swap what fact is being displayed, and also edit - that fact via a two-way mutable binding. + Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` + itself extends `Ember.Component`. Expect isolated component semantics, not + legacy 1.x view semantics (like `controller` being present). - @public - @method get + See more about [Ember components](/api/classes/Ember.Component.html) + + @method textarea @for Ember.Templates.helpers - @since 2.1.0 - */ + @param {Hash} options + @public + */ - exports.default = function (vm, args) { - return GetHelperReference.create(args.positional.at(0), args.positional.at(1)); - }; + /** + The internal class used to create textarea element when the `{{textarea}}` + helper is used. + + See [Ember.Templates.helpers.textarea](/api/classes/Ember.Templates.helpers.html#method_textarea) for usage details. + + ## Layout and LayoutName properties + + Because HTML `textarea` elements do not contain inner HTML the `layout` and + `layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextArea + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + @public + */ + exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { + classNames: ['ember-text-area'], - var GetHelperReference = (function (_CachedReference) { - babelHelpers.inherits(GetHelperReference, _CachedReference); + layout: _emberGlimmerTemplatesEmpty.default, - GetHelperReference.create = function create(sourceReference, pathReference) { - if (_glimmerReference.isConst(pathReference)) { - var parts = pathReference.value().split('.'); - return _glimmerReference.referenceFromParts(sourceReference, parts); - } else { - return new GetHelperReference(sourceReference, pathReference); - } - }; + tagName: 'textarea', + attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir', 'value'], + rows: null, + cols: null + }); +}); +enifed('ember-glimmer/components/text_field', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-glimmer/component', 'ember-glimmer/templates/empty', 'ember-views'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty, _emberViews) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - function GetHelperReference(sourceReference, pathReference) { - babelHelpers.classCallCheck(this, GetHelperReference); + var inputTypeTestElement = undefined; + var inputTypes = new _emberUtils.EmptyObject(); + function canSetTypeOfInput(type) { + if (type in inputTypes) { + return inputTypes[type]; + } - _CachedReference.call(this); - this.sourceReference = sourceReference; - this.pathReference = pathReference; + // if running in outside of a browser always return the + // original type + if (!_emberEnvironment.environment.hasDOM) { + inputTypes[type] = type; - this.lastPath = null; - this.innerReference = null; + return type; + } - var innerTag = this.innerTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + if (!inputTypeTestElement) { + inputTypeTestElement = document.createElement('input'); + } - this.tag = _glimmerReference.combine([sourceReference.tag, pathReference.tag, innerTag]); + try { + inputTypeTestElement.type = type; + } catch (e) { + // ignored } - GetHelperReference.prototype.compute = function compute() { - var lastPath = this.lastPath; - var innerReference = this.innerReference; - var innerTag = this.innerTag; + return inputTypes[type] = inputTypeTestElement.type === type; + } - var path = this.lastPath = this.pathReference.value(); + /** + + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `text`. + + See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. + + ## Layout and LayoutName properties + + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextField + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + @public + */ + exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { + layout: _emberGlimmerTemplatesEmpty.default, + classNames: ['ember-text-field'], + tagName: 'input', + attributeBindings: ['accept', 'autocomplete', 'autosave', 'dir', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'inputmode', 'lang', 'list', 'max', 'min', 'multiple', 'name', 'pattern', 'size', 'step', 'type', 'value', 'width'], - if (path !== lastPath) { - if (path) { - var pathType = typeof path; + /** + The `value` attribute of the input element. As the user inputs text, this + property is updated live. + @property value + @type String + @default "" + @public + */ + value: '', - if (pathType === 'string') { - innerReference = this.innerReference = _glimmerReference.referenceFromParts(this.sourceReference, path.split('.')); - } else if (pathType === 'number') { - innerReference = this.innerReference = this.sourceReference.get(path); - } + /** + The `type` attribute of the input element. + @property type + @type String + @default "text" + @public + */ + type: _emberMetal.computed({ + get: function () { + return 'text'; + }, - innerTag.update(innerReference.tag); - } else { - innerReference = this.innerReference = null; - innerTag.update(_glimmerReference.CONSTANT_TAG); - } - } + set: function (key, value) { + var type = 'text'; - return innerReference ? innerReference.value() : null; - }; + if (canSetTypeOfInput(value)) { + type = value; + } - GetHelperReference.prototype[_emberGlimmerUtilsReferences.UPDATE] = function (value) { - _emberMetal.set(this.sourceReference.value(), this.pathReference.value(), value); - }; + return type; + } + }), - return GetHelperReference; - })(_emberGlimmerUtilsReferences.CachedReference); -}); -enifed("ember-glimmer/helpers/hash", ["exports"], function (exports) { - /** - @module ember - @submodule ember-glimmer - */ + /** + The `size` of the text field in characters. + @property size + @type String + @default null + @public + */ + size: null, - /** - Use the `{{hash}}` helper to create a hash to pass as an option to your - components. This is specially useful for contextual components where you can - just yield a hash: - - ```handlebars - {{yield (hash - name='Sarah' - title=office - )}} - ``` - - Would result in an object such as: - - ```js - { name: 'Sarah', title: this.get('office') } - ``` - - Where the `title` is bound to updates of the `office` property. - - @method hash - @for Ember.Templates.helpers - @param {Object} options - @return {Object} Hash + /** + The `pattern` attribute of input element. + @property pattern + @type String + @default null @public */ + pattern: null, - "use strict"; + /** + The `min` attribute of input element used with `type="number"` or `type="range"`. + @property min + @type String + @default null + @since 1.4.0 + @public + */ + min: null, - exports.default = function (vm, args) { - return args.named; - }; + /** + The `max` attribute of input element used with `type="number"` or `type="range"`. + @property max + @type String + @default null + @since 1.4.0 + @public + */ + max: null + }); }); -enifed('ember-glimmer/helpers/if-unless', ['exports', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - /** - @module ember - @submodule ember-glimmer - */ - +enifed('ember-glimmer/dom', ['exports', '@glimmer/runtime', '@glimmer/node'], function (exports, _glimmerRuntime, _glimmerNode) { 'use strict'; - exports.inlineIf = inlineIf; - exports.inlineUnless = inlineUnless; + exports.DOMChanges = _glimmerRuntime.DOMChanges; + exports.DOMTreeConstruction = _glimmerRuntime.DOMTreeConstruction; + exports.NodeDOMTreeConstruction = _glimmerNode.NodeDOMTreeConstruction; +}); +enifed('ember-glimmer/environment', ['exports', 'ember-utils', 'ember-metal', 'ember-views', '@glimmer/runtime', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/utils/debug-stack', 'ember-glimmer/helpers/if-unless', 'ember-glimmer/helpers/action', 'ember-glimmer/helpers/component', 'ember-glimmer/helpers/concat', 'ember-glimmer/helpers/get', 'ember-glimmer/helpers/hash', 'ember-glimmer/helpers/loc', 'ember-glimmer/helpers/log', 'ember-glimmer/helpers/mut', 'ember-glimmer/helpers/readonly', 'ember-glimmer/helpers/unbound', 'ember-glimmer/helpers/-class', 'ember-glimmer/helpers/-input-type', 'ember-glimmer/helpers/query-param', 'ember-glimmer/helpers/each-in', 'ember-glimmer/helpers/-normalize-class', 'ember-glimmer/helpers/-html-safe', 'ember-glimmer/protocol-for-url', 'container', 'ember-glimmer/modifiers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _glimmerRuntime, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntax, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerUtilsDebugStack, _emberGlimmerHelpersIfUnless, _emberGlimmerHelpersAction, _emberGlimmerHelpersComponent, _emberGlimmerHelpersConcat, _emberGlimmerHelpersGet, _emberGlimmerHelpersHash, _emberGlimmerHelpersLoc, _emberGlimmerHelpersLog, _emberGlimmerHelpersMut, _emberGlimmerHelpersReadonly, _emberGlimmerHelpersUnbound, _emberGlimmerHelpersClass, _emberGlimmerHelpersInputType, _emberGlimmerHelpersQueryParam, _emberGlimmerHelpersEachIn, _emberGlimmerHelpersNormalizeClass, _emberGlimmerHelpersHtmlSafe, _emberGlimmerProtocolForUrl, _container, _emberGlimmerModifiersAction) { + 'use strict'; - /** - Use the `if` block helper to conditionally render a block depending on a - property. If the property is "falsey", for example: `false`, `undefined`, - `null`, `""`, `0`, `NaN` or an empty array, the block will not be rendered. - - ```handlebars - {{! will not render if foo is falsey}} - {{#if foo}} - Welcome to the {{foo.bar}} - {{/if}} - ``` - - You can also specify a template to show if the property is falsey by using - the `else` helper. - - ```handlebars - {{! is it raining outside?}} - {{#if isRaining}} - Yes, grab an umbrella! - {{else}} - No, it's lovely outside! - {{/if}} - ``` - - You are also able to combine `else` and `if` helpers to create more complex - conditional logic. - - ```handlebars - {{#if isMorning}} - Good morning - {{else if isAfternoon}} - Good afternoon - {{else}} - Good night - {{/if}} - ``` - - You can use `if` inline to conditionally render a single property or string. - This helper acts like a ternary operator. If the first property is truthy, - the second argument will be displayed, if not, the third argument will be - displayed - - ```handlebars - {{if useLongGreeting "Hello" "Hi"}} Dave - ``` - - Finally, you can use the `if` helper inside another helper as a subexpression. - - ```handlebars - {{some-component height=(if isBig "100" "10")}} - ``` - - @method if - @for Ember.Templates.helpers - @public - */ + var Environment = (function (_GlimmerEnvironment) { + babelHelpers.inherits(Environment, _GlimmerEnvironment); - var ConditionalHelperReference = (function (_CachedReference) { - babelHelpers.inherits(ConditionalHelperReference, _CachedReference); + Environment.create = function create(options) { + return new Environment(options); + }; - ConditionalHelperReference.create = function create(_condRef, _truthyRef, _falsyRef) { - var condRef = _emberGlimmerUtilsReferences.ConditionalReference.create(_condRef); - var truthyRef = _truthyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; - var falsyRef = _falsyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; + function Environment(_ref) { + var _this = this; - if (_glimmerReference.isConst(condRef)) { - return condRef.value() ? truthyRef : falsyRef; - } else { - return new ConditionalHelperReference(condRef, truthyRef, falsyRef); - } - }; + var owner = _ref[_emberUtils.OWNER]; + babelHelpers.classCallCheck(this, Environment); - function ConditionalHelperReference(cond, truthy, falsy) { - babelHelpers.classCallCheck(this, ConditionalHelperReference); + _GlimmerEnvironment.apply(this, arguments); + this.owner = owner; + this.isInteractive = owner.lookup('-environment:main').isInteractive; - _CachedReference.call(this); + // can be removed once https://github.com/tildeio/glimmer/pull/305 lands + this.destroyedComponents = undefined; - this.branchTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([cond.tag, this.branchTag]); + _emberGlimmerProtocolForUrl.default(this); - this.cond = cond; - this.truthy = truthy; - this.falsy = falsy; - } + this._definitionCache = new _emberMetal.Cache(2000, function (_ref2) { + var name = _ref2.name; + var source = _ref2.source; + var owner = _ref2.owner; - /** - The inline `if` helper conditionally renders a single property or string. - This helper acts like a ternary operator. If the first property is truthy, - the second argument will be displayed, otherwise, the third argument will be - displayed - - ```handlebars - {{if useLongGreeting "Hello" "Hi"}} Alex - ``` - - You can use the `if` helper inside another helper as a subexpression. - - ```handlebars - {{some-component height=(if isBig "100" "10")}} - ``` - - @method if - @for Ember.Templates.helpers - @public - */ + var _lookupComponent = _emberViews.lookupComponent(owner, name, { source: source }); - ConditionalHelperReference.prototype.compute = function compute() { - var cond = this.cond; - var truthy = this.truthy; - var falsy = this.falsy; + var componentFactory = _lookupComponent.component; + var layout = _lookupComponent.layout; - var branch = cond.value() ? truthy : falsy; + if (componentFactory || layout) { + return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(name, componentFactory, layout); + } + }, function (_ref3) { + var name = _ref3.name; + var source = _ref3.source; + var owner = _ref3.owner; - this.branchTag.update(branch.tag); + var expandedName = source && owner._resolveLocalLookupName(name, source) || name; + var ownerGuid = _emberUtils.guidFor(owner); - return branch.value(); - }; + return ownerGuid + '|' + expandedName; + }); - return ConditionalHelperReference; - })(_emberGlimmerUtilsReferences.CachedReference); + this._templateCache = new _emberMetal.Cache(1000, function (_ref4) { + var Template = _ref4.Template; + var owner = _ref4.owner; - function inlineIf(vm, _ref) { - var positional = _ref.positional; + if (Template.create) { + var _Template$create; - switch (positional.length) { - case 2: - return ConditionalHelperReference.create(positional.at(0), positional.at(1), null); - case 3: - return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); - default: - _emberMetal.assert('The inline form of the `if` helper expects two or three arguments, e.g. ' + '`{{if trialExpired "Expired" expiryDate}}`.'); - } - } + // we received a factory + return Template.create((_Template$create = { env: _this }, _Template$create[_emberUtils.OWNER] = owner, _Template$create)); + } else { + // we were provided an instance already + return Template; + } + }, function (_ref5) { + var Template = _ref5.Template; + var owner = _ref5.owner; + return _emberUtils.guidFor(owner) + '|' + Template.id; + }); - /** - The inline `unless` helper conditionally renders a single property or string. - This helper acts like a ternary operator. If the first property is falsy, - the second argument will be displayed, otherwise, the third argument will be - displayed - - ```handlebars - {{unless useLongGreeting "Hi" "Hello"}} Ben - ``` - - You can use the `unless` helper inside another helper as a subexpression. - - ```handlebars - {{some-component height=(unless isBig "10" "100")}} - ``` - - @method unless - @for Ember.Templates.helpers - @public - */ + this._compilerCache = new _emberMetal.Cache(10, function (Compiler) { + return new _emberMetal.Cache(2000, function (template) { + var compilable = new Compiler(template); + return _glimmerRuntime.compileLayout(compilable, _this); + }, function (template) { + var owner = template.meta.owner; + return _emberUtils.guidFor(owner) + '|' + template.id; + }); + }, function (Compiler) { + return Compiler.id; + }); - function inlineUnless(vm, _ref2) { - var positional = _ref2.positional; + this.builtInModifiers = { + action: new _emberGlimmerModifiersAction.default() + }; - switch (positional.length) { - case 2: - return ConditionalHelperReference.create(positional.at(0), null, positional.at(1)); - case 3: - return ConditionalHelperReference.create(positional.at(0), positional.at(2), positional.at(1)); - default: - _emberMetal.assert('The inline form of the `unless` helper expects two or three arguments, e.g. ' + '`{{unless isFirstLogin "Welcome back!"}}`.'); + this.builtInHelpers = { + if: _emberGlimmerHelpersIfUnless.inlineIf, + action: _emberGlimmerHelpersAction.default, + component: _emberGlimmerHelpersComponent.default, + concat: _emberGlimmerHelpersConcat.default, + get: _emberGlimmerHelpersGet.default, + hash: _emberGlimmerHelpersHash.default, + loc: _emberGlimmerHelpersLoc.default, + log: _emberGlimmerHelpersLog.default, + mut: _emberGlimmerHelpersMut.default, + 'query-params': _emberGlimmerHelpersQueryParam.default, + readonly: _emberGlimmerHelpersReadonly.default, + unbound: _emberGlimmerHelpersUnbound.default, + unless: _emberGlimmerHelpersIfUnless.inlineUnless, + '-class': _emberGlimmerHelpersClass.default, + '-each-in': _emberGlimmerHelpersEachIn.default, + '-input-type': _emberGlimmerHelpersInputType.default, + '-normalize-class': _emberGlimmerHelpersNormalizeClass.default, + '-html-safe': _emberGlimmerHelpersHtmlSafe.default, + '-get-dynamic-var': _glimmerRuntime.getDynamicVar + }; + + _emberMetal.runInDebug(function () { + return _this.debugStack = new _emberGlimmerUtilsDebugStack.default(); + }); } - } -}); -enifed('ember-glimmer/helpers/loc', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - /** - Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the - provided string. This is a convenient way to localize text within a template. - For example: - - ```javascript - Ember.STRINGS = { - '_welcome_': 'Bonjour' + Environment.prototype.macros = function macros() { + var macros = _GlimmerEnvironment.prototype.macros.call(this); + _emberGlimmerSyntax.populateMacros(macros.blocks, macros.inlines); + return macros; }; - ``` - - ```handlebars -
    - {{loc '_welcome_'}} -
    - ``` - - ```html -
    - Bonjour -
    - ``` - - See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to - set up localized string references. - - @method loc - @for Ember.Templates.helpers - @param {String} str The string to format. - @see {Ember.String#loc} - @public - */ - function locHelper(_ref) { - var positional = _ref.positional; - return _emberRuntime.String.loc.apply(null, positional.value()); - } + Environment.prototype.hasComponentDefinition = function hasComponentDefinition() { + return false; + }; - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(locHelper, args); - }; -}); -enifed('ember-glimmer/helpers/log', ['exports', 'ember-glimmer/utils/references', 'ember-console'], function (exports, _emberGlimmerUtilsReferences, _emberConsole) { - 'use strict'; + Environment.prototype.getComponentDefinition = function getComponentDefinition(path, symbolTable) { + var name = path[0]; + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var source = blockMeta.moduleName && 'template:' + blockMeta.moduleName; - /** - `log` allows you to output the value of variables in the current rendering - context. `log` also accepts primitive types such as strings or numbers. - - ```handlebars - {{log "myVariable:" myVariable }} - ``` - - @method log - @for Ember.Templates.helpers - @param {Array} params - @public - */ - function log(_ref) { - var positional = _ref.positional; + return this._definitionCache.get({ name: name, source: source, owner: owner }); + }; - _emberConsole.default.log.apply(null, positional.value()); - } + // normally templates should be exported at the proper module name + // and cached in the container, but this cache supports templates + // that have been set directly on the component's layout property - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(log, args); - }; -}); + Environment.prototype.getTemplate = function getTemplate(Template, owner) { + return this._templateCache.get({ Template: Template, owner: owner }); + }; -/** -@module ember -@submodule ember-glimmer -*/ -enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerHelpersAction) { + // a Compiler can wrap the template so it needs its own cache + + Environment.prototype.getCompiledBlock = function getCompiledBlock(Compiler, template) { + var compilerCache = this._compilerCache.get(Compiler); + return compilerCache.get(template); + }; + + Environment.prototype.hasPartial = function hasPartial(name, symbolTable) { + var _symbolTable$getMeta = symbolTable.getMeta(); + + var owner = _symbolTable$getMeta.owner; + + return _emberViews.hasPartial(name, owner); + }; + + Environment.prototype.lookupPartial = function lookupPartial(name, symbolTable) { + var _symbolTable$getMeta2 = symbolTable.getMeta(); + + var owner = _symbolTable$getMeta2.owner; + + var partial = { + template: _emberViews.lookupPartial(name, owner) + }; + + if (partial.template) { + return partial; + } else { + throw new Error(name + ' is not a partial'); + } + }; + + Environment.prototype.hasHelper = function hasHelper(nameParts, symbolTable) { + _emberMetal.assert('The first argument passed into `hasHelper` should be an array', Array.isArray(nameParts)); + + // helpers are not allowed to include a dot in their invocation + if (nameParts.length > 1) { + return false; + } + + var name = nameParts[0]; + + if (this.builtInHelpers[name]) { + return true; + } + + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var options = { source: 'template:' + blockMeta.moduleName }; + + return owner.hasRegistration('helper:' + name, options) || owner.hasRegistration('helper:' + name); + }; + + Environment.prototype.lookupHelper = function lookupHelper(nameParts, symbolTable) { + _emberMetal.assert('The first argument passed into `lookupHelper` should be an array', Array.isArray(nameParts)); + + var name = nameParts[0]; + var helper = this.builtInHelpers[name]; + + if (helper) { + return helper; + } + + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var options = blockMeta.moduleName && { source: 'template:' + blockMeta.moduleName } || {}; + + if (true) { + var _ret = (function () { + var helperFactory = owner[_container.FACTORY_FOR]('helper:' + name, options) || owner[_container.FACTORY_FOR]('helper:' + name); + + // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations + if (helperFactory.class.isHelperInstance) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helperFactory.class.compute, args); + } + }; + } else if (helperFactory.class.isHelperFactory) { + if (!_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + helperFactory = helperFactory.create(); + } + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helperFactory, vm, args); + } + }; + } else { + throw new Error(nameParts + ' is not a helper'); + } + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + var _ret2 = (function () { + var helperFactory = owner.lookup('helper:' + name, options) || owner.lookup('helper:' + name); + + // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations + if (helperFactory.isHelperInstance) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helperFactory.compute, args); + } + }; + } else if (helperFactory.isHelperFactory) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helperFactory, vm, args); + } + }; + } else { + throw new Error(nameParts + ' is not a helper'); + } + })(); + + if (typeof _ret2 === 'object') return _ret2.v; + } + }; + + Environment.prototype.hasModifier = function hasModifier(nameParts) { + _emberMetal.assert('The first argument passed into `hasModifier` should be an array', Array.isArray(nameParts)); + + // modifiers are not allowed to include a dot in their invocation + if (nameParts.length > 1) { + return false; + } + + return !!this.builtInModifiers[nameParts[0]]; + }; + + Environment.prototype.lookupModifier = function lookupModifier(nameParts) { + _emberMetal.assert('The first argument passed into `lookupModifier` should be an array', Array.isArray(nameParts)); + + var modifier = this.builtInModifiers[nameParts[0]]; + + if (modifier) { + return modifier; + } else { + throw new Error(nameParts + ' is not a modifier'); + } + }; + + Environment.prototype.toConditionalReference = function toConditionalReference(reference) { + return _emberGlimmerUtilsReferences.ConditionalReference.create(reference); + }; + + Environment.prototype.iterableFor = function iterableFor(ref, args) { + var keyPath = args.named.get('key').value(); + return _emberGlimmerUtilsIterable.default(ref, keyPath); + }; + + Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier() { + if (this.isInteractive) { + var _GlimmerEnvironment$prototype$scheduleInstallModifier; + + (_GlimmerEnvironment$prototype$scheduleInstallModifier = _GlimmerEnvironment.prototype.scheduleInstallModifier).call.apply(_GlimmerEnvironment$prototype$scheduleInstallModifier, [this].concat(babelHelpers.slice.call(arguments))); + } + }; + + Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier() { + if (this.isInteractive) { + var _GlimmerEnvironment$prototype$scheduleUpdateModifier; + + (_GlimmerEnvironment$prototype$scheduleUpdateModifier = _GlimmerEnvironment.prototype.scheduleUpdateModifier).call.apply(_GlimmerEnvironment$prototype$scheduleUpdateModifier, [this].concat(babelHelpers.slice.call(arguments))); + } + }; + + Environment.prototype.didDestroy = function didDestroy(destroyable) { + destroyable.destroy(); + }; + + Environment.prototype.begin = function begin() { + this.inTransaction = true; + + _GlimmerEnvironment.prototype.begin.call(this); + + this.destroyedComponents = []; + }; + + Environment.prototype.commit = function commit() { + // components queued for destruction must be destroyed before firing + // `didCreate` to prevent errors when removing and adding a component + // with the same name (would throw an error when added to view registry) + for (var i = 0; i < this.destroyedComponents.length; i++) { + this.destroyedComponents[i].destroy(); + } + + _GlimmerEnvironment.prototype.commit.call(this); + + this.inTransaction = false; + }; + + return Environment; + })(_glimmerRuntime.Environment); + + exports.default = Environment; + + _emberMetal.runInDebug(function () { + var StyleAttributeManager = (function (_AttributeManager) { + babelHelpers.inherits(StyleAttributeManager, _AttributeManager); + + function StyleAttributeManager() { + babelHelpers.classCallCheck(this, StyleAttributeManager); + + _AttributeManager.apply(this, arguments); + } + + StyleAttributeManager.prototype.setAttribute = function setAttribute(dom, element, value) { + var _AttributeManager$prototype$setAttribute; + + _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { + if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { + return true; + } + return false; + })(), { id: 'ember-htmlbars.style-xss-warning' }); + (_AttributeManager$prototype$setAttribute = _AttributeManager.prototype.setAttribute).call.apply(_AttributeManager$prototype$setAttribute, [this].concat(babelHelpers.slice.call(arguments))); + }; + + StyleAttributeManager.prototype.updateAttribute = function updateAttribute(dom, element, value) { + var _AttributeManager$prototype$updateAttribute; + + _emberMetal.warn(_emberViews.STYLE_WARNING, (function () { + if (value === null || value === undefined || _glimmerRuntime.isSafeString(value)) { + return true; + } + return false; + })(), { id: 'ember-htmlbars.style-xss-warning' }); + (_AttributeManager$prototype$updateAttribute = _AttributeManager.prototype.updateAttribute).call.apply(_AttributeManager$prototype$updateAttribute, [this].concat(babelHelpers.slice.call(arguments))); + }; + + return StyleAttributeManager; + })(_glimmerRuntime.AttributeManager); + + var STYLE_ATTRIBUTE_MANANGER = new StyleAttributeManager('style'); + + Environment.prototype.attributeFor = function (element, attribute, isTrusting, namespace) { + if (attribute === 'style' && !isTrusting) { + return STYLE_ATTRIBUTE_MANANGER; + } + + return _glimmerRuntime.Environment.prototype.attributeFor.call(this, element, attribute, isTrusting); + }; + }); +}); +enifed('ember-glimmer/helper', ['exports', 'ember-utils', 'ember-runtime', '@glimmer/reference'], function (exports, _emberUtils, _emberRuntime, _glimmerReference) { /** @module ember @submodule ember-glimmer */ + 'use strict'; - exports.isMut = isMut; - exports.unMut = unMut; + exports.helper = helper; + var RECOMPUTE_TAG = _emberUtils.symbol('RECOMPUTE_TAG'); + exports.RECOMPUTE_TAG = RECOMPUTE_TAG; /** - The `mut` helper lets you __clearly specify__ that a child `Component` can update the - (mutable) value passed to it, which will __change the value of the parent component__. - - To specify that a parameter is mutable, when invoking the child `Component`: + Ember Helpers are functions that can compute values, and are used in templates. + For example, this code calls a helper named `format-currency`: ```handlebars - {{my-child childClickCount=(mut totalClicks)}} - ``` - - The child `Component` can then modify the parent's value just by modifying its own - property: - - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.incrementProperty('childClickCount'); - } - }); +
    {{format-currency cents currency="$"}}
    ``` - Note that for curly components (`{{my-component}}`) the bindings are already mutable, - making the `mut` unnecessary. - - Additionally, the `mut` helper can be combined with the `action` helper to - mutate a value. For example: + Additionally a helper can be called as a nested helper (sometimes called a + subexpression). In this example, the computed value of a helper is passed + to a component named `show-money`: ```handlebars - {{my-child childClickCount=totalClicks click-count-change=(action (mut totalClicks))}} + {{show-money amount=(format-currency cents currency="$")}} ``` - The child `Component` would invoke the action with the new click value: + Helpers defined using a class must provide a `compute` function. For example: - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.get('click-count-change')(this.get('childClickCount') + 1); + ```js + export default Ember.Helper.extend({ + compute(params, hash) { + let cents = params[0]; + let currency = hash.currency; + return `${currency}${cents * 0.01}`; } }); ``` - The `mut` helper changes the `totalClicks` value to what was provided as the action argument. - - The `mut` helper, when used with `action`, will return a function that - sets the value passed to `mut` to its first argument. This works like any other - closure action and interacts with the other features `action` provides. - As an example, we can create a button that increments a value passing the value - directly to the `action`: - - ```handlebars - {{! inc helper is not provided by Ember }} - - ``` + Each time the input to a helper changes, the `compute` function will be + called again. - You can also use the `value` option: + As instances, these helpers also have access to the container an will accept + injected dependencies. - ```handlebars - - ``` + Additionally, class helpers can call `recompute` to force a new computation. - @method mut - @param {Object} [attr] the "two-way" attribute that can be modified. - @for Ember.Templates.helpers + @class Ember.Helper @public + @since 1.13.0 */ - var MUT_REFERENCE = _emberUtils.symbol('MUT'); - var SOURCE = _emberUtils.symbol('SOURCE'); + var Helper = _emberRuntime.FrameworkObject.extend({ + isHelperInstance: true, - function isMut(ref) { - return ref && ref[MUT_REFERENCE]; - } + init: function () { + this._super.apply(this, arguments); + this[RECOMPUTE_TAG] = new _glimmerReference.DirtyableTag(); + }, - function unMut(ref) { - return ref[SOURCE] || ref; - } + /** + On a class-based helper, it may be useful to force a recomputation of that + helpers value. This is akin to `rerender` on a component. + For example, this component will rerender when the `currentUser` on a + session service changes: + ```js + // app/helpers/current-user-email.js + export default Ember.Helper.extend({ + session: Ember.inject.service(), + onNewUser: Ember.observer('session.currentUser', function() { + this.recompute(); + }), + compute() { + return this.get('session.currentUser.email'); + } + }); + ``` + @method recompute + @public + @since 1.13.0 + */ + recompute: function () { + this[RECOMPUTE_TAG].dirty(); + } - exports.default = function (vm, args) { - var rawRef = args.positional.at(0); + /** + Override this function when writing a class-based helper. + @method compute + @param {Array} params The positional arguments to the helper + @param {Object} hash The named arguments to the helper + @public + @since 1.13.0 + */ + }); - if (isMut(rawRef)) { - return rawRef; - } + Helper.reopenClass({ + isHelperFactory: true + }); - // TODO: Improve this error message. This covers at least two distinct - // cases: - // - // 1. (mut "not a path") – passing a literal, result from a helper - // invocation, etc - // - // 2. (mut receivedValue) – passing a value received from the caller - // that was originally derived from a literal, result from a helper - // invocation, etc - // - // This message is alright for the first case, but could be quite - // confusing for the second case. - _emberMetal.assert('You can only pass a path to mut', rawRef[_emberGlimmerUtilsReferences.UPDATE]); + /** + In many cases, the ceremony of a full `Ember.Helper` class is not required. + The `helper` method create pure-function helpers without instances. For + example: + + ```js + // app/helpers/format-currency.js + export default Ember.Helper.helper(function(params, hash) { + let cents = params[0]; + let currency = hash.currency; + return `${currency}${cents * 0.01}`; + }); + ``` + + @static + @param {Function} helper The helper function + @method helper + @public + @since 1.13.0 + */ - var wrappedRef = Object.create(rawRef); + function helper(helperFn) { + return { + isHelperInstance: true, + compute: helperFn + }; + } - wrappedRef[SOURCE] = rawRef; - wrappedRef[_emberGlimmerHelpersAction.INVOKE] = rawRef[_emberGlimmerUtilsReferences.UPDATE]; - wrappedRef[MUT_REFERENCE] = true; + exports.default = Helper; +}); +enifed('ember-glimmer/helpers/-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { + 'use strict'; - return wrappedRef; + function classHelper(_ref) { + var positional = _ref.positional; + + var path = positional.at(0); + var args = positional.length; + var value = path.value(); + + if (value === true) { + if (args > 1) { + return _emberRuntime.String.dasherize(positional.at(1).value()); + } + return null; + } + + if (value === false) { + if (args > 2) { + return _emberRuntime.String.dasherize(positional.at(2).value()); + } + return null; + } + + return value; + } + + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(classHelper, args); }; }); -enifed('ember-glimmer/helpers/query-param', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal, _emberRouting) { - /** - @module ember - @submodule ember-glimmer - */ +enifed('ember-glimmer/helpers/-html-safe', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/utils/string'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerUtilsString) { 'use strict'; - /** - This is a helper to be used in conjunction with the link-to helper. - It will supply url query parameters to the target route. - - Example - - ```handlebars - {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} - ``` - - @method query-params - @for Ember.Templates.helpers - @param {Object} hash takes a hash of query parameters - @return {Object} A `QueryParams` object for `{{link-to}}` - @public - */ - function queryParams(_ref) { + function htmlSafe(_ref) { + var positional = _ref.positional; + + var path = positional.at(0); + return new _emberGlimmerUtilsString.SafeString(path.value()); + } + + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(htmlSafe, args); + }; +}); +enifed('ember-glimmer/helpers/-input-type', ['exports', 'ember-glimmer/utils/references'], function (exports, _emberGlimmerUtilsReferences) { + 'use strict'; + + function inputTypeHelper(_ref) { var positional = _ref.positional; var named = _ref.named; - _emberMetal.assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', positional.value().length === 0); + var type = positional.at(0).value(); + if (type === 'checkbox') { + return '-checkbox'; + } + return '-text-field'; + } - return _emberRouting.QueryParams.create({ - values: _emberUtils.assign({}, named.value()) - }); + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(inputTypeHelper, args); + }; +}); +enifed('ember-glimmer/helpers/-normalize-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { + 'use strict'; + + function normalizeClass(_ref) { + var positional = _ref.positional; + var named = _ref.named; + + var classNameParts = positional.at(0).value().split('.'); + var className = classNameParts[classNameParts.length - 1]; + var value = positional.at(1).value(); + + if (value === true) { + return _emberRuntime.String.dasherize(className); + } else if (!value && value !== 0) { + return ''; + } else { + return String(value); + } } exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(queryParams, args); + return new _emberGlimmerUtilsReferences.InternalHelperReference(normalizeClass, args); }; }); -enifed('ember-glimmer/helpers/readonly', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/mut'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerHelpersMut) { +enifed('ember-glimmer/helpers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/runtime', '@glimmer/reference'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _glimmerRuntime, _glimmerReference) { /** @module ember @submodule ember-glimmer */ 'use strict'; + var INVOKE = _emberUtils.symbol('INVOKE'); + exports.INVOKE = INVOKE; + var ACTION = _emberUtils.symbol('ACTION'); + + exports.ACTION = ACTION; /** - The `readonly` helper let's you specify that a binding is one-way only, - instead of two-way. - When you pass a `readonly` binding from an outer context (e.g. parent component), - to to an inner context (e.g. child component), you are saying that changing that - property in the inner context does not change the value in the outer context. + The `{{action}}` helper provides a way to pass triggers for behavior (usually + just a function) between components, and into components from controllers. - To specify that a binding is read-only, when invoking the child `Component`: + ### Passing functions with the action helper - ```app/components/my-parent.js - export default Component.extend({ - totalClicks: 3 - }); - ``` + There are three contexts an action helper can be used in. The first two + contexts to discuss are attribute context, and Handlebars value context. - ```app/templates/components/my-parent.hbs - {{log totalClicks}} // -> 3 - {{my-child childClickCount=(readonly totalClicks)}} + ```handlebars + {{! An example of attribute context }} +
    + {{! Examples of Handlebars value context }} + {{input on-input=(action "save")}} + {{yield (action "refreshData") andAnotherParam}} ``` - Now, when you update `childClickCount`: - - ```app/components/my-child.js - export default Component.extend({ - click() { - this.incrementProperty('childClickCount'); - } - }); - ``` + In these contexts, + the helper is called a "closure action" helper. Its behavior is simple: + If passed a function name, read that function off the `actions` property + of the current context. Once that function is read (or if a function was + passed), create a closure over that function and any arguments. + The resulting value of an action helper used this way is simply a function. - The value updates in the child component, but not the parent component: + For example, in the attribute context: - ```app/templates/components/my-child.hbs - {{log childClickCount}} //-> 4 + ```handlebars + {{! An example of attribute context }} +
    ``` - ```app/templates/components/my-parent.hbs - {{log totalClicks}} //-> 3 - {{my-child childClickCount=(readonly totalClicks)}} - ``` + The resulting template render logic would be: - ### Objects and Arrays + ```js + var div = document.createElement('div'); + var actionFunction = (function(context){ + return function() { + return context.actions.save.apply(context, arguments); + }; + })(context); + div.onclick = actionFunction; + ``` - When passing a property that is a complex object (e.g. object, array) instead of a primitive object (e.g. number, string), - only the reference to the object is protected using the readonly helper. - This means that you can change properties of the object both on the parent component, as well as the child component. - The `readonly` binding behaves similar to the `const` keyword in JavaScript. + Thus when the div is clicked, the action on that context is called. + Because the `actionFunction` is just a function, closure actions can be + passed between components and still execute in the correct context. - Let's look at an example: + Here is an example action handler on a component: - First let's set up the parent component: + ```js + import Ember from 'ember'; - ```app/components/my-parent.js export default Ember.Component.extend({ - clicks: null, - - init() { - this._super(...arguments); - this.set('clicks', { total: 3 }); + actions: { + save() { + this.get('model').save(); + } } }); ``` - ```app/templates/components/my-parent.hbs - {{log clicks.total}} //-> 3 - {{my-child childClicks=(readonly clicks)}} - ``` + Actions are always looked up on the `actions` property of the current context. + This avoids collisions in the naming of common actions, such as `destroy`. + Two options can be passed to the `action` helper when it is used in this way. - Now, if you update the `total` property of `childClicks`: + * `target=someProperty` will look to `someProperty` instead of the current + context for the `actions` hash. This can be useful when targetting a + service for actions. + * `value="target.value"` will read the path `target.value` off the first + argument to the action when it is called and rewrite the first argument + to be that value. This is useful when attaching actions to event listeners. - ```app/components/my-child.js + ### Invoking an action + + Closure actions curry both their scope and any arguments. When invoked, any + additional arguments are added to the already curried list. + Actions should be invoked using the [sendAction](/api/classes/Ember.Component.html#method_sendAction) + method. The first argument to `sendAction` is the action to be called, and + additional arguments are passed to the action function. This has interesting + properties combined with currying of arguments. For example: + + ```js export default Ember.Component.extend({ - click() { - this.get('clicks').incrementProperty('total'); + actions: { + // Usage {{input on-input=(action (action 'setName' model) value="target.value")}} + setName(model, name) { + model.set('name', name); + } } }); ``` - You will see the following happen: - - ```app/templates/components/my-parent.hbs - {{log clicks.total}} //-> 4 - {{my-child childClicks=(readonly clicks)}} - ``` + The first argument (`model`) was curried over, and the run-time argument (`event`) + becomes a second argument. Action calls can be nested this way because each simply + returns a function. Any function can be passed to the `{{action}}` helper, including + other actions. - ```app/templates/components/my-child.hbs - {{log childClicks.total}} //-> 4 - ``` + Actions invoked with `sendAction` have the same currying behavior as demonstrated + with `on-input` above. For example: - @method readonly - @param {Object} [attr] the read-only attribute. - @for Ember.Templates.helpers - @private - */ - - exports.default = function (vm, args) { - var ref = _emberGlimmerHelpersMut.unMut(args.positional.at(0)); - - var wrapped = Object.create(ref); - - wrapped[_emberGlimmerUtilsReferences.UPDATE] = undefined; - - return wrapped; - }; -}); -enifed('ember-glimmer/helpers/unbound', ['exports', 'ember-metal', 'ember-glimmer/utils/references'], function (exports, _emberMetal, _emberGlimmerUtilsReferences) { - /** - @module ember - @submodule ember-glimmer - */ - - 'use strict'; - - /** - The `{{unbound}}` helper disconnects the one-way binding of a property, - essentially freezing its value at the moment of rendering. For example, - in this example the display of the variable `name` will not change even - if it is set with a new value: + ```app/components/my-input.js + import Ember from 'ember'; - ```handlebars - {{unbound name}} + export default Ember.Component.extend({ + actions: { + setName(model, name) { + model.set('name', name); + } + } + }); ``` - Like any helper, the `unbound` helper can accept a nested helper expression. - This allows for custom helpers to be rendered unbound: - ```handlebars - {{unbound (some-custom-helper)}} - {{unbound (capitalize name)}} - {{! You can use any helper, including unbound, in a nested expression }} - {{capitalize (unbound name)}} + {{my-input submit=(action 'setName' model)}} ``` - The `unbound` helper only accepts a single argument, and it return an - unbound value. - - @method unbound - @for Ember.Templates.helpers - @public - */ - - exports.default = function (vm, args) { - _emberMetal.assert('unbound helper cannot be called with multiple params or hash params', args.positional.values.length === 1 && args.named.keys.length === 0); - - return _emberGlimmerUtilsReferences.UnboundReference.create(args.positional.at(0).value()); - }; -}); -enifed('ember-glimmer/index', ['exports', 'ember-glimmer/helpers/action', 'ember-glimmer/templates/root', 'ember-glimmer/syntax', 'ember-glimmer/template', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/helper', 'ember-glimmer/environment', 'ember-glimmer/make-bound-helper', 'ember-glimmer/utils/string', 'ember-glimmer/renderer', 'ember-glimmer/template_registry', 'ember-glimmer/setup-registry', 'ember-glimmer/dom'], function (exports, _emberGlimmerHelpersAction, _emberGlimmerTemplatesRoot, _emberGlimmerSyntax, _emberGlimmerTemplate, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerHelper, _emberGlimmerEnvironment, _emberGlimmerMakeBoundHelper, _emberGlimmerUtilsString, _emberGlimmerRenderer, _emberGlimmerTemplate_registry, _emberGlimmerSetupRegistry, _emberGlimmerDom) { - /** - [Glimmer](https://github.com/tildeio/glimmer) is a [Handlebars](http://handlebarsjs.com/) - compatible templating engine used by Ember.js. - Any valid Handlebars syntax is valid in an Ember template. + ```app/components/my-component.js + import Ember from 'ember'; - ### Showing a property + export default Ember.Component.extend({ + click() { + // Note that model is not passed, it was curried in the template + this.sendAction('submit', 'bob'); + } + }); + ``` - Templates manage the flow of an application's UI, and display state (through - the DOM) to a user. For example, given a component with the property "name", - that component's template can use the name in several ways: + ### Attaching actions to DOM elements - ```javascript - // app/components/person.js - export default Ember.Component.extend({ - name: 'Jill' - }); - ``` + The third context of the `{{action}}` helper can be called "element space". + For example: ```handlebars - {{! app/components/person.hbs }} - {{name}} -
    {{name}}
    - + {{! An example of element space }} +
    ``` - Any time the "name" property on the component changes, the DOM will be - updated. - - Properties can be chained as well: + Used this way, the `{{action}}` helper provides a useful shortcut for + registering an HTML element in a template for a single DOM event and + forwarding that interaction to the template's context (controller or component). + If the context of a template is a controller, actions used this way will + bubble to routes when the controller does not implement the specified action. + Once an action hits a route, it will bubble through the route hierarchy. - ```handlebars - {{aUserModel.name}} -
    {{listOfUsers.firstObject.name}}
    - ``` + ### Event Propagation - ### Using Ember helpers + `{{action}}` helpers called in element space can control event bubbling. Note + that the closure style actions cannot. - When content is passed in mustaches `{{}}`, Ember will first try to find a helper - or component with that name. For example, the `if` helper: + Events triggered through the action helper will automatically have + `.preventDefault()` called on them. You do not need to do so in your event + handlers. If you need to allow event propagation (to handle file inputs for + example) you can supply the `preventDefault=false` option to the `{{action}}` helper: ```handlebars - {{if name "I have a name" "I have no name"}} - +
    + + +
    ``` - The returned value is placed where the `{{}}` is called. The above style is - called "inline". A second style of helper usage is called "block". For example: + To disable bubbling, pass `bubbles=false` to the helper: ```handlebars - {{#if name}} - I have a name - {{else}} - I have no name - {{/if}} + ``` - The block form of helpers allows you to control how the UI is created based - on the values of properties. - A third form of helper is called "nested". For example here the concat - helper will add " Doe" to a displayed name if the person has no last name: + To disable bubbling with closure style actions you must create your own + wrapper helper that makes use of `event.stopPropagation()`: ```handlebars - +
    Hello
    ``` - Ember's built-in helpers are described under the [Ember.Templates.helpers](/api/classes/Ember.Templates.helpers.html) - namespace. Documentation on creating custom helpers can be found under - [Ember.Helper](/api/classes/Ember.Helper.html). + ```app/helpers/disable-bubbling.js + import Ember from 'ember'; - ### Invoking a Component + export function disableBubbling([action]) { + return function(event) { + event.stopPropagation(); + return action(event); + }; + } + export default Ember.Helper.helper(disableBubbling); + ``` - Ember components represent state to the UI of an application. Further - reading on components can be found under [Ember.Component](/api/classes/Ember.Component.html). + If you need the default handler to trigger you should either register your + own event handler, or use event methods on your view class. See + ["Responding to Browser Events"](/api/classes/Ember.View.html#toc_responding-to-browser-events) + in the documentation for Ember.View for more information. - @module ember - @submodule ember-glimmer - @main ember-glimmer - @public - */ - - /** - Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful - for semantic clarity as it allows you to retain default scope or to reference a property from another - `{{with}}` block. + ### Specifying DOM event type - If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0`, NaN or - an empty array, the block will not be rendered. + `{{action}}` helpers called in element space can specify an event type. + By default the `{{action}}` helper registers for DOM `click` events. You can + supply an `on` option to the helper to specify a different DOM event name: ```handlebars - {{! Will only render if user.posts contains items}} - {{#with user.posts as |blogPosts|}} -
    - There are {{blogPosts.length}} blog posts written by {{user.name}}. -
    - {{#each blogPosts as |post|}} -
  • {{post.title}}
  • - {{/each}} - {{/with}} +
    + click me +
    ``` - Without the `as` operator, it would be impossible to reference `user.name` in the example above. - - NOTE: The alias should not reuse a name from the bound property path. + See ["Event Names"](/api/classes/Ember.View.html#toc_event-names) for a list of + acceptable DOM event names. - For example: `{{#with foo.bar as |foo|}}` is not supported because it attempts to alias using - the first part of the property path, `foo`. Instead, use `{{#with foo.bar as |baz|}}`. + ### Specifying whitelisted modifier keys - @method with - @for Ember.Templates.helpers - @param {Object} options - @return {String} HTML string - @public - */ - - /** - Execute the `debugger` statement in the current template's context. + `{{action}}` helpers called in element space can specify modifier keys. + By default the `{{action}}` helper will ignore click events with pressed modifier + keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. ```handlebars - {{debugger}} +
    + click me +
    ``` - When using the debugger helper you will have access to a `get` function. This - function retrieves values available in the context of the template. - For example, if you're wondering why a value `{{foo}}` isn't rendering as - expected within a template, you could place a `{{debugger}}` statement and, - when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: + This way the action will fire when clicking with the alt key pressed down. + Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. - ``` - > get('foo') + ```handlebars +
    + click me with any key pressed +
    ``` - `get` is also aware of keywords. So in this situation + ### Specifying a Target - ```handlebars - {{#each items as |item|}} - {{debugger}} - {{/each}} - ``` - - You'll be able to get values from the current item: + A `target` option can be provided to the helper to change + which object will receive the method call. This option must be a path + to an object, accessible in the current context: - ``` - > get('item.name') + ```app/templates/application.hbs +
    + click me +
    ``` - You can also access the context of the view to make sure it is the object that - you expect: + ```app/controllers/application.js + import Ember from 'ember'; - ``` - > context + export default Ember.Controller.extend({ + someService: Ember.inject.service() + }); ``` - @method debugger + @method action @for Ember.Templates.helpers @public - */ + */ + + exports.default = function (vm, args) { + var named = args.named; + var positional = args.positional; + + // The first two argument slots are reserved. + // pos[0] is the context (or `this`) + // pos[1] is the action name or function + // Anything else is an action argument. + var context = positional.at(0); + var action = positional.at(1); + + // TODO: Is there a better way of doing this? + var debugKey = action._propertyKey; + + var restArgs = undefined; + + if (positional.length === 2) { + restArgs = _glimmerRuntime.EvaluatedPositionalArgs.empty(); + } else { + restArgs = _glimmerRuntime.EvaluatedPositionalArgs.create(positional.values.slice(2)); + } + + var target = named.has('target') ? named.get('target') : context; + var processArgs = makeArgsProcessor(named.has('value') && named.get('value'), restArgs); + + var fn = undefined; + + if (typeof action[INVOKE] === 'function') { + fn = makeClosureAction(action, action, action[INVOKE], processArgs, debugKey); + } else if (_glimmerReference.isConst(target) && _glimmerReference.isConst(action)) { + fn = makeClosureAction(context.value(), target.value(), action.value(), processArgs, debugKey); + } else { + fn = makeDynamicClosureAction(context.value(), target, action, processArgs, debugKey); + } + + fn[ACTION] = true; + + return new _emberGlimmerUtilsReferences.UnboundReference(fn); + }; + + function NOOP(args) { + return args; + } + + function makeArgsProcessor(valuePathRef, actionArgsRef) { + var mergeArgs = null; + + if (actionArgsRef.length > 0) { + mergeArgs = function (args) { + return actionArgsRef.value().concat(args); + }; + } + + var readValue = null; + + if (valuePathRef) { + readValue = function (args) { + var valuePath = valuePathRef.value(); + + if (valuePath && args.length > 0) { + args[0] = _emberMetal.get(args[0], valuePath); + } + + return args; + }; + } + + if (mergeArgs && readValue) { + return function (args) { + return readValue(mergeArgs(args)); + }; + } else { + return mergeArgs || readValue || NOOP; + } + } + + function makeDynamicClosureAction(context, targetRef, actionRef, processArgs, debugKey) { + // We don't allow undefined/null values, so this creates a throw-away action to trigger the assertions + _emberMetal.runInDebug(function () { + makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey); + }); + + return function () { + return makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey).apply(undefined, arguments); + }; + } + + function makeClosureAction(context, target, action, processArgs, debugKey) { + var self = undefined, + fn = undefined; + + _emberMetal.assert('Action passed is null or undefined in (action) from ' + target + '.', !_emberMetal.isNone(action)); + + if (typeof action[INVOKE] === 'function') { + self = action; + fn = action[INVOKE]; + } else { + var typeofAction = typeof action; + + if (typeofAction === 'string') { + self = target; + fn = target.actions && target.actions[action]; + + _emberMetal.assert('An action named \'' + action + '\' was not found in ' + target, fn); + } else if (typeofAction === 'function') { + self = context; + fn = action; + } else { + _emberMetal.assert('An action could not be made for `' + (debugKey || action) + '` in ' + target + '. Please confirm that you are using either a quoted action name (i.e. `(action \'' + (debugKey || 'myAction') + '\')`) or a function available in ' + target + '.', false); + } + } + + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + var payload = { target: self, args: args, label: '@glimmer/closure-action' }; + return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + return _emberMetal.run.join.apply(_emberMetal.run, [self, fn].concat(processArgs(args))); + }); + }; + } +}); +enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/curly-component', '@glimmer/runtime', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxCurlyComponent, _glimmerRuntime, _emberMetal) { /** - The `partial` helper renders another template without - changing the template context: + @module ember + @submodule ember-glimmer + */ + 'use strict'; + + /** + The `{{component}}` helper lets you add instances of `Ember.Component` to a + template. See [Ember.Component](/api/classes/Ember.Component.html) for + additional information on how a `Component` functions. + `{{component}}`'s primary use is for cases where you want to dynamically + change which type of component is rendered as the state of your application + changes. This helper has three modes: inline, block, and nested. - ```handlebars - {{foo}} - {{partial "nav"}} + ### Inline Form + + Given the following template: + + ```app/application.hbs + {{component infographicComponentName}} ``` - The above example template will render a template named - "-nav", which has the same context as the parent template - it's rendered into, so if the "-nav" template also referenced - `{{foo}}`, it would print the same thing as the `{{foo}}` - in the above example. + And the following application code: - If a "-nav" template isn't found, the `partial` helper will - fall back to a template named "nav". + ```app/controllers/application.js + export default Ember.Controller.extend({ + infographicComponentName: computed('isMarketOpen', { + get() { + if (this.get('isMarketOpen')) { + return 'live-updating-chart'; + } else { + return 'market-close-summary'; + } + } + }) + }); + ``` - ### Bound template names + The `live-updating-chart` component will be appended when `isMarketOpen` is + `true`, and the `market-close-summary` component will be appended when + `isMarketOpen` is `false`. If the value changes while the app is running, + the component will be automatically swapped out accordingly. + Note: You should not use this helper when you are consistently rendering the same + component. In that case, use standard component syntax, for example: - The parameter supplied to `partial` can also be a path - to a property containing a template name, e.g.: + ```app/templates/application.hbs + {{live-updating-chart}} + ``` - ```handlebars - {{partial someTemplateName}} + ### Block Form + + Using the block form of this helper is similar to using the block form + of a component. Given the following application template: + + ```app/templates/application.hbs + {{#component infographicComponentName}} + Last update: {{lastUpdateTimestamp}} + {{/component}} ``` - The above example will look up the value of `someTemplateName` - on the template context (e.g. a controller) and use that - value as the name of the template to render. If the resolved - value is falsy, nothing will be rendered. If `someTemplateName` - changes, the partial will be re-rendered using the new template - name. + The following controller code: - @method partial - @for Ember.Templates.helpers - @param {String} partialName The name of the template to render minus the leading underscore. - @public - */ - - 'use strict'; - - exports.INVOKE = _emberGlimmerHelpersAction.INVOKE; - exports.RootTemplate = _emberGlimmerTemplatesRoot.default; - exports.registerSyntax = _emberGlimmerSyntax.registerSyntax; - exports.template = _emberGlimmerTemplate.default; - exports.Checkbox = _emberGlimmerComponentsCheckbox.default; - exports.TextField = _emberGlimmerComponentsText_field.default; - exports.TextArea = _emberGlimmerComponentsText_area.default; - exports.LinkComponent = _emberGlimmerComponentsLinkTo.default; - exports.Component = _emberGlimmerComponent.default; - exports.Helper = _emberGlimmerHelper.default; - exports.helper = _emberGlimmerHelper.helper; - exports.Environment = _emberGlimmerEnvironment.default; - exports.makeBoundHelper = _emberGlimmerMakeBoundHelper.default; - exports.SafeString = _emberGlimmerUtilsString.SafeString; - exports.escapeExpression = _emberGlimmerUtilsString.escapeExpression; - exports.htmlSafe = _emberGlimmerUtilsString.htmlSafe; - exports.isHTMLSafe = _emberGlimmerUtilsString.isHTMLSafe; - exports._getSafeString = _emberGlimmerUtilsString.getSafeString; - exports.Renderer = _emberGlimmerRenderer.Renderer; - exports.InertRenderer = _emberGlimmerRenderer.InertRenderer; - exports.InteractiveRenderer = _emberGlimmerRenderer.InteractiveRenderer; - exports.getTemplate = _emberGlimmerTemplate_registry.getTemplate; - exports.setTemplate = _emberGlimmerTemplate_registry.setTemplate; - exports.hasTemplate = _emberGlimmerTemplate_registry.hasTemplate; - exports.getTemplates = _emberGlimmerTemplate_registry.getTemplates; - exports.setTemplates = _emberGlimmerTemplate_registry.setTemplates; - exports.setupEngineRegistry = _emberGlimmerSetupRegistry.setupEngineRegistry; - exports.setupApplicationRegistry = _emberGlimmerSetupRegistry.setupApplicationRegistry; - exports.DOMChanges = _emberGlimmerDom.DOMChanges; - exports.NodeDOMTreeConstruction = _emberGlimmerDom.NodeDOMTreeConstruction; - exports.DOMTreeConstruction = _emberGlimmerDom.DOMTreeConstruction; -}); -enifed('ember-glimmer/make-bound-helper', ['exports', 'ember-metal', 'ember-glimmer/helper'], function (exports, _emberMetal, _emberGlimmerHelper) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - exports.default = makeBoundHelper; - - /** - Create a bound helper. Accepts a function that receives the ordered and hash parameters - from the template. If a bound property was provided in the template, it will be resolved to its - value and any changes to the bound property cause the helper function to be re-run with the updated - values. + ```app/controllers/application.js + export default Ember.Controller.extend({ + lastUpdateTimestamp: computed(function() { + return new Date(); + }), - * `params` - An array of resolved ordered parameters. - * `hash` - An object containing the hash parameters. + infographicComponentName: computed('isMarketOpen', { + get() { + if (this.get('isMarketOpen')) { + return 'live-updating-chart'; + } else { + return 'market-close-summary'; + } + } + }) + }); + ``` - For example: + And the following component template: - * With an unquoted ordered parameter: + ```app/templates/components/live-updating-chart.hbs + {{! chart }} + {{yield}} + ``` - ```javascript - {{x-capitalize foo}} - ``` + The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. - Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and - an empty hash as its second. + ### Nested Usage - * With a quoted ordered parameter: + The `component` helper can be used to package a component path with initial attrs. + The included attrs can then be merged during the final invocation. + For example, given a `person-form` component with the following template: - ```javascript - {{x-capitalize "foo"}} - ``` + ```app/templates/components/person-form.hbs + {{yield (hash + nameInput=(component "my-input-component" value=model.name placeholder="First Name") + )}} + ``` - The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. + When yielding the component via the `hash` helper, the component is invocked directly. + See the following snippet: - * With an unquoted hash parameter: + ``` + {{#person-form as |form|}} + {{form.nameInput placeholder="Username"}} + {{/person-form}} + ``` - ```javascript - {{x-repeat "foo" count=repeatCount}} - ``` + Which outputs an input whose value is already bound to `model.name` and `placeholder` + is "Username". - Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, - and { count: 2 } as its second. + When yielding the component without the hash helper use the `component` helper. + For example, below is a `full-name` component template: - @private - @method makeBoundHelper - @for Ember.HTMLBars - @param {Function} fn - @since 1.10.0 + ```handlebars + {{yield (component "my-input-component" value=model.name placeholder="Name")}} + ``` + + ``` + {{#full-name as |field|}} + {{component field placeholder="Full name"}} + {{/full-name}} + ``` + + @method component + @since 1.11.0 + @for Ember.Templates.helpers + @public */ - function makeBoundHelper(fn) { - _emberMetal.deprecate('Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.', false, { id: 'ember-htmlbars.make-bound-helper', until: '3.0.0' }); - return _emberGlimmerHelper.helper(fn); - } -}); -enifed('ember-glimmer/modifiers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _emberGlimmerHelpersAction) { - 'use strict'; - - var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; - var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; + var ClosureComponentReference = (function (_CachedReference) { + babelHelpers.inherits(ClosureComponentReference, _CachedReference); - function isAllowedEvent(event, allowedKeys) { - if (allowedKeys === null || typeof allowedKeys === 'undefined') { - if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { - return _emberViews.isSimpleClick(event); - } else { - allowedKeys = ''; - } - } + ClosureComponentReference.create = function create(args, symbolTable, env) { + return new ClosureComponentReference(args, symbolTable, env); + }; - if (allowedKeys.indexOf('any') >= 0) { - return true; - } + function ClosureComponentReference(args, symbolTable, env) { + babelHelpers.classCallCheck(this, ClosureComponentReference); - for (var i = 0; i < MODIFIERS.length; i++) { - if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { - return false; - } + _CachedReference.call(this); + this.defRef = args.positional.at(0); + this.env = env; + this.tag = args.positional.at(0).tag; + this.symbolTable = symbolTable; + this.args = args; + this.lastDefinition = undefined; + this.lastName = undefined; } - return true; - } + ClosureComponentReference.prototype.compute = function compute() { + // TODO: Figure out how to extract this because it's nearly identical to + // DynamicComponentReference::compute(). The only differences besides + // currying are in the assertion messages. + var args = this.args; + var defRef = this.defRef; + var env = this.env; + var symbolTable = this.symbolTable; + var lastDefinition = this.lastDefinition; + var lastName = this.lastName; - var ActionHelper = { - // registeredActions is re-exported for compatibility with older plugins - // that were using this undocumented API. - registeredActions: _emberViews.ActionManager.registeredActions, + var nameOrDef = defRef.value(); + var definition = null; - registerAction: function (actionState) { - var actionId = actionState.actionId; + if (nameOrDef && nameOrDef === lastName) { + return lastDefinition; + } - var actions = _emberViews.ActionManager.registeredActions[actionId]; + this.lastName = nameOrDef; - if (!actions) { - actions = _emberViews.ActionManager.registeredActions[actionId] = []; + if (typeof nameOrDef === 'string') { + _emberMetal.assert('You cannot use the input helper as a contextual helper. Please extend Ember.TextField or Ember.Checkbox to use it as a contextual component.', nameOrDef !== 'input'); + _emberMetal.assert('You cannot use the textarea helper as a contextual helper. Please extend Ember.TextArea to use it as a contextual component.', nameOrDef !== 'textarea'); + definition = env.getComponentDefinition([nameOrDef], symbolTable); + _emberMetal.assert('The component helper cannot be used without a valid component name. You used "' + nameOrDef + '" via (component "' + nameOrDef + '")', definition); + } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { + definition = nameOrDef; + } else { + _emberMetal.assert('You cannot create a component from ' + nameOrDef + ' using the {{component}} helper', nameOrDef); + return null; } - actions.push(actionState); + var newDef = createCurriedDefinition(definition, args); - return actionId; - }, + this.lastDefinition = newDef; - unregisterAction: function (actionState) { - var actionId = actionState.actionId; + return newDef; + }; - var actions = _emberViews.ActionManager.registeredActions[actionId]; + return ClosureComponentReference; + })(_emberGlimmerUtilsReferences.CachedReference); - if (!actions) { - return; - } + exports.ClosureComponentReference = ClosureComponentReference; - var index = actions.indexOf(actionState); + function createCurriedDefinition(definition, args) { + var curriedArgs = curryArgs(definition, args); - if (index !== -1) { - actions.splice(index, 1); - } + return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(definition.name, definition.ComponentClass, definition.template, curriedArgs); + } - if (actions.length === 0) { - delete _emberViews.ActionManager.registeredActions[actionId]; - } - } + var EMPTY_BLOCKS = { + default: null, + inverse: null }; - exports.ActionHelper = ActionHelper; + _emberMetal.runInDebug(function () { + EMPTY_BLOCKS = Object.freeze(EMPTY_BLOCKS); + }); - var ActionState = (function () { - function ActionState(element, actionId, actionName, actionArgs, namedArgs, positionalArgs, implicitTarget, dom) { - babelHelpers.classCallCheck(this, ActionState); + function curryArgs(definition, newArgs) { + var args = definition.args; + var ComponentClass = definition.ComponentClass; - this.element = element; - this.actionId = actionId; - this.actionName = actionName; - this.actionArgs = actionArgs; - this.namedArgs = namedArgs; - this.positional = positionalArgs; - this.implicitTarget = implicitTarget; - this.dom = dom; - this.eventName = this.getEventName(); - } + var positionalParams = ComponentClass.class.positionalParams; - // implements ModifierManager + // The args being passed in are from the (component ...) invocation, + // so the first positional argument is actually the name or component + // definition. It needs to be dropped in order for any actual positional + // args to coincide with the ComponentClass's positionParams. - ActionState.prototype.getEventName = function getEventName() { - return this.namedArgs.get('on').value() || 'click'; - }; + // For "normal" curly components this slicing is done at the syntax layer, + // but we don't have that luxury here. - ActionState.prototype.getActionArgs = function getActionArgs() { - var result = new Array(this.actionArgs.length); + var _newArgs$positional$values = newArgs.positional.values; - for (var i = 0; i < this.actionArgs.length; i++) { - result[i] = this.actionArgs[i].value(); - } + var slicedPositionalArgs = _newArgs$positional$values.slice(1); - return result; - }; + if (positionalParams && slicedPositionalArgs.length) { + _emberGlimmerSyntaxCurlyComponent.validatePositionalParameters(newArgs.named, slicedPositionalArgs, positionalParams); + } - ActionState.prototype.getTarget = function getTarget() { - var implicitTarget = this.implicitTarget; - var namedArgs = this.namedArgs; + var isRest = typeof positionalParams === 'string'; - var target = undefined; + // For non-rest position params, we need to perform the position -> name mapping + // at each layer to avoid a collision later when the args are used to construct + // the component instance (inside of processArgs(), inside of create()). + var positionalToNamedParams = {}; - if (namedArgs.has('target')) { - target = namedArgs.get('target').value(); - } else { - target = implicitTarget.value(); + if (!isRest && positionalParams && positionalParams.length > 0) { + var limit = Math.min(positionalParams.length, slicedPositionalArgs.length); + + for (var i = 0; i < limit; i++) { + var _name = positionalParams[i]; + positionalToNamedParams[_name] = slicedPositionalArgs[i]; } - return target; - }; + slicedPositionalArgs.length = 0; // Throw them away since you're merged in. + } - ActionState.prototype.handler = function handler(event) { - var _this = this; + // args (aka 'oldArgs') may be undefined or simply be empty args, so + // we need to fall back to an empty array or object. + var oldNamed = args && args.named && args.named.map || {}; + var oldPositional = args && args.positional && args.positional.values || []; - var actionName = this.actionName; - var namedArgs = this.namedArgs; + // Merge positional arrays + var mergedPositional = new Array(Math.max(oldPositional.length, slicedPositionalArgs.length)); + mergedPositional.splice.apply(mergedPositional, [0, oldPositional.length].concat(oldPositional)); + mergedPositional.splice.apply(mergedPositional, [0, slicedPositionalArgs.length].concat(slicedPositionalArgs)); - var bubbles = namedArgs.get('bubbles'); - var preventDefault = namedArgs.get('preventDefault'); - var allowedKeys = namedArgs.get('allowedKeys'); - var target = this.getTarget(); + // Merge named maps + var mergedNamed = _emberUtils.assign({}, oldNamed, positionalToNamedParams, newArgs.named.map); - if (!isAllowedEvent(event, allowedKeys.value())) { - return true; - } + var mergedArgs = _glimmerRuntime.EvaluatedArgs.create(_glimmerRuntime.EvaluatedPositionalArgs.create(mergedPositional), _glimmerRuntime.EvaluatedNamedArgs.create(mergedNamed), EMPTY_BLOCKS); - if (preventDefault.value() !== false) { - event.preventDefault(); - } + return mergedArgs; + } - if (bubbles.value() === false) { - event.stopPropagation(); - } + exports.default = function (vm, args, symbolTable) { + return ClosureComponentReference.create(args, symbolTable, vm.env); + }; +}); +enifed('ember-glimmer/helpers/concat', ['exports', 'ember-glimmer/utils/references', '@glimmer/runtime'], function (exports, _emberGlimmerUtilsReferences, _glimmerRuntime) { + 'use strict'; - _emberMetal.run(function () { - var args = _this.getActionArgs(); - var payload = { - args: args, - target: target - }; - if (typeof actionName[_emberGlimmerHelpersAction.INVOKE] === 'function') { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - actionName[_emberGlimmerHelpersAction.INVOKE].apply(actionName, args); - }); - return; - } - if (typeof actionName === 'function') { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - actionName.apply(target, args); - }); - return; - } - payload.name = actionName; - if (target.send) { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - target.send.apply(target, [actionName].concat(args)); - }); - } else { - _emberMetal.assert('The action \'' + actionName + '\' did not exist on ' + target, typeof target[actionName] === 'function'); - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - target[actionName].apply(target, args); - }); - } - }); - }; + /** + @module ember + @submodule ember-glimmer + */ - ActionState.prototype.destroy = function destroy() { - ActionHelper.unregisterAction(this); - }; + /** + Concatenates the given arguments into a string. + + Example: + + ```handlebars + {{some-component name=(concat firstName " " lastName)}} + + {{! would pass name=" " to the component}} + ``` + + @public + @method concat + @for Ember.Templates.helpers + @since 1.13.0 + */ + function concat(_ref) { + var positional = _ref.positional; - return ActionState; - })(); + return positional.value().map(_glimmerRuntime.normalizeTextValue).join(''); + } - exports.ActionState = ActionState; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(concat, args); + }; +}); +enifed('ember-glimmer/helpers/each-in', ['exports', 'ember-utils'], function (exports, _emberUtils) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var ActionModifierManager = (function () { - function ActionModifierManager() { - babelHelpers.classCallCheck(this, ActionModifierManager); - } + exports.isEachIn = isEachIn; - ActionModifierManager.prototype.create = function create(element, args, dynamicScope, dom) { - var named = args.named; - var positional = args.positional; + /** + The `{{#each}}` helper loops over elements in a collection. It is an extension + of the base Handlebars `{{#each}}` helper. + The default behavior of `{{#each}}` is to yield its inner block once for every + item in an array passing the item as the first block parameter. + + ```javascript + var developers = [{ name: 'Yehuda' },{ name: 'Tom' }, { name: 'Paul' }]; + ``` + + ```handlebars + {{#each developers key="name" as |person|}} + {{person.name}} + {{! `this` is whatever it was outside the #each }} + {{/each}} + ``` + + The same rules apply to arrays of primitives. + + ```javascript + var developerNames = ['Yehuda', 'Tom', 'Paul'] + ``` + + ```handlebars + {{#each developerNames key="@index" as |name|}} + {{name}} + {{/each}} + ``` + + During iteration, the index of each item in the array is provided as a second block parameter. + + ```handlebars +
      + {{#each people as |person index|}} +
    • Hello, {{person.name}}! You're number {{index}} in line
    • + {{/each}} +
    + ``` + + ### Specifying Keys + + The `key` option is used to tell Ember how to determine if the array being + iterated over with `{{#each}}` has changed between renders. By helping Ember + detect that some elements in the array are the same, DOM elements can be + re-used, significantly improving rendering speed. + + For example, here's the `{{#each}}` helper with its `key` set to `id`: + + ```handlebars + {{#each model key="id" as |item|}} + {{/each}} + ``` + + When this `{{#each}}` re-renders, Ember will match up the previously rendered + items (and reorder the generated DOM elements) based on each item's `id` + property. + By default the item's own reference is used. + + ### {{else}} condition + + `{{#each}}` can have a matching `{{else}}`. The contents of this block will render + if the collection is empty. + + ```handlebars + {{#each developers as |person|}} + {{person.name}} + {{else}} +

    Sorry, nobody is available for this task.

    + {{/each}} + ``` + + @method each + @for Ember.Templates.helpers + @public + */ - var implicitTarget = undefined; - var actionName = undefined; - var actionNameRef = undefined; - if (positional.length > 1) { - implicitTarget = positional.at(0); - actionNameRef = positional.at(1); + /** + The `{{each-in}}` helper loops over properties on an object. + + For example, given a `user` object that looks like: + + ```javascript + { + "name": "Shelly Sails", + "age": 42 + } + ``` + + This template would display all properties on the `user` + object in a list: + + ```handlebars +
      + {{#each-in user as |key value|}} +
    • {{key}}: {{value}}
    • + {{/each-in}} +
    + ``` + + Outputting their name and age. + + @method each-in + @for Ember.Templates.helpers + @public + @since 2.1.0 + */ + var EACH_IN_REFERENCE = _emberUtils.symbol('EACH_IN'); - if (actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { - actionName = actionNameRef; - } else { - var actionLabel = actionNameRef._propertyKey; - actionName = actionNameRef.value(); + function isEachIn(ref) { + return ref && ref[EACH_IN_REFERENCE]; + } - _emberMetal.assert('You specified a quoteless path, `' + actionLabel + '`, to the ' + '{{action}} helper which did not resolve to an action name (a ' + 'string). Perhaps you meant to use a quoted actionName? (e.g. ' + '{{action "' + actionLabel + '"}}).', typeof actionName === 'string' || typeof actionName === 'function'); - } - } + exports.default = function (vm, args) { + var ref = Object.create(args.positional.at(0)); + ref[EACH_IN_REFERENCE] = true; + return ref; + }; +}); +enifed('ember-glimmer/helpers/get', ['exports', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { + 'use strict'; - var actionArgs = []; - // The first two arguments are (1) `this` and (2) the action name. - // Everything else is a param. - for (var i = 2; i < positional.length; i++) { - actionArgs.push(positional.at(i)); - } + /** + @module ember + @submodule ember-glimmer + */ - var actionId = _emberUtils.uuid(); - return new ActionState(element, actionId, actionName, actionArgs, named, positional, implicitTarget, dom); - }; + /** + Dynamically look up a property on an object. The second argument to `{{get}}` + should have a string value, although it can be bound. + + For example, these two usages are equivilent: + + ```handlebars + {{person.height}} + {{get person "height"}} + ``` + + If there were several facts about a person, the `{{get}}` helper can dynamically + pick one: + + ```handlebars + {{get person factName}} + ``` + + For a more complex example, this template would allow the user to switch + between showing the user's height and weight with a click: + + ```handlebars + {{get person factName}} + + + ``` + + The `{{get}}` helper can also respect mutable values itself. For example: + + ```handlebars + {{input value=(mut (get person factName)) type="text"}} + + + ``` + + Would allow the user to swap what fact is being displayed, and also edit + that fact via a two-way mutable binding. + + @public + @method get + @for Ember.Templates.helpers + @since 2.1.0 + */ - ActionModifierManager.prototype.install = function install(actionState) { - var dom = actionState.dom; - var element = actionState.element; - var actionId = actionState.actionId; + exports.default = function (vm, args) { + return GetHelperReference.create(args.positional.at(0), args.positional.at(1)); + }; - ActionHelper.registerAction(actionState); + var GetHelperReference = (function (_CachedReference) { + babelHelpers.inherits(GetHelperReference, _CachedReference); - dom.setAttribute(element, 'data-ember-action', ''); - dom.setAttribute(element, 'data-ember-action-' + actionId, actionId); + GetHelperReference.create = function create(sourceReference, pathReference) { + if (_glimmerReference.isConst(pathReference)) { + var parts = pathReference.value().split('.'); + return _glimmerReference.referenceFromParts(sourceReference, parts); + } else { + return new GetHelperReference(sourceReference, pathReference); + } }; - ActionModifierManager.prototype.update = function update(actionState) { - var positional = actionState.positional; + function GetHelperReference(sourceReference, pathReference) { + babelHelpers.classCallCheck(this, GetHelperReference); - var actionNameRef = positional.at(1); + _CachedReference.call(this); + this.sourceReference = sourceReference; + this.pathReference = pathReference; - if (!actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { - actionState.actionName = actionNameRef.value(); - } - actionState.eventName = actionState.getEventName(); + this.lastPath = null; + this.innerReference = null; - // Not sure if this is needed? If we mutate the actionState is that good enough? - ActionHelper.unregisterAction(actionState); - ActionHelper.registerAction(actionState); - }; + var innerTag = this.innerTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - ActionModifierManager.prototype.getDestructor = function getDestructor(modifier) { - return modifier; - }; + this.tag = _glimmerReference.combine([sourceReference.tag, pathReference.tag, innerTag]); + } - return ActionModifierManager; - })(); + GetHelperReference.prototype.compute = function compute() { + var lastPath = this.lastPath; + var innerReference = this.innerReference; + var innerTag = this.innerTag; - exports.default = ActionModifierManager; -}); -enifed('ember-glimmer/protocol-for-url', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - /* globals module, URL */ + var path = this.lastPath = this.pathReference.value(); - 'use strict'; + if (path !== lastPath) { + if (path) { + var pathType = typeof path; - exports.default = installProtocolForURL; + if (pathType === 'string') { + innerReference = this.innerReference = _glimmerReference.referenceFromParts(this.sourceReference, path.split('.')); + } else if (pathType === 'number') { + innerReference = this.innerReference = this.sourceReference.get(path); + } - var nodeURL = undefined; - var parsingNode = undefined; + innerTag.update(innerReference.tag); + } else { + innerReference = this.innerReference = null; + innerTag.update(_glimmerReference.CONSTANT_TAG); + } + } - function installProtocolForURL(environment) { - var protocol = undefined; + return innerReference ? innerReference.value() : null; + }; - if (_emberEnvironment.environment.hasDOM) { - protocol = browserProtocolForURL.call(environment, 'foobar:baz'); - } + GetHelperReference.prototype[_emberGlimmerUtilsReferences.UPDATE] = function (value) { + _emberMetal.set(this.sourceReference.value(), this.pathReference.value(), value); + }; - // Test to see if our DOM implementation parses - // and normalizes URLs. - if (protocol === 'foobar:') { - // Swap in the method that doesn't do this test now that - // we know it works. - environment.protocolForURL = browserProtocolForURL; - } else if (typeof URL === 'object') { - // URL globally provided, likely from FastBoot's sandbox - nodeURL = URL; - environment.protocolForURL = nodeProtocolForURL; - } else if (typeof module === 'object' && typeof module.require === 'function') { - // Otherwise, we need to fall back to our own URL parsing. - // Global `require` is shadowed by Ember's loader so we have to use the fully - // qualified `module.require`. - nodeURL = module.require('url'); - environment.protocolForURL = nodeProtocolForURL; - } else { - throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); - } - } + return GetHelperReference; + })(_emberGlimmerUtilsReferences.CachedReference); +}); +enifed("ember-glimmer/helpers/hash", ["exports"], function (exports) { + /** + @module ember + @submodule ember-glimmer + */ - function browserProtocolForURL(url) { - if (!parsingNode) { - parsingNode = document.createElement('a'); - } + /** + Use the `{{hash}}` helper to create a hash to pass as an option to your + components. This is specially useful for contextual components where you can + just yield a hash: + + ```handlebars + {{yield (hash + name='Sarah' + title=office + )}} + ``` + + Would result in an object such as: + + ```js + { name: 'Sarah', title: this.get('office') } + ``` + + Where the `title` is bound to updates of the `office` property. + + @method hash + @for Ember.Templates.helpers + @param {Object} options + @return {Object} Hash + @since 2.3.0 + @public + */ - parsingNode.href = url; - return parsingNode.protocol; - } + "use strict"; - function nodeProtocolForURL(url) { - var protocol = null; - if (typeof url === 'string') { - protocol = nodeURL.parse(url).protocol; - } - return protocol === null ? ':' : protocol; - } + exports.default = function (vm, args) { + return args.named; + }; }); -enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', 'ember-metal', 'glimmer-reference', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/outlet'], function (exports, _emberGlimmerUtilsReferences, _emberMetal, _glimmerReference, _emberViews, _emberGlimmerComponent, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxOutlet) { - 'use strict'; +enifed('ember-glimmer/helpers/if-unless', ['exports', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { + /** + @module ember + @submodule ember-glimmer + */ - var runInTransaction = undefined; + 'use strict'; - if (true || false) { - runInTransaction = _emberMetal.runInTransaction; - } else { - runInTransaction = function (context, methodName) { - context[methodName](); - return false; - }; - } + exports.inlineIf = inlineIf; + exports.inlineUnless = inlineUnless; - var backburner = _emberMetal.run.backburner; + /** + Use the `if` block helper to conditionally render a block depending on a + property. If the property is "falsey", for example: `false`, `undefined`, + `null`, `""`, `0`, `NaN` or an empty array, the block will not be rendered. + + ```handlebars + {{! will not render if foo is falsey}} + {{#if foo}} + Welcome to the {{foo.bar}} + {{/if}} + ``` + + You can also specify a template to show if the property is falsey by using + the `else` helper. + + ```handlebars + {{! is it raining outside?}} + {{#if isRaining}} + Yes, grab an umbrella! + {{else}} + No, it's lovely outside! + {{/if}} + ``` + + You are also able to combine `else` and `if` helpers to create more complex + conditional logic. + + ```handlebars + {{#if isMorning}} + Good morning + {{else if isAfternoon}} + Good afternoon + {{else}} + Good night + {{/if}} + ``` + + You can use `if` inline to conditionally render a single property or string. + This helper acts like a ternary operator. If the first property is truthy, + the second argument will be displayed, if not, the third argument will be + displayed + + ```handlebars + {{if useLongGreeting "Hello" "Hi"}} Dave + ``` + + Finally, you can use the `if` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(if isBig "100" "10")}} + ``` + + @method if + @for Ember.Templates.helpers + @public + */ - var DynamicScope = (function () { - function DynamicScope(view, outletState, rootOutletState, targetObject) { - babelHelpers.classCallCheck(this, DynamicScope); + var ConditionalHelperReference = (function (_CachedReference) { + babelHelpers.inherits(ConditionalHelperReference, _CachedReference); - this.view = view; - this.outletState = outletState; - this.rootOutletState = rootOutletState; - } + ConditionalHelperReference.create = function create(_condRef, _truthyRef, _falsyRef) { + var condRef = _emberGlimmerUtilsReferences.ConditionalReference.create(_condRef); + var truthyRef = _truthyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; + var falsyRef = _falsyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; - DynamicScope.prototype.child = function child() { - return new DynamicScope(this.view, this.outletState, this.rootOutletState); + if (_glimmerReference.isConst(condRef)) { + return condRef.value() ? truthyRef : falsyRef; + } else { + return new ConditionalHelperReference(condRef, truthyRef, falsyRef); + } }; - DynamicScope.prototype.get = function get(key) { - _emberMetal.assert('Using `-get-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); - return this.outletState; - }; + function ConditionalHelperReference(cond, truthy, falsy) { + babelHelpers.classCallCheck(this, ConditionalHelperReference); - DynamicScope.prototype.set = function set(key, value) { - _emberMetal.assert('Using `-with-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); - this.outletState = value; - return value; - }; + _CachedReference.call(this); - return DynamicScope; - })(); + this.branchTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + this.tag = _glimmerReference.combine([cond.tag, this.branchTag]); - var RootState = (function () { - function RootState(root, env, template, self, parentElement, dynamicScope) { - var _this = this; + this.cond = cond; + this.truthy = truthy; + this.falsy = falsy; + } - babelHelpers.classCallCheck(this, RootState); - - _emberMetal.assert('You cannot render `' + self.value() + '` without a template.', template); - - this.id = _emberViews.getViewId(root); - this.env = env; - this.root = root; - this.result = undefined; - this.shouldReflush = false; - this.destroyed = false; - this._removing = false; - - var options = this.options = { - alwaysRevalidate: false - }; - - this.render = function () { - var result = _this.result = template.render(self, parentElement, dynamicScope); - - // override .render function after initial render - _this.render = function () { - result.rerender(options); - }; - }; - } - - RootState.prototype.isFor = function isFor(possibleRoot) { - return this.root === possibleRoot; - }; - - RootState.prototype.destroy = function destroy() { - var result = this.result; - var env = this.env; - - this.destroyed = true; - - this.env = null; - this.root = null; - this.result = null; - this.render = null; + /** + The inline `if` helper conditionally renders a single property or string. + This helper acts like a ternary operator. If the first property is truthy, + the second argument will be displayed, otherwise, the third argument will be + displayed + + ```handlebars + {{if useLongGreeting "Hello" "Hi"}} Alex + ``` + + You can use the `if` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(if isBig "100" "10")}} + ``` + + @method if + @for Ember.Templates.helpers + @public + */ - if (result) { - /* - Handles these scenarios: - * When roots are removed during standard rendering process, a transaction exists already - `.begin()` / `.commit()` are not needed. - * When roots are being destroyed manually (`component.append(); component.destroy() case), no - transaction exists already. - * When roots are being destroyed during `Renderer#destroy`, no transaction exists - */ - var needsTransaction = !env.inTransaction; + ConditionalHelperReference.prototype.compute = function compute() { + var cond = this.cond; + var truthy = this.truthy; + var falsy = this.falsy; - if (needsTransaction) { - env.begin(); - } + var branch = cond.value() ? truthy : falsy; - result.destroy(); + this.branchTag.update(branch.tag); - if (needsTransaction) { - env.commit(); - } - } + return branch.value(); }; - return RootState; - })(); - - var renderers = []; - - _emberMetal.setHasViews(function () { - return renderers.length > 0; - }); - - function register(renderer) { - _emberMetal.assert('Cannot register the same renderer twice', renderers.indexOf(renderer) === -1); - renderers.push(renderer); - } - - function deregister(renderer) { - var index = renderers.indexOf(renderer); - _emberMetal.assert('Cannot deregister unknown unregistered renderer', index !== -1); - renderers.splice(index, 1); - } - - function loopBegin() { - for (var i = 0; i < renderers.length; i++) { - renderers[i]._scheduleRevalidate(); - } - } + return ConditionalHelperReference; + })(_emberGlimmerUtilsReferences.CachedReference); - function K() {} + function inlineIf(vm, _ref) { + var positional = _ref.positional; - var loops = 0; - function loopEnd(current, next) { - for (var i = 0; i < renderers.length; i++) { - if (!renderers[i]._isValid()) { - if (loops > 10) { - loops = 0; - // TODO: do something better - renderers[i].destroy(); - throw new Error('infinite rendering invalidation detected'); - } - loops++; - return backburner.join(null, K); - } + switch (positional.length) { + case 2: + return ConditionalHelperReference.create(positional.at(0), positional.at(1), null); + case 3: + return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); + default: + _emberMetal.assert('The inline form of the `if` helper expects two or three arguments, e.g. ' + '`{{if trialExpired "Expired" expiryDate}}`.'); } - loops = 0; } - backburner.on('begin', loopBegin); - backburner.on('end', loopEnd); - - var Renderer = (function () { - function Renderer(env, rootTemplate) { - var _viewRegistry = arguments.length <= 2 || arguments[2] === undefined ? _emberViews.fallbackViewRegistry : arguments[2]; + /** + The inline `unless` helper conditionally renders a single property or string. + This helper acts like a ternary operator. If the first property is falsy, + the second argument will be displayed, otherwise, the third argument will be + displayed + + ```handlebars + {{unless useLongGreeting "Hi" "Hello"}} Ben + ``` + + You can use the `unless` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(unless isBig "10" "100")}} + ``` + + @method unless + @for Ember.Templates.helpers + @public + */ - var destinedForDOM = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; - babelHelpers.classCallCheck(this, Renderer); + function inlineUnless(vm, _ref2) { + var positional = _ref2.positional; - this._env = env; - this._rootTemplate = rootTemplate; - this._viewRegistry = _viewRegistry; - this._destinedForDOM = destinedForDOM; - this._destroyed = false; - this._roots = []; - this._lastRevision = null; - this._isRenderingRoots = false; - this._removedRoots = []; + switch (positional.length) { + case 2: + return ConditionalHelperReference.create(positional.at(0), null, positional.at(1)); + case 3: + return ConditionalHelperReference.create(positional.at(0), positional.at(2), positional.at(1)); + default: + _emberMetal.assert('The inline form of the `unless` helper expects two or three arguments, e.g. ' + '`{{unless isFirstLogin "Welcome back!"}}`.'); } + } +}); +enifed('ember-glimmer/helpers/loc', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - // renderer HOOKS - - Renderer.prototype.appendOutletView = function appendOutletView(view, target) { - var definition = new _emberGlimmerSyntaxOutlet.TopLevelOutletComponentDefinition(view); - var outletStateReference = view.toReference(); - var targetObject = view.outletState.render.controller; - - this._appendDefinition(view, definition, target, outletStateReference, targetObject); - }; - - Renderer.prototype.appendTo = function appendTo(view, target) { - var rootDef = new _emberGlimmerSyntaxCurlyComponent.RootComponentDefinition(view); - - this._appendDefinition(view, rootDef, target); - }; - - Renderer.prototype._appendDefinition = function _appendDefinition(root, definition, target) { - var outletStateReference = arguments.length <= 3 || arguments[3] === undefined ? _glimmerReference.UNDEFINED_REFERENCE : arguments[3]; - var targetObject = arguments.length <= 4 || arguments[4] === undefined ? null : arguments[4]; - - var self = new _emberGlimmerUtilsReferences.RootReference(definition); - var dynamicScope = new DynamicScope(null, outletStateReference, outletStateReference, true, targetObject); - var rootState = new RootState(root, this._env, this._rootTemplate, self, target, dynamicScope); - - this._renderRoot(rootState); - }; - - Renderer.prototype.rerender = function rerender(view) { - this._scheduleRevalidate(); - }; - - Renderer.prototype.register = function register(view) { - var id = _emberViews.getViewId(view); - _emberMetal.assert('Attempted to register a view with an id already in use: ' + id, !this._viewRegistry[id]); - this._viewRegistry[id] = view; - }; - - Renderer.prototype.unregister = function unregister(view) { - delete this._viewRegistry[_emberViews.getViewId(view)]; + /** + Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the + provided string. This is a convenient way to localize text within a template. + For example: + + ```javascript + Ember.STRINGS = { + '_welcome_': 'Bonjour' }; + ``` + + ```handlebars +
    + {{loc '_welcome_'}} +
    + ``` + + ```html +
    + Bonjour +
    + ``` + + See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to + set up localized string references. + + @method loc + @for Ember.Templates.helpers + @param {String} str The string to format. + @see {Ember.String#loc} + @public + */ + function locHelper(_ref) { + var positional = _ref.positional; - Renderer.prototype.remove = function remove(view) { - view._transitionTo('destroying'); + return _emberRuntime.String.loc.apply(null, positional.value()); + } - this.cleanupRootFor(view); + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(locHelper, args); + }; +}); +enifed('ember-glimmer/helpers/log', ['exports', 'ember-glimmer/utils/references', 'ember-console'], function (exports, _emberGlimmerUtilsReferences, _emberConsole) { + 'use strict'; - _emberViews.setViewElement(view, null); + /** + `log` allows you to output the value of variables in the current rendering + context. `log` also accepts primitive types such as strings or numbers. + + ```handlebars + {{log "myVariable:" myVariable }} + ``` + + @method log + @for Ember.Templates.helpers + @param {Array} params + @public + */ + function log(_ref) { + var positional = _ref.positional; - if (this._destinedForDOM) { - view.trigger('didDestroyElement'); - } + _emberConsole.default.log.apply(null, positional.value()); + } - if (!view.isDestroying) { - view.destroy(); - } - }; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(log, args); + }; +}); - Renderer.prototype.cleanupRootFor = function cleanupRootFor(view) { - // no need to cleanup roots if we have already been destroyed - if (this._destroyed) { - return; - } +/** +@module ember +@submodule ember-glimmer +*/ +enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerHelpersAction) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var roots = this._roots; + exports.isMut = isMut; + exports.unMut = unMut; - // traverse in reverse so we can remove items - // without mucking up the index - var i = this._roots.length; - while (i--) { - var root = roots[i]; - if (root.isFor(view)) { - root.destroy(); - } + /** + The `mut` helper lets you __clearly specify__ that a child `Component` can update the + (mutable) value passed to it, which will __change the value of the parent component__. + + To specify that a parameter is mutable, when invoking the child `Component`: + + ```handlebars + {{my-child childClickCount=(mut totalClicks)}} + ``` + + The child `Component` can then modify the parent's value just by modifying its own + property: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.incrementProperty('childClickCount'); } - }; - - Renderer.prototype.destroy = function destroy() { - if (this._destroyed) { - return; + }); + ``` + + Note that for curly components (`{{my-component}}`) the bindings are already mutable, + making the `mut` unnecessary. + + Additionally, the `mut` helper can be combined with the `action` helper to + mutate a value. For example: + + ```handlebars + {{my-child childClickCount=totalClicks click-count-change=(action (mut totalClicks))}} + ``` + + The child `Component` would invoke the action with the new click value: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.get('click-count-change')(this.get('childClickCount') + 1); } - this._destroyed = true; - this._clearAllRoots(); - }; - - Renderer.prototype.getElement = function getElement(view) { - // overriden in the subclasses - }; - - Renderer.prototype.getBounds = function getBounds(view) { - var bounds = view[_emberGlimmerComponent.BOUNDS]; + }); + ``` + + The `mut` helper changes the `totalClicks` value to what was provided as the action argument. + + The `mut` helper, when used with `action`, will return a function that + sets the value passed to `mut` to its first argument. This works like any other + closure action and interacts with the other features `action` provides. + As an example, we can create a button that increments a value passing the value + directly to the `action`: + + ```handlebars + {{! inc helper is not provided by Ember }} + + ``` + + You can also use the `value` option: + + ```handlebars + + ``` + + @method mut + @param {Object} [attr] the "two-way" attribute that can be modified. + @for Ember.Templates.helpers + @public + */ + var MUT_REFERENCE = _emberUtils.symbol('MUT'); + var SOURCE = _emberUtils.symbol('SOURCE'); - var parentElement = bounds.parentElement(); - var firstNode = bounds.firstNode(); - var lastNode = bounds.lastNode(); + function isMut(ref) { + return ref && ref[MUT_REFERENCE]; + } - return { parentElement: parentElement, firstNode: firstNode, lastNode: lastNode }; - }; + function unMut(ref) { + return ref[SOURCE] || ref; + } - Renderer.prototype.createElement = function createElement(tagName) { - return this._env.getAppendOperations().createElement(tagName); - }; + exports.default = function (vm, args) { + var rawRef = args.positional.at(0); - Renderer.prototype._renderRoot = function _renderRoot(root) { - var roots = this._roots; + if (isMut(rawRef)) { + return rawRef; + } - roots.push(root); + // TODO: Improve this error message. This covers at least two distinct + // cases: + // + // 1. (mut "not a path") – passing a literal, result from a helper + // invocation, etc + // + // 2. (mut receivedValue) – passing a value received from the caller + // that was originally derived from a literal, result from a helper + // invocation, etc + // + // This message is alright for the first case, but could be quite + // confusing for the second case. + _emberMetal.assert('You can only pass a path to mut', rawRef[_emberGlimmerUtilsReferences.UPDATE]); - if (roots.length === 1) { - register(this); - } + var wrappedRef = Object.create(rawRef); - this._renderRootsTransaction(); - }; + wrappedRef[SOURCE] = rawRef; + wrappedRef[_emberGlimmerHelpersAction.INVOKE] = rawRef[_emberGlimmerUtilsReferences.UPDATE]; + wrappedRef[MUT_REFERENCE] = true; - Renderer.prototype._renderRoots = function _renderRoots() { - var roots = this._roots; - var env = this._env; - var removedRoots = this._removedRoots; + return wrappedRef; + }; +}); +enifed('ember-glimmer/helpers/query-param', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal, _emberRouting) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var globalShouldReflush = undefined, - initialRootsLength = undefined; + /** + This is a helper to be used in conjunction with the link-to helper. + It will supply url query parameters to the target route. + + Example + + ```handlebars + {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} + ``` + + @method query-params + @for Ember.Templates.helpers + @param {Object} hash takes a hash of query parameters + @return {Object} A `QueryParams` object for `{{link-to}}` + @public + */ + function queryParams(_ref) { + var positional = _ref.positional; + var named = _ref.named; - do { - env.begin(); + _emberMetal.assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', positional.value().length === 0); - // ensure that for the first iteration of the loop - // each root is processed - initialRootsLength = roots.length; - globalShouldReflush = false; + return _emberRouting.QueryParams.create({ + values: _emberUtils.assign({}, named.value()) + }); + } - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(queryParams, args); + }; +}); +enifed('ember-glimmer/helpers/readonly', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/mut'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerHelpersMut) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - if (root.destroyed) { - // add to the list of roots to be removed - // they will be removed from `this._roots` later - removedRoots.push(root); - - // skip over roots that have been marked as destroyed - continue; - } - - var shouldReflush = root.shouldReflush; - - // when processing non-initial reflush loops, - // do not process more roots than needed - if (i >= initialRootsLength && !shouldReflush) { - continue; - } - - root.options.alwaysRevalidate = shouldReflush; - // track shouldReflush based on this roots render result - shouldReflush = root.shouldReflush = runInTransaction(root, 'render'); - - // globalShouldReflush should be `true` if *any* of - // the roots need to reflush - globalShouldReflush = globalShouldReflush || shouldReflush; - } - - this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - - env.commit(); - } while (globalShouldReflush || roots.length > initialRootsLength); - - // remove any roots that were destroyed during this transaction - while (removedRoots.length) { - var root = removedRoots.pop(); - - var rootIndex = roots.indexOf(root); - roots.splice(rootIndex, 1); - } - - if (this._roots.length === 0) { - deregister(this); - } - }; - - Renderer.prototype._renderRootsTransaction = function _renderRootsTransaction() { - if (this._isRenderingRoots) { - // currently rendering roots, a new root was added and will - // be processed by the existing _renderRoots invocation - return; - } - - // used to prevent calling _renderRoots again (see above) - // while we are actively rendering roots - this._isRenderingRoots = true; - - var completedWithoutError = false; - try { - this._renderRoots(); - completedWithoutError = true; - } finally { - if (!completedWithoutError) { - this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - } - this._isRenderingRoots = false; - } - }; - - Renderer.prototype._clearAllRoots = function _clearAllRoots() { - var roots = this._roots; - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; - root.destroy(); - } - - this._removedRoots.length = 0; - this._roots = null; - - // if roots were present before destroying - // deregister this renderer instance - if (roots.length) { - deregister(this); - } - }; - - Renderer.prototype._scheduleRevalidate = function _scheduleRevalidate() { - backburner.scheduleOnce('render', this, this._revalidate); - }; - - Renderer.prototype._isValid = function _isValid() { - return this._destroyed || this._roots.length === 0 || _glimmerReference.CURRENT_TAG.validate(this._lastRevision); - }; - - Renderer.prototype._revalidate = function _revalidate() { - if (this._isValid()) { - return; - } - this._renderRootsTransaction(); - }; - - return Renderer; - })(); - - var InertRenderer = (function (_Renderer) { - babelHelpers.inherits(InertRenderer, _Renderer); - - function InertRenderer() { - babelHelpers.classCallCheck(this, InertRenderer); - - _Renderer.apply(this, arguments); - } - - InertRenderer.create = function create(_ref) { - var env = _ref.env; - var rootTemplate = _ref.rootTemplate; - var _viewRegistry = _ref._viewRegistry; - - return new this(env, rootTemplate, _viewRegistry, false); - }; - - InertRenderer.prototype.getElement = function getElement(view) { - throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); - }; - - return InertRenderer; - })(Renderer); - - exports.InertRenderer = InertRenderer; - - var InteractiveRenderer = (function (_Renderer2) { - babelHelpers.inherits(InteractiveRenderer, _Renderer2); - - function InteractiveRenderer() { - babelHelpers.classCallCheck(this, InteractiveRenderer); - - _Renderer2.apply(this, arguments); - } - - InteractiveRenderer.create = function create(_ref2) { - var env = _ref2.env; - var rootTemplate = _ref2.rootTemplate; - var _viewRegistry = _ref2._viewRegistry; - - return new this(env, rootTemplate, _viewRegistry, true); - }; - - InteractiveRenderer.prototype.getElement = function getElement(view) { - return _emberViews.getViewElement(view); - }; - - return InteractiveRenderer; - })(Renderer); - - exports.InteractiveRenderer = InteractiveRenderer; -}); -enifed('ember-glimmer/setup-registry', ['exports', 'ember-environment', 'container', 'ember-glimmer/renderer', 'ember-glimmer/dom', 'ember-glimmer/views/outlet', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/templates/component', 'ember-glimmer/templates/root', 'ember-glimmer/templates/outlet', 'ember-glimmer/environment'], function (exports, _emberEnvironment, _container, _emberGlimmerRenderer, _emberGlimmerDom, _emberGlimmerViewsOutlet, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerTemplatesComponent, _emberGlimmerTemplatesRoot, _emberGlimmerTemplatesOutlet, _emberGlimmerEnvironment) { - 'use strict'; - - exports.setupApplicationRegistry = setupApplicationRegistry; - exports.setupEngineRegistry = setupEngineRegistry; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:-root'], ['template:-root']), - _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']), - _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - - function setupApplicationRegistry(registry) { - registry.injection('service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); - registry.injection('renderer', 'env', 'service:-glimmer-environment'); - - registry.register(_container.privatize(_templateObject), _emberGlimmerTemplatesRoot.default); - registry.injection('renderer', 'rootTemplate', _container.privatize(_templateObject)); - - registry.register('renderer:-dom', _emberGlimmerRenderer.InteractiveRenderer); - registry.register('renderer:-inert', _emberGlimmerRenderer.InertRenderer); - - if (_emberEnvironment.environment.hasDOM) { - registry.injection('service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); - } - - registry.register('service:-dom-changes', { - create: function (_ref) { - var document = _ref.document; - return new _emberGlimmerDom.DOMChanges(document); - } - }); - - registry.register('service:-dom-tree-construction', { - create: function (_ref2) { - var document = _ref2.document; - - var Implementation = _emberEnvironment.environment.hasDOM ? _emberGlimmerDom.DOMTreeConstruction : _emberGlimmerDom.NodeDOMTreeConstruction; - return new Implementation(document); - } - }); - } - - function setupEngineRegistry(registry) { - registry.register('view:-outlet', _emberGlimmerViewsOutlet.default); - registry.register('template:-outlet', _emberGlimmerTemplatesOutlet.default); - registry.injection('view:-outlet', 'template', 'template:-outlet'); - - registry.injection('service:-dom-changes', 'document', 'service:-document'); - registry.injection('service:-dom-tree-construction', 'document', 'service:-document'); - - registry.register(_container.privatize(_templateObject2), _emberGlimmerTemplatesComponent.default); - - registry.register('service:-glimmer-environment', _emberGlimmerEnvironment.default); - registry.injection('template', 'env', 'service:-glimmer-environment'); - - registry.optionsForType('helper', { instantiate: false }); - - registry.register('component:-text-field', _emberGlimmerComponentsText_field.default); - registry.register('component:-text-area', _emberGlimmerComponentsText_area.default); - registry.register('component:-checkbox', _emberGlimmerComponentsCheckbox.default); - registry.register('component:link-to', _emberGlimmerComponentsLinkTo.default); - registry.register(_container.privatize(_templateObject3), _emberGlimmerComponent.default); - } -}); -enifed('ember-glimmer/syntax', ['exports', 'ember-glimmer/syntax/render', 'ember-glimmer/syntax/outlet', 'ember-glimmer/syntax/mount', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/syntax/input', 'glimmer-runtime'], function (exports, _emberGlimmerSyntaxRender, _emberGlimmerSyntaxOutlet, _emberGlimmerSyntaxMount, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerSyntaxInput, _glimmerRuntime) { - 'use strict'; - - exports.registerSyntax = registerSyntax; - exports.findSyntaxBuilder = findSyntaxBuilder; - - var syntaxKeys = []; - var syntaxes = []; - - function registerSyntax(key, syntax) { - syntaxKeys.push(key); - syntaxes.push(syntax); - } - - function findSyntaxBuilder(key) { - var index = syntaxKeys.indexOf(key); - - if (index > -1) { - return syntaxes[index]; - } - } - - registerSyntax('render', _emberGlimmerSyntaxRender.RenderSyntax); - registerSyntax('outlet', _emberGlimmerSyntaxOutlet.OutletSyntax); - registerSyntax('mount', _emberGlimmerSyntaxMount.MountSyntax); - registerSyntax('component', _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax); - registerSyntax('input', _emberGlimmerSyntaxInput.InputSyntax); - - registerSyntax('-with-dynamic-vars', (function () { - function _class() { - babelHelpers.classCallCheck(this, _class); - } - - _class.create = function create(environment, args, symbolTable) { - return new _glimmerRuntime.WithDynamicVarsSyntax(args); - }; - - return _class; - })()); - - registerSyntax('-in-element', (function () { - function _class2() { - babelHelpers.classCallCheck(this, _class2); - } - - _class2.create = function create(environment, args, symbolTable) { - return new _glimmerRuntime.InElementSyntax(args); - }; - - return _class2; - })()); -}); -enifed('ember-glimmer/syntax/curly-component', ['exports', 'ember-utils', 'glimmer-runtime', 'ember-glimmer/utils/bindings', 'ember-glimmer/component', 'ember-metal', 'ember-views', 'ember-glimmer/utils/process-args', 'container'], function (exports, _emberUtils, _glimmerRuntime, _emberGlimmerUtilsBindings, _emberGlimmerComponent, _emberMetal, _emberViews, _emberGlimmerUtilsProcessArgs, _container) { - 'use strict'; - - exports.validatePositionalParameters = validatePositionalParameters; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); - - var DEFAULT_LAYOUT = _container.privatize(_templateObject); - - function processComponentInitializationAssertions(component, props) { - _emberMetal.assert('classNameBindings must not have spaces in them: ' + component.toString(), (function () { - var classNameBindings = component.classNameBindings; - - for (var i = 0; i < classNameBindings.length; i++) { - var binding = classNameBindings[i]; - if (binding.split(' ').length > 1) { - return false; - } - } - return true; - })()); - - _emberMetal.assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), (function () { - var classNameBindings = component.classNameBindings; - var tagName = component.tagName; - - return tagName !== '' || !classNameBindings || classNameBindings.length === 0; - })()); - - _emberMetal.assert('You cannot use `elementId` on a tag-less component: ' + component.toString(), (function () { - var elementId = component.elementId; - var tagName = component.tagName; - - return tagName !== '' || props.id === elementId || !elementId && elementId !== ''; - })()); - - _emberMetal.assert('You cannot use `attributeBindings` on a tag-less component: ' + component.toString(), (function () { - var attributeBindings = component.attributeBindings; - var tagName = component.tagName; - - return tagName !== '' || !attributeBindings || attributeBindings.length === 0; - })()); - } - - function validatePositionalParameters(named, positional, positionalParamsDefinition) { - _emberMetal.runInDebug(function () { - if (!named || !positional || !positional.length) { - return; - } - - var paramType = typeof positionalParamsDefinition; - - if (paramType === 'string') { - _emberMetal.assert('You cannot specify positional parameters and the hash argument `' + positionalParamsDefinition + '`.', !named.has(positionalParamsDefinition)); - } else { - if (positional.length < positionalParamsDefinition.length) { - positionalParamsDefinition = positionalParamsDefinition.slice(0, positional.length); - } - - for (var i = 0; i < positionalParamsDefinition.length; i++) { - var _name = positionalParamsDefinition[i]; - - _emberMetal.assert('You cannot specify both a positional param (at position ' + i + ') and the hash argument `' + _name + '`.', !named.has(_name)); - } - } - }); - } - - function aliasIdToElementId(args, props) { - if (args.named.has('id')) { - _emberMetal.assert('You cannot invoke a component with both \'id\' and \'elementId\' at the same time.', !args.named.has('elementId')); - props.elementId = props.id; - } - } - - // We must traverse the attributeBindings in reverse keeping track of - // what has already been applied. This is essentially refining the concated - // properties applying right to left. - function applyAttributeBindings(element, attributeBindings, component, operations) { - var seen = []; - var i = attributeBindings.length - 1; - - while (i !== -1) { - var binding = attributeBindings[i]; - var parsed = _emberGlimmerUtilsBindings.AttributeBinding.parse(binding); - var attribute = parsed[1]; - - if (seen.indexOf(attribute) === -1) { - seen.push(attribute); - _emberGlimmerUtilsBindings.AttributeBinding.install(element, component, parsed, operations); - } - - i--; - } - - if (seen.indexOf('id') === -1) { - operations.addStaticAttribute(element, 'id', component.elementId); - } - - if (seen.indexOf('style') === -1) { - _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); - } - } - - var CurlyComponentSyntax = (function (_StatementSyntax) { -babelHelpers.inherits(CurlyComponentSyntax, _StatementSyntax); - - function CurlyComponentSyntax(args, definition, symbolTable) { -babelHelpers.classCallCheck(this, CurlyComponentSyntax); - - _StatementSyntax.call(this); - this.args = args; - this.definition = definition; - this.symbolTable = symbolTable; - this.shadow = null; - } - - CurlyComponentSyntax.prototype.compile = function compile(builder) { - builder.component.static(this.definition, this.args, this.symbolTable, this.shadow); - }; - - return CurlyComponentSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.CurlyComponentSyntax = CurlyComponentSyntax; - - function NOOP() {} - - var ComponentStateBucket = (function () { - function ComponentStateBucket(environment, component, args, finalizer) { -babelHelpers.classCallCheck(this, ComponentStateBucket); - - this.environment = environment; - this.component = component; - this.classRef = null; - this.args = args; - this.argsRevision = args.tag.value(); - this.finalizer = finalizer; - } - - ComponentStateBucket.prototype.destroy = function destroy() { - var component = this.component; - var environment = this.environment; - - if (environment.isInteractive) { - component.trigger('willDestroyElement'); - component.trigger('willClearRender'); - } - - environment.destroyedComponents.push(component); - }; - - ComponentStateBucket.prototype.finalize = function finalize() { - var finalizer = this.finalizer; - - finalizer(); - this.finalizer = NOOP; - }; - - return ComponentStateBucket; - })(); - - function initialRenderInstrumentDetails(component) { - return component.instrumentDetails({ initialRender: true }); - } - - function rerenderInstrumentDetails(component) { - return component.instrumentDetails({ initialRender: false }); - } - - var CurlyComponentManager = (function () { - function CurlyComponentManager() { -babelHelpers.classCallCheck(this, CurlyComponentManager); - } - - CurlyComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { - validatePositionalParameters(args.named, args.positional.values, definition.ComponentClass.positionalParams); - - return _emberGlimmerUtilsProcessArgs.gatherArgs(args, definition); - }; - - CurlyComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, callerSelfRef, hasBlock) { - var parentView = dynamicScope.view; - - var klass = definition.ComponentClass; - var processedArgs = _emberGlimmerUtilsProcessArgs.ComponentArgs.create(args); - - var _processedArgs$value = processedArgs.value(); - - var props = _processedArgs$value.props; - - aliasIdToElementId(args, props); - - props.parentView = parentView; - props[_emberGlimmerComponent.HAS_BLOCK] = hasBlock; - - props._targetObject = callerSelfRef.value(); - - var component = klass.create(props); - - var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - - dynamicScope.view = component; - - if (parentView !== null) { - parentView.appendChild(component); - } - - // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components - if (component.tagName === '') { - if (environment.isInteractive) { - component.trigger('willRender'); - } - - component._transitionTo('hasElement'); - - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } - } - - var bucket = new ComponentStateBucket(environment, component, processedArgs, finalizer); - - if (args.named.has('class')) { - bucket.classRef = args.named.get('class'); - } - - processComponentInitializationAssertions(component, props); - - if (environment.isInteractive && component.tagName !== '') { - component.trigger('willRender'); - } - - return bucket; - }; - - CurlyComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - var template = definition.template; - if (!template) { - var component = bucket.component; - - template = this.templateFor(component, env); - } - return env.getCompiledBlock(CurlyComponentLayoutCompiler, template); - }; - - CurlyComponentManager.prototype.templateFor = function templateFor(component, env) { - var Template = _emberMetal.get(component, 'layout'); - var owner = component[_emberUtils.OWNER]; - if (Template) { - return env.getTemplate(Template, owner); - } - var layoutName = _emberMetal.get(component, 'layoutName'); - if (layoutName) { - var template = owner.lookup('template:' + layoutName); - if (template) { - return template; - } - } - return owner.lookup(DEFAULT_LAYOUT); - }; - - CurlyComponentManager.prototype.getSelf = function getSelf(_ref) { - var component = _ref.component; - - return component[_emberGlimmerComponent.ROOT_REF]; - }; - - CurlyComponentManager.prototype.didCreateElement = function didCreateElement(_ref2, element, operations) { - var component = _ref2.component; - var classRef = _ref2.classRef; - var environment = _ref2.environment; - - _emberViews.setViewElement(component, element); - - var attributeBindings = component.attributeBindings; - var classNames = component.classNames; - var classNameBindings = component.classNameBindings; - - if (attributeBindings && attributeBindings.length) { - applyAttributeBindings(element, attributeBindings, component, operations); - } else { - operations.addStaticAttribute(element, 'id', component.elementId); - _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); - } - - if (classRef) { - operations.addDynamicAttribute(element, 'class', classRef); - } - - if (classNames && classNames.length) { - classNames.forEach(function (name) { - operations.addStaticAttribute(element, 'class', name); - }); - } - - if (classNameBindings && classNameBindings.length) { - classNameBindings.forEach(function (binding) { - _emberGlimmerUtilsBindings.ClassNameBinding.install(element, component, binding, operations); - }); - } - - component._transitionTo('hasElement'); - - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } - }; - - CurlyComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket, bounds) { - bucket.component[_emberGlimmerComponent.BOUNDS] = bounds; - bucket.finalize(); - }; - - CurlyComponentManager.prototype.getTag = function getTag(_ref3) { - var component = _ref3.component; - - return component[_emberGlimmerComponent.DIRTY_TAG]; - }; - - CurlyComponentManager.prototype.didCreate = function didCreate(_ref4) { - var component = _ref4.component; - var environment = _ref4.environment; - - if (environment.isInteractive) { - component._transitionTo('inDOM'); - component.trigger('didInsertElement'); - component.trigger('didRender'); - } - }; - - CurlyComponentManager.prototype.update = function update(bucket, _, dynamicScope) { - var component = bucket.component; - var args = bucket.args; - var argsRevision = bucket.argsRevision; - var environment = bucket.environment; - - bucket.finalizer = _emberMetal._instrumentStart('render.component', rerenderInstrumentDetails, component); - - if (!args.tag.validate(argsRevision)) { - var _args$value = args.value(); - - var attrs = _args$value.attrs; - var props = _args$value.props; - - bucket.argsRevision = args.tag.value(); - - var oldAttrs = component.attrs; - var newAttrs = attrs; - - component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = true; - component.setProperties(props); - component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = false; - - component.trigger('didUpdateAttrs', { oldAttrs: oldAttrs, newAttrs: newAttrs }); - component.trigger('didReceiveAttrs', { oldAttrs: oldAttrs, newAttrs: newAttrs }); - } - - if (environment.isInteractive) { - component.trigger('willUpdate'); - component.trigger('willRender'); - } - }; - - CurlyComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) { - bucket.finalize(); - }; - - CurlyComponentManager.prototype.didUpdate = function didUpdate(_ref5) { - var component = _ref5.component; - var environment = _ref5.environment; - - if (environment.isInteractive) { - component.trigger('didUpdate'); - component.trigger('didRender'); - } - }; - - CurlyComponentManager.prototype.getDestructor = function getDestructor(stateBucket) { - return stateBucket; - }; - - return CurlyComponentManager; - })(); - - var MANAGER = new CurlyComponentManager(); - - var TopComponentManager = (function (_CurlyComponentManager) { -babelHelpers.inherits(TopComponentManager, _CurlyComponentManager); - - function TopComponentManager() { -babelHelpers.classCallCheck(this, TopComponentManager); - - _CurlyComponentManager.apply(this, arguments); - } - - TopComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, currentScope, hasBlock) { - var component = definition.ComponentClass; - - var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - - dynamicScope.view = component; - - // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components - if (component.tagName === '') { - if (environment.isInteractive) { - component.trigger('willRender'); - } - - component._transitionTo('hasElement'); - - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } - } - - processComponentInitializationAssertions(component, {}); - - return new ComponentStateBucket(environment, component, args, finalizer); - }; - - return TopComponentManager; - })(CurlyComponentManager); - - var ROOT_MANAGER = new TopComponentManager(); - - function tagName(vm) { - var tagName = vm.dynamicScope().view.tagName; - - return _glimmerRuntime.PrimitiveReference.create(tagName === '' ? null : tagName || 'div'); - } - - function ariaRole(vm) { - return vm.getSelf().get('ariaRole'); - } - - var CurlyComponentDefinition = (function (_ComponentDefinition) { -babelHelpers.inherits(CurlyComponentDefinition, _ComponentDefinition); - - function CurlyComponentDefinition(name, ComponentClass, template, args) { -babelHelpers.classCallCheck(this, CurlyComponentDefinition); - - _ComponentDefinition.call(this, name, MANAGER, ComponentClass); - this.template = template; - this.args = args; - } - - return CurlyComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - exports.CurlyComponentDefinition = CurlyComponentDefinition; - - var RootComponentDefinition = (function (_ComponentDefinition2) { -babelHelpers.inherits(RootComponentDefinition, _ComponentDefinition2); - - function RootComponentDefinition(instance) { -babelHelpers.classCallCheck(this, RootComponentDefinition); - - _ComponentDefinition2.call(this, '-root', ROOT_MANAGER, instance); - this.template = undefined; - this.args = undefined; - } - - return RootComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - exports.RootComponentDefinition = RootComponentDefinition; - - var CurlyComponentLayoutCompiler = (function () { - function CurlyComponentLayoutCompiler(template) { -babelHelpers.classCallCheck(this, CurlyComponentLayoutCompiler); - - this.template = template; - } - - CurlyComponentLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - builder.tag.dynamic(tagName); - builder.attrs.dynamic('role', ariaRole); - builder.attrs.static('class', 'ember-view'); - }; - - return CurlyComponentLayoutCompiler; - })(); - - CurlyComponentLayoutCompiler.id = 'curly'; -}); -enifed('ember-glimmer/syntax/dynamic-component', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal) { - 'use strict'; - - function dynamicComponentFor(vm, symbolTable) { - var env = vm.env; - var args = vm.getArgs(); - var nameRef = args.positional.at(0); - - return new DynamicComponentReference({ nameRef: nameRef, env: env, symbolTable: symbolTable }); - } - - var DynamicComponentSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(DynamicComponentSyntax, _StatementSyntax); - - // for {{component componentName}} - - DynamicComponentSyntax.create = function create(environment, args, symbolTable) { - var definitionArgs = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1)); - var invocationArgs = _glimmerRuntime.ArgsSyntax.build(args.positional.slice(1), args.named, args.blocks); - - return new this(definitionArgs, invocationArgs, symbolTable); - }; - - // Transforms {{foo.bar with=args}} or {{#foo.bar with=args}}{{/foo.bar}} - // into {{component foo.bar with=args}} or - // {{#component foo.bar with=args}}{{/component}} - // with all of it's arguments - - DynamicComponentSyntax.fromPath = function fromPath(environment, path, args, symbolTable) { - var positional = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(_glimmerRuntime.PositionalArgsSyntax.build([_glimmerRuntime.GetSyntax.build(path.join('.'))])); - - return new this(positional, args, symbolTable); - }; - - function DynamicComponentSyntax(definitionArgs, args, symbolTable) { - babelHelpers.classCallCheck(this, DynamicComponentSyntax); - - _StatementSyntax.call(this); - this.definition = dynamicComponentFor; - this.definitionArgs = definitionArgs; - this.args = args; - this.symbolTable = symbolTable; - this.shadow = null; - } - - DynamicComponentSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return DynamicComponentSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.DynamicComponentSyntax = DynamicComponentSyntax; - - var DynamicComponentReference = (function () { - function DynamicComponentReference(_ref) { - var nameRef = _ref.nameRef; - var env = _ref.env; - var symbolTable = _ref.symbolTable; - var args = _ref.args; - babelHelpers.classCallCheck(this, DynamicComponentReference); - - this.tag = nameRef.tag; - this.nameRef = nameRef; - this.env = env; - this.symbolTable = symbolTable; - this.args = args; - } - - DynamicComponentReference.prototype.value = function value() { - var env = this.env; - var nameRef = this.nameRef; - var symbolTable = this.symbolTable; - - var nameOrDef = nameRef.value(); - - if (typeof nameOrDef === 'string') { - var definition = env.getComponentDefinition([nameOrDef], symbolTable); - - _emberMetal.assert('Could not find component named "' + nameOrDef + '" (no component or template with that name was found)', definition); - - return definition; - } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { - return nameOrDef; - } else { - return null; - } - }; - - DynamicComponentReference.prototype.get = function get() { - return _glimmerReference.UNDEFINED_REFERENCE; - }; - - return DynamicComponentReference; - })(); -}); -enifed('ember-glimmer/syntax/input', ['exports', 'ember-metal', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/bindings'], function (exports, _emberMetal, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsBindings) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - function buildTextFieldSyntax(args, getDefinition, symbolTable) { - var definition = getDefinition('-text-field'); - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } - - /** - The `{{input}}` helper lets you create an HTML `` component. - It causes an `Ember.TextField` component to be rendered. For more info, - see the [Ember.TextField](/api/classes/Ember.TextField.html) docs and - the [templates guide](http://emberjs.com/guides/templates/input-helpers/). - - ```handlebars - {{input value="987"}} - ``` - - renders as: - - ```HTML - - ``` - - ### Text field - - If no `type` option is specified, a default of type 'text' is used. - Many of the standard HTML attributes may be passed to this helper. - - - - - - - - - - - -
    `readonly``required``autofocus`
    `value``placeholder``disabled`
    `size``tabindex``maxlength`
    `name``min``max`
    `pattern``accept``autocomplete`
    `autosave``formaction``formenctype`
    `formmethod``formnovalidate``formtarget`
    `height``inputmode``multiple`
    `step``width``form`
    `selectionDirection``spellcheck` 
    - When set to a quoted string, these values will be directly applied to the HTML - element. When left unquoted, these values will be bound to a property on the - template's current rendering context (most typically a controller instance). - A very common use of this helper is to bind the `value` of an input to an Object's attribute: - - ```handlebars - Search: - {{input value=searchWord}} - ``` - - In this example, the inital value in the `` will be set to the value of `searchWord`. - If the user changes the text, the value of `searchWord` will also be updated. - - ### Actions - - The helper can send multiple actions based on user events. - The action property defines the action which is sent when - the user presses the return key. - - ```handlebars - {{input action="submit"}} - ``` - - The helper allows some user events to send actions. - - * `enter` - * `insert-newline` - * `escape-press` - * `focus-in` - * `focus-out` - * `key-press` - * `key-up` - - For example, if you desire an action to be sent when the input is blurred, - you only need to setup the action name to the event name property. - - ```handlebars - {{input focus-out="alertMessage"}} - ``` - See more about [Text Support Actions](/api/classes/Ember.TextField.html) - - ### Extending `Ember.TextField` - - Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing - arguments from the helper to `Ember.TextField`'s `create` method. You can extend the - capabilities of text inputs in your applications by reopening this class. For example, - if you are building a Bootstrap project where `data-*` attributes are used, you - can add one to the `TextField`'s `attributeBindings` property: - - ```javascript - Ember.TextField.reopen({ - attributeBindings: ['data-error'] - }); - ``` - - Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` - itself extends `Ember.Component`. Expect isolated component semantics, not - legacy 1.x view semantics (like `controller` being present). - See more about [Ember components](/api/classes/Ember.Component.html) - - ### Checkbox - - Checkboxes are special forms of the `{{input}}` helper. To create a ``: - - ```handlebars - Emberize Everything: - {{input type="checkbox" name="isEmberized" checked=isEmberized}} - ``` - - This will bind checked state of this checkbox to the value of `isEmberized` -- if either one changes, - it will be reflected in the other. - - The following HTML attributes can be set via the helper: - - * `checked` - * `disabled` - * `tabindex` - * `indeterminate` - * `name` - * `autofocus` - * `form` - - ### Extending `Ember.Checkbox` - - Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing - arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the - capablilties of checkbox inputs in your applications by reopening this class. For example, - if you wanted to add a css class to all checkboxes in your application: - - ```javascript - Ember.Checkbox.reopen({ - classNames: ['my-app-checkbox'] - }); - ``` - - @method input - @for Ember.Templates.helpers - @param {Hash} options - @public - */ - var InputSyntax = { - create: function (environment, args, symbolTable) { - var getDefinition = function (path) { - return environment.getComponentDefinition([path], symbolTable); - }; - - if (args.named.has('type')) { - var typeArg = args.named.at('type'); - if (typeArg.type === 'value') { - if (typeArg.value === 'checkbox') { - _emberMetal.assert('{{input type=\'checkbox\'}} does not support setting `value=someBooleanValue`; ' + 'you must use `checked=someBooleanValue` instead.', !args.named.has('value')); - - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - var definition = getDefinition('-checkbox'); - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } else { - return buildTextFieldSyntax(args, getDefinition, symbolTable); - } - } - } else { - return buildTextFieldSyntax(args, getDefinition, symbolTable); - } - - return _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax.create(environment, args, symbolTable); - } - }; - exports.InputSyntax = InputSyntax; -}); -enifed('ember-glimmer/syntax/mount', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - /** - The `{{mount}}` helper lets you embed a routeless engine in a template. - Mounting an engine will cause an instance to be booted and its `application` - template to be rendered. - - For example, the following template mounts the `ember-chat` engine: - - ```handlebars - {{! application.hbs }} - {{mount "ember-chat"}} - ``` - - Currently, the engine name is the only argument that can be passed to - `{{mount}}`. - - @method mount - @for Ember.Templates.helpers - @category ember-application-engines - @public - */ - - var MountSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(MountSyntax, _StatementSyntax); - - MountSyntax.create = function create(env, args, symbolTable) { - _emberMetal.assert('You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.', args.positional.length === 1 && args.named.length === 0); - - _emberMetal.assert('The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}.', args.positional.at(0).type === 'value' && typeof args.positional.at(0).inner() === 'string'); - - var name = args.positional.at(0).inner(); - - _emberMetal.assert('You used `{{mount \'' + name + '\'}}`, but the engine \'' + name + '\' can not be found.', env.owner.hasRegistration('engine:' + name)); - - var definition = new MountDefinition(name, env); - - return new MountSyntax(definition, symbolTable); - }; - - function MountSyntax(definition, symbolTable) { - babelHelpers.classCallCheck(this, MountSyntax); - - _StatementSyntax.call(this); - this.definition = definition; - this.symbolTable = symbolTable; - } - - MountSyntax.prototype.compile = function compile(builder) { - builder.component.static(this.definition, _glimmerRuntime.ArgsSyntax.empty(), null, this.symbolTable, null); - }; - - return MountSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.MountSyntax = MountSyntax; - - var MountManager = (function () { - function MountManager() { - babelHelpers.classCallCheck(this, MountManager); - } - - MountManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - MountManager.prototype.create = function create(environment, _ref, args, dynamicScope) { - var name = _ref.name; - var env = _ref.env; - - dynamicScope.outletState = _glimmerReference.UNDEFINED_REFERENCE; - - var engine = env.owner.buildChildEngineInstance(name); - - engine.boot(); - - return { engine: engine }; - }; - - MountManager.prototype.layoutFor = function layoutFor(definition, _ref2, env) { - var engine = _ref2.engine; - - var template = engine.lookup('template:application'); - return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, template); - }; - - MountManager.prototype.getSelf = function getSelf(_ref3) { - var engine = _ref3.engine; - - var factory = engine._lookupFactory('controller:application') || _emberRouting.generateControllerFactory(engine, 'application'); - return new _emberGlimmerUtilsReferences.RootReference(factory.create()); - }; - - MountManager.prototype.getTag = function getTag() { - return null; - }; - - MountManager.prototype.getDestructor = function getDestructor(_ref4) { - var engine = _ref4.engine; - - return engine; - }; - - MountManager.prototype.didCreateElement = function didCreateElement() {}; - - MountManager.prototype.didRenderLayout = function didRenderLayout() {}; - - MountManager.prototype.didCreate = function didCreate(state) {}; - - MountManager.prototype.update = function update(state, args, dynamicScope) {}; - - MountManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - - MountManager.prototype.didUpdate = function didUpdate(state) {}; - - return MountManager; - })(); - - var MOUNT_MANAGER = new MountManager(); - - var MountDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(MountDefinition, _ComponentDefinition); - - function MountDefinition(name, env) { - babelHelpers.classCallCheck(this, MountDefinition); - - _ComponentDefinition.call(this, name, MOUNT_MANAGER, null); - this.env = env; - } - - return MountDefinition; - })(_glimmerRuntime.ComponentDefinition); -}); -enifed('ember-glimmer/syntax/outlet', ['exports', 'ember-utils', 'glimmer-runtime', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberUtils, _glimmerRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - function outletComponentFor(vm) { - var _vm$dynamicScope = vm.dynamicScope(); - - var outletState = _vm$dynamicScope.outletState; - - var args = vm.getArgs(); - var outletNameRef = undefined; - if (args.positional.length === 0) { - outletNameRef = new _glimmerReference.ConstReference('main'); - } else { - outletNameRef = args.positional.at(0); - } - - return new OutletComponentReference(outletNameRef, outletState); - } - - /** - The `{{outlet}}` helper lets you specify where a child route will render in - your template. An important use of the `{{outlet}}` helper is in your - application's `application.hbs` file: - - ```handlebars - {{! app/templates/application.hbs }} - - {{my-header}} -
    - - {{outlet}} -
    - - {{my-footer}} - ``` - - See [templates guide](http://emberjs.com/guides/templates/the-application-template/) for - additional information on using `{{outlet}}` in `application.hbs`. - You may also specify a name for the `{{outlet}}`, which is useful when using more than one - `{{outlet}}` in a template: - - ```handlebars - {{outlet "menu"}} - {{outlet "sidebar"}} - {{outlet "main"}} - ``` - - Your routes can then render into a specific one of these `outlet`s by specifying the `outlet` - attribute in your `renderTemplate` function: - - ```javascript - // app/routes/menu.js - export default Ember.Route.extend({ - renderTemplate() { - this.render({ outlet: 'menu' }); - } - }); - ``` - - See the [routing guide](http://emberjs.com/guides/routing/rendering-a-template/) for more - information on how your `route` interacts with the `{{outlet}}` helper. - Note: Your content __will not render__ if there isn't an `{{outlet}}` for it. - - @method outlet - @param {String} [name] - @for Ember.Templates.helpers - @public - */ - - var OutletSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(OutletSyntax, _StatementSyntax); - - OutletSyntax.create = function create(environment, args, symbolTable) { - var definitionArgs = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1)); - return new this(environment, definitionArgs, symbolTable); - }; - - function OutletSyntax(environment, args, symbolTable) { - babelHelpers.classCallCheck(this, OutletSyntax); - - _StatementSyntax.call(this); - this.definitionArgs = args; - this.definition = outletComponentFor; - this.args = _glimmerRuntime.ArgsSyntax.empty(); - this.symbolTable = symbolTable; - this.shadow = null; - } - - OutletSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return OutletSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.OutletSyntax = OutletSyntax; - - var OutletComponentReference = (function () { - function OutletComponentReference(outletNameRef, parentOutletStateRef) { - babelHelpers.classCallCheck(this, OutletComponentReference); - - this.outletNameRef = outletNameRef; - this.parentOutletStateRef = parentOutletStateRef; - this.definition = null; - this.lastState = null; - var outletStateTag = this.outletStateTag = new _glimmerReference.UpdatableTag(parentOutletStateRef.tag); - this.tag = _glimmerReference.combine([outletStateTag.tag, outletNameRef.tag]); - } - - OutletComponentReference.prototype.value = function value() { - var outletNameRef = this.outletNameRef; - var parentOutletStateRef = this.parentOutletStateRef; - var definition = this.definition; - var lastState = this.lastState; - - var outletName = outletNameRef.value(); - var outletStateRef = parentOutletStateRef.get('outlets').get(outletName); - var newState = this.lastState = outletStateRef.value(); - - this.outletStateTag.update(outletStateRef.tag); - - definition = revalidate(definition, lastState, newState); - - var hasTemplate = newState && newState.render.template; - - if (definition) { - return definition; - } else if (hasTemplate) { - return this.definition = new OutletComponentDefinition(outletName, newState.render.template); - } else { - return this.definition = null; - } - }; - - return OutletComponentReference; - })(); - - function revalidate(definition, lastState, newState) { - if (!lastState && !newState) { - return definition; - } - - if (!lastState && newState || lastState && !newState) { - return null; - } - - if (newState.render.template === lastState.render.template && newState.render.controller === lastState.render.controller) { - return definition; - } - - return null; - } - - function instrumentationPayload(_ref) { - var _ref$render = _ref.render; - var name = _ref$render.name; - var outlet = _ref$render.outlet; - - return { object: name + ':' + outlet }; - } - - function NOOP() {} - - var StateBucket = (function () { - function StateBucket(outletState) { - babelHelpers.classCallCheck(this, StateBucket); - - this.outletState = outletState; - this.instrument(); - } - - StateBucket.prototype.instrument = function instrument() { - this.finalizer = _emberMetal._instrumentStart('render.outlet', instrumentationPayload, this.outletState); - }; - - StateBucket.prototype.finalize = function finalize() { - var finalizer = this.finalizer; - - finalizer(); - this.finalizer = NOOP; - }; - - return StateBucket; - })(); - - var OutletComponentManager = (function () { - function OutletComponentManager() { - babelHelpers.classCallCheck(this, OutletComponentManager); - } - - OutletComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - OutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var outletStateReference = dynamicScope.outletState = dynamicScope.outletState.get('outlets').get(definition.outletName); - var outletState = outletStateReference.value(); - return new StateBucket(outletState); - }; - - OutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(OutletLayoutCompiler, definition.template); - }; - - OutletComponentManager.prototype.getSelf = function getSelf(_ref2) { - var outletState = _ref2.outletState; - - return new _emberGlimmerUtilsReferences.RootReference(outletState.render.controller); - }; - - OutletComponentManager.prototype.getTag = function getTag() { - return null; - }; - - OutletComponentManager.prototype.getDestructor = function getDestructor() { - return null; - }; - - OutletComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket) { - bucket.finalize(); - }; - - OutletComponentManager.prototype.didCreateElement = function didCreateElement() {}; - - OutletComponentManager.prototype.didCreate = function didCreate(state) {}; - - OutletComponentManager.prototype.update = function update(bucket) {}; - - OutletComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) {}; - - OutletComponentManager.prototype.didUpdate = function didUpdate(state) {}; - - return OutletComponentManager; - })(); - - var MANAGER = new OutletComponentManager(); - - var TopLevelOutletComponentManager = (function (_OutletComponentManager) { - babelHelpers.inherits(TopLevelOutletComponentManager, _OutletComponentManager); - - function TopLevelOutletComponentManager() { - babelHelpers.classCallCheck(this, TopLevelOutletComponentManager); - - _OutletComponentManager.apply(this, arguments); - } - - TopLevelOutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - return new StateBucket(dynamicScope.outletState.value()); - }; - - TopLevelOutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(TopLevelOutletLayoutCompiler, definition.template); - }; - - return TopLevelOutletComponentManager; - })(OutletComponentManager); - - var TOP_LEVEL_MANAGER = new TopLevelOutletComponentManager(); - - var TopLevelOutletComponentDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(TopLevelOutletComponentDefinition, _ComponentDefinition); - - function TopLevelOutletComponentDefinition(instance) { - babelHelpers.classCallCheck(this, TopLevelOutletComponentDefinition); - - _ComponentDefinition.call(this, 'outlet', TOP_LEVEL_MANAGER, instance); - this.template = instance.template; - _emberUtils.generateGuid(this); - } - - return TopLevelOutletComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - exports.TopLevelOutletComponentDefinition = TopLevelOutletComponentDefinition; - - var TopLevelOutletLayoutCompiler = (function () { - function TopLevelOutletLayoutCompiler(template) { - babelHelpers.classCallCheck(this, TopLevelOutletLayoutCompiler); - - this.template = template; - } - - TopLevelOutletLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - builder.tag.static('div'); - builder.attrs.static('id', _emberUtils.guidFor(this)); - builder.attrs.static('class', 'ember-view'); - }; - - return TopLevelOutletLayoutCompiler; - })(); - - TopLevelOutletLayoutCompiler.id = 'top-level-outlet'; - - var OutletComponentDefinition = (function (_ComponentDefinition2) { - babelHelpers.inherits(OutletComponentDefinition, _ComponentDefinition2); - - function OutletComponentDefinition(outletName, template) { - babelHelpers.classCallCheck(this, OutletComponentDefinition); - - _ComponentDefinition2.call(this, 'outlet', MANAGER, null); - this.outletName = outletName; - this.template = template; - _emberUtils.generateGuid(this); - } - - return OutletComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); - - var OutletLayoutCompiler = (function () { - function OutletLayoutCompiler(template) { - babelHelpers.classCallCheck(this, OutletLayoutCompiler); - - this.template = template; - } - - OutletLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - }; - - return OutletLayoutCompiler; - })(); - - exports.OutletLayoutCompiler = OutletLayoutCompiler; - - OutletLayoutCompiler.id = 'outlet'; -}); -enifed('ember-glimmer/syntax/render', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - function makeComponentDefinition(vm) { - var env = vm.env; - var args = vm.getArgs(); - var nameRef = args.positional.at(0); - - _emberMetal.assert('The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.', _glimmerReference.isConst(nameRef)); - _emberMetal.assert('The second argument of {{render}} must be a path, e.g. {{render "post" post}}.', args.positional.length === 1 || !_glimmerReference.isConst(args.positional.at(1))); - - var templateName = nameRef.value(); - - _emberMetal.assert('You used `{{render \'' + templateName + '\'}}`, but \'' + templateName + '\' can not be found as a template.', env.owner.hasRegistration('template:' + templateName)); - - var template = env.owner.lookup('template:' + templateName); - - var controllerName = undefined; - - if (args.named.has('controller')) { - var controllerNameRef = args.named.get('controller'); - - _emberMetal.assert('The controller argument for {{render}} must be quoted, e.g. {{render "sidebar" controller="foo"}}.', _glimmerReference.isConst(controllerNameRef)); - - controllerName = controllerNameRef.value(); - - _emberMetal.assert('The controller name you supplied \'' + controllerName + '\' did not resolve to a controller.', env.owner.hasRegistration('controller:' + controllerName)); - } else { - controllerName = templateName; - } - - if (args.positional.length === 1) { - return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, SINGLETON_RENDER_MANAGER)); - } else { - return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, NON_SINGLETON_RENDER_MANAGER)); - } - } - - /** - Calling ``{{render}}`` from within a template will insert another - template that matches the provided name. The inserted template will - access its properties on its own controller (rather than the controller - of the parent template). - - If a view class with the same name exists, the view class also will be used. - Note: A given controller may only be used *once* in your app in this manner. - A singleton instance of the controller will be created for you. - - Example: - - ```javascript - App.NavigationController = Ember.Controller.extend({ - who: "world" - }); - ``` - - ```handlebars - - Hello, {{who}}. - ``` - - ```handlebars - -

    My great app

    - {{render "navigation"}} - ``` - - ```html -

    My great app

    -
    - Hello, world. -
    - ``` - - Optionally you may provide a second argument: a property path - that will be bound to the `model` property of the controller. - If a `model` property path is specified, then a new instance of the - controller will be created and `{{render}}` can be used multiple times - with the same name. - - For example if you had this `author` template. - - ```handlebars -
    - Written by {{firstName}} {{lastName}}. - Total Posts: {{postCount}} -
    - ``` - - You could render it inside the `post` template using the `render` helper. - - ```handlebars -
    -

    {{title}}

    -
    {{body}}
    - {{render "author" author}} -
    - ``` - - @method render - @for Ember.Templates.helpers - @param {String} name - @param {Object?} context - @param {Hash} options - @return {String} HTML string - @public - */ - - var RenderSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(RenderSyntax, _StatementSyntax); - - RenderSyntax.create = function create(environment, args, symbolTable) { - return new this(environment, args, symbolTable); - }; - - function RenderSyntax(environment, args, symbolTable) { - babelHelpers.classCallCheck(this, RenderSyntax); - - _StatementSyntax.call(this); - this.definitionArgs = args; - this.definition = makeComponentDefinition; - this.args = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(1, 2)); - this.symbolTable = symbolTable; - this.shadow = null; - } - - RenderSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return RenderSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.RenderSyntax = RenderSyntax; - - var AbstractRenderManager = (function () { - function AbstractRenderManager() { - babelHelpers.classCallCheck(this, AbstractRenderManager); - } - - AbstractRenderManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - /* abstract create(environment, definition, args, dynamicScope); */ - - AbstractRenderManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, definition.template); - }; - - AbstractRenderManager.prototype.getSelf = function getSelf(_ref) { - var controller = _ref.controller; - - return new _emberGlimmerUtilsReferences.RootReference(controller); - }; - - AbstractRenderManager.prototype.getTag = function getTag() { - return null; - }; - - AbstractRenderManager.prototype.getDestructor = function getDestructor() { - return null; - }; - - AbstractRenderManager.prototype.didCreateElement = function didCreateElement() {}; - - AbstractRenderManager.prototype.didRenderLayout = function didRenderLayout() {}; - - AbstractRenderManager.prototype.didCreate = function didCreate() {}; - - AbstractRenderManager.prototype.update = function update() {}; - - AbstractRenderManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - - AbstractRenderManager.prototype.didUpdate = function didUpdate() {}; - - return AbstractRenderManager; - })(); - - var SingletonRenderManager = (function (_AbstractRenderManager) { - babelHelpers.inherits(SingletonRenderManager, _AbstractRenderManager); - - function SingletonRenderManager() { - babelHelpers.classCallCheck(this, SingletonRenderManager); - - _AbstractRenderManager.apply(this, arguments); - } - - SingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var name = definition.name; - var env = definition.env; - - var controller = env.owner.lookup('controller:' + name) || _emberRouting.generateController(env.owner, name); - - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); - } - - return { controller: controller }; - }; - - return SingletonRenderManager; - })(AbstractRenderManager); - - var SINGLETON_RENDER_MANAGER = new SingletonRenderManager(); - - var NonSingletonRenderManager = (function (_AbstractRenderManager2) { - babelHelpers.inherits(NonSingletonRenderManager, _AbstractRenderManager2); - - function NonSingletonRenderManager() { - babelHelpers.classCallCheck(this, NonSingletonRenderManager); - - _AbstractRenderManager2.apply(this, arguments); - } - - NonSingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var name = definition.name; - var env = definition.env; - - var modelRef = args.positional.at(0); - - var factory = env.owner._lookupFactory('controller:' + name) || _emberRouting.generateControllerFactory(env.owner, name); - var controller = factory.create({ model: modelRef.value() }); - - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); - } - - return { controller: controller }; - }; - - NonSingletonRenderManager.prototype.update = function update(_ref2, args, dynamicScope) { - var controller = _ref2.controller; - - controller.set('model', args.positional.at(0).value()); - }; - - NonSingletonRenderManager.prototype.getDestructor = function getDestructor(_ref3) { - var controller = _ref3.controller; - - return controller; - }; - - return NonSingletonRenderManager; - })(AbstractRenderManager); - - var NON_SINGLETON_RENDER_MANAGER = new NonSingletonRenderManager(); - - var RenderDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(RenderDefinition, _ComponentDefinition); - - function RenderDefinition(name, template, env, manager) { - babelHelpers.classCallCheck(this, RenderDefinition); - - _ComponentDefinition.call(this, 'render', manager, null); - - this.name = name; - this.template = template; - this.env = env; - } - - return RenderDefinition; - })(_glimmerRuntime.ComponentDefinition); -}); -enifed('ember-glimmer/template', ['exports', 'ember-utils', 'glimmer-runtime'], function (exports, _emberUtils, _glimmerRuntime) { - 'use strict'; - - exports.default = template; - - function template(json) { - var factory = _glimmerRuntime.templateFactory(json); - - return { - id: factory.id, - meta: factory.meta, - create: function (props) { - return factory.create(props.env, { owner: props[_emberUtils.OWNER] }); - } - }; - } -}); -enifed("ember-glimmer/template_registry", ["exports"], function (exports) { - // STATE within a module is frowned apon, this exists - // to support Ember.TEMPLATES but shield ember internals from this legacy - // global API. - "use strict"; - - exports.setTemplates = setTemplates; - exports.getTemplates = getTemplates; - exports.getTemplate = getTemplate; - exports.hasTemplate = hasTemplate; - exports.setTemplate = setTemplate; - var TEMPLATES = {}; - - function setTemplates(templates) { - TEMPLATES = templates; - } - - function getTemplates() { - return TEMPLATES; - } - - function getTemplate(name) { - if (TEMPLATES.hasOwnProperty(name)) { - return TEMPLATES[name]; - } - } - - function hasTemplate(name) { - return TEMPLATES.hasOwnProperty(name); - } - - function setTemplate(name, template) { - return TEMPLATES[name] = template; - } -}); -enifed("ember-glimmer/templates/component", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "ZoGfVsSJ", "block": "{\"statements\":[[\"yield\",\"default\"]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/component.hbs" } }); -}); -enifed("ember-glimmer/templates/empty", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "qEHL4OLi", "block": "{\"statements\":[],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/empty.hbs" } }); -}); -enifed("ember-glimmer/templates/link-to", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "Ca7iQMR7", "block": "{\"statements\":[[\"block\",[\"if\"],[[\"get\",[\"linkTitle\"]]],null,1,0]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"blocks\":[{\"statements\":[[\"yield\",\"default\"]],\"locals\":[]},{\"statements\":[[\"append\",[\"unknown\",[\"linkTitle\"]],false]],\"locals\":[]}],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/link-to.hbs" } }); -}); -enifed("ember-glimmer/templates/outlet", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "sYQo9vi/", "block": "{\"statements\":[[\"append\",[\"unknown\",[\"outlet\"]],false]],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/outlet.hbs" } }); -}); -enifed("ember-glimmer/templates/root", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "Eaf3RPY3", "block": "{\"statements\":[[\"append\",[\"helper\",[\"component\"],[[\"get\",[null]]],null],false]],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/root.hbs" } }); -}); -enifed('ember-glimmer/utils/bindings', ['exports', 'glimmer-reference', 'glimmer-runtime', 'ember-metal', 'ember-runtime', 'ember-glimmer/component', 'ember-glimmer/utils/string'], function (exports, _glimmerReference, _glimmerRuntime, _emberMetal, _emberRuntime, _emberGlimmerComponent, _emberGlimmerUtilsString) { - 'use strict'; - - exports.wrapComponentClassAttribute = wrapComponentClassAttribute; - - function referenceForKey(component, key) { - return component[_emberGlimmerComponent.ROOT_REF].get(key); - } - - function referenceForParts(component, parts) { - var isAttrs = parts[0] === 'attrs'; - - // TODO deprecate this - if (isAttrs) { - parts.shift(); - - if (parts.length === 1) { - return referenceForKey(component, parts[0]); - } - } - - return _glimmerReference.referenceFromParts(component[_emberGlimmerComponent.ROOT_REF], parts); - } - - // TODO we should probably do this transform at build time - - function wrapComponentClassAttribute(args) { - var named = args.named; - - var index = named.keys.indexOf('class'); - - if (index !== -1) { - var _named$values$index = named.values[index]; - var ref = _named$values$index.ref; - var type = _named$values$index.type; - - if (type === 'get') { - var propName = ref.parts[ref.parts.length - 1]; - named.values[index] = _glimmerRuntime.HelperSyntax.fromSpec(['helper', ['-class'], [['get', ref.parts], propName], null]); - } - } - - return args; - } - - var AttributeBinding = { - parse: function (microsyntax) { - var colonIndex = microsyntax.indexOf(':'); - - if (colonIndex === -1) { - _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', microsyntax !== 'class'); - return [microsyntax, microsyntax, true]; - } else { - var prop = microsyntax.substring(0, colonIndex); - var attribute = microsyntax.substring(colonIndex + 1); - - _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attribute !== 'class'); - - return [prop, attribute, false]; - } - }, - - install: function (element, component, parsed, operations) { - var prop = parsed[0]; - var attribute = parsed[1]; - var isSimple = parsed[2]; - - if (attribute === 'id') { - var elementId = _emberMetal.get(component, prop); - if (elementId === undefined || elementId === null) { - elementId = component.elementId; - } - operations.addStaticAttribute(element, 'id', elementId); - return; - } - - var isPath = prop.indexOf('.') > -1; - var reference = isPath ? referenceForParts(component, prop.split('.')) : referenceForKey(component, prop); - - _emberMetal.assert('Illegal attributeBinding: \'' + prop + '\' is not a valid attribute name.', !(isSimple && isPath)); - - if (attribute === 'style') { - reference = new StyleBindingReference(reference, referenceForKey(component, 'isVisible')); - } - - operations.addDynamicAttribute(element, attribute, reference); - } - }; - - exports.AttributeBinding = AttributeBinding; - var DISPLAY_NONE = 'display: none;'; - var SAFE_DISPLAY_NONE = _emberGlimmerUtilsString.htmlSafe(DISPLAY_NONE); - - var StyleBindingReference = (function (_CachedReference) { - babelHelpers.inherits(StyleBindingReference, _CachedReference); - - function StyleBindingReference(inner, isVisible) { - babelHelpers.classCallCheck(this, StyleBindingReference); - - _CachedReference.call(this); - - this.tag = _glimmerReference.combine([inner.tag, isVisible.tag]); - this.inner = inner; - this.isVisible = isVisible; - } - - StyleBindingReference.prototype.compute = function compute() { - var value = this.inner.value(); - var isVisible = this.isVisible.value(); - - if (isVisible !== false) { - return value; - } else if (!value && value !== 0) { - return SAFE_DISPLAY_NONE; - } else { - var style = value + ' ' + DISPLAY_NONE; - return _emberGlimmerUtilsString.isHTMLSafe(value) ? _emberGlimmerUtilsString.htmlSafe(style) : style; - } - }; - - return StyleBindingReference; - })(_glimmerReference.CachedReference); - - var IsVisibleBinding = { - install: function (element, component, operations) { - operations.addDynamicAttribute(element, 'style', _glimmerReference.map(referenceForKey(component, 'isVisible'), this.mapStyleValue)); - }, - - mapStyleValue: function (isVisible) { - return isVisible === false ? SAFE_DISPLAY_NONE : null; - } - }; - - exports.IsVisibleBinding = IsVisibleBinding; - var ClassNameBinding = { - install: function (element, component, microsyntax, operations) { - var _microsyntax$split = microsyntax.split(':'); - - var prop = _microsyntax$split[0]; - var truthy = _microsyntax$split[1]; - var falsy = _microsyntax$split[2]; - - var isStatic = prop === ''; - - if (isStatic) { - operations.addStaticAttribute(element, 'class', truthy); - } else { - var isPath = prop.indexOf('.') > -1; - var parts = isPath && prop.split('.'); - var value = isPath ? referenceForParts(component, parts) : referenceForKey(component, prop); - var ref = undefined; - - if (truthy === undefined) { - ref = new SimpleClassNameBindingReference(value, isPath ? parts[parts.length - 1] : prop); - } else { - ref = new ColonClassNameBindingReference(value, truthy, falsy); - } - - operations.addDynamicAttribute(element, 'class', ref); - } - } - }; - - exports.ClassNameBinding = ClassNameBinding; - - var SimpleClassNameBindingReference = (function (_CachedReference2) { - babelHelpers.inherits(SimpleClassNameBindingReference, _CachedReference2); - - function SimpleClassNameBindingReference(inner, path) { - babelHelpers.classCallCheck(this, SimpleClassNameBindingReference); - - _CachedReference2.call(this); - - this.tag = inner.tag; - this.inner = inner; - this.path = path; - this.dasherizedPath = null; - } - - SimpleClassNameBindingReference.prototype.compute = function compute() { - var value = this.inner.value(); - - if (value === true) { - var path = this.path; - var dasherizedPath = this.dasherizedPath; - - return dasherizedPath || (this.dasherizedPath = _emberRuntime.String.dasherize(path)); - } else if (value || value === 0) { - return value; - } else { - return null; - } - }; - - return SimpleClassNameBindingReference; - })(_glimmerReference.CachedReference); - - var ColonClassNameBindingReference = (function (_CachedReference3) { - babelHelpers.inherits(ColonClassNameBindingReference, _CachedReference3); - - function ColonClassNameBindingReference(inner, truthy, falsy) { - babelHelpers.classCallCheck(this, ColonClassNameBindingReference); - - _CachedReference3.call(this); - - this.tag = inner.tag; - this.inner = inner; - this.truthy = truthy || null; - this.falsy = falsy || null; - } - - ColonClassNameBindingReference.prototype.compute = function compute() { - var inner = this.inner; - var truthy = this.truthy; - var falsy = this.falsy; - - return inner.value() ? truthy : falsy; - }; - - return ColonClassNameBindingReference; - })(_glimmerReference.CachedReference); -}); -enifed('ember-glimmer/utils/iterable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', 'glimmer-reference'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerReference) { - 'use strict'; - - exports.default = iterableFor; - - var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; - - function iterableFor(ref, keyPath) { - if (_emberGlimmerHelpersEachIn.isEachIn(ref)) { - return new EachInIterable(ref, keyForEachIn(keyPath)); - } else { - return new ArrayIterable(ref, keyForArray(keyPath)); - } - } - - function keyForEachIn(keyPath) { - switch (keyPath) { - case '@index': - case undefined: - case null: - return index; - case '@identity': - return identity; - default: - return function (item) { - return _emberMetal.get(item, keyPath); - }; - } - } - - function keyForArray(keyPath) { - switch (keyPath) { - case '@index': - return index; - case '@identity': - case undefined: - case null: - return identity; - default: - return function (item) { - return _emberMetal.get(item, keyPath); - }; - } - } - - function index(item, index) { - return String(index); - } - - function identity(item) { - switch (typeof item) { - case 'string': - case 'number': - return String(item); - default: - return _emberUtils.guidFor(item); - } - } - - function ensureUniqueKey(seen, key) { - var seenCount = seen[key]; - - if (seenCount) { - seen[key]++; - return '' + key + ITERATOR_KEY_GUID + seenCount; - } else { - seen[key] = 1; - } - - return key; - } - - var ArrayIterator = (function () { - function ArrayIterator(array, keyFor) { - babelHelpers.classCallCheck(this, ArrayIterator); - - this.array = array; - this.length = array.length; - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } - - ArrayIterator.prototype.isEmpty = function isEmpty() { - return false; - }; - - ArrayIterator.prototype.next = function next() { - var array = this.array; - var length = this.length; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; - - if (position >= length) { - return null; - } - - var value = array[position]; - var memo = position; - var key = ensureUniqueKey(seen, keyFor(value, memo)); - - this.position++; - - return { key: key, value: value, memo: memo }; - }; - - return ArrayIterator; - })(); - - var EmberArrayIterator = (function () { - function EmberArrayIterator(array, keyFor) { - babelHelpers.classCallCheck(this, EmberArrayIterator); - - this.array = array; - this.length = _emberMetal.get(array, 'length'); - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } - - EmberArrayIterator.prototype.isEmpty = function isEmpty() { - return this.length === 0; - }; - - EmberArrayIterator.prototype.next = function next() { - var array = this.array; - var length = this.length; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; - - if (position >= length) { - return null; - } - - var value = _emberRuntime.objectAt(array, position); - var memo = position; - var key = ensureUniqueKey(seen, keyFor(value, memo)); - - this.position++; - - return { key: key, value: value, memo: memo }; - }; - - return EmberArrayIterator; - })(); - - var ObjectKeysIterator = (function () { - function ObjectKeysIterator(keys, values, keyFor) { - babelHelpers.classCallCheck(this, ObjectKeysIterator); - - this.keys = keys; - this.values = values; - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } - - ObjectKeysIterator.prototype.isEmpty = function isEmpty() { - return this.keys.length === 0; - }; - - ObjectKeysIterator.prototype.next = function next() { - var keys = this.keys; - var values = this.values; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; - - if (position >= keys.length) { - return null; - } - - var value = values[position]; - var memo = keys[position]; - var key = ensureUniqueKey(seen, keyFor(value, memo)); - - this.position++; - - return { key: key, value: value, memo: memo }; - }; - - return ObjectKeysIterator; - })(); - - var EmptyIterator = (function () { - function EmptyIterator() { - babelHelpers.classCallCheck(this, EmptyIterator); - } - - EmptyIterator.prototype.isEmpty = function isEmpty() { - return true; - }; - - EmptyIterator.prototype.next = function next() { - throw new Error('Cannot call next() on an empty iterator'); - }; - - return EmptyIterator; - })(); - - var EMPTY_ITERATOR = new EmptyIterator(); - - var EachInIterable = (function () { - function EachInIterable(ref, keyFor) { - babelHelpers.classCallCheck(this, EachInIterable); - - this.ref = ref; - this.keyFor = keyFor; - - var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - - this.tag = _glimmerReference.combine([ref.tag, valueTag]); - } - - EachInIterable.prototype.iterate = function iterate() { - var ref = this.ref; - var keyFor = this.keyFor; - var valueTag = this.valueTag; - - var iterable = ref.value(); - - valueTag.update(_emberMetal.tagFor(iterable)); - - if (_emberMetal.isProxy(iterable)) { - iterable = _emberMetal.get(iterable, 'content'); - } - - var typeofIterable = typeof iterable; - - if (iterable && (typeofIterable === 'object' || typeofIterable === 'function')) { - var keys = Object.keys(iterable); - var values = keys.map(function (key) { - return iterable[key]; - }); - return keys.length > 0 ? new ObjectKeysIterator(keys, values, keyFor) : EMPTY_ITERATOR; - } else { - return EMPTY_ITERATOR; - } - }; - - // {{each-in}} yields |key value| instead of |value key|, so the memo and - // value are flipped - - EachInIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); - }; - - EachInIterable.prototype.updateValueReference = function updateValueReference(reference, item) { - reference.update(item.memo); - }; - - EachInIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); - }; - - EachInIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { - reference.update(item.value); - }; - - return EachInIterable; - })(); - - var ArrayIterable = (function () { - function ArrayIterable(ref, keyFor) { - babelHelpers.classCallCheck(this, ArrayIterable); - - this.ref = ref; - this.keyFor = keyFor; - - var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - - this.tag = _glimmerReference.combine([ref.tag, valueTag]); - } - - ArrayIterable.prototype.iterate = function iterate() { - var ref = this.ref; - var keyFor = this.keyFor; - var valueTag = this.valueTag; - - var iterable = ref.value(); - - valueTag.update(_emberMetal.tagForProperty(iterable, '[]')); - - if (!iterable || typeof iterable !== 'object') { - return EMPTY_ITERATOR; - } - - if (Array.isArray(iterable)) { - return iterable.length > 0 ? new ArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; - } else if (_emberRuntime.isEmberArray(iterable)) { - return _emberMetal.get(iterable, 'length') > 0 ? new EmberArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; - } else if (typeof iterable.forEach === 'function') { - var _ret = (function () { - var array = []; - iterable.forEach(function (item) { - array.push(item); - }); - return { - v: array.length > 0 ? new ArrayIterator(array, keyFor) : EMPTY_ITERATOR - }; - })(); - - if (typeof _ret === 'object') return _ret.v; - } else { - return EMPTY_ITERATOR; - } - }; - - ArrayIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); - }; - - ArrayIterable.prototype.updateValueReference = function updateValueReference(reference, item) { - reference.update(item.value); - }; - - ArrayIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); - }; - - ArrayIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { - reference.update(item.memo); - }; - - return ArrayIterable; - })(); -}); -enifed('ember-glimmer/utils/process-args', ['exports', 'ember-utils', 'glimmer-reference', 'ember-glimmer/component', 'ember-glimmer/utils/references', 'ember-views', 'ember-glimmer/helpers/action', 'glimmer-runtime'], function (exports, _emberUtils, _glimmerReference, _emberGlimmerComponent, _emberGlimmerUtilsReferences, _emberViews, _emberGlimmerHelpersAction, _glimmerRuntime) { - 'use strict'; - - exports.gatherArgs = gatherArgs; - - // Maps all variants of positional and dynamically scoped arguments - // into the named arguments. Input `args` and return value are both - // `EvaluatedArgs`. - - function gatherArgs(args, definition) { - var namedMap = gatherNamedMap(args, definition); - var positionalValues = gatherPositionalValues(args, definition); - return mergeArgs(namedMap, positionalValues, args.blocks, definition.ComponentClass); - } - - function gatherNamedMap(args, definition) { - var namedMap = args.named.map; - if (definition.args) { - return _emberUtils.assign({}, definition.args.named.map, namedMap); - } else { - return namedMap; - } - } - - function gatherPositionalValues(args, definition) { - var positionalValues = args.positional.values; - if (definition.args) { - var oldPositional = definition.args.positional.values; - var newPositional = []; - newPositional.push.apply(newPositional, oldPositional); - newPositional.splice.apply(newPositional, [0, positionalValues.length].concat(positionalValues)); - return newPositional; - } else { - return positionalValues; - } - } - - function mergeArgs(namedMap, positionalValues, blocks, componentClass) { - var positionalParamsDefinition = componentClass.positionalParams; - - if (positionalParamsDefinition && positionalParamsDefinition.length > 0 && positionalValues.length > 0) { - if (typeof positionalParamsDefinition === 'string') { - namedMap = mergeRestArg(namedMap, positionalValues, positionalParamsDefinition); - } else { - namedMap = mergePositionalParams(namedMap, positionalValues, positionalParamsDefinition); - } - } - return _glimmerRuntime.EvaluatedArgs.named(namedMap, blocks); - } - - var EMPTY_ARGS = { - tag: _glimmerReference.CONSTANT_TAG, - value: function () { - var _props; - - return { attrs: {}, props: (_props = { attrs: {} }, _props[_emberGlimmerComponent.ARGS] = {}, _props) }; - } - }; - - // ComponentArgs takes EvaluatedNamedArgs and converts them into the - // inputs needed by CurlyComponents (attrs and props, with mutable - // cells, etc). - - var ComponentArgs = (function () { - ComponentArgs.create = function create(args) { - if (args.named.keys.length === 0) { - return EMPTY_ARGS; - } else { - return new ComponentArgs(args.named); - } - }; - - function ComponentArgs(namedArgs) { - babelHelpers.classCallCheck(this, ComponentArgs); - - this.tag = namedArgs.tag; - this.namedArgs = namedArgs; - } - - ComponentArgs.prototype.value = function value() { - var namedArgs = this.namedArgs; - - var keys = namedArgs.keys; - var attrs = namedArgs.value(); - var props = new _emberUtils.EmptyObject(); - var args = new _emberUtils.EmptyObject(); - - props[_emberGlimmerComponent.ARGS] = args; - - for (var i = 0, l = keys.length; i < l; i++) { - var _name = keys[i]; - var ref = namedArgs.get(_name); - var value = attrs[_name]; - - if (typeof value === 'function' && value[_emberGlimmerHelpersAction.ACTION]) { - attrs[_name] = value; - } else if (ref[_emberGlimmerUtilsReferences.UPDATE]) { - attrs[_name] = new MutableCell(ref, value); - } - - args[_name] = ref; - props[_name] = value; - } - - props.attrs = attrs; - - return { attrs: attrs, props: props }; - }; - - return ComponentArgs; - })(); - - exports.ComponentArgs = ComponentArgs; - - function mergeRestArg(namedMap, positionalValues, restArgName) { - var mergedNamed = _emberUtils.assign({}, namedMap); - mergedNamed[restArgName] = _glimmerRuntime.EvaluatedPositionalArgs.create(positionalValues); - return mergedNamed; - } - - function mergePositionalParams(namedMap, values, positionalParamNames) { - var mergedNamed = _emberUtils.assign({}, namedMap); - var length = Math.min(values.length, positionalParamNames.length); - for (var i = 0; i < length; i++) { - var _name2 = positionalParamNames[i]; - mergedNamed[_name2] = values[i]; - } - return mergedNamed; - } - - var REF = _emberUtils.symbol('REF'); - - var MutableCell = (function () { - function MutableCell(ref, value) { - babelHelpers.classCallCheck(this, MutableCell); - - this[_emberViews.MUTABLE_CELL] = true; - this[REF] = ref; - this.value = value; - } - - MutableCell.prototype.update = function update(val) { - this[REF][_emberGlimmerUtilsReferences.UPDATE](val); - }; - - return MutableCell; - })(); -}); -enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal', 'glimmer-reference', 'glimmer-runtime', 'ember-glimmer/utils/to-bool', 'ember-glimmer/helper'], function (exports, _emberUtils, _emberMetal, _glimmerReference, _glimmerRuntime, _emberGlimmerUtilsToBool, _emberGlimmerHelper) { - 'use strict'; - - var UPDATE = _emberUtils.symbol('UPDATE'); - - exports.UPDATE = UPDATE; - exports.NULL_REFERENCE = _glimmerRuntime.NULL_REFERENCE; - exports.UNDEFINED_REFERENCE = _glimmerRuntime.UNDEFINED_REFERENCE; - - // @abstract - // @implements PathReference - - var EmberPathReference = (function () { - function EmberPathReference() { - babelHelpers.classCallCheck(this, EmberPathReference); - } - - // @abstract - - // @abstract get tag() - // @abstract value() - - EmberPathReference.prototype.get = function get(key) { - return PropertyReference.create(this, key); - }; - - return EmberPathReference; - })(); - - var CachedReference = (function (_EmberPathReference) { - babelHelpers.inherits(CachedReference, _EmberPathReference); - - function CachedReference() { - babelHelpers.classCallCheck(this, CachedReference); - - _EmberPathReference.call(this); - this._lastRevision = null; - this._lastValue = null; - } - - // @implements PathReference - - CachedReference.prototype.value = function value() { - var tag = this.tag; - var _lastRevision = this._lastRevision; - var _lastValue = this._lastValue; - - if (!_lastRevision || !tag.validate(_lastRevision)) { - _lastValue = this._lastValue = this.compute(); - this._lastRevision = tag.value(); - } - - return _lastValue; - }; - - // @abstract compute() - return CachedReference; - })(EmberPathReference); - - exports.CachedReference = CachedReference; - - var RootReference = (function (_ConstReference) { - babelHelpers.inherits(RootReference, _ConstReference); - - function RootReference(value) { - babelHelpers.classCallCheck(this, RootReference); - - _ConstReference.call(this, value); - this.children = new _emberUtils.EmptyObject(); - } - - RootReference.prototype.get = function get(propertyKey) { - var ref = this.children[propertyKey]; - - if (!ref) { - ref = this.children[propertyKey] = new RootPropertyReference(this.inner, propertyKey); - } - - return ref; - }; - - return RootReference; - })(_glimmerReference.ConstReference); - - exports.RootReference = RootReference; - - var TwoWayFlushDetectionTag = undefined; - - if (true || false) { - TwoWayFlushDetectionTag = (function () { - function _class(tag, key, ref) { - babelHelpers.classCallCheck(this, _class); - - this.tag = tag; - this.parent = null; - this.key = key; - this.ref = ref; - } - - _class.prototype.value = function value() { - return this.tag.value(); - }; - - _class.prototype.validate = function validate(ticket) { - var parent = this.parent; - var key = this.key; - - var isValid = this.tag.validate(ticket); - - if (isValid && parent) { - _emberMetal.didRender(parent, key, this.ref); - } - - return isValid; - }; - - _class.prototype.didCompute = function didCompute(parent) { - this.parent = parent; - _emberMetal.didRender(parent, this.key, this.ref); - }; - - return _class; - })(); - } - - var PropertyReference = (function (_CachedReference) { - babelHelpers.inherits(PropertyReference, _CachedReference); - - function PropertyReference() { - babelHelpers.classCallCheck(this, PropertyReference); - - _CachedReference.apply(this, arguments); - } - - PropertyReference.create = function create(parentReference, propertyKey) { - if (_glimmerReference.isConst(parentReference)) { - return new RootPropertyReference(parentReference.value(), propertyKey); - } else { - return new NestedPropertyReference(parentReference, propertyKey); - } - }; - - PropertyReference.prototype.get = function get(key) { - return new NestedPropertyReference(this, key); - }; - - return PropertyReference; - })(CachedReference); - - exports.PropertyReference = PropertyReference; - - var RootPropertyReference = (function (_PropertyReference) { - babelHelpers.inherits(RootPropertyReference, _PropertyReference); - - function RootPropertyReference(parentValue, propertyKey) { - babelHelpers.classCallCheck(this, RootPropertyReference); - - _PropertyReference.call(this); - - this._parentValue = parentValue; - this._propertyKey = propertyKey; - - if (true || false) { - this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); - } else { - this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); - } - - if (true) { - _emberMetal.watchKey(parentValue, propertyKey); - } - } - - RootPropertyReference.prototype.compute = function compute() { - var _parentValue = this._parentValue; - var _propertyKey = this._propertyKey; - - if (true || false) { - this.tag.didCompute(_parentValue); - } - - return _emberMetal.get(_parentValue, _propertyKey); - }; - - RootPropertyReference.prototype[UPDATE] = function (value) { - _emberMetal.set(this._parentValue, this._propertyKey, value); - }; - - return RootPropertyReference; - })(PropertyReference); - - exports.RootPropertyReference = RootPropertyReference; - - var NestedPropertyReference = (function (_PropertyReference2) { - babelHelpers.inherits(NestedPropertyReference, _PropertyReference2); - - function NestedPropertyReference(parentReference, propertyKey) { - babelHelpers.classCallCheck(this, NestedPropertyReference); - - _PropertyReference2.call(this); - - var parentReferenceTag = parentReference.tag; - var parentObjectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - - this._parentReference = parentReference; - this._parentObjectTag = parentObjectTag; - this._propertyKey = propertyKey; - - if (true || false) { - var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); - this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); - } else { - this.tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); - } - } - - NestedPropertyReference.prototype.compute = function compute() { - var _parentReference = this._parentReference; - var _parentObjectTag = this._parentObjectTag; - var _propertyKey = this._propertyKey; - - var parentValue = _parentReference.value(); - - _parentObjectTag.update(_emberMetal.tagForProperty(parentValue, _propertyKey)); - - if (typeof parentValue === 'string' && _propertyKey === 'length') { - return parentValue.length; - } - - if (typeof parentValue === 'object' && parentValue) { - if (true) { - _emberMetal.watchKey(parentValue, _propertyKey); - } - - if (true || false) { - this.tag.didCompute(parentValue); - } - - return _emberMetal.get(parentValue, _propertyKey); - } else { - return undefined; - } - }; - - NestedPropertyReference.prototype[UPDATE] = function (value) { - var parent = this._parentReference.value(); - _emberMetal.set(parent, this._propertyKey, value); - }; - - return NestedPropertyReference; - })(PropertyReference); - - exports.NestedPropertyReference = NestedPropertyReference; - - var UpdatableReference = (function (_EmberPathReference2) { - babelHelpers.inherits(UpdatableReference, _EmberPathReference2); - - function UpdatableReference(value) { - babelHelpers.classCallCheck(this, UpdatableReference); - - _EmberPathReference2.call(this); - - this.tag = new _glimmerReference.DirtyableTag(); - this._value = value; - } - - UpdatableReference.prototype.value = function value() { - return this._value; - }; - - UpdatableReference.prototype.update = function update(value) { - var _value = this._value; - - if (value !== _value) { - this.tag.dirty(); - this._value = value; - } - }; - - return UpdatableReference; - })(EmberPathReference); - - exports.UpdatableReference = UpdatableReference; - - var UpdatablePrimitiveReference = (function (_UpdatableReference) { - babelHelpers.inherits(UpdatablePrimitiveReference, _UpdatableReference); - - function UpdatablePrimitiveReference() { - babelHelpers.classCallCheck(this, UpdatablePrimitiveReference); - - _UpdatableReference.apply(this, arguments); - } - - UpdatablePrimitiveReference.prototype.get = function get() { - return _glimmerRuntime.UNDEFINED_REFERENCE; - }; - - return UpdatablePrimitiveReference; - })(UpdatableReference); - - exports.UpdatablePrimitiveReference = UpdatablePrimitiveReference; - - var ConditionalReference = (function (_GlimmerConditionalReference) { - babelHelpers.inherits(ConditionalReference, _GlimmerConditionalReference); - - ConditionalReference.create = function create(reference) { - if (_glimmerReference.isConst(reference)) { - var value = reference.value(); - - if (_emberMetal.isProxy(value)) { - return new RootPropertyReference(value, 'isTruthy'); - } else { - return _glimmerRuntime.PrimitiveReference.create(_emberGlimmerUtilsToBool.default(value)); - } - } - - return new ConditionalReference(reference); - }; - - function ConditionalReference(reference) { - babelHelpers.classCallCheck(this, ConditionalReference); - - _GlimmerConditionalReference.call(this, reference); - - this.objectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([reference.tag, this.objectTag]); - } - - ConditionalReference.prototype.toBool = function toBool(predicate) { - if (_emberMetal.isProxy(predicate)) { - this.objectTag.update(_emberMetal.tagForProperty(predicate, 'isTruthy')); - return _emberMetal.get(predicate, 'isTruthy'); - } else { - this.objectTag.update(_emberMetal.tagFor(predicate)); - return _emberGlimmerUtilsToBool.default(predicate); - } - }; - - return ConditionalReference; - })(_glimmerRuntime.ConditionalReference); - - exports.ConditionalReference = ConditionalReference; - - var SimpleHelperReference = (function (_CachedReference2) { - babelHelpers.inherits(SimpleHelperReference, _CachedReference2); - - SimpleHelperReference.create = function create(helper, args) { - if (_glimmerReference.isConst(args)) { - var _ret = (function () { - var positional = args.positional; - var named = args.named; - - var positionalValue = positional.value(); - var namedValue = named.value(); - - _emberMetal.runInDebug(function () { - Object.freeze(positionalValue); - Object.freeze(namedValue); - }); - - var result = helper(positionalValue, namedValue); - - if (result === null) { - return { - v: _glimmerRuntime.NULL_REFERENCE - }; - } else if (result === undefined) { - return { - v: _glimmerRuntime.UNDEFINED_REFERENCE - }; - } else if (typeof result === 'object') { - return { - v: new RootReference(result) - }; - } else { - return { - v: _glimmerRuntime.PrimitiveReference.create(result) - }; - } - })(); - - if (typeof _ret === 'object') return _ret.v; - } else { - return new SimpleHelperReference(helper, args); - } - }; - - function SimpleHelperReference(helper, args) { - babelHelpers.classCallCheck(this, SimpleHelperReference); - - _CachedReference2.call(this); - - this.tag = args.tag; - this.helper = helper; - this.args = args; - } - - SimpleHelperReference.prototype.compute = function compute() { - var helper = this.helper; - var _args = this.args; - var positional = _args.positional; - var named = _args.named; - - var positionalValue = positional.value(); - var namedValue = named.value(); - - _emberMetal.runInDebug(function () { - Object.freeze(positionalValue); - Object.freeze(namedValue); - }); - - return helper(positionalValue, namedValue); - }; - - return SimpleHelperReference; - })(CachedReference); - - exports.SimpleHelperReference = SimpleHelperReference; - - var ClassBasedHelperReference = (function (_CachedReference3) { - babelHelpers.inherits(ClassBasedHelperReference, _CachedReference3); - - ClassBasedHelperReference.create = function create(helperClass, vm, args) { - var instance = helperClass.create(); - vm.newDestroyable(instance); - return new ClassBasedHelperReference(instance, args); - }; - - function ClassBasedHelperReference(instance, args) { - babelHelpers.classCallCheck(this, ClassBasedHelperReference); - - _CachedReference3.call(this); - - this.tag = _glimmerReference.combine([instance[_emberGlimmerHelper.RECOMPUTE_TAG], args.tag]); - this.instance = instance; - this.args = args; - } - - ClassBasedHelperReference.prototype.compute = function compute() { - var instance = this.instance; - var _args2 = this.args; - var positional = _args2.positional; - var named = _args2.named; - - var positionalValue = positional.value(); - var namedValue = named.value(); - - _emberMetal.runInDebug(function () { - Object.freeze(positionalValue); - Object.freeze(namedValue); - }); - - return instance.compute(positionalValue, namedValue); - }; - - return ClassBasedHelperReference; - })(CachedReference); - - exports.ClassBasedHelperReference = ClassBasedHelperReference; - - var InternalHelperReference = (function (_CachedReference4) { - babelHelpers.inherits(InternalHelperReference, _CachedReference4); - - function InternalHelperReference(helper, args) { - babelHelpers.classCallCheck(this, InternalHelperReference); - - _CachedReference4.call(this); - - this.tag = args.tag; - this.helper = helper; - this.args = args; - } - - // @implements PathReference - - InternalHelperReference.prototype.compute = function compute() { - var helper = this.helper; - var args = this.args; - - return helper(args); - }; - - return InternalHelperReference; - })(CachedReference); - - exports.InternalHelperReference = InternalHelperReference; - - var UnboundReference = (function (_ConstReference2) { - babelHelpers.inherits(UnboundReference, _ConstReference2); - - function UnboundReference() { - babelHelpers.classCallCheck(this, UnboundReference); - - _ConstReference2.apply(this, arguments); - } - - UnboundReference.create = function create(value) { - if (value === null) { - return _glimmerRuntime.NULL_REFERENCE; - } else if (value === undefined) { - return _glimmerRuntime.UNDEFINED_REFERENCE; - } else if (typeof value === 'object') { - return new UnboundReference(value); - } else { - return _glimmerRuntime.PrimitiveReference.create(value); - } - }; - - UnboundReference.prototype.get = function get(key) { - return new UnboundReference(_emberMetal.get(this.inner, key)); - }; - - return UnboundReference; - })(_glimmerReference.ConstReference); - - exports.UnboundReference = UnboundReference; -}); -enifed('ember-glimmer/utils/string', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - - 'use strict'; - - exports.getSafeString = getSafeString; - exports.escapeExpression = escapeExpression; - exports.htmlSafe = htmlSafe; - exports.isHTMLSafe = isHTMLSafe; - - var SafeString = (function () { - function SafeString(string) { - babelHelpers.classCallCheck(this, SafeString); - - this.string = string; - } - - SafeString.prototype.toString = function toString() { - return '' + this.string; - }; - - SafeString.prototype.toHTML = function toHTML() { - return this.toString(); - }; - - return SafeString; - })(); - - exports.SafeString = SafeString; - - function getSafeString() { - _emberMetal.deprecate('Ember.Handlebars.SafeString is deprecated in favor of Ember.String.htmlSafe', !true, { - id: 'ember-htmlbars.ember-handlebars-safestring', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_use-ember-string-htmlsafe-over-ember-handlebars-safestring' - }); - - return SafeString; - } - - var escape = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - // jscs:disable - "'": ''', - // jscs:enable - '`': '`', - '=': '=' - }; - - var possible = /[&<>"'`=]/; - var badChars = /[&<>"'`=]/g; - - function escapeChar(chr) { - return escape[chr]; - } - - function escapeExpression(string) { - if (typeof string !== 'string') { - // don't escape SafeStrings, since they're already safe - if (string && string.toHTML) { - return string.toHTML(); - } else if (string == null) { - return ''; - } else if (!string) { - return string + ''; - } - - // Force a string conversion as this will be done by the append regardless and - // the regex test will do this transparently behind the scenes, causing issues if - // an object's to string has escaped characters in it. - string = '' + string; - } - - if (!possible.test(string)) { - return string; - } - return string.replace(badChars, escapeChar); - } - - /** - Mark a string as safe for unescaped output with Ember templates. If you - return HTML from a helper, use this function to - ensure Ember's rendering layer does not escape the HTML. - - ```javascript - Ember.String.htmlSafe('
    someString
    ') - ``` - - @method htmlSafe - @for Ember.String - @static - @return {Handlebars.SafeString} A string that will not be HTML escaped by Handlebars. - @public - */ - - function htmlSafe(str) { - if (str === null || str === undefined) { - str = ''; - } else if (typeof str !== 'string') { - str = '' + str; - } - return new SafeString(str); - } - - /** - Detects if a string was decorated using `Ember.String.htmlSafe`. - - ```javascript - var plainString = 'plain string', - safeString = Ember.String.htmlSafe('
    someValue
    '); - - Ember.String.isHTMLSafe(plainString); // false - Ember.String.isHTMLSafe(safeString); // true - ``` - - @method isHTMLSafe - @for Ember.String - @static - @return {Boolean} `true` if the string was decorated with `htmlSafe`, `false` otherwise. - @public - */ - - function isHTMLSafe(str) { - return str && typeof str.toHTML === 'function'; - } -}); -enifed('ember-glimmer/utils/to-bool', ['exports', 'ember-runtime', 'ember-metal'], function (exports, _emberRuntime, _emberMetal) { - 'use strict'; - - exports.default = toBool; - - function toBool(predicate) { - if (!predicate) { - return false; - } - - if (predicate === true) { - return true; - } - - if (_emberRuntime.isArray(predicate)) { - return _emberMetal.get(predicate, 'length') !== 0; - } - - return true; - } -}); -enifed('ember-glimmer/views/outlet', ['exports', 'ember-utils', 'glimmer-reference', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _glimmerReference, _emberEnvironment, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - var OutletStateReference = (function () { - function OutletStateReference(outletView) { - babelHelpers.classCallCheck(this, OutletStateReference); - - this.outletView = outletView; - this.tag = outletView._tag; - } - - // So this is a relic of the past that SHOULD go away - // in 3.0. Preferably it is deprecated in the release that - // follows the Glimmer release. - - OutletStateReference.prototype.get = function get(key) { - return new ChildOutletStateReference(this, key); - }; - - OutletStateReference.prototype.value = function value() { - return this.outletView.outletState; - }; - - OutletStateReference.prototype.getOrphan = function getOrphan(name) { - return new OrphanedOutletStateReference(this, name); - }; - - OutletStateReference.prototype.update = function update(state) { - this.outletView.setOutletState(state); - }; - - return OutletStateReference; - })(); - - var OrphanedOutletStateReference = (function (_OutletStateReference) { - babelHelpers.inherits(OrphanedOutletStateReference, _OutletStateReference); - - function OrphanedOutletStateReference(root, name) { - babelHelpers.classCallCheck(this, OrphanedOutletStateReference); - - _OutletStateReference.call(this, root.outletView); - this.root = root; - this.name = name; - } - - OrphanedOutletStateReference.prototype.value = function value() { - var rootState = this.root.value(); - - var orphans = rootState.outlets.main.outlets.__ember_orphans__; - - if (!orphans) { - return null; - } - - var matched = orphans.outlets[this.name]; - - if (!matched) { - return null; - } - - var state = new _emberUtils.EmptyObject(); - state[matched.render.outlet] = matched; - matched.wasUsed = true; - return { outlets: state }; - }; - - return OrphanedOutletStateReference; - })(OutletStateReference); - - var ChildOutletStateReference = (function () { - function ChildOutletStateReference(parent, key) { - babelHelpers.classCallCheck(this, ChildOutletStateReference); - - this.parent = parent; - this.key = key; - this.tag = parent.tag; - } - - ChildOutletStateReference.prototype.get = function get(key) { - return new ChildOutletStateReference(this, key); - }; - - ChildOutletStateReference.prototype.value = function value() { - return this.parent.value()[this.key]; - }; - - return ChildOutletStateReference; - })(); - - var OutletView = (function () { - OutletView.extend = function extend(injections) { - return (function (_OutletView) { - babelHelpers.inherits(_class, _OutletView); - - function _class() { - babelHelpers.classCallCheck(this, _class); - - _OutletView.apply(this, arguments); - } - - _class.create = function create(options) { - if (options) { - return _OutletView.create.call(this, _emberUtils.assign({}, injections, options)); - } else { - return _OutletView.create.call(this, injections); - } - }; - - return _class; - })(OutletView); - }; - - OutletView.reopenClass = function reopenClass(injections) { - _emberUtils.assign(this, injections); - }; - - OutletView.create = function create(options) { - var _environment = options._environment; - var renderer = options.renderer; - var template = options.template; - - var owner = options[_emberUtils.OWNER]; - return new OutletView(_environment, renderer, owner, template); - }; - - function OutletView(_environment, renderer, owner, template) { - babelHelpers.classCallCheck(this, OutletView); - - this._environment = _environment; - this.renderer = renderer; - this.owner = owner; - this.template = template; - this.outletState = null; - this._tag = new _glimmerReference.DirtyableTag(); - } - - OutletView.prototype.appendTo = function appendTo(selector) { - var env = this._environment || _emberEnvironment.environment; - var target = undefined; - - if (env.hasDOM) { - target = typeof selector === 'string' ? document.querySelector(selector) : selector; - } else { - target = selector; - } - - _emberMetal.run.schedule('render', this.renderer, 'appendOutletView', this, target); - }; - - OutletView.prototype.rerender = function rerender() {}; - - OutletView.prototype.setOutletState = function setOutletState(state) { - this.outletState = { - outlets: { - main: state - }, - render: { - owner: undefined, - into: undefined, - outlet: 'main', - name: '-top-level', - controller: undefined, - ViewClass: undefined, - template: undefined - } - }; - this._tag.dirty(); - }; - - OutletView.prototype.toReference = function toReference() { - return new OutletStateReference(this); - }; - - OutletView.prototype.destroy = function destroy() {}; - - return OutletView; - })(); - - exports.default = OutletView; -}); -enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) { - 'use strict'; - - exports.default = alias; - exports.AliasedProperty = AliasedProperty; - - function alias(altKey) { - return new AliasedProperty(altKey); - } - - function AliasedProperty(altKey) { - this.isDescriptor = true; - this.altKey = altKey; - this._dependentKeys = [altKey]; - } - - AliasedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); - - AliasedProperty.prototype.setup = function (obj, keyName) { - _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName); - var meta = _emberMetalMeta.meta(obj); - if (meta.peekWatching(keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; - - AliasedProperty.prototype._addDependentKeyIfMissing = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (!meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; - - AliasedProperty.prototype._removeDependentKeyIfAdded = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; - - AliasedProperty.prototype.willWatch = AliasedProperty.prototype._addDependentKeyIfMissing; - AliasedProperty.prototype.didUnwatch = AliasedProperty.prototype._removeDependentKeyIfAdded; - AliasedProperty.prototype.teardown = AliasedProperty.prototype._removeDependentKeyIfAdded; - - AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) { - this._addDependentKeyIfMissing(obj, keyName); - - return _emberMetalProperty_get.get(obj, this.altKey); - }; - - AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) { - return _emberMetalProperty_set.set(obj, this.altKey, value); - }; - - AliasedProperty.prototype.readOnly = function () { - this.set = AliasedProperty_readOnlySet; - return this; - }; - - function AliasedProperty_readOnlySet(obj, keyName, value) { - throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); - } - - AliasedProperty.prototype.oneWay = function () { - this.set = AliasedProperty_oneWaySet; - return this; - }; - - function AliasedProperty_oneWaySet(obj, keyName, value) { - _emberMetalProperties.defineProperty(obj, keyName, null); - return _emberMetalProperty_set.set(obj, keyName, value); - } - - // Backwards compatibility with Ember Data. - AliasedProperty.prototype._meta = undefined; - AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta; -}); -enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) { - 'use strict'; - - exports.bind = bind; - - /** - @module ember - @submodule ember-metal - */ - - // .......................................................... - // BINDING - // - - function Binding(toPath, fromPath) { - // Configuration - this._from = fromPath; - this._to = toPath; - this._oneWay = undefined; - - // State - this._direction = undefined; - this._readyToSync = undefined; - this._fromObj = undefined; - this._fromPath = undefined; - this._toObj = undefined; - } - - /** - @class Binding - @namespace Ember - @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding - @public - */ - - Binding.prototype = { - /** - This copies the Binding so it can be connected to another object. - @method copy - @return {Ember.Binding} `this` - @public - */ - copy: function () { - var copy = new Binding(this._to, this._from); - if (this._oneWay) { - copy._oneWay = true; - } - return copy; - }, - - // .......................................................... - // CONFIG - // - - /** - This will set `from` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method from - @param {String} path The property path to connect to. - @return {Ember.Binding} `this` - @public - */ - from: function (path) { - this._from = path; - return this; - }, - - /** - This will set the `to` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method to - @param {String|Tuple} path A property path or tuple. - @return {Ember.Binding} `this` - @public - */ - to: function (path) { - this._to = path; - return this; - }, - - /** - Configures the binding as one way. A one-way binding will relay changes - on the `from` side to the `to` side, but not the other way around. This - means that if you change the `to` side directly, the `from` side may have - a different value. - @method oneWay - @return {Ember.Binding} `this` - @public - */ - oneWay: function () { - this._oneWay = true; - return this; - }, - - /** - @method toString - @return {String} string representation of binding - @public - */ - toString: function () { - var oneWay = this._oneWay ? '[oneWay]' : ''; - return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; - }, - - // .......................................................... - // CONNECT AND SYNC - // - - /** - Attempts to connect this binding instance so that it can receive and relay - changes. This method will raise an exception if you have not set the - from/to properties yet. - @method connect - @param {Object} obj The root object for this binding. - @return {Ember.Binding} `this` - @public - */ - connect: function (obj) { - _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.connect()', !!obj); - - var fromObj = undefined, - fromPath = undefined, - possibleGlobal = undefined; - - // If the binding's "from" path could be interpreted as a global, verify - // whether the path refers to a global or not by consulting `Ember.lookup`. - if (_emberMetalPath_cache.isGlobalPath(this._from)) { - var _name = _emberMetalPath_cache.getFirstKey(this._from); - possibleGlobal = _emberEnvironment.context.lookup[_name]; - - if (possibleGlobal) { - fromObj = possibleGlobal; - fromPath = _emberMetalPath_cache.getTailPath(this._from); - } - } - - if (fromObj === undefined) { - fromObj = obj; - fromPath = this._from; - } - - _emberMetalProperty_set.trySet(obj, this._to, _emberMetalProperty_get.get(fromObj, fromPath)); - - // Add an observer on the object to be notified when the binding should be updated. - _emberMetalObserver.addObserver(fromObj, fromPath, this, 'fromDidChange'); - - // If the binding is a two-way binding, also set up an observer on the target. - if (!this._oneWay) { - _emberMetalObserver.addObserver(obj, this._to, this, 'toDidChange'); - } - - _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect'); - - fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); - - this._readyToSync = true; - this._fromObj = fromObj; - this._fromPath = fromPath; - this._toObj = obj; - - return this; - }, - - /** - Disconnects the binding instance. Changes will no longer be relayed. You - will not usually need to call this method. - @method disconnect - @return {Ember.Binding} `this` - @public - */ - disconnect: function () { - _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); - - // Remove an observer on the object so we're no longer notified of - // changes that should update bindings. - _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); - - // If the binding is two-way, remove the observer from the target as well. - if (!this._oneWay) { - _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); - } - - this._readyToSync = false; // Disable scheduled syncs... - return this; - }, - - // .......................................................... - // PRIVATE - // - - /* Called when the from side changes. */ - fromDidChange: function (target) { - this._scheduleSync('fwd'); - }, - - /* Called when the to side changes. */ - toDidChange: function (target) { - this._scheduleSync('back'); - }, - - _scheduleSync: function (dir) { - var existingDir = this._direction; - - // If we haven't scheduled the binding yet, schedule it. - if (existingDir === undefined) { - _emberMetalRun_loop.default.schedule('sync', this, '_sync'); - this._direction = dir; - } - - // If both a 'back' and 'fwd' sync have been scheduled on the same object, - // default to a 'fwd' sync so that it remains deterministic. - if (existingDir === 'back' && dir === 'fwd') { - this._direction = 'fwd'; - } - }, - - _sync: function () { - var log = _emberEnvironment.ENV.LOG_BINDINGS; - - var toObj = this._toObj; - - // Don't synchronize destroyed objects or disconnected bindings. - if (toObj.isDestroyed || !this._readyToSync) { - return; - } - - // Get the direction of the binding for the object we are - // synchronizing from. - var direction = this._direction; - - var fromObj = this._fromObj; - var fromPath = this._fromPath; - - this._direction = undefined; - - // If we're synchronizing from the remote object... - if (direction === 'fwd') { - var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); - if (log) { - _emberConsole.default.log(' ', this.toString(), '->', fromValue, fromObj); - } - if (this._oneWay) { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - } else { - _emberMetalObserver._suspendObserver(toObj, this._to, this, 'toDidChange', function () { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - }); - } - // If we're synchronizing *to* the remote object. - } else if (direction === 'back') { - var toValue = _emberMetalProperty_get.get(toObj, this._to); - if (log) { - _emberConsole.default.log(' ', this.toString(), '<-', toValue, toObj); - } - _emberMetalObserver._suspendObserver(fromObj, fromPath, this, 'fromDidChange', function () { - _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); - }); - } - } - - }; - - function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { - var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; - var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; - var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - - var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; - _emberMetalDebug.deprecate(objectInfo + deprecateGlobalMessage, !deprecateGlobal, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - _emberMetalDebug.deprecate(objectInfo + deprecateOneWayMessage, !deprecateOneWay, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - _emberMetalDebug.deprecate(objectInfo + deprecateAliasMessage, !deprecateAlias, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - } - - function mixinProperties(to, from) { - for (var key in from) { - if (from.hasOwnProperty(key)) { - to[key] = from[key]; - } - } - } - - mixinProperties(Binding, { - - /* - See `Ember.Binding.from`. - @method from - @static - */ - from: function (from) { - var C = this; - return new C(undefined, from); - }, - - /* - See `Ember.Binding.to`. - @method to - @static - */ - to: function (to) { - var C = this; - return new C(to, undefined); - } - }); - /** - An `Ember.Binding` connects the properties of two objects so that whenever - the value of one property changes, the other property will be changed also. - - ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. - - You do not usually create Binding objects directly but instead describe - bindings in your class or object definition using automatic binding - detection. - - Properties ending in a `Binding` suffix will be converted to `Ember.Binding` - instances. The value of this property should be a string representing a path - to another object or a custom binding instance created using Binding helpers - (see "One Way Bindings"): - - ``` - valueBinding: "MyApp.someController.title" - ``` - - This will create a binding from `MyApp.someController.title` to the `value` - property of your object instance automatically. Now the two values will be - kept in sync. - - ## One Way Bindings - - One especially useful binding customization you can use is the `oneWay()` - helper. This helper tells Ember that you are only interested in - receiving changes on the object you are binding from. For example, if you - are binding to a preference and you want to be notified if the preference - has changed, but your object will not be changing the preference itself, you - could do: - - ``` - bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") - ``` - - This way if the value of `MyApp.preferencesController.bigTitles` changes the - `bigTitles` property of your object will change also. However, if you - change the value of your `bigTitles` property, it will not update the - `preferencesController`. - - One way bindings are almost twice as fast to setup and twice as fast to - execute because the binding only has to worry about changes to one side. - - You should consider using one way bindings anytime you have an object that - may be created frequently and you do not intend to change a property; only - to monitor it for changes (such as in the example above). - - ## Adding Bindings Manually - - All of the examples above show you how to configure a custom binding, but the - result of these customizations will be a binding template, not a fully active - Binding instance. The binding will actually become active only when you - instantiate the object the binding belongs to. It is useful, however, to - understand what actually happens when the binding is activated. - - For a binding to function it must have at least a `from` property and a `to` - property. The `from` property path points to the object/key that you want to - bind from while the `to` path points to the object/key you want to bind to. - - When you define a custom binding, you are usually describing the property - you want to bind from (such as `MyApp.someController.value` in the examples - above). When your object is created, it will automatically assign the value - you want to bind `to` based on the name of your binding key. In the - examples above, during init, Ember objects will effectively call - something like this on your binding: - - ```javascript - binding = Ember.Binding.from("valueBinding").to("value"); - ``` - - This creates a new binding instance based on the template you provide, and - sets the to path to the `value` property of the new object. Now that the - binding is fully configured with a `from` and a `to`, it simply needs to be - connected to become active. This is done through the `connect()` method: - - ```javascript - binding.connect(this); - ``` - - Note that when you connect a binding you pass the object you want it to be - connected to. This object will be used as the root for both the from and - to side of the binding when inspecting relative paths. This allows the - binding to be automatically inherited by subclassed objects as well. - - This also allows you to bind between objects using the paths you declare in - `from` and `to`: - - ```javascript - // Example 1 - binding = Ember.Binding.from("App.someObject.value").to("value"); - binding.connect(this); - - // Example 2 - binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); - binding.connect(this); - ``` - - Now that the binding is connected, it will observe both the from and to side - and relay changes. - - If you ever needed to do so (you almost never will, but it is useful to - understand this anyway), you could manually create an active binding by - using the `Ember.bind()` helper method. (This is the same method used by - to setup your bindings on objects): - - ```javascript - Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); - ``` - - Both of these code fragments have the same effect as doing the most friendly - form of binding creation like so: - - ```javascript - MyApp.anotherObject = Ember.Object.create({ - valueBinding: "MyApp.someController.value", - - // OTHER CODE FOR THIS OBJECT... - }); - ``` - - Ember's built in binding creation method makes it easy to automatically - create bindings for you. You should always use the highest-level APIs - available, even if you understand how it works underneath. - - @class Binding - @namespace Ember - @since Ember 0.9 - @public - */ - // Ember.Binding = Binding; ES6TODO: where to put this? - - /** - Global helper method to create a new binding. Just pass the root object - along with a `to` and `from` path to create and connect the binding. - - @method bind - @for Ember - @param {Object} obj The root object of the transform. - @param {String} to The path to the 'to' side of the binding. - Must be relative to obj. - @param {String} from The path to the 'from' side of the binding. - Must be relative to obj or a global path. - @return {Ember.Binding} binding instance - @public - */ - - function bind(obj, to, from) { - return new Binding(to, from).connect(obj); - } - - exports.Binding = Binding; -}); -enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; - - var Cache = (function () { - function Cache(limit, func, key, store) { - babelHelpers.classCallCheck(this, Cache); - - this.size = 0; - this.misses = 0; - this.hits = 0; - this.limit = limit; - this.func = func; - this.key = key; - this.store = store || new DefaultStore(); - } - - Cache.prototype.get = function get(obj) { - var key = this.key === undefined ? obj : this.key(obj); - var value = this.store.get(key); - if (value === undefined) { - this.misses++; - value = this._set(key, this.func(obj)); - } else if (value === _emberMetalMeta.UNDEFINED) { - this.hits++; - value = undefined; - } else { - this.hits++; - // nothing to translate - } - - return value; - }; - - Cache.prototype.set = function set(obj, value) { - var key = this.key === undefined ? obj : this.key(obj); - return this._set(key, value); - }; - - Cache.prototype._set = function _set(key, value) { - if (this.limit > this.size) { - this.size++; - if (value === undefined) { - this.store.set(key, _emberMetalMeta.UNDEFINED); - } else { - this.store.set(key, value); - } - } - - return value; - }; - - Cache.prototype.purge = function purge() { - this.store.clear(); - this.size = 0; - this.hits = 0; - this.misses = 0; - }; - - return Cache; - })(); - - exports.default = Cache; - - var DefaultStore = (function () { - function DefaultStore() { - babelHelpers.classCallCheck(this, DefaultStore); - - this.data = new _emberUtils.EmptyObject(); - } - - DefaultStore.prototype.get = function get(key) { - return this.data[key]; - }; - - DefaultStore.prototype.set = function set(key, value) { - this.data[key] = value; - }; - - DefaultStore.prototype.clear = function clear() { - this.data = new _emberUtils.EmptyObject(); - }; - - return DefaultStore; - })(); -}); -enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalWatch_path) { - 'use strict'; - - exports.finishChains = finishChains; - - var FIRST_KEY = /^([^\.]+)/; - - function firstKey(path) { - return path.match(FIRST_KEY)[0]; - } - - function isObject(obj) { - return typeof obj === 'object' && obj; - } - - function isVolatile(obj) { - return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); - } - - function ChainWatchers() { - // chain nodes that reference a key in this obj by key - // we only create ChainWatchers when we are going to add them - // so create this upfront - this.chains = new _emberUtils.EmptyObject(); - } - - ChainWatchers.prototype = { - add: function (key, node) { - var nodes = this.chains[key]; - if (nodes === undefined) { - this.chains[key] = [node]; - } else { - nodes.push(node); - } - }, - - remove: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - nodes.splice(i, 1); - break; - } - } - } - }, - - has: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - return true; - } - } - } - return false; - }, - - revalidateAll: function () { - for (var key in this.chains) { - this.notify(key, true, undefined); - } - }, - - revalidate: function (key) { - this.notify(key, true, undefined); - }, - - // key: the string key that is part of a path changed - // revalidate: boolean; the chains that are watching this value should revalidate - // callback: function that will be called with the object and path that - // will be/are invalidated by this key change, depending on - // whether the revalidate flag is passed - notify: function (key, revalidate, callback) { - var nodes = this.chains[key]; - if (nodes === undefined || nodes.length === 0) { - return; - } - - var affected = undefined; - - if (callback) { - affected = []; - } - - for (var i = 0; i < nodes.length; i++) { - nodes[i].notify(revalidate, affected); - } - - if (callback === undefined) { - return; - } - - // we gather callbacks so we don't notify them during revalidation - for (var i = 0; i < affected.length; i += 2) { - var obj = affected[i]; - var path = affected[i + 1]; - callback(obj, path); - } - } - }; - - function makeChainWatcher() { - return new ChainWatchers(); - } - - function addChainWatcher(obj, keyName, node) { - var m = _emberMetalMeta.meta(obj); - m.writableChainWatchers(makeChainWatcher).add(keyName, node); - _emberMetalWatch_key.watchKey(obj, keyName, m); - } - - function removeChainWatcher(obj, keyName, node, _meta) { - if (!isObject(obj)) { - return; - } - - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (!meta || !meta.readableChainWatchers()) { - return; - } - - // make meta writable - meta = _emberMetalMeta.meta(obj); - - meta.readableChainWatchers().remove(keyName, node); - - _emberMetalWatch_key.unwatchKey(obj, keyName, meta); - } - - // A ChainNode watches a single key on an object. If you provide a starting - // value for the key then the node won't actually watch it. For a root node - // pass null for parent and key and object for value. - function ChainNode(parent, key, value) { - this._parent = parent; - this._key = key; - - // _watching is true when calling get(this._parent, this._key) will - // return the value of this node. - // - // It is false for the root of a chain (because we have no parent) - // and for global paths (because the parent node is the object with - // the observer on it) - this._watching = value === undefined; - - this._chains = undefined; - this._object = undefined; - this.count = 0; - - this._value = value; - this._paths = {}; - if (this._watching) { - var obj = parent.value(); - - if (!isObject(obj)) { - return; - } - - this._object = obj; - - addChainWatcher(this._object, this._key, this); - } - } - - function lazyGet(obj, key) { - if (!isObject(obj)) { - return; - } - - var meta = _emberMetalMeta.peekMeta(obj); - - // check if object meant only to be a prototype - if (meta && meta.proto === obj) { - return; - } - - // Use `get` if the return value is an EachProxy or an uncacheable value. - if (isVolatile(obj[key])) { - return _emberMetalProperty_get.get(obj, key); - // Otherwise attempt to get the cached value of the computed property - } else { - var cache = meta.readableCache(); - if (cache && key in cache) { - return cache[key]; - } - } - } - - ChainNode.prototype = { - value: function () { - if (this._value === undefined && this._watching) { - var obj = this._parent.value(); - this._value = lazyGet(obj, this._key); - } - return this._value; - }, - - destroy: function () { - if (this._watching) { - var obj = this._object; - if (obj) { - removeChainWatcher(obj, this._key, this); - } - this._watching = false; // so future calls do nothing - } - }, - - // copies a top level object only - copy: function (obj) { - var ret = new ChainNode(null, null, obj); - var paths = this._paths; - var path = undefined; - - for (path in paths) { - // this check will also catch non-number vals. - if (paths[path] <= 0) { - continue; - } - ret.add(path); - } - return ret; - }, - - // called on the root node of a chain to setup watchers on the specified - // path. - add: function (path) { - var paths = this._paths; - paths[path] = (paths[path] || 0) + 1; - - var key = firstKey(path); - var tail = path.slice(key.length + 1); - - this.chain(key, tail); - }, - - // called on the root node of a chain to teardown watcher on the specified - // path - remove: function (path) { - var paths = this._paths; - if (paths[path] > 0) { - paths[path]--; - } - - var key = firstKey(path); - var tail = path.slice(key.length + 1); - - this.unchain(key, tail); - }, - - chain: function (key, path) { - var chains = this._chains; - var node = undefined; - if (chains === undefined) { - chains = this._chains = new _emberUtils.EmptyObject(); - } else { - node = chains[key]; - } - - if (node === undefined) { - node = chains[key] = new ChainNode(this, key, undefined); - } - - node.count++; // count chains... - - // chain rest of path if there is one - if (path) { - key = firstKey(path); - path = path.slice(key.length + 1); - node.chain(key, path); - } - }, - - unchain: function (key, path) { - var chains = this._chains; - var node = chains[key]; - - // unchain rest of path first... - if (path && path.length > 1) { - var nextKey = firstKey(path); - var nextPath = path.slice(nextKey.length + 1); - node.unchain(nextKey, nextPath); - } - - // delete node if needed. - node.count--; - if (node.count <= 0) { - chains[node._key] = undefined; - node.destroy(); - } - }, - - notify: function (revalidate, affected) { - if (revalidate && this._watching) { - var parentValue = this._parent.value(); - - if (parentValue !== this._object) { - if (this._object) { - removeChainWatcher(this._object, this._key, this); - } - - if (isObject(parentValue)) { - this._object = parentValue; - addChainWatcher(parentValue, this._key, this); - } else { - this._object = undefined; - } - } - this._value = undefined; - } - - // then notify chains... - var chains = this._chains; - var node = undefined; - if (chains) { - for (var key in chains) { - node = chains[key]; - if (node !== undefined) { - node.notify(revalidate, affected); - } - } - } - - if (affected && this._parent) { - this._parent.populateAffected(this._key, 1, affected); - } - }, - - populateAffected: function (path, depth, affected) { - if (this._key) { - path = this._key + '.' + path; - } - - if (this._parent) { - this._parent.populateAffected(path, depth + 1, affected); - } else { - if (depth > 1) { - affected.push(this.value(), path); - } - } - } - }; - - function finishChains(obj) { - // We only create meta if we really have to - var m = _emberMetalMeta.peekMeta(obj); - if (m) { - m = _emberMetalMeta.meta(obj); - - // finish any current chains node watchers that reference obj - var chainWatchers = m.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidateAll(); - } - // ensure that if we have inherited any chains they have been - // copied onto our own meta. - if (m.readableChains()) { - m.writableChains(_emberMetalWatch_path.makeChainNode); - } - } - } - - exports.removeChainWatcher = removeChainWatcher; - exports.ChainNode = ChainNode; -}); -enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) { - 'use strict'; - - exports.default = computed; - - /** - @module ember - @submodule ember-metal - */ - - var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; - - /** - A computed property transforms an object literal with object's accessor function(s) 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 - `fullName` - by calling - `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter 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 - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', function() { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }) - }); - - let 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 by providing additional function (`set`) in hash argument. - If you try to set a computed property, it will try to invoke setter accessor function with the key and - value you want to set it to as arguments. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }, - set(key, value) { - let [firstName, lastName] = value.split(' '); - - this.set('firstName', firstName); - this.set('lastName', lastName); - - return value; - } - }) - }); - - let person = Person.create(); - - person.set('fullName', 'Peter Wagenet'); - person.get('firstName'); // 'Peter' - person.get('lastName'); // 'Wagenet' - ``` - - You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined. - - You can also mark computed property as `.readOnly()` and block all attempts to set it. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'); - let lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - } - }).readOnly() - }); - - let person = Person.create(); - person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX> - ``` - - Additional resources: - - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md) - - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax) - - @class ComputedProperty - @namespace Ember - @public - */ - function ComputedProperty(config, opts) { - this.isDescriptor = true; - if (typeof config === 'function') { - this._getter = config; - } else { - _emberMetalDebug.assert('Ember.computed expects a function or an object as last argument.', typeof config === 'object' && !Array.isArray(config)); - _emberMetalDebug.assert('Config object passed to an Ember.computed can only contain `get` or `set` keys.', (function () { - var keys = Object.keys(config); - for (var i = 0; i < keys.length; i++) { - if (keys[i] !== 'get' && keys[i] !== 'set') { - return false; - } - } - return true; - })()); - this._getter = config.get; - this._setter = config.set; - } - _emberMetalDebug.assert('Computed properties must receive a getter or a setter, you passed none.', !!this._getter || !!this._setter); - this._dependentKeys = undefined; - this._suspended = undefined; - this._meta = undefined; - this._volatile = false; - this._dependentKeys = opts && opts.dependentKeys; - this._readOnly = false; - } - - ComputedProperty.prototype = new _emberMetalProperties.Descriptor(); - ComputedProperty.prototype.constructor = ComputedProperty; - - var ComputedPropertyPrototype = ComputedProperty.prototype; - - /** - 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. - - It also does not automatically fire any change events. You must manually notify - any changes if you want to observe this property. - - Dependency keys have no effect on volatile properties as they are for cache - invalidation and notification when cached value is invalidated. - - ```javascript - let outsideService = Ember.Object.extend({ - value: Ember.computed(function() { - return OutsideService.getValue(); - }).volatile() - }).create(); - ``` - - @method volatile - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.volatile = function () { - this._volatile = true; - 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 - let Person = Ember.Object.extend({ - guid: Ember.computed(function() { - return 'guid-guid-guid'; - }).readOnly() - }); - - let person = Person.create(); - - person.set('guid', 'new-guid'); // will throw an exception - ``` - - @method readOnly - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.readOnly = function () { - this._readOnly = true; - _emberMetalDebug.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 - let President = Ember.Object.extend({ - fullName: Ember.computed(function() { - return this.get('firstName') + ' ' + this.get('lastName'); - - // Tell Ember that this computed property depends on firstName - // and lastName - }).property('firstName', 'lastName') - }); - - let 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 = []; - - function addArg(property) { - _emberMetalDebug.warn('Dependent keys containing @each only work one level deep. ' + ('You used the key "' + property + '" which is invalid. ') + 'Please create an intermediary computed property.', DEEP_EACH_REGEX.test(property) === false, { id: 'ember-metal.computed-deep-each' }); - args.push(property); - } - - for (var i = 0; i < arguments.length; 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: Ember.computed(function() { - let personId = this.get('personId'); - return App.Person.create({ id: personId }); - }).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; - } - }; - - // invalidate cache when CP key changes - 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._volatile || this._suspended === obj) { - return; - } - - // don't create objects just to invalidate - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta || meta.source !== obj) { - return; - } - - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - cache[keyName] = undefined; - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; - - ComputedPropertyPrototype.get = function (obj, keyName) { - if (this._volatile) { - return this._getter.call(obj, keyName); - } - - var meta = _emberMetalMeta.meta(obj); - var cache = meta.writableCache(); - - var result = cache[keyName]; - if (result === _emberMetalMeta.UNDEFINED) { - return undefined; - } else if (result !== undefined) { - return result; - } - - var ret = this._getter.call(obj, keyName); - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } - - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - - return ret; - }; - - ComputedPropertyPrototype.set = function computedPropertySetEntry(obj, keyName, value) { - if (this._readOnly) { - this._throwReadOnlyError(obj, keyName); - } - - if (!this._setter) { - return this.clobberSet(obj, keyName, value); - } - - if (this._volatile) { - return this.volatileSet(obj, keyName, value); - } - - return this.setWithSuspend(obj, keyName, value); - }; - - ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) { - throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj)); - }; - - ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) { - var cachedValue = cacheFor(obj, keyName); - _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue); - _emberMetalProperty_set.set(obj, keyName, value); - return value; - }; - - ComputedPropertyPrototype.volatileSet = function computedPropertyVolatileSet(obj, keyName, value) { - return this._setter.call(obj, keyName, value); - }; - - ComputedPropertyPrototype.setWithSuspend = function computedPropertySetWithSuspend(obj, keyName, value) { - var oldSuspended = this._suspended; - this._suspended = obj; - try { - return this._set(obj, keyName, value); - } finally { - this._suspended = oldSuspended; - } - }; - - ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { - // cache requires own meta - var meta = _emberMetalMeta.meta(obj); - // either there is a writable cache or we need one to update - var cache = meta.writableCache(); - var hadCachedValue = false; - var cachedValue = undefined; - if (cache[keyName] !== undefined) { - if (cache[keyName] !== _emberMetalMeta.UNDEFINED) { - cachedValue = cache[keyName]; - } - hadCachedValue = true; - } - - var ret = this._setter.call(obj, keyName, value, cachedValue); - - // allows setter to return the same value that is cached already - if (hadCachedValue && cachedValue === ret) { - return ret; - } - - _emberMetalProperty_events.propertyWillChange(obj, keyName); - - if (hadCachedValue) { - cache[keyName] = undefined; - } - - if (!hadCachedValue) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } - - _emberMetalProperty_events.propertyDidChange(obj, keyName); - - return ret; - }; - - /* called before property is overridden */ - ComputedPropertyPrototype.teardown = function (obj, keyName) { - if (this._volatile) { - return; - } - var meta = _emberMetalMeta.meta(obj); - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - cache[keyName] = undefined; - } - }; - - /** - This helper returns a new property descriptor that wraps the passed - computed property function. You can use this helper to define properties - with mixins or via `Ember.defineProperty()`. - - If you pass a function as an argument, it will be used as a getter. A computed - property defined in this way might look like this: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', function() { - return `${this.get('firstName')} ${this.get('lastName')}`; - }) - }); - - let client = Person.create(); - - client.get('fullName'); // 'Betty Jones' - - client.set('lastName', 'Fuller'); - client.get('fullName'); // 'Betty Fuller' - ``` - - You can pass a hash with two functions, `get` and `set`, as an - argument to provide both a getter and setter: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - return `${this.get('firstName')} ${this.get('lastName')}`; - }, - set(key, value) { - let [firstName, lastName] = value.split(/\s+/); - this.setProperties({ firstName, lastName }); - return value; - } - }); - }) - - let client = Person.create(); - client.get('firstName'); // 'Betty' - - client.set('fullName', 'Carroll Fuller'); - client.get('firstName'); // 'Carroll' - ``` - - The `set` function should accept two parameters, `key` and `value`. The value - returned from `set` will be the new value of the property. - - _Note: This is the preferred way to define computed properties when writing third-party - libraries that depend on or use Ember, since there is no guarantee that the user - will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._ - - The alternative syntax, with prototype extensions, might look like: - - ```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 = undefined; - - 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 = _emberMetalMeta.peekMeta(obj); - var cache = meta && meta.source === obj && meta.readableCache(); - var ret = cache && cache[key]; - - if (ret === _emberMetalMeta.UNDEFINED) { - return undefined; - } - return ret; - } - - cacheFor.set = function (cache, key, value) { - if (value === undefined) { - cache[key] = _emberMetalMeta.UNDEFINED; - } else { - cache[key] = value; - } - }; - - cacheFor.get = function (cache, key) { - var ret = cache[key]; - if (ret === _emberMetalMeta.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', 'ember-environment'], function (exports, _emberEnvironment) { - 'use strict'; - - /** - @module ember - @submodule ember-metal - */ - - /** - This namespace contains all Ember methods and functions. Future versions of - Ember may overwrite this namespace and therefore, you should avoid adding any - new properties. - - At the heart of Ember is Ember-Runtime, a set of core functions that provide - cross-platform compatibility and object property observing. Ember-Runtime is - small and performance-focused so you can use it alongside other - cross-platform libraries such as jQuery. For more details, see - [Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html). - - @class Ember - @static - @public - */ - var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {}; - - // Make sure these are set whether Ember was already defined or not - Ember.isNamespace = true; - Ember.toString = function () { - return 'Ember'; - }; - - // .......................................................... - // BOOTSTRAP - // - - exports.default = Ember; -}); -enifed("ember-metal/debug", ["exports"], function (exports) { - "use strict"; - - exports.getDebugFunction = getDebugFunction; - exports.setDebugFunction = setDebugFunction; - exports.assert = assert; - exports.info = info; - exports.warn = warn; - exports.debug = debug; - exports.deprecate = deprecate; - exports.deprecateFunc = deprecateFunc; - exports.runInDebug = runInDebug; - exports.debugSeal = debugSeal; - exports.debugFreeze = debugFreeze; - var debugFunctions = { - assert: function () {}, - info: function () {}, - warn: function () {}, - debug: function () {}, - deprecate: function () {}, - deprecateFunc: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return args[args.length - 1]; - }, - runInDebug: function () {}, - debugSeal: function () {}, - debugFreeze: function () {} - }; - - exports.debugFunctions = debugFunctions; - - function getDebugFunction(name) { - return debugFunctions[name]; - } - - function setDebugFunction(name, fn) { - debugFunctions[name] = fn; - } - - function assert() { - return debugFunctions.assert.apply(undefined, arguments); - } - - function info() { - return debugFunctions.info.apply(undefined, arguments); - } - - function warn() { - return debugFunctions.warn.apply(undefined, arguments); - } - - function debug() { - return debugFunctions.debug.apply(undefined, arguments); - } - - function deprecate() { - return debugFunctions.deprecate.apply(undefined, arguments); - } - - function deprecateFunc() { - return debugFunctions.deprecateFunc.apply(undefined, arguments); - } - - function runInDebug() { - return debugFunctions.runInDebug.apply(undefined, arguments); - } - - function debugSeal() { - return debugFunctions.debugSeal.apply(undefined, arguments); - } - - function debugFreeze() { - return debugFunctions.debugFreeze.apply(undefined, arguments); - } -}); -enifed('ember-metal/dependent_keys', ['exports', 'ember-metal/watching'], function (exports, _emberMetalWatching) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - exports.addDependentKeys = addDependentKeys; - exports.removeDependentKeys = removeDependentKeys; - - /** - @module ember - @submodule ember-metal - */ - - // .......................................................... - // DEPENDENT KEYS - // - - function addDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // add all of its dependent keys. - var idx = undefined, - depKey = undefined; - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; - } - - for (idx = 0; idx < depKeys.length; idx++) { - depKey = depKeys[idx]; - // Increment the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1); - // Watch the depKey - _emberMetalWatching.watch(obj, depKey, meta); - } - } - - function removeDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // remove all of its dependent keys. - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; - } - - for (var idx = 0; idx < depKeys.length; idx++) { - var depKey = depKeys[idx]; - // Decrement the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1); - // Unwatch the depKey - _emberMetalWatching.unwatch(obj, depKey, meta); - } - } -}); -enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set) { - /** - @module ember - @submodule ember-metal - */ - - 'use strict'; - - exports.deprecateProperty = deprecateProperty; - - /** - Used internally to allow changing properties in a backwards compatible way, and print a helpful - deprecation warning. - - @method deprecateProperty - @param {Object} object The object to add the deprecated property to. - @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). - @param {String} newKey The property that will be aliased. - @private - @since 1.7.0 - */ - - function deprecateProperty(object, deprecatedKey, newKey, options) { - function _deprecate() { - _emberMetalDebug.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.', false, options); - } - - Object.defineProperty(object, deprecatedKey, { - configurable: true, - enumerable: false, - set: function (value) { - _deprecate(); - _emberMetalProperty_set.set(this, newKey, value); - }, - get: function () { - _deprecate(); - return _emberMetalProperty_get.get(this, newKey); - } - }); - } -}); -enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) { - 'use strict'; - - exports.default = descriptor; - - function descriptor(desc) { - return new Descriptor(desc); - } - - /** - A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need - this at all, however, the way we currently flatten/merge our mixins require - a special value to denote a descriptor. - - @class Descriptor - @private - */ - - var Descriptor = (function (_EmberDescriptor) { - babelHelpers.inherits(Descriptor, _EmberDescriptor); - - function Descriptor(desc) { - babelHelpers.classCallCheck(this, Descriptor); - - _EmberDescriptor.call(this); - this.desc = desc; - } - - Descriptor.prototype.setup = function setup(obj, key) { - Object.defineProperty(obj, key, this.desc); - }; - - Descriptor.prototype.teardown = function teardown(obj, key) {}; - - return Descriptor; - })(_emberMetalProperties.Descriptor); -}); -enifed("ember-metal/error", ["exports"], function (exports) { - - /** - A subclass of the JavaScript Error object for use in Ember. - - @class Error - @namespace Ember - @extends Error - @constructor - @public - */ - "use strict"; - - exports.default = EmberError; - - function EmberError(message) { - if (!(this instanceof EmberError)) { - return new EmberError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, EmberError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message; - this.name = error.name; - this.number = error.number; - this.code = error.code; - } - - EmberError.prototype = Object.create(Error.prototype); -}); -enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { - 'use strict'; - - exports.getOnerror = getOnerror; - exports.setOnerror = setOnerror; - exports.dispatchError = dispatchError; - exports.setDispatchOverride = setDispatchOverride; - - // To maintain stacktrace consistency across browsers - var getStack = function (error) { - var stack = error.stack; - var message = error.message; - - if (stack && stack.indexOf(message) === -1) { - stack = message + '\n' + stack; - } - - return stack; - }; - - var onerror = undefined; - // Ember.onerror getter - - function getOnerror() { - return onerror; - } - - // Ember.onerror setter - - function setOnerror(handler) { - onerror = handler; - } - - var dispatchOverride = undefined; - // dispatch error - - function dispatchError(error) { - if (dispatchOverride) { - dispatchOverride(error); - } else { - defaultDispatch(error); - } - } - - // allows testing adapter to override dispatch - - function setDispatchOverride(handler) { - dispatchOverride = handler; - } - - function defaultDispatch(error) { - if (_emberMetalTesting.isTesting()) { - throw error; - } - if (onerror) { - onerror(error); - } else { - _emberConsole.default.error(getStack(error)); - } - } -}); -enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-metal - */ - exports.accumulateListeners = accumulateListeners; - exports.addListener = addListener; - exports.removeListener = removeListener; - exports.suspendListener = suspendListener; - exports.suspendListeners = suspendListeners; - exports.watchedEvents = watchedEvents; - exports.sendEvent = sendEvent; - exports.hasListeners = hasListeners; - exports.listenersFor = listenersFor; - exports.on = on; - - /* - The event system uses a series of nested hashes to store listeners on an - object. When a listener is registered, or when an event arrives, these - hashes are consulted to determine which target and action pair to invoke. - - The hashes are stored in the object's meta hash, and look like this: - - // Object's meta hash - { - listeners: { // variable name: `listenerSet` - "foo:changed": [ // variable name: `actions` - target, method, flags - ] - } - } - - */ - - function indexOf(array, target, method) { - var index = -1; - // hashes are added to the end of the event array - // so it makes sense to start searching at the end - // of the array and search in reverse - for (var i = array.length - 3; i >= 0; i -= 3) { - if (target === array[i] && method === array[i + 1]) { - index = i; - break; - } - } - return index; - } - - function accumulateListeners(obj, eventName, otherActions) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return; - } - var actions = meta.matchingListeners(eventName); - var newActions = []; - - for (var i = actions.length - 3; i >= 0; i -= 3) { - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - var actionIndex = indexOf(otherActions, target, method); - - if (actionIndex === -1) { - otherActions.push(target, method, flags); - newActions.push(target, method, flags); - } - } - - return newActions; - } - - /** - Add an event listener - - @method addListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Boolean} once A flag whether a function should only be called once - @public - */ - - function addListener(obj, eventName, target, method, once) { - _emberMetalDebug.assert('You must pass at least an object and event name to Ember.addListener', !!obj && !!eventName); - - _emberMetalDebug.deprecate('didInitAttrs called in ' + (obj && obj.toString && obj.toString()) + '.', eventName !== 'didInitAttrs', { - id: 'ember-views.did-init-attrs', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' - }); - - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - - var flags = 0; - if (once) { - flags |= _emberMetalMeta_listeners.ONCE; - } - - _emberMetalMeta.meta(obj).addToListeners(eventName, target, method, flags); - - if ('function' === typeof obj.didAddListener) { - obj.didAddListener(eventName, target, method); - } - } - - /** - Remove an event listener - - Arguments should match those passed to `Ember.addListener`. - - @method removeListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @public - */ - - function removeListener(obj, eventName, target, method) { - _emberMetalDebug.assert('You must pass at least an object and event name to Ember.removeListener', !!obj && !!eventName); - - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - - _emberMetalMeta.meta(obj).removeFromListeners(eventName, target, method, function () { - if ('function' === typeof obj.didRemoveListener) { - obj.didRemoveListener.apply(obj, arguments); - } - }); - } - - /** - Suspend listener during callback. - - This should only be used by the target of the event listener - when it is taking an action that would cause the event, e.g. - an object might suspend its property change listener while it is - setting that property. - - @method suspendListener - @for Ember - - @private - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ - - function suspendListener(obj, eventName, target, method, callback) { - return suspendListeners(obj, [eventName], target, method, callback); - } - - /** - Suspends multiple listeners during a callback. - - @method suspendListeners - @for Ember - - @private - @param obj - @param {Array} eventNames Array of event names - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ - - function suspendListeners(obj, eventNames, target, method, callback) { - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - return _emberMetalMeta.meta(obj).suspendListeners(eventNames, target, method, callback); - } - - /** - Return a list of currently watched events - - @private - @method watchedEvents - @for Ember - @param obj - */ - - function watchedEvents(obj) { - return _emberMetalMeta.meta(obj).watchedEvents(); - } - - /** - Send an event. The execution of suspended listeners - is skipped, and once listeners are removed. A listener without - a target is executed on the passed object. If an array of actions - is not passed, the actions stored on the passed object are invoked. - - @method sendEvent - @for Ember - @param obj - @param {String} eventName - @param {Array} params Optional parameters for each listener. - @param {Array} actions Optional array of actions (listeners). - @return true - @public - */ - - function sendEvent(obj, eventName, params, actions) { - if (!actions) { - var meta = _emberMetalMeta.peekMeta(obj); - actions = meta && meta.matchingListeners(eventName); - } - - if (!actions || actions.length === 0) { - return; - } - - for (var i = actions.length - 3; i >= 0; i -= 3) { - // looping in reverse for once listeners - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - - if (!method) { - continue; - } - if (flags & _emberMetalMeta_listeners.SUSPENDED) { - continue; - } - if (flags & _emberMetalMeta_listeners.ONCE) { - removeListener(obj, eventName, target, method); - } - if (!target) { - target = obj; - } - if ('string' === typeof method) { - if (params) { - _emberUtils.applyStr(target, method, params); - } else { - target[method](); - } - } else { - if (params) { - method.apply(target, params); - } else { - method.call(target); - } - } - } - return true; - } - - /** - @private - @method hasListeners - @for Ember - @param obj - @param {String} eventName - */ - - function hasListeners(obj, eventName) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return false; - } - return meta.matchingListeners(eventName).length > 0; - } - - /** - @private - @method listenersFor - @for Ember - @param obj - @param {String} eventName - */ - - function listenersFor(obj, eventName) { - var ret = []; - var meta = _emberMetalMeta.peekMeta(obj); - var actions = meta && meta.matchingListeners(eventName); - - if (!actions) { - return ret; - } - - for (var i = 0; i < actions.length; i += 3) { - var target = actions[i]; - var method = actions[i + 1]; - ret.push([target, method]); - } - - return ret; - } - - /** - Define a property as a function that should be executed when - a specified event or events are triggered. - - - ``` javascript - let Job = Ember.Object.extend({ - logCompleted: Ember.on('completed', function() { - console.log('Job completed!'); - }) - }); - - let job = Job.create(); - - Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' - ``` - - @method on - @for Ember - @param {String} eventNames* - @param {Function} func - @return func - @public - */ - - function on() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var func = args.pop(); - var events = args; - func.__ember_listens__ = events; - return func; - } -}); -enifed('ember-metal/expand_properties', ['exports', 'ember-metal/debug'], function (exports, _emberMetalDebug) { - 'use strict'; - - exports.default = expandProperties; - - /** - @module ember - @submodule ember-metal - */ - - var SPLIT_REGEX = /\{|\}/; - var END_WITH_EACH_REGEX = /\.@each$/; - - /** - Expands `pattern`, invoking `callback` for each expansion. - - The only pattern supported is brace-expansion, anything else will be passed - once to `callback` directly. - - Example - - ```js - function echo(arg){ console.log(arg); } - - Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' - Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' - Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' - Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' - Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' - Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' - Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' - ``` - - @method expandProperties - @for Ember - @private - @param {String} pattern The property pattern to expand. - @param {Function} callback The callback to invoke. It is invoked once per - expansion, and is passed the expansion. - */ - - function expandProperties(pattern, callback) { - _emberMetalDebug.assert('A computed property key must be a string', typeof pattern === 'string'); - _emberMetalDebug.assert('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1); - _emberMetalDebug.assert('Brace expanded properties have to be balanced and cannot be nested, pattern: ' + pattern, (function (str) { - var inBrace = 0; - var char = undefined; - for (var i = 0; i < str.length; i++) { - char = str.charAt(i); - - if (char === '{') { - inBrace++; - } else if (char === '}') { - inBrace--; - } - - if (inBrace > 1 || inBrace < 0) { - return false; - } - } - - return true; - })(pattern)); - - var parts = pattern.split(SPLIT_REGEX); - var properties = [parts]; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part.indexOf(',') >= 0) { - properties = duplicateAndReplace(properties, part.split(','), i); - } - } - - for (var i = 0; i < properties.length; i++) { - callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); - } - } - - function duplicateAndReplace(properties, currentParts, index) { - var all = []; - - properties.forEach(function (property) { - currentParts.forEach(function (part) { - var current = property.slice(0); - current[index] = part; - all.push(current); - }); - }); - - return all; - } -}); -enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) { - 'use strict'; - - exports.default = isEnabled; - - /** - The hash of enabled Canary features. Add to this, any canary features - before creating your application. - - Alternatively (and recommended), you can also define `EmberENV.FEATURES` - if you need to enable features flagged at runtime. - - @class FEATURES - @namespace Ember - @static - @since 1.1.0 - @public - */ - var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES); - - exports.FEATURES = FEATURES; - /** - Determine whether the specified `feature` is enabled. Used by Ember's - build tools to exclude experimental features from beta/stable builds. - - You can define the following configuration options: - - * `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly - enabled/disabled. - - @method isEnabled - @param {String} feature The feature to check - @return {Boolean} - @for Ember.FEATURES - @since 1.1.0 - @public - */ - - function isEnabled(feature) { - var featureValue = FEATURES[feature]; - - if (featureValue === true || featureValue === false || featureValue === undefined) { - return featureValue; - } else if (_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES) { - return true; - } else { - return false; - } - } - - exports.DEFAULT_FEATURES = _emberFeatures.default; -}); -enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; - - exports.default = getProperties; - - /** - To get multiple properties at once, call `Ember.getProperties` - with an object followed by a list of strings or an array: - - ```javascript - Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - is equivalent to: - - ```javascript - Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - @method getProperties - @for Ember - @param {Object} obj - @param {String...|Array} list of keys to get - @return {Object} - @public - */ - - function getProperties(obj) { - var ret = {}; - var propertyNames = arguments; - var i = 1; - - if (arguments.length === 2 && Array.isArray(arguments[1])) { - i = 0; - propertyNames = arguments[1]; - } - for (; i < propertyNames.length; i++) { - ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]); - } - return ret; - } -}); -enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/is_proxy', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalIs_proxy, _emberMetalDescriptor) { - /** - @module ember - @submodule ember-metal - */ - - 'use strict'; - - exports.default = _emberMetalCore.default; - // reexports - exports.computed = _emberMetalComputed.default; - exports.cacheFor = _emberMetalComputed.cacheFor; - exports.ComputedProperty = _emberMetalComputed.ComputedProperty; - exports.alias = _emberMetalAlias.default; - exports.merge = _emberMetalMerge.default; - exports.assert = _emberMetalDebug.assert; - exports.info = _emberMetalDebug.info; - exports.warn = _emberMetalDebug.warn; - exports.debug = _emberMetalDebug.debug; - exports.deprecate = _emberMetalDebug.deprecate; - exports.deprecateFunc = _emberMetalDebug.deprecateFunc; - exports.runInDebug = _emberMetalDebug.runInDebug; - exports.setDebugFunction = _emberMetalDebug.setDebugFunction; - exports.getDebugFunction = _emberMetalDebug.getDebugFunction; - exports.debugSeal = _emberMetalDebug.debugSeal; - exports.debugFreeze = _emberMetalDebug.debugFreeze; - exports.instrument = _emberMetalInstrumentation.instrument; - exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument; - exports._instrumentStart = _emberMetalInstrumentation._instrumentStart; - exports.instrumentationReset = _emberMetalInstrumentation.reset; - exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe; - exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe; - exports.isTesting = _emberMetalTesting.isTesting; - exports.setTesting = _emberMetalTesting.setTesting; - exports.getOnerror = _emberMetalError_handler.getOnerror; - exports.setOnerror = _emberMetalError_handler.setOnerror; - exports.dispatchError = _emberMetalError_handler.dispatchError; - exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride; - exports.META_DESC = _emberMetalMeta.META_DESC; - exports.meta = _emberMetalMeta.meta; - exports.peekMeta = _emberMetalMeta.peekMeta; - exports.Error = _emberMetalError.default; - exports.Cache = _emberMetalCache.default; - exports.isFeatureEnabled = _emberMetalFeatures.default; - exports.FEATURES = _emberMetalFeatures.FEATURES; - exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES; - exports._getPath = _emberMetalProperty_get._getPath; - exports.get = _emberMetalProperty_get.get; - exports.getWithDefault = _emberMetalProperty_get.getWithDefault; - exports.set = _emberMetalProperty_set.set; - exports.trySet = _emberMetalProperty_set.trySet; - exports.WeakMap = _emberMetalWeak_map.default; - exports.accumulateListeners = _emberMetalEvents.accumulateListeners; - exports.addListener = _emberMetalEvents.addListener; - exports.hasListeners = _emberMetalEvents.hasListeners; - exports.listenersFor = _emberMetalEvents.listenersFor; - exports.on = _emberMetalEvents.on; - exports.removeListener = _emberMetalEvents.removeListener; - exports.sendEvent = _emberMetalEvents.sendEvent; - exports.suspendListener = _emberMetalEvents.suspendListener; - exports.suspendListeners = _emberMetalEvents.suspendListeners; - exports.watchedEvents = _emberMetalEvents.watchedEvents; - exports.isNone = _emberMetalIs_none.default; - exports.isEmpty = _emberMetalIs_empty.default; - exports.isBlank = _emberMetalIs_blank.default; - exports.isPresent = _emberMetalIs_present.default; - exports.run = _emberMetalRun_loop.default; - exports.ObserverSet = _emberMetalObserver_set.default; - exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges; - exports.changeProperties = _emberMetalProperty_events.changeProperties; - exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges; - exports.overrideChains = _emberMetalProperty_events.overrideChains; - exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; - exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; - exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; - exports.defineProperty = _emberMetalProperties.defineProperty; - exports.Descriptor = _emberMetalProperties.Descriptor; - exports.watchKey = _emberMetalWatch_key.watchKey; - exports.unwatchKey = _emberMetalWatch_key.unwatchKey; - exports.ChainNode = _emberMetalChains.ChainNode; - exports.finishChains = _emberMetalChains.finishChains; - exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; - exports.watchPath = _emberMetalWatch_path.watchPath; - exports.unwatchPath = _emberMetalWatch_path.unwatchPath; - exports.destroy = _emberMetalWatching.destroy; - exports.isWatching = _emberMetalWatching.isWatching; - exports.unwatch = _emberMetalWatching.unwatch; - exports.watch = _emberMetalWatching.watch; - exports.watcherCount = _emberMetalWatching.watcherCount; - exports.libraries = _emberMetalLibraries.default; - exports.Map = _emberMetalMap.Map; - exports.MapWithDefault = _emberMetalMap.MapWithDefault; - exports.OrderedSet = _emberMetalMap.OrderedSet; - exports.getProperties = _emberMetalGet_properties.default; - exports.setProperties = _emberMetalSet_properties.default; - exports.expandProperties = _emberMetalExpand_properties.default; - exports._suspendObserver = _emberMetalObserver._suspendObserver; - exports._suspendObservers = _emberMetalObserver._suspendObservers; - exports.addObserver = _emberMetalObserver.addObserver; - exports.observersFor = _emberMetalObserver.observersFor; - exports.removeObserver = _emberMetalObserver.removeObserver; - exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; - exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; - exports.Mixin = _emberMetalMixin.Mixin; - exports.aliasMethod = _emberMetalMixin.aliasMethod; - exports._immediateObserver = _emberMetalMixin._immediateObserver; - exports._beforeObserver = _emberMetalMixin._beforeObserver; - exports.mixin = _emberMetalMixin.mixin; - exports.observer = _emberMetalMixin.observer; - exports.required = _emberMetalMixin.required; - exports.REQUIRED = _emberMetalMixin.REQUIRED; - exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins; - exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins; - exports.detectBinding = _emberMetalMixin.detectBinding; - exports.Binding = _emberMetalBinding.Binding; - exports.bind = _emberMetalBinding.bind; - exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath; - exports.InjectedProperty = _emberMetalInjected_property.default; - exports.setHasViews = _emberMetalTags.setHasViews; - exports.tagForProperty = _emberMetalTags.tagForProperty; - exports.tagFor = _emberMetalTags.tagFor; - exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty; - exports.replace = _emberMetalReplace.default; - exports.runInTransaction = _emberMetalTransaction.default; - exports.didRender = _emberMetalTransaction.didRender; - exports.assertNotRendered = _emberMetalTransaction.assertNotRendered; - exports.isProxy = _emberMetalIs_proxy.isProxy; - exports.descriptor = _emberMetalDescriptor.default; - - // TODO: this needs to be deleted once we refactor the build tooling - // do this for side-effects of updating Ember.assert, warn, etc when - // ember-debug is present - // This needs to be called before any deprecateFunc - - if (_require.has('ember-debug')) { - _require.default('ember-debug'); - } -}); -enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) { - 'use strict'; - - exports.default = InjectedProperty; - - /** - Read-only property that returns the result of a container lookup. - - @class InjectedProperty - @namespace Ember - @constructor - @param {String} type The container type the property will lookup - @param {String} name (optional) The name the property will lookup, defaults - to the property's name - @private - */ - - function InjectedProperty(type, name) { - this.type = type; - this.name = name; - - this._super$Constructor(injectedPropertyGet); - AliasedPropertyPrototype.oneWay.call(this); - } - - function injectedPropertyGet(keyName) { - var desc = this[keyName]; - var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat - - _emberMetalDebug.assert('InjectedProperties should be defined with the Ember.inject computed property macros.', desc && desc.isDescriptor && desc.type); - _emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', owner); - - return owner.lookup(desc.type + ':' + (desc.name || keyName)); - } - - InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); - - var InjectedPropertyPrototype = InjectedProperty.prototype; - var ComputedPropertyPrototype = _emberMetalComputed.ComputedProperty.prototype; - var AliasedPropertyPrototype = _emberMetalAlias.AliasedProperty.prototype; - - InjectedPropertyPrototype._super$Constructor = _emberMetalComputed.ComputedProperty; - - InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; - InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; - InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; -}); -enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { - 'use strict'; - - exports.instrument = instrument; - exports._instrumentStart = _instrumentStart; - exports.subscribe = subscribe; - exports.unsubscribe = unsubscribe; - exports.reset = reset; - - /** - The purpose of the Ember Instrumentation module is - to provide efficient, general-purpose instrumentation - for Ember. - - Subscribe to a listener by using `Ember.subscribe`: - - ```javascript - Ember.subscribe("render", { - before(name, timestamp, payload) { - - }, - - after(name, timestamp, payload) { - - } - }); - ``` - - If you return a value from the `before` callback, that same - value will be passed as a fourth parameter to the `after` - callback. - - Instrument a block of code by using `Ember.instrument`: - - ```javascript - Ember.instrument("render.handlebars", payload, function() { - // rendering logic - }, binding); - ``` - - Event names passed to `Ember.instrument` are namespaced - by periods, from more general to more specific. Subscribers - can listen for events by whatever level of granularity they - are interested in. - - In the above example, the event is `render.handlebars`, - and the subscriber listened for all events beginning with - `render`. It would receive callbacks for events named - `render`, `render.handlebars`, `render.container`, or - even `render.handlebars.layout`. - - @class Instrumentation - @namespace Ember - @static - @private - */ - var subscribers = []; - exports.subscribers = subscribers; - var cache = {}; - - function populateListeners(name) { - var listeners = []; - var subscriber = undefined; - - for (var i = 0; i < subscribers.length; i++) { - subscriber = subscribers[i]; - if (subscriber.regex.test(name)) { - listeners.push(subscriber.object); - } - } - - cache[name] = listeners; - return listeners; - } - - var time = (function () { - var perf = 'undefined' !== typeof window ? window.performance || {} : {}; - var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; - // fn.bind will be available in all the browsers that support the advanced window.performance... ;-) - return fn ? fn.bind(perf) : function () { - return +new Date(); - }; - })(); - - /** - Notifies event's subscribers, calls `before` and `after` hooks. - - @method instrument - @namespace Ember.Instrumentation - - @param {String} [name] Namespaced event name. - @param {Object} _payload - @param {Function} callback Function that you're instrumenting. - @param {Object} binding Context that instrument function is called with. - @private - */ - - function instrument(name, _payload, callback, binding) { - if (arguments.length <= 3 && typeof _payload === 'function') { - binding = callback; - callback = _payload; - _payload = undefined; - } - if (subscribers.length === 0) { - return callback.call(binding); - } - var payload = _payload || {}; - var finalizer = _instrumentStart(name, function () { - return payload; - }); - - if (finalizer) { - return withFinalizer(callback, finalizer, payload, binding); - } else { - return callback.call(binding); - } - } - - var flaggedInstrument = undefined; - if (false) { - exports.flaggedInstrument = flaggedInstrument = instrument; - } else { - exports.flaggedInstrument = flaggedInstrument = function (name, payload, callback) { - return callback(); - }; - } - exports.flaggedInstrument = flaggedInstrument; - - function withFinalizer(callback, finalizer, payload, binding) { - var result = undefined; - try { - result = callback.call(binding); - } catch (e) { - payload.exception = e; - result = payload; - } finally { - finalizer(); - return result; - } - } - - function NOOP() {} - - // private for now - - function _instrumentStart(name, _payload, _payloadParam) { - if (subscribers.length === 0) { - return NOOP; - } - - var listeners = cache[name]; - - if (!listeners) { - listeners = populateListeners(name); - } - - if (listeners.length === 0) { - return NOOP; - } - - var payload = _payload(_payloadParam); - - var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE; - var timeName = undefined; - if (STRUCTURED_PROFILE) { - timeName = name + ': ' + payload.object; - console.time(timeName); - } - - var beforeValues = new Array(listeners.length); - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - beforeValues[i] = listener.before(name, timestamp, payload); - } - - return function _instrumentEnd() { - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - if (typeof listener.after === 'function') { - listener.after(name, timestamp, payload, beforeValues[i]); - } - } - - if (STRUCTURED_PROFILE) { - console.timeEnd(timeName); - } - }; - } - - /** - Subscribes to a particular event or instrumented block of code. - - @method subscribe - @namespace Ember.Instrumentation - - @param {String} [pattern] Namespaced event name. - @param {Object} [object] Before and After hooks. - - @return {Subscriber} - @private - */ - - function subscribe(pattern, object) { - var paths = pattern.split('.'); - var path = undefined; - var regex = []; - - for (var i = 0; i < paths.length; i++) { - path = paths[i]; - if (path === '*') { - regex.push('[^\\.]*'); - } else { - regex.push(path); - } - } - - regex = regex.join('\\.'); - regex = regex + '(\\..*)?'; - - var subscriber = { - pattern: pattern, - regex: new RegExp('^' + regex + '$'), - object: object - }; - - subscribers.push(subscriber); - cache = {}; - - return subscriber; - } - - /** - Unsubscribes from a particular event or instrumented block of code. - - @method unsubscribe - @namespace Ember.Instrumentation - - @param {Object} [subscriber] - @private - */ - - function unsubscribe(subscriber) { - var index = undefined; - - for (var i = 0; i < subscribers.length; i++) { - if (subscribers[i] === subscriber) { - index = i; - } - } - - subscribers.splice(index, 1); - cache = {}; - } - - /** - Resets `Ember.Instrumentation` by flushing list of subscribers. - - @method reset - @namespace Ember.Instrumentation - @private - */ - - function reset() { - subscribers.length = 0; - cache = {}; - } -}); -enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, _emberMetalIs_empty) { - 'use strict'; - - exports.default = isBlank; - - /** - A value is blank if it is empty or a whitespace string. - - ```javascript - Ember.isBlank(); // true - Ember.isBlank(null); // true - Ember.isBlank(undefined); // true - Ember.isBlank(''); // true - Ember.isBlank([]); // true - Ember.isBlank('\n\t'); // true - Ember.isBlank(' '); // true - Ember.isBlank({}); // false - Ember.isBlank('\n\t Hello'); // false - Ember.isBlank('Hello world'); // false - Ember.isBlank([1,2,3]); // false - ``` - - @method isBlank - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.5.0 - @public - */ - - function isBlank(obj) { - return _emberMetalIs_empty.default(obj) || typeof obj === 'string' && obj.match(/\S/) === null; - } -}); -enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, _emberMetalProperty_get, _emberMetalIs_none) { - 'use strict'; - - exports.default = isEmpty; - - /** - Verifies that a value is `null` or an empty string, empty array, - or empty function. - - Constrains the rules on `Ember.isNone` by returning true for empty - string and empty arrays. - - ```javascript - Ember.isEmpty(); // true - Ember.isEmpty(null); // true - Ember.isEmpty(undefined); // true - Ember.isEmpty(''); // true - Ember.isEmpty([]); // true - Ember.isEmpty({}); // false - Ember.isEmpty('Adam Hawkins'); // false - Ember.isEmpty([0,1,2]); // false - Ember.isEmpty('\n\t'); // false - Ember.isEmpty(' '); // false - ``` - - @method isEmpty - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ - - function isEmpty(obj) { - var none = _emberMetalIs_none.default(obj); - if (none) { - return none; - } - - if (typeof obj.size === 'number') { - return !obj.size; - } - - var objectType = typeof obj; - - if (objectType === 'object') { - var size = _emberMetalProperty_get.get(obj, 'size'); - if (typeof size === 'number') { - return !size; - } - } - - if (typeof obj.length === 'number' && objectType !== 'function') { - return !obj.length; - } - - if (objectType === 'object') { - var _length = _emberMetalProperty_get.get(obj, 'length'); - if (typeof _length === 'number') { - return !_length; - } - } - - return false; - } -}); -enifed("ember-metal/is_none", ["exports"], function (exports) { - /** - Returns true if the passed value is null or undefined. This avoids errors - from JSLint complaining about use of ==, which can be technically - confusing. - - ```javascript - Ember.isNone(); // true - Ember.isNone(null); // true - Ember.isNone(undefined); // true - Ember.isNone(''); // false - Ember.isNone([]); // false - Ember.isNone(function() {}); // false - ``` - - @method isNone - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ - "use strict"; - - exports.default = isNone; - - function isNone(obj) { - return obj === null || obj === undefined; - } -}); -enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { - 'use strict'; - - exports.default = isPresent; - - /** - A value is present if it not `isBlank`. - - ```javascript - Ember.isPresent(); // false - Ember.isPresent(null); // false - Ember.isPresent(undefined); // false - Ember.isPresent(''); // false - Ember.isPresent(' '); // false - Ember.isPresent('\n\t'); // false - Ember.isPresent([]); // false - Ember.isPresent({ length: 0 }) // false - Ember.isPresent(false); // true - Ember.isPresent(true); // true - Ember.isPresent('string'); // true - Ember.isPresent(0); // true - Ember.isPresent(function() {}) // true - Ember.isPresent({}); // true - Ember.isPresent(false); // true - Ember.isPresent('\n\t Hello'); // true - Ember.isPresent([1,2,3]); // true - ``` - - @method isPresent - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.8.0 - @public - */ - - function isPresent(obj) { - return !_emberMetalIs_blank.default(obj); - } -}); -enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { - 'use strict'; - - exports.isProxy = isProxy; - - function isProxy(value) { - if (typeof value === 'object' && value) { - var meta = _emberMetalMeta.peekMeta(value); - return meta && meta.isProxy(); - } - - return false; - } -}); -enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; - - exports.Libraries = Libraries; - - /** - Helper class that allows you to register your library with Ember. - - Singleton created at `Ember.libraries`. - - @class Libraries - @constructor - @private - */ - - function Libraries() { - this._registry = []; - this._coreLibIndex = 0; - } - - Libraries.prototype = { - constructor: Libraries, - - _getLibraryByName: function (name) { - var libs = this._registry; - var count = libs.length; - - for (var i = 0; i < count; i++) { - if (libs[i].name === name) { - return libs[i]; - } - } - }, - - register: function (name, version, isCoreLibrary) { - var index = this._registry.length; - - if (!this._getLibraryByName(name)) { - if (isCoreLibrary) { - index = this._coreLibIndex++; - } - this._registry.splice(index, 0, { name: name, version: version }); - } else { - _emberMetalDebug.warn('Library "' + name + '" is already registered with Ember.', false, { id: 'ember-metal.libraries-register' }); - } - }, - - registerCoreLibrary: function (name, version) { - this.register(name, version, true); - }, - - deRegister: function (name) { - var lib = this._getLibraryByName(name); - var index = undefined; - - if (lib) { - index = this._registry.indexOf(lib); - this._registry.splice(index, 1); - } - } - }; - - if (false) { - Libraries.prototype.isRegistered = function (name) { - return !!this._getLibraryByName(name); - }; - } - - exports.default = new Libraries(); -}); -enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) { - /** - @module ember - @submodule ember-metal - */ - - /* - JavaScript (before ES6) does not have a Map implementation. Objects, - which are often used as dictionaries, may only have Strings as keys. - - Because Ember has a way to get a unique identifier for every object - via `Ember.guidFor`, we can implement a performant Map with arbitrary - keys. Because it is commonly used in low-level bookkeeping, Map is - implemented as a pure JavaScript object for performance. - - This implementation follows the current iteration of the ES6 proposal for - maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets), - with one exception: as we do not have the luxury of in-VM iteration, we implement a - forEach method for iteration. - - Map is mocked out to look like an Ember object, so you can do - `Ember.Map.create()` for symmetry with other Ember classes. - */ - 'use strict'; - - function missingFunction(fn) { - throw new TypeError(Object.prototype.toString.call(fn) + ' is not a function'); - } - - function missingNew(name) { - throw new TypeError('Constructor ' + name + ' requires \'new\''); - } - - function copyNull(obj) { - var output = new _emberUtils.EmptyObject(); - - for (var prop in obj) { - // hasOwnPropery is not needed because obj is new EmptyObject(); - output[prop] = obj[prop]; - } - - return output; - } - - function copyMap(original, newObject) { - var keys = original._keys.copy(); - var values = copyNull(original._values); - - newObject._keys = keys; - newObject._values = values; - newObject.size = original.size; - - return newObject; - } - - /** - This class is used internally by Ember and Ember Data. - Please do not use it at this time. We plan to clean it up - and add many tests soon. - - @class OrderedSet - @namespace Ember - @constructor - @private - */ - function OrderedSet() { - if (this instanceof OrderedSet) { - this.clear(); - this._silenceRemoveDeprecation = false; - } else { - missingNew('OrderedSet'); - } - } - - /** - @method create - @static - @return {Ember.OrderedSet} - @private - */ - OrderedSet.create = function () { - var Constructor = this; - - return new Constructor(); - }; - - OrderedSet.prototype = { - constructor: OrderedSet, - /** - @method clear - @private - */ - clear: function () { - this.presenceSet = new _emberUtils.EmptyObject(); - this.list = []; - this.size = 0; - }, - - /** - @method add - @param obj - @param guid (optional, and for internal use) - @return {Ember.OrderedSet} - @private - */ - add: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; - - if (presenceSet[guid] !== true) { - presenceSet[guid] = true; - this.size = list.push(obj); - } - - return this; - }, - - /** - @since 1.8.0 - @method delete - @param obj - @param _guid (optional and for internal use only) - @return {Boolean} - @private - */ - delete: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; - - if (presenceSet[guid] === true) { - delete presenceSet[guid]; - var index = list.indexOf(obj); - if (index > -1) { - list.splice(index, 1); - } - this.size = list.length; - return true; - } else { - return false; - } - }, - - /** - @method isEmpty - @return {Boolean} - @private - */ - isEmpty: function () { - return this.size === 0; - }, - - /** - @method has - @param obj - @return {Boolean} - @private - */ - has: function (obj) { - if (this.size === 0) { - return false; - } - - var guid = _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - - return presenceSet[guid] === true; - }, - - /** - @method forEach - @param {Function} fn - @param self - @private - */ - forEach: function (fn /*, ...thisArg*/) { - if (typeof fn !== 'function') { - missingFunction(fn); - } - - if (this.size === 0) { - return; - } - - var list = this.list; - - if (arguments.length === 2) { - for (var i = 0; i < list.length; i++) { - fn.call(arguments[1], list[i]); - } - } else { - for (var i = 0; i < list.length; i++) { - fn(list[i]); - } - } - }, - - /** - @method toArray - @return {Array} - @private - */ - toArray: function () { - return this.list.slice(); - }, - - /** - @method copy - @return {Ember.OrderedSet} - @private - */ - copy: function () { - var Constructor = this.constructor; - var set = new Constructor(); - - set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; - set.presenceSet = copyNull(this.presenceSet); - set.list = this.toArray(); - set.size = this.size; - - return set; - } - }; - - /** - A Map stores values indexed by keys. Unlike JavaScript's - default Objects, the keys of a Map can be any JavaScript - object. - - Internally, a Map has two data structures: - - 1. `keys`: an OrderedSet of all of the existing keys - 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)` - - When a key/value pair is added for the first time, we - add the key to the `keys` OrderedSet, and create or - replace an entry in `values`. When an entry is deleted, - we delete its entry in `keys` and `values`. - - @class Map - @namespace Ember - @private - @constructor - */ - function Map() { - if (this instanceof Map) { - this._keys = OrderedSet.create(); - this._keys._silenceRemoveDeprecation = true; - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - } else { - missingNew('Map'); - } - } - - /** - @method create - @static - @private - */ - Map.create = function () { - var Constructor = this; - return new Constructor(); - }; - - Map.prototype = { - constructor: Map, - - /** - This property will change as the number of objects in the map changes. - @since 1.8.0 - @property size - @type number - @default 0 - @private - */ - size: 0, - - /** - Retrieve the value associated with a given key. - @method get - @param {*} key - @return {*} the value associated with the key, or `undefined` - @private - */ - get: function (key) { - if (this.size === 0) { - return; - } - - var values = this._values; - var guid = _emberUtils.guidFor(key); - - return values[guid]; - }, - - /** - Adds a value to the map. If a value for the given key has already been - provided, the new value will replace the old value. - @method set - @param {*} key - @param {*} value - @return {Ember.Map} - @private - */ - set: function (key, value) { - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); - - // ensure we don't store -0 - var k = key === -0 ? 0 : key; - - keys.add(k, guid); - - values[guid] = value; - - this.size = keys.size; - - return this; - }, - - /** - Removes a value from the map for an associated key. - @since 1.8.0 - @method delete - @param {*} key - @return {Boolean} true if an item was removed, false otherwise - @private - */ - delete: function (key) { - if (this.size === 0) { - return false; - } - // don't use ES6 "delete" because it will be annoying - // to use in browsers that are not ES6 friendly; - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); - - if (keys.delete(key, guid)) { - delete values[guid]; - this.size = keys.size; - return true; - } else { - return false; - } - }, - - /** - Check whether a key is present. - @method has - @param {*} key - @return {Boolean} true if the item was present, false otherwise - @private - */ - has: function (key) { - return this._keys.has(key); - }, - - /** - Iterate over all the keys and values. Calls the function once - for each key, passing in value, key, and the map being iterated over, - in that order. - The keys are guaranteed to be iterated over in insertion order. - @method forEach - @param {Function} callback - @param {*} self if passed, the `this` value inside the - callback. By default, `this` is the map. - @private - */ - forEach: function (callback /*, ...thisArg*/) { - if (typeof callback !== 'function') { - missingFunction(callback); - } - - if (this.size === 0) { - return; - } - - var map = this; - var cb = undefined, - thisArg = undefined; - - if (arguments.length === 2) { - thisArg = arguments[1]; - cb = function (key) { - return callback.call(thisArg, map.get(key), key, map); - }; - } else { - cb = function (key) { - return callback(map.get(key), key, map); - }; - } - - this._keys.forEach(cb); - }, - - /** - @method clear - @private - */ - clear: function () { - this._keys.clear(); - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - }, - - /** - @method copy - @return {Ember.Map} - @private - */ - copy: function () { - return copyMap(this, new Map()); - } - }; - - /** - @class MapWithDefault - @namespace Ember - @extends Ember.Map - @private - @constructor - @param [options] - @param {*} [options.defaultValue] - */ - function MapWithDefault(options) { - this._super$constructor(); - this.defaultValue = options.defaultValue; - } - - /** - @method create - @static - @param [options] - @param {*} [options.defaultValue] - @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns - `Ember.MapWithDefault` otherwise returns `Ember.Map` - @private - */ - MapWithDefault.create = function (options) { - if (options) { - return new MapWithDefault(options); - } else { - return new Map(); - } - }; - - MapWithDefault.prototype = Object.create(Map.prototype); - MapWithDefault.prototype.constructor = MapWithDefault; - MapWithDefault.prototype._super$constructor = Map; - MapWithDefault.prototype._super$get = Map.prototype.get; - - /** - Retrieve the value associated with a given key. - - @method get - @param {*} key - @return {*} the value associated with the key, or the default value - @private - */ - MapWithDefault.prototype.get = function (key) { - var hasValue = this.has(key); - - if (hasValue) { - return this._super$get(key); - } else { - var defaultValue = this.defaultValue(key); - this.set(key, defaultValue); - return defaultValue; - } - }; - - /** - @method copy - @return {Ember.MapWithDefault} - @private - */ - MapWithDefault.prototype.copy = function () { - var Constructor = this.constructor; - return copyMap(this, new Constructor({ - defaultValue: this.defaultValue - })); - }; - - exports.default = Map; - exports.OrderedSet = OrderedSet; - exports.Map = Map; - exports.MapWithDefault = MapWithDefault; -}); -enifed('ember-metal/merge', ['exports'], function (exports) { - /** - Merge the contents of two objects together into the first object. - - ```javascript - Ember.merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' } - var a = { first: 'Yehuda' }; - var b = { last: 'Katz' }; - Ember.merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' } - ``` - - @method merge - @for Ember - @param {Object} original The object to merge into - @param {Object} updates The object to copy properties from - @return {Object} - @public - */ - 'use strict'; - - exports.default = merge; - - function merge(original, updates) { - if (!updates || typeof updates !== 'object') { - return original; - } - - var props = Object.keys(updates); - var prop = undefined; - - for (var i = 0; i < props.length; i++) { - prop = props[i]; - original[prop] = updates[prop]; - } - - return original; - } -}); -enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - exports.Meta = Meta; - exports.deleteMeta = deleteMeta; - exports.meta = meta; - - var counters = { - peekCalls: 0, - peekParentCalls: 0, - peekPrototypeWalks: 0, - setCalls: 0, - deleteCalls: 0, - metaCalls: 0, - metaInstantiated: 0 - }; - - /** - @module ember-metal - */ - - /* - This declares several meta-programmed members on the Meta class. Such - meta! - - In general, the `readable` variants will give you an object (if it - already exists) that you can read but should not modify. The - `writable` variants will give you a mutable object, and they will - create it if it didn't already exist. - - The following methods will get generated metaprogrammatically, and - I'm including them here for greppability: - - writableCache, readableCache, writeWatching, - peekWatching, clearWatching, writeMixins, - peekMixins, clearMixins, writeBindings, - peekBindings, clearBindings, writeValues, - peekValues, clearValues, writeDeps, forEachInDeps - writableChainWatchers, readableChainWatchers, writableChains, - readableChains, writableTag, readableTag, writableTags, - readableTags - */ - var members = { - cache: ownMap, - weak: ownMap, - watching: inheritedMap, - mixins: inheritedMap, - bindings: inheritedMap, - values: inheritedMap, - chainWatchers: ownCustomObject, - chains: inheritedCustomObject, - tag: ownCustomObject, - tags: ownMap - }; - - // FLAGS - var SOURCE_DESTROYING = 1 << 1; - var SOURCE_DESTROYED = 1 << 2; - var META_DESTROYED = 1 << 3; - var IS_PROXY = 1 << 4; - - if (true || false) { - members.lastRendered = ownMap; - members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds - } - - var memberNames = Object.keys(members); - var META_FIELD = '__ember_meta__'; - - function Meta(obj, parentMeta) { - _emberMetalDebug.runInDebug(function () { - return counters.metaInstantiated++; - }); - - this._cache = undefined; - this._weak = undefined; - this._watching = undefined; - this._mixins = undefined; - this._bindings = undefined; - this._values = undefined; - this._deps = undefined; - this._chainWatchers = undefined; - this._chains = undefined; - this._tag = undefined; - this._tags = undefined; - - // initial value for all flags right now is false - // see FLAGS const for detailed list of flags used - this._flags = 0; - - // used only internally - this.source = obj; - - // when meta(obj).proto === obj, the object is intended to be only a - // prototype and doesn't need to actually be observable itself - this.proto = undefined; - - // The next meta in our inheritance chain. We (will) track this - // explicitly instead of using prototypical inheritance because we - // have detailed knowledge of how each property should really be - // inherited, and we can optimize it much better than JS runtimes. - this.parent = parentMeta; - - if (true || false) { - this._lastRendered = undefined; - this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds - } - - this._initializeListeners(); - } - - Meta.prototype.isInitialized = function (obj) { - return this.proto !== obj; - }; - - var NODE_STACK = []; - - Meta.prototype.destroy = function () { - if (this.isMetaDestroyed()) { - return; - } - - // remove chainWatchers to remove circular references that would prevent GC - var node = undefined, - nodes = undefined, - key = undefined, - nodeObject = undefined; - node = this.readableChains(); - if (node) { - NODE_STACK.push(node); - // process tree - while (NODE_STACK.length > 0) { - node = NODE_STACK.pop(); - // push children - nodes = node._chains; - if (nodes) { - for (key in nodes) { - if (nodes[key] !== undefined) { - NODE_STACK.push(nodes[key]); - } - } - } - - // remove chainWatcher in node object - if (node._watching) { - nodeObject = node._object; - if (nodeObject) { - var foreignMeta = peekMeta(nodeObject); - // avoid cleaning up chain watchers when both current and - // foreign objects are being destroyed - // if both are being destroyed manual cleanup is not needed - // as they will be GC'ed and no non-destroyed references will - // be remaining - if (foreignMeta && !foreignMeta.isSourceDestroying()) { - _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); - } - } - } - } - } - - this.setMetaDestroyed(); - }; - - for (var _name in _emberMetalMeta_listeners.protoMethods) { - Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; - } - memberNames.forEach(function (name) { - return members[name](name, Meta); - }); - - Meta.prototype.isSourceDestroying = function isSourceDestroying() { - return (this._flags & SOURCE_DESTROYING) !== 0; - }; - - Meta.prototype.setSourceDestroying = function setSourceDestroying() { - this._flags |= SOURCE_DESTROYING; - }; - - Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { - return (this._flags & SOURCE_DESTROYED) !== 0; - }; - - Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { - this._flags |= SOURCE_DESTROYED; - }; - - Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { - return (this._flags & META_DESTROYED) !== 0; - }; - - Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { - this._flags |= META_DESTROYED; - }; - - Meta.prototype.isProxy = function isProxy() { - return (this._flags & IS_PROXY) !== 0; - }; - - Meta.prototype.setProxy = function setProxy() { - this._flags |= IS_PROXY; - }; - - // Implements a member that is a lazily created, non-inheritable - // POJO. - function ownMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function () { - return this._getOrCreateOwnMap(key); - }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; - }; - } - - Meta.prototype._getOrCreateOwnMap = function (key) { - var ret = this[key]; - if (!ret) { - ret = this[key] = new _emberUtils.EmptyObject(); - } - return ret; - }; - - // Implements a member that is a lazily created POJO with inheritable - // values. - function inheritedMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - - Meta.prototype['write' + capitalized] = function (subkey, value) { - _emberMetalDebug.assert('Cannot call write' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var map = this._getOrCreateOwnMap(key); - map[subkey] = value; - }; - - Meta.prototype['peek' + capitalized] = function (subkey) { - return this._findInherited(key, subkey); - }; - - Meta.prototype['forEach' + capitalized] = function (fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - for (var _key in map) { - if (!seen[_key]) { - seen[_key] = true; - fn(_key, map[_key]); - } - } - } - pointer = pointer.parent; - } - }; - - Meta.prototype['clear' + capitalized] = function () { - _emberMetalDebug.assert('Cannot call clear' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - this[key] = undefined; - }; - - Meta.prototype['deleteFrom' + capitalized] = function (subkey) { - delete this._getOrCreateOwnMap(key)[subkey]; - }; - - Meta.prototype['hasIn' + capitalized] = function (subkey) { - return this._findInherited(key, subkey) !== undefined; - }; - } - - Meta.prototype._getInherited = function (key) { - var pointer = this; - while (pointer !== undefined) { - if (pointer[key]) { - return pointer[key]; - } - pointer = pointer.parent; - } - }; - - Meta.prototype._findInherited = function (key, subkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var value = map[subkey]; - if (value !== undefined) { - return value; - } - } - pointer = pointer.parent; - } - }; - - var UNDEFINED = _emberUtils.symbol('undefined'); - - exports.UNDEFINED = UNDEFINED; - // Implements a member that provides a lazily created map of maps, - // with inheritance at both levels. - Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { - _emberMetalDebug.assert('Cannot call writeDeps after the object is destroyed.', !this.isMetaDestroyed()); - - var outerMap = this._getOrCreateOwnMap('_deps'); - var innerMap = outerMap[subkey]; - if (!innerMap) { - innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); - } - innerMap[itemkey] = value; - }; - - Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer._deps; - if (map) { - var value = map[subkey]; - if (value) { - if (value[itemkey] !== undefined) { - return value[itemkey]; - } - } - } - pointer = pointer.parent; - } - }; - - Meta.prototype.hasDeps = function hasDeps(subkey) { - var pointer = this; - while (pointer !== undefined) { - if (pointer._deps && pointer._deps[subkey]) { - return true; - } - pointer = pointer.parent; - } - return false; - }; - - Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { - return this._forEachIn('_deps', subkey, fn); - }; - - Meta.prototype._forEachIn = function (key, subkey, fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - var calls = []; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var innerMap = map[subkey]; - if (innerMap) { - for (var innerKey in innerMap) { - if (!seen[innerKey]) { - seen[innerKey] = true; - calls.push([innerKey, innerMap[innerKey]]); - } - } - } - } - pointer = pointer.parent; - } - for (var i = 0; i < calls.length; i++) { - var _calls$i = calls[i]; - var innerKey = _calls$i[0]; - var value = _calls$i[1]; - - fn(innerKey, value); - } - }; - - // Implements a member that provides a non-heritable, lazily-created - // object using the method you provide. - function ownCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { - _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var ret = this[key]; - if (!ret) { - ret = this[key] = create(this.source); - } - return ret; - }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; - }; - } - - // Implements a member that provides an inheritable, lazily-created - // object using the method you provide. We will derived children from - // their parents by calling your object's `copy()` method. - function inheritedCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { - _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - - var ret = this[key]; - if (!ret) { - if (this.parent) { - ret = this[key] = this.parent['writable' + capitalized](create).copy(this.source); - } else { - ret = this[key] = create(this.source); - } - } - return ret; - }; - Meta.prototype['readable' + capitalized] = function () { - return this._getInherited(key); - }; - } - - function memberProperty(name) { - return '_' + name; - } - - // there's a more general-purpose capitalize in ember-runtime, but we - // don't want to make ember-metal depend on ember-runtime. - function capitalize(name) { - return name.replace(/^\w/, function (m) { - return m.toUpperCase(); - }); - } - - var META_DESC = { - writable: true, - configurable: true, - enumerable: false, - value: null - }; - - exports.META_DESC = META_DESC; - var EMBER_META_PROPERTY = { - name: META_FIELD, - descriptor: META_DESC - }; - - if (true) { - Meta.prototype.readInheritedValue = function (key, subkey) { - var internalKey = '_' + key; - - var pointer = this; - - while (pointer !== undefined) { - var map = pointer[internalKey]; - if (map) { - var value = map[subkey]; - if (value !== undefined || subkey in map) { - return map[subkey]; - } - } - pointer = pointer.parent; - } - - return UNDEFINED; - }; - - Meta.prototype.writeValue = function (obj, key, value) { - var descriptor = _emberUtils.lookupDescriptor(obj, key); - var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - - if (isMandatorySetter) { - this.writeValues(key, value); - } else { - obj[key] = value; - } - }; - } - - var HAS_NATIVE_WEAKMAP = (function () { - // detect if `WeakMap` is even present - var hasWeakMap = typeof WeakMap === 'function'; - if (!hasWeakMap) { - return false; - } - - var instance = new WeakMap(); - // use `Object`'s `.toString` directly to prevent us from detecting - // polyfills as native weakmaps - return Object.prototype.toString.call(instance) === '[object WeakMap]'; - })(); - - var setMeta = undefined, - peekMeta = undefined; - - // choose the one appropriate for given platform - if (HAS_NATIVE_WEAKMAP) { - (function () { - var getPrototypeOf = Object.getPrototypeOf; - var metaStore = new WeakMap(); - - exports.setMeta = setMeta = function WeakMap_setMeta(obj, meta) { - _emberMetalDebug.runInDebug(function () { - return counters.setCalls++; - }); - metaStore.set(obj, meta); - }; - - exports.peekMeta = peekMeta = function WeakMap_peekMeta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.peekCalls++; - }); - - return metaStore.get(obj); - }; - - exports.peekMeta = peekMeta = function WeakMap_peekParentMeta(obj) { - var pointer = obj; - var meta = undefined; - while (pointer) { - meta = metaStore.get(pointer); - // jshint loopfunc:true - _emberMetalDebug.runInDebug(function () { - return counters.peekCalls++; - }); - // stop if we find a `null` value, since - // that means the meta was deleted - // any other truthy value is a "real" meta - if (meta === null || meta) { - return meta; - } - - pointer = getPrototypeOf(pointer); - _emberMetalDebug.runInDebug(function () { - return counters.peakPrototypeWalks++; - }); - } - }; - })(); - } else { - exports.setMeta = setMeta = function Fallback_setMeta(obj, meta) { - // if `null` already, just set it to the new value - // otherwise define property first - if (obj[META_FIELD] !== null) { - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(EMBER_META_PROPERTY); - } else { - Object.defineProperty(obj, META_FIELD, META_DESC); - } - } - - obj[META_FIELD] = meta; - }; - - exports.peekMeta = peekMeta = function Fallback_peekMeta(obj) { - return obj[META_FIELD]; - }; - } - - function deleteMeta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.deleteCalls++; - }); - - var meta = peekMeta(obj); - if (meta) { - meta.destroy(); - } - } - - /** - Retrieves the meta hash for an object. If `writable` is true ensures the - hash is writable for this object as well. - - The meta object contains information about computed property descriptors as - well as any watched properties and other information. You generally will - not access this information directly but instead work with higher level - methods that manipulate this hash indirectly. - - @method meta - @for Ember - @private - - @param {Object} obj The object to retrieve meta for - @param {Boolean} [writable=true] Pass `false` if you do not intend to modify - the meta hash, allowing the method to avoid making an unnecessary copy. - @return {Object} the meta hash for an object - */ - - function meta(obj) { - _emberMetalDebug.runInDebug(function () { - return counters.metaCalls++; - }); - - var maybeMeta = peekMeta(obj); - var parent = undefined; - - // remove this code, in-favor of explicit parent - if (maybeMeta) { - if (maybeMeta.source === obj) { - return maybeMeta; - } - parent = maybeMeta; - } - - var newMeta = new Meta(obj, parent); - setMeta(obj, newMeta); - return newMeta; - } - - exports.peekMeta = peekMeta; - exports.setMeta = setMeta; - exports.counters = counters; -}); -enifed('ember-metal/meta_listeners', ['exports'], function (exports) { - /* - When we render a rich template hierarchy, the set of events that - *might* happen tends to be much larger than the set of events that - actually happen. This implies that we should make listener creation & - destruction cheap, even at the cost of making event dispatch more - expensive. - - Thus we store a new listener with a single push and no new - allocations, without even bothering to do deduplication -- we can - save that for dispatch time, if an event actually happens. - */ - - /* listener flags */ - 'use strict'; - - var ONCE = 1; - exports.ONCE = ONCE; - var SUSPENDED = 2; - - exports.SUSPENDED = SUSPENDED; - var protoMethods = { - - addToListeners: function (eventName, target, method, flags) { - if (!this._listeners) { - this._listeners = []; - } - this._listeners.push(eventName, target, method, flags); - }, - - _finalizeListeners: function () { - if (this._listenersFinalized) { - return; - } - if (!this._listeners) { - this._listeners = []; - } - var pointer = this.parent; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - this._listeners = this._listeners.concat(listeners); - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - this._listenersFinalized = true; - }, - - removeFromListeners: function (eventName, target, method, didRemove) { - var pointer = this; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = listeners.length - 4; index >= 0; index -= 4) { - if (listeners[index] === eventName && (!method || listeners[index + 1] === target && listeners[index + 2] === method)) { - if (pointer === this) { - // we are modifying our own list, so we edit directly - if (typeof didRemove === 'function') { - didRemove(eventName, target, listeners[index + 2]); - } - listeners.splice(index, 4); - } else { - // we are trying to remove an inherited listener, so we do - // just-in-time copying to detach our own listeners from - // our inheritance chain. - this._finalizeListeners(); - return this.removeFromListeners(eventName, target, method); - } - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - }, - - matchingListeners: function (eventName) { - var pointer = this; - var result = []; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - if (listeners[index] === eventName) { - pushUniqueListener(result, listeners, index); - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - var sus = this._suspendedListeners; - if (sus) { - for (var susIndex = 0; susIndex < sus.length - 2; susIndex += 3) { - if (eventName === sus[susIndex]) { - for (var resultIndex = 0; resultIndex < result.length - 2; resultIndex += 3) { - if (result[resultIndex] === sus[susIndex + 1] && result[resultIndex + 1] === sus[susIndex + 2]) { - result[resultIndex + 2] |= SUSPENDED; - } - } - } - } - } - return result; - }, - - suspendListeners: function (eventNames, target, method, callback) { - var sus = this._suspendedListeners; - if (!sus) { - sus = this._suspendedListeners = []; - } - for (var i = 0; i < eventNames.length; i++) { - sus.push(eventNames[i], target, method); - } - try { - return callback.call(target); - } finally { - if (sus.length === eventNames.length) { - this._suspendedListeners = undefined; - } else { - for (var i = sus.length - 3; i >= 0; i -= 3) { - if (sus[i + 1] === target && sus[i + 2] === method && eventNames.indexOf(sus[i]) !== -1) { - sus.splice(i, 3); - } - } - } - } - }, - - watchedEvents: function () { - var pointer = this; - var names = {}; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - names[listeners[index]] = true; - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - return Object.keys(names); - }, - - _initializeListeners: function () { - this._listeners = undefined; - this._listenersFinalized = undefined; - this._suspendedListeners = undefined; - } - }; - - exports.protoMethods = protoMethods; - function pushUniqueListener(destination, source, index) { - var target = source[index + 1]; - var method = source[index + 2]; - for (var destinationIndex = 0; destinationIndex < destination.length - 2; destinationIndex += 3) { - if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { - return; - } - } - destination.push(target, method, source[index + 3]); - } -}); -enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-metal - */ - exports.detectBinding = detectBinding; - exports.mixin = mixin; - exports.default = Mixin; - exports.hasUnprocessedMixins = hasUnprocessedMixins; - exports.clearUnprocessedMixins = clearUnprocessedMixins; - exports.required = required; - exports.aliasMethod = aliasMethod; - exports.observer = observer; - exports._immediateObserver = _immediateObserver; - exports._beforeObserver = _beforeObserver; - - function ROOT() {} - ROOT.__hasSuper = false; - - var a_slice = [].slice; - - function isMethod(obj) { - return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; - } - - var CONTINUE = {}; - - function mixinProperties(mixinsMeta, mixin) { - var guid = undefined; - - if (mixin instanceof Mixin) { - guid = _emberUtils.guidFor(mixin); - if (mixinsMeta.peekMixins(guid)) { - return CONTINUE; - } - mixinsMeta.writeMixins(guid, mixin); - return mixin.properties; - } else { - return mixin; // apply anonymous mixin properties - } - } - - function concatenatedMixinProperties(concatProp, props, values, base) { - var concats = undefined; - - // reset before adding each new mixin to pickup concats from previous - concats = values[concatProp] || base[concatProp]; - if (props[concatProp]) { - concats = concats ? concats.concat(props[concatProp]) : props[concatProp]; - } - - return concats; - } - - function giveDescriptorSuper(meta, key, property, values, descs, base) { - var superProperty = undefined; - - // Computed properties override methods, and do not call super to them - if (values[key] === undefined) { - // Find the original descriptor in a parent mixin - superProperty = descs[key]; - } - - // If we didn't find the original descriptor in a parent mixin, find - // it on the original object. - if (!superProperty) { - var possibleDesc = base[key]; - var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - superProperty = superDesc; - } - - if (superProperty === undefined || !(superProperty instanceof _emberMetalComputed.ComputedProperty)) { - return property; - } - - // Since multiple mixins may inherit from the same parent, we need - // to clone the computed property so that other mixins do not receive - // the wrapped version. - property = Object.create(property); - property._getter = _emberUtils.wrap(property._getter, superProperty._getter); - if (superProperty._setter) { - if (property._setter) { - property._setter = _emberUtils.wrap(property._setter, superProperty._setter); - } else { - property._setter = superProperty._setter; - } - } - - return property; - } - - function giveMethodSuper(obj, key, method, values, descs) { - var superMethod = undefined; - - // Methods overwrite computed properties, and do not call super to them. - if (descs[key] === undefined) { - // Find the original method in a parent mixin - superMethod = values[key]; - } - - // If we didn't find the original value in a parent mixin, find it in - // the original object - superMethod = superMethod || obj[key]; - - // Only wrap the new method if the original method was a function - if (superMethod === undefined || 'function' !== typeof superMethod) { - return method; - } - - return _emberUtils.wrap(method, superMethod); - } - - function applyConcatenatedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; - var ret = undefined; - - if (baseValue) { - if ('function' === typeof baseValue.concat) { - if (value === null || value === undefined) { - ret = baseValue; - } else { - ret = baseValue.concat(value); - } - } else { - ret = _emberUtils.makeArray(baseValue).concat(value); - } - } else { - ret = _emberUtils.makeArray(value); - } - - _emberMetalDebug.runInDebug(function () { - // it is possible to use concatenatedProperties with strings (which cannot be frozen) - // only freeze objects... - if (typeof ret === 'object' && ret !== null) { - // prevent mutating `concatenatedProperties` array after it is applied - Object.freeze(ret); - } - }); - - return ret; - } - - function applyMergedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; - - _emberMetalDebug.runInDebug(function () { - if (Array.isArray(value)) { - // use conditional to avoid stringifying every time - _emberMetalDebug.assert('You passed in `' + JSON.stringify(value) + '` as the value for `' + key + '` but `' + key + '` cannot be an Array', false); - } - }); - - if (!baseValue) { - return value; - } - - var newBase = _emberUtils.assign({}, baseValue); - var hasFunction = false; - - for (var prop in value) { - if (!value.hasOwnProperty(prop)) { - continue; - } - - var propValue = value[prop]; - if (isMethod(propValue)) { - // TODO: support for Computed Properties, etc? - hasFunction = true; - newBase[prop] = giveMethodSuper(obj, prop, propValue, baseValue, {}); - } else { - newBase[prop] = propValue; - } - } - - if (hasFunction) { - newBase._super = ROOT; - } - - return newBase; - } - - function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { - if (value instanceof _emberMetalProperties.Descriptor) { - if (value === REQUIRED && descs[key]) { - return CONTINUE; - } - - // Wrap descriptor function to implement - // _super() if needed - if (value._getter) { - value = giveDescriptorSuper(meta, key, value, values, descs, base); - } - - descs[key] = value; - values[key] = undefined; - } else { - if (concats && concats.indexOf(key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') { - value = applyConcatenatedProperties(base, key, value, values); - } else if (mergings && mergings.indexOf(key) >= 0) { - value = applyMergedProperties(base, key, value, values); - } else if (isMethod(value)) { - value = giveMethodSuper(base, key, value, values, descs); - } - - descs[key] = undefined; - values[key] = value; - } - } - - function mergeMixins(mixins, m, descs, values, base, keys) { - var currentMixin = undefined, - props = undefined, - key = undefined, - concats = undefined, - mergings = undefined; - - function removeKeys(keyName) { - delete descs[keyName]; - delete values[keyName]; - } - - for (var i = 0; i < mixins.length; i++) { - currentMixin = mixins[i]; - _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - - props = mixinProperties(m, currentMixin); - if (props === CONTINUE) { - continue; - } - - if (props) { - if (base.willMergeMixin) { - base.willMergeMixin(props); - } - concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); - mergings = concatenatedMixinProperties('mergedProperties', props, values, base); - - for (key in props) { - if (!props.hasOwnProperty(key)) { - continue; - } - keys.push(key); - addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings); - } - - // manually copy toString() because some JS engines do not enumerate it - if (props.hasOwnProperty('toString')) { - base.toString = props.toString; - } - } else if (currentMixin.mixins) { - mergeMixins(currentMixin.mixins, m, descs, values, base, keys); - if (currentMixin._without) { - currentMixin._without.forEach(removeKeys); - } - } - } - } - - function detectBinding(key) { - var length = key.length; - - return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; - } - - // warm both paths of above function - detectBinding('notbound'); - detectBinding('fooBinding'); - - function connectBindings(obj, m) { - // TODO Mixin.apply(instance) should disconnect binding if exists - m.forEachBindings(function (key, binding) { - if (binding) { - var to = key.slice(0, -7); // strip Binding off end - if (binding instanceof _emberMetalBinding.Binding) { - binding = binding.copy(); // copy prototypes' instance - binding.to(to); - } else { - // binding is string path - binding = new _emberMetalBinding.Binding(to, binding); - } - binding.connect(obj); - obj[key] = binding; - } - }); - // mark as applied - m.clearBindings(); - } - - function finishPartial(obj, m) { - connectBindings(obj, m || _emberMetalMeta.meta(obj)); - return obj; - } - - function followAlias(obj, desc, m, descs, values) { - var altKey = desc.methodName; - var value = undefined; - var possibleDesc = undefined; - if (descs[altKey] || values[altKey]) { - value = values[altKey]; - desc = descs[altKey]; - } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - value = undefined; - } else { - desc = undefined; - value = obj[altKey]; - } - - return { desc: desc, value: value }; - } - - function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { - var paths = observerOrListener[pathsKey]; - - if (paths) { - for (var i = 0; i < paths.length; i++) { - updateMethod(obj, paths[i], null, key); - } - } - } - - function replaceObserversAndListeners(obj, key, observerOrListener) { - var prev = obj[key]; - - if ('function' === typeof prev) { - updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _emberMetalObserver._removeBeforeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_observes__', _emberMetalObserver.removeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_listens__', _emberMetalEvents.removeListener); - } - - if ('function' === typeof observerOrListener) { - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', _emberMetalObserver._addBeforeObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', _emberMetalObserver.addObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', _emberMetalEvents.addListener); - } - } - - function applyMixin(obj, mixins, partial) { - var descs = {}; - var values = {}; - var m = _emberMetalMeta.meta(obj); - var keys = []; - var key = undefined, - value = undefined, - desc = undefined; - - obj._super = ROOT; - - // Go through all mixins and hashes passed in, and: - // - // * Handle concatenated properties - // * Handle merged properties - // * Set up _super wrapping if necessary - // * Set up computed property descriptors - // * Copying `toString` in broken browsers - mergeMixins(mixins, m, descs, values, obj, keys); - - for (var i = 0; i < keys.length; i++) { - key = keys[i]; - if (key === 'constructor' || !values.hasOwnProperty(key)) { - continue; - } - - desc = descs[key]; - value = values[key]; - - if (desc === REQUIRED) { - continue; - } - - while (desc && desc instanceof Alias) { - var followed = followAlias(obj, desc, m, descs, values); - desc = followed.desc; - value = followed.value; - } - - if (desc === undefined && value === undefined) { - continue; - } - - replaceObserversAndListeners(obj, key, value); - - if (detectBinding(key)) { - m.writeBindings(key, value); - } - - _emberMetalProperties.defineProperty(obj, key, desc, value, m); - } - - if (!partial) { - // don't apply to prototype - finishPartial(obj, m); - } - - return obj; - } - - /** - @method mixin - @for Ember - @param obj - @param mixins* - @return obj - @private - */ - - function mixin(obj) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - applyMixin(obj, args, false); - return obj; - } - - /** - The `Ember.Mixin` class allows you to create mixins, whose properties can be - added to other classes. For instance, - - ```javascript - const EditableMixin = Ember.Mixin.create({ - edit() { - console.log('starting to edit'); - this.set('isEditing', true); - }, - isEditing: false - }); - - // Mix mixins into classes by passing them as the first arguments to - // `.extend.` - const Comment = Ember.Object.extend(EditableMixin, { - post: null - }); - - let comment = Comment.create(post: somePost); - comment.edit(); // outputs 'starting to edit' - ``` - - Note that Mixins are created with `Ember.Mixin.create`, not - `Ember.Mixin.extend`. - - Note that mixins extend a constructor's prototype so arrays and object literals - defined as properties will be shared amongst objects that implement the mixin. - If you want to define a property in a mixin that is not shared, you can define - it either as a computed property or have it be created on initialization of the object. - - ```javascript - // filters array will be shared amongst any object implementing mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.A() - }); - - // filters will be a separate array for every object implementing the mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.computed(function() { - return Ember.A(); - }) - }); - - // filters will be created as a separate array during the object's initialization - const Filterable = Ember.Mixin.create({ - init() { - this._super(...arguments); - this.set("filters", Ember.A()); - } - }); - ``` - - @class Mixin - @namespace Ember - @public - */ - - function Mixin(args, properties) { - this.properties = properties; - - var length = args && args.length; - - if (length > 0) { - var m = new Array(length); - - for (var i = 0; i < length; i++) { - var x = args[i]; - if (x instanceof Mixin) { - m[i] = x; - } else { - m[i] = new Mixin(undefined, x); - } - } - - this.mixins = m; - } else { - this.mixins = undefined; - } - this.ownerConstructor = undefined; - this._without = undefined; - this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; - _emberMetalDebug.debugSeal(this); - } - - Mixin._apply = applyMixin; - - Mixin.applyPartial = function (obj) { - var args = a_slice.call(arguments, 1); - return applyMixin(obj, args, true); - }; - - Mixin.finishPartial = finishPartial; - - var unprocessedFlag = false; - - function hasUnprocessedMixins() { - return unprocessedFlag; - } - - function clearUnprocessedMixins() { - unprocessedFlag = false; - } - - /** - @method create - @static - @param arguments* - @public - */ - Mixin.create = function () { - // ES6TODO: this relies on a global state? - unprocessedFlag = true; - var M = this; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return new M(args, undefined); - }; - - var MixinPrototype = Mixin.prototype; - - /** - @method reopen - @param arguments* - @private - */ - MixinPrototype.reopen = function () { - var currentMixin = undefined; - - if (this.properties) { - currentMixin = new Mixin(undefined, this.properties); - this.properties = undefined; - this.mixins = [currentMixin]; - } else if (!this.mixins) { - this.mixins = []; - } - - var mixins = this.mixins; - var idx = undefined; - - for (idx = 0; idx < arguments.length; idx++) { - currentMixin = arguments[idx]; - _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - - if (currentMixin instanceof Mixin) { - mixins.push(currentMixin); - } else { - mixins.push(new Mixin(undefined, currentMixin)); - } - } - - return this; - }; - - /** - @method apply - @param obj - @return applied object - @private - */ - MixinPrototype.apply = function (obj) { - return applyMixin(obj, [this], false); - }; - - MixinPrototype.applyPartial = function (obj) { - return applyMixin(obj, [this], true); - }; - - MixinPrototype.toString = Object.toString; - - function _detect(curMixin, targetMixin, seen) { - var guid = _emberUtils.guidFor(curMixin); - - if (seen[guid]) { - return false; - } - seen[guid] = true; - - if (curMixin === targetMixin) { - return true; - } - var mixins = curMixin.mixins; - var loc = mixins ? mixins.length : 0; - while (--loc >= 0) { - if (_detect(mixins[loc], targetMixin, seen)) { - return true; - } - } - return false; - } - - /** - @method detect - @param obj - @return {Boolean} - @private - */ - MixinPrototype.detect = function (obj) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - if (obj instanceof Mixin) { - return _detect(obj, this, {}); - } - var m = _emberMetalMeta.peekMeta(obj); - if (!m) { - return false; - } - return !!m.peekMixins(_emberUtils.guidFor(this)); - }; - - MixinPrototype.without = function () { - var ret = new Mixin([this]); - - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - ret._without = args; - return ret; - }; - - function _keys(ret, mixin, seen) { - if (seen[_emberUtils.guidFor(mixin)]) { - return; - } - seen[_emberUtils.guidFor(mixin)] = true; - - if (mixin.properties) { - 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); - }); - } - } - - MixinPrototype.keys = function () { - var keys = {}; - var seen = {}; - - _keys(keys, this, seen); - var ret = Object.keys(keys); - return ret; - }; - - _emberMetalDebug.debugSeal(MixinPrototype); - - // returns the mixins currently applied to the specified object - // TODO: Make Ember.mixin - Mixin.mixins = function (obj) { - var m = _emberMetalMeta.peekMeta(obj); - var ret = []; - if (!m) { - return ret; - } - - m.forEachMixins(function (key, currentMixin) { - // skip primitive mixins since these are always anonymous - if (!currentMixin.properties) { - ret.push(currentMixin); - } - }); - - return ret; - }; - - var REQUIRED = new _emberMetalProperties.Descriptor(); - REQUIRED.toString = function () { - return '(Required Property)'; - }; - - /** - Denotes a required property for a mixin - - @method required - @for Ember - @private - */ - - function required() { - _emberMetalDebug.deprecate('Ember.required is deprecated as its behavior is inconsistent and unreliable.', false, { id: 'ember-metal.required', until: '3.0.0' }); - return REQUIRED; - } - - function Alias(methodName) { - this.isDescriptor = true; - this.methodName = methodName; - } - - Alias.prototype = new _emberMetalProperties.Descriptor(); - - /** - Makes a method available via an additional name. - - ```javascript - App.Person = Ember.Object.extend({ - name: function() { - return 'Tomhuda Katzdale'; - }, - moniker: Ember.aliasMethod('name') - }); - - let goodGuy = App.Person.create(); - - goodGuy.name(); // 'Tomhuda Katzdale' - goodGuy.moniker(); // 'Tomhuda Katzdale' - ``` - - @method aliasMethod - @for Ember - @param {String} methodName name of the method to alias - @public - */ - - function aliasMethod(methodName) { - return new Alias(methodName); - } - - // .......................................................... - // OBSERVER HELPER - // - - /** - Specify a method that observes property changes. - - ```javascript - Ember.Object.extend({ - valueObserver: Ember.observer('value', function() { - // Executes whenever the "value" property changes - }) - }); - ``` - - Also available as `Function.prototype.observes` if prototype extensions are - enabled. - - @method observer - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func - @public - */ - - function observer() { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - _emberMetalDebug.deprecate('Passing the dependentKeys after the callback function in Ember.observer is deprecated. Ensure the callback function is the last argument.', false, { id: 'ember-metal.observer-argument-order', until: '3.0.0' }); - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('Ember.observer called without a function'); - } - - func.__ember_observes__ = paths; - return func; - } - - /** - Specify a method that observes property changes. - - ```javascript - Ember.Object.extend({ - valueObserver: Ember.immediateObserver('value', function() { - // Executes whenever the "value" property changes - }) - }); - ``` - - In the future, `Ember.observer` may become asynchronous. In this event, - `Ember.immediateObserver` will maintain the synchronous behavior. - - Also available as `Function.prototype.observesImmediately` if prototype extensions are - enabled. - - @method _immediateObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @deprecated Use `Ember.observer` instead. - @return func - @private - */ - - function _immediateObserver() { - _emberMetalDebug.deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.', false, { id: 'ember-metal.immediate-observer', until: '3.0.0' }); - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - _emberMetalDebug.assert('Immediate observers must observe internal properties only, not properties on other objects.', typeof arg !== 'string' || arg.indexOf('.') === -1); - } - - return observer.apply(this, arguments); - } - - /** - When observers fire, they are called with the arguments `obj`, `keyName`. - - Note, `@each.property` observer is called per each add or replace of an element - and it's not called with a specific enumeration item. - - A `_beforeObserver` fires before a property changes. - - @method beforeObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func - @deprecated - @private - */ - - function _beforeObserver() { - for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { - args[_key5] = arguments[_key5]; - } - - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('_beforeObserver called without a function'); - } - - func.__ember_observesBefore__ = paths; - return func; - } - - exports.Mixin = Mixin; - exports.required = required; - exports.REQUIRED = REQUIRED; -}); -enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { - 'use strict'; - - exports.addObserver = addObserver; - exports.observersFor = observersFor; - exports.removeObserver = removeObserver; - exports._addBeforeObserver = _addBeforeObserver; - exports._suspendObserver = _suspendObserver; - exports._suspendObservers = _suspendObservers; - exports._removeBeforeObserver = _removeBeforeObserver; - - /** - @module ember-metal - */ - - var AFTER_OBSERVERS = ':change'; - var BEFORE_OBSERVERS = ':before'; - - function changeEvent(keyName) { - return keyName + AFTER_OBSERVERS; - } - - function beforeEvent(keyName) { - return keyName + BEFORE_OBSERVERS; - } - - /** - @method addObserver - @for Ember - @param obj - @param {String} _path - @param {Object|Function} target - @param {Function|String} [method] - @public - */ - - function addObserver(obj, _path, target, method) { - _emberMetalEvents.addListener(obj, changeEvent(_path), target, method); - _emberMetalWatching.watch(obj, _path); - - return this; - } - - function observersFor(obj, path) { - return _emberMetalEvents.listenersFor(obj, changeEvent(path)); - } - - /** - @method removeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @public - */ - - function removeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, changeEvent(path), target, method); - - return this; - } - - /** - @method _addBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _addBeforeObserver(obj, path, target, method) { - _emberMetalEvents.addListener(obj, beforeEvent(path), target, method); - _emberMetalWatching.watch(obj, path); - - return this; - } - - // Suspend observer during callback. - // - // This should only be used by the target of the observer - // while it is setting the observed path. - - function _suspendObserver(obj, path, target, method, callback) { - return _emberMetalEvents.suspendListener(obj, changeEvent(path), target, method, callback); - } - - function _suspendObservers(obj, paths, target, method, callback) { - var events = paths.map(changeEvent); - return _emberMetalEvents.suspendListeners(obj, events, target, method, callback); - } - - /** - @method removeBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _removeBeforeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, beforeEvent(path), target, method); - - return this; - } -}); -enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { - 'use strict'; - - exports.default = ObserverSet; - - /* - this.observerSet = { - [senderGuid]: { // variable name: `keySet` - [keyName]: listIndex - } - }, - this.observers = [ - { - sender: obj, - keyName: keyName, - eventName: eventName, - listeners: [ - [target, method, flags] - ] - }, - ... - ] - */ - - function ObserverSet() { - this.clear(); - } - - ObserverSet.prototype.add = function (sender, keyName, eventName) { - var observerSet = this.observerSet; - var observers = this.observers; - var senderGuid = _emberUtils.guidFor(sender); - var keySet = observerSet[senderGuid]; - var index = undefined; - - 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 = undefined, - observer = undefined, - sender = undefined; - this.clear(); - for (i = 0; i < observers.length; ++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; - exports.hasThis = hasThis; - exports.isPath = isPath; - exports.getFirstKey = getFirstKey; - exports.getTailPath = getTailPath; - - var IS_GLOBAL = /^[A-Z$]/; - var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; - var HAS_THIS = 'this.'; - - var isGlobalCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL.test(key); - }); - var isGlobalPathCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL_PATH.test(key); - }); - var hasThisCache = new _emberMetalCache.default(1000, function (key) { - return key.lastIndexOf(HAS_THIS, 0) === 0; - }); - var firstDotIndexCache = new _emberMetalCache.default(1000, function (key) { - return key.indexOf('.'); - }); - - var firstKeyCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index === -1) { - return path; - } else { - return path.slice(0, index); - } - }); - - var tailPathCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index !== -1) { - return path.slice(index + 1); - } - }); - - var caches = { - isGlobalCache: isGlobalCache, - isGlobalPathCache: isGlobalPathCache, - hasThisCache: hasThisCache, - firstDotIndexCache: firstDotIndexCache, - firstKeyCache: firstKeyCache, - tailPathCache: tailPathCache - }; - - exports.caches = caches; - - function isGlobal(path) { - return isGlobalCache.get(path); - } - - function isGlobalPath(path) { - return isGlobalPathCache.get(path); - } - - function hasThis(path) { - return hasThisCache.get(path); - } - - function isPath(path) { - return firstDotIndexCache.get(path) !== -1; - } - - function getFirstKey(path) { - return firstKeyCache.get(path); - } - - function getTailPath(path) { - return tailPathCache.get(path); - } -}); -enifed('ember-metal/properties', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/property_events'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperty_events) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.Descriptor = Descriptor; - exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; - exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; - exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; - exports.defineProperty = defineProperty; - - // .......................................................... - // DESCRIPTOR - // - - /** - Objects of this type can implement an interface to respond to requests to - get and set. The default implementation handles simple properties. - - @class Descriptor - @private - */ - - function Descriptor() { - this.isDescriptor = true; - } - - var REDEFINE_SUPPORTED = (function () { - // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 - var a = Object.create(Object.prototype, { - prop: { - configurable: true, - value: 1 - } - }); - - Object.defineProperty(a, 'prop', { - configurable: true, - value: 2 - }); - - return a.prop === 2; - })(); - // .......................................................... - // DEFINING PROPERTIES API - // - - function MANDATORY_SETTER_FUNCTION(name) { - function SETTER_FUNCTION(value) { - var m = _emberMetalMeta.peekMeta(this); - if (!m.isInitialized(this)) { - m.writeValues(name, value); - } else { - _emberMetalDebug.assert('You must use Ember.set() to set the `' + name + '` property (of ' + this + ') to `' + value + '`.', false); - } - } - - SETTER_FUNCTION.isMandatorySetter = true; - return SETTER_FUNCTION; - } - - function DEFAULT_GETTER_FUNCTION(name) { - return function GETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - return meta && meta.peekValues(name); - }; - } - - function INHERITING_GETTER_FUNCTION(name) { - function IGETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - var val = meta && meta.readInheritedValue('values', name); - - if (val === _emberMetalMeta.UNDEFINED) { - var proto = Object.getPrototypeOf(this); - return proto && proto[name]; - } else { - return val; - } - } - - IGETTER_FUNCTION.isInheritingGetter = true; - return IGETTER_FUNCTION; - } - - /** - NOTE: This is a low-level method used by other parts of the API. You almost - never want to call this method directly. Instead you should use - `Ember.mixin()` to define new properties. - - Defines a property on an object. This method works much like the ES5 - `Object.defineProperty()` method except that it can also accept computed - properties and other special descriptors. - - Normally this method takes only three parameters. However if you pass an - instance of `Descriptor` as the third param then you can pass an - optional value as the fourth parameter. This is often more efficient than - creating new descriptor hashes for each property. - - ## Examples - - ```javascript - // ES5 compatible mode - Ember.defineProperty(contact, 'firstName', { - writable: true, - configurable: false, - enumerable: true, - value: 'Charles' - }); - - // define a simple property - Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); - - // define a computed property - Ember.defineProperty(contact, 'fullName', Ember.computed('firstName', 'lastName', function() { - return this.firstName+' '+this.lastName; - })); - ``` - - @private - @method defineProperty - @for Ember - @param {Object} obj the object to define this property on. This may be a prototype. - @param {String} keyName the name of the property - @param {Descriptor} [desc] an instance of `Descriptor` (typically a - computed property) or an ES5 descriptor. - You must provide this or `data` but not both. - @param {*} [data] something other than a descriptor, that will - become the explicit value of this property. - */ - - function defineProperty(obj, keyName, desc, data, meta) { - var possibleDesc = undefined, - existingDesc = undefined, - watching = undefined, - value = undefined; - - if (!meta) { - meta = _emberMetalMeta.meta(obj); - } - var watchEntry = meta.peekWatching(keyName); - possibleDesc = obj[keyName]; - existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - watching = watchEntry !== undefined && watchEntry > 0; - - if (existingDesc) { - existingDesc.teardown(obj, keyName); - } - - if (desc instanceof Descriptor) { - value = desc; - if (true) { - if (watching) { - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: true, - writable: true, - value: value - }); - } else { - obj[keyName] = value; - } - } else { - obj[keyName] = value; - } - if (desc.setup) { - desc.setup(obj, keyName); - } - } else { - if (desc == null) { - value = data; - - if (true) { - if (watching) { - meta.writeValues(keyName, data); - - var defaultDescriptor = { - configurable: true, - enumerable: true, - set: MANDATORY_SETTER_FUNCTION(keyName), - get: DEFAULT_GETTER_FUNCTION(keyName) - }; - - if (REDEFINE_SUPPORTED) { - Object.defineProperty(obj, keyName, defaultDescriptor); - } else { - handleBrokenPhantomDefineProperty(obj, keyName, defaultDescriptor); - } - } else { - obj[keyName] = data; - } - } else { - obj[keyName] = data; - } - } else { - value = desc; - - // fallback to ES5 - Object.defineProperty(obj, keyName, desc); - } - } - - // if key is being watched, override chains that - // were initialized with the prototype - if (watching) { - _emberMetalProperty_events.overrideChains(obj, keyName, meta); - } - - // The `value` passed to the `didDefineProperty` hook is - // either the descriptor or data, whichever was passed. - if (obj.didDefineProperty) { - obj.didDefineProperty(obj, keyName, value); - } - - return this; - } - - function handleBrokenPhantomDefineProperty(obj, keyName, desc) { - // https://github.com/ariya/phantomjs/issues/11856 - Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); - Object.defineProperty(obj, keyName, desc); - } -}); -enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) { - 'use strict'; - - var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE'); - - exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; - var beforeObserverSet = new _emberMetalObserver_set.default(); - var observerSet = new _emberMetalObserver_set.default(); - var deferred = 0; - - // .......................................................... - // PROPERTY CHANGES - // - - /** - This function is called just before an object property is about to change. - It will notify any before observers and prepare caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyDidChange()` which you should call just - after the property value changes. - - @method propertyWillChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @return {void} - @private - */ - function propertyWillChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.willChange) { - desc.willChange(obj, keyName); - } - - if (watching) { - dependentKeysWillChange(obj, keyName, meta); - chainsWillChange(obj, keyName, meta); - notifyBeforeObservers(obj, keyName, meta); - } - } - - /** - This function is called just after an object property has changed. - It will notify any observers and clear caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyWillChange()` which you should call just - before the property value changes. - - @method propertyDidChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @param {Meta} meta The objects meta. - @return {void} - @private - */ - function propertyDidChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - // shouldn't this mean that we're watching this key? - if (desc && desc.didChange) { - desc.didChange(obj, keyName); - } - - if (watching) { - if (meta.hasDeps(keyName)) { - dependentKeysDidChange(obj, keyName, meta); - } - - chainsDidChange(obj, keyName, meta, false); - notifyObservers(obj, keyName, meta); - } - - if (obj[PROPERTY_DID_CHANGE]) { - obj[PROPERTY_DID_CHANGE](keyName); - } - - if (meta && meta.isSourceDestroying()) { - return; - } - - _emberMetalTags.markObjectAsDirty(meta, keyName); - - if (true || false) { - _emberMetalTransaction.assertNotRendered(obj, keyName, meta); - } - } - - var WILL_SEEN = undefined, - DID_SEEN = undefined; - // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) - function dependentKeysWillChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = WILL_SEEN; - var _top = !seen; - - if (_top) { - seen = WILL_SEEN = {}; - } - - iterDeps(propertyWillChange, obj, depKey, seen, meta); - - if (_top) { - WILL_SEEN = null; - } - } - } - - // called whenever a property has just changed to update dependent keys - function dependentKeysDidChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = DID_SEEN; - var _top2 = !seen; - - if (_top2) { - seen = DID_SEEN = {}; - } - - iterDeps(propertyDidChange, obj, depKey, seen, meta); - - if (_top2) { - DID_SEEN = null; - } - } - } - - function iterDeps(method, obj, depKey, seen, meta) { - var possibleDesc = undefined, - desc = undefined; - var guid = _emberUtils.guidFor(obj); - var current = seen[guid]; - - if (!current) { - current = seen[guid] = {}; - } - - if (current[depKey]) { - return; - } - - current[depKey] = true; - - meta.forEachInDeps(depKey, function (key, value) { - if (!value) { - return; - } - - possibleDesc = obj[key]; - desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc._suspended === obj) { - return; - } - - method(obj, key, meta); - }); - } - - function chainsWillChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, false, propertyWillChange); - } - } - - function chainsDidChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, true, propertyDidChange); - } - } - - function overrideChains(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - } - - /** - @method beginPropertyChanges - @chainable - @private - */ - function beginPropertyChanges() { - deferred++; - } - - /** - @method endPropertyChanges - @private - */ - function endPropertyChanges() { - deferred--; - if (deferred <= 0) { - beforeObserverSet.clear(); - observerSet.flush(); - } - } - - /** - Make a series of property changes together in an - exception-safe way. - - ```javascript - Ember.changeProperties(function() { - obj1.set('foo', mayBlowUpWhenSet); - obj2.set('bar', baz); - }); - ``` - - @method changeProperties - @param {Function} callback - @param [binding] - @private - */ - function changeProperties(callback, binding) { - beginPropertyChanges(); - try { - callback.call(binding); - } finally { - endPropertyChanges.call(binding); - } - } - - function notifyBeforeObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':before'; - var listeners = undefined, - added = undefined; - if (deferred) { - listeners = beforeObserverSet.add(obj, keyName, eventName); - added = _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName], added); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - function notifyObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':change'; - var listeners = undefined; - if (deferred) { - listeners = observerSet.add(obj, keyName, eventName); - _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - exports.propertyWillChange = propertyWillChange; - exports.propertyDidChange = propertyDidChange; - exports.overrideChains = overrideChains; - exports.beginPropertyChanges = beginPropertyChanges; - exports.endPropertyChanges = endPropertyChanges; - exports.changeProperties = changeProperties; -}); -enifed('ember-metal/property_get', ['exports', 'ember-metal/debug', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalPath_cache) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.get = get; - exports._getPath = _getPath; - exports.getWithDefault = getWithDefault; - - var ALLOWABLE_TYPES = { - object: true, - function: true, - string: true - }; - - // .......................................................... - // GET AND SET - // - // If we are on a platform that supports accessors we can use those. - // Otherwise simulate accessors by looking up the property directly on the - // object. - - /** - Gets the value of a property on an object. If the property is computed, - the function will be invoked. If the property is not defined but the - object implements the `unknownProperty` method then that will be invoked. - - ```javascript - Ember.get(obj, "name"); - ``` - - If you plan to run on IE8 and older browsers then you should use this - method anytime you want to retrieve a property on an object that you don't - know for sure is private. (Properties beginning with an underscore '_' - are considered private.) - - On all newer browsers, you only need to use this method to retrieve - properties if the property might not be defined on the object and you want - to respect the `unknownProperty` handler. Otherwise you can ignore this - method. - - Note that if the object itself is `undefined`, this method will throw - an error. - - @method get - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The property key to retrieve - @return {Object} the property value or `null`. - @public - */ - - function get(obj, keyName) { - _emberMetalDebug.assert('Get must be called with two arguments; an object and a property key', arguments.length === 2); - _emberMetalDebug.assert('Cannot call get with \'' + keyName + '\' on an undefined object.', obj !== undefined && obj !== null); - _emberMetalDebug.assert('The key provided to get must be a string, you passed ' + keyName, typeof keyName === 'string'); - _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); - _emberMetalDebug.assert('Cannot call `Ember.get` with an empty string', keyName !== ''); - - var value = obj[keyName]; - var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined; - var ret = undefined; - - if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) { - return _getPath(obj, keyName); - } - - if (desc) { - return desc.get(obj, keyName); - } else { - ret = value; - - if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { - return obj.unknownProperty(keyName); - } - - return ret; - } - } - - function _getPath(root, path) { - var obj = root; - var parts = path.split('.'); - - for (var i = 0; i < parts.length; i++) { - if (!isGettable(obj)) { - return undefined; - } - - obj = get(obj, parts[i]); - - if (obj && obj.isDestroyed) { - return undefined; - } - } - - return obj; - } - - function isGettable(obj) { - if (obj == null) { - return false; - } - - return ALLOWABLE_TYPES[typeof obj]; - } - - /** - Retrieves the value of a property from an Object, or a default value in the - case that the property returns `undefined`. - - ```javascript - Ember.getWithDefault(person, 'lastName', 'Doe'); - ``` - - @method getWithDefault - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public - */ - - function getWithDefault(root, key, defaultValue) { - var value = get(root, key); - - if (value === undefined) { - return defaultValue; - } - return value; - } - - exports.default = get; -}); -enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) { - 'use strict'; - - exports.set = set; - exports.trySet = trySet; - - /** - Sets the value of a property on an object, respecting computed properties - and notifying observers and other listeners of the change. If the - property is not defined but the object implements the `setUnknownProperty` - method then that will be invoked as well. - - ```javascript - Ember.set(obj, "name", value); - ``` - - @method set - @for Ember - @param {Object} obj The object to modify. - @param {String} keyName The property key to set - @param {Object} value The value to set - @return {Object} the passed value. - @public - */ - - function set(obj, keyName, value, tolerant) { - _emberMetalDebug.assert('Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false', arguments.length === 3 || arguments.length === 4); - _emberMetalDebug.assert('Cannot call set with \'' + keyName + '\' on an undefined object.', obj && typeof obj === 'object' || typeof obj === 'function'); - _emberMetalDebug.assert('The key provided to set must be a string, you passed ' + keyName, typeof keyName === 'string'); - _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); - _emberMetalDebug.assert('calling set on destroyed object: ' + _emberUtils.toString(obj) + '.' + keyName + ' = ' + _emberUtils.toString(value), !obj.isDestroyed); - - if (_emberMetalPath_cache.isPath(keyName)) { - return setPath(obj, keyName, value, tolerant); - } - - var meta = _emberMetalMeta.peekMeta(obj); - var possibleDesc = obj[keyName]; - - var desc = undefined, - currentValue = undefined; - if (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - } else { - currentValue = possibleDesc; - } - - if (desc) { - /* computed property */ - desc.set(obj, keyName, value); - } else if (obj.setUnknownProperty && currentValue === undefined && !(keyName in obj)) { - /* unknown property */ - _emberMetalDebug.assert('setUnknownProperty must be a function', typeof obj.setUnknownProperty === 'function'); - obj.setUnknownProperty(keyName, value); - } else if (currentValue === value) { - /* no change */ - return value; - } else { - _emberMetalProperty_events.propertyWillChange(obj, keyName); - - if (true) { - setWithMandatorySetter(meta, obj, keyName, value); - } else { - obj[keyName] = value; - } - - _emberMetalProperty_events.propertyDidChange(obj, keyName); - } - - return value; - } - - if (true) { - var setWithMandatorySetter = function (meta, obj, keyName, value) { - if (meta && meta.peekWatching(keyName) > 0) { - makeEnumerable(obj, keyName); - meta.writeValue(obj, keyName, value); - } else { - obj[keyName] = value; - } - }; - - var makeEnumerable = function (obj, key) { - var desc = Object.getOwnPropertyDescriptor(obj, key); - - if (desc && desc.set && desc.set.isMandatorySetter) { - desc.enumerable = true; - Object.defineProperty(obj, key, desc); - } - }; - } - - function setPath(root, path, value, tolerant) { - // get the last part of the path - var keyName = path.slice(path.lastIndexOf('.') + 1); - - // get the first part of the part - path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); - - // unless the path is this, look up the first part to - // get the root - if (path !== 'this') { - root = _emberMetalProperty_get._getPath(root, path); - } - - if (!keyName || keyName.length === 0) { - throw new _emberMetalError.default('Property set failed: You passed an empty path'); - } - - if (!root) { - if (tolerant) { - return; - } else { - throw new _emberMetalError.default('Property set failed: object in path "' + path + '" could not be found or was destroyed.'); - } - } - - return set(root, keyName, value); - } - - /** - Error-tolerant form of `Ember.set`. Will not blow up if any part of the - chain is `undefined`, `null`, or destroyed. - - This is primarily used when syncing bindings, which may try to update after - an object has been destroyed. - - @method trySet - @for Ember - @param {Object} root The object to modify. - @param {String} path The property path to set - @param {Object} value The value to set - @public - */ - - function trySet(root, path, value) { - return set(root, path, value, true); - } -}); -enifed("ember-metal/replace", ["exports"], function (exports) { - "use strict"; - - exports.default = replace; - var splice = Array.prototype.splice; - - function replace(array, idx, amt, objects) { - var args = [].concat(objects); - var ret = []; - // https://code.google.com/p/chromium/issues/detail?id=56588 - var size = 60000; - var start = idx; - var ends = amt; - var count = undefined, - chunk = undefined; - - while (args.length) { - count = ends > size ? size : ends; - if (count <= 0) { - count = 0; - } - - chunk = args.splice(0, size); - chunk = [start, count].concat(chunk); - - start += size; - ends -= count; - - ret = ret.concat(splice.apply(array, chunk)); - } - return ret; - } -}); -enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) { - 'use strict'; - - exports.default = run; - - function onBegin(current) { - run.currentRunLoop = current; - } - - function onEnd(current, next) { - run.currentRunLoop = next; - } - - var onErrorTarget = { - get onerror() { - return _emberMetalError_handler.getOnerror(); - }, - set onerror(handler) { - return _emberMetalError_handler.setOnerror(handler); - } - }; - - var backburner = new _backburner.default(['sync', 'actions', 'destroy'], { - GUID_KEY: _emberUtils.GUID_KEY, - sync: { - before: _emberMetalProperty_events.beginPropertyChanges, - after: _emberMetalProperty_events.endPropertyChanges - }, - defaultQueue: 'actions', - onBegin: onBegin, - onEnd: onEnd, - onErrorTarget: onErrorTarget, - onErrorMethod: 'onerror' - }); - - // .......................................................... - // run - this is ideally the only public API the dev sees - // - - /** - Runs the passed target and method inside of a RunLoop, ensuring any - deferred actions including bindings and views updates are flushed at the - end. - - Normally you should not need to invoke this method yourself. However if - you are implementing raw event handlers when interfacing with other - libraries or plugins, you should probably wrap all of your code inside this - call. - - ```javascript - run(function() { - // code to be executed within a RunLoop - }); - ``` - - @class run - @namespace Ember - @static - @constructor - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} return value from invoking the passed function. - @public - */ - - function run() { - return backburner.run.apply(backburner, arguments); - } - - /** - If no run-loop is present, it creates a new one. If a run loop is - present it will queue itself to run on the existing run-loops action - queue. - - Please note: This is not for normal usage, and should be used sparingly. - - If invoked when not within a run loop: - - ```javascript - run.join(function() { - // creates a new run-loop - }); - ``` - - Alternatively, if called within an existing run loop: - - ```javascript - run(function() { - // creates a new run-loop - run.join(function() { - // joins with the existing run-loop, and queues for invocation on - // the existing run-loops action queue. - }); - }); - ``` - - @method join - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} Return value from invoking the passed function. Please note, - when called within an existing loop, no return value is possible. - @public - */ - run.join = function () { - return backburner.join.apply(backburner, arguments); - }; - - /** - Allows you to specify which context to call the specified function in while - adding the execution of that function to the Ember run loop. This ability - makes this method a great way to asynchronously integrate third-party libraries - into your Ember application. - - `run.bind` takes two main arguments, the desired context and the function to - invoke in that context. Any additional arguments will be supplied as arguments - to the function that is passed in. - - Let's use the creation of a TinyMCE component as an example. Currently, - TinyMCE provides a setup configuration option we can use to do some processing - after the TinyMCE instance is initialized but before it is actually rendered. - We can use that setup option to do some additional setup for our component. - The component itself could look something like the following: - - ```javascript - App.RichTextEditorComponent = Ember.Component.extend({ - initializeTinyMCE: Ember.on('didInsertElement', function() { - tinymce.init({ - selector: '#' + this.$().prop('id'), - setup: Ember.run.bind(this, this.setupEditor) - }); - }), - - setupEditor: function(editor) { - this.set('editor', editor); - - editor.on('change', function() { - console.log('content changed!'); - }); - } - }); - ``` - - In this example, we use Ember.run.bind to bind the setupEditor method to the - context of the App.RichTextEditorComponent and to have the invocation of that - method be safely handled and executed by the Ember run loop. - - @method bind - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Function} returns a new function that will always have a particular context - @since 1.4.0 - @public - */ - run.bind = function () { - for (var _len = arguments.length, curried = Array(_len), _key = 0; _key < _len; _key++) { - curried[_key] = arguments[_key]; - } - - return function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return run.join.apply(run, curried.concat(args)); - }; - }; - - run.backburner = backburner; - run.currentRunLoop = null; - run.queues = backburner.queueNames; - - /** - Begins a new RunLoop. Any deferred actions invoked after the begin will - be buffered until you invoke a matching call to `run.end()`. This is - a lower-level way to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method begin - @return {void} - @public - */ - run.begin = function () { - backburner.begin(); - }; - - /** - Ends a RunLoop. This must be called sometime after you call - `run.begin()` to flush any deferred actions. This is a lower-level way - to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method end - @return {void} - @public - */ - run.end = function () { - backburner.end(); - }; - - /** - Array of named queues. This array determines the order in which queues - are flushed at the end of the RunLoop. You can define your own queues by - simply adding the queue name to this array. Normally you should not need - to inspect or modify this property. - - @property queues - @type Array - @default ['sync', 'actions', 'destroy'] - @private - */ - - /** - Adds the passed target/method and any optional arguments to the named - queue to be executed at the end of the RunLoop. If you have not already - started a RunLoop when calling this method one will be started for you - automatically. - - At the end of a RunLoop, any methods scheduled in this way will be invoked. - Methods will be invoked in an order matching the named queues defined in - the `run.queues` property. - - ```javascript - run.schedule('sync', this, function() { - // this will be executed in the first RunLoop queue, when bindings are synced - console.log('scheduled on sync queue'); - }); - - run.schedule('actions', this, function() { - // this will be executed in the 'actions' queue, after bindings have synced. - console.log('scheduled on actions queue'); - }); - - // Note the functions will be run in order based on the run queues order. - // Output would be: - // scheduled on sync queue - // scheduled on actions queue - ``` - - @method schedule - @param {String} queue The name of the queue to schedule against. - Default queues are 'sync' and 'actions' - @param {Object} [target] target object to use as the context when invoking a method. - @param {String|Function} method The method to invoke. If you pass a string it - will be resolved on the target object at the time the scheduled item is - invoked allowing you to change the target function. - @param {Object} [arguments*] Optional arguments to be passed to the queued method. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.schedule = function () /* queue, target, method */{ - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - - return backburner.schedule.apply(backburner, arguments); - }; - - // Used by global test teardown - run.hasScheduledTimers = function () { - return backburner.hasTimers(); - }; - - // Used by global test teardown - run.cancelTimers = function () { - backburner.cancelTimers(); - }; - - /** - Immediately flushes any events scheduled in the 'sync' queue. Bindings - use this queue so this method is a useful way to immediately force all - bindings in the application to sync. - - You should call this method anytime you need any changed state to propagate - throughout the app immediately without repainting the UI (which happens - in the later 'render' queue added by the `ember-views` package). - - ```javascript - run.sync(); - ``` - - @method sync - @return {void} - @private - */ - run.sync = function () { - if (backburner.currentInstance) { - backburner.currentInstance.queues.sync.flush(); - } - }; - - /** - Invokes the passed target/method and optional arguments after a specified - period of time. The last parameter of this method must always be a number - of milliseconds. - - You should use this method whenever you need to run some action after a - period of time instead of using `setTimeout()`. This method will ensure that - items that expire during the same script execution cycle all execute - together, which is often more efficient than using a real setTimeout. - - ```javascript - run.later(myContext, function() { - // code here will execute within a RunLoop in about 500ms with this == myContext - }, 500); - ``` - - @method later - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.later = function () /*target, method*/{ - return backburner.later.apply(backburner, arguments); - }; - - /** - Schedule a function to run one time during the current RunLoop. This is equivalent - to calling `scheduleOnce` with the "actions" queue. - - @method once - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.once = function () { - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - args.unshift('actions'); - return backburner.scheduleOnce.apply(backburner, args); - }; - - /** - Schedules a function to run one time in a given queue of the current RunLoop. - Calling this method with the same queue/target/method combination will have - no effect (past the initial call). - - Note that although you can pass optional arguments these will not be - considered when looking for duplicates. New arguments will replace previous - calls. - - ```javascript - function sayHi() { - console.log('hi'); - } - - run(function() { - run.scheduleOnce('afterRender', myContext, sayHi); - run.scheduleOnce('afterRender', myContext, sayHi); - // sayHi will only be executed once, in the afterRender queue of the RunLoop - }); - ``` - - Also note that passing an anonymous function to `run.scheduleOnce` will - not prevent additional calls with an identical anonymous function from - scheduling the items multiple times, e.g.: - - ```javascript - function scheduleIt() { - run.scheduleOnce('actions', myContext, function() { - console.log('Closure'); - }); - } - - scheduleIt(); - scheduleIt(); - - // "Closure" will print twice, even though we're using `run.scheduleOnce`, - // because the function we pass to it is anonymous and won't match the - // previously scheduled operation. - ``` - - Available queues, and their order, can be found at `run.queues` - - @method scheduleOnce - @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'. - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.scheduleOnce = function () /*queue, target, method*/{ - _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - return backburner.scheduleOnce.apply(backburner, arguments); - }; - - /** - Schedules an item to run from within a separate run loop, after - control has been returned to the system. This is equivalent to calling - `run.later` with a wait time of 1ms. - - ```javascript - run.next(myContext, function() { - // code to be executed in the next run loop, - // which will be scheduled after the current one - }); - ``` - - Multiple operations scheduled with `run.next` will coalesce - into the same later run loop, along with any other operations - scheduled by `run.later` that expire right around the same - time that `run.next` operations will fire. - - Note that there are often alternatives to using `run.next`. - For instance, if you'd like to schedule an operation to happen - after all DOM element operations have completed within the current - run loop, you can make use of the `afterRender` run loop queue (added - by the `ember-views` package, along with the preceding `render` queue - where all the DOM element operations happen). - - Example: - - ```javascript - export default Ember.Component.extend({ - didInsertElement() { - this._super(...arguments); - run.scheduleOnce('afterRender', this, 'processChildElements'); - }, - - processChildElements() { - // ... do something with component's child component - // elements after they've finished rendering, which - // can't be done within this component's - // `didInsertElement` hook because that gets run - // before the child elements have been added to the DOM. - } - }); - ``` - - One benefit of the above approach compared to using `run.next` is - that you will be able to perform DOM/CSS operations before unprocessed - elements are rendered to the screen, which may prevent flickering or - other artifacts caused by delaying processing until after rendering. - - The other major benefit to the above approach is that `run.next` - introduces an element of non-determinism, which can make things much - harder to test, due to its reliance on `setTimeout`; it's much harder - to guarantee the order of scheduled operations when they are scheduled - outside of the current run loop, i.e. with `run.next`. - - @method next - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.next = function () { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - args.push(1); - return backburner.later.apply(backburner, args); - }; - - /** - Cancels a scheduled item. Must be a value returned by `run.later()`, - `run.once()`, `run.scheduleOnce()`, `run.next()`, `run.debounce()`, or - `run.throttle()`. - - ```javascript - let runNext = run.next(myContext, function() { - // will not be executed - }); - - run.cancel(runNext); - - let runLater = run.later(myContext, function() { - // will not be executed - }, 500); - - run.cancel(runLater); - - let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { - // will not be executed - }); - - run.cancel(runScheduleOnce); - - let runOnce = run.once(myContext, function() { - // will not be executed - }); - - run.cancel(runOnce); - - let throttle = run.throttle(myContext, function() { - // will not be executed - }, 1, false); - - run.cancel(throttle); - - let debounce = run.debounce(myContext, function() { - // will not be executed - }, 1); - - run.cancel(debounce); - - let debounceImmediate = run.debounce(myContext, function() { - // will be executed since we passed in true (immediate) - }, 100, true); - - // the 100ms delay until this method can be called again will be cancelled - run.cancel(debounceImmediate); - ``` - - @method cancel - @param {Object} timer Timer object to cancel - @return {Boolean} true if cancelled or false/undefined if it wasn't found - @public - */ - run.cancel = function (timer) { - return backburner.cancel(timer); - }; - - /** - Delay calling the target method until the debounce period has elapsed - with no additional debounce calls. If `debounce` is called again before - the specified time has elapsed, the timer is reset and the entire period - must pass again before the target method is called. - - This method should be used when an event may be called multiple times - but the action should only be called once when the event is done firing. - A common example is for scroll events where you only want updates to - happen once scrolling has ceased. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150); - - // less than 150ms passes - run.debounce(myContext, whoRan, 150); - - // 150ms passes - // whoRan is invoked with context myContext - // console logs 'debounce ran.' one time. - ``` - - Immediate allows you to run the function immediately, but debounce - other calls for this function until the wait time has elapsed. If - `debounce` is called again before the specified time has elapsed, - the timer is reset and the entire period must pass again before - the method can be called again. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 100ms passes - run.debounce(myContext, whoRan, 150, true); - - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - - ``` - - @method debounce - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to false. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.debounce = function () { - return backburner.debounce.apply(backburner, arguments); - }; - - /** - Ensure that the target method is never called more frequently than - the specified spacing period. The target method is called immediately. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'throttle' }; - - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 150ms passes - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - ``` - - @method throttle - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} spacing Number of milliseconds to space out requests. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to true. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.throttle = function () { - return backburner.throttle.apply(backburner, arguments); - }; - - /** - Add a new named queue after the specified queue. - - The queue to add will only be added once. - - @method _addQueue - @param {String} name the name of the queue to add. - @param {String} after the name of the queue to add after. - @private - */ - run._addQueue = function (name, after) { - if (run.queues.indexOf(name) === -1) { - run.queues.splice(run.queues.indexOf(after) + 1, 0, name); - } - }; -}); -enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set'], function (exports, _emberMetalProperty_events, _emberMetalProperty_set) { - 'use strict'; - - exports.default = setProperties; - - /** - Set a list of properties on an object. These properties are set inside - a single `beginPropertyChanges` and `endPropertyChanges` batch, so - observers will be buffered. - - ```javascript - let anObject = Ember.Object.create(); - - anObject.setProperties({ - firstName: 'Stanley', - lastName: 'Stuart', - age: 21 - }); - ``` - - @method setProperties - @param obj - @param {Object} properties - @return properties - @public - */ - - function setProperties(obj, properties) { - if (!properties || typeof properties !== 'object') { - return properties; - } - _emberMetalProperty_events.changeProperties(function () { - var props = Object.keys(properties); - var propertyName = undefined; - - for (var i = 0; i < props.length; i++) { - propertyName = props[i]; - - _emberMetalProperty_set.set(obj, propertyName, properties[propertyName]); - } - }); - return properties; - } -}); -enifed('ember-metal/tags', ['exports', 'glimmer-reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { - 'use strict'; - - exports.setHasViews = setHasViews; - exports.tagForProperty = tagForProperty; - exports.tagFor = tagFor; - exports.markObjectAsDirty = markObjectAsDirty; - - var hasViews = function () { - return false; - }; - - function setHasViews(fn) { - hasViews = fn; - } - - function makeTag() { - return new _glimmerReference.DirtyableTag(); - } - - function tagForProperty(object, propertyKey, _meta) { - if (_emberMetalIs_proxy.isProxy(object)) { - return tagFor(object, _meta); - } - - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - var tags = meta.writableTags(); - var tag = tags[propertyKey]; - if (tag) { - return tag; - } - - return tags[propertyKey] = makeTag(); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function tagFor(object, _meta) { - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - return meta.writableTag(makeTag); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function markObjectAsDirty(meta, propertyKey) { - var objectTag = meta && meta.readableTag(); - - if (objectTag) { - objectTag.dirty(); - } - - var tags = meta && meta.readableTags(); - var propertyTag = tags && tags[propertyKey]; - - if (propertyTag) { - propertyTag.dirty(); - } - - if (objectTag || propertyTag) { - ensureRunloop(); - } - } - - var run = undefined; - - function K() {} - - function ensureRunloop() { - if (!run) { - run = _require.default('ember-metal/run_loop').default; - } - - if (hasViews() && !run.backburner.currentInstance) { - run.schedule('actions', K); - } - } -}); -enifed("ember-metal/testing", ["exports"], function (exports) { - "use strict"; - - exports.isTesting = isTesting; - exports.setTesting = setTesting; - var testing = false; - - function isTesting() { - return testing; - } - - function setTesting(value) { - testing = !!value; - } -}); -enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; - - var runInTransaction = undefined, - didRender = undefined, - assertNotRendered = undefined; - - var raise = _emberMetalDebug.assert; - if (false) { - raise = function (message, test) { - _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' }); - }; - } - - var implication = undefined; - if (false) { - implication = 'will be removed in Ember 3.0.'; - } else if (true) { - implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; - } - - if (true || false) { - (function () { - var counter = 0; - var inTransaction = false; - var shouldReflush = undefined; - - exports.default = runInTransaction = function (context, methodName) { - shouldReflush = false; - inTransaction = true; - context[methodName](); - inTransaction = false; - counter++; - return shouldReflush; - }; - - exports.didRender = didRender = function (object, key, reference) { - if (!inTransaction) { - return; - } - var meta = _emberMetalMeta.meta(object); - var lastRendered = meta.writableLastRendered(); - lastRendered[key] = counter; - - _emberMetalDebug.runInDebug(function () { - var lastRenderedFrom = meta.writableLastRenderedFrom(); - lastRenderedFrom[key] = reference; - }); - }; - - exports.assertNotRendered = assertNotRendered = function (object, key, _meta) { - var meta = _meta || _emberMetalMeta.meta(object); - var lastRendered = meta.readableLastRendered(); - - if (lastRendered && lastRendered[key] === counter) { - raise((function () { - var ref = meta.readableLastRenderedFrom(); - var parts = []; - var lastRef = ref[key]; - - var label = undefined; - - if (lastRef) { - while (lastRef && lastRef._propertyKey) { - parts.unshift(lastRef._propertyKey); - lastRef = lastRef._parentReference; - } - - label = parts.join(); - } else { - label = 'the same value'; - } - - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; - })(), false); - - shouldReflush = true; - } - }; - })(); - } else { - exports.default = runInTransaction = function () { - throw new Error('Cannot call runInTransaction without Glimmer'); - }; - - exports.didRender = didRender = function () { - throw new Error('Cannot call didRender without Glimmer'); - }; - - exports.assertNotRendered = assertNotRendered = function () { - throw new Error('Cannot call assertNotRendered without Glimmer'); - }; - } - - exports.default = runInTransaction; - exports.didRender = didRender; - exports.assertNotRendered = assertNotRendered; -}); -enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) { - 'use strict'; - - exports.watchKey = watchKey; - exports.unwatchKey = unwatchKey; - - var handleMandatorySetter = undefined; - - function watchKey(obj, keyName, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - - // activate watching first time - if (!m.peekWatching(keyName)) { - m.writeWatching(keyName, 1); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - if (desc && desc.willWatch) { - desc.willWatch(obj, keyName); - } - - if ('function' === typeof obj.willWatchProperty) { - obj.willWatchProperty(keyName); - } - - if (true) { - // NOTE: this is dropped for prod + minified builds - handleMandatorySetter(m, obj, keyName); - } - } else { - m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1); - } - } - - if (true) { - (function () { - var hasOwnProperty = function (obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - }; - - var propertyIsEnumerable = function (obj, key) { - return Object.prototype.propertyIsEnumerable.call(obj, key); - }; - - // Future traveler, although this code looks scary. It merely exists in - // development to aid in development asertions. Production builds of - // ember strip this entire block out - handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { - var descriptor = _emberUtils.lookupDescriptor(obj, keyName); - var configurable = descriptor ? descriptor.configurable : true; - var isWritable = descriptor ? descriptor.writable : true; - var hasValue = descriptor ? 'value' in descriptor : true; - var possibleDesc = descriptor && descriptor.value; - var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; - - if (isDescriptor) { - return; - } - - // this x in Y deopts, so keeping it in this function is better; - if (configurable && isWritable && hasValue && keyName in obj) { - var desc = { - configurable: true, - set: _emberMetalProperties.MANDATORY_SETTER_FUNCTION(keyName), - enumerable: propertyIsEnumerable(obj, keyName), - get: undefined - }; - - if (hasOwnProperty(obj, keyName)) { - m.writeValues(keyName, obj[keyName]); - desc.get = _emberMetalProperties.DEFAULT_GETTER_FUNCTION(keyName); - } else { - desc.get = _emberMetalProperties.INHERITING_GETTER_FUNCTION(keyName); - } - - Object.defineProperty(obj, keyName, desc); - } - }; - })(); - } - - function unwatchKey(obj, keyName, _meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var meta = _meta || _emberMetalMeta.meta(obj); - - // do nothing of this object has already been destroyed - if (meta.isSourceDestroyed()) { - return; - } - - var count = meta.peekWatching(keyName); - if (count === 1) { - meta.writeWatching(keyName, 0); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.didUnwatch) { - desc.didUnwatch(obj, keyName); - } - - if ('function' === typeof obj.didUnwatchProperty) { - obj.didUnwatchProperty(keyName); - } - - if (true) { - // It is true, the following code looks quite WAT. But have no fear, It - // exists purely to improve development ergonomics and is removed from - // ember.min.js and ember.prod.js builds. - // - // Some further context: Once a property is watched by ember, bypassing `set` - // for mutation, will bypass observation. This code exists to assert when - // that occurs, and attempt to provide more helpful feedback. The alternative - // is tricky to debug partially observable properties. - if (!desc && keyName in obj) { - var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName); - - if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { - if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { - var possibleValue = meta.readInheritedValue('values', keyName); - if (possibleValue === _emberMetalMeta.UNDEFINED) { - delete obj[keyName]; - return; - } - } - - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), - writable: true, - value: meta.peekValues(keyName) - }); - meta.deleteFromValues(keyName); - } - } - } - } else if (count > 1) { - meta.writeWatching(keyName, count - 1); - } - } -}); -enifed('ember-metal/watch_path', ['exports', 'ember-metal/meta', 'ember-metal/chains'], function (exports, _emberMetalMeta, _emberMetalChains) { - 'use strict'; - - exports.makeChainNode = makeChainNode; - exports.watchPath = watchPath; - exports.unwatchPath = unwatchPath; - - // get the chains for the current object. If the current object has - // chains inherited from the proto they will be cloned and reconfigured for - // the current object. - function chainsFor(obj, meta) { - return (meta || _emberMetalMeta.meta(obj)).writableChains(makeChainNode); - } - - function makeChainNode(obj) { - return new _emberMetalChains.ChainNode(null, null, obj); - } - - function watchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - if (!counter) { - // activate watching first time - m.writeWatching(keyPath, 1); - chainsFor(obj, m).add(keyPath); - } else { - m.writeWatching(keyPath, counter + 1); - } - } - - function unwatchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - - if (counter === 1) { - m.writeWatching(keyPath, 0); - chainsFor(obj, m).remove(keyPath); - } else if (counter > 1) { - m.writeWatching(keyPath, counter - 1); - } - } -}); -enifed('ember-metal/watching', ['exports', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.isWatching = isWatching; - exports.watcherCount = watcherCount; - exports.unwatch = unwatch; - exports.destroy = destroy; - - /** - Starts watching a property on an object. Whenever the property changes, - invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the - primitive used by observers and dependent keys; usually you will never call - this method directly but instead use higher level methods like - `Ember.addObserver()` - - @private - @method watch - @for Ember - @param obj - @param {String} _keyPath - */ - function watch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.watchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.watchPath(obj, _keyPath, m); - } - } - - exports.watch = watch; - - function isWatching(obj, key) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - var meta = _emberMetalMeta.peekMeta(obj); - return (meta && meta.peekWatching(key)) > 0; - } - - function watcherCount(obj, key) { - var meta = _emberMetalMeta.peekMeta(obj); - return meta && meta.peekWatching(key) || 0; - } - - function unwatch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.unwatchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.unwatchPath(obj, _keyPath, m); - } - } - - /** - Tears down the meta on an object so that it can be garbage collected. - Multiple calls will have no effect. - - @method destroy - @for Ember - @param {Object} obj the object to destroy - @return {void} - @private - */ - - function destroy(obj) { - _emberMetalMeta.deleteMeta(obj); - } -}); -enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; - - exports.default = WeakMap; - - var id = 0; - - // Returns whether Type(value) is Object according to the terminology in the spec - function isObject(value) { - return typeof value === 'object' && value !== null || typeof value === 'function'; - } - - /* - * @class Ember.WeakMap - * @public - * @category ember-metal-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(iterable) { - if (!(this instanceof WeakMap)) { - throw new TypeError('Constructor WeakMap requires \'new\''); - } - - this._id = _emberUtils.GUID_KEY + id++; - - if (iterable === null || iterable === undefined) { - return; - } else if (Array.isArray(iterable)) { - for (var i = 0; i < iterable.length; i++) { - var _iterable$i = iterable[i]; - var key = _iterable$i[0]; - var value = _iterable$i[1]; - - this.set(key, value); - } - } else { - throw new TypeError('The weak map constructor polyfill only supports an array argument'); - } - } - - /* - * @method get - * @param key {Object | Function} - * @return {Any} stored value - */ - WeakMap.prototype.get = function (obj) { - if (!isObject(obj)) { - return undefined; - } - - var meta = _emberMetalMeta.peekMeta(obj); - if (meta) { - var map = meta.readableWeak(); - if (map) { - if (map[this._id] === _emberMetalMeta.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 (!isObject(obj)) { - throw new TypeError('Invalid value used as weak map key'); - } - - if (value === undefined) { - value = _emberMetalMeta.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) { - if (!isObject(obj)) { - return false; - } - - 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; - } - }; - - /* - * @method toString - * @return {String} - */ - WeakMap.prototype.toString = function () { - return '[object WeakMap]'; - }; -}); -enifed('ember-routing/ext/controller', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/utils'], function (exports, _emberMetal, _emberRuntime, _emberRoutingUtils) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - _emberRuntime.ControllerMixin.reopen({ - concatenatedProperties: ['queryParams'], - - /** - Defines which query parameters the controller accepts. - If you give the names `['category','page']` it will bind - the values of these query parameters to the variables - `this.category` and `this.page` - @property queryParams - @public - */ - queryParams: null, - - /** - This property is updated to various different callback functions depending on - the current "state" of the backing route. It is used by - `Ember.Controller.prototype._qpChanged`. - The methods backing each state can be found in the `Ember.Route.prototype._qp` computed - property return value (the `.states` property). The current values are listed here for - the sanity of future travelers: - * `inactive` - This state is used when this controller instance is not part of the active - route heirarchy. Set in `Ember.Route.prototype._reset` (a `router.js` microlib hook) and - `Ember.Route.prototype.actions.finalizeQueryParamChange`. - * `active` - This state is used when this controller instance is part of the active - route heirarchy. Set in `Ember.Route.prototype.actions.finalizeQueryParamChange`. - * `allowOverrides` - This state is used in `Ember.Route.prototype.setup` (`route.js` microlib hook). - @method _qpDelegate - @private - */ - _qpDelegate: null, // set by route - - /** - During `Ember.Route#setup` observers are created to invoke this method - when any of the query params declared in `Ember.Controller#queryParams` property - are changed. - When invoked this method uses the currently active query param update delegate - (see `Ember.Controller.prototype._qpDelegate` for details) and invokes it with - the QP key/value being changed. - @method _qpChanged - @private - */ - _qpChanged: function (controller, _prop) { - var prop = _prop.substr(0, _prop.length - 3); - - var delegate = controller._qpDelegate; - var value = _emberMetal.get(controller, prop); - delegate(prop, value); - }, - - /** - Transition the application into another route. The route may - be either a single route or route path: - ```javascript - aController.transitionToRoute('blogPosts'); - aController.transitionToRoute('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - aController.transitionToRoute('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - aController.transitionToRoute('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```javascript - App.Router.map(function() { - this.route('blogPost', { path: ':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); - }); - }); - aController.transitionToRoute('blogComment', aPost, aComment); - aController.transitionToRoute('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - aController.transitionToRoute('/'); - aController.transitionToRoute('/blog/post/1/comment/13'); - aController.transitionToRoute('/blog/posts?sort=title'); - ``` - An options hash with a `queryParams` property may be provided as - the final argument to add query parameters to the destination URL. - ```javascript - aController.transitionToRoute('blogPost', 1, { - queryParams: { showComments: 'true' } - }); - // if you just want to transition the query parameters without changing the route - aController.transitionToRoute({ queryParams: { sort: 'date' } }); - ``` - See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). - @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 - @for Ember.ControllerMixin - @method transitionToRoute - @public - */ - transitionToRoute: function () { - // target may be either another controller or a router - var target = _emberMetal.get(this, 'target'); - var method = target.transitionToRoute || target.transitionTo; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(this, args)); - }, - - /** - Transition into another route while replacing the current URL, if possible. - This will replace the current history entry instead of adding a new one. - Beside that, it is identical to `transitionToRoute` in all other respects. - ```javascript - aController.replaceRoute('blogPosts'); - aController.replaceRoute('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - aController.replaceRoute('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - aController.replaceRoute('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```javascript - App.Router.map(function() { - this.route('blogPost', { path: ':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); - }); - }); - aController.replaceRoute('blogComment', aPost, aComment); - aController.replaceRoute('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - aController.replaceRoute('/'); - aController.replaceRoute('/blog/post/1/comment/13'); - ``` - @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. - @for Ember.ControllerMixin - @method replaceRoute - @public - */ - replaceRoute: function () { - // target may be either another controller or a router - var target = _emberMetal.get(this, 'target'); - var method = target.replaceRoute || target.replaceWith; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(target, args)); - } - }); - - exports.default = _emberRuntime.ControllerMixin; -}); -enifed('ember-routing/ext/run_loop', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - /** - @module ember - @submodule ember-views - */ - - // Add a new named queue after the 'actions' queue (where RSVP promises - // resolve), which is used in router transitions to prevent unnecessary - // loading state entry if all context promises resolve on the - // 'actions' queue first. - _emberMetal.run._addQueue('routerTransitions', 'actions'); -}); -enifed('ember-routing/index', ['exports', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route', 'ember-routing/system/query_params', 'ember-routing/services/routing', 'ember-routing/system/cache'], function (exports, _emberRoutingExtRun_loop, _emberRoutingExtController, _emberRoutingLocationApi, _emberRoutingLocationNone_location, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingSystemGenerate_controller, _emberRoutingSystemController_for, _emberRoutingSystemDsl, _emberRoutingSystemRouter, _emberRoutingSystemRoute, _emberRoutingSystemQuery_params, _emberRoutingServicesRouting, _emberRoutingSystemCache) { - /** - @module ember - @submodule ember-routing - */ - - // ES6TODO: Cleanup modules with side-effects below - 'use strict'; - - exports.Location = _emberRoutingLocationApi.default; - exports.NoneLocation = _emberRoutingLocationNone_location.default; - exports.HashLocation = _emberRoutingLocationHash_location.default; - exports.HistoryLocation = _emberRoutingLocationHistory_location.default; - exports.AutoLocation = _emberRoutingLocationAuto_location.default; - exports.generateController = _emberRoutingSystemGenerate_controller.default; - exports.generateControllerFactory = _emberRoutingSystemGenerate_controller.generateControllerFactory; - exports.controllerFor = _emberRoutingSystemController_for.default; - exports.RouterDSL = _emberRoutingSystemDsl.default; - exports.Router = _emberRoutingSystemRouter.default; - exports.Route = _emberRoutingSystemRoute.default; - exports.QueryParams = _emberRoutingSystemQuery_params.default; - exports.RoutingService = _emberRoutingServicesRouting.default; - exports.BucketCache = _emberRoutingSystemCache.default; -}); -enifed('ember-routing/location/api', ['exports', 'ember-metal', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberMetal, _emberEnvironment, _emberRoutingLocationUtil) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - /** - Ember.Location returns an instance of the correct implementation of - the `location` API. - - ## Implementations - - You can pass an implementation name (`hash`, `history`, `none`) to force a - particular implementation to be used in your application. - - ### HashLocation - - Using `HashLocation` results in URLs with a `#` (hash sign) separating the - server side URL portion of the URL from the portion that is used by Ember. - This relies upon the `hashchange` event existing in the browser. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'hash' - }); - ``` - - This will result in a posts.new url of `/#/posts/new`. - - ### HistoryLocation - - Using `HistoryLocation` results in URLs that are indistinguishable from a - standard URL. This relies upon the browser's `history` API. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'history' - }); - ``` - - This will result in a posts.new url of `/posts/new`. - - Keep in mind that your server must serve the Ember app at all the routes you - define. - - ### AutoLocation - - Using `AutoLocation`, the router will use the best Location class supported by - the browser it is running in. - - Browsers that support the `history` API will use `HistoryLocation`, those that - do not, but still support the `hashchange` event will use `HashLocation`, and - in the rare case neither is supported will use `NoneLocation`. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'auto' - }); - ``` - - This will result in a posts.new url of `/posts/new` for modern browsers that - support the `history` api or `/#/posts/new` for older ones, like Internet - Explorer 9 and below. - - When a user visits a link to your application, they will be automatically - upgraded or downgraded to the appropriate `Location` class, with the URL - transformed accordingly, if needed. - - Keep in mind that since some of your users will use `HistoryLocation`, your - server must serve the Ember app at all the routes you define. - - ### NoneLocation - - Using `NoneLocation` causes Ember to not store the applications URL state - in the actual URL. This is generally used for testing purposes, and is one - of the changes made when calling `App.setupForTesting()`. - - ## Location API - - Each location implementation must provide the following methods: - - * implementation: returns the string name used to reference the implementation. - * getURL: returns the current URL. - * setURL(path): sets the current URL. - * replaceURL(path): replace the current URL (optional). - * onUpdateURL(callback): triggers the callback when the URL changes. - * formatURL(url): formats `url` to be placed into `href` attribute. - * detect() (optional): instructs the location to do any feature detection - necessary. If the location needs to redirect to a different URL, it - can cancel routing by setting the `cancelRouterSetup` property on itself - to `false`. - - Calling setURL or replaceURL will not trigger onUpdateURL callbacks. - - ## Custom implementation - - Ember scans `app/locations/*` for extending the Location API. - - Example: - - ```javascript - import Ember from 'ember'; - - export default Ember.HistoryLocation.extend({ - implementation: 'history-url-logging', - - pushState: function (path) { - console.log(path); - this._super.apply(this, arguments); - } - }); - ``` - - @class Location - @namespace Ember - @static - @private - */ - exports.default = { - /** - This is deprecated in favor of using the container to lookup the location - implementation as desired. - For example: - ```javascript - // Given a location registered as follows: - container.register('location:history-test', HistoryTestLocation); - // You could create a new instance via: - container.lookup('location:history-test'); - ``` - @method create - @param {Object} options - @return {Object} an instance of an implementation of the `location` API - @deprecated Use the container to lookup the location implementation that you - need. - @private - */ - create: function (options) { - var implementation = options && options.implementation; - _emberMetal.assert('Ember.Location.create: you must specify a \'implementation\' option', !!implementation); - - var implementationClass = this.implementations[implementation]; - _emberMetal.assert('Ember.Location.create: ' + implementation + ' is not a valid implementation', !!implementationClass); - - return implementationClass.create.apply(implementationClass, arguments); - }, - - implementations: {}, - _location: _emberEnvironment.environment.location, - - /** - Returns the current `location.hash` by parsing location.href since browsers - inconsistently URL-decode `location.hash`. - https://bugzilla.mozilla.org/show_bug.cgi?id=483304 - @private - @method getHash - @since 1.4.0 - */ - _getHash: function () { - return _emberRoutingLocationUtil.getHash(this.location); - } - }; -}); -enifed('ember-routing/location/auto_location', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberRoutingLocationUtil) { - 'use strict'; - - exports.getHistoryPath = getHistoryPath; - exports.getHashPath = getHashPath; - - /** - @module ember - @submodule ember-routing - */ - - /** - Ember.AutoLocation will select the best location option based off browser - support with the priority order: history, hash, none. - - Clean pushState paths accessed by hashchange-only browsers will be redirected - to the hash-equivalent and vice versa so future transitions are consistent. - - Keep in mind that since some of your users will use `HistoryLocation`, your - server must serve the Ember app at all the routes you define. - - @class AutoLocation - @namespace Ember - @static - @private - */ - exports.default = _emberRuntime.Object.extend({ - /** - @private - The browser's `location` object. This is typically equivalent to - `window.location`, but may be overridden for testing. - @property location - @default environment.location - */ - location: _emberEnvironment.environment.location, - - /** - @private - The browser's `history` object. This is typically equivalent to - `window.history`, but may be overridden for testing. - @since 1.5.1 - @property history - @default environment.history - */ - history: _emberEnvironment.environment.history, - - /** - @private - The user agent's global variable. In browsers, this will be `window`. - @since 1.11 - @property global - @default window - */ - global: _emberEnvironment.environment.window, - - /** - @private - The browser's `userAgent`. This is typically equivalent to - `navigator.userAgent`, but may be overridden for testing. - @since 1.5.1 - @property userAgent - @default environment.history - */ - userAgent: _emberEnvironment.environment.userAgent, - - /** - @private - This property is used by the router to know whether to cancel the routing - setup process, which is needed while we redirect the browser. - @since 1.5.1 - @property cancelRouterSetup - @default false - */ - cancelRouterSetup: false, - - /** - @private - Will be pre-pended to path upon state change. - @since 1.5.1 - @property rootURL - @default '/' - */ - rootURL: '/', - - /** - Called by the router to instruct the location to do any feature detection - necessary. In the case of AutoLocation, we detect whether to use history - or hash concrete implementations. - @private - */ - detect: function () { - var rootURL = this.rootURL; - - _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); - - var implementation = detectImplementation({ - location: this.location, - history: this.history, - userAgent: this.userAgent, - rootURL: rootURL, - documentMode: this.documentMode, - global: this.global - }); - - if (implementation === false) { - _emberMetal.set(this, 'cancelRouterSetup', true); - implementation = 'none'; - } - - var concrete = _emberUtils.getOwner(this).lookup('location:' + implementation); - _emberMetal.set(concrete, 'rootURL', rootURL); - - _emberMetal.assert('Could not find location \'' + implementation + '\'.', !!concrete); - - _emberMetal.set(this, 'concreteImplementation', concrete); - }, - - initState: delegateToConcreteImplementation('initState'), - getURL: delegateToConcreteImplementation('getURL'), - setURL: delegateToConcreteImplementation('setURL'), - replaceURL: delegateToConcreteImplementation('replaceURL'), - onUpdateURL: delegateToConcreteImplementation('onUpdateURL'), - formatURL: delegateToConcreteImplementation('formatURL'), - - willDestroy: function () { - var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - - if (concreteImplementation) { - concreteImplementation.destroy(); - } - } - }); - - function delegateToConcreteImplementation(methodName) { - return function () { - var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - _emberMetal.assert('AutoLocation\'s detect() method should be called before calling any other hooks.', !!concreteImplementation); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _emberUtils.tryInvoke(concreteImplementation, methodName, args); - }; - } - - /* - Given the browser's `location`, `history` and `userAgent`, and a configured - root URL, this function detects whether the browser supports the [History - API](https://developer.mozilla.org/en-US/docs/Web/API/History) and returns a - string representing the Location object to use based on its determination. + /** + The `readonly` helper let's you specify that a binding is one-way only, + instead of two-way. + When you pass a `readonly` binding from an outer context (e.g. parent component), + to to an inner context (e.g. child component), you are saying that changing that + property in the inner context does not change the value in the outer context. - For example, if the page loads in an evergreen browser, this function would - return the string "history", meaning the history API and thus HistoryLocation - should be used. If the page is loaded in IE8, it will return the string - "hash," indicating that the History API should be simulated by manipulating the - hash portion of the location. + To specify that a binding is read-only, when invoking the child `Component`: - */ - - function detectImplementation(options) { - var location = options.location; - var userAgent = options.userAgent; - var history = options.history; - var documentMode = options.documentMode; - var global = options.global; - var rootURL = options.rootURL; - - var implementation = 'none'; - var cancelRouterSetup = false; - var currentPath = _emberRoutingLocationUtil.getFullPath(location); - - if (_emberRoutingLocationUtil.supportsHistory(userAgent, history)) { - var historyPath = getHistoryPath(rootURL, location); - - // If the browser supports history and we have a history path, we can use - // the history location with no redirects. - if (currentPath === historyPath) { - return 'history'; - } else { - if (currentPath.substr(0, 2) === '/#') { - history.replaceState({ path: historyPath }, null, historyPath); - implementation = 'history'; - } else { - cancelRouterSetup = true; - _emberRoutingLocationUtil.replacePath(location, historyPath); - } - } - } else if (_emberRoutingLocationUtil.supportsHashChange(documentMode, global)) { - var hashPath = getHashPath(rootURL, location); - - // Be sure we're using a hashed path, otherwise let's switch over it to so - // we start off clean and consistent. We'll count an index path with no - // hash as "good enough" as well. - if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') { - implementation = 'hash'; - } else { - // Our URL isn't in the expected hash-supported format, so we want to - // cancel the router setup and replace the URL to start off clean - cancelRouterSetup = true; - _emberRoutingLocationUtil.replacePath(location, hashPath); - } - } - - if (cancelRouterSetup) { - return false; - } - - return implementation; - } - - /** - @private + ```app/components/my-parent.js + export default Component.extend({ + totalClicks: 3 + }); + ``` - Returns the current path as it should appear for HistoryLocation supported - browsers. This may very well differ from the real current path (e.g. if it - starts off as a hashed URL) - */ - - function getHistoryPath(rootURL, location) { - var path = _emberRoutingLocationUtil.getPath(location); - var hash = _emberRoutingLocationUtil.getHash(location); - var query = _emberRoutingLocationUtil.getQuery(location); - var rootURLIndex = path.indexOf(rootURL); - var routeHash = undefined, - hashParts = undefined; - - _emberMetal.assert('Path ' + path + ' does not start with the provided rootURL ' + rootURL, rootURLIndex === 0); - - // By convention, Ember.js routes using HashLocation are required to start - // with `#/`. Anything else should NOT be considered a route and should - // be passed straight through, without transformation. - if (hash.substr(0, 2) === '#/') { - // There could be extra hash segments after the route - hashParts = hash.substr(1).split('#'); - // The first one is always the route url - routeHash = hashParts.shift(); - - // If the path already has a trailing slash, remove the one - // from the hashed route so we don't double up. - if (path.slice(-1) === '/') { - routeHash = routeHash.substr(1); - } - - // This is the "expected" final order - path = path + routeHash + query; - - if (hashParts.length) { - path += '#' + hashParts.join('#'); - } - } else { - path = path + query + hash; - } - - return path; - } - - /** - @private + ```app/templates/components/my-parent.hbs + {{log totalClicks}} // -> 3 + {{my-child childClickCount=(readonly totalClicks)}} + ``` - Returns the current path as it should appear for HashLocation supported - browsers. This may very well differ from the real current path. + Now, when you update `childClickCount`: - @method _getHashPath - */ - - function getHashPath(rootURL, location) { - var path = rootURL; - var historyPath = getHistoryPath(rootURL, location); - var routePath = historyPath.substr(rootURL.length); - - if (routePath !== '') { - if (routePath.charAt(0) !== '/') { - routePath = '/' + routePath; + ```app/components/my-child.js + export default Component.extend({ + click() { + this.incrementProperty('childClickCount'); } - - path += '#' + routePath; - } - - return path; - } -}); -enifed('ember-routing/location/hash_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - /** - `Ember.HashLocation` implements the location API using the browser's - hash. At present, it relies on a `hashchange` event existing in the - browser. + }); + ``` - @class HashLocation - @namespace Ember - @extends Ember.Object - @private - */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'hash', - - init: function () { - _emberMetal.set(this, 'location', _emberMetal.get(this, '_location') || window.location); - - this._hashchangeHandler = undefined; - }, - - /** - @private - Returns normalized location.hash - @since 1.5.1 - @method getHash - */ - getHash: _emberRoutingLocationApi.default._getHash, - - /** - Returns the normalized URL, constructed from `location.hash`. - e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. - By convention, hashed paths must begin with a forward slash, otherwise they - are not treated as a path so we can distinguish intent. - @private - @method getURL - */ - getURL: function () { - var originalPath = this.getHash().substr(1); - var outPath = originalPath; - - if (outPath.charAt(0) !== '/') { - outPath = '/'; - - // Only add the # if the path isn't empty. - // We do NOT want `/#` since the ampersand - // is only included (conventionally) when - // the location.hash has a value - if (originalPath) { - outPath += '#' + originalPath; - } - } - - return outPath; - }, - - /** - Set the `location.hash` and remembers what was set. This prevents - `onUpdateURL` callbacks from triggering when the hash was set by - `HashLocation`. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - _emberMetal.get(this, 'location').hash = path; - _emberMetal.set(this, 'lastSetURL', path); - }, - - /** - Uses location.replace to update the url without a page reload - or history modification. - @private - @method replaceURL - @param path {String} - */ - replaceURL: function (path) { - _emberMetal.get(this, 'location').replace('#' + path); - _emberMetal.set(this, 'lastSetURL', path); - }, - - /** - Register a callback to be invoked when the hash changes. These - callbacks will execute when the user presses the back or forward - button, but not after `setURL` is invoked. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - var _this = this; - - this._removeEventListener(); - - this._hashchangeHandler = function () { - _emberMetal.run(function () { - var path = _this.getURL(); - if (_emberMetal.get(_this, 'lastSetURL') === path) { - return; - } - - _emberMetal.set(_this, 'lastSetURL', null); - - callback(path); - }); - }; - - window.addEventListener('hashchange', this._hashchangeHandler); - }, - - /** - Given a URL, formats it to be placed into the page as part - of an element's `href` attribute. - This is used, for example, when using the {{action}} helper - to generate a URL based on an event. - @private - @method formatURL - @param url {String} - */ - formatURL: function (url) { - return '#' + url; - }, - - /** - Cleans up the HashLocation event listener. - @private - @method willDestroy - */ - willDestroy: function () { - this._removeEventListener(); - }, - - _removeEventListener: function () { - if (this._hashchangeHandler) { - window.removeEventListener('hashchange', this._hashchangeHandler); - } - } - }); -}); -enifed('ember-routing/location/history_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - var popstateFired = false; - - /** - Ember.HistoryLocation implements the location API using the browser's - history.pushState API. + The value updates in the child component, but not the parent component: - @class HistoryLocation - @namespace Ember - @extends Ember.Object - @private - */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'history', - - init: function () { - this._super.apply(this, arguments); - - var base = document.querySelector('base'); - var baseURL = base ? base.getAttribute('href') : ''; - - _emberMetal.set(this, 'baseURL', baseURL); - _emberMetal.set(this, 'location', _emberMetal.get(this, 'location') || window.location); - - this._popstateHandler = undefined; - }, - - /** - Used to set state on first call to setURL - @private - @method initState - */ - initState: function () { - var history = _emberMetal.get(this, 'history') || window.history; - _emberMetal.set(this, 'history', history); - - if (history && 'state' in history) { - this.supportsHistory = true; - } - - this.replaceState(this.formatURL(this.getURL())); - }, - - /** - Will be pre-pended to path upon state change - @property rootURL - @default '/' - @private - */ - rootURL: '/', - - /** - Returns the current `location.pathname` without `rootURL` or `baseURL` - @private - @method getURL - @return url {String} - */ - getURL: function () { - var location = _emberMetal.get(this, 'location'); - var path = location.pathname; - - var rootURL = _emberMetal.get(this, 'rootURL'); - var baseURL = _emberMetal.get(this, 'baseURL'); - - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - baseURL = baseURL.replace(/\/$/, ''); - - // remove baseURL and rootURL from start of path - var url = path.replace(new RegExp('^' + baseURL + '(?=/|$)'), '').replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - - var search = location.search || ''; - url += search; - url += this.getHash(); - - return url; - }, - - /** - Uses `history.pushState` to update the url without a page reload. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - var state = this.getState(); - path = this.formatURL(path); - - if (!state || state.path !== path) { - this.pushState(path); - } - }, - - /** - Uses `history.replaceState` to update the url without a page reload - or history modification. - @private - @method replaceURL - @param path {String} - */ - replaceURL: function (path) { - var state = this.getState(); - path = this.formatURL(path); - - if (!state || state.path !== path) { - this.replaceState(path); - } - }, - - /** - Get the current `history.state`. Checks for if a polyfill is - required and if so fetches this._historyState. The state returned - from getState may be null if an iframe has changed a window's - history. - @private - @method getState - @return state {Object} - */ - getState: function () { - if (this.supportsHistory) { - return _emberMetal.get(this, 'history').state; + ```app/templates/components/my-child.hbs + {{log childClickCount}} //-> 4 + ``` + + ```app/templates/components/my-parent.hbs + {{log totalClicks}} //-> 3 + {{my-child childClickCount=(readonly totalClicks)}} + ``` + + ### Objects and Arrays + + When passing a property that is a complex object (e.g. object, array) instead of a primitive object (e.g. number, string), + only the reference to the object is protected using the readonly helper. + This means that you can change properties of the object both on the parent component, as well as the child component. + The `readonly` binding behaves similar to the `const` keyword in JavaScript. + + Let's look at an example: + + First let's set up the parent component: + + ```app/components/my-parent.js + export default Ember.Component.extend({ + clicks: null, + + init() { + this._super(...arguments); + this.set('clicks', { total: 3 }); } - - return this._historyState; - }, - - /** - Pushes a new state. - @private - @method pushState - @param path {String} - */ - pushState: function (path) { - var state = { path: path }; - - _emberMetal.get(this, 'history').pushState(state, null, path); - - this._historyState = state; - - // used for webkit workaround - this._previousURL = this.getURL(); - }, - - /** - Replaces the current state. - @private - @method replaceState - @param path {String} - */ - replaceState: function (path) { - var state = { path: path }; - _emberMetal.get(this, 'history').replaceState(state, null, path); - - this._historyState = state; - - // used for webkit workaround - this._previousURL = this.getURL(); - }, - - /** - Register a callback to be invoked whenever the browser - history changes, including using forward and back buttons. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - var _this = this; - - this._removeEventListener(); - - this._popstateHandler = function () { - // Ignore initial page load popstate event in Chrome - if (!popstateFired) { - popstateFired = true; - if (_this.getURL() === _this._previousURL) { - return; - } - } - callback(_this.getURL()); - }; - - window.addEventListener('popstate', this._popstateHandler); - }, - - /** - Used when using `{{action}}` helper. The url is always appended to the rootURL. - @private - @method formatURL - @param url {String} - @return formatted url {String} - */ - formatURL: function (url) { - var rootURL = _emberMetal.get(this, 'rootURL'); - var baseURL = _emberMetal.get(this, 'baseURL'); - - if (url !== '') { - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - baseURL = baseURL.replace(/\/$/, ''); - } else if (baseURL.match(/^\//) && rootURL.match(/^\//)) { - // if baseURL and rootURL both start with a slash - // ... remove trailing slash from baseURL if it exists - baseURL = baseURL.replace(/\/$/, ''); + }); + ``` + + ```app/templates/components/my-parent.hbs + {{log clicks.total}} //-> 3 + {{my-child childClicks=(readonly clicks)}} + ``` + + Now, if you update the `total` property of `childClicks`: + + ```app/components/my-child.js + export default Ember.Component.extend({ + click() { + this.get('clicks').incrementProperty('total'); } + }); + ``` + + You will see the following happen: + + ```app/templates/components/my-parent.hbs + {{log clicks.total}} //-> 4 + {{my-child childClicks=(readonly clicks)}} + ``` + + ```app/templates/components/my-child.hbs + {{log childClicks.total}} //-> 4 + ``` + + @method readonly + @param {Object} [attr] the read-only attribute. + @for Ember.Templates.helpers + @private + */ - return baseURL + rootURL + url; - }, + exports.default = function (vm, args) { + var ref = _emberGlimmerHelpersMut.unMut(args.positional.at(0)); - /** - Cleans up the HistoryLocation event listener. - @private - @method willDestroy - */ - willDestroy: function () { - this._removeEventListener(); - }, + var wrapped = Object.create(ref); - /** - @private - Returns normalized location.hash - @method getHash - */ - getHash: _emberRoutingLocationApi.default._getHash, + wrapped[_emberGlimmerUtilsReferences.UPDATE] = undefined; - _removeEventListener: function () { - if (this._popstateHandler) { - window.removeEventListener('popstate', this._popstateHandler); - } - } - }); + return wrapped; + }; }); -enifed('ember-routing/location/none_location', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { - 'use strict'; - +enifed('ember-glimmer/helpers/unbound', ['exports', 'ember-metal', 'ember-glimmer/utils/references'], function (exports, _emberMetal, _emberGlimmerUtilsReferences) { /** @module ember - @submodule ember-routing + @submodule ember-glimmer */ + 'use strict'; + /** - Ember.NoneLocation does not interact with the browser. It is useful for - testing, or when you need to manage state with your Router, but temporarily - don't want it to muck with the URL (for example when you embed your - application in a larger page). + The `{{unbound}}` helper disconnects the one-way binding of a property, + essentially freezing its value at the moment of rendering. For example, + in this example the display of the variable `name` will not change even + if it is set with a new value: - @class NoneLocation - @namespace Ember - @extends Ember.Object - @private + ```handlebars + {{unbound name}} + ``` + + Like any helper, the `unbound` helper can accept a nested helper expression. + This allows for custom helpers to be rendered unbound: + + ```handlebars + {{unbound (some-custom-helper)}} + {{unbound (capitalize name)}} + {{! You can use any helper, including unbound, in a nested expression }} + {{capitalize (unbound name)}} + ``` + + The `unbound` helper only accepts a single argument, and it return an + unbound value. + + @method unbound + @for Ember.Templates.helpers + @public */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'none', - path: '', - - detect: function () { - var rootURL = this.rootURL; - - _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); - }, - - /** - Will be pre-pended to path. - @private - @property rootURL - @default '/' - */ - rootURL: '/', - - /** - Returns the current path without `rootURL`. - @private - @method getURL - @return {String} path - */ - getURL: function () { - var path = _emberMetal.get(this, 'path'); - var rootURL = _emberMetal.get(this, 'rootURL'); - - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - // remove rootURL from url - return path.replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - }, + exports.default = function (vm, args) { + _emberMetal.assert('unbound helper cannot be called with multiple params or hash params', args.positional.values.length === 1 && args.named.keys.length === 0); - /** - Set the path and remembers what was set. Using this method - to change the path will not invoke the `updateURL` callback. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - _emberMetal.set(this, 'path', path); - }, + return _emberGlimmerUtilsReferences.UnboundReference.create(args.positional.at(0).value()); + }; +}); +enifed('ember-glimmer/index', ['exports', 'ember-glimmer/helpers/action', 'ember-glimmer/templates/root', 'ember-glimmer/template', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/helper', 'ember-glimmer/environment', 'ember-glimmer/make-bound-helper', 'ember-glimmer/utils/string', 'ember-glimmer/renderer', 'ember-glimmer/template_registry', 'ember-glimmer/setup-registry', 'ember-glimmer/dom'], function (exports, _emberGlimmerHelpersAction, _emberGlimmerTemplatesRoot, _emberGlimmerTemplate, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerHelper, _emberGlimmerEnvironment, _emberGlimmerMakeBoundHelper, _emberGlimmerUtilsString, _emberGlimmerRenderer, _emberGlimmerTemplate_registry, _emberGlimmerSetupRegistry, _emberGlimmerDom) { + /** + [Glimmer](https://github.com/tildeio/glimmer) is a [Handlebars](http://handlebarsjs.com/) + compatible templating engine used by Ember.js. + Any valid Handlebars syntax is valid in an Ember template. + + ### Showing a property + + Templates manage the flow of an application's UI, and display state (through + the DOM) to a user. For example, given a component with the property "name", + that component's template can use the name in several ways: + + ```javascript + // app/components/person.js + export default Ember.Component.extend({ + name: 'Jill' + }); + ``` + + ```handlebars + {{! app/components/person.hbs }} + {{name}} +
    {{name}}
    + + ``` + + Any time the "name" property on the component changes, the DOM will be + updated. + + Properties can be chained as well: + + ```handlebars + {{aUserModel.name}} +
    {{listOfUsers.firstObject.name}}
    + ``` + + ### Using Ember helpers + + When content is passed in mustaches `{{}}`, Ember will first try to find a helper + or component with that name. For example, the `if` helper: + + ```handlebars + {{if name "I have a name" "I have no name"}} + + ``` + + The returned value is placed where the `{{}}` is called. The above style is + called "inline". A second style of helper usage is called "block". For example: + + ```handlebars + {{#if name}} + I have a name + {{else}} + I have no name + {{/if}} + ``` + + The block form of helpers allows you to control how the UI is created based + on the values of properties. + A third form of helper is called "nested". For example here the concat + helper will add " Doe" to a displayed name if the person has no last name: + + ```handlebars + + ``` + + Ember's built-in helpers are described under the [Ember.Templates.helpers](/api/classes/Ember.Templates.helpers.html) + namespace. Documentation on creating custom helpers can be found under + [Ember.Helper](/api/classes/Ember.Helper.html). + + ### Invoking a Component + + Ember components represent state to the UI of an application. Further + reading on components can be found under [Ember.Component](/api/classes/Ember.Component.html). + + @module ember + @submodule ember-glimmer + @main ember-glimmer + @public + */ - /** - Register a callback to be invoked when the path changes. These - callbacks will execute when the user presses the back or forward - button, but not after `setURL` is invoked. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - this.updateCallback = callback; - }, + /** + Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful + for semantic clarity as it allows you to retain default scope or to reference a property from another + `{{with}}` block. + + If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0`, NaN or + an empty array, the block will not be rendered. + + ```handlebars + {{! Will only render if user.posts contains items}} + {{#with user.posts as |blogPosts|}} +
    + There are {{blogPosts.length}} blog posts written by {{user.name}}. +
    + {{#each blogPosts as |post|}} +
  • {{post.title}}
  • + {{/each}} + {{/with}} + ``` + + Without the `as` operator, it would be impossible to reference `user.name` in the example above. + + NOTE: The alias should not reuse a name from the bound property path. + + For example: `{{#with foo.bar as |foo|}}` is not supported because it attempts to alias using + the first part of the property path, `foo`. Instead, use `{{#with foo.bar as |baz|}}`. + + @method with + @for Ember.Templates.helpers + @param {Object} options + @return {String} HTML string + @public + */ - /** - Sets the path and calls the `updateURL` callback. - @private - @method handleURL - @param callback {Function} - */ - handleURL: function (url) { - _emberMetal.set(this, 'path', url); - this.updateCallback(url); - }, + /** + Execute the `debugger` statement in the current template's context. + + ```handlebars + {{debugger}} + ``` + + When using the debugger helper you will have access to a `get` function. This + function retrieves values available in the context of the template. + For example, if you're wondering why a value `{{foo}}` isn't rendering as + expected within a template, you could place a `{{debugger}}` statement and, + when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: + + ``` + > get('foo') + ``` + + `get` is also aware of keywords. So in this situation + + ```handlebars + {{#each items as |item|}} + {{debugger}} + {{/each}} + ``` + + You'll be able to get values from the current item: + + ``` + > get('item.name') + ``` + + You can also access the context of the view to make sure it is the object that + you expect: + + ``` + > context + ``` + + @method debugger + @for Ember.Templates.helpers + @public + */ - /** - Given a URL, formats it to be placed into the page as part - of an element's `href` attribute. - This is used, for example, when using the {{action}} helper - to generate a URL based on an event. - @private - @method formatURL - @param url {String} - @return {String} url - */ - formatURL: function (url) { - var rootURL = _emberMetal.get(this, 'rootURL'); + /** + The `partial` helper renders another template without + changing the template context: + + ```handlebars + {{foo}} + {{partial "nav"}} + ``` + + The above example template will render a template named + "-nav", which has the same context as the parent template + it's rendered into, so if the "-nav" template also referenced + `{{foo}}`, it would print the same thing as the `{{foo}}` + in the above example. + + If a "-nav" template isn't found, the `partial` helper will + fall back to a template named "nav". + + ### Bound template names + + The parameter supplied to `partial` can also be a path + to a property containing a template name, e.g.: + + ```handlebars + {{partial someTemplateName}} + ``` + + The above example will look up the value of `someTemplateName` + on the template context (e.g. a controller) and use that + value as the name of the template to render. If the resolved + value is falsy, nothing will be rendered. If `someTemplateName` + changes, the partial will be re-rendered using the new template + name. + + @method partial + @for Ember.Templates.helpers + @param {String} partialName The name of the template to render minus the leading underscore. + @public + */ - if (url !== '') { - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - } + 'use strict'; - return rootURL + url; - } - }); + exports.INVOKE = _emberGlimmerHelpersAction.INVOKE; + exports.RootTemplate = _emberGlimmerTemplatesRoot.default; + exports.template = _emberGlimmerTemplate.default; + exports.Checkbox = _emberGlimmerComponentsCheckbox.default; + exports.TextField = _emberGlimmerComponentsText_field.default; + exports.TextArea = _emberGlimmerComponentsText_area.default; + exports.LinkComponent = _emberGlimmerComponentsLinkTo.default; + exports.Component = _emberGlimmerComponent.default; + exports.Helper = _emberGlimmerHelper.default; + exports.helper = _emberGlimmerHelper.helper; + exports.Environment = _emberGlimmerEnvironment.default; + exports.makeBoundHelper = _emberGlimmerMakeBoundHelper.default; + exports.SafeString = _emberGlimmerUtilsString.SafeString; + exports.escapeExpression = _emberGlimmerUtilsString.escapeExpression; + exports.htmlSafe = _emberGlimmerUtilsString.htmlSafe; + exports.isHTMLSafe = _emberGlimmerUtilsString.isHTMLSafe; + exports._getSafeString = _emberGlimmerUtilsString.getSafeString; + exports.Renderer = _emberGlimmerRenderer.Renderer; + exports.InertRenderer = _emberGlimmerRenderer.InertRenderer; + exports.InteractiveRenderer = _emberGlimmerRenderer.InteractiveRenderer; + exports.getTemplate = _emberGlimmerTemplate_registry.getTemplate; + exports.setTemplate = _emberGlimmerTemplate_registry.setTemplate; + exports.hasTemplate = _emberGlimmerTemplate_registry.hasTemplate; + exports.getTemplates = _emberGlimmerTemplate_registry.getTemplates; + exports.setTemplates = _emberGlimmerTemplate_registry.setTemplates; + exports.setupEngineRegistry = _emberGlimmerSetupRegistry.setupEngineRegistry; + exports.setupApplicationRegistry = _emberGlimmerSetupRegistry.setupApplicationRegistry; + exports.DOMChanges = _emberGlimmerDom.DOMChanges; + exports.NodeDOMTreeConstruction = _emberGlimmerDom.NodeDOMTreeConstruction; + exports.DOMTreeConstruction = _emberGlimmerDom.DOMTreeConstruction; }); -enifed('ember-routing/location/util', ['exports'], function (exports) { +enifed('ember-glimmer/make-bound-helper', ['exports', 'ember-metal', 'ember-glimmer/helper'], function (exports, _emberMetal, _emberGlimmerHelper) { /** - @private - - Returns the current `location.pathname`, normalized for IE inconsistencies. + @module ember + @submodule ember-glimmer */ 'use strict'; - exports.getPath = getPath; - exports.getQuery = getQuery; - exports.getHash = getHash; - exports.getFullPath = getFullPath; - exports.getOrigin = getOrigin; - exports.supportsHashChange = supportsHashChange; - exports.supportsHistory = supportsHistory; - exports.replacePath = replacePath; - - function getPath(location) { - var pathname = location.pathname; - // Various versions of IE/Opera don't always return a leading slash - if (pathname.charAt(0) !== '/') { - pathname = '/' + pathname; - } - - return pathname; - } + exports.default = makeBoundHelper; /** - @private + Create a bound helper. Accepts a function that receives the ordered and hash parameters + from the template. If a bound property was provided in the template, it will be resolved to its + value and any changes to the bound property cause the helper function to be re-run with the updated + values. - Returns the current `location.search`. - */ - - function getQuery(location) { - return location.search; - } - - /** - @private + * `params` - An array of resolved ordered parameters. + * `hash` - An object containing the hash parameters. - Returns the current `location.hash` by parsing location.href since browsers - inconsistently URL-decode `location.hash`. + For example: - Should be passed the browser's `location` object as the first argument. + * With an unquoted ordered parameter: - https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + ```javascript + {{x-capitalize foo}} + ``` + + Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and + an empty hash as its second. + + * With a quoted ordered parameter: + + ```javascript + {{x-capitalize "foo"}} + ``` + + The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. + + * With an unquoted hash parameter: + + ```javascript + {{x-repeat "foo" count=repeatCount}} + ``` + + Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, + and { count: 2 } as its second. + + @private + @method makeBoundHelper + @for Ember.HTMLBars + @param {Function} fn + @since 1.10.0 */ - function getHash(location) { - var href = location.href; - var hashIndex = href.indexOf('#'); - - if (hashIndex === -1) { - return ''; - } else { - return href.substr(hashIndex); - } + function makeBoundHelper(fn) { + _emberMetal.deprecate('Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.', false, { id: 'ember-htmlbars.make-bound-helper', until: '3.0.0' }); + return _emberGlimmerHelper.helper(fn); } +}); +enifed('ember-glimmer/modifiers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _emberGlimmerHelpersAction) { + 'use strict'; - function getFullPath(location) { - return getPath(location) + getQuery(location) + getHash(location); - } + var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; + var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; - function getOrigin(location) { - var origin = location.origin; + function isAllowedEvent(event, allowedKeys) { + if (allowedKeys === null || typeof allowedKeys === 'undefined') { + if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { + return _emberViews.isSimpleClick(event); + } else { + allowedKeys = ''; + } + } - // Older browsers, especially IE, don't have origin - if (!origin) { - origin = location.protocol + '//' + location.hostname; + if (allowedKeys.indexOf('any') >= 0) { + return true; + } - if (location.port) { - origin += ':' + location.port; + for (var i = 0; i < MODIFIERS.length; i++) { + if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { + return false; } } - return origin; + return true; } - /* - `documentMode` only exist in Internet Explorer, and it's tested because IE8 running in - IE7 compatibility mode claims to support `onhashchange` but actually does not. - - `global` is an object that may have an `onhashchange` property. - - @private - @function supportsHashChange - */ + var ActionHelper = { + // registeredActions is re-exported for compatibility with older plugins + // that were using this undocumented API. + registeredActions: _emberViews.ActionManager.registeredActions, - function supportsHashChange(documentMode, global) { - return 'onhashchange' in global && (documentMode === undefined || documentMode > 7); - } + registerAction: function (actionState) { + var actionId = actionState.actionId; - /* - `userAgent` is a user agent string. We use user agent testing here, because - the stock Android browser is known to have buggy versions of the History API, - in some Android versions. - - @private - @function supportsHistory - */ + _emberViews.ActionManager.registeredActions[actionId] = actionState; - function supportsHistory(userAgent, history) { - // Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js - // The stock browser on Android 2.2 & 2.3, and 4.0.x returns positive on history support - // Unfortunately support is really buggy and there is no clean way to detect - // these bugs, so we fall back to a user agent sniff :( + return actionId; + }, - // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies - // itself as 'Mobile Safari' as well, nor Windows Phone. - if ((userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 4.0') !== -1) && userAgent.indexOf('Mobile Safari') !== -1 && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Windows Phone') === -1) { - return false; + unregisterAction: function (actionState) { + var actionId = actionState.actionId; + + delete _emberViews.ActionManager.registeredActions[actionId]; } + }; - return !!(history && 'pushState' in history); - } + exports.ActionHelper = ActionHelper; - /** - Replaces the current location, making sure we explicitly include the origin - to prevent redirecting to a different origin. - - @private - */ + var ActionState = (function () { + function ActionState(element, actionId, actionName, actionArgs, namedArgs, positionalArgs, implicitTarget, dom) { + babelHelpers.classCallCheck(this, ActionState); - function replacePath(location, path) { - location.replace(getOrigin(location) + path); - } -}); -enifed('ember-routing/services/routing', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'ember-routing/utils'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _emberRoutingUtils) { - /** - @module ember - @submodule ember-routing - */ + this.element = element; + this.actionId = actionId; + this.actionName = actionName; + this.actionArgs = actionArgs; + this.namedArgs = namedArgs; + this.positional = positionalArgs; + this.implicitTarget = implicitTarget; + this.dom = dom; + this.eventName = this.getEventName(); + } - 'use strict'; + // implements ModifierManager - /** - The Routing service is used by LinkComponent, and provides facilities for - the component/view layer to interact with the router. - - While still private, this service can eventually be opened up, and provides - the set of API needed for components to control routing without interacting - with router internals. - - @private - @class RoutingService - */ - exports.default = _emberRuntime.Service.extend({ - router: null, + ActionState.prototype.getEventName = function getEventName() { + return this.namedArgs.get('on').value() || 'click'; + }; - targetState: _emberRuntime.readOnly('router.targetState'), - currentState: _emberRuntime.readOnly('router.currentState'), - currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), - currentPath: _emberRuntime.readOnly('router.currentPath'), + ActionState.prototype.getActionArgs = function getActionArgs() { + var result = new Array(this.actionArgs.length); - availableRoutes: function () { - return Object.keys(_emberMetal.get(this, 'router').router.recognizer.names); - }, + for (var i = 0; i < this.actionArgs.length; i++) { + result[i] = this.actionArgs[i].value(); + } - hasRoute: function (routeName) { - return _emberMetal.get(this, 'router').hasRoute(routeName); - }, + return result; + }; - transitionTo: function (routeName, models, queryParams, shouldReplace) { - var router = _emberMetal.get(this, 'router'); + ActionState.prototype.getTarget = function getTarget() { + var implicitTarget = this.implicitTarget; + var namedArgs = this.namedArgs; - var transition = router._doTransition(routeName, models, queryParams); + var target = undefined; - if (shouldReplace) { - transition.method('replace'); + if (namedArgs.has('target')) { + target = namedArgs.get('target').value(); + } else { + target = implicitTarget.value(); } - return transition; - }, + return target; + }; - normalizeQueryParams: function (routeName, models, queryParams) { - var router = _emberMetal.get(this, 'router'); - router._prepareQueryParams(routeName, models, queryParams); - }, + ActionState.prototype.handler = function handler(event) { + var _this = this; - generateURL: function (routeName, models, queryParams) { - var router = _emberMetal.get(this, 'router'); - if (!router.router) { - return; - } + var actionName = this.actionName; + var namedArgs = this.namedArgs; - var visibleQueryParams = {}; - _emberUtils.assign(visibleQueryParams, queryParams); + var bubbles = namedArgs.get('bubbles'); + var preventDefault = namedArgs.get('preventDefault'); + var allowedKeys = namedArgs.get('allowedKeys'); + var target = this.getTarget(); - this.normalizeQueryParams(routeName, models, visibleQueryParams); + if (!isAllowedEvent(event, allowedKeys.value())) { + return true; + } - var args = _emberRoutingUtils.routeArgs(routeName, models, visibleQueryParams); - return router.generate.apply(router, args); - }, + if (preventDefault.value() !== false) { + event.preventDefault(); + } - isActiveForRoute: function (contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { - var router = _emberMetal.get(this, 'router'); + if (bubbles.value() === false) { + event.stopPropagation(); + } - var handlers = router.router.recognizer.handlersFor(routeName); - var leafName = handlers[handlers.length - 1].handler; - var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); + _emberMetal.run(function () { + var args = _this.getActionArgs(); + var payload = { + args: args, + target: target + }; + if (typeof actionName[_emberGlimmerHelpersAction.INVOKE] === 'function') { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + actionName[_emberGlimmerHelpersAction.INVOKE].apply(actionName, args); + }); + return; + } + if (typeof actionName === 'function') { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + actionName.apply(target, args); + }); + return; + } + payload.name = actionName; + if (target.send) { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + target.send.apply(target, [actionName].concat(args)); + }); + } else { + _emberMetal.assert('The action \'' + actionName + '\' did not exist on ' + target, typeof target[actionName] === 'function'); + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + target[actionName].apply(target, args); + }); + } + }); + }; - // NOTE: any ugliness in the calculation of activeness is largely - // due to the fact that we support automatic normalizing of - // `resource` -> `resource.index`, even though there might be - // dynamic segments / query params defined on `resource.index` - // which complicates (and makes somewhat ambiguous) the calculation - // of activeness for links that link to `resource` instead of - // directly to `resource.index`. + ActionState.prototype.destroy = function destroy() { + ActionHelper.unregisterAction(this); + }; - // if we don't have enough contexts revert back to full route name - // this is because the leaf route will use one of the contexts - if (contexts.length > maximumContexts) { - routeName = leafName; - } + return ActionState; + })(); - return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified); - } - }); + exports.ActionState = ActionState; - function numberOfContextsAcceptedByHandler(handler, handlerInfos) { - var req = 0; - for (var i = 0; i < handlerInfos.length; i++) { - req = req + handlerInfos[i].names.length; - if (handlerInfos[i].handler === handler) { - break; - } + var ActionModifierManager = (function () { + function ActionModifierManager() { + babelHelpers.classCallCheck(this, ActionModifierManager); } - return req; - } -}); -enifed('ember-routing/system/cache', ['exports', 'ember-utils', 'ember-runtime'], function (exports, _emberUtils, _emberRuntime) { - 'use strict'; + ActionModifierManager.prototype.create = function create(element, args, dynamicScope, dom) { + var named = args.named; + var positional = args.positional; - /** - A two-tiered cache with support for fallback values when doing lookups. - Uses "buckets" and then "keys" to cache values. - - @private - @class BucketCache - */ - exports.default = _emberRuntime.Object.extend({ - init: function () { - this.cache = new _emberUtils.EmptyObject(); - }, + var implicitTarget = undefined; + var actionName = undefined; + var actionNameRef = undefined; + if (positional.length > 1) { + implicitTarget = positional.at(0); + actionNameRef = positional.at(1); - has: function (bucketKey) { - return !!this.cache[bucketKey]; - }, + if (actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { + actionName = actionNameRef; + } else { + var actionLabel = actionNameRef._propertyKey; + actionName = actionNameRef.value(); - stash: function (bucketKey, key, value) { - var bucket = this.cache[bucketKey]; + _emberMetal.assert('You specified a quoteless path, `' + actionLabel + '`, to the ' + '{{action}} helper which did not resolve to an action name (a ' + 'string). Perhaps you meant to use a quoted actionName? (e.g. ' + '{{action "' + actionLabel + '"}}).', typeof actionName === 'string' || typeof actionName === 'function'); + } + } - if (!bucket) { - bucket = this.cache[bucketKey] = new _emberUtils.EmptyObject(); + var actionArgs = []; + // The first two arguments are (1) `this` and (2) the action name. + // Everything else is a param. + for (var i = 2; i < positional.length; i++) { + actionArgs.push(positional.at(i)); } - bucket[key] = value; - }, + var actionId = _emberUtils.uuid(); + return new ActionState(element, actionId, actionName, actionArgs, named, positional, implicitTarget, dom); + }; - lookup: function (bucketKey, prop, defaultValue) { - var cache = this.cache; - if (!this.has(bucketKey)) { - return defaultValue; - } + ActionModifierManager.prototype.install = function install(actionState) { + var dom = actionState.dom; + var element = actionState.element; + var actionId = actionState.actionId; - var bucket = cache[bucketKey]; - if (prop in bucket && bucket[prop] !== undefined) { - return bucket[prop]; - } else { - return defaultValue; + ActionHelper.registerAction(actionState); + + dom.setAttribute(element, 'data-ember-action', ''); + dom.setAttribute(element, 'data-ember-action-' + actionId, actionId); + }; + + ActionModifierManager.prototype.update = function update(actionState) { + var positional = actionState.positional; + + var actionNameRef = positional.at(1); + + if (!actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { + actionState.actionName = actionNameRef.value(); } - } - }); + actionState.eventName = actionState.getEventName(); + + // Not sure if this is needed? If we mutate the actionState is that good enough? + ActionHelper.unregisterAction(actionState); + ActionHelper.registerAction(actionState); + }; + + ActionModifierManager.prototype.getDestructor = function getDestructor(modifier) { + return modifier; + }; + + return ActionModifierManager; + })(); + + exports.default = ActionModifierManager; }); -enifed("ember-routing/system/controller_for", ["exports"], function (exports) { - /** - @module ember - @submodule ember-routing - */ +enifed('ember-glimmer/protocol-for-url', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + /* globals module, URL */ - /** - Finds a controller instance. - - @for Ember - @method controllerFor - @private - */ - "use strict"; + 'use strict'; - exports.default = controllerFor; + exports.default = installProtocolForURL; - function controllerFor(container, controllerName, lookupOptions) { - return container.lookup("controller:" + controllerName, lookupOptions); + var nodeURL = undefined; + var parsingNode = undefined; + + function installProtocolForURL(environment) { + var protocol = undefined; + + if (_emberEnvironment.environment.hasDOM) { + protocol = browserProtocolForURL.call(environment, 'foobar:baz'); + } + + // Test to see if our DOM implementation parses + // and normalizes URLs. + if (protocol === 'foobar:') { + // Swap in the method that doesn't do this test now that + // we know it works. + environment.protocolForURL = browserProtocolForURL; + } else if (typeof URL === 'object') { + // URL globally provided, likely from FastBoot's sandbox + nodeURL = URL; + environment.protocolForURL = nodeProtocolForURL; + } else if (typeof module === 'object' && typeof module.require === 'function') { + // Otherwise, we need to fall back to our own URL parsing. + // Global `require` is shadowed by Ember's loader so we have to use the fully + // qualified `module.require`. + nodeURL = module.require('url'); + environment.protocolForURL = nodeProtocolForURL; + } else { + throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); + } + } + + function browserProtocolForURL(url) { + if (!parsingNode) { + parsingNode = document.createElement('a'); + } + + parsingNode.href = url; + return parsingNode.protocol; + } + + function nodeProtocolForURL(url) { + var protocol = null; + if (typeof url === 'string') { + protocol = nodeURL.parse(url).protocol; + } + return protocol === null ? ':' : protocol; } }); -enifed('ember-routing/system/dsl', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { +enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', 'ember-metal', '@glimmer/reference', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/outlet'], function (exports, _emberGlimmerUtilsReferences, _emberMetal, _glimmerReference, _emberViews, _emberGlimmerComponent, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxOutlet) { 'use strict'; - /** - @module ember - @submodule ember-routing - */ + var backburner = _emberMetal.run.backburner; + + var DynamicScope = (function () { + function DynamicScope(view, outletState, rootOutletState, targetObject) { + babelHelpers.classCallCheck(this, DynamicScope); - function DSL(name, options) { - this.parent = name; - this.enableLoadingSubstates = options && options.enableLoadingSubstates; - this.matches = []; - this.explicitIndex = undefined; - this.options = options; - } + this.view = view; + this.outletState = outletState; + this.rootOutletState = rootOutletState; + } - exports.default = DSL; + DynamicScope.prototype.child = function child() { + return new DynamicScope(this.view, this.outletState, this.rootOutletState); + }; - DSL.prototype = { - route: function (name, options, callback) { - var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; - if (arguments.length === 2 && typeof options === 'function') { - callback = options; - options = {}; - } + DynamicScope.prototype.get = function get(key) { + _emberMetal.assert('Using `-get-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); + return this.outletState; + }; - if (arguments.length === 1) { - options = {}; - } + DynamicScope.prototype.set = function set(key, value) { + _emberMetal.assert('Using `-with-dynamic-scope` is only supported for `outletState` (you used `' + key + '`).', key === 'outletState'); + this.outletState = value; + return value; + }; - _emberMetal.assert('\'' + name + '\' cannot be used as a route name.', (function () { - if (options.overrideNameAssertion === true) { - return true; - } + return DynamicScope; + })(); - return ['array', 'basic', 'object', 'application'].indexOf(name) === -1; - })()); + var RootState = (function () { + function RootState(root, env, template, self, parentElement, dynamicScope) { + var _this = this; - if (this.enableLoadingSubstates) { - createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace }); - createRoute(this, name + '_error', { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); - } + babelHelpers.classCallCheck(this, RootState); - if (callback) { - var fullName = getFullName(this, name, options.resetNamespace); - var dsl = new DSL(fullName, this.options); + _emberMetal.assert('You cannot render `' + self.value() + '` without a template.', template); - createRoute(dsl, 'loading'); - createRoute(dsl, 'error', { path: dummyErrorRoute }); + this.id = _emberViews.getViewId(root); + this.env = env; + this.root = root; + this.result = undefined; + this.shouldReflush = false; + this.destroyed = false; + this._removing = false; - callback.call(dsl); + var options = this.options = { + alwaysRevalidate: false + }; - createRoute(this, name, options, dsl.generate()); - } else { - createRoute(this, name, options); - } - }, + this.render = function () { + var result = _this.result = template.render(self, parentElement, dynamicScope); - push: function (url, name, callback, serialize) { - var parts = name.split('.'); + // override .render function after initial render + _this.render = function () { + result.rerender(options); + }; + }; + } - if (this.options.engineInfo) { - var localFullName = name.slice(this.options.engineInfo.fullName.length + 1); - var routeInfo = _emberUtils.assign({ localFullName: localFullName }, this.options.engineInfo); + RootState.prototype.isFor = function isFor(possibleRoot) { + return this.root === possibleRoot; + }; - if (serialize) { - routeInfo.serializeMethod = serialize; - } + RootState.prototype.destroy = function destroy() { + var result = this.result; + var env = this.env; - this.options.addRouteForEngine(name, routeInfo); - } else if (serialize) { - throw new Error('Defining a route serializer on route \'' + name + '\' outside an Engine is not allowed.'); - } + this.destroyed = true; - if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { - this.explicitIndex = true; - } + this.env = null; + this.root = null; + this.result = null; + this.render = null; - this.matches.push([url, name, callback]); - }, + if (result) { + /* + Handles these scenarios: + * When roots are removed during standard rendering process, a transaction exists already + `.begin()` / `.commit()` are not needed. + * When roots are being destroyed manually (`component.append(); component.destroy() case), no + transaction exists already. + * When roots are being destroyed during `Renderer#destroy`, no transaction exists + */ + var needsTransaction = !env.inTransaction; - resource: function (name, options, callback) { - if (arguments.length === 2 && typeof options === 'function') { - callback = options; - options = {}; - } + if (needsTransaction) { + env.begin(); + } - if (arguments.length === 1) { - options = {}; + result.destroy(); + + if (needsTransaction) { + env.commit(); + } } + }; - options.resetNamespace = true; - _emberMetal.deprecate('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.', false, { id: 'ember-routing.router-resource', until: '3.0.0' }); - this.route(name, options, callback); - }, + return RootState; + })(); - generate: function () { - var dslMatches = this.matches; + var renderers = []; - if (!this.explicitIndex) { - this.route('index', { path: '/' }); - } + _emberMetal.setHasViews(function () { + return renderers.length > 0; + }); - return function (match) { - for (var i = 0; i < dslMatches.length; i++) { - var dslMatch = dslMatches[i]; - match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); - } - }; - } - }; + function register(renderer) { + _emberMetal.assert('Cannot register the same renderer twice', renderers.indexOf(renderer) === -1); + renderers.push(renderer); + } - function canNest(dsl) { - return dsl.parent && dsl.parent !== 'application'; + function deregister(renderer) { + var index = renderers.indexOf(renderer); + _emberMetal.assert('Cannot deregister unknown unregistered renderer', index !== -1); + renderers.splice(index, 1); } - function getFullName(dsl, name, resetNamespace) { - if (canNest(dsl) && resetNamespace !== true) { - return dsl.parent + '.' + name; - } else { - return name; + function loopBegin() { + for (var i = 0; i < renderers.length; i++) { + renderers[i]._scheduleRevalidate(); } } - function createRoute(dsl, name, options, callback) { - options = options || {}; - - var fullName = getFullName(dsl, name, options.resetNamespace); + function K() {} - if (typeof options.path !== 'string') { - options.path = '/' + name; + var loops = 0; + function loopEnd(current, next) { + for (var i = 0; i < renderers.length; i++) { + if (!renderers[i]._isValid()) { + if (loops > 10) { + loops = 0; + // TODO: do something better + renderers[i].destroy(); + throw new Error('infinite rendering invalidation detected'); + } + loops++; + return backburner.join(null, K); + } } - - dsl.push(options.path, fullName, callback, options.serialize); + loops = 0; } - DSL.map = function (callback) { - var dsl = new DSL(); - callback.call(dsl); - return dsl; - }; + backburner.on('begin', loopBegin); + backburner.on('end', loopEnd); - var uuid = 0; + var Renderer = (function () { + function Renderer(env, rootTemplate) { + var _viewRegistry = arguments.length <= 2 || arguments[2] === undefined ? _emberViews.fallbackViewRegistry : arguments[2]; - DSL.prototype.mount = function (_name, _options) { - var options = _options || {}; - var engineRouteMap = this.options.resolveRouteMap(_name); - var name = _name; + var destinedForDOM = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; + babelHelpers.classCallCheck(this, Renderer); - if (options.as) { - name = options.as; + this._env = env; + this._rootTemplate = rootTemplate; + this._viewRegistry = _viewRegistry; + this._destinedForDOM = destinedForDOM; + this._destroyed = false; + this._roots = []; + this._lastRevision = null; + this._isRenderingRoots = false; + this._removedRoots = []; } - var fullName = getFullName(this, name, options.resetNamespace); + // renderer HOOKS + + Renderer.prototype.appendOutletView = function appendOutletView(view, target) { + var definition = new _emberGlimmerSyntaxOutlet.TopLevelOutletComponentDefinition(view); + var outletStateReference = view.toReference(); + var targetObject = view.outletState.render.controller; - var engineInfo = { - name: _name, - instanceId: uuid++, - mountPoint: fullName, - fullName: fullName + this._appendDefinition(view, definition, target, outletStateReference, targetObject); }; - var path = options.path; + Renderer.prototype.appendTo = function appendTo(view, target) { + var rootDef = new _emberGlimmerSyntaxCurlyComponent.RootComponentDefinition(view); - if (typeof path !== 'string') { - path = '/' + name; - } + this._appendDefinition(view, rootDef, target); + }; - var callback = undefined; - var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; - if (engineRouteMap) { - var shouldResetEngineInfo = false; - var oldEngineInfo = this.options.engineInfo; - if (oldEngineInfo) { - shouldResetEngineInfo = true; - this.options.engineInfo = engineInfo; - } + Renderer.prototype._appendDefinition = function _appendDefinition(root, definition, target) { + var outletStateReference = arguments.length <= 3 || arguments[3] === undefined ? _glimmerReference.UNDEFINED_REFERENCE : arguments[3]; + var targetObject = arguments.length <= 4 || arguments[4] === undefined ? null : arguments[4]; - var optionsForChild = _emberUtils.assign({ engineInfo: engineInfo }, this.options); - var childDSL = new DSL(fullName, optionsForChild); + var self = new _emberGlimmerUtilsReferences.RootReference(definition); + var dynamicScope = new DynamicScope(null, outletStateReference, outletStateReference, true, targetObject); + var rootState = new RootState(root, this._env, this._rootTemplate, self, target, dynamicScope); - createRoute(childDSL, 'loading'); - createRoute(childDSL, 'error', { path: dummyErrorRoute }); + this._renderRoot(rootState); + }; - engineRouteMap.call(childDSL); + Renderer.prototype.rerender = function rerender(view) { + this._scheduleRevalidate(); + }; - callback = childDSL.generate(); + Renderer.prototype.register = function register(view) { + var id = _emberViews.getViewId(view); + _emberMetal.assert('Attempted to register a view with an id already in use: ' + id, !this._viewRegistry[id]); + this._viewRegistry[id] = view; + }; - if (shouldResetEngineInfo) { - this.options.engineInfo = oldEngineInfo; - } - } + Renderer.prototype.unregister = function unregister(view) { + delete this._viewRegistry[_emberViews.getViewId(view)]; + }; - var localFullName = 'application'; - var routeInfo = _emberUtils.assign({ localFullName: localFullName }, engineInfo); + Renderer.prototype.remove = function remove(view) { + view._transitionTo('destroying'); - if (this.enableLoadingSubstates) { - // These values are important to register the loading routes under their - // proper names for the Router and within the Engine's registry. - var substateName = name + '_loading'; - var _localFullName = 'application_loading'; - var _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); - createRoute(this, substateName, { resetNamespace: options.resetNamespace }); - this.options.addRouteForEngine(substateName, _routeInfo); + this.cleanupRootFor(view); - substateName = name + '_error'; - _localFullName = 'application_error'; - _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); - createRoute(this, substateName, { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); - this.options.addRouteForEngine(substateName, _routeInfo); - } + _emberViews.setViewElement(view, null); - this.options.addRouteForEngine(fullName, routeInfo); + if (this._destinedForDOM) { + view.trigger('didDestroyElement'); + } - this.push(path, fullName, callback); - }; -}); -enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + if (!view.isDestroying) { + view.destroy(); + } + }; - exports.generateControllerFactory = generateControllerFactory; - exports.default = generateController; + Renderer.prototype.cleanupRootFor = function cleanupRootFor(view) { + // no need to cleanup roots if we have already been destroyed + if (this._destroyed) { + return; + } - /** - @module ember - @submodule ember-routing - */ + var roots = this._roots; - /** - Generates a controller factory - - @for Ember - @method generateControllerFactory - @private - */ + // traverse in reverse so we can remove items + // without mucking up the index + var i = this._roots.length; + while (i--) { + var root = roots[i]; + if (root.isFor(view)) { + root.destroy(); + } + } + }; - function generateControllerFactory(owner, controllerName) { - var Factory = owner._lookupFactory('controller:basic').extend({ - isGenerated: true, - toString: function () { - return '(generated ' + controllerName + ' controller)'; + Renderer.prototype.destroy = function destroy() { + if (this._destroyed) { + return; } - }); + this._destroyed = true; + this._clearAllRoots(); + }; - var fullName = 'controller:' + controllerName; + Renderer.prototype.getElement = function getElement(view) { + // overriden in the subclasses + }; - owner.register(fullName, Factory); + Renderer.prototype.getBounds = function getBounds(view) { + var bounds = view[_emberGlimmerComponent.BOUNDS]; - return Factory; - } + var parentElement = bounds.parentElement(); + var firstNode = bounds.firstNode(); + var lastNode = bounds.lastNode(); - /** - Generates and instantiates a controller extending from `controller:basic` - if present, or `Ember.Controller` if not. - - @for Ember - @method generateController - @private - @since 1.3.0 - */ + return { parentElement: parentElement, firstNode: firstNode, lastNode: lastNode }; + }; - function generateController(owner, controllerName) { - generateControllerFactory(owner, controllerName); + Renderer.prototype.createElement = function createElement(tagName) { + return this._env.getAppendOperations().createElement(tagName); + }; - var fullName = 'controller:' + controllerName; - var instance = owner.lookup(fullName); + Renderer.prototype._renderRoot = function _renderRoot(root) { + var roots = this._roots; - if (_emberMetal.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { - _emberMetal.info('generated -> ' + fullName, { fullName: fullName }); - } + roots.push(root); - return instance; - } -}); -enifed('ember-routing/system/query_params', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { - 'use strict'; + if (roots.length === 1) { + register(this); + } - exports.default = _emberRuntime.Object.extend({ - isQueryParams: true, - values: null - }); -}); -enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-routing/system/generate_controller', 'ember-routing/utils'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberRoutingSystemGenerate_controller, _emberRoutingUtils) { - 'use strict'; + this._renderRootsTransaction(); + }; - exports.defaultSerialize = defaultSerialize; - exports.hasDefaultSerialize = hasDefaultSerialize; - var slice = Array.prototype.slice; + Renderer.prototype._renderRoots = function _renderRoots() { + var roots = this._roots; + var env = this._env; + var removedRoots = this._removedRoots; - function K() { - return this; - } + var globalShouldReflush = undefined, + initialRootsLength = undefined; - function defaultSerialize(model, params) { - if (params.length < 1) { - return; - } - if (!model) { - return; - } + do { + env.begin(); - var name = params[0]; - var object = {}; + // ensure that for the first iteration of the loop + // each root is processed + initialRootsLength = roots.length; + globalShouldReflush = false; - if (params.length === 1) { - if (name in model) { - object[name] = _emberMetal.get(model, name); - } else if (/_id$/.test(name)) { - object[name] = _emberMetal.get(model, 'id'); - } - } else { - object = _emberMetal.getProperties(model, params); - } + for (var i = 0; i < roots.length; i++) { + var root = roots[i]; - return object; - } + if (root.destroyed) { + // add to the list of roots to be removed + // they will be removed from `this._roots` later + removedRoots.push(root); - var DEFAULT_SERIALIZE = _emberUtils.symbol('DEFAULT_SERIALIZE'); + // skip over roots that have been marked as destroyed + continue; + } - defaultSerialize[DEFAULT_SERIALIZE] = true; + var shouldReflush = root.shouldReflush; - function hasDefaultSerialize(route) { - return !!route.serialize[DEFAULT_SERIALIZE]; - } + // when processing non-initial reflush loops, + // do not process more roots than needed + if (i >= initialRootsLength && !shouldReflush) { + continue; + } - /** - @module ember - @submodule ember-routing - */ + root.options.alwaysRevalidate = shouldReflush; + // track shouldReflush based on this roots render result + shouldReflush = root.shouldReflush = _emberMetal.runInTransaction(root, 'render'); - /** - The `Ember.Route` class is used to define individual routes. Refer to - the [routing guide](http://emberjs.com/guides/routing/) for documentation. - - @class Route - @namespace Ember - @extends Ember.Object - @uses Ember.ActionHandler - @uses Ember.Evented - @since 1.0.0 - @public - */ - var Route = _emberRuntime.Object.extend(_emberRuntime.ActionHandler, _emberRuntime.Evented, { - /** - Configuration hash for this route's queryParams. The possible - configuration options and their defaults are as follows - (assuming a query param whose controller property is `page`): - ```javascript - queryParams: { - page: { - // By default, controller query param properties don't - // cause a full transition when they are changed, but - // rather only cause the URL to update. Setting - // `refreshModel` to true will cause an "in-place" - // transition to occur, whereby the model hooks for - // this route (and any child routes) will re-fire, allowing - // you to reload models (e.g., from the server) using the - // updated query param values. - refreshModel: false, - // By default, changes to controller query param properties - // cause the URL to update via `pushState`, which means an - // item will be added to the browser's history, allowing - // you to use the back button to restore the app to the - // previous state before the query param property was changed. - // Setting `replace` to true will use `replaceState` (or its - // hash location equivalent), which causes no browser history - // item to be added. This options name and default value are - // the same as the `link-to` helper's `replace` option. - replace: false, - // By default, the query param URL key is the same name as - // the controller property name. Use `as` to specify a - // different URL key. - as: 'page' + // globalShouldReflush should be `true` if *any* of + // the roots need to reflush + globalShouldReflush = globalShouldReflush || shouldReflush; } - } - ``` - @property queryParams - @for Ember.Route - @type Object - @since 1.6.0 - @public - */ - queryParams: {}, - - /** - The name of the route, dot-delimited. - For example, a route found at `app/routes/posts/post.js` will have - a `routeName` of `posts.post`. - @property routeName - @for Ember.Route - @type String - @since 1.0.0 - @public - */ - /** - Sets the name for this route, including a fully resolved name for routes - inside engines. - @private - @method _setRouteName - @param {String} name - */ - _setRouteName: function (name) { - this.routeName = name; - this.fullRouteName = getEngineRouteName(_emberUtils.getOwner(this), name); - }, - - /** - Populates the QP meta information in the BucketCache. - @private - @method _populateQPMeta - */ - _populateQPMeta: function () { - this._bucketCache.stash('route-meta', this.fullRouteName, this.get('_qp')); - }, - - /** - @private - @property _qp - */ - _qp: _emberMetal.computed(function () { - var _this = this; + this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - var controllerProto = undefined, - combinedQueryParameterConfiguration = undefined; + env.commit(); + } while (globalShouldReflush || roots.length > initialRootsLength); - var controllerName = this.controllerName || this.routeName; - var definedControllerClass = _emberUtils.getOwner(this)._lookupFactory('controller:' + controllerName); - var queryParameterConfiguraton = _emberMetal.get(this, 'queryParams'); - var hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; + // remove any roots that were destroyed during this transaction + while (removedRoots.length) { + var root = removedRoots.pop(); - if (definedControllerClass) { - // the developer has authored a controller class in their application for this route - // access the prototype, find its query params and normalize their object shape - // them merge in the query params for the route. As a mergedProperty, Route#queryParams is always - // at least `{}` - controllerProto = definedControllerClass.proto(); + var rootIndex = roots.indexOf(root); + roots.splice(rootIndex, 1); + } - var controllerDefinedQueryParameterConfiguration = _emberMetal.get(controllerProto, 'queryParams'); - var normalizedControllerQueryParameterConfiguration = _emberRoutingUtils.normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); - combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton); - } else if (hasRouterDefinedQueryParams) { - // the developer has not defined a controller but *has* supplied route query params. - // Generate a class for them so we can later insert default values - var generatedControllerClass = _emberRoutingSystemGenerate_controller.generateControllerFactory(_emberUtils.getOwner(this), controllerName); - controllerProto = generatedControllerClass.proto(); - combinedQueryParameterConfiguration = queryParameterConfiguraton; + if (this._roots.length === 0) { + deregister(this); } + }; - var qps = []; - var map = {}; - var propertyNames = []; + Renderer.prototype._renderRootsTransaction = function _renderRootsTransaction() { + if (this._isRenderingRoots) { + // currently rendering roots, a new root was added and will + // be processed by the existing _renderRoots invocation + return; + } - for (var propName in combinedQueryParameterConfiguration) { - if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { - continue; - } + // used to prevent calling _renderRoots again (see above) + // while we are actively rendering roots + this._isRenderingRoots = true; - // to support the dubious feature of using unknownProperty - // on queryParams configuration - if (propName === 'unknownProperty' || propName === '_super') { - // possible todo: issue deprecation warning? - continue; + var completedWithoutError = false; + try { + this._renderRoots(); + completedWithoutError = true; + } finally { + if (!completedWithoutError) { + this._lastRevision = _glimmerReference.CURRENT_TAG.value(); } + this._isRenderingRoots = false; + } + }; - var desc = combinedQueryParameterConfiguration[propName]; - var scope = desc.scope || 'model'; - var parts = undefined; + Renderer.prototype._clearAllRoots = function _clearAllRoots() { + var roots = this._roots; + for (var i = 0; i < roots.length; i++) { + var root = roots[i]; + root.destroy(); + } - if (scope === 'controller') { - parts = []; - } + this._removedRoots.length = 0; + this._roots = null; - var urlKey = desc.as || this.serializeQueryParamKey(propName); - var defaultValue = _emberMetal.get(controllerProto, propName); + // if roots were present before destroying + // deregister this renderer instance + if (roots.length) { + deregister(this); + } + }; - if (Array.isArray(defaultValue)) { - defaultValue = _emberRuntime.A(defaultValue.slice()); - } + Renderer.prototype._scheduleRevalidate = function _scheduleRevalidate() { + backburner.scheduleOnce('render', this, this._revalidate); + }; - var type = desc.type || _emberRuntime.typeOf(defaultValue); + Renderer.prototype._isValid = function _isValid() { + return this._destroyed || this._roots.length === 0 || _glimmerReference.CURRENT_TAG.validate(this._lastRevision); + }; - var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); - var scopedPropertyName = controllerName + ':' + propName; - var qp = { - undecoratedDefaultValue: _emberMetal.get(controllerProto, propName), - defaultValue: defaultValue, - serializedDefaultValue: defaultValueSerialized, - serializedValue: defaultValueSerialized, + Renderer.prototype._revalidate = function _revalidate() { + if (this._isValid()) { + return; + } + this._renderRootsTransaction(); + }; - type: type, - urlKey: urlKey, - prop: propName, - scopedPropertyName: scopedPropertyName, - controllerName: controllerName, - route: this, - parts: parts, // provided later when stashNames is called if 'model' scope - values: null, // provided later when setup is called. no idea why. - scope: scope - }; + return Renderer; + })(); - map[propName] = map[urlKey] = map[scopedPropertyName] = qp; - qps.push(qp); - propertyNames.push(propName); - } + var InertRenderer = (function (_Renderer) { + babelHelpers.inherits(InertRenderer, _Renderer); - return { - qps: qps, - map: map, - propertyNames: propertyNames, - states: { - /* - Called when a query parameter changes in the URL, this route cares - about that query parameter, but the route is not currently - in the active route hierarchy. - */ - inactive: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - }, - /* - Called when a query parameter changes in the URL, this route cares - about that query parameter, and the route is currently - in the active route hierarchy. - */ - active: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - return _this._activeQPChanged(map[prop], value); - }, - /* - Called when a value of a query parameter this route handles changes in a controller - and the route is currently in the active route hierarchy. - */ - allowOverrides: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - return _this._updatingQPChanged(map[prop]); - } - } - }; - }), + function InertRenderer() { + babelHelpers.classCallCheck(this, InertRenderer); - /** - @private - @property _names - */ - _names: null, + _Renderer.apply(this, arguments); + } - /** - @private - @method _stashNames - */ - _stashNames: function (_handlerInfo, dynamicParent) { - var handlerInfo = _handlerInfo; - if (this._names) { - return; - } - var names = this._names = handlerInfo._names; + InertRenderer.create = function create(_ref) { + var env = _ref.env; + var rootTemplate = _ref.rootTemplate; + var _viewRegistry = _ref._viewRegistry; - if (!names.length) { - handlerInfo = dynamicParent; - names = handlerInfo && handlerInfo._names || []; - } + return new this(env, rootTemplate, _viewRegistry, false); + }; - var qps = _emberMetal.get(this, '_qp.qps'); + InertRenderer.prototype.getElement = function getElement(view) { + throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); + }; - var namePaths = new Array(names.length); - for (var a = 0; a < names.length; ++a) { - namePaths[a] = handlerInfo.name + '.' + names[a]; - } + return InertRenderer; + })(Renderer); - for (var i = 0; i < qps.length; ++i) { - var qp = qps[i]; - if (qp.scope === 'model') { - qp.parts = namePaths; - } - } - }, + exports.InertRenderer = InertRenderer; - /** - @private - @property _activeQPChanged - */ - _activeQPChanged: function (qp, value) { - var router = this.router; - router._activeQPChanged(qp.scopedPropertyName, value); - }, + var InteractiveRenderer = (function (_Renderer2) { + babelHelpers.inherits(InteractiveRenderer, _Renderer2); - /** - @private - @method _updatingQPChanged - */ - _updatingQPChanged: function (qp) { - var router = this.router; - router._updatingQPChanged(qp.urlKey); - }, + function InteractiveRenderer() { + babelHelpers.classCallCheck(this, InteractiveRenderer); - mergedProperties: ['queryParams'], + _Renderer2.apply(this, arguments); + } - /** - Returns a hash containing the parameters of an ancestor route. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('member', { path: ':name' }, function() { - this.route('interest', { path: ':interest' }); - }); - }); - ``` - ```app/routes/member.js - export default Ember.Route.extend({ - queryParams: { - memberQp: { refreshModel: true } - } - }); - ``` - ```app/routes/member/interest.js - export default Ember.Route.extend({ - queryParams: { - interestQp: { refreshModel: true } - }, - model() { - return this.paramsFor('member'); - } - }); - ``` - If we visit `/turing/maths?memberQp=member&interestQp=interest` the model for - the `member.interest` route is hash with: - * `name`: `turing` - * `memberQp`: `member` - @method paramsFor - @param {String} name - @return {Object} hash containing the parameters of the route `name` - @since 1.4.0 - @public - */ - paramsFor: function (name) { - var _this2 = this; + InteractiveRenderer.create = function create(_ref2) { + var env = _ref2.env; + var rootTemplate = _ref2.rootTemplate; + var _viewRegistry = _ref2._viewRegistry; - var route = _emberUtils.getOwner(this).lookup('route:' + name); + return new this(env, rootTemplate, _viewRegistry, true); + }; - if (!route) { - return {}; - } + InteractiveRenderer.prototype.getElement = function getElement(view) { + return _emberViews.getViewElement(view); + }; - var transition = this.router.router.activeTransition; - var state = transition ? transition.state : this.router.router.state; + return InteractiveRenderer; + })(Renderer); - var fullName = route.fullRouteName; - var params = _emberUtils.assign({}, state.params[fullName]); - var queryParams = getQueryParamsFor(route, state); + exports.InteractiveRenderer = InteractiveRenderer; +}); +enifed('ember-glimmer/setup-registry', ['exports', 'ember-environment', 'container', 'ember-glimmer/renderer', 'ember-glimmer/dom', 'ember-glimmer/views/outlet', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/templates/component', 'ember-glimmer/templates/root', 'ember-glimmer/templates/outlet', 'ember-glimmer/environment'], function (exports, _emberEnvironment, _container, _emberGlimmerRenderer, _emberGlimmerDom, _emberGlimmerViewsOutlet, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerTemplatesComponent, _emberGlimmerTemplatesRoot, _emberGlimmerTemplatesOutlet, _emberGlimmerEnvironment) { + 'use strict'; - return Object.keys(queryParams).reduce(function (params, key) { - _emberMetal.assert('The route \'' + _this2.routeName + '\' has both a dynamic segment and query param with name \'' + key + '\'. Please rename one to avoid collisions.', !params[key]); - params[key] = queryParams[key]; - return params; - }, params); - }, + exports.setupApplicationRegistry = setupApplicationRegistry; + exports.setupEngineRegistry = setupEngineRegistry; - /** - Serializes the query parameter key - @method serializeQueryParamKey - @param {String} controllerPropertyName - @private - */ - serializeQueryParamKey: function (controllerPropertyName) { - return controllerPropertyName; - }, + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:-root'], ['template:-root']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - /** - Serializes value of the query parameter based on defaultValueType - @method serializeQueryParam - @param {Object} value - @param {String} urlKey - @param {String} defaultValueType - @private - */ - serializeQueryParam: function (value, urlKey, defaultValueType) { - // urlKey isn't used here, but anyone overriding - // can use it to provide serialization specific - // to a certain query param. - return this.router._serializeQueryParam(value, defaultValueType); - }, + function setupApplicationRegistry(registry) { + registry.injection('service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); + registry.injection('renderer', 'env', 'service:-glimmer-environment'); - /** - Deserializes value of the query parameter based on defaultValueType - @method deserializeQueryParam - @param {Object} value - @param {String} urlKey - @param {String} defaultValueType - @private - */ - deserializeQueryParam: function (value, urlKey, defaultValueType) { - // urlKey isn't used here, but anyone overriding - // can use it to provide deserialization specific - // to a certain query param. - return this.router._deserializeQueryParam(value, defaultValueType); - }, + registry.register(_container.privatize(_templateObject), _emberGlimmerTemplatesRoot.default); + registry.injection('renderer', 'rootTemplate', _container.privatize(_templateObject)); - /** - @private - @property _optionsForQueryParam - */ - _optionsForQueryParam: function (qp) { - return _emberMetal.get(this, 'queryParams.' + qp.urlKey) || _emberMetal.get(this, 'queryParams.' + qp.prop) || {}; - }, + registry.register('renderer:-dom', _emberGlimmerRenderer.InteractiveRenderer); + registry.register('renderer:-inert', _emberGlimmerRenderer.InertRenderer); - /** - A hook you can use to reset controller values either when the model - changes or the route is exiting. - ```app/routes/articles.js - import Ember from 'ember'; - export default Ember.Route.extend({ - resetController(controller, isExiting, transition) { - if (isExiting) { - controller.set('page', 1); - } - } - }); - ``` - @method resetController - @param {Controller} controller instance - @param {Boolean} isExiting - @param {Object} transition - @since 1.7.0 - @public - */ - resetController: K, + if (_emberEnvironment.environment.hasDOM) { + registry.injection('service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); + } - /** - @private - @method exit - */ - exit: function () { - this.deactivate(); - this.trigger('deactivate'); - this.teardownViews(); - }, + registry.register('service:-dom-changes', { + create: function (_ref) { + var document = _ref.document; - /** - @private - @method _reset - @since 1.7.0 - */ - _reset: function (isExiting, transition) { - var controller = this.controller; - controller._qpDelegate = _emberMetal.get(this, '_qp.states.inactive'); + return new _emberGlimmerDom.DOMChanges(document); + } + }); - this.resetController(controller, isExiting, transition); - }, + registry.register('service:-dom-tree-construction', { + create: function (_ref2) { + var document = _ref2.document; - /** - @private - @method enter - */ - enter: function () { - this.connections = []; - this.activate(); - this.trigger('activate'); - }, + var Implementation = _emberEnvironment.environment.hasDOM ? _emberGlimmerDom.DOMTreeConstruction : _emberGlimmerDom.NodeDOMTreeConstruction; + return new Implementation(document); + } + }); + } - /** - The name of the template to use by default when rendering this routes - template. - ```app/routes/posts/list.js - import Ember from 'ember'; - export default Ember.Route.extend({ - templateName: 'posts/list' - }); - ``` - ```app/routes/posts/index.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - ```app/routes/posts/archived.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - @property templateName - @type String - @default null - @since 1.4.0 - @public - */ - templateName: null, + function setupEngineRegistry(registry) { + registry.register('view:-outlet', _emberGlimmerViewsOutlet.default); + registry.register('template:-outlet', _emberGlimmerTemplatesOutlet.default); + registry.injection('view:-outlet', 'template', 'template:-outlet'); - /** - The name of the controller to associate with this route. - By default, Ember will lookup a route's controller that matches the name - of the route (i.e. `App.PostController` for `App.PostRoute`). However, - if you would like to define a specific controller to use, you can do so - using this property. - This is useful in many ways, as the controller specified will be: - * passed to the `setupController` method. - * used as the controller for the template being rendered by the route. - * returned from a call to `controllerFor` for the route. - @property controllerName - @type String - @default null - @since 1.4.0 - @public - */ - controllerName: null, + registry.injection('service:-dom-changes', 'document', 'service:-document'); + registry.injection('service:-dom-tree-construction', 'document', 'service:-document'); - /** - The `willTransition` action is fired at the beginning of any - attempted transition with a `Transition` object as the sole - argument. This action can be used for aborting, redirecting, - or decorating the transition from the currently active routes. - A good example is preventing navigation when a form is - half-filled out: - ```app/routes/contact-form.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - willTransition(transition) { - if (this.controller.get('userHasEnteredData')) { - this.controller.displayNavigationConfirm(); - transition.abort(); - } - } - } - }); - ``` - You can also redirect elsewhere by calling - `this.transitionTo('elsewhere')` from within `willTransition`. - Note that `willTransition` will not be fired for the - redirecting `transitionTo`, since `willTransition` doesn't - fire when there is already a transition underway. If you want - subsequent `willTransition` actions to fire for the redirecting - transition, you must first explicitly call - `transition.abort()`. - To allow the `willTransition` event to continue bubbling to the parent - route, use `return true;`. When the `willTransition` method has a - return value of `true` then the parent route's `willTransition` method - will be fired, enabling "bubbling" behavior for the event. - @event willTransition - @param {Transition} transition - @since 1.0.0 - @public - */ + registry.register(_container.privatize(_templateObject2), _emberGlimmerTemplatesComponent.default); + + registry.register('service:-glimmer-environment', _emberGlimmerEnvironment.default); + registry.injection('template', 'env', 'service:-glimmer-environment'); + + registry.optionsForType('helper', { instantiate: false }); + + registry.register('component:-text-field', _emberGlimmerComponentsText_field.default); + registry.register('component:-text-area', _emberGlimmerComponentsText_area.default); + registry.register('component:-checkbox', _emberGlimmerComponentsCheckbox.default); + registry.register('component:link-to', _emberGlimmerComponentsLinkTo.default); + registry.register(_container.privatize(_templateObject3), _emberGlimmerComponent.default); + } +}); +enifed('ember-glimmer/syntax', ['exports', 'ember-glimmer/syntax/render', 'ember-glimmer/syntax/outlet', 'ember-glimmer/syntax/mount', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/bindings', 'ember-glimmer/syntax/-with-dynamic-vars', 'ember-glimmer/syntax/-in-element', 'ember-glimmer/syntax/input', 'ember-glimmer/syntax/-text-area', 'ember-metal'], function (exports, _emberGlimmerSyntaxRender, _emberGlimmerSyntaxOutlet, _emberGlimmerSyntaxMount, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsBindings, _emberGlimmerSyntaxWithDynamicVars, _emberGlimmerSyntaxInElement, _emberGlimmerSyntaxInput, _emberGlimmerSyntaxTextArea, _emberMetal) { + 'use strict'; - /** - The `didTransition` action is fired after a transition has - successfully been completed. This occurs after the normal model - hooks (`beforeModel`, `model`, `afterModel`, `setupController`) - have resolved. The `didTransition` action has no arguments, - however, it can be useful for tracking page views or resetting - state on the controller. - ```app/routes/login.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - didTransition() { - this.controller.get('errors.base').clear(); - return true; // Bubble the didTransition event - } - } - }); - ``` - @event didTransition - @since 1.2.0 - @public - */ + exports.registerMacros = registerMacros; + exports.populateMacros = populateMacros; - /** - The `loading` action is fired on the route when a route's `model` - hook returns a promise that is not already resolved. The current - `Transition` object is the first parameter and the route that - triggered the loading event is the second parameter. - ```app/routes/application.js - export default Ember.Route.extend({ - actions: { - loading(transition, route) { - let controller = this.controllerFor('foo'); - controller.set('currentlyLoading', true); - transition.finally(function() { - controller.set('currentlyLoading', false); - }); - } - } - }); - ``` - @event loading - @param {Transition} transition - @param {Ember.Route} route The route that triggered the loading event - @since 1.2.0 - @public - */ + function refineInlineSyntax(path, params, hash, builder) { + var name = path[0]; - /** - When attempting to transition into a route, any of the hooks - may return a promise that rejects, at which point an `error` - action will be fired on the partially-entered routes, allowing - for per-route error handling logic, or shared error handling - logic defined on a parent route. - Here is an example of an error handler that will be invoked - for rejected promises from the various hooks on the route, - as well as any unhandled errors from child routes: - ```app/routes/admin.js - import Ember from 'ember'; - export default Ember.Route.extend({ - beforeModel() { - return Ember.RSVP.reject('bad things!'); - }, - actions: { - error(error, transition) { - // Assuming we got here due to the error in `beforeModel`, - // we can expect that error === "bad things!", - // but a promise model rejecting would also - // call this hook, as would any errors encountered - // in `afterModel`. - // The `error` hook is also provided the failed - // `transition`, which can be stored and later - // `.retry()`d if desired. - this.transitionTo('login'); - } - } - }); - ``` - `error` actions that bubble up all the way to `ApplicationRoute` - will fire a default error handler that logs the error. You can - specify your own global default error handler by overriding the - `error` handler on `ApplicationRoute`: - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - error(error, transition) { - this.controllerFor('banner').displayError(error.message); - } - } - }); - ``` - @event error - @param {Error} error - @param {Transition} transition - @since 1.0.0 - @public - */ + _emberMetal.assert('You attempted to overwrite the built-in helper "' + name + '" which is not allowed. Please rename the helper.', !(builder.env.builtInHelpers[name] && builder.env.owner.hasRegistration('helper:' + name))); - /** - This event is triggered when the router enters the route. It is - not executed when the model for the route changes. - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - collectAnalytics: Ember.on('activate', function(){ - collectAnalytics(); - }) - }); - ``` - @event activate - @since 1.9.0 - @public - */ + if (path.length > 1) { + return _emberGlimmerSyntaxDynamicComponent.closureComponentMacro(path, params, hash, null, null, builder); + } - /** - This event is triggered when the router completely exits this - route. It is not executed when the model for the route changes. - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - trackPageLeaveAnalytics: Ember.on('deactivate', function(){ - trackPageLeaveAnalytics(); - }) - }); - ``` - @event deactivate - @since 1.9.0 - @public - */ + var symbolTable = builder.symbolTable; - /** - The controller associated with this route. - Example - ```app/routes/form.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - willTransition(transition) { - if (this.controller.get('userHasEnteredData') && - !confirm('Are you sure you want to abandon progress?')) { - transition.abort(); - } else { - // Bubble the `willTransition` action so that - // parent routes can decide whether or not to abort. - return true; - } - } - } - }); - ``` - @property controller - @type Ember.Controller - @since 1.6.0 - @public - */ + var definition = undefined; + if (name.indexOf('-') > -1) { + definition = builder.env.getComponentDefinition(path, symbolTable); + } - actions: { + if (definition) { + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, null, null], symbolTable); + return true; + } - /** - This action is called when one or more query params have changed. Bubbles. - @method queryParamsDidChange - @param changed {Object} Keys are names of query params that have changed. - @param totalPresent {Object} Keys are names of query params that are currently set. - @param removed {Object} Keys are names of query params that have been removed. - @returns {boolean} - @private - */ - queryParamsDidChange: function (changed, totalPresent, removed) { - var qpMap = _emberMetal.get(this, '_qp').map; + return false; + } - var totalChanged = Object.keys(changed).concat(Object.keys(removed)); - for (var i = 0; i < totalChanged.length; ++i) { - var qp = qpMap[totalChanged[i]]; - if (qp && _emberMetal.get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) { - this.refresh(); - } - } + function refineBlockSyntax(sexp, builder) { + var path = sexp[1]; + var params = sexp[2]; + var hash = sexp[3]; + var _default = sexp[4]; + var inverse = sexp[5]; + var name = path[0]; - return true; - }, + if (path.length > 1) { + return _emberGlimmerSyntaxDynamicComponent.closureComponentMacro(path, params, hash, _default, inverse, builder); + } - finalizeQueryParamChange: function (params, finalParams, transition) { - if (this.fullRouteName !== 'application') { - return true; - } + if (name.indexOf('-') === -1) { + return false; + } - // Transition object is absent for intermediate transitions. - if (!transition) { - return; - } + var symbolTable = builder.symbolTable; - var handlerInfos = transition.state.handlerInfos; - var router = this.router; - var qpMeta = router._queryParamsFor(handlerInfos); - var changes = router._qpUpdates; - var replaceUrl = undefined; + var definition = undefined; + if (name.indexOf('-') > -1) { + definition = builder.env.getComponentDefinition(path, symbolTable); + } - _emberRoutingUtils.stashParamNames(router, handlerInfos); + if (definition) { + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, _default, inverse], symbolTable); + return true; + } - for (var i = 0; i < qpMeta.qps.length; ++i) { - var qp = qpMeta.qps[i]; - var route = qp.route; - var controller = route.controller; - var presentKey = qp.urlKey in params && qp.urlKey; + _emberMetal.assert('A component or helper named "' + name + '" could not be found', builder.env.hasHelper(path, symbolTable)); - // Do a reverse lookup to see if the changed query - // param URL key corresponds to a QP property on - // this controller. - var value = undefined, - svalue = undefined; - if (changes && qp.urlKey in changes) { - // Value updated in/before setupController - value = _emberMetal.get(controller, qp.prop); - svalue = route.serializeQueryParam(value, qp.urlKey, qp.type); - } else { - if (presentKey) { - svalue = params[presentKey]; - value = route.deserializeQueryParam(svalue, qp.urlKey, qp.type); - } else { - // No QP provided; use default value. - svalue = qp.serializedDefaultValue; - value = copyDefaultValue(qp.defaultValue); - } - } + _emberMetal.assert('Helpers may not be used in the block form, for example {{#' + name + '}}{{/' + name + '}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (' + name + ')}}{{/if}}.', !builder.env.hasHelper(path, symbolTable)); - controller._qpDelegate = _emberMetal.get(route, '_qp.states.inactive'); + return false; + } - var thisQueryParamChanged = svalue !== qp.serializedValue; - if (thisQueryParamChanged) { - if (transition.queryParamsOnly && replaceUrl !== false) { - var options = route._optionsForQueryParam(qp); - var replaceConfigValue = _emberMetal.get(options, 'replace'); - if (replaceConfigValue) { - replaceUrl = true; - } else if (replaceConfigValue === false) { - // Explicit pushState wins over any other replaceStates. - replaceUrl = false; - } - } + var experimentalMacros = []; - _emberMetal.set(controller, qp.prop, value); - } + // This is a private API to allow for expiremental macros + // to be created in user space. Registering a macro should + // should be done in an initializer. - // Stash current serialized value of controller. - qp.serializedValue = svalue; + function registerMacros(macro) { + experimentalMacros.push(macro); + } - var thisQueryParamHasDefaultValue = qp.serializedDefaultValue === svalue; - if (!thisQueryParamHasDefaultValue) { - finalParams.push({ - value: svalue, - visible: true, - key: presentKey || qp.urlKey - }); - } - } + function populateMacros(blocks, inlines) { + inlines.add('outlet', _emberGlimmerSyntaxOutlet.outletMacro); + inlines.add('component', _emberGlimmerSyntaxDynamicComponent.inlineComponentMacro); + inlines.add('render', _emberGlimmerSyntaxRender.renderMacro); + inlines.add('mount', _emberGlimmerSyntaxMount.mountMacro); + inlines.add('input', _emberGlimmerSyntaxInput.inputMacro); + inlines.add('textarea', _emberGlimmerSyntaxTextArea.textAreaMacro); + inlines.addMissing(refineInlineSyntax); + blocks.add('component', _emberGlimmerSyntaxDynamicComponent.blockComponentMacro); + blocks.add('-with-dynamic-vars', _emberGlimmerSyntaxWithDynamicVars._withDynamicVarsMacro); + blocks.add('-in-element', _emberGlimmerSyntaxInElement._inElementMacro); + blocks.addMissing(refineBlockSyntax); - if (replaceUrl) { - transition.method('replace'); - } + for (var i = 0; i < experimentalMacros.length; i++) { + var macro = experimentalMacros[i]; + macro(blocks, inlines); + } - qpMeta.qps.forEach(function (qp) { - var routeQpMeta = _emberMetal.get(qp.route, '_qp'); - var finalizedController = qp.route.controller; - finalizedController._qpDelegate = _emberMetal.get(routeQpMeta, 'states.active'); - }); + experimentalMacros = []; - router._qpUpdates = null; - } - }, + return { blocks: blocks, inlines: inlines }; + } +}); +enifed('ember-glimmer/syntax/-in-element', ['exports', '@glimmer/runtime', '@glimmer/util'], function (exports, _glimmerRuntime, _glimmerUtil) { + 'use strict'; - /** - This hook is executed when the router completely exits this route. It is - not executed when the model for the route changes. - @method deactivate - @since 1.0.0 - @public - */ - deactivate: K, + exports._inElementMacro = _inElementMacro; + var _BaselineSyntax$NestedBlock = _glimmerRuntime.BaselineSyntax.NestedBlock; + var defaultBlock = _BaselineSyntax$NestedBlock.defaultBlock; + var params = _BaselineSyntax$NestedBlock.params; + var hash = _BaselineSyntax$NestedBlock.hash; - /** - This hook is executed when the router enters the route. It is not executed - when the model for the route changes. - @method activate - @since 1.0.0 - @public - */ - activate: K, + function _inElementMacro(sexp, builder) { + var block = defaultBlock(sexp); + var args = _glimmerRuntime.compileArgs(params(sexp), hash(sexp), builder); - /** - Transition the application into another route. The route may - be either a single route or route path: - ```javascript - this.transitionTo('blogPosts'); - this.transitionTo('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - this.transitionTo('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - this.transitionTo('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```app/routes.js - // ... - Router.map(function() { - this.route('blogPost', { path:':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId' }); - }); - }); - export default Router; - ``` - ```javascript - this.transitionTo('blogComment', aPost, aComment); - this.transitionTo('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - this.transitionTo('/'); - this.transitionTo('/blog/post/1/comment/13'); - this.transitionTo('/blog/posts?sort=title'); - ``` - An options hash with a `queryParams` property may be provided as - the final argument to add query parameters to the destination URL. - ```javascript - this.transitionTo('blogPost', 1, { - queryParams: { showComments: 'true' } - }); - // if you just want to transition the query parameters without changing the route - this.transitionTo({ queryParams: { sort: 'date' } }); - ``` - See also [replaceWith](#method_replaceWith). - Simple Transition Example - ```app/routes.js - // ... - Router.map(function() { - this.route('index'); - this.route('secret'); - this.route('fourOhFour', { path: '*:' }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember': - export Ember.Route.extend({ - actions: { - moveToSecret(context) { - if (authorized()) { - this.transitionTo('secret', context); - } else { - this.transitionTo('fourOhFour'); - } - } - } - }); - ``` - Transition to a nested route - ```app/router.js - // ... - Router.map(function() { - this.route('articles', { path: '/articles' }, function() { - this.route('new'); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - transitionToNewArticle() { - this.transitionTo('articles.new'); - } - } - }); - ``` - Multiple Models Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('breakfast', { path: ':breakfastId' }, function() { - this.route('cereal', { path: ':cerealId' }); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - moveToChocolateCereal() { - let cereal = { cerealId: 'ChocolateYumminess' }; - let breakfast = { breakfastId: 'CerealAndMilk' }; - this.transitionTo('breakfast.cereal', breakfast, cereal); - } - } - }); - ``` - Nested Route with Query String Example - ```app/routes.js - // ... - Router.map(function() { - this.route('fruits', function() { - this.route('apples'); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - transitionToApples() { - this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); - } - } - }); - ``` - @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 - @since 1.0.0 - @public - */ - transitionTo: function (name, context) { - var router = this.router; - return router.transitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, + builder.putArgs(args); + builder.test('simple'); - /** - Perform a synchronous transition into another route without attempting - to resolve promises, update the URL, or abort any currently active - asynchronous transitions (i.e. regular transitions caused by - `transitionTo` or URL changes). - This method is handy for performing intermediate transitions on the - way to a final destination route, and is called internally by the - default implementations of the `error` and `loading` handlers. - @method intermediateTransitionTo - @param {String} name the name of the route - @param {...Object} models the model(s) to be used while transitioning - to the route. - @since 1.2.0 - @public - */ - intermediateTransitionTo: function () { - var router = this.router; - router.intermediateTransitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, + builder.labelled(null, function (b) { + b.jumpUnless('END'); + b.pushRemoteElement(); + b.evaluate(_glimmerUtil.unwrap(block)); + b.popRemoteElement(); + }); + } +}); +enifed('ember-glimmer/syntax/-text-area', ['exports', 'ember-glimmer/utils/bindings'], function (exports, _emberGlimmerUtilsBindings) { + 'use strict'; - /** - Refresh the model on this route and any child routes, firing the - `beforeModel`, `model`, and `afterModel` hooks in a similar fashion - to how routes are entered when transitioning in from other route. - The current route params (e.g. `article_id`) will be passed in - to the respective model hooks, and if a different model is returned, - `setupController` and associated route hooks will re-fire as well. - An example usage of this method is re-querying the server for the - latest information using the same parameters as when the route - was first entered. - Note that this will cause `model` hooks to fire even on routes - that were provided a model object when the route was initially - entered. - @method refresh - @return {Transition} the transition object associated with this - attempted transition - @since 1.4.0 - @public - */ - refresh: function () { - return this.router.router.refresh(this); - }, + exports.textAreaMacro = textAreaMacro; + + function textAreaMacro(path, params, hash, builder) { + var definition = builder.env.getComponentDefinition(['-text-area'], builder.symbolTable); + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; + } +}); +enifed('ember-glimmer/syntax/-with-dynamic-vars', ['exports', '@glimmer/runtime', '@glimmer/util'], function (exports, _glimmerRuntime, _glimmerUtil) { + 'use strict'; + + exports._withDynamicVarsMacro = _withDynamicVarsMacro; + var _BaselineSyntax$NestedBlock = _glimmerRuntime.BaselineSyntax.NestedBlock; + var defaultBlock = _BaselineSyntax$NestedBlock.defaultBlock; + var params = _BaselineSyntax$NestedBlock.params; + var hash = _BaselineSyntax$NestedBlock.hash; + + function _withDynamicVarsMacro(sexp, builder) { + var block = defaultBlock(sexp); + var args = _glimmerRuntime.compileArgs(params(sexp), hash(sexp), builder); + + builder.unit(function (b) { + b.putArgs(args); + b.pushDynamicScope(); + b.bindDynamicScope(args.named.keys); + b.evaluate(_glimmerUtil.unwrap(block)); + b.popDynamicScope(); + }); + } +}); +enifed('ember-glimmer/syntax/abstract-manager', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; + + var AbstractManager = function AbstractManager() { + babelHelpers.classCallCheck(this, AbstractManager); + }; + + _emberMetal.runInDebug(function () { + AbstractManager.prototype._pushToDebugStack = function (name, environment) { + this.debugStack = environment.debugStack; + this.debugStack.push(name); + }; + + AbstractManager.prototype._pushEngineToDebugStack = function (name, environment) { + this.debugStack = environment.debugStack; + this.debugStack.pushEngine(name); + }; + }); + + exports.default = AbstractManager; +}); +enifed('ember-glimmer/syntax/curly-component', ['exports', 'ember-utils', '@glimmer/runtime', 'ember-glimmer/utils/bindings', 'ember-glimmer/component', 'ember-metal', 'ember-views', 'ember-glimmer/utils/process-args', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _emberUtils, _glimmerRuntime, _emberGlimmerUtilsBindings, _emberGlimmerComponent, _emberMetal, _emberViews, _emberGlimmerUtilsProcessArgs, _container, _emberGlimmerSyntaxAbstractManager) { + 'use strict'; + + exports.validatePositionalParameters = validatePositionalParameters; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); - /** - Transition into another route while replacing the current URL, if possible. - This will replace the current history entry instead of adding a new one. - Beside that, it is identical to `transitionTo` in all other respects. See - 'transitionTo' for additional information regarding multiple models. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('secret'); - }); - export default Router; - ``` - ```app/routes/secret.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { - if (!authorized()){ - this.replaceWith('index'); - } - } - }); - ``` - @method replaceWith - @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. - @return {Transition} the transition object associated with this - attempted transition - @since 1.0.0 - @public - */ - replaceWith: function () { - var router = this.router; - return router.replaceWith.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, + var DEFAULT_LAYOUT = _container.privatize(_templateObject); - /** - Sends an action to the router, which will delegate it to the currently - active route hierarchy per the bubbling rules explained under `actions`. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - }); - export default Router; - ``` - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - track(arg) { - console.log(arg, 'was clicked'); - } - } - }); - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - trackIfDebug(arg) { - if (debug) { - this.send('track', arg); - } - } + function processComponentInitializationAssertions(component, props) { + _emberMetal.assert('classNameBindings must not have spaces in them: ' + component.toString(), (function () { + var classNameBindings = component.classNameBindings; + + for (var i = 0; i < classNameBindings.length; i++) { + var binding = classNameBindings[i]; + if (binding.split(' ').length > 1) { + return false; } - }); - ``` - @method send - @param {String} name the name of the action to trigger - @param {...*} args - @since 1.0.0 - @public - */ - send: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; } + return true; + })()); - if (this.router && this.router.router || !_emberMetal.isTesting()) { - var _router; + _emberMetal.assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), (function () { + var classNameBindings = component.classNameBindings; + var tagName = component.tagName; - (_router = this.router).send.apply(_router, args); - } else { - var _name2 = args[0]; - args = slice.call(args, 1); - var action = this.actions[_name2]; - if (action) { - return this.actions[_name2].apply(this, args); - } - } - }, + return tagName !== '' || !classNameBindings || classNameBindings.length === 0; + })()); - /** - This hook is the entry point for router.js - @private - @method setup - */ - setup: function (context, transition) { - var _this3 = this; + _emberMetal.assert('You cannot use `elementId` on a tag-less component: ' + component.toString(), (function () { + var elementId = component.elementId; + var tagName = component.tagName; - var controller = undefined; + return tagName !== '' || props.id === elementId || !elementId && elementId !== ''; + })()); - var controllerName = this.controllerName || this.routeName; - var definedController = this.controllerFor(controllerName, true); + _emberMetal.assert('You cannot use `attributeBindings` on a tag-less component: ' + component.toString(), (function () { + var attributeBindings = component.attributeBindings; + var tagName = component.tagName; - if (!definedController) { - controller = this.generateController(controllerName); + return tagName !== '' || !attributeBindings || attributeBindings.length === 0; + })()); + } + + function validatePositionalParameters(named, positional, positionalParamsDefinition) { + _emberMetal.runInDebug(function () { + if (!named || !positional || !positional.length) { + return; + } + + var paramType = typeof positionalParamsDefinition; + + if (paramType === 'string') { + _emberMetal.assert('You cannot specify positional parameters and the hash argument `' + positionalParamsDefinition + '`.', !named.has(positionalParamsDefinition)); } else { - controller = definedController; + if (positional.length < positionalParamsDefinition.length) { + positionalParamsDefinition = positionalParamsDefinition.slice(0, positional.length); + } + + for (var i = 0; i < positionalParamsDefinition.length; i++) { + var _name = positionalParamsDefinition[i]; + + _emberMetal.assert('You cannot specify both a positional param (at position ' + i + ') and the hash argument `' + _name + '`.', !named.has(_name)); + } } + }); + } - // Assign the route's controller so that it can more easily be - // referenced in action handlers. Side effects. Side effects everywhere. - if (!this.controller) { - var propNames = _emberMetal.get(this, '_qp.propertyNames'); - addQueryParamsObservers(controller, propNames); - this.controller = controller; + function aliasIdToElementId(args, props) { + if (args.named.has('id')) { + _emberMetal.assert('You cannot invoke a component with both \'id\' and \'elementId\' at the same time.', !args.named.has('elementId')); + props.elementId = props.id; + } + } + + // We must traverse the attributeBindings in reverse keeping track of + // what has already been applied. This is essentially refining the concated + // properties applying right to left. + function applyAttributeBindings(element, attributeBindings, component, operations) { + var seen = []; + var i = attributeBindings.length - 1; + + while (i !== -1) { + var binding = attributeBindings[i]; + var parsed = _emberGlimmerUtilsBindings.AttributeBinding.parse(binding); + var attribute = parsed[1]; + + if (seen.indexOf(attribute) === -1) { + seen.push(attribute); + _emberGlimmerUtilsBindings.AttributeBinding.install(element, component, parsed, operations); } - var queryParams = _emberMetal.get(this, '_qp'); + i--; + } - var states = queryParams.states; + if (seen.indexOf('id') === -1) { + operations.addStaticAttribute(element, 'id', component.elementId); + } - controller._qpDelegate = states.allowOverrides; + if (seen.indexOf('style') === -1) { + _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); + } + } - if (transition) { - (function () { - // Update the model dep values used to calculate cache keys. - _emberRoutingUtils.stashParamNames(_this3.router, transition.state.handlerInfos); + function NOOP() {} - var params = transition.params; - var allParams = queryParams.propertyNames; - var cache = _this3._bucketCache; + var ComponentStateBucket = (function () { + function ComponentStateBucket(environment, component, args, finalizer) { +babelHelpers.classCallCheck(this, ComponentStateBucket); - allParams.forEach(function (prop) { - var aQp = queryParams.map[prop]; + this.environment = environment; + this.component = component; + this.classRef = null; + this.args = args; + this.argsRevision = args.tag.value(); + this.finalizer = finalizer; + } - aQp.values = params; - var cacheKey = _emberRoutingUtils.calculateCacheKey(aQp.controllerName, aQp.parts, aQp.values); + ComponentStateBucket.prototype.destroy = function destroy() { + var component = this.component; + var environment = this.environment; - if (cache) { - var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); - _emberMetal.set(controller, prop, value); - } - }); - })(); + if (environment.isInteractive) { + component.trigger('willDestroyElement'); + component.trigger('willClearRender'); } - if (transition) { - var qpValues = getQueryParamsFor(this, transition.state); - controller.setProperties(qpValues); - } + environment.destroyedComponents.push(component); + }; - this.setupController(controller, context, transition); + ComponentStateBucket.prototype.finalize = function finalize() { + var finalizer = this.finalizer; - if (this._environment.options.shouldRender) { - this.renderTemplate(controller, context); - } - }, + finalizer(); + this.finalizer = NOOP; + }; - /* - Called when a query parameter for this route changes, regardless of whether the route - is currently part of the active route hierarchy. This will update the query parameter's - value in the cache so if this route becomes active, the cache value has been updated. - */ - _qpChanged: function (prop, value, qp) { - if (!qp) { - return; - } + return ComponentStateBucket; + })(); - var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.controllerName, qp.parts, qp.values); + function initialRenderInstrumentDetails(component) { + return component.instrumentDetails({ initialRender: true }); + } - // Update model-dep cache - var cache = this._bucketCache; - if (cache) { - cache.stash(cacheKey, prop, value); - } - }, + function rerenderInstrumentDetails(component) { + return component.instrumentDetails({ initialRender: false }); + } - /** - This hook is the first of the route entry validation hooks - called when an attempt is made to transition into a route - or one of its children. It is called before `model` and - `afterModel`, and is appropriate for cases when: - 1) A decision can be made to redirect elsewhere without - needing to resolve the model first. - 2) Any async operations need to occur first before the - model is attempted to be resolved. - This hook is provided the current `transition` attempt - as a parameter, which can be used to `.abort()` the transition, - save it for a later `.retry()`, or retrieve values set - on it from a previous hook. You can also just call - `this.transitionTo` to another route to implicitly - abort the `transition`. - You can return a promise from this hook to pause the - transition until the promise resolves (or rejects). This could - be useful, for instance, for retrieving async code from - the server that is required to enter a route. - @method beforeModel - @param {Transition} transition - @return {Promise} if the value returned from this hook is - a promise, the transition will pause until the transition - resolves. Otherwise, non-promise return values are not - utilized in any way. - @since 1.0.0 - @public - */ - beforeModel: K, + var CurlyComponentManager = (function (_AbstractManager) { +babelHelpers.inherits(CurlyComponentManager, _AbstractManager); - /** - This hook is called after this route's model has resolved. - It follows identical async/promise semantics to `beforeModel` - but is provided the route's resolved model in addition to - the `transition`, and is therefore suited to performing - logic that can only take place after the model has already - resolved. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel(posts, transition) { - if (posts.get('length') === 1) { - this.transitionTo('post.show', posts.get('firstObject')); - } - } - }); - ``` - Refer to documentation for `beforeModel` for a description - of transition-pausing semantics when a promise is returned - from this hook. - @method afterModel - @param {Object} resolvedModel the value returned from `model`, - or its resolved value if it was a promise - @param {Transition} transition - @return {Promise} if the value returned from this hook is - a promise, the transition will pause until the transition - resolves. Otherwise, non-promise return values are not - utilized in any way. - @since 1.0.0 - @public - */ - afterModel: K, + function CurlyComponentManager() { +babelHelpers.classCallCheck(this, CurlyComponentManager); - /** - A hook you can implement to optionally redirect to another route. - If you call `this.transitionTo` from inside of this hook, this route - will not be entered in favor of the other hook. - `redirect` and `afterModel` behave very similarly and are - called almost at the same time, but they have an important - distinction in the case that, from one of these hooks, a - redirect into a child route of this route occurs: redirects - from `afterModel` essentially invalidate the current attempt - to enter this route, and will result in this route's `beforeModel`, - `model`, and `afterModel` hooks being fired again within - the new, redirecting transition. Redirects that occur within - the `redirect` hook, on the other hand, will _not_ cause - these hooks to be fired again the second time around; in - other words, by the time the `redirect` hook has been called, - both the resolved model and attempted entry into this route - are considered to be fully validated. - @method redirect - @param {Object} model the model for this route - @param {Transition} transition the transition object associated with the current transition - @since 1.0.0 - @public - */ - redirect: K, + _AbstractManager.apply(this, arguments); + } - /** - Called when the context is changed by router.js. - @private - @method contextDidChange - */ - contextDidChange: function () { - this.currentModel = this.context; - }, + CurlyComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { + if (definition.ComponentClass) { + validatePositionalParameters(args.named, args.positional.values, definition.ComponentClass.class.positionalParams); + } - /** - A hook you can implement to convert the URL into the model for - this route. - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - The model for the `post` route is `store.findRecord('post', params.post_id)`. - By default, if your route has a dynamic segment ending in `_id`: - * The model class is determined from the segment (`post_id`'s - class is `App.Post`) - * The find method is called on the model class with the value of - the dynamic segment. - Note that for routes with dynamic segments, this hook is not always - executed. If the route is entered through a transition (e.g. when - using the `link-to` Handlebars helper or the `transitionTo` method - of routes), and a model context is already provided this hook - is not called. - A model context does not include a primitive string or number, - which does cause the model hook to be called. - Routes without dynamic segments will always execute the model hook. - ```javascript - // no dynamic segment, model hook always called - this.transitionTo('posts'); - // model passed in, so model hook not called - thePost = store.findRecord('post', 1); - this.transitionTo('post', thePost); - // integer passed in, model hook is called - this.transitionTo('post', 1); - // model id passed in, model hook is called - // useful for forcing the hook to execute - thePost = store.findRecord('post', 1); - this.transitionTo('post', thePost.id); - ``` - This hook follows the asynchronous/promise semantics - described in the documentation for `beforeModel`. In particular, - if a promise returned from `model` fails, the error will be - handled by the `error` hook on `Ember.Route`. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { - return this.store.findRecord('post', params.post_id); - } + return _emberGlimmerUtilsProcessArgs.gatherArgs(args, definition); + }; + + CurlyComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, callerSelfRef, hasBlock) { + var _this = this; + + _emberMetal.runInDebug(function () { + return _this._pushToDebugStack('component:' + definition.name, environment); }); - ``` - @method model - @param {Object} params the parameters extracted from the URL - @param {Transition} transition - @return {Object|Promise} the model for this route. If - a promise is returned, the transition will pause until - the promise resolves, and the resolved value of the promise - will be used as the model for this route. - @since 1.0.0 - @public - */ - model: function (params, transition) { - var name = undefined, - sawParams = undefined, - value = undefined; - var queryParams = _emberMetal.get(this, '_qp.map'); - for (var prop in params) { - if (prop === 'queryParams' || queryParams && prop in queryParams) { - continue; - } + var parentView = dynamicScope.view; - var match = prop.match(/^(.*)_id$/); - if (match) { - name = match[1]; - value = params[prop]; - } - sawParams = true; - } + var factory = definition.ComponentClass; - if (!name && sawParams) { - return _emberRuntime.copy(params); - } else if (!name) { - if (transition.resolveIndex < 1) { - return; - } + var processedArgs = _emberGlimmerUtilsProcessArgs.ComponentArgs.create(args); - var parentModel = transition.state.handlerInfos[transition.resolveIndex - 1].context; + var _processedArgs$value = processedArgs.value(); - return parentModel; - } + var props = _processedArgs$value.props; - return this.findModel(name, value); - }, + aliasIdToElementId(args, props); - /** - @private - @method deserialize - @param {Object} params the parameters extracted from the URL - @param {Transition} transition - @return {Object|Promise} the model for this route. - Router.js hook. - */ - deserialize: function (params, transition) { - return this.model(this.paramsFor(this.routeName), transition); - }, + props.parentView = parentView; + props[_emberGlimmerComponent.HAS_BLOCK] = hasBlock; - /** - @method findModel - @param {String} type the model type - @param {Object} value the value passed to find - @private - */ - findModel: function () { - var store = _emberMetal.get(this, 'store'); - return store.find.apply(store, arguments); - }, + props._targetObject = callerSelfRef.value(); - /** - Store property provides a hook for data persistence libraries to inject themselves. - By default, this store property provides the exact same functionality previously - in the model hook. - Currently, the required interface is: - `store.find(modelName, findArguments)` - @method store - @param {Object} store - @private - */ - store: _emberMetal.computed(function () { - var owner = _emberUtils.getOwner(this); - var routeName = this.routeName; - var namespace = _emberMetal.get(this, 'router.namespace'); + var component = factory.create(props); - return { - find: function (name, value) { - var modelClass = owner._lookupFactory('model:' + name); + var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - _emberMetal.assert('You used the dynamic segment ' + name + '_id in your route ' + routeName + ', but ' + namespace + '.' + _emberRuntime.String.classify(name) + ' did not exist and you did not override your route\'s `model` hook.', !!modelClass); + dynamicScope.view = component; - if (!modelClass) { - return; - } + if (parentView !== null) { + parentView.appendChild(component); + } + + // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components + if (component.tagName === '') { + if (environment.isInteractive) { + component.trigger('willRender'); + } - _emberMetal.assert(_emberRuntime.String.classify(name) + ' has no method `find`.', typeof modelClass.find === 'function'); + component._transitionTo('hasElement'); - return modelClass.find(value); + if (environment.isInteractive) { + component.trigger('willInsertElement'); } - }; - }), + } - /** - A hook you can implement to convert the route's model into parameters - for the URL. - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { - // the server returns `{ id: 12 }` - return Ember.$.getJSON('/posts/' + params.post_id); - }, - serialize(model) { - // this will make the URL `/posts/12` - return { post_id: model.id }; - } - }); - ``` - The default `serialize` method will insert the model's `id` into the - route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'. - If the route has multiple dynamic segments or does not contain '_id', `serialize` - will return `Ember.getProperties(model, params)` - This method is called when `transitionTo` is called with a context - in order to populate the URL. - @method serialize - @param {Object} model the routes model - @param {Array} params an Array of parameter names for the current - route (in the example, `['post_id']`. - @return {Object} the serialized parameters - @since 1.0.0 - @public - */ - serialize: defaultSerialize, + var bucket = new ComponentStateBucket(environment, component, processedArgs, finalizer); - /** - A hook you can use to setup the controller for the current route. - This method is called with the controller for the current route and the - model supplied by the `model` hook. - By default, the `setupController` hook sets the `model` property of - the controller to the `model`. - If you implement the `setupController` hook in your Route, it will - prevent this default behavior. If you want to preserve that behavior - when implementing your `setupController` function, make sure to call - `_super`: - ```app/routes/photos.js - import Ember from 'ebmer'; - export default Ember.Route.extend({ - model() { - return this.store.findAll('photo'); - }, - setupController(controller, model) { - // Call _super for default behavior - this._super(controller, model); - // Implement your custom setup after - this.controllerFor('application').set('showingPhotos', true); - } - }); - ``` - The provided controller will be one resolved based on the name - of this route. - If no explicit controller is defined, Ember will automatically create one. - As an example, consider the router: - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - For the `post` route, a controller named `App.PostController` would - be used if it is defined. If it is not defined, a basic `Ember.Controller` - instance would be used. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, model) { - controller.set('model', model); - } - }); - ``` - @method setupController - @param {Controller} controller instance - @param {Object} model - @since 1.0.0 - @public - */ - setupController: function (controller, context, transition) { - if (controller && context !== undefined) { - _emberMetal.set(controller, 'model', context); + if (args.named.has('class')) { + bucket.classRef = args.named.get('class'); } - }, - /** - Returns the resolved model of the current route, or a parent (or any ancestor) - route in a route hierarchy. - The controller instance must already have been created, either through entering the - associated route or using `generateController`. - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { - this._super(controller, post); - this.controllerFor('posts').set('currentPost', post); - } - }); - ``` - @method controllerFor - @param {String} name the name of the route or controller - @return {Ember.Controller} - @since 1.0.0 - @public - */ - controllerFor: function (name, _skipAssert) { - var owner = _emberUtils.getOwner(this); - var route = owner.lookup('route:' + name); - var controller = undefined; + processComponentInitializationAssertions(component, props); - if (route && route.controllerName) { - name = route.controllerName; + if (environment.isInteractive && component.tagName !== '') { + component.trigger('willRender'); } - controller = owner.lookup('controller:' + name); + return bucket; + }; - // NOTE: We're specifically checking that skipAssert is true, because according - // to the old API the second parameter was model. We do not want people who - // passed a model to skip the assertion. - _emberMetal.assert('The controller named \'' + name + '\' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.', controller || _skipAssert === true); + CurlyComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + var template = definition.template; + if (!template) { + var component = bucket.component; - return controller; - }, + template = this.templateFor(component, env); + } + return env.getCompiledBlock(CurlyComponentLayoutCompiler, template); + }; - /** - Generates a controller for a route. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { - this._super(controller, post); - this.generateController('posts'); + CurlyComponentManager.prototype.templateFor = function templateFor(component, env) { + var Template = _emberMetal.get(component, 'layout'); + var owner = component[_emberUtils.OWNER]; + if (Template) { + return env.getTemplate(Template, owner); + } + var layoutName = _emberMetal.get(component, 'layoutName'); + if (layoutName) { + var template = owner.lookup('template:' + layoutName); + if (template) { + return template; } - }); - ``` - @method generateController - @param {String} name the name of the controller - @private - */ - generateController: function (name) { - var owner = _emberUtils.getOwner(this); + } + return owner.lookup(DEFAULT_LAYOUT); + }; - return _emberRoutingSystemGenerate_controller.default(owner, name); - }, + CurlyComponentManager.prototype.getSelf = function getSelf(_ref) { + var component = _ref.component; - /** - Returns the resolved model of a parent (or any ancestor) route - in a route hierarchy. During a transition, all routes - must resolve a model object, and if a route - needs access to a parent route's model in order to - resolve a model (or just reuse the model from a parent), - it can call `this.modelFor(theNameOfParentRoute)` to - retrieve it. If the ancestor route's model was a promise, - its resolved result is returned. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/post/:post_id' }, function() { - this.route('comments', { resetNamespace: true }); - }); - }); - export default Router; - ``` - ```app/routes/comments.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { - this.set('post', this.modelFor('post')); - } - }); - ``` - @method modelFor - @param {String} name the name of the route - @return {Object} the model object - @since 1.0.0 - @public - */ - modelFor: function (_name) { - var name = undefined; - var owner = _emberUtils.getOwner(this); + return component[_emberGlimmerComponent.ROOT_REF]; + }; - // Only change the route name when there is an active transition. - // Otherwise, use the passed in route name. - if (owner.routable && this.router && this.router.router.activeTransition) { - name = getEngineRouteName(owner, _name); + CurlyComponentManager.prototype.didCreateElement = function didCreateElement(_ref2, element, operations) { + var component = _ref2.component; + var classRef = _ref2.classRef; + var environment = _ref2.environment; + + _emberViews.setViewElement(component, element); + + var attributeBindings = component.attributeBindings; + var classNames = component.classNames; + var classNameBindings = component.classNameBindings; + + if (attributeBindings && attributeBindings.length) { + applyAttributeBindings(element, attributeBindings, component, operations); } else { - name = _name; + operations.addStaticAttribute(element, 'id', component.elementId); + _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); } - var route = _emberUtils.getOwner(this).lookup('route:' + name); - var transition = this.router ? this.router.router.activeTransition : null; + if (classRef) { + operations.addDynamicAttribute(element, 'class', classRef); + } - // If we are mid-transition, we want to try and look up - // resolved parent contexts on the current transitionEvent. - if (transition) { - var modelLookupName = route && route.routeName || name; - if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { - return transition.resolvedModels[modelLookupName]; - } + if (classNames && classNames.length) { + classNames.forEach(function (name) { + operations.addStaticAttribute(element, 'class', name); + }); } - return route && route.currentModel; - }, + if (classNameBindings && classNameBindings.length) { + classNameBindings.forEach(function (binding) { + _emberGlimmerUtilsBindings.ClassNameBinding.install(element, component, binding, operations); + }); + } - /** - A hook you can use to render the template for the current route. - This method is called with the controller for the current route and the - model supplied by the `model` hook. By default, it renders the route's - template, configured with the controller for the route. - This method can be overridden to set up and render additional or - alternative templates. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model) { - let favController = this.controllerFor('favoritePost'); - // Render the `favoritePost` template into - // the outlet `posts`, and display the `favoritePost` - // controller. - this.render('favoritePost', { - outlet: 'posts', - controller: favController - }); - } - }); - ``` - @method renderTemplate - @param {Object} controller the route's controller - @param {Object} model the route's model - @since 1.0.0 - @public - */ - renderTemplate: function (controller, model) { - this.render(); - }, + component._transitionTo('hasElement'); - /** - `render` is used to render a template into a region of another template - (indicated by an `{{outlet}}`). `render` is used both during the entry - phase of routing (via the `renderTemplate` hook) and later in response to - user interaction. - For example, given the following minimal router and templates: - ```app/router.js - // ... - Router.map(function() { - this.route('photos'); - }); - export default Router; - ``` - ```handlebars - -
    - {{outlet "anOutletName"}} -
    - ``` - ```handlebars - -

    Photos

    - ``` - You can render `photos.hbs` into the `"anOutletName"` outlet of - `application.hbs` by calling `render`: - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { - this.render('photos', { - into: 'application', - outlet: 'anOutletName' - }) - } - }); - ``` - `render` additionally allows you to supply which `controller` and - `model` objects should be loaded and associated with the rendered template. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model){ - this.render('posts', { // the template to render, referenced by name - into: 'application', // the template to render into, referenced by name - outlet: 'anOutletName', // the outlet inside `options.template` to render into. - controller: 'someControllerName', // the controller to use for this template, referenced by name - model: model // the model to set on `options.controller`. - }) - } - }); - ``` - The string values provided for the template name, and controller - will eventually pass through to the resolver for lookup. See - Ember.Resolver for how these are mapped to JavaScript objects in your - application. The template to render into needs to be related to either the - current route or one of its ancestors. - Not all options need to be passed to `render`. Default values will be used - based on the name of the route specified in the router or the Route's - `controllerName` and `templateName` properties. - For example: - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { - this.render(); // all defaults apply - } + if (environment.isInteractive) { + component.trigger('willInsertElement'); + } + }; + + CurlyComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket, bounds) { + var _this2 = this; + + bucket.component[_emberGlimmerComponent.BOUNDS] = bounds; + bucket.finalize(); + + _emberMetal.runInDebug(function () { + return _this2.debugStack.pop(); }); - ``` - The name of the route, defined by the router, is `post`. - The following equivalent default options will be applied when - the Route calls `render`: - ```javascript - this.render('post', { // the template name associated with 'post' Route - into: 'application', // the parent route to 'post' Route - outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, - controller: 'post', // the controller associated with the 'post' Route - }) - ``` - By default the controller's `model` will be the route's model, so it does not - need to be passed unless you wish to change which model is being used. - @method render - @param {String} name the name of the template to render - @param {Object} [options] the options - @param {String} [options.into] the template to render into, - referenced by name. Defaults to the parent template - @param {String} [options.outlet] the outlet inside `options.template` to render into. - Defaults to 'main' - @param {String|Object} [options.controller] the controller to use for this template, - referenced by name or as a controller instance. Defaults to the Route's paired controller - @param {Object} [options.model] the model object to set on `options.controller`. - Defaults to the return value of the Route's model hook - @since 1.0.0 - @public - */ - render: function (_name, options) { - _emberMetal.assert('The name in the given arguments is undefined', arguments.length > 0 ? !_emberMetal.isNone(arguments[0]) : true); + }; - var namePassed = typeof _name === 'string' && !!_name; - var isDefaultRender = arguments.length === 0 || _emberMetal.isEmpty(arguments[0]); - var name = undefined; + CurlyComponentManager.prototype.getTag = function getTag(_ref3) { + var component = _ref3.component; - if (typeof _name === 'object' && !options) { - name = this.templateName || this.routeName; - options = _name; - } else { - name = _name; + return component[_emberGlimmerComponent.DIRTY_TAG]; + }; + + CurlyComponentManager.prototype.didCreate = function didCreate(_ref4) { + var component = _ref4.component; + var environment = _ref4.environment; + + if (environment.isInteractive) { + component._transitionTo('inDOM'); + component.trigger('didInsertElement'); + component.trigger('didRender'); } + }; - var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); - this.connections.push(renderOptions); - _emberMetal.run.once(this.router, '_setOutlets'); - }, + CurlyComponentManager.prototype.update = function update(bucket, _, dynamicScope) { + var _this3 = this; - /** - Disconnects a view that has been rendered into an outlet. - You may pass any or all of the following options to `disconnectOutlet`: - * `outlet`: the name of the outlet to clear (default: 'main') - * `parentView`: the name of the view containing the outlet to clear - (default: the view rendered by the parent route) - Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - this.render(evt.modalName, { - outlet: 'modal', - into: 'application' - }); - }, - hideModal(evt) { - this.disconnectOutlet({ - outlet: 'modal', - parentView: 'application' - }); - } - } - }); - ``` - Alternatively, you can pass the `outlet` name directly as a string. - Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - // ... - }, - hideModal(evt) { - this.disconnectOutlet('modal'); - } - } + var component = bucket.component; + var args = bucket.args; + var argsRevision = bucket.argsRevision; + var environment = bucket.environment; + + _emberMetal.runInDebug(function () { + return _this3._pushToDebugStack(component._debugContainerKey, environment); }); - @method disconnectOutlet - @param {Object|String} options the options hash or outlet name - @since 1.0.0 - @public - */ - disconnectOutlet: function (options) { - var outletName = undefined; - var parentView = undefined; - if (!options || typeof options === 'string') { - outletName = options; - } else { - outletName = options.outlet; - parentView = options.parentView; - if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { - throw new _emberMetal.Error('You passed undefined as the outlet name.'); - } - } - parentView = parentView && parentView.replace(/\//g, '.'); - outletName = outletName || 'main'; - this._disconnectOutlet(outletName, parentView); - for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { - // This non-local state munging is sadly necessary to maintain - // backward compatibility with our existing semantics, which allow - // any route to disconnectOutlet things originally rendered by any - // other route. This should all get cut in 2.0. - this.router.router.currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); + bucket.finalizer = _emberMetal._instrumentStart('render.component', rerenderInstrumentDetails, component); + + if (!args.tag.validate(argsRevision)) { + var _args$value = args.value(); + + var attrs = _args$value.attrs; + var props = _args$value.props; + + bucket.argsRevision = args.tag.value(); + + var oldAttrs = component.attrs; + var newAttrs = attrs; + + component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = true; + component.setProperties(props); + component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = false; + + _emberViews.dispatchLifeCycleHook(component, 'didUpdateAttrs', oldAttrs, newAttrs); + _emberViews.dispatchLifeCycleHook(component, 'didReceiveAttrs', oldAttrs, newAttrs); } - }, - _disconnectOutlet: function (outletName, parentView) { - var parent = parentRoute(this); - if (parent && parentView === parent.routeName) { - parentView = undefined; - } - for (var i = 0; i < this.connections.length; i++) { - var connection = this.connections[i]; - if (connection.outlet === outletName && connection.into === parentView) { - // This neuters the disconnected outlet such that it doesn't - // render anything, but it leaves an entry in the outlet - // hierarchy so that any existing other renders that target it - // don't suddenly blow up. They will still stick themselves - // into its outlets, which won't render anywhere. All of this - // statefulness should get the machete in 2.0. - this.connections[i] = { - owner: connection.owner, - into: connection.into, - outlet: connection.outlet, - name: connection.name, - controller: undefined, - template: undefined, - ViewClass: undefined - }; - _emberMetal.run.once(this.router, '_setOutlets'); - } + if (environment.isInteractive) { + component.trigger('willUpdate'); + component.trigger('willRender'); } - }, + }; - willDestroy: function () { - this.teardownViews(); - }, + CurlyComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) { + var _this4 = this; - /** - @private - @method teardownViews - */ - teardownViews: function () { - if (this.connections && this.connections.length > 0) { - this.connections = []; - _emberMetal.run.once(this.router, '_setOutlets'); + bucket.finalize(); + + _emberMetal.runInDebug(function () { + return _this4.debugStack.pop(); + }); + }; + + CurlyComponentManager.prototype.didUpdate = function didUpdate(_ref5) { + var component = _ref5.component; + var environment = _ref5.environment; + + if (environment.isInteractive) { + component.trigger('didUpdate'); + component.trigger('didRender'); } - } - }); + }; - _emberRuntime.deprecateUnderscoreActions(Route); + CurlyComponentManager.prototype.getDestructor = function getDestructor(stateBucket) { + return stateBucket; + }; - Route.reopenClass({ - isRouteFactory: true - }); + return CurlyComponentManager; + })(_emberGlimmerSyntaxAbstractManager.default); - function parentRoute(route) { - var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); - return handlerInfo && handlerInfo.handler; - } + var MANAGER = new CurlyComponentManager(); - function handlerInfoFor(route, handlerInfos, _offset) { - if (!handlerInfos) { - return; - } + var TopComponentManager = (function (_CurlyComponentManager) { +babelHelpers.inherits(TopComponentManager, _CurlyComponentManager); - var offset = _offset || 0; - var current = undefined; - for (var i = 0; i < handlerInfos.length; i++) { - current = handlerInfos[i].handler; - if (current === route) { - return handlerInfos[i + offset]; - } + function TopComponentManager() { +babelHelpers.classCallCheck(this, TopComponentManager); + + _CurlyComponentManager.apply(this, arguments); } - } - function buildRenderOptions(route, namePassed, isDefaultRender, _name, options) { - var into = options && options.into && options.into.replace(/\//g, '.'); - var outlet = options && options.outlet || 'main'; + TopComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, currentScope, hasBlock) { + var _this5 = this; - var name = undefined, - templateName = undefined; - if (_name) { - name = _name.replace(/\//g, '.'); - templateName = name; - } else { - name = route.routeName; - templateName = route.templateName || name; - } + var component = definition.ComponentClass.create(); - var owner = _emberUtils.getOwner(route); - var controller = options && options.controller; - if (!controller) { - if (namePassed) { - controller = owner.lookup('controller:' + name) || route.controllerName || route.routeName; - } else { - controller = route.controllerName || owner.lookup('controller:' + name); - } - } + _emberMetal.runInDebug(function () { + return _this5._pushToDebugStack(component._debugContainerKey, environment); + }); - if (typeof controller === 'string') { - var controllerName = controller; - controller = owner.lookup('controller:' + controllerName); - if (!controller) { - throw new _emberMetal.Error('You passed `controller: \'' + controllerName + '\'` into the `render` method, but no such controller could be found.'); - } - } + var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { - throw new _emberMetal.Error('You passed undefined as the outlet name.'); - } + dynamicScope.view = component; - if (options && options.model) { - controller.set('model', options.model); - } + // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components + if (component.tagName === '') { + if (environment.isInteractive) { + component.trigger('willRender'); + } - var template = owner.lookup('template:' + templateName); + component._transitionTo('hasElement'); - var parent = undefined; - if (into && (parent = parentRoute(route)) && into === parent.routeName) { - into = undefined; - } + if (environment.isInteractive) { + component.trigger('willInsertElement'); + } + } - var renderOptions = { - owner: owner, - into: into, - outlet: outlet, - name: name, - controller: controller, - template: template || route._topLevelViewTemplate, - ViewClass: undefined + processComponentInitializationAssertions(component, {}); + + return new ComponentStateBucket(environment, component, args, finalizer); }; - _emberMetal.assert('Could not find "' + name + '" template, view, or component.', isDefaultRender || template); + return TopComponentManager; + })(CurlyComponentManager); - var LOG_VIEW_LOOKUPS = _emberMetal.get(route.router, 'namespace.LOG_VIEW_LOOKUPS'); - if (LOG_VIEW_LOOKUPS && !template) { - _emberMetal.info('Could not find "' + name + '" template. Nothing will be rendered', { fullName: 'template:' + name }); - } + var ROOT_MANAGER = new TopComponentManager(); - return renderOptions; + function tagName(vm) { + var tagName = vm.dynamicScope().view.tagName; + + return _glimmerRuntime.PrimitiveReference.create(tagName === '' ? null : tagName || 'div'); } - function getFullQueryParams(router, state) { - if (state.fullQueryParams) { - return state.fullQueryParams; + function ariaRole(vm) { + return vm.getSelf().get('ariaRole'); + } + + var CurlyComponentDefinition = (function (_ComponentDefinition) { +babelHelpers.inherits(CurlyComponentDefinition, _ComponentDefinition); + + function CurlyComponentDefinition(name, ComponentClass, template, args) { +babelHelpers.classCallCheck(this, CurlyComponentDefinition); + + _ComponentDefinition.call(this, name, MANAGER, ComponentClass); + this.template = template; + this.args = args; } - state.fullQueryParams = {}; - _emberUtils.assign(state.fullQueryParams, state.queryParams); + return CurlyComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - router._deserializeQueryParams(state.handlerInfos, state.fullQueryParams); - return state.fullQueryParams; - } + exports.CurlyComponentDefinition = CurlyComponentDefinition; - function getQueryParamsFor(route, state) { - state.queryParamsFor = state.queryParamsFor || {}; - var name = route.fullRouteName; + var RootComponentDefinition = (function (_ComponentDefinition2) { +babelHelpers.inherits(RootComponentDefinition, _ComponentDefinition2); - if (state.queryParamsFor[name]) { - return state.queryParamsFor[name]; + function RootComponentDefinition(instance) { +babelHelpers.classCallCheck(this, RootComponentDefinition); + + _ComponentDefinition2.call(this, '-root', ROOT_MANAGER, { + class: instance.constructor, + create: function () { + return instance; + } + }); + this.template = undefined; + this.args = undefined; } - var fullQueryParams = getFullQueryParams(route.router, state); + return RootComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - var params = state.queryParamsFor[name] = {}; + exports.RootComponentDefinition = RootComponentDefinition; - // Copy over all the query params for this route/controller into params hash. - var qpMeta = _emberMetal.get(route, '_qp'); - var qps = qpMeta.qps; - for (var i = 0; i < qps.length; ++i) { - // Put deserialized qp on params hash. - var qp = qps[i]; + var CurlyComponentLayoutCompiler = (function () { + function CurlyComponentLayoutCompiler(template) { +babelHelpers.classCallCheck(this, CurlyComponentLayoutCompiler); - var qpValueWasPassedIn = (qp.prop in fullQueryParams); - params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.defaultValue); + this.template = template; } - return params; + CurlyComponentLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + builder.tag.dynamic(tagName); + builder.attrs.dynamic('role', ariaRole); + builder.attrs.static('class', 'ember-view'); + }; + + return CurlyComponentLayoutCompiler; + })(); + + CurlyComponentLayoutCompiler.id = 'curly'; +}); +enifed('ember-glimmer/syntax/dynamic-component', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal) { + 'use strict'; + + exports.closureComponentMacro = closureComponentMacro; + exports.dynamicComponentMacro = dynamicComponentMacro; + exports.blockComponentMacro = blockComponentMacro; + exports.inlineComponentMacro = inlineComponentMacro; + + function dynamicComponentFor(vm, symbolTable) { + var env = vm.env; + var args = vm.getArgs(); + var nameRef = args.positional.at(0); + + return new DynamicComponentReference({ nameRef: nameRef, env: env, symbolTable: symbolTable }); } - function copyDefaultValue(value) { - if (Array.isArray(value)) { - return _emberRuntime.A(value.slice()); - } - return value; + function closureComponentMacro(path, params, hash, _default, inverse, builder) { + var definitionArgs = [[['get', path]], hash, _default, inverse]; + var args = [params, hash, _default, inverse]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; } - /* - Merges all query parameters from a controller with those from - a route, returning a new object and avoiding any mutations to - the existing objects. - */ - function mergeEachQueryParams(controllerQP, routeQP) { - var keysAlreadyMergedOrSkippable = undefined; - var qps = {}; + function dynamicComponentMacro(params, hash, _default, inverse, builder) { + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - keysAlreadyMergedOrSkippable = { - defaultValue: true, - type: true, - scope: true, - as: true - }; + function blockComponentMacro(sexp, builder) { + var params = sexp[2]; + var hash = sexp[3]; + var _default = sexp[4]; + var inverse = sexp[5]; - // first loop over all controller qps, merging them with any matching route qps - // into a new empty object to avoid mutating. - for (var cqpName in controllerQP) { - if (!controllerQP.hasOwnProperty(cqpName)) { - continue; - } + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, _default, inverse]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - var newControllerParameterConfiguration = {}; - _emberUtils.assign(newControllerParameterConfiguration, controllerQP[cqpName]); - _emberUtils.assign(newControllerParameterConfiguration, routeQP[cqpName]); + function inlineComponentMacro(path, params, hash, builder) { + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - qps[cqpName] = newControllerParameterConfiguration; + var DynamicComponentReference = (function () { + function DynamicComponentReference(_ref) { + var nameRef = _ref.nameRef; + var env = _ref.env; + var symbolTable = _ref.symbolTable; + var args = _ref.args; + babelHelpers.classCallCheck(this, DynamicComponentReference); - // allows us to skip this QP when we check route QPs. - keysAlreadyMergedOrSkippable[cqpName] = true; + this.tag = nameRef.tag; + this.nameRef = nameRef; + this.env = env; + this.symbolTable = symbolTable; + this.args = args; } - // loop over all route qps, skipping those that were merged in the first pass - // because they also appear in controller qps - for (var rqpName in routeQP) { - if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { - continue; + DynamicComponentReference.prototype.value = function value() { + var env = this.env; + var nameRef = this.nameRef; + var symbolTable = this.symbolTable; + + var nameOrDef = nameRef.value(); + + if (typeof nameOrDef === 'string') { + var definition = env.getComponentDefinition([nameOrDef], symbolTable); + + _emberMetal.assert('Could not find component named "' + nameOrDef + '" (no component or template with that name was found)', definition); + + return definition; + } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { + return nameOrDef; + } else { + return null; } + }; - var newRouteParameterConfiguration = {}; - _emberUtils.assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); - qps[rqpName] = newRouteParameterConfiguration; - } + DynamicComponentReference.prototype.get = function get() { + return _glimmerReference.UNDEFINED_REFERENCE; + }; - return qps; + return DynamicComponentReference; + })(); +}); +enifed('ember-glimmer/syntax/input', ['exports', 'ember-metal', 'ember-glimmer/utils/bindings', 'ember-glimmer/syntax/dynamic-component'], function (exports, _emberMetal, _emberGlimmerUtilsBindings, _emberGlimmerSyntaxDynamicComponent) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; + + exports.inputMacro = inputMacro; + + function buildTextFieldSyntax(params, hash, builder) { + var definition = builder.env.getComponentDefinition(['-text-field'], builder.symbolTable); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; } - function addQueryParamsObservers(controller, propNames) { - propNames.forEach(function (prop) { - controller.addObserver(prop + '.[]', controller, controller._qpChanged); + /** + The `{{input}}` helper lets you create an HTML `` component. + It causes an `Ember.TextField` component to be rendered. For more info, + see the [Ember.TextField](/api/classes/Ember.TextField.html) docs and + the [templates guide](http://emberjs.com/guides/templates/input-helpers/). + + ```handlebars + {{input value="987"}} + ``` + + renders as: + + ```HTML + + ``` + + ### Text field + + If no `type` option is specified, a default of type 'text' is used. + Many of the standard HTML attributes may be passed to this helper. + + + + + + + + + + + +
    `readonly``required``autofocus`
    `value``placeholder``disabled`
    `size``tabindex``maxlength`
    `name``min``max`
    `pattern``accept``autocomplete`
    `autosave``formaction``formenctype`
    `formmethod``formnovalidate``formtarget`
    `height``inputmode``multiple`
    `step``width``form`
    `selectionDirection``spellcheck` 
    + When set to a quoted string, these values will be directly applied to the HTML + element. When left unquoted, these values will be bound to a property on the + template's current rendering context (most typically a controller instance). + A very common use of this helper is to bind the `value` of an input to an Object's attribute: + + ```handlebars + Search: + {{input value=searchWord}} + ``` + + In this example, the inital value in the `` will be set to the value of `searchWord`. + If the user changes the text, the value of `searchWord` will also be updated. + + ### Actions + + The helper can send multiple actions based on user events. + The action property defines the action which is sent when + the user presses the return key. + + ```handlebars + {{input action="submit"}} + ``` + + The helper allows some user events to send actions. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + * `key-up` + + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. + + ```handlebars + {{input focus-out="alertMessage"}} + ``` + See more about [Text Support Actions](/api/classes/Ember.TextField.html) + + ### Extending `Ember.TextField` + + Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing + arguments from the helper to `Ember.TextField`'s `create` method. You can extend the + capabilities of text inputs in your applications by reopening this class. For example, + if you are building a Bootstrap project where `data-*` attributes are used, you + can add one to the `TextField`'s `attributeBindings` property: + + ```javascript + Ember.TextField.reopen({ + attributeBindings: ['data-error'] }); - } + ``` + + Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` + itself extends `Ember.Component`. Expect isolated component semantics, not + legacy 1.x view semantics (like `controller` being present). + See more about [Ember components](/api/classes/Ember.Component.html) + + ### Checkbox + + Checkboxes are special forms of the `{{input}}` helper. To create a ``: + + ```handlebars + Emberize Everything: + {{input type="checkbox" name="isEmberized" checked=isEmberized}} + ``` + + This will bind checked state of this checkbox to the value of `isEmberized` -- if either one changes, + it will be reflected in the other. + + The following HTML attributes can be set via the helper: + + * `checked` + * `disabled` + * `tabindex` + * `indeterminate` + * `name` + * `autofocus` + * `form` + + ### Extending `Ember.Checkbox` + + Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing + arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the + capablilties of checkbox inputs in your applications by reopening this class. For example, + if you wanted to add a css class to all checkboxes in your application: + + ```javascript + Ember.Checkbox.reopen({ + classNames: ['my-app-checkbox'] + }); + ``` + + @method input + @for Ember.Templates.helpers + @param {Hash} options + @public + */ - function getEngineRouteName(engine, routeName) { - if (engine.routable) { - var prefix = engine.mountPoint; + function inputMacro(path, params, hash, builder) { + var keys = undefined; + var values = undefined; + var typeIndex = -1; + var valueIndex = -1; - if (routeName === 'application') { - return prefix; - } else { - return prefix + '.' + routeName; - } + if (hash) { + keys = hash[0]; + values = hash[1]; + typeIndex = keys.indexOf('type'); + valueIndex = keys.indexOf('value'); } - return routeName; - } + if (!params) { + params = []; + } - exports.default = Route; -}); -enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-routing/system/route', 'ember-routing/system/dsl', 'ember-routing/location/api', 'ember-routing/utils', 'ember-routing/system/router_state', 'router'], function (exports, _emberUtils, _emberConsole, _emberMetal, _emberRuntime, _emberRoutingSystemRoute, _emberRoutingSystemDsl, _emberRoutingLocationApi, _emberRoutingUtils, _emberRoutingSystemRouter_state, _router4) { - 'use strict'; + if (typeIndex > -1) { + var typeArg = values[typeIndex]; + if (!Array.isArray(typeArg)) { + if (typeArg === 'checkbox') { + _emberMetal.assert('{{input type=\'checkbox\'}} does not support setting `value=someBooleanValue`; ' + 'you must use `checked=someBooleanValue` instead.', valueIndex === -1); - exports.triggerEvent = triggerEvent; + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); - function K() { - return this; + var definition = builder.env.getComponentDefinition(['-checkbox'], builder.symbolTable); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; + } else { + return buildTextFieldSyntax(params, hash, builder); + } + } + } else { + return buildTextFieldSyntax(params, hash, builder); + } + + return _emberGlimmerSyntaxDynamicComponent.dynamicComponentMacro(params, hash, null, null, builder); } +}); +enifed('ember-glimmer/syntax/mount', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet, _container, _emberGlimmerSyntaxAbstractManager) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var slice = Array.prototype.slice; + exports.mountMacro = mountMacro; /** - The `Ember.Router` class manages the application state and URLs. Refer to - the [routing guide](http://emberjs.com/guides/routing/) for documentation. + The `{{mount}}` helper lets you embed a routeless engine in a template. + Mounting an engine will cause an instance to be booted and its `application` + template to be rendered. - @class Router - @namespace Ember - @extends Ember.Object - @uses Ember.Evented + For example, the following template mounts the `ember-chat` engine: + + ```handlebars + {{! application.hbs }} + {{mount "ember-chat"}} + ``` + + Currently, the engine name is the only argument that can be passed to + `{{mount}}`. + + @method mount + @for Ember.Templates.helpers + @category ember-application-engines @public */ - var EmberRouter = _emberRuntime.Object.extend(_emberRuntime.Evented, { - /** - The `location` property determines the type of URL's that your - application will use. - The following location types are currently available: - * `history` - use the browser's history API to make the URLs look just like any standard URL - * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new` - * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing) - * `auto` - use the best option based on browser capabilites: `history` if possible, then `hash` if possible, otherwise `none` - Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js` - @property location - @default 'hash' - @see {Ember.Location} - @public - */ - location: 'hash', - - /** - Represents the URL of the root of the application, often '/'. This prefix is - assumed on all routes defined on this router. - @property rootURL - @default '/' - @public - */ - rootURL: '/', - - _initRouterJs: function () { - var router = this.router = new _router4.default(); - router.triggerEvent = triggerEvent; - - router._triggerWillChangeContext = K; - router._triggerWillLeave = K; - var dslCallbacks = this.constructor.dslCallbacks || [K]; - var dsl = this._buildDSL(); + function mountMacro(path, params, hash, builder) { + _emberMetal.assert('You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.', params.length === 1 && hash === null); - dsl.route('application', { path: '/', resetNamespace: true, overrideNameAssertion: true }, function () { - for (var i = 0; i < dslCallbacks.length; i++) { - dslCallbacks[i].call(this); - } - }); + var name = params[0]; - if (_emberMetal.get(this, 'namespace.LOG_TRANSITIONS_INTERNAL')) { - router.log = _emberConsole.default.debug; - } + _emberMetal.assert('The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}.', typeof name === 'string'); - router.map(dsl.generate()); - }, + _emberMetal.assert('You used `{{mount \'' + name + '\'}}`, but the engine \'' + name + '\' can not be found.', builder.env.owner.hasRegistration('engine:' + name)); - _buildDSL: function () { - var moduleBasedResolver = this._hasModuleBasedResolver(); - var options = { - enableLoadingSubstates: !!moduleBasedResolver - }; + builder.component.static(new MountDefinition(name, builder.env), [params, hash, null, null], builder.symbolTable); + return true; + } - var owner = _emberUtils.getOwner(this); - var router = this; + var MountManager = (function (_AbstractManager) { + babelHelpers.inherits(MountManager, _AbstractManager); - options.resolveRouteMap = function (name) { - return owner._lookupFactory('route-map:' + name); - }; + function MountManager() { + babelHelpers.classCallCheck(this, MountManager); - options.addRouteForEngine = function (name, engineInfo) { - if (!router._engineInfoByRoute[name]) { - router._engineInfoByRoute[name] = engineInfo; - } - }; + _AbstractManager.apply(this, arguments); + } - return new _emberRoutingSystemDsl.default(null, options); - }, + MountManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - init: function () { - this._super.apply(this, arguments); + MountManager.prototype.create = function create(environment, _ref, args, dynamicScope) { + var name = _ref.name; + var env = _ref.env; - this._qpCache = new _emberUtils.EmptyObject(); - this._resetQueuedQueryParameterChanges(); - this._handledErrors = _emberUtils.dictionary(null); - this._engineInstances = new _emberUtils.EmptyObject(); - this._engineInfoByRoute = new _emberUtils.EmptyObject(); - }, + var _this = this; - /* - Resets all pending query paramter changes. - Called after transitioning to a new route - based on query parameter changes. - */ - _resetQueuedQueryParameterChanges: function () { - this._queuedQPChanges = {}; - }, + _emberMetal.runInDebug(function () { + return _this._pushEngineToDebugStack('engine:' + name, env); + }); - /** - Represents the current URL. - @method url - @return {String} The current URL. - @private - */ - url: _emberMetal.computed(function () { - return _emberMetal.get(this, 'location').getURL(); - }), + dynamicScope.outletState = _glimmerReference.UNDEFINED_REFERENCE; - _hasModuleBasedResolver: function () { - var owner = _emberUtils.getOwner(this); + var engine = env.owner.buildChildEngineInstance(name); - if (!owner) { - return false; - } + engine.boot(); - var resolver = owner.application && owner.application.__registry__ && owner.application.__registry__.resolver; + return { engine: engine }; + }; - if (!resolver) { - return false; - } + MountManager.prototype.layoutFor = function layoutFor(definition, _ref2, env) { + var engine = _ref2.engine; - return !!resolver.moduleBasedResolver; - }, + var template = engine.lookup('template:application'); + return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, template); + }; - /** - Initializes the current router instance and sets up the change handling - event listeners used by the instances `location` implementation. - A property named `initialURL` will be used to determine the initial URL. - If no value is found `/` will be used. - @method startRouting - @private - */ - startRouting: function () { - var initialURL = _emberMetal.get(this, 'initialURL'); + MountManager.prototype.getSelf = function getSelf(_ref3) { + var engine = _ref3.engine; - if (this.setupRouter()) { - if (typeof initialURL === 'undefined') { - initialURL = _emberMetal.get(this, 'location').getURL(); - } - var initialTransition = this.handleURL(initialURL); - if (initialTransition && initialTransition.error) { - throw initialTransition.error; - } - } - }, + var applicationFactory = engine[_container.FACTORY_FOR]('controller:application'); + var factory = applicationFactory || _emberRouting.generateControllerFactory(engine, 'application'); + return new _emberGlimmerUtilsReferences.RootReference(factory.create()); + }; - setupRouter: function () { - var _this = this; + MountManager.prototype.getTag = function getTag() { + return null; + }; - this._initRouterJs(); - this._setupLocation(); + MountManager.prototype.getDestructor = function getDestructor(_ref4) { + var engine = _ref4.engine; - var router = this.router; - var location = _emberMetal.get(this, 'location'); + return engine; + }; - // Allow the Location class to cancel the router setup while it refreshes - // the page - if (_emberMetal.get(location, 'cancelRouterSetup')) { - return false; - } + MountManager.prototype.didCreateElement = function didCreateElement() {}; - this._setupRouter(router, location); + MountManager.prototype.didRenderLayout = function didRenderLayout() { + var _this2 = this; - location.onUpdateURL(function (url) { - _this.handleURL(url); + _emberMetal.runInDebug(function () { + return _this2.debugStack.pop(); }); + }; - return true; - }, + MountManager.prototype.didCreate = function didCreate(state) {}; - /** - Handles updating the paths and notifying any listeners of the URL - change. - Triggers the router level `didTransition` hook. - For example, to notify google analytics when the route changes, - you could use this hook. (Note: requires also including GA scripts, etc.) - ```javascript - let Router = Ember.Router.extend({ - location: config.locationType, - didTransition: function() { - this._super(...arguments); - return ga('send', 'pageview', { - 'page': this.get('url'), - 'title': this.get('url') - }); - } - }); - ``` - @method didTransition - @public - @since 1.2.0 - */ - didTransition: function (infos) { - updatePaths(this); + MountManager.prototype.update = function update(state, args, dynamicScope) {}; - this._cancelSlowTransitionTimer(); + MountManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - this.notifyPropertyChange('url'); - this.set('currentState', this.targetState); + MountManager.prototype.didUpdate = function didUpdate(state) {}; - // Put this in the runloop so url will be accurate. Seems - // less surprising than didTransition being out of sync. - _emberMetal.run.once(this, this.trigger, 'didTransition'); + return MountManager; + })(_emberGlimmerSyntaxAbstractManager.default); - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Transitioned into \'' + EmberRouter._routePath(infos) + '\''); - } - }, + var MOUNT_MANAGER = new MountManager(); - _setOutlets: function () { - // This is triggered async during Ember.Route#willDestroy. - // If the router is also being destroyed we do not want to - // to create another this._toplevelView (and leak the renderer) - if (this.isDestroying || this.isDestroyed) { - return; - } + var MountDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(MountDefinition, _ComponentDefinition); - var handlerInfos = this.router.currentHandlerInfos; - var route = undefined; - var defaultParentState = undefined; - var liveRoutes = null; + function MountDefinition(name, env) { + babelHelpers.classCallCheck(this, MountDefinition); - if (!handlerInfos) { - return; - } + _ComponentDefinition.call(this, name, MOUNT_MANAGER, null); + this.env = env; + } - for (var i = 0; i < handlerInfos.length; i++) { - route = handlerInfos[i].handler; - var connections = route.connections; - var ownState = undefined; - for (var j = 0; j < connections.length; j++) { - var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); - liveRoutes = appended.liveRoutes; - if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { - ownState = appended.ownState; - } - } - if (connections.length === 0) { - ownState = representEmptyRoute(liveRoutes, defaultParentState, route); - } - defaultParentState = ownState; - } + return MountDefinition; + })(_glimmerRuntime.ComponentDefinition); +}); +enifed('ember-glimmer/syntax/outlet', ['exports', 'ember-utils', '@glimmer/runtime', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/abstract-manager', '@glimmer/reference'], function (exports, _emberUtils, _glimmerRuntime, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxAbstractManager, _glimmerReference) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - // when a transitionTo happens after the validation phase - // during the initial transition _setOutlets is called - // when no routes are active. However, it will get called - // again with the correct values during the next turn of - // the runloop - if (!liveRoutes) { - return; - } + exports.outletMacro = outletMacro; - if (!this._toplevelView) { - var owner = _emberUtils.getOwner(this); - var OutletView = owner._lookupFactory('view:-outlet'); - this._toplevelView = OutletView.create(); - this._toplevelView.setOutletState(liveRoutes); - var instance = owner.lookup('-application-instance:main'); - instance.didCreateRootView(this._toplevelView); - } else { - this._toplevelView.setOutletState(liveRoutes); - } - }, + function outletComponentFor(vm) { + var _vm$dynamicScope = vm.dynamicScope(); - /** - Handles notifying any listeners of an impending URL - change. - Triggers the router level `willTransition` hook. - @method willTransition - @public - @since 1.11.0 - */ - willTransition: function (oldInfos, newInfos, transition) { - _emberMetal.run.once(this, this.trigger, 'willTransition', transition); + var outletState = _vm$dynamicScope.outletState; - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Preparing to transition from \'' + EmberRouter._routePath(oldInfos) + '\' to \'' + EmberRouter._routePath(newInfos) + '\''); - } - }, + var args = vm.getArgs(); + var outletNameRef = undefined; + if (args.positional.length === 0) { + outletNameRef = new _glimmerReference.ConstReference('main'); + } else { + outletNameRef = args.positional.at(0); + } - handleURL: function (url) { - // Until we have an ember-idiomatic way of accessing #hashes, we need to - // remove it because router.js doesn't know how to handle it. - url = url.split(/#(.+)?/)[0]; - return this._doURLTransition('handleURL', url); - }, + return new OutletComponentReference(outletNameRef, outletState); + } - _doURLTransition: function (routerJsMethod, url) { - var transition = this.router[routerJsMethod](url || '/'); - didBeginTransition(transition, this); - return transition; - }, + /** + The `{{outlet}}` helper lets you specify where a child route will render in + your template. An important use of the `{{outlet}}` helper is in your + application's `application.hbs` file: + + ```handlebars + {{! app/templates/application.hbs }} + + {{my-header}} +
    + + {{outlet}} +
    + + {{my-footer}} + ``` + + See [templates guide](http://emberjs.com/guides/templates/the-application-template/) for + additional information on using `{{outlet}}` in `application.hbs`. + You may also specify a name for the `{{outlet}}`, which is useful when using more than one + `{{outlet}}` in a template: + + ```handlebars + {{outlet "menu"}} + {{outlet "sidebar"}} + {{outlet "main"}} + ``` + + Your routes can then render into a specific one of these `outlet`s by specifying the `outlet` + attribute in your `renderTemplate` function: + + ```javascript + // app/routes/menu.js + export default Ember.Route.extend({ + renderTemplate() { + this.render({ outlet: 'menu' }); + } + }); + ``` + + See the [routing guide](http://emberjs.com/guides/routing/rendering-a-template/) for more + information on how your `route` interacts with the `{{outlet}}` helper. + Note: Your content __will not render__ if there isn't an `{{outlet}}` for it. + + @method outlet + @param {String} [name] + @for Ember.Templates.helpers + @public + */ - /** - 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 - @public - */ - transitionTo: function () { - var queryParams = undefined; + function outletMacro(path, params, hash, builder) { + if (!params) { + params = []; + } + var definitionArgs = [params.slice(0, 1), null, null, null]; + builder.component.dynamic(definitionArgs, outletComponentFor, _glimmerRuntime.CompiledArgs.empty(), builder.symbolTable, null); + return true; + } - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + var OutletComponentReference = (function () { + function OutletComponentReference(outletNameRef, parentOutletStateRef) { + babelHelpers.classCallCheck(this, OutletComponentReference); - if (resemblesURL(args[0])) { - return this._doURLTransition('transitionTo', args[0]); - } + this.outletNameRef = outletNameRef; + this.parentOutletStateRef = parentOutletStateRef; + this.definition = null; + this.lastState = null; + var outletStateTag = this.outletStateTag = new _glimmerReference.UpdatableTag(parentOutletStateRef.tag); + this.tag = _glimmerReference.combine([outletStateTag.tag, outletNameRef.tag]); + } - var possibleQueryParams = args[args.length - 1]; - if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { - queryParams = args.pop().queryParams; - } else { - queryParams = {}; - } + OutletComponentReference.prototype.value = function value() { + var outletNameRef = this.outletNameRef; + var parentOutletStateRef = this.parentOutletStateRef; + var definition = this.definition; + var lastState = this.lastState; - var targetRouteName = args.shift(); - return this._doTransition(targetRouteName, args, queryParams); - }, + var outletName = outletNameRef.value(); + var outletStateRef = parentOutletStateRef.get('outlets').get(outletName); + var newState = this.lastState = outletStateRef.value(); - intermediateTransitionTo: function () { - var _router; + this.outletStateTag.update(outletStateRef.tag); - (_router = this.router).intermediateTransitionTo.apply(_router, arguments); + definition = revalidate(definition, lastState, newState); - updatePaths(this); + var hasTemplate = newState && newState.render.template; - var infos = this.router.currentHandlerInfos; - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Intermediate-transitioned into \'' + EmberRouter._routePath(infos) + '\''); + if (definition) { + return definition; + } else if (hasTemplate) { + return this.definition = new OutletComponentDefinition(outletName, newState.render.template); + } else { + return this.definition = null; } - }, - - replaceWith: function () { - return this.transitionTo.apply(this, arguments).method('replace'); - }, + }; - generate: function () { - var _router2; + return OutletComponentReference; + })(); - var url = (_router2 = this.router).generate.apply(_router2, arguments); - return this.location.formatURL(url); - }, + function revalidate(definition, lastState, newState) { + if (!lastState && !newState) { + return definition; + } - /** - Determines if the supplied route is currently active. - @method isActive - @param routeName - @return {Boolean} - @private - */ - isActive: function (routeName) { - var router = this.router; - return router.isActive.apply(router, arguments); - }, + if (!lastState && newState || lastState && !newState) { + return null; + } - /** - An alternative form of `isActive` that doesn't require - manual concatenation of the arguments into a single - array. - @method isActiveIntent - @param routeName - @param models - @param queryParams - @return {Boolean} - @private - @since 1.7.0 - */ - isActiveIntent: function (routeName, models, queryParams) { - return this.currentState.isActiveIntent(routeName, models, queryParams); - }, + if (newState.render.template === lastState.render.template && newState.render.controller === lastState.render.controller) { + return definition; + } - send: function (name, context) { - var _router3; + return null; + } - (_router3 = this.router).trigger.apply(_router3, arguments); - }, + function instrumentationPayload(_ref) { + var _ref$render = _ref.render; + var name = _ref$render.name; + var outlet = _ref$render.outlet; - /** - Does this router instance have the given route. - @method hasRoute - @return {Boolean} - @private - */ - hasRoute: function (route) { - return this.router.hasRoute(route); - }, + return { object: name + ':' + outlet }; + } - /** - Resets the state of the router by clearing the current route - handlers and deactivating them. - @private - @method reset - */ - reset: function () { - if (this.router) { - this.router.reset(); - } - }, + function NOOP() {} - willDestroy: function () { - if (this._toplevelView) { - this._toplevelView.destroy(); - this._toplevelView = null; - } + var StateBucket = (function () { + function StateBucket(outletState) { + babelHelpers.classCallCheck(this, StateBucket); - this._super.apply(this, arguments); + this.outletState = outletState; + this.instrument(); + } - this.reset(); + StateBucket.prototype.instrument = function instrument() { + this.finalizer = _emberMetal._instrumentStart('render.outlet', instrumentationPayload, this.outletState); + }; - var instances = this._engineInstances; - for (var _name in instances) { - for (var id in instances[_name]) { - _emberMetal.run(instances[_name][id], 'destroy'); - } - } - }, + StateBucket.prototype.finalize = function finalize() { + var finalizer = this.finalizer; - /* - Called when an active route's query parameter has changed. - These changes are batched into a runloop run and trigger - a single transition. - */ - _activeQPChanged: function (queryParameterName, newValue) { - this._queuedQPChanges[queryParameterName] = newValue; - _emberMetal.run.once(this, this._fireQueryParamTransition); - }, + finalizer(); + this.finalizer = NOOP; + }; - _updatingQPChanged: function (queryParameterName) { - if (!this._qpUpdates) { - this._qpUpdates = {}; - } - this._qpUpdates[queryParameterName] = true; - }, + return StateBucket; + })(); - /* - Triggers a transition to a route based on query parameter changes. - This is called once per runloop, to batch changes. - e.g. - if these methods are called in succession: - this._activeQPChanged('foo', '10'); - // results in _queuedQPChanges = { foo: '10' } - this._activeQPChanged('bar', false); - // results in _queuedQPChanges = { foo: '10', bar: false } - _queuedQPChanges will represent both of these changes - and the transition using `transitionTo` will be triggered - once. - */ - _fireQueryParamTransition: function () { - this.transitionTo({ queryParams: this._queuedQPChanges }); - this._resetQueuedQueryParameterChanges(); - }, + var OutletComponentManager = (function (_AbstractManager) { + babelHelpers.inherits(OutletComponentManager, _AbstractManager); - _setupLocation: function () { - var location = _emberMetal.get(this, 'location'); - var rootURL = _emberMetal.get(this, 'rootURL'); - var owner = _emberUtils.getOwner(this); + function OutletComponentManager() { + babelHelpers.classCallCheck(this, OutletComponentManager); - if ('string' === typeof location && owner) { - var resolvedLocation = owner.lookup('location:' + location); + _AbstractManager.apply(this, arguments); + } - if ('undefined' !== typeof resolvedLocation) { - location = _emberMetal.set(this, 'location', resolvedLocation); - } else { - // Allow for deprecated registration of custom location API's - var options = { - implementation: location - }; + OutletComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - location = _emberMetal.set(this, 'location', _emberRoutingLocationApi.default.create(options)); - } - } + OutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this = this; - if (location !== null && typeof location === 'object') { - if (rootURL) { - _emberMetal.set(location, 'rootURL', rootURL); - } + _emberMetal.runInDebug(function () { + return _this._pushToDebugStack('template:' + definition.template.meta.moduleName, environment); + }); - // Allow the location to do any feature detection, such as AutoLocation - // detecting history support. This gives it a chance to set its - // `cancelRouterSetup` property which aborts routing. - if (typeof location.detect === 'function') { - location.detect(); - } + var outletStateReference = dynamicScope.outletState = dynamicScope.outletState.get('outlets').get(definition.outletName); + var outletState = outletStateReference.value(); + return new StateBucket(outletState); + }; - // ensure that initState is called AFTER the rootURL is set on - // the location instance - if (typeof location.initState === 'function') { - location.initState(); - } - } - }, + OutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(OutletLayoutCompiler, definition.template); + }; - _getHandlerFunction: function () { - var _this2 = this; + OutletComponentManager.prototype.getSelf = function getSelf(_ref2) { + var outletState = _ref2.outletState; - var seen = new _emberUtils.EmptyObject(); - var owner = _emberUtils.getOwner(this); + return new _emberGlimmerUtilsReferences.RootReference(outletState.render.controller); + }; - return function (name) { - var routeName = name; - var routeOwner = owner; - var engineInfo = _this2._engineInfoByRoute[routeName]; + OutletComponentManager.prototype.getTag = function getTag() { + return null; + }; - if (engineInfo) { - var engineInstance = _this2._getEngineInstance(engineInfo); + OutletComponentManager.prototype.getDestructor = function getDestructor() { + return null; + }; - routeOwner = engineInstance; - routeName = engineInfo.localFullName; - } + OutletComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket) { + var _this2 = this; - var fullRouteName = 'route:' + routeName; + bucket.finalize(); - var handler = routeOwner.lookup(fullRouteName); + _emberMetal.runInDebug(function () { + return _this2.debugStack.pop(); + }); + }; - if (seen[name]) { - return handler; - } + OutletComponentManager.prototype.didCreateElement = function didCreateElement() {}; - seen[name] = true; + OutletComponentManager.prototype.didCreate = function didCreate(state) {}; - if (!handler) { - var DefaultRoute = routeOwner._lookupFactory('route:basic'); + OutletComponentManager.prototype.update = function update(bucket) {}; - routeOwner.register(fullRouteName, DefaultRoute.extend()); - handler = routeOwner.lookup(fullRouteName); + OutletComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) {}; - if (_emberMetal.get(_this2, 'namespace.LOG_ACTIVE_GENERATION')) { - _emberMetal.info('generated -> ' + fullRouteName, { fullName: fullRouteName }); - } - } + OutletComponentManager.prototype.didUpdate = function didUpdate(state) {}; - handler._setRouteName(routeName); - handler._populateQPMeta(); + return OutletComponentManager; + })(_emberGlimmerSyntaxAbstractManager.default); - if (engineInfo && !_emberRoutingSystemRoute.hasDefaultSerialize(handler)) { - throw new Error('Defining a custom serialize method on an Engine route is not supported.'); - } + var MANAGER = new OutletComponentManager(); - return handler; - }; - }, + var TopLevelOutletComponentManager = (function (_OutletComponentManager) { + babelHelpers.inherits(TopLevelOutletComponentManager, _OutletComponentManager); - _getSerializerFunction: function () { - var _this3 = this; + function TopLevelOutletComponentManager() { + babelHelpers.classCallCheck(this, TopLevelOutletComponentManager); - return function (name) { - var engineInfo = _this3._engineInfoByRoute[name]; + _OutletComponentManager.apply(this, arguments); + } - // If this is not an Engine route, we fall back to the handler for serialization - if (!engineInfo) { - return; - } + TopLevelOutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this3 = this; - return engineInfo.serializeMethod || _emberRoutingSystemRoute.defaultSerialize; - }; - }, + _emberMetal.runInDebug(function () { + return _this3._pushToDebugStack('template:' + definition.template.meta.moduleName, environment); + }); - _setupRouter: function (router, location) { - var lastURL = undefined; - var emberRouter = this; + return new StateBucket(dynamicScope.outletState.value()); + }; - router.getHandler = this._getHandlerFunction(); - router.getSerializer = this._getSerializerFunction(); + TopLevelOutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(TopLevelOutletLayoutCompiler, definition.template); + }; - var doUpdateURL = function () { - location.setURL(lastURL); - }; + return TopLevelOutletComponentManager; + })(OutletComponentManager); - router.updateURL = function (path) { - lastURL = path; - _emberMetal.run.once(doUpdateURL); - }; + var TOP_LEVEL_MANAGER = new TopLevelOutletComponentManager(); - if (location.replaceURL) { - (function () { - var doReplaceURL = function () { - location.replaceURL(lastURL); - }; + var TopLevelOutletComponentDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(TopLevelOutletComponentDefinition, _ComponentDefinition); - router.replaceURL = function (path) { - lastURL = path; - _emberMetal.run.once(doReplaceURL); - }; - })(); - } + function TopLevelOutletComponentDefinition(instance) { + babelHelpers.classCallCheck(this, TopLevelOutletComponentDefinition); - router.didTransition = function (infos) { - emberRouter.didTransition(infos); - }; + _ComponentDefinition.call(this, 'outlet', TOP_LEVEL_MANAGER, instance); + this.template = instance.template; + _emberUtils.generateGuid(this); + } - router.willTransition = function (oldInfos, newInfos, transition) { - emberRouter.willTransition(oldInfos, newInfos, transition); - }; - }, + return TopLevelOutletComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - /** - Serializes the given query params according to their QP meta information. - @private - @method _serializeQueryParams - @param {Arrray} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _serializeQueryParams: function (handlerInfos, queryParams) { - var _this4 = this; + exports.TopLevelOutletComponentDefinition = TopLevelOutletComponentDefinition; - forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { - if (qp) { - delete queryParams[key]; - queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); - } else if (value === undefined) { - return; // We don't serialize undefined values - } else { - queryParams[key] = _this4._serializeQueryParam(value, _emberRuntime.typeOf(value)); - } - }); - }, + var TopLevelOutletLayoutCompiler = (function () { + function TopLevelOutletLayoutCompiler(template) { + babelHelpers.classCallCheck(this, TopLevelOutletLayoutCompiler); - /** - Serializes the value of a query parameter based on a type - @private - @method _serializeQueryParam - @param {Object} value - @param {String} type - */ - _serializeQueryParam: function (value, type) { - if (type === 'array') { - return JSON.stringify(value); - } + this.template = template; + } - return '' + value; - }, + TopLevelOutletLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + builder.tag.static('div'); + builder.attrs.static('id', _emberUtils.guidFor(this)); + builder.attrs.static('class', 'ember-view'); + }; - /** - Deserializes the given query params according to their QP meta information. - @private - @method _deserializeQueryParams - @param {Array} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _deserializeQueryParams: function (handlerInfos, queryParams) { - forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { - // If we don't have QP meta info for a given key, then we do nothing - // because all values will be treated as strings - if (qp) { - delete queryParams[key]; - queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); - } - }); - }, + return TopLevelOutletLayoutCompiler; + })(); - /** - Deserializes the value of a query parameter based on a default type - @private - @method _deserializeQueryParam - @param {Object} value - @param {String} defaultType - */ - _deserializeQueryParam: function (value, defaultType) { - if (defaultType === 'boolean') { - return value === 'true' ? true : false; - } else if (defaultType === 'number') { - return Number(value).valueOf(); - } else if (defaultType === 'array') { - return _emberRuntime.A(JSON.parse(value)); - } + TopLevelOutletLayoutCompiler.id = 'top-level-outlet'; - return value; - }, + var OutletComponentDefinition = (function (_ComponentDefinition2) { + babelHelpers.inherits(OutletComponentDefinition, _ComponentDefinition2); - /** - Removes (prunes) any query params with default values from the given QP - object. Default values are determined from the QP meta information per key. - @private - @method _pruneDefaultQueryParamValues - @param {Array} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _pruneDefaultQueryParamValues: function (handlerInfos, queryParams) { - var qps = this._queryParamsFor(handlerInfos); - for (var key in queryParams) { - var qp = qps.map[key]; - if (qp && qp.serializedDefaultValue === queryParams[key]) { - delete queryParams[key]; - } - } - }, + function OutletComponentDefinition(outletName, template) { + babelHelpers.classCallCheck(this, OutletComponentDefinition); - _doTransition: function (_targetRouteName, models, _queryParams) { - var targetRouteName = _targetRouteName || _emberRoutingUtils.getActiveTargetName(this.router); - _emberMetal.assert('The route ' + targetRouteName + ' was not found', targetRouteName && this.router.hasRoute(targetRouteName)); + _ComponentDefinition2.call(this, 'outlet', MANAGER, null); + this.outletName = outletName; + this.template = template; + _emberUtils.generateGuid(this); + } - var queryParams = {}; + return OutletComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); + var OutletLayoutCompiler = (function () { + function OutletLayoutCompiler(template) { + babelHelpers.classCallCheck(this, OutletLayoutCompiler); - _emberUtils.assign(queryParams, _queryParams); - this._prepareQueryParams(targetRouteName, models, queryParams); + this.template = template; + } - var transitionArgs = _emberRoutingUtils.routeArgs(targetRouteName, models, queryParams); - var transition = this.router.transitionTo.apply(this.router, transitionArgs); + OutletLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + }; - didBeginTransition(transition, this); + return OutletLayoutCompiler; + })(); - return transition; - }, + exports.OutletLayoutCompiler = OutletLayoutCompiler; - _processActiveTransitionQueryParams: function (targetRouteName, models, queryParams, _queryParams) { - // merge in any queryParams from the active transition which could include - // queryParams from the url on initial load. - if (!this.router.activeTransition) { - return; - } + OutletLayoutCompiler.id = 'outlet'; +}); +enifed('ember-glimmer/syntax/render', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet, _container, _emberGlimmerSyntaxAbstractManager) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var unchangedQPs = {}; - var qpUpdates = this._qpUpdates || {}; - for (var key in this.router.activeTransition.queryParams) { - if (!qpUpdates[key]) { - unchangedQPs[key] = this.router.activeTransition.queryParams[key]; - } - } + exports.renderMacro = renderMacro; - // We need to fully scope queryParams so that we can create one object - // that represents both pased in queryParams and ones that aren't changed - // from the active transition. - this._fullyScopeQueryParams(targetRouteName, models, _queryParams); - this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs); - _emberUtils.assign(queryParams, unchangedQPs); - }, + function makeComponentDefinition(vm) { + var env = vm.env; + var args = vm.getArgs(); + var nameRef = args.positional.at(0); - /** - Prepares the query params for a URL or Transition. Restores any undefined QP - keys/values, serializes all values, and then prunes any default values. - @private - @method _prepareQueryParams - @param {String} targetRouteName - @param {Array} models - @param {Object} queryParams - @return {Void} - */ - _prepareQueryParams: function (targetRouteName, models, queryParams) { - var state = calculatePostTransitionState(this, targetRouteName, models); - this._hydrateUnsuppliedQueryParams(state, queryParams); - this._serializeQueryParams(state.handlerInfos, queryParams); - this._pruneDefaultQueryParamValues(state.handlerInfos, queryParams); - }, + _emberMetal.assert('The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.', _glimmerReference.isConst(nameRef)); + _emberMetal.assert('The second argument of {{render}} must be a path, e.g. {{render "post" post}}.', args.positional.length === 1 || !_glimmerReference.isConst(args.positional.at(1))); - /** - Returns the meta information for the query params of a given route. This - will be overriden to allow support for lazy routes. - @private - @method _getQPMeta - @param {HandlerInfo} handlerInfo - @return {Object} - */ - _getQPMeta: function (handlerInfo) { - var route = handlerInfo.handler; - return route && _emberMetal.get(route, '_qp'); - }, + var templateName = nameRef.value(); - /** - Returns a merged query params meta object for a given set of handlerInfos. - Useful for knowing what query params are available for a given route hierarchy. - @private - @method _queryParamsFor - @param {Array} handlerInfos - @return {Object} - */ - _queryParamsFor: function (handlerInfos) { - var leafRouteName = handlerInfos[handlerInfos.length - 1].name; - if (this._qpCache[leafRouteName]) { - return this._qpCache[leafRouteName]; - } + _emberMetal.assert('You used `{{render \'' + templateName + '\'}}`, but \'' + templateName + '\' can not be found as a template.', env.owner.hasRegistration('template:' + templateName)); - var shouldCache = true; - var qpsByUrlKey = {}; - var map = {}; - var qps = []; + var template = env.owner.lookup('template:' + templateName); - for (var i = 0; i < handlerInfos.length; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); + var controllerName = undefined; - if (!qpMeta) { - shouldCache = false; - continue; - } + if (args.named.has('controller')) { + var controllerNameRef = args.named.get('controller'); - // Loop over each QP to make sure we don't have any collisions by urlKey - for (var _i = 0; _i < qpMeta.qps.length; _i++) { - var qp = qpMeta.qps[_i]; - var urlKey = qp.urlKey; + _emberMetal.assert('The controller argument for {{render}} must be quoted, e.g. {{render "sidebar" controller="foo"}}.', _glimmerReference.isConst(controllerNameRef)); - if (qpsByUrlKey[urlKey]) { - var otherQP = qpsByUrlKey[urlKey]; - _emberMetal.assert('You\'re not allowed to have more than one controller property map to the same query param key, but both `' + otherQP.scopedPropertyName + '` and `' + qp.scopedPropertyName + '` map to `' + urlKey + '`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `' + otherQP.prop + ': { as: \'other-' + otherQP.prop + '\' }`', false); - } + controllerName = controllerNameRef.value(); - qpsByUrlKey[urlKey] = qp; - qps.push(qp); - } + _emberMetal.assert('The controller name you supplied \'' + controllerName + '\' did not resolve to a controller.', env.owner.hasRegistration('controller:' + controllerName)); + } else { + controllerName = templateName; + } - _emberUtils.assign(map, qpMeta.map); - } + if (args.positional.length === 1) { + return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, SINGLETON_RENDER_MANAGER)); + } else { + return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, NON_SINGLETON_RENDER_MANAGER)); + } + } + + /** + Calling ``{{render}}`` from within a template will insert another + template that matches the provided name. The inserted template will + access its properties on its own controller (rather than the controller + of the parent template). + + If a view class with the same name exists, the view class also will be used. + Note: A given controller may only be used *once* in your app in this manner. + A singleton instance of the controller will be created for you. + + Example: + + ```javascript + App.NavigationController = Ember.Controller.extend({ + who: "world" + }); + ``` + + ```handlebars + + Hello, {{who}}. + ``` + + ```handlebars + +

    My great app

    + {{render "navigation"}} + ``` + + ```html +

    My great app

    +
    + Hello, world. +
    + ``` + + Optionally you may provide a second argument: a property path + that will be bound to the `model` property of the controller. + If a `model` property path is specified, then a new instance of the + controller will be created and `{{render}}` can be used multiple times + with the same name. + + For example if you had this `author` template. + + ```handlebars +
    + Written by {{firstName}} {{lastName}}. + Total Posts: {{postCount}} +
    + ``` + + You could render it inside the `post` template using the `render` helper. + + ```handlebars +
    +

    {{title}}

    +
    {{body}}
    + {{render "author" author}} +
    + ``` + + @method render + @for Ember.Templates.helpers + @param {String} name + @param {Object?} context + @param {Hash} options + @return {String} HTML string + @public + */ - var finalQPMeta = { - qps: qps, - map: map - }; + function renderMacro(path, params, hash, builder) { + if (!params) { + params = []; + } + var definitionArgs = [params.slice(0), hash, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, makeComponentDefinition, args, builder.symbolTable); + return true; + } - if (shouldCache) { - this._qpCache[leafRouteName] = finalQPMeta; - } + var AbstractRenderManager = (function (_AbstractManager) { + babelHelpers.inherits(AbstractRenderManager, _AbstractManager); - return finalQPMeta; - }, + function AbstractRenderManager() { + babelHelpers.classCallCheck(this, AbstractRenderManager); - /** - Maps all query param keys to their fully scoped property name of the form - `controllerName:propName`. - @private - @method _fullyScopeQueryParams - @param {String} leafRouteName - @param {Array} contexts - @param {Object} queryParams - @return {Void} - */ - _fullyScopeQueryParams: function (leafRouteName, contexts, queryParams) { - var state = calculatePostTransitionState(this, leafRouteName, contexts); - var handlerInfos = state.handlerInfos; + _AbstractManager.apply(this, arguments); + } - for (var i = 0, len = handlerInfos.length; i < len; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); + AbstractRenderManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - if (!qpMeta) { - continue; - } + /* abstract create(environment, definition, args, dynamicScope); */ - for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { - var qp = qpMeta.qps[j]; + AbstractRenderManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, definition.template); + }; - var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; + AbstractRenderManager.prototype.getSelf = function getSelf(_ref) { + var controller = _ref.controller; - if (presentProp) { - if (presentProp !== qp.scopedPropertyName) { - queryParams[qp.scopedPropertyName] = queryParams[presentProp]; - delete queryParams[presentProp]; - } - } - } - } - }, + return new _emberGlimmerUtilsReferences.RootReference(controller); + }; - /** - Hydrates (adds/restores) any query params that have pre-existing values into - the given queryParams hash. This is what allows query params to be "sticky" - and restore their last known values for their scope. - @private - @method _hydrateUnsuppliedQueryParams - @param {TransitionState} state - @param {Object} queryParams - @return {Void} - */ - _hydrateUnsuppliedQueryParams: function (state, queryParams) { - var handlerInfos = state.handlerInfos; - var appCache = this._bucketCache; + AbstractRenderManager.prototype.getTag = function getTag() { + return null; + }; - for (var i = 0; i < handlerInfos.length; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); + AbstractRenderManager.prototype.getDestructor = function getDestructor() { + return null; + }; - if (!qpMeta) { - continue; - } + AbstractRenderManager.prototype.didCreateElement = function didCreateElement() {}; - for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { - var qp = qpMeta.qps[j]; + AbstractRenderManager.prototype.didRenderLayout = function didRenderLayout() {}; - var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; + AbstractRenderManager.prototype.didCreate = function didCreate() {}; - if (presentProp) { - if (presentProp !== qp.scopedPropertyName) { - queryParams[qp.scopedPropertyName] = queryParams[presentProp]; - delete queryParams[presentProp]; - } - } else { - var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.controllerName, qp.parts, state.params); - queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); - } - } - } - }, + AbstractRenderManager.prototype.update = function update() {}; - _scheduleLoadingEvent: function (transition, originRoute) { - this._cancelSlowTransitionTimer(); - this._slowTransitionTimer = _emberMetal.run.scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute); - }, + AbstractRenderManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - currentState: null, - targetState: null, + AbstractRenderManager.prototype.didUpdate = function didUpdate() {}; - _handleSlowTransition: function (transition, originRoute) { - if (!this.router.activeTransition) { - // Don't fire an event if we've since moved on from - // the transition that put us in a loading state. - return; - } + return AbstractRenderManager; + })(_emberGlimmerSyntaxAbstractManager.default); - this.set('targetState', _emberRoutingSystemRouter_state.default.create({ - emberRouter: this, - routerJs: this.router, - routerJsState: this.router.activeTransition.state - })); + _emberMetal.runInDebug(function () { + AbstractRenderManager.prototype.didRenderLayout = function () { + this.debugStack.pop(); + }; + }); - transition.trigger(true, 'loading', transition, originRoute); - }, + var SingletonRenderManager = (function (_AbstractRenderManager) { + babelHelpers.inherits(SingletonRenderManager, _AbstractRenderManager); - _cancelSlowTransitionTimer: function () { - if (this._slowTransitionTimer) { - _emberMetal.run.cancel(this._slowTransitionTimer); - } - this._slowTransitionTimer = null; - }, + function SingletonRenderManager() { + babelHelpers.classCallCheck(this, SingletonRenderManager); - // These three helper functions are used to ensure errors aren't - // re-raised if they're handled in a route's error action. - _markErrorAsHandled: function (errorGuid) { - this._handledErrors[errorGuid] = true; - }, + _AbstractRenderManager.apply(this, arguments); + } - _isErrorHandled: function (errorGuid) { - return this._handledErrors[errorGuid]; - }, + SingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this = this; - _clearHandledError: function (errorGuid) { - delete this._handledErrors[errorGuid]; - }, + var name = definition.name; + var env = definition.env; - _getEngineInstance: function (_ref) { - var name = _ref.name; - var instanceId = _ref.instanceId; - var mountPoint = _ref.mountPoint; + var controller = env.owner.lookup('controller:' + name) || _emberRouting.generateController(env.owner, name); - var engineInstances = this._engineInstances; + _emberMetal.runInDebug(function () { + return _this._pushToDebugStack('controller:' + name + ' (with the render helper)', environment); + }); - if (!engineInstances[name]) { - engineInstances[name] = new _emberUtils.EmptyObject(); + if (dynamicScope.rootOutletState) { + dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); } - var engineInstance = engineInstances[name][instanceId]; - - if (!engineInstance) { - var owner = _emberUtils.getOwner(this); + return { controller: controller }; + }; - _emberMetal.assert('You attempted to mount the engine \'' + name + '\' in your router map, but the engine can not be found.', owner.hasRegistration('engine:' + name)); + return SingletonRenderManager; + })(AbstractRenderManager); - engineInstance = owner.buildChildEngineInstance(name, { - routable: true, - mountPoint: mountPoint - }); + var SINGLETON_RENDER_MANAGER = new SingletonRenderManager(); - engineInstance.boot(); + var NonSingletonRenderManager = (function (_AbstractRenderManager2) { + babelHelpers.inherits(NonSingletonRenderManager, _AbstractRenderManager2); - engineInstances[name][instanceId] = engineInstance; - } + function NonSingletonRenderManager() { + babelHelpers.classCallCheck(this, NonSingletonRenderManager); - return engineInstance; + _AbstractRenderManager2.apply(this, arguments); } - }); - /* - Helper function for iterating over routes in a set of handlerInfos that are - at or above the given origin route. Example: if `originRoute` === 'foo.bar' - and the handlerInfos given were for 'foo.bar.baz', then the given callback - will be invoked with the routes for 'foo.bar', 'foo', and 'application' - individually. - - If the callback returns anything other than `true`, then iteration will stop. - - @private - @param {Route} originRoute - @param {Array} handlerInfos - @param {Function} callback - @return {Void} - */ - function forEachRouteAbove(originRoute, handlerInfos, callback) { - var originRouteFound = false; + NonSingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var _this2 = this; - for (var i = handlerInfos.length - 1; i >= 0; --i) { - var handlerInfo = handlerInfos[i]; - var route = handlerInfo.handler; + var name = definition.name; + var env = definition.env; - if (originRoute === route) { - originRouteFound = true; - } + var modelRef = args.positional.at(0); + var controllerFactory = env.owner[_container.FACTORY_FOR]('controller:' + name); - if (!originRouteFound) { - continue; - } + var factory = controllerFactory || _emberRouting.generateControllerFactory(env.owner, name); + var controller = factory.create({ model: modelRef.value() }); - if (callback(route) !== true) { - return; + _emberMetal.runInDebug(function () { + return _this2._pushToDebugStack('controller:' + name + ' (with the render helper)', environment); + }); + + if (dynamicScope.rootOutletState) { + dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); } - } - } - // These get invoked when an action bubbles above ApplicationRoute - // and are not meant to be overridable. - var defaultActionHandlers = { + return { controller: controller }; + }; - willResolveModel: function (transition, originRoute) { - originRoute.router._scheduleLoadingEvent(transition, originRoute); - }, + NonSingletonRenderManager.prototype.update = function update(_ref2, args, dynamicScope) { + var controller = _ref2.controller; - // Attempt to find an appropriate error route or substate to enter. - error: function (error, transition, originRoute) { - var handlerInfos = transition.state.handlerInfos; - var router = originRoute.router; + controller.set('model', args.positional.at(0).value()); + }; - forEachRouteAbove(originRoute, handlerInfos, function (route) { - // Check for the existence of an 'error' route. - // We don't check for an 'error' route on the originRoute, since that would - // technically be below where we're at in the route hierarchy. - if (originRoute !== route) { - var errorRouteName = findRouteStateName(route, 'error'); - if (errorRouteName) { - router.intermediateTransitionTo(errorRouteName, error); - return false; - } - } + NonSingletonRenderManager.prototype.getDestructor = function getDestructor(_ref3) { + var controller = _ref3.controller; - // Check for an 'error' substate route - var errorSubstateName = findRouteSubstateName(route, 'error'); - if (errorSubstateName) { - router.intermediateTransitionTo(errorSubstateName, error); - return false; - } + return controller; + }; - return true; - }); + return NonSingletonRenderManager; + })(AbstractRenderManager); - logError(error, 'Error while processing route: ' + transition.targetName); - }, + var NON_SINGLETON_RENDER_MANAGER = new NonSingletonRenderManager(); - // Attempt to find an appropriate loading route or substate to enter. - loading: function (transition, originRoute) { - var handlerInfos = transition.state.handlerInfos; - var router = originRoute.router; + var RenderDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(RenderDefinition, _ComponentDefinition); - forEachRouteAbove(originRoute, handlerInfos, function (route) { - // Check for the existence of a 'loading' route. - // We don't check for a 'loading' route on the originRoute, since that would - // technically be below where we're at in the route hierarchy. - if (originRoute !== route) { - var loadingRouteName = findRouteStateName(route, 'loading'); - if (loadingRouteName) { - router.intermediateTransitionTo(loadingRouteName); - return false; - } - } + function RenderDefinition(name, template, env, manager) { + babelHelpers.classCallCheck(this, RenderDefinition); - // Check for loading substate - var loadingSubstateName = findRouteSubstateName(route, 'loading'); - if (loadingSubstateName) { - router.intermediateTransitionTo(loadingSubstateName); - return false; - } + _ComponentDefinition.call(this, 'render', manager, null); - // Don't bubble above pivot route. - return transition.pivotHandler !== route; - }); + this.name = name; + this.template = template; + this.env = env; } - }; - function logError(_error, initialMessage) { - var errorArgs = []; - var error = undefined; - if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { - error = _error.errorThrown; - } else { - error = _error; - } + return RenderDefinition; + })(_glimmerRuntime.ComponentDefinition); +}); +enifed('ember-glimmer/template', ['exports', 'ember-utils', '@glimmer/runtime'], function (exports, _emberUtils, _glimmerRuntime) { + 'use strict'; - if (initialMessage) { - errorArgs.push(initialMessage); - } + exports.default = template; - if (error) { - if (error.message) { - errorArgs.push(error.message); - } - if (error.stack) { - errorArgs.push(error.stack); - } + function template(json) { + var factory = _glimmerRuntime.templateFactory(json); - if (typeof error === 'string') { - errorArgs.push(error); + return { + id: factory.id, + meta: factory.meta, + create: function (props) { + return factory.create(props.env, { owner: props[_emberUtils.OWNER] }); } - } - - _emberConsole.default.error.apply(this, errorArgs); + }; } +}); +enifed("ember-glimmer/template_registry", ["exports"], function (exports) { + // STATE within a module is frowned apon, this exists + // to support Ember.TEMPLATES but shield ember internals from this legacy + // global API. + "use strict"; - /** - Finds the name of the substate route if it exists for the given route. A - substate route is of the form `route_state`, such as `foo_loading`. - - @private - @param {Route} route - @param {String} state - @return {String} - */ - function findRouteSubstateName(route, state) { - var router = route.router; - var owner = _emberUtils.getOwner(route); - - var routeName = route.routeName; - var substateName = routeName + '_' + state; - - var routeNameFull = route.fullRouteName; - var substateNameFull = routeNameFull + '_' + state; + exports.setTemplates = setTemplates; + exports.getTemplates = getTemplates; + exports.getTemplate = getTemplate; + exports.hasTemplate = hasTemplate; + exports.setTemplate = setTemplate; + var TEMPLATES = {}; - return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; + function setTemplates(templates) { + TEMPLATES = templates; } - /** - Finds the name of the state route if it exists for the given route. A state - route is of the form `route.state`, such as `foo.loading`. Properly Handles - `application` named routes. - - @private - @param {Route} route - @param {String} state - @return {String} - */ - function findRouteStateName(route, state) { - var router = route.router; - var owner = _emberUtils.getOwner(route); - - var routeName = route.routeName; - var stateName = routeName === 'application' ? state : routeName + '.' + state; - - var routeNameFull = route.fullRouteName; - var stateNameFull = routeNameFull === 'application' ? state : routeNameFull + '.' + state; + function getTemplates() { + return TEMPLATES; + } - return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; + function getTemplate(name) { + if (TEMPLATES.hasOwnProperty(name)) { + return TEMPLATES[name]; + } } - /** - Determines whether or not a route has been defined by checking that the route - is in the Router's map and the owner has a registration for that route. - - @private - @param {Owner} owner - @param {Ember.Router} router - @param {String} localName - @param {String} fullName - @return {Boolean} - */ - function routeHasBeenDefined(owner, router, localName, fullName) { - var routerHasRoute = router.hasRoute(fullName); - var ownerHasRoute = owner.hasRegistration('template:' + localName) || owner.hasRegistration('route:' + localName); - return routerHasRoute && ownerHasRoute; + function hasTemplate(name) { + return TEMPLATES.hasOwnProperty(name); } - function triggerEvent(handlerInfos, ignoreFailure, args) { - var name = args.shift(); + function setTemplate(name, template) { + return TEMPLATES[name] = template; + } +}); +enifed("ember-glimmer/templates/component", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - if (!handlerInfos) { - if (ignoreFailure) { - return; - } - throw new _emberMetal.Error('Can\'t trigger action \'' + name + '\' because your app hasn\'t finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.'); - } + exports.default = _emberGlimmerTemplate.default({ "id": "2aYM5QYc", "block": "{\"statements\":[[\"yield\",\"default\"]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/component.hbs" } }); +}); +enifed("ember-glimmer/templates/empty", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - var eventWasHandled = false; - var handlerInfo = undefined, - handler = undefined; + exports.default = _emberGlimmerTemplate.default({ "id": "5QJJjniM", "block": "{\"statements\":[],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/empty.hbs" } }); +}); +enifed("ember-glimmer/templates/link-to", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - for (var i = handlerInfos.length - 1; i >= 0; i--) { - handlerInfo = handlerInfos[i]; - handler = handlerInfo.handler; + exports.default = _emberGlimmerTemplate.default({ "id": "Y2DX6qHQ", "block": "{\"statements\":[[\"block\",[\"if\"],[[\"get\",[\"linkTitle\"]]],null,{\"statements\":[[\"append\",[\"unknown\",[\"linkTitle\"]],false]],\"locals\":[]},{\"statements\":[[\"yield\",\"default\"]],\"locals\":[]}]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/link-to.hbs" } }); +}); +enifed("ember-glimmer/templates/outlet", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - if (handler && handler.actions && handler.actions[name]) { - if (handler.actions[name].apply(handler, args) === true) { - eventWasHandled = true; - } else { - // Should only hit here if a non-bubbling error action is triggered on a route. - if (name === 'error') { - var errorId = _emberUtils.guidFor(args[0]); - handler.router._markErrorAsHandled(errorId); - } - return; - } - } - } + exports.default = _emberGlimmerTemplate.default({ "id": "xyZMyWzn", "block": "{\"statements\":[[\"append\",[\"unknown\",[\"outlet\"]],false]],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/outlet.hbs" } }); +}); +enifed("ember-glimmer/templates/root", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - if (defaultActionHandlers[name]) { - defaultActionHandlers[name].apply(null, args); - return; - } + exports.default = _emberGlimmerTemplate.default({ "id": "/KBRNPqv", "block": "{\"statements\":[[\"append\",[\"helper\",[\"component\"],[[\"get\",[null]]],null],false]],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/root.hbs" } }); +}); +enifed('ember-glimmer/utils/bindings', ['exports', '@glimmer/reference', 'ember-metal', 'ember-runtime', 'ember-glimmer/component', 'ember-glimmer/utils/string'], function (exports, _glimmerReference, _emberMetal, _emberRuntime, _emberGlimmerComponent, _emberGlimmerUtilsString) { + 'use strict'; - if (!eventWasHandled && !ignoreFailure) { - throw new _emberMetal.Error('Nothing handled the action \'' + name + '\'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.'); - } + exports.wrapComponentClassAttribute = wrapComponentClassAttribute; + + function referenceForKey(component, key) { + return component[_emberGlimmerComponent.ROOT_REF].get(key); } - function calculatePostTransitionState(emberRouter, leafRouteName, contexts) { - var routerjs = emberRouter.router; - var state = routerjs.applyIntent(leafRouteName, contexts); - var handlerInfos = state.handlerInfos; - var params = state.params; + function referenceForParts(component, parts) { + var isAttrs = parts[0] === 'attrs'; - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; + // TODO deprecate this + if (isAttrs) { + parts.shift(); - // If the handlerInfo is not resolved, we serialize the context into params - if (!handlerInfo.isResolved) { - params[handlerInfo.name] = handlerInfo.serialize(handlerInfo.context); - } else { - params[handlerInfo.name] = handlerInfo.params; + if (parts.length === 1) { + return referenceForKey(component, parts[0]); } } - return state; - } - - function updatePaths(router) { - var infos = router.router.currentHandlerInfos; - if (infos.length === 0) { - return; - } - - var path = EmberRouter._routePath(infos); - var currentRouteName = infos[infos.length - 1].name; - _emberMetal.set(router, 'currentPath', path); - _emberMetal.set(router, 'currentRouteName', currentRouteName); + return _glimmerReference.referenceFromParts(component[_emberGlimmerComponent.ROOT_REF], parts); + } - var appController = _emberUtils.getOwner(router).lookup('controller:application'); + // TODO we should probably do this transform at build time - if (!appController) { - // appController might not exist when top-level loading/error - // substates have been entered since ApplicationRoute hasn't - // actually been entered at that point. - return; + function wrapComponentClassAttribute(hash) { + if (!hash) { + return hash; } - if (!('currentPath' in appController)) { - _emberMetal.defineProperty(appController, 'currentPath'); - } + var keys = hash[0]; + var values = hash[1]; - _emberMetal.set(appController, 'currentPath', path); + var index = keys.indexOf('class'); - if (!('currentRouteName' in appController)) { - _emberMetal.defineProperty(appController, 'currentRouteName'); + if (index !== -1) { + var _values$index = values[index]; + var type = _values$index[0]; + + if (type === 'get') { + var getExp = values[index]; + var path = getExp[1]; + var propName = path[path.length - 1]; + hash[1][index] = ['helper', ['-class'], [getExp, propName]]; + } } - _emberMetal.set(appController, 'currentRouteName', currentRouteName); + return hash; } - EmberRouter.reopenClass({ - router: null, + var AttributeBinding = { + parse: function (microsyntax) { + var colonIndex = microsyntax.indexOf(':'); - /** - The `Router.map` function allows you to define mappings from URLs to routes - in your application. These mappings are defined within the - supplied callback function using `this.route`. - The first parameter is the name of the route which is used by default as the - path name as well. - The second parameter is the optional options hash. Available options are: - * `path`: allows you to provide your own path as well as mark dynamic - segments. - * `resetNamespace`: false by default; when nesting routes, ember will - combine the route names to form the fully-qualified route name, which is - used with `{{link-to}}` or manually transitioning to routes. Setting - `resetNamespace: true` will cause the route not to inherit from its - parent route's names. This is handy for preventing extremely long route names. - Keep in mind that the actual URL path behavior is still retained. - The third parameter is a function, which can be used to nest routes. - Nested routes, by default, will have the parent route tree's route name and - path prepended to it's own. - ```javascript - App.Router.map(function(){ - this.route('post', { path: '/post/:post_id' }, function() { - this.route('edit'); - this.route('comments', { resetNamespace: true }, function() { - this.route('new'); - }); - }); - }); - ``` - For more detailed documentation and examples please see - [the guides](http://emberjs.com/guides/routing/defining-your-routes/). - @method map - @param callback - @public - */ - map: function (callback) { - if (!this.dslCallbacks) { - this.dslCallbacks = []; - this.reopenClass({ dslCallbacks: this.dslCallbacks }); - } + if (colonIndex === -1) { + _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', microsyntax !== 'class'); + return [microsyntax, microsyntax, true]; + } else { + var prop = microsyntax.substring(0, colonIndex); + var attribute = microsyntax.substring(colonIndex + 1); - this.dslCallbacks.push(callback); + _emberMetal.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attribute !== 'class'); - return this; + return [prop, attribute, false]; + } }, - _routePath: function (handlerInfos) { - var path = []; - - // We have to handle coalescing resource names that - // are prefixed with their parent's names, e.g. - // ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz' + install: function (element, component, parsed, operations) { + var prop = parsed[0]; + var attribute = parsed[1]; + var isSimple = parsed[2]; - function intersectionMatches(a1, a2) { - for (var i = 0; i < a1.length; ++i) { - if (a1[i] !== a2[i]) { - return false; - } + if (attribute === 'id') { + var elementId = _emberMetal.get(component, prop); + if (elementId === undefined || elementId === null) { + elementId = component.elementId; } - return true; + operations.addStaticAttribute(element, 'id', elementId); + return; } - var name = undefined, - nameParts = undefined, - oldNameParts = undefined; - for (var i = 1; i < handlerInfos.length; i++) { - name = handlerInfos[i].name; - nameParts = name.split('.'); - oldNameParts = slice.call(path); + var isPath = prop.indexOf('.') > -1; + var reference = isPath ? referenceForParts(component, prop.split('.')) : referenceForKey(component, prop); - while (oldNameParts.length) { - if (intersectionMatches(oldNameParts, nameParts)) { - break; - } - oldNameParts.shift(); - } + _emberMetal.assert('Illegal attributeBinding: \'' + prop + '\' is not a valid attribute name.', !(isSimple && isPath)); - path.push.apply(path, nameParts.slice(oldNameParts.length)); + if (attribute === 'style') { + reference = new StyleBindingReference(reference, referenceForKey(component, 'isVisible')); } - return path.join('.'); - } - }); - - function didBeginTransition(transition, router) { - var routerState = _emberRoutingSystemRouter_state.default.create({ - emberRouter: router, - routerJs: router.router, - routerJsState: transition.state - }); - - if (!router.currentState) { - router.set('currentState', routerState); + operations.addDynamicAttribute(element, attribute, reference); } - router.set('targetState', routerState); - - transition.promise = transition.catch(function (error) { - var errorId = _emberUtils.guidFor(error); - - if (router._isErrorHandled(errorId)) { - router._clearHandledError(errorId); - } else { - throw error; - } - }); - } + }; - function resemblesURL(str) { - return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); - } + exports.AttributeBinding = AttributeBinding; + var DISPLAY_NONE = 'display: none;'; + var SAFE_DISPLAY_NONE = _emberGlimmerUtilsString.htmlSafe(DISPLAY_NONE); - function forEachQueryParam(router, handlerInfos, queryParams, callback) { - var qpCache = router._queryParamsFor(handlerInfos); + var StyleBindingReference = (function (_CachedReference) { + babelHelpers.inherits(StyleBindingReference, _CachedReference); - for (var key in queryParams) { - if (!queryParams.hasOwnProperty(key)) { - continue; - } - var value = queryParams[key]; - var qp = qpCache.map[key]; + function StyleBindingReference(inner, isVisible) { + babelHelpers.classCallCheck(this, StyleBindingReference); - callback(key, value, qp); - } - } + _CachedReference.call(this); - function findLiveRoute(liveRoutes, name) { - if (!liveRoutes) { - return; - } - var stack = [liveRoutes]; - while (stack.length > 0) { - var test = stack.shift(); - if (test.render.name === name) { - return test; - } - var outlets = test.outlets; - for (var outletName in outlets) { - stack.push(outlets[outletName]); - } + this.tag = _glimmerReference.combine([inner.tag, isVisible.tag]); + this.inner = inner; + this.isVisible = isVisible; } - } - function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { - var target = undefined; - var myState = { - render: renderOptions, - outlets: new _emberUtils.EmptyObject(), - wasUsed: false - }; - if (renderOptions.into) { - target = findLiveRoute(liveRoutes, renderOptions.into); - } else { - target = defaultParentState; - } - if (target) { - _emberMetal.set(target.outlets, renderOptions.outlet, myState); - } else { - if (renderOptions.into) { - _emberMetal.deprecate('Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated.', false, { - id: 'ember-routing.top-level-render-helper', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' - }); + StyleBindingReference.prototype.compute = function compute() { + var value = this.inner.value(); + var isVisible = this.isVisible.value(); - // Megahax time. Post-3.0-breaking-changes, we will just assert - // right here that the user tried to target a nonexistent - // thing. But for now we still need to support the `render` - // helper, and people are allowed to target templates rendered - // by the render helper. So instead we defer doing anyting with - // these orphan renders until afterRender. - appendOrphan(liveRoutes, renderOptions.into, myState); + if (isVisible !== false) { + return value; + } else if (!value && value !== 0) { + return SAFE_DISPLAY_NONE; } else { - liveRoutes = myState; + var style = value + ' ' + DISPLAY_NONE; + return _emberGlimmerUtilsString.isHTMLSafe(value) ? _emberGlimmerUtilsString.htmlSafe(style) : style; } - } - return { - liveRoutes: liveRoutes, - ownState: myState }; - } - - function appendOrphan(liveRoutes, into, myState) { - if (!liveRoutes.outlets.__ember_orphans__) { - liveRoutes.outlets.__ember_orphans__ = { - render: { - name: '__ember_orphans__' - }, - outlets: new _emberUtils.EmptyObject() - }; - } - liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; - _emberMetal.run.schedule('afterRender', function () { - // `wasUsed` gets set by the render helper. - _emberMetal.assert('You attempted to render into \'' + into + '\' but it was not found', liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed); - }); - } - - function representEmptyRoute(liveRoutes, defaultParentState, route) { - // the route didn't render anything - var alreadyAppended = findLiveRoute(liveRoutes, route.routeName); - if (alreadyAppended) { - // But some other route has already rendered our default - // template, so that becomes the default target for any - // children we may have. - return alreadyAppended; - } else { - // Create an entry to represent our default template name, - // just so other routes can target it and inherit its place - // in the outlet hierarchy. - defaultParentState.outlets.main = { - render: { - name: route.routeName, - outlet: 'main' - }, - outlets: {} - }; - return defaultParentState; - } - } - exports.default = EmberRouter; -}); + return StyleBindingReference; + })(_glimmerReference.CachedReference); -/** -@module ember -@submodule ember-routing -*/ -enifed('ember-routing/system/router_state', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime'], function (exports, _emberUtils, _emberMetal, _emberRuntime) { - 'use strict'; + var IsVisibleBinding = { + install: function (element, component, operations) { + operations.addDynamicAttribute(element, 'style', _glimmerReference.map(referenceForKey(component, 'isVisible'), this.mapStyleValue)); + }, - exports.default = _emberRuntime.Object.extend({ - emberRouter: null, - routerJs: null, - routerJsState: null, + mapStyleValue: function (isVisible) { + return isVisible === false ? SAFE_DISPLAY_NONE : null; + } + }; - isActiveIntent: function (routeName, models, queryParams, queryParamsMustMatch) { - var state = this.routerJsState; - if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { - return false; - } + exports.IsVisibleBinding = IsVisibleBinding; + var ClassNameBinding = { + install: function (element, component, microsyntax, operations) { + var _microsyntax$split = microsyntax.split(':'); - var emptyQueryParams = _emberMetal.isEmpty(Object.keys(queryParams)); + var prop = _microsyntax$split[0]; + var truthy = _microsyntax$split[1]; + var falsy = _microsyntax$split[2]; - if (queryParamsMustMatch && !emptyQueryParams) { - var visibleQueryParams = {}; - _emberUtils.assign(visibleQueryParams, queryParams); + var isStatic = prop === ''; - this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); - return shallowEqual(visibleQueryParams, state.queryParams); - } + if (isStatic) { + operations.addStaticAttribute(element, 'class', truthy); + } else { + var isPath = prop.indexOf('.') > -1; + var parts = isPath && prop.split('.'); + var value = isPath ? referenceForParts(component, parts) : referenceForKey(component, prop); + var ref = undefined; - return true; - } - }); + if (truthy === undefined) { + ref = new SimpleClassNameBindingReference(value, isPath ? parts[parts.length - 1] : prop); + } else { + ref = new ColonClassNameBindingReference(value, truthy, falsy); + } - function shallowEqual(a, b) { - var k = undefined; - for (k in a) { - if (a.hasOwnProperty(k) && a[k] !== b[k]) { - return false; - } - } - for (k in b) { - if (b.hasOwnProperty(k) && a[k] !== b[k]) { - return false; + operations.addDynamicAttribute(element, 'class', ref); } } - return true; - } -}); -enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { - 'use strict'; + }; - exports.routeArgs = routeArgs; - exports.getActiveTargetName = getActiveTargetName; - exports.stashParamNames = stashParamNames; - exports.calculateCacheKey = calculateCacheKey; - exports.normalizeControllerQueryParams = normalizeControllerQueryParams; - exports.prefixRouteNameArg = prefixRouteNameArg; + exports.ClassNameBinding = ClassNameBinding; - var ALL_PERIODS_REGEX = /\./g; + var SimpleClassNameBindingReference = (function (_CachedReference2) { + babelHelpers.inherits(SimpleClassNameBindingReference, _CachedReference2); - function routeArgs(targetRouteName, models, queryParams) { - var args = []; - if (typeof targetRouteName === 'string') { - args.push('' + targetRouteName); - } - args.push.apply(args, models); - args.push({ queryParams: queryParams }); - return args; - } + function SimpleClassNameBindingReference(inner, path) { + babelHelpers.classCallCheck(this, SimpleClassNameBindingReference); - function getActiveTargetName(router) { - var handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; - return handlerInfos[handlerInfos.length - 1].name; - } + _CachedReference2.call(this); - function stashParamNames(router, handlerInfos) { - if (handlerInfos._namesStashed) { - return; + this.tag = inner.tag; + this.inner = inner; + this.path = path; + this.dasherizedPath = null; } - // This helper exists because router.js/route-recognizer.js awkwardly - // keeps separate a handlerInfo's list of parameter names depending - // on whether a URL transition or named transition is happening. - // Hopefully we can remove this in the future. - var targetRouteName = handlerInfos[handlerInfos.length - 1].name; - var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); - var dynamicParent = null; + SimpleClassNameBindingReference.prototype.compute = function compute() { + var value = this.inner.value(); - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; - var names = recogHandlers[i].names; + if (value === true) { + var path = this.path; + var dasherizedPath = this.dasherizedPath; - if (names.length) { - dynamicParent = handlerInfo; + return dasherizedPath || (this.dasherizedPath = _emberRuntime.String.dasherize(path)); + } else if (value || value === 0) { + return value; + } else { + return null; } + }; - handlerInfo._names = names; + return SimpleClassNameBindingReference; + })(_glimmerReference.CachedReference); - var route = handlerInfo.handler; - route._stashNames(handlerInfo, dynamicParent); + var ColonClassNameBindingReference = (function (_CachedReference3) { + babelHelpers.inherits(ColonClassNameBindingReference, _CachedReference3); + + function ColonClassNameBindingReference(inner, truthy, falsy) { + babelHelpers.classCallCheck(this, ColonClassNameBindingReference); + + _CachedReference3.call(this); + + this.tag = inner.tag; + this.inner = inner; + this.truthy = truthy || null; + this.falsy = falsy || null; } - handlerInfos._namesStashed = true; - } + ColonClassNameBindingReference.prototype.compute = function compute() { + var inner = this.inner; + var truthy = this.truthy; + var falsy = this.falsy; - function _calculateCacheValuePrefix(prefix, part) { - // calculates the dot seperated sections from prefix that are also - // at the start of part - which gives us the route name + return inner.value() ? truthy : falsy; + }; - // given : prefix = site.article.comments, part = site.article.id - // - returns: site.article (use get(values[site.article], 'id') to get the dynamic part - used below) + return ColonClassNameBindingReference; + })(_glimmerReference.CachedReference); +}); +enifed('ember-glimmer/utils/debug-stack', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - // given : prefix = site.article, part = site.article.id - // - returns: site.article. (use get(values[site.article], 'id') to get the dynamic part - used below) + var DebugStack = undefined; - var prefixParts = prefix.split('.'); - var currPrefix = ''; + _emberMetal.runInDebug(function () { + var Element = function Element(name) { + babelHelpers.classCallCheck(this, Element); - for (var i = 0; i < prefixParts.length; i++) { - var currPart = prefixParts.slice(0, i + 1).join('.'); - if (part.indexOf(currPart) !== 0) { - break; - } - currPrefix = currPart; - } + this.name = name; + }; - return currPrefix; - } + var TemplateElement = (function (_Element) { + babelHelpers.inherits(TemplateElement, _Element); - /* - Stolen from Controller - */ + function TemplateElement() { + babelHelpers.classCallCheck(this, TemplateElement); - function calculateCacheKey(prefix, _parts, values) { - var parts = _parts || []; - var suffixes = ''; - for (var i = 0; i < parts.length; ++i) { - var part = parts[i]; - var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); - var value = undefined; - if (values) { - if (cacheValuePrefix && cacheValuePrefix in values) { - var partRemovedPrefix = part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part; - value = _emberMetal.get(values[cacheValuePrefix], partRemovedPrefix); - } else { - value = _emberMetal.get(values, part); - } + _Element.apply(this, arguments); + } + + return TemplateElement; + })(Element); + + var EngineElement = (function (_Element2) { + babelHelpers.inherits(EngineElement, _Element2); + + function EngineElement() { + babelHelpers.classCallCheck(this, EngineElement); + + _Element2.apply(this, arguments); } - suffixes += '::' + part + ':' + value; - } - return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); - } - /* - Controller-defined query parameters can come in three shapes: - - Array - queryParams: ['foo', 'bar'] - Array of simple objects where value is an alias - queryParams: [ - { - 'foo': 'rename_foo_to_this' - }, - { - 'bar': 'call_bar_this_instead' + return EngineElement; + })(Element); + + DebugStack = (function () { + function DebugStack() { + babelHelpers.classCallCheck(this, DebugStack); + + this._stack = []; + } + + DebugStack.prototype.push = function push(name) { + this._stack.push(new TemplateElement(name)); + }; + + DebugStack.prototype.pushEngine = function pushEngine(name) { + this._stack.push(new EngineElement(name)); + }; + + DebugStack.prototype.pop = function pop() { + var element = this._stack.pop(); + + if (element) { + return element.name; } - ] - Array of fully defined objects - queryParams: [ - { - 'foo': { - as: 'rename_foo_to_this' - }, + }; + + DebugStack.prototype.peek = function peek() { + var template = this._currentTemplate(); + var engine = this._currentEngine(); + + if (engine) { + return '"' + template + '" (in "' + engine + '")'; + } else if (template) { + return '"' + template + '"'; } - { - 'bar': { - as: 'call_bar_this_instead', - scope: 'controller' + }; + + DebugStack.prototype._currentTemplate = function _currentTemplate() { + return this._getCurrentByType(TemplateElement); + }; + + DebugStack.prototype._currentEngine = function _currentEngine() { + return this._getCurrentByType(EngineElement); + }; + + DebugStack.prototype._getCurrentByType = function _getCurrentByType(type) { + for (var i = this._stack.length; i >= 0; i--) { + var element = this._stack[i]; + if (element instanceof type) { + return element.name; } } - ] - - This helper normalizes all three possible styles into the - 'Array of fully defined objects' style. - */ + }; - function normalizeControllerQueryParams(queryParams) { - var qpMap = {}; + return DebugStack; + })(); + }); - for (var i = 0; i < queryParams.length; ++i) { - accumulateQueryParamDescriptors(queryParams[i], qpMap); + exports.default = DebugStack; +}); +enifed('ember-glimmer/utils/iterable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', '@glimmer/reference'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerReference) { + 'use strict'; + + exports.default = iterableFor; + + var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; + + function iterableFor(ref, keyPath) { + if (_emberGlimmerHelpersEachIn.isEachIn(ref)) { + return new EachInIterable(ref, keyForEachIn(keyPath)); + } else { + return new ArrayIterable(ref, keyForArray(keyPath)); } + } - return qpMap; + function keyForEachIn(keyPath) { + switch (keyPath) { + case '@index': + case undefined: + case null: + return index; + case '@identity': + return identity; + default: + return function (item) { + return _emberMetal.get(item, keyPath); + }; + } } - function accumulateQueryParamDescriptors(_desc, accum) { - var desc = _desc; - var tmp = undefined; - if (typeof desc === 'string') { - tmp = {}; - tmp[desc] = { as: null }; - desc = tmp; + function keyForArray(keyPath) { + switch (keyPath) { + case '@index': + return index; + case '@identity': + case undefined: + case null: + return identity; + default: + return function (item) { + return _emberMetal.get(item, keyPath); + }; } + } - for (var key in desc) { - if (!desc.hasOwnProperty(key)) { - return; - } + function index(item, index) { + return String(index); + } - var singleDesc = desc[key]; - if (typeof singleDesc === 'string') { - singleDesc = { as: singleDesc }; - } + function identity(item) { + switch (typeof item) { + case 'string': + case 'number': + return String(item); + default: + return _emberUtils.guidFor(item); + } + } - tmp = accum[key] || { as: null, scope: 'model' }; - _emberUtils.assign(tmp, singleDesc); + function ensureUniqueKey(seen, key) { + var seenCount = seen[key]; - accum[key] = tmp; + if (seenCount) { + seen[key]++; + return '' + key + ITERATOR_KEY_GUID + seenCount; + } else { + seen[key] = 1; } - } - /* - Check if a routeName resembles a url instead - - @private - */ - function resemblesURL(str) { - return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); + return key; } - /* - Returns an arguments array where the route name arg is prefixed based on the mount point - - @private - */ + var ArrayIterator = (function () { + function ArrayIterator(array, keyFor) { + babelHelpers.classCallCheck(this, ArrayIterator); - function prefixRouteNameArg(route, args) { - var routeName = args[0]; - var owner = _emberUtils.getOwner(route); - var prefix = owner.mountPoint; + this.array = array; + this.length = array.length; + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); + } - // only alter the routeName if it's actually referencing a route. - if (owner.routable && typeof routeName === 'string') { - if (resemblesURL(routeName)) { - throw new _emberMetal.Error('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'); - } else { - routeName = prefix + '.' + routeName; - args[0] = routeName; + ArrayIterator.prototype.isEmpty = function isEmpty() { + return false; + }; + + ArrayIterator.prototype.next = function next() { + var array = this.array; + var length = this.length; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; + + if (position >= length) { + return null; } - } - return args; - } -}); -enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeMixinsComparable) { - 'use strict'; + var value = array[position]; + var memo = position; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - exports.default = compare; + this.position++; - var TYPE_ORDER = { - 'undefined': 0, - 'null': 1, - 'boolean': 2, - 'number': 3, - 'string': 4, - 'array': 5, - 'object': 6, - 'instance': 7, - 'function': 8, - 'class': 9, - 'date': 10 - }; + return { key: key, value: value, memo: memo }; + }; - // - // the spaceship operator - // - // `. ___ - // __,' __`. _..----....____ - // __...--.'``;. ,. ;``--..__ .' ,-._ _.-' - // _..-''-------' `' `' `' O ``-''._ (,;') _,' - // ,'________________ \`-._`-',' - // `._ ```````````------...___ '-.._'-: - // ```--.._ ,. ````--...__\-. - // `.--. `-` "INFINITY IS LESS ____ | |` - // `. `. THAN BEYOND" ,'`````. ; ;` - // `._`. __________ `. \'__/` - // `-:._____/______/___/____`. \ ` - // | `._ `. \ - // `._________`-. `. `.___ - // SSt `------'` - function spaceship(a, b) { - var diff = a - b; - return (diff > 0) - (diff < 0); - } + return ArrayIterator; + })(); - /** - Compares two javascript values and returns: - - - -1 if the first is smaller than the second, - - 0 if both are equal, - - 1 if the first is greater than the second. - - ```javascript - Ember.compare('hello', 'hello'); // 0 - Ember.compare('abc', 'dfg'); // -1 - Ember.compare(2, 1); // 1 - ``` - - If the types of the two objects are different precedence occurs in the - following order, with types earlier in the list considered `<` types - later in the list: - - - undefined - - null - - boolean - - number - - string - - array - - object - - instance - - function - - class - - date - - ```javascript - Ember.compare('hello', 50); // 1 - Ember.compare(50, 'hello'); // -1 - ``` - - @method compare - @for Ember - @param {Object} v First value to compare - @param {Object} w Second value to compare - @return {Number} -1 if v < w, 0 if v = w and 1 if v > w. - @public - */ + var EmberArrayIterator = (function () { + function EmberArrayIterator(array, keyFor) { + babelHelpers.classCallCheck(this, EmberArrayIterator); - function compare(v, w) { - if (v === w) { - return 0; + this.array = array; + this.length = _emberMetal.get(array, 'length'); + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); } - var type1 = _emberRuntimeUtils.typeOf(v); - var type2 = _emberRuntimeUtils.typeOf(w); + EmberArrayIterator.prototype.isEmpty = function isEmpty() { + return this.length === 0; + }; - if (_emberRuntimeMixinsComparable.default) { - if (type1 === 'instance' && _emberRuntimeMixinsComparable.default.detect(v) && v.constructor.compare) { - return v.constructor.compare(v, w); - } + EmberArrayIterator.prototype.next = function next() { + var array = this.array; + var length = this.length; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; - if (type2 === 'instance' && _emberRuntimeMixinsComparable.default.detect(w) && w.constructor.compare) { - return w.constructor.compare(w, v) * -1; + if (position >= length) { + return null; } - } - var res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); + var value = _emberRuntime.objectAt(array, position); + var memo = position; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - if (res !== 0) { - return res; - } + this.position++; - // types are equal - so we have to check values now - switch (type1) { - case 'boolean': - case 'number': - return spaceship(v, w); + return { key: key, value: value, memo: memo }; + }; - case 'string': - return spaceship(v.localeCompare(w), 0); + return EmberArrayIterator; + })(); - case 'array': - var vLen = v.length; - var wLen = w.length; - var len = Math.min(vLen, wLen); - - for (var i = 0; i < len; i++) { - var r = compare(v[i], w[i]); - if (r !== 0) { - return r; - } - } + var ObjectKeysIterator = (function () { + function ObjectKeysIterator(keys, values, keyFor) { + babelHelpers.classCallCheck(this, ObjectKeysIterator); - // all elements are equal now - // shorter array should be ordered first - return spaceship(vLen, wLen); + this.keys = keys; + this.values = values; + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); + } - case 'instance': - if (_emberRuntimeMixinsComparable.default && _emberRuntimeMixinsComparable.default.detect(v)) { - return v.compare(v, w); - } - return 0; + ObjectKeysIterator.prototype.isEmpty = function isEmpty() { + return this.keys.length === 0; + }; - case 'date': - return spaceship(v.getTime(), w.getTime()); + ObjectKeysIterator.prototype.next = function next() { + var keys = this.keys; + var values = this.values; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; - default: - return 0; - } - } -}); -enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + if (position >= keys.length) { + return null; + } - exports.empty = empty; - exports.notEmpty = notEmpty; - exports.none = none; - exports.not = not; - exports.bool = bool; - exports.match = match; - exports.equal = equal; - exports.gt = gt; - exports.gte = gte; - exports.lt = lt; - exports.lte = lte; - exports.oneWay = oneWay; - exports.readOnly = readOnly; - exports.deprecatingAlias = deprecatingAlias; + var value = values[position]; + var memo = keys[position]; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - /** - @module ember - @submodule ember-metal - */ + this.position++; - function expandPropertiesToArray(predicateName, properties) { - var expandedProperties = []; + return { key: key, value: value, memo: memo }; + }; - function extractProperty(entry) { - expandedProperties.push(entry); + return ObjectKeysIterator; + })(); + + var EmptyIterator = (function () { + function EmptyIterator() { + babelHelpers.classCallCheck(this, EmptyIterator); } - for (var i = 0; i < properties.length; i++) { - var property = properties[i]; - _emberMetal.assert('Dependent keys passed to Ember.computed.' + predicateName + '() can\'t have spaces.', property.indexOf(' ') < 0); + EmptyIterator.prototype.isEmpty = function isEmpty() { + return true; + }; - _emberMetal.expandProperties(property, extractProperty); - } + EmptyIterator.prototype.next = function next() { + throw new Error('Cannot call next() on an empty iterator'); + }; - return expandedProperties; - } + return EmptyIterator; + })(); - function generateComputedWithPredicate(name, predicate) { - return function () { - for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) { - properties[_key] = arguments[_key]; - } + var EMPTY_ITERATOR = new EmptyIterator(); - var expandedProperties = expandPropertiesToArray(name, properties); + var EachInIterable = (function () { + function EachInIterable(ref, keyFor) { + babelHelpers.classCallCheck(this, EachInIterable); - var computedFunc = _emberMetal.computed(function () { - var lastIdx = expandedProperties.length - 1; + this.ref = ref; + this.keyFor = keyFor; - for (var i = 0; i < lastIdx; i++) { - var value = _emberMetal.get(this, expandedProperties[i]); - if (!predicate(value)) { - return value; - } - } + var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - return _emberMetal.get(this, expandedProperties[lastIdx]); - }); + this.tag = _glimmerReference.combine([ref.tag, valueTag]); + } - return computedFunc.property.apply(computedFunc, expandedProperties); - }; - } + EachInIterable.prototype.iterate = function iterate() { + var ref = this.ref; + var keyFor = this.keyFor; + var valueTag = this.valueTag; - /** - A computed property that returns true if the value of the dependent - property is null, an empty string, empty array, or empty function. - - Example - - ```javascript - let ToDoList = Ember.Object.extend({ - isDone: Ember.computed.empty('todos') - }); - - let todoList = ToDoList.create({ - todos: ['Unit Test', 'Documentation', 'Release'] - }); - - todoList.get('isDone'); // false - todoList.get('todos').clear(); - todoList.get('isDone'); // true - ``` - - @since 1.6.0 - @method empty - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which negate - the original value for property - @public - */ + var iterable = ref.value(); - function empty(dependentKey) { - return _emberMetal.computed(dependentKey + '.length', function () { - return _emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); - }); - } + valueTag.update(_emberMetal.tagFor(iterable)); - /** - A computed property that returns true if the value of the dependent - property is NOT null, an empty string, empty array, or empty function. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasStuff: Ember.computed.notEmpty('backpack') - }); - - let hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); - - hamster.get('hasStuff'); // true - hamster.get('backpack').clear(); // [] - hamster.get('hasStuff'); // false - ``` - - @method notEmpty - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which returns true if - original value for property is not empty. - @public - */ + if (_emberMetal.isProxy(iterable)) { + iterable = _emberMetal.get(iterable, 'content'); + } - function notEmpty(dependentKey) { - return _emberMetal.computed(dependentKey + '.length', function () { - return !_emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); - }); - } + var typeofIterable = typeof iterable; - /** - A computed property that returns true if the value of the dependent - property is null or undefined. This avoids errors from JSLint complaining - about use of ==, which can be technically confusing. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - isHungry: Ember.computed.none('food') - }); - - let hamster = Hamster.create(); - - hamster.get('isHungry'); // true - hamster.set('food', 'Banana'); - hamster.get('isHungry'); // false - hamster.set('food', null); - hamster.get('isHungry'); // true - ``` - - @method none - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which - returns true if original value for property is null or undefined. - @public - */ + if (iterable && (typeofIterable === 'object' || typeofIterable === 'function')) { + var keys = Object.keys(iterable); + var values = keys.map(function (key) { + return iterable[key]; + }); + return keys.length > 0 ? new ObjectKeysIterator(keys, values, keyFor) : EMPTY_ITERATOR; + } else { + return EMPTY_ITERATOR; + } + }; - function none(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.isNone(_emberMetal.get(this, dependentKey)); - }); - } + // {{each-in}} yields |key value| instead of |value key|, so the memo and + // value are flipped - /** - A computed property that returns the inverse boolean value - of the original value for the dependent property. - - Example - - ```javascript - let User = Ember.Object.extend({ - isAnonymous: Ember.computed.not('loggedIn') - }); - - let user = User.create({loggedIn: false}); - - user.get('isAnonymous'); // true - user.set('loggedIn', true); - user.get('isAnonymous'); // false - ``` - - @method not - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which returns - inverse of the original value for property - @public - */ + EachInIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); + }; - function not(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return !_emberMetal.get(this, dependentKey); - }); - } + EachInIterable.prototype.updateValueReference = function updateValueReference(reference, item) { + reference.update(item.memo); + }; - /** - A computed property that converts the provided dependent property - into a boolean value. - - ```javascript - let Hamster = Ember.Object.extend({ - hasBananas: Ember.computed.bool('numBananas') - }); - - let hamster = Hamster.create(); - - hamster.get('hasBananas'); // false - hamster.set('numBananas', 0); - hamster.get('hasBananas'); // false - hamster.set('numBananas', 1); - hamster.get('hasBananas'); // true - hamster.set('numBananas', null); - hamster.get('hasBananas'); // false - ``` - - @method bool - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which converts - to boolean the original value for property - @public - */ + EachInIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); + }; - function bool(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return !!_emberMetal.get(this, dependentKey); - }); - } + EachInIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { + reference.update(item.value); + }; - /** - A computed property which matches the original value for the - dependent property against a given RegExp, returning `true` - if the value matches the RegExp and `false` if it does not. - - Example - - ```javascript - let User = Ember.Object.extend({ - hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) - }); - - let user = User.create({loggedIn: false}); - - user.get('hasValidEmail'); // false - user.set('email', ''); - user.get('hasValidEmail'); // false - user.set('email', 'ember_hamster@example.com'); - user.get('hasValidEmail'); // true - ``` - - @method match - @for Ember.computed - @param {String} dependentKey - @param {RegExp} regexp - @return {Ember.ComputedProperty} computed property which match - the original value for property against a given RegExp - @public - */ + return EachInIterable; + })(); - function match(dependentKey, regexp) { - return _emberMetal.computed(dependentKey, function () { - var value = _emberMetal.get(this, dependentKey); + var ArrayIterable = (function () { + function ArrayIterable(ref, keyFor) { + babelHelpers.classCallCheck(this, ArrayIterable); - return typeof value === 'string' ? regexp.test(value) : false; - }); - } + this.ref = ref; + this.keyFor = keyFor; - /** - A computed property that returns true if the provided dependent property - is equal to the given value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - napTime: Ember.computed.equal('state', 'sleepy') - }); - - let hamster = Hamster.create(); - - hamster.get('napTime'); // false - hamster.set('state', 'sleepy'); - hamster.get('napTime'); // true - hamster.set('state', 'hungry'); - hamster.get('napTime'); // false - ``` - - @method equal - @for Ember.computed - @param {String} dependentKey - @param {String|Number|Object} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is equal to the given value. - @public - */ + var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - function equal(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) === value; - }); - } + this.tag = _glimmerReference.combine([ref.tag, valueTag]); + } - /** - A computed property that returns true if the provided dependent property - is greater than the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasTooManyBananas: Ember.computed.gt('numBananas', 10) - }); - - let hamster = Hamster.create(); - - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 3); - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 11); - hamster.get('hasTooManyBananas'); // true - ``` - - @method gt - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is greater than given value. - @public - */ + ArrayIterable.prototype.iterate = function iterate() { + var ref = this.ref; + var keyFor = this.keyFor; + var valueTag = this.valueTag; - function gt(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) > value; - }); - } + var iterable = ref.value(); - /** - A computed property that returns true if the provided dependent property - is greater than or equal to the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasTooManyBananas: Ember.computed.gte('numBananas', 10) - }); - - let hamster = Hamster.create(); - - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 3); - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 10); - hamster.get('hasTooManyBananas'); // true - ``` - - @method gte - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is greater or equal then given value. - @public - */ + valueTag.update(_emberMetal.tagForProperty(iterable, '[]')); - function gte(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) >= value; - }); - } + if (!iterable || typeof iterable !== 'object') { + return EMPTY_ITERATOR; + } - /** - A computed property that returns true if the provided dependent property - is less than the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - needsMoreBananas: Ember.computed.lt('numBananas', 3) - }); - - let hamster = Hamster.create(); - - hamster.get('needsMoreBananas'); // true - hamster.set('numBananas', 3); - hamster.get('needsMoreBananas'); // false - hamster.set('numBananas', 2); - hamster.get('needsMoreBananas'); // true - ``` - - @method lt - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is less then given value. - @public - */ + if (Array.isArray(iterable)) { + return iterable.length > 0 ? new ArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; + } else if (_emberRuntime.isEmberArray(iterable)) { + return _emberMetal.get(iterable, 'length') > 0 ? new EmberArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; + } else if (typeof iterable.forEach === 'function') { + var _ret = (function () { + var array = []; + iterable.forEach(function (item) { + array.push(item); + }); + return { + v: array.length > 0 ? new ArrayIterator(array, keyFor) : EMPTY_ITERATOR + }; + })(); - function lt(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) < value; - }); - } + if (typeof _ret === 'object') return _ret.v; + } else { + return EMPTY_ITERATOR; + } + }; - /** - A computed property that returns true if the provided dependent property - is less than or equal to the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - needsMoreBananas: Ember.computed.lte('numBananas', 3) - }); - - let hamster = Hamster.create(); - - hamster.get('needsMoreBananas'); // true - hamster.set('numBananas', 5); - hamster.get('needsMoreBananas'); // false - hamster.set('numBananas', 3); - hamster.get('needsMoreBananas'); // true - ``` - - @method lte - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is less or equal than given value. - @public - */ + ArrayIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); + }; - function lte(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) <= value; - }); - } + ArrayIterable.prototype.updateValueReference = function updateValueReference(reference, item) { + reference.update(item.value); + }; - /** - A computed property that performs a logical `and` on the - original values for the provided dependent properties. - - You may pass in more than two properties and even use - property brace expansion. The computed property will - return the first falsy value or last truthy value - just like JavaScript's `&&` operator. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), - readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') - }); - - let tomster = Hamster.create(); - - tomster.get('readyForCamp'); // false - tomster.set('hasTent', true); - tomster.get('readyForCamp'); // false - tomster.set('hasBackpack', true); - tomster.get('readyForCamp'); // true - tomster.set('hasBackpack', 'Yes'); - tomster.get('readyForCamp'); // 'Yes' - tomster.set('hasWalkingStick', null); - tomster.get('readyForHike'); // null - ``` - - @method and - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which performs - a logical `and` on the values of all the original values for properties. - @public - */ - var and = generateComputedWithPredicate('and', function (value) { - return value; - }); + ArrayIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); + }; - exports.and = and; - /** - A computed property which performs a logical `or` on the - original values for the provided dependent properties. - - You may pass in more than two properties and even use - property brace expansion. The computed property will - return the first truthy value or last falsy value just - like JavaScript's `||` operator. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'), - readyForBeach: Ember.computed.or('{hasSunscreen,hasUmbrella}') - }); - - let tomster = Hamster.create(); - - tomster.get('readyForRain'); // undefined - tomster.set('hasUmbrella', true); - tomster.get('readyForRain'); // true - tomster.set('hasJacket', 'Yes'); - tomster.get('readyForRain'); // 'Yes' - tomster.set('hasSunscreen', 'Check'); - tomster.get('readyForBeach'); // 'Check' - ``` - - @method or - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which performs - a logical `or` on the values of all the original values for properties. - @public - */ - var or = generateComputedWithPredicate('or', function (value) { - return !value; - }); + ArrayIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { + reference.update(item.memo); + }; - exports.or = or; - /** - Creates a new property that is an alias for another property - on an object. Calls to `get` or `set` this property behave as - though they were called on the original property. - - ```javascript - let Person = Ember.Object.extend({ - name: 'Alex Matchneer', - nomen: Ember.computed.alias('name') - }); - - let alex = Person.create(); - - alex.get('nomen'); // 'Alex Matchneer' - alex.get('name'); // 'Alex Matchneer' - - alex.set('nomen', '@machty'); - alex.get('name'); // '@machty' - ``` - - @method alias - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates an - alias to the original value for property. - @public - */ + return ArrayIterable; + })(); +}); +enifed('ember-glimmer/utils/process-args', ['exports', 'ember-utils', '@glimmer/reference', 'ember-glimmer/component', 'ember-glimmer/utils/references', 'ember-views', 'ember-glimmer/helpers/action', '@glimmer/runtime'], function (exports, _emberUtils, _glimmerReference, _emberGlimmerComponent, _emberGlimmerUtilsReferences, _emberViews, _emberGlimmerHelpersAction, _glimmerRuntime) { + 'use strict'; - /** - Where `computed.alias` aliases `get` and `set`, and allows for bidirectional - data flow, `computed.oneWay` only provides an aliased `get`. The `set` will - not mutate the upstream property, rather causes the current property to - become the value set. This causes the downstream property to permanently - diverge from the upstream property. - - Example - - ```javascript - let User = Ember.Object.extend({ - firstName: null, - lastName: null, - nickName: Ember.computed.oneWay('firstName') - }); - - let teddy = User.create({ - firstName: 'Teddy', - lastName: 'Zeenny' - }); - - teddy.get('nickName'); // 'Teddy' - teddy.set('nickName', 'TeddyBear'); // 'TeddyBear' - teddy.get('firstName'); // 'Teddy' - ``` - - @method oneWay - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @public - */ + exports.gatherArgs = gatherArgs; + + // Maps all variants of positional and dynamically scoped arguments + // into the named arguments. Input `args` and return value are both + // `EvaluatedArgs`. - function oneWay(dependentKey) { - return _emberMetal.alias(dependentKey).oneWay(); + function gatherArgs(args, definition) { + var namedMap = gatherNamedMap(args, definition); + var positionalValues = gatherPositionalValues(args, definition); + return mergeArgs(namedMap, positionalValues, args.blocks, definition.ComponentClass.class); } - /** - This is a more semantically meaningful alias of `computed.oneWay`, - whose name is somewhat ambiguous as to which direction the data flows. - - @method reads - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @public - */ - - /** - Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides - a readOnly one way binding. Very often when using `computed.oneWay` one does - not also want changes to propagate back up, as they will replace the value. - - This prevents the reverse flow, and also throws an exception when it occurs. - - Example - - ```javascript - let User = Ember.Object.extend({ - firstName: null, - lastName: null, - nickName: Ember.computed.readOnly('firstName') - }); - - let teddy = User.create({ - firstName: 'Teddy', - lastName: 'Zeenny' - }); - - teddy.get('nickName'); // 'Teddy' - teddy.set('nickName', 'TeddyBear'); // throws Exception - // throw new Ember.Error('Cannot Set: nickName on: ' );` - teddy.get('firstName'); // 'Teddy' - ``` - - @method readOnly - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @since 1.5.0 - @public - */ + function gatherNamedMap(args, definition) { + var namedMap = args.named.map; + if (definition.args) { + return _emberUtils.assign({}, definition.args.named.map, namedMap); + } else { + return namedMap; + } + } - function readOnly(dependentKey) { - return _emberMetal.alias(dependentKey).readOnly(); + function gatherPositionalValues(args, definition) { + var positionalValues = args.positional.values; + if (definition.args) { + var oldPositional = definition.args.positional.values; + var newPositional = []; + newPositional.push.apply(newPositional, oldPositional); + newPositional.splice.apply(newPositional, [0, positionalValues.length].concat(positionalValues)); + return newPositional; + } else { + return positionalValues; + } } - /** - Creates a new property that is an alias for another property - on an object. Calls to `get` or `set` this property behave as - though they were called on the original property, but also - print a deprecation warning. - - ```javascript - let Hamster = Ember.Object.extend({ - bananaCount: Ember.computed.deprecatingAlias('cavendishCount', { - id: 'hamster.deprecate-banana', - until: '3.0.0' - }) - }); - - let hamster = Hamster.create(); - - hamster.set('bananaCount', 5); // Prints a deprecation warning. - hamster.get('cavendishCount'); // 5 - ``` - - @method deprecatingAlias - @for Ember.computed - @param {String} dependentKey - @param {Object} options Options for `Ember.deprecate`. - @return {Ember.ComputedProperty} computed property which creates an - alias with a deprecation to the original value for property. - @since 1.7.0 - @public - */ + function mergeArgs(namedMap, positionalValues, blocks, componentClass) { + var positionalParamsDefinition = componentClass.positionalParams; - function deprecatingAlias(dependentKey, options) { - return _emberMetal.computed(dependentKey, { - get: function (key) { - _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); - return _emberMetal.get(this, dependentKey); - }, - set: function (key, value) { - _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); - _emberMetal.set(this, dependentKey, value); - return value; + if (positionalParamsDefinition && positionalParamsDefinition.length > 0 && positionalValues.length > 0) { + if (typeof positionalParamsDefinition === 'string') { + namedMap = mergeRestArg(namedMap, positionalValues, positionalParamsDefinition); + } else { + namedMap = mergePositionalParams(namedMap, positionalValues, positionalParamsDefinition); } - }); + } + return _glimmerRuntime.EvaluatedArgs.named(namedMap, blocks); } -}); -enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) { - /** - @module ember - @submodule ember-runtime - */ - 'use strict'; - - exports.sum = sum; - exports.max = max; - exports.min = min; - exports.map = map; - exports.mapBy = mapBy; - exports.filter = filter; - exports.filterBy = filterBy; - exports.uniq = uniq; - exports.uniqBy = uniqBy; - exports.intersect = intersect; - exports.setDiff = setDiff; - exports.collect = collect; - exports.sort = sort; + var EMPTY_ARGS = { + tag: _glimmerReference.CONSTANT_TAG, + value: function () { + var _props; - function reduceMacro(dependentKey, callback, initialValue) { - return _emberMetal.computed(dependentKey + '.[]', function () { - var _this = this; + return { attrs: {}, props: (_props = { attrs: {} }, _props[_emberGlimmerComponent.ARGS] = {}, _props) }; + } + }; - var arr = _emberMetal.get(this, dependentKey); + // ComponentArgs takes EvaluatedNamedArgs and converts them into the + // inputs needed by CurlyComponents (attrs and props, with mutable + // cells, etc). - if (arr === null || typeof arr !== 'object') { - return initialValue; + var ComponentArgs = (function () { + ComponentArgs.create = function create(args) { + if (args.named.keys.length === 0) { + return EMPTY_ARGS; + } else { + return new ComponentArgs(args.named); } + }; - return arr.reduce(function (previousValue, currentValue, index, array) { - return callback.call(_this, previousValue, currentValue, index, array); - }, initialValue); - }).readOnly(); - } + function ComponentArgs(namedArgs) { + babelHelpers.classCallCheck(this, ComponentArgs); - function arrayMacro(dependentKey, callback) { - // This is a bit ugly - var propertyName = undefined; - if (/@each/.test(dependentKey)) { - propertyName = dependentKey.replace(/\.@each.*$/, ''); - } else { - propertyName = dependentKey; - dependentKey += '.[]'; + this.tag = namedArgs.tag; + this.namedArgs = namedArgs; } - return _emberMetal.computed(dependentKey, function () { - var value = _emberMetal.get(this, propertyName); - if (_emberRuntimeUtils.isArray(value)) { - return _emberRuntimeSystemNative_array.A(callback.call(this, value)); - } else { - return _emberRuntimeSystemNative_array.A(); + ComponentArgs.prototype.value = function value() { + var namedArgs = this.namedArgs; + + var keys = namedArgs.keys; + var attrs = namedArgs.value(); + var props = new _emberUtils.EmptyObject(); + var args = new _emberUtils.EmptyObject(); + + props[_emberGlimmerComponent.ARGS] = args; + + for (var i = 0, l = keys.length; i < l; i++) { + var _name = keys[i]; + var ref = namedArgs.get(_name); + var value = attrs[_name]; + + if (typeof value === 'function' && value[_emberGlimmerHelpersAction.ACTION]) { + attrs[_name] = value; + } else if (ref[_emberGlimmerUtilsReferences.UPDATE]) { + attrs[_name] = new MutableCell(ref, value); + } + + args[_name] = ref; + props[_name] = value; } - }).readOnly(); - } - function multiArrayMacro(dependentKeys, callback) { - var args = dependentKeys.map(function (key) { - return key + '.[]'; - }); + props.attrs = attrs; - args.push(function () { - return _emberRuntimeSystemNative_array.A(callback.call(this, dependentKeys)); - }); + return { attrs: attrs, props: props }; + }; - return _emberMetal.computed.apply(this, args).readOnly(); - } + return ComponentArgs; + })(); - /** - A computed property that returns the sum of the values - in the dependent array. - - @method sum - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the sum of all values in the dependentKey's array - @since 1.4.0 - @public - */ + exports.ComponentArgs = ComponentArgs; - function sum(dependentKey) { - return reduceMacro(dependentKey, function (sum, item) { - return sum + item; - }, 0); + function mergeRestArg(namedMap, positionalValues, restArgName) { + var mergedNamed = _emberUtils.assign({}, namedMap); + mergedNamed[restArgName] = _glimmerRuntime.EvaluatedPositionalArgs.create(positionalValues); + return mergedNamed; } - /** - A computed property that calculates the maximum value in the - dependent array. This will return `-Infinity` when the dependent - array is empty. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age'), - maxChildAge: Ember.computed.max('childAges') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('maxChildAge'); // -Infinity - lordByron.get('children').pushObject({ - name: 'Augusta Ada Byron', age: 7 - }); - lordByron.get('maxChildAge'); // 7 - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('maxChildAge'); // 8 - ``` - - If the types of the arguments are not numbers, - they will be converted to numbers and the type - of the return value will always be `Number`. - For example, the max of a list of Date objects will be - the highest timestamp as a `Number`. - This behavior is consistent with `Math.max`. - - @method max - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array - @public - */ - - function max(dependentKey) { - return reduceMacro(dependentKey, function (max, item) { - return Math.max(max, item); - }, -Infinity); + function mergePositionalParams(namedMap, values, positionalParamNames) { + var mergedNamed = _emberUtils.assign({}, namedMap); + var length = Math.min(values.length, positionalParamNames.length); + for (var i = 0; i < length; i++) { + var _name2 = positionalParamNames[i]; + mergedNamed[_name2] = values[i]; + } + return mergedNamed; } - /** - A computed property that calculates the minimum value in the - dependent array. This will return `Infinity` when the dependent - array is empty. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age'), - minChildAge: Ember.computed.min('childAges') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('minChildAge'); // Infinity - lordByron.get('children').pushObject({ - name: 'Augusta Ada Byron', age: 7 - }); - lordByron.get('minChildAge'); // 7 - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('minChildAge'); // 5 - ``` - - If the types of the arguments are not numbers, - they will be converted to numbers and the type - of the return value will always be `Number`. - For example, the min of a list of Date objects will be - the lowest timestamp as a `Number`. - This behavior is consistent with `Math.min`. - - @method min - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array - @public - */ + var REF = _emberUtils.symbol('REF'); - function min(dependentKey) { - return reduceMacro(dependentKey, function (min, item) { - return Math.min(min, item); - }, Infinity); - } + var MutableCell = (function () { + function MutableCell(ref, value) { + babelHelpers.classCallCheck(this, MutableCell); - /** - Returns an array mapped via the callback - - The callback method you provide should have the following signature. - `item` is the current item in the iteration. - `index` is the integer index of the current item in the iteration. - - ```javascript - function(item, index); - ``` - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - excitingChores: Ember.computed.map('chores', function(chore, index) { - return chore.toUpperCase() + '!'; - }) - }); - - let hamster = Hamster.create({ - chores: ['clean', 'write more unit tests'] - }); - - hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] - ``` - - @method map - @for Ember.computed - @param {String} dependentKey - @param {Function} callback - @return {Ember.ComputedProperty} an array mapped via the callback - @public - */ + this[_emberViews.MUTABLE_CELL] = true; + this[REF] = ref; + this.value = value; + } - function map(dependentKey, callback) { - return arrayMacro(dependentKey, function (value) { - return value.map(callback, this); - }); - } + MutableCell.prototype.update = function update(val) { + this[REF][_emberGlimmerUtilsReferences.UPDATE](val); + }; - /** - Returns an array mapped to the specified key. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('childAges'); // [] - lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); - lordByron.get('childAges'); // [7] - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('childAges'); // [7, 5, 8] - ``` - - @method mapBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @return {Ember.ComputedProperty} an array mapped to the specified key - @public - */ + return MutableCell; + })(); +}); +enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal', '@glimmer/reference', '@glimmer/runtime', 'ember-glimmer/utils/to-bool', 'ember-glimmer/helper'], function (exports, _emberUtils, _emberMetal, _glimmerReference, _glimmerRuntime, _emberGlimmerUtilsToBool, _emberGlimmerHelper) { + 'use strict'; + + var UPDATE = _emberUtils.symbol('UPDATE'); + + exports.UPDATE = UPDATE; + exports.NULL_REFERENCE = _glimmerRuntime.NULL_REFERENCE; + exports.UNDEFINED_REFERENCE = _glimmerRuntime.UNDEFINED_REFERENCE; + + // @abstract + // @implements PathReference + + var EmberPathReference = (function () { + function EmberPathReference() { + babelHelpers.classCallCheck(this, EmberPathReference); + } + + // @abstract + + // @abstract get tag() + // @abstract value() + + EmberPathReference.prototype.get = function get(key) { + return PropertyReference.create(this, key); + }; + + return EmberPathReference; + })(); + + var CachedReference = (function (_EmberPathReference) { + babelHelpers.inherits(CachedReference, _EmberPathReference); + + function CachedReference() { + babelHelpers.classCallCheck(this, CachedReference); + + _EmberPathReference.call(this); + this._lastRevision = null; + this._lastValue = null; + } + + // @implements PathReference + + CachedReference.prototype.value = function value() { + var tag = this.tag; + var _lastRevision = this._lastRevision; + var _lastValue = this._lastValue; + + if (!_lastRevision || !tag.validate(_lastRevision)) { + _lastValue = this._lastValue = this.compute(); + this._lastRevision = tag.value(); + } + + return _lastValue; + }; + + // @abstract compute() + return CachedReference; + })(EmberPathReference); + + exports.CachedReference = CachedReference; + + var RootReference = (function (_ConstReference) { + babelHelpers.inherits(RootReference, _ConstReference); + + function RootReference(value) { + babelHelpers.classCallCheck(this, RootReference); + + _ConstReference.call(this, value); + this.children = new _emberUtils.EmptyObject(); + } + + RootReference.prototype.get = function get(propertyKey) { + var ref = this.children[propertyKey]; + + if (!ref) { + ref = this.children[propertyKey] = new RootPropertyReference(this.inner, propertyKey); + } + + return ref; + }; + + return RootReference; + })(_glimmerReference.ConstReference); - function mapBy(dependentKey, propertyKey) { - _emberMetal.assert('Ember.computed.mapBy expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string'); + exports.RootReference = RootReference; - return map(dependentKey + '.@each.' + propertyKey, function (item) { - return _emberMetal.get(item, propertyKey); - }); - } + var TwoWayFlushDetectionTag = undefined; - /** - Filters the array by the callback. - - The callback method you provide should have the following signature. - `item` is the current item in the iteration. - `index` is the integer index of the current item in the iteration. - `array` is the dependant array itself. - - ```javascript - function(item, index, array); - ``` - - ```javascript - let Hamster = Ember.Object.extend({ - remainingChores: Ember.computed.filter('chores', function(chore, index, array) { - return !chore.done; - }) - }); - - let hamster = Hamster.create({ - chores: [ - { name: 'cook', done: true }, - { name: 'clean', done: true }, - { name: 'write more unit tests', done: false } - ] - }); - - hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] - ``` - - @method filter - @for Ember.computed - @param {String} dependentKey - @param {Function} callback - @return {Ember.ComputedProperty} the filtered array - @public - */ + if (true || false) { + TwoWayFlushDetectionTag = (function () { + function _class(tag, key, ref) { + babelHelpers.classCallCheck(this, _class); - function filter(dependentKey, callback) { - return arrayMacro(dependentKey, function (value) { - return value.filter(callback, this); - }); - } + this.tag = tag; + this.parent = null; + this.key = key; + this.ref = ref; + } - /** - Filters the array by the property and value - - ```javascript - let Hamster = Ember.Object.extend({ - remainingChores: Ember.computed.filterBy('chores', 'done', false) - }); - - let hamster = Hamster.create({ - chores: [ - { name: 'cook', done: true }, - { name: 'clean', done: true }, - { name: 'write more unit tests', done: false } - ] - }); - - hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] - ``` - - @method filterBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @param {*} value - @return {Ember.ComputedProperty} the filtered array - @public - */ + _class.prototype.value = function value() { + return this.tag.value(); + }; - function filterBy(dependentKey, propertyKey, value) { - var callback = undefined; + _class.prototype.validate = function validate(ticket) { + var parent = this.parent; + var key = this.key; - if (arguments.length === 2) { - callback = function (item) { - return _emberMetal.get(item, propertyKey); + var isValid = this.tag.validate(ticket); + + if (isValid && parent) { + _emberMetal.didRender(parent, key, this.ref); + } + + return isValid; }; - } else { - callback = function (item) { - return _emberMetal.get(item, propertyKey) === value; + + _class.prototype.didCompute = function didCompute(parent) { + this.parent = parent; + _emberMetal.didRender(parent, this.key, this.ref); }; - } - return filter(dependentKey + '.@each.' + propertyKey, callback); + return _class; + })(); } - /** - A computed property which returns a new array with all the unique - elements from one or more dependent arrays. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - uniqueFruits: Ember.computed.uniq('fruits') - }); - - let hamster = Hamster.create({ - fruits: [ - 'banana', - 'grape', - 'kale', - 'banana' - ] - }); - - hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale'] - ``` - - @method uniq - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ + var PropertyReference = (function (_CachedReference) { + babelHelpers.inherits(PropertyReference, _CachedReference); - function uniq() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + function PropertyReference() { + babelHelpers.classCallCheck(this, PropertyReference); + + _CachedReference.apply(this, arguments); } - return multiArrayMacro(args, function (dependentKeys) { - var _this2 = this; + PropertyReference.create = function create(parentReference, propertyKey) { + if (_glimmerReference.isConst(parentReference)) { + return new RootPropertyReference(parentReference.value(), propertyKey); + } else { + return new NestedPropertyReference(parentReference, propertyKey); + } + }; - var uniq = _emberRuntimeSystemNative_array.A(); + PropertyReference.prototype.get = function get(key) { + return new NestedPropertyReference(this, key); + }; - dependentKeys.forEach(function (dependentKey) { - var value = _emberMetal.get(_this2, dependentKey); - if (_emberRuntimeUtils.isArray(value)) { - value.forEach(function (item) { - if (uniq.indexOf(item) === -1) { - uniq.push(item); - } - }); - } - }); + return PropertyReference; + })(CachedReference); - return uniq; - }); - } + exports.PropertyReference = PropertyReference; - /** - A computed property which returns a new array with all the unique - elements from an array, with uniqueness determined by specific key. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - uniqueFruits: Ember.computed.uniqBy('fruits', 'id') - }); - let hamster = Hamster.create({ - fruits: [ - { id: 1, 'banana' }, - { id: 2, 'grape' }, - { id: 3, 'peach' }, - { id: 1, 'banana' } - ] - }); - hamster.get('uniqueFruits'); // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }] - ``` - - @method uniqBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ + var RootPropertyReference = (function (_PropertyReference) { + babelHelpers.inherits(RootPropertyReference, _PropertyReference); - function uniqBy(dependentKey, propertyKey) { - return _emberMetal.computed(dependentKey + '.[]', function () { - var uniq = _emberRuntimeSystemNative_array.A(); - var seen = new _emberUtils.EmptyObject(); - var list = _emberMetal.get(this, dependentKey); - if (_emberRuntimeUtils.isArray(list)) { - list.forEach(function (item) { - var guid = _emberUtils.guidFor(_emberMetal.get(item, propertyKey)); - if (!(guid in seen)) { - seen[guid] = true; - uniq.push(item); - } - }); - } - return uniq; - }).readOnly(); - } + function RootPropertyReference(parentValue, propertyKey) { + babelHelpers.classCallCheck(this, RootPropertyReference); - /** - Alias for [Ember.computed.uniq](/api/#method_computed_uniq). - - @method union - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ - var union = uniq; + _PropertyReference.call(this); - exports.union = union; - /** - A computed property which returns a new array with all the duplicated - elements from two or more dependent arrays. - - Example - - ```javascript - let obj = Ember.Object.extend({ - friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') - }).create({ - adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], - charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'] - }); - - obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] - ``` - - @method intersect - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - duplicated elements from the dependent arrays - @public - */ + this._parentValue = parentValue; + this._propertyKey = propertyKey; - function intersect() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + if (true || false) { + this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); + } else { + this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); + } + + if (true) { + _emberMetal.watchKey(parentValue, propertyKey); + } } - return multiArrayMacro(args, function (dependentKeys) { - var _this3 = this; + RootPropertyReference.prototype.compute = function compute() { + var _parentValue = this._parentValue; + var _propertyKey = this._propertyKey; - var arrays = dependentKeys.map(function (dependentKey) { - var array = _emberMetal.get(_this3, dependentKey); + if (true || false) { + this.tag.didCompute(_parentValue); + } - return _emberRuntimeUtils.isArray(array) ? array : []; - }); + return _emberMetal.get(_parentValue, _propertyKey); + }; - var results = arrays.pop().filter(function (candidate) { - for (var i = 0; i < arrays.length; i++) { - var found = false; - var array = arrays[i]; - for (var j = 0; j < array.length; j++) { - if (array[j] === candidate) { - found = true; - break; - } - } + RootPropertyReference.prototype[UPDATE] = function (value) { + _emberMetal.set(this._parentValue, this._propertyKey, value); + }; - if (found === false) { - return false; - } - } + return RootPropertyReference; + })(PropertyReference); - return true; - }); + exports.RootPropertyReference = RootPropertyReference; - return _emberRuntimeSystemNative_array.A(results); - }); - } + var NestedPropertyReference = (function (_PropertyReference2) { + babelHelpers.inherits(NestedPropertyReference, _PropertyReference2); - /** - A computed property which returns a new array with all the - properties from the first dependent array that are not in the second - dependent array. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - likes: ['banana', 'grape', 'kale'], - wants: Ember.computed.setDiff('likes', 'fruits') - }); - - let hamster = Hamster.create({ - fruits: [ - 'grape', - 'kale', - ] - }); - - hamster.get('wants'); // ['banana'] - ``` - - @method setDiff - @for Ember.computed - @param {String} setAProperty - @param {String} setBProperty - @return {Ember.ComputedProperty} computes a new array with all the - items from the first dependent array that are not in the second - dependent array - @public - */ + function NestedPropertyReference(parentReference, propertyKey) { + babelHelpers.classCallCheck(this, NestedPropertyReference); - function setDiff(setAProperty, setBProperty) { - if (arguments.length !== 2) { - throw new _emberMetal.Error('setDiff requires exactly two dependent arrays.'); - } + _PropertyReference2.call(this); - return _emberMetal.computed(setAProperty + '.[]', setBProperty + '.[]', function () { - var setA = this.get(setAProperty); - var setB = this.get(setBProperty); + var parentReferenceTag = parentReference.tag; + var parentObjectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - if (!_emberRuntimeUtils.isArray(setA)) { - return _emberRuntimeSystemNative_array.A(); - } - if (!_emberRuntimeUtils.isArray(setB)) { - return _emberRuntimeSystemNative_array.A(setA); + this._parentReference = parentReference; + this._parentObjectTag = parentObjectTag; + this._propertyKey = propertyKey; + + if (true || false) { + var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); + this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); + } else { + this.tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); } + } - return setA.filter(function (x) { - return setB.indexOf(x) === -1; - }); - }).readOnly(); - } + NestedPropertyReference.prototype.compute = function compute() { + var _parentReference = this._parentReference; + var _parentObjectTag = this._parentObjectTag; + var _propertyKey = this._propertyKey; - /** - A computed property that returns the array of values - for the provided dependent properties. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - clothes: Ember.computed.collect('hat', 'shirt') - }); - - let hamster = Hamster.create(); - - hamster.get('clothes'); // [null, null] - hamster.set('hat', 'Camp Hat'); - hamster.set('shirt', 'Camp Shirt'); - hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] - ``` - - @method collect - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which maps - values of all passed in properties to an array. - @public - */ + var parentValue = _parentReference.value(); - function collect() { - for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - dependentKeys[_key3] = arguments[_key3]; - } + _parentObjectTag.update(_emberMetal.tagForProperty(parentValue, _propertyKey)); - return multiArrayMacro(dependentKeys, function () { - var properties = _emberMetal.getProperties(this, dependentKeys); - var res = _emberRuntimeSystemNative_array.A(); - for (var key in properties) { - if (properties.hasOwnProperty(key)) { - if (_emberMetal.isNone(properties[key])) { - res.push(null); - } else { - res.push(properties[key]); - } - } + if (typeof parentValue === 'string' && _propertyKey === 'length') { + return parentValue.length; } - return res; - }); - } - /** - A computed property which returns a new array with all the - properties from the first dependent array sorted based on a property - or sort function. - - The callback method you provide should have the following signature: - - ```javascript - function(itemA, itemB); - ``` - - - `itemA` the first item to compare. - - `itemB` the second item to compare. - - This function should return negative number (e.g. `-1`) when `itemA` should come before - `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after - `itemB`. If the `itemA` and `itemB` are equal this function should return `0`. - - Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or - `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`. - - Example - - ```javascript - let ToDoList = Ember.Object.extend({ - // using standard ascending sort - todosSorting: ['name'], - sortedTodos: Ember.computed.sort('todos', 'todosSorting'), - - // using descending sort - todosSortingDesc: ['name:desc'], - sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), - - // using a custom sort function - priorityTodos: Ember.computed.sort('todos', function(a, b){ - if (a.priority > b.priority) { - return 1; - } else if (a.priority < b.priority) { - return -1; + if (typeof parentValue === 'object' && parentValue) { + if (true) { + _emberMetal.watchKey(parentValue, _propertyKey); + } + + if (true || false) { + this.tag.didCompute(parentValue); } - - return 0; - }) - }); - - let todoList = ToDoList.create({todos: [ - { name: 'Unit Test', priority: 2 }, - { name: 'Documentation', priority: 3 }, - { name: 'Release', priority: 1 } - ]}); - - todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }] - todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }] - todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }] - ``` - - @method sort - @for Ember.computed - @param {String} itemsKey - @param {String or Function} sortDefinition a dependent key to an - array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting - @return {Ember.ComputedProperty} computes a new sorted array based - on the sort property array or callback function - @public - */ - function sort(itemsKey, sortDefinition) { - _emberMetal.assert('Ember.computed.sort requires two arguments: an array key to sort and ' + 'either a sort properties key or sort function', arguments.length === 2); + return _emberMetal.get(parentValue, _propertyKey); + } else { + return undefined; + } + }; - if (typeof sortDefinition === 'function') { - return customSort(itemsKey, sortDefinition); - } else { - return propertySort(itemsKey, sortDefinition); - } - } + NestedPropertyReference.prototype[UPDATE] = function (value) { + var parent = this._parentReference.value(); + _emberMetal.set(parent, this._propertyKey, value); + }; - function customSort(itemsKey, comparator) { - return arrayMacro(itemsKey, function (value) { - var _this4 = this; + return NestedPropertyReference; + })(PropertyReference); - return value.slice().sort(function (x, y) { - return comparator.call(_this4, x, y); - }); - }); - } + exports.NestedPropertyReference = NestedPropertyReference; - // This one needs to dynamically set up and tear down observers on the itemsKey - // depending on the sortProperties - function propertySort(itemsKey, sortPropertiesKey) { - var cp = new _emberMetal.ComputedProperty(function (key) { - var _this5 = this; + var UpdatableReference = (function (_EmberPathReference2) { + babelHelpers.inherits(UpdatableReference, _EmberPathReference2); - var itemsKeyIsAtThis = itemsKey === '@this'; - var sortProperties = _emberMetal.get(this, sortPropertiesKey); + function UpdatableReference(value) { + babelHelpers.classCallCheck(this, UpdatableReference); - _emberMetal.assert('The sort definition for \'' + key + '\' on ' + this + ' must be a function or an array of strings', _emberRuntimeUtils.isArray(sortProperties) && sortProperties.every(function (s) { - return typeof s === 'string'; - })); + _EmberPathReference2.call(this); - var normalizedSortProperties = normalizeSortProperties(sortProperties); + this.tag = new _glimmerReference.DirtyableTag(); + this._value = value; + } - // Add/remove property observers as required. - var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetal.WeakMap()); - var activeObservers = activeObserversMap.get(this); + UpdatableReference.prototype.value = function value() { + return this._value; + }; - if (activeObservers) { - activeObservers.forEach(function (args) { - return _emberMetal.removeObserver.apply(null, args); - }); + UpdatableReference.prototype.update = function update(value) { + var _value = this._value; + + if (value !== _value) { + this.tag.dirty(); + this._value = value; } + }; - function sortPropertyDidChange() { - this.notifyPropertyChange(key); + return UpdatableReference; + })(EmberPathReference); + + exports.UpdatableReference = UpdatableReference; + + var UpdatablePrimitiveReference = (function (_UpdatableReference) { + babelHelpers.inherits(UpdatablePrimitiveReference, _UpdatableReference); + + function UpdatablePrimitiveReference() { + babelHelpers.classCallCheck(this, UpdatablePrimitiveReference); + + _UpdatableReference.apply(this, arguments); + } + + UpdatablePrimitiveReference.prototype.get = function get() { + return _glimmerRuntime.UNDEFINED_REFERENCE; + }; + + return UpdatablePrimitiveReference; + })(UpdatableReference); + + exports.UpdatablePrimitiveReference = UpdatablePrimitiveReference; + + var ConditionalReference = (function (_GlimmerConditionalReference) { + babelHelpers.inherits(ConditionalReference, _GlimmerConditionalReference); + + ConditionalReference.create = function create(reference) { + if (_glimmerReference.isConst(reference)) { + var value = reference.value(); + + if (_emberMetal.isProxy(value)) { + return new RootPropertyReference(value, 'isTruthy'); + } else { + return _glimmerRuntime.PrimitiveReference.create(_emberGlimmerUtilsToBool.default(value)); + } } - activeObservers = normalizedSortProperties.map(function (_ref) { - var prop = _ref[0]; + return new ConditionalReference(reference); + }; - var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; - var args = [_this5, path, sortPropertyDidChange]; - _emberMetal.addObserver.apply(null, args); - return args; - }); + function ConditionalReference(reference) { + babelHelpers.classCallCheck(this, ConditionalReference); - activeObserversMap.set(this, activeObservers); + _GlimmerConditionalReference.call(this, reference); - // Sort and return the array. - var items = itemsKeyIsAtThis ? this : _emberMetal.get(this, itemsKey); + this.objectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + this.tag = _glimmerReference.combine([reference.tag, this.objectTag]); + } - if (_emberRuntimeUtils.isArray(items)) { - return sortByNormalizedSortProperties(items, normalizedSortProperties); + ConditionalReference.prototype.toBool = function toBool(predicate) { + if (_emberMetal.isProxy(predicate)) { + this.objectTag.update(_emberMetal.tagForProperty(predicate, 'isTruthy')); + return _emberMetal.get(predicate, 'isTruthy'); } else { - return _emberRuntimeSystemNative_array.A(); + this.objectTag.update(_emberMetal.tagFor(predicate)); + return _emberGlimmerUtilsToBool.default(predicate); } - }); + }; - cp._activeObserverMap = undefined; + return ConditionalReference; + })(_glimmerRuntime.ConditionalReference); - return cp.property(sortPropertiesKey + '.[]').readOnly(); - } + exports.ConditionalReference = ConditionalReference; - function normalizeSortProperties(sortProperties) { - return sortProperties.map(function (p) { - var _p$split = p.split(':'); + var SimpleHelperReference = (function (_CachedReference2) { + babelHelpers.inherits(SimpleHelperReference, _CachedReference2); - var prop = _p$split[0]; - var direction = _p$split[1]; + SimpleHelperReference.create = function create(helper, args) { + if (_glimmerReference.isConst(args)) { + var _ret = (function () { + var positional = args.positional; + var named = args.named; - direction = direction || 'asc'; + var positionalValue = positional.value(); + var namedValue = named.value(); - return [prop, direction]; - }); - } + _emberMetal.runInDebug(function () { + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + Object.freeze(positionalValue); + Object.freeze(namedValue); + } + }); - 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 = helper(positionalValue, namedValue); - var result = _emberRuntimeCompare.default(_emberMetal.get(itemA, prop), _emberMetal.get(itemB, prop)); - if (result !== 0) { - return direction === 'desc' ? -1 * result : result; - } + if (result === null) { + return { + v: _glimmerRuntime.NULL_REFERENCE + }; + } else if (result === undefined) { + return { + v: _glimmerRuntime.UNDEFINED_REFERENCE + }; + } else if (typeof result === 'object') { + return { + v: new RootReference(result) + }; + } else { + return { + v: _glimmerRuntime.PrimitiveReference.create(result) + }; + } + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return new SimpleHelperReference(helper, args); } + }; - return 0; - })); - } -}); -enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) { - 'use strict'; + function SimpleHelperReference(helper, args) { + babelHelpers.classCallCheck(this, SimpleHelperReference); - /** - @module ember - @submodule ember-runtime - */ + _CachedReference2.call(this); - /** - @class Controller - @namespace Ember - @extends Ember.Object - @uses Ember.ControllerMixin - @public - */ - var Controller = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsController.default); + this.tag = args.tag; + this.helper = helper; + this.args = args; + } - _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions(Controller); + SimpleHelperReference.prototype.compute = function compute() { + var helper = this.helper; + var _args = this.args; + var positional = _args.positional; + var named = _args.named; - function controllerInjectionHelper(factory) { - _emberMetal.assert('Defining an injected controller property on a ' + 'non-controller is not allowed.', _emberRuntimeMixinsController.default.detect(factory.PrototypeMixin)); - } + var positionalValue = positional.value(); + var namedValue = named.value(); - /** - Creates a property that lazily looks up another controller in the container. - Can only be used when defining another controller. - - Example: - - ```javascript - App.PostController = Ember.Controller.extend({ - posts: Ember.inject.controller() - }); - ``` - - This example will create a `posts` property on the `post` controller that - looks up the `posts` controller in the container, making it easy to - reference other controllers. This is functionally equivalent to: - - ```javascript - App.PostController = Ember.Controller.extend({ - needs: 'posts', - posts: Ember.computed.alias('controllers.posts') - }); - ``` - - @method controller - @since 1.10.0 - @for Ember.inject - @param {String} name (optional) name of the controller to inject, defaults - to the property's name - @return {Ember.InjectedProperty} injection descriptor instance - @public - */ - _emberRuntimeInject.createInjectionHelper('controller', controllerInjectionHelper); + _emberMetal.runInDebug(function () { + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + Object.freeze(positionalValue); + Object.freeze(namedValue); + } + }); - exports.default = Controller; -}); -enifed('ember-runtime/copy', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) { - 'use strict'; + return helper(positionalValue, namedValue); + }; - exports.default = copy; + return SimpleHelperReference; + })(CachedReference); - function _copy(obj, deep, seen, copies) { - var ret = undefined, - loc = undefined, - key = undefined; + exports.SimpleHelperReference = SimpleHelperReference; - // primitive data types are immutable, just return them. - if (typeof obj !== 'object' || obj === null) { - return obj; - } + var ClassBasedHelperReference = (function (_CachedReference3) { + babelHelpers.inherits(ClassBasedHelperReference, _CachedReference3); - // avoid cyclical loops - if (deep && (loc = seen.indexOf(obj)) >= 0) { - return copies[loc]; - } + ClassBasedHelperReference.create = function create(helperClass, vm, args) { + var instance = helperClass.create(); + vm.newDestroyable(instance); + return new ClassBasedHelperReference(instance, args); + }; - _emberMetal.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof _emberRuntimeSystemObject.default) || _emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)); + function ClassBasedHelperReference(instance, args) { + babelHelpers.classCallCheck(this, ClassBasedHelperReference); - // IMPORTANT: this specific test will detect a native array only. Any other - // object will need to implement Copyable. - if (Array.isArray(obj)) { - ret = obj.slice(); + _CachedReference3.call(this); - if (deep) { - loc = ret.length; + this.tag = _glimmerReference.combine([instance[_emberGlimmerHelper.RECOMPUTE_TAG], args.tag]); + this.instance = instance; + this.args = args; + } - while (--loc >= 0) { - ret[loc] = _copy(ret[loc], deep, seen, copies); - } - } - } else if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { - ret = obj.copy(deep, seen, copies); - } else if (obj instanceof Date) { - ret = new Date(obj.getTime()); - } else { - ret = {}; + ClassBasedHelperReference.prototype.compute = function compute() { + var instance = this.instance; + var _args2 = this.args; + var positional = _args2.positional; + var named = _args2.named; - for (key in obj) { - // support Null prototype - if (!Object.prototype.hasOwnProperty.call(obj, key)) { - continue; - } + var positionalValue = positional.value(); + var namedValue = named.value(); - // Prevents browsers that don't respect non-enumerability from - // copying internal Ember properties - if (key.substring(0, 2) === '__') { - continue; + _emberMetal.runInDebug(function () { + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + Object.freeze(positionalValue); + Object.freeze(namedValue); } + }); - ret[key] = deep ? _copy(obj[key], deep, seen, copies) : obj[key]; - } - } + return instance.compute(positionalValue, namedValue); + }; - if (deep) { - seen.push(obj); - copies.push(ret); - } + return ClassBasedHelperReference; + })(CachedReference); - return ret; - } + exports.ClassBasedHelperReference = ClassBasedHelperReference; - /** - Creates a shallow copy of the passed object. A deep copy of the object is - returned if the optional `deep` argument is `true`. - - If the passed object implements the `Ember.Copyable` interface, then this - function will delegate to the object's `copy()` method and return the - result. See `Ember.Copyable` for further details. - - For primitive values (which are immutable in JavaScript), the passed object - is simply returned. - - @method copy - @for Ember - @param {Object} obj The object to clone - @param {Boolean} [deep=false] If true, a deep copy of the object is made. - @return {Object} The copied object - @public - */ + var InternalHelperReference = (function (_CachedReference4) { + babelHelpers.inherits(InternalHelperReference, _CachedReference4); - function copy(obj, deep) { - // fast paths - if ('object' !== typeof obj || obj === null) { - return obj; // can't copy primitives + function InternalHelperReference(helper, args) { + babelHelpers.classCallCheck(this, InternalHelperReference); + + _CachedReference4.call(this); + + this.tag = args.tag; + this.helper = helper; + this.args = args; } - if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { - return obj.copy(deep); + // @implements PathReference + + InternalHelperReference.prototype.compute = function compute() { + var helper = this.helper; + var args = this.args; + + return helper(args); + }; + + return InternalHelperReference; + })(CachedReference); + + exports.InternalHelperReference = InternalHelperReference; + + var UnboundReference = (function (_ConstReference2) { + babelHelpers.inherits(UnboundReference, _ConstReference2); + + function UnboundReference() { + babelHelpers.classCallCheck(this, UnboundReference); + + _ConstReference2.apply(this, arguments); } - return _copy(obj, deep, deep ? [] : null, deep ? [] : null); - } + UnboundReference.create = function create(value) { + if (value === null) { + return _glimmerRuntime.NULL_REFERENCE; + } else if (value === undefined) { + return _glimmerRuntime.UNDEFINED_REFERENCE; + } else if (typeof value === 'object') { + return new UnboundReference(value); + } else { + return _glimmerRuntime.PrimitiveReference.create(value); + } + }; + + UnboundReference.prototype.get = function get(key) { + return new UnboundReference(_emberMetal.get(this.inner, key)); + }; + + return UnboundReference; + })(_glimmerReference.ConstReference); + + exports.UnboundReference = UnboundReference; }); -enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { +enifed('ember-glimmer/utils/string', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** @module ember - @submodule ember-runtime + @submodule ember-glimmer */ 'use strict'; - var a_slice = Array.prototype.slice; - var FunctionPrototype = Function.prototype; - - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { - /** - The `property` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - `true`, which is the default. - Computed properties allow you to treat a function like a property: - ```javascript - MyApp.President = Ember.Object.extend({ - firstName: '', - lastName: '', - fullName: function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }.property() // Call this flag to mark the function as a property - }); - let president = MyApp.President.create({ - firstName: 'Barack', - lastName: 'Obama' - }); - president.get('fullName'); // 'Barack Obama' - ``` - Treating a function like a property is useful because they can work with - bindings, just like any other property. - Many computed properties have dependencies on other properties. For - example, in the above example, the `fullName` property depends on - `firstName` and `lastName` to determine its value. You can tell Ember - about these dependencies like this: - ```javascript - MyApp.President = Ember.Object.extend({ - firstName: '', - lastName: '', - fullName: function() { - return this.get('firstName') + ' ' + this.get('lastName'); - // Tell Ember.js that this computed property depends on firstName - // and lastName - }.property('firstName', 'lastName') - }); - ``` - Make sure you list these dependencies so Ember knows when to update - bindings that connect to a computed property. Changing a dependency - will not immediately trigger an update of the computed property, but - will instead clear the cache so that it is updated when the next `get` - is called on the property. - See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/classes/Ember.computed.html). - @method property - @for Function - @public - */ - FunctionPrototype.property = function () { - var ret = _emberMetal.computed(this); - // ComputedProperty.prototype.property expands properties; no need for us to - // do so here. - return ret.property.apply(ret, arguments); - }; - - /** - The `observes` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - true, which is the default. - You can observe property changes simply by adding the `observes` - call to the end of your method declarations in classes that you write. - For example: - ```javascript - Ember.Object.extend({ - valueObserver: function() { - // Executes whenever the "value" property changes - }.observes('value') - }); - ``` - In the future this method may become asynchronous. - See `Ember.observer`. - @method observes - @for Function - @public - */ - FunctionPrototype.observes = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + exports.getSafeString = getSafeString; + exports.escapeExpression = escapeExpression; + exports.htmlSafe = htmlSafe; + exports.isHTMLSafe = isHTMLSafe; - args.push(this); - return _emberMetal.observer.apply(this, args); - }; + var SafeString = (function () { + function SafeString(string) { + babelHelpers.classCallCheck(this, SafeString); - FunctionPrototype._observesImmediately = function () { - _emberMetal.assert('Immediate observers must observe internal properties only, ' + 'not properties on other objects.', function checkIsInternalProperty() { - for (var i = 0; i < arguments.length; i++) { - if (arguments[i].indexOf('.') !== -1) { - return false; - } - } - return true; - }); + this.string = string; + } - // observes handles property expansion - return this.observes.apply(this, arguments); + SafeString.prototype.toString = function toString() { + return '' + this.string; }; - /** - The `observesImmediately` extension of Javascript's Function prototype is - available when `EmberENV.EXTEND_PROTOTYPES` or - `EmberENV.EXTEND_PROTOTYPES.Function` is true, which is the default. - You can observe property changes simply by adding the `observesImmediately` - call to the end of your method declarations in classes that you write. - For example: - ```javascript - Ember.Object.extend({ - valueObserver: function() { - // Executes immediately after the "value" property changes - }.observesImmediately('value') - }); - ``` - In the future, `observes` may become asynchronous. In this event, - `observesImmediately` will maintain the synchronous behavior. - See `Ember.immediateObserver`. - @method observesImmediately - @for Function - @deprecated - @private - */ - FunctionPrototype.observesImmediately = _emberMetal.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately); - - /** - The `on` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - true, which is the default. - You can listen for events simply by adding the `on` call to the end of - your method declarations in classes or mixins that you write. For example: - ```javascript - Ember.Mixin.create({ - doSomethingWithElement: function() { - // Executes whenever the "didInsertElement" event fires - }.on('didInsertElement') - }); - ``` - See `Ember.on`. - @method on - @for Function - @public - */ - FunctionPrototype.on = function () { - var events = a_slice.call(arguments); - this.__ember_listens__ = events; - return this; + SafeString.prototype.toHTML = function toHTML() { + return this.toString(); }; - } -}); -enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal'], function (exports, _rsvp, _emberMetal) { - 'use strict'; - exports.onerrorDefault = onerrorDefault; + return SafeString; + })(); - var backburner = _emberMetal.run.backburner; - _emberMetal.run._addQueue('rsvpAfter', 'destroy'); + exports.SafeString = SafeString; - _rsvp.configure('async', function (callback, promise) { - backburner.schedule('actions', null, callback, promise); - }); + function getSafeString() { + _emberMetal.deprecate('Ember.Handlebars.SafeString is deprecated in favor of Ember.String.htmlSafe', false, { + id: 'ember-htmlbars.ember-handlebars-safestring', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_use-ember-string-htmlsafe-over-ember-handlebars-safestring' + }); - _rsvp.configure('after', function (cb) { - backburner.schedule('rsvpAfter', null, cb); - }); + return SafeString; + } - _rsvp.on('error', onerrorDefault); + var escape = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + // jscs:disable + "'": ''', + // jscs:enable + '`': '`', + '=': '=' + }; - function onerrorDefault(reason) { - var error = errorFor(reason); - if (error) { - _emberMetal.dispatchError(error); - } + var possible = /[&<>"'`=]/; + var badChars = /[&<>"'`=]/g; + + function escapeChar(chr) { + return escape[chr]; } - function errorFor(reason) { - if (!reason) return; + function escapeExpression(string) { + if (typeof string !== 'string') { + // don't escape SafeStrings, since they're already safe + if (string && string.toHTML) { + return string.toHTML(); + } else if (string == null) { + return ''; + } else if (!string) { + return string + ''; + } - if (reason.errorThrown) { - return unwrapErrorThrown(reason); + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = '' + string; } - if (reason.name === 'UnrecognizedURLError') { - _emberMetal.assert('The URL \'' + reason.message + '\' did not match any routes in your application', false); - return; + if (!possible.test(string)) { + return string; } + return string.replace(badChars, escapeChar); + } - if (reason.name === 'TransitionAborted') { - return; + /** + Mark a string as safe for unescaped output with Ember templates. If you + return HTML from a helper, use this function to + ensure Ember's rendering layer does not escape the HTML. + + ```javascript + Ember.String.htmlSafe('
    someString
    ') + ``` + + @method htmlSafe + @for Ember.String + @static + @return {Handlebars.SafeString} A string that will not be HTML escaped by Handlebars. + @public + */ + + function htmlSafe(str) { + if (str === null || str === undefined) { + str = ''; + } else if (typeof str !== 'string') { + str = '' + str; } + return new SafeString(str); + } - return reason; + /** + Detects if a string was decorated using `Ember.String.htmlSafe`. + + ```javascript + var plainString = 'plain string', + safeString = Ember.String.htmlSafe('
    someValue
    '); + + Ember.String.isHTMLSafe(plainString); // false + Ember.String.isHTMLSafe(safeString); // true + ``` + + @method isHTMLSafe + @for Ember.String + @static + @return {Boolean} `true` if the string was decorated with `htmlSafe`, `false` otherwise. + @public + */ + + function isHTMLSafe(str) { + return str && typeof str.toHTML === 'function'; } +}); +enifed('ember-glimmer/utils/to-bool', ['exports', 'ember-runtime', 'ember-metal'], function (exports, _emberRuntime, _emberMetal) { + 'use strict'; - function unwrapErrorThrown(reason) { - var error = reason.errorThrown; - if (typeof error === 'string') { - error = new Error(error); + exports.default = toBool; + + function toBool(predicate) { + if (!predicate) { + return false; } - Object.defineProperty(error, '__reason_with_error_thrown__', { - value: reason, - enumerable: false - }); - return error; - } - exports.default = _rsvp; + if (predicate === true) { + return true; + } + + if (_emberRuntime.isArray(predicate)) { + return _emberMetal.get(predicate, 'length') !== 0; + } + + return true; + } }); -enifed('ember-runtime/ext/string', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { +enifed('ember-glimmer/views/outlet', ['exports', 'ember-utils', '@glimmer/reference', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _glimmerReference, _emberEnvironment, _emberMetal) { /** @module ember - @submodule ember-runtime + @submodule ember-glimmer */ - 'use strict'; - var StringPrototype = String.prototype; + var OutletStateReference = (function () { + function OutletStateReference(outletView) { + babelHelpers.classCallCheck(this, OutletStateReference); - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { - /** - See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt). - @method fmt - @for String - @private - @deprecated - */ - StringPrototype.fmt = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + this.outletView = outletView; + this.tag = outletView._tag; + } - return _emberRuntimeSystemString.fmt(this, args); - }; + // So this is a relic of the past that SHOULD go away + // in 3.0. Preferably it is deprecated in the release that + // follows the Glimmer release. - /** - See [Ember.String.w](/api/classes/Ember.String.html#method_w). - @method w - @for String - @private - */ - StringPrototype.w = function () { - return _emberRuntimeSystemString.w(this); + OutletStateReference.prototype.get = function get(key) { + return new ChildOutletStateReference(this, key); }; - /** - See [Ember.String.loc](/api/classes/Ember.String.html#method_loc). - @method loc - @for String - @private - */ - StringPrototype.loc = function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return _emberRuntimeSystemString.loc(this, args); + OutletStateReference.prototype.value = function value() { + return this.outletView.outletState; }; - /** - See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize). - @method camelize - @for String - @private - */ - StringPrototype.camelize = function () { - return _emberRuntimeSystemString.camelize(this); + OutletStateReference.prototype.getOrphan = function getOrphan(name) { + return new OrphanedOutletStateReference(this, name); }; - /** - See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize). - @method decamelize - @for String - @private - */ - StringPrototype.decamelize = function () { - return _emberRuntimeSystemString.decamelize(this); + OutletStateReference.prototype.update = function update(state) { + this.outletView.setOutletState(state); }; - /** - See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize). - @method dasherize - @for String - @private - */ - StringPrototype.dasherize = function () { - return _emberRuntimeSystemString.dasherize(this); - }; + return OutletStateReference; + })(); - /** - See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore). - @method underscore - @for String - @private - */ - StringPrototype.underscore = function () { - return _emberRuntimeSystemString.underscore(this); - }; + var OrphanedOutletStateReference = (function (_OutletStateReference) { + babelHelpers.inherits(OrphanedOutletStateReference, _OutletStateReference); - /** - See [Ember.String.classify](/api/classes/Ember.String.html#method_classify). - @method classify - @for String - @private - */ - StringPrototype.classify = function () { - return _emberRuntimeSystemString.classify(this); - }; + function OrphanedOutletStateReference(root, name) { + babelHelpers.classCallCheck(this, OrphanedOutletStateReference); - /** - See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize). - @method capitalize - @for String - @private - */ - StringPrototype.capitalize = function () { - return _emberRuntimeSystemString.capitalize(this); + _OutletStateReference.call(this, root.outletView); + this.root = root; + this.name = name; + } + + OrphanedOutletStateReference.prototype.value = function value() { + var rootState = this.root.value(); + + var orphans = rootState.outlets.main.outlets.__ember_orphans__; + + if (!orphans) { + return null; + } + + var matched = orphans.outlets[this.name]; + + if (!matched) { + return null; + } + + var state = new _emberUtils.EmptyObject(); + state[matched.render.outlet] = matched; + matched.wasUsed = true; + return { outlets: state }; }; - } -}); -enifed('ember-runtime/index', ['exports', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/system/object', 'ember-runtime/system/string', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/compare', 'ember-runtime/is-equal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/system/namespace', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeSystemObject, _emberRuntimeSystemString, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeCompare, _emberRuntimeIsEqual, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeSystemNamespace, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsObservable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeUtils, _emberRuntimeString_registry) { - /** - @module ember - @submodule ember-runtime - */ - 'use strict'; + return OrphanedOutletStateReference; + })(OutletStateReference); - exports.Object = _emberRuntimeSystemObject.default; - exports.FrameworkObject = _emberRuntimeSystemObject.FrameworkObject; - exports.String = _emberRuntimeSystemString.default; - exports.RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default; - exports.buildFakeRegistryWithDeprecations = _emberRuntimeMixinsRegistry_proxy.buildFakeRegistryWithDeprecations; - exports.ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default; - exports.copy = _emberRuntimeCopy.default; - exports.inject = _emberRuntimeInject.default; - exports.compare = _emberRuntimeCompare.default; - exports.isEqual = _emberRuntimeIsEqual.default; - exports.Array = _emberRuntimeMixinsArray.default; - exports.objectAt = _emberRuntimeMixinsArray.objectAt; - exports.isEmberArray = _emberRuntimeMixinsArray.isEmberArray; - exports.addArrayObserver = _emberRuntimeMixinsArray.addArrayObserver; - exports.removeArrayObserver = _emberRuntimeMixinsArray.removeArrayObserver; - exports.Comparable = _emberRuntimeMixinsComparable.default; - exports.Namespace = _emberRuntimeSystemNamespace.default; - exports.isNamespaceSearchDisabled = _emberRuntimeSystemNamespace.isSearchDisabled; - exports.setNamespaceSearchDisabled = _emberRuntimeSystemNamespace.setSearchDisabled; - exports.ArrayProxy = _emberRuntimeSystemArray_proxy.default; - exports.ObjectProxy = _emberRuntimeSystemObject_proxy.default; - exports.CoreObject = _emberRuntimeSystemCore_object.default; - exports.NativeArray = _emberRuntimeSystemNative_array.default; - exports.A = _emberRuntimeSystemNative_array.A; - exports.ActionHandler = _emberRuntimeMixinsAction_handler.default; - exports.deprecateUnderscoreActions = _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions; - exports.Copyable = _emberRuntimeMixinsCopyable.default; - exports.Enumerable = _emberRuntimeMixinsEnumerable.default; - exports.Freezable = _emberRuntimeMixinsFreezable.Freezable; - exports.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR; - exports._ProxyMixin = _emberRuntimeMixinsProxy.default; - exports.onLoad = _emberRuntimeSystemLazy_load.onLoad; - exports.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks; - exports._loaded = _emberRuntimeSystemLazy_load._loaded; - exports.Observable = _emberRuntimeMixinsObservable.default; - exports.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default; - exports.MutableArray = _emberRuntimeMixinsMutable_array.default; - exports.removeAt = _emberRuntimeMixinsMutable_array.removeAt; - exports.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default; - exports.Evented = _emberRuntimeMixinsEvented.default; - exports.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default; - exports.empty = _emberRuntimeComputedComputed_macros.empty; - exports.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty; - exports.none = _emberRuntimeComputedComputed_macros.none; - exports.not = _emberRuntimeComputedComputed_macros.not; - exports.bool = _emberRuntimeComputedComputed_macros.bool; - exports.match = _emberRuntimeComputedComputed_macros.match; - exports.equal = _emberRuntimeComputedComputed_macros.equal; - exports.gt = _emberRuntimeComputedComputed_macros.gt; - exports.gte = _emberRuntimeComputedComputed_macros.gte; - exports.lt = _emberRuntimeComputedComputed_macros.lt; - exports.lte = _emberRuntimeComputedComputed_macros.lte; - exports.oneWay = _emberRuntimeComputedComputed_macros.oneWay; - exports.readOnly = _emberRuntimeComputedComputed_macros.readOnly; - exports.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias; - exports.and = _emberRuntimeComputedComputed_macros.and; - exports.or = _emberRuntimeComputedComputed_macros.or; - exports.sum = _emberRuntimeComputedReduce_computed_macros.sum; - exports.min = _emberRuntimeComputedReduce_computed_macros.min; - exports.max = _emberRuntimeComputedReduce_computed_macros.max; - exports.map = _emberRuntimeComputedReduce_computed_macros.map; - exports.sort = _emberRuntimeComputedReduce_computed_macros.sort; - exports.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff; - exports.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy; - exports.filter = _emberRuntimeComputedReduce_computed_macros.filter; - exports.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy; - exports.uniq = _emberRuntimeComputedReduce_computed_macros.uniq; - exports.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy; - exports.union = _emberRuntimeComputedReduce_computed_macros.union; - exports.intersect = _emberRuntimeComputedReduce_computed_macros.intersect; - exports.collect = _emberRuntimeComputedReduce_computed_macros.collect; - exports.Controller = _emberRuntimeControllersController.default; - exports.ControllerMixin = _emberRuntimeMixinsController.default; - exports.Service = _emberRuntimeSystemService.default; - exports.RSVP = _emberRuntimeExtRsvp.default; - exports.onerrorDefault = _emberRuntimeExtRsvp.onerrorDefault; - // just for side effect of extending Ember.RSVP - exports.isArray = _emberRuntimeUtils.isArray; - exports.typeOf = _emberRuntimeUtils.typeOf; - exports.getStrings = _emberRuntimeString_registry.getStrings; - exports.setStrings = _emberRuntimeString_registry.setStrings; -}); -// just for side effect of extending String.prototype -// just for side effect of extending Function.prototype -enifed('ember-runtime/inject', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + var ChildOutletStateReference = (function () { + function ChildOutletStateReference(parent, key) { + babelHelpers.classCallCheck(this, ChildOutletStateReference); - exports.default = inject; - exports.createInjectionHelper = createInjectionHelper; - exports.validatePropertyInjections = validatePropertyInjections; + this.parent = parent; + this.key = key; + this.tag = parent.tag; + } - /** - Namespace for injection helper methods. - - @class inject - @namespace Ember - @static - @public - */ + ChildOutletStateReference.prototype.get = function get(key) { + return new ChildOutletStateReference(this, key); + }; - function inject() { - _emberMetal.assert('Injected properties must be created through helpers, see \'' + Object.keys(inject).join('"', '"') + '\''); - } + ChildOutletStateReference.prototype.value = function value() { + return this.parent.value()[this.key]; + }; - // Dictionary of injection validations by type, added to by `createInjectionHelper` - var typeValidators = {}; + return ChildOutletStateReference; + })(); - /** - This method allows other Ember modules to register injection helpers for a - given container type. Helpers are exported to the `inject` namespace as the - container type itself. - - @private - @method createInjectionHelper - @since 1.10.0 - @for Ember - @param {String} type The container type the helper will inject - @param {Function} validator A validation callback that is executed at mixin-time - */ + var OutletView = (function () { + OutletView.extend = function extend(injections) { + return (function (_OutletView) { + babelHelpers.inherits(_class, _OutletView); - function createInjectionHelper(type, validator) { - typeValidators[type] = validator; + function _class() { + babelHelpers.classCallCheck(this, _class); + + _OutletView.apply(this, arguments); + } + + _class.create = function create(options) { + if (options) { + return _OutletView.create.call(this, _emberUtils.assign({}, injections, options)); + } else { + return _OutletView.create.call(this, injections); + } + }; + + return _class; + })(OutletView); + }; - inject[type] = function (name) { - return new _emberMetal.InjectedProperty(type, name); + OutletView.reopenClass = function reopenClass(injections) { + _emberUtils.assign(this, injections); }; - } - /** - Validation function that runs per-type validation functions once for each - injected type encountered. - - @private - @method validatePropertyInjections - @since 1.10.0 - @for Ember - @param {Object} factory The factory object - */ + OutletView.create = function create(options) { + var _environment = options._environment; + var renderer = options.renderer; + var template = options.template; - function validatePropertyInjections(factory) { - var proto = factory.proto(); - var types = []; + var owner = options[_emberUtils.OWNER]; + return new OutletView(_environment, renderer, owner, template); + }; - for (var key in proto) { - var desc = proto[key]; - if (desc instanceof _emberMetal.InjectedProperty && types.indexOf(desc.type) === -1) { - types.push(desc.type); - } + function OutletView(_environment, renderer, owner, template) { + babelHelpers.classCallCheck(this, OutletView); + + this._environment = _environment; + this.renderer = renderer; + this.owner = owner; + this.template = template; + this.outletState = null; + this._tag = new _glimmerReference.DirtyableTag(); } - if (types.length) { - for (var i = 0; i < types.length; i++) { - var validator = typeValidators[types[i]]; + OutletView.prototype.appendTo = function appendTo(selector) { + var env = this._environment || _emberEnvironment.environment; + var target = undefined; - if (typeof validator === 'function') { - validator(factory); - } + if (env.hasDOM) { + target = typeof selector === 'string' ? document.querySelector(selector) : selector; + } else { + target = selector; } - } - return true; - } -}); -enifed('ember-runtime/is-equal', ['exports'], function (exports) { - /** - Compares two objects, returning true if they are equal. - - ```javascript - Ember.isEqual('hello', 'hello'); // true - Ember.isEqual(1, 2); // false - ``` - - `isEqual` is a more specific comparison than a triple equal comparison. - It will call the `isEqual` instance method on the objects being - compared, allowing finer control over when objects should be considered - equal to each other. - - ```javascript - let Person = Ember.Object.extend({ - isEqual(other) { return this.ssn == other.ssn; } - }); - - let personA = Person.create({name: 'Muhammad Ali', ssn: '123-45-6789'}); - let personB = Person.create({name: 'Cassius Clay', ssn: '123-45-6789'}); - - Ember.isEqual(personA, personB); // true - ``` - - Due to the expense of array comparisons, collections will never be equal to - each other even if each of their items are equal to each other. - - ```javascript - Ember.isEqual([4, 2], [4, 2]); // false - ``` - - @method isEqual - @for Ember - @param {Object} a first object to compare - @param {Object} b second object to compare - @return {Boolean} - @public - */ - 'use strict'; + _emberMetal.run.schedule('render', this.renderer, 'appendOutletView', this, target); + }; - exports.default = isEqual; + OutletView.prototype.rerender = function rerender() {}; - function isEqual(a, b) { - if (a && typeof a.isEqual === 'function') { - return a.isEqual(b); - } + OutletView.prototype.setOutletState = function setOutletState(state) { + this.outletState = { + outlets: { + main: state + }, + render: { + owner: undefined, + into: undefined, + outlet: 'main', + name: '-top-level', + controller: undefined, + ViewClass: undefined, + template: undefined + } + }; + this._tag.dirty(); + }; - if (a instanceof Date && b instanceof Date) { - return a.getTime() === b.getTime(); - } + OutletView.prototype.toReference = function toReference() { + return new OutletStateReference(this); + }; - return a === b; - } -}); -enifed('ember-runtime/mixins/-proxy', ['exports', 'glimmer-reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { - /** - @module ember - @submodule ember-runtime - */ + OutletView.prototype.destroy = function destroy() {}; - 'use strict'; + return OutletView; + })(); - function contentPropertyWillChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { - return; - } // if shadowed in proxy - _emberMetal.propertyWillChange(this, key); - } + exports.default = OutletView; +}); +enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) { + 'use strict'; - function contentPropertyDidChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { - return; - } // if shadowed in proxy - _emberMetal.propertyDidChange(this, key); - } + exports.default = alias; - var ProxyTag = (function (_CachedTag) { - babelHelpers.inherits(ProxyTag, _CachedTag); + var CONSUMED = {}; - function ProxyTag(proxy) { - babelHelpers.classCallCheck(this, ProxyTag); + function alias(altKey) { + return new AliasedProperty(altKey); + } - _CachedTag.call(this); + var AliasedProperty = (function (_Descriptor) { + babelHelpers.inherits(AliasedProperty, _Descriptor); - var content = _emberMetal.get(proxy, 'content'); + function AliasedProperty(altKey) { + babelHelpers.classCallCheck(this, AliasedProperty); - this.proxy = proxy; - this.proxyWrapperTag = new _glimmerReference.DirtyableTag(); - this.proxyContentTag = new _glimmerReference.UpdatableTag(_emberMetal.tagFor(content)); + _Descriptor.call(this); + this.isDescriptor = true; + this.altKey = altKey; + this._dependentKeys = [altKey]; } - /** - `Ember.ProxyMixin` forwards all properties not defined by the proxy itself - to a proxied `content` object. See Ember.ObjectProxy for more details. - - @class ProxyMixin - @namespace Ember - @private - */ - - ProxyTag.prototype.compute = function compute() { - return Math.max(this.proxyWrapperTag.value(), this.proxyContentTag.value()); + AliasedProperty.prototype.setup = function setup(obj, keyName) { + _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName); + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } }; - ProxyTag.prototype.dirty = function dirty() { - this.proxyWrapperTag.dirty(); + AliasedProperty.prototype.teardown = function teardown(obj, keyName) { + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + } }; - ProxyTag.prototype.contentDidChange = function contentDidChange() { - var content = _emberMetal.get(this.proxy, 'content'); - this.proxyContentTag.update(_emberMetal.tagFor(content)); + AliasedProperty.prototype.willWatch = function willWatch(obj, keyName) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); }; - return ProxyTag; - })(_glimmerReference.CachedTag); - - exports.default = _emberMetal.Mixin.create({ - /** - The object whose properties will be forwarded. - @property content - @type Ember.Object - @default null - @private - */ - content: null, + AliasedProperty.prototype.didUnwatch = function didUnwatch(obj, keyName) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); + }; - init: function () { - this._super.apply(this, arguments); - _emberMetal.meta(this).setProxy(); - }, + AliasedProperty.prototype.get = function get(obj, keyName) { + var ret = _emberMetalProperty_get.get(obj, this.altKey); + var meta = _emberMetalMeta.meta(obj); + var cache = meta.writableCache(); + if (cache[keyName] !== CONSUMED) { + cache[keyName] = CONSUMED; + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } + return ret; + }; - _initializeTag: _emberMetal.on('init', function () { - _emberMetal.meta(this)._tag = new ProxyTag(this); - }), + AliasedProperty.prototype.set = function set(obj, keyName, value) { + return _emberMetalProperty_set.set(obj, this.altKey, value); + }; - _contentDidChange: _emberMetal.observer('content', function () { - _emberMetal.assert('Can\'t set Proxy\'s content to itself', _emberMetal.get(this, 'content') !== this); - _emberMetal.tagFor(this).contentDidChange(); - }), + AliasedProperty.prototype.readOnly = function readOnly() { + this.set = AliasedProperty_readOnlySet; + return this; + }; - isTruthy: _emberRuntimeComputedComputed_macros.bool('content'), + AliasedProperty.prototype.oneWay = function oneWay() { + this.set = AliasedProperty_oneWaySet; + return this; + }; - _debugContainerKey: null, + return AliasedProperty; + })(_emberMetalProperties.Descriptor); - willWatchProperty: function (key) { - var contentKey = 'content.' + key; - _emberMetal._addBeforeObserver(this, contentKey, null, contentPropertyWillChange); - _emberMetal.addObserver(this, contentKey, null, contentPropertyDidChange); - }, + exports.AliasedProperty = AliasedProperty; - didUnwatchProperty: function (key) { - var contentKey = 'content.' + key; - _emberMetal._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); - _emberMetal.removeObserver(this, contentKey, null, contentPropertyDidChange); - }, + function AliasedProperty_readOnlySet(obj, keyName, value) { + throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); + } - unknownProperty: function (key) { - var content = _emberMetal.get(this, 'content'); - if (content) { - _emberMetal.deprecate('You attempted to access `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); - return _emberMetal.get(content, key); - } - }, + function AliasedProperty_oneWaySet(obj, keyName, value) { + _emberMetalProperties.defineProperty(obj, keyName, null); + return _emberMetalProperty_set.set(obj, keyName, value); + } - setUnknownProperty: function (key, value) { - var m = _emberMetal.meta(this); - if (m.proto === this) { - // if marked as prototype then just defineProperty - // rather than delegate - _emberMetal.defineProperty(this, key, null, value); - return value; - } + // Backwards compatibility with Ember Data. + AliasedProperty.prototype._meta = undefined; + AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta; +}); +enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) { + 'use strict'; - var content = _emberMetal.get(this, 'content'); - _emberMetal.assert('Cannot delegate set(\'' + key + '\', ' + value + ') to the \'content\' property of object proxy ' + this + ': its \'content\' is undefined.', content); + exports.bind = bind; - _emberMetal.deprecate('You attempted to set `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); - return _emberMetal.set(content, key, value); - } - }); -}); -enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** @module ember - @submodule ember-runtime + @submodule ember-metal */ - 'use strict'; + // .......................................................... + // BINDING + // - exports.deprecateUnderscoreActions = deprecateUnderscoreActions; + var Binding = (function () { + function Binding(toPath, fromPath) { + babelHelpers.classCallCheck(this, Binding); - /** - `Ember.ActionHandler` is available on some familiar classes including - `Ember.Route`, `Ember.Component`, and `Ember.Controller`. - (Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`, - and `Ember.Route` and available to the above classes through - inheritance.) - - @class ActionHandler - @namespace Ember - @private - */ - var ActionHandler = _emberMetal.Mixin.create({ - mergedProperties: ['actions'], + // Configuration + this._from = fromPath; + this._to = toPath; + this._oneWay = undefined; + + // State + this._direction = undefined; + this._readyToSync = undefined; + this._fromObj = undefined; + this._fromPath = undefined; + this._toObj = undefined; + } /** - The collection of functions, keyed by name, available on this - `ActionHandler` as action targets. - These functions will be invoked when a matching `{{action}}` is triggered - from within a template and the application's current route is this route. - Actions can also be invoked from other parts of your application - via `ActionHandler#send`. - The `actions` hash will inherit action handlers from - the `actions` hash defined on extended parent classes - or mixins rather than just replace the entire hash, e.g.: - ```js - App.CanDisplayBanner = Ember.Mixin.create({ - actions: { - displayBanner(msg) { - // ... - } - } - }); - App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { - actions: { - playMusic() { - // ... - } - } - }); - // `WelcomeRoute`, when active, will be able to respond - // to both actions, since the actions hash is merged rather - // then replaced when extending mixins / parent classes. - this.send('displayBanner'); - this.send('playMusic'); - ``` - Within a Controller, Route or Component's action handler, - the value of the `this` context is the Controller, Route or - Component object: - ```js - App.SongRoute = Ember.Route.extend({ - actions: { - myAction() { - this.controllerFor("song"); - this.transitionTo("other.route"); - ... - } - } - }); - ``` - It is also possible to call `this._super(...arguments)` from within an - action handler if it overrides a handler defined on a parent - class or mixin: - Take for example the following routes: - ```js - App.DebugRoute = Ember.Mixin.create({ - actions: { - debugRouteInformation() { - console.debug("trololo"); - } - } - }); - App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { - actions: { - debugRouteInformation() { - // also call the debugRouteInformation of mixed in App.DebugRoute - this._super(...arguments); - // show additional annoyance - window.alert(...); - } - } - }); - ``` - ## Bubbling - By default, an action will stop bubbling once a handler defined - on the `actions` hash handles it. To continue bubbling the action, - you must return `true` from the handler: - ```js - App.Router.map(function() { - this.route("album", function() { - this.route("song"); - }); - }); - App.AlbumRoute = Ember.Route.extend({ - actions: { - startPlaying: function() { - } - } - }); - App.AlbumSongRoute = Ember.Route.extend({ - actions: { - startPlaying() { - // ... - if (actionShouldAlsoBeTriggeredOnParentRoute) { - return true; - } - } - } - }); - ``` - @property actions - @type Object - @default null + @class Binding + @namespace Ember + @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding @public */ /** - Triggers a named action on the `ActionHandler`. Any parameters - supplied after the `actionName` string will be passed as arguments - to the action target function. - If the `ActionHandler` has its `target` property set, actions may - bubble to the `target`. Bubbling happens when an `actionName` can - not be found in the `ActionHandler`'s `actions` hash or if the - action target function returns `true`. - Example - ```js - App.WelcomeRoute = Ember.Route.extend({ - actions: { - playTheme() { - this.send('playMusic', 'theme.mp3'); - }, - playMusic(track) { - // ... - } - } - }); - ``` - @method send - @param {String} actionName The action to trigger - @param {*} context a context to send with the action + This copies the Binding so it can be connected to another object. + @method copy + @return {Ember.Binding} `this` @public */ - send: function (actionName) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + + Binding.prototype.copy = function copy() { + var copy = new Binding(this._to, this._from); + if (this._oneWay) { + copy._oneWay = true; } + return copy; + }; + + // .......................................................... + // CONFIG + // + + /** + This will set `from` property path to the specified value. It will not + attempt to resolve this property path to an actual object until you + connect the binding. + The binding will search for the property path starting at the root object + you pass when you `connect()` the binding. It follows the same rules as + `get()` - see that method for more information. + @method from + @param {String} path The property path to connect to. + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.from = function from(path) { + this._from = path; + return this; + }; + + /** + This will set the `to` property path to the specified value. It will not + attempt to resolve this property path to an actual object until you + connect the binding. + The binding will search for the property path starting at the root object + you pass when you `connect()` the binding. It follows the same rules as + `get()` - see that method for more information. + @method to + @param {String|Tuple} path A property path or tuple. + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.to = function to(path) { + this._to = path; + return this; + }; + + /** + Configures the binding as one way. A one-way binding will relay changes + on the `from` side to the `to` side, but not the other way around. This + means that if you change the `to` side directly, the `from` side may have + a different value. + @method oneWay + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.oneWay = function oneWay() { + this._oneWay = true; + return this; + }; + + /** + @method toString + @return {String} string representation of binding + @public + */ + + Binding.prototype.toString = function toString() { + var oneWay = this._oneWay ? '[oneWay]' : ''; + return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; + }; + + // .......................................................... + // CONNECT AND SYNC + // + + /** + Attempts to connect this binding instance so that it can receive and relay + changes. This method will raise an exception if you have not set the + from/to properties yet. + @method connect + @param {Object} obj The root object for this binding. + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.connect = function connect(obj) { + _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.connect()', !!obj); + + var fromObj = undefined, + fromPath = undefined, + possibleGlobal = undefined; + + // If the binding's "from" path could be interpreted as a global, verify + // whether the path refers to a global or not by consulting `Ember.lookup`. + if (_emberMetalPath_cache.isGlobalPath(this._from)) { + var _name = _emberMetalPath_cache.getFirstKey(this._from); + possibleGlobal = _emberEnvironment.context.lookup[_name]; - if (this.actions && this.actions[actionName]) { - var shouldBubble = this.actions[actionName].apply(this, args) === true; - if (!shouldBubble) { - return; + if (possibleGlobal) { + fromObj = possibleGlobal; + fromPath = _emberMetalPath_cache.getTailPath(this._from); } } - var target = _emberMetal.get(this, 'target'); - if (target) { - _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); + if (fromObj === undefined) { + fromObj = obj; + fromPath = this._from; } - }, - willMergeMixin: function (props) { - _emberMetal.assert('Specifying `_actions` and `actions` in the same mixin is not supported.', !props.actions || !props._actions); + _emberMetalProperty_set.trySet(obj, this._to, _emberMetalProperty_get.get(fromObj, fromPath)); - if (props._actions) { - _emberMetal.deprecate('Specifying actions in `_actions` is deprecated, please use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); + // Add an observer on the object to be notified when the binding should be updated. + _emberMetalObserver.addObserver(fromObj, fromPath, this, 'fromDidChange'); - props.actions = props._actions; - delete props._actions; + // If the binding is a two-way binding, also set up an observer on the target. + if (!this._oneWay) { + _emberMetalObserver.addObserver(obj, this._to, this, 'toDidChange'); } - } - }); - exports.default = ActionHandler; + _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect'); - function deprecateUnderscoreActions(factory) { - Object.defineProperty(factory.prototype, '_actions', { - configurable: true, - enumerable: false, - set: function (value) { - _emberMetal.assert('You cannot set `_actions` on ' + this + ', please use `actions` instead.'); - }, - get: function () { - _emberMetal.deprecate('Usage of `_actions` is deprecated, use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); - return _emberMetal.get(this, 'actions'); - } - }); - } -}); -enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/each_proxy'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsEnumerable, _emberRuntimeSystemEach_proxy) { - /** - @module ember - @submodule ember-runtime - */ + fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); - // .......................................................... - // HELPERS - // - 'use strict'; + this._readyToSync = true; + this._fromObj = fromObj; + this._fromPath = fromPath; + this._toObj = obj; - var _Mixin$create; + return this; + }; - exports.addArrayObserver = addArrayObserver; - exports.removeArrayObserver = removeArrayObserver; - exports.objectAt = objectAt; - exports.arrayContentWillChange = arrayContentWillChange; - exports.arrayContentDidChange = arrayContentDidChange; - exports.isEmberArray = isEmberArray; + /** + Disconnects the binding instance. Changes will no longer be relayed. You + will not usually need to call this method. + @method disconnect + @return {Ember.Binding} `this` + @public + */ - function arrayObserversHelper(obj, target, opts, operation, notify) { - var willChange = opts && opts.willChange || 'arrayWillChange'; - var didChange = opts && opts.didChange || 'arrayDidChange'; - var hasObservers = _emberMetal.get(obj, 'hasArrayObservers'); + Binding.prototype.disconnect = function disconnect() { + _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); - if (hasObservers === notify) { - _emberMetal.propertyWillChange(obj, 'hasArrayObservers'); - } + // Remove an observer on the object so we're no longer notified of + // changes that should update bindings. + _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); - operation(obj, '@array:before', target, willChange); - operation(obj, '@array:change', target, didChange); + // If the binding is two-way, remove the observer from the target as well. + if (!this._oneWay) { + _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); + } - if (hasObservers === notify) { - _emberMetal.propertyDidChange(obj, 'hasArrayObservers'); - } + this._readyToSync = false; // Disable scheduled syncs... + return this; + }; - return obj; - } + // .......................................................... + // PRIVATE + // - function addArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, _emberMetal.addListener, false); - } + /* Called when the from side changes. */ - function removeArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, _emberMetal.removeListener, true); - } + Binding.prototype.fromDidChange = function fromDidChange(target) { + this._scheduleSync('fwd'); + }; - function objectAt(content, idx) { - if (content.objectAt) { - return content.objectAt(idx); - } + /* Called when the to side changes. */ - return content[idx]; - } + Binding.prototype.toDidChange = function toDidChange(target) { + this._scheduleSync('back'); + }; - function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { - var removing = undefined, - lim = undefined; + Binding.prototype._scheduleSync = function _scheduleSync(dir) { + var existingDir = this._direction; - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; + // If we haven't scheduled the binding yet, schedule it. + if (existingDir === undefined) { + _emberMetalRun_loop.default.schedule('sync', this, '_sync'); + this._direction = dir; } - if (addAmt === undefined) { - addAmt = -1; + // If both a 'back' and 'fwd' sync have been scheduled on the same object, + // default to a 'fwd' sync so that it remains deterministic. + if (existingDir === 'back' && dir === 'fwd') { + this._direction = 'fwd'; } - } - - if (array.__each) { - array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt); - } - - _emberMetal.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); - - if (startIdx >= 0 && removeAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { - removing = []; - lim = startIdx + removeAmt; + }; - for (var idx = startIdx; idx < lim; idx++) { - removing.push(objectAt(array, idx)); - } - } else { - removing = removeAmt; - } + Binding.prototype._sync = function _sync() { + var _this = this; - array.enumerableContentWillChange(removing, addAmt); + var log = _emberEnvironment.ENV.LOG_BINDINGS; - return array; - } + var toObj = this._toObj; - function arrayContentDidChange(array, startIdx, removeAmt, addAmt) { - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; + // Don't synchronize destroyed objects or disconnected bindings. + if (toObj.isDestroyed || !this._readyToSync) { + return; } - if (addAmt === undefined) { - addAmt = -1; - } - } + // Get the direction of the binding for the object we are + // synchronizing from. + var direction = this._direction; - var adding = undefined; - if (startIdx >= 0 && addAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { - adding = []; - var lim = startIdx + addAmt; + var fromObj = this._fromObj; + var fromPath = this._fromPath; - for (var idx = startIdx; idx < lim; idx++) { - adding.push(objectAt(array, idx)); - } - } else { - adding = addAmt; - } + this._direction = undefined; - array.enumerableContentDidChange(removeAmt, adding); + // If we're synchronizing from the remote object... + if (direction === 'fwd') { + (function () { + var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); + if (log) { + _emberConsole.default.log(' ', _this.toString(), '->', fromValue, fromObj); + } + if (_this._oneWay) { + _emberMetalProperty_set.trySet(toObj, _this._to, fromValue); + } else { + _emberMetalObserver._suspendObserver(toObj, _this._to, _this, 'toDidChange', function () { + _emberMetalProperty_set.trySet(toObj, this._to, fromValue); + }); + } + // If we're synchronizing *to* the remote object. + })(); + } else if (direction === 'back') { + (function () { + var toValue = _emberMetalProperty_get.get(toObj, _this._to); + if (log) { + _emberConsole.default.log(' ', _this.toString(), '<-', toValue, toObj); + } + _emberMetalObserver._suspendObserver(fromObj, fromPath, _this, 'fromDidChange', function () { + _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); + }); + })(); + } + }; - if (array.__each) { - array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt); - } + return Binding; + })(); - _emberMetal.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); + function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { + var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; + var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; + var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - var meta = _emberMetal.peekMeta(array); - var cache = meta && meta.readableCache(); + var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; + _emberMetalDebug.deprecate(objectInfo + deprecateGlobalMessage, !deprecateGlobal, { + id: 'ember-metal.binding', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' + }); + _emberMetalDebug.deprecate(objectInfo + deprecateOneWayMessage, !deprecateOneWay, { + id: 'ember-metal.binding', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' + }); + _emberMetalDebug.deprecate(objectInfo + deprecateAliasMessage, !deprecateAlias, { + id: 'ember-metal.binding', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding' + }); + } - if (cache) { - if (cache.firstObject !== undefined && objectAt(array, 0) !== _emberMetal.cacheFor.get(cache, 'firstObject')) { - _emberMetal.propertyWillChange(array, 'firstObject'); - _emberMetal.propertyDidChange(array, 'firstObject'); - } - if (cache.lastObject !== undefined && objectAt(array, _emberMetal.get(array, 'length') - 1) !== _emberMetal.cacheFor.get(cache, 'lastObject')) { - _emberMetal.propertyWillChange(array, 'lastObject'); - _emberMetal.propertyDidChange(array, 'lastObject'); + function mixinProperties(to, from) { + for (var key in from) { + if (from.hasOwnProperty(key)) { + to[key] = from[key]; } } - return array; } - var EMBER_ARRAY = _emberUtils.symbol('EMBER_ARRAY'); + mixinProperties(Binding, { - function isEmberArray(obj) { - return obj && !!obj[EMBER_ARRAY]; - } + /* + See `Ember.Binding.from`. + @method from + @static + */ + from: function (from) { + var C = this; + return new C(undefined, from); + }, - // .......................................................... - // ARRAY - // + /* + See `Ember.Binding.to`. + @method to + @static + */ + to: function (to) { + var C = this; + return new C(to, undefined); + } + }); /** - This mixin implements Observer-friendly Array-like behavior. It is not a - concrete implementation, but it can be used up by other classes that want - to appear like arrays. + An `Ember.Binding` connects the properties of two objects so that whenever + the value of one property changes, the other property will be changed also. - For example, ArrayProxy is a concrete classes that can - be instantiated to implement array-like behavior. Both of these classes use - the Array Mixin by way of the MutableArray mixin, which allows observable - changes to be made to the underlying array. + ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. - Unlike `Ember.Enumerable,` this mixin defines methods specifically for - collections that provide index-ordered access to their contents. When you - are designing code that needs to accept any kind of Array-like object, you - should use these methods instead of Array primitives because these will - properly notify observers of changes to the array. + You do not usually create Binding objects directly but instead describe + bindings in your class or object definition using automatic binding + detection. - Although these methods are efficient, they do add a layer of indirection to - your application so it is a good idea to use them only when you need the - flexibility of using both true JavaScript arrays and "virtual" arrays such - as controllers and collections. + Properties ending in a `Binding` suffix will be converted to `Ember.Binding` + instances. The value of this property should be a string representing a path + to another object or a custom binding instance created using Binding helpers + (see "One Way Bindings"): - You can use the methods defined in this module to access and modify array - contents in a KVO-friendly way. You can also be notified whenever the - membership of an array changes by using `.observes('myArray.[]')`. + ``` + valueBinding: "MyApp.someController.title" + ``` - To support `Ember.Array` in your own class, you must override two - primitives to use it: `length()` and `objectAt()`. + This will create a binding from `MyApp.someController.title` to the `value` + property of your object instance automatically. Now the two values will be + kept in sync. - Note that the Ember.Array mixin also incorporates the `Ember.Enumerable` - mixin. All `Ember.Array`-like objects are also enumerable. + ## One Way Bindings - @class Array + One especially useful binding customization you can use is the `oneWay()` + helper. This helper tells Ember that you are only interested in + receiving changes on the object you are binding from. For example, if you + are binding to a preference and you want to be notified if the preference + has changed, but your object will not be changing the preference itself, you + could do: + + ``` + bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") + ``` + + This way if the value of `MyApp.preferencesController.bigTitles` changes the + `bigTitles` property of your object will change also. However, if you + change the value of your `bigTitles` property, it will not update the + `preferencesController`. + + One way bindings are almost twice as fast to setup and twice as fast to + execute because the binding only has to worry about changes to one side. + + You should consider using one way bindings anytime you have an object that + may be created frequently and you do not intend to change a property; only + to monitor it for changes (such as in the example above). + + ## Adding Bindings Manually + + All of the examples above show you how to configure a custom binding, but the + result of these customizations will be a binding template, not a fully active + Binding instance. The binding will actually become active only when you + instantiate the object the binding belongs to. It is useful, however, to + understand what actually happens when the binding is activated. + + For a binding to function it must have at least a `from` property and a `to` + property. The `from` property path points to the object/key that you want to + bind from while the `to` path points to the object/key you want to bind to. + + When you define a custom binding, you are usually describing the property + you want to bind from (such as `MyApp.someController.value` in the examples + above). When your object is created, it will automatically assign the value + you want to bind `to` based on the name of your binding key. In the + examples above, during init, Ember objects will effectively call + something like this on your binding: + + ```javascript + binding = Ember.Binding.from("valueBinding").to("value"); + ``` + + This creates a new binding instance based on the template you provide, and + sets the to path to the `value` property of the new object. Now that the + binding is fully configured with a `from` and a `to`, it simply needs to be + connected to become active. This is done through the `connect()` method: + + ```javascript + binding.connect(this); + ``` + + Note that when you connect a binding you pass the object you want it to be + connected to. This object will be used as the root for both the from and + to side of the binding when inspecting relative paths. This allows the + binding to be automatically inherited by subclassed objects as well. + + This also allows you to bind between objects using the paths you declare in + `from` and `to`: + + ```javascript + // Example 1 + binding = Ember.Binding.from("App.someObject.value").to("value"); + binding.connect(this); + + // Example 2 + binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); + binding.connect(this); + ``` + + Now that the binding is connected, it will observe both the from and to side + and relay changes. + + If you ever needed to do so (you almost never will, but it is useful to + understand this anyway), you could manually create an active binding by + using the `Ember.bind()` helper method. (This is the same method used by + to setup your bindings on objects): + + ```javascript + Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); + ``` + + Both of these code fragments have the same effect as doing the most friendly + form of binding creation like so: + + ```javascript + MyApp.anotherObject = Ember.Object.create({ + valueBinding: "MyApp.someController.value", + + // OTHER CODE FOR THIS OBJECT... + }); + ``` + + Ember's built in binding creation method makes it easy to automatically + create bindings for you. You should always use the highest-level APIs + available, even if you understand how it works underneath. + + @class Binding @namespace Ember - @uses Ember.Enumerable - @since Ember 0.9.0 + @since Ember 0.9 @public */ - var ArrayMixin = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) { - if (idx < 0 || idx >= _emberMetal.get(this, 'length')) { - return undefined; + // Ember.Binding = Binding; ES6TODO: where to put this? + + /** + Global helper method to create a new binding. Just pass the root object + along with a `to` and `from` path to create and connect the binding. + + @method bind + @for Ember + @param {Object} obj The root object of the transform. + @param {String} to The path to the 'to' side of the binding. + Must be relative to obj. + @param {String} from The path to the 'from' side of the binding. + Must be relative to obj or a global path. + @return {Ember.Binding} binding instance + @public + */ + + function bind(obj, to, from) { + return new Binding(to, from).connect(obj); + } + + exports.Binding = Binding; +}); +enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { + 'use strict'; + + var Cache = (function () { + function Cache(limit, func, key, store) { + babelHelpers.classCallCheck(this, Cache); + + this.size = 0; + this.misses = 0; + this.hits = 0; + this.limit = limit; + this.func = func; + this.key = key; + this.store = store || new DefaultStore(); } - return _emberMetal.get(this, idx); - }, _Mixin$create.objectsAt = function (indexes) { - var _this = this; + Cache.prototype.get = function get(obj) { + var key = this.key === undefined ? obj : this.key(obj); + var value = this.store.get(key); + if (value === undefined) { + this.misses++; + value = this._set(key, this.func(obj)); + } else if (value === _emberMetalMeta.UNDEFINED) { + this.hits++; + value = undefined; + } else { + this.hits++; + // nothing to translate + } + + return value; + }; + + Cache.prototype.set = function set(obj, value) { + var key = this.key === undefined ? obj : this.key(obj); + return this._set(key, value); + }; + + Cache.prototype._set = function _set(key, value) { + if (this.limit > this.size) { + this.size++; + if (value === undefined) { + this.store.set(key, _emberMetalMeta.UNDEFINED); + } else { + this.store.set(key, value); + } + } + + return value; + }; + + Cache.prototype.purge = function purge() { + this.store.clear(); + this.size = 0; + this.hits = 0; + this.misses = 0; + }; + + return Cache; + })(); + + exports.default = Cache; - return indexes.map(function (idx) { - return objectAt(_this, idx); - }); - }, _Mixin$create.nextObject = function (idx) { - return objectAt(this, idx); - }, _Mixin$create['[]'] = _emberMetal.computed({ - get: function (key) { - return this; - }, - set: function (key, value) { - this.replace(0, _emberMetal.get(this, 'length'), value); - return this; - } - }), _Mixin$create.firstObject = _emberMetal.computed(function () { - return objectAt(this, 0); - }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () { - return objectAt(this, _emberMetal.get(this, 'length') - 1); - }).readOnly(), _Mixin$create.contains = function (obj) { - if (true) { - _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); + var DefaultStore = (function () { + function DefaultStore() { + babelHelpers.classCallCheck(this, DefaultStore); + + this.data = new _emberUtils.EmptyObject(); } - return this.indexOf(obj) >= 0; - }, _Mixin$create.slice = function (beginIndex, endIndex) { - var ret = _emberMetal.default.A(); - var length = _emberMetal.get(this, 'length'); + DefaultStore.prototype.get = function get(key) { + return this.data[key]; + }; - if (_emberMetal.isNone(beginIndex)) { - beginIndex = 0; - } + DefaultStore.prototype.set = function set(key, value) { + this.data[key] = value; + }; - if (_emberMetal.isNone(endIndex) || endIndex > length) { - endIndex = length; - } + DefaultStore.prototype.clear = function clear() { + this.data = new _emberUtils.EmptyObject(); + }; - if (beginIndex < 0) { - beginIndex = length + beginIndex; - } + return DefaultStore; + })(); +}); +enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/computed', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalComputed, _emberMetalWatch_path) { + 'use strict'; - if (endIndex < 0) { - endIndex = length + endIndex; - } + exports.finishChains = finishChains; - while (beginIndex < endIndex) { - ret[ret.length] = objectAt(this, beginIndex++); - } + var FIRST_KEY = /^([^\.]+)/; - return ret; - }, _Mixin$create.indexOf = function (object, startAt) { - var len = _emberMetal.get(this, 'length'); + function firstKey(path) { + return path.match(FIRST_KEY)[0]; + } - if (startAt === undefined) { - startAt = 0; - } + function isObject(obj) { + return typeof obj === 'object' && obj; + } - if (startAt < 0) { - startAt += len; - } + function isVolatile(obj) { + return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); + } - for (var idx = startAt; idx < len; idx++) { - if (objectAt(this, idx) === object) { - return idx; - } + var ChainWatchers = (function () { + function ChainWatchers() { + babelHelpers.classCallCheck(this, ChainWatchers); + + // chain nodes that reference a key in this obj by key + // we only create ChainWatchers when we are going to add them + // so create this upfront + this.chains = new _emberUtils.EmptyObject(); } - return -1; - }, _Mixin$create.lastIndexOf = function (object, startAt) { - var len = _emberMetal.get(this, 'length'); + ChainWatchers.prototype.add = function add(key, node) { + var nodes = this.chains[key]; + if (nodes === undefined) { + this.chains[key] = [node]; + } else { + nodes.push(node); + } + }; - if (startAt === undefined || startAt >= len) { - startAt = len - 1; - } + ChainWatchers.prototype.remove = function remove(key, node) { + var nodes = this.chains[key]; + if (nodes) { + for (var i = 0; i < nodes.length; i++) { + if (nodes[i] === node) { + nodes.splice(i, 1); + break; + } + } + } + }; - if (startAt < 0) { - startAt += len; - } + ChainWatchers.prototype.has = function has(key, node) { + var nodes = this.chains[key]; + if (nodes) { + for (var i = 0; i < nodes.length; i++) { + if (nodes[i] === node) { + return true; + } + } + } + return false; + }; - for (var idx = startAt; idx >= 0; idx--) { - if (objectAt(this, idx) === object) { - return idx; + ChainWatchers.prototype.revalidateAll = function revalidateAll() { + for (var key in this.chains) { + this.notify(key, true, undefined); } - } + }; - return -1; - }, _Mixin$create.addArrayObserver = function (target, opts) { - return addArrayObserver(this, target, opts); - }, _Mixin$create.removeArrayObserver = function (target, opts) { - return removeArrayObserver(this, target, opts); - }, _Mixin$create.hasArrayObservers = _emberMetal.computed(function () { - return _emberMetal.hasListeners(this, '@array:change') || _emberMetal.hasListeners(this, '@array:before'); - }), _Mixin$create.arrayContentWillChange = function (startIdx, removeAmt, addAmt) { - return arrayContentWillChange(this, startIdx, removeAmt, addAmt); - }, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) { - return arrayContentDidChange(this, startIdx, removeAmt, addAmt); - }, _Mixin$create['@each'] = _emberMetal.computed(function () { - // TODO use Symbol or add to meta - if (!this.__each) { - this.__each = new _emberRuntimeSystemEach_proxy.default(this); - } + ChainWatchers.prototype.revalidate = function revalidate(key) { + this.notify(key, true, undefined); + }; - return this.__each; - }).volatile().readOnly(), _Mixin$create)); + // key: the string key that is part of a path changed + // revalidate: boolean; the chains that are watching this value should revalidate + // callback: function that will be called with the object and path that + // will be/are invalidated by this key change, depending on + // whether the revalidate flag is passed - if (true) { - ArrayMixin.reopen({ - /** - Returns `true` if the passed object can be found in the array. - This method is a Polyfill for ES 2016 Array.includes. - If no `startAt` argument is given, the starting location to - search is 0. If it's negative, searches from the index of - `this.length + startAt` by asc. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, 3].includes(3, 2); // true - [1, 2, 3].includes(3, 3); // false - [1, 2, 3].includes(3, -1); // true - [1, 2, 3].includes(1, -1); // false - [1, 2, 3].includes(1, -4); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @param {Number} startAt optional starting location to search, default 0 - @return {Boolean} `true` if object is found in the array. - @public - */ - includes: function (obj, startAt) { - var len = _emberMetal.get(this, 'length'); + ChainWatchers.prototype.notify = function notify(key, revalidate, callback) { + var nodes = this.chains[key]; + if (nodes === undefined || nodes.length === 0) { + return; + } - if (startAt === undefined) { - startAt = 0; - } + var affected = undefined; - if (startAt < 0) { - startAt += len; - } + if (callback) { + affected = []; + } - for (var idx = startAt; idx < len; idx++) { - var currentObj = objectAt(this, idx); + for (var i = 0; i < nodes.length; i++) { + nodes[i].notify(revalidate, affected); + } - // SameValueZero comparison (NaN !== NaN) - if (obj === currentObj || obj !== obj && currentObj !== currentObj) { - return true; - } - } + if (callback === undefined) { + return; + } - return false; + // we gather callbacks so we don't notify them during revalidation + for (var i = 0; i < affected.length; i += 2) { + var obj = affected[i]; + var path = affected[i + 1]; + callback(obj, path); } - }); + }; + + return ChainWatchers; + })(); + + function makeChainWatcher() { + return new ChainWatchers(); } - exports.default = ArrayMixin; -}); -// ES6TODO: Ember.A + function addChainWatcher(obj, keyName, node) { + var m = _emberMetalMeta.meta(obj); + m.writableChainWatchers(makeChainWatcher).add(keyName, node); + _emberMetalWatch_key.watchKey(obj, keyName, m); + } -/** - __Required.__ You must implement this method to apply this mixin. - Your array must support the `length` property. Your replace methods should - set this property whenever it changes. - @property {Number} length - @public -*/ + function removeChainWatcher(obj, keyName, node, _meta) { + if (!isObject(obj)) { + return; + } -/** - Returns the object at the given `index`. If the given `index` is negative - or is greater or equal than the array length, returns `undefined`. - This is one of the primitives you must implement to support `Ember.Array`. - If your object supports retrieving the value of an array item using `get()` - (i.e. `myArray.get(0)`), then you do not need to implement this method - yourself. - ```javascript - let arr = ['a', 'b', 'c', 'd']; - arr.objectAt(0); // 'a' - arr.objectAt(3); // 'd' - arr.objectAt(-1); // undefined - arr.objectAt(4); // undefined - arr.objectAt(5); // undefined - ``` - @method objectAt - @param {Number} idx The index of the item to return. - @return {*} item at index or undefined - @public -*/ + var meta = _meta || _emberMetalMeta.peekMeta(obj); -/** - This returns the objects at the specified indexes, using `objectAt`. - ```javascript - let arr = ['a', 'b', 'c', 'd']; - arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] - arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] - ``` - @method objectsAt - @param {Array} indexes An array of indexes of items to return. - @return {Array} - @public - */ + if (!meta || !meta.readableChainWatchers()) { + return; + } -// overrides Ember.Enumerable version + // make meta writable + meta = _emberMetalMeta.meta(obj); -/** - 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 - array, it will replace the current content. - This property overrides the default property defined in `Ember.Enumerable`. - @property [] - @return this - @public -*/ + meta.readableChainWatchers().remove(keyName, node); -// optimized version from Enumerable + _emberMetalWatch_key.unwatchKey(obj, keyName, meta); + } -// Add any extra methods to Ember.Array that are native to the built-in Array. -/** - Returns a new array that is a slice of the receiver. This implementation - uses the observable array methods to retrieve the objects for the new - slice. - ```javascript - let arr = ['red', 'green', 'blue']; - arr.slice(0); // ['red', 'green', 'blue'] - arr.slice(0, 2); // ['red', 'green'] - arr.slice(1, 100); // ['green', 'blue'] - ``` - @method slice - @param {Number} beginIndex (Optional) index to begin slicing from. - @param {Number} endIndex (Optional) index to end the slice at (but not included). - @return {Array} New array with specified slice - @public -*/ + // A ChainNode watches a single key on an object. If you provide a starting + // value for the key then the node won't actually watch it. For a root node + // pass null for parent and key and object for value. -/** - Returns the index of the given object's first occurrence. - If no `startAt` argument is given, the starting location to - search is 0. If it's negative, will count backward from - the end of the array. Returns -1 if no match is found. - ```javascript - let arr = ['a', 'b', 'c', 'd', 'a']; - arr.indexOf('a'); // 0 - arr.indexOf('z'); // -1 - arr.indexOf('a', 2); // 4 - arr.indexOf('a', -1); // 4 - arr.indexOf('b', 3); // -1 - arr.indexOf('a', 100); // -1 - ``` - @method indexOf - @param {Object} object the item to search for - @param {Number} startAt optional starting location to search, default 0 - @return {Number} index or -1 if not found - @public -*/ + var ChainNode = (function () { + function ChainNode(parent, key, value) { + babelHelpers.classCallCheck(this, ChainNode); -/** - Returns the index of the given object's last occurrence. - If no `startAt` argument is given, the search starts from - the last position. If it's negative, will count backward - from the end of the array. Returns -1 if no match is found. - ```javascript - let arr = ['a', 'b', 'c', 'd', 'a']; - arr.lastIndexOf('a'); // 4 - arr.lastIndexOf('z'); // -1 - arr.lastIndexOf('a', 2); // 0 - arr.lastIndexOf('a', -1); // 4 - arr.lastIndexOf('b', 3); // 1 - arr.lastIndexOf('a', 100); // 4 - ``` - @method lastIndexOf - @param {Object} object the item to search for - @param {Number} startAt optional starting location to search, default 0 - @return {Number} index or -1 if not found - @public -*/ + this._parent = parent; + this._key = key; -// .......................................................... -// ARRAY OBSERVERS -// + // _watching is true when calling get(this._parent, this._key) will + // return the value of this node. + // + // It is false for the root of a chain (because we have no parent) + // and for global paths (because the parent node is the object with + // the observer on it) + this._watching = value === undefined; -/** - Adds an array observer to the receiving array. The array observer object - normally must implement two methods: - * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be - called just before the array is modified. - * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be - called just after the array is modified. - Both callbacks will be passed the observed object, starting index of the - change as well as a count of the items to be removed and added. You can use - these callbacks to optionally inspect the array during the change, clear - caches, or do any other bookkeeping necessary. - In addition to passing a target, you can also include an options hash - which you can use to override the method names that will be invoked on the - target. - @method addArrayObserver - @param {Object} target The observer object. - @param {Object} opts Optional hash of configuration options including - `willChange` and `didChange` option. - @return {Ember.Array} receiver - @public -*/ + this._chains = undefined; + this._object = undefined; + this.count = 0; -/** - Removes an array observer from the object if the observer is current - registered. Calling this method multiple times with the same object will - have no effect. - @method removeArrayObserver - @param {Object} target The object observing the array. - @param {Object} opts Optional hash of configuration options including - `willChange` and `didChange` option. - @return {Ember.Array} receiver - @public -*/ + this._value = value; + this._paths = {}; + if (this._watching) { + var obj = parent.value(); -/** - Becomes true whenever the array currently has observers watching changes - on the array. - @property {Boolean} hasArrayObservers - @public -*/ + if (!isObject(obj)) { + return; + } -/** - If you are implementing an object that supports `Ember.Array`, call this - method just before the array content changes to notify any observers and - invalidate any related properties. Pass the starting index of the change - as well as a delta of the amounts to change. - @method arrayContentWillChange - @param {Number} startIdx The starting index in the array that will change. - @param {Number} removeAmt The number of items that will be removed. If you - pass `null` assumes 0 - @param {Number} addAmt The number of items that will be added. If you - pass `null` assumes 0. - @return {Ember.Array} receiver - @public -*/ + this._object = obj; -/** - If you are implementing an object that supports `Ember.Array`, call this - method just after the array content changes to notify any observers and - invalidate any related properties. Pass the starting index of the change - as well as a delta of the amounts to change. - @method arrayContentDidChange - @param {Number} startIdx The starting index in the array that did change. - @param {Number} removeAmt The number of items that were removed. If you - pass `null` assumes 0 - @param {Number} addAmt The number of items that were added. If you - pass `null` assumes 0. - @return {Ember.Array} receiver - @public -*/ + addChainWatcher(this._object, this._key, this); + } + } -/** - Returns a special object that can be used to observe individual properties - on the array. Just get an equivalent property on this object and it will - return an enumerable that maps automatically to the named key on the - member objects. - `@each` should only be used in a non-terminal context. Example: - ```javascript - myMethod: computed('posts.@each.author', function(){ - ... - }); - ``` - If you merely want to watch for the array being changed, like an object being - replaced, added or removed, use `[]` instead of `@each`. - ```javascript - myMethod: computed('posts.[]', function(){ - ... - }); - ``` - @property @each - @public -*/ -enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + ChainNode.prototype.value = function value() { + if (this._value === undefined && this._watching) { + var obj = this._parent.value(); + this._value = lazyGet(obj, this._key); + } + return this._value; + }; - /** - @module ember - @submodule ember-runtime - */ + ChainNode.prototype.destroy = function destroy() { + if (this._watching) { + var obj = this._object; + if (obj) { + removeChainWatcher(obj, this._key, this); + } + this._watching = false; // so future calls do nothing + } + }; - /** - Implements some standard methods for comparing objects. Add this mixin to - any class you create that can compare its instances. - - You should implement the `compare()` method. - - @class Comparable - @namespace Ember - @since Ember 0.9 - @private - */ - exports.default = _emberMetal.Mixin.create({ + // copies a top level object only - /** - __Required.__ You must implement this method to apply this mixin. - Override to return the result of the comparison of the two parameters. The - compare method should return: - - `-1` if `a < b` - - `0` if `a == b` - - `1` if `a > b` - Default implementation raises an exception. - @method compare - @param a {Object} the first object to compare - @param b {Object} the second object to compare - @return {Number} the result of the comparison - @private - */ - compare: null - }); -}); -enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ - 'use strict'; + ChainNode.prototype.copy = function copy(obj) { + var ret = new ChainNode(null, null, obj); + var paths = this._paths; + var path = undefined; + + for (path in paths) { + // this check will also catch non-number vals. + if (paths[path] <= 0) { + continue; + } + ret.add(path); + } + return ret; + }; + + // called on the root node of a chain to setup watchers on the specified + // path. + + ChainNode.prototype.add = function add(path) { + var paths = this._paths; + paths[path] = (paths[path] || 0) + 1; + + var key = firstKey(path); + var tail = path.slice(key.length + 1); + + this.chain(key, tail); + }; + + // called on the root node of a chain to teardown watcher on the specified + // path + + ChainNode.prototype.remove = function remove(path) { + var paths = this._paths; + if (paths[path] > 0) { + paths[path]--; + } + + var key = firstKey(path); + var tail = path.slice(key.length + 1); + + this.unchain(key, tail); + }; - /** - ContainerProxyMixin is used to provide public access to specific - container functionality. - - @class ContainerProxyMixin - @private - */ - exports.default = _emberMetal.Mixin.create({ - /** - The container stores state. - @private - @property {Ember.Container} __container__ - */ - __container__: null, + ChainNode.prototype.chain = function chain(key, path) { + var chains = this._chains; + var node = undefined; + if (chains === undefined) { + chains = this._chains = new _emberUtils.EmptyObject(); + } else { + node = chains[key]; + } - /** - Returns an object that can be used to provide an owner to a - manually created instance. - Example: - ``` - let owner = Ember.getOwner(this); - User.create( - owner.ownerInjection(), - { username: 'rwjblue' } - ) - ``` - @public - @method ownerInjection - @return {Object} - */ - ownerInjection: function () { - return this.__container__.ownerInjection(); - }, + if (node === undefined) { + node = chains[key] = new ChainNode(this, key, undefined); + } - /** - Given a fullName return a corresponding instance. - The default behaviour is for lookup to return a singleton instance. - The singleton is scoped to the container, allowing multiple containers - to all have their own locally scoped singletons. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter'); - twitter instanceof Twitter; // => true - // by default the container will return singletons - let twitter2 = container.lookup('api:twitter'); - twitter2 instanceof Twitter; // => true - twitter === twitter2; //=> true - ``` - If singletons are not wanted an optional flag can be provided at lookup. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter', { singleton: false }); - let twitter2 = container.lookup('api:twitter', { singleton: false }); - twitter === twitter2; //=> false - ``` - @public - @method lookup - @param {String} fullName - @param {Object} options - @return {any} - */ - lookup: function (fullName, options) { - return this.__container__.lookup(fullName, options); - }, + node.count++; // count chains... - /** - Given a fullName return the corresponding factory. - @private - @method _lookupFactory - @param {String} fullName - @return {any} - */ - _lookupFactory: function (fullName, options) { - return this.__container__.lookupFactory(fullName, options); - }, + // chain rest of path if there is one + if (path) { + key = firstKey(path); + path = path.slice(key.length + 1); + node.chain(key, path); + } + }; - /** - Given a name and a source path, resolve the fullName - @private - @method _resolveLocalLookupName - @param {String} fullName - @param {String} source - @return {String} - */ - _resolveLocalLookupName: function (name, source) { - return this.__container__.registry.expandLocalLookup('component:' + name, { - source: source - }); - }, + ChainNode.prototype.unchain = function unchain(key, path) { + var chains = this._chains; + var node = chains[key]; - /** - @private - */ - willDestroy: function () { - this._super.apply(this, arguments); + // unchain rest of path first... + if (path && path.length > 1) { + var nextKey = firstKey(path); + var nextPath = path.slice(nextKey.length + 1); + node.unchain(nextKey, nextPath); + } - if (this.__container__) { - _emberMetal.run(this.__container__, 'destroy'); + // delete node if needed. + node.count--; + if (node.count <= 0) { + chains[node._key] = undefined; + node.destroy(); } - } - }); -}); -enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) { - 'use strict'; + }; - /** - @class ControllerMixin - @namespace Ember - @uses Ember.ActionHandler - @private - */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, { - /* ducktype as a controller */ - isController: true, + ChainNode.prototype.notify = function notify(revalidate, affected) { + if (revalidate && this._watching) { + var parentValue = this._parent.value(); - /** - The object to which actions from the view should be sent. - For example, when a Handlebars template uses the `{{action}}` helper, - it will attempt to send the action to the view's controller's `target`. - By default, the value of the target property is set to the router, and - is injected when a controller is instantiated. This injection is applied - as part of the application's initialization process. In most cases the - `target` property will automatically be set to the logical consumer of - actions for the controller. - @property target - @default null - @public - */ - target: null, + if (parentValue !== this._object) { + if (this._object) { + removeChainWatcher(this._object, this._key, this); + } - store: null, + if (isObject(parentValue)) { + this._object = parentValue; + addChainWatcher(parentValue, this._key, this); + } else { + this._object = undefined; + } + } + this._value = undefined; + } - /** - The controller's current model. When retrieving or modifying a controller's - model, this property should be used instead of the `content` property. - @property model - @public - */ - model: null, + // then notify chains... + var chains = this._chains; + var node = undefined; + if (chains) { + for (var key in chains) { + node = chains[key]; + if (node !== undefined) { + node.notify(revalidate, affected); + } + } + } - /** - @private - */ - content: _emberMetal.alias('model') + if (affected && this._parent) { + this._parent.populateAffected(this._key, 1, affected); + } + }; - }); -}); -enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + ChainNode.prototype.populateAffected = function populateAffected(path, depth, affected) { + if (this._key) { + path = this._key + '.' + path; + } - /* - The ControllerContentModelAliasDeprecation mixin is used to provide a useful - deprecation warning when specifying `content` directly on a `Ember.Controller` - (without also specifying `model`). - - Ember versions prior to 1.7 used `model` as an alias of `content`, but due to - much confusion this alias was reversed (so `content` is now an alias of `model). - - This change reduces many caveats with model/content, and also sets a - simple ground rule: Never set a controllers content, rather always set - its model and ember will do the right thing. - - Used internally by Ember in `Ember.Controller`. - */ - exports.default = _emberMetal.Mixin.create({ - /** - @private - Moves `content` to `model` at extend time if a `model` is not also specified. - Note that this currently modifies the mixin themselves, which is technically - dubious but is practically of little consequence. This may change in the - future. - @method willMergeMixin - @since 1.4.0 - */ - willMergeMixin: function (props) { - // Calling super is only OK here since we KNOW that - // there is another Mixin loaded first. - this._super.apply(this, arguments); + if (this._parent) { + this._parent.populateAffected(path, depth + 1, affected); + } else { + if (depth > 1) { + affected.push(this.value(), path); + } + } + }; - var modelSpecified = !!props.model; + return ChainNode; + })(); - if (props.content && !modelSpecified) { - props.model = props.content; - delete props['content']; + function lazyGet(obj, key) { + if (!isObject(obj)) { + return; + } - _emberMetal.deprecate('Do not specify `content` on a Controller, use `model` instead.', false, { id: 'ember-runtime.will-merge-mixin', until: '3.0.0' }); + var meta = _emberMetalMeta.peekMeta(obj); + + // check if object meant only to be a prototype + if (meta && meta.proto === obj) { + return; + } + + // Use `get` if the return value is an EachProxy or an uncacheable value. + if (isVolatile(obj[key])) { + return _emberMetalProperty_get.get(obj, key); + // Otherwise attempt to get the cached value of the computed property + } else { + var cache = meta.readableCache(); + if (cache) { + return _emberMetalComputed.cacheFor.get(cache, key); + } + } + } + + function finishChains(obj) { + // We only create meta if we really have to + var m = _emberMetalMeta.peekMeta(obj); + if (m) { + m = _emberMetalMeta.meta(obj); + + // finish any current chains node watchers that reference obj + var chainWatchers = m.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidateAll(); + } + // ensure that if we have inherited any chains they have been + // copied onto our own meta. + if (m.readableChains()) { + m.writableChains(_emberMetalWatch_path.makeChainNode); } } - }); + } + + exports.removeChainWatcher = removeChainWatcher; + exports.ChainNode = ChainNode; }); -enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal', 'ember-runtime/mixins/freezable'], function (exports, _emberMetal, _emberRuntimeMixinsFreezable) { +enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) { + 'use strict'; + + exports.default = computed; + /** @module ember - @submodule ember-runtime + @submodule ember-metal */ - 'use strict'; + var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; /** - Implements some standard methods for copying an object. Add this mixin to - any object you create that can create a copy of itself. This mixin is - added automatically to the built-in array. + A computed property transforms an object literal with object's accessor function(s) into a property. - You should generally implement the `copy()` method to return a copy of the - receiver. + 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. - Note that `frozenCopy()` will only work if you also implement - `Ember.Freezable`. + In the following example we declare a computed property - `fullName` - by calling + `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter 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. - @class Copyable + ```javascript + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', function() { + let firstName = this.get('firstName'), + lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + }) + }); + + let 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 by providing additional function (`set`) in hash argument. + If you try to set a computed property, it will try to invoke setter accessor function with the key and + value you want to set it to as arguments. + + ```javascript + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + let firstName = this.get('firstName'), + lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + }, + set(key, value) { + let [firstName, lastName] = value.split(' '); + + this.set('firstName', firstName); + this.set('lastName', lastName); + + return value; + } + }) + }); + + let person = Person.create(); + + person.set('fullName', 'Peter Wagenet'); + person.get('firstName'); // 'Peter' + person.get('lastName'); // 'Wagenet' + ``` + + You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined. + + You can also mark computed property as `.readOnly()` and block all attempts to set it. + + ```javascript + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + let firstName = this.get('firstName'); + let lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + } + }).readOnly() + }); + + let person = Person.create(); + person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX> + ``` + + Additional resources: + - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md) + - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax) + + @class ComputedProperty @namespace Ember - @since Ember 0.9 - @private + @public */ - exports.default = _emberMetal.Mixin.create({ - /** - __Required.__ You must implement this method to apply this mixin. - Override to return a copy of the receiver. Default implementation raises - an exception. - @method copy - @param {Boolean} deep if `true`, a deep copy of the object should be made - @return {Object} copy of receiver - @private - */ - copy: null, - - /** - If the object implements `Ember.Freezable`, then this will return a new - copy if the object is not frozen and the receiver if the object is frozen. - Raises an exception if you try to call this method on a object that does - not support freezing. - You should use this method whenever you want a copy of a freezable object - since a freezable object can simply return itself without actually - consuming more memory. - @method frozenCopy - @return {Object} copy of receiver or receiver - @deprecated Use `Object.freeze` instead. - @private - */ - frozenCopy: function () { - _emberMetal.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.frozen-copy', until: '3.0.0' }); - if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) { - return _emberMetal.get(this, 'isFrozen') ? this : this.copy().freeze(); - } else { - throw new _emberMetal.Error(this + ' does not support freezing'); - } + function ComputedProperty(config, opts) { + this.isDescriptor = true; + if (typeof config === 'function') { + this._getter = config; + } else { + _emberMetalDebug.assert('Ember.computed expects a function or an object as last argument.', typeof config === 'object' && !Array.isArray(config)); + _emberMetalDebug.assert('Config object passed to an Ember.computed can only contain `get` or `set` keys.', (function () { + var keys = Object.keys(config); + for (var i = 0; i < keys.length; i++) { + if (keys[i] !== 'get' && keys[i] !== 'set') { + return false; + } + } + return true; + })()); + this._getter = config.get; + this._setter = config.set; } - }); -}); -enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'require'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _require) { - /** - @module ember - @submodule ember-runtime - */ - - // .......................................................... - // HELPERS - // - - 'use strict'; - - var _emberA = undefined; - - function emberA() { - return (_emberA || (_emberA = _require.default('ember-runtime/system/native_array').A))(); - } - - var contexts = []; - - function popCtx() { - return contexts.length === 0 ? {} : contexts.pop(); + _emberMetalDebug.assert('Computed properties must receive a getter or a setter, you passed none.', !!this._getter || !!this._setter); + this._dependentKeys = undefined; + this._suspended = undefined; + this._meta = undefined; + this._volatile = false; + this._dependentKeys = opts && opts.dependentKeys; + this._readOnly = false; } - function pushCtx(ctx) { - contexts.push(ctx); - return null; - } + ComputedProperty.prototype = new _emberMetalProperties.Descriptor(); + ComputedProperty.prototype.constructor = ComputedProperty; - function iter(key, value) { - var valueProvided = arguments.length === 2; + var ComputedPropertyPrototype = ComputedProperty.prototype; - function i(item) { - var cur = _emberMetal.get(item, key); - return valueProvided ? value === cur : !!cur; - } + /** + 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. + + It also does not automatically fire any change events. You must manually notify + any changes if you want to observe this property. + + Dependency keys have no effect on volatile properties as they are for cache + invalidation and notification when cached value is invalidated. + + ```javascript + let outsideService = Ember.Object.extend({ + value: Ember.computed(function() { + return OutsideService.getValue(); + }).volatile() + }).create(); + ``` + + @method volatile + @return {Ember.ComputedProperty} this + @chainable + @public + */ + ComputedPropertyPrototype.volatile = function () { + this._volatile = true; + return this; + }; - return i; - } + /** + 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 + let Person = Ember.Object.extend({ + guid: Ember.computed(function() { + return 'guid-guid-guid'; + }).readOnly() + }); + + let person = Person.create(); + + person.set('guid', 'new-guid'); // will throw an exception + ``` + + @method readOnly + @return {Ember.ComputedProperty} this + @chainable + @public + */ + ComputedPropertyPrototype.readOnly = function () { + this._readOnly = true; + _emberMetalDebug.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; + }; /** - This mixin defines the common interface implemented by enumerable objects - in Ember. Most of these methods follow the standard Array iteration - API defined up to JavaScript 1.8 (excluding language-specific features that - cannot be emulated in older versions of JavaScript). + Sets the dependent keys on this computed property. Pass any number of + arguments containing key paths that this computed property depends on. - This mixin is applied automatically to the Array class on page load, so you - can use any of these methods on simple arrays. If Array already implements - one of these methods, the mixin will not override them. + ```javascript + let President = Ember.Object.extend({ + fullName: Ember.computed(function() { + return this.get('firstName') + ' ' + this.get('lastName'); - ## Writing Your Own Enumerable + // Tell Ember that this computed property depends on firstName + // and lastName + }).property('firstName', 'lastName') + }); - To make your own custom class enumerable, you need two items: + let president = President.create({ + firstName: 'Barack', + lastName: 'Obama' + }); - 1. You must have a length property. This property should change whenever - the number of items in your enumerable object changes. If you use this - with an `Ember.Object` subclass, you should be sure to change the length - property using `set().` + president.get('fullName'); // 'Barack Obama' + ``` - 2. You must implement `nextObject().` See documentation. + @method property + @param {String} path* zero or more property paths + @return {Ember.ComputedProperty} this + @chainable + @public + */ + ComputedPropertyPrototype.property = function () { + var args = []; + + function addArg(property) { + _emberMetalDebug.warn('Dependent keys containing @each only work one level deep. ' + ('You used the key "' + property + '" which is invalid. ') + 'Please create an intermediary computed property.', DEEP_EACH_REGEX.test(property) === false, { id: 'ember-metal.computed-deep-each' }); + args.push(property); + } + + for (var i = 0; i < arguments.length; 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. - Once you have these two methods implemented, apply the `Ember.Enumerable` mixin - to your class and you will be able to enumerate the contents of your object - like any other collection. + You can pass a hash of these values to a computed property like this: - ## Using Ember Enumeration with Other Libraries + ``` + person: Ember.computed(function() { + let personId = this.get('personId'); + return App.Person.create({ id: personId }); + }).meta({ type: App.Person }) + ``` - Many other libraries provide some kind of iterator or enumeration like - facility. This is often where the most common API conflicts occur. - Ember's API is designed to be as friendly as possible with other - libraries by implementing only methods that mostly correspond to the - JavaScript 1.8 API. + 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. - @class Enumerable - @namespace Ember - @since Ember 0.9 - @private + @method meta + @param {Object} meta + @chainable + @public */ - var Enumerable = _emberMetal.Mixin.create({ + ComputedPropertyPrototype.meta = function (meta) { + if (arguments.length === 0) { + return this._meta || {}; + } else { + this._meta = meta; + return this; + } + }; - /** - __Required.__ You must implement this method to apply this mixin. - Implement this method to make your class enumerable. - This method will be called repeatedly during enumeration. The index value - will always begin with 0 and increment monotonically. You don't have to - rely on the index value to determine what object to return, but you should - always check the value and start from the beginning when you see the - requested index is 0. - The `previousObject` is the object that was returned from the last call - to `nextObject` for the current iteration. This is a useful way to - manage iteration if you are tracing a linked list, for example. - Finally the context parameter will always contain a hash you can use as - a "scratchpad" to maintain any other state you need in order to iterate - properly. The context object is reused and is not reset between - iterations so make sure you setup the context with a fresh state whenever - the index parameter is 0. - Generally iterators will continue to call `nextObject` until the index - reaches the current length-1. If you run out of data before this - time for some reason, you should simply return undefined. - The default implementation of this method simply looks up the index. - This works great on any Array-like objects. - @method nextObject - @param {Number} index the current index of the iteration - @param {Object} previousObject the value returned by the last call to - `nextObject`. - @param {Object} context a context object you can use to maintain state. - @return {Object} the next object in the iteration or undefined - @private - */ - nextObject: null, + // invalidate cache when CP key changes + 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._volatile || this._suspended === obj) { + return; + } - /** - Helper method returns the first object from a collection. This is usually - used by bindings and other parts of the framework to extract a single - object if the enumerable contains only one item. - If you override this method, you should implement it so that it will - always return the same value each time it is called. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - ```javascript - let arr = ['a', 'b', 'c']; - arr.get('firstObject'); // 'a' - let arr = []; - arr.get('firstObject'); // undefined - ``` - @property firstObject - @return {Object} the object or undefined - @readOnly - @public - */ - firstObject: _emberMetal.computed('[]', function () { - if (_emberMetal.get(this, 'length') === 0) { - return undefined; - } + // don't create objects just to invalidate + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta || meta.source !== obj) { + return; + } - // handle generic enumerables - var context = popCtx(); - var ret = this.nextObject(0, null, context); + var cache = meta.readableCache(); + if (cache && cache[keyName] !== undefined) { + cache[keyName] = undefined; + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + } + }; - pushCtx(context); + ComputedPropertyPrototype.get = function (obj, keyName) { + if (this._volatile) { + return this._getter.call(obj, keyName); + } - return ret; - }).readOnly(), + var meta = _emberMetalMeta.meta(obj); + var cache = meta.writableCache(); - /** - Helper method returns the last object from a collection. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - ```javascript - let arr = ['a', 'b', 'c']; - arr.get('lastObject'); // 'c' - let arr = []; - arr.get('lastObject'); // undefined - ``` - @property lastObject - @return {Object} the last object or undefined - @readOnly - @public - */ - lastObject: _emberMetal.computed('[]', function () { - var len = _emberMetal.get(this, 'length'); + var result = cache[keyName]; + if (result === _emberMetalMeta.UNDEFINED) { + return undefined; + } else if (result !== undefined) { + return result; + } - if (len === 0) { - return undefined; - } + var ret = this._getter.call(obj, keyName); + if (ret === undefined) { + cache[keyName] = _emberMetalMeta.UNDEFINED; + } else { + cache[keyName] = ret; + } - var context = popCtx(); - var idx = 0; - var last = null; - var cur = undefined; + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidate(keyName); + } + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - do { - last = cur; - cur = this.nextObject(idx++, last, context); - } while (cur !== undefined); + return ret; + }; - pushCtx(context); + ComputedPropertyPrototype.set = function computedPropertySetEntry(obj, keyName, value) { + if (this._readOnly) { + this._throwReadOnlyError(obj, keyName); + } - return last; - }).readOnly(), + if (!this._setter) { + return this.clobberSet(obj, keyName, value); + } - /** - Returns `true` if the passed object can be found in the receiver. The - default version will iterate through the enumerable until the object - is found. You may want to override this with a more efficient version. - ```javascript - let arr = ['a', 'b', 'c']; - arr.contains('a'); // true - arr.contains('z'); // false - ``` - @method contains - @deprecated Use `Enumerable#includes` instead. See http://emberjs.com/deprecations/v2.x#toc_enumerable-contains - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in enumerable. - @public - */ - contains: function (obj) { - if (true) { - _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - } + if (this._volatile) { + return this.volatileSet(obj, keyName, value); + } - var found = this.find(function (item) { - return item === obj; - }); + return this.setWithSuspend(obj, keyName, value); + }; - return found !== undefined; - }, + ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) { + throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj)); + }; - /** - Iterates through the enumerable, calling the passed function on each - item. This method corresponds to the `forEach()` method defined in - JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method forEach - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Object} receiver - @public - */ - forEach: function (callback, target) { - if (typeof callback !== 'function') { - throw new TypeError(); - } + ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) { + var cachedValue = cacheFor(obj, keyName); + _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue); + _emberMetalProperty_set.set(obj, keyName, value); + return value; + }; - var context = popCtx(); - var len = _emberMetal.get(this, 'length'); - var last = null; + ComputedPropertyPrototype.volatileSet = function computedPropertyVolatileSet(obj, keyName, value) { + return this._setter.call(obj, keyName, value); + }; - if (target === undefined) { - target = null; - } + ComputedPropertyPrototype.setWithSuspend = function computedPropertySetWithSuspend(obj, keyName, value) { + var oldSuspended = this._suspended; + this._suspended = obj; + try { + return this._set(obj, keyName, value); + } finally { + this._suspended = oldSuspended; + } + }; - for (var idx = 0; idx < len; idx++) { - var next = this.nextObject(idx, last, context); - callback.call(target, next, idx, this); - last = next; + ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { + // cache requires own meta + var meta = _emberMetalMeta.meta(obj); + // either there is a writable cache or we need one to update + var cache = meta.writableCache(); + var hadCachedValue = false; + var cachedValue = undefined; + if (cache[keyName] !== undefined) { + if (cache[keyName] !== _emberMetalMeta.UNDEFINED) { + cachedValue = cache[keyName]; } + hadCachedValue = true; + } - last = null; - context = pushCtx(context); + var ret = this._setter.call(obj, keyName, value, cachedValue); - return this; - }, + // allows setter to return the same value that is cached already + if (hadCachedValue && cachedValue === ret) { + return ret; + } - /** - Alias for `mapBy` - @method getEach - @param {String} key name of the property - @return {Array} The mapped array. - @public - */ - getEach: _emberMetal.aliasMethod('mapBy'), + _emberMetalProperty_events.propertyWillChange(obj, keyName); - /** - Sets the value on the named property for each member. This is more - ergonomic than using other methods defined on this helper. If the object - implements Ember.Observable, the value will be changed to `set(),` otherwise - it will be set directly. `null` objects are skipped. - @method setEach - @param {String} key The key to set - @param {Object} value The object to set - @return {Object} receiver - @public - */ - setEach: function (key, value) { - return this.forEach(function (item) { - return _emberMetal.set(item, key, value); - }); - }, + if (hadCachedValue) { + cache[keyName] = undefined; + } - /** - Maps all of the items in the enumeration to another value, returning - a new array. This method corresponds to `map()` defined in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the mapped value. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method map - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} The mapped array. - @public - */ - map: function (callback, target) { - var ret = emberA(); + if (!hadCachedValue) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } - this.forEach(function (x, idx, i) { - return ret[idx] = callback.call(target, x, idx, i); - }); + if (ret === undefined) { + cache[keyName] = _emberMetalMeta.UNDEFINED; + } else { + cache[keyName] = ret; + } - return ret; - }, + _emberMetalProperty_events.propertyDidChange(obj, keyName); - /** - Similar to map, this specialized function returns the value of the named - property on all items in the enumeration. - @method mapBy - @param {String} key name of the property - @return {Array} The mapped array. - @public - */ - mapBy: function (key) { - return this.map(function (next) { - return _emberMetal.get(next, key); - }); - }, + return ret; + }; - /** - Returns an array with all of the items in the enumeration that the passed - function returns true for. This method corresponds to `filter()` defined in - JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method filter - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} A filtered array. - @public - */ - filter: function (callback, target) { - var ret = emberA(); + /* called before property is overridden */ + ComputedPropertyPrototype.teardown = function (obj, keyName) { + if (this._volatile) { + return; + } + var meta = _emberMetalMeta.meta(obj); + var cache = meta.readableCache(); + if (cache && cache[keyName] !== undefined) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + cache[keyName] = undefined; + } + }; - this.forEach(function (x, idx, i) { - if (callback.call(target, x, idx, i)) { - ret.push(x); + /** + This helper returns a new property descriptor that wraps the passed + computed property function. You can use this helper to define properties + with mixins or via `Ember.defineProperty()`. + + If you pass a function as an argument, it will be used as a getter. A computed + property defined in this way might look like this: + + ```js + let Person = Ember.Object.extend({ + init() { + this._super(...arguments); + + this.firstName = 'Betty'; + this.lastName = 'Jones'; + }, + + fullName: Ember.computed('firstName', 'lastName', function() { + return `${this.get('firstName')} ${this.get('lastName')}`; + }) + }); + + let client = Person.create(); + + client.get('fullName'); // 'Betty Jones' + + client.set('lastName', 'Fuller'); + client.get('fullName'); // 'Betty Fuller' + ``` + + You can pass a hash with two functions, `get` and `set`, as an + argument to provide both a getter and setter: + + ```js + let Person = Ember.Object.extend({ + init() { + this._super(...arguments); + + this.firstName = 'Betty'; + this.lastName = 'Jones'; + }, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + return `${this.get('firstName')} ${this.get('lastName')}`; + }, + set(key, value) { + let [firstName, lastName] = value.split(/\s+/); + this.setProperties({ firstName, lastName }); + return value; } - }); - - return ret; - }, - - /** - Returns an array with all of the items in the enumeration where the passed - function returns false. This method is the inverse of filter(). - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - *item* is the current item in the iteration. - - *index* is the current index in the iteration - - *enumerable* is the enumerable object itself. - It should return a falsey value to include the item in the results. - Note that in addition to a callback, you can also pass an optional target - object that will be set as "this" on the context. This is a good way - to give your iterator function access to the current object. - @method reject - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} A rejected array. - @public - */ - reject: function (callback, target) { - return this.filter(function () { - return !callback.apply(target, arguments); - }); - }, + }) + }); + + let client = Person.create(); + client.get('firstName'); // 'Betty' + + client.set('fullName', 'Carroll Fuller'); + client.get('firstName'); // 'Carroll' + ``` + + The `set` function should accept two parameters, `key` and `value`. The value + returned from `set` will be the new value of the property. + + _Note: This is the preferred way to define computed properties when writing third-party + libraries that depend on or use Ember, since there is no guarantee that the user + will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._ + + The alternative syntax, with prototype extensions, might look like: + + ```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 + */ - /** - Returns an array with just the items with the matched property. You - can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to `true`. - @method filterBy - @param {String} key the property to test - @param {*} [value] optional value to test against. - @return {Array} filtered array - @public - */ - filterBy: function (key, value) { - return this.filter(iter.apply(this, arguments)); - }, + function computed(func) { + var args = undefined; - /** - Returns an array with the items that do not have truthy values for - key. You can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to false. - @method rejectBy - @param {String} key the property to test - @param {String} [value] optional value to test against. - @return {Array} rejected array - @public - */ - rejectBy: function (key, value) { - var exactValue = function (item) { - return _emberMetal.get(item, key) === value; - }; - var hasValue = function (item) { - return !!_emberMetal.get(item, key); - }; - var use = arguments.length === 2 ? exactValue : hasValue; + if (arguments.length > 1) { + args = [].slice.call(arguments); + func = args.pop(); + } - return this.reject(use); - }, + var cp = new ComputedProperty(func); - /** - Returns the first item in the array for which the callback returns true. - This method works similar to the `filter()` method defined in JavaScript 1.6 - except that it will stop working on the array once a match is found. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method find - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Object} Found item or `undefined`. - @public - */ - find: function (callback, target) { - var len = _emberMetal.get(this, 'length'); + if (args) { + cp.property.apply(cp, args); + } - if (target === undefined) { - target = null; - } + return cp; + } - var context = popCtx(); - var found = false; - var last = null; - var next = undefined, - ret = undefined; + /** + 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 = _emberMetalMeta.peekMeta(obj); + var cache = meta && meta.source === obj && meta.readableCache(); + var ret = cache && cache[key]; - for (var idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); + if (ret === _emberMetalMeta.UNDEFINED) { + return undefined; + } + return ret; + } - found = callback.call(target, next, idx, this); - if (found) { - ret = next; - } + cacheFor.set = function (cache, key, value) { + if (value === undefined) { + cache[key] = _emberMetalMeta.UNDEFINED; + } else { + cache[key] = value; + } + }; - last = next; - } + cacheFor.get = function (cache, key) { + var ret = cache[key]; + if (ret === _emberMetalMeta.UNDEFINED) { + return undefined; + } + return ret; + }; - next = last = null; - context = pushCtx(context); + cacheFor.remove = function (cache, key) { + cache[key] = undefined; + }; - return ret; - }, + exports.ComputedProperty = ComputedProperty; + exports.computed = computed; + exports.cacheFor = cacheFor; +}); +enifed('ember-metal/core', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; - /** - Returns the first item with a property matching the passed value. You - can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to `true`. - This method works much like the more generic `find()` method. - @method findBy - @param {String} key the property to test - @param {String} [value] optional value to test against. - @return {Object} found item or `undefined` - @public - */ - findBy: function (key, value) { - return this.find(iter.apply(this, arguments)); - }, + /** + @module ember + @submodule ember-metal + */ - /** - Returns `true` if the passed function returns true for every item in the - enumeration. This corresponds with the `every()` method in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` or `false`. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - Example Usage: - ```javascript - if (people.every(isEngineer)) { - Paychecks.addBigBonus(); - } - ``` - @method every - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Boolean} - @public - */ - every: function (callback, target) { - return !this.find(function (x, idx, i) { - return !callback.call(target, x, idx, i); - }); - }, + /** + This namespace contains all Ember methods and functions. Future versions of + Ember may overwrite this namespace and therefore, you should avoid adding any + new properties. + + At the heart of Ember is Ember-Runtime, a set of core functions that provide + cross-platform compatibility and object property observing. Ember-Runtime is + small and performance-focused so you can use it alongside other + cross-platform libraries such as jQuery. For more details, see + [Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html). + + @class Ember + @static + @public + */ + var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {}; - /** - Returns `true` if the passed property resolves to the value of the second - argument for all items in the enumerable. This method is often simpler/faster - than using a callback. - @method isEvery - @param {String} key the property to test - @param {String} [value] optional value to test against. Defaults to `true` - @return {Boolean} - @since 1.3.0 - @public - */ - isEvery: function (key, value) { - return this.every(iter.apply(this, arguments)); - }, + // Make sure these are set whether Ember was already defined or not + Ember.isNamespace = true; + Ember.toString = function () { + return 'Ember'; + }; - /** - Returns `true` if the passed function returns true for any item in the - enumeration. This corresponds with the `some()` method in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - Usage Example: - ```javascript - if (people.any(isManager)) { - Paychecks.addBiggerBonus(); - } - ``` - @method any - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Boolean} `true` if the passed function returns `true` for any item - @public - */ - any: function (callback, target) { - var len = _emberMetal.get(this, 'length'); - var context = popCtx(); - var found = false; - var last = null; - var next = undefined; + // .......................................................... + // BOOTSTRAP + // - if (target === undefined) { - target = null; - } + exports.default = Ember; +}); +enifed("ember-metal/debug", ["exports"], function (exports) { + "use strict"; - for (var idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); - found = callback.call(target, next, idx, this); - last = next; + exports.getDebugFunction = getDebugFunction; + exports.setDebugFunction = setDebugFunction; + exports.assert = assert; + exports.info = info; + exports.warn = warn; + exports.debug = debug; + exports.deprecate = deprecate; + exports.deprecateFunc = deprecateFunc; + exports.runInDebug = runInDebug; + exports.debugSeal = debugSeal; + exports.debugFreeze = debugFreeze; + var debugFunctions = { + assert: function () {}, + info: function () {}, + warn: function () {}, + debug: function () {}, + deprecate: function () {}, + deprecateFunc: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - next = last = null; - context = pushCtx(context); - return found; + return args[args.length - 1]; }, + runInDebug: function () {}, + debugSeal: function () {}, + debugFreeze: function () {} + }; - /** - Returns `true` if the passed property resolves to the value of the second - argument for any item in 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. Defaults to `true` - @return {Boolean} - @since 1.3.0 - @public - */ - isAny: function (key, value) { - return this.any(iter.apply(this, arguments)); - }, + exports.debugFunctions = debugFunctions; - /** - This will combine the values of the enumerator into a single value. It - is a useful way to collect a summary value from an enumeration. This - corresponds to the `reduce()` method defined in JavaScript 1.8. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(previousValue, item, index, enumerable); - ``` - - `previousValue` is the value returned by the last call to the iterator. - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - Return the new cumulative value. - In addition to the callback you can also pass an `initialValue`. An error - will be raised if you do not pass an initial value and the enumerator is - empty. - Note that unlike the other methods, this method does not allow you to - pass a target object to set as this for the callback. It's part of the - spec. Sorry. - @method reduce - @param {Function} callback The callback to execute - @param {Object} initialValue Initial value for the reduce - @param {String} reducerProperty internal use only. - @return {Object} The reduced value. - @public - */ - reduce: function (callback, initialValue, reducerProperty) { - if (typeof callback !== 'function') { - throw new TypeError(); - } + function getDebugFunction(name) { + return debugFunctions[name]; + } - var ret = initialValue; + function setDebugFunction(name, fn) { + debugFunctions[name] = fn; + } - this.forEach(function (item, i) { - ret = callback(ret, item, i, this, reducerProperty); - }, this); + function assert() { + return debugFunctions.assert.apply(undefined, arguments); + } - return ret; - }, + function info() { + return debugFunctions.info.apply(undefined, arguments); + } - /** - Invokes the named method on every object in the receiver that - implements it. This method corresponds to the implementation in - Prototype 1.6. - @method invoke - @param {String} methodName the name of the method - @param {Object...} args optional arguments to pass as well. - @return {Array} return values from calling invoke. - @public - */ - invoke: function (methodName) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } + function warn() { + return debugFunctions.warn.apply(undefined, arguments); + } - var ret = emberA(); + function debug() { + return debugFunctions.debug.apply(undefined, arguments); + } - this.forEach(function (x, idx) { - var method = x && x[methodName]; + function deprecate() { + return debugFunctions.deprecate.apply(undefined, arguments); + } - if ('function' === typeof method) { - ret[idx] = args ? method.apply(x, args) : x[methodName](); - } - }, this); + function deprecateFunc() { + return debugFunctions.deprecateFunc.apply(undefined, arguments); + } - return ret; - }, + function runInDebug() { + return debugFunctions.runInDebug.apply(undefined, arguments); + } - /** - Simply converts the enumerable into a genuine array. The order is not - guaranteed. Corresponds to the method implemented by Prototype. - @method toArray - @return {Array} the enumerable as an array. - @public - */ - toArray: function () { - var ret = emberA(); + function debugSeal() { + return debugFunctions.debugSeal.apply(undefined, arguments); + } + + function debugFreeze() { + return debugFunctions.debugFreeze.apply(undefined, arguments); + } +}); +enifed('ember-metal/dependent_keys', ['exports', 'ember-metal/watching'], function (exports, _emberMetalWatching) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - this.forEach(function (o, idx) { - return ret[idx] = o; - }); + exports.addDependentKeys = addDependentKeys; + exports.removeDependentKeys = removeDependentKeys; - return ret; - }, + /** + @module ember + @submodule ember-metal + */ - /** - Returns a copy of the array with all `null` and `undefined` elements removed. - ```javascript - let arr = ['a', null, 'c', undefined]; - arr.compact(); // ['a', 'c'] - ``` - @method compact - @return {Array} the array without null and undefined elements. - @public - */ - compact: function () { - return this.filter(function (value) { - return value != null; - }); - }, + // .......................................................... + // DEPENDENT KEYS + // - /** - Returns a new enumerable that excludes the passed value. The default - implementation returns an array regardless of the receiver type. - If the receiver does not contain the value it returns the original enumerable. - ```javascript - let arr = ['a', 'b', 'a', 'c']; - arr.without('a'); // ['b', 'c'] - ``` - @method without - @param {Object} value - @return {Ember.Enumerable} - @public - */ - without: function (value) { - if (!this.contains(value)) { - return this; // nothing to do - } + function addDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // add all of its dependent keys. + var idx = undefined, + depKey = undefined; + var depKeys = desc._dependentKeys; + if (!depKeys) { + return; + } - var ret = emberA(); + for (idx = 0; idx < depKeys.length; idx++) { + depKey = depKeys[idx]; + // Increment the number of times depKey depends on keyName. + meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1); + // Watch the depKey + _emberMetalWatching.watch(obj, depKey, meta); + } + } - this.forEach(function (k) { - if (k !== value) { - ret[ret.length] = k; - } - }); + function removeDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // remove all of its dependent keys. + var depKeys = desc._dependentKeys; + if (!depKeys) { + return; + } - return ret; - }, + for (var idx = 0; idx < depKeys.length; idx++) { + var depKey = depKeys[idx]; + // Decrement the number of times depKey depends on keyName. + meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1); + // Unwatch the depKey + _emberMetalWatching.unwatch(obj, depKey, meta); + } + } +}); +enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set) { + /** + @module ember + @submodule ember-metal + */ - /** - Returns a new enumerable that contains only unique values. The default - implementation returns an array regardless of the receiver type. - ```javascript - let arr = ['a', 'a', 'b', 'b']; - arr.uniq(); // ['a', 'b'] - ``` - This only works on primitive data types, e.g. Strings, Numbers, etc. - @method uniq - @return {Ember.Enumerable} - @public - */ - uniq: function () { - var ret = emberA(); + 'use strict'; - this.forEach(function (k) { - if (ret.indexOf(k) < 0) { - ret.push(k); - } - }); + exports.deprecateProperty = deprecateProperty; - return ret; - }, + /** + Used internally to allow changing properties in a backwards compatible way, and print a helpful + deprecation warning. + + @method deprecateProperty + @param {Object} object The object to add the deprecated property to. + @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). + @param {String} newKey The property that will be aliased. + @private + @since 1.7.0 + */ - /** - This property will trigger anytime the enumerable's content changes. - You can observe this property to be notified of changes to the enumerable's - content. - For plain enumerables, this property is read only. `Array` overrides - this method. - @property [] - @type Array - @return this - @private - */ - '[]': _emberMetal.computed({ - get: function (key) { - return this; - } - }), + function deprecateProperty(object, deprecatedKey, newKey, options) { + function _deprecate() { + _emberMetalDebug.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.', false, options); + } - // .......................................................... - // ENUMERABLE OBSERVERS - // + Object.defineProperty(object, deprecatedKey, { + configurable: true, + enumerable: false, + set: function (value) { + _deprecate(); + _emberMetalProperty_set.set(this, newKey, value); + }, + get: function () { + _deprecate(); + return _emberMetalProperty_get.get(this, newKey); + } + }); + } +}); +enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) { + 'use strict'; - /** - Registers an enumerable observer. Must implement `Ember.EnumerableObserver` - mixin. - @method addEnumerableObserver - @param {Object} target - @param {Object} [opts] - @return this - @private - */ - addEnumerableObserver: function (target, opts) { - var willChange = opts && opts.willChange || 'enumerableWillChange'; - var didChange = opts && opts.didChange || 'enumerableDidChange'; - var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); + exports.default = descriptor; - if (!hasObservers) { - _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); - } + function descriptor(desc) { + return new Descriptor(desc); + } - _emberMetal.addListener(this, '@enumerable:before', target, willChange); - _emberMetal.addListener(this, '@enumerable:change', target, didChange); + /** + A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need + this at all, however, the way we currently flatten/merge our mixins require + a special value to denote a descriptor. + + @class Descriptor + @private + */ - if (!hasObservers) { - _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); - } + var Descriptor = (function (_EmberDescriptor) { + babelHelpers.inherits(Descriptor, _EmberDescriptor); - return this; - }, + function Descriptor(desc) { + babelHelpers.classCallCheck(this, Descriptor); - /** - Removes a registered enumerable observer. - @method removeEnumerableObserver - @param {Object} target - @param {Object} [opts] - @return this - @private - */ - removeEnumerableObserver: function (target, opts) { - var willChange = opts && opts.willChange || 'enumerableWillChange'; - var didChange = opts && opts.didChange || 'enumerableDidChange'; - var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); + _EmberDescriptor.call(this); + this.desc = desc; + } - if (hasObservers) { - _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); - } + Descriptor.prototype.setup = function setup(obj, key) { + Object.defineProperty(obj, key, this.desc); + }; - _emberMetal.removeListener(this, '@enumerable:before', target, willChange); - _emberMetal.removeListener(this, '@enumerable:change', target, didChange); + Descriptor.prototype.teardown = function teardown(obj, key) {}; - if (hasObservers) { - _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); - } + return Descriptor; + })(_emberMetalProperties.Descriptor); +}); +enifed("ember-metal/error", ["exports"], function (exports) { - return this; - }, + /** + A subclass of the JavaScript Error object for use in Ember. + + @class Error + @namespace Ember + @extends Error + @constructor + @public + */ + "use strict"; - /** - Becomes true whenever the array currently has observers watching changes - on the array. - @property hasEnumerableObservers - @type Boolean - @private - */ - hasEnumerableObservers: _emberMetal.computed(function () { - return _emberMetal.hasListeners(this, '@enumerable:change') || _emberMetal.hasListeners(this, '@enumerable:before'); - }), + var EmberError = (function (_Error) { + babelHelpers.inherits(EmberError, _Error); - /** - Invoke this method just before the contents of your enumerable will - change. You can either omit the parameters completely or pass the objects - to be removed or added if available or just a count. - @method enumerableContentWillChange - @param {Ember.Enumerable|Number} removing An enumerable of the objects to - be removed or the number of items to be removed. - @param {Ember.Enumerable|Number} adding An enumerable of the objects to be - added or the number of items to be added. - @chainable - @private - */ - enumerableContentWillChange: function (removing, adding) { - var removeCnt = undefined, - addCnt = undefined, - hasDelta = undefined; + function EmberError(message) { + babelHelpers.classCallCheck(this, EmberError); - if ('number' === typeof removing) { - removeCnt = removing; - } else if (removing) { - removeCnt = _emberMetal.get(removing, 'length'); - } else { - removeCnt = removing = -1; - } + _Error.call(this); - if ('number' === typeof adding) { - addCnt = adding; - } else if (adding) { - addCnt = _emberMetal.get(adding, 'length'); - } else { - addCnt = adding = -1; + if (!(this instanceof EmberError)) { + return new EmberError(message); } - hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; + var error = Error.call(this, message); - if (removing === -1) { - removing = null; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, EmberError); + } else { + this.stack = error.stack; } - if (adding === -1) { - adding = null; - } + this.description = error.description; + this.fileName = error.fileName; + this.lineNumber = error.lineNumber; + this.message = error.message; + this.name = error.name; + this.number = error.number; + this.code = error.code; + } - _emberMetal.propertyWillChange(this, '[]'); + return EmberError; + })(Error); - if (hasDelta) { - _emberMetal.propertyWillChange(this, 'length'); - } + exports.default = EmberError; +}); +enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { + 'use strict'; - _emberMetal.sendEvent(this, '@enumerable:before', [this, removing, adding]); + exports.getOnerror = getOnerror; + exports.setOnerror = setOnerror; + exports.dispatchError = dispatchError; + exports.setDispatchOverride = setDispatchOverride; - return this; - }, + // To maintain stacktrace consistency across browsers + var getStack = function (error) { + var stack = error.stack; + var message = error.message; - /** - Invoke this method when the contents of your enumerable has changed. - This will notify any observers watching for content changes. If you are - implementing an ordered enumerable (such as an array), also pass the - start and end values where the content changed so that it can be used to - notify range observers. - @method enumerableContentDidChange - @param {Ember.Enumerable|Number} removing An enumerable of the objects to - be removed or the number of items to be removed. - @param {Ember.Enumerable|Number} adding An enumerable of the objects to - be added or the number of items to be added. - @chainable - @private - */ - enumerableContentDidChange: function (removing, adding) { - var removeCnt = undefined, - addCnt = undefined, - hasDelta = undefined; + if (stack && !stack.includes(message)) { + stack = message + '\n' + stack; + } - if ('number' === typeof removing) { - removeCnt = removing; - } else if (removing) { - removeCnt = _emberMetal.get(removing, 'length'); - } else { - removeCnt = removing = -1; - } + return stack; + }; - if ('number' === typeof adding) { - addCnt = adding; - } else if (adding) { - addCnt = _emberMetal.get(adding, 'length'); - } else { - addCnt = adding = -1; - } + var onerror = undefined; + // Ember.onerror getter - hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; + function getOnerror() { + return onerror; + } - if (removing === -1) { - removing = null; - } + // Ember.onerror setter - if (adding === -1) { - adding = null; - } + function setOnerror(handler) { + onerror = handler; + } - _emberMetal.sendEvent(this, '@enumerable:change', [this, removing, adding]); + var dispatchOverride = undefined; + // dispatch error - if (hasDelta) { - _emberMetal.propertyDidChange(this, 'length'); - } + function dispatchError(error) { + if (dispatchOverride) { + dispatchOverride(error); + } else { + defaultDispatch(error); + } + } - _emberMetal.propertyDidChange(this, '[]'); + // allows testing adapter to override dispatch - return this; - }, + function setDispatchOverride(handler) { + dispatchOverride = handler; + } - /** - Converts the enumerable into an array and sorts by the keys - specified in the argument. - You may provide multiple arguments to sort by multiple properties. - @method sortBy - @param {String} property name(s) to sort on - @return {Array} The sorted array. - @since 1.2.0 - @public - */ - sortBy: function () { - var sortKeys = arguments; + function defaultDispatch(error) { + if (_emberMetalTesting.isTesting()) { + throw error; + } + if (onerror) { + onerror(error); + } else { + _emberConsole.default.error(getStack(error)); + } + } +}); +enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - return this.toArray().sort(function (a, b) { - for (var i = 0; i < sortKeys.length; i++) { - var key = sortKeys[i]; - var propA = _emberMetal.get(a, key); - var propB = _emberMetal.get(b, key); - // return 1 or -1 else continue to the next sortKey - var compareValue = _emberRuntimeCompare.default(propA, propB); + /** + @module ember + @submodule ember-metal + */ + exports.accumulateListeners = accumulateListeners; + exports.addListener = addListener; + exports.removeListener = removeListener; + exports.suspendListener = suspendListener; + exports.suspendListeners = suspendListeners; + exports.watchedEvents = watchedEvents; + exports.sendEvent = sendEvent; + exports.hasListeners = hasListeners; + exports.listenersFor = listenersFor; + exports.on = on; - if (compareValue) { - return compareValue; + /* + The event system uses a series of nested hashes to store listeners on an + object. When a listener is registered, or when an event arrives, these + hashes are consulted to determine which target and action pair to invoke. + + The hashes are stored in the object's meta hash, and look like this: + + // Object's meta hash + { + listeners: { // variable name: `listenerSet` + "foo:changed": [ // variable name: `actions` + target, method, flags + ] } } - return 0; - }); - } - }); + + */ - if (true) { - Enumerable.reopen({ - /** - Returns a new enumerable that contains only items containing a unique property value. - The default implementation returns an array regardless of the receiver type. - ```javascript - let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; - arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] - ``` - @method uniqBy - @return {Ember.Enumerable} - @public - */ + function indexOf(array, target, method) { + var index = -1; + // hashes are added to the end of the event array + // so it makes sense to start searching at the end + // of the array and search in reverse + for (var i = array.length - 3; i >= 0; i -= 3) { + if (target === array[i] && method === array[i + 1]) { + index = i; + break; + } + } + return index; + } - uniqBy: function (key) { - var ret = emberA(); - var seen = new _emberUtils.EmptyObject(); + function accumulateListeners(obj, eventName, otherActions) { + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta) { + return; + } + var actions = meta.matchingListeners(eventName); + var newActions = []; - this.forEach(function (item) { - var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); - if (!(guid in seen)) { - seen[guid] = true; - ret.push(item); - } - }); + for (var i = actions.length - 3; i >= 0; i -= 3) { + var target = actions[i]; + var method = actions[i + 1]; + var flags = actions[i + 2]; + var actionIndex = indexOf(otherActions, target, method); - return ret; + if (actionIndex === -1) { + otherActions.push(target, method, flags); + newActions.push(target, method, flags); } - }); - } + } - if (true) { - Enumerable.reopen({ - /** - Returns `true` if the passed object can be found in the enumerable. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, undefined].includes(undefined); // true - [1, 2, null].includes(null); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in the enumerable. - @public - */ - includes: function (obj) { - _emberMetal.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1); + return newActions; + } - var len = _emberMetal.get(this, 'length'); - var idx = undefined, - next = undefined; - var last = null; - var found = false; + /** + Add an event listener + + @method addListener + @for Ember + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Boolean} once A flag whether a function should only be called once + @public + */ - var context = popCtx(); + function addListener(obj, eventName, target, method, once) { + _emberMetalDebug.assert('You must pass at least an object and event name to Ember.addListener', !!obj && !!eventName); - for (idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); + _emberMetalDebug.deprecate('didInitAttrs called in ' + (obj && obj.toString && obj.toString()) + '.', eventName !== 'didInitAttrs', { + id: 'ember-views.did-init-attrs', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' + }); - found = obj === next || obj !== obj && next !== next; + if (!method && 'function' === typeof target) { + method = target; + target = null; + } - last = next; - } + var flags = 0; + if (once) { + flags |= _emberMetalMeta_listeners.ONCE; + } - next = last = null; - context = pushCtx(context); + _emberMetalMeta.meta(obj).addToListeners(eventName, target, method, flags); - return found; - }, + if ('function' === typeof obj.didAddListener) { + obj.didAddListener(eventName, target, method); + } + } - without: function (value) { - if (!this.includes(value)) { - return this; // nothing to do - } + /** + Remove an event listener + + Arguments should match those passed to `Ember.addListener`. + + @method removeListener + @for Ember + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @public + */ - var ret = emberA(); + function removeListener(obj, eventName, target, method) { + _emberMetalDebug.assert('You must pass at least an object and event name to Ember.removeListener', !!obj && !!eventName); - this.forEach(function (k) { - // SameValueZero comparison (NaN !== NaN) - if (!(k === value || k !== k && value !== value)) { - ret[ret.length] = k; - } - }); + if (!method && 'function' === typeof target) { + method = target; + target = null; + } - return ret; + _emberMetalMeta.meta(obj).removeFromListeners(eventName, target, method, function () { + if ('function' === typeof obj.didRemoveListener) { + obj.didRemoveListener.apply(obj, arguments); } }); } - exports.default = Enumerable; -}); -enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - /** - @module ember - @submodule ember-runtime - */ - /** - This mixin allows for Ember objects to subscribe to and emit events. - - ```javascript - App.Person = Ember.Object.extend(Ember.Evented, { - greet: function() { - // ... - this.trigger('greet'); - } - }); + Suspend listener during callback. - var person = App.Person.create(); + This should only be used by the target of the event listener + when it is taking an action that would cause the event, e.g. + an object might suspend its property change listener while it is + setting that property. - person.on('greet', function() { - console.log('Our person has greeted'); - }); + @method suspendListener + @for Ember - person.greet(); + @private + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Function} callback + */ + + function suspendListener(obj, eventName, target, method, callback) { + return suspendListeners(obj, [eventName], target, method, callback); + } + + /** + Suspends multiple listeners during a callback. - // outputs: 'Our person has greeted' - ``` + @method suspendListeners + @for Ember - You can also chain multiple event subscriptions: + @private + @param obj + @param {Array} eventNames Array of event names + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Function} callback + */ + + function suspendListeners(obj, eventNames, target, method, callback) { + if (!method && 'function' === typeof target) { + method = target; + target = null; + } + return _emberMetalMeta.meta(obj).suspendListeners(eventNames, target, method, callback); + } + + /** + Return a list of currently watched events - ```javascript - person.on('greet', function() { - console.log('Our person has greeted'); - }).one('greet', function() { - console.log('Offer one-time special'); - }).off('event', this, forgetThis); - ``` + @private + @method watchedEvents + @for Ember + @param obj + */ + + function watchedEvents(obj) { + return _emberMetalMeta.meta(obj).watchedEvents(); + } + + /** + Send an event. The execution of suspended listeners + is skipped, and once listeners are removed. A listener without + a target is executed on the passed object. If an array of actions + is not passed, the actions stored on the passed object are invoked. - @class Evented - @namespace Ember + @method sendEvent + @for Ember + @param obj + @param {String} eventName + @param {Array} params Optional parameters for each listener. + @param {Array} actions Optional array of actions (listeners). + @return true @public - */ - exports.default = _emberMetal.Mixin.create({ + */ - /** - Subscribes to a named event with given function. - ```javascript - person.on('didLoad', function() { - // fired once the person has loaded - }); - ``` - An optional target can be passed in as the 2nd argument that will - be set as the "this" for the callback. This is a good way to give your - function access to the object triggering the event. When the target - parameter is used the callback becomes the third argument. - @method on - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - @public - */ - on: function (name, target, method) { - _emberMetal.addListener(this, name, target, method); - return this; - }, + function sendEvent(obj, eventName, params, actions) { + if (!actions) { + var meta = _emberMetalMeta.peekMeta(obj); + actions = meta && meta.matchingListeners(eventName); + } - /** - Subscribes a function to a named event and then cancels the subscription - after the first time the event is triggered. It is good to use ``one`` when - you only care about the first time an event has taken place. - This function takes an optional 2nd argument that will become the "this" - value for the callback. If this argument is passed then the 3rd argument - becomes the function. - @method one - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - @public - */ - one: function (name, target, method) { - if (!method) { - method = target; - target = null; - } + if (!actions || actions.length === 0) { + return; + } - _emberMetal.addListener(this, name, target, method, true); - return this; - }, + for (var i = actions.length - 3; i >= 0; i -= 3) { + // looping in reverse for once listeners + var target = actions[i]; + var method = actions[i + 1]; + var flags = actions[i + 2]; - /** - Triggers a named event for the object. Any additional arguments - will be passed as parameters to the functions that are subscribed to the - event. - ```javascript - person.on('didEat', function(food) { - console.log('person ate some ' + food); - }); - person.trigger('didEat', 'broccoli'); - // outputs: person ate some broccoli - ``` - @method trigger - @param {String} name The name of the event - @param {Object...} args Optional arguments to pass on - @public - */ - trigger: function (name) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + if (!method) { + continue; } + if (flags & _emberMetalMeta_listeners.SUSPENDED) { + continue; + } + if (flags & _emberMetalMeta_listeners.ONCE) { + removeListener(obj, eventName, target, method); + } + if (!target) { + target = obj; + } + if ('string' === typeof method) { + if (params) { + _emberUtils.applyStr(target, method, params); + } else { + target[method](); + } + } else { + if (params) { + method.apply(target, params); + } else { + method.call(target); + } + } + } + return true; + } - _emberMetal.sendEvent(this, name, args); - }, - - /** - Cancels subscription for given name, target, and method. - @method off - @param {String} name The name of the event - @param {Object} target The target of the subscription - @param {Function} method The function of the subscription - @return this - @public - */ - off: function (name, target, method) { - _emberMetal.removeListener(this, name, target, method); - return this; - }, + /** + @private + @method hasListeners + @for Ember + @param obj + @param {String} eventName + */ - /** - Checks to see if object has any subscriptions for named event. - @method has - @param {String} name The name of the event - @return {Boolean} does the object have a subscription for event - @public - */ - has: function (name) { - return _emberMetal.hasListeners(this, name); + function hasListeners(obj, eventName) { + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta) { + return false; } - }); -}); -enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + return meta.matchingListeners(eventName).length > 0; + } + /** - @module ember - @submodule ember-runtime + @private + @method listenersFor + @for Ember + @param obj + @param {String} eventName */ - 'use strict'; + function listenersFor(obj, eventName) { + var ret = []; + var meta = _emberMetalMeta.peekMeta(obj); + var actions = meta && meta.matchingListeners(eventName); + + if (!actions) { + return ret; + } + + for (var i = 0; i < actions.length; i += 3) { + var target = actions[i]; + var method = actions[i + 1]; + ret.push([target, method]); + } + + return ret; + } /** - The `Ember.Freezable` mixin implements some basic methods for marking an - object as frozen. Once an object is frozen it should be read only. No changes - may be made the internal state of the object. - - ## Enforcement - - To fully support freezing in your subclass, you must include this mixin and - override any method that might alter any property on the object to instead - raise an exception. You can check the state of an object by checking the - `isFrozen` property. - - Although future versions of JavaScript may support language-level freezing - object objects, that is not the case today. Even if an object is freezable, - it is still technically possible to modify the object, even though it could - break other parts of your application that do not expect a frozen object to - change. It is, therefore, very important that you always respect the - `isFrozen` property on all freezable objects. - - ## Example Usage - - The example below shows a simple object that implement the `Ember.Freezable` - protocol. - - ```javascript - Contact = Ember.Object.extend(Ember.Freezable, { - firstName: null, - lastName: null, + Define a property as a function that should be executed when + a specified event or events are triggered. - // swaps the names - swapNames: function() { - if (this.get('isFrozen')) throw Ember.FROZEN_ERROR; - var tmp = this.get('firstName'); - this.set('firstName', this.get('lastName')); - this.set('lastName', tmp); - return this; - } + ``` javascript + let Job = Ember.Object.extend({ + logCompleted: Ember.on('completed', function() { + console.log('Job completed!'); + }) }); - c = Contact.create({ firstName: "John", lastName: "Doe" }); - c.swapNames(); // returns c - c.freeze(); - c.swapNames(); // EXCEPTION - ``` - - ## Copying + let job = Job.create(); - Usually the `Ember.Freezable` protocol is implemented in cooperation with the - `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will - return a frozen object, if the object implements this method as well. + Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' + ``` - @class Freezable - @namespace Ember - @since Ember 0.9 - @deprecated Use `Object.freeze` instead. - @private + @method on + @for Ember + @param {String} eventNames* + @param {Function} func + @return func + @public */ - var Freezable = _emberMetal.Mixin.create({ - - init: function () { - _emberMetal.deprecate('`Ember.Freezable` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.freezable-init', until: '3.0.0' }); - this._super.apply(this, arguments); - }, - - /** - Set to `true` when the object is frozen. Use this property to detect - whether your object is frozen or not. - @property isFrozen - @type Boolean - @private - */ - isFrozen: false, - - /** - Freezes the object. Once this method has been called the object should - no longer allow any properties to be edited. - @method freeze - @return {Object} receiver - @private - */ - freeze: function () { - if (_emberMetal.get(this, 'isFrozen')) { - return this; - } - _emberMetal.set(this, 'isFrozen', true); - return this; + function on() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - }); - - exports.Freezable = Freezable; - var FROZEN_ERROR = 'Frozen object cannot be modified.'; - exports.FROZEN_ERROR = FROZEN_ERROR; + var func = args.pop(); + var events = args; + func.__ember_listens__ = events; + return func; + } }); -enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable'], function (exports, _emberMetal, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable) { - /** - @module ember - @submodule ember-runtime - */ - +enifed('ember-metal/expand_properties', ['exports', 'ember-metal/debug'], function (exports, _emberMetalDebug) { 'use strict'; - exports.removeAt = removeAt; - var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; - var EMPTY = []; - - // .......................................................... - // HELPERS - // - - function removeAt(array, start, len) { - if ('number' === typeof start) { - if (start < 0 || start >= _emberMetal.get(array, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } - - // fast case - if (len === undefined) { - len = 1; - } + exports.default = expandProperties; - array.replace(start, len, EMPTY); - } + /** + @module ember + @submodule ember-metal + */ - return array; - } + var SPLIT_REGEX = /\{|\}/; + var END_WITH_EACH_REGEX = /\.@each$/; /** - This mixin defines the API for modifying array-like objects. These methods - can be applied only to a collection that keeps its items in an ordered set. - It builds upon the Array mixin and adds methods to modify the array. - One concrete implementations of this class include ArrayProxy. + Expands `pattern`, invoking `callback` for each expansion. - It is important to use the methods in this class to modify arrays so that - changes are observable. This allows the binding system in Ember to function - correctly. + The only pattern supported is brace-expansion, anything else will be passed + once to `callback` directly. + Example - Note that an Array can change even if it does not implement this mixin. - For example, one might implement a SparseArray that cannot be directly - modified, but if its underlying enumerable changes, it will change also. + ```js + function echo(arg){ console.log(arg); } - @class MutableArray - @namespace Ember - @uses Ember.Array - @uses Ember.MutableEnumerable - @public - */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, { - - /** - __Required.__ You must implement this method to apply this mixin. - This is one of the primitives you must implement to support `Ember.Array`. - You should replace amt objects started at idx with the objects in the - passed array. You should also call `this.enumerableContentDidChange()` - @method replace - @param {Number} idx Starting index in the array to replace. If - idx >= length, then append to the end of the array. - @param {Number} amt Number of elements that should be removed from - the array, starting at *idx*. - @param {Array} objects An array of zero or more objects that should be - inserted into the array at *idx* - @public - */ - replace: null, + Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' + Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' + Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' + Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' + Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' + Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' + Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' + ``` + + @method expandProperties + @for Ember + @private + @param {String} pattern The property pattern to expand. + @param {Function} callback The callback to invoke. It is invoked once per + expansion, and is passed the expansion. + */ - /** - Remove all elements from the array. This is useful if you - want to reuse an existing array without having to recreate it. - ```javascript - let colors = ['red', 'green', 'blue']; - color.length(); // 3 - colors.clear(); // [] - colors.length(); // 0 - ``` - @method clear - @return {Ember.Array} An empty Array. - @public - */ - clear: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return this; - } + function expandProperties(pattern, callback) { + _emberMetalDebug.assert('A computed property key must be a string', typeof pattern === 'string'); + _emberMetalDebug.assert('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1); + _emberMetalDebug.assert('Brace expanded properties have to be balanced and cannot be nested, pattern: ' + pattern, (function (str) { + var inBrace = 0; + var char = undefined; + for (var i = 0; i < str.length; i++) { + char = str.charAt(i); - this.replace(0, len, EMPTY); - return this; - }, + if (char === '{') { + inBrace++; + } else if (char === '}') { + inBrace--; + } - /** - This will use the primitive `replace()` method to insert an object at the - specified index. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue'] - colors.insertAt(5, 'orange'); // Error: Index out of range - ``` - @method insertAt - @param {Number} idx index of insert the object at. - @param {Object} object object to insert - @return {Ember.Array} receiver - @public - */ - insertAt: function (idx, object) { - if (idx > _emberMetal.get(this, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + if (inBrace > 1 || inBrace < 0) { + return false; + } } - this.replace(idx, 0, [object]); - return this; - }, - - /** - Remove an object at the specified index using the `replace()` primitive - method. You can pass either a single index, or a start and a length. - If you pass a start and length that is beyond the - length this method will throw an `OUT_OF_RANGE_EXCEPTION`. - ```javascript - let colors = ['red', 'green', 'blue', 'yellow', 'orange']; - colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] - colors.removeAt(2, 2); // ['green', 'blue'] - colors.removeAt(4, 2); // Error: Index out of range - ``` - @method removeAt - @param {Number} start index, start of range - @param {Number} len length of passing range - @return {Ember.Array} receiver - @public - */ - removeAt: function (start, len) { - return removeAt(this, start, len); - }, + return true; + })(pattern)); - /** - Push the object onto the end of the array. Works just like `push()` but it - is KVO-compliant. - ```javascript - let colors = ['red', 'green']; - colors.pushObject('black'); // ['red', 'green', 'black'] - colors.pushObject(['yellow']); // ['red', 'green', ['yellow']] - ``` - @method pushObject - @param {*} obj object to push - @return object same object passed as a param - @public - */ - pushObject: function (obj) { - this.insertAt(_emberMetal.get(this, 'length'), obj); - return obj; - }, + var parts = pattern.split(SPLIT_REGEX); + var properties = [parts]; - /** - Add the objects in the passed numerable to the end of the array. Defers - notifying observers of the change until all objects are added. - ```javascript - let colors = ['red']; - colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange'] - ``` - @method pushObjects - @param {Ember.Enumerable} objects the objects to add - @return {Ember.Array} receiver - @public - */ - pushObjects: function (objects) { - if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || Array.isArray(objects))) { - throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part.indexOf(',') >= 0) { + properties = duplicateAndReplace(properties, part.split(','), i); } - this.replace(_emberMetal.get(this, 'length'), 0, objects); - return this; - }, + } - /** - Pop object from array or nil if none are left. Works just like `pop()` but - it is KVO-compliant. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.popObject(); // 'blue' - console.log(colors); // ['red', 'green'] - ``` - @method popObject - @return object - @public - */ - popObject: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return null; - } + for (var i = 0; i < properties.length; i++) { + callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); + } + } - var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1); - this.removeAt(len - 1, 1); - return ret; - }, + function duplicateAndReplace(properties, currentParts, index) { + var all = []; - /** - Shift an object from start of array or nil if none are left. Works just - like `shift()` but it is KVO-compliant. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.shiftObject(); // 'red' - console.log(colors); // ['green', 'blue'] - ``` - @method shiftObject - @return object - @public - */ - shiftObject: function () { - if (_emberMetal.get(this, 'length') === 0) { - return null; - } + properties.forEach(function (property) { + currentParts.forEach(function (part) { + var current = property.slice(0); + current[index] = part; + all.push(current); + }); + }); - var ret = _emberRuntimeMixinsArray.objectAt(this, 0); - this.removeAt(0); - return ret; - }, + return all; + } +}); +enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) { + 'use strict'; - /** - Unshift an object to start of array. Works just like `unshift()` but it is - KVO-compliant. - ```javascript - let colors = ['red']; - colors.unshiftObject('yellow'); // ['yellow', 'red'] - colors.unshiftObject(['black']); // [['black'], 'yellow', 'red'] - ``` - @method unshiftObject - @param {*} obj object to unshift - @return object same object passed as a param - @public - */ - unshiftObject: function (obj) { - this.insertAt(0, obj); - return obj; - }, + exports.default = isEnabled; - /** - Adds the named objects to the beginning of the array. Defers notifying - observers until all objects have been added. - ```javascript - let colors = ['red']; - colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red'] - colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function - ``` - @method unshiftObjects - @param {Ember.Enumerable} objects the objects to add - @return {Ember.Array} receiver - @public - */ - unshiftObjects: function (objects) { - this.replace(0, 0, objects); - return this; - }, + /** + The hash of enabled Canary features. Add to this, any canary features + before creating your application. + + Alternatively (and recommended), you can also define `EmberENV.FEATURES` + if you need to enable features flagged at runtime. + + @class FEATURES + @namespace Ember + @static + @since 1.1.0 + @public + */ + var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES); - /** - Reverse objects in the array. Works just like `reverse()` but it is - KVO-compliant. - @method reverseObjects - @return {Ember.Array} receiver - @public - */ - reverseObjects: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return this; - } + exports.FEATURES = FEATURES; + /** + Determine whether the specified `feature` is enabled. Used by Ember's + build tools to exclude experimental features from beta/stable builds. + + You can define the following configuration options: + + * `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly + enabled/disabled. + + @method isEnabled + @param {String} feature The feature to check + @return {Boolean} + @for Ember.FEATURES + @since 1.1.0 + @public + */ - var objects = this.toArray().reverse(); - this.replace(0, len, objects); - return this; - }, + function isEnabled(feature) { + var featureValue = FEATURES[feature]; - /** - Replace all the receiver's content with content of the argument. - If argument is an empty array receiver will be cleared. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.setObjects(['black', 'white']); // ['black', 'white'] - colors.setObjects([]); // [] - ``` - @method setObjects - @param {Ember.Array} objects array whose content will be used for replacing - the content of the receiver - @return {Ember.Array} receiver with the new content - @public - */ - setObjects: function (objects) { - if (objects.length === 0) { - return this.clear(); - } + if (featureValue === true || featureValue === false || featureValue === undefined) { + return featureValue; + } else if (_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES) { + return true; + } else { + return false; + } + } - var len = _emberMetal.get(this, 'length'); - this.replace(0, len, objects); - return this; - }, + exports.DEFAULT_FEATURES = _emberFeatures.default; +}); +enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; - // .......................................................... - // IMPLEMENT Ember.MutableEnumerable - // + exports.default = getProperties; - /** - Remove all occurrences of an object in the array. - ```javascript - let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; - cities.removeObject('Chicago'); // ['Berlin', 'Lima'] - cities.removeObject('Lima'); // ['Berlin'] - cities.removeObject('Tokyo') // ['Berlin'] - ``` - @method removeObject - @param {*} obj object to remove - @return {Ember.Array} receiver - @public - */ - removeObject: function (obj) { - var loc = _emberMetal.get(this, 'length') || 0; - while (--loc >= 0) { - var curObject = _emberRuntimeMixinsArray.objectAt(this, loc); + /** + To get multiple properties at once, call `Ember.getProperties` + with an object followed by a list of strings or an array: + + ```javascript + Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + + is equivalent to: + + ```javascript + Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + + @method getProperties + @for Ember + @param {Object} obj + @param {String...|Array} list of keys to get + @return {Object} + @public + */ - if (curObject === obj) { - this.removeAt(loc); - } - } - return this; - }, + function getProperties(obj) { + var ret = {}; + var propertyNames = arguments; + var i = 1; - /** - Push the object onto the end of the array if it is not already - present in the array. - ```javascript - let cities = ['Chicago', 'Berlin']; - cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] - cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] - ``` - @method addObject - @param {*} obj object to add, if not already present - @return {Ember.Array} receiver - @public - */ - addObject: function (obj) { - var included = undefined; + if (arguments.length === 2 && Array.isArray(arguments[1])) { + i = 0; + propertyNames = arguments[1]; + } + for (; i < propertyNames.length; i++) { + ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]); + } + return ret; + } +}); +enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/is_proxy', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalIs_proxy, _emberMetalDescriptor) { + /** + @module ember + @submodule ember-metal + */ - if (true) { - included = this.includes(obj); - } else { - included = this.contains(obj); - } + 'use strict'; + + exports.default = _emberMetalCore.default; + // reexports + exports.computed = _emberMetalComputed.default; + exports.cacheFor = _emberMetalComputed.cacheFor; + exports.ComputedProperty = _emberMetalComputed.ComputedProperty; + exports.alias = _emberMetalAlias.default; + exports.merge = _emberMetalMerge.default; + exports.assert = _emberMetalDebug.assert; + exports.info = _emberMetalDebug.info; + exports.warn = _emberMetalDebug.warn; + exports.debug = _emberMetalDebug.debug; + exports.deprecate = _emberMetalDebug.deprecate; + exports.deprecateFunc = _emberMetalDebug.deprecateFunc; + exports.runInDebug = _emberMetalDebug.runInDebug; + exports.setDebugFunction = _emberMetalDebug.setDebugFunction; + exports.getDebugFunction = _emberMetalDebug.getDebugFunction; + exports.debugSeal = _emberMetalDebug.debugSeal; + exports.debugFreeze = _emberMetalDebug.debugFreeze; + exports.instrument = _emberMetalInstrumentation.instrument; + exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument; + exports._instrumentStart = _emberMetalInstrumentation._instrumentStart; + exports.instrumentationReset = _emberMetalInstrumentation.reset; + exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe; + exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe; + exports.isTesting = _emberMetalTesting.isTesting; + exports.setTesting = _emberMetalTesting.setTesting; + exports.getOnerror = _emberMetalError_handler.getOnerror; + exports.setOnerror = _emberMetalError_handler.setOnerror; + exports.dispatchError = _emberMetalError_handler.dispatchError; + exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride; + exports.META_DESC = _emberMetalMeta.META_DESC; + exports.meta = _emberMetalMeta.meta; + exports.peekMeta = _emberMetalMeta.peekMeta; + exports.Error = _emberMetalError.default; + exports.Cache = _emberMetalCache.default; + exports.isFeatureEnabled = _emberMetalFeatures.default; + exports.FEATURES = _emberMetalFeatures.FEATURES; + exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES; + exports._getPath = _emberMetalProperty_get._getPath; + exports.get = _emberMetalProperty_get.get; + exports.getWithDefault = _emberMetalProperty_get.getWithDefault; + exports.set = _emberMetalProperty_set.set; + exports.trySet = _emberMetalProperty_set.trySet; + exports.WeakMap = _emberMetalWeak_map.default; + exports.accumulateListeners = _emberMetalEvents.accumulateListeners; + exports.addListener = _emberMetalEvents.addListener; + exports.hasListeners = _emberMetalEvents.hasListeners; + exports.listenersFor = _emberMetalEvents.listenersFor; + exports.on = _emberMetalEvents.on; + exports.removeListener = _emberMetalEvents.removeListener; + exports.sendEvent = _emberMetalEvents.sendEvent; + exports.suspendListener = _emberMetalEvents.suspendListener; + exports.suspendListeners = _emberMetalEvents.suspendListeners; + exports.watchedEvents = _emberMetalEvents.watchedEvents; + exports.isNone = _emberMetalIs_none.default; + exports.isEmpty = _emberMetalIs_empty.default; + exports.isBlank = _emberMetalIs_blank.default; + exports.isPresent = _emberMetalIs_present.default; + exports.run = _emberMetalRun_loop.default; + exports.ObserverSet = _emberMetalObserver_set.default; + exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges; + exports.changeProperties = _emberMetalProperty_events.changeProperties; + exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges; + exports.overrideChains = _emberMetalProperty_events.overrideChains; + exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; + exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; + exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; + exports.defineProperty = _emberMetalProperties.defineProperty; + exports.Descriptor = _emberMetalProperties.Descriptor; + exports.watchKey = _emberMetalWatch_key.watchKey; + exports.unwatchKey = _emberMetalWatch_key.unwatchKey; + exports.ChainNode = _emberMetalChains.ChainNode; + exports.finishChains = _emberMetalChains.finishChains; + exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; + exports.watchPath = _emberMetalWatch_path.watchPath; + exports.unwatchPath = _emberMetalWatch_path.unwatchPath; + exports.destroy = _emberMetalWatching.destroy; + exports.isWatching = _emberMetalWatching.isWatching; + exports.unwatch = _emberMetalWatching.unwatch; + exports.watch = _emberMetalWatching.watch; + exports.watcherCount = _emberMetalWatching.watcherCount; + exports.libraries = _emberMetalLibraries.default; + exports.Map = _emberMetalMap.Map; + exports.MapWithDefault = _emberMetalMap.MapWithDefault; + exports.OrderedSet = _emberMetalMap.OrderedSet; + exports.getProperties = _emberMetalGet_properties.default; + exports.setProperties = _emberMetalSet_properties.default; + exports.expandProperties = _emberMetalExpand_properties.default; + exports._suspendObserver = _emberMetalObserver._suspendObserver; + exports._suspendObservers = _emberMetalObserver._suspendObservers; + exports.addObserver = _emberMetalObserver.addObserver; + exports.observersFor = _emberMetalObserver.observersFor; + exports.removeObserver = _emberMetalObserver.removeObserver; + exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; + exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.Mixin = _emberMetalMixin.Mixin; + exports.aliasMethod = _emberMetalMixin.aliasMethod; + exports._immediateObserver = _emberMetalMixin._immediateObserver; + exports._beforeObserver = _emberMetalMixin._beforeObserver; + exports.mixin = _emberMetalMixin.mixin; + exports.observer = _emberMetalMixin.observer; + exports.required = _emberMetalMixin.required; + exports.REQUIRED = _emberMetalMixin.REQUIRED; + exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins; + exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins; + exports.detectBinding = _emberMetalMixin.detectBinding; + exports.Binding = _emberMetalBinding.Binding; + exports.bind = _emberMetalBinding.bind; + exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath; + exports.InjectedProperty = _emberMetalInjected_property.default; + exports.setHasViews = _emberMetalTags.setHasViews; + exports.tagForProperty = _emberMetalTags.tagForProperty; + exports.tagFor = _emberMetalTags.tagFor; + exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty; + exports.replace = _emberMetalReplace.default; + exports.runInTransaction = _emberMetalTransaction.default; + exports.didRender = _emberMetalTransaction.didRender; + exports.assertNotRendered = _emberMetalTransaction.assertNotRendered; + exports.isProxy = _emberMetalIs_proxy.isProxy; + exports.descriptor = _emberMetalDescriptor.default; - if (!included) { - this.pushObject(obj); - } + // TODO: this needs to be deleted once we refactor the build tooling + // do this for side-effects of updating Ember.assert, warn, etc when + // ember-debug is present + // This needs to be called before any deprecateFunc - return this; - } - }); + if (_require.has('ember-debug')) { + _require.default('ember-debug'); + } }); -enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetal) { +enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) { 'use strict'; - /** - @module ember - @submodule ember-runtime - */ + exports.default = InjectedProperty; /** - This mixin defines the API for modifying generic enumerables. These methods - can be applied to an object regardless of whether it is ordered or - unordered. - - Note that an Enumerable can change even if it does not implement this mixin. - For example, a MappedEnumerable cannot be directly modified but if its - underlying enumerable changes, it will change also. - - ## Adding Objects - - To add an object to an enumerable, use the `addObject()` method. This - method will only add the object to the enumerable if the object is not - already present and is of a type supported by the enumerable. - - ```javascript - set.addObject(contact); - ``` - - ## Removing Objects - - To remove an object from an enumerable, use the `removeObject()` method. This - will only remove the object if it is present in the enumerable, otherwise - this method has no effect. - - ```javascript - set.removeObject(contact); - ``` - - ## Implementing In Your Own Code - - If you are implementing an object and want to support this API, just include - this mixin in your class and implement the required methods. In your unit - tests, be sure to apply the Ember.MutableEnumerableTests to your object. + Read-only property that returns the result of a container lookup. - @class MutableEnumerable + @class InjectedProperty @namespace Ember - @uses Ember.Enumerable - @public + @constructor + @param {String} type The container type the property will lookup + @param {String} name (optional) The name the property will lookup, defaults + to the property's name + @private */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, { - /** - __Required.__ You must implement this method to apply this mixin. - Attempts to add the passed object to the receiver if the object is not - already present in the collection. If the object is present, this method - has no effect. - If the passed object is of a type not supported by the receiver, - then this method should raise an exception. - @method addObject - @param {Object} object The object to add to the enumerable. - @return {Object} the passed object - @public - */ - addObject: null, + function InjectedProperty(type, name) { + this.type = type; + this.name = name; - /** - Adds each object in the passed enumerable to the receiver. - @method addObjects - @param {Ember.Enumerable} objects the objects to add. - @return {Object} receiver - @public - */ - addObjects: function (objects) { - var _this = this; + this._super$Constructor(injectedPropertyGet); + AliasedPropertyPrototype.oneWay.call(this); + } - _emberMetal.beginPropertyChanges(this); - objects.forEach(function (obj) { - return _this.addObject(obj); - }); - _emberMetal.endPropertyChanges(this); - return this; - }, + function injectedPropertyGet(keyName) { + var desc = this[keyName]; + var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat - /** - __Required.__ You must implement this method to apply this mixin. - Attempts to remove the passed object from the receiver collection if the - object is present in the collection. If the object is not present, - this method has no effect. - If the passed object is of a type not supported by the receiver, - then this method should raise an exception. - @method removeObject - @param {Object} object The object to remove from the enumerable. - @return {Object} the passed object - @public - */ - removeObject: null, + _emberMetalDebug.assert('InjectedProperties should be defined with the Ember.inject computed property macros.', desc && desc.isDescriptor && desc.type); + _emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', owner); - /** - Removes each object in the passed enumerable from the receiver. - @method removeObjects - @param {Ember.Enumerable} objects the objects to remove - @return {Object} receiver - @public - */ - removeObjects: function (objects) { - _emberMetal.beginPropertyChanges(this); - for (var i = objects.length - 1; i >= 0; i--) { - this.removeObject(objects[i]); - } - _emberMetal.endPropertyChanges(this); - return this; - } - }); + return owner.lookup(desc.type + ':' + (desc.name || keyName)); + } + + InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); + + var InjectedPropertyPrototype = InjectedProperty.prototype; + var ComputedPropertyPrototype = _emberMetalComputed.ComputedProperty.prototype; + var AliasedPropertyPrototype = _emberMetalAlias.AliasedProperty.prototype; + + InjectedPropertyPrototype._super$Constructor = _emberMetalComputed.ComputedProperty; + + InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; + InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; + InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; }); -enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ +enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { + /* eslint no-console:off */ + /* global console */ 'use strict'; + exports.instrument = instrument; + exports._instrumentStart = _instrumentStart; + exports.subscribe = subscribe; + exports.unsubscribe = unsubscribe; + exports.reset = reset; + /** - ## Overview - - This mixin provides properties and property observing functionality, core - features of the Ember object model. - - Properties and observers allow one object to observe changes to a - property on another object. This is one of the fundamental ways that - models, controllers and views communicate with each other in an Ember - application. - - Any object that has this mixin applied can be used in observer - operations. That includes `Ember.Object` and most objects you will - interact with as you write your Ember application. - - Note that you will not generally apply this mixin to classes yourself, - but you will use the features provided by this module frequently, so it - is important to understand how to use it. - - ## Using `get()` and `set()` - - Because of Ember's support for bindings and observers, you will always - access properties using the get method, and set properties using the - set method. This allows the observing objects to be notified and - computed properties to be handled properly. + The purpose of the Ember Instrumentation module is + to provide efficient, general-purpose instrumentation + for Ember. - More documentation about `get` and `set` are below. + Subscribe to a listener by using `Ember.subscribe`: - ## Observing Property Changes + ```javascript + Ember.subscribe("render", { + before(name, timestamp, payload) { - You typically observe property changes simply by using the `Ember.observer` - function in classes that you write. + }, - For example: + after(name, timestamp, payload) { - ```javascript - Ember.Object.extend({ - valueObserver: Ember.observer('value', function(sender, key, value, rev) { - // Executes whenever the "value" property changes - // See the addObserver method for more information about the callback arguments - }) + } }); ``` - Although this is the most common way to add an observer, this capability - is actually built into the `Ember.Object` class on top of two methods - defined in this mixin: `addObserver` and `removeObserver`. You can use - these two methods to add and remove observers yourself if you need to - do so at runtime. + If you return a value from the `before` callback, that same + value will be passed as a fourth parameter to the `after` + callback. - To add an observer for a property, call: + Instrument a block of code by using `Ember.instrument`: ```javascript - object.addObserver('propertyKey', targetObject, targetAction) + Ember.instrument("render.handlebars", payload, function() { + // rendering logic + }, binding); ``` - This will call the `targetAction` method on the `targetObject` whenever - the value of the `propertyKey` changes. + Event names passed to `Ember.instrument` are namespaced + by periods, from more general to more specific. Subscribers + can listen for events by whatever level of granularity they + are interested in. - Note that if `propertyKey` is a computed property, the observer will be - called when any of the property dependencies are changed, even if the - resulting value of the computed property is unchanged. This is necessary - because computed properties are not computed until `get` is called. + In the above example, the event is `render.handlebars`, + and the subscriber listened for all events beginning with + `render`. It would receive callbacks for events named + `render`, `render.handlebars`, `render.container`, or + even `render.handlebars.layout`. - @class Observable + @class Instrumentation @namespace Ember - @public + @static + @private */ - exports.default = _emberMetal.Mixin.create({ + var subscribers = []; + exports.subscribers = subscribers; + var cache = {}; - /** - Retrieves the value of a property from the object. - This method is usually similar to using `object[keyName]` or `object.keyName`, - however it supports both computed properties and the unknownProperty - handler. - Because `get` unifies the syntax for accessing all these kinds - of properties, it can make many refactorings easier, such as replacing a - simple property with a computed property, or vice versa. - ### Computed Properties - Computed properties are methods defined with the `property` modifier - declared at the end, such as: - ```javascript - fullName: Ember.computed('firstName', 'lastName', function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }) - ``` - When you call `get` on a computed property, the function will be - called and the return value will be returned instead of the function - itself. - ### Unknown Properties - Likewise, if you try to call `get` on a property whose value is - `undefined`, the `unknownProperty()` method will be called on the object. - If this method returns any value other than `undefined`, it will be returned - instead. This allows you to implement "virtual" properties that are - not defined upfront. - @method get - @param {String} keyName The property to retrieve - @return {Object} The property value or undefined. - @public - */ - get: function (keyName) { - return _emberMetal.get(this, keyName); - }, + function populateListeners(name) { + var listeners = []; + var subscriber = undefined; - /** - To get the values of multiple properties at once, call `getProperties` - with a list of strings or an array: - ```javascript - record.getProperties('firstName', 'lastName', 'zipCode'); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - is equivalent to: - ```javascript - record.getProperties(['firstName', 'lastName', 'zipCode']); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - @method getProperties - @param {String...|Array} list of keys to get - @return {Object} - @public - */ - getProperties: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var i = 0; i < subscribers.length; i++) { + subscriber = subscribers[i]; + if (subscriber.regex.test(name)) { + listeners.push(subscriber.object); } + } - return _emberMetal.getProperties.apply(null, [this].concat(args)); - }, - - /** - Sets the provided key or path to the value. - ```javascript - record.set("key", value); - ``` - This method is generally very similar to calling `object["key"] = value` or - `object.key = value`, except that it provides support for computed - properties, the `setUnknownProperty()` method and property observers. - ### Computed Properties - If you try to set a value on a key that has a computed property handler - defined (see the `get()` method for an example), then `set()` will call - that method, passing both the value and key instead of simply changing - the value itself. This is useful for those times when you need to - implement a property that is composed of one or more member - properties. - ### Unknown Properties - If you try to set a value on a key that is undefined in the target - object, then the `setUnknownProperty()` handler will be called instead. This - gives you an opportunity to implement complex "virtual" properties that - are not predefined on the object. If `setUnknownProperty()` returns - undefined, then `set()` will simply set the value on the object. - ### Property Observers - In addition to changing the property, `set()` will also register a property - change with the object. Unless you have placed this call inside of a - `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers - (i.e. observer methods declared on the same object), will be called - immediately. Any "remote" observers (i.e. observer methods declared on - another object) will be placed in a queue and called at a later time in a - coalesced manner. - @method set - @param {String} keyName The property to set - @param {Object} value The value to set or `null`. - @return {Object} The passed value - @public - */ - set: function (keyName, value) { - return _emberMetal.set(this, keyName, value); - }, - - /** - Sets a list of properties at once. These properties are set inside - a single `beginPropertyChanges` and `endPropertyChanges` batch, so - observers will be buffered. - ```javascript - record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); - ``` - @method setProperties - @param {Object} hash the hash of keys and values to set - @return {Object} The passed in hash - @public - */ - setProperties: function (hash) { - return _emberMetal.setProperties(this, hash); - }, - - /** - Begins a grouping of property changes. - You can use this method to group property changes so that notifications - will not be sent until the changes are finished. If you plan to make a - large number of changes to an object at one time, you should call this - method at the beginning of the changes to begin deferring change - notifications. When you are done making changes, call - `endPropertyChanges()` to deliver the deferred change notifications and end - deferring. - @method beginPropertyChanges - @return {Ember.Observable} - @private - */ - beginPropertyChanges: function () { - _emberMetal.beginPropertyChanges(); - return this; - }, - - /** - Ends a grouping of property changes. - You can use this method to group property changes so that notifications - will not be sent until the changes are finished. If you plan to make a - large number of changes to an object at one time, you should call - `beginPropertyChanges()` at the beginning of the changes to defer change - notifications. When you are done making changes, call this method to - deliver the deferred change notifications and end deferring. - @method endPropertyChanges - @return {Ember.Observable} - @private - */ - endPropertyChanges: function () { - _emberMetal.endPropertyChanges(); - return this; - }, + cache[name] = listeners; + return listeners; + } - /** - Notify the observer system that a property is about to change. - Sometimes you need to change a value directly or indirectly without - actually calling `get()` or `set()` on it. In this case, you can use this - method and `propertyDidChange()` instead. Calling these two methods - together will notify all observers that the property has potentially - changed value. - Note that you must always call `propertyWillChange` and `propertyDidChange` - as a pair. If you do not, it may get the property change groups out of - order and cause notifications to be delivered more often than you would - like. - @method propertyWillChange - @param {String} keyName The property key that is about to change. - @return {Ember.Observable} - @private - */ - propertyWillChange: function (keyName) { - _emberMetal.propertyWillChange(this, keyName); - return this; - }, + var time = (function () { + var perf = 'undefined' !== typeof window ? window.performance || {} : {}; + var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; + // fn.bind will be available in all the browsers that support the advanced window.performance... ;-) + return fn ? fn.bind(perf) : function () { + return +new Date(); + }; + })(); - /** - Notify the observer system that a property has just changed. - Sometimes you need to change a value directly or indirectly without - actually calling `get()` or `set()` on it. In this case, you can use this - method and `propertyWillChange()` instead. Calling these two methods - together will notify all observers that the property has potentially - changed value. - Note that you must always call `propertyWillChange` and `propertyDidChange` - as a pair. If you do not, it may get the property change groups out of - order and cause notifications to be delivered more often than you would - like. - @method propertyDidChange - @param {String} keyName The property key that has just changed. - @return {Ember.Observable} - @private - */ - propertyDidChange: function (keyName) { - _emberMetal.propertyDidChange(this, keyName); - return this; - }, + /** + Notifies event's subscribers, calls `before` and `after` hooks. + + @method instrument + @namespace Ember.Instrumentation + + @param {String} [name] Namespaced event name. + @param {Object} _payload + @param {Function} callback Function that you're instrumenting. + @param {Object} binding Context that instrument function is called with. + @private + */ - /** - Convenience method to call `propertyWillChange` and `propertyDidChange` in - succession. - @method notifyPropertyChange - @param {String} keyName The property key to be notified about. - @return {Ember.Observable} - @public - */ - notifyPropertyChange: function (keyName) { - this.propertyWillChange(keyName); - this.propertyDidChange(keyName); - return this; - }, + function instrument(name, _payload, callback, binding) { + if (arguments.length <= 3 && typeof _payload === 'function') { + binding = callback; + callback = _payload; + _payload = undefined; + } + if (subscribers.length === 0) { + return callback.call(binding); + } + var payload = _payload || {}; + var finalizer = _instrumentStart(name, function () { + return payload; + }); - /** - Adds an observer on a property. - This is the core method used to register an observer for a property. - Once you call this method, any time the key's value is set, your observer - will be notified. Note that the observers are triggered any time the - value is set, regardless of whether it has actually changed. Your - observer should be prepared to handle that. - You can also pass an optional context parameter to this method. The - context will be passed to your observer method whenever it is triggered. - Note that if you add the same target/method pair on a key multiple times - with different context parameters, your observer will only be called once - with the last context you passed. - ### Observer Methods - Observer methods you pass should generally have the following signature if - you do not pass a `context` parameter: - ```javascript - fooDidChange: function(sender, key, value, rev) { }; - ``` - The sender is the object that changed. The key is the property that - changes. The value property is currently reserved and unused. The rev - is the last property revision of the object when it changed, which you can - use to detect if the key value has really changed or not. - If you pass a `context` parameter, the context will be passed before the - revision like so: - ```javascript - fooDidChange: function(sender, key, value, context, rev) { }; - ``` - Usually you will not need the value, context or revision parameters at - the end. In this case, it is common to write observer methods that take - only a sender and key value as parameters or, if you aren't interested in - any of these values, to write an observer that has no parameters at all. - @method addObserver - @param {String} key The key to observer - @param {Object} target The target object to invoke - @param {String|Function} method The method to invoke. - @public - */ - addObserver: function (key, target, method) { - _emberMetal.addObserver(this, key, target, method); - }, + if (finalizer) { + return withFinalizer(callback, finalizer, payload, binding); + } else { + return callback.call(binding); + } + } - /** - Remove an observer you have previously registered on this object. Pass - the same key, target, and method you passed to `addObserver()` and your - target will no longer receive notifications. - @method removeObserver - @param {String} key The key to observer - @param {Object} target The target object to invoke - @param {String|Function} method The method to invoke. - @public - */ - removeObserver: function (key, target, method) { - _emberMetal.removeObserver(this, key, target, method); - }, + var flaggedInstrument = undefined; + if (_emberMetalFeatures.default('ember-improved-instrumentation')) { + exports.flaggedInstrument = flaggedInstrument = instrument; + } else { + exports.flaggedInstrument = flaggedInstrument = function (name, payload, callback) { + return callback(); + }; + } + exports.flaggedInstrument = flaggedInstrument; - /** - Returns `true` if the object currently has observers registered for a - particular key. You can use this method to potentially defer performing - an expensive action until someone begins observing a particular property - on the object. - @method hasObserverFor - @param {String} key Key to check - @return {Boolean} - @private - */ - hasObserverFor: function (key) { - return _emberMetal.hasListeners(this, key + ':change'); - }, + function withFinalizer(callback, finalizer, payload, binding) { + var result = undefined; + try { + result = callback.call(binding); + } catch (e) { + payload.exception = e; + result = payload; + } finally { + finalizer(); + } + return result; + } - /** - Retrieves the value of a property, or a default value in the case that the - property returns `undefined`. - ```javascript - person.getWithDefault('lastName', 'Doe'); - ``` - @method getWithDefault - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public - */ - getWithDefault: function (keyName, defaultValue) { - return _emberMetal.getWithDefault(this, keyName, defaultValue); - }, + function NOOP() {} - /** - Set the value of a property to the current value plus some amount. - ```javascript - person.incrementProperty('age'); - team.incrementProperty('score', 2); - ``` - @method incrementProperty - @param {String} keyName The name of the property to increment - @param {Number} increment The amount to increment by. Defaults to 1 - @return {Number} The new property value - @public - */ - incrementProperty: function (keyName, increment) { - if (_emberMetal.isNone(increment)) { - increment = 1; - } - _emberMetal.assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment)); - return _emberMetal.set(this, keyName, (parseFloat(_emberMetal.get(this, keyName)) || 0) + increment); - }, + // private for now - /** - Set the value of a property to the current value minus some amount. - ```javascript - player.decrementProperty('lives'); - orc.decrementProperty('health', 5); - ``` - @method decrementProperty - @param {String} keyName The name of the property to decrement - @param {Number} decrement The amount to decrement by. Defaults to 1 - @return {Number} The new property value - @public - */ - decrementProperty: function (keyName, decrement) { - if (_emberMetal.isNone(decrement)) { - decrement = 1; - } - _emberMetal.assert('Must pass a numeric value to decrementProperty', !isNaN(parseFloat(decrement)) && isFinite(decrement)); - return _emberMetal.set(this, keyName, (_emberMetal.get(this, keyName) || 0) - decrement); - }, + function _instrumentStart(name, _payload, _payloadParam) { + if (subscribers.length === 0) { + return NOOP; + } - /** - Set the value of a boolean property to the opposite of its - current value. - ```javascript - starship.toggleProperty('warpDriveEngaged'); - ``` - @method toggleProperty - @param {String} keyName The name of the property to toggle - @return {Boolean} The new property value - @public - */ - toggleProperty: function (keyName) { - return _emberMetal.set(this, keyName, !_emberMetal.get(this, keyName)); - }, + var listeners = cache[name]; - /** - Returns the cached value of a computed property, if it exists. - This allows you to inspect the value of a computed property - without accidentally invoking it if it is intended to be - generated lazily. - @method cacheFor - @param {String} keyName - @return {Object} The cached value of the computed property, if any - @public - */ - cacheFor: function (keyName) { - return _emberMetal.cacheFor(this, keyName); - }, + if (!listeners) { + listeners = populateListeners(name); + } - // intended for debugging purposes - observersForKey: function (keyName) { - return _emberMetal.observersFor(this, keyName); + if (listeners.length === 0) { + return NOOP; } - }); -}); -enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros) { - 'use strict'; - /** - @module ember - @submodule ember-runtime - */ + var payload = _payload(_payloadParam); - function tap(proxy, promise) { - _emberMetal.setProperties(proxy, { - isFulfilled: false, - isRejected: false - }); + var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE; + var timeName = undefined; + if (STRUCTURED_PROFILE) { + timeName = name + ': ' + payload.object; + console.time(timeName); + } - return promise.then(function (value) { - if (!proxy.isDestroyed && !proxy.isDestroying) { - _emberMetal.setProperties(proxy, { - content: value, - isFulfilled: true - }); + var beforeValues = new Array(listeners.length); + var i = undefined, + listener = undefined; + var timestamp = time(); + for (i = 0; i < listeners.length; i++) { + listener = listeners[i]; + beforeValues[i] = listener.before(name, timestamp, payload); + } + + return function _instrumentEnd() { + var i = undefined, + listener = undefined; + var timestamp = time(); + for (i = 0; i < listeners.length; i++) { + listener = listeners[i]; + if (typeof listener.after === 'function') { + listener.after(name, timestamp, payload, beforeValues[i]); + } } - return value; - }, function (reason) { - if (!proxy.isDestroyed && !proxy.isDestroying) { - _emberMetal.setProperties(proxy, { - reason: reason, - isRejected: true - }); + + if (STRUCTURED_PROFILE) { + console.timeEnd(timeName); } - throw reason; - }, 'Ember: PromiseProxy'); + }; } /** - A low level mixin making ObjectProxy promise-aware. + Subscribes to a particular event or instrumented block of code. - ```javascript - let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); + @method subscribe + @namespace Ember.Instrumentation - let proxy = ObjectPromiseProxy.create({ - promise: Ember.RSVP.cast($.getJSON('/some/remote/data.json')) - }); + @param {String} [pattern] Namespaced event name. + @param {Object} [object] Before and After hooks. - proxy.then(function(json){ - // the json - }, function(reason) { - // the reason why you have no json - }); - ``` + @return {Subscriber} + @private + */ + + function subscribe(pattern, object) { + var paths = pattern.split('.'); + var path = undefined; + var regex = []; + + for (var i = 0; i < paths.length; i++) { + path = paths[i]; + if (path === '*') { + regex.push('[^\\.]*'); + } else { + regex.push(path); + } + } + + regex = regex.join('\\.'); + regex = regex + '(\\..*)?'; + + var subscriber = { + pattern: pattern, + regex: new RegExp('^' + regex + '$'), + object: object + }; + + subscribers.push(subscriber); + cache = {}; + + return subscriber; + } + + /** + Unsubscribes from a particular event or instrumented block of code. - the proxy has bindable attributes which - track the promises life cycle + @method unsubscribe + @namespace Ember.Instrumentation - ```javascript - proxy.get('isPending') //=> true - proxy.get('isSettled') //=> false - proxy.get('isRejected') //=> false - proxy.get('isFulfilled') //=> false - ``` + @param {Object} [subscriber] + @private + */ + + function unsubscribe(subscriber) { + var index = undefined; + + for (var i = 0; i < subscribers.length; i++) { + if (subscribers[i] === subscriber) { + index = i; + } + } + + subscribers.splice(index, 1); + cache = {}; + } + + /** + Resets `Ember.Instrumentation` by flushing list of subscribers. - When the $.getJSON completes, and the promise is fulfilled - with json, the life cycle attributes will update accordingly. - Note that $.getJSON doesn't return an ECMA specified promise, - it is useful to wrap this with an `RSVP.cast` so that it behaves - as a spec compliant promise. + @method reset + @namespace Ember.Instrumentation + @private + */ + + function reset() { + subscribers.length = 0; + cache = {}; + } +}); +enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, _emberMetalIs_empty) { + 'use strict'; + + exports.default = isBlank; + + /** + A value is blank if it is empty or a whitespace string. ```javascript - proxy.get('isPending') //=> false - proxy.get('isSettled') //=> true - proxy.get('isRejected') //=> false - proxy.get('isFulfilled') //=> true + Ember.isBlank(); // true + Ember.isBlank(null); // true + Ember.isBlank(undefined); // true + Ember.isBlank(''); // true + Ember.isBlank([]); // true + Ember.isBlank('\n\t'); // true + Ember.isBlank(' '); // true + Ember.isBlank({}); // false + Ember.isBlank('\n\t Hello'); // false + Ember.isBlank('Hello world'); // false + Ember.isBlank([1,2,3]); // false ``` - As the proxy is an ObjectProxy, and the json now its content, - all the json properties will be available directly from the proxy. + @method isBlank + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @since 1.5.0 + @public + */ + + function isBlank(obj) { + return _emberMetalIs_empty.default(obj) || typeof obj === 'string' && obj.match(/\S/) === null; + } +}); +enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, _emberMetalProperty_get, _emberMetalIs_none) { + 'use strict'; + + exports.default = isEmpty; + + /** + Verifies that a value is `null` or an empty string, empty array, + or empty function. - ```javascript - // Assuming the following json: - { - firstName: 'Stefan', - lastName: 'Penner' - } + Constrains the rules on `Ember.isNone` by returning true for empty + string and empty arrays. - // both properties will accessible on the proxy - proxy.get('firstName') //=> 'Stefan' - proxy.get('lastName') //=> 'Penner' + ```javascript + Ember.isEmpty(); // true + Ember.isEmpty(null); // true + Ember.isEmpty(undefined); // true + Ember.isEmpty(''); // true + Ember.isEmpty([]); // true + Ember.isEmpty({}); // false + Ember.isEmpty('Adam Hawkins'); // false + Ember.isEmpty([0,1,2]); // false + Ember.isEmpty('\n\t'); // false + Ember.isEmpty(' '); // false ``` - @class Ember.PromiseProxyMixin + @method isEmpty + @for Ember + @param {Object} obj Value to test + @return {Boolean} @public */ - exports.default = _emberMetal.Mixin.create({ - /** - If the proxied promise is rejected this will contain the reason - provided. - @property reason - @default null - @public - */ - reason: null, - - /** - Once the proxied promise has settled this will become `false`. - @property isPending - @default true - @public - */ - isPending: _emberRuntimeComputedComputed_macros.not('isSettled').readOnly(), - /** - Once the proxied promise has settled this will become `true`. - @property isSettled - @default false - @public - */ - isSettled: _emberRuntimeComputedComputed_macros.or('isRejected', 'isFulfilled').readOnly(), + function isEmpty(obj) { + var none = _emberMetalIs_none.default(obj); + if (none) { + return none; + } - /** - Will become `true` if the proxied promise is rejected. - @property isRejected - @default false - @public - */ - isRejected: false, + if (typeof obj.size === 'number') { + return !obj.size; + } - /** - Will become `true` if the proxied promise is fulfilled. - @property isFulfilled - @default false - @public - */ - isFulfilled: false, + var objectType = typeof obj; - /** - The promise whose fulfillment value is being proxied by this object. - This property must be specified upon creation, and should not be - changed once created. - Example: - ```javascript - Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({ - promise: - }); - ``` - @property promise - @public - */ - promise: _emberMetal.computed({ - get: function () { - throw new _emberMetal.Error('PromiseProxy\'s promise must be set'); - }, - set: function (key, promise) { - return tap(this, promise); + if (objectType === 'object') { + var size = _emberMetalProperty_get.get(obj, 'size'); + if (typeof size === 'number') { + return !size; } - }), + } - /** - An alias to the proxied promise's `then`. - See RSVP.Promise.then. - @method then - @param {Function} callback - @return {RSVP.Promise} - @public - */ - then: promiseAlias('then'), + if (typeof obj.length === 'number' && objectType !== 'function') { + return !obj.length; + } - /** - An alias to the proxied promise's `catch`. - See RSVP.Promise.catch. - @method catch - @param {Function} callback - @return {RSVP.Promise} - @since 1.3.0 - @public - */ - 'catch': promiseAlias('catch'), + if (objectType === 'object') { + var _length = _emberMetalProperty_get.get(obj, 'length'); + if (typeof _length === 'number') { + return !_length; + } + } - /** - An alias to the proxied promise's `finally`. - See RSVP.Promise.finally. - @method finally - @param {Function} callback - @return {RSVP.Promise} - @since 1.3.0 - @public - */ - 'finally': promiseAlias('finally') + return false; + } +}); +enifed("ember-metal/is_none", ["exports"], function (exports) { + /** + Returns true if the passed value is null or undefined. This avoids errors + from JSLint complaining about use of ==, which can be technically + confusing. + + ```javascript + Ember.isNone(); // true + Ember.isNone(null); // true + Ember.isNone(undefined); // true + Ember.isNone(''); // false + Ember.isNone([]); // false + Ember.isNone(function() {}); // false + ``` + + @method isNone + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @public + */ + "use strict"; - }); + exports.default = isNone; - function promiseAlias(name) { - return function () { - var promise = _emberMetal.get(this, 'promise'); - return promise[name].apply(promise, arguments); - }; + function isNone(obj) { + return obj === null || obj === undefined; } }); -enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { + 'use strict'; + + exports.default = isPresent; + /** - @module ember - @submodule ember-runtime + A value is present if it not `isBlank`. + + ```javascript + Ember.isPresent(); // false + Ember.isPresent(null); // false + Ember.isPresent(undefined); // false + Ember.isPresent(''); // false + Ember.isPresent(' '); // false + Ember.isPresent('\n\t'); // false + Ember.isPresent([]); // false + Ember.isPresent({ length: 0 }) // false + Ember.isPresent(false); // true + Ember.isPresent(true); // true + Ember.isPresent('string'); // true + Ember.isPresent(0); // true + Ember.isPresent(function() {}) // true + Ember.isPresent({}); // true + Ember.isPresent(false); // true + Ember.isPresent('\n\t Hello'); // true + Ember.isPresent([1,2,3]); // true + ``` + + @method isPresent + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @since 1.8.0 + @public */ + function isPresent(obj) { + return !_emberMetalIs_blank.default(obj); + } +}); +enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { 'use strict'; - exports.buildFakeRegistryWithDeprecations = buildFakeRegistryWithDeprecations; + exports.isProxy = isProxy; + + function isProxy(value) { + if (typeof value === 'object' && value) { + var meta = _emberMetalMeta.peekMeta(value); + return meta && meta.isProxy(); + } + + return false; + } +}); +enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { + 'use strict'; /** - RegistryProxyMixin is used to provide public access to specific - registry functionality. + Helper class that allows you to register your library with Ember. - @class RegistryProxyMixin + Singleton created at `Ember.libraries`. + + @class Libraries + @constructor @private */ - exports.default = _emberMetal.Mixin.create({ - __registry__: null, - - /** - Given a fullName return the corresponding factory. - @public - @method resolveRegistration - @param {String} fullName - @return {Function} fullName's factory - */ - resolveRegistration: registryAlias('resolve'), - - /** - Registers a factory that can be used for dependency injection (with - `inject`) or for service lookup. Each factory is registered with - a full name including two parts: `type:name`. - A simple example: - ```javascript - let App = Ember.Application.create(); - App.Orange = Ember.Object.extend(); - App.register('fruit:favorite', App.Orange); - ``` - Ember will resolve factories from the `App` namespace automatically. - For example `App.CarsController` will be discovered and returned if - an application requests `controller:cars`. - An example of registering a controller with a non-standard name: - ```javascript - let App = Ember.Application.create(); - let Session = Ember.Controller.extend(); - App.register('controller:session', Session); - // The Session controller can now be treated like a normal controller, - // despite its non-standard name. - App.ApplicationController = Ember.Controller.extend({ - needs: ['session'] - }); - ``` - Registered factories are **instantiated** by having `create` - called on them. Additionally they are **singletons**, each time - they are looked up they return the same instance. - Some examples modifying that default behavior: - ```javascript - let App = Ember.Application.create(); - App.Person = Ember.Object.extend(); - App.Orange = Ember.Object.extend(); - App.Email = Ember.Object.extend(); - App.session = Ember.Object.create(); - App.register('model:user', App.Person, { singleton: false }); - App.register('fruit:favorite', App.Orange); - App.register('communication:main', App.Email, { singleton: false }); - App.register('session', App.session, { instantiate: false }); - ``` - @method register - @param fullName {String} type:name (e.g., 'model:user') - @param factory {Function} (e.g., App.Person) - @param options {Object} (optional) disable instantiation or singleton usage - @public - */ - register: registryAlias('register'), - /** - Unregister a factory. - ```javascript - let App = Ember.Application.create(); - let User = Ember.Object.extend(); - App.register('model:user', User); - App.resolveRegistration('model:user').create() instanceof User //=> true - App.unregister('model:user') - App.resolveRegistration('model:user') === undefined //=> true - ``` - @public - @method unregister - @param {String} fullName - */ - unregister: registryAlias('unregister'), + var Libraries = (function () { + function Libraries() { + babelHelpers.classCallCheck(this, Libraries); - /** - Check if a factory is registered. - @public - @method hasRegistration - @param {String} fullName - @return {Boolean} - */ - hasRegistration: registryAlias('has'), + this._registry = []; + this._coreLibIndex = 0; + } - /** - Register an option for a particular factory. - @public - @method registerOption - @param {String} fullName - @param {String} optionName - @param {Object} options - */ - registerOption: registryAlias('option'), + Libraries.prototype.isRegistered = function isRegistered(name) { + return !!this._getLibraryByName(name); + }; - /** - Return a specific registered option for a particular factory. - @public - @method registeredOption - @param {String} fullName - @param {String} optionName - @return {Object} options - */ - registeredOption: registryAlias('getOption'), + return Libraries; + })(); - /** - Register options for a particular factory. - @public - @method registerOptions - @param {String} fullName - @param {Object} options - */ - registerOptions: registryAlias('options'), + exports.Libraries = Libraries; - /** - Return registered options for a particular factory. - @public - @method registeredOptions - @param {String} fullName - @return {Object} options - */ - registeredOptions: registryAlias('getOptions'), + Libraries.prototype = { + constructor: Libraries, - /** - Allow registering options for all factories of a type. - ```javascript - let App = Ember.Application.create(); - let appInstance = App.buildInstance(); - // if all of type `connection` must not be singletons - appInstance.optionsForType('connection', { singleton: false }); - appInstance.register('connection:twitter', TwitterConnection); - appInstance.register('connection:facebook', FacebookConnection); - let twitter = appInstance.lookup('connection:twitter'); - let twitter2 = appInstance.lookup('connection:twitter'); - twitter === twitter2; // => false - let facebook = appInstance.lookup('connection:facebook'); - let facebook2 = appInstance.lookup('connection:facebook'); - facebook === facebook2; // => false - ``` - @public - @method registerOptionsForType - @param {String} type - @param {Object} options - */ - registerOptionsForType: registryAlias('optionsForType'), + _getLibraryByName: function (name) { + var libs = this._registry; + var count = libs.length; - /** - Return the registered options for all factories of a type. - @public - @method registeredOptionsForType - @param {String} type - @return {Object} options - */ - registeredOptionsForType: registryAlias('getOptionsForType'), + for (var i = 0; i < count; i++) { + if (libs[i].name === name) { + return libs[i]; + } + } + }, - /** - Define a dependency injection onto a specific factory or all factories - of a type. - When Ember instantiates a controller, view, or other framework component - it can attach a dependency to that component. This is often used to - provide services to a set of framework components. - An example of providing a session object to all controllers: - ```javascript - let App = Ember.Application.create(); - let Session = Ember.Object.extend({ isAuthenticated: false }); - // A factory must be registered before it can be injected - App.register('session:main', Session); - // Inject 'session:main' onto all factories of the type 'controller' - // with the name 'session' - App.inject('controller', 'session', 'session:main'); - App.IndexController = Ember.Controller.extend({ - isLoggedIn: Ember.computed.alias('session.isAuthenticated') - }); - ``` - Injections can also be performed on specific factories. - ```javascript - App.inject(, , ) - App.inject('route', 'source', 'source:main') - App.inject('route:application', 'email', 'model:email') - ``` - It is important to note that injections can only be performed on - classes that are instantiated by Ember itself. Instantiating a class - directly (via `create` or `new`) bypasses the dependency injection - system. - **Note:** Ember-Data instantiates its models in a unique manner, and consequently - injections onto models (or all models) will not work as expected. Injections - on models can be enabled by setting `EmberENV.MODEL_FACTORY_INJECTIONS` - to `true`. - @public - @method inject - @param factoryNameOrType {String} - @param property {String} - @param injectionName {String} - **/ - inject: registryAlias('injection') - }); + register: function (name, version, isCoreLibrary) { + var index = this._registry.length; - function registryAlias(name) { - return function () { - var _registry__; + if (!this._getLibraryByName(name)) { + if (isCoreLibrary) { + index = this._coreLibIndex++; + } + this._registry.splice(index, 0, { name: name, version: version }); + } else { + _emberMetalDebug.warn('Library "' + name + '" is already registered with Ember.', false, { id: 'ember-metal.libraries-register' }); + } + }, - return (_registry__ = this.__registry__)[name].apply(_registry__, arguments); - }; - } + registerCoreLibrary: function (name, version) { + this.register(name, version, true); + }, - function buildFakeRegistryWithDeprecations(instance, typeForMessage) { - var fakeRegistry = {}; - var registryProps = { - resolve: 'resolveRegistration', - register: 'register', - unregister: 'unregister', - has: 'hasRegistration', - option: 'registerOption', - options: 'registerOptions', - getOptions: 'registeredOptions', - optionsForType: 'registerOptionsForType', - getOptionsForType: 'registeredOptionsForType', - injection: 'inject' - }; + deRegister: function (name) { + var lib = this._getLibraryByName(name); + var index = undefined; - for (var deprecatedProperty in registryProps) { - fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]); + if (lib) { + index = this._registry.indexOf(lib); + this._registry.splice(index, 1); + } } + }; - return fakeRegistry; - } - - function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) { - return function () { - _emberMetal.deprecate('Using `' + typeForMessage + '.registry.' + deprecatedProperty + '` is deprecated. Please use `' + typeForMessage + '.' + nonDeprecatedProperty + '` instead.', false, { - id: 'ember-application.app-instance-registry', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-application-registry-ember-applicationinstance-registry' - }); - return instance[nonDeprecatedProperty].apply(instance, arguments); + if (_emberMetalFeatures.default('ember-libraries-isregistered')) { + Libraries.prototype.isRegistered = function (name) { + return !!this._getLibraryByName(name); }; } + + exports.default = new Libraries(); }); -enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { +enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) { /** @module ember - @submodule ember-runtime + @submodule ember-metal */ + /* + JavaScript (before ES6) does not have a Map implementation. Objects, + which are often used as dictionaries, may only have Strings as keys. + + Because Ember has a way to get a unique identifier for every object + via `Ember.guidFor`, we can implement a performant Map with arbitrary + keys. Because it is commonly used in low-level bookkeeping, Map is + implemented as a pure JavaScript object for performance. + + This implementation follows the current iteration of the ES6 proposal for + maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets), + with one exception: as we do not have the luxury of in-VM iteration, we implement a + forEach method for iteration. + + Map is mocked out to look like an Ember object, so you can do + `Ember.Map.create()` for symmetry with other Ember classes. + */ 'use strict'; + function missingFunction(fn) { + throw new TypeError(Object.prototype.toString.call(fn) + ' is not a function'); + } + + function missingNew(name) { + throw new TypeError('Constructor ' + name + ' requires \'new\''); + } + + function copyNull(obj) { + var output = new _emberUtils.EmptyObject(); + + for (var prop in obj) { + // hasOwnPropery is not needed because obj is new EmptyObject(); + output[prop] = obj[prop]; + } + + return output; + } + + function copyMap(original, newObject) { + var keys = original._keys.copy(); + var values = copyNull(original._values); + + newObject._keys = keys; + newObject._values = values; + newObject.size = original.size; + + return newObject; + } + /** - `Ember.TargetActionSupport` is a mixin that can be included in a class - to add a `triggerAction` method with semantics similar to the Handlebars - `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is - usually the best choice. This mixin is most often useful when you are - doing more complex event handling in Components. + This class is used internally by Ember and Ember Data. + Please do not use it at this time. We plan to clean it up + and add many tests soon. - @class TargetActionSupport - @namespace Ember - @extends Ember.Mixin - @private + @class OrderedSet + @namespace Ember + @constructor + @private */ - exports.default = _emberMetal.Mixin.create({ - target: null, - action: null, - actionContext: null, + function OrderedSet() { + if (this instanceof OrderedSet) { + this.clear(); + this._silenceRemoveDeprecation = false; + } else { + missingNew('OrderedSet'); + } + } - actionContextObject: _emberMetal.computed('actionContext', function () { - var actionContext = _emberMetal.get(this, 'actionContext'); + /** + @method create + @static + @return {Ember.OrderedSet} + @private + */ + OrderedSet.create = function () { + var Constructor = this; - if (typeof actionContext === 'string') { - var value = _emberMetal.get(this, actionContext); - if (value === undefined) { - value = _emberMetal.get(_emberEnvironment.context.lookup, actionContext); - } - return value; - } else { - return actionContext; - } - }), + return new Constructor(); + }; + OrderedSet.prototype = { + constructor: OrderedSet, /** - Send an `action` with an `actionContext` to a `target`. The action, actionContext - and target will be retrieved from properties of the object. For example: - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - target: Ember.computed.alias('controller'), - action: 'save', - actionContext: Ember.computed.alias('context'), - click() { - this.triggerAction(); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - The `target`, `action`, and `actionContext` can be provided as properties of - an optional object argument to `triggerAction` as well. - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - click() { - this.triggerAction({ - action: 'save', - target: this.get('controller'), - actionContext: this.get('context') - }); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. - But `target` and `action` must be specified either as properties or with the argument - to `triggerAction`, or a combination: - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - target: Ember.computed.alias('controller'), - click() { - this.triggerAction({ - action: 'save' - }); // Sends the `save` action, along with a reference to `this`, - // to the current controller - } - }); - ``` - @method triggerAction - @param opts {Object} (optional, with the optional keys action, target and/or actionContext) - @return {Boolean} true if the action was sent successfully and did not return false - @private + @method clear + @private */ - triggerAction: function () { - var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - var action = opts.action || _emberMetal.get(this, 'action'); - var target = opts.target; - - if (!target) { - target = getTarget(this); - } - - var actionContext = opts.actionContext; - - function args(options, actionName) { - var ret = []; - if (actionName) { - ret.push(actionName); - } + clear: function () { + this.presenceSet = new _emberUtils.EmptyObject(); + this.list = []; + this.size = 0; + }, - return ret.concat(options); - } + /** + @method add + @param obj + @param guid (optional, and for internal use) + @return {Ember.OrderedSet} + @private + */ + add: function (obj, _guid) { + var guid = _guid || _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; + var list = this.list; - if (typeof actionContext === 'undefined') { - actionContext = _emberMetal.get(this, 'actionContextObject') || this; + if (presenceSet[guid] !== true) { + presenceSet[guid] = true; + this.size = list.push(obj); } - if (target && action) { - var ret = undefined; + return this; + }, - if (target.send) { - ret = target.send.apply(target, args(actionContext, action)); - } else { - _emberMetal.assert('The action \'' + action + '\' did not exist on ' + target, typeof target[action] === 'function'); - ret = target[action].apply(target, args(actionContext)); - } + /** + @since 1.8.0 + @method delete + @param obj + @param _guid (optional and for internal use only) + @return {Boolean} + @private + */ + delete: function (obj, _guid) { + var guid = _guid || _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; + var list = this.list; - if (ret !== false) { - ret = true; + if (presenceSet[guid] === true) { + delete presenceSet[guid]; + var index = list.indexOf(obj); + if (index > -1) { + list.splice(index, 1); } - - return ret; + this.size = list.length; + return true; } else { return false; } - } - }); + }, - function getTarget(instance) { - // TODO: Deprecate specifying `targetObject` - var target = _emberMetal.get(instance, 'targetObject'); + /** + @method isEmpty + @return {Boolean} + @private + */ + isEmpty: function () { + return this.size === 0; + }, - // if a `targetObject` CP was provided, use it - if (target) { - return target; - } + /** + @method has + @param obj + @return {Boolean} + @private + */ + has: function (obj) { + if (this.size === 0) { + return false; + } - // if _targetObject use it - if (instance._targetObject) { - return instance._targetObject; - } + var guid = _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; - target = _emberMetal.get(instance, 'target'); - if (target) { - if (typeof target === 'string') { - var value = _emberMetal.get(instance, target); - if (value === undefined) { - value = _emberMetal.get(_emberEnvironment.context.lookup, target); - } + return presenceSet[guid] === true; + }, - return value; - } else { - return target; + /** + @method forEach + @param {Function} fn + @param self + @private + */ + forEach: function (fn /*, ...thisArg*/) { + if (typeof fn !== 'function') { + missingFunction(fn); } - } - - return null; - } -}); -enifed("ember-runtime/string_registry", ["exports"], function (exports) { - // STATE within a module is frowned apon, this exists - // to support Ember.STRINGS but shield ember internals from this legacy global - // API. - "use strict"; - - exports.setStrings = setStrings; - exports.getStrings = getStrings; - exports.get = get; - var STRINGS = {}; - function setStrings(strings) { - STRINGS = strings; - } + if (this.size === 0) { + return; + } - function getStrings() { - return STRINGS; - } + var list = this.list; - function get(name) { - return STRINGS[name]; - } -}); -enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) { - 'use strict'; + if (arguments.length === 2) { + for (var i = 0; i < list.length; i++) { + fn.call(arguments[1], list[i]); + } + } else { + for (var i = 0; i < list.length; i++) { + fn(list[i]); + } + } + }, - exports.default = _emberRuntimeSystemNamespace.default.extend(); -}); -enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray) { - 'use strict'; + /** + @method toArray + @return {Array} + @private + */ + toArray: function () { + return this.list.slice(); + }, - /** - @module ember - @submodule ember-runtime - */ + /** + @method copy + @return {Ember.OrderedSet} + @private + */ + copy: function () { + var Constructor = this.constructor; + var set = new Constructor(); - var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; - var EMPTY = []; + set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; + set.presenceSet = copyNull(this.presenceSet); + set.list = this.toArray(); + set.size = this.size; - function K() { - return this; - } + return set; + } + }; /** - An ArrayProxy wraps any other object that implements `Ember.Array` and/or - `Ember.MutableArray,` forwarding all requests. This makes it very useful for - a number of binding use cases or other cases where being able to swap - out the underlying array is useful. - - A simple example of usage: - - ```javascript - let pets = ['dog', 'cat', 'fish']; - let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); - - ap.get('firstObject'); // 'dog' - ap.set('content', ['amoeba', 'paramecium']); - ap.get('firstObject'); // 'amoeba' - ``` + A Map stores values indexed by keys. Unlike JavaScript's + default Objects, the keys of a Map can be any JavaScript + object. - This class can also be useful as a layer to transform the contents of - an array, as they are accessed. This can be done by overriding - `objectAtContent`: + Internally, a Map has two data structures: - ```javascript - let pets = ['dog', 'cat', 'fish']; - let ap = Ember.ArrayProxy.create({ - content: Ember.A(pets), - objectAtContent: function(idx) { - return this.get('content').objectAt(idx).toUpperCase(); - } - }); + 1. `keys`: an OrderedSet of all of the existing keys + 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)` - ap.get('firstObject'); // . 'DOG' - ``` + When a key/value pair is added for the first time, we + add the key to the `keys` OrderedSet, and create or + replace an entry in `values`. When an entry is deleted, + we delete its entry in `keys` and `values`. - @class ArrayProxy + @class Map @namespace Ember - @extends Ember.Object - @uses Ember.MutableArray - @public + @private + @constructor */ - exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { + function Map() { + if (this instanceof Map) { + this._keys = OrderedSet.create(); + this._keys._silenceRemoveDeprecation = true; + this._values = new _emberUtils.EmptyObject(); + this.size = 0; + } else { + missingNew('Map'); + } + } + + /** + @method create + @static + @private + */ + Map.create = function () { + var Constructor = this; + return new Constructor(); + }; + + Map.prototype = { + constructor: Map, /** - The content array. Must be an object that implements `Ember.Array` and/or - `Ember.MutableArray.` - @property content - @type Ember.Array + This property will change as the number of objects in the map changes. + @since 1.8.0 + @property size + @type number + @default 0 @private */ - content: null, + size: 0, /** - The array that the proxy pretends to be. In the default `ArrayProxy` - implementation, this and `content` are the same. Subclasses of `ArrayProxy` - can override this property to provide things like sorting and filtering. - @property arrangedContent - @private + Retrieve the value associated with a given key. + @method get + @param {*} key + @return {*} the value associated with the key, or `undefined` + @private */ - arrangedContent: _emberMetal.alias('content'), + get: function (key) { + if (this.size === 0) { + return; + } + + var values = this._values; + var guid = _emberUtils.guidFor(key); + + return values[guid]; + }, /** - Should actually retrieve the object at the specified index from the - content. You can override this method in subclasses to transform the - content item to something new. - This method will only be called if content is non-`null`. - @method objectAtContent - @param {Number} idx The index to retrieve. - @return {Object} the value or undefined if none found - @public + Adds a value to the map. If a value for the given key has already been + provided, the new value will replace the old value. + @method set + @param {*} key + @param {*} value + @return {Ember.Map} + @private */ - objectAtContent: function (idx) { - return _emberRuntimeMixinsArray.objectAt(_emberMetal.get(this, 'arrangedContent'), idx); + set: function (key, value) { + var keys = this._keys; + var values = this._values; + var guid = _emberUtils.guidFor(key); + + // ensure we don't store -0 + var k = key === -0 ? 0 : key; + + keys.add(k, guid); + + values[guid] = value; + + this.size = keys.size; + + return this; }, /** - Should actually replace the specified objects on the content array. - You can override this method in subclasses to transform the content item - into something new. - This method will only be called if content is non-`null`. - @method replaceContent - @param {Number} idx The starting index - @param {Number} amt The number of items to remove from the content. - @param {Array} objects Optional array of objects to insert or null if no - objects. - @return {void} + Removes a value from the map for an associated key. + @since 1.8.0 + @method delete + @param {*} key + @return {Boolean} true if an item was removed, false otherwise @private */ - replaceContent: function (idx, amt, objects) { - _emberMetal.get(this, 'content').replace(idx, amt, objects); + delete: function (key) { + if (this.size === 0) { + return false; + } + // don't use ES6 "delete" because it will be annoying + // to use in browsers that are not ES6 friendly; + var keys = this._keys; + var values = this._values; + var guid = _emberUtils.guidFor(key); + + if (keys.delete(key, guid)) { + delete values[guid]; + this.size = keys.size; + return true; + } else { + return false; + } }, /** - Invoked when the content property is about to change. Notifies observers that the - entire array content will change. - @private - @method _contentWillChange + Check whether a key is present. + @method has + @param {*} key + @return {Boolean} true if the item was present, false otherwise + @private */ - _contentWillChange: _emberMetal._beforeObserver('content', function () { - this._teardownContent(); - }), + has: function (key) { + return this._keys.has(key); + }, - _teardownContent: function () { - var content = _emberMetal.get(this, 'content'); + /** + Iterate over all the keys and values. Calls the function once + for each key, passing in value, key, and the map being iterated over, + in that order. + The keys are guaranteed to be iterated over in insertion order. + @method forEach + @param {Function} callback + @param {*} self if passed, the `this` value inside the + callback. By default, `this` is the map. + @private + */ + forEach: function (callback /*, ...thisArg*/) { + if (typeof callback !== 'function') { + missingFunction(callback); + } - if (content) { - _emberRuntimeMixinsArray.removeArrayObserver(content, this, { - willChange: 'contentArrayWillChange', - didChange: 'contentArrayDidChange' - }); + if (this.size === 0) { + return; + } + + var map = this; + var cb = undefined, + thisArg = undefined; + + if (arguments.length === 2) { + thisArg = arguments[1]; + cb = function (key) { + return callback.call(thisArg, map.get(key), key, map); + }; + } else { + cb = function (key) { + return callback(map.get(key), key, map); + }; } + + this._keys.forEach(cb); }, /** - Override to implement content array `willChange` observer. - @method contentArrayWillChange - @param {Ember.Array} contentArray the content array - @param {Number} start starting index of the change - @param {Number} removeCount count of items removed - @param {Number} addCount count of items added + @method clear @private */ - contentArrayWillChange: K, + clear: function () { + this._keys.clear(); + this._values = new _emberUtils.EmptyObject(); + this.size = 0; + }, + /** - Override to implement content array `didChange` observer. - @method contentArrayDidChange - @param {Ember.Array} contentArray the content array - @param {Number} start starting index of the change - @param {Number} removeCount count of items removed - @param {Number} addCount count of items added + @method copy + @return {Ember.Map} @private */ - contentArrayDidChange: K, + copy: function () { + return copyMap(this, new Map()); + } + }; - /** - Invoked when the content property changes. Notifies observers that the - entire array content has changed. - @private - @method _contentDidChange - */ - _contentDidChange: _emberMetal.observer('content', function () { - var content = _emberMetal.get(this, 'content'); + /** + @class MapWithDefault + @namespace Ember + @extends Ember.Map + @private + @constructor + @param [options] + @param {*} [options.defaultValue] + */ + function MapWithDefault(options) { + this._super$constructor(); + this.defaultValue = options.defaultValue; + } + + /** + @method create + @static + @param [options] + @param {*} [options.defaultValue] + @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns + `Ember.MapWithDefault` otherwise returns `Ember.Map` + @private + */ + MapWithDefault.create = function (options) { + if (options) { + return new MapWithDefault(options); + } else { + return new Map(); + } + }; + + MapWithDefault.prototype = Object.create(Map.prototype); + MapWithDefault.prototype.constructor = MapWithDefault; + MapWithDefault.prototype._super$constructor = Map; + MapWithDefault.prototype._super$get = Map.prototype.get; + + /** + Retrieve the value associated with a given key. + + @method get + @param {*} key + @return {*} the value associated with the key, or the default value + @private + */ + MapWithDefault.prototype.get = function (key) { + var hasValue = this.has(key); + + if (hasValue) { + return this._super$get(key); + } else { + var defaultValue = this.defaultValue(key); + this.set(key, defaultValue); + return defaultValue; + } + }; + + /** + @method copy + @return {Ember.MapWithDefault} + @private + */ + MapWithDefault.prototype.copy = function () { + var Constructor = this.constructor; + return copyMap(this, new Constructor({ + defaultValue: this.defaultValue + })); + }; + + exports.default = Map; + exports.OrderedSet = OrderedSet; + exports.Map = Map; + exports.MapWithDefault = MapWithDefault; +}); +enifed('ember-metal/merge', ['exports'], function (exports) { + /** + Merge the contents of two objects together into the first object. + + ```javascript + Ember.merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' } + var a = { first: 'Yehuda' }; + var b = { last: 'Katz' }; + Ember.merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' } + ``` + + @method merge + @for Ember + @param {Object} original The object to merge into + @param {Object} updates The object to copy properties from + @return {Object} + @public + */ + 'use strict'; - _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', content !== this); + exports.default = merge; - this._setupContent(); - }), + function merge(original, updates) { + if (!updates || typeof updates !== 'object') { + return original; + } - _setupContent: function () { - var content = _emberMetal.get(this, 'content'); + var props = Object.keys(updates); + var prop = undefined; - if (content) { - _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof content, _emberRuntimeUtils.isArray(content) || content.isDestroyed); + for (var i = 0; i < props.length; i++) { + prop = props[i]; + original[prop] = updates[prop]; + } - _emberRuntimeMixinsArray.addArrayObserver(content, this, { - willChange: 'contentArrayWillChange', - didChange: 'contentArrayDidChange' - }); - } - }, + return original; + } +}); +enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains', 'require'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains, _require) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - _arrangedContentWillChange: _emberMetal._beforeObserver('arrangedContent', function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + exports.deleteMeta = deleteMeta; + exports.meta = meta; - this.arrangedContentArrayWillChange(this, 0, len, undefined); - this.arrangedContentWillChange(this); + var counters = { + peekCalls: 0, + peekParentCalls: 0, + peekPrototypeWalks: 0, + setCalls: 0, + deleteCalls: 0, + metaCalls: 0, + metaInstantiated: 0 + }; - this._teardownArrangedContent(arrangedContent); - }), + /** + @module ember-metal + */ - _arrangedContentDidChange: _emberMetal.observer('arrangedContent', function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + /* + This declares several meta-programmed members on the Meta class. Such + meta! + + In general, the `readable` variants will give you an object (if it + already exists) that you can read but should not modify. The + `writable` variants will give you a mutable object, and they will + create it if it didn't already exist. + + The following methods will get generated metaprogrammatically, and + I'm including them here for greppability: + + writableCache, readableCache, writeWatching, + peekWatching, clearWatching, writeMixins, + peekMixins, clearMixins, writeBindings, + peekBindings, clearBindings, writeValues, + peekValues, clearValues, writeDeps, forEachInDeps + writableChainWatchers, readableChainWatchers, writableChains, + readableChains, writableTag, readableTag, writableTags, + readableTags + */ + var members = { + cache: ownMap, + weak: ownMap, + watching: inheritedMap, + mixins: inheritedMap, + bindings: inheritedMap, + values: inheritedMap, + chainWatchers: ownCustomObject, + chains: inheritedCustomObject, + tag: ownCustomObject, + tags: ownMap + }; - _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this); + // FLAGS + var SOURCE_DESTROYING = 1 << 1; + var SOURCE_DESTROYED = 1 << 2; + var META_DESTROYED = 1 << 3; + var IS_PROXY = 1 << 4; - this._setupArrangedContent(); + if (true || false) { + members.lastRendered = ownMap; + if (_require.has('ember-debug')) { + //https://github.com/emberjs/ember.js/issues/14732 + members.lastRenderedReferenceMap = ownMap; + members.lastRenderedTemplateMap = ownMap; + } + } - this.arrangedContentDidChange(this); - this.arrangedContentArrayDidChange(this, 0, undefined, len); - }), + var memberNames = Object.keys(members); + var META_FIELD = '__ember_meta__'; - _setupArrangedContent: function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var Meta = (function () { + function Meta(obj, parentMeta) { + var _this = this; - if (arrangedContent) { - _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof arrangedContent, _emberRuntimeUtils.isArray(arrangedContent) || arrangedContent.isDestroyed); + babelHelpers.classCallCheck(this, Meta); - _emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, { - willChange: 'arrangedContentArrayWillChange', - didChange: 'arrangedContentArrayDidChange' - }); - } - }, + _emberMetalDebug.runInDebug(function () { + return counters.metaInstantiated++; + }); - _teardownArrangedContent: function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + this._cache = undefined; + this._weak = undefined; + this._watching = undefined; + this._mixins = undefined; + this._bindings = undefined; + this._values = undefined; + this._deps = undefined; + this._chainWatchers = undefined; + this._chains = undefined; + this._tag = undefined; + this._tags = undefined; + + // initial value for all flags right now is false + // see FLAGS const for detailed list of flags used + this._flags = 0; + + // used only internally + this.source = obj; + + // when meta(obj).proto === obj, the object is intended to be only a + // prototype and doesn't need to actually be observable itself + this.proto = undefined; + + // The next meta in our inheritance chain. We (will) track this + // explicitly instead of using prototypical inheritance because we + // have detailed knowledge of how each property should really be + // inherited, and we can optimize it much better than JS runtimes. + this.parent = parentMeta; - if (arrangedContent) { - _emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, { - willChange: 'arrangedContentArrayWillChange', - didChange: 'arrangedContentArrayDidChange' + if (true || false) { + this._lastRendered = undefined; + _emberMetalDebug.runInDebug(function () { + _this._lastRenderedReferenceMap = undefined; + _this._lastRenderedTemplateMap = undefined; }); } - }, - - arrangedContentWillChange: K, - arrangedContentDidChange: K, - objectAt: function (idx) { - return _emberMetal.get(this, 'content') && this.objectAtContent(idx); - }, + this._initializeListeners(); + } - length: _emberMetal.computed(function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - return arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - // No dependencies since Enumerable notifies length of change - }), + Meta.prototype.isInitialized = function isInitialized(obj) { + return this.proto !== obj; + }; - _replace: function (idx, amt, objects) { - var content = _emberMetal.get(this, 'content'); - _emberMetal.assert('The content property of ' + this.constructor + ' should be set before modifying it', content); - if (content) { - this.replaceContent(idx, amt, objects); + Meta.prototype.destroy = function destroy() { + if (this.isMetaDestroyed()) { + return; } - return this; - }, - - replace: function () { - if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { - this._replace.apply(this, arguments); - } else { - throw new _emberMetal.Error('Using replace on an arranged ArrayProxy is not allowed.'); - } - }, + // remove chainWatchers to remove circular references that would prevent GC + var nodes = undefined, + key = undefined, + nodeObject = undefined; + var node = this.readableChains(); + if (node) { + NODE_STACK.push(node); + // process tree + while (NODE_STACK.length > 0) { + node = NODE_STACK.pop(); + // push children + nodes = node._chains; + if (nodes) { + for (key in nodes) { + if (nodes[key] !== undefined) { + NODE_STACK.push(nodes[key]); + } + } + } - _insertAt: function (idx, object) { - if (idx > _emberMetal.get(this, 'content.length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + // remove chainWatcher in node object + if (node._watching) { + nodeObject = node._object; + if (nodeObject) { + var foreignMeta = peekMeta(nodeObject); + // avoid cleaning up chain watchers when both current and + // foreign objects are being destroyed + // if both are being destroyed manual cleanup is not needed + // as they will be GC'ed and no non-destroyed references will + // be remaining + if (foreignMeta && !foreignMeta.isSourceDestroying()) { + _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); + } + } + } + } } - this._replace(idx, 0, [object]); - return this; - }, + this.setMetaDestroyed(); + }; - insertAt: function (idx, object) { - if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { - return this._insertAt(idx, object); - } else { - throw new _emberMetal.Error('Using insertAt on an arranged ArrayProxy is not allowed.'); - } - }, + Meta.prototype.isSourceDestroying = function isSourceDestroying() { + return (this._flags & SOURCE_DESTROYING) !== 0; + }; - removeAt: function (start, len) { - if ('number' === typeof start) { - var content = _emberMetal.get(this, 'content'); - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var indices = []; + Meta.prototype.setSourceDestroying = function setSourceDestroying() { + this._flags |= SOURCE_DESTROYING; + }; - if (start < 0 || start >= _emberMetal.get(this, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } + Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { + return (this._flags & SOURCE_DESTROYED) !== 0; + }; - if (len === undefined) { - len = 1; - } + Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { + this._flags |= SOURCE_DESTROYED; + }; - // Get a list of indices in original content to remove - for (var i = start; i < start + len; i++) { - // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent - indices.push(content.indexOf(_emberRuntimeMixinsArray.objectAt(arrangedContent, i))); - } + Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { + return (this._flags & META_DESTROYED) !== 0; + }; - // Replace in reverse order since indices will change - indices.sort(function (a, b) { - return b - a; - }); + Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { + this._flags |= META_DESTROYED; + }; - _emberMetal.beginPropertyChanges(); - for (var i = 0; i < indices.length; i++) { - this._replace(indices[i], 1, EMPTY); - } - _emberMetal.endPropertyChanges(); - } + Meta.prototype.isProxy = function isProxy() { + return (this._flags & IS_PROXY) !== 0; + }; - return this; - }, + Meta.prototype.setProxy = function setProxy() { + this._flags |= IS_PROXY; + }; - pushObject: function (obj) { - this._insertAt(_emberMetal.get(this, 'content.length'), obj); - return obj; - }, + Meta.prototype._getOrCreateOwnMap = function _getOrCreateOwnMap(key) { + return this[key] || (this[key] = new _emberUtils.EmptyObject()); + }; - pushObjects: function (objects) { - if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || _emberRuntimeUtils.isArray(objects))) { - throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + Meta.prototype._getInherited = function _getInherited(key) { + var pointer = this; + while (pointer !== undefined) { + if (pointer[key]) { + return pointer[key]; + } + pointer = pointer.parent; } - this._replace(_emberMetal.get(this, 'length'), 0, objects); - return this; - }, + }; - setObjects: function (objects) { - if (objects.length === 0) { - return this.clear(); + Meta.prototype._findInherited = function _findInherited(key, subkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var value = map[subkey]; + if (value !== undefined) { + return value; + } + } + pointer = pointer.parent; } + }; - var len = _emberMetal.get(this, 'length'); - this._replace(0, len, objects); - return this; - }, - - unshiftObject: function (obj) { - this._insertAt(0, obj); - return obj; - }, - - unshiftObjects: function (objects) { - this._replace(0, 0, objects); - return this; - }, - - slice: function () { - var arr = this.toArray(); - return arr.slice.apply(arr, arguments); - }, - - arrangedContentArrayWillChange: function (item, idx, removedCnt, addedCnt) { - this.arrayContentWillChange(idx, removedCnt, addedCnt); - }, - - arrangedContentArrayDidChange: function (item, idx, removedCnt, addedCnt) { - this.arrayContentDidChange(idx, removedCnt, addedCnt); - }, - - init: function () { - this._super.apply(this, arguments); - this._setupContent(); - this._setupArrangedContent(); - }, - - willDestroy: function () { - this._teardownArrangedContent(); - this._teardownContent(); - } - }); -}); -enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/inject'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeInject) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-runtime - */ - - // using ember-metal/lib/main here to ensure that ember-debug is setup - // if present - - var _Mixin$create, _ClassMixinProps; + // Implements a member that provides a lazily created map of maps, + // with inheritance at both levels. - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['.'], ['.']); + Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { + _emberMetalDebug.assert('Cannot call writeDeps after the object is destroyed.', !this.isMetaDestroyed()); - var schedule = _emberMetal.run.schedule; - var applyMixin = _emberMetal.Mixin._apply; - var finishPartial = _emberMetal.Mixin.finishPartial; - var reopen = _emberMetal.Mixin.prototype.reopen; - var hasCachedComputedProperties = false; + var outerMap = this._getOrCreateOwnMap('_deps'); + var innerMap = outerMap[subkey]; + if (!innerMap) { + innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); + } + innerMap[itemkey] = value; + }; - var POST_INIT = _emberUtils.symbol('POST_INIT'); + Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer._deps; + if (map) { + var value = map[subkey]; + if (value) { + if (value[itemkey] !== undefined) { + return value[itemkey]; + } + } + } + pointer = pointer.parent; + } + }; - exports.POST_INIT = POST_INIT; - function makeCtor() { - // Note: avoid accessing any properties on the object since it makes the - // method a lot faster. This is glue code so we want it to be as fast as - // possible. + Meta.prototype.hasDeps = function hasDeps(subkey) { + var pointer = this; + while (pointer !== undefined) { + if (pointer._deps && pointer._deps[subkey]) { + return true; + } + pointer = pointer.parent; + } + return false; + }; - var wasApplied = false; - var initProperties; + Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { + return this._forEachIn('_deps', subkey, fn); + }; - var Class = function () { - if (!wasApplied) { - Class.proto(); // prepare prototype... + Meta.prototype._forEachIn = function _forEachIn(key, subkey, fn) { + var pointer = this; + var seen = new _emberUtils.EmptyObject(); + var calls = []; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var innerMap = map[subkey]; + if (innerMap) { + for (var innerKey in innerMap) { + if (!seen[innerKey]) { + seen[innerKey] = true; + calls.push([innerKey, innerMap[innerKey]]); + } + } + } + } + pointer = pointer.parent; } + for (var i = 0; i < calls.length; i++) { + var _calls$i = calls[i]; + var innerKey = _calls$i[0]; + var value = _calls$i[1]; - if (arguments.length > 0) { - initProperties = [arguments[0]]; + fn(innerKey, value); } + }; - this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); - var m = _emberMetal.meta(this); - var proto = m.proto; - m.proto = this; - if (initProperties) { - // capture locally so we can clear the closed over variable - var props = initProperties; - initProperties = null; + Meta.prototype.readInheritedValue = function readInheritedValue(key, subkey) { + var internalKey = '_' + key; - var concatenatedProperties = this.concatenatedProperties; - var mergedProperties = this.mergedProperties; + var pointer = this; - for (var i = 0; i < props.length; i++) { - var properties = props[i]; + while (pointer !== undefined) { + var map = pointer[internalKey]; + if (map) { + var value = map[subkey]; + if (value !== undefined || subkey in map) { + return map[subkey]; + } + } + pointer = pointer.parent; + } - _emberMetal.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetal.Mixin)); + return UNDEFINED; + }; - if (typeof properties !== 'object' && properties !== undefined) { - throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); - } + Meta.prototype.writeValue = function writeValue(obj, key, value) { + var descriptor = _emberUtils.lookupDescriptor(obj, key); + var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - if (!properties) { - continue; - } + if (isMandatorySetter) { + this.writeValues(key, value); + } else { + obj[key] = value; + } + }; - var keyNames = Object.keys(properties); + return Meta; + })(); - for (var j = 0; j < keyNames.length; j++) { - var keyName = keyNames[j]; - var value = properties[keyName]; + exports.Meta = Meta; - if (_emberMetal.detectBinding(keyName)) { - m.writeBindings(keyName, value); - } + var NODE_STACK = []; - var possibleDesc = this[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + for (var _name in _emberMetalMeta_listeners.protoMethods) { + Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; + } + memberNames.forEach(function (name) { + return members[name](name, Meta); + }); - _emberMetal.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty)); - _emberMetal.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1)); - _emberMetal.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this))); + // Implements a member that is a lazily created, non-inheritable + // POJO. + function ownMap(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function () { + return this._getOrCreateOwnMap(key); + }; + Meta.prototype['readable' + capitalized] = function () { + return this[key]; + }; + } - if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { - var baseValue = this[keyName]; + // Implements a member that is a lazily created POJO with inheritable + // values. + function inheritedMap(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); - if (baseValue) { - if ('function' === typeof baseValue.concat) { - value = baseValue.concat(value); - } else { - value = _emberUtils.makeArray(baseValue).concat(value); - } - } else { - value = _emberUtils.makeArray(value); - } - } + Meta.prototype['write' + capitalized] = function (subkey, value) { + _emberMetalDebug.assert('Cannot call write' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { - var originalValue = this[keyName]; + var map = this._getOrCreateOwnMap(key); + map[subkey] = value; + }; - value = _emberUtils.assign({}, originalValue, value); - } + Meta.prototype['peek' + capitalized] = function (subkey) { + return this._findInherited(key, subkey); + }; - if (desc) { - desc.set(this, keyName, value); - } else { - if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { - this.setUnknownProperty(keyName, value); - } else { - if (true) { - _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter - } else { - this[keyName] = value; - } - } + Meta.prototype['forEach' + capitalized] = function (fn) { + var pointer = this; + var seen = new _emberUtils.EmptyObject(); + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + for (var _key in map) { + if (!seen[_key]) { + seen[_key] = true; + fn(_key, map[_key]); } } } + pointer = pointer.parent; } - - finishPartial(this, m); - - this.init.apply(this, arguments); - - this[POST_INIT](); - - m.proto = proto; - _emberMetal.finishChains(this); - _emberMetal.sendEvent(this, 'init'); }; - Class.toString = _emberMetal.Mixin.prototype.toString; - Class.willReopen = function () { - if (wasApplied) { - Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); - } + Meta.prototype['clear' + capitalized] = function () { + _emberMetalDebug.assert('Cannot call clear' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - wasApplied = false; + this[key] = undefined; }; - Class._initProperties = function (args) { - initProperties = args; + Meta.prototype['deleteFrom' + capitalized] = function (subkey) { + delete this._getOrCreateOwnMap(key)[subkey]; }; - Class.proto = function () { - var superclass = Class.superclass; - if (superclass) { - superclass.proto(); - } - - if (!wasApplied) { - wasApplied = true; - Class.PrototypeMixin.applyPartial(Class.prototype); - } - - return this.prototype; + Meta.prototype['hasIn' + capitalized] = function (subkey) { + return this._findInherited(key, subkey) !== undefined; }; - - return Class; } - /** - @class CoreObject - @namespace Ember - @public - */ - var CoreObject = makeCtor(); - CoreObject.toString = function () { - return 'Ember.CoreObject'; - }; - CoreObject.PrototypeMixin = _emberMetal.Mixin.create((_Mixin$create = { - reopen: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - applyMixin(this, args, true); - return this; - }, - - /** - An overridable method called when objects are instantiated. By default, - does nothing unless it is overridden during class definition. - Example: - ```javascript - const Person = Ember.Object.extend({ - init() { - alert(`Name is ${this.get('name')}`); - } - }); - let steve = Person.create({ - name: "Steve" - }); - // alerts 'Name is Steve'. - ``` - NOTE: If you do override `init` for a framework class like `Ember.View`, - be sure to call `this._super(...arguments)` in your - `init` declaration! If you don't, Ember may not have an opportunity to - do important setup work, and you'll see strange behavior in your - application. - @method init - @public - */ - init: function () {} - - }, _Mixin$create[POST_INIT] = function () {}, _Mixin$create.__defineNonEnumerable = function (property) { - Object.defineProperty(this, property.name, property.descriptor); - //this[property.name] = property.descriptor.value; - }, _Mixin$create.concatenatedProperties = null, _Mixin$create.mergedProperties = null, _Mixin$create.isDestroyed = _emberMetal.descriptor({ - get: function () { - return _emberMetal.meta(this).isSourceDestroyed(); - }, - - set: function (value) { - // prevent setting while applying mixins - if (typeof value === 'object' && value !== null && value.isDescriptor) { - return; - } + var UNDEFINED = _emberUtils.symbol('undefined'); - _emberMetal.assert(('You cannot set `' + this + '.isDestroyed` directly, please use ').destroy()(_templateObject), false); - } - }), _Mixin$create.isDestroying = _emberMetal.descriptor({ - get: function () { - return _emberMetal.meta(this).isSourceDestroying(); - }, + exports.UNDEFINED = UNDEFINED; + // Implements a member that provides a non-heritable, lazily-created + // object using the method you provide. + function ownCustomObject(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function (create) { + _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - set: function (value) { - // prevent setting while applying mixins - if (typeof value === 'object' && value !== null && value.isDescriptor) { - return; + var ret = this[key]; + if (!ret) { + ret = this[key] = create(this.source); } + return ret; + }; + Meta.prototype['readable' + capitalized] = function () { + return this[key]; + }; + } - _emberMetal.assert(('You cannot set `' + this + '.isDestroying` directly, please use ').destroy()(_templateObject), false); - } - }), _Mixin$create.destroy = function () { - var m = _emberMetal.meta(this); - if (m.isSourceDestroying()) { - return; - } + // Implements a member that provides an inheritable, lazily-created + // object using the method you provide. We will derived children from + // their parents by calling your object's `copy()` method. + function inheritedCustomObject(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function (create) { + _emberMetalDebug.assert('Cannot call writable' + capitalized + ' after the object is destroyed.', !this.isMetaDestroyed()); - m.setSourceDestroying(); + var ret = this[key]; + if (!ret) { + if (this.parent) { + ret = this[key] = this.parent['writable' + capitalized](create).copy(this.source); + } else { + ret = this[key] = create(this.source); + } + } + return ret; + }; + Meta.prototype['readable' + capitalized] = function () { + return this._getInherited(key); + }; + } - schedule('actions', this, this.willDestroy); - schedule('destroy', this, this._scheduledDestroy, m); + function memberProperty(name) { + return '_' + name; + } - return this; - }, _Mixin$create.willDestroy = function () {}, _Mixin$create._scheduledDestroy = function (m) { - if (m.isSourceDestroyed()) { - return; - } - _emberMetal.destroy(this); - m.setSourceDestroyed(); - }, _Mixin$create.bind = function (to, from) { - if (!(from instanceof _emberMetal.Binding)) { - from = _emberMetal.Binding.from(from); - } - from.to(to).connect(this); - return from; - }, _Mixin$create.toString = function () { - var hasToStringExtension = typeof this.toStringExtension === 'function'; - var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; - var ret = '<' + this.constructor.toString() + ':' + _emberUtils.guidFor(this) + extension + '>'; + // there's a more general-purpose capitalize in ember-runtime, but we + // don't want to make ember-metal depend on ember-runtime. + function capitalize(name) { + return name.replace(/^\w/, function (m) { + return m.toUpperCase(); + }); + } - return ret; - }, _Mixin$create)); + var META_DESC = { + writable: true, + configurable: true, + enumerable: false, + value: null + }; - CoreObject.PrototypeMixin.ownerConstructor = CoreObject; + exports.META_DESC = META_DESC; + var EMBER_META_PROPERTY = { + name: META_FIELD, + descriptor: META_DESC + }; - CoreObject.__super__ = null; + if (true) { + Meta.prototype.readInheritedValue = function (key, subkey) { + var internalKey = '_' + key; - var ClassMixinProps = (_ClassMixinProps = { + var pointer = this; - ClassMixin: _emberMetal.REQUIRED, + while (pointer !== undefined) { + var map = pointer[internalKey]; + if (map) { + var value = map[subkey]; + if (value !== undefined || subkey in map) { + return map[subkey]; + } + } + pointer = pointer.parent; + } - PrototypeMixin: _emberMetal.REQUIRED, + return UNDEFINED; + }; - isClass: true, + Meta.prototype.writeValue = function (obj, key, value) { + var descriptor = _emberUtils.lookupDescriptor(obj, key); + var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - isMethod: false - }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { - var Class = makeCtor(); - var proto; - Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); - Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); + if (isMandatorySetter) { + this.writeValues(key, value); + } else { + obj[key] = value; + } + }; + } - Class.ClassMixin.ownerConstructor = Class; - Class.PrototypeMixin.ownerConstructor = Class; + var setMeta = undefined, + peekMeta = undefined; - reopen.apply(Class.PrototypeMixin, arguments); + // choose the one appropriate for given platform + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + (function () { + var getPrototypeOf = Object.getPrototypeOf; + var metaStore = new WeakMap(); - Class.superclass = this; - Class.__super__ = this.prototype; + exports.setMeta = setMeta = function WeakMap_setMeta(obj, meta) { + _emberMetalDebug.runInDebug(function () { + return counters.setCalls++; + }); + metaStore.set(obj, meta); + }; - proto = Class.prototype = Object.create(this.prototype); - proto.constructor = Class; - _emberUtils.generateGuid(proto); - _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype + exports.peekMeta = peekMeta = function WeakMap_peekMeta(obj) { + _emberMetalDebug.runInDebug(function () { + return counters.peekCalls++; + }); - Class.ClassMixin.apply(Class); - return Class; - }, _ClassMixinProps.create = function () { - var C = this; + return metaStore.get(obj); + }; - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + exports.peekMeta = peekMeta = function WeakMap_peekParentMeta(obj) { + var pointer = obj; + var meta = undefined; + while (pointer) { + meta = metaStore.get(pointer); + // jshint loopfunc:true + _emberMetalDebug.runInDebug(function () { + return counters.peekCalls++; + }); + // stop if we find a `null` value, since + // that means the meta was deleted + // any other truthy value is a "real" meta + if (meta === null || meta) { + return meta; + } - if (args.length > 0) { - this._initProperties(args); - } - return new C(); - }, _ClassMixinProps.reopen = function () { - this.willReopen(); - reopen.apply(this.PrototypeMixin, arguments); - return this; - }, _ClassMixinProps.reopenClass = function () { - reopen.apply(this.ClassMixin, arguments); - applyMixin(this, arguments, false); - return this; - }, _ClassMixinProps.detect = function (obj) { - if ('function' !== typeof obj) { - return false; - } - while (obj) { - if (obj === this) { - return true; + pointer = getPrototypeOf(pointer); + _emberMetalDebug.runInDebug(function () { + return counters.peakPrototypeWalks++; + }); + } + }; + })(); + } else { + exports.setMeta = setMeta = function Fallback_setMeta(obj, meta) { + // if `null` already, just set it to the new value + // otherwise define property first + if (obj[META_FIELD] !== null) { + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(EMBER_META_PROPERTY); + } else { + Object.defineProperty(obj, META_FIELD, META_DESC); + } } - obj = obj.superclass; - } - return false; - }, _ClassMixinProps.detectInstance = function (obj) { - return obj instanceof this; - }, _ClassMixinProps.metaForProperty = function (key) { - var proto = this.proto(); - var possibleDesc = proto[key]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); - return desc._meta || {}; - }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; - var proto = this.proto(); - var property; - var properties = []; - for (var name in proto) { - property = proto[name]; + obj[META_FIELD] = meta; + }; - if (property && property.isDescriptor) { - properties.push({ - name: name, - meta: property._meta - }); - } - } - return properties; - }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; - var empty = {}; + exports.peekMeta = peekMeta = function Fallback_peekMeta(obj) { + return obj[META_FIELD]; + }; + } - var properties = _emberMetal.get(this, '_computedProperties'); + function deleteMeta(obj) { + _emberMetalDebug.runInDebug(function () { + return counters.deleteCalls++; + }); - for (var i = 0; i < properties.length; i++) { - property = properties[i]; - callback.call(binding || this, property.name, property.meta || empty); + var meta = peekMeta(obj); + if (meta) { + meta.destroy(); } - }, _ClassMixinProps); - - function injectedPropertyAssertion() { - _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this)); } - _emberMetal.runInDebug(function () { - /** - Provides lookup-time type validation for injected properties. - @private - @method _onLookup - */ - ClassMixinProps._onLookup = injectedPropertyAssertion; - }); - /** - Returns a hash of property names and container names that injected - properties will lookup on the container lazily. + Retrieves the meta hash for an object. If `writable` is true ensures the + hash is writable for this object as well. - @method _lazyInjections - @return {Object} Hash of all lazy injected property keys to container names + The meta object contains information about computed property descriptors as + well as any watched properties and other information. You generally will + not access this information directly but instead work with higher level + methods that manipulate this hash indirectly. + + @method meta + @for Ember @private + + @param {Object} obj The object to retrieve meta for + @param {Boolean} [writable=true] Pass `false` if you do not intend to modify + the meta hash, allowing the method to avoid making an unnecessary copy. + @return {Object} the meta hash for an object */ - ClassMixinProps._lazyInjections = function () { - var injections = {}; - var proto = this.proto(); - var key, desc; - for (key in proto) { - desc = proto[key]; - if (desc instanceof _emberMetal.InjectedProperty) { - injections[key] = desc.type + ':' + (desc.name || key); + function meta(obj) { + _emberMetalDebug.runInDebug(function () { + return counters.metaCalls++; + }); + + var maybeMeta = peekMeta(obj); + var parent = undefined; + + // remove this code, in-favor of explicit parent + if (maybeMeta) { + if (maybeMeta.source === obj) { + return maybeMeta; } + parent = maybeMeta; } - return injections; - }; + var newMeta = new Meta(obj, parent); + setMeta(obj, newMeta); + return newMeta; + } - var ClassMixin = _emberMetal.Mixin.create(ClassMixinProps); + exports.peekMeta = peekMeta; + exports.setMeta = setMeta; + exports.counters = counters; +}); +enifed('ember-metal/meta_listeners', ['exports'], function (exports) { + /* + When we render a rich template hierarchy, the set of events that + *might* happen tends to be much larger than the set of events that + actually happen. This implies that we should make listener creation & + destruction cheap, even at the cost of making event dispatch more + expensive. + + Thus we store a new listener with a single push and no new + allocations, without even bothering to do deduplication -- we can + save that for dispatch time, if an event actually happens. + */ - ClassMixin.ownerConstructor = CoreObject; + /* listener flags */ + 'use strict'; - CoreObject.ClassMixin = ClassMixin; + var ONCE = 1; + exports.ONCE = ONCE; + var SUSPENDED = 2; - ClassMixin.apply(CoreObject); + exports.SUSPENDED = SUSPENDED; + var protoMethods = { - CoreObject.reopen({ - didDefineProperty: function (proto, key, value) { - if (hasCachedComputedProperties === false) { - return; + addToListeners: function (eventName, target, method, flags) { + if (!this._listeners) { + this._listeners = []; } - if (value instanceof _emberMetal.ComputedProperty) { - var cache = _emberMetal.meta(this.constructor).readableCache(); + this._listeners.push(eventName, target, method, flags); + }, - if (cache && cache._computedProperties !== undefined) { - cache._computedProperties = undefined; + _finalizeListeners: function () { + if (this._listenersFinalized) { + return; + } + if (!this._listeners) { + this._listeners = []; + } + var pointer = this.parent; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + this._listeners = this._listeners.concat(listeners); + } + if (pointer._listenersFinalized) { + break; } + pointer = pointer.parent; } - } - }); + this._listenersFinalized = true; + }, - exports.default = CoreObject; -}); -// Private, and only for didInitAttrs willRecieveAttrs + removeFromListeners: function (eventName, target, method, didRemove) { + var pointer = this; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = listeners.length - 4; index >= 0; index -= 4) { + if (listeners[index] === eventName && (!method || listeners[index + 1] === target && listeners[index + 2] === method)) { + if (pointer === this) { + // we are modifying our own list, so we edit directly + if (typeof didRemove === 'function') { + didRemove(eventName, target, listeners[index + 2]); + } + listeners.splice(index, 4); + } else { + // we are trying to remove an inherited listener, so we do + // just-in-time copying to detach our own listeners from + // our inheritance chain. + this._finalizeListeners(); + return this.removeFromListeners(eventName, target, method); + } + } + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + }, -/** - Defines the properties that will be concatenated from the superclass - (instead of overridden). - By default, when you extend an Ember class a property defined in - the subclass overrides a property with the same name that is defined - in the superclass. However, there are some cases where it is preferable - to build up a property's value by combining the superclass' property - value with the subclass' value. An example of this in use within Ember - is the `classNames` property of `Ember.View`. - Here is some sample code showing the difference between a concatenated - property and a normal one: - ```javascript - const Bar = Ember.Object.extend({ - // Configure which properties to concatenate - concatenatedProperties: ['concatenatedProperty'], - someNonConcatenatedProperty: ['bar'], - concatenatedProperty: ['bar'] - }); - const FooBar = Bar.extend({ - someNonConcatenatedProperty: ['foo'], - concatenatedProperty: ['foo'] - }); - let fooBar = FooBar.create(); - fooBar.get('someNonConcatenatedProperty'); // ['foo'] - fooBar.get('concatenatedProperty'); // ['bar', 'foo'] - ``` - This behavior extends to object creation as well. Continuing the - above example: - ```javascript - let fooBar = FooBar.create({ - someNonConcatenatedProperty: ['baz'], - concatenatedProperty: ['baz'] - }) - fooBar.get('someNonConcatenatedProperty'); // ['baz'] - fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] - ``` - Adding a single property that is not an array will just add it in the array: - ```javascript - let fooBar = FooBar.create({ - concatenatedProperty: 'baz' - }) - view.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] - ``` - Using the `concatenatedProperties` property, we can tell Ember to mix the - content of the properties. - In `Ember.Component` the `classNames`, `classNameBindings` and - `attributeBindings` properties are concatenated. - This feature is available for you to use throughout the Ember object model, - although typical app developers are likely to use it infrequently. Since - it changes expectations about behavior of properties, you should properly - document its usage in each individual concatenated property (to not - mislead your users to think they can override the property in a subclass). - @property concatenatedProperties - @type Array - @default null - @public -*/ + matchingListeners: function (eventName) { + var pointer = this; + var result = []; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = 0; index < listeners.length - 3; index += 4) { + if (listeners[index] === eventName) { + pushUniqueListener(result, listeners, index); + } + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + var sus = this._suspendedListeners; + if (sus) { + for (var susIndex = 0; susIndex < sus.length - 2; susIndex += 3) { + if (eventName === sus[susIndex]) { + for (var resultIndex = 0; resultIndex < result.length - 2; resultIndex += 3) { + if (result[resultIndex] === sus[susIndex + 1] && result[resultIndex + 1] === sus[susIndex + 2]) { + result[resultIndex + 2] |= SUSPENDED; + } + } + } + } + } + return result; + }, -/** - Defines the properties that will be merged from the superclass - (instead of overridden). - By default, when you extend an Ember class a property defined in - the subclass overrides a property with the same name that is defined - in the superclass. However, there are some cases where it is preferable - to build up a property's value by merging the superclass property value - with the subclass property's value. An example of this in use within Ember - is the `queryParams` property of routes. - Here is some sample code showing the difference between a merged - property and a normal one: - ```javascript - const Bar = Ember.Object.extend({ - // Configure which properties are to be merged - mergedProperties: ['mergedProperty'], - someNonMergedProperty: { - nonMerged: 'superclass value of nonMerged' + suspendListeners: function (eventNames, target, method, callback) { + var sus = this._suspendedListeners; + if (!sus) { + sus = this._suspendedListeners = []; + } + for (var i = 0; i < eventNames.length; i++) { + sus.push(eventNames[i], target, method); + } + try { + return callback.call(target); + } finally { + if (sus.length === eventNames.length) { + this._suspendedListeners = undefined; + } else { + for (var i = sus.length - 3; i >= 0; i -= 3) { + if (sus[i + 1] === target && sus[i + 2] === method && eventNames.indexOf(sus[i]) !== -1) { + sus.splice(i, 3); + } + } + } + } }, - mergedProperty: { - page: {replace: false}, - limit: {replace: true} - } - }); - const FooBar = Bar.extend({ - someNonMergedProperty: { - completelyNonMerged: 'subclass value of nonMerged' + + watchedEvents: function () { + var pointer = this; + var names = {}; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = 0; index < listeners.length - 3; index += 4) { + names[listeners[index]] = true; + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + return Object.keys(names); }, - mergedProperty: { - limit: {replace: false} + + _initializeListeners: function () { + this._listeners = undefined; + this._listenersFinalized = undefined; + this._suspendedListeners = undefined; } - }); - let fooBar = FooBar.create(); - fooBar.get('someNonMergedProperty'); - // => { completelyNonMerged: 'subclass value of nonMerged' } - // - // Note the entire object, including the nonMerged property of - // the superclass object, has been replaced - fooBar.get('mergedProperty'); - // => { - // page: {replace: false}, - // limit: {replace: false} - // } - // - // Note the page remains from the superclass, and the - // `limit` property's value of `false` has been merged from - // the subclass. - ``` - This behavior is not available during object `create` calls. It is only - available at `extend` time. - In `Ember.Route` the `queryParams` property is merged. - This feature is available for you to use throughout the Ember object model, - although typical app developers are likely to use it infrequently. Since - it changes expectations about behavior of properties, you should properly - document its usage in each individual merged property (to not - mislead your users to think they can override the property in a subclass). - @property mergedProperties - @type Array - @default null - @public -*/ + }; -/** - Destroyed object property flag. - if this property is `true` the observers and bindings were already - removed by the effect of calling the `destroy()` method. - @property isDestroyed - @default false - @public -*/ + exports.protoMethods = protoMethods; + function pushUniqueListener(destination, source, index) { + var target = source[index + 1]; + var method = source[index + 2]; + for (var destinationIndex = 0; destinationIndex < destination.length - 2; destinationIndex += 3) { + if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { + return; + } + } + destination.push(target, method, source[index + 3]); + } +}); +enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -/** - Destruction scheduled flag. The `destroy()` method has been called. - The object stays intact until the end of the run loop at which point - the `isDestroyed` flag is set. - @property isDestroying - @default false - @public -*/ + /** + @module ember + @submodule ember-metal + */ + exports.detectBinding = detectBinding; + exports.mixin = mixin; + exports.hasUnprocessedMixins = hasUnprocessedMixins; + exports.clearUnprocessedMixins = clearUnprocessedMixins; + exports.required = required; + exports.aliasMethod = aliasMethod; + exports.observer = observer; + exports._immediateObserver = _immediateObserver; + exports._beforeObserver = _beforeObserver; -/** - Destroys an object by setting the `isDestroyed` flag and removing its - metadata, which effectively destroys observers and bindings. - If you try to set a property on a destroyed object, an exception will be - raised. - Note that destruction is scheduled for the end of the run loop and does not - happen immediately. It will set an isDestroying flag immediately. - @method destroy - @return {Ember.Object} receiver - @public -*/ + function ROOT() {} + ROOT.__hasSuper = false; -/** - Override to implement teardown. - @method willDestroy - @public -*/ + var a_slice = Array.prototype.slice; + var a_concat = Array.prototype.concat; + var isArray = Array.isArray; -/** - Invoked by the run loop to actually destroy the object. This is - scheduled for execution by the `destroy` method. - @private - @method _scheduledDestroy -*/ + function isMethod(obj) { + return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; + } -/** - Returns a string representation which attempts to provide more information - than Javascript's `toString` typically does, in a generic way for all Ember - objects. - ```javascript - const Person = Ember.Object.extend() - person = Person.create() - person.toString() //=> "" - ``` - If the object's class is not defined on an Ember namespace, it will - indicate it is a subclass of the registered superclass: - ```javascript - const Student = Person.extend() - let student = Student.create() - student.toString() //=> "<(subclass of Person):ember1025>" - ``` - If the method `toStringExtension` is defined, its return value will be - included in the output. - ```javascript - const Teacher = Person.extend({ - toStringExtension() { - return this.get('fullName'); - } - }); - teacher = Teacher.create() - teacher.toString(); //=> "" - ``` - @method toString - @return {String} string representation - @public -*/ + var CONTINUE = {}; -/** - Creates a new subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(thing); - } - }); - ``` - This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. - You can also create a subclass from any existing class by calling its `extend()` method. - For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: - ```javascript - const PersonComponent = Ember.Component.extend({ - tagName: 'li', - classNameBindings: ['isAdministrator'] - }); - ``` - When defining a subclass, you can override methods but still access the - implementation of your parent class by calling the special `_super()` method: - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - var name = this.get('name'); - alert(`${name} says: ${thing}`); - } - }); - const Soldier = Person.extend({ - say(thing) { - this._super(`${thing}, sir!`); - }, - march(numberOfHours) { - alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + function mixinProperties(mixinsMeta, mixin) { + var guid = undefined; + + if (mixin instanceof Mixin) { + guid = _emberUtils.guidFor(mixin); + if (mixinsMeta.peekMixins(guid)) { + return CONTINUE; + } + mixinsMeta.writeMixins(guid, mixin); + return mixin.properties; + } else { + return mixin; // apply anonymous mixin properties } - }); - let yehuda = Soldier.create({ - name: "Yehuda Katz" - }); - yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" - ``` - The `create()` on line #17 creates an *instance* of the `Soldier` class. - The `extend()` on line #8 creates a *subclass* of `Person`. Any instance - of the `Person` class will *not* have the `march()` method. - You can also pass `Mixin` classes to add additional properties to the subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(`${this.get('name')} says: ${thing}`); + } + + function concatenatedMixinProperties(concatProp, props, values, base) { + // reset before adding each new mixin to pickup concats from previous + var concats = values[concatProp] || base[concatProp]; + if (props[concatProp]) { + concats = concats ? a_concat.call(concats, props[concatProp]) : props[concatProp]; } - }); - const SingingMixin = Mixin.create({ - sing(thing){ - alert(`${this.get('name')} sings: la la la ${thing}`); + return concats; + } + + function giveDescriptorSuper(meta, key, property, values, descs, base) { + var superProperty = undefined; + + // Computed properties override methods, and do not call super to them + if (values[key] === undefined) { + // Find the original descriptor in a parent mixin + superProperty = descs[key]; } - }); - const BroadwayStar = Person.extend(SingingMixin, { - dance() { - alert(`${this.get('name')} dances: tap tap tap tap `); + + // If we didn't find the original descriptor in a parent mixin, find + // it on the original object. + if (!superProperty) { + var possibleDesc = base[key]; + var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + superProperty = superDesc; } - }); - ``` - The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. - @method extend - @static - @param {Mixin} [mixins]* One or more Mixin classes - @param {Object} [arguments]* Object containing values to use within the new class - @public -*/ -/** - Creates an instance of a class. Accepts either no arguments, or an object - containing values to initialize the newly instantiated object with. - ```javascript - const Person = Ember.Object.extend({ - helloWorld() { - alert(`Hi, my name is ${this.get('name')}`); + if (superProperty === undefined || !(superProperty instanceof _emberMetalComputed.ComputedProperty)) { + return property; } - }); - let tom = Person.create({ - name: 'Tom Dale' - }); - tom.helloWorld(); // alerts "Hi, my name is Tom Dale". - ``` - `create` will call the `init` function if defined during - `Ember.AnyObject.extend` - If no arguments are passed to `create`, it will not set values to the new - instance during initialization: - ```javascript - let noName = Person.create(); - noName.helloWorld(); // alerts undefined - ``` - NOTE: For performance reasons, you cannot declare methods or computed - properties during `create`. You should instead declare methods and computed - properties when using `extend`. - @method create - @static - @param [arguments]* - @public -*/ -/** - Augments a constructor's prototype with additional - properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - o = MyObject.create(); - o.get('name'); // 'an object' - MyObject.reopen({ - say(msg){ - console.log(msg); + // Since multiple mixins may inherit from the same parent, we need + // to clone the computed property so that other mixins do not receive + // the wrapped version. + property = Object.create(property); + property._getter = _emberUtils.wrap(property._getter, superProperty._getter); + if (superProperty._setter) { + if (property._setter) { + property._setter = _emberUtils.wrap(property._setter, superProperty._setter); + } else { + property._setter = superProperty._setter; + } } - }) - o2 = MyObject.create(); - o2.say("hello"); // logs "hello" - o.say("goodbye"); // logs "goodbye" - ``` - To add functions and properties to the constructor itself, - see `reopenClass` - @method reopen - @public -*/ -/** - Augments a constructor's own properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - MyObject.reopenClass({ - canBuild: false - }); - MyObject.canBuild; // false - o = MyObject.create(); - ``` - In other words, this creates static properties and functions for the class. - These are only available on the class and not on any instance of that class. - ```javascript - const Person = Ember.Object.extend({ - name: "", - sayHello() { - alert("Hello. My name is " + this.get('name')); + return property; + } + + function giveMethodSuper(obj, key, method, values, descs) { + var superMethod = undefined; + + // Methods overwrite computed properties, and do not call super to them. + if (descs[key] === undefined) { + // Find the original method in a parent mixin + superMethod = values[key]; } - }); - Person.reopenClass({ - species: "Homo sapiens", - createPerson(newPersonsName){ - return Person.create({ - name:newPersonsName - }); + + // If we didn't find the original value in a parent mixin, find it in + // the original object + superMethod = superMethod || obj[key]; + + // Only wrap the new method if the original method was a function + if (superMethod === undefined || 'function' !== typeof superMethod) { + return method; } - }); - let tom = Person.create({ - name: "Tom Dale" - }); - let yehuda = Person.createPerson("Yehuda Katz"); - tom.sayHello(); // "Hello. My name is Tom Dale" - yehuda.sayHello(); // "Hello. My name is Yehuda Katz" - alert(Person.species); // "Homo sapiens" - ``` - Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` - variables. They are only valid on `Person`. - To add functions and properties to instances of - a constructor by extending the constructor's prototype - see `reopen` - @method reopenClass - @public -*/ -/** - 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: - ```javascript - person: Ember.computed(function() { - var personId = this.get('personId'); - return Person.create({ id: personId }); - }).meta({ type: Person }) - ``` - Once you've done this, you can retrieve the values saved to the computed - property from your class like this: - ```javascript - MyClass.metaForProperty('person'); - ``` - This will return the original hash that was passed to `meta()`. - @static - @method metaForProperty - @param key {String} property name - @private -*/ + return _emberUtils.wrap(method, superMethod); + } -/** - Iterate over each computed property for the class, passing its name - and any associated metadata (see `metaForProperty`) to the callback. - @static - @method eachComputedProperty - @param {Function} callback - @param {Object} binding - @private -*/ -enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { - 'use strict'; + function applyConcatenatedProperties(obj, key, value, values) { + var baseValue = values[key] || obj[key]; + var ret = undefined; - exports.default = EachProxy; + if (baseValue === null || baseValue === undefined) { + ret = _emberUtils.makeArray(value); + } else { + if (isArray(baseValue)) { + if (value === null || value === undefined) { + ret = baseValue; + } else { + ret = a_concat.call(baseValue, value); + } + } else { + ret = a_concat.call(_emberUtils.makeArray(baseValue), value); + } + } - /** - This is the object instance returned when you get the `@each` property on an - array. It uses the unknownProperty handler to automatically create - EachArray instances for property names. - @class EachProxy - @private - */ + _emberMetalDebug.runInDebug(function () { + // it is possible to use concatenatedProperties with strings (which cannot be frozen) + // only freeze objects... + if (typeof ret === 'object' && ret !== null) { + // prevent mutating `concatenatedProperties` array after it is applied + Object.freeze(ret); + } + }); - function EachProxy(content) { - this._content = content; - this._keys = undefined; - this.__ember_meta__ = null; + return ret; } - EachProxy.prototype = { - __defineNonEnumerable: function (property) { - this[property.name] = property.descriptor.value; - }, + function applyMergedProperties(obj, key, value, values) { + var baseValue = values[key] || obj[key]; + + _emberMetalDebug.runInDebug(function () { + if (isArray(value)) { + // use conditional to avoid stringifying every time + _emberMetalDebug.assert('You passed in `' + JSON.stringify(value) + '` as the value for `' + key + '` but `' + key + '` cannot be an Array', false); + } + }); + + if (!baseValue) { + return value; + } + + var newBase = _emberUtils.assign({}, baseValue); + var hasFunction = false; + + for (var prop in value) { + if (!value.hasOwnProperty(prop)) { + continue; + } + + var propValue = value[prop]; + if (isMethod(propValue)) { + // TODO: support for Computed Properties, etc? + hasFunction = true; + newBase[prop] = giveMethodSuper(obj, prop, propValue, baseValue, {}); + } else { + newBase[prop] = propValue; + } + } + + if (hasFunction) { + newBase._super = ROOT; + } + + return newBase; + } - // .......................................................... - // ARRAY CHANGES - // Invokes whenever the content array itself changes. + function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { + if (value instanceof _emberMetalProperties.Descriptor) { + if (value === REQUIRED && descs[key]) { + return CONTINUE; + } - arrayWillChange: function (content, idx, removedCnt, addedCnt) { - var keys = this._keys; - var lim = removedCnt > 0 ? idx + removedCnt : -1; - for (var key in keys) { - if (lim > 0) { - removeObserverForContentKey(content, key, this, idx, lim); - } - _emberMetal.propertyWillChange(this, key); + // Wrap descriptor function to implement + // _super() if needed + if (value._getter) { + value = giveDescriptorSuper(meta, key, value, values, descs, base); } - }, - arrayDidChange: function (content, idx, removedCnt, addedCnt) { - var keys = this._keys; - var lim = addedCnt > 0 ? idx + addedCnt : -1; - for (var key in keys) { - if (lim > 0) { - addObserverForContentKey(content, key, this, idx, lim); - } - _emberMetal.propertyDidChange(this, key); + descs[key] = value; + values[key] = undefined; + } else { + if (concats && concats.indexOf(key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') { + value = applyConcatenatedProperties(base, key, value, values); + } else if (mergings && mergings.indexOf(key) >= 0) { + value = applyMergedProperties(base, key, value, values); + } else if (isMethod(value)) { + value = giveMethodSuper(base, key, value, values, descs); } - }, - // .......................................................... - // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS - // Start monitoring keys based on who is listening... + descs[key] = undefined; + values[key] = value; + } + } - willWatchProperty: function (property) { - this.beginObservingContentKey(property); - }, + function mergeMixins(mixins, m, descs, values, base, keys) { + var currentMixin = undefined, + props = undefined, + key = undefined, + concats = undefined, + mergings = undefined; - didUnwatchProperty: function (property) { - this.stopObservingContentKey(property); - }, + function removeKeys(keyName) { + delete descs[keyName]; + delete values[keyName]; + } - // .......................................................... - // CONTENT KEY OBSERVING - // Actual watch keys on the source content. + for (var i = 0; i < mixins.length; i++) { + currentMixin = mixins[i]; + _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); - beginObservingContentKey: function (keyName) { - var keys = this._keys; - if (!keys) { - keys = this._keys = new _emberUtils.EmptyObject(); + props = mixinProperties(m, currentMixin); + if (props === CONTINUE) { + continue; } - if (!keys[keyName]) { - keys[keyName] = 1; - var content = this._content; - var len = _emberMetal.get(content, 'length'); + if (props) { + if (base.willMergeMixin) { + base.willMergeMixin(props); + } + concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); + mergings = concatenatedMixinProperties('mergedProperties', props, values, base); - addObserverForContentKey(content, keyName, this, 0, len); - } else { - keys[keyName]++; + for (key in props) { + if (!props.hasOwnProperty(key)) { + continue; + } + keys.push(key); + addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings); + } + + // manually copy toString() because some JS engines do not enumerate it + if (props.hasOwnProperty('toString')) { + base.toString = props.toString; + } + } else if (currentMixin.mixins) { + mergeMixins(currentMixin.mixins, m, descs, values, base, keys); + if (currentMixin._without) { + currentMixin._without.forEach(removeKeys); + } } - }, + } + } - stopObservingContentKey: function (keyName) { - var keys = this._keys; - if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) { - var content = this._content; - var len = _emberMetal.get(content, 'length'); + function detectBinding(key) { + var length = key.length; - removeObserverForContentKey(content, keyName, this, 0, len); + return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; + } + + // warm both paths of above function + detectBinding('notbound'); + detectBinding('fooBinding'); + + function connectBindings(obj, m) { + // TODO Mixin.apply(instance) should disconnect binding if exists + m.forEachBindings(function (key, binding) { + if (binding) { + var to = key.slice(0, -7); // strip Binding off end + if (binding instanceof _emberMetalBinding.Binding) { + binding = binding.copy(); // copy prototypes' instance + binding.to(to); + } else { + // binding is string path + binding = new _emberMetalBinding.Binding(to, binding); + } + binding.connect(obj); + obj[key] = binding; } - }, + }); + // mark as applied + m.clearBindings(); + } - contentKeyWillChange: function (obj, keyName) { - _emberMetal.propertyWillChange(this, keyName); - }, + function finishPartial(obj, m) { + connectBindings(obj, m || _emberMetalMeta.meta(obj)); + return obj; + } - contentKeyDidChange: function (obj, keyName) { - _emberMetal.propertyDidChange(this, keyName); + function followAlias(obj, desc, m, descs, values) { + var altKey = desc.methodName; + var value = undefined; + var possibleDesc = undefined; + if (descs[altKey] || values[altKey]) { + value = values[altKey]; + desc = descs[altKey]; + } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { + desc = possibleDesc; + value = undefined; + } else { + desc = undefined; + value = obj[altKey]; } - }; - function addObserverForContentKey(content, keyName, proxy, idx, loc) { - while (--loc >= idx) { - var item = _emberRuntimeMixinsArray.objectAt(content, loc); - if (item) { - _emberMetal.assert('When using @each to observe the array ' + content + ', the array must return an object', typeof item === 'object'); - _emberMetal._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); - _emberMetal.addObserver(item, keyName, proxy, 'contentKeyDidChange'); + return { desc: desc, value: value }; + } + + function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { + var paths = observerOrListener[pathsKey]; + + if (paths) { + for (var i = 0; i < paths.length; i++) { + updateMethod(obj, paths[i], null, key); } } } - function removeObserverForContentKey(content, keyName, proxy, idx, loc) { - while (--loc >= idx) { - var item = _emberRuntimeMixinsArray.objectAt(content, loc); - if (item) { - _emberMetal._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); - _emberMetal.removeObserver(item, keyName, proxy, 'contentKeyDidChange'); - } + function replaceObserversAndListeners(obj, key, observerOrListener) { + var prev = obj[key]; + + if ('function' === typeof prev) { + updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _emberMetalObserver._removeBeforeObserver); + updateObserversAndListeners(obj, key, prev, '__ember_observes__', _emberMetalObserver.removeObserver); + updateObserversAndListeners(obj, key, prev, '__ember_listens__', _emberMetalEvents.removeListener); + } + + if ('function' === typeof observerOrListener) { + updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', _emberMetalObserver._addBeforeObserver); + updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', _emberMetalObserver.addObserver); + updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', _emberMetalEvents.addListener); } } -}); -enifed('ember-runtime/system/lazy_load', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - /*globals CustomEvent */ - 'use strict'; + function applyMixin(obj, mixins, partial) { + var descs = {}; + var values = {}; + var m = _emberMetalMeta.meta(obj); + var keys = []; + var key = undefined, + value = undefined, + desc = undefined; - exports.onLoad = onLoad; - exports.runLoadHooks = runLoadHooks; + obj._super = ROOT; - /** - @module ember - @submodule ember-runtime - */ + // Go through all mixins and hashes passed in, and: + // + // * Handle concatenated properties + // * Handle merged properties + // * Set up _super wrapping if necessary + // * Set up computed property descriptors + // * Copying `toString` in broken browsers + mergeMixins(mixins, m, descs, values, obj, keys); - var loadHooks = _emberEnvironment.ENV.EMBER_LOAD_HOOKS || {}; - var loaded = {}; - var _loaded = loaded; + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + if (key === 'constructor' || !values.hasOwnProperty(key)) { + continue; + } - exports._loaded = _loaded; - /** - Detects when a specific package of Ember (e.g. 'Ember.Application') - has fully loaded and is available for extension. - - The provided `callback` will be called with the `name` passed - resolved from a string into the object: - - ``` javascript - Ember.onLoad('Ember.Application' function(hbars) { - hbars.registerHelper(...); - }); - ``` - - @method onLoad - @for Ember - @param name {String} name of hook - @param callback {Function} callback to be called - @private - */ + desc = descs[key]; + value = values[key]; - function onLoad(name, callback) { - var object = loaded[name]; + if (desc === REQUIRED) { + continue; + } - loadHooks[name] = loadHooks[name] || []; - loadHooks[name].push(callback); + while (desc && desc instanceof Alias) { + var followed = followAlias(obj, desc, m, descs, values); + desc = followed.desc; + value = followed.value; + } - if (object) { - callback(object); - } - } + if (desc === undefined && value === undefined) { + continue; + } - /** - Called when an Ember.js package (e.g Ember.Application) has finished - loading. Triggers any callbacks registered for this event. - - @method runLoadHooks - @for Ember - @param name {String} name of hook - @param object {Object} object to pass to callbacks - @private - */ + replaceObserversAndListeners(obj, key, value); - function runLoadHooks(name, object) { - loaded[name] = object; - var window = _emberEnvironment.environment.window; + if (detectBinding(key)) { + m.writeBindings(key, value); + } - if (window && typeof CustomEvent === 'function') { - var _event = new CustomEvent(name, { detail: object, name: name }); - window.dispatchEvent(_event); + _emberMetalProperties.defineProperty(obj, key, desc, value, m); } - if (loadHooks[name]) { - loadHooks[name].forEach(function (callback) { - return callback(object); - }); + if (!partial) { + // don't apply to prototype + finishPartial(obj, m); } + + return obj; } -}); -enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-runtime/system/object'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberRuntimeSystemObject) { + /** - @module ember - @submodule ember-runtime + @method mixin + @for Ember + @param obj + @param mixins* + @return obj + @private */ - 'use strict'; - - exports.isSearchDisabled = isSearchDisabled; - exports.setSearchDisabled = setSearchDisabled; - var searchDisabled = false; - - function isSearchDisabled() { - return searchDisabled; - } + function mixin(obj) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - function setSearchDisabled(flag) { - searchDisabled = !!flag; + applyMixin(obj, args, false); + return obj; } /** - A Namespace is an object usually used to contain other objects or methods - such as an application or framework. Create a namespace anytime you want - to define one of these new containers. + The `Ember.Mixin` class allows you to create mixins, whose properties can be + added to other classes. For instance, - # Example Usage + ```javascript + const EditableMixin = Ember.Mixin.create({ + edit() { + console.log('starting to edit'); + this.set('isEditing', true); + }, + isEditing: false + }); + + // Mix mixins into classes by passing them as the first arguments to + // `.extend.` + const Comment = Ember.Object.extend(EditableMixin, { + post: null + }); + + let comment = Comment.create(post: somePost); + comment.edit(); // outputs 'starting to edit' + ``` + + Note that Mixins are created with `Ember.Mixin.create`, not + `Ember.Mixin.extend`. + + Note that mixins extend a constructor's prototype so arrays and object literals + defined as properties will be shared amongst objects that implement the mixin. + If you want to define a property in a mixin that is not shared, you can define + it either as a computed property or have it be created on initialization of the object. ```javascript - MyFramework = Ember.Namespace.create({ - VERSION: '1.0.0' + // filters array will be shared amongst any object implementing mixin + const FilterableMixin = Ember.Mixin.create({ + filters: Ember.A() + }); + + // filters will be a separate array for every object implementing the mixin + const FilterableMixin = Ember.Mixin.create({ + filters: Ember.computed(function() { + return Ember.A(); + }) + }); + + // filters will be created as a separate array during the object's initialization + const Filterable = Ember.Mixin.create({ + init() { + this._super(...arguments); + this.set("filters", Ember.A()); + } }); ``` - @class Namespace + @class Mixin @namespace Ember - @extends Ember.Object @public */ - var Namespace = _emberRuntimeSystemObject.default.extend({ - isNamespace: true, - - init: function () { - Namespace.NAMESPACES.push(this); - Namespace.PROCESSED = false; - }, - - toString: function () { - var name = _emberMetal.get(this, 'name') || _emberMetal.get(this, 'modulePrefix'); - if (name) { - return name; - } - - findNamespaces(); - return this[_emberUtils.NAME_KEY]; - }, - - nameClasses: function () { - processNamespace([this.toString()], this, {}); - }, - - destroy: function () { - var namespaces = Namespace.NAMESPACES; - var toString = this.toString(); - - if (toString) { - _emberEnvironment.context.lookup[toString] = undefined; - delete Namespace.NAMESPACES_BY_ID[toString]; - } - namespaces.splice(namespaces.indexOf(this), 1); - this._super.apply(this, arguments); - } - }); - - Namespace.reopenClass({ - NAMESPACES: [_emberMetal.default], - NAMESPACES_BY_ID: { - Ember: _emberMetal.default - }, - PROCESSED: false, - processAll: processAllNamespaces, - byName: function (name) { - if (!searchDisabled) { - processAllNamespaces(); - } - - return NAMESPACES_BY_ID[name]; - } - }); - - var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; - - var hasOwnProp = ({}).hasOwnProperty; - - function processNamespace(paths, root, seen) { - var idx = paths.length; - NAMESPACES_BY_ID[paths.join('.')] = root; + var Mixin = (function () { + function Mixin(args, properties) { + babelHelpers.classCallCheck(this, Mixin); - // Loop over all of the keys in the namespace, looking for classes - for (var key in root) { - if (!hasOwnProp.call(root, key)) { - continue; - } - var obj = root[key]; + this.properties = properties; - // If we are processing the `Ember` namespace, for example, the - // `paths` will start with `["Ember"]`. Every iteration through - // the loop will update the **second** element of this list with - // the key, so processing `Ember.View` will make the Array - // `['Ember', 'View']`. - paths[idx] = key; + var length = args && args.length; - // If we have found an unprocessed class - if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { - // Replace the class' `toString` with the dot-separated path - // and set its `NAME_KEY` - obj[_emberUtils.NAME_KEY] = paths.join('.'); + if (length > 0) { + var m = new Array(length); - // Support nested namespaces - } else if (obj && obj.isNamespace) { - // Skip aliased namespaces - if (seen[_emberUtils.guidFor(obj)]) { - continue; + for (var i = 0; i < length; i++) { + var x = args[i]; + if (x instanceof Mixin) { + m[i] = x; + } else { + m[i] = new Mixin(undefined, x); } - seen[_emberUtils.guidFor(obj)] = true; - - // Process the child namespace - processNamespace(paths, obj, seen); } - } - - paths.length = idx; // cut out last item - } - - function isUppercase(code) { - return code >= 65 && // A - code <= 90; // Z - } - - function tryIsNamespace(lookup, prop) { - try { - var obj = lookup[prop]; - return obj && obj.isNamespace && obj; - } catch (e) { - // continue - } - } - function findNamespaces() { - if (Namespace.PROCESSED) { - return; - } - var lookup = _emberEnvironment.context.lookup; - var keys = Object.keys(lookup); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - // Only process entities that start with uppercase A-Z - if (!isUppercase(key.charCodeAt(0))) { - continue; - } - var obj = tryIsNamespace(lookup, key); - if (obj) { - obj[_emberUtils.NAME_KEY] = key; + this.mixins = m; + } else { + this.mixins = undefined; } + this.ownerConstructor = undefined; + this._without = undefined; + this[_emberUtils.GUID_KEY] = null; + this[_emberUtils.NAME_KEY] = null; + _emberMetalDebug.debugSeal(this); } - } - function superClassString(mixin) { - var superclass = mixin.superclass; - if (superclass) { - if (superclass[_emberUtils.NAME_KEY]) { - return superclass[_emberUtils.NAME_KEY]; + Mixin.applyPartial = function applyPartial(obj) { + var args = a_slice.call(arguments, 1); + return applyMixin(obj, args, true); + }; + + /** + @method create + @static + @param arguments* + @public + */ + + Mixin.create = function create() { + // ES6TODO: this relies on a global state? + unprocessedFlag = true; + var M = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - return superClassString(superclass); - } - } - function calculateToString(target) { - var str = undefined; + return new M(args, undefined); + }; - if (!searchDisabled) { - processAllNamespaces(); - // can also be set by processAllNamespaces - str = target[_emberUtils.NAME_KEY]; - if (str) { - return str; - } else { - str = superClassString(target); - str = str ? '(subclass of ' + str + ')' : str; + // returns the mixins currently applied to the specified object + // TODO: Make Ember.mixin + + Mixin.mixins = function mixins(obj) { + var m = _emberMetalMeta.peekMeta(obj); + var ret = []; + if (!m) { + return ret; } - } - if (str) { - return str; - } else { - return '(unknown mixin)'; - } - } - function classToString() { - var name = this[_emberUtils.NAME_KEY]; - if (name) { - return name; - } + m.forEachMixins(function (key, currentMixin) { + // skip primitive mixins since these are always anonymous + if (!currentMixin.properties) { + ret.push(currentMixin); + } + }); - return this[_emberUtils.NAME_KEY] = calculateToString(this); - } + return ret; + }; - function processAllNamespaces() { - var unprocessedNamespaces = !Namespace.PROCESSED; - var unprocessedMixins = _emberMetal.hasUnprocessedMixins(); + return Mixin; + })(); - if (unprocessedNamespaces) { - findNamespaces(); - Namespace.PROCESSED = true; - } + exports.default = Mixin; - if (unprocessedNamespaces || unprocessedMixins) { - var namespaces = Namespace.NAMESPACES; - var namespace = undefined; + Mixin._apply = applyMixin; - for (var i = 0; i < namespaces.length; i++) { - namespace = namespaces[i]; - processNamespace([namespace.toString()], namespace, {}); - } + Mixin.finishPartial = finishPartial; - _emberMetal.clearUnprocessedMixins(); - } + var unprocessedFlag = false; + + function hasUnprocessedMixins() { + return unprocessedFlag; } - _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. + function clearUnprocessedMixins() { + unprocessedFlag = false; + } + + var MixinPrototype = Mixin.prototype; - exports.default = Namespace; -}); -// Preloaded into namespaces -enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) { /** - @module ember - @submodule ember-runtime + @method reopen + @param arguments* + @private */ - 'use strict'; + MixinPrototype.reopen = function () { + var currentMixin = undefined; - // Add Ember.Array to Array.prototype. Remove methods with native - // implementations and supply some more optimized versions of generic methods - // because they are so common. + if (this.properties) { + currentMixin = new Mixin(undefined, this.properties); + this.properties = undefined; + this.mixins = [currentMixin]; + } else if (!this.mixins) { + this.mixins = []; + } - /** - The NativeArray mixin contains the properties needed to make the native - Array support Ember.MutableArray and all of its dependent APIs. Unless you - have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to - false, this will be applied automatically. Otherwise you can apply the mixin - at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. - - @class NativeArray - @namespace Ember - @uses Ember.MutableArray - @uses Ember.Observable - @uses Ember.Copyable - @public - */ - var NativeArray = _emberMetal.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, { + var mixins = this.mixins; + var idx = undefined; - // because length is a built-in property we need to know to just get the - // original property. - get: function (key) { - if ('number' === typeof key) { - return this[key]; + for (idx = 0; idx < arguments.length; idx++) { + currentMixin = arguments[idx]; + _emberMetalDebug.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); + + if (currentMixin instanceof Mixin) { + mixins.push(currentMixin); } else { - return this._super(key); + mixins.push(new Mixin(undefined, currentMixin)); } - }, - - objectAt: function (idx) { - return this[idx]; - }, + } - // primitive for array support. - replace: function (idx, amt, objects) { - if (this.isFrozen) { - throw _emberRuntimeMixinsFreezable.FROZEN_ERROR; - } + return this; + }; - // if we replaced exactly the same number of items, then pass only the - // replaced range. Otherwise, pass the full remaining array length - // since everything has shifted - var len = objects ? _emberMetal.get(objects, 'length') : 0; - _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, amt, len); + /** + @method apply + @param obj + @return applied object + @private + */ + MixinPrototype.apply = function (obj) { + return applyMixin(obj, [this], false); + }; - if (len === 0) { - this.splice(idx, amt); - } else { - _emberMetal.replace(this, idx, amt, objects); - } + MixinPrototype.applyPartial = function (obj) { + return applyMixin(obj, [this], true); + }; - _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, amt, len); - return this; - }, + MixinPrototype.toString = Object.toString; - // If you ask for an unknown property, then try to collect the value - // from member items. - unknownProperty: function (key, value) { - var ret = undefined; // = this.reducedProperty(key, value); - if (value !== undefined && ret === undefined) { - ret = this[key] = value; - } - return ret; - }, + function _detect(curMixin, targetMixin, seen) { + var guid = _emberUtils.guidFor(curMixin); - indexOf: Array.prototype.indexOf, - lastIndexOf: Array.prototype.lastIndexOf, + if (seen[guid]) { + return false; + } + seen[guid] = true; - copy: function (deep) { - if (deep) { - return this.map(function (item) { - return _emberRuntimeCopy.default(item, true); - }); + if (curMixin === targetMixin) { + return true; + } + var mixins = curMixin.mixins; + var loc = mixins ? mixins.length : 0; + while (--loc >= 0) { + if (_detect(mixins[loc], targetMixin, seen)) { + return true; } + } + return false; + } - return this.slice(); + /** + @method detect + @param obj + @return {Boolean} + @private + */ + MixinPrototype.detect = function (obj) { + if (typeof obj !== 'object' || obj === null) { + return false; } - }); + if (obj instanceof Mixin) { + return _detect(obj, this, {}); + } + var m = _emberMetalMeta.peekMeta(obj); + if (!m) { + return false; + } + return !!m.peekMixins(_emberUtils.guidFor(this)); + }; - // Remove any methods implemented natively so we don't override them - var ignore = ['length']; - NativeArray.keys().forEach(function (methodName) { - if (Array.prototype[methodName]) { - ignore.push(methodName); + MixinPrototype.without = function () { + var ret = new Mixin([this]); + + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; } - }); - exports.NativeArray // TODO: only use default export - = NativeArray = NativeArray.without.apply(NativeArray, ignore); + ret._without = args; + return ret; + }; - /** - Creates an `Ember.NativeArray` from an Array like object. - Does not modify the original object. Ember.A is not needed if - `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However, - it is recommended that you use Ember.A when creating addons for - ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES` - will be `true`. - - Example - - ```js - export default Ember.Component.extend({ - tagName: 'ul', - classNames: ['pagination'], - - init() { - this._super(...arguments); - - if (!this.get('content')) { - this.set('content', Ember.A()); - } - } - }); - ``` - - @method A - @for Ember - @return {Ember.NativeArray} - @public - */ - var A = undefined; + function _keys(ret, mixin, seen) { + if (seen[_emberUtils.guidFor(mixin)]) { + return; + } + seen[_emberUtils.guidFor(mixin)] = true; - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Array) { - NativeArray.apply(Array.prototype); - exports.A = A = function (arr) { - return arr || []; - }; - } else { - exports.A = A = function (arr) { - if (!arr) { - arr = []; + if (mixin.properties) { + var props = Object.keys(mixin.properties); + for (var i = 0; i < props.length; i++) { + var key = props[i]; + ret[key] = true; } - return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr); - }; + } else if (mixin.mixins) { + mixin.mixins.forEach(function (x) { + return _keys(ret, x, seen); + }); + } } - _emberMetal.default.A = A; - exports.A = A; - exports.NativeArray = NativeArray; - exports.default = NativeArray; -}); -// Ember.A circular -enifed('ember-runtime/system/object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberUtils, _emberMetal, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; + MixinPrototype.keys = function () { + var keys = {}; + var seen = {}; - /** - `Ember.Object` is the main base class for all Ember objects. It is a subclass - of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, - see the documentation for each of these. - - @class Object - @namespace Ember - @extends Ember.CoreObject - @uses Ember.Observable - @public - */ - var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default); - EmberObject.toString = function () { - return 'Ember.Object'; + _keys(keys, this, seen); + var ret = Object.keys(keys); + return ret; }; - var FrameworkObject = EmberObject; + _emberMetalDebug.debugSeal(MixinPrototype); - exports.FrameworkObject = FrameworkObject; - _emberMetal.runInDebug(function () { - var _EmberObject$extend; + var REQUIRED = new _emberMetalProperties.Descriptor(); + REQUIRED.toString = function () { + return '(Required Property)'; + }; - var INIT_WAS_CALLED = _emberUtils.symbol('INIT_WAS_CALLED'); - var ASSERT_INIT_WAS_CALLED = _emberUtils.symbol('ASSERT_INIT_WAS_CALLED'); + /** + Denotes a required property for a mixin + + @method required + @for Ember + @private + */ - exports.FrameworkObject = FrameworkObject = EmberObject.extend((_EmberObject$extend = { - init: function () { - this._super.apply(this, arguments); - this[INIT_WAS_CALLED] = true; - } + function required() { + _emberMetalDebug.deprecate('Ember.required is deprecated as its behavior is inconsistent and unreliable.', false, { id: 'ember-metal.required', until: '3.0.0' }); + return REQUIRED; + } - }, _EmberObject$extend[ASSERT_INIT_WAS_CALLED] = _emberMetal.on('init', function () { - _emberMetal.assert('You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update ' + this + ' to call `this._super(...arguments);` from `init`.', this[INIT_WAS_CALLED]); - }), _EmberObject$extend)); - }); + function Alias(methodName) { + this.isDescriptor = true; + this.methodName = methodName; + } - exports.default = EmberObject; -}); -enifed('ember-runtime/system/object_proxy', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/-proxy'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsProxy) { - 'use strict'; + Alias.prototype = new _emberMetalProperties.Descriptor(); /** - `Ember.ObjectProxy` forwards all properties not defined by the proxy itself - to a proxied `content` object. + Makes a method available via an additional name. ```javascript - object = Ember.Object.create({ - name: 'Foo' - }); - - proxy = Ember.ObjectProxy.create({ - content: object + App.Person = Ember.Object.extend({ + name: function() { + return 'Tomhuda Katzdale'; + }, + moniker: Ember.aliasMethod('name') }); - // Access and change existing properties - proxy.get('name') // 'Foo' - proxy.set('name', 'Bar'); - object.get('name') // 'Bar' - - // Create new 'description' property on `object` - proxy.set('description', 'Foo is a whizboo baz'); - object.get('description') // 'Foo is a whizboo baz' - ``` - - While `content` is unset, setting a property to be delegated will throw an - Error. + let goodGuy = App.Person.create(); - ```javascript - proxy = Ember.ObjectProxy.create({ - content: null, - flag: null - }); - proxy.set('flag', true); - proxy.get('flag'); // true - proxy.get('foo'); // undefined - proxy.set('foo', 'data'); // throws Error + goodGuy.name(); // 'Tomhuda Katzdale' + goodGuy.moniker(); // 'Tomhuda Katzdale' ``` - Delegated properties can be bound to and will change when content is updated. - - Computed properties on the proxy itself can depend on delegated properties. + @method aliasMethod + @for Ember + @param {String} methodName name of the method to alias + @public + */ + + function aliasMethod(methodName) { + return new Alias(methodName); + } + + // .......................................................... + // OBSERVER HELPER + // + + /** + Specify a method that observes property changes. ```javascript - ProxyWithComputedProperty = Ember.ObjectProxy.extend({ - fullName: Ember.computed('firstName', 'lastName', function() { - var firstName = this.get('firstName'), - lastName = this.get('lastName'); - if (firstName && lastName) { - return firstName + ' ' + lastName; - } - return firstName || lastName; + Ember.Object.extend({ + valueObserver: Ember.observer('value', function() { + // Executes whenever the "value" property changes }) }); - - proxy = ProxyWithComputedProperty.create(); - - proxy.get('fullName'); // undefined - proxy.set('content', { - firstName: 'Tom', lastName: 'Dale' - }); // triggers property change for fullName on proxy - - proxy.get('fullName'); // 'Tom Dale' ``` - @class ObjectProxy - @namespace Ember - @extends Ember.Object - @extends Ember._ProxyMixin + Also available as `Function.prototype.observes` if prototype extensions are + enabled. + + @method observer + @for Ember + @param {String} propertyNames* + @param {Function} func + @return func @public */ - exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsProxy.default); -}); -enifed('ember-runtime/system/service', ['exports', 'ember-runtime/system/object', 'ember-runtime/inject'], function (exports, _emberRuntimeSystemObject, _emberRuntimeInject) { - 'use strict'; + function observer() { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + var func = args.slice(-1)[0]; + var paths = undefined; + + var addWatchedProperty = function (path) { + paths.push(path); + }; + var _paths = args.slice(0, -1); + + if (typeof func !== 'function') { + // revert to old, soft-deprecated argument ordering + _emberMetalDebug.deprecate('Passing the dependentKeys after the callback function in Ember.observer is deprecated. Ensure the callback function is the last argument.', false, { id: 'ember-metal.observer-argument-order', until: '3.0.0' }); + + func = args[0]; + _paths = args.slice(1); + } + + paths = []; + + for (var i = 0; i < _paths.length; ++i) { + _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); + } + + if (typeof func !== 'function') { + throw new _emberMetalError.default('Ember.observer called without a function'); + } + + func.__ember_observes__ = paths; + return func; + } /** - Creates a property that lazily looks up a service in the container. There - are no restrictions as to what objects a service can be injected into. - - Example: + Specify a method that observes property changes. ```javascript - App.ApplicationRoute = Ember.Route.extend({ - authManager: Ember.inject.service('auth'), - - model: function() { - return this.get('authManager').findCurrentUser(); - } + Ember.Object.extend({ + valueObserver: Ember.immediateObserver('value', function() { + // Executes whenever the "value" property changes + }) }); ``` - This example will create an `authManager` property on the application route - that looks up the `auth` service in the container, making it easily - accessible in the `model` hook. + In the future, `Ember.observer` may become asynchronous. In this event, + `Ember.immediateObserver` will maintain the synchronous behavior. - @method service - @since 1.10.0 - @for Ember.inject - @param {String} name (optional) name of the service to inject, defaults to - the property's name - @return {Ember.InjectedProperty} injection descriptor instance - @public + Also available as `Function.prototype.observesImmediately` if prototype extensions are + enabled. + + @method _immediateObserver + @for Ember + @param {String} propertyNames* + @param {Function} func + @deprecated Use `Ember.observer` instead. + @return func + @private */ - _emberRuntimeInject.createInjectionHelper('service'); - /** - @class Service - @namespace Ember - @extends Ember.Object - @since 1.10.0 - @public - */ - var Service = _emberRuntimeSystemObject.default.extend(); + function _immediateObserver() { + _emberMetalDebug.deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.', false, { id: 'ember-metal.immediate-observer', until: '3.0.0' }); - Service.reopenClass({ - isServiceFactory: true - }); + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + _emberMetalDebug.assert('Immediate observers must observe internal properties only, not properties on other objects.', typeof arg !== 'string' || arg.indexOf('.') === -1); + } + + return observer.apply(this, arguments); + } - exports.default = Service; -}); -enifed('ember-runtime/system/string', ['exports', 'ember-metal', 'ember-utils', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberUtils, _emberRuntimeUtils, _emberRuntimeString_registry) { /** - @module ember - @submodule ember-runtime + When observers fire, they are called with the arguments `obj`, `keyName`. + + Note, `@each.property` observer is called per each add or replace of an element + and it's not called with a specific enumeration item. + + A `_beforeObserver` fires before a property changes. + + @method beforeObserver + @for Ember + @param {String} propertyNames* + @param {Function} func + @return func + @deprecated + @private */ - 'use strict'; - var STRING_DASHERIZE_REGEXP = /[ _]/g; + function _beforeObserver() { + for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; + } - var STRING_DASHERIZE_CACHE = new _emberMetal.Cache(1000, function (key) { - return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-'); - }); + var func = args.slice(-1)[0]; + var paths = undefined; - var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; - var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; + var addWatchedProperty = function (path) { + paths.push(path); + }; - var CAMELIZE_CACHE = new _emberMetal.Cache(1000, function (key) { - return key.replace(STRING_CAMELIZE_REGEXP_1, function (match, separator, chr) { - return chr ? chr.toUpperCase() : ''; - }).replace(STRING_CAMELIZE_REGEXP_2, function (match, separator, chr) { - return match.toLowerCase(); - }); - }); + var _paths = args.slice(0, -1); - var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; - var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; - var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; + if (typeof func !== 'function') { + // revert to old, soft-deprecated argument ordering - var CLASSIFY_CACHE = new _emberMetal.Cache(1000, function (str) { - var replace1 = function (match, separator, chr) { - return chr ? '_' + chr.toUpperCase() : ''; - }; - var replace2 = function (match, initialChar, separator, chr) { - return initialChar + (chr ? chr.toUpperCase() : ''); - }; - var parts = str.split('/'); - for (var i = 0; i < parts.length; i++) { - parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); + func = args[0]; + _paths = args.slice(1); } - return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, function (match, separator, chr) { - return match.toUpperCase(); - }); - }); - - var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; - var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; - var UNDERSCORE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase(); - }); + paths = []; - var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z])/g; + for (var i = 0; i < _paths.length; ++i) { + _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); + } - var CAPITALIZE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_CAPITALIZE_REGEXP, function (match, separator, chr) { - return match.toUpperCase(); - }); - }); + if (typeof func !== 'function') { + throw new _emberMetalError.default('_beforeObserver called without a function'); + } - var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; + func.__ember_observesBefore__ = paths; + return func; + } - var DECAMELIZE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase(); - }); + exports.Mixin = Mixin; + exports.REQUIRED = REQUIRED; +}); +enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { + 'use strict'; - function _fmt(str, formats) { - var cachedFormats = formats; + exports.addObserver = addObserver; + exports.observersFor = observersFor; + exports.removeObserver = removeObserver; + exports._addBeforeObserver = _addBeforeObserver; + exports._suspendObserver = _suspendObserver; + exports._suspendObservers = _suspendObservers; + exports._removeBeforeObserver = _removeBeforeObserver; - if (!_emberRuntimeUtils.isArray(cachedFormats) || arguments.length > 2) { - cachedFormats = new Array(arguments.length - 1); + /** + @module ember-metal + */ - for (var i = 1; i < arguments.length; i++) { - cachedFormats[i - 1] = arguments[i]; - } - } + var AFTER_OBSERVERS = ':change'; + var BEFORE_OBSERVERS = ':before'; - // first, replace any ORDERED replacements. - var idx = 0; // the current index for non-numerical replacements - return str.replace(/%@([0-9]+)?/g, function (s, argIndex) { - argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++; - s = cachedFormats[argIndex]; - return s === null ? '(null)' : s === undefined ? '' : _emberUtils.inspect(s); - }); + function changeEvent(keyName) { + return keyName + AFTER_OBSERVERS; } - function fmt(str, formats) { - _emberMetal.deprecate('Ember.String.fmt is deprecated, use ES6 template strings instead.', false, { id: 'ember-string-utils.fmt', until: '3.0.0', url: 'http://babeljs.io/docs/learn-es2015/#template-strings' }); - return _fmt.apply(undefined, arguments); + function beforeEvent(keyName) { + return keyName + BEFORE_OBSERVERS; } - function loc(str, formats) { - if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) { - formats = Array.prototype.slice.call(arguments, 1); - } + /** + @method addObserver + @for Ember + @param obj + @param {String} _path + @param {Object|Function} target + @param {Function|String} [method] + @public + */ - str = _emberRuntimeString_registry.get(str) || str; - return _fmt(str, formats); - } + function addObserver(obj, _path, target, method) { + _emberMetalEvents.addListener(obj, changeEvent(_path), target, method); + _emberMetalWatching.watch(obj, _path); - function w(str) { - return str.split(/\s+/); + return this; } - function decamelize(str) { - return DECAMELIZE_CACHE.get(str); + function observersFor(obj, path) { + return _emberMetalEvents.listenersFor(obj, changeEvent(path)); } - function dasherize(str) { - return STRING_DASHERIZE_CACHE.get(str); - } + /** + @method removeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @public + */ - function camelize(str) { - return CAMELIZE_CACHE.get(str); + function removeObserver(obj, path, target, method) { + _emberMetalWatching.unwatch(obj, path); + _emberMetalEvents.removeListener(obj, changeEvent(path), target, method); + + return this; } - function classify(str) { - return CLASSIFY_CACHE.get(str); + /** + @method _addBeforeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @deprecated + @private + */ + + function _addBeforeObserver(obj, path, target, method) { + _emberMetalEvents.addListener(obj, beforeEvent(path), target, method); + _emberMetalWatching.watch(obj, path); + + return this; } - function underscore(str) { - return UNDERSCORE_CACHE.get(str); + // Suspend observer during callback. + // + // This should only be used by the target of the observer + // while it is setting the observed path. + + function _suspendObserver(obj, path, target, method, callback) { + return _emberMetalEvents.suspendListener(obj, changeEvent(path), target, method, callback); } - function capitalize(str) { - return CAPITALIZE_CACHE.get(str); + function _suspendObservers(obj, paths, target, method, callback) { + var events = paths.map(changeEvent); + return _emberMetalEvents.suspendListeners(obj, events, target, method, callback); } /** - Defines string helper methods including string formatting and localization. - Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be - added to the `String.prototype` as well. - - @class String - @namespace Ember - @static - @public + @method removeBeforeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @deprecated + @private */ - exports.default = { - /** - Apply formatting options to the string. This will look for occurrences - of "%@" in your string and substitute them with the arguments you pass into - this method. If you want to control the specific order of replacement, - you can add a number after the key as well to indicate which argument - you want to insert. - Ordered insertions are most useful when building loc strings where values - you need to insert may appear in different orders. - ```javascript - "Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe" - "Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John" - ``` - @method fmt - @param {String} str The string to format - @param {Array} formats An array of parameters to interpolate into string. - @return {String} formatted string - @public - @deprecated Use ES6 template strings instead: http://babeljs.io/docs/learn-es2015/#template-strings - */ - fmt: fmt, - /** - Formats the passed string, but first looks up the string in the localized - strings hash. This is a convenient way to localize text. See - `Ember.String.fmt()` for more information on formatting. - Note that it is traditional but not required to prefix localized string - keys with an underscore or other character so you can easily identify - localized strings. - ```javascript - Ember.STRINGS = { - '_Hello World': 'Bonjour le monde', - '_Hello %@ %@': 'Bonjour %@ %@' - }; - Ember.String.loc("_Hello World"); // 'Bonjour le monde'; - Ember.String.loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; - ``` - @method loc - @param {String} str The string to format - @param {Array} formats Optional array of parameters to interpolate into string. - @return {String} formatted string - @public - */ - loc: loc, + function _removeBeforeObserver(obj, path, target, method) { + _emberMetalWatching.unwatch(obj, path); + _emberMetalEvents.removeListener(obj, beforeEvent(path), target, method); - /** - Splits a string into separate units separated by spaces, eliminating any - empty strings in the process. This is a convenience method for split that - is mostly useful when applied to the `String.prototype`. - ```javascript - Ember.String.w("alpha beta gamma").forEach(function(key) { - console.log(key); - }); - // > alpha - // > beta - // > gamma - ``` - @method w - @param {String} str The string to split - @return {Array} array containing the split strings - @public - */ - w: w, + return this; + } +}); +enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { + 'use strict'; - /** - Converts a camelized string into all lower case separated by underscores. - ```javascript - 'innerHTML'.decamelize(); // 'inner_html' - 'action_name'.decamelize(); // 'action_name' - 'css-class-name'.decamelize(); // 'css-class-name' - 'my favorite items'.decamelize(); // 'my favorite items' - ``` - @method decamelize - @param {String} str The string to decamelize. - @return {String} the decamelized string. - @public - */ - decamelize: decamelize, + /* + this.observerSet = { + [senderGuid]: { // variable name: `keySet` + [keyName]: listIndex + } + }, + this.observers = [ + { + sender: obj, + keyName: keyName, + eventName: eventName, + listeners: [ + [target, method, flags] + ] + }, + ... + ] + */ - /** - Replaces underscores, spaces, or camelCase with dashes. - ```javascript - 'innerHTML'.dasherize(); // 'inner-html' - 'action_name'.dasherize(); // 'action-name' - 'css-class-name'.dasherize(); // 'css-class-name' - 'my favorite items'.dasherize(); // 'my-favorite-items' - 'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice' - ``` - @method dasherize - @param {String} str The string to dasherize. - @return {String} the dasherized string. - @public - */ - dasherize: dasherize, + var ObserverSet = (function () { + function ObserverSet() { + babelHelpers.classCallCheck(this, ObserverSet); - /** - Returns the lowerCamelCase form of a string. - ```javascript - 'innerHTML'.camelize(); // 'innerHTML' - 'action_name'.camelize(); // 'actionName' - 'css-class-name'.camelize(); // 'cssClassName' - 'my favorite items'.camelize(); // 'myFavoriteItems' - 'My Favorite Items'.camelize(); // 'myFavoriteItems' - 'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice' - ``` - @method camelize - @param {String} str The string to camelize. - @return {String} the camelized string. - @public - */ - camelize: camelize, + this.clear(); + } - /** - Returns the UpperCamelCase form of a string. - ```javascript - 'innerHTML'.classify(); // 'InnerHTML' - 'action_name'.classify(); // 'ActionName' - 'css-class-name'.classify(); // 'CssClassName' - 'my favorite items'.classify(); // 'MyFavoriteItems' - 'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice' - ``` - @method classify - @param {String} str the string to classify - @return {String} the classified string - @public - */ - classify: classify, + ObserverSet.prototype.add = function add(sender, keyName, eventName) { + var observerSet = this.observerSet; + var observers = this.observers; + var senderGuid = _emberUtils.guidFor(sender); + var keySet = observerSet[senderGuid]; + var index = undefined; - /** - More general than decamelize. Returns the lower\_case\_and\_underscored - form of a string. - ```javascript - 'innerHTML'.underscore(); // 'inner_html' - 'action_name'.underscore(); // 'action_name' - 'css-class-name'.underscore(); // 'css_class_name' - 'my favorite items'.underscore(); // 'my_favorite_items' - 'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice' - ``` - @method underscore - @param {String} str The string to underscore. - @return {String} the underscored string. - @public - */ - underscore: underscore, + 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; + }; - /** - Returns the Capitalized form of a string - ```javascript - 'innerHTML'.capitalize() // 'InnerHTML' - 'action_name'.capitalize() // 'Action_name' - 'css-class-name'.capitalize() // 'Css-class-name' - 'my favorite items'.capitalize() // 'My favorite items' - 'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice' - ``` - @method capitalize - @param {String} str The string to capitalize. - @return {String} The capitalized string. - @public - */ - capitalize: capitalize + ObserverSet.prototype.flush = function flush() { + var observers = this.observers; + var i = undefined, + observer = undefined, + sender = undefined; + this.clear(); + for (i = 0; i < observers.length; ++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 clear() { + this.observerSet = {}; + this.observers = []; + }; + + return ObserverSet; + })(); + + exports.default = ObserverSet; +}); +enifed('ember-metal/path_cache', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) { + 'use strict'; + + exports.isGlobal = isGlobal; + exports.isGlobalPath = isGlobalPath; + exports.hasThis = hasThis; + exports.isPath = isPath; + exports.getFirstKey = getFirstKey; + exports.getTailPath = getTailPath; + + var IS_GLOBAL = /^[A-Z$]/; + var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; + var HAS_THIS = 'this.'; + + var isGlobalCache = new _emberMetalCache.default(1000, function (key) { + return IS_GLOBAL.test(key); + }); + var isGlobalPathCache = new _emberMetalCache.default(1000, function (key) { + return IS_GLOBAL_PATH.test(key); + }); + var hasThisCache = new _emberMetalCache.default(1000, function (key) { + return key.lastIndexOf(HAS_THIS, 0) === 0; + }); + var firstDotIndexCache = new _emberMetalCache.default(1000, function (key) { + return key.indexOf('.'); + }); + + var firstKeyCache = new _emberMetalCache.default(1000, function (path) { + var index = firstDotIndexCache.get(path); + if (index === -1) { + return path; + } else { + return path.slice(0, index); + } + }); + + var tailPathCache = new _emberMetalCache.default(1000, function (path) { + var index = firstDotIndexCache.get(path); + if (index !== -1) { + return path.slice(index + 1); + } + }); + + var caches = { + isGlobalCache: isGlobalCache, + isGlobalPathCache: isGlobalPathCache, + hasThisCache: hasThisCache, + firstDotIndexCache: firstDotIndexCache, + firstKeyCache: firstKeyCache, + tailPathCache: tailPathCache }; - exports.fmt = fmt; - exports.loc = loc; - exports.w = w; - exports.decamelize = decamelize; - exports.dasherize = dasherize; - exports.camelize = camelize; - exports.classify = classify; - exports.underscore = underscore; - exports.capitalize = capitalize; + + exports.caches = caches; + + function isGlobal(path) { + return isGlobalCache.get(path); + } + + function isGlobalPath(path) { + return isGlobalPathCache.get(path); + } + + function hasThis(path) { + return hasThisCache.get(path); + } + + function isPath(path) { + return firstDotIndexCache.get(path) !== -1; + } + + function getFirstKey(path) { + return firstKeyCache.get(path); + } + + function getTailPath(path) { + return tailPathCache.get(path); + } }); -enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemObject) { +enifed('ember-metal/properties', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/property_events'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperty_events) { + /** + @module ember-metal + */ + 'use strict'; - exports.isArray = isArray; - exports.typeOf = typeOf; + exports.Descriptor = Descriptor; + exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; + exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; + exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; + exports.defineProperty = defineProperty; - // ........................................ - // TYPING & ARRAY MESSAGING + // .......................................................... + // DESCRIPTOR // - var TYPE_MAP = { - '[object Boolean]': 'boolean', - '[object Number]': 'number', - '[object String]': 'string', - '[object Function]': 'function', - '[object Array]': 'array', - '[object Date]': 'date', - '[object RegExp]': 'regexp', - '[object Object]': 'object', - '[object FileList]': 'filelist' - }; - - var toString = Object.prototype.toString; /** - Returns true if the passed object is an array or Array-like. - - Objects are considered Array-like if any of the following are true: - - - the object is a native Array - - the object has an objectAt property - - the object is an Object, and has a length property - - Unlike `Ember.typeOf` this method returns true even if the passed object is - not formally an array but appears to be array-like (i.e. implements `Ember.Array`) - - ```javascript - Ember.isArray(); // false - Ember.isArray([]); // true - Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true - ``` + Objects of this type can implement an interface to respond to requests to + get and set. The default implementation handles simple properties. - @method isArray - @for Ember - @param {Object} obj The object to test - @return {Boolean} true if the passed object is an array or Array-like - @public + @class Descriptor + @private */ - function isArray(obj) { - if (!obj || obj.setInterval) { - return false; - } - if (Array.isArray(obj)) { - return true; - } - if (_emberRuntimeMixinsArray.default.detect(obj)) { - return true; - } + function Descriptor() { + this.isDescriptor = true; + } - var type = typeOf(obj); - if ('array' === type) { - return true; + var REDEFINE_SUPPORTED = (function () { + // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 + var a = Object.create(Object.prototype, { + prop: { + configurable: true, + value: 1 + } + }); + + Object.defineProperty(a, 'prop', { + configurable: true, + value: 2 + }); + + return a.prop === 2; + })(); + // .......................................................... + // DEFINING PROPERTIES API + // + + function MANDATORY_SETTER_FUNCTION(name) { + function SETTER_FUNCTION(value) { + var m = _emberMetalMeta.peekMeta(this); + if (!m.isInitialized(this)) { + m.writeValues(name, value); + } else { + _emberMetalDebug.assert('You must use Ember.set() to set the `' + name + '` property (of ' + this + ') to `' + value + '`.', false); + } } - if (obj.length !== undefined && 'object' === type) { - return true; + + SETTER_FUNCTION.isMandatorySetter = true; + return SETTER_FUNCTION; + } + + function DEFAULT_GETTER_FUNCTION(name) { + return function GETTER_FUNCTION() { + var meta = _emberMetalMeta.peekMeta(this); + return meta && meta.peekValues(name); + }; + } + + function INHERITING_GETTER_FUNCTION(name) { + function IGETTER_FUNCTION() { + var meta = _emberMetalMeta.peekMeta(this); + var val = meta && meta.readInheritedValue('values', name); + + if (val === _emberMetalMeta.UNDEFINED) { + var proto = Object.getPrototypeOf(this); + return proto && proto[name]; + } else { + return val; + } } - return false; + + IGETTER_FUNCTION.isInheritingGetter = true; + return IGETTER_FUNCTION; } /** - Returns a consistent type for the passed object. + NOTE: This is a low-level method used by other parts of the API. You almost + never want to call this method directly. Instead you should use + `Ember.mixin()` to define new properties. - Use this instead of the built-in `typeof` to get the type of an item. - It will return the same result across all browsers and includes a bit - more detail. Here is what will be returned: + Defines a property on an object. This method works much like the ES5 + `Object.defineProperty()` method except that it can also accept computed + properties and other special descriptors. - | Return Value | Meaning | - |---------------|------------------------------------------------------| - | 'string' | String primitive or String object. | - | 'number' | Number primitive or Number object. | - | 'boolean' | Boolean primitive or Boolean object. | - | 'null' | Null value | - | 'undefined' | Undefined value | - | 'function' | A function | - | 'array' | An instance of Array | - | 'regexp' | An instance of RegExp | - | 'date' | An instance of Date | - | 'filelist' | An instance of FileList | - | 'class' | An Ember class (created using Ember.Object.extend()) | - | 'instance' | An Ember object instance | - | 'error' | An instance of the Error object | - | 'object' | A JavaScript object not inheriting from Ember.Object | + Normally this method takes only three parameters. However if you pass an + instance of `Descriptor` as the third param then you can pass an + optional value as the fourth parameter. This is often more efficient than + creating new descriptor hashes for each property. - Examples: + ## Examples ```javascript - Ember.typeOf(); // 'undefined' - Ember.typeOf(null); // 'null' - Ember.typeOf(undefined); // 'undefined' - Ember.typeOf('michael'); // 'string' - Ember.typeOf(new String('michael')); // 'string' - Ember.typeOf(101); // 'number' - Ember.typeOf(new Number(101)); // 'number' - Ember.typeOf(true); // 'boolean' - Ember.typeOf(new Boolean(true)); // 'boolean' - Ember.typeOf(Ember.makeArray); // 'function' - Ember.typeOf([1, 2, 90]); // 'array' - Ember.typeOf(/abc/); // 'regexp' - Ember.typeOf(new Date()); // 'date' - Ember.typeOf(event.target.files); // 'filelist' - Ember.typeOf(Ember.Object.extend()); // 'class' - Ember.typeOf(Ember.Object.create()); // 'instance' - Ember.typeOf(new Error('teamocil')); // 'error' + // ES5 compatible mode + Ember.defineProperty(contact, 'firstName', { + writable: true, + configurable: false, + enumerable: true, + value: 'Charles' + }); - // 'normal' JavaScript object - Ember.typeOf({ a: 'b' }); // 'object' + // define a simple property + Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); + + // define a computed property + Ember.defineProperty(contact, 'fullName', Ember.computed('firstName', 'lastName', function() { + return this.firstName+' '+this.lastName; + })); ``` - @method typeOf + @private + @method defineProperty @for Ember - @param {Object} item the item to check - @return {String} the type - @public + @param {Object} obj the object to define this property on. This may be a prototype. + @param {String} keyName the name of the property + @param {Descriptor} [desc] an instance of `Descriptor` (typically a + computed property) or an ES5 descriptor. + You must provide this or `data` but not both. + @param {*} [data] something other than a descriptor, that will + become the explicit value of this property. */ - function typeOf(item) { - if (item === null) { - return 'null'; + function defineProperty(obj, keyName, desc, data, meta) { + var possibleDesc = undefined, + existingDesc = undefined, + watching = undefined, + value = undefined; + + if (!meta) { + meta = _emberMetalMeta.meta(obj); } - if (item === undefined) { - return 'undefined'; + var watchEntry = meta.peekWatching(keyName); + possibleDesc = obj[keyName]; + existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + watching = watchEntry !== undefined && watchEntry > 0; + + if (existingDesc) { + existingDesc.teardown(obj, keyName); } - var ret = TYPE_MAP[toString.call(item)] || 'object'; - if (ret === 'function') { - if (_emberRuntimeSystemObject.default.detect(item)) { - ret = 'class'; + if (desc instanceof Descriptor) { + value = desc; + if (true) { + if (watching) { + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable: true, + writable: true, + value: value + }); + } else { + obj[keyName] = value; + } + } else { + obj[keyName] = value; } - } else if (ret === 'object') { - if (item instanceof Error) { - ret = 'error'; - } else if (item instanceof _emberRuntimeSystemObject.default) { - ret = 'instance'; - } else if (item instanceof Date) { - ret = 'date'; + if (desc.setup) { + desc.setup(obj, keyName); } - } - - return ret; - } -}); -enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { - 'use strict'; + } else { + if (desc == null) { + value = data; - function K() { - return this; - } + if (true) { + if (watching) { + meta.writeValues(keyName, data); - /** - @module ember - @submodule ember-testing - */ + var defaultDescriptor = { + configurable: true, + enumerable: true, + set: MANDATORY_SETTER_FUNCTION(keyName), + get: DEFAULT_GETTER_FUNCTION(keyName) + }; - /** - The primary purpose of this class is to create hooks that can be implemented - by an adapter for various test frameworks. - - @class Adapter - @namespace Ember.Test - @public - */ - exports.default = _emberRuntime.Object.extend({ - /** - This callback will be called whenever an async operation is about to start. - Override this to call your framework's methods that handle async - operations. - @public - @method asyncStart - */ - asyncStart: K, + if (REDEFINE_SUPPORTED) { + Object.defineProperty(obj, keyName, defaultDescriptor); + } else { + handleBrokenPhantomDefineProperty(obj, keyName, defaultDescriptor); + } + } else { + obj[keyName] = data; + } + } else { + obj[keyName] = data; + } + } else { + value = desc; - /** - This callback will be called whenever an async operation has completed. - @public - @method asyncEnd - */ - asyncEnd: K, + // fallback to ES5 + Object.defineProperty(obj, keyName, desc); + } + } - /** - Override this method with your testing framework's false assertion. - This function is called whenever an exception occurs causing the testing - promise to fail. - QUnit example: - ```javascript - exception: function(error) { - ok(false, error); - }; - ``` - @public - @method exception - @param {String} error The exception to be raised. - */ - exception: function (error) { - throw error; + // if key is being watched, override chains that + // were initialized with the prototype + if (watching) { + _emberMetalProperty_events.overrideChains(obj, keyName, meta); } - }); -}); -enifed('ember-testing/adapters/qunit', ['exports', 'ember-utils', 'ember-testing/adapters/adapter'], function (exports, _emberUtils, _emberTestingAdaptersAdapter) { - 'use strict'; - /** - This class implements the methods defined by Ember.Test.Adapter for the - QUnit testing framework. - - @class QUnitAdapter - @namespace Ember.Test - @extends Ember.Test.Adapter - @public - */ - exports.default = _emberTestingAdaptersAdapter.default.extend({ - asyncStart: function () { - QUnit.stop(); - }, - asyncEnd: function () { - QUnit.start(); - }, - exception: function (error) { - ok(false, _emberUtils.inspect(error)); + // The `value` passed to the `didDefineProperty` hook is + // either the descriptor or data, whichever was passed. + if (obj.didDefineProperty) { + obj.didDefineProperty(obj, keyName, value); } - }); + + return this; + } + + function handleBrokenPhantomDefineProperty(obj, keyName, desc) { + // https://github.com/ariya/phantomjs/issues/11856 + Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); + Object.defineProperty(obj, keyName, desc); + } }); -enifed('ember-testing/events', ['exports', 'ember-views', 'ember-metal'], function (exports, _emberViews, _emberMetal) { +enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) { 'use strict'; - exports.focus = focus; - exports.fireEvent = fireEvent; - - var DEFAULT_EVENT_OPTIONS = { canBubble: true, cancelable: true }; - var KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup']; - var MOUSE_EVENT_TYPES = ['click', 'mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover']; + var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE'); - function focus(el) { - if (!el) { - return; - } - var $el = _emberViews.jQuery(el); - if ($el.is(':input, [contenteditable=true]')) { - var type = $el.prop('type'); - if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') { - _emberMetal.run(null, function () { - // Firefox does not trigger the `focusin` event if the window - // does not have focus. If the document doesn't have focus just - // use trigger('focusin') instead. + exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; + var beforeObserverSet = new _emberMetalObserver_set.default(); + var observerSet = new _emberMetalObserver_set.default(); + var deferred = 0; - if (!document.hasFocus || document.hasFocus()) { - el.focus(); - } else { - $el.trigger('focusin'); - } - }); - } - } - } + // .......................................................... + // PROPERTY CHANGES + // - function fireEvent(element, type) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + /** + This function is called just before an object property is about to change. + It will notify any before observers and prepare caches among other things. + + Normally you will not need to call this method directly but if for some + reason you can't directly watch a property you can invoke this method + manually along with `Ember.propertyDidChange()` which you should call just + after the property value changes. + + @method propertyWillChange + @for Ember + @param {Object} obj The object with the property that will change + @param {String} keyName The property key (or path) that will change. + @return {void} + @private + */ + function propertyWillChange(obj, keyName, _meta) { + var meta = _meta || _emberMetalMeta.peekMeta(obj); - if (!element) { + if (meta && !meta.isInitialized(obj)) { return; } - var event = undefined; - if (KEYBOARD_EVENT_TYPES.indexOf(type) > -1) { - event = buildKeyboardEvent(type, options); - } else if (MOUSE_EVENT_TYPES.indexOf(type) > -1) { - var rect = element.getBoundingClientRect(); - var x = rect.left + 1; - var y = rect.top + 1; - var simulatedCoordinates = { - screenX: x + 5, - screenY: y + 95, - clientX: x, - clientY: y - }; - event = buildMouseEvent(type, _emberViews.jQuery.extend(simulatedCoordinates, options)); - } else { - event = buildBasicEvent(type, options); - } - element.dispatchEvent(event); - } - - function buildBasicEvent(type) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - var event = document.createEvent('Events'); - event.initEvent(type, true, true); - _emberViews.jQuery.extend(event, options); - return event; - } - function buildMouseEvent(type) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var watching = meta && meta.peekWatching(keyName) > 0; + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - var event = undefined; - try { - event = document.createEvent('MouseEvents'); - var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); - event.initMouseEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.detail, eventOpts.screenX, eventOpts.screenY, eventOpts.clientX, eventOpts.clientY, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.button, eventOpts.relatedTarget); - } catch (e) { - event = buildBasicEvent(type, options); + if (desc && desc.willChange) { + desc.willChange(obj, keyName); + } + + if (watching) { + dependentKeysWillChange(obj, keyName, meta); + chainsWillChange(obj, keyName, meta); + notifyBeforeObservers(obj, keyName, meta); } - return event; } - function buildKeyboardEvent(type) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + /** + This function is called just after an object property has changed. + It will notify any observers and clear caches among other things. + + Normally you will not need to call this method directly but if for some + reason you can't directly watch a property you can invoke this method + manually along with `Ember.propertyWillChange()` which you should call just + before the property value changes. + + @method propertyDidChange + @for Ember + @param {Object} obj The object with the property that will change + @param {String} keyName The property key (or path) that will change. + @param {Meta} meta The objects meta. + @return {void} + @private + */ + function propertyDidChange(obj, keyName, _meta) { + var meta = _meta || _emberMetalMeta.peekMeta(obj); - var event = undefined; - try { - event = document.createEvent('KeyEvents'); - var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); - event.initKeyEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.keyCode, eventOpts.charCode); - } catch (e) { - event = buildBasicEvent(type, options); + if (meta && !meta.isInitialized(obj)) { + return; } - return event; - } -}); -enifed('ember-testing/ext/application', ['exports', 'ember-application', 'ember-testing/setup_for_testing', 'ember-testing/test/helpers', 'ember-testing/test/promise', 'ember-testing/test/run', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/adapter'], function (exports, _emberApplication, _emberTestingSetup_for_testing, _emberTestingTestHelpers, _emberTestingTestPromise, _emberTestingTestRun, _emberTestingTestOn_inject_helpers, _emberTestingTestAdapter) { - 'use strict'; - _emberApplication.Application.reopen({ - /** - This property contains the testing helpers for the current application. These - are created once you call `injectTestHelpers` on your `Ember.Application` - instance. The included helpers are also available on the `window` object by - default, but can be used from this object on the individual application also. - @property testHelpers - @type {Object} - @default {} - @public - */ - testHelpers: {}, + var watching = meta && meta.peekWatching(keyName) > 0; + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - /** - This property will contain the original methods that were registered - on the `helperContainer` before `injectTestHelpers` is called. - When `removeTestHelpers` is called, these methods are restored to the - `helperContainer`. - @property originalMethods - @type {Object} - @default {} - @private - @since 1.3.0 - */ - originalMethods: {}, + // shouldn't this mean that we're watching this key? + if (desc && desc.didChange) { + desc.didChange(obj, keyName); + } - /** - This property indicates whether or not this application is currently in - testing mode. This is set when `setupForTesting` is called on the current - application. - @property testing - @type {Boolean} - @default false - @since 1.3.0 - @public - */ - testing: false, + if (watching) { + if (meta.hasDeps(keyName)) { + dependentKeysDidChange(obj, keyName, meta); + } - /** - This hook defers the readiness of the application, so that you can start - the app when your tests are ready to run. It also sets the router's - location to 'none', so that the window's location will not be modified - (preventing both accidental leaking of state between tests and interference - with your testing framework). - Example: - ``` - App.setupForTesting(); - ``` - @method setupForTesting - @public - */ - setupForTesting: function () { - _emberTestingSetup_for_testing.default(); + chainsDidChange(obj, keyName, meta, false); + notifyObservers(obj, keyName, meta); + } - this.testing = true; + if (obj[PROPERTY_DID_CHANGE]) { + obj[PROPERTY_DID_CHANGE](keyName); + } - this.Router.reopen({ - location: 'none' - }); - }, + if (meta && meta.isSourceDestroying()) { + return; + } - /** - This will be used as the container to inject the test helpers into. By - default the helpers are injected into `window`. - @property helperContainer - @type {Object} The object to be used for test helpers. - @default window - @since 1.2.0 - @private - */ - helperContainer: null, + _emberMetalTags.markObjectAsDirty(meta, keyName); - /** - This injects the test helpers into the `helperContainer` object. If an object is provided - it will be used as the helperContainer. If `helperContainer` is not set it will default - to `window`. If a function of the same name has already been defined it will be cached - (so that it can be reset if the helper is removed with `unregisterHelper` or - `removeTestHelpers`). - Any callbacks registered with `onInjectHelpers` will be called once the - helpers have been injected. - Example: - ``` - App.injectTestHelpers(); - ``` - @method injectTestHelpers - @public - */ - injectTestHelpers: function (helperContainer) { - if (helperContainer) { - this.helperContainer = helperContainer; - } else { - this.helperContainer = window; - } + if (true || false) { + _emberMetalTransaction.assertNotRendered(obj, keyName, meta); + } + } - this.reopen({ - willDestroy: function () { - this._super.apply(this, arguments); - this.removeTestHelpers(); - } - }); + var WILL_SEEN = undefined, + DID_SEEN = undefined; + // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) + function dependentKeysWillChange(obj, depKey, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - this.testHelpers = {}; - for (var _name in _emberTestingTestHelpers.helpers) { - this.originalMethods[_name] = this.helperContainer[_name]; - this.testHelpers[_name] = this.helperContainer[_name] = helper(this, _name); - protoWrap(_emberTestingTestPromise.default.prototype, _name, helper(this, _name), _emberTestingTestHelpers.helpers[_name].meta.wait); + if (meta && meta.hasDeps(depKey)) { + var seen = WILL_SEEN; + var _top = !seen; + + if (_top) { + seen = WILL_SEEN = {}; } - _emberTestingTestOn_inject_helpers.invokeInjectHelpersCallbacks(this); - }, + iterDeps(propertyWillChange, obj, depKey, seen, meta); - /** - This removes all helpers that have been registered, and resets and functions - that were overridden by the helpers. - Example: - ```javascript - App.removeTestHelpers(); - ``` - @public - @method removeTestHelpers - */ - removeTestHelpers: function () { - if (!this.helperContainer) { - return; + if (_top) { + WILL_SEEN = null; } + } + } - for (var _name2 in _emberTestingTestHelpers.helpers) { - this.helperContainer[_name2] = this.originalMethods[_name2]; - delete _emberTestingTestPromise.default.prototype[_name2]; - delete this.testHelpers[_name2]; - delete this.originalMethods[_name2]; - } + // called whenever a property has just changed to update dependent keys + function dependentKeysDidChange(obj, depKey, meta) { + if (meta && meta.isSourceDestroying()) { + return; } - }); - // This method is no longer needed - // But still here for backwards compatibility - // of helper chaining - function protoWrap(proto, name, callback, isAsync) { - proto[name] = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + if (meta && meta.hasDeps(depKey)) { + var seen = DID_SEEN; + var _top2 = !seen; + + if (_top2) { + seen = DID_SEEN = {}; } - if (isAsync) { - return callback.apply(this, args); - } else { - return this.then(function () { - return callback.apply(this, args); - }); + iterDeps(propertyDidChange, obj, depKey, seen, meta); + + if (_top2) { + DID_SEEN = null; } - }; + } } - function helper(app, name) { - var fn = _emberTestingTestHelpers.helpers[name].method; - var meta = _emberTestingTestHelpers.helpers[name].meta; - if (!meta.wait) { - return function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + function iterDeps(method, obj, depKey, seen, meta) { + var possibleDesc = undefined, + desc = undefined; + var guid = _emberUtils.guidFor(obj); + var current = seen[guid]; - return fn.apply(app, [app].concat(args)); - }; + if (!current) { + current = seen[guid] = {}; } - return function () { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; + if (current[depKey]) { + return; + } + + current[depKey] = true; + + meta.forEachInDeps(depKey, function (key, value) { + if (!value) { + return; } - var lastPromise = _emberTestingTestRun.default(function () { - return _emberTestingTestPromise.resolve(_emberTestingTestPromise.getLastPromise()); - }); + possibleDesc = obj[key]; + desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - // wait for last helper's promise to resolve and then - // execute. To be safe, we need to tell the adapter we're going - // asynchronous here, because fn may not be invoked before we - // return. - _emberTestingTestAdapter.asyncStart(); - return lastPromise.then(function () { - return fn.apply(app, [app].concat(args)); - }).finally(_emberTestingTestAdapter.asyncEnd); - }; + if (desc && desc._suspended === obj) { + return; + } + + method(obj, key, meta); + }); } -}); -enifed('ember-testing/ext/rsvp', ['exports', 'ember-runtime', 'ember-metal', 'ember-testing/test/adapter'], function (exports, _emberRuntime, _emberMetal, _emberTestingTestAdapter) { - 'use strict'; - _emberRuntime.RSVP.configure('async', function (callback, promise) { - // if schedule will cause autorun, we need to inform adapter - if (_emberMetal.isTesting() && !_emberMetal.run.backburner.currentInstance) { - _emberTestingTestAdapter.asyncStart(); - _emberMetal.run.backburner.schedule('actions', function () { - _emberTestingTestAdapter.asyncEnd(); - callback(promise); - }); - } else { - _emberMetal.run.backburner.schedule('actions', function () { - return callback(promise); - }); + function chainsWillChange(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.notify(keyName, false, propertyWillChange); } - }); - - exports.default = _emberRuntime.RSVP; -}); -enifed('ember-testing/helpers', ['exports', 'ember-metal', 'ember-testing/test/helpers', 'ember-testing/helpers/and_then', 'ember-testing/helpers/click', 'ember-testing/helpers/current_path', 'ember-testing/helpers/current_route_name', 'ember-testing/helpers/current_url', 'ember-testing/helpers/fill_in', 'ember-testing/helpers/find', 'ember-testing/helpers/find_with_assert', 'ember-testing/helpers/key_event', 'ember-testing/helpers/pause_test', 'ember-testing/helpers/trigger_event', 'ember-testing/helpers/visit', 'ember-testing/helpers/wait'], function (exports, _emberMetal, _emberTestingTestHelpers, _emberTestingHelpersAnd_then, _emberTestingHelpersClick, _emberTestingHelpersCurrent_path, _emberTestingHelpersCurrent_route_name, _emberTestingHelpersCurrent_url, _emberTestingHelpersFill_in, _emberTestingHelpersFind, _emberTestingHelpersFind_with_assert, _emberTestingHelpersKey_event, _emberTestingHelpersPause_test, _emberTestingHelpersTrigger_event, _emberTestingHelpersVisit, _emberTestingHelpersWait) { - 'use strict'; - - _emberTestingTestHelpers.registerAsyncHelper('visit', _emberTestingHelpersVisit.default); - _emberTestingTestHelpers.registerAsyncHelper('click', _emberTestingHelpersClick.default); - _emberTestingTestHelpers.registerAsyncHelper('keyEvent', _emberTestingHelpersKey_event.default); - _emberTestingTestHelpers.registerAsyncHelper('fillIn', _emberTestingHelpersFill_in.default); - _emberTestingTestHelpers.registerAsyncHelper('wait', _emberTestingHelpersWait.default); - _emberTestingTestHelpers.registerAsyncHelper('andThen', _emberTestingHelpersAnd_then.default); - _emberTestingTestHelpers.registerAsyncHelper('pauseTest', _emberTestingHelpersPause_test.pauseTest); - _emberTestingTestHelpers.registerAsyncHelper('triggerEvent', _emberTestingHelpersTrigger_event.default); + } - _emberTestingTestHelpers.registerHelper('find', _emberTestingHelpersFind.default); - _emberTestingTestHelpers.registerHelper('findWithAssert', _emberTestingHelpersFind_with_assert.default); - _emberTestingTestHelpers.registerHelper('currentRouteName', _emberTestingHelpersCurrent_route_name.default); - _emberTestingTestHelpers.registerHelper('currentPath', _emberTestingHelpersCurrent_path.default); - _emberTestingTestHelpers.registerHelper('currentURL', _emberTestingHelpersCurrent_url.default); + function chainsDidChange(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.notify(keyName, true, propertyDidChange); + } + } - if (false) { - _emberTestingTestHelpers.registerHelper('resumeTest', _emberTestingHelpersPause_test.resumeTest); + function overrideChains(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidate(keyName); + } } -}); -enifed("ember-testing/helpers/and_then", ["exports"], function (exports) { + /** - @module ember - @submodule ember-testing + @method beginPropertyChanges + @chainable + @private */ - "use strict"; - - exports.default = andThen; - - function andThen(app, callback) { - return app.testHelpers.wait(callback(app)); + function beginPropertyChanges() { + deferred++; } -}); -enifed('ember-testing/helpers/click', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** - @module ember - @submodule ember-testing + @method endPropertyChanges + @private */ - 'use strict'; - - exports.default = click; + function endPropertyChanges() { + deferred--; + if (deferred <= 0) { + beforeObserverSet.clear(); + observerSet.flush(); + } + } /** - Clicks an element and triggers any actions triggered by the element's `click` - event. - - Example: + Make a series of property changes together in an + exception-safe way. ```javascript - click('.some-jQuery-selector').then(function() { - // assert something + Ember.changeProperties(function() { + obj1.set('foo', mayBlowUpWhenSet); + obj2.set('bar', baz); }); ``` - @method click - @param {String} selector jQuery selector for finding element on the DOM - @param {Object} context A DOM Element, Document, or jQuery to use as context - @return {RSVP.Promise} - @public - */ - - function click(app, selector, context) { - var $el = app.testHelpers.findWithAssert(selector, context); - var el = $el[0]; - - _emberTestingEvents.fireEvent(el, 'mousedown'); - - _emberTestingEvents.focus(el); - - _emberTestingEvents.fireEvent(el, 'mouseup'); - _emberTestingEvents.fireEvent(el, 'click'); - - return app.testHelpers.wait(); - } -}); -enifed('ember-testing/helpers/current_path', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - - exports.default = currentPath; - - /** - Returns the current path. - - Example: - - ```javascript - function validateURL() { - equal(currentPath(), 'some.path.index', "correct path was transitioned into."); - } - - click('#some-link-id').then(validateURL); - ``` - - @method currentPath - @return {Object} The currently active path. - @since 1.5.0 - @public + @method changeProperties + @param {Function} callback + @param [binding] + @private */ - - function currentPath(app) { - var routingService = app.__container__.lookup('service:-routing'); - return _emberMetal.get(routingService, 'currentPath'); + function changeProperties(callback, binding) { + beginPropertyChanges(); + try { + callback.call(binding); + } finally { + endPropertyChanges.call(binding); + } } -}); -enifed('ember-testing/helpers/current_route_name', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.default = currentRouteName; - - /** - Returns the currently active route name. - Example: - ```javascript - function validateRouteName() { - equal(currentRouteName(), 'some.path', "correct route was transitioned into."); - } - visit('/some/path').then(validateRouteName) - ``` - @method currentRouteName - @return {Object} The name of the currently active route. - @since 1.5.0 - @public - */ + function notifyBeforeObservers(obj, keyName, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - function currentRouteName(app) { - var routingService = app.__container__.lookup('service:-routing'); - return _emberMetal.get(routingService, 'currentRouteName'); + var eventName = keyName + ':before'; + var listeners = undefined, + added = undefined; + if (deferred) { + listeners = beforeObserverSet.add(obj, keyName, eventName); + added = _emberMetalEvents.accumulateListeners(obj, eventName, listeners); + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName], added); + } else { + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); + } } -}); -enifed('ember-testing/helpers/current_url', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.default = currentURL; - - /** - Returns the current URL. - - Example: - - ```javascript - function validateURL() { - equal(currentURL(), '/some/path', "correct URL was transitioned into."); - } - - click('#some-link-id').then(validateURL); - ``` - - @method currentURL - @return {Object} The currently active URL. - @since 1.5.0 - @public - */ + function notifyObservers(obj, keyName, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - function currentURL(app) { - var router = app.__container__.lookup('router:main'); - return _emberMetal.get(router, 'location').getURL(); + var eventName = keyName + ':change'; + var listeners = undefined; + if (deferred) { + listeners = observerSet.add(obj, keyName, eventName); + _emberMetalEvents.accumulateListeners(obj, eventName, listeners); + } else { + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); + } } + + exports.propertyWillChange = propertyWillChange; + exports.propertyDidChange = propertyDidChange; + exports.overrideChains = overrideChains; + exports.beginPropertyChanges = beginPropertyChanges; + exports.endPropertyChanges = endPropertyChanges; + exports.changeProperties = changeProperties; }); -enifed('ember-testing/helpers/fill_in', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { +enifed('ember-metal/property_get', ['exports', 'ember-metal/debug', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalPath_cache) { /** - @module ember - @submodule ember-testing + @module ember-metal */ + 'use strict'; - exports.default = fillIn; + exports.get = get; + exports._getPath = _getPath; + exports.getWithDefault = getWithDefault; + + var ALLOWABLE_TYPES = { + object: true, + function: true, + string: true + }; + + // .......................................................... + // GET AND SET + // + // If we are on a platform that supports accessors we can use those. + // Otherwise simulate accessors by looking up the property directly on the + // object. /** - Fills in an input element with some text. - - Example: + Gets the value of a property on an object. If the property is computed, + the function will be invoked. If the property is not defined but the + object implements the `unknownProperty` method then that will be invoked. ```javascript - fillIn('#email', 'you@example.com').then(function() { - // assert something - }); + Ember.get(obj, "name"); ``` - @method fillIn - @param {String} selector jQuery selector finding an input element on the DOM - to fill text with - @param {String} text text to place inside the input element - @return {RSVP.Promise} + If you plan to run on IE8 and older browsers then you should use this + method anytime you want to retrieve a property on an object that you don't + know for sure is private. (Properties beginning with an underscore '_' + are considered private.) + + On all newer browsers, you only need to use this method to retrieve + properties if the property might not be defined on the object and you want + to respect the `unknownProperty` handler. Otherwise you can ignore this + method. + + Note that if the object itself is `undefined`, this method will throw + an error. + + @method get + @for Ember + @param {Object} obj The object to retrieve from. + @param {String} keyName The property key to retrieve + @return {Object} the property value or `null`. @public */ - function fillIn(app, selector, contextOrText, text) { - var $el = undefined, - el = undefined, - context = undefined; - if (typeof text === 'undefined') { - text = contextOrText; + function get(obj, keyName) { + _emberMetalDebug.assert('Get must be called with two arguments; an object and a property key', arguments.length === 2); + _emberMetalDebug.assert('Cannot call get with \'' + keyName + '\' on an undefined object.', obj !== undefined && obj !== null); + _emberMetalDebug.assert('The key provided to get must be a string, you passed ' + keyName, typeof keyName === 'string'); + _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); + _emberMetalDebug.assert('Cannot call `Ember.get` with an empty string', keyName !== ''); + + var value = obj[keyName]; + var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined; + var ret = undefined; + + if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) { + return _getPath(obj, keyName); + } + + if (desc) { + return desc.get(obj, keyName); } else { - context = contextOrText; + ret = value; + + if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { + return obj.unknownProperty(keyName); + } + + return ret; } - $el = app.testHelpers.findWithAssert(selector, context); - el = $el[0]; - _emberTestingEvents.focus(el); + } - $el.eq(0).val(text); - _emberTestingEvents.fireEvent(el, 'input'); - _emberTestingEvents.fireEvent(el, 'change'); + function _getPath(root, path) { + var obj = root; + var parts = path.split('.'); - return app.testHelpers.wait(); + for (var i = 0; i < parts.length; i++) { + if (!isGettable(obj)) { + return undefined; + } + + obj = get(obj, parts[i]); + + if (obj && obj.isDestroyed) { + return undefined; + } + } + + return obj; } -}); -enifed('ember-testing/helpers/find', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.default = find; + function isGettable(obj) { + if (obj == null) { + return false; + } + + return ALLOWABLE_TYPES[typeof obj]; + } /** - Finds an element in the context of the app's container element. A simple alias - for `app.$(selector)`. - - Example: - - ```javascript - var $el = find('.my-selector'); - ``` - - With the `context` param: + Retrieves the value of a property from an Object, or a default value in the + case that the property returns `undefined`. ```javascript - var $el = find('.my-selector', '.parent-element-class'); + Ember.getWithDefault(person, 'lastName', 'Doe'); ``` - @method find - @param {String} selector jQuery string selector for element lookup - @param {String} [context] (optional) jQuery selector that will limit the selector - argument to find only within the context's children - @return {Object} jQuery object representing the results of the query + @method getWithDefault + @for Ember + @param {Object} obj The object to retrieve from. + @param {String} keyName The name of the property to retrieve + @param {Object} defaultValue The value to return if the property value is undefined + @return {Object} The property value or the defaultValue. @public */ - function find(app, selector, context) { - var $el = undefined; - context = context || _emberMetal.get(app, 'rootElement'); - $el = app.$(selector, context); - return $el; + function getWithDefault(root, key, defaultValue) { + var value = get(root, key); + + if (value === undefined) { + return defaultValue; + } + return value; } + + exports.default = get; }); -enifed('ember-testing/helpers/find_with_assert', ['exports'], function (exports) { - /** - @module ember - @submodule ember-testing - */ +enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) { + 'use strict'; + + exports.set = set; + exports.trySet = trySet; + /** - Like `find`, but throws an error if the element selector returns no results. - - Example: - - ```javascript - var $el = findWithAssert('.doesnt-exist'); // throws error - ``` - - With the `context` param: + Sets the value of a property on an object, respecting computed properties + and notifying observers and other listeners of the change. If the + property is not defined but the object implements the `setUnknownProperty` + method then that will be invoked as well. ```javascript - var $el = findWithAssert('.selector-id', '.parent-element-class'); // assert will pass + Ember.set(obj, "name", value); ``` - @method findWithAssert - @param {String} selector jQuery selector string for finding an element within - the DOM - @param {String} [context] (optional) jQuery selector that will limit the - selector argument to find only within the context's children - @return {Object} jQuery object representing the results of the query - @throws {Error} throws error if jQuery object returned has a length of 0 + @method set + @for Ember + @param {Object} obj The object to modify. + @param {String} keyName The property key to set + @param {Object} value The value to set + @return {Object} the passed value. @public */ - 'use strict'; - exports.default = findWithAssert; + function set(obj, keyName, value, tolerant) { + _emberMetalDebug.assert('Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false', arguments.length === 3 || arguments.length === 4); + _emberMetalDebug.assert('Cannot call set with \'' + keyName + '\' on an undefined object.', obj && typeof obj === 'object' || typeof obj === 'function'); + _emberMetalDebug.assert('The key provided to set must be a string, you passed ' + keyName, typeof keyName === 'string'); + _emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName)); + _emberMetalDebug.assert('calling set on destroyed object: ' + _emberUtils.toString(obj) + '.' + keyName + ' = ' + _emberUtils.toString(value), !obj.isDestroyed); - function findWithAssert(app, selector, context) { - var $el = app.testHelpers.find(selector, context); - if ($el.length === 0) { - throw new Error('Element ' + selector + ' not found.'); + if (_emberMetalPath_cache.isPath(keyName)) { + return setPath(obj, keyName, value, tolerant); } - return $el; - } -}); -enifed('ember-testing/helpers/key_event', ['exports'], function (exports) { - /** - @module ember - @submodule ember-testing - */ - /** - Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode - Example: - ```javascript - keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() { - // assert something - }); - ``` - @method keyEvent - @param {String} selector jQuery selector for finding element on the DOM - @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup` - @param {Number} keyCode the keyCode of the simulated key event - @return {RSVP.Promise} - @since 1.5.0 - @public - */ - 'use strict'; - exports.default = keyEvent; + var meta = _emberMetalMeta.peekMeta(obj); + var possibleDesc = obj[keyName]; - function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { - var context = undefined, - type = undefined; + var desc = undefined, + currentValue = undefined; + if (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { + desc = possibleDesc; + } else { + currentValue = possibleDesc; + } - if (typeof keyCode === 'undefined') { - context = null; - keyCode = typeOrKeyCode; - type = contextOrType; + if (desc) { + /* computed property */ + desc.set(obj, keyName, value); + } else if (obj.setUnknownProperty && currentValue === undefined && !(keyName in obj)) { + /* unknown property */ + _emberMetalDebug.assert('setUnknownProperty must be a function', typeof obj.setUnknownProperty === 'function'); + obj.setUnknownProperty(keyName, value); + } else if (currentValue === value) { + /* no change */ + return value; } else { - context = contextOrType; - type = typeOrKeyCode; + _emberMetalProperty_events.propertyWillChange(obj, keyName); + + if (true) { + setWithMandatorySetter(meta, obj, keyName, value); + } else { + obj[keyName] = value; + } + + _emberMetalProperty_events.propertyDidChange(obj, keyName); } - return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode }); + return value; } -}); -enifed('ember-testing/helpers/pause_test', ['exports', 'ember-runtime', 'ember-console', 'ember-metal'], function (exports, _emberRuntime, _emberConsole, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; - exports.resumeTest = resumeTest; - exports.pauseTest = pauseTest; - - var resume = undefined; + if (true) { + var setWithMandatorySetter = function (meta, obj, keyName, value) { + if (meta && meta.peekWatching(keyName) > 0) { + makeEnumerable(obj, keyName); + meta.writeValue(obj, keyName, value); + } else { + obj[keyName] = value; + } + }; - /** - Resumes a test paused by `pauseTest`. - - @method resumeTest - @return {void} - @public - */ + var makeEnumerable = function (obj, key) { + var desc = Object.getOwnPropertyDescriptor(obj, key); - function resumeTest() { - _emberMetal.assert('Testing has not been paused. There is nothing to resume.', resume); - resume(); - resume = undefined; + if (desc && desc.set && desc.set.isMandatorySetter) { + desc.enumerable = true; + Object.defineProperty(obj, key, desc); + } + }; } - /** - Pauses the current test - this is useful for debugging while testing or for test-driving. - It allows you to inspect the state of your application at any point. - Example (The test will pause before clicking the button): - - ```javascript - visit('/') - return pauseTest(); - click('.btn'); - ``` - @since 1.9.0 - @method pauseTest - @return {Object} A promise that will never resolve - @public - */ + function setPath(root, path, value, tolerant) { + // get the last part of the path + var keyName = path.slice(path.lastIndexOf('.') + 1); - function pauseTest() { - if (false) { - _emberConsole.default.info('Testing paused. Use `resumeTest()` to continue.'); + // get the first part of the part + path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); + + // unless the path is this, look up the first part to + // get the root + if (path !== 'this') { + root = _emberMetalProperty_get._getPath(root, path); } - return new _emberRuntime.RSVP.Promise(function (resolve) { - if (false) { - resume = resolve; + if (!keyName || keyName.length === 0) { + throw new _emberMetalError.default('Property set failed: You passed an empty path'); + } + + if (!root) { + if (tolerant) { + return; + } else { + throw new _emberMetalError.default('Property set failed: object in path "' + path + '" could not be found or was destroyed.'); } - }, 'TestAdapter paused promise'); + } + + return set(root, keyName, value); } -}); -enifed('ember-testing/helpers/trigger_event', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** - @module ember - @submodule ember-testing + Error-tolerant form of `Ember.set`. Will not blow up if any part of the + chain is `undefined`, `null`, or destroyed. + + This is primarily used when syncing bindings, which may try to update after + an object has been destroyed. + + @method trySet + @for Ember + @param {Object} root The object to modify. + @param {String} path The property path to set + @param {Object} value The value to set + @public */ - 'use strict'; - exports.default = triggerEvent; + function trySet(root, path, value) { + return set(root, path, value, true); + } +}); +enifed("ember-metal/replace", ["exports"], function (exports) { + "use strict"; - /** - Triggers the given DOM event on the element identified by the provided selector. - Example: - ```javascript - triggerEvent('#some-elem-id', 'blur'); - ``` - This is actually used internally by the `keyEvent` helper like so: - ```javascript - triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 }); - ``` - @method triggerEvent - @param {String} selector jQuery selector for finding element on the DOM - @param {String} [context] jQuery selector that will limit the selector - argument to find only within the context's children - @param {String} type The event type to be triggered. - @param {Object} [options] The options to be passed to jQuery.Event. - @return {RSVP.Promise} - @since 1.5.0 - @public - */ + exports.default = replace; + var splice = Array.prototype.splice; - function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { - var arity = arguments.length; - var context = undefined, - type = undefined, - options = undefined; + function replace(array, idx, amt, objects) { + var args = [].concat(objects); + var ret = []; + // https://code.google.com/p/chromium/issues/detail?id=56588 + var size = 60000; + var start = idx; + var ends = amt; + var count = undefined, + chunk = undefined; - if (arity === 3) { - // context and options are optional, so this is - // app, selector, type - context = null; - type = contextOrType; - options = {}; - } else if (arity === 4) { - // context and options are optional, so this is - if (typeof typeOrOptions === 'object') { - // either - // app, selector, type, options - context = null; - type = contextOrType; - options = typeOrOptions; - } else { - // or - // app, selector, context, type - context = contextOrType; - type = typeOrOptions; - options = {}; + while (args.length) { + count = ends > size ? size : ends; + if (count <= 0) { + count = 0; } - } else { - context = contextOrType; - type = typeOrOptions; - options = possibleOptions; - } - var $el = app.testHelpers.findWithAssert(selector, context); - var el = $el[0]; + chunk = args.splice(0, size); + chunk = [start, count].concat(chunk); - _emberTestingEvents.fireEvent(el, type, options); + start += size; + ends -= count; - return app.testHelpers.wait(); + ret = ret.concat(splice.apply(array, chunk)); + } + return ret; } }); -enifed('ember-testing/helpers/visit', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ +enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) { 'use strict'; - exports.default = visit; + exports.default = run; + + function onBegin(current) { + run.currentRunLoop = current; + } + + function onEnd(current, next) { + run.currentRunLoop = next; + } + + var onErrorTarget = { + get onerror() { + return _emberMetalError_handler.getOnerror(); + }, + set onerror(handler) { + return _emberMetalError_handler.setOnerror(handler); + } + }; + + var backburner = new _backburner.default(['sync', 'actions', 'destroy'], { + GUID_KEY: _emberUtils.GUID_KEY, + sync: { + before: _emberMetalProperty_events.beginPropertyChanges, + after: _emberMetalProperty_events.endPropertyChanges + }, + defaultQueue: 'actions', + onBegin: onBegin, + onEnd: onEnd, + onErrorTarget: onErrorTarget, + onErrorMethod: 'onerror' + }); + + // .......................................................... + // run - this is ideally the only public API the dev sees + // /** - Loads a route, sets up any controllers, and renders any templates associated - with the route as though a real user had triggered the route change while - using your app. + Runs the passed target and method inside of a RunLoop, ensuring any + deferred actions including bindings and views updates are flushed at the + end. - Example: + Normally you should not need to invoke this method yourself. However if + you are implementing raw event handlers when interfacing with other + libraries or plugins, you should probably wrap all of your code inside this + call. ```javascript - visit('posts/index').then(function() { - // assert something + run(function() { + // code to be executed within a RunLoop }); ``` - @method visit - @param {String} url the name of the route - @return {RSVP.Promise} + @class run + @namespace Ember + @static + @constructor + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Object} return value from invoking the passed function. @public */ - function visit(app, url) { - var router = app.__container__.lookup('router:main'); - var shouldHandleURL = false; - - app.boot().then(function () { - router.location.setURL(url); - - if (shouldHandleURL) { - _emberMetal.run(app.__deprecatedInstance__, 'handleURL', url); - } - }); - - if (app._readinessDeferrals > 0) { - router['initialURL'] = url; - _emberMetal.run(app, 'advanceReadiness'); - delete router['initialURL']; - } else { - shouldHandleURL = true; - } - - return app.testHelpers.wait(); + function run() { + return backburner.run.apply(backburner, arguments); } -}); -enifed('ember-testing/helpers/wait', ['exports', 'ember-testing/test/waiters', 'ember-runtime', 'ember-metal', 'ember-testing/test/pending_requests'], function (exports, _emberTestingTestWaiters, _emberRuntime, _emberMetal, _emberTestingTestPending_requests) { + /** - @module ember - @submodule ember-testing + If no run-loop is present, it creates a new one. If a run loop is + present it will queue itself to run on the existing run-loops action + queue. + + Please note: This is not for normal usage, and should be used sparingly. + + If invoked when not within a run loop: + + ```javascript + run.join(function() { + // creates a new run-loop + }); + ``` + + Alternatively, if called within an existing run loop: + + ```javascript + run(function() { + // creates a new run-loop + run.join(function() { + // joins with the existing run-loop, and queues for invocation on + // the existing run-loops action queue. + }); + }); + ``` + + @method join + @namespace Ember + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Object} Return value from invoking the passed function. Please note, + when called within an existing loop, no return value is possible. + @public */ - 'use strict'; - - exports.default = wait; + run.join = function () { + return backburner.join.apply(backburner, arguments); + }; /** - Causes the run loop to process any pending events. This is used to ensure that - any async operations from other helpers (or your assertions) have been processed. - - This is most often used as the return value for the helper functions (see 'click', - 'fillIn','visit',etc). However, there is a method to register a test helper which - utilizes this method without the need to actually call `wait()` in your helpers. + Allows you to specify which context to call the specified function in while + adding the execution of that function to the Ember run loop. This ability + makes this method a great way to asynchronously integrate third-party libraries + into your Ember application. - The `wait` helper is built into `registerAsyncHelper` by default. You will not need - to `return app.testHelpers.wait();` - the wait behavior is provided for you. + `run.bind` takes two main arguments, the desired context and the function to + invoke in that context. Any additional arguments will be supplied as arguments + to the function that is passed in. - Example: + Let's use the creation of a TinyMCE component as an example. Currently, + TinyMCE provides a setup configuration option we can use to do some processing + after the TinyMCE instance is initialized but before it is actually rendered. + We can use that setup option to do some additional setup for our component. + The component itself could look something like the following: ```javascript - Ember.Test.registerAsyncHelper('loginUser', function(app, username, password) { - visit('secured/path/here') - .fillIn('#username', username) - .fillIn('#password', password) - .click('.submit'); + App.RichTextEditorComponent = Ember.Component.extend({ + initializeTinyMCE: Ember.on('didInsertElement', function() { + tinymce.init({ + selector: '#' + this.$().prop('id'), + setup: Ember.run.bind(this, this.setupEditor) + }); + }), + + setupEditor: function(editor) { + this.set('editor', editor); + + editor.on('change', function() { + console.log('content changed!'); + }); + } }); + ``` - @method wait - @param {Object} value The value to be returned. - @return {RSVP.Promise} + In this example, we use Ember.run.bind to bind the setupEditor method to the + context of the App.RichTextEditorComponent and to have the invocation of that + method be safely handled and executed by the Ember run loop. + + @method bind + @namespace Ember + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Function} returns a new function that will always have a particular context + @since 1.4.0 @public */ + run.bind = function () { + for (var _len = arguments.length, curried = Array(_len), _key = 0; _key < _len; _key++) { + curried[_key] = arguments[_key]; + } - function wait(app, value) { - return new _emberRuntime.RSVP.Promise(function (resolve) { - var router = app.__container__.lookup('router:main'); + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - // Every 10ms, poll for the async thing to have finished - var watcher = setInterval(function () { - // 1. If the router is loading, keep polling - var routerIsLoading = router.router && !!router.router.activeTransition; - if (routerIsLoading) { - return; - } + return run.join.apply(run, curried.concat(args)); + }; + }; - // 2. If there are pending Ajax requests, keep polling - if (_emberTestingTestPending_requests.pendingRequests()) { - return; - } + run.backburner = backburner; + run.currentRunLoop = null; + run.queues = backburner.queueNames; - // 3. If there are scheduled timers or we are inside of a run loop, keep polling - if (_emberMetal.run.hasScheduledTimers() || _emberMetal.run.currentRunLoop) { - return; - } + /** + Begins a new RunLoop. Any deferred actions invoked after the begin will + be buffered until you invoke a matching call to `run.end()`. This is + a lower-level way to use a RunLoop instead of using `run()`. + + ```javascript + run.begin(); + // code to be executed within a RunLoop + run.end(); + ``` + + @method begin + @return {void} + @public + */ + run.begin = function () { + backburner.begin(); + }; - if (_emberTestingTestWaiters.checkWaiters()) { - return; - } + /** + Ends a RunLoop. This must be called sometime after you call + `run.begin()` to flush any deferred actions. This is a lower-level way + to use a RunLoop instead of using `run()`. + + ```javascript + run.begin(); + // code to be executed within a RunLoop + run.end(); + ``` + + @method end + @return {void} + @public + */ + run.end = function () { + backburner.end(); + }; - // Stop polling - clearInterval(watcher); + /** + Array of named queues. This array determines the order in which queues + are flushed at the end of the RunLoop. You can define your own queues by + simply adding the queue name to this array. Normally you should not need + to inspect or modify this property. + + @property queues + @type Array + @default ['sync', 'actions', 'destroy'] + @private + */ - // Synchronously resolve the promise - _emberMetal.run(null, resolve, value); - }, 10); + /** + Adds the passed target/method and any optional arguments to the named + queue to be executed at the end of the RunLoop. If you have not already + started a RunLoop when calling this method one will be started for you + automatically. + + At the end of a RunLoop, any methods scheduled in this way will be invoked. + Methods will be invoked in an order matching the named queues defined in + the `run.queues` property. + + ```javascript + run.schedule('sync', this, function() { + // this will be executed in the first RunLoop queue, when bindings are synced + console.log('scheduled on sync queue'); }); - } -}); -enifed('ember-testing/index', ['exports', 'ember-testing/support', 'ember-testing/ext/application', 'ember-testing/ext/rsvp', 'ember-testing/helpers', 'ember-testing/initializers', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/setup_for_testing', 'ember-testing/adapters/qunit'], function (exports, _emberTestingSupport, _emberTestingExtApplication, _emberTestingExtRsvp, _emberTestingHelpers, _emberTestingInitializers, _emberTestingTest, _emberTestingAdaptersAdapter, _emberTestingSetup_for_testing, _emberTestingAdaptersQunit) { - 'use strict'; - - exports.Test = _emberTestingTest.default; - exports.Adapter = _emberTestingAdaptersAdapter.default; - exports.setupForTesting = _emberTestingSetup_for_testing.default; - exports.QUnitAdapter = _emberTestingAdaptersQunit.default; -}); -// to handle various edge cases -// setup RSVP + run loop integration -// adds helpers to helpers object in Test -// to setup initializer - -/** - @module ember - @submodule ember-testing -*/ -enifed('ember-testing/initializers', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { - 'use strict'; - - var name = 'deferReadiness in `testing` mode'; - - _emberRuntime.onLoad('Ember.Application', function (Application) { - if (!Application.initializers[name]) { - Application.initializer({ - name: name, + + run.schedule('actions', this, function() { + // this will be executed in the 'actions' queue, after bindings have synced. + console.log('scheduled on actions queue'); + }); + + // Note the functions will be run in order based on the run queues order. + // Output would be: + // scheduled on sync queue + // scheduled on actions queue + ``` + + @method schedule + @param {String} queue The name of the queue to schedule against. + Default queues are 'sync' and 'actions' + @param {Object} [target] target object to use as the context when invoking a method. + @param {String|Function} method The method to invoke. If you pass a string it + will be resolved on the target object at the time the scheduled item is + invoked allowing you to change the target function. + @param {Object} [arguments*] Optional arguments to be passed to the queued method. + @return {*} Timer information for use in cancelling, see `run.cancel`. + @public + */ + run.schedule = function () /* queue, target, method */{ + _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - initialize: function (application) { - if (application.testing) { - application.deferReadiness(); - } - } - }); - } - }); -}); -enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit) { - /* global self */ + return backburner.schedule.apply(backburner, arguments); + }; - 'use strict'; + // Used by global test teardown + run.hasScheduledTimers = function () { + return backburner.hasTimers(); + }; - exports.default = setupForTesting; + // Used by global test teardown + run.cancelTimers = function () { + backburner.cancelTimers(); + }; /** - Sets Ember up for testing. This is useful to perform - basic setup steps in order to unit test. + Immediately flushes any events scheduled in the 'sync' queue. Bindings + use this queue so this method is a useful way to immediately force all + bindings in the application to sync. - Use `App.setupForTesting` to perform integration tests (full - application testing). + You should call this method anytime you need any changed state to propagate + throughout the app immediately without repainting the UI (which happens + in the later 'render' queue added by the `ember-views` package). - @method setupForTesting - @namespace Ember - @since 1.5.0 + ```javascript + run.sync(); + ``` + + @method sync + @return {void} @private */ - - function setupForTesting() { - _emberMetal.setTesting(true); - - var adapter = _emberTestingTestAdapter.getAdapter(); - // if adapter is not manually set default to QUnit - if (!adapter) { - _emberTestingTestAdapter.setAdapter(typeof self.QUnit === 'undefined' ? new _emberTestingAdaptersAdapter.default() : new _emberTestingAdaptersQunit.default()); + run.sync = function () { + if (backburner.currentInstance) { + backburner.currentInstance.queues.sync.flush(); } - - _emberViews.jQuery(document).off('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); - _emberViews.jQuery(document).off('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); - - _emberTestingTestPending_requests.clearPendingRequests(); - - _emberViews.jQuery(document).on('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); - _emberViews.jQuery(document).on('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); - } -}); -enifed('ember-testing/support', ['exports', 'ember-metal', 'ember-views', 'ember-environment'], function (exports, _emberMetal, _emberViews, _emberEnvironment) { - 'use strict'; + }; /** - @module ember - @submodule ember-testing + Invokes the passed target/method and optional arguments after a specified + period of time. The last parameter of this method must always be a number + of milliseconds. + + You should use this method whenever you need to run some action after a + period of time instead of using `setTimeout()`. This method will ensure that + items that expire during the same script execution cycle all execute + together, which is often more efficient than using a real setTimeout. + + ```javascript + run.later(myContext, function() { + // code here will execute within a RunLoop in about 500ms with this == myContext + }, 500); + ``` + + @method later + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} wait Number of milliseconds to wait. + @return {*} Timer information for use in cancelling, see `run.cancel`. + @public */ - - var $ = _emberViews.jQuery; + run.later = function () /*target, method*/{ + return backburner.later.apply(backburner, arguments); + }; /** - This method creates a checkbox and triggers the click event to fire the - passed in handler. It is used to correct for a bug in older versions - of jQuery (e.g 1.8.3). + Schedule a function to run one time during the current RunLoop. This is equivalent + to calling `scheduleOnce` with the "actions" queue. - @private - @method testCheckboxClick + @method once + @param {Object} [target] The target of the method to invoke. + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. + @public */ - function testCheckboxClick(handler) { - var input = document.createElement('input'); - $(input).attr('type', 'checkbox').css({ position: 'absolute', left: '-1000px', top: '-1000px' }).appendTo('body').on('click', handler).trigger('click').remove(); - } + run.once = function () { + _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); - if (_emberEnvironment.environment.hasDOM && typeof $ === 'function') { - $(function () { - /* - Determine whether a checkbox checked using jQuery's "click" method will have - the correct value for its checked property. - If we determine that the current jQuery version exhibits this behavior, - patch it to work correctly as in the commit for the actual fix: - https://github.com/jquery/jquery/commit/1fb2f92. - */ - testCheckboxClick(function () { - if (!this.checked && !$.event.special.click) { - $.event.special.click = { - // For checkbox, fire native event so checked state will be right - trigger: function () { - if ($.nodeName(this, 'input') && this.type === 'checkbox' && this.click) { - this.click(); - return false; - } - } - }; - } - }); + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } - // Try again to verify that the patch took effect or blow up. - testCheckboxClick(function () { - _emberMetal.warn('clicked checkboxes should be checked! the jQuery patch didn\'t work', this.checked, { id: 'ember-testing.test-checkbox-click' }); - }); - }); - } -}); -enifed('ember-testing/test', ['exports', 'ember-testing/test/helpers', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/promise', 'ember-testing/test/waiters', 'ember-testing/test/adapter', 'ember-metal'], function (exports, _emberTestingTestHelpers, _emberTestingTestOn_inject_helpers, _emberTestingTestPromise, _emberTestingTestWaiters, _emberTestingTestAdapter, _emberMetal) { - /** - @module ember - @submodule ember-testing - */ - 'use strict'; + args.unshift('actions'); + return backburner.scheduleOnce.apply(backburner, args); + }; /** - This is a container for an assortment of testing related functionality: + Schedules a function to run one time in a given queue of the current RunLoop. + Calling this method with the same queue/target/method combination will have + no effect (past the initial call). + + Note that although you can pass optional arguments these will not be + considered when looking for duplicates. New arguments will replace previous + calls. + + ```javascript + function sayHi() { + console.log('hi'); + } + + run(function() { + run.scheduleOnce('afterRender', myContext, sayHi); + run.scheduleOnce('afterRender', myContext, sayHi); + // sayHi will only be executed once, in the afterRender queue of the RunLoop + }); + ``` + + Also note that passing an anonymous function to `run.scheduleOnce` will + not prevent additional calls with an identical anonymous function from + scheduling the items multiple times, e.g.: + + ```javascript + function scheduleIt() { + run.scheduleOnce('actions', myContext, function() { + console.log('Closure'); + }); + } + + scheduleIt(); + scheduleIt(); - * Choose your default test adapter (for your framework of choice). - * Register/Unregister additional test helpers. - * Setup callbacks to be fired when the test helpers are injected into - your application. + // "Closure" will print twice, even though we're using `run.scheduleOnce`, + // because the function we pass to it is anonymous and won't match the + // previously scheduled operation. + ``` - @class Test - @namespace Ember + Available queues, and their order, can be found at `run.queues` + + @method scheduleOnce + @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'. + @param {Object} [target] The target of the method to invoke. + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. @public */ - var Test = { - /** - Hash containing all known test helpers. - @property _helpers - @private - @since 1.7.0 - */ - _helpers: _emberTestingTestHelpers.helpers, - - registerHelper: _emberTestingTestHelpers.registerHelper, - registerAsyncHelper: _emberTestingTestHelpers.registerAsyncHelper, - unregisterHelper: _emberTestingTestHelpers.unregisterHelper, - onInjectHelpers: _emberTestingTestOn_inject_helpers.onInjectHelpers, - Promise: _emberTestingTestPromise.default, - promise: _emberTestingTestPromise.promise, - resolve: _emberTestingTestPromise.resolve, - registerWaiter: _emberTestingTestWaiters.registerWaiter, - unregisterWaiter: _emberTestingTestWaiters.unregisterWaiter + run.scheduleOnce = function () /*queue, target, method*/{ + _emberMetalDebug.assert('You have turned on testing mode, which disabled the run-loop\'s autorun. ' + 'You will need to wrap any code with asynchronous side-effects in a run', run.currentRunLoop || !_emberMetalTesting.isTesting()); + return backburner.scheduleOnce.apply(backburner, arguments); }; - if (true) { - Test.checkWaiters = _emberTestingTestWaiters.checkWaiters; - } - /** - Used to allow ember-testing to communicate with a specific testing - framework. + Schedules an item to run from within a separate run loop, after + control has been returned to the system. This is equivalent to calling + `run.later` with a wait time of 1ms. - You can manually set it before calling `App.setupForTesting()`. + ```javascript + run.next(myContext, function() { + // code to be executed in the next run loop, + // which will be scheduled after the current one + }); + ``` - Example: + Multiple operations scheduled with `run.next` will coalesce + into the same later run loop, along with any other operations + scheduled by `run.later` that expire right around the same + time that `run.next` operations will fire. - ```javascript - Ember.Test.adapter = MyCustomAdapter.create() - ``` + Note that there are often alternatives to using `run.next`. + For instance, if you'd like to schedule an operation to happen + after all DOM element operations have completed within the current + run loop, you can make use of the `afterRender` run loop queue (added + by the `ember-views` package, along with the preceding `render` queue + where all the DOM element operations happen). - If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`. + Example: - @public - @for Ember.Test - @property adapter - @type {Class} The adapter to be used. - @default Ember.Test.QUnitAdapter + ```javascript + export default Ember.Component.extend({ + didInsertElement() { + this._super(...arguments); + run.scheduleOnce('afterRender', this, 'processChildElements'); + }, + + processChildElements() { + // ... do something with component's child component + // elements after they've finished rendering, which + // can't be done within this component's + // `didInsertElement` hook because that gets run + // before the child elements have been added to the DOM. + } + }); + ``` + + One benefit of the above approach compared to using `run.next` is + that you will be able to perform DOM/CSS operations before unprocessed + elements are rendered to the screen, which may prevent flickering or + other artifacts caused by delaying processing until after rendering. + + The other major benefit to the above approach is that `run.next` + introduces an element of non-determinism, which can make things much + harder to test, due to its reliance on `setTimeout`; it's much harder + to guarantee the order of scheduled operations when they are scheduled + outside of the current run loop, i.e. with `run.next`. + + @method next + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. + @public */ - Object.defineProperty(Test, 'adapter', { - get: _emberTestingTestAdapter.getAdapter, - set: _emberTestingTestAdapter.setAdapter - }); - - Object.defineProperty(Test, 'waiters', { - get: _emberTestingTestWaiters.generateDeprecatedWaitersArray - }); - - exports.default = Test; -}); -enifed('ember-testing/test/adapter', ['exports', 'ember-console', 'ember-metal'], function (exports, _emberConsole, _emberMetal) { - 'use strict'; - - exports.getAdapter = getAdapter; - exports.setAdapter = setAdapter; - exports.asyncStart = asyncStart; - exports.asyncEnd = asyncEnd; - - var adapter = undefined; - - function getAdapter() { - return adapter; - } - - function setAdapter(value) { - adapter = value; - if (value) { - _emberMetal.setDispatchOverride(adapterDispatch); - } else { - _emberMetal.setDispatchOverride(null); - } - } - - function asyncStart() { - if (adapter) { - adapter.asyncStart(); - } - } - - function asyncEnd() { - if (adapter) { - adapter.asyncEnd(); + run.next = function () { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; } - } - - function adapterDispatch(error) { - adapter.exception(error); - _emberConsole.default.error(error.stack); - } -}); -enifed('ember-testing/test/helpers', ['exports', 'ember-testing/test/promise'], function (exports, _emberTestingTestPromise) { - 'use strict'; - exports.registerHelper = registerHelper; - exports.registerAsyncHelper = registerAsyncHelper; - exports.unregisterHelper = unregisterHelper; - var helpers = {}; + args.push(1); + return backburner.later.apply(backburner, args); + }; - exports.helpers = helpers; /** - `registerHelper` is used to register a test helper that will be injected - when `App.injectTestHelpers` is called. + Cancels a scheduled item. Must be a value returned by `run.later()`, + `run.once()`, `run.scheduleOnce()`, `run.next()`, `run.debounce()`, or + `run.throttle()`. - The helper method will always be called with the current Application as - the first parameter. + ```javascript + let runNext = run.next(myContext, function() { + // will not be executed + }); - For example: + run.cancel(runNext); - ```javascript - Ember.Test.registerHelper('boot', function(app) { - Ember.run(app, app.advanceReadiness); + let runLater = run.later(myContext, function() { + // will not be executed + }, 500); + + run.cancel(runLater); + + let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { + // will not be executed }); - ``` - This helper can later be called without arguments because it will be - called with `app` as the first parameter. + run.cancel(runScheduleOnce); - ```javascript - App = Ember.Application.create(); - App.injectTestHelpers(); - boot(); + let runOnce = run.once(myContext, function() { + // will not be executed + }); + + run.cancel(runOnce); + + let throttle = run.throttle(myContext, function() { + // will not be executed + }, 1, false); + + run.cancel(throttle); + + let debounce = run.debounce(myContext, function() { + // will not be executed + }, 1); + + run.cancel(debounce); + + let debounceImmediate = run.debounce(myContext, function() { + // will be executed since we passed in true (immediate) + }, 100, true); + + // the 100ms delay until this method can be called again will be cancelled + run.cancel(debounceImmediate); ``` + @method cancel + @param {Object} timer Timer object to cancel + @return {Boolean} true if cancelled or false/undefined if it wasn't found @public - @for Ember.Test - @method registerHelper - @param {String} name The name of the helper method to add. - @param {Function} helperMethod - @param options {Object} */ - - function registerHelper(name, helperMethod) { - helpers[name] = { - method: helperMethod, - meta: { wait: false } - }; - } + run.cancel = function (timer) { + return backburner.cancel(timer); + }; /** - `registerAsyncHelper` is used to register an async test helper that will be injected - when `App.injectTestHelpers` is called. - - The helper method will always be called with the current Application as - the first parameter. + Delay calling the target method until the debounce period has elapsed + with no additional debounce calls. If `debounce` is called again before + the specified time has elapsed, the timer is reset and the entire period + must pass again before the target method is called. - For example: + This method should be used when an event may be called multiple times + but the action should only be called once when the event is done firing. + A common example is for scroll events where you only want updates to + happen once scrolling has ceased. ```javascript - Ember.Test.registerAsyncHelper('boot', function(app) { - Ember.run(app, app.advanceReadiness); - }); - ``` + function whoRan() { + console.log(this.name + ' ran.'); + } - The advantage of an async helper is that it will not run - until the last async helper has completed. All async helpers - after it will wait for it complete before running. + let myContext = { name: 'debounce' }; + run.debounce(myContext, whoRan, 150); - For example: + // less than 150ms passes + run.debounce(myContext, whoRan, 150); + + // 150ms passes + // whoRan is invoked with context myContext + // console logs 'debounce ran.' one time. + ``` + + Immediate allows you to run the function immediately, but debounce + other calls for this function until the wait time has elapsed. If + `debounce` is called again before the specified time has elapsed, + the timer is reset and the entire period must pass again before + the method can be called again. ```javascript - Ember.Test.registerAsyncHelper('deletePost', function(app, postId) { - click('.delete-' + postId); - }); + function whoRan() { + console.log(this.name + ' ran.'); + } + + let myContext = { name: 'debounce' }; + + run.debounce(myContext, whoRan, 150, true); + + // console logs 'debounce ran.' one time immediately. + // 100ms passes + run.debounce(myContext, whoRan, 150, true); + + // 150ms passes and nothing else is logged to the console and + // the debouncee is no longer being watched + run.debounce(myContext, whoRan, 150, true); + + // console logs 'debounce ran.' one time immediately. + // 150ms passes and nothing else is logged to the console and + // the debouncee is no longer being watched - // ... in your test - visit('/post/2'); - deletePost(2); - visit('/post/3'); - deletePost(3); ``` + @method debounce + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} wait Number of milliseconds to wait. + @param {Boolean} immediate Trigger the function on the leading instead + of the trailing edge of the wait interval. Defaults to false. + @return {Array} Timer information for use in cancelling, see `run.cancel`. @public - @for Ember.Test - @method registerAsyncHelper - @param {String} name The name of the helper method to add. - @param {Function} helperMethod - @since 1.2.0 */ - - function registerAsyncHelper(name, helperMethod) { - helpers[name] = { - method: helperMethod, - meta: { wait: true } - }; - } + run.debounce = function () { + return backburner.debounce.apply(backburner, arguments); + }; /** - Remove a previously added helper method. - - Example: + Ensure that the target method is never called more frequently than + the specified spacing period. The target method is called immediately. ```javascript - Ember.Test.unregisterHelper('wait'); + function whoRan() { + console.log(this.name + ' ran.'); + } + + let myContext = { name: 'throttle' }; + + run.throttle(myContext, whoRan, 150); + // whoRan is invoked with context myContext + // console logs 'throttle ran.' + + // 50ms passes + run.throttle(myContext, whoRan, 150); + + // 50ms passes + run.throttle(myContext, whoRan, 150); + + // 150ms passes + run.throttle(myContext, whoRan, 150); + // whoRan is invoked with context myContext + // console logs 'throttle ran.' ``` + @method throttle + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} spacing Number of milliseconds to space out requests. + @param {Boolean} immediate Trigger the function on the leading instead + of the trailing edge of the wait interval. Defaults to true. + @return {Array} Timer information for use in cancelling, see `run.cancel`. @public - @method unregisterHelper - @param {String} name The helper to remove. */ + run.throttle = function () { + return backburner.throttle.apply(backburner, arguments); + }; - function unregisterHelper(name) { - delete helpers[name]; - delete _emberTestingTestPromise.default.prototype[name]; - } + /** + Add a new named queue after the specified queue. + + The queue to add will only be added once. + + @method _addQueue + @param {String} name the name of the queue to add. + @param {String} after the name of the queue to add after. + @private + */ + run._addQueue = function (name, after) { + if (run.queues.indexOf(name) === -1) { + run.queues.splice(run.queues.indexOf(after) + 1, 0, name); + } + }; }); -enifed("ember-testing/test/on_inject_helpers", ["exports"], function (exports) { - "use strict"; +enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set'], function (exports, _emberMetalProperty_events, _emberMetalProperty_set) { + 'use strict'; - exports.onInjectHelpers = onInjectHelpers; - exports.invokeInjectHelpersCallbacks = invokeInjectHelpersCallbacks; - var callbacks = []; + exports.default = setProperties; - exports.callbacks = callbacks; /** - Used to register callbacks to be fired whenever `App.injectTestHelpers` - is called. - - The callback will receive the current application as an argument. - - Example: + Set a list of properties on an object. These properties are set inside + a single `beginPropertyChanges` and `endPropertyChanges` batch, so + observers will be buffered. ```javascript - Ember.Test.onInjectHelpers(function() { - Ember.$(document).ajaxSend(function() { - Test.pendingRequests++; - }); + let anObject = Ember.Object.create(); - Ember.$(document).ajaxComplete(function() { - Test.pendingRequests--; - }); + anObject.setProperties({ + firstName: 'Stanley', + lastName: 'Stuart', + age: 21 }); ``` + @method setProperties + @param obj + @param {Object} properties + @return properties @public - @for Ember.Test - @method onInjectHelpers - @param {Function} callback The function to be called. */ - function onInjectHelpers(callback) { - callbacks.push(callback); - } + function setProperties(obj, properties) { + if (!properties || typeof properties !== 'object') { + return properties; + } + _emberMetalProperty_events.changeProperties(function () { + var props = Object.keys(properties); + var propertyName = undefined; + + for (var i = 0; i < props.length; i++) { + propertyName = props[i]; + + _emberMetalProperty_set.set(obj, propertyName, properties[propertyName]); + } + }); + return properties; + } +}); +enifed('ember-metal/tags', ['exports', '@glimmer/reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { + 'use strict'; + + exports.setHasViews = setHasViews; + exports.tagForProperty = tagForProperty; + exports.tagFor = tagFor; + exports.markObjectAsDirty = markObjectAsDirty; + + var hasViews = function () { + return false; + }; + + function setHasViews(fn) { + hasViews = fn; + } + + function makeTag() { + return new _glimmerReference.DirtyableTag(); + } + + function tagForProperty(object, propertyKey, _meta) { + if (_emberMetalIs_proxy.isProxy(object)) { + return tagFor(object, _meta); + } + + if (typeof object === 'object' && object) { + var meta = _meta || _emberMetalMeta.meta(object); + var tags = meta.writableTags(); + var tag = tags[propertyKey]; + if (tag) { + return tag; + } + + return tags[propertyKey] = makeTag(); + } else { + return _glimmerReference.CONSTANT_TAG; + } + } + + function tagFor(object, _meta) { + if (typeof object === 'object' && object) { + var meta = _meta || _emberMetalMeta.meta(object); + return meta.writableTag(makeTag); + } else { + return _glimmerReference.CONSTANT_TAG; + } + } + + function markObjectAsDirty(meta, propertyKey) { + var objectTag = meta && meta.readableTag(); + + if (objectTag) { + objectTag.dirty(); + } + + var tags = meta && meta.readableTags(); + var propertyTag = tags && tags[propertyKey]; + + if (propertyTag) { + propertyTag.dirty(); + } - function invokeInjectHelpersCallbacks(app) { - for (var i = 0; i < callbacks.length; i++) { - callbacks[i](app); + if (objectTag || propertyTag) { + ensureRunloop(); } } -}); -enifed("ember-testing/test/pending_requests", ["exports"], function (exports) { - "use strict"; - exports.pendingRequests = pendingRequests; - exports.clearPendingRequests = clearPendingRequests; - exports.incrementPendingRequests = incrementPendingRequests; - exports.decrementPendingRequests = decrementPendingRequests; - var requests = []; + var run = undefined; - function pendingRequests() { - return requests.length; - } + function K() {} - function clearPendingRequests() { - requests.length = 0; + function ensureRunloop() { + if (!run) { + run = _require.default('ember-metal/run_loop').default; + } + + if (hasViews() && !run.backburner.currentInstance) { + run.schedule('actions', K); + } } +}); +enifed("ember-metal/testing", ["exports"], function (exports) { + "use strict"; - function incrementPendingRequests(_, xhr) { - requests.push(xhr); + exports.isTesting = isTesting; + exports.setTesting = setTesting; + var testing = false; + + function isTesting() { + return testing; } - function decrementPendingRequests(_, xhr) { - for (var i = 0; i < requests.length; i++) { - if (xhr === requests[i]) { - requests.splice(i, 1); - break; - } - } + function setTesting(value) { + testing = !!value; } }); -enifed('ember-testing/test/promise', ['exports', 'ember-runtime', 'ember-testing/test/run'], function (exports, _emberRuntime, _emberTestingTestRun) { +enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) { 'use strict'; - exports.promise = promise; - exports.resolve = resolve; - exports.getLastPromise = getLastPromise; - - var lastPromise = undefined; + var runInTransaction = undefined, + didRender = undefined, + assertNotRendered = undefined; - var TestPromise = (function (_RSVP$Promise) { - babelHelpers.inherits(TestPromise, _RSVP$Promise); + // detect-backtracking-rerender by default is debug build only + // detect-glimmer-allow-backtracking-rerender can be enabled in custom builds + if (true || false) { + (function () { + var counter = 0; + var inTransaction = false; + var shouldReflush = undefined; + var debugStack = undefined; - function TestPromise() { - babelHelpers.classCallCheck(this, TestPromise); + exports.default = runInTransaction = function (context, methodName) { + shouldReflush = false; + inTransaction = true; + _emberMetalDebug.runInDebug(function () { + debugStack = context.env.debugStack; + }); + context[methodName](); + inTransaction = false; + counter++; + return shouldReflush; + }; - _RSVP$Promise.apply(this, arguments); - lastPromise = this; - } + exports.didRender = didRender = function (object, key, reference) { + if (!inTransaction) { + return; + } + var meta = _emberMetalMeta.meta(object); + var lastRendered = meta.writableLastRendered(); + lastRendered[key] = counter; - /** - This returns a thenable tailored for testing. It catches failed - `onSuccess` callbacks and invokes the `Ember.Test.adapter.exception` - callback in the last chained then. - - This method should be returned by async helpers such as `wait`. - - @public - @for Ember.Test - @method promise - @param {Function} resolver The function used to resolve the promise. - @param {String} label An optional string for identifying the promise. - */ + _emberMetalDebug.runInDebug(function () { + var referenceMap = meta.writableLastRenderedReferenceMap(); + referenceMap[key] = reference; - TestPromise.prototype.then = function then(onFulfillment) { - var _RSVP$Promise$prototype$then; + var templateMap = meta.writableLastRenderedTemplateMap(); + if (templateMap[key] === undefined) { + templateMap[key] = debugStack.peek(); + } + }); + }; - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } + exports.assertNotRendered = assertNotRendered = function (object, key, _meta) { + var meta = _meta || _emberMetalMeta.meta(object); + var lastRendered = meta.readableLastRendered(); - return (_RSVP$Promise$prototype$then = _RSVP$Promise.prototype.then).call.apply(_RSVP$Promise$prototype$then, [this, function (result) { - return isolate(onFulfillment, result); - }].concat(args)); - }; + if (lastRendered && lastRendered[key] === counter) { + _emberMetalDebug.runInDebug(function () { + var templateMap = meta.readableLastRenderedTemplateMap(); + var lastRenderedIn = templateMap[key]; + var currentlyIn = debugStack.peek(); - return TestPromise; - })(_emberRuntime.RSVP.Promise); + var referenceMap = meta.readableLastRenderedReferenceMap(); + var lastRef = referenceMap[key]; + var parts = []; + var label = undefined; - exports.default = TestPromise; + if (lastRef) { + while (lastRef && lastRef._propertyKey) { + parts.unshift(lastRef._propertyKey); + lastRef = lastRef._parentReference; + } - function promise(resolver, label) { - var fullLabel = 'Ember.Test.promise: ' + (label || ''); - return new TestPromise(resolver, fullLabel); - } + label = parts.join('.'); + } else { + label = 'the same value'; + } - /** - Replacement for `Ember.RSVP.resolve` - The only difference is this uses - an instance of `Ember.Test.Promise` - - @public - @for Ember.Test - @method resolve - @param {Mixed} The value to resolve - @since 1.2.0 - */ + var message = 'You modified "' + label + '" twice on ' + object + ' in a single render. It was rendered in ' + lastRenderedIn + ' and modified in ' + currentlyIn + '. This was unreliable and slow in Ember 1.x and'; - function resolve(result, label) { - return TestPromise.resolve(result, label); - } + if (false) { + _emberMetalDebug.deprecate(message + ' will be removed in Ember 3.0.', false, { id: 'ember-views.render-double-modify', until: '3.0.0' }); + } else { + _emberMetalDebug.assert(message + ' is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.', false); + } + }); - function getLastPromise() { - return lastPromise; + shouldReflush = true; + } + }; + })(); + } else { + // in production do nothing to detect reflushes + exports.default = runInTransaction = function (context, methodName) { + context[methodName](); + return false; + }; } - // This method isolates nested async methods - // so that they don't conflict with other last promises. - // - // 1. Set `Ember.Test.lastPromise` to null - // 2. Invoke method - // 3. Return the last promise created during method - function isolate(onFulfillment, result) { - // Reset lastPromise for nested helpers - lastPromise = null; + exports.default = runInTransaction; + exports.didRender = didRender; + exports.assertNotRendered = assertNotRendered; +}); +enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) { + 'use strict'; - var value = onFulfillment(result); + exports.watchKey = watchKey; + exports.unwatchKey = unwatchKey; - var promise = lastPromise; - lastPromise = null; + var handleMandatorySetter = undefined; - // If the method returned a promise - // return that promise. If not, - // return the last async helper's promise - if (value && value instanceof TestPromise || !promise) { - return value; - } else { - return _emberTestingTestRun.default(function () { - return resolve(promise).then(function () { - return value; - }); - }); + function watchKey(obj, keyName, meta) { + if (typeof obj !== 'object' || obj === null) { + return; } - } -}); -enifed('ember-testing/test/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + var m = meta || _emberMetalMeta.meta(obj); - exports.default = run; + // activate watching first time + if (!m.peekWatching(keyName)) { + m.writeWatching(keyName, 1); - function run(fn) { - if (!_emberMetal.run.currentRunLoop) { - return _emberMetal.run(fn); + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + if (desc && desc.willWatch) { + desc.willWatch(obj, keyName); + } + + if ('function' === typeof obj.willWatchProperty) { + obj.willWatchProperty(keyName); + } + + if (true) { + // NOTE: this is dropped for prod + minified builds + handleMandatorySetter(m, obj, keyName); + } } else { - return fn(); + m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1); } } -}); -enifed('ember-testing/test/waiters', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - exports.registerWaiter = registerWaiter; - exports.unregisterWaiter = unregisterWaiter; - exports.checkWaiters = checkWaiters; - exports.generateDeprecatedWaitersArray = generateDeprecatedWaitersArray; + if (true) { + (function () { + var hasOwnProperty = function (obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + }; - var contexts = []; - var callbacks = []; + var propertyIsEnumerable = function (obj, key) { + return Object.prototype.propertyIsEnumerable.call(obj, key); + }; - /** - This allows ember-testing to play nicely with other asynchronous - events, such as an application that is waiting for a CSS3 - transition or an IndexDB transaction. The waiter runs periodically - after each async helper (i.e. `click`, `andThen`, `visit`, etc) has executed, - until the returning result is truthy. After the waiters finish, the next async helper - is executed and the process repeats. - - For example: - - ```javascript - Ember.Test.registerWaiter(function() { - return myPendingTransactions() == 0; - }); - ``` - The `context` argument allows you to optionally specify the `this` - with which your callback will be invoked. - - For example: - - ```javascript - Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions); - ``` - - @public - @for Ember.Test - @method registerWaiter - @param {Object} context (optional) - @param {Function} callback - @since 1.2.0 - */ + // Future traveler, although this code looks scary. It merely exists in + // development to aid in development asertions. Production builds of + // ember strip this entire block out + handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { + var descriptor = _emberUtils.lookupDescriptor(obj, keyName); + var configurable = descriptor ? descriptor.configurable : true; + var isWritable = descriptor ? descriptor.writable : true; + var hasValue = descriptor ? 'value' in descriptor : true; + var possibleDesc = descriptor && descriptor.value; + var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; - function registerWaiter(context, callback) { - if (arguments.length === 1) { - callback = context; - context = null; - } - if (indexOf(context, callback) > -1) { - return; - } - contexts.push(context); - callbacks.push(callback); - } + if (isDescriptor) { + return; + } - /** - `unregisterWaiter` is used to unregister a callback that was - registered with `registerWaiter`. - - @public - @for Ember.Test - @method unregisterWaiter - @param {Object} context (optional) - @param {Function} callback - @since 1.2.0 - */ + // this x in Y deopts, so keeping it in this function is better; + if (configurable && isWritable && hasValue && keyName in obj) { + var desc = { + configurable: true, + set: _emberMetalProperties.MANDATORY_SETTER_FUNCTION(keyName), + enumerable: propertyIsEnumerable(obj, keyName), + get: undefined + }; - function unregisterWaiter(context, callback) { - if (!callbacks.length) { + if (hasOwnProperty(obj, keyName)) { + m.writeValues(keyName, obj[keyName]); + desc.get = _emberMetalProperties.DEFAULT_GETTER_FUNCTION(keyName); + } else { + desc.get = _emberMetalProperties.INHERITING_GETTER_FUNCTION(keyName); + } + + Object.defineProperty(obj, keyName, desc); + } + }; + })(); + } + + function unwatchKey(obj, keyName, _meta) { + if (typeof obj !== 'object' || obj === null) { return; } - if (arguments.length === 1) { - callback = context; - context = null; - } - var i = indexOf(context, callback); - if (i === -1) { + var meta = _meta || _emberMetalMeta.meta(obj); + + // do nothing of this object has already been destroyed + if (meta.isSourceDestroyed()) { return; } - contexts.splice(i, 1); - callbacks.splice(i, 1); - } - /** - Iterates through each registered test waiter, and invokes - its callback. If any waiter returns false, this method will return - true indicating that the waiters have not settled yet. - - This is generally used internally from the acceptance/integration test - infrastructure. - - @public - @for Ember.Test - @static - @method checkWaiters - */ + var count = meta.peekWatching(keyName); + if (count === 1) { + meta.writeWatching(keyName, 0); - function checkWaiters() { - if (!callbacks.length) { - return false; - } - for (var i = 0; i < callbacks.length; i++) { - var context = contexts[i]; - var callback = callbacks[i]; - if (!callback.call(context)) { - return true; - } - } - return false; - } + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - function indexOf(context, callback) { - for (var i = 0; i < callbacks.length; i++) { - if (callbacks[i] === callback && contexts[i] === context) { - return i; + if (desc && desc.didUnwatch) { + desc.didUnwatch(obj, keyName); } - } - return -1; - } - - function generateDeprecatedWaitersArray() { - _emberMetal.deprecate('Usage of `Ember.Test.waiters` is deprecated. Please refactor to `Ember.Test.checkWaiters`.', !true, { until: '2.8.0', id: 'ember-testing.test-waiters' }); - - var array = new Array(callbacks.length); - for (var i = 0; i < callbacks.length; i++) { - var context = contexts[i]; - var callback = callbacks[i]; - array[i] = [context, callback]; - } + if ('function' === typeof obj.didUnwatchProperty) { + obj.didUnwatchProperty(keyName); + } - return array; - } -}); -enifed("ember-utils/apply-str", ["exports"], function (exports) { - /** - @param {Object} t target - @param {String} m method - @param {Array} a args - @private - */ - "use strict"; + if (true) { + // It is true, the following code looks quite WAT. But have no fear, It + // exists purely to improve development ergonomics and is removed from + // ember.min.js and ember.prod.js builds. + // + // Some further context: Once a property is watched by ember, bypassing `set` + // for mutation, will bypass observation. This code exists to assert when + // that occurs, and attempt to provide more helpful feedback. The alternative + // is tricky to debug partially observable properties. + if (!desc && keyName in obj) { + var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName); - exports.default = applyStr; + if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { + if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { + var possibleValue = meta.readInheritedValue('values', keyName); + if (possibleValue === _emberMetalMeta.UNDEFINED) { + delete obj[keyName]; + return; + } + } - function applyStr(t, m, a) { - var l = a && a.length; - if (!a || !l) { - return t[m](); - } - switch (l) { - case 1: - return t[m](a[0]); - case 2: - return t[m](a[0], a[1]); - case 3: - return t[m](a[0], a[1], a[2]); - case 4: - return t[m](a[0], a[1], a[2], a[3]); - case 5: - return t[m](a[0], a[1], a[2], a[3], a[4]); - default: - return t[m].apply(t, a); + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), + writable: true, + value: meta.peekValues(keyName) + }); + meta.deleteFromValues(keyName); + } + } + } + } else if (count > 1) { + meta.writeWatching(keyName, count - 1); } } }); -enifed("ember-utils/assign", ["exports"], function (exports) { - /** - Copy properties from a source object to a target object. - - ```javascript - var a = { first: 'Yehuda' }; - var b = { last: 'Katz' }; - var c = { company: 'Tilde Inc.' }; - Ember.assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' } - ``` - - @method assign - @for Ember - @param {Object} original The object to assign into - @param {Object} ...args The objects to copy properties from - @return {Object} - @public - */ - "use strict"; - - exports.default = assign; - - function assign(original) { - for (var i = 1; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) { - continue; - } - - var updates = Object.keys(arg); +enifed('ember-metal/watch_path', ['exports', 'ember-metal/meta', 'ember-metal/chains'], function (exports, _emberMetalMeta, _emberMetalChains) { + 'use strict'; - for (var _i = 0; _i < updates.length; _i++) { - var prop = updates[_i]; - original[prop] = arg[prop]; - } - } + exports.makeChainNode = makeChainNode; + exports.watchPath = watchPath; + exports.unwatchPath = unwatchPath; - return original; + // get the chains for the current object. If the current object has + // chains inherited from the proto they will be cloned and reconfigured for + // the current object. + function chainsFor(obj, meta) { + return (meta || _emberMetalMeta.meta(obj)).writableChains(makeChainNode); } -}); -enifed('ember-utils/dictionary', ['exports', 'ember-utils/empty-object'], function (exports, _emberUtilsEmptyObject) { - 'use strict'; - exports.default = makeDictionary; - - // the delete is meant to hint at runtimes that this object should remain in - // dictionary mode. This is clearly a runtime specific hack, but currently it - // appears worthwhile in some usecases. Please note, these deletes do increase - // the cost of creation dramatically over a plain Object.create. And as this - // only makes sense for long-lived dictionaries that aren't instantiated often. + function makeChainNode(obj) { + return new _emberMetalChains.ChainNode(null, null, obj); + } - function makeDictionary(parent) { - var dict = undefined; - if (parent === null) { - dict = new _emberUtilsEmptyObject.default(); + function watchPath(obj, keyPath, meta) { + if (typeof obj !== 'object' || obj === null) { + return; + } + var m = meta || _emberMetalMeta.meta(obj); + var counter = m.peekWatching(keyPath) || 0; + if (!counter) { + // activate watching first time + m.writeWatching(keyPath, 1); + chainsFor(obj, m).add(keyPath); } else { - dict = Object.create(parent); + m.writeWatching(keyPath, counter + 1); } - dict['_dict'] = null; - delete dict['_dict']; - return dict; } -}); -enifed("ember-utils/empty-object", ["exports"], function (exports) { - // This exists because `Object.create(null)` is absurdly slow compared - // to `new EmptyObject()`. In either case, you want a null prototype - // when you're treating the object instances as arbitrary dictionaries - // and don't want your keys colliding with build-in methods on the - // default object prototype. - "use strict"; - - var proto = Object.create(null, { - // without this, we will always still end up with (new - // EmptyObject()).constructor === Object - constructor: { - value: undefined, - enumerable: false, - writable: true + function unwatchPath(obj, keyPath, meta) { + if (typeof obj !== 'object' || obj === null) { + return; } - }); + var m = meta || _emberMetalMeta.meta(obj); + var counter = m.peekWatching(keyPath) || 0; - function EmptyObject() {} - EmptyObject.prototype = proto; - exports.default = EmptyObject; + if (counter === 1) { + m.writeWatching(keyPath, 0); + chainsFor(obj, m).remove(keyPath); + } else if (counter > 1) { + m.writeWatching(keyPath, counter - 1); + } + } }); -enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, _emberUtilsIntern) { +enifed('ember-metal/watching', ['exports', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) { + /** + @module ember-metal + */ + 'use strict'; - exports.uuid = uuid; - exports.generateGuid = generateGuid; - exports.guidFor = guidFor; + exports.isWatching = isWatching; + exports.watcherCount = watcherCount; + exports.unwatch = unwatch; + exports.destroy = destroy; /** - Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from - jQuery master. We'll just bootstrap our own uuid now. + Starts watching a property on an object. Whenever the property changes, + invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the + primitive used by observers and dependent keys; usually you will never call + this method directly but instead use higher level methods like + `Ember.addObserver()` - @private - @return {Number} the uuid - */ - var _uuid = 0; + @private + @method watch + @for Ember + @param obj + @param {String} _keyPath + */ + function watch(obj, _keyPath, m) { + if (!_emberMetalPath_cache.isPath(_keyPath)) { + _emberMetalWatch_key.watchKey(obj, _keyPath, m); + } else { + _emberMetalWatch_path.watchPath(obj, _keyPath, m); + } + } - /** - Generates a universally unique identifier. This method - is used internally by Ember for assisting with - the generation of GUID's and other unique identifiers. - - @public - @return {Number} [description] - */ + exports.watch = watch; - function uuid() { - return ++_uuid; + function isWatching(obj, key) { + if (typeof obj !== 'object' || obj === null) { + return false; + } + var meta = _emberMetalMeta.peekMeta(obj); + return (meta && meta.peekWatching(key)) > 0; } - /** - Prefix used for guids through out Ember. - @private - @property GUID_PREFIX - @for Ember - @type String - @final - */ - var GUID_PREFIX = 'ember'; + function watcherCount(obj, key) { + var meta = _emberMetalMeta.peekMeta(obj); + return meta && meta.peekWatching(key) || 0; + } - // Used for guid generation... - var numberCache = []; - var stringCache = {}; + function unwatch(obj, _keyPath, m) { + if (!_emberMetalPath_cache.isPath(_keyPath)) { + _emberMetalWatch_key.unwatchKey(obj, _keyPath, m); + } else { + _emberMetalWatch_path.unwatchPath(obj, _keyPath, m); + } + } /** - A unique key used to assign guids and other private metadata to objects. - If you inspect an object in your browser debugger you will often see these. - They can be safely ignored. - - On browsers that support it, these properties are added with enumeration - disabled so they won't show up when you iterate over your properties. + Tears down the meta on an object so that it can be garbage collected. + Multiple calls will have no effect. - @private - @property GUID_KEY + @method destroy @for Ember - @type String - @final + @param {Object} obj the object to destroy + @return {void} + @private */ - var GUID_KEY = _emberUtilsIntern.default('__ember' + +new Date()); - exports.GUID_KEY = GUID_KEY; - var GUID_DESC = { - writable: true, - configurable: true, - enumerable: false, - value: null - }; + function destroy(obj) { + _emberMetalMeta.deleteMeta(obj); + } +}); +enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { + 'use strict'; - exports.GUID_DESC = GUID_DESC; - var nullDescriptor = { - configurable: true, - writable: true, - enumerable: false, - value: null - }; + exports.default = WeakMap; - var GUID_KEY_PROPERTY = { - name: GUID_KEY, - descriptor: nullDescriptor - }; + var id = 0; - exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY; - /** - Generates a new guid, optionally saving the guid to the object that you - pass in. You will rarely need to use this method. Instead you should - call `Ember.guidFor(obj)`, which return an existing guid if available. - - @private - @method generateGuid - @for Ember - @param {Object} [obj] Object the guid will be used for. If passed in, the guid will - be saved on the object and reused whenever you pass the same object - again. - - If no object is passed, just generate a new guid. - @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to - separate the guid into separate namespaces. - @return {String} the guid - */ + // Returns whether Type(value) is Object according to the terminology in the spec + function isObject(value) { + return typeof value === 'object' && value !== null || typeof value === 'function'; + } - function generateGuid(obj, prefix) { - if (!prefix) { - prefix = GUID_PREFIX; + /* + * @class Ember.WeakMap + * @public + * @category ember-metal-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(iterable) { + if (!(this instanceof WeakMap)) { + throw new TypeError('Constructor WeakMap requires \'new\''); } - var ret = prefix + uuid(); - if (obj) { - if (obj[GUID_KEY] === null) { - obj[GUID_KEY] = ret; - } else { - GUID_DESC.value = ret; - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(GUID_KEY_PROPERTY); - } else { - Object.defineProperty(obj, GUID_KEY, GUID_DESC); - } + this._id = _emberUtils.GUID_KEY + id++; + + if (iterable === null || iterable === undefined) { + return; + } else if (Array.isArray(iterable)) { + for (var i = 0; i < iterable.length; i++) { + var _iterable$i = iterable[i]; + var key = _iterable$i[0]; + var value = _iterable$i[1]; + + this.set(key, value); } + } else { + throw new TypeError('The weak map constructor polyfill only supports an array argument'); } - return ret; } - /** - Returns a unique id for the object. If the object does not yet have a guid, - one will be assigned to it. You can call this on any object, - `Ember.Object`-based or not, but be aware that it will add a `_guid` - property. - - You can also use this method on DOM Element objects. - - @public - @method guidFor - @for Ember - @param {Object} obj any object, string, number, Element, or primitive - @return {String} the unique guid for this instance. - */ + /* + * @method get + * @param key {Object | Function} + * @return {Any} stored value + */ + WeakMap.prototype.get = function (obj) { + if (!isObject(obj)) { + return undefined; + } - function guidFor(obj) { - var type = typeof obj; - var isObject = type === 'object' && obj !== null; - var isFunction = type === 'function'; + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + if (map[this._id] === _emberMetalMeta.UNDEFINED) { + return undefined; + } - if ((isObject || isFunction) && obj[GUID_KEY]) { - return obj[GUID_KEY]; + return map[this._id]; + } } + }; - // special cases where we don't want to add a key to object - if (obj === undefined) { - return '(undefined)'; + /* + * @method set + * @param key {Object | Function} + * @param value {Any} + * @return {WeakMap} the weak map + */ + WeakMap.prototype.set = function (obj, value) { + if (!isObject(obj)) { + throw new TypeError('Invalid value used as weak map key'); } - if (obj === null) { - return '(null)'; + if (value === undefined) { + value = _emberMetalMeta.UNDEFINED; } - var ret = undefined; + _emberMetalMeta.meta(obj).writableWeak()[this._id] = value; - // Don't allow prototype changes to String etc. to change the guidFor - switch (type) { - case 'number': - ret = numberCache[obj]; + return this; + }; - if (!ret) { - ret = numberCache[obj] = 'nu' + obj; - } + /* + * @method has + * @param key {Object | Function} + * @return {boolean} if the key exists + */ + WeakMap.prototype.has = function (obj) { + if (!isObject(obj)) { + return false; + } - return ret; + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + return map[this._id] !== undefined; + } + } - case 'string': - ret = stringCache[obj]; + return false; + }; - if (!ret) { - ret = stringCache[obj] = 'st' + uuid(); - } + /* + * @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; + } + }; - return ret; + /* + * @method toString + * @return {String} + */ + WeakMap.prototype.toString = function () { + return '[object WeakMap]'; + }; +}); +enifed('ember-routing/ext/controller', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/utils'], function (exports, _emberMetal, _emberRuntime, _emberRoutingUtils) { + 'use strict'; - case 'boolean': - return obj ? '(true)' : '(false)'; + /** + @module ember + @submodule ember-routing + */ + + _emberRuntime.ControllerMixin.reopen({ + concatenatedProperties: ['queryParams'], + + /** + Defines which query parameters the controller accepts. + If you give the names `['category','page']` it will bind + the values of these query parameters to the variables + `this.category` and `this.page` + @property queryParams + @public + */ + queryParams: null, + + /** + This property is updated to various different callback functions depending on + the current "state" of the backing route. It is used by + `Ember.Controller.prototype._qpChanged`. + The methods backing each state can be found in the `Ember.Route.prototype._qp` computed + property return value (the `.states` property). The current values are listed here for + the sanity of future travelers: + * `inactive` - This state is used when this controller instance is not part of the active + route heirarchy. Set in `Ember.Route.prototype._reset` (a `router.js` microlib hook) and + `Ember.Route.prototype.actions.finalizeQueryParamChange`. + * `active` - This state is used when this controller instance is part of the active + route heirarchy. Set in `Ember.Route.prototype.actions.finalizeQueryParamChange`. + * `allowOverrides` - This state is used in `Ember.Route.prototype.setup` (`route.js` microlib hook). + @method _qpDelegate + @private + */ + _qpDelegate: null, // set by route + + /** + During `Ember.Route#setup` observers are created to invoke this method + when any of the query params declared in `Ember.Controller#queryParams` property + are changed. + When invoked this method uses the currently active query param update delegate + (see `Ember.Controller.prototype._qpDelegate` for details) and invokes it with + the QP key/value being changed. + @method _qpChanged + @private + */ + _qpChanged: function (controller, _prop) { + var prop = _prop.substr(0, _prop.length - 3); + + var delegate = controller._qpDelegate; + var value = _emberMetal.get(controller, prop); + delegate(prop, value); + }, + + /** + Transition the application into another route. The route may + be either a single route or route path: + ```javascript + aController.transitionToRoute('blogPosts'); + aController.transitionToRoute('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + aController.transitionToRoute('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + aController.transitionToRoute('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```javascript + App.Router.map(function() { + this.route('blogPost', { path: ':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); + }); + }); + aController.transitionToRoute('blogComment', aPost, aComment); + aController.transitionToRoute('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + aController.transitionToRoute('/'); + aController.transitionToRoute('/blog/post/1/comment/13'); + aController.transitionToRoute('/blog/posts?sort=title'); + ``` + An options hash with a `queryParams` property may be provided as + the final argument to add query parameters to the destination URL. + ```javascript + aController.transitionToRoute('blogPost', 1, { + queryParams: { showComments: 'true' } + }); + // if you just want to transition the query parameters without changing the route + aController.transitionToRoute({ queryParams: { sort: 'date' } }); + ``` + See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). + @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 + @for Ember.ControllerMixin + @method transitionToRoute + @public + */ + transitionToRoute: function () { + // target may be either another controller or a router + var target = _emberMetal.get(this, 'target'); + var method = target.transitionToRoute || target.transitionTo; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(this, args)); + }, + + /** + Transition into another route while replacing the current URL, if possible. + This will replace the current history entry instead of adding a new one. + Beside that, it is identical to `transitionToRoute` in all other respects. + ```javascript + aController.replaceRoute('blogPosts'); + aController.replaceRoute('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + aController.replaceRoute('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + aController.replaceRoute('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```javascript + App.Router.map(function() { + this.route('blogPost', { path: ':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); + }); + }); + aController.replaceRoute('blogComment', aPost, aComment); + aController.replaceRoute('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + aController.replaceRoute('/'); + aController.replaceRoute('/blog/post/1/comment/13'); + ``` + @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. + @for Ember.ControllerMixin + @method replaceRoute + @public + */ + replaceRoute: function () { + // target may be either another controller or a router + var target = _emberMetal.get(this, 'target'); + var method = target.replaceRoute || target.replaceWith; - default: - if (obj === Object) { - return '(Object)'; - } + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - if (obj === Array) { - return '(Array)'; - } + return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(target, args)); + } + }); - ret = GUID_PREFIX + uuid(); + exports.default = _emberRuntime.ControllerMixin; +}); +enifed('ember-routing/ext/run_loop', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - if (obj[GUID_KEY] === null) { - obj[GUID_KEY] = ret; - } else { - GUID_DESC.value = ret; + /** + @module ember + @submodule ember-views + */ - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(GUID_KEY_PROPERTY); - } else { - Object.defineProperty(obj, GUID_KEY, GUID_DESC); - } - } - return ret; - } - } + // Add a new named queue after the 'actions' queue (where RSVP promises + // resolve), which is used in router transitions to prevent unnecessary + // loading state entry if all context promises resolve on the + // 'actions' queue first. + _emberMetal.run._addQueue('routerTransitions', 'actions'); }); -enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString) { - /* - This package will be eagerly parsed and should have no dependencies on external - packages. - - It is intended to be used to share utility methods that will be needed - by every Ember application (and is **not** a dumping ground of useful utilities). - - Utility methods that are needed in < 80% of cases should be placed - elsewhere (so they can be lazily evaluated / parsed). +enifed('ember-routing/index', ['exports', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route', 'ember-routing/system/query_params', 'ember-routing/services/routing', 'ember-routing/services/router', 'ember-routing/system/cache'], function (exports, _emberRoutingExtRun_loop, _emberRoutingExtController, _emberRoutingLocationApi, _emberRoutingLocationNone_location, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingSystemGenerate_controller, _emberRoutingSystemController_for, _emberRoutingSystemDsl, _emberRoutingSystemRouter, _emberRoutingSystemRoute, _emberRoutingSystemQuery_params, _emberRoutingServicesRouting, _emberRoutingServicesRouter, _emberRoutingSystemCache) { + /** + @module ember + @submodule ember-routing */ + + // ES6TODO: Cleanup modules with side-effects below 'use strict'; - exports.symbol = _emberUtilsSymbol.default; - exports.getOwner = _emberUtilsOwner.getOwner; - exports.setOwner = _emberUtilsOwner.setOwner; - exports.OWNER = _emberUtilsOwner.OWNER; - exports.assign = _emberUtilsAssign.default; - exports.EmptyObject = _emberUtilsEmptyObject.default; - exports.dictionary = _emberUtilsDictionary.default; - exports.uuid = _emberUtilsGuid.uuid; - exports.GUID_KEY = _emberUtilsGuid.GUID_KEY; - exports.GUID_DESC = _emberUtilsGuid.GUID_DESC; - exports.GUID_KEY_PROPERTY = _emberUtilsGuid.GUID_KEY_PROPERTY; - exports.generateGuid = _emberUtilsGuid.generateGuid; - exports.guidFor = _emberUtilsGuid.guidFor; - exports.intern = _emberUtilsIntern.default; - exports.checkHasSuper = _emberUtilsSuper.checkHasSuper; - exports.ROOT = _emberUtilsSuper.ROOT; - exports.wrap = _emberUtilsSuper.wrap; - exports.inspect = _emberUtilsInspect.default; - exports.lookupDescriptor = _emberUtilsLookupDescriptor.default; - exports.canInvoke = _emberUtilsInvoke.canInvoke; - exports.tryInvoke = _emberUtilsInvoke.tryInvoke; - exports.makeArray = _emberUtilsMakeArray.default; - exports.applyStr = _emberUtilsApplyStr.default; - exports.NAME_KEY = _emberUtilsName.default; - exports.toString = _emberUtilsToString.default; + exports.Location = _emberRoutingLocationApi.default; + exports.NoneLocation = _emberRoutingLocationNone_location.default; + exports.HashLocation = _emberRoutingLocationHash_location.default; + exports.HistoryLocation = _emberRoutingLocationHistory_location.default; + exports.AutoLocation = _emberRoutingLocationAuto_location.default; + exports.generateController = _emberRoutingSystemGenerate_controller.default; + exports.generateControllerFactory = _emberRoutingSystemGenerate_controller.generateControllerFactory; + exports.controllerFor = _emberRoutingSystemController_for.default; + exports.RouterDSL = _emberRoutingSystemDsl.default; + exports.Router = _emberRoutingSystemRouter.default; + exports.Route = _emberRoutingSystemRoute.default; + exports.QueryParams = _emberRoutingSystemQuery_params.default; + exports.RoutingService = _emberRoutingServicesRouting.default; + exports.RouterService = _emberRoutingServicesRouter.default; + exports.BucketCache = _emberRoutingSystemCache.default; }); -enifed('ember-utils/inspect', ['exports'], function (exports) { +enifed('ember-routing/location/api', ['exports', 'ember-metal', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberMetal, _emberEnvironment, _emberRoutingLocationUtil) { 'use strict'; - exports.default = inspect; - var objectToString = Object.prototype.toString; - /** - Convenience method to inspect an object. This method will attempt to - convert the object into a useful string description. - - It is a pretty simple implementation. If you want something more robust, - use something like JSDump: https://github.com/NV/jsDump - - @method inspect - @for Ember - @param {Object} obj The object you want to inspect. - @return {String} A description of the object - @since 1.4.0 - @private + @module ember + @submodule ember-routing */ - function inspect(obj) { - if (obj === null) { - return 'null'; - } - if (obj === undefined) { - return 'undefined'; - } - if (Array.isArray(obj)) { - return '[' + obj + ']'; - } - // for non objects - var type = typeof obj; - if (type !== 'object' && type !== 'symbol') { - return '' + obj; - } - // overridden toString - if (typeof obj.toString === 'function' && obj.toString !== objectToString) { - return obj.toString(); - } - - // Object.prototype.toString === {}.toString - var v = undefined; - var ret = []; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - v = obj[key]; - if (v === 'toString') { - continue; - } // ignore useless items - if (typeof v === 'function') { - v = 'function() { ... }'; - } - - if (v && typeof v.toString !== 'function') { - ret.push(key + ': ' + objectToString.call(v)); - } else { - ret.push(key + ': ' + v); - } - } - } - return '{' + ret.join(', ') + '}'; - } -}); -enifed("ember-utils/intern", ["exports"], function (exports) { /** - Strongly hint runtimes to intern the provided string. + Ember.Location returns an instance of the correct implementation of + the `location` API. - When do I need to use this function? + ## Implementations - For the most part, never. Pre-mature optimization is bad, and often the - runtime does exactly what you need it to, and more often the trade-off isn't - worth it. + You can pass an implementation name (`hash`, `history`, `none`) to force a + particular implementation to be used in your application. - Why? + ### HashLocation - Runtimes store strings in at least 2 different representations: - Ropes and Symbols (interned strings). The Rope provides a memory efficient - data-structure for strings created from concatenation or some other string - manipulation like splitting. + Using `HashLocation` results in URLs with a `#` (hash sign) separating the + server side URL portion of the URL from the portion that is used by Ember. + This relies upon the `hashchange` event existing in the browser. - Unfortunately checking equality of different ropes can be quite costly as - runtimes must resort to clever string comparison algorithms. These - algorithms typically cost in proportion to the length of the string. - Luckily, this is where the Symbols (interned strings) shine. As Symbols are - unique by their string content, equality checks can be done by pointer - comparison. + Example: - How do I know if my string is a rope or symbol? + ```javascript + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); - Typically (warning general sweeping statement, but truthy in runtimes at - present) static strings created as part of the JS source are interned. - Strings often used for comparisons can be interned at runtime if some - criteria are met. One of these criteria can be the size of the entire rope. - For example, in chrome 38 a rope longer then 12 characters will not - intern, nor will segments of that rope. + App.Router.reopen({ + location: 'hash' + }); + ``` - Some numbers: http://jsperf.com/eval-vs-keys/8 + This will result in a posts.new url of `/#/posts/new`. - Known Trick™ + ### HistoryLocation - @private - @return {String} interned version of the provided string - */ - "use strict"; - - exports.default = intern; - - function intern(str) { - var obj = {}; - obj[str] = 1; - for (var key in obj) { - if (key === str) { - return key; - } - } - return str; - } -}); -enifed('ember-utils/invoke', ['exports', 'ember-utils/apply-str'], function (exports, _emberUtilsApplyStr) { - 'use strict'; - - exports.canInvoke = canInvoke; - exports.tryInvoke = tryInvoke; - - /** - Checks to see if the `methodName` exists on the `obj`. + Using `HistoryLocation` results in URLs that are indistinguishable from a + standard URL. This relies upon the browser's `history` API. + + Example: ```javascript - let foo = { bar: function() { return 'bar'; }, baz: null }; + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); - Ember.canInvoke(foo, 'bar'); // true - Ember.canInvoke(foo, 'baz'); // false - Ember.canInvoke(foo, 'bat'); // false + App.Router.reopen({ + location: 'history' + }); ``` - @method canInvoke - @for Ember - @param {Object} obj The object to check for the method - @param {String} methodName The method name to check for - @return {Boolean} - @private - */ - - function canInvoke(obj, methodName) { - return !!(obj && typeof obj[methodName] === 'function'); - } - - /** - Checks to see if the `methodName` exists on the `obj`, - and if it does, invokes it with the arguments passed. + This will result in a posts.new url of `/posts/new`. + + Keep in mind that your server must serve the Ember app at all the routes you + define. + + ### AutoLocation + + Using `AutoLocation`, the router will use the best Location class supported by + the browser it is running in. + + Browsers that support the `history` API will use `HistoryLocation`, those that + do not, but still support the `hashchange` event will use `HashLocation`, and + in the rare case neither is supported will use `NoneLocation`. + + Example: ```javascript - let d = new Date('03/15/2013'); + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); - Ember.tryInvoke(d, 'getTime'); // 1363320000000 - Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 - Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined + App.Router.reopen({ + location: 'auto' + }); ``` - @method tryInvoke - @for Ember - @param {Object} obj The object to check for the method - @param {String} methodName The method name to check for - @param {Array} [args] The arguments to pass to the method - @return {*} the return value of the invoked method or undefined if it cannot be invoked - @public - */ - - function tryInvoke(obj, methodName, args) { - if (canInvoke(obj, methodName)) { - return args ? _emberUtilsApplyStr.default(obj, methodName, args) : _emberUtilsApplyStr.default(obj, methodName); - } - } -}); -enifed("ember-utils/lookup-descriptor", ["exports"], function (exports) { - "use strict"; - - exports.default = lookupDescriptor; - - function lookupDescriptor(obj, keyName) { - var current = obj; - while (current) { - var descriptor = Object.getOwnPropertyDescriptor(current, keyName); - - if (descriptor) { - return descriptor; - } - - current = Object.getPrototypeOf(current); - } - - return null; - } -}); -enifed("ember-utils/make-array", ["exports"], function (exports) { - /** - Forces the passed object to be part of an array. If the object is already - an array, it will return the object. Otherwise, it will add the object to - an array. If obj is `null` or `undefined`, it will return an empty array. + This will result in a posts.new url of `/posts/new` for modern browsers that + support the `history` api or `/#/posts/new` for older ones, like Internet + Explorer 9 and below. - ```javascript - Ember.makeArray(); // [] - Ember.makeArray(null); // [] - Ember.makeArray(undefined); // [] - Ember.makeArray('lindsay'); // ['lindsay'] - Ember.makeArray([1, 2, 42]); // [1, 2, 42] + When a user visits a link to your application, they will be automatically + upgraded or downgraded to the appropriate `Location` class, with the URL + transformed accordingly, if needed. - let controller = Ember.ArrayProxy.create({ content: [] }); + Keep in mind that since some of your users will use `HistoryLocation`, your + server must serve the Ember app at all the routes you define. - Ember.makeArray(controller) === controller; // true - ``` + ### NoneLocation - @method makeArray - @for Ember - @param {Object} obj the object - @return {Array} - @private - */ - "use strict"; - - exports.default = makeArray; - - function makeArray(obj) { - if (obj === null || obj === undefined) { - return []; - } - return Array.isArray(obj) ? obj : [obj]; - } -}); -enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - 'use strict'; - - exports.default = _emberUtilsSymbol.default('NAME_KEY'); -}); -enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - exports.getOwner = getOwner; - exports.setOwner = setOwner; - var OWNER = _emberUtilsSymbol.default('OWNER'); - - exports.OWNER = OWNER; - /** - Framework objects in an Ember application (components, services, routes, etc.) - are created via a factory and dependency injection system. Each of these - objects is the responsibility of an "owner", which handled its - instantiation and manages its lifetime. + Using `NoneLocation` causes Ember to not store the applications URL state + in the actual URL. This is generally used for testing purposes, and is one + of the changes made when calling `App.setupForTesting()`. - `getOwner` fetches the owner object responsible for an instance. This can - be used to lookup or resolve other class instances, or register new factories - into the owner. + ## Location API - For example, this component dynamically looks up a service based on the - `audioType` passed as an attribute: + Each location implementation must provide the following methods: - ``` - // app/components/play-audio.js + * implementation: returns the string name used to reference the implementation. + * getURL: returns the current URL. + * setURL(path): sets the current URL. + * replaceURL(path): replace the current URL (optional). + * onUpdateURL(callback): triggers the callback when the URL changes. + * formatURL(url): formats `url` to be placed into `href` attribute. + * detect() (optional): instructs the location to do any feature detection + necessary. If the location needs to redirect to a different URL, it + can cancel routing by setting the `cancelRouterSetup` property on itself + to `false`. + + Calling setURL or replaceURL will not trigger onUpdateURL callbacks. + + ## Custom implementation + + Ember scans `app/locations/*` for extending the Location API. + + Example: + + ```javascript import Ember from 'ember'; - // Usage: - // - // {{play-audio audioType=model.audioType audioFile=model.file}} - // - export default Ember.Component.extend({ - audioService: Ember.computed('audioType', function() { - let owner = Ember.getOwner(this); - return owner.lookup(`service:${this.get('audioType')}`); - }), - click() { - let player = this.get('audioService'); - player.play(this.get('audioFile')); + export default Ember.HistoryLocation.extend({ + implementation: 'history-url-logging', + + pushState: function (path) { + console.log(path); + this._super.apply(this, arguments); } }); ``` - @method getOwner - @for Ember - @param {Object} object An object with an owner. - @return {Object} An owner object. - @since 2.3.0 - @public - */ - - function getOwner(object) { - return object[OWNER]; - } - - /** - `setOwner` forces a new owner on a given object instance. This is primarily - useful in some testing cases. - - @method setOwner - @for Ember - @param {Object} object An object with an owner. - @return {Object} An owner object. - @since 2.3.0 - @public + @class Location + @namespace Ember + @static + @private */ + exports.default = { + /** + This is deprecated in favor of using the container to lookup the location + implementation as desired. + For example: + ```javascript + // Given a location registered as follows: + container.register('location:history-test', HistoryTestLocation); + // You could create a new instance via: + container.lookup('location:history-test'); + ``` + @method create + @param {Object} options + @return {Object} an instance of an implementation of the `location` API + @deprecated Use the container to lookup the location implementation that you + need. + @private + */ + create: function (options) { + var implementation = options && options.implementation; + _emberMetal.assert('Ember.Location.create: you must specify a \'implementation\' option', !!implementation); - function setOwner(object, owner) { - object[OWNER] = owner; - } -}); -enifed('ember-utils/super', ['exports'], function (exports) { - 'use strict'; - - exports.wrap = wrap; - var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/; - var fnToString = Function.prototype.toString; + var implementationClass = this.implementations[implementation]; + _emberMetal.assert('Ember.Location.create: ' + implementation + ' is not a valid implementation', !!implementationClass); - var checkHasSuper = (function () { - var sourceAvailable = fnToString.call(function () { - return this; - }).indexOf('return this') > -1; + return implementationClass.create.apply(implementationClass, arguments); + }, - if (sourceAvailable) { - return function checkHasSuper(func) { - return HAS_SUPER_PATTERN.test(fnToString.call(func)); - }; - } + implementations: {}, + _location: _emberEnvironment.environment.location, - return function checkHasSuper() { - return true; - }; - })(); + /** + Returns the current `location.hash` by parsing location.href since browsers + inconsistently URL-decode `location.hash`. + https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + @private + @method getHash + @since 1.4.0 + */ + _getHash: function () { + return _emberRoutingLocationUtil.getHash(this.location); + } + }; +}); +enifed('ember-routing/location/auto_location', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberRoutingLocationUtil) { + 'use strict'; - exports.checkHasSuper = checkHasSuper; - function ROOT() {} - ROOT.__hasSuper = false; + exports.getHistoryPath = getHistoryPath; + exports.getHashPath = getHashPath; - function hasSuper(func) { - if (func.__hasSuper === undefined) { - func.__hasSuper = checkHasSuper(func); - } - return func.__hasSuper; - } + /** + @module ember + @submodule ember-routing + */ /** - Wraps the passed function so that `this._super` will point to the superFunc - when the function is invoked. This is the primitive we use to implement - calls to super. + Ember.AutoLocation will select the best location option based off browser + support with the priority order: history, hash, none. + + Clean pushState paths accessed by hashchange-only browsers will be redirected + to the hash-equivalent and vice versa so future transitions are consistent. + Keep in mind that since some of your users will use `HistoryLocation`, your + server must serve the Ember app at all the routes you define. + + @class AutoLocation + @namespace Ember + @static @private - @method wrap - @for Ember - @param {Function} func The function to call - @param {Function} superFunc The super function. - @return {Function} wrapped function. */ + exports.default = _emberRuntime.Object.extend({ + /** + @private + The browser's `location` object. This is typically equivalent to + `window.location`, but may be overridden for testing. + @property location + @default environment.location + */ + location: _emberEnvironment.environment.location, - function wrap(func, superFunc) { - if (!hasSuper(func)) { - return func; - } - // ensure an unwrapped super that calls _super is wrapped with a terminal _super - if (!superFunc.wrappedFunction && hasSuper(superFunc)) { - return _wrap(func, _wrap(superFunc, ROOT)); - } - return _wrap(func, superFunc); - } - - function _wrap(func, superFunc) { - function superWrapper() { - var orig = this._super; - this._super = superFunc; - var ret = func.apply(this, arguments); - this._super = orig; - return ret; - } - - superWrapper.wrappedFunction = func; - superWrapper.__ember_observes__ = func.__ember_observes__; - superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__; - superWrapper.__ember_listens__ = func.__ember_listens__; + /** + @private + The browser's `history` object. This is typically equivalent to + `window.history`, but may be overridden for testing. + @since 1.5.1 + @property history + @default environment.history + */ + history: _emberEnvironment.environment.history, - return superWrapper; - } -}); -enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern'], function (exports, _emberUtilsGuid, _emberUtilsIntern) { - 'use strict'; + /** + @private + The user agent's global variable. In browsers, this will be `window`. + @since 1.11 + @property global + @default window + */ + global: _emberEnvironment.environment.window, - exports.default = symbol; + /** + @private + The browser's `userAgent`. This is typically equivalent to + `navigator.userAgent`, but may be overridden for testing. + @since 1.5.1 + @property userAgent + @default environment.history + */ + userAgent: _emberEnvironment.environment.userAgent, - function symbol(debugName) { - // TODO: Investigate using platform symbols, but we do not - // want to require non-enumerability for this API, which - // would introduce a large cost. + /** + @private + This property is used by the router to know whether to cancel the routing + setup process, which is needed while we redirect the browser. + @since 1.5.1 + @property cancelRouterSetup + @default false + */ + cancelRouterSetup: false, - return _emberUtilsIntern.default(debugName + ' [id=' + _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()) + ']'); - } -}); -enifed('ember-utils/to-string', ['exports'], function (exports) { - 'use strict'; + /** + @private + Will be pre-pended to path upon state change. + @since 1.5.1 + @property rootURL + @default '/' + */ + rootURL: '/', - exports.default = toString; - var objectToString = Object.prototype.toString; + /** + Called by the router to instruct the location to do any feature detection + necessary. In the case of AutoLocation, we detect whether to use history + or hash concrete implementations. + @private + */ + detect: function () { + var rootURL = this.rootURL; - /* - A `toString` util function that supports objects without a `toString` - method, e.g. an object created with `Object.create(null)`. - */ + _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); - function toString(obj) { - if (obj && typeof obj.toString === 'function') { - return obj.toString(); - } else { - return objectToString.call(obj); - } - } -}); -enifed('ember-views/compat/attrs', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + var implementation = detectImplementation({ + location: this.location, + history: this.history, + userAgent: this.userAgent, + rootURL: rootURL, + documentMode: this.documentMode, + global: this.global + }); - var MUTABLE_CELL = _emberUtils.symbol('MUTABLE_CELL'); - exports.MUTABLE_CELL = MUTABLE_CELL; -}); -enifed('ember-views/compat/fallback-view-registry', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + if (implementation === false) { + _emberMetal.set(this, 'cancelRouterSetup', true); + implementation = 'none'; + } - exports.default = _emberUtils.dictionary(null); -}); -enifed('ember-views/component_lookup', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { - 'use strict'; + var concrete = _emberUtils.getOwner(this).lookup('location:' + implementation); + _emberMetal.set(concrete, 'rootURL', rootURL); - exports.default = _emberRuntime.Object.extend({ - componentFor: function (name, owner, options) { - _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); + _emberMetal.assert('Could not find location \'' + implementation + '\'.', !!concrete); - var fullName = 'component:' + name; - return owner._lookupFactory(fullName, options); + _emberMetal.set(this, 'concreteImplementation', concrete); }, - layoutFor: function (name, owner, options) { - _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); + initState: delegateToConcreteImplementation('initState'), + getURL: delegateToConcreteImplementation('getURL'), + setURL: delegateToConcreteImplementation('setURL'), + replaceURL: delegateToConcreteImplementation('replaceURL'), + onUpdateURL: delegateToConcreteImplementation('onUpdateURL'), + formatURL: delegateToConcreteImplementation('formatURL'), - var templateFullName = 'template:components/' + name; - return owner.lookup(templateFullName, options); + willDestroy: function () { + var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); + + if (concreteImplementation) { + concreteImplementation.destroy(); + } } }); -}); -enifed('ember-views/index', ['exports', 'ember-views/system/ext', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/system/event_dispatcher', 'ember-views/component_lookup', 'ember-views/mixins/text_support', 'ember-views/views/core_view', 'ember-views/mixins/class_names_support', 'ember-views/mixins/child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/view_support', 'ember-views/mixins/action_support', 'ember-views/compat/attrs', 'ember-views/system/lookup_partial', 'ember-views/utils/lookup-component', 'ember-views/system/action_manager', 'ember-views/compat/fallback-view-registry'], function (exports, _emberViewsSystemExt, _emberViewsSystemJquery, _emberViewsSystemUtils, _emberViewsSystemEvent_dispatcher, _emberViewsComponent_lookup, _emberViewsMixinsText_support, _emberViewsViewsCore_view, _emberViewsMixinsClass_names_support, _emberViewsMixinsChild_views_support, _emberViewsMixinsView_state_support, _emberViewsMixinsView_support, _emberViewsMixinsAction_support, _emberViewsCompatAttrs, _emberViewsSystemLookup_partial, _emberViewsUtilsLookupComponent, _emberViewsSystemAction_manager, _emberViewsCompatFallbackViewRegistry) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; + function delegateToConcreteImplementation(methodName) { + return function () { + var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); + _emberMetal.assert('AutoLocation\'s detect() method should be called before calling any other hooks.', !!concreteImplementation); - exports.jQuery = _emberViewsSystemJquery.default; - exports.isSimpleClick = _emberViewsSystemUtils.isSimpleClick; - exports.getViewBounds = _emberViewsSystemUtils.getViewBounds; - exports.getViewClientRects = _emberViewsSystemUtils.getViewClientRects; - exports.getViewBoundingClientRect = _emberViewsSystemUtils.getViewBoundingClientRect; - exports.getRootViews = _emberViewsSystemUtils.getRootViews; - exports.getChildViews = _emberViewsSystemUtils.getChildViews; - exports.getViewId = _emberViewsSystemUtils.getViewId; - exports.getViewElement = _emberViewsSystemUtils.getViewElement; - exports.setViewElement = _emberViewsSystemUtils.setViewElement; - exports.STYLE_WARNING = _emberViewsSystemUtils.STYLE_WARNING; - exports.EventDispatcher = _emberViewsSystemEvent_dispatcher.default; - exports.ComponentLookup = _emberViewsComponent_lookup.default; - exports.TextSupport = _emberViewsMixinsText_support.default; - exports.CoreView = _emberViewsViewsCore_view.default; - exports.ClassNamesSupport = _emberViewsMixinsClass_names_support.default; - exports.ChildViewsSupport = _emberViewsMixinsChild_views_support.default; - exports.ViewStateSupport = _emberViewsMixinsView_state_support.default; - exports.ViewMixin = _emberViewsMixinsView_support.default; - exports.ActionSupport = _emberViewsMixinsAction_support.default; - exports.MUTABLE_CELL = _emberViewsCompatAttrs.MUTABLE_CELL; - exports.lookupPartial = _emberViewsSystemLookup_partial.default; - exports.hasPartial = _emberViewsSystemLookup_partial.hasPartial; - exports.lookupComponent = _emberViewsUtilsLookupComponent.default; - exports.ActionManager = _emberViewsSystemAction_manager.default; - exports.fallbackViewRegistry = _emberViewsCompatFallbackViewRegistry.default; -}); -// for the side effect of extending Ember.run.queues -enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/compat/attrs'], function (exports, _emberUtils, _emberMetal, _emberViewsCompatAttrs) { - /** - @module ember - @submodule ember-views + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _emberUtils.tryInvoke(concreteImplementation, methodName, args); + }; + } + + /* + Given the browser's `location`, `history` and `userAgent`, and a configured + root URL, this function detects whether the browser supports the [History + API](https://developer.mozilla.org/en-US/docs/Web/API/History) and returns a + string representing the Location object to use based on its determination. + + For example, if the page loads in an evergreen browser, this function would + return the string "history", meaning the history API and thus HistoryLocation + should be used. If the page is loaded in IE8, it will return the string + "hash," indicating that the History API should be simulated by manipulating the + hash portion of the location. + */ - 'use strict'; - function validateAction(component, actionName) { - if (actionName && actionName[_emberViewsCompatAttrs.MUTABLE_CELL]) { - actionName = actionName.value; + function detectImplementation(options) { + var location = options.location; + var userAgent = options.userAgent; + var history = options.history; + var documentMode = options.documentMode; + var global = options.global; + var rootURL = options.rootURL; + + var implementation = 'none'; + var cancelRouterSetup = false; + var currentPath = _emberRoutingLocationUtil.getFullPath(location); + + if (_emberRoutingLocationUtil.supportsHistory(userAgent, history)) { + var historyPath = getHistoryPath(rootURL, location); + + // If the browser supports history and we have a history path, we can use + // the history location with no redirects. + if (currentPath === historyPath) { + return 'history'; + } else { + if (currentPath.substr(0, 2) === '/#') { + history.replaceState({ path: historyPath }, null, historyPath); + implementation = 'history'; + } else { + cancelRouterSetup = true; + _emberRoutingLocationUtil.replacePath(location, historyPath); + } + } + } else if (_emberRoutingLocationUtil.supportsHashChange(documentMode, global)) { + var hashPath = getHashPath(rootURL, location); + + // Be sure we're using a hashed path, otherwise let's switch over it to so + // we start off clean and consistent. We'll count an index path with no + // hash as "good enough" as well. + if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') { + implementation = 'hash'; + } else { + // Our URL isn't in the expected hash-supported format, so we want to + // cancel the router setup and replace the URL to start off clean + cancelRouterSetup = true; + _emberRoutingLocationUtil.replacePath(location, hashPath); + } } - _emberMetal.assert('The default action was triggered on the component ' + component.toString() + ', but the action name (' + actionName + ') was not a string.', _emberMetal.isNone(actionName) || typeof actionName === 'string' || typeof actionName === 'function'); - return actionName; + if (cancelRouterSetup) { + return false; + } + + return implementation; } /** - @class ActionSupport - @namespace Ember - @private + @private + + Returns the current path as it should appear for HistoryLocation supported + browsers. This may very well differ from the real current path (e.g. if it + starts off as a hashed URL) */ - exports.default = _emberMetal.Mixin.create({ - /** - Calls an action passed to a component. - For example a component for playing or pausing music may translate click events - into action notifications of "play" or "stop" depending on some internal state - of the component: - ```javascript - // app/components/play-button.js - export default Ember.Component.extend({ - click() { - if (this.get('isPlaying')) { - this.sendAction('play'); - } else { - this.sendAction('stop'); - } - } - }); - ``` - The actions "play" and "stop" must be passed to this `play-button` component: - ```handlebars - {{! app/templates/application.hbs }} - {{play-button play=(action "musicStarted") stop=(action "musicStopped")}} - ``` - When the component receives a browser `click` event it translate this - interaction into application-specific semantics ("play" or "stop") and - calls the specified action. - ```javascript - // app/controller/application.js - export default Ember.Controller.extend({ - actions: { - musicStarted() { - // called when the play button is clicked - // and the music started playing - }, - musicStopped() { - // called when the play button is clicked - // and the music stopped playing - } - } - }); - ``` - If no action is passed to `sendAction` a default name of "action" - is assumed. - ```javascript - // app/components/next-button.js - export default Ember.Component.extend({ - click() { - this.sendAction(); - } - }); - ``` - ```handlebars - {{! app/templates/application.hbs }} - {{next-button action=(action "playNextSongInAlbum")}} - ``` - ```javascript - // app/controllers/application.js - App.ApplicationController = Ember.Controller.extend({ - actions: { - playNextSongInAlbum() { - ... - } - } - }); - ``` - @method sendAction - @param [action] {String} the action to call - @param [params] {*} arguments for the action - @public - */ - sendAction: function (action) { - for (var _len = arguments.length, contexts = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - contexts[_key - 1] = arguments[_key]; - } - var actionName = undefined; + function getHistoryPath(rootURL, location) { + var path = _emberRoutingLocationUtil.getPath(location); + var hash = _emberRoutingLocationUtil.getHash(location); + var query = _emberRoutingLocationUtil.getQuery(location); + var rootURLIndex = path.indexOf(rootURL); + var routeHash = undefined, + hashParts = undefined; - // Send the default action - if (action === undefined) { - action = 'action'; - } - actionName = _emberMetal.get(this, 'attrs.' + action) || _emberMetal.get(this, action); - actionName = validateAction(this, actionName); + _emberMetal.assert('Path ' + path + ' does not start with the provided rootURL ' + rootURL, rootURLIndex === 0); - // If no action name for that action could be found, just abort. - if (actionName === undefined) { - return; - } + // By convention, Ember.js routes using HashLocation are required to start + // with `#/`. Anything else should NOT be considered a route and should + // be passed straight through, without transformation. + if (hash.substr(0, 2) === '#/') { + // There could be extra hash segments after the route + hashParts = hash.substr(1).split('#'); + // The first one is always the route url + routeHash = hashParts.shift(); - if (typeof actionName === 'function') { - actionName.apply(undefined, contexts); - } else { - this.triggerAction({ - action: actionName, - actionContext: contexts - }); + // If the path already has a trailing slash, remove the one + // from the hashed route so we don't double up. + if (path.charAt(path.length - 1) === '/') { + routeHash = routeHash.substr(1); } - }, - send: function (actionName) { - for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - args[_key2 - 1] = arguments[_key2]; + // This is the "expected" final order + path += routeHash + query; + + if (hashParts.length) { + path += '#' + hashParts.join('#'); } + } else { + path += query + hash; + } - var action = this.actions && this.actions[actionName]; + return path; + } - if (action) { - var shouldBubble = action.apply(this, args) === true; - if (!shouldBubble) { - return; - } - } + /** + @private + + Returns the current path as it should appear for HashLocation supported + browsers. This may very well differ from the real current path. + + @method _getHashPath + */ - var target = _emberMetal.get(this, 'target'); - if (target) { - _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); - } else { - _emberMetal.assert(_emberUtils.inspect(this) + ' had no action handler for: ' + actionName, action); + function getHashPath(rootURL, location) { + var path = rootURL; + var historyPath = getHistoryPath(rootURL, location); + var routePath = historyPath.substr(rootURL.length); + + if (routePath !== '') { + if (routePath[0] !== '/') { + routePath = '/' + routePath; } + + path += '#' + routePath; } - }); + + return path; + } }); -enifed('ember-views/mixins/child_views_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/system/utils'], function (exports, _emberUtils, _emberMetal, _emberViewsSystemUtils) { +enifed('ember-routing/location/hash_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { + 'use strict'; + /** @module ember - @submodule ember-views + @submodule ember-routing */ - 'use strict'; - exports.default = _emberMetal.Mixin.create({ + /** + `Ember.HashLocation` implements the location API using the browser's + hash. At present, it relies on a `hashchange` event existing in the + browser. + + @class HashLocation + @namespace Ember + @extends Ember.Object + @private + */ + exports.default = _emberRuntime.Object.extend({ + implementation: 'hash', + init: function () { - this._super.apply(this, arguments); - _emberViewsSystemUtils.initChildViews(this); + _emberMetal.set(this, 'location', _emberMetal.get(this, '_location') || window.location); + + this._hashchangeHandler = undefined; }, /** - Array of child views. You should never edit this array directly. - @property childViews - @type Array - @default [] @private + Returns normalized location.hash + @since 1.5.1 + @method getHash */ - childViews: _emberMetal.descriptor({ - configurable: false, - enumerable: false, - get: function () { - return _emberViewsSystemUtils.getChildViews(this); + getHash: _emberRoutingLocationApi.default._getHash, + + /** + Returns the normalized URL, constructed from `location.hash`. + e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. + By convention, hashed paths must begin with a forward slash, otherwise they + are not treated as a path so we can distinguish intent. + @private + @method getURL + */ + getURL: function () { + var originalPath = this.getHash().substr(1); + var outPath = originalPath; + + if (outPath[0] !== '/') { + outPath = '/'; + + // Only add the # if the path isn't empty. + // We do NOT want `/#` since the ampersand + // is only included (conventionally) when + // the location.hash has a value + if (originalPath) { + outPath += '#' + originalPath; + } } - }), - appendChild: function (view) { - this.linkChild(view); - _emberViewsSystemUtils.addChildView(this, view); + return outPath; }, - linkChild: function (instance) { - if (!_emberUtils.getOwner(instance)) { - _emberUtils.setOwner(instance, _emberUtils.getOwner(this)); - } - } - }); -}); -enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-views - */ + /** + Set the `location.hash` and remembers what was set. This prevents + `onUpdateURL` callbacks from triggering when the hash was set by + `HashLocation`. + @private + @method setURL + @param path {String} + */ + setURL: function (path) { + _emberMetal.get(this, 'location').hash = path; + _emberMetal.set(this, 'lastSetURL', path); + }, - 'use strict'; + /** + Uses location.replace to update the url without a page reload + or history modification. + @private + @method replaceURL + @param path {String} + */ + replaceURL: function (path) { + _emberMetal.get(this, 'location').replace('#' + path); + _emberMetal.set(this, 'lastSetURL', path); + }, - var EMPTY_ARRAY = Object.freeze([]); + /** + Register a callback to be invoked when the hash changes. These + callbacks will execute when the user presses the back or forward + button, but not after `setURL` is invoked. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + var _this = this; - /** - @class ClassNamesSupport - @namespace Ember - @private - */ - exports.default = _emberMetal.Mixin.create({ - concatenatedProperties: ['classNames', 'classNameBindings'], + this._removeEventListener(); - init: function () { - this._super.apply(this, arguments); + this._hashchangeHandler = function () { + _emberMetal.run(function () { + var path = _this.getURL(); + if (_emberMetal.get(_this, 'lastSetURL') === path) { + return; + } - _emberMetal.assert('Only arrays are allowed for \'classNameBindings\'', Array.isArray(this.classNameBindings)); - _emberMetal.assert('Only arrays of static class strings are allowed for \'classNames\'. For dynamic classes, use \'classNameBindings\'.', Array.isArray(this.classNames)); + _emberMetal.set(_this, 'lastSetURL', null); + + callback(path); + }); + }; + + window.addEventListener('hashchange', this._hashchangeHandler); }, /** - Standard CSS class names to apply to the view's outer element. This - property automatically inherits any class names defined by the view's - superclasses as well. - @property classNames - @type Array - @default ['ember-view'] - @public + Given a URL, formats it to be placed into the page as part + of an element's `href` attribute. + This is used, for example, when using the {{action}} helper + to generate a URL based on an event. + @private + @method formatURL + @param url {String} */ - classNames: EMPTY_ARRAY, + formatURL: function (url) { + return '#' + url; + }, /** - A list of properties of the view to apply as class names. If the property - is a string value, the value of that string will be applied as a class - name. - ```javascript - // Applies the 'high' class to the view element - Ember.Component.extend({ - classNameBindings: ['priority'], - priority: 'high' - }); - ``` - If the value of the property is a Boolean, the name of that property is - added as a dasherized class name. - ```javascript - // Applies the 'is-urgent' class to the view element - Ember.Component.extend({ - classNameBindings: ['isUrgent'], - isUrgent: true - }); - ``` - If you would prefer to use a custom value instead of the dasherized - property name, you can pass a binding like this: - ```javascript - // Applies the 'urgent' class to the view element - Ember.Component.extend({ - classNameBindings: ['isUrgent:urgent'], - isUrgent: true - }); - ``` - This list of properties is inherited from the component's superclasses as well. - @property classNameBindings - @type Array - @default [] - @public + Cleans up the HashLocation event listener. + @private + @method willDestroy */ - classNameBindings: EMPTY_ARRAY + willDestroy: function () { + this._removeEventListener(); + }, + + _removeEventListener: function () { + if (this._hashchangeHandler) { + window.removeEventListener('hashchange', this._hashchangeHandler); + } + } }); }); -enifed('ember-views/mixins/text_support', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { +enifed('ember-routing/location/history_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { + 'use strict'; + /** @module ember - @submodule ember-views + @submodule ember-routing */ - 'use strict'; + var popstateFired = false; - var KEY_EVENTS = { - 13: 'insertNewline', - 27: 'cancel' - }; + var _uuid = undefined; + + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + _uuid = function _uuid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r, v; + r = Math.random() * 16 | 0; + v = c === 'x' ? r : r & 3 | 8; + return v.toString(16); + }); + }; + } /** - `TextSupport` is a shared mixin used by both `Ember.TextField` and - `Ember.TextArea`. `TextSupport` adds a number of methods that allow you to - specify a controller action to invoke when a certain event is fired on your - text field or textarea. The specifed controller action would get the current - value of the field passed in as the only argument unless the value of - the field is empty. In that case, the instance of the field itself is passed - in as the only argument. - - Let's use the pressing of the escape key as an example. If you wanted to - invoke a controller action when a user presses the escape key while on your - field, you would use the `escape-press` attribute on your field like so: - - ```handlebars - {{! application.hbs}} - - {{input escape-press='alertUser'}} - ``` - - ```javascript - App = Ember.Application.create(); - - App.ApplicationController = Ember.Controller.extend({ - actions: { - alertUser: function ( currentValue ) { - alert( 'escape pressed, current value: ' + currentValue ); - } - } - }); - ``` - - The following chart is a visual representation of what takes place when the - escape key is pressed in this scenario: - - ``` - The Template - +---------------------------+ - | | - | escape-press='alertUser' | - | | TextSupport Mixin - +----+----------------------+ +-------------------------------+ - | | cancel method | - | escape button pressed | | - +-------------------------------> | checks for the `escape-press` | - | attribute and pulls out the | - +-------------------------------+ | `alertUser` value | - | action name 'alertUser' +-------------------------------+ - | sent to controller - v - Controller - +------------------------------------------ + - | | - | actions: { | - | alertUser: function( currentValue ){ | - | alert( 'the esc key was pressed!' ) | - | } | - | } | - | | - +-------------------------------------------+ - ``` - - Here are the events that we currently support along with the name of the - attribute you would need to use on your field. To reiterate, you would use the - attribute name like so: - - ```handlebars - {{input attribute-name='controllerAction'}} - ``` - - ``` - +--------------------+----------------+ - | | | - | event | attribute name | - +--------------------+----------------+ - | new line inserted | insert-newline | - | | | - | enter key pressed | insert-newline | - | | | - | cancel key pressed | escape-press | - | | | - | focusin | focus-in | - | | | - | focusout | focus-out | - | | | - | keypress | key-press | - | | | - | keyup | key-up | - | | | - | keydown | key-down | - +--------------------+----------------+ - ``` + Ember.HistoryLocation implements the location API using the browser's + history.pushState API. - @class TextSupport + @class HistoryLocation @namespace Ember - @uses Ember.TargetActionSupport - @extends Ember.Mixin + @extends Ember.Object @private */ - exports.default = _emberMetal.Mixin.create(_emberRuntime.TargetActionSupport, { - value: '', - - attributeBindings: ['autocapitalize', 'autocorrect', 'autofocus', 'disabled', 'form', 'maxlength', 'placeholder', 'readonly', 'required', 'selectionDirection', 'spellcheck', 'tabindex', 'title'], - placeholder: null, - disabled: false, - maxlength: null, + exports.default = _emberRuntime.Object.extend({ + implementation: 'history', init: function () { this._super.apply(this, arguments); - this.on('paste', this, this._elementValueDidChange); - this.on('cut', this, this._elementValueDidChange); - this.on('input', this, this._elementValueDidChange); + + var base = document.querySelector('base'); + var baseURL = ''; + if (base) { + baseURL = base.getAttribute('href'); + } + + _emberMetal.set(this, 'baseURL', baseURL); + _emberMetal.set(this, 'location', _emberMetal.get(this, 'location') || window.location); + + this._popstateHandler = undefined; }, /** - The action to be sent when the user presses the return key. - This is similar to the `{{action}}` helper, but is fired when - the user presses the return key when editing a text field, and sends - the value of the field as the context. - @property action - @type String - @default null - @private + Used to set state on first call to setURL + @private + @method initState */ - action: null, + initState: function () { + var history = _emberMetal.get(this, 'history') || window.history; + _emberMetal.set(this, 'history', history); + + if (history && 'state' in history) { + this.supportsHistory = true; + } + + this.replaceState(this.formatURL(this.getURL())); + }, /** - The event that should send the action. - Options are: - * `enter`: the user pressed enter - * `keyPress`: the user pressed a key - @property onEvent - @type String - @default enter + Will be pre-pended to path upon state change + @property rootURL + @default '/' @private */ - onEvent: 'enter', + rootURL: '/', /** - Whether the `keyUp` event that triggers an `action` to be sent continues - propagating to other views. - By default, when the user presses the return key on their keyboard and - the text field has an `action` set, the action will be sent to the view's - controller and the key event will stop propagating. - If you would like parent views to receive the `keyUp` event even after an - action has been dispatched, set `bubbles` to true. - @property bubbles - @type Boolean - @default false - @private + Returns the current `location.pathname` without `rootURL` or `baseURL` + @private + @method getURL + @return url {String} */ - bubbles: false, + getURL: function () { + var location = _emberMetal.get(this, 'location'); + var path = location.pathname; - interpretKeyEvents: function (event) { - var map = KEY_EVENTS; - var method = map[event.keyCode]; + var rootURL = _emberMetal.get(this, 'rootURL'); + var baseURL = _emberMetal.get(this, 'baseURL'); - this._elementValueDidChange(); - if (method) { - return this[method](event); - } - }, + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); + baseURL = baseURL.replace(/\/$/, ''); - _elementValueDidChange: function () { - _emberMetal.set(this, 'value', this.element.value); - }, + // remove baseURL and rootURL from start of path + var url = path.replace(new RegExp('^' + baseURL + '(?=/|$)'), '').replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - change: function (event) { - this._elementValueDidChange(event); - }, + var search = location.search || ''; + url += search + this.getHash(); - /** - Allows you to specify a controller action to invoke when either the `enter` - key is pressed or, in the case of the field being a textarea, when a newline - is inserted. To use this method, give your field an `insert-newline` - attribute. The value of that attribute should be the name of the action - in your controller that you wish to invoke. - For an example on how to use the `insert-newline` attribute, please - reference the example near the top of this file. - @method insertNewline - @param {Event} event - @private - */ - insertNewline: function (event) { - sendAction('enter', this, event); - sendAction('insert-newline', this, event); + return url; }, /** - Allows you to specify a controller action to invoke when the escape button - is pressed. To use this method, give your field an `escape-press` - attribute. The value of that attribute should be the name of the action - in your controller that you wish to invoke. - For an example on how to use the `escape-press` attribute, please reference - the example near the top of this file. - @method cancel - @param {Event} event - @private + Uses `history.pushState` to update the url without a page reload. + @private + @method setURL + @param path {String} */ - cancel: function (event) { - sendAction('escape-press', this, event); - }, + setURL: function (path) { + var state = this.getState(); + path = this.formatURL(path); - /** - Allows you to specify a controller action to invoke when a field receives - focus. To use this method, give your field a `focus-in` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `focus-in` attribute, please reference the - example near the top of this file. - @method focusIn - @param {Event} event - @private - */ - focusIn: function (event) { - sendAction('focus-in', this, event); + if (!state || state.path !== path) { + this.pushState(path); + } }, /** - Allows you to specify a controller action to invoke when a field loses - focus. To use this method, give your field a `focus-out` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `focus-out` attribute, please reference the - example near the top of this file. - @method focusOut - @param {Event} event - @private + Uses `history.replaceState` to update the url without a page reload + or history modification. + @private + @method replaceURL + @param path {String} */ - focusOut: function (event) { - this._elementValueDidChange(event); - sendAction('focus-out', this, event); - }, + replaceURL: function (path) { + var state = this.getState(); + path = this.formatURL(path); - /** - Allows you to specify a controller action to invoke when a key is pressed. - To use this method, give your field a `key-press` attribute. The value of - that attribute should be the name of the action in your controller you - that wish to invoke. - For an example on how to use the `key-press` attribute, please reference the - example near the top of this file. - @method keyPress - @param {Event} event - @private - */ - keyPress: function (event) { - sendAction('key-press', this, event); + if (!state || state.path !== path) { + this.replaceState(path); + } }, /** - Allows you to specify a controller action to invoke when a key-up event is - fired. To use this method, give your field a `key-up` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `key-up` attribute, please reference the - example near the top of this file. - @method keyUp - @param {Event} event - @private + Get the current `history.state`. Checks for if a polyfill is + required and if so fetches this._historyState. The state returned + from getState may be null if an iframe has changed a window's + history. + The object returned will contain a `path` for the given state as well + as a unique state `id`. The state index will allow the app to distinguish + between two states with similar paths but should be unique from one another. + @private + @method getState + @return state {Object} */ - keyUp: function (event) { - this.interpretKeyEvents(event); + getState: function () { + if (this.supportsHistory) { + return _emberMetal.get(this, 'history').state; + } - this.sendAction('key-up', _emberMetal.get(this, 'value'), event); + return this._historyState; }, /** - Allows you to specify a controller action to invoke when a key-down event is - fired. To use this method, give your field a `key-down` attribute. The value - of that attribute should be the name of the action in your controller that - you wish to invoke. - For an example on how to use the `key-down` attribute, please reference the - example near the top of this file. - @method keyDown - @param {Event} event + Pushes a new state. @private + @method pushState + @param path {String} */ - keyDown: function (event) { - this.sendAction('key-down', _emberMetal.get(this, 'value'), event); - } - }); - - // In principle, this shouldn't be necessary, but the legacy - // sendAction semantics for TextField are different from - // the component semantics so this method normalizes them. - function sendAction(eventName, view, event) { - var action = _emberMetal.get(view, 'attrs.' + eventName) || _emberMetal.get(view, eventName); - var on = _emberMetal.get(view, 'onEvent'); - var value = _emberMetal.get(view, 'value'); - - // back-compat support for keyPress as an event name even though - // it's also a method name that consumes the event (and therefore - // incompatible with sendAction semantics). - if (on === eventName || on === 'keyPress' && eventName === 'key-press') { - view.sendAction('action', value); - } + pushState: function (path) { + var state = { path: path }; + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + state.uuid = _uuid(); + } - view.sendAction(eventName, value); + _emberMetal.get(this, 'history').pushState(state, null, path); - if (action || on === eventName) { - if (!_emberMetal.get(view, 'bubbles')) { - event.stopPropagation(); - } - } - } -}); -enifed('ember-views/mixins/view_state_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; + this._historyState = state; - exports.default = _emberMetal.Mixin.create({ - _transitionTo: function (state) { - var priorState = this._currentState; - var currentState = this._currentState = this._states[state]; - this._state = state; + // used for webkit workaround + this._previousURL = this.getURL(); + }, - if (priorState && priorState.exit) { - priorState.exit(this); - } - if (currentState.enter) { - currentState.enter(this); + /** + Replaces the current state. + @private + @method replaceState + @param path {String} + */ + replaceState: function (path) { + var state = { path: path }; + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + state.uuid = _uuid(); } - } - }); -}); -enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-views/system/utils', 'ember-runtime/system/core_object', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberViewsSystemUtils, _emberRuntimeSystemCore_object, _emberViewsSystemJquery) { - 'use strict'; - var _Mixin$create; - - function K() { - return this; - } + _emberMetal.get(this, 'history').replaceState(state, null, path); - /** - @class ViewMixin - @namespace Ember - @private - */ - exports.default = _emberMetal.Mixin.create((_Mixin$create = { - concatenatedProperties: ['attributeBindings'] - }, _Mixin$create[_emberRuntimeSystemCore_object.POST_INIT] = function () { - this.trigger('didInitAttrs', { attrs: this.attrs }); - this.trigger('didReceiveAttrs', { newAttrs: this.attrs }); - }, _Mixin$create.nearestOfType = function (klass) { - var view = this.parentView; - var isOfType = klass instanceof _emberMetal.Mixin ? function (view) { - return klass.detect(view); - } : function (view) { - return klass.detect(view.constructor); - }; + this._historyState = state; - while (view) { - if (isOfType(view)) { - return view; - } - view = view.parentView; - } - }, _Mixin$create.nearestWithProperty = function (property) { - var view = this.parentView; + // used for webkit workaround + this._previousURL = this.getURL(); + }, - while (view) { - if (property in view) { - return view; - } - view = view.parentView; - } - }, _Mixin$create.rerender = function () { - return this._currentState.rerender(this); - }, _Mixin$create.element = _emberMetal.descriptor({ - configurable: false, - enumerable: false, - get: function () { - return this.renderer.getElement(this); - } - }), _Mixin$create.$ = function (sel) { - _emberMetal.assert('You cannot access this.$() on a component with `tagName: \'\'` specified.', this.tagName !== ''); - return this._currentState.$(this, sel); - }, _Mixin$create.appendTo = function (selector) { - var env = this._environment || _emberEnvironment.environment; - var target = undefined; + /** + Register a callback to be invoked whenever the browser + history changes, including using forward and back buttons. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + var _this = this; - if (env.hasDOM) { - target = typeof selector === 'string' ? document.querySelector(selector) : selector; + this._removeEventListener(); - _emberMetal.assert('You tried to append to (' + selector + ') but that isn\'t in the DOM', target); - _emberMetal.assert('You cannot append to an existing Ember.View.', !_emberViewsSystemUtils.matches(target, '.ember-view')); - _emberMetal.assert('You cannot append to an existing Ember.View.', (function () { - var node = target.parentNode; - while (node) { - if (node.nodeType !== 9 && _emberViewsSystemUtils.matches(node, '.ember-view')) { - return false; + this._popstateHandler = function () { + // Ignore initial page load popstate event in Chrome + if (!popstateFired) { + popstateFired = true; + if (_this.getURL() === _this._previousURL) { + return; } - - node = node.parentNode; } + callback(_this.getURL()); + }; - return true; - })()); - } else { - target = selector; - - _emberMetal.assert('You tried to append to a selector string (' + selector + ') in an environment without jQuery', typeof target !== 'string'); - _emberMetal.assert('You tried to append to a non-Element (' + selector + ') in an environment without jQuery', typeof selector.appendChild === 'function'); - } - - this.renderer.appendTo(this, target); - - return this; - }, _Mixin$create.renderToElement = function (tagName) { - tagName = tagName || 'body'; - - _emberMetal.deprecate('Using the `renderToElement` is deprecated in favor of `appendTo`. Called in ' + this.toString(), false, { - id: 'ember-views.render-to-element', - until: '2.12.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_code-rendertoelement-code' - }); + window.addEventListener('popstate', this._popstateHandler); + }, - var element = this.renderer.createElement(tagName); + /** + Used when using `{{action}}` helper. The url is always appended to the rootURL. + @private + @method formatURL + @param url {String} + @return formatted url {String} + */ + formatURL: function (url) { + var rootURL = _emberMetal.get(this, 'rootURL'); + var baseURL = _emberMetal.get(this, 'baseURL'); - this.renderer.appendTo(this, element); - return element; - }, _Mixin$create.replaceIn = function (selector) { - var target = _emberViewsSystemJquery.default(selector); + if (url !== '') { + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); + baseURL = baseURL.replace(/\/$/, ''); + } else if (baseURL[0] === '/' && rootURL[0] === '/') { + // if baseURL and rootURL both start with a slash + // ... remove trailing slash from baseURL if it exists + baseURL = baseURL.replace(/\/$/, ''); + } - _emberMetal.assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0); - _emberMetal.assert('You cannot replace an existing Ember.View.', !target.is('.ember-view') && !target.parents().is('.ember-view')); + return baseURL + rootURL + url; + }, - this.renderer.replaceIn(this, target[0]); + /** + Cleans up the HistoryLocation event listener. + @private + @method willDestroy + */ + willDestroy: function () { + this._removeEventListener(); + }, - return this; - }, _Mixin$create.append = function () { - return this.appendTo(document.body); - }, _Mixin$create.elementId = null, _Mixin$create.findElementInParentElement = function (parentElem) { - var id = '#' + this.elementId; - return _emberViewsSystemJquery.default(id)[0] || _emberViewsSystemJquery.default(id, parentElem)[0]; - }, _Mixin$create.willInsertElement = K, _Mixin$create.didInsertElement = K, _Mixin$create.willClearRender = K, _Mixin$create.destroy = function () { - this._super.apply(this, arguments); - this._currentState.destroy(this); - }, _Mixin$create.willDestroyElement = K, _Mixin$create.parentViewDidChange = K, _Mixin$create.tagName = null, _Mixin$create.init = function () { - this._super.apply(this, arguments); + /** + @private + Returns normalized location.hash + @method getHash + */ + getHash: _emberRoutingLocationApi.default._getHash, - if (!this.elementId && this.tagName !== '') { - this.elementId = _emberUtils.guidFor(this); + _removeEventListener: function () { + if (this._popstateHandler) { + window.removeEventListener('popstate', this._popstateHandler); + } } - - _emberMetal.deprecate('[DEPRECATED] didInitAttrs called in ' + this.toString() + '.', typeof this.didInitAttrs !== 'function', { - id: 'ember-views.did-init-attrs', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' - }); - - _emberMetal.assert('Using a custom `.render` function is no longer supported.', !this.render); - }, _Mixin$create.__defineNonEnumerable = function (property) { - this[property.name] = property.descriptor.value; - }, _Mixin$create.handleEvent = function (eventName, evt) { - return this._currentState.handleEvent(this, eventName, evt); - }, _Mixin$create)); + }); }); +enifed('ember-routing/location/none_location', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; -// .......................................................... -// TEMPLATE SUPPORT -// + /** + @module ember + @submodule ember-routing + */ -/** - Return the nearest ancestor that is an instance of the provided - class or mixin. - @method nearestOfType - @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself), - or an instance of Ember.Mixin. - @return Ember.View - @deprecated use `yield` and contextual components for composition instead. - @private -*/ + /** + Ember.NoneLocation does not interact with the browser. It is useful for + testing, or when you need to manage state with your Router, but temporarily + don't want it to muck with the URL (for example when you embed your + application in a larger page). + + @class NoneLocation + @namespace Ember + @extends Ember.Object + @private + */ + exports.default = _emberRuntime.Object.extend({ + implementation: 'none', + path: '', -/** - Return the nearest ancestor that has a given property. - @method nearestWithProperty - @param {String} property A property name - @return Ember.View - @deprecated use `yield` and contextual components for composition instead. - @private -*/ + detect: function () { + var rootURL = this.rootURL; -/** - Renders the view again. This will work regardless of whether the - view is already in the DOM or not. If the view is in the DOM, the - rendering process will be deferred to give bindings a chance - to synchronize. - If children were added during the rendering process using `appendChild`, - `rerender` will remove them, because they will be added again - if needed by the next `render`. - In general, if the display of your view changes, you should modify - the DOM element directly instead of manually calling `rerender`, which can - be slow. - @method rerender - @public -*/ + _emberMetal.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); + }, -// .......................................................... -// ELEMENT SUPPORT -// + /** + Will be pre-pended to path. + @private + @property rootURL + @default '/' + */ + rootURL: '/', -/** - Returns the current DOM element for the view. - @property element - @type DOMElement - @public -*/ + /** + Returns the current path without `rootURL`. + @private + @method getURL + @return {String} path + */ + getURL: function () { + var path = _emberMetal.get(this, 'path'); + var rootURL = _emberMetal.get(this, 'rootURL'); -/** - Returns a jQuery object for this view's element. If you pass in a selector - string, this method will return a jQuery object, using the current element - as its buffer. - For example, calling `view.$('li')` will return a jQuery object containing - all of the `li` elements inside the DOM element of this view. - @method $ - @param {String} [selector] a jQuery-compatible selector string - @return {jQuery} the jQuery object for the DOM node - @public -*/ + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); -/** - Appends the view's element to the specified parent element. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the given element until all bindings have - finished synchronizing. - This is not typically a function that you will need to call directly when - building your application. If you do need to use `appendTo`, be sure that - the target element you are providing is associated with an `Ember.Application` - and does not have an ancestor element that is associated with an Ember view. - @method appendTo - @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object - @return {Ember.View} receiver - @private -*/ + // remove rootURL from url + return path.replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); + }, -/** - Creates a new DOM element, renders the view into it, then returns the - element. - By default, the element created and rendered into will be a `BODY` element, - since this is the default context that views are rendered into when being - inserted directly into the DOM. - ```js - let element = view.renderToElement(); - element.tagName; // => "BODY" - ``` - You can override the kind of element rendered into and returned by - specifying an optional tag name as the first argument. - ```js - let element = view.renderToElement('table'); - element.tagName; // => "TABLE" - ``` - This method is useful if you want to render the view into an element that - is not in the document's body. Instead, a new `body` element, detached from - the DOM is returned. FastBoot uses this to serialize the rendered view into - a string for transmission over the network. - ```js - app.visit('/').then(function(instance) { - let element; - Ember.run(function() { - element = renderToElement(instance); - }); - res.send(serialize(element)); - }); - ``` - @method renderToElement - @param {String} tagName The tag of the element to create and render into. Defaults to "body". - @return {HTMLBodyElement} element - @deprecated Use appendTo instead. - @private -*/ + /** + Set the path and remembers what was set. Using this method + to change the path will not invoke the `updateURL` callback. + @private + @method setURL + @param path {String} + */ + setURL: function (path) { + _emberMetal.set(this, 'path', path); + }, -/** - Replaces the content of the specified parent element with this view's - element. If the view does not have an HTML representation yet, - the element will be generated automatically. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the given element until all bindings have - finished synchronizing - @method replaceIn - @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object - @return {Ember.View} received - @private -*/ + /** + Register a callback to be invoked when the path changes. These + callbacks will execute when the user presses the back or forward + button, but not after `setURL` is invoked. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + this.updateCallback = callback; + }, -/** - Appends the view's element to the document body. If the view does - not have an HTML representation yet - the element will be generated automatically. - If your application uses the `rootElement` property, you must append - the view within that element. Rendering views outside of the `rootElement` - is not supported. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the document body until all bindings have - finished synchronizing. - @method append - @return {Ember.View} receiver - @private -*/ + /** + Sets the path and calls the `updateURL` callback. + @private + @method handleURL + @param callback {Function} + */ + handleURL: function (url) { + _emberMetal.set(this, 'path', url); + this.updateCallback(url); + }, -/** - The HTML `id` of the view's element in the DOM. You can provide this - value yourself but it must be unique (just as in HTML): - ```handlebars - {{my-component elementId="a-really-cool-id"}} - ``` - If not manually set a default value will be provided by the framework. - Once rendered an element's `elementId` is considered immutable and you - should never change it. If you need to compute a dynamic value for the - `elementId`, you should do this when the component or element is being - instantiated: - ```javascript - export default Ember.Component.extend({ - init() { - this._super(...arguments); - let index = this.get('index'); - this.set('elementId', 'component-id' + index); + /** + Given a URL, formats it to be placed into the page as part + of an element's `href` attribute. + This is used, for example, when using the {{action}} helper + to generate a URL based on an event. + @private + @method formatURL + @param url {String} + @return {String} url + */ + formatURL: function (url) { + var rootURL = _emberMetal.get(this, 'rootURL'); + + if (url !== '') { + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); } - }); - ``` - @property elementId - @type String - @public -*/ -/** - Attempts to discover the element in the parent element. The default - implementation looks for an element with an ID of `elementId` (or the - view's guid if `elementId` is null). You can override this method to - provide your own form of lookup. For example, if you want to discover your - element using a CSS class name instead of an ID. - @method findElementInParentElement - @param {DOMElement} parentElement The parent's DOM element - @return {DOMElement} The discovered element - @private -*/ + return rootURL + url; + } + }); +}); +enifed('ember-routing/location/util', ['exports'], function (exports) { + /** + @private + + Returns the current `location.pathname`, normalized for IE inconsistencies. + */ + 'use strict'; + + exports.getPath = getPath; + exports.getQuery = getQuery; + exports.getHash = getHash; + exports.getFullPath = getFullPath; + exports.getOrigin = getOrigin; + exports.supportsHashChange = supportsHashChange; + exports.supportsHistory = supportsHistory; + exports.replacePath = replacePath; -/** - Called when a view is going to insert an element into the DOM. - @event willInsertElement - @public -*/ + function getPath(location) { + var pathname = location.pathname; + // Various versions of IE/Opera don't always return a leading slash + if (pathname[0] !== '/') { + pathname = '/' + pathname; + } -/** - Called when the element of the view has been inserted into the DOM. - Override this function to do any set up that requires an element - in the document body. - When a view has children, didInsertElement will be called on the - child view(s) first and on itself afterwards. - @event didInsertElement - @public -*/ + return pathname; + } -/** - Called when the view is about to rerender, but before anything has - been torn down. This is a good opportunity to tear down any manual - observers you have installed based on the DOM state - @event willClearRender - @public -*/ + /** + @private + + Returns the current `location.search`. + */ -/** - You must call `destroy` on a view to destroy the view (and all of its - child views). This will remove the view from any parent node, then make - sure that the DOM element managed by the view can be released by the - memory manager. - @method destroy - @private -*/ + function getQuery(location) { + return location.search; + } -/** - Called when the element of the view is going to be destroyed. Override - this function to do any teardown that requires an element, like removing - event listeners. - Please note: any property changes made during this event will have no - effect on object observers. - @event willDestroyElement - @public -*/ + /** + @private + + Returns the current `location.hash` by parsing location.href since browsers + inconsistently URL-decode `location.hash`. + + Should be passed the browser's `location` object as the first argument. + + https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + */ -/** - Called when the parentView property has changed. - @event parentViewDidChange - @private -*/ + function getHash(location) { + var href = location.href; + var hashIndex = href.indexOf('#'); -// .......................................................... -// STANDARD RENDER PROPERTIES -// + if (hashIndex === -1) { + return ''; + } else { + return href.substr(hashIndex); + } + } -/** - Tag name for the view's outer element. The tag name is only used when an - element is first created. If you change the `tagName` for an element, you - must destroy and recreate the view element. - By default, the render buffer will use a `
    ` tag for views. - @property tagName - @type String - @default null - @public -*/ + function getFullPath(location) { + return getPath(location) + getQuery(location) + getHash(location); + } -// We leave this null by default so we can tell the difference between -// the default case and a user-specified tag. + function getOrigin(location) { + var origin = location.origin; -// ....................................................... -// CORE DISPLAY METHODS -// + // Older browsers, especially IE, don't have origin + if (!origin) { + origin = location.protocol + '//' + location.hostname; -/** - Setup a view, but do not finish waking it up. - * configure `childViews` - * register the view with the global views hash, which is used for event - dispatch - @method init - @private -*/ + if (location.port) { + origin += ':' + location.port; + } + } -// ....................................................... -// EVENT HANDLING -// + return origin; + } -/** - Handle events from `Ember.EventDispatcher` - @method handleEvent - @param eventName {String} - @param evt {Event} - @private -*/ -enifed("ember-views/system/action_manager", ["exports"], function (exports) { - /** - @module ember - @submodule ember-views + /* + `documentMode` only exist in Internet Explorer, and it's tested because IE8 running in + IE7 compatibility mode claims to support `onhashchange` but actually does not. + + `global` is an object that may have an `onhashchange` property. + + @private + @function supportsHashChange */ - "use strict"; + function supportsHashChange(documentMode, global) { + return 'onhashchange' in global && (documentMode === undefined || documentMode > 7); + } - exports.default = ActionManager; + /* + `userAgent` is a user agent string. We use user agent testing here, because + the stock Android browser is known to have buggy versions of the History API, + in some Android versions. + + @private + @function supportsHistory + */ - function ActionManager() {} + function supportsHistory(userAgent, history) { + // Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + // The stock browser on Android 2.2 & 2.3, and 4.0.x returns positive on history support + // Unfortunately support is really buggy and there is no clean way to detect + // these bugs, so we fall back to a user agent sniff :( + + // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies + // itself as 'Mobile Safari' as well, nor Windows Phone. + if ((userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 4.0') !== -1) && userAgent.indexOf('Mobile Safari') !== -1 && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Windows Phone') === -1) { + return false; + } + + return !!(history && 'pushState' in history); + } /** - Global action id hash. + Replaces the current location, making sure we explicitly include the origin + to prevent redirecting to a different origin. @private - @property registeredActions - @type Object */ - ActionManager.registeredActions = {}; + + function replacePath(location, path) { + location.replace(getOrigin(location) + path); + } }); -enifed('ember-views/system/event_dispatcher', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-environment', 'ember-views/compat/fallback-view-registry'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberViewsSystemJquery, _emberViewsSystemAction_manager, _emberEnvironment, _emberViewsCompatFallbackViewRegistry) { +enifed('ember-routing/services/router', ['exports', 'ember-runtime', 'ember-metal', 'ember-routing/system/dsl'], function (exports, _emberRuntime, _emberMetal, _emberRoutingSystemDsl) { /** @module ember - @submodule ember-views + @submodule ember-routing */ 'use strict'; - var ROOT_ELEMENT_CLASS = 'ember-application'; - var ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; - /** - `Ember.EventDispatcher` handles delegating browser events to their - corresponding `Ember.Views.` For example, when you click on a view, - `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets - called. + The Router service is the public API that provides component/view layer + access to the router. - @class EventDispatcher - @namespace Ember - @private - @extends Ember.Object - */ - exports.default = _emberRuntime.Object.extend({ + @public + @class RouterService + @category ember-routing-router-service + */ + var RouterService = _emberRuntime.Service.extend({ + currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), + currentURL: _emberRuntime.readOnly('router.currentURL'), + location: _emberRuntime.readOnly('router.location'), + rootURL: _emberRuntime.readOnly('router.rootURL'), /** - The set of events names (and associated handler function names) to be setup - and dispatched by the `EventDispatcher`. Modifications to this list can be done - at setup time, generally via the `Ember.Application.customEvents` hash. - To add new events to be listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - paste: 'paste' - } - }); - ``` - To prevent default events from being listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - mouseenter: null, - mouseleave: null - } - }); - ``` - @property events - @type Object - @private - */ - events: { - touchstart: 'touchStart', - touchmove: 'touchMove', - touchend: 'touchEnd', - touchcancel: 'touchCancel', - keydown: 'keyDown', - keyup: 'keyUp', - keypress: 'keyPress', - mousedown: 'mouseDown', - mouseup: 'mouseUp', - contextmenu: 'contextMenu', - click: 'click', - dblclick: 'doubleClick', - mousemove: 'mouseMove', - focusin: 'focusIn', - focusout: 'focusOut', - mouseenter: 'mouseEnter', - mouseleave: 'mouseLeave', - submit: 'submit', - input: 'input', - change: 'change', - dragstart: 'dragStart', - drag: 'drag', - dragenter: 'dragEnter', - dragleave: 'dragLeave', - dragover: 'dragOver', - drop: 'drop', - dragend: 'dragEnd' + 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 + @category ember-routing-router-service + @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 + @public + */ + transitionTo: function () { + var _router; + + return (_router = this.router).transitionTo.apply(_router, arguments); }, /** - The root DOM element to which event listeners should be attached. Event - listeners will be attached to the document unless this is overridden. - Can be specified as a DOMElement or a selector string. - The default body is a string since this may be evaluated before document.body - exists in the DOM. - @private - @property rootElement - @type DOMElement - @default 'body' - */ - rootElement: 'body', + Transition into another route while replacing the current URL, if possible. + The route may be either a single route or route path: + See [Route.replaceWith](http://emberjs.com/api/classes/Ember.Route.html#method_replaceWith) for more info. + @method replaceWith + @category ember-routing-router-service + @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 + @public + */ + replaceWith: function () { + var _router2; - /** - It enables events to be dispatched to the view's `eventManager.` When present, - this object takes precedence over handling of events on the view itself. - Note that most Ember applications do not use this feature. If your app also - does not use it, consider setting this property to false to gain some performance - improvement by allowing the EventDispatcher to skip the search for the - `eventManager` on the view tree. - ```javascript - let EventDispatcher = Em.EventDispatcher.extend({ - events: { - click : 'click', - focusin : 'focusIn', - focusout : 'focusOut', - change : 'change' - }, - canDispatchToEventManager: false - }); - container.register('event_dispatcher:main', EventDispatcher); - ``` - @property canDispatchToEventManager - @type boolean - @default 'true' - @since 1.7.0 - @private - */ - canDispatchToEventManager: true, + return (_router2 = this.router).replaceWith.apply(_router2, arguments); + } + }); - init: function () { - this._super(); - _emberMetal.assert('EventDispatcher should never be instantiated in fastboot mode. Please report this as an Ember bug.', _emberEnvironment.environment.hasDOM); - }, + exports.default = RouterService; +}); +enifed('ember-routing/services/routing', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'ember-routing/utils'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _emberRoutingUtils) { + /** + @module ember + @submodule ember-routing + */ - /** - Sets up event listeners for standard browser events. - This will be called after the browser sends a `DOMContentReady` event. By - default, it will set up all of the listeners on the document body. If you - would like to register the listeners on a different element, set the event - dispatcher's `root` property. - @private - @method setup - @param addedEvents {Object} - */ - setup: function (addedEvents, rootElement) { - var event = undefined; - var events = this._finalEvents = _emberUtils.assign({}, _emberMetal.get(this, 'events'), addedEvents); + 'use strict'; - if (!_emberMetal.isNone(rootElement)) { - _emberMetal.set(this, 'rootElement', rootElement); - } + /** + The Routing service is used by LinkComponent, and provides facilities for + the component/view layer to interact with the router. + + While still private, this service can eventually be opened up, and provides + the set of API needed for components to control routing without interacting + with router internals. + + @private + @class RoutingService + */ + exports.default = _emberRuntime.Service.extend({ + router: null, - rootElement = _emberViewsSystemJquery.default(_emberMetal.get(this, 'rootElement')); + targetState: _emberRuntime.readOnly('router.targetState'), + currentState: _emberRuntime.readOnly('router.currentState'), + currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), + currentPath: _emberRuntime.readOnly('router.currentPath'), - _emberMetal.assert('You cannot use the same root element (' + (rootElement.selector || rootElement[0].tagName) + ') multiple times in an Ember.Application', !rootElement.is(ROOT_ELEMENT_SELECTOR)); - _emberMetal.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length); - _emberMetal.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find(ROOT_ELEMENT_SELECTOR).length); + availableRoutes: function () { + return Object.keys(_emberMetal.get(this, 'router').router.recognizer.names); + }, - rootElement.addClass(ROOT_ELEMENT_CLASS); + hasRoute: function (routeName) { + return _emberMetal.get(this, 'router').hasRoute(routeName); + }, - if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) { - throw new TypeError('Unable to add \'' + ROOT_ELEMENT_CLASS + '\' class to root element (' + (rootElement.selector || rootElement[0].tagName) + '). Make sure you set rootElement to the body or an element in the body.'); - } + transitionTo: function (routeName, models, queryParams, shouldReplace) { + var router = _emberMetal.get(this, 'router'); - for (event in events) { - if (events.hasOwnProperty(event)) { - this.setupHandler(rootElement, event, events[event]); - } + var transition = router._doTransition(routeName, models, queryParams); + + if (shouldReplace) { + transition.method('replace'); } - }, - /** - Registers an event listener on the rootElement. If the given event is - triggered, the provided event handler will be triggered on the target view. - If the target view does not implement the event handler, or if the handler - returns `false`, the parent view will be called. The event will continue to - bubble to each successive parent view until it reaches the top. - @private - @method setupHandler - @param {Element} rootElement - @param {String} event the browser-originated event to listen to - @param {String} eventName the name of the method to call on the view - */ - setupHandler: function (rootElement, event, eventName) { - var self = this; + return transition; + }, - var owner = _emberUtils.getOwner(this); - var viewRegistry = owner && owner.lookup('-view-registry:main') || _emberViewsCompatFallbackViewRegistry.default; + normalizeQueryParams: function (routeName, models, queryParams) { + var router = _emberMetal.get(this, 'router'); + router._prepareQueryParams(routeName, models, queryParams); + }, - if (eventName === null) { + generateURL: function (routeName, models, queryParams) { + var router = _emberMetal.get(this, 'router'); + if (!router.router) { return; } - rootElement.on(event + '.ember', '.ember-view', function (evt, triggeringManager) { - var view = viewRegistry[this.id]; - var result = true; - - var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; + var visibleQueryParams = {}; + _emberUtils.assign(visibleQueryParams, queryParams); - if (manager && manager !== triggeringManager) { - result = self._dispatchEvent(manager, evt, eventName, view); - } else if (view) { - result = self._bubbleEvent(view, evt, eventName); - } + this.normalizeQueryParams(routeName, models, visibleQueryParams); - return result; - }); + var args = _emberRoutingUtils.routeArgs(routeName, models, visibleQueryParams); + return router.generate.apply(router, args); + }, - rootElement.on(event + '.ember', '[data-ember-action]', function (evt) { - var actionId = _emberViewsSystemJquery.default(evt.currentTarget).attr('data-ember-action'); - var actions = _emberViewsSystemAction_manager.default.registeredActions[actionId]; + isActiveForRoute: function (contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { + var router = _emberMetal.get(this, 'router'); - // In Glimmer2 this attribute is set to an empty string and an additional - // attribute it set for each action on a given element. In this case, the - // attributes need to be read so that a proper set of action handlers can - // be coalesced. - if (actionId === '') { - var attributes = evt.currentTarget.attributes; - var attributeCount = attributes.length; + var handlers = router.router.recognizer.handlersFor(routeName); + var leafName = handlers[handlers.length - 1].handler; + var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); - actions = []; + // NOTE: any ugliness in the calculation of activeness is largely + // due to the fact that we support automatic normalizing of + // `resource` -> `resource.index`, even though there might be + // dynamic segments / query params defined on `resource.index` + // which complicates (and makes somewhat ambiguous) the calculation + // of activeness for links that link to `resource` instead of + // directly to `resource.index`. - for (var i = 0; i < attributeCount; i++) { - var attr = attributes.item(i); - var attrName = attr.name; + // if we don't have enough contexts revert back to full route name + // this is because the leaf route will use one of the contexts + if (contexts.length > maximumContexts) { + routeName = leafName; + } - if (attrName.indexOf('data-ember-action-') === 0) { - actions = actions.concat(_emberViewsSystemAction_manager.default.registeredActions[attr.value]); - } - } - } + return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified); + } + }); - // We have to check for actions here since in some cases, jQuery will trigger - // an event on `removeChild` (i.e. focusout) after we've already torn down the - // action handlers for the view. - if (!actions) { - return; - } + function numberOfContextsAcceptedByHandler(handler, handlerInfos) { + var req = 0; + for (var i = 0; i < handlerInfos.length; i++) { + req += handlerInfos[i].names.length; + if (handlerInfos[i].handler === handler) { + break; + } + } - for (var index = 0; index < actions.length; index++) { - var action = actions[index]; + return req; + } +}); +enifed('ember-routing/system/cache', ['exports', 'ember-utils', 'ember-runtime'], function (exports, _emberUtils, _emberRuntime) { + 'use strict'; - if (action && action.eventName === eventName) { - return action.handler(evt); - } - } - }); + /** + A two-tiered cache with support for fallback values when doing lookups. + Uses "buckets" and then "keys" to cache values. + + @private + @class BucketCache + */ + exports.default = _emberRuntime.Object.extend({ + init: function () { + this.cache = new _emberUtils.EmptyObject(); }, - _findNearestEventManager: function (view, eventName) { - var manager = null; - - while (view) { - manager = _emberMetal.get(view, 'eventManager'); - if (manager && manager[eventName]) { - break; - } - - view = _emberMetal.get(view, 'parentView'); - } - - return manager; + has: function (bucketKey) { + return !!this.cache[bucketKey]; }, - _dispatchEvent: function (object, evt, eventName, view) { - var result = true; + stash: function (bucketKey, key, value) { + var bucket = this.cache[bucketKey]; - var handler = object[eventName]; - if (typeof handler === 'function') { - result = _emberMetal.run(object, handler, evt, view); - // Do not preventDefault in eventManagers. - evt.stopPropagation(); - } else { - result = this._bubbleEvent(view, evt, eventName); + if (!bucket) { + bucket = this.cache[bucketKey] = new _emberUtils.EmptyObject(); } - return result; - }, - - _bubbleEvent: function (view, evt, eventName) { - return view.handleEvent(eventName, evt); + bucket[key] = value; }, - destroy: function () { - var rootElement = _emberMetal.get(this, 'rootElement'); - _emberViewsSystemJquery.default(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); - return this._super.apply(this, arguments); - }, + lookup: function (bucketKey, prop, defaultValue) { + var cache = this.cache; + if (!this.has(bucketKey)) { + return defaultValue; + } - toString: function () { - return '(EventDispatcher)'; + var bucket = cache[bucketKey]; + if (prop in bucket && bucket[prop] !== undefined) { + return bucket[prop]; + } else { + return defaultValue; + } } }); }); -enifed('ember-views/system/ext', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed("ember-routing/system/controller_for", ["exports"], function (exports) { /** @module ember - @submodule ember-views + @submodule ember-routing */ - 'use strict'; + /** + Finds a controller instance. + + @for Ember + @method controllerFor + @private + */ + "use strict"; - // Add a new named queue for rendering views that happens - // after bindings have synced, and a queue for scheduling actions - // that should occur after view rendering. - _emberMetal.run._addQueue('render', 'actions'); - _emberMetal.run._addQueue('afterRender', 'render'); + exports.default = controllerFor; + + function controllerFor(container, controllerName, lookupOptions) { + return container.lookup("controller:" + controllerName, lookupOptions); + } }); -enifed('ember-views/system/jquery', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { +enifed('ember-routing/system/dsl', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { 'use strict'; - var jQuery = undefined; + /** + @module ember + @submodule ember-routing + */ - if (_emberEnvironment.environment.hasDOM) { - jQuery = _emberEnvironment.context.imports.jQuery; + var uuid = 0; - if (jQuery) { - if (jQuery.event.addProp) { - jQuery.event.addProp('dataTransfer'); - } else { - // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents - ['dragstart', 'drag', 'dragenter', 'dragleave', 'dragover', 'drop', 'dragend'].forEach(function (eventName) { - jQuery.event.fixHooks[eventName] = { - props: ['dataTransfer'] - }; - }); - } + var DSL = (function () { + function DSL(name, options) { + babelHelpers.classCallCheck(this, DSL); + + this.parent = name; + this.enableLoadingSubstates = options && options.enableLoadingSubstates; + this.matches = []; + this.explicitIndex = undefined; + this.options = options; } - } - exports.default = jQuery; -}); -enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + DSL.prototype.route = function route(name, options, callback) { + if (options === undefined) options = {}; - exports.default = lookupPartial; - exports.hasPartial = hasPartial; + var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; + if (arguments.length === 2 && typeof options === 'function') { + callback = options; + options = {}; + } - function parseUnderscoredName(templateName) { - var nameParts = templateName.split('/'); - var lastPart = nameParts[nameParts.length - 1]; + _emberMetal.assert('\'' + name + '\' cannot be used as a route name.', (function () { + if (options.overrideNameAssertion === true) { + return true; + } - nameParts[nameParts.length - 1] = '_' + lastPart; + return ['array', 'basic', 'object', 'application'].indexOf(name) === -1; + })()); - return nameParts.join('/'); - } + if (this.enableLoadingSubstates) { + createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace }); + createRoute(this, name + '_error', { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); + } - function lookupPartial(templateName, owner) { - if (templateName == null) { - return; - } + if (callback) { + var fullName = getFullName(this, name, options.resetNamespace); + var dsl = new DSL(fullName, this.options); - var template = templateFor(owner, parseUnderscoredName(templateName), templateName); + createRoute(dsl, 'loading'); + createRoute(dsl, 'error', { path: dummyErrorRoute }); - _emberMetal.assert('Unable to find partial with name "' + templateName + '"', !!template); + callback.call(dsl); - return template; - } + createRoute(this, name, options, dsl.generate()); + } else { + createRoute(this, name, options); + } + }; - function hasPartial(name, owner) { - if (!owner) { - throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); - } + DSL.prototype.push = function push(url, name, callback, serialize) { + var parts = name.split('.'); - return owner.hasRegistration('template:' + parseUnderscoredName(name)) || owner.hasRegistration('template:' + name); - } + if (this.options.engineInfo) { + var localFullName = name.slice(this.options.engineInfo.fullName.length + 1); + var routeInfo = _emberUtils.assign({ localFullName: localFullName }, this.options.engineInfo); - function templateFor(owner, underscored, name) { - if (!name) { - return; - } - _emberMetal.assert('templateNames are not allowed to contain periods: ' + name, name.indexOf('.') === -1); + if (serialize) { + routeInfo.serializeMethod = serialize; + } - if (!owner) { - throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); - } + this.options.addRouteForEngine(name, routeInfo); + } else if (serialize) { + throw new Error('Defining a route serializer on route \'' + name + '\' outside an Engine is not allowed.'); + } - return owner.lookup('template:' + underscored) || owner.lookup('template:' + name); - } -}); -enifed('ember-views/system/utils', ['exports', 'ember-utils'], function (exports, _emberUtils) { - /* globals Element */ - 'use strict'; + if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { + this.explicitIndex = true; + } - exports.isSimpleClick = isSimpleClick; - exports.getRootViews = getRootViews; - exports.getViewId = getViewId; - exports.getViewElement = getViewElement; - exports.initViewElement = initViewElement; - exports.setViewElement = setViewElement; - exports.getChildViews = getChildViews; - exports.initChildViews = initChildViews; - exports.addChildView = addChildView; - exports.collectChildViews = collectChildViews; - exports.getViewBounds = getViewBounds; - exports.getViewRange = getViewRange; - exports.getViewClientRects = getViewClientRects; - exports.getViewBoundingClientRect = getViewBoundingClientRect; - exports.matches = matches; + this.matches.push([url, name, callback]); + }; - /** - @module ember - @submodule ember-views - */ + DSL.prototype.resource = function resource(name, options, callback) { + if (options === undefined) options = {}; - function isSimpleClick(event) { - var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; - var secondaryClick = event.which > 1; // IE9 may return undefined + if (arguments.length === 2 && typeof options === 'function') { + callback = options; + options = {}; + } - return !modifier && !secondaryClick; - } + options.resetNamespace = true; + _emberMetal.deprecate('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.', false, { id: 'ember-routing.router-resource', until: '3.0.0' }); + this.route(name, options, callback); + }; - var STYLE_WARNING = '' + 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + 'please ensure that values being bound are properly escaped. For more information, ' + 'including how to disable this warning, see ' + 'http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.'; + DSL.prototype.generate = function generate() { + var dslMatches = this.matches; - exports.STYLE_WARNING = STYLE_WARNING; - /** - @private - @method getRootViews - @param {Object} owner - */ + if (!this.explicitIndex) { + this.route('index', { path: '/' }); + } - function getRootViews(owner) { - var registry = owner.lookup('-view-registry:main'); + return function (match) { + for (var i = 0; i < dslMatches.length; i++) { + var dslMatch = dslMatches[i]; + match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); + } + }; + }; - var rootViews = []; + DSL.prototype.mount = function mount(_name) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - Object.keys(registry).forEach(function (id) { - var view = registry[id]; + var engineRouteMap = this.options.resolveRouteMap(_name); + var name = _name; - if (view.parentView === null) { - rootViews.push(view); + if (options.as) { + name = options.as; } - }); - return rootViews; - } + var fullName = getFullName(this, name, options.resetNamespace); - /** - @private - @method getViewId - @param {Ember.View} view - */ + var engineInfo = { + name: _name, + instanceId: uuid++, + mountPoint: fullName, + fullName: fullName + }; - function getViewId(view) { - if (view.tagName === '') { - return _emberUtils.guidFor(view); - } else { - return view.elementId || _emberUtils.guidFor(view); - } - } + var path = options.path; - var VIEW_ELEMENT = _emberUtils.symbol('VIEW_ELEMENT'); + if (typeof path !== 'string') { + path = '/' + name; + } - /** - @private - @method getViewElement - @param {Ember.View} view - */ + var callback = undefined; + var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; + if (engineRouteMap) { + var shouldResetEngineInfo = false; + var oldEngineInfo = this.options.engineInfo; + if (oldEngineInfo) { + shouldResetEngineInfo = true; + this.options.engineInfo = engineInfo; + } - function getViewElement(view) { - return view[VIEW_ELEMENT]; - } + var optionsForChild = _emberUtils.assign({ engineInfo: engineInfo }, this.options); + var childDSL = new DSL(fullName, optionsForChild); - function initViewElement(view) { - view[VIEW_ELEMENT] = null; - } + createRoute(childDSL, 'loading'); + createRoute(childDSL, 'error', { path: dummyErrorRoute }); - function setViewElement(view, element) { - return view[VIEW_ELEMENT] = element; - } + engineRouteMap.class.call(childDSL); - var CHILD_VIEW_IDS = _emberUtils.symbol('CHILD_VIEW_IDS'); + callback = childDSL.generate(); - /** - @private - @method getChildViews - @param {Ember.View} view - */ + if (shouldResetEngineInfo) { + this.options.engineInfo = oldEngineInfo; + } + } - function getChildViews(view) { - var owner = _emberUtils.getOwner(view); - var registry = owner.lookup('-view-registry:main'); - return collectChildViews(view, registry); - } + var localFullName = 'application'; + var routeInfo = _emberUtils.assign({ localFullName: localFullName }, engineInfo); - function initChildViews(view) { - view[CHILD_VIEW_IDS] = []; - } + if (this.enableLoadingSubstates) { + // These values are important to register the loading routes under their + // proper names for the Router and within the Engine's registry. + var substateName = name + '_loading'; + var _localFullName = 'application_loading'; + var _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); + createRoute(this, substateName, { resetNamespace: options.resetNamespace }); + this.options.addRouteForEngine(substateName, _routeInfo); - function addChildView(parent, child) { - parent[CHILD_VIEW_IDS].push(getViewId(child)); - } + substateName = name + '_error'; + _localFullName = 'application_error'; + _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); + createRoute(this, substateName, { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); + this.options.addRouteForEngine(substateName, _routeInfo); + } - function collectChildViews(view, registry) { - var ids = []; - var views = []; + this.options.addRouteForEngine(fullName, routeInfo); - view[CHILD_VIEW_IDS].forEach(function (id) { - var view = registry[id]; + this.push(path, fullName, callback); + }; - if (view && !view.isDestroying && !view.isDestroyed && ids.indexOf(id) === -1) { - ids.push(id); - views.push(view); - } - }); + return DSL; + })(); - view[CHILD_VIEW_IDS] = ids; + exports.default = DSL; - return views; + function canNest(dsl) { + return dsl.parent && dsl.parent !== 'application'; } - /** - @private - @method getViewBounds - @param {Ember.View} view - */ - - function getViewBounds(view) { - return view.renderer.getBounds(view); + function getFullName(dsl, name, resetNamespace) { + if (canNest(dsl) && resetNamespace !== true) { + return dsl.parent + '.' + name; + } else { + return name; + } } - /** - @private - @method getViewRange - @param {Ember.View} view - */ + function createRoute(dsl, name, options, callback) { + if (options === undefined) options = {}; - function getViewRange(view) { - var bounds = getViewBounds(view); + var fullName = getFullName(dsl, name, options.resetNamespace); - var range = document.createRange(); - range.setStartBefore(bounds.firstNode); - range.setEndAfter(bounds.lastNode); + if (typeof options.path !== 'string') { + options.path = '/' + name; + } - return range; + dsl.push(options.path, fullName, callback, options.serialize); } - /** - `getViewClientRects` provides information about the position of the border - box edges of a view relative to the viewport. - - It is only intended to be used by development tools like the Ember Inspector - and may not work on older browsers. - - @private - @method getViewClientRects - @param {Ember.View} view - */ + DSL.map = function (callback) { + var dsl = new DSL(); + callback.call(dsl); + return dsl; + }; +}); +enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal', 'container'], function (exports, _emberMetal, _container) { + 'use strict'; - function getViewClientRects(view) { - var range = getViewRange(view); - return range.getClientRects(); - } + exports.generateControllerFactory = generateControllerFactory; + exports.default = generateController; /** - `getViewBoundingClientRect` provides information about the position of the - bounding border box edges of a view relative to the viewport. - - It is only intended to be used by development tools like the Ember Inpsector - and may not work on older browsers. - - @private - @method getViewBoundingClientRect - @param {Ember.View} view + @module ember + @submodule ember-routing */ - function getViewBoundingClientRect(view) { - var range = getViewRange(view); - return range.getBoundingClientRect(); - } - /** - Determines if the element matches the specified selector. + Generates a controller factory + @for Ember + @method generateControllerFactory @private - @method matches - @param {DOMElement} el - @param {String} selector */ - var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector); - - exports.elMatches = elMatches; - - function matches(el, selector) { - return elMatches.call(el, selector); - } -}); -enifed('ember-views/utils/lookup-component', ['exports', 'container'], function (exports, _container) { - 'use strict'; - - exports.default = lookupComponent; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - - function lookupComponentPair(componentLookup, owner, name, options) { - var component = componentLookup.componentFor(name, owner, options); - var layout = componentLookup.layoutFor(name, owner, options); - - var result = { layout: layout, component: component }; - - if (layout && !component) { - result.component = owner._lookupFactory(_container.privatize(_templateObject)); - } - - return result; - } - function lookupComponent(owner, name, options) { - var componentLookup = owner.lookup('component-lookup:main'); + function generateControllerFactory(owner, controllerName, context) { + var Factory = owner[_container.FACTORY_FOR]('controller:basic').class; - var source = options && options.source; + Factory = Factory.extend({ + toString: function () { + return '(generated ' + controllerName + ' controller)'; + } + }); - if (source) { - var localResult = lookupComponentPair(componentLookup, owner, name, options); + var fullName = 'controller:' + controllerName; - if (localResult.component || localResult.layout) { - return localResult; - } - } + owner.register(fullName, Factory); - return lookupComponentPair(componentLookup, owner, name); + return Factory; } -}); -enifed('ember-views/views/core_view', ['exports', 'ember-runtime', 'ember-views/system/utils', 'ember-views/views/states'], function (exports, _emberRuntime, _emberViewsSystemUtils, _emberViewsViewsStates) { - 'use strict'; /** - `Ember.CoreView` is an abstract class that exists to give view-like behavior - to both Ember's main view class `Ember.Component` and other classes that don't need - the full functionality of `Ember.Component`. - - Unless you have specific needs for `CoreView`, you will use `Ember.Component` - in your applications. + Generates and instantiates a controller extending from `controller:basic` + if present, or `Ember.Controller` if not. - @class CoreView - @namespace Ember - @extends Ember.Object - @deprecated Use `Ember.Component` instead. - @uses Ember.Evented - @uses Ember.ActionHandler + @for Ember + @method generateController @private + @since 1.3.0 */ - var CoreView = _emberRuntime.FrameworkObject.extend(_emberRuntime.Evented, _emberRuntime.ActionHandler, { - isView: true, - - _states: _emberViewsViewsStates.cloneStates(_emberViewsViewsStates.states), - - init: function () { - this._super.apply(this, arguments); - this._state = 'preRender'; - this._currentState = this._states.preRender; - - _emberViewsSystemUtils.initViewElement(this); - - if (!this.renderer) { - throw new Error('Cannot instantiate a component without a renderer. Please ensure that you are creating ' + this + ' with a proper container/registry.'); - } - }, - /** - If the view is currently inserted into the DOM of a parent view, this - property will point to the parent of the view. - @property parentView - @type Ember.View - @default null - @private - */ - parentView: null, + function generateController(owner, controllerName) { + generateControllerFactory(owner, controllerName); - instrumentDetails: function (hash) { - hash.object = this.toString(); - hash.containerKey = this._debugContainerKey; - hash.view = this; - return hash; - }, + var fullName = 'controller:' + controllerName; + var instance = owner.lookup(fullName); - /** - Override the default event firing from `Ember.Evented` to - also call methods with the given name. - @method trigger - @param name {String} - @private - */ - trigger: function () { - this._super.apply(this, arguments); - var name = arguments[0]; - var method = this[name]; - if (method) { - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - return method.apply(this, args); + _emberMetal.runInDebug(function () { + if (_emberMetal.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { + _emberMetal.info('generated -> ' + fullName, { fullName: fullName }); } - }, - - has: function (name) { - return _emberRuntime.typeOf(this[name]) === 'function' || this._super(name); - } - }); + }); - _emberRuntime.deprecateUnderscoreActions(CoreView); + return instance; + } +}); +enifed('ember-routing/system/query_params', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { + 'use strict'; - CoreView.reopenClass({ - isViewFactory: true + exports.default = _emberRuntime.Object.extend({ + isQueryParams: true, + values: null }); - - exports.default = CoreView; }); -enifed('ember-views/views/states', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberViewsViewsStatesPre_render, _emberViewsViewsStatesHas_element, _emberViewsViewsStatesIn_dom, _emberViewsViewsStatesDestroying) { +enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-routing/system/generate_controller', 'ember-routing/utils', 'container'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberRoutingSystemGenerate_controller, _emberRoutingUtils, _container) { 'use strict'; - exports.cloneStates = cloneStates; + exports.defaultSerialize = defaultSerialize; + exports.hasDefaultSerialize = hasDefaultSerialize; + var slice = Array.prototype.slice; - function cloneStates(from) { - var into = {}; + function K() { + return this; + } + + function defaultSerialize(model, params) { + if (params.length < 1 || !model) { + return; + } - into._default = {}; - into.preRender = Object.create(into._default); - into.destroying = Object.create(into._default); - into.hasElement = Object.create(into._default); - into.inDOM = Object.create(into.hasElement); + var name = params[0]; + var object = {}; - for (var stateName in from) { - if (!from.hasOwnProperty(stateName)) { - continue; + if (params.length === 1) { + if (name in model) { + object[name] = _emberMetal.get(model, name); + } else if (/_id$/.test(name)) { + object[name] = _emberMetal.get(model, 'id'); } - _emberUtils.assign(into[stateName], from[stateName]); + } else { + object = _emberMetal.getProperties(model, params); } - return into; + return object; } - /* - Describe how the specified actions should behave in the various - states that a view can exist in. Possible states: - - * preRender: when a view is first instantiated, and after its - element was destroyed, it is in the preRender state - * hasElement: the DOM representation of the view is created, - and is ready to be inserted - * inDOM: once a view has been inserted into the DOM it is in - the inDOM state. A view spends the vast majority of its - existence in this state. - * destroyed: once a view has been destroyed (using the destroy - method), it is in this state. No further actions can be invoked - on a destroyed view. - */ - var states = { - _default: _emberViewsViewsStatesDefault.default, - preRender: _emberViewsViewsStatesPre_render.default, - inDOM: _emberViewsViewsStatesIn_dom.default, - hasElement: _emberViewsViewsStatesHas_element.default, - destroying: _emberViewsViewsStatesDestroying.default - }; - exports.states = states; -}); -enifed('ember-views/views/states/default', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + var DEFAULT_SERIALIZE = _emberUtils.symbol('DEFAULT_SERIALIZE'); + + defaultSerialize[DEFAULT_SERIALIZE] = true; + + function hasDefaultSerialize(route) { + return !!route.serialize[DEFAULT_SERIALIZE]; + } /** @module ember - @submodule ember-views + @submodule ember-routing */ - exports.default = { - // appendChild is only legal while rendering the buffer. - appendChild: function () { - throw new _emberMetal.Error('You can\'t use appendChild outside of the rendering process'); - }, - - $: function () { - return undefined; - }, - - // Handle events from `Ember.EventDispatcher` - handleEvent: function () { - return true; // continue event propagation - }, - - rerender: function () {}, - - destroy: function () {} - }; -}); -enifed('ember-views/views/states/destroying', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/default'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesDefault) { - 'use strict'; /** - @module ember - @submodule ember-views + The `Ember.Route` class is used to define individual routes. Refer to + the [routing guide](http://emberjs.com/guides/routing/) for documentation. + + @class Route + @namespace Ember + @extends Ember.Object + @uses Ember.ActionHandler + @uses Ember.Evented + @since 1.0.0 + @public */ + var Route = _emberRuntime.Object.extend(_emberRuntime.ActionHandler, _emberRuntime.Evented, { + /** + Configuration hash for this route's queryParams. The possible + configuration options and their defaults are as follows + (assuming a query param whose controller property is `page`): + ```javascript + queryParams: { + page: { + // By default, controller query param properties don't + // cause a full transition when they are changed, but + // rather only cause the URL to update. Setting + // `refreshModel` to true will cause an "in-place" + // transition to occur, whereby the model hooks for + // this route (and any child routes) will re-fire, allowing + // you to reload models (e.g., from the server) using the + // updated query param values. + refreshModel: false, + // By default, changes to controller query param properties + // cause the URL to update via `pushState`, which means an + // item will be added to the browser's history, allowing + // you to use the back button to restore the app to the + // previous state before the query param property was changed. + // Setting `replace` to true will use `replaceState` (or its + // hash location equivalent), which causes no browser history + // item to be added. This options name and default value are + // the same as the `link-to` helper's `replace` option. + replace: false, + // By default, the query param URL key is the same name as + // the controller property name. Use `as` to specify a + // different URL key. + as: 'page' + } + } + ``` + @property queryParams + @for Ember.Route + @type Object + @since 1.6.0 + @public + */ + queryParams: {}, - var destroying = Object.create(_emberViewsViewsStatesDefault.default); + /** + The name of the route, dot-delimited. + For example, a route found at `app/routes/posts/post.js` will have + a `routeName` of `posts.post`. + @property routeName + @for Ember.Route + @type String + @since 1.0.0 + @public + */ - _emberUtils.assign(destroying, { - appendChild: function () { - throw new _emberMetal.Error('You can\'t call appendChild on a view being destroyed'); + /** + Sets the name for this route, including a fully resolved name for routes + inside engines. + @private + @method _setRouteName + @param {String} name + */ + _setRouteName: function (name) { + this.routeName = name; + this.fullRouteName = getEngineRouteName(_emberUtils.getOwner(this), name); }, - rerender: function () { - throw new _emberMetal.Error('You can\'t call rerender on a view being destroyed'); - } - }); - exports.default = destroying; -}); -enifed('ember-views/views/states/has_element', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-metal', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberMetal, _emberViewsSystemJquery) { - 'use strict'; + /** + Populates the QP meta information in the BucketCache. + @private + @method _populateQPMeta + */ + _populateQPMeta: function () { + this._bucketCache.stash('route-meta', this.fullRouteName, this.get('_qp')); + }, - var hasElement = Object.create(_emberViewsViewsStatesDefault.default); + /** + @private + @property _qp + */ + _qp: _emberMetal.computed(function () { + var _this = this; - _emberUtils.assign(hasElement, { - $: function (view, sel) { - var elem = view.element; - return sel ? _emberViewsSystemJquery.default(sel, elem) : _emberViewsSystemJquery.default(elem); - }, + var controllerProto = undefined, + combinedQueryParameterConfiguration = undefined; - rerender: function (view) { - view.renderer.rerender(view); - }, + var controllerName = this.controllerName || this.routeName; + var owner = _emberUtils.getOwner(this); + var definedControllerClass = owner[_container.LOOKUP_FACTORY]('controller:' + controllerName); + var queryParameterConfiguraton = _emberMetal.get(this, 'queryParams'); + var hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; - destroy: function (view) { - view.renderer.remove(view); - }, + if (definedControllerClass) { + // the developer has authored a controller class in their application for this route + // access the prototype, find its query params and normalize their object shape + // them merge in the query params for the route. As a mergedProperty, Route#queryParams is always + // at least `{}` + controllerProto = definedControllerClass.proto(); - // Handle events from `Ember.EventDispatcher` - handleEvent: function (view, eventName, event) { - if (view.has(eventName)) { - // Handler should be able to re-dispatch events, so we don't - // preventDefault or stopPropagation. - return _emberMetal.flaggedInstrument('interaction.' + eventName, { event: event, view: view }, function () { - return _emberMetal.run.join(view, view.trigger, eventName, event); - }); - } else { - return true; // continue event propagation + var controllerDefinedQueryParameterConfiguration = _emberMetal.get(controllerProto, 'queryParams'); + var normalizedControllerQueryParameterConfiguration = _emberRoutingUtils.normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); + combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton); + } else if (hasRouterDefinedQueryParams) { + // the developer has not defined a controller but *has* supplied route query params. + // Generate a class for them so we can later insert default values + var generatedControllerClass = _emberRoutingSystemGenerate_controller.generateControllerFactory(_emberUtils.getOwner(this), controllerName); + controllerProto = generatedControllerClass.proto(); + combinedQueryParameterConfiguration = queryParameterConfiguraton; } - } - }); - exports.default = hasElement; -}); -enifed('ember-views/views/states/in_dom', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/has_element'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesHas_element) { - 'use strict'; + var qps = []; + var map = {}; + var propertyNames = []; - /** - @module ember - @submodule ember-views - */ + for (var propName in combinedQueryParameterConfiguration) { + if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { + continue; + } - var inDOM = Object.create(_emberViewsViewsStatesHas_element.default); + // to support the dubious feature of using unknownProperty + // on queryParams configuration + if (propName === 'unknownProperty' || propName === '_super') { + // possible todo: issue deprecation warning? + continue; + } - _emberUtils.assign(inDOM, { - enter: function (view) { - // Register the view for event handling. This hash is used by - // Ember.EventDispatcher to dispatch incoming events. - view.renderer.register(view); + var desc = combinedQueryParameterConfiguration[propName]; + var scope = desc.scope || 'model'; + var parts = undefined; - _emberMetal.runInDebug(function () { - _emberMetal._addBeforeObserver(view, 'elementId', function () { - throw new _emberMetal.Error('Changing a view\'s elementId after creation is not allowed'); - }); - }); - }, + if (scope === 'controller') { + parts = []; + } - exit: function (view) { - view.renderer.unregister(view); - } - }); + var urlKey = desc.as || this.serializeQueryParamKey(propName); + var defaultValue = _emberMetal.get(controllerProto, propName); - exports.default = inDOM; -}); -enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default'], function (exports, _emberViewsViewsStatesDefault) { - 'use strict'; + if (Array.isArray(defaultValue)) { + defaultValue = _emberRuntime.A(defaultValue.slice()); + } - /** - @module ember - @submodule ember-views - */ + var type = desc.type || _emberRuntime.typeOf(defaultValue); - exports.default = Object.create(_emberViewsViewsStatesDefault.default); -}); -enifed("ember-views/views/view", ["exports"], function (exports) { - "use strict"; -}); -/** -@module ember -@submodule ember-views -*/ + var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); + var scopedPropertyName = controllerName + ':' + propName; + var qp = { + undecoratedDefaultValue: _emberMetal.get(controllerProto, propName), + defaultValue: defaultValue, + serializedDefaultValue: defaultValueSerialized, + serializedValue: defaultValueSerialized, -/** - `Ember.View` is the class in Ember responsible for encapsulating templates of - HTML content, combining templates with data to render as sections of a page's - DOM, and registering and responding to user-initiated events. + type: type, + urlKey: urlKey, + prop: propName, + scopedPropertyName: scopedPropertyName, + controllerName: controllerName, + route: this, + parts: parts, // provided later when stashNames is called if 'model' scope + values: null, // provided later when setup is called. no idea why. + scope: scope + }; - ## HTML Tag + map[propName] = map[urlKey] = map[scopedPropertyName] = qp; + qps.push(qp); + propertyNames.push(propName); + } - The default HTML tag name used for a view's DOM representation is `div`. This - can be customized by setting the `tagName` property. The following view - class: + return { + qps: qps, + map: map, + propertyNames: propertyNames, + states: { + /* + Called when a query parameter changes in the URL, this route cares + about that query parameter, but the route is not currently + in the active route hierarchy. + */ + inactive: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + }, + /* + Called when a query parameter changes in the URL, this route cares + about that query parameter, and the route is currently + in the active route hierarchy. + */ + active: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + return _this._activeQPChanged(map[prop], value); + }, + /* + Called when a value of a query parameter this route handles changes in a controller + and the route is currently in the active route hierarchy. + */ + allowOverrides: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + return _this._updatingQPChanged(map[prop]); + } + } + }; + }), - ```javascript - ParagraphView = Ember.View.extend({ - tagName: 'em' - }); - ``` + /** + @private + @property _names + */ + _names: null, - Would result in instances with the following HTML: + /** + @private + @method _stashNames + */ + _stashNames: function (handlerInfo, dynamicParent) { + if (this._names) { + return; + } + var names = this._names = handlerInfo._names; - ```html - - ``` + if (!names.length) { + handlerInfo = dynamicParent; + names = handlerInfo && handlerInfo._names || []; + } - ## HTML `class` Attribute + var qps = _emberMetal.get(this, '_qp.qps'); - The HTML `class` attribute of a view's tag can be set by providing a - `classNames` property that is set to an array of strings: + var namePaths = new Array(names.length); + for (var a = 0; a < names.length; ++a) { + namePaths[a] = handlerInfo.name + '.' + names[a]; + } - ```javascript - MyView = Ember.View.extend({ - classNames: ['my-class', 'my-other-class'] - }); - ``` + for (var i = 0; i < qps.length; ++i) { + var qp = qps[i]; + if (qp.scope === 'model') { + qp.parts = namePaths; + } + } + }, - Will result in view instances with an HTML representation of: + /** + @private + @property _activeQPChanged + */ + _activeQPChanged: function (qp, value) { + var router = this.router; + router._activeQPChanged(qp.scopedPropertyName, value); + }, - ```html -
    - ``` + /** + @private + @method _updatingQPChanged + */ + _updatingQPChanged: function (qp) { + var router = this.router; + router._updatingQPChanged(qp.urlKey); + }, - `class` attribute values can also be set by providing a `classNameBindings` - property set to an array of properties names for the view. The return value - of these properties will be added as part of the value for the view's `class` - attribute. These properties can be computed properties: + mergedProperties: ['queryParams'], - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['propertyA', 'propertyB'], - propertyA: 'from-a', - propertyB: Ember.computed(function() { - if (someLogic) { return 'from-b'; } - }) - }); - ``` + /** + Returns a hash containing the parameters of an ancestor route. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('member', { path: ':name' }, function() { + this.route('interest', { path: ':interest' }); + }); + }); + ``` + ```app/routes/member.js + export default Ember.Route.extend({ + queryParams: { + memberQp: { refreshModel: true } + } + }); + ``` + ```app/routes/member/interest.js + export default Ember.Route.extend({ + queryParams: { + interestQp: { refreshModel: true } + }, + model() { + return this.paramsFor('member'); + } + }); + ``` + If we visit `/turing/maths?memberQp=member&interestQp=interest` the model for + the `member.interest` route is hash with: + * `name`: `turing` + * `memberQp`: `member` + @method paramsFor + @param {String} name + @return {Object} hash containing the parameters of the route `name` + @since 1.4.0 + @public + */ + paramsFor: function (name) { + var _this2 = this; - Will result in view instances with an HTML representation of: + var route = _emberUtils.getOwner(this).lookup('route:' + name); - ```html -
    - ``` + if (!route) { + return {}; + } - If the value of a class name binding returns a boolean the property name - itself will be used as the class name if the property is true. The class name - will not be added if the value is `false` or `undefined`. + var transition = this.router.router.activeTransition; + var state = transition ? transition.state : this.router.router.state; - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['hovered'], - hovered: true - }); - ``` + var fullName = route.fullRouteName; + var params = _emberUtils.assign({}, state.params[fullName]); + var queryParams = getQueryParamsFor(route, state); - Will result in view instances with an HTML representation of: + return Object.keys(queryParams).reduce(function (params, key) { + _emberMetal.assert('The route \'' + _this2.routeName + '\' has both a dynamic segment and query param with name \'' + key + '\'. Please rename one to avoid collisions.', !params[key]); + params[key] = queryParams[key]; + return params; + }, params); + }, - ```html -
    - ``` + /** + Serializes the query parameter key + @method serializeQueryParamKey + @param {String} controllerPropertyName + @private + */ + serializeQueryParamKey: function (controllerPropertyName) { + return controllerPropertyName; + }, - When using boolean class name bindings you can supply a string value other - than the property name for use as the `class` HTML attribute by appending the - preferred value after a ":" character when defining the binding: + /** + Serializes value of the query parameter based on defaultValueType + @method serializeQueryParam + @param {Object} value + @param {String} urlKey + @param {String} defaultValueType + @private + */ + serializeQueryParam: function (value, urlKey, defaultValueType) { + // urlKey isn't used here, but anyone overriding + // can use it to provide serialization specific + // to a certain query param. + return this.router._serializeQueryParam(value, defaultValueType); + }, - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['awesome:so-very-cool'], - awesome: true - }); - ``` + /** + Deserializes value of the query parameter based on defaultValueType + @method deserializeQueryParam + @param {Object} value + @param {String} urlKey + @param {String} defaultValueType + @private + */ + deserializeQueryParam: function (value, urlKey, defaultValueType) { + // urlKey isn't used here, but anyone overriding + // can use it to provide deserialization specific + // to a certain query param. + return this.router._deserializeQueryParam(value, defaultValueType); + }, - Will result in view instances with an HTML representation of: + /** + @private + @property _optionsForQueryParam + */ + _optionsForQueryParam: function (qp) { + return _emberMetal.get(this, 'queryParams.' + qp.urlKey) || _emberMetal.get(this, 'queryParams.' + qp.prop) || {}; + }, - ```html -
    - ``` + /** + A hook you can use to reset controller values either when the model + changes or the route is exiting. + ```app/routes/articles.js + import Ember from 'ember'; + export default Ember.Route.extend({ + resetController(controller, isExiting, transition) { + if (isExiting) { + controller.set('page', 1); + } + } + }); + ``` + @method resetController + @param {Controller} controller instance + @param {Boolean} isExiting + @param {Object} transition + @since 1.7.0 + @public + */ + resetController: K, - Boolean value class name bindings whose property names are in a - camelCase-style format will be converted to a dasherized format: + /** + @private + @method exit + */ + exit: function () { + this.deactivate(); + this.trigger('deactivate'); + this.teardownViews(); + }, - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['isUrgent'], - isUrgent: true - }); - ``` + /** + @private + @method _reset + @since 1.7.0 + */ + _reset: function (isExiting, transition) { + var controller = this.controller; + controller._qpDelegate = _emberMetal.get(this, '_qp.states.inactive'); - Will result in view instances with an HTML representation of: + this.resetController(controller, isExiting, transition); + }, - ```html -
    - ``` + /** + @private + @method enter + */ + enter: function () { + this.connections = []; + this.activate(); + this.trigger('activate'); + }, - Class name bindings can also refer to object values that are found by - traversing a path relative to the view itself: + /** + The name of the template to use by default when rendering this routes + template. + ```app/routes/posts/list.js + import Ember from 'ember'; + export default Ember.Route.extend({ + templateName: 'posts/list' + }); + ``` + ```app/routes/posts/index.js + import PostsList from '../posts/list'; + export default PostsList.extend(); + ``` + ```app/routes/posts/archived.js + import PostsList from '../posts/list'; + export default PostsList.extend(); + ``` + @property templateName + @type String + @default null + @since 1.4.0 + @public + */ + templateName: null, - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['messages.empty'] - messages: Ember.Object.create({ - empty: true - }) - }); - ``` + /** + The name of the controller to associate with this route. + By default, Ember will lookup a route's controller that matches the name + of the route (i.e. `App.PostController` for `App.PostRoute`). However, + if you would like to define a specific controller to use, you can do so + using this property. + This is useful in many ways, as the controller specified will be: + * passed to the `setupController` method. + * used as the controller for the template being rendered by the route. + * returned from a call to `controllerFor` for the route. + @property controllerName + @type String + @default null + @since 1.4.0 + @public + */ + controllerName: null, - Will result in view instances with an HTML representation of: + /** + The `willTransition` action is fired at the beginning of any + attempted transition with a `Transition` object as the sole + argument. This action can be used for aborting, redirecting, + or decorating the transition from the currently active routes. + A good example is preventing navigation when a form is + half-filled out: + ```app/routes/contact-form.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + willTransition(transition) { + if (this.controller.get('userHasEnteredData')) { + this.controller.displayNavigationConfirm(); + transition.abort(); + } + } + } + }); + ``` + You can also redirect elsewhere by calling + `this.transitionTo('elsewhere')` from within `willTransition`. + Note that `willTransition` will not be fired for the + redirecting `transitionTo`, since `willTransition` doesn't + fire when there is already a transition underway. If you want + subsequent `willTransition` actions to fire for the redirecting + transition, you must first explicitly call + `transition.abort()`. + To allow the `willTransition` event to continue bubbling to the parent + route, use `return true;`. When the `willTransition` method has a + return value of `true` then the parent route's `willTransition` method + will be fired, enabling "bubbling" behavior for the event. + @event willTransition + @param {Transition} transition + @since 1.0.0 + @public + */ - ```html -
    - ``` + /** + The `didTransition` action is fired after a transition has + successfully been completed. This occurs after the normal model + hooks (`beforeModel`, `model`, `afterModel`, `setupController`) + have resolved. The `didTransition` action has no arguments, + however, it can be useful for tracking page views or resetting + state on the controller. + ```app/routes/login.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + didTransition() { + this.controller.get('errors.base').clear(); + return true; // Bubble the didTransition event + } + } + }); + ``` + @event didTransition + @since 1.2.0 + @public + */ - If you want to add a class name for a property which evaluates to true and - and a different class name if it evaluates to false, you can pass a binding - like this: + /** + The `loading` action is fired on the route when a route's `model` + hook returns a promise that is not already resolved. The current + `Transition` object is the first parameter and the route that + triggered the loading event is the second parameter. + ```app/routes/application.js + export default Ember.Route.extend({ + actions: { + loading(transition, route) { + let controller = this.controllerFor('foo'); + controller.set('currentlyLoading', true); + transition.finally(function() { + controller.set('currentlyLoading', false); + }); + } + } + }); + ``` + @event loading + @param {Transition} transition + @param {Ember.Route} route The route that triggered the loading event + @since 1.2.0 + @public + */ - ```javascript - // Applies 'enabled' class when isEnabled is true and 'disabled' when isEnabled is false - Ember.View.extend({ - classNameBindings: ['isEnabled:enabled:disabled'] - isEnabled: true - }); - ``` + /** + When attempting to transition into a route, any of the hooks + may return a promise that rejects, at which point an `error` + action will be fired on the partially-entered routes, allowing + for per-route error handling logic, or shared error handling + logic defined on a parent route. + Here is an example of an error handler that will be invoked + for rejected promises from the various hooks on the route, + as well as any unhandled errors from child routes: + ```app/routes/admin.js + import Ember from 'ember'; + export default Ember.Route.extend({ + beforeModel() { + return Ember.RSVP.reject('bad things!'); + }, + actions: { + error(error, transition) { + // Assuming we got here due to the error in `beforeModel`, + // we can expect that error === "bad things!", + // but a promise model rejecting would also + // call this hook, as would any errors encountered + // in `afterModel`. + // The `error` hook is also provided the failed + // `transition`, which can be stored and later + // `.retry()`d if desired. + this.transitionTo('login'); + } + } + }); + ``` + `error` actions that bubble up all the way to `ApplicationRoute` + will fire a default error handler that logs the error. You can + specify your own global default error handler by overriding the + `error` handler on `ApplicationRoute`: + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + error(error, transition) { + this.controllerFor('banner').displayError(error.message); + } + } + }); + ``` + @event error + @param {Error} error + @param {Transition} transition + @since 1.0.0 + @public + */ - Will result in view instances with an HTML representation of: + /** + This event is triggered when the router enters the route. It is + not executed when the model for the route changes. + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + collectAnalytics: Ember.on('activate', function(){ + collectAnalytics(); + }) + }); + ``` + @event activate + @since 1.9.0 + @public + */ - ```html -
    - ``` + /** + This event is triggered when the router completely exits this + route. It is not executed when the model for the route changes. + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + trackPageLeaveAnalytics: Ember.on('deactivate', function(){ + trackPageLeaveAnalytics(); + }) + }); + ``` + @event deactivate + @since 1.9.0 + @public + */ - When isEnabled is `false`, the resulting HTML representation looks like - this: + /** + The controller associated with this route. + Example + ```app/routes/form.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + willTransition(transition) { + if (this.controller.get('userHasEnteredData') && + !confirm('Are you sure you want to abandon progress?')) { + transition.abort(); + } else { + // Bubble the `willTransition` action so that + // parent routes can decide whether or not to abort. + return true; + } + } + } + }); + ``` + @property controller + @type Ember.Controller + @since 1.6.0 + @public + */ - ```html -
    - ``` + actions: { - This syntax offers the convenience to add a class if a property is `false`: + /** + This action is called when one or more query params have changed. Bubbles. + @method queryParamsDidChange + @param changed {Object} Keys are names of query params that have changed. + @param totalPresent {Object} Keys are names of query params that are currently set. + @param removed {Object} Keys are names of query params that have been removed. + @returns {boolean} + @private + */ + queryParamsDidChange: function (changed, totalPresent, removed) { + var qpMap = _emberMetal.get(this, '_qp').map; - ```javascript - // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false - Ember.View.extend({ - classNameBindings: ['isEnabled::disabled'] - isEnabled: true - }); - ``` + var totalChanged = Object.keys(changed).concat(Object.keys(removed)); + for (var i = 0; i < totalChanged.length; ++i) { + var qp = qpMap[totalChanged[i]]; + if (qp && _emberMetal.get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) { + this.refresh(); + break; + } + } - Will result in view instances with an HTML representation of: + return true; + }, - ```html -
    - ``` + finalizeQueryParamChange: function (params, finalParams, transition) { + if (this.fullRouteName !== 'application') { + return true; + } - When the `isEnabled` property on the view is set to `false`, it will result - in view instances with an HTML representation of: + // Transition object is absent for intermediate transitions. + if (!transition) { + return; + } - ```html -
    - ``` + var handlerInfos = transition.state.handlerInfos; + var router = this.router; + var qpMeta = router._queryParamsFor(handlerInfos); + var changes = router._qpUpdates; + var replaceUrl = undefined; - Updates to the value of a class name binding will result in automatic - update of the HTML `class` attribute in the view's rendered HTML - representation. If the value becomes `false` or `undefined` the class name - will be removed. + _emberRoutingUtils.stashParamNames(router, handlerInfos); - Both `classNames` and `classNameBindings` are concatenated properties. See - [Ember.Object](/api/classes/Ember.Object.html) documentation for more - information about concatenated properties. + for (var i = 0; i < qpMeta.qps.length; ++i) { + var qp = qpMeta.qps[i]; + var route = qp.route; + var controller = route.controller; + var presentKey = qp.urlKey in params && qp.urlKey; - ## HTML Attributes + // Do a reverse lookup to see if the changed query + // param URL key corresponds to a QP property on + // this controller. + var value = undefined, + svalue = undefined; + if (changes && qp.urlKey in changes) { + // Value updated in/before setupController + value = _emberMetal.get(controller, qp.prop); + svalue = route.serializeQueryParam(value, qp.urlKey, qp.type); + } else { + if (presentKey) { + svalue = params[presentKey]; + value = route.deserializeQueryParam(svalue, qp.urlKey, qp.type); + } else { + // No QP provided; use default value. + svalue = qp.serializedDefaultValue; + value = copyDefaultValue(qp.defaultValue); + } + } - The HTML attribute section of a view's tag can be set by providing an - `attributeBindings` property set to an array of property names on the view. - The return value of these properties will be used as the value of the view's - HTML associated attribute: + controller._qpDelegate = _emberMetal.get(route, '_qp.states.inactive'); - ```javascript - AnchorView = Ember.View.extend({ - tagName: 'a', - attributeBindings: ['href'], - href: 'http://google.com' - }); - ``` + var thisQueryParamChanged = svalue !== qp.serializedValue; + if (thisQueryParamChanged) { + if (transition.queryParamsOnly && replaceUrl !== false) { + var options = route._optionsForQueryParam(qp); + var replaceConfigValue = _emberMetal.get(options, 'replace'); + if (replaceConfigValue) { + replaceUrl = true; + } else if (replaceConfigValue === false) { + // Explicit pushState wins over any other replaceStates. + replaceUrl = false; + } + } - Will result in view instances with an HTML representation of: + _emberMetal.set(controller, qp.prop, value); + } - ```html - - ``` + // Stash current serialized value of controller. + qp.serializedValue = svalue; - One property can be mapped on to another by placing a ":" between - the source property and the destination property: + var thisQueryParamHasDefaultValue = qp.serializedDefaultValue === svalue; + if (!thisQueryParamHasDefaultValue) { + finalParams.push({ + value: svalue, + visible: true, + key: presentKey || qp.urlKey + }); + } + } - ```javascript - AnchorView = Ember.View.extend({ - tagName: 'a', - attributeBindings: ['url:href'], - url: 'http://google.com' - }); - ``` + if (replaceUrl) { + transition.method('replace'); + } - Will result in view instances with an HTML representation of: + qpMeta.qps.forEach(function (qp) { + var routeQpMeta = _emberMetal.get(qp.route, '_qp'); + var finalizedController = qp.route.controller; + finalizedController._qpDelegate = _emberMetal.get(routeQpMeta, 'states.active'); + }); - ```html - - ``` + router._qpUpdates = null; + } + }, - Namespaced attributes (e.g. `xlink:href`) are supported, but have to be - mapped, since `:` is not a valid character for properties in Javascript: + /** + This hook is executed when the router completely exits this route. It is + not executed when the model for the route changes. + @method deactivate + @since 1.0.0 + @public + */ + deactivate: K, - ```javascript - UseView = Ember.View.extend({ - tagName: 'use', - attributeBindings: ['xlinkHref:xlink:href'], - xlinkHref: '#triangle' - }); - ``` - Will result in view instances with an HTML representation of: + /** + This hook is executed when the router enters the route. It is not executed + when the model for the route changes. + @method activate + @since 1.0.0 + @public + */ + activate: K, - ```html - - ``` + /** + Transition the application into another route. The route may + be either a single route or route path: + ```javascript + this.transitionTo('blogPosts'); + this.transitionTo('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + this.transitionTo('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + this.transitionTo('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```app/routes.js + // ... + Router.map(function() { + this.route('blogPost', { path:':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId' }); + }); + }); + export default Router; + ``` + ```javascript + this.transitionTo('blogComment', aPost, aComment); + this.transitionTo('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + this.transitionTo('/'); + this.transitionTo('/blog/post/1/comment/13'); + this.transitionTo('/blog/posts?sort=title'); + ``` + An options hash with a `queryParams` property may be provided as + the final argument to add query parameters to the destination URL. + ```javascript + this.transitionTo('blogPost', 1, { + queryParams: { showComments: 'true' } + }); + // if you just want to transition the query parameters without changing the route + this.transitionTo({ queryParams: { sort: 'date' } }); + ``` + See also [replaceWith](#method_replaceWith). + Simple Transition Example + ```app/routes.js + // ... + Router.map(function() { + this.route('index'); + this.route('secret'); + this.route('fourOhFour', { path: '*:' }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember': + export Ember.Route.extend({ + actions: { + moveToSecret(context) { + if (authorized()) { + this.transitionTo('secret', context); + } else { + this.transitionTo('fourOhFour'); + } + } + } + }); + ``` + Transition to a nested route + ```app/router.js + // ... + Router.map(function() { + this.route('articles', { path: '/articles' }, function() { + this.route('new'); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + transitionToNewArticle() { + this.transitionTo('articles.new'); + } + } + }); + ``` + Multiple Models Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('breakfast', { path: ':breakfastId' }, function() { + this.route('cereal', { path: ':cerealId' }); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + moveToChocolateCereal() { + let cereal = { cerealId: 'ChocolateYumminess' }; + let breakfast = { breakfastId: 'CerealAndMilk' }; + this.transitionTo('breakfast.cereal', breakfast, cereal); + } + } + }); + ``` + Nested Route with Query String Example + ```app/routes.js + // ... + Router.map(function() { + this.route('fruits', function() { + this.route('apples'); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + transitionToApples() { + this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); + } + } + }); + ``` + @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 + @since 1.0.0 + @public + */ + transitionTo: function (name, context) { + var router = this.router; + return router.transitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - If the return value of an `attributeBindings` monitored property is a boolean - the attribute will be present or absent depending on the value: + /** + Perform a synchronous transition into another route without attempting + to resolve promises, update the URL, or abort any currently active + asynchronous transitions (i.e. regular transitions caused by + `transitionTo` or URL changes). + This method is handy for performing intermediate transitions on the + way to a final destination route, and is called internally by the + default implementations of the `error` and `loading` handlers. + @method intermediateTransitionTo + @param {String} name the name of the route + @param {...Object} models the model(s) to be used while transitioning + to the route. + @since 1.2.0 + @public + */ + intermediateTransitionTo: function () { + var router = this.router; + router.intermediateTransitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'input', - attributeBindings: ['disabled'], - disabled: false - }); - ``` + /** + Refresh the model on this route and any child routes, firing the + `beforeModel`, `model`, and `afterModel` hooks in a similar fashion + to how routes are entered when transitioning in from other route. + The current route params (e.g. `article_id`) will be passed in + to the respective model hooks, and if a different model is returned, + `setupController` and associated route hooks will re-fire as well. + An example usage of this method is re-querying the server for the + latest information using the same parameters as when the route + was first entered. + Note that this will cause `model` hooks to fire even on routes + that were provided a model object when the route was initially + entered. + @method refresh + @return {Transition} the transition object associated with this + attempted transition + @since 1.4.0 + @public + */ + refresh: function () { + return this.router.router.refresh(this); + }, - Will result in a view instance with an HTML representation of: + /** + Transition into another route while replacing the current URL, if possible. + This will replace the current history entry instead of adding a new one. + Beside that, it is identical to `transitionTo` in all other respects. See + 'transitionTo' for additional information regarding multiple models. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('secret'); + }); + export default Router; + ``` + ```app/routes/secret.js + import Ember from 'ember'; + export default Ember.Route.extend({ + afterModel() { + if (!authorized()){ + this.replaceWith('index'); + } + } + }); + ``` + @method replaceWith + @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. + @return {Transition} the transition object associated with this + attempted transition + @since 1.0.0 + @public + */ + replaceWith: function () { + var router = this.router; + return router.replaceWith.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - ```html - - ``` + /** + Sends an action to the router, which will delegate it to the currently + active route hierarchy per the bubbling rules explained under `actions`. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + }); + export default Router; + ``` + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + track(arg) { + console.log(arg, 'was clicked'); + } + } + }); + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + trackIfDebug(arg) { + if (debug) { + this.send('track', arg); + } + } + } + }); + ``` + @method send + @param {String} name the name of the action to trigger + @param {...*} args + @since 1.0.0 + @public + */ + send: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - `attributeBindings` can refer to computed properties: + if (this.router && this.router.router || !_emberMetal.isTesting()) { + var _router; - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'input', - attributeBindings: ['disabled'], - disabled: Ember.computed(function() { - if (someLogic) { - return true; + (_router = this.router).send.apply(_router, args); } else { - return false; + var _name2 = args[0]; + args = slice.call(args, 1); + var action = this.actions[_name2]; + if (action) { + return this.actions[_name2].apply(this, args); + } } - }) - }); - ``` - - To prevent setting an attribute altogether, use `null` or `undefined` as the - return value of the `attributeBindings` monitored property: - - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'form', - attributeBindings: ['novalidate'], - novalidate: null - }); - ``` - - Updates to the property of an attribute binding will result in automatic - update of the HTML attribute in the view's rendered HTML representation. - - `attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html) - documentation for more information about concatenated properties. - - ## Layouts - - Views can have a secondary template that wraps their main template. Like - primary templates, layouts can be any function that accepts an optional - context parameter and returns a string of HTML that will be inserted inside - view's tag. Views whose HTML element is self closing (e.g. ``) - cannot have a layout and this property will be ignored. - - Most typically in Ember a layout will be a compiled template. - - A view's layout can be set directly with the `layout` property or reference - an existing template by name with the `layoutName` property. + }, - A template used as a layout must contain a single use of the - `{{yield}}` helper. The HTML contents of a view's rendered `template` will be - inserted at this location: + /** + This hook is the entry point for router.js + @private + @method setup + */ + setup: function (context, transition) { + var _this3 = this; - ```javascript - AViewWithLayout = Ember.View.extend({ - layout: Ember.HTMLBars.compile("
    {{yield}}
    "), - template: Ember.HTMLBars.compile("I got wrapped") - }); - ``` + var controller = undefined; - Will result in view instances with an HTML representation of: + var controllerName = this.controllerName || this.routeName; + var definedController = this.controllerFor(controllerName, true); - ```html -
    -
    - I got wrapped -
    -
    - ``` + if (!definedController) { + controller = this.generateController(controllerName); + } else { + controller = definedController; + } - See [Ember.Templates.helpers.yield](/api/classes/Ember.Templates.helpers.html#method_yield) - for more information. + // Assign the route's controller so that it can more easily be + // referenced in action handlers. Side effects. Side effects everywhere. + if (!this.controller) { + var propNames = _emberMetal.get(this, '_qp.propertyNames'); + addQueryParamsObservers(controller, propNames); + this.controller = controller; + } - ## Responding to Browser Events + var queryParams = _emberMetal.get(this, '_qp'); - Views can respond to user-initiated events in one of three ways: method - implementation, through an event manager, and through `{{action}}` helper use - in their template or layout. + var states = queryParams.states; - ### Method Implementation + controller._qpDelegate = states.allowOverrides; - Views can respond to user-initiated events by implementing a method that - matches the event name. A `jQuery.Event` object will be passed as the - argument to this method. + if (transition) { + (function () { + // Update the model dep values used to calculate cache keys. + _emberRoutingUtils.stashParamNames(_this3.router, transition.state.handlerInfos); - ```javascript - AView = Ember.View.extend({ - click: function(event) { - // will be called when an instance's - // rendered element is clicked - } - }); - ``` + var params = transition.params; + var allParams = queryParams.propertyNames; + var cache = _this3._bucketCache; - ### Event Managers + allParams.forEach(function (prop) { + var aQp = queryParams.map[prop]; - Views can define an object as their `eventManager` property. This object can - then implement methods that match the desired event names. Matching events - that occur on the view's rendered HTML or the rendered HTML of any of its DOM - descendants will trigger this method. A `jQuery.Event` object will be passed - as the first argument to the method and an `Ember.View` object as the - second. The `Ember.View` will be the view whose rendered HTML was interacted - with. This may be the view with the `eventManager` property or one of its - descendant views. + aQp.values = params; + var cacheKey = _emberRoutingUtils.calculateCacheKey(aQp.route.fullRouteName, aQp.parts, aQp.values); - ```javascript - AView = Ember.View.extend({ - eventManager: Ember.Object.create({ - doubleClick: function(event, view) { - // will be called when an instance's - // rendered element or any rendering - // of this view's descendant - // elements is clicked + if (cache) { + var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); + _emberMetal.set(controller, prop, value); + } + }); + })(); } - }) - }); - ``` - - An event defined for an event manager takes precedence over events of the - same name handled through methods on the view. - ```javascript - AView = Ember.View.extend({ - mouseEnter: function(event) { - // will never trigger. - }, - eventManager: Ember.Object.create({ - mouseEnter: function(event, view) { - // takes precedence over AView#mouseEnter + if (transition) { + var qpValues = getQueryParamsFor(this, transition.state); + controller.setProperties(qpValues); } - }) - }); - ``` - Similarly a view's event manager will take precedence for events of any views - rendered as a descendant. A method name that matches an event name will not - be called if the view instance was rendered inside the HTML representation of - a view that has an `eventManager` property defined that handles events of the - name. Events not handled by the event manager will still trigger method calls - on the descendant. + this.setupController(controller, context, transition); - ```javascript - var App = Ember.Application.create(); - App.OuterView = Ember.View.extend({ - template: Ember.HTMLBars.compile("outer {{#view 'inner'}}inner{{/view}} outer"), - eventManager: Ember.Object.create({ - mouseEnter: function(event, view) { - // view might be instance of either - // OuterView or InnerView depending on - // where on the page the user interaction occurred + if (this._environment.options.shouldRender) { + this.renderTemplate(controller, context); } - }) - }); - - App.InnerView = Ember.View.extend({ - click: function(event) { - // will be called if rendered inside - // an OuterView because OuterView's - // eventManager doesn't handle click events }, - mouseEnter: function(event) { - // will never be called if rendered inside - // an OuterView. - } - }); - ``` - - ### `{{action}}` Helper - - See [Ember.Templates.helpers.action](/api/classes/Ember.Templates.helpers.html#method_action). - - ### Event Names - - All of the event handling approaches described above respond to the same set - of events. The names of the built-in events are listed below. (The hash of - built-in events exists in `Ember.EventDispatcher`.) Additional, custom events - can be registered by using `Ember.Application.customEvents`. - - Touch events: - - * `touchStart` - * `touchMove` - * `touchEnd` - * `touchCancel` - - Keyboard events - - * `keyDown` - * `keyUp` - * `keyPress` - - Mouse events - - * `mouseDown` - * `mouseUp` - * `contextMenu` - * `click` - * `doubleClick` - * `mouseMove` - * `focusIn` - * `focusOut` - * `mouseEnter` - * `mouseLeave` - - Form events: - - * `submit` - * `change` - * `focusIn` - * `focusOut` - * `input` - - HTML5 drag and drop events: - - * `dragStart` - * `drag` - * `dragEnter` - * `dragLeave` - * `dragOver` - * `dragEnd` - * `drop` - - @class View - @namespace Ember - @extends Ember.CoreView - @deprecated See http://emberjs.com/deprecations/v1.x/#toc_ember-view - @uses Ember.ViewSupport - @uses Ember.ChildViewsSupport - @uses Ember.ClassNamesSupport - @uses Ember.AttributeBindingsSupport - @private -*/ -enifed("ember/features", ["exports"], function (exports) { - "use strict"; - - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; -}); -enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { - 'use strict'; - - // ember-utils exports - _emberMetal.default.getOwner = _emberUtils.getOwner; - _emberMetal.default.setOwner = _emberUtils.setOwner; - _emberMetal.default.generateGuid = _emberUtils.generateGuid; - _emberMetal.default.GUID_KEY = _emberUtils.GUID_KEY; - _emberMetal.default.guidFor = _emberUtils.guidFor; - _emberMetal.default.inspect = _emberUtils.inspect; - _emberMetal.default.makeArray = _emberUtils.makeArray; - _emberMetal.default.canInvoke = _emberUtils.canInvoke; - _emberMetal.default.tryInvoke = _emberUtils.tryInvoke; - _emberMetal.default.wrap = _emberUtils.wrap; - _emberMetal.default.applyStr = _emberUtils.applyStr; - _emberMetal.default.uuid = _emberUtils.uuid; - _emberMetal.default.assign = Object.assign || _emberUtils.assign; - - // container exports - _emberMetal.default.Container = _container.Container; - _emberMetal.default.Registry = _container.Registry; - - // need to import this directly, to ensure the babel feature - // flag plugin works properly - - var computed = _emberMetal.computed; - computed.alias = _emberMetal.alias; - _emberMetal.default.computed = computed; - _emberMetal.default.ComputedProperty = _emberMetal.ComputedProperty; - _emberMetal.default.cacheFor = _emberMetal.cacheFor; - - _emberMetal.default.assert = _emberMetal.assert; - _emberMetal.default.warn = _emberMetal.warn; - _emberMetal.default.debug = _emberMetal.debug; - _emberMetal.default.deprecate = _emberMetal.deprecate; - _emberMetal.default.deprecateFunc = _emberMetal.deprecateFunc; - _emberMetal.default.runInDebug = _emberMetal.runInDebug; - _emberMetal.default.merge = _emberMetal.merge; - - _emberMetal.default.instrument = _emberMetal.instrument; - _emberMetal.default.subscribe = _emberMetal.instrumentationSubscribe; - _emberMetal.default.Instrumentation = { - instrument: _emberMetal.instrument, - subscribe: _emberMetal.instrumentationSubscribe, - unsubscribe: _emberMetal.instrumentationUnsubscribe, - reset: _emberMetal.instrumentationReset - }; - - _emberMetal.default.Error = _emberMetal.Error; - _emberMetal.default.META_DESC = _emberMetal.META_DESC; - _emberMetal.default.meta = _emberMetal.meta; - _emberMetal.default.get = _emberMetal.get; - _emberMetal.default.getWithDefault = _emberMetal.getWithDefault; - _emberMetal.default._getPath = _emberMetal._getPath; - _emberMetal.default.set = _emberMetal.set; - _emberMetal.default.trySet = _emberMetal.trySet; - _emberMetal.default.FEATURES = _emberMetal.FEATURES; - _emberMetal.default.FEATURES.isEnabled = _emberMetal.isFeatureEnabled; - _emberMetal.default._Cache = _emberMetal.Cache; - _emberMetal.default.on = _emberMetal.on; - _emberMetal.default.addListener = _emberMetal.addListener; - _emberMetal.default.removeListener = _emberMetal.removeListener; - _emberMetal.default._suspendListener = _emberMetal.suspendListener; - _emberMetal.default._suspendListeners = _emberMetal.suspendListeners; - _emberMetal.default.sendEvent = _emberMetal.sendEvent; - _emberMetal.default.hasListeners = _emberMetal.hasListeners; - _emberMetal.default.watchedEvents = _emberMetal.watchedEvents; - _emberMetal.default.listenersFor = _emberMetal.listenersFor; - _emberMetal.default.accumulateListeners = _emberMetal.accumulateListeners; - _emberMetal.default.isNone = _emberMetal.isNone; - _emberMetal.default.isEmpty = _emberMetal.isEmpty; - _emberMetal.default.isBlank = _emberMetal.isBlank; - _emberMetal.default.isPresent = _emberMetal.isPresent; - _emberMetal.default.run = _emberMetal.run; - _emberMetal.default._ObserverSet = _emberMetal.ObserverSet; - _emberMetal.default.propertyWillChange = _emberMetal.propertyWillChange; - _emberMetal.default.propertyDidChange = _emberMetal.propertyDidChange; - _emberMetal.default.overrideChains = _emberMetal.overrideChains; - _emberMetal.default.beginPropertyChanges = _emberMetal.beginPropertyChanges; - _emberMetal.default.endPropertyChanges = _emberMetal.endPropertyChanges; - _emberMetal.default.changeProperties = _emberMetal.changeProperties; - _emberMetal.default.platform = { - defineProperty: true, - hasPropertyAccessors: true - }; - _emberMetal.default.defineProperty = _emberMetal.defineProperty; - _emberMetal.default.watchKey = _emberMetal.watchKey; - _emberMetal.default.unwatchKey = _emberMetal.unwatchKey; - _emberMetal.default.removeChainWatcher = _emberMetal.removeChainWatcher; - _emberMetal.default._ChainNode = _emberMetal.ChainNode; - _emberMetal.default.finishChains = _emberMetal.finishChains; - _emberMetal.default.watchPath = _emberMetal.watchPath; - _emberMetal.default.unwatchPath = _emberMetal.unwatchPath; - _emberMetal.default.watch = _emberMetal.watch; - _emberMetal.default.isWatching = _emberMetal.isWatching; - _emberMetal.default.unwatch = _emberMetal.unwatch; - _emberMetal.default.destroy = _emberMetal.destroy; - _emberMetal.default.libraries = _emberMetal.libraries; - _emberMetal.default.OrderedSet = _emberMetal.OrderedSet; - _emberMetal.default.Map = _emberMetal.Map; - _emberMetal.default.MapWithDefault = _emberMetal.MapWithDefault; - _emberMetal.default.getProperties = _emberMetal.getProperties; - _emberMetal.default.setProperties = _emberMetal.setProperties; - _emberMetal.default.expandProperties = _emberMetal.expandProperties; - _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; - _emberMetal.default.addObserver = _emberMetal.addObserver; - _emberMetal.default.observersFor = _emberMetal.observersFor; - _emberMetal.default.removeObserver = _emberMetal.removeObserver; - _emberMetal.default._suspendObserver = _emberMetal._suspendObserver; - _emberMetal.default._suspendObservers = _emberMetal._suspendObservers; - _emberMetal.default.required = _emberMetal.required; - _emberMetal.default.aliasMethod = _emberMetal.aliasMethod; - _emberMetal.default.observer = _emberMetal.observer; - _emberMetal.default.immediateObserver = _emberMetal._immediateObserver; - _emberMetal.default.mixin = _emberMetal.mixin; - _emberMetal.default.Mixin = _emberMetal.Mixin; - _emberMetal.default.bind = _emberMetal.bind; - _emberMetal.default.Binding = _emberMetal.Binding; - _emberMetal.default.isGlobalPath = _emberMetal.isGlobalPath; - if (false) { - _emberMetal.default.WeakMap = _emberMetal.WeakMap; - } + /* + Called when a query parameter for this route changes, regardless of whether the route + is currently part of the active route hierarchy. This will update the query parameter's + value in the cache so if this route becomes active, the cache value has been updated. + */ + _qpChanged: function (prop, value, qp) { + if (!qp) { + return; + } - Object.defineProperty(_emberMetal.default, 'ENV', { - get: function () { - return _emberEnvironment.ENV; - }, - enumerable: false - }); + var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.route.fullRouteName, qp.parts, qp.values); - /** - The context that Ember searches for namespace instances on. - - @private - */ - Object.defineProperty(_emberMetal.default, 'lookup', { - get: function () { - return _emberEnvironment.context.lookup; - }, - set: function (value) { - _emberEnvironment.context.lookup = value; + // Update model-dep cache + var cache = this._bucketCache; + if (cache) { + cache.stash(cacheKey, prop, value); + } }, - enumerable: false - }); - - _emberMetal.default.EXTEND_PROTOTYPES = _emberEnvironment.ENV.EXTEND_PROTOTYPES; - // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS - Object.defineProperty(_emberMetal.default, 'LOG_STACKTRACE_ON_DEPRECATION', { - get: function () { - return _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; - }, - enumerable: false - }); + /** + This hook is the first of the route entry validation hooks + called when an attempt is made to transition into a route + or one of its children. It is called before `model` and + `afterModel`, and is appropriate for cases when: + 1) A decision can be made to redirect elsewhere without + needing to resolve the model first. + 2) Any async operations need to occur first before the + model is attempted to be resolved. + This hook is provided the current `transition` attempt + as a parameter, which can be used to `.abort()` the transition, + save it for a later `.retry()`, or retrieve values set + on it from a previous hook. You can also just call + `this.transitionTo` to another route to implicitly + abort the `transition`. + You can return a promise from this hook to pause the + transition until the promise resolves (or rejects). This could + be useful, for instance, for retrieving async code from + the server that is required to enter a route. + @method beforeModel + @param {Transition} transition + @return {Promise} if the value returned from this hook is + a promise, the transition will pause until the transition + resolves. Otherwise, non-promise return values are not + utilized in any way. + @since 1.0.0 + @public + */ + beforeModel: K, - Object.defineProperty(_emberMetal.default, 'LOG_VERSION', { - get: function () { - return _emberEnvironment.ENV.LOG_VERSION; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_VERSION = !!value; - }, - enumerable: false - }); + /** + This hook is called after this route's model has resolved. + It follows identical async/promise semantics to `beforeModel` + but is provided the route's resolved model in addition to + the `transition`, and is therefore suited to performing + logic that can only take place after the model has already + resolved. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + afterModel(posts, transition) { + if (posts.get('length') === 1) { + this.transitionTo('post.show', posts.get('firstObject')); + } + } + }); + ``` + Refer to documentation for `beforeModel` for a description + of transition-pausing semantics when a promise is returned + from this hook. + @method afterModel + @param {Object} resolvedModel the value returned from `model`, + or its resolved value if it was a promise + @param {Transition} transition + @return {Promise} if the value returned from this hook is + a promise, the transition will pause until the transition + resolves. Otherwise, non-promise return values are not + utilized in any way. + @since 1.0.0 + @public + */ + afterModel: K, - Object.defineProperty(_emberMetal.default, 'MODEL_FACTORY_INJECTIONS', { - get: function () { - return _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; - }, - set: function (value) { - _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = !!value; - }, - enumerable: false - }); + /** + A hook you can implement to optionally redirect to another route. + If you call `this.transitionTo` from inside of this hook, this route + will not be entered in favor of the other hook. + `redirect` and `afterModel` behave very similarly and are + called almost at the same time, but they have an important + distinction in the case that, from one of these hooks, a + redirect into a child route of this route occurs: redirects + from `afterModel` essentially invalidate the current attempt + to enter this route, and will result in this route's `beforeModel`, + `model`, and `afterModel` hooks being fired again within + the new, redirecting transition. Redirects that occur within + the `redirect` hook, on the other hand, will _not_ cause + these hooks to be fired again the second time around; in + other words, by the time the `redirect` hook has been called, + both the resolved model and attempted entry into this route + are considered to be fully validated. + @method redirect + @param {Object} model the model for this route + @param {Transition} transition the transition object associated with the current transition + @since 1.0.0 + @public + */ + redirect: K, - Object.defineProperty(_emberMetal.default, 'LOG_BINDINGS', { - get: function () { - return _emberEnvironment.ENV.LOG_BINDINGS; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_BINDINGS = !!value; + /** + Called when the context is changed by router.js. + @private + @method contextDidChange + */ + contextDidChange: function () { + this.currentModel = this.context; }, - enumerable: false - }); - /** - A function may be assigned to `Ember.onerror` to be called when Ember - internals encounter an error. This is useful for specialized error handling - and reporting code. - - ```javascript - Ember.onerror = function(error) { - Em.$.ajax('/report-error', 'POST', { - stack: error.stack, - otherInformation: 'whatever app state you want to provide' + /** + A hook you can implement to convert the URL into the model for + this route. + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); }); - }; - ``` - - Internally, `Ember.onerror` is used as Backburner's error handler. - - @event onerror - @for Ember - @param {Exception} error the error object - @public - */ - Object.defineProperty(_emberMetal.default, 'onerror', { - get: _emberMetal.getOnerror, - set: _emberMetal.setOnerror, - enumerable: false - }); + export default Router; + ``` + The model for the `post` route is `store.findRecord('post', params.post_id)`. + By default, if your route has a dynamic segment ending in `_id`: + * The model class is determined from the segment (`post_id`'s + class is `App.Post`) + * The find method is called on the model class with the value of + the dynamic segment. + Note that for routes with dynamic segments, this hook is not always + executed. If the route is entered through a transition (e.g. when + using the `link-to` Handlebars helper or the `transitionTo` method + of routes), and a model context is already provided this hook + is not called. + A model context does not include a primitive string or number, + which does cause the model hook to be called. + Routes without dynamic segments will always execute the model hook. + ```javascript + // no dynamic segment, model hook always called + this.transitionTo('posts'); + // model passed in, so model hook not called + thePost = store.findRecord('post', 1); + this.transitionTo('post', thePost); + // integer passed in, model hook is called + this.transitionTo('post', 1); + // model id passed in, model hook is called + // useful for forcing the hook to execute + thePost = store.findRecord('post', 1); + this.transitionTo('post', thePost.id); + ``` + This hook follows the asynchronous/promise semantics + described in the documentation for `beforeModel`. In particular, + if a promise returned from `model` fails, the error will be + handled by the `error` hook on `Ember.Route`. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model(params) { + return this.store.findRecord('post', params.post_id); + } + }); + ``` + @method model + @param {Object} params the parameters extracted from the URL + @param {Transition} transition + @return {Object|Promise} the model for this route. If + a promise is returned, the transition will pause until + the promise resolves, and the resolved value of the promise + will be used as the model for this route. + @since 1.0.0 + @public + */ + model: function (params, transition) { + var name = undefined, + sawParams = undefined, + value = undefined; + var queryParams = _emberMetal.get(this, '_qp.map'); - /** - An empty function useful for some operations. Always returns `this`. - - @method K - @return {Object} - @public - */ - _emberMetal.default.K = function K() { - return this; - }; + for (var prop in params) { + if (prop === 'queryParams' || queryParams && prop in queryParams) { + continue; + } - Object.defineProperty(_emberMetal.default, 'testing', { - get: _emberMetal.isTesting, - set: _emberMetal.setTesting, - enumerable: false - }); + var match = prop.match(/^(.*)_id$/); + if (match) { + name = match[1]; + value = params[prop]; + } + sawParams = true; + } - if (!_require.has('ember-debug')) { - _emberMetal.default.Debug = { - registerDeprecationHandler: function () {}, - registerWarnHandler: function () {} - }; - } + if (!name && sawParams) { + return _emberRuntime.copy(params); + } else if (!name) { + if (transition.resolveIndex < 1) { + return; + } - /** - @class Backburner - @for Ember - @private - */ - _emberMetal.default.Backburner = function () { - _emberMetal.deprecate('Usage of Ember.Backburner is deprecated.', false, { - id: 'ember-metal.ember-backburner', - until: '2.8.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-backburner' - }); + return transition.state.handlerInfos[transition.resolveIndex - 1].context; + } - function BackburnerAlias(args) { - return _backburner.default.apply(this, args); - } + return this.findModel(name, value); + }, - BackburnerAlias.prototype = _backburner.default.prototype; + /** + @private + @method deserialize + @param {Object} params the parameters extracted from the URL + @param {Transition} transition + @return {Object|Promise} the model for this route. + Router.js hook. + */ + deserialize: function (params, transition) { + return this.model(this.paramsFor(this.routeName), transition); + }, - return new BackburnerAlias(arguments); - }; + /** + @method findModel + @param {String} type the model type + @param {Object} value the value passed to find + @private + */ + findModel: function () { + var store = _emberMetal.get(this, 'store'); + return store.find.apply(store, arguments); + }, - _emberMetal.default._Backburner = _backburner.default; + /** + Store property provides a hook for data persistence libraries to inject themselves. + By default, this store property provides the exact same functionality previously + in the model hook. + Currently, the required interface is: + `store.find(modelName, findArguments)` + @method store + @param {Object} store + @private + */ + store: _emberMetal.computed(function () { + var owner = _emberUtils.getOwner(this); + var routeName = this.routeName; + var namespace = _emberMetal.get(this, 'router.namespace'); - _emberMetal.default.Logger = _emberConsole.default; + return { + find: function (name, value) { + var modelClass = owner[_container.FACTORY_FOR]('model:' + name); - // ****ember-runtime**** + _emberMetal.assert('You used the dynamic segment ' + name + '_id in your route ' + routeName + ', but ' + namespace + '.' + _emberRuntime.String.classify(name) + ' did not exist and you did not override your route\'s `model` hook.', !!modelClass); - _emberMetal.default.String = _emberRuntime.String; - _emberMetal.default.Object = _emberRuntime.Object; - _emberMetal.default._RegistryProxyMixin = _emberRuntime.RegistryProxyMixin; - _emberMetal.default._ContainerProxyMixin = _emberRuntime.ContainerProxyMixin; - _emberMetal.default.compare = _emberRuntime.compare; - _emberMetal.default.copy = _emberRuntime.copy; - _emberMetal.default.isEqual = _emberRuntime.isEqual; - _emberMetal.default.inject = _emberRuntime.inject; - _emberMetal.default.Array = _emberRuntime.Array; - _emberMetal.default.Comparable = _emberRuntime.Comparable; - _emberMetal.default.Enumerable = _emberRuntime.Enumerable; - _emberMetal.default.ArrayProxy = _emberRuntime.ArrayProxy; - _emberMetal.default.ObjectProxy = _emberRuntime.ObjectProxy; - _emberMetal.default.ActionHandler = _emberRuntime.ActionHandler; - _emberMetal.default.CoreObject = _emberRuntime.CoreObject; - _emberMetal.default.NativeArray = _emberRuntime.NativeArray; - _emberMetal.default.Copyable = _emberRuntime.Copyable; - _emberMetal.default.Freezable = _emberRuntime.Freezable; - _emberMetal.default.FROZEN_ERROR = _emberRuntime.FROZEN_ERROR; - _emberMetal.default.MutableEnumerable = _emberRuntime.MutableEnumerable; - _emberMetal.default.MutableArray = _emberRuntime.MutableArray; - _emberMetal.default.TargetActionSupport = _emberRuntime.TargetActionSupport; - _emberMetal.default.Evented = _emberRuntime.Evented; - _emberMetal.default.PromiseProxyMixin = _emberRuntime.PromiseProxyMixin; - _emberMetal.default.Observable = _emberRuntime.Observable; - _emberMetal.default.typeOf = _emberRuntime.typeOf; - _emberMetal.default.isArray = _emberRuntime.isArray; - _emberMetal.default.Object = _emberRuntime.Object; - _emberMetal.default.onLoad = _emberRuntime.onLoad; - _emberMetal.default.runLoadHooks = _emberRuntime.runLoadHooks; - _emberMetal.default.Controller = _emberRuntime.Controller; - _emberMetal.default.ControllerMixin = _emberRuntime.ControllerMixin; - _emberMetal.default.Service = _emberRuntime.Service; - _emberMetal.default._ProxyMixin = _emberRuntime._ProxyMixin; - _emberMetal.default.RSVP = _emberRuntime.RSVP; - _emberMetal.default.Namespace = _emberRuntime.Namespace; + if (!modelClass) { + return; + } - // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed - computed.empty = _emberRuntime.empty; - computed.notEmpty = _emberRuntime.notEmpty; - computed.none = _emberRuntime.none; - computed.not = _emberRuntime.not; - computed.bool = _emberRuntime.bool; - computed.match = _emberRuntime.match; - computed.equal = _emberRuntime.equal; - computed.gt = _emberRuntime.gt; - computed.gte = _emberRuntime.gte; - computed.lt = _emberRuntime.lt; - computed.lte = _emberRuntime.lte; - computed.oneWay = _emberRuntime.oneWay; - computed.reads = _emberRuntime.oneWay; - computed.readOnly = _emberRuntime.readOnly; - computed.deprecatingAlias = _emberRuntime.deprecatingAlias; - computed.and = _emberRuntime.and; - computed.or = _emberRuntime.or; - computed.any = _emberRuntime.any; + modelClass = modelClass.class; - computed.sum = _emberRuntime.sum; - computed.min = _emberRuntime.min; - computed.max = _emberRuntime.max; - computed.map = _emberRuntime.map; - computed.sort = _emberRuntime.sort; - computed.setDiff = _emberRuntime.setDiff; - computed.mapBy = _emberRuntime.mapBy; - computed.filter = _emberRuntime.filter; - computed.filterBy = _emberRuntime.filterBy; - computed.uniq = _emberRuntime.uniq; + _emberMetal.assert(_emberRuntime.String.classify(name) + ' has no method `find`.', typeof modelClass.find === 'function'); - if (true) { - computed.uniqBy = _emberRuntime.uniqBy; - } - computed.union = _emberRuntime.union; - computed.intersect = _emberRuntime.intersect; - computed.collect = _emberRuntime.collect; + return modelClass.find(value); + } + }; + }), - /** - Defines the hash of localized strings for the current language. Used by - the `Ember.String.loc()` helper. To localize, add string values to this - hash. - - @property STRINGS - @for Ember - @type Object - @private - */ - Object.defineProperty(_emberMetal.default, 'STRINGS', { - configurable: false, - get: _emberRuntime.getStrings, - set: _emberRuntime.setStrings - }); + /** + A hook you can implement to convert the route's model into parameters + for the URL. + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); + }); + ``` + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model(params) { + // the server returns `{ id: 12 }` + return Ember.$.getJSON('/posts/' + params.post_id); + }, + serialize(model) { + // this will make the URL `/posts/12` + return { post_id: model.id }; + } + }); + ``` + The default `serialize` method will insert the model's `id` into the + route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'. + If the route has multiple dynamic segments or does not contain '_id', `serialize` + will return `Ember.getProperties(model, params)` + This method is called when `transitionTo` is called with a context + in order to populate the URL. + @method serialize + @param {Object} model the routes model + @param {Array} params an Array of parameter names for the current + route (in the example, `['post_id']`. + @return {Object} the serialized parameters + @since 1.0.0 + @public + */ + serialize: defaultSerialize, - /** - Whether searching on the global for new Namespace instances is enabled. - - This is only exported here as to not break any addons. Given the new - visit API, you will have issues if you treat this as a indicator of - booted. - - Internally this is only exposing a flag in Namespace. - - @property BOOTED - @for Ember - @type Boolean - @private - */ - Object.defineProperty(_emberMetal.default, 'BOOTED', { - configurable: false, - enumerable: false, - get: _emberRuntime.isNamespaceSearchDisabled, - set: _emberRuntime.setNamespaceSearchDisabled - }); + /** + A hook you can use to setup the controller for the current route. + This method is called with the controller for the current route and the + model supplied by the `model` hook. + By default, the `setupController` hook sets the `model` property of + the controller to the `model`. + If you implement the `setupController` hook in your Route, it will + prevent this default behavior. If you want to preserve that behavior + when implementing your `setupController` function, make sure to call + `_super`: + ```app/routes/photos.js + import Ember from 'ebmer'; + export default Ember.Route.extend({ + model() { + return this.store.findAll('photo'); + }, + setupController(controller, model) { + // Call _super for default behavior + this._super(controller, model); + // Implement your custom setup after + this.controllerFor('application').set('showingPhotos', true); + } + }); + ``` + The provided controller will be one resolved based on the name + of this route. + If no explicit controller is defined, Ember will automatically create one. + As an example, consider the router: + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); + }); + export default Router; + ``` + For the `post` route, a controller named `App.PostController` would + be used if it is defined. If it is not defined, a basic `Ember.Controller` + instance would be used. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, model) { + controller.set('model', model); + } + }); + ``` + @method setupController + @param {Controller} controller instance + @param {Object} model + @since 1.0.0 + @public + */ + setupController: function (controller, context, transition) { + if (controller && context !== undefined) { + _emberMetal.set(controller, 'model', context); + } + }, + + /** + Returns the resolved model of the current route, or a parent (or any ancestor) + route in a route hierarchy. + The controller instance must already have been created, either through entering the + associated route or using `generateController`. + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, post) { + this._super(controller, post); + this.controllerFor('posts').set('currentPost', post); + } + }); + ``` + @method controllerFor + @param {String} name the name of the route or controller + @return {Ember.Controller} + @since 1.0.0 + @public + */ + controllerFor: function (name, _skipAssert) { + var owner = _emberUtils.getOwner(this); + var route = owner.lookup('route:' + name); + var controller = undefined; + + if (route && route.controllerName) { + name = route.controllerName; + } - _emberMetal.default.Component = _emberGlimmer.Component; - _emberGlimmer.Helper.helper = _emberGlimmer.helper; - _emberMetal.default.Helper = _emberGlimmer.Helper; - _emberMetal.default.Checkbox = _emberGlimmer.Checkbox; - _emberMetal.default.TextField = _emberGlimmer.TextField; - _emberMetal.default.TextArea = _emberGlimmer.TextArea; - _emberMetal.default.LinkComponent = _emberGlimmer.LinkComponent; + controller = owner.lookup('controller:' + name); - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { - String.prototype.htmlSafe = function () { - return _emberGlimmer.htmlSafe(this); - }; - } + // NOTE: We're specifically checking that skipAssert is true, because according + // to the old API the second parameter was model. We do not want people who + // passed a model to skip the assertion. + _emberMetal.assert('The controller named \'' + name + '\' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.', controller || _skipAssert === true); - var EmberHandlebars = _emberMetal.default.Handlebars = _emberMetal.default.Handlebars || {}; - var EmberHTMLBars = _emberMetal.default.HTMLBars = _emberMetal.default.HTMLBars || {}; - var EmberHandleBarsUtils = EmberHandlebars.Utils = EmberHandlebars.Utils || {}; + return controller; + }, - Object.defineProperty(EmberHandlebars, 'SafeString', { - get: _emberGlimmer._getSafeString - }); + /** + Generates a controller for a route. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, post) { + this._super(controller, post); + this.generateController('posts'); + } + }); + ``` + @method generateController + @param {String} name the name of the controller + @private + */ + generateController: function (name) { + var owner = _emberUtils.getOwner(this); - EmberHTMLBars.template = EmberHandlebars.template = _emberGlimmer.template; - EmberHandleBarsUtils.escapeExpression = _emberGlimmer.escapeExpression; - _emberRuntime.String.htmlSafe = _emberGlimmer.htmlSafe; + return _emberRoutingSystemGenerate_controller.default(owner, name); + }, - if (true) { - _emberRuntime.String.isHTMLSafe = _emberGlimmer.isHTMLSafe; - } - EmberHTMLBars.makeBoundHelper = _emberGlimmer.makeBoundHelper; + /** + Returns the resolved model of a parent (or any ancestor) route + in a route hierarchy. During a transition, all routes + must resolve a model object, and if a route + needs access to a parent route's model in order to + resolve a model (or just reuse the model from a parent), + it can call `this.modelFor(theNameOfParentRoute)` to + retrieve it. If the ancestor route's model was a promise, + its resolved result is returned. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }, function() { + this.route('comments'); + }); + }); + export default Router; + ``` + ```app/routes/comments.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model() { + let post = this.modelFor('post'); + return post.get('comments'); + } + }); + ``` + @method modelFor + @param {String} name the name of the route + @return {Object} the model object + @since 1.0.0 + @public + */ + modelFor: function (_name) { + var name = undefined; + var owner = _emberUtils.getOwner(this); - /** - Global hash of shared templates. This will automatically be populated - by the build tools so that you can store your Handlebars templates in - separate files that get loaded into JavaScript at buildtime. - - @property TEMPLATES - @for Ember - @type Object - @private - */ - Object.defineProperty(_emberMetal.default, 'TEMPLATES', { - get: _emberGlimmer.getTemplates, - set: _emberGlimmer.setTemplates, - configurable: false, - enumerable: false - }); + // Only change the route name when there is an active transition. + // Otherwise, use the passed in route name. + if (owner.routable && this.router && this.router.router.activeTransition) { + name = getEngineRouteName(owner, _name); + } else { + name = _name; + } - exports.VERSION = _emberVersion.default; + var route = _emberUtils.getOwner(this).lookup('route:' + name); + var transition = this.router ? this.router.router.activeTransition : null; - /** - The semantic version - @property VERSION - @type String - @public - */ - _emberMetal.default.VERSION = _emberVersion.default; + // If we are mid-transition, we want to try and look up + // resolved parent contexts on the current transitionEvent. + if (transition) { + var modelLookupName = route && route.routeName || name; + if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { + return transition.resolvedModels[modelLookupName]; + } + } - _emberMetal.libraries.registerCoreLibrary('Ember', _emberVersion.default); + return route && route.currentModel; + }, - _emberMetal.default.create = _emberMetal.deprecateFunc('Ember.create is deprecated in favor of Object.create', { id: 'ember-metal.ember-create', until: '3.0.0' }, Object.create); - _emberMetal.default.keys = _emberMetal.deprecateFunc('Ember.keys is deprecated in favor of Object.keys', { id: 'ember-metal.ember.keys', until: '3.0.0' }, Object.keys); + /** + A hook you can use to render the template for the current route. + This method is called with the controller for the current route and the + model supplied by the `model` hook. By default, it renders the route's + template, configured with the controller for the route. + This method can be overridden to set up and render additional or + alternative templates. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate(controller, model) { + let favController = this.controllerFor('favoritePost'); + // Render the `favoritePost` template into + // the outlet `posts`, and display the `favoritePost` + // controller. + this.render('favoritePost', { + outlet: 'posts', + controller: favController + }); + } + }); + ``` + @method renderTemplate + @param {Object} controller the route's controller + @param {Object} model the route's model + @since 1.0.0 + @public + */ + renderTemplate: function (controller, model) { + this.render(); + }, - // require the main entry points for each of these packages - // this is so that the global exports occur properly + /** + `render` is used to render a template into a region of another template + (indicated by an `{{outlet}}`). `render` is used both during the entry + phase of routing (via the `renderTemplate` hook) and later in response to + user interaction. + For example, given the following minimal router and templates: + ```app/router.js + // ... + Router.map(function() { + this.route('photos'); + }); + export default Router; + ``` + ```handlebars + +
    + {{outlet "anOutletName"}} +
    + ``` + ```handlebars + +

    Photos

    + ``` + You can render `photos.hbs` into the `"anOutletName"` outlet of + `application.hbs` by calling `render`: + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate() { + this.render('photos', { + into: 'application', + outlet: 'anOutletName' + }) + } + }); + ``` + `render` additionally allows you to supply which `controller` and + `model` objects should be loaded and associated with the rendered template. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate(controller, model){ + this.render('posts', { // the template to render, referenced by name + into: 'application', // the template to render into, referenced by name + outlet: 'anOutletName', // the outlet inside `options.template` to render into. + controller: 'someControllerName', // the controller to use for this template, referenced by name + model: model // the model to set on `options.controller`. + }) + } + }); + ``` + The string values provided for the template name, and controller + will eventually pass through to the resolver for lookup. See + Ember.Resolver for how these are mapped to JavaScript objects in your + application. The template to render into needs to be related to either the + current route or one of its ancestors. + Not all options need to be passed to `render`. Default values will be used + based on the name of the route specified in the router or the Route's + `controllerName` and `templateName` properties. + For example: + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('post', { path: '/posts/:post_id' }); + }); + export default Router; + ``` + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate() { + this.render(); // all defaults apply + } + }); + ``` + The name of the route, defined by the router, is `post`. + The following equivalent default options will be applied when + the Route calls `render`: + ```javascript + this.render('post', { // the template name associated with 'post' Route + into: 'application', // the parent route to 'post' Route + outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, + controller: 'post', // the controller associated with the 'post' Route + }) + ``` + By default the controller's `model` will be the route's model, so it does not + need to be passed unless you wish to change which model is being used. + @method render + @param {String} name the name of the template to render + @param {Object} [options] the options + @param {String} [options.into] the template to render into, + referenced by name. Defaults to the parent template + @param {String} [options.outlet] the outlet inside `options.template` to render into. + Defaults to 'main' + @param {String|Object} [options.controller] the controller to use for this template, + referenced by name or as a controller instance. Defaults to the Route's paired controller + @param {Object} [options.model] the model object to set on `options.controller`. + Defaults to the return value of the Route's model hook + @since 1.0.0 + @public + */ + render: function (_name, options) { + _emberMetal.assert('The name in the given arguments is undefined', arguments.length > 0 ? !_emberMetal.isNone(arguments[0]) : true); - /** - Alias for jQuery - - @method $ - @for Ember - @public - */ - _emberMetal.default.$ = _emberViews.jQuery; + var namePassed = typeof _name === 'string' && !!_name; + var isDefaultRender = arguments.length === 0 || _emberMetal.isEmpty(arguments[0]); + var name = undefined; - _emberMetal.default.ViewTargetActionSupport = _emberViews.ViewTargetActionSupport; + if (typeof _name === 'object' && !options) { + name = this.templateName || this.routeName; + options = _name; + } else { + name = _name; + } - _emberMetal.default.ViewUtils = { - isSimpleClick: _emberViews.isSimpleClick, - getViewElement: _emberViews.getViewElement, - getViewBounds: _emberViews.getViewBounds, - getViewClientRects: _emberViews.getViewClientRects, - getViewBoundingClientRect: _emberViews.getViewBoundingClientRect, - getRootViews: _emberViews.getRootViews, - getChildViews: _emberViews.getChildViews - }; + var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); + this.connections.push(renderOptions); + _emberMetal.run.once(this.router, '_setOutlets'); + }, - _emberMetal.default.TextSupport = _emberViews.TextSupport; - _emberMetal.default.ComponentLookup = _emberViews.ComponentLookup; - _emberMetal.default.EventDispatcher = _emberViews.EventDispatcher; + /** + Disconnects a view that has been rendered into an outlet. + You may pass any or all of the following options to `disconnectOutlet`: + * `outlet`: the name of the outlet to clear (default: 'main') + * `parentView`: the name of the view containing the outlet to clear + (default: the view rendered by the parent route) + Example: + ```app/routes/application.js + import Ember from 'ember'; + export default App.Route.extend({ + actions: { + showModal(evt) { + this.render(evt.modalName, { + outlet: 'modal', + into: 'application' + }); + }, + hideModal(evt) { + this.disconnectOutlet({ + outlet: 'modal', + parentView: 'application' + }); + } + } + }); + ``` + Alternatively, you can pass the `outlet` name directly as a string. + Example: + ```app/routes/application.js + import Ember from 'ember'; + export default App.Route.extend({ + actions: { + showModal(evt) { + // ... + }, + hideModal(evt) { + this.disconnectOutlet('modal'); + } + } + }); + @method disconnectOutlet + @param {Object|String} options the options hash or outlet name + @since 1.0.0 + @public + */ + disconnectOutlet: function (options) { + var outletName = undefined; + var parentView = undefined; + if (!options || typeof options === 'string') { + outletName = options; + } else { + outletName = options.outlet; + parentView = options.parentView; - _emberMetal.default.Location = _emberRouting.Location; - _emberMetal.default.AutoLocation = _emberRouting.AutoLocation; - _emberMetal.default.HashLocation = _emberRouting.HashLocation; - _emberMetal.default.HistoryLocation = _emberRouting.HistoryLocation; - _emberMetal.default.NoneLocation = _emberRouting.NoneLocation; - _emberMetal.default.controllerFor = _emberRouting.controllerFor; - _emberMetal.default.generateControllerFactory = _emberRouting.generateControllerFactory; - _emberMetal.default.generateController = _emberRouting.generateController; - _emberMetal.default.RouterDSL = _emberRouting.RouterDSL; - _emberMetal.default.Router = _emberRouting.Router; - _emberMetal.default.Route = _emberRouting.Route; + if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { + throw new _emberMetal.Error('You passed undefined as the outlet name.'); + } + } + parentView = parentView && parentView.replace(/\//g, '.'); + outletName = outletName || 'main'; + this._disconnectOutlet(outletName, parentView); + for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { + // This non-local state munging is sadly necessary to maintain + // backward compatibility with our existing semantics, which allow + // any route to disconnectOutlet things originally rendered by any + // other route. This should all get cut in 2.0. + this.router.router.currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); + } + }, - _emberMetal.default.Application = _emberApplication.Application; - _emberMetal.default.ApplicationInstance = _emberApplication.ApplicationInstance; - _emberMetal.default.Engine = _emberApplication.Engine; - _emberMetal.default.EngineInstance = _emberApplication.EngineInstance; - _emberMetal.default.DefaultResolver = _emberMetal.default.Resolver = _emberApplication.Resolver; + _disconnectOutlet: function (outletName, parentView) { + var parent = parentRoute(this); + if (parent && parentView === parent.routeName) { + parentView = undefined; + } + for (var i = 0; i < this.connections.length; i++) { + var connection = this.connections[i]; + if (connection.outlet === outletName && connection.into === parentView) { + // This neuters the disconnected outlet such that it doesn't + // render anything, but it leaves an entry in the outlet + // hierarchy so that any existing other renders that target it + // don't suddenly blow up. They will still stick themselves + // into its outlets, which won't render anywhere. All of this + // statefulness should get the machete in 2.0. + this.connections[i] = { + owner: connection.owner, + into: connection.into, + outlet: connection.outlet, + name: connection.name, + controller: undefined, + template: undefined, + ViewClass: undefined + }; + _emberMetal.run.once(this.router, '_setOutlets'); + } + } + }, - _emberRuntime.runLoadHooks('Ember.Application', _emberApplication.Application); + willDestroy: function () { + this.teardownViews(); + }, - _emberMetal.default.DataAdapter = _emberExtensionSupport.DataAdapter; - _emberMetal.default.ContainerDebugAdapter = _emberExtensionSupport.ContainerDebugAdapter; + /** + @private + @method teardownViews + */ + teardownViews: function () { + if (this.connections && this.connections.length > 0) { + this.connections = []; + _emberMetal.run.once(this.router, '_setOutlets'); + } + } + }); - if (_require.has('ember-template-compiler')) { - _require.default('ember-template-compiler'); - } + _emberRuntime.deprecateUnderscoreActions(Route); - // do this to ensure that Ember.Test is defined properly on the global - // if it is present. - if (_require.has('ember-testing')) { - var testing = _require.default('ember-testing'); + Route.reopenClass({ + isRouteFactory: true + }); - _emberMetal.default.Test = testing.Test; - _emberMetal.default.Test.Adapter = testing.Adapter; - _emberMetal.default.Test.QUnitAdapter = testing.QUnitAdapter; - _emberMetal.default.setupForTesting = testing.setupForTesting; + function parentRoute(route) { + var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); + return handlerInfo && handlerInfo.handler; } - _emberRuntime.runLoadHooks('Ember'); + function handlerInfoFor(route, handlerInfos) { + var offset = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2]; - /** - @module ember - */ - exports.default = _emberMetal.default; + if (!handlerInfos) { + return; + } - /* globals module */ - if (typeof module === 'object' && module.exports) { - module.exports = _emberMetal.default; - } else { - _emberEnvironment.context.exports.Ember = _emberEnvironment.context.exports.Em = _emberMetal.default; + var current = undefined; + for (var i = 0; i < handlerInfos.length; i++) { + current = handlerInfos[i].handler; + if (current === route) { + return handlerInfos[i + offset]; + } + } } -}); -// ****ember-environment**** + function buildRenderOptions(route, namePassed, isDefaultRender, _name, options) { + var into = options && options.into && options.into.replace(/\//g, '.'); + var outlet = options && options.outlet || 'main'; -// ****ember-metal**** + var name = undefined, + templateName = undefined; + if (_name) { + name = _name.replace(/\//g, '.'); + templateName = name; + } else { + name = route.routeName; + templateName = route.templateName || name; + } -// computed macros + var owner = _emberUtils.getOwner(route); + var controller = options && options.controller; + if (!controller) { + if (namePassed) { + controller = owner.lookup('controller:' + name) || route.controllerName || route.routeName; + } else { + controller = route.controllerName || owner.lookup('controller:' + name); + } + } -// reduced computed macros -enifed("ember/version", ["exports"], function (exports) { - "use strict"; + if (typeof controller === 'string') { + var controllerName = controller; + controller = owner.lookup('controller:' + controllerName); + if (!controller) { + throw new _emberMetal.Error('You passed `controller: \'' + controllerName + '\'` into the `render` method, but no such controller could be found.'); + } + } - exports.default = "2.11.0-beta.2"; -}); -enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { + throw new _emberMetal.Error('You passed undefined as the outlet name.'); + } - exports.default = applyMixins; + if (options && options.model) { + controller.set('model', options.model); + } - function isGenerator(mixin) { - return Array.isArray(mixin.cases) && typeof mixin.generate === 'function'; - } + var template = owner.lookup('template:' + templateName); - function applyMixins(TestClass) { - for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - mixins[_key - 1] = arguments[_key]; + var parent = undefined; + if (into && (parent = parentRoute(route)) && into === parent.routeName) { + into = undefined; } - mixins.forEach(function (mixinOrGenerator) { - var mixin = undefined; + var renderOptions = { + owner: owner, + into: into, + outlet: outlet, + name: name, + controller: controller, + template: template || route._topLevelViewTemplate, + ViewClass: undefined + }; - if (isGenerator(mixinOrGenerator)) { - (function () { - var generator = mixinOrGenerator; - mixin = {}; + _emberMetal.assert('Could not find "' + name + '" template, view, or component.', isDefaultRender || template); - generator.cases.forEach(function (value, idx) { - _emberUtils.assign(mixin, generator.generate(value, idx)); - }); - })(); - } else { - mixin = mixinOrGenerator; + _emberMetal.runInDebug(function () { + var LOG_VIEW_LOOKUPS = _emberMetal.get(route.router, 'namespace.LOG_VIEW_LOOKUPS'); + if (LOG_VIEW_LOOKUPS && !template) { + _emberMetal.info('Could not find "' + name + '" template. Nothing will be rendered', { fullName: 'template:' + name }); } - - _emberUtils.assign(TestClass.prototype, mixin); }); - return TestClass; + return renderOptions; } -}); -enifed('internal-test-helpers/build-owner', ['exports', 'container', 'ember-routing', 'ember-application', 'ember-runtime'], function (exports, _container, _emberRouting, _emberApplication, _emberRuntime) { - 'use strict'; - exports.default = buildOwner; + function getFullQueryParams(router, state) { + if (state.fullQueryParams) { + return state.fullQueryParams; + } - function buildOwner() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + state.fullQueryParams = {}; + _emberUtils.assign(state.fullQueryParams, state.queryParams); - var ownerOptions = options.ownerOptions || {}; - var resolver = options.resolver; - var bootOptions = options.bootOptions || {}; + router._deserializeQueryParams(state.handlerInfos, state.fullQueryParams); + return state.fullQueryParams; + } - var Owner = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin); + function getQueryParamsFor(route, state) { + state.queryParamsFor = state.queryParamsFor || {}; + var name = route.fullRouteName; - var namespace = _emberRuntime.Object.create({ - Resolver: { create: function () { - return resolver; - } } - }); + if (state.queryParamsFor[name]) { + return state.queryParamsFor[name]; + } - var fallbackRegistry = _emberApplication.Application.buildRegistry(namespace); - fallbackRegistry.register('router:main', _emberRouting.Router); + var fullQueryParams = getFullQueryParams(route.router, state); - var registry = new _container.Registry({ - fallback: fallbackRegistry - }); + var params = state.queryParamsFor[name] = {}; - _emberApplication.ApplicationInstance.setupRegistry(registry, bootOptions); + // Copy over all the query params for this route/controller into params hash. + var qpMeta = _emberMetal.get(route, '_qp'); + var qps = qpMeta.qps; + for (var i = 0; i < qps.length; ++i) { + // Put deserialized qp on params hash. + var qp = qps[i]; - var owner = Owner.create({ - __registry__: registry, - __container__: null - }, ownerOptions); + var qpValueWasPassedIn = (qp.prop in fullQueryParams); + params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.defaultValue); + } - var container = registry.container({ owner: owner }); - owner.__container__ = container; + return params; + } - return owner; + function copyDefaultValue(value) { + if (Array.isArray(value)) { + return _emberRuntime.A(value.slice()); + } + return value; } -}); -enifed('internal-test-helpers/confirm-export', ['exports', 'require'], function (exports, _require) { - 'use strict'; - exports.default = confirmExport; + /* + Merges all query parameters from a controller with those from + a route, returning a new object and avoiding any mutations to + the existing objects. + */ + function mergeEachQueryParams(controllerQP, routeQP) { + var keysAlreadyMergedOrSkippable = undefined; + var qps = {}; - function getDescriptor(obj, path) { - var parts = path.split('.'); - var value = obj; - for (var i = 0; i < parts.length - 1; i++) { - var part = parts[i]; - value = value[part]; - if (!value) { - return undefined; + keysAlreadyMergedOrSkippable = { + defaultValue: true, + type: true, + scope: true, + as: true + }; + + // first loop over all controller qps, merging them with any matching route qps + // into a new empty object to avoid mutating. + for (var cqpName in controllerQP) { + if (!controllerQP.hasOwnProperty(cqpName)) { + continue; } - } - var last = parts[parts.length - 1]; - return Object.getOwnPropertyDescriptor(value, last); - } - function confirmExport(Ember, assert, path, moduleId, exportName) { - var desc = getDescriptor(Ember, path); - assert.ok(desc, 'the property exists on the global'); + var newControllerParameterConfiguration = {}; + _emberUtils.assign(newControllerParameterConfiguration, controllerQP[cqpName]); + _emberUtils.assign(newControllerParameterConfiguration, routeQP[cqpName]); - var mod = _require.default(moduleId); - if (typeof exportName === 'string') { - assert.equal(desc.value, mod[exportName], 'Ember.' + path + ' is exported correctly'); - assert.notEqual(mod[exportName], undefined, 'Ember.' + path + ' is not `undefined`'); - } else { - assert.equal(desc.get, mod[exportName.get], 'Ember.' + path + ' getter is exported correctly'); - assert.notEqual(desc.get, undefined, 'Ember.' + path + ' getter is not undefined'); + qps[cqpName] = newControllerParameterConfiguration; - if (exportName.set) { - assert.equal(desc.set, mod[exportName.set], 'Ember.' + path + ' setter is exported correctly'); - assert.notEqual(desc.set, undefined, 'Ember.' + path + ' setter is not undefined'); + // allows us to skip this QP when we check route QPs. + keysAlreadyMergedOrSkippable[cqpName] = true; + } + + // loop over all route qps, skipping those that were merged in the first pass + // because they also appear in controller qps + for (var rqpName in routeQP) { + if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { + continue; } + + var newRouteParameterConfiguration = {}; + _emberUtils.assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); + qps[rqpName] = newRouteParameterConfiguration; } + + return qps; } -}); -enifed('internal-test-helpers/equal-inner-html', ['exports'], function (exports) { - // detect side-effects of cloning svg elements in IE9-11 - 'use strict'; - exports.default = equalInnerHTML; - var ieSVGInnerHTML = (function () { - if (!document.createElementNS) { - return false; - } - var div = document.createElement('div'); - var node = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - div.appendChild(node); - var clone = div.cloneNode(true); - return clone.innerHTML === ''; - })(); + function addQueryParamsObservers(controller, propNames) { + propNames.forEach(function (prop) { + controller.addObserver(prop + '.[]', controller, controller._qpChanged); + }); + } - function normalizeInnerHTML(actualHTML) { - if (ieSVGInnerHTML) { - // Replace `` with ``, etc. - // drop namespace attribute - actualHTML = actualHTML.replace(/ xmlns="[^"]+"/, ''); - // replace self-closing elements - actualHTML = actualHTML.replace(/<([^ >]+) [^\/>]*\/>/gi, function (tag, tagName) { - return tag.slice(0, tag.length - 3) + '>'; - }); + function getEngineRouteName(engine, routeName) { + if (engine.routable) { + var prefix = engine.mountPoint; + + if (routeName === 'application') { + return prefix; + } else { + return prefix + '.' + routeName; + } } - return actualHTML; + return routeName; } - function equalInnerHTML(fragment, html) { - var actualHTML = normalizeInnerHTML(fragment.innerHTML); - QUnit.push(actualHTML === html, actualHTML, html); - } + exports.default = Route; }); -enifed('internal-test-helpers/equal-tokens', ['exports', 'simple-html-tokenizer'], function (exports, _simpleHtmlTokenizer) { +enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-routing/system/route', 'ember-routing/system/dsl', 'ember-routing/location/api', 'ember-routing/utils', 'ember-routing/system/router_state', 'container', 'router'], function (exports, _emberUtils, _emberConsole, _emberMetal, _emberRuntime, _emberRoutingSystemRoute, _emberRoutingSystemDsl, _emberRoutingLocationApi, _emberRoutingUtils, _emberRoutingSystemRouter_state, _container, _router5) { 'use strict'; - exports.default = equalTokens; + exports.triggerEvent = triggerEvent; - function generateTokens(containerOrHTML) { - if (typeof containerOrHTML === 'string') { - return { - tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML), - html: containerOrHTML - }; - } else { - return { - tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML.innerHTML), - html: containerOrHTML.innerHTML - }; - } + function K() { + return this; } - function normalizeTokens(tokens) { - tokens.forEach(function (token) { - if (token.type === 'StartTag') { - token.attributes = token.attributes.sort(function (a, b) { - if (a[0] > b[0]) { - return 1; - } - if (a[0] < b[0]) { - return -1; - } - return 0; - }); - } - }); - } + var slice = Array.prototype.slice; - function equalTokens(actualContainer, expectedHTML) { - var message = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + /** + The `Ember.Router` class manages the application state and URLs. Refer to + the [routing guide](http://emberjs.com/guides/routing/) for documentation. + + @class Router + @namespace Ember + @extends Ember.Object + @uses Ember.Evented + @public + */ + var EmberRouter = _emberRuntime.Object.extend(_emberRuntime.Evented, { + /** + The `location` property determines the type of URL's that your + application will use. + The following location types are currently available: + * `history` - use the browser's history API to make the URLs look just like any standard URL + * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new` + * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing) + * `auto` - use the best option based on browser capabilites: `history` if possible, then `hash` if possible, otherwise `none` + Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js` + @property location + @default 'hash' + @see {Ember.Location} + @public + */ + location: 'hash', - var actual = generateTokens(actualContainer); - var expected = generateTokens(expectedHTML); + /** + Represents the URL of the root of the application, often '/'. This prefix is + assumed on all routes defined on this router. + @property rootURL + @default '/' + @public + */ + rootURL: '/', - normalizeTokens(actual.tokens); - normalizeTokens(expected.tokens); + _initRouterJs: function () { + var _this = this; - var equiv = QUnit.equiv(actual.tokens, expected.tokens); + var router = this.router = new _router5.default(); + router.triggerEvent = triggerEvent; - if (equiv && expected.html !== actual.html) { - deepEqual(actual.tokens, expected.tokens, message); - } else { - QUnit.push(QUnit.equiv(actual.tokens, expected.tokens), actual.html, expected.html, message); - } - } -}); -enifed('internal-test-helpers/factory', ['exports'], function (exports) { - 'use strict'; + router._triggerWillChangeContext = K; + router._triggerWillLeave = K; - exports.default = factory; - function setProperties(object, properties) { - for (var key in properties) { - if (properties.hasOwnProperty(key)) { - object[key] = properties[key]; - } - } - } + var dslCallbacks = this.constructor.dslCallbacks || [K]; + var dsl = this._buildDSL(); - var guids = 0; + dsl.route('application', { path: '/', resetNamespace: true, overrideNameAssertion: true }, function () { + for (var i = 0; i < dslCallbacks.length; i++) { + dslCallbacks[i].call(this); + } + }); - function factory() { - /*jshint validthis: true */ + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this, 'namespace.LOG_TRANSITIONS_INTERNAL')) { + router.log = _emberConsole.default.debug; + } + }); - function Klass(options) { - setProperties(this, options); - this._guid = guids++; - this.isDestroyed = false; - } + router.map(dsl.generate()); + }, - Klass.prototype.constructor = Klass; - Klass.prototype.destroy = function () { - this.isDestroyed = true; - }; + _buildDSL: function () { + var moduleBasedResolver = this._hasModuleBasedResolver(); + var options = { + enableLoadingSubstates: !!moduleBasedResolver + }; - Klass.prototype.toString = function () { - return ''; - }; + var owner = _emberUtils.getOwner(this); + var router = this; - Klass.create = create; - Klass.extend = extend; - Klass.reopen = extend; - Klass.reopenClass = reopenClass; + options.resolveRouteMap = function (name) { + return owner[_container.FACTORY_FOR]('route-map:' + name); + }; - return Klass; + options.addRouteForEngine = function (name, engineInfo) { + if (!router._engineInfoByRoute[name]) { + router._engineInfoByRoute[name] = engineInfo; + } + }; - function create(options) { - return new this.prototype.constructor(options); - } + return new _emberRoutingSystemDsl.default(null, options); + }, - function reopenClass(options) { - setProperties(this, options); - } + init: function () { + this._super.apply(this, arguments); - function extend(options) { - function Child(options) { - Klass.call(this, options); + this.currentURL = null; + this.currentRouteName = null; + this.currentPath = null; + + this._qpCache = new _emberUtils.EmptyObject(); + this._resetQueuedQueryParameterChanges(); + this._handledErrors = _emberUtils.dictionary(null); + this._engineInstances = new _emberUtils.EmptyObject(); + this._engineInfoByRoute = new _emberUtils.EmptyObject(); + }, + + /* + Resets all pending query paramter changes. + Called after transitioning to a new route + based on query parameter changes. + */ + _resetQueuedQueryParameterChanges: function () { + this._queuedQPChanges = {}; + }, + + /** + Represents the current URL. + @method url + @return {String} The current URL. + @private + */ + url: _emberMetal.computed(function () { + return _emberMetal.get(this, 'location').getURL(); + }), + + _hasModuleBasedResolver: function () { + var owner = _emberUtils.getOwner(this); + + if (!owner) { + return false; } - var Parent = this; + var resolver = owner.application && owner.application.__registry__ && owner.application.__registry__.resolver; - Child.prototype = new Parent(); - Child.prototype.constructor = Child; + if (!resolver) { + return false; + } - setProperties(Child, Klass); - setProperties(Child.prototype, options); + return !!resolver.moduleBasedResolver; + }, - Child.create = create; - Child.extend = extend; - Child.reopen = extend; + /** + Initializes the current router instance and sets up the change handling + event listeners used by the instances `location` implementation. + A property named `initialURL` will be used to determine the initial URL. + If no value is found `/` will be used. + @method startRouting + @private + */ + startRouting: function () { + var initialURL = _emberMetal.get(this, 'initialURL'); - Child.reopenClass = reopenClass; + if (this.setupRouter()) { + if (typeof initialURL === 'undefined') { + initialURL = _emberMetal.get(this, 'location').getURL(); + } + var initialTransition = this.handleURL(initialURL); + if (initialTransition && initialTransition.error) { + throw initialTransition.error; + } + } + }, - return Child; - } - } -}); -enifed('internal-test-helpers/index', ['exports', 'internal-test-helpers/factory', 'internal-test-helpers/build-owner', 'internal-test-helpers/confirm-export', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/module-for', 'internal-test-helpers/strip', 'internal-test-helpers/apply-mixins', 'internal-test-helpers/matchers', 'internal-test-helpers/run', 'internal-test-helpers/test-groups', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/test-cases/abstract-application', 'internal-test-helpers/test-cases/application', 'internal-test-helpers/test-cases/query-param', 'internal-test-helpers/test-cases/abstract-rendering', 'internal-test-helpers/test-cases/rendering'], function (exports, _internalTestHelpersFactory, _internalTestHelpersBuildOwner, _internalTestHelpersConfirmExport, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersModuleFor, _internalTestHelpersStrip, _internalTestHelpersApplyMixins, _internalTestHelpersMatchers, _internalTestHelpersRun, _internalTestHelpersTestGroups, _internalTestHelpersTestCasesAbstract, _internalTestHelpersTestCasesAbstractApplication, _internalTestHelpersTestCasesApplication, _internalTestHelpersTestCasesQueryParam, _internalTestHelpersTestCasesAbstractRendering, _internalTestHelpersTestCasesRendering) { - 'use strict'; + setupRouter: function () { + var _this2 = this; - exports.factory = _internalTestHelpersFactory.default; - exports.buildOwner = _internalTestHelpersBuildOwner.default; - exports.confirmExport = _internalTestHelpersConfirmExport.default; - exports.equalInnerHTML = _internalTestHelpersEqualInnerHtml.default; - exports.equalTokens = _internalTestHelpersEqualTokens.default; - exports.moduleFor = _internalTestHelpersModuleFor.default; - exports.strip = _internalTestHelpersStrip.default; - exports.applyMixins = _internalTestHelpersApplyMixins.default; - exports.equalsElement = _internalTestHelpersMatchers.equalsElement; - exports.classes = _internalTestHelpersMatchers.classes; - exports.styles = _internalTestHelpersMatchers.styles; - exports.regex = _internalTestHelpersMatchers.regex; - exports.runAppend = _internalTestHelpersRun.runAppend; - exports.runDestroy = _internalTestHelpersRun.runDestroy; - exports.testBoth = _internalTestHelpersTestGroups.testBoth; - exports.testWithDefault = _internalTestHelpersTestGroups.testWithDefault; - exports.AbstractTestCase = _internalTestHelpersTestCasesAbstract.default; - exports.AbstractApplicationTestCase = _internalTestHelpersTestCasesAbstractApplication.default; - exports.ApplicationTestCase = _internalTestHelpersTestCasesApplication.default; - exports.QueryParamTestCase = _internalTestHelpersTestCasesQueryParam.default; - exports.AbstractRenderingTestCase = _internalTestHelpersTestCasesAbstractRendering.default; - exports.RenderingTestCase = _internalTestHelpersTestCasesRendering.default; -}); -enifed('internal-test-helpers/matchers', ['exports'], function (exports) { - 'use strict'; + this._initRouterJs(); + this._setupLocation(); - exports.regex = regex; - exports.classes = classes; - exports.styles = styles; - exports.equalsElement = equalsElement; - var HTMLElement = window.HTMLElement; - var MATCHER_BRAND = '3d4ef194-13be-4ccf-8dc7-862eea02c93e'; + var router = this.router; + var location = _emberMetal.get(this, 'location'); - function isMatcher(obj) { - return typeof obj === 'object' && obj !== null && MATCHER_BRAND in obj; - } + // Allow the Location class to cancel the router setup while it refreshes + // the page + if (_emberMetal.get(location, 'cancelRouterSetup')) { + return false; + } - function equalsAttr(expected) { - var _ref; + this._setupRouter(router, location); + + location.onUpdateURL(function (url) { + _this2.handleURL(url); + }); + + return true; + }, + + /** + Handles updating the paths and notifying any listeners of the URL + change. + Triggers the router level `didTransition` hook. + For example, to notify google analytics when the route changes, + you could use this hook. (Note: requires also including GA scripts, etc.) + ```javascript + let Router = Ember.Router.extend({ + location: config.locationType, + didTransition: function() { + this._super(...arguments); + return ga('send', 'pageview', { + 'page': this.get('url'), + 'title': this.get('url') + }); + } + }); + ``` + @method didTransition + @public + @since 1.2.0 + */ + didTransition: function (infos) { + var _this3 = this; - return _ref = {}, _ref[MATCHER_BRAND] = true, _ref.match = function (actual) { - return expected === actual; - }, _ref.expected = function () { - return expected; - }, _ref.message = function () { - return 'should equal ' + this.expected(); - }, _ref; - } + updatePaths(this); - function regex(r) { - var _ref2; + this._cancelSlowTransitionTimer(); - return _ref2 = {}, _ref2[MATCHER_BRAND] = true, _ref2.match = function (v) { - return r.test(v); - }, _ref2.expected = function () { - return r.toString(); - }, _ref2.message = function () { - return 'should match ' + this.expected(); - }, _ref2; - } + this.notifyPropertyChange('url'); + this.set('currentState', this.targetState); - function classes(expected) { - var _ref3; + // Put this in the runloop so url will be accurate. Seems + // less surprising than didTransition being out of sync. + _emberMetal.run.once(this, this.trigger, 'didTransition'); - return _ref3 = {}, _ref3[MATCHER_BRAND] = true, _ref3.match = function (actual) { - actual = actual.trim(); - return actual && expected.split(/\s+/).sort().join(' ') === actual.trim().split(/\s+/).sort().join(' '); - }, _ref3.expected = function () { - return expected; - }, _ref3.message = function () { - return 'should match ' + this.expected(); - }, _ref3; - } + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this3, 'namespace').LOG_TRANSITIONS) { + _emberConsole.default.log('Transitioned into \'' + EmberRouter._routePath(infos) + '\''); + } + }); + }, - function styles(expected) { - var _ref4; + _setOutlets: function () { + // This is triggered async during Ember.Route#willDestroy. + // If the router is also being destroyed we do not want to + // to create another this._toplevelView (and leak the renderer) + if (this.isDestroying || this.isDestroyed) { + return; + } - return _ref4 = {}, _ref4[MATCHER_BRAND] = true, _ref4.match = function (actual) { - // coerce `null` or `undefined` to an empty string - // needed for matching empty styles on IE9 - IE11 - actual = actual || ''; - actual = actual.trim(); + var handlerInfos = this.router.currentHandlerInfos; + var route = undefined; + var defaultParentState = undefined; + var liveRoutes = null; - return expected.split(';').map(function (s) { - return s.trim(); - }).filter(function (s) { - return s; - }).sort().join('; ') === actual.split(';').map(function (s) { - return s.trim(); - }).filter(function (s) { - return s; - }).sort().join('; '); - }, _ref4.expected = function () { - return expected; - }, _ref4.message = function () { - return 'should match ' + this.expected(); - }, _ref4; - } + if (!handlerInfos) { + return; + } - function equalsElement(element, tagName, attributes, content) { - QUnit.push(element.tagName === tagName.toUpperCase(), element.tagName.toLowerCase(), tagName, 'expect tagName to be ' + tagName); + for (var i = 0; i < handlerInfos.length; i++) { + route = handlerInfos[i].handler; + var connections = route.connections; + var ownState = undefined; + for (var j = 0; j < connections.length; j++) { + var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); + liveRoutes = appended.liveRoutes; + if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { + ownState = appended.ownState; + } + } + if (connections.length === 0) { + ownState = representEmptyRoute(liveRoutes, defaultParentState, route); + } + defaultParentState = ownState; + } - var expectedAttrs = {}; - var expectedCount = 0; + // when a transitionTo happens after the validation phase + // during the initial transition _setOutlets is called + // when no routes are active. However, it will get called + // again with the correct values during the next turn of + // the runloop + if (!liveRoutes) { + return; + } - for (var _name in attributes) { - var expected = attributes[_name]; - if (expected !== null) { - expectedCount++; + if (!this._toplevelView) { + var owner = _emberUtils.getOwner(this); + var OutletView = owner[_container.FACTORY_FOR]('view:-outlet'); + this._toplevelView = OutletView.create(); + this._toplevelView.setOutletState(liveRoutes); + var instance = owner.lookup('-application-instance:main'); + instance.didCreateRootView(this._toplevelView); + } else { + this._toplevelView.setOutletState(liveRoutes); } + }, - var matcher = isMatcher(expected) ? expected : equalsAttr(expected); + /** + Handles notifying any listeners of an impending URL + change. + Triggers the router level `willTransition` hook. + @method willTransition + @public + @since 1.11.0 + */ + willTransition: function (oldInfos, newInfos, transition) { + var _this4 = this; - expectedAttrs[_name] = matcher; + _emberMetal.run.once(this, this.trigger, 'willTransition', transition); - QUnit.push(expectedAttrs[_name].match(element.getAttribute(_name)), element.getAttribute(_name), matcher.expected(), 'Element\'s ' + _name + ' attribute ' + matcher.message()); - } + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this4, 'namespace').LOG_TRANSITIONS) { + _emberConsole.default.log('Preparing to transition from \'' + EmberRouter._routePath(oldInfos) + '\' to \'' + EmberRouter._routePath(newInfos) + '\''); + } + }); + }, - var actualAttributes = {}; + handleURL: function (url) { + // Until we have an ember-idiomatic way of accessing #hashes, we need to + // remove it because router.js doesn't know how to handle it. + url = url.split(/#(.+)?/)[0]; + return this._doURLTransition('handleURL', url); + }, - for (var i = 0, l = element.attributes.length; i < l; i++) { - actualAttributes[element.attributes[i].name] = element.attributes[i].value; - } + _doURLTransition: function (routerJsMethod, url) { + var transition = this.router[routerJsMethod](url || '/'); + didBeginTransition(transition, this); + return transition; + }, - if (!(element instanceof HTMLElement)) { - QUnit.push(element instanceof HTMLElement, null, null, 'Element must be an HTML Element, not an SVG Element'); - } else { - QUnit.push(element.attributes.length === expectedCount || !attributes, element.attributes.length, expectedCount, 'Expected ' + expectedCount + ' attributes; got ' + element.outerHTML); + /** + 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 + @public + */ + transitionTo: function () { + var queryParams = undefined; - if (content !== null) { - QUnit.push(element.innerHTML === content, element.innerHTML, content, 'The element had \'' + content + '\' as its content'); + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - } - } -}); -enifed('internal-test-helpers/module-for', ['exports', 'internal-test-helpers/apply-mixins'], function (exports, _internalTestHelpersApplyMixins) { - 'use strict'; - exports.default = moduleFor; - - function moduleFor(description, TestClass) { - var context = undefined; - - QUnit.module(description, { - setup: function () { - context = new TestClass(); - }, + if (resemblesURL(args[0])) { + return this._doURLTransition('transitionTo', args[0]); + } - teardown: function () { - context.teardown(); + var possibleQueryParams = args[args.length - 1]; + if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { + queryParams = args.pop().queryParams; + } else { + queryParams = {}; } - }); - for (var _len = arguments.length, mixins = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - mixins[_key - 2] = arguments[_key]; - } + var targetRouteName = args.shift(); + return this._doTransition(targetRouteName, args, queryParams); + }, - _internalTestHelpersApplyMixins.default(TestClass, mixins); + intermediateTransitionTo: function () { + var _router, + _this5 = this; - var proto = TestClass.prototype; + (_router = this.router).intermediateTransitionTo.apply(_router, arguments); - while (proto !== Object.prototype) { - Object.keys(proto).forEach(generateTest); - proto = Object.getPrototypeOf(proto); - } + updatePaths(this); - function generateTest(name) { - if (name.indexOf('@test ') === 0) { - QUnit.test(name.slice(5), function (assert) { - return context[name](assert); - }); - } else if (name.indexOf('@skip ') === 0) { - QUnit.skip(name.slice(5), function (assert) { - return context[name](assert); - }); - } - } - } -}); -enifed('internal-test-helpers/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + _emberMetal.runInDebug(function () { + var infos = _this5.router.currentHandlerInfos; + if (_emberMetal.get(_this5, 'namespace').LOG_TRANSITIONS) { + _emberConsole.default.log('Intermediate-transitioned into \'' + EmberRouter._routePath(infos) + '\''); + } + }); + }, - exports.runAppend = runAppend; - exports.runDestroy = runDestroy; + replaceWith: function () { + return this.transitionTo.apply(this, arguments).method('replace'); + }, - function runAppend(view) { - _emberMetal.run(view, 'appendTo', '#qunit-fixture'); - } + generate: function () { + var _router2; - function runDestroy(toDestroy) { - if (toDestroy) { - _emberMetal.run(toDestroy, 'destroy'); - } - } -}); -enifed('internal-test-helpers/strip', ['exports'], function (exports) { - 'use strict'; + var url = (_router2 = this.router).generate.apply(_router2, arguments); + return this.location.formatURL(url); + }, - exports.default = strip; + /** + Determines if the supplied route is currently active. + @method isActive + @param routeName + @return {Boolean} + @private + */ + isActive: function (routeName) { + var router = this.router; + return router.isActive.apply(router, arguments); + }, - function strip(_ref) { - for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - values[_key - 1] = arguments[_key]; - } + /** + An alternative form of `isActive` that doesn't require + manual concatenation of the arguments into a single + array. + @method isActiveIntent + @param routeName + @param models + @param queryParams + @return {Boolean} + @private + @since 1.7.0 + */ + isActiveIntent: function (routeName, models, queryParams) { + return this.currentState.isActiveIntent(routeName, models, queryParams); + }, - var strings = _ref; + send: function (name, context) { + var _router3; - var str = strings.map(function (string, index) { - var interpolated = values[index]; - return string + (interpolated !== undefined ? interpolated : ''); - }).join(''); - return str.split('\n').map(function (s) { - return s.trim(); - }).join(''); - } -}); -enifed('internal-test-helpers/test-cases/abstract-application', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-routing', 'ember-template-compiler', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/run'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberRouting, _emberTemplateCompiler, _internalTestHelpersTestCasesAbstract, _internalTestHelpersRun) { - 'use strict'; + (_router3 = this.router).trigger.apply(_router3, arguments); + }, - var AbstractApplicationTestCase = (function (_AbstractTestCase) { - babelHelpers.inherits(AbstractApplicationTestCase, _AbstractTestCase); + /** + Does this router instance have the given route. + @method hasRoute + @return {Boolean} + @private + */ + hasRoute: function (route) { + return this.router.hasRoute(route); + }, - function AbstractApplicationTestCase() { - babelHelpers.classCallCheck(this, AbstractApplicationTestCase); + /** + Resets the state of the router by clearing the current route + handlers and deactivating them. + @private + @method reset + */ + reset: function () { + if (this.router) { + this.router.reset(); + } + }, - _AbstractTestCase.call(this); + willDestroy: function () { + if (this._toplevelView) { + this._toplevelView.destroy(); + this._toplevelView = null; + } - this.element = _emberViews.jQuery('#qunit-fixture')[0]; + this._super.apply(this, arguments); - this.application = _emberMetal.run(_emberApplication.Application, 'create', this.applicationOptions); + this.reset(); - this.router = this.application.Router = _emberRouting.Router.extend(this.routerOptions); + var instances = this._engineInstances; + for (var _name in instances) { + for (var id in instances[_name]) { + _emberMetal.run(instances[_name][id], 'destroy'); + } + } + }, - this.applicationInstance = null; - } + /* + Called when an active route's query parameter has changed. + These changes are batched into a runloop run and trigger + a single transition. + */ + _activeQPChanged: function (queryParameterName, newValue) { + this._queuedQPChanges[queryParameterName] = newValue; + _emberMetal.run.once(this, this._fireQueryParamTransition); + }, - AbstractApplicationTestCase.prototype.teardown = function teardown() { - if (this.applicationInstance) { - _internalTestHelpersRun.runDestroy(this.applicationInstance); + _updatingQPChanged: function (queryParameterName) { + if (!this._qpUpdates) { + this._qpUpdates = {}; } + this._qpUpdates[queryParameterName] = true; + }, - _internalTestHelpersRun.runDestroy(this.application); - }; + /* + Triggers a transition to a route based on query parameter changes. + This is called once per runloop, to batch changes. + e.g. + if these methods are called in succession: + this._activeQPChanged('foo', '10'); + // results in _queuedQPChanges = { foo: '10' } + this._activeQPChanged('bar', false); + // results in _queuedQPChanges = { foo: '10', bar: false } + _queuedQPChanges will represent both of these changes + and the transition using `transitionTo` will be triggered + once. + */ + _fireQueryParamTransition: function () { + this.transitionTo({ queryParams: this._queuedQPChanges }); + this._resetQueuedQueryParameterChanges(); + }, - AbstractApplicationTestCase.prototype.visit = function visit(url, options) { - var _this = this; + _setupLocation: function () { + var location = _emberMetal.get(this, 'location'); + var rootURL = _emberMetal.get(this, 'rootURL'); + var owner = _emberUtils.getOwner(this); - var applicationInstance = this.applicationInstance; + if ('string' === typeof location && owner) { + var resolvedLocation = owner.lookup('location:' + location); - if (applicationInstance) { - return _emberMetal.run(applicationInstance, 'visit', url, options); - } else { - return _emberMetal.run(this.application, 'visit', url, options).then(function (instance) { - _this.applicationInstance = instance; - }); + if ('undefined' !== typeof resolvedLocation) { + location = _emberMetal.set(this, 'location', resolvedLocation); + } else { + // Allow for deprecated registration of custom location API's + var options = { + implementation: location + }; + + location = _emberMetal.set(this, 'location', _emberRoutingLocationApi.default.create(options)); + } } - }; - AbstractApplicationTestCase.prototype.transitionTo = function transitionTo() { - return _emberMetal.run.apply(undefined, [this.appRouter, 'transitionTo'].concat(babelHelpers.slice.call(arguments))); - }; + if (location !== null && typeof location === 'object') { + if (rootURL) { + _emberMetal.set(location, 'rootURL', rootURL); + } - AbstractApplicationTestCase.prototype.compile = function compile(string, options) { - return _emberTemplateCompiler.compile.apply(undefined, arguments); - }; + // Allow the location to do any feature detection, such as AutoLocation + // detecting history support. This gives it a chance to set its + // `cancelRouterSetup` property which aborts routing. + if (typeof location.detect === 'function') { + location.detect(); + } - AbstractApplicationTestCase.prototype.registerRoute = function registerRoute(name, route) { - this.application.register('route:' + name, route); - }; + // ensure that initState is called AFTER the rootURL is set on + // the location instance + if (typeof location.initState === 'function') { + location.initState(); + } + } + }, - AbstractApplicationTestCase.prototype.registerTemplate = function registerTemplate(name, template) { - this.application.register('template:' + name, this.compile(template, { - moduleName: name - })); - }; + _getHandlerFunction: function () { + var _this6 = this; - AbstractApplicationTestCase.prototype.registerComponent = function registerComponent(name, _ref) { - var _ref$ComponentClass = _ref.ComponentClass; - var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; - var _ref$template = _ref.template; - var template = _ref$template === undefined ? null : _ref$template; + var seen = new _emberUtils.EmptyObject(); + var owner = _emberUtils.getOwner(this); - if (ComponentClass) { - this.application.register('component:' + name, ComponentClass); - } + return function (name) { + var routeName = name; + var routeOwner = owner; + var engineInfo = _this6._engineInfoByRoute[routeName]; - if (typeof template === 'string') { - this.application.register('template:components/' + name, this.compile(template, { - moduleName: 'components/' + name - })); - } - }; + if (engineInfo) { + var engineInstance = _this6._getEngineInstance(engineInfo); - AbstractApplicationTestCase.prototype.registerController = function registerController(name, controller) { - this.application.register('controller:' + name, controller); - }; + routeOwner = engineInstance; + routeName = engineInfo.localFullName; + } - AbstractApplicationTestCase.prototype.registerEngine = function registerEngine(name, engine) { - this.application.register('engine:' + name, engine); - }; + var fullRouteName = 'route:' + routeName; - babelHelpers.createClass(AbstractApplicationTestCase, [{ - key: 'applicationOptions', - get: function () { - return { - rootElement: '#qunit-fixture', - autoboot: false - }; - } - }, { - key: 'routerOptions', - get: function () { - return { - location: 'none' - }; - } - }, { - key: 'appRouter', - get: function () { - return this.applicationInstance.lookup('router:main'); - } - }]); - return AbstractApplicationTestCase; - })(_internalTestHelpersTestCasesAbstract.default); + var handler = routeOwner.lookup(fullRouteName); + + if (seen[name]) { + return handler; + } + + seen[name] = true; + + if (!handler) { + var DefaultRoute = routeOwner[_container.FACTORY_FOR]('route:basic').class; + routeOwner.register(fullRouteName, DefaultRoute.extend()); + handler = routeOwner.lookup(fullRouteName); + + _emberMetal.runInDebug(function () { + if (_emberMetal.get(_this6, 'namespace.LOG_ACTIVE_GENERATION')) { + _emberMetal.info('generated -> ' + fullRouteName, { fullName: fullRouteName }); + } + }); + } - exports.default = AbstractApplicationTestCase; -}); -enifed('internal-test-helpers/test-cases/abstract-rendering', ['exports', 'ember-utils', 'ember-template-compiler', 'ember-views', 'ember-glimmer', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/build-owner', 'internal-test-helpers/run'], function (exports, _emberUtils, _emberTemplateCompiler, _emberViews, _emberGlimmer, _internalTestHelpersTestCasesAbstract, _internalTestHelpersBuildOwner, _internalTestHelpersRun) { - 'use strict'; + handler._setRouteName(routeName); + handler._populateQPMeta(); - var TextNode = window.Text; + if (engineInfo && !_emberRoutingSystemRoute.hasDefaultSerialize(handler)) { + throw new Error('Defining a custom serialize method on an Engine route is not supported.'); + } - var AbstractRenderingTestCase = (function (_AbstractTestCase) { - babelHelpers.inherits(AbstractRenderingTestCase, _AbstractTestCase); + return handler; + }; + }, - function AbstractRenderingTestCase() { - babelHelpers.classCallCheck(this, AbstractRenderingTestCase); + _getSerializerFunction: function () { + var _this7 = this; - _AbstractTestCase.call(this); - var owner = this.owner = _internalTestHelpersBuildOwner.default({ - ownerOptions: this.getOwnerOptions(), - bootOptions: this.getBootOptions(), - resolver: this.getResolver() - }); + return function (name) { + var engineInfo = _this7._engineInfoByRoute[name]; - this.renderer = this.owner.lookup('renderer:-dom'); - this.element = _emberViews.jQuery('#qunit-fixture')[0]; - this.component = null; + // If this is not an Engine route, we fall back to the handler for serialization + if (!engineInfo) { + return; + } - owner.register('event_dispatcher:main', _emberViews.EventDispatcher); - owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); - owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); - } + return engineInfo.serializeMethod || _emberRoutingSystemRoute.defaultSerialize; + }; + }, - AbstractRenderingTestCase.prototype.compile = function compile() { - return _emberTemplateCompiler.compile.apply(undefined, arguments); - }; + _setupRouter: function (router, location) { + var lastURL = undefined; + var emberRouter = this; - AbstractRenderingTestCase.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { - return {}; - }; + router.getHandler = this._getHandlerFunction(); + router.getSerializer = this._getSerializerFunction(); - AbstractRenderingTestCase.prototype.getOwnerOptions = function getOwnerOptions() {}; + var doUpdateURL = function () { + location.setURL(lastURL); + _emberMetal.set(emberRouter, 'currentURL', lastURL); + }; - AbstractRenderingTestCase.prototype.getBootOptions = function getBootOptions() {}; + router.updateURL = function (path) { + lastURL = path; + _emberMetal.run.once(doUpdateURL); + }; - AbstractRenderingTestCase.prototype.getResolver = function getResolver() {}; + if (location.replaceURL) { + (function () { + var doReplaceURL = function () { + location.replaceURL(lastURL); + _emberMetal.set(emberRouter, 'currentURL', lastURL); + }; - AbstractRenderingTestCase.prototype.teardown = function teardown() { - if (this.component) { - _internalTestHelpersRun.runDestroy(this.component); - } - if (this.owner) { - _internalTestHelpersRun.runDestroy(this.owner); + router.replaceURL = function (path) { + lastURL = path; + _emberMetal.run.once(doReplaceURL); + }; + })(); } - }; - AbstractRenderingTestCase.prototype.render = function render(templateStr) { - var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var owner = this.owner; + router.didTransition = function (infos) { + emberRouter.didTransition(infos); + }; - owner.register('template:-top-level', this.compile(templateStr, { - moduleName: '-top-level' - })); + router.willTransition = function (oldInfos, newInfos, transition) { + emberRouter.willTransition(oldInfos, newInfos, transition); + }; + }, - var attrs = _emberUtils.assign({}, context, { - tagName: '', - layoutName: '-top-level' + /** + Serializes the given query params according to their QP meta information. + @private + @method _serializeQueryParams + @param {Arrray} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _serializeQueryParams: function (handlerInfos, queryParams) { + var _this8 = this; + + forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { + if (qp) { + delete queryParams[key]; + queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); + } else if (value === undefined) { + return; // We don't serialize undefined values + } else { + queryParams[key] = _this8._serializeQueryParam(value, _emberRuntime.typeOf(value)); + } }); + }, - owner.register('component:-top-level', _emberGlimmer.Component.extend(attrs)); + /** + Serializes the value of a query parameter based on a type + @private + @method _serializeQueryParam + @param {Object} value + @param {String} type + */ + _serializeQueryParam: function (value, type) { + if (type === 'array') { + return JSON.stringify(value); + } - this.component = owner.lookup('component:-top-level'); + return '' + value; + }, - _internalTestHelpersRun.runAppend(this.component); - }; + /** + Deserializes the given query params according to their QP meta information. + @private + @method _deserializeQueryParams + @param {Array} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _deserializeQueryParams: function (handlerInfos, queryParams) { + forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { + // If we don't have QP meta info for a given key, then we do nothing + // because all values will be treated as strings + if (qp) { + delete queryParams[key]; + queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); + } + }); + }, - AbstractRenderingTestCase.prototype.rerender = function rerender() { - this.component.rerender(); - }; + /** + Deserializes the value of a query parameter based on a default type + @private + @method _deserializeQueryParam + @param {Object} value + @param {String} defaultType + */ + _deserializeQueryParam: function (value, defaultType) { + if (defaultType === 'boolean') { + return value === 'true' ? true : false; + } else if (defaultType === 'number') { + return Number(value).valueOf(); + } else if (defaultType === 'array') { + return _emberRuntime.A(JSON.parse(value)); + } - AbstractRenderingTestCase.prototype.registerHelper = function registerHelper(name, funcOrClassBody) { - var type = typeof funcOrClassBody; + return value; + }, - if (type === 'function') { - this.owner.register('helper:' + name, _emberGlimmer.helper(funcOrClassBody)); - } else if (type === 'object' && type !== null) { - this.owner.register('helper:' + name, _emberGlimmer.Helper.extend(funcOrClassBody)); - } else { - throw new Error('Cannot register ' + funcOrClassBody + ' as a helper'); + /** + Removes (prunes) any query params with default values from the given QP + object. Default values are determined from the QP meta information per key. + @private + @method _pruneDefaultQueryParamValues + @param {Array} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _pruneDefaultQueryParamValues: function (handlerInfos, queryParams) { + var qps = this._queryParamsFor(handlerInfos); + for (var key in queryParams) { + var qp = qps.map[key]; + if (qp && qp.serializedDefaultValue === queryParams[key]) { + delete queryParams[key]; + } } - }; + }, - AbstractRenderingTestCase.prototype.registerPartial = function registerPartial(name, template) { - var owner = this.env.owner || this.owner; - if (typeof template === 'string') { - var moduleName = 'template:' + name; - owner.register(moduleName, this.compile(template, { moduleName: moduleName })); - } - }; + _doTransition: function (_targetRouteName, models, _queryParams) { + var _router4; - AbstractRenderingTestCase.prototype.registerComponent = function registerComponent(name, _ref) { - var _ref$ComponentClass = _ref.ComponentClass; - var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; - var _ref$template = _ref.template; - var template = _ref$template === undefined ? null : _ref$template; - var owner = this.owner; + var targetRouteName = _targetRouteName || _emberRoutingUtils.getActiveTargetName(this.router); + _emberMetal.assert('The route ' + targetRouteName + ' was not found', targetRouteName && this.router.hasRoute(targetRouteName)); - if (ComponentClass) { - owner.register('component:' + name, ComponentClass); - } + var queryParams = {}; - if (typeof template === 'string') { - owner.register('template:components/' + name, this.compile(template, { - moduleName: 'components/' + name - })); - } - }; + this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); - AbstractRenderingTestCase.prototype.registerTemplate = function registerTemplate(name, template) { - var owner = this.owner; + _emberUtils.assign(queryParams, _queryParams); + this._prepareQueryParams(targetRouteName, models, queryParams); - if (typeof template === 'string') { - owner.register('template:' + name, this.compile(template, { - moduleName: name - })); - } else { - throw new Error('Registered template "' + name + '" must be a string'); - } - }; + var transitionArgs = _emberRoutingUtils.routeArgs(targetRouteName, models, queryParams); + var transition = (_router4 = this.router).transitionTo.apply(_router4, transitionArgs); - AbstractRenderingTestCase.prototype.registerService = function registerService(name, klass) { - this.owner.register('service:' + name, klass); - }; + didBeginTransition(transition, this); - AbstractRenderingTestCase.prototype.assertTextNode = function assertTextNode(node, text) { - if (!(node instanceof TextNode)) { - throw new Error('Expecting a text node, but got ' + node); + return transition; + }, + + _processActiveTransitionQueryParams: function (targetRouteName, models, queryParams, _queryParams) { + // merge in any queryParams from the active transition which could include + // queryParams from the url on initial load. + if (!this.router.activeTransition) { + return; } - this.assert.strictEqual(node.textContent, text, 'node.textContent'); - }; + var unchangedQPs = {}; + var qpUpdates = this._qpUpdates || {}; + for (var key in this.router.activeTransition.queryParams) { + if (!qpUpdates[key]) { + unchangedQPs[key] = this.router.activeTransition.queryParams[key]; + } + } - babelHelpers.createClass(AbstractRenderingTestCase, [{ - key: 'context', - get: function () { - return this.component; + // We need to fully scope queryParams so that we can create one object + // that represents both pased in queryParams and ones that aren't changed + // from the active transition. + this._fullyScopeQueryParams(targetRouteName, models, _queryParams); + this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs); + _emberUtils.assign(queryParams, unchangedQPs); + }, + + /** + Prepares the query params for a URL or Transition. Restores any undefined QP + keys/values, serializes all values, and then prunes any default values. + @private + @method _prepareQueryParams + @param {String} targetRouteName + @param {Array} models + @param {Object} queryParams + @return {Void} + */ + _prepareQueryParams: function (targetRouteName, models, queryParams) { + var state = calculatePostTransitionState(this, targetRouteName, models); + this._hydrateUnsuppliedQueryParams(state, queryParams); + this._serializeQueryParams(state.handlerInfos, queryParams); + this._pruneDefaultQueryParamValues(state.handlerInfos, queryParams); + }, + + /** + Returns the meta information for the query params of a given route. This + will be overriden to allow support for lazy routes. + @private + @method _getQPMeta + @param {HandlerInfo} handlerInfo + @return {Object} + */ + _getQPMeta: function (handlerInfo) { + var route = handlerInfo.handler; + return route && _emberMetal.get(route, '_qp'); + }, + + /** + Returns a merged query params meta object for a given set of handlerInfos. + Useful for knowing what query params are available for a given route hierarchy. + @private + @method _queryParamsFor + @param {Array} handlerInfos + @return {Object} + */ + _queryParamsFor: function (handlerInfos) { + var leafRouteName = handlerInfos[handlerInfos.length - 1].name; + if (this._qpCache[leafRouteName]) { + return this._qpCache[leafRouteName]; } - }]); - return AbstractRenderingTestCase; - })(_internalTestHelpersTestCasesAbstract.default); - exports.default = AbstractRenderingTestCase; -}); -enifed('internal-test-helpers/test-cases/abstract', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/matchers'], function (exports, _emberUtils, _emberMetal, _emberViews, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersMatchers) { - 'use strict'; + var shouldCache = true; + var qpsByUrlKey = {}; + var map = {}; + var qps = []; - var TextNode = window.Text; - var HTMLElement = window.HTMLElement; - var Comment = window.Comment; + for (var i = 0; i < handlerInfos.length; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - function isMarker(node) { - if (node instanceof Comment && node.textContent === '') { - return true; - } + if (!qpMeta) { + shouldCache = false; + continue; + } - if (node instanceof TextNode && node.textContent === '') { - return true; - } + // Loop over each QP to make sure we don't have any collisions by urlKey + for (var _i = 0; _i < qpMeta.qps.length; _i++) { + var qp = qpMeta.qps[_i]; + var urlKey = qp.urlKey; + var qpOther = qpsByUrlKey[urlKey]; - return false; - } + if (qpOther && qpOther.controllerName !== qp.controllerName) { + var otherQP = qpsByUrlKey[urlKey]; + _emberMetal.assert('You\'re not allowed to have more than one controller property map to the same query param key, but both `' + otherQP.scopedPropertyName + '` and `' + qp.scopedPropertyName + '` map to `' + urlKey + '`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `' + otherQP.prop + ': { as: \'other-' + otherQP.prop + '\' }`', false); + } - var AbstractTestCase = (function () { - function AbstractTestCase() { - babelHelpers.classCallCheck(this, AbstractTestCase); + qpsByUrlKey[urlKey] = qp; + qps.push(qp); + } - this.element = null; - this.snapshot = null; - this.assert = QUnit.config.current.assert; - } + _emberUtils.assign(map, qpMeta.map); + } - AbstractTestCase.prototype.teardown = function teardown() {}; + var finalQPMeta = { + qps: qps, + map: map + }; - AbstractTestCase.prototype.runTask = function runTask(callback) { - _emberMetal.run(callback); - }; + if (shouldCache) { + this._qpCache[leafRouteName] = finalQPMeta; + } - AbstractTestCase.prototype.runTaskNext = function runTaskNext(callback) { - _emberMetal.run.next(callback); - }; + return finalQPMeta; + }, - // The following methods require `this.element` to work + /** + Maps all query param keys to their fully scoped property name of the form + `controllerName:propName`. + @private + @method _fullyScopeQueryParams + @param {String} leafRouteName + @param {Array} contexts + @param {Object} queryParams + @return {Void} + */ + _fullyScopeQueryParams: function (leafRouteName, contexts, queryParams) { + var state = calculatePostTransitionState(this, leafRouteName, contexts); + var handlerInfos = state.handlerInfos; - AbstractTestCase.prototype.nthChild = function nthChild(n) { - var i = 0; - var node = this.element.firstChild; + for (var i = 0, len = handlerInfos.length; i < len; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - while (node) { - if (!isMarker(node)) { - i++; + if (!qpMeta) { + continue; } - if (i > n) { - break; - } else { - node = node.nextSibling; + for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { + var qp = qpMeta.qps[j]; + + var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; + + if (presentProp) { + if (presentProp !== qp.scopedPropertyName) { + queryParams[qp.scopedPropertyName] = queryParams[presentProp]; + delete queryParams[presentProp]; + } + } } } + }, - return node; - }; + /** + Hydrates (adds/restores) any query params that have pre-existing values into + the given queryParams hash. This is what allows query params to be "sticky" + and restore their last known values for their scope. + @private + @method _hydrateUnsuppliedQueryParams + @param {TransitionState} state + @param {Object} queryParams + @return {Void} + */ + _hydrateUnsuppliedQueryParams: function (state, queryParams) { + var handlerInfos = state.handlerInfos; + var appCache = this._bucketCache; - AbstractTestCase.prototype.$ = function $(sel) { - return sel ? _emberViews.jQuery(sel, this.element) : _emberViews.jQuery(this.element); - }; + for (var i = 0; i < handlerInfos.length; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - AbstractTestCase.prototype.textValue = function textValue() { - return this.$().text(); - }; + if (!qpMeta) { + continue; + } - AbstractTestCase.prototype.takeSnapshot = function takeSnapshot() { - var snapshot = this.snapshot = []; + for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { + var qp = qpMeta.qps[j]; - var node = this.element.firstChild; + var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; - while (node) { - if (!isMarker(node)) { - snapshot.push(node); + if (presentProp) { + if (presentProp !== qp.scopedPropertyName) { + queryParams[qp.scopedPropertyName] = queryParams[presentProp]; + delete queryParams[presentProp]; + } + } else { + var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.route.fullRouteName, qp.parts, state.params); + queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); + } } - - node = node.nextSibling; } + }, - return snapshot; - }; + _scheduleLoadingEvent: function (transition, originRoute) { + this._cancelSlowTransitionTimer(); + this._slowTransitionTimer = _emberMetal.run.scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute); + }, - AbstractTestCase.prototype.assertText = function assertText(text) { - this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content should be: `' + text + '`'); - }; + currentState: null, + targetState: null, - AbstractTestCase.prototype.assertInnerHTML = function assertInnerHTML(html) { - _internalTestHelpersEqualInnerHtml.default(this.element, html); - }; + _handleSlowTransition: function (transition, originRoute) { + if (!this.router.activeTransition) { + // Don't fire an event if we've since moved on from + // the transition that put us in a loading state. + return; + } - AbstractTestCase.prototype.assertHTML = function assertHTML(html) { - _internalTestHelpersEqualTokens.default(this.element, html, '#qunit-fixture content should be: `' + html + '`'); - }; + this.set('targetState', _emberRoutingSystemRouter_state.default.create({ + emberRouter: this, + routerJs: this.router, + routerJsState: this.router.activeTransition.state + })); - AbstractTestCase.prototype.assertElement = function assertElement(node, _ref) { - var _ref$ElementType = _ref.ElementType; - var ElementType = _ref$ElementType === undefined ? HTMLElement : _ref$ElementType; - var tagName = _ref.tagName; - var _ref$attrs = _ref.attrs; - var attrs = _ref$attrs === undefined ? null : _ref$attrs; - var _ref$content = _ref.content; - var content = _ref$content === undefined ? null : _ref$content; + transition.trigger(true, 'loading', transition, originRoute); + }, - if (!(node instanceof ElementType)) { - throw new Error('Expecting a ' + ElementType.name + ', but got ' + node); + _cancelSlowTransitionTimer: function () { + if (this._slowTransitionTimer) { + _emberMetal.run.cancel(this._slowTransitionTimer); } + this._slowTransitionTimer = null; + }, + + // These three helper functions are used to ensure errors aren't + // re-raised if they're handled in a route's error action. + _markErrorAsHandled: function (errorGuid) { + this._handledErrors[errorGuid] = true; + }, - _internalTestHelpersMatchers.equalsElement(node, tagName, attrs, content); - }; + _isErrorHandled: function (errorGuid) { + return this._handledErrors[errorGuid]; + }, - AbstractTestCase.prototype.assertComponentElement = function assertComponentElement(node, _ref2) { - var _ref2$ElementType = _ref2.ElementType; - var ElementType = _ref2$ElementType === undefined ? HTMLElement : _ref2$ElementType; - var _ref2$tagName = _ref2.tagName; - var tagName = _ref2$tagName === undefined ? 'div' : _ref2$tagName; - var _ref2$attrs = _ref2.attrs; - var attrs = _ref2$attrs === undefined ? null : _ref2$attrs; - var _ref2$content = _ref2.content; - var content = _ref2$content === undefined ? null : _ref2$content; + _clearHandledError: function (errorGuid) { + delete this._handledErrors[errorGuid]; + }, - attrs = _emberUtils.assign({}, { id: _internalTestHelpersMatchers.regex(/^ember\d*$/), class: _internalTestHelpersMatchers.classes('ember-view') }, attrs || {}); - this.assertElement(node, { ElementType: ElementType, tagName: tagName, attrs: attrs, content: content }); - }; + _getEngineInstance: function (_ref) { + var name = _ref.name; + var instanceId = _ref.instanceId; + var mountPoint = _ref.mountPoint; - AbstractTestCase.prototype.assertSameNode = function assertSameNode(actual, expected) { - this.assert.strictEqual(actual, expected, 'DOM node stability'); - }; + var engineInstances = this._engineInstances; - AbstractTestCase.prototype.assertInvariants = function assertInvariants(oldSnapshot, newSnapshot) { - oldSnapshot = oldSnapshot || this.snapshot; - newSnapshot = newSnapshot || this.takeSnapshot(); + if (!engineInstances[name]) { + engineInstances[name] = new _emberUtils.EmptyObject(); + } - this.assert.strictEqual(newSnapshot.length, oldSnapshot.length, 'Same number of nodes'); + var engineInstance = engineInstances[name][instanceId]; - for (var i = 0; i < oldSnapshot.length; i++) { - this.assertSameNode(newSnapshot[i], oldSnapshot[i]); - } - }; + if (!engineInstance) { + var owner = _emberUtils.getOwner(this); - AbstractTestCase.prototype.assertPartialInvariants = function assertPartialInvariants(start, end) { - this.assertInvariants(this.snapshot, this.takeSnapshot().slice(start, end)); - }; + _emberMetal.assert('You attempted to mount the engine \'' + name + '\' in your router map, but the engine can not be found.', owner.hasRegistration('engine:' + name)); - AbstractTestCase.prototype.assertStableRerender = function assertStableRerender() { - var _this = this; + engineInstance = owner.buildChildEngineInstance(name, { + routable: true, + mountPoint: mountPoint + }); - this.takeSnapshot(); - this.runTask(function () { - return _this.rerender(); - }); - this.assertInvariants(); - }; + engineInstance.boot(); - babelHelpers.createClass(AbstractTestCase, [{ - key: 'firstChild', - get: function () { - return this.nthChild(0); + engineInstances[name][instanceId] = engineInstance; } - }, { - key: 'nodesCount', - get: function () { - var count = 0; - var node = this.element.firstChild; - while (node) { - if (!isMarker(node)) { - count++; - } + return engineInstance; + } + }); - node = node.nextSibling; - } + /* + Helper function for iterating over routes in a set of handlerInfos that are + at or above the given origin route. Example: if `originRoute` === 'foo.bar' + and the handlerInfos given were for 'foo.bar.baz', then the given callback + will be invoked with the routes for 'foo.bar', 'foo', and 'application' + individually. + + If the callback returns anything other than `true`, then iteration will stop. + + @private + @param {Route} originRoute + @param {Array} handlerInfos + @param {Function} callback + @return {Void} + */ + function forEachRouteAbove(originRoute, handlerInfos, callback) { + var originRouteFound = false; - return count; + for (var i = handlerInfos.length - 1; i >= 0; --i) { + var handlerInfo = handlerInfos[i]; + var route = handlerInfo.handler; + + if (originRoute === route) { + originRouteFound = true; } - }]); - return AbstractTestCase; - })(); - exports.default = AbstractTestCase; -}); -enifed('internal-test-helpers/test-cases/application', ['exports', 'internal-test-helpers/test-cases/abstract-application'], function (exports, _internalTestHelpersTestCasesAbstractApplication) { - 'use strict'; + if (!originRouteFound) { + continue; + } - var ApplicationTestCase = (function (_AbstractApplicationTestCase) { - babelHelpers.inherits(ApplicationTestCase, _AbstractApplicationTestCase); + if (callback(route) !== true) { + return; + } + } + } - function ApplicationTestCase() { - babelHelpers.classCallCheck(this, ApplicationTestCase); + // These get invoked when an action bubbles above ApplicationRoute + // and are not meant to be overridable. + var defaultActionHandlers = { - _AbstractApplicationTestCase.apply(this, arguments); - } + willResolveModel: function (transition, originRoute) { + originRoute.router._scheduleLoadingEvent(transition, originRoute); + }, - return ApplicationTestCase; - })(_internalTestHelpersTestCasesAbstractApplication.default); + // Attempt to find an appropriate error route or substate to enter. + error: function (error, transition, originRoute) { + var handlerInfos = transition.state.handlerInfos; + var router = originRoute.router; - exports.default = ApplicationTestCase; -}); -enifed('internal-test-helpers/test-cases/query-param', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers/test-cases/application'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpersTestCasesApplication) { - 'use strict'; + forEachRouteAbove(originRoute, handlerInfos, function (route) { + // Check for the existence of an 'error' route. + // We don't check for an 'error' route on the originRoute, since that would + // technically be below where we're at in the route hierarchy. + if (originRoute !== route) { + var errorRouteName = findRouteStateName(route, 'error'); + if (errorRouteName) { + router.intermediateTransitionTo(errorRouteName, error); + return false; + } + } - var QueryParamTestCase = (function (_ApplicationTestCase) { - babelHelpers.inherits(QueryParamTestCase, _ApplicationTestCase); + // Check for an 'error' substate route + var errorSubstateName = findRouteSubstateName(route, 'error'); + if (errorSubstateName) { + router.intermediateTransitionTo(errorSubstateName, error); + return false; + } - function QueryParamTestCase() { - babelHelpers.classCallCheck(this, QueryParamTestCase); + return true; + }); - _ApplicationTestCase.call(this); + logError(error, 'Error while processing route: ' + transition.targetName); + }, - var testCase = this; - testCase.expectedPushURL = null; - testCase.expectedReplaceURL = null; - this.application.register('location:test', _emberRouting.NoneLocation.extend({ - setURL: function (path) { - if (testCase.expectedReplaceURL) { - testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); - } + // Attempt to find an appropriate loading route or substate to enter. + loading: function (transition, originRoute) { + var handlerInfos = transition.state.handlerInfos; + var router = originRoute.router; - if (testCase.expectedPushURL) { - testCase.assert.equal(path, testCase.expectedPushURL, 'an expected pushState occurred'); - testCase.expectedPushURL = null; + forEachRouteAbove(originRoute, handlerInfos, function (route) { + // Check for the existence of a 'loading' route. + // We don't check for a 'loading' route on the originRoute, since that would + // technically be below where we're at in the route hierarchy. + if (originRoute !== route) { + var loadingRouteName = findRouteStateName(route, 'loading'); + if (loadingRouteName) { + router.intermediateTransitionTo(loadingRouteName); + return false; } + } - this.set('path', path); - }, + // Check for loading substate + var loadingSubstateName = findRouteSubstateName(route, 'loading'); + if (loadingSubstateName) { + router.intermediateTransitionTo(loadingSubstateName); + return false; + } - replaceURL: function (path) { - if (testCase.expectedPushURL) { - testCase.assert.ok(false, 'replaceState occurred but a pushState was expected'); - } + // Don't bubble above pivot route. + return transition.pivotHandler !== route; + }); + } + }; - if (testCase.expectedReplaceURL) { - testCase.assert.equal(path, testCase.expectedReplaceURL, 'an expected replaceState occurred'); - testCase.expectedReplaceURL = null; - } + function logError(_error, initialMessage) { + var errorArgs = []; + var error = undefined; + if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { + error = _error.errorThrown; + } else { + error = _error; + } - this.set('path', path); - } - })); + if (initialMessage) { + errorArgs.push(initialMessage); } - QueryParamTestCase.prototype.visitAndAssert = function visitAndAssert(path) { - var _this = this; + if (error) { + if (error.message) { + errorArgs.push(error.message); + } + if (error.stack) { + errorArgs.push(error.stack); + } - return this.visit.apply(this, arguments).then(function () { - _this.assertCurrentPath(path); - }); - }; + if (typeof error === 'string') { + errorArgs.push(error); + } + } - QueryParamTestCase.prototype.getController = function getController(name) { - return this.applicationInstance.lookup('controller:' + name); - }; + _emberConsole.default.error.apply(this, errorArgs); + } - QueryParamTestCase.prototype.getRoute = function getRoute(name) { - return this.applicationInstance.lookup('route:' + name); - }; + /** + Finds the name of the substate route if it exists for the given route. A + substate route is of the form `route_state`, such as `foo_loading`. + + @private + @param {Route} route + @param {String} state + @return {String} + */ + function findRouteSubstateName(route, state) { + var router = route.router; + var owner = _emberUtils.getOwner(route); - QueryParamTestCase.prototype.setAndFlush = function setAndFlush(obj, prop, value) { - return _emberMetal.run(obj, 'set', prop, value); - }; + var routeName = route.routeName; + var substateName = routeName + '_' + state; - QueryParamTestCase.prototype.assertCurrentPath = function assertCurrentPath(path) { - var message = arguments.length <= 1 || arguments[1] === undefined ? 'current path equals \'' + path + '\'' : arguments[1]; - return (function () { - this.assert.equal(this.appRouter.get('location.path'), path, message); - }).apply(this, arguments); - }; + var routeNameFull = route.fullRouteName; + var substateNameFull = routeNameFull + '_' + state; - /** - Sets up a Controller for a given route with a single query param and default - value. Can optionally extend the controller with an object. - @public - @method setSingleQPController - */ + return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; + } - QueryParamTestCase.prototype.setSingleQPController = function setSingleQPController(routeName) { - var param = arguments.length <= 1 || arguments[1] === undefined ? 'foo' : arguments[1]; - var defaultValue = arguments.length <= 2 || arguments[2] === undefined ? 'bar' : arguments[2]; + /** + Finds the name of the state route if it exists for the given route. A state + route is of the form `route.state`, such as `foo.loading`. Properly Handles + `application` named routes. + + @private + @param {Route} route + @param {String} state + @return {String} + */ + function findRouteStateName(route, state) { + var router = route.router; + var owner = _emberUtils.getOwner(route); - var _Controller$extend; + var routeName = route.routeName; + var stateName = routeName === 'application' ? state : routeName + '.' + state; - var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; + var routeNameFull = route.fullRouteName; + var stateNameFull = routeNameFull === 'application' ? state : routeNameFull + '.' + state; - this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend = { - queryParams: [param] - }, _Controller$extend[param] = defaultValue, _Controller$extend), options)); - }; + return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; + } - /** - Sets up a Controller for a given route with a custom property/url key mapping. - @public - @method setMappedQPController - */ + /** + Determines whether or not a route has been defined by checking that the route + is in the Router's map and the owner has a registration for that route. + + @private + @param {Owner} owner + @param {Ember.Router} router + @param {String} localName + @param {String} fullName + @return {Boolean} + */ + function routeHasBeenDefined(owner, router, localName, fullName) { + var routerHasRoute = router.hasRoute(fullName); + var ownerHasRoute = owner.hasRegistration('template:' + localName) || owner.hasRegistration('route:' + localName); + return routerHasRoute && ownerHasRoute; + } - QueryParamTestCase.prototype.setMappedQPController = function setMappedQPController(routeName) { - var prop = arguments.length <= 1 || arguments[1] === undefined ? 'page' : arguments[1]; - var urlKey = arguments.length <= 2 || arguments[2] === undefined ? 'parentPage' : arguments[2]; - var defaultValue = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3]; + function triggerEvent(handlerInfos, ignoreFailure, args) { + var name = args.shift(); - var _queryParams, _Controller$extend2; + if (!handlerInfos) { + if (ignoreFailure) { + return; + } + throw new _emberMetal.Error('Can\'t trigger action \'' + name + '\' because your app hasn\'t finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.'); + } - var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; + var eventWasHandled = false; + var handlerInfo = undefined, + handler = undefined; - this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend2 = { - queryParams: (_queryParams = {}, _queryParams[prop] = urlKey, _queryParams) - }, _Controller$extend2[prop] = defaultValue, _Controller$extend2), options)); - }; + for (var i = handlerInfos.length - 1; i >= 0; i--) { + handlerInfo = handlerInfos[i]; + handler = handlerInfo.handler; - babelHelpers.createClass(QueryParamTestCase, [{ - key: 'routerOptions', - get: function () { - return { - location: 'test' - }; + if (handler && handler.actions && handler.actions[name]) { + if (handler.actions[name].apply(handler, args) === true) { + eventWasHandled = true; + } else { + // Should only hit here if a non-bubbling error action is triggered on a route. + if (name === 'error') { + var errorId = _emberUtils.guidFor(args[0]); + handler.router._markErrorAsHandled(errorId); + } + return; + } } - }]); - return QueryParamTestCase; - })(_internalTestHelpersTestCasesApplication.default); + } - exports.default = QueryParamTestCase; -}); -enifed('internal-test-helpers/test-cases/rendering', ['exports', 'ember-views', 'internal-test-helpers/test-cases/abstract-rendering'], function (exports, _emberViews, _internalTestHelpersTestCasesAbstractRendering) { - 'use strict'; + if (defaultActionHandlers[name]) { + defaultActionHandlers[name].apply(null, args); + return; + } - var RenderingTestCase = (function (_AbstractRenderingTestCase) { - babelHelpers.inherits(RenderingTestCase, _AbstractRenderingTestCase); + if (!eventWasHandled && !ignoreFailure) { + throw new _emberMetal.Error('Nothing handled the action \'' + name + '\'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.'); + } + } - function RenderingTestCase() { - babelHelpers.classCallCheck(this, RenderingTestCase); + function calculatePostTransitionState(emberRouter, leafRouteName, contexts) { + var routerjs = emberRouter.router; + var state = routerjs.applyIntent(leafRouteName, contexts); + var handlerInfos = state.handlerInfos; + var params = state.params; - _AbstractRenderingTestCase.call(this); - var owner = this.owner; + for (var i = 0; i < handlerInfos.length; ++i) { + var handlerInfo = handlerInfos[i]; - this.env = owner.lookup('service:-glimmer-environment'); - owner.register('component-lookup:main', _emberViews.ComponentLookup); - owner.registerOptionsForType('helper', { instantiate: false }); - owner.registerOptionsForType('component', { singleton: false }); + // If the handlerInfo is not resolved, we serialize the context into params + if (!handlerInfo.isResolved) { + params[handlerInfo.name] = handlerInfo.serialize(handlerInfo.context); + } else { + params[handlerInfo.name] = handlerInfo.params; + } } + return state; + } - return RenderingTestCase; - })(_internalTestHelpersTestCasesAbstractRendering.default); + function updatePaths(router) { + var infos = router.router.currentHandlerInfos; + if (infos.length === 0) { + return; + } - exports.default = RenderingTestCase; -}); -enifed('internal-test-helpers/test-groups', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { - 'use strict'; + var path = EmberRouter._routePath(infos); + var currentRouteName = infos[infos.length - 1].name; + var currentURL = router.get('location').getURL(); - exports.testBoth = testBoth; - exports.testWithDefault = testWithDefault; + _emberMetal.set(router, 'currentPath', path); + _emberMetal.set(router, 'currentRouteName', currentRouteName); + _emberMetal.set(router, 'currentURL', currentURL); - // used by unit tests to test both accessor mode and non-accessor mode + var appController = _emberUtils.getOwner(router).lookup('controller:application'); - function testBoth(testname, callback) { - function emberget(x, y) { - return _emberMetal.get(x, y); - } - function emberset(x, y, z) { - return _emberMetal.set(x, y, z); + if (!appController) { + // appController might not exist when top-level loading/error + // substates have been entered since ApplicationRoute hasn't + // actually been entered at that point. + return; } - function aget(x, y) { - return x[y]; + + if (!('currentPath' in appController)) { + _emberMetal.defineProperty(appController, 'currentPath'); } - function aset(x, y, z) { - return x[y] = z; + + _emberMetal.set(appController, 'currentPath', path); + + if (!('currentRouteName' in appController)) { + _emberMetal.defineProperty(appController, 'currentRouteName'); } - QUnit.test(testname + ' using getFromEmberMetal()/Ember.set()', function () { - callback(emberget, emberset); - }); + _emberMetal.set(appController, 'currentRouteName', currentRouteName); + } + + EmberRouter.reopenClass({ + router: null, + + /** + The `Router.map` function allows you to define mappings from URLs to routes + in your application. These mappings are defined within the + supplied callback function using `this.route`. + The first parameter is the name of the route which is used by default as the + path name as well. + The second parameter is the optional options hash. Available options are: + * `path`: allows you to provide your own path as well as mark dynamic + segments. + * `resetNamespace`: false by default; when nesting routes, ember will + combine the route names to form the fully-qualified route name, which is + used with `{{link-to}}` or manually transitioning to routes. Setting + `resetNamespace: true` will cause the route not to inherit from its + parent route's names. This is handy for preventing extremely long route names. + Keep in mind that the actual URL path behavior is still retained. + The third parameter is a function, which can be used to nest routes. + Nested routes, by default, will have the parent route tree's route name and + path prepended to it's own. + ```javascript + App.Router.map(function(){ + this.route('post', { path: '/post/:post_id' }, function() { + this.route('edit'); + this.route('comments', { resetNamespace: true }, function() { + this.route('new'); + }); + }); + }); + ``` + For more detailed documentation and examples please see + [the guides](http://emberjs.com/guides/routing/defining-your-routes/). + @method map + @param callback + @public + */ + map: function (callback) { + if (!this.dslCallbacks) { + this.dslCallbacks = []; + this.reopenClass({ dslCallbacks: this.dslCallbacks }); + } + + this.dslCallbacks.push(callback); + + return this; + }, + + _routePath: function (handlerInfos) { + var path = []; + + // We have to handle coalescing resource names that + // are prefixed with their parent's names, e.g. + // ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz' + + function intersectionMatches(a1, a2) { + for (var i = 0; i < a1.length; ++i) { + if (a1[i] !== a2[i]) { + return false; + } + } + return true; + } - QUnit.test(testname + ' using accessors', function () { - if (_emberEnvironment.ENV.USES_ACCESSORS) { - callback(aget, aset); - } else { - ok('SKIPPING ACCESSORS'); + var name = undefined, + nameParts = undefined, + oldNameParts = undefined; + for (var i = 1; i < handlerInfos.length; i++) { + name = handlerInfos[i].name; + nameParts = name.split('.'); + oldNameParts = slice.call(path); + + while (oldNameParts.length) { + if (intersectionMatches(oldNameParts, nameParts)) { + break; + } + oldNameParts.shift(); + } + + path.push.apply(path, nameParts.slice(oldNameParts.length)); } - }); - } - function testWithDefault(testname, callback) { - function emberget(x, y) { - return _emberMetal.get(x, y); - } - function embergetwithdefault(x, y, z) { - return _emberMetal.getWithDefault(x, y, z); - } - function getwithdefault(x, y, z) { - return x.getWithDefault(y, z); - } - function emberset(x, y, z) { - return _emberMetal.set(x, y, z); - } - function aget(x, y) { - return x[y]; - } - function aset(x, y, z) { - return x[y] = z; + return path.join('.'); } + }); - QUnit.test(testname + ' using obj.get()', function () { - callback(emberget, emberset); - }); - - QUnit.test(testname + ' using obj.getWithDefault()', function () { - callback(getwithdefault, emberset); + function didBeginTransition(transition, router) { + var routerState = _emberRoutingSystemRouter_state.default.create({ + emberRouter: router, + routerJs: router.router, + routerJsState: transition.state }); - QUnit.test(testname + ' using getFromEmberMetal()', function () { - callback(emberget, emberset); - }); + if (!router.currentState) { + router.set('currentState', routerState); + } + router.set('targetState', routerState); - QUnit.test(testname + ' using Ember.getWithDefault()', function () { - callback(embergetwithdefault, emberset); - }); + transition.promise = transition.catch(function (error) { + var errorId = _emberUtils.guidFor(error); - QUnit.test(testname + ' using accessors', function () { - if (_emberEnvironment.ENV.USES_ACCESSORS) { - callback(aget, aset); + if (router._isErrorHandled(errorId)) { + router._clearHandledError(errorId); } else { - ok('SKIPPING ACCESSORS'); + throw error; } }); } -}); -enifed('glimmer-node/index', ['exports', 'glimmer-node/lib/node-dom-helper'], function (exports, _glimmerNodeLibNodeDomHelper) { - 'use strict'; - exports.NodeDOMTreeConstruction = _glimmerNodeLibNodeDomHelper.default; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItbm9kZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFBb0IsdUJBQXVCLGdDQUFsQyxPQUFPIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBOb2RlRE9NVHJlZUNvbnN0cnVjdGlvbiB9IGZyb20gJy4vbGliL25vZGUtZG9tLWhlbHBlcic7XG4iXX0= -enifed('glimmer-node/lib/node-dom-helper', ['exports', 'glimmer-runtime'], function (exports, _glimmerRuntime) { - 'use strict'; - - var NodeDOMTreeConstruction = (function (_DOMTreeConstruction) { - babelHelpers.inherits(NodeDOMTreeConstruction, _DOMTreeConstruction); - - function NodeDOMTreeConstruction(doc) { - _DOMTreeConstruction.call(this, doc); - } + function resemblesURL(str) { + return typeof str === 'string' && (str === '' || str[0] === '/'); + } - // override to prevent usage of `this.document` until after the constructor + function forEachQueryParam(router, handlerInfos, queryParams, callback) { + var qpCache = router._queryParamsFor(handlerInfos); - NodeDOMTreeConstruction.prototype.setupUselessElement = function setupUselessElement() {}; + for (var key in queryParams) { + if (!queryParams.hasOwnProperty(key)) { + continue; + } + var value = queryParams[key]; + var qp = qpCache.map[key]; - NodeDOMTreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - var prev = reference ? reference.previousSibling : parent.lastChild; - var raw = this.document.createRawHTMLSection(html); - parent.insertBefore(raw, reference); - var first = prev ? prev.nextSibling : parent.firstChild; - var last = reference ? reference.previousSibling : parent.lastChild; - return new _glimmerRuntime.ConcreteBounds(parent, first, last); - }; + callback(key, value, qp); + } + } - // override to avoid SVG detection/work when in node (this is not needed in SSR) + function findLiveRoute(liveRoutes, name) { + if (!liveRoutes) { + return; + } + var stack = [liveRoutes]; + while (stack.length > 0) { + var test = stack.shift(); + if (test.render.name === name) { + return test; + } + var outlets = test.outlets; + for (var outletName in outlets) { + stack.push(outlets[outletName]); + } + } + } - NodeDOMTreeConstruction.prototype.createElement = function createElement(tag) { - return this.document.createElement(tag); - }; + function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { + var target = undefined; + var myState = { + render: renderOptions, + outlets: new _emberUtils.EmptyObject(), + wasUsed: false + }; + if (renderOptions.into) { + target = findLiveRoute(liveRoutes, renderOptions.into); + } else { + target = defaultParentState; + } + if (target) { + _emberMetal.set(target.outlets, renderOptions.outlet, myState); + } else { + if (renderOptions.into) { + _emberMetal.deprecate('Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated.', false, { + id: 'ember-routing.top-level-render-helper', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' + }); - // override to avoid namespace shenanigans when in node (this is not needed in SSR) + // Megahax time. Post-3.0-breaking-changes, we will just assert + // right here that the user tried to target a nonexistent + // thing. But for now we still need to support the `render` + // helper, and people are allowed to target templates rendered + // by the render helper. So instead we defer doing anyting with + // these orphan renders until afterRender. + appendOrphan(liveRoutes, renderOptions.into, myState); + } else { + liveRoutes = myState; + } + } + return { + liveRoutes: liveRoutes, + ownState: myState + }; + } - NodeDOMTreeConstruction.prototype.setAttribute = function setAttribute(element, name, value) { - element.setAttribute(name, value); - }; + function appendOrphan(liveRoutes, into, myState) { + if (!liveRoutes.outlets.__ember_orphans__) { + liveRoutes.outlets.__ember_orphans__ = { + render: { + name: '__ember_orphans__' + }, + outlets: new _emberUtils.EmptyObject() + }; + } + liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; + _emberMetal.run.schedule('afterRender', function () { + // `wasUsed` gets set by the render helper. + _emberMetal.assert('You attempted to render into \'' + into + '\' but it was not found', liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed); + }); + } - return NodeDOMTreeConstruction; - })(_glimmerRuntime.DOMTreeConstruction); + function representEmptyRoute(liveRoutes, defaultParentState, route) { + // the route didn't render anything + var alreadyAppended = findLiveRoute(liveRoutes, route.routeName); + if (alreadyAppended) { + // But some other route has already rendered our default + // template, so that becomes the default target for any + // children we may have. + return alreadyAppended; + } else { + // Create an entry to represent our default template name, + // just so other routes can target it and inherit its place + // in the outlet hierarchy. + defaultParentState.outlets.main = { + render: { + name: route.routeName, + outlet: 'main' + }, + outlets: {} + }; + return defaultParentState; + } + } - exports.default = NodeDOMTreeConstruction; + exports.default = EmberRouter; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItbm9kZS9saWIvbm9kZS1kb20taGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQUlBLHVCQUFBOzhCQUFBL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udC5jcmVhdGVSYXdIVE1MU2VjdGlvbihodG1sKTtcbiAgICBwYXJlbnQuaW5zZXJ0QmVmb3JlKHJhdywgcmVmZXJlbmNlKTtcblxuICAgIGxldCBmaXJzdCA9IHByZXYgPyBwcmV2Lm5leHRTaWJsaW5nIDogcGFyZW50LmZpcnN0Q2hpbGQ7XG4gICAgbGV0IGxhc3QgPSByZWZlcmVuY2UgPyByZWZlcmVuY2UucHJldmlvdXNTaWJsaW5nIDogcGFyZW50Lmxhc3RDaGlsZDtcblxuICAgIHJldHVybiBuZXcgQ29uY3JldGVCb3VuZHMocGFyZW50LCBmaXJzdCwgbGFzdCk7XG4gIH1cblxuICAvLyBvdmVycmlkZSB0byBhdm9pZCBTVkcgZGV0ZWN0aW9uL3dvcmsgd2hlbiBpbiBub2RlICh0aGlzIGlzIG5vdCBuZWVkZWQgaW4gU1NSKVxuICBjcmVhdGVFbGVtZW50KHRhZzogc3RyaW5nKSB7XG4gICAgcmV0dXJuIHRoaXMuZG9jdW1lbnQuY3JlYXRlRWxlbWVudCh0YWcpO1xuICB9XG5cbiAgLy8gb3ZlcnJpZGUgdG8gYXZvaWQgbmFtZXNwYWNlIHNoZW5hbmlnYW5zIHdoZW4gaW4gbm9kZSAodGhpcyBpcyBub3QgbmVlZGVkIGluIFNTUilcbiAgc2V0QXR0cmlidXRlKGVsZW1lbnQ6IEVsZW1lbnQsIG5hbWU6IHN0cmluZywgdmFsdWU6IHN0cmluZykge1xuICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKG5hbWUsIHZhbHVlKTtcbiAgfVxufVxuIl19 -enifed('glimmer-reference/index', ['exports', 'glimmer-reference/lib/reference', 'glimmer-reference/lib/const', 'glimmer-reference/lib/validators', 'glimmer-reference/lib/utils', 'glimmer-reference/lib/iterable'], function (exports, _glimmerReferenceLibReference, _glimmerReferenceLibConst, _glimmerReferenceLibValidators, _glimmerReferenceLibUtils, _glimmerReferenceLibIterable) { + +/** +@module ember +@submodule ember-routing +*/ +enifed('ember-routing/system/router_state', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime'], function (exports, _emberUtils, _emberMetal, _emberRuntime) { 'use strict'; - exports.BasicReference = _glimmerReferenceLibReference.Reference; - exports.BasicPathReference = _glimmerReferenceLibReference.PathReference; - exports.ConstReference = _glimmerReferenceLibConst.ConstReference; - exports.isConst = _glimmerReferenceLibConst.isConst; - babelHelpers.defaults(exports, babelHelpers.interopExportWildcard(_glimmerReferenceLibValidators, babelHelpers.defaults)); - exports.Reference = _glimmerReferenceLibValidators.VersionedReference; - exports.PathReference = _glimmerReferenceLibValidators.VersionedPathReference; - exports.referenceFromParts = _glimmerReferenceLibUtils.referenceFromParts; - exports.IterationItem = _glimmerReferenceLibIterable.IterationItem; - exports.Iterator = _glimmerReferenceLibIterable.Iterator; - exports.Iterable = _glimmerReferenceLibIterable.Iterable; - exports.OpaqueIterator = _glimmerReferenceLibIterable.OpaqueIterator; - exports.OpaqueIterable = _glimmerReferenceLibIterable.OpaqueIterable; - exports.AbstractIterator = _glimmerReferenceLibIterable.AbstractIterator; - exports.AbstractIterable = _glimmerReferenceLibIterable.AbstractIterable; - exports.IterationArtifacts = _glimmerReferenceLibIterable.IterationArtifacts; - exports.ReferenceIterator = _glimmerReferenceLibIterable.ReferenceIterator; - exports.IteratorSynchronizer = _glimmerReferenceLibIterable.IteratorSynchronizer; - exports.IteratorSynchronizerDelegate = _glimmerReferenceLibIterable.IteratorSynchronizerDelegate; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztVQUNlLGNBQWMsaUNBQTNCLFNBQVM7VUFDUSxrQkFBa0IsaUNBQW5DLGFBQWE7VUFJYixjQUFjLDZCQUFkLGNBQWM7VUFDZCxPQUFPLDZCQUFQLE9BQU87O1VBTWUsU0FBUyxrQ0FBL0Isa0JBQWtCO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ZXJhdG9yLFxuICBJdGVyYWJsZSxcbiAgT3BhcXVlSXRlcmF0b3IsXG4gIE9wYXF1ZUl0ZXJhYmxlLFxuICBBYnN0cmFjdEl0ZXJhdG9yLFxuICBBYnN0cmFjdEl0ZXJhYmxlLFxuICBJdGVyYXRpb25BcnRpZmFjdHMsXG4gIFJlZmVyZW5jZUl0ZXJhdG9yLFxuICBJdGVyYXRvclN5bmNocm9uaXplcixcbiAgSXRlcmF0b3JTeW5jaHJvbml6ZXJEZWxlZ2F0ZVxufSBmcm9tICcuL2xpYi9pdGVyYWJsZSc7XG4iXX0= -enifed('glimmer-reference/lib/const', ['exports', 'glimmer-reference/lib/validators'], function (exports, _glimmerReferenceLibValidators) { - 'use strict'; + exports.default = _emberRuntime.Object.extend({ + emberRouter: null, + routerJs: null, + routerJsState: null, - exports.isConst = isConst; + isActiveIntent: function (routeName, models, queryParams, queryParamsMustMatch) { + var state = this.routerJsState; + if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { + return false; + } - var ConstReference = (function () { - function ConstReference(inner) { - this.inner = inner; - this.tag = _glimmerReferenceLibValidators.CONSTANT_TAG; - } + var emptyQueryParams = _emberMetal.isEmpty(Object.keys(queryParams)); - ConstReference.prototype.value = function value() { - return this.inner; - }; + if (queryParamsMustMatch && !emptyQueryParams) { + var visibleQueryParams = {}; + _emberUtils.assign(visibleQueryParams, queryParams); - return ConstReference; - })(); + this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); + return shallowEqual(visibleQueryParams, state.queryParams); + } - exports.ConstReference = ConstReference; + return true; + } + }); - function isConst(reference) { - return reference.tag === _glimmerReferenceLibValidators.CONSTANT_TAG; + function shallowEqual(a, b) { + var k = undefined; + for (k in a) { + if (a.hasOwnProperty(k) && a[k] !== b[k]) { + return false; + } + } + for (k in b) { + if (b.hasOwnProperty(k) && a[k] !== b[k]) { + return false; + } } + return true; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzI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mV0dXJuIHJlZmVyZW5jZS50YWcgPT09IENPTlNUQU5UX1RBRztcbn1cbiJdfQ== -enifed("glimmer-reference/lib/iterable", ["exports", "glimmer-util"], function (exports, _glimmerUtil) { - "use strict"; - - var ListItem = (function (_ListNode) { - babelHelpers.inherits(ListItem, _ListNode); - - function ListItem(iterable, result) { - _ListNode.call(this, iterable.valueReferenceFor(result)); - this.retained = false; - this.seen = false; - this.key = result.key; - this.iterable = iterable; - this.memo = iterable.memoReferenceFor(result); - } +enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { + 'use strict'; - ListItem.prototype.update = function update(item) { - this.retained = true; - this.iterable.updateValueReference(this.value, item); - this.iterable.updateMemoReference(this.memo, item); - }; + exports.routeArgs = routeArgs; + exports.getActiveTargetName = getActiveTargetName; + exports.stashParamNames = stashParamNames; + exports.calculateCacheKey = calculateCacheKey; + exports.normalizeControllerQueryParams = normalizeControllerQueryParams; + exports.prefixRouteNameArg = prefixRouteNameArg; - ListItem.prototype.shouldRemove = function shouldRemove() { - return !this.retained; - }; + var ALL_PERIODS_REGEX = /\./g; - ListItem.prototype.reset = function reset() { - this.retained = false; - this.seen = false; - }; + function routeArgs(targetRouteName, models, queryParams) { + var args = []; + if (typeof targetRouteName === 'string') { + args.push('' + targetRouteName); + } + args.push.apply(args, models); + args.push({ queryParams: queryParams }); + return args; + } - return ListItem; - })(_glimmerUtil.ListNode); + function getActiveTargetName(router) { + var handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; + return handlerInfos[handlerInfos.length - 1].name; + } - exports.ListItem = ListItem; + function stashParamNames(router, handlerInfos) { + if (handlerInfos._namesStashed) { + return; + } - var IterationArtifacts = (function () { - function IterationArtifacts(iterable) { - this.map = _glimmerUtil.dict(); - this.list = new _glimmerUtil.LinkedList(); - this.tag = iterable.tag; - this.iterable = iterable; - } + // This helper exists because router.js/route-recognizer.js awkwardly + // keeps separate a handlerInfo's list of parameter names depending + // on whether a URL transition or named transition is happening. + // Hopefully we can remove this in the future. + var targetRouteName = handlerInfos[handlerInfos.length - 1].name; + var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); + var dynamicParent = null; - IterationArtifacts.prototype.isEmpty = function isEmpty() { - var iterator = this.iterator = this.iterable.iterate(); - return iterator.isEmpty(); - }; + for (var i = 0; i < handlerInfos.length; ++i) { + var handlerInfo = handlerInfos[i]; + var names = recogHandlers[i].names; - IterationArtifacts.prototype.iterate = function iterate() { - var iterator = this.iterator || this.iterable.iterate(); - this.iterator = null; - return iterator; - }; + if (names.length) { + dynamicParent = handlerInfo; + } - IterationArtifacts.prototype.has = function has(key) { - return !!this.map[key]; - }; + handlerInfo._names = names; - IterationArtifacts.prototype.get = function get(key) { - return this.map[key]; - }; + var route = handlerInfo.handler; + route._stashNames(handlerInfo, dynamicParent); + } - IterationArtifacts.prototype.wasSeen = function wasSeen(key) { - var node = this.map[key]; - return node && node.seen; - }; + handlerInfos._namesStashed = true; + } - IterationArtifacts.prototype.append = function append(item) { - var map = this.map; - var list = this.list; - var iterable = this.iterable; + function _calculateCacheValuePrefix(prefix, part) { + // calculates the dot seperated sections from prefix that are also + // at the start of part - which gives us the route name - var node = map[item.key] = new ListItem(iterable, item); - list.append(node); - return node; - }; + // given : prefix = site.article.comments, part = site.article.id + // - returns: site.article (use get(values[site.article], 'id') to get the dynamic part - used below) - IterationArtifacts.prototype.insertBefore = function insertBefore(item, reference) { - var map = this.map; - var list = this.list; - var iterable = this.iterable; + // given : prefix = site.article, part = site.article.id + // - returns: site.article. (use get(values[site.article], 'id') to get the dynamic part - used below) - var node = map[item.key] = new ListItem(iterable, item); - node.retained = true; - list.insertBefore(node, reference); - return node; - }; + var prefixParts = prefix.split('.'); + var currPrefix = ''; - IterationArtifacts.prototype.move = function move(item, reference) { - var list = this.list; + for (var i = 0; i < prefixParts.length; i++) { + var currPart = prefixParts.slice(0, i + 1).join('.'); + if (part.indexOf(currPart) !== 0) { + break; + } + currPrefix = currPart; + } - item.retained = true; - list.remove(item); - list.insertBefore(item, reference); - }; + return currPrefix; + } - IterationArtifacts.prototype.remove = function remove(item) { - var list = this.list; + /* + Stolen from Controller + */ - list.remove(item); - delete this.map[item.key]; - }; + function calculateCacheKey(prefix, parts, values) { + if (parts === undefined) parts = []; - IterationArtifacts.prototype.nextNode = function nextNode(item) { - return this.list.nextNode(item); - }; + var suffixes = ''; + for (var i = 0; i < parts.length; ++i) { + var part = parts[i]; + var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); + var value = undefined; + if (values) { + if (cacheValuePrefix && cacheValuePrefix in values) { + var partRemovedPrefix = part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part; + value = _emberMetal.get(values[cacheValuePrefix], partRemovedPrefix); + } else { + value = _emberMetal.get(values, part); + } + } + suffixes += '::' + part + ':' + value; + } + return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); + } - IterationArtifacts.prototype.head = function head() { - return this.list.head(); - }; + /* + Controller-defined query parameters can come in three shapes: + + Array + queryParams: ['foo', 'bar'] + Array of simple objects where value is an alias + queryParams: [ + { + 'foo': 'rename_foo_to_this' + }, + { + 'bar': 'call_bar_this_instead' + } + ] + Array of fully defined objects + queryParams: [ + { + 'foo': { + as: 'rename_foo_to_this' + }, + } + { + 'bar': { + as: 'call_bar_this_instead', + scope: 'controller' + } + } + ] + + This helper normalizes all three possible styles into the + 'Array of fully defined objects' style. + */ - return IterationArtifacts; - })(); + function normalizeControllerQueryParams(queryParams) { + var qpMap = {}; - exports.IterationArtifacts = IterationArtifacts; + for (var i = 0; i < queryParams.length; ++i) { + accumulateQueryParamDescriptors(queryParams[i], qpMap); + } - var ReferenceIterator = (function () { - // if anyone needs to construct this object with something other than - // an iterable, let @wycats know. + return qpMap; + } - function ReferenceIterator(iterable) { - this.iterator = null; - var artifacts = new IterationArtifacts(iterable); - this.artifacts = artifacts; - } + function accumulateQueryParamDescriptors(_desc, accum) { + var desc = _desc; + var tmp = undefined; + if (typeof desc === 'string') { + tmp = {}; + tmp[desc] = { as: null }; + desc = tmp; + } - ReferenceIterator.prototype.next = function next() { - var artifacts = this.artifacts; + for (var key in desc) { + if (!desc.hasOwnProperty(key)) { + return; + } - var iterator = this.iterator = this.iterator || artifacts.iterate(); - var item = iterator.next(); - if (!item) return null; - return artifacts.append(item); - }; + var singleDesc = desc[key]; + if (typeof singleDesc === 'string') { + singleDesc = { as: singleDesc }; + } - return ReferenceIterator; - })(); + tmp = accum[key] || { as: null, scope: 'model' }; + _emberUtils.assign(tmp, singleDesc); - exports.ReferenceIterator = ReferenceIterator; + accum[key] = tmp; + } + } - var Phase; - (function (Phase) { - Phase[Phase["Append"] = 0] = "Append"; - Phase[Phase["Prune"] = 1] = "Prune"; - Phase[Phase["Done"] = 2] = "Done"; - })(Phase || (Phase = {})); + /* + Check if a routeName resembles a url instead + + @private + */ + function resemblesURL(str) { + return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); + } - var IteratorSynchronizer = (function () { - function IteratorSynchronizer(_ref) { - var target = _ref.target; - var artifacts = _ref.artifacts; + /* + Returns an arguments array where the route name arg is prefixed based on the mount point + + @private + */ - this.target = target; - this.artifacts = artifacts; - this.iterator = artifacts.iterate(); - this.current = artifacts.head(); - } + function prefixRouteNameArg(route, args) { + var routeName = args[0]; + var owner = _emberUtils.getOwner(route); + var prefix = owner.mountPoint; - IteratorSynchronizer.prototype.sync = function sync() { - var phase = Phase.Append; - while (true) { - switch (phase) { - case Phase.Append: - phase = this.nextAppend(); - break; - case Phase.Prune: - phase = this.nextPrune(); - break; - case Phase.Done: - this.nextDone(); - return; - } - } - }; + // only alter the routeName if it's actually referencing a route. + if (owner.routable && typeof routeName === 'string') { + if (resemblesURL(routeName)) { + throw new _emberMetal.Error('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'); + } else { + routeName = prefix + '.' + routeName; + args[0] = routeName; + } + } - IteratorSynchronizer.prototype.advanceToKey = function advanceToKey(key) { - var current = this.current; - var artifacts = this.artifacts; + return args; + } +}); +enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeMixinsComparable) { + 'use strict'; - var seek = current; - while (seek && seek.key !== key) { - seek.seen = true; - seek = artifacts.nextNode(seek); - } - this.current = seek && artifacts.nextNode(seek); - }; + exports.default = compare; - IteratorSynchronizer.prototype.nextAppend = function nextAppend() { - var iterator = this.iterator; - var current = this.current; - var artifacts = this.artifacts; + var TYPE_ORDER = { + 'undefined': 0, + 'null': 1, + 'boolean': 2, + 'number': 3, + 'string': 4, + 'array': 5, + 'object': 6, + 'instance': 7, + 'function': 8, + 'class': 9, + 'date': 10 + }; - var item = iterator.next(); - if (item === null) { - return this.startPrune(); - } - var key = item.key; + // + // the spaceship operator + // + // `. ___ + // __,' __`. _..----....____ + // __...--.'``;. ,. ;``--..__ .' ,-._ _.-' + // _..-''-------' `' `' `' O ``-''._ (,;') _,' + // ,'________________ \`-._`-',' + // `._ ```````````------...___ '-.._'-: + // ```--.._ ,. ````--...__\-. + // `.--. `-` "INFINITY IS LESS ____ | |` + // `. `. THAN BEYOND" ,'`````. ; ;` + // `._`. __________ `. \'__/` + // `-:._____/______/___/____`. \ ` + // | `._ `. \ + // `._________`-. `. `.___ + // SSt `------'` + function spaceship(a, b) { + var diff = a - b; + return (diff > 0) - (diff < 0); + } - if (current && current.key === key) { - this.nextRetain(item); - } else if (artifacts.has(key)) { - this.nextMove(item); - } else { - this.nextInsert(item); - } - return Phase.Append; - }; + /** + Compares two javascript values and returns: + + - -1 if the first is smaller than the second, + - 0 if both are equal, + - 1 if the first is greater than the second. + + ```javascript + Ember.compare('hello', 'hello'); // 0 + Ember.compare('abc', 'dfg'); // -1 + Ember.compare(2, 1); // 1 + ``` + + If the types of the two objects are different precedence occurs in the + following order, with types earlier in the list considered `<` types + later in the list: + + - undefined + - null + - boolean + - number + - string + - array + - object + - instance + - function + - class + - date + + ```javascript + Ember.compare('hello', 50); // 1 + Ember.compare(50, 'hello'); // -1 + ``` + + @method compare + @for Ember + @param {Object} v First value to compare + @param {Object} w Second value to compare + @return {Number} -1 if v < w, 0 if v = w and 1 if v > w. + @public + */ - IteratorSynchronizer.prototype.nextRetain = function nextRetain(item) { - var artifacts = this.artifacts; - var current = this.current; + function compare(v, w) { + if (v === w) { + return 0; + } - current.update(item); - this.current = artifacts.nextNode(current); - this.target.retain(item.key, current.value, current.memo); - }; + var type1 = _emberRuntimeUtils.typeOf(v); + var type2 = _emberRuntimeUtils.typeOf(w); - IteratorSynchronizer.prototype.nextMove = function nextMove(item) { - var current = this.current; - var artifacts = this.artifacts; - var target = this.target; - var key = item.key; + if (_emberRuntimeMixinsComparable.default) { + if (type1 === 'instance' && _emberRuntimeMixinsComparable.default.detect(v) && v.constructor.compare) { + return v.constructor.compare(v, w); + } - var found = artifacts.get(item.key); - found.update(item); - if (artifacts.wasSeen(item.key)) { - artifacts.move(found, current); - target.move(found.key, found.value, found.memo, current ? current.key : null); - } else { - this.advanceToKey(key); - } - }; + if (type2 === 'instance' && _emberRuntimeMixinsComparable.default.detect(w) && w.constructor.compare) { + return w.constructor.compare(w, v) * -1; + } + } - IteratorSynchronizer.prototype.nextInsert = function nextInsert(item) { - var artifacts = this.artifacts; - var target = this.target; - var current = this.current; + var res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); - var node = artifacts.insertBefore(item, current); - target.insert(node.key, node.value, node.memo, current ? current.key : null); - }; + if (res !== 0) { + return res; + } - IteratorSynchronizer.prototype.startPrune = function startPrune() { - this.current = this.artifacts.head(); - return Phase.Prune; - }; + // types are equal - so we have to check values now + switch (type1) { + case 'boolean': + case 'number': + return spaceship(v, w); - IteratorSynchronizer.prototype.nextPrune = function nextPrune() { - var artifacts = this.artifacts; - var target = this.target; - var current = this.current; + case 'string': + return spaceship(v.localeCompare(w), 0); - if (current === null) { - return Phase.Done; - } - var node = current; - this.current = artifacts.nextNode(node); - if (node.shouldRemove()) { - artifacts.remove(node); - target.delete(node.key); - } else { - node.reset(); + case 'array': + { + var vLen = v.length; + var wLen = w.length; + var len = Math.min(vLen, wLen); + + for (var i = 0; i < len; i++) { + var r = compare(v[i], w[i]); + if (r !== 0) { + return r; } - return Phase.Prune; - }; + } - IteratorSynchronizer.prototype.nextDone = function nextDone() { - this.target.done(); - }; + // all elements are equal now + // shorter array should be ordered first + return spaceship(vLen, wLen); + } + case 'instance': + if (_emberRuntimeMixinsComparable.default && _emberRuntimeMixinsComparable.default.detect(v)) { + return v.compare(v, w); + } + return 0; - return IteratorSynchronizer; - })(); + case 'date': + return spaceship(v.getTime(), w.getTime()); - exports.IteratorSynchronizer = IteratorSynchronizer; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9pdGVyYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFrQ0EsUUFBQTs4QkFBQSxRQUFBOztBQU9FLGlCQVBGLFFBQUEsQ0FPYyxRQUF3QixFQUFFLE1BQTJCLEVBQUE7QUFDL0QsaUNBQU0sUUFBUSxDQUFDLGlCQUFpQixDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7QUFMckMsZ0JBQUEsQ0FBQSxRQUFRLEdBQVksS0FBSyxDQUFDO0FBQzFCLGdCQUFBLENBQUEsSUFBSSxHQUFZLEtBQUssQ0FBQztBQUszQixnQkFBSSxDQUFDLEdBQUcsR0FBRyxNQUFNLENBQUMsR0FBRyxDQUFDO0FBQ3RCLGdCQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztBQUN6QixnQkFBSSxDQUFDLElBQUksR0FBRyxRQUFRLENBQUMsZ0JBQWdCLENBQUMsTUFBTSxDQUFDLENBQUM7U0FDL0M7O0FBWkgsZ0JBQUEsV0FjRSxNQUFNLEdBQUEsZ0JBQUMsSUFBeUIsRUFBQTtBQUM5Q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SA9IHRoaXM7XG5cbiAgICBpZiAoY3VycmVudCA9PT0gbnVsbCkge1xuICAgICAgcmV0dXJuIFBoYXNlLkRvbmU7XG4gICAgfVxuXG4gICAgbGV0IG5vZGUgPSBjdXJyZW50O1xuICAgIHRoaXMuY3VycmVudCA9IGFydGlmYWN0cy5uZXh0Tm9kZShub2RlKTtcblxuICAgIGlmIChub2RlLnNob3VsZFJlbW92ZSgpKSB7XG4gICAgICBhcnRpZmFjdHMucmVtb3ZlKG5vZGUpO1xuICAgICAgdGFyZ2V0LmRlbGV0ZShub2RlLmtleSk7XG4gICAgfSBlbHNlIHtcbiAgICAgIG5vZGUucmVzZXQoKTtcbiAgICB9XG5cbiAgICByZXR1cm4gUGhhc2UuUHJ1bmU7XG4gIH1cblxuICBwcml2YXRlIG5leHREb25lKCkge1xuICAgIHRoaXMudGFyZ2V0LmRvbmUoKTtcbiAgfVxufVxuIl19 -enifed("glimmer-reference/lib/reference", ["exports"], function (exports) { - "use strict"; + default: + return 0; + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9yZWZlcmVuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJyZWZlcmVuY2UuanMiLCJzb3VyY2VzQ29udGVudCI6W119 -enifed("glimmer-reference/lib/utils", ["exports"], function (exports) { - "use strict"; +enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - exports.referenceFromParts = referenceFromParts; + exports.empty = empty; + exports.notEmpty = notEmpty; + exports.none = none; + exports.not = not; + exports.bool = bool; + exports.match = match; + exports.equal = equal; + exports.gt = gt; + exports.gte = gte; + exports.lt = lt; + exports.lte = lte; + exports.oneWay = oneWay; + exports.readOnly = readOnly; + exports.deprecatingAlias = deprecatingAlias; - function referenceFromParts(root, parts) { - var reference = root; - for (var i = 0; i < parts.length; i++) { - reference = reference.get(parts[i]); - } - return reference; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUdBLGFBQUEsa0JBQUEsQ0FBbUMsSUFBb0MsRUFBRSxLQUFlLEVBQUE7QUFDdEYsWUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDO0FBRXJCLGFBQUssSUFBSSxDQUFDLEdBQUMsQ0FBQyxFQUFFLENBQUMsR0FBQyxLQUFLLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO0FBQ2pDLHFCQUFTLEdBQUcsU0FBUyxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUNyQztBQUVELGVBQU8sU0FBUyxDQUFDO0tBQ2xCIiwiZmlsZSI6InV0aWxzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgVmVyc2lvbmVkUGF0aFJlZmVyZW5jZSB9IGZyb20gJy4vdmFsaWRhdG9ycyc7XG5pbXBvcnQgeyBPcGFxdWUgfSBmcm9tICdnbGltbWVyLXV0aWwnO1xuXG5leHBvcnQgZnVuY3Rpb24gcmVmZXJlbmNlRnJvbVBhcnRzKHJvb3Q6IFZlcnNpb25lZFBhdGhSZWZlcmVuY2U8T3BhcXVlPiwgcGFydHM6IHN0cmluZ1tdKTogVmVyc2lvbmVkUGF0aFJlZmVyZW5jZTxPcGFxdWU+IHtcbiAgbGV0IHJlZmVyZW5jZSA9IHJvb3Q7XG5cbiAgZm9yIChsZXQgaT0wOyBpPHBhcnRzLmxlbmd0aDsgaSsrKSB7XG4gICAgcmVmZXJlbmNlID0gcmVmZXJlbmNlLmdldChwYXJ0c1tpXSk7XG4gIH1cblxuICByZXR1cm4gcmVmZXJlbmNlO1xufVxuIl19 -enifed("glimmer-reference/lib/validators", ["exports"], function (exports) { - "use strict"; + /** + @module ember + @submodule ember-metal + */ - exports.combineTagged = combineTagged; - exports.combineSlice = combineSlice; - exports.combine = combine; - exports.map = map; - exports.isModified = isModified; - var CONSTANT = 0; - exports.CONSTANT = CONSTANT; - var INITIAL = 1; - exports.INITIAL = INITIAL; - var VOLATILE = NaN; - exports.VOLATILE = VOLATILE; + function expandPropertiesToArray(predicateName, properties) { + var expandedProperties = []; - var RevisionTag = (function () { - function RevisionTag() {} + function extractProperty(entry) { + expandedProperties.push(entry); + } - RevisionTag.prototype.validate = function validate(snapshot) { - return this.value() === snapshot; - }; + for (var i = 0; i < properties.length; i++) { + var property = properties[i]; + _emberMetal.assert('Dependent keys passed to Ember.computed.' + predicateName + '() can\'t have spaces.', property.indexOf(' ') < 0); - return RevisionTag; - })(); + _emberMetal.expandProperties(property, extractProperty); + } - exports.RevisionTag = RevisionTag; + return expandedProperties; + } - var $REVISION = INITIAL; + function generateComputedWithPredicate(name, predicate) { + return function () { + for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) { + properties[_key] = arguments[_key]; + } - var DirtyableTag = (function (_RevisionTag) { - babelHelpers.inherits(DirtyableTag, _RevisionTag); + var expandedProperties = expandPropertiesToArray(name, properties); - function DirtyableTag() { - var revision = arguments.length <= 0 || arguments[0] === undefined ? $REVISION : arguments[0]; + var computedFunc = _emberMetal.computed(function () { + var lastIdx = expandedProperties.length - 1; - _RevisionTag.call(this); - this.revision = revision; + for (var i = 0; i < lastIdx; i++) { + var value = _emberMetal.get(this, expandedProperties[i]); + if (!predicate(value)) { + return value; + } } - DirtyableTag.prototype.value = function value() { - return this.revision; - }; + return _emberMetal.get(this, expandedProperties[lastIdx]); + }); - DirtyableTag.prototype.dirty = function dirty() { - this.revision = ++$REVISION; - }; + return computedFunc.property.apply(computedFunc, expandedProperties); + }; + } - return DirtyableTag; - })(RevisionTag); + /** + A computed property that returns true if the value of the dependent + property is null, an empty string, empty array, or empty function. + + Example + + ```javascript + let ToDoList = Ember.Object.extend({ + isDone: Ember.computed.empty('todos') + }); + + let todoList = ToDoList.create({ + todos: ['Unit Test', 'Documentation', 'Release'] + }); + + todoList.get('isDone'); // false + todoList.get('todos').clear(); + todoList.get('isDone'); // true + ``` + + @since 1.6.0 + @method empty + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which negate + the original value for property + @public + */ - exports.DirtyableTag = DirtyableTag; + function empty(dependentKey) { + return _emberMetal.computed(dependentKey + '.length', function () { + return _emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); + }); + } - function combineTagged(tagged) { - var optimized = []; - for (var i = 0, l = tagged.length; i < l; i++) { - var tag = tagged[i].tag; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); - } - return _combine(optimized); - } + /** + A computed property that returns true if the value of the dependent + property is NOT null, an empty string, empty array, or empty function. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasStuff: Ember.computed.notEmpty('backpack') + }); + + let hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); + + hamster.get('hasStuff'); // true + hamster.get('backpack').clear(); // [] + hamster.get('hasStuff'); // false + ``` + + @method notEmpty + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which returns true if + original value for property is not empty. + @public + */ - function combineSlice(slice) { - var optimized = []; - var node = slice.head(); - while (node !== null) { - var tag = node.tag; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag !== CONSTANT_TAG) optimized.push(tag); - node = slice.nextNode(node); - } - return _combine(optimized); - } + function notEmpty(dependentKey) { + return _emberMetal.computed(dependentKey + '.length', function () { + return !_emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); + }); + } - function combine(tags) { - var optimized = []; - for (var i = 0, l = tags.length; i < l; i++) { - var tag = tags[i]; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); - } - return _combine(optimized); - } + /** + A computed property that returns true if the value of the dependent + property is null or undefined. This avoids errors from JSLint complaining + about use of ==, which can be technically confusing. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + isHungry: Ember.computed.none('food') + }); + + let hamster = Hamster.create(); + + hamster.get('isHungry'); // true + hamster.set('food', 'Banana'); + hamster.get('isHungry'); // false + hamster.set('food', null); + hamster.get('isHungry'); // true + ``` + + @method none + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which + returns true if original value for property is null or undefined. + @public + */ - function _combine(tags) { - switch (tags.length) { - case 0: - return CONSTANT_TAG; - case 1: - return tags[0]; - case 2: - return new TagsPair(tags[0], tags[1]); - default: - return new TagsCombinator(tags); - } - ; - } + function none(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.isNone(_emberMetal.get(this, dependentKey)); + }); + } + + /** + A computed property that returns the inverse boolean value + of the original value for the dependent property. + + Example + + ```javascript + let User = Ember.Object.extend({ + isAnonymous: Ember.computed.not('loggedIn') + }); + + let user = User.create({loggedIn: false}); + + user.get('isAnonymous'); // true + user.set('loggedIn', true); + user.get('isAnonymous'); // false + ``` + + @method not + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which returns + inverse of the original value for property + @public + */ - var CachedTag = (function (_RevisionTag2) { - babelHelpers.inherits(CachedTag, _RevisionTag2); + function not(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return !_emberMetal.get(this, dependentKey); + }); + } - function CachedTag() { - _RevisionTag2.apply(this, arguments); - this.lastChecked = null; - this.lastValue = null; - } + /** + A computed property that converts the provided dependent property + into a boolean value. + + ```javascript + let Hamster = Ember.Object.extend({ + hasBananas: Ember.computed.bool('numBananas') + }); + + let hamster = Hamster.create(); + + hamster.get('hasBananas'); // false + hamster.set('numBananas', 0); + hamster.get('hasBananas'); // false + hamster.set('numBananas', 1); + hamster.get('hasBananas'); // true + hamster.set('numBananas', null); + hamster.get('hasBananas'); // false + ``` + + @method bool + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which converts + to boolean the original value for property + @public + */ - CachedTag.prototype.value = function value() { - var lastChecked = this.lastChecked; - var lastValue = this.lastValue; + function bool(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return !!_emberMetal.get(this, dependentKey); + }); + } - if (lastChecked !== $REVISION) { - this.lastChecked = $REVISION; - this.lastValue = lastValue = this.compute(); - } - return this.lastValue; - }; + /** + A computed property which matches the original value for the + dependent property against a given RegExp, returning `true` + if the value matches the RegExp and `false` if it does not. + + Example + + ```javascript + let User = Ember.Object.extend({ + hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) + }); + + let user = User.create({loggedIn: false}); + + user.get('hasValidEmail'); // false + user.set('email', ''); + user.get('hasValidEmail'); // false + user.set('email', 'ember_hamster@example.com'); + user.get('hasValidEmail'); // true + ``` + + @method match + @for Ember.computed + @param {String} dependentKey + @param {RegExp} regexp + @return {Ember.ComputedProperty} computed property which match + the original value for property against a given RegExp + @public + */ - CachedTag.prototype.invalidate = function invalidate() { - this.lastChecked = null; - }; + function match(dependentKey, regexp) { + return _emberMetal.computed(dependentKey, function () { + var value = _emberMetal.get(this, dependentKey); - return CachedTag; - })(RevisionTag); + return typeof value === 'string' ? regexp.test(value) : false; + }); + } - exports.CachedTag = CachedTag; + /** + A computed property that returns true if the provided dependent property + is equal to the given value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + satisfied: Ember.computed.equal('percentCarrotsEaten', 100) + }); + + let hamster = Hamster.create(); + + hamster.get('satisfied'); // false + hamster.set('percentCarrotsEaten', 100); + hamster.get('satisfied'); // true + hamster.set('percentCarrotsEaten', 50); + hamster.get('satisfied'); // false + ``` + + @method equal + @for Ember.computed + @param {String} dependentKey + @param {String|Number|Object} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is equal to the given value. + @public + */ - var TagsPair = (function (_CachedTag) { - babelHelpers.inherits(TagsPair, _CachedTag); + function equal(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) === value; + }); + } - function TagsPair(first, second) { - _CachedTag.call(this); - this.first = first; - this.second = second; - } + /** + A computed property that returns true if the provided dependent property + is greater than the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasTooManyBananas: Ember.computed.gt('numBananas', 10) + }); + + let hamster = Hamster.create(); + + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 3); + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 11); + hamster.get('hasTooManyBananas'); // true + ``` + + @method gt + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is greater than given value. + @public + */ - TagsPair.prototype.compute = function compute() { - return Math.max(this.first.value(), this.second.value()); - }; + function gt(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) > value; + }); + } - return TagsPair; - })(CachedTag); + /** + A computed property that returns true if the provided dependent property + is greater than or equal to the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasTooManyBananas: Ember.computed.gte('numBananas', 10) + }); + + let hamster = Hamster.create(); + + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 3); + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 10); + hamster.get('hasTooManyBananas'); // true + ``` + + @method gte + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is greater or equal then given value. + @public + */ - var TagsCombinator = (function (_CachedTag2) { - babelHelpers.inherits(TagsCombinator, _CachedTag2); + function gte(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) >= value; + }); + } - function TagsCombinator(tags) { - _CachedTag2.call(this); - this.tags = tags; - } + /** + A computed property that returns true if the provided dependent property + is less than the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + needsMoreBananas: Ember.computed.lt('numBananas', 3) + }); + + let hamster = Hamster.create(); + + hamster.get('needsMoreBananas'); // true + hamster.set('numBananas', 3); + hamster.get('needsMoreBananas'); // false + hamster.set('numBananas', 2); + hamster.get('needsMoreBananas'); // true + ``` + + @method lt + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is less then given value. + @public + */ - TagsCombinator.prototype.compute = function compute() { - var tags = this.tags; + function lt(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) < value; + }); + } - var max = -1; - for (var i = 0; i < tags.length; i++) { - var value = tags[i].value(); - max = Math.max(value, max); - } - return max; - }; + /** + A computed property that returns true if the provided dependent property + is less than or equal to the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + needsMoreBananas: Ember.computed.lte('numBananas', 3) + }); + + let hamster = Hamster.create(); + + hamster.get('needsMoreBananas'); // true + hamster.set('numBananas', 5); + hamster.get('needsMoreBananas'); // false + hamster.set('numBananas', 3); + hamster.get('needsMoreBananas'); // true + ``` + + @method lte + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is less or equal than given value. + @public + */ - return TagsCombinator; - })(CachedTag); + function lte(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) <= value; + }); + } - var UpdatableTag = (function (_CachedTag3) { - babelHelpers.inherits(UpdatableTag, _CachedTag3); + /** + A computed property that performs a logical `and` on the + original values for the provided dependent properties. + + You may pass in more than two properties and even use + property brace expansion. The computed property will + return the first falsy value or last truthy value + just like JavaScript's `&&` operator. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), + readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') + }); + + let tomster = Hamster.create(); + + tomster.get('readyForCamp'); // false + tomster.set('hasTent', true); + tomster.get('readyForCamp'); // false + tomster.set('hasBackpack', true); + tomster.get('readyForCamp'); // true + tomster.set('hasBackpack', 'Yes'); + tomster.get('readyForCamp'); // 'Yes' + tomster.set('hasWalkingStick', null); + tomster.get('readyForHike'); // null + ``` + + @method and + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which performs + a logical `and` on the values of all the original values for properties. + @public + */ + var and = generateComputedWithPredicate('and', function (value) { + return value; + }); - function UpdatableTag(tag) { - _CachedTag3.call(this); - this.tag = tag; - this.lastUpdated = INITIAL; - } + exports.and = and; + /** + A computed property which performs a logical `or` on the + original values for the provided dependent properties. + + You may pass in more than two properties and even use + property brace expansion. The computed property will + return the first truthy value or last falsy value just + like JavaScript's `||` operator. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'), + readyForBeach: Ember.computed.or('{hasSunscreen,hasUmbrella}') + }); + + let tomster = Hamster.create(); + + tomster.get('readyForRain'); // undefined + tomster.set('hasUmbrella', true); + tomster.get('readyForRain'); // true + tomster.set('hasJacket', 'Yes'); + tomster.get('readyForRain'); // 'Yes' + tomster.set('hasSunscreen', 'Check'); + tomster.get('readyForBeach'); // 'Check' + ``` + + @method or + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which performs + a logical `or` on the values of all the original values for properties. + @public + */ + var or = generateComputedWithPredicate('or', function (value) { + return !value; + }); - ////////// + exports.or = or; + /** + Creates a new property that is an alias for another property + on an object. Calls to `get` or `set` this property behave as + though they were called on the original property. + + ```javascript + let Person = Ember.Object.extend({ + name: 'Alex Matchneer', + nomen: Ember.computed.alias('name') + }); + + let alex = Person.create(); + + alex.get('nomen'); // 'Alex Matchneer' + alex.get('name'); // 'Alex Matchneer' + + alex.set('nomen', '@machty'); + alex.get('name'); // '@machty' + ``` + + @method alias + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates an + alias to the original value for property. + @public + */ - UpdatableTag.prototype.compute = function compute() { - return Math.max(this.lastUpdated, this.tag.value()); - }; + /** + Where `computed.alias` aliases `get` and `set`, and allows for bidirectional + data flow, `computed.oneWay` only provides an aliased `get`. The `set` will + not mutate the upstream property, rather causes the current property to + become the value set. This causes the downstream property to permanently + diverge from the upstream property. + + Example + + ```javascript + let User = Ember.Object.extend({ + firstName: null, + lastName: null, + nickName: Ember.computed.oneWay('firstName') + }); + + let teddy = User.create({ + firstName: 'Teddy', + lastName: 'Zeenny' + }); + + teddy.get('nickName'); // 'Teddy' + teddy.set('nickName', 'TeddyBear'); // 'TeddyBear' + teddy.get('firstName'); // 'Teddy' + ``` + + @method oneWay + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @public + */ - UpdatableTag.prototype.update = function update(tag) { - if (tag !== this.tag) { - this.tag = tag; - this.lastUpdated = $REVISION; - this.invalidate(); - } - }; + function oneWay(dependentKey) { + return _emberMetal.alias(dependentKey).oneWay(); + } - return UpdatableTag; - })(CachedTag); + /** + This is a more semantically meaningful alias of `computed.oneWay`, + whose name is somewhat ambiguous as to which direction the data flows. + + @method reads + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @public + */ - exports.UpdatableTag = UpdatableTag; - var CONSTANT_TAG = new ((function (_RevisionTag3) { - babelHelpers.inherits(ConstantTag, _RevisionTag3); + /** + Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides + a readOnly one way binding. Very often when using `computed.oneWay` one does + not also want changes to propagate back up, as they will replace the value. + + This prevents the reverse flow, and also throws an exception when it occurs. + + Example + + ```javascript + let User = Ember.Object.extend({ + firstName: null, + lastName: null, + nickName: Ember.computed.readOnly('firstName') + }); + + let teddy = User.create({ + firstName: 'Teddy', + lastName: 'Zeenny' + }); + + teddy.get('nickName'); // 'Teddy' + teddy.set('nickName', 'TeddyBear'); // throws Exception + // throw new Ember.Error('Cannot Set: nickName on: ' );` + teddy.get('firstName'); // 'Teddy' + ``` + + @method readOnly + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @since 1.5.0 + @public + */ - function ConstantTag() { - _RevisionTag3.apply(this, arguments); - } + function readOnly(dependentKey) { + return _emberMetal.alias(dependentKey).readOnly(); + } - ConstantTag.prototype.value = function value() { - return CONSTANT; - }; + /** + Creates a new property that is an alias for another property + on an object. Calls to `get` or `set` this property behave as + though they were called on the original property, but also + print a deprecation warning. + + ```javascript + let Hamster = Ember.Object.extend({ + bananaCount: Ember.computed.deprecatingAlias('cavendishCount', { + id: 'hamster.deprecate-banana', + until: '3.0.0' + }) + }); + + let hamster = Hamster.create(); + + hamster.set('bananaCount', 5); // Prints a deprecation warning. + hamster.get('cavendishCount'); // 5 + ``` + + @method deprecatingAlias + @for Ember.computed + @param {String} dependentKey + @param {Object} options Options for `Ember.deprecate`. + @return {Ember.ComputedProperty} computed property which creates an + alias with a deprecation to the original value for property. + @since 1.7.0 + @public + */ - return ConstantTag; - })(RevisionTag))(); - exports.CONSTANT_TAG = CONSTANT_TAG; - var VOLATILE_TAG = new ((function (_RevisionTag4) { - babelHelpers.inherits(VolatileTag, _RevisionTag4); + function deprecatingAlias(dependentKey, options) { + return _emberMetal.computed(dependentKey, { + get: function (key) { + _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); + return _emberMetal.get(this, dependentKey); + }, + set: function (key, value) { + _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); + _emberMetal.set(this, dependentKey, value); + return value; + } + }); + } +}); +enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) { + /** + @module ember + @submodule ember-runtime + */ - function VolatileTag() { - _RevisionTag4.apply(this, arguments); - } + 'use strict'; - VolatileTag.prototype.value = function value() { - return VOLATILE; - }; + exports.sum = sum; + exports.max = max; + exports.min = min; + exports.map = map; + exports.mapBy = mapBy; + exports.filter = filter; + exports.filterBy = filterBy; + exports.uniq = uniq; + exports.uniqBy = uniqBy; + exports.intersect = intersect; + exports.setDiff = setDiff; + exports.collect = collect; + exports.sort = sort; - return VolatileTag; - })(RevisionTag))(); - exports.VOLATILE_TAG = VOLATILE_TAG; - var CURRENT_TAG = new ((function (_DirtyableTag) { - babelHelpers.inherits(CurrentTag, _DirtyableTag); + function reduceMacro(dependentKey, callback, initialValue) { + return _emberMetal.computed(dependentKey + '.[]', function () { + var _this = this; - function CurrentTag() { - _DirtyableTag.apply(this, arguments); - } + var arr = _emberMetal.get(this, dependentKey); - CurrentTag.prototype.value = function value() { - return $REVISION; - }; + if (arr === null || typeof arr !== 'object') { + return initialValue; + } - return CurrentTag; - })(DirtyableTag))(); - exports.CURRENT_TAG = CURRENT_TAG; + return arr.reduce(function (previousValue, currentValue, index, array) { + return callback.call(_this, previousValue, currentValue, index, array); + }, initialValue); + }).readOnly(); + } - var CachedReference = (function () { - function CachedReference() { - this.lastRevision = null; - this.lastValue = null; - } + function arrayMacro(dependentKey, callback) { + // This is a bit ugly + var propertyName = undefined; + if (/@each/.test(dependentKey)) { + propertyName = dependentKey.replace(/\.@each.*$/, ''); + } else { + propertyName = dependentKey; + dependentKey += '.[]'; + } - CachedReference.prototype.value = function value() { - var tag = this.tag; - var lastRevision = this.lastRevision; - var lastValue = this.lastValue; + return _emberMetal.computed(dependentKey, function () { + var value = _emberMetal.get(this, propertyName); + if (_emberRuntimeUtils.isArray(value)) { + return _emberRuntimeSystemNative_array.A(callback.call(this, value)); + } else { + return _emberRuntimeSystemNative_array.A(); + } + }).readOnly(); + } - if (!lastRevision || !tag.validate(lastRevision)) { - lastValue = this.lastValue = this.compute(); - this.lastRevision = tag.value(); - } - return lastValue; - }; + function multiArrayMacro(dependentKeys, callback) { + var args = dependentKeys.map(function (key) { + return key + '.[]'; + }); - CachedReference.prototype.invalidate = function invalidate() { - this.lastRevision = null; - }; + args.push(function () { + return _emberRuntimeSystemNative_array.A(callback.call(this, dependentKeys)); + }); - return CachedReference; - })(); + return _emberMetal.computed.apply(this, args).readOnly(); + } - exports.CachedReference = CachedReference; + /** + A computed property that returns the sum of the values + in the dependent array. + + @method sum + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the sum of all values in the dependentKey's array + @since 1.4.0 + @public + */ - var MapperReference = (function (_CachedReference) { - babelHelpers.inherits(MapperReference, _CachedReference); + function sum(dependentKey) { + return reduceMacro(dependentKey, function (sum, item) { + return sum + item; + }, 0); + } - function MapperReference(reference, mapper) { - _CachedReference.call(this); - this.tag = reference.tag; - this.reference = reference; - this.mapper = mapper; - } + /** + A computed property that calculates the maximum value in the + dependent array. This will return `-Infinity` when the dependent + array is empty. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age'), + maxChildAge: Ember.computed.max('childAges') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('maxChildAge'); // -Infinity + lordByron.get('children').pushObject({ + name: 'Augusta Ada Byron', age: 7 + }); + lordByron.get('maxChildAge'); // 7 + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('maxChildAge'); // 8 + ``` + + If the types of the arguments are not numbers, + they will be converted to numbers and the type + of the return value will always be `Number`. + For example, the max of a list of Date objects will be + the highest timestamp as a `Number`. + This behavior is consistent with `Math.max`. + + @method max + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array + @public + */ - MapperReference.prototype.compute = function compute() { - var reference = this.reference; - var mapper = this.mapper; + function max(dependentKey) { + return reduceMacro(dependentKey, function (max, item) { + return Math.max(max, item); + }, -Infinity); + } - return mapper(reference.value()); - }; + /** + A computed property that calculates the minimum value in the + dependent array. This will return `Infinity` when the dependent + array is empty. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age'), + minChildAge: Ember.computed.min('childAges') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('minChildAge'); // Infinity + lordByron.get('children').pushObject({ + name: 'Augusta Ada Byron', age: 7 + }); + lordByron.get('minChildAge'); // 7 + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('minChildAge'); // 5 + ``` + + If the types of the arguments are not numbers, + they will be converted to numbers and the type + of the return value will always be `Number`. + For example, the min of a list of Date objects will be + the lowest timestamp as a `Number`. + This behavior is consistent with `Math.min`. + + @method min + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array + @public + */ - return MapperReference; - })(CachedReference); + function min(dependentKey) { + return reduceMacro(dependentKey, function (min, item) { + return Math.min(min, item); + }, Infinity); + } - function map(reference, mapper) { - return new MapperReference(reference, mapper); - } + /** + Returns an array mapped via the callback + + The callback method you provide should have the following signature. + `item` is the current item in the iteration. + `index` is the integer index of the current item in the iteration. + + ```javascript + function(item, index); + ``` + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + excitingChores: Ember.computed.map('chores', function(chore, index) { + return chore.toUpperCase() + '!'; + }) + }); + + let hamster = Hamster.create({ + chores: ['clean', 'write more unit tests'] + }); + + hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] + ``` + + @method map + @for Ember.computed + @param {String} dependentKey + @param {Function} callback + @return {Ember.ComputedProperty} an array mapped via the callback + @public + */ - ////////// + function map(dependentKey, callback) { + return arrayMacro(dependentKey, function (value) { + return value.map(callback, this); + }); + } - var ReferenceCache = (function () { - function ReferenceCache(reference) { - this.lastValue = null; - this.lastRevision = null; - this.initialized = false; - this.tag = reference.tag; - this.reference = reference; - } + /** + Returns an array mapped to the specified key. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('childAges'); // [] + lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); + lordByron.get('childAges'); // [7] + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('childAges'); // [7, 5, 8] + ``` + + @method mapBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @return {Ember.ComputedProperty} an array mapped to the specified key + @public + */ - ReferenceCache.prototype.peek = function peek() { - if (!this.initialized) { - return this.initialize(); - } - return this.lastValue; - }; + function mapBy(dependentKey, propertyKey) { + _emberMetal.assert('Ember.computed.mapBy expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string'); - ReferenceCache.prototype.revalidate = function revalidate() { - if (!this.initialized) { - return this.initialize(); - } - var reference = this.reference; - var lastRevision = this.lastRevision; + return map(dependentKey + '.@each.' + propertyKey, function (item) { + return _emberMetal.get(item, propertyKey); + }); + } - var tag = reference.tag; - if (tag.validate(lastRevision)) return NOT_MODIFIED; - this.lastRevision = tag.value(); - var lastValue = this.lastValue; + /** + Filters the array by the callback. + + The callback method you provide should have the following signature. + `item` is the current item in the iteration. + `index` is the integer index of the current item in the iteration. + `array` is the dependant array itself. + + ```javascript + function(item, index, array); + ``` + + ```javascript + let Hamster = Ember.Object.extend({ + remainingChores: Ember.computed.filter('chores', function(chore, index, array) { + return !chore.done; + }) + }); + + let hamster = Hamster.create({ + chores: [ + { name: 'cook', done: true }, + { name: 'clean', done: true }, + { name: 'write more unit tests', done: false } + ] + }); + + hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] + ``` + + @method filter + @for Ember.computed + @param {String} dependentKey + @param {Function} callback + @return {Ember.ComputedProperty} the filtered array + @public + */ - var value = reference.value(); - if (value === lastValue) return NOT_MODIFIED; - this.lastValue = value; - return value; - }; + function filter(dependentKey, callback) { + return arrayMacro(dependentKey, function (value) { + return value.filter(callback, this); + }); + } - ReferenceCache.prototype.initialize = function initialize() { - var reference = this.reference; + /** + Filters the array by the property and value + + ```javascript + let Hamster = Ember.Object.extend({ + remainingChores: Ember.computed.filterBy('chores', 'done', false) + }); + + let hamster = Hamster.create({ + chores: [ + { name: 'cook', done: true }, + { name: 'clean', done: true }, + { name: 'write more unit tests', done: false } + ] + }); + + hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] + ``` + + @method filterBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @param {*} value + @return {Ember.ComputedProperty} the filtered array + @public + */ - var value = this.lastValue = reference.value(); - this.lastRevision = reference.tag.value(); - this.initialized = true; - return value; - }; + function filterBy(dependentKey, propertyKey, value) { + var callback = undefined; - return ReferenceCache; - })(); + if (arguments.length === 2) { + callback = function (item) { + return _emberMetal.get(item, propertyKey); + }; + } else { + callback = function (item) { + return _emberMetal.get(item, propertyKey) === value; + }; + } - exports.ReferenceCache = ReferenceCache; + return filter(dependentKey + '.@each.' + propertyKey, callback); + } - var NOT_MODIFIED = "adb3b78e-3d22-4e4b-877a-6317c2c5c145"; + /** + A computed property which returns a new array with all the unique + elements from one or more dependent arrays. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + uniqueFruits: Ember.computed.uniq('fruits') + }); + + let hamster = Hamster.create({ + fruits: [ + 'banana', + 'grape', + 'kale', + 'banana' + ] + }); + + hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale'] + ``` + + @method uniq + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ - function isModified(value) { - return value !== NOT_MODIFIED; + function uniq() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi92YWxpZGF0b3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiO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TtcblxuICAgIGxldCB7IGxhc3RWYWx1ZSB9ID0gdGhpcztcbiAgICBsZXQgdmFsdWUgPSByZWZlcmVuY2UudmFsdWUoKTtcbiAgICBpZiAodmFsdWUgPT09IGxhc3RWYWx1ZSkgcmV0dXJuIE5PVF9NT0RJRklFRDtcbiAgICB0aGlzLmxhc3RWYWx1ZSA9IHZhbHVlO1xuXG4gICAgcmV0dXJuIHZhbHVlO1xuICB9XG5cbiAgcHJpdmF0ZSBpbml0aWFsaXplKCk6IFQge1xuICAgIGxldCB7IHJlZmVyZW5jZSB9ID0gdGhpcztcblxuICAgIGxldCB2YWx1ZSA9IHRoaXMubGFzdFZhbHVlID0gcmVmZXJlbmNlLnZhbHVlKCk7XG4gICAgdGhpcy5sYXN0UmV2aXNpb24gPSByZWZlcmVuY2UudGFnLnZhbHVlKCk7XG4gICAgdGhpcy5pbml0aWFsaXplZCA9IHRydWU7XG5cbiAgICByZXR1cm4gdmFsdWU7XG4gIH1cbn1cblxuZXhwb3J0IHR5cGUgVmFsaWRhdGlvbjxUPiA9IFQgfCBOb3RNb2RpZmllZDtcblxuZXhwb3J0IHR5cGUgTm90TW9kaWZpZWQgPSBcImFkYjNiNzhlLTNkMjItNGU0Yi04NzdhLTYzMTdjMmM1YzE0NVwiO1xuXG5jb25zdCBOT1RfTU9ESUZJRUQ6IE5vdE1vZGlmaWVkID0gXCJhZGIzYjc4ZS0zZDIyLTRlNGItODc3YS02MzE3YzJjNWMxNDVcIjtcblxuZXhwb3J0IGZ1bmN0aW9uIGlzTW9kaWZpZWQ8VD4odmFsdWU6IFZhbGlkYXRpb248VD4pOiB2YWx1ZSBpcyBUIHtcbiAgcmV0dXJuIHZhbHVlICE9PSBOT1RfTU9ESUZJRUQ7XG59XG4iXX0= -enifed('glimmer-runtime/index', ['exports', 'glimmer-runtime/lib/dom/interfaces', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/template', 'glimmer-runtime/lib/symbol-table', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/compiled/opcodes/builder', 'glimmer-runtime/lib/compiler', 'glimmer-runtime/lib/opcode-builder', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-runtime/lib/dom/attribute-managers', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/compiled/expressions/function', 'glimmer-runtime/lib/helpers/get-dynamic-var', 'glimmer-runtime/lib/syntax/builtins/with-dynamic-vars', 'glimmer-runtime/lib/syntax/builtins/in-element', 'glimmer-runtime/lib/vm', 'glimmer-runtime/lib/upsert', 'glimmer-runtime/lib/environment', 'glimmer-runtime/lib/partial', 'glimmer-runtime/lib/component/interfaces', 'glimmer-runtime/lib/modifier/interfaces', 'glimmer-runtime/lib/dom/helper', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/bounds'], function (exports, _glimmerRuntimeLibDomInterfaces, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibTemplate, _glimmerRuntimeLibSymbolTable, _glimmerRuntimeLibReferences, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibCompiledOpcodesBuilder, _glimmerRuntimeLibCompiler, _glimmerRuntimeLibOpcodeBuilder, _glimmerRuntimeLibCompiledBlocks, _glimmerRuntimeLibDomAttributeManagers, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibCompiledExpressionsFunction, _glimmerRuntimeLibHelpersGetDynamicVar, _glimmerRuntimeLibSyntaxBuiltinsWithDynamicVars, _glimmerRuntimeLibSyntaxBuiltinsInElement, _glimmerRuntimeLibVm, _glimmerRuntimeLibUpsert, _glimmerRuntimeLibEnvironment, _glimmerRuntimeLibPartial, _glimmerRuntimeLibComponentInterfaces, _glimmerRuntimeLibModifierInterfaces, _glimmerRuntimeLibDomHelper, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibBounds) { - 'use strict'; - - exports.ATTRIBUTE_SYNTAX = _glimmerRuntimeLibSyntax.ATTRIBUTE; - exports.StatementSyntax = _glimmerRuntimeLibSyntax.Statement; - exports.ExpressionSyntax = _glimmerRuntimeLibSyntax.Expression; - exports.AttributeSyntax = _glimmerRuntimeLibSyntax.Attribute; - exports.StatementCompilationBuffer = _glimmerRuntimeLibSyntax.StatementCompilationBuffer; - exports.SymbolLookup = _glimmerRuntimeLibSyntax.SymbolLookup; - exports.CompileInto = _glimmerRuntimeLibSyntax.CompileInto; - exports.isAttribute = _glimmerRuntimeLibSyntax.isAttribute; - exports.templateFactory = _glimmerRuntimeLibTemplate.default; - exports.TemplateFactory = _glimmerRuntimeLibTemplate.TemplateFactory; - exports.Template = _glimmerRuntimeLibTemplate.Template; - exports.SymbolTable = _glimmerRuntimeLibSymbolTable.default; - exports.NULL_REFERENCE = _glimmerRuntimeLibReferences.NULL_REFERENCE; - exports.UNDEFINED_REFERENCE = _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - exports.PrimitiveReference = _glimmerRuntimeLibReferences.PrimitiveReference; - exports.ConditionalReference = _glimmerRuntimeLibReferences.ConditionalReference; - exports.Blocks = _glimmerRuntimeLibSyntaxCore.Blocks; - exports.OptimizedAppend = _glimmerRuntimeLibSyntaxCore.OptimizedAppend; - exports.UnoptimizedAppend = _glimmerRuntimeLibSyntaxCore.UnoptimizedAppend; - exports.Unknown = _glimmerRuntimeLibSyntaxCore.Unknown; - exports.StaticAttr = _glimmerRuntimeLibSyntaxCore.StaticAttr; - exports.DynamicAttr = _glimmerRuntimeLibSyntaxCore.DynamicAttr; - exports.ArgsSyntax = _glimmerRuntimeLibSyntaxCore.Args; - exports.NamedArgsSyntax = _glimmerRuntimeLibSyntaxCore.NamedArgs; - exports.PositionalArgsSyntax = _glimmerRuntimeLibSyntaxCore.PositionalArgs; - exports.RefSyntax = _glimmerRuntimeLibSyntaxCore.Ref; - exports.GetNamedParameterSyntax = _glimmerRuntimeLibSyntaxCore.GetArgument; - exports.GetSyntax = _glimmerRuntimeLibSyntaxCore.Get; - exports.ValueSyntax = _glimmerRuntimeLibSyntaxCore.Value; - exports.OpenElement = _glimmerRuntimeLibSyntaxCore.OpenElement; - exports.HelperSyntax = _glimmerRuntimeLibSyntaxCore.Helper; - exports.BlockSyntax = _glimmerRuntimeLibSyntaxCore.Block; - exports.OpenPrimitiveElementSyntax = _glimmerRuntimeLibSyntaxCore.OpenPrimitiveElement; - exports.CloseElementSyntax = _glimmerRuntimeLibSyntaxCore.CloseElement; - exports.OpcodeBuilderDSL = _glimmerRuntimeLibCompiledOpcodesBuilder.default; - exports.Compiler = _glimmerRuntimeLibCompiler.default; - exports.Compilable = _glimmerRuntimeLibCompiler.Compilable; - exports.CompileIntoList = _glimmerRuntimeLibCompiler.CompileIntoList; - exports.compileLayout = _glimmerRuntimeLibCompiler.compileLayout; - exports.ComponentBuilder = _glimmerRuntimeLibOpcodeBuilder.ComponentBuilder; - exports.StaticDefinition = _glimmerRuntimeLibOpcodeBuilder.StaticDefinition; - exports.DynamicDefinition = _glimmerRuntimeLibOpcodeBuilder.DynamicDefinition; - exports.Block = _glimmerRuntimeLibCompiledBlocks.Block; - exports.CompiledBlock = _glimmerRuntimeLibCompiledBlocks.CompiledBlock; - exports.Layout = _glimmerRuntimeLibCompiledBlocks.Layout; - exports.InlineBlock = _glimmerRuntimeLibCompiledBlocks.InlineBlock; - exports.EntryPoint = _glimmerRuntimeLibCompiledBlocks.EntryPoint; - exports.IAttributeManager = _glimmerRuntimeLibDomAttributeManagers.AttributeManager; - exports.AttributeManager = _glimmerRuntimeLibDomAttributeManagers.AttributeManager; - exports.PropertyManager = _glimmerRuntimeLibDomAttributeManagers.PropertyManager; - exports.INPUT_VALUE_PROPERTY_MANAGER = _glimmerRuntimeLibDomAttributeManagers.INPUT_VALUE_PROPERTY_MANAGER; - exports.defaultManagers = _glimmerRuntimeLibDomAttributeManagers.defaultManagers; - exports.defaultAttributeManagers = _glimmerRuntimeLibDomAttributeManagers.defaultAttributeManagers; - exports.defaultPropertyManagers = _glimmerRuntimeLibDomAttributeManagers.defaultPropertyManagers; - exports.readDOMAttr = _glimmerRuntimeLibDomAttributeManagers.readDOMAttr; - exports.normalizeTextValue = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue; - exports.CompiledExpression = _glimmerRuntimeLibCompiledExpressions.CompiledExpression; - exports.CompiledArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs; - exports.CompiledNamedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs; - exports.CompiledPositionalArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs; - exports.EvaluatedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs; - exports.EvaluatedNamedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedNamedArgs; - exports.EvaluatedPositionalArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedPositionalArgs; - exports.FunctionExpression = _glimmerRuntimeLibCompiledExpressionsFunction.FunctionExpression; - exports.getDynamicVar = _glimmerRuntimeLibHelpersGetDynamicVar.default; - exports.WithDynamicVarsSyntax = _glimmerRuntimeLibSyntaxBuiltinsWithDynamicVars.default; - exports.InElementSyntax = _glimmerRuntimeLibSyntaxBuiltinsInElement.default; - exports.VM = _glimmerRuntimeLibVm.PublicVM; - exports.UpdatingVM = _glimmerRuntimeLibVm.UpdatingVM; - exports.RenderResult = _glimmerRuntimeLibVm.RenderResult; - exports.SafeString = _glimmerRuntimeLibUpsert.SafeString; - exports.isSafeString = _glimmerRuntimeLibUpsert.isSafeString; - exports.Scope = _glimmerRuntimeLibEnvironment.Scope; - exports.Environment = _glimmerRuntimeLibEnvironment.default; - exports.Helper = _glimmerRuntimeLibEnvironment.Helper; - exports.ParsedStatement = _glimmerRuntimeLibEnvironment.ParsedStatement; - exports.DynamicScope = _glimmerRuntimeLibEnvironment.DynamicScope; - exports.PartialDefinition = _glimmerRuntimeLibPartial.PartialDefinition; - exports.Component = _glimmerRuntimeLibComponentInterfaces.Component; - exports.ComponentClass = _glimmerRuntimeLibComponentInterfaces.ComponentClass; - exports.ComponentManager = _glimmerRuntimeLibComponentInterfaces.ComponentManager; - exports.ComponentDefinition = _glimmerRuntimeLibComponentInterfaces.ComponentDefinition; - exports.ComponentLayoutBuilder = _glimmerRuntimeLibComponentInterfaces.ComponentLayoutBuilder; - exports.ComponentAttrsBuilder = _glimmerRuntimeLibComponentInterfaces.ComponentAttrsBuilder; - exports.isComponentDefinition = _glimmerRuntimeLibComponentInterfaces.isComponentDefinition; - exports.ModifierManager = _glimmerRuntimeLibModifierInterfaces.ModifierManager; - exports.DOMChanges = _glimmerRuntimeLibDomHelper.default; - exports.IDOMChanges = _glimmerRuntimeLibDomHelper.DOMChanges; - exports.DOMTreeConstruction = _glimmerRuntimeLibDomHelper.DOMTreeConstruction; - exports.isWhitespace = _glimmerRuntimeLibDomHelper.isWhitespace; - exports.insertHTMLBefore = _glimmerRuntimeLibDomHelper.insertHTMLBefore; - exports.Simple = _glimmerRuntimeLibDomInterfaces; - exports.ElementStack = _glimmerRuntimeLibBuilder.ElementStack; - exports.ElementOperations = _glimmerRuntimeLibBuilder.ElementOperations; - exports.Bounds = _glimmerRuntimeLibBounds.default; - exports.ConcreteBounds = _glimmerRuntimeLibBounds.ConcreteBounds; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFDZSxnQkFBZ0IsNEJBQTdCLFNBQVM7VUFDSSxlQUFlLDRCQUE1QixTQUFTO1VBQ0ssZ0JBQWdCLDRCQUE5QixVQUFVO1VBQ0csZUFBZSw0QkFBNUIsU0FBUztVQUNULDBCQUEwQiw0QkFBMUIsMEJBQTBCO1VBQzFCLFlBQVksNEJBQVosWUFBWTtVQ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WFsRGVmaW5pdGlvblxufSBmcm9tICcuL2xpYi9wYXJ0aWFsJztcblxuZXhwb3J0IHtcbiAgQ29tcG9uZW50LFxuICBDb21wb25lbnRDbGFzcyxcbiAgQ29tcG9uZW50TWFuYWdlcixcbiAgQ29tcG9uZW50RGVmaW5pdGlvbixcbiAgQ29tcG9uZW50TGF5b3V0QnVpbGRlcixcbiAgQ29tcG9uZW50QXR0cnNCdWlsZGVyLFxuICBpc0NvbXBvbmVudERlZmluaXRpb25cbn0gZnJvbSAnLi9saWIvY29tcG9uZW50L2ludGVyZmFjZXMnO1xuXG5leHBvcnQge1xuICBNb2RpZmllck1hbmFnZXJcbn0gZnJvbSAnLi9saWIvbW9kaWZpZXIvaW50ZXJmYWNlcyc7XG5cbmV4cG9ydCB7IGRlZmF1bHQgYXMgRE9NQ2hhbmdlcywgRE9NQ2hhbmdlcyBhcyBJRE9NQ2hhbmdlcywgRE9NVHJlZUNvbnN0cnVjdGlvbiwgaXNXaGl0ZXNwYWNlLCBpbnNlcnRIVE1MQmVmb3JlIH0gZnJvbSAnLi9saWIvZG9tL2hlbHBlcic7XG5pbXBvcnQgICogYXMgU2ltcGxlIGZyb20gJy4vbGliL2RvbS9pbnRlcmZhY2VzJztcbmV4cG9ydCB7IFNpbXBsZSB9O1xuZXhwb3J0IHsgRWxlbWVudFN0YWNrLCBFbGVtZW50T3BlcmF0aW9ucyB9IGZyb20gJy4vbGliL2J1aWxkZXInO1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBCb3VuZHMsIENvbmNyZXRlQm91bmRzIH0gZnJvbSAnLi9saWIvYm91bmRzJztcbiJdfQ== -enifed("glimmer-runtime/lib/bounds", ["exports"], function (exports) { - "use strict"; - - exports.bounds = bounds; - exports.single = single; - exports.move = move; - exports.clear = clear; - var Cursor = function Cursor(element, nextSibling) { - this.element = element; - this.nextSibling = nextSibling; - }; + return multiArrayMacro(args, function (dependentKeys) { + var _this2 = this; - exports.Cursor = Cursor; + var uniq = _emberRuntimeSystemNative_array.A(); - var RealDOMBounds = (function () { - function RealDOMBounds(bounds) { - this.bounds = bounds; + dependentKeys.forEach(function (dependentKey) { + var value = _emberMetal.get(_this2, dependentKey); + if (_emberRuntimeUtils.isArray(value)) { + value.forEach(function (item) { + if (uniq.indexOf(item) === -1) { + uniq.push(item); + } + }); } + }); - RealDOMBounds.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; - - RealDOMBounds.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + return uniq; + }); + } - RealDOMBounds.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + /** + A computed property which returns a new array with all the unique + elements from an array, with uniqueness determined by specific key. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + uniqueFruits: Ember.computed.uniqBy('fruits', 'id') + }); + let hamster = Hamster.create({ + fruits: [ + { id: 1, 'banana' }, + { id: 2, 'grape' }, + { id: 3, 'peach' }, + { id: 1, 'banana' } + ] + }); + hamster.get('uniqueFruits'); // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }] + ``` + + @method uniqBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ - return RealDOMBounds; - })(); + function uniqBy(dependentKey, propertyKey) { + return _emberMetal.computed(dependentKey + '.[]', function () { + var uniq = _emberRuntimeSystemNative_array.A(); + var seen = new _emberUtils.EmptyObject(); + var list = _emberMetal.get(this, dependentKey); + if (_emberRuntimeUtils.isArray(list)) { + list.forEach(function (item) { + var guid = _emberUtils.guidFor(_emberMetal.get(item, propertyKey)); + if (!(guid in seen)) { + seen[guid] = true; + uniq.push(item); + } + }); + } + return uniq; + }).readOnly(); + } - exports.RealDOMBounds = RealDOMBounds; + /** + Alias for [Ember.computed.uniq](/api/#method_computed_uniq). + + @method union + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ + var union = uniq; - var ConcreteBounds = (function () { - function ConcreteBounds(parentNode, first, last) { - this.parentNode = parentNode; - this.first = first; - this.last = last; - } + exports.union = union; + /** + A computed property which returns a new array with all the duplicated + elements from two or more dependent arrays. + + Example + + ```javascript + let obj = Ember.Object.extend({ + friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') + }).create({ + adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], + charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'] + }); + + obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] + ``` + + @method intersect + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + duplicated elements from the dependent arrays + @public + */ - ConcreteBounds.prototype.parentElement = function parentElement() { - return this.parentNode; - }; + function intersect() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - ConcreteBounds.prototype.firstNode = function firstNode() { - return this.first; - }; + return multiArrayMacro(args, function (dependentKeys) { + var _this3 = this; - ConcreteBounds.prototype.lastNode = function lastNode() { - return this.last; - }; + var arrays = dependentKeys.map(function (dependentKey) { + var array = _emberMetal.get(_this3, dependentKey); - return ConcreteBounds; - })(); + return _emberRuntimeUtils.isArray(array) ? array : []; + }); - exports.ConcreteBounds = ConcreteBounds; + var results = arrays.pop().filter(function (candidate) { + for (var i = 0; i < arrays.length; i++) { + var found = false; + var array = arrays[i]; + for (var j = 0; j < array.length; j++) { + if (array[j] === candidate) { + found = true; + break; + } + } - var SingleNodeBounds = (function () { - function SingleNodeBounds(parentNode, node) { - this.parentNode = parentNode; - this.node = node; + if (found === false) { + return false; + } } - SingleNodeBounds.prototype.parentElement = function parentElement() { - return this.parentNode; - }; + return true; + }); - SingleNodeBounds.prototype.firstNode = function firstNode() { - return this.node; - }; + return _emberRuntimeSystemNative_array.A(results); + }); + } - SingleNodeBounds.prototype.lastNode = function lastNode() { - return this.node; - }; + /** + A computed property which returns a new array with all the + properties from the first dependent array that are not in the second + dependent array. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + likes: ['banana', 'grape', 'kale'], + wants: Ember.computed.setDiff('likes', 'fruits') + }); + + let hamster = Hamster.create({ + fruits: [ + 'grape', + 'kale', + ] + }); + + hamster.get('wants'); // ['banana'] + ``` + + @method setDiff + @for Ember.computed + @param {String} setAProperty + @param {String} setBProperty + @return {Ember.ComputedProperty} computes a new array with all the + items from the first dependent array that are not in the second + dependent array + @public + */ - return SingleNodeBounds; - })(); + function setDiff(setAProperty, setBProperty) { + if (arguments.length !== 2) { + throw new _emberMetal.Error('setDiff requires exactly two dependent arrays.'); + } - exports.SingleNodeBounds = SingleNodeBounds; + return _emberMetal.computed(setAProperty + '.[]', setBProperty + '.[]', function () { + var setA = this.get(setAProperty); + var setB = this.get(setBProperty); - function bounds(parent, first, last) { - return new ConcreteBounds(parent, first, last); - } + if (!_emberRuntimeUtils.isArray(setA)) { + return _emberRuntimeSystemNative_array.A(); + } + if (!_emberRuntimeUtils.isArray(setB)) { + return _emberRuntimeSystemNative_array.A(setA); + } - function single(parent, node) { - return new SingleNodeBounds(parent, node); - } + return setA.filter(function (x) { + return setB.indexOf(x) === -1; + }); + }).readOnly(); + } - function move(bounds, reference) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var node = first; - while (node) { - var next = node.nextSibling; - parent.insertBefore(node, reference); - if (node === last) return next; - node = next; - } - return null; - } + /** + A computed property that returns the array of values + for the provided dependent properties. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + clothes: Ember.computed.collect('hat', 'shirt') + }); + + let hamster = Hamster.create(); + + hamster.get('clothes'); // [null, null] + hamster.set('hat', 'Camp Hat'); + hamster.set('shirt', 'Camp Shirt'); + hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] + ``` + + @method collect + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which maps + values of all passed in properties to an array. + @public + */ - function clear(bounds) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var node = first; - while (node) { - var next = node.nextSibling; - parent.removeChild(node); - if (node === last) return next; - node = next; - } - return null; + function collect() { + for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + dependentKeys[_key3] = arguments[_key3]; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvYm91bmRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O1FBVUEsTUFBQSxHQUNFLFNBREYsTUFBQSxDQUNxQixPQUF1QixFQUFTLFdBQXdCLEVBQUE7QUFBeEQsWUFBQSxDQUFBLE9BQU8sR0FBUCxPQUFPLENBQWdCO0FBQVMsWUFBQSxDQUFBLFdBQVcsR0FBWCxXQUFXLENBQWE7S0FBSTs7OztRQU9qRixhQUFBO0FBQ0UsaUJBREYsYUFBQSxDQUNzQixNQUFjLEVBQUE7QUFBZCxnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQVE7U0FBSTs7QUFEeEMscUJBQUEsV0FHRSxhQUFhLEdBQUEseUJBQUE7QUFBSyxtQkFBTyxJQUFJLENBQUMsTUFBTSxDQUFDLGFBQWEsRUFBYSxDQUFDO1NBQUU7O0FBSHBFLHFCQUFBLFdBSUUsU0FBUyxHQUFBLHFCQUFBO0FBQUssbUJBQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxTQUFTLEVBQVUsQ0FBQztTQUFFOztBQUp6RCxxQkFBQSxXQUtFLFFBQVEsR0FBQSxvQkFBQTtBQUFLLG1CQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsUUFBUSxFQUFVLENBQUM7U0FBRTs7ZUFMdkQsYUFBQTs7Ozs7UUFRQSxjQUFBO0FBQ0UsaUJBREYsY0FBQSxDQUNxQixVQUEwQixFQUFVLEtBQWtC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wbGUuTm9kZSB7XG4gIGxldCBwYXJlbnQgPSBib3VuZHMucGFyZW50RWxlbWVudCgpO1xuICBsZXQgZmlyc3QgPSBib3VuZHMuZmlyc3ROb2RlKCk7XG4gIGxldCBsYXN0ID0gYm91bmRzLmxhc3ROb2RlKCk7XG5cbiAgbGV0IG5vZGUgPSBmaXJzdDtcblxuICB3aGlsZSAobm9kZSkge1xuICAgIGxldCBuZXh0ID0gbm9kZS5uZXh0U2libGluZztcbiAgICBwYXJlbnQucmVtb3ZlQ2hpbGQobm9kZSk7XG4gICAgaWYgKG5vZGUgPT09IGxhc3QpIHJldHVybiBuZXh0O1xuICAgIG5vZGUgPSBuZXh0O1xuICB9XG5cbiAgcmV0dXJuIG51bGw7XG59XG4iXX0= -enifed('glimmer-runtime/lib/builder', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-util', 'glimmer-runtime/lib/compiled/opcodes/dom'], function (exports, _glimmerRuntimeLibBounds, _glimmerUtil, _glimmerRuntimeLibCompiledOpcodesDom) { - 'use strict'; - var First = (function () { - function First(node) { - this.node = node; + return multiArrayMacro(dependentKeys, function () { + var properties = _emberMetal.getProperties(this, dependentKeys); + var res = _emberRuntimeSystemNative_array.A(); + for (var key in properties) { + if (properties.hasOwnProperty(key)) { + if (_emberMetal.isNone(properties[key])) { + res.push(null); + } else { + res.push(properties[key]); + } } + } + return res; + }); + } - First.prototype.firstNode = function firstNode() { - return this.node; - }; - - return First; - })(); - - var Last = (function () { - function Last(node) { - this.node = node; + /** + A computed property which returns a new array with all the + properties from the first dependent array sorted based on a property + or sort function. + + The callback method you provide should have the following signature: + + ```javascript + function(itemA, itemB); + ``` + + - `itemA` the first item to compare. + - `itemB` the second item to compare. + + This function should return negative number (e.g. `-1`) when `itemA` should come before + `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after + `itemB`. If the `itemA` and `itemB` are equal this function should return `0`. + + Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or + `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`. + + Example + + ```javascript + let ToDoList = Ember.Object.extend({ + // using standard ascending sort + todosSorting: ['name'], + sortedTodos: Ember.computed.sort('todos', 'todosSorting'), + + // using descending sort + todosSortingDesc: ['name:desc'], + sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), + + // using a custom sort function + priorityTodos: Ember.computed.sort('todos', function(a, b){ + if (a.priority > b.priority) { + return 1; + } else if (a.priority < b.priority) { + return -1; } + + return 0; + }) + }); + + let todoList = ToDoList.create({todos: [ + { name: 'Unit Test', priority: 2 }, + { name: 'Documentation', priority: 3 }, + { name: 'Release', priority: 1 } + ]}); + + todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }] + todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }] + todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }] + ``` + + @method sort + @for Ember.computed + @param {String} itemsKey + @param {String or Function} sortDefinition a dependent key to an + array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting + @return {Ember.ComputedProperty} computes a new sorted array based + on the sort property array or callback function + @public + */ - Last.prototype.lastNode = function lastNode() { - return this.node; - }; + function sort(itemsKey, sortDefinition) { + _emberMetal.assert('Ember.computed.sort requires two arguments: an array key to sort and ' + 'either a sort properties key or sort function', arguments.length === 2); - return Last; - })(); + if (typeof sortDefinition === 'function') { + return customSort(itemsKey, sortDefinition); + } else { + return propertySort(itemsKey, sortDefinition); + } + } - var Fragment = (function () { - function Fragment(bounds) { - this.bounds = bounds; - } + function customSort(itemsKey, comparator) { + return arrayMacro(itemsKey, function (value) { + var _this4 = this; - Fragment.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + return value.slice().sort(function (x, y) { + return comparator.call(_this4, x, y); + }); + }); + } - Fragment.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + // This one needs to dynamically set up and tear down observers on the itemsKey + // depending on the sortProperties + function propertySort(itemsKey, sortPropertiesKey) { + var cp = new _emberMetal.ComputedProperty(function (key) { + var _this5 = this; - Fragment.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + var itemsKeyIsAtThis = itemsKey === '@this'; + var sortProperties = _emberMetal.get(this, sortPropertiesKey); - Fragment.prototype.update = function update(bounds) { - this.bounds = bounds; - }; + _emberMetal.assert('The sort definition for \'' + key + '\' on ' + this + ' must be a function or an array of strings', _emberRuntimeUtils.isArray(sortProperties) && sortProperties.every(function (s) { + return typeof s === 'string'; + })); - return Fragment; - })(); + var normalizedSortProperties = normalizeSortProperties(sortProperties); - exports.Fragment = Fragment; - - var ElementStack = (function () { - function ElementStack(env, parentNode, nextSibling) { - this.constructing = null; - this.operations = null; - this.elementStack = new _glimmerUtil.Stack(); - this.nextSiblingStack = new _glimmerUtil.Stack(); - this.blockStack = new _glimmerUtil.Stack(); - this.env = env; - this.dom = env.getAppendOperations(); - this.updateOperations = env.getDOM(); - this.element = parentNode; - this.nextSibling = nextSibling; - this.defaultOperations = new _glimmerRuntimeLibCompiledOpcodesDom.SimpleElementOperations(env); - this.elementStack.push(this.element); - this.nextSiblingStack.push(this.nextSibling); - } - - ElementStack.forInitialRender = function forInitialRender(env, parentNode, nextSibling) { - return new ElementStack(env, parentNode, nextSibling); - }; + // Add/remove property observers as required. + var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetal.WeakMap()); + var activeObservers = activeObserversMap.get(this); - ElementStack.resume = function resume(env, tracker, nextSibling) { - var parentNode = tracker.parentElement(); - var stack = new ElementStack(env, parentNode, nextSibling); - stack.pushBlockTracker(tracker); - return stack; - }; + if (activeObservers) { + activeObservers.forEach(function (args) { + return _emberMetal.removeObserver.apply(undefined, args); + }); + } - ElementStack.prototype.block = function block() { - return this.blockStack.current; - }; + function sortPropertyDidChange() { + this.notifyPropertyChange(key); + } - ElementStack.prototype.popElement = function popElement() { - var elementStack = this.elementStack; - var nextSiblingStack = this.nextSiblingStack; + activeObservers = normalizedSortProperties.map(function (_ref) { + var prop = _ref[0]; - var topElement = elementStack.pop(); - nextSiblingStack.pop(); - this.element = elementStack.current; - this.nextSibling = nextSiblingStack.current; - return topElement; - }; + var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; + var args = [_this5, path, sortPropertyDidChange]; + _emberMetal.addObserver.apply(undefined, args); + return args; + }); - ElementStack.prototype.pushSimpleBlock = function pushSimpleBlock() { - var tracker = new SimpleBlockTracker(this.element); - this.pushBlockTracker(tracker); - return tracker; - }; + activeObserversMap.set(this, activeObservers); - ElementStack.prototype.pushUpdatableBlock = function pushUpdatableBlock() { - var tracker = new UpdatableBlockTracker(this.element); - this.pushBlockTracker(tracker); - return tracker; - }; + // Sort and return the array. + var items = itemsKeyIsAtThis ? this : _emberMetal.get(this, itemsKey); - ElementStack.prototype.pushBlockTracker = function pushBlockTracker(tracker) { - var isRemote = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + if (_emberRuntimeUtils.isArray(items)) { + return sortByNormalizedSortProperties(items, normalizedSortProperties); + } else { + return _emberRuntimeSystemNative_array.A(); + } + }); - var current = this.blockStack.current; - if (current !== null) { - current.newDestroyable(tracker); - if (!isRemote) { - current.newBounds(tracker); - } - } - this.blockStack.push(tracker); - return tracker; - }; + cp._activeObserverMap = undefined; - ElementStack.prototype.pushBlockList = function pushBlockList(list) { - var tracker = new BlockListTracker(this.element, list); - var current = this.blockStack.current; - if (current !== null) { - current.newDestroyable(tracker); - current.newBounds(tracker); - } - this.blockStack.push(tracker); - return tracker; - }; + return cp.property(sortPropertiesKey + '.[]').readOnly(); + } - ElementStack.prototype.popBlock = function popBlock() { - this.blockStack.current.finalize(this); - return this.blockStack.pop(); - }; + function normalizeSortProperties(sortProperties) { + return sortProperties.map(function (p) { + var _p$split = p.split(':'); - ElementStack.prototype.openElement = function openElement(tag) { - var operations = arguments.length <= 1 || arguments[1] === undefined ? this.defaultOperations : arguments[1]; + var prop = _p$split[0]; + var direction = _p$split[1]; - var element = this.dom.createElement(tag, this.element); - this.constructing = element; - this.operations = operations; - return element; - }; + direction = direction || 'asc'; - ElementStack.prototype.flushElement = function flushElement() { - var parent = this.element; - var element = this.constructing; - this.dom.insertBefore(parent, element, this.nextSibling); - this.constructing = null; - this.operations = null; - this.pushElement(element); - this.blockStack.current.openElement(element); - }; + return [prop, direction]; + }); + } - ElementStack.prototype.pushRemoteElement = function pushRemoteElement(element) { - this.pushElement(element); - var tracker = new RemoteBlockTracker(element); - this.pushBlockTracker(tracker, true); - }; + 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]; - ElementStack.prototype.popRemoteElement = function popRemoteElement() { - this.popBlock(); - this.popElement(); - }; + var result = _emberRuntimeCompare.default(_emberMetal.get(itemA, prop), _emberMetal.get(itemB, prop)); + if (result !== 0) { + return direction === 'desc' ? -1 * result : result; + } + } - ElementStack.prototype.pushElement = function pushElement(element) { - this.element = element; - this.elementStack.push(element); - this.nextSibling = null; - this.nextSiblingStack.push(null); - }; + return 0; + })); + } +}); +enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) { + 'use strict'; - ElementStack.prototype.newDestroyable = function newDestroyable(d) { - this.blockStack.current.newDestroyable(d); - }; + /** + @module ember + @submodule ember-runtime + */ - ElementStack.prototype.newBounds = function newBounds(bounds) { - this.blockStack.current.newBounds(bounds); - }; + /** + @class Controller + @namespace Ember + @extends Ember.Object + @uses Ember.ControllerMixin + @public + */ + var Controller = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsController.default); - ElementStack.prototype.appendText = function appendText(string) { - var dom = this.dom; + _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions(Controller); - var text = dom.createTextNode(string); - dom.insertBefore(this.element, text, this.nextSibling); - this.blockStack.current.newNode(text); - return text; - }; + function controllerInjectionHelper(factory) { + _emberMetal.assert('Defining an injected controller property on a ' + 'non-controller is not allowed.', _emberRuntimeMixinsController.default.detect(factory.PrototypeMixin)); + } - ElementStack.prototype.appendComment = function appendComment(string) { - var dom = this.dom; + /** + Creates a property that lazily looks up another controller in the container. + Can only be used when defining another controller. + + Example: + + ```javascript + App.PostController = Ember.Controller.extend({ + posts: Ember.inject.controller() + }); + ``` + + This example will create a `posts` property on the `post` controller that + looks up the `posts` controller in the container, making it easy to + reference other controllers. This is functionally equivalent to: + + ```javascript + App.PostController = Ember.Controller.extend({ + needs: 'posts', + posts: Ember.computed.alias('controllers.posts') + }); + ``` + + @method controller + @since 1.10.0 + @for Ember.inject + @param {String} name (optional) name of the controller to inject, defaults + to the property's name + @return {Ember.InjectedProperty} injection descriptor instance + @public + */ + _emberRuntimeInject.createInjectionHelper('controller', controllerInjectionHelper); - var comment = dom.createComment(string); - dom.insertBefore(this.element, comment, this.nextSibling); - this.blockStack.current.newNode(comment); - return comment; - }; + exports.default = Controller; +}); +enifed('ember-runtime/copy', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) { + 'use strict'; - ElementStack.prototype.setStaticAttribute = function setStaticAttribute(name, value) { - this.operations.addStaticAttribute(this.constructing, name, value); - }; + exports.default = copy; - ElementStack.prototype.setStaticAttributeNS = function setStaticAttributeNS(namespace, name, value) { - this.operations.addStaticAttributeNS(this.constructing, namespace, name, value); - }; + function _copy(obj, deep, seen, copies) { + var ret = undefined, + loc = undefined, + key = undefined; - ElementStack.prototype.setDynamicAttribute = function setDynamicAttribute(name, reference, isTrusting) { - this.operations.addDynamicAttribute(this.constructing, name, reference, isTrusting); - }; + // primitive data types are immutable, just return them. + if (typeof obj !== 'object' || obj === null) { + return obj; + } - ElementStack.prototype.setDynamicAttributeNS = function setDynamicAttributeNS(namespace, name, reference, isTrusting) { - this.operations.addDynamicAttributeNS(this.constructing, namespace, name, reference, isTrusting); - }; + // avoid cyclical loops + if (deep && (loc = seen.indexOf(obj)) >= 0) { + return copies[loc]; + } - ElementStack.prototype.closeElement = function closeElement() { - this.blockStack.current.closeElement(); - this.popElement(); - }; + _emberMetal.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof _emberRuntimeSystemObject.default) || _emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)); - return ElementStack; - })(); + // IMPORTANT: this specific test will detect a native array only. Any other + // object will need to implement Copyable. + if (Array.isArray(obj)) { + ret = obj.slice(); - exports.ElementStack = ElementStack; + if (deep) { + loc = ret.length; - var SimpleBlockTracker = (function () { - function SimpleBlockTracker(parent) { - this.parent = parent; - this.first = null; - this.last = null; - this.destroyables = null; - this.nesting = 0; + while (--loc >= 0) { + ret[loc] = _copy(ret[loc], deep, seen, copies); } + } + } else if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { + ret = obj.copy(deep, seen, copies); + } else if (obj instanceof Date) { + ret = new Date(obj.getTime()); + } else { + ret = {}; - SimpleBlockTracker.prototype.destroy = function destroy() { - var destroyables = this.destroyables; + for (key in obj) { + // support Null prototype + if (!Object.prototype.hasOwnProperty.call(obj, key)) { + continue; + } - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - destroyables[i].destroy(); - } - } - }; + // Prevents browsers that don't respect non-enumerability from + // copying internal Ember properties + if (key.substring(0, 2) === '__') { + continue; + } - SimpleBlockTracker.prototype.parentElement = function parentElement() { - return this.parent; - }; + ret[key] = deep ? _copy(obj[key], deep, seen, copies) : obj[key]; + } + } - SimpleBlockTracker.prototype.firstNode = function firstNode() { - return this.first && this.first.firstNode(); - }; + if (deep) { + seen.push(obj); + copies.push(ret); + } - SimpleBlockTracker.prototype.lastNode = function lastNode() { - return this.last && this.last.lastNode(); - }; + return ret; + } - SimpleBlockTracker.prototype.openElement = function openElement(element) { - this.newNode(element); - this.nesting++; - }; + /** + Creates a shallow copy of the passed object. A deep copy of the object is + returned if the optional `deep` argument is `true`. + + If the passed object implements the `Ember.Copyable` interface, then this + function will delegate to the object's `copy()` method and return the + result. See `Ember.Copyable` for further details. + + For primitive values (which are immutable in JavaScript), the passed object + is simply returned. + + @method copy + @for Ember + @param {Object} obj The object to clone + @param {Boolean} [deep=false] If true, a deep copy of the object is made. + @return {Object} The copied object + @public + */ - SimpleBlockTracker.prototype.closeElement = function closeElement() { - this.nesting--; - }; + function copy(obj, deep) { + // fast paths + if ('object' !== typeof obj || obj === null) { + return obj; // can't copy primitives + } - SimpleBlockTracker.prototype.newNode = function newNode(node) { - if (this.nesting !== 0) return; - if (!this.first) { - this.first = new First(node); - } - this.last = new Last(node); - }; + if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { + return obj.copy(deep); + } - SimpleBlockTracker.prototype.newBounds = function newBounds(bounds) { - if (this.nesting !== 0) return; - if (!this.first) { - this.first = bounds; - } - this.last = bounds; - }; + return _copy(obj, deep, deep ? [] : null, deep ? [] : null); + } +}); +enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - SimpleBlockTracker.prototype.newDestroyable = function newDestroyable(d) { - this.destroyables = this.destroyables || []; - this.destroyables.push(d); - }; + 'use strict'; - SimpleBlockTracker.prototype.finalize = function finalize(stack) { - if (!this.first) { - stack.appendComment(''); - } - }; + var a_slice = Array.prototype.slice; + var FunctionPrototype = Function.prototype; - return SimpleBlockTracker; - })(); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + /** + The `property` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + `true`, which is the default. + Computed properties allow you to treat a function like a property: + ```javascript + MyApp.President = Ember.Object.extend({ + firstName: '', + lastName: '', + fullName: function() { + return this.get('firstName') + ' ' + this.get('lastName'); + }.property() // Call this flag to mark the function as a property + }); + let president = MyApp.President.create({ + firstName: 'Barack', + lastName: 'Obama' + }); + president.get('fullName'); // 'Barack Obama' + ``` + Treating a function like a property is useful because they can work with + bindings, just like any other property. + Many computed properties have dependencies on other properties. For + example, in the above example, the `fullName` property depends on + `firstName` and `lastName` to determine its value. You can tell Ember + about these dependencies like this: + ```javascript + MyApp.President = Ember.Object.extend({ + firstName: '', + lastName: '', + fullName: function() { + return this.get('firstName') + ' ' + this.get('lastName'); + // Tell Ember.js that this computed property depends on firstName + // and lastName + }.property('firstName', 'lastName') + }); + ``` + Make sure you list these dependencies so Ember knows when to update + bindings that connect to a computed property. Changing a dependency + will not immediately trigger an update of the computed property, but + will instead clear the cache so that it is updated when the next `get` + is called on the property. + See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/classes/Ember.computed.html). + @method property + @for Function + @public + */ + FunctionPrototype.property = function () { + var ret = _emberMetal.computed(this); + // ComputedProperty.prototype.property expands properties; no need for us to + // do so here. + return ret.property.apply(ret, arguments); + }; - exports.SimpleBlockTracker = SimpleBlockTracker; + /** + The `observes` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + true, which is the default. + You can observe property changes simply by adding the `observes` + call to the end of your method declarations in classes that you write. + For example: + ```javascript + Ember.Object.extend({ + valueObserver: function() { + // Executes whenever the "value" property changes + }.observes('value') + }); + ``` + In the future this method may become asynchronous. + See `Ember.observer`. + @method observes + @for Function + @public + */ + FunctionPrototype.observes = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - var RemoteBlockTracker = (function (_SimpleBlockTracker) { - babelHelpers.inherits(RemoteBlockTracker, _SimpleBlockTracker); + args.push(this); + return _emberMetal.observer.apply(this, args); + }; - function RemoteBlockTracker() { - _SimpleBlockTracker.apply(this, arguments); + FunctionPrototype._observesImmediately = function () { + _emberMetal.assert('Immediate observers must observe internal properties only, ' + 'not properties on other objects.', function checkIsInternalProperty() { + for (var i = 0; i < arguments.length; i++) { + if (arguments[i].indexOf('.') !== -1) { + return false; + } } + return true; + }); - RemoteBlockTracker.prototype.destroy = function destroy() { - _SimpleBlockTracker.prototype.destroy.call(this); - _glimmerRuntimeLibBounds.clear(this); - }; + // observes handles property expansion + return this.observes.apply(this, arguments); + }; + /** + The `observesImmediately` extension of Javascript's Function prototype is + available when `EmberENV.EXTEND_PROTOTYPES` or + `EmberENV.EXTEND_PROTOTYPES.Function` is true, which is the default. + You can observe property changes simply by adding the `observesImmediately` + call to the end of your method declarations in classes that you write. + For example: + ```javascript + Ember.Object.extend({ + valueObserver: function() { + // Executes immediately after the "value" property changes + }.observesImmediately('value') + }); + ``` + In the future, `observes` may become asynchronous. In this event, + `observesImmediately` will maintain the synchronous behavior. + See `Ember.immediateObserver`. + @method observesImmediately + @for Function + @deprecated + @private + */ + FunctionPrototype.observesImmediately = _emberMetal.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately); - return RemoteBlockTracker; - })(SimpleBlockTracker); + /** + The `on` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + true, which is the default. + You can listen for events simply by adding the `on` call to the end of + your method declarations in classes or mixins that you write. For example: + ```javascript + Ember.Mixin.create({ + doSomethingWithElement: function() { + // Executes whenever the "didInsertElement" event fires + }.on('didInsertElement') + }); + ``` + See `Ember.on`. + @method on + @for Function + @public + */ + FunctionPrototype.on = function () { + var events = a_slice.call(arguments); + this.__ember_listens__ = events; - var UpdatableBlockTracker = (function (_SimpleBlockTracker2) { - babelHelpers.inherits(UpdatableBlockTracker, _SimpleBlockTracker2); + return this; + }; + } +}); +enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal'], function (exports, _rsvp, _emberMetal) { + 'use strict'; - function UpdatableBlockTracker() { - _SimpleBlockTracker2.apply(this, arguments); - } + exports.onerrorDefault = onerrorDefault; - UpdatableBlockTracker.prototype.reset = function reset(env) { - var destroyables = this.destroyables; + var backburner = _emberMetal.run.backburner; + _emberMetal.run._addQueue('rsvpAfter', 'destroy'); - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - env.didDestroy(destroyables[i]); - } - } - var nextSibling = _glimmerRuntimeLibBounds.clear(this); - this.destroyables = null; - this.first = null; - this.last = null; - return nextSibling; - }; + _rsvp.configure('async', function (callback, promise) { + backburner.schedule('actions', null, callback, promise); + }); - return UpdatableBlockTracker; - })(SimpleBlockTracker); + _rsvp.configure('after', function (cb) { + backburner.schedule('rsvpAfter', null, cb); + }); - exports.UpdatableBlockTracker = UpdatableBlockTracker; + _rsvp.on('error', onerrorDefault); - var BlockListTracker = (function () { - function BlockListTracker(parent, boundList) { - this.parent = parent; - this.boundList = boundList; - this.parent = parent; - this.boundList = boundList; - } + function onerrorDefault(reason) { + var error = errorFor(reason); + if (error) { + _emberMetal.dispatchError(error); + } + } - BlockListTracker.prototype.destroy = function destroy() { - this.boundList.forEachNode(function (node) { - return node.destroy(); - }); - }; + function errorFor(reason) { + if (!reason) return; - BlockListTracker.prototype.parentElement = function parentElement() { - return this.parent; - }; + if (reason.errorThrown) { + return unwrapErrorThrown(reason); + } - BlockListTracker.prototype.firstNode = function firstNode() { - return this.boundList.head().firstNode(); - }; + if (reason.name === 'UnrecognizedURLError') { + _emberMetal.assert('The URL \'' + reason.message + '\' did not match any routes in your application', false); + return; + } - BlockListTracker.prototype.lastNode = function lastNode() { - return this.boundList.tail().lastNode(); - }; + if (reason.name === 'TransitionAborted') { + return; + } - BlockListTracker.prototype.openElement = function openElement(element) { - _glimmerUtil.assert(false, 'Cannot openElement directly inside a block list'); - }; + return reason; + } - BlockListTracker.prototype.closeElement = function closeElement() { - _glimmerUtil.assert(false, 'Cannot closeElement directly inside a block list'); - }; + function unwrapErrorThrown(reason) { + var error = reason.errorThrown; + if (typeof error === 'string') { + error = new Error(error); + } + Object.defineProperty(error, '__reason_with_error_thrown__', { + value: reason, + enumerable: false + }); + return error; + } - BlockListTracker.prototype.newNode = function newNode(node) { - _glimmerUtil.assert(false, 'Cannot create a new node directly inside a block list'); - }; + exports.default = _rsvp; +}); +enifed('ember-runtime/ext/string', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + /** + @module ember + @submodule ember-runtime + */ - BlockListTracker.prototype.newBounds = function newBounds(bounds) {}; + 'use strict'; - BlockListTracker.prototype.newDestroyable = function newDestroyable(d) {}; + var StringPrototype = String.prototype; - BlockListTracker.prototype.finalize = function finalize(stack) {}; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + /** + See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt). + @method fmt + @for String + @private + @deprecated + */ + StringPrototype.fmt = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - return BlockListTracker; - })(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvYnVpbGRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUE0QkEsS0FBQTtBQUNFLGlCQURGLEtBQUEsQ0FDc0IsSUFBVSxFQUFBO0FBQVYsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFNO1NBQU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dCBjbG9zZUVsZW1lbnQgZGlyZWN0bHkgaW5zaWRlIGEgYmxvY2sgbGlzdCcpO1xuICB9XG5cbiAgbmV3Tm9kZShub2RlOiBOb2RlKSB7XG4gICAgYXNzZXJ0KGZhbHNlLCAnQ2Fubm90IGNyZWF0ZSBhIG5ldyBub2RlIGRpcmVjdGx5IGluc2lkZSBhIGJsb2NrIGxpc3QnKTtcbiAgfVxuXG4gIG5ld0JvdW5kcyhib3VuZHM6IEJvdW5kcykge1xuICB9XG5cbiAgbmV3RGVzdHJveWFibGUoZDogRGVzdHJveWFibGUpIHtcbiAgfVxuXG4gIGZpbmFsaXplKHN0YWNrOiBFbGVtZW50U3RhY2spIHtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compat/inner-html-fix', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/dom/helper'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibDomHelper) { - 'use strict'; + return _emberRuntimeSystemString.fmt(this, args); + }; - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; - - var innerHTMLWrapper = { - colgroup: { depth: 2, before: '', after: '
    ' }, - table: { depth: 1, before: '', after: '
    ' }, - tbody: { depth: 2, before: '', after: '
    ' }, - tfoot: { depth: 2, before: '', after: '
    ' }, - thead: { depth: 2, before: '', after: '
    ' }, - tr: { depth: 3, before: '', after: '
    ' } - }; - // Patch: innerHTML Fix - // Browsers: IE9 - // Reason: IE9 don't allow us to set innerHTML on col, colgroup, frameset, - // html, style, table, tbody, tfoot, thead, title, tr. - // Fix: Wrap the innerHTML we are about to set in its parents, apply the - // wrapped innerHTML on a div, then move the unwrapped nodes into the - // target position. - - function domChanges(document, DOMChangesClass) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document)) { - return DOMChangesClass; - } - var div = document.createElement('div'); - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithInnerHTMLFix, _DOMChangesClass); - - function DOMChangesWithInnerHTMLFix() { - _DOMChangesClass.apply(this, arguments); - } + /** + See [Ember.String.w](/api/classes/Ember.String.html#method_w). + @method w + @for String + @private + */ + StringPrototype.w = function () { + return _emberRuntimeSystemString.w(this); + }; - DOMChangesWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null || html === '') { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - var parentTag = parent.tagName.toLowerCase(); - var wrapper = innerHTMLWrapper[parentTag]; - if (wrapper === undefined) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - return fixInnerHTML(parent, wrapper, div, html, nextSibling); - }; + /** + See [Ember.String.loc](/api/classes/Ember.String.html#method_loc). + @method loc + @for String + @private + */ + StringPrototype.loc = function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - return DOMChangesWithInnerHTMLFix; - })(DOMChangesClass); - } + return _emberRuntimeSystemString.loc(this, args); + }; - function treeConstruction(document, DOMTreeConstructionClass) { - if (!document) return DOMTreeConstructionClass; - if (!shouldApplyFix(document)) { - return DOMTreeConstructionClass; - } - var div = document.createElement('div'); - return (function (_DOMTreeConstructionClass) { - babelHelpers.inherits(DOMTreeConstructionWithInnerHTMLFix, _DOMTreeConstructionClass); + /** + See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize). + @method camelize + @for String + @private + */ + StringPrototype.camelize = function () { + return _emberRuntimeSystemString.camelize(this); + }; - function DOMTreeConstructionWithInnerHTMLFix() { - _DOMTreeConstructionClass.apply(this, arguments); - } + /** + See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize). + @method decamelize + @for String + @private + */ + StringPrototype.decamelize = function () { + return _emberRuntimeSystemString.decamelize(this); + }; - DOMTreeConstructionWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null || html === '') { - return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - var parentTag = parent.tagName.toLowerCase(); - var wrapper = innerHTMLWrapper[parentTag]; - if (wrapper === undefined) { - return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - return fixInnerHTML(parent, wrapper, div, html, reference); - }; + /** + See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize). + @method dasherize + @for String + @private + */ + StringPrototype.dasherize = function () { + return _emberRuntimeSystemString.dasherize(this); + }; - return DOMTreeConstructionWithInnerHTMLFix; - })(DOMTreeConstructionClass); - } + /** + See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore). + @method underscore + @for String + @private + */ + StringPrototype.underscore = function () { + return _emberRuntimeSystemString.underscore(this); + }; - function fixInnerHTML(parent, wrapper, div, html, reference) { - var wrappedHtml = wrapper.before + html + wrapper.after; - div.innerHTML = wrappedHtml; - var parentNode = div; - for (var i = 0; i < wrapper.depth; i++) { - parentNode = parentNode.childNodes[0]; - } + /** + See [Ember.String.classify](/api/classes/Ember.String.html#method_classify). + @method classify + @for String + @private + */ + StringPrototype.classify = function () { + return _emberRuntimeSystemString.classify(this); + }; - var _moveNodesBefore = _glimmerRuntimeLibDomHelper.moveNodesBefore(parentNode, parent, reference); + /** + See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize). + @method capitalize + @for String + @private + */ + StringPrototype.capitalize = function () { + return _emberRuntimeSystemString.capitalize(this); + }; + } +}); +enifed('ember-runtime/index', ['exports', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/system/object', 'ember-runtime/system/string', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/compare', 'ember-runtime/is-equal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/system/namespace', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeSystemObject, _emberRuntimeSystemString, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeCompare, _emberRuntimeIsEqual, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeSystemNamespace, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsObservable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeUtils, _emberRuntimeString_registry) { + /** + @module ember + @submodule ember-runtime + */ - var first = _moveNodesBefore[0]; - var last = _moveNodesBefore[1]; + 'use strict'; - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - function shouldApplyFix(document) { - var table = document.createElement('table'); - try { - table.innerHTML = ''; - } catch (e) {} finally { - if (table.childNodes.length !== 0) { - // It worked as expected, no fix required - return false; - } - } - return true; - } + exports.Object = _emberRuntimeSystemObject.default; + exports.FrameworkObject = _emberRuntimeSystemObject.FrameworkObject; + exports.String = _emberRuntimeSystemString.default; + exports.RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default; + exports.buildFakeRegistryWithDeprecations = _emberRuntimeMixinsRegistry_proxy.buildFakeRegistryWithDeprecations; + exports.ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default; + exports.copy = _emberRuntimeCopy.default; + exports.inject = _emberRuntimeInject.default; + exports.compare = _emberRuntimeCompare.default; + exports.isEqual = _emberRuntimeIsEqual.default; + exports.Array = _emberRuntimeMixinsArray.default; + exports.objectAt = _emberRuntimeMixinsArray.objectAt; + exports.isEmberArray = _emberRuntimeMixinsArray.isEmberArray; + exports.addArrayObserver = _emberRuntimeMixinsArray.addArrayObserver; + exports.removeArrayObserver = _emberRuntimeMixinsArray.removeArrayObserver; + exports.Comparable = _emberRuntimeMixinsComparable.default; + exports.Namespace = _emberRuntimeSystemNamespace.default; + exports.isNamespaceSearchDisabled = _emberRuntimeSystemNamespace.isSearchDisabled; + exports.setNamespaceSearchDisabled = _emberRuntimeSystemNamespace.setSearchDisabled; + exports.ArrayProxy = _emberRuntimeSystemArray_proxy.default; + exports.ObjectProxy = _emberRuntimeSystemObject_proxy.default; + exports.CoreObject = _emberRuntimeSystemCore_object.default; + exports.NativeArray = _emberRuntimeSystemNative_array.default; + exports.A = _emberRuntimeSystemNative_array.A; + exports.ActionHandler = _emberRuntimeMixinsAction_handler.default; + exports.deprecateUnderscoreActions = _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions; + exports.Copyable = _emberRuntimeMixinsCopyable.default; + exports.Enumerable = _emberRuntimeMixinsEnumerable.default; + exports.Freezable = _emberRuntimeMixinsFreezable.Freezable; + exports.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR; + exports._ProxyMixin = _emberRuntimeMixinsProxy.default; + exports.onLoad = _emberRuntimeSystemLazy_load.onLoad; + exports.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks; + exports._loaded = _emberRuntimeSystemLazy_load._loaded; + exports.Observable = _emberRuntimeMixinsObservable.default; + exports.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default; + exports.MutableArray = _emberRuntimeMixinsMutable_array.default; + exports.removeAt = _emberRuntimeMixinsMutable_array.removeAt; + exports.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default; + exports.Evented = _emberRuntimeMixinsEvented.default; + exports.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default; + exports.empty = _emberRuntimeComputedComputed_macros.empty; + exports.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty; + exports.none = _emberRuntimeComputedComputed_macros.none; + exports.not = _emberRuntimeComputedComputed_macros.not; + exports.bool = _emberRuntimeComputedComputed_macros.bool; + exports.match = _emberRuntimeComputedComputed_macros.match; + exports.equal = _emberRuntimeComputedComputed_macros.equal; + exports.gt = _emberRuntimeComputedComputed_macros.gt; + exports.gte = _emberRuntimeComputedComputed_macros.gte; + exports.lt = _emberRuntimeComputedComputed_macros.lt; + exports.lte = _emberRuntimeComputedComputed_macros.lte; + exports.oneWay = _emberRuntimeComputedComputed_macros.oneWay; + exports.readOnly = _emberRuntimeComputedComputed_macros.readOnly; + exports.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias; + exports.and = _emberRuntimeComputedComputed_macros.and; + exports.or = _emberRuntimeComputedComputed_macros.or; + exports.sum = _emberRuntimeComputedReduce_computed_macros.sum; + exports.min = _emberRuntimeComputedReduce_computed_macros.min; + exports.max = _emberRuntimeComputedReduce_computed_macros.max; + exports.map = _emberRuntimeComputedReduce_computed_macros.map; + exports.sort = _emberRuntimeComputedReduce_computed_macros.sort; + exports.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff; + exports.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy; + exports.filter = _emberRuntimeComputedReduce_computed_macros.filter; + exports.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy; + exports.uniq = _emberRuntimeComputedReduce_computed_macros.uniq; + exports.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy; + exports.union = _emberRuntimeComputedReduce_computed_macros.union; + exports.intersect = _emberRuntimeComputedReduce_computed_macros.intersect; + exports.collect = _emberRuntimeComputedReduce_computed_macros.collect; + exports.Controller = _emberRuntimeControllersController.default; + exports.ControllerMixin = _emberRuntimeMixinsController.default; + exports.Service = _emberRuntimeSystemService.default; + exports.RSVP = _emberRuntimeExtRsvp.default; + exports.onerrorDefault = _emberRuntimeExtRsvp.onerrorDefault; + // just for side effect of extending Ember.RSVP + exports.isArray = _emberRuntimeUtils.isArray; + exports.typeOf = _emberRuntimeUtils.typeOf; + exports.getStrings = _emberRuntimeString_registry.getStrings; + exports.setStrings = _emberRuntimeString_registry.setStrings; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L2lubmVyLWh0bWwtZml4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQVNBLFFBQUksZ0JBQWdCLEdBQUc7QUFDckIsZ0JBQVEsRUFBRSxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsTUFBTSxFQUFFLG1CQUFtQixFQUFFLEtBQUssRUFBRSxxQkFBcUIsRUFBRTtBQUNqRixhQUFLLEVBQUssRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFFLFVBQVUsRUFBRTtBQUM1RCxhQUFLLEVBQUssRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxnQkFBZ0IsRUFBRSxLQUFLLEVBQUUsa0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xFbGVtZW50LCBodG1sOiBzdHJpbmcsIHJlZmVyZW5jZTogTm9kZSk6IEJvdW5kcyB7XG4gIGxldCB3cmFwcGVkSHRtbCA9IHdyYXBwZXIuYmVmb3JlICsgaHRtbCArIHdyYXBwZXIuYWZ0ZXI7XG5cbiAgZGl2LmlubmVySFRNTCA9IHdyYXBwZWRIdG1sO1xuXG4gIGxldCBwYXJlbnROb2RlOiBOb2RlID0gZGl2O1xuXG4gIGZvciAobGV0IGk9MDsgaTx3cmFwcGVyLmRlcHRoOyBpKyspIHtcbiAgICBwYXJlbnROb2RlID0gcGFyZW50Tm9kZS5jaGlsZE5vZGVzWzBdO1xuICB9XG5cbiAgbGV0IFtmaXJzdCwgbGFzdF0gPSBtb3ZlTm9kZXNCZWZvcmUocGFyZW50Tm9kZSwgcGFyZW50LCByZWZlcmVuY2UpO1xuICByZXR1cm4gbmV3IENvbmNyZXRlQm91bmRzKHBhcmVudCwgZmlyc3QsIGxhc3QpO1xufVxuXG5mdW5jdGlvbiBzaG91bGRBcHBseUZpeChkb2N1bWVudCkge1xuICBsZXQgdGFibGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCd0YWJsZScpO1xuICB0cnkge1xuICAgIHRhYmxlLmlubmVySFRNTCA9ICc8dGJvZHk+PC90Ym9keT4nO1xuICB9IGNhdGNoIChlKSB7XG4gIH0gZmluYWxseSB7XG4gICAgaWYgKHRhYmxlLmNoaWxkTm9kZXMubGVuZ3RoICE9PSAwKSB7XG4gICAgICAvLyBJdCB3b3JrZWQgYXMgZXhwZWN0ZWQsIG5vIGZpeCByZXF1aXJlZFxuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgfVxuXG4gIHJldHVybiB0cnVlO1xufVxuIl19 -enifed('glimmer-runtime/lib/compat/svg-inner-html-fix', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/dom/helper'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibDomHelper) { - 'use strict'; - - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; - - var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - // Patch: insertAdjacentHTML on SVG Fix - // Browsers: Safari, IE, Edge, Firefox ~33-34 - // Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is - // present but throws an exception on IE and Edge. Old versions of - // Firefox create nodes in the incorrect namespace. - // Fix: Since IE and Edge silently fail to create SVG nodes using - // innerHTML, and because Firefox may create nodes in the incorrect - // namespace using innerHTML on SVG elements, an HTML-string wrapping - // approach is used. A pre/post SVG tag is added to the string, then - // that whole string is added to a div. The created nodes are plucked - // out and applied to the target location on DOM. - - function domChanges(document, DOMChangesClass, svgNamespace) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document, svgNamespace)) { - return DOMChangesClass; - } - var div = document.createElement('div'); - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithSVGInnerHTMLFix, _DOMChangesClass); - - function DOMChangesWithSVGInnerHTMLFix() { - _DOMChangesClass.apply(this, arguments); - } +// just for side effect of extending String.prototype +// just for side effect of extending Function.prototype +enifed('ember-runtime/inject', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - DOMChangesWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null || html === '') { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - if (parent.namespaceURI !== svgNamespace) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - return fixSVG(parent, div, html, nextSibling); - }; + exports.default = inject; + exports.createInjectionHelper = createInjectionHelper; + exports.validatePropertyInjections = validatePropertyInjections; - return DOMChangesWithSVGInnerHTMLFix; - })(DOMChangesClass); - } + /** + Namespace for injection helper methods. + + @class inject + @namespace Ember + @static + @public + */ - function treeConstruction(document, TreeConstructionClass, svgNamespace) { - if (!document) return TreeConstructionClass; - if (!shouldApplyFix(document, svgNamespace)) { - return TreeConstructionClass; - } - var div = document.createElement('div'); - return (function (_TreeConstructionClass) { - babelHelpers.inherits(TreeConstructionWithSVGInnerHTMLFix, _TreeConstructionClass); + function inject() { + _emberMetal.assert('Injected properties must be created through helpers, see \'' + Object.keys(inject).join('"', '"') + '\''); + } - function TreeConstructionWithSVGInnerHTMLFix() { - _TreeConstructionClass.apply(this, arguments); - } + // Dictionary of injection validations by type, added to by `createInjectionHelper` + var typeValidators = {}; - TreeConstructionWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null || html === '') { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - if (parent.namespaceURI !== svgNamespace) { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - return fixSVG(parent, div, html, reference); - }; + /** + This method allows other Ember modules to register injection helpers for a + given container type. Helpers are exported to the `inject` namespace as the + container type itself. + + @private + @method createInjectionHelper + @since 1.10.0 + @for Ember + @param {String} type The container type the helper will inject + @param {Function} validator A validation callback that is executed at mixin-time + */ - return TreeConstructionWithSVGInnerHTMLFix; - })(TreeConstructionClass); - } + function createInjectionHelper(type, validator) { + typeValidators[type] = validator; - function fixSVG(parent, div, html, reference) { - // IE, Edge: also do not correctly support using `innerHTML` on SVG - // namespaced elements. So here a wrapper is used. - var wrappedHtml = '' + html + ''; - div.innerHTML = wrappedHtml; + inject[type] = function (name) { + return new _emberMetal.InjectedProperty(type, name); + }; + } - var _moveNodesBefore = _glimmerRuntimeLibDomHelper.moveNodesBefore(div.firstChild, parent, reference); + /** + Validation function that runs per-type validation functions once for each + injected type encountered. + + @private + @method validatePropertyInjections + @since 1.10.0 + @for Ember + @param {Object} factory The factory object + */ - var first = _moveNodesBefore[0]; - var last = _moveNodesBefore[1]; + function validatePropertyInjections(factory) { + var proto = factory.proto(); + var types = []; - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - function shouldApplyFix(document, svgNamespace) { - var svg = document.createElementNS(svgNamespace, 'svg'); - try { - svg['insertAdjacentHTML']('beforeEnd', ''); - } catch (e) {} finally { - // FF: Old versions will create a node in the wrong namespace - if (svg.childNodes.length === 1 && svg.firstChild.namespaceURI === SVG_NAMESPACE) { - // The test worked as expected, no fix required - return false; - } - svg = null; - return true; - } + for (var key in proto) { + var desc = proto[key]; + if (desc instanceof _emberMetal.InjectedProperty && types.indexOf(desc.type) === -1) { + types.push(desc.type); + } } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L3N2Zy1pbm5lci1odG1sLWZpeC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFHQSxRQUFNLGFBQWEsR0FBRyw0QkFBNEIsQ0FBQzs7Ozs7Ozs7Ozs7OztBQWFuRCxhQUFBLFVBQUEsQ0FBMkIsUUFBa0IsRUFBRSxlQUFrQyxFQUFFLFlBQW9CLEVBQUE7QUFDckcsWUFBSSxDQUFDLFFBQVEsRUFBRSxPQUFPLGVBQWUsQ0FBQztBQUV0QyxZQUFJLENBQUMsY0FBYyxDQUFDLFFBQVEsRUFBRSxZQUFZLENBQUMsRUFBRTtBQUMzQyxtQkFBTyxlQUFlLENBQUM7U0FDeEI7QUFFRCxZQUFJLEdBQUcsR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFDO0FBRXhDO2tDQUFPLDZCQUFBOztxQkFBQSw2QkFBQTs7OztBQUFBLHlDQUFBLFdBQ0wsZ0JBQWdCLEdBQUEsMEJBQUMsTUFBbUIsRUFBRSxXQUFpQixFQUFFLElBQVksRUFBQTtBQUNuRSxvQkFBSSxJQUFJLEtBQUssSUFBSSxJQUFJLElBQUksS0FBSyxFQUFFLEVBQUU7QUFDaEMsMkJBQU8sMkJBQU0sZ0JBQWdCLEtBQUEsT0FBQyxNQUFNLEVBQUUsV0FBVyxFQUFFLElBQUksQ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c3BhY2UsICdzdmcnKTtcblxuICB0cnkge1xuICAgIHN2Z1snaW5zZXJ0QWRqYWNlbnRIVE1MJ10oJ2JlZm9yZUVuZCcsICc8Y2lyY2xlPjwvY2lyY2xlPicpO1xuICB9IGNhdGNoIChlKSB7XG4gICAgLy8gSUUsIEVkZ2U6IFdpbGwgdGhyb3csIGluc2VydEFkamFjZW50SFRNTCBpcyB1bnN1cHBvcnRlZCBvbiBTVkdcbiAgICAvLyBTYWZhcmk6IFdpbGwgdGhyb3csIGluc2VydEFkamFjZW50SFRNTCBpcyBub3QgcHJlc2VudCBvbiBTVkdcbiAgfSBmaW5hbGx5IHtcbiAgICAvLyBGRjogT2xkIHZlcnNpb25zIHdpbGwgY3JlYXRlIGEgbm9kZSBpbiB0aGUgd3JvbmcgbmFtZXNwYWNlXG4gICAgaWYgKHN2Zy5jaGlsZE5vZGVzLmxlbmd0aCA9PT0gMSAmJiBzdmcuZmlyc3RDaGlsZC5uYW1lc3BhY2VVUkkgPT09IFNWR19OQU1FU1BBQ0UpIHtcbiAgICAgIC8vIFRoZSB0ZXN0IHdvcmtlZCBhcyBleHBlY3RlZCwgbm8gZml4IHJlcXVpcmVkXG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIHN2ZyA9IG51bGw7XG5cbiAgICByZXR1cm4gdHJ1ZTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compat/text-node-merging-fix', ['exports'], function (exports) { - // Patch: Adjacent text node merging fix - // Browsers: IE, Edge, Firefox w/o inspector open - // Reason: These browsers will merge adjacent text nodes. For exmaple given - //
    Hello
    with div.insertAdjacentHTML(' world') browsers - // with proper behavior will populate div.childNodes with two items. - // These browsers will populate it with one merged node instead. - // Fix: Add these nodes to a wrapper element, then iterate the childNodes - // of that wrapper and move the nodes to their target location. Note - // that potential SVG bugs will have been handled before this fix. - // Note that this fix must only apply to the previous text node, as - // the base implementation of `insertHTMLBefore` already handles - // following text nodes correctly. - 'use strict'; - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; + if (types.length) { + for (var i = 0; i < types.length; i++) { + var validator = typeValidators[types[i]]; - function domChanges(document, DOMChangesClass) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document)) { - return DOMChangesClass; + if (typeof validator === 'function') { + validator(factory); } - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithTextNodeMergingFix, _DOMChangesClass); - - function DOMChangesWithTextNodeMergingFix(document) { - _DOMChangesClass.call(this, document); - this.uselessComment = document.createComment(''); - } - - DOMChangesWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - var didSetUselessComment = false; - var nextPrevious = nextSibling ? nextSibling.previousSibling : parent.lastChild; - if (nextPrevious && nextPrevious instanceof Text) { - didSetUselessComment = true; - parent.insertBefore(this.uselessComment, nextSibling); - } - var bounds = _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - if (didSetUselessComment) { - parent.removeChild(this.uselessComment); - } - return bounds; - }; - - return DOMChangesWithTextNodeMergingFix; - })(DOMChangesClass); + } } - function treeConstruction(document, TreeConstructionClass) { - if (!document) return TreeConstructionClass; - if (!shouldApplyFix(document)) { - return TreeConstructionClass; - } - return (function (_TreeConstructionClass) { - babelHelpers.inherits(TreeConstructionWithTextNodeMergingFix, _TreeConstructionClass); - - function TreeConstructionWithTextNodeMergingFix(document) { - _TreeConstructionClass.call(this, document); - this.uselessComment = this.createComment(''); - } + return true; + } +}); +enifed('ember-runtime/is-equal', ['exports'], function (exports) { + /** + Compares two objects, returning true if they are equal. + + ```javascript + Ember.isEqual('hello', 'hello'); // true + Ember.isEqual(1, 2); // false + ``` + + `isEqual` is a more specific comparison than a triple equal comparison. + It will call the `isEqual` instance method on the objects being + compared, allowing finer control over when objects should be considered + equal to each other. + + ```javascript + let Person = Ember.Object.extend({ + isEqual(other) { return this.ssn == other.ssn; } + }); + + let personA = Person.create({name: 'Muhammad Ali', ssn: '123-45-6789'}); + let personB = Person.create({name: 'Cassius Clay', ssn: '123-45-6789'}); + + Ember.isEqual(personA, personB); // true + ``` + + Due to the expense of array comparisons, collections will never be equal to + each other even if each of their items are equal to each other. + + ```javascript + Ember.isEqual([4, 2], [4, 2]); // false + ``` + + @method isEqual + @for Ember + @param {Object} a first object to compare + @param {Object} b second object to compare + @return {Boolean} + @public + */ + 'use strict'; - TreeConstructionWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null) { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - var didSetUselessComment = false; - var nextPrevious = reference ? reference.previousSibling : parent.lastChild; - if (nextPrevious && nextPrevious instanceof Text) { - didSetUselessComment = true; - parent.insertBefore(this.uselessComment, reference); - } - var bounds = _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - if (didSetUselessComment) { - parent.removeChild(this.uselessComment); - } - return bounds; - }; + exports.default = isEqual; - return TreeConstructionWithTextNodeMergingFix; - })(TreeConstructionClass); + function isEqual(a, b) { + if (a && typeof a.isEqual === 'function') { + return a.isEqual(b); } - function shouldApplyFix(document) { - var mergingTextDiv = document.createElement('div'); - mergingTextDiv.innerHTML = 'first'; - mergingTextDiv.insertAdjacentHTML('beforeEnd', 'second'); - if (mergingTextDiv.childNodes.length === 2) { - mergingTextDiv = null; - // It worked as expected, no fix required - return false; - } - mergingTextDiv = null; - return true; + if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime(); } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L3RleHQtbm9kZS1tZXJnaW5nLWZpeC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFlQSxhQUFBLFVBQUEsQ0F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1bWVudCkge1xuICBsZXQgbWVyZ2luZ1RleHREaXYgPSA8SFRNTEVsZW1lbnQ+IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpO1xuXG4gIG1lcmdpbmdUZXh0RGl2LmlubmVySFRNTCA9ICdmaXJzdCc7XG4gIG1lcmdpbmdUZXh0RGl2Lmluc2VydEFkamFjZW50SFRNTCgnYmVmb3JlRW5kJywgJ3NlY29uZCcpO1xuXG4gIGlmIChtZXJnaW5nVGV4dERpdi5jaGlsZE5vZGVzLmxlbmd0aCA9PT0gMikge1xuICAgIG1lcmdpbmdUZXh0RGl2ID0gbnVsbDtcbiAgICAvLyBJdCB3b3JrZWQgYXMgZXhwZWN0ZWQsIG5vIGZpeCByZXF1aXJlZFxuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuXG4gIG1lcmdpbmdUZXh0RGl2ID0gbnVsbDtcblxuICByZXR1cm4gdHJ1ZTtcbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/blocks', ['exports', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/compiler'], function (exports, _glimmerRuntimeLibUtils, _glimmerRuntimeLibCompiler) { - 'use strict'; - - var CompiledBlock = function CompiledBlock(ops, symbols) { - this.ops = ops; - this.symbols = symbols; - }; - - exports.CompiledBlock = CompiledBlock; - var Block = function Block(program, symbolTable) { - this.program = program; - this.symbolTable = symbolTable; - this.compiled = null; - }; + return a === b; + } +}); +enifed('ember-runtime/mixins/-proxy', ['exports', '@glimmer/reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { + /** + @module ember + @submodule ember-runtime + */ - exports.Block = Block; + 'use strict'; - var InlineBlock = (function (_Block) { - babelHelpers.inherits(InlineBlock, _Block); + function contentPropertyWillChange(content, contentKey) { + var key = contentKey.slice(8); // remove "content." + if (key in this) { + return; + } // if shadowed in proxy + _emberMetal.propertyWillChange(this, key); + } - function InlineBlock(program, symbolTable) { - var locals = arguments.length <= 2 || arguments[2] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[2]; + function contentPropertyDidChange(content, contentKey) { + var key = contentKey.slice(8); // remove "content." + if (key in this) { + return; + } // if shadowed in proxy + _emberMetal.propertyDidChange(this, key); + } - _Block.call(this, program, symbolTable); - this.locals = locals; - } + var ProxyTag = (function (_CachedTag) { + babelHelpers.inherits(ProxyTag, _CachedTag); - InlineBlock.prototype.hasPositionalParameters = function hasPositionalParameters() { - return !!this.locals.length; - }; + function ProxyTag(proxy) { + babelHelpers.classCallCheck(this, ProxyTag); - InlineBlock.prototype.compile = function compile(env) { - var compiled = this.compiled; - if (compiled) return compiled; - var ops = new _glimmerRuntimeLibCompiler.InlineBlockCompiler(this, env).compile(); - return this.compiled = new CompiledBlock(ops, this.symbolTable.size); - }; + _CachedTag.call(this); - return InlineBlock; - })(Block); + var content = _emberMetal.get(proxy, 'content'); - exports.InlineBlock = InlineBlock; + this.proxy = proxy; + this.proxyWrapperTag = new _glimmerReference.DirtyableTag(); + this.proxyContentTag = new _glimmerReference.UpdatableTag(_emberMetal.tagFor(content)); + } - var PartialBlock = (function (_InlineBlock) { - babelHelpers.inherits(PartialBlock, _InlineBlock); + /** + `Ember.ProxyMixin` forwards all properties not defined by the proxy itself + to a proxied `content` object. See Ember.ObjectProxy for more details. + + @class ProxyMixin + @namespace Ember + @private + */ - function PartialBlock() { - _InlineBlock.apply(this, arguments); - } + ProxyTag.prototype.compute = function compute() { + return Math.max(this.proxyWrapperTag.value(), this.proxyContentTag.value()); + }; - return PartialBlock; - })(InlineBlock); + ProxyTag.prototype.dirty = function dirty() { + this.proxyWrapperTag.dirty(); + }; - exports.PartialBlock = PartialBlock; + ProxyTag.prototype.contentDidChange = function contentDidChange() { + var content = _emberMetal.get(this.proxy, 'content'); + this.proxyContentTag.update(_emberMetal.tagFor(content)); + }; - var TopLevelTemplate = (function (_Block2) { - babelHelpers.inherits(TopLevelTemplate, _Block2); + return ProxyTag; + })(_glimmerReference.CachedTag); - function TopLevelTemplate() { - _Block2.apply(this, arguments); - } + exports.default = _emberMetal.Mixin.create({ + /** + The object whose properties will be forwarded. + @property content + @type Ember.Object + @default null + @private + */ + content: null, - return TopLevelTemplate; - })(Block); + init: function () { + this._super.apply(this, arguments); + _emberMetal.meta(this).setProxy(); + }, - exports.TopLevelTemplate = TopLevelTemplate; + _initializeTag: _emberMetal.on('init', function () { + _emberMetal.meta(this)._tag = new ProxyTag(this); + }), - var EntryPoint = (function (_TopLevelTemplate) { - babelHelpers.inherits(EntryPoint, _TopLevelTemplate); + _contentDidChange: _emberMetal.observer('content', function () { + _emberMetal.assert('Can\'t set Proxy\'s content to itself', _emberMetal.get(this, 'content') !== this); + _emberMetal.tagFor(this).contentDidChange(); + }), - function EntryPoint() { - _TopLevelTemplate.apply(this, arguments); - } + isTruthy: _emberRuntimeComputedComputed_macros.bool('content'), - EntryPoint.prototype.compile = function compile(env) { - var compiled = this.compiled; - if (compiled) return compiled; - var ops = new _glimmerRuntimeLibCompiler.EntryPointCompiler(this, env).compile(); - return this.compiled = new CompiledBlock(ops, this.symbolTable.size); - }; + _debugContainerKey: null, - return EntryPoint; - })(TopLevelTemplate); + willWatchProperty: function (key) { + var contentKey = 'content.' + key; + _emberMetal._addBeforeObserver(this, contentKey, null, contentPropertyWillChange); + _emberMetal.addObserver(this, contentKey, null, contentPropertyDidChange); + }, - exports.EntryPoint = EntryPoint; + didUnwatchProperty: function (key) { + var contentKey = 'content.' + key; + _emberMetal._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); + _emberMetal.removeObserver(this, contentKey, null, contentPropertyDidChange); + }, - var Layout = (function (_TopLevelTemplate2) { - babelHelpers.inherits(Layout, _TopLevelTemplate2); + unknownProperty: function (key) { + var content = _emberMetal.get(this, 'content'); + if (content) { + _emberMetal.deprecate('You attempted to access `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); + return _emberMetal.get(content, key); + } + }, - function Layout(program, symbolTable, named, yields, hasPartials) { - _TopLevelTemplate2.call(this, program, symbolTable); - this.named = named; - this.yields = yields; - this.hasPartials = hasPartials; - this.hasNamedParameters = !!this.named.length; - this.hasYields = !!this.yields.length; - ; - } + setUnknownProperty: function (key, value) { + var m = _emberMetal.meta(this); + if (m.proto === this) { + // if marked as prototype then just defineProperty + // rather than delegate + _emberMetal.defineProperty(this, key, null, value); + return value; + } - return Layout; - })(TopLevelTemplate); + var content = _emberMetal.get(this, 'content'); + _emberMetal.assert('Cannot delegate set(\'' + key + '\', ' + value + ') to the \'content\' property of object proxy ' + this + ': its \'content\' is undefined.', content); - exports.Layout = Layout; + _emberMetal.deprecate('You attempted to set `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' }); + return _emberMetal.set(content, key, value); + } + }); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvYmxvY2tzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVdBLGFBQUEsR0FJRSxTQUpGLGFBQUEsQ0FJYyxHQUFVLEVBQUUsT0FBZSxFQUFBO0FBQ3JDLFlBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO0FBQ2YsWUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUM7S0FDeEI7Ozs7UUFHSCxLQUFBLEdBR0UsU0FIRixLQUFBLENBR3FCLE9BQWdCLEVBQVMsV0FBd0IsRUFBQTtBQUFqRCxZQUFBLENBQUEsT0FBTyxHQUFQLE9BQU8sQ0FBUztBQUFTLFlBQUEsQ0FBQSxXQUFXLEdBQVgsV0FBVyxDQUFhO0FBRjFELFlBQUEsQ0FBQSxRQUFRLEdBQWtCLElBQUksQ0FBQztLQUU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FyYW1ldGVyczogYm9vbGVhbjtcbiAgcHVibGljIGhhc1lpZWxkczogYm9vbGVhbjtcbiAgY29uc3RydWN0b3IocHJvZ3JhbTogUHJvZ3JhbSwgc3ltYm9sVGFibGU6IFN5bWJvbFRhYmxlLCBwdWJsaWMgbmFtZWQ6IHN0cmluZ1tdLCBwdWJsaWMgeWllbGRzOiBzdHJpbmdbXSwgcHVibGljIGhhc1BhcnRpYWxzOiBib29sZWFuKSB7XG4gICAgc3VwZXIocHJvZ3JhbSwgc3ltYm9sVGFibGUpO1xuICAgIHRoaXMuaGFzTmFtZWRQYXJhbWV0ZXJzID0gISF0aGlzLm5hbWVkLmxlbmd0aDtcbiAgICB0aGlzLmhhc1lpZWxkcyA9ICEhdGhpcy55aWVsZHMubGVuZ3RoOztcbiAgfVxufVxuIl19 -enifed("glimmer-runtime/lib/compiled/expressions", ["exports"], function (exports) { - "use strict"; - - var CompiledExpression = (function () { - function CompiledExpression() {} +enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - CompiledExpression.prototype.toJSON = function toJSON() { - return "UNIMPL: " + this.type.toUpperCase(); - }; + 'use strict'; - return CompiledExpression; - })(); + exports.deprecateUnderscoreActions = deprecateUnderscoreActions; - exports.CompiledExpression = CompiledExpression; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBR0Esa0JBQUE7aUJBQUEsa0JBQUE7O0FBQUEsMEJBQUEsV0FJRSxNQUFNLEdBQUEsa0JBQUE7QUFDSixnQ0FBa0IsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBRztTQUM3Qzs7ZUFOSCxrQkFBQSIsImZpbGUiOiJleHByZXNzaW9ucy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBWTSBmcm9tICcuLi92bS9hcHBlbmQnO1xuaW1wb3J0IHsgUGF0aFJlZmVyZW5jZSB9IGZyb20gJ2dsaW1tZXItcmVmZXJlbmNlJztcblxuZXhwb3J0IGFic3RyYWN0IGNsYXNzIENvbXBpbGVkRXhwcmVzc2lvbjxUPiB7XG4gIHR5cGU6IHN0cmluZztcbiAgYWJzdHJhY3QgZXZhbHVhdGUodm06IFZNKTogUGF0aFJlZmVyZW5jZTxUPjtcblxuICB0b0pTT04oKTogc3RyaW5nIHtcbiAgICByZXR1cm4gYFVOSU1QTDogJHt0aGlzLnR5cGUudG9VcHBlckNhc2UoKX1gO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/args', ['exports', 'glimmer-runtime/lib/compiled/expressions/positional-args', 'glimmer-runtime/lib/compiled/expressions/named-args', 'glimmer-runtime/lib/syntax/core', 'glimmer-reference'], function (exports, _glimmerRuntimeLibCompiledExpressionsPositionalArgs, _glimmerRuntimeLibCompiledExpressionsNamedArgs, _glimmerRuntimeLibSyntaxCore, _glimmerReference) { - 'use strict'; + /** + `Ember.ActionHandler` is available on some familiar classes including + `Ember.Route`, `Ember.Component`, and `Ember.Controller`. + (Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`, + and `Ember.Route` and available to the above classes through + inheritance.) + + @class ActionHandler + @namespace Ember + @private + */ + var ActionHandler = _emberMetal.Mixin.create({ + mergedProperties: ['actions'], - var CompiledArgs = (function () { - function CompiledArgs(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; + /** + The collection of functions, keyed by name, available on this + `ActionHandler` as action targets. + These functions will be invoked when a matching `{{action}}` is triggered + from within a template and the application's current route is this route. + Actions can also be invoked from other parts of your application + via `ActionHandler#send`. + The `actions` hash will inherit action handlers from + the `actions` hash defined on extended parent classes + or mixins rather than just replace the entire hash, e.g.: + ```js + App.CanDisplayBanner = Ember.Mixin.create({ + actions: { + displayBanner(msg) { + // ... + } } - - CompiledArgs.create = function create(positional, named, blocks) { - if (positional === _glimmerRuntimeLibCompiledExpressionsPositionalArgs.COMPILED_EMPTY_POSITIONAL_ARGS && named === _glimmerRuntimeLibCompiledExpressionsNamedArgs.COMPILED_EMPTY_NAMED_ARGS && blocks === _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS) { - return this.empty(); - } else { - return new this(positional, named, blocks); - } - }; - - CompiledArgs.empty = function empty() { - return COMPILED_EMPTY_ARGS; - }; - - CompiledArgs.prototype.evaluate = function evaluate(vm) { - var positional = this.positional; - var named = this.named; - var blocks = this.blocks; - - return EvaluatedArgs.create(positional.evaluate(vm), named.evaluate(vm), blocks); - }; - - return CompiledArgs; - })(); - - exports.CompiledArgs = CompiledArgs; - - var COMPILED_EMPTY_ARGS = new ((function (_CompiledArgs) { - babelHelpers.inherits(_class, _CompiledArgs); - - function _class() { - _CompiledArgs.call(this, _glimmerRuntimeLibCompiledExpressionsPositionalArgs.COMPILED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.COMPILED_EMPTY_NAMED_ARGS, _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS); + }); + App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { + actions: { + playMusic() { + // ... + } } - - _class.prototype.evaluate = function evaluate(vm) { - return EMPTY_EVALUATED_ARGS; - }; - - return _class; - })(CompiledArgs))(); - - var EvaluatedArgs = (function () { - function EvaluatedArgs(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; - this.tag = _glimmerReference.combineTagged([positional, named]); + }); + // `WelcomeRoute`, when active, will be able to respond + // to both actions, since the actions hash is merged rather + // then replaced when extending mixins / parent classes. + this.send('displayBanner'); + this.send('playMusic'); + ``` + Within a Controller, Route or Component's action handler, + the value of the `this` context is the Controller, Route or + Component object: + ```js + App.SongRoute = Ember.Route.extend({ + actions: { + myAction() { + this.controllerFor("song"); + this.transitionTo("other.route"); + ... + } } - - EvaluatedArgs.empty = function empty() { - return EMPTY_EVALUATED_ARGS; - }; - - EvaluatedArgs.create = function create(positional, named, blocks) { - return new this(positional, named, blocks); - }; - - EvaluatedArgs.positional = function positional(values) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS : arguments[1]; - - return new this(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EvaluatedPositionalArgs.create(values), _glimmerRuntimeLibCompiledExpressionsNamedArgs.EVALUATED_EMPTY_NAMED_ARGS, blocks); - }; - - EvaluatedArgs.named = function named(map) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS : arguments[1]; - - return new this(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EVALUATED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.EvaluatedNamedArgs.create(map), blocks); - }; - - return EvaluatedArgs; - })(); - - exports.EvaluatedArgs = EvaluatedArgs; - - var EMPTY_EVALUATED_ARGS = new EvaluatedArgs(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EVALUATED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.EVALUATED_EMPTY_NAMED_ARGS, _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS); - exports.CompiledPositionalArgs = _glimmerRuntimeLibCompiledExpressionsPositionalArgs.CompiledPositionalArgs; - exports.EvaluatedPositionalArgs = _glimmerRuntimeLibCompiledExpressionsPositionalArgs.EvaluatedPositionalArgs; - exports.CompiledNamedArgs = _glimmerRuntimeLibCompiledExpressionsNamedArgs.CompiledNamedArgs; - exports.EvaluatedNamedArgs = _glimmerRuntimeLibCompiledExpressionsNamedArgs.EvaluatedNamedArgs; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29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WVkQXJncywgRXZhbHVhdGVkTmFtZWRBcmdzIH07XG4iXX0= -enifed("glimmer-runtime/lib/compiled/expressions/concat", ["exports", "glimmer-reference"], function (exports, _glimmerReference) { - "use strict"; - - var CompiledConcat = (function () { - function CompiledConcat(parts) { - this.parts = parts; - this.type = "concat"; + }); + ``` + It is also possible to call `this._super(...arguments)` from within an + action handler if it overrides a handler defined on a parent + class or mixin: + Take for example the following routes: + ```js + App.DebugRoute = Ember.Mixin.create({ + actions: { + debugRouteInformation() { + console.debug("trololo"); + } } - - CompiledConcat.prototype.evaluate = function evaluate(vm) { - var parts = new Array(this.parts.length); - for (var i = 0; i < this.parts.length; i++) { - parts[i] = this.parts[i].evaluate(vm); + }); + App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { + actions: { + debugRouteInformation() { + // also call the debugRouteInformation of mixed in App.DebugRoute + this._super(...arguments); + // show additional annoyance + window.alert(...); + } + } + }); + ``` + ## Bubbling + By default, an action will stop bubbling once a handler defined + on the `actions` hash handles it. To continue bubbling the action, + you must return `true` from the handler: + ```js + App.Router.map(function() { + this.route("album", function() { + this.route("song"); + }); + }); + App.AlbumRoute = Ember.Route.extend({ + actions: { + startPlaying: function() { + } + } + }); + App.AlbumSongRoute = Ember.Route.extend({ + actions: { + startPlaying() { + // ... + if (actionShouldAlsoBeTriggeredOnParentRoute) { + return true; } - return new ConcatReference(parts); - }; + } + } + }); + ``` + @property actions + @type Object + @default null + @public + */ - CompiledConcat.prototype.toJSON = function toJSON() { - return "concat(" + this.parts.map(function (expr) { - return expr.toJSON(); - }).join(", ") + ")"; - }; + /** + Triggers a named action on the `ActionHandler`. Any parameters + supplied after the `actionName` string will be passed as arguments + to the action target function. + If the `ActionHandler` has its `target` property set, actions may + bubble to the `target`. Bubbling happens when an `actionName` can + not be found in the `ActionHandler`'s `actions` hash or if the + action target function returns `true`. + Example + ```js + App.WelcomeRoute = Ember.Route.extend({ + actions: { + playTheme() { + this.send('playMusic', 'theme.mp3'); + }, + playMusic(track) { + // ... + } + } + }); + ``` + @method send + @param {String} actionName The action to trigger + @param {*} context a context to send with the action + @public + */ + send: function (actionName) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - return CompiledConcat; - })(); + if (this.actions && this.actions[actionName]) { + var shouldBubble = this.actions[actionName].apply(this, args) === true; + if (!shouldBubble) { + return; + } + } - exports.default = CompiledConcat; + var target = _emberMetal.get(this, 'target'); + if (target) { + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); + target.send.apply(target, arguments); + } + }, - var ConcatReference = (function (_CachedReference) { - babelHelpers.inherits(ConcatReference, _CachedReference); + willMergeMixin: function (props) { + _emberMetal.assert('Specifying `_actions` and `actions` in the same mixin is not supported.', !props.actions || !props._actions); - function ConcatReference(parts) { - _CachedReference.call(this); - this.parts = parts; - this.tag = _glimmerReference.combineTagged(parts); - } + if (props._actions) { + _emberMetal.deprecate('Specifying actions in `_actions` is deprecated, please use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); - ConcatReference.prototype.compute = function compute() { - var parts = new Array(); - for (var i = 0; i < this.parts.length; i++) { - var value = this.parts[i].value(); - if (value !== null && value !== undefined) { - parts[i] = castToString(this.parts[i].value()); - } - } - if (parts.length > 0) { - return parts.join(''); - } - return null; - }; + props.actions = props._actions; + delete props._actions; + } + } + }); - return ConcatReference; - })(_glimmerReference.CachedReference); + exports.default = ActionHandler; - function castToString(value) { - if (typeof value['toString'] !== 'function') { - return ''; - } - return String(value); - } + function deprecateUnderscoreActions(factory) { + Object.defineProperty(factory.prototype, '_actions', { + configurable: true, + enumerable: false, + set: function (value) { + _emberMetal.assert('You cannot set `_actions` on ' + this + ', please use `actions` instead.'); + }, + get: function () { + _emberMetal.deprecate('Usage of `_actions` is deprecated, use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }); + return _emberM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B2YWx1ZVsndG9TdHJpbmcnXSAhPT0gJ2Z1bmN0aW9uJykge1xuICAgIHJldHVybiAnJztcbiAgfVxuXG4gIHJldHVybiBTdHJpbmcodmFsdWUpO1xufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/function', ['exports', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/compiled/expressions'], function (exports, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibCompiledExpressions) { - 'use strict'; - - exports.default = make; +enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/each_proxy'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsEnumerable, _emberRuntimeSystemEach_proxy) { + /** + @module ember + @submodule ember-runtime + */ - function make(func) { - return new FunctionExpressionSyntax(func); - } + // .......................................................... + // HELPERS + // + 'use strict'; - var FunctionExpressionSyntax = (function (_ExpressionSyntax) { - babelHelpers.inherits(FunctionExpressionSyntax, _ExpressionSyntax); + var _Mixin$create; - function FunctionExpressionSyntax(func) { - _ExpressionSyntax.call(this); - this.type = "function-expression"; - this.func = func; - } + exports.addArrayObserver = addArrayObserver; + exports.removeArrayObserver = removeArrayObserver; + exports.objectAt = objectAt; + exports.arrayContentWillChange = arrayContentWillChange; + exports.arrayContentDidChange = arrayContentDidChange; + exports.isEmberArray = isEmberArray; - FunctionExpressionSyntax.prototype.compile = function compile(lookup, env, symbolTable) { - return new CompiledFunctionExpression(this.func, symbolTable); - }; + function arrayObserversHelper(obj, target, opts, operation, notify) { + var willChange = opts && opts.willChange || 'arrayWillChange'; + var didChange = opts && opts.didChange || 'arrayDidChange'; + var hasObservers = _emberMetal.get(obj, 'hasArrayObservers'); - return FunctionExpressionSyntax; - })(_glimmerRuntimeLibSyntax.Expression); + if (hasObservers === notify) { + _emberMetal.propertyWillChange(obj, 'hasArrayObservers'); + } - var CompiledFunctionExpression = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledFunctionExpression, _CompiledExpression); + operation(obj, '@array:before', target, willChange); + operation(obj, '@array:change', target, didChange); - function CompiledFunctionExpression(func, symbolTable) { - _CompiledExpression.call(this); - this.func = func; - this.symbolTable = symbolTable; - this.type = "function"; - this.func = func; - } + if (hasObservers === notify) { + _emberMetal.propertyDidChange(obj, 'hasArrayObservers'); + } - CompiledFunctionExpression.prototype.evaluate = function evaluate(vm) { - var func = this.func; - var symbolTable = this.symbolTable; + return obj; + } - return func(vm, symbolTable); - }; + function addArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetal.addListener, false); + } - CompiledFunctionExpression.prototype.toJSON = function toJSON() { - var func = this.func; + function removeArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetal.removeListener, true); + } - if (func.name) { - return '`' + func.name + '(...)`'; - } else { - return "`func(...)`"; - } - }; + function objectAt(content, idx) { + if (content.objectAt) { + return content.objectAt(idx); + } - return CompiledFunctionExpression; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O3NCQVFBLElBQUE7O0FBQUEsYUFBQSxJQUFBLENBQWdDLElBQTJCLEVBQUE7QUFDekQsZUFBTyxJQUFJLHdCQUF3QixDQUFDLElBQUksQ0FBQyxDQUFDO0tBQzNDOztRQUVELHdCQUFBOzhCQUFBLHdCQUFBOztBQUlFLGlCQUpGLHdCQUFBLENBSWMsSUFBMkIsRUFBQTtBQUNyQyx3Q0FBTyxDQUFDO0FBSkgsZ0JBQUEsQ0FBQSxJQUFJLEdBQUcscUJBQXFCLENBQUM7QUFLbEMsZ0JBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1NBQ2xCOztBQVBILGdDQUFBLFdBU0UsT0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VD4ge1xuICAgIHJldHVybiBuZXcgQ29tcGlsZWRGdW5jdGlvbkV4cHJlc3Npb24odGhpcy5mdW5jLCBzeW1ib2xUYWJsZSk7XG4gIH1cbn1cblxuY2xhc3MgQ29tcGlsZWRGdW5jdGlvbkV4cHJlc3Npb248VD4gZXh0ZW5kcyBDb21waWxlZEV4cHJlc3Npb248VD4ge1xuICBwdWJsaWMgdHlwZSA9IFwiZnVuY3Rpb25cIjtcblxuICBjb25zdHJ1Y3Rvcihwcml2YXRlIGZ1bmM6IEZ1bmN0aW9uRXhwcmVzc2lvbjxUPiwgcHJpdmF0ZSBzeW1ib2xUYWJsZTogU3ltYm9sVGFibGUpIHtcbiAgICBzdXBlcigpO1xuICAgIHRoaXMuZnVuYyA9IGZ1bmM7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPFQ+IHtcbiAgICBsZXQgeyBmdW5jLCBzeW1ib2xUYWJsZSB9ID0gdGhpcztcbiAgICByZXR1cm4gZnVuYyh2bSwgc3ltYm9sVGFibGUpO1xuICB9XG5cbiAgdG9KU09OKCk6IHN0cmluZyB7XG4gICAgbGV0IHsgZnVuYyB9ID0gdGhpcztcblxuICAgIGlmIChmdW5jLm5hbWUpIHtcbiAgICAgIHJldHVybiBgXFxgJHtmdW5jLm5hbWV9KC4uLilcXGBgO1xuICAgIH0gZWxzZSB7XG4gICAgICByZXR1cm4gXCJgZnVuYyguLi4pYFwiO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/has-block', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/references'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibReferences) { - 'use strict'; + return content[idx]; + } - var CompiledHasBlock = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledHasBlock, _CompiledExpression); + function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { + var removing = undefined, + lim = undefined; - function CompiledHasBlock(inner) { - _CompiledExpression.call(this); - this.inner = inner; - this.type = "has-block"; - } + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; + } else { + if (removeAmt === undefined) { + removeAmt = -1; + } - CompiledHasBlock.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - return _glimmerRuntimeLibReferences.PrimitiveReference.create(!!block); - }; + if (addAmt === undefined) { + addAmt = -1; + } + } - CompiledHasBlock.prototype.toJSON = function toJSON() { - return 'has-block(' + this.inner.toJSON() + ')'; - }; + if (array.__each) { + array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt); + } - return CompiledHasBlock; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + _emberMetal.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); - exports.default = CompiledHasBlock; + if (startIdx >= 0 && removeAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { + removing = []; + lim = startIdx + removeAmt; - var CompiledHasBlockParams = (function (_CompiledExpression2) { - babelHelpers.inherits(CompiledHasBlockParams, _CompiledExpression2); + for (var idx = startIdx; idx < lim; idx++) { + removing.push(objectAt(array, idx)); + } + } else { + removing = removeAmt; + } - function CompiledHasBlockParams(inner) { - _CompiledExpression2.call(this); - this.inner = inner; - this.type = "has-block-params"; - } + array.enumerableContentWillChange(removing, addAmt); - CompiledHasBlockParams.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - return _glimmerRuntimeLibReferences.PrimitiveReference.create(!!(block && block.locals.length > 0)); - }; + return array; + } - CompiledHasBlockParams.prototype.toJSON = function toJSON() { - return 'has-block-params(' + this.inner.toJSON() + ')'; - }; + function arrayContentDidChange(array, startIdx, removeAmt, addAmt) { + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; + } else { + if (removeAmt === undefined) { + removeAmt = -1; + } - return CompiledHasBlockParams; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + if (addAmt === undefined) { + addAmt = -1; + } + } - exports.CompiledHasBlockParams = CompiledHasBlockParams; + var adding = undefined; + if (startIdx >= 0 && addAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { + adding = []; + var lim = startIdx + addAmt; - var CompiledGetBlockBySymbol = (function () { - function CompiledGetBlockBySymbol(symbol, debug) { - this.symbol = symbol; - this.debug = debug; - } + for (var idx = startIdx; idx < lim; idx++) { + adding.push(objectAt(array, idx)); + } + } else { + adding = addAmt; + } - CompiledGetBlockBySymbol.prototype.evaluate = function evaluate(vm) { - return vm.scope().getBlock(this.symbol); - }; + array.enumerableContentDidChange(removeAmt, adding); - CompiledGetBlockBySymbol.prototype.toJSON = function toJSON() { - return 'get-block($' + this.symbol + '(' + this.debug + '))'; - }; + if (array.__each) { + array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt); + } - return CompiledGetBlockBySymbol; - })(); + _emberMetal.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); - exports.CompiledGetBlockBySymbol = CompiledGetBlockBySymbol; + var meta = _emberMetal.peekMeta(array); + var cache = meta && meta.readableCache(); - var CompiledInPartialGetBlock = (function () { - function CompiledInPartialGetBlock(symbol, name) { - this.symbol = symbol; - this.name = name; - } + if (cache) { + if (cache.firstObject !== undefined && objectAt(array, 0) !== _emberMetal.cacheFor.get(cache, 'firstObject')) { + _emberMetal.propertyWillChange(array, 'firstObject'); + _emberMetal.propertyDidChange(array, 'firstObject'); + } + if (cache.lastObject !== undefined && objectAt(array, _emberMetal.get(array, 'length') - 1) !== _emberMetal.cacheFor.get(cache, 'lastObject')) { + _emberMetal.propertyWillChange(array, 'lastObject'); + _emberMetal.propertyDidChange(array, 'lastObject'); + } + } + return array; + } - CompiledInPartialGetBlock.prototype.evaluate = function evaluate(vm) { - var symbol = this.symbol; - var name = this.name; + var EMBER_ARRAY = _emberUtils.symbol('EMBER_ARRAY'); - var args = vm.scope().getPartialArgs(symbol); - return args.blocks[name]; - }; + function isEmberArray(obj) { + return obj && !!obj[EMBER_ARRAY]; + } - CompiledInPartialGetBlock.prototype.toJSON = function toJSON() { - return 'get-block($' + this.symbol + '($ARGS).' + this.name + '))'; - }; + // .......................................................... + // ARRAY + // + /** + This mixin implements Observer-friendly Array-like behavior. It is not a + concrete implementation, but it can be used up by other classes that want + to appear like arrays. + + For example, ArrayProxy is a concrete classes that can + be instantiated to implement array-like behavior. Both of these classes use + the Array Mixin by way of the MutableArray mixin, which allows observable + changes to be made to the underlying array. + + Unlike `Ember.Enumerable,` this mixin defines methods specifically for + collections that provide index-ordered access to their contents. When you + are designing code that needs to accept any kind of Array-like object, you + should use these methods instead of Array primitives because these will + properly notify observers of changes to the array. + + Although these methods are efficient, they do add a layer of indirection to + your application so it is a good idea to use them only when you need the + flexibility of using both true JavaScript arrays and "virtual" arrays such + as controllers and collections. + + You can use the methods defined in this module to access and modify array + contents in a KVO-friendly way. You can also be notified whenever the + membership of an array changes by using `.observes('myArray.[]')`. + + To support `Ember.Array` in your own class, you must override two + primitives to use it: `length()` and `objectAt()`. + + Note that the Ember.Array mixin also incorporates the `Ember.Enumerable` + mixin. All `Ember.Array`-like objects are also enumerable. + + @class Array + @namespace Ember + @uses Ember.Enumerable + @since Ember 0.9.0 + @public + */ + var ArrayMixin = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) { + if (idx < 0 || idx >= _emberMetal.get(this, 'length')) { + return undefined; + } - return CompiledInPartialGetBlock; - })(); + return _emberMetal.get(this, idx); + }, _Mixin$create.objectsAt = function (indexes) { + var _this = this; - exports.CompiledInPartialGetBlock = CompiledInPartialGetBlock; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvaGFzLWJsb2NrLnRzIl0sIm5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c6IHN0cmluZykge1xuICB9XG5cbiAgZXZhbHVhdGUodm06IFZNKTogSW5saW5lQmxvY2sge1xuICAgIHJldHVybiB2bS5zY29wZSgpLmdldEJsb2NrKHRoaXMuc3ltYm9sKTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgZ2V0LWJsb2NrKCQke3RoaXMuc3ltYm9sfSgke3RoaXMuZGVidWd9KSlgO1xuICB9XG59XG5cbmV4cG9ydCBjbGFzcyBDb21waWxlZEluUGFydGlhbEdldEJsb2NrIGltcGxlbWVudHMgQ29tcGlsZWRHZXRCbG9jayB7XG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgc3ltYm9sOiBudW1iZXIsIHByaXZhdGUgbmFtZTogc3RyaW5nKSB7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBJbmxpbmVCbG9jayB7XG4gICAgbGV0IHsgc3ltYm9sLCBuYW1lIH0gPSB0aGlzO1xuICAgIGxldCBhcmdzID0gdm0uc2NvcGUoKS5nZXRQYXJ0aWFsQXJncyhzeW1ib2wpO1xuICAgIHJldHVybiBhcmdzLmJsb2Nrc1tuYW1lXTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgZ2V0LWJsb2NrKCQke3RoaXMuc3ltYm9sfSgkQVJHUykuJHt0aGlzLm5hbWV9KSlgO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/helper', ['exports', 'glimmer-runtime/lib/compiled/expressions'], function (exports, _glimmerRuntimeLibCompiledExpressions) { - 'use strict'; + return indexes.map(function (idx) { + return objectAt(_this, idx); + }); + }, _Mixin$create.nextObject = function (idx) { + return objectAt(this, idx); + }, _Mixin$create['[]'] = _emberMetal.computed({ + get: function (key) { + return this; + }, + set: function (key, value) { + this.replace(0, _emberMetal.get(this, 'length'), value); + return this; + } + }), _Mixin$create.firstObject = _emberMetal.computed(function () { + return objectAt(this, 0); + }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () { + return objectAt(this, _emberMetal.get(this, 'length') - 1); + }).readOnly(), _Mixin$create.contains = function (obj) { + _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - var CompiledHelper = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledHelper, _CompiledExpression); + return this.indexOf(obj) >= 0; + }, _Mixin$create.slice = function (beginIndex, endIndex) { + var ret = _emberMetal.default.A(); + var length = _emberMetal.get(this, 'length'); - function CompiledHelper(name, helper, args, symbolTable) { - _CompiledExpression.call(this); - this.name = name; - this.helper = helper; - this.args = args; - this.symbolTable = symbolTable; - this.type = "helper"; - } + if (_emberMetal.isNone(beginIndex)) { + beginIndex = 0; + } - CompiledHelper.prototype.evaluate = function evaluate(vm) { - var helper = this.helper; + if (_emberMetal.isNone(endIndex) || endIndex > length) { + endIndex = length; + } - return helper(vm, this.args.evaluate(vm), this.symbolTable); - }; + if (beginIndex < 0) { + beginIndex = length + beginIndex; + } - CompiledHelper.prototype.toJSON = function toJSON() { - return '`' + this.name.join('.') + '($ARGS)`'; - }; + if (endIndex < 0) { + endIndex = length + endIndex; + } - return CompiledHelper; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + while (beginIndex < endIndex) { + ret[ret.length] = objectAt(this, beginIndex++); + } - exports.default = CompiledHelper; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvaGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLGNBQUE7OEJBQUEsY0FBQTs7QUFHRSxpQkFIRixjQUFBLENBR3FCLElBQWMsRUFBUyxNQUFjLEVBQVMsSUFBa0IsRUFBUyxXQUF3QixFQ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XRoUmVmZXJlbmNlIH0gZnJvbSAnZ2xpbW1lci1yZWZlcmVuY2UnO1xuaW1wb3J0IHsgT3BhcXVlIH0gZnJvbSAnZ2xpbW1lci11dGlsJztcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgQ29tcGlsZWRIZWxwZXIgZXh0ZW5kcyBDb21waWxlZEV4cHJlc3Npb248T3BhcXVlPiB7XG4gIHB1YmxpYyB0eXBlID0gXCJoZWxwZXJcIjtcblxuICBjb25zdHJ1Y3RvcihwdWJsaWMgbmFtZTogc3RyaW5nW10sIHB1YmxpYyBoZWxwZXI6IEhlbHBlciwgcHVibGljIGFyZ3M6IENvbXBpbGVkQXJncywgcHVibGljIHN5bWJvbFRhYmxlOiBTeW1ib2xUYWJsZSkge1xuICAgIHN1cGVyKCk7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIGxldCB7IGhlbHBlciB9ID0gdGhpcztcbiAgICByZXR1cm4gaGVscGVyKHZtLCB0aGlzLmFyZ3MuZXZhbHVhdGUodm0pLCB0aGlzLnN5bWJvbFRhYmxlKTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgXFxgJHt0aGlzLm5hbWUuam9pbignLicpfSgkQVJHUylcXGBgO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/lookups', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-reference'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerReference) { - 'use strict'; + return ret; + }, _Mixin$create.indexOf = function (object, startAt) { + var len = _emberMetal.get(this, 'length'); - var CompiledLookup = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledLookup, _CompiledExpression); + if (startAt === undefined) { + startAt = 0; + } - function CompiledLookup(base, path) { - _CompiledExpression.call(this); - this.base = base; - this.path = path; - this.type = "lookup"; - } + if (startAt < 0) { + startAt += len; + } - CompiledLookup.create = function create(base, path) { - if (path.length === 0) { - return base; - } else { - return new this(base, path); - } - }; + for (var idx = startAt; idx < len; idx++) { + if (objectAt(this, idx) === object) { + return idx; + } + } - CompiledLookup.prototype.evaluate = function evaluate(vm) { - var base = this.base; - var path = this.path; + return -1; + }, _Mixin$create.lastIndexOf = function (object, startAt) { + var len = _emberMetal.get(this, 'length'); - return _glimmerReference.referenceFromParts(base.evaluate(vm), path); - }; + if (startAt === undefined || startAt >= len) { + startAt = len - 1; + } - CompiledLookup.prototype.toJSON = function toJSON() { - return this.base.toJSON() + '.' + this.path.join('.'); - }; + if (startAt < 0) { + startAt += len; + } - return CompiledLookup; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + for (var idx = startAt; idx >= 0; idx--) { + if (objectAt(this, idx) === object) { + return idx; + } + } - exports.default = CompiledLookup; + return -1; + }, _Mixin$create.addArrayObserver = function (target, opts) { + return addArrayObserver(this, target, opts); + }, _Mixin$create.removeArrayObserver = function (target, opts) { + return removeArrayObserver(this, target, opts); + }, _Mixin$create.hasArrayObservers = _emberMetal.computed(function () { + return _emberMetal.hasListeners(this, '@array:change') || _emberMetal.hasListeners(this, '@array:before'); + }), _Mixin$create.arrayContentWillChange = function (startIdx, removeAmt, addAmt) { + return arrayContentWillChange(this, startIdx, removeAmt, addAmt); + }, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) { + return arrayContentDidChange(this, startIdx, removeAmt, addAmt); + }, _Mixin$create.includes = function (obj, startAt) { + var len = _emberMetal.get(this, 'length'); - var CompiledSelf = (function (_CompiledExpression2) { - babelHelpers.inherits(CompiledSelf, _CompiledExpression2); + if (startAt === undefined) { + startAt = 0; + } - function CompiledSelf() { - _CompiledExpression2.apply(this, arguments); - } + if (startAt < 0) { + startAt += len; + } - CompiledSelf.prototype.evaluate = function evaluate(vm) { - return vm.getSelf(); - }; + for (var idx = startAt; idx < len; idx++) { + var currentObj = objectAt(this, idx); - CompiledSelf.prototype.toJSON = function toJSON() { - return 'self'; - }; + // SameValueZero comparison (NaN !== NaN) + if (obj === currentObj || obj !== obj && currentObj !== currentObj) { + return true; + } + } - return CompiledSelf; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + return false; + }, _Mixin$create['@each'] = _emberMetal.computed(function () { + // TODO use Symbol or add to meta + if (!this.__each) { + this.__each = new _emberRuntimeSystemEach_proxy.default(this); + } - exports.CompiledSelf = CompiledSelf; + return this.__each; + }).volatile().readOnly(), _Mixin$create)); - var CompiledSymbol = (function (_CompiledExpression3) { - babelHelpers.inherits(CompiledSymbol, _CompiledExpression3); + exports.default = ArrayMixin; +}); +// ES6TODO: Ember.A - function CompiledSymbol(symbol, debug) { - _CompiledExpression3.call(this); - this.symbol = symbol; - this.debug = debug; - } +/** + __Required.__ You must implement this method to apply this mixin. + Your array must support the `length` property. Your replace methods should + set this property whenever it changes. + @property {Number} length + @public +*/ - CompiledSymbol.prototype.evaluate = function evaluate(vm) { - return vm.referenceForSymbol(this.symbol); - }; +/** + Returns the object at the given `index`. If the given `index` is negative + or is greater or equal than the array length, returns `undefined`. + This is one of the primitives you must implement to support `Ember.Array`. + If your object supports retrieving the value of an array item using `get()` + (i.e. `myArray.get(0)`), then you do not need to implement this method + yourself. + ```javascript + let arr = ['a', 'b', 'c', 'd']; + arr.objectAt(0); // 'a' + arr.objectAt(3); // 'd' + arr.objectAt(-1); // undefined + arr.objectAt(4); // undefined + arr.objectAt(5); // undefined + ``` + @method objectAt + @param {Number} idx The index of the item to return. + @return {*} item at index or undefined + @public +*/ - CompiledSymbol.prototype.toJSON = function toJSON() { - return '$' + this.symbol + '(' + this.debug + ')'; - }; +/** + This returns the objects at the specified indexes, using `objectAt`. + ```javascript + let arr = ['a', 'b', 'c', 'd']; + arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] + arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] + ``` + @method objectsAt + @param {Array} indexes An array of indexes of items to return. + @return {Array} + @public + */ - return CompiledSymbol; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); +// overrides Ember.Enumerable version - exports.CompiledSymbol = CompiledSymbol; +/** + 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 + array, it will replace the current content. + This property overrides the default property defined in `Ember.Enumerable`. + @property [] + @return this + @public +*/ - var CompiledInPartialName = (function (_CompiledExpression4) { - babelHelpers.inherits(CompiledInPartialName, _CompiledExpression4); +// optimized version from Enumerable - function CompiledInPartialName(symbol, name) { - _CompiledExpression4.call(this); - this.symbol = symbol; - this.name = name; - } +// Add any extra methods to Ember.Array that are native to the built-in Array. +/** + Returns a new array that is a slice of the receiver. This implementation + uses the observable array methods to retrieve the objects for the new + slice. + ```javascript + let arr = ['red', 'green', 'blue']; + arr.slice(0); // ['red', 'green', 'blue'] + arr.slice(0, 2); // ['red', 'green'] + arr.slice(1, 100); // ['green', 'blue'] + ``` + @method slice + @param {Number} beginIndex (Optional) index to begin slicing from. + @param {Number} endIndex (Optional) index to end the slice at (but not included). + @return {Array} New array with specified slice + @public +*/ - CompiledInPartialName.prototype.evaluate = function evaluate(vm) { - var symbol = this.symbol; - var name = this.name; +/** + Returns the index of the given object's first occurrence. + If no `startAt` argument is given, the starting location to + search is 0. If it's negative, will count backward from + the end of the array. Returns -1 if no match is found. + ```javascript + let arr = ['a', 'b', 'c', 'd', 'a']; + arr.indexOf('a'); // 0 + arr.indexOf('z'); // -1 + arr.indexOf('a', 2); // 4 + arr.indexOf('a', -1); // 4 + arr.indexOf('b', 3); // -1 + arr.indexOf('a', 100); // -1 + ``` + @method indexOf + @param {Object} object the item to search for + @param {Number} startAt optional starting location to search, default 0 + @return {Number} index or -1 if not found + @public +*/ - var args = vm.scope().getPartialArgs(symbol); - return args.named.get(name); - }; +/** + Returns the index of the given object's last occurrence. + If no `startAt` argument is given, the search starts from + the last position. If it's negative, will count backward + from the end of the array. Returns -1 if no match is found. + ```javascript + let arr = ['a', 'b', 'c', 'd', 'a']; + arr.lastIndexOf('a'); // 4 + arr.lastIndexOf('z'); // -1 + arr.lastIndexOf('a', 2); // 0 + arr.lastIndexOf('a', -1); // 4 + arr.lastIndexOf('b', 3); // 1 + arr.lastIndexOf('a', 100); // 4 + ``` + @method lastIndexOf + @param {Object} object the item to search for + @param {Number} startAt optional starting location to search, default 0 + @return {Number} index or -1 if not found + @public +*/ - CompiledInPartialName.prototype.toJSON = function toJSON() { - return '$' + this.symbol + '($ARGS).' + this.name; - }; +// .......................................................... +// ARRAY OBSERVERS +// - return CompiledInPartialName; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); +/** + Adds an array observer to the receiving array. The array observer object + normally must implement two methods: + * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be + called just before the array is modified. + * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be + called just after the array is modified. + Both callbacks will be passed the observed object, starting index of the + change as well as a count of the items to be removed and added. You can use + these callbacks to optionally inspect the array during the change, clear + caches, or do any other bookkeeping necessary. + In addition to passing a target, you can also include an options hash + which you can use to override the method names that will be invoked on the + target. + @method addArrayObserver + @param {Object} target The observer object. + @param {Object} opts Optional hash of configuration options including + `willChange` and `didChange` option. + @return {Ember.Array} receiver + @public +*/ - exports.CompiledInPartialName = CompiledInPartialName; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvbG9va3Vwcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFNQSxjQUFBOzhCQUFBLGNBQUE7O0FBV0UsaUJBWEYsY0FBQSxDQVlZLElBQWdDLEVBQ2hDLElBQWMsRUFBQTtBQUV0QiwwQ0FBTyxDQUFDO0FBSEEsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUE0QjtBQUNoQyxnQkFBQSxDQUFBLElBQUksR0FBSixJQUFJLENBQVU7QUFaakIsZ0JBQUEsQ0FBQSxJQUFJL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G5leHBvcnQgY2xhc3MgQ29tcGlsZWRJblBhcnRpYWxOYW1lIGV4dGVuZHMgQ29tcGlsZWRFeHByZXNzaW9uPE9wYXF1ZT4ge1xuICBjb25zdHJ1Y3Rvcihwcml2YXRlIHN5bWJvbDogbnVtYmVyLCBwcml2YXRlIG5hbWU6IHN0cmluZykge1xuICAgIHN1cGVyKCk7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIGxldCB7IHN5bWJvbCwgbmFtZSB9ID0gdGhpcztcbiAgICBsZXQgYXJncyA9IHZtLnNjb3BlKCkuZ2V0UGFydGlhbEFyZ3Moc3ltYm9sKTtcbiAgICByZXR1cm4gYXJncy5uYW1lZC5nZXQobmFtZSk7XG4gIH1cblxuICB0b0pTT04oKTogc3RyaW5nIHtcbiAgICByZXR1cm4gYCQke3RoaXMuc3ltYm9sfSgkQVJHUykuJHt0aGlzLm5hbWV9YDtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/named-args', ['exports', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/utils', 'glimmer-reference', 'glimmer-util'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibUtils, _glimmerReference, _glimmerUtil) { - 'use strict'; +/** + Removes an array observer from the object if the observer is current + registered. Calling this method multiple times with the same object will + have no effect. + @method removeArrayObserver + @param {Object} target The object observing the array. + @param {Object} opts Optional hash of configuration options including + `willChange` and `didChange` option. + @return {Ember.Array} receiver + @public +*/ - var CompiledNamedArgs = (function () { - function CompiledNamedArgs(keys, values) { - this.keys = keys; - this.values = values; - this.length = keys.length; - _glimmerUtil.assert(keys.length === values.length, 'Keys and values do not have the same length'); - } +/** + Becomes true whenever the array currently has observers watching changes + on the array. + @property {Boolean} hasArrayObservers + @public +*/ - CompiledNamedArgs.empty = function empty() { - return COMPILED_EMPTY_NAMED_ARGS; - }; +/** + If you are implementing an object that supports `Ember.Array`, call this + method just before the array content changes to notify any observers and + invalidate any related properties. Pass the starting index of the change + as well as a delta of the amounts to change. + @method arrayContentWillChange + @param {Number} startIdx The starting index in the array that will change. + @param {Number} removeAmt The number of items that will be removed. If you + pass `null` assumes 0 + @param {Number} addAmt The number of items that will be added. If you + pass `null` assumes 0. + @return {Ember.Array} receiver + @public +*/ - CompiledNamedArgs.create = function create(map) { - var keys = Object.keys(map); - var length = keys.length; - if (length > 0) { - var values = []; - for (var i = 0; i < length; i++) { - values[i] = map[keys[i]]; - } - return new this(keys, values); - } else { - return COMPILED_EMPTY_NAMED_ARGS; - } - }; +/** + If you are implementing an object that supports `Ember.Array`, call this + method just after the array content changes to notify any observers and + invalidate any related properties. Pass the starting index of the change + as well as a delta of the amounts to change. + @method arrayContentDidChange + @param {Number} startIdx The starting index in the array that did change. + @param {Number} removeAmt The number of items that were removed. If you + pass `null` assumes 0 + @param {Number} addAmt The number of items that were added. If you + pass `null` assumes 0. + @return {Ember.Array} receiver + @public +*/ - CompiledNamedArgs.prototype.evaluate = function evaluate(vm) { - var keys = this.keys; - var values = this.values; - var length = this.length; +/** + Returns `true` if the passed object can be found in the array. + This method is a Polyfill for ES 2016 Array.includes. + If no `startAt` argument is given, the starting location to + search is 0. If it's negative, searches from the index of + `this.length + startAt` by asc. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, 3].includes(3, 2); // true + [1, 2, 3].includes(3, 3); // false + [1, 2, 3].includes(3, -1); // true + [1, 2, 3].includes(1, -1); // false + [1, 2, 3].includes(1, -4); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @param {Number} startAt optional starting location to search, default 0 + @return {Boolean} `true` if object is found in the array. + @public +*/ - var evaluated = new Array(length); - for (var i = 0; i < length; i++) { - evaluated[i] = values[i].evaluate(vm); - } - return new EvaluatedNamedArgs(keys, evaluated); - }; +/** + Returns a special object that can be used to observe individual properties + on the array. Just get an equivalent property on this object and it will + return an enumerable that maps automatically to the named key on the + member objects. + `@each` should only be used in a non-terminal context. Example: + ```javascript + myMethod: computed('posts.@each.author', function(){ + ... + }); + ``` + If you merely want to watch for the array being changed, like an object being + replaced, added or removed, use `[]` instead of `@each`. + ```javascript + myMethod: computed('posts.[]', function(){ + ... + }); + ``` + @property @each + @public +*/ +enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - CompiledNamedArgs.prototype.toJSON = function toJSON() { - var keys = this.keys; - var values = this.values; + /** + @module ember + @submodule ember-runtime + */ - var inner = keys.map(function (key, i) { - return key + ': ' + values[i].toJSON(); - }).join(", "); - return '{' + inner + '}'; - }; + /** + Implements some standard methods for comparing objects. Add this mixin to + any class you create that can compare its instances. + + You should implement the `compare()` method. + + @class Comparable + @namespace Ember + @since Ember 0.9 + @private + */ + exports.default = _emberMetal.Mixin.create({ - return CompiledNamedArgs; - })(); + /** + __Required.__ You must implement this method to apply this mixin. + Override to return the result of the comparison of the two parameters. The + compare method should return: + - `-1` if `a < b` + - `0` if `a == b` + - `1` if `a > b` + Default implementation raises an exception. + @method compare + @param a {Object} the first object to compare + @param b {Object} the second object to compare + @return {Number} the result of the comparison + @private + */ + compare: null + }); +}); +enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal', 'container'], function (exports, _emberMetal, _container) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - exports.CompiledNamedArgs = CompiledNamedArgs; - var COMPILED_EMPTY_NAMED_ARGS = new ((function (_CompiledNamedArgs) { - babelHelpers.inherits(_class, _CompiledNamedArgs); + var _containerProxyMixin; - function _class() { - _CompiledNamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + /** + ContainerProxyMixin is used to provide public access to specific + container functionality. + + @class ContainerProxyMixin + @private + */ + var containerProxyMixin = (_containerProxyMixin = { + /** + The container stores state. + @private + @property {Ember.Container} __container__ + */ + __container__: null, - _class.prototype.evaluate = function evaluate(vm) { - return EVALUATED_EMPTY_NAMED_ARGS; - }; + /** + Returns an object that can be used to provide an owner to a + manually created instance. + Example: + ``` + let owner = Ember.getOwner(this); + User.create( + owner.ownerInjection(), + { username: 'rwjblue' } + ) + ``` + @public + @method ownerInjection + @since 2.3.0 + @return {Object} + */ + ownerInjection: function () { + return this.__container__.ownerInjection(); + }, - _class.prototype.toJSON = function toJSON() { - return ''; - }; + /** + Given a fullName return a corresponding instance. + The default behaviour is for lookup to return a singleton instance. + The singleton is scoped to the container, allowing multiple containers + to all have their own locally scoped singletons. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter'); + twitter instanceof Twitter; // => true + // by default the container will return singletons + let twitter2 = container.lookup('api:twitter'); + twitter2 instanceof Twitter; // => true + twitter === twitter2; //=> true + ``` + If singletons are not wanted an optional flag can be provided at lookup. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter', { singleton: false }); + let twitter2 = container.lookup('api:twitter', { singleton: false }); + twitter === twitter2; //=> false + ``` + @public + @method lookup + @param {String} fullName + @param {Object} options + @return {any} + */ + lookup: function (fullName, options) { + return this.__container__.lookup(fullName, options); + }, - return _class; - })(CompiledNamedArgs))(); - exports.COMPILED_EMPTY_NAMED_ARGS = COMPILED_EMPTY_NAMED_ARGS; - - var EvaluatedNamedArgs = (function () { - function EvaluatedNamedArgs(keys, values) { - var _map = arguments.length <= 2 || arguments[2] === undefined ? undefined : arguments[2]; - - this.keys = keys; - this.values = values; - this._map = _map; - this.tag = _glimmerReference.combineTagged(values); - this.length = keys.length; - _glimmerUtil.assert(keys.length === values.length, 'Keys and values do not have the same length'); - } - - EvaluatedNamedArgs.create = function create(map) { - var keys = Object.keys(map); - var length = keys.length; - if (length > 0) { - var values = new Array(length); - for (var i = 0; i < length; i++) { - values[i] = map[keys[i]]; - } - return new this(keys, values, map); - } else { - return EVALUATED_EMPTY_NAMED_ARGS; - } - }; + /** + Given a fullName return the corresponding factory. + @private + @method _lookupFactory + @param {String} fullName + @return {any} + */ + _lookupFactory: function (fullName, options) { + return this.__container__.lookupFactory(fullName, options); + } - EvaluatedNamedArgs.empty = function empty() { - return EVALUATED_EMPTY_NAMED_ARGS; - }; + }, _containerProxyMixin[_container.FACTORY_FOR] = function () { + var _container__; - EvaluatedNamedArgs.prototype.get = function get(key) { - var keys = this.keys; - var values = this.values; + return (_container__ = this.__container__)[_container.FACTORY_FOR].apply(_container__, arguments); + }, _containerProxyMixin[_container.LOOKUP_FACTORY] = function () { + var _container__2; - var index = keys.indexOf(key); - return index === -1 ? _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE : values[index]; - }; + return (_container__2 = this.__container__)[_container.LOOKUP_FACTORY].apply(_container__2, arguments); + }, _containerProxyMixin._resolveLocalLookupName = function (name, source) { + return this.__container__.registry.expandLocalLookup('component:' + name, { + source: source + }); + }, _containerProxyMixin.willDestroy = function () { + this._super.apply(this, arguments); - EvaluatedNamedArgs.prototype.has = function has(key) { - return this.keys.indexOf(key) !== -1; - }; + if (this.__container__) { + _emberMetal.run(this.__container__, 'destroy'); + } + }, _containerProxyMixin); - EvaluatedNamedArgs.prototype.value = function value() { - var keys = this.keys; - var values = this.values; + if (true) { + containerProxyMixin.factoryFor = function ContainerProxyMixin_factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var out = _glimmerUtil.dict(); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var ref = values[i]; - out[key] = ref.value(); - } - return out; - }; + return this.__container__.factoryFor(fullName, options); + }; + } - babelHelpers.createClass(EvaluatedNamedArgs, [{ - key: 'map', - get: function () { - var map = this._map; + exports.default = _emberMetal.Mixin.create(containerProxyMixin); +}); - if (map) { - return map; - } - map = this._map = _glimmerUtil.dict(); - var keys = this.keys; - var values = this.values; - var length = this.length; +/** + Given a name and a source path, resolve the fullName + @private + @method _resolveLocalLookupName + @param {String} fullName + @param {String} source + @return {String} + */ - for (var i = 0; i < length; i++) { - map[keys[i]] = values[i]; - } - return map; - } - }]); - return EvaluatedNamedArgs; - })(); +/** + @private + */ +enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) { + 'use strict'; - exports.EvaluatedNamedArgs = EvaluatedNamedArgs; - var EVALUATED_EMPTY_NAMED_ARGS = new ((function (_EvaluatedNamedArgs) { - babelHelpers.inherits(_class2, _EvaluatedNamedArgs); + /** + @class ControllerMixin + @namespace Ember + @uses Ember.ActionHandler + @private + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, { + /* ducktype as a controller */ + isController: true, - function _class2() { - _EvaluatedNamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_DICT); - } + /** + The object to which actions from the view should be sent. + For example, when a Handlebars template uses the `{{action}}` helper, + it will attempt to send the action to the view's controller's `target`. + By default, the value of the target property is set to the router, and + is injected when a controller is instantiated. This injection is applied + as part of the application's initialization process. In most cases the + `target` property will automatically be set to the logical consumer of + actions for the controller. + @property target + @default null + @public + */ + target: null, - _class2.prototype.get = function get() { - return _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + store: null, - _class2.prototype.has = function has(key) { - return false; - }; + /** + The controller's current model. When retrieving or modifying a controller's + model, this property should be used instead of the `content` property. + @property model + @public + */ + model: null, - _class2.prototype.value = function value() { - return _glimmerRuntimeLibUtils.EMPTY_DICT; - }; + /** + @private + */ + content: _emberMetal.alias('model') - return _class2; - })(EvaluatedNamedArgs))(); - exports.EVALUATED_EMPTY_NAMED_ARGS = EVALUATED_EMPTY_NA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aV07XG4gICAgICBvdXRba2V5XSA9IHJlZi52YWx1ZSgpO1xuICAgIH1cblxuICAgIHJldHVybiBvdXQ7XG4gIH1cbn1cblxuZXhwb3J0IGNvbnN0IEVWQUxVQVRFRF9FTVBUWV9OQU1FRF9BUkdTOiBFdmFsdWF0ZWROYW1lZEFyZ3MgPSBuZXcgKGNsYXNzIGV4dGVuZHMgRXZhbHVhdGVkTmFtZWRBcmdzIHtcbiAgY29uc3RydWN0b3IoKSB7XG4gICAgc3VwZXIoRU1QVFlfQVJSQVksIEVNUFRZX0FSUkFZLCBFTVBUWV9ESUNUKTtcbiAgfVxuXG4gIGdldCgpOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIHJldHVybiBVTkRFRklORURfUkVGRVJFTkNFO1xuICB9XG5cbiAgaGFzKGtleTogc3RyaW5nKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuIGZhbHNlO1xuICB9XG5cbiAgdmFsdWUoKTogRGljdDxPcGFxdWU+IHtcbiAgICByZXR1cm4gRU1QVFlfRElDVDtcbiAgfVxufSk7XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/positional-args', ['exports', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/utils', 'glimmer-reference'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibUtils, _glimmerReference) { - 'use strict'; +enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - var CompiledPositionalArgs = (function () { - function CompiledPositionalArgs(values) { - this.values = values; - this.length = values.length; - } + /* + The ControllerContentModelAliasDeprecation mixin is used to provide a useful + deprecation warning when specifying `content` directly on a `Ember.Controller` + (without also specifying `model`). + + Ember versions prior to 1.7 used `model` as an alias of `content`, but due to + much confusion this alias was reversed (so `content` is now an alias of `model). + + This change reduces many caveats with model/content, and also sets a + simple ground rule: Never set a controllers content, rather always set + its model and ember will do the right thing. + + Used internally by Ember in `Ember.Controller`. + */ + exports.default = _emberMetal.Mixin.create({ + /** + @private + Moves `content` to `model` at extend time if a `model` is not also specified. + Note that this currently modifies the mixin themselves, which is technically + dubious but is practically of little consequence. This may change in the + future. + @method willMergeMixin + @since 1.4.0 + */ + willMergeMixin: function (props) { + // Calling super is only OK here since we KNOW that + // there is another Mixin loaded first. + this._super.apply(this, arguments); - CompiledPositionalArgs.create = function create(values) { - if (values.length) { - return new this(values); - } else { - return COMPILED_EMPTY_POSITIONAL_ARGS; - } - }; + var modelSpecified = !!props.model; - CompiledPositionalArgs.empty = function empty() { - return COMPILED_EMPTY_POSITIONAL_ARGS; - }; + if (props.content && !modelSpecified) { + props.model = props.content; + delete props['content']; - CompiledPositionalArgs.prototype.evaluate = function evaluate(vm) { - var values = this.values; - var length = this.length; + _emberMetal.deprecate('Do not specify `content` on a Controller, use `model` instead.', false, { id: 'ember-runtime.will-merge-mixin', until: '3.0.0' }); + } + } + }); +}); +enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal', 'ember-runtime/mixins/freezable'], function (exports, _emberMetal, _emberRuntimeMixinsFreezable) { + /** + @module ember + @submodule ember-runtime + */ - var references = new Array(length); - for (var i = 0; i < length; i++) { - references[i] = values[i].evaluate(vm); - } - return EvaluatedPositionalArgs.create(references); - }; + 'use strict'; - CompiledPositionalArgs.prototype.toJSON = function toJSON() { - return '[' + this.values.map(function (value) { - return value.toJSON(); - }).join(", ") + ']'; - }; + /** + Implements some standard methods for copying an object. Add this mixin to + any object you create that can create a copy of itself. This mixin is + added automatically to the built-in array. + + You should generally implement the `copy()` method to return a copy of the + receiver. + + Note that `frozenCopy()` will only work if you also implement + `Ember.Freezable`. + + @class Copyable + @namespace Ember + @since Ember 0.9 + @private + */ + exports.default = _emberMetal.Mixin.create({ + /** + __Required.__ You must implement this method to apply this mixin. + Override to return a copy of the receiver. Default implementation raises + an exception. + @method copy + @param {Boolean} deep if `true`, a deep copy of the object should be made + @return {Object} copy of receiver + @private + */ + copy: null, - return CompiledPositionalArgs; - })(); + /** + If the object implements `Ember.Freezable`, then this will return a new + copy if the object is not frozen and the receiver if the object is frozen. + Raises an exception if you try to call this method on a object that does + not support freezing. + You should use this method whenever you want a copy of a freezable object + since a freezable object can simply return itself without actually + consuming more memory. + @method frozenCopy + @return {Object} copy of receiver or receiver + @deprecated Use `Object.freeze` instead. + @private + */ + frozenCopy: function () { + _emberMetal.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.frozen-copy', until: '3.0.0' }); + if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) { + return _emberMetal.get(this, 'isFrozen') ? this : this.copy().freeze(); + } else { + throw new _emberMetal.Error(this + ' does not support freezing'); + } + } + }); +}); +enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'require'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _require) { + /** + @module ember + @submodule ember-runtime + */ - exports.CompiledPositionalArgs = CompiledPositionalArgs; - var COMPILED_EMPTY_POSITIONAL_ARGS = new ((function (_CompiledPositionalArgs) { - babelHelpers.inherits(_class, _CompiledPositionalArgs); + // .......................................................... + // HELPERS + // - function _class() { - _CompiledPositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + 'use strict'; - _class.prototype.evaluate = function evaluate(vm) { - return EVALUATED_EMPTY_POSITIONAL_ARGS; - }; + var _emberA = undefined; - _class.prototype.toJSON = function toJSON() { - return ''; - }; + function emberA() { + return (_emberA || (_emberA = _require.default('ember-runtime/system/native_array').A))(); + } - return _class; - })(CompiledPositionalArgs))(); - exports.COMPILED_EMPTY_POSITIONAL_ARGS = COMPILED_EMPTY_POSITIONAL_ARGS; + var contexts = []; - var EvaluatedPositionalArgs = (function () { - function EvaluatedPositionalArgs(values) { - this.values = values; - this.tag = _glimmerReference.combineTagged(values); - this.length = values.length; - } + function popCtx() { + return contexts.length === 0 ? {} : contexts.pop(); + } - EvaluatedPositionalArgs.create = function create(values) { - return new this(values); - }; + function pushCtx(ctx) { + contexts.push(ctx); + return null; + } - EvaluatedPositionalArgs.empty = function empty() { - return EVALUATED_EMPTY_POSITIONAL_ARGS; - }; + function iter(key, value) { + var valueProvided = arguments.length === 2; - EvaluatedPositionalArgs.prototype.at = function at(index) { - var values = this.values; - var length = this.length; + function i(item) { + var cur = _emberMetal.get(item, key); + return valueProvided ? value === cur : !!cur; + } - return index < length ? values[index] : _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + return i; + } - EvaluatedPositionalArgs.prototype.value = function value() { - var values = this.values; - var length = this.length; + /** + This mixin defines the common interface implemented by enumerable objects + in Ember. Most of these methods follow the standard Array iteration + API defined up to JavaScript 1.8 (excluding language-specific features that + cannot be emulated in older versions of JavaScript). + + This mixin is applied automatically to the Array class on page load, so you + can use any of these methods on simple arrays. If Array already implements + one of these methods, the mixin will not override them. + + ## Writing Your Own Enumerable + + To make your own custom class enumerable, you need two items: + + 1. You must have a length property. This property should change whenever + the number of items in your enumerable object changes. If you use this + with an `Ember.Object` subclass, you should be sure to change the length + property using `set().` + + 2. You must implement `nextObject().` See documentation. + + Once you have these two methods implemented, apply the `Ember.Enumerable` mixin + to your class and you will be able to enumerate the contents of your object + like any other collection. + + ## Using Ember Enumeration with Other Libraries + + Many other libraries provide some kind of iterator or enumeration like + facility. This is often where the most common API conflicts occur. + Ember's API is designed to be as friendly as possible with other + libraries by implementing only methods that mostly correspond to the + JavaScript 1.8 API. + + @class Enumerable + @namespace Ember + @since Ember 0.9 + @private + */ + var Enumerable = _emberMetal.Mixin.create({ - var ret = new Array(length); - for (var i = 0; i < length; i++) { - ret[i] = values[i].value(); - } - return ret; - }; + /** + __Required.__ You must implement this method to apply this mixin. + Implement this method to make your class enumerable. + This method will be called repeatedly during enumeration. The index value + will always begin with 0 and increment monotonically. You don't have to + rely on the index value to determine what object to return, but you should + always check the value and start from the beginning when you see the + requested index is 0. + The `previousObject` is the object that was returned from the last call + to `nextObject` for the current iteration. This is a useful way to + manage iteration if you are tracing a linked list, for example. + Finally the context parameter will always contain a hash you can use as + a "scratchpad" to maintain any other state you need in order to iterate + properly. The context object is reused and is not reset between + iterations so make sure you setup the context with a fresh state whenever + the index parameter is 0. + Generally iterators will continue to call `nextObject` until the index + reaches the current length-1. If you run out of data before this + time for some reason, you should simply return undefined. + The default implementation of this method simply looks up the index. + This works great on any Array-like objects. + @method nextObject + @param {Number} index the current index of the iteration + @param {Object} previousObject the value returned by the last call to + `nextObject`. + @param {Object} context a context object you can use to maintain state. + @return {Object} the next object in the iteration or undefined + @private + */ + nextObject: null, - return EvaluatedPositionalArgs; - })(); + /** + Helper method returns the first object from a collection. This is usually + used by bindings and other parts of the framework to extract a single + object if the enumerable contains only one item. + If you override this method, you should implement it so that it will + always return the same value each time it is called. If your enumerable + contains only one object, this method should always return that object. + If your enumerable is empty, this method should return `undefined`. + ```javascript + let arr = ['a', 'b', 'c']; + arr.get('firstObject'); // 'a' + let arr = []; + arr.get('firstObject'); // undefined + ``` + @property firstObject + @return {Object} the object or undefined + @readOnly + @public + */ + firstObject: _emberMetal.computed('[]', function () { + if (_emberMetal.get(this, 'length') === 0) { + return undefined; + } - exports.EvaluatedPositionalArgs = EvaluatedPositionalArgs; - var EVALUATED_EMPTY_POSITIONAL_ARGS = new ((function (_EvaluatedPositionalArgs) { - babelHelpers.inherits(_class2, _EvaluatedPositionalArgs); + // handle generic enumerables + var context = popCtx(); + var ret = this.nextObject(0, null, context); - function _class2() { - _EvaluatedPositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + pushCtx(context); - _class2.prototype.at = function at() { - return _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + return ret; + }).readOnly(), - _class2.prototype.value = function value() { - return this.values; - }; + /** + Helper method returns the last object from a collection. If your enumerable + contains only one object, this method should always return that object. + If your enumerable is empty, this method should return `undefined`. + ```javascript + let arr = ['a', 'b', 'c']; + arr.get('lastObject'); // 'c' + let arr = []; + arr.get('lastObject'); // undefined + ``` + @property lastObject + @return {Object} the last object or undefined + @readOnly + @public + */ + lastObject: _emberMetal.computed('[]', function () { + var len = _emberMetal.get(this, 'length'); - return _class2; - })(EvaluatedPositionalArgs))(); - exports.EVALUATED_EMPTY_POSITIONAL_ARGS = EVALUATED_EMPTY_POSITIONAL_ARGS; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvcG9zaXRpb25hbC1hcmdzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQU9BLHNCQUFBO0FBZUUsaUJBZkYsc0JBQUEsQ0FlcUIsTUFBb0MsRUFBQTtBQUFwQyxnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQThCO0FBQ3JELGdCQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUM7U0FDN0I7O0FBakJILDhCQUFBLENBQ1MsTUFBTSxHQUFBLGdCQUFDLE1BQW9DLEVBQUE7QUFDaEQsZ0JBQUksTUFBTSxDQUFDLE1BQU0sRUFBRTtBQUNqQix1QkFBTyxJQUFJLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQzthQUN6QixNQUFNO0FBQ0wsdUJBQU8sOEJBQThCLENBQUM7YUFDdkM7U0FDRjs7QUFQSCw4QkFBQSxDQVNTLEtBQUssR0FBQSxpQkFBQTtBQUNWLG1CQUFPLDhCQUE4QixDQUFDO1NBQ3ZDOztBQVhILDhCQUFBLFdBbUJFLFFBQVEsR0FBQSxrQkFBQyxFQUFNLEVBQUE7Z0JBQ1AsTUFBTSxHQUFhLElBQUksQ0FBdkIsTUFBTTtnQkFBRSxNQUFNLEdBQUssSUFBSSxDQUFmLE1BQU07O0FBQ3BCLGdCQUFJLFVBQVUsR0FBNEIsSUFBSSxLQUFLLENBQUMsTUFBTSxDQ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biAgICAgIHJldFtpXSA9IHZhbHVlc1tpXS52YWx1ZSgpO1xuICAgIH1cblxuICAgIHJldHVybiByZXQ7XG4gIH1cbn1cblxuZXhwb3J0IGNvbnN0IEVWQUxVQVRFRF9FTVBUWV9QT1NJVElPTkFMX0FSR1M6IEV2YWx1YXRlZFBvc2l0aW9uYWxBcmdzID0gbmV3IChjbGFzcyBleHRlbmRzIEV2YWx1YXRlZFBvc2l0aW9uYWxBcmdzIHtcbiAgY29uc3RydWN0b3IoKSB7XG4gICAgc3VwZXIoRU1QVFlfQVJSQVkpO1xuICB9XG5cbiAgYXQoKTogUGF0aFJlZmVyZW5jZTxPcGFxdWU+IHtcbiAgICByZXR1cm4gVU5ERUZJTkVEX1JFRkVSRU5DRTtcbiAgfVxuXG4gIHZhbHVlKCk6IE9wYXF1ZVtdIHtcbiAgICByZXR1cm4gdGhpcy52YWx1ZXM7XG4gIH1cbn0pO1xuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/value', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/references'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibReferences) { - 'use strict'; + if (len === 0) { + return undefined; + } - var CompiledValue = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledValue, _CompiledExpression); + var context = popCtx(); + var idx = 0; + var last = null; + var cur = undefined; - function CompiledValue(value) { - _CompiledExpression.call(this); - this.type = "value"; - this.reference = _glimmerRuntimeLibReferences.PrimitiveReference.create(value); - } + do { + last = cur; + cur = this.nextObject(idx++, last, context); + } while (cur !== undefined); - CompiledValue.prototype.evaluate = function evaluate(vm) { - return this.reference; - }; + pushCtx(context); - CompiledValue.prototype.toJSON = function toJSON() { - return JSON.stringify(this.reference.value()); - }; + return last; + }).readOnly(), - return CompiledValue; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + /** + Returns `true` if the passed object can be found in the receiver. The + default version will iterate through the enumerable until the object + is found. You may want to override this with a more efficient version. + ```javascript + let arr = ['a', 'b', 'c']; + arr.contains('a'); // true + arr.contains('z'); // false + ``` + @method contains + @deprecated Use `Enumerable#includes` instead. See http://emberjs.com/deprecations/v2.x#toc_enumerable-contains + @param {Object} obj The object to search for. + @return {Boolean} `true` if object is found in enumerable. + @public + */ + contains: function (obj) { + _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' }); - exports.default = CompiledValue; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvdmFsdWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBSUEsYUFBQTs4QkFBQSxhQUFBOztBQUlFLGlCQUpGLGFBQUEsQ0FJYyxLQUFRLEVBQUE7QUFDbEIsMENBQU8sQ0FBQztBQUpILGdCQUFBLENBQUEsSUFBSSxHQUFHLE9BQU8sQ0FBQztBQUtwQixnQkFBSSxDQUFDLFNBQVMsR0FBRyw2QkFSRCxrQkFBa0IsQ0FRRSxNQUFNLENBQUMsS0FBWSxDQUFDLENBQUM7U0FDMUQ7O0FBUEgscUJBQUEsV0FTRSxRQUFRLEdBQUEsa0JBQUMsRUFBTSxFQUFBO0FBQ2IsbUJBQU8sSUFBSSxDQUFDLFNBQVMsQ0FBQztTQUN2Qjs7QUFYSCxxQkFBQSxXQWFFLE1BQU0sR0FBQSxrQkFBQTtBQUNKLG1CQUFPLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxLQUFLLEVBQUUsQ0FBQyxDQUFDO1NBQy9DOztlQWZILGFBQUE7NkNBSFMsa0JBQWtCOztzQkFHM0IsYUFBQSIsImZpbGUiOiJ2YWx1ZS5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFZNIH0gZnJvbSAnLi4vLi4vdm0nO1xuaW1wb3J0IHsgQ29tcGlsZWRFeHByZXNzaW9uIH0gZnJvbSAnLi4vZXhwcmVzc2lvbnMnO1xuaW1wb3J0IHsgUHJpbWl0aXZlLCBQcmltaXRpdmVSZWZlcmVuY2UgfSBmcm9tICcuLi8uLi9yZWZlcmVuY2VzJztcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgQ29tcGlsZWRWYWx1ZTxUIGV4dGVuZHMgUHJpbWl0aXZlPiBleHRlbmRzIENvbXBpbGVkRXhwcmVzc2lvbjxUPiB7XG4gIHB1YmxpYyB0eXBlID0gXCJ2YWx1ZVwiO1xuICBwcml2YXRlIHJlZmVyZW5jZTogUHJpbWl0aXZlUmVmZXJlbmNlPFQ+O1xuXG4gIGNvbnN0cnVjdG9yKHZhbHVlOiBUKSB7XG4gICAgc3VwZXIoKTtcbiAgICB0aGlzLnJlZmVyZW5jZSA9IFByaW1pdGl2ZVJlZmVyZW5jZS5jcmVhdGUodmFsdWUgYXMgYW55KTtcbiAgfVxuXG4gIGV2YWx1YXRlKHZtOiBWTSk6IFByaW1pdGl2ZVJlZmVyZW5jZTxUPiB7XG4gICAgcmV0dXJuIHRoaXMucmVmZXJlbmNlO1xuICB9XG5cbiAgdG9KU09OKCk6IHN0cmluZyB7XG4gICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHRoaXMucmVmZXJlbmNlLnZhbHVlKCkpO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/opcodes/builder', ['exports', 'glimmer-runtime/lib/compiled/opcodes/component', 'glimmer-runtime/lib/compiled/opcodes/partial', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/compiled/opcodes/dom', 'glimmer-runtime/lib/compiled/opcodes/lists', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-util', 'glimmer-runtime/lib/utils'], function (exports, _glimmerRuntimeLibCompiledOpcodesComponent, _glimmerRuntimeLibCompiledOpcodesPartial, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibCompiledOpcodesDom, _glimmerRuntimeLibCompiledOpcodesLists, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerUtil, _glimmerRuntimeLibUtils) { - 'use strict'; + var found = this.find(function (item) { + return item === obj; + }); - var StatementCompilationBufferProxy = (function () { - function StatementCompilationBufferProxy(inner) { - this.inner = inner; - } + return found !== undefined; + }, - StatementCompilationBufferProxy.prototype.toOpSeq = function toOpSeq() { - return this.inner.toOpSeq(); - }; + /** + Iterates through the enumerable, calling the passed function on each + item. This method corresponds to the `forEach()` method defined in + JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method forEach + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Object} receiver + @public + */ + forEach: function (callback, target) { + if (typeof callback !== 'function') { + throw new TypeError(); + } - StatementCompilationBufferProxy.prototype.append = function append(opcode) { - this.inner.append(opcode); - }; + var context = popCtx(); + var len = _emberMetal.get(this, 'length'); + var last = null; - StatementCompilationBufferProxy.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.inner.getLocalSymbol(name); - }; + if (target === undefined) { + target = null; + } - StatementCompilationBufferProxy.prototype.hasLocalSymbol = function hasLocalSymbol(name) { - return this.inner.hasLocalSymbol(name); - }; + for (var idx = 0; idx < len; idx++) { + var next = this.nextObject(idx, last, context); + callback.call(target, next, idx, this); + last = next; + } - StatementCompilationBufferProxy.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.inner.getNamedSymbol(name); - }; + last = null; + context = pushCtx(context); - StatementCompilationBufferProxy.prototype.hasNamedSymbol = function hasNamedSymbol(name) { - return this.inner.hasNamedSymbol(name); - }; + return this; + }, - StatementCompilationBufferProxy.prototype.getBlockSymbol = function getBlockSymbol(name) { - return this.inner.getBlockSymbol(name); - }; + /** + Alias for `mapBy` + @method getEach + @param {String} key name of the property + @return {Array} The mapped array. + @public + */ + getEach: _emberMetal.aliasMethod('mapBy'), - StatementCompilationBufferProxy.prototype.hasBlockSymbol = function hasBlockSymbol(name) { - return this.inner.hasBlockSymbol(name); - }; + /** + Sets the value on the named property for each member. This is more + ergonomic than using other methods defined on this helper. If the object + implements Ember.Observable, the value will be changed to `set(),` otherwise + it will be set directly. `null` objects are skipped. + @method setEach + @param {String} key The key to set + @param {Object} value The object to set + @return {Object} receiver + @public + */ + setEach: function (key, value) { + return this.forEach(function (item) { + return _emberMetal.set(item, key, value); + }); + }, - StatementCompilationBufferProxy.prototype.getPartialArgsSymbol = function getPartialArgsSymbol() { - return this.inner.getPartialArgsSymbol(); - }; + /** + Maps all of the items in the enumeration to another value, returning + a new array. This method corresponds to `map()` defined in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the mapped value. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method map + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} The mapped array. + @public + */ + map: function (callback, target) { + var ret = emberA(); - StatementCompilationBufferProxy.prototype.hasPartialArgsSymbol = function hasPartialArgsSymbol() { - return this.inner.hasPartialArgsSymbol(); - }; + this.forEach(function (x, idx, i) { + return ret[idx] = callback.call(target, x, idx, i); + }); - babelHelpers.createClass(StatementCompilationBufferProxy, [{ - key: 'component', - get: function () { - return this.inner.component; - } - }]); - return StatementCompilationBufferProxy; - })(); + return ret; + }, - exports.StatementCompilationBufferProxy = StatementCompilationBufferProxy; + /** + Similar to map, this specialized function returns the value of the named + property on all items in the enumeration. + @method mapBy + @param {String} key name of the property + @return {Array} The mapped array. + @public + */ + mapBy: function (key) { + return this.map(function (next) { + return _emberMetal.get(next, key); + }); + }, - var BasicOpcodeBuilder = (function (_StatementCompilationBufferProxy) { - babelHelpers.inherits(BasicOpcodeBuilder, _StatementCompilationBufferProxy); + /** + Returns an array with all of the items in the enumeration that the passed + function returns true for. This method corresponds to `filter()` defined in + JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method filter + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} A filtered array. + @public + */ + filter: function (callback, target) { + var ret = emberA(); - function BasicOpcodeBuilder(inner, symbolTable, env) { - _StatementCompilationBufferProxy.call(this, inner); - this.symbolTable = symbolTable; - this.env = env; - this.labelsStack = new _glimmerUtil.Stack(); + this.forEach(function (x, idx, i) { + if (callback.call(target, x, idx, i)) { + ret.push(x); } + }); - // helpers + return ret; + }, - BasicOpcodeBuilder.prototype.startLabels = function startLabels() { - this.labelsStack.push(_glimmerUtil.dict()); - }; + /** + Returns an array with all of the items in the enumeration where the passed + function returns false. This method is the inverse of filter(). + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - *item* is the current item in the iteration. + - *index* is the current index in the iteration + - *enumerable* is the enumerable object itself. + It should return a falsey value to include the item in the results. + Note that in addition to a callback, you can also pass an optional target + object that will be set as "this" on the context. This is a good way + to give your iterator function access to the current object. + @method reject + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} A rejected array. + @public + */ + reject: function (callback, target) { + return this.filter(function () { + return !callback.apply(target, arguments); + }); + }, - BasicOpcodeBuilder.prototype.stopLabels = function stopLabels() { - this.labelsStack.pop(); - }; + /** + Returns an array with just the items with the matched property. You + can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to `true`. + @method filterBy + @param {String} key the property to test + @param {*} [value] optional value to test against. + @return {Array} filtered array + @public + */ + filterBy: function (key, value) { + return this.filter(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.labelFor = function labelFor(name) { - var labels = this.labels; - var label = labels[name]; - if (!label) { - label = labels[name] = new _glimmerRuntimeLibCompiledOpcodesVm.LabelOpcode(name); - } - return label; - }; + /** + Returns an array with the items that do not have truthy values for + key. You can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to false. + @method rejectBy + @param {String} key the property to test + @param {String} [value] optional value to test against. + @return {Array} rejected array + @public + */ + rejectBy: function (key, value) { + var exactValue = function (item) { + return _emberMetal.get(item, key) === value; + }; + var hasValue = function (item) { + return !!_emberMetal.get(item, key); + }; + var use = arguments.length === 2 ? exactValue : hasValue; - // partials + return this.reject(use); + }, - BasicOpcodeBuilder.prototype.putPartialDefinition = function putPartialDefinition(definition) { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.PutPartialDefinitionOpcode(definition)); - }; + /** + Returns the first item in the array for which the callback returns true. + This method works similar to the `filter()` method defined in JavaScript 1.6 + except that it will stop working on the array once a match is found. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method find + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Object} Found item or `undefined`. + @public + */ + find: function (callback, target) { + var len = _emberMetal.get(this, 'length'); - BasicOpcodeBuilder.prototype.putDynamicPartialDefinition = function putDynamicPartialDefinition() { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.PutDynamicPartialDefinitionOpcode(this.symbolTable)); - }; + if (target === undefined) { + target = null; + } - BasicOpcodeBuilder.prototype.evaluatePartial = function evaluatePartial() { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.EvaluatePartialOpcode(this.symbolTable)); - }; + var context = popCtx(); + var found = false; + var last = null; + var next = undefined, + ret = undefined; - // components + for (var idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); - BasicOpcodeBuilder.prototype.putComponentDefinition = function putComponentDefinition(definition) { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutComponentDefinitionOpcode(definition)); - }; + found = callback.call(target, next, idx, this); + if (found) { + ret = next; + } - BasicOpcodeBuilder.prototype.putDynamicComponentDefinition = function putDynamicComponentDefinition() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutDynamicComponentDefinitionOpcode()); - }; + last = next; + } - BasicOpcodeBuilder.prototype.openComponent = function openComponent(args) { - var shadow = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[1]; + next = last = null; + context = pushCtx(context); - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.OpenComponentOpcode(this.compile(args), shadow)); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.didCreateElement = function didCreateElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.DidCreateElementOpcode()); - }; + /** + Returns the first item with a property matching the passed value. You + can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to `true`. + This method works much like the more generic `find()` method. + @method findBy + @param {String} key the property to test + @param {String} [value] optional value to test against. + @return {Object} found item or `undefined` + @public + */ + findBy: function (key, value) { + return this.find(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.shadowAttributes = function shadowAttributes() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.ShadowAttributesOpcode()); - }; + /** + Returns `true` if the passed function returns true for every item in the + enumeration. This corresponds with the `every()` method in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` or `false`. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + Example Usage: + ```javascript + if (people.every(isEngineer)) { + Paychecks.addBigBonus(); + } + ``` + @method every + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Boolean} + @public + */ + every: function (callback, target) { + return !this.find(function (x, idx, i) { + return !callback.call(target, x, idx, i); + }); + }, - BasicOpcodeBuilder.prototype.didRenderLayout = function didRenderLayout() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.DidRenderLayoutOpcode()); - }; + /** + Returns `true` if the passed property resolves to the value of the second + argument for all items in the enumerable. This method is often simpler/faster + than using a callback. + @method isEvery + @param {String} key the property to test + @param {String} [value] optional value to test against. Defaults to `true` + @return {Boolean} + @since 1.3.0 + @public + */ + isEvery: function (key, value) { + return this.every(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.closeComponent = function closeComponent() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.CloseComponentOpcode()); - }; + /** + Returns `true` if the passed function returns true for any item in the + enumeration. This corresponds with the `some()` method in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + Usage Example: + ```javascript + if (people.any(isManager)) { + Paychecks.addBiggerBonus(); + } + ``` + @method any + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Boolean} `true` if the passed function returns `true` for any item + @public + */ + any: function (callback, target) { + var len = _emberMetal.get(this, 'length'); + var context = popCtx(); + var found = false; + var last = null; + var next = undefined; - // content + if (target === undefined) { + target = null; + } - BasicOpcodeBuilder.prototype.cautiousAppend = function cautiousAppend() { - this.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedCautiousAppendOpcode()); - }; + for (var idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); + found = callback.call(target, next, idx, this); + last = next; + } - BasicOpcodeBuilder.prototype.trustingAppend = function trustingAppend() { - this.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedTrustingAppendOpcode()); - }; + next = last = null; + context = pushCtx(context); + return found; + }, - // dom + /** + Returns `true` if the passed property resolves to the value of the second + argument for any item in 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. Defaults to `true` + @return {Boolean} + @since 1.3.0 + @public + */ + isAny: function (key, value) { + return this.any(iter.apply(this, arguments)); + }, - BasicOpcodeBuilder.prototype.text = function text(_text) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.TextOpcode(_text)); - }; + /** + This will combine the values of the enumerator into a single value. It + is a useful way to collect a summary value from an enumeration. This + corresponds to the `reduce()` method defined in JavaScript 1.8. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(previousValue, item, index, enumerable); + ``` + - `previousValue` is the value returned by the last call to the iterator. + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + Return the new cumulative value. + In addition to the callback you can also pass an `initialValue`. An error + will be raised if you do not pass an initial value and the enumerator is + empty. + Note that unlike the other methods, this method does not allow you to + pass a target object to set as this for the callback. It's part of the + spec. Sorry. + @method reduce + @param {Function} callback The callback to execute + @param {Object} initialValue Initial value for the reduce + @param {String} reducerProperty internal use only. + @return {Object} The reduced value. + @public + */ + reduce: function (callback, initialValue, reducerProperty) { + if (typeof callback !== 'function') { + throw new TypeError(); + } - BasicOpcodeBuilder.prototype.openPrimitiveElement = function openPrimitiveElement(tag) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(tag)); - }; + var ret = initialValue; - BasicOpcodeBuilder.prototype.openComponentElement = function openComponentElement(tag) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenComponentElementOpcode(tag)); - }; + this.forEach(function (item, i) { + ret = callback(ret, item, i, this, reducerProperty); + }, this); - BasicOpcodeBuilder.prototype.openDynamicPrimitiveElement = function openDynamicPrimitiveElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenDynamicPrimitiveElementOpcode()); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.flushElement = function flushElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.FlushElementOpcode()); - }; + /** + Invokes the named method on every object in the receiver that + implements it. This method corresponds to the implementation in + Prototype 1.6. + @method invoke + @param {String} methodName the name of the method + @param {Object...} args optional arguments to pass as well. + @return {Array} return values from calling invoke. + @public + */ + invoke: function (methodName) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - BasicOpcodeBuilder.prototype.closeElement = function closeElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.CloseElementOpcode()); - }; + var ret = emberA(); - BasicOpcodeBuilder.prototype.staticAttr = function staticAttr(name, namespace, value) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.StaticAttrOpcode(name, namespace, value)); - }; + this.forEach(function (x, idx) { + var method = x && x[methodName]; - BasicOpcodeBuilder.prototype.dynamicAttrNS = function dynamicAttrNS(name, namespace, isTrusting) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrNSOpcode(name, namespace, isTrusting)); - }; + if ('function' === typeof method) { + ret[idx] = args ? method.apply(x, args) : x[methodName](); + } + }, this); - BasicOpcodeBuilder.prototype.dynamicAttr = function dynamicAttr(name, isTrusting) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrOpcode(name, isTrusting)); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.comment = function comment(_comment) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.CommentOpcode(_comment)); - }; + /** + Simply converts the enumerable into a genuine array. The order is not + guaranteed. Corresponds to the method implemented by Prototype. + @method toArray + @return {Array} the enumerable as an array. + @public + */ + toArray: function () { + var ret = emberA(); - // lists + this.forEach(function (o, idx) { + return ret[idx] = o; + }); - BasicOpcodeBuilder.prototype.putIterator = function putIterator() { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.PutIteratorOpcode()); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.enterList = function enterList(start, end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.EnterListOpcode(this.labelFor(start), this.labelFor(end))); - }; + /** + Returns a copy of the array with all `null` and `undefined` elements removed. + ```javascript + let arr = ['a', null, 'c', undefined]; + arr.compact(); // ['a', 'c'] + ``` + @method compact + @return {Array} the array without null and undefined elements. + @public + */ + compact: function () { + return this.filter(function (value) { + return value != null; + }); + }, - BasicOpcodeBuilder.prototype.exitList = function exitList() { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.ExitListOpcode()); - }; + /** + Returns a new enumerable that excludes the passed value. The default + implementation returns an array regardless of the receiver type. + If the receiver does not contain the value it returns the original enumerable. + ```javascript + let arr = ['a', 'b', 'a', 'c']; + arr.without('a'); // ['b', 'c'] + ``` + @method without + @param {Object} value + @return {Ember.Enumerable} + @public + */ + without: function (value) { + if (!this.includes(value)) { + return this; // nothing to do + } - BasicOpcodeBuilder.prototype.enterWithKey = function enterWithKey(start, end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.EnterWithKeyOpcode(this.labelFor(start), this.labelFor(end))); - }; + var ret = emberA(); - BasicOpcodeBuilder.prototype.nextIter = function nextIter(end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.NextIterOpcode(this.labelFor(end))); - }; + this.forEach(function (k) { + // SameValueZero comparison (NaN !== NaN) + if (!(k === value || k !== k && value !== value)) { + ret[ret.length] = k; + } + }); - // vm + return ret; + }, - BasicOpcodeBuilder.prototype.pushRemoteElement = function pushRemoteElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PushRemoteElementOpcode()); - }; + /** + Returns a new enumerable that contains only unique values. The default + implementation returns an array regardless of the receiver type. + ```javascript + let arr = ['a', 'a', 'b', 'b']; + arr.uniq(); // ['a', 'b'] + ``` + This only works on primitive data types, e.g. Strings, Numbers, etc. + @method uniq + @return {Ember.Enumerable} + @public + */ + uniq: function () { + var ret = emberA(); + + this.forEach(function (k) { + if (ret.indexOf(k) < 0) { + ret.push(k); + } + }); - BasicOpcodeBuilder.prototype.popRemoteElement = function popRemoteElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PopRemoteElementOpcode()); - }; + return ret; + }, - BasicOpcodeBuilder.prototype.popElement = function popElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PopElementOpcode()); - }; + /** + This property will trigger anytime the enumerable's content changes. + You can observe this property to be notified of changes to the enumerable's + content. + For plain enumerables, this property is read only. `Array` overrides + this method. + @property [] + @type Array + @return this + @private + */ + '[]': _emberMetal.computed({ + get: function (key) { + return this; + } + }), - BasicOpcodeBuilder.prototype.label = function label(name) { - this.append(this.labelFor(name)); - }; + // .......................................................... + // ENUMERABLE OBSERVERS + // - BasicOpcodeBuilder.prototype.pushChildScope = function pushChildScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PushChildScopeOpcode()); - }; + /** + Registers an enumerable observer. Must implement `Ember.EnumerableObserver` + mixin. + @method addEnumerableObserver + @param {Object} target + @param {Object} [opts] + @return this + @private + */ + addEnumerableObserver: function (target, opts) { + var willChange = opts && opts.willChange || 'enumerableWillChange'; + var didChange = opts && opts.didChange || 'enumerableDidChange'; + var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); - BasicOpcodeBuilder.prototype.popScope = function popScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PopScopeOpcode()); - }; + if (!hasObservers) { + _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.pushDynamicScope = function pushDynamicScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PushDynamicScopeOpcode()); - }; + _emberMetal.addListener(this, '@enumerable:before', target, willChange); + _emberMetal.addListener(this, '@enumerable:change', target, didChange); - BasicOpcodeBuilder.prototype.popDynamicScope = function popDynamicScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PopDynamicScopeOpcode()); - }; + if (!hasObservers) { + _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.putNull = function putNull() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutNullOpcode()); - }; + return this; + }, - BasicOpcodeBuilder.prototype.putValue = function putValue(expression) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(this.compile(expression))); - }; + /** + Removes a registered enumerable observer. + @method removeEnumerableObserver + @param {Object} target + @param {Object} [opts] + @return this + @private + */ + removeEnumerableObserver: function (target, opts) { + var willChange = opts && opts.willChange || 'enumerableWillChange'; + var didChange = opts && opts.didChange || 'enumerableDidChange'; + var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); - BasicOpcodeBuilder.prototype.putArgs = function putArgs(args) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutArgsOpcode(this.compile(args))); - }; + if (hasObservers) { + _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.bindDynamicScope = function bindDynamicScope(names) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindDynamicScopeOpcode(names)); - }; + _emberMetal.removeListener(this, '@enumerable:before', target, willChange); + _emberMetal.removeListener(this, '@enumerable:change', target, didChange); - BasicOpcodeBuilder.prototype.bindPositionalArgs = function bindPositionalArgs(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindPositionalArgsOpcode(names, symbols)); - }; + if (hasObservers) { + _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); + } - BasicOpcodeBuilder.prototype.bindNamedArgs = function bindNamedArgs(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindNamedArgsOpcode(names, symbols)); - }; + return this; + }, - BasicOpcodeBuilder.prototype.bindBlocks = function bindBlocks(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindBlocksOpcode(names, symbols)); - }; + /** + Becomes true whenever the array currently has observers watching changes + on the array. + @property hasEnumerableObservers + @type Boolean + @private + */ + hasEnumerableObservers: _emberMetal.computed(function () { + return _emberMetal.hasListeners(this, '@enumerable:change') || _emberMetal.hasListeners(this, '@enumerable:before'); + }), - BasicOpcodeBuilder.prototype.enter = function enter(_enter, exit) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.EnterOpcode(this.labelFor(_enter), this.labelFor(exit))); - }; + /** + Invoke this method just before the contents of your enumerable will + change. You can either omit the parameters completely or pass the objects + to be removed or added if available or just a count. + @method enumerableContentWillChange + @param {Ember.Enumerable|Number} removing An enumerable of the objects to + be removed or the number of items to be removed. + @param {Ember.Enumerable|Number} adding An enumerable of the objects to be + added or the number of items to be added. + @chainable + @private + */ + enumerableContentWillChange: function (removing, adding) { + var removeCnt = undefined, + addCnt = undefined, + hasDelta = undefined; - BasicOpcodeBuilder.prototype.exit = function exit() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.ExitOpcode()); - }; + if ('number' === typeof removing) { + removeCnt = removing; + } else if (removing) { + removeCnt = _emberMetal.get(removing, 'length'); + } else { + removeCnt = removing = -1; + } - BasicOpcodeBuilder.prototype.evaluate = function evaluate(name, block) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.EvaluateOpcode(name, block)); - }; + if ('number' === typeof adding) { + addCnt = adding; + } else if (adding) { + addCnt = _emberMetal.get(adding, 'length'); + } else { + addCnt = adding = -1; + } - BasicOpcodeBuilder.prototype.test = function test(testFunc) { - if (testFunc === 'const') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.ConstTest)); - } else if (testFunc === 'simple') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.SimpleTest)); - } else if (testFunc === 'environment') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.EnvironmentTest)); - } else if (typeof testFunc === 'function') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(testFunc)); - } else { - throw new Error('unreachable'); - } - }; + hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; - BasicOpcodeBuilder.prototype.jump = function jump(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpOpcode(this.labelFor(target))); - }; + if (removing === -1) { + removing = null; + } - BasicOpcodeBuilder.prototype.jumpIf = function jumpIf(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpIfOpcode(this.labelFor(target))); - }; + if (adding === -1) { + adding = null; + } - BasicOpcodeBuilder.prototype.jumpUnless = function jumpUnless(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpUnlessOpcode(this.labelFor(target))); - }; + _emberMetal.propertyWillChange(this, '[]'); - babelHelpers.createClass(BasicOpcodeBuilder, [{ - key: 'labels', - get: function () { - return this.labelsStack.current; - } - }]); - return BasicOpcodeBuilder; - })(StatementCompilationBufferProxy); + if (hasDelta) { + _emberMetal.propertyWillChange(this, 'length'); + } - exports.BasicOpcodeBuilder = BasicOpcodeBuilder; + _emberMetal.sendEvent(this, '@enumerable:before', [this, removing, adding]); - function isCompilableExpression(expr) { - return expr && typeof expr['compile'] === 'function'; - } + return this; + }, - var OpcodeBuilder = (function (_BasicOpcodeBuilder) { - babelHelpers.inherits(OpcodeBuilder, _BasicOpcodeBuilder); + /** + Invoke this method when the contents of your enumerable has changed. + This will notify any observers watching for content changes. If you are + implementing an ordered enumerable (such as an array), also pass the + start and end values where the content changed so that it can be used to + notify range observers. + @method enumerableContentDidChange + @param {Ember.Enumerable|Number} removing An enumerable of the objects to + be removed or the number of items to be removed. + @param {Ember.Enumerable|Number} adding An enumerable of the objects to + be added or the number of items to be added. + @chainable + @private + */ + enumerableContentDidChange: function (removing, adding) { + var removeCnt = undefined, + addCnt = undefined, + hasDelta = undefined; - function OpcodeBuilder() { - _BasicOpcodeBuilder.apply(this, arguments); - } + if ('number' === typeof removing) { + removeCnt = removing; + } else if (removing) { + removeCnt = _emberMetal.get(removing, 'length'); + } else { + removeCnt = removing = -1; + } - OpcodeBuilder.prototype.compile = function compile(expr) { - if (isCompilableExpression(expr)) { - return expr.compile(this, this.env, this.symbolTable); - } else { - return expr; - } - }; + if ('number' === typeof adding) { + addCnt = adding; + } else if (adding) { + addCnt = _emberMetal.get(adding, 'length'); + } else { + addCnt = adding = -1; + } - OpcodeBuilder.prototype.bindPositionalArgsForBlock = function bindPositionalArgsForBlock(block) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindPositionalArgsOpcode.create(block)); - }; + hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; - OpcodeBuilder.prototype.preludeForLayout = function preludeForLayout(layout) { - if (layout.hasNamedParameters) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindNamedArgsOpcode.create(layout)); - } - if (layout.hasYields || layout.hasPartials) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindCallerScopeOpcode()); - } - if (layout.hasYields) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindBlocksOpcode.create(layout)); - } - if (layout.hasPartials) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindPartialArgsOpcode.create(layout)); - } - }; + if (removing === -1) { + removing = null; + } - // TODO - // come back to this - - OpcodeBuilder.prototype.block = function block(args, callback) { - if (args) this.putArgs(args); - this.startLabels(); - this.enter('BEGIN', 'END'); - this.label('BEGIN'); - callback(this, 'BEGIN', 'END'); - this.label('END'); - this.exit(); - this.stopLabels(); - }; + if (adding === -1) { + adding = null; + } - // TODO - // come back to this - - OpcodeBuilder.prototype.iter = function iter(callback) { - this.startLabels(); - this.enterList('BEGIN', 'END'); - this.label('ITER'); - this.nextIter('BREAK'); - this.enterWithKey('BEGIN', 'END'); - this.label('BEGIN'); - callback(this, 'BEGIN', 'END'); - this.label('END'); - this.exit(); - this.jump('ITER'); - this.label('BREAK'); - this.exitList(); - this.stopLabels(); - }; + _emberMetal.sendEvent(this, '@enumerable:change', [this, removing, adding]); - // TODO - // come back to this + if (hasDelta) { + _emberMetal.propertyDidChange(this, 'length'); + } - OpcodeBuilder.prototype.unit = function unit(callback) { - this.startLabels(); - callback(this); - this.stopLabels(); - }; + _emberMetal.propertyDidChange(this, '[]'); - return OpcodeBuilder; - })(BasicOpcodeBuilder); + return this; + }, - exports.default = OpcodeBuilder; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQXlCQSwrQkFBQTtBQUVFLGlCQUZGLCtCQUFBLENBRXdCLEtBQWlDLEVBQUE7QUFBakMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUE0QjtTQUFJOztBQUY3RCx1Q0FBQSxXQVFFLE9BQU8sR0FBQSxtQkFBQTtBQUNMLG1CQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsT0FBTyxFQUFFLENBQUM7U0FDN0I7O0FBVkgsdUNBQUEsV0FZRSxNQUFNLEdBQUEsZ0JBQW1CLE1BQVMsRUFBQTtBQUNoQyxnQkFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUM7U0FDM0I7O0FBZEgsdUNBQUEsV0FnQkUsY0FBYyxHQUFBLHdCQUFDLElBQVksRUFBQTtBQUN6QixtQkFBTyxJQUFJLENBQUMsS0FBSyxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsQ0FBQztTQUN4Qzs7QUFsQkgsdUNBQUEsV0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QnVpbGRlciwgQkVHSU46IExhYmVsLCBFTkQ6IExhYmVsKSA9PiB2b2lkO1xuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/component', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-reference'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerReference) { - 'use strict'; + /** + Converts the enumerable into an array and sorts by the keys + specified in the argument. + You may provide multiple arguments to sort by multiple properties. + @method sortBy + @param {String} property name(s) to sort on + @return {Array} The sorted array. + @since 1.2.0 + @public + */ + sortBy: function () { + var sortKeys = arguments; - var PutDynamicComponentDefinitionOpcode = (function (_Opcode) { - babelHelpers.inherits(PutDynamicComponentDefinitionOpcode, _Opcode); + return this.toArray().sort(function (a, b) { + for (var i = 0; i < sortKeys.length; i++) { + var key = sortKeys[i]; + var propA = _emberMetal.get(a, key); + var propB = _emberMetal.get(b, key); + // return 1 or -1 else continue to the next sortKey + var compareValue = _emberRuntimeCompare.default(propA, propB); - function PutDynamicComponentDefinitionOpcode() { - _Opcode.apply(this, arguments); - this.type = "put-dynamic-component-definition"; + if (compareValue) { + return compareValue; + } } + return 0; + }); + }, - PutDynamicComponentDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var definition = cache ? cache.peek() : reference.value(); - vm.frame.setImmediate(definition); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; - - PutDynamicComponentDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + /** + Returns a new enumerable that contains only items containing a unique property value. + The default implementation returns an array regardless of the receiver type. + ```javascript + let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; + arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] + ``` + @method uniqBy + @return {Ember.Enumerable} + @public + */ - return PutDynamicComponentDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + uniqBy: function (key) { + var ret = emberA(); + var seen = new _emberUtils.EmptyObject(); - exports.PutDynamicComponentDefinitionOpcode = PutDynamicComponentDefinitionOpcode; + this.forEach(function (item) { + var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); + if (!(guid in seen)) { + seen[guid] = true; + ret.push(item); + } + }); - var PutComponentDefinitionOpcode = (function (_Opcode2) { - babelHelpers.inherits(PutComponentDefinitionOpcode, _Opcode2); + return ret; + }, - function PutComponentDefinitionOpcode(definition) { - _Opcode2.call(this); - this.definition = definition; - this.type = "put-component-definition"; - } + /** + Returns `true` if the passed object can be found in the enumerable. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, undefined].includes(undefined); // true + [1, 2, null].includes(null); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @return {Boolean} `true` if object is found in the enumerable. + @public + */ + includes: function (obj) { + _emberMetal.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1); - PutComponentDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setImmediate(this.definition); - }; + var len = _emberMetal.get(this, 'length'); + var idx = undefined, + next = undefined; + var last = null; + var found = false; - PutComponentDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.definition.name)] - }; - }; + var context = popCtx(); - return PutComponentDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PutComponentDefinitionOpcode = PutComponentDefinitionOpcode; - - var OpenComponentOpcode = (function (_Opcode3) { - babelHelpers.inherits(OpenComponentOpcode, _Opcode3); - - function OpenComponentOpcode(args, shadow) { - _Opcode3.call(this); - this.args = args; - this.shadow = shadow; - this.type = "open-component"; - } - - OpenComponentOpcode.prototype.evaluate = function evaluate(vm) { - var rawArgs = this.args; - var shadow = this.shadow; - - var definition = vm.frame.getImmediate(); - var dynamicScope = vm.pushDynamicScope(); - var callerScope = vm.scope(); - var manager = definition.manager; - var args = manager.prepareArgs(definition, rawArgs.evaluate(vm), dynamicScope); - var hasDefaultBlock = !!args.blocks.default; // TODO Cleanup? - var component = manager.create(vm.env, definition, args, dynamicScope, vm.getSelf(), hasDefaultBlock); - var destructor = manager.getDestructor(component); - if (destructor) vm.newDestroyable(destructor); - var layout = manager.layoutFor(definition, component, vm.env); - var selfRef = manager.getSelf(component); - vm.beginCacheGroup(); - vm.stack().pushSimpleBlock(); - vm.pushRootScope(selfRef, layout.symbols); - vm.invokeLayout(args, layout, callerScope, component, manager, shadow); - vm.updateWith(new UpdateComponentOpcode(definition.name, component, manager, args, dynamicScope)); - }; + for (idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); - OpenComponentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + found = obj === next || obj !== obj && next !== next; - return OpenComponentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.OpenComponentOpcode = OpenComponentOpcode; - - var UpdateComponentOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateComponentOpcode, _UpdatingOpcode); - - function UpdateComponentOpcode(name, component, manager, args, dynamicScope) { - _UpdatingOpcode.call(this); - this.name = name; - this.component = component; - this.manager = manager; - this.args = args; - this.dynamicScope = dynamicScope; - this.type = "update-component"; - var componentTag = manager.getTag(component); - if (componentTag) { - this.tag = _glimmerReference.combine([args.tag, componentTag]); - } else { - this.tag = args.tag; - } - } + last = next; + } - UpdateComponentOpcode.prototype.evaluate = function evaluate(vm) { - var component = this.component; - var manager = this.manager; - var args = this.args; - var dynamicScope = this.dynamicScope; + next = last = null; + context = pushCtx(context); - manager.update(component, args, dynamicScope); - }; + return found; + } + }); - UpdateComponentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.name)] - }; - }; + exports.default = Enumerable; +}); +enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - return UpdateComponentOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + @module ember + @submodule ember-runtime + */ - exports.UpdateComponentOpcode = UpdateComponentOpcode; + /** + This mixin allows for Ember objects to subscribe to and emit events. + + ```javascript + App.Person = Ember.Object.extend(Ember.Evented, { + greet: function() { + // ... + this.trigger('greet'); + } + }); + + var person = App.Person.create(); + + person.on('greet', function() { + console.log('Our person has greeted'); + }); + + person.greet(); + + // outputs: 'Our person has greeted' + ``` + + You can also chain multiple event subscriptions: + + ```javascript + person.on('greet', function() { + console.log('Our person has greeted'); + }).one('greet', function() { + console.log('Offer one-time special'); + }).off('event', this, forgetThis); + ``` + + @class Evented + @namespace Ember + @public + */ + exports.default = _emberMetal.Mixin.create({ - var DidCreateElementOpcode = (function (_Opcode4) { - babelHelpers.inherits(DidCreateElementOpcode, _Opcode4); + /** + Subscribes to a named event with given function. + ```javascript + person.on('didLoad', function() { + // fired once the person has loaded + }); + ``` + An optional target can be passed in as the 2nd argument that will + be set as the "this" for the callback. This is a good way to give your + function access to the object triggering the event. When the target + parameter is used the callback becomes the third argument. + @method on + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute + @return this + @public + */ + on: function (name, target, method) { + _emberMetal.addListener(this, name, target, method); + return this; + }, - function DidCreateElementOpcode() { - _Opcode4.apply(this, arguments); - this.type = "did-create-element"; - } + /** + Subscribes a function to a named event and then cancels the subscription + after the first time the event is triggered. It is good to use ``one`` when + you only care about the first time an event has taken place. + This function takes an optional 2nd argument that will become the "this" + value for the callback. If this argument is passed then the 3rd argument + becomes the function. + @method one + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute + @return this + @public + */ + one: function (name, target, method) { + if (!method) { + method = target; + target = null; + } - // Slow path for non-specialized component invocations. Uses an internal - // named lookup on the args. + _emberMetal.addListener(this, name, target, method, true); + return this; + }, - DidCreateElementOpcode.prototype.evaluate = function evaluate(vm) { - var manager = vm.frame.getManager(); - var component = vm.frame.getComponent(); - manager.didCreateElement(component, vm.stack().constructing, vm.stack().operations); - }; + /** + Triggers a named event for the object. Any additional arguments + will be passed as parameters to the functions that are subscribed to the + event. + ```javascript + person.on('didEat', function(food) { + console.log('person ate some ' + food); + }); + person.trigger('didEat', 'broccoli'); + // outputs: person ate some broccoli + ``` + @method trigger + @param {String} name The name of the event + @param {Object...} args Optional arguments to pass on + @public + */ + trigger: function (name) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - DidCreateElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$ARGS"] - }; - }; + _emberMetal.sendEvent(this, name, args); + }, - return DidCreateElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Cancels subscription for given name, target, and method. + @method off + @param {String} name The name of the event + @param {Object} target The target of the subscription + @param {Function} method The function of the subscription + @return this + @public + */ + off: function (name, target, method) { + _emberMetal.removeListener(this, name, target, method); + return this; + }, - exports.DidCreateElementOpcode = DidCreateElementOpcode; + /** + Checks to see if object has any subscriptions for named event. + @method has + @param {String} name The name of the event + @return {Boolean} does the object have a subscription for event + @public + */ + has: function (name) { + return _emberMetal.hasListeners(this, name); + } + }); +}); +enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - var ShadowAttributesOpcode = (function (_Opcode5) { - babelHelpers.inherits(ShadowAttributesOpcode, _Opcode5); + 'use strict'; - function ShadowAttributesOpcode() { - _Opcode5.apply(this, arguments); - this.type = "shadow-attributes"; - } + /** + The `Ember.Freezable` mixin implements some basic methods for marking an + object as frozen. Once an object is frozen it should be read only. No changes + may be made the internal state of the object. + + ## Enforcement + + To fully support freezing in your subclass, you must include this mixin and + override any method that might alter any property on the object to instead + raise an exception. You can check the state of an object by checking the + `isFrozen` property. + + Although future versions of JavaScript may support language-level freezing + object objects, that is not the case today. Even if an object is freezable, + it is still technically possible to modify the object, even though it could + break other parts of your application that do not expect a frozen object to + change. It is, therefore, very important that you always respect the + `isFrozen` property on all freezable objects. + + ## Example Usage + + The example below shows a simple object that implement the `Ember.Freezable` + protocol. + + ```javascript + Contact = Ember.Object.extend(Ember.Freezable, { + firstName: null, + lastName: null, + + // swaps the names + swapNames: function() { + if (this.get('isFrozen')) throw Ember.FROZEN_ERROR; + var tmp = this.get('firstName'); + this.set('firstName', this.get('lastName')); + this.set('lastName', tmp); + return this; + } + + }); + + c = Contact.create({ firstName: "John", lastName: "Doe" }); + c.swapNames(); // returns c + c.freeze(); + c.swapNames(); // EXCEPTION + ``` + + ## Copying + + Usually the `Ember.Freezable` protocol is implemented in cooperation with the + `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will + return a frozen object, if the object implements this method as well. + + @class Freezable + @namespace Ember + @since Ember 0.9 + @deprecated Use `Object.freeze` instead. + @private + */ + var Freezable = _emberMetal.Mixin.create({ - ShadowAttributesOpcode.prototype.evaluate = function evaluate(vm) { - var shadow = vm.frame.getShadow(); - if (!shadow) return; + init: function () { + _emberMetal.deprecate('`Ember.Freezable` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.freezable-init', until: '3.0.0' }); + this._super.apply(this, arguments); + }, - var _vm$frame$getArgs = vm.frame.getArgs(); + /** + Set to `true` when the object is frozen. Use this property to detect + whether your object is frozen or not. + @property isFrozen + @type Boolean + @private + */ + isFrozen: false, - var named = _vm$frame$getArgs.named; + /** + Freezes the object. Once this method has been called the object should + no longer allow any properties to be edited. + @method freeze + @return {Object} receiver + @private + */ + freeze: function () { + if (_emberMetal.get(this, 'isFrozen')) { + return this; + } - shadow.forEach(function (name) { - vm.stack().setDynamicAttribute(name, named.get(name), false); - }); - }; + _emberMetal.set(this, 'isFrozen', true); + return this; + } - ShadowAttributesOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$ARGS"] - }; - }; + }); - return ShadowAttributesOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + exports.Freezable = Freezable; + var FROZEN_ERROR = 'Frozen object cannot be modified.'; + exports.FROZEN_ERROR = FROZEN_ERROR; +}); +enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable'], function (exports, _emberMetal, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable) { + /** + @module ember + @submodule ember-runtime + */ - exports.ShadowAttributesOpcode = ShadowAttributesOpcode; + 'use strict'; - var DidRenderLayoutOpcode = (function (_Opcode6) { - babelHelpers.inherits(DidRenderLayoutOpcode, _Opcode6); + exports.removeAt = removeAt; + var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; + var EMPTY = []; - function DidRenderLayoutOpcode() { - _Opcode6.apply(this, arguments); - this.type = "did-render-layout"; - } + // .......................................................... + // HELPERS + // - DidRenderLayoutOpcode.prototype.evaluate = function evaluate(vm) { - var manager = vm.frame.getManager(); - var component = vm.frame.getComponent(); - var bounds = vm.stack().popBlock(); - manager.didRenderLayout(component, bounds); - vm.env.didCreate(component, manager); - vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); - }; + function removeAt(array, start, len) { + if ('number' === typeof start) { + if (start < 0 || start >= _emberMetal.get(array, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - return DidRenderLayoutOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + // fast case + if (len === undefined) { + len = 1; + } - exports.DidRenderLayoutOpcode = DidRenderLayoutOpcode; + array.replace(start, len, EMPTY); + } - var DidUpdateLayoutOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(DidUpdateLayoutOpcode, _UpdatingOpcode2); + return array; + } - function DidUpdateLayoutOpcode(manager, component, bounds) { - _UpdatingOpcode2.call(this); - this.manager = manager; - this.component = component; - this.bounds = bounds; - this.type = "did-update-layout"; - this.tag = _glimmerReference.CONSTANT_TAG; - } + /** + This mixin defines the API for modifying array-like objects. These methods + can be applied only to a collection that keeps its items in an ordered set. + It builds upon the Array mixin and adds methods to modify the array. + One concrete implementations of this class include ArrayProxy. + + It is important to use the methods in this class to modify arrays so that + changes are observable. This allows the binding system in Ember to function + correctly. + + + Note that an Array can change even if it does not implement this mixin. + For example, one might implement a SparseArray that cannot be directly + modified, but if its underlying enumerable changes, it will change also. + + @class MutableArray + @namespace Ember + @uses Ember.Array + @uses Ember.MutableEnumerable + @public + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, { - DidUpdateLayoutOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; - var component = this.component; - var bounds = this.bounds; + /** + __Required.__ You must implement this method to apply this mixin. + This is one of the primitives you must implement to support `Ember.Array`. + You should replace amt objects started at idx with the objects in the + passed array. You should also call `this.enumerableContentDidChange()` + @method replace + @param {Number} idx Starting index in the array to replace. If + idx >= length, then append to the end of the array. + @param {Number} amt Number of elements that should be removed from + the array, starting at *idx*. + @param {Array} objects An array of zero or more objects that should be + inserted into the array at *idx* + @public + */ + replace: null, - manager.didUpdateLayout(component, bounds); - vm.env.didUpdate(component, manager); - }; + /** + Remove all elements from the array. This is useful if you + want to reuse an existing array without having to recreate it. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.length; // 3 + colors.clear(); // [] + colors.length; // 0 + ``` + @method clear + @return {Ember.Array} An empty Array. + @public + */ + clear: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return this; + } - return DidUpdateLayoutOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + this.replace(0, len, EMPTY); + return this; + }, - exports.DidUpdateLayoutOpcode = DidUpdateLayoutOpcode; + /** + This will use the primitive `replace()` method to insert an object at the + specified index. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue'] + colors.insertAt(5, 'orange'); // Error: Index out of range + ``` + @method insertAt + @param {Number} idx index of insert the object at. + @param {Object} object object to insert + @return {Ember.Array} receiver + @public + */ + insertAt: function (idx, object) { + if (idx > _emberMetal.get(this, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - var CloseComponentOpcode = (function (_Opcode7) { - babelHelpers.inherits(CloseComponentOpcode, _Opcode7); + this.replace(idx, 0, [object]); + return this; + }, - function CloseComponentOpcode() { - _Opcode7.apply(this, arguments); - this.type = "close-component"; - } + /** + Remove an object at the specified index using the `replace()` primitive + method. You can pass either a single index, or a start and a length. + If you pass a start and length that is beyond the + length this method will throw an `OUT_OF_RANGE_EXCEPTION`. + ```javascript + let colors = ['red', 'green', 'blue', 'yellow', 'orange']; + colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] + colors.removeAt(2, 2); // ['green', 'blue'] + colors.removeAt(4, 2); // Error: Index out of range + ``` + @method removeAt + @param {Number} start index, start of range + @param {Number} len length of passing range + @return {Ember.Array} receiver + @public + */ + removeAt: function (start, len) { + return removeAt(this, start, len); + }, - CloseComponentOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - vm.popDynamicScope(); - vm.commitCacheGroup(); - }; + /** + Push the object onto the end of the array. Works just like `push()` but it + is KVO-compliant. + ```javascript + let colors = ['red', 'green']; + colors.pushObject('black'); // ['red', 'green', 'black'] + colors.pushObject(['yellow']); // ['red', 'green', ['yellow']] + ``` + @method pushObject + @param {*} obj object to push + @return object same object passed as a param + @public + */ + pushObject: function (obj) { + this.insertAt(_emberMetal.get(this, 'length'), obj); + return obj; + }, - return CloseComponentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Add the objects in the passed numerable to the end of the array. Defers + notifying observers of the change until all objects are added. + ```javascript + let colors = ['red']; + colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange'] + ``` + @method pushObjects + @param {Ember.Enumerable} objects the objects to add + @return {Ember.Array} receiver + @public + */ + pushObjects: function (objects) { + if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || Array.isArray(objects))) { + throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + } + this.replace(_emberMetal.get(this, 'length'), 0, objects); + return this; + }, - exports.CloseComponentOpcode = CloseComponentOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBVUEsbUNBQUE7OEJBQUEsbUNBQUE7O0FBQUEsaUJBQUEsbUNBQUEsR0FBQTtBQUF5RCxnQ0FBQSxTQUFBLENBQUEsQ0FBTTtBQUN0RCxnQkFBQSxDQUFBLElBQUksR0FBRyxrQ0FBa0MsQ0FBQztTQXFCbEQ7O0FBdEJELDJDQUFBLFdBR0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGdCQUFJLFNBQVMsR0FBRyxFQUFFLENBQUMsS0FBSyxDQUFDLFVBQVUsRUFBa0MsQ0FBQztBQUN0RSxnQkFBSSxLQUFLLEdBQUcsa0JBUitDLE9BQU8sQ0FROUMsU0FBUyxDQUFDLEdBQUcsU0FBUyxHQUFHLHNCQVJYLGNBQWMsQ0FRZ0IsU0FBUyxDQUFDLENBQUM7QUFDM0UsZ0JBQUksVUFBVSxHQUFHLEtBQUssR0FBRyxLQUFLLENBQUMsSUFBSSxFQUFFLEdBQUcsU0FBUyxDQUFDLEtBQUssRUFBRSxDQUFDO0FBRTFELGNBQUUsQ0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLFVBQVUsQ0FBQyxDQUFDO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biAgfVxufVxuXG5leHBvcnQgY2xhc3MgQ2xvc2VDb21wb25lbnRPcGNvZGUgZXh0ZW5kcyBPcGNvZGUge1xuICBwdWJsaWMgdHlwZSA9IFwiY2xvc2UtY29tcG9uZW50XCI7XG5cbiAgZXZhbHVhdGUodm06IFZNKSB7XG4gICAgdm0ucG9wU2NvcGUoKTtcbiAgICB2bS5wb3BEeW5hbWljU2NvcGUoKTtcbiAgICB2bS5jb21taXRDYWNoZUdyb3VwKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/opcodes/content', ['exports', 'glimmer-runtime/lib/upsert', 'glimmer-runtime/lib/component/interfaces', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/vm/update', 'glimmer-reference', 'glimmer-util', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/compiler', 'glimmer-runtime/lib/compiled/opcodes/builder', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/syntax/core'], function (exports, _glimmerRuntimeLibUpsert, _glimmerRuntimeLibComponentInterfaces, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibVmUpdate, _glimmerReference, _glimmerUtil, _glimmerRuntimeLibBounds, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibCompiler, _glimmerRuntimeLibCompiledOpcodesBuilder, _glimmerRuntimeLibReferences, _glimmerRuntimeLibSyntaxCore) { - 'use strict'; + /** + Pop object from array or nil if none are left. Works just like `pop()` but + it is KVO-compliant. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.popObject(); // 'blue' + console.log(colors); // ['red', 'green'] + ``` + @method popObject + @return object + @public + */ + popObject: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return null; + } - exports.normalizeTextValue = normalizeTextValue; + var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1); + this.removeAt(len - 1, 1); + return ret; + }, - function isEmpty(value) { - return value === null || value === undefined || typeof value['toString'] !== 'function'; - } + /** + Shift an object from start of array or nil if none are left. Works just + like `shift()` but it is KVO-compliant. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.shiftObject(); // 'red' + console.log(colors); // ['green', 'blue'] + ``` + @method shiftObject + @return object + @public + */ + shiftObject: function () { + if (_emberMetal.get(this, 'length') === 0) { + return null; + } - function normalizeTextValue(value) { - if (isEmpty(value)) { - return ''; - } - return String(value); - } + var ret = _emberRuntimeMixinsArray.objectAt(this, 0); + this.removeAt(0); + return ret; + }, - function normalizeTrustedValue(value) { - if (isEmpty(value)) { - return ''; - } - if (_glimmerRuntimeLibUpsert.isString(value)) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value)) { - return value.toHTML(); - } - if (_glimmerRuntimeLibUpsert.isNode(value)) { - return value; - } - return String(value); - } - function normalizeValue(value) { - if (isEmpty(value)) { - return ''; - } - if (_glimmerRuntimeLibUpsert.isString(value)) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value) || _glimmerRuntimeLibUpsert.isNode(value)) { - return value; - } - return String(value); - } + /** + Unshift an object to start of array. Works just like `unshift()` but it is + KVO-compliant. + ```javascript + let colors = ['red']; + colors.unshiftObject('yellow'); // ['yellow', 'red'] + colors.unshiftObject(['black']); // [['black'], 'yellow', 'red'] + ``` + @method unshiftObject + @param {*} obj object to unshift + @return object same object passed as a param + @public + */ + unshiftObject: function (obj) { + this.insertAt(0, obj); + return obj; + }, - var AppendOpcode = (function (_Opcode) { - babelHelpers.inherits(AppendOpcode, _Opcode); + /** + Adds the named objects to the beginning of the array. Defers notifying + observers until all objects have been added. + ```javascript + let colors = ['red']; + colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red'] + colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function + ``` + @method unshiftObjects + @param {Ember.Enumerable} objects the objects to add + @return {Ember.Array} receiver + @public + */ + unshiftObjects: function (objects) { + this.replace(0, 0, objects); + return this; + }, - function AppendOpcode() { - _Opcode.apply(this, arguments); - } + /** + Reverse objects in the array. Works just like `reverse()` but it is + KVO-compliant. + @method reverseObjects + @return {Ember.Array} receiver + @public + */ + reverseObjects: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return this; + } - AppendOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var normalized = this.normalize(reference); - var value = undefined, - cache = undefined; - if (_glimmerReference.isConst(reference)) { - value = normalized.value(); - } else { - cache = new _glimmerReference.ReferenceCache(normalized); - value = cache.peek(); - } - var stack = vm.stack(); - var upsert = this.insert(vm.env.getAppendOperations(), stack, value); - var bounds = new _glimmerRuntimeLibBuilder.Fragment(upsert.bounds); - stack.newBounds(bounds); - if (cache /* i.e. !isConst(reference) */) { - vm.updateWith(this.updateWith(vm, reference, cache, bounds, upsert)); - } - }; + var objects = this.toArray().reverse(); + this.replace(0, len, objects); + return this; + }, - AppendOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + /** + Replace all the receiver's content with content of the argument. + If argument is an empty array receiver will be cleared. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.setObjects(['black', 'white']); // ['black', 'white'] + colors.setObjects([]); // [] + ``` + @method setObjects + @param {Ember.Array} objects array whose content will be used for replacing + the content of the receiver + @return {Ember.Array} receiver with the new content + @public + */ + setObjects: function (objects) { + if (objects.length === 0) { + return this.clear(); + } - return AppendOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var len = _emberMetal.get(this, 'length'); + this.replace(0, len, objects); + return this; + }, - exports.AppendOpcode = AppendOpcode; + // .......................................................... + // IMPLEMENT Ember.MutableEnumerable + // - var GuardedAppendOpcode = (function (_AppendOpcode) { - babelHelpers.inherits(GuardedAppendOpcode, _AppendOpcode); + /** + Remove all occurrences of an object in the array. + ```javascript + let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; + cities.removeObject('Chicago'); // ['Berlin', 'Lima'] + cities.removeObject('Lima'); // ['Berlin'] + cities.removeObject('Tokyo') // ['Berlin'] + ``` + @method removeObject + @param {*} obj object to remove + @return {Ember.Array} receiver + @public + */ + removeObject: function (obj) { + var loc = _emberMetal.get(this, 'length') || 0; + while (--loc >= 0) { + var curObject = _emberRuntimeMixinsArray.objectAt(this, loc); - function GuardedAppendOpcode(expression, symbolTable) { - _AppendOpcode.call(this); - this.expression = expression; - this.symbolTable = symbolTable; - this.deopted = null; + if (curObject === obj) { + this.removeAt(loc); } + } + return this; + }, - GuardedAppendOpcode.prototype.evaluate = function evaluate(vm) { - if (this.deopted) { - vm.pushEvalFrame(this.deopted); - } else { - vm.evaluateOperand(this.expression); - var value = vm.frame.getOperand().value(); - if (_glimmerRuntimeLibComponentInterfaces.isComponentDefinition(value)) { - vm.pushEvalFrame(this.deopt(vm.env)); - } else { - _AppendOpcode.prototype.evaluate.call(this, vm); - } - } - }; - - GuardedAppendOpcode.prototype.deopt = function deopt(env) { - var _this = this; - - // At compile time, we determined that this append callsite might refer - // to a local variable/property lookup that resolves to a component - // definition at runtime. - // - // We could have eagerly compiled this callsite into something like this: - // - // {{#if (is-component-definition foo)}} - // {{component foo}} - // {{else}} - // {{foo}} - // {{/if}} - // - // However, in practice, there might be a large amout of these callsites - // and most of them would resolve to a simple value lookup. Therefore, we - // tried to be optimistic and assumed that the callsite will resolve to - // appending a simple value. - // - // However, we have reached here because at runtime, the guard conditional - // have detected that this callsite is indeed referring to a component - // definition object. Since this is likely going to be true for other - // instances of the same callsite, it is now appropiate to deopt into the - // expanded version that handles both cases. The compilation would look - // like this: - // - // PutValue(expression) - // Test(is-component-definition) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(VALUE) - // PutDynamicComponentDefinitionOpcode - // OpenComponent - // CloseComponent - // Jump(END) - // VALUE: Noop - // OptimizedAppend - // END: Noop - // Exit - // - // Keep in mind that even if we *don't* reach here at initial render time, - // it is still possible (although quite rare) that the simple value we - // encounter during initial render could later change into a component - // definition object at update time. That is handled by the "lazy deopt" - // code on the update side (scroll down for the next big block of comment). - var buffer = new _glimmerRuntimeLibCompiler.CompileIntoList(env, null); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, this.symbolTable, env); - dsl.putValue(this.expression); - dsl.test(IsComponentDefinitionReference.create); - dsl.block(null, function (dsl, BEGIN, END) { - dsl.jumpUnless('VALUE'); - dsl.putDynamicComponentDefinition(); - dsl.openComponent(_glimmerRuntimeLibSyntaxCore.Args.empty()); - dsl.closeComponent(); - dsl.jump(END); - dsl.label('VALUE'); - dsl.append(new _this.AppendOpcode()); - }); - var deopted = this.deopted = dsl.toOpSeq(); - // From this point on, we have essentially replaced ourselve with a new set - // of opcodes. Since we will always be executing the new/deopted code, it's - // a good idea (as a pattern) to null out any unneeded fields here to avoid - // holding on to unneeded/stale objects: - this.expression = null; - return deopted; - }; - - GuardedAppendOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var deopted = this.deopted; - - if (deopted) { - return { - guid: guid, - type: type, - deopted: true, - children: deopted.toArray().map(function (op) { - return op.toJSON(); - }) - }; - } else { - return { - guid: guid, - type: type, - args: [this.expression.toJSON()] - }; - } - }; + /** + Push the object onto the end of the array if it is not already + present in the array. + ```javascript + let cities = ['Chicago', 'Berlin']; + cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] + cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] + ``` + @method addObject + @param {*} obj object to add, if not already present + @return {Ember.Array} receiver + @public + */ + addObject: function (obj) { + var included = this.includes(obj); - return GuardedAppendOpcode; - })(AppendOpcode); + if (!included) { + this.pushObject(obj); + } - exports.GuardedAppendOpcode = GuardedAppendOpcode; + return this; + } + }); +}); +enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetal) { + 'use strict'; - var IsComponentDefinitionReference = (function (_ConditionalReference) { - babelHelpers.inherits(IsComponentDefinitionReference, _ConditionalReference); + /** + @module ember + @submodule ember-runtime + */ - function IsComponentDefinitionReference() { - _ConditionalReference.apply(this, arguments); - } + /** + This mixin defines the API for modifying generic enumerables. These methods + can be applied to an object regardless of whether it is ordered or + unordered. + + Note that an Enumerable can change even if it does not implement this mixin. + For example, a MappedEnumerable cannot be directly modified but if its + underlying enumerable changes, it will change also. + + ## Adding Objects + + To add an object to an enumerable, use the `addObject()` method. This + method will only add the object to the enumerable if the object is not + already present and is of a type supported by the enumerable. + + ```javascript + set.addObject(contact); + ``` + + ## Removing Objects + + To remove an object from an enumerable, use the `removeObject()` method. This + will only remove the object if it is present in the enumerable, otherwise + this method has no effect. + + ```javascript + set.removeObject(contact); + ``` + + ## Implementing In Your Own Code + + If you are implementing an object and want to support this API, just include + this mixin in your class and implement the required methods. In your unit + tests, be sure to apply the Ember.MutableEnumerableTests to your object. + + @class MutableEnumerable + @namespace Ember + @uses Ember.Enumerable + @public + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, { - IsComponentDefinitionReference.create = function create(inner) { - return new IsComponentDefinitionReference(inner); - }; + /** + __Required.__ You must implement this method to apply this mixin. + Attempts to add the passed object to the receiver if the object is not + already present in the collection. If the object is present, this method + has no effect. + If the passed object is of a type not supported by the receiver, + then this method should raise an exception. + @method addObject + @param {Object} object The object to add to the enumerable. + @return {Object} the passed object + @public + */ + addObject: null, - IsComponentDefinitionReference.prototype.toBool = function toBool(value) { - return _glimmerRuntimeLibComponentInterfaces.isComponentDefinition(value); - }; + /** + Adds each object in the passed enumerable to the receiver. + @method addObjects + @param {Ember.Enumerable} objects the objects to add. + @return {Object} receiver + @public + */ + addObjects: function (objects) { + var _this = this; - return IsComponentDefinitionReference; - })(_glimmerRuntimeLibReferences.ConditionalReference); + _emberMetal.beginPropertyChanges(this); + objects.forEach(function (obj) { + return _this.addObject(obj); + }); + _emberMetal.endPropertyChanges(this); + return this; + }, - var UpdateOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateOpcode, _UpdatingOpcode); + /** + __Required.__ You must implement this method to apply this mixin. + Attempts to remove the passed object from the receiver collection if the + object is present in the collection. If the object is not present, + this method has no effect. + If the passed object is of a type not supported by the receiver, + then this method should raise an exception. + @method removeObject + @param {Object} object The object to remove from the enumerable. + @return {Object} the passed object + @public + */ + removeObject: null, - function UpdateOpcode(cache, bounds, upsert) { - _UpdatingOpcode.call(this); - this.cache = cache; - this.bounds = bounds; - this.upsert = upsert; - this.tag = cache.tag; - } + /** + Removes each object in the passed enumerable from the receiver. + @method removeObjects + @param {Ember.Enumerable} objects the objects to remove + @return {Object} receiver + @public + */ + removeObjects: function (objects) { + _emberMetal.beginPropertyChanges(this); + for (var i = objects.length - 1; i >= 0; i--) { + this.removeObject(objects[i]); + } + _emberMetal.endPropertyChanges(this); + return this; + } + }); +}); +enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - UpdateOpcode.prototype.evaluate = function evaluate(vm) { - var value = this.cache.revalidate(); - if (_glimmerReference.isModified(value)) { - var bounds = this.bounds; - var upsert = this.upsert; - var dom = vm.dom; + 'use strict'; - if (!this.upsert.update(dom, value)) { - var cursor = new _glimmerRuntimeLibBounds.Cursor(bounds.parentElement(), _glimmerRuntimeLibBounds.clear(bounds)); - upsert = this.upsert = this.insert(vm.env.getAppendOperations(), cursor, value); - } - bounds.update(upsert.bounds); - } - }; + /** + ## Overview + + This mixin provides properties and property observing functionality, core + features of the Ember object model. + + Properties and observers allow one object to observe changes to a + property on another object. This is one of the fundamental ways that + models, controllers and views communicate with each other in an Ember + application. + + Any object that has this mixin applied can be used in observer + operations. That includes `Ember.Object` and most objects you will + interact with as you write your Ember application. + + Note that you will not generally apply this mixin to classes yourself, + but you will use the features provided by this module frequently, so it + is important to understand how to use it. + + ## Using `get()` and `set()` + + Because of Ember's support for bindings and observers, you will always + access properties using the get method, and set properties using the + set method. This allows the observing objects to be notified and + computed properties to be handled properly. + + More documentation about `get` and `set` are below. + + ## Observing Property Changes + + 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) { + // Executes whenever the "value" property changes + // See the addObserver method for more information about the callback arguments + }) + }); + ``` + + Although this is the most common way to add an observer, this capability + is actually built into the `Ember.Object` class on top of two methods + defined in this mixin: `addObserver` and `removeObserver`. You can use + these two methods to add and remove observers yourself if you need to + do so at runtime. + + To add an observer for a property, call: + + ```javascript + object.addObserver('propertyKey', targetObject, targetAction) + ``` + + This will call the `targetAction` method on the `targetObject` whenever + the value of the `propertyKey` changes. + + Note that if `propertyKey` is a computed property, the observer will be + called when any of the property dependencies are changed, even if the + resulting value of the computed property is unchanged. This is necessary + because computed properties are not computed until `get` is called. + + @class Observable + @namespace Ember + @public + */ + exports.default = _emberMetal.Mixin.create({ - UpdateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var cache = this.cache; + /** + Retrieves the value of a property from the object. + This method is usually similar to using `object[keyName]` or `object.keyName`, + however it supports both computed properties and the unknownProperty + handler. + Because `get` unifies the syntax for accessing all these kinds + of properties, it can make many refactorings easier, such as replacing a + simple property with a computed property, or vice versa. + ### Computed Properties + Computed properties are methods defined with the `property` modifier + declared at the end, such as: + ```javascript + fullName: Ember.computed('firstName', 'lastName', function() { + return this.get('firstName') + ' ' + this.get('lastName'); + }) + ``` + When you call `get` on a computed property, the function will be + called and the return value will be returned instead of the function + itself. + ### Unknown Properties + Likewise, if you try to call `get` on a property whose value is + `undefined`, the `unknownProperty()` method will be called on the object. + If this method returns any value other than `undefined`, it will be returned + instead. This allows you to implement "virtual" properties that are + not defined upfront. + @method get + @param {String} keyName The property to retrieve + @return {Object} The property value or undefined. + @public + */ + get: function (keyName) { + return _emberMetal.get(this, keyName); + }, - return { - guid: guid, - type: type, - details: { lastValue: JSON.stringify(cache.peek()) } - }; - }; + /** + To get the values of multiple properties at once, call `getProperties` + with a list of strings or an array: + ```javascript + record.getProperties('firstName', 'lastName', 'zipCode'); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + is equivalent to: + ```javascript + record.getProperties(['firstName', 'lastName', 'zipCode']); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + @method getProperties + @param {String...|Array} list of keys to get + @return {Object} + @public + */ + getProperties: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - return UpdateOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + return _emberMetal.getProperties.apply(undefined, [this].concat(args)); + }, - var GuardedUpdateOpcode = (function (_UpdateOpcode) { - babelHelpers.inherits(GuardedUpdateOpcode, _UpdateOpcode); + /** + Sets the provided key or path to the value. + ```javascript + record.set("key", value); + ``` + This method is generally very similar to calling `object["key"] = value` or + `object.key = value`, except that it provides support for computed + properties, the `setUnknownProperty()` method and property observers. + ### Computed Properties + If you try to set a value on a key that has a computed property handler + defined (see the `get()` method for an example), then `set()` will call + that method, passing both the value and key instead of simply changing + the value itself. This is useful for those times when you need to + implement a property that is composed of one or more member + properties. + ### Unknown Properties + If you try to set a value on a key that is undefined in the target + object, then the `setUnknownProperty()` handler will be called instead. This + gives you an opportunity to implement complex "virtual" properties that + are not predefined on the object. If `setUnknownProperty()` returns + undefined, then `set()` will simply set the value on the object. + ### Property Observers + In addition to changing the property, `set()` will also register a property + change with the object. Unless you have placed this call inside of a + `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers + (i.e. observer methods declared on the same object), will be called + immediately. Any "remote" observers (i.e. observer methods declared on + another object) will be placed in a queue and called at a later time in a + coalesced manner. + @method set + @param {String} keyName The property to set + @param {Object} value The value to set or `null`. + @return {Object} The passed value + @public + */ + set: function (keyName, value) { + return _emberMetal.set(this, keyName, value); + }, - function GuardedUpdateOpcode(reference, cache, bounds, upsert, appendOpcode, state) { - _UpdateOpcode.call(this, cache, bounds, upsert); - this.reference = reference; - this.appendOpcode = appendOpcode; - this.state = state; - this.deopted = null; - this.tag = this._tag = new _glimmerReference.UpdatableTag(this.tag); - } + /** + Sets a list of properties at once. These properties are set inside + a single `beginPropertyChanges` and `endPropertyChanges` batch, so + observers will be buffered. + ```javascript + record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); + ``` + @method setProperties + @param {Object} hash the hash of keys and values to set + @return {Object} The passed in hash + @public + */ + setProperties: function (hash) { + return _emberMetal.setProperties(this, hash); + }, - GuardedUpdateOpcode.prototype.evaluate = function evaluate(vm) { - if (this.deopted) { - vm.evaluateOpcode(this.deopted); - } else { - if (_glimmerRuntimeLibComponentInterfaces.isComponentDefinition(this.reference.value())) { - this.lazyDeopt(vm); - } else { - _UpdateOpcode.prototype.evaluate.call(this, vm); - } - } - }; + /** + Begins a grouping of property changes. + You can use this method to group property changes so that notifications + will not be sent until the changes are finished. If you plan to make a + large number of changes to an object at one time, you should call this + method at the beginning of the changes to begin deferring change + notifications. When you are done making changes, call + `endPropertyChanges()` to deliver the deferred change notifications and end + deferring. + @method beginPropertyChanges + @return {Ember.Observable} + @private + */ + beginPropertyChanges: function () { + _emberMetal.beginPropertyChanges(); + return this; + }, - GuardedUpdateOpcode.prototype.lazyDeopt = function lazyDeopt(vm) { - // Durign initial render, we know that the reference does not contain a - // component definition, so we optimistically assumed that this append - // is just a normal append. However, at update time, we discovered that - // the reference has switched into containing a component definition, so - // we need to do a "lazy deopt", simulating what would have happened if - // we had decided to perform the deopt in the first place during initial - // render. - // - // More concretely, we would have expanded the curly into a if/else, and - // based on whether the value is a component definition or not, we would - // have entered either the dynamic component branch or the simple value - // branch. - // - // Since we rendered a simple value during initial render (and all the - // updates up until this point), we need to pretend that the result is - // produced by the "VALUE" branch of the deopted append opcode: - // - // Try(BEGIN, END) - // Assert(IsComponentDefinition, expected=false) - // OptimizedUpdate - // - // In this case, because the reference has switched from being a simple - // value into a component definition, what would have happened is that - // the assert would throw, causing the Try opcode to teardown the bounds - // and rerun the original append opcode. - // - // Since the Try opcode would have nuked the updating opcodes anyway, we - // wouldn't have to worry about simulating those. All we have to do is to - // execute the Try opcode and immediately throw. - var bounds = this.bounds; - var appendOpcode = this.appendOpcode; - var state = this.state; - - var appendOps = appendOpcode.deopt(vm.env); - var enter = appendOps.head().next.next; - var ops = enter.slice; - var tracker = new _glimmerRuntimeLibBuilder.UpdatableBlockTracker(bounds.parentElement()); - tracker.newBounds(this.bounds); - var children = new _glimmerUtil.LinkedList(); - state.frame['condition'] = IsComponentDefinitionReference.create(state.frame['operand']); - var deopted = this.deopted = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, children); - this._tag.update(deopted.tag); - vm.evaluateOpcode(deopted); - vm.throw(); - // From this point on, we have essentially replaced ourselve with a new - // opcode. Since we will always be executing the new/deopted code, it's a - // good idea (as a pattern) to null out any unneeded fields here to avoid - // holding on to unneeded/stale objects: - this._tag = null; - this.reference = null; - this.cache = null; - this.bounds = null; - this.upsert = null; - this.appendOpcode = null; - this.state = null; - }; + /** + Ends a grouping of property changes. + You can use this method to group property changes so that notifications + will not be sent until the changes are finished. If you plan to make a + large number of changes to an object at one time, you should call + `beginPropertyChanges()` at the beginning of the changes to defer change + notifications. When you are done making changes, call this method to + deliver the deferred change notifications and end deferring. + @method endPropertyChanges + @return {Ember.Observable} + @private + */ + endPropertyChanges: function () { + _emberMetal.endPropertyChanges(); + return this; + }, - GuardedUpdateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var deopted = this.deopted; - - if (deopted) { - return { - guid: guid, - type: type, - deopted: true, - children: [deopted.toJSON()] - }; - } else { - return _UpdateOpcode.prototype.toJSON.call(this); - } - }; + /** + Notify the observer system that a property is about to change. + Sometimes you need to change a value directly or indirectly without + actually calling `get()` or `set()` on it. In this case, you can use this + method and `propertyDidChange()` instead. Calling these two methods + together will notify all observers that the property has potentially + changed value. + Note that you must always call `propertyWillChange` and `propertyDidChange` + as a pair. If you do not, it may get the property change groups out of + order and cause notifications to be delivered more often than you would + like. + @method propertyWillChange + @param {String} keyName The property key that is about to change. + @return {Ember.Observable} + @private + */ + propertyWillChange: function (keyName) { + _emberMetal.propertyWillChange(this, keyName); + return this; + }, - return GuardedUpdateOpcode; - })(UpdateOpcode); + /** + Notify the observer system that a property has just changed. + Sometimes you need to change a value directly or indirectly without + actually calling `get()` or `set()` on it. In this case, you can use this + method and `propertyWillChange()` instead. Calling these two methods + together will notify all observers that the property has potentially + changed value. + Note that you must always call `propertyWillChange` and `propertyDidChange` + as a pair. If you do not, it may get the property change groups out of + order and cause notifications to be delivered more often than you would + like. + @method propertyDidChange + @param {String} keyName The property key that has just changed. + @return {Ember.Observable} + @private + */ + propertyDidChange: function (keyName) { + _emberMetal.propertyDidChange(this, keyName); + return this; + }, - var OptimizedCautiousAppendOpcode = (function (_AppendOpcode2) { - babelHelpers.inherits(OptimizedCautiousAppendOpcode, _AppendOpcode2); + /** + Convenience method to call `propertyWillChange` and `propertyDidChange` in + succession. + @method notifyPropertyChange + @param {String} keyName The property key to be notified about. + @return {Ember.Observable} + @public + */ + notifyPropertyChange: function (keyName) { + this.propertyWillChange(keyName); + this.propertyDidChange(keyName); + return this; + }, - function OptimizedCautiousAppendOpcode() { - _AppendOpcode2.apply(this, arguments); - this.type = 'optimized-cautious-append'; + /** + Adds an observer on a property. + This is the core method used to register an observer for a property. + Once you call this method, any time the key's value is set, your observer + will be notified. Note that the observers are triggered any time the + value is set, regardless of whether it has actually changed. Your + observer should be prepared to handle that. + ### Observer Methods + Observer methods have the following signature: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + this.addObserver('foo', this, 'fooDidChange'); + }, + fooDidChange(sender, key, value, rev) { + // your code } + }); + ``` + The `sender` is the object that changed. The `key` is the property that + changes. The `value` property is currently reserved and unused. The `rev` + is the last property revision of the object when it changed, which you can + use to detect if the key value has really changed or not. + Usually you will not need the value or revision parameters at + the end. In this case, it is common to write observer methods that take + only a sender and key value as parameters or, if you aren't interested in + any of these values, to write an observer that has no parameters at all. + @method addObserver + @param {String} key The key to observer + @param {Object} target The target object to invoke + @param {String|Function} method The method to invoke. + @public + */ + addObserver: function (key, target, method) { + _emberMetal.addObserver(this, key, target, method); + }, - OptimizedCautiousAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeValue); - }; + /** + Remove an observer you have previously registered on this object. Pass + the same key, target, and method you passed to `addObserver()` and your + target will no longer receive notifications. + @method removeObserver + @param {String} key The key to observer + @param {Object} target The target object to invoke + @param {String|Function} method The method to invoke. + @public + */ + removeObserver: function (key, target, method) { + _emberMetal.removeObserver(this, key, target, method); + }, - OptimizedCautiousAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + /** + Returns `true` if the object currently has observers registered for a + particular key. You can use this method to potentially defer performing + an expensive action until someone begins observing a particular property + on the object. + @method hasObserverFor + @param {String} key Key to check + @return {Boolean} + @private + */ + hasObserverFor: function (key) { + return _emberMetal.hasListeners(this, key + ':change'); + }, - OptimizedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new OptimizedCautiousUpdateOpcode(cache, bounds, upsert); - }; + /** + Retrieves the value of a property, or a default value in the case that the + property returns `undefined`. + ```javascript + person.getWithDefault('lastName', 'Doe'); + ``` + @method getWithDefault + @param {String} keyName The name of the property to retrieve + @param {Object} defaultValue The value to return if the property value is undefined + @return {Object} The property value or the defaultValue. + @public + */ + getWithDefault: function (keyName, defaultValue) { + return _emberMetal.getWithDefault(this, keyName, defaultValue); + }, - return OptimizedCautiousAppendOpcode; - })(AppendOpcode); + /** + Set the value of a property to the current value plus some amount. + ```javascript + person.incrementProperty('age'); + team.incrementProperty('score', 2); + ``` + @method incrementProperty + @param {String} keyName The name of the property to increment + @param {Number} increment The amount to increment by. Defaults to 1 + @return {Number} The new property value + @public + */ + incrementProperty: function (keyName, increment) { + if (_emberMetal.isNone(increment)) { + increment = 1; + } + _emberMetal.assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment)); + return _emberMetal.set(this, keyName, (parseFloat(_emberMetal.get(this, keyName)) || 0) + increment); + }, - exports.OptimizedCautiousAppendOpcode = OptimizedCautiousAppendOpcode; + /** + Set the value of a property to the current value minus some amount. + ```javascript + player.decrementProperty('lives'); + orc.decrementProperty('health', 5); + ``` + @method decrementProperty + @param {String} keyName The name of the property to decrement + @param {Number} decrement The amount to decrement by. Defaults to 1 + @return {Number} The new property value + @public + */ + decrementProperty: function (keyName, decrement) { + if (_emberMetal.isNone(decrement)) { + decrement = 1; + } + _emberMetal.assert('Must pass a numeric value to decrementProperty', !isNaN(parseFloat(decrement)) && isFinite(decrement)); + return _emberMetal.set(this, keyName, (_emberMetal.get(this, keyName) || 0) - decrement); + }, - var OptimizedCautiousUpdateOpcode = (function (_UpdateOpcode2) { - babelHelpers.inherits(OptimizedCautiousUpdateOpcode, _UpdateOpcode2); + /** + Set the value of a boolean property to the opposite of its + current value. + ```javascript + starship.toggleProperty('warpDriveEngaged'); + ``` + @method toggleProperty + @param {String} keyName The name of the property to toggle + @return {Boolean} The new property value + @public + */ + toggleProperty: function (keyName) { + return _emberMetal.set(this, keyName, !_emberMetal.get(this, keyName)); + }, - function OptimizedCautiousUpdateOpcode() { - _UpdateOpcode2.apply(this, arguments); - this.type = 'optimized-cautious-update'; - } + /** + Returns the cached value of a computed property, if it exists. + This allows you to inspect the value of a computed property + without accidentally invoking it if it is intended to be + generated lazily. + @method cacheFor + @param {String} keyName + @return {Object} The cached value of the computed property, if any + @public + */ + cacheFor: function (keyName) { + return _emberMetal.cacheFor(this, keyName); + }, - OptimizedCautiousUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + // intended for debugging purposes + observersForKey: function (keyName) { + return _emberMetal.observersFor(this, keyName); + } + }); +}); +enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros) { + 'use strict'; - return OptimizedCautiousUpdateOpcode; - })(UpdateOpcode); + /** + @module ember + @submodule ember-runtime + */ - var GuardedCautiousAppendOpcode = (function (_GuardedAppendOpcode) { - babelHelpers.inherits(GuardedCautiousAppendOpcode, _GuardedAppendOpcode); + function tap(proxy, promise) { + _emberMetal.setProperties(proxy, { + isFulfilled: false, + isRejected: false + }); - function GuardedCautiousAppendOpcode() { - _GuardedAppendOpcode.apply(this, arguments); - this.type = 'guarded-cautious-append'; - this.AppendOpcode = OptimizedCautiousAppendOpcode; - } + return promise.then(function (value) { + if (!proxy.isDestroyed && !proxy.isDestroying) { + _emberMetal.setProperties(proxy, { + content: value, + isFulfilled: true + }); + } + return value; + }, function (reason) { + if (!proxy.isDestroyed && !proxy.isDestroying) { + _emberMetal.setProperties(proxy, { + reason: reason, + isRejected: true + }); + } + throw reason; + }, 'Ember: PromiseProxy'); + } - GuardedCautiousAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeValue); - }; + /** + A low level mixin making ObjectProxy promise-aware. + + ```javascript + let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); + + let proxy = ObjectPromiseProxy.create({ + promise: Ember.RSVP.cast($.getJSON('/some/remote/data.json')) + }); + + proxy.then(function(json){ + // the json + }, function(reason) { + // the reason why you have no json + }); + ``` + + the proxy has bindable attributes which + track the promises life cycle + + ```javascript + proxy.get('isPending') //=> true + proxy.get('isSettled') //=> false + proxy.get('isRejected') //=> false + proxy.get('isFulfilled') //=> false + ``` + + When the $.getJSON completes, and the promise is fulfilled + with json, the life cycle attributes will update accordingly. + Note that $.getJSON doesn't return an ECMA specified promise, + it is useful to wrap this with an `RSVP.cast` so that it behaves + as a spec compliant promise. + + ```javascript + proxy.get('isPending') //=> false + proxy.get('isSettled') //=> true + proxy.get('isRejected') //=> false + proxy.get('isFulfilled') //=> true + ``` + + As the proxy is an ObjectProxy, and the json now its content, + all the json properties will be available directly from the proxy. + + ```javascript + // Assuming the following json: + { + firstName: 'Stefan', + lastName: 'Penner' + } + + // both properties will accessible on the proxy + proxy.get('firstName') //=> 'Stefan' + proxy.get('lastName') //=> 'Penner' + ``` + + @class Ember.PromiseProxyMixin + @public + */ + exports.default = _emberMetal.Mixin.create({ + /** + If the proxied promise is rejected this will contain the reason + provided. + @property reason + @default null + @public + */ + reason: null, - GuardedCautiousAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + /** + Once the proxied promise has settled this will become `false`. + @property isPending + @default true + @public + */ + isPending: _emberRuntimeComputedComputed_macros.not('isSettled').readOnly(), - GuardedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new GuardedCautiousUpdateOpcode(reference, cache, bounds, upsert, this, vm.capture()); - }; + /** + Once the proxied promise has settled this will become `true`. + @property isSettled + @default false + @public + */ + isSettled: _emberRuntimeComputedComputed_macros.or('isRejected', 'isFulfilled').readOnly(), - return GuardedCautiousAppendOpcode; - })(GuardedAppendOpcode); + /** + Will become `true` if the proxied promise is rejected. + @property isRejected + @default false + @public + */ + isRejected: false, - exports.GuardedCautiousAppendOpcode = GuardedCautiousAppendOpcode; + /** + Will become `true` if the proxied promise is fulfilled. + @property isFulfilled + @default false + @public + */ + isFulfilled: false, - var GuardedCautiousUpdateOpcode = (function (_GuardedUpdateOpcode) { - babelHelpers.inherits(GuardedCautiousUpdateOpcode, _GuardedUpdateOpcode); + /** + The promise whose fulfillment value is being proxied by this object. + This property must be specified upon creation, and should not be + changed once created. + Example: + ```javascript + Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({ + promise: + }); + ``` + @property promise + @public + */ + promise: _emberMetal.computed({ + get: function () { + throw new _emberMetal.Error('PromiseProxy\'s promise must be set'); + }, + set: function (key, promise) { + return tap(this, promise); + } + }), - function GuardedCautiousUpdateOpcode() { - _GuardedUpdateOpcode.apply(this, arguments); - this.type = 'guarded-cautious-update'; - } + /** + An alias to the proxied promise's `then`. + See RSVP.Promise.then. + @method then + @param {Function} callback + @return {RSVP.Promise} + @public + */ + then: promiseAlias('then'), - GuardedCautiousUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + /** + An alias to the proxied promise's `catch`. + See RSVP.Promise.catch. + @method catch + @param {Function} callback + @return {RSVP.Promise} + @since 1.3.0 + @public + */ + 'catch': promiseAlias('catch'), - return GuardedCautiousUpdateOpcode; - })(GuardedUpdateOpcode); + /** + An alias to the proxied promise's `finally`. + See RSVP.Promise.finally. + @method finally + @param {Function} callback + @return {RSVP.Promise} + @since 1.3.0 + @public + */ + 'finally': promiseAlias('finally') - var OptimizedTrustingAppendOpcode = (function (_AppendOpcode3) { - babelHelpers.inherits(OptimizedTrustingAppendOpcode, _AppendOpcode3); + }); - function OptimizedTrustingAppendOpcode() { - _AppendOpcode3.apply(this, arguments); - this.type = 'optimized-trusting-append'; - } + function promiseAlias(name) { + return function () { + var promise = _emberMetal.get(this, 'promise'); + return promise[name].apply(promise, arguments); + }; + } +}); +enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - OptimizedTrustingAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeTrustedValue); - }; + 'use strict'; - OptimizedTrustingAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + exports.buildFakeRegistryWithDeprecations = buildFakeRegistryWithDeprecations; - OptimizedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new OptimizedTrustingUpdateOpcode(cache, bounds, upsert); - }; + /** + RegistryProxyMixin is used to provide public access to specific + registry functionality. + + @class RegistryProxyMixin + @private + */ + exports.default = _emberMetal.Mixin.create({ + __registry__: null, - return OptimizedTrustingAppendOpcode; - })(AppendOpcode); + /** + Given a fullName return the corresponding factory. + @public + @method resolveRegistration + @param {String} fullName + @return {Function} fullName's factory + */ + resolveRegistration: registryAlias('resolve'), - exports.OptimizedTrustingAppendOpcode = OptimizedTrustingAppendOpcode; + /** + Registers a factory that can be used for dependency injection (with + `inject`) or for service lookup. Each factory is registered with + a full name including two parts: `type:name`. + A simple example: + ```javascript + let App = Ember.Application.create(); + App.Orange = Ember.Object.extend(); + App.register('fruit:favorite', App.Orange); + ``` + Ember will resolve factories from the `App` namespace automatically. + For example `App.CarsController` will be discovered and returned if + an application requests `controller:cars`. + An example of registering a controller with a non-standard name: + ```javascript + let App = Ember.Application.create(); + let Session = Ember.Controller.extend(); + App.register('controller:session', Session); + // The Session controller can now be treated like a normal controller, + // despite its non-standard name. + App.ApplicationController = Ember.Controller.extend({ + needs: ['session'] + }); + ``` + Registered factories are **instantiated** by having `create` + called on them. Additionally they are **singletons**, each time + they are looked up they return the same instance. + Some examples modifying that default behavior: + ```javascript + let App = Ember.Application.create(); + App.Person = Ember.Object.extend(); + App.Orange = Ember.Object.extend(); + App.Email = Ember.Object.extend(); + App.session = Ember.Object.create(); + App.register('model:user', App.Person, { singleton: false }); + App.register('fruit:favorite', App.Orange); + App.register('communication:main', App.Email, { singleton: false }); + App.register('session', App.session, { instantiate: false }); + ``` + @method register + @param fullName {String} type:name (e.g., 'model:user') + @param factory {Function} (e.g., App.Person) + @param options {Object} (optional) disable instantiation or singleton usage + @public + */ + register: registryAlias('register'), - var OptimizedTrustingUpdateOpcode = (function (_UpdateOpcode3) { - babelHelpers.inherits(OptimizedTrustingUpdateOpcode, _UpdateOpcode3); + /** + Unregister a factory. + ```javascript + let App = Ember.Application.create(); + let User = Ember.Object.extend(); + App.register('model:user', User); + App.resolveRegistration('model:user').create() instanceof User //=> true + App.unregister('model:user') + App.resolveRegistration('model:user') === undefined //=> true + ``` + @public + @method unregister + @param {String} fullName + */ + unregister: registryAlias('unregister'), - function OptimizedTrustingUpdateOpcode() { - _UpdateOpcode3.apply(this, arguments); - this.type = 'optimized-trusting-update'; - } + /** + Check if a factory is registered. + @public + @method hasRegistration + @param {String} fullName + @return {Boolean} + */ + hasRegistration: registryAlias('has'), - OptimizedTrustingUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + /** + Register an option for a particular factory. + @public + @method registerOption + @param {String} fullName + @param {String} optionName + @param {Object} options + */ + registerOption: registryAlias('option'), - return OptimizedTrustingUpdateOpcode; - })(UpdateOpcode); + /** + Return a specific registered option for a particular factory. + @public + @method registeredOption + @param {String} fullName + @param {String} optionName + @return {Object} options + */ + registeredOption: registryAlias('getOption'), - var GuardedTrustingAppendOpcode = (function (_GuardedAppendOpcode2) { - babelHelpers.inherits(GuardedTrustingAppendOpcode, _GuardedAppendOpcode2); + /** + Register options for a particular factory. + @public + @method registerOptions + @param {String} fullName + @param {Object} options + */ + registerOptions: registryAlias('options'), - function GuardedTrustingAppendOpcode() { - _GuardedAppendOpcode2.apply(this, arguments); - this.type = 'guarded-trusting-append'; - this.AppendOpcode = OptimizedTrustingAppendOpcode; - } + /** + Return registered options for a particular factory. + @public + @method registeredOptions + @param {String} fullName + @return {Object} options + */ + registeredOptions: registryAlias('getOptions'), - GuardedTrustingAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeTrustedValue); - }; + /** + Allow registering options for all factories of a type. + ```javascript + let App = Ember.Application.create(); + let appInstance = App.buildInstance(); + // if all of type `connection` must not be singletons + appInstance.registerOptionsForType('connection', { singleton: false }); + appInstance.register('connection:twitter', TwitterConnection); + appInstance.register('connection:facebook', FacebookConnection); + let twitter = appInstance.lookup('connection:twitter'); + let twitter2 = appInstance.lookup('connection:twitter'); + twitter === twitter2; // => false + let facebook = appInstance.lookup('connection:facebook'); + let facebook2 = appInstance.lookup('connection:facebook'); + facebook === facebook2; // => false + ``` + @public + @method registerOptionsForType + @param {String} type + @param {Object} options + */ + registerOptionsForType: registryAlias('optionsForType'), - GuardedTrustingAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + /** + Return the registered options for all factories of a type. + @public + @method registeredOptionsForType + @param {String} type + @return {Object} options + */ + registeredOptionsForType: registryAlias('getOptionsForType'), - GuardedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new GuardedTrustingUpdateOpcode(reference, cache, bounds, upsert, this, vm.capture()); - }; + /** + Define a dependency injection onto a specific factory or all factories + of a type. + When Ember instantiates a controller, view, or other framework component + it can attach a dependency to that component. This is often used to + provide services to a set of framework components. + An example of providing a session object to all controllers: + ```javascript + let App = Ember.Application.create(); + let Session = Ember.Object.extend({ isAuthenticated: false }); + // A factory must be registered before it can be injected + App.register('session:main', Session); + // Inject 'session:main' onto all factories of the type 'controller' + // with the name 'session' + App.inject('controller', 'session', 'session:main'); + App.IndexController = Ember.Controller.extend({ + isLoggedIn: Ember.computed.alias('session.isAuthenticated') + }); + ``` + Injections can also be performed on specific factories. + ```javascript + App.inject(, , ) + App.inject('route', 'source', 'source:main') + App.inject('route:application', 'email', 'model:email') + ``` + It is important to note that injections can only be performed on + classes that are instantiated by Ember itself. Instantiating a class + directly (via `create` or `new`) bypasses the dependency injection + system. + **Note:** Ember-Data instantiates its models in a unique manner, and consequently + injections onto models (or all models) will not work as expected. Injections + on models can be enabled by setting `EmberENV.MODEL_FACTORY_INJECTIONS` + to `true`. + @public + @method inject + @param factoryNameOrType {String} + @param property {String} + @param injectionName {String} + **/ + inject: registryAlias('injection') + }); - return GuardedTrustingAppendOpcode; - })(GuardedAppendOpcode); + function registryAlias(name) { + return function () { + var _registry__; - exports.GuardedTrustingAppendOpcode = GuardedTrustingAppendOpcode; + return (_registry__ = this.__registry__)[name].apply(_registry__, arguments); + }; + } - var GuardedTrustingUpdateOpcode = (function (_GuardedUpdateOpcode2) { - babelHelpers.inherits(GuardedTrustingUpdateOpcode, _GuardedUpdateOpcode2); + function buildFakeRegistryWithDeprecations(instance, typeForMessage) { + var fakeRegistry = {}; + var registryProps = { + resolve: 'resolveRegistration', + register: 'register', + unregister: 'unregister', + has: 'hasRegistration', + option: 'registerOption', + options: 'registerOptions', + getOptions: 'registeredOptions', + optionsForType: 'registerOptionsForType', + getOptionsForType: 'registeredOptionsForType', + injection: 'inject' + }; - function GuardedTrustingUpdateOpcode() { - _GuardedUpdateOpcode2.apply(this, arguments); - this.type = 'trusting-update'; - } + for (var deprecatedProperty in registryProps) { + fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]); + } - GuardedTrustingUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + return fakeRegistry; + } - return GuardedTrustingUpdateOpcode; - })(GuardedUpdateOpcode); + function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) { + return function () { + _emberMetal.deprecate('Using `' + typeForMessage + '.registry.' + deprecatedProperty + '` is deprecated. Please use `' + typeForMessage + '.' + nonDeprecatedProperty + '` instead.', false, { + id: 'ember-application.app-instance-registry', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-application-registry-ember-applicationinstance-registry' + }); + return instance[nonDeprecatedProperty].apply(instance, arguments); + }; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9jb250ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBK0JBLGFBQUEsT0FBQSxDQUFpQixLQUFhLEVBQUE7QUFDNUIsZUFBTyxLQUFLLEtBQUssSUFBSSxJQUFJLEtBQUssS0FBSyxTQUFTLElBQUksT0FBTyxLQUFLLEN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WRUcnVzdGluZ1VwZGF0ZU9wY29kZSBleHRlbmRzIEd1YXJkZWRVcGRhdGVPcGNvZGU8VHJ1c3RpbmdJbnNlcnRpb24+IHtcbiAgdHlwZSA9ICd0cnVzdGluZy11cGRhdGUnO1xuXG4gIHByb3RlY3RlZCBpbnNlcnQoZG9tOiBET01UcmVlQ29uc3RydWN0aW9uLCBjdXJzb3I6IEN1cnNvciwgdmFsdWU6IFRydXN0aW5nSW5zZXJ0aW9uKTogVXBzZXJ0IHtcbiAgICByZXR1cm4gdHJ1c3RpbmdJbnNlcnQoZG9tLCBjdXJzb3IsIHZhbHVlKTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/dom', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/compiled/opcodes/vm'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibReferences, _glimmerRuntimeLibCompiledOpcodesVm) { - 'use strict'; - - var TextOpcode = (function (_Opcode) { - babelHelpers.inherits(TextOpcode, _Opcode); - - function TextOpcode(text) { - _Opcode.call(this); - this.text = text; - this.type = "text"; - } - - TextOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().appendText(this.text); - }; - - TextOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.text)] - }; - }; +enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - return TextOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + 'use strict'; - exports.TextOpcode = TextOpcode; + /** + `Ember.TargetActionSupport` is a mixin that can be included in a class + to add a `triggerAction` method with semantics similar to the Handlebars + `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is + usually the best choice. This mixin is most often useful when you are + doing more complex event handling in Components. + + @class TargetActionSupport + @namespace Ember + @extends Ember.Mixin + @private + */ + exports.default = _emberMetal.Mixin.create({ + target: null, + action: null, + actionContext: null, - var OpenPrimitiveElementOpcode = (function (_Opcode2) { - babelHelpers.inherits(OpenPrimitiveElementOpcode, _Opcode2); + actionContextObject: _emberMetal.computed('actionContext', function () { + var actionContext = _emberMetal.get(this, 'actionContext'); - function OpenPrimitiveElementOpcode(tag) { - _Opcode2.call(this); - this.tag = tag; - this.type = "open-primitive-element"; + if (typeof actionContext === 'string') { + var value = _emberMetal.get(this, actionContext); + if (value === undefined) { + value = _emberMetal.get(_emberEnvironment.context.lookup, actionContext); } + return value; + } else { + return actionContext; + } + }), - OpenPrimitiveElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().openElement(this.tag); - }; - - OpenPrimitiveElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.tag)] - }; - }; + /** + Send an `action` with an `actionContext` to a `target`. The action, actionContext + and target will be retrieved from properties of the object. For example: + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + action: 'save', + actionContext: Ember.computed.alias('context'), + click() { + this.triggerAction(); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + The `target`, `action`, and `actionContext` can be provided as properties of + an optional object argument to `triggerAction` as well. + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + click() { + this.triggerAction({ + action: 'save', + target: this.get('controller'), + actionContext: this.get('context') + }); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. + But `target` and `action` must be specified either as properties or with the argument + to `triggerAction`, or a combination: + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + click() { + this.triggerAction({ + action: 'save' + }); // Sends the `save` action, along with a reference to `this`, + // to the current controller + } + }); + ``` + @method triggerAction + @param opts {Object} (optional, with the optional keys action, target and/or actionContext) + @return {Boolean} true if the action was sent successfully and did not return false + @private + */ + triggerAction: function () { + var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - return OpenPrimitiveElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var action = opts.action || _emberMetal.get(this, 'action'); + var target = opts.target; - exports.OpenPrimitiveElementOpcode = OpenPrimitiveElementOpcode; + if (!target) { + target = getTarget(this); + } - var PushRemoteElementOpcode = (function (_Opcode3) { - babelHelpers.inherits(PushRemoteElementOpcode, _Opcode3); + var actionContext = opts.actionContext; - function PushRemoteElementOpcode() { - _Opcode3.apply(this, arguments); - this.type = "push-remote-element"; + function args(options, actionName) { + var ret = []; + if (actionName) { + ret.push(actionName); } - PushRemoteElementOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var element = cache ? cache.peek() : reference.value(); - vm.stack().pushRemoteElement(element); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; + return ret.concat(options); + } - PushRemoteElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ['$OPERAND'] - }; - }; + if (typeof actionContext === 'undefined') { + actionContext = _emberMetal.get(this, 'actionContextObject') || this; + } - return PushRemoteElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (target && action) { + var ret = undefined; - exports.PushRemoteElementOpcode = PushRemoteElementOpcode; + if (target.send) { + var _target; - var PopRemoteElementOpcode = (function (_Opcode4) { - babelHelpers.inherits(PopRemoteElementOpcode, _Opcode4); + ret = (_target = target).send.apply(_target, args(actionContext, action)); + } else { + var _target2; - function PopRemoteElementOpcode() { - _Opcode4.apply(this, arguments); - this.type = "pop-remote-element"; + _emberMetal.assert('The action \'' + action + '\' did not exist on ' + target, typeof target[action] === 'function'); + ret = (_target2 = target)[action].apply(_target2, args(actionContext)); } - PopRemoteElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().popRemoteElement(); - }; - - return PopRemoteElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PopRemoteElementOpcode = PopRemoteElementOpcode; - - var OpenComponentElementOpcode = (function (_Opcode5) { - babelHelpers.inherits(OpenComponentElementOpcode, _Opcode5); - - function OpenComponentElementOpcode(tag) { - _Opcode5.call(this); - this.tag = tag; - this.type = "open-component-element"; + if (ret !== false) { + ret = true; } - OpenComponentElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().openElement(this.tag, new ComponentElementOperations(vm.env)); - }; - - OpenComponentElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.tag)] - }; - }; + return ret; + } else { + return false; + } + } + }); - return OpenComponentElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function getTarget(instance) { + // TODO: Deprecate specifying `targetObject` + var target = _emberMetal.get(instance, 'targetObject'); - exports.OpenComponentElementOpcode = OpenComponentElementOpcode; + // if a `targetObject` CP was provided, use it + if (target) { + return target; + } - var OpenDynamicPrimitiveElementOpcode = (function (_Opcode6) { - babelHelpers.inherits(OpenDynamicPrimitiveElementOpcode, _Opcode6); + // if _targetObject use it + if (instance._targetObject) { + return instance._targetObject; + } - function OpenDynamicPrimitiveElementOpcode() { - _Opcode6.apply(this, arguments); - this.type = "open-dynamic-primitive-element"; + target = _emberMetal.get(instance, 'target'); + if (target) { + if (typeof target === 'string') { + var value = _emberMetal.get(instance, target); + if (value === undefined) { + value = _emberMetal.get(_emberEnvironment.context.lookup, target); } - OpenDynamicPrimitiveElementOpcode.prototype.evaluate = function evaluate(vm) { - var tagName = vm.frame.getOperand().value(); - vm.stack().openElement(tagName); - }; - - OpenDynamicPrimitiveElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + return value; + } else { + return target; + } + } - return OpenDynamicPrimitiveElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + return null; + } +}); +enifed("ember-runtime/string_registry", ["exports"], function (exports) { + // STATE within a module is frowned apon, this exists + // to support Ember.STRINGS but shield ember internals from this legacy global + // API. + "use strict"; - exports.OpenDynamicPrimitiveElementOpcode = OpenDynamicPrimitiveElementOpcode; + exports.setStrings = setStrings; + exports.getStrings = getStrings; + exports.get = get; + var STRINGS = {}; - var ClassList = (function () { - function ClassList() { - this.list = null; - this.isConst = true; - } + function setStrings(strings) { + STRINGS = strings; + } - ClassList.prototype.append = function append(reference) { - var list = this.list; - var isConst = this.isConst; + function getStrings() { + return STRINGS; + } - if (list === null) list = this.list = []; - list.push(reference); - this.isConst = isConst && _glimmerReference.isConst(reference); - }; + function get(name) { + return STRINGS[name]; + } +}); +enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) { + 'use strict'; - ClassList.prototype.toReference = function toReference() { - var list = this.list; - var isConst = this.isConst; + exports.default = _emberRuntimeSystemNamespace.default.extend(); +}); +enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray) { + 'use strict'; - if (!list) return _glimmerRuntimeLibReferences.NULL_REFERENCE; - if (isConst) return _glimmerRuntimeLibReferences.PrimitiveReference.create(toClassName(list)); - return new ClassListReference(list); - }; + /** + @module ember + @submodule ember-runtime + */ - return ClassList; - })(); + var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; + var EMPTY = []; - var ClassListReference = (function (_CachedReference) { - babelHelpers.inherits(ClassListReference, _CachedReference); + function K() { + return this; + } - function ClassListReference(list) { - _CachedReference.call(this); - this.list = []; - this.tag = _glimmerReference.combineTagged(list); - this.list = list; + /** + An ArrayProxy wraps any other object that implements `Ember.Array` and/or + `Ember.MutableArray,` forwarding all requests. This makes it very useful for + a number of binding use cases or other cases where being able to swap + out the underlying array is useful. + + A simple example of usage: + + ```javascript + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); + + ap.get('firstObject'); // 'dog' + ap.set('content', ['amoeba', 'paramecium']); + ap.get('firstObject'); // 'amoeba' + ``` + + This class can also be useful as a layer to transform the contents of + an array, as they are accessed. This can be done by overriding + `objectAtContent`: + + ```javascript + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ + content: Ember.A(pets), + objectAtContent: function(idx) { + return this.get('content').objectAt(idx).toUpperCase(); } + }); + + ap.get('firstObject'); // . 'DOG' + ``` + + @class ArrayProxy + @namespace Ember + @extends Ember.Object + @uses Ember.MutableArray + @public + */ + exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { - ClassListReference.prototype.compute = function compute() { - return toClassName(this.list); - }; + /** + The content array. Must be an object that implements `Ember.Array` and/or + `Ember.MutableArray.` + @property content + @type Ember.Array + @private + */ + content: null, - return ClassListReference; - })(_glimmerReference.CachedReference); + /** + The array that the proxy pretends to be. In the default `ArrayProxy` + implementation, this and `content` are the same. Subclasses of `ArrayProxy` + can override this property to provide things like sorting and filtering. + @property arrangedContent + @private + */ + arrangedContent: _emberMetal.alias('content'), - function toClassName(list) { - var ret = []; - for (var i = 0; i < list.length; i++) { - var value = list[i].value(); - if (value !== false && value !== null && value !== undefined) ret.push(value); - } - return ret.length === 0 ? null : ret.join(' '); - } + /** + Should actually retrieve the object at the specified index from the + content. You can override this method in subclasses to transform the + content item to something new. + This method will only be called if content is non-`null`. + @method objectAtContent + @param {Number} idx The index to retrieve. + @return {Object} the value or undefined if none found + @public + */ + objectAtContent: function (idx) { + return _emberRuntimeMixinsArray.objectAt(_emberMetal.get(this, 'arrangedContent'), idx); + }, - var SimpleElementOperations = (function () { - function SimpleElementOperations(env) { - this.env = env; - this.opcodes = null; - this.classList = null; - } + /** + Should actually replace the specified objects on the content array. + You can override this method in subclasses to transform the content item + into something new. + This method will only be called if content is non-`null`. + @method replaceContent + @param {Number} idx The starting index + @param {Number} amt The number of items to remove from the content. + @param {Array} objects Optional array of objects to insert or null if no + objects. + @return {void} + @private + */ + replaceContent: function (idx, amt, objects) { + _emberMetal.get(this, 'content').replace(idx, amt, objects); + }, - SimpleElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element, name, value) { - if (name === 'class') { - this.addClass(_glimmerRuntimeLibReferences.PrimitiveReference.create(value)); - } else { - this.env.getAppendOperations().setAttribute(element, name, value); - } - }; + /** + Invoked when the content property is about to change. Notifies observers that the + entire array content will change. + @private + @method _contentWillChange + */ + _contentWillChange: _emberMetal._beforeObserver('content', function () { + this._teardownContent(); + }), - SimpleElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element, namespace, name, value) { - this.env.getAppendOperations().setAttribute(element, name, value, namespace); - }; + _teardownContent: function () { + var content = _emberMetal.get(this, 'content'); - SimpleElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element, name, reference, isTrusting) { - if (name === 'class') { - this.addClass(reference); - } else { - var attributeManager = this.env.attributeFor(element, name, isTrusting); - var attribute = new DynamicAttribute(element, attributeManager, name, reference); - this.addAttribute(attribute); - } - }; + if (content) { + _emberRuntimeMixinsArray.removeArrayObserver(content, this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + } + }, - SimpleElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element, namespace, name, reference, isTrusting) { - var attributeManager = this.env.attributeFor(element, name, isTrusting, namespace); - var nsAttribute = new DynamicAttribute(element, attributeManager, name, reference, namespace); - this.addAttribute(nsAttribute); - }; + /** + Override to implement content array `willChange` observer. + @method contentArrayWillChange + @param {Ember.Array} contentArray the content array + @param {Number} start starting index of the change + @param {Number} removeCount count of items removed + @param {Number} addCount count of items added + @private + */ + contentArrayWillChange: K, + /** + Override to implement content array `didChange` observer. + @method contentArrayDidChange + @param {Ember.Array} contentArray the content array + @param {Number} start starting index of the change + @param {Number} removeCount count of items removed + @param {Number} addCount count of items added + @private + */ + contentArrayDidChange: K, - SimpleElementOperations.prototype.flush = function flush(element, vm) { - var env = vm.env; - var opcodes = this.opcodes; - var classList = this.classList; + /** + Invoked when the content property changes. Notifies observers that the + entire array content has changed. + @private + @method _contentDidChange + */ + _contentDidChange: _emberMetal.observer('content', function () { + var content = _emberMetal.get(this, 'content'); - for (var i = 0; opcodes && i < opcodes.length; i++) { - vm.updateWith(opcodes[i]); - } - if (classList) { - var attributeManager = env.attributeFor(element, 'class', false); - var attribute = new DynamicAttribute(element, attributeManager, 'class', classList.toReference()); - var opcode = attribute.flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - this.opcodes = null; - this.classList = null; - }; + _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', content !== this); - SimpleElementOperations.prototype.addClass = function addClass(reference) { - var classList = this.classList; + this._setupContent(); + }), - if (!classList) { - classList = this.classList = new ClassList(); - } - classList.append(reference); - }; + _setupContent: function () { + var content = _emberMetal.get(this, 'content'); - SimpleElementOperations.prototype.addAttribute = function addAttribute(attribute) { - var opcode = attribute.flush(this.env); - if (opcode) { - var opcodes = this.opcodes; + if (content) { + _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof content, _emberRuntimeUtils.isArray(content) || content.isDestroyed); - if (!opcodes) { - opcodes = this.opcodes = []; - } - opcodes.push(opcode); - } - }; + _emberRuntimeMixinsArray.addArrayObserver(content, this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + } + }, - return SimpleElementOperations; - })(); + _arrangedContentWillChange: _emberMetal._beforeObserver('arrangedContent', function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - exports.SimpleElementOperations = SimpleElementOperations; + this.arrangedContentArrayWillChange(this, 0, len, undefined); + this.arrangedContentWillChange(this); - var ComponentElementOperations = (function () { - function ComponentElementOperations(env) { - this.env = env; - this.attributeNames = null; - this.attributes = null; - this.classList = null; - } + this._teardownArrangedContent(arrangedContent); + }), - ComponentElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element, name, value) { - if (name === 'class') { - this.addClass(_glimmerRuntimeLibReferences.PrimitiveReference.create(value)); - } else if (this.shouldAddAttribute(name)) { - this.addAttribute(name, new StaticAttribute(element, name, value)); - } - }; + _arrangedContentDidChange: _emberMetal.observer('arrangedContent', function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - ComponentElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element, namespace, name, value) { - if (this.shouldAddAttribute(name)) { - this.addAttribute(name, new StaticAttribute(element, name, value, namespace)); - } - }; + _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this); - ComponentElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element, name, reference, isTrusting) { - if (name === 'class') { - this.addClass(reference); - } else if (this.shouldAddAttribute(name)) { - var attributeManager = this.env.attributeFor(element, name, isTrusting); - var attribute = new DynamicAttribute(element, attributeManager, name, reference); - this.addAttribute(name, attribute); - } - }; + this._setupArrangedContent(); - ComponentElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element, namespace, name, reference, isTrusting) { - if (this.shouldAddAttribute(name)) { - var attributeManager = this.env.attributeFor(element, name, isTrusting, namespace); - var nsAttribute = new DynamicAttribute(element, attributeManager, name, reference, namespace); - this.addAttribute(name, nsAttribute); - } - }; + this.arrangedContentDidChange(this); + this.arrangedContentArrayDidChange(this, 0, undefined, len); + }), - ComponentElementOperations.prototype.flush = function flush(element, vm) { - var env = this.env; - var attributes = this.attributes; - var classList = this.classList; + _setupArrangedContent: function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - for (var i = 0; attributes && i < attributes.length; i++) { - var opcode = attributes[i].flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - if (classList) { - var attributeManager = env.attributeFor(element, 'class', false); - var attribute = new DynamicAttribute(element, attributeManager, 'class', classList.toReference()); - var opcode = attribute.flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - }; + if (arrangedContent) { + _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof arrangedContent, _emberRuntimeUtils.isArray(arrangedContent) || arrangedContent.isDestroyed); - ComponentElementOperations.prototype.shouldAddAttribute = function shouldAddAttribute(name) { - return !this.attributeNames || this.attributeNames.indexOf(name) === -1; - }; + _emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, { + willChange: 'arrangedContentArrayWillChange', + didChange: 'arrangedContentArrayDidChange' + }); + } + }, - ComponentElementOperations.prototype.addClass = function addClass(reference) { - var classList = this.classList; + _teardownArrangedContent: function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - if (!classList) { - classList = this.classList = new ClassList(); - } - classList.append(reference); - }; + if (arrangedContent) { + _emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, { + willChange: 'arrangedContentArrayWillChange', + didChange: 'arrangedContentArrayDidChange' + }); + } + }, - ComponentElementOperations.prototype.addAttribute = function addAttribute(name, attribute) { - var attributeNames = this.attributeNames; - var attributes = this.attributes; + arrangedContentWillChange: K, + arrangedContentDidChange: K, - if (!attributeNames) { - attributeNames = this.attributeNames = []; - attributes = this.attributes = []; - } - attributeNames.push(name); - attributes.push(attribute); - }; + objectAt: function (idx) { + return _emberMetal.get(this, 'content') && this.objectAtContent(idx); + }, - return ComponentElementOperations; - })(); + length: _emberMetal.computed(function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + return arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + // No dependencies since Enumerable notifies length of change + }), - exports.ComponentElementOperations = ComponentElementOperations; + _replace: function (idx, amt, objects) { + var content = _emberMetal.get(this, 'content'); + _emberMetal.assert('The content property of ' + this.constructor + ' should be set before modifying it', content); + if (content) { + this.replaceContent(idx, amt, objects); + } - var FlushElementOpcode = (function (_Opcode7) { - babelHelpers.inherits(FlushElementOpcode, _Opcode7); + return this; + }, - function FlushElementOpcode() { - _Opcode7.apply(this, arguments); - this.type = "flush-element"; - } + replace: function () { + if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { + this._replace.apply(this, arguments); + } else { + throw new _emberMetal.Error('Using replace on an arranged ArrayProxy is not allowed.'); + } + }, - FlushElementOpcode.prototype.evaluate = function evaluate(vm) { - var stack = vm.stack(); - stack.operations.flush(stack.constructing, vm); - stack.flushElement(); - }; + _insertAt: function (idx, object) { + if (idx > _emberMetal.get(this, 'content.length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - return FlushElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + this._replace(idx, 0, [object]); + return this; + }, - exports.FlushElementOpcode = FlushElementOpcode; + insertAt: function (idx, object) { + if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { + return this._insertAt(idx, object); + } else { + throw new _emberMetal.Error('Using insertAt on an arranged ArrayProxy is not allowed.'); + } + }, - var CloseElementOpcode = (function (_Opcode8) { - babelHelpers.inherits(CloseElementOpcode, _Opcode8); + removeAt: function (start, len) { + if ('number' === typeof start) { + var content = _emberMetal.get(this, 'content'); + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var indices = []; - function CloseElementOpcode() { - _Opcode8.apply(this, arguments); - this.type = "close-element"; + if (start < 0 || start >= _emberMetal.get(this, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); } - CloseElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().closeElement(); - }; - - return CloseElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.CloseElementOpcode = CloseElementOpcode; - - var PopElementOpcode = (function (_Opcode9) { - babelHelpers.inherits(PopElementOpcode, _Opcode9); - - function PopElementOpcode() { - _Opcode9.apply(this, arguments); - this.type = "pop-element"; + if (len === undefined) { + len = 1; } - PopElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().popElement(); - }; - - return PopElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PopElementOpcode = PopElementOpcode; + // Get a list of indices in original content to remove + for (var i = start; i < start + len; i++) { + // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent + indices.push(content.indexOf(_emberRuntimeMixinsArray.objectAt(arrangedContent, i))); + } - var StaticAttrOpcode = (function (_Opcode10) { - babelHelpers.inherits(StaticAttrOpcode, _Opcode10); + // Replace in reverse order since indices will change + indices.sort(function (a, b) { + return b - a; + }); - function StaticAttrOpcode(namespace, name, value) { - _Opcode10.call(this); - this.namespace = namespace; - this.name = name; - this.value = value; - this.type = "static-attr"; + _emberMetal.beginPropertyChanges(); + for (var i = 0; i < indices.length; i++) { + this._replace(indices[i], 1, EMPTY); } + _emberMetal.endPropertyChanges(); + } - StaticAttrOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var value = this.value; - var namespace = this.namespace; + return this; + }, - if (namespace) { - vm.stack().setStaticAttributeNS(namespace, name, value); - } else { - vm.stack().setStaticAttribute(name, value); - } - }; + pushObject: function (obj) { + this._insertAt(_emberMetal.get(this, 'content.length'), obj); + return obj; + }, - StaticAttrOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var namespace = this.namespace; - var name = this.name; - var value = this.value; + pushObjects: function (objects) { + if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || _emberRuntimeUtils.isArray(objects))) { + throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + } + this._replace(_emberMetal.get(this, 'length'), 0, objects); + return this; + }, - var details = _glimmerUtil.dict(); - if (namespace) { - details["namespace"] = JSON.stringify(namespace); - } - details["name"] = JSON.stringify(name); - details["value"] = JSON.stringify(value); - return { guid: guid, type: type, details: details }; - }; + setObjects: function (objects) { + if (objects.length === 0) { + return this.clear(); + } - return StaticAttrOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var len = _emberMetal.get(this, 'length'); + this._replace(0, len, objects); + return this; + }, - exports.StaticAttrOpcode = StaticAttrOpcode; + unshiftObject: function (obj) { + this._insertAt(0, obj); + return obj; + }, - var ModifierOpcode = (function (_Opcode11) { - babelHelpers.inherits(ModifierOpcode, _Opcode11); + unshiftObjects: function (objects) { + this._replace(0, 0, objects); + return this; + }, - function ModifierOpcode(name, manager, args) { - _Opcode11.call(this); - this.name = name; - this.manager = manager; - this.args = args; - this.type = "modifier"; - } + slice: function () { + var arr = this.toArray(); + return arr.slice.apply(arr, arguments); + }, - ModifierOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; + arrangedContentArrayWillChange: function (item, idx, removedCnt, addedCnt) { + this.arrayContentWillChange(idx, removedCnt, addedCnt); + }, - var stack = vm.stack(); - var element = stack.constructing; - var updateOperations = stack.updateOperations; + arrangedContentArrayDidChange: function (item, idx, removedCnt, addedCnt) { + this.arrayContentDidChange(idx, removedCnt, addedCnt); + }, - var args = this.args.evaluate(vm); - var dynamicScope = vm.dynamicScope(); - var modifier = manager.create(element, args, dynamicScope, updateOperations); - vm.env.scheduleInstallModifier(modifier, manager); - var destructor = manager.getDestructor(modifier); - if (destructor) { - vm.newDestroyable(destructor); - } - vm.updateWith(new UpdateModifierOpcode(manager, modifier, args)); - }; + init: function () { + this._super.apply(this, arguments); + this._setupContent(); + this._setupArrangedContent(); + }, - ModifierOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; - var args = this.args; - - var details = _glimmerUtil.dict(); - details["type"] = JSON.stringify(type); - details["name"] = JSON.stringify(name); - details["args"] = JSON.stringify(args); - return { guid: guid, type: type, details: details }; - }; + willDestroy: function () { + this._teardownArrangedContent(); + this._teardownContent(); + } + }); +}); +enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/inject'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeInject) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - return ModifierOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + @module ember + @submodule ember-runtime + */ - exports.ModifierOpcode = ModifierOpcode; + // using ember-metal/lib/main here to ensure that ember-debug is setup + // if present - var UpdateModifierOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateModifierOpcode, _UpdatingOpcode); + var _Mixin$create, _ClassMixinProps; - function UpdateModifierOpcode(manager, modifier, args) { - _UpdatingOpcode.call(this); - this.manager = manager; - this.modifier = modifier; - this.args = args; - this.type = "update-modifier"; - this.tag = args.tag; - this.lastUpdated = args.tag.value(); - } + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['.'], ['.']); - UpdateModifierOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; - var modifier = this.modifier; - var tag = this.tag; - var lastUpdated = this.lastUpdated; + var schedule = _emberMetal.run.schedule; + var applyMixin = _emberMetal.Mixin._apply; + var finishPartial = _emberMetal.Mixin.finishPartial; + var reopen = _emberMetal.Mixin.prototype.reopen; + var hasCachedComputedProperties = false; - if (!tag.validate(lastUpdated)) { - vm.env.scheduleUpdateModifier(modifier, manager); - this.lastUpdated = tag.value(); - } - }; + var POST_INIT = _emberUtils.symbol('POST_INIT'); - UpdateModifierOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.args)] - }; - }; + exports.POST_INIT = POST_INIT; + function makeCtor() { + // Note: avoid accessing any properties on the object since it makes the + // method a lot faster. This is glue code so we want it to be as fast as + // possible. - return UpdateModifierOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + var wasApplied = false; + var initProperties = undefined; - exports.UpdateModifierOpcode = UpdateModifierOpcode; + var Class = (function () { + function Class() { +babelHelpers.classCallCheck(this, Class); - var StaticAttribute = (function () { - function StaticAttribute(element, name, value, namespace) { - this.element = element; - this.name = name; - this.value = value; - this.namespace = namespace; + if (!wasApplied) { + Class.proto(); // prepare prototype... } - StaticAttribute.prototype.flush = function flush(env) { - env.getAppendOperations().setAttribute(this.element, this.name, this.value, this.namespace); - return null; - }; - - return StaticAttribute; - })(); - - exports.StaticAttribute = StaticAttribute; - - var DynamicAttribute = (function () { - function DynamicAttribute(element, attributeManager, name, reference, namespace) { - this.element = element; - this.attributeManager = attributeManager; - this.name = name; - this.reference = reference; - this.namespace = namespace; - this.tag = reference.tag; - this.cache = null; + if (arguments.length > 0) { + initProperties = [arguments[0]]; } - DynamicAttribute.prototype.patch = function patch(env) { - var element = this.element; - var cache = this.cache; + this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); + var m = _emberMetal.meta(this); + var proto = m.proto; + m.proto = this; + if (initProperties) { + // capture locally so we can clear the closed over variable + var props = initProperties; + initProperties = null; - var value = cache.revalidate(); - if (_glimmerReference.isModified(value)) { - this.attributeManager.updateAttribute(env, element, value, this.namespace); - } - }; + var concatenatedProperties = this.concatenatedProperties; + var mergedProperties = this.mergedProperties; - DynamicAttribute.prototype.flush = function flush(env) { - var reference = this.reference; - var element = this.element; + for (var i = 0; i < props.length; i++) { + var properties = props[i]; + _emberMetal.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetal.Mixin)); - if (_glimmerReference.isConst(reference)) { - var value = reference.value(); - this.attributeManager.setAttribute(env, element, value, this.namespace); - return null; - } else { - var cache = this.cache = new _glimmerReference.ReferenceCache(reference); - var value = cache.peek(); - this.attributeManager.setAttribute(env, element, value, this.namespace); - return new PatchElementOpcode(this); + if (typeof properties !== 'object' && properties !== undefined) { + throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); } - }; - DynamicAttribute.prototype.toJSON = function toJSON() { - var element = this.element; - var namespace = this.namespace; - var name = this.name; - var cache = this.cache; - - var formattedElement = formatElement(element); - var lastValue = cache.peek(); - if (namespace) { - return { - element: formattedElement, - type: 'attribute', - namespace: namespace, - name: name, - lastValue: lastValue - }; + if (!properties) { + continue; } - return { - element: formattedElement, - type: 'attribute', - namespace: namespace, - name: name, - lastValue: lastValue - }; - }; - - return DynamicAttribute; - })(); - - exports.DynamicAttribute = DynamicAttribute; - function formatElement(element) { - return JSON.stringify('<' + element.tagName.toLowerCase() + ' />'); - } + var keyNames = Object.keys(properties); - var DynamicAttrNSOpcode = (function (_Opcode12) { - babelHelpers.inherits(DynamicAttrNSOpcode, _Opcode12); + for (var j = 0; j < keyNames.length; j++) { + var keyName = keyNames[j]; + var value = properties[keyName]; - function DynamicAttrNSOpcode(name, namespace, isTrusting) { - _Opcode12.call(this); - this.name = name; - this.namespace = namespace; - this.isTrusting = isTrusting; - this.type = "dynamic-attr"; - } + if (_emberMetal.detectBinding(keyName)) { + m.writeBindings(keyName, value); + } - DynamicAttrNSOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var namespace = this.namespace; - var isTrusting = this.isTrusting; + var possibleDesc = this[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - var reference = vm.frame.getOperand(); - vm.stack().setDynamicAttributeNS(namespace, name, reference, isTrusting); - }; + _emberMetal.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty)); + _emberMetal.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1)); + _emberMetal.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this))); - DynamicAttrNSOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; - var namespace = this.namespace; - - var details = _glimmerUtil.dict(); - details["name"] = JSON.stringify(name); - details["value"] = "$OPERAND"; - if (namespace) { - details["namespace"] = JSON.stringify(namespace); - } - return { guid: guid, type: type, details: details }; - }; + if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { + var baseValue = this[keyName]; - return DynamicAttrNSOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (baseValue) { + if ('function' === typeof baseValue.concat) { + value = baseValue.concat(value); + } else { + value = _emberUtils.makeArray(baseValue).concat(value); + } + } else { + value = _emberUtils.makeArray(value); + } + } - exports.DynamicAttrNSOpcode = DynamicAttrNSOpcode; + if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { + var originalValue = this[keyName]; - var DynamicAttrOpcode = (function (_Opcode13) { - babelHelpers.inherits(DynamicAttrOpcode, _Opcode13); + value = _emberUtils.assign({}, originalValue, value); + } - function DynamicAttrOpcode(name, isTrusting) { - _Opcode13.call(this); - this.name = name; - this.isTrusting = isTrusting; - this.type = "dynamic-attr"; + if (desc) { + desc.set(this, keyName, value); + } else { + if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { + this.setUnknownProperty(keyName, value); + } else { + if (true) { + _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter + } else { + this[keyName] = value; + } + } + } + } + } } - DynamicAttrOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var isTrusting = this.isTrusting; + finishPartial(this, m); - var reference = vm.frame.getOperand(); - vm.stack().setDynamicAttribute(name, reference, isTrusting); - }; + this.init.apply(this, arguments); - DynamicAttrOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; + this[POST_INIT](); - var details = _glimmerUtil.dict(); - details["name"] = JSON.stringify(name); - details["value"] = "$OPERAND"; - return { guid: guid, type: type, details: details }; - }; + m.proto = proto; + _emberMetal.finishChains(this); + _emberMetal.sendEvent(this, 'init'); + } + + Class.willReopen = function willReopen() { + if (wasApplied) { + Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); + } - return DynamicAttrOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + wasApplied = false; + }; - exports.DynamicAttrOpcode = DynamicAttrOpcode; + Class._initProperties = function _initProperties(args) { + initProperties = args; + }; - var PatchElementOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(PatchElementOpcode, _UpdatingOpcode2); + Class.proto = function proto() { + var superclass = Class.superclass; + if (superclass) { + superclass.proto(); + } - function PatchElementOpcode(operation) { - _UpdatingOpcode2.call(this); - this.type = "patch-element"; - this.tag = operation.tag; - this.operation = operation; + if (!wasApplied) { + wasApplied = true; + Class.PrototypeMixin.applyPartial(Class.prototype); } - PatchElementOpcode.prototype.evaluate = function evaluate(vm) { - this.operation.patch(vm.env); - }; + return this.prototype; + }; - PatchElementOpcode.prototype.toJSON = function toJSON() { - var _guid = this._guid; - var type = this.type; - var operation = this.operation; + return Class; + })(); - return { - guid: _guid, - type: type, - details: operation.toJSON() - }; - }; + Class.toString = _emberMetal.Mixin.prototype.toString; - return PatchElementOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + return Class; + } - exports.PatchElementOpcode = PatchElementOpcode; + /** + @class CoreObject + @namespace Ember + @public + */ + var CoreObject = makeCtor(); + CoreObject.toString = function () { + return 'Ember.CoreObject'; + }; + CoreObject.PrototypeMixin = _emberMetal.Mixin.create((_Mixin$create = { + reopen: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - var CommentOpcode = (function (_Opcode14) { - babelHelpers.inherits(CommentOpcode, _Opcode14); + applyMixin(this, args, true); + return this; + }, - function CommentOpcode(comment) { - _Opcode14.call(this); - this.comment = comment; - this.type = "comment"; + /** + An overridable method called when objects are instantiated. By default, + does nothing unless it is overridden during class definition. + Example: + ```javascript + const Person = Ember.Object.extend({ + init() { + alert(`Name is ${this.get('name')}`); } + }); + let steve = Person.create({ + name: "Steve" + }); + // alerts 'Name is Steve'. + ``` + NOTE: If you do override `init` for a framework class like `Ember.View`, + be sure to call `this._super(...arguments)` in your + `init` declaration! If you don't, Ember may not have an opportunity to + do important setup work, and you'll see strange behavior in your + application. + @method init + @public + */ + init: function () {} - CommentOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().appendComment(this.comment); - }; + }, _Mixin$create[POST_INIT] = function () {}, _Mixin$create.__defineNonEnumerable = function (property) { + Object.defineProperty(this, property.name, property.descriptor); + //this[property.name] = property.descriptor.value; + }, _Mixin$create.concatenatedProperties = null, _Mixin$create.mergedProperties = null, _Mixin$create.isDestroyed = _emberMetal.descriptor({ + get: function () { + return _emberMetal.meta(this).isSourceDestroyed(); + }, - CommentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.comment)] - }; - }; + set: function (value) { + // prevent setting while applying mixins + if (typeof value === 'object' && value !== null && value.isDescriptor) { + return; + } - return CommentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberMetal.assert(('You cannot set `' + this + '.isDestroyed` directly, please use ').destroy()(_templateObject), false); + } + }), _Mixin$create.isDestroying = _emberMetal.descriptor({ + get: function () { + return _emberMetal.meta(this).isSourceDestroying(); + }, - exports.CommentOpcode = CommentOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9kb20udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBd0JBLFVBQUE7OEJBQUEsVUFBQTs7QUFHRSxpQkFIRixVQUFBLENBR3NCLElBQVksRUFBQTtBQUM5Qiw4QkFBTyxDQUFDO0FBRFUsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFRO0FBRnpCLGdCQUFBLENBQUEsSUFBSSxHQUFHLE1BQU0sQ0FBQztTQUlwQjs7QUFMSCxrQkFBQSxXQU9FLF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xuXG4gIGV2YWx1YXRlKHZtOiBWTSkge1xuICAgIHZtLnN0YWNrKCkuYXBwZW5kQ29tbWVudCh0aGlzLmNvbW1lbnQpO1xuICB9XG5cbiAgdG9KU09OKCk6IE9wY29kZUpTT04ge1xuICAgIHJldHVybiB7XG4gICAgICBndWlkOiB0aGlzLl9ndWlkLFxuICAgICAgdHlwZTogdGhpcy50eXBlLFxuICAgICAgYXJnczogW0pTT04uc3RyaW5naWZ5KHRoaXMuY29tbWVudCldXG4gICAgfTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/lists', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-util', 'glimmer-reference'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerUtil, _glimmerReference) { - 'use strict'; + set: function (value) { + // prevent setting while applying mixins + if (typeof value === 'object' && value !== null && value.isDescriptor) { + return; + } - var IterablePresenceReference = (function () { - function IterablePresenceReference(artifacts) { - this.tag = artifacts.tag; - this.artifacts = artifacts; - } + _emberMetal.assert(('You cannot set `' + this + '.isDestroying` directly, please use ').destroy()(_templateObject), false); + } + }), _Mixin$create.destroy = function () { + var m = _emberMetal.meta(this); + if (m.isSourceDestroying()) { + return; + } - IterablePresenceReference.prototype.value = function value() { - return !this.artifacts.isEmpty(); - }; + m.setSourceDestroying(); - return IterablePresenceReference; - })(); + schedule('actions', this, this.willDestroy); + schedule('destroy', this, this._scheduledDestroy, m); - var PutIteratorOpcode = (function (_Opcode) { - babelHelpers.inherits(PutIteratorOpcode, _Opcode); + return this; + }, _Mixin$create.willDestroy = function () {}, _Mixin$create._scheduledDestroy = function (m) { + if (m.isSourceDestroyed()) { + return; + } + _emberMetal.destroy(this); + m.setSourceDestroyed(); + }, _Mixin$create.bind = function (to, from) { + if (!(from instanceof _emberMetal.Binding)) { + from = _emberMetal.Binding.from(from); + } + from.to(to).connect(this); + return from; + }, _Mixin$create.toString = function () { + var hasToStringExtension = typeof this.toStringExtension === 'function'; + var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; + var ret = '<' + (this[_emberUtils.NAME_KEY] || this.constructor.toString()) + ':' + _emberUtils.guidFor(this) + extension + '>'; - function PutIteratorOpcode() { - _Opcode.apply(this, arguments); - this.type = "put-iterator"; - } + return ret; + }, _Mixin$create)); - PutIteratorOpcode.prototype.evaluate = function evaluate(vm) { - var listRef = vm.frame.getOperand(); - var args = vm.frame.getArgs(); - var iterable = vm.env.iterableFor(listRef, args); - var iterator = new _glimmerReference.ReferenceIterator(iterable); - vm.frame.setIterator(iterator); - vm.frame.setCondition(new IterablePresenceReference(iterator.artifacts)); - }; + CoreObject.PrototypeMixin.ownerConstructor = CoreObject; - return PutIteratorOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + CoreObject.__super__ = null; - exports.PutIteratorOpcode = PutIteratorOpcode; + var ClassMixinProps = (_ClassMixinProps = { - var EnterListOpcode = (function (_Opcode2) { - babelHelpers.inherits(EnterListOpcode, _Opcode2); + ClassMixin: _emberMetal.REQUIRED, - function EnterListOpcode(start, end) { - _Opcode2.call(this); - this.type = "enter-list"; - this.slice = new _glimmerUtil.ListSlice(start, end); - } + PrototypeMixin: _emberMetal.REQUIRED, - EnterListOpcode.prototype.evaluate = function evaluate(vm) { - vm.enterList(this.slice); - }; + isClass: true, - EnterListOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var type = this.type; - var _guid = this._guid; + isMethod: false + }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { + var Class = makeCtor(); + var proto = undefined; + Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); + Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + Class.ClassMixin.ownerConstructor = Class; + Class.PrototypeMixin.ownerConstructor = Class; - return EnterListOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + reopen.apply(Class.PrototypeMixin, arguments); - exports.EnterListOpcode = EnterListOpcode; + Class.superclass = this; + Class.__super__ = this.prototype; - var ExitListOpcode = (function (_Opcode3) { - babelHelpers.inherits(ExitListOpcode, _Opcode3); + proto = Class.prototype = Object.create(this.prototype); + proto.constructor = Class; + _emberUtils.generateGuid(proto); + _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype - function ExitListOpcode() { - _Opcode3.apply(this, arguments); - this.type = "exit-list"; - } + Class.ClassMixin.apply(Class); + return Class; + }, _ClassMixinProps.create = function () { + var C = this; - ExitListOpcode.prototype.evaluate = function evaluate(vm) { - vm.exitList(); - }; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - return ExitListOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (args.length > 0) { + this._initProperties(args); + } + return new C(); + }, _ClassMixinProps.reopen = function () { + this.willReopen(); + reopen.apply(this.PrototypeMixin, arguments); + return this; + }, _ClassMixinProps.reopenClass = function () { + reopen.apply(this.ClassMixin, arguments); + applyMixin(this, arguments, false); + return this; + }, _ClassMixinProps.detect = function (obj) { + if ('function' !== typeof obj) { + return false; + } + while (obj) { + if (obj === this) { + return true; + } + obj = obj.superclass; + } + return false; + }, _ClassMixinProps.detectInstance = function (obj) { + return obj instanceof this; + }, _ClassMixinProps.metaForProperty = function (key) { + var proto = this.proto(); + var possibleDesc = proto[key]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - exports.ExitListOpcode = ExitListOpcode; + _emberMetal.assert('metaForProperty() could not find a computed property with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); + return desc._meta || {}; + }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { + hasCachedComputedProperties = true; + var proto = this.proto(); + var property = undefined; + var properties = []; - var EnterWithKeyOpcode = (function (_Opcode4) { - babelHelpers.inherits(EnterWithKeyOpcode, _Opcode4); + for (var _name in proto) { + property = proto[_name]; - function EnterWithKeyOpcode(start, end) { - _Opcode4.call(this); - this.type = "enter-with-key"; - this.slice = new _glimmerUtil.ListSlice(start, end); - } + if (property && property.isDescriptor) { + properties.push({ + name: _name, + meta: property._meta + }); + } + } + return properties; + }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { + var property = undefined; + var empty = {}; - EnterWithKeyOpcode.prototype.evaluate = function evaluate(vm) { - vm.enterWithKey(vm.frame.getKey(), this.slice); - }; + var properties = _emberMetal.get(this, '_computedProperties'); - EnterWithKeyOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var _guid = this._guid; - var type = this.type; + for (var i = 0; i < properties.length; i++) { + property = properties[i]; + callback.call(binding || this, property.name, property.meta || empty); + } + }, _ClassMixinProps); - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + function injectedPropertyAssertion() { + _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this)); + } - return EnterWithKeyOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberMetal.runInDebug(function () { + /** + Provides lookup-time type validation for injected properties. + @private + @method _onLookup + */ + ClassMixinProps._onLookup = injectedPropertyAssertion; + }); - exports.EnterWithKeyOpcode = EnterWithKeyOpcode; + /** + Returns a hash of property names and container names that injected + properties will lookup on the container lazily. + + @method _lazyInjections + @return {Object} Hash of all lazy injected property keys to container names + @private + */ + ClassMixinProps._lazyInjections = function () { + var injections = {}; + var proto = this.proto(); + var key = undefined; + var desc = undefined; - var TRUE_REF = new _glimmerReference.ConstReference(true); - var FALSE_REF = new _glimmerReference.ConstReference(false); + for (key in proto) { + desc = proto[key]; + if (desc instanceof _emberMetal.InjectedProperty) { + injections[key] = desc.type + ':' + (desc.name || key); + } + } - var NextIterOpcode = (function (_Opcode5) { - babelHelpers.inherits(NextIterOpcode, _Opcode5); + return injections; + }; - function NextIterOpcode(end) { - _Opcode5.call(this); - this.type = "next-iter"; - this.end = end; - } + var ClassMixin = _emberMetal.Mixin.create(ClassMixinProps); - NextIterOpcode.prototype.evaluate = function evaluate(vm) { - var item = vm.frame.getIterator().next(); - if (item) { - vm.frame.setCondition(TRUE_REF); - vm.frame.setKey(item.key); - vm.frame.setOperand(item.value); - vm.frame.setArgs(_glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs.positional([item.value, item.memo])); - } else { - vm.frame.setCondition(FALSE_REF); - vm.goto(this.end); - } - }; + ClassMixin.ownerConstructor = CoreObject; - return NextIterOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + CoreObject.ClassMixin = ClassMixin; - exports.NextIterOpcode = NextIterOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9saXN0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFPQSx5QkFBQTtBQUlFLGlCQUpGLHlCQUFBLENBSWMsU0FBNkIsRUFBQTtBQUN2QyxnQkFBSSxDQUFDLEdBQUcsR0FBRyxTQUFTLENBQUMsR0FBRyxDQUFDO0FBQ3pCLGdCQUFJLENBQUMsU0FBUyxHQUFHLFNBQVMsQ0FBQztTQUM1Qjs7QUFQSCxpQ0FBQSxXQVNFLEtBQUssR0FBQSxpQkFBQTtBQUNILG1CQUFPLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLEVBQUUsQ0FBQztTQUNsQzs7ZUFYSCx5QkFBQTs7O1FBY0EsaUJBQUE7OEJBQUEsaUJBQUE7O0FBQUEsaUJBQUEsaUJBQUEsR0FBQTtBQUF1QyxnQ0FBQSxTQUFBLENBQUE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glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm'], function (exports, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm) { - 'use strict'; + ClassMixin.apply(CoreObject); - var PutDynamicPartialDefinitionOpcode = (function (_Opcode) { - babelHelpers.inherits(PutDynamicPartialDefinitionOpcode, _Opcode); + CoreObject.reopen({ + didDefineProperty: function (proto, key, value) { + if (hasCachedComputedProperties === false) { + return; + } + if (value instanceof _emberMetal.ComputedProperty) { + var cache = _emberMetal.meta(this.constructor).readableCache(); - function PutDynamicPartialDefinitionOpcode(symbolTable) { - _Opcode.call(this); - this.symbolTable = symbolTable; - this.type = "put-dynamic-partial-definition"; + if (cache && cache._computedProperties !== undefined) { + cache._computedProperties = undefined; } + } + } + }); - PutDynamicPartialDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - var env = vm.env; - var symbolTable = this.symbolTable; + exports.default = CoreObject; +}); +// Private, and only for didInitAttrs willRecieveAttrs - function lookupPartial(name) { - var normalized = String(name); - if (!env.hasPartial(normalized, symbolTable)) { - throw new Error('Could not find a partial named "' + normalized + '"'); - } - return env.lookupPartial(normalized, symbolTable); - } - var reference = _glimmerReference.map(vm.frame.getOperand(), lookupPartial); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var definition = cache ? cache.peek() : reference.value(); - vm.frame.setImmediate(definition); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; +/** + Defines the properties that will be concatenated from the superclass + (instead of overridden). + By default, when you extend an Ember class a property defined in + the subclass overrides a property with the same name that is defined + in the superclass. However, there are some cases where it is preferable + to build up a property's value by combining the superclass' property + value with the subclass' value. An example of this in use within Ember + is the `classNames` property of `Ember.View`. + Here is some sample code showing the difference between a concatenated + property and a normal one: + ```javascript + const Bar = Ember.Object.extend({ + // Configure which properties to concatenate + concatenatedProperties: ['concatenatedProperty'], + someNonConcatenatedProperty: ['bar'], + concatenatedProperty: ['bar'] + }); + const FooBar = Bar.extend({ + someNonConcatenatedProperty: ['foo'], + concatenatedProperty: ['foo'] + }); + let fooBar = FooBar.create(); + fooBar.get('someNonConcatenatedProperty'); // ['foo'] + fooBar.get('concatenatedProperty'); // ['bar', 'foo'] + ``` + This behavior extends to object creation as well. Continuing the + above example: + ```javascript + let fooBar = FooBar.create({ + someNonConcatenatedProperty: ['baz'], + concatenatedProperty: ['baz'] + }) + fooBar.get('someNonConcatenatedProperty'); // ['baz'] + fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] + ``` + Adding a single property that is not an array will just add it in the array: + ```javascript + let fooBar = FooBar.create({ + concatenatedProperty: 'baz' + }) + view.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] + ``` + Using the `concatenatedProperties` property, we can tell Ember to mix the + content of the properties. + In `Ember.Component` the `classNames`, `classNameBindings` and + `attributeBindings` properties are concatenated. + This feature is available for you to use throughout the Ember object model, + although typical app developers are likely to use it infrequently. Since + it changes expectations about behavior of properties, you should properly + document its usage in each individual concatenated property (to not + mislead your users to think they can override the property in a subclass). + @property concatenatedProperties + @type Array + @default null + @public +*/ - PutDynamicPartialDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; +/** + Defines the properties that will be merged from the superclass + (instead of overridden). + By default, when you extend an Ember class a property defined in + the subclass overrides a property with the same name that is defined + in the superclass. However, there are some cases where it is preferable + to build up a property's value by merging the superclass property value + with the subclass property's value. An example of this in use within Ember + is the `queryParams` property of routes. + Here is some sample code showing the difference between a merged + property and a normal one: + ```javascript + const Bar = Ember.Object.extend({ + // Configure which properties are to be merged + mergedProperties: ['mergedProperty'], + someNonMergedProperty: { + nonMerged: 'superclass value of nonMerged' + }, + mergedProperty: { + page: {replace: false}, + limit: {replace: true} + } + }); + const FooBar = Bar.extend({ + someNonMergedProperty: { + completelyNonMerged: 'subclass value of nonMerged' + }, + mergedProperty: { + limit: {replace: false} + } + }); + let fooBar = FooBar.create(); + fooBar.get('someNonMergedProperty'); + // => { completelyNonMerged: 'subclass value of nonMerged' } + // + // Note the entire object, including the nonMerged property of + // the superclass object, has been replaced + fooBar.get('mergedProperty'); + // => { + // page: {replace: false}, + // limit: {replace: false} + // } + // + // Note the page remains from the superclass, and the + // `limit` property's value of `false` has been merged from + // the subclass. + ``` + This behavior is not available during object `create` calls. It is only + available at `extend` time. + In `Ember.Route` the `queryParams` property is merged. + This feature is available for you to use throughout the Ember object model, + although typical app developers are likely to use it infrequently. Since + it changes expectations about behavior of properties, you should properly + document its usage in each individual merged property (to not + mislead your users to think they can override the property in a subclass). + @property mergedProperties + @type Array + @default null + @public +*/ - return PutDynamicPartialDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); +/** + Destroyed object property flag. + if this property is `true` the observers and bindings were already + removed by the effect of calling the `destroy()` method. + @property isDestroyed + @default false + @public +*/ - exports.PutDynamicPartialDefinitionOpcode = PutDynamicPartialDefinitionOpcode; +/** + Destruction scheduled flag. The `destroy()` method has been called. + The object stays intact until the end of the run loop at which point + the `isDestroyed` flag is set. + @property isDestroying + @default false + @public +*/ - var PutPartialDefinitionOpcode = (function (_Opcode2) { - babelHelpers.inherits(PutPartialDefinitionOpcode, _Opcode2); +/** + Destroys an object by setting the `isDestroyed` flag and removing its + metadata, which effectively destroys observers and bindings. + If you try to set a property on a destroyed object, an exception will be + raised. + Note that destruction is scheduled for the end of the run loop and does not + happen immediately. It will set an isDestroying flag immediately. + @method destroy + @return {Ember.Object} receiver + @public +*/ - function PutPartialDefinitionOpcode(definition) { - _Opcode2.call(this); - this.definition = definition; - this.type = "put-partial-definition"; - } +/** + Override to implement teardown. + @method willDestroy + @public +*/ - PutPartialDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setImmediate(this.definition); - }; +/** + Invoked by the run loop to actually destroy the object. This is + scheduled for execution by the `destroy` method. + @private + @method _scheduledDestroy +*/ - PutPartialDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.definition.name)] - }; - }; +/** + Returns a string representation which attempts to provide more information + than Javascript's `toString` typically does, in a generic way for all Ember + objects. + ```javascript + const Person = Ember.Object.extend() + person = Person.create() + person.toString() //=> "" + ``` + If the object's class is not defined on an Ember namespace, it will + indicate it is a subclass of the registered superclass: + ```javascript + const Student = Person.extend() + let student = Student.create() + student.toString() //=> "<(subclass of Person):ember1025>" + ``` + If the method `toStringExtension` is defined, its return value will be + included in the output. + ```javascript + const Teacher = Person.extend({ + toStringExtension() { + return this.get('fullName'); + } + }); + teacher = Teacher.create() + teacher.toString(); //=> "" + ``` + @method toString + @return {String} string representation + @public +*/ - return PutPartialDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); +/** + Creates a new subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(thing); + } + }); + ``` + This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. + You can also create a subclass from any existing class by calling its `extend()` method. + For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: + ```javascript + const PersonComponent = Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isAdministrator'] + }); + ``` + When defining a subclass, you can override methods but still access the + implementation of your parent class by calling the special `_super()` method: + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + let name = this.get('name'); + alert(`${name} says: ${thing}`); + } + }); + const Soldier = Person.extend({ + say(thing) { + this._super(`${thing}, sir!`); + }, + march(numberOfHours) { + alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + } + }); + let yehuda = Soldier.create({ + name: "Yehuda Katz" + }); + yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" + ``` + The `create()` on line #17 creates an *instance* of the `Soldier` class. + The `extend()` on line #8 creates a *subclass* of `Person`. Any instance + of the `Person` class will *not* have the `march()` method. + You can also pass `Mixin` classes to add additional properties to the subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(`${this.get('name')} says: ${thing}`); + } + }); + const SingingMixin = Mixin.create({ + sing(thing){ + alert(`${this.get('name')} sings: la la la ${thing}`); + } + }); + const BroadwayStar = Person.extend(SingingMixin, { + dance() { + alert(`${this.get('name')} dances: tap tap tap tap `); + } + }); + ``` + The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. + @method extend + @static + @param {Mixin} [mixins]* One or more Mixin classes + @param {Object} [arguments]* Object containing values to use within the new class + @public +*/ - exports.PutPartialDefinitionOpcode = PutPartialDefinitionOpcode; +/** + Creates an instance of a class. Accepts either no arguments, or an object + containing values to initialize the newly instantiated object with. + ```javascript + const Person = Ember.Object.extend({ + helloWorld() { + alert(`Hi, my name is ${this.get('name')}`); + } + }); + let tom = Person.create({ + name: 'Tom Dale' + }); + tom.helloWorld(); // alerts "Hi, my name is Tom Dale". + ``` + `create` will call the `init` function if defined during + `Ember.AnyObject.extend` + If no arguments are passed to `create`, it will not set values to the new + instance during initialization: + ```javascript + let noName = Person.create(); + noName.helloWorld(); // alerts undefined + ``` + NOTE: For performance reasons, you cannot declare methods or computed + properties during `create`. You should instead declare methods and computed + properties when using `extend`. + @method create + @static + @param [arguments]* + @public +*/ - var EvaluatePartialOpcode = (function (_Opcode3) { - babelHelpers.inherits(EvaluatePartialOpcode, _Opcode3); +/** + Augments a constructor's prototype with additional + properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + o = MyObject.create(); + o.get('name'); // 'an object' + MyObject.reopen({ + say(msg){ + console.log(msg); + } + }) + o2 = MyObject.create(); + o2.say("hello"); // logs "hello" + o.say("goodbye"); // logs "goodbye" + ``` + To add functions and properties to the constructor itself, + see `reopenClass` + @method reopen + @public +*/ - function EvaluatePartialOpcode(symbolTable) { - _Opcode3.call(this); - this.symbolTable = symbolTable; - this.type = "evaluate-partial"; - this.cache = _glimmerUtil.dict(); - } +/** + Augments a constructor's own properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + MyObject.reopenClass({ + canBuild: false + }); + MyObject.canBuild; // false + o = MyObject.create(); + ``` + In other words, this creates static properties and functions for the class. + These are only available on the class and not on any instance of that class. + ```javascript + const Person = Ember.Object.extend({ + name: "", + sayHello() { + alert("Hello. My name is " + this.get('name')); + } + }); + Person.reopenClass({ + species: "Homo sapiens", + createPerson(newPersonsName){ + return Person.create({ + name:newPersonsName + }); + } + }); + let tom = Person.create({ + name: "Tom Dale" + }); + let yehuda = Person.createPerson("Yehuda Katz"); + tom.sayHello(); // "Hello. My name is Tom Dale" + yehuda.sayHello(); // "Hello. My name is Yehuda Katz" + alert(Person.species); // "Homo sapiens" + ``` + Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` + variables. They are only valid on `Person`. + To add functions and properties to instances of + a constructor by extending the constructor's prototype + see `reopen` + @method reopenClass + @public +*/ - EvaluatePartialOpcode.prototype.evaluate = function evaluate(vm) { - var _vm$frame$getImmediate = vm.frame.getImmediate(); +/** + 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: + ```javascript + person: Ember.computed(function() { + let personId = this.get('personId'); + return Person.create({ id: personId }); + }).meta({ type: Person }) + ``` + Once you've done this, you can retrieve the values saved to the computed + property from your class like this: + ```javascript + MyClass.metaForProperty('person'); + ``` + This will return the original hash that was passed to `meta()`. + @static + @method metaForProperty + @param key {String} property name + @private +*/ - var template = _vm$frame$getImmediate.template; +/** + Iterate over each computed property for the class, passing its name + and any associated metadata (see `metaForProperty`) to the callback. + @static + @method eachComputedProperty + @param {Function} callback + @param {Object} binding + @private +*/ +enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { + 'use strict'; - var block = this.cache[template.id]; - if (!block) { - block = template.asPartial(this.symbolTable); - } - vm.invokePartial(block); - }; + exports.default = EachProxy; - EvaluatePartialOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + /** + This is the object instance returned when you get the `@each` property on an + array. It uses the unknownProperty handler to automatically create + EachArray instances for property names. + @class EachProxy + @private + */ - return EvaluatePartialOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function EachProxy(content) { + this._content = content; + this._keys = undefined; + this.__ember_meta__ = null; + } - exports.EvaluatePartialOpcode = EvaluatePartialOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9wYXJ0aWFsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVNBLGlDQUFBOzhCQUFBLGlDQUFBOztBQUdFLGlCQUhGLGlDQUFBLENBR3NCLFdBQXdCLEVBQUE7QUFDMUMsOEJBQU8sQ0FBQztBQURVLGdCQUFBLENBQUEsV0FBVyxHQUFYLFdBQVcsQ0FBYTtBQUZyQyxnQkFBQSxDQUFBLElBQUksR0FBRyxnQ0FBZ0MsQ0FBQztTQUk5Qzs7QUFMSCx5Q0FBQSxXQU9FLFFBQVEsR0FBQSxrQkFBQyxFQUFNLEVBQUE7QUFDYixnQkFBSSxHQUFHLEdBQUcsRUFBRSxDQUFDLEdBQUcsQ0FBQztnQkFDWCxXQUFXLEdBQUssSUFBSSxDQUFwQixXQUFXOztBQUVqQixxQkFBQSxhQUFBLENBQXVCLElBQVksRUFBQTtBQUNqQyxvQkFBSSxVQUFVLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBRTlCLG9CQUFJLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxVQUFVLEVBQUUsV0FBVyxDQUFDLEVBQUU7QUFDNUMsMEJBQU0sSUFBSSxLQUFLLHNDQUFvQyxVQUFVLE9BQUksQ0FBQztpQkFDbkU7QUFFRCx1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FtZS5nZXRJbW1lZGlhdGU8UGFydGlhbERlZmluaXRpb248T3BhcXVlPj4oKTtcblxuICAgIGxldCBibG9jayA9IHRoaXMuY2FjaGVbdGVtcGxhdGUuaWRdO1xuXG4gICAgaWYgKCFibG9jaykge1xuICAgICAgYmxvY2sgPSB0ZW1wbGF0ZS5hc1BhcnRpYWwodGhpcy5zeW1ib2xUYWJsZSk7XG4gICAgfVxuXG4gICAgdm0uaW52b2tlUGFydGlhbChibG9jayk7XG4gIH1cblxuICB0b0pTT04oKTogT3Bjb2RlSlNPTiB7XG4gICAgcmV0dXJuIHtcbiAgICAgIGd1aWQ6IHRoaXMuX2d1aWQsXG4gICAgICB0eXBlOiB0aGlzLnR5cGUsXG4gICAgICBhcmdzOiBbXCIkT1BFUkFORFwiXVxuICAgIH07XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/opcodes/vm', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/references', 'glimmer-reference', 'glimmer-util'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibReferences, _glimmerReference, _glimmerUtil) { - 'use strict'; + EachProxy.prototype = { + __defineNonEnumerable: function (property) { + this[property.name] = property.descriptor.value; + }, - var PushChildScopeOpcode = (function (_Opcode) { - babelHelpers.inherits(PushChildScopeOpcode, _Opcode); + // .......................................................... + // ARRAY CHANGES + // Invokes whenever the content array itself changes. - function PushChildScopeOpcode() { - _Opcode.apply(this, arguments); - this.type = "push-child-scope"; + arrayWillChange: function (content, idx, removedCnt, addedCnt) { + var keys = this._keys; + var lim = removedCnt > 0 ? idx + removedCnt : -1; + for (var key in keys) { + if (lim > 0) { + removeObserverForContentKey(content, key, this, idx, lim); } + _emberMetal.propertyWillChange(this, key); + } + }, - PushChildScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.pushChildScope(); - }; - - return PushChildScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PushChildScopeOpcode = PushChildScopeOpcode; - - var PopScopeOpcode = (function (_Opcode2) { - babelHelpers.inherits(PopScopeOpcode, _Opcode2); - - function PopScopeOpcode() { - _Opcode2.apply(this, arguments); - this.type = "pop-scope"; + arrayDidChange: function (content, idx, removedCnt, addedCnt) { + var keys = this._keys; + var lim = addedCnt > 0 ? idx + addedCnt : -1; + for (var key in keys) { + if (lim > 0) { + addObserverForContentKey(content, key, this, idx, lim); } + _emberMetal.propertyDidChange(this, key); + } + }, - PopScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - }; + // .......................................................... + // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS + // Start monitoring keys based on who is listening... - return PopScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + willWatchProperty: function (property) { + this.beginObservingContentKey(property); + }, - exports.PopScopeOpcode = PopScopeOpcode; + didUnwatchProperty: function (property) { + this.stopObservingContentKey(property); + }, - var PushDynamicScopeOpcode = (function (_Opcode3) { - babelHelpers.inherits(PushDynamicScopeOpcode, _Opcode3); + // .......................................................... + // CONTENT KEY OBSERVING + // Actual watch keys on the source content. - function PushDynamicScopeOpcode() { - _Opcode3.apply(this, arguments); - this.type = "push-dynamic-scope"; - } + beginObservingContentKey: function (keyName) { + var keys = this._keys; + if (!keys) { + keys = this._keys = new _emberUtils.EmptyObject(); + } - PushDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.pushDynamicScope(); - }; + if (!keys[keyName]) { + keys[keyName] = 1; + var content = this._content; + var len = _emberMetal.get(content, 'length'); - return PushDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + addObserverForContentKey(content, keyName, this, 0, len); + } else { + keys[keyName]++; + } + }, - exports.PushDynamicScopeOpcode = PushDynamicScopeOpcode; + stopObservingContentKey: function (keyName) { + var keys = this._keys; + if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) { + var content = this._content; + var len = _emberMetal.get(content, 'length'); - var PopDynamicScopeOpcode = (function (_Opcode4) { - babelHelpers.inherits(PopDynamicScopeOpcode, _Opcode4); + removeObserverForContentKey(content, keyName, this, 0, len); + } + }, - function PopDynamicScopeOpcode() { - _Opcode4.apply(this, arguments); - this.type = "pop-dynamic-scope"; - } + contentKeyWillChange: function (obj, keyName) { + _emberMetal.propertyWillChange(this, keyName); + }, - PopDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.popDynamicScope(); - }; + contentKeyDidChange: function (obj, keyName) { + _emberMetal.propertyDidChange(this, keyName); + } + }; - return PopDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function addObserverForContentKey(content, keyName, proxy, idx, loc) { + while (--loc >= idx) { + var item = _emberRuntimeMixinsArray.objectAt(content, loc); + if (item) { + _emberMetal.assert('When using @each to observe the array ' + content + ', the array must return an object', typeof item === 'object'); + _emberMetal._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); + _emberMetal.addObserver(item, keyName, proxy, 'contentKeyDidChange'); + } + } + } - exports.PopDynamicScopeOpcode = PopDynamicScopeOpcode; + function removeObserverForContentKey(content, keyName, proxy, idx, loc) { + while (--loc >= idx) { + var item = _emberRuntimeMixinsArray.objectAt(content, loc); + if (item) { + _emberMetal._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); + _emberMetal.removeObserver(item, keyName, proxy, 'contentKeyDidChange'); + } + } + } +}); +enifed('ember-runtime/system/lazy_load', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + /*globals CustomEvent */ - var PutNullOpcode = (function (_Opcode5) { - babelHelpers.inherits(PutNullOpcode, _Opcode5); + 'use strict'; - function PutNullOpcode() { - _Opcode5.apply(this, arguments); - this.type = "put-null"; - } + exports.onLoad = onLoad; + exports.runLoadHooks = runLoadHooks; - PutNullOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setOperand(_glimmerRuntimeLibReferences.NULL_REFERENCE); - }; + /** + @module ember + @submodule ember-runtime + */ - return PutNullOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var loadHooks = _emberEnvironment.ENV.EMBER_LOAD_HOOKS || {}; + var loaded = {}; + var _loaded = loaded; - exports.PutNullOpcode = PutNullOpcode; + exports._loaded = _loaded; + /** + Detects when a specific package of Ember (e.g. 'Ember.Application') + has fully loaded and is available for extension. + + The provided `callback` will be called with the `name` passed + resolved from a string into the object: + + ``` javascript + Ember.onLoad('Ember.Application' function(hbars) { + hbars.registerHelper(...); + }); + ``` + + @method onLoad + @for Ember + @param name {String} name of hook + @param callback {Function} callback to be called + @private + */ - var PutValueOpcode = (function (_Opcode6) { - babelHelpers.inherits(PutValueOpcode, _Opcode6); + function onLoad(name, callback) { + var object = loaded[name]; - function PutValueOpcode(expression) { - _Opcode6.call(this); - this.expression = expression; - this.type = "put-value"; - } + loadHooks[name] = loadHooks[name] || []; + loadHooks[name].push(callback); - PutValueOpcode.prototype.evaluate = function evaluate(vm) { - vm.evaluateOperand(this.expression); - }; + if (object) { + callback(object); + } + } - PutValueOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [this.expression.toJSON()] - }; - }; + /** + Called when an Ember.js package (e.g Ember.Application) has finished + loading. Triggers any callbacks registered for this event. + + @method runLoadHooks + @for Ember + @param name {String} name of hook + @param object {Object} object to pass to callbacks + @private + */ - return PutValueOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function runLoadHooks(name, object) { + loaded[name] = object; + var window = _emberEnvironment.environment.window; - exports.PutValueOpcode = PutValueOpcode; + if (window && typeof CustomEvent === 'function') { + var _event = new CustomEvent(name, { detail: object, name: name }); + window.dispatchEvent(_event); + } - var PutArgsOpcode = (function (_Opcode7) { - babelHelpers.inherits(PutArgsOpcode, _Opcode7); + if (loadHooks[name]) { + loadHooks[name].forEach(function (callback) { + return callback(object); + }); + } + } +}); +enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-runtime/system/object'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberRuntimeSystemObject) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - function PutArgsOpcode(args) { - _Opcode7.call(this); - this.args = args; - this.type = "put-args"; - } + exports.isSearchDisabled = isSearchDisabled; + exports.setSearchDisabled = setSearchDisabled; - PutArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.evaluateArgs(this.args); - }; + var searchDisabled = false; - PutArgsOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - details: { - "positional": this.args.positional.toJSON(), - "named": this.args.named.toJSON() - } - }; - }; + function isSearchDisabled() { + return searchDisabled; + } - return PutArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function setSearchDisabled(flag) { + searchDisabled = !!flag; + } - exports.PutArgsOpcode = PutArgsOpcode; + /** + A Namespace is an object usually used to contain other objects or methods + such as an application or framework. Create a namespace anytime you want + to define one of these new containers. + + # Example Usage + + ```javascript + MyFramework = Ember.Namespace.create({ + VERSION: '1.0.0' + }); + ``` + + @class Namespace + @namespace Ember + @extends Ember.Object + @public + */ + var Namespace = _emberRuntimeSystemObject.default.extend({ + isNamespace: true, - var BindPositionalArgsOpcode = (function (_Opcode8) { - babelHelpers.inherits(BindPositionalArgsOpcode, _Opcode8); + init: function () { + Namespace.NAMESPACES.push(this); + Namespace.PROCESSED = false; + }, - function BindPositionalArgsOpcode(names, symbols) { - _Opcode8.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-positional-args"; - } + toString: function () { + var name = _emberMetal.get(this, 'name') || _emberMetal.get(this, 'modulePrefix'); + if (name) { + return name; + } - BindPositionalArgsOpcode.create = function create(block) { - var names = block.locals; - var symbols = names.map(function (name) { - return block.symbolTable.getLocal(name); - }); - return new this(names, symbols); - }; + findNamespaces(); + return this[_emberUtils.NAME_KEY]; + }, - BindPositionalArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindPositionalArgs(this.symbols); - }; + nameClasses: function () { + processNamespace([this.toString()], this, {}); + }, - BindPositionalArgsOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ['[' + this.names.map(function (name) { - return JSON.stringify(name); - }).join(", ") + ']'] - }; - }; + destroy: function () { + var namespaces = Namespace.NAMESPACES; + var toString = this.toString(); - return BindPositionalArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (toString) { + _emberEnvironment.context.lookup[toString] = undefined; + delete Namespace.NAMESPACES_BY_ID[toString]; + } + namespaces.splice(namespaces.indexOf(this), 1); + this._super.apply(this, arguments); + } + }); - exports.BindPositionalArgsOpcode = BindPositionalArgsOpcode; + Namespace.reopenClass({ + NAMESPACES: [_emberMetal.default], + NAMESPACES_BY_ID: { + Ember: _emberMetal.default + }, + PROCESSED: false, + processAll: processAllNamespaces, + byName: function (name) { + if (!searchDisabled) { + processAllNamespaces(); + } - var BindNamedArgsOpcode = (function (_Opcode9) { - babelHelpers.inherits(BindNamedArgsOpcode, _Opcode9); + return NAMESPACES_BY_ID[name]; + } + }); - function BindNamedArgsOpcode(names, symbols) { - _Opcode9.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-named-args"; - } + var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; - BindNamedArgsOpcode.create = function create(layout) { - var names = layout.named; - var symbols = names.map(function (name) { - return layout.symbolTable.getNamed(name); - }); - return new this(names, symbols); - }; + var hasOwnProp = ({}).hasOwnProperty; - BindNamedArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindNamedArgs(this.names, this.symbols); - }; + function processNamespace(paths, root, seen) { + var idx = paths.length; - BindNamedArgsOpcode.prototype.toJSON = function toJSON() { - var names = this.names; - var symbols = this.symbols; + NAMESPACES_BY_ID[paths.join('.')] = root; - var args = names.map(function (name, i) { - return '$' + symbols[i] + ': $ARGS[' + name + ']'; - }); - return { - guid: this._guid, - type: this.type, - args: args - }; - }; + // Loop over all of the keys in the namespace, looking for classes + for (var key in root) { + if (!hasOwnProp.call(root, key)) { + continue; + } + var obj = root[key]; - return BindNamedArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + // If we are processing the `Ember` namespace, for example, the + // `paths` will start with `["Ember"]`. Every iteration through + // the loop will update the **second** element of this list with + // the key, so processing `Ember.View` will make the Array + // `['Ember', 'View']`. + paths[idx] = key; - exports.BindNamedArgsOpcode = BindNamedArgsOpcode; + // If we have found an unprocessed class + if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { + // Replace the class' `toString` with the dot-separated path + // and set its `NAME_KEY` + obj[_emberUtils.NAME_KEY] = paths.join('.'); - var BindBlocksOpcode = (function (_Opcode10) { - babelHelpers.inherits(BindBlocksOpcode, _Opcode10); + // Support nested namespaces + } else if (obj && obj.isNamespace) { + // Skip aliased namespaces + if (seen[_emberUtils.guidFor(obj)]) { + continue; + } + seen[_emberUtils.guidFor(obj)] = true; - function BindBlocksOpcode(names, symbols) { - _Opcode10.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-blocks"; + // Process the child namespace + processNamespace(paths, obj, seen); } + } - BindBlocksOpcode.create = function create(layout) { - var names = layout.yields; - var symbols = names.map(function (name) { - return layout.symbolTable.getYield(name); - }); - return new this(names, symbols); - }; - - BindBlocksOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindBlocks(this.names, this.symbols); - }; - - BindBlocksOpcode.prototype.toJSON = function toJSON() { - var names = this.names; - var symbols = this.symbols; - - var args = names.map(function (name, i) { - return '$' + symbols[i] + ': $BLOCKS[' + name + ']'; - }); - return { - guid: this._guid, - type: this.type, - args: args - }; - }; - - return BindBlocksOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + paths.length = idx; // cut out last item + } - exports.BindBlocksOpcode = BindBlocksOpcode; + function isUppercase(code) { + return code >= 65 && // A + code <= 90; // Z + } - var BindPartialArgsOpcode = (function (_Opcode11) { - babelHelpers.inherits(BindPartialArgsOpcode, _Opcode11); + function tryIsNamespace(lookup, prop) { + try { + var obj = lookup[prop]; + return obj && obj.isNamespace && obj; + } catch (e) { + // continue + } + } - function BindPartialArgsOpcode(symbol) { - _Opcode11.call(this); - this.symbol = symbol; - this.type = "bind-partial-args"; - } + function findNamespaces() { + if (Namespace.PROCESSED) { + return; + } + var lookup = _emberEnvironment.context.lookup; + var keys = Object.keys(lookup); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + // Only process entities that start with uppercase A-Z + if (!isUppercase(key.charCodeAt(0))) { + continue; + } + var obj = tryIsNamespace(lookup, key); + if (obj) { + obj[_emberUtils.NAME_KEY] = key; + } + } + } - BindPartialArgsOpcode.create = function create(layout) { - return new this(layout.symbolTable.getPartialArgs()); - }; + function superClassString(mixin) { + var superclass = mixin.superclass; + if (superclass) { + if (superclass[_emberUtils.NAME_KEY]) { + return superclass[_emberUtils.NAME_KEY]; + } + return superClassString(superclass); + } + } - BindPartialArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindPartialArgs(this.symbol); - }; + function calculateToString(target) { + var str = undefined; - return BindPartialArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (!searchDisabled) { + processAllNamespaces(); + // can also be set by processAllNamespaces + str = target[_emberUtils.NAME_KEY]; + if (str) { + return str; + } else { + str = superClassString(target); + str = str ? '(subclass of ' + str + ')' : str; + } + } + if (str) { + return str; + } else { + return '(unknown mixin)'; + } + } - exports.BindPartialArgsOpcode = BindPartialArgsOpcode; + function classToString() { + var name = this[_emberUtils.NAME_KEY]; + if (name) { + return name; + } - var BindCallerScopeOpcode = (function (_Opcode12) { - babelHelpers.inherits(BindCallerScopeOpcode, _Opcode12); + return this[_emberUtils.NAME_KEY] = calculateToString(this); + } - function BindCallerScopeOpcode() { - _Opcode12.apply(this, arguments); - this.type = "bind-caller-scope"; - } + function processAllNamespaces() { + var unprocessedNamespaces = !Namespace.PROCESSED; + var unprocessedMixins = _emberMetal.hasUnprocessedMixins(); - BindCallerScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindCallerScope(); - }; + if (unprocessedNamespaces) { + findNamespaces(); + Namespace.PROCESSED = true; + } - return BindCallerScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (unprocessedNamespaces || unprocessedMixins) { + var namespaces = Namespace.NAMESPACES; + var namespace = undefined; - exports.BindCallerScopeOpcode = BindCallerScopeOpcode; + for (var i = 0; i < namespaces.length; i++) { + namespace = namespaces[i]; + processNamespace([namespace.toString()], namespace, {}); + } - var BindDynamicScopeOpcode = (function (_Opcode13) { - babelHelpers.inherits(BindDynamicScopeOpcode, _Opcode13); + _emberMetal.clearUnprocessedMixins(); + } + } - function BindDynamicScopeOpcode(names) { - _Opcode13.call(this); - this.names = names; - this.type = "bind-dynamic-scope"; - } + _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. - BindDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindDynamicScope(this.names); - }; + exports.default = Namespace; +}); +// Preloaded into namespaces +enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - return BindDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var _NativeArray; - exports.BindDynamicScopeOpcode = BindDynamicScopeOpcode; + // Add Ember.Array to Array.prototype. Remove methods with native + // implementations and supply some more optimized versions of generic methods + // because they are so common. - var EnterOpcode = (function (_Opcode14) { - babelHelpers.inherits(EnterOpcode, _Opcode14); + /** + The NativeArray mixin contains the properties needed to make the native + Array support Ember.MutableArray and all of its dependent APIs. Unless you + have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to + false, this will be applied automatically. Otherwise you can apply the mixin + at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. + + @class NativeArray + @namespace Ember + @uses Ember.MutableArray + @uses Ember.Observable + @uses Ember.Copyable + @public + */ + var NativeArray = _emberMetal.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, { - function EnterOpcode(begin, end) { - _Opcode14.call(this); - this.type = "enter"; - this.slice = new _glimmerUtil.ListSlice(begin, end); - } + // because length is a built-in property we need to know to just get the + // original property. + get: function (key) { + if ('number' === typeof key) { + return this[key]; + } else { + return this._super(key); + } + }, - EnterOpcode.prototype.evaluate = function evaluate(vm) { - vm.enter(this.slice); - }; + objectAt: function (idx) { + return this[idx]; + }, - EnterOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var type = this.type; - var _guid = this._guid; + // primitive for array support. + replace: function (idx, amt, objects) { + if (this.isFrozen) { + throw _emberRuntimeMixinsFreezable.FROZEN_ERROR; + } - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + // if we replaced exactly the same number of items, then pass only the + // replaced range. Otherwise, pass the full remaining array length + // since everything has shifted + var len = objects ? _emberMetal.get(objects, 'length') : 0; + _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, amt, len); - return EnterOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (len === 0) { + this.splice(idx, amt); + } else { + _emberMetal.replace(this, idx, amt, objects); + } - exports.EnterOpcode = EnterOpcode; + _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, amt, len); + return this; + }, - var ExitOpcode = (function (_Opcode15) { - babelHelpers.inherits(ExitOpcode, _Opcode15); + // If you ask for an unknown property, then try to collect the value + // from member items. + unknownProperty: function (key, value) { + var ret = undefined; // = this.reducedProperty(key, value); + if (value !== undefined && ret === undefined) { + ret = this[key] = value; + } + return ret; + }, - function ExitOpcode() { - _Opcode15.apply(this, arguments); - this.type = "exit"; - } + indexOf: Array.prototype.indexOf, + lastIndexOf: Array.prototype.lastIndexOf, - ExitOpcode.prototype.evaluate = function evaluate(vm) { - vm.exit(); - }; + copy: function (deep) { + if (deep) { + return this.map(function (item) { + return _emberRuntimeCopy.default(item, true); + }); + } - return ExitOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + return this.slice(); + } + }); - exports.ExitOpcode = ExitOpcode; + // Remove any methods implemented natively so we don't override them + var ignore = ['length']; + NativeArray.keys().forEach(function (methodName) { + if (Array.prototype[methodName]) { + ignore.push(methodName); + } + }); - var LabelOpcode = (function (_Opcode16) { - babelHelpers.inherits(LabelOpcode, _Opcode16); + exports.NativeArray // TODO: only use default export + = NativeArray = (_NativeArray = NativeArray).without.apply(_NativeArray, ignore); - function LabelOpcode(label) { - _Opcode16.call(this); - this.tag = _glimmerReference.CONSTANT_TAG; - this.type = "label"; - this.label = null; - this.prev = null; - this.next = null; - if (label) this.label = label; + /** + Creates an `Ember.NativeArray` from an Array like object. + Does not modify the original object. Ember.A is not needed if + `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However, + it is recommended that you use Ember.A when creating addons for + ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES` + will be `true`. + + Example + + ```js + export default Ember.Component.extend({ + tagName: 'ul', + classNames: ['pagination'], + + init() { + this._super(...arguments); + + if (!this.get('content')) { + this.set('content', Ember.A()); } + } + }); + ``` + + @method A + @for Ember + @return {Ember.NativeArray} + @public + */ + var A = undefined; - LabelOpcode.prototype.evaluate = function evaluate() {}; - - LabelOpcode.prototype.inspect = function inspect() { - return this.label + ' [' + this._guid + ']'; - }; - - LabelOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.inspect())] - }; - }; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Array) { + NativeArray.apply(Array.prototype); + exports.A = A = function (arr) { + return arr || []; + }; + } else { + exports.A = A = function (arr) { + if (!arr) { + arr = []; + } + return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr); + }; + } - return LabelOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberMetal.default.A = A; + exports.A = A; + exports.NativeArray = NativeArray; + exports.default = NativeArray; +}); +// Ember.A circular +enifed('ember-runtime/system/object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberUtils, _emberMetal, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) { + /** + @module ember + @submodule ember-runtime + */ - exports.LabelOpcode = LabelOpcode; + 'use strict'; - var EvaluateOpcode = (function (_Opcode17) { - babelHelpers.inherits(EvaluateOpcode, _Opcode17); + /** + `Ember.Object` is the main base class for all Ember objects. It is a subclass + of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, + see the documentation for each of these. + + @class Object + @namespace Ember + @extends Ember.CoreObject + @uses Ember.Observable + @public + */ + var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default); + EmberObject.toString = function () { + return 'Ember.Object'; + }; - function EvaluateOpcode(debug, block) { - _Opcode17.call(this); - this.debug = debug; - this.block = block; - this.type = "evaluate"; - } + var FrameworkObject = EmberObject; - EvaluateOpcode.prototype.evaluate = function evaluate(vm) { - vm.invokeBlock(this.block, vm.frame.getArgs()); - }; + exports.FrameworkObject = FrameworkObject; + _emberMetal.runInDebug(function () { + var _EmberObject$extend; - EvaluateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var debug = this.debug; - var block = this.block; - - var compiled = block['compiled']; - var children = undefined; - if (compiled) { - children = compiled.ops.toArray().map(function (op) { - return op.toJSON(); - }); - } else { - children = [{ guid: null, type: '[ UNCOMPILED BLOCK ]' }]; - } - return { - guid: guid, - type: type, - args: [debug], - children: children - }; - }; + var INIT_WAS_CALLED = _emberUtils.symbol('INIT_WAS_CALLED'); + var ASSERT_INIT_WAS_CALLED = _emberUtils.symbol('ASSERT_INIT_WAS_CALLED'); - return EvaluateOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + exports.FrameworkObject = FrameworkObject = EmberObject.extend((_EmberObject$extend = { + init: function () { + this._super.apply(this, arguments); + this[INIT_WAS_CALLED] = true; + } - exports.EvaluateOpcode = EvaluateOpcode; - var ConstTest = function (ref, env) { - return new _glimmerReference.ConstReference(!!ref.value()); - }; - exports.ConstTest = ConstTest; - var SimpleTest = function (ref, env) { - return ref; - }; - exports.SimpleTest = SimpleTest; - var EnvironmentTest = function (ref, env) { - return env.toConditionalReference(ref); - }; - exports.EnvironmentTest = EnvironmentTest; + }, _EmberObject$extend[ASSERT_INIT_WAS_CALLED] = _emberMetal.on('init', function () { + _emberMetal.assert('You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update ' + this + ' to call `this._super(...arguments);` from `init`.', this[INIT_WAS_CALLED]); + }), _EmberObject$extend)); + }); - var TestOpcode = (function (_Opcode18) { - babelHelpers.inherits(TestOpcode, _Opcode18); + exports.default = EmberObject; +}); +enifed('ember-runtime/system/object_proxy', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/-proxy'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsProxy) { + 'use strict'; - function TestOpcode(testFunc) { - _Opcode18.call(this); - this.testFunc = testFunc; - this.type = "test"; + /** + `Ember.ObjectProxy` forwards all properties not defined by the proxy itself + to a proxied `content` object. + + ```javascript + object = Ember.Object.create({ + name: 'Foo' + }); + + proxy = Ember.ObjectProxy.create({ + content: object + }); + + // Access and change existing properties + proxy.get('name') // 'Foo' + proxy.set('name', 'Bar'); + object.get('name') // 'Bar' + + // Create new 'description' property on `object` + proxy.set('description', 'Foo is a whizboo baz'); + object.get('description') // 'Foo is a whizboo baz' + ``` + + While `content` is unset, setting a property to be delegated will throw an + Error. + + ```javascript + proxy = Ember.ObjectProxy.create({ + content: null, + flag: null + }); + proxy.set('flag', true); + proxy.get('flag'); // true + proxy.get('foo'); // undefined + proxy.set('foo', 'data'); // throws Error + ``` + + Delegated properties can be bound to and will change when content is updated. + + Computed properties on the proxy itself can depend on delegated properties. + + ```javascript + ProxyWithComputedProperty = Ember.ObjectProxy.extend({ + fullName: Ember.computed('firstName', 'lastName', function() { + var firstName = this.get('firstName'), + lastName = this.get('lastName'); + if (firstName && lastName) { + return firstName + ' ' + lastName; } + return firstName || lastName; + }) + }); + + proxy = ProxyWithComputedProperty.create(); + + proxy.get('fullName'); // undefined + proxy.set('content', { + firstName: 'Tom', lastName: 'Dale' + }); // triggers property change for fullName on proxy + + proxy.get('fullName'); // 'Tom Dale' + ``` + + @class ObjectProxy + @namespace Ember + @extends Ember.Object + @extends Ember._ProxyMixin + @public + */ - TestOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setCondition(this.testFunc(vm.frame.getOperand(), vm.env)); - }; - - TestOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND", this.testFunc.name] - }; - }; + exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsProxy.default); +}); +enifed('ember-runtime/system/service', ['exports', 'ember-runtime/system/object', 'ember-runtime/inject'], function (exports, _emberRuntimeSystemObject, _emberRuntimeInject) { + 'use strict'; - return TestOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Creates a property that lazily looks up a service in the container. There + are no restrictions as to what objects a service can be injected into. + + Example: + + ```javascript + App.ApplicationRoute = Ember.Route.extend({ + authManager: Ember.inject.service('auth'), + + model: function() { + return this.get('authManager').findCurrentUser(); + } + }); + ``` + + This example will create an `authManager` property on the application route + that looks up the `auth` service in the container, making it easily + accessible in the `model` hook. + + @method service + @since 1.10.0 + @for Ember.inject + @param {String} name (optional) name of the service to inject, defaults to + the property's name + @return {Ember.InjectedProperty} injection descriptor instance + @public + */ + _emberRuntimeInject.createInjectionHelper('service'); - exports.TestOpcode = TestOpcode; + /** + @class Service + @namespace Ember + @extends Ember.Object + @since 1.10.0 + @public + */ + var Service = _emberRuntimeSystemObject.default.extend(); - var JumpOpcode = (function (_Opcode19) { - babelHelpers.inherits(JumpOpcode, _Opcode19); + Service.reopenClass({ + isServiceFactory: true + }); - function JumpOpcode(target) { - _Opcode19.call(this); - this.target = target; - this.type = "jump"; - } + exports.default = Service; +}); +enifed('ember-runtime/system/string', ['exports', 'ember-metal', 'ember-utils', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberUtils, _emberRuntimeUtils, _emberRuntimeString_registry) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - JumpOpcode.prototype.evaluate = function evaluate(vm) { - vm.goto(this.target); - }; + var STRING_DASHERIZE_REGEXP = /[ _]/g; - JumpOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.target.inspect())] - }; - }; + var STRING_DASHERIZE_CACHE = new _emberMetal.Cache(1000, function (key) { + return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-'); + }); - return JumpOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; + var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; - exports.JumpOpcode = JumpOpcode; + var CAMELIZE_CACHE = new _emberMetal.Cache(1000, function (key) { + return key.replace(STRING_CAMELIZE_REGEXP_1, function (match, separator, chr) { + return chr ? chr.toUpperCase() : ''; + }).replace(STRING_CAMELIZE_REGEXP_2, function (match, separator, chr) { + return match.toLowerCase(); + }); + }); - var JumpIfOpcode = (function (_JumpOpcode) { - babelHelpers.inherits(JumpIfOpcode, _JumpOpcode); + var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; + var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; + var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; - function JumpIfOpcode() { - _JumpOpcode.apply(this, arguments); - this.type = "jump-if"; - } + var CLASSIFY_CACHE = new _emberMetal.Cache(1000, function (str) { + var replace1 = function (match, separator, chr) { + return chr ? '_' + chr.toUpperCase() : ''; + }; + var replace2 = function (match, initialChar, separator, chr) { + return initialChar + (chr ? chr.toUpperCase() : ''); + }; + var parts = str.split('/'); + for (var i = 0; i < parts.length; i++) { + parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); + } + return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, function (match, separator, chr) { + return match.toUpperCase(); + }); + }); - JumpIfOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getCondition(); - if (_glimmerReference.isConst(reference)) { - if (reference.value()) { - _JumpOpcode.prototype.evaluate.call(this, vm); - } - } else { - var cache = new _glimmerReference.ReferenceCache(reference); - if (cache.peek()) { - _JumpOpcode.prototype.evaluate.call(this, vm); - } - vm.updateWith(new Assert(cache)); - } - }; + var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; + var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; - return JumpIfOpcode; - })(JumpOpcode); + var UNDERSCORE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase(); + }); - exports.JumpIfOpcode = JumpIfOpcode; + var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z])/g; - var JumpUnlessOpcode = (function (_JumpOpcode2) { - babelHelpers.inherits(JumpUnlessOpcode, _JumpOpcode2); + var CAPITALIZE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_CAPITALIZE_REGEXP, function (match, separator, chr) { + return match.toUpperCase(); + }); + }); - function JumpUnlessOpcode() { - _JumpOpcode2.apply(this, arguments); - this.type = "jump-unless"; - } + var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; - JumpUnlessOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getCondition(); - if (_glimmerReference.isConst(reference)) { - if (!reference.value()) { - _JumpOpcode2.prototype.evaluate.call(this, vm); - } - } else { - var cache = new _glimmerReference.ReferenceCache(reference); - if (!cache.peek()) { - _JumpOpcode2.prototype.evaluate.call(this, vm); - } - vm.updateWith(new Assert(cache)); - } - }; + var DECAMELIZE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase(); + }); - return JumpUnlessOpcode; - })(JumpOpcode); + function _fmt(str, formats) { + var cachedFormats = formats; - exports.JumpUnlessOpcode = JumpUnlessOpcode; + if (!_emberRuntimeUtils.isArray(cachedFormats) || arguments.length > 2) { + cachedFormats = new Array(arguments.length - 1); - var Assert = (function (_UpdatingOpcode) { - babelHelpers.inherits(Assert, _UpdatingOpcode); + for (var i = 1; i < arguments.length; i++) { + cachedFormats[i - 1] = arguments[i]; + } + } - function Assert(cache) { - _UpdatingOpcode.call(this); - this.type = "assert"; - this.tag = cache.tag; - this.cache = cache; - } + // first, replace any ORDERED replacements. + var idx = 0; // the current index for non-numerical replacements + return str.replace(/%@([0-9]+)?/g, function (s, argIndex) { + argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++; + s = cachedFormats[argIndex]; + return s === null ? '(null)' : s === undefined ? '' : _emberUtils.inspect(s); + }); + } - Assert.prototype.evaluate = function evaluate(vm) { - var cache = this.cache; + function fmt(str, formats) { + _emberMetal.deprecate('Ember.String.fmt is deprecated, use ES6 template strings instead.', false, { id: 'ember-string-utils.fmt', until: '3.0.0', url: 'http://babeljs.io/docs/learn-es2015/#template-strings' }); + return _fmt.apply(undefined, arguments); + } - if (_glimmerReference.isModified(cache.revalidate())) { - vm.throw(); - } - }; + function loc(str, formats) { + if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) { + formats = Array.prototype.slice.call(arguments, 1); + } - Assert.prototype.toJSON = function toJSON() { - var type = this.type; - var _guid = this._guid; - var cache = this.cache; + str = _emberRuntimeString_registry.get(str) || str; + return _fmt(str, formats); + } - var expected = undefined; - try { - expected = JSON.stringify(cache.peek()); - } catch (e) { - expected = String(cache.peek()); - } - return { - guid: _guid, - type: type, - args: [], - details: { expected: expected } - }; - }; + function w(str) { + return str.split(/\s+/); + } - return Assert; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + function decamelize(str) { + return DECAMELIZE_CACHE.get(str); + } - exports.Assert = Assert; + function dasherize(str) { + return STRING_DASHERIZE_CACHE.get(str); + } - var JumpIfNotModifiedOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(JumpIfNotModifiedOpcode, _UpdatingOpcode2); + function camelize(str) { + return CAMELIZE_CACHE.get(str); + } - function JumpIfNotModifiedOpcode(tag, target) { - _UpdatingOpcode2.call(this); - this.target = target; - this.type = "jump-if-not-modified"; - this.tag = tag; - this.lastRevision = tag.value(); - } + function classify(str) { + return CLASSIFY_CACHE.get(str); + } - JumpIfNotModifiedOpcode.prototype.evaluate = function evaluate(vm) { - var tag = this.tag; - var target = this.target; - var lastRevision = this.lastRevision; + function underscore(str) { + return UNDERSCORE_CACHE.get(str); + } - if (!vm.alwaysRevalidate && tag.validate(lastRevision)) { - vm.goto(target); - } - }; + function capitalize(str) { + return CAPITALIZE_CACHE.get(str); + } - JumpIfNotModifiedOpcode.prototype.didModify = function didModify() { - this.lastRevision = this.tag.value(); - }; + /** + Defines string helper methods including string formatting and localization. + Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be + added to the `String.prototype` as well. + + @class String + @namespace Ember + @static + @public + */ + exports.default = { + /** + Apply formatting options to the string. This will look for occurrences + of "%@" in your string and substitute them with the arguments you pass into + this method. If you want to control the specific order of replacement, + you can add a number after the key as well to indicate which argument + you want to insert. + Ordered insertions are most useful when building loc strings where values + you need to insert may appear in different orders. + ```javascript + "Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe" + "Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John" + ``` + @method fmt + @param {String} str The string to format + @param {Array} formats An array of parameters to interpolate into string. + @return {String} formatted string + @public + @deprecated Use ES6 template strings instead: http://babeljs.io/docs/learn-es2015/#template-strings + */ + fmt: fmt, - JumpIfNotModifiedOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.target.inspect())] - }; - }; + /** + Formats the passed string, but first looks up the string in the localized + strings hash. This is a convenient way to localize text. See + `Ember.String.fmt()` for more information on formatting. + Note that it is traditional but not required to prefix localized string + keys with an underscore or other character so you can easily identify + localized strings. + ```javascript + Ember.STRINGS = { + '_Hello World': 'Bonjour le monde', + '_Hello %@ %@': 'Bonjour %@ %@' + }; + Ember.String.loc("_Hello World"); // 'Bonjour le monde'; + Ember.String.loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; + ``` + @method loc + @param {String} str The string to format + @param {Array} formats Optional array of parameters to interpolate into string. + @return {String} formatted string + @public + */ + loc: loc, - return JumpIfNotModifiedOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + Splits a string into separate units separated by spaces, eliminating any + empty strings in the process. This is a convenience method for split that + is mostly useful when applied to the `String.prototype`. + ```javascript + Ember.String.w("alpha beta gamma").forEach(function(key) { + console.log(key); + }); + // > alpha + // > beta + // > gamma + ``` + @method w + @param {String} str The string to split + @return {Array} array containing the split strings + @public + */ + w: w, - exports.JumpIfNotModifiedOpcode = JumpIfNotModifiedOpcode; + /** + Converts a camelized string into all lower case separated by underscores. + ```javascript + 'innerHTML'.decamelize(); // 'inner_html' + 'action_name'.decamelize(); // 'action_name' + 'css-class-name'.decamelize(); // 'css-class-name' + 'my favorite items'.decamelize(); // 'my favorite items' + ``` + @method decamelize + @param {String} str The string to decamelize. + @return {String} the decamelized string. + @public + */ + decamelize: decamelize, - var DidModifyOpcode = (function (_UpdatingOpcode3) { - babelHelpers.inherits(DidModifyOpcode, _UpdatingOpcode3); + /** + Replaces underscores, spaces, or camelCase with dashes. + ```javascript + 'innerHTML'.dasherize(); // 'inner-html' + 'action_name'.dasherize(); // 'action-name' + 'css-class-name'.dasherize(); // 'css-class-name' + 'my favorite items'.dasherize(); // 'my-favorite-items' + 'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice' + ``` + @method dasherize + @param {String} str The string to dasherize. + @return {String} the dasherized string. + @public + */ + dasherize: dasherize, - function DidModifyOpcode(target) { - _UpdatingOpcode3.call(this); - this.target = target; - this.type = "did-modify"; - this.tag = _glimmerReference.CONSTANT_TAG; - } + /** + Returns the lowerCamelCase form of a string. + ```javascript + 'innerHTML'.camelize(); // 'innerHTML' + 'action_name'.camelize(); // 'actionName' + 'css-class-name'.camelize(); // 'cssClassName' + 'my favorite items'.camelize(); // 'myFavoriteItems' + 'My Favorite Items'.camelize(); // 'myFavoriteItems' + 'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice' + ``` + @method camelize + @param {String} str The string to camelize. + @return {String} the camelized string. + @public + */ + camelize: camelize, - DidModifyOpcode.prototype.evaluate = function evaluate() { - this.target.didModify(); - }; + /** + Returns the UpperCamelCase form of a string. + ```javascript + 'innerHTML'.classify(); // 'InnerHTML' + 'action_name'.classify(); // 'ActionName' + 'css-class-name'.classify(); // 'CssClassName' + 'my favorite items'.classify(); // 'MyFavoriteItems' + 'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice' + ``` + @method classify + @param {String} str the string to classify + @return {String} the classified string + @public + */ + classify: classify, - return DidModifyOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + More general than decamelize. Returns the lower\_case\_and\_underscored + form of a string. + ```javascript + 'innerHTML'.underscore(); // 'inner_html' + 'action_name'.underscore(); // 'action_name' + 'css-class-name'.underscore(); // 'css_class_name' + 'my favorite items'.underscore(); // 'my_favorite_items' + 'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice' + ``` + @method underscore + @param {String} str The string to underscore. + @return {String} the underscored string. + @public + */ + underscore: underscore, - exports.DidModifyOpcode = DidModifyOpcode; + /** + Returns the Capitalized form of a string + ```javascript + 'innerHTML'.capitalize() // 'InnerHTML' + 'action_name'.capitalize() // 'Action_name' + 'css-class-name'.capitalize() // 'Css-class-name' + 'my favorite items'.capitalize() // 'My favorite items' + 'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice' + ``` + @method capitalize + @param {String} str The string to capitalize. + @return {String} The capitalized string. + @public + */ + capitalize: capitalize + }; + exports.fmt = fmt; + exports.loc = loc; + exports.w = w; + exports.decamelize = decamelize; + exports.dasherize = dasherize; + exports.camelize = camelize; + exports.classify = classify; + exports.underscore = underscore; + exports.capitalize = capitalize; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy92bS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFXQSxvQkFBQTs4QkFBQSxvQkFBQTs7QUFBQSxpQkFBQSxvQkFBQSxHQUFBO0FBQTBDLGdDQUFBLFNBQUEsQ0FBQSxDQUFNO0FBQ3ZDLGdCQUFBLENBQUEsSUFBSSxHQUFHLGtCQUFrQixDQUFDO1NBS2xDOztBQU5ELDRCQUFBLFdBR0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGNBQUUsQ0FBQyxjQUFjLEVBQUUsQ0FBQztTQUNyQjs7ZUFMSCxvQkFBQTtpQ0FYUyxNQUFNOzs7O1FBbUJmLGNBQUE7OEJBQUEsY0FBQTs7QUFBQSxpQkFBQSxjQUFBLEdBQUE7QUFBb0MsaUNBQUEsU0FBQSxDQUFBLENBQU07QUFDakMsZ0JBQUEsQ0FBQSxJQUFJLEdBQUcsV0FBVyxDQUFDO1NBSzNCOztBQU5ELHNCQUFBLFdBR0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGNBQUUsQ0FBQyxRQUFR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SB7XG4gICAgICB2bS5nb3RvKHRhcmdldCk7XG4gICAgfVxuICB9XG5cbiAgZGlkTW9kaWZ5KCkge1xuICAgIHRoaXMubGFzdFJldmlzaW9uID0gdGhpcy50YWcudmFsdWUoKTtcbiAgfVxuXG4gIHRvSlNPTigpOiBPcGNvZGVKU09OIHtcbiAgICByZXR1cm4ge1xuICAgICAgZ3VpZDogdGhpcy5fZ3VpZCxcbiAgICAgIHR5cGU6IHRoaXMudHlwZSxcbiAgICAgIGFyZ3M6IFtKU09OLnN0cmluZ2lmeSh0aGlzLnRhcmdldC5pbnNwZWN0KCkpXVxuICAgIH07XG4gIH1cbn1cblxuZXhwb3J0IGNsYXNzIERpZE1vZGlmeU9wY29kZSBleHRlbmRzIFVwZGF0aW5nT3Bjb2RlIHtcbiAgcHVibGljIHR5cGUgPSBcImRpZC1tb2RpZnlcIjtcblxuICBjb25zdHJ1Y3Rvcihwcml2YXRlIHRhcmdldDogSnVtcElmTm90TW9kaWZpZWRPcGNvZGUpIHtcbiAgICBzdXBlcigpO1xuICAgIHRoaXMudGFnID0gQ09OU1RBTlRfVEFHO1xuICB9XG5cbiAgZXZhbHVhdGUoKSB7XG4gICAgdGhpcy50YXJnZXQuZGlkTW9kaWZ5KCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiler', ['exports', 'glimmer-util', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-runtime/lib/compiled/expressions/function', 'glimmer-runtime/lib/compiled/opcodes/builder'], function (exports, _glimmerUtil, _glimmerRuntimeLibUtils, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibCompiledBlocks, _glimmerRuntimeLibCompiledExpressionsFunction, _glimmerRuntimeLibCompiledOpcodesBuilder) { - 'use strict'; +enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemObject) { + 'use strict'; - exports.compileLayout = compileLayout; + exports.isArray = isArray; + exports.typeOf = typeOf; - var Compiler = (function () { - function Compiler(block, env) { - this.block = block; - this.env = env; - this.current = block.program.head(); - this.symbolTable = block.symbolTable; - } + // ........................................ + // TYPING & ARRAY MESSAGING + // + var TYPE_MAP = { + '[object Boolean]': 'boolean', + '[object Number]': 'number', + '[object String]': 'string', + '[object Function]': 'function', + '[object Array]': 'array', + '[object Date]': 'date', + '[object RegExp]': 'regexp', + '[object Object]': 'object', + '[object FileList]': 'filelist' + }; - Compiler.prototype.compileStatement = function compileStatement(statement, ops) { - this.env.statement(statement, this.symbolTable).compile(ops, this.env, this.symbolTable); - }; + var toString = Object.prototype.toString; - return Compiler; - })(); + /** + Returns true if the passed object is an array or Array-like. + + Objects are considered Array-like if any of the following are true: + + - the object is a native Array + - the object has an objectAt property + - the object is an Object, and has a length property + + Unlike `Ember.typeOf` this method returns true even if the passed object is + not formally an array but appears to be array-like (i.e. implements `Ember.Array`) + + ```javascript + Ember.isArray(); // false + Ember.isArray([]); // true + Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true + ``` + + @method isArray + @for Ember + @param {Object} obj The object to test + @return {Boolean} true if the passed object is an array or Array-like + @public + */ - function compileStatement(env, statement, ops, layout) { - env.statement(statement, layout.symbolTable).compile(ops, env, layout.symbolTable); + function isArray(obj) { + if (!obj || obj.setInterval) { + return false; + } + if (Array.isArray(obj)) { + return true; + } + if (_emberRuntimeMixinsArray.default.detect(obj)) { + return true; } - exports.default = Compiler; - - var EntryPointCompiler = (function (_Compiler) { - babelHelpers.inherits(EntryPointCompiler, _Compiler); - - function EntryPointCompiler(template, env) { - _Compiler.call(this, template, env); - var list = new CompileIntoList(env, template.symbolTable); - this.ops = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(list, template.symbolTable, env); - } - - EntryPointCompiler.prototype.compile = function compile() { - var block = this.block; - var ops = this.ops; - var program = block.program; - - var current = program.head(); - while (current) { - var next = program.nextNode(current); - this.compileStatement(current, ops); - current = next; - } - return ops.toOpSeq(); - }; - EntryPointCompiler.prototype.append = function append(op) { - this.ops.append(op); - }; + var type = typeOf(obj); + if ('array' === type) { + return true; + } + if (obj.length !== undefined && 'object' === type) { + return true; + } + return false; + } - EntryPointCompiler.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.symbolTable.getLocal(name); - }; + /** + Returns a consistent type for the passed object. + + Use this instead of the built-in `typeof` to get the type of an item. + It will return the same result across all browsers and includes a bit + more detail. Here is what will be returned: + + | Return Value | Meaning | + |---------------|------------------------------------------------------| + | 'string' | String primitive or String object. | + | 'number' | Number primitive or Number object. | + | 'boolean' | Boolean primitive or Boolean object. | + | 'null' | Null value | + | 'undefined' | Undefined value | + | 'function' | A function | + | 'array' | An instance of Array | + | 'regexp' | An instance of RegExp | + | 'date' | An instance of Date | + | 'filelist' | An instance of FileList | + | 'class' | An Ember class (created using Ember.Object.extend()) | + | 'instance' | An Ember object instance | + | 'error' | An instance of the Error object | + | 'object' | A JavaScript object not inheriting from Ember.Object | + + Examples: + + ```javascript + Ember.typeOf(); // 'undefined' + Ember.typeOf(null); // 'null' + Ember.typeOf(undefined); // 'undefined' + Ember.typeOf('michael'); // 'string' + Ember.typeOf(new String('michael')); // 'string' + Ember.typeOf(101); // 'number' + Ember.typeOf(new Number(101)); // 'number' + Ember.typeOf(true); // 'boolean' + Ember.typeOf(new Boolean(true)); // 'boolean' + Ember.typeOf(Ember.makeArray); // 'function' + Ember.typeOf([1, 2, 90]); // 'array' + Ember.typeOf(/abc/); // 'regexp' + Ember.typeOf(new Date()); // 'date' + Ember.typeOf(event.target.files); // 'filelist' + Ember.typeOf(Ember.Object.extend()); // 'class' + Ember.typeOf(Ember.Object.create()); // 'instance' + Ember.typeOf(new Error('teamocil')); // 'error' + + // 'normal' JavaScript object + Ember.typeOf({ a: 'b' }); // 'object' + ``` + + @method typeOf + @for Ember + @param {Object} item the item to check + @return {String} the type + @public + */ - EntryPointCompiler.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.symbolTable.getNamed(name); - }; + function typeOf(item) { + if (item === null) { + return 'null'; + } + if (item === undefined) { + return 'undefined'; + } + var ret = TYPE_MAP[toString.call(item)] || 'object'; - EntryPointCompiler.prototype.getYieldSymbol = function getYieldSymbol(name) { - return this.symbolTable.getYield(name); - }; + if (ret === 'function') { + if (_emberRuntimeSystemObject.default.detect(item)) { + ret = 'class'; + } + } else if (ret === 'object') { + if (item instanceof Error) { + ret = 'error'; + } else if (item instanceof _emberRuntimeSystemObject.default) { + ret = 'instance'; + } else if (item instanceof Date) { + ret = 'date'; + } + } - return EntryPointCompiler; - })(Compiler); + return ret; + } +}); +enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { + 'use strict'; - exports.EntryPointCompiler = EntryPointCompiler; + function K() { + return this; + } - var InlineBlockCompiler = (function (_Compiler2) { - babelHelpers.inherits(InlineBlockCompiler, _Compiler2); + /** + @module ember + @submodule ember-testing + */ - function InlineBlockCompiler(block, env) { - _Compiler2.call(this, block, env); - this.block = block; - var list = new CompileIntoList(env, block.symbolTable); - this.ops = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(list, block.symbolTable, env); - } + /** + The primary purpose of this class is to create hooks that can be implemented + by an adapter for various test frameworks. + + @class Adapter + @namespace Ember.Test + @public + */ + exports.default = _emberRuntime.Object.extend({ + /** + This callback will be called whenever an async operation is about to start. + Override this to call your framework's methods that handle async + operations. + @public + @method asyncStart + */ + asyncStart: K, - InlineBlockCompiler.prototype.compile = function compile() { - var block = this.block; - var ops = this.ops; - var program = block.program; + /** + This callback will be called whenever an async operation has completed. + @public + @method asyncEnd + */ + asyncEnd: K, - var hasPositionalParameters = block.hasPositionalParameters(); - if (hasPositionalParameters) { - ops.pushChildScope(); - ops.bindPositionalArgsForBlock(block); - } - var current = program.head(); - while (current) { - var next = program.nextNode(current); - this.compileStatement(current, ops); - current = next; - } - if (hasPositionalParameters) { - ops.popScope(); - } - return ops.toOpSeq(); + /** + Override this method with your testing framework's false assertion. + This function is called whenever an exception occurs causing the testing + promise to fail. + QUnit example: + ```javascript + exception: function(error) { + ok(false, error); }; + ``` + @public + @method exception + @param {String} error The exception to be raised. + */ + exception: function (error) { + throw error; + } + }); +}); +enifed('ember-testing/adapters/qunit', ['exports', 'ember-utils', 'ember-testing/adapters/adapter'], function (exports, _emberUtils, _emberTestingAdaptersAdapter) { + 'use strict'; - return InlineBlockCompiler; - })(Compiler); - - exports.InlineBlockCompiler = InlineBlockCompiler; - - function compileLayout(compilable, env) { - var builder = new ComponentLayoutBuilder(env); - compilable.compile(builder); - return builder.compile(); + /** + This class implements the methods defined by Ember.Test.Adapter for the + QUnit testing framework. + + @class QUnitAdapter + @namespace Ember.Test + @extends Ember.Test.Adapter + @public + */ + exports.default = _emberTestingAdaptersAdapter.default.extend({ + asyncStart: function () { + QUnit.stop(); + }, + asyncEnd: function () { + QUnit.start(); + }, + exception: function (error) { + ok(false, _emberUtils.inspect(error)); } + }); +}); +enifed('ember-testing/events', ['exports', 'ember-views', 'ember-metal'], function (exports, _emberViews, _emberMetal) { + 'use strict'; - var ComponentLayoutBuilder = (function () { - function ComponentLayoutBuilder(env) { - this.env = env; - } + exports.focus = focus; + exports.fireEvent = fireEvent; - ComponentLayoutBuilder.prototype.empty = function empty() { - this.inner = new EmptyBuilder(this.env); - }; + var DEFAULT_EVENT_OPTIONS = { canBubble: true, cancelable: true }; + var KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup']; + var MOUSE_EVENT_TYPES = ['click', 'mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover']; - ComponentLayoutBuilder.prototype.wrapLayout = function wrapLayout(layout) { - this.inner = new WrappedBuilder(this.env, layout); - }; + function focus(el) { + if (!el) { + return; + } + var $el = _emberViews.jQuery(el); + if ($el.is(':input, [contenteditable=true]')) { + var type = $el.prop('type'); + if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') { + _emberMetal.run(null, function () { + // Firefox does not trigger the `focusin` event if the window + // does not have focus. If the document doesn't have focus just + // use trigger('focusin') instead. - ComponentLayoutBuilder.prototype.fromLayout = function fromLayout(layout) { - this.inner = new UnwrappedBuilder(this.env, layout); - }; + if (!document.hasFocus || document.hasFocus()) { + el.focus(); + } else { + $el.trigger('focusin'); + } + }); + } + } + } - ComponentLayoutBuilder.prototype.compile = function compile() { - return this.inner.compile(); - }; + function fireEvent(element, type) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - babelHelpers.createClass(ComponentLayoutBuilder, [{ - key: 'tag', - get: function () { - return this.inner.tag; - } - }, { - key: 'attrs', - get: function () { - return this.inner.attrs; - } - }]); - return ComponentLayoutBuilder; - })(); + if (!element) { + return; + } + var event = undefined; + if (KEYBOARD_EVENT_TYPES.indexOf(type) > -1) { + event = buildKeyboardEvent(type, options); + } else if (MOUSE_EVENT_TYPES.indexOf(type) > -1) { + var rect = element.getBoundingClientRect(); + var x = rect.left + 1; + var y = rect.top + 1; + var simulatedCoordinates = { + screenX: x + 5, + screenY: y + 95, + clientX: x, + clientY: y + }; + event = buildMouseEvent(type, _emberViews.jQuery.extend(simulatedCoordinates, options)); + } else { + event = buildBasicEvent(type, options); + } + element.dispatchEvent(event); + } - var EmptyBuilder = (function () { - function EmptyBuilder(env) { - this.env = env; - } + function buildBasicEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - EmptyBuilder.prototype.compile = function compile() { - var env = this.env; + var event = document.createEvent('Events'); + event.initEvent(type, true, true); + _emberViews.jQuery.extend(event, options); + return event; + } - var list = new CompileIntoList(env, null); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(list, 0); - }; + function buildMouseEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - babelHelpers.createClass(EmptyBuilder, [{ - key: 'tag', - get: function () { - throw new Error('Nope'); - } - }, { - key: 'attrs', - get: function () { - throw new Error('Nope'); - } - }]); - return EmptyBuilder; - })(); + var event = undefined; + try { + event = document.createEvent('MouseEvents'); + var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); + event.initMouseEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.detail, eventOpts.screenX, eventOpts.screenY, eventOpts.clientX, eventOpts.clientY, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.button, eventOpts.relatedTarget); + } catch (e) { + event = buildBasicEvent(type, options); + } + return event; + } - var WrappedBuilder = (function () { - function WrappedBuilder(env, layout) { - this.env = env; - this.layout = layout; - this.tag = new ComponentTagBuilder(); - this.attrs = new ComponentAttrsBuilder(); - } - - WrappedBuilder.prototype.compile = function compile() { - //========DYNAMIC - // PutValue(TagExpr) - // Test - // JumpUnless(BODY) - // OpenDynamicPrimitiveElement - // DidCreateElement - // ...attr statements... - // FlushElement - // BODY: Noop - // ...body statements... - // PutValue(TagExpr) - // Test - // JumpUnless(END) - // CloseElement - // END: Noop - // DidRenderLayout - // Exit - // - //========STATIC - // OpenPrimitiveElementOpcode - // DidCreateElement - // ...attr statements... - // FlushElement - // ...body statements... - // CloseElement - // DidRenderLayout - // Exit - var env = this.env; - var layout = this.layout; - - var symbolTable = layout.symbolTable; - var buffer = new CompileIntoList(env, layout.symbolTable); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, layout.symbolTable, env); - dsl.startLabels(); - if (this.tag.isDynamic) { - dsl.putValue(this.tag.dynamicTagName); - dsl.test('simple'); - dsl.jumpUnless('BODY'); - dsl.openDynamicPrimitiveElement(); - dsl.didCreateElement(); - this.attrs['buffer'].forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - dsl.flushElement(); - dsl.label('BODY'); - } else if (this.tag.isStatic) { - var tag = this.tag.staticTagName; - dsl.openPrimitiveElement(tag); - dsl.didCreateElement(); - this.attrs['buffer'].forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - dsl.flushElement(); - } - dsl.preludeForLayout(layout); - layout.program.forEachNode(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - if (this.tag.isDynamic) { - dsl.putValue(this.tag.dynamicTagName); - dsl.test('simple'); - dsl.jumpUnless('END'); - dsl.closeElement(); - dsl.label('END'); - } else if (this.tag.isStatic) { - dsl.closeElement(); - } - dsl.didRenderLayout(); - dsl.stopLabels(); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(dsl.toOpSeq(), symbolTable.size); - }; + function buildKeyboardEvent(type) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - return WrappedBuilder; - })(); + var event = undefined; + try { + event = document.createEvent('KeyEvents'); + var eventOpts = _emberViews.jQuery.extend({}, DEFAULT_EVENT_OPTIONS, options); + event.initKeyEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.keyCode, eventOpts.charCode); + } catch (e) { + event = buildBasicEvent(type, options); + } + return event; + } +}); +enifed('ember-testing/ext/application', ['exports', 'ember-application', 'ember-testing/setup_for_testing', 'ember-testing/test/helpers', 'ember-testing/test/promise', 'ember-testing/test/run', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/adapter'], function (exports, _emberApplication, _emberTestingSetup_for_testing, _emberTestingTestHelpers, _emberTestingTestPromise, _emberTestingTestRun, _emberTestingTestOn_inject_helpers, _emberTestingTestAdapter) { + 'use strict'; - var UnwrappedBuilder = (function () { - function UnwrappedBuilder(env, layout) { - this.env = env; - this.layout = layout; - this.attrs = new ComponentAttrsBuilder(); - } - - UnwrappedBuilder.prototype.compile = function compile() { - var env = this.env; - var layout = this.layout; - - var buffer = new CompileIntoList(env, layout.symbolTable); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, layout.symbolTable, env); - dsl.startLabels(); - dsl.preludeForLayout(layout); - var attrs = this.attrs['buffer']; - var attrsInserted = false; - this.layout.program.forEachNode(function (statement) { - if (!attrsInserted && isOpenElement(statement)) { - dsl.openComponentElement(statement.tag); - dsl.didCreateElement(); - dsl.shadowAttributes(); - attrs.forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - attrsInserted = true; - } else { - compileStatement(env, statement, dsl, layout); - } - }); - dsl.didRenderLayout(); - dsl.stopLabels(); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(dsl.toOpSeq(), layout.symbolTable.size); - }; + _emberApplication.Application.reopen({ + /** + This property contains the testing helpers for the current application. These + are created once you call `injectTestHelpers` on your `Ember.Application` + instance. The included helpers are also available on the `window` object by + default, but can be used from this object on the individual application also. + @property testHelpers + @type {Object} + @default {} + @public + */ + testHelpers: {}, - babelHelpers.createClass(UnwrappedBuilder, [{ - key: 'tag', - get: function () { - throw new Error('BUG: Cannot call `tag` on an UnwrappedBuilder'); - } - }]); - return UnwrappedBuilder; - })(); + /** + This property will contain the original methods that were registered + on the `helperContainer` before `injectTestHelpers` is called. + When `removeTestHelpers` is called, these methods are restored to the + `helperContainer`. + @property originalMethods + @type {Object} + @default {} + @private + @since 1.3.0 + */ + originalMethods: {}, - function isOpenElement(syntax) { - return syntax instanceof _glimmerRuntimeLibSyntaxCore.OpenElement || syntax instanceof _glimmerRuntimeLibSyntaxCore.OpenPrimitiveElement; - } + /** + This property indicates whether or not this application is currently in + testing mode. This is set when `setupForTesting` is called on the current + application. + @property testing + @type {Boolean} + @default false + @since 1.3.0 + @public + */ + testing: false, + + /** + This hook defers the readiness of the application, so that you can start + the app when your tests are ready to run. It also sets the router's + location to 'none', so that the window's location will not be modified + (preventing both accidental leaking of state between tests and interference + with your testing framework). + Example: + ``` + App.setupForTesting(); + ``` + @method setupForTesting + @public + */ + setupForTesting: function () { + _emberTestingSetup_for_testing.default(); - var ComponentTagBuilder = (function () { - function ComponentTagBuilder() { - this.isDynamic = null; - this.isStatic = null; - this.staticTagName = null; - this.dynamicTagName = null; - } + this.testing = true; - ComponentTagBuilder.prototype.static = function _static(tagName) { - this.isStatic = true; - this.staticTagName = tagName; - }; + this.Router.reopen({ + location: 'none' + }); + }, - ComponentTagBuilder.prototype.dynamic = function dynamic(tagName) { - this.isDynamic = true; - this.dynamicTagName = _glimmerRuntimeLibCompiledExpressionsFunction.default(tagName); - }; + /** + This will be used as the container to inject the test helpers into. By + default the helpers are injected into `window`. + @property helperContainer + @type {Object} The object to be used for test helpers. + @default window + @since 1.2.0 + @private + */ + helperContainer: null, - return ComponentTagBuilder; - })(); + /** + This injects the test helpers into the `helperContainer` object. If an object is provided + it will be used as the helperContainer. If `helperContainer` is not set it will default + to `window`. If a function of the same name has already been defined it will be cached + (so that it can be reset if the helper is removed with `unregisterHelper` or + `removeTestHelpers`). + Any callbacks registered with `onInjectHelpers` will be called once the + helpers have been injected. + Example: + ``` + App.injectTestHelpers(); + ``` + @method injectTestHelpers + @public + */ + injectTestHelpers: function (helperContainer) { + if (helperContainer) { + this.helperContainer = helperContainer; + } else { + this.helperContainer = window; + } - var ComponentAttrsBuilder = (function () { - function ComponentAttrsBuilder() { - this.buffer = []; + this.reopen({ + willDestroy: function () { + this._super.apply(this, arguments); + this.removeTestHelpers(); } + }); - ComponentAttrsBuilder.prototype.static = function _static(name, value) { - this.buffer.push(new _glimmerRuntimeLibSyntaxCore.StaticAttr(name, value, null)); - }; + this.testHelpers = {}; + for (var _name in _emberTestingTestHelpers.helpers) { + this.originalMethods[_name] = this.helperContainer[_name]; + this.testHelpers[_name] = this.helperContainer[_name] = helper(this, _name); + protoWrap(_emberTestingTestPromise.default.prototype, _name, helper(this, _name), _emberTestingTestHelpers.helpers[_name].meta.wait); + } - ComponentAttrsBuilder.prototype.dynamic = function dynamic(name, value) { - this.buffer.push(new _glimmerRuntimeLibSyntaxCore.DynamicAttr(name, _glimmerRuntimeLibCompiledExpressionsFunction.default(value), null, false)); - }; + _emberTestingTestOn_inject_helpers.invokeInjectHelpersCallbacks(this); + }, - return ComponentAttrsBuilder; - })(); + /** + This removes all helpers that have been registered, and resets and functions + that were overridden by the helpers. + Example: + ```javascript + App.removeTestHelpers(); + ``` + @public + @method removeTestHelpers + */ + removeTestHelpers: function () { + if (!this.helperContainer) { + return; + } - var ComponentBuilder = (function () { - function ComponentBuilder(dsl) { - this.dsl = dsl; - this.env = dsl.env; - } + for (var _name2 in _emberTestingTestHelpers.helpers) { + this.helperContainer[_name2] = this.originalMethods[_name2]; + delete _emberTestingTestPromise.default.prototype[_name2]; + delete this.testHelpers[_name2]; + delete this.originalMethods[_name2]; + } + } + }); - ComponentBuilder.prototype.static = function _static(definition, args, symbolTable) { - var shadow = arguments.length <= 3 || arguments[3] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[3]; + // This method is no longer needed + // But still here for backwards compatibility + // of helper chaining + function protoWrap(proto, name, callback, isAsync) { + proto[name] = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - this.dsl.unit(function (dsl) { - dsl.putComponentDefinition(definition); - dsl.openComponent(args, shadow); - dsl.closeComponent(); - }); - }; + if (isAsync) { + return callback.apply(this, args); + } else { + return this.then(function () { + return callback.apply(this, args); + }); + } + }; + } - ComponentBuilder.prototype.dynamic = function dynamic(definitionArgs, definition, args, symbolTable) { - var shadow = arguments.length <= 4 || arguments[4] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[4]; - - this.dsl.unit(function (dsl) { - dsl.putArgs(definitionArgs); - dsl.putValue(_glimmerRuntimeLibCompiledExpressionsFunction.default(definition)); - dsl.test('simple'); - dsl.enter('BEGIN', 'END'); - dsl.label('BEGIN'); - dsl.jumpUnless('END'); - dsl.putDynamicComponentDefinition(); - dsl.openComponent(args, shadow); - dsl.closeComponent(); - dsl.label('END'); - dsl.exit(); - }); - }; + function helper(app, name) { + var fn = _emberTestingTestHelpers.helpers[name].method; + var meta = _emberTestingTestHelpers.helpers[name].meta; + if (!meta.wait) { + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - return ComponentBuilder; - })(); + return fn.apply(app, [app].concat(args)); + }; + } - var CompileIntoList = (function (_LinkedList) { - babelHelpers.inherits(CompileIntoList, _LinkedList); + return function () { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } - function CompileIntoList(env, symbolTable) { - _LinkedList.call(this); - this.env = env; - this.symbolTable = symbolTable; - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(this, symbolTable, env); - this.component = new ComponentBuilder(dsl); - } + var lastPromise = _emberTestingTestRun.default(function () { + return _emberTestingTestPromise.resolve(_emberTestingTestPromise.getLastPromise()); + }); - CompileIntoList.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.symbolTable.getLocal(name); - }; + // wait for last helper's promise to resolve and then + // execute. To be safe, we need to tell the adapter we're going + // asynchronous here, because fn may not be invoked before we + // return. + _emberTestingTestAdapter.asyncStart(); + return lastPromise.then(function () { + return fn.apply(app, [app].concat(args)); + }).finally(_emberTestingTestAdapter.asyncEnd); + }; + } +}); +enifed('ember-testing/ext/rsvp', ['exports', 'ember-runtime', 'ember-metal', 'ember-testing/test/adapter'], function (exports, _emberRuntime, _emberMetal, _emberTestingTestAdapter) { + 'use strict'; - CompileIntoList.prototype.hasLocalSymbol = function hasLocalSymbol(name) { - return typeof this.symbolTable.getLocal(name) === 'number'; - }; + _emberRuntime.RSVP.configure('async', function (callback, promise) { + // if schedule will cause autorun, we need to inform adapter + if (_emberMetal.isTesting() && !_emberMetal.run.backburner.currentInstance) { + _emberTestingTestAdapter.asyncStart(); + _emberMetal.run.backburner.schedule('actions', function () { + _emberTestingTestAdapter.asyncEnd(); + callback(promise); + }); + } else { + _emberMetal.run.backburner.schedule('actions', function () { + return callback(promise); + }); + } + }); - CompileIntoList.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.symbolTable.getNamed(name); - }; + exports.default = _emberRuntime.RSVP; +}); +enifed('ember-testing/helpers', ['exports', 'ember-metal', 'ember-testing/test/helpers', 'ember-testing/helpers/and_then', 'ember-testing/helpers/click', 'ember-testing/helpers/current_path', 'ember-testing/helpers/current_route_name', 'ember-testing/helpers/current_url', 'ember-testing/helpers/fill_in', 'ember-testing/helpers/find', 'ember-testing/helpers/find_with_assert', 'ember-testing/helpers/key_event', 'ember-testing/helpers/pause_test', 'ember-testing/helpers/trigger_event', 'ember-testing/helpers/visit', 'ember-testing/helpers/wait'], function (exports, _emberMetal, _emberTestingTestHelpers, _emberTestingHelpersAnd_then, _emberTestingHelpersClick, _emberTestingHelpersCurrent_path, _emberTestingHelpersCurrent_route_name, _emberTestingHelpersCurrent_url, _emberTestingHelpersFill_in, _emberTestingHelpersFind, _emberTestingHelpersFind_with_assert, _emberTestingHelpersKey_event, _emberTestingHelpersPause_test, _emberTestingHelpersTrigger_event, _emberTestingHelpersVisit, _emberTestingHelpersWait) { + 'use strict'; - CompileIntoList.prototype.hasNamedSymbol = function hasNamedSymbol(name) { - return typeof this.symbolTable.getNamed(name) === 'number'; - }; + _emberTestingTestHelpers.registerAsyncHelper('visit', _emberTestingHelpersVisit.default); + _emberTestingTestHelpers.registerAsyncHelper('click', _emberTestingHelpersClick.default); + _emberTestingTestHelpers.registerAsyncHelper('keyEvent', _emberTestingHelpersKey_event.default); + _emberTestingTestHelpers.registerAsyncHelper('fillIn', _emberTestingHelpersFill_in.default); + _emberTestingTestHelpers.registerAsyncHelper('wait', _emberTestingHelpersWait.default); + _emberTestingTestHelpers.registerAsyncHelper('andThen', _emberTestingHelpersAnd_then.default); + _emberTestingTestHelpers.registerAsyncHelper('pauseTest', _emberTestingHelpersPause_test.pauseTest); + _emberTestingTestHelpers.registerAsyncHelper('triggerEvent', _emberTestingHelpersTrigger_event.default); - CompileIntoList.prototype.getBlockSymbol = function getBlockSymbol(name) { - return this.symbolTable.getYield(name); - }; + _emberTestingTestHelpers.registerHelper('find', _emberTestingHelpersFind.default); + _emberTestingTestHelpers.registerHelper('findWithAssert', _emberTestingHelpersFind_with_assert.default); + _emberTestingTestHelpers.registerHelper('currentRouteName', _emberTestingHelpersCurrent_route_name.default); + _emberTestingTestHelpers.registerHelper('currentPath', _emberTestingHelpersCurrent_path.default); + _emberTestingTestHelpers.registerHelper('currentURL', _emberTestingHelpersCurrent_url.default); - CompileIntoList.prototype.hasBlockSymbol = function hasBlockSymbol(name) { - return typeof this.symbolTable.getYield(name) === 'number'; - }; + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + _emberTestingTestHelpers.registerHelper('resumeTest', _emberTestingHelpersPause_test.resumeTest); + } +}); +enifed("ember-testing/helpers/and_then", ["exports"], function (exports) { + /** + @module ember + @submodule ember-testing + */ + "use strict"; - CompileIntoList.prototype.getPartialArgsSymbol = function getPartialArgsSymbol() { - return this.symbolTable.getPartialArgs(); - }; + exports.default = andThen; - CompileIntoList.prototype.hasPartialArgsSymbol = function hasPartialArgsSymbol() { - return typeof this.symbolTable.getPartialArgs() === 'number'; - }; + function andThen(app, callback) { + return app.testHelpers.wait(callback(app)); + } +}); +enifed('ember-testing/helpers/click', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - CompileIntoList.prototype.toOpSeq = function toOpSeq() { - return this; - }; + exports.default = click; - return CompileIntoList; - })(_glimmerUtil.LinkedList); + /** + Clicks an element and triggers any actions triggered by the element's `click` + event. + + Example: + + ```javascript + click('.some-jQuery-selector').then(function() { + // assert something + }); + ``` + + @method click + @param {String} selector jQuery selector for finding element on the DOM + @param {Object} context A DOM Element, Document, or jQuery to use as context + @return {RSVP.Promise} + @public + */ - exports.CompileIntoList = CompileIntoList; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs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VybiB0eXBlb2YgdGhpcy5zeW1ib2xUYWJsZS5nZXRZaWVsZChuYW1lKSA9PT0gJ251bWJlcic7XG4gIH1cblxuICBnZXRQYXJ0aWFsQXJnc1N5bWJvbCgpOiBudW1iZXIge1xuICAgIHJldHVybiB0aGlzLnN5bWJvbFRhYmxlLmdldFBhcnRpYWxBcmdzKCk7XG4gIH1cblxuICBoYXNQYXJ0aWFsQXJnc1N5bWJvbCgpOiBib29sZWFuIHtcbiAgICByZXR1cm4gdHlwZW9mIHRoaXMuc3ltYm9sVGFibGUuZ2V0UGFydGlhbEFyZ3MoKSA9PT0gJ251bWJlcic7XG4gIH1cblxuICB0b09wU2VxKCk6IE9wU2VxIHtcbiAgICByZXR1cm4gdGhpcztcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/component/interfaces', ['exports'], function (exports) { - 'use strict'; + function click(app, selector, context) { + var $el = app.testHelpers.findWithAssert(selector, context); + var el = $el[0]; - exports.isComponentDefinition = isComponentDefinition; - var COMPONENT_DEFINITION_BRAND = 'COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]'; + _emberTestingEvents.fireEvent(el, 'mousedown'); - function isComponentDefinition(obj) { - return typeof obj === 'object' && obj && obj[COMPONENT_DEFINITION_BRAND]; - } + _emberTestingEvents.focus(el); - var ComponentDefinition = function ComponentDefinition(name, manager, ComponentClass) { - this['COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]'] = true; - this.name = name; - this.manager = manager; - this.ComponentClass = ComponentClass; - }; + _emberTestingEvents.fireEvent(el, 'mouseup'); + _emberTestingEvents.fireEvent(el, 'click'); - exports.ComponentDefinition = ComponentDefinition; + return app.testHelpers.wait(); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcG9uZW50L2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5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ID0gQ29tcG9uZW50Q2xhc3M7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/dom/attribute-managers', ['exports', 'glimmer-runtime/lib/dom/sanitized-values', 'glimmer-runtime/lib/dom/props', 'glimmer-runtime/lib/dom/helper', 'glimmer-runtime/lib/compiled/opcodes/content'], function (exports, _glimmerRuntimeLibDomSanitizedValues, _glimmerRuntimeLibDomProps, _glimmerRuntimeLibDomHelper, _glimmerRuntimeLibCompiledOpcodesContent) { - 'use strict'; +enifed('ember-testing/helpers/current_path', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - exports.defaultManagers = defaultManagers; - exports.defaultPropertyManagers = defaultPropertyManagers; - exports.defaultAttributeManagers = defaultAttributeManagers; - exports.readDOMAttr = readDOMAttr; + exports.default = currentPath; - function defaultManagers(element, attr, isTrusting, namespace) { - var tagName = element.tagName; - var isSVG = element.namespaceURI === _glimmerRuntimeLibDomHelper.SVG_NAMESPACE; - if (isSVG) { - return defaultAttributeManagers(tagName, attr); - } + /** + Returns the current path. + + Example: + + ```javascript + function validateURL() { + equal(currentPath(), 'some.path.index', "correct path was transitioned into."); + } + + click('#some-link-id').then(validateURL); + ``` + + @method currentPath + @return {Object} The currently active path. + @since 1.5.0 + @public + */ - var _normalizeProperty = _glimmerRuntimeLibDomProps.normalizeProperty(element, attr); + function currentPath(app) { + var routingService = app.__container__.lookup('service:-routing'); + return _emberMetal.get(routingService, 'currentPath'); + } +}); +enifed('ember-testing/helpers/current_route_name', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - var type = _normalizeProperty.type; - var normalized = _normalizeProperty.normalized; + exports.default = currentRouteName; - if (type === 'attr') { - return defaultAttributeManagers(tagName, normalized); - } else { - return defaultPropertyManagers(tagName, normalized); - } - } + /** + Returns the currently active route name. + Example: + ```javascript + function validateRouteName() { + equal(currentRouteName(), 'some.path', "correct route was transitioned into."); + } + visit('/some/path').then(validateRouteName) + ``` + @method currentRouteName + @return {Object} The name of the currently active route. + @since 1.5.0 + @public + */ - function defaultPropertyManagers(tagName, attr) { - if (_glimmerRuntimeLibDomSanitizedValues.requiresSanitization(tagName, attr)) { - return new SafePropertyManager(attr); - } - if (isUserInputValue(tagName, attr)) { - return INPUT_VALUE_PROPERTY_MANAGER; - } - if (isOptionSelected(tagName, attr)) { - return OPTION_SELECTED_MANAGER; - } - return new PropertyManager(attr); - } + function currentRouteName(app) { + var routingService = app.__container__.lookup('service:-routing'); + return _emberMetal.get(routingService, 'currentRouteName'); + } +}); +enifed('ember-testing/helpers/current_url', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - function defaultAttributeManagers(tagName, attr) { - if (_glimmerRuntimeLibDomSanitizedValues.requiresSanitization(tagName, attr)) { - return new SafeAttributeManager(attr); - } - return new AttributeManager(attr); - } + exports.default = currentURL; + + /** + Returns the current URL. + + Example: + + ```javascript + function validateURL() { + equal(currentURL(), '/some/path', "correct URL was transitioned into."); + } + + click('#some-link-id').then(validateURL); + ``` + + @method currentURL + @return {Object} The currently active URL. + @since 1.5.0 + @public + */ - function readDOMAttr(element, attr) { - var isSVG = element.namespaceURI === _glimmerRuntimeLibDomHelper.SVG_NAMESPACE; + function currentURL(app) { + var router = app.__container__.lookup('router:main'); + return _emberMetal.get(router, 'location').getURL(); + } +}); +enifed('ember-testing/helpers/fill_in', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - var _normalizeProperty2 = _glimmerRuntimeLibDomProps.normalizeProperty(element, attr); + exports.default = fillIn; - var type = _normalizeProperty2.type; - var normalized = _normalizeProperty2.normalized; + /** + Fills in an input element with some text. + + Example: + + ```javascript + fillIn('#email', 'you@example.com').then(function() { + // assert something + }); + ``` + + @method fillIn + @param {String} selector jQuery selector finding an input element on the DOM + to fill text with + @param {String} text text to place inside the input element + @return {RSVP.Promise} + @public + */ - if (isSVG) { - return element.getAttribute(normalized); - } - if (type === 'attr') { - return element.getAttribute(normalized); - } - { - return element[normalized]; - } + function fillIn(app, selector, contextOrText, text) { + var $el = undefined, + el = undefined, + context = undefined; + if (typeof text === 'undefined') { + text = contextOrText; + } else { + context = contextOrText; } + $el = app.testHelpers.findWithAssert(selector, context); + el = $el[0]; + _emberTestingEvents.focus(el); - ; + $el.eq(0).val(text); + _emberTestingEvents.fireEvent(el, 'input'); + _emberTestingEvents.fireEvent(el, 'change'); - var AttributeManager = (function () { - function AttributeManager(attr) { - this.attr = attr; - } + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/find', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - AttributeManager.prototype.setAttribute = function setAttribute(env, element, value, namespace) { - var dom = env.getAppendOperations(); - var normalizedValue = normalizeAttributeValue(value); - if (!isAttrRemovalValue(normalizedValue)) { - dom.setAttribute(element, this.attr, normalizedValue, namespace); - } - }; + exports.default = find; - AttributeManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - if (value === null || value === undefined || value === false) { - if (namespace) { - env.getDOM().removeAttributeNS(element, namespace, this.attr); - } else { - env.getDOM().removeAttribute(element, this.attr); - } - } else { - this.setAttribute(env, element, value); - } - }; + /** + Finds an element in the context of the app's container element. A simple alias + for `app.$(selector)`. + + Example: + + ```javascript + var $el = find('.my-selector'); + ``` + + With the `context` param: + + ```javascript + var $el = find('.my-selector', '.parent-element-class'); + ``` + + @method find + @param {String} selector jQuery string selector for element lookup + @param {String} [context] (optional) jQuery selector that will limit the selector + argument to find only within the context's children + @return {Object} jQuery object representing the results of the query + @public + */ - return AttributeManager; - })(); + function find(app, selector, context) { + var $el = undefined; + context = context || _emberMetal.get(app, 'rootElement'); + $el = app.$(selector, context); + return $el; + } +}); +enifed('ember-testing/helpers/find_with_assert', ['exports'], function (exports) { + /** + @module ember + @submodule ember-testing + */ + /** + Like `find`, but throws an error if the element selector returns no results. + + Example: + + ```javascript + var $el = findWithAssert('.doesnt-exist'); // throws error + ``` + + With the `context` param: + + ```javascript + var $el = findWithAssert('.selector-id', '.parent-element-class'); // assert will pass + ``` + + @method findWithAssert + @param {String} selector jQuery selector string for finding an element within + the DOM + @param {String} [context] (optional) jQuery selector that will limit the + selector argument to find only within the context's children + @return {Object} jQuery object representing the results of the query + @throws {Error} throws error if jQuery object returned has a length of 0 + @public + */ + 'use strict'; - exports.AttributeManager = AttributeManager; + exports.default = findWithAssert; - ; + function findWithAssert(app, selector, context) { + var $el = app.testHelpers.find(selector, context); + if ($el.length === 0) { + throw new Error('Element ' + selector + ' not found.'); + } + return $el; + } +}); +enifed('ember-testing/helpers/key_event', ['exports'], function (exports) { + /** + @module ember + @submodule ember-testing + */ + /** + Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode + Example: + ```javascript + keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() { + // assert something + }); + ``` + @method keyEvent + @param {String} selector jQuery selector for finding element on the DOM + @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup` + @param {Number} keyCode the keyCode of the simulated key event + @return {RSVP.Promise} + @since 1.5.0 + @public + */ + 'use strict'; - var PropertyManager = (function (_AttributeManager) { - babelHelpers.inherits(PropertyManager, _AttributeManager); + exports.default = keyEvent; - function PropertyManager() { - _AttributeManager.apply(this, arguments); - } + function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { + var context = undefined, + type = undefined; - PropertyManager.prototype.setAttribute = function setAttribute(env, element, value, namespace) { - if (!isAttrRemovalValue(value)) { - element[this.attr] = value; - } - }; + if (typeof keyCode === 'undefined') { + context = null; + keyCode = typeOrKeyCode; + type = contextOrType; + } else { + context = contextOrType; + type = typeOrKeyCode; + } - PropertyManager.prototype.removeAttribute = function removeAttribute(env, element, namespace) { - // TODO this sucks but to preserve properties first and to meet current - // semantics we must do this. - var attr = this.attr; + return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode }); + } +}); +enifed('ember-testing/helpers/pause_test', ['exports', 'ember-runtime', 'ember-console', 'ember-metal'], function (exports, _emberRuntime, _emberConsole, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - if (namespace) { - env.getDOM().removeAttributeNS(element, namespace, attr); - } else { - env.getDOM().removeAttribute(element, attr); - } - }; + exports.resumeTest = resumeTest; + exports.pauseTest = pauseTest; - PropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - // ensure the property is always updated - element[this.attr] = value; - if (isAttrRemovalValue(value)) { - this.removeAttribute(env, element, namespace); - } - }; + var resume = undefined; - return PropertyManager; - })(AttributeManager); + /** + Resumes a test paused by `pauseTest`. + + @method resumeTest + @return {void} + @public + */ - exports.PropertyManager = PropertyManager; + function resumeTest() { + _emberMetal.assert('Testing has not been paused. There is nothing to resume.', resume); + resume(); + resume = undefined; + } - ; - function normalizeAttributeValue(value) { - if (value === false || value === undefined || value === null) { - return null; - } - if (value === true) { - return ''; - } - // onclick function etc in SSR - if (typeof value === 'function') { - return null; - } - return String(value); - } - function isAttrRemovalValue(value) { - return value === null || value === undefined; - } + /** + Pauses the current test - this is useful for debugging while testing or for test-driving. + It allows you to inspect the state of your application at any point. + Example (The test will pause before clicking the button): + + ```javascript + visit('/') + return pauseTest(); + click('.btn'); + ``` + @since 1.9.0 + @method pauseTest + @return {Object} A promise that will never resolve + @public + */ - var SafePropertyManager = (function (_PropertyManager) { - babelHelpers.inherits(SafePropertyManager, _PropertyManager); + function pauseTest() { + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + _emberConsole.default.info('Testing paused. Use `resumeTest()` to continue.'); + } - function SafePropertyManager() { - _PropertyManager.apply(this, arguments); - } + return new _emberRuntime.RSVP.Promise(function (resolve) { + if (_emberMetal.isFeatureEnabled('ember-testing-resume-test')) { + resume = resolve; + } + }, 'TestAdapter paused promise'); + } +}); +enifed('ember-testing/helpers/trigger_event', ['exports', 'ember-testing/events'], function (exports, _emberTestingEvents) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - SafePropertyManager.prototype.setAttribute = function setAttribute(env, element, value) { - _PropertyManager.prototype.setAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + exports.default = triggerEvent; - SafePropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - _PropertyManager.prototype.updateAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + /** + Triggers the given DOM event on the element identified by the provided selector. + Example: + ```javascript + triggerEvent('#some-elem-id', 'blur'); + ``` + This is actually used internally by the `keyEvent` helper like so: + ```javascript + triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 }); + ``` + @method triggerEvent + @param {String} selector jQuery selector for finding element on the DOM + @param {String} [context] jQuery selector that will limit the selector + argument to find only within the context's children + @param {String} type The event type to be triggered. + @param {Object} [options] The options to be passed to jQuery.Event. + @return {RSVP.Promise} + @since 1.5.0 + @public + */ - return SafePropertyManager; - })(PropertyManager); + function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { + var arity = arguments.length; + var context = undefined, + type = undefined, + options = undefined; - function isUserInputValue(tagName, attribute) { - return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value'; + if (arity === 3) { + // context and options are optional, so this is + // app, selector, type + context = null; + type = contextOrType; + options = {}; + } else if (arity === 4) { + // context and options are optional, so this is + if (typeof typeOrOptions === 'object') { + // either + // app, selector, type, options + context = null; + type = contextOrType; + options = typeOrOptions; + } else { + // or + // app, selector, context, type + context = contextOrType; + type = typeOrOptions; + options = {}; + } + } else { + context = contextOrType; + type = typeOrOptions; + options = possibleOptions; } - var InputValuePropertyManager = (function (_AttributeManager2) { - babelHelpers.inherits(InputValuePropertyManager, _AttributeManager2); + var $el = app.testHelpers.findWithAssert(selector, context); + var el = $el[0]; - function InputValuePropertyManager() { - _AttributeManager2.apply(this, arguments); - } + _emberTestingEvents.fireEvent(el, type, options); - InputValuePropertyManager.prototype.setAttribute = function setAttribute(env, element, value) { - var input = element; - input.value = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - }; + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/visit', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - InputValuePropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - var input = element; - var currentValue = input.value; - var normalizedValue = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - if (currentValue !== normalizedValue) { - input.value = normalizedValue; - } - }; + exports.default = visit; - return InputValuePropertyManager; - })(AttributeManager); + /** + Loads a route, sets up any controllers, and renders any templates associated + with the route as though a real user had triggered the route change while + using your app. + + Example: + + ```javascript + visit('posts/index').then(function() { + // assert something + }); + ``` + + @method visit + @param {String} url the name of the route + @return {RSVP.Promise} + @public + */ - var INPUT_VALUE_PROPERTY_MANAGER = new InputValuePropertyManager('value'); - exports.INPUT_VALUE_PROPERTY_MANAGER = INPUT_VALUE_PROPERTY_MANAGER; - function isOptionSelected(tagName, attribute) { - return tagName === 'OPTION' && attribute === 'selected'; - } + function visit(app, url) { + var router = app.__container__.lookup('router:main'); + var shouldHandleURL = false; - var OptionSelectedManager = (function (_PropertyManager2) { - babelHelpers.inherits(OptionSelectedManager, _PropertyManager2); + app.boot().then(function () { + router.location.setURL(url); - function OptionSelectedManager() { - _PropertyManager2.apply(this, arguments); - } + if (shouldHandleURL) { + _emberMetal.run(app.__deprecatedInstance__, 'handleURL', url); + } + }); - OptionSelectedManager.prototype.setAttribute = function setAttribute(env, element, value) { - if (value !== null && value !== undefined && value !== false) { - var option = element; - option.selected = true; - } - }; + if (app._readinessDeferrals > 0) { + router['initialURL'] = url; + _emberMetal.run(app, 'advanceReadiness'); + delete router['initialURL']; + } else { + shouldHandleURL = true; + } - OptionSelectedManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - var option = element; - if (value) { - option.selected = true; - } else { - option.selected = false; - } - }; + return app.testHelpers.wait(); + } +}); +enifed('ember-testing/helpers/wait', ['exports', 'ember-testing/test/waiters', 'ember-runtime', 'ember-metal', 'ember-testing/test/pending_requests'], function (exports, _emberTestingTestWaiters, _emberRuntime, _emberMetal, _emberTestingTestPending_requests) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - return OptionSelectedManager; - })(PropertyManager); + exports.default = wait; - var OPTION_SELECTED_MANAGER = new OptionSelectedManager('selected'); - exports.OPTION_SELECTED_MANAGER = OPTION_SELECTED_MANAGER; + /** + Causes the run loop to process any pending events. This is used to ensure that + any async operations from other helpers (or your assertions) have been processed. + + This is most often used as the return value for the helper functions (see 'click', + 'fillIn','visit',etc). However, there is a method to register a test helper which + utilizes this method without the need to actually call `wait()` in your helpers. + + The `wait` helper is built into `registerAsyncHelper` by default. You will not need + to `return app.testHelpers.wait();` - the wait behavior is provided for you. + + Example: + + ```javascript + Ember.Test.registerAsyncHelper('loginUser', function(app, username, password) { + visit('secured/path/here') + .fillIn('#username', username) + .fillIn('#password', password) + .click('.submit'); + }); + + @method wait + @param {Object} value The value to be returned. + @return {RSVP.Promise} + @public + @since 1.0.0 + */ - var SafeAttributeManager = (function (_AttributeManager3) { - babelHelpers.inherits(SafeAttributeManager, _AttributeManager3); + function wait(app, value) { + return new _emberRuntime.RSVP.Promise(function (resolve) { + var router = app.__container__.lookup('router:main'); - function SafeAttributeManager() { - _AttributeManager3.apply(this, arguments); + // Every 10ms, poll for the async thing to have finished + var watcher = setInterval(function () { + // 1. If the router is loading, keep polling + var routerIsLoading = router.router && !!router.router.activeTransition; + if (routerIsLoading) { + return; } - SafeAttributeManager.prototype.setAttribute = function setAttribute(env, element, value) { - _AttributeManager3.prototype.setAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + // 2. If there are pending Ajax requests, keep polling + if (_emberTestingTestPending_requests.pendingRequests()) { + return; + } - SafeAttributeManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - _AttributeManager3.prototype.updateAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + // 3. If there are scheduled timers or we are inside of a run loop, keep polling + if (_emberMetal.run.hasScheduledTimers() || _emberMetal.run.currentRunLoop) { + return; + } - return SafeAttributeManager; - })(AttributeManager); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2F0dHJpYnV0ZS1tYW5hZ2Vycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7OztBQVlBLGFBQUEsZUFBQSxDQUFnQyxPQUF1QixFQUFFLElBQVksRUFBRSxVQUFtQixFQUFFLFNBQWlCLEVBQUE7QUFDM0csWUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQztBQUM5QixZQUFJLEtBQUssR0FBRyxPQUFPLENBQUMsWUFBWSxpQ0FOekIsYUFBYSxBQU04QixDQUFDO0FBRW5ELFlBQUksS0FBSyxFQUFFO0FBQ1QsbUJBQU8sd0JBQXdCLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxDQUFDO1NBQ2hEOztpQ0FFMEIsMkJBYnBCLGlCQUFpQixDQWFxQixPQUFPLEVBQUUsSUFBSSxDQUFDOztZQUFyRCxJQUFJLHNCQUFKLElBQUk7WUFBRSxVQUFVLHNCQUFWLFVBQVU7O0FBRXRCLFlBQUksSUFBSSxLQUFLLE1BQU0sRUFBRTtBQUNuQixtQkFBTyx3QkFBd0IsQ0FBQyxPQUFPLEVBQUUsVUFBVSxDQUFDLENBQUM7U0FDdEQsTUFBTTtBQUNMLG1CQUFPLHVCQUF1QixDQUFDLE9BQU8sRUFBRSxVQUFVLENBQUMsQ0FBQztTQUNyRDtLQUNGOztBQUVELGFBQ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0= -enifed('glimmer-runtime/lib/dom/helper', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/compat/inner-html-fix', 'glimmer-runtime/lib/compat/svg-inner-html-fix', 'glimmer-runtime/lib/compat/text-node-merging-fix', 'glimmer-runtime/lib/dom/interfaces'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibCompatInnerHtmlFix, _glimmerRuntimeLibCompatSvgInnerHtmlFix, _glimmerRuntimeLibCompatTextNodeMergingFix, _glimmerRuntimeLibDomInterfaces) { - 'use strict'; + if (_emberTestingTestWaiters.checkWaiters()) { + return; + } - exports.isWhitespace = isWhitespace; - exports.moveNodesBefore = moveNodesBefore; - exports.insertHTMLBefore = _insertHTMLBefore; - var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - exports.SVG_NAMESPACE = SVG_NAMESPACE; - // http://www.w3.org/TR/html/syntax.html#html-integration-point - var SVG_INTEGRATION_POINTS = { foreignObject: 1, desc: 1, title: 1 }; - // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes - // TODO: Adjust SVG attributes - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - // TODO: Adjust SVG elements - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - var BLACKLIST_TABLE = Object.create(null); - exports.BLACKLIST_TABLE = BLACKLIST_TABLE; - ["b", "big", "blockquote", "body", "br", "center", "code", "dd", "div", "dl", "dt", "em", "embed", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "i", "img", "li", "listing", "main", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", "span", "strong", "strike", "sub", "sup", "table", "tt", "u", "ul", "var"].forEach(function (tag) { - return BLACKLIST_TABLE[tag] = 1; - }); - var WHITESPACE = /[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/; - var doc = typeof document === 'undefined' ? undefined : document; - - function isWhitespace(string) { - return WHITESPACE.test(string); - } - - function moveNodesBefore(source, target, nextSibling) { - var first = source.firstChild; - var last = null; - var current = first; - while (current) { - last = current; - current = current.nextSibling; - target.insertBefore(last, nextSibling); - } - return [first, last]; - } - - var DOM; - exports.DOM = DOM; - (function (DOM) { - var TreeConstruction = (function () { - function TreeConstruction(document) { - this.document = document; - this.uselessElement = null; - this.setupUselessElement(); - } + // Stop polling + clearInterval(watcher); - TreeConstruction.prototype.setupUselessElement = function setupUselessElement() { - this.uselessElement = this.document.createElement('div'); - }; + // Synchronously resolve the promise + _emberMetal.run(null, resolve, value); + }, 10); + }); + } +}); +enifed('ember-testing/index', ['exports', 'ember-testing/support', 'ember-testing/ext/application', 'ember-testing/ext/rsvp', 'ember-testing/helpers', 'ember-testing/initializers', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/setup_for_testing', 'ember-testing/adapters/qunit'], function (exports, _emberTestingSupport, _emberTestingExtApplication, _emberTestingExtRsvp, _emberTestingHelpers, _emberTestingInitializers, _emberTestingTest, _emberTestingAdaptersAdapter, _emberTestingSetup_for_testing, _emberTestingAdaptersQunit) { + 'use strict'; - TreeConstruction.prototype.createElement = function createElement(tag, context) { - var isElementInSVGNamespace = undefined, - isHTMLIntegrationPoint = undefined; - if (context) { - isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg'; - isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName]; - } else { - isElementInSVGNamespace = tag === 'svg'; - isHTMLIntegrationPoint = false; - } - if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { - // FIXME: This does not properly handle with color, face, or - // size attributes, which is also disallowed by the spec. We should fix - // this. - if (BLACKLIST_TABLE[tag]) { - throw new Error('Cannot create a ' + tag + ' inside an SVG context'); - } - return this.document.createElementNS(SVG_NAMESPACE, tag); - } else { - return this.document.createElement(tag); - } - }; + exports.Test = _emberTestingTest.default; + exports.Adapter = _emberTestingAdaptersAdapter.default; + exports.setupForTesting = _emberTestingSetup_for_testing.default; + exports.QUnitAdapter = _emberTestingAdaptersQunit.default; +}); +// to handle various edge cases +// setup RSVP + run loop integration +// adds helpers to helpers object in Test +// to setup initializer - TreeConstruction.prototype.createElementNS = function createElementNS(namespace, tag) { - return this.document.createElementNS(namespace, tag); - }; +/** + @module ember + @submodule ember-testing +*/ +enifed('ember-testing/initializers', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { + 'use strict'; - TreeConstruction.prototype.setAttribute = function setAttribute(element, name, value, namespace) { - if (namespace) { - element.setAttributeNS(namespace, name, value); - } else { - element.setAttribute(name, value); - } - }; + var name = 'deferReadiness in `testing` mode'; - TreeConstruction.prototype.createTextNode = function createTextNode(text) { - return this.document.createTextNode(text); - }; + _emberRuntime.onLoad('Ember.Application', function (Application) { + if (!Application.initializers[name]) { + Application.initializer({ + name: name, - TreeConstruction.prototype.createComment = function createComment(data) { - return this.document.createComment(data); - }; + initialize: function (application) { + if (application.testing) { + application.deferReadiness(); + } + } + }); + } + }); +}); +enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit) { + /* global self */ - TreeConstruction.prototype.insertBefore = function insertBefore(parent, node, reference) { - parent.insertBefore(node, reference); - }; + 'use strict'; - TreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - return _insertHTMLBefore(this.uselessElement, parent, reference, html); - }; + exports.default = setupForTesting; - return TreeConstruction; - })(); + /** + Sets Ember up for testing. This is useful to perform + basic setup steps in order to unit test. + + Use `App.setupForTesting` to perform integration tests (full + application testing). + + @method setupForTesting + @namespace Ember + @since 1.5.0 + @private + */ - DOM.TreeConstruction = TreeConstruction; - var appliedTreeContruction = TreeConstruction; - appliedTreeContruction = _glimmerRuntimeLibCompatTextNodeMergingFix.treeConstruction(doc, appliedTreeContruction); - appliedTreeContruction = _glimmerRuntimeLibCompatInnerHtmlFix.treeConstruction(doc, appliedTreeContruction); - appliedTreeContruction = _glimmerRuntimeLibCompatSvgInnerHtmlFix.treeConstruction(doc, appliedTreeContruction, SVG_NAMESPACE); - DOM.DOMTreeConstruction = appliedTreeContruction; - })(DOM || (exports.DOM = DOM = {})); + function setupForTesting() { + _emberMetal.setTesting(true); - var DOMChanges = (function () { - function DOMChanges(document) { - this.document = document; - this.uselessElement = null; - this.namespace = null; - this.uselessElement = this.document.createElement('div'); - } + var adapter = _emberTestingTestAdapter.getAdapter(); + // if adapter is not manually set default to QUnit + if (!adapter) { + _emberTestingTestAdapter.setAdapter(typeof self.QUnit === 'undefined' ? new _emberTestingAdaptersAdapter.default() : new _emberTestingAdaptersQunit.default()); + } - DOMChanges.prototype.setAttribute = function setAttribute(element, name, value) { - element.setAttribute(name, value); - }; + _emberViews.jQuery(document).off('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); + _emberViews.jQuery(document).off('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); - DOMChanges.prototype.setAttributeNS = function setAttributeNS(element, namespace, name, value) { - element.setAttributeNS(namespace, name, value); - }; + _emberTestingTestPending_requests.clearPendingRequests(); - DOMChanges.prototype.removeAttribute = function removeAttribute(element, name) { - element.removeAttribute(name); - }; + _emberViews.jQuery(document).on('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); + _emberViews.jQuery(document).on('ajaxComplete', _emberTestingTestPending_requests.decrementPendingRequests); + } +}); +enifed('ember-testing/support', ['exports', 'ember-metal', 'ember-views', 'ember-environment'], function (exports, _emberMetal, _emberViews, _emberEnvironment) { + 'use strict'; - DOMChanges.prototype.removeAttributeNS = function removeAttributeNS(element, namespace, name) { - element.removeAttributeNS(namespace, name); - }; + /** + @module ember + @submodule ember-testing + */ - DOMChanges.prototype.createTextNode = function createTextNode(text) { - return this.document.createTextNode(text); - }; + var $ = _emberViews.jQuery; - DOMChanges.prototype.createComment = function createComment(data) { - return this.document.createComment(data); - }; + /** + This method creates a checkbox and triggers the click event to fire the + passed in handler. It is used to correct for a bug in older versions + of jQuery (e.g 1.8.3). + + @private + @method testCheckboxClick + */ + function testCheckboxClick(handler) { + var input = document.createElement('input'); + $(input).attr('type', 'checkbox').css({ position: 'absolute', left: '-1000px', top: '-1000px' }).appendTo('body').on('click', handler).trigger('click').remove(); + } - DOMChanges.prototype.createElement = function createElement(tag, context) { - var isElementInSVGNamespace = undefined, - isHTMLIntegrationPoint = undefined; - if (context) { - isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg'; - isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName]; - } else { - isElementInSVGNamespace = tag === 'svg'; - isHTMLIntegrationPoint = false; - } - if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { - // FIXME: This does not properly handle with color, face, or - // size attributes, which is also disallowed by the spec. We should fix - // this. - if (BLACKLIST_TABLE[tag]) { - throw new Error('Cannot create a ' + tag + ' inside an SVG context'); - } - return this.document.createElementNS(SVG_NAMESPACE, tag); - } else { - return this.document.createElement(tag); + if (_emberEnvironment.environment.hasDOM && typeof $ === 'function') { + $(function () { + /* + Determine whether a checkbox checked using jQuery's "click" method will have + the correct value for its checked property. + If we determine that the current jQuery version exhibits this behavior, + patch it to work correctly as in the commit for the actual fix: + https://github.com/jquery/jquery/commit/1fb2f92. + */ + testCheckboxClick(function () { + if (!this.checked && !$.event.special.click) { + $.event.special.click = { + // For checkbox, fire native event so checked state will be right + trigger: function () { + if ($.nodeName(this, 'input') && this.type === 'checkbox' && this.click) { + this.click(); + return false; + } } - }; - - DOMChanges.prototype.insertHTMLBefore = function insertHTMLBefore(_parent, nextSibling, html) { - return _insertHTMLBefore(this.uselessElement, _parent, nextSibling, html); - }; - - DOMChanges.prototype.insertNodeBefore = function insertNodeBefore(parent, node, reference) { - if (isDocumentFragment(node)) { - var firstChild = node.firstChild; - var lastChild = node.lastChild; + }; + } + }); - this.insertBefore(parent, node, reference); - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, firstChild, lastChild); - } else { - this.insertBefore(parent, node, reference); - return new _glimmerRuntimeLibBounds.SingleNodeBounds(parent, node); - } - }; + // Try again to verify that the patch took effect or blow up. + testCheckboxClick(function () { + _emberMetal.warn('clicked checkboxes should be checked! the jQuery patch didn\'t work', this.checked, { id: 'ember-testing.test-checkbox-click' }); + }); + }); + } +}); +enifed('ember-testing/test', ['exports', 'ember-testing/test/helpers', 'ember-testing/test/on_inject_helpers', 'ember-testing/test/promise', 'ember-testing/test/waiters', 'ember-testing/test/adapter'], function (exports, _emberTestingTestHelpers, _emberTestingTestOn_inject_helpers, _emberTestingTestPromise, _emberTestingTestWaiters, _emberTestingTestAdapter) { + /** + @module ember + @submodule ember-testing + */ + 'use strict'; - DOMChanges.prototype.insertTextBefore = function insertTextBefore(parent, nextSibling, text) { - var textNode = this.createTextNode(text); - this.insertBefore(parent, textNode, nextSibling); - return textNode; - }; + /** + This is a container for an assortment of testing related functionality: + + * Choose your default test adapter (for your framework of choice). + * Register/Unregister additional test helpers. + * Setup callbacks to be fired when the test helpers are injected into + your application. + + @class Test + @namespace Ember + @public + */ + var Test = { + /** + Hash containing all known test helpers. + @property _helpers + @private + @since 1.7.0 + */ + _helpers: _emberTestingTestHelpers.helpers, - DOMChanges.prototype.insertBefore = function insertBefore(element, node, reference) { - element.insertBefore(node, reference); - }; + registerHelper: _emberTestingTestHelpers.registerHelper, + registerAsyncHelper: _emberTestingTestHelpers.registerAsyncHelper, + unregisterHelper: _emberTestingTestHelpers.unregisterHelper, + onInjectHelpers: _emberTestingTestOn_inject_helpers.onInjectHelpers, + Promise: _emberTestingTestPromise.default, + promise: _emberTestingTestPromise.promise, + resolve: _emberTestingTestPromise.resolve, + registerWaiter: _emberTestingTestWaiters.registerWaiter, + unregisterWaiter: _emberTestingTestWaiters.unregisterWaiter, + checkWaiters: _emberTestingTestWaiters.checkWaiters + }; - DOMChanges.prototype.insertAfter = function insertAfter(element, node, reference) { - this.insertBefore(element, node, reference.nextSibling); - }; + /** + Used to allow ember-testing to communicate with a specific testing + framework. + + You can manually set it before calling `App.setupForTesting()`. + + Example: + + ```javascript + Ember.Test.adapter = MyCustomAdapter.create() + ``` + + If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`. + + @public + @for Ember.Test + @property adapter + @type {Class} The adapter to be used. + @default Ember.Test.QUnitAdapter + */ + Object.defineProperty(Test, 'adapter', { + get: _emberTestingTestAdapter.getAdapter, + set: _emberTestingTestAdapter.setAdapter + }); - return DOMChanges; - })(); + Object.defineProperty(Test, 'waiters', { + get: _emberTestingTestWaiters.generateDeprecatedWaitersArray + }); - exports.DOMChanges = DOMChanges; - - function _insertHTMLBefore(_useless, _parent, _nextSibling, html) { - // TypeScript vendored an old version of the DOM spec where `insertAdjacentHTML` - // only exists on `HTMLElement` but not on `Element`. We actually work with the - // newer version of the DOM API here (and monkey-patch this method in `./compat` - // when we detect older browsers). This is a hack to work around this limitation. - var parent = _parent; - var useless = _useless; - var nextSibling = _nextSibling; - var prev = nextSibling ? nextSibling.previousSibling : parent.lastChild; - var last = undefined; - if (html === null || html === '') { - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, null, null); - } - if (nextSibling === null) { - parent.insertAdjacentHTML('beforeEnd', html); - last = parent.lastChild; - } else if (nextSibling instanceof HTMLElement) { - nextSibling.insertAdjacentHTML('beforeBegin', html); - last = nextSibling.previousSibling; - } else { - // Non-element nodes do not support insertAdjacentHTML, so add an - // element and call it on that element. Then remove the element. - // - // This also protects Edge, IE and Firefox w/o the inspector open - // from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts - parent.insertBefore(useless, nextSibling); - useless.insertAdjacentHTML('beforeBegin', html); - last = useless.previousSibling; - parent.removeChild(useless); - } - var first = prev ? prev.nextSibling : parent.firstChild; - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - - function isDocumentFragment(node) { - return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE; - } - var helper = DOMChanges; - helper = _glimmerRuntimeLibCompatTextNodeMergingFix.domChanges(doc, helper); - helper = _glimmerRuntimeLibCompatInnerHtmlFix.domChanges(doc, helper); - helper = _glimmerRuntimeLibCompatSvgInnerHtmlFix.domChanges(doc, helper, SVG_NAMESPACE); - exports.default = helper; - var DOMTreeConstruction = DOM.DOMTreeConstruction; - exports.DOMTreeConstruction = DOMTreeConstruction; - exports.DOMNamespace = _glimmerRuntimeLibDomInterfaces.Namespace; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2hlbHBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFlTyxRQUFNLGFBQWEsR0FBRyw0QkFBNEIsQ0FBQzs7O0FBRzFELFFBQU0sc0JBQXNCLEdBQUcsRUFBRSxhQUFhLEVBQUUsQ0FBQyxFQUFFLElBQUksRUFBRSxDQUFDLEVBQUUsS0FBSyxFQUFFLENBQUMsRUFBRSxDQUFDOzs7Ozs7QUFTaEUsUUFBTSxlQUFlLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQzs7QUFFbkQsQUFBQyxLQUNDLEdBQUcsRUFBRSxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsUUFBUSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFDaEcsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxHQUFHLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxTQUFTLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxNQUFNLEVBQ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29uY3JldGVCb3VuZHMocGFyZW50LCBmaXJzdCwgbGFzdCk7XG59XG5cbmZ1bmN0aW9uIGlzRG9jdW1lbnRGcmFnbWVudChub2RlOiBTaW1wbGUuTm9kZSk6IG5vZGUgaXMgRG9jdW1lbnRGcmFnbWVudCB7XG4gIHJldHVybiBub2RlLm5vZGVUeXBlID09PSBOb2RlLkRPQ1VNRU5UX0ZSQUdNRU5UX05PREU7XG59XG5cbmxldCBoZWxwZXIgPSBET01DaGFuZ2VzO1xuXG5oZWxwZXIgPSBkb21DaGFuZ2VzTm9kZU1lcmdpbmdGaXgoZG9jLCBoZWxwZXIpO1xuaGVscGVyID0gZG9tQ2hhbmdlc1RhYmxlRWxlbWVudEZpeChkb2MsIGhlbHBlcik7XG5oZWxwZXIgPSBkb21DaGFuZ2VzU3ZnRWxlbWVudEZpeChkb2MsIGhlbHBlciwgU1ZHX05BTUVTUEFDRSk7XG5cbmV4cG9ydCBkZWZhdWx0IGhlbHBlcjtcbmV4cG9ydCBjb25zdCBET01UcmVlQ29uc3RydWN0aW9uID0gRE9NLkRPTVRyZWVDb25zdHJ1Y3Rpb247XG5leHBvcnQgdHlwZSBET01UcmVlQ29uc3RydWN0aW9uID0gRE9NLkRPTVRyZWVDb25zdHJ1Y3Rpb247XG5leHBvcnQgeyBOYW1lc3BhY2UgYXMgRE9NTmFtZXNwYWNlIH0gZnJvbSAnLi9pbnRlcmZhY2VzJztcbiJdfQ== -enifed("glimmer-runtime/lib/dom/interfaces", ["exports"], function (exports) { - "use strict"; + exports.default = Test; +}); +enifed('ember-testing/test/adapter', ['exports', 'ember-console', 'ember-metal'], function (exports, _emberConsole, _emberMetal) { + 'use strict'; - var NodeType; - exports.NodeType = NodeType; - (function (NodeType) { - NodeType[NodeType["Element"] = 0] = "Element"; - NodeType[NodeType["Attribute"] = 1] = "Attribute"; - NodeType[NodeType["Text"] = 2] = "Text"; - NodeType[NodeType["CdataSection"] = 3] = "CdataSection"; - NodeType[NodeType["EntityReference"] = 4] = "EntityReference"; - NodeType[NodeType["Entity"] = 5] = "Entity"; - NodeType[NodeType["ProcessingInstruction"] = 6] = "ProcessingInstruction"; - NodeType[NodeType["Comment"] = 7] = "Comment"; - NodeType[NodeType["Document"] = 8] = "Document"; - NodeType[NodeType["DocumentType"] = 9] = "DocumentType"; - NodeType[NodeType["DocumentFragment"] = 10] = "DocumentFragment"; - NodeType[NodeType["Notation"] = 11] = "Notation"; - })(NodeType || (exports.NodeType = NodeType = {})); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBV0EsUUFBWSxRQWFYLENBQUE7O0FBYkQsS0FBQSxVQUFZLFFBQVEsRUFBQTtBQUNsQixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxTQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxTQUFPLENBQUE7QUFDUCxnQkFBQSxDQUFBLFFBQUEsQ0FBQSxXQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxXQUFTLENBQUE7QUFDVCxnQkFBQSxDQUFBLFFBQUEsQ0FBQSxNQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxNQUFJLENBQUE7QUFDSixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxjQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxjQUFZLENBQUE7QUFDWixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxpQkFBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsaUJBQWUsQ0FBQTtBQUNmLGdCQUFBLENBQUEsUUFBQSxDQUFBLFFBQUEsQ0FBQSxHQUFBLENBQUEsQ0FBQSxHQUFBLFFBQU0sQ0FBQTtBQUNOLGdCQUFBLENBQUEsUUFBQSxDQUFBLHVCQUFBLENBQUEsR0FBQ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9XG4iXX0= -enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { - /* - * @method normalizeProperty - * @param element {HTMLElement} - * @param slotName {String} - * @returns {Object} { name, type } - */ - 'use strict'; + exports.getAdapter = getAdapter; + exports.setAdapter = setAdapter; + exports.asyncStart = asyncStart; + exports.asyncEnd = asyncEnd; - exports.normalizeProperty = normalizeProperty; - exports.normalizePropertyValue = normalizePropertyValue; + var adapter = undefined; - function normalizeProperty(element, slotName) { - var type = undefined, - normalized = undefined; - if (slotName in element) { - normalized = slotName; - type = 'prop'; - } else { - var lower = slotName.toLowerCase(); - if (lower in element) { - type = 'prop'; - normalized = lower; - } else { - type = 'attr'; - normalized = slotName; - } - } - if (type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName, normalized))) { - type = 'attr'; - } - return { normalized: normalized, type: type }; - } + function getAdapter() { + return adapter; + } - function normalizePropertyValue(value) { - if (value === '') { - return true; - } - return value; + function setAdapter(value) { + adapter = value; + if (value) { + _emberMetal.setDispatchOverride(adapterDispatch); + } else { + _emberMetal.setDispatchOverride(null); } + } - // properties that MUST be set as attributes, due to: - // * browser bug - // * strange spec outlier - var ATTR_OVERRIDES = { - // phantomjs < 2.0 lets you set it as a prop but won't reflect it - // back to the attribute. button.getAttribute('type') === null - BUTTON: { type: true, form: true }, - INPUT: { - // Some version of IE (like IE9) actually throw an exception - // if you set input.type = 'something-unknown' - type: true, - form: true, - // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false - // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false - // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true - }, - // element.form is actually a legitimate readOnly property, that is to be - // mutated, but must be mutated by setAttribute... - SELECT: { form: true }, - OPTION: { form: true }, - TEXTAREA: { form: true }, - LABEL: { form: true }, - FIELDSET: { form: true }, - LEGEND: { form: true }, - OBJECT: { form: true } - }; - function preferAttr(tagName, propName) { - var tag = ATTR_OVERRIDES[tagName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IHRoYXQgaXMgdG8gYmVcbiAgLy8gbXV0YXRlZCwgYnV0IG11c3QgYmUgbXV0YXRlZCBieSBzZXRBdHRyaWJ1dGUuLi5cbiAgU0VMRUNUOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPUFRJT046ICAgeyBmb3JtOiB0cnVlIH0sXG4gIFRFWFRBUkVBOiB7IGZvcm06IHRydWUgfSxcbiAgTEFCRUw6ICAgIHsgZm9ybTogdHJ1ZSB9LFxuICBGSUVMRFNFVDogeyBmb3JtOiB0cnVlIH0sXG4gIExFR0VORDogICB7IGZvcm06IHRydWUgfSxcbiAgT0JKRUNUOiAgIHsgZm9ybTogdHJ1ZSB9XG59O1xuXG5mdW5jdGlvbiBwcmVmZXJBdHRyKHRhZ05hbWUsIHByb3BOYW1lKSB7XG4gIGxldCB0YWcgPSBBVFRSX09WRVJSSURFU1t0YWdOYW1lLnRvVXBwZXJDYXNlKCldO1xuICByZXR1cm4gdGFnICYmIHRhZ1twcm9wTmFtZS50b0xvd2VyQ2FzZSgpXSB8fCBmYWxzZTtcbn1cbiJdfQ== -enifed('glimmer-runtime/lib/dom/sanitized-values', ['exports', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/upsert'], function (exports, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibUpsert) { - 'use strict'; - - exports.requiresSanitization = requiresSanitization; - exports.sanitizeAttributeValue = sanitizeAttributeValue; - - var badProtocols = ['javascript:', 'vbscript:']; - var badTags = ['A', 'BODY', 'LINK', 'IMG', 'IFRAME', 'BASE', 'FORM']; - var badTagsForDataURI = ['EMBED']; - var badAttributes = ['href', 'src', 'background', 'action']; - var badAttributesForDataURI = ['src']; - function has(array, item) { - return array.indexOf(item) !== -1; - } - function checkURI(tagName, attribute) { - return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute); - } - function checkDataURI(tagName, attribute) { - return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute); + function asyncStart() { + if (adapter) { + adapter.asyncStart(); } + } - function requiresSanitization(tagName, attribute) { - return checkURI(tagName, attribute) || checkDataURI(tagName, attribute); + function asyncEnd() { + if (adapter) { + adapter.asyncEnd(); } + } - function sanitizeAttributeValue(env, element, attribute, value) { - var tagName = undefined; - if (value === null || value === undefined) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value)) { - return value.toHTML(); - } - if (!element) { - tagName = null; - } else { - tagName = element.tagName.toUpperCase(); - } - var str = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - if (checkURI(tagName, attribute)) { - var protocol = env.protocolForURL(str); - if (has(badProtocols, protocol)) { - return 'unsafe:' + str; - } - } - if (checkDataURI(tagName, attribute)) { - return 'unsafe:' + str; - } - return str; - } + function adapterDispatch(error) { + adapter.exception(error); + _emberConsole.default.error(error.stack); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Nhbml0aXplZC12YWx1ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBTUEsUUFBTSxZQUFZLEdBQUcsQ0FDbkIsYUFBYSxFQUNiLFdBQVcsQ0FDWixDQUFDO0FBRUYsUUFBTSxPQUFPLEdBQUcsQ0FDZCxHQUFHLEVBQ0gsTUFBTSxFQUNOLE1BQU0sRUFDTixLQUFLLEVBQ0wsUUFBUSxFQUNSLE1BQU0sRUFDTixNQUFNLENBQ1AsQ0FBQztBQUVGLFFBQU0saUJBQWlCLEdBQUcsQ0FDeEIsT0FBTyxDQUNSLENBQUM7QUFFRixRQUFNLGFBQWEsR0FBRyxDQUNwQixNQUFNLEVBQ04sS0FBSyxFQUNMLFlBQVksRUFDWixRQUFRLENBQ1QsQ0FBQztBQUVGLFFBQU0sdUJBQXVCLEdBQUcsQ0FDOUIsS0FBSyxDQUNOLENBQUM7QUFFRixhQUFBLEdBQUEsQ0FBYSxLQUFvQixFQUF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-runtime/lib/dom/attribute-managers', 'glimmer-util', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/syntax/builtins/if', 'glimmer-runtime/lib/syntax/builtins/unless', 'glimmer-runtime/lib/syntax/builtins/with', 'glimmer-runtime/lib/syntax/builtins/each'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibDomAttributeManagers, _glimmerUtil, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibSyntaxBuiltinsIf, _glimmerRuntimeLibSyntaxBuiltinsUnless, _glimmerRuntimeLibSyntaxBuiltinsWith, _glimmerRuntimeLibSyntaxBuiltinsEach) { - 'use strict'; - - var Scope = (function () { - function Scope(references) { - var callerScope = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; +enifed('ember-testing/test/helpers', ['exports', 'ember-testing/test/promise'], function (exports, _emberTestingTestPromise) { + 'use strict'; - this.callerScope = null; - this.slots = references; - this.callerScope = callerScope; - } + exports.registerHelper = registerHelper; + exports.registerAsyncHelper = registerAsyncHelper; + exports.unregisterHelper = unregisterHelper; + var helpers = {}; - Scope.root = function root(self) { - var size = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; + exports.helpers = helpers; + /** + `registerHelper` is used to register a test helper that will be injected + when `App.injectTestHelpers` is called. + + The helper method will always be called with the current Application as + the first parameter. + + For example: + + ```javascript + Ember.Test.registerHelper('boot', function(app) { + Ember.run(app, app.advanceReadiness); + }); + ``` + + This helper can later be called without arguments because it will be + called with `app` as the first parameter. + + ```javascript + App = Ember.Application.create(); + App.injectTestHelpers(); + boot(); + ``` + + @public + @for Ember.Test + @method registerHelper + @param {String} name The name of the helper method to add. + @param {Function} helperMethod + @param options {Object} + */ - var refs = new Array(size + 1); - for (var i = 0; i <= size; i++) { - refs[i] = _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - } - return new Scope(refs).init({ self: self }); - }; + function registerHelper(name, helperMethod) { + helpers[name] = { + method: helperMethod, + meta: { wait: false } + }; + } - Scope.prototype.init = function init(_ref) { - var self = _ref.self; + /** + `registerAsyncHelper` is used to register an async test helper that will be injected + when `App.injectTestHelpers` is called. + + The helper method will always be called with the current Application as + the first parameter. + + For example: + + ```javascript + Ember.Test.registerAsyncHelper('boot', function(app) { + Ember.run(app, app.advanceReadiness); + }); + ``` + + The advantage of an async helper is that it will not run + until the last async helper has completed. All async helpers + after it will wait for it complete before running. + + + For example: + + ```javascript + Ember.Test.registerAsyncHelper('deletePost', function(app, postId) { + click('.delete-' + postId); + }); + + // ... in your test + visit('/post/2'); + deletePost(2); + visit('/post/3'); + deletePost(3); + ``` + + @public + @for Ember.Test + @method registerAsyncHelper + @param {String} name The name of the helper method to add. + @param {Function} helperMethod + @since 1.2.0 + */ - this.slots[0] = self; - return this; - }; + function registerAsyncHelper(name, helperMethod) { + helpers[name] = { + method: helperMethod, + meta: { wait: true } + }; + } - Scope.prototype.getSelf = function getSelf() { - return this.slots[0]; - }; + /** + Remove a previously added helper method. + + Example: + + ```javascript + Ember.Test.unregisterHelper('wait'); + ``` + + @public + @method unregisterHelper + @param {String} name The helper to remove. + */ - Scope.prototype.getSymbol = function getSymbol(symbol) { - return this.slots[symbol]; - }; + function unregisterHelper(name) { + delete helpers[name]; + delete _emberTestingTestPromise.default.prototype[name]; + } +}); +enifed("ember-testing/test/on_inject_helpers", ["exports"], function (exports) { + "use strict"; - Scope.prototype.getBlock = function getBlock(symbol) { - return this.slots[symbol]; - }; + exports.onInjectHelpers = onInjectHelpers; + exports.invokeInjectHelpersCallbacks = invokeInjectHelpersCallbacks; + var callbacks = []; - Scope.prototype.getPartialArgs = function getPartialArgs(symbol) { - return this.slots[symbol]; - }; + exports.callbacks = callbacks; + /** + Used to register callbacks to be fired whenever `App.injectTestHelpers` + is called. + + The callback will receive the current application as an argument. + + Example: + + ```javascript + Ember.Test.onInjectHelpers(function() { + Ember.$(document).ajaxSend(function() { + Test.pendingRequests++; + }); + + Ember.$(document).ajaxComplete(function() { + Test.pendingRequests--; + }); + }); + ``` + + @public + @for Ember.Test + @method onInjectHelpers + @param {Function} callback The function to be called. + */ - Scope.prototype.bindSymbol = function bindSymbol(symbol, value) { - this.slots[symbol] = value; - }; + function onInjectHelpers(callback) { + callbacks.push(callback); + } - Scope.prototype.bindBlock = function bindBlock(symbol, value) { - this.slots[symbol] = value; - }; + function invokeInjectHelpersCallbacks(app) { + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](app); + } + } +}); +enifed("ember-testing/test/pending_requests", ["exports"], function (exports) { + "use strict"; - Scope.prototype.bindPartialArgs = function bindPartialArgs(symbol, value) { - this.slots[symbol] = value; - }; + exports.pendingRequests = pendingRequests; + exports.clearPendingRequests = clearPendingRequests; + exports.incrementPendingRequests = incrementPendingRequests; + exports.decrementPendingRequests = decrementPendingRequests; + var requests = []; - Scope.prototype.bindCallerScope = function bindCallerScope(scope) { - this.callerScope = scope; - }; + function pendingRequests() { + return requests.length; + } - Scope.prototype.getCallerScope = function getCallerScope() { - return this.callerScope; - }; + function clearPendingRequests() { + requests.length = 0; + } - Scope.prototype.child = function child() { - return new Scope(this.slots.slice(), this.callerScope); - }; + function incrementPendingRequests(_, xhr) { + requests.push(xhr); + } - return Scope; - })(); + function decrementPendingRequests(_, xhr) { + for (var i = 0; i < requests.length; i++) { + if (xhr === requests[i]) { + requests.splice(i, 1); + break; + } + } + } +}); +enifed('ember-testing/test/promise', ['exports', 'ember-runtime', 'ember-testing/test/run'], function (exports, _emberRuntime, _emberTestingTestRun) { + 'use strict'; - exports.Scope = Scope; + exports.promise = promise; + exports.resolve = resolve; + exports.getLastPromise = getLastPromise; - var Environment = (function () { - function Environment(_ref2) { - var appendOperations = _ref2.appendOperations; - var updateOperations = _ref2.updateOperations; + var lastPromise = undefined; - this.scheduledInstallManagers = null; - this.scheduledInstallModifiers = null; - this.scheduledUpdateModifierManagers = null; - this.scheduledUpdateModifiers = null; - this.createdComponents = null; - this.createdManagers = null; - this.updatedComponents = null; - this.updatedManagers = null; - this.destructors = null; - this.appendOperations = appendOperations; - this.updateOperations = updateOperations; - } + var TestPromise = (function (_RSVP$Promise) { + babelHelpers.inherits(TestPromise, _RSVP$Promise); - Environment.prototype.toConditionalReference = function toConditionalReference(reference) { - return new _glimmerRuntimeLibReferences.ConditionalReference(reference); - }; + function TestPromise() { + babelHelpers.classCallCheck(this, TestPromise); - Environment.prototype.getAppendOperations = function getAppendOperations() { - return this.appendOperations; - }; + _RSVP$Promise.apply(this, arguments); + lastPromise = this; + } - Environment.prototype.getDOM = function getDOM() { - return this.updateOperations; - }; + /** + This returns a thenable tailored for testing. It catches failed + `onSuccess` callbacks and invokes the `Ember.Test.adapter.exception` + callback in the last chained then. + + This method should be returned by async helpers such as `wait`. + + @public + @for Ember.Test + @method promise + @param {Function} resolver The function used to resolve the promise. + @param {String} label An optional string for identifying the promise. + */ - Environment.prototype.getIdentity = function getIdentity(object) { - return _glimmerUtil.ensureGuid(object) + ''; - }; + TestPromise.prototype.then = function then(onFulfillment) { + var _RSVP$Promise$prototype$then; - Environment.prototype.statement = function statement(_statement, symbolTable) { - return this.refineStatement(parseStatement(_statement), symbolTable) || _statement; - }; + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - Environment.prototype.refineStatement = function refineStatement(statement, symbolTable) { - var isSimple = statement.isSimple; - var isBlock = statement.isBlock; - var key = statement.key; - var args = statement.args; - - if (isSimple && isBlock) { - switch (key) { - case 'each': - return new _glimmerRuntimeLibSyntaxBuiltinsEach.default(args); - case 'if': - return new _glimmerRuntimeLibSyntaxBuiltinsIf.default(args); - case 'with': - return new _glimmerRuntimeLibSyntaxBuiltinsWith.default(args); - case 'unless': - return new _glimmerRuntimeLibSyntaxBuiltinsUnless.default(args); - } - } - }; + return (_RSVP$Promise$prototype$then = _RSVP$Promise.prototype.then).call.apply(_RSVP$Promise$prototype$then, [this, function (result) { + return isolate(onFulfillment, result); + }].concat(args)); + }; - Environment.prototype.begin = function begin() { - this.createdComponents = []; - this.createdManagers = []; - this.updatedComponents = []; - this.updatedManagers = []; - this.destructors = []; - this.scheduledInstallManagers = []; - this.scheduledInstallModifiers = []; - this.scheduledUpdateModifierManagers = []; - this.scheduledUpdateModifiers = []; - }; + return TestPromise; + })(_emberRuntime.RSVP.Promise); - Environment.prototype.didCreate = function didCreate(component, manager) { - this.createdComponents.push(component); - this.createdManagers.push(manager); - }; + exports.default = TestPromise; - Environment.prototype.didUpdate = function didUpdate(component, manager) { - this.updatedComponents.push(component); - this.updatedManagers.push(manager); - }; + function promise(resolver, label) { + var fullLabel = 'Ember.Test.promise: ' + (label || ''); + return new TestPromise(resolver, fullLabel); + } - Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier, manager) { - this.scheduledInstallManagers.push(manager); - this.scheduledInstallModifiers.push(modifier); - }; + /** + Replacement for `Ember.RSVP.resolve` + The only difference is this uses + an instance of `Ember.Test.Promise` + + @public + @for Ember.Test + @method resolve + @param {Mixed} The value to resolve + @since 1.2.0 + */ - Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier, manager) { - this.scheduledUpdateModifierManagers.push(manager); - this.scheduledUpdateModifiers.push(modifier); - }; + function resolve(result, label) { + return TestPromise.resolve(result, label); + } - Environment.prototype.didDestroy = function didDestroy(d) { - this.destructors.push(d); - }; + function getLastPromise() { + return lastPromise; + } - Environment.prototype.commit = function commit() { - for (var i = 0; i < this.createdComponents.length; i++) { - var component = this.createdComponents[i]; - var manager = this.createdManagers[i]; - manager.didCreate(component); - } - for (var i = 0; i < this.updatedComponents.length; i++) { - var component = this.updatedComponents[i]; - var manager = this.updatedManagers[i]; - manager.didUpdate(component); - } - for (var i = 0; i < this.destructors.length; i++) { - this.destructors[i].destroy(); - } - for (var i = 0; i < this.scheduledInstallManagers.length; i++) { - var manager = this.scheduledInstallManagers[i]; - var modifier = this.scheduledInstallModifiers[i]; - manager.install(modifier); - } - for (var i = 0; i < this.scheduledUpdateModifierManagers.length; i++) { - var manager = this.scheduledUpdateModifierManagers[i]; - var modifier = this.scheduledUpdateModifiers[i]; - manager.update(modifier); - } - this.createdComponents = null; - this.createdManagers = null; - this.updatedComponents = null; - this.updatedManagers = null; - this.destructors = null; - this.scheduledInstallManagers = null; - this.scheduledInstallModifiers = null; - this.scheduledUpdateModifierManagers = null; - this.scheduledUpdateModifiers = null; - }; + // This method isolates nested async methods + // so that they don't conflict with other last promises. + // + // 1. Set `Ember.Test.lastPromise` to null + // 2. Invoke method + // 3. Return the last promise created during method + function isolate(onFulfillment, result) { + // Reset lastPromise for nested helpers + lastPromise = null; - Environment.prototype.attributeFor = function attributeFor(element, attr, isTrusting, namespace) { - return _glimmerRuntimeLibDomAttributeManagers.defaultManagers(element, attr, isTrusting, namespace); - }; + var value = onFulfillment(result); - return Environment; - })(); + var promise = lastPromise; + lastPromise = null; - exports.Environment = Environment; - exports.default = Environment; - - function parseStatement(statement) { - var type = statement.type; - var block = type === 'block' ? statement : null; - var append = type === 'optimized-append' ? statement : null; - var modifier = type === 'modifier' ? statement : null; - var appendType = append && append.value.type; - var args = undefined; - var path = undefined; - if (block) { - args = block.args; - path = block.path; - } else if (append && (appendType === 'unknown' || appendType === 'get')) { - var appendValue = append.value; - args = _glimmerRuntimeLibSyntaxCore.Args.empty(); - path = appendValue.ref.parts; - } else if (append && append.value.type === 'helper') { - var helper = append.value; - args = helper.args; - path = helper.ref.parts; - } else if (modifier) { - path = modifier.path; - args = modifier.args; - } - var key = undefined, - isSimple = undefined; - if (path) { - isSimple = path.length === 1; - key = path[0]; - } - return { - isSimple: isSimple, - path: path, - key: key, - args: args, - appendType: appendType, - original: statement, - isInline: !!append, - isBlock: !!block, - isModifier: !!modifier - }; + // If the method returned a promise + // return that promise. If not, + // return the last async helper's promise + if (value && value instanceof TestPromise || !promise) { + return value; + } else { + return _emberTestingTestRun.default(function () { + return resolve(promise).then(function () { + return value; + }); + }); } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3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7XG4gICAgfSBlbHNlIGlmIChtb2RpZmllcikge1xuICAgICAgcGF0aCA9IG1vZGlmaWVyLnBhdGg7XG4gICAgICBhcmdzID0gbW9kaWZpZXIuYXJncztcbiAgICB9XG5cbiAgICBsZXQga2V5OiBzdHJpbmcsIGlzU2ltcGxlOiBib29sZWFuO1xuXG4gICAgaWYgKHBhdGgpIHtcbiAgICAgIGlzU2ltcGxlID0gcGF0aC5sZW5ndGggPT09IDE7XG4gICAgICBrZXkgPSBwYXRoWzBdO1xuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICBpc1NpbXBsZSxcbiAgICAgIHBhdGgsXG4gICAgICBrZXksXG4gICAgICBhcmdzLFxuICAgICAgYXBwZW5kVHlwZSxcbiAgICAgIG9yaWdpbmFsOiBzdGF0ZW1lbnQsXG4gICAgICBpc0lubGluZTogISFhcHBlbmQsXG4gICAgICBpc0Jsb2NrOiAhIWJsb2NrLFxuICAgICAgaXNNb2RpZmllcjogISFtb2RpZmllclxuICAgIH07XG59XG4iXX0= -enifed('glimmer-runtime/lib/helpers/get-dynamic-var', ['exports', 'glimmer-reference'], function (exports, _glimmerReference) { - 'use strict'; - - var DynamicVarReference = (function () { - function DynamicVarReference(scope, nameRef) { - this.scope = scope; - this.nameRef = nameRef; - var varTag = this.varTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([nameRef.tag, varTag]); - } - - DynamicVarReference.prototype.value = function value() { - return this.getVar().value(); - }; - - DynamicVarReference.prototype.get = function get(key) { - return this.getVar().get(key); - }; - - DynamicVarReference.prototype.getVar = function getVar() { - var name = String(this.nameRef.value()); - var ref = this.scope.get(name); - this.varTag.update(ref.tag); - return ref; - }; +enifed('ember-testing/test/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - return DynamicVarReference; - })(); + exports.default = run; - function getDynamicVar(vm, args, symbolTable) { - var scope = vm.dynamicScope(); - var nameRef = args.positional.at(0); - return new DynamicVarReference(scope, nameRef); + function run(fn) { + if (!_emberMetal.run.currentRunLoop) { + return _emberMetal.run(fn); + } else { + return fn(); } - exports.default = getDynamicVar; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvaGVscGVycy9nZXQtZHluYW1pYy12YXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBT0EsbUJBQUE7QUFJRSxpQkFKRixtQkFBQSxDQUlzQixLQUFtQixFQUFVLE9BQThCLEVBQUE7QUFBM0QsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUFjO0FBQVUsZ0JBQUEsQ0FBQSxPQUFPLEdBQVAsT0FBTyxDQUF1QjtBQUM3RSxnQkFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLE1BQU0sR0FBRyxzQkFSb0IsWUFBWSxtQkFBdEQsWUFBWSxDQVF3QyxDQUFDO0FBQzFELGdCQUFJLENBQUMsR0FBRyxHQUFHLGtCQVRrRCxPQUFPLENBU2pELENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDO1NBQzNDOztBQVBILDJCQUFBLFdBU0UsS0FBSyxHQUFBLGlCQUFBO0FBQ0gsbUJBQU8sSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDO1NBQzlCOztBQVhILDJCQUFBLFdBYUUsR0FBRyxHQUFBLGFBQUMsR0FBVyxFQUFBO0FBQ2IsbUJBQU8sSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztTQUMvQjs7QUFmSCwyQkFBQSxXQWlCVSxNQUFNLEdBQUEsa0JBQUE7QUFDWixnQkFBSSxJQUFJLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQztB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lID0gdm0uZHluYW1pY1Njb3BlKCk7XG4gIGxldCBuYW1lUmVmID0gYXJncy5wb3NpdGlvbmFsLmF0KDApO1xuXG4gIHJldHVybiBuZXcgRHluYW1pY1ZhclJlZmVyZW5jZShzY29wZSwgbmFtZVJlZik7XG59XG5cbmV4cG9ydCBkZWZhdWx0IChnZXREeW5hbWljVmFyIGFzIEhlbHBlcik7XG4iXX0= -enifed("glimmer-runtime/lib/modifier/interfaces", ["exports"], function (exports) { - "use strict"; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvbW9kaWZpZXIvaW50ZXJmYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwiZmlsZSI6ImludGVyZmFjZXMuanMiLCJzb3VyY2VzQ29udGVudCI6W119 -enifed("glimmer-runtime/lib/opcode-builder", ["exports"], function (exports) { - "use strict"; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvb3Bjb2RlLWJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJvcGNvZGUtYnVpbGRlci5qcyIsInNvdXJjZXNDb250ZW50IjpbXX0= -enifed('glimmer-runtime/lib/opcodes', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; - - exports.inspect = inspect; - - var AbstractOpcode = (function () { - function AbstractOpcode() { - _glimmerUtil.initializeGuid(this); - } +enifed('ember-testing/test/waiters', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - AbstractOpcode.prototype.toJSON = function toJSON() { - return { guid: this._guid, type: this.type }; - }; + exports.registerWaiter = registerWaiter; + exports.unregisterWaiter = unregisterWaiter; + exports.checkWaiters = checkWaiters; + exports.generateDeprecatedWaitersArray = generateDeprecatedWaitersArray; - return AbstractOpcode; - })(); + var contexts = []; + var callbacks = []; - exports.AbstractOpcode = AbstractOpcode; + /** + This allows ember-testing to play nicely with other asynchronous + events, such as an application that is waiting for a CSS3 + transition or an IndexDB transaction. The waiter runs periodically + after each async helper (i.e. `click`, `andThen`, `visit`, etc) has executed, + until the returning result is truthy. After the waiters finish, the next async helper + is executed and the process repeats. + + For example: + + ```javascript + Ember.Test.registerWaiter(function() { + return myPendingTransactions() == 0; + }); + ``` + The `context` argument allows you to optionally specify the `this` + with which your callback will be invoked. + + For example: + + ```javascript + Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions); + ``` + + @public + @for Ember.Test + @method registerWaiter + @param {Object} context (optional) + @param {Function} callback + @since 1.2.0 + */ - var Opcode = (function (_AbstractOpcode) { - babelHelpers.inherits(Opcode, _AbstractOpcode); + function registerWaiter(context, callback) { + if (arguments.length === 1) { + callback = context; + context = null; + } + if (indexOf(context, callback) > -1) { + return; + } + contexts.push(context); + callbacks.push(callback); + } - function Opcode() { - _AbstractOpcode.apply(this, arguments); - this.next = null; - this.prev = null; - } + /** + `unregisterWaiter` is used to unregister a callback that was + registered with `registerWaiter`. + + @public + @for Ember.Test + @method unregisterWaiter + @param {Object} context (optional) + @param {Function} callback + @since 1.2.0 + */ - return Opcode; - })(AbstractOpcode); + function unregisterWaiter(context, callback) { + if (!callbacks.length) { + return; + } + if (arguments.length === 1) { + callback = context; + context = null; + } + var i = indexOf(context, callback); + if (i === -1) { + return; + } + contexts.splice(i, 1); + callbacks.splice(i, 1); + } - exports.Opcode = Opcode; + /** + Iterates through each registered test waiter, and invokes + its callback. If any waiter returns false, this method will return + true indicating that the waiters have not settled yet. + + This is generally used internally from the acceptance/integration test + infrastructure. + + @public + @for Ember.Test + @static + @method checkWaiters + */ - var UpdatingOpcode = (function (_AbstractOpcode2) { - babelHelpers.inherits(UpdatingOpcode, _AbstractOpcode2); + function checkWaiters() { + if (!callbacks.length) { + return false; + } + for (var i = 0; i < callbacks.length; i++) { + var context = contexts[i]; + var callback = callbacks[i]; + if (!callback.call(context)) { + return true; + } + } + return false; + } - function UpdatingOpcode() { - _AbstractOpcode2.apply(this, arguments); - this.next = null; - this.prev = null; - } + function indexOf(context, callback) { + for (var i = 0; i < callbacks.length; i++) { + if (callbacks[i] === callback && contexts[i] === context) { + return i; + } + } + return -1; + } - return UpdatingOpcode; - })(AbstractOpcode); + function generateDeprecatedWaitersArray() { + _emberMetal.deprecate('Usage of `Ember.Test.waiters` is deprecated. Please refactor to `Ember.Test.checkWaiters`.', false, { until: '2.8.0', id: 'ember-testing.test-waiters' }); - exports.UpdatingOpcode = UpdatingOpcode; + var array = new Array(callbacks.length); + for (var i = 0; i < callbacks.length; i++) { + var context = contexts[i]; + var callback = callbacks[i]; - function inspect(opcodes) { - var buffer = []; - opcodes.toArray().forEach(function (opcode, i) { - _inspect(opcode.toJSON(), buffer, 0, i); - }); - return buffer.join(''); + array[i] = [context, callback]; } - function _inspect(opcode, buffer, level, index) { - var indentation = []; - for (var i = 0; i < level; i++) { - indentation.push(' '); - } - buffer.push.apply(buffer, indentation); - buffer.push(index + 1 + '. ' + opcode.type.toUpperCase()); - if (opcode.args || opcode.details) { - buffer.push('('); - if (opcode.args) { - buffer.push(opcode.args.join(', ')); - } - if (opcode.details) { - var keys = Object.keys(opcode.details); - if (keys.length) { - if (opcode.args && opcode.args.length) { - buffer.push(', '); - } - buffer.push(keys.map(function (key) { - return key + '=' + opcode.details[key]; - }).join(', ')); - } - } - buffer.push(')'); - } - buffer.push('\n'); - if (opcode.children && opcode.children.length) { - for (var i = 0; i < opcode.children.length; i++) { - _inspect(opcode.children[i], buffer, level + 1, i); - } - } - } + return array; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvb3Bjb2Rlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztRQWFBLGNBQUE7QUFPRSxpQkFQRixjQUFBLEdBT0U7QUFDRSx5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G4gICAgICBidWZmZXIucHVzaChvcGNvZGUuYXJncy5qb2luKCcsICcpKTtcbiAgICB9XG5cbiAgICBpZiAob3Bjb2RlLmRldGFpbHMpIHtcbiAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob3Bjb2RlLmRldGFpbHMpO1xuXG4gICAgICBpZiAoa2V5cy5sZW5ndGgpIHtcbiAgICAgICAgaWYgKG9wY29kZS5hcmdzICYmIG9wY29kZS5hcmdzLmxlbmd0aCkge1xuICAgICAgICAgIGJ1ZmZlci5wdXNoKCcsICcpO1xuICAgICAgICB9XG5cbiAgICAgICAgYnVmZmVyLnB1c2goa2V5cy5tYXAoa2V5ID0+IGAke2tleX09JHtvcGNvZGUuZGV0YWlsc1trZXldfWApLmpvaW4oJywgJykpO1xuICAgICAgfVxuICAgIH1cblxuICAgIGJ1ZmZlci5wdXNoKCcpJyk7XG4gIH1cblxuICBidWZmZXIucHVzaCgnXFxuJyk7XG5cbiAgaWYgKG9wY29kZS5jaGlsZHJlbiAmJiBvcGNvZGUuY2hpbGRyZW4ubGVuZ3RoKSB7XG4gICAgZm9yIChsZXQgaT0wOyBpPG9wY29kZS5jaGlsZHJlbi5sZW5ndGg7IGkrKykge1xuICAgICAgX2luc3BlY3Qob3Bjb2RlLmNoaWxkcmVuW2ldLCBidWZmZXIsIGxldmVsKzEsIGkpO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed("glimmer-runtime/lib/partial", ["exports"], function (exports) { - "use strict"; +enifed("ember-utils/apply-str", ["exports"], function (exports) { + /** + @param {Object} t target + @param {String} m method + @param {Array} a args + @private + */ + "use strict"; - var PartialDefinition = function PartialDefinition(name, template) { - this.name = name; - this.template = template; - }; + exports.default = applyStr; - exports.PartialDefinition = PartialDefinition; + function applyStr(t, m, a) { + var l = a && a.length; + if (!a || !l) { + return t[m](); + } + switch (l) { + case 1: + return t[m](a[0]); + case 2: + return t[m](a[0], a[1]); + case 3: + return t[m](a[0], a[1], a[2]); + case 4: + return t[m](a[0], a[1], a[2], a[3]); + case 5: + return t[m](a[0], a[1], a[2], a[3], a[4]); + default: + return t[m].apply(t, a); + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvcGFydGlhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFFQSxpQkFBQSxHQUlFLFNBSkYsaUJBQUEsQ0FJYyxJQUFZLEVBQUUsUUFBcUIsRUFBQTtBQUM3QyxZQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztBQUNqQixZQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztLQUMxQiIsImZpbGUiOiJwYXJ0aWFsLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgVGVtcGxhdGUgfSBmcm9tICcuL3RlbXBsYXRlJztcblxuZXhwb3J0IGNsYXNzIFBhcnRpYWxEZWZpbml0aW9uPFQ+IHtcbiAgbmFtZTogc3RyaW5nOyAvLyBmb3IgZGVidWdnaW5nXG4gIHRlbXBsYXRlOiBUZW1wbGF0ZTxUPjtcblxuICBjb25zdHJ1Y3RvcihuYW1lOiBzdHJpbmcsIHRlbXBsYXRlOiBUZW1wbGF0ZTxUPikge1xuICAgIHRoaXMubmFtZSA9IG5hbWU7XG4gICAgdGhpcy50ZW1wbGF0ZSA9IHRlbXBsYXRlO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/references', ['exports', 'glimmer-reference'], function (exports, _glimmerReference) { - 'use strict'; - - var PrimitiveReference = (function (_ConstReference) { - babelHelpers.inherits(PrimitiveReference, _ConstReference); - - function PrimitiveReference(value) { - _ConstReference.call(this, value); - } - - PrimitiveReference.create = function create(value) { - if (value === undefined) { - return UNDEFINED_REFERENCE; - } else if (value === null) { - return NULL_REFERENCE; - } else if (value === true) { - return TRUE_REFERENCE; - } else if (value === false) { - return FALSE_REFERENCE; - } else if (typeof value === 'number') { - return new ValueReference(value); - } else { - return new StringReference(value); - } - }; - - PrimitiveReference.prototype.get = function get(key) { - return UNDEFINED_REFERENCE; - }; - - return PrimitiveReference; - })(_glimmerReference.ConstReference); - - exports.PrimitiveReference = PrimitiveReference; - - var StringReference = (function (_PrimitiveReference) { - babelHelpers.inherits(StringReference, _PrimitiveReference); +enifed("ember-utils/assign", ["exports"], function (exports) { + /** + Copy properties from a source object to a target object. + + ```javascript + var a = { first: 'Yehuda' }; + var b = { last: 'Katz' }; + var c = { company: 'Tilde Inc.' }; + Ember.assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' } + ``` + + @method assign + @for Ember + @param {Object} original The object to assign into + @param {Object} ...args The objects to copy properties from + @return {Object} + @public + */ + "use strict"; - function StringReference() { - _PrimitiveReference.apply(this, arguments); - this.lengthReference = null; - } + exports.default = assign; - StringReference.prototype.get = function get(key) { - if (key === 'length') { - var lengthReference = this.lengthReference; + function assign(original) { + for (var i = 1; i < arguments.length; i++) { + var arg = arguments[i]; + if (!arg) { + continue; + } - if (lengthReference === null) { - lengthReference = this.lengthReference = new ValueReference(this.inner.length); - } - return lengthReference; - } else { - return _PrimitiveReference.prototype.get.call(this, key); - } - }; + var updates = Object.keys(arg); - return StringReference; - })(PrimitiveReference); + for (var _i = 0; _i < updates.length; _i++) { + var prop = updates[_i]; + original[prop] = arg[prop]; + } + } - var ValueReference = (function (_PrimitiveReference2) { - babelHelpers.inherits(ValueReference, _PrimitiveReference2); + return original; + } +}); +enifed('ember-utils/dictionary', ['exports', 'ember-utils/empty-object'], function (exports, _emberUtilsEmptyObject) { + 'use strict'; - function ValueReference(value) { - _PrimitiveReference2.call(this, value); - } + exports.default = makeDictionary; - return ValueReference; - })(PrimitiveReference); + // the delete is meant to hint at runtimes that this object should remain in + // dictionary mode. This is clearly a runtime specific hack, but currently it + // appears worthwhile in some usecases. Please note, these deletes do increase + // the cost of creation dramatically over a plain Object.create. And as this + // only makes sense for long-lived dictionaries that aren't instantiated often. - var UNDEFINED_REFERENCE = new ValueReference(undefined); - exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE; - var NULL_REFERENCE = new ValueReference(null); - exports.NULL_REFERENCE = NULL_REFERENCE; - var TRUE_REFERENCE = new ValueReference(true); - var FALSE_REFERENCE = new ValueReference(false); + function makeDictionary(parent) { + var dict = undefined; + if (parent === null) { + dict = new _emberUtilsEmptyObject.default(); + } else { + dict = Object.create(parent); + } + dict['_dict'] = null; + delete dict['_dict']; + return dict; + } +}); +enifed("ember-utils/empty-object", ["exports"], function (exports) { + // This exists because `Object.create(null)` is absurdly slow compared + // to `new EmptyObject()`. In either case, you want a null prototype + // when you're treating the object instances as arbitrary dictionaries + // and don't want your keys colliding with build-in methods on the + // default object prototype. - var ConditionalReference = (function () { - function ConditionalReference(inner) { - this.inner = inner; - this.tag = inner.tag; - } + "use strict"; - ConditionalReference.prototype.value = function value() { - return this.toBool(this.inner.value()); - }; + var proto = Object.create(null, { + // without this, we will always still end up with (new + // EmptyObject()).constructor === Object + constructor: { + value: undefined, + enumerable: false, + writable: true + } + }); - ConditionalReference.prototype.toBool = function toBool(value) { - return !!value; - }; + function EmptyObject() {} + EmptyObject.prototype = proto; + exports.default = EmptyObject; +}); +enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, _emberUtilsIntern) { + 'use strict'; - return ConditionalReference; - })(); + exports.uuid = uuid; + exports.generateGuid = generateGuid; + exports.guidFor = guidFor; - exports.ConditionalReference = ConditionalReference; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvcmVmZXJlbmNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFLQSxrQkFBQTs4QkFBQSxrQkFBQTs7QUFzQkUsaUJBdEJGLGtCQUFBLENBc0J3QixLQUFRLEVBQUE7QUFDNUIsdUN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gbmV3IFZhbHVlUmVmZXJlbmNlKGZhbHNlKTtcblxuZXhwb3J0IGNsYXNzIENvbmRpdGlvbmFsUmVmZXJlbmNlIGltcGxlbWVudHMgUmVmZXJlbmNlPGJvb2xlYW4+IHtcbiAgcHVibGljIHRhZzogUmV2aXNpb25UYWc7XG5cbiAgY29uc3RydWN0b3IocHJpdmF0ZSBpbm5lcjogUmVmZXJlbmNlPE9wYXF1ZT4pIHtcbiAgICB0aGlzLnRhZyA9IGlubmVyLnRhZztcbiAgfVxuXG4gIHZhbHVlKCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLnRvQm9vbCh0aGlzLmlubmVyLnZhbHVlKCkpO1xuICB9XG5cbiAgcHJvdGVjdGVkIHRvQm9vbCh2YWx1ZTogT3BhcXVlKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuICEhdmFsdWU7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/scanner', ['exports', 'glimmer-runtime/lib/syntax/statements', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-util', 'glimmer-runtime/lib/symbol-table'], function (exports, _glimmerRuntimeLibSyntaxStatements, _glimmerRuntimeLibCompiledBlocks, _glimmerUtil, _glimmerRuntimeLibSymbolTable) { - 'use strict'; + /** + Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from + jQuery master. We'll just bootstrap our own uuid now. + + @private + @return {Number} the uuid + */ + var _uuid = 0; - var Scanner = (function () { - function Scanner(block, meta, env) { - this.block = block; - this.meta = meta; - this.env = env; - } + /** + Generates a universally unique identifier. This method + is used internally by Ember for assisting with + the generation of GUID's and other unique identifiers. + + @public + @return {Number} [description] + */ - Scanner.prototype.scanEntryPoint = function scanEntryPoint() { - var block = this.block; - var meta = this.meta; + function uuid() { + return ++_uuid; + } - var symbolTable = _glimmerRuntimeLibSymbolTable.default.forEntryPoint(meta); - var program = buildStatements(block, block.blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.EntryPoint(program, symbolTable); - }; + /** + Prefix used for guids through out Ember. + @private + @property GUID_PREFIX + @for Ember + @type String + @final + */ + var GUID_PREFIX = 'ember'; - Scanner.prototype.scanLayout = function scanLayout() { - var block = this.block; - var meta = this.meta; - var blocks = block.blocks; - var named = block.named; - var yields = block.yields; - var hasPartials = block.hasPartials; - - var symbolTable = _glimmerRuntimeLibSymbolTable.default.forLayout(named, yields, hasPartials, meta); - var program = buildStatements(block, blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.Layout(program, symbolTable, named, yields, hasPartials); - }; + // Used for guid generation... + var numberCache = []; + var stringCache = {}; - Scanner.prototype.scanPartial = function scanPartial(symbolTable) { - var block = this.block; - var blocks = block.blocks; - var locals = block.locals; + /** + A unique key used to assign guids and other private metadata to objects. + If you inspect an object in your browser debugger you will often see these. + They can be safely ignored. + + On browsers that support it, these properties are added with enumeration + disabled so they won't show up when you iterate over your properties. + + @private + @property GUID_KEY + @for Ember + @type String + @final + */ + var GUID_KEY = _emberUtilsIntern.default('__ember' + +new Date()); - var program = buildStatements(block, blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.PartialBlock(program, symbolTable, locals); - }; + exports.GUID_KEY = GUID_KEY; + var GUID_DESC = { + writable: true, + configurable: true, + enumerable: false, + value: null + }; - return Scanner; - })(); + exports.GUID_DESC = GUID_DESC; + var nullDescriptor = { + configurable: true, + writable: true, + enumerable: false, + value: null + }; - exports.default = Scanner; + var GUID_KEY_PROPERTY = { + name: GUID_KEY, + descriptor: nullDescriptor + }; - function buildStatements(_ref, blocks, symbolTable, env) { - var statements = _ref.statements; + exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY; + /** + Generates a new guid, optionally saving the guid to the object that you + pass in. You will rarely need to use this method. Instead you should + call `Ember.guidFor(obj)`, which return an existing guid if available. + + @private + @method generateGuid + @for Ember + @param {Object} [obj] Object the guid will be used for. If passed in, the guid will + be saved on the object and reused whenever you pass the same object + again. + + If no object is passed, just generate a new guid. + @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to + separate the guid into separate namespaces. + @return {String} the guid + */ - if (statements.length === 0) return EMPTY_PROGRAM; - return new BlockScanner(statements, blocks, symbolTable, env).scan(); + function generateGuid(obj, prefix) { + if (!prefix) { + prefix = GUID_PREFIX; } - var EMPTY_PROGRAM = _glimmerUtil.EMPTY_SLICE; - var BlockScanner = (function () { - function BlockScanner(statements, blocks, symbolTable, env) { - this.blocks = blocks; - this.symbolTable = symbolTable; - this.stack = new _glimmerUtil.Stack(); - this.stack.push(new ChildBlockScanner(symbolTable)); - this.reader = new SyntaxReader(statements, symbolTable, this); - this.env = env; + var ret = prefix + uuid(); + if (obj) { + if (obj[GUID_KEY] === null) { + obj[GUID_KEY] = ret; + } else { + GUID_DESC.value = ret; + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(GUID_KEY_PROPERTY); + } else { + Object.defineProperty(obj, GUID_KEY, GUID_DESC); } + } + } + return ret; + } - BlockScanner.prototype.scan = function scan() { - var statement = undefined; - while (statement = this.reader.next()) { - this.addStatement(statement); - } - return this.stack.current.program; - }; - - BlockScanner.prototype.blockFor = function blockFor(symbolTable, id) { - var block = this.blocks[id]; - var childTable = _glimmerRuntimeLibSymbolTable.default.forBlock(this.symbolTable, block.locals); - var program = buildStatements(block, this.blocks, childTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.InlineBlock(program, childTable, block.locals); - }; - - BlockScanner.prototype.startBlock = function startBlock(locals) { - var childTable = _glimmerRuntimeLibSymbolTable.default.forBlock(this.symbolTable, locals); - this.stack.push(new ChildBlockScanner(childTable)); - }; - - BlockScanner.prototype.endBlock = function endBlock(locals) { - var _stack$pop = this.stack.pop(); - - var program = _stack$pop.program; - var symbolTable = _stack$pop.symbolTable; + /** + Returns a unique id for the object. If the object does not yet have a guid, + one will be assigned to it. You can call this on any object, + `Ember.Object`-based or not, but be aware that it will add a `_guid` + property. + + You can also use this method on DOM Element objects. + + @public + @method guidFor + @for Ember + @param {Object} obj any object, string, number, Element, or primitive + @return {String} the unique guid for this instance. + */ - var block = new _glimmerRuntimeLibCompiledBlocks.InlineBlock(program, symbolTable, locals); - this.addChild(block); - return block; - }; + function guidFor(obj) { + var type = typeof obj; + var isObject = type === 'object' && obj !== null; + var isFunction = type === 'function'; - BlockScanner.prototype.addChild = function addChild(block) { - this.stack.current.addChild(block); - }; + if ((isObject || isFunction) && obj[GUID_KEY]) { + return obj[GUID_KEY]; + } - BlockScanner.prototype.addStatement = function addStatement(statement) { - this.stack.current.addStatement(statement.scan(this)); - }; + // special cases where we don't want to add a key to object + if (obj === undefined) { + return '(undefined)'; + } - BlockScanner.prototype.next = function next() { - return this.reader.next(); - }; + if (obj === null) { + return '(null)'; + } - return BlockScanner; - })(); + var ret = undefined; - exports.BlockScanner = BlockScanner; + // Don't allow prototype changes to String etc. to change the guidFor + switch (type) { + case 'number': + ret = numberCache[obj]; - var ChildBlockScanner = (function () { - function ChildBlockScanner(symbolTable) { - this.symbolTable = symbolTable; - this.children = []; - this.program = new _glimmerUtil.LinkedList(); + if (!ret) { + ret = numberCache[obj] = 'nu' + obj; } - ChildBlockScanner.prototype.addChild = function addChild(block) { - this.children.push(block); - }; - - ChildBlockScanner.prototype.addStatement = function addStatement(statement) { - this.program.append(statement); - }; - - return ChildBlockScanner; - })(); - - var SyntaxReader = (function () { - function SyntaxReader(statements, symbolTable, scanner) { - this.statements = statements; - this.symbolTable = symbolTable; - this.scanner = scanner; - this.current = 0; - this.last = null; - } - - SyntaxReader.prototype.next = function next() { - var last = this.last; - if (last) { - this.last = null; - return last; - } else if (this.current === this.statements.length) { - return null; - } - var sexp = this.statements[this.current++]; - return _glimmerRuntimeLibSyntaxStatements.default(sexp, this.symbolTable, this.scanner); - }; - - return SyntaxReader; - })(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc2Nhbm5lci50cyJdLCJuYW1lcyI6W10sIm1h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AgcmV0dXJuIGJ1aWxkU3RhdGVtZW50KHNleHAsIHRoaXMuc3ltYm9sVGFibGUsIHRoaXMuc2Nhbm5lcik7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/symbol-table', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; + return ret; - var SymbolTable = (function () { - function SymbolTable(parent) { - var meta = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + case 'string': + ret = stringCache[obj]; - this.parent = parent; - this.meta = meta; - this.locals = _glimmerUtil.dict(); - this.named = _glimmerUtil.dict(); - this.yields = _glimmerUtil.dict(); - this.partialArgs = null; - this.size = 1; - this.top = parent ? parent.top : this; + if (!ret) { + ret = stringCache[obj] = 'st' + uuid(); } - SymbolTable.forEntryPoint = function forEntryPoint(meta) { - return new SymbolTable(null, meta).initEntryPoint(); - }; - - SymbolTable.forLayout = function forLayout(named, yields, hasPartials, meta) { - return new SymbolTable(null, meta).initLayout(named, yields, hasPartials); - }; - - SymbolTable.forBlock = function forBlock(parent, locals) { - return new SymbolTable(parent, null).initBlock(locals); - }; - - SymbolTable.prototype.initEntryPoint = function initEntryPoint() { - return this; - }; - - SymbolTable.prototype.initBlock = function initBlock(locals) { - this.initPositionals(locals); - return this; - }; - - SymbolTable.prototype.initLayout = function initLayout(named, yields, hasPartials) { - this.initNamed(named); - this.initYields(yields); - this.initPartials(hasPartials); - return this; - }; - - SymbolTable.prototype.initPositionals = function initPositionals(positionals) { - var _this = this; - - if (positionals) positionals.forEach(function (s) { - return _this.locals[s] = _this.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initNamed = function initNamed(named) { - var _this2 = this; - - if (named) named.forEach(function (s) { - return _this2.named[s] = _this2.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initYields = function initYields(yields) { - var _this3 = this; - - if (yields) yields.forEach(function (b) { - return _this3.yields[b] = _this3.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initPartials = function initPartials(hasPartials) { - if (hasPartials) this.top.partialArgs = this.top.size++; - return this; - }; - - SymbolTable.prototype.getMeta = function getMeta() { - var meta = this.meta; - var parent = this.parent; - - if (!meta && parent) { - meta = parent.getMeta(); - } - return meta; - }; - - SymbolTable.prototype.getYield = function getYield(name) { - var yields = this.yields; - var parent = this.parent; - - var symbol = yields[name]; - if (!symbol && parent) { - symbol = parent.getYield(name); - } - return symbol; - }; - - SymbolTable.prototype.getNamed = function getNamed(name) { - var named = this.named; - var parent = this.parent; + return ret; - var symbol = named[name]; - if (!symbol && parent) { - symbol = parent.getNamed(name); - } - return symbol; - }; + case 'boolean': + return obj ? '(true)' : '(false)'; - SymbolTable.prototype.getLocal = function getLocal(name) { - var locals = this.locals; - var parent = this.parent; + default: + if (obj === Object) { + return '(Object)'; + } - var symbol = locals[name]; - if (!symbol && parent) { - symbol = parent.getLocal(name); - } - return symbol; - }; + if (obj === Array) { + return '(Array)'; + } - SymbolTable.prototype.getPartialArgs = function getPartialArgs() { - return this.top.partialArgs; - }; + ret = GUID_PREFIX + uuid(); - SymbolTable.prototype.isTop = function isTop() { - return this.top === this; - }; + if (obj[GUID_KEY] === null) { + obj[GUID_KEY] = ret; + } else { + GUID_DESC.value = ret; - return SymbolTable; - })(); + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(GUID_KEY_PROPERTY); + } else { + Object.defineProperty(obj, GUID_KEY, GUID_DESC); + } + } + return ret; + } + } +}); +enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string', 'ember-utils/weak-map-utils', 'ember-utils/proxy-utils'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString, _emberUtilsWeakMapUtils, _emberUtilsProxyUtils) { + /* + This package will be eagerly parsed and should have no dependencies on external + packages. + + It is intended to be used to share utility methods that will be needed + by every Ember application (and is **not** a dumping ground of useful utilities). + + Utility methods that are needed in < 80% of cases should be placed + elsewhere (so they can be lazily evaluated / parsed). + */ + 'use strict'; - exports.default = SymbolTable; + exports.symbol = _emberUtilsSymbol.default; + exports.getOwner = _emberUtilsOwner.getOwner; + exports.setOwner = _emberUtilsOwner.setOwner; + exports.OWNER = _emberUtilsOwner.OWNER; + exports.assign = _emberUtilsAssign.default; + exports.EmptyObject = _emberUtilsEmptyObject.default; + exports.dictionary = _emberUtilsDictionary.default; + exports.uuid = _emberUtilsGuid.uuid; + exports.GUID_KEY = _emberUtilsGuid.GUID_KEY; + exports.GUID_DESC = _emberUtilsGuid.GUID_DESC; + exports.GUID_KEY_PROPERTY = _emberUtilsGuid.GUID_KEY_PROPERTY; + exports.generateGuid = _emberUtilsGuid.generateGuid; + exports.guidFor = _emberUtilsGuid.guidFor; + exports.intern = _emberUtilsIntern.default; + exports.checkHasSuper = _emberUtilsSuper.checkHasSuper; + exports.ROOT = _emberUtilsSuper.ROOT; + exports.wrap = _emberUtilsSuper.wrap; + exports.inspect = _emberUtilsInspect.default; + exports.lookupDescriptor = _emberUtilsLookupDescriptor.default; + exports.canInvoke = _emberUtilsInvoke.canInvoke; + exports.tryInvoke = _emberUtilsInvoke.tryInvoke; + exports.makeArray = _emberUtilsMakeArray.default; + exports.applyStr = _emberUtilsApplyStr.default; + exports.NAME_KEY = _emberUtilsName.default; + exports.toString = _emberUtilsToString.default; + exports.HAS_NATIVE_WEAKMAP = _emberUtilsWeakMapUtils.HAS_NATIVE_WEAKMAP; + exports.HAS_NATIVE_PROXY = _emberUtilsProxyUt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tcbiAgICB9XG5cbiAgICByZXR1cm4gc3ltYm9sO1xuICB9XG5cbiAgZ2V0TmFtZWQobmFtZTogc3RyaW5nKTogbnVtYmVyIHtcbiAgICBsZXQgeyBuYW1lZCwgcGFyZW50IH0gPSB0aGlzO1xuXG4gICAgbGV0IHN5bWJvbCA9IG5hbWVkW25hbWVdO1xuXG4gICAgaWYgKCFzeW1ib2wgJiYgcGFyZW50KSB7XG4gICAgICBzeW1ib2wgPSBwYXJlbnQuZ2V0TmFtZWQobmFtZSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHN5bWJvbDtcbiAgfVxuXG4gIGdldExvY2FsKG5hbWU6IHN0cmluZyk6IG51bWJlciB7XG4gICAgbGV0IHsgbG9jYWxzLCBwYXJlbnQgfSA9IHRoaXM7XG5cbiAgICBsZXQgc3ltYm9sID0gbG9jYWxzW25hbWVdO1xuXG4gICAgaWYgKCFzeW1ib2wgJiYgcGFyZW50KSB7XG4gICAgICBzeW1ib2wgPSBwYXJlbnQuZ2V0TG9jYWwobmFtZSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHN5bWJvbDtcbiAgfVxuXG4gIGdldFBhcnRpYWxBcmdzKCk6IG51bWJlciB7XG4gICAgcmV0dXJuIHRoaXMudG9wLnBhcnRpYWxBcmdzO1xuICB9XG5cbiAgaXNUb3AoKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuIHRoaXMudG9wID09PSB0aGlzO1xuICB9XG59XG4iXX0= -enifed("glimmer-runtime/lib/syntax", ["exports"], function (exports) { - "use strict"; +enifed('ember-utils/inspect', ['exports'], function (exports) { + 'use strict'; - exports.isAttribute = isAttribute; + exports.default = inspect; + var objectToString = Object.prototype.toString; - var Statement = (function () { - function Statement() { - this.next = null; - this.prev = null; - } + /** + Convenience method to inspect an object. This method will attempt to + convert the object into a useful string description. + + It is a pretty simple implementation. If you want something more robust, + use something like JSDump: https://github.com/NV/jsDump + + @method inspect + @for Ember + @param {Object} obj The object you want to inspect. + @return {String} A description of the object + @since 1.4.0 + @private + */ - Statement.fromSpec = function fromSpec(spec, symbolTable, scanner) { - throw new Error("You need to implement fromSpec on " + this); - }; + function inspect(obj) { + if (obj === null) { + return 'null'; + } + if (obj === undefined) { + return 'undefined'; + } + if (Array.isArray(obj)) { + return '[' + obj + ']'; + } + // for non objects + var type = typeof obj; + if (type !== 'object' && type !== 'symbol') { + return '' + obj; + } + // overridden toString + if (typeof obj.toString === 'function' && obj.toString !== objectToString) { + return obj.toString(); + } - Statement.prototype.clone = function clone() { - // not type safe but the alternative is extreme boilerplate per - // syntax subclass. - return new this.constructor(this); - }; + // Object.prototype.toString === {}.toString + var v = undefined; + var ret = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + v = obj[key]; + if (v === 'toString') { + continue; + } // ignore useless items + if (typeof v === 'function') { + v = 'function() { ... }'; + } - Statement.prototype.scan = function scan(scanner) { - return this; - }; + if (v && typeof v.toString !== 'function') { + ret.push(key + ': ' + objectToString.call(v)); + } else { + ret.push(key + ': ' + v); + } + } + } + return '{' + ret.join(', ') + '}'; + } +}); +enifed("ember-utils/intern", ["exports"], function (exports) { + /** + Strongly hint runtimes to intern the provided string. + + When do I need to use this function? + + For the most part, never. Pre-mature optimization is bad, and often the + runtime does exactly what you need it to, and more often the trade-off isn't + worth it. + + Why? + + Runtimes store strings in at least 2 different representations: + Ropes and Symbols (interned strings). The Rope provides a memory efficient + data-structure for strings created from concatenation or some other string + manipulation like splitting. + + Unfortunately checking equality of different ropes can be quite costly as + runtimes must resort to clever string comparison algorithms. These + algorithms typically cost in proportion to the length of the string. + Luckily, this is where the Symbols (interned strings) shine. As Symbols are + unique by their string content, equality checks can be done by pointer + comparison. + + How do I know if my string is a rope or symbol? + + Typically (warning general sweeping statement, but truthy in runtimes at + present) static strings created as part of the JS source are interned. + Strings often used for comparisons can be interned at runtime if some + criteria are met. One of these criteria can be the size of the entire rope. + For example, in chrome 38 a rope longer then 12 characters will not + intern, nor will segments of that rope. + + Some numbers: http://jsperf.com/eval-vs-keys/8 + + Known Trick™ + + @private + @return {String} interned version of the provided string + */ + "use strict"; - return Statement; - })(); + exports.default = intern; - exports.Statement = Statement; + function intern(str) { + var obj = {}; + obj[str] = 1; + for (var key in obj) { + if (key === str) { + return key; + } + } + return str; + } +}); +enifed('ember-utils/invoke', ['exports', 'ember-utils/apply-str'], function (exports, _emberUtilsApplyStr) { + 'use strict'; - var Expression = (function () { - function Expression() {} + exports.canInvoke = canInvoke; + exports.tryInvoke = tryInvoke; - Expression.fromSpec = function fromSpec(spec, blocks) { - throw new Error("You need to implement fromSpec on " + this); - }; + /** + Checks to see if the `methodName` exists on the `obj`. + + ```javascript + let foo = { bar: function() { return 'bar'; }, baz: null }; + + Ember.canInvoke(foo, 'bar'); // true + Ember.canInvoke(foo, 'baz'); // false + Ember.canInvoke(foo, 'bat'); // false + ``` + + @method canInvoke + @for Ember + @param {Object} obj The object to check for the method + @param {String} methodName The method name to check for + @return {Boolean} + @private + */ - return Expression; - })(); + function canInvoke(obj, methodName) { + return !!(obj && typeof obj[methodName] === 'function'); + } - exports.Expression = Expression; - var ATTRIBUTE = "e1185d30-7cac-4b12-b26a-35327d905d92"; - exports.ATTRIBUTE = ATTRIBUTE; - var ARGUMENT = "0f3802314-d747-bbc5-0168-97875185c3rt"; - exports.ARGUMENT = ARGUMENT; + /** + Checks to see if the `methodName` exists on the `obj`, + and if it does, invokes it with the arguments passed. + + ```javascript + let d = new Date('03/15/2013'); + + Ember.tryInvoke(d, 'getTime'); // 1363320000000 + Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 + Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined + ``` + + @method tryInvoke + @for Ember + @param {Object} obj The object to check for the method + @param {String} methodName The method name to check for + @param {Array} [args] The arguments to pass to the method + @return {*} the return value of the invoked method or undefined if it cannot be invoked + @public + */ - var Attribute = (function (_Statement) { - babelHelpers.inherits(Attribute, _Statement); + function tryInvoke(obj, methodName, args) { + if (canInvoke(obj, methodName)) { + return args ? _emberUtilsApplyStr.default(obj, methodName, args) : _emberUtilsApplyStr.default(obj, methodName); + } + } +}); +enifed("ember-utils/lookup-descriptor", ["exports"], function (exports) { + "use strict"; - function Attribute() { - _Statement.apply(this, arguments); - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - } + exports.default = lookupDescriptor; - return Attribute; - })(Statement); + function lookupDescriptor(obj, keyName) { + var current = obj; + while (current) { + var descriptor = Object.getOwnPropertyDescriptor(current, keyName); - exports.Attribute = Attribute; + if (descriptor) { + return descriptor; + } - var Argument = (function (_Statement2) { - babelHelpers.inherits(Argument, _Statement2); + current = Object.getPrototypeOf(current); + } - function Argument() { - _Statement2.apply(this, arguments); - this["0f3802314-d747-bbc5-0168-97875185c3rt"] = true; - } + return null; + } +}); +enifed("ember-utils/make-array", ["exports"], function (exports) { + "use strict"; - return Argument; - })(Statement); + exports.default = makeArray; + var isArray = Array.isArray; - exports.Argument = Argument; + /** + Forces the passed object to be part of an array. If the object is already + an array, it will return the object. Otherwise, it will add the object to + an array. If obj is `null` or `undefined`, it will return an empty array. + + ```javascript + Ember.makeArray(); // [] + Ember.makeArray(null); // [] + Ember.makeArray(undefined); // [] + Ember.makeArray('lindsay'); // ['lindsay'] + Ember.makeArray([1, 2, 42]); // [1, 2, 42] + + let controller = Ember.ArrayProxy.create({ content: [] }); + + Ember.makeArray(controller) === controller; // true + ``` + + @method makeArray + @for Ember + @param {Object} obj the object + @return {Array} + @private + */ - function isAttribute(value) { - return value && value[ATTRIBUTE] === true; + function makeArray(obj) { + if (obj === null || obj === undefined) { + return []; } + return isArray(obj) ? obj : [obj]; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O1FBbUJBLFNBQUE7QUFBQSxpQkFBQSxTQUFBLEdBQUE7QUFNUyxnQkFBQ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ic3RyYWN0IHZhbHVlU3ludGF4KCk6IEV4cHJlc3Npb248VD47XG59XG5cbmV4cG9ydCBhYnN0cmFjdCBjbGFzcyBBcmd1bWVudDxUPiBleHRlbmRzIFN0YXRlbWVudCB7XG4gIFwiMGYzODAyMzE0LWQ3NDctYmJjNS0wMTY4LTk3ODc1MTg1YzNydFwiID0gdHJ1ZTtcbiAgbmFtZTogc3RyaW5nO1xuICBuYW1lc3BhY2U6IHN0cmluZztcbiAgYWJzdHJhY3QgdmFsdWVTeW50YXgoKTogRXhwcmVzc2lvbjxUPjtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGlzQXR0cmlidXRlKHZhbHVlOiBTdGF0ZW1lbnQpOiB2YWx1ZSBpcyBBdHRyaWJ1dGU8YW55PiB7XG4gIHJldHVybiB2YWx1ZSAmJiB2YWx1ZVtBVFRSSUJVVEVdID09PSB0cnVlO1xufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/each', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var EachSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(EachSyntax, _StatementSyntax); - - function EachSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "each-statement"; - } - - EachSyntax.prototype.compile = function compile(dsl, env) { - // Enter(BEGIN, END) - // BEGIN: Noop - // PutArgs - // PutIterable - // JumpUnless(ELSE) - // EnterList(BEGIN2, END2) - // ITER: Noop - // NextIter(BREAK) - // EnterWithKey(BEGIN2, END2) - // BEGIN2: Noop - // PushChildScope - // Evaluate(default) - // PopScope - // END2: Noop - // Exit - // Jump(ITER) - // BREAK: Noop - // ExitList - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.block(args, function (dsl, BEGIN, END) { - dsl.putIterator(); - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - } else { - dsl.jumpUnless(END); - } - dsl.iter(function (dsl, BEGIN, END) { - dsl.evaluate('default', blocks.default); - }); - if (blocks.inverse) { - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } - }); - }; - - return EachSyntax; - })(_glimmerRuntimeLibSyntax.Statement); +enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { + 'use strict'; - exports.default = EachSyntax; + exports.default = _emberUtilsSymbol.default('NAME_KEY'); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL2VhY2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBVUEsVUFBQTs4QkFBQSxVQUFBOztBQUdFLGlCQUhGLFVBQUEsQ0FHcUIsSUFBaUIsRUFBQTtBQUNsQyx1Q0FBTyxDQUFDO0FBRFMsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFhO0FBRnBDLGdCQUFBLENBQUEsSUFBSSxHQUFHLGdCQUFnQixDQUFDO1NBSXZCOztBQUxILGtCQUFBLFdBT0UsT0FBTyxHQUFBLGlCQUFDLEdBQXFCLEVBQUUsR0FBZ0IsRUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O2dCQXlCdkMsSUFBSSxHQUF1QixJQUFJLENBQS9CLElBQUk7Z0JBQVUsTUFBTSxHQUFPLElBQUksQ0FBekIsSUFBSSxDQUFJLE1BQU07O0FBRTFCLGVBQUcsQ0FBQyxLQUFLLENBQUMsSUFBSSxFQUFFLFVBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxHQUFHLEVBQUE7QUFDOUIsbUJBQUcsQ0FBQyxXQUFXLEVBQUUsQ0FBQztBQUVsQixvQkFBSSxNQUFNLENBQUMsT0FBTyxFQUFFO0FBQ2xCLHVCQUFHLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFDO2l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0b3IocHVibGljIGFyZ3M6IFN5bnRheC5BcmdzKSB7XG4gICAgc3VwZXIoKTtcbiAgfVxuXG4gIGNvbXBpbGUoZHNsOiBPcGNvZGVCdWlsZGVyRFNMLCBlbnY6IEVudmlyb25tZW50KSB7XG4gICAgLy8gICAgICAgICBFbnRlcihCRUdJTiwgRU5EKVxuICAgIC8vIEJFR0lOOiAgTm9vcFxuICAgIC8vICAgICAgICAgUHV0QXJnc1xuICAgIC8vICAgICAgICAgUHV0SXRlcmFibGVcbiAgICAvLyAgICAgICAgIEp1bXBVbmxlc3MoRUxTRSlcbiAgICAvLyAgICAgICAgIEVudGVyTGlzdChCRUdJTjIsIEVORDIpXG4gICAgLy8gSVRFUjogICBOb29wXG4gICAgLy8gICAgICAgICBOZXh0SXRlcihCUkVBSylcbiAgICAvLyAgICAgICAgIEVudGVyV2l0aEtleShCRUdJTjIsIEVORDIpXG4gICAgLy8gQkVHSU4yOiBOb29wXG4gICAgLy8gICAgICAgICBQdXNoQ2hpbGRTY29wZVxuICAgIC8vICAgICAgICAgRXZhbHVhdGUoZGVmYXVsdClcbiAgICAvLyAgICAgICAgIFBvcFNjb3BlXG4gICAgLy8gRU5EMjogICBOb29wXG4gICAgLy8gICAgICAgICBFeGl0XG4gICAgLy8gICAgICAgICBKdW1wKElURVIpXG4gICAgLy8gQlJFQUs6ICBOb29wXG4gICAgLy8gICAgICAgICBFeGl0TGlzdFxuICAgIC8vICAgICAgICAgSnVtcChFTkQpXG4gICAgLy8gRUxTRTogICBOb29wXG4gICAgLy8gICAgICAgICBFdmFsdWxhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgIE5vb3BcbiAgICAvLyAgICAgICAgIEV4aXRcblxuICAgIGxldCB7IGFyZ3MsIGFyZ3M6IHsgYmxvY2tzIH0gfSA9IHRoaXM7XG5cbiAgICBkc2wuYmxvY2soYXJncywgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgZHNsLnB1dEl0ZXJhdG9yKCk7XG5cbiAgICAgIGlmIChibG9ja3MuaW52ZXJzZSkge1xuICAgICAgICBkc2wuanVtcFVubGVzcygnRUxTRScpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgZHNsLmp1bXBVbmxlc3MoRU5EKTtcbiAgICAgIH1cblxuICAgICAgZHNsLml0ZXIoKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgICBkc2wuZXZhbHVhdGUoJ2RlZmF1bHQnLCBibG9ja3MuZGVmYXVsdCk7XG4gICAgICB9KTtcblxuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wKEVORCk7XG4gICAgICAgIGRzbC5sYWJlbCgnRUxTRScpO1xuICAgICAgICBkc2wuZXZhbHVhdGUoJ2ludmVyc2UnLCBibG9ja3MuaW52ZXJzZSk7XG4gICAgICB9XG4gICAgfSk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/syntax/builtins/if', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var IfSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(IfSyntax, _StatementSyntax); - - function IfSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "if-statement"; - } - - IfSyntax.prototype.compile = function compile(dsl) { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl, BEGIN, END) { - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpUnless(END); - dsl.evaluate('default', blocks.default); - } - }); - }; - - return IfSyntax; - })(_glimmerRuntimeLibSyntax.Statement); +enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { + /** + @module ember + @submodule ember-runtime + */ - exports.default = IfSyntax; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL2lmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLFFBQUE7OEJBQUEsUUFBQTs7QUFHRSxpQkFIRixRQUFBLENBR3FCLElBQWlCLEVBQUE7QUFDbEMsdUNBQU8sQ0FBQztBQURTLGdCQUFBLENBQUEsSUFBSSxHQUFKLElBQUksQ0FBYTtBQUZwQyxnQkFBQSxDQUFBLElBQUksR0FBRyxjQUFjLENBQUM7U0FJckI7O0FBTEgsZ0JBQUEsV0FPRSxPQUFPLEdBQUEsaUJBQUMsR0FBcUIsRUFBQTs7Ozs7Ozs7Ozs7O2dCQWFyQixJQUFJLEdBQXVCLElBQUksQ0FBL0IsSUFBSTtnQkFBVSxNQUFNLEdBQU8sSUFBSSxDQUF6QixJQUFJLENBQUksTUFBTTs7QUFFMUIsZUFBRyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUNsQixlQUFHLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxDQUFDO0FBRXhCLGVBQUcsQ0FBQyxLQUFLLENBQUMsSUFBSSxFQUFFLFVBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxHQUFHLEVBQUE7QUFDOUIsb0JBQUksTUFBTSxDQUFDLE9BQU8sRUFBRTtBQUNsQix1QkFBRyxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUN2Qix1QkFBRyxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUUsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQ3hDLHVCQUFHLENBQUMsSUFBSSxDQUFDL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gICAgICAgSnVtcFVubGVzcyhFTFNFKVxuICAgIC8vICAgICAgICBFdmFsdWF0ZShkZWZhdWx0KVxuICAgIC8vICAgICAgICBKdW1wKEVORClcbiAgICAvLyBFTFNFOiAgTm9vcFxuICAgIC8vICAgICAgICBFdmFsdWxhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgTm9vcFxuICAgIC8vICAgICAgICBFeGl0XG5cbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoRU5EKTtcbiAgICAgICAgZHNsLmxhYmVsKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnaW52ZXJzZScsIGJsb2Nrcy5pbnZlcnNlKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/in-element', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; + 'use strict'; - var InElementSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(InElementSyntax, _StatementSyntax); + exports.getOwner = getOwner; + exports.setOwner = setOwner; + var OWNER = _emberUtilsSymbol.default('OWNER'); - function InElementSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "in-element-statement"; - } + exports.OWNER = OWNER; + /** + Framework objects in an Ember application (components, services, routes, etc.) + are created via a factory and dependency injection system. Each of these + objects is the responsibility of an "owner", which handled its + instantiation and manages its lifetime. + + `getOwner` fetches the owner object responsible for an instance. This can + be used to lookup or resolve other class instances, or register new factories + into the owner. + + For example, this component dynamically looks up a service based on the + `audioType` passed as an attribute: + + ``` + // app/components/play-audio.js + import Ember from 'ember'; + + // Usage: + // + // {{play-audio audioType=model.audioType audioFile=model.file}} + // + export default Ember.Component.extend({ + audioService: Ember.computed('audioType', function() { + let owner = Ember.getOwner(this); + return owner.lookup(`service:${this.get('audioType')}`); + }), + click() { + let player = this.get('audioService'); + player.play(this.get('audioFile')); + } + }); + ``` + + @method getOwner + @for Ember + @param {Object} object An object with an owner. + @return {Object} An owner object. + @since 2.3.0 + @public + */ - InElementSyntax.prototype.compile = function compile(dsl, env) { - var args = this.args; - var blocks = this.args.blocks; + function getOwner(object) { + return object[OWNER]; + } - dsl.putArgs(args); - dsl.test('simple'); - dsl.block(null, function (dsl, BEGIN, END) { - dsl.jumpUnless(END); - dsl.pushRemoteElement(); - dsl.evaluate('default', blocks.default); - dsl.popRemoteElement(); - }); - }; + /** + `setOwner` forces a new owner on a given object instance. This is primarily + useful in some testing cases. + + @method setOwner + @for Ember + @param {Object} object An object instance. + @param {Object} object The new owner object of the object instance. + @since 2.3.0 + @public + */ - return InElementSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + function setOwner(object, owner) { + object[OWNER] = owner; + } +}); +enifed('ember-utils/proxy-utils', ['exports'], function (exports) { + 'use strict'; - exports.default = InElementSyntax; + var HAS_NATIVE_PROXY = typeof Proxy === 'function'; + exports.HAS_NATIVE_PROXY = HAS_NATIVE_PROXY; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZ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dGF0ZW1lbnQgYXMgU3RhdGVtZW50U3ludGF4XG59IGZyb20gJy4uLy4uL3N5bnRheCc7XG5cbmltcG9ydCBPcGNvZGVCdWlsZGVyRFNMIGZyb20gJy4uLy4uL2NvbXBpbGVkL29wY29kZXMvYnVpbGRlcic7XG5pbXBvcnQgKiBhcyBTeW50YXggZnJvbSAnLi4vY29yZSc7XG5pbXBvcnQgRW52aXJvbm1lbnQgZnJvbSAnLi4vLi4vZW52aXJvbm1lbnQnO1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBJbkVsZW1lbnRTeW50YXggZXh0ZW5kcyBTdGF0ZW1lbnRTeW50YXgge1xuICB0eXBlID0gXCJpbi1lbGVtZW50LXN0YXRlbWVudFwiO1xuXG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgYXJnczogU3ludGF4LkFyZ3MpIHtcbiAgICBzdXBlcigpO1xuICB9XG5cbiAgY29tcGlsZShkc2w6IE9wY29kZUJ1aWxkZXJEU0wsIGVudjogRW52aXJvbm1lbnQpIHtcbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ3NpbXBsZScpO1xuXG4gICAgZHNsLmJsb2NrKG51bGwsIChkc2wsIEJFR0lOLCBFTkQpID0+IHtcbiAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICBkc2wucHVzaFJlbW90ZUVsZW1lbnQoKTtcbiAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIGRzbC5wb3BSZW1vdGVFbGVtZW50KCk7XG4gICAgfSk7XG4gIH1cbn1cbiJdfQ== -enifed("glimmer-runtime/lib/syntax/builtins/partial", ["exports", "glimmer-runtime/lib/syntax"], function (exports, _glimmerRuntimeLibSyntax) { - "use strict"; +enifed('ember-utils/super', ['exports'], function (exports) { + 'use strict'; - var StaticPartialSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(StaticPartialSyntax, _StatementSyntax); + exports.wrap = wrap; + var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/; + var fnToString = Function.prototype.toString; - function StaticPartialSyntax(name) { - _StatementSyntax.call(this); - this.name = name; - this.type = "static-partial"; - } + var checkHasSuper = (function () { + var sourceAvailable = fnToString.call(function () { + return this; + }).indexOf('return this') > -1; - StaticPartialSyntax.prototype.compile = function compile(dsl, env, symbolTable) { - var name = String(this.name.inner()); - if (!env.hasPartial(name, symbolTable)) { - throw new Error("Compile Error: " + name + " is not a partial"); - } - var definition = env.lookupPartial(name, symbolTable); - dsl.putPartialDefinition(definition); - dsl.evaluatePartial(); - }; + if (sourceAvailable) { + return function checkHasSuper(func) { + return HAS_SUPER_PATTERN.test(fnToString.call(func)); + }; + } - return StaticPartialSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + return function checkHasSuper() { + return true; + }; + })(); - exports.StaticPartialSyntax = StaticPartialSyntax; + exports.checkHasSuper = checkHasSuper; + function ROOT() {} + ROOT.__hasSuper = false; - var DynamicPartialSyntax = (function (_StatementSyntax2) { - babelHelpers.inherits(DynamicPartialSyntax, _StatementSyntax2); + function hasSuper(func) { + if (func.__hasSuper === undefined) { + func.__hasSuper = checkHasSuper(func); + } + return func.__hasSuper; + } - function DynamicPartialSyntax(name) { - _StatementSyntax2.call(this); - this.name = name; - this.type = "dynamic-partial"; - } + /** + Wraps the passed function so that `this._super` will point to the superFunc + when the function is invoked. This is the primitive we use to implement + calls to super. + + @private + @method wrap + @for Ember + @param {Function} func The function to call + @param {Function} superFunc The super function. + @return {Function} wrapped function. + */ - DynamicPartialSyntax.prototype.compile = function compile(dsl) { - var name = this.name; + function wrap(func, superFunc) { + if (!hasSuper(func)) { + return func; + } + // ensure an unwrapped super that calls _super is wrapped with a terminal _super + if (!superFunc.wrappedFunction && hasSuper(superFunc)) { + return _wrap(func, _wrap(superFunc, ROOT)); + } + return _wrap(func, superFunc); + } - dsl.startLabels(); - dsl.putValue(name); - dsl.test('simple'); - dsl.enter('BEGIN', 'END'); - dsl.label('BEGIN'); - dsl.jumpUnless('END'); - dsl.putDynamicPartialDefinition(); - dsl.evaluatePartial(); - dsl.label('END'); - dsl.exit(); - dsl.stopLabels(); - }; + function _wrap(func, superFunc) { + function superWrapper() { + var orig = this._super; + this._super = superFunc; + var ret = func.apply(this, arguments); + this._super = orig; + return ret; + } - return DynamicPartialSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + superWrapper.wrappedFunction = func; + superWrapper.__ember_observes__ = func.__ember_observes__; + superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__; + superWrapper.__ember_listens__ = func.__ember_listens__; - exports.DynamicPartialSyntax = DynamicPartialSyntax; + return superWrapper; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3BhcnRpYWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBY0EsbUJBQUE7OEJBQUEsbUJBQUE7O0FBR0UsaUJBSEYsbUJBQUEsQ0FHc0IsSUFBdUIsRUFBQTtBQUN6Qyx1Q0FBTyxDQUFDO0FBRFUsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFtQjtBQUZwQyxnQkFBQSxDQUFBLElBQUksR0FBRyxnQkFBZ0IsQ0FBQztTQUk5Qjs7QUFMSCwyQkFBQSxXQU9FLE9BQU8sR0FBQSxpQkFBQyxHQUFxQixFQUFFLEdBQWdCLEVBQUUsV0FBd0IsRUFBQTtBQUN2RSxnQkFBSSxJQUFJLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQztBQUVyQyxnQkFBSSxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsSUFBSS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k7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/syntax/builtins/unless', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var UnlessSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(UnlessSyntax, _StatementSyntax); - - function UnlessSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "unless-statement"; - } - - UnlessSyntax.prototype.compile = function compile(dsl, env) { - // PutArgs - // Enter(BEGIN, END) - // BEGIN: Noop - // Test(Environment) - // JumpIf(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl) { - if (blocks.inverse) { - dsl.jumpIf('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump('END'); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpIf('END'); - dsl.evaluate('default', blocks.default); - } - }); - }; +enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern'], function (exports, _emberUtilsGuid, _emberUtilsIntern) { + 'use strict'; - return UnlessSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + exports.default = symbol; - exports.default = UnlessSyntax; + function symbol(debugName) { + // TODO: Investigate using platform symbols, but we do not + // want to require non-enumerability for this API, which + // would introduce a large cost. + var id = _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()); + return _emberUtilsIntern.default('__' + debugName + '__ [id=' + id + ']'); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3VubGVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFVQSxZQUFBOzhCQUFBLFlBQUE7O0FBR0UsaUJBSEYsWUFBQSxDQUdx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5cbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgZHNsID0+IHtcbiAgICAgIGlmIChibG9ja3MuaW52ZXJzZSkge1xuICAgICAgICBkc2wuanVtcElmKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoJ0VORCcpO1xuICAgICAgICBkc2wubGFiZWwoJ0VMU0UnKTtcbiAgICAgICAgZHNsLmV2YWx1YXRlKCdpbnZlcnNlJywgYmxvY2tzLmludmVyc2UpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgZHNsLmp1bXBJZignRU5EJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/with-dynamic-vars', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var WithDynamicVarsSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(WithDynamicVarsSyntax, _StatementSyntax); - - function WithDynamicVarsSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "with-dynamic-vars-statement"; - } - - WithDynamicVarsSyntax.prototype.compile = function compile(dsl, env) { - var args = this.args; - var blocks = this.args.blocks; +enifed('ember-utils/to-string', ['exports'], function (exports) { + 'use strict'; - dsl.unit(function (dsl) { - dsl.putArgs(args); - dsl.pushDynamicScope(); - dsl.bindDynamicScope(args.named.keys); - dsl.evaluate('default', blocks.default); - dsl.popDynamicScope(); - }); - }; + exports.default = toString; + var objectToString = Object.prototype.toString; - return WithDynamicVarsSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + /* + A `toString` util function that supports objects without a `toString` + method, e.g. an object created with `Object.create(null)`. + */ - exports.default = WithDynamicVarsSyntax; + function toString(obj) { + if (obj && typeof obj.toString === 'function') { + return obj.toString(); + } else { + return objectToString.call(obj); + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3dpdGgtZHluYW1pYy12YXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLHFCQUFBOzhCQUFBLHFCQUFBOztBQUdFLGlCQUhGLHFCQUFBLENBR3NCLElBQWlCLEVBQUE7QUFDbkMsdUNBQU8sQ0FBQztBQURVLGdCQUFBLENBQUEsSUFBSSxHQUFKLElBQUksQ0FBYTtBQUZyQyxnQkFBQSxDQUFBLElBQUksR0FBRyw2QkFBNkIsQ0FBQztTQUlwQzs7QUFMSCw2QkFBQSxXQU9FLE9BQU8sR0FBQSxpQkFBQyxHQUFxQixFQUFFLEdBQWdCLEVBQUE7Z0JBQ3ZDLElBQUksR0FBdUIsSUFBSSxDQUEvQixJQUFJO2dCQUFVLE1BQU0sR0FBTyxJQUFJLENBQXpCLElBQUksQ0FBSSxNQUFNOztBQUUxQixlQUFHLENBQUMsSUFBSSxDQUFDLFVBQUEsR0FBRyxFQUFBO0FBQ1YsbUJBQUcsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7QUFDbEIsbUJBQUcsQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDO0FBQ3ZCLG1CQUFHLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUN0QyxtQkFBRyxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUUsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFD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zbC5wb3BEeW5hbWljU2NvcGUoKTtcbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/with', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var WithSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(WithSyntax, _StatementSyntax); - - function WithSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "with-statement"; - } - - WithSyntax.prototype.compile = function compile(dsl, env) { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evaluate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl, BEGIN, END) { - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpUnless(END); - dsl.evaluate('default', blocks.default); - } - }); - }; +enifed('ember-utils/weak-map-utils', ['exports'], function (exports) { + 'use strict'; - return WithSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + var HAS_NATIVE_WEAKMAP = (function () { + // detect if `WeakMap` is even present + var hasWeakMap = typeof WeakMap === 'function'; + if (!hasWeakMap) { + return false; + } - exports.default = WithSyntax; + var instance = new WeakMap(); + // use `Object`'s `.toString` directly to prevent us from detecting + // polyfills as native weakmaps + return Object.prototype.toString.call(instance) === '[object WeakMap]'; + })(); + exports.HAS_NATIVE_WEAKMAP = HAS_NATIVE_WEAKMAP; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3dpdGgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBU0EsVUFBQ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yAgICAgICAgRXZhbHVhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgTm9vcFxuICAgIC8vICAgICAgICBFeGl0XG5cbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoRU5EKTtcbiAgICAgICAgZHNsLmxhYmVsKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnaW52ZXJzZScsIGJsb2Nrcy5pbnZlcnNlKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/core', ['exports', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/syntax/builtins/partial', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-runtime/lib/compiled/opcodes/component', 'glimmer-runtime/lib/compiled/opcodes/dom', 'glimmer-runtime/lib/syntax/expressions', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/compiled/expressions/value', 'glimmer-runtime/lib/compiled/expressions/lookups', 'glimmer-runtime/lib/compiled/expressions/has-block', 'glimmer-runtime/lib/compiled/expressions/helper', 'glimmer-runtime/lib/compiled/expressions/concat', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/compiled/opcodes/content'], function (exports, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibSyntaxBuiltinsPartial, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerRuntimeLibCompiledOpcodesComponent, _glimmerRuntimeLibCompiledOpcodesDom, _glimmerRuntimeLibSyntaxExpressions, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibCompiledExpressionsValue, _glimmerRuntimeLibCompiledExpressionsLookups, _glimmerRuntimeLibCompiledExpressionsHasBlock, _glimmerRuntimeLibCompiledExpressionsHelper, _glimmerRuntimeLibCompiledExpressionsConcat, _glimmerRuntimeLibUtils, _glimmerRuntimeLibCompiledOpcodesContent) { - 'use strict'; - - var Block = (function (_StatementSyntax) { - babelHelpers.inherits(Block, _StatementSyntax); - - function Block(path, args) { - _StatementSyntax.call(this); - this.path = path; - this.args = args; - this.type = "block"; - } - - Block.fromSpec = function fromSpec(sexp, symbolTable, scanner) { - var path = sexp[1]; - var params = sexp[2]; - var hash = sexp[3]; - var templateId = sexp[4]; - var inverseId = sexp[5]; +enifed('ember-views/compat/attrs', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; - var template = scanner.blockFor(symbolTable, templateId); - var inverse = typeof inverseId === 'number' ? scanner.blockFor(symbolTable, inverseId) : null; - var blocks = Blocks.fromSpec(template, inverse); - return new Block(path, Args.fromSpec(params, hash, blocks)); - }; + var MUTABLE_CELL = _emberUtils.symbol('MUTABLE_CELL'); + exports.MUTABLE_CELL = MUTABLE_CELL; +}); +enifed('ember-views/compat/fallback-view-registry', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; - Block.build = function build(path, args) { - return new this(path, args); - }; + exports.default = _emberUtils.dictionary(null); +}); +enifed('ember-views/component_lookup', ['exports', 'ember-metal', 'ember-runtime', 'container'], function (exports, _emberMetal, _emberRuntime, _container) { + 'use strict'; - Block.prototype.scan = function scan(scanner) { - var _args$blocks = this.args.blocks; - var _default = _args$blocks.default; - var inverse = _args$blocks.inverse; + exports.default = _emberRuntime.Object.extend({ + componentFor: function (name, owner, options) { + _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); + var fullName = 'component:' + name; + return owner[_container.FACTORY_FOR](fullName, options); + }, - if (_default) scanner.addChild(_default); - if (inverse) scanner.addChild(inverse); - return this; - }; + layoutFor: function (name, owner, options) { + _emberMetal.assert('You cannot use \'' + name + '\' as a component name. Component names must contain a hyphen.', ~name.indexOf('-')); - Block.prototype.compile = function compile(ops) { - throw new Error("SyntaxError"); - }; + var templateFullName = 'template:components/' + name; + return owner.lookup(templateFullName, options); + } + }); +}); +enifed('ember-views/index', ['exports', 'ember-views/system/ext', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/system/event_dispatcher', 'ember-views/component_lookup', 'ember-views/mixins/text_support', 'ember-views/views/core_view', 'ember-views/mixins/class_names_support', 'ember-views/mixins/child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/view_support', 'ember-views/mixins/action_support', 'ember-views/compat/attrs', 'ember-views/system/lookup_partial', 'ember-views/utils/lookup-component', 'ember-views/system/action_manager', 'ember-views/compat/fallback-view-registry'], function (exports, _emberViewsSystemExt, _emberViewsSystemJquery, _emberViewsSystemUtils, _emberViewsSystemEvent_dispatcher, _emberViewsComponent_lookup, _emberViewsMixinsText_support, _emberViewsViewsCore_view, _emberViewsMixinsClass_names_support, _emberViewsMixinsChild_views_support, _emberViewsMixinsView_state_support, _emberViewsMixinsView_support, _emberViewsMixinsAction_support, _emberViewsCompatAttrs, _emberViewsSystemLookup_partial, _emberViewsUtilsLookupComponent, _emberViewsSystemAction_manager, _emberViewsCompatFallbackViewRegistry) { + /** + @module ember + @submodule ember-views + */ - return Block; - })(_glimmerRuntimeLibSyntax.Statement); + 'use strict'; - exports.Block = Block; + exports.jQuery = _emberViewsSystemJquery.default; + exports.isSimpleClick = _emberViewsSystemUtils.isSimpleClick; + exports.getViewBounds = _emberViewsSystemUtils.getViewBounds; + exports.getViewClientRects = _emberViewsSystemUtils.getViewClientRects; + exports.getViewBoundingClientRect = _emberViewsSystemUtils.getViewBoundingClientRect; + exports.getRootViews = _emberViewsSystemUtils.getRootViews; + exports.getChildViews = _emberViewsSystemUtils.getChildViews; + exports.getViewId = _emberViewsSystemUtils.getViewId; + exports.getViewElement = _emberViewsSystemUtils.getViewElement; + exports.setViewElement = _emberViewsSystemUtils.setViewElement; + exports.STYLE_WARNING = _emberViewsSystemUtils.STYLE_WARNING; + exports.EventDispatcher = _emberViewsSystemEvent_dispatcher.default; + exports.ComponentLookup = _emberViewsComponent_lookup.default; + exports.TextSupport = _emberViewsMixinsText_support.default; + exports.CoreView = _emberViewsViewsCore_view.default; + exports.ClassNamesSupport = _emberViewsMixinsClass_names_support.default; + exports.ChildViewsSupport = _emberViewsMixinsChild_views_support.default; + exports.ViewStateSupport = _emberViewsMixinsView_state_support.default; + exports.ViewMixin = _emberViewsMixinsView_support.default; + exports.dispatchLifeCycleHook = _emberViewsMixinsView_support.dispatchLifeCycleHook; + exports.ActionSupport = _emberViewsMixinsAction_support.default; + exports.MUTABLE_CELL = _emberViewsCompatAttrs.MUTABLE_CELL; + exports.lookupPartial = _emberViewsSystemLookup_partial.default; + exports.hasPartial = _emberViewsSystemLookup_partial.hasPartial; + exports.lookupComponent = _emberViewsUtilsLookupComponent.default; + exports.ActionManager = _emberViewsSystemAction_manager.default; + exports.fallbackViewRegistry = _emberViewsCompatFallbackViewRegistry.default; +}); +// for the side effect of extending Ember.run.queues +enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/compat/attrs'], function (exports, _emberUtils, _emberMetal, _emberViewsCompatAttrs) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - var Append = (function (_StatementSyntax2) { - babelHelpers.inherits(Append, _StatementSyntax2); + function validateAction(component, actionName) { + if (actionName && actionName[_emberViewsCompatAttrs.MUTABLE_CELL]) { + actionName = actionName.value; + } - function Append(_ref) { - var value = _ref.value; - var trustingMorph = _ref.trustingMorph; + _emberMetal.assert('The default action was triggered on the component ' + component.toString() + ', but the action name (' + actionName + ') was not a string.', _emberMetal.isNone(actionName) || typeof actionName === 'string' || typeof actionName === 'function'); + return actionName; + } - _StatementSyntax2.call(this); - this.value = value; - this.trustingMorph = trustingMorph; + /** + @class ActionSupport + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create({ + /** + Calls an action passed to a component. + For example a component for playing or pausing music may translate click events + into action notifications of "play" or "stop" depending on some internal state + of the component: + ```javascript + // app/components/play-button.js + export default Ember.Component.extend({ + click() { + if (this.get('isPlaying')) { + this.sendAction('play'); + } else { + this.sendAction('stop'); + } } - - Append.fromSpec = function fromSpec(sexp) { - var value = sexp[1]; - var trustingMorph = sexp[2]; - - return new OptimizedAppend({ value: _glimmerRuntimeLibSyntaxExpressions.default(value), trustingMorph: trustingMorph }); - }; - - return Append; - })(_glimmerRuntimeLibSyntax.Statement); - - exports.Append = Append; - - var OptimizedAppend = (function (_Append) { - babelHelpers.inherits(OptimizedAppend, _Append); - - function OptimizedAppend() { - _Append.apply(this, arguments); - this.type = "optimized-append"; + }); + ``` + The actions "play" and "stop" must be passed to this `play-button` component: + ```handlebars + {{! app/templates/application.hbs }} + {{play-button play=(action "musicStarted") stop=(action "musicStopped")}} + ``` + When the component receives a browser `click` event it translate this + interaction into application-specific semantics ("play" or "stop") and + calls the specified action. + ```javascript + // app/controller/application.js + export default Ember.Controller.extend({ + actions: { + musicStarted() { + // called when the play button is clicked + // and the music started playing + }, + musicStopped() { + // called when the play button is clicked + // and the music stopped playing + } + } + }); + ``` + If no action is passed to `sendAction` a default name of "action" + is assumed. + ```javascript + // app/components/next-button.js + export default Ember.Component.extend({ + click() { + this.sendAction(); + } + }); + ``` + ```handlebars + {{! app/templates/application.hbs }} + {{next-button action=(action "playNextSongInAlbum")}} + ``` + ```javascript + // app/controllers/application.js + App.ApplicationController = Ember.Controller.extend({ + actions: { + playNextSongInAlbum() { + ... + } } + }); + ``` + @method sendAction + @param [action] {String} the action to call + @param [params] {*} arguments for the action + @public + */ + sendAction: function (action) { + for (var _len = arguments.length, contexts = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + contexts[_key - 1] = arguments[_key]; + } - OptimizedAppend.prototype.deopt = function deopt() { - return new UnoptimizedAppend(this); - }; + var actionName = undefined; - OptimizedAppend.prototype.compile = function compile(compiler, env, symbolTable) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(this.value.compile(compiler, env, symbolTable))); - if (this.trustingMorph) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedTrustingAppendOpcode()); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedCautiousAppendOpcode()); - } - }; + // Send the default action + if (action === undefined) { + action = 'action'; + } + actionName = _emberMetal.get(this, 'attrs.' + action) || _emberMetal.get(this, action); + actionName = validateAction(this, actionName); + + // If no action name for that action could be found, just abort. + if (actionName === undefined) { + return; + } - return OptimizedAppend; - })(Append); + if (typeof actionName === 'function') { + actionName.apply(undefined, contexts); + } else { + this.triggerAction({ + action: actionName, + actionContext: contexts + }); + } + }, - exports.OptimizedAppend = OptimizedAppend; + send: function (actionName) { + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } - var UnoptimizedAppend = (function (_Append2) { - babelHelpers.inherits(UnoptimizedAppend, _Append2); + var action = this.actions && this.actions[actionName]; - function UnoptimizedAppend() { - _Append2.apply(this, arguments); - this.type = "unoptimized-append"; + if (action) { + var shouldBubble = action.apply(this, args) === true; + if (!shouldBubble) { + return; } + } - UnoptimizedAppend.prototype.compile = function compile(compiler, env, symbolTable) { - var expression = this.value.compile(compiler, env, symbolTable); - if (this.trustingMorph) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.GuardedTrustingAppendOpcode(expression, symbolTable)); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.GuardedCautiousAppendOpcode(expression, symbolTable)); - } - }; + var target = _emberMetal.get(this, 'target'); + if (target) { + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); + target.send.apply(target, arguments); + } else { + _emberMetal.assert(_emberUtils.inspect(this) + ' had no action handler for: ' + actionName, action); + } + } + }); +}); +enifed('ember-views/mixins/child_views_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/system/utils'], function (exports, _emberUtils, _emberMetal, _emberViewsSystemUtils) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; + + exports.default = _emberMetal.Mixin.create({ + init: function () { + this._super.apply(this, arguments); + _emberViewsSystemUtils.initChildViews(this); + }, - return UnoptimizedAppend; - })(Append); + /** + Array of child views. You should never edit this array directly. + @property childViews + @type Array + @default [] + @private + */ + childViews: _emberMetal.descriptor({ + configurable: false, + enumerable: false, + get: function () { + return _emberViewsSystemUtils.getChildViews(this); + } + }), - exports.UnoptimizedAppend = UnoptimizedAppend; + appendChild: function (view) { + this.linkChild(view); + _emberViewsSystemUtils.addChildView(this, view); + }, - var MODIFIER_SYNTAX = "c0420397-8ff1-4241-882b-4b7a107c9632"; + linkChild: function (instance) { + if (!_emberUtils.getOwner(instance)) { + _emberUtils.setOwner(instance, _emberUtils.getOwner(this)); + } + } + }); +}); +enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ - var Modifier = (function (_StatementSyntax3) { - babelHelpers.inherits(Modifier, _StatementSyntax3); + 'use strict'; - function Modifier(options) { - _StatementSyntax3.call(this); - this["c0420397-8ff1-4241-882b-4b7a107c9632"] = true; - this.type = "modifier"; - this.path = options.path; - this.args = options.args; - } + var EMPTY_ARRAY = Object.freeze([]); - Modifier.fromSpec = function fromSpec(node) { - var path = node[1]; - var params = node[2]; - var hash = node[3]; + /** + @class ClassNamesSupport + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create({ + concatenatedProperties: ['classNames', 'classNameBindings'], - return new Modifier({ - path: path, - args: Args.fromSpec(params, hash, EMPTY_BLOCKS) - }); - }; + init: function () { + this._super.apply(this, arguments); - Modifier.build = function build(path, options) { - return new Modifier({ - path: path, - params: options.params, - hash: options.hash - }); - }; + _emberMetal.assert('Only arrays are allowed for \'classNameBindings\'', Array.isArray(this.classNameBindings)); + _emberMetal.assert('Only arrays of static class strings are allowed for \'classNames\'. For dynamic classes, use \'classNameBindings\'.', Array.isArray(this.classNames)); + }, - Modifier.prototype.compile = function compile(compiler, env, symbolTable) { - var args = this.args.compile(compiler, env, symbolTable); - if (env.hasModifier(this.path, symbolTable)) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.ModifierOpcode(this.path[0], env.lookupModifier(this.path, symbolTable), args)); - } else { - throw new Error('Compile Error: ' + this.path.join('.') + ' is not a modifier'); - } - }; + /** + Standard CSS class names to apply to the view's outer element. This + property automatically inherits any class names defined by the view's + superclasses as well. + @property classNames + @type Array + @default ['ember-view'] + @public + */ + classNames: EMPTY_ARRAY, - return Modifier; - })(_glimmerRuntimeLibSyntax.Statement); + /** + A list of properties of the view to apply as class names. If the property + is a string value, the value of that string will be applied as a class + name. + ```javascript + // Applies the 'high' class to the view element + Ember.Component.extend({ + classNameBindings: ['priority'], + priority: 'high' + }); + ``` + If the value of the property is a Boolean, the name of that property is + added as a dasherized class name. + ```javascript + // Applies the 'is-urgent' class to the view element + Ember.Component.extend({ + classNameBindings: ['isUrgent'], + isUrgent: true + }); + ``` + If you would prefer to use a custom value instead of the dasherized + property name, you can pass a binding like this: + ```javascript + // Applies the 'urgent' class to the view element + Ember.Component.extend({ + classNameBindings: ['isUrgent:urgent'], + isUrgent: true + }); + ``` + This list of properties is inherited from the component's superclasses as well. + @property classNameBindings + @type Array + @default [] + @public + */ + classNameBindings: EMPTY_ARRAY + }); +}); +enifed('ember-views/mixins/text_support', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + /** + @module ember + @submodule ember-views + */ - exports.Modifier = Modifier; + 'use strict'; - var StaticArg = (function (_ArgumentSyntax) { - babelHelpers.inherits(StaticArg, _ArgumentSyntax); + var KEY_EVENTS = { + 13: 'insertNewline', + 27: 'cancel' + }; - function StaticArg(name, value) { - _ArgumentSyntax.call(this); - this.name = name; - this.value = value; - this.type = "static-arg"; - } + /** + `TextSupport` is a shared mixin used by both `Ember.TextField` and + `Ember.TextArea`. `TextSupport` adds a number of methods that allow you to + specify a controller action to invoke when a certain event is fired on your + text field or textarea. The specifed controller action would get the current + value of the field passed in as the only argument unless the value of + the field is empty. In that case, the instance of the field itself is passed + in as the only argument. + + Let's use the pressing of the escape key as an example. If you wanted to + invoke a controller action when a user presses the escape key while on your + field, you would use the `escape-press` attribute on your field like so: + + ```handlebars + {{! application.hbs}} + + {{input escape-press='alertUser'}} + ``` + + ```javascript + App = Ember.Application.create(); + + App.ApplicationController = Ember.Controller.extend({ + actions: { + alertUser: function ( currentValue ) { + alert( 'escape pressed, current value: ' + currentValue ); + } + } + }); + ``` + + The following chart is a visual representation of what takes place when the + escape key is pressed in this scenario: + + ``` + The Template + +---------------------------+ + | | + | escape-press='alertUser' | + | | TextSupport Mixin + +----+----------------------+ +-------------------------------+ + | | cancel method | + | escape button pressed | | + +-------------------------------> | checks for the `escape-press` | + | attribute and pulls out the | + +-------------------------------+ | `alertUser` value | + | action name 'alertUser' +-------------------------------+ + | sent to controller + v + Controller + +------------------------------------------ + + | | + | actions: { | + | alertUser: function( currentValue ){ | + | alert( 'the esc key was pressed!' ) | + | } | + | } | + | | + +-------------------------------------------+ + ``` + + Here are the events that we currently support along with the name of the + attribute you would need to use on your field. To reiterate, you would use the + attribute name like so: + + ```handlebars + {{input attribute-name='controllerAction'}} + ``` + + ``` + +--------------------+----------------+ + | | | + | event | attribute name | + +--------------------+----------------+ + | new line inserted | insert-newline | + | | | + | enter key pressed | insert-newline | + | | | + | cancel key pressed | escape-press | + | | | + | focusin | focus-in | + | | | + | focusout | focus-out | + | | | + | keypress | key-press | + | | | + | keyup | key-up | + | | | + | keydown | key-down | + +--------------------+----------------+ + ``` + + @class TextSupport + @namespace Ember + @uses Ember.TargetActionSupport + @extends Ember.Mixin + @private + */ + exports.default = _emberMetal.Mixin.create(_emberRuntime.TargetActionSupport, { + value: '', - StaticArg.fromSpec = function fromSpec(node) { - var name = node[1]; - var value = node[2]; + attributeBindings: ['autocapitalize', 'autocorrect', 'autofocus', 'disabled', 'form', 'maxlength', 'placeholder', 'readonly', 'required', 'selectionDirection', 'spellcheck', 'tabindex', 'title'], + placeholder: null, + disabled: false, + maxlength: null, - return new StaticArg(name, value); - }; + init: function () { + this._super.apply(this, arguments); + this.on('paste', this, this._elementValueDidChange); + this.on('cut', this, this._elementValueDidChange); + this.on('input', this, this._elementValueDidChange); + }, - StaticArg.build = function build(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + /** + The action to be sent when the user presses the return key. + This is similar to the `{{action}}` helper, but is fired when + the user presses the return key when editing a text field, and sends + the value of the field as the context. + @property action + @type String + @default null + @private + */ + action: null, - return new this(name, value); - }; + /** + The event that should send the action. + Options are: + * `enter`: the user pressed enter + * `keyPress`: the user pressed a key + @property onEvent + @type String + @default enter + @private + */ + onEvent: 'enter', - StaticArg.prototype.compile = function compile() { - throw new Error('Cannot compiler StaticArg "' + this.name + '" as it is a delegate for ValueSyntax.'); - }; + /** + Whether the `keyUp` event that triggers an `action` to be sent continues + propagating to other views. + By default, when the user presses the return key on their keyboard and + the text field has an `action` set, the action will be sent to the view's + controller and the key event will stop propagating. + If you would like parent views to receive the `keyUp` event even after an + action has been dispatched, set `bubbles` to true. + @property bubbles + @type Boolean + @default false + @private + */ + bubbles: false, - StaticArg.prototype.valueSyntax = function valueSyntax() { - return Value.build(this.value); - }; + interpretKeyEvents: function (event) { + var map = KEY_EVENTS; + var method = map[event.keyCode]; - return StaticArg; - })(_glimmerRuntimeLibSyntax.Argument); + this._elementValueDidChange(); + if (method) { + return this[method](event); + } + }, - exports.StaticArg = StaticArg; + _elementValueDidChange: function () { + _emberMetal.set(this, 'value', this.element.value); + }, - var DynamicArg = (function (_ArgumentSyntax2) { - babelHelpers.inherits(DynamicArg, _ArgumentSyntax2); + change: function (event) { + this._elementValueDidChange(event); + }, - function DynamicArg(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + /** + Allows you to specify a controller action to invoke when either the `enter` + key is pressed or, in the case of the field being a textarea, when a newline + is inserted. To use this method, give your field an `insert-newline` + attribute. The value of that attribute should be the name of the action + in your controller that you wish to invoke. + For an example on how to use the `insert-newline` attribute, please + reference the example near the top of this file. + @method insertNewline + @param {Event} event + @private + */ + insertNewline: function (event) { + sendAction('enter', this, event); + sendAction('insert-newline', this, event); + }, - _ArgumentSyntax2.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this.type = 'dynamic-arg'; - } + /** + Allows you to specify a controller action to invoke when the escape button + is pressed. To use this method, give your field an `escape-press` + attribute. The value of that attribute should be the name of the action + in your controller that you wish to invoke. + For an example on how to use the `escape-press` attribute, please reference + the example near the top of this file. + @method cancel + @param {Event} event + @private + */ + cancel: function (event) { + sendAction('escape-press', this, event); + }, - DynamicArg.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; + /** + Allows you to specify a controller action to invoke when a field receives + focus. To use this method, give your field a `focus-in` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `focus-in` attribute, please reference the + example near the top of this file. + @method focusIn + @param {Event} event + @private + */ + focusIn: function (event) { + sendAction('focus-in', this, event); + }, - return new DynamicArg(name, _glimmerRuntimeLibSyntaxExpressions.default(value)); - }; + /** + Allows you to specify a controller action to invoke when a field loses + focus. To use this method, give your field a `focus-out` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `focus-out` attribute, please reference the + example near the top of this file. + @method focusOut + @param {Event} event + @private + */ + focusOut: function (event) { + this._elementValueDidChange(event); + sendAction('focus-out', this, event); + }, - DynamicArg.build = function build(name, value) { - return new this(name, value); - }; + /** + Allows you to specify a controller action to invoke when a key is pressed. + To use this method, give your field a `key-press` attribute. The value of + that attribute should be the name of the action in your controller you + that wish to invoke. + For an example on how to use the `key-press` attribute, please reference the + example near the top of this file. + @method keyPress + @param {Event} event + @private + */ + keyPress: function (event) { + sendAction('key-press', this, event); + }, - DynamicArg.prototype.compile = function compile() { - throw new Error('Cannot compile DynamicArg for "' + this.name + '" as it is delegate for ExpressionSyntax.'); - }; + /** + Allows you to specify a controller action to invoke when a key-up event is + fired. To use this method, give your field a `key-up` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `key-up` attribute, please reference the + example near the top of this file. + @method keyUp + @param {Event} event + @private + */ + keyUp: function (event) { + this.interpretKeyEvents(event); - DynamicArg.prototype.valueSyntax = function valueSyntax() { - return this.value; - }; + this.sendAction('key-up', _emberMetal.get(this, 'value'), event); + }, - return DynamicArg; - })(_glimmerRuntimeLibSyntax.Argument); + /** + Allows you to specify a controller action to invoke when a key-down event is + fired. To use this method, give your field a `key-down` attribute. The value + of that attribute should be the name of the action in your controller that + you wish to invoke. + For an example on how to use the `key-down` attribute, please reference the + example near the top of this file. + @method keyDown + @param {Event} event + @private + */ + keyDown: function (event) { + this.sendAction('key-down', _emberMetal.get(this, 'value'), event); + } + }); - exports.DynamicArg = DynamicArg; + // In principle, this shouldn't be necessary, but the legacy + // sendAction semantics for TextField are different from + // the component semantics so this method normalizes them. + function sendAction(eventName, view, event) { + var action = _emberMetal.get(view, 'attrs.' + eventName) || _emberMetal.get(view, eventName); + var on = _emberMetal.get(view, 'onEvent'); + var value = _emberMetal.get(view, 'value'); - var TrustingAttr = (function () { - function TrustingAttr() {} + // back-compat support for keyPress as an event name even though + // it's also a method name that consumes the event (and therefore + // incompatible with sendAction semantics). + if (on === eventName || on === 'keyPress' && eventName === 'key-press') { + view.sendAction('action', value); + } - TrustingAttr.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; - var namespace = sexp[3]; + view.sendAction(eventName, value); - return new DynamicAttr(name, _glimmerRuntimeLibSyntaxExpressions.default(value), namespace, true); - }; + if (action || on === eventName) { + if (!_emberMetal.get(view, 'bubbles')) { + event.stopPropagation(); + } + } + } +}); +enifed('ember-views/mixins/view_state_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - TrustingAttr.build = function build(name, value, isTrusting) { - var namespace = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + exports.default = _emberMetal.Mixin.create({ + _transitionTo: function (state) { + var priorState = this._currentState; + var currentState = this._currentState = this._states[state]; + this._state = state; - return new DynamicAttr(name, value, namespace, isTrusting); - }; + if (priorState && priorState.exit) { + priorState.exit(this); + } + if (currentState.enter) { + currentState.enter(this); + } + } + }); +}); +enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-views/system/utils', 'ember-runtime/system/core_object', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberViewsSystemUtils, _emberRuntimeSystemCore_object, _emberViewsSystemJquery) { + 'use strict'; - TrustingAttr.prototype.compile = function compile() { - throw new Error('Attempting to compile a TrustingAttr which is just a delegate for DynamicAttr.'); - }; + var _Mixin$create; - return TrustingAttr; - })(); + function K() { + return this; + } - exports.TrustingAttr = TrustingAttr; + var dispatchLifeCycleHook = function (component, hook, oldAttrs, newAttrs) { + component.trigger(hook, { attrs: newAttrs, oldAttrs: oldAttrs, newAttrs: newAttrs }); + }; - var StaticAttr = (function (_AttributeSyntax) { - babelHelpers.inherits(StaticAttr, _AttributeSyntax); + exports.dispatchLifeCycleHook = dispatchLifeCycleHook; + _emberMetal.runInDebug(function () { + var Attrs = (function () { + function Attrs(oldAttrs, newAttrs, message) { + babelHelpers.classCallCheck(this, Attrs); + + this._oldAttrs = oldAttrs; + this._newAttrs = newAttrs; + this._message = message; + } + + babelHelpers.createClass(Attrs, [{ + key: 'attrs', + get: function () { + return this.newAttrs; + } + }, { + key: 'oldAttrs', + get: function () { + _emberMetal.deprecate(this._message, false, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - function StaticAttr(name, value, namespace) { - _AttributeSyntax.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - this.type = "static-attr"; - this.isTrusting = false; + return this._oldAttrs; } + }, { + key: 'newAttrs', + get: function () { + _emberMetal.deprecate(this._message, false, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - StaticAttr.fromSpec = function fromSpec(node) { - var name = node[1]; - var value = node[2]; - var namespace = node[3]; - - return new StaticAttr(name, value, namespace); - }; - - StaticAttr.build = function build(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - - return new this(name, value, namespace); - }; + return this._newAttrs; + } + }]); + return Attrs; + })(); - StaticAttr.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.StaticAttrOpcode(this.namespace, this.name, this.value)); - }; + exports.dispatchLifeCycleHook = dispatchLifeCycleHook = function (component, hook, oldAttrs, newAttrs) { + if (typeof component[hook] === 'function' && component[hook].length !== 0) { + // Already warned in init + component.trigger(hook, { attrs: newAttrs, oldAttrs: oldAttrs, newAttrs: newAttrs }); + } else { + component.trigger(hook, new Attrs(oldAttrs, newAttrs, '[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + component.toString() + '#' + hook + '` to stop taking arguments.')); + } + }; + }); - StaticAttr.prototype.valueSyntax = function valueSyntax() { - return Value.build(this.value); - }; + /** + @class ViewMixin + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create((_Mixin$create = { + concatenatedProperties: ['attributeBindings'] + }, _Mixin$create[_emberRuntimeSystemCore_object.POST_INIT] = function () { + dispatchLifeCycleHook(this, 'didInitAttrs', undefined, this.attrs); + dispatchLifeCycleHook(this, 'didReceiveAttrs', undefined, this.attrs); + }, _Mixin$create.nearestOfType = function (klass) { + var view = this.parentView; + var isOfType = klass instanceof _emberMetal.Mixin ? function (view) { + return klass.detect(view); + } : function (view) { + return klass.detect(view.constructor); + }; - return StaticAttr; - })(_glimmerRuntimeLibSyntax.Attribute); + while (view) { + if (isOfType(view)) { + return view; + } + view = view.parentView; + } + }, _Mixin$create.nearestWithProperty = function (property) { + var view = this.parentView; - exports.StaticAttr = StaticAttr; + while (view) { + if (property in view) { + return view; + } + view = view.parentView; + } + }, _Mixin$create.rerender = function () { + return this._currentState.rerender(this); + }, _Mixin$create.element = _emberMetal.descriptor({ + configurable: false, + enumerable: false, + get: function () { + return this.renderer.getElement(this); + } + }), _Mixin$create.$ = function (sel) { + _emberMetal.assert('You cannot access this.$() on a component with `tagName: \'\'` specified.', this.tagName !== ''); + if (this.element) { + return sel ? _emberViewsSystemJquery.default(sel, this.element) : _emberViewsSystemJquery.default(this.element); + } + }, _Mixin$create.appendTo = function (selector) { + var env = this._environment || _emberEnvironment.environment; + var target = undefined; - var DynamicAttr = (function (_AttributeSyntax2) { - babelHelpers.inherits(DynamicAttr, _AttributeSyntax2); + if (env.hasDOM) { + target = typeof selector === 'string' ? document.querySelector(selector) : selector; - function DynamicAttr(name, value, namespace, isTrusting) { - if (namespace === undefined) namespace = undefined; + _emberMetal.assert('You tried to append to (' + selector + ') but that isn\'t in the DOM', target); + _emberMetal.assert('You cannot append to an existing Ember.View.', !_emberViewsSystemUtils.matches(target, '.ember-view')); + _emberMetal.assert('You cannot append to an existing Ember.View.', (function () { + var node = target.parentNode; + while (node) { + if (node.nodeType !== 9 && _emberViewsSystemUtils.matches(node, '.ember-view')) { + return false; + } - _AttributeSyntax2.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this.isTrusting = isTrusting; - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - this.type = "dynamic-attr"; + node = node.parentNode; } - DynamicAttr.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; - var namespace = sexp[3]; + return true; + })()); + } else { + target = selector; - return new DynamicAttr(name, _glimmerRuntimeLibSyntaxExpressions.default(value), namespace); - }; + _emberMetal.assert('You tried to append to a selector string (' + selector + ') in an environment without jQuery', typeof target !== 'string'); + _emberMetal.assert('You tried to append to a non-Element (' + selector + ') in an environment without jQuery', typeof selector.appendChild === 'function'); + } - DynamicAttr.build = function build(name, value) { - var isTrusting = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; - var namespace = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + this.renderer.appendTo(this, target); - return new this(name, value, namespace, isTrusting); - }; + return this; + }, _Mixin$create.renderToElement = function () { + var tagName = arguments.length <= 0 || arguments[0] === undefined ? 'body' : arguments[0]; + + _emberMetal.deprecate('Using the `renderToElement` is deprecated in favor of `appendTo`. Called in ' + this.toString(), false, { + id: 'ember-views.render-to-element', + until: '2.12.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_code-rendertoelement-code' + }); - DynamicAttr.prototype.compile = function compile(compiler, env, symbolTable) { - var namespace = this.namespace; - var value = this.value; + var element = this.renderer.createElement(tagName); - compiler.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(value.compile(compiler, env, symbolTable))); - if (namespace) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrNSOpcode(this.name, this.namespace, this.isTrusting)); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrOpcode(this.name, this.isTrusting)); - } - }; + this.renderer.appendTo(this, element); + return element; + }, _Mixin$create.replaceIn = function (selector) { + var target = _emberViewsSystemJquery.default(selector); - DynamicAttr.prototype.valueSyntax = function valueSyntax() { - return this.value; - }; + _emberMetal.assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0); + _emberMetal.assert('You cannot replace an existing Ember.View.', !target.is('.ember-view') && !target.parents().is('.ember-view')); - return DynamicAttr; - })(_glimmerRuntimeLibSyntax.Attribute); + this.renderer.replaceIn(this, target[0]); - exports.DynamicAttr = DynamicAttr; + return this; + }, _Mixin$create.append = function () { + return this.appendTo(document.body); + }, _Mixin$create.elementId = null, _Mixin$create.findElementInParentElement = function (parentElem) { + var id = '#' + this.elementId; + return _emberViewsSystemJquery.default(id)[0] || _emberViewsSystemJquery.default(id, parentElem)[0]; + }, _Mixin$create.willInsertElement = K, _Mixin$create.didInsertElement = K, _Mixin$create.willClearRender = K, _Mixin$create.destroy = function () { + this._super.apply(this, arguments); + this._currentState.destroy(this); + }, _Mixin$create.willDestroyElement = K, _Mixin$create.parentViewDidChange = K, _Mixin$create.tagName = null, _Mixin$create.init = function () { + this._super.apply(this, arguments); - var FlushElement = (function (_StatementSyntax4) { - babelHelpers.inherits(FlushElement, _StatementSyntax4); + if (!this.elementId && this.tagName !== '') { + this.elementId = _emberUtils.guidFor(this); + } - function FlushElement() { - _StatementSyntax4.apply(this, arguments); - this.type = "flush-element"; - } + // if we find an `eventManager` property, deopt the + // `EventDispatcher`'s `canDispatchToEventManager` property + // if `null` + if (this.eventManager) { + var owner = _emberUtils.getOwner(this); + var dispatcher = owner && owner.lookup('event_dispatcher:main'); - FlushElement.fromSpec = function fromSpec() { - return new FlushElement(); - }; + if (dispatcher && dispatcher.canDispatchToEventManager === null) { + dispatcher.canDispatchToEventManager = true; + } + } - FlushElement.build = function build() { - return new this(); - }; + _emberMetal.deprecate('[DEPRECATED] didInitAttrs called in ' + this.toString() + '.', typeof this.didInitAttrs !== 'function', { + id: 'ember-views.did-init-attrs', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' + }); - FlushElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.FlushElementOpcode()); - }; + _emberMetal.deprecate('[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + this.toString() + '#didInitAttrs` to stop taking arguments.', typeof this.didInitAttrs !== 'function' || this.didInitAttrs.length === 0, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - return FlushElement; - })(_glimmerRuntimeLibSyntax.Statement); + _emberMetal.deprecate('[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + this.toString() + '#didReceiveAttrs` to stop taking arguments.', typeof this.didReceiveAttrs !== 'function' || this.didReceiveAttrs.length === 0, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - exports.FlushElement = FlushElement; + _emberMetal.deprecate('[DEPRECATED] Ember will stop passing arguments to component lifecycle hooks. Please change `' + this.toString() + '#didUpdateAttrs` to stop taking arguments.', typeof this.didUpdateAttrs !== 'function' || this.didUpdateAttrs.length === 0, { + id: 'ember-views.lifecycle-hook-arguments', + until: '2.13.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks' + }); - var CloseElement = (function (_StatementSyntax5) { - babelHelpers.inherits(CloseElement, _StatementSyntax5); + _emberMetal.assert('Using a custom `.render` function is no longer supported.', !this.render); + }, _Mixin$create.__defineNonEnumerable = function (property) { + this[property.name] = property.descriptor.value; + }, _Mixin$create.handleEvent = function (eventName, evt) { + return this._currentState.handleEvent(this, eventName, evt); + }, _Mixin$create)); +}); - function CloseElement() { - _StatementSyntax5.apply(this, arguments); - this.type = "close-element"; - } +// .......................................................... +// TEMPLATE SUPPORT +// - CloseElement.fromSpec = function fromSpec() { - return new CloseElement(); - }; +/** + Return the nearest ancestor that is an instance of the provided + class or mixin. + @method nearestOfType + @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself), + or an instance of Ember.Mixin. + @return Ember.View + @deprecated use `yield` and contextual components for composition instead. + @private +*/ - CloseElement.build = function build() { - return new this(); - }; +/** + Return the nearest ancestor that has a given property. + @method nearestWithProperty + @param {String} property A property name + @return Ember.View + @deprecated use `yield` and contextual components for composition instead. + @private +*/ - CloseElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.CloseElementOpcode()); - }; +/** + Renders the view again. This will work regardless of whether the + view is already in the DOM or not. If the view is in the DOM, the + rendering process will be deferred to give bindings a chance + to synchronize. + If children were added during the rendering process using `appendChild`, + `rerender` will remove them, because they will be added again + if needed by the next `render`. + In general, if the display of your view changes, you should modify + the DOM element directly instead of manually calling `rerender`, which can + be slow. + @method rerender + @public +*/ - return CloseElement; - })(_glimmerRuntimeLibSyntax.Statement); +// .......................................................... +// ELEMENT SUPPORT +// - exports.CloseElement = CloseElement; +/** + Returns the current DOM element for the view. + @property element + @type DOMElement + @public +*/ - var Text = (function (_StatementSyntax6) { - babelHelpers.inherits(Text, _StatementSyntax6); +/** + Returns a jQuery object for this view's element. If you pass in a selector + string, this method will return a jQuery object, using the current element + as its buffer. + For example, calling `view.$('li')` will return a jQuery object containing + all of the `li` elements inside the DOM element of this view. + @method $ + @param {String} [selector] a jQuery-compatible selector string + @return {jQuery} the jQuery object for the DOM node + @public +*/ - function Text(content) { - _StatementSyntax6.call(this); - this.content = content; - this.type = "text"; - } +/** + Appends the view's element to the specified parent element. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing. + This is not typically a function that you will need to call directly when + building your application. If you do need to use `appendTo`, be sure that + the target element you are providing is associated with an `Ember.Application` + and does not have an ancestor element that is associated with an Ember view. + @method appendTo + @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object + @return {Ember.View} receiver + @private +*/ - Text.fromSpec = function fromSpec(node) { - var content = node[1]; +/** + Creates a new DOM element, renders the view into it, then returns the + element. + By default, the element created and rendered into will be a `BODY` element, + since this is the default context that views are rendered into when being + inserted directly into the DOM. + ```js + let element = view.renderToElement(); + element.tagName; // => "BODY" + ``` + You can override the kind of element rendered into and returned by + specifying an optional tag name as the first argument. + ```js + let element = view.renderToElement('table'); + element.tagName; // => "TABLE" + ``` + This method is useful if you want to render the view into an element that + is not in the document's body. Instead, a new `body` element, detached from + the DOM is returned. FastBoot uses this to serialize the rendered view into + a string for transmission over the network. + ```js + app.visit('/').then(function(instance) { + let element; + Ember.run(function() { + element = renderToElement(instance); + }); + res.send(serialize(element)); + }); + ``` + @method renderToElement + @param {String} tagName The tag of the element to create and render into. Defaults to "body". + @return {HTMLBodyElement} element + @deprecated Use appendTo instead. + @private +*/ - return new Text(content); - }; +/** + Replaces the content of the specified parent element with this view's + element. If the view does not have an HTML representation yet, + the element will be generated automatically. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing + @method replaceIn + @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object + @return {Ember.View} received + @private +*/ - Text.build = function build(content) { - return new this(content); - }; +/** + Appends the view's element to the document body. If the view does + not have an HTML representation yet + the element will be generated automatically. + If your application uses the `rootElement` property, you must append + the view within that element. Rendering views outside of the `rootElement` + is not supported. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the document body until all bindings have + finished synchronizing. + @method append + @return {Ember.View} receiver + @private +*/ - Text.prototype.compile = function compile(dsl) { - dsl.text(this.content); - }; +/** + The HTML `id` of the view's element in the DOM. You can provide this + value yourself but it must be unique (just as in HTML): + ```handlebars + {{my-component elementId="a-really-cool-id"}} + ``` + If not manually set a default value will be provided by the framework. + Once rendered an element's `elementId` is considered immutable and you + should never change it. If you need to compute a dynamic value for the + `elementId`, you should do this when the component or element is being + instantiated: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + let index = this.get('index'); + this.set('elementId', 'component-id' + index); + } + }); + ``` + @property elementId + @type String + @public +*/ - return Text; - })(_glimmerRuntimeLibSyntax.Statement); +/** + Attempts to discover the element in the parent element. The default + implementation looks for an element with an ID of `elementId` (or the + view's guid if `elementId` is null). You can override this method to + provide your own form of lookup. For example, if you want to discover your + element using a CSS class name instead of an ID. + @method findElementInParentElement + @param {DOMElement} parentElement The parent's DOM element + @return {DOMElement} The discovered element + @private +*/ - exports.Text = Text; +/** + Called when a view is going to insert an element into the DOM. + @event willInsertElement + @public +*/ - var Comment = (function (_StatementSyntax7) { - babelHelpers.inherits(Comment, _StatementSyntax7); +/** + Called when the element of the view has been inserted into the DOM. + Override this function to do any set up that requires an element + in the document body. + When a view has children, didInsertElement will be called on the + child view(s) first and on itself afterwards. + @event didInsertElement + @public +*/ - function Comment(comment) { - _StatementSyntax7.call(this); - this.comment = comment; - this.type = "comment"; - } +/** + Called when the view is about to rerender, but before anything has + been torn down. This is a good opportunity to tear down any manual + observers you have installed based on the DOM state + @event willClearRender + @public +*/ - Comment.fromSpec = function fromSpec(sexp) { - var value = sexp[1]; +/** + You must call `destroy` on a view to destroy the view (and all of its + child views). This will remove the view from any parent node, then make + sure that the DOM element managed by the view can be released by the + memory manager. + @method destroy + @private +*/ - return new Comment(value); - }; +/** + Called when the element of the view is going to be destroyed. Override + this function to do any teardown that requires an element, like removing + event listeners. + Please note: any property changes made during this event will have no + effect on object observers. + @event willDestroyElement + @public +*/ - Comment.build = function build(value) { - return new this(value); - }; +/** + Called when the parentView property has changed. + @event parentViewDidChange + @private +*/ - Comment.prototype.compile = function compile(dsl) { - dsl.comment(this.comment); - }; +// .......................................................... +// STANDARD RENDER PROPERTIES +// - return Comment; - })(_glimmerRuntimeLibSyntax.Statement); +/** + Tag name for the view's outer element. The tag name is only used when an + element is first created. If you change the `tagName` for an element, you + must destroy and recreate the view element. + By default, the render buffer will use a `
    ` tag for views. + @property tagName + @type String + @default null + @public +*/ - exports.Comment = Comment; +// We leave this null by default so we can tell the difference between +// the default case and a user-specified tag. - var OpenElement = (function (_StatementSyntax8) { - babelHelpers.inherits(OpenElement, _StatementSyntax8); +// ....................................................... +// CORE DISPLAY METHODS +// - function OpenElement(tag, blockParams, symbolTable) { - _StatementSyntax8.call(this); - this.tag = tag; - this.blockParams = blockParams; - this.symbolTable = symbolTable; - this.type = "open-element"; - } +/** + Setup a view, but do not finish waking it up. + * configure `childViews` + * register the view with the global views hash, which is used for event + dispatch + @method init + @private +*/ - OpenElement.fromSpec = function fromSpec(sexp, symbolTable) { - var tag = sexp[1]; - var blockParams = sexp[2]; +// ....................................................... +// EVENT HANDLING +// - return new OpenElement(tag, blockParams, symbolTable); - }; +/** + Handle events from `Ember.EventDispatcher` + @method handleEvent + @param eventName {String} + @param evt {Event} + @private +*/ +enifed("ember-views/system/action_manager", ["exports"], function (exports) { + /** + @module ember + @submodule ember-views + */ - OpenElement.build = function build(tag, blockParams, symbolTable) { - return new this(tag, blockParams, symbolTable); - }; + "use strict"; - OpenElement.prototype.scan = function scan(scanner) { - var tag = this.tag; + exports.default = ActionManager; - if (scanner.env.hasComponentDefinition([tag], this.symbolTable)) { - var _parameters = this.parameters(scanner); + function ActionManager() {} - var args = _parameters.args; - var attrs = _parameters.attrs; + /** + Global action id hash. + + @private + @property registeredActions + @type Object + */ + ActionManager.registeredActions = {}; +}); +enifed('ember-views/system/event_dispatcher', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-environment', 'ember-views/compat/fallback-view-registry'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberViewsSystemJquery, _emberViewsSystemAction_manager, _emberEnvironment, _emberViewsCompatFallbackViewRegistry) { + /** + @module ember + @submodule ember-views + */ - scanner.startBlock(this.blockParams); - this.tagContents(scanner); - var template = scanner.endBlock(this.blockParams); - args.blocks = Blocks.fromSpec(template); - return new Component(tag, attrs, args); - } else { - return new OpenPrimitiveElement(tag); - } - }; + 'use strict'; - OpenElement.prototype.compile = function compile(list, env) { - list.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(this.tag)); - }; + var ROOT_ELEMENT_CLASS = 'ember-application'; + var ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; - OpenElement.prototype.toIdentity = function toIdentity() { - var tag = this.tag; + /** + `Ember.EventDispatcher` handles delegating browser events to their + corresponding `Ember.Views.` For example, when you click on a view, + `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets + called. + + @class EventDispatcher + @namespace Ember + @private + @extends Ember.Object + */ + exports.default = _emberRuntime.Object.extend({ - return new OpenPrimitiveElement(tag); - }; + /** + The set of events names (and associated handler function names) to be setup + and dispatched by the `EventDispatcher`. Modifications to this list can be done + at setup time, generally via the `Ember.Application.customEvents` hash. + To add new events to be listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + paste: 'paste' + } + }); + ``` + To prevent default events from being listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + mouseenter: null, + mouseleave: null + } + }); + ``` + @property events + @type Object + @private + */ + events: { + touchstart: 'touchStart', + touchmove: 'touchMove', + touchend: 'touchEnd', + touchcancel: 'touchCancel', + keydown: 'keyDown', + keyup: 'keyUp', + keypress: 'keyPress', + mousedown: 'mouseDown', + mouseup: 'mouseUp', + contextmenu: 'contextMenu', + click: 'click', + dblclick: 'doubleClick', + mousemove: 'mouseMove', + focusin: 'focusIn', + focusout: 'focusOut', + mouseenter: 'mouseEnter', + mouseleave: 'mouseLeave', + submit: 'submit', + input: 'input', + change: 'change', + dragstart: 'dragStart', + drag: 'drag', + dragenter: 'dragEnter', + dragleave: 'dragLeave', + dragover: 'dragOver', + drop: 'drop', + dragend: 'dragEnd' + }, - OpenElement.prototype.parameters = function parameters(scanner) { - var current = scanner.next(); - var attrs = []; - var argKeys = []; - var argValues = []; - while (!(current instanceof FlushElement)) { - if (current[MODIFIER_SYNTAX]) { - throw new Error('Compile Error: Element modifiers are not allowed in components'); - } - var param = current; - if (current[_glimmerRuntimeLibSyntax.ATTRIBUTE]) { - attrs.push(param.name); - // REMOVE ME: attributes should not be treated as args - argKeys.push(param.name); - argValues.push(param.valueSyntax()); - } else if (current[_glimmerRuntimeLibSyntax.ARGUMENT]) { - argKeys.push(param.name); - argValues.push(param.valueSyntax()); - } else { - throw new Error("Expected FlushElement, but got ${current}"); - } - current = scanner.next(); - } - return { args: Args.fromNamedArgs(NamedArgs.build(argKeys, argValues)), attrs: attrs }; - }; + /** + The root DOM element to which event listeners should be attached. Event + listeners will be attached to the document unless this is overridden. + Can be specified as a DOMElement or a selector string. + The default body is a string since this may be evaluated before document.body + exists in the DOM. + @private + @property rootElement + @type DOMElement + @default 'body' + */ + rootElement: 'body', - OpenElement.prototype.tagContents = function tagContents(scanner) { - var nesting = 1; - while (true) { - var current = scanner.next(); - if (current instanceof CloseElement && --nesting === 0) { - break; - } - scanner.addStatement(current); - if (current instanceof OpenElement || current instanceof OpenPrimitiveElement) { - nesting++; - } - } - }; + /** + It enables events to be dispatched to the view's `eventManager.` When present, + this object takes precedence over handling of events on the view itself. + Note that most Ember applications do not use this feature. If your app also + does not use it, consider setting this property to false to gain some performance + improvement by allowing the EventDispatcher to skip the search for the + `eventManager` on the view tree. + ```javascript + let EventDispatcher = Em.EventDispatcher.extend({ + events: { + click : 'click', + focusin : 'focusIn', + focusout : 'focusOut', + change : 'change' + }, + canDispatchToEventManager: false + }); + container.register('event_dispatcher:main', EventDispatcher); + ``` + @property canDispatchToEventManager + @type boolean + @default false + @since 1.7.0 + @private + */ + canDispatchToEventManager: null, - return OpenElement; - })(_glimmerRuntimeLibSyntax.Statement); + init: function () { + this._super(); + _emberMetal.assert('EventDispatcher should never be instantiated in fastboot mode. Please report this as an Ember bug.', _emberEnvironment.environment.hasDOM); + }, - exports.OpenElement = OpenElement; + /** + Sets up event listeners for standard browser events. + This will be called after the browser sends a `DOMContentReady` event. By + default, it will set up all of the listeners on the document body. If you + would like to register the listeners on a different element, set the event + dispatcher's `root` property. + @private + @method setup + @param addedEvents {Object} + */ + setup: function (addedEvents, rootElement) { + var event = undefined; + var events = this._finalEvents = _emberUtils.assign({}, _emberMetal.get(this, 'events'), addedEvents); - var Component = (function (_StatementSyntax9) { - babelHelpers.inherits(Component, _StatementSyntax9); + if (_emberMetal.isNone(rootElement)) { + rootElement = _emberMetal.get(this, 'rootElement'); + } else { + _emberMetal.set(this, 'rootElement', rootElement); + } - function Component(tag, attrs, args) { - _StatementSyntax9.call(this); - this.tag = tag; - this.attrs = attrs; - this.args = args; - this.type = 'component'; - } - - Component.prototype.compile = function compile(list, env, symbolTable) { - var definition = env.getComponentDefinition([this.tag], symbolTable); - var args = this.args.compile(list, env, symbolTable); - var shadow = this.attrs; - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutComponentDefinitionOpcode(definition)); - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.OpenComponentOpcode(args, shadow)); - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.CloseComponentOpcode()); - }; + rootElement = _emberViewsSystemJquery.default(rootElement); - return Component; - })(_glimmerRuntimeLibSyntax.Statement); + _emberMetal.assert('You cannot use the same root element (' + (rootElement.selector || rootElement[0].tagName) + ') multiple times in an Ember.Application', !rootElement.is(ROOT_ELEMENT_SELECTOR)); + _emberMetal.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length); + _emberMetal.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find(ROOT_ELEMENT_SELECTOR).length); - exports.Component = Component; + rootElement.addClass(ROOT_ELEMENT_CLASS); - var OpenPrimitiveElement = (function (_StatementSyntax10) { - babelHelpers.inherits(OpenPrimitiveElement, _StatementSyntax10); + if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) { + throw new TypeError('Unable to add \'' + ROOT_ELEMENT_CLASS + '\' class to root element (' + (rootElement.selector || rootElement[0].tagName) + '). Make sure you set rootElement to the body or an element in the body.'); + } - function OpenPrimitiveElement(tag) { - _StatementSyntax10.call(this); - this.tag = tag; - this.type = "open-primitive-element"; + for (event in events) { + if (events.hasOwnProperty(event)) { + this.setupHandler(rootElement, event, events[event]); } + } + }, - OpenPrimitiveElement.build = function build(tag) { - return new this(tag); - }; + /** + Registers an event listener on the rootElement. If the given event is + triggered, the provided event handler will be triggered on the target view. + If the target view does not implement the event handler, or if the handler + returns `false`, the parent view will be called. The event will continue to + bubble to each successive parent view until it reaches the top. + @private + @method setupHandler + @param {Element} rootElement + @param {String} event the browser-originated event to listen to + @param {String} eventName the name of the method to call on the view + */ + setupHandler: function (rootElement, event, eventName) { + var self = this; - OpenPrimitiveElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(this.tag)); - }; + var owner = _emberUtils.getOwner(this); + var viewRegistry = owner && owner.lookup('-view-registry:main') || _emberViewsCompatFallbackViewRegistry.default; - return OpenPrimitiveElement; - })(_glimmerRuntimeLibSyntax.Statement); + if (eventName === null) { + return; + } - exports.OpenPrimitiveElement = OpenPrimitiveElement; + rootElement.on(event + '.ember', '.ember-view', function (evt, triggeringManager) { + var view = viewRegistry[this.id]; + var result = true; - var Yield = (function (_StatementSyntax11) { - babelHelpers.inherits(Yield, _StatementSyntax11); + var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; - function Yield(to, args) { - _StatementSyntax11.call(this); - this.to = to; - this.args = args; - this.type = "yield"; + if (manager && manager !== triggeringManager) { + result = self._dispatchEvent(manager, evt, eventName, view); + } else if (view) { + result = self._bubbleEvent(view, evt, eventName); } - Yield.fromSpec = function fromSpec(sexp) { - var to = sexp[1]; - var params = sexp[2]; - - var args = Args.fromSpec(params, null, EMPTY_BLOCKS); - return new Yield(to, args); - }; - - Yield.build = function build(params, to) { - var args = Args.fromPositionalArgs(PositionalArgs.build(params)); - return new this(to, args); - }; + return result; + }); - Yield.prototype.compile = function compile(dsl, env, symbolTable) { - var to = this.to; - - var args = this.args.compile(dsl, env, symbolTable); - if (dsl.hasBlockSymbol(to)) { - var symbol = dsl.getBlockSymbol(to); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, to); - dsl.append(new OpenBlockOpcode(inner, args)); - dsl.append(new CloseBlockOpcode()); - } else if (dsl.hasPartialArgsSymbol()) { - var symbol = dsl.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, to); - dsl.append(new OpenBlockOpcode(inner, args)); - dsl.append(new CloseBlockOpcode()); - } else { - throw new Error('[BUG] ${to} is not a valid block name.'); - } - }; + rootElement.on(event + '.ember', '[data-ember-action]', function (evt) { + var attributes = evt.currentTarget.attributes; - return Yield; - })(_glimmerRuntimeLibSyntax.Statement); + for (var i = 0; i < attributes.length; i++) { + var attr = attributes.item(i); + var attrName = attr.name; - exports.Yield = Yield; + if (attrName.lastIndexOf('data-ember-action-', 0) !== -1) { + var action = _emberViewsSystemAction_manager.default.registeredActions[attr.value]; - function isStaticPartialName(exp) { - return exp.type === 'value'; - } + if (action.eventName === eventName) { + action.handler(evt); + } + } + } + }); + }, - var Partial = (function (_StatementSyntax12) { - babelHelpers.inherits(Partial, _StatementSyntax12); + _findNearestEventManager: function (view, eventName) { + var manager = null; - function Partial() { - _StatementSyntax12.apply(this, arguments); + while (view) { + manager = _emberMetal.get(view, 'eventManager'); + if (manager && manager[eventName]) { + break; } - Partial.fromSpec = function fromSpec(sexp) { - var exp = sexp[1]; - - var name = _glimmerRuntimeLibSyntaxExpressions.default(exp); - if (isStaticPartialName(name)) { - return new _glimmerRuntimeLibSyntaxBuiltinsPartial.StaticPartialSyntax(name); - } else { - return new _glimmerRuntimeLibSyntaxBuiltinsPartial.DynamicPartialSyntax(name); - } - }; + view = _emberMetal.get(view, 'parentView'); + } - return Partial; - })(_glimmerRuntimeLibSyntax.Statement); + return manager; + }, - exports.Partial = Partial; + _dispatchEvent: function (object, evt, eventName, view) { + var result = true; - var OpenBlockOpcode = (function (_Opcode) { - babelHelpers.inherits(OpenBlockOpcode, _Opcode); + var handler = object[eventName]; + if (typeof handler === 'function') { + result = _emberMetal.run(object, handler, evt, view); + // Do not preventDefault in eventManagers. + evt.stopPropagation(); + } else { + result = this._bubbleEvent(view, evt, eventName); + } - function OpenBlockOpcode(inner, args) { - _Opcode.call(this); - this.inner = inner; - this.args = args; - this.type = "open-block"; - } + return result; + }, - OpenBlockOpcode.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - var args = undefined; - if (block) { - args = this.args.evaluate(vm); - } - // FIXME: can we avoid doing this when we don't have a block? - vm.pushCallerScope(); - if (block) { - vm.invokeBlock(block, args); - } - }; + _bubbleEvent: function (view, evt, eventName) { + return view.handleEvent(eventName, evt); + }, - OpenBlockOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - details: { - "block": this.inner.toJSON(), - "positional": this.args.positional.toJSON(), - "named": this.args.named.toJSON() - } - }; - }; + destroy: function () { + var rootElement = _emberMetal.get(this, 'rootElement'); + _emberViewsSystemJquery.default(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); + return this._super.apply(this, arguments); + }, - return OpenBlockOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + toString: function () { + return '(EventDispatcher)'; + } + }); +}); +enifed('ember-views/system/ext', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ - var CloseBlockOpcode = (function (_Opcode2) { - babelHelpers.inherits(CloseBlockOpcode, _Opcode2); + 'use strict'; - function CloseBlockOpcode() { - _Opcode2.apply(this, arguments); - this.type = "close-block"; - } + // Add a new named queue for rendering views that happens + // after bindings have synced, and a queue for scheduling actions + // that should occur after view rendering. + _emberMetal.run._addQueue('render', 'actions'); + _emberMetal.run._addQueue('afterRender', 'render'); +}); +enifed('ember-views/system/jquery', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; - CloseBlockOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - }; + var jQuery = undefined; - return CloseBlockOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (_emberEnvironment.environment.hasDOM) { + jQuery = _emberEnvironment.context.imports.jQuery; - exports.CloseBlockOpcode = CloseBlockOpcode; + if (jQuery) { + if (jQuery.event.addProp) { + jQuery.event.addProp('dataTransfer'); + } else { + // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents + ['dragstart', 'drag', 'dragenter', 'dragleave', 'dragover', 'drop', 'dragend'].forEach(function (eventName) { + jQuery.event.fixHooks[eventName] = { + props: ['dataTransfer'] + }; + }); + } + } + } - var Value = (function (_ExpressionSyntax) { - babelHelpers.inherits(Value, _ExpressionSyntax); + exports.default = jQuery; +}); +enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - function Value(value) { - _ExpressionSyntax.call(this); - this.value = value; - this.type = "value"; - } + exports.default = lookupPartial; + exports.hasPartial = hasPartial; - Value.fromSpec = function fromSpec(value) { - return new Value(value); - }; + function parseUnderscoredName(templateName) { + var nameParts = templateName.split('/'); + var lastPart = nameParts[nameParts.length - 1]; - Value.build = function build(value) { - return new this(value); - }; + nameParts[nameParts.length - 1] = '_' + lastPart; - Value.prototype.inner = function inner() { - return this.value; - }; + return nameParts.join('/'); + } - Value.prototype.compile = function compile(compiler) { - return new _glimmerRuntimeLibCompiledExpressionsValue.default(this.value); - }; + function lookupPartial(templateName, owner) { + if (templateName == null) { + return; + } - return Value; - })(_glimmerRuntimeLibSyntax.Expression); + var template = templateFor(owner, parseUnderscoredName(templateName), templateName); - exports.Value = Value; + _emberMetal.assert('Unable to find partial with name "' + templateName + '"', !!template); - var GetArgument = (function (_ExpressionSyntax2) { - babelHelpers.inherits(GetArgument, _ExpressionSyntax2); + return template; + } - function GetArgument(parts) { - _ExpressionSyntax2.call(this); - this.parts = parts; - this.type = "get-argument"; - } + function hasPartial(name, owner) { + if (!owner) { + throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); + } - // this is separated out from Get because Unknown also has a ref, but it - // may turn out to be a helper + return owner.hasRegistration('template:' + parseUnderscoredName(name)) || owner.hasRegistration('template:' + name); + } - GetArgument.fromSpec = function fromSpec(sexp) { - var parts = sexp[1]; + function templateFor(owner, underscored, name) { + if (!name) { + return; + } + _emberMetal.assert('templateNames are not allowed to contain periods: ' + name, name.indexOf('.') === -1); - return new GetArgument(parts); - }; + if (!owner) { + throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); + } - GetArgument.build = function build(path) { - return new this(path.split('.')); - }; + return owner.lookup('template:' + underscored) || owner.lookup('template:' + name); + } +}); +enifed('ember-views/system/utils', ['exports', 'ember-utils'], function (exports, _emberUtils) { + /* globals Element */ + 'use strict'; - GetArgument.prototype.compile = function compile(lookup) { - var parts = this.parts; - - var head = parts[0]; - if (lookup.hasNamedSymbol(head)) { - var symbol = lookup.getNamedSymbol(head); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSymbol(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else if (lookup.hasPartialArgsSymbol()) { - var symbol = lookup.getPartialArgsSymbol(); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledInPartialName(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else { - throw new Error('[BUG] @' + this.parts.join('.') + ' is not a valid lookup path.'); - } - }; + exports.isSimpleClick = isSimpleClick; + exports.getRootViews = getRootViews; + exports.getViewId = getViewId; + exports.getViewElement = getViewElement; + exports.initViewElement = initViewElement; + exports.setViewElement = setViewElement; + exports.getChildViews = getChildViews; + exports.initChildViews = initChildViews; + exports.addChildView = addChildView; + exports.collectChildViews = collectChildViews; + exports.getViewBounds = getViewBounds; + exports.getViewRange = getViewRange; + exports.getViewClientRects = getViewClientRects; + exports.getViewBoundingClientRect = getViewBoundingClientRect; + exports.matches = matches; - return GetArgument; - })(_glimmerRuntimeLibSyntax.Expression); + /** + @module ember + @submodule ember-views + */ - exports.GetArgument = GetArgument; + function isSimpleClick(event) { + var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; + var secondaryClick = event.which > 1; // IE9 may return undefined - var Ref = (function (_ExpressionSyntax3) { - babelHelpers.inherits(Ref, _ExpressionSyntax3); + return !modifier && !secondaryClick; + } - function Ref(parts) { - _ExpressionSyntax3.call(this); - this.parts = parts; - this.type = "ref"; - } + var STYLE_WARNING = '' + 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + 'please ensure that values being bound are properly escaped. For more information, ' + 'including how to disable this warning, see ' + 'http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.'; - Ref.build = function build(path) { - var parts = path.split('.'); - if (parts[0] === 'this') { - parts[0] = null; - } - return new this(parts); - }; + exports.STYLE_WARNING = STYLE_WARNING; + /** + @private + @method getRootViews + @param {Object} owner + */ - Ref.prototype.compile = function compile(lookup) { - var parts = this.parts; - - var head = parts[0]; - if (head === null) { - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSelf(); - var path = parts.slice(1); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else if (lookup.hasLocalSymbol(head)) { - var symbol = lookup.getLocalSymbol(head); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSymbol(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else { - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSelf(); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, parts); - } - }; + function getRootViews(owner) { + var registry = owner.lookup('-view-registry:main'); - return Ref; - })(_glimmerRuntimeLibSyntax.Expression); + var rootViews = []; - exports.Ref = Ref; + Object.keys(registry).forEach(function (id) { + var view = registry[id]; - var Get = (function (_ExpressionSyntax4) { - babelHelpers.inherits(Get, _ExpressionSyntax4); + if (view.parentView === null) { + rootViews.push(view); + } + }); - function Get(ref) { - _ExpressionSyntax4.call(this); - this.ref = ref; - this.type = "get"; - } + return rootViews; + } - Get.fromSpec = function fromSpec(sexp) { - var parts = sexp[1]; + /** + @private + @method getViewId + @param {Ember.View} view + */ - return new this(new Ref(parts)); - }; + function getViewId(view) { + if (view.tagName === '') { + return _emberUtils.guidFor(view); + } else { + return view.elementId || _emberUtils.guidFor(view); + } + } - Get.build = function build(path) { - return new this(Ref.build(path)); - }; + var VIEW_ELEMENT = _emberUtils.symbol('VIEW_ELEMENT'); - Get.prototype.compile = function compile(compiler) { - return this.ref.compile(compiler); - }; + /** + @private + @method getViewElement + @param {Ember.View} view + */ - return Get; - })(_glimmerRuntimeLibSyntax.Expression); + function getViewElement(view) { + return view[VIEW_ELEMENT]; + } - exports.Get = Get; + function initViewElement(view) { + view[VIEW_ELEMENT] = null; + } - var Unknown = (function (_ExpressionSyntax5) { - babelHelpers.inherits(Unknown, _ExpressionSyntax5); + function setViewElement(view, element) { + return view[VIEW_ELEMENT] = element; + } - function Unknown(ref) { - _ExpressionSyntax5.call(this); - this.ref = ref; - this.type = "unknown"; - } + var CHILD_VIEW_IDS = _emberUtils.symbol('CHILD_VIEW_IDS'); - Unknown.fromSpec = function fromSpec(sexp) { - var path = sexp[1]; + /** + @private + @method getChildViews + @param {Ember.View} view + */ - return new this(new Ref(path)); - }; + function getChildViews(view) { + var owner = _emberUtils.getOwner(view); + var registry = owner.lookup('-view-registry:main'); + return collectChildViews(view, registry); + } - Unknown.build = function build(path) { - return new this(Ref.build(path)); - }; + function initChildViews(view) { + view[CHILD_VIEW_IDS] = []; + } - Unknown.prototype.compile = function compile(compiler, env, symbolTable) { - var ref = this.ref; + function addChildView(parent, child) { + parent[CHILD_VIEW_IDS].push(getViewId(child)); + } - if (env.hasHelper(ref.parts, symbolTable)) { - return new _glimmerRuntimeLibCompiledExpressionsHelper.default(ref.parts, env.lookupHelper(ref.parts, symbolTable), _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.empty(), symbolTable); - } else { - return this.ref.compile(compiler); - } - }; + function collectChildViews(view, registry) { + var ids = []; + var views = []; - return Unknown; - })(_glimmerRuntimeLibSyntax.Expression); + view[CHILD_VIEW_IDS].forEach(function (id) { + var view = registry[id]; - exports.Unknown = Unknown; + if (view && !view.isDestroying && !view.isDestroyed && ids.indexOf(id) === -1) { + ids.push(id); + views.push(view); + } + }); - var Helper = (function (_ExpressionSyntax6) { - babelHelpers.inherits(Helper, _ExpressionSyntax6); + view[CHILD_VIEW_IDS] = ids; - function Helper(ref, args) { - _ExpressionSyntax6.call(this); - this.ref = ref; - this.args = args; - this.type = "helper"; - } + return views; + } - Helper.fromSpec = function fromSpec(sexp) { - var path = sexp[1]; - var params = sexp[2]; - var hash = sexp[3]; + /** + @private + @method getViewBounds + @param {Ember.View} view + */ - return new Helper(new Ref(path), Args.fromSpec(params, hash, EMPTY_BLOCKS)); - }; + function getViewBounds(view) { + return view.renderer.getBounds(view); + } - Helper.build = function build(path, positional, named) { - return new this(Ref.build(path), Args.build(positional, named, EMPTY_BLOCKS)); - }; + /** + @private + @method getViewRange + @param {Ember.View} view + */ - Helper.prototype.compile = function compile(compiler, env, symbolTable) { - if (env.hasHelper(this.ref.parts, symbolTable)) { - var args = this.args; - var ref = this.ref; + function getViewRange(view) { + var bounds = getViewBounds(view); - return new _glimmerRuntimeLibCompiledExpressionsHelper.default(ref.parts, env.lookupHelper(ref.parts, symbolTable), args.compile(compiler, env, symbolTable), symbolTable); - } else { - throw new Error('Compile Error: ' + this.ref.parts.join('.') + ' is not a helper'); - } - }; + var range = document.createRange(); + range.setStartBefore(bounds.firstNode); + range.setEndAfter(bounds.lastNode); - return Helper; - })(_glimmerRuntimeLibSyntax.Expression); + return range; + } - exports.Helper = Helper; + /** + `getViewClientRects` provides information about the position of the border + box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inspector + and may not work on older browsers. + + @private + @method getViewClientRects + @param {Ember.View} view + */ - var HasBlock = (function (_ExpressionSyntax7) { - babelHelpers.inherits(HasBlock, _ExpressionSyntax7); + function getViewClientRects(view) { + var range = getViewRange(view); + return range.getClientRects(); + } - function HasBlock(blockName) { - _ExpressionSyntax7.call(this); - this.blockName = blockName; - this.type = "has-block"; - } + /** + `getViewBoundingClientRect` provides information about the position of the + bounding border box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inpsector + and may not work on older browsers. + + @private + @method getViewBoundingClientRect + @param {Ember.View} view + */ - HasBlock.fromSpec = function fromSpec(sexp) { - var blockName = sexp[1]; + function getViewBoundingClientRect(view) { + var range = getViewRange(view); + return range.getBoundingClientRect(); + } - return new HasBlock(blockName); - }; + /** + Determines if the element matches the specified selector. + + @private + @method matches + @param {DOMElement} el + @param {String} selector + */ + var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector); - HasBlock.build = function build(blockName) { - return new this(blockName); - }; + exports.elMatches = elMatches; - HasBlock.prototype.compile = function compile(compiler, env) { - var blockName = this.blockName; - - if (compiler.hasBlockSymbol(blockName)) { - var symbol = compiler.getBlockSymbol(blockName); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.default(inner); - } else if (compiler.hasPartialArgsSymbol()) { - var symbol = compiler.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.default(inner); - } else { - throw new Error('[BUG] ${blockName} is not a valid block name.'); - } - }; + function matches(el, selector) { + return elMatches.call(el, selector); + } +}); +enifed('ember-views/utils/lookup-component', ['exports', 'container'], function (exports, _container) { + 'use strict'; - return HasBlock; - })(_glimmerRuntimeLibSyntax.Expression); + exports.default = lookupComponent; - exports.HasBlock = HasBlock; + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - var HasBlockParams = (function (_ExpressionSyntax8) { - babelHelpers.inherits(HasBlockParams, _ExpressionSyntax8); + function lookupComponentPair(componentLookup, owner, name, options) { + var component = componentLookup.componentFor(name, owner, options); + var layout = componentLookup.layoutFor(name, owner, options); - function HasBlockParams(blockName) { - _ExpressionSyntax8.call(this); - this.blockName = blockName; - this.type = "has-block-params"; - } + var result = { layout: layout, component: component }; - HasBlockParams.fromSpec = function fromSpec(sexp) { - var blockName = sexp[1]; + if (layout && !component) { + result.component = owner[_container.FACTORY_FOR](_container.privatize(_templateObject)); + } - return new HasBlockParams(blockName); - }; + return result; + } - HasBlockParams.build = function build(blockName) { - return new this(blockName); - }; + function lookupComponent(owner, name, options) { + var componentLookup = owner.lookup('component-lookup:main'); - HasBlockParams.prototype.compile = function compile(compiler, env) { - var blockName = this.blockName; - - if (compiler.hasBlockSymbol(blockName)) { - var symbol = compiler.getBlockSymbol(blockName); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledHasBlockParams(inner); - } else if (compiler.hasPartialArgsSymbol()) { - var symbol = compiler.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledHasBlockParams(inner); - } else { - throw new Error('[BUG] ${blockName} is not a valid block name.'); - } - }; + var source = options && options.source; - return HasBlockParams; - })(_glimmerRuntimeLibSyntax.Expression); + if (source) { + var localResult = lookupComponentPair(componentLookup, owner, name, options); - exports.HasBlockParams = HasBlockParams; + if (localResult.component || localResult.layout) { + return localResult; + } + } - var Concat = (function () { - function Concat(parts) { - this.parts = parts; - this.type = "concat"; - } + return lookupComponentPair(componentLookup, owner, name); + } +}); +enifed('ember-views/views/core_view', ['exports', 'ember-runtime', 'ember-views/system/utils', 'ember-views/views/states'], function (exports, _emberRuntime, _emberViewsSystemUtils, _emberViewsViewsStates) { + 'use strict'; - Concat.fromSpec = function fromSpec(sexp) { - var params = sexp[1]; + /** + `Ember.CoreView` is an abstract class that exists to give view-like behavior + to both Ember's main view class `Ember.Component` and other classes that don't need + the full functionality of `Ember.Component`. + + Unless you have specific needs for `CoreView`, you will use `Ember.Component` + in your applications. + + @class CoreView + @namespace Ember + @extends Ember.Object + @deprecated Use `Ember.Component` instead. + @uses Ember.Evented + @uses Ember.ActionHandler + @private + */ + var CoreView = _emberRuntime.FrameworkObject.extend(_emberRuntime.Evented, _emberRuntime.ActionHandler, { + isView: true, - return new Concat(params.map(_glimmerRuntimeLibSyntaxExpressions.default)); - }; + _states: _emberViewsViewsStates.cloneStates(_emberViewsViewsStates.states), - Concat.build = function build(parts) { - return new this(parts); - }; + init: function () { + this._super.apply(this, arguments); + this._state = 'preRender'; + this._currentState = this._states.preRender; - Concat.prototype.compile = function compile(compiler, env, symbolTable) { - return new _glimmerRuntimeLibCompiledExpressionsConcat.default(this.parts.map(function (p) { - return p.compile(compiler, env, symbolTable); - })); - }; + _emberViewsSystemUtils.initViewElement(this); - return Concat; - })(); + if (!this.renderer) { + throw new Error('Cannot instantiate a component without a renderer. Please ensure that you are creating ' + this + ' with a proper container/registry.'); + } + }, - exports.Concat = Concat; + /** + If the view is currently inserted into the DOM of a parent view, this + property will point to the parent of the view. + @property parentView + @type Ember.View + @default null + @private + */ + parentView: null, - var Blocks = (function () { - function Blocks(_default) { - var inverse = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + instrumentDetails: function (hash) { + hash.object = this.toString(); + hash.containerKey = this._debugContainerKey; + hash.view = this; + return hash; + }, - this.type = "blocks"; - this.default = _default; - this.inverse = inverse; + /** + Override the default event firing from `Ember.Evented` to + also call methods with the given name. + @method trigger + @param name {String} + @private + */ + trigger: function () { + this._super.apply(this, arguments); + var name = arguments[0]; + var method = this[name]; + if (method) { + var args = new Array(arguments.length - 1); + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; } + return method.apply(this, args); + } + }, - Blocks.fromSpec = function fromSpec(_default) { - var inverse = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + has: function (name) { + return _emberRuntime.typeOf(this[name]) === 'function' || this._super(name); + } + }); - return new Blocks(_default, inverse); - }; + _emberRuntime.deprecateUnderscoreActions(CoreView); - Blocks.empty = function empty() { - return EMPTY_BLOCKS; - }; + CoreView.reopenClass({ + isViewFactory: true + }); - return Blocks; - })(); + exports.default = CoreView; +}); +enifed('ember-views/views/states', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberViewsViewsStatesPre_render, _emberViewsViewsStatesHas_element, _emberViewsViewsStatesIn_dom, _emberViewsViewsStatesDestroying) { + 'use strict'; - exports.Blocks = Blocks; - var EMPTY_BLOCKS = new ((function (_Blocks) { - babelHelpers.inherits(_class, _Blocks); + exports.cloneStates = cloneStates; - function _class() { - _Blocks.call(this, null, null); - } + function cloneStates(from) { + var into = {}; - return _class; - })(Blocks))(); - exports.EMPTY_BLOCKS = EMPTY_BLOCKS; + into._default = {}; + into.preRender = Object.create(into._default); + into.destroying = Object.create(into._default); + into.hasElement = Object.create(into._default); + into.inDOM = Object.create(into.hasElement); - var Args = (function () { - function Args(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; - this.type = "args"; - } + for (var stateName in from) { + if (!from.hasOwnProperty(stateName)) { + continue; + } + _emberUtils.assign(into[stateName], from[stateName]); + } - Args.empty = function empty() { - return EMPTY_ARGS; - }; + return into; + } - Args.fromSpec = function fromSpec(positional, named, blocks) { - return new Args(PositionalArgs.fromSpec(positional), NamedArgs.fromSpec(named), blocks); - }; + /* + Describe how the specified actions should behave in the various + states that a view can exist in. Possible states: + + * preRender: when a view is first instantiated, and after its + element was destroyed, it is in the preRender state + * hasElement: the DOM representation of the view is created, + and is ready to be inserted + * inDOM: once a view has been inserted into the DOM it is in + the inDOM state. A view spends the vast majority of its + existence in this state. + * destroyed: once a view has been destroyed (using the destroy + method), it is in this state. No further actions can be invoked + on a destroyed view. + */ + var states = { + _default: _emberViewsViewsStatesDefault.default, + preRender: _emberViewsViewsStatesPre_render.default, + inDOM: _emberViewsViewsStatesIn_dom.default, + hasElement: _emberViewsViewsStatesHas_element.default, + destroying: _emberViewsViewsStatesDestroying.default + }; + exports.states = states; +}); +enifed('ember-views/views/states/default', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; + + /** + @module ember + @submodule ember-views + */ + exports.default = { + // appendChild is only legal while rendering the buffer. + appendChild: function () { + throw new _emberMetal.Error('You can\'t use appendChild outside of the rendering process'); + }, - Args.fromPositionalArgs = function fromPositionalArgs(positional) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? EMPTY_BLOCKS : arguments[1]; + // Handle events from `Ember.EventDispatcher` + handleEvent: function () { + return true; // continue event propagation + }, - return new Args(positional, EMPTY_NAMED_ARGS, blocks); - }; + rerender: function () {}, - Args.fromNamedArgs = function fromNamedArgs(named) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? EMPTY_BLOCKS : arguments[1]; + destroy: function () {} + }; +}); +enifed('ember-views/views/states/destroying', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/default'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesDefault) { + 'use strict'; - return new Args(EMPTY_POSITIONAL_ARGS, named, blocks); - }; + /** + @module ember + @submodule ember-views + */ - Args.build = function build(positional, named, blocks) { - if (positional === EMPTY_POSITIONAL_ARGS && named === EMPTY_NAMED_ARGS && blocks === EMPTY_BLOCKS) { - return EMPTY_ARGS; - } else { - return new this(positional, named, blocks); - } - }; + var destroying = Object.create(_emberViewsViewsStatesDefault.default); - Args.prototype.compile = function compile(compiler, env, symbolTable) { - var positional = this.positional; - var named = this.named; - var blocks = this.blocks; + _emberUtils.assign(destroying, { + appendChild: function () { + throw new _emberMetal.Error('You can\'t call appendChild on a view being destroyed'); + }, + rerender: function () { + throw new _emberMetal.Error('You can\'t call rerender on a view being destroyed'); + } + }); - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.create(positional.compile(compiler, env, symbolTable), named.compile(compiler, env, symbolTable), blocks); - }; + exports.default = destroying; +}); +enifed('ember-views/views/states/has_element', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-metal'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberMetal) { + 'use strict'; - return Args; - })(); + var hasElement = Object.create(_emberViewsViewsStatesDefault.default); - exports.Args = Args; + _emberUtils.assign(hasElement, { - var PositionalArgs = (function () { - function PositionalArgs(values) { - this.values = values; - this.type = "positional"; - this.length = values.length; - } + rerender: function (view) { + view.renderer.rerender(view); + }, - PositionalArgs.empty = function empty() { - return EMPTY_POSITIONAL_ARGS; - }; + destroy: function (view) { + view.renderer.remove(view); + }, - PositionalArgs.fromSpec = function fromSpec(sexp) { - if (!sexp || sexp.length === 0) return EMPTY_POSITIONAL_ARGS; - return new PositionalArgs(sexp.map(_glimmerRuntimeLibSyntaxExpressions.default)); - }; + // Handle events from `Ember.EventDispatcher` + handleEvent: function (view, eventName, event) { + if (view.has(eventName)) { + // Handler should be able to re-dispatch events, so we don't + // preventDefault or stopPropagation. + return _emberMetal.flaggedInstrument('interaction.' + eventName, { event: event, view: view }, function () { + return _emberMetal.run.join(view, view.trigger, eventName, event); + }); + } else { + return true; // continue event propagation + } + } + }); - PositionalArgs.build = function build(exprs) { - if (exprs.length === 0) { - return EMPTY_POSITIONAL_ARGS; - } else { - return new this(exprs); - } - }; + exports.default = hasElement; +}); +enifed('ember-views/views/states/in_dom', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/has_element'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesHas_element) { + 'use strict'; - PositionalArgs.prototype.slice = function slice(start, end) { - return PositionalArgs.build(this.values.slice(start, end)); - }; + /** + @module ember + @submodule ember-views + */ - PositionalArgs.prototype.at = function at(index) { - return this.values[index]; - }; + var inDOM = Object.create(_emberViewsViewsStatesHas_element.default); - PositionalArgs.prototype.compile = function compile(compiler, env, symbolTable) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs.create(this.values.map(function (v) { - return v.compile(compiler, env, symbolTable); - })); - }; + _emberUtils.assign(inDOM, { + enter: function (view) { + // Register the view for event handling. This hash is used by + // Ember.EventDispatcher to dispatch incoming events. + view.renderer.register(view); - return PositionalArgs; - })(); + _emberMetal.runInDebug(function () { + _emberMetal._addBeforeObserver(view, 'elementId', function () { + throw new _emberMetal.Error('Changing a view\'s elementId after creation is not allowed'); + }); + }); + }, - exports.PositionalArgs = PositionalArgs; + exit: function (view) { + view.renderer.unregister(view); + } + }); - var EMPTY_POSITIONAL_ARGS = new ((function (_PositionalArgs) { - babelHelpers.inherits(_class2, _PositionalArgs); + exports.default = inDOM; +}); +enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default'], function (exports, _emberViewsViewsStatesDefault) { + 'use strict'; - function _class2() { - _PositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + /** + @module ember + @submodule ember-views + */ - _class2.prototype.slice = function slice(start, end) { - return this; - }; + exports.default = Object.create(_emberViewsViewsStatesDefault.default); +}); +enifed("ember-views/views/view", ["exports"], function (exports) { + "use strict"; +}); +/** +@module ember +@submodule ember-views +*/ - _class2.prototype.at = function at(index) { - return undefined; // ??! - }; +/** + @class View + @namespace Ember + @extends Ember.CoreView + @deprecated See http://emberjs.com/deprecations/v1.x/#toc_ember-view + @uses Ember.ViewSupport + @uses Ember.ChildViewsSupport + @uses Ember.ClassNamesSupport + @uses Ember.AttributeBindingsSupport + @private +*/ +enifed("ember/features", ["exports"], function (exports) { + "use strict"; - _class2.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs.empty(); - }; + exports.default = { "features-stripped-test": null, "ember-libraries-isregistered": null, "ember-improved-instrumentation": null, "ember-metal-weakmap": null, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": null, "ember-factory-for": true, "ember-no-double-extend": null, "ember-routing-router-service": null, "ember-unique-location-history-state": null, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; +}); +enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { + 'use strict'; - return _class2; - })(PositionalArgs))(); + // ember-utils exports + _emberMetal.default.getOwner = _emberUtils.getOwner; + _emberMetal.default.setOwner = _emberUtils.setOwner; + _emberMetal.default.generateGuid = _emberUtils.generateGuid; + _emberMetal.default.GUID_KEY = _emberUtils.GUID_KEY; + _emberMetal.default.guidFor = _emberUtils.guidFor; + _emberMetal.default.inspect = _emberUtils.inspect; + _emberMetal.default.makeArray = _emberUtils.makeArray; + _emberMetal.default.canInvoke = _emberUtils.canInvoke; + _emberMetal.default.tryInvoke = _emberUtils.tryInvoke; + _emberMetal.default.wrap = _emberUtils.wrap; + _emberMetal.default.applyStr = _emberUtils.applyStr; + _emberMetal.default.uuid = _emberUtils.uuid; + _emberMetal.default.assign = Object.assign || _emberUtils.assign; - var NamedArgs = (function () { - function NamedArgs(keys, values) { - this.keys = keys; - this.values = values; - this.type = "named"; - this.length = keys.length; - } + // container exports + _emberMetal.default.Container = _container.Container; + _emberMetal.default.Registry = _container.Registry; - NamedArgs.empty = function empty() { - return EMPTY_NAMED_ARGS; - }; + // need to import this directly, to ensure the babel feature + // flag plugin works properly - NamedArgs.fromSpec = function fromSpec(sexp) { - if (sexp === null || sexp === undefined) { - return EMPTY_NAMED_ARGS; - } - var keys = sexp[0]; - var exprs = sexp[1]; + var computed = _emberMetal.computed; + computed.alias = _emberMetal.alias; + _emberMetal.default.computed = computed; + _emberMetal.default.ComputedProperty = _emberMetal.ComputedProperty; + _emberMetal.default.cacheFor = _emberMetal.cacheFor; - if (keys.length === 0) { - return EMPTY_NAMED_ARGS; - } - return new this(keys, exprs.map(function (expr) { - return _glimmerRuntimeLibSyntaxExpressions.default(expr); - })); - }; + _emberMetal.default.assert = _emberMetal.assert; + _emberMetal.default.warn = _emberMetal.warn; + _emberMetal.default.debug = _emberMetal.debug; + _emberMetal.default.deprecate = _emberMetal.deprecate; + _emberMetal.default.deprecateFunc = _emberMetal.deprecateFunc; + _emberMetal.default.runInDebug = _emberMetal.runInDebug; + _emberMetal.default.merge = _emberMetal.merge; - NamedArgs.build = function build(keys, values) { - if (keys.length === 0) { - return EMPTY_NAMED_ARGS; - } else { - return new this(keys, values); - } - }; + _emberMetal.default.instrument = _emberMetal.instrument; + _emberMetal.default.subscribe = _emberMetal.instrumentationSubscribe; + _emberMetal.default.Instrumentation = { + instrument: _emberMetal.instrument, + subscribe: _emberMetal.instrumentationSubscribe, + unsubscribe: _emberMetal.instrumentationUnsubscribe, + reset: _emberMetal.instrumentationReset + }; - NamedArgs.prototype.at = function at(key) { - var keys = this.keys; - var values = this.values; + _emberMetal.default.Error = _emberMetal.Error; + _emberMetal.default.META_DESC = _emberMetal.META_DESC; + _emberMetal.default.meta = _emberMetal.meta; + _emberMetal.default.get = _emberMetal.get; + _emberMetal.default.getWithDefault = _emberMetal.getWithDefault; + _emberMetal.default._getPath = _emberMetal._getPath; + _emberMetal.default.set = _emberMetal.set; + _emberMetal.default.trySet = _emberMetal.trySet; + _emberMetal.default.FEATURES = _emberMetal.FEATURES; + _emberMetal.default.FEATURES.isEnabled = _emberMetal.isFeatureEnabled; + _emberMetal.default._Cache = _emberMetal.Cache; + _emberMetal.default.on = _emberMetal.on; + _emberMetal.default.addListener = _emberMetal.addListener; + _emberMetal.default.removeListener = _emberMetal.removeListener; + _emberMetal.default._suspendListener = _emberMetal.suspendListener; + _emberMetal.default._suspendListeners = _emberMetal.suspendListeners; + _emberMetal.default.sendEvent = _emberMetal.sendEvent; + _emberMetal.default.hasListeners = _emberMetal.hasListeners; + _emberMetal.default.watchedEvents = _emberMetal.watchedEvents; + _emberMetal.default.listenersFor = _emberMetal.listenersFor; + _emberMetal.default.accumulateListeners = _emberMetal.accumulateListeners; + _emberMetal.default.isNone = _emberMetal.isNone; + _emberMetal.default.isEmpty = _emberMetal.isEmpty; + _emberMetal.default.isBlank = _emberMetal.isBlank; + _emberMetal.default.isPresent = _emberMetal.isPresent; + _emberMetal.default.run = _emberMetal.run; + _emberMetal.default._ObserverSet = _emberMetal.ObserverSet; + _emberMetal.default.propertyWillChange = _emberMetal.propertyWillChange; + _emberMetal.default.propertyDidChange = _emberMetal.propertyDidChange; + _emberMetal.default.overrideChains = _emberMetal.overrideChains; + _emberMetal.default.beginPropertyChanges = _emberMetal.beginPropertyChanges; + _emberMetal.default.endPropertyChanges = _emberMetal.endPropertyChanges; + _emberMetal.default.changeProperties = _emberMetal.changeProperties; + _emberMetal.default.platform = { + defineProperty: true, + hasPropertyAccessors: true + }; + _emberMetal.default.defineProperty = _emberMetal.defineProperty; + _emberMetal.default.watchKey = _emberMetal.watchKey; + _emberMetal.default.unwatchKey = _emberMetal.unwatchKey; + _emberMetal.default.removeChainWatcher = _emberMetal.removeChainWatcher; + _emberMetal.default._ChainNode = _emberMetal.ChainNode; + _emberMetal.default.finishChains = _emberMetal.finishChains; + _emberMetal.default.watchPath = _emberMetal.watchPath; + _emberMetal.default.unwatchPath = _emberMetal.unwatchPath; + _emberMetal.default.watch = _emberMetal.watch; + _emberMetal.default.isWatching = _emberMetal.isWatching; + _emberMetal.default.unwatch = _emberMetal.unwatch; + _emberMetal.default.destroy = _emberMetal.destroy; + _emberMetal.default.libraries = _emberMetal.libraries; + _emberMetal.default.OrderedSet = _emberMetal.OrderedSet; + _emberMetal.default.Map = _emberMetal.Map; + _emberMetal.default.MapWithDefault = _emberMetal.MapWithDefault; + _emberMetal.default.getProperties = _emberMetal.getProperties; + _emberMetal.default.setProperties = _emberMetal.setProperties; + _emberMetal.default.expandProperties = _emberMetal.expandProperties; + _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; + _emberMetal.default.addObserver = _emberMetal.addObserver; + _emberMetal.default.observersFor = _emberMetal.observersFor; + _emberMetal.default.removeObserver = _emberMetal.removeObserver; + _emberMetal.default._suspendObserver = _emberMetal._suspendObserver; + _emberMetal.default._suspendObservers = _emberMetal._suspendObservers; + _emberMetal.default.required = _emberMetal.required; + _emberMetal.default.aliasMethod = _emberMetal.aliasMethod; + _emberMetal.default.observer = _emberMetal.observer; + _emberMetal.default.immediateObserver = _emberMetal._immediateObserver; + _emberMetal.default.mixin = _emberMetal.mixin; + _emberMetal.default.Mixin = _emberMetal.Mixin; + _emberMetal.default.bind = _emberMetal.bind; + _emberMetal.default.Binding = _emberMetal.Binding; + _emberMetal.default.isGlobalPath = _emberMetal.isGlobalPath; - var index = keys.indexOf(key); - return values[index]; - }; + if (_emberMetal.isFeatureEnabled('ember-metal-weakmap')) { + _emberMetal.default.WeakMap = _emberMetal.WeakMap; + } - NamedArgs.prototype.has = function has(key) { - return this.keys.indexOf(key) !== -1; - }; + Object.defineProperty(_emberMetal.default, 'ENV', { + get: function () { + return _emberEnvironment.ENV; + }, + enumerable: false + }); - NamedArgs.prototype.compile = function compile(compiler, env, symbolTable) { - var keys = this.keys; - var values = this.values; + /** + The context that Ember searches for namespace instances on. + + @private + */ + Object.defineProperty(_emberMetal.default, 'lookup', { + get: function () { + return _emberEnvironment.context.lookup; + }, + set: function (value) { + _emberEnvironment.context.lookup = value; + }, + enumerable: false + }); - return new _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs(keys, values.map(function (value) { - return value.compile(compiler, env, symbolTable); - })); - }; + _emberMetal.default.EXTEND_PROTOTYPES = _emberEnvironment.ENV.EXTEND_PROTOTYPES; - return NamedArgs; - })(); + // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS + Object.defineProperty(_emberMetal.default, 'LOG_STACKTRACE_ON_DEPRECATION', { + get: function () { + return _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; + }, + enumerable: false + }); - exports.NamedArgs = NamedArgs; + Object.defineProperty(_emberMetal.default, 'LOG_VERSION', { + get: function () { + return _emberEnvironment.ENV.LOG_VERSION; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_VERSION = !!value; + }, + enumerable: false + }); - var EMPTY_NAMED_ARGS = new ((function (_NamedArgs) { - babelHelpers.inherits(_class3, _NamedArgs); + Object.defineProperty(_emberMetal.default, 'MODEL_FACTORY_INJECTIONS', { + get: function () { + return _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; + }, + set: function (value) { + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = !!value; + }, + enumerable: false + }); - function _class3() { - _NamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + Object.defineProperty(_emberMetal.default, 'LOG_BINDINGS', { + get: function () { + return _emberEnvironment.ENV.LOG_BINDINGS; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_BINDINGS = !!value; + }, + enumerable: false + }); - _class3.prototype.at = function at(key) { - return undefined; // ??! - }; + /** + A function may be assigned to `Ember.onerror` to be called when Ember + internals encounter an error. This is useful for specialized error handling + and reporting code. + + ```javascript + Ember.onerror = function(error) { + Em.$.ajax('/report-error', 'POST', { + stack: error.stack, + otherInformation: 'whatever app state you want to provide' + }); + }; + ``` + + Internally, `Ember.onerror` is used as Backburner's error handler. + + @event onerror + @for Ember + @param {Exception} error the error object + @public + */ + Object.defineProperty(_emberMetal.default, 'onerror', { + get: _emberMetal.getOnerror, + set: _emberMetal.setOnerror, + enumerable: false + }); - _class3.prototype.has = function has(key) { - return false; - }; + /** + An empty function useful for some operations. Always returns `this`. + + @method K + @return {Object} + @public + */ + function deprecatedEmberK() { + return this; + } - _class3.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs.empty(); - }; + Object.defineProperty(_emberMetal.default, 'K', { + get: function () { + _emberMetal.deprecate('Ember.K is deprecated in favor of defining a function inline.', false, { + id: 'ember-metal.ember-k', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x#toc_code-ember-k-code' + }); - return _class3; - })(NamedArgs))(); - var EMPTY_ARGS = new ((function (_Args) { - babelHelpers.inherits(_class4, _Args); + return deprecatedEmberK; + } + }); - function _class4() { - _Args.call(this, EMPTY_POSITIONAL_ARGS, EMPTY_NAMED_ARGS, EMPTY_BLOCKS); - } + Object.defineProperty(_emberMetal.default, 'testing', { + get: _emberMetal.isTesting, + set: _emberMetal.setTesting, + enumerable: false + }); - _class4.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.empty(); - }; + if (!_require.has('ember-debug')) { + _emberMetal.default.Debug = { + registerDeprecationHandler: function () {}, + registerWarnHandler: function () {} + }; + } - return _class4; - })(Args))(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2NvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBMEdBLEtBQUE7OEJBQUEsS0FBQTs7QUFxQkUsaUJBckJGLEtBQUEs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nZpcm9ubWVudCk6IENvbXBpbGVkTmFtZWRBcmdzIHtcbiAgICByZXR1cm4gQ29tcGlsZWROYW1lZEFyZ3MuZW1wdHkoKTtcbiAgfVxufSk7XG5cbmNvbnN0IEVNUFRZX0FSR1M6IEFyZ3MgPSBuZXcgKGNsYXNzIGV4dGVuZHMgQXJncyB7XG4gIGNvbnN0cnVjdG9yKCkge1xuICAgIHN1cGVyKEVNUFRZX1BPU0lUSU9OQUxfQVJHUywgRU1QVFlfTkFNRURfQVJHUywgRU1QVFlfQkxPQ0tTKTtcbiAgfVxuXG4gIGNvbXBpbGUoY29tcGlsZXI6IFN5bWJvbExvb2t1cCwgZW52OiBFbnZpcm9ubWVudCk6IENvbXBpbGVkQXJncyB7XG4gICAgcmV0dXJuIENvbXBpbGVkQXJncy5lbXB0eSgpO1xuICB9XG59KTtcbiJdfQ== -enifed('glimmer-runtime/lib/syntax/expressions', ['exports', 'glimmer-runtime/lib/syntax/core', 'glimmer-wire-format'], function (exports, _glimmerRuntimeLibSyntaxCore, _glimmerWireFormat) { - 'use strict'; + /** + @class Backburner + @for Ember + @private + */ + _emberMetal.default.Backburner = function () { + _emberMetal.deprecate('Usage of Ember.Backburner is deprecated.', false, { + id: 'ember-metal.ember-backburner', + until: '2.8.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-backburner' + }); - var isArg = _glimmerWireFormat.Expressions.isArg; - var isConcat = _glimmerWireFormat.Expressions.isConcat; - var isGet = _glimmerWireFormat.Expressions.isGet; - var isHasBlock = _glimmerWireFormat.Expressions.isHasBlock; - var isHasBlockParams = _glimmerWireFormat.Expressions.isHasBlockParams; - var isHelper = _glimmerWireFormat.Expressions.isHelper; - var isUnknown = _glimmerWireFormat.Expressions.isUnknown; - var isPrimitiveValue = _glimmerWireFormat.Expressions.isPrimitiveValue; - var isUndefined = _glimmerWireFormat.Expressions.isUndefined; - - exports.default = function (sexp) { - if (isPrimitiveValue(sexp)) return _glimmerRuntimeLibSyntaxCore.Value.fromSpec(sexp); - if (isUndefined(sexp)) return _glimmerRuntimeLibSyntaxCore.Value.build(undefined); - if (isArg(sexp)) return _glimmerRuntimeLibSyntaxCore.GetArgument.fromSpec(sexp); - if (isConcat(sexp)) return _glimmerRuntimeLibSyntaxCore.Concat.fromSpec(sexp); - if (isGet(sexp)) return _glimmerRuntimeLibSyntaxCore.Get.fromSpec(sexp); - if (isHelper(sexp)) return _glimmerRuntimeLibSyntaxCore.Helper.fromSpec(sexp); - if (isUnknown(sexp)) return _glimmerRuntimeLibSyntaxCore.Unknown.fromSpec(sexp); - if (isHasBlock(sexp)) return _glimmerRuntimeLibSyntaxCore.HasBlock.fromSpec(sexp); - if (isHasBlockParams(sexp)) return _glimmerRuntimeLibSyntaxCore.HasBlockParams.fromSpec(sexp); - throw new Error('Unexpected wire format: ' + JSON.stringify(sexp)); - }; + function BackburnerAlias(args) { + return _backburner.default.apply(this, args); + } - ; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2V4cHJlc3Npb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQWlCRSxLQUFLLHNCQUxMLFdBQVcsQ0FLWCxLQUFLO1FBQ0wsUUFBUSxzQkFOUixXQUFXLENBTVgsUUFBUTtRQUNSLEtBQUssc0JBUEwsV0FBVyxDQU9YLEtBQUs7UUFDTCxVQUFVLHNCQVJWLFdBQVcsQ0FRWCxVQUFVO1FBQ1YsZ0JBQWdCLHNCQVRoQixXQUFXLENBU1gsZ0JBQWdCO1FBQ2hCLFFBQVEsc0JBVlIsV0FBVyxDQVVYLFFBQVE7UUFDUixTQUFTLHNCQVhULFdBQVcsQ0FXWCxTQUFTO1FBQ1QsZ0JBQWdCLHNCQVpoQixXQUFXLENBWVgsZ0JBQWdCO1FBQ2hCLFdBQVcsc0JBYlgsV0FBVyxDQWFYLFdBQVc7O3NCQUdiLFVBQXdCLEl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AoaXNVbmRlZmluZWQoc2V4cCkpIHJldHVybiBWYWx1ZVN5bnRheC5idWlsZCh1bmRlZmluZWQpO1xuICBpZiAoaXNBcmcoc2V4cCkpIHJldHVybiBBcmdTeW50YXguZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc0NvbmNhdChzZXhwKSkgcmV0dXJuIENvbmNhdFN5bnRheC5mcm9tU3BlYyhzZXhwKTtcbiAgaWYgKGlzR2V0KHNleHApKSByZXR1cm4gR2V0U3ludGF4LmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNIZWxwZXIoc2V4cCkpIHJldHVybiBIZWxwZXJTeW50YXguZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc1Vua25vd24oc2V4cCkpIHJldHVybiBVbmtub3duU3ludGF4LmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNIYXNCbG9jayhzZXhwKSkgcmV0dXJuIEhhc0Jsb2NrU3ludGF4LmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNIYXNCbG9ja1BhcmFtcyhzZXhwKSkgcmV0dXJuIEhhc0Jsb2NrUGFyYW1zU3ludGF4LmZyb21TcGVjKHNleHApO1xuXG4gIHRocm93IG5ldyBFcnJvcihgVW5leHBlY3RlZCB3aXJlIGZvcm1hdDogJHtKU09OLnN0cmluZ2lmeShzZXhwKX1gKTtcbn07XG4iXX0= -enifed('glimmer-runtime/lib/syntax/statements', ['exports', 'glimmer-runtime/lib/syntax/core', 'glimmer-wire-format'], function (exports, _glimmerRuntimeLibSyntaxCore, _glimmerWireFormat) { - 'use strict'; + BackburnerAlias.prototype = _backburner.default.prototype; - var isYield = _glimmerWireFormat.Statements.isYield; - var isBlock = _glimmerWireFormat.Statements.isBlock; - var isPartial = _glimmerWireFormat.Statements.isPartial; - var isAppend = _glimmerWireFormat.Statements.isAppend; - var isDynamicAttr = _glimmerWireFormat.Statements.isDynamicAttr; - var isText = _glimmerWireFormat.Statements.isText; - var isComment = _glimmerWireFormat.Statements.isComment; - var isOpenElement = _glimmerWireFormat.Statements.isOpenElement; - var isFlushElement = _glimmerWireFormat.Statements.isFlushElement; - var isCloseElement = _glimmerWireFormat.Statements.isCloseElement; - var isStaticAttr = _glimmerWireFormat.Statements.isStaticAttr; - var isModifier = _glimmerWireFormat.Statements.isModifier; - var isDynamicArg = _glimmerWireFormat.Statements.isDynamicArg; - var isStaticArg = _glimmerWireFormat.Statements.isStaticArg; - var isTrustingAttr = _glimmerWireFormat.Statements.isTrustingAttr; - - exports.default = function (sexp, symbolTable, scanner) { - if (isYield(sexp)) return _glimmerRuntimeLibSyntaxCore.Yield.fromSpec(sexp); - if (isPartial(sexp)) return _glimmerRuntimeLibSyntaxCore.Partial.fromSpec(sexp); - if (isBlock(sexp)) return _glimmerRuntimeLibSyntaxCore.Block.fromSpec(sexp, symbolTable, scanner); - if (isAppend(sexp)) return _glimmerRuntimeLibSyntaxCore.OptimizedAppend.fromSpec(sexp); - if (isDynamicAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.DynamicAttr.fromSpec(sexp); - if (isDynamicArg(sexp)) return _glimmerRuntimeLibSyntaxCore.DynamicArg.fromSpec(sexp); - if (isTrustingAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.TrustingAttr.fromSpec(sexp); - if (isText(sexp)) return _glimmerRuntimeLibSyntaxCore.Text.fromSpec(sexp); - if (isComment(sexp)) return _glimmerRuntimeLibSyntaxCore.Comment.fromSpec(sexp); - if (isOpenElement(sexp)) return _glimmerRuntimeLibSyntaxCore.OpenElement.fromSpec(sexp, symbolTable); - if (isFlushElement(sexp)) return _glimmerRuntimeLibSyntaxCore.FlushElement.fromSpec(); - if (isCloseElement(sexp)) return _glimmerRuntimeLibSyntaxCore.CloseElement.fromSpec(); - if (isStaticAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.StaticAttr.fromSpec(sexp); - if (isStaticArg(sexp)) return _glimmerRuntimeLibSyntaxCore.StaticArg.fromSpec(sexp); - if (isModifier(sexp)) return _glimmerRuntimeLibSyntaxCore.Modifier.fromSpec(sexp); - }; + return new BackburnerAlias(arguments); + }; - ; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L3N0YXRlbWVudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBMkJFLE9BQU8sc0JBTlAsVUFBVSxDQU1WLE9BQU87UUFDUCxPQUFPLHNCQVBQLFVBQVUsQ0FPVixPQUFPO1FBQ1AsU0FBUyxzQkFSVCxVQUFVLENBUVYsU0FBUztRQUNULFFBQVEsc0JBVFIsVUFBVSxDQVNWLFFBQVE7UUFDUixhQUFhLHNCQVZiLFVBQVUsQ0FVVixhQUFhO1FBQ2IsTUFBTSxzQkFYTixVQUFVLENBV1YsTUFBTTtRQUNOLFNBQVMsc0JBWlQsVUFBVSxDQVlWLFNBQVM7UUFDVCxhQUFhLHNCQWJiLFVBQVUsQ0FhVixhQUFhO1FBQ2IsY0FBYyxzQkFkZCxVQUFVLENBY1YsY0FBYztRQUNkLGNBQWMsc0JBZmQsVUFBVSxDQWVWLGNBQWM7UUFDZCxZQUFZLHNCQWhCWixVQUFVLENBZ0JWLFlBQVk7UUFDWixVQUFVLHNCQWpCVixVQUFVLENBaUJWLFVBQVU7UUFDVixZQUFZLHNCQWxCWixVQUFVLENBa0JWLFlBQVk7UUFDWixXQUFXLHNCQW5CWCxVQUFVLENBbUJWLFdBQVc7UUFDWCxjQUFjLHNCQXBCZCxVQUFVLENBb0JWLGNBQWM7O3NCQUdoQixVQUF3QixJQUF5QixFQUFFLFdBQXdCLEVBQUUsT0FBcUIsRUFBQTtBQUNoRyxZQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsRUFBRSxPQUFPLDZCQTVDMUIsS0FBSyxDQTRDMkIsUUFBUSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQy9DLFlBQUksU0FBUyxDQUFDLElBQUksQ0FBQyxFQUFFLE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aXNEeW5hbWljQXR0cihzZXhwKSkgcmV0dXJuIER5bmFtaWNBdHRyLmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNEeW5hbWljQXJnKHNleHApKSByZXR1cm4gRHluYW1pY0FyZy5mcm9tU3BlYyhzZXhwKTtcbiAgaWYgKGlzVHJ1c3RpbmdBdHRyKHNleHApKSByZXR1cm4gVHJ1c3RpbmdBdHRyLmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNUZXh0KHNleHApKSByZXR1cm4gVGV4dC5mcm9tU3BlYyhzZXhwKTtcbiAgaWYgKGlzQ29tbWVudChzZXhwKSkgcmV0dXJuIENvbW1lbnQuZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc09wZW5FbGVtZW50KHNleHApKSByZXR1cm4gT3BlbkVsZW1lbnQuZnJvbVNwZWMoc2V4cCwgc3ltYm9sVGFibGUpO1xuICBpZiAoaXNGbHVzaEVsZW1lbnQoc2V4cCkpIHJldHVybiBGbHVzaEVsZW1lbnQuZnJvbVNwZWMoKTtcbiAgaWYgKGlzQ2xvc2VFbGVtZW50KHNleHApKSByZXR1cm4gQ2xvc2VFbGVtZW50LmZyb21TcGVjKCk7XG4gIGlmIChpc1N0YXRpY0F0dHIoc2V4cCkpIHJldHVybiBTdGF0aWNBdHRyLmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNTdGF0aWNBcmcoc2V4cCkpIHJldHVybiBTdGF0aWNBcmcuZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc01vZGlmaWVyKHNleHApKSByZXR1cm4gTW9kaWZpZXIuZnJvbVNwZWMoc2V4cCk7XG59O1xuIl19 -enifed('glimmer-runtime/lib/template', ['exports', 'glimmer-util', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/vm', 'glimmer-runtime/lib/scanner'], function (exports, _glimmerUtil, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibVm, _glimmerRuntimeLibScanner) { - 'use strict'; + _emberMetal.default._Backburner = _backburner.default; - exports.default = templateFactory; + _emberMetal.default.Logger = _emberConsole.default; - var clientId = 0; + // ****ember-runtime**** - function templateFactory(_ref) { - var id = _ref.id; - var meta = _ref.meta; - var block = _ref.block; + _emberMetal.default.String = _emberRuntime.String; + _emberMetal.default.Object = _emberRuntime.Object; + _emberMetal.default._RegistryProxyMixin = _emberRuntime.RegistryProxyMixin; + _emberMetal.default._ContainerProxyMixin = _emberRuntime.ContainerProxyMixin; + _emberMetal.default.compare = _emberRuntime.compare; + _emberMetal.default.copy = _emberRuntime.copy; + _emberMetal.default.isEqual = _emberRuntime.isEqual; + _emberMetal.default.inject = _emberRuntime.inject; + _emberMetal.default.Array = _emberRuntime.Array; + _emberMetal.default.Comparable = _emberRuntime.Comparable; + _emberMetal.default.Enumerable = _emberRuntime.Enumerable; + _emberMetal.default.ArrayProxy = _emberRuntime.ArrayProxy; + _emberMetal.default.ObjectProxy = _emberRuntime.ObjectProxy; + _emberMetal.default.ActionHandler = _emberRuntime.ActionHandler; + _emberMetal.default.CoreObject = _emberRuntime.CoreObject; + _emberMetal.default.NativeArray = _emberRuntime.NativeArray; + _emberMetal.default.Copyable = _emberRuntime.Copyable; + _emberMetal.default.Freezable = _emberRuntime.Freezable; + _emberMetal.default.FROZEN_ERROR = _emberRuntime.FROZEN_ERROR; + _emberMetal.default.MutableEnumerable = _emberRuntime.MutableEnumerable; + _emberMetal.default.MutableArray = _emberRuntime.MutableArray; + _emberMetal.default.TargetActionSupport = _emberRuntime.TargetActionSupport; + _emberMetal.default.Evented = _emberRuntime.Evented; + _emberMetal.default.PromiseProxyMixin = _emberRuntime.PromiseProxyMixin; + _emberMetal.default.Observable = _emberRuntime.Observable; + _emberMetal.default.typeOf = _emberRuntime.typeOf; + _emberMetal.default.isArray = _emberRuntime.isArray; + _emberMetal.default.Object = _emberRuntime.Object; + _emberMetal.default.onLoad = _emberRuntime.onLoad; + _emberMetal.default.runLoadHooks = _emberRuntime.runLoadHooks; + _emberMetal.default.Controller = _emberRuntime.Controller; + _emberMetal.default.ControllerMixin = _emberRuntime.ControllerMixin; + _emberMetal.default.Service = _emberRuntime.Service; + _emberMetal.default._ProxyMixin = _emberRuntime._ProxyMixin; + _emberMetal.default.RSVP = _emberRuntime.RSVP; + _emberMetal.default.Namespace = _emberRuntime.Namespace; - var parsedBlock = undefined; - if (!id) { - id = 'client-' + clientId++; - } - var create = function (env, envMeta) { - var newMeta = envMeta ? _glimmerUtil.assign({}, envMeta, meta) : meta; - if (!parsedBlock) { - parsedBlock = JSON.parse(block); - } - return template(parsedBlock, id, newMeta, env); - }; - return { id: id, meta: meta, create: create }; - } + // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed + computed.empty = _emberRuntime.empty; + computed.notEmpty = _emberRuntime.notEmpty; + computed.none = _emberRuntime.none; + computed.not = _emberRuntime.not; + computed.bool = _emberRuntime.bool; + computed.match = _emberRuntime.match; + computed.equal = _emberRuntime.equal; + computed.gt = _emberRuntime.gt; + computed.gte = _emberRuntime.gte; + computed.lt = _emberRuntime.lt; + computed.lte = _emberRuntime.lte; + computed.oneWay = _emberRuntime.oneWay; + computed.reads = _emberRuntime.oneWay; + computed.readOnly = _emberRuntime.readOnly; + computed.deprecatingAlias = _emberRuntime.deprecatingAlias; + computed.and = _emberRuntime.and; + computed.or = _emberRuntime.or; + computed.any = _emberRuntime.any; - function template(block, id, meta, env) { - var scanner = new _glimmerRuntimeLibScanner.default(block, meta, env); - var entryPoint = undefined; - var asEntryPoint = function () { - if (!entryPoint) entryPoint = scanner.scanEntryPoint(); - return entryPoint; - }; - var layout = undefined; - var asLayout = function () { - if (!layout) layout = scanner.scanLayout(); - return layout; - }; - var asPartial = function (symbols) { - return scanner.scanPartial(symbols); - }; - var render = function (self, appendTo, dynamicScope) { - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.forInitialRender(env, appendTo, null); - var compiled = asEntryPoint().compile(env); - var vm = _glimmerRuntimeLibVm.VM.initial(env, self, dynamicScope, elementStack, compiled.symbols); - return vm.execute(compiled.ops); - }; - return { id: id, meta: meta, _block: block, asEntryPoint: asEntryPoint, asLayout: asLayout, asPartial: asPartial, render: render }; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdGVtcGxhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O3NCQWtGQSxlQUFBOztBQVRBLFFBQUksUUFBUSxHQUFHLENBQUMsQ0FBQzs7QUFTakIsYUFBQSxlQUFBLENBQXdDLElBQXlELEVBQUE7WUFBdkQsRUFBRSxHQUFKLElBQXlELENBQXZELEVBQUU7WUFBRSxJQUFJLEdBQVYsSUFBeUQsQ0FBbkQsSUFBSTtZQUFFLEtBQUssR0FBakIsSUFBeUQsQ0FBN0MsS0FBSzs7QUFDdkQsWUFBSSxXQUFvQyxZQUFBLENBQUM7QUFDekMsWUFBSSxDQUFDLEVBQUUsRUFBRTtBQUNQLGNBQUUsZUFBYSxRQUFRLEVBQUcsQUFBRSxDQUFDO1NBQzlCO0FBQ0QsWUFBSSxNQUFNLEdBQUcsVUFBQyxHQUFnQixFQUFFLE9BQVksRUFBQTtBQUMxQyxnQkFBSSxPQUFPLEdBQUcsT0FBTyxHQUFHLGFBbkZuQixNQUFNLENBbUZvQixFQUFFLEVBQUUsT0FBTyxFQUFFLElBQUksQ0FBQyxHQUFHLElBQUksQ0FBQztBQUN6RCxnQkFBSSxDQUFDLFdBQVcsRUFBRTtBQUNoQiwyQkFBVyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLENBQUM7YUFDakM7QUFDRCxtQkFBTyxRQUFRLENBQUMsV0FBVyxFQUFFLEVBQUUsRUFBRSxPQUFPLEVBQUUsR0FBRyxDQUFDLENBQUM7U0FDaEQsQ0FBQztBQUNGLGVBQU8sRUFBRSxFQUFFLEVBQUYsRUFBRSxFQUFFLElBQUksRUFBSixJQUFJLEVBQUUsTUFBTSxFQUFOLE1BQU0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nN5bWJvbHMpO1xuICAgIHJldHVybiB2bS5leGVjdXRlKGNvbXBpbGVkLm9wcyk7XG4gIH07XG4gIHJldHVybiB7IGlkLCBtZXRhLCBfYmxvY2s6IGJsb2NrLCBhc0VudHJ5UG9pbnQsIGFzTGF5b3V0LCBhc1BhcnRpYWwsIHJlbmRlciB9O1xufVxuIl19 -enifed('glimmer-runtime/lib/upsert', ['exports', 'glimmer-runtime/lib/bounds'], function (exports, _glimmerRuntimeLibBounds) { - 'use strict'; + computed.sum = _emberRuntime.sum; + computed.min = _emberRuntime.min; + computed.max = _emberRuntime.max; + computed.map = _emberRuntime.map; + computed.sort = _emberRuntime.sort; + computed.setDiff = _emberRuntime.setDiff; + computed.mapBy = _emberRuntime.mapBy; + computed.filter = _emberRuntime.filter; + computed.filterBy = _emberRuntime.filterBy; + computed.uniq = _emberRuntime.uniq; - exports.isSafeString = isSafeString; - exports.isNode = isNode; - exports.isString = isString; - exports.cautiousInsert = cautiousInsert; - exports.trustingInsert = trustingInsert; + computed.uniqBy = _emberRuntime.uniqBy; + computed.union = _emberRuntime.union; + computed.intersect = _emberRuntime.intersect; + computed.collect = _emberRuntime.collect; - function isSafeString(value) { - return value && typeof value['toHTML'] === 'function'; - } + /** + Defines the hash of localized strings for the current language. Used by + the `Ember.String.loc()` helper. To localize, add string values to this + hash. + + @property STRINGS + @for Ember + @type Object + @private + */ + Object.defineProperty(_emberMetal.default, 'STRINGS', { + configurable: false, + get: _emberRuntime.getStrings, + set: _emberRuntime.setStrings + }); - function isNode(value) { - return value !== null && typeof value === 'object' && typeof value['nodeType'] === 'number'; - } + /** + Whether searching on the global for new Namespace instances is enabled. + + This is only exported here as to not break any addons. Given the new + visit API, you will have issues if you treat this as a indicator of + booted. + + Internally this is only exposing a flag in Namespace. + + @property BOOTED + @for Ember + @type Boolean + @private + */ + Object.defineProperty(_emberMetal.default, 'BOOTED', { + configurable: false, + enumerable: false, + get: _emberRuntime.isNamespaceSearchDisabled, + set: _emberRuntime.setNamespaceSearchDisabled + }); - function isString(value) { - return typeof value === 'string'; - } + _emberMetal.default.Component = _emberGlimmer.Component; + _emberGlimmer.Helper.helper = _emberGlimmer.helper; + _emberMetal.default.Helper = _emberGlimmer.Helper; + _emberMetal.default.Checkbox = _emberGlimmer.Checkbox; + _emberMetal.default.TextField = _emberGlimmer.TextField; + _emberMetal.default.TextArea = _emberGlimmer.TextArea; + _emberMetal.default.LinkComponent = _emberGlimmer.LinkComponent; - var Upsert = function Upsert(bounds) { - this.bounds = bounds; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + String.prototype.htmlSafe = function () { + return _emberGlimmer.htmlSafe(this); }; + } - exports.default = Upsert; - - function cautiousInsert(dom, cursor, value) { - if (isString(value)) { - return TextUpsert.insert(dom, cursor, value); - } - if (isSafeString(value)) { - return SafeStringUpsert.insert(dom, cursor, value); - } - if (isNode(value)) { - return NodeUpsert.insert(dom, cursor, value); - } - } - - function trustingInsert(dom, cursor, value) { - if (isString(value)) { - return HTMLUpsert.insert(dom, cursor, value); - } - if (isNode(value)) { - return NodeUpsert.insert(dom, cursor, value); - } - } - - var TextUpsert = (function (_Upsert) { - babelHelpers.inherits(TextUpsert, _Upsert); + var EmberHandlebars = _emberMetal.default.Handlebars = _emberMetal.default.Handlebars || {}; + var EmberHTMLBars = _emberMetal.default.HTMLBars = _emberMetal.default.HTMLBars || {}; + var EmberHandleBarsUtils = EmberHandlebars.Utils = EmberHandlebars.Utils || {}; - function TextUpsert(bounds, textNode) { - _Upsert.call(this, bounds); - this.textNode = textNode; - } + Object.defineProperty(EmberHandlebars, 'SafeString', { + get: _emberGlimmer._getSafeString + }); - TextUpsert.insert = function insert(dom, cursor, value) { - var textNode = dom.createTextNode(value); - dom.insertBefore(cursor.element, textNode, cursor.nextSibling); - var bounds = new _glimmerRuntimeLibBounds.SingleNodeBounds(cursor.element, textNode); - return new TextUpsert(bounds, textNode); - }; + EmberHTMLBars.template = EmberHandlebars.template = _emberGlimmer.template; + EmberHandleBarsUtils.escapeExpression = _emberGlimmer.escapeExpression; + _emberRuntime.String.htmlSafe = _emberGlimmer.htmlSafe; - TextUpsert.prototype.update = function update(dom, value) { - if (isString(value)) { - var textNode = this.textNode; + _emberRuntime.String.isHTMLSafe = _emberGlimmer.isHTMLSafe; + EmberHTMLBars.makeBoundHelper = _emberGlimmer.makeBoundHelper; - textNode.nodeValue = value; - return true; - } else { - return false; - } - }; + /** + Global hash of shared templates. This will automatically be populated + by the build tools so that you can store your Handlebars templates in + separate files that get loaded into JavaScript at buildtime. + + @property TEMPLATES + @for Ember + @type Object + @private + */ + Object.defineProperty(_emberMetal.default, 'TEMPLATES', { + get: _emberGlimmer.getTemplates, + set: _emberGlimmer.setTemplates, + configurable: false, + enumerable: false + }); - return TextUpsert; - })(Upsert); + exports.VERSION = _emberVersion.default; - var HTMLUpsert = (function (_Upsert2) { - babelHelpers.inherits(HTMLUpsert, _Upsert2); + /** + The semantic version + @property VERSION + @type String + @public + */ + _emberMetal.default.VERSION = _emberVersion.default; - function HTMLUpsert() { - _Upsert2.apply(this, arguments); - } + _emberMetal.libraries.registerCoreLibrary('Ember', _emberVersion.default); - HTMLUpsert.insert = function insert(dom, cursor, value) { - var bounds = dom.insertHTMLBefore(cursor.element, value, cursor.nextSibling); - return new HTMLUpsert(bounds); - }; + _emberMetal.default.create = _emberMetal.deprecateFunc('Ember.create is deprecated in favor of Object.create', { id: 'ember-metal.ember-create', until: '3.0.0' }, Object.create); + _emberMetal.default.keys = _emberMetal.deprecateFunc('Ember.keys is deprecated in favor of Object.keys', { id: 'ember-metal.ember.keys', until: '3.0.0' }, Object.keys); - HTMLUpsert.prototype.update = function update(dom, value) { - if (isString(value)) { - var bounds = this.bounds; + // require the main entry points for each of these packages + // this is so that the global exports occur properly - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertHTMLBefore(parentElement, nextSibling, value); - return true; - } else { - return false; - } - }; + /** + Alias for jQuery + + @method $ + @for Ember + @public + */ + _emberMetal.default.$ = _emberViews.jQuery; - return HTMLUpsert; - })(Upsert); + _emberMetal.default.ViewTargetActionSupport = _emberViews.ViewTargetActionSupport; - var SafeStringUpsert = (function (_Upsert3) { - babelHelpers.inherits(SafeStringUpsert, _Upsert3); + _emberMetal.default.ViewUtils = { + isSimpleClick: _emberViews.isSimpleClick, + getViewElement: _emberViews.getViewElement, + getViewBounds: _emberViews.getViewBounds, + getViewClientRects: _emberViews.getViewClientRects, + getViewBoundingClientRect: _emberViews.getViewBoundingClientRect, + getRootViews: _emberViews.getRootViews, + getChildViews: _emberViews.getChildViews + }; - function SafeStringUpsert(bounds, lastStringValue) { - _Upsert3.call(this, bounds); - this.lastStringValue = lastStringValue; - } + _emberMetal.default.TextSupport = _emberViews.TextSupport; + _emberMetal.default.ComponentLookup = _emberViews.ComponentLookup; + _emberMetal.default.EventDispatcher = _emberViews.EventDispatcher; - SafeStringUpsert.insert = function insert(dom, cursor, value) { - var stringValue = value.toHTML(); - var bounds = dom.insertHTMLBefore(cursor.element, stringValue, cursor.nextSibling); - return new SafeStringUpsert(bounds, stringValue); - }; + _emberMetal.default.Location = _emberRouting.Location; + _emberMetal.default.AutoLocation = _emberRouting.AutoLocation; + _emberMetal.default.HashLocation = _emberRouting.HashLocation; + _emberMetal.default.HistoryLocation = _emberRouting.HistoryLocation; + _emberMetal.default.NoneLocation = _emberRouting.NoneLocation; + _emberMetal.default.controllerFor = _emberRouting.controllerFor; + _emberMetal.default.generateControllerFactory = _emberRouting.generateControllerFactory; + _emberMetal.default.generateController = _emberRouting.generateController; + _emberMetal.default.RouterDSL = _emberRouting.RouterDSL; + _emberMetal.default.Router = _emberRouting.Router; + _emberMetal.default.Route = _emberRouting.Route; - SafeStringUpsert.prototype.update = function update(dom, value) { - if (isSafeString(value)) { - var stringValue = value.toHTML(); - if (stringValue !== this.lastStringValue) { - var bounds = this.bounds; + _emberMetal.default.Application = _emberApplication.Application; + _emberMetal.default.ApplicationInstance = _emberApplication.ApplicationInstance; + _emberMetal.default.Engine = _emberApplication.Engine; + _emberMetal.default.EngineInstance = _emberApplication.EngineInstance; + _emberMetal.default.DefaultResolver = _emberMetal.default.Resolver = _emberApplication.Resolver; - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertHTMLBefore(parentElement, nextSibling, stringValue); - this.lastStringValue = stringValue; - } - return true; - } else { - return false; - } - }; + _emberRuntime.runLoadHooks('Ember.Application', _emberApplication.Application); - return SafeStringUpsert; - })(Upsert); + _emberMetal.default.DataAdapter = _emberExtensionSupport.DataAdapter; + _emberMetal.default.ContainerDebugAdapter = _emberExtensionSupport.ContainerDebugAdapter; - var NodeUpsert = (function (_Upsert4) { - babelHelpers.inherits(NodeUpsert, _Upsert4); + if (_require.has('ember-template-compiler')) { + _require.default('ember-template-compiler'); + } - function NodeUpsert() { - _Upsert4.apply(this, arguments); - } + // do this to ensure that Ember.Test is defined properly on the global + // if it is present. + if (_require.has('ember-testing')) { + var testing = _require.default('ember-testing'); - NodeUpsert.insert = function insert(dom, cursor, node) { - dom.insertBefore(cursor.element, node, cursor.nextSibling); - return new NodeUpsert(_glimmerRuntimeLibBounds.single(cursor.element, node)); - }; + _emberMetal.default.Test = testing.Test; + _emberMetal.default.Test.Adapter = testing.Adapter; + _emberMetal.default.Test.QUnitAdapter = testing.QUnitAdapter; + _emberMetal.default.setupForTesting = testing.setupForTesting; + } - NodeUpsert.prototype.update = function update(dom, value) { - if (isNode(value)) { - var bounds = this.bounds; + _emberRuntime.runLoadHooks('Ember'); - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertNodeBefore(parentElement, value, nextSibling); - return true; - } else { - return false; - } - }; + /** + @module ember + */ + exports.default = _emberMetal.default; - return NodeUpsert; - })(Upsert); + /* globals module */ + if (typeof module === 'object' && module.exports) { + module.exports = _emberMetal.default; + } else { + _emberEnvironment.context.exports.Ember = _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AgIGxldCBuZXh0U2libGluZyA9IGNsZWFyKGJvdW5kcyk7XG5cbiAgICAgIHRoaXMuYm91bmRzID0gZG9tLmluc2VydE5vZGVCZWZvcmUocGFyZW50RWxlbWVudCBhcyBGSVhfUkVJRklDQVRJT048RWxlbWVudD4sIHZhbHVlLCBuZXh0U2libGluZyBhcyBGSVhfUkVJRklDQVRJT048Tm9kZT4pO1xuXG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9IGVsc2Uge1xuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/utils', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; - - var EMPTY_ARRAY = Object.freeze([]); - exports.EMPTY_ARRAY = EMPTY_ARRAY; - var EMPTY_DICT = Object.freeze(_glimmerUtil.dict()); - exports.EMPTY_DICT = EMPTY_DICT; - - var ListRange = (function () { - function ListRange(list, start, end) { - this.list = list; - this.start = start; - this.end = end; - } - ListRange.prototype.at = function at(index) { - if (index >= this.list.length) return null; - return this.list[index]; - }; +// ****ember-environment**** - ListRange.prototype.min = function min() { - return this.start; - }; +// ****ember-metal**** - ListRange.prototype.max = function max() { - return this.end; - }; +// computed macros - return ListRange; - })(); +// reduced computed macros +enifed("ember/version", ["exports"], function (exports) { + "use strict"; - exports.ListRange = ListRange; + exports.default = "2.12.0-canary"; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRU8sUUFBTSxXQUFXLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQzs7QUFDdEMsUUFBTSxVQUFVLEdBQWMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxhQUhwQyxJQUFJLEVBRzJDLENBQUMsQ0FBQzs7O1FBb0JoRSxT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jaChjYWxsYmFjazogRW51bWVyYWJsZUNhbGxiYWNrPFQ+KTtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBEZXN0cm95YWJsZSB7XG4gIGRlc3Ryb3koKTtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBSYW5nZTxUPiB7XG4gIG1pbigpOiBudW1iZXI7XG4gIG1heCgpOiBudW1iZXI7XG4gIGF0KGluZGV4OiBudW1iZXIpOiBUO1xufVxuXG5leHBvcnQgY2xhc3MgTGlzdFJhbmdlPFQ+IGltcGxlbWVudHMgUmFuZ2U8VD4ge1xuICBwcml2YXRlIGxpc3Q6IFRbXTtcblxuICAvLyBbc3RhcnQsIGVuZF1cbiAgcHJpdmF0ZSBzdGFydDogbnVtYmVyO1xuICBwcml2YXRlIGVuZDogbnVtYmVyO1xuXG4gIGNvbnN0cnVjdG9yKGxpc3Q6IFRbXSwgc3RhcnQ6IG51bWJlciwgZW5kOiBudW1iZXIpIHtcbiAgICB0aGlzLmxpc3QgPSBsaXN0O1xuICAgIHRoaXMuc3RhcnQgPSBzdGFydDtcbiAgICB0aGlzLmVuZCA9IGVuZDtcbiAgfVxuXG4gIGF0KGluZGV4OiBudW1iZXIpOiBUIHtcbiAgICBpZiAoaW5kZXggPj0gdGhpcy5saXN0Lmxlbmd0aCkgcmV0dXJuIG51bGw7XG4gICAgcmV0dXJuIHRoaXMubGlzdFtpbmRleF07XG4gIH1cblxuICBtaW4oKTogbnVtYmVyIHtcbiAgICByZXR1cm4gdGhpcy5zdGFydDtcbiAgfVxuXG4gIG1heCgpOiBudW1iZXIge1xuICAgIHJldHVybiB0aGlzLmVuZDtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/vm', ['exports', 'glimmer-runtime/lib/vm/append', 'glimmer-runtime/lib/vm/update', 'glimmer-runtime/lib/vm/render-result'], function (exports, _glimmerRuntimeLibVmAppend, _glimmerRuntimeLibVmUpdate, _glimmerRuntimeLibVmRenderResult) { +enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; - exports.VM = _glimmerRuntimeLibVmAppend.default; - exports.PublicVM = _glimmerRuntimeLibVmAppend.PublicVM; - exports.UpdatingVM = _glimmerRuntimeLibVmUpdate.default; - exports.RenderResult = _glimmerRuntimeLibVmRenderResult.default; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1VBQW9CLEVBQUUsOEJBQWIsT0FBTztVQUFRLFFBQVEsOEJBQVIsUUFBUTtVQUNaLFVBQVUsOEJBQXJCLE9BQU87VUFDSSxZQUFZLG9DQUF2QixPQUFPIiwiZmlsZSI6InZtLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBWTSwgUHVibGljVk0gfSBmcm9tICcuL3ZtL2FwcGVuZCc7XG5leHBvcnQgeyBkZWZhdWx0IGFzIFVwZGF0aW5nVk0gfSBmcm9tICcuL3ZtL3VwZGF0ZSc7XG5leHBvcnQgeyBkZWZhdWx0IGFzIFJlbmRlclJlc3VsdCB9IGZyb20gJy4vdm0vcmVuZGVyLXJlc3VsdCc7XG4iXX0= -enifed('glimmer-runtime/lib/vm/append', ['exports', 'glimmer-runtime/lib/environment', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-runtime/lib/vm/update', 'glimmer-runtime/lib/vm/render-result', 'glimmer-runtime/lib/vm/frame'], function (exports, _glimmerRuntimeLibEnvironment, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerRuntimeLibVmUpdate, _glimmerRuntimeLibVmRenderResult, _glimmerRuntimeLibVmFrame) { - 'use strict'; - - var VM = (function () { - function VM(env, scope, dynamicScope, elementStack) { - this.env = env; - this.elementStack = elementStack; - this.dynamicScopeStack = new _glimmerUtil.Stack(); - this.scopeStack = new _glimmerUtil.Stack(); - this.updatingOpcodeStack = new _glimmerUtil.Stack(); - this.cacheGroups = new _glimmerUtil.Stack(); - this.listBlockStack = new _glimmerUtil.Stack(); - this.frame = new _glimmerRuntimeLibVmFrame.FrameStack(); - this.env = env; - this.elementStack = elementStack; - this.scopeStack.push(scope); - this.dynamicScopeStack.push(dynamicScope); - } - - VM.initial = function initial(env, self, dynamicScope, elementStack, size) { - var scope = _glimmerRuntimeLibEnvironment.Scope.root(self, size); - return new VM(env, scope, dynamicScope, elementStack); - }; - - VM.prototype.capture = function capture() { - return { - env: this.env, - scope: this.scope(), - dynamicScope: this.dynamicScope(), - frame: this.frame.capture() - }; - }; - - VM.prototype.goto = function goto(op) { - // assert(this.frame.getOps().contains(op), `Illegal jump to ${op.label}`); - this.frame.goto(op); - }; - - VM.prototype.beginCacheGroup = function beginCacheGroup() { - this.cacheGroups.push(this.updatingOpcodeStack.current.tail()); - }; - - VM.prototype.commitCacheGroup = function commitCacheGroup() { - // JumpIfNotModified(END) - // (head) - // (....) - // (tail) - // DidModify - // END: Noop - var END = new _glimmerRuntimeLibCompiledOpcodesVm.LabelOpcode("END"); - var opcodes = this.updatingOpcodeStack.current; - var marker = this.cacheGroups.pop(); - var head = marker ? opcodes.nextNode(marker) : opcodes.head(); - var tail = opcodes.tail(); - var tag = _glimmerReference.combineSlice(new _glimmerUtil.ListSlice(head, tail)); - var guard = new _glimmerRuntimeLibCompiledOpcodesVm.JumpIfNotModifiedOpcode(tag, END); - opcodes.insertBefore(guard, head); - opcodes.append(new _glimmerRuntimeLibCompiledOpcodesVm.DidModifyOpcode(guard)); - opcodes.append(END); - }; - - VM.prototype.enter = function enter(ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushUpdatableBlock(); - var state = this.capture(); - var tryOpcode = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, updating); - this.didEnter(tryOpcode, updating); - }; - - VM.prototype.enterWithKey = function enterWithKey(key, ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushUpdatableBlock(); - var state = this.capture(); - var tryOpcode = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, updating); - this.listBlockStack.current.map[key] = tryOpcode; - this.didEnter(tryOpcode, updating); - }; - - VM.prototype.enterList = function enterList(ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushBlockList(updating); - var state = this.capture(); - var artifacts = this.frame.getIterator().artifacts; - var opcode = new _glimmerRuntimeLibVmUpdate.ListBlockOpcode(ops, state, tracker, updating, artifacts); - this.listBlockStack.push(opcode); - this.didEnter(opcode, updating); - }; - - VM.prototype.didEnter = function didEnter(opcode, updating) { - this.updateWith(opcode); - this.updatingOpcodeStack.push(updating); - }; - - VM.prototype.exit = function exit() { - this.stack().popBlock(); - this.updatingOpcodeStack.pop(); - var parent = this.updatingOpcodeStack.current.tail(); - parent.didInitializeChildren(); - }; - - VM.prototype.exitList = function exitList() { - this.exit(); - this.listBlockStack.pop(); - }; - - VM.prototype.updateWith = function updateWith(opcode) { - this.updatingOpcodeStack.current.append(opcode); - }; - - VM.prototype.stack = function stack() { - return this.elementStack; - }; - - VM.prototype.scope = function scope() { - return this.scopeStack.current; - }; - - VM.prototype.dynamicScope = function dynamicScope() { - return this.dynamicScopeStack.current; - }; - - VM.prototype.pushFrame = function pushFrame(block, args, callerScope) { - this.frame.push(block.ops); - if (args) this.frame.setArgs(args); - if (args && args.blocks) this.frame.setBlocks(args.blocks); - if (callerScope) this.frame.setCallerScope(callerScope); - }; - - VM.prototype.pushComponentFrame = function pushComponentFrame(layout, args, callerScope, component, manager, shadow) { - this.frame.push(layout.ops, component, manager, shadow); - if (args) this.frame.setArgs(args); - if (args && args.blocks) this.frame.setBlocks(args.blocks); - if (callerScope) this.frame.setCallerScope(callerScope); - }; + exports.default = applyMixins; - VM.prototype.pushEvalFrame = function pushEvalFrame(ops) { - this.frame.push(ops); - }; + function isGenerator(mixin) { + return Array.isArray(mixin.cases) && typeof mixin.generate === 'function'; + } - VM.prototype.pushChildScope = function pushChildScope() { - this.scopeStack.push(this.scopeStack.current.child()); - }; + function applyMixins(TestClass) { + for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + mixins[_key - 1] = arguments[_key]; + } - VM.prototype.pushCallerScope = function pushCallerScope() { - this.scopeStack.push(this.scope().getCallerScope()); - }; + mixins.forEach(function (mixinOrGenerator) { + var mixin = undefined; - VM.prototype.pushDynamicScope = function pushDynamicScope() { - var child = this.dynamicScopeStack.current.child(); - this.dynamicScopeStack.push(child); - return child; - }; + if (isGenerator(mixinOrGenerator)) { + (function () { + var generator = mixinOrGenerator; + mixin = {}; - VM.prototype.pushRootScope = function pushRootScope(self, size) { - var scope = _glimmerRuntimeLibEnvironment.Scope.root(self, size); - this.scopeStack.push(scope); - return scope; - }; + generator.cases.forEach(function (value, idx) { + _emberUtils.assign(mixin, generator.generate(value, idx)); + }); + })(); + } else { + mixin = mixinOrGenerator; + } - VM.prototype.popScope = function popScope() { - this.scopeStack.pop(); - }; + _emberUtils.assign(TestClass.prototype, mixin); + }); - VM.prototype.popDynamicScope = function popDynamicScope() { - this.dynamicScopeStack.pop(); - }; + return TestClass; + } +}); +enifed('internal-test-helpers/build-owner', ['exports', 'container', 'ember-routing', 'ember-application', 'ember-metal', 'ember-runtime'], function (exports, _container, _emberRouting, _emberApplication, _emberMetal, _emberRuntime) { + 'use strict'; - VM.prototype.newDestroyable = function newDestroyable(d) { - this.stack().newDestroyable(d); - }; + exports.default = buildOwner; - /// SCOPE HELPERS + function buildOwner() { + var _EmberObject$extend; - VM.prototype.getSelf = function getSelf() { - return this.scope().getSelf(); - }; + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - VM.prototype.referenceForSymbol = function referenceForSymbol(symbol) { - return this.scope().getSymbol(symbol); - }; + var ownerOptions = options.ownerOptions || {}; + var resolver = options.resolver; + var bootOptions = options.bootOptions || {}; - VM.prototype.getArgs = function getArgs() { - return this.frame.getArgs(); - }; + var Owner = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, (_EmberObject$extend = {}, _EmberObject$extend[_container.FACTORY_FOR] = function () { + var _container__; - /// EXECUTION + return (_container__ = this.__container__)[_container.FACTORY_FOR].apply(_container__, arguments); + }, _EmberObject$extend[_container.LOOKUP_FACTORY] = function () { + var _container__2; - VM.prototype.resume = function resume(opcodes, frame) { - return this.execute(opcodes, function (vm) { - return vm.frame.restore(frame); - }); - }; + return (_container__2 = this.__container__)[_container.LOOKUP_FACTORY].apply(_container__2, arguments); + }, _EmberObject$extend)); - VM.prototype.execute = function execute(opcodes, initialize) { - _glimmerUtil.LOGGER.debug("[VM] Begin program execution"); - var elementStack = this.elementStack; - var frame = this.frame; - var updatingOpcodeStack = this.updatingOpcodeStack; - var env = this.env; - - elementStack.pushSimpleBlock(); - updatingOpcodeStack.push(new _glimmerUtil.LinkedList()); - frame.push(opcodes); - if (initialize) initialize(this); - var opcode = undefined; - while (frame.hasOpcodes()) { - if (opcode = frame.nextStatement()) { - _glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type); - _glimmerUtil.LOGGER.trace(opcode); - opcode.evaluate(this); - } - } - _glimmerUtil.LOGGER.debug("[VM] Completed program execution"); - return new _glimmerRuntimeLibVmRenderResult.default(env, updatingOpcodeStack.pop(), elementStack.popBlock()); - }; + if (true) { + Owner.reopen({ + factoryFor: function () { + var _container__3; - VM.prototype.evaluateOpcode = function evaluateOpcode(opcode) { - opcode.evaluate(this); - }; + return (_container__3 = this.__container__).factoryFor.apply(_container__3, arguments); + } + }); + } - // Make sure you have opcodes that push and pop a scope around this opcode - // if you need to change the scope. + var namespace = _emberRuntime.Object.create({ + Resolver: { create: function () { + return resolver; + } } + }); - VM.prototype.invokeBlock = function invokeBlock(block, args) { - var compiled = block.compile(this.env); - this.pushFrame(compiled, args); - }; + var fallbackRegistry = _emberApplication.Application.buildRegistry(namespace); + fallbackRegistry.register('router:main', _emberRouting.Router); - VM.prototype.invokePartial = function invokePartial(block) { - var compiled = block.compile(this.env); - this.pushFrame(compiled); - }; + var registry = new _container.Registry({ + fallback: fallbackRegistry + }); - VM.prototype.invokeLayout = function invokeLayout(args, layout, callerScope, component, manager, shadow) { - this.pushComponentFrame(layout, args, callerScope, component, manager, shadow); - }; + _emberApplication.ApplicationInstance.setupRegistry(registry, bootOptions); - VM.prototype.evaluateOperand = function evaluateOperand(expr) { - this.frame.setOperand(expr.evaluate(this)); - }; + var owner = Owner.create({ + __registry__: registry, + __container__: null + }, ownerOptions); - VM.prototype.evaluateArgs = function evaluateArgs(args) { - var evaledArgs = this.frame.setArgs(args.evaluate(this)); - this.frame.setOperand(evaledArgs.positional.at(0)); - }; + var container = registry.container({ owner: owner }); + owner.__container__ = container; - VM.prototype.bindPositionalArgs = function bindPositionalArgs(symbols) { - var args = this.frame.getArgs(); - _glimmerUtil.assert(args, "Cannot bind positional args"); - var positional = args.positional; + return owner; + } +}); +enifed('internal-test-helpers/confirm-export', ['exports', 'require'], function (exports, _require) { + 'use strict'; - var scope = this.scope(); - for (var i = 0; i < symbols.length; i++) { - scope.bindSymbol(symbols[i], positional.at(i)); - } - }; + exports.default = confirmExport; - VM.prototype.bindNamedArgs = function bindNamedArgs(names, symbols) { - var args = this.frame.getArgs(); - var scope = this.scope(); - _glimmerUtil.assert(args, "Cannot bind named args"); - var named = args.named; + function getDescriptor(obj, path) { + var parts = path.split('.'); + var value = obj; + for (var i = 0; i < parts.length - 1; i++) { + var part = parts[i]; + value = value[part]; + if (!value) { + return undefined; + } + } + var last = parts[parts.length - 1]; + return Object.getOwnPropertyDescriptor(value, last); + } - for (var i = 0; i < names.length; i++) { - scope.bindSymbol(symbols[i], named.get(names[i])); - } - }; + function confirmExport(Ember, assert, path, moduleId, exportName) { + var desc = getDescriptor(Ember, path); + assert.ok(desc, 'the property exists on the global'); - VM.prototype.bindBlocks = function bindBlocks(names, symbols) { - var blocks = this.frame.getBlocks(); - var scope = this.scope(); - for (var i = 0; i < names.length; i++) { - scope.bindBlock(symbols[i], blocks && blocks[names[i]] || null); - } - }; + var mod = _require.default(moduleId); + if (typeof exportName === 'string') { + assert.equal(desc.value, mod[exportName], 'Ember.' + path + ' is exported correctly'); + assert.notEqual(mod[exportName], undefined, 'Ember.' + path + ' is not `undefined`'); + } else { + assert.equal(desc.get, mod[exportName.get], 'Ember.' + path + ' getter is exported correctly'); + assert.notEqual(desc.get, undefined, 'Ember.' + path + ' getter is not undefined'); - VM.prototype.bindPartialArgs = function bindPartialArgs(symbol) { - var args = this.frame.getArgs(); - var scope = this.scope(); - _glimmerUtil.assert(args, "Cannot bind named args"); - scope.bindPartialArgs(symbol, args); - }; + if (exportName.set) { + assert.equal(desc.set, mod[exportName.set], 'Ember.' + path + ' setter is exported correctly'); + assert.notEqual(desc.set, undefined, 'Ember.' + path + ' setter is not undefined'); + } + } + } +}); +enifed('internal-test-helpers/equal-inner-html', ['exports'], function (exports) { + // detect side-effects of cloning svg elements in IE9-11 + 'use strict'; - VM.prototype.bindCallerScope = function bindCallerScope() { - var callerScope = this.frame.getCallerScope(); - var scope = this.scope(); - _glimmerUtil.assert(callerScope, "Cannot bind caller scope"); - scope.bindCallerScope(callerScope); - }; + exports.default = equalInnerHTML; + var ieSVGInnerHTML = (function () { + if (!document.createElementNS) { + return false; + } + var div = document.createElement('div'); + var node = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + div.appendChild(node); + var clone = div.cloneNode(true); + return clone.innerHTML === ''; + })(); - VM.prototype.bindDynamicScope = function bindDynamicScope(names) { - var args = this.frame.getArgs(); - var scope = this.dynamicScope(); - _glimmerUtil.assert(args, "Cannot bind dynamic scope"); - for (var i = 0; i < names.length; i++) { - scope.set(names[i], args.named.get(names[i])); - } - }; + function normalizeInnerHTML(actualHTML) { + if (ieSVGInnerHTML) { + // Replace `` with ``, etc. + // drop namespace attribute + actualHTML = actualHTML.replace(/ xmlns="[^"]+"/, ''); + // replace self-closing elements + actualHTML = actualHTML.replace(/<([^ >]+) [^\/>]*\/>/gi, function (tag, tagName) { + return tag.slice(0, tag.length - 3) + '>'; + }); + } - return VM; - })(); + return actualHTML; + } - exports.default = VM; + function equalInnerHTML(fragment, html) { + var actualHTML = normalizeInnerHTML(fragment.innerHTML); + QUnit.push(actualHTML === html, actualHTML, html); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vYXBwZW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQXlCQSxFQUFBO0FBbUJFLGlCQW5CRixFQUFBLENBb0JXLEdBQWdCLEVBQ3ZCLEtBQVksRUFDWixZQUEwQixFQUNsQixZQUEwQixFQUFBO0FBSDNCLGdCQUFBLENBQUEsR0FBRyxHQUFILEdBQUcsQ0FBYTtBQUdmLGdCQUFBLENBQUEsWUFBWSxHQUFaLFlBQVksQ0FBYztBQXRCNUIsZ0JBQUEsQ0FBQSxpQkFBaUIsR0FBRyxpQkF4QlIsS0FBSyxFQXdCNEIsQ0FBQztBQUM5QyxnQkFBQSxDQUFBLFVBQVUsR0FBRyxpQkF6QkQsS0FBSyxFQXlCYyxDQUFDO0FBQ2pDLGdCQUFBLENBQUEsbUJBQW1CLEdBQUcsaUJBMUJULEtBQUssRUEwQjJDLENBQUM7QUFDOUQsZ0JBQUEsQ0FBQSxXQUFXLEdBQUcsaUJBM0JELEtBQUssRUEyQnVCLENBQUM7QUFDMUMsZ0JBQUEsQ0FBQSxjQUFjLEdBQUcsaUJBNUJKLEtBQUssRUE0QjJCLENBQUM7QUFDOUMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUcsOEJBbEJPLFVBQVUsRUFrQkQsQ0FBQztBQW1COUIsZ0JBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO0FBQ2YsZ0JBQUksQ0FBQyxZQUFZLEdBQ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clNjb3BlKGNhbGxlclNjb3BlKTtcbiAgfVxuXG4gIGJpbmREeW5hbWljU2NvcGUobmFtZXM6IHN0cmluZ1tdKSB7XG4gICAgbGV0IGFyZ3MgPSB0aGlzLmZyYW1lLmdldEFyZ3MoKTtcbiAgICBsZXQgc2NvcGUgPSB0aGlzLmR5bmFtaWNTY29wZSgpO1xuXG4gICAgYXNzZXJ0KGFyZ3MsIFwiQ2Fubm90IGJpbmQgZHluYW1pYyBzY29wZVwiKTtcblxuICAgIGZvcihsZXQgaT0wOyBpIDwgbmFtZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgIHNjb3BlLnNldChuYW1lc1tpXSwgYXJncy5uYW1lZC5nZXQobmFtZXNbaV0pKTtcbiAgICB9XG4gIH1cbn1cblxuaW50ZXJmYWNlIEV4Y2VwdGlvbkhhbmRsZXIge1xuICBoYW5kbGVFeGNlcHRpb24oaW5pdGlhbGl6ZT86ICh2bTogVk0pID0+IHZvaWQpO1xufVxuXG5pbnRlcmZhY2UgUmV0dXJuSGFuZGxlciB7XG4gIHNldFJlbmRlclJlc3VsdChyZW5kZXJSZXN1bHQ6IFJlbmRlclJlc3VsdCk7XG59XG4iXX0= -enifed('glimmer-runtime/lib/vm/frame', ['exports'], function (exports) { - 'use strict'; - - var CapturedFrame = function CapturedFrame(operand, args, condition) { - this.operand = operand; - this.args = args; - this.condition = condition; - }; - - exports.CapturedFrame = CapturedFrame; - - var Frame = (function () { - function Frame(ops) { - var component = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - var manager = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - var shadow = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; - - this.component = component; - this.manager = manager; - this.shadow = shadow; - this.operand = null; - this.immediate = null; - this.args = null; - this.callerScope = null; - this.blocks = null; - this.condition = null; - this.iterator = null; - this.key = null; - this.ops = ops; - this.op = ops.head(); - } - - Frame.prototype.capture = function capture() { - return new CapturedFrame(this.operand, this.args, this.condition); - }; - - Frame.prototype.restore = function restore(frame) { - this.operand = frame['operand']; - this.args = frame['args']; - this.condition = frame['condition']; - }; +enifed('internal-test-helpers/equal-tokens', ['exports', 'simple-html-tokenizer'], function (exports, _simpleHtmlTokenizer) { + 'use strict'; - return Frame; - })(); + exports.default = equalTokens; - var FrameStack = (function () { - function FrameStack() { - this.frames = []; - this.frame = undefined; - } + function generateTokens(containerOrHTML) { + if (typeof containerOrHTML === 'string') { + return { + tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML), + html: containerOrHTML + }; + } else { + return { + tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML.innerHTML), + html: containerOrHTML.innerHTML + }; + } + } - FrameStack.prototype.push = function push(ops) { - var component = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - var manager = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - var shadow = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + function normalizeTokens(tokens) { + tokens.forEach(function (token) { + if (token.type === 'StartTag') { + token.attributes = token.attributes.sort(function (a, b) { + if (a[0] > b[0]) { + return 1; + } + if (a[0] < b[0]) { + return -1; + } + return 0; + }); + } + }); + } - var frame = this.frame === undefined ? this.frame = 0 : ++this.frame; - if (this.frames.length <= frame) { - this.frames.push(null); - } - this.frames[frame] = new Frame(ops, component, manager, shadow); - }; + function equalTokens(actualContainer, expectedHTML) { + var message = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - FrameStack.prototype.pop = function pop() { - var frames = this.frames; - var frame = this.frame; + var actual = generateTokens(actualContainer); + var expected = generateTokens(expectedHTML); - frames[frame] = null; - this.frame = frame === 0 ? undefined : frame - 1; - }; + normalizeTokens(actual.tokens); + normalizeTokens(expected.tokens); - FrameStack.prototype.capture = function capture() { - return this.frames[this.frame].capture(); - }; + var equiv = QUnit.equiv(actual.tokens, expected.tokens); - FrameStack.prototype.restore = function restore(frame) { - this.frames[this.frame].restore(frame); - }; + if (equiv && expected.html !== actual.html) { + deepEqual(actual.tokens, expected.tokens, message); + } else { + QUnit.push(QUnit.equiv(actual.tokens, expected.tokens), actual.html, expected.html, message); + } + } +}); +enifed('internal-test-helpers/factory', ['exports'], function (exports) { + 'use strict'; - FrameStack.prototype.getOps = function getOps() { - return this.frames[this.frame].ops; - }; + exports.default = factory; + function setProperties(object, properties) { + for (var key in properties) { + if (properties.hasOwnProperty(key)) { + object[key] = properties[key]; + } + } + } - FrameStack.prototype.getCurrent = function getCurrent() { - return this.frames[this.frame].op; - }; + var guids = 0; - FrameStack.prototype.setCurrent = function setCurrent(op) { - return this.frames[this.frame].op = op; - }; + function factory() { + /*jshint validthis: true */ - FrameStack.prototype.getOperand = function getOperand() { - return this.frames[this.frame].operand; - }; + function Klass(options) { + setProperties(this, options); + this._guid = guids++; + this.isDestroyed = false; + } - FrameStack.prototype.setOperand = function setOperand(operand) { - return this.frames[this.frame].operand = operand; - }; + Klass.prototype.constructor = Klass; + Klass.prototype.destroy = function () { + this.isDestroyed = true; + }; - FrameStack.prototype.getImmediate = function getImmediate() { - return this.frames[this.frame].immediate; - }; + Klass.prototype.toString = function () { + return ''; + }; - FrameStack.prototype.setImmediate = function setImmediate(value) { - return this.frames[this.frame].immediate = value; - }; + Klass.create = create; + Klass.extend = extend; + Klass.reopen = extend; + Klass.reopenClass = reopenClass; - FrameStack.prototype.getArgs = function getArgs() { - return this.frames[this.frame].args; - }; + return Klass; - FrameStack.prototype.setArgs = function setArgs(args) { - var frame = this.frames[this.frame]; - return frame.args = args; - }; + function create(options) { + return new this.prototype.constructor(options); + } - FrameStack.prototype.getCondition = function getCondition() { - return this.frames[this.frame].condition; - }; + function reopenClass(options) { + setProperties(this, options); + } - FrameStack.prototype.setCondition = function setCondition(condition) { - return this.frames[this.frame].condition = condition; - }; + function extend(options) { + function Child(options) { + Klass.call(this, options); + } - FrameStack.prototype.getIterator = function getIterator() { - return this.frames[this.frame].iterator; - }; + var Parent = this; - FrameStack.prototype.setIterator = function setIterator(iterator) { - return this.frames[this.frame].iterator = iterator; - }; + Child.prototype = new Parent(); + Child.prototype.constructor = Child; - FrameStack.prototype.getKey = function getKey() { - return this.frames[this.frame].key; - }; + setProperties(Child, Klass); + setProperties(Child.prototype, options); - FrameStack.prototype.setKey = function setKey(key) { - return this.frames[this.frame].key = key; - }; + Child.create = create; + Child.extend = extend; + Child.reopen = extend; - FrameStack.prototype.getBlocks = function getBlocks() { - return this.frames[this.frame].blocks; - }; + Child.reopenClass = reopenClass; - FrameStack.prototype.setBlocks = function setBlocks(blocks) { - return this.frames[this.frame].blocks = blocks; - }; + return Child; + } + } +}); +enifed('internal-test-helpers/index', ['exports', 'internal-test-helpers/factory', 'internal-test-helpers/build-owner', 'internal-test-helpers/confirm-export', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/module-for', 'internal-test-helpers/strip', 'internal-test-helpers/apply-mixins', 'internal-test-helpers/matchers', 'internal-test-helpers/run', 'internal-test-helpers/test-groups', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/test-cases/abstract-application', 'internal-test-helpers/test-cases/application', 'internal-test-helpers/test-cases/query-param', 'internal-test-helpers/test-cases/abstract-rendering', 'internal-test-helpers/test-cases/rendering', 'internal-test-helpers/test-cases/router'], function (exports, _internalTestHelpersFactory, _internalTestHelpersBuildOwner, _internalTestHelpersConfirmExport, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersModuleFor, _internalTestHelpersStrip, _internalTestHelpersApplyMixins, _internalTestHelpersMatchers, _internalTestHelpersRun, _internalTestHelpersTestGroups, _internalTestHelpersTestCasesAbstract, _internalTestHelpersTestCasesAbstractApplication, _internalTestHelpersTestCasesApplication, _internalTestHelpersTestCasesQueryParam, _internalTestHelpersTestCasesAbstractRendering, _internalTestHelpersTestCasesRendering, _internalTestHelpersTestCasesRouter) { + 'use strict'; - FrameStack.prototype.getCallerScope = function getCallerScope() { - return this.frames[this.frame].callerScope; - }; + exports.factory = _internalTestHelpersFactory.default; + exports.buildOwner = _internalTestHelpersBuildOwner.default; + exports.confirmExport = _internalTestHelpersConfirmExport.default; + exports.equalInnerHTML = _internalTestHelpersEqualInnerHtml.default; + exports.equalTokens = _internalTestHelpersEqualTokens.default; + exports.moduleFor = _internalTestHelpersModuleFor.default; + exports.strip = _internalTestHelpersStrip.default; + exports.applyMixins = _internalTestHelpersApplyMixins.default; + exports.equalsElement = _internalTestHelpersMatchers.equalsElement; + exports.classes = _internalTestHelpersMatchers.classes; + exports.styles = _internalTestHelpersMatchers.styles; + exports.regex = _internalTestHelpersMatchers.regex; + exports.runAppend = _internalTestHelpersRun.runAppend; + exports.runDestroy = _internalTestHelpersRun.runDestroy; + exports.testBoth = _internalTestHelpersTestGroups.testBoth; + exports.testWithDefault = _internalTestHelpersTestGroups.testWithDefault; + exports.AbstractTestCase = _internalTestHelpersTestCasesAbstract.default; + exports.AbstractApplicationTestCase = _internalTestHelpersTestCasesAbstractApplication.default; + exports.ApplicationTestCase = _internalTestHelpersTestCasesApplication.default; + exports.QueryParamTestCase = _internalTestHelpersTestCasesQueryParam.default; + exports.AbstractRenderingTestCase = _internalTestHelpersTestCasesAbstractRendering.default; + exports.RenderingTestCase = _internalTestHelpersTestCasesRendering.default; + exports.RouterTestCase = _internalTestHelpersTestCasesRouter.default; +}); +enifed('internal-test-helpers/matchers', ['exports'], function (exports) { + 'use strict'; - FrameStack.prototype.setCallerScope = function setCallerScope(callerScope) { - return this.frames[this.frame].callerScope = callerScope; - }; + exports.regex = regex; + exports.classes = classes; + exports.styles = styles; + exports.equalsElement = equalsElement; + var HTMLElement = window.HTMLElement; + var MATCHER_BRAND = '3d4ef194-13be-4ccf-8dc7-862eea02c93e'; - FrameStack.prototype.getComponent = function getComponent() { - return this.frames[this.frame].component; - }; + function isMatcher(obj) { + return typeof obj === 'object' && obj !== null && MATCHER_BRAND in obj; + } - FrameStack.prototype.getManager = function getManager() { - return this.frames[this.frame].manager; - }; + function equalsAttr(expected) { + var _ref; - FrameStack.prototype.getShadow = function getShadow() { - return this.frames[this.frame].shadow; - }; + return _ref = {}, _ref[MATCHER_BRAND] = true, _ref.match = function (actual) { + return expected === actual; + }, _ref.expected = function () { + return expected; + }, _ref.message = function () { + return 'should equal ' + this.expected(); + }, _ref; + } - FrameStack.prototype.goto = function goto(op) { - this.setCurrent(op); - }; + function regex(r) { + var _ref2; - FrameStack.prototype.hasOpcodes = function hasOpcodes() { - return this.frame !== undefined; - }; + return _ref2 = {}, _ref2[MATCHER_BRAND] = true, _ref2.match = function (v) { + return r.test(v); + }, _ref2.expected = function () { + return r.toString(); + }, _ref2.message = function () { + return 'should match ' + this.expected(); + }, _ref2; + } - FrameStack.prototype.nextStatement = function nextStatement() { - var op = this.frames[this.frame].op; - var ops = this.getOps(); - if (op) { - this.setCurrent(ops.nextNode(op)); - return op; - } else { - this.pop(); - return null; - } - }; + function classes(expected) { + var _ref3; - return FrameStack; - })(); + return _ref3 = {}, _ref3[MATCHER_BRAND] = true, _ref3.match = function (actual) { + actual = actual.trim(); + return actual && expected.split(/\s+/).sort().join(' ') === actual.trim().split(/\s+/).sort().join(' '); + }, _ref3.expected = function () { + return expected; + }, _ref3.message = function () { + return 'should match ' + this.expected(); + }, _ref3; + } - exports.FrameStack = FrameStack; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vZnJhbWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBUUEsYUFBQSxHQUNFLFNBREYsYUFBQSxDQUVZLE9BQTJCLEVBQzNCLElBQW1CLEVBQ25CLFNBQTZCLEVBQUE7QUFGN0IsWUFBQSxDQUFBLE9BQU8sR0FBUCxPQUFPLENBQW9CO0FBQzNCLFlBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFlO0FBQ25CLFlBQUEsQ0FBQSxTQUFTLEdBQVQsU0FBUyxDQUFvQjtLQUNuQzs7OztRQU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YXNPcGNvZGVzKCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLmZyYW1lICE9PSB1bmRlZmluZWQ7XG4gIH1cblxuICBuZXh0U3RhdGVtZW50KCk6IE9wY29kZSB7XG4gICAgbGV0IG9wID0gdGhpcy5mcmFtZXNbdGhpcy5mcmFtZV0ub3A7XG4gICAgbGV0IG9wcyA9IHRoaXMuZ2V0T3BzKCk7XG5cbiAgICBpZiAob3ApIHtcbiAgICAgIHRoaXMuc2V0Q3VycmVudChvcHMubmV4dE5vZGUob3ApKTtcbiAgICAgIHJldHVybiBvcDtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhpcy5wb3AoKTtcbiAgICAgIHJldHVybiBudWxsO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/vm/render-result', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/vm/update'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibVmUpdate) { - 'use strict'; + function styles(expected) { + var _ref4; - var RenderResult = (function () { - function RenderResult(env, updating, bounds) { - this.env = env; - this.updating = updating; - this.bounds = bounds; - } + return _ref4 = {}, _ref4[MATCHER_BRAND] = true, _ref4.match = function (actual) { + // coerce `null` or `undefined` to an empty string + // needed for matching empty styles on IE9 - IE11 + actual = actual || ''; + actual = actual.trim(); - RenderResult.prototype.rerender = function rerender() { - var _ref = arguments.length <= 0 || arguments[0] === undefined ? { alwaysRevalidate: false } : arguments[0]; + return expected.split(';').map(function (s) { + return s.trim(); + }).filter(function (s) { + return s; + }).sort().join('; ') === actual.split(';').map(function (s) { + return s.trim(); + }).filter(function (s) { + return s; + }).sort().join('; '); + }, _ref4.expected = function () { + return expected; + }, _ref4.message = function () { + return 'should match ' + this.expected(); + }, _ref4; + } - var _ref$alwaysRevalidate = _ref.alwaysRevalidate; - var alwaysRevalidate = _ref$alwaysRevalidate === undefined ? false : _ref$alwaysRevalidate; - var env = this.env; - var updating = this.updating; + function equalsElement(element, tagName, attributes, content) { + QUnit.push(element.tagName === tagName.toUpperCase(), element.tagName.toLowerCase(), tagName, 'expect tagName to be ' + tagName); - var vm = new _glimmerRuntimeLibVmUpdate.default(env, { alwaysRevalidate: alwaysRevalidate }); - vm.execute(updating, this); - }; + var expectedAttrs = {}; + var expectedCount = 0; - RenderResult.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + for (var _name in attributes) { + var expected = attributes[_name]; + if (expected !== null) { + expectedCount++; + } - RenderResult.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + var matcher = isMatcher(expected) ? expected : equalsAttr(expected); - RenderResult.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + expectedAttrs[_name] = matcher; - RenderResult.prototype.opcodes = function opcodes() { - return this.updating; - }; + QUnit.push(expectedAttrs[_name].match(element.getAttribute(_name)), element.getAttribute(_name), matcher.expected(), 'Element\'s ' + _name + ' attribute ' + matcher.message()); + } - RenderResult.prototype.handleException = function handleException() { - throw "this should never happen"; - }; + var actualAttributes = {}; - RenderResult.prototype.destroy = function destroy() { - this.bounds.destroy(); - _glimmerRuntimeLibBounds.clear(this.bounds); - }; + for (var i = 0, l = element.attributes.length; i < l; i++) { + actualAttributes[element.attributes[i].name] = element.attributes[i].value; + } - return RenderResult; - })(); + if (!(element instanceof HTMLElement)) { + QUnit.push(element instanceof HTMLElement, null, null, 'Element must be an HTML Element, not an SVG Element'); + } else { + QUnit.push(element.attributes.length === expectedCount || !attributes, element.attributes.length, expectedCount, 'Expected ' + expectedCount + ' attributes; got ' + element.outerHTML); - exports.default = RenderResult; + if (content !== null) { + QUnit.push(element.innerHTML === content, element.innerHTML, content, 'The element had \'' + content + '\' as its content'); + } + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vcmVuZGVyLXJlc3VsdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UU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T4sXG4gICAgcHJpdmF0ZSBib3VuZHM6IERlc3Ryb3lhYmxlQm91bmRzXG4gICkge31cblxuICByZXJlbmRlcih7IGFsd2F5c1JldmFsaWRhdGUgPSBmYWxzZSB9ID0geyBhbHdheXNSZXZhbGlkYXRlOiBmYWxzZSB9KSB7XG4gICAgbGV0IHsgZW52LCB1cGRhdGluZyB9ID0gdGhpcztcbiAgICBsZXQgdm0gPSBuZXcgVXBkYXRpbmdWTShlbnYsIHsgYWx3YXlzUmV2YWxpZGF0ZSB9KTtcbiAgICB2bS5leGVjdXRlKHVwZGF0aW5nLCB0aGlzKTtcbiAgfVxuXG4gIHBhcmVudEVsZW1lbnQoKTogU2ltcGxlLkVsZW1lbnQge1xuICAgIHJldHVybiB0aGlzLmJvdW5kcy5wYXJlbnRFbGVtZW50KCk7XG4gIH1cblxuICBmaXJzdE5vZGUoKTogU2ltcGxlLk5vZGUge1xuICAgIHJldHVybiB0aGlzLmJvdW5kcy5maXJzdE5vZGUoKTtcbiAgfVxuXG4gIGxhc3ROb2RlKCk6IFNpbXBsZS5Ob2RlIHtcbiAgICByZXR1cm4gdGhpcy5ib3VuZHMubGFzdE5vZGUoKTtcbiAgfVxuXG4gIG9wY29kZXMoKTogTGlua2VkTGlzdDxVcGRhdGluZ09wY29kZT4ge1xuICAgIHJldHVybiB0aGlzLnVwZGF0aW5nO1xuICB9XG5cbiAgaGFuZGxlRXhjZXB0aW9uKCkge1xuICAgIHRocm93IFwidGhpcyBzaG91bGQgbmV2ZXIgaGFwcGVuXCI7XG4gIH1cblxuICBkZXN0cm95KCkge1xuICAgIHRoaXMuYm91bmRzLmRlc3Ryb3koKTtcbiAgICBjbGVhcih0aGlzLmJvdW5kcyk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/vm/update', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/builder', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/vm/append'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibBuilder, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibVmAppend) { - 'use strict'; +enifed('internal-test-helpers/module-for', ['exports', 'internal-test-helpers/apply-mixins'], function (exports, _internalTestHelpersApplyMixins) { + 'use strict'; - var UpdatingVM = (function () { - function UpdatingVM(env, _ref) { - var _ref$alwaysRevalidate = _ref.alwaysRevalidate; - var alwaysRevalidate = _ref$alwaysRevalidate === undefined ? false : _ref$alwaysRevalidate; + exports.default = moduleFor; - this.frameStack = new _glimmerUtil.Stack(); - this.env = env; - this.dom = env.getDOM(); - this.alwaysRevalidate = alwaysRevalidate; - } + function moduleFor(description, TestClass) { + var context = undefined; - UpdatingVM.prototype.execute = function execute(opcodes, handler) { - var frameStack = this.frameStack; + QUnit.module(description, { + setup: function () { + context = new TestClass(); + }, - this.try(opcodes, handler); - while (true) { - if (frameStack.isEmpty()) break; - var opcode = this.frameStack.current.nextStatement(); - if (opcode === null) { - this.frameStack.pop(); - continue; - } - _glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type); - _glimmerUtil.LOGGER.trace(opcode); - opcode.evaluate(this); - } - }; + teardown: function () { + context.teardown(); + } + }); - UpdatingVM.prototype.goto = function goto(op) { - this.frameStack.current.goto(op); - }; + for (var _len = arguments.length, mixins = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + mixins[_key - 2] = arguments[_key]; + } - UpdatingVM.prototype.try = function _try(ops, handler) { - this.frameStack.push(new UpdatingVMFrame(this, ops, handler)); - }; + _internalTestHelpersApplyMixins.default(TestClass, mixins); - UpdatingVM.prototype.throw = function _throw() { - this.frameStack.current.handleException(); - this.frameStack.pop(); - }; + var proto = TestClass.prototype; - UpdatingVM.prototype.evaluateOpcode = function evaluateOpcode(opcode) { - opcode.evaluate(this); - }; + while (proto !== Object.prototype) { + Object.keys(proto).forEach(generateTest); + proto = Object.getPrototypeOf(proto); + } - return UpdatingVM; - })(); + function generateTest(name) { + if (name.indexOf('@test ') === 0) { + QUnit.test(name.slice(5), function (assert) { + return context[name](assert); + }); + } else if (name.indexOf('@skip ') === 0) { + QUnit.skip(name.slice(5), function (assert) { + return context[name](assert); + }); + } + } + } +}); +enifed('internal-test-helpers/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - exports.default = UpdatingVM; + exports.runAppend = runAppend; + exports.runDestroy = runDestroy; - var BlockOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(BlockOpcode, _UpdatingOpcode); + function runAppend(view) { + _emberMetal.run(view, 'appendTo', '#qunit-fixture'); + } - function BlockOpcode(ops, state, bounds, children) { - _UpdatingOpcode.call(this); - this.type = "block"; - this.next = null; - this.prev = null; - var env = state.env; - var scope = state.scope; - var dynamicScope = state.dynamicScope; - var frame = state.frame; + function runDestroy(toDestroy) { + if (toDestroy) { + _emberMetal.run(toDestroy, 'destroy'); + } + } +}); +enifed('internal-test-helpers/strip', ['exports'], function (exports) { + 'use strict'; - this.ops = ops; - this.children = children; - this.env = env; - this.scope = scope; - this.dynamicScope = dynamicScope; - this.frame = frame; - this.bounds = bounds; - } + exports.default = strip; - BlockOpcode.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + function strip(_ref) { + for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + values[_key - 1] = arguments[_key]; + } - BlockOpcode.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + var strings = _ref; - BlockOpcode.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + var str = strings.map(function (string, index) { + var interpolated = values[index]; + return string + (interpolated !== undefined ? interpolated : ''); + }).join(''); + return str.split('\n').map(function (s) { + return s.trim(); + }).join(''); + } +}); +enifed('internal-test-helpers/test-cases/abstract-application', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-routing', 'ember-template-compiler', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/run'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberRouting, _emberTemplateCompiler, _internalTestHelpersTestCasesAbstract, _internalTestHelpersRun) { + 'use strict'; - BlockOpcode.prototype.evaluate = function evaluate(vm) { - vm.try(this.children, null); - }; + var AbstractApplicationTestCase = (function (_AbstractTestCase) { + babelHelpers.inherits(AbstractApplicationTestCase, _AbstractTestCase); - BlockOpcode.prototype.destroy = function destroy() { - this.bounds.destroy(); - }; + function AbstractApplicationTestCase() { + babelHelpers.classCallCheck(this, AbstractApplicationTestCase); - BlockOpcode.prototype.didDestroy = function didDestroy() { - this.env.didDestroy(this.bounds); - }; + _AbstractTestCase.call(this); - BlockOpcode.prototype.toJSON = function toJSON() { - var begin = this.ops.head(); - var end = this.ops.tail(); - var details = _glimmerUtil.dict(); - details["guid"] = '' + this._guid; - details["begin"] = begin.inspect(); - details["end"] = end.inspect(); - return { - guid: this._guid, - type: this.type, - details: details, - children: this.children.toArray().map(function (op) { - return op.toJSON(); - }) - }; - }; + this.element = _emberViews.jQuery('#qunit-fixture')[0]; - return BlockOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + this.application = _emberMetal.run(_emberApplication.Application, 'create', this.applicationOptions); - exports.BlockOpcode = BlockOpcode; + this.router = this.application.Router = _emberRouting.Router.extend(this.routerOptions); - var TryOpcode = (function (_BlockOpcode) { - babelHelpers.inherits(TryOpcode, _BlockOpcode); + this.applicationInstance = null; + } - function TryOpcode(ops, state, bounds, children) { - _BlockOpcode.call(this, ops, state, bounds, children); - this.type = "try"; - this.tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - } + AbstractApplicationTestCase.prototype.teardown = function teardown() { + if (this.applicationInstance) { + _internalTestHelpersRun.runDestroy(this.applicationInstance); + } - TryOpcode.prototype.didInitializeChildren = function didInitializeChildren() { - this._tag.update(_glimmerReference.combineSlice(this.children)); - }; + _internalTestHelpersRun.runDestroy(this.application); + }; - TryOpcode.prototype.evaluate = function evaluate(vm) { - vm.try(this.children, this); - }; + AbstractApplicationTestCase.prototype.visit = function visit(url, options) { + var _this = this; - TryOpcode.prototype.handleException = function handleException() { - var env = this.env; - var scope = this.scope; - var ops = this.ops; - var dynamicScope = this.dynamicScope; - var frame = this.frame; - - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.resume(this.env, this.bounds, this.bounds.reset(env)); - var vm = new _glimmerRuntimeLibVmAppend.default(env, scope, dynamicScope, elementStack); - var result = vm.resume(ops, frame); - this.children = result.opcodes(); - this.didInitializeChildren(); - }; + var applicationInstance = this.applicationInstance; - TryOpcode.prototype.toJSON = function toJSON() { - var json = _BlockOpcode.prototype.toJSON.call(this); - var begin = this.ops.head(); - var end = this.ops.tail(); - json["details"]["begin"] = JSON.stringify(begin.inspect()); - json["details"]["end"] = JSON.stringify(end.inspect()); - return _BlockOpcode.prototype.toJSON.call(this); - }; + if (applicationInstance) { + return _emberMetal.run(applicationInstance, 'visit', url, options); + } else { + return _emberMetal.run(this.application, 'visit', url, options).then(function (instance) { + _this.applicationInstance = instance; + }); + } + }; - return TryOpcode; - })(BlockOpcode); + AbstractApplicationTestCase.prototype.transitionTo = function transitionTo() { + return _emberMetal.run.apply(undefined, [this.appRouter, 'transitionTo'].concat(babelHelpers.slice.call(arguments))); + }; - exports.TryOpcode = TryOpcode; + AbstractApplicationTestCase.prototype.compile = function compile(string, options) { + return _emberTemplateCompiler.compile.apply(undefined, arguments); + }; - var ListRevalidationDelegate = (function () { - function ListRevalidationDelegate(opcode, marker) { - this.opcode = opcode; - this.marker = marker; - this.didInsert = false; - this.didDelete = false; - this.map = opcode.map; - this.updating = opcode['children']; - } + AbstractApplicationTestCase.prototype.registerRoute = function registerRoute(name, route) { + this.application.register('route:' + name, route); + }; - ListRevalidationDelegate.prototype.insert = function insert(key, item, memo, before) { - var map = this.map; - var opcode = this.opcode; - var updating = this.updating; + AbstractApplicationTestCase.prototype.registerTemplate = function registerTemplate(name, template) { + this.application.register('template:' + name, this.compile(template, { + moduleName: name + })); + }; - var nextSibling = null; - var reference = null; - if (before) { - reference = map[before]; - nextSibling = reference.bounds.firstNode(); - } else { - nextSibling = this.marker; - } - var vm = opcode.vmForInsertion(nextSibling); - var tryOpcode = undefined; - vm.execute(opcode.ops, function (vm) { - vm.frame.setArgs(_glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs.positional([item, memo])); - vm.frame.setOperand(item); - vm.frame.setCondition(new _glimmerReference.ConstReference(true)); - vm.frame.setKey(key); - var state = vm.capture(); - var tracker = vm.stack().pushUpdatableBlock(); - tryOpcode = new TryOpcode(opcode.ops, state, tracker, vm.updatingOpcodeStack.current); - }); - tryOpcode.didInitializeChildren(); - updating.insertBefore(tryOpcode, reference); - map[key] = tryOpcode; - this.didInsert = true; - }; + AbstractApplicationTestCase.prototype.registerComponent = function registerComponent(name, _ref) { + var _ref$ComponentClass = _ref.ComponentClass; + var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; - ListRevalidationDelegate.prototype.retain = function retain(key, item, memo) {}; + if (ComponentClass) { + this.application.register('component:' + name, ComponentClass); + } - ListRevalidationDelegate.prototype.move = function move(key, item, memo, before) { - var map = this.map; - var updating = this.updating; + if (typeof template === 'string') { + this.application.register('template:components/' + name, this.compile(template, { + moduleName: 'components/' + name + })); + } + }; - var entry = map[key]; - var reference = map[before] || null; - if (before) { - _glimmerRuntimeLibBounds.move(entry, reference.firstNode()); - } else { - _glimmerRuntimeLibBounds.move(entry, this.marker); - } - updating.remove(entry); - updating.insertBefore(entry, reference); - }; + AbstractApplicationTestCase.prototype.registerController = function registerController(name, controller) { + this.application.register('controller:' + name, controller); + }; - ListRevalidationDelegate.prototype.delete = function _delete(key) { - var map = this.map; + AbstractApplicationTestCase.prototype.registerEngine = function registerEngine(name, engine) { + this.application.register('engine:' + name, engine); + }; - var opcode = map[key]; - opcode.didDestroy(); - _glimmerRuntimeLibBounds.clear(opcode); - this.updating.remove(opcode); - delete map[key]; - this.didDelete = true; + babelHelpers.createClass(AbstractApplicationTestCase, [{ + key: 'applicationOptions', + get: function () { + return { + rootElement: '#qunit-fixture', + autoboot: false }; - - ListRevalidationDelegate.prototype.done = function done() { - this.opcode.didInitializeChildren(this.didInsert || this.didDelete); + } + }, { + key: 'routerOptions', + get: function () { + return { + location: 'none' }; + } + }, { + key: 'appRouter', + get: function () { + return this.applicationInstance.lookup('router:main'); + } + }]); + return AbstractApplicationTestCase; + })(_internalTestHelpersTestCasesAbstract.default); - return ListRevalidationDelegate; - })(); - - var ListBlockOpcode = (function (_BlockOpcode2) { - babelHelpers.inherits(ListBlockOpcode, _BlockOpcode2); - - function ListBlockOpcode(ops, state, bounds, children, artifacts) { - _BlockOpcode2.call(this, ops, state, bounds, children); - this.type = "list-block"; - this.map = _glimmerUtil.dict(); - this.lastIterated = _glimmerReference.INITIAL; - this.artifacts = artifacts; - var _tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([artifacts.tag, _tag]); - } + exports.default = AbstractApplicationTestCase; +}); +enifed('internal-test-helpers/test-cases/abstract-rendering', ['exports', 'ember-utils', 'ember-template-compiler', 'ember-views', 'ember-glimmer', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/build-owner', 'internal-test-helpers/run'], function (exports, _emberUtils, _emberTemplateCompiler, _emberViews, _emberGlimmer, _internalTestHelpersTestCasesAbstract, _internalTestHelpersBuildOwner, _internalTestHelpersRun) { + 'use strict'; - ListBlockOpcode.prototype.didInitializeChildren = function didInitializeChildren() { - var listDidChange = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; + var TextNode = window.Text; - this.lastIterated = this.artifacts.tag.value(); - if (listDidChange) { - this._tag.update(_glimmerReference.combineSlice(this.children)); - } - }; + var AbstractRenderingTestCase = (function (_AbstractTestCase) { + babelHelpers.inherits(AbstractRenderingTestCase, _AbstractTestCase); - ListBlockOpcode.prototype.evaluate = function evaluate(vm) { - var artifacts = this.artifacts; - var lastIterated = this.lastIterated; - - if (!artifacts.tag.validate(lastIterated)) { - var bounds = this.bounds; - var dom = vm.dom; - - var marker = dom.createComment(''); - dom.insertAfter(bounds.parentElement(), marker, bounds.lastNode()); - var target = new ListRevalidationDelegate(this, marker); - var synchronizer = new _glimmerReference.IteratorSynchronizer({ target: target, artifacts: artifacts }); - synchronizer.sync(); - this.parentElement().removeChild(marker); - } - // Run now-updated updating opcodes - _BlockOpcode2.prototype.evaluate.call(this, vm); - }; + function AbstractRenderingTestCase() { + babelHelpers.classCallCheck(this, AbstractRenderingTestCase); - ListBlockOpcode.prototype.vmForInsertion = function vmForInsertion(nextSibling) { - var env = this.env; - var scope = this.scope; - var dynamicScope = this.dynamicScope; + _AbstractTestCase.call(this); + var owner = this.owner = _internalTestHelpersBuildOwner.default({ + ownerOptions: this.getOwnerOptions(), + bootOptions: this.getBootOptions(), + resolver: this.getResolver() + }); - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.forInitialRender(this.env, this.bounds.parentElement(), nextSibling); - return new _glimmerRuntimeLibVmAppend.default(env, scope, dynamicScope, elementStack); - }; + this.renderer = this.owner.lookup('renderer:-dom'); + this.element = _emberViews.jQuery('#qunit-fixture')[0]; + this.component = null; - ListBlockOpcode.prototype.toJSON = function toJSON() { - var json = _BlockOpcode2.prototype.toJSON.call(this); - var map = this.map; - var inner = Object.keys(map).map(function (key) { - return JSON.stringify(key) + ': ' + map[key]._guid; - }).join(", "); - json["details"]["map"] = '{' + inner + '}'; - return json; - }; + owner.register('event_dispatcher:main', _emberViews.EventDispatcher); + owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); + owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); + } - return ListBlockOpcode; - })(BlockOpcode); + AbstractRenderingTestCase.prototype.compile = function compile() { + return _emberTemplateCompiler.compile.apply(undefined, arguments); + }; - exports.ListBlockOpcode = ListBlockOpcode; + AbstractRenderingTestCase.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { + return {}; + }; - var UpdatingVMFrame = (function () { - function UpdatingVMFrame(vm, ops, handler) { - this.vm = vm; - this.ops = ops; - this.current = ops.head(); - this.exceptionHandler = handler; - } + AbstractRenderingTestCase.prototype.getOwnerOptions = function getOwnerOptions() {}; - UpdatingVMFrame.prototype.goto = function goto(op) { - this.current = op; - }; + AbstractRenderingTestCase.prototype.getBootOptions = function getBootOptions() {}; - UpdatingVMFrame.prototype.nextStatement = function nextStatement() { - var current = this.current; - var ops = this.ops; + AbstractRenderingTestCase.prototype.getResolver = function getResolver() {}; - if (current) this.current = ops.nextNode(current); - return current; - }; + AbstractRenderingTestCase.prototype.teardown = function teardown() { + if (this.component) { + _internalTestHelpersRun.runDestroy(this.component); + } + if (this.owner) { + _internalTestHelpersRun.runDestroy(this.owner); + } + }; - UpdatingVMFrame.prototype.handleException = function handleException() { - this.exceptionHandler.handleException(); - }; + AbstractRenderingTestCase.prototype.render = function render(templateStr) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var owner = this.owner; - return UpdatingVMFrame; - })(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vdXBkYXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQTRCQSxVQUFBO0FBTUUsaUJBTkYsVUFBQSxDQU1jLEdBQWdCLEVBQUUsSUFBNEIsRUFBQTt3Q0FBNUIsSUFBNEIsQ0FBMUIsZ0JBQWdCO2dCQUFoQixnQkFBZ0IseUNBQUcsS0FBSzs7QUFGaEQsZ0JBQUEsQ0FBQSxVQUFVLEdBQTJCLGlCQTdCdEIsS0FBSyxFQTZCNkMsQ0FBQztBQUd4RSxnQkFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQ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7XG4gICAgaWYgKGN1cnJlbnQpIHRoaXMuY3VycmVudCA9IG9wcy5uZXh0Tm9kZShjdXJyZW50KTtcbiAgICByZXR1cm4gY3VycmVudDtcbiAgfVxuXG4gIGhhbmRsZUV4Y2VwdGlvbigpIHtcbiAgICB0aGlzLmV4Y2VwdGlvbkhhbmRsZXIuaGFuZGxlRXhjZXB0aW9uKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-util/index', ['exports', 'glimmer-util/lib/namespaces', 'glimmer-util/lib/platform-utils', 'glimmer-util/lib/assert', 'glimmer-util/lib/logger', 'glimmer-util/lib/object-utils', 'glimmer-util/lib/guid', 'glimmer-util/lib/collections', 'glimmer-util/lib/list-utils'], function (exports, _glimmerUtilLibNamespaces, _glimmerUtilLibPlatformUtils, _glimmerUtilLibAssert, _glimmerUtilLibLogger, _glimmerUtilLibObjectUtils, _glimmerUtilLibGuid, _glimmerUtilLibCollections, _glimmerUtilLibListUtils) { - 'use strict'; + owner.register('template:-top-level', this.compile(templateStr, { + moduleName: '-top-level' + })); - exports.getAttrNamespace = _glimmerUtilLibNamespaces.getAttrNamespace; - exports.Option = _glimmerUtilLibPlatformUtils.Option; - exports.Maybe = _glimmerUtilLibPlatformUtils.Maybe; - exports.Opaque = _glimmerUtilLibPlatformUtils.Opaque; - exports.assert = _glimmerUtilLibAssert.default; - exports.LOGGER = _glimmerUtilLibLogger.default; - exports.Logger = _glimmerUtilLibLogger.Logger; - exports.LogLevel = _glimmerUtilLibLogger.LogLevel; - exports.assign = _glimmerUtilLibObjectUtils.assign; - exports.ensureGuid = _glimmerUtilLibGuid.ensureGuid; - exports.initializeGuid = _glimmerUtilLibGuid.initializeGuid; - exports.HasGuid = _glimmerUtilLibGuid.HasGuid; - exports.Stack = _glimmerUtilLibCollections.Stack; - exports.Dict = _glimmerUtilLibCollections.Dict; - exports.Set = _glimmerUtilLibCollections.Set; - exports.DictSet = _glimmerUtilLibCollections.DictSet; - exports.dict = _glimmerUtilLibCollections.dict; - exports.EMPTY_SLICE = _glimmerUtilLibListUtils.EMPTY_SLICE; - exports.LinkedList = _glimmerUtilLibListUtils.LinkedList; - exports.LinkedListNode = _glimmerUtilLibListUtils.LinkedListNode; - exports.ListNode = _glimmerUtilLibListUtils.ListNode; - exports.CloneableListNode = _glimmerUtilLibListUtils.CloneableListNode; - exports.ListSlice = _glimmerUtilLibListUtils.ListSlice; - exports.Slice = _glimmerUtilLibListUtils.Slice; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFJUyxnQkFBZ0IsNkJBQWhCLGdCQUFnQjtVQUNoQixNQUFNLGdDQUFOLE1BQU07VUFBRSxLQUFLLGdDQUFMLEtBQUs7VUFBRSxNQUFNLGdDQUFOLE1BQU07VUFDVixNQUFNLHlCQUFqQixPQUFPO1VBQ0ksTUFBTSx5QkFBakIsT0FBTztVQUFZLE1BQU0seUJBQU4sTUFBTTtVQUFFLFFBQVEseUJBQVIsUUFBUTtVQUVuQyxNQUFNLDhCQUFOLE1BQU07VUFDTixVQUFVLHVCQUFWLFVBQVU7VUFBRSxjQUFjLHVCQUFkLGNBQWM7VUFBRSxPQUFPLHVCQUFQLE9BQU87VUFFbkMsS0FBSyw4QkFBTCxLQUFLO1VBQUUsSUFBSSw4QkFBSixJQUFJO1VBQUUsR0FBRyw4QkFBSCxHQUFHO1VBQUUsT0FBTyw4QkFBUCxPQUFPO1VBQUUsSUFBSSw4QkFBSixJQUFJO1VBQy9CLFdBQVcsNEJBQVgsV0FBVztVQUFFLFVBQVUsNEJBQVYsVUFBVTtVQUFFLGNBQWMsNEJBQWQsY0FBYztVQUFFLFFBQVEsNEJBQVIsUUFBUTtVQUFFLGlCQUFpQiw0QkFBakIsaUJBQWlCO1VBQUUsU0FBUyw0QkFBVCxTQUFTO1VBQUUsS0FBSyw0QkFBTCxLQUFLIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGludGVyZmFjZSBEZXN0cm95YWJsZSB7XG4gIGRlc3Ryb3koKTtcbn1cblxuZXhwb3J0IHsgZ2V0QXR0ck5hbWVzcGFjZSB9IGZyb20gJy4vbGliL25hbWVzcGFjZXMnO1xuZXhwb3J0IHsgT3B0aW9uLCBNYXliZSwgT3BhcXVlIH0gZnJvbSAnLi9saWIvcGxhdGZvcm0tdXRpbHMnO1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBhc3NlcnQgfSBmcm9tICcuL2xpYi9hc3NlcnQnO1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBMT0dHRVIsIExvZ2dlciwgTG9nTGV2ZWwgfSBmcm9tICcuL2xpYi9sb2dnZXInO1xuXG5leHBvcnQgeyBhc3NpZ24gfSBmcm9tICcuL2xpYi9vYmplY3QtdXRpbHMnO1xuZXhwb3J0IHsgZW5zdXJlR3VpZCwgaW5pdGlhbGl6ZUd1aWQsIEhhc0d1aWQgfSBmcm9tICcuL2xpYi9ndWlkJztcblxuZXhwb3J0IHsgU3RhY2ssIERpY3QsIFNldCwgRGljdFNldCwgZGljdCB9IGZyb20gJy4vbGliL2NvbGxlY3Rpb25zJztcbmV4cG9ydCB7IEVNUFRZX1NMSUNFLCBMaW5rZWRMaXN0LCBMaW5rZWRMaXN0Tm9kZSwgTGlzdE5vZGUsIENsb25lYWJsZUxpc3ROb2RlLCBMaXN0U2xpY2UsIFNsaWNlIH0gZnJvbSAnLi9saWIvbGlzdC11dGlscyc7XG5cbmV4cG9ydCB0eXBlIEZJWE1FPFQsIHN0cmluZz4gPSBUO1xuIl19 -enifed("glimmer-util/lib/assert", ["exports"], function (exports) { - // import Logger from './logger'; - // let alreadyWarned = false; - "use strict"; + var attrs = _emberUtils.assign({}, context, { + tagName: '', + layoutName: '-top-level' + }); - exports.debugAssert = debugAssert; - exports.prodAssert = prodAssert; + owner.register('component:-top-level', _emberGlimmer.Component.extend(attrs)); - function debugAssert(test, msg) { - // if (!alreadyWarned) { - // alreadyWarned = true; - // Logger.warn("Don't leave debug assertions on in public builds"); - // } - if (!test) { - throw new Error(msg || "assertion failure"); - } - } + this.component = owner.lookup('component:-top-level'); - function prodAssert() {} + _internalTestHelpersRun.runAppend(this.component); + }; - exports.default = debugAssert; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvYXNzZXJ0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBSUEsYUFBQSxXQUFBLENBQTRCLElBQUksRUFBRSxHQUFHLEVBQUE7Ozs7O0FBTW5DLFlBQUksQ0FBQyxJQUFJLEVBQUU7QUFDVCxrQkFBTSxJQUFJLEtBQUssQ0FBQyxHQUFHLElBQUksbUJBQW1CLENBQUMsQ0FBQztTQUM3QztLQUNGOztBQUVELGFBQUEsVUFBQSxHQUFBLEVBQStCOztzQkFFaEIsV0FBVyIsImZpbGUiOiJhc3NlcnQuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBpbXBvcnQgTG9nZ2VyIGZyb20gJy4vbG9nZ2VyJztcblxuLy8gbGV0IGFscmVhZHlXYXJuZWQgPSBmYWxzZTtcblxuZXhwb3J0IGZ1bmN0aW9uIGRlYnVnQXNzZXJ0KHRlc3QsIG1zZykge1xuICAvLyBpZiAoIWFscmVhZHlXYXJuZWQpIHtcbiAgLy8gICBhbHJlYWR5V2FybmVkID0gdHJ1ZTtcbiAgLy8gICBMb2dnZXIud2FybihcIkRvbid0IGxlYXZlIGRlYnVnIGFzc2VydGlvbnMgb24gaW4gcHVibGljIGJ1aWxkc1wiKTtcbiAgLy8gfVxuXG4gIGlmICghdGVzdCkge1xuICAgIHRocm93IG5ldyBFcnJvcihtc2cgfHwgXCJhc3NlcnRpb24gZmFpbHVyZVwiKTtcbiAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gcHJvZEFzc2VydCgpIHt9XG5cbmV4cG9ydCBkZWZhdWx0IGRlYnVnQXNzZXJ0O1xuIl19 -enifed('glimmer-util/lib/collections', ['exports', 'glimmer-util/lib/guid'], function (exports, _glimmerUtilLibGuid) { - 'use strict'; + AbstractRenderingTestCase.prototype.rerender = function rerender() { + this.component.rerender(); + }; - exports.dict = dict; + AbstractRenderingTestCase.prototype.registerHelper = function registerHelper(name, funcOrClassBody) { + var type = typeof funcOrClassBody; - var proto = Object.create(null, { - // without this, we will always still end up with (new - // EmptyObject()).constructor === Object - constructor: { - value: undefined, - enumerable: false, - writable: true - } - }); - function EmptyObject() {} - EmptyObject.prototype = proto; + if (type === 'function') { + this.owner.register('helper:' + name, _emberGlimmer.helper(funcOrClassBody)); + } else if (type === 'object' && type !== null) { + this.owner.register('helper:' + name, _emberGlimmer.Helper.extend(funcOrClassBody)); + } else { + throw new Error('Cannot register ' + funcOrClassBody + ' as a helper'); + } + }; - function dict() { - // let d = Object.create(null); - // d.x = 1; - // delete d.x; - // return d; - return new EmptyObject(); - } + AbstractRenderingTestCase.prototype.registerPartial = function registerPartial(name, template) { + var owner = this.env.owner || this.owner; + if (typeof template === 'string') { + var moduleName = 'template:' + name; + owner.register(moduleName, this.compile(template, { moduleName: moduleName })); + } + }; - var DictSet = (function () { - function DictSet() { - this.dict = dict(); - } + AbstractRenderingTestCase.prototype.registerComponent = function registerComponent(name, _ref) { + var _ref$ComponentClass = _ref.ComponentClass; + var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; + var owner = this.owner; - DictSet.prototype.add = function add(obj) { - if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[_glimmerUtilLibGuid.ensureGuid(obj)] = obj; - return this; - }; + if (ComponentClass) { + owner.register('component:' + name, ComponentClass); + } - DictSet.prototype.delete = function _delete(obj) { - if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; - }; + if (typeof template === 'string') { + owner.register('template:components/' + name, this.compile(template, { + moduleName: 'components/' + name + })); + } + }; - DictSet.prototype.forEach = function forEach(callback) { - var dict = this.dict; + AbstractRenderingTestCase.prototype.registerTemplate = function registerTemplate(name, template) { + var owner = this.owner; - Object.keys(dict).forEach(function (key) { - return callback(dict[key]); - }); - }; + if (typeof template === 'string') { + owner.register('template:' + name, this.compile(template, { + moduleName: name + })); + } else { + throw new Error('Registered template "' + name + '" must be a string'); + } + }; - DictSet.prototype.toArray = function toArray() { - return Object.keys(this.dict); - }; + AbstractRenderingTestCase.prototype.registerService = function registerService(name, klass) { + this.owner.register('service:' + name, klass); + }; - return DictSet; - })(); + AbstractRenderingTestCase.prototype.assertTextNode = function assertTextNode(node, text) { + if (!(node instanceof TextNode)) { + throw new Error('Expecting a text node, but got ' + node); + } - exports.DictSet = DictSet; + this.assert.strictEqual(node.textContent, text, 'node.textContent'); + }; - var Stack = (function () { - function Stack() { - this.stack = []; - this.current = null; - } + babelHelpers.createClass(AbstractRenderingTestCase, [{ + key: 'context', + get: function () { + return this.component; + } + }]); + return AbstractRenderingTestCase; + })(_internalTestHelpersTestCasesAbstract.default); - Stack.prototype.push = function push(item) { - this.current = item; - this.stack.push(item); - }; + exports.default = AbstractRenderingTestCase; +}); +enifed('internal-test-helpers/test-cases/abstract', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/matchers'], function (exports, _emberUtils, _emberMetal, _emberViews, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersMatchers) { + 'use strict'; - Stack.prototype.pop = function pop() { - var item = this.stack.pop(); - var len = this.stack.length; - this.current = len === 0 ? null : this.stack[len - 1]; - return item; - }; + var TextNode = window.Text; + var HTMLElement = window.HTMLElement; + var Comment = window.Comment; - Stack.prototype.isEmpty = function isEmpty() { - return this.stack.length === 0; - }; + function isMarker(node) { + if (node instanceof Comment && node.textContent === '') { + return true; + } - return Stack; - })(); + if (node instanceof TextNode && node.textContent === '') { + return true; + } - exports.Stack = Stack; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvY29sbGVjdGlvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFZQSxRQUFJLEtBQUssR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRTs7O0FBRzlCLG1CQUFXLEVBQUU7QUFDWCxpQkFBSyxFQUFFLFNBQVM7QUFDaEIsc0JBQVUsRUFBRSxLQUFLO0FBQ2pCLG9CQUFRLEVBQUUsSUFBSTtTQUNmO0tBQ0YsQ0FBQyxDQUFDO0FBRUgsYUFBQSxXQUFBLEdBQUEsRUFBeUI7QUFDekIsZUFBVyxDQUFDLFNBQVMsR0FBRyxLQUFLLENBQUM7O0FBRTlCLGFBQUEsSUFBQSxHQUFBOzs7OztBQUtFLGVBQU8sSUFBSSxXQUFXLEVBQUUsQ0FBQztLQUMxQjs7UUFJRCxPQUFBO0FBR0UsaUJBSEYsT0FBQSxHQUdFO0FBQ0UsZ0JBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxFQUFLLENBQUM7U0FDdkI7O0FBTEgsZUFBQSxXQU9FLEdBQUcsR0FBQSxhQUFDLEdBQU0sRUFBQTtBQUNSLGdCQUFJLE9BQU8sR0FBRyxLQUFLLFFBQVEsRUFBRSxJQUFJLENBQUMsSUFBSSxDQUFNLEdBQUcsQ0FBQyxHQUFHLEdBQUcsQ0FBQyxLQUNsRCxJQUFJLENBQUMsSUFBSSxDQUFDLG9CQTVDRCxVQUFVLENBNENPLEdBQUcsQ0FBQyxDQUFDLEdBQUcsR0FBRyxDQUFDO0FBQzNDLG1CQUFPLElBQUksQ0FBQztTQUNiOztBQVhILGVBQUEsV0FhRSxNQUFNLEdBQUEsaUJBQUMsR0F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GlzO1xuICAgIE9iamVjdC5rZXlzKGRpY3QpLmZvckVhY2goa2V5ID0+IGNhbGxiYWNrKGRpY3Rba2V5XSkpO1xuICB9XG5cbiAgdG9BcnJheSgpOiBzdHJpbmdbXSB7XG4gICAgcmV0dXJuIE9iamVjdC5rZXlzKHRoaXMuZGljdCk7XG4gIH1cbn1cblxuZXhwb3J0IGNsYXNzIFN0YWNrPFQ+IHtcbiAgcHJpdmF0ZSBzdGFjazogVFtdID0gW107XG4gIHB1YmxpYyBjdXJyZW50OiBUID0gbnVsbDtcblxuICBwdXNoKGl0ZW06IFQpIHtcbiAgICB0aGlzLmN1cnJlbnQgPSBpdGVtO1xuICAgIHRoaXMuc3RhY2sucHVzaChpdGVtKTtcbiAgfVxuXG4gIHBvcCgpOiBUIHtcbiAgICBsZXQgaXRlbSA9IHRoaXMuc3RhY2sucG9wKCk7XG4gICAgbGV0IGxlbiA9IHRoaXMuc3RhY2subGVuZ3RoO1xuICAgIHRoaXMuY3VycmVudCA9IGxlbiA9PT0gMCA/IG51bGwgOiB0aGlzLnN0YWNrW2xlbiAtIDFdO1xuXG4gICAgcmV0dXJuIGl0ZW07XG4gIH1cblxuICBpc0VtcHR5KCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLnN0YWNrLmxlbmd0aCA9PT0gMDtcbiAgfVxufVxuIl19 -enifed("glimmer-util/lib/guid", ["exports"], function (exports) { - "use strict"; + return false; + } - exports.initializeGuid = initializeGuid; - exports.ensureGuid = ensureGuid; - var GUID = 0; + var AbstractTestCase = (function () { + function AbstractTestCase() { + babelHelpers.classCallCheck(this, AbstractTestCase); - function initializeGuid(object) { - return object._guid = ++GUID; + this.element = null; + this.snapshot = null; + this.assert = QUnit.config.current.assert; } - function ensureGuid(object) { - return object._guid || initializeGuid(object); - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvZ3VpZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLFFBQUksSUFBSSxHQUFHLENBQUMsQ0FBQzs7QUFNYixhQUFBLGNBQUEsQ0FBK0IsTUFBZSxFQUFBO0FBQzVDLGVBQVEsTUFBTSxDQUFDLEtBQUssR0FBRyxFQUFFLElBQUksQ0FBRTtLQUNoQzs7QUFFRCxhQUFBLFVBQUEsQ0FBMkIsTUFBZSxFQUFBO0FBQ3hDLGVBQU8sTUFBTSxDQUFDLEtBQUssSUFBSSxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7S0FDL0MiLCJmaWxlIjoiZ3VpZC5qcyIsInNvdXJjZXNDb250ZW50IjpbImxldCBHVUlEID0gMDtcblxuZXhwb3J0IGludGVyZmFjZSBIYXNHdWlkIHtcbiAgX2d1aWQ6IG51bWJlcjtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGluaXRpYWxpemVHdWlkKG9iamVjdDogSGFzR3VpZCk6IG51bWJlciB7XG4gIHJldHVybiAob2JqZWN0Ll9ndWlkID0gKytHVUlEKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGVuc3VyZUd1aWQob2JqZWN0OiBIYXNHdWlkKTogbnVtYmVyIHtcbiAgcmV0dXJuIG9iamVjdC5fZ3VpZCB8fCBpbml0aWFsaXplR3VpZChvYmplY3QpO1xufSJdfQ== -enifed("glimmer-util/lib/list-utils", ["exports"], function (exports) { - "use strict"; + AbstractTestCase.prototype.teardown = function teardown() {}; - var ListNode = function ListNode(value) { - this.next = null; - this.prev = null; - this.value = value; + AbstractTestCase.prototype.runTask = function runTask(callback) { + _emberMetal.run(callback); }; - exports.ListNode = ListNode; + AbstractTestCase.prototype.runTaskNext = function runTaskNext(callback) { + _emberMetal.run.next(callback); + }; - var LinkedList = (function () { - function LinkedList() { - this.clear(); - } + // The following methods require `this.element` to work - LinkedList.fromSlice = function fromSlice(slice) { - var list = new LinkedList(); - slice.forEachNode(function (n) { - return list.append(n.clone()); - }); - return list; - }; + AbstractTestCase.prototype.nthChild = function nthChild(n) { + var i = 0; + var node = this.element.firstChild; - LinkedList.prototype.head = function head() { - return this._head; - }; + while (node) { + if (!isMarker(node)) { + i++; + } - LinkedList.prototype.tail = function tail() { - return this._tail; - }; + if (i > n) { + break; + } else { + node = node.nextSibling; + } + } - LinkedList.prototype.clear = function clear() { - this._head = this._tail = null; - }; + return node; + }; - LinkedList.prototype.isEmpty = function isEmpty() { - return this._head === null; - }; + AbstractTestCase.prototype.$ = function $(sel) { + return sel ? _emberViews.jQuery(sel, this.element) : _emberViews.jQuery(this.element); + }; - LinkedList.prototype.toArray = function toArray() { - var out = []; - this.forEachNode(function (n) { - return out.push(n); - }); - return out; - }; + AbstractTestCase.prototype.textValue = function textValue() { + return this.$().text(); + }; - LinkedList.prototype.splice = function splice(start, end, reference) { - var before = undefined; - if (reference === null) { - before = this._tail; - this._tail = end; - } else { - before = reference.prev; - end.next = reference; - reference.prev = end; - } - if (before) { - before.next = start; - start.prev = before; - } - }; + AbstractTestCase.prototype.takeSnapshot = function takeSnapshot() { + var snapshot = this.snapshot = []; - LinkedList.prototype.spliceList = function spliceList(list, reference) { - if (list.isEmpty()) return; - this.splice(list.head(), list.tail(), reference); - }; + var node = this.element.firstChild; - LinkedList.prototype.nextNode = function nextNode(node) { - return node.next; - }; + while (node) { + if (!isMarker(node)) { + snapshot.push(node); + } - LinkedList.prototype.prevNode = function prevNode(node) { - return node.prev; - }; + node = node.nextSibling; + } - LinkedList.prototype.forEachNode = function forEachNode(callback) { - var node = this._head; - while (node !== null) { - callback(node); - node = node.next; - } - }; + return snapshot; + }; - LinkedList.prototype.contains = function contains(needle) { - var node = this._head; - while (node !== null) { - if (node === needle) return true; - node = node.next; - } - return false; - }; + AbstractTestCase.prototype.assertText = function assertText(text) { + this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content should be: `' + text + '`'); + }; - LinkedList.prototype.insertBefore = function insertBefore(node) { - var reference = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + AbstractTestCase.prototype.assertInnerHTML = function assertInnerHTML(html) { + _internalTestHelpersEqualInnerHtml.default(this.element, html); + }; - if (reference === null) return this.append(node); - if (reference.prev) reference.prev.next = node;else this._head = node; - node.prev = reference.prev; - node.next = reference; - reference.prev = node; - return node; - }; + AbstractTestCase.prototype.assertHTML = function assertHTML(html) { + _internalTestHelpersEqualTokens.default(this.element, html, '#qunit-fixture content should be: `' + html + '`'); + }; - LinkedList.prototype.append = function append(node) { - var tail = this._tail; - if (tail) { - tail.next = node; - node.prev = tail; - node.next = null; - } else { - this._head = node; - } - return this._tail = node; - }; + AbstractTestCase.prototype.assertElement = function assertElement(node, _ref) { + var _ref$ElementType = _ref.ElementType; + var ElementType = _ref$ElementType === undefined ? HTMLElement : _ref$ElementType; + var tagName = _ref.tagName; + var _ref$attrs = _ref.attrs; + var attrs = _ref$attrs === undefined ? null : _ref$attrs; + var _ref$content = _ref.content; + var content = _ref$content === undefined ? null : _ref$content; - LinkedList.prototype.pop = function pop() { - if (this._tail) return this.remove(this._tail); - return null; - }; + if (!(node instanceof ElementType)) { + throw new Error('Expecting a ' + ElementType.name + ', but got ' + node); + } - LinkedList.prototype.prepend = function prepend(node) { - if (this._head) return this.insertBefore(node, this._head); - return this._head = this._tail = node; - }; + _internalTestHelpersMatchers.equalsElement(node, tagName, attrs, content); + }; - LinkedList.prototype.remove = function remove(node) { - if (node.prev) node.prev.next = node.next;else this._head = node.next; - if (node.next) node.next.prev = node.prev;else this._tail = node.prev; - return node; - }; + AbstractTestCase.prototype.assertComponentElement = function assertComponentElement(node, _ref2) { + var _ref2$ElementType = _ref2.ElementType; + var ElementType = _ref2$ElementType === undefined ? HTMLElement : _ref2$ElementType; + var _ref2$tagName = _ref2.tagName; + var tagName = _ref2$tagName === undefined ? 'div' : _ref2$tagName; + var _ref2$attrs = _ref2.attrs; + var attrs = _ref2$attrs === undefined ? null : _ref2$attrs; + var _ref2$content = _ref2.content; + var content = _ref2$content === undefined ? null : _ref2$content; - return LinkedList; - })(); + attrs = _emberUtils.assign({}, { id: _internalTestHelpersMatchers.regex(/^ember\d*$/), class: _internalTestHelpersMatchers.classes('ember-view') }, attrs || {}); + this.assertElement(node, { ElementType: ElementType, tagName: tagName, attrs: attrs, content: content }); + }; - exports.LinkedList = LinkedList; + AbstractTestCase.prototype.assertSameNode = function assertSameNode(actual, expected) { + this.assert.strictEqual(actual, expected, 'DOM node stability'); + }; - var LinkedListRemover = (function () { - function LinkedListRemover(node) { - this.node = node; - } + AbstractTestCase.prototype.assertInvariants = function assertInvariants(oldSnapshot, newSnapshot) { + oldSnapshot = oldSnapshot || this.snapshot; + newSnapshot = newSnapshot || this.takeSnapshot(); - LinkedListRemover.prototype.destroy = function destroy() { - var _node = this.node; - var prev = _node.prev; - var next = _node.next; + this.assert.strictEqual(newSnapshot.length, oldSnapshot.length, 'Same number of nodes'); - prev.next = next; - next.prev = prev; - }; + for (var i = 0; i < oldSnapshot.length; i++) { + this.assertSameNode(newSnapshot[i], oldSnapshot[i]); + } + }; - return LinkedListRemover; - })(); + AbstractTestCase.prototype.assertPartialInvariants = function assertPartialInvariants(start, end) { + this.assertInvariants(this.snapshot, this.takeSnapshot().slice(start, end)); + }; - var ListSlice = (function () { - function ListSlice(head, tail) { - this._head = head; - this._tail = tail; - } + AbstractTestCase.prototype.assertStableRerender = function assertStableRerender() { + var _this = this; - ListSlice.toList = function toList(slice) { - var list = new LinkedList(); - slice.forEachNode(function (n) { - return list.append(n.clone()); - }); - return list; - }; + this.takeSnapshot(); + this.runTask(function () { + return _this.rerender(); + }); + this.assertInvariants(); + }; - ListSlice.prototype.forEachNode = function forEachNode(callback) { - var node = this._head; - while (node !== null) { - callback(node); - node = this.nextNode(node); - } - }; + babelHelpers.createClass(AbstractTestCase, [{ + key: 'firstChild', + get: function () { + return this.nthChild(0); + } + }, { + key: 'nodesCount', + get: function () { + var count = 0; + var node = this.element.firstChild; - ListSlice.prototype.contains = function contains(needle) { - var node = this._head; - while (node !== null) { - if (node === needle) return true; - node = node.next; - } - return false; - }; + while (node) { + if (!isMarker(node)) { + count++; + } - ListSlice.prototype.head = function head() { - return this._head; - }; + node = node.nextSibling; + } - ListSlice.prototype.tail = function tail() { - return this._tail; - }; + return count; + } + }]); + return AbstractTestCase; + })(); - ListSlice.prototype.toArray = function toArray() { - var out = []; - this.forEachNode(function (n) { - return out.push(n); - }); - return out; - }; + exports.default = AbstractTestCase; +}); +enifed('internal-test-helpers/test-cases/application', ['exports', 'internal-test-helpers/test-cases/abstract-application'], function (exports, _internalTestHelpersTestCasesAbstractApplication) { + 'use strict'; - ListSlice.prototype.nextNode = function nextNode(node) { - if (node === this._tail) return null; - return node.next; - }; + var ApplicationTestCase = (function (_AbstractApplicationTestCase) { + babelHelpers.inherits(ApplicationTestCase, _AbstractApplicationTestCase); - ListSlice.prototype.prevNode = function prevNode(node) { - if (node === this._head) return null; - return node.prev; - }; + function ApplicationTestCase() { + babelHelpers.classCallCheck(this, ApplicationTestCase); - ListSlice.prototype.isEmpty = function isEmpty() { - return false; - }; + _AbstractApplicationTestCase.apply(this, arguments); + } - return ListSlice; - })(); + return ApplicationTestCase; + })(_internalTestHelpersTestCasesAbstractApplication.default); - exports.ListSlice = ListSlice; - var EMPTY_SLICE = new ListSlice(null, null); - exports.EMPTY_SLICE = EMPTY_SLICE; + exports.default = ApplicationTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbGlzdC11dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFTQSxRQUFBLEdBS0UsU0FMRixRQUFBLENBS2MsS0FBUSxFQUFBO0FBSmIsWUFBQSxDQUFBLElBQUksR0FBZ0IsSUFBSSxDQUFDO0FBQ3pCLFlBQUEsQ0FBQSxJQUFJLEdBQWdCLElBQUksQ0FBQztBQUk5QixZQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQztLQUNwQ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gIG5vZGUgPSB0aGlzLm5leHROb2RlKG5vZGUpO1xuICAgIH1cbiAgfVxuXG4gIGNvbnRhaW5zKG5lZWRsZTogVCk6IGJvb2xlYW4ge1xuICAgIGxldCBub2RlID0gdGhpcy5faGVhZDtcblxuICAgIHdoaWxlIChub2RlICE9PSBudWxsKSB7XG4gICAgICBpZiAobm9kZSA9PT0gbmVlZGxlKSByZXR1cm4gdHJ1ZTtcbiAgICAgIG5vZGUgPSA8dHJ1c3Q+bm9kZS5uZXh0O1xuICAgIH1cblxuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuXG4gIGhlYWQoKTogVCB7XG4gICAgcmV0dXJuIHRoaXMuX2hlYWQ7XG4gIH1cblxuICB0YWlsKCk6IFQge1xuICAgIHJldHVybiB0aGlzLl90YWlsO1xuICB9XG5cbiAgdG9BcnJheSgpOiBUW10ge1xuICAgIGxldCBvdXQgPSBbXTtcbiAgICB0aGlzLmZvckVhY2hOb2RlKG4gPT4gb3V0LnB1c2gobikpO1xuICAgIHJldHVybiBvdXQ7XG4gIH1cblxuICBuZXh0Tm9kZShub2RlOiBUKTogVCB7XG4gICAgaWYgKG5vZGUgPT09IHRoaXMuX3RhaWwpIHJldHVybiBudWxsO1xuICAgIHJldHVybiA8VD5ub2RlLm5leHQ7XG4gIH1cblxuICBwcmV2Tm9kZShub2RlOiBUKTogVCB7XG4gICAgaWYgKG5vZGUgPT09IHRoaXMuX2hlYWQpIHJldHVybiBudWxsO1xuICAgIHJldHVybiA8VD5ub2RlLnByZXY7XG4gIH1cblxuICBpc0VtcHR5KCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxufVxuXG5leHBvcnQgY29uc3QgRU1QVFlfU0xJQ0UgPSBuZXcgTGlzdFNsaWNlKG51bGwsIG51bGwpO1xuIl19 -enifed("glimmer-util/lib/logger", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-cases/query-param', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers/test-cases/application'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpersTestCasesApplication) { + 'use strict'; - var LogLevel; - exports.LogLevel = LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["Trace"] = 0] = "Trace"; - LogLevel[LogLevel["Debug"] = 1] = "Debug"; - LogLevel[LogLevel["Warn"] = 2] = "Warn"; - LogLevel[LogLevel["Error"] = 3] = "Error"; - })(LogLevel || (exports.LogLevel = LogLevel = {})); + var QueryParamTestCase = (function (_ApplicationTestCase) { + babelHelpers.inherits(QueryParamTestCase, _ApplicationTestCase); - var NullConsole = (function () { - function NullConsole() {} + function QueryParamTestCase() { + babelHelpers.classCallCheck(this, QueryParamTestCase); - NullConsole.prototype.log = function log(message) {}; + _ApplicationTestCase.call(this); - NullConsole.prototype.warn = function warn(message) {}; + var testCase = this; + testCase.expectedPushURL = null; + testCase.expectedReplaceURL = null; + this.application.register('location:test', _emberRouting.NoneLocation.extend({ + setURL: function (path) { + if (testCase.expectedReplaceURL) { + testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); + } - NullConsole.prototype.error = function error(message) {}; + if (testCase.expectedPushURL) { + testCase.assert.equal(path, testCase.expectedPushURL, 'an expected pushState occurred'); + testCase.expectedPushURL = null; + } - NullConsole.prototype.trace = function trace() {}; + this.set('path', path); + }, - return NullConsole; - })(); + replaceURL: function (path) { + if (testCase.expectedPushURL) { + testCase.assert.ok(false, 'replaceState occurred but a pushState was expected'); + } - var Logger = (function () { - function Logger(_ref) { - var console = _ref.console; - var level = _ref.level; + if (testCase.expectedReplaceURL) { + testCase.assert.equal(path, testCase.expectedReplaceURL, 'an expected replaceState occurred'); + testCase.expectedReplaceURL = null; + } - this.f = ALWAYS; - this.force = ALWAYS; - this.console = console; - this.level = level; + this.set('path', path); } + })); + } - Logger.prototype.skipped = function skipped(level) { - return level < this.level; - }; + QueryParamTestCase.prototype.visitAndAssert = function visitAndAssert(path) { + var _this = this; - Logger.prototype.trace = function trace(message) { - var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + return this.visit.apply(this, arguments).then(function () { + _this.assertCurrentPath(path); + }); + }; - var _ref2$stackTrace = _ref2.stackTrace; - var stackTrace = _ref2$stackTrace === undefined ? false : _ref2$stackTrace; + QueryParamTestCase.prototype.getController = function getController(name) { + return this.applicationInstance.lookup('controller:' + name); + }; - if (this.skipped(LogLevel.Trace)) return; - this.console.log(message); - if (stackTrace) this.console.trace(); - }; + QueryParamTestCase.prototype.getRoute = function getRoute(name) { + return this.applicationInstance.lookup('route:' + name); + }; - Logger.prototype.debug = function debug(message) { - var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + QueryParamTestCase.prototype.setAndFlush = function setAndFlush(obj, prop, value) { + return _emberMetal.run(obj, 'set', prop, value); + }; - var _ref3$stackTrace = _ref3.stackTrace; - var stackTrace = _ref3$stackTrace === undefined ? false : _ref3$stackTrace; + QueryParamTestCase.prototype.assertCurrentPath = function assertCurrentPath(path) { + var message = arguments.length <= 1 || arguments[1] === undefined ? 'current path equals \'' + path + '\'' : arguments[1]; + return (function () { + this.assert.equal(this.appRouter.get('location.path'), path, message); + }).apply(this, arguments); + }; - if (this.skipped(LogLevel.Debug)) return; - this.console.log(message); - if (stackTrace) this.console.trace(); - }; + /** + Sets up a Controller for a given route with a single query param and default + value. Can optionally extend the controller with an object. + @public + @method setSingleQPController + */ - Logger.prototype.warn = function warn(message) { - var _ref4 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + QueryParamTestCase.prototype.setSingleQPController = function setSingleQPController(routeName) { + var param = arguments.length <= 1 || arguments[1] === undefined ? 'foo' : arguments[1]; + var defaultValue = arguments.length <= 2 || arguments[2] === undefined ? 'bar' : arguments[2]; - var _ref4$stackTrace = _ref4.stackTrace; - var stackTrace = _ref4$stackTrace === undefined ? false : _ref4$stackTrace; + var _Controller$extend; - if (this.skipped(LogLevel.Warn)) return; - this.console.warn(message); - if (stackTrace) this.console.trace(); - }; + var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; - Logger.prototype.error = function error(message) { - if (this.skipped(LogLevel.Error)) return; - this.console.error(message); - }; + this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend = { + queryParams: [param] + }, _Controller$extend[param] = defaultValue, _Controller$extend), options)); + }; - return Logger; - })(); + /** + Sets up a Controller for a given route with a custom property/url key mapping. + @public + @method setMappedQPController + */ - exports.Logger = Logger; + QueryParamTestCase.prototype.setMappedQPController = function setMappedQPController(routeName) { + var prop = arguments.length <= 1 || arguments[1] === undefined ? 'page' : arguments[1]; + var urlKey = arguments.length <= 2 || arguments[2] === undefined ? 'parentPage' : arguments[2]; + var defaultValue = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3]; - var _console = typeof console === 'undefined' ? new NullConsole() : console; - var ALWAYS = new Logger({ console: _console, level: LogLevel.Trace }); - var LOG_LEVEL = LogLevel.Warn; - exports.default = new Logger({ console: _console, level: LOG_LEVEL }); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbG9nZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLFFBQVksUUFLWCxDQUFBOztBQUxELEtBQUEsVUFBWSxRQUFRLEVBQUE7QUFDbEIsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsT0FBSyxDQUFBO0FBQ0wsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsT0FBSyxDQUFBO0FBQ0wsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsTUFBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsTUFBSSxDQUFBO0FBQ0osZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0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B9XG5cbiAgZXJyb3IobWVzc2FnZTogYW55IHwgYW55W10pIHtcbiAgICBpZiAodGhpcy5za2lwcGVkKExvZ0xldmVsLkVycm9yKSkgcmV0dXJuO1xuICAgIHRoaXMuY29uc29sZS5lcnJvcihtZXNzYWdlKTtcbiAgfVxufVxuXG5sZXQgX2NvbnNvbGUgPSAodHlwZW9mIGNvbnNvbGUgPT09ICd1bmRlZmluZWQnKSA/IG5ldyBOdWxsQ29uc29sZSgpIDogY29uc29sZTtcblxuY29uc3QgQUxXQVlTID0gbmV3IExvZ2dlcih7IGNvbnNvbGU6IF9jb25zb2xlLCBsZXZlbDogTG9nTGV2ZWwuVHJhY2UgfSk7XG5jb25zdCBMT0dfTEVWRUwgPSBMb2dMZXZlbC5XYXJuO1xuXG5leHBvcnQgZGVmYXVsdCBuZXcgTG9nZ2VyKHsgY29uc29sZTogX2NvbnNvbGUsIGxldmVsOiBMT0dfTEVWRUwgfSk7XG4iXX0= -enifed('glimmer-util/lib/namespaces', ['exports'], function (exports) { - // There is a small whitelist of namespaced attributes specially - // enumerated in - // https://www.w3.org/TR/html/syntax.html#attributes-0 - // - // > When a foreign element has one of the namespaced attributes given by - // > the local name and namespace of the first and second cells of a row - // > from the following table, it must be written using the name given by - // > the third cell from the same row. - // - // In all other cases, colons are interpreted as a regular character - // with no special meaning: - // - // > No other namespaced attribute can be expressed in the HTML syntax. - 'use strict'; + var _queryParams, _Controller$extend2; - exports.getAttrNamespace = getAttrNamespace; - var XLINK = 'http://www.w3.org/1999/xlink'; - var XML = 'http://www.w3.org/XML/1998/namespace'; - var XMLNS = 'http://www.w3.org/2000/xmlns/'; - var WHITELIST = { - 'xlink:actuate': XLINK, - 'xlink:arcrole': XLINK, - 'xlink:href': XLINK, - 'xlink:role': XLINK, - 'xlink:show': XLINK, - 'xlink:title': XLINK, - 'xlink:type': XLINK, - 'xml:base': XML, - 'xml:lang': XML, - 'xml:space': XML, - 'xmlns': XMLNS, - 'xmlns:xlink': XMLNS + var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; + + this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend2 = { + queryParams: (_queryParams = {}, _queryParams[prop] = urlKey, _queryParams) + }, _Controller$extend2[prop] = defaultValue, _Controller$extend2), options)); }; - function getAttrNamespace(attrName) { - return WHITELIST[attrName] || null; - } + babelHelpers.createClass(QueryParamTestCase, [{ + key: 'routerOptions', + get: function () { + return { + location: 'test' + }; + } + }]); + return QueryParamTestCase; + })(_internalTestHelpersTestCasesApplication.default); + + exports.default = QueryParamTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbmFtZXNwYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7OztBQWNBLFFBQU0sS0FBSyxHQUFHLDhCQUE4QixDQUFDO0FBQzdDLFFBQU0sR0FBRyxHQUFHLHNDQUFzQyxDQUFDO0FBQ25ELFFBQU0sS0FBSyxHQUFHLCtCQUErQixDQUFDO0FBRTlDLFFBQU0sU0FBUyxHQUFHO0FBQ2hCLHVCQUFlLEVBQUUsS0FBSztBQUN0Qix1QkFBZSxFQUFFLEtBQUs7QUFDdEIsb0JBQVksRUFBRSxLQUFLO0FBQ25CLG9CQUFZLEVBQUUsS0FBSztBQUNuQixvQkFBWSxFQUFFLEtBQUs7QUFDbkIscUJBQWEsRUFBRSxLQUFLO0FBQ3BCLG9CQUFZLEVBQUUsS0FBSztBQUNuQixrQkFBVSxFQUFFLEdBQUc7QUFDZixrQkFBVSxFQUFFLEdBQUc7QUFDZixtQkFBVyxFQUFFLEdBQUc7QUFDaEIsZUFBTyxFQUFFLEtBQUs7QUFDZCxxQkFBYSxFQUFFLEtBQUs7S0FDckIsQ0FBQzs7QUFFRixhQUFBLGdCQUFBLENBQWlDLFFBQVEsRUFBQTtBQUN2QyxlQUFPLFNBQVMsQ0FBQy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IwMDAveG1sbnMvJztcblxuY29uc3QgV0hJVEVMSVNUID0ge1xuICAneGxpbms6YWN0dWF0ZSc6IFhMSU5LLFxuICAneGxpbms6YXJjcm9sZSc6IFhMSU5LLFxuICAneGxpbms6aHJlZic6IFhMSU5LLFxuICAneGxpbms6cm9sZSc6IFhMSU5LLFxuICAneGxpbms6c2hvdyc6IFhMSU5LLFxuICAneGxpbms6dGl0bGUnOiBYTElOSyxcbiAgJ3hsaW5rOnR5cGUnOiBYTElOSyxcbiAgJ3htbDpiYXNlJzogWE1MLFxuICAneG1sOmxhbmcnOiBYTUwsXG4gICd4bWw6c3BhY2UnOiBYTUwsXG4gICd4bWxucyc6IFhNTE5TLFxuICAneG1sbnM6eGxpbmsnOiBYTUxOU1xufTtcblxuZXhwb3J0IGZ1bmN0aW9uIGdldEF0dHJOYW1lc3BhY2UoYXR0ck5hbWUpIHtcbiAgcmV0dXJuIFdISVRFTElTVFthdHRyTmFtZV0gfHwgbnVsbDtcbn0iXX0= -enifed('glimmer-util/lib/object-utils', ['exports'], function (exports) { - 'use strict'; +enifed('internal-test-helpers/test-cases/rendering', ['exports', 'ember-views', 'internal-test-helpers/test-cases/abstract-rendering'], function (exports, _emberViews, _internalTestHelpersTestCasesAbstractRendering) { + 'use strict'; - exports.assign = assign; - var objKeys = Object.keys; + var RenderingTestCase = (function (_AbstractRenderingTestCase) { + babelHelpers.inherits(RenderingTestCase, _AbstractRenderingTestCase); - function assign(obj) { - for (var i = 1; i < arguments.length; i++) { - var assignment = arguments[i]; - if (assignment === null || typeof assignment !== 'object') continue; - var keys = objKeys(assignment); - for (var j = 0; j < keys.length; j++) { - var key = keys[j]; - obj[key] = assignment[key]; - } - } - return obj; + function RenderingTestCase() { + babelHelpers.classCallCheck(this, RenderingTestCase); + + _AbstractRenderingTestCase.call(this); + var owner = this.owner; + + this.env = owner.lookup('service:-glimmer-environment'); + owner.register('component-lookup:main', _emberViews.ComponentLookup); + owner.registerOptionsForType('helper', { instantiate: false }); + owner.registerOptionsForType('component', { singleton: false }); } + + return RenderingTestCase; + })(_internalTestHelpersTestCasesAbstractRendering.default); + + exports.default = RenderingTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvb2JqZWN0LXV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7UUFBYyxPQUFPLEdBQUssTUFBTSxDQUF4QixJQUFJOztBQVNaLGFBQUEsTUFBQSxDQUF1QixHQUFHLEVBQUE7QUFDeEIsYUFBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxFQUFFLEVBQUU7QUFDekMsZ0JBQUksVUFBVSxHQUFHLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUM5QixnQkFBSSxVQUFVLEtBQUssSUFBSSxJQUFJLE9BQU8sVUFBVSxLQUFLLFFBQVEsRUFBRSxTQUFTO0FBQ3BFLGdCQUFJLElBQUksR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7QUFDL0IsaUJBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO0FBQ3BDLG9CQUFJLEdBQUcsR0FBRyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDbEIsbUJBQUcsQ0FBQyxHQUFHLENBQUMsR0FBRyxVQUFVLENBQUMsR0FBRyxDQUFDLENBQUM7YUFDNUI7U0FDRjtBQUNELGVBQU8sR0FBRyxDQUFDO0tBQ1oiLCJmaWxlIjoib2JqZWN0LXV0aWxzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY29uc3QgeyBrZXlzOiBvYmpLZXlzIH0gPSBPYmplY3Q7XG5cbmV4cG9ydCBmdW5jdGlvbiBh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SB7XG4gICAgICBsZXQga2V5ID0ga2V5c1tqXTtcbiAgICAgIG9ialtrZXldID0gYXNzaWdubWVudFtrZXldO1xuICAgIH1cbiAgfVxuICByZXR1cm4gb2JqO1xufVxuIl19 -enifed("glimmer-util/lib/platform-utils", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-cases/router', ['exports', 'internal-test-helpers/test-cases/application'], function (exports, _internalTestHelpersTestCasesApplication) { + 'use strict'; - exports.unwrap = unwrap; + var RouterTestCase = (function (_ApplicationTestCase) { + babelHelpers.inherits(RouterTestCase, _ApplicationTestCase); - function unwrap(val) { - if (val === null || val === undefined) throw new Error("Expected value to be present"); - return val; + function RouterTestCase() { + babelHelpers.classCallCheck(this, RouterTestCase); + + _ApplicationTestCase.call(this); + + this.router.map(function () { + this.route('parent', { path: '/' }, function () { + this.route('child'); + this.route('sister'); + this.route('brother'); + }); + this.route('dynamic', { path: '/dynamic/:post_id' }); + }); } + + babelHelpers.createClass(RouterTestCase, [{ + key: 'routerService', + get: function () { + return this.applicationInstance.lookup('service:router'); + } + }]); + return RouterTestCase; + })(_internalTestHelpersTestCasesApplication.default); + + exports.default = RouterTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvcGxhdGZvcm0tdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFJQSxhQUFBLE1BQUEsQ0FBMEIsR0FBYSxFQUFBO0FBQ3JDLFlBQUksR0FBRyxLQUFLLElBQUksSUFBSSxHQUFHLEtBQUssU0FBUyxFQUFFLE1BQU0sSUFBSSxLQUFLLGdDQUFnQyxDQUFDO0FBQ3ZGLGVBQU8sR0FBRyxDQUFDO0tBQ1oiLCJmaWxlIjoicGxhdGZvcm0tdXRpbHMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgdHlwZSBPcGFxdWUgPSB7fSB8IHZvaWQ7XG5leHBvcnQgdHlwZSBPcHRpb248VD4gPSBUIHwgbnVsbDsgLy8gdHNsaW50OmRpc2FibGUtbGluZVxuZXhwb3J0IHR5cGUgTWF5YmU8VD4gPSBPcHRpb248VD4gfCB1bmRlZmluZWQ7IC8vIHRzbGludDpkaXNhYmxlLWxpbmVcblxuZXhwb3J0IGZ1bmN0aW9uIHVud3JhcDxUPih2YWw6IE1heWJlPFQ+KTogVCB7XG4gIGlmICh2YWwgPT09IG51bGwgfHwgdmFsID09PSB1bmRlZmluZWQpIHRocm93IG5ldyBFcnJvcihgRXhwZWN0ZWQgdmFsdWUgdG8gYmUgcHJlc2VudGApO1xuICByZXR1cm4gdmFsO1xufVxuIl19 -enifed("glimmer-util/lib/quoting", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-groups', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + 'use strict'; - exports.hash = hash; - exports.repeat = repeat; - function escapeString(str) { - str = str.replace(/\\/g, "\\\\"); - str = str.replace(/"/g, '\\"'); - str = str.replace(/\n/g, "\\n"); - return str; - } - exports.escapeString = escapeString; + exports.testBoth = testBoth; + exports.testWithDefault = testWithDefault; - function string(str) { - return '"' + escapeString(str) + '"'; - } - exports.string = string; + // used by unit tests to test both accessor mode and non-accessor mode - function array(a) { - return "[" + a + "]"; + function testBoth(testname, callback) { + function emberget(x, y) { + return _emberMetal.get(x, y); } - exports.array = array; - - function hash(pairs) { - return "{" + pairs.join(", ") + "}"; + function emberset(x, y, z) { + return _emberMetal.set(x, y, z); } - - function repeat(chars, times) { - var str = ""; - while (times--) { - str += chars; - } - return str; + function aget(x, y) { + return x[y]; + } + function aset(x, y, z) { + return x[y] = z; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvcXVvdGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLGFBQUE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0cikge1xuICBzdHIgPSBzdHIucmVwbGFjZSgvXFxcXC9nLCBcIlxcXFxcXFxcXCIpO1xuICBzdHIgPSBzdHIucmVwbGFjZSgvXCIvZywgJ1xcXFxcIicpO1xuICBzdHIgPSBzdHIucmVwbGFjZSgvXFxuL2csIFwiXFxcXG5cIik7XG4gIHJldHVybiBzdHI7XG59XG5cbmV4cG9ydCB7IGVzY2FwZVN0cmluZyB9O1xuXG5mdW5jdGlvbiBzdHJpbmcoc3RyKSB7XG4gIHJldHVybiAnXCInICsgZXNjYXBlU3RyaW5nKHN0cikgKyAnXCInO1xufVxuXG5leHBvcnQgeyBzdHJpbmcgfTtcblxuZnVuY3Rpb24gYXJyYXkoYSkge1xuICByZXR1cm4gXCJbXCIgKyBhICsgXCJdXCI7XG59XG5cbmV4cG9ydCB7IGFycmF5IH07XG5cbmV4cG9ydCBmdW5jdGlvbiBoYXNoKHBhaXJzKSB7XG4gIHJldHVybiBcIntcIiArIHBhaXJzLmpvaW4oXCIsIFwiKSArIFwifVwiO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gcmVwZWF0KGNoYXJzLCB0aW1lcykge1xuICBsZXQgc3RyID0gXCJcIjtcbiAgd2hpbGUgKHRpbWVzLS0pIHtcbiAgICBzdHIgKz0gY2hhcnM7XG4gIH1cbiAgcmV0dXJuIHN0cjtcbn1cbiJdfQ== -enifed('glimmer-wire-format/index', ['exports'], function (exports) { - 'use strict'; - function is(variant) { - return function (value) { - return value[0] === variant; - }; + QUnit.test(testname + ' using getFromEmberMetal()/Ember.set()', function () { + callback(emberget, emberset); + }); + + QUnit.test(testname + ' using accessors', function () { + if (_emberEnvironment.ENV.USES_ACCESSORS) { + callback(aget, aset); + } else { + ok('SKIPPING ACCESSORS'); + } + }); + } + + function testWithDefault(testname, callback) { + function emberget(x, y) { + return _emberMetal.get(x, y); } - var Expressions; - exports.Expressions = Expressions; - (function (Expressions) { - Expressions.isUnknown = is('unknown'); - Expressions.isArg = is('arg'); - Expressions.isGet = is('get'); - Expressions.isConcat = is('concat'); - Expressions.isHelper = is('helper'); - Expressions.isHasBlock = is('has-block'); - Expressions.isHasBlockParams = is('has-block-params'); - Expressions.isUndefined = is('undefined'); - function isPrimitiveValue(value) { - if (value === null) { - return true; - } - return typeof value !== 'object'; - } - Expressions.isPrimitiveValue = isPrimitiveValue; - })(Expressions || (exports.Expressions = Expressions = {})); - var Statements; - exports.Statements = Statements; - (function (Statements) { - Statements.isText = is('text'); - Statements.isAppend = is('append'); - Statements.isComment = is('comment'); - Statements.isModifier = is('modifier'); - Statements.isBlock = is('block'); - Statements.isOpenElement = is('open-element'); - Statements.isFlushElement = is('flush-element'); - Statements.isCloseElement = is('close-element'); - Statements.isStaticAttr = is('static-attr'); - Statements.isDynamicAttr = is('dynamic-attr'); - Statements.isYield = is('yield'); - Statements.isPartial = is('partial'); - Statements.isDynamicArg = is('dynamic-arg'); - Statements.isStaticArg = is('static-arg'); - Statements.isTrustingAttr = is('trusting-attr'); - })(Statements || (exports.Statements = Statements = {})); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItd2lyZS1mb3JtYXQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBbUJBLGFBQUEsRUFBQSxDQUE2QixPQUFlLEVBQUE7QUFDMUMsZUFBTyxVQUFTLEtBQVksRUFBQTtBQUMxQixtQkFBTyxLQUFLLENBQUMsQ0FBQyxDQUFDLEtBQUssT0FBTyxDQUFDO1NBQzdCLENBQUM7S0FDSDtBQVVELFFBQWlCLFdBQVcsQ0FvRDNCOztBQXBERCxLQUFBLFVBQWlCLFdBQVcsRUFBQztBQXFDZCxtQkFBQSxDQUFBLFNBQVMsR0FBVSxFQUFFLENBQVUsU0FBUyxDQUFDLENBQUM7QUFDMUMsbUJBQUEsQ0FBQSxLQUFLLEdBQWMsRUFBRSxDQUFNLEtBQUssQ0FBQyxDQUFDO0FBQ2xDL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lbXBsYXRlQmxvY2sgYXMgSlNPTiBhbmQgVGVtcGxhdGVNZXRhLlxuICovXG5leHBvcnQgaW50ZXJmYWNlIFNlcmlhbGl6ZWRUZW1wbGF0ZVdpdGhMYXp5QmxvY2s8VCBleHRlbmRzIFRlbXBsYXRlTWV0YT4ge1xuICBpZD86IHN0cmluZztcbiAgYmxvY2s6IFNlcmlhbGl6ZWRUZW1wbGF0ZUJsb2NrSlNPTjtcbiAgbWV0YTogVDtcbn1cblxuLyoqXG4gKiBBIHN0cmluZyBvZiBKYXZhc2NyaXB0IGNvbnRhaW5pbmcgYSBTZXJpYWxpemVkVGVtcGxhdGVXaXRoTGF6eUJsb2NrIHRvIGJlXG4gKiBjb25jYXRlbmF0ZWQgaW50byBhIEphdmFzY3JpcHQgbW9kdWxlLlxuICogQHR5cGVkZWYge3N0cmluZ30gVGVtcGxhdGVKYXZhc2NyaXB0XG4gKi9cbmV4cG9ydCB0eXBlIFRlbXBsYXRlSmF2YXNjcmlwdCA9IHN0cmluZztcbiJdfQ== -enifed('glimmer/index', ['exports', 'glimmer-compiler'], function (exports, _glimmerCompiler) { - /* - * @overview Glimmer - * @copyright Copyright 2011-2015 Tilde Inc. and contributors - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/tildeio/glimmer/master/LICENSE - * @version VERSION_STRING_PLACEHOLDER - */ - 'use strict'; + function embergetwithdefault(x, y, z) { + return _emberMetal.getWithDefault(x, y, z); + } + function getwithdefault(x, y, z) { + return x.getWithDefault(y, z); + } + function emberset(x, y, z) { + return _emberMetal.set(x, y, z); + } + function aget(x, y) { + return x[y]; + } + function aset(x, y, z) { + return x[y] = z; + } + + QUnit.test(testname + ' using obj.get()', function () { + callback(emberget, emberset); + }); + + QUnit.test(testname + ' using obj.getWithDefault()', function () { + callback(getwithdefault, emberset); + }); + + QUnit.test(testname + ' using getFromEmberMetal()', function () { + callback(emberget, emberset); + }); - exports.precompile = _glimmerCompiler.precompile; + QUnit.test(testname + ' using Ember.getWithDefault()', function () { + callback(embergetwithdefault, emberset); + }); + + QUnit.test(testname + ' using accessors', function () { + if (_emberEnvironment.ENV.USES_ACCESSORS) { + callback(aget, aset); + } else { + ok('SKIPPING ACCESSORS'); + } + }); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztVQU9TLFVBQVUsb0JBQVYsVUFBVSIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBAb3ZlcnZpZXcgIEdsaW1tZXJcbiAqIEBjb3B5cmlnaHQgQ29weXJpZ2h0IDIwMTEtMjAxNSBUaWxkZSBJbmMuIGFuZCBjb250cmlidXRvcnNcbiAqIEBsaWNlbnNlICAgTGljZW5zZWQgdW5kZXIgTUlUIGxpY2Vuc2VcbiAqICAgICAgICAgICAgU2VlIGh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS90aWxkZWlvL2dsaW1tZXIvbWFzdGVyL0xJQ0VOU0VcbiAqIEB2ZXJzaW9uICAgVkVSU0lPTl9TVFJJTkdfUExBQ0VIT0xERVJcbiAqL1xuZXhwb3J0IHsgcHJlY29tcGlsZSB9IGZyb20gJ2dsaW1tZXItY29tcGlsZXInO1xuIl19 enifed('route-recognizer', ['exports'], function (exports) { 'use strict'; -function Target(path, matcher, delegate) { - this.path = path; - this.matcher = matcher; - this.delegate = delegate; +var createObject = Object.create; +function createMap() { + var map = createObject(null); + map["__"] = undefined; + delete map["__"]; + return map; } -Target.prototype = { - to: function(target, callback) { +var Target = function Target(path, matcher, delegate) { + this.path = path; + this.matcher = matcher; + this.delegate = delegate; +}; +Target.prototype.to = function to (target, callback) { var delegate = this.delegate; - if (delegate && delegate.willAddRoute) { - target = delegate.willAddRoute(this.matcher.target, target); + target = delegate.willAddRoute(this.matcher.target, target); } - this.matcher.add(this.path, target); - if (callback) { - if (callback.length === 0) { throw new Error("You must have an argument in the function passed to `to`"); } - this.matcher.addChild(this.path, target, callback, this.delegate); + if (callback.length === 0) { + throw new Error("You must have an argument in the function passed to `to`"); + } + this.matcher.addChild(this.path, target, callback, this.delegate); } - return this; - } }; - -function Matcher(target) { - this.routes = {}; - this.children = {}; - this.target = target; -} - -Matcher.prototype = { - add: function(path, handler) { - this.routes[path] = handler; - }, - - addChild: function(path, target, callback, delegate) { +var Matcher = function Matcher(target) { + this.routes = createMap(); + this.children = createMap(); + this.target = target; +}; +Matcher.prototype.add = function add (path, target) { + this.routes[path] = target; +}; +Matcher.prototype.addChild = function addChild (path, target, callback, delegate) { var matcher = new Matcher(target); this.children[path] = matcher; - var match = generateMatch(path, matcher, delegate); - if (delegate && delegate.contextEntered) { - delegate.contextEntered(target, match); + delegate.contextEntered(target, match); } - callback(match); - } }; - function generateMatch(startingPath, matcher, delegate) { - return function(path, nestedCallback) { - var fullPath = startingPath + path; - - if (nestedCallback) { - nestedCallback(generateMatch(fullPath, matcher, delegate)); - } else { - return new Target(startingPath + path, matcher, delegate); + function match(path, callback) { + var fullPath = startingPath + path; + if (callback) { + callback(generateMatch(fullPath, matcher, delegate)); + } + else { + return new Target(fullPath, matcher, delegate); + } } - }; + ; + return match; } - function addRoute(routeArray, path, handler) { - var len = 0; - for (var i=0; i 0 && route.charCodeAt(0) === 47 /* SLASH */) { + route = route.substr(1); + } + var parts = route.split("/"); + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + var flags = 0; + var type = 0; + if (part === "") { + type = 4 /* Epsilon */; + } + else if (part.charCodeAt(0) === 58 /* COLON */) { + type = 1 /* Dynamic */; + } + else if (part.charCodeAt(0) === 42 /* STAR */) { + type = 2 /* Star */; + } + else { + type = 0 /* Static */; + } + flags = 2 << type; + if (flags & 12 /* Named */) { + part = part.slice(1); + names.push(part); + shouldDecodes.push((flags & 4 /* Decoded */) !== 0); + } + if (flags & 14 /* Counted */) { + types[type]++; + } + segments.push({ type: type, value: normalizeSegment(part) }); } - } - - return results; } - -function isEqualCharSpec(specA, specB) { - return specA.validChars === specB.validChars && - specA.invalidChars === specB.invalidChars; +function isEqualCharSpec(spec, char, negate) { + return spec.char === char && spec.negate === negate; } - // A State has a character specification and (`charSpec`) and a list of possible // subsequent states (`nextStates`). // @@ -55153,75 +46501,95 @@ function isEqualCharSpec(specA, specB) { // Currently, State is implemented naively by looping over `nextStates` and // comparing a character specification against a character. A more efficient // implementation would use a hash of keys pointing at one or more next states. +var State = function State(states, id, char, negate, repeat) { + this.states = states; + this.id = id; + this.char = char; + this.negate = negate; + this.nextStates = repeat ? id : null; + this.pattern = ""; + this._regex = undefined; + this.handlers = undefined; + this.types = undefined; +}; +State.prototype.regex = function regex$1 () { + if (!this._regex) { + this._regex = new RegExp(this.pattern); + } + return this._regex; +}; +State.prototype.get = function get (char, negate) { + var this$1 = this; -function State(charSpec) { - this.charSpec = charSpec; - this.nextStates = []; - this.regex = undefined; - this.handlers = undefined; - this.specificity = undefined; -} - -State.prototype = { - get: function(charSpec) { var nextStates = this.nextStates; - - for (var i=0; i 2 && key.slice(keyLength -2) === '[]') { - isArray = true; - key = key.slice(0, keyLength - 2); - if(!queryParams[key]) { - queryParams[key] = []; - } +}; +RouteRecognizer.prototype.parseQueryString = function parseQueryString (queryString) { + var pairs = queryString.split("&"); + var queryParams = {}; + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i].split("="), key = decodeQueryParamPart(pair[0]), keyLength = key.length, isArray = false, value = (void 0); + if (pair.length === 1) { + value = "true"; + } + else { + // Handle arrays + if (keyLength > 2 && key.slice(keyLength - 2) === "[]") { + isArray = true; + key = key.slice(0, keyLength - 2); + if (!queryParams[key]) { + queryParams[key] = []; + } + } + value = pair[1] ? decodeQueryParamPart(pair[1]) : ""; + } + if (isArray) { + queryParams[key].push(value); + } + else { + queryParams[key] = value; } - value = pair[1] ? decodeQueryParamPart(pair[1]) : ''; - } - if (isArray) { - queryParams[key].push(value); - } else { - queryParams[key] = value; - } } return queryParams; - }, - - recognize: function(path) { - var states = [ this.rootState ], - pathLen, i, queryStart, queryParams = {}, - hashStart, - isSlashDropped = false; - - hashStart = path.indexOf('#'); +}; +RouteRecognizer.prototype.recognize = function recognize (path) { + var results; + var states = [this.rootState]; + var queryParams = {}; + var isSlashDropped = false; + var hashStart = path.indexOf("#"); if (hashStart !== -1) { - path = path.substr(0, hashStart); + path = path.substr(0, hashStart); } - - queryStart = path.indexOf('?'); + var queryStart = path.indexOf("?"); if (queryStart !== -1) { - var queryString = path.substr(queryStart + 1, path.length); - path = path.substr(0, queryStart); - queryParams = this.parseQueryString(queryString); + var queryString = path.substr(queryStart + 1, path.length); + path = path.substr(0, queryStart); + queryParams = this.parseQueryString(queryString); + } + if (path.charAt(0) !== "/") { + path = "/" + path; } - - if (path.charAt(0) !== "/") { path = "/" + path; } var originalPath = path; - if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) { - path = normalizePath(path); - } else { - path = decodeURI(path); - originalPath = decodeURI(originalPath); + path = normalizePath(path); } - - pathLen = path.length; + else { + path = decodeURI(path); + originalPath = decodeURI(originalPath); + } + var pathLen = path.length; if (pathLen > 1 && path.charAt(pathLen - 1) === "/") { - path = path.substr(0, pathLen - 1); - originalPath = originalPath.substr(0, originalPath.length - 1); - isSlashDropped = true; + path = path.substr(0, pathLen - 1); + originalPath = originalPath.substr(0, originalPath.length - 1); + isSlashDropped = true; } - - for (i=0; i=t[n]?i=n+2:o=n;return e>=t[i]?i+2:i}function a(e,t,n){this.name=e,this.globalOptions=n||{},this.options=t,this._queue=[],this.targetQueues={},this._queueBeingFlushed=void 0}function u(e,n){var r=this.queues={};this.queueNames=e=e||[],this.options=n,t(e,function(e){r[e]=new a(e,n[e],n)})}function l(e){throw new Error("You attempted to schedule an action in a queue ("+e+") that doesn't exist")}function c(e){throw new Error("You attempted to schedule an action in a queue ("+e+") for a method that doesn't exist")}function p(e,t){this.queueNames=e,this.options=t||{},this.options.defaultQueue||(this.options.defaultQueue=e[0]),this.instanceStack=[],this._debouncees=[],this._throttlers=[],this._eventCallbacks={end:[],begin:[]};var n=this;this._boundClearItems=function(){v()},this._timerTimeoutId=void 0,this._timers=[],this._platform=this.options._platform||{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){clearTimeout(e)}},this._boundRunExpiredTimers=function(){n._runExpiredTimers()}}function h(e){return e.onError||e.onErrorTarget&&e.onErrorTarget[e.onErrorMethod]}function f(e){var t=e._platform.setTimeout;e.begin(),e._autorun=t(function(){e._autorun=null,e.end()},0)}function m(e,t,n){return g(e,t,n)}function d(e,t,n){return g(e,t,n)}function g(e,t,n){for(var r,i=-1,o=0,s=n.length;o0?t.apply(e,n):t.call(e)},invokeWithOnError:function(e,t,n,r,i){try{n&&n.length>0?t.apply(e,n):t.call(e)}catch(e){r(e,i)}},flush:function(e){var t=this._queue,r=t.length;if(0!==r){var i,o,s,a,u=this.globalOptions,l=this.options,c=l&&l.before,p=l&&l.after,h=u.onError||u.onErrorTarget&&u.onErrorTarget[u.onErrorMethod],f=h?this.invokeWithOnError:this.invoke;this.targetQueues=Object.create(null);var m=this._queueBeingFlushed=this._queue.slice();this._queue=[],c&&c();for(var d=0;d0&&this.flush(!0)}},cancel:function(e){var t,n,r,i,o=this._queue,s=e.target,a=e.method,u=this.globalOptions.GUID_KEY;if(u&&this.targetQueues&&s){var l=this.targetQueues[s[u]];if(l)for(r=0,i=l.length;r2){r=new Array(i-2);for(var o=0,s=i-2;o3){i=new Array(o-3);for(var a=3;a3){i=new Array(o-3);for(var a=3;a-1?this._throttlers[l]:(c=this._platform.setTimeout(function(){p||r.run.apply(r,o);var n=d(e,t,r._throttlers);n>-1&&r._throttlers.splice(n,1)},a),p&&this.run.apply(this,o),u=[e,t,c],this._throttlers.push(u),u)},debounce:function(e,t){for(var r=this,o=new Array(arguments.length),s=0;s-1&&(l=this._debouncees[u],this._debouncees.splice(u,1),this._platform.clearTimeout(l[2])),c=this._platform.setTimeout(function(){p||r.run.apply(r,o);var n=m(e,t,r._debouncees);n>-1&&r._debouncees.splice(n,1)},a),p&&u===-1&&r.run.apply(r,o),l=[e,t,c],r._debouncees.push(l),l},cancelTimers:function(){t(this._throttlers,this._boundClearItems),this._throttlers=[],t(this._debouncees,this._boundClearItems),this._debouncees=[],this._clearTimerTimeout(),this._timers=[],this._autorun&&(this._platform.clearTimeout(this._autorun),this._autorun=null)},hasTimers:function(){return!!this._timers.length||!!this._debouncees.length||!!this._throttlers.length||this._autorun},cancel:function(e){var t=typeof e;if(e&&"object"===t&&e.queue&&e.method)return e.queue.cancel(e);if("function"!==t)return"[object Array]"===Object.prototype.toString.call(e)?this._cancelItem(d,this._throttlers,e)||this._cancelItem(m,this._debouncees,e):void 0;for(var n=0,r=this._timers.length;n-1&&(r=t[i],r[2]===n[2])&&(t.splice(i,1),this._platform.clearTimeout(n[2]),!0))},_runExpiredTimers:function(){this._timerTimeoutId=void 0,this.run(this,this._scheduleExpiredTimers)},_scheduleExpiredTimers:function(){for(var e=Date.now(),t=this._timers,n=0,r=t.length;n1){for(var t=arguments[0],n=[],r=void 0,i=1;i0?v(this,this.registry.normalize(e)):g(this)},ownerInjection:function(){var e;return e={},e[t.OWNER]=this.owner,e}}}),s("container/index",["exports","container/registry","container/container"],function(e,t,n){"use strict";e.Registry=t.default,e.privatize=t.privatize,e.Container=n.default,e.buildFakeContainerWithDeprecations=n.buildFakeContainerWithDeprecations}),s("container/registry",["exports","ember-utils","ember-metal","container/container"],function(e,t,n,r){"use strict";function i(e){this.fallback=e&&e.fallback?e.fallback:null,e&&e.resolver&&(this.resolver=e.resolver,"function"==typeof this.resolver&&o(this)),this.registrations=t.dictionary(e&&e.registrations?e.registrations:null),this._typeInjections=t.dictionary(null),this._injections=t.dictionary(null),this._factoryTypeInjections=t.dictionary(null),this._factoryInjections=t.dictionary(null),this._localLookupCache=new t.EmptyObject,this._normalizeCache=t.dictionary(null),this._resolveCache=t.dictionary(null),this._failCache=t.dictionary(null),this._options=t.dictionary(null),this._typeOptions=t.dictionary(null)}function o(e){e.resolver={resolve:e.resolver}}function s(e,n,r){var i=e._localLookupCache,o=i[n];o||(o=i[n]=new t.EmptyObject);var s=o[r];if(void 0!==s)return s;var a=e.resolver.expandLocalLookup(n,r);return o[r]=a}function a(e,t,n){if(!n||!n.source||(t=e.expandLocalLookup(t,n))){var r=e._resolveCache[t];if(void 0!==r)return r;if(!e._failCache[t]){var i=void 0;return e.resolver&&(i=e.resolver.resolve(t)),void 0===i&&(i=e.registrations[t]),void 0===i?e._failCache[t]=!0:e._resolveCache[t]=i,i}}}function u(e,t,n){return void 0!==e.resolve(t,{source:n})}function l(e){var n=e[0],r=p[n];if(r)return r;var i=n.split(":"),o=i[0],s=i[1];return p[n]=t.intern(o+":"+s+"-"+h)}e.default=i,e.privatize=l;var c=/^[^:]+:[^:]+$/;i.prototype={fallback:null,resolver:null,registrations:null,_typeInjections:null,_injections:null,_factoryTypeInjections:null,_factoryInjections:null,_normalizeCache:null,_resolveCache:null,_options:null,_typeOptions:null,container:function(e){return new r.default(this,e)},register:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(void 0===t)throw new TypeError("Attempting to register an unknown factory: '"+e+"'");var r=this.normalize(e);if(this._resolveCache[r])throw new Error("Cannot re-register: '"+e+"', as it has already been resolved.");delete this._failCache[r],this.registrations[r]=t,this._options[r]=n},unregister:function(e){var n=this.normalize(e);this._localLookupCache=new t.EmptyObject,delete this.registrations[n],delete this._resolveCache[n],delete this._failCache[n],delete this._options[n]},resolve:function(e,t){var n=a(this,this.normalize(e),t);if(void 0===n&&this.fallback){var r;n=(r=this.fallback).resolve.apply(r,arguments)}return n},describe:function(e){return this.resolver&&this.resolver.lookupDescription?this.resolver.lookupDescription(e):this.fallback?this.fallback.describe(e):e},normalizeFullName:function(e){return this.resolver&&this.resolver.normalize?this.resolver.normalize(e):this.fallback?this.fallback.normalizeFullName(e):e},normalize:function(e){return this._normalizeCache[e]||(this._normalizeCache[e]=this.normalizeFullName(e))},makeToString:function(e,t){return this.resolver&&this.resolver.makeToString?this.resolver.makeToString(e,t):this.fallback?this.fallback.makeToString(e,t):e.toString()},has:function(e,t){if(!this.isValidFullName(e))return!1;var n=t&&t.source&&this.normalize(t.source);return u(this,this.normalize(e),n)},optionsForType:function(e,t){this._typeOptions[e]=t},getOptionsForType:function(e){var t=this._typeOptions[e];return void 0===t&&this.fallback&&(t=this.fallback.getOptionsForType(e)),t},options:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=this.normalize(e);this._options[n]=t},getOptions:function(e){var t=this.normalize(e),n=this._options[t];return void 0===n&&this.fallback&&(n=this.fallback.getOptions(e)),n},getOption:function(e,t){var n=this._options[e];if(n&&void 0!==n[t])return n[t];var r=e.split(":")[0];return n=this._typeOptions[r],n&&void 0!==n[t]?n[t]:this.fallback?this.fallback.getOption(e,t):void 0},typeInjection:function(e,t,n){var r=n.split(":")[0];if(r===e)throw new Error("Cannot inject a '"+n+"' on other "+e+"(s).");var i=this._typeInjections[e]||(this._typeInjections[e]=[]);i.push({property:t,fullName:n})},injection:function(e,t,n){this.validateFullName(n);var r=this.normalize(n);if(e.indexOf(":")===-1)return this.typeInjection(e,t,r);var i=this.normalize(e),o=this._injections[i]||(this._injections[i]=[]);o.push({property:t,fullName:r})},factoryTypeInjection:function(e,t,n){var r=this._factoryTypeInjections[e]||(this._factoryTypeInjections[e]=[]);r.push({property:t,fullName:this.normalize(n)})},factoryInjection:function(e,t,n){var r=this.normalize(e),i=this.normalize(n);if(this.validateFullName(n),e.indexOf(":")===-1)return this.factoryTypeInjection(r,t,i);var o=this._factoryInjections[r]||(this._factoryInjections[r]=[]);o.push({property:t,fullName:i})},knownForType:function(e){for(var n=void 0,r=void 0,i=t.dictionary(null),o=Object.keys(this.registrations),s=0;s0){var s="cycle detected: "+t;throw this.each(function(e){s+=" <- "+e}),new Error(s)}}},e.prototype.each=function(e){for(var t=this,n=t.result,r=t.vertices,i=0;i-1&&(i=i.replace(/\.(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("_")>-1&&(i=i.replace(/_(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("-")>-1&&(i=i.replace(/-(.)/g,function(e){return e.charAt(1).toUpperCase()})),n+":"+i}return e},resolve:function(e){var t,n=this.parseName(e),r=n.resolveMethodName;return this[r]&&(t=this[r](n)),t=t||this.resolveOther(n),n.root&&n.root.LOG_RESOLVER&&this._logLookup(t,n),t&&i.default(t,n),t},parseName:function(e){return this._parseNameCache[e]||(this._parseNameCache[e]=this._parseName(e))},_parseName:function(e){var t=e.split(":"),i=t[0],o=t[1],s=o,a=n.get(this,"namespace"),u=a,l=s.lastIndexOf("/"),c=l!==-1?s.slice(0,l):null;if("template"!==i&&l!==-1){var p=s.split("/");s=p[p.length-1];var h=r.String.capitalize(p.slice(0,-1).join("."));u=r.Namespace.byName(h)}var f="main"===o?"Main":r.String.classify(i);if(!s||!i)throw new TypeError("Invalid fullName: `"+e+"`, must be of the form `type:name` ");return{fullName:e,type:i,fullNameWithoutType:o,dirname:c,name:s,root:u,resolveMethodName:"resolve"+f}},lookupDescription:function(e){var t=this.parseName(e),n=void 0;return"template"===t.type?"template at "+t.fullNameWithoutType.replace(/\./g,"/"):(n=t.root+"."+r.String.classify(t.name).replace(/\./g,""),"model"!==t.type&&(n+=r.String.classify(t.type)),n)},makeToString:function(e,t){return e.toString()},useRouterNaming:function(e){e.name=e.name.replace(/\./g,"_"),"basic"===e.name&&(e.name="")},resolveTemplate:function(e){var t=e.fullNameWithoutType.replace(/\./g,"/");return o.getTemplate(t)||o.getTemplate(r.String.decamelize(t))},resolveView:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveController:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveRoute:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveModel:function(e){var t=r.String.classify(e.name),i=n.get(e.root,t);return i},resolveHelper:function(e){return this.resolveOther(e)},resolveOther:function(e){var t=r.String.classify(e.name)+r.String.classify(e.type),i=n.get(e.root,t);return i},resolveMain:function(e){var t=r.String.classify(e.type);return n.get(e.root,t)},_logLookup:function(e,t){var n=void 0,r=void 0;n=e?"[✓]":"[ ]",r=t.fullName.length>60?".":new Array(60-t.fullName.length).join(".")},knownForType:function(e){for(var i=n.get(this,"namespace"),o=r.String.classify(e),s=new RegExp(o+"$"),a=t.dictionary(null),u=Object.keys(i),l=0;l1?this.set("models",this._getModels(t)):this.set("models",[])}});a.toString=function(){return"LinkComponent"},a.reopenClass({positionalParams:"params"}),e.default=a}),s("ember-glimmer/components/text_area",["exports","ember-glimmer/component","ember-views","ember-glimmer/templates/empty"],function(e,t,n,r){"use strict";e.default=t.default.extend(n.TextSupport,{classNames:["ember-text-area"],layout:r.default,tagName:"textarea",attributeBindings:["rows","cols","name","selectionEnd","selectionStart","wrap","lang","dir","value"],rows:null,cols:null})}),s("ember-glimmer/components/text_field",["exports","ember-utils","ember-metal","ember-environment","ember-glimmer/component","ember-glimmer/templates/empty","ember-views"],function(e,t,n,r,i,o,s){"use strict";function a(e){if(e in l)return l[e];if(!r.environment.hasDOM)return l[e]=e,e;u||(u=document.createElement("input"));try{u.type=e}catch(e){}return l[e]=u.type===e}var u=void 0,l=new t.EmptyObject;e.default=i.default.extend(s.TextSupport,{layout:o.default,classNames:["ember-text-field"],tagName:"input",attributeBindings:["accept","autocomplete","autosave","dir","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","lang","list","max","min","multiple","name","pattern","size","step","type","value","width"],value:"",type:n.computed({get:function(){return"text"},set:function(e,t){var n="text";return a(t)&&(n=t),n}}),size:null,pattern:null,min:null,max:null})}),s("ember-glimmer/dom",["exports","glimmer-runtime","glimmer-node"],function(e,t,n){"use strict";e.DOMChanges=t.DOMChanges,e.DOMTreeConstruction=t.DOMTreeConstruction,e.NodeDOMTreeConstruction=n.NodeDOMTreeConstruction}),s("ember-glimmer/environment",["exports","ember-utils","ember-metal","ember-views","glimmer-runtime","ember-glimmer/syntax/curly-component","ember-glimmer/syntax","ember-glimmer/syntax/dynamic-component","ember-glimmer/utils/iterable","ember-glimmer/utils/references","ember-glimmer/helpers/if-unless","ember-glimmer/utils/bindings","ember-glimmer/helpers/action","ember-glimmer/helpers/component","ember-glimmer/helpers/concat","ember-glimmer/helpers/debugger","ember-glimmer/helpers/get","ember-glimmer/helpers/hash","ember-glimmer/helpers/loc","ember-glimmer/helpers/log","ember-glimmer/helpers/mut","ember-glimmer/helpers/readonly","ember-glimmer/helpers/unbound","ember-glimmer/helpers/-class","ember-glimmer/helpers/-input-type","ember-glimmer/helpers/query-param","ember-glimmer/helpers/each-in","ember-glimmer/helpers/-normalize-class","ember-glimmer/helpers/-html-safe","ember-glimmer/protocol-for-url","ember-glimmer/modifiers/action"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v,y,b,_,w,E,O,S,x,C,A,k,T,N){"use strict";var R={textarea:"-text-area"},P=function(e){function P(s){var a=this,u=s[t.OWNER];e.apply(this,arguments),this.owner=u,this.isInteractive=u.lookup("-environment:main").isInteractive,this.destroyedComponents=void 0,T.default(this),this._definitionCache=new n.Cache(2e3,function(e){var t=e.name,n=e.source,i=e.owner,s=r.lookupComponent(i,t,{source:n}),a=s.component,u=s.layout;if(a||u)return new o.CurlyComponentDefinition(t,a,u)},function(e){var n=e.name,r=e.source,i=e.owner,o=r&&i._resolveLocalLookupName(n,r)||n,s=t.guidFor(i);return s+"|"+o}),this._templateCache=new n.Cache(1e3,function(e){var n=e.Template,r=e.owner;if(n.create){var i;return n.create((i={env:a},i[t.OWNER]=r,i))}return n},function(e){var n=e.Template,r=e.owner;return t.guidFor(r)+"|"+n.id}),this._compilerCache=new n.Cache(10,function(e){return new n.Cache(2e3,function(t){var n=new e(t);return i.compileLayout(n,a)},function(e){var n=e.meta.owner;return t.guidFor(n)+"|"+e.id})},function(e){return e.id}),this.builtInModifiers={action:new N.default},this.builtInHelpers={if:c.inlineIf,action:h.default,component:f.default,concat:m.default,debugger:d.default,get:g.default,hash:v.default,loc:y.default,log:b.default,mut:_.default,"query-params":x.default,readonly:w.default,unbound:E.default,unless:c.inlineUnless,"-class":O.default,"-each-in":C.default,"-input-type":S.default,"-normalize-class":A.default,"-html-safe":k.default,"-get-dynamic-var":i.getDynamicVar}}return babelHelpers.inherits(P,e),P.create=function(e){return new P(e)},P.prototype.refineStatement=function(t,n){var r=e.prototype.refineStatement.call(this,t,n);if(r)return r;var i=t.appendType,u=t.isSimple,l=t.isInline,c=t.isBlock,h=(t.isModifier,t.key),f=t.path,m=t.args;if(u&&(l||c)&&"get"!==i){var d=s.findSyntaxBuilder(h);if(d)return d.create(this,m,n);var g=R[h],v=null;if(g?v=this.getComponentDefinition([g],n):h.indexOf("-")>=0&&(v=this.getComponentDefinition(f,n)),v)return p.wrapComponentClassAttribute(m),new o.CurlyComponentSyntax(m,v,n)}return l&&!u&&"helper"!==i?t.original.deopt():!u&&f?a.DynamicComponentSyntax.fromPath(this,f,m,n):void 0},P.prototype.hasComponentDefinition=function(){return!1},P.prototype.getComponentDefinition=function(e,t){var n=e[0],r=t.getMeta(),i=r.owner,o=r.moduleName&&"template:"+r.moduleName;return this._definitionCache.get({name:n,source:o,owner:i})},P.prototype.getTemplate=function(e,t){return this._templateCache.get({Template:e,owner:t})},P.prototype.getCompiledBlock=function(e,t){var n=this._compilerCache.get(e);return n.get(t)},P.prototype.hasPartial=function(e,t){var n=t.getMeta(),i=n.owner;return r.hasPartial(e,i)},P.prototype.lookupPartial=function(e,t){var n=t.getMeta(),i=n.owner,o={template:r.lookupPartial(e,i)};if(o.template)return o;throw new Error(e+" is not a partial")},P.prototype.hasHelper=function(e,t){if(e.length>1)return!1;var n=e[0];if(this.builtInHelpers[n])return!0;var r=t.getMeta(),i=r.owner,o={source:"template:"+r.moduleName};return i.hasRegistration("helper:"+n,o)||i.hasRegistration("helper:"+n)},P.prototype.lookupHelper=function(e,t){var n=e[0],r=this.builtInHelpers[n];if(r)return r;var i=t.getMeta(),o=i.owner,s=i.moduleName&&{source:"template:"+i.moduleName}||{};if(r=o.lookup("helper:"+n,s)||o.lookup("helper:"+n),r.isHelperInstance)return function(e,t){return l.SimpleHelperReference.create(r.compute,t)};if(r.isHelperFactory)return function(e,t){return l.ClassBasedHelperReference.create(r,e,t)};throw new Error(e+" is not a helper")},P.prototype.hasModifier=function(e){return!(e.length>1)&&!!this.builtInModifiers[e[0]]},P.prototype.lookupModifier=function(e){var t=this.builtInModifiers[e[0]];if(t)return t;throw new Error(e+" is not a modifier")},P.prototype.toConditionalReference=function(e){return l.ConditionalReference.create(e)},P.prototype.iterableFor=function(e,t){var n=t.named.get("key").value();return u.default(e,n)},P.prototype.scheduleInstallModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleInstallModifier).call.apply(t,[this].concat(babelHelpers.slice.call(arguments)))}},P.prototype.scheduleUpdateModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleUpdateModifier).call.apply(t,[this].concat(babelHelpers.slice.call(arguments)))}},P.prototype.didDestroy=function(e){e.destroy()},P.prototype.begin=function(){this.inTransaction=!0,e.prototype.begin.call(this),this.destroyedComponents=[]},P.prototype.commit=function(){for(var t=0;t1?n.String.dasherize(t.at(1).value()):null:o===!1?i>2?n.String.dasherize(t.at(2).value()):null:o}e.default=function(e,n){return new t.InternalHelperReference(r,n); -}}),s("ember-glimmer/helpers/-html-safe",["exports","ember-glimmer/utils/references","ember-glimmer/utils/string"],function(e,t,n){"use strict";function r(e){var t=e.positional,r=t.at(0);return new n.SafeString(r.value())}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/-input-type",["exports","ember-glimmer/utils/references"],function(e,t){"use strict";function n(e){var t=e.positional,n=(e.named,t.at(0).value());return"checkbox"===n?"-checkbox":"-text-field"}e.default=function(e,r){return new t.InternalHelperReference(n,r)}}),s("ember-glimmer/helpers/-normalize-class",["exports","ember-glimmer/utils/references","ember-runtime"],function(e,t,n){"use strict";function r(e){var t=e.positional,r=(e.named,t.at(0).value().split(".")),i=r[r.length-1],o=t.at(1).value();return o===!0?n.String.dasherize(i):o||0===o?String(o):""}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/action",["exports","ember-utils","ember-glimmer/utils/references","ember-metal"],function(e,t,n,r){"use strict";function i(e,t,n,i){var o=void 0,a=i.length;return o=a>0?function(){for(var o=arguments.length,s=Array(o),u=0;u0&&(l[0]=r.get(l[0],n));var p={target:e,args:l,label:"glimmer-closure-action"};return r.flaggedInstrument("interaction.ember-action",p,function(){return r.run.join.apply(r.run,[e,t].concat(l))})}:function(){for(var i=arguments.length,o=Array(i),s=0;s0&&(o[0]=r.get(o[0],n));var a={target:e,args:o,label:"glimmer-closure-action"};return r.flaggedInstrument("interaction.ember-action",a,function(){return r.run.join.apply(r.run,[e,t].concat(o))})},o[s]=!0,o}e.createClosureAction=i;var o=t.symbol("INVOKE");e.INVOKE=o;var s=t.symbol("ACTION");e.ACTION=s;var a=function(e){function t(t){e.call(this),this.args=t,this.tag=t.tag}return babelHelpers.inherits(t,e),t.create=function(e){return new t(e)},t.prototype.compute=function(){var e=this.args,t=e.named,n=e.positional,s=n.value(),a=s[0],u=n.at(1),l=s[1],c=s.slice(2),p=typeof l,h=l;if(u[o])a=u,h=u[o];else{if(r.isNone(l))throw new r.Error("Action passed is null or undefined in (action) from "+a+".");if("string"===p){var f=l;if(h=null,t.has("target")&&(a=t.get("target").value()),a.actions&&(h=a.actions[f]),!h)throw new r.Error("An action named '"+f+"' was not found in "+a)}else if(h&&"function"==typeof h[o])a=h,h=h[o];else if("function"!==p){var m=u._propertyKey||l;throw new r.Error("An action could not be made for `"+m+"` in "+a+". Please confirm that you are using either a quoted action name (i.e. `(action '"+m+"')`) or a function available in "+a+".")}}var d=t.get("value").value();return i(a,h,d,c)},t}(n.CachedReference);e.ClosureActionReference=a,e.default=function(e,t){return a.create(t)}}),s("ember-glimmer/helpers/component",["exports","ember-utils","ember-glimmer/utils/references","ember-glimmer/syntax/curly-component","glimmer-runtime","ember-metal"],function(e,t,n,r,i,o){"use strict";function s(e,t){var n=a(e,t);return new r.CurlyComponentDefinition(e.name,e.ComponentClass,e.template,n)}function a(e,n){var o=e.args,s=e.ComponentClass,a=s.positionalParams,u=n.positional.values,l=u.slice(1);a&&l.length&&r.validatePositionalParameters(n.named,l,a);var c="string"==typeof a,p={};if(!c&&a&&a.length>0){for(var h=Math.min(a.length,l.length),f=0;f=0)return!0;for(var n=0;n1)if(u=a.at(0),p=a.at(1),p[i.INVOKE])c=p;else{p._propertyKey;c=p.value()}for(var h=[],f=2;f10)throw y=0,v[n].destroy(),new Error("infinite rendering invalidation detected");return y++,m.join(null,p)}y=0}var f=void 0;f=function(e,t){return e[t](),!1};var m=n.run.backburner,d=function(){function e(e,t,n,r){this.view=e,this.outletState=t,this.rootOutletState=n}return e.prototype.child=function(){return new e(this.view,this.outletState,this.rootOutletState)},e.prototype.get=function(e){return this.outletState},e.prototype.set=function(e,t){return this.outletState=t,t},e}(),g=function(){function e(e,t,n,r,o,s){var a=this;this.id=i.getViewId(e),this.env=t,this.root=e,this.result=void 0,this.shouldReflush=!1,this.destroyed=!1,this._removing=!1;var u=this.options={alwaysRevalidate:!1};this.render=function(){var e=a.result=n.render(r,o,s);a.render=function(){e.rerender(u)}}}return e.prototype.isFor=function(e){return this.root===e},e.prototype.destroy=function(){var e=this.result,t=this.env;if(this.destroyed=!0,this.env=null,this.root=null,this.result=null,this.render=null,e){var n=!t.inTransaction;n&&t.begin(),e.destroy(),n&&t.commit()}},e}(),v=[];n.setHasViews(function(){return v.length>0});var y=0;m.on("begin",c),m.on("end",h);var b=function(){function e(e,t){var n=arguments.length<=2||void 0===arguments[2]?i.fallbackViewRegistry:arguments[2],r=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];this._env=e,this._rootTemplate=t,this._viewRegistry=n,this._destinedForDOM=r,this._destroyed=!1,this._roots=[],this._lastRevision=null,this._isRenderingRoots=!1,this._removedRoots=[]}return e.prototype.appendOutletView=function(e,t){var n=new a.TopLevelOutletComponentDefinition(e),r=e.toReference(),i=e.outletState.render.controller;this._appendDefinition(e,n,t,r,i)},e.prototype.appendTo=function(e,t){var n=new s.RootComponentDefinition(e);this._appendDefinition(e,n,t)},e.prototype._appendDefinition=function(e,n,i){var o=arguments.length<=3||void 0===arguments[3]?r.UNDEFINED_REFERENCE:arguments[3],s=arguments.length<=4||void 0===arguments[4]?null:arguments[4],a=new t.RootReference(n),u=new d(null,o,o,!0,s),l=new g(e,this._env,this._rootTemplate,a,i,u);this._renderRoot(l)},e.prototype.rerender=function(e){this._scheduleRevalidate()},e.prototype.register=function(e){var t=i.getViewId(e);this._viewRegistry[t]=e},e.prototype.unregister=function(e){delete this._viewRegistry[i.getViewId(e)]},e.prototype.remove=function(e){e._transitionTo("destroying"),this.cleanupRootFor(e),i.setViewElement(e,null),this._destinedForDOM&&e.trigger("didDestroyElement"),e.isDestroying||e.destroy()},e.prototype.cleanupRootFor=function(e){if(!this._destroyed)for(var t=this._roots,n=this._roots.length;n--;){var r=t[n];r.isFor(e)&&r.destroy()}},e.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this._clearAllRoots())},e.prototype.getElement=function(e){},e.prototype.getBounds=function(e){var t=e[o.BOUNDS],n=t.parentElement(),r=t.firstNode(),i=t.lastNode();return{parentElement:n,firstNode:r,lastNode:i}},e.prototype.createElement=function(e){return this._env.getAppendOperations().createElement(e)},e.prototype._renderRoot=function(e){var t=this._roots;t.push(e),1===t.length&&u(this),this._renderRootsTransaction()},e.prototype._renderRoots=function(){var e=this._roots,t=this._env,n=this._removedRoots,i=void 0,o=void 0;do{t.begin(),o=e.length,i=!1;for(var s=0;s=o&&!u||(a.options.alwaysRevalidate=u,u=a.shouldReflush=f(a,"render"),i=i||u)}}this._lastRevision=r.CURRENT_TAG.value(),t.commit()}while(i||e.length>o);for(;n.length;){var a=n.pop(),c=e.indexOf(a);e.splice(c,1)}0===this._roots.length&&l(this)},e.prototype._renderRootsTransaction=function(){if(!this._isRenderingRoots){this._isRenderingRoots=!0;var e=!1;try{this._renderRoots(),e=!0}finally{e||(this._lastRevision=r.CURRENT_TAG.value()),this._isRenderingRoots=!1}}},e.prototype._clearAllRoots=function(){for(var e=this._roots,t=0;t-1)return c[t]}e.registerSyntax=a,e.findSyntaxBuilder=u;var l=[],c=[];a("render",t.RenderSyntax),a("outlet",n.OutletSyntax),a("mount",r.MountSyntax),a("component",i.DynamicComponentSyntax),a("input",o.InputSyntax),a("-with-dynamic-vars",function(){function e(){}return e.create=function(e,t,n){return new s.WithDynamicVarsSyntax(t)},e}()),a("-in-element",function(){function e(){}return e.create=function(e,t,n){return new s.InElementSyntax(t)},e}())}),s("ember-glimmer/syntax/curly-component",["exports","ember-utils","glimmer-runtime","ember-glimmer/utils/bindings","ember-glimmer/component","ember-metal","ember-views","ember-glimmer/utils/process-args","container"],function(e,t,n,r,i,o,s,a,u){"use strict";function l(e,t){}function c(e,t,n){}function p(e,t){e.named.has("id")&&(t.elementId=t.id)}function h(e,t,n,i){for(var o=[],s=t.length-1;s!==-1;){var a=t[s],u=r.AttributeBinding.parse(a),l=u[1];o.indexOf(l)===-1&&(o.push(l),r.AttributeBinding.install(e,n,u,i)),s--}o.indexOf("id")===-1&&i.addStaticAttribute(e,"id",n.elementId),o.indexOf("style")===-1&&r.IsVisibleBinding.install(e,n,i)}function f(){}function m(e){return e.instrumentDetails({initialRender:!0})}function d(e){return e.instrumentDetails({initialRender:!1})}function g(e){var t=e.dynamicScope().view.tagName;return n.PrimitiveReference.create(""===t?null:t||"div")}function v(e){return e.getSelf().get("ariaRole")}e.validatePositionalParameters=c;var y=babelHelpers.taggedTemplateLiteralLoose(["template:components/-default"],["template:components/-default"]),b=u.privatize(y),_=function(e){function t(t,n,r){e.call(this),this.args=t,this.definition=n,this.symbolTable=r,this.shadow=null}return babelHelpers.inherits(t,e),t.prototype.compile=function(e){e.component.static(this.definition,this.args,this.symbolTable,this.shadow)},t}(n.StatementSyntax);e.CurlyComponentSyntax=_;var w=function(){function e(e,t,n,r){this.environment=e,this.component=t,this.classRef=null,this.args=n,this.argsRevision=n.tag.value(),this.finalizer=r}return e.prototype.destroy=function(){var e=this.component,t=this.environment;t.isInteractive&&(e.trigger("willDestroyElement"),e.trigger("willClearRender")),t.destroyedComponents.push(e)},e.prototype.finalize=function(){var e=this.finalizer;e(),this.finalizer=f},e}(),E=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return c(t.named,t.positional.values,e.ComponentClass.positionalParams),a.gatherArgs(t,e)},e.prototype.create=function(e,t,n,r,s,u){var c=r.view,h=t.ComponentClass,f=a.ComponentArgs.create(n),d=f.value(),g=d.props;p(n,g),g.parentView=c,g[i.HAS_BLOCK]=u,g._targetObject=s.value();var v=h.create(g),y=o._instrumentStart("render.component",m,v);r.view=v,null!==c&&c.appendChild(v),""===v.tagName&&(e.isInteractive&&v.trigger("willRender"),v._transitionTo("hasElement"),e.isInteractive&&v.trigger("willInsertElement"));var b=new w(e,v,f,y);return n.named.has("class")&&(b.classRef=n.named.get("class")),l(v,g),e.isInteractive&&""!==v.tagName&&v.trigger("willRender"),b},e.prototype.layoutFor=function(e,t,n){var r=e.template;if(!r){var i=t.component;r=this.templateFor(i,n)}return n.getCompiledBlock(k,r)},e.prototype.templateFor=function(e,n){var r=o.get(e,"layout"),i=e[t.OWNER];if(r)return n.getTemplate(r,i);var s=o.get(e,"layoutName");if(s){var a=i.lookup("template:"+s);if(a)return a}return i.lookup(b)},e.prototype.getSelf=function(e){var t=e.component;return t[i.ROOT_REF]},e.prototype.didCreateElement=function(e,t,n){var i=e.component,o=e.classRef,a=e.environment;s.setViewElement(i,t);var u=i.attributeBindings,l=i.classNames,c=i.classNameBindings;u&&u.length?h(t,u,i,n):(n.addStaticAttribute(t,"id",i.elementId),r.IsVisibleBinding.install(t,i,n)),o&&n.addDynamicAttribute(t,"class",o),l&&l.length&&l.forEach(function(e){n.addStaticAttribute(t,"class",e)}),c&&c.length&&c.forEach(function(e){r.ClassNameBinding.install(t,i,e,n)}),i._transitionTo("hasElement"),a.isInteractive&&i.trigger("willInsertElement")},e.prototype.didRenderLayout=function(e,t){e.component[i.BOUNDS]=t,e.finalize()},e.prototype.getTag=function(e){var t=e.component;return t[i.DIRTY_TAG]},e.prototype.didCreate=function(e){var t=e.component,n=e.environment;n.isInteractive&&(t._transitionTo("inDOM"),t.trigger("didInsertElement"),t.trigger("didRender"))},e.prototype.update=function(e,t,n){var r=e.component,s=e.args,a=e.argsRevision,u=e.environment;if(e.finalizer=o._instrumentStart("render.component",d,r),!s.tag.validate(a)){var l=s.value(),c=l.attrs,p=l.props;e.argsRevision=s.tag.value();var h=r.attrs,f=c;r[i.IS_DISPATCHING_ATTRS]=!0,r.setProperties(p),r[i.IS_DISPATCHING_ATTRS]=!1,r.trigger("didUpdateAttrs",{oldAttrs:h,newAttrs:f}),r.trigger("didReceiveAttrs",{oldAttrs:h,newAttrs:f})}u.isInteractive&&(r.trigger("willUpdate"),r.trigger("willRender"))},e.prototype.didUpdateLayout=function(e){e.finalize()},e.prototype.didUpdate=function(e){var t=e.component,n=e.environment;n.isInteractive&&(t.trigger("didUpdate"),t.trigger("didRender"))},e.prototype.getDestructor=function(e){return e},e}(),O=new E,S=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r,i,s){var a=t.ComponentClass,u=o._instrumentStart("render.component",m,a);return r.view=a,""===a.tagName&&(e.isInteractive&&a.trigger("willRender"),a._transitionTo("hasElement"),e.isInteractive&&a.trigger("willInsertElement")),l(a,{}),new w(e,a,n,u)},t}(E),x=new S,C=function(e){function t(t,n,r,i){e.call(this,t,O,n),this.template=r,this.args=i}return babelHelpers.inherits(t,e),t}(n.ComponentDefinition);e.CurlyComponentDefinition=C;var A=function(e){function t(t){e.call(this,"-root",x,t),this.template=void 0,this.args=void 0}return babelHelpers.inherits(t,e),t}(n.ComponentDefinition);e.RootComponentDefinition=A;var k=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout()),e.tag.dynamic(g),e.attrs.dynamic("role",v),e.attrs.static("class","ember-view")},e}();k.id="curly"}),s("ember-glimmer/syntax/dynamic-component",["exports","glimmer-runtime","glimmer-reference","ember-metal"],function(e,t,n,r){"use strict";function i(e,t){var n=e.env,r=e.getArgs(),i=r.positional.at(0);return new s({nameRef:i,env:n,symbolTable:t})}var o=function(e){function n(t,n,r){e.call(this),this.definition=i,this.definitionArgs=t,this.args=n,this.symbolTable=r,this.shadow=null}return babelHelpers.inherits(n,e),n.create=function(e,n,r){var i=t.ArgsSyntax.fromPositionalArgs(n.positional.slice(0,1)),o=t.ArgsSyntax.build(n.positional.slice(1),n.named,n.blocks);return new this(i,o,r)},n.fromPath=function(e,n,r,i){var o=t.ArgsSyntax.fromPositionalArgs(t.PositionalArgsSyntax.build([t.GetSyntax.build(n.join("."))]));return new this(o,r,i)},n.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},n}(t.StatementSyntax);e.DynamicComponentSyntax=o;var s=function(){function e(e){var t=e.nameRef,n=e.env,r=e.symbolTable,i=e.args;this.tag=t.tag,this.nameRef=t,this.env=n,this.symbolTable=r,this.args=i}return e.prototype.value=function(){var e=this.env,n=this.nameRef,r=this.symbolTable,i=n.value();if("string"==typeof i){var o=e.getComponentDefinition([i],r);return o}return t.isComponentDefinition(i)?i:null},e.prototype.get=function(){return n.UNDEFINED_REFERENCE},e}()}),s("ember-glimmer/syntax/input",["exports","ember-metal","ember-glimmer/syntax/curly-component","ember-glimmer/syntax/dynamic-component","ember-glimmer/utils/bindings"],function(e,t,n,r,i){"use strict";function o(e,t,r){var o=t("-text-field");return i.wrapComponentClassAttribute(e),new n.CurlyComponentSyntax(e,o,r)}var s={create:function(e,t,s){var a=function(t){return e.getComponentDefinition([t],s)};if(!t.named.has("type"))return o(t,a,s);var u=t.named.at("type");if("value"===u.type){if("checkbox"===u.value){i.wrapComponentClassAttribute(t);var l=a("-checkbox");return new n.CurlyComponentSyntax(t,l,s)}return o(t,a,s)}return r.DynamicComponentSyntax.create(e,t,s)}};e.InputSyntax=s}),s("ember-glimmer/syntax/mount",["exports","glimmer-runtime","glimmer-reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet"],function(e,t,n,r,i,o,s){"use strict";var a=function(e){function n(t,n){e.call(this),this.definition=t,this.symbolTable=n}return babelHelpers.inherits(n,e),n.create=function(e,t,r){var i=t.positional.at(0).inner(),o=new c(i,e);return new n(o,r)},n.prototype.compile=function(e){e.component.static(this.definition,t.ArgsSyntax.empty(),null,this.symbolTable,null)},n}(t.StatementSyntax);e.MountSyntax=a;var u=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.create=function(e,t,r,i){var o=t.name,s=t.env;i.outletState=n.UNDEFINED_REFERENCE;var a=s.owner.buildChildEngineInstance(o);return a.boot(),{engine:a}},e.prototype.layoutFor=function(e,t,n){var r=t.engine,i=r.lookup("template:application");return n.getCompiledBlock(s.OutletLayoutCompiler,i)},e.prototype.getSelf=function(e){var t=e.engine,n=t._lookupFactory("controller:application")||o.generateControllerFactory(t,"application"); -return new i.RootReference(n.create())},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(e){var t=e.engine;return t},e.prototype.didCreateElement=function(){},e.prototype.didRenderLayout=function(){},e.prototype.didCreate=function(e){},e.prototype.update=function(e,t,n){},e.prototype.didUpdateLayout=function(){},e.prototype.didUpdate=function(e){},e}(),l=new u,c=function(e){function t(t,n){e.call(this,t,l,null),this.env=n}return babelHelpers.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/syntax/outlet",["exports","ember-utils","glimmer-runtime","ember-metal","ember-glimmer/utils/references","glimmer-reference"],function(e,t,n,r,i,o){"use strict";function s(e){var t=e.dynamicScope(),n=t.outletState,r=e.getArgs(),i=void 0;return i=0===r.positional.length?new o.ConstReference("main"):r.positional.at(0),new p(i,n)}function a(e,t,n){return t||n?!t&&n||t&&!n?null:n.render.template===t.render.template&&n.render.controller===t.render.controller?e:null:e}function u(e){var t=e.render,n=t.name,r=t.outlet;return{object:n+":"+r}}function l(){}var c=function(e){function t(t,r,i){e.call(this),this.definitionArgs=r,this.definition=s,this.args=n.ArgsSyntax.empty(),this.symbolTable=i,this.shadow=null}return babelHelpers.inherits(t,e),t.create=function(e,t,r){var i=n.ArgsSyntax.fromPositionalArgs(t.positional.slice(0,1));return new this(e,i,r)},t.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},t}(n.StatementSyntax);e.OutletSyntax=c;var p=function(){function e(e,t){this.outletNameRef=e,this.parentOutletStateRef=t,this.definition=null,this.lastState=null;var n=this.outletStateTag=new o.UpdatableTag(t.tag);this.tag=o.combine([n.tag,e.tag])}return e.prototype.value=function(){var e=this.outletNameRef,t=this.parentOutletStateRef,n=this.definition,r=this.lastState,i=e.value(),o=t.get("outlets").get(i),s=this.lastState=o.value();this.outletStateTag.update(o.tag),n=a(n,r,s);var u=s&&s.render.template;return n?n:u?this.definition=new b(i,s.render.template):this.definition=null},e}(),h=function(){function e(e){this.outletState=e,this.instrument()}return e.prototype.instrument=function(){this.finalizer=r._instrumentStart("render.outlet",u,this.outletState)},e.prototype.finalize=function(){var e=this.finalizer;e(),this.finalizer=l},e}(),f=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.create=function(e,t,n,r){var i=r.outletState=r.outletState.get("outlets").get(t.outletName),o=i.value();return new h(o)},e.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(_,e.template)},e.prototype.getSelf=function(e){var t=e.outletState;return new i.RootReference(t.render.controller)},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(){return null},e.prototype.didRenderLayout=function(e){e.finalize()},e.prototype.didCreateElement=function(){},e.prototype.didCreate=function(e){},e.prototype.update=function(e){},e.prototype.didUpdateLayout=function(e){},e.prototype.didUpdate=function(e){},e}(),m=new f,d=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){return new h(r.outletState.value())},t.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(y,e.template)},t}(f),g=new d,v=function(e){function n(n){e.call(this,"outlet",g,n),this.template=n.template,t.generateGuid(this)}return babelHelpers.inherits(n,e),n}(n.ComponentDefinition);e.TopLevelOutletComponentDefinition=v;var y=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout()),e.tag.static("div"),e.attrs.static("id",t.guidFor(this)),e.attrs.static("class","ember-view")},e}();y.id="top-level-outlet";var b=function(e){function n(n,r){e.call(this,"outlet",m,null),this.outletName=n,this.template=r,t.generateGuid(this)}return babelHelpers.inherits(n,e),n}(n.ComponentDefinition),_=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout())},e}();e.OutletLayoutCompiler=_,_.id="outlet"}),s("ember-glimmer/syntax/render",["exports","glimmer-runtime","glimmer-reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet"],function(e,t,n,r,i,o,s){"use strict";function a(e){var t=e.env,r=e.getArgs(),i=r.positional.at(0),o=i.value(),s=t.owner.lookup("template:"+o),a=void 0;if(r.named.has("controller")){var u=r.named.get("controller");a=u.value()}else a=o;return 1===r.positional.length?new n.ConstReference(new m(a,s,t,p)):new n.ConstReference(new m(a,s,t,f))}var u=function(e){function n(n,r,i){e.call(this),this.definitionArgs=r,this.definition=a,this.args=t.ArgsSyntax.fromPositionalArgs(r.positional.slice(1,2)),this.symbolTable=i,this.shadow=null}return babelHelpers.inherits(n,e),n.create=function(e,t,n){return new this(e,t,n)},n.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},n}(t.StatementSyntax);e.RenderSyntax=u;var l=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(s.OutletLayoutCompiler,e.template)},e.prototype.getSelf=function(e){var t=e.controller;return new i.RootReference(t)},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(){return null},e.prototype.didCreateElement=function(){},e.prototype.didRenderLayout=function(){},e.prototype.didCreate=function(){},e.prototype.update=function(){},e.prototype.didUpdateLayout=function(){},e.prototype.didUpdate=function(){},e}(),c=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,a=s.owner.lookup("controller:"+i)||o.generateController(s.owner,i);return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:a}},t}(l),p=new c,h=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,a=n.positional.at(0),u=s.owner._lookupFactory("controller:"+i)||o.generateControllerFactory(s.owner,i),l=u.create({model:a.value()});return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:l}},t.prototype.update=function(e,t,n){var r=e.controller;r.set("model",t.positional.at(0).value())},t.prototype.getDestructor=function(e){var t=e.controller;return t},t}(l),f=new h,m=function(e){function t(t,n,r,i){e.call(this,"render",i,null),this.name=t,this.template=n,this.env=r}return babelHelpers.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/template",["exports","ember-utils","glimmer-runtime"],function(e,t,n){"use strict";function r(e){var r=n.templateFactory(e);return{id:r.id,meta:r.meta,create:function(e){return r.create(e.env,{owner:e[t.OWNER]})}}}e.default=r}),s("ember-glimmer/template_registry",["exports"],function(e){"use strict";function t(e){s=e}function n(){return s}function r(e){if(s.hasOwnProperty(e))return s[e]}function i(e){return s.hasOwnProperty(e)}function o(e,t){return s[e]=t}e.setTemplates=t,e.getTemplates=n,e.getTemplate=r,e.hasTemplate=i,e.setTemplate=o;var s={}}),s("ember-glimmer/templates/component",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"ZoGfVsSJ",block:'{"statements":[["yield","default"]],"locals":[],"named":[],"yields":["default"],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/component.hbs"}})}),s("ember-glimmer/templates/empty",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"qEHL4OLi",block:'{"statements":[],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/empty.hbs"}})}),s("ember-glimmer/templates/link-to",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"Ca7iQMR7",block:'{"statements":[["block",["if"],[["get",["linkTitle"]]],null,1,0]],"locals":[],"named":[],"yields":["default"],"blocks":[{"statements":[["yield","default"]],"locals":[]},{"statements":[["append",["unknown",["linkTitle"]],false]],"locals":[]}],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/link-to.hbs"}})}),s("ember-glimmer/templates/outlet",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"sYQo9vi/",block:'{"statements":[["append",["unknown",["outlet"]],false]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/outlet.hbs"}})}),s("ember-glimmer/templates/root",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"Eaf3RPY3",block:'{"statements":[["append",["helper",["component"],[["get",[null]]],null],false]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/root.hbs"}})}),s("ember-glimmer/utils/bindings",["exports","glimmer-reference","glimmer-runtime","ember-metal","ember-runtime","ember-glimmer/component","ember-glimmer/utils/string"],function(e,t,n,r,i,o,s){"use strict";function a(e,t){return e[o.ROOT_REF].get(t)}function u(e,n){var r="attrs"===n[0];return r&&(n.shift(),1===n.length)?a(e,n[0]):t.referenceFromParts(e[o.ROOT_REF],n)}function l(e){var t=e.named,r=t.keys.indexOf("class");if(r!==-1){var i=t.values[r],o=i.ref,s=i.type;if("get"===s){var a=o.parts[o.parts.length-1];t.values[r]=n.HelperSyntax.fromSpec(["helper",["-class"],[["get",o.parts],a],null])}}return e}e.wrapComponentClassAttribute=l;var c={parse:function(e){var t=e.indexOf(":");if(t===-1)return[e,e,!0];var n=e.substring(0,t),r=e.substring(t+1);return[n,r,!1]},install:function(e,t,n,i){var o=n[0],s=n[1];n[2];if("id"===s){var l=r.get(t,o);return void 0!==l&&null!==l||(l=t.elementId),void i.addStaticAttribute(e,"id",l)}var c=o.indexOf(".")>-1,p=c?u(t,o.split(".")):a(t,o);"style"===s&&(p=new f(p,a(t,"isVisible"))),i.addDynamicAttribute(e,s,p)}};e.AttributeBinding=c;var p="display: none;",h=s.htmlSafe(p),f=function(e){function n(n,r){e.call(this),this.tag=t.combine([n.tag,r.tag]),this.inner=n,this.isVisible=r}return babelHelpers.inherits(n,e),n.prototype.compute=function(){var e=this.inner.value(),t=this.isVisible.value();if(t!==!1)return e;if(e||0===e){var n=e+" "+p;return s.isHTMLSafe(e)?s.htmlSafe(n):n}return h},n}(t.CachedReference),m={install:function(e,n,r){r.addDynamicAttribute(e,"style",t.map(a(n,"isVisible"),this.mapStyleValue))},mapStyleValue:function(e){return e===!1?h:null}};e.IsVisibleBinding=m;var d={install:function(e,t,n,r){var i=n.split(":"),o=i[0],s=i[1],l=i[2],c=""===o;if(c)r.addStaticAttribute(e,"class",s);else{var p=o.indexOf(".")>-1,h=p&&o.split("."),f=p?u(t,h):a(t,o),m=void 0;m=void 0===s?new g(f,p?h[h.length-1]:o):new v(f,s,l),r.addDynamicAttribute(e,"class",m)}}};e.ClassNameBinding=d;var g=function(e){function t(t,n){e.call(this),this.tag=t.tag,this.inner=t,this.path=n,this.dasherizedPath=null}return babelHelpers.inherits(t,e),t.prototype.compute=function(){var e=this.inner.value();if(e===!0){var t=this.path,n=this.dasherizedPath;return n||(this.dasherizedPath=i.String.dasherize(t))}return e||0===e?e:null},t}(t.CachedReference),v=function(e){function t(t,n,r){e.call(this),this.tag=t.tag,this.inner=t,this.truthy=n||null,this.falsy=r||null}return babelHelpers.inherits(t,e),t.prototype.compute=function(){var e=this.inner,t=this.truthy,n=this.falsy;return e.value()?t:n},t}(t.CachedReference)}),s("ember-glimmer/utils/iterable",["exports","ember-utils","ember-metal","ember-runtime","ember-glimmer/utils/references","ember-glimmer/helpers/each-in","glimmer-reference"],function(e,t,n,r,i,o,s){"use strict";function a(e,t){return o.isEachIn(e)?new b(e,u(t)):new _(e,l(t))}function u(e){switch(e){case"@index":case void 0:case null:return c;case"@identity":return p;default:return function(t){return n.get(t,e)}}}function l(e){switch(e){case"@index":return c;case"@identity":case void 0:case null:return p;default:return function(t){return n.get(t,e)}}}function c(e,t){return String(t)}function p(e){switch(typeof e){case"string":case"number":return String(e);default:return t.guidFor(e)}}function h(e,t){var n=e[t];return n?(e[t]++,""+t+f+n):(e[t]=1,t)}e.default=a;var f="be277757-bbbe-4620-9fcb-213ef433cca2",m=function(){function e(e,n){this.array=e,this.length=e.length,this.keyFor=n,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return!1},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,r=this.position,i=this.seen;if(r>=t)return null;var o=e[r],s=r,a=h(i,n(o,s));return this.position++,{key:a,value:o,memo:s}},e}(),d=function(){function e(e,r){this.array=e,this.length=n.get(e,"length"),this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.length},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,i=this.position,o=this.seen;if(i>=t)return null;var s=r.objectAt(e,i),a=i,u=h(o,n(s,a));return this.position++,{key:u,value:s,memo:a}},e}(),g=function(){function e(e,n,r){this.keys=e,this.values=n,this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.keys.length},e.prototype.next=function(){var e=this.keys,t=this.values,n=this.keyFor,r=this.position,i=this.seen;if(r>=e.length)return null;var o=t[r],s=e[r],a=h(i,n(o,s));return this.position++,{key:a,value:o,memo:s}},e}(),v=function(){function e(){}return e.prototype.isEmpty=function(){return!0},e.prototype.next=function(){throw new Error("Cannot call next() on an empty iterator")},e}(),y=new v,b=function(){function e(e,t){this.ref=e,this.keyFor=t;var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG);this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,r=this.valueTag,i=e.value();r.update(n.tagFor(i)),n.isProxy(i)&&(i=n.get(i,"content"));var o=typeof i;if(!i||"object"!==o&&"function"!==o)return y;var s=Object.keys(i),a=s.map(function(e){return i[e]});return s.length>0?new g(s,a,t):y},e.prototype.valueReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateValueReference=function(e,t){e.update(t.memo)},e.prototype.memoReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateMemoReference=function(e,t){e.update(t.value)},e}(),_=function(){function e(e,t){this.ref=e,this.keyFor=t;var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG);this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,i=this.valueTag,o=e.value();if(i.update(n.tagForProperty(o,"[]")),!o||"object"!=typeof o)return y;if(Array.isArray(o))return o.length>0?new m(o,t):y;if(r.isEmberArray(o))return n.get(o,"length")>0?new d(o,t):y;if("function"!=typeof o.forEach)return y;var s=function(){var e=[];return o.forEach(function(t){e.push(t)}),{v:e.length>0?new m(e,t):y}}();return"object"==typeof s?s.v:void 0},e.prototype.valueReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateValueReference=function(e,t){e.update(t.value)},e.prototype.memoReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateMemoReference=function(e,t){e.update(t.memo)},e}()}),s("ember-glimmer/utils/process-args",["exports","ember-utils","glimmer-reference","ember-glimmer/component","ember-glimmer/utils/references","ember-views","ember-glimmer/helpers/action","glimmer-runtime"],function(e,t,n,r,i,o,s,a){"use strict";function u(e,t){var n=l(e,t),r=c(e,t);return p(n,r,e.blocks,t.ComponentClass)}function l(e,n){var r=e.named.map;return n.args?t.assign({},n.args.named.map,r):r}function c(e,t){var n=e.positional.values;if(t.args){var r=t.args.positional.values,i=[];return i.push.apply(i,r),i.splice.apply(i,[0,n.length].concat(n)),i}return n}function p(e,t,n,r){var i=r.positionalParams;return i&&i.length>0&&t.length>0&&(e="string"==typeof i?h(e,t,i):f(e,t,i)),a.EvaluatedArgs.named(e,n)}function h(e,n,r){var i=t.assign({},e);return i[r]=a.EvaluatedPositionalArgs.create(n),i}function f(e,n,r){for(var i=t.assign({},e),o=Math.min(n.length,r.length),s=0;s":">",'"':""","'":"'","`":"`","=":"="},l=/[&<>"'`=]/,c=/[&<>"'`=]/g}),s("ember-glimmer/utils/to-bool",["exports","ember-runtime","ember-metal"],function(e,t,n){"use strict";function r(e){return!!e&&(e===!0||(!t.isArray(e)||0!==n.get(e,"length")))}e.default=r}),s("ember-glimmer/views/outlet",["exports","ember-utils","glimmer-reference","ember-environment","ember-metal"],function(e,t,n,r,i){"use strict";var o=function(){function e(e){this.outletView=e,this.tag=e._tag}return e.prototype.get=function(e){return new a(this,e)},e.prototype.value=function(){return this.outletView.outletState},e.prototype.getOrphan=function(e){return new s(this,e)},e.prototype.update=function(e){this.outletView.setOutletState(e)},e}(),s=function(e){function n(t,n){e.call(this,t.outletView),this.root=t,this.name=n}return babelHelpers.inherits(n,e),n.prototype.value=function(){var e=this.root.value(),n=e.outlets.main.outlets.__ember_orphans__;if(!n)return null;var r=n.outlets[this.name];if(!r)return null;var i=new t.EmptyObject;return i[r.render.outlet]=r,r.wasUsed=!0,{outlets:i}},n}(o),a=function(){function e(e,t){this.parent=e,this.key=t,this.tag=e.tag}return e.prototype.get=function(t){return new e(this,t)},e.prototype.value=function(){return this.parent.value()[this.key]},e}(),u=function(){function e(e,t,r,i){this._environment=e,this.renderer=t,this.owner=r,this.template=i,this.outletState=null,this._tag=new n.DirtyableTag}return e.extend=function(n){return function(e){function r(){e.apply(this,arguments)}return babelHelpers.inherits(r,e),r.create=function(r){return r?e.create.call(this,t.assign({},n,r)):e.create.call(this,n)},r}(e)},e.reopenClass=function(e){t.assign(this,e)},e.create=function(n){var r=n._environment,i=n.renderer,o=n.template,s=n[t.OWNER];return new e(r,i,s,o)},e.prototype.appendTo=function(e){var t=this._environment||r.environment,n=void 0;n=t.hasDOM&&"string"==typeof e?document.querySelector(e):e,i.run.schedule("render",this.renderer,"appendOutletView",this,n)},e.prototype.rerender=function(){},e.prototype.setOutletState=function(e){this.outletState={outlets:{main:e},render:{owner:void 0,into:void 0,outlet:"main",name:"-top-level",controller:void 0,ViewClass:void 0,template:void 0}},this._tag.dirty()},e.prototype.toReference=function(){return new o(this)},e.prototype.destroy=function(){},e}();e.default=u}),s("ember-metal/alias",["exports","ember-utils","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/error","ember-metal/properties","ember-metal/computed","ember-metal/meta","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict";function c(e){return new p(e)}function p(e){this.isDescriptor=!0,this.altKey=e,this._dependentKeys=[e]}function h(e,n,r){throw new o.default("Cannot set read-only property '"+n+"' on object: "+t.inspect(e))}function f(e,t,n){return s.defineProperty(e,t,null),i.set(e,t,n)}e.default=c,e.AliasedProperty=p,p.prototype=Object.create(s.Descriptor.prototype),p.prototype.setup=function(e,t){var n=u.meta(e);n.peekWatching(t)&&l.addDependentKeys(this,e,t,n)},p.prototype._addDependentKeyIfMissing=function(e,t){var n=u.meta(e);n.peekDeps(this.altKey,t)||l.addDependentKeys(this,e,t,n)},p.prototype._removeDependentKeyIfAdded=function(e,t){var n=u.meta(e);n.peekDeps(this.altKey,t)&&l.removeDependentKeys(this,e,t,n)},p.prototype.willWatch=p.prototype._addDependentKeyIfMissing,p.prototype.didUnwatch=p.prototype._removeDependentKeyIfAdded,p.prototype.teardown=p.prototype._removeDependentKeyIfAdded,p.prototype.get=function(e,t){return this._addDependentKeyIfMissing(e,t),r.get(e,this.altKey)},p.prototype.set=function(e,t,n){return i.set(e,this.altKey,n)},p.prototype.readOnly=function(){return this.set=h,this},p.prototype.oneWay=function(){return this.set=f,this},p.prototype._meta=void 0,p.prototype.meta=a.ComputedProperty.prototype.meta}),s("ember-metal/binding",["exports","ember-utils","ember-console","ember-environment","ember-metal/run_loop","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/events","ember-metal/observer","ember-metal/path_cache"],function(e,t,n,r,i,o,s,a,u,l,c){"use strict";function p(e,t){this._from=t,this._to=e,this._oneWay=void 0,this._direction=void 0,this._readyToSync=void 0,this._fromObj=void 0,this._fromPath=void 0,this._toObj=void 0}function h(e,t,n,r,i,o){}function f(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function m(e,t,n){return new p(t,n).connect(e)}e.bind=m,p.prototype={copy:function(){var e=new p(this._to,this._from);return this._oneWay&&(e._oneWay=!0),e},from:function(e){return this._from=e,this},to:function(e){return this._to=e,this},oneWay:function(){return this._oneWay=!0,this},toString:function(){var e=this._oneWay?"[oneWay]":"";return"Ember.Binding<"+t.guidFor(this)+">("+this._from+" -> "+this._to+")"+e},connect:function(e){var t=void 0,n=void 0,i=void 0;if(c.isGlobalPath(this._from)){var o=c.getFirstKey(this._from);i=r.context.lookup[o],i&&(t=i,n=c.getTailPath(this._from))}return void 0===t&&(t=e,n=this._from),a.trySet(e,this._to,s.get(t,n)),l.addObserver(t,n,this,"fromDidChange"),this._oneWay||l.addObserver(e,this._to,this,"toDidChange"),u.addListener(e,"willDestroy",this,"disconnect"),h(e,this._to,this._from,i,this._oneWay,!i&&!this._oneWay),this._readyToSync=!0,this._fromObj=t,this._fromPath=n,this._toObj=e,this},disconnect:function(){return l.removeObserver(this._fromObj,this._fromPath,this,"fromDidChange"),this._oneWay||l.removeObserver(this._toObj,this._to,this,"toDidChange"),this._readyToSync=!1,this},fromDidChange:function(e){this._scheduleSync("fwd")},toDidChange:function(e){this._scheduleSync("back")},_scheduleSync:function(e){var t=this._direction;void 0===t&&(i.default.schedule("sync",this,"_sync"),this._direction=e),"back"===t&&"fwd"===e&&(this._direction="fwd")},_sync:function(){var e=r.ENV.LOG_BINDINGS,t=this._toObj;if(!t.isDestroyed&&this._readyToSync){var i=this._direction,o=this._fromObj,u=this._fromPath;if(this._direction=void 0,"fwd"===i){var c=s.get(o,u);e&&n.default.log(" ",this.toString(),"->",c,o),this._oneWay?a.trySet(t,this._to,c):l._suspendObserver(t,this._to,this,"toDidChange",function(){a.trySet(t,this._to,c)})}else if("back"===i){var p=s.get(t,this._to);e&&n.default.log(" ",this.toString(),"<-",p,t),l._suspendObserver(o,u,this,"fromDidChange",function(){a.trySet(o,u,p)})}}}},f(p,{from:function(e){var t=this;return new t(void 0,e)},to:function(e){var t=this;return new t(e,void 0)}}),e.Binding=p}),s("ember-metal/cache",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict";var r=function(){function e(e,t,n,r){this.size=0,this.misses=0,this.hits=0,this.limit=e,this.func=t,this.key=n,this.store=r||new i}return e.prototype.get=function(e){var t=void 0===this.key?e:this.key(e),r=this.store.get(t);return void 0===r?(this.misses++,r=this._set(t,this.func(e))):r===n.UNDEFINED?(this.hits++,r=void 0):this.hits++,r},e.prototype.set=function(e,t){var n=void 0===this.key?e:this.key(e);return this._set(n,t)},e.prototype._set=function(e,t){return this.limit>this.size&&(this.size++,void 0===t?this.store.set(e,n.UNDEFINED):this.store.set(e,t)),t},e.prototype.purge=function(){this.store.clear(),this.size=0,this.hits=0,this.misses=0},e}();e.default=r;var i=function(){function e(){this.data=new t.EmptyObject}return e.prototype.get=function(e){return this.data[e]},e.prototype.set=function(e,t){this.data[e]=t},e.prototype.clear=function(){this.data=new t.EmptyObject},e}()}),s("ember-metal/chains",["exports","ember-utils","ember-metal/property_get","ember-metal/meta","ember-metal/watch_key","ember-metal/watch_path"],function(e,t,n,r,i,o){"use strict";function s(e){return e.match(g)[0]}function a(e){return"object"==typeof e&&e}function u(e){return!(a(e)&&e.isDescriptor&&e._volatile===!1)}function l(){this.chains=new t.EmptyObject}function c(){return new l}function p(e,t,n){var o=r.meta(e);o.writableChainWatchers(c).add(t,n),i.watchKey(e,t,o)}function h(e,t,n,o){if(a(e)){var s=o||r.peekMeta(e);s&&s.readableChainWatchers()&&(s=r.meta(e),s.readableChainWatchers().remove(t,n),i.unwatchKey(e,t,s))}}function f(e,t,n){if(this._parent=e,this._key=t,this._watching=void 0===n,this._chains=void 0,this._object=void 0,this.count=0,this._value=n,this._paths={},this._watching){var r=e.value();if(!a(r))return;this._object=r,p(this._object,this._key,this)}}function m(e,t){if(a(e)){var i=r.peekMeta(e);if(!i||i.proto!==e){if(u(e[t]))return n.get(e,t);var o=i.readableCache();return o&&t in o?o[t]:void 0}}}function d(e){var t=r.peekMeta(e);if(t){t=r.meta(e);var n=t.readableChainWatchers();n&&n.revalidateAll(),t.readableChains()&&t.writableChains(o.makeChainNode)}}e.finishChains=d;var g=/^([^\.]+)/;l.prototype={add:function(e,t){var n=this.chains[e];void 0===n?this.chains[e]=[t]:n.push(t)},remove:function(e,t){var n=this.chains[e];if(n)for(var r=0;r0&&t[e]--;var n=s(e),r=e.slice(n.length+1);this.unchain(n,r)},chain:function(e,n){var r=this._chains,i=void 0;void 0===r?r=this._chains=new t.EmptyObject:i=r[e],void 0===i&&(i=r[e]=new f(this,e,void 0)),i.count++,n&&(e=s(n),n=n.slice(e.length+1),i.chain(e,n))},unchain:function(e,t){var n=this._chains,r=n[e];if(t&&t.length>1){var i=s(t),o=t.slice(i.length+1);r.unchain(i,o)}r.count--,r.count<=0&&(n[r._key]=void 0,r.destroy())},notify:function(e,t){if(e&&this._watching){var n=this._parent.value();n!==this._object&&(this._object&&h(this._object,this._key,this),a(n)?(this._object=n,p(n,this._key,this)):this._object=void 0),this._value=void 0}var r=this._chains,i=void 0;if(r)for(var o in r)i=r[o],void 0!==i&&i.notify(e,t);t&&this._parent&&this._parent.populateAffected(this._key,1,t)},populateAffected:function(e,t,n){this._key&&(e=this._key+"."+e),this._parent?this._parent.populateAffected(e,t+1,n):t>1&&n.push(this.value(),e)}},e.removeChainWatcher=h,e.ChainNode=f}),s("ember-metal/computed",["exports","ember-utils","ember-metal/debug","ember-metal/property_set","ember-metal/meta","ember-metal/expand_properties","ember-metal/error","ember-metal/properties","ember-metal/property_events","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict";function c(e,t){this.isDescriptor=!0,"function"==typeof e?this._getter=e:(this._getter=e.get,this._setter=e.set),this._dependentKeys=void 0,this._suspended=void 0,this._meta=void 0,this._volatile=!1,this._dependentKeys=t&&t.dependentKeys,this._readOnly=!1}function p(e){var t=void 0;arguments.length>1&&(t=[].slice.call(arguments),e=t.pop());var n=new c(e);return t&&n.property.apply(n,t),n}function h(e,t){var n=i.peekMeta(e),r=n&&n.source===e&&n.readableCache(),o=r&&r[t];if(o!==i.UNDEFINED)return o}e.default=p;c.prototype=new a.Descriptor,c.prototype.constructor=c;var f=c.prototype;f.volatile=function(){return this._volatile=!0,this},f.readOnly=function(){return this._readOnly=!0,this},f.property=function(){function e(e){t.push(e)}for(var t=[],n=0;n=0;i-=3)if(t===e[i]&&n===e[i+1]){r=i;break}return r}function s(e,t,n){var i=r.peekMeta(e);if(i){for(var s=i.matchingListeners(t),a=[],u=s.length-3;u>=0;u-=3){var l=s[u],c=s[u+1],p=s[u+2],h=o(n,l,c);h===-1&&(n.push(l,c,p),a.push(l,c,p))}return a}}function a(e,t,n,o,s){o||"function"!=typeof n||(o=n,n=null);var a=0;s&&(a|=i.ONCE),r.meta(e).addToListeners(t,n,o,a),"function"==typeof e.didAddListener&&e.didAddListener(t,n,o)}function u(e,t,n,i){i||"function"!=typeof n||(i=n,n=null),r.meta(e).removeFromListeners(t,n,i,function(){"function"==typeof e.didRemoveListener&&e.didRemoveListener.apply(e,arguments)})}function l(e,t,n,r,i){return c(e,[t],n,r,i)}function c(e,t,n,i,o){return i||"function"!=typeof n||(i=n,n=null),r.meta(e).suspendListeners(t,n,i,o)}function p(e){return r.meta(e).watchedEvents()}function h(e,n,o,s){if(!s){var a=r.peekMeta(e);s=a&&a.matchingListeners(n)}if(s&&0!==s.length){for(var l=s.length-3;l>=0;l-=3){var c=s[l],p=s[l+1],h=s[l+2];p&&(h&i.SUSPENDED||(h&i.ONCE&&u(e,n,c,p),c||(c=e),"string"==typeof p?o?t.applyStr(c,p,o):c[p]():o?p.apply(c,o):p.call(c)))}return!0}}function f(e,t){var n=r.peekMeta(e);return!!n&&n.matchingListeners(t).length>0}function m(e,t){var n=[],i=r.peekMeta(e),o=i&&i.matchingListeners(t);if(!o)return n;for(var s=0;s=0&&(s=r(s,u.split(","),a))}for(var a=0;a-1&&o.splice(s,1),this.size=o.length,!0}return!1},isEmpty:function(){return 0===this.size},has:function(e){if(0===this.size)return!1;var n=t.guidFor(e),r=this.presenceSet;return r[n]===!0},forEach:function(e){if("function"!=typeof e&&n(e),0!==this.size){var t=this.list;if(2===arguments.length)for(var r=0;r0;){if(e=O.pop(),t=e._chains)for(n in t)void 0!==t[n]&&O.push(t[n]);if(e._watching&&(r=e._object)){var i=N(r);i&&!i.isSourceDestroying()&&o.removeChainWatcher(r,e._key,e,i)}}this.setMetaDestroyed()}};for(var S in r.protoMethods)s.prototype[S]=r.protoMethods[S];w.forEach(function(e){return g[e](e,s)}),s.prototype.isSourceDestroying=function(){return 0!==(this._flags&v)},s.prototype.setSourceDestroying=function(){this._flags|=v},s.prototype.isSourceDestroyed=function(){return 0!==(this._flags&y)},s.prototype.setSourceDestroyed=function(){this._flags|=y},s.prototype.isMetaDestroyed=function(){return 0!==(this._flags&b)},s.prototype.setMetaDestroyed=function(){this._flags|=b},s.prototype.isProxy=function(){return 0!==(this._flags&_)},s.prototype.setProxy=function(){this._flags|=_},s.prototype._getOrCreateOwnMap=function(e){var n=this[e];return n||(n=this[e]=new t.EmptyObject),n},s.prototype._getInherited=function(e){for(var t=this;void 0!==t;){if(t[e])return t[e];t=t.parent}},s.prototype._findInherited=function(e,t){for(var n=this;void 0!==n;){var r=n[e];if(r){var i=r[t];if(void 0!==i)return i}n=n.parent}};var x=t.symbol("undefined");e.UNDEFINED=x,s.prototype.writeDeps=function(e,n,r){var i=this._getOrCreateOwnMap("_deps"),o=i[e];o||(o=i[e]=new t.EmptyObject),o[n]=r},s.prototype.peekDeps=function(e,t){for(var n=this;void 0!==n;){var r=n._deps;if(r){var i=r[e];if(i&&void 0!==i[t])return i[t]}n=n.parent}},s.prototype.hasDeps=function(e){for(var t=this;void 0!==t;){if(t._deps&&t._deps[e])return!0;t=t.parent}return!1},s.prototype.forEachInDeps=function(e,t){return this._forEachIn("_deps",e,t)},s.prototype._forEachIn=function(e,n,r){for(var i=this,o=new t.EmptyObject,s=[];void 0!==i;){var a=i[e];if(a){var u=a[n];if(u)for(var l in u)o[l]||(o[l]=!0,s.push([l,u[l]]))}i=i.parent}for(var c=0;c=0;s-=4)if(o[s]===e&&(!n||o[s+1]===t&&o[s+2]===n)){if(i!==this)return this._finalizeListeners(),this.removeFromListeners(e,t,n);"function"==typeof r&&r(e,t,o[s+2]),o.splice(s,4)}if(i._listenersFinalized)break;i=i.parent}},matchingListeners:function(e){for(var n=this,i=[];n;){var o=n._listeners;if(o)for(var s=0;s=0;o-=3)i[o+1]===t&&i[o+2]===n&&e.indexOf(i[o])!==-1&&i.splice(o,3)}},watchedEvents:function(){for(var e=this,t={};e;){var n=e._listeners;if(n)for(var r=0;r=0||"concatenatedProperties"===t||"mergedProperties"===t?n=v(e,t,n,o):u&&u.indexOf(t)>=0?n=y(e,t,n,o):h(n)&&(n=g(e,t,n,o,i)),i[t]=void 0,o[t]=n}function _(e,t,n,r,i,o){function s(e){delete n[e],delete r[e]}for(var a=void 0,u=void 0,l=void 0,c=void 0,p=void 0,h=0;h7&&66===e.charCodeAt(t-7)&&e.indexOf("inding",t-6)!==-1}function E(e,t){t.forEachBindings(function(t,n){if(n){var r=t.slice(0,-7);n instanceof u.Binding?(n=n.copy(),n.to(r)):n=new u.Binding(r,n),n.connect(e),e[t]=n}}),t.clearBindings()}function O(e,t){return E(e,t||i.meta(e)),e}function S(e,t,n,r,i){var o=t.methodName,s=void 0,a=void 0;return r[o]||i[o]?(s=i[o],t=r[o]):(a=e[o])&&null!==a&&"object"==typeof a&&a.isDescriptor?(t=a,s=void 0):(t=void 0,s=e[o]),{desc:t,value:s}}function x(e,t,n,r,i){var o=n[r];if(o)for(var s=0;s1?t-1:0),r=1;r0){for(var i=new Array(r),o=0;o=0;)if(P(o[s],n,r))return!0;return!1}function D(e,n,r){if(!r[t.guidFor(n)])if(r[t.guidFor(n)]=!0,n.properties)for(var i=Object.keys(n.properties),o=0;o0,l&&l.teardown(e,t),n instanceof o)p=n,e[t]=p,n.setup&&n.setup(e,t);else if(null==n){p=s;e[t]=s}else p=n,Object.defineProperty(e,t,n);return c&&i.overrideChains(e,t,a),e.didDefineProperty&&e.didDefineProperty(e,t,p),this}e.Descriptor=o,e.MANDATORY_SETTER_FUNCTION=s,e.DEFAULT_GETTER_FUNCTION=a,e.INHERITING_GETTER_FUNCTION=u,e.defineProperty=l;(function(){var e=Object.create(Object.prototype,{prop:{configurable:!0,value:1}});return Object.defineProperty(e,"prop",{configurable:!0,value:2}),2===e.prop})()}),s("ember-metal/property_events",["exports","ember-utils","ember-metal/meta","ember-metal/events","ember-metal/tags","ember-metal/observer_set","ember-metal/features","ember-metal/transaction"],function(e,t,n,r,i,o,s,a){"use strict";function u(e,t,r){var i=r||n.peekMeta(e);if(!i||i.isInitialized(e)){var o=i&&i.peekWatching(t)>0,s=e[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0;a&&a.willChange&&a.willChange(e,t),o&&(c(e,t,i),f(e,t,i),b(e,t,i))}}function l(e,t,r){var o=r||n.peekMeta(e);if(!o||o.isInitialized(e)){var s=o&&o.peekWatching(t)>0,a=e[t],u=null!==a&&"object"==typeof a&&a.isDescriptor?a:void 0;u&&u.didChange&&u.didChange(e,t),s&&(o.hasDeps(t)&&p(e,t,o),m(e,t,o,!1),_(e,t,o)),e[w]&&e[w](t),o&&o.isSourceDestroying()||i.markObjectAsDirty(o,t)}}function c(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=x,i=!r;i&&(r=x={}),h(u,e,t,r,n),i&&(x=null)}}function p(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=C,i=!r;i&&(r=C={}),h(l,e,t,r,n),i&&(C=null)}}function h(e,n,r,i,o){var s=void 0,a=void 0,u=t.guidFor(n),l=i[u];l||(l=i[u]={}),l[r]||(l[r]=!0,o.forEachInDeps(r,function(t,r){r&&(s=n[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0,a&&a._suspended===n||e(n,t,o))}))}function f(e,t,n){var r=n.readableChainWatchers();r&&r.notify(t,!1,u)}function m(e,t,n){var r=n.readableChainWatchers();r&&r.notify(t,!0,l)}function d(e,t,n){var r=n.readableChainWatchers();r&&r.revalidate(t)}function g(){S++}function v(){S--,S<=0&&(E.clear(),O.flush())}function y(e,t){g();try{e.call(t)}finally{v.call(t)}}function b(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":before",o=void 0,s=void 0;S?(o=E.add(e,t,i),s=r.accumulateListeners(e,i,o),r.sendEvent(e,i,[e,t],s)):r.sendEvent(e,i,[e,t])}}function _(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":change",o=void 0;S?(o=O.add(e,t,i),r.accumulateListeners(e,i,o)):r.sendEvent(e,i,[e,t])}}var w=t.symbol("PROPERTY_DID_CHANGE");e.PROPERTY_DID_CHANGE=w;var E=new o.default,O=new o.default,S=0,x=void 0,C=void 0;e.propertyWillChange=u,e.propertyDidChange=l,e.overrideChains=d,e.beginPropertyChanges=g,e.endPropertyChanges=v,e.changeProperties=y}),s("ember-metal/property_get",["exports","ember-metal/debug","ember-metal/path_cache"],function(e,t,n){"use strict";function r(e,t){var r=e[t],o=null!==r&&"object"==typeof r&&r.isDescriptor?r:void 0,s=void 0;return void 0===o&&n.isPath(t)?i(e,t):o?o.get(e,t):(s=r,void 0!==s||"object"!=typeof e||t in e||"function"!=typeof e.unknownProperty?s:e.unknownProperty(t))}function i(e,t){for(var n=e,i=t.split("."),s=0;sa?a:l,c<=0&&(c=0),p=o.splice(0,a),p=[u,c].concat(p),u+=a,l-=c,s=s.concat(n.apply(e,p));return s}e.default=t;var n=Array.prototype.splice}),s("ember-metal/run_loop",["exports","ember-utils","ember-metal/debug","ember-metal/testing","ember-metal/error_handler","ember-metal/property_events","backburner"],function(e,t,n,r,i,o,s){"use strict";function a(e){l.currentRunLoop=e}function u(e,t){l.currentRunLoop=t}function l(){return p.run.apply(p,arguments)}e.default=l;var c={get onerror(){return i.getOnerror()},set onerror(e){return i.setOnerror(e)}},p=new s.default(["sync","actions","destroy"],{GUID_KEY:t.GUID_KEY,sync:{before:o.beginPropertyChanges,after:o.endPropertyChanges},defaultQueue:"actions",onBegin:a,onEnd:u,onErrorTarget:c,onErrorMethod:"onerror"});l.join=function(){return p.join.apply(p,arguments)},l.bind=function(){for(var e=arguments.length,t=Array(e),n=0;n1&&i.writeWatching(t,o-1)}}}e.watchKey=o,e.unwatchKey=s}),s("ember-metal/watch_path",["exports","ember-metal/meta","ember-metal/chains"],function(e,t,n){"use strict";function r(e,n){return(n||t.meta(e)).writableChains(i)}function i(e){return new n.ChainNode(null,null,e)}function o(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0;s?o.writeWatching(n,s+1):(o.writeWatching(n,1),r(e,o).add(n))}}function s(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0;1===s?(o.writeWatching(n,0),r(e,o).remove(n)):s>1&&o.writeWatching(n,s-1)}}e.makeChainNode=i,e.watchPath=o,e.unwatchPath=s}),s("ember-metal/watching",["exports","ember-metal/watch_key","ember-metal/watch_path","ember-metal/path_cache","ember-metal/meta"],function(e,t,n,r,i){"use strict";function o(e,i,o){r.isPath(i)?n.watchPath(e,i,o):t.watchKey(e,i,o)}function s(e,t){if("object"!=typeof e||null===e)return!1;var n=i.peekMeta(e);return(n&&n.peekWatching(t))>0}function a(e,t){var n=i.peekMeta(e);return n&&n.peekWatching(t)||0}function u(e,i,o){r.isPath(i)?n.unwatchPath(e,i,o):t.unwatchKey(e,i,o)}function l(e){i.deleteMeta(e)}e.isWatching=s,e.watcherCount=a,e.unwatch=u,e.destroy=l,e.watch=o}),s("ember-metal/weak_map",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict";function r(e){return"object"==typeof e&&null!==e||"function"==typeof e}function i(e){if(!(this instanceof i))throw new TypeError("Constructor WeakMap requires 'new'");if(this._id=t.GUID_KEY+o++,null!==e&&void 0!==e){if(!Array.isArray(e))throw new TypeError("The weak map constructor polyfill only supports an array argument");for(var n=0;n7)}function a(e,t){return(e.indexOf("Android 2.")===-1&&e.indexOf("Android 4.0")===-1||e.indexOf("Mobile Safari")===-1||e.indexOf("Chrome")!==-1||e.indexOf("Windows Phone")!==-1)&&!!(t&&"pushState"in t)}function u(e,t){e.replace(o(e)+t)}e.getPath=t,e.getQuery=n,e.getHash=r,e.getFullPath=i,e.getOrigin=o,e.supportsHashChange=s,e.supportsHistory=a,e.replacePath=u}),s("ember-routing/services/routing",["exports","ember-utils","ember-runtime","ember-metal","ember-routing/utils"],function(e,t,n,r,i){"use strict";function o(e,t){for(var n=0,r=0;rc&&(n=l),i.isActiveIntent(n,e,t,!s)}})}),s("ember-routing/system/cache",["exports","ember-utils","ember-runtime"],function(e,t,n){"use strict";e.default=n.Object.extend({init:function(){this.cache=new t.EmptyObject},has:function(e){return!!this.cache[e]},stash:function(e,n,r){var i=this.cache[e];i||(i=this.cache[e]=new t.EmptyObject),i[n]=r},lookup:function(e,t,n){var r=this.cache;if(!this.has(e))return n;var i=r[e];return t in i&&void 0!==i[t]?i[t]:n}})}),s("ember-routing/system/controller_for",["exports"],function(e){"use strict";function t(e,t,n){return e.lookup("controller:"+t,n)}e.default=t}),s("ember-routing/system/dsl",["exports","ember-utils","ember-metal"],function(e,t,n){"use strict";function r(e,t){this.parent=e,this.enableLoadingSubstates=t&&t.enableLoadingSubstates,this.matches=[],this.explicitIndex=void 0,this.options=t}function i(e){return e.parent&&"application"!==e.parent}function o(e,t,n){return i(e)&&n!==!0?e.parent+"."+t:t}function s(e,t,n,r){n=n||{};var i=o(e,t,n.resetNamespace);"string"!=typeof n.path&&(n.path="/"+t),e.push(n.path,i,r,n.serialize)}e.default=r,r.prototype={route:function(e,t,n){var i="/_unused_dummy_error_path_route_"+e+"/:error";if(2===arguments.length&&"function"==typeof t&&(n=t,t={}),1===arguments.length&&(t={}),this.enableLoadingSubstates&&(s(this,e+"_loading",{resetNamespace:t.resetNamespace}),s(this,e+"_error",{resetNamespace:t.resetNamespace,path:i})),n){var a=o(this,e,t.resetNamespace),u=new r(a,this.options);s(u,"loading"),s(u,"error",{path:i}),n.call(u),s(this,e,t,u.generate())}else s(this,e,t)},push:function(e,n,r,i){var o=n.split(".");if(this.options.engineInfo){var s=n.slice(this.options.engineInfo.fullName.length+1),a=t.assign({localFullName:s},this.options.engineInfo);i&&(a.serializeMethod=i),this.options.addRouteForEngine(n,a)}else if(i)throw new Error("Defining a route serializer on route '"+n+"' outside an Engine is not allowed.");""!==e&&"/"!==e&&"index"!==o[o.length-1]||(this.explicitIndex=!0),this.matches.push([e,n,r])},resource:function(e,t,n){2===arguments.length&&"function"==typeof t&&(n=t,t={}),1===arguments.length&&(t={}),t.resetNamespace=!0,this.route(e,t,n)},generate:function(){var e=this.matches;return this.explicitIndex||this.route("index",{path:"/"}),function(t){for(var n=0;n0&&(this.connections=[],n.run.once(this.router,"_setOutlets"))}});r.deprecateUnderscoreActions(_),_.reopenClass({isRouteFactory:!0}),e.default=_}),s("ember-routing/system/router",["exports","ember-utils","ember-console","ember-metal","ember-runtime","ember-routing/system/route","ember-routing/system/dsl","ember-routing/location/api","ember-routing/utils","ember-routing/system/router_state","router"],function(e,t,n,r,i,o,s,a,u,l,c){"use strict";function p(){return this}function h(e,t,n){for(var r=!1,i=t.length-1;i>=0;--i){var o=t[i],s=o.handler;if(e===s&&(r=!0),r&&n(s)!==!0)return}}function f(e,t){var r=[],i=void 0;i=e&&"object"==typeof e&&"object"==typeof e.errorThrown?e.errorThrown:e,t&&r.push(t),i&&(i.message&&r.push(i.message),i.stack&&r.push(i.stack),"string"==typeof i&&r.push(i)),n.default.error.apply(this,r)}function m(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s=o+"_"+n,a=e.fullRouteName,u=a+"_"+n;return g(i,r,s,u)?u:""}function d(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s="application"===o?n:o+"."+n,a=e.fullRouteName,u="application"===a?n:a+"."+n;return g(i,r,s,u)?u:""}function g(e,t,n,r){var i=t.hasRoute(r),o=e.hasRegistration("template:"+n)||e.hasRegistration("route:"+n);return i&&o}function v(e,n,i){var o=i.shift();if(!e){if(n)return;throw new r.Error("Can't trigger action '"+o+"' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.")}for(var s=!1,a=void 0,u=void 0,l=e.length-1;l>=0;l--)if(a=e[l],u=a.handler,u&&u.actions&&u.actions[o]){if(u.actions[o].apply(u,i)!==!0){if("error"===o){var c=t.guidFor(i[0]);u.router._markErrorAsHandled(c)}return}s=!0}if(T[o])return void T[o].apply(null,i);if(!s&&!n)throw new r.Error("Nothing handled the action '"+o+"'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.")}function y(e,t,n){for(var r=e.router,i=r.applyIntent(t,n),o=i.handlerInfos,s=i.params,a=0;a0;){var r=n.shift();if(r.render.name===t)return r;var i=r.outlets;for(var o in i)n.push(i[o])}}function S(e,n,i){var o=void 0,s={render:i,outlets:new t.EmptyObject,wasUsed:!1};return o=i.into?O(e,i.into):n,o?r.set(o.outlets,i.outlet,s):i.into?x(e,i.into,s):e=s,{liveRoutes:e,ownState:s}}function x(e,n,i){e.outlets.__ember_orphans__||(e.outlets.__ember_orphans__={render:{name:"__ember_orphans__"},outlets:new t.EmptyObject}),e.outlets.__ember_orphans__.outlets[n]=i,r.run.schedule("afterRender",function(){})}function C(e,t,n){var r=O(e,n.routeName);return r?r:(t.outlets.main={render:{name:n.routeName,outlet:"main"},outlets:{}},t)}e.triggerEvent=v;var A=Array.prototype.slice,k=i.Object.extend(i.Evented,{location:"hash",rootURL:"/",_initRouterJs:function(){var e=this.router=new c.default;e.triggerEvent=v,e._triggerWillChangeContext=p,e._triggerWillLeave=p;var t=this.constructor.dslCallbacks||[p],i=this._buildDSL();i.route("application",{path:"/",resetNamespace:!0,overrideNameAssertion:!0},function(){for(var e=0;e0)-(n<0)}function i(e,s){if(e===s)return 0;var a=t.typeOf(e),u=t.typeOf(s);if(n.default){if("instance"===a&&n.default.detect(e)&&e.constructor.compare)return e.constructor.compare(e,s);if("instance"===u&&n.default.detect(s)&&s.constructor.compare)return s.constructor.compare(s,e)*-1}var l=r(o[a],o[u]);if(0!==l)return l;switch(a){case"boolean":case"number":return r(e,s);case"string":return r(e.localeCompare(s),0);case"array":for(var c=e.length,p=s.length,h=Math.min(c,p),f=0;fn})}function h(e,n){return t.computed(e,function(){return t.get(this,e)>=n})}function f(e,n){return t.computed(e,function(){return t.get(this,e)=0)return o[a];if(Array.isArray(e)){if(s=e.slice(),t)for(a=s.length;--a>=0;)s[a]=i(s[a],t,n,o)}else if(r.default&&r.default.detect(e))s=e.copy(t,n,o);else if(e instanceof Date)s=new Date(e.getTime());else{s={};for(u in e)Object.prototype.hasOwnProperty.call(e,u)&&"__"!==u.substring(0,2)&&(s[u]=t?i(e[u],t,n,o):e[u])}return t&&(n.push(e),o.push(s)),s}function o(e,t){return"object"!=typeof e||null===e?e:r.default&&r.default.detect(e)?e.copy(t):i(e,t,t?[]:null,t?[]:null)}e.default=o}),s("ember-runtime/ext/function",["exports","ember-environment","ember-metal"],function(e,t,n){"use strict";var r=Array.prototype.slice,i=Function.prototype;t.ENV.EXTEND_PROTOTYPES.Function&&(i.property=function(){var e=n.computed(this);return e.property.apply(e,arguments)},i.observes=function(){for(var e=arguments.length,t=Array(e),r=0;r1?n-1:0),i=1;i=0&&r>=0&&n.get(e,"hasEnumerableObservers")){o=[],s=t+r;for(var a=t;a=0&&i>=0&&n.get(e,"hasEnumerableObservers")){o=[];for(var s=t+i,a=t;a=n.get(this,"length")))return n.get(this,e)},h.objectsAt=function(e){var t=this;return e.map(function(e){return u(t,e)})},h.nextObject=function(e){return u(this,e)},h["[]"]=n.computed({get:function(e){return this},set:function(e,t){return this.replace(0,n.get(this,"length"),t),this}}),h.firstObject=n.computed(function(){return u(this,0)}).readOnly(),h.lastObject=n.computed(function(){return u(this,n.get(this,"length")-1)}).readOnly(),h.contains=function(e){return this.indexOf(e)>=0},h.slice=function(e,t){var r=n.default.A(),i=n.get(this,"length");for(n.isNone(e)&&(e=0),(n.isNone(t)||t>i)&&(t=i),e<0&&(e=i+e),t<0&&(t=i+t);e=r)&&(t=r-1),t<0&&(t+=r);for(var i=t;i>=0;i--)if(u(this,i)===e)return i;return-1},h.addArrayObserver=function(e,t){return s(this,e,t)},h.removeArrayObserver=function(e,t){return a(this,e,t)},h.hasArrayObservers=n.computed(function(){return n.hasListeners(this,"@array:change")||n.hasListeners(this,"@array:before")}),h.arrayContentWillChange=function(e,t,n){return l(this,e,t,n)},h.arrayContentDidChange=function(e,t,n){return c(this,e,t,n)},h["@each"]=n.computed(function(){return this.__each||(this.__each=new i.default(this)),this.__each}).volatile().readOnly(),h));m.reopen({includes:function(e,t){var r=n.get(this,"length");void 0===t&&(t=0),t<0&&(t+=r);for(var i=t;i1?t-1:0),r=1;r1?n-1:0),i=1;i=t.get(e,"length"))throw new t.Error(s);void 0===r&&(r=1),e.replace(n,r,a)}return e}e.removeAt=o;var s="Index out of range",a=[];e.default=t.Mixin.create(n.default,r.default,{replace:null,clear:function(){var e=t.get(this,"length");return 0===e?this:(this.replace(0,e,a),this)},insertAt:function(e,n){if(e>t.get(this,"length"))throw new t.Error(s);return this.replace(e,0,[n]),this},removeAt:function(e,t){return o(this,e,t)},pushObject:function(e){return this.insertAt(t.get(this,"length"),e),e},pushObjects:function(e){if(!i.default.detect(e)&&!Array.isArray(e))throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");return this.replace(t.get(this,"length"),0,e),this},popObject:function(){var e=t.get(this,"length");if(0===e)return null;var r=n.objectAt(this,e-1);return this.removeAt(e-1,1),r},shiftObject:function(){if(0===t.get(this,"length"))return null;var e=n.objectAt(this,0);return this.removeAt(0),e},unshiftObject:function(e){return this.insertAt(0,e),e},unshiftObjects:function(e){return this.replace(0,0,e),this},reverseObjects:function(){var e=t.get(this,"length");if(0===e)return this;var n=this.toArray().reverse();return this.replace(0,e,n),this},setObjects:function(e){if(0===e.length)return this.clear();var n=t.get(this,"length");return this.replace(0,n,e),this},removeObject:function(e){for(var r=t.get(this,"length")||0;--r>=0;){var i=n.objectAt(this,r);i===e&&this.removeAt(r)}return this},addObject:function(e){var t=void 0;return t=this.includes(e),t||this.pushObject(e),this}})}),s("ember-runtime/mixins/mutable_enumerable",["exports","ember-runtime/mixins/enumerable","ember-metal"],function(e,t,n){"use strict";e.default=n.Mixin.create(t.default,{addObject:null,addObjects:function(e){var t=this;return n.beginPropertyChanges(this),e.forEach(function(e){return t.addObject(e)}),n.endPropertyChanges(this),this},removeObject:null,removeObjects:function(e){n.beginPropertyChanges(this);for(var t=e.length-1;t>=0;t--)this.removeObject(e[t]);return n.endPropertyChanges(this),this}})}),s("ember-runtime/mixins/observable",["exports","ember-metal"],function(e,t){"use strict";e.default=t.Mixin.create({get:function(e){return t.get(this,e)},getProperties:function(){for(var e=arguments.length,n=Array(e),r=0;rt.get(this,"content.length"))throw new t.Error(u);return this._replace(e,0,[n]),this},insertAt:function(e,n){if(t.get(this,"arrangedContent")===t.get(this,"content"))return this._insertAt(e,n);throw new t.Error("Using insertAt on an arranged ArrayProxy is not allowed.")},removeAt:function(e,n){if("number"==typeof e){var r=t.get(this,"content"),i=t.get(this,"arrangedContent"),o=[];if(e<0||e>=t.get(this,"length"))throw new t.Error(u);void 0===n&&(n=1);for(var a=e;a0&&(e=[arguments[0]]),this.__defineNonEnumerable(t.GUID_KEY_PROPERTY);var o=n.meta(this),s=o.proto;if(o.proto=this,e){var a=e;e=null;for(var u=this.concatenatedProperties,l=this.mergedProperties,p=0;p0&&u.indexOf(g)>=0){var _=this[g];v=_?"function"==typeof _.concat?_.concat(v):t.makeArray(_).concat(v):t.makeArray(v)}if(l&&l.length&&l.indexOf(g)>=0){var w=this[g];v=t.assign({},w,v)}b?b.set(this,g,v):"function"!=typeof this.setUnknownProperty||g in this?this[g]=v:this.setUnknownProperty(g,v)}}}c(this,o),this.init.apply(this,arguments),this[f](),o.proto=s,n.finishChains(this),n.sendEvent(this,"init")};return i.toString=n.Mixin.prototype.toString,i.willReopen=function(){r&&(i.PrototypeMixin=n.Mixin.create(i.PrototypeMixin)),r=!1},i._initProperties=function(t){e=t},i.proto=function(){var e=i.superclass;return e&&e.proto(),r||(r=!0,i.PrototypeMixin.applyPartial(i.prototype)),this.prototype},i}var s,a,u=n.run.schedule,l=n.Mixin._apply,c=n.Mixin.finishPartial,p=n.Mixin.prototype.reopen,h=!1,f=t.symbol("POST_INIT");e.POST_INIT=f;var m=o();m.toString=function(){return"Ember.CoreObject"},m.PrototypeMixin=n.Mixin.create((s={reopen:function(){for(var e=arguments.length,t=Array(e),n=0;n";return r},s)),m.PrototypeMixin.ownerConstructor=m,m.__super__=null;var d=(a={ClassMixin:n.REQUIRED,PrototypeMixin:n.REQUIRED,isClass:!0,isMethod:!1},a[t.NAME_KEY]=null,a[t.GUID_KEY]=null,a.extend=function(){var e,r=o();return r.ClassMixin=n.Mixin.create(this.ClassMixin),r.PrototypeMixin=n.Mixin.create(this.PrototypeMixin),r.ClassMixin.ownerConstructor=r,r.PrototypeMixin.ownerConstructor=r,p.apply(r.PrototypeMixin,arguments),r.superclass=this,r.__super__=this.prototype,e=r.prototype=Object.create(this.prototype),e.constructor=r,t.generateGuid(e),n.meta(e).proto=e,r.ClassMixin.apply(r),r},a.create=function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r0&&this._initProperties(n),new e},a.reopen=function(){return this.willReopen(),p.apply(this.PrototypeMixin,arguments),this},a.reopenClass=function(){return p.apply(this.ClassMixin,arguments),l(this,arguments,!1),this},a.detect=function(e){if("function"!=typeof e)return!1;for(;e;){if(e===this)return!0;e=e.superclass}return!1},a.detectInstance=function(e){return e instanceof this},a.metaForProperty=function(e){var t=this.proto(),n=t[e],r=null!==n&&"object"==typeof n&&n.isDescriptor?n:void 0;return r._meta||{}},a._computedProperties=n.computed(function(){h=!0;var e,t=this.proto(),n=[];for(var r in t)e=t[r],e&&e.isDescriptor&&n.push({name:r,meta:e._meta});return n}).readOnly(),a.eachComputedProperty=function(e,t){for(var r,i={},o=n.get(this,"_computedProperties"),s=0;s=o;){var a=r.objectAt(e,s);a&&(n._addBeforeObserver(a,t,i,"contentKeyWillChange"),n.addObserver(a,t,i,"contentKeyDidChange"))}}function s(e,t,i,o,s){for(;--s>=o;){var a=r.objectAt(e,s);a&&(n._removeBeforeObserver(a,t,i,"contentKeyWillChange"),n.removeObserver(a,t,i,"contentKeyDidChange"))}}e.default=i,i.prototype={__defineNonEnumerable:function(e){this[e.name]=e.descriptor.value},arrayWillChange:function(e,t,r,i){var o=this._keys,a=r>0?t+r:-1;for(var u in o)a>0&&s(e,u,this,t,a),n.propertyWillChange(this,u)},arrayDidChange:function(e,t,r,i){var s=this._keys,a=i>0?t+i:-1;for(var u in s)a>0&&o(e,u,this,t,a),n.propertyDidChange(this,u)},willWatchProperty:function(e){this.beginObservingContentKey(e)},didUnwatchProperty:function(e){this.stopObservingContentKey(e)},beginObservingContentKey:function(e){var r=this._keys;if(r||(r=this._keys=new t.EmptyObject),r[e])r[e]++;else{r[e]=1;var i=this._content,s=n.get(i,"length");o(i,e,this,0,s)}},stopObservingContentKey:function(e){var t=this._keys;if(t&&t[e]>0&&--t[e]<=0){var r=this._content,i=n.get(r,"length");s(r,e,this,0,i)}},contentKeyWillChange:function(e,t){n.propertyWillChange(this,t)},contentKeyDidChange:function(e,t){n.propertyDidChange(this,t)}}}),s("ember-runtime/system/lazy_load",["exports","ember-environment"],function(e,t){"use strict";function n(e,t){var n=o[e];i[e]=i[e]||[],i[e].push(t),n&&t(n)}function r(e,n){o[e]=n;var r=t.environment.window;if(r&&"function"==typeof CustomEvent){var s=new CustomEvent(e,{detail:n,name:e});r.dispatchEvent(s)}i[e]&&i[e].forEach(function(e){return e(n)})}e.onLoad=n,e.runLoadHooks=r;var i=t.ENV.EMBER_LOAD_HOOKS||{},o={},s=o;e._loaded=s}),s("ember-runtime/system/namespace",["exports","ember-utils","ember-metal","ember-environment","ember-runtime/system/object"],function(e,t,n,r,i){"use strict";function o(){return d}function s(e){d=!!e}function a(e,n,r){var i=e.length;v[e.join(".")]=n;for(var o in n)if(y.call(n,o)){var s=n[o];if(e[i]=o,s&&s.toString===f&&!s[t.NAME_KEY])s[t.NAME_KEY]=e.join(".");else if(s&&s.isNamespace){if(r[t.guidFor(s)])continue;r[t.guidFor(s)]=!0,a(e,s,r)}}e.length=i}function u(e){return e>=65&&e<=90}function l(e,t){try{var n=e[t];return n&&n.isNamespace&&n}catch(e){}}function c(){if(!g.PROCESSED)for(var e=r.context.lookup,n=Object.keys(e),i=0;i2){i=new Array(arguments.length-1);for(var o=1;o2)&&(t=Array.prototype.slice.call(arguments,1)),e=i.get(e)||e,o(e,t)}function u(e){return e.split(/\s+/)}function l(e){return N.get(e)}function c(e){return g.get(e)}function p(e){return b.get(e)}function h(e){return O.get(e)}function f(e){return C.get(e)}function m(e){return k.get(e)}var d=/[ _]/g,g=new t.Cache(1e3,function(e){return l(e).replace(d,"-")}),v=/(\-|\_|\.|\s)+(.)?/g,y=/(^|\/)([A-Z])/g,b=new t.Cache(1e3,function(e){return e.replace(v,function(e,t,n){return n?n.toUpperCase():""}).replace(y,function(e,t,n){return e.toLowerCase()})}),_=/^(\-|_)+(.)?/,w=/(.)(\-|\_|\.|\s)+(.)?/g,E=/(^|\/|\.)([a-z])/g,O=new t.Cache(1e3,function(e){for(var t=function(e,t,n){return n?"_"+n.toUpperCase():""},n=function(e,t,n,r){return t+(r?r.toUpperCase():"")},r=e.split("/"),i=0;i-1;return e?function(e){return o.test(s.call(e))}:function(){return!0}}();e.checkHasSuper=a,t.__hasSuper=!1}),s("ember-utils/symbol",["exports","ember-utils/guid","ember-utils/intern"],function(e,t,n){"use strict";function r(e){return n.default(e+" [id="+t.GUID_KEY+Math.floor(Math.random()*new Date)+"]")}e.default=r}),s("ember-utils/to-string",["exports"],function(e){"use strict";function t(e){return e&&"function"==typeof e.toString?e.toString():n.call(e)}e.default=t;var n=Object.prototype.toString}),s("ember-views/compat/attrs",["exports","ember-utils"],function(e,t){"use strict";var n=t.symbol("MUTABLE_CELL");e.MUTABLE_CELL=n});s("ember-views/compat/fallback-view-registry",["exports","ember-utils"],function(e,t){"use strict";e.default=t.dictionary(null)});s("ember-views/component_lookup",["exports","ember-metal","ember-runtime"],function(e,t,n){"use strict";e.default=n.Object.extend({componentFor:function(e,t,n){var r="component:"+e;return t._lookupFactory(r,n)},layoutFor:function(e,t,n){var r="template:components/"+e;return t.lookup(r,n)}})}),s("ember-views/index",["exports","ember-views/system/ext","ember-views/system/jquery","ember-views/system/utils","ember-views/system/event_dispatcher","ember-views/component_lookup","ember-views/mixins/text_support","ember-views/views/core_view","ember-views/mixins/class_names_support","ember-views/mixins/child_views_support","ember-views/mixins/view_state_support","ember-views/mixins/view_support","ember-views/mixins/action_support","ember-views/compat/attrs","ember-views/system/lookup_partial","ember-views/utils/lookup-component","ember-views/system/action_manager","ember-views/compat/fallback-view-registry"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v){"use strict";e.jQuery=n.default,e.isSimpleClick=r.isSimpleClick,e.getViewBounds=r.getViewBounds,e.getViewClientRects=r.getViewClientRects,e.getViewBoundingClientRect=r.getViewBoundingClientRect,e.getRootViews=r.getRootViews,e.getChildViews=r.getChildViews,e.getViewId=r.getViewId,e.getViewElement=r.getViewElement,e.setViewElement=r.setViewElement,e.STYLE_WARNING=r.STYLE_WARNING,e.EventDispatcher=i.default,e.ComponentLookup=o.default,e.TextSupport=s.default,e.CoreView=a.default,e.ClassNamesSupport=u.default,e.ChildViewsSupport=l.default,e.ViewStateSupport=c.default,e.ViewMixin=p.default,e.ActionSupport=h.default,e.MUTABLE_CELL=f.MUTABLE_CELL,e.lookupPartial=m.default,e.hasPartial=m.hasPartial,e.lookupComponent=d.default,e.ActionManager=g.default,e.fallbackViewRegistry=v.default}),s("ember-views/mixins/action_support",["exports","ember-utils","ember-metal","ember-views/compat/attrs"],function(e,t,n,r){"use strict";function i(e,t){return t&&t[r.MUTABLE_CELL]&&(t=t.value),t}e.default=n.Mixin.create({sendAction:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o1?t-1:0),i=1;i1;return!t&&!n}function r(e){var t=e.lookup("-view-registry:main"),n=[];return Object.keys(t).forEach(function(e){var r=t[e];null===r.parentView&&n.push(r)}),n}function i(e){return""===e.tagName?t.guidFor(e):e.elementId||t.guidFor(e)}function o(e){return e[y]}function s(e){e[y]=null}function a(e,t){return e[y]=t}function u(e){var n=t.getOwner(e),r=n.lookup("-view-registry:main");return p(e,r)}function l(e){e[b]=[]}function c(e,t){e[b].push(i(t))}function p(e,t){var n=[],r=[];return e[b].forEach(function(e){var i=t[e];!i||i.isDestroying||i.isDestroyed||n.indexOf(e)!==-1||(n.push(e),r.push(i))}),e[b]=n,r}function h(e){return e.renderer.getBounds(e)}function f(e){var t=h(e),n=document.createRange();return n.setStartBefore(t.firstNode),n.setEndAfter(t.lastNode),n}function m(e){var t=f(e);return t.getClientRects()}function d(e){var t=f(e);return t.getBoundingClientRect()}function g(e,t){return _.call(e,t)}e.isSimpleClick=n,e.getRootViews=r,e.getViewId=i,e.getViewElement=o,e.initViewElement=s,e.setViewElement=a,e.getChildViews=u,e.initChildViews=l,e.addChildView=c,e.collectChildViews=p,e.getViewBounds=h,e.getViewRange=f,e.getViewClientRects=m,e.getViewBoundingClientRect=d,e.matches=g;var v="Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.";e.STYLE_WARNING=v;var y=t.symbol("VIEW_ELEMENT"),b=t.symbol("CHILD_VIEW_IDS"),_="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector);e.elMatches=_}),s("ember-views/utils/lookup-component",["exports","container"],function(e,t){"use strict";function n(e,n,r,o){var s=e.componentFor(r,n,o),a=e.layoutFor(r,n,o),u={layout:a,component:s};return a&&!s&&(u.component=n._lookupFactory(t.privatize(i))),u}function r(e,t,r){var i=e.lookup("component-lookup:main"),o=r&&r.source;if(o){var s=n(i,e,t,r);if(s.component||s.layout)return s}return n(i,e,t)}e.default=r;var i=babelHelpers.taggedTemplateLiteralLoose(["component:-default"],["component:-default"])}),s("ember-views/views/core_view",["exports","ember-runtime","ember-views/system/utils","ember-views/views/states"],function(e,t,n,r){"use strict";var i=t.FrameworkObject.extend(t.Evented,t.ActionHandler,{isView:!0,_states:r.cloneStates(r.states),init:function(){if(this._super.apply(this,arguments),this._state="preRender",this._currentState=this._states.preRender,n.initViewElement(this),!this.renderer)throw new Error("Cannot instantiate a component without a renderer. Please ensure that you are creating "+this+" with a proper container/registry.")},parentView:null,instrumentDetails:function(e){return e.object=this.toString(),e.containerKey=this._debugContainerKey,e.view=this,e},trigger:function(){this._super.apply(this,arguments);var e=arguments[0],t=this[e];if(t){for(var n=new Array(arguments.length-1),r=1;r1?r-1:0),o=1;o]+) [^\/>]*\/>/gi,function(e,t){return e.slice(0,e.length-3)+">"})),e}function n(e,n){var r=t(e.innerHTML);QUnit.push(r===n,r,n)}e.default=n;var r=function(){if(!document.createElementNS)return!1;var e=document.createElement("div"),t=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(t);var n=e.cloneNode(!0);return''===n.innerHTML}()}),s("internal-test-helpers/equal-tokens",["exports","simple-html-tokenizer"],function(e,t){"use strict";function n(e){return"string"==typeof e?{tokens:t.tokenize(e),html:e}:{tokens:t.tokenize(e.innerHTML),html:e.innerHTML}}function r(e){e.forEach(function(e){"StartTag"===e.type&&(e.attributes=e.attributes.sort(function(e,t){return e[0]>t[0]?1:e[0]"},e.create=n,e.extend=o,e.reopen=o,e.reopenClass=i,e}e.default=n;var r=0}),s("internal-test-helpers/index",["exports","internal-test-helpers/factory","internal-test-helpers/build-owner","internal-test-helpers/confirm-export","internal-test-helpers/equal-inner-html","internal-test-helpers/equal-tokens","internal-test-helpers/module-for","internal-test-helpers/strip","internal-test-helpers/apply-mixins","internal-test-helpers/matchers","internal-test-helpers/run","internal-test-helpers/test-groups","internal-test-helpers/test-cases/abstract","internal-test-helpers/test-cases/abstract-application","internal-test-helpers/test-cases/application","internal-test-helpers/test-cases/query-param","internal-test-helpers/test-cases/abstract-rendering","internal-test-helpers/test-cases/rendering"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v){"use strict";e.factory=t.default,e.buildOwner=n.default,e.confirmExport=r.default,e.equalInnerHTML=i.default,e.equalTokens=o.default,e.moduleFor=s.default,e.strip=a.default,e.applyMixins=u.default,e.equalsElement=l.equalsElement,e.classes=l.classes,e.styles=l.styles,e.regex=l.regex,e.runAppend=c.runAppend,e.runDestroy=c.runDestroy,e.testBoth=p.testBoth,e.testWithDefault=p.testWithDefault,e.AbstractTestCase=h.default,e.AbstractApplicationTestCase=f.default,e.ApplicationTestCase=m.default,e.QueryParamTestCase=d.default,e.AbstractRenderingTestCase=g.default,e.RenderingTestCase=v.default}),s("internal-test-helpers/matchers",["exports"],function(e){"use strict";function t(e){return"object"==typeof e&&null!==e&&u in e}function n(e){var t;return t={},t[u]=!0,t.match=function(t){return e===t},t.expected=function(){return e},t.message=function(){return"should equal "+this.expected()},t}function r(e){var t;return t={},t[u]=!0,t.match=function(t){return e.test(t)},t.expected=function(){return e.toString()},t.message=function(){return"should match "+this.expected()},t}function i(e){var t;return t={},t[u]=!0,t.match=function(t){return t=t.trim(),t&&e.split(/\s+/).sort().join(" ")===t.trim().split(/\s+/).sort().join(" ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function o(e){var t;return t={},t[u]=!0,t.match=function(t){return t=t||"",t=t.trim(),e.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")===t.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function s(e,r,i,o){QUnit.push(e.tagName===r.toUpperCase(),e.tagName.toLowerCase(),r,"expect tagName to be "+r);var s={},u=0;for(var l in i){var c=i[l];null!==c&&u++;var p=t(c)?c:n(c);s[l]=p,QUnit.push(s[l].match(e.getAttribute(l)),e.getAttribute(l),p.expected(),"Element's "+l+" attribute "+p.message())}for(var h={},f=0,m=e.attributes.length;f2?o-2:0),a=2;a1?t-1:0),r=1;re));)n=n.nextSibling; -return n},e.prototype.$=function(e){return e?r.jQuery(e,this.element):r.jQuery(this.element)},e.prototype.textValue=function(){return this.$().text()},e.prototype.takeSnapshot=function(){for(var e=this.snapshot=[],t=this.element.firstChild;t;)a(t)||e.push(t),t=t.nextSibling;return e},e.prototype.assertText=function(e){this.assert.strictEqual(this.textValue(),e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertInnerHTML=function(e){i.default(this.element,e)},e.prototype.assertHTML=function(e){o.default(this.element,e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertElement=function(e,t){var n=t.ElementType,r=void 0===n?l:n,i=t.tagName,o=t.attrs,a=void 0===o?null:o,u=t.content,c=void 0===u?null:u;if(!(e instanceof r))throw new Error("Expecting a "+r.name+", but got "+e);s.equalsElement(e,i,a,c)},e.prototype.assertComponentElement=function(e,n){var r=n.ElementType,i=void 0===r?l:r,o=n.tagName,a=void 0===o?"div":o,u=n.attrs,c=void 0===u?null:u,p=n.content,h=void 0===p?null:p;c=t.assign({},{id:s.regex(/^ember\d*$/),class:s.classes("ember-view")},c||{}),this.assertElement(e,{ElementType:i,tagName:a,attrs:c,content:h})},e.prototype.assertSameNode=function(e,t){this.assert.strictEqual(e,t,"DOM node stability")},e.prototype.assertInvariants=function(e,t){e=e||this.snapshot,t=t||this.takeSnapshot(),this.assert.strictEqual(t.length,e.length,"Same number of nodes");for(var n=0;n"}catch(e){}finally{if(0!==t.childNodes.length)return!1}return!0}e.domChanges=r,e.treeConstruction=i;var a={colgroup:{depth:2,before:"",after:"
    "},table:{depth:1,before:"",after:"
    "},tbody:{depth:2,before:"",after:"
    "},tfoot:{depth:2,before:"",after:"
    "},thead:{depth:2,before:"",after:"
    "},tr:{depth:3,before:"",after:"
    "}}}),s("glimmer-runtime/lib/compat/svg-inner-html-fix",["exports","glimmer-runtime/lib/bounds","glimmer-runtime/lib/dom/helper"],function(e,t,n){"use strict";function r(e,t,n){if(!e)return t;if(!s(e,n))return t;var r=e.createElement("div");return function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,i,s){return null===s||""===s?e.prototype.insertHTMLBefore.call(this,t,i,s):t.namespaceURI!==n?e.prototype.insertHTMLBefore.call(this,t,i,s):o(t,r,s,i)},t}(t)}function i(e,t,n){if(!e)return t;if(!s(e,n))return t;var r=e.createElement("div");return function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,i,s){return null===i||""===i?e.prototype.insertHTMLBefore.call(this,t,i,s):t.namespaceURI!==n?e.prototype.insertHTMLBefore.call(this,t,i,s):o(t,r,i,s)},t}(t)}function o(e,r,i,o){var s=""+i+"";r.innerHTML=s;var a=n.moveNodesBefore(r.firstChild,e,o),u=a[0],l=a[1];return new t.ConcreteBounds(e,u,l)}function s(e,t){var n=e.createElementNS(t,"svg");try{n.insertAdjacentHTML("beforeEnd","")}catch(e){}finally{return(1!==n.childNodes.length||n.firstChild.namespaceURI!==a)&&(n=null,!0)}}e.domChanges=r,e.treeConstruction=i;var a="http://www.w3.org/2000/svg"}),s("glimmer-runtime/lib/compat/text-node-merging-fix",["exports"],function(e){"use strict";function t(e,t){return e&&r(e)?function(e){function t(t){e.call(this,t),this.uselessComment=t.createComment("")}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===r)return e.prototype.insertHTMLBefore.call(this,t,n,r);var i=!1,o=n?n.previousSibling:t.lastChild;o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,n));var s=e.prototype.insertHTMLBefore.call(this,t,n,r);return i&&t.removeChild(this.uselessComment),s},t}(t):t}function n(e,t){return e&&r(e)?function(e){function t(t){e.call(this,t),this.uselessComment=this.createComment("")}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===n)return e.prototype.insertHTMLBefore.call(this,t,n,r);var i=!1,o=r?r.previousSibling:t.lastChild;o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,r));var s=e.prototype.insertHTMLBefore.call(this,t,n,r);return i&&t.removeChild(this.uselessComment),s},t}(t):t}function r(e){var t=e.createElement("div");return t.innerHTML="first", -t.insertAdjacentHTML("beforeEnd","second"),2===t.childNodes.length?(t=null,!1):(t=null,!0)}e.domChanges=t,e.treeConstruction=n}),s("glimmer-runtime/lib/compiled/blocks",["exports","glimmer-runtime/lib/utils","glimmer-runtime/lib/compiler"],function(e,t,n){"use strict";var r=function(e,t){this.ops=e,this.symbols=t};e.CompiledBlock=r;var i=function(e,t){this.program=e,this.symbolTable=t,this.compiled=null};e.Block=i;var o=function(e){function i(n,r){var i=arguments.length<=2||void 0===arguments[2]?t.EMPTY_ARRAY:arguments[2];e.call(this,n,r),this.locals=i}return babelHelpers.inherits(i,e),i.prototype.hasPositionalParameters=function(){return!!this.locals.length},i.prototype.compile=function(e){var t=this.compiled;if(t)return t;var i=new n.InlineBlockCompiler(this,e).compile();return this.compiled=new r(i,this.symbolTable.size)},i}(i);e.InlineBlock=o;var s=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t}(o);e.PartialBlock=s;var a=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t}(i);e.TopLevelTemplate=a;var u=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.compile=function(e){var t=this.compiled;if(t)return t;var i=new n.EntryPointCompiler(this,e).compile();return this.compiled=new r(i,this.symbolTable.size)},t}(a);e.EntryPoint=u;var l=function(e){function t(t,n,r,i,o){e.call(this,t,n),this.named=r,this.yields=i,this.hasPartials=o,this.hasNamedParameters=!!this.named.length,this.hasYields=!!this.yields.length}return babelHelpers.inherits(t,e),t}(a);e.Layout=l}),s("glimmer-runtime/lib/compiled/expressions",["exports"],function(e){"use strict";var t=function(){function e(){}return e.prototype.toJSON=function(){return"UNIMPL: "+this.type.toUpperCase()},e}();e.CompiledExpression=t}),s("glimmer-runtime/lib/compiled/expressions/args",["exports","glimmer-runtime/lib/compiled/expressions/positional-args","glimmer-runtime/lib/compiled/expressions/named-args","glimmer-runtime/lib/syntax/core","glimmer-reference"],function(e,t,n,r,i){"use strict";var o=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n}return e.create=function(e,i,o){return e===t.COMPILED_EMPTY_POSITIONAL_ARGS&&i===n.COMPILED_EMPTY_NAMED_ARGS&&o===r.EMPTY_BLOCKS?this.empty():new this(e,i,o)},e.empty=function(){return s},e.prototype.evaluate=function(e){var t=this.positional,n=this.named,r=this.blocks;return a.create(t.evaluate(e),n.evaluate(e),r)},e}();e.CompiledArgs=o;var s=new(function(e){function i(){e.call(this,t.COMPILED_EMPTY_POSITIONAL_ARGS,n.COMPILED_EMPTY_NAMED_ARGS,r.EMPTY_BLOCKS)}return babelHelpers.inherits(i,e),i.prototype.evaluate=function(e){return u},i}(o)),a=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n,this.tag=i.combineTagged([e,t])}return e.empty=function(){return u},e.create=function(e,t,n){return new this(e,t,n)},e.positional=function(e){var i=arguments.length<=1||void 0===arguments[1]?r.EMPTY_BLOCKS:arguments[1];return new this(t.EvaluatedPositionalArgs.create(e),n.EVALUATED_EMPTY_NAMED_ARGS,i)},e.named=function(e){var i=arguments.length<=1||void 0===arguments[1]?r.EMPTY_BLOCKS:arguments[1];return new this(t.EVALUATED_EMPTY_POSITIONAL_ARGS,n.EvaluatedNamedArgs.create(e),i)},e}();e.EvaluatedArgs=a;var u=new a(t.EVALUATED_EMPTY_POSITIONAL_ARGS,n.EVALUATED_EMPTY_NAMED_ARGS,r.EMPTY_BLOCKS);e.CompiledPositionalArgs=t.CompiledPositionalArgs,e.EvaluatedPositionalArgs=t.EvaluatedPositionalArgs,e.CompiledNamedArgs=n.CompiledNamedArgs,e.EvaluatedNamedArgs=n.EvaluatedNamedArgs}),s("glimmer-runtime/lib/compiled/expressions/concat",["exports","glimmer-reference"],function(e,t){"use strict";function n(e){return"function"!=typeof e.toString?"":String(e)}var r=function(){function e(e){this.parts=e,this.type="concat"}return e.prototype.evaluate=function(e){for(var t=new Array(this.parts.length),n=0;n0?e.join(""):null},r}(t.CachedReference)}),s("glimmer-runtime/lib/compiled/expressions/function",["exports","glimmer-runtime/lib/syntax","glimmer-runtime/lib/compiled/expressions"],function(e,t,n){"use strict";function r(e){return new i(e)}e.default=r;var i=function(e){function t(t){e.call(this),this.type="function-expression",this.func=t}return babelHelpers.inherits(t,e),t.prototype.compile=function(e,t,n){return new o(this.func,n)},t}(t.Expression),o=function(e){function t(t,n){e.call(this),this.func=t,this.symbolTable=n,this.type="function",this.func=t}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.func,n=this.symbolTable;return t(e,n)},t.prototype.toJSON=function(){var e=this.func;return e.name?"`"+e.name+"(...)`":"`func(...)`"},t}(n.CompiledExpression)}),s("glimmer-runtime/lib/compiled/expressions/has-block",["exports","glimmer-runtime/lib/compiled/expressions","glimmer-runtime/lib/references"],function(e,t,n){"use strict";var r=function(e){function t(t){e.call(this),this.inner=t,this.type="has-block"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e);return n.PrimitiveReference.create(!!t)},t.prototype.toJSON=function(){return"has-block("+this.inner.toJSON()+")"},t}(t.CompiledExpression);e.default=r;var i=function(e){function t(t){e.call(this),this.inner=t,this.type="has-block-params"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e);return n.PrimitiveReference.create(!!(t&&t.locals.length>0))},t.prototype.toJSON=function(){return"has-block-params("+this.inner.toJSON()+")"},t}(t.CompiledExpression);e.CompiledHasBlockParams=i;var o=function(){function e(e,t){this.symbol=e,this.debug=t}return e.prototype.evaluate=function(e){return e.scope().getBlock(this.symbol)},e.prototype.toJSON=function(){return"get-block($"+this.symbol+"("+this.debug+"))"},e}();e.CompiledGetBlockBySymbol=o;var s=function(){function e(e,t){this.symbol=e,this.name=t}return e.prototype.evaluate=function(e){var t=this.symbol,n=this.name,r=e.scope().getPartialArgs(t);return r.blocks[n]},e.prototype.toJSON=function(){return"get-block($"+this.symbol+"($ARGS)."+this.name+"))"},e}();e.CompiledInPartialGetBlock=s}),s("glimmer-runtime/lib/compiled/expressions/helper",["exports","glimmer-runtime/lib/compiled/expressions"],function(e,t){"use strict";var n=function(e){function t(t,n,r,i){e.call(this),this.name=t,this.helper=n,this.args=r,this.symbolTable=i,this.type="helper"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.helper;return t(e,this.args.evaluate(e),this.symbolTable)},t.prototype.toJSON=function(){return"`"+this.name.join(".")+"($ARGS)`"},t}(t.CompiledExpression);e.default=n}),s("glimmer-runtime/lib/compiled/expressions/lookups",["exports","glimmer-runtime/lib/compiled/expressions","glimmer-reference"],function(e,t,n){"use strict";var r=function(e){function t(t,n){e.call(this),this.base=t,this.path=n,this.type="lookup"}return babelHelpers.inherits(t,e),t.create=function(e,t){return 0===t.length?e:new this(e,t)},t.prototype.evaluate=function(e){var t=this.base,r=this.path;return n.referenceFromParts(t.evaluate(e),r)},t.prototype.toJSON=function(){return this.base.toJSON()+"."+this.path.join(".")},t}(t.CompiledExpression);e.default=r;var i=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){return e.getSelf()},t.prototype.toJSON=function(){return"self"},t}(t.CompiledExpression);e.CompiledSelf=i;var o=function(e){function t(t,n){e.call(this),this.symbol=t,this.debug=n}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){return e.referenceForSymbol(this.symbol)},t.prototype.toJSON=function(){return"$"+this.symbol+"("+this.debug+")"},t}(t.CompiledExpression);e.CompiledSymbol=o;var s=function(e){function t(t,n){e.call(this),this.symbol=t,this.name=n}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.symbol,n=this.name,r=e.scope().getPartialArgs(t);return r.named.get(n)},t.prototype.toJSON=function(){return"$"+this.symbol+"($ARGS)."+this.name},t}(t.CompiledExpression);e.CompiledInPartialName=s}),s("glimmer-runtime/lib/compiled/expressions/named-args",["exports","glimmer-runtime/lib/references","glimmer-runtime/lib/utils","glimmer-reference","glimmer-util"],function(e,t,n,r,i){"use strict";var o=function(){function e(e,t){this.keys=e,this.values=t,this.length=e.length,i.assert(e.length===t.length,"Keys and values do not have the same length")}return e.empty=function(){return s},e.create=function(e){var t=Object.keys(e),n=t.length;if(n>0){for(var r=[],i=0;i"},t}(o));e.COMPILED_EMPTY_NAMED_ARGS=s;var a=function(){function e(e,t){var n=arguments.length<=2||void 0===arguments[2]?void 0:arguments[2];this.keys=e,this.values=t,this._map=n,this.tag=r.combineTagged(t),this.length=e.length,i.assert(e.length===t.length,"Keys and values do not have the same length")}return e.create=function(e){var t=Object.keys(e),n=t.length;if(n>0){for(var r=new Array(n),i=0;i"},t}(i));e.COMPILED_EMPTY_POSITIONAL_ARGS=o;var s=function(){function e(e){this.values=e,this.tag=r.combineTagged(e),this.length=e.length}return e.create=function(e){return new this(e)},e.empty=function(){return a},e.prototype.at=function(e){var n=this.values,r=this.length;return e")}var u=function(e){function t(t){e.call(this),this.text=t,this.type="text"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().appendText(this.text)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.text)]}},t}(t.Opcode);e.TextOpcode=u;var l=function(e){function t(t){e.call(this),this.tag=t,this.type="open-primitive-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().openElement(this.tag)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.tag)]}},t}(t.Opcode);e.OpenPrimitiveElementOpcode=l; -var c=function(e){function t(){e.apply(this,arguments),this.type="push-remote-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=e.frame.getOperand(),n=r.isConst(t)?void 0:new r.ReferenceCache(t),i=n?n.peek():t.value();e.stack().pushRemoteElement(i),n&&e.updateWith(new o.Assert(n))},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:["$OPERAND"]}},t}(t.Opcode);e.PushRemoteElementOpcode=c;var p=function(e){function t(){e.apply(this,arguments),this.type="pop-remote-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().popRemoteElement()},t}(t.Opcode);e.PopRemoteElementOpcode=p;var h=function(e){function t(t){e.call(this),this.tag=t,this.type="open-component-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().openElement(this.tag,new v(e.env))},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.tag)]}},t}(t.Opcode);e.OpenComponentElementOpcode=h;var f=function(e){function t(){e.apply(this,arguments),this.type="open-dynamic-primitive-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=e.frame.getOperand().value();e.stack().openElement(t)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:["$OPERAND"]}},t}(t.Opcode);e.OpenDynamicPrimitiveElementOpcode=f;var m=function(){function e(){this.list=null,this.isConst=!0}return e.prototype.append=function(e){var t=this.list,n=this.isConst;null===t&&(t=this.list=[]),t.push(e),this.isConst=n&&r.isConst(e)},e.prototype.toReference=function(){var e=this.list,t=this.isConst;return e?t?i.PrimitiveReference.create(s(e)):new d(e):i.NULL_REFERENCE},e}(),d=function(e){function t(t){e.call(this),this.list=[],this.tag=r.combineTagged(t),this.list=t}return babelHelpers.inherits(t,e),t.prototype.compute=function(){return s(this.list)},t}(r.CachedReference),g=function(){function e(e){this.env=e,this.opcodes=null,this.classList=null}return e.prototype.addStaticAttribute=function(e,t,n){"class"===t?this.addClass(i.PrimitiveReference.create(n)):this.env.getAppendOperations().setAttribute(e,t,n)},e.prototype.addStaticAttributeNS=function(e,t,n,r){this.env.getAppendOperations().setAttribute(e,n,r,t)},e.prototype.addDynamicAttribute=function(e,t,n,r){if("class"===t)this.addClass(n);else{var i=this.env.attributeFor(e,t,r),o=new x(e,i,t,n);this.addAttribute(o)}},e.prototype.addDynamicAttributeNS=function(e,t,n,r,i){var o=this.env.attributeFor(e,n,i,t),s=new x(e,o,n,r,t);this.addAttribute(s)},e.prototype.flush=function(e,t){for(var n=t.env,r=this.opcodes,i=this.classList,o=0;r&&o.')},t.prototype.valueSyntax=function(){return F.build(this.value)},t}(t.Argument);e.StaticArg=O;var S=function(e){function t(t,n){var r=arguments.length<=2||void 0===arguments[2]?null:arguments[2];e.call(this),this.name=t,this.value=n,this.namespace=r,this.type="dynamic-arg"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2];return new t(n,a.default(r))},t.build=function(e,t){return new this(e,t)},t.prototype.compile=function(){throw new Error('Cannot compile DynamicArg for "'+this.name+'" as it is delegate for ExpressionSyntax.')},t.prototype.valueSyntax=function(){return this.value},t}(t.Argument);e.DynamicArg=S;var x=function(){function e(){}return e.fromSpec=function(e){var t=e[1],n=e[2],r=e[3];return new A(t,a.default(n),r,!0)},e.build=function(e,t,n){var r=arguments.length<=3||void 0===arguments[3]?null:arguments[3];return new A(e,t,r,n)},e.prototype.compile=function(){throw new Error("Attempting to compile a TrustingAttr which is just a delegate for DynamicAttr.")},e}();e.TrustingAttr=x;var C=function(e){function t(t,n,r){e.call(this),this.name=t,this.value=n,this.namespace=r,this["e1185d30-7cac-4b12-b26a-35327d905d92"]=!0,this.type="static-attr",this.isTrusting=!1}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(n,r,i)},t.build=function(e,t){var n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];return new this(e,t,n)},t.prototype.compile=function(e){e.append(new s.StaticAttrOpcode(this.namespace,this.name,this.value))},t.prototype.valueSyntax=function(){return F.build(this.value)},t}(t.Attribute);e.StaticAttr=C;var A=function(e){function t(t,n,r,i){void 0===r&&(r=void 0),e.call(this),this.name=t,this.value=n,this.namespace=r,this.isTrusting=i,this["e1185d30-7cac-4b12-b26a-35327d905d92"]=!0,this.type="dynamic-attr"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(n,a.default(r),i)},t.build=function(e,t){var n=!(arguments.length<=2||void 0===arguments[2])&&arguments[2],r=arguments.length<=3||void 0===arguments[3]?null:arguments[3];return new this(e,t,r,n)},t.prototype.compile=function(e,t,n){var r=this.namespace,o=this.value;e.append(new i.PutValueOpcode(o.compile(e,t,n))),r?e.append(new s.DynamicAttrNSOpcode(this.name,this.namespace,this.isTrusting)):e.append(new s.DynamicAttrOpcode(this.name,this.isTrusting))},t.prototype.valueSyntax=function(){return this.value},t}(t.Attribute);e.DynamicAttr=A;var k=function(e){function t(){e.apply(this,arguments),this.type="flush-element"}return babelHelpers.inherits(t,e),t.fromSpec=function(){return new t},t.build=function(){return new this},t.prototype.compile=function(e){e.append(new s.FlushElementOpcode)},t}(t.Statement);e.FlushElement=k;var T=function(e){function t(){e.apply(this,arguments),this.type="close-element"}return babelHelpers.inherits(t,e),t.fromSpec=function(){return new t},t.build=function(){return new this},t.prototype.compile=function(e){e.append(new s.CloseElementOpcode)},t}(t.Statement);e.CloseElement=T;var N=function(e){function t(t){e.call(this),this.content=t,this.type="text"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.text(this.content)},t}(t.Statement);e.Text=N;var R=function(e){function t(t){e.call(this),this.comment=t,this.type="comment"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.comment(this.comment)},t}(t.Statement);e.Comment=R;var P=function(e){function n(t,n,r){e.call(this),this.tag=t,this.blockParams=n,this.symbolTable=r,this.type="open-element"}return babelHelpers.inherits(n,e),n.fromSpec=function(e,t){var r=e[1],i=e[2];return new n(r,i,t)},n.build=function(e,t,n){return new this(e,t,n)},n.prototype.scan=function(e){var t=this.tag;if(e.env.hasComponentDefinition([t],this.symbolTable)){var n=this.parameters(e),r=n.args,i=n.attrs;e.startBlock(this.blockParams),this.tagContents(e);var o=e.endBlock(this.blockParams);return r.blocks=Y.fromSpec(o),new D(t,i,r)}return new I(t)},n.prototype.compile=function(e,t){e.append(new s.OpenPrimitiveElementOpcode(this.tag))},n.prototype.toIdentity=function(){var e=this.tag;return new I(e)},n.prototype.parameters=function(e){for(var n=e.next(),r=[],i=[],o=[];!(n instanceof k);){if(n[w])throw new Error("Compile Error: Element modifiers are not allowed in components");var s=n;if(n[t.ATTRIBUTE])r.push(s.name),i.push(s.name),o.push(s.valueSyntax());else{if(!n[t.ARGUMENT])throw new Error("Expected FlushElement, but got ${current}");i.push(s.name),o.push(s.valueSyntax())}n=e.next()}return{args:J.fromNamedArgs(X.build(i,o)),attrs:r}},n.prototype.tagContents=function(e){for(var t=1;;){var r=e.next();if(r instanceof T&&0===--t)break;e.addStatement(r),(r instanceof n||r instanceof I)&&t++}},n}(t.Statement);e.OpenElement=P;var D=function(e){function t(t,n,r){e.call(this),this.tag=t,this.attrs=n,this.args=r,this.type="component"}return babelHelpers.inherits(t,e),t.prototype.compile=function(e,t,n){var r=t.getComponentDefinition([this.tag],n),i=this.args.compile(e,t,n),s=this.attrs; -e.append(new o.PutComponentDefinitionOpcode(r)),e.append(new o.OpenComponentOpcode(i,s)),e.append(new o.CloseComponentOpcode)},t}(t.Statement);e.Component=D;var I=function(e){function t(t){e.call(this),this.tag=t,this.type="open-primitive-element"}return babelHelpers.inherits(t,e),t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.append(new s.OpenPrimitiveElementOpcode(this.tag))},t}(t.Statement);e.OpenPrimitiveElement=I;var L=function(e){function t(t,n){e.call(this),this.to=t,this.args=n,this.type="yield"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=J.fromSpec(r,null,Q);return new t(n,i)},t.build=function(e,t){var n=J.fromPositionalArgs($.build(e));return new this(t,n)},t.prototype.compile=function(e,t,n){var r=this.to,i=this.args.compile(e,t,n);if(e.hasBlockSymbol(r)){var o=e.getBlockSymbol(r),s=new p.CompiledGetBlockBySymbol(o,r);e.append(new j(s,i)),e.append(new H)}else{if(!e.hasPartialArgsSymbol())throw new Error("[BUG] ${to} is not a valid block name.");var o=e.getPartialArgsSymbol(),s=new p.CompiledInPartialGetBlock(o,r);e.append(new j(s,i)),e.append(new H)}},t}(t.Statement);e.Yield=L;var M=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var t=e[1],r=a.default(t);return g(r)?new n.StaticPartialSyntax(r):new n.DynamicPartialSyntax(r)},t}(t.Statement);e.Partial=M;var j=function(e){function t(t,n){e.call(this),this.inner=t,this.args=n,this.type="open-block"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e),n=void 0;t&&(n=this.args.evaluate(e)),e.pushCallerScope(),t&&e.invokeBlock(t,n)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,details:{block:this.inner.toJSON(),positional:this.args.positional.toJSON(),named:this.args.named.toJSON()}}},t}(r.Opcode),H=function(e){function t(){e.apply(this,arguments),this.type="close-block"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.popScope()},t}(r.Opcode);e.CloseBlockOpcode=H;var F=function(e){function t(t){e.call(this),this.value=t,this.type="value"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){return new t(e)},t.build=function(e){return new this(e)},t.prototype.inner=function(){return this.value},t.prototype.compile=function(e){return new l.default(this.value)},t}(t.Expression);e.Value=F;var U=function(e){function t(t){e.call(this),this.parts=t,this.type="get-argument"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e.split("."))},t.prototype.compile=function(e){var t=this.parts,n=t[0];if(e.hasNamedSymbol(n)){var r=e.getNamedSymbol(n),i=t.slice(1),o=new c.CompiledSymbol(r,n);return c.default.create(o,i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=t.slice(1),o=new c.CompiledInPartialName(r,n);return c.default.create(o,i)}throw new Error("[BUG] @"+this.parts.join(".")+" is not a valid lookup path.")},t}(t.Expression);e.GetArgument=U;var B=function(e){function t(t){e.call(this),this.parts=t,this.type="ref"}return babelHelpers.inherits(t,e),t.build=function(e){var t=e.split(".");return"this"===t[0]&&(t[0]=null),new this(t)},t.prototype.compile=function(e){var t=this.parts,n=t[0];if(null===n){var r=new c.CompiledSelf,i=t.slice(1);return c.default.create(r,i)}if(e.hasLocalSymbol(n)){var o=e.getLocalSymbol(n),i=t.slice(1),r=new c.CompiledSymbol(o,n);return c.default.create(r,i)}var r=new c.CompiledSelf;return c.default.create(r,t)},t}(t.Expression);e.Ref=B;var z=function(e){function t(t){e.call(this),this.ref=t,this.type="get"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var t=e[1];return new this(new B(t))},t.build=function(e){return new this(B.build(e))},t.prototype.compile=function(e){return this.ref.compile(e)},t}(t.Expression);e.Get=z;var V=function(e){function t(t){e.call(this),this.ref=t,this.type="unknown"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var t=e[1];return new this(new B(t))},t.build=function(e){return new this(B.build(e))},t.prototype.compile=function(e,t,n){var r=this.ref;return t.hasHelper(r.parts,n)?new h.default(r.parts,t.lookupHelper(r.parts,n),u.CompiledArgs.empty(),n):this.ref.compile(e)},t}(t.Expression);e.Unknown=V;var q=function(e){function t(t,n){e.call(this),this.ref=t,this.args=n,this.type="helper"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(new B(n),J.fromSpec(r,i,Q))},t.build=function(e,t,n){return new this(B.build(e),J.build(t,n,Q))},t.prototype.compile=function(e,t,n){if(t.hasHelper(this.ref.parts,n)){var r=this.args,i=this.ref;return new h.default(i.parts,t.lookupHelper(i.parts,n),r.compile(e,t,n),n)}throw new Error("Compile Error: "+this.ref.parts.join(".")+" is not a helper")},t}(t.Expression);e.Helper=q;var G=function(e){function t(t){e.call(this),this.blockName=t,this.type="has-block"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e,t){var n=this.blockName;if(e.hasBlockSymbol(n)){var r=e.getBlockSymbol(n),i=new p.CompiledGetBlockBySymbol(r,n);return new p.default(i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=new p.CompiledInPartialGetBlock(r,n);return new p.default(i)}throw new Error("[BUG] ${blockName} is not a valid block name.")},t}(t.Expression);e.HasBlock=G;var W=function(e){function t(t){e.call(this),this.blockName=t,this.type="has-block-params"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e,t){var n=this.blockName;if(e.hasBlockSymbol(n)){var r=e.getBlockSymbol(n),i=new p.CompiledGetBlockBySymbol(r,n);return new p.CompiledHasBlockParams(i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=new p.CompiledInPartialGetBlock(r,n);return new p.CompiledHasBlockParams(i)}throw new Error("[BUG] ${blockName} is not a valid block name.")},t}(t.Expression);e.HasBlockParams=W;var K=function(){function e(e){this.parts=e,this.type="concat"}return e.fromSpec=function(t){var n=t[1];return new e(n.map(a.default))},e.build=function(e){return new this(e)},e.prototype.compile=function(e,t,n){return new f.default(this.parts.map(function(r){return r.compile(e,t,n)}))},e}();e.Concat=K;var Y=function(){function e(e){var t=arguments.length<=1||void 0===arguments[1]?null:arguments[1];this.type="blocks",this.default=e,this.inverse=t}return e.fromSpec=function(t){var n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];return new e(t,n)},e.empty=function(){return Q},e}();e.Blocks=Y;var Q=new(function(e){function t(){e.call(this,null,null)}return babelHelpers.inherits(t,e),t}(Y));e.EMPTY_BLOCKS=Q;var J=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n,this.type="args"}return e.empty=function(){return te},e.fromSpec=function(t,n,r){return new e($.fromSpec(t),X.fromSpec(n),r)},e.fromPositionalArgs=function(t){var n=arguments.length<=1||void 0===arguments[1]?Q:arguments[1];return new e(t,ee,n)},e.fromNamedArgs=function(t){var n=arguments.length<=1||void 0===arguments[1]?Q:arguments[1];return new e(Z,t,n)},e.build=function(e,t,n){return e===Z&&t===ee&&n===Q?te:new this(e,t,n)},e.prototype.compile=function(e,t,n){var r=this.positional,i=this.named,o=this.blocks;return u.CompiledArgs.create(r.compile(e,t,n),i.compile(e,t,n),o)},e}();e.Args=J;var $=function(){function e(e){this.values=e,this.type="positional",this.length=e.length}return e.empty=function(){return Z},e.fromSpec=function(t){return t&&0!==t.length?new e(t.map(a.default)):Z},e.build=function(e){return 0===e.length?Z:new this(e)},e.prototype.slice=function(t,n){return e.build(this.values.slice(t,n))},e.prototype.at=function(e){return this.values[e]},e.prototype.compile=function(e,t,n){return u.CompiledPositionalArgs.create(this.values.map(function(r){return r.compile(e,t,n)}))},e}();e.PositionalArgs=$;var Z=new(function(e){function t(){e.call(this,m.EMPTY_ARRAY)}return babelHelpers.inherits(t,e),t.prototype.slice=function(e,t){return this},t.prototype.at=function(e){},t.prototype.compile=function(e,t){return u.CompiledPositionalArgs.empty()},t}($)),X=function(){function e(e,t){this.keys=e,this.values=t,this.type="named",this.length=e.length}return e.empty=function(){return ee},e.fromSpec=function(e){if(null===e||void 0===e)return ee;var t=e[0],n=e[1];return 0===t.length?ee:new this(t,n.map(function(e){return a.default(e)}))},e.build=function(e,t){return 0===e.length?ee:new this(e,t)},e.prototype.at=function(e){var t=this.keys,n=this.values,r=t.indexOf(e);return n[r]},e.prototype.has=function(e){return this.keys.indexOf(e)!==-1},e.prototype.compile=function(e,t,n){var r=this.keys,i=this.values;return new u.CompiledNamedArgs(r,i.map(function(r){return r.compile(e,t,n)}))},e}();e.NamedArgs=X;var ee=new(function(e){function t(){e.call(this,m.EMPTY_ARRAY,m.EMPTY_ARRAY)}return babelHelpers.inherits(t,e),t.prototype.at=function(e){},t.prototype.has=function(e){return!1},t.prototype.compile=function(e,t){return u.CompiledNamedArgs.empty()},t}(X)),te=new(function(e){function t(){e.call(this,Z,ee,Q)}return babelHelpers.inherits(t,e),t.prototype.compile=function(e,t){return u.CompiledArgs.empty()},t}(J))}),s("glimmer-runtime/lib/syntax/expressions",["exports","glimmer-runtime/lib/syntax/core","glimmer-wire-format"],function(e,t,n){"use strict";var r=n.Expressions.isArg,i=n.Expressions.isConcat,o=n.Expressions.isGet,s=n.Expressions.isHasBlock,a=n.Expressions.isHasBlockParams,u=n.Expressions.isHelper,l=n.Expressions.isUnknown,c=n.Expressions.isPrimitiveValue,p=n.Expressions.isUndefined;e.default=function(e){if(c(e))return t.Value.fromSpec(e);if(p(e))return t.Value.build(void 0);if(r(e))return t.GetArgument.fromSpec(e);if(i(e))return t.Concat.fromSpec(e);if(o(e))return t.Get.fromSpec(e);if(u(e))return t.Helper.fromSpec(e);if(l(e))return t.Unknown.fromSpec(e);if(s(e))return t.HasBlock.fromSpec(e);if(a(e))return t.HasBlockParams.fromSpec(e);throw new Error("Unexpected wire format: "+JSON.stringify(e))}}),s("glimmer-runtime/lib/syntax/statements",["exports","glimmer-runtime/lib/syntax/core","glimmer-wire-format"],function(e,t,n){"use strict";var r=n.Statements.isYield,i=n.Statements.isBlock,o=n.Statements.isPartial,s=n.Statements.isAppend,a=n.Statements.isDynamicAttr,u=n.Statements.isText,l=n.Statements.isComment,c=n.Statements.isOpenElement,p=n.Statements.isFlushElement,h=n.Statements.isCloseElement,f=n.Statements.isStaticAttr,m=n.Statements.isModifier,d=n.Statements.isDynamicArg,g=n.Statements.isStaticArg,v=n.Statements.isTrustingAttr;e.default=function(e,n,y){return r(e)?t.Yield.fromSpec(e):o(e)?t.Partial.fromSpec(e):i(e)?t.Block.fromSpec(e,n,y):s(e)?t.OptimizedAppend.fromSpec(e):a(e)?t.DynamicAttr.fromSpec(e):d(e)?t.DynamicArg.fromSpec(e):v(e)?t.TrustingAttr.fromSpec(e):u(e)?t.Text.fromSpec(e):l(e)?t.Comment.fromSpec(e):c(e)?t.OpenElement.fromSpec(e,n):p(e)?t.FlushElement.fromSpec():h(e)?t.CloseElement.fromSpec():f(e)?t.StaticAttr.fromSpec(e):g(e)?t.StaticArg.fromSpec(e):m(e)?t.Modifier.fromSpec(e):void 0}}),s("glimmer-runtime/lib/template",["exports","glimmer-util","glimmer-runtime/lib/builder","glimmer-runtime/lib/vm","glimmer-runtime/lib/scanner"],function(e,t,n,r,i){"use strict";function o(e){var n=e.id,r=e.meta,i=e.block,o=void 0;n||(n="client-"+a++);var u=function(e,a){var u=a?t.assign({},a,r):r;return o||(o=JSON.parse(i)),s(o,n,u,e)};return{id:n,meta:r,create:u}}function s(e,t,o,s){var a=new i.default(e,o,s),u=void 0,l=function(){return u||(u=a.scanEntryPoint()),u},c=void 0,p=function(){return c||(c=a.scanLayout()),c},h=function(e){return a.scanPartial(e)},f=function(e,t,i){var o=n.ElementStack.forInitialRender(s,t,null),a=l().compile(s),u=r.VM.initial(s,e,i,o,a.symbols);return u.execute(a.ops)};return{id:t,meta:o,_block:e,asEntryPoint:l,asLayout:p,asPartial:h,render:f}}e.default=o;var a=0}),s("glimmer-runtime/lib/upsert",["exports","glimmer-runtime/lib/bounds"],function(e,t){"use strict";function n(e){return e&&"function"==typeof e.toHTML}function r(e){return null!==e&&"object"==typeof e&&"number"==typeof e.nodeType}function i(e){return"string"==typeof e}function o(e,t,o){return i(o)?u.insert(e,t,o):n(o)?c.insert(e,t,o):r(o)?p.insert(e,t,o):void 0}function s(e,t,n){return i(n)?l.insert(e,t,n):r(n)?p.insert(e,t,n):void 0}e.isSafeString=n,e.isNode=r,e.isString=i,e.cautiousInsert=o,e.trustingInsert=s;var a=function(e){this.bounds=e};e.default=a;var u=function(e){function n(t,n){e.call(this,t),this.textNode=n}return babelHelpers.inherits(n,e),n.insert=function(e,r,i){var o=e.createTextNode(i);e.insertBefore(r.element,o,r.nextSibling);var s=new t.SingleNodeBounds(r.element,o);return new n(s,o)},n.prototype.update=function(e,t){if(i(t)){var n=this.textNode;return n.nodeValue=t,!0}return!1},n}(a),l=function(e){function n(){e.apply(this,arguments)}return babelHelpers.inherits(n,e),n.insert=function(e,t,r){var i=e.insertHTMLBefore(t.element,r,t.nextSibling);return new n(i)},n.prototype.update=function(e,n){if(i(n)){var r=this.bounds,o=r.parentElement(),s=t.clear(r);return this.bounds=e.insertHTMLBefore(o,s,n),!0}return!1},n}(a),c=function(e){function r(t,n){e.call(this,t),this.lastStringValue=n}return babelHelpers.inherits(r,e),r.insert=function(e,t,n){var i=n.toHTML(),o=e.insertHTMLBefore(t.element,i,t.nextSibling);return new r(o,i)},r.prototype.update=function(e,r){if(n(r)){var i=r.toHTML();if(i!==this.lastStringValue){var o=this.bounds,s=o.parentElement(),a=t.clear(o);this.bounds=e.insertHTMLBefore(s,a,i),this.lastStringValue=i}return!0}return!1},r}(a),p=function(e){function n(){e.apply(this,arguments)}return babelHelpers.inherits(n,e),n.insert=function(e,r,i){return e.insertBefore(r.element,i,r.nextSibling),new n(t.single(r.element,i))},n.prototype.update=function(e,n){if(r(n)){var i=this.bounds,o=i.parentElement(),s=t.clear(i);return this.bounds=e.insertNodeBefore(o,n,s),!0}return!1},n}(a)}),s("glimmer-runtime/lib/utils",["exports","glimmer-util"],function(e,t){"use strict";var n=Object.freeze([]);e.EMPTY_ARRAY=n;var r=Object.freeze(t.dict());e.EMPTY_DICT=r;var i=function(){function e(e,t,n){this.list=e,this.start=t,this.end=n}return e.prototype.at=function(e){return e>=this.list.length?null:this.list[e]},e.prototype.min=function(){return this.start},e.prototype.max=function(){return this.end},e}();e.ListRange=i}),s("glimmer-runtime/lib/vm",["exports","glimmer-runtime/lib/vm/append","glimmer-runtime/lib/vm/update","glimmer-runtime/lib/vm/render-result"],function(e,t,n,r){"use strict";e.VM=t.default,e.PublicVM=t.PublicVM,e.UpdatingVM=n.default,e.RenderResult=r.default}),s("glimmer-runtime/lib/vm/append",["exports","glimmer-runtime/lib/environment","glimmer-util","glimmer-reference","glimmer-runtime/lib/compiled/opcodes/vm","glimmer-runtime/lib/vm/update","glimmer-runtime/lib/vm/render-result","glimmer-runtime/lib/vm/frame"],function(e,t,n,r,i,o,s,a){"use strict";var u=function(){function e(e,t,r,i){this.env=e,this.elementStack=i,this.dynamicScopeStack=new n.Stack,this.scopeStack=new n.Stack,this.updatingOpcodeStack=new n.Stack,this.cacheGroups=new n.Stack,this.listBlockStack=new n.Stack,this.frame=new a.FrameStack,this.env=e,this.elementStack=i,this.scopeStack.push(t),this.dynamicScopeStack.push(r)}return e.initial=function(n,r,i,o,s){var a=t.Scope.root(r,s);return new e(n,a,i,o)},e.prototype.capture=function(){return{env:this.env,scope:this.scope(),dynamicScope:this.dynamicScope(),frame:this.frame.capture()}},e.prototype.goto=function(e){this.frame.goto(e)},e.prototype.beginCacheGroup=function(){this.cacheGroups.push(this.updatingOpcodeStack.current.tail())},e.prototype.commitCacheGroup=function(){var e=new i.LabelOpcode("END"),t=this.updatingOpcodeStack.current,o=this.cacheGroups.pop(),s=o?t.nextNode(o):t.head(),a=t.tail(),u=r.combineSlice(new n.ListSlice(s,a)),l=new i.JumpIfNotModifiedOpcode(u,e);t.insertBefore(l,s),t.append(new i.DidModifyOpcode(l)),t.append(e)},e.prototype.enter=function(e){var t=new n.LinkedList,r=this.stack().pushUpdatableBlock(),i=this.capture(),s=new o.TryOpcode(e,i,r,t);this.didEnter(s,t)},e.prototype.enterWithKey=function(e,t){var r=new n.LinkedList,i=this.stack().pushUpdatableBlock(),s=this.capture(),a=new o.TryOpcode(t,s,i,r);this.listBlockStack.current.map[e]=a,this.didEnter(a,r)},e.prototype.enterList=function(e){var t=new n.LinkedList,r=this.stack().pushBlockList(t),i=this.capture(),s=this.frame.getIterator().artifacts,a=new o.ListBlockOpcode(e,i,r,t,s);this.listBlockStack.push(a),this.didEnter(a,t)},e.prototype.didEnter=function(e,t){this.updateWith(e),this.updatingOpcodeStack.push(t)},e.prototype.exit=function(){this.stack().popBlock(),this.updatingOpcodeStack.pop();var e=this.updatingOpcodeStack.current.tail();e.didInitializeChildren()},e.prototype.exitList=function(){this.exit(),this.listBlockStack.pop()},e.prototype.updateWith=function(e){this.updatingOpcodeStack.current.append(e)},e.prototype.stack=function(){return this.elementStack},e.prototype.scope=function(){return this.scopeStack.current},e.prototype.dynamicScope=function(){return this.dynamicScopeStack.current},e.prototype.pushFrame=function(e,t,n){this.frame.push(e.ops),t&&this.frame.setArgs(t),t&&t.blocks&&this.frame.setBlocks(t.blocks),n&&this.frame.setCallerScope(n)},e.prototype.pushComponentFrame=function(e,t,n,r,i,o){this.frame.push(e.ops,r,i,o),t&&this.frame.setArgs(t),t&&t.blocks&&this.frame.setBlocks(t.blocks),n&&this.frame.setCallerScope(n)},e.prototype.pushEvalFrame=function(e){this.frame.push(e)},e.prototype.pushChildScope=function(){this.scopeStack.push(this.scopeStack.current.child())},e.prototype.pushCallerScope=function(){this.scopeStack.push(this.scope().getCallerScope())},e.prototype.pushDynamicScope=function(){var e=this.dynamicScopeStack.current.child();return this.dynamicScopeStack.push(e),e},e.prototype.pushRootScope=function(e,n){var r=t.Scope.root(e,n);return this.scopeStack.push(r),r},e.prototype.popScope=function(){this.scopeStack.pop()},e.prototype.popDynamicScope=function(){this.dynamicScopeStack.pop()},e.prototype.newDestroyable=function(e){this.stack().newDestroyable(e)},e.prototype.getSelf=function(){return this.scope().getSelf()},e.prototype.referenceForSymbol=function(e){return this.scope().getSymbol(e)},e.prototype.getArgs=function(){return this.frame.getArgs()},e.prototype.resume=function(e,t){return this.execute(e,function(e){return e.frame.restore(t)})},e.prototype.execute=function(e,t){n.LOGGER.debug("[VM] Begin program execution");var r=this.elementStack,i=this.frame,o=this.updatingOpcodeStack,a=this.env;r.pushSimpleBlock(),o.push(new n.LinkedList),i.push(e),t&&t(this);for(var u=void 0;i.hasOpcodes();)(u=i.nextStatement())&&(n.LOGGER.debug("[VM] OP "+u.type),n.LOGGER.trace(u),u.evaluate(this));return n.LOGGER.debug("[VM] Completed program execution"),new s.default(a,o.pop(),r.popBlock())},e.prototype.evaluateOpcode=function(e){e.evaluate(this)},e.prototype.invokeBlock=function(e,t){var n=e.compile(this.env);this.pushFrame(n,t)},e.prototype.invokePartial=function(e){var t=e.compile(this.env);this.pushFrame(t)},e.prototype.invokeLayout=function(e,t,n,r,i,o){this.pushComponentFrame(t,e,n,r,i,o)},e.prototype.evaluateOperand=function(e){this.frame.setOperand(e.evaluate(this))},e.prototype.evaluateArgs=function(e){var t=this.frame.setArgs(e.evaluate(this));this.frame.setOperand(t.positional.at(0))},e.prototype.bindPositionalArgs=function(e){var t=this.frame.getArgs();n.assert(t,"Cannot bind positional args");for(var r=t.positional,i=this.scope(),o=0;o2&&"[]"===s.slice(a-2)&&(u=!0,s=s.slice(0,a-2),n[s]||(n[s]=[])),i=o[1]?O(o[1]):""),u?n[s].push(i):n[s]=i}return n},recognize:function(e){var t,n,r,i,o=[this.rootState],s={},u=!1;if(i=e.indexOf("#"),i!==-1&&(e=e.substr(0,i)),r=e.indexOf("?"),r!==-1){var l=e.substr(r+1,e.length);e=e.substr(0,r),s=this.parseQueryString(l)}"/"!==e.charAt(0)&&(e="/"+e);var c=e;for(T.ENCODE_AND_DECODE_PATH_SEGMENTS?e=a(e):(e=decodeURI(e),c=decodeURI(c)),t=e.length,t>1&&"/"===e.charAt(t-1)&&(e=e.substr(0,t-1),c=c.substr(0,c.length-1),u=!0),n=0;n0&&e[r-1]&&e[r-1].hasOwnProperty("queryParams")?(n=e[r-1].queryParams,t=B.call(e,0,r-1),[t,n]):[e,null]}function s(e){for(var t in e)if("number"==typeof e[t])e[t]=""+e[t];else if(z(e[t]))for(var n=0,r=e[t].length;n=0;a--){var l=t[a],c=l.handler;if(c){if(c.events&&c.events[o]){if(c.events[o].apply(c,r)!==!0)return;s=!0}}else l.handlerPromise.then(u(null,i,o,r))}if("error"===o&&"UnrecognizedURLError"===r[0].name)throw r[0];if(!s&&!n)throw new Error("Nothing handled the event '"+o+"'.")}function h(e,t){var n,r={all:{},changed:{},removed:{}};i(r.all,t);var o=!1;s(e),s(t);for(n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||(o=!0,r.removed[n]=e[n]));for(n in t)if(t.hasOwnProperty(n))if(z(e[n])&&z(t[n]))if(e[n].length!==t[n].length)r.changed[n]=t[n],o=!0;else for(var a=0,u=e[n].length;a=0;--u){var l=o[u];i(a,l.params),l.handler.inaccessibleByURL&&(n=null)}if(n){a.queryParams=e._visibleQueryParams||t.queryParams;var c=r.recognizer.generate(s,a),p=e.isCausedByInitialTransition,h="replace"===n&&!e.isCausedByAbortingTransition;p||h?r.replaceURL(c):r.updateURL(c)}}}function L(e,t){try{a(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.");var r=e.router,i=t.handlerInfos;return R(r,t,e),e.isAborted?(r.state.handlerInfos=r.currentHandlerInfos,n.Promise.reject(E(e))):(I(e,t,e.intent.url),e.isActive=!1,r.activeTransition=null,p(r,r.currentHandlerInfos,!0,["didTransition"]),r.didTransition&&r.didTransition(r.currentHandlerInfos),a(r,e.sequence,"TRANSITION COMPLETE."),i[i.length-1].handler)}catch(t){if(!(t instanceof b)){var o=e.state.handlerInfos;e.trigger(!0,"error",t,e,o[o.length-1].handler),e.abort()}throw t}}function M(e,t,n){var r=t[0]||"/",i=t[t.length-1],o={};i&&i.hasOwnProperty("queryParams")&&(o=J.call(t).queryParams);var s;if(0===t.length){a(e,"Updating query params");var u=e.state.handlerInfos;s=new Y({name:u[u.length-1].name,contexts:[],queryParams:o})}else"/"===r.charAt(0)?(a(e,"Attempting URL transition to "+r),s=new Q({url:r})):(a(e,"Attempting transition to "+r),s=new Y({name:t[0],contexts:B.call(t,1),queryParams:o}));return e.transitionByIntent(s,n)}function j(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n=r.length?r.length-1:t.resolveIndex;return n.Promise.reject({error:e,handlerWithError:u.handlerInfos[i].handler,wasAborted:l,state:u})}function o(e){var n=u.handlerInfos[t.resolveIndex].isResolved;if(u.handlerInfos[t.resolveIndex++]=e,!n){var i=e.handler;g(i,"redirect",e.context,t)}return r().then(s,null,u.promiseLabel("Resolve handler"))}function s(){if(t.resolveIndex===u.handlerInfos.length)return{error:null,state:u};var e=u.handlerInfos[t.resolveIndex];return e.resolve(r,t).then(o,null,u.promiseLabel("Proceed"))}var a=this.params;c(this.handlerInfos,function(e){a[e.name]=e.params||{}}),t=t||{},t.resolveIndex=0;var u=this,l=!1;return n.Promise.resolve(null,this.promiseLabel("Start transition")).then(s,null,this.promiseLabel("Resolve handler")).catch(i,this.promiseLabel("Handle error"))}},b.prototype=V(Error.prototype),_.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:!1,isTransition:!0,isExiting:function(e){for(var t=this.handlerInfos,n=0,r=t.length;n=0;--u){var f=t[u],m=f.handler,d=e.handlerInfos[u],g=null;if(f.names.length>0)if(u>=h)g=this.createParamHandlerInfo(m,n,f.names,p,d);else{var v=a(m);g=this.getHandlerInfoForDynamicSegment(m,n,f.names,p,d,r,u,v); -}else g=this.createParamHandlerInfo(m,n,f.names,p,d);if(s){g=g.becomeResolved(null,g.context);var b=d&&d.context;f.names.length>0&&g.context===b&&(g.params=d&&d.params),g.context=b}var _=d;(u>=h||g.shouldSupercede(d))&&(h=Math.min(u,h),_=g),o&&!s&&(_=_.becomeResolved(null,_.context)),c.handlerInfos.unshift(_)}if(p.length>0)throw new Error("More context objects were passed than there are dynamic segments for the route: "+r);return o||this.invalidateChildren(c.handlerInfos,h),i(c.queryParams,this.queryParams||{}),c},invalidateChildren:function(e,t){for(var n=t,r=e.length;n0){if(u=r[r.length-1],l(u))return this.createParamHandlerInfo(e,t,n,r,i);r.pop()}else{if(i&&i.name===e)return i;if(!this.preTransitionState)return i;var c=this.preTransitionState.handlerInfos[s];u=c&&c.context}return C("object",{name:e,getHandler:t,serializer:a,context:u,names:n})},createParamHandlerInfo:function(e,t,n,r,i){for(var o={},s=n.length;s--;){var a=i&&e===i.name&&i.params||{},u=r[r.length-1],c=n[s];if(l(u))o[c]=""+r.pop();else{if(!a.hasOwnProperty(c))throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e);o[c]=a[c]}}return C("param",{name:e,getHandler:t,params:o})}});A.prototype=V(Error.prototype);var Q=m(O,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,t,n){function r(e){if(e&&e.inaccessibleByURL)throw new A(c);return e}var o,s,a=new y,u=t.recognize(this.url);if(!u)throw new A(this.url);var l=!1,c=this.url;for(o=0,s=u.length;o=0&&r;--n){var i=t[n];e.add(t,{as:i.handler}),r="/"===i.path||""===i.path||".index"===i.handler.slice(-6)}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,t,n,r){var i=this;if(N(this,r,e),!t&&this.activeTransition)return this.activeTransition;var o=new _(this);return o.queryParamsOnly=!0,n.queryParams=H(this,r.handlerInfos,r.queryParams,o),o.promise=o.promise.then(function(e){return I(o,n,!0),i.didTransition&&i.didTransition(i.currentHandlerInfos),e},null,f("Transition complete")),o},transitionByIntent:function(e){try{return T.apply(this,arguments)}catch(t){return new _(this,e,null,t)}},reset:function(){this.state&&c(this.state.handlerInfos.slice().reverse(),function(e){var t=e.handler;g(t,"exit")}),this.oldState=void 0,this.state=new y,this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var t=B.call(arguments);return"/"!==e.charAt(0)&&(t[0]="/"+e),M(this,t).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return M(this,arguments)},intermediateTransitionTo:function(){return M(this,arguments,!0)},refresh:function(e){for(var t=this.activeTransition?this.activeTransition.state:this.state,n=t.handlerInfos,r={},i=0,o=n.length;i1)throw new Error("Second argument not supported");if("object"!=typeof e)throw new TypeError("Argument must be an object");return a.prototype=e,new a},Ce=[],Ae=void 0,ke=1,Te=2,Ne=new S,Re=new S;N.prototype._validateInput=function(e){return Oe(e)},N.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},N.prototype._init=function(){this._result=new Array(this.length)},N.prototype._enumerate=function(){for(var e=this.length,t=this.promise,n=this._input,r=0;t._state===Ae&&r")}function m(e){return"function"!=typeof e.toString?"":String(e)}function v(e,t){return console.info("Use `context`, and `get()` to debug this template."),{context:e,get:t}}function g(e,t){return function(n){var r=n.split(".") +return"this"===r[0]&&(r[0]=null),A(r,t).evaluate(e)}}function y(e){Wt=e}function b(){Wt=v}function _(e,t){return Array.isArray(e)?Qt.compile(e,t):new Pt(e)}function w(e,t,n){var r=C(e,n),i=O(t,n) +return Ze.create(r,i,Xe)}function E(e,t,n,r){var i=C(e,r),o=O(t,r) +return Ze.create(i,o,n)}function x(e,t){var n=e[0],r=e[1],i=e[2],o=e[3] +return Ze.create(C(n,t),O(r,t),{default:i,inverse:o})}function C(e,t){if(!e||0===e.length)return We +var n=e.map(function(e){return _(e,t)}) +return Ve.create(n)}function O(e,t){if(!e)return Ye +var n=e[0],r=e[1] +if(0===n.length)return Ye +var i=r.map(function(e){return _(e,t)}) +return new Qe(n,i)}function A(e,t){var n=e[0],r=void 0 +if(null===n){var i=new Ft,o=e.slice(1) +return Mt.create(i,o)}if(r=t.symbolTable.getSymbol("local",n)){var o=e.slice(1),i=new Ut(r,n) +return Mt.create(i,o)}var i=new Ft +return Mt.create(i,e)}function S(){var e=arguments.length<=0||void 0===arguments[0]?new Yt:arguments[0],n=arguments.length<=1||void 0===arguments[1]?new $t:arguments[1] +return e.add("if",function(e,n){var r=e[2],i=e[3],o=e[4],s=e[5],a=w(r,i,n) +n.putArgs(a),n.test("environment"),n.labelled(null,function(e){if(o&&s)e.jumpUnless("ELSE"),e.evaluate(o),e.jump("END"),e.label("ELSE"),e.evaluate(s) +else{if(!o)throw t.unreachable() +e.jumpUnless("END"),e.evaluate(o)}})}),e.add("unless",function(e,n){var r=e[2],i=e[3],o=e[4],s=e[5],a=w(r,i,n) +n.putArgs(a),n.test("environment"),n.labelled(null,function(e){if(o&&s)e.jumpIf("ELSE"),e.evaluate(o),e.jump("END"),e.label("ELSE"),e.evaluate(s) +else{if(!o)throw t.unreachable() +e.jumpIf("END"),e.evaluate(o)}})}),e.add("with",function(e,n){var r=e[2],i=e[3],o=e[4],s=e[5],a=w(r,i,n) +n.putArgs(a),n.test("environment"),n.labelled(null,function(e){if(o&&s)e.jumpUnless("ELSE"),e.evaluate(o),e.jump("END"),e.label("ELSE"),e.evaluate(s) +else{if(!o)throw t.unreachable() +e.jumpUnless("END"),e.evaluate(o)}})}),e.add("each",function(e,n){var r=e[2],i=e[3],o=e[4],s=e[5],a=w(r,i,n) +n.labelled(a,function(e){e.putIterator(),s?e.jumpUnless("ELSE"):e.jumpUnless("END"),e.iter(function(e){e.evaluate(t.unwrap(o))}),s&&(e.jump("END"),e.label("ELSE"),e.evaluate(s))})}),{blocks:e,inlines:n}}function k(e,t){return e.indexOf(t)!==-1}function T(e,t){return(null===e||k(en,e))&&k(nn,t)}function R(e,t){return null!==e&&(k(tn,e)&&k(rn,t))}function N(e,t){return T(e,t)||R(e,t)}function P(e,t,n,r){var i=null +if(null===r||void 0===r)return r +if(a(r))return r.toHTML() +i=t?t.tagName.toUpperCase():null +var o=ve(r) +if(T(i,n)){var s=e.protocolForURL(o) +if(k(Zt,s))return"unsafe:"+o}return R(i,n)?"unsafe:"+o:o}function D(e,t){var n=void 0,r=void 0 +if(t in e)r=t,n="prop" +else{var i=t.toLowerCase() +i in e?(n="prop",r=i):(n="attr",r=t)}return"prop"!==n||"style"!==r.toLowerCase()&&!I(e.tagName,r)||(n="attr"),{normalized:r,type:n}}function I(e,t){var n=on[e.toUpperCase()] +return n&&n[t.toLowerCase()]||!1}function j(e,t){if(!e)return t +if(!F(e))return t +var n=e.createElement("div") +return function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,r,i){if(null===i||""===i)return e.prototype.insertHTMLBefore.call(this,t,r,i) +var o=t.tagName.toLowerCase(),s=sn[o] +return void 0===s?e.prototype.insertHTMLBefore.call(this,t,r,i):M(t,s,n,i,r)},t}(t)}function L(e,t){if(!e)return t +if(!F(e))return t +var n=e.createElement("div") +return function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,r,i){if(null===r||""===r)return e.prototype.insertHTMLBefore.call(this,t,r,i) +var o=t.tagName.toLowerCase(),s=sn[o] +return void 0===s?e.prototype.insertHTMLBefore.call(this,t,r,i):M(t,s,n,r,i)},t}(t)}function M(e,t,n,r,i){var o=t.before+r+t.after +n.innerHTML=o +for(var s=n,a=0;a" +t.innerHTML=i +var o=G(t.firstChild,e,r),s=o[0],a=o[1] +return new st(e,s,a)}function B(e,n){var r=e.createElementNS(n,"svg") +try{r.insertAdjacentHTML("beforeEnd","")}catch(e){}finally{return 1!==r.childNodes.length||t.unwrap(r.firstChild).namespaceURI!==an}}function q(e,t){return e&&W(e)?function(e){function t(t){e.call(this,t),this.uselessComment=t.createComment("")}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===r)return e.prototype.insertHTMLBefore.call(this,t,n,r) +var i=!1,o=n?n.previousSibling:t.lastChild +o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,n)) +var s=e.prototype.insertHTMLBefore.call(this,t,n,r) +return i&&t.removeChild(this.uselessComment),s},t}(t):t}function V(e,t){return e&&W(e)?function(e){function t(t){e.call(this,t),this.uselessComment=this.createComment("")}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===n)return e.prototype.insertHTMLBefore.call(this,t,n,r) +var i=!1,o=r?r.previousSibling:t.lastChild +o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,r)) +var s=e.prototype.insertHTMLBefore.call(this,t,n,r) +return i&&t.removeChild(this.uselessComment),s},t}(t):t}function W(e){var t=e.createElement("div") +return t.innerHTML="first",t.insertAdjacentHTML("beforeEnd","second"),2!==t.childNodes.length}function K(e){return hn.test(e)}function G(e,t,n){for(var r=e.firstChild,i=null,o=r;o;)i=o,o=o.nextSibling,t.insertBefore(i,n) +return[r,i]}function Q(e,t,n,r){var i=t,o=e,s=n,a=s?s.previousSibling:i.lastChild,u=void 0 +if(null===r||""===r)return new st(i,null,null) +null===s?(i.insertAdjacentHTML("beforeEnd",r),u=i.lastChild):s instanceof HTMLElement?(s.insertAdjacentHTML("beforeBegin",r),u=s.previousSibling):(i.insertBefore(o,s),o.insertAdjacentHTML("beforeBegin",r),u=o.previousSibling,i.removeChild(o)) +var l=a?a.nextSibling:i.firstChild +return new st(i,l,u)}function Y(e){return e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function J(e,t,n,r){var i=e.tagName,o=e.namespaceURI===un +if(o)return X(i,t) +var s=D(e,t),a=s.type,u=s.normalized +return"attr"===a?X(i,u):$(i,u)}function $(e,t){return N(e,t)?new _n(t):ne(e,t)?En:re(e,t)?Cn:new bn(t)}function X(e,t){return N(e,t)?new On(t):new yn(t)}function Z(e,t){var n=e.namespaceURI===un,r=D(e,t),i=r.type,o=r.normalized +return n?e.getAttribute(o):"attr"===i?e.getAttribute(o):e[o]}function ee(e){return e===!1||void 0===e||null===e?null:e===!0?"":"function"==typeof e?null:String(e)}function te(e){return null===e||void 0===e}function ne(e,t){return("INPUT"===e||"TEXTAREA"===e)&&"value"===t}function re(e,t){return"OPTION"===e&&"selected"===t}function ie(e){return new Vn(e)}function oe(e,t,n,r){var i=ae(t,n,r),o=i.named,s=i.yields,a=i.partialSymbol,u=i.size +return new Vn(e,o,s,a,u)}function se(e,n){var r=null,i=e.program +return 0!==n.length&&function(){var e=r=t.dict() +n.forEach(function(t){return e[t]=i.size++})}(),new Wn(e,i,r)}function ae(e,n,r){var i=null,o=null,s=1 +0!==n.length&&function(){var e=i=t.dict() +n.forEach(function(t){return e[t]=s++})}(),0!==e.length&&function(){var n=o=t.dict() +e.forEach(function(e){return n[e]=s++})}() +var a=r?s++:null +return{named:o,yields:i,partialSymbol:a,size:s}}function ue(e,t){var n=Gn.specialize(e,t.symbolTable) +Gt.compile(n,t)}function le(e,t,n){var r=e.statements +return new nr(n,t,r).scan()}function ce(e,t){var n=new rr(t) +return e.compile(n),n.compile()}function pe(e){var t=e[0] +return"open-element"===t||"open-primitive-element"===t}function he(e,t){return new pr(t,e)}function fe(e,t,n,r){return Pe.construct(e,null,t,n,r)}function de(e){return e&&"function"==typeof e.compile}function me(e){return null===e||void 0===e||"function"!=typeof e.toString}function ve(e){return me(e)?"":String(e)}function ge(e){return me(e)?"":l(e)?e:a(e)?e.toHTML():u(e)?e:String(e)}function ye(e){return me(e)?"":l(e)?e:a(e)||u(e)?e:String(e)}function be(e){var n=e.id,r=e.meta,i=e.block,o=void 0,s=n||"client-"+Tr++,a=function(e,n){var a=n?t.assign({},n,r):r +return o||(o=JSON.parse(i)),_e(o,s,a,e)} +return{id:s,meta:r,create:a}}function _e(e,t,n,r){var i=new tr(e,n,r),o=void 0,s=function(){return o||(o=i.scanEntryPoint()),o},a=void 0,u=function(){return a||(a=i.scanLayout()),a},l=function(e){return i.scanPartial(e)},c=function(e,t,n){var i=St.forInitialRender(r,t,null),o=s().compile(r),a=jn.initial(r,e,n,i,o.symbols) +return a.execute(o.slice)} +return{id:t,meta:n,_block:e,asEntryPoint:s,asLayout:u,asPartial:l,render:c}}function we(e,t,n){var r=e.dynamicScope(),i=t.positional.at(0) +return new Rr(r,i)}var Ee=function(e){function t(t){e.call(this,t)}return babelHelpers.inherits(t,e),t.create=function(e){return void 0===e?Oe:null===e?Ae:e===!0?Se:e===!1?ke:"number"==typeof e?new Ce(e):new xe(e)},t.prototype.get=function(e){return Oe},t}(n.ConstReference),xe=function(e){function t(){e.apply(this,arguments),this.lengthReference=null}return babelHelpers.inherits(t,e),t.prototype.get=function(t){if("length"===t){var n=this.lengthReference +return null===n&&(n=this.lengthReference=new Ce(this.inner.length)),n}return e.prototype.get.call(this,t)},t}(Ee),Ce=function(e){function t(t){e.call(this,t)}return babelHelpers.inherits(t,e),t}(Ee),Oe=new Ce(void 0),Ae=new Ce(null),Se=new Ce(!0),ke=new Ce(!1),Te=function(){function e(e){this.inner=e,this.tag=e.tag}return e.prototype.value=function(){return this.toBool(this.inner.value())},e.prototype.toBool=function(e){return!!e},e}(),Re=function(){function e(){this.references=[],this.strings=[],this.expressions=[],this.arrays=[],this.slices=[],this.blocks=[],this.functions=[],this.others=[],this.NULL_REFERENCE=this.reference(Ae),this.UNDEFINED_REFERENCE=this.reference(Oe)}return e.prototype.getReference=function(e){return this.references[e-1]},e.prototype.reference=function(e){var t=this.references.length +return this.references.push(e),t+1},e.prototype.getString=function(e){return this.strings[e-1]},e.prototype.string=function(e){var t=this.strings.length +return this.strings.push(e),t+1},e.prototype.getExpression=function(e){return this.expressions[e-1]},e.prototype.expression=function(e){var t=this.expressions.length +return this.expressions.push(e),t+1},e.prototype.getArray=function(e){return this.arrays[e-1]},e.prototype.array=function(e){var t=this.arrays.length +return this.arrays.push(e),t+1},e.prototype.getSlice=function(e){return this.slices[e-1]},e.prototype.slice=function(e){var t=this.slices.length +return this.slices.push(e),t+1},e.prototype.getBlock=function(e){return this.blocks[e-1]},e.prototype.block=function(e){var t=this.blocks.length +return this.blocks.push(e),t+1},e.prototype.getFunction=function(e){return this.functions[e-1]},e.prototype.function=function(e){var t=this.functions.length +return this.functions.push(e),t+1},e.prototype.getOther=function(e){return this.others[e-1]},e.prototype.other=function(e){var t=this.others.length +return this.others.push(e),t+1},e}(),Ne=function(){function e(){this.evaluateOpcode=t.fillNulls(52)}return e.prototype.add=function(e,t){this.evaluateOpcode[e]=t},e.prototype.construct=function(e,t,n,r,i){return[0|e,0|(n||0),0|(r||0),0|(i||0)]},e.prototype.evaluate=function(e,n){t.LOGGER.debug("[VM] OPCODE: "+n.type) +var r=this.evaluateOpcode[n.type] +r(e,n)},e}(),Pe=new Ne,De=function(){function e(){t.initializeGuid(this)}return e.prototype.toJSON=function(){return{guid:this._guid,type:this.type}},e}(),Ie=function(e){function t(){e.apply(this,arguments),this.next=null,this.prev=null}return babelHelpers.inherits(t,e),t}(De) +Pe.add(20,function(e,t){var n=t.op1,r=t.op2,i=e.constants.getOther(n),o=e.constants.getExpression(r),s=null,a=i.evaluate(e) +a&&(s=o.evaluate(e)),e.pushCallerScope(),a&&e.invokeBlock(a,s||null)}),Pe.add(21,function(e){return e.popScope()}),Pe.add(0,function(e){return e.pushChildScope()}),Pe.add(1,function(e){return e.popScope()}),Pe.add(2,function(e){return e.pushDynamicScope()}),Pe.add(3,function(e){return e.popDynamicScope()}),Pe.add(4,function(e,t){var n=t.op1 +e.frame.setOperand(e.constants.getReference(n))}),Pe.add(5,function(e,t){var n=t.op1,r=e.constants.getExpression(n) +e.evaluateOperand(r)}),Pe.add(6,function(e,t){var n=t.op1 +e.evaluateArgs(e.constants.getExpression(n))}),Pe.add(7,function(e,t){var n=t.op1,r=e.constants.getArray(n) +e.bindPositionalArgs(r)}),Pe.add(8,function(e,t){var n=t.op1,r=t.op2,i=e.constants.getArray(n),o=e.constants.getArray(r) +e.bindNamedArgs(i,o)}),Pe.add(9,function(e,t){var n=t.op1,r=t.op2,i=e.constants.getArray(n),o=e.constants.getArray(r) +e.bindBlocks(i,o)}),Pe.add(10,function(e,t){var n=t.op1 +e.bindPartialArgs(n)}),Pe.add(11,function(e){return e.bindCallerScope()}),Pe.add(12,function(e,t){var n=t.op1,r=e.constants.getArray(n) +e.bindDynamicScope(r)}),Pe.add(13,function(e,t){var n=t.op1 +return e.enter(n)}),Pe.add(14,function(e){return e.exit()}),Pe.add(15,function(e,t){var n=t.op1,r=e.constants.getBlock(n),i=e.frame.getArgs() +e.invokeBlock(r,i)}),Pe.add(16,function(e,t){var n=t.op1 +return e.goto(n)}),Pe.add(17,function(e,t){var r=t.op1,i=e.frame.getCondition() +if(n.isConst(i))i.value()&&e.goto(r) +else{var o=new n.ReferenceCache(i) +o.peek()&&e.goto(r),e.updateWith(new Fe(o))}}),Pe.add(18,function(e,t){var r=t.op1,i=e.frame.getCondition() +if(n.isConst(i))i.value()||e.goto(r) +else{var o=new n.ReferenceCache(i) +o.peek()||e.goto(r),e.updateWith(new Fe(o))}}) +var je=function(e,t){return new n.ConstReference(!!e.value())},Le=function(e,t){return e},Me=function(e,t){return t.toConditionalReference(e)} +Pe.add(19,function(e,t){var n=t.op1,r=e.frame.getOperand(),i=e.constants.getFunction(n) +e.frame.setCondition(i(r,e.env))}) +var Fe=function(e){function t(t){e.call(this),this.type="assert",this.tag=t.tag,this.cache=t}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.cache +n.isModified(t.revalidate())&&e.throw()},t.prototype.toJSON=function(){var e=this.type,t=this._guid,n=this.cache,r=void 0 +try{r=JSON.stringify(n.peek())}catch(e){r=String(n.peek())}return{guid:t,type:e,args:[],details:{expected:r}}},t}(Ie),Ue=function(e){function t(t,n){e.call(this),this.target=n,this.type="jump-if-not-modified",this.tag=t,this.lastRevision=t.value()}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.tag,n=this.target,r=this.lastRevision +!e.alwaysRevalidate&&t.validate(r)&&e.goto(n)},t.prototype.didModify=function(){this.lastRevision=this.tag.value()},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.target.inspect())]}},t}(Ie),He=function(e){function t(t){e.call(this),this.target=t,this.type="did-modify",this.tag=n.CONSTANT_TAG}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(){this.target.didModify()},t}(Ie),ze=function(){function e(e){this.tag=n.CONSTANT_TAG,this.type="label",this.label=null,this.prev=null,this.next=null,t.initializeGuid(this),e&&(this.label=e)}return e.prototype.evaluate=function(){},e.prototype.inspect=function(){return this.label+" ["+this._guid+"]"},e.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.inspect())]}},e}(),Be=t.HAS_NATIVE_WEAKMAP?Object.freeze([]):[],qe=t.HAS_NATIVE_WEAKMAP?Object.freeze(t.dict()):t.dict(),Ve=function(){function e(e){this.values=e,this.length=e.length}return e.create=function(e){return e.length?new this(e):We},e.empty=function(){return We},e.prototype.evaluate=function(e){for(var t=this.values,n=this.length,r=new Array(n),i=0;i"},t}(Ve)),Ke=function(){function e(e){this.values=e,this.tag=n.combineTagged(e),this.length=e.length}return e.create=function(e){return new this(e)},e.empty=function(){return Ge},e.prototype.at=function(e){var t=this.values,n=this.length +return e0){for(var r=[],i=0;i"},t}(Qe)),Je=function(){function e(e,r){var i=arguments.length<=2||void 0===arguments[2]?null:arguments[2] +this.keys=e,this.values=r,this._map=i,this.tag=n.combineTagged(r),this.length=e.length,t.assert(e.length===r.length,"Keys and values do not have the same length")}return e.create=function(e){var t=Object.keys(e),n=t.length +if(n>0){for(var r=new Array(n),i=0;i element stack "+this.elementStack.toArray().map(function(e){return e.tagName}).join(", ")),this.element=t.expect(e.current,"can't pop past the last element"),this.nextSibling=n.current,r},e.prototype.pushSimpleBlock=function(){var e=new kt(this.element) +return this.pushBlockTracker(e),e},e.prototype.pushUpdatableBlock=function(){var e=new Rt(this.element) +return this.pushBlockTracker(e),e},e.prototype.pushBlockTracker=function(e){var t=!(arguments.length<=1||void 0===arguments[1])&&arguments[1],n=this.blockStack.current +return null!==n&&(n.newDestroyable(e),t||n.newBounds(e)),this.blockStack.push(e),e},e.prototype.pushBlockList=function(e){var t=new Nt(this.element,e),n=this.blockStack.current +return null!==n&&(n.newDestroyable(t),n.newBounds(t)),this.blockStack.push(t),t},e.prototype.popBlock=function(){return this.block().finalize(this),t.expect(this.blockStack.pop(),"Expected popBlock to return a block")},e.prototype.openElement=function(e){var t=arguments.length<=1||void 0===arguments[1]?this.defaultOperations:arguments[1],n=this.dom.createElement(e,this.element) +return this.constructing=n,this.operations=t,n},e.prototype.flushElement=function(){var e=this.element,n=t.expect(this.constructing,"flushElement should only be called when constructing an element") +this.dom.insertBefore(e,n,this.nextSibling),this.constructing=null,this.operations=null,this.pushElement(n),this.block().openElement(n)},e.prototype.pushRemoteElement=function(e){this.pushElement(e) +var t=new Tt(e) +this.pushBlockTracker(t,!0)},e.prototype.popRemoteElement=function(){this.popBlock(),this.popElement()},e.prototype.pushElement=function(e){this.element=e,this.elementStack.push(e),t.LOGGER.debug("-> element stack "+this.elementStack.toArray().map(function(e){return e.tagName}).join(", ")),this.nextSibling=null,this.nextSiblingStack.push(null)},e.prototype.newDestroyable=function(e){this.block().newDestroyable(e)},e.prototype.newBounds=function(e){this.block().newBounds(e)},e.prototype.appendText=function(e){var t=this.dom,n=t.createTextNode(e) +return t.insertBefore(this.element,n,this.nextSibling),this.block().newNode(n),n},e.prototype.appendComment=function(e){var t=this.dom,n=t.createComment(e) +return t.insertBefore(this.element,n,this.nextSibling),this.block().newNode(n),n},e.prototype.setStaticAttribute=function(e,t){this.expectOperations("setStaticAttribute").addStaticAttribute(this.expectConstructing("setStaticAttribute"),e,t)},e.prototype.setStaticAttributeNS=function(e,t,n){this.expectOperations("setStaticAttributeNS").addStaticAttributeNS(this.expectConstructing("setStaticAttributeNS"),e,t,n)},e.prototype.setDynamicAttribute=function(e,t,n){this.expectOperations("setDynamicAttribute").addDynamicAttribute(this.expectConstructing("setDynamicAttribute"),e,t,n)},e.prototype.setDynamicAttributeNS=function(e,t,n,r){this.expectOperations("setDynamicAttributeNS").addDynamicAttributeNS(this.expectConstructing("setDynamicAttributeNS"),e,t,n,r)},e.prototype.closeElement=function(){this.block().closeElement(),this.popElement()},e}(),kt=function(){function e(e){this.parent=e,this.first=null,this.last=null,this.destroyables=null,this.nesting=0}return e.prototype.destroy=function(){var e=this.destroyables +if(e&&e.length)for(var t=0;t0?e.join(""):null},t}(n.CachedReference),Vt=function(e){function t(t,n){e.call(this),this.func=t,this.symbolTable=n,this.type="function",this.func=t}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.func,n=this.symbolTable +return t(e,n)},t.prototype.toJSON=function(){var e=this.func +return e.name?"`"+e.name+"(...)`":"`func(...)`"},t}(mt),Wt=v,Kt=function(){function e(){this.names=t.dict(),this.funcs=[]}return e.prototype.add=function(e,t){this.funcs.push(t),this.names[e]=this.funcs.length-1},e.prototype.compile=function(e,n){var r=e[0],i=this.names[r],o=this.funcs[i] +return t.assert(!!o,"expected an implementation for "+e[0]),o(e,n)},e}(),Gt=new Kt +Gt.add("text",function(e,t){t.text(e[1])}),Gt.add("comment",function(e,t){t.comment(e[1])}),Gt.add("close-element",function(e,n){t.LOGGER.trace("close-element statement"),n.closeElement()}),Gt.add("flush-element",function(e,t){t.flushElement()}),Gt.add("modifier",function(e,t){var n=e[1],r=e[2],i=e[3],o=w(r,i,t) +if(!t.env.hasModifier(n,t.symbolTable))throw new Error("Compile Error "+n.join(".")+" is not a modifier: Helpers may not be used in the element form.") +t.modifier(n[0],o)}),Gt.add("static-attr",function(e,t){var n=e[1],r=e[2],i=e[3] +t.staticAttr(n,i,r)}),Gt.add("any-dynamic-attr",function(e,t){var n=e[1],r=e[2],i=e[3],o=e[4] +t.putValue(r),i?t.dynamicAttrNS(n,i,o):t.dynamicAttr(n,o)}),Gt.add("open-element",function(e,n){t.LOGGER.trace("open-element statement"),n.openPrimitiveElement(e[1])}),Gt.add("optimized-append",function(e,t){var n=e[1],r=e[2],i=t.env.macros(),o=i.inlines,s=o.compile(e,t)||n +s!==!0&&(t.putValue(s[1]),r?t.trustingAppend():t.cautiousAppend())}),Gt.add("unoptimized-append",function(e,t){var n=e[1],r=e[2],i=t.env.macros(),o=i.inlines,s=o.compile(e,t)||n +s!==!0&&(r?t.guardedTrustingAppend(s[1]):t.guardedCautiousAppend(s[1]))}),Gt.add("nested-block",function(e,t){var n=t.env.macros(),r=n.blocks +r.compile(e,t)}),Gt.add("scanned-block",function(e,t){var n=e[1],r=e[2],i=e[3],o=e[4],s=e[5],a=o&&o.scan(),u=s&&s.scan(),l=t.env.macros(),c=l.blocks +c.compile(["nested-block",n,r,i,a,u],t)}),Gt.add("scanned-component",function(e,t){var n=e[1],r=e[2],i=e[3],o=e[4],s=o&&o.scan(),a=E(null,i,{default:s,inverse:null},t),u=t.env.getComponentDefinition([n],t.symbolTable) +t.putComponentDefinition(u),t.openComponent(a,r.scan()),t.closeComponent()}),Gt.add("static-partial",function(e,t){var n=e[1] +if(!t.env.hasPartial(n,t.symbolTable))throw new Error('Compile Error: Could not find a partial named "'+n+'"') +var r=t.env.lookupPartial(n,t.symbolTable) +t.putPartialDefinition(r),t.evaluatePartial()}),Gt.add("dynamic-partial",function(e,t){var n=e[1] +t.startLabels(),t.putValue(n),t.test("simple"),t.enter("BEGIN","END"),t.label("BEGIN"),t.jumpUnless("END"),t.putDynamicPartialDefinition(),t.evaluatePartial(),t.label("END"),t.exit(),t.stopLabels()}),Gt.add("yield",function(e,t){var n=e[1],r=e[2],i=w(r,null,t) +t.yield(i,n)}),Gt.add("debugger",function(e,t){return t.putValue(["function",function(e){var n=e.getSelf().value(),r=function(n){return g(e,t)(n).value()} +Wt(n,r)}]),e}) +var Qt=new Kt +Qt.add("unknown",function(e,t){var n=e[1] +return t.env.hasHelper(n,t.symbolTable)?new zt(n,t.env.lookupHelper(n,t.symbolTable),Ze.empty(),t.symbolTable):A(n,t)}),Qt.add("concat",function(e,t){var n=e[1].map(function(e){return _(e,t)}) +return new Bt(n)}),Qt.add("function",function(e,t){return new Vt(e[1],t.symbolTable)}),Qt.add("helper",function(e,t){var n=t.env,r=t.symbolTable,i=e[1],o=e[2],s=e[3] +if(n.hasHelper(i,r)){var a=w(o,s,t) +return new zt(i,n.lookupHelper(i,r),a,r)}throw new Error("Compile Error: "+i.join(".")+" is not a helper")}),Qt.add("get",function(e,t){return A(e[1],t)}),Qt.add("undefined",function(e,t){return new Pt(void 0)}),Qt.add("arg",function(e,t){var n=e[1],r=n[0],i=void 0,o=void 0 +if(i=t.symbolTable.getSymbol("named",r)){var s=n.slice(1),a=new Ut(i,r) +return Mt.create(a,s)}if(o=t.symbolTable.getPartialArgs()){var s=n.slice(1),a=new Ht(o,r) +return Mt.create(a,s)}throw new Error("[BUG] @"+n.join(".")+" is not a valid lookup path.")}),Qt.add("has-block",function(e,t){var n=e[1],r=void 0,i=void 0 +if(r=t.symbolTable.getSymbol("yields",n)){var o=new jt(r,n) +return new Dt(o)}if(i=t.symbolTable.getPartialArgs()){var o=new Lt(i,n) +return new Dt(o)}throw new Error("[BUG] ${blockName} is not a valid block name.")}),Qt.add("has-block-params",function(e,t){var n=e[1],r=void 0,i=void 0 +if(r=t.symbolTable.getSymbol("yields",n)){var o=new jt(r,n) +return new It(o)}if(i=t.symbolTable.getPartialArgs()){var o=new Lt(i,n) +return new It(o)}throw new Error("[BUG] ${blockName} is not a valid block name.")}) +var Yt=function(){function e(){this.names=t.dict(),this.funcs=[]}return e.prototype.add=function(e,t){this.funcs.push(t),this.names[e]=this.funcs.length-1},e.prototype.addMissing=function(e){this.missing=e},e.prototype.compile=function(e,n){var r=e[1][0],i=this.names[r] +if(void 0===i){t.assert(!!this.missing,r+" not found, and no catch-all block handler was registered") +var o=this.missing,s=o(e,n) +t.assert(!!s,r+" not found, and the catch-all block handler didn't handle it")}else{var o=this.funcs[i] +o(e,n)}},e}(),Jt=new Yt,$t=function(){function e(){this.names=t.dict(),this.funcs=[]}return e.prototype.add=function(e,t){this.funcs.push(t),this.names[e]=this.funcs.length-1},e.prototype.addMissing=function(e){this.missing=e},e.prototype.compile=function(e,t){var n=e[1] +if(!Array.isArray(n))return["expr",n] +var r=void 0,i=void 0,o=void 0 +if("helper"===n[0])r=n[1],i=n[2],o=n[3] +else{if("unknown"!==n[0])return["expr",n] +r=n[1],i=o=null}if(r.length>1&&!i&&!o)return["expr",n] +var s=r[0],a=this.names[s] +if(void 0===a&&this.missing){var u=this.missing,l=u(r,i,o,t) +return l===!1?["expr",n]:l}if(void 0!==a){var u=this.funcs[a],l=u(r,i,o,t) +return l===!1?["expr",n]:l}return["expr",n]},e}(),Xt=new $t +S(Jt,Xt) +var Zt=["javascript:","vbscript:"],en=["A","BODY","LINK","IMG","IFRAME","BASE","FORM"],tn=["EMBED"],nn=["href","src","background","action"],rn=["src"],on={BUTTON:{type:!0,form:!0},INPUT:{type:!0,form:!0,autocorrect:!0,list:!0},SELECT:{form:!0},OPTION:{form:!0},TEXTAREA:{form:!0},LABEL:{form:!0},FIELDSET:{form:!0},LEGEND:{form:!0},OBJECT:{form:!0}},sn={colgroup:{depth:2,before:"",after:"
    "},table:{depth:1,before:"",after:"
    "},tbody:{depth:2,before:"",after:"
    "},tfoot:{depth:2,before:"",after:"
    "},thead:{depth:2,before:"",after:"
    "},tr:{depth:3,before:"",after:"
    "}},an="http://www.w3.org/2000/svg",un="http://www.w3.org/2000/svg",ln={foreignObject:1,desc:1,title:1},cn=Object.create(null);["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach(function(e){return cn[e]=1}) +var pn,hn=/[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/,fn="undefined"==typeof document?null:document;(function(e){var t=function(){function e(e){this.document=e,this.setupUselessElement()}return e.prototype.setupUselessElement=function(){this.uselessElement=this.document.createElement("div")},e.prototype.createElement=function(e,t){var n=void 0,r=void 0 +if(t?(n=t.namespaceURI===un||"svg"===e,r=ln[t.tagName]):(n="svg"===e,r=!1),n&&!r){if(cn[e])throw new Error("Cannot create a "+e+" inside an SVG context") +return this.document.createElementNS(un,e)}return this.document.createElement(e)},e.prototype.createElementNS=function(e,t){return this.document.createElementNS(e,t)},e.prototype.setAttribute=function(e,t,n,r){r?e.setAttributeNS(r,t,n):e.setAttribute(t,n)},e.prototype.createTextNode=function(e){return this.document.createTextNode(e)},e.prototype.createComment=function(e){return this.document.createComment(e)},e.prototype.insertBefore=function(e,t,n){e.insertBefore(t,n)},e.prototype.insertHTMLBefore=function(e,t,n){return Q(this.uselessElement,e,n,t)},e}() +e.TreeConstruction=t +var n=t +n=V(fn,n),n=L(fn,n),n=H(fn,n,un),e.DOMTreeConstruction=n})(pn||(pn={})) +var dn=function(){function e(e){this.document=e,this.namespace=null,this.uselessElement=this.document.createElement("div")}return e.prototype.setAttribute=function(e,t,n){e.setAttribute(t,n)},e.prototype.setAttributeNS=function(e,t,n,r){e.setAttributeNS(t,n,r)},e.prototype.removeAttribute=function(e,t){e.removeAttribute(t)},e.prototype.removeAttributeNS=function(e,t,n){e.removeAttributeNS(t,n)},e.prototype.createTextNode=function(e){return this.document.createTextNode(e)},e.prototype.createComment=function(e){return this.document.createComment(e)},e.prototype.createElement=function(e,t){var n=void 0,r=void 0 +if(t?(n=t.namespaceURI===un||"svg"===e,r=ln[t.tagName]):(n="svg"===e,r=!1),n&&!r){if(cn[e])throw new Error("Cannot create a "+e+" inside an SVG context") +return this.document.createElementNS(un,e)}return this.document.createElement(e)},e.prototype.insertHTMLBefore=function(e,t,n){return Q(this.uselessElement,e,t,n)},e.prototype.insertNodeBefore=function(e,t,n){if(Y(t)){var r=t.firstChild,i=t.lastChild +return this.insertBefore(e,t,n),new st(e,r,i)}return this.insertBefore(e,t,n),new at(e,t)},e.prototype.insertTextBefore=function(e,t,n){var r=this.createTextNode(n) +return this.insertBefore(e,r,t),r},e.prototype.insertBefore=function(e,t,n){e.insertBefore(t,n)},e.prototype.insertAfter=function(e,t,n){this.insertBefore(e,t,n.nextSibling)},e}(),mn=dn +mn=q(fn,mn),mn=j(fn,mn),mn=U(fn,mn,un) +var vn=mn,gn=pn.DOMTreeConstruction,yn=function(){function e(e){this.attr=e}return e.prototype.setAttribute=function(e,t,n,r){var i=e.getAppendOperations(),o=ee(n) +te(o)||i.setAttribute(t,this.attr,o,r)},e.prototype.updateAttribute=function(e,t,n,r){null===n||void 0===n||n===!1?r?e.getDOM().removeAttributeNS(t,r,this.attr):e.getDOM().removeAttribute(t,this.attr):this.setAttribute(e,t,n)},e}(),bn=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.setAttribute=function(e,t,n,r){te(n)||(t[this.attr]=n)},t.prototype.removeAttribute=function(e,t,n){var r=this.attr +n?e.getDOM().removeAttributeNS(t,n,r):e.getDOM().removeAttribute(t,r)},t.prototype.updateAttribute=function(e,t,n,r){t[this.attr]=n,te(n)&&this.removeAttribute(e,t,r)},t}(yn),_n=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.setAttribute=function(t,n,r){e.prototype.setAttribute.call(this,t,n,P(t,n,this.attr,r))},t.prototype.updateAttribute=function(t,n,r){e.prototype.updateAttribute.call(this,t,n,P(t,n,this.attr,r))},t}(bn),wn=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.setAttribute=function(e,t,n){var r=t +r.value=ve(n)},t.prototype.updateAttribute=function(e,t,n){var r=t,i=r.value,o=ve(n) +i!==o&&(r.value=o)},t}(yn),En=new wn("value"),xn=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.setAttribute=function(e,t,n){if(null!==n&&void 0!==n&&n!==!1){var r=t +r.selected=!0}},t.prototype.updateAttribute=function(e,t,n){var r=t +n?r.selected=!0:r.selected=!1},t}(bn),Cn=new xn("selected"),On=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.setAttribute=function(t,n,r){e.prototype.setAttribute.call(this,t,n,P(t,n,this.attr,r))},t.prototype.updateAttribute=function(t,n,r,i){e.prototype.updateAttribute.call(this,t,n,P(t,n,this.attr,r))},t}(yn),An=function(){function e(e){var t=arguments.length<=1||void 0===arguments[1]?null:arguments[1] +this.callerScope=null,this.slots=e,this.callerScope=t}return e.root=function(t){for(var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1],r=new Array(n+1),i=0;i<=n;i++)r[i]=Oe +return new e(r).init({self:t})},e.prototype.init=function(e){var t=e.self +return this.slots[0]=t,this},e.prototype.getSelf=function(){return this.slots[0]},e.prototype.getSymbol=function(e){return this.slots[e]},e.prototype.getBlock=function(e){return this.slots[e]},e.prototype.getPartialArgs=function(e){return this.slots[e]},e.prototype.bindSymbol=function(e,t){this.slots[e]=t},e.prototype.bindBlock=function(e,t){this.slots[e]=t},e.prototype.bindPartialArgs=function(e,t){this.slots[e]=t},e.prototype.bindCallerScope=function(e){this.callerScope=e},e.prototype.getCallerScope=function(){return this.callerScope},e.prototype.child=function(){return new e(this.slots.slice(),this.callerScope)},e}(),Sn=function(){function e(){this.scheduledInstallManagers=[],this.scheduledInstallModifiers=[],this.scheduledUpdateModifierManagers=[],this.scheduledUpdateModifiers=[],this.createdComponents=[],this.createdManagers=[],this.updatedComponents=[],this.updatedManagers=[],this.destructors=[]}return e.prototype.didCreate=function(e,t){this.createdComponents.push(e),this.createdManagers.push(t)},e.prototype.didUpdate=function(e,t){this.updatedComponents.push(e),this.updatedManagers.push(t)},e.prototype.scheduleInstallModifier=function(e,t){this.scheduledInstallManagers.push(t),this.scheduledInstallModifiers.push(e)},e.prototype.scheduleUpdateModifier=function(e,t){this.scheduledUpdateModifierManagers.push(t),this.scheduledUpdateModifiers.push(e)},e.prototype.didDestroy=function(e){this.destructors.push(e)},e.prototype.commit=function(){for(var e=this.createdComponents,t=this.createdManagers,n=0;n=t[n]?i=n+2:o=n +return e>=t[i]?i+2:i}function a(e,t,n){this.name=e,this.globalOptions=n||{},this.options=t,this._queue=[],this.targetQueues={},this._queueBeingFlushed=void 0}function u(e,n){var r=this.queues={} +this.queueNames=e=e||[],this.options=n,t(e,function(e){r[e]=new a(e,n[e],n)})}function l(e){throw new Error("You attempted to schedule an action in a queue ("+e+") that doesn't exist")}function c(e){throw new Error("You attempted to schedule an action in a queue ("+e+") for a method that doesn't exist")}function p(e,t){this.queueNames=e,this.options=t||{},this.options.defaultQueue||(this.options.defaultQueue=e[0]),this.instanceStack=[],this._debouncees=[],this._throttlers=[],this._eventCallbacks={end:[],begin:[]} +var n=this +this._boundClearItems=function(){g()},this._timerTimeoutId=void 0,this._timers=[],this._platform=this.options._platform||{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){clearTimeout(e)}},this._boundRunExpiredTimers=function(){n._runExpiredTimers()}}function h(e){return e.onError||e.onErrorTarget&&e.onErrorTarget[e.onErrorMethod]}function f(e){var t=e._platform.setTimeout +e.begin(),e._autorun=t(function(){e._autorun=null,e.end()},0)}function d(e,t,n){return v(e,t,n)}function m(e,t,n){return v(e,t,n)}function v(e,t,n){for(var r,i=-1,o=0,s=n.length;o0?t.apply(e,n):t.call(e)},invokeWithOnError:function(e,t,n,r,i){try{n&&n.length>0?t.apply(e,n):t.call(e)}catch(e){r(e,i)}},flush:function(e){var t=this._queue,r=t.length +if(0!==r){var i,o,s,a,u=this.globalOptions,l=this.options,c=l&&l.before,p=l&&l.after,h=u.onError||u.onErrorTarget&&u.onErrorTarget[u.onErrorMethod],f=h?this.invokeWithOnError:this.invoke +this.targetQueues=Object.create(null) +var d=this._queueBeingFlushed=this._queue.slice() +this._queue=[],c&&c() +for(var m=0;m0&&this.flush(!0)}},cancel:function(e){var t,n,r,i,o=this._queue,s=e.target,a=e.method,u=this.globalOptions.GUID_KEY +if(u&&this.targetQueues&&s){var l=this.targetQueues[s[u]] +if(l)for(r=0,i=l.length;r2){r=new Array(i-2) +for(var o=0,s=i-2;o3){i=new Array(o-3) +for(var a=3;a3){i=new Array(o-3) +for(var a=3;a-1?this._throttlers[l]:(c=this._platform.setTimeout(function(){p||r.run.apply(r,o) +var n=m(e,t,r._throttlers) +n>-1&&r._throttlers.splice(n,1)},a),p&&this.run.apply(this,o),u=[e,t,c],this._throttlers.push(u),u)},debounce:function(e,t){for(var r=this,o=new Array(arguments.length),s=0;s-1&&(l=this._debouncees[u],this._debouncees.splice(u,1),this._platform.clearTimeout(l[2])),c=this._platform.setTimeout(function(){p||r.run.apply(r,o) +var n=d(e,t,r._debouncees) +n>-1&&r._debouncees.splice(n,1)},a),p&&u===-1&&r.run.apply(r,o),l=[e,t,c],r._debouncees.push(l),l},cancelTimers:function(){t(this._throttlers,this._boundClearItems),this._throttlers=[],t(this._debouncees,this._boundClearItems),this._debouncees=[],this._clearTimerTimeout(),this._timers=[],this._autorun&&(this._platform.clearTimeout(this._autorun),this._autorun=null)},hasTimers:function(){return!!this._timers.length||!!this._debouncees.length||!!this._throttlers.length||this._autorun},cancel:function(e){var t=typeof e +if(e&&"object"===t&&e.queue&&e.method)return e.queue.cancel(e) +if("function"!==t)return"[object Array]"===Object.prototype.toString.call(e)?this._cancelItem(m,this._throttlers,e)||this._cancelItem(d,this._debouncees,e):void 0 +for(var n=0,r=this._timers.length;n-1&&(r=t[i],r[2]===n[2])&&(t.splice(i,1),this._platform.clearTimeout(n[2]),!0))},_runExpiredTimers:function(){this._timerTimeoutId=void 0,this.run(this,this._scheduleExpiredTimers)},_scheduleExpiredTimers:function(){for(var e=Date.now(),t=this._timers,n=0,r=t.length;n1){for(var t=arguments[0],n=[],r=void 0,i=1;i0?x(this,this.registry.normalize(e)):E(this)},A.ownerInjection=function(){var e +return e={},e[t.OWNER]=this.owner,e},A),i.prototype.factoryFor=function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=this.registry.normalize(e) +if(!t.source||(n=this.registry.expandLocalLookup(e,t))){var r=this.registry.resolve(n) +if(void 0!==r){var i=new N(this,r,e,n) +return i}}} +var R=function(){function e(e,t,n){this.container=e,this.class=t,this.fullName=n}return e.prototype.create=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0] +return y(this.class,e,this.container,this.fullName)},e}(),N=function(){function e(e,t,n,r){this.container=e,this.class=t,this.fullName=n,this.normalizedName=r}return e.prototype.create=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=g(this.container,this.normalizedName),r=t.assign({},n,e) +if(r[t.NAME_KEY]=this.container.registry.makeToString(this.class,this.fullName),!this.class.create)throw new Error("Failed to create an instance of '"+this.normalizedName+"'. Most likely an improperly defined class or an invalid module export.") +return this.class.prototype&&_(this.class.prototype,this.container),this.class.create(r)},e}()}),s("container/index",["exports","container/registry","container/container"],function(e,t,n){"use strict" +e.Registry=t.default,e.privatize=t.privatize,e.Container=n.default,e.buildFakeContainerWithDeprecations=n.buildFakeContainerWithDeprecations,e.FACTORY_FOR=n.FACTORY_FOR,e.LOOKUP_FACTORY=n.LOOKUP_FACTORY}),s("container/registry",["exports","ember-utils","ember-metal","container/container"],function(e,t,n,r){"use strict" +function i(e){this.fallback=e&&e.fallback?e.fallback:null,e&&e.resolver&&(this.resolver=e.resolver,"function"==typeof this.resolver&&o(this)),this.registrations=t.dictionary(e&&e.registrations?e.registrations:null),this._typeInjections=t.dictionary(null),this._injections=t.dictionary(null),this._factoryTypeInjections=t.dictionary(null),this._factoryInjections=t.dictionary(null),this._localLookupCache=new t.EmptyObject,this._normalizeCache=t.dictionary(null),this._resolveCache=t.dictionary(null),this._failCache=t.dictionary(null),this._options=t.dictionary(null),this._typeOptions=t.dictionary(null)}function o(e){e.resolver={resolve:e.resolver}}function s(e,n,r){var i=e._localLookupCache,o=i[n] +o||(o=i[n]=new t.EmptyObject) +var s=o[r] +if(void 0!==s)return s +var a=e.resolver.expandLocalLookup(n,r) +return o[r]=a}function a(e,t,n){if(!n||!n.source||(t=e.expandLocalLookup(t,n))){var r=e._resolveCache[t] +if(void 0!==r)return r +if(!e._failCache[t]){var i=void 0 +return e.resolver&&(i=e.resolver.resolve(t)),void 0===i&&(i=e.registrations[t]),void 0===i?e._failCache[t]=!0:e._resolveCache[t]=i,i}}}function u(e,t,n){return void 0!==e.resolve(t,{source:n})}function l(e){var n=e[0],r=p[n] +if(r)return r +var i=n.split(":"),o=i[0],s=i[1] +return p[n]=t.intern(o+":"+s+"-"+h)}e.default=i,e.privatize=l +var c=/^[^:]+:[^:]+$/ +i.prototype={fallback:null,resolver:null,registrations:null,_typeInjections:null,_injections:null,_factoryTypeInjections:null,_factoryInjections:null,_normalizeCache:null,_resolveCache:null,_options:null,_typeOptions:null,container:function(e){return new r.default(this,e)},register:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2] +if(void 0===t)throw new TypeError("Attempting to register an unknown factory: '"+e+"'") +var r=this.normalize(e) +if(this._resolveCache[r])throw new Error("Cannot re-register: '"+e+"', as it has already been resolved.") +delete this._failCache[r],this.registrations[r]=t,this._options[r]=n},unregister:function(e){var n=this.normalize(e) +this._localLookupCache=new t.EmptyObject,delete this.registrations[n],delete this._resolveCache[n],delete this._failCache[n],delete this._options[n]},resolve:function(e,t){var n=a(this,this.normalize(e),t) +if(void 0===n&&this.fallback){var r +n=(r=this.fallback).resolve.apply(r,arguments)}return n},describe:function(e){return this.resolver&&this.resolver.lookupDescription?this.resolver.lookupDescription(e):this.fallback?this.fallback.describe(e):e},normalizeFullName:function(e){return this.resolver&&this.resolver.normalize?this.resolver.normalize(e):this.fallback?this.fallback.normalizeFullName(e):e},normalize:function(e){return this._normalizeCache[e]||(this._normalizeCache[e]=this.normalizeFullName(e))},makeToString:function(e,t){return this.resolver&&this.resolver.makeToString?this.resolver.makeToString(e,t):this.fallback?this.fallback.makeToString(e,t):e.toString()},has:function(e,t){if(!this.isValidFullName(e))return!1 +var n=t&&t.source&&this.normalize(t.source) +return u(this,this.normalize(e),n)},optionsForType:function(e,t){this._typeOptions[e]=t},getOptionsForType:function(e){var t=this._typeOptions[e] +return void 0===t&&this.fallback&&(t=this.fallback.getOptionsForType(e)),t},options:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=this.normalize(e) +this._options[n]=t},getOptions:function(e){var t=this.normalize(e),n=this._options[t] +return void 0===n&&this.fallback&&(n=this.fallback.getOptions(e)),n},getOption:function(e,t){var n=this._options[e] +if(n&&void 0!==n[t])return n[t] +var r=e.split(":")[0] +return n=this._typeOptions[r],n&&void 0!==n[t]?n[t]:this.fallback?this.fallback.getOption(e,t):void 0},typeInjection:function(e,t,n){var r=n.split(":")[0] +if(r===e)throw new Error("Cannot inject a '"+n+"' on other "+e+"(s).") +var i=this._typeInjections[e]||(this._typeInjections[e]=[]) +i.push({property:t,fullName:n})},injection:function(e,t,n){this.validateFullName(n) +var r=this.normalize(n) +if(e.indexOf(":")===-1)return this.typeInjection(e,t,r) +var i=this.normalize(e),o=this._injections[i]||(this._injections[i]=[]) +o.push({property:t,fullName:r})},factoryTypeInjection:function(e,t,n){var r=this._factoryTypeInjections[e]||(this._factoryTypeInjections[e]=[]) +r.push({property:t,fullName:this.normalize(n)})},factoryInjection:function(e,t,n){var r=this.normalize(e),i=this.normalize(n) +if(this.validateFullName(n),e.indexOf(":")===-1)return this.factoryTypeInjection(r,t,i) +var o=this._factoryInjections[r]||(this._factoryInjections[r]=[]) +o.push({property:t,fullName:i})},knownForType:function(e){for(var n=void 0,r=void 0,i=t.dictionary(null),o=Object.keys(this.registrations),s=0;s0){var s="cycle detected: "+t +throw this.each(function(e){s+=" <- "+e}),new Error(s)}}},e.prototype.each=function(e){for(var t=this,n=t.result,r=t.vertices,i=0;i-1&&(i=i.replace(/\.(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("_")>-1&&(i=i.replace(/_(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("-")>-1&&(i=i.replace(/-(.)/g,function(e){return e.charAt(1).toUpperCase()})),n+":"+i}return e},resolve:function(e){var t=this.parseName(e),n=t.resolveMethodName,r=void 0 +return this[n]&&(r=this[n](t)),r=r||this.resolveOther(t),r&&i.default(r,t),r},parseName:function(e){return this._parseNameCache[e]||(this._parseNameCache[e]=this._parseName(e))},_parseName:function(e){var t=e.split(":"),i=t[0],o=t[1],s=o,a=n.get(this,"namespace"),u=a,l=s.lastIndexOf("/"),c=l!==-1?s.slice(0,l):null +if("template"!==i&&l!==-1){var p=s.split("/") +s=p[p.length-1] +var h=r.String.capitalize(p.slice(0,-1).join(".")) +u=r.Namespace.byName(h)}var f="main"===o?"Main":r.String.classify(i) +if(!s||!i)throw new TypeError("Invalid fullName: `"+e+"`, must be of the form `type:name` ") +return{fullName:e,type:i,fullNameWithoutType:o,dirname:c,name:s,root:u,resolveMethodName:"resolve"+f}},lookupDescription:function(e){var t=this.parseName(e),n=void 0 +return"template"===t.type?"template at "+t.fullNameWithoutType.replace(/\./g,"/"):(n=t.root+"."+r.String.classify(t.name).replace(/\./g,""),"model"!==t.type&&(n+=r.String.classify(t.type)),n)},makeToString:function(e,t){return e.toString()},useRouterNaming:function(e){e.name=e.name.replace(/\./g,"_"),"basic"===e.name&&(e.name="")},resolveTemplate:function(e){var t=e.fullNameWithoutType.replace(/\./g,"/") +return o.getTemplate(t)||o.getTemplate(r.String.decamelize(t))},resolveView:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveController:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveRoute:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveModel:function(e){var t=r.String.classify(e.name),i=n.get(e.root,t) +return i},resolveHelper:function(e){return this.resolveOther(e)},resolveOther:function(e){var t=r.String.classify(e.name)+r.String.classify(e.type),i=n.get(e.root,t) +return i},resolveMain:function(e){var t=r.String.classify(e.type) +return n.get(e.root,t)},_logLookup:function(e,t){var n=void 0,r=void 0 +n=e?"[✓]":"[ ]",r=t.fullName.length>60?".":new Array(60-t.fullName.length).join(".")},knownForType:function(e){for(var i=n.get(this,"namespace"),o=r.String.classify(e),s=new RegExp(o+"$"),a=t.dictionary(null),u=Object.keys(i),l=0;l1?this.set("models",this._getModels(t)):this.set("models",[])}}) +a.toString=function(){return"LinkComponent"},a.reopenClass({positionalParams:"params"}),e.default=a}) +s("ember-glimmer/components/text_area",["exports","ember-glimmer/component","ember-views","ember-glimmer/templates/empty"],function(e,t,n,r){"use strict" +e.default=t.default.extend(n.TextSupport,{classNames:["ember-text-area"],layout:r.default,tagName:"textarea",attributeBindings:["rows","cols","name","selectionEnd","selectionStart","wrap","lang","dir","value"],rows:null,cols:null})}),s("ember-glimmer/components/text_field",["exports","ember-utils","ember-metal","ember-environment","ember-glimmer/component","ember-glimmer/templates/empty","ember-views"],function(e,t,n,r,i,o,s){"use strict" +function a(e){if(e in l)return l[e] +if(!r.environment.hasDOM)return l[e]=e,e +u||(u=document.createElement("input")) +try{u.type=e}catch(e){}return l[e]=u.type===e}var u=void 0,l=new t.EmptyObject +e.default=i.default.extend(s.TextSupport,{layout:o.default,classNames:["ember-text-field"],tagName:"input",attributeBindings:["accept","autocomplete","autosave","dir","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","lang","list","max","min","multiple","name","pattern","size","step","type","value","width"],value:"",type:n.computed({get:function(){return"text"},set:function(e,t){var n="text" +return a(t)&&(n=t),n}}),size:null,pattern:null,min:null,max:null})}),s("ember-glimmer/dom",["exports","@glimmer/runtime","@glimmer/node"],function(e,t,n){"use strict" +e.DOMChanges=t.DOMChanges,e.DOMTreeConstruction=t.DOMTreeConstruction,e.NodeDOMTreeConstruction=n.NodeDOMTreeConstruction}),s("ember-glimmer/environment",["exports","ember-utils","ember-metal","ember-views","@glimmer/runtime","ember-glimmer/syntax/curly-component","ember-glimmer/syntax","ember-glimmer/utils/iterable","ember-glimmer/utils/references","ember-glimmer/utils/debug-stack","ember-glimmer/helpers/if-unless","ember-glimmer/helpers/action","ember-glimmer/helpers/component","ember-glimmer/helpers/concat","ember-glimmer/helpers/get","ember-glimmer/helpers/hash","ember-glimmer/helpers/loc","ember-glimmer/helpers/log","ember-glimmer/helpers/mut","ember-glimmer/helpers/readonly","ember-glimmer/helpers/unbound","ember-glimmer/helpers/-class","ember-glimmer/helpers/-input-type","ember-glimmer/helpers/query-param","ember-glimmer/helpers/each-in","ember-glimmer/helpers/-normalize-class","ember-glimmer/helpers/-html-safe","ember-glimmer/protocol-for-url","container","ember-glimmer/modifiers/action"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,d,m,v,g,y,b,_,w,E,x,C,O,A,S,k,T){"use strict" +var R=function(e){function l(s){var a=this,u=s[t.OWNER] +e.apply(this,arguments),this.owner=u,this.isInteractive=u.lookup("-environment:main").isInteractive,this.destroyedComponents=void 0,S.default(this),this._definitionCache=new n.Cache(2e3,function(e){var t=e.name,n=e.source,i=e.owner,s=r.lookupComponent(i,t,{source:n}),a=s.component,u=s.layout +if(a||u)return new o.CurlyComponentDefinition(t,a,u)},function(e){var n=e.name,r=e.source,i=e.owner,o=r&&i._resolveLocalLookupName(n,r)||n,s=t.guidFor(i) +return s+"|"+o}),this._templateCache=new n.Cache(1e3,function(e){var n=e.Template,r=e.owner +if(n.create){var i +return n.create((i={env:a},i[t.OWNER]=r,i))}return n},function(e){var n=e.Template,r=e.owner +return t.guidFor(r)+"|"+n.id}),this._compilerCache=new n.Cache(10,function(e){return new n.Cache(2e3,function(t){var n=new e(t) +return i.compileLayout(n,a)},function(e){var n=e.meta.owner +return t.guidFor(n)+"|"+e.id})},function(e){return e.id}),this.builtInModifiers={action:new T.default},this.builtInHelpers={if:c.inlineIf,action:p.default,component:h.default,concat:f.default,get:d.default,hash:m.default,loc:v.default,log:g.default,mut:y.default,"query-params":x.default,readonly:b.default,unbound:_.default,unless:c.inlineUnless,"-class":w.default,"-each-in":C.default,"-input-type":E.default,"-normalize-class":O.default,"-html-safe":A.default,"-get-dynamic-var":i.getDynamicVar}}return babelHelpers.inherits(l,e),l.create=function(e){return new l(e)},l.prototype.macros=function t(){var t=e.prototype.macros.call(this) +return s.populateMacros(t.blocks,t.inlines),t},l.prototype.hasComponentDefinition=function(){return!1},l.prototype.getComponentDefinition=function(e,t){var n=e[0],r=t.getMeta(),i=r.owner,o=r.moduleName&&"template:"+r.moduleName +return this._definitionCache.get({name:n,source:o,owner:i})},l.prototype.getTemplate=function(e,t){return this._templateCache.get({Template:e,owner:t})},l.prototype.getCompiledBlock=function(e,t){var n=this._compilerCache.get(e) +return n.get(t)},l.prototype.hasPartial=function(e,t){var n=t.getMeta(),i=n.owner +return r.hasPartial(e,i)},l.prototype.lookupPartial=function(e,t){var n=t.getMeta(),i=n.owner,o={template:r.lookupPartial(e,i)} +if(o.template)return o +throw new Error(e+" is not a partial")},l.prototype.hasHelper=function(e,t){if(e.length>1)return!1 +var n=e[0] +if(this.builtInHelpers[n])return!0 +var r=t.getMeta(),i=r.owner,o={source:"template:"+r.moduleName} +return i.hasRegistration("helper:"+n,o)||i.hasRegistration("helper:"+n)},l.prototype.lookupHelper=function(e,t){var r=e[0],i=this.builtInHelpers[r] +if(i)return i +var o=t.getMeta(),s=o.owner,a=o.moduleName&&{source:"template:"+o.moduleName}||{},l=function(){var t=s[k.FACTORY_FOR]("helper:"+r,a)||s[k.FACTORY_FOR]("helper:"+r) +if(t.class.isHelperInstance)return{v:function(e,n){return u.SimpleHelperReference.create(t.class.compute,n)}} +if(t.class.isHelperFactory)return n.isFeatureEnabled("ember-no-double-extend")||(t=t.create()),{v:function(e,n){return u.ClassBasedHelperReference.create(t,e,n)}} +throw new Error(e+" is not a helper")}() +return"object"==typeof l?l.v:void 0},l.prototype.hasModifier=function(e){return!(e.length>1)&&!!this.builtInModifiers[e[0]]},l.prototype.lookupModifier=function(e){var t=this.builtInModifiers[e[0]] +if(t)return t +throw new Error(e+" is not a modifier")},l.prototype.toConditionalReference=function(e){return u.ConditionalReference.create(e)},l.prototype.iterableFor=function(e,t){var n=t.named.get("key").value() +return a.default(e,n)},l.prototype.scheduleInstallModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleInstallModifier).call.apply(t,[this].concat(babelHelpers.slice.call(arguments)))}},l.prototype.scheduleUpdateModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleUpdateModifier).call.apply(t,[this].concat(babelHelpers.slice.call(arguments)))}},l.prototype.didDestroy=function(e){e.destroy()},l.prototype.begin=function(){this.inTransaction=!0,e.prototype.begin.call(this),this.destroyedComponents=[]},l.prototype.commit=function(){for(var t=0;t1?n.String.dasherize(t.at(1).value()):null:o===!1?i>2?n.String.dasherize(t.at(2).value()):null:o}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/-html-safe",["exports","ember-glimmer/utils/references","ember-glimmer/utils/string"],function(e,t,n){"use strict" +function r(e){var t=e.positional,r=t.at(0) +return new n.SafeString(r.value())}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/-input-type",["exports","ember-glimmer/utils/references"],function(e,t){"use strict" +function n(e){var t=e.positional,n=(e.named,t.at(0).value()) +return"checkbox"===n?"-checkbox":"-text-field"}e.default=function(e,r){return new t.InternalHelperReference(n,r)}}),s("ember-glimmer/helpers/-normalize-class",["exports","ember-glimmer/utils/references","ember-runtime"],function(e,t,n){"use strict" +function r(e){var t=e.positional,r=(e.named,t.at(0).value().split(".")),i=r[r.length-1],o=t.at(1).value() +return o===!0?n.String.dasherize(i):o||0===o?String(o):""}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/action",["exports","ember-utils","ember-metal","ember-glimmer/utils/references","@glimmer/runtime","@glimmer/reference"],function(e,t,n,r,i,o){"use strict" +function s(e){return e}function a(e,t){var r=null +t.length>0&&(r=function(e){return t.value().concat(e)}) +var i=null +return e&&(i=function(t){var r=e.value() +return r&&t.length>0&&(t[0]=n.get(t[0],r)),t}),r&&i?function(e){return i(r(e))}:r||i||s}function u(e,t,n,r,i){return function(){return l(e,t.value(),n.value(),r,i).apply(void 0,arguments)}}function l(e,t,r,i,o){var s=void 0,a=void 0 +if("function"==typeof r[c])s=r,a=r[c] +else{var u=typeof r +"string"===u?(s=t,a=t.actions&&t.actions[r]):"function"===u&&(s=e,a=r)}return function(){for(var e=arguments.length,t=Array(e),r=0;r0){for(var f=Math.min(a.length,c.length),d=0;d=0)return!0 +for(var n=0;n1)if(u=a.at(0),p=a.at(1),p[i.INVOKE])c=p +else{p._propertyKey +c=p.value()}for(var h=[],f=2;f10)throw g=0,v[n].destroy(),new Error("infinite rendering invalidation detected") +return g++,f.join(null,p)}g=0}var f=n.run.backburner,d=function(){function e(e,t,n,r){this.view=e,this.outletState=t,this.rootOutletState=n}return e.prototype.child=function(){return new e(this.view,this.outletState,this.rootOutletState)},e.prototype.get=function(e){return this.outletState},e.prototype.set=function(e,t){return this.outletState=t,t},e}(),m=function(){function e(e,t,n,r,o,s){var a=this +this.id=i.getViewId(e),this.env=t,this.root=e,this.result=void 0,this.shouldReflush=!1,this.destroyed=!1,this._removing=!1 +var u=this.options={alwaysRevalidate:!1} +this.render=function(){var e=a.result=n.render(r,o,s) +a.render=function(){e.rerender(u)}}}return e.prototype.isFor=function(e){return this.root===e},e.prototype.destroy=function(){var e=this.result,t=this.env +if(this.destroyed=!0,this.env=null,this.root=null,this.result=null,this.render=null,e){var n=!t.inTransaction +n&&t.begin(),e.destroy(),n&&t.commit()}},e}(),v=[] +n.setHasViews(function(){return v.length>0}) +var g=0 +f.on("begin",c),f.on("end",h) +var y=function(){function e(e,t){var n=arguments.length<=2||void 0===arguments[2]?i.fallbackViewRegistry:arguments[2],r=!(arguments.length<=3||void 0===arguments[3])&&arguments[3] +this._env=e,this._rootTemplate=t,this._viewRegistry=n,this._destinedForDOM=r,this._destroyed=!1,this._roots=[],this._lastRevision=null,this._isRenderingRoots=!1,this._removedRoots=[]}return e.prototype.appendOutletView=function(e,t){var n=new a.TopLevelOutletComponentDefinition(e),r=e.toReference(),i=e.outletState.render.controller +this._appendDefinition(e,n,t,r,i)},e.prototype.appendTo=function(e,t){var n=new s.RootComponentDefinition(e) +this._appendDefinition(e,n,t)},e.prototype._appendDefinition=function(e,n,i){var o=arguments.length<=3||void 0===arguments[3]?r.UNDEFINED_REFERENCE:arguments[3],s=arguments.length<=4||void 0===arguments[4]?null:arguments[4],a=new t.RootReference(n),u=new d(null,o,o,!0,s),l=new m(e,this._env,this._rootTemplate,a,i,u) +this._renderRoot(l)},e.prototype.rerender=function(e){this._scheduleRevalidate()},e.prototype.register=function(e){var t=i.getViewId(e) +this._viewRegistry[t]=e},e.prototype.unregister=function(e){delete this._viewRegistry[i.getViewId(e)]},e.prototype.remove=function(e){e._transitionTo("destroying"),this.cleanupRootFor(e),i.setViewElement(e,null),this._destinedForDOM&&e.trigger("didDestroyElement"),e.isDestroying||e.destroy()},e.prototype.cleanupRootFor=function(e){if(!this._destroyed)for(var t=this._roots,n=this._roots.length;n--;){var r=t[n] +r.isFor(e)&&r.destroy()}},e.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this._clearAllRoots())},e.prototype.getElement=function(e){},e.prototype.getBounds=function(e){var t=e[o.BOUNDS],n=t.parentElement(),r=t.firstNode(),i=t.lastNode() +return{parentElement:n,firstNode:r,lastNode:i}},e.prototype.createElement=function(e){return this._env.getAppendOperations().createElement(e)},e.prototype._renderRoot=function(e){var t=this._roots +t.push(e),1===t.length&&u(this),this._renderRootsTransaction()},e.prototype._renderRoots=function(){var e=this._roots,t=this._env,i=this._removedRoots,o=void 0,s=void 0 +do{t.begin(),s=e.length,o=!1 +for(var a=0;a=s&&!c||(u.options.alwaysRevalidate=c,c=u.shouldReflush=n.runInTransaction(u,"render"),o=o||c)}}this._lastRevision=r.CURRENT_TAG.value(),t.commit()}while(o||e.length>s) +for(;i.length;){var u=i.pop(),p=e.indexOf(u) +e.splice(p,1)}0===this._roots.length&&l(this)},e.prototype._renderRootsTransaction=function(){if(!this._isRenderingRoots){this._isRenderingRoots=!0 +var e=!1 +try{this._renderRoots(),e=!0}finally{e||(this._lastRevision=r.CURRENT_TAG.value()),this._isRenderingRoots=!1}}},e.prototype._clearAllRoots=function(){for(var e=this._roots,t=0;t1)return i.closureComponentMacro(e,t,n,null,null,r) +var a=r.symbolTable,u=void 0 +return s.indexOf("-")>-1&&(u=r.env.getComponentDefinition(e,a)),!!u&&(o.wrapComponentClassAttribute(n),r.component.static(u,[t,n,null,null],a),!0)}function h(e,t){var n=e[1],r=e[2],s=e[3],a=e[4],u=e[5],l=n[0] +if(n.length>1)return i.closureComponentMacro(n,r,s,a,u,t) +if(l.indexOf("-")===-1)return!1 +var c=t.symbolTable,p=void 0 +return l.indexOf("-")>-1&&(p=t.env.getComponentDefinition(n,c)),!!p&&(o.wrapComponentClassAttribute(s),t.component.static(p,[r,s,a,u],c),!0)}function f(e){m.push(e)}function d(e,o){o.add("outlet",n.outletMacro),o.add("component",i.inlineComponentMacro),o.add("render",t.renderMacro),o.add("mount",r.mountMacro),o.add("input",u.inputMacro),o.add("textarea",l.textAreaMacro),o.addMissing(p),e.add("component",i.blockComponentMacro),e.add("-with-dynamic-vars",s._withDynamicVarsMacro),e.add("-in-element",a._inElementMacro),e.addMissing(h) +for(var c=0;c-1))return i(t,o,s) +var p=u[l] +if(!Array.isArray(p)){if("checkbox"===p){n.wrapComponentClassAttribute(o) +var h=s.env.getComponentDefinition(["-checkbox"],s.symbolTable) +return s.component.static(h,[t,o,null,null],s.symbolTable),!0}return i(t,o,s)}return r.dynamicComponentMacro(t,o,null,null,s)}e.inputMacro=o}),s("ember-glimmer/syntax/mount",["exports","@glimmer/runtime","@glimmer/reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet","container","ember-glimmer/syntax/abstract-manager"],function(e,t,n,r,i,o,s,a,u){"use strict" +function l(e,t,n,r){var i=t[0] +return r.component.static(new h(i,r.env),[t,n,null,null],r.symbolTable),!0}e.mountMacro=l +var c=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.prepareArgs=function(e,t){return t},t.prototype.create=function(e,t,r,i){var o=t.name,s=t.env +i.outletState=n.UNDEFINED_REFERENCE +var a=s.owner.buildChildEngineInstance(o) +return a.boot(),{engine:a}},t.prototype.layoutFor=function(e,t,n){var r=t.engine,i=r.lookup("template:application") +return n.getCompiledBlock(s.OutletLayoutCompiler,i)},t.prototype.getSelf=function(e){var t=e.engine,n=t[a.FACTORY_FOR]("controller:application"),r=n||o.generateControllerFactory(t,"application") +return new i.RootReference(r.create())},t.prototype.getTag=function(){return null},t.prototype.getDestructor=function(e){var t=e.engine +return t},t.prototype.didCreateElement=function(){},t.prototype.didRenderLayout=function(){},t.prototype.didCreate=function(e){},t.prototype.update=function(e,t,n){},t.prototype.didUpdateLayout=function(){},t.prototype.didUpdate=function(e){},t}(u.default),p=new c,h=function(e){function t(t,n){e.call(this,t,p,null),this.env=n}return babelHelpers.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/syntax/outlet",["exports","ember-utils","@glimmer/runtime","ember-metal","ember-glimmer/utils/references","ember-glimmer/syntax/abstract-manager","@glimmer/reference"],function(e,t,n,r,i,o,s){"use strict" +function a(e){var t=e.dynamicScope(),n=t.outletState,r=e.getArgs(),i=void 0 +return i=0===r.positional.length?new s.ConstReference("main"):r.positional.at(0),new h(i,n)}function u(e,t,r,i){t||(t=[]) +var o=[t.slice(0,1),null,null,null] +return i.component.dynamic(o,a,n.CompiledArgs.empty(),i.symbolTable,null),!0}function l(e,t,n){return t||n?!t&&n||t&&!n?null:n.render.template===t.render.template&&n.render.controller===t.render.controller?e:null:e}function c(e){var t=e.render,n=t.name,r=t.outlet +return{object:n+":"+r}}function p(){}e.outletMacro=u +var h=function(){function e(e,t){this.outletNameRef=e,this.parentOutletStateRef=t,this.definition=null,this.lastState=null +var n=this.outletStateTag=new s.UpdatableTag(t.tag) +this.tag=s.combine([n.tag,e.tag])}return e.prototype.value=function(){var e=this.outletNameRef,t=this.parentOutletStateRef,n=this.definition,r=this.lastState,i=e.value(),o=t.get("outlets").get(i),s=this.lastState=o.value() +this.outletStateTag.update(o.tag),n=l(n,r,s) +var a=s&&s.render.template +return n?n:a?this.definition=new _(i,s.render.template):this.definition=null},e}(),f=function(){function e(e){this.outletState=e,this.instrument()}return e.prototype.instrument=function(){this.finalizer=r._instrumentStart("render.outlet",c,this.outletState)},e.prototype.finalize=function(){var e=this.finalizer +e(),this.finalizer=p},e}(),d=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.prepareArgs=function(e,t){return t},t.prototype.create=function(e,t,n,r){var i=r.outletState=r.outletState.get("outlets").get(t.outletName),o=i.value() +return new f(o)},t.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(w,e.template)},t.prototype.getSelf=function(e){var t=e.outletState +return new i.RootReference(t.render.controller)},t.prototype.getTag=function(){return null},t.prototype.getDestructor=function(){return null},t.prototype.didRenderLayout=function(e){e.finalize()},t.prototype.didCreateElement=function(){},t.prototype.didCreate=function(e){},t.prototype.update=function(e){},t.prototype.didUpdateLayout=function(e){},t.prototype.didUpdate=function(e){},t}(o.default),m=new d,v=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){return new f(r.outletState.value())},t.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(b,e.template)},t}(d),g=new v,y=function(e){function n(n){e.call(this,"outlet",g,n),this.template=n.template,t.generateGuid(this)}return babelHelpers.inherits(n,e),n}(n.ComponentDefinition) +e.TopLevelOutletComponentDefinition=y +var b=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout()),e.tag.static("div"),e.attrs.static("id",t.guidFor(this)),e.attrs.static("class","ember-view")},e}() +b.id="top-level-outlet" +var _=function(e){function n(n,r){e.call(this,"outlet",m,null),this.outletName=n,this.template=r,t.generateGuid(this)}return babelHelpers.inherits(n,e),n}(n.ComponentDefinition),w=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout())},e}() +e.OutletLayoutCompiler=w,w.id="outlet"}),s("ember-glimmer/syntax/render",["exports","@glimmer/runtime","@glimmer/reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet","container","ember-glimmer/syntax/abstract-manager"],function(e,t,n,r,i,o,s,a,u){"use strict" +function l(e){var t=e.env,r=e.getArgs(),i=r.positional.at(0),o=i.value(),s=t.owner.lookup("template:"+o),a=void 0 +if(r.named.has("controller")){var u=r.named.get("controller") +a=u.value()}else a=o +return 1===r.positional.length?new n.ConstReference(new v(a,s,t,f)):new n.ConstReference(new v(a,s,t,m))}function c(e,t,n,r){t||(t=[]) +var i=[t.slice(0),n,null,null],o=[t.slice(1),n,null,null] +return r.component.dynamic(i,l,o,r.symbolTable),!0}e.renderMacro=c +var p=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.prepareArgs=function(e,t){return t},t.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(s.OutletLayoutCompiler,e.template)},t.prototype.getSelf=function(e){var t=e.controller +return new i.RootReference(t)},t.prototype.getTag=function(){return null},t.prototype.getDestructor=function(){return null},t.prototype.didCreateElement=function(){},t.prototype.didRenderLayout=function(){},t.prototype.didCreate=function(){},t.prototype.update=function(){},t.prototype.didUpdateLayout=function(){},t.prototype.didUpdate=function(){},t}(u.default),h=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,a=s.owner.lookup("controller:"+i)||o.generateController(s.owner,i) +return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:a}},t}(p),f=new h,d=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,u=n.positional.at(0),l=s.owner[a.FACTORY_FOR]("controller:"+i),c=l||o.generateControllerFactory(s.owner,i),p=c.create({model:u.value()}) +return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:p}},t.prototype.update=function(e,t,n){var r=e.controller +r.set("model",t.positional.at(0).value())},t.prototype.getDestructor=function(e){var t=e.controller +return t},t}(p),m=new d,v=function(e){function t(t,n,r,i){e.call(this,"render",i,null),this.name=t,this.template=n,this.env=r}return babelHelpers.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/template",["exports","ember-utils","@glimmer/runtime"],function(e,t,n){"use strict" +function r(e){var r=n.templateFactory(e) +return{id:r.id,meta:r.meta,create:function(e){return r.create(e.env,{owner:e[t.OWNER]})}}}e.default=r}),s("ember-glimmer/template_registry",["exports"],function(e){"use strict" +function t(e){s=e}function n(){return s}function r(e){if(s.hasOwnProperty(e))return s[e]}function i(e){return s.hasOwnProperty(e)}function o(e,t){return s[e]=t}e.setTemplates=t,e.getTemplates=n,e.getTemplate=r,e.hasTemplate=i,e.setTemplate=o +var s={}}),s("ember-glimmer/templates/component",["exports","ember-glimmer/template"],function(e,t){"use strict" +e.default=t.default({id:"2aYM5QYc",block:'{"statements":[["yield","default"]],"locals":[],"named":[],"yields":["default"],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/component.hbs"}})}),s("ember-glimmer/templates/empty",["exports","ember-glimmer/template"],function(e,t){"use strict" +e.default=t.default({id:"5QJJjniM",block:'{"statements":[],"locals":[],"named":[],"yields":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/empty.hbs"}})}),s("ember-glimmer/templates/link-to",["exports","ember-glimmer/template"],function(e,t){"use strict" +e.default=t.default({id:"Y2DX6qHQ",block:'{"statements":[["block",["if"],[["get",["linkTitle"]]],null,{"statements":[["append",["unknown",["linkTitle"]],false]],"locals":[]},{"statements":[["yield","default"]],"locals":[]}]],"locals":[],"named":[],"yields":["default"],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/link-to.hbs"}})}),s("ember-glimmer/templates/outlet",["exports","ember-glimmer/template"],function(e,t){"use strict" +e.default=t.default({id:"xyZMyWzn",block:'{"statements":[["append",["unknown",["outlet"]],false]],"locals":[],"named":[],"yields":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/outlet.hbs"}})}),s("ember-glimmer/templates/root",["exports","ember-glimmer/template"],function(e,t){"use strict" +e.default=t.default({id:"/KBRNPqv",block:'{"statements":[["append",["helper",["component"],[["get",[null]]],null],false]],"locals":[],"named":[],"yields":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/root.hbs"}})}),s("ember-glimmer/utils/bindings",["exports","@glimmer/reference","ember-metal","ember-runtime","ember-glimmer/component","ember-glimmer/utils/string"],function(e,t,n,r,i,o){"use strict" +function s(e,t){return e[i.ROOT_REF].get(t)}function a(e,n){var r="attrs"===n[0] +return r&&(n.shift(),1===n.length)?s(e,n[0]):t.referenceFromParts(e[i.ROOT_REF],n)}function u(e){if(!e)return e +var t=e[0],n=e[1],r=t.indexOf("class") +if(r!==-1){var i=n[r],o=i[0] +if("get"===o){var s=n[r],a=s[1],u=a[a.length-1] +e[1][r]=["helper",["-class"],[s,u]]}}return e}e.wrapComponentClassAttribute=u +var l={parse:function(e){var t=e.indexOf(":") +if(t===-1)return[e,e,!0] +var n=e.substring(0,t),r=e.substring(t+1) +return[n,r,!1]},install:function(e,t,r,i){var o=r[0],u=r[1] +r[2] +if("id"===u){var l=n.get(t,o) +return void 0!==l&&null!==l||(l=t.elementId),void i.addStaticAttribute(e,"id",l)}var c=o.indexOf(".")>-1,p=c?a(t,o.split(".")):s(t,o) +"style"===u&&(p=new h(p,s(t,"isVisible"))),i.addDynamicAttribute(e,u,p)}} +e.AttributeBinding=l +var c="display: none;",p=o.htmlSafe(c),h=function(e){function n(n,r){e.call(this),this.tag=t.combine([n.tag,r.tag]),this.inner=n,this.isVisible=r}return babelHelpers.inherits(n,e),n.prototype.compute=function(){var e=this.inner.value(),t=this.isVisible.value() +if(t!==!1)return e +if(e||0===e){var n=e+" "+c +return o.isHTMLSafe(e)?o.htmlSafe(n):n}return p},n}(t.CachedReference),f={install:function(e,n,r){r.addDynamicAttribute(e,"style",t.map(s(n,"isVisible"),this.mapStyleValue))},mapStyleValue:function(e){return e===!1?p:null}} +e.IsVisibleBinding=f +var d={install:function(e,t,n,r){var i=n.split(":"),o=i[0],u=i[1],l=i[2],c=""===o +if(c)r.addStaticAttribute(e,"class",u) +else{var p=o.indexOf(".")>-1,h=p&&o.split("."),f=p?a(t,h):s(t,o),d=void 0 +d=void 0===u?new m(f,p?h[h.length-1]:o):new v(f,u,l),r.addDynamicAttribute(e,"class",d)}}} +e.ClassNameBinding=d +var m=function(e){function t(t,n){e.call(this),this.tag=t.tag,this.inner=t,this.path=n,this.dasherizedPath=null}return babelHelpers.inherits(t,e),t.prototype.compute=function(){var e=this.inner.value() +if(e===!0){var t=this.path,n=this.dasherizedPath +return n||(this.dasherizedPath=r.String.dasherize(t))}return e||0===e?e:null},t}(t.CachedReference),v=function(e){function t(t,n,r){e.call(this),this.tag=t.tag,this.inner=t,this.truthy=n||null,this.falsy=r||null}return babelHelpers.inherits(t,e),t.prototype.compute=function(){var e=this.inner,t=this.truthy,n=this.falsy +return e.value()?t:n},t}(t.CachedReference)}),s("ember-glimmer/utils/debug-stack",["exports","ember-metal"],function(e,t){"use strict" +var n=void 0 +e.default=n}),s("ember-glimmer/utils/iterable",["exports","ember-utils","ember-metal","ember-runtime","ember-glimmer/utils/references","ember-glimmer/helpers/each-in","@glimmer/reference"],function(e,t,n,r,i,o,s){"use strict" +function a(e,t){return o.isEachIn(e)?new b(e,u(t)):new _(e,l(t))}function u(e){switch(e){case"@index":case void 0:case null:return c +case"@identity":return p +default:return function(t){return n.get(t,e)}}}function l(e){switch(e){case"@index":return c +case"@identity":case void 0:case null:return p +default:return function(t){return n.get(t,e)}}}function c(e,t){return String(t)}function p(e){switch(typeof e){case"string":case"number":return String(e) +default:return t.guidFor(e)}}function h(e,t){var n=e[t] +return n?(e[t]++,""+t+f+n):(e[t]=1,t)}e.default=a +var f="be277757-bbbe-4620-9fcb-213ef433cca2",d=function(){function e(e,n){this.array=e,this.length=e.length,this.keyFor=n,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return!1},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,r=this.position,i=this.seen +if(r>=t)return null +var o=e[r],s=r,a=h(i,n(o,s)) +return this.position++,{key:a,value:o,memo:s}},e}(),m=function(){function e(e,r){this.array=e,this.length=n.get(e,"length"),this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.length},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,i=this.position,o=this.seen +if(i>=t)return null +var s=r.objectAt(e,i),a=i,u=h(o,n(s,a)) +return this.position++,{key:u,value:s,memo:a}},e}(),v=function(){function e(e,n,r){this.keys=e,this.values=n,this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.keys.length},e.prototype.next=function(){var e=this.keys,t=this.values,n=this.keyFor,r=this.position,i=this.seen +if(r>=e.length)return null +var o=t[r],s=e[r],a=h(i,n(o,s)) +return this.position++,{key:a,value:o,memo:s}},e}(),g=function(){function e(){}return e.prototype.isEmpty=function(){return!0},e.prototype.next=function(){throw new Error("Cannot call next() on an empty iterator")},e}(),y=new g,b=function(){function e(e,t){this.ref=e,this.keyFor=t +var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG) +this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,r=this.valueTag,i=e.value() +r.update(n.tagFor(i)),n.isProxy(i)&&(i=n.get(i,"content")) +var o=typeof i +if(!i||"object"!==o&&"function"!==o)return y +var s=Object.keys(i),a=s.map(function(e){return i[e]}) +return s.length>0?new v(s,a,t):y},e.prototype.valueReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateValueReference=function(e,t){e.update(t.memo)},e.prototype.memoReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateMemoReference=function(e,t){e.update(t.value)},e}(),_=function(){function e(e,t){this.ref=e,this.keyFor=t +var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG) +this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,i=this.valueTag,o=e.value() +if(i.update(n.tagForProperty(o,"[]")),!o||"object"!=typeof o)return y +if(Array.isArray(o))return o.length>0?new d(o,t):y +if(r.isEmberArray(o))return n.get(o,"length")>0?new m(o,t):y +if("function"!=typeof o.forEach)return y +var s=function(){var e=[] +return o.forEach(function(t){e.push(t)}),{v:e.length>0?new d(e,t):y}}() +return"object"==typeof s?s.v:void 0},e.prototype.valueReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateValueReference=function(e,t){e.update(t.value)},e.prototype.memoReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateMemoReference=function(e,t){e.update(t.memo)},e}()}),s("ember-glimmer/utils/process-args",["exports","ember-utils","@glimmer/reference","ember-glimmer/component","ember-glimmer/utils/references","ember-views","ember-glimmer/helpers/action","@glimmer/runtime"],function(e,t,n,r,i,o,s,a){"use strict" +function u(e,t){var n=l(e,t),r=c(e,t) +return p(n,r,e.blocks,t.ComponentClass.class)}function l(e,n){var r=e.named.map +return n.args?t.assign({},n.args.named.map,r):r}function c(e,t){var n=e.positional.values +if(t.args){var r=t.args.positional.values,i=[] +return i.push.apply(i,r),i.splice.apply(i,[0,n.length].concat(n)),i}return n}function p(e,t,n,r){var i=r.positionalParams +return i&&i.length>0&&t.length>0&&(e="string"==typeof i?h(e,t,i):f(e,t,i)),a.EvaluatedArgs.named(e,n)}function h(e,n,r){var i=t.assign({},e) +return i[r]=a.EvaluatedPositionalArgs.create(n),i}function f(e,n,r){for(var i=t.assign({},e),o=Math.min(n.length,r.length),s=0;s":">",'"':""","'":"'","`":"`","=":"="},l=/[&<>"'`=]/,c=/[&<>"'`=]/g}),s("ember-glimmer/utils/to-bool",["exports","ember-runtime","ember-metal"],function(e,t,n){"use strict" +function r(e){return!!e&&(e===!0||(!t.isArray(e)||0!==n.get(e,"length")))}e.default=r}),s("ember-glimmer/views/outlet",["exports","ember-utils","@glimmer/reference","ember-environment","ember-metal"],function(e,t,n,r,i){"use strict" +var o=function(){function e(e){this.outletView=e,this.tag=e._tag}return e.prototype.get=function(e){return new a(this,e)},e.prototype.value=function(){return this.outletView.outletState},e.prototype.getOrphan=function(e){return new s(this,e)},e.prototype.update=function(e){this.outletView.setOutletState(e)},e}(),s=function(e){function n(t,n){e.call(this,t.outletView),this.root=t,this.name=n}return babelHelpers.inherits(n,e),n.prototype.value=function(){var e=this.root.value(),n=e.outlets.main.outlets.__ember_orphans__ +if(!n)return null +var r=n.outlets[this.name] +if(!r)return null +var i=new t.EmptyObject +return i[r.render.outlet]=r,r.wasUsed=!0,{outlets:i}},n}(o),a=function(){function e(e,t){this.parent=e,this.key=t,this.tag=e.tag}return e.prototype.get=function(t){return new e(this,t)},e.prototype.value=function(){return this.parent.value()[this.key]},e}(),u=function(){function e(e,t,r,i){this._environment=e,this.renderer=t,this.owner=r,this.template=i,this.outletState=null,this._tag=new n.DirtyableTag}return e.extend=function(n){return function(e){function r(){e.apply(this,arguments)}return babelHelpers.inherits(r,e),r.create=function(r){return r?e.create.call(this,t.assign({},n,r)):e.create.call(this,n)},r}(e)},e.reopenClass=function(e){t.assign(this,e)},e.create=function(n){var r=n._environment,i=n.renderer,o=n.template,s=n[t.OWNER] +return new e(r,i,s,o)},e.prototype.appendTo=function(e){var t=this._environment||r.environment,n=void 0 +n=t.hasDOM&&"string"==typeof e?document.querySelector(e):e,i.run.schedule("render",this.renderer,"appendOutletView",this,n)},e.prototype.rerender=function(){},e.prototype.setOutletState=function(e){this.outletState={outlets:{main:e},render:{owner:void 0,into:void 0,outlet:"main",name:"-top-level",controller:void 0,ViewClass:void 0,template:void 0}},this._tag.dirty()},e.prototype.toReference=function(){return new o(this)},e.prototype.destroy=function(){},e}() +e.default=u}),s("ember-metal/alias",["exports","ember-utils","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/error","ember-metal/properties","ember-metal/computed","ember-metal/meta","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict" +function c(e){return new d(e)}function p(e,n,r){throw new o.default("Cannot set read-only property '"+n+"' on object: "+t.inspect(e))}function h(e,t,n){return s.defineProperty(e,t,null),i.set(e,t,n)}e.default=c +var f={},d=function(e){function t(t){e.call(this),this.isDescriptor=!0,this.altKey=t,this._dependentKeys=[t]}return babelHelpers.inherits(t,e),t.prototype.setup=function(e,t){var n=u.meta(e) +n.peekWatching(t)&&l.addDependentKeys(this,e,t,n)},t.prototype.teardown=function(e,t){var n=u.meta(e) +n.peekWatching(t)&&l.removeDependentKeys(this,e,t,n)},t.prototype.willWatch=function(e,t){l.addDependentKeys(this,e,t,u.meta(e))},t.prototype.didUnwatch=function(e,t){l.removeDependentKeys(this,e,t,u.meta(e))},t.prototype.get=function(e,t){var n=r.get(e,this.altKey),i=u.meta(e),o=i.writableCache() +return o[t]!==f&&(o[t]=f,l.addDependentKeys(this,e,t,i)),n},t.prototype.set=function(e,t,n){return i.set(e,this.altKey,n)},t.prototype.readOnly=function(){return this.set=p,this},t.prototype.oneWay=function(){return this.set=h,this},t}(s.Descriptor) +e.AliasedProperty=d,d.prototype._meta=void 0,d.prototype.meta=a.ComputedProperty.prototype.meta}),s("ember-metal/binding",["exports","ember-utils","ember-console","ember-environment","ember-metal/run_loop","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/events","ember-metal/observer","ember-metal/path_cache"],function(e,t,n,r,i,o,s,a,u,l,c){"use strict" +function p(e,t,n,r,i,o){}function h(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function f(e,t,n){return new d(t,n).connect(e)}e.bind=f +var d=function(){function e(e,t){this._from=t,this._to=e,this._oneWay=void 0,this._direction=void 0,this._readyToSync=void 0,this._fromObj=void 0,this._fromPath=void 0,this._toObj=void 0}return e.prototype.copy=function t(){var t=new e(this._to,this._from) +return this._oneWay&&(t._oneWay=!0),t},e.prototype.from=function(e){return this._from=e,this},e.prototype.to=function(e){return this._to=e,this},e.prototype.oneWay=function(){return this._oneWay=!0,this},e.prototype.toString=function(){var e=this._oneWay?"[oneWay]":"" +return"Ember.Binding<"+t.guidFor(this)+">("+this._from+" -> "+this._to+")"+e},e.prototype.connect=function(e){var t=void 0,n=void 0,i=void 0 +if(c.isGlobalPath(this._from)){var o=c.getFirstKey(this._from) +i=r.context.lookup[o],i&&(t=i,n=c.getTailPath(this._from))}return void 0===t&&(t=e,n=this._from),a.trySet(e,this._to,s.get(t,n)),l.addObserver(t,n,this,"fromDidChange"),this._oneWay||l.addObserver(e,this._to,this,"toDidChange"),u.addListener(e,"willDestroy",this,"disconnect"),p(e,this._to,this._from,i,this._oneWay,!i&&!this._oneWay),this._readyToSync=!0,this._fromObj=t,this._fromPath=n,this._toObj=e,this},e.prototype.disconnect=function(){return l.removeObserver(this._fromObj,this._fromPath,this,"fromDidChange"),this._oneWay||l.removeObserver(this._toObj,this._to,this,"toDidChange"),this._readyToSync=!1,this},e.prototype.fromDidChange=function(e){this._scheduleSync("fwd")},e.prototype.toDidChange=function(e){this._scheduleSync("back")},e.prototype._scheduleSync=function(e){var t=this._direction +void 0===t&&(i.default.schedule("sync",this,"_sync"),this._direction=e),"back"===t&&"fwd"===e&&(this._direction="fwd")},e.prototype._sync=function(){var e=this,t=r.ENV.LOG_BINDINGS,i=this._toObj +if(!i.isDestroyed&&this._readyToSync){var o=this._direction,u=this._fromObj,c=this._fromPath +this._direction=void 0,"fwd"===o?function(){var r=s.get(u,c) +t&&n.default.log(" ",e.toString(),"->",r,u),e._oneWay?a.trySet(i,e._to,r):l._suspendObserver(i,e._to,e,"toDidChange",function(){a.trySet(i,this._to,r)})}():"back"===o&&function(){var r=s.get(i,e._to) +t&&n.default.log(" ",e.toString(),"<-",r,i),l._suspendObserver(u,c,e,"fromDidChange",function(){a.trySet(u,c,r)})}()}},e}() +h(d,{from:function(e){var t=this +return new t(void 0,e)},to:function(e){var t=this +return new t(e,void 0)}}),e.Binding=d}),s("ember-metal/cache",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict" +var r=function(){function e(e,t,n,r){this.size=0,this.misses=0,this.hits=0,this.limit=e,this.func=t,this.key=n,this.store=r||new i}return e.prototype.get=function(e){var t=void 0===this.key?e:this.key(e),r=this.store.get(t) +return void 0===r?(this.misses++,r=this._set(t,this.func(e))):r===n.UNDEFINED?(this.hits++,r=void 0):this.hits++,r},e.prototype.set=function(e,t){var n=void 0===this.key?e:this.key(e) +return this._set(n,t)},e.prototype._set=function(e,t){return this.limit>this.size&&(this.size++,void 0===t?this.store.set(e,n.UNDEFINED):this.store.set(e,t)),t},e.prototype.purge=function(){this.store.clear(),this.size=0,this.hits=0,this.misses=0},e}() +e.default=r +var i=function(){function e(){this.data=new t.EmptyObject}return e.prototype.get=function(e){return this.data[e]},e.prototype.set=function(e,t){this.data[e]=t},e.prototype.clear=function(){this.data=new t.EmptyObject},e}()}),s("ember-metal/chains",["exports","ember-utils","ember-metal/property_get","ember-metal/meta","ember-metal/watch_key","ember-metal/computed","ember-metal/watch_path"],function(e,t,n,r,i,o,s){"use strict" +function a(e){return e.match(m)[0]}function u(e){return"object"==typeof e&&e}function l(e){return!(u(e)&&e.isDescriptor&&e._volatile===!1)}function c(){return new v}function p(e,t,n){var o=r.meta(e) +o.writableChainWatchers(c).add(t,n),i.watchKey(e,t,o)}function h(e,t,n,o){if(u(e)){var s=o||r.peekMeta(e) +s&&s.readableChainWatchers()&&(s=r.meta(e),s.readableChainWatchers().remove(t,n),i.unwatchKey(e,t,s))}}function f(e,t){if(u(e)){var i=r.peekMeta(e) +if(!i||i.proto!==e){if(l(e[t]))return n.get(e,t) +var s=i.readableCache() +return s?o.cacheFor.get(s,t):void 0}}}function d(e){var t=r.peekMeta(e) +if(t){t=r.meta(e) +var n=t.readableChainWatchers() +n&&n.revalidateAll(),t.readableChains()&&t.writableChains(s.makeChainNode)}}e.finishChains=d +var m=/^([^\.]+)/,v=function(){function e(){this.chains=new t.EmptyObject}return e.prototype.add=function(e,t){var n=this.chains[e] +void 0===n?this.chains[e]=[t]:n.push(t)},e.prototype.remove=function(e,t){var n=this.chains[e] +if(n)for(var r=0;r0&&t[e]-- +var n=a(e),r=e.slice(n.length+1) +this.unchain(n,r)},e.prototype.chain=function(n,r){var i=this._chains,o=void 0 +void 0===i?i=this._chains=new t.EmptyObject:o=i[n],void 0===o&&(o=i[n]=new e(this,n,void 0)),o.count++,r&&(n=a(r),r=r.slice(n.length+1),o.chain(n,r))},e.prototype.unchain=function(e,t){var n=this._chains,r=n[e] +if(t&&t.length>1){var i=a(t),o=t.slice(i.length+1) +r.unchain(i,o)}r.count--,r.count<=0&&(n[r._key]=void 0,r.destroy())},e.prototype.notify=function(e,t){if(e&&this._watching){var n=this._parent.value() +n!==this._object&&(this._object&&h(this._object,this._key,this),u(n)?(this._object=n,p(n,this._key,this)):this._object=void 0),this._value=void 0}var r=this._chains,i=void 0 +if(r)for(var o in r)i=r[o],void 0!==i&&i.notify(e,t) +t&&this._parent&&this._parent.populateAffected(this._key,1,t)},e.prototype.populateAffected=function(e,t,n){this._key&&(e=this._key+"."+e),this._parent?this._parent.populateAffected(e,t+1,n):t>1&&n.push(this.value(),e)},e}() +e.removeChainWatcher=h,e.ChainNode=g}),s("ember-metal/computed",["exports","ember-utils","ember-metal/debug","ember-metal/property_set","ember-metal/meta","ember-metal/expand_properties","ember-metal/error","ember-metal/properties","ember-metal/property_events","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict" +function c(e,t){this.isDescriptor=!0,"function"==typeof e?this._getter=e:(this._getter=e.get,this._setter=e.set),this._dependentKeys=void 0,this._suspended=void 0,this._meta=void 0,this._volatile=!1,this._dependentKeys=t&&t.dependentKeys,this._readOnly=!1}function p(e){var t=void 0 +arguments.length>1&&(t=[].slice.call(arguments),e=t.pop()) +var n=new c(e) +return t&&n.property.apply(n,t),n}function h(e,t){var n=i.peekMeta(e),r=n&&n.source===e&&n.readableCache(),o=r&&r[t] +if(o!==i.UNDEFINED)return o}e.default=p +c.prototype=new a.Descriptor,c.prototype.constructor=c +var f=c.prototype +f.volatile=function(){return this._volatile=!0,this},f.readOnly=function(){return this._readOnly=!0,this},f.property=function(){function e(e){t.push(e)}for(var t=[],n=0;n=0;i-=3)if(t===e[i]&&n===e[i+1]){r=i +break}return r}function s(e,t,n){var i=r.peekMeta(e) +if(i){for(var s=i.matchingListeners(t),a=[],u=s.length-3;u>=0;u-=3){var l=s[u],c=s[u+1],p=s[u+2],h=o(n,l,c) +h===-1&&(n.push(l,c,p),a.push(l,c,p))}return a}}function a(e,t,n,o,s){o||"function"!=typeof n||(o=n,n=null) +var a=0 +s&&(a|=i.ONCE),r.meta(e).addToListeners(t,n,o,a),"function"==typeof e.didAddListener&&e.didAddListener(t,n,o)}function u(e,t,n,i){i||"function"!=typeof n||(i=n,n=null),r.meta(e).removeFromListeners(t,n,i,function(){"function"==typeof e.didRemoveListener&&e.didRemoveListener.apply(e,arguments)})}function l(e,t,n,r,i){return c(e,[t],n,r,i)}function c(e,t,n,i,o){return i||"function"!=typeof n||(i=n,n=null),r.meta(e).suspendListeners(t,n,i,o)}function p(e){return r.meta(e).watchedEvents()}function h(e,n,o,s){if(!s){var a=r.peekMeta(e) +s=a&&a.matchingListeners(n)}if(s&&0!==s.length){for(var l=s.length-3;l>=0;l-=3){var c=s[l],p=s[l+1],h=s[l+2] +p&&(h&i.SUSPENDED||(h&i.ONCE&&u(e,n,c,p),c||(c=e),"string"==typeof p?o?t.applyStr(c,p,o):c[p]():o?p.apply(c,o):p.call(c)))}return!0}}function f(e,t){var n=r.peekMeta(e) +return!!n&&n.matchingListeners(t).length>0}function d(e,t){var n=[],i=r.peekMeta(e),o=i&&i.matchingListeners(t) +if(!o)return n +for(var s=0;s=0&&(s=r(s,u.split(","),a))}for(var a=0;a-1&&o.splice(s,1),this.size=o.length,!0}return!1},isEmpty:function(){return 0===this.size},has:function(e){if(0===this.size)return!1 +var n=t.guidFor(e),r=this.presenceSet +return r[n]===!0},forEach:function(e){if("function"!=typeof e&&n(e),0!==this.size){var t=this.list +if(2===arguments.length)for(var r=0;r0;){if(r=C.pop(),e=r._chains)for(t in e)void 0!==e[t]&&C.push(e[t]) +if(r._watching&&(n=r._object)){var i=R(n) +i&&!i.isSourceDestroying()&&o.removeChainWatcher(n,r._key,r,i)}}this.setMetaDestroyed()}},e.prototype.isSourceDestroying=function(){return 0!==(this._flags&g)},e.prototype.setSourceDestroying=function(){this._flags|=g},e.prototype.isSourceDestroyed=function(){return 0!==(this._flags&y)},e.prototype.setSourceDestroyed=function(){this._flags|=y},e.prototype.isMetaDestroyed=function(){return 0!==(this._flags&b)},e.prototype.setMetaDestroyed=function(){this._flags|=b},e.prototype.isProxy=function(){return 0!==(this._flags&_)},e.prototype.setProxy=function(){this._flags|=_},e.prototype._getOrCreateOwnMap=function(e){return this[e]||(this[e]=new t.EmptyObject)},e.prototype._getInherited=function(e){for(var t=this;void 0!==t;){if(t[e])return t[e] +t=t.parent}},e.prototype._findInherited=function(e,t){for(var n=this;void 0!==n;){var r=n[e] +if(r){var i=r[t] +if(void 0!==i)return i}n=n.parent}},e.prototype.writeDeps=function(e,n,r){var i=this._getOrCreateOwnMap("_deps"),o=i[e] +o||(o=i[e]=new t.EmptyObject),o[n]=r},e.prototype.peekDeps=function(e,t){for(var n=this;void 0!==n;){var r=n._deps +if(r){var i=r[e] +if(i&&void 0!==i[t])return i[t]}n=n.parent}},e.prototype.hasDeps=function(e){for(var t=this;void 0!==t;){if(t._deps&&t._deps[e])return!0 +t=t.parent}return!1},e.prototype.forEachInDeps=function(e,t){return this._forEachIn("_deps",e,t)},e.prototype._forEachIn=function(e,n,r){for(var i=this,o=new t.EmptyObject,s=[];void 0!==i;){var a=i[e] +if(a){var u=a[n] +if(u)for(var l in u)o[l]||(o[l]=!0,s.push([l,u[l]]))}i=i.parent}for(var c=0;c=0;s-=4)if(o[s]===e&&(!n||o[s+1]===t&&o[s+2]===n)){if(i!==this)return this._finalizeListeners(),this.removeFromListeners(e,t,n) +"function"==typeof r&&r(e,t,o[s+2]),o.splice(s,4)}if(i._listenersFinalized)break +i=i.parent}},matchingListeners:function(e){for(var n=this,i=[];n;){var o=n._listeners +if(o)for(var s=0;s=0;o-=3)i[o+1]===t&&i[o+2]===n&&e.indexOf(i[o])!==-1&&i.splice(o,3)}},watchedEvents:function(){for(var e=this,t={};e;){var n=e._listeners +if(n)for(var r=0;r=0||"concatenatedProperties"===t||"mergedProperties"===t?n=g(e,t,n,o):u&&u.indexOf(t)>=0?n=y(e,t,n,o):h(n)&&(n=v(e,t,n,o,i)),i[t]=void 0,o[t]=n}function _(e,t,n,r,i,o){function s(e){delete n[e],delete r[e]}for(var a=void 0,u=void 0,l=void 0,c=void 0,p=void 0,h=0;h7&&66===e.charCodeAt(t-7)&&e.indexOf("inding",t-6)!==-1}function E(e,t){t.forEachBindings(function(t,n){if(n){var r=t.slice(0,-7) +n instanceof u.Binding?(n=n.copy(),n.to(r)):n=new u.Binding(r,n),n.connect(e),e[t]=n}}),t.clearBindings()}function x(e,t){return E(e,t||i.meta(e)),e}function C(e,t,n,r,i){var o=t.methodName,s=void 0,a=void 0 +return r[o]||i[o]?(s=i[o],t=r[o]):(a=e[o])&&null!==a&&"object"==typeof a&&a.isDescriptor?(t=a,s=void 0):(t=void 0,s=e[o]),{desc:t,value:s}}function O(e,t,n,r,i){var o=n[r] +if(o)for(var s=0;s1?t-1:0),r=1;r=0;)if(N(o[s],n,r))return!0 +return!1}function P(e,n,r){if(!r[t.guidFor(n)])if(r[t.guidFor(n)]=!0,n.properties)for(var i=Object.keys(n.properties),o=0;o0){for(var o=new Array(i),s=0;s0,l&&l.teardown(e,t),n instanceof o)p=n,e[t]=p,n.setup&&n.setup(e,t) +else if(null==n){p=s +e[t]=s}else p=n,Object.defineProperty(e,t,n) +return c&&i.overrideChains(e,t,a),e.didDefineProperty&&e.didDefineProperty(e,t,p),this}e.Descriptor=o,e.MANDATORY_SETTER_FUNCTION=s,e.DEFAULT_GETTER_FUNCTION=a,e.INHERITING_GETTER_FUNCTION=u,e.defineProperty=l;(function(){var e=Object.create(Object.prototype,{prop:{configurable:!0,value:1}}) +return Object.defineProperty(e,"prop",{configurable:!0,value:2}),2===e.prop})()}),s("ember-metal/property_events",["exports","ember-utils","ember-metal/meta","ember-metal/events","ember-metal/tags","ember-metal/observer_set","ember-metal/features","ember-metal/transaction"],function(e,t,n,r,i,o,s,a){"use strict" +function u(e,t,r){var i=r||n.peekMeta(e) +if(!i||i.isInitialized(e)){var o=i&&i.peekWatching(t)>0,s=e[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0 +a&&a.willChange&&a.willChange(e,t),o&&(c(e,t,i),f(e,t,i),b(e,t,i))}}function l(e,t,r){var o=r||n.peekMeta(e) +if(!o||o.isInitialized(e)){var s=o&&o.peekWatching(t)>0,a=e[t],u=null!==a&&"object"==typeof a&&a.isDescriptor?a:void 0 +u&&u.didChange&&u.didChange(e,t),s&&(o.hasDeps(t)&&p(e,t,o),d(e,t,o,!1),_(e,t,o)),e[w]&&e[w](t),o&&o.isSourceDestroying()||i.markObjectAsDirty(o,t)}}function c(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=O,i=!r +i&&(r=O={}),h(u,e,t,r,n),i&&(O=null)}}function p(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=A,i=!r +i&&(r=A={}),h(l,e,t,r,n),i&&(A=null)}}function h(e,n,r,i,o){var s=void 0,a=void 0,u=t.guidFor(n),l=i[u] +l||(l=i[u]={}),l[r]||(l[r]=!0,o.forEachInDeps(r,function(t,r){r&&(s=n[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0,a&&a._suspended===n||e(n,t,o))}))}function f(e,t,n){var r=n.readableChainWatchers() +r&&r.notify(t,!1,u)}function d(e,t,n){var r=n.readableChainWatchers() +r&&r.notify(t,!0,l)}function m(e,t,n){var r=n.readableChainWatchers() +r&&r.revalidate(t)}function v(){C++}function g(){C--,C<=0&&(E.clear(),x.flush())}function y(e,t){v() +try{e.call(t)}finally{g.call(t)}}function b(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":before",o=void 0,s=void 0 +C?(o=E.add(e,t,i),s=r.accumulateListeners(e,i,o),r.sendEvent(e,i,[e,t],s)):r.sendEvent(e,i,[e,t])}}function _(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":change",o=void 0 +C?(o=x.add(e,t,i),r.accumulateListeners(e,i,o)):r.sendEvent(e,i,[e,t])}}var w=t.symbol("PROPERTY_DID_CHANGE") +e.PROPERTY_DID_CHANGE=w +var E=new o.default,x=new o.default,C=0,O=void 0,A=void 0 +e.propertyWillChange=u,e.propertyDidChange=l,e.overrideChains=m,e.beginPropertyChanges=v,e.endPropertyChanges=g,e.changeProperties=y}),s("ember-metal/property_get",["exports","ember-metal/debug","ember-metal/path_cache"],function(e,t,n){"use strict" +function r(e,t){var r=e[t],o=null!==r&&"object"==typeof r&&r.isDescriptor?r:void 0,s=void 0 +return void 0===o&&n.isPath(t)?i(e,t):o?o.get(e,t):(s=r,void 0!==s||"object"!=typeof e||t in e||"function"!=typeof e.unknownProperty?s:e.unknownProperty(t))}function i(e,t){for(var n=e,i=t.split("."),s=0;sa?a:l,c<=0&&(c=0),p=o.splice(0,a),p=[u,c].concat(p),u+=a,l-=c,s=s.concat(n.apply(e,p)) +return s}e.default=t +var n=Array.prototype.splice}) +s("ember-metal/run_loop",["exports","ember-utils","ember-metal/debug","ember-metal/testing","ember-metal/error_handler","ember-metal/property_events","backburner"],function(e,t,n,r,i,o,s){"use strict" +function a(e){l.currentRunLoop=e}function u(e,t){l.currentRunLoop=t}function l(){return p.run.apply(p,arguments)}e.default=l +var c={get onerror(){return i.getOnerror()},set onerror(e){return i.setOnerror(e)}},p=new s.default(["sync","actions","destroy"],{GUID_KEY:t.GUID_KEY,sync:{before:o.beginPropertyChanges,after:o.endPropertyChanges},defaultQueue:"actions",onBegin:a,onEnd:u,onErrorTarget:c,onErrorMethod:"onerror"}) +l.join=function(){return p.join.apply(p,arguments)},l.bind=function(){for(var e=arguments.length,t=Array(e),n=0;n1&&i.writeWatching(t,o-1)}}}e.watchKey=o,e.unwatchKey=s}),s("ember-metal/watch_path",["exports","ember-metal/meta","ember-metal/chains"],function(e,t,n){"use strict" +function r(e,n){return(n||t.meta(e)).writableChains(i)}function i(e){return new n.ChainNode(null,null,e)}function o(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0 +s?o.writeWatching(n,s+1):(o.writeWatching(n,1),r(e,o).add(n))}}function s(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0 +1===s?(o.writeWatching(n,0),r(e,o).remove(n)):s>1&&o.writeWatching(n,s-1)}}e.makeChainNode=i,e.watchPath=o,e.unwatchPath=s}),s("ember-metal/watching",["exports","ember-metal/watch_key","ember-metal/watch_path","ember-metal/path_cache","ember-metal/meta"],function(e,t,n,r,i){"use strict" +function o(e,i,o){r.isPath(i)?n.watchPath(e,i,o):t.watchKey(e,i,o)}function s(e,t){if("object"!=typeof e||null===e)return!1 +var n=i.peekMeta(e) +return(n&&n.peekWatching(t))>0}function a(e,t){var n=i.peekMeta(e) +return n&&n.peekWatching(t)||0}function u(e,i,o){r.isPath(i)?n.unwatchPath(e,i,o):t.unwatchKey(e,i,o)}function l(e){i.deleteMeta(e)}e.isWatching=s,e.watcherCount=a,e.unwatch=u,e.destroy=l,e.watch=o}),s("ember-metal/weak_map",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict" +function r(e){return"object"==typeof e&&null!==e||"function"==typeof e}function i(e){if(!(this instanceof i))throw new TypeError("Constructor WeakMap requires 'new'") +if(this._id=t.GUID_KEY+o++,null!==e&&void 0!==e){if(!Array.isArray(e))throw new TypeError("The weak map constructor polyfill only supports an array argument") +for(var n=0;n7)}function a(e,t){return(e.indexOf("Android 2.")===-1&&e.indexOf("Android 4.0")===-1||e.indexOf("Mobile Safari")===-1||e.indexOf("Chrome")!==-1||e.indexOf("Windows Phone")!==-1)&&!!(t&&"pushState"in t)}function u(e,t){e.replace(o(e)+t)}e.getPath=t,e.getQuery=n,e.getHash=r,e.getFullPath=i,e.getOrigin=o,e.supportsHashChange=s,e.supportsHistory=a,e.replacePath=u}),s("ember-routing/services/router",["exports","ember-runtime","ember-metal","ember-routing/system/dsl"],function(e,t,n,r){"use strict" +var i=t.Service.extend({currentRouteName:t.readOnly("router.currentRouteName"),currentURL:t.readOnly("router.currentURL"),location:t.readOnly("router.location"),rootURL:t.readOnly("router.rootURL"),transitionTo:function(){var e +return(e=this.router).transitionTo.apply(e,arguments)},replaceWith:function(){var e +return(e=this.router).replaceWith.apply(e,arguments)}}) +e.default=i}),s("ember-routing/services/routing",["exports","ember-utils","ember-runtime","ember-metal","ember-routing/utils"],function(e,t,n,r,i){"use strict" +function o(e,t){for(var n=0,r=0;rc&&(n=l),i.isActiveIntent(n,e,t,!s)}})}),s("ember-routing/system/cache",["exports","ember-utils","ember-runtime"],function(e,t,n){"use strict" +e.default=n.Object.extend({init:function(){this.cache=new t.EmptyObject},has:function(e){return!!this.cache[e]},stash:function(e,n,r){var i=this.cache[e] +i||(i=this.cache[e]=new t.EmptyObject),i[n]=r},lookup:function(e,t,n){var r=this.cache +if(!this.has(e))return n +var i=r[e] +return t in i&&void 0!==i[t]?i[t]:n}})}),s("ember-routing/system/controller_for",["exports"],function(e){"use strict" +function t(e,t,n){return e.lookup("controller:"+t,n)}e.default=t}),s("ember-routing/system/dsl",["exports","ember-utils","ember-metal"],function(e,t,n){"use strict" +function r(e){return e.parent&&"application"!==e.parent}function i(e,t,n){return r(e)&&n!==!0?e.parent+"."+t:t}function o(e,t,n,r){void 0===n&&(n={}) +var o=i(e,t,n.resetNamespace) +"string"!=typeof n.path&&(n.path="/"+t),e.push(n.path,o,r,n.serialize)}var s=0,a=function(){function e(e,t){this.parent=e,this.enableLoadingSubstates=t&&t.enableLoadingSubstates,this.matches=[],this.explicitIndex=void 0,this.options=t}return e.prototype.route=function(t,n,r){void 0===n&&(n={}) +var s="/_unused_dummy_error_path_route_"+t+"/:error" +if(2===arguments.length&&"function"==typeof n&&(r=n,n={}),this.enableLoadingSubstates&&(o(this,t+"_loading",{resetNamespace:n.resetNamespace}),o(this,t+"_error",{resetNamespace:n.resetNamespace,path:s})),r){var a=i(this,t,n.resetNamespace),u=new e(a,this.options) +o(u,"loading"),o(u,"error",{path:s}),r.call(u),o(this,t,n,u.generate())}else o(this,t,n)},e.prototype.push=function(e,n,r,i){var o=n.split(".") +if(this.options.engineInfo){var s=n.slice(this.options.engineInfo.fullName.length+1),a=t.assign({localFullName:s},this.options.engineInfo) +i&&(a.serializeMethod=i),this.options.addRouteForEngine(n,a)}else if(i)throw new Error("Defining a route serializer on route '"+n+"' outside an Engine is not allowed.") +""!==e&&"/"!==e&&"index"!==o[o.length-1]||(this.explicitIndex=!0),this.matches.push([e,n,r])},e.prototype.resource=function(e,t,n){void 0===t&&(t={}),2===arguments.length&&"function"==typeof t&&(n=t,t={}),t.resetNamespace=!0,this.route(e,t,n)},e.prototype.generate=function(){var e=this.matches +return this.explicitIndex||this.route("index",{path:"/"}),function(t){for(var n=0;n0&&(this.connections=[],n.run.once(this.router,"_setOutlets"))}}) +r.deprecateUnderscoreActions(w),w.reopenClass({isRouteFactory:!0}),e.default=w}),s("ember-routing/system/router",["exports","ember-utils","ember-console","ember-metal","ember-runtime","ember-routing/system/route","ember-routing/system/dsl","ember-routing/location/api","ember-routing/utils","ember-routing/system/router_state","container","router"],function(e,t,n,r,i,o,s,a,u,l,c,p){"use strict" +function h(){return this}function f(e,t,n){for(var r=!1,i=t.length-1;i>=0;--i){var o=t[i],s=o.handler +if(e===s&&(r=!0),r&&n(s)!==!0)return}}function d(e,t){var r=[],i=void 0 +i=e&&"object"==typeof e&&"object"==typeof e.errorThrown?e.errorThrown:e,t&&r.push(t),i&&(i.message&&r.push(i.message),i.stack&&r.push(i.stack),"string"==typeof i&&r.push(i)),n.default.error.apply(this,r)}function m(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s=o+"_"+n,a=e.fullRouteName,u=a+"_"+n +return g(i,r,s,u)?u:""}function v(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s="application"===o?n:o+"."+n,a=e.fullRouteName,u="application"===a?n:a+"."+n +return g(i,r,s,u)?u:""}function g(e,t,n,r){var i=t.hasRoute(r),o=e.hasRegistration("template:"+n)||e.hasRegistration("route:"+n) +return i&&o}function y(e,n,i){var o=i.shift() +if(!e){if(n)return +throw new r.Error("Can't trigger action '"+o+"' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.")}for(var s=!1,a=void 0,u=void 0,l=e.length-1;l>=0;l--)if(a=e[l],u=a.handler,u&&u.actions&&u.actions[o]){if(u.actions[o].apply(u,i)!==!0){if("error"===o){var c=t.guidFor(i[0]) +u.router._markErrorAsHandled(c)}return}s=!0}if(R[o])return void R[o].apply(null,i) +if(!s&&!n)throw new r.Error("Nothing handled the action '"+o+"'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.")}function b(e,t,n){for(var r=e.router,i=r.applyIntent(t,n),o=i.handlerInfos,s=i.params,a=0;a0;){var r=n.shift() +if(r.render.name===t)return r +var i=r.outlets +for(var o in i)n.push(i[o])}}function O(e,n,i){var o=void 0,s={render:i,outlets:new t.EmptyObject,wasUsed:!1} +return o=i.into?C(e,i.into):n,o?r.set(o.outlets,i.outlet,s):i.into?A(e,i.into,s):e=s,{liveRoutes:e,ownState:s}}function A(e,n,i){e.outlets.__ember_orphans__||(e.outlets.__ember_orphans__={render:{name:"__ember_orphans__"},outlets:new t.EmptyObject}),e.outlets.__ember_orphans__.outlets[n]=i,r.run.schedule("afterRender",function(){})}function S(e,t,n){var r=C(e,n.routeName) +return r?r:(t.outlets.main={render:{name:n.routeName,outlet:"main"},outlets:{}},t)}e.triggerEvent=y +var k=Array.prototype.slice,T=i.Object.extend(i.Evented,{location:"hash",rootURL:"/",_initRouterJs:function(){var e=this.router=new p.default +e.triggerEvent=y,e._triggerWillChangeContext=h,e._triggerWillLeave=h +var t=this.constructor.dslCallbacks||[h],n=this._buildDSL() +n.route("application",{path:"/",resetNamespace:!0,overrideNameAssertion:!0},function(){for(var e=0;e0)-(n<0)}function i(e,s){if(e===s)return 0 +var a=t.typeOf(e),u=t.typeOf(s) +if(n.default){if("instance"===a&&n.default.detect(e)&&e.constructor.compare)return e.constructor.compare(e,s) +if("instance"===u&&n.default.detect(s)&&s.constructor.compare)return s.constructor.compare(s,e)*-1}var l=r(o[a],o[u]) +if(0!==l)return l +switch(a){case"boolean":case"number":return r(e,s) +case"string":return r(e.localeCompare(s),0) +case"array":for(var c=e.length,p=s.length,h=Math.min(c,p),f=0;fn})}function h(e,n){return t.computed(e,function(){return t.get(this,e)>=n})}function f(e,n){return t.computed(e,function(){return t.get(this,e)=0)return o[a] +if(Array.isArray(e)){if(s=e.slice(),t)for(a=s.length;--a>=0;)s[a]=i(s[a],t,n,o)}else if(r.default&&r.default.detect(e))s=e.copy(t,n,o) +else if(e instanceof Date)s=new Date(e.getTime()) +else{s={} +for(u in e)Object.prototype.hasOwnProperty.call(e,u)&&"__"!==u.substring(0,2)&&(s[u]=t?i(e[u],t,n,o):e[u])}return t&&(n.push(e),o.push(s)),s}function o(e,t){return"object"!=typeof e||null===e?e:r.default&&r.default.detect(e)?e.copy(t):i(e,t,t?[]:null,t?[]:null)}e.default=o}),s("ember-runtime/ext/function",["exports","ember-environment","ember-metal"],function(e,t,n){"use strict" +var r=Array.prototype.slice,i=Function.prototype +t.ENV.EXTEND_PROTOTYPES.Function&&(i.property=function(){var e=n.computed(this) +return e.property.apply(e,arguments)},i.observes=function(){for(var e=arguments.length,t=Array(e),r=0;r1?n-1:0),i=1;i=0&&r>=0&&n.get(e,"hasEnumerableObservers")){o=[],s=t+r +for(var a=t;a=0&&i>=0&&n.get(e,"hasEnumerableObservers")){o=[] +for(var s=t+i,a=t;a=n.get(this,"length")))return n.get(this,e)},h.objectsAt=function(e){var t=this +return e.map(function(e){return u(t,e)})},h.nextObject=function(e){return u(this,e)},h["[]"]=n.computed({get:function(e){return this},set:function(e,t){return this.replace(0,n.get(this,"length"),t),this}}),h.firstObject=n.computed(function(){return u(this,0)}).readOnly(),h.lastObject=n.computed(function(){return u(this,n.get(this,"length")-1)}).readOnly(),h.contains=function(e){return this.indexOf(e)>=0},h.slice=function(e,t){var r=n.default.A(),i=n.get(this,"length") +for(n.isNone(e)&&(e=0),(n.isNone(t)||t>i)&&(t=i),e<0&&(e=i+e),t<0&&(t=i+t);e=r)&&(t=r-1),t<0&&(t+=r) +for(var i=t;i>=0;i--)if(u(this,i)===e)return i +return-1},h.addArrayObserver=function(e,t){return s(this,e,t)},h.removeArrayObserver=function(e,t){return a(this,e,t)},h.hasArrayObservers=n.computed(function(){return n.hasListeners(this,"@array:change")||n.hasListeners(this,"@array:before")}),h.arrayContentWillChange=function(e,t,n){return l(this,e,t,n)},h.arrayContentDidChange=function(e,t,n){return c(this,e,t,n)},h.includes=function(e,t){var r=n.get(this,"length") +void 0===t&&(t=0),t<0&&(t+=r) +for(var i=t;i1?t-1:0),r=1;r1?n-1:0),i=1;i=t.get(e,"length"))throw new t.Error(s) +void 0===r&&(r=1),e.replace(n,r,a)}return e}e.removeAt=o +var s="Index out of range",a=[] +e.default=t.Mixin.create(n.default,r.default,{replace:null,clear:function(){var e=t.get(this,"length") +return 0===e?this:(this.replace(0,e,a),this)},insertAt:function(e,n){if(e>t.get(this,"length"))throw new t.Error(s) +return this.replace(e,0,[n]),this},removeAt:function(e,t){return o(this,e,t)},pushObject:function(e){return this.insertAt(t.get(this,"length"),e),e},pushObjects:function(e){if(!i.default.detect(e)&&!Array.isArray(e))throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects") +return this.replace(t.get(this,"length"),0,e),this},popObject:function(){var e=t.get(this,"length") +if(0===e)return null +var r=n.objectAt(this,e-1) +return this.removeAt(e-1,1),r},shiftObject:function(){if(0===t.get(this,"length"))return null +var e=n.objectAt(this,0) +return this.removeAt(0),e},unshiftObject:function(e){return this.insertAt(0,e),e},unshiftObjects:function(e){return this.replace(0,0,e),this},reverseObjects:function(){var e=t.get(this,"length") +if(0===e)return this +var n=this.toArray().reverse() +return this.replace(0,e,n),this},setObjects:function(e){if(0===e.length)return this.clear() +var n=t.get(this,"length") +return this.replace(0,n,e),this},removeObject:function(e){for(var r=t.get(this,"length")||0;--r>=0;){var i=n.objectAt(this,r) +i===e&&this.removeAt(r)}return this},addObject:function(e){var t=this.includes(e) +return t||this.pushObject(e),this}})}),s("ember-runtime/mixins/mutable_enumerable",["exports","ember-runtime/mixins/enumerable","ember-metal"],function(e,t,n){"use strict" +e.default=n.Mixin.create(t.default,{addObject:null,addObjects:function(e){var t=this +return n.beginPropertyChanges(this),e.forEach(function(e){return t.addObject(e)}),n.endPropertyChanges(this),this},removeObject:null,removeObjects:function(e){n.beginPropertyChanges(this) +for(var t=e.length-1;t>=0;t--)this.removeObject(e[t]) +return n.endPropertyChanges(this),this}})}),s("ember-runtime/mixins/observable",["exports","ember-metal"],function(e,t){"use strict" +e.default=t.Mixin.create({get:function(e){return t.get(this,e)},getProperties:function(){for(var e=arguments.length,n=Array(e),r=0;rt.get(this,"content.length"))throw new t.Error(u) +return this._replace(e,0,[n]),this},insertAt:function(e,n){if(t.get(this,"arrangedContent")===t.get(this,"content"))return this._insertAt(e,n) +throw new t.Error("Using insertAt on an arranged ArrayProxy is not allowed.")},removeAt:function(e,n){if("number"==typeof e){var r=t.get(this,"content"),i=t.get(this,"arrangedContent"),o=[] +if(e<0||e>=t.get(this,"length"))throw new t.Error(u) +void 0===n&&(n=1) +for(var a=e;a0&&(r=[arguments[0]]),this.__defineNonEnumerable(t.GUID_KEY_PROPERTY) +var o=n.meta(this),s=o.proto +if(o.proto=this,r){var a=r +r=null +for(var u=this.concatenatedProperties,l=this.mergedProperties,p=0;p0&&u.indexOf(v)>=0){var _=this[v] +g=_?"function"==typeof _.concat?_.concat(g):t.makeArray(_).concat(g):t.makeArray(g)}if(l&&l.length&&l.indexOf(v)>=0){var w=this[v] +g=t.assign({},w,g)}b?b.set(this,v,g):"function"!=typeof this.setUnknownProperty||v in this?this[v]=g:this.setUnknownProperty(v,g)}}}c(this,o),this.init.apply(this,arguments),this[f](),o.proto=s,n.finishChains(this),n.sendEvent(this,"init")}return i.willReopen=function(){e&&(i.PrototypeMixin=n.Mixin.create(i.PrototypeMixin)),e=!1},i._initProperties=function(e){r=e},i.proto=function(){var t=i.superclass +return t&&t.proto(),e||(e=!0,i.PrototypeMixin.applyPartial(i.prototype)),this.prototype},i}() +return i.toString=n.Mixin.prototype.toString,i}var s,a,u=n.run.schedule,l=n.Mixin._apply,c=n.Mixin.finishPartial,p=n.Mixin.prototype.reopen,h=!1,f=t.symbol("POST_INIT") +e.POST_INIT=f +var d=o() +d.toString=function(){return"Ember.CoreObject"},d.PrototypeMixin=n.Mixin.create((s={reopen:function(){for(var e=arguments.length,t=Array(e),n=0;n" +return r},s)),d.PrototypeMixin.ownerConstructor=d,d.__super__=null +var m=(a={ClassMixin:n.REQUIRED,PrototypeMixin:n.REQUIRED,isClass:!0,isMethod:!1},a[t.NAME_KEY]=null,a[t.GUID_KEY]=null,a.extend=function(){var e=o(),r=void 0 +return e.ClassMixin=n.Mixin.create(this.ClassMixin),e.PrototypeMixin=n.Mixin.create(this.PrototypeMixin),e.ClassMixin.ownerConstructor=e,e.PrototypeMixin.ownerConstructor=e,p.apply(e.PrototypeMixin,arguments),e.superclass=this,e.__super__=this.prototype,r=e.prototype=Object.create(this.prototype),r.constructor=e,t.generateGuid(r),n.meta(r).proto=r,e.ClassMixin.apply(e),e},a.create=function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r0&&this._initProperties(n),new e},a.reopen=function(){return this.willReopen(),p.apply(this.PrototypeMixin,arguments),this},a.reopenClass=function(){return p.apply(this.ClassMixin,arguments),l(this,arguments,!1),this},a.detect=function(e){if("function"!=typeof e)return!1 +for(;e;){if(e===this)return!0 +e=e.superclass}return!1},a.detectInstance=function(e){return e instanceof this},a.metaForProperty=function(e){var t=this.proto(),n=t[e],r=null!==n&&"object"==typeof n&&n.isDescriptor?n:void 0 +return r._meta||{}},a._computedProperties=n.computed(function(){h=!0 +var e=this.proto(),t=void 0,n=[] +for(var r in e)t=e[r],t&&t.isDescriptor&&n.push({name:r,meta:t._meta}) +return n}).readOnly(),a.eachComputedProperty=function(e,t){for(var r=void 0,i={},o=n.get(this,"_computedProperties"),s=0;s=o;){var a=r.objectAt(e,s) +a&&(n._addBeforeObserver(a,t,i,"contentKeyWillChange"),n.addObserver(a,t,i,"contentKeyDidChange"))}}function s(e,t,i,o,s){for(;--s>=o;){var a=r.objectAt(e,s) +a&&(n._removeBeforeObserver(a,t,i,"contentKeyWillChange"),n.removeObserver(a,t,i,"contentKeyDidChange"))}}e.default=i,i.prototype={__defineNonEnumerable:function(e){this[e.name]=e.descriptor.value},arrayWillChange:function(e,t,r,i){var o=this._keys,a=r>0?t+r:-1 +for(var u in o)a>0&&s(e,u,this,t,a),n.propertyWillChange(this,u)},arrayDidChange:function(e,t,r,i){var s=this._keys,a=i>0?t+i:-1 +for(var u in s)a>0&&o(e,u,this,t,a),n.propertyDidChange(this,u)},willWatchProperty:function(e){this.beginObservingContentKey(e)},didUnwatchProperty:function(e){this.stopObservingContentKey(e)},beginObservingContentKey:function(e){var r=this._keys +if(r||(r=this._keys=new t.EmptyObject),r[e])r[e]++ +else{r[e]=1 +var i=this._content,s=n.get(i,"length") +o(i,e,this,0,s)}},stopObservingContentKey:function(e){var t=this._keys +if(t&&t[e]>0&&--t[e]<=0){var r=this._content,i=n.get(r,"length") +s(r,e,this,0,i)}},contentKeyWillChange:function(e,t){n.propertyWillChange(this,t)},contentKeyDidChange:function(e,t){n.propertyDidChange(this,t)}}}) +s("ember-runtime/system/lazy_load",["exports","ember-environment"],function(e,t){"use strict" +function n(e,t){var n=o[e] +i[e]=i[e]||[],i[e].push(t),n&&t(n)}function r(e,n){o[e]=n +var r=t.environment.window +if(r&&"function"==typeof CustomEvent){var s=new CustomEvent(e,{detail:n,name:e}) +r.dispatchEvent(s)}i[e]&&i[e].forEach(function(e){return e(n)})}e.onLoad=n,e.runLoadHooks=r +var i=t.ENV.EMBER_LOAD_HOOKS||{},o={},s=o +e._loaded=s}) +s("ember-runtime/system/namespace",["exports","ember-utils","ember-metal","ember-environment","ember-runtime/system/object"],function(e,t,n,r,i){"use strict" +function o(){return m}function s(e){m=!!e}function a(e,n,r){var i=e.length +g[e.join(".")]=n +for(var o in n)if(y.call(n,o)){var s=n[o] +if(e[i]=o,s&&s.toString===f&&!s[t.NAME_KEY])s[t.NAME_KEY]=e.join(".") +else if(s&&s.isNamespace){if(r[t.guidFor(s)])continue +r[t.guidFor(s)]=!0,a(e,s,r)}}e.length=i}function u(e){return e>=65&&e<=90}function l(e,t){try{var n=e[t] +return n&&n.isNamespace&&n}catch(e){}}function c(){if(!v.PROCESSED)for(var e=r.context.lookup,n=Object.keys(e),i=0;i2){i=new Array(arguments.length-1) +for(var o=1;o2)&&(t=Array.prototype.slice.call(arguments,1)),e=i.get(e)||e,o(e,t)}function u(e){return e.split(/\s+/)}function l(e){return R.get(e)}function c(e){return v.get(e)}function p(e){return b.get(e)}function h(e){return x.get(e)}function f(e){return A.get(e)}function d(e){return k.get(e)}var m=/[ _]/g,v=new t.Cache(1e3,function(e){return l(e).replace(m,"-")}),g=/(\-|\_|\.|\s)+(.)?/g,y=/(^|\/)([A-Z])/g,b=new t.Cache(1e3,function(e){return e.replace(g,function(e,t,n){return n?n.toUpperCase():""}).replace(y,function(e,t,n){return e.toLowerCase()})}),_=/^(\-|_)+(.)?/,w=/(.)(\-|\_|\.|\s)+(.)?/g,E=/(^|\/|\.)([a-z])/g,x=new t.Cache(1e3,function(e){for(var t=function(e,t,n){return n?"_"+n.toUpperCase():""},n=function(e,t,n,r){return t+(r?r.toUpperCase():"")},r=e.split("/"),i=0;i-1 +return e?function(e){return o.test(s.call(e))}:function(){return!0}}() +e.checkHasSuper=a,t.__hasSuper=!1}),s("ember-utils/symbol",["exports","ember-utils/guid","ember-utils/intern"],function(e,t,n){"use strict" +function r(e){var r=t.GUID_KEY+Math.floor(Math.random()*new Date) +return n.default("__"+e+"__ [id="+r+"]")}e.default=r}),s("ember-utils/to-string",["exports"],function(e){"use strict" +function t(e){return e&&"function"==typeof e.toString?e.toString():n.call(e)}e.default=t +var n=Object.prototype.toString}),s("ember-utils/weak-map-utils",["exports"],function(e){"use strict" +var t=function(){var e="function"==typeof WeakMap +if(!e)return!1 +var t=new WeakMap +return"[object WeakMap]"===Object.prototype.toString.call(t)}() +e.HAS_NATIVE_WEAKMAP=t}),s("ember-views/compat/attrs",["exports","ember-utils"],function(e,t){"use strict" +var n=t.symbol("MUTABLE_CELL") +e.MUTABLE_CELL=n}),s("ember-views/compat/fallback-view-registry",["exports","ember-utils"],function(e,t){"use strict" +e.default=t.dictionary(null)}),s("ember-views/component_lookup",["exports","ember-metal","ember-runtime","container"],function(e,t,n,r){"use strict" +e.default=n.Object.extend({componentFor:function(e,t,n){var i="component:"+e +return t[r.FACTORY_FOR](i,n)},layoutFor:function(e,t,n){var r="template:components/"+e +return t.lookup(r,n)}})}),s("ember-views/index",["exports","ember-views/system/ext","ember-views/system/jquery","ember-views/system/utils","ember-views/system/event_dispatcher","ember-views/component_lookup","ember-views/mixins/text_support","ember-views/views/core_view","ember-views/mixins/class_names_support","ember-views/mixins/child_views_support","ember-views/mixins/view_state_support","ember-views/mixins/view_support","ember-views/mixins/action_support","ember-views/compat/attrs","ember-views/system/lookup_partial","ember-views/utils/lookup-component","ember-views/system/action_manager","ember-views/compat/fallback-view-registry"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,d,m,v,g){"use strict" +e.jQuery=n.default,e.isSimpleClick=r.isSimpleClick,e.getViewBounds=r.getViewBounds,e.getViewClientRects=r.getViewClientRects,e.getViewBoundingClientRect=r.getViewBoundingClientRect,e.getRootViews=r.getRootViews,e.getChildViews=r.getChildViews,e.getViewId=r.getViewId,e.getViewElement=r.getViewElement,e.setViewElement=r.setViewElement,e.STYLE_WARNING=r.STYLE_WARNING,e.EventDispatcher=i.default,e.ComponentLookup=o.default,e.TextSupport=s.default,e.CoreView=a.default,e.ClassNamesSupport=u.default,e.ChildViewsSupport=l.default,e.ViewStateSupport=c.default,e.ViewMixin=p.default,e.dispatchLifeCycleHook=p.dispatchLifeCycleHook,e.ActionSupport=h.default,e.MUTABLE_CELL=f.MUTABLE_CELL,e.lookupPartial=d.default,e.hasPartial=d.hasPartial,e.lookupComponent=m.default,e.ActionManager=v.default,e.fallbackViewRegistry=g.default}),s("ember-views/mixins/action_support",["exports","ember-utils","ember-metal","ember-views/compat/attrs"],function(e,t,n,r){"use strict" +function i(e,t){return t&&t[r.MUTABLE_CELL]&&(t=t.value),t}e.default=n.Mixin.create({sendAction:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o1?t-1:0),i=1;i1 +return!t&&!n}function r(e){var t=e.lookup("-view-registry:main"),n=[] +return Object.keys(t).forEach(function(e){var r=t[e] +null===r.parentView&&n.push(r)}),n}function i(e){return""===e.tagName?t.guidFor(e):e.elementId||t.guidFor(e)}function o(e){return e[y]}function s(e){e[y]=null}function a(e,t){return e[y]=t}function u(e){var n=t.getOwner(e),r=n.lookup("-view-registry:main") +return p(e,r)}function l(e){e[b]=[]}function c(e,t){e[b].push(i(t))}function p(e,t){var n=[],r=[] +return e[b].forEach(function(e){var i=t[e] +!i||i.isDestroying||i.isDestroyed||n.indexOf(e)!==-1||(n.push(e),r.push(i))}),e[b]=n,r}function h(e){return e.renderer.getBounds(e)}function f(e){var t=h(e),n=document.createRange() +return n.setStartBefore(t.firstNode),n.setEndAfter(t.lastNode),n}function d(e){var t=f(e) +return t.getClientRects()}function m(e){var t=f(e) +return t.getBoundingClientRect()}function v(e,t){return _.call(e,t)}e.isSimpleClick=n,e.getRootViews=r,e.getViewId=i,e.getViewElement=o,e.initViewElement=s,e.setViewElement=a,e.getChildViews=u,e.initChildViews=l,e.addChildView=c,e.collectChildViews=p,e.getViewBounds=h,e.getViewRange=f,e.getViewClientRects=d,e.getViewBoundingClientRect=m,e.matches=v +var g="Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes." +e.STYLE_WARNING=g +var y=t.symbol("VIEW_ELEMENT"),b=t.symbol("CHILD_VIEW_IDS"),_="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector) +e.elMatches=_}),s("ember-views/utils/lookup-component",["exports","container"],function(e,t){"use strict" +function n(e,n,r,o){var s=e.componentFor(r,n,o),a=e.layoutFor(r,n,o),u={layout:a,component:s} +return a&&!s&&(u.component=n[t.FACTORY_FOR](t.privatize(i))),u}function r(e,t,r){var i=e.lookup("component-lookup:main"),o=r&&r.source +if(o){var s=n(i,e,t,r) +if(s.component||s.layout)return s}return n(i,e,t)}e.default=r +var i=babelHelpers.taggedTemplateLiteralLoose(["component:-default"],["component:-default"])}),s("ember-views/views/core_view",["exports","ember-runtime","ember-views/system/utils","ember-views/views/states"],function(e,t,n,r){"use strict" +var i=t.FrameworkObject.extend(t.Evented,t.ActionHandler,{isView:!0,_states:r.cloneStates(r.states),init:function(){if(this._super.apply(this,arguments),this._state="preRender",this._currentState=this._states.preRender,n.initViewElement(this),!this.renderer)throw new Error("Cannot instantiate a component without a renderer. Please ensure that you are creating "+this+" with a proper container/registry.")},parentView:null,instrumentDetails:function(e){return e.object=this.toString(),e.containerKey=this._debugContainerKey,e.view=this,e},trigger:function(){this._super.apply(this,arguments) +var e=arguments[0],t=this[e] +if(t){for(var n=new Array(arguments.length-1),r=1;r1?r-1:0),o=1;o]+) [^\/>]*\/>/gi,function(e,t){return e.slice(0,e.length-3)+">"})),e}function n(e,n){var r=t(e.innerHTML) +QUnit.push(r===n,r,n)}e.default=n +var r=function(){if(!document.createElementNS)return!1 +var e=document.createElement("div"),t=document.createElementNS("http://www.w3.org/2000/svg","svg") +e.appendChild(t) +var n=e.cloneNode(!0) +return''===n.innerHTML}()}),s("internal-test-helpers/equal-tokens",["exports","simple-html-tokenizer"],function(e,t){"use strict" +function n(e){return"string"==typeof e?{tokens:t.tokenize(e),html:e}:{tokens:t.tokenize(e.innerHTML),html:e.innerHTML}}function r(e){e.forEach(function(e){"StartTag"===e.type&&(e.attributes=e.attributes.sort(function(e,t){return e[0]>t[0]?1:e[0]"},e.create=n,e.extend=o,e.reopen=o,e.reopenClass=i,e}e.default=n +var r=0}),s("internal-test-helpers/index",["exports","internal-test-helpers/factory","internal-test-helpers/build-owner","internal-test-helpers/confirm-export","internal-test-helpers/equal-inner-html","internal-test-helpers/equal-tokens","internal-test-helpers/module-for","internal-test-helpers/strip","internal-test-helpers/apply-mixins","internal-test-helpers/matchers","internal-test-helpers/run","internal-test-helpers/test-groups","internal-test-helpers/test-cases/abstract","internal-test-helpers/test-cases/abstract-application","internal-test-helpers/test-cases/application","internal-test-helpers/test-cases/query-param","internal-test-helpers/test-cases/abstract-rendering","internal-test-helpers/test-cases/rendering","internal-test-helpers/test-cases/router"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,d,m,v,g,y){"use strict" +e.factory=t.default,e.buildOwner=n.default,e.confirmExport=r.default,e.equalInnerHTML=i.default,e.equalTokens=o.default,e.moduleFor=s.default,e.strip=a.default,e.applyMixins=u.default,e.equalsElement=l.equalsElement,e.classes=l.classes,e.styles=l.styles,e.regex=l.regex,e.runAppend=c.runAppend,e.runDestroy=c.runDestroy,e.testBoth=p.testBoth,e.testWithDefault=p.testWithDefault,e.AbstractTestCase=h.default,e.AbstractApplicationTestCase=f.default,e.ApplicationTestCase=d.default,e.QueryParamTestCase=m.default,e.AbstractRenderingTestCase=v.default,e.RenderingTestCase=g.default,e.RouterTestCase=y.default}),s("internal-test-helpers/matchers",["exports"],function(e){"use strict" +function t(e){return"object"==typeof e&&null!==e&&u in e}function n(e){var t +return t={},t[u]=!0,t.match=function(t){return e===t},t.expected=function(){return e},t.message=function(){return"should equal "+this.expected()},t}function r(e){var t +return t={},t[u]=!0,t.match=function(t){return e.test(t)},t.expected=function(){return e.toString()},t.message=function(){return"should match "+this.expected()},t}function i(e){var t +return t={},t[u]=!0,t.match=function(t){return t=t.trim(),t&&e.split(/\s+/).sort().join(" ")===t.trim().split(/\s+/).sort().join(" ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function o(e){var t +return t={},t[u]=!0,t.match=function(t){return t=t||"",t=t.trim(),e.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")===t.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function s(e,r,i,o){QUnit.push(e.tagName===r.toUpperCase(),e.tagName.toLowerCase(),r,"expect tagName to be "+r) +var s={},u=0 +for(var l in i){var c=i[l] +null!==c&&u++ +var p=t(c)?c:n(c) +s[l]=p,QUnit.push(s[l].match(e.getAttribute(l)),e.getAttribute(l),p.expected(),"Element's "+l+" attribute "+p.message())}for(var h={},f=0,d=e.attributes.length;f2?o-2:0),a=2;a1?t-1:0),r=1;re));)n=n.nextSibling +return n},e.prototype.$=function(e){return e?r.jQuery(e,this.element):r.jQuery(this.element)},e.prototype.textValue=function(){return this.$().text()},e.prototype.takeSnapshot=function(){for(var e=this.snapshot=[],t=this.element.firstChild;t;)a(t)||e.push(t),t=t.nextSibling +return e},e.prototype.assertText=function(e){this.assert.strictEqual(this.textValue(),e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertInnerHTML=function(e){i.default(this.element,e)},e.prototype.assertHTML=function(e){o.default(this.element,e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertElement=function(e,t){var n=t.ElementType,r=void 0===n?l:n,i=t.tagName,o=t.attrs,a=void 0===o?null:o,u=t.content,c=void 0===u?null:u +if(!(e instanceof r))throw new Error("Expecting a "+r.name+", but got "+e) +s.equalsElement(e,i,a,c)},e.prototype.assertComponentElement=function(e,n){var r=n.ElementType,i=void 0===r?l:r,o=n.tagName,a=void 0===o?"div":o,u=n.attrs,c=void 0===u?null:u,p=n.content,h=void 0===p?null:p +c=t.assign({},{id:s.regex(/^ember\d*$/),class:s.classes("ember-view")},c||{}),this.assertElement(e,{ElementType:i,tagName:a,attrs:c,content:h})},e.prototype.assertSameNode=function(e,t){this.assert.strictEqual(e,t,"DOM node stability")},e.prototype.assertInvariants=function(e,t){e=e||this.snapshot,t=t||this.takeSnapshot(),this.assert.strictEqual(t.length,e.length,"Same number of nodes") +for(var n=0;n0&&47===t.charCodeAt(0)&&(t=t.substr(1)) +for(var o=t.split("/"),s=0;s2&&"[]"===o.slice(s-2)&&(a=!0,o=o.slice(0,s-2),n[o]||(n[o]=[])),u=i[1]?v(i[1]):""),a?n[o].push(u):n[o]=u}return n},R.prototype.recognize=function(e){var t,n=[this.rootState],r={},i=!1,o=e.indexOf("#") +o!==-1&&(e=e.substr(0,o)) +var a=e.indexOf("?") +if(a!==-1){var u=e.substr(a+1,e.length) +e=e.substr(0,a),r=this.parseQueryString(u)}"/"!==e.charAt(0)&&(e="/"+e) +var l=e +R.ENCODE_AND_DECODE_PATH_SEGMENTS?e=s(e):(e=decodeURI(e),l=decodeURI(l)) +var c=e.length +c>1&&"/"===e.charAt(c-1)&&(e=e.substr(0,c-1),l=l.substr(0,l.length-1),i=!0) +for(var p=0;p0&&e[r-1]&&e[r-1].hasOwnProperty("queryParams")?(n=e[r-1].queryParams,t=z.call(e,0,r-1),[t,n]):[e,null]}function s(e){for(var t in e)if("number"==typeof e[t])e[t]=""+e[t] +else if(B(e[t]))for(var n=0,r=e[t].length;n=0;a--){var l=t[a],c=l.handler +if(c){if(c.events&&c.events[o]){if(c.events[o].apply(c,r)!==!0)return +s=!0}}else l.handlerPromise.then(u(null,i,o,r))}if("error"===o&&"UnrecognizedURLError"===r[0].name)throw r[0] +if(!s&&!n)throw new Error("Nothing handled the event '"+o+"'.")}function h(e,t){var n,r={all:{},changed:{},removed:{}} +i(r.all,t) +var o=!1 +s(e),s(t) +for(n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||(o=!0,r.removed[n]=e[n])) +for(n in t)if(t.hasOwnProperty(n))if(B(e[n])&&B(t[n]))if(e[n].length!==t[n].length)r.changed[n]=t[n],o=!0 +else for(var a=0,u=e[n].length;a=0;--u){var l=o[u] +i(a,l.params),l.handler.inaccessibleByURL&&(n=null)}if(n){a.queryParams=e._visibleQueryParams||t.queryParams +var c=r.recognizer.generate(s,a),p=e.isCausedByInitialTransition,h="replace"===n&&!e.isCausedByAbortingTransition +p||h?r.replaceURL(c):r.updateURL(c)}}}function j(e,t){try{a(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.") +var r=e.router,i=t.handlerInfos +return N(r,t,e),e.isAborted?(r.state.handlerInfos=r.currentHandlerInfos,n.Promise.reject(E(e))):(I(e,t,e.intent.url),e.isActive=!1,r.activeTransition=null,p(r,r.currentHandlerInfos,!0,["didTransition"]),r.didTransition&&r.didTransition(r.currentHandlerInfos),a(r,e.sequence,"TRANSITION COMPLETE."),i[i.length-1].handler)}catch(t){if(!(t instanceof b)){var o=e.state.handlerInfos +e.trigger(!0,"error",t,e,o[o.length-1].handler),e.abort()}throw t}}function L(e,t,n){var r=t[0]||"/",i=t[t.length-1],o={} +i&&i.hasOwnProperty("queryParams")&&(o=J.call(t).queryParams) +var s +if(0===t.length){a(e,"Updating query params") +var u=e.state.handlerInfos +s=new Q({name:u[u.length-1].name,contexts:[],queryParams:o})}else"/"===r.charAt(0)?(a(e,"Attempting URL transition to "+r),s=new Y({url:r})):(a(e,"Attempting transition to "+r),s=new Q({name:t[0],contexts:z.call(t,1),queryParams:o})) +return e.transitionByIntent(s,n)}function M(e,t){if(e.length!==t.length)return!1 +for(var n=0,r=e.length;n=r.length?r.length-1:t.resolveIndex +return n.Promise.reject({error:e,handlerWithError:u.handlerInfos[i].handler,wasAborted:l,state:u})}function o(e){var n=u.handlerInfos[t.resolveIndex].isResolved +if(u.handlerInfos[t.resolveIndex++]=e,!n){var i=e.handler +v(i,"redirect",e.context,t)}return r().then(s,null,u.promiseLabel("Resolve handler"))}function s(){if(t.resolveIndex===u.handlerInfos.length)return{error:null,state:u} +var e=u.handlerInfos[t.resolveIndex] +return e.resolve(r,t).then(o,null,u.promiseLabel("Proceed"))}var a=this.params +c(this.handlerInfos,function(e){a[e.name]=e.params||{}}),t=t||{},t.resolveIndex=0 +var u=this,l=!1 +return n.Promise.resolve(null,this.promiseLabel("Start transition")).then(s,null,this.promiseLabel("Resolve handler")).catch(i,this.promiseLabel("Handle error"))}},b.prototype=q(Error.prototype),_.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:!1,isTransition:!0,isExiting:function(e){for(var t=this.handlerInfos,n=0,r=t.length;n=0;--u){var f=t[u],d=f.handler,m=e.handlerInfos[u],v=null +if(f.names.length>0)if(u>=h)v=this.createParamHandlerInfo(d,n,f.names,p,m) +else{var g=a(d) +v=this.getHandlerInfoForDynamicSegment(d,n,f.names,p,m,r,u,g)}else v=this.createParamHandlerInfo(d,n,f.names,p,m) +if(s){v=v.becomeResolved(null,v.context) +var b=m&&m.context +f.names.length>0&&v.context===b&&(v.params=m&&m.params),v.context=b}var _=m;(u>=h||v.shouldSupercede(m))&&(h=Math.min(u,h),_=v),o&&!s&&(_=_.becomeResolved(null,_.context)),c.handlerInfos.unshift(_)}if(p.length>0)throw new Error("More context objects were passed than there are dynamic segments for the route: "+r) +return o||this.invalidateChildren(c.handlerInfos,h),i(c.queryParams,this.queryParams||{}),c},invalidateChildren:function(e,t){for(var n=t,r=e.length;n0){if(u=r[r.length-1],l(u))return this.createParamHandlerInfo(e,t,n,r,i) +r.pop()}else{if(i&&i.name===e)return i +if(!this.preTransitionState)return i +var c=this.preTransitionState.handlerInfos[s] +u=c&&c.context}return A("object",{name:e,getHandler:t,serializer:a,context:u,names:n})},createParamHandlerInfo:function(e,t,n,r,i){for(var o={},s=n.length;s--;){var a=i&&e===i.name&&i.params||{},u=r[r.length-1],c=n[s] +if(l(u))o[c]=""+r.pop() +else{if(!a.hasOwnProperty(c))throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e) +o[c]=a[c]}}return A("param",{name:e,getHandler:t,params:o})}}) +S.prototype=q(Error.prototype) +var Y=d(x,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,t,n){function r(e){if(e&&e.inaccessibleByURL)throw new S(c) +return e}var o,s,a=new y,u=t.recognize(this.url) +if(!u)throw new S(this.url) +var l=!1,c=this.url +for(o=0,s=u.length;o=0&&r;--n){var i=t[n] +e.add(t,{as:i.handler}),r="/"===i.path||""===i.path||".index"===i.handler.slice(-6)}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,t,n,r){var i=this +if(R(this,r,e),!t&&this.activeTransition)return this.activeTransition +var o=new _(this) +return o.queryParamsOnly=!0,n.queryParams=F(this,r.handlerInfos,r.queryParams,o),o.promise=o.promise.then(function(e){return I(o,n,!0),i.didTransition&&i.didTransition(i.currentHandlerInfos),e},null,f("Transition complete")),o},transitionByIntent:function(e){try{return T.apply(this,arguments)}catch(t){return new _(this,e,null,t)}},reset:function(){this.state&&c(this.state.handlerInfos.slice().reverse(),function(e){var t=e.handler +v(t,"exit")}),this.oldState=void 0,this.state=new y,this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var t=z.call(arguments) +return"/"!==e.charAt(0)&&(t[0]="/"+e),L(this,t).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return L(this,arguments)},intermediateTransitionTo:function(){return L(this,arguments,!0)},refresh:function(e){for(var t=this.activeTransition?this.activeTransition.state:this.state,n=t.handlerInfos,r={},i=0,o=n.length;i1)throw new Error("Second argument not supported") +if("object"!=typeof e)throw new TypeError("Argument must be an object") +return a.prototype=e,new a},Ae=[],Se=void 0,ke=1,Te=2,Re=new C,Ne=new C +R.prototype._validateInput=function(e){return xe(e)},R.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},R.prototype._init=function(){this._result=new Array(this.length)},R.prototype._enumerate=function(){for(var e=this.length,t=this.promise,n=this._input,r=0;t._state===Se&&r= timers[middle]) { - start = middle + 2; - } else { - end = middle; - } - } + NodeDOMTreeConstruction.prototype.setAttribute = function setAttribute(element, name, value) { + element.setAttribute(name, value); + }; - return (time >= timers[start]) ? start + 2 : start; -} + return NodeDOMTreeConstruction; + })(_glimmerRuntime.DOMTreeConstruction); -function Queue(name, options, globalOptions) { - this.name = name; - this.globalOptions = globalOptions || {}; - this.options = options; - this._queue = []; - this.targetQueues = {}; - this._queueBeingFlushed = undefined; -} + exports.NodeDOMTreeConstruction = NodeDOMTreeConstruction; +}); +enifed("@glimmer/reference", ["exports", "@glimmer/util"], function (exports, _glimmerUtil) { + "use strict"; -Queue.prototype = { - push: function(target, method, args, stack) { - var queue = this._queue; - queue.push(target, method, args, stack); + var CONSTANT = 0; + var INITIAL = 1; + var VOLATILE = NaN; - return { - queue: this, - target: target, - method: method - }; - }, + var RevisionTag = (function () { + function RevisionTag() {} - pushUniqueWithoutGuid: function(target, method, args, stack) { - var queue = this._queue; + RevisionTag.prototype.validate = function validate(snapshot) { + return this.value() === snapshot; + }; - for (var i = 0, l = queue.length; i < l; i += 4) { - var currentTarget = queue[i]; - var currentMethod = queue[i+1]; + return RevisionTag; + })(); - if (currentTarget === target && currentMethod === method) { - queue[i+2] = args; // replace args - queue[i+3] = stack; // replace stack - return; - } - } + var $REVISION = INITIAL; - queue.push(target, method, args, stack); - }, + var DirtyableTag = (function (_RevisionTag) { + babelHelpers.inherits(DirtyableTag, _RevisionTag); - targetQueue: function(targetQueue, target, method, args, stack) { - var queue = this._queue; + function DirtyableTag() { + var revision = arguments.length <= 0 || arguments[0] === undefined ? $REVISION : arguments[0]; - for (var i = 0, l = targetQueue.length; i < l; i += 2) { - var currentMethod = targetQueue[i]; - var currentIndex = targetQueue[i + 1]; + _RevisionTag.call(this); + this.revision = revision; + } - if (currentMethod === method) { - queue[currentIndex + 2] = args; // replace args - queue[currentIndex + 3] = stack; // replace stack - return; - } - } + DirtyableTag.prototype.value = function value() { + return this.revision; + }; - targetQueue.push( - method, - queue.push(target, method, args, stack) - 4 - ); - }, + DirtyableTag.prototype.dirty = function dirty() { + this.revision = ++$REVISION; + }; - pushUniqueWithGuid: function(guid, target, method, args, stack) { - var hasLocalQueue = this.targetQueues[guid]; + return DirtyableTag; + })(RevisionTag); - if (hasLocalQueue) { - this.targetQueue(hasLocalQueue, target, method, args, stack); - } else { - this.targetQueues[guid] = [ - method, - this._queue.push(target, method, args, stack) - 4 - ]; + function combineTagged(tagged) { + var optimized = []; + for (var i = 0, l = tagged.length; i < l; i++) { + var tag = tagged[i].tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function combineSlice(slice) { + var optimized = []; + var node = slice.head(); + while (node !== null) { + var tag = node.tag; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag !== CONSTANT_TAG) optimized.push(tag); + node = slice.nextNode(node); + } + return _combine(optimized); + } + function combine(tags) { + var optimized = []; + for (var i = 0, l = tags.length; i < l; i++) { + var tag = tags[i]; + if (tag === VOLATILE_TAG) return VOLATILE_TAG; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); + } + return _combine(optimized); + } + function _combine(tags) { + switch (tags.length) { + case 0: + return CONSTANT_TAG; + case 1: + return tags[0]; + case 2: + return new TagsPair(tags[0], tags[1]); + default: + return new TagsCombinator(tags); + } + ; } - return { - queue: this, - target: target, - method: method - }; - }, + var CachedTag = (function (_RevisionTag2) { + babelHelpers.inherits(CachedTag, _RevisionTag2); - pushUnique: function(target, method, args, stack) { - var KEY = this.globalOptions.GUID_KEY; + function CachedTag() { + _RevisionTag2.apply(this, arguments); + this.lastChecked = null; + this.lastValue = null; + } - if (target && KEY) { - var guid = target[KEY]; - if (guid) { - return this.pushUniqueWithGuid(guid, target, method, args, stack); - } - } + CachedTag.prototype.value = function value() { + var lastChecked = this.lastChecked; + var lastValue = this.lastValue; - this.pushUniqueWithoutGuid(target, method, args, stack); + if (lastChecked !== $REVISION) { + this.lastChecked = $REVISION; + this.lastValue = lastValue = this.compute(); + } + return this.lastValue; + }; - return { - queue: this, - target: target, - method: method - }; - }, + CachedTag.prototype.invalidate = function invalidate() { + this.lastChecked = null; + }; - invoke: function(target, method, args /*, onError, errorRecordedForStack */) { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - }, + return CachedTag; + })(RevisionTag); - invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { - try { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - } catch(error) { - onError(error, errorRecordedForStack); - } - }, + var TagsPair = (function (_CachedTag) { + babelHelpers.inherits(TagsPair, _CachedTag); - flush: function(sync) { - var queue = this._queue; - var length = queue.length; + function TagsPair(first, second) { + _CachedTag.call(this); + this.first = first; + this.second = second; + } - if (length === 0) { - return; - } + TagsPair.prototype.compute = function compute() { + return Math.max(this.first.value(), this.second.value()); + }; - var globalOptions = this.globalOptions; - var options = this.options; - var before = options && options.before; - var after = options && options.after; - var onError = globalOptions.onError || (globalOptions.onErrorTarget && - globalOptions.onErrorTarget[globalOptions.onErrorMethod]); - var target, method, args, errorRecordedForStack; - var invoke = onError ? this.invokeWithOnError : this.invoke; + return TagsPair; + })(CachedTag); - this.targetQueues = Object.create(null); - var queueItems = this._queueBeingFlushed = this._queue.slice(); - this._queue = []; + var TagsCombinator = (function (_CachedTag2) { + babelHelpers.inherits(TagsCombinator, _CachedTag2); - if (before) { - before(); - } + function TagsCombinator(tags) { + _CachedTag2.call(this); + this.tags = tags; + } - for (var i = 0; i < length; i += 4) { - target = queueItems[i]; - method = queueItems[i+1]; - args = queueItems[i+2]; - errorRecordedForStack = queueItems[i+3]; // Debugging assistance + TagsCombinator.prototype.compute = function compute() { + var tags = this.tags; - if (isString(method)) { - method = target[method]; - } + var max = -1; + for (var i = 0; i < tags.length; i++) { + var value = tags[i].value(); + max = Math.max(value, max); + } + return max; + }; - // method could have been nullified / canceled during flush - if (method) { - // - // ** Attention intrepid developer ** - // - // To find out the stack of this task when it was scheduled onto - // the run loop, add the following to your app.js: - // - // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. - // - // Once that is in place, when you are at a breakpoint and navigate - // here in the stack explorer, you can look at `errorRecordedForStack.stack`, - // which will be the captured stack when this job was scheduled. - // - // One possible long-term solution is the following Chrome issue: - // https://bugs.chromium.org/p/chromium/issues/detail?id=332624 - // - invoke(target, method, args, onError, errorRecordedForStack); - } - } + return TagsCombinator; + })(CachedTag); - if (after) { - after(); - } + var UpdatableTag = (function (_CachedTag3) { + babelHelpers.inherits(UpdatableTag, _CachedTag3); - this._queueBeingFlushed = undefined; + function UpdatableTag(tag) { + _CachedTag3.call(this); + this.tag = tag; + this.lastUpdated = INITIAL; + } - if (sync !== false && - this._queue.length > 0) { - // check if new items have been added - this.flush(true); - } - }, + ////////// - cancel: function(actionToCancel) { - var queue = this._queue, currentTarget, currentMethod, i, l; - var target = actionToCancel.target; - var method = actionToCancel.method; - var GUID_KEY = this.globalOptions.GUID_KEY; + UpdatableTag.prototype.compute = function compute() { + return Math.max(this.lastUpdated, this.tag.value()); + }; - if (GUID_KEY && this.targetQueues && target) { - var targetQueue = this.targetQueues[target[GUID_KEY]]; + UpdatableTag.prototype.update = function update(tag) { + if (tag !== this.tag) { + this.tag = tag; + this.lastUpdated = $REVISION; + this.invalidate(); + } + }; - if (targetQueue) { - for (i = 0, l = targetQueue.length; i < l; i++) { - if (targetQueue[i] === method) { - targetQueue.splice(i, 1); - } + return UpdatableTag; + })(CachedTag); + + var CONSTANT_TAG = new ((function (_RevisionTag3) { + babelHelpers.inherits(ConstantTag, _RevisionTag3); + + function ConstantTag() { + _RevisionTag3.apply(this, arguments); } - } - } - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; + ConstantTag.prototype.value = function value() { + return CONSTANT; + }; - if (currentTarget === target && - currentMethod === method) { - queue.splice(i, 4); - return true; - } - } + return ConstantTag; + })(RevisionTag))(); + var VOLATILE_TAG = new ((function (_RevisionTag4) { + babelHelpers.inherits(VolatileTag, _RevisionTag4); - // if not found in current queue - // could be in the queue that is being flushed - queue = this._queueBeingFlushed; + function VolatileTag() { + _RevisionTag4.apply(this, arguments); + } - if (!queue) { - return; - } + VolatileTag.prototype.value = function value() { + return VOLATILE; + }; - for (i = 0, l = queue.length; i < l; i += 4) { - currentTarget = queue[i]; - currentMethod = queue[i+1]; + return VolatileTag; + })(RevisionTag))(); + var CURRENT_TAG = new ((function (_DirtyableTag) { + babelHelpers.inherits(CurrentTag, _DirtyableTag); - if (currentTarget === target && - currentMethod === method) { - // don't mess with array during flush - // just nullify the method - queue[i+1] = null; - return true; - } - } - } -}; + function CurrentTag() { + _DirtyableTag.apply(this, arguments); + } -function DeferredActionQueues(queueNames, options) { - var queues = this.queues = {}; - this.queueNames = queueNames = queueNames || []; + CurrentTag.prototype.value = function value() { + return $REVISION; + }; - this.options = options; + return CurrentTag; + })(DirtyableTag))(); - each(queueNames, function(queueName) { - queues[queueName] = new Queue(queueName, options[queueName], options); - }); -} + var CachedReference = (function () { + function CachedReference() { + this.lastRevision = null; + this.lastValue = null; + } -function noSuchQueue(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist'); -} + CachedReference.prototype.value = function value() { + var tag = this.tag; + var lastRevision = this.lastRevision; + var lastValue = this.lastValue; -function noSuchMethod(name) { - throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist'); -} + if (!lastRevision || !tag.validate(lastRevision)) { + lastValue = this.lastValue = this.compute(); + this.lastRevision = tag.value(); + } + return lastValue; + }; -DeferredActionQueues.prototype = { - schedule: function(name, target, method, args, onceFlag, stack) { - var queues = this.queues; - var queue = queues[name]; + CachedReference.prototype.invalidate = function invalidate() { + this.lastRevision = null; + }; - if (!queue) { - noSuchQueue(name); - } + return CachedReference; + })(); - if (!method) { - noSuchMethod(name); - } + var MapperReference = (function (_CachedReference) { + babelHelpers.inherits(MapperReference, _CachedReference); - if (onceFlag) { - return queue.pushUnique(target, method, args, stack); - } else { - return queue.push(target, method, args, stack); - } - }, + function MapperReference(reference, mapper) { + _CachedReference.call(this); + this.tag = reference.tag; + this.reference = reference; + this.mapper = mapper; + } - flush: function() { - var queues = this.queues; - var queueNames = this.queueNames; - var queueName, queue; - var queueNameIndex = 0; - var numberOfQueues = queueNames.length; + MapperReference.prototype.compute = function compute() { + var reference = this.reference; + var mapper = this.mapper; - while (queueNameIndex < numberOfQueues) { - queueName = queueNames[queueNameIndex]; - queue = queues[queueName]; + return mapper(reference.value()); + }; - var numberOfQueueItems = queue._queue.length; + return MapperReference; + })(CachedReference); - if (numberOfQueueItems === 0) { - queueNameIndex++; - } else { - queue.flush(false /* async */); - queueNameIndex = 0; - } + function map(reference, mapper) { + return new MapperReference(reference, mapper); } - } -}; - -function Backburner(queueNames, options) { - this.queueNames = queueNames; - this.options = options || {}; - if (!this.options.defaultQueue) { - this.options.defaultQueue = queueNames[0]; - } - this.instanceStack = []; - this._debouncees = []; - this._throttlers = []; - this._eventCallbacks = { - end: [], - begin: [] - }; - - var _this = this; - this._boundClearItems = function() { - clearItems(); - }; - - this._timerTimeoutId = undefined; - this._timers = []; + ////////// - this._platform = this.options._platform || { - setTimeout: function (fn, ms) { - return setTimeout(fn, ms); - }, - clearTimeout: function (id) { - clearTimeout(id); - } - }; + var ReferenceCache = (function () { + function ReferenceCache(reference) { + this.lastValue = null; + this.lastRevision = null; + this.initialized = false; + this.tag = reference.tag; + this.reference = reference; + } - this._boundRunExpiredTimers = function () { - _this._runExpiredTimers(); - }; -} + ReferenceCache.prototype.peek = function peek() { + if (!this.initialized) { + return this.initialize(); + } + return this.lastValue; + }; -Backburner.prototype = { - begin: function() { - var options = this.options; - var onBegin = options && options.onBegin; - var previousInstance = this.currentInstance; + ReferenceCache.prototype.revalidate = function revalidate() { + if (!this.initialized) { + return this.initialize(); + } + var reference = this.reference; + var lastRevision = this.lastRevision; - if (previousInstance) { - this.instanceStack.push(previousInstance); - } + var tag = reference.tag; + if (tag.validate(lastRevision)) return NOT_MODIFIED; + this.lastRevision = tag.value(); + var lastValue = this.lastValue; - this.currentInstance = new DeferredActionQueues(this.queueNames, options); - this._trigger('begin', this.currentInstance, previousInstance); - if (onBegin) { - onBegin(this.currentInstance, previousInstance); - } - }, + var value = reference.value(); + if (value === lastValue) return NOT_MODIFIED; + this.lastValue = value; + return value; + }; - end: function() { - var options = this.options; - var onEnd = options && options.onEnd; - var currentInstance = this.currentInstance; - var nextInstance = null; + ReferenceCache.prototype.initialize = function initialize() { + var reference = this.reference; - // Prevent double-finally bug in Safari 6.0.2 and iOS 6 - // This bug appears to be resolved in Safari 6.0.5 and iOS 7 - var finallyAlreadyCalled = false; - try { - currentInstance.flush(); - } finally { - if (!finallyAlreadyCalled) { - finallyAlreadyCalled = true; + var value = this.lastValue = reference.value(); + this.lastRevision = reference.tag.value(); + this.initialized = true; + return value; + }; - this.currentInstance = null; + return ReferenceCache; + })(); - if (this.instanceStack.length) { - nextInstance = this.instanceStack.pop(); - this.currentInstance = nextInstance; - } - this._trigger('end', currentInstance, nextInstance); - if (onEnd) { - onEnd(currentInstance, nextInstance); - } - } + var NOT_MODIFIED = "adb3b78e-3d22-4e4b-877a-6317c2c5c145"; + function isModified(value) { + return value !== NOT_MODIFIED; } - }, - /** - Trigger an event. Supports up to two arguments. Designed around - triggering transition events from one run loop instance to the - next, which requires an argument for the first instance and then - an argument for the next instance. + var ConstReference = (function () { + function ConstReference(inner) { + this.inner = inner; + this.tag = CONSTANT_TAG; + } - @private - @method _trigger - @param {String} eventName - @param {any} arg1 - @param {any} arg2 - */ - _trigger: function(eventName, arg1, arg2) { - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - for (var i = 0; i < callbacks.length; i++) { - callbacks[i](arg1, arg2); - } - } - }, + ConstReference.prototype.value = function value() { + return this.inner; + }; - on: function(eventName, callback) { - if (typeof callback !== 'function') { - throw new TypeError('Callback must be a function'); - } - var callbacks = this._eventCallbacks[eventName]; - if (callbacks) { - callbacks.push(callback); - } else { - throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist'); - } - }, + return ConstReference; + })(); - off: function(eventName, callback) { - if (eventName) { - var callbacks = this._eventCallbacks[eventName]; - var callbackFound = false; - if (!callbacks) return; - if (callback) { - for (var i = 0; i < callbacks.length; i++) { - if (callbacks[i] === callback) { - callbackFound = true; - callbacks.splice(i, 1); - i--; - } - } - } - if (!callbackFound) { - throw new TypeError('Cannot off() callback that does not exist'); - } - } else { - throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist'); + function isConst(reference) { + return reference.tag === CONSTANT_TAG; } - }, - - run: function(/* target, method, args */) { - var length = arguments.length; - var method, target, args; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + var ListItem = (function (_ListNode) { + babelHelpers.inherits(ListItem, _ListNode); - if (isString(method)) { - method = target[method]; - } + function ListItem(iterable, result) { + _ListNode.call(this, iterable.valueReferenceFor(result)); + this.retained = false; + this.seen = false; + this.key = result.key; + this.iterable = iterable; + this.memo = iterable.memoReferenceFor(result); + } - if (length > 2) { - args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - } else { - args = []; - } + ListItem.prototype.update = function update(item) { + this.retained = true; + this.iterable.updateValueReference(this.value, item); + this.iterable.updateMemoReference(this.memo, item); + }; - var onError = getOnError(this.options); + ListItem.prototype.shouldRemove = function shouldRemove() { + return !this.retained; + }; - this.begin(); + ListItem.prototype.reset = function reset() { + this.retained = false; + this.seen = false; + }; - // guard against Safari 6's double-finally bug - var didFinally = false; + return ListItem; + })(_glimmerUtil.ListNode); - if (onError) { - try { - return method.apply(target, args); - } catch(error) { - onError(error); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); - } - } - } else { - try { - return method.apply(target, args); - } finally { - if (!didFinally) { - didFinally = true; - this.end(); + var IterationArtifacts = (function () { + function IterationArtifacts(iterable) { + this.map = _glimmerUtil.dict(); + this.list = new _glimmerUtil.LinkedList(); + this.tag = iterable.tag; + this.iterable = iterable; } - } - } - }, - /* - Join the passed method with an existing queue and execute immediately, - if there isn't one use `Backburner#run`. + IterationArtifacts.prototype.isEmpty = function isEmpty() { + var iterator = this.iterator = this.iterable.iterate(); + return iterator.isEmpty(); + }; - The join method is like the run method except that it will schedule into - an existing queue if one already exists. In either case, the join method will - immediately execute the passed in function and return its result. + IterationArtifacts.prototype.iterate = function iterate() { + var iterator = this.iterator || this.iterable.iterate(); + this.iterator = null; + return iterator; + }; - @method join - @param {Object} target - @param {Function} method The method to be executed - @param {any} args The method arguments - @return method result - */ - join: function(/* target, method, args */) { - if (!this.currentInstance) { - return this.run.apply(this, arguments); - } + IterationArtifacts.prototype.has = function has(key) { + return !!this.map[key]; + }; - var length = arguments.length; - var method, target; + IterationArtifacts.prototype.get = function get(key) { + return this.map[key]; + }; - if (length === 1) { - method = arguments[0]; - target = null; - } else { - target = arguments[0]; - method = arguments[1]; - } + IterationArtifacts.prototype.wasSeen = function wasSeen(key) { + var node = this.map[key]; + return node && node.seen; + }; - if (isString(method)) { - method = target[method]; - } + IterationArtifacts.prototype.append = function append(item) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - if (length === 1) { - return method(); - } else if (length === 2) { - return method.call(target); - } else { - var args = new Array(length - 2); - for (var i = 0, l = length - 2; i < l; i++) { - args[i] = arguments[i + 2]; - } - return method.apply(target, args); - } - }, + var node = map[item.key] = new ListItem(iterable, item); + list.append(node); + return node; + }; + IterationArtifacts.prototype.insertBefore = function insertBefore(item, reference) { + var map = this.map; + var list = this.list; + var iterable = this.iterable; - /* - Defer the passed function to run inside the specified queue. + var node = map[item.key] = new ListItem(iterable, item); + node.retained = true; + list.insertBefore(node, reference); + return node; + }; - @method defer - @param {String} queueName - @param {Object} target - @param {Function|String} method The method or method name to be executed - @param {any} args The method arguments - @return method result - */ - defer: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + IterationArtifacts.prototype.move = function move(item, reference) { + var list = this.list; - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; - } + item.retained = true; + list.remove(item); + list.insertBefore(item, reference); + }; - if (isString(method)) { - method = target[method]; - } + IterationArtifacts.prototype.remove = function remove(item) { + var list = this.list; - var stack = this.DEBUG ? new Error() : undefined; + list.remove(item); + delete this.map[item.key]; + }; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + IterationArtifacts.prototype.nextNode = function nextNode(item) { + return this.list.nextNode(item); + }; - if (!this.currentInstance) { createAutorun(this); } - return this.currentInstance.schedule(queueName, target, method, args, false, stack); - }, + IterationArtifacts.prototype.head = function head() { + return this.list.head(); + }; - deferOnce: function(queueName /* , target, method, args */) { - var length = arguments.length; - var method, target, args; + return IterationArtifacts; + })(); - if (length === 2) { - method = arguments[1]; - target = null; - } else { - target = arguments[1]; - method = arguments[2]; - } + var ReferenceIterator = (function () { + // if anyone needs to construct this object with something other than + // an iterable, let @wycats know. - if (isString(method)) { - method = target[method]; - } + function ReferenceIterator(iterable) { + this.iterator = null; + var artifacts = new IterationArtifacts(iterable); + this.artifacts = artifacts; + } - var stack = this.DEBUG ? new Error() : undefined; + ReferenceIterator.prototype.next = function next() { + var artifacts = this.artifacts; - if (length > 3) { - args = new Array(length - 3); - for (var i = 3; i < length; i++) { - args[i-3] = arguments[i]; - } - } else { - args = undefined; - } + var iterator = this.iterator = this.iterator || artifacts.iterate(); + var item = iterator.next(); + if (!item) return null; + return artifacts.append(item); + }; - if (!this.currentInstance) { - createAutorun(this); - } - return this.currentInstance.schedule(queueName, target, method, args, true, stack); - }, + return ReferenceIterator; + })(); - setTimeout: function() { - var l = arguments.length; - var args = new Array(l); + var Phase; + (function (Phase) { + Phase[Phase["Append"] = 0] = "Append"; + Phase[Phase["Prune"] = 1] = "Prune"; + Phase[Phase["Done"] = 2] = "Done"; + })(Phase || (Phase = {})); - for (var x = 0; x < l; x++) { - args[x] = arguments[x]; - } + var IteratorSynchronizer = (function () { + function IteratorSynchronizer(_ref) { + var target = _ref.target; + var artifacts = _ref.artifacts; - var length = args.length, - method, wait, target, - methodOrTarget, methodOrWait, methodOrArgs; + this.target = target; + this.artifacts = artifacts; + this.iterator = artifacts.iterate(); + this.current = artifacts.head(); + } - if (length === 0) { - return; - } else if (length === 1) { - method = args.shift(); - wait = 0; - } else if (length === 2) { - methodOrTarget = args[0]; - methodOrWait = args[1]; + IteratorSynchronizer.prototype.sync = function sync() { + var phase = Phase.Append; + while (true) { + switch (phase) { + case Phase.Append: + phase = this.nextAppend(); + break; + case Phase.Prune: + phase = this.nextPrune(); + break; + case Phase.Done: + this.nextDone(); + return; + } + } + }; - if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { - target = args.shift(); - method = args.shift(); - wait = 0; - } else if (isCoercableNumber(methodOrWait)) { - method = args.shift(); - wait = args.shift(); - } else { - method = args.shift(); - wait = 0; - } - } else { - var last = args[args.length - 1]; + IteratorSynchronizer.prototype.advanceToKey = function advanceToKey(key) { + var current = this.current; + var artifacts = this.artifacts; - if (isCoercableNumber(last)) { - wait = args.pop(); - } else { - wait = 0; - } + var seek = current; + while (seek && seek.key !== key) { + seek.seen = true; + seek = artifacts.nextNode(seek); + } + this.current = seek && artifacts.nextNode(seek); + }; - methodOrTarget = args[0]; - methodOrArgs = args[1]; + IteratorSynchronizer.prototype.nextAppend = function nextAppend() { + var iterator = this.iterator; + var current = this.current; + var artifacts = this.artifacts; - if (isFunction(methodOrArgs) || (isString(methodOrArgs) && - methodOrTarget !== null && - methodOrArgs in methodOrTarget)) { - target = args.shift(); - method = args.shift(); - } else { - method = args.shift(); - } - } - - var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); - - if (isString(method)) { - method = target[method]; - } - - var onError = getOnError(this.options); + var item = iterator.next(); + if (item === null) { + return this.startPrune(); + } + var key = item.key; - function fn() { - if (onError) { - try { - method.apply(target, args); - } catch (e) { - onError(e); - } - } else { - method.apply(target, args); - } - } + if (current && current.key === key) { + this.nextRetain(item); + } else if (artifacts.has(key)) { + this.nextMove(item); + } else { + this.nextInsert(item); + } + return Phase.Append; + }; - return this._setTimeout(fn, executeAt); - }, + IteratorSynchronizer.prototype.nextRetain = function nextRetain(item) { + var artifacts = this.artifacts; + var current = this.current; - _setTimeout: function (fn, executeAt) { - if (this._timers.length === 0) { - this._timers.push(executeAt, fn); - this._installTimerTimeout(); - return fn; - } + current = _glimmerUtil.expect(current, 'BUG: current is empty'); + current.update(item); + this.current = artifacts.nextNode(current); + this.target.retain(item.key, current.value, current.memo); + }; - // find position to insert - var i = binarySearch(executeAt, this._timers); + IteratorSynchronizer.prototype.nextMove = function nextMove(item) { + var current = this.current; + var artifacts = this.artifacts; + var target = this.target; + var key = item.key; - this._timers.splice(i, 0, executeAt, fn); + var found = artifacts.get(item.key); + found.update(item); + if (artifacts.wasSeen(item.key)) { + artifacts.move(found, current); + target.move(found.key, found.value, found.memo, current ? current.key : null); + } else { + this.advanceToKey(key); + } + }; - // we should be the new earliest timer if i == 0 - if (i === 0) { - this._reinstallTimerTimeout(); - } + IteratorSynchronizer.prototype.nextInsert = function nextInsert(item) { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - return fn; - }, + var node = artifacts.insertBefore(item, current); + target.insert(node.key, node.value, node.memo, current ? current.key : null); + }; - throttle: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } - var immediate = args.pop(); - var wait, throttler, index, timer; + IteratorSynchronizer.prototype.startPrune = function startPrune() { + this.current = this.artifacts.head(); + return Phase.Prune; + }; - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = true; - } else { - wait = args.pop(); - } + IteratorSynchronizer.prototype.nextPrune = function nextPrune() { + var artifacts = this.artifacts; + var target = this.target; + var current = this.current; - wait = parseInt(wait, 10); + if (current === null) { + return Phase.Done; + } + var node = current; + this.current = artifacts.nextNode(node); + if (node.shouldRemove()) { + artifacts.remove(node); + target.delete(node.key); + } else { + node.reset(); + } + return Phase.Prune; + }; - index = findThrottler(target, method, this._throttlers); - if (index > -1) { return this._throttlers[index]; } // throttled + IteratorSynchronizer.prototype.nextDone = function nextDone() { + this.target.done(); + }; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findThrottler(target, method, backburner._throttlers); - if (index > -1) { - backburner._throttlers.splice(index, 1); - } - }, wait); + return IteratorSynchronizer; + })(); - if (immediate) { - this.run.apply(this, args); + function referenceFromParts(root, parts) { + var reference = root; + for (var i = 0; i < parts.length; i++) { + reference = reference.get(parts[i]); + } + return reference; } - throttler = [target, method, timer]; + exports.ConstReference = ConstReference; + exports.isConst = isConst; + exports.ListItem = ListItem; + exports.referenceFromParts = referenceFromParts; + exports.IterationArtifacts = IterationArtifacts; + exports.ReferenceIterator = ReferenceIterator; + exports.IteratorSynchronizer = IteratorSynchronizer; + exports.CONSTANT = CONSTANT; + exports.INITIAL = INITIAL; + exports.VOLATILE = VOLATILE; + exports.RevisionTag = RevisionTag; + exports.DirtyableTag = DirtyableTag; + exports.combineTagged = combineTagged; + exports.combineSlice = combineSlice; + exports.combine = combine; + exports.CachedTag = CachedTag; + exports.UpdatableTag = UpdatableTag; + exports.CONSTANT_TAG = CONSTANT_TAG; + exports.VOLATILE_TAG = VOLATILE_TAG; + exports.CURRENT_TAG = CURRENT_TAG; + exports.CachedReference = CachedReference; + exports.map = map; + exports.ReferenceCache = ReferenceCache; + exports.isModified = isModified; +}); +enifed('@glimmer/runtime',['exports','@glimmer/util','@glimmer/reference','@glimmer/wire-format'],function(exports,_glimmerUtil,_glimmerReference,_glimmerWireFormat){'use strict';var PrimitiveReference=(function(_ConstReference){babelHelpers.inherits(PrimitiveReference,_ConstReference);function PrimitiveReference(value){_ConstReference.call(this,value);}PrimitiveReference.create = function create(value){if(value === undefined){return UNDEFINED_REFERENCE;}else if(value === null){return NULL_REFERENCE;}else if(value === true){return TRUE_REFERENCE;}else if(value === false){return FALSE_REFERENCE;}else if(typeof value === 'number'){return new ValueReference(value);}else {return new StringReference(value);}};PrimitiveReference.prototype.get = function get(_key){return UNDEFINED_REFERENCE;};return PrimitiveReference;})(_glimmerReference.ConstReference);var StringReference=(function(_PrimitiveReference){babelHelpers.inherits(StringReference,_PrimitiveReference);function StringReference(){_PrimitiveReference.apply(this,arguments);this.lengthReference = null;}StringReference.prototype.get = function get(key){if(key === 'length'){var lengthReference=this.lengthReference;if(lengthReference === null){lengthReference = this.lengthReference = new ValueReference(this.inner.length);}return lengthReference;}else {return _PrimitiveReference.prototype.get.call(this,key);}};return StringReference;})(PrimitiveReference);var ValueReference=(function(_PrimitiveReference2){babelHelpers.inherits(ValueReference,_PrimitiveReference2);function ValueReference(value){_PrimitiveReference2.call(this,value);}return ValueReference;})(PrimitiveReference);var UNDEFINED_REFERENCE=new ValueReference(undefined);var NULL_REFERENCE=new ValueReference(null);var TRUE_REFERENCE=new ValueReference(true);var FALSE_REFERENCE=new ValueReference(false);var ConditionalReference=(function(){function ConditionalReference(inner){this.inner = inner;this.tag = inner.tag;}ConditionalReference.prototype.value = function value(){return this.toBool(this.inner.value());};ConditionalReference.prototype.toBool = function toBool(value){return !!value;};return ConditionalReference;})();var Constants=(function(){function Constants(){ // `0` means NULL +this.references = [];this.strings = [];this.expressions = [];this.arrays = [];this.slices = [];this.blocks = [];this.functions = [];this.others = [];this.NULL_REFERENCE = this.reference(NULL_REFERENCE);this.UNDEFINED_REFERENCE = this.reference(UNDEFINED_REFERENCE);}Constants.prototype.getReference = function getReference(value){return this.references[value - 1];};Constants.prototype.reference = function reference(value){var index=this.references.length;this.references.push(value);return index + 1;};Constants.prototype.getString = function getString(value){return this.strings[value - 1];};Constants.prototype.string = function string(value){var index=this.strings.length;this.strings.push(value);return index + 1;};Constants.prototype.getExpression = function getExpression(value){return this.expressions[value - 1];};Constants.prototype.expression = function expression(value){var index=this.expressions.length;this.expressions.push(value);return index + 1;};Constants.prototype.getArray = function getArray(value){return this.arrays[value - 1];};Constants.prototype.array = function array(values){var index=this.arrays.length;this.arrays.push(values);return index + 1;};Constants.prototype.getSlice = function getSlice(value){return this.slices[value - 1];};Constants.prototype.slice = function slice(_slice2){ // TODO: Put the entire program in one big array +var index=this.slices.length;this.slices.push(_slice2);return index + 1;};Constants.prototype.getBlock = function getBlock(value){return this.blocks[value - 1];};Constants.prototype.block = function block(_block2){var index=this.blocks.length;this.blocks.push(_block2);return index + 1;};Constants.prototype.getFunction = function getFunction(value){return this.functions[value - 1];};Constants.prototype.function = function _function(f){var index=this.functions.length;this.functions.push(f);return index + 1;};Constants.prototype.getOther = function getOther(value){return this.others[value - 1];};Constants.prototype.other = function other(_other){var index=this.others.length;this.others.push(_other);return index + 1;};return Constants;})();var AppendOpcodes=(function(){function AppendOpcodes(){this.evaluateOpcode = _glimmerUtil.fillNulls(51 /* EvaluatePartial */ + 1);}AppendOpcodes.prototype.add = function add(name,evaluate){this.evaluateOpcode[name] = evaluate;};AppendOpcodes.prototype.construct = function construct(name,_debug,op1,op2,op3){return [name | 0,(op1 || 0) | 0,(op2 || 0) | 0,(op3 || 0) | 0];};AppendOpcodes.prototype.evaluate = function evaluate(vm,opcode){_glimmerUtil.LOGGER.debug('[VM] OPCODE: ' + opcode.type);var func=this.evaluateOpcode[opcode.type];func(vm,opcode);};return AppendOpcodes;})();var APPEND_OPCODES=new AppendOpcodes();var AbstractOpcode=(function(){function AbstractOpcode(){_glimmerUtil.initializeGuid(this);}AbstractOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type};};return AbstractOpcode;})();var UpdatingOpcode=(function(_AbstractOpcode){babelHelpers.inherits(UpdatingOpcode,_AbstractOpcode);function UpdatingOpcode(){_AbstractOpcode.apply(this,arguments);this.next = null;this.prev = null;}return UpdatingOpcode;})(AbstractOpcode);APPEND_OPCODES.add(20, /* OpenBlock */function(vm,_ref){var _getBlock=_ref.op1;var _args=_ref.op2;var inner=vm.constants.getOther(_getBlock);var rawArgs=vm.constants.getExpression(_args);var args=null;var block=inner.evaluate(vm);if(block){args = rawArgs.evaluate(vm);} // FIXME: can we avoid doing this when we don't have a block? +vm.pushCallerScope();if(block){vm.invokeBlock(block,args || null);}});APPEND_OPCODES.add(21, /* CloseBlock */function(vm){return vm.popScope();});APPEND_OPCODES.add(0, /* PushChildScope */function(vm){return vm.pushChildScope();});APPEND_OPCODES.add(1, /* PopScope */function(vm){return vm.popScope();});APPEND_OPCODES.add(2, /* PushDynamicScope */function(vm){return vm.pushDynamicScope();});APPEND_OPCODES.add(3, /* PopDynamicScope */function(vm){return vm.popDynamicScope();});APPEND_OPCODES.add(4, /* Put */function(vm,_ref2){var reference=_ref2.op1;vm.frame.setOperand(vm.constants.getReference(reference));});APPEND_OPCODES.add(5, /* EvaluatePut */function(vm,_ref3){var expression=_ref3.op1;var expr=vm.constants.getExpression(expression);vm.evaluateOperand(expr);});APPEND_OPCODES.add(6, /* PutArgs */function(vm,_ref4){var args=_ref4.op1;vm.evaluateArgs(vm.constants.getExpression(args));});APPEND_OPCODES.add(7, /* BindPositionalArgs */function(vm,_ref5){var _symbols=_ref5.op1;var symbols=vm.constants.getArray(_symbols);vm.bindPositionalArgs(symbols);});APPEND_OPCODES.add(8, /* BindNamedArgs */function(vm,_ref6){var _names=_ref6.op1;var _symbols=_ref6.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindNamedArgs(names,symbols);});APPEND_OPCODES.add(9, /* BindBlocks */function(vm,_ref7){var _names=_ref7.op1;var _symbols=_ref7.op2;var names=vm.constants.getArray(_names);var symbols=vm.constants.getArray(_symbols);vm.bindBlocks(names,symbols);});APPEND_OPCODES.add(10, /* BindPartialArgs */function(vm,_ref8){var symbol=_ref8.op1;vm.bindPartialArgs(symbol);});APPEND_OPCODES.add(11, /* BindCallerScope */function(vm){return vm.bindCallerScope();});APPEND_OPCODES.add(12, /* BindDynamicScope */function(vm,_ref9){var _names=_ref9.op1;var names=vm.constants.getArray(_names);vm.bindDynamicScope(names);});APPEND_OPCODES.add(13, /* Enter */function(vm,_ref10){var slice=_ref10.op1;return vm.enter(slice);});APPEND_OPCODES.add(14, /* Exit */function(vm){return vm.exit();});APPEND_OPCODES.add(15, /* Evaluate */function(vm,_ref11){var _block=_ref11.op1;var block=vm.constants.getBlock(_block);var args=vm.frame.getArgs();vm.invokeBlock(block,args);});APPEND_OPCODES.add(16, /* Jump */function(vm,_ref12){var target=_ref12.op1;return vm.goto(target);});APPEND_OPCODES.add(17, /* JumpIf */function(vm,_ref13){var target=_ref13.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(18, /* JumpUnless */function(vm,_ref14){var target=_ref14.op1;var reference=vm.frame.getCondition();if(_glimmerReference.isConst(reference)){if(!reference.value()){vm.goto(target);}}else {var cache=new _glimmerReference.ReferenceCache(reference);if(!cache.peek()){vm.goto(target);}vm.updateWith(new Assert(cache));}});var ConstTest=function(ref,_env){return new _glimmerReference.ConstReference(!!ref.value());};var SimpleTest=function(ref,_env){return ref;};var EnvironmentTest=function(ref,env){return env.toConditionalReference(ref);};APPEND_OPCODES.add(19, /* Test */function(vm,_ref15){var _func=_ref15.op1;var operand=vm.frame.getOperand();var func=vm.constants.getFunction(_func);vm.frame.setCondition(func(operand,vm.env));});var Assert=(function(_UpdatingOpcode){babelHelpers.inherits(Assert,_UpdatingOpcode);function Assert(cache){_UpdatingOpcode.call(this);this.type = "assert";this.tag = cache.tag;this.cache = cache;}Assert.prototype.evaluate = function evaluate(vm){var cache=this.cache;if(_glimmerReference.isModified(cache.revalidate())){vm.throw();}};Assert.prototype.toJSON = function toJSON(){var type=this.type;var _guid=this._guid;var cache=this.cache;var expected=undefined;try{expected = JSON.stringify(cache.peek());}catch(e) {expected = String(cache.peek());}return {guid:_guid,type:type,args:[],details:{expected:expected}};};return Assert;})(UpdatingOpcode);var JumpIfNotModifiedOpcode=(function(_UpdatingOpcode2){babelHelpers.inherits(JumpIfNotModifiedOpcode,_UpdatingOpcode2);function JumpIfNotModifiedOpcode(tag,target){_UpdatingOpcode2.call(this);this.target = target;this.type = "jump-if-not-modified";this.tag = tag;this.lastRevision = tag.value();}JumpIfNotModifiedOpcode.prototype.evaluate = function evaluate(vm){var tag=this.tag;var target=this.target;var lastRevision=this.lastRevision;if(!vm.alwaysRevalidate && tag.validate(lastRevision)){vm.goto(target);}};JumpIfNotModifiedOpcode.prototype.didModify = function didModify(){this.lastRevision = this.tag.value();};JumpIfNotModifiedOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.target.inspect())]};};return JumpIfNotModifiedOpcode;})(UpdatingOpcode);var DidModifyOpcode=(function(_UpdatingOpcode3){babelHelpers.inherits(DidModifyOpcode,_UpdatingOpcode3);function DidModifyOpcode(target){_UpdatingOpcode3.call(this);this.target = target;this.type = "did-modify";this.tag = _glimmerReference.CONSTANT_TAG;}DidModifyOpcode.prototype.evaluate = function evaluate(){this.target.didModify();};return DidModifyOpcode;})(UpdatingOpcode);var LabelOpcode=(function(){function LabelOpcode(label){this.tag = _glimmerReference.CONSTANT_TAG;this.type = "label";this.label = null;this.prev = null;this.next = null;_glimmerUtil.initializeGuid(this);if(label)this.label = label;}LabelOpcode.prototype.evaluate = function evaluate(){};LabelOpcode.prototype.inspect = function inspect(){return this.label + ' [' + this._guid + ']';};LabelOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.inspect())]};};return LabelOpcode;})();var EMPTY_ARRAY=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze([]):[];var EMPTY_DICT=_glimmerUtil.HAS_NATIVE_WEAKMAP?Object.freeze(_glimmerUtil.dict()):_glimmerUtil.dict();var CompiledPositionalArgs=(function(){function CompiledPositionalArgs(values){this.values = values;this.length = values.length;}CompiledPositionalArgs.create = function create(values){if(values.length){return new this(values);}else {return COMPILED_EMPTY_POSITIONAL_ARGS;}};CompiledPositionalArgs.empty = function empty(){return COMPILED_EMPTY_POSITIONAL_ARGS;};CompiledPositionalArgs.prototype.evaluate = function evaluate(vm){var values=this.values;var length=this.length;var references=new Array(length);for(var i=0;i < length;i++) {references[i] = values[i].evaluate(vm);}return EvaluatedPositionalArgs.create(references);};CompiledPositionalArgs.prototype.toJSON = function toJSON(){return '[' + this.values.map(function(value){return value.toJSON();}).join(", ") + ']';};return CompiledPositionalArgs;})();var COMPILED_EMPTY_POSITIONAL_ARGS=new ((function(_CompiledPositionalArgs){babelHelpers.inherits(_class,_CompiledPositionalArgs);function _class(){_CompiledPositionalArgs.call(this,EMPTY_ARRAY);}_class.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_POSITIONAL_ARGS;};_class.prototype.toJSON = function toJSON(){return '';};return _class;})(CompiledPositionalArgs))();var EvaluatedPositionalArgs=(function(){function EvaluatedPositionalArgs(values){this.values = values;this.tag = _glimmerReference.combineTagged(values);this.length = values.length;}EvaluatedPositionalArgs.create = function create(values){return new this(values);};EvaluatedPositionalArgs.empty = function empty(){return EVALUATED_EMPTY_POSITIONAL_ARGS;};EvaluatedPositionalArgs.prototype.at = function at(index){var values=this.values;var length=this.length;return index < length?values[index]:UNDEFINED_REFERENCE;};EvaluatedPositionalArgs.prototype.value = function value(){var values=this.values;var length=this.length;var ret=new Array(length);for(var i=0;i < length;i++) {ret[i] = values[i].value();}return ret;};return EvaluatedPositionalArgs;})();var EVALUATED_EMPTY_POSITIONAL_ARGS=new ((function(_EvaluatedPositionalArgs){babelHelpers.inherits(_class2,_EvaluatedPositionalArgs);function _class2(){_EvaluatedPositionalArgs.call(this,EMPTY_ARRAY);}_class2.prototype.at = function at(){return UNDEFINED_REFERENCE;};_class2.prototype.value = function value(){return this.values;};return _class2;})(EvaluatedPositionalArgs))();var CompiledNamedArgs=(function(){function CompiledNamedArgs(keys,values){this.keys = keys;this.values = values;this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}CompiledNamedArgs.empty = function empty(){return COMPILED_EMPTY_NAMED_ARGS;};CompiledNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=[];for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values);}else {return COMPILED_EMPTY_NAMED_ARGS;}};CompiledNamedArgs.prototype.evaluate = function evaluate(vm){var keys=this.keys;var values=this.values;var length=this.length;var evaluated=new Array(length);for(var i=0;i < length;i++) {evaluated[i] = values[i].evaluate(vm);}return new EvaluatedNamedArgs(keys,evaluated);};CompiledNamedArgs.prototype.toJSON = function toJSON(){var keys=this.keys;var values=this.values;var inner=keys.map(function(key,i){return key + ': ' + values[i].toJSON();}).join(", ");return '{' + inner + '}';};return CompiledNamedArgs;})();var COMPILED_EMPTY_NAMED_ARGS=new ((function(_CompiledNamedArgs){babelHelpers.inherits(_class3,_CompiledNamedArgs);function _class3(){_CompiledNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY);}_class3.prototype.evaluate = function evaluate(_vm){return EVALUATED_EMPTY_NAMED_ARGS;};_class3.prototype.toJSON = function toJSON(){return '';};return _class3;})(CompiledNamedArgs))();var EvaluatedNamedArgs=(function(){function EvaluatedNamedArgs(keys,values){var _map=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];this.keys = keys;this.values = values;this._map = _map;this.tag = _glimmerReference.combineTagged(values);this.length = keys.length;_glimmerUtil.assert(keys.length === values.length,'Keys and values do not have the same length');}EvaluatedNamedArgs.create = function create(map){var keys=Object.keys(map);var length=keys.length;if(length > 0){var values=new Array(length);for(var i=0;i < length;i++) {values[i] = map[keys[i]];}return new this(keys,values,map);}else {return EVALUATED_EMPTY_NAMED_ARGS;}};EvaluatedNamedArgs.empty = function empty(){return EVALUATED_EMPTY_NAMED_ARGS;};EvaluatedNamedArgs.prototype.get = function get(key){var keys=this.keys;var values=this.values;var index=keys.indexOf(key);return index === -1?UNDEFINED_REFERENCE:values[index];};EvaluatedNamedArgs.prototype.has = function has(key){return this.keys.indexOf(key) !== -1;};EvaluatedNamedArgs.prototype.value = function value(){var keys=this.keys;var values=this.values;var out=_glimmerUtil.dict();for(var i=0;i < keys.length;i++) {var key=keys[i];var ref=values[i];out[key] = ref.value();}return out;};babelHelpers.createClass(EvaluatedNamedArgs,[{key:'map',get:function(){var map=this._map;if(map){return map;}map = this._map = _glimmerUtil.dict();var keys=this.keys;var values=this.values;var length=this.length;for(var i=0;i < length;i++) {map[keys[i]] = values[i];}return map;}}]);return EvaluatedNamedArgs;})();var EVALUATED_EMPTY_NAMED_ARGS=new ((function(_EvaluatedNamedArgs){babelHelpers.inherits(_class4,_EvaluatedNamedArgs);function _class4(){_EvaluatedNamedArgs.call(this,EMPTY_ARRAY,EMPTY_ARRAY,EMPTY_DICT);}_class4.prototype.get = function get(){return UNDEFINED_REFERENCE;};_class4.prototype.has = function has(_key){return false;};_class4.prototype.value = function value(){return EMPTY_DICT;};return _class4;})(EvaluatedNamedArgs))();var EMPTY_BLOCKS={default:null,inverse:null};var CompiledArgs=(function(){function CompiledArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.type = "compiled-args";}CompiledArgs.create = function create(positional,named,blocks){if(positional === COMPILED_EMPTY_POSITIONAL_ARGS && named === COMPILED_EMPTY_NAMED_ARGS && blocks === EMPTY_BLOCKS){return this.empty();}else {return new this(positional,named,blocks);}};CompiledArgs.empty = function empty(){return COMPILED_EMPTY_ARGS;};CompiledArgs.prototype.evaluate = function evaluate(vm){var positional=this.positional;var named=this.named;var blocks=this.blocks;return EvaluatedArgs.create(positional.evaluate(vm),named.evaluate(vm),blocks);};return CompiledArgs;})();var COMPILED_EMPTY_ARGS=new ((function(_CompiledArgs){babelHelpers.inherits(_class5,_CompiledArgs);function _class5(){_CompiledArgs.call(this,COMPILED_EMPTY_POSITIONAL_ARGS,COMPILED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);}_class5.prototype.evaluate = function evaluate(_vm){return EMPTY_EVALUATED_ARGS;};return _class5;})(CompiledArgs))();var EvaluatedArgs=(function(){function EvaluatedArgs(positional,named,blocks){this.positional = positional;this.named = named;this.blocks = blocks;this.tag = _glimmerReference.combineTagged([positional,named]);}EvaluatedArgs.empty = function empty(){return EMPTY_EVALUATED_ARGS;};EvaluatedArgs.create = function create(positional,named,blocks){return new this(positional,named,blocks);};EvaluatedArgs.positional = function positional(values){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EvaluatedPositionalArgs.create(values),EVALUATED_EMPTY_NAMED_ARGS,blocks);};EvaluatedArgs.named = function named(map){var blocks=arguments.length <= 1 || arguments[1] === undefined?EMPTY_BLOCKS:arguments[1];return new this(EVALUATED_EMPTY_POSITIONAL_ARGS,EvaluatedNamedArgs.create(map),blocks);};return EvaluatedArgs;})();var EMPTY_EVALUATED_ARGS=new EvaluatedArgs(EVALUATED_EMPTY_POSITIONAL_ARGS,EVALUATED_EMPTY_NAMED_ARGS,EMPTY_BLOCKS);APPEND_OPCODES.add(22, /* PutDynamicComponent */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(23, /* PutComponent */function(vm,_ref16){var _component=_ref16.op1;var definition=vm.constants.getOther(_component);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(24, /* OpenComponent */function(vm,_ref17){var _args=_ref17.op1;var _shadow=_ref17.op2;var rawArgs=vm.constants.getExpression(_args);var shadow=vm.constants.getBlock(_shadow);var definition=vm.frame.getImmediate();var dynamicScope=vm.pushDynamicScope();var callerScope=vm.scope();var manager=definition.manager;var args=manager.prepareArgs(definition,rawArgs.evaluate(vm),dynamicScope);var hasDefaultBlock=!!args.blocks.default; // TODO Cleanup? +var component=manager.create(vm.env,definition,args,dynamicScope,vm.getSelf(),hasDefaultBlock);var destructor=manager.getDestructor(component);if(destructor)vm.newDestroyable(destructor);var layout=manager.layoutFor(definition,component,vm.env);var selfRef=manager.getSelf(component);vm.beginCacheGroup();vm.stack().pushSimpleBlock();vm.pushRootScope(selfRef,layout.symbols);vm.invokeLayout(args,layout,callerScope,component,manager,shadow);vm.updateWith(new UpdateComponentOpcode(definition.name,component,manager,args,dynamicScope));}); // export class DidCreateElementOpcode extends Opcode { +// public type = "did-create-element"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let action = 'DidCreateElementOpcode#evaluate'; +// manager.didCreateElement(component, vm.stack().expectConstructing(action), vm.stack().expectOperations(action)); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +APPEND_OPCODES.add(25, /* DidCreateElement */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var action='DidCreateElementOpcode#evaluate';manager.didCreateElement(component,vm.stack().expectConstructing(action),vm.stack().expectOperations(action));}); // export class ShadowAttributesOpcode extends Opcode { +// public type = "shadow-attributes"; +// evaluate(vm: VM) { +// let shadow = vm.frame.getShadow(); +// vm.pushCallerScope(); +// if (!shadow) return; +// vm.invokeBlock(shadow, EvaluatedArgs.empty()); +// } +// toJSON(): OpcodeJSON { +// return { +// guid: this._guid, +// type: this.type, +// args: ["$ARGS"] +// }; +// } +// } +// Slow path for non-specialized component invocations. Uses an internal +// named lookup on the args. +APPEND_OPCODES.add(26, /* ShadowAttributes */function(vm){var shadow=vm.frame.getShadow();vm.pushCallerScope();if(!shadow)return;vm.invokeBlock(shadow,EvaluatedArgs.empty());}); // export class DidRenderLayoutOpcode extends Opcode { +// public type = "did-render-layout"; +// evaluate(vm: VM) { +// let manager = vm.frame.getManager(); +// let component = vm.frame.getComponent(); +// let bounds = vm.stack().popBlock(); +// manager.didRenderLayout(component, bounds); +// vm.env.didCreate(component, manager); +// vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); +// } +// } +APPEND_OPCODES.add(27, /* DidRenderLayout */function(vm){var manager=vm.frame.getManager();var component=vm.frame.getComponent();var bounds=vm.stack().popBlock();manager.didRenderLayout(component,bounds);vm.env.didCreate(component,manager);vm.updateWith(new DidUpdateLayoutOpcode(manager,component,bounds));}); // export class CloseComponentOpcode extends Opcode { +// public type = "close-component"; +// evaluate(vm: VM) { +// vm.popScope(); +// vm.popDynamicScope(); +// vm.commitCacheGroup(); +// } +// } +APPEND_OPCODES.add(28, /* CloseComponent */function(vm){vm.popScope();vm.popDynamicScope();vm.commitCacheGroup();});var UpdateComponentOpcode=(function(_UpdatingOpcode4){babelHelpers.inherits(UpdateComponentOpcode,_UpdatingOpcode4);function UpdateComponentOpcode(name,component,manager,args,dynamicScope){_UpdatingOpcode4.call(this);this.name = name;this.component = component;this.manager = manager;this.args = args;this.dynamicScope = dynamicScope;this.type = "update-component";var componentTag=manager.getTag(component);if(componentTag){this.tag = _glimmerReference.combine([args.tag,componentTag]);}else {this.tag = args.tag;}}UpdateComponentOpcode.prototype.evaluate = function evaluate(_vm){var component=this.component;var manager=this.manager;var args=this.args;var dynamicScope=this.dynamicScope;manager.update(component,args,dynamicScope);};UpdateComponentOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.name)]};};return UpdateComponentOpcode;})(UpdatingOpcode);var DidUpdateLayoutOpcode=(function(_UpdatingOpcode5){babelHelpers.inherits(DidUpdateLayoutOpcode,_UpdatingOpcode5);function DidUpdateLayoutOpcode(manager,component,bounds){_UpdatingOpcode5.call(this);this.manager = manager;this.component = component;this.bounds = bounds;this.type = "did-update-layout";this.tag = _glimmerReference.CONSTANT_TAG;}DidUpdateLayoutOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var component=this.component;var bounds=this.bounds;manager.didUpdateLayout(component,bounds);vm.env.didUpdate(component,manager);};return DidUpdateLayoutOpcode;})(UpdatingOpcode);var Cursor=function Cursor(element,nextSibling){this.element = element;this.nextSibling = nextSibling;};var ConcreteBounds=(function(){function ConcreteBounds(parentNode,first,last){this.parentNode = parentNode;this.first = first;this.last = last;}ConcreteBounds.prototype.parentElement = function parentElement(){return this.parentNode;};ConcreteBounds.prototype.firstNode = function firstNode(){return this.first;};ConcreteBounds.prototype.lastNode = function lastNode(){return this.last;};return ConcreteBounds;})();var SingleNodeBounds=(function(){function SingleNodeBounds(parentNode,node){this.parentNode = parentNode;this.node = node;}SingleNodeBounds.prototype.parentElement = function parentElement(){return this.parentNode;};SingleNodeBounds.prototype.firstNode = function firstNode(){return this.node;};SingleNodeBounds.prototype.lastNode = function lastNode(){return this.node;};return SingleNodeBounds;})();function single(parent,node){return new SingleNodeBounds(parent,node);}function moveBounds(bounds,reference){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.insertBefore(node,reference);if(node === last)return next;node = next;}return null;}function clear(bounds){var parent=bounds.parentElement();var first=bounds.firstNode();var last=bounds.lastNode();var node=first;while(node) {var next=node.nextSibling;parent.removeChild(node);if(node === last)return next;node = next;}return null;}function isSafeString(value){return !!value && typeof value['toHTML'] === 'function';}function isNode(value){return value !== null && typeof value === 'object' && typeof value['nodeType'] === 'number';}function isString(value){return typeof value === 'string';}var Upsert=function Upsert(bounds){this.bounds = bounds;};function cautiousInsert(dom,cursor,value){if(isString(value)){return TextUpsert.insert(dom,cursor,value);}if(isSafeString(value)){return SafeStringUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}function trustingInsert(dom,cursor,value){if(isString(value)){return HTMLUpsert.insert(dom,cursor,value);}if(isNode(value)){return NodeUpsert.insert(dom,cursor,value);}throw _glimmerUtil.unreachable();}var TextUpsert=(function(_Upsert){babelHelpers.inherits(TextUpsert,_Upsert);TextUpsert.insert = function insert(dom,cursor,value){var textNode=dom.createTextNode(value);dom.insertBefore(cursor.element,textNode,cursor.nextSibling);var bounds=new SingleNodeBounds(cursor.element,textNode);return new TextUpsert(bounds,textNode);};function TextUpsert(bounds,textNode){_Upsert.call(this,bounds);this.textNode = textNode;}TextUpsert.prototype.update = function update(_dom,value){if(isString(value)){var textNode=this.textNode;textNode.nodeValue = value;return true;}else {return false;}};return TextUpsert;})(Upsert);var HTMLUpsert=(function(_Upsert2){babelHelpers.inherits(HTMLUpsert,_Upsert2);function HTMLUpsert(){_Upsert2.apply(this,arguments);}HTMLUpsert.insert = function insert(dom,cursor,value){var bounds=dom.insertHTMLBefore(cursor.element,value,cursor.nextSibling);return new HTMLUpsert(bounds);};HTMLUpsert.prototype.update = function update(dom,value){if(isString(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,value);return true;}else {return false;}};return HTMLUpsert;})(Upsert);var SafeStringUpsert=(function(_Upsert3){babelHelpers.inherits(SafeStringUpsert,_Upsert3);function SafeStringUpsert(bounds,lastStringValue){_Upsert3.call(this,bounds);this.lastStringValue = lastStringValue;}SafeStringUpsert.insert = function insert(dom,cursor,value){var stringValue=value.toHTML();var bounds=dom.insertHTMLBefore(cursor.element,stringValue,cursor.nextSibling);return new SafeStringUpsert(bounds,stringValue);};SafeStringUpsert.prototype.update = function update(dom,value){if(isSafeString(value)){var stringValue=value.toHTML();if(stringValue !== this.lastStringValue){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertHTMLBefore(parentElement,nextSibling,stringValue);this.lastStringValue = stringValue;}return true;}else {return false;}};return SafeStringUpsert;})(Upsert);var NodeUpsert=(function(_Upsert4){babelHelpers.inherits(NodeUpsert,_Upsert4);function NodeUpsert(){_Upsert4.apply(this,arguments);}NodeUpsert.insert = function insert(dom,cursor,node){dom.insertBefore(cursor.element,node,cursor.nextSibling);return new NodeUpsert(single(cursor.element,node));};NodeUpsert.prototype.update = function update(dom,value){if(isNode(value)){var bounds=this.bounds;var parentElement=bounds.parentElement();var nextSibling=clear(bounds);this.bounds = dom.insertNodeBefore(parentElement,value,nextSibling);return true;}else {return false;}};return NodeUpsert;})(Upsert);var COMPONENT_DEFINITION_BRAND='COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]';function isComponentDefinition(obj){return typeof obj === 'object' && obj && obj[COMPONENT_DEFINITION_BRAND];}var ComponentDefinition=function ComponentDefinition(name,manager,ComponentClass){this[COMPONENT_DEFINITION_BRAND] = true;this.name = name;this.manager = manager;this.ComponentClass = ComponentClass;};var CompiledExpression=(function(){function CompiledExpression(){}CompiledExpression.prototype.toJSON = function toJSON(){return 'UNIMPL: ' + this.type.toUpperCase();};return CompiledExpression;})();APPEND_OPCODES.add(29, /* Text */function(vm,_ref18){var text=_ref18.op1;vm.stack().appendText(vm.constants.getString(text));});APPEND_OPCODES.add(30, /* Comment */function(vm,_ref19){var text=_ref19.op1;vm.stack().appendComment(vm.constants.getString(text));});APPEND_OPCODES.add(32, /* OpenElement */function(vm,_ref20){var tag=_ref20.op1;vm.stack().openElement(vm.constants.getString(tag));});APPEND_OPCODES.add(33, /* PushRemoteElement */function(vm){var reference=vm.frame.getOperand();var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var element=cache?cache.peek():reference.value();vm.stack().pushRemoteElement(element);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(34, /* PopRemoteElement */function(vm){return vm.stack().popRemoteElement();});APPEND_OPCODES.add(35, /* OpenComponentElement */function(vm,_ref21){var _tag=_ref21.op1;var tag=vm.constants.getString(_tag);vm.stack().openElement(tag,new ComponentElementOperations(vm.env));});APPEND_OPCODES.add(36, /* OpenDynamicElement */function(vm){var tagName=vm.frame.getOperand().value();vm.stack().openElement(tagName);});var ClassList=(function(){function ClassList(){this.list = null;this.isConst = true;}ClassList.prototype.append = function append(reference){var list=this.list;var isConst$$=this.isConst;if(list === null)list = this.list = [];list.push(reference);this.isConst = isConst$$ && _glimmerReference.isConst(reference);};ClassList.prototype.toReference = function toReference(){var list=this.list;var isConst$$=this.isConst;if(!list)return NULL_REFERENCE;if(isConst$$)return PrimitiveReference.create(toClassName(list));return new ClassListReference(list);};return ClassList;})();var ClassListReference=(function(_CachedReference){babelHelpers.inherits(ClassListReference,_CachedReference);function ClassListReference(list){_CachedReference.call(this);this.list = [];this.tag = _glimmerReference.combineTagged(list);this.list = list;}ClassListReference.prototype.compute = function compute(){return toClassName(this.list);};return ClassListReference;})(_glimmerReference.CachedReference);function toClassName(list){var ret=[];for(var i=0;i < list.length;i++) {var value=list[i].value();if(value !== false && value !== null && value !== undefined)ret.push(value);}return ret.length === 0?null:ret.join(' ');}var SimpleElementOperations=(function(){function SimpleElementOperations(env){this.env = env;this.opcodes = null;this.classList = null;}SimpleElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else {this.env.getAppendOperations().setAttribute(element,name,value);}};SimpleElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){this.env.getAppendOperations().setAttribute(element,name,value,namespace);};SimpleElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else {var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(attribute);}};SimpleElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(nsAttribute);};SimpleElementOperations.prototype.flush = function flush(element,vm){var env=vm.env;var opcodes=this.opcodes;var classList=this.classList;for(var i=0;opcodes && i < opcodes.length;i++) {vm.updateWith(opcodes[i]);}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}this.opcodes = null;this.classList = null;};SimpleElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};SimpleElementOperations.prototype.addAttribute = function addAttribute(attribute){var opcode=attribute.flush(this.env);if(opcode){var opcodes=this.opcodes;if(!opcodes){opcodes = this.opcodes = [];}opcodes.push(opcode);}};return SimpleElementOperations;})();var ComponentElementOperations=(function(){function ComponentElementOperations(env){this.env = env;this.attributeNames = null;this.attributes = null;this.classList = null;}ComponentElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element,name,value){if(name === 'class'){this.addClass(PrimitiveReference.create(value));}else if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value));}};ComponentElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element,namespace,name,value){if(this.shouldAddAttribute(name)){this.addAttribute(name,new StaticAttribute(element,name,value,namespace));}};ComponentElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element,name,reference,isTrusting){if(name === 'class'){this.addClass(reference);}else if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting);var attribute=new DynamicAttribute(element,attributeManager,name,reference);this.addAttribute(name,attribute);}};ComponentElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element,namespace,name,reference,isTrusting){if(this.shouldAddAttribute(name)){var attributeManager=this.env.attributeFor(element,name,isTrusting,namespace);var nsAttribute=new DynamicAttribute(element,attributeManager,name,reference,namespace);this.addAttribute(name,nsAttribute);}};ComponentElementOperations.prototype.flush = function flush(element,vm){var env=this.env;var attributes=this.attributes;var classList=this.classList;for(var i=0;attributes && i < attributes.length;i++) {var opcode=attributes[i].flush(env);if(opcode){vm.updateWith(opcode);}}if(classList){var attributeManager=env.attributeFor(element,'class',false);var attribute=new DynamicAttribute(element,attributeManager,'class',classList.toReference());var opcode=attribute.flush(env);if(opcode){vm.updateWith(opcode);}}};ComponentElementOperations.prototype.shouldAddAttribute = function shouldAddAttribute(name){return !this.attributeNames || this.attributeNames.indexOf(name) === -1;};ComponentElementOperations.prototype.addClass = function addClass(reference){var classList=this.classList;if(!classList){classList = this.classList = new ClassList();}classList.append(reference);};ComponentElementOperations.prototype.addAttribute = function addAttribute(name,attribute){var attributeNames=this.attributeNames;var attributes=this.attributes;if(!attributeNames){attributeNames = this.attributeNames = [];attributes = this.attributes = [];}attributeNames.push(name);_glimmerUtil.unwrap(attributes).push(attribute);};return ComponentElementOperations;})();APPEND_OPCODES.add(37, /* FlushElement */function(vm){var stack=vm.stack();var action='FlushElementOpcode#evaluate';stack.expectOperations(action).flush(stack.expectConstructing(action),vm);stack.flushElement();});APPEND_OPCODES.add(38, /* CloseElement */function(vm){return vm.stack().closeElement();});APPEND_OPCODES.add(39, /* PopElement */function(vm){return vm.stack().popElement();});APPEND_OPCODES.add(40, /* StaticAttr */function(vm,_ref22){var _name=_ref22.op1;var _value=_ref22.op2;var _namespace=_ref22.op3;var name=vm.constants.getString(_name);var value=vm.constants.getString(_value);if(_namespace){var namespace=vm.constants.getString(_namespace);vm.stack().setStaticAttributeNS(namespace,name,value);}else {vm.stack().setStaticAttribute(name,value);}});APPEND_OPCODES.add(41, /* Modifier */function(vm,_ref23){var _name=_ref23.op1;var _manager=_ref23.op2;var _args=_ref23.op3;var manager=vm.constants.getOther(_manager);var rawArgs=vm.constants.getExpression(_args);var stack=vm.stack();var element=stack.constructing;var updateOperations=stack.updateOperations;var args=rawArgs.evaluate(vm);var dynamicScope=vm.dynamicScope();var modifier=manager.create(element,args,dynamicScope,updateOperations);vm.env.scheduleInstallModifier(modifier,manager);var destructor=manager.getDestructor(modifier);if(destructor){vm.newDestroyable(destructor);}vm.updateWith(new UpdateModifierOpcode(manager,modifier,args));});var UpdateModifierOpcode=(function(_UpdatingOpcode6){babelHelpers.inherits(UpdateModifierOpcode,_UpdatingOpcode6);function UpdateModifierOpcode(manager,modifier,args){_UpdatingOpcode6.call(this);this.manager = manager;this.modifier = modifier;this.args = args;this.type = "update-modifier";this.tag = args.tag;this.lastUpdated = args.tag.value();}UpdateModifierOpcode.prototype.evaluate = function evaluate(vm){var manager=this.manager;var modifier=this.modifier;var tag=this.tag;var lastUpdated=this.lastUpdated;if(!tag.validate(lastUpdated)){vm.env.scheduleUpdateModifier(modifier,manager);this.lastUpdated = tag.value();}};UpdateModifierOpcode.prototype.toJSON = function toJSON(){return {guid:this._guid,type:this.type,args:[JSON.stringify(this.args)]};};return UpdateModifierOpcode;})(UpdatingOpcode);var StaticAttribute=(function(){function StaticAttribute(element,name,value,namespace){this.element = element;this.name = name;this.value = value;this.namespace = namespace;}StaticAttribute.prototype.flush = function flush(env){env.getAppendOperations().setAttribute(this.element,this.name,this.value,this.namespace);return null;};return StaticAttribute;})();var DynamicAttribute=(function(){function DynamicAttribute(element,attributeManager,name,reference,namespace){this.element = element;this.attributeManager = attributeManager;this.name = name;this.reference = reference;this.namespace = namespace;this.cache = null;this.tag = reference.tag;}DynamicAttribute.prototype.patch = function patch(env){var element=this.element;var cache=this.cache;var value=_glimmerUtil.expect(cache,'must patch after flush').revalidate();if(_glimmerReference.isModified(value)){this.attributeManager.updateAttribute(env,element,value,this.namespace);}};DynamicAttribute.prototype.flush = function flush(env){var reference=this.reference;var element=this.element;if(_glimmerReference.isConst(reference)){var value=reference.value();this.attributeManager.setAttribute(env,element,value,this.namespace);return null;}else {var cache=this.cache = new _glimmerReference.ReferenceCache(reference);var value=cache.peek();this.attributeManager.setAttribute(env,element,value,this.namespace);return new PatchElementOpcode(this);}};DynamicAttribute.prototype.toJSON = function toJSON(){var element=this.element;var namespace=this.namespace;var name=this.name;var cache=this.cache;var formattedElement=formatElement(element);var lastValue=_glimmerUtil.expect(cache,'must serialize after flush').peek();if(namespace){return {element:formattedElement,type:'attribute',namespace:namespace,name:name,lastValue:lastValue};}return {element:formattedElement,type:'attribute',namespace:namespace === undefined?null:namespace,name:name,lastValue:lastValue};};return DynamicAttribute;})();function formatElement(element){return JSON.stringify('<' + element.tagName.toLowerCase() + ' />');}APPEND_OPCODES.add(42, /* DynamicAttrNS */function(vm,_ref24){var _name=_ref24.op1;var _namespace=_ref24.op2;var trusting=_ref24.op3;var name=vm.constants.getString(_name);var namespace=vm.constants.getString(_namespace);var reference=vm.frame.getOperand();vm.stack().setDynamicAttributeNS(namespace,name,reference,!!trusting);});APPEND_OPCODES.add(43, /* DynamicAttr */function(vm,_ref25){var _name=_ref25.op1;var trusting=_ref25.op2;var name=vm.constants.getString(_name);var reference=vm.frame.getOperand();vm.stack().setDynamicAttribute(name,reference,!!trusting);});var PatchElementOpcode=(function(_UpdatingOpcode7){babelHelpers.inherits(PatchElementOpcode,_UpdatingOpcode7);function PatchElementOpcode(operation){_UpdatingOpcode7.call(this);this.type = "patch-element";this.tag = operation.tag;this.operation = operation;}PatchElementOpcode.prototype.evaluate = function evaluate(vm){this.operation.patch(vm.env);};PatchElementOpcode.prototype.toJSON = function toJSON(){var _guid=this._guid;var type=this.type;var operation=this.operation;return {guid:_guid,type:type,details:operation.toJSON()};};return PatchElementOpcode;})(UpdatingOpcode);var First=(function(){function First(node){this.node = node;}First.prototype.firstNode = function firstNode(){return this.node;};return First;})();var Last=(function(){function Last(node){this.node = node;}Last.prototype.lastNode = function lastNode(){return this.node;};return Last;})();var Fragment=(function(){function Fragment(bounds){this.bounds = bounds;}Fragment.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};Fragment.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};Fragment.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};Fragment.prototype.update = function update(bounds){this.bounds = bounds;};return Fragment;})();var ElementStack=(function(){function ElementStack(env,parentNode,nextSibling){this.constructing = null;this.operations = null;this.elementStack = new _glimmerUtil.Stack();this.nextSiblingStack = new _glimmerUtil.Stack();this.blockStack = new _glimmerUtil.Stack();this.env = env;this.dom = env.getAppendOperations();this.updateOperations = env.getDOM();this.element = parentNode;this.nextSibling = nextSibling;this.defaultOperations = new SimpleElementOperations(env);this.elementStack.push(this.element);this.nextSiblingStack.push(this.nextSibling);}ElementStack.forInitialRender = function forInitialRender(env,parentNode,nextSibling){return new ElementStack(env,parentNode,nextSibling);};ElementStack.resume = function resume(env,tracker,nextSibling){var parentNode=tracker.parentElement();var stack=new ElementStack(env,parentNode,nextSibling);stack.pushBlockTracker(tracker);return stack;};ElementStack.prototype.expectConstructing = function expectConstructing(method){return _glimmerUtil.expect(this.constructing,method + ' should only be called while constructing an element');};ElementStack.prototype.expectOperations = function expectOperations(method){return _glimmerUtil.expect(this.operations,method + ' should only be called while constructing an element');};ElementStack.prototype.block = function block(){return _glimmerUtil.expect(this.blockStack.current,"Expected a current block tracker");};ElementStack.prototype.popElement = function popElement(){var elementStack=this.elementStack;var nextSiblingStack=this.nextSiblingStack;var topElement=elementStack.pop();nextSiblingStack.pop();_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.element = _glimmerUtil.expect(elementStack.current,"can't pop past the last element");this.nextSibling = nextSiblingStack.current;return topElement;};ElementStack.prototype.pushSimpleBlock = function pushSimpleBlock(){var tracker=new SimpleBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushUpdatableBlock = function pushUpdatableBlock(){var tracker=new UpdatableBlockTracker(this.element);this.pushBlockTracker(tracker);return tracker;};ElementStack.prototype.pushBlockTracker = function pushBlockTracker(tracker){var isRemote=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);if(!isRemote){current.newBounds(tracker);}}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.pushBlockList = function pushBlockList(list){var tracker=new BlockListTracker(this.element,list);var current=this.blockStack.current;if(current !== null){current.newDestroyable(tracker);current.newBounds(tracker);}this.blockStack.push(tracker);return tracker;};ElementStack.prototype.popBlock = function popBlock(){this.block().finalize(this);return _glimmerUtil.expect(this.blockStack.pop(),"Expected popBlock to return a block");};ElementStack.prototype.openElement = function openElement(tag){var operations=arguments.length <= 1 || arguments[1] === undefined?this.defaultOperations:arguments[1];var element=this.dom.createElement(tag,this.element);this.constructing = element;this.operations = operations;return element;};ElementStack.prototype.flushElement = function flushElement(){var parent=this.element;var element=_glimmerUtil.expect(this.constructing,'flushElement should only be called when constructing an element');this.dom.insertBefore(parent,element,this.nextSibling);this.constructing = null;this.operations = null;this.pushElement(element);this.block().openElement(element);};ElementStack.prototype.pushRemoteElement = function pushRemoteElement(element){this.pushElement(element);var tracker=new RemoteBlockTracker(element);this.pushBlockTracker(tracker,true);};ElementStack.prototype.popRemoteElement = function popRemoteElement(){this.popBlock();this.popElement();};ElementStack.prototype.pushElement = function pushElement(element){this.element = element;this.elementStack.push(element);_glimmerUtil.LOGGER.debug('-> element stack ' + this.elementStack.toArray().map(function(e){return e.tagName;}).join(', '));this.nextSibling = null;this.nextSiblingStack.push(null);};ElementStack.prototype.newDestroyable = function newDestroyable(d){this.block().newDestroyable(d);};ElementStack.prototype.newBounds = function newBounds(bounds){this.block().newBounds(bounds);};ElementStack.prototype.appendText = function appendText(string){var dom=this.dom;var text=dom.createTextNode(string);dom.insertBefore(this.element,text,this.nextSibling);this.block().newNode(text);return text;};ElementStack.prototype.appendComment = function appendComment(string){var dom=this.dom;var comment=dom.createComment(string);dom.insertBefore(this.element,comment,this.nextSibling);this.block().newNode(comment);return comment;};ElementStack.prototype.setStaticAttribute = function setStaticAttribute(name,value){this.expectOperations('setStaticAttribute').addStaticAttribute(this.expectConstructing('setStaticAttribute'),name,value);};ElementStack.prototype.setStaticAttributeNS = function setStaticAttributeNS(namespace,name,value){this.expectOperations('setStaticAttributeNS').addStaticAttributeNS(this.expectConstructing('setStaticAttributeNS'),namespace,name,value);};ElementStack.prototype.setDynamicAttribute = function setDynamicAttribute(name,reference,isTrusting){this.expectOperations('setDynamicAttribute').addDynamicAttribute(this.expectConstructing('setDynamicAttribute'),name,reference,isTrusting);};ElementStack.prototype.setDynamicAttributeNS = function setDynamicAttributeNS(namespace,name,reference,isTrusting){this.expectOperations('setDynamicAttributeNS').addDynamicAttributeNS(this.expectConstructing('setDynamicAttributeNS'),namespace,name,reference,isTrusting);};ElementStack.prototype.closeElement = function closeElement(){this.block().closeElement();this.popElement();};return ElementStack;})();var SimpleBlockTracker=(function(){function SimpleBlockTracker(parent){this.parent = parent;this.first = null;this.last = null;this.destroyables = null;this.nesting = 0;}SimpleBlockTracker.prototype.destroy = function destroy(){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {destroyables[i].destroy();}}};SimpleBlockTracker.prototype.parentElement = function parentElement(){return this.parent;};SimpleBlockTracker.prototype.firstNode = function firstNode(){return this.first && this.first.firstNode();};SimpleBlockTracker.prototype.lastNode = function lastNode(){return this.last && this.last.lastNode();};SimpleBlockTracker.prototype.openElement = function openElement(element){this.newNode(element);this.nesting++;};SimpleBlockTracker.prototype.closeElement = function closeElement(){this.nesting--;};SimpleBlockTracker.prototype.newNode = function newNode(node){if(this.nesting !== 0)return;if(!this.first){this.first = new First(node);}this.last = new Last(node);};SimpleBlockTracker.prototype.newBounds = function newBounds(bounds){if(this.nesting !== 0)return;if(!this.first){this.first = bounds;}this.last = bounds;};SimpleBlockTracker.prototype.newDestroyable = function newDestroyable(d){this.destroyables = this.destroyables || [];this.destroyables.push(d);};SimpleBlockTracker.prototype.finalize = function finalize(stack){if(!this.first){stack.appendComment('');}};return SimpleBlockTracker;})();var RemoteBlockTracker=(function(_SimpleBlockTracker){babelHelpers.inherits(RemoteBlockTracker,_SimpleBlockTracker);function RemoteBlockTracker(){_SimpleBlockTracker.apply(this,arguments);}RemoteBlockTracker.prototype.destroy = function destroy(){_SimpleBlockTracker.prototype.destroy.call(this);clear(this);};return RemoteBlockTracker;})(SimpleBlockTracker);var UpdatableBlockTracker=(function(_SimpleBlockTracker2){babelHelpers.inherits(UpdatableBlockTracker,_SimpleBlockTracker2);function UpdatableBlockTracker(){_SimpleBlockTracker2.apply(this,arguments);}UpdatableBlockTracker.prototype.reset = function reset(env){var destroyables=this.destroyables;if(destroyables && destroyables.length){for(var i=0;i < destroyables.length;i++) {env.didDestroy(destroyables[i]);}}var nextSibling=clear(this);this.destroyables = null;this.first = null;this.last = null;return nextSibling;};return UpdatableBlockTracker;})(SimpleBlockTracker);var BlockListTracker=(function(){function BlockListTracker(parent,boundList){this.parent = parent;this.boundList = boundList;this.parent = parent;this.boundList = boundList;}BlockListTracker.prototype.destroy = function destroy(){this.boundList.forEachNode(function(node){return node.destroy();});};BlockListTracker.prototype.parentElement = function parentElement(){return this.parent;};BlockListTracker.prototype.firstNode = function firstNode(){var head=this.boundList.head();return head && head.firstNode();};BlockListTracker.prototype.lastNode = function lastNode(){var tail=this.boundList.tail();return tail && tail.lastNode();};BlockListTracker.prototype.openElement = function openElement(_element){_glimmerUtil.assert(false,'Cannot openElement directly inside a block list');};BlockListTracker.prototype.closeElement = function closeElement(){_glimmerUtil.assert(false,'Cannot closeElement directly inside a block list');};BlockListTracker.prototype.newNode = function newNode(_node){_glimmerUtil.assert(false,'Cannot create a new node directly inside a block list');};BlockListTracker.prototype.newBounds = function newBounds(_bounds){};BlockListTracker.prototype.newDestroyable = function newDestroyable(_d){};BlockListTracker.prototype.finalize = function finalize(_stack){};return BlockListTracker;})();var CompiledValue=(function(_CompiledExpression){babelHelpers.inherits(CompiledValue,_CompiledExpression);function CompiledValue(value){_CompiledExpression.call(this);this.type = "value";this.reference = PrimitiveReference.create(value);}CompiledValue.prototype.evaluate = function evaluate(_vm){return this.reference;};CompiledValue.prototype.toJSON = function toJSON(){return JSON.stringify(this.reference.value());};return CompiledValue;})(CompiledExpression);var CompiledHasBlock=(function(_CompiledExpression2){babelHelpers.inherits(CompiledHasBlock,_CompiledExpression2);function CompiledHasBlock(inner){_CompiledExpression2.call(this);this.inner = inner;this.type = "has-block";}CompiledHasBlock.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);return PrimitiveReference.create(!!block);};CompiledHasBlock.prototype.toJSON = function toJSON(){return 'has-block(' + this.inner.toJSON() + ')';};return CompiledHasBlock;})(CompiledExpression);var CompiledHasBlockParams=(function(_CompiledExpression3){babelHelpers.inherits(CompiledHasBlockParams,_CompiledExpression3);function CompiledHasBlockParams(inner){_CompiledExpression3.call(this);this.inner = inner;this.type = "has-block-params";}CompiledHasBlockParams.prototype.evaluate = function evaluate(vm){var block=this.inner.evaluate(vm);var hasLocals=block && block.symbolTable.getSymbols().locals;return PrimitiveReference.create(!!hasLocals);};CompiledHasBlockParams.prototype.toJSON = function toJSON(){return 'has-block-params(' + this.inner.toJSON() + ')';};return CompiledHasBlockParams;})(CompiledExpression);var CompiledGetBlockBySymbol=(function(){function CompiledGetBlockBySymbol(symbol,debug){this.symbol = symbol;this.debug = debug;}CompiledGetBlockBySymbol.prototype.evaluate = function evaluate(vm){return vm.scope().getBlock(this.symbol);};CompiledGetBlockBySymbol.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '(' + this.debug + '))';};return CompiledGetBlockBySymbol;})();var CompiledInPartialGetBlock=(function(){function CompiledInPartialGetBlock(symbol,name){this.symbol = symbol;this.name = name;}CompiledInPartialGetBlock.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.blocks[name];};CompiledInPartialGetBlock.prototype.toJSON = function toJSON(){return 'get-block($' + this.symbol + '($ARGS).' + this.name + '))';};return CompiledInPartialGetBlock;})();var CompiledLookup=(function(_CompiledExpression4){babelHelpers.inherits(CompiledLookup,_CompiledExpression4);function CompiledLookup(base,path){_CompiledExpression4.call(this);this.base = base;this.path = path;this.type = "lookup";}CompiledLookup.create = function create(base,path){if(path.length === 0){return base;}else {return new this(base,path);}};CompiledLookup.prototype.evaluate = function evaluate(vm){var base=this.base;var path=this.path;return _glimmerReference.referenceFromParts(base.evaluate(vm),path);};CompiledLookup.prototype.toJSON = function toJSON(){return this.base.toJSON() + '.' + this.path.join('.');};return CompiledLookup;})(CompiledExpression);var CompiledSelf=(function(_CompiledExpression5){babelHelpers.inherits(CompiledSelf,_CompiledExpression5);function CompiledSelf(){_CompiledExpression5.apply(this,arguments);}CompiledSelf.prototype.evaluate = function evaluate(vm){return vm.getSelf();};CompiledSelf.prototype.toJSON = function toJSON(){return 'self';};return CompiledSelf;})(CompiledExpression);var CompiledSymbol=(function(_CompiledExpression6){babelHelpers.inherits(CompiledSymbol,_CompiledExpression6);function CompiledSymbol(symbol,debug){_CompiledExpression6.call(this);this.symbol = symbol;this.debug = debug;}CompiledSymbol.prototype.evaluate = function evaluate(vm){return vm.referenceForSymbol(this.symbol);};CompiledSymbol.prototype.toJSON = function toJSON(){return '$' + this.symbol + '(' + this.debug + ')';};return CompiledSymbol;})(CompiledExpression);var CompiledInPartialName=(function(_CompiledExpression7){babelHelpers.inherits(CompiledInPartialName,_CompiledExpression7);function CompiledInPartialName(symbol,name){_CompiledExpression7.call(this);this.symbol = symbol;this.name = name;}CompiledInPartialName.prototype.evaluate = function evaluate(vm){var symbol=this.symbol;var name=this.name;var args=vm.scope().getPartialArgs(symbol);return args.named.get(name);};CompiledInPartialName.prototype.toJSON = function toJSON(){return '$' + this.symbol + '($ARGS).' + this.name;};return CompiledInPartialName;})(CompiledExpression);var CompiledHelper=(function(_CompiledExpression8){babelHelpers.inherits(CompiledHelper,_CompiledExpression8);function CompiledHelper(name,helper,args,symbolTable){_CompiledExpression8.call(this);this.name = name;this.helper = helper;this.args = args;this.symbolTable = symbolTable;this.type = "helper";}CompiledHelper.prototype.evaluate = function evaluate(vm){var helper=this.helper;return helper(vm,this.args.evaluate(vm),this.symbolTable);};CompiledHelper.prototype.toJSON = function toJSON(){return '`' + this.name.join('.') + '($ARGS)`';};return CompiledHelper;})(CompiledExpression);var CompiledConcat=(function(){function CompiledConcat(parts){this.parts = parts;this.type = "concat";}CompiledConcat.prototype.evaluate = function evaluate(vm){var parts=new Array(this.parts.length);for(var i=0;i < this.parts.length;i++) {parts[i] = this.parts[i].evaluate(vm);}return new ConcatReference(parts);};CompiledConcat.prototype.toJSON = function toJSON(){return 'concat(' + this.parts.map(function(expr){return expr.toJSON();}).join(", ") + ')';};return CompiledConcat;})();var ConcatReference=(function(_CachedReference2){babelHelpers.inherits(ConcatReference,_CachedReference2);function ConcatReference(parts){_CachedReference2.call(this);this.parts = parts;this.tag = _glimmerReference.combineTagged(parts);}ConcatReference.prototype.compute = function compute(){var parts=new Array();for(var i=0;i < this.parts.length;i++) {var value=this.parts[i].value();if(value !== null && value !== undefined){parts[i] = castToString(value);}}if(parts.length > 0){return parts.join('');}return null;};return ConcatReference;})(_glimmerReference.CachedReference);function castToString(value){if(typeof value['toString'] !== 'function'){return '';}return String(value);}var CompiledFunctionExpression=(function(_CompiledExpression9){babelHelpers.inherits(CompiledFunctionExpression,_CompiledExpression9);function CompiledFunctionExpression(func,symbolTable){_CompiledExpression9.call(this);this.func = func;this.symbolTable = symbolTable;this.type = "function";this.func = func;}CompiledFunctionExpression.prototype.evaluate = function evaluate(vm){var func=this.func;var symbolTable=this.symbolTable;return func(vm,symbolTable);};CompiledFunctionExpression.prototype.toJSON = function toJSON(){var func=this.func;if(func.name){return '`' + func.name + '(...)`';}else {return "`func(...)`";}};return CompiledFunctionExpression;})(CompiledExpression);function debugCallback(context,get){console.info('Use `context`, and `get()` to debug this template.'); /* tslint:disable */debugger; /* tslint:enable */return {context:context,get:get};}function getter(vm,builder){return function(path){var parts=path.split('.');if(parts[0] === 'this'){parts[0] = null;}return compileRef(parts,builder).evaluate(vm);};}var callback=debugCallback; // For testing purposes +function setDebuggerCallback(cb){callback = cb;}function resetDebuggerCallback(){callback = debugCallback;}var Compilers=(function(){function Compilers(){this.names = _glimmerUtil.dict();this.funcs = [];}Compilers.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Compilers.prototype.compile = function compile(sexp,builder){var name=sexp[0];var index=this.names[name];var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected an implementation for ' + sexp[0]);return func(sexp,builder);};return Compilers;})();var STATEMENTS=new Compilers();STATEMENTS.add('text',function(sexp,builder){builder.text(sexp[1]);});STATEMENTS.add('comment',function(sexp,builder){builder.comment(sexp[1]);});STATEMENTS.add('close-element',function(_sexp,builder){_glimmerUtil.LOGGER.trace('close-element statement');builder.closeElement();});STATEMENTS.add('flush-element',function(_sexp,builder){builder.flushElement();});STATEMENTS.add('modifier',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var args=compileArgs(params,hash,builder);if(builder.env.hasModifier(path,builder.symbolTable)){builder.modifier(path[0],args);}else {throw new Error('Compile Error ' + path.join('.') + ' is not a modifier: Helpers may not be used in the element form.');}});STATEMENTS.add('static-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];builder.staticAttr(name,namespace,value);});STATEMENTS.add('any-dynamic-attr',function(sexp,builder){var name=sexp[1];var value=sexp[2];var namespace=sexp[3];var trusting=sexp[4];builder.putValue(value);if(namespace){builder.dynamicAttrNS(name,namespace,trusting);}else {builder.dynamicAttr(name,trusting);}});STATEMENTS.add('open-element',function(sexp,builder){_glimmerUtil.LOGGER.trace('open-element statement');builder.openPrimitiveElement(sexp[1]);});STATEMENTS.add('optimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros=builder.env.macros();var inlines=_builder$env$macros.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;builder.putValue(returned[1]);if(trustingMorph){builder.trustingAppend();}else {builder.cautiousAppend();}});STATEMENTS.add('unoptimized-append',function(sexp,builder){var value=sexp[1];var trustingMorph=sexp[2];var _builder$env$macros2=builder.env.macros();var inlines=_builder$env$macros2.inlines;var returned=inlines.compile(sexp,builder) || value;if(returned === true)return;if(trustingMorph){builder.guardedTrustingAppend(returned[1]);}else {builder.guardedCautiousAppend(returned[1]);}});STATEMENTS.add('nested-block',function(sexp,builder){var _builder$env$macros3=builder.env.macros();var blocks=_builder$env$macros3.blocks;blocks.compile(sexp,builder);});STATEMENTS.add('scanned-block',function(sexp,builder){var path=sexp[1];var params=sexp[2];var hash=sexp[3];var template=sexp[4];var inverse=sexp[5];var templateBlock=template && template.scan();var inverseBlock=inverse && inverse.scan();var _builder$env$macros4=builder.env.macros();var blocks=_builder$env$macros4.blocks;blocks.compile(['nested-block',path,params,hash,templateBlock,inverseBlock],builder);});STATEMENTS.add('scanned-component',function(sexp,builder){var tag=sexp[1];var attrs=sexp[2];var rawArgs=sexp[3];var rawBlock=sexp[4];var block=rawBlock && rawBlock.scan();var args=compileBlockArgs(null,rawArgs,{default:block,inverse:null},builder);var definition=builder.env.getComponentDefinition([tag],builder.symbolTable);builder.putComponentDefinition(definition);builder.openComponent(args,attrs.scan());builder.closeComponent();});STATEMENTS.add('static-partial',function(sexp,builder){var name=sexp[1];if(!builder.env.hasPartial(name,builder.symbolTable)){throw new Error('Compile Error: Could not find a partial named "' + name + '"');}var definition=builder.env.lookupPartial(name,builder.symbolTable);builder.putPartialDefinition(definition);builder.evaluatePartial();});STATEMENTS.add('dynamic-partial',function(sexp,builder){var name=sexp[1];builder.startLabels();builder.putValue(name);builder.test('simple');builder.enter('BEGIN','END');builder.label('BEGIN');builder.jumpUnless('END');builder.putDynamicPartialDefinition();builder.evaluatePartial();builder.label('END');builder.exit();builder.stopLabels();});STATEMENTS.add('yield',function(sexp,builder){var to=sexp[1];var params=sexp[2];var args=compileArgs(params,null,builder);builder.yield(args,to);});STATEMENTS.add('debugger',function(sexp,builder){builder.putValue(['function',function(vm){var context=vm.getSelf().value();var get=function(path){return getter(vm,builder)(path).value();};callback(context,get);}]);return sexp;});var EXPRESSIONS=new Compilers();function expr(expression,builder){if(Array.isArray(expression)){return EXPRESSIONS.compile(expression,builder);}else {return new CompiledValue(expression);}}EXPRESSIONS.add('unknown',function(sexp,builder){var path=sexp[1];if(builder.env.hasHelper(path,builder.symbolTable)){return new CompiledHelper(path,builder.env.lookupHelper(path,builder.symbolTable),CompiledArgs.empty(),builder.symbolTable);}else {return compileRef(path,builder);}});EXPRESSIONS.add('concat',function(sexp,builder){var params=sexp[1].map(function(p){return expr(p,builder);});return new CompiledConcat(params);});EXPRESSIONS.add('function',function(sexp,builder){return new CompiledFunctionExpression(sexp[1],builder.symbolTable);});EXPRESSIONS.add('helper',function(sexp,builder){var env=builder.env;var symbolTable=builder.symbolTable;var path=sexp[1];var params=sexp[2];var hash=sexp[3];if(env.hasHelper(path,symbolTable)){var args=compileArgs(params,hash,builder);return new CompiledHelper(path,env.lookupHelper(path,symbolTable),args,symbolTable);}else {throw new Error('Compile Error: ' + path.join('.') + ' is not a helper');}});EXPRESSIONS.add('get',function(sexp,builder){return compileRef(sexp[1],builder);});EXPRESSIONS.add('undefined',function(_sexp,_builder){return new CompiledValue(undefined);});EXPRESSIONS.add('arg',function(sexp,builder){var parts=sexp[1];var head=parts[0];var named=undefined,partial=undefined;if(named = builder.symbolTable.getSymbol('named',head)){var path=parts.slice(1);var inner=new CompiledSymbol(named,head);return CompiledLookup.create(inner,path);}else if(partial = builder.symbolTable.getPartialArgs()){var path=parts.slice(1);var inner=new CompiledInPartialName(partial,head);return CompiledLookup.create(inner,path);}else {throw new Error('[BUG] @' + parts.join('.') + ' is not a valid lookup path.');}});EXPRESSIONS.add('has-block',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlock(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlock(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});EXPRESSIONS.add('has-block-params',function(sexp,builder){var blockName=sexp[1];var yields=undefined,partial=undefined;if(yields = builder.symbolTable.getSymbol('yields',blockName)){var inner=new CompiledGetBlockBySymbol(yields,blockName);return new CompiledHasBlockParams(inner);}else if(partial = builder.symbolTable.getPartialArgs()){var inner=new CompiledInPartialGetBlock(partial,blockName);return new CompiledHasBlockParams(inner);}else {throw new Error('[BUG] ${blockName} is not a valid block name.');}});function compileArgs(params,hash,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,EMPTY_BLOCKS);}function compileBlockArgs(params,hash,blocks,builder){var compiledParams=compileParams(params,builder);var compiledHash=compileHash(hash,builder);return CompiledArgs.create(compiledParams,compiledHash,blocks);}function compileBaselineArgs(args,builder){var params=args[0];var hash=args[1];var _default=args[2];var inverse=args[3];return CompiledArgs.create(compileParams(params,builder),compileHash(hash,builder),{default:_default,inverse:inverse});}function compileParams(params,builder){if(!params || params.length === 0)return COMPILED_EMPTY_POSITIONAL_ARGS;var compiled=params.map(function(p){return expr(p,builder);});return CompiledPositionalArgs.create(compiled);}function compileHash(hash,builder){if(!hash)return COMPILED_EMPTY_NAMED_ARGS;var keys=hash[0];var values=hash[1];if(keys.length === 0)return COMPILED_EMPTY_NAMED_ARGS;var compiled=values.map(function(p){return expr(p,builder);});return new CompiledNamedArgs(keys,compiled);}function compileRef(parts,builder){var head=parts[0];var local=undefined;if(head === null){var inner=new CompiledSelf();var path=parts.slice(1);return CompiledLookup.create(inner,path);}else if(local = builder.symbolTable.getSymbol('local',head)){var path=parts.slice(1);var inner=new CompiledSymbol(local,head);return CompiledLookup.create(inner,path);}else {var inner=new CompiledSelf();return CompiledLookup.create(inner,parts);}}var Blocks=(function(){function Blocks(){this.names = _glimmerUtil.dict();this.funcs = [];}Blocks.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Blocks.prototype.addMissing = function addMissing(func){this.missing = func;};Blocks.prototype.compile = function compile(sexp,builder){ // assert(sexp[1].length === 1, 'paths in blocks are not supported'); +var name=sexp[1][0];var index=this.names[name];if(index === undefined){_glimmerUtil.assert(!!this.missing,name + ' not found, and no catch-all block handler was registered');var func=this.missing;var handled=func(sexp,builder);_glimmerUtil.assert(!!handled,name + ' not found, and the catch-all block handler didn\'t handle it');}else {var func=this.funcs[index];func(sexp,builder);}};return Blocks;})();var BLOCKS=new Blocks();var Inlines=(function(){function Inlines(){this.names = _glimmerUtil.dict();this.funcs = [];}Inlines.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Inlines.prototype.addMissing = function addMissing(func){this.missing = func;};Inlines.prototype.compile = function compile(sexp,builder){var value=sexp[1]; // TODO: Fix this so that expression macros can return +// things like components, so that {{component foo}} +// is the same as {{(component foo)}} +if(!Array.isArray(value))return ['expr',value];var path=undefined;var params=undefined;var hash=undefined;if(value[0] === 'helper'){path = value[1];params = value[2];hash = value[3];}else if(value[0] === 'unknown'){path = value[1];params = hash = null;}else {return ['expr',value];}if(path.length > 1 && !params && !hash){return ['expr',value];}var name=path[0];var index=this.names[name];if(index === undefined && this.missing){var func=this.missing;var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else if(index !== undefined){var func=this.funcs[index];var returned=func(path,params,hash,builder);return returned === false?['expr',value]:returned;}else {return ['expr',value];}};return Inlines;})();var INLINES=new Inlines();populateBuiltins(BLOCKS,INLINES);function populateBuiltins(){var blocks=arguments.length <= 0 || arguments[0] === undefined?new Blocks():arguments[0];var inlines=arguments.length <= 1 || arguments[1] === undefined?new Inlines():arguments[1];blocks.add('if',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('unless',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpIf('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpIf('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('with',function(sexp,builder){ // PutArgs +// Test(Environment) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(ELSE) +// Evaluate(default) +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.putArgs(args);builder.test('environment');builder.labelled(null,function(b){if(_default && inverse){b.jumpUnless('ELSE');b.evaluate(_default);b.jump('END');b.label('ELSE');b.evaluate(inverse);}else if(_default){b.jumpUnless('END');b.evaluate(_default);}else {throw _glimmerUtil.unreachable();}});});blocks.add('each',function(sexp,builder){ // Enter(BEGIN, END) +// BEGIN: Noop +// PutArgs +// PutIterable +// JumpUnless(ELSE) +// EnterList(BEGIN2, END2) +// ITER: Noop +// NextIter(BREAK) +// EnterWithKey(BEGIN2, END2) +// BEGIN2: Noop +// PushChildScope +// Evaluate(default) +// PopScope +// END2: Noop +// Exit +// Jump(ITER) +// BREAK: Noop +// ExitList +// Jump(END) +// ELSE: Noop +// Evalulate(inverse) +// END: Noop +// Exit +var params=sexp[2];var hash=sexp[3];var _default=sexp[4];var inverse=sexp[5];var args=compileArgs(params,hash,builder);builder.labelled(args,function(b){b.putIterator();if(inverse){b.jumpUnless('ELSE');}else {b.jumpUnless('END');}b.iter(function(b){b.evaluate(_glimmerUtil.unwrap(_default));});if(inverse){b.jump('END');b.label('ELSE');b.evaluate(inverse);}});});return {blocks:blocks,inlines:inlines};}var badProtocols=['javascript:','vbscript:'];var badTags=['A','BODY','LINK','IMG','IFRAME','BASE','FORM'];var badTagsForDataURI=['EMBED'];var badAttributes=['href','src','background','action'];var badAttributesForDataURI=['src'];function has(array,item){return array.indexOf(item) !== -1;}function checkURI(tagName,attribute){return (tagName === null || has(badTags,tagName)) && has(badAttributes,attribute);}function checkDataURI(tagName,attribute){if(tagName === null)return false;return has(badTagsForDataURI,tagName) && has(badAttributesForDataURI,attribute);}function requiresSanitization(tagName,attribute){return checkURI(tagName,attribute) || checkDataURI(tagName,attribute);}function sanitizeAttributeValue(env,element,attribute,value){var tagName=null;if(value === null || value === undefined){return value;}if(isSafeString(value)){return value.toHTML();}if(!element){tagName = null;}else {tagName = element.tagName.toUpperCase();}var str=normalizeTextValue(value);if(checkURI(tagName,attribute)){var protocol=env.protocolForURL(str);if(has(badProtocols,protocol)){return 'unsafe:' + str;}}if(checkDataURI(tagName,attribute)){return 'unsafe:' + str;}return str;} /* + * @method normalizeProperty + * @param element {HTMLElement} + * @param slotName {String} + * @returns {Object} { name, type } + */function normalizeProperty(element,slotName){var type=undefined,normalized=undefined;if(slotName in element){normalized = slotName;type = 'prop';}else {var lower=slotName.toLowerCase();if(lower in element){type = 'prop';normalized = lower;}else {type = 'attr';normalized = slotName;}}if(type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName,normalized))){type = 'attr';}return {normalized:normalized,type:type};} // properties that MUST be set as attributes, due to: +// * browser bug +// * strange spec outlier +var ATTR_OVERRIDES={ // phantomjs < 2.0 lets you set it as a prop but won't reflect it +// back to the attribute. button.getAttribute('type') === null +BUTTON:{type:true,form:true},INPUT:{ // Some version of IE (like IE9) actually throw an exception +// if you set input.type = 'something-unknown' +type:true,form:true, // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false +// Safari 8.0.7: 'autocorrect' in document.createElement('input') === false +// Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true +autocorrect:true, // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true +// Safari 9.1.3: 'list' in document.createElement('input') === false +list:true}, // element.form is actually a legitimate readOnly property, that is to be +// mutated, but must be mutated by setAttribute... +SELECT:{form:true},OPTION:{form:true},TEXTAREA:{form:true},LABEL:{form:true},FIELDSET:{form:true},LEGEND:{form:true},OBJECT:{form:true}};function preferAttr(tagName,propName){var tag=ATTR_OVERRIDES[tagName.toUpperCase()];return tag && tag[propName.toLowerCase()] || false;}var innerHTMLWrapper={colgroup:{depth:2,before:'',after:'
    '},table:{depth:1,before:'',after:'
    '},tbody:{depth:2,before:'',after:'
    '},tfoot:{depth:2,before:'',after:'
    '},thead:{depth:2,before:'',after:'
    '},tr:{depth:3,before:'',after:'
    '}}; // Patch: innerHTML Fix +// Browsers: IE9 +// Reason: IE9 don't allow us to set innerHTML on col, colgroup, frameset, +// html, style, table, tbody, tfoot, thead, title, tr. +// Fix: Wrap the innerHTML we are about to set in its parents, apply the +// wrapped innerHTML on a div, then move the unwrapped nodes into the +// target position. +function domChanges(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix(document)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass){babelHelpers.inherits(DOMChangesWithInnerHTMLFix,_DOMChangesClass);function DOMChangesWithInnerHTMLFix(){_DOMChangesClass.apply(this,arguments);}DOMChangesWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMChangesClass.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixInnerHTML(parent,wrapper,div,html,nextSibling);};return DOMChangesWithInnerHTMLFix;})(DOMChangesClass);}function treeConstruction(document,DOMTreeConstructionClass){if(!document)return DOMTreeConstructionClass;if(!shouldApplyFix(document)){return DOMTreeConstructionClass;}var div=document.createElement('div');return (function(_DOMTreeConstructionClass){babelHelpers.inherits(DOMTreeConstructionWithInnerHTMLFix,_DOMTreeConstructionClass);function DOMTreeConstructionWithInnerHTMLFix(){_DOMTreeConstructionClass.apply(this,arguments);}DOMTreeConstructionWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}var parentTag=parent.tagName.toLowerCase();var wrapper=innerHTMLWrapper[parentTag];if(wrapper === undefined){return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixInnerHTML(parent,wrapper,div,html,reference);};return DOMTreeConstructionWithInnerHTMLFix;})(DOMTreeConstructionClass);}function fixInnerHTML(parent,wrapper,div,html,reference){var wrappedHtml=wrapper.before + html + wrapper.after;div.innerHTML = wrappedHtml;var parentNode=div;for(var i=0;i < wrapper.depth;i++) {parentNode = parentNode.childNodes[0];}var _moveNodesBefore=moveNodesBefore(parentNode,parent,reference);var first=_moveNodesBefore[0];var last=_moveNodesBefore[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix(document){var table=document.createElement('table');try{table.innerHTML = '';}catch(e) {}finally {if(table.childNodes.length !== 0){ // It worked as expected, no fix required +return false;}}return true;}var SVG_NAMESPACE$1='http://www.w3.org/2000/svg'; // Patch: insertAdjacentHTML on SVG Fix +// Browsers: Safari, IE, Edge, Firefox ~33-34 +// Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is +// present but throws an exception on IE and Edge. Old versions of +// Firefox create nodes in the incorrect namespace. +// Fix: Since IE and Edge silently fail to create SVG nodes using +// innerHTML, and because Firefox may create nodes in the incorrect +// namespace using innerHTML on SVG elements, an HTML-string wrapping +// approach is used. A pre/post SVG tag is added to the string, then +// that whole string is added to a div. The created nodes are plucked +// out and applied to the target location on DOM. +function domChanges$1(document,DOMChangesClass,svgNamespace){if(!document)return DOMChangesClass;if(!shouldApplyFix$1(document,svgNamespace)){return DOMChangesClass;}var div=document.createElement('div');return (function(_DOMChangesClass2){babelHelpers.inherits(DOMChangesWithSVGInnerHTMLFix,_DOMChangesClass2);function DOMChangesWithSVGInnerHTMLFix(){_DOMChangesClass2.apply(this,arguments);}DOMChangesWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null || html === ''){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}if(parent.namespaceURI !== svgNamespace){return _DOMChangesClass2.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}return fixSVG(parent,div,html,nextSibling);};return DOMChangesWithSVGInnerHTMLFix;})(DOMChangesClass);}function treeConstruction$1(document,TreeConstructionClass,svgNamespace){if(!document)return TreeConstructionClass;if(!shouldApplyFix$1(document,svgNamespace)){return TreeConstructionClass;}var div=document.createElement('div');return (function(_TreeConstructionClass){babelHelpers.inherits(TreeConstructionWithSVGInnerHTMLFix,_TreeConstructionClass);function TreeConstructionWithSVGInnerHTMLFix(){_TreeConstructionClass.apply(this,arguments);}TreeConstructionWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null || html === ''){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}if(parent.namespaceURI !== svgNamespace){return _TreeConstructionClass.prototype.insertHTMLBefore.call(this,parent,html,reference);}return fixSVG(parent,div,html,reference);};return TreeConstructionWithSVGInnerHTMLFix;})(TreeConstructionClass);}function fixSVG(parent,div,html,reference){ // IE, Edge: also do not correctly support using `innerHTML` on SVG +// namespaced elements. So here a wrapper is used. +var wrappedHtml='' + html + '';div.innerHTML = wrappedHtml;var _moveNodesBefore2=moveNodesBefore(div.firstChild,parent,reference);var first=_moveNodesBefore2[0];var last=_moveNodesBefore2[1];return new ConcreteBounds(parent,first,last);}function shouldApplyFix$1(document,svgNamespace){var svg=document.createElementNS(svgNamespace,'svg');try{svg['insertAdjacentHTML']('beforeEnd','');}catch(e) {}finally { // FF: Old versions will create a node in the wrong namespace +if(svg.childNodes.length === 1 && _glimmerUtil.unwrap(svg.firstChild).namespaceURI === SVG_NAMESPACE$1){ // The test worked as expected, no fix required +return false;}return true;}} // Patch: Adjacent text node merging fix +// Browsers: IE, Edge, Firefox w/o inspector open +// Reason: These browsers will merge adjacent text nodes. For exmaple given +//
    Hello
    with div.insertAdjacentHTML(' world') browsers +// with proper behavior will populate div.childNodes with two items. +// These browsers will populate it with one merged node instead. +// Fix: Add these nodes to a wrapper element, then iterate the childNodes +// of that wrapper and move the nodes to their target location. Note +// that potential SVG bugs will have been handled before this fix. +// Note that this fix must only apply to the previous text node, as +// the base implementation of `insertHTMLBefore` already handles +// following text nodes correctly. +function domChanges$2(document,DOMChangesClass){if(!document)return DOMChangesClass;if(!shouldApplyFix$2(document)){return DOMChangesClass;}return (function(_DOMChangesClass3){babelHelpers.inherits(DOMChangesWithTextNodeMergingFix,_DOMChangesClass3);function DOMChangesWithTextNodeMergingFix(document){_DOMChangesClass3.call(this,document);this.uselessComment = document.createComment('');}DOMChangesWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,nextSibling,html){if(html === null){return _DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);}var didSetUselessComment=false;var nextPrevious=nextSibling?nextSibling.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,nextSibling);}var bounds=_DOMChangesClass3.prototype.insertHTMLBefore.call(this,parent,nextSibling,html);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return DOMChangesWithTextNodeMergingFix;})(DOMChangesClass);}function treeConstruction$2(document,TreeConstructionClass){if(!document)return TreeConstructionClass;if(!shouldApplyFix$2(document)){return TreeConstructionClass;}return (function(_TreeConstructionClass2){babelHelpers.inherits(TreeConstructionWithTextNodeMergingFix,_TreeConstructionClass2);function TreeConstructionWithTextNodeMergingFix(document){_TreeConstructionClass2.call(this,document);this.uselessComment = this.createComment('');}TreeConstructionWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){if(html === null){return _TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);}var didSetUselessComment=false;var nextPrevious=reference?reference.previousSibling:parent.lastChild;if(nextPrevious && nextPrevious instanceof Text){didSetUselessComment = true;parent.insertBefore(this.uselessComment,reference);}var bounds=_TreeConstructionClass2.prototype.insertHTMLBefore.call(this,parent,html,reference);if(didSetUselessComment){parent.removeChild(this.uselessComment);}return bounds;};return TreeConstructionWithTextNodeMergingFix;})(TreeConstructionClass);}function shouldApplyFix$2(document){var mergingTextDiv=document.createElement('div');mergingTextDiv.innerHTML = 'first';mergingTextDiv.insertAdjacentHTML('beforeEnd','second');if(mergingTextDiv.childNodes.length === 2){ // It worked as expected, no fix required +return false;}return true;}var SVG_NAMESPACE='http://www.w3.org/2000/svg'; // http://www.w3.org/TR/html/syntax.html#html-integration-point +var SVG_INTEGRATION_POINTS={foreignObject:1,desc:1,title:1}; // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes +// TODO: Adjust SVG attributes +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +// TODO: Adjust SVG elements +// http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign +var BLACKLIST_TABLE=Object.create(null);["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach(function(tag){return BLACKLIST_TABLE[tag] = 1;});var WHITESPACE=/[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;var doc=typeof document === 'undefined'?null:document;function isWhitespace(string){return WHITESPACE.test(string);}function moveNodesBefore(source,target,nextSibling){var first=source.firstChild;var last=null;var current=first;while(current) {last = current;current = current.nextSibling;target.insertBefore(last,nextSibling);}return [first,last];}var DOM;(function(DOM){var TreeConstruction=(function(){function TreeConstruction(document){this.document = document;this.setupUselessElement();}TreeConstruction.prototype.setupUselessElement = function setupUselessElement(){this.uselessElement = this.document.createElement('div');};TreeConstruction.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};TreeConstruction.prototype.createElementNS = function createElementNS(namespace,tag){return this.document.createElementNS(namespace,tag);};TreeConstruction.prototype.setAttribute = function setAttribute(element,name,value,namespace){if(namespace){element.setAttributeNS(namespace,name,value);}else {element.setAttribute(name,value);}};TreeConstruction.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};TreeConstruction.prototype.createComment = function createComment(data){return this.document.createComment(data);};TreeConstruction.prototype.insertBefore = function insertBefore(parent,node,reference){parent.insertBefore(node,reference);};TreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent,html,reference){return _insertHTMLBefore(this.uselessElement,parent,reference,html);};return TreeConstruction;})();DOM.TreeConstruction = TreeConstruction;var appliedTreeContruction=TreeConstruction;appliedTreeContruction = treeConstruction$2(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction(doc,appliedTreeContruction);appliedTreeContruction = treeConstruction$1(doc,appliedTreeContruction,SVG_NAMESPACE);DOM.DOMTreeConstruction = appliedTreeContruction;})(DOM || (DOM = {}));var DOMChanges=(function(){function DOMChanges(document){this.document = document;this.namespace = null;this.uselessElement = this.document.createElement('div');}DOMChanges.prototype.setAttribute = function setAttribute(element,name,value){element.setAttribute(name,value);};DOMChanges.prototype.setAttributeNS = function setAttributeNS(element,namespace,name,value){element.setAttributeNS(namespace,name,value);};DOMChanges.prototype.removeAttribute = function removeAttribute(element,name){element.removeAttribute(name);};DOMChanges.prototype.removeAttributeNS = function removeAttributeNS(element,namespace,name){element.removeAttributeNS(namespace,name);};DOMChanges.prototype.createTextNode = function createTextNode(text){return this.document.createTextNode(text);};DOMChanges.prototype.createComment = function createComment(data){return this.document.createComment(data);};DOMChanges.prototype.createElement = function createElement(tag,context){var isElementInSVGNamespace=undefined,isHTMLIntegrationPoint=undefined;if(context){isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg';isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName];}else {isElementInSVGNamespace = tag === 'svg';isHTMLIntegrationPoint = false;}if(isElementInSVGNamespace && !isHTMLIntegrationPoint){ // FIXME: This does not properly handle with color, face, or +// size attributes, which is also disallowed by the spec. We should fix +// this. +if(BLACKLIST_TABLE[tag]){throw new Error('Cannot create a ' + tag + ' inside an SVG context');}return this.document.createElementNS(SVG_NAMESPACE,tag);}else {return this.document.createElement(tag);}};DOMChanges.prototype.insertHTMLBefore = function insertHTMLBefore(_parent,nextSibling,html){return _insertHTMLBefore(this.uselessElement,_parent,nextSibling,html);};DOMChanges.prototype.insertNodeBefore = function insertNodeBefore(parent,node,reference){if(isDocumentFragment(node)){var firstChild=node.firstChild;var lastChild=node.lastChild;this.insertBefore(parent,node,reference);return new ConcreteBounds(parent,firstChild,lastChild);}else {this.insertBefore(parent,node,reference);return new SingleNodeBounds(parent,node);}};DOMChanges.prototype.insertTextBefore = function insertTextBefore(parent,nextSibling,text){var textNode=this.createTextNode(text);this.insertBefore(parent,textNode,nextSibling);return textNode;};DOMChanges.prototype.insertBefore = function insertBefore(element,node,reference){element.insertBefore(node,reference);};DOMChanges.prototype.insertAfter = function insertAfter(element,node,reference){this.insertBefore(element,node,reference.nextSibling);};return DOMChanges;})();function _insertHTMLBefore(_useless,_parent,_nextSibling,html){ // TypeScript vendored an old version of the DOM spec where `insertAdjacentHTML` +// only exists on `HTMLElement` but not on `Element`. We actually work with the +// newer version of the DOM API here (and monkey-patch this method in `./compat` +// when we detect older browsers). This is a hack to work around this limitation. +var parent=_parent;var useless=_useless;var nextSibling=_nextSibling;var prev=nextSibling?nextSibling.previousSibling:parent.lastChild;var last=undefined;if(html === null || html === ''){return new ConcreteBounds(parent,null,null);}if(nextSibling === null){parent.insertAdjacentHTML('beforeEnd',html);last = parent.lastChild;}else if(nextSibling instanceof HTMLElement){nextSibling.insertAdjacentHTML('beforeBegin',html);last = nextSibling.previousSibling;}else { // Non-element nodes do not support insertAdjacentHTML, so add an +// element and call it on that element. Then remove the element. +// +// This also protects Edge, IE and Firefox w/o the inspector open +// from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts +parent.insertBefore(useless,nextSibling);useless.insertAdjacentHTML('beforeBegin',html);last = useless.previousSibling;parent.removeChild(useless);}var first=prev?prev.nextSibling:parent.firstChild;return new ConcreteBounds(parent,first,last);}function isDocumentFragment(node){return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;}var helper=DOMChanges;helper = domChanges$2(doc,helper);helper = domChanges(doc,helper);helper = domChanges$1(doc,helper,SVG_NAMESPACE);var helper$1=helper;var DOMTreeConstruction=DOM.DOMTreeConstruction;function defaultManagers(element,attr,_isTrusting,_namespace){var tagName=element.tagName;var isSVG=element.namespaceURI === SVG_NAMESPACE;if(isSVG){return defaultAttributeManagers(tagName,attr);}var _normalizeProperty=normalizeProperty(element,attr);var type=_normalizeProperty.type;var normalized=_normalizeProperty.normalized;if(type === 'attr'){return defaultAttributeManagers(tagName,normalized);}else {return defaultPropertyManagers(tagName,normalized);}}function defaultPropertyManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafePropertyManager(attr);}if(isUserInputValue(tagName,attr)){return INPUT_VALUE_PROPERTY_MANAGER;}if(isOptionSelected(tagName,attr)){return OPTION_SELECTED_MANAGER;}return new PropertyManager(attr);}function defaultAttributeManagers(tagName,attr){if(requiresSanitization(tagName,attr)){return new SafeAttributeManager(attr);}return new AttributeManager(attr);}function readDOMAttr(element,attr){var isSVG=element.namespaceURI === SVG_NAMESPACE;var _normalizeProperty2=normalizeProperty(element,attr);var type=_normalizeProperty2.type;var normalized=_normalizeProperty2.normalized;if(isSVG){return element.getAttribute(normalized);}if(type === 'attr'){return element.getAttribute(normalized);}{return element[normalized];}};var AttributeManager=(function(){function AttributeManager(attr){this.attr = attr;}AttributeManager.prototype.setAttribute = function setAttribute(env,element,value,namespace){var dom=env.getAppendOperations();var normalizedValue=normalizeAttributeValue(value);if(!isAttrRemovalValue(normalizedValue)){dom.setAttribute(element,this.attr,normalizedValue,namespace);}};AttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){if(value === null || value === undefined || value === false){if(namespace){env.getDOM().removeAttributeNS(element,namespace,this.attr);}else {env.getDOM().removeAttribute(element,this.attr);}}else {this.setAttribute(env,element,value);}};return AttributeManager;})();;var PropertyManager=(function(_AttributeManager){babelHelpers.inherits(PropertyManager,_AttributeManager);function PropertyManager(){_AttributeManager.apply(this,arguments);}PropertyManager.prototype.setAttribute = function setAttribute(_env,element,value,_namespace){if(!isAttrRemovalValue(value)){element[this.attr] = value;}};PropertyManager.prototype.removeAttribute = function removeAttribute(env,element,namespace){ // TODO this sucks but to preserve properties first and to meet current +// semantics we must do this. +var attr=this.attr;if(namespace){env.getDOM().removeAttributeNS(element,namespace,attr);}else {env.getDOM().removeAttribute(element,attr);}};PropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value,namespace){ // ensure the property is always updated +element[this.attr] = value;if(isAttrRemovalValue(value)){this.removeAttribute(env,element,namespace);}};return PropertyManager;})(AttributeManager);;function normalizeAttributeValue(value){if(value === false || value === undefined || value === null){return null;}if(value === true){return '';} // onclick function etc in SSR +if(typeof value === 'function'){return null;}return String(value);}function isAttrRemovalValue(value){return value === null || value === undefined;}var SafePropertyManager=(function(_PropertyManager){babelHelpers.inherits(SafePropertyManager,_PropertyManager);function SafePropertyManager(){_PropertyManager.apply(this,arguments);}SafePropertyManager.prototype.setAttribute = function setAttribute(env,element,value){_PropertyManager.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafePropertyManager.prototype.updateAttribute = function updateAttribute(env,element,value){_PropertyManager.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafePropertyManager;})(PropertyManager);function isUserInputValue(tagName,attribute){return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value';}var InputValuePropertyManager=(function(_AttributeManager2){babelHelpers.inherits(InputValuePropertyManager,_AttributeManager2);function InputValuePropertyManager(){_AttributeManager2.apply(this,arguments);}InputValuePropertyManager.prototype.setAttribute = function setAttribute(_env,element,value){var input=element;input.value = normalizeTextValue(value);};InputValuePropertyManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var input=element;var currentValue=input.value;var normalizedValue=normalizeTextValue(value);if(currentValue !== normalizedValue){input.value = normalizedValue;}};return InputValuePropertyManager;})(AttributeManager);var INPUT_VALUE_PROPERTY_MANAGER=new InputValuePropertyManager('value');function isOptionSelected(tagName,attribute){return tagName === 'OPTION' && attribute === 'selected';}var OptionSelectedManager=(function(_PropertyManager2){babelHelpers.inherits(OptionSelectedManager,_PropertyManager2);function OptionSelectedManager(){_PropertyManager2.apply(this,arguments);}OptionSelectedManager.prototype.setAttribute = function setAttribute(_env,element,value){if(value !== null && value !== undefined && value !== false){var option=element;option.selected = true;}};OptionSelectedManager.prototype.updateAttribute = function updateAttribute(_env,element,value){var option=element;if(value){option.selected = true;}else {option.selected = false;}};return OptionSelectedManager;})(PropertyManager);var OPTION_SELECTED_MANAGER=new OptionSelectedManager('selected');var SafeAttributeManager=(function(_AttributeManager3){babelHelpers.inherits(SafeAttributeManager,_AttributeManager3);function SafeAttributeManager(){_AttributeManager3.apply(this,arguments);}SafeAttributeManager.prototype.setAttribute = function setAttribute(env,element,value){_AttributeManager3.prototype.setAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};SafeAttributeManager.prototype.updateAttribute = function updateAttribute(env,element,value,_namespace){_AttributeManager3.prototype.updateAttribute.call(this,env,element,sanitizeAttributeValue(env,element,this.attr,value));};return SafeAttributeManager;})(AttributeManager);var Scope=(function(){function Scope(references){var callerScope=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];this.callerScope = null;this.slots = references;this.callerScope = callerScope;}Scope.root = function root(self){var size=arguments.length <= 1 || arguments[1] === undefined?0:arguments[1];var refs=new Array(size + 1);for(var i=0;i <= size;i++) {refs[i] = UNDEFINED_REFERENCE;}return new Scope(refs).init({self:self});};Scope.prototype.init = function init(_ref26){var self=_ref26.self;this.slots[0] = self;return this;};Scope.prototype.getSelf = function getSelf(){return this.slots[0];};Scope.prototype.getSymbol = function getSymbol(symbol){return this.slots[symbol];};Scope.prototype.getBlock = function getBlock(symbol){return this.slots[symbol];};Scope.prototype.getPartialArgs = function getPartialArgs(symbol){return this.slots[symbol];};Scope.prototype.bindSymbol = function bindSymbol(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindBlock = function bindBlock(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindPartialArgs = function bindPartialArgs(symbol,value){this.slots[symbol] = value;};Scope.prototype.bindCallerScope = function bindCallerScope(scope){this.callerScope = scope;};Scope.prototype.getCallerScope = function getCallerScope(){return this.callerScope;};Scope.prototype.child = function child(){return new Scope(this.slots.slice(),this.callerScope);};return Scope;})();var Transaction=(function(){function Transaction(){this.scheduledInstallManagers = [];this.scheduledInstallModifiers = [];this.scheduledUpdateModifierManagers = [];this.scheduledUpdateModifiers = [];this.createdComponents = [];this.createdManagers = [];this.updatedComponents = [];this.updatedManagers = [];this.destructors = [];}Transaction.prototype.didCreate = function didCreate(component,manager){this.createdComponents.push(component);this.createdManagers.push(manager);};Transaction.prototype.didUpdate = function didUpdate(component,manager){this.updatedComponents.push(component);this.updatedManagers.push(manager);};Transaction.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.scheduledInstallManagers.push(manager);this.scheduledInstallModifiers.push(modifier);};Transaction.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.scheduledUpdateModifierManagers.push(manager);this.scheduledUpdateModifiers.push(modifier);};Transaction.prototype.didDestroy = function didDestroy(d){this.destructors.push(d);};Transaction.prototype.commit = function commit(){var createdComponents=this.createdComponents;var createdManagers=this.createdManagers;for(var i=0;i < createdComponents.length;i++) {var component=createdComponents[i];var manager=createdManagers[i];manager.didCreate(component);}var updatedComponents=this.updatedComponents;var updatedManagers=this.updatedManagers;for(var i=0;i < updatedComponents.length;i++) {var component=updatedComponents[i];var manager=updatedManagers[i];manager.didUpdate(component);}var destructors=this.destructors;for(var i=0;i < destructors.length;i++) {destructors[i].destroy();}var scheduledInstallManagers=this.scheduledInstallManagers;var scheduledInstallModifiers=this.scheduledInstallModifiers;for(var i=0;i < scheduledInstallManagers.length;i++) {var manager=scheduledInstallManagers[i];var modifier=scheduledInstallModifiers[i];manager.install(modifier);}var scheduledUpdateModifierManagers=this.scheduledUpdateModifierManagers;var scheduledUpdateModifiers=this.scheduledUpdateModifiers;for(var i=0;i < scheduledUpdateModifierManagers.length;i++) {var manager=scheduledUpdateModifierManagers[i];var modifier=scheduledUpdateModifiers[i];manager.update(modifier);}};return Transaction;})();var Opcode=(function(){function Opcode(array){this.array = array;this.offset = 0;}babelHelpers.createClass(Opcode,[{key:'type',get:function(){return this.array[this.offset];}},{key:'op1',get:function(){return this.array[this.offset + 1];}},{key:'op2',get:function(){return this.array[this.offset + 2];}},{key:'op3',get:function(){return this.array[this.offset + 3];}}]);return Opcode;})();var Program=(function(){function Program(){this.opcodes = new _glimmerUtil.A(0x100000);this._offset = 0;this._opcode = new Opcode(this.opcodes);}Program.prototype.opcode = function opcode(offset){this._opcode.offset = offset;return this._opcode;};Program.prototype.set = function set(pos,opcode){var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[pos] = type;this.opcodes[pos + 1] = op1;this.opcodes[pos + 2] = op2;this.opcodes[pos + 3] = op3;};Program.prototype.push = function push(opcode){var offset=this._offset;var type=opcode[0];var op1=opcode[1];var op2=opcode[2];var op3=opcode[3];this.opcodes[this._offset++] = type;this.opcodes[this._offset++] = op1;this.opcodes[this._offset++] = op2;this.opcodes[this._offset++] = op3;return offset;};babelHelpers.createClass(Program,[{key:'next',get:function(){return this._offset;}},{key:'current',get:function(){return this._offset - 4;}}]);return Program;})();var Environment=(function(){function Environment(_ref27){var appendOperations=_ref27.appendOperations;var updateOperations=_ref27.updateOperations;this._macros = null;this._transaction = null;this.constants = new Constants();this.program = new Program();this.appendOperations = appendOperations;this.updateOperations = updateOperations;}Environment.prototype.toConditionalReference = function toConditionalReference(reference){return new ConditionalReference(reference);};Environment.prototype.getAppendOperations = function getAppendOperations(){return this.appendOperations;};Environment.prototype.getDOM = function getDOM(){return this.updateOperations;};Environment.prototype.getIdentity = function getIdentity(object){return _glimmerUtil.ensureGuid(object) + '';};Environment.prototype.begin = function begin(){_glimmerUtil.assert(!this._transaction,'Cannot start a nested transaction');this._transaction = new Transaction();};Environment.prototype.didCreate = function didCreate(component,manager){this.transaction.didCreate(component,manager);};Environment.prototype.didUpdate = function didUpdate(component,manager){this.transaction.didUpdate(component,manager);};Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier,manager){this.transaction.scheduleInstallModifier(modifier,manager);};Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier,manager){this.transaction.scheduleUpdateModifier(modifier,manager);};Environment.prototype.didDestroy = function didDestroy(d){this.transaction.didDestroy(d);};Environment.prototype.commit = function commit(){this.transaction.commit();this._transaction = null;};Environment.prototype.attributeFor = function attributeFor(element,attr,isTrusting,namespace){return defaultManagers(element,attr,isTrusting,namespace === undefined?null:namespace);};Environment.prototype.macros = function macros(){var macros=this._macros;if(!macros){this._macros = macros = populateBuiltins();}return macros;};babelHelpers.createClass(Environment,[{key:'transaction',get:function(){return _glimmerUtil.expect(this._transaction,'must be in a transaction');}}]);return Environment;})();var RenderResult=(function(){function RenderResult(env,updating,bounds){this.env = env;this.updating = updating;this.bounds = bounds;}RenderResult.prototype.rerender = function rerender(){var _ref28=arguments.length <= 0 || arguments[0] === undefined?{alwaysRevalidate:false}:arguments[0];var _ref28$alwaysRevalidate=_ref28.alwaysRevalidate;var alwaysRevalidate=_ref28$alwaysRevalidate === undefined?false:_ref28$alwaysRevalidate;var env=this.env;var updating=this.updating;var vm=new UpdatingVM(env,{alwaysRevalidate:alwaysRevalidate});vm.execute(updating,this);};RenderResult.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};RenderResult.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};RenderResult.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};RenderResult.prototype.opcodes = function opcodes(){return this.updating;};RenderResult.prototype.handleException = function handleException(){throw "this should never happen";};RenderResult.prototype.destroy = function destroy(){this.bounds.destroy();clear(this.bounds);};return RenderResult;})();var CapturedFrame=function CapturedFrame(operand,args,condition){this.operand = operand;this.args = args;this.condition = condition;};var Frame=(function(){function Frame(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];this.ops = ops;this.component = component;this.manager = manager;this.shadow = shadow;this.operand = null;this.immediate = null;this.args = null;this.callerScope = null;this.blocks = null;this.condition = null;this.iterator = null;this.key = null;this.ip = ops[0];}Frame.prototype.capture = function capture(){return new CapturedFrame(this.operand,this.args,this.condition);};Frame.prototype.restore = function restore(frame){this.operand = frame['operand'];this.args = frame['args'];this.condition = frame['condition'];};return Frame;})();var FrameStack=(function(){function FrameStack(){this.frames = [];this.frame = null;}FrameStack.prototype.push = function push(ops){var component=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var manager=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var shadow=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var frame=this.frame === null?this.frame = 0:++this.frame;if(this.frames.length <= frame){this.frames.push(null);}this.frames[frame] = new Frame(ops,component,manager,shadow);};FrameStack.prototype.pop = function pop(){var frames=this.frames;var frame=this.frame;frames[_glimmerUtil.expect(frame,'only pop after pushing')] = null;this.frame = frame === 0?null:frame - 1;};FrameStack.prototype.capture = function capture(){return this.currentFrame.capture();};FrameStack.prototype.restore = function restore(frame){this.currentFrame.restore(frame);};FrameStack.prototype.getOps = function getOps(){return this.currentFrame.ops;};FrameStack.prototype.getCurrent = function getCurrent(){return this.currentFrame.ip;};FrameStack.prototype.setCurrent = function setCurrent(ip){return this.currentFrame.ip = ip;};FrameStack.prototype.getOperand = function getOperand(){return _glimmerUtil.unwrap(this.currentFrame.operand);};FrameStack.prototype.setOperand = function setOperand(operand){return this.currentFrame.operand = operand;};FrameStack.prototype.getImmediate = function getImmediate(){return this.currentFrame.immediate;};FrameStack.prototype.setImmediate = function setImmediate(value){return this.currentFrame.immediate = value;}; // FIXME: These options are required in practice by the existing code, but +// figure out why. +FrameStack.prototype.getArgs = function getArgs(){return this.currentFrame.args;};FrameStack.prototype.setArgs = function setArgs(args){return this.currentFrame.args = args;};FrameStack.prototype.getCondition = function getCondition(){return _glimmerUtil.unwrap(this.currentFrame.condition);};FrameStack.prototype.setCondition = function setCondition(condition){return this.currentFrame.condition = condition;};FrameStack.prototype.getIterator = function getIterator(){return _glimmerUtil.unwrap(this.currentFrame.iterator);};FrameStack.prototype.setIterator = function setIterator(iterator){return this.currentFrame.iterator = iterator;};FrameStack.prototype.getKey = function getKey(){return this.currentFrame.key;};FrameStack.prototype.setKey = function setKey(key){return this.currentFrame.key = key;};FrameStack.prototype.getBlocks = function getBlocks(){return _glimmerUtil.unwrap(this.currentFrame.blocks);};FrameStack.prototype.setBlocks = function setBlocks(blocks){return this.currentFrame.blocks = blocks;};FrameStack.prototype.getCallerScope = function getCallerScope(){return _glimmerUtil.unwrap(this.currentFrame.callerScope);};FrameStack.prototype.setCallerScope = function setCallerScope(callerScope){return this.currentFrame.callerScope = callerScope;};FrameStack.prototype.getComponent = function getComponent(){return _glimmerUtil.unwrap(this.currentFrame.component);};FrameStack.prototype.getManager = function getManager(){return _glimmerUtil.unwrap(this.currentFrame.manager);};FrameStack.prototype.getShadow = function getShadow(){return this.currentFrame.shadow;};FrameStack.prototype.goto = function goto(ip){this.setCurrent(ip);};FrameStack.prototype.hasOpcodes = function hasOpcodes(){return this.frame !== null;};FrameStack.prototype.nextStatement = function nextStatement(env){var ip=this.frames[_glimmerUtil.unwrap(this.frame)].ip;var ops=this.getOps();if(ip <= ops[1]){var program=env.program;this.setCurrent(ip + 4);return program.opcode(ip);}else {this.pop();return null;}};babelHelpers.createClass(FrameStack,[{key:'currentFrame',get:function(){return this.frames[_glimmerUtil.unwrap(this.frame)];}}]);return FrameStack;})();var VM=(function(){function VM(env,scope,dynamicScope,elementStack){this.env = env;this.elementStack = elementStack;this.dynamicScopeStack = new _glimmerUtil.Stack();this.scopeStack = new _glimmerUtil.Stack();this.updatingOpcodeStack = new _glimmerUtil.Stack();this.cacheGroups = new _glimmerUtil.Stack();this.listBlockStack = new _glimmerUtil.Stack();this.frame = new FrameStack();this.env = env;this.constants = env.constants;this.elementStack = elementStack;this.scopeStack.push(scope);this.dynamicScopeStack.push(dynamicScope);}VM.initial = function initial(env,self,dynamicScope,elementStack,size){var scope=Scope.root(self,size);return new VM(env,scope,dynamicScope,elementStack);};VM.prototype.capture = function capture(){return {env:this.env,scope:this.scope(),dynamicScope:this.dynamicScope(),frame:this.frame.capture()};};VM.prototype.goto = function goto(ip){ // assert(this.frame.getOps().contains(op), `Illegal jump to ${op.label}`); +this.frame.goto(ip);};VM.prototype.beginCacheGroup = function beginCacheGroup(){this.cacheGroups.push(this.updating().tail());};VM.prototype.commitCacheGroup = function commitCacheGroup(){ // JumpIfNotModified(END) +// (head) +// (....) +// (tail) +// DidModify +// END: Noop +var END=new LabelOpcode("END");var opcodes=this.updating();var marker=this.cacheGroups.pop();var head=marker?opcodes.nextNode(marker):opcodes.head();var tail=opcodes.tail();var tag=_glimmerReference.combineSlice(new _glimmerUtil.ListSlice(head,tail));var guard=new JumpIfNotModifiedOpcode(tag,END);opcodes.insertBefore(guard,head);opcodes.append(new DidModifyOpcode(guard));opcodes.append(END);};VM.prototype.enter = function enter(sliceId){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var slice=this.constants.getSlice(sliceId);var tryOpcode=new TryOpcode(slice,state,tracker,updating);this.didEnter(tryOpcode,updating);};VM.prototype.enterWithKey = function enterWithKey(key,ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushUpdatableBlock();var state=this.capture();var tryOpcode=new TryOpcode(ops,state,tracker,updating);this.listBlock().map[key] = tryOpcode;this.didEnter(tryOpcode,updating);};VM.prototype.enterList = function enterList(ops){var updating=new _glimmerUtil.LinkedList();var tracker=this.stack().pushBlockList(updating);var state=this.capture();var artifacts=this.frame.getIterator().artifacts;var opcode=new ListBlockOpcode(ops,state,tracker,updating,artifacts);this.listBlockStack.push(opcode);this.didEnter(opcode,updating);};VM.prototype.didEnter = function didEnter(opcode,updating){this.updateWith(opcode);this.updatingOpcodeStack.push(updating);};VM.prototype.exit = function exit(){this.stack().popBlock();this.updatingOpcodeStack.pop();var parent=this.updating().tail();parent.didInitializeChildren();};VM.prototype.exitList = function exitList(){this.exit();this.listBlockStack.pop();};VM.prototype.updateWith = function updateWith(opcode){this.updating().append(opcode);};VM.prototype.listBlock = function listBlock(){return _glimmerUtil.expect(this.listBlockStack.current,'expected a list block');};VM.prototype.updating = function updating(){return _glimmerUtil.expect(this.updatingOpcodeStack.current,'expected updating opcode on the updating opcode stack');};VM.prototype.stack = function stack(){return this.elementStack;};VM.prototype.scope = function scope(){return _glimmerUtil.expect(this.scopeStack.current,'expected scope on the scope stack');};VM.prototype.dynamicScope = function dynamicScope(){return _glimmerUtil.expect(this.dynamicScopeStack.current,'expected dynamic scope on the dynamic scope stack');};VM.prototype.pushFrame = function pushFrame(block,args,callerScope){this.frame.push(block.slice);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushComponentFrame = function pushComponentFrame(layout,args,callerScope,component,manager,shadow){this.frame.push(layout.slice,component,manager,shadow);if(args)this.frame.setArgs(args);if(args && args.blocks)this.frame.setBlocks(args.blocks);if(callerScope)this.frame.setCallerScope(callerScope);};VM.prototype.pushEvalFrame = function pushEvalFrame(slice){this.frame.push(slice);};VM.prototype.pushChildScope = function pushChildScope(){this.scopeStack.push(this.scope().child());};VM.prototype.pushCallerScope = function pushCallerScope(){this.scopeStack.push(_glimmerUtil.expect(this.scope().getCallerScope(),'pushCallerScope is called when a caller scope is present'));};VM.prototype.pushDynamicScope = function pushDynamicScope(){var child=this.dynamicScope().child();this.dynamicScopeStack.push(child);return child;};VM.prototype.pushRootScope = function pushRootScope(self,size){var scope=Scope.root(self,size);this.scopeStack.push(scope);return scope;};VM.prototype.popScope = function popScope(){this.scopeStack.pop();};VM.prototype.popDynamicScope = function popDynamicScope(){this.dynamicScopeStack.pop();};VM.prototype.newDestroyable = function newDestroyable(d){this.stack().newDestroyable(d);}; /// SCOPE HELPERS +VM.prototype.getSelf = function getSelf(){return this.scope().getSelf();};VM.prototype.referenceForSymbol = function referenceForSymbol(symbol){return this.scope().getSymbol(symbol);};VM.prototype.getArgs = function getArgs(){return this.frame.getArgs();}; /// EXECUTION +VM.prototype.resume = function resume(opcodes,frame){return this.execute(opcodes,function(vm){return vm.frame.restore(frame);});};VM.prototype.execute = function execute(opcodes,initialize){_glimmerUtil.LOGGER.debug("[VM] Begin program execution");var elementStack=this.elementStack;var frame=this.frame;var updatingOpcodeStack=this.updatingOpcodeStack;var env=this.env;elementStack.pushSimpleBlock();updatingOpcodeStack.push(new _glimmerUtil.LinkedList());frame.push(opcodes);if(initialize)initialize(this);var opcode=undefined;while(frame.hasOpcodes()) {if(opcode = frame.nextStatement(this.env)){_glimmerUtil.LOGGER.trace(opcode);APPEND_OPCODES.evaluate(this,opcode);}}_glimmerUtil.LOGGER.debug("[VM] Completed program execution");return new RenderResult(env,_glimmerUtil.expect(updatingOpcodeStack.pop(),'there should be a final updating opcode stack'),elementStack.popBlock());};VM.prototype.evaluateOpcode = function evaluateOpcode(opcode){APPEND_OPCODES.evaluate(this,opcode);}; // Make sure you have opcodes that push and pop a scope around this opcode +// if you need to change the scope. +VM.prototype.invokeBlock = function invokeBlock(block,args){var compiled=block.compile(this.env);this.pushFrame(compiled,args);};VM.prototype.invokePartial = function invokePartial(block){var compiled=block.compile(this.env);this.pushFrame(compiled);};VM.prototype.invokeLayout = function invokeLayout(args,layout,callerScope,component,manager,shadow){this.pushComponentFrame(layout,args,callerScope,component,manager,shadow);};VM.prototype.evaluateOperand = function evaluateOperand(expr){this.frame.setOperand(expr.evaluate(this));};VM.prototype.evaluateArgs = function evaluateArgs(args){var evaledArgs=this.frame.setArgs(args.evaluate(this));this.frame.setOperand(evaledArgs.positional.at(0));};VM.prototype.bindPositionalArgs = function bindPositionalArgs(symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPositionalArgs assumes a previous setArgs');var positional=args.positional;var scope=this.scope();for(var i=0;i < symbols.length;i++) {scope.bindSymbol(symbols[i],positional.at(i));}};VM.prototype.bindNamedArgs = function bindNamedArgs(names,symbols){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindNamedArgs assumes a previous setArgs');var scope=this.scope();var named=args.named;for(var i=0;i < names.length;i++) {var _name2=this.constants.getString(names[i]);scope.bindSymbol(symbols[i],named.get(_name2));}};VM.prototype.bindBlocks = function bindBlocks(names,symbols){var blocks=this.frame.getBlocks();var scope=this.scope();for(var i=0;i < names.length;i++) {var _name3=this.constants.getString(names[i]);scope.bindBlock(symbols[i],blocks && blocks[_name3] || null);}};VM.prototype.bindPartialArgs = function bindPartialArgs(symbol){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindPartialArgs assumes a previous setArgs');var scope=this.scope();_glimmerUtil.assert(args,"Cannot bind named args");scope.bindPartialArgs(symbol,args);};VM.prototype.bindCallerScope = function bindCallerScope(){var callerScope=this.frame.getCallerScope();var scope=this.scope();_glimmerUtil.assert(callerScope,"Cannot bind caller scope");scope.bindCallerScope(callerScope);};VM.prototype.bindDynamicScope = function bindDynamicScope(names){var args=_glimmerUtil.expect(this.frame.getArgs(),'bindDynamicScope assumes a previous setArgs');var scope=this.dynamicScope();_glimmerUtil.assert(args,"Cannot bind dynamic scope");for(var i=0;i < names.length;i++) {var _name4=this.constants.getString(names[i]);scope.set(_name4,args.named.get(_name4));}};return VM;})();var UpdatingVM=(function(){function UpdatingVM(env,_ref29){var _ref29$alwaysRevalidate=_ref29.alwaysRevalidate;var alwaysRevalidate=_ref29$alwaysRevalidate === undefined?false:_ref29$alwaysRevalidate;this.frameStack = new _glimmerUtil.Stack();this.env = env;this.constants = env.constants;this.dom = env.getDOM();this.alwaysRevalidate = alwaysRevalidate;}UpdatingVM.prototype.execute = function execute(opcodes,handler){var frameStack=this.frameStack;this.try(opcodes,handler);while(true) {if(frameStack.isEmpty())break;var opcode=this.frame.nextStatement();if(opcode === null){this.frameStack.pop();continue;}_glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type);_glimmerUtil.LOGGER.trace(opcode);opcode.evaluate(this);}};UpdatingVM.prototype.goto = function goto(op){this.frame.goto(op);};UpdatingVM.prototype.try = function _try(ops,handler){this.frameStack.push(new UpdatingVMFrame(this,ops,handler));};UpdatingVM.prototype.throw = function _throw(){this.frame.handleException();this.frameStack.pop();};UpdatingVM.prototype.evaluateOpcode = function evaluateOpcode(opcode){opcode.evaluate(this);};babelHelpers.createClass(UpdatingVM,[{key:'frame',get:function(){return _glimmerUtil.expect(this.frameStack.current,'bug: expected a frame');}}]);return UpdatingVM;})();var BlockOpcode=(function(_UpdatingOpcode8){babelHelpers.inherits(BlockOpcode,_UpdatingOpcode8);function BlockOpcode(ops,state,bounds,children){_UpdatingOpcode8.call(this);this.ops = ops;this.type = "block";this.next = null;this.prev = null;var env=state.env;var scope=state.scope;var dynamicScope=state.dynamicScope;var frame=state.frame;this.children = children;this.env = env;this.scope = scope;this.dynamicScope = dynamicScope;this.frame = frame;this.bounds = bounds;}BlockOpcode.prototype.parentElement = function parentElement(){return this.bounds.parentElement();};BlockOpcode.prototype.firstNode = function firstNode(){return this.bounds.firstNode();};BlockOpcode.prototype.lastNode = function lastNode(){return this.bounds.lastNode();};BlockOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,null);};BlockOpcode.prototype.destroy = function destroy(){this.bounds.destroy();};BlockOpcode.prototype.didDestroy = function didDestroy(){this.env.didDestroy(this.bounds);};BlockOpcode.prototype.toJSON = function toJSON(){var details=_glimmerUtil.dict();details["guid"] = '' + this._guid;return {guid:this._guid,type:this.type,details:details,children:this.children.toArray().map(function(op){return op.toJSON();})};};return BlockOpcode;})(UpdatingOpcode);var TryOpcode=(function(_BlockOpcode){babelHelpers.inherits(TryOpcode,_BlockOpcode);function TryOpcode(ops,state,bounds,children){_BlockOpcode.call(this,ops,state,bounds,children);this.type = "try";this.tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);}TryOpcode.prototype.didInitializeChildren = function didInitializeChildren(){this._tag.update(_glimmerReference.combineSlice(this.children));};TryOpcode.prototype.evaluate = function evaluate(vm){vm.try(this.children,this);};TryOpcode.prototype.handleException = function handleException(){var env=this.env;var scope=this.scope;var ops=this.ops;var dynamicScope=this.dynamicScope;var frame=this.frame;var elementStack=ElementStack.resume(this.env,this.bounds,this.bounds.reset(env));var vm=new VM(env,scope,dynamicScope,elementStack);var result=vm.resume(ops,frame);this.children = result.opcodes();this.didInitializeChildren();};TryOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode.prototype.toJSON.call(this);var details=json["details"];if(!details){details = json["details"] = {};}return _BlockOpcode.prototype.toJSON.call(this);};return TryOpcode;})(BlockOpcode);var ListRevalidationDelegate=(function(){function ListRevalidationDelegate(opcode,marker){this.opcode = opcode;this.marker = marker;this.didInsert = false;this.didDelete = false;this.map = opcode.map;this.updating = opcode['children'];}ListRevalidationDelegate.prototype.insert = function insert(key,item,memo,before){var map=this.map;var opcode=this.opcode;var updating=this.updating;var nextSibling=null;var reference=null;if(before){reference = map[before];nextSibling = reference['bounds'].firstNode();}else {nextSibling = this.marker;}var vm=opcode.vmForInsertion(nextSibling);var tryOpcode=null;vm.execute(opcode.ops,function(vm){vm.frame.setArgs(EvaluatedArgs.positional([item,memo]));vm.frame.setOperand(item);vm.frame.setCondition(new _glimmerReference.ConstReference(true));vm.frame.setKey(key);var state=vm.capture();var tracker=vm.stack().pushUpdatableBlock();tryOpcode = new TryOpcode(opcode.ops,state,tracker,vm.updating());});tryOpcode.didInitializeChildren();updating.insertBefore(tryOpcode,reference);map[key] = tryOpcode;this.didInsert = true;};ListRevalidationDelegate.prototype.retain = function retain(_key,_item,_memo){};ListRevalidationDelegate.prototype.move = function move(key,_item,_memo,before){var map=this.map;var updating=this.updating;var entry=map[key];var reference=map[before] || null;if(before){moveBounds(entry,reference.firstNode());}else {moveBounds(entry,this.marker);}updating.remove(entry);updating.insertBefore(entry,reference);};ListRevalidationDelegate.prototype.delete = function _delete(key){var map=this.map;var opcode=map[key];opcode.didDestroy();clear(opcode);this.updating.remove(opcode);delete map[key];this.didDelete = true;};ListRevalidationDelegate.prototype.done = function done(){this.opcode.didInitializeChildren(this.didInsert || this.didDelete);};return ListRevalidationDelegate;})();var ListBlockOpcode=(function(_BlockOpcode2){babelHelpers.inherits(ListBlockOpcode,_BlockOpcode2);function ListBlockOpcode(ops,state,bounds,children,artifacts){_BlockOpcode2.call(this,ops,state,bounds,children);this.type = "list-block";this.map = _glimmerUtil.dict();this.lastIterated = _glimmerReference.INITIAL;this.artifacts = artifacts;var _tag=this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([artifacts.tag,_tag]);}ListBlockOpcode.prototype.didInitializeChildren = function didInitializeChildren(){var listDidChange=arguments.length <= 0 || arguments[0] === undefined?true:arguments[0];this.lastIterated = this.artifacts.tag.value();if(listDidChange){this._tag.update(_glimmerReference.combineSlice(this.children));}};ListBlockOpcode.prototype.evaluate = function evaluate(vm){var artifacts=this.artifacts;var lastIterated=this.lastIterated;if(!artifacts.tag.validate(lastIterated)){var bounds=this.bounds;var dom=vm.dom;var marker=dom.createComment('');dom.insertAfter(bounds.parentElement(),marker,_glimmerUtil.expect(bounds.lastNode(),"can't insert after an empty bounds"));var target=new ListRevalidationDelegate(this,marker);var synchronizer=new _glimmerReference.IteratorSynchronizer({target:target,artifacts:artifacts});synchronizer.sync();this.parentElement().removeChild(marker);} // Run now-updated updating opcodes +_BlockOpcode2.prototype.evaluate.call(this,vm);};ListBlockOpcode.prototype.vmForInsertion = function vmForInsertion(nextSibling){var env=this.env;var scope=this.scope;var dynamicScope=this.dynamicScope;var elementStack=ElementStack.forInitialRender(this.env,this.bounds.parentElement(),nextSibling);return new VM(env,scope,dynamicScope,elementStack);};ListBlockOpcode.prototype.toJSON = function toJSON(){var json=_BlockOpcode2.prototype.toJSON.call(this);var map=this.map;var inner=Object.keys(map).map(function(key){return JSON.stringify(key) + ': ' + map[key]._guid;}).join(", ");var details=json["details"];if(!details){details = json["details"] = {};}details["map"] = '{' + inner + '}';return json;};return ListBlockOpcode;})(BlockOpcode);var UpdatingVMFrame=(function(){function UpdatingVMFrame(vm,ops,exceptionHandler){this.vm = vm;this.ops = ops;this.exceptionHandler = exceptionHandler;this.vm = vm;this.ops = ops;this.current = ops.head();}UpdatingVMFrame.prototype.goto = function goto(op){this.current = op;};UpdatingVMFrame.prototype.nextStatement = function nextStatement(){var current=this.current;var ops=this.ops;if(current)this.current = ops.nextNode(current);return current;};UpdatingVMFrame.prototype.handleException = function handleException(){if(this.exceptionHandler){this.exceptionHandler.handleException();}};return UpdatingVMFrame;})();var CompiledBlock=function CompiledBlock(slice){this.start = slice[0];this.end = slice[1];this.slice = slice;};var CompiledProgram=(function(_CompiledBlock){babelHelpers.inherits(CompiledProgram,_CompiledBlock);function CompiledProgram(slice,symbols){_CompiledBlock.call(this,slice);this.symbols = symbols;}return CompiledProgram;})(CompiledBlock);function entryPoint(meta){return new ProgramSymbolTable(meta);}function layout(meta,wireNamed,wireYields,hasPartials){var _symbols3=symbols(wireNamed,wireYields,hasPartials);var named=_symbols3.named;var yields=_symbols3.yields;var partialSymbol=_symbols3.partialSymbol;var size=_symbols3.size;return new ProgramSymbolTable(meta,named,yields,partialSymbol,size);}function block(parent,locals){var localsMap=null;var program=parent['program'];if(locals.length !== 0){(function(){var map=localsMap = _glimmerUtil.dict();locals.forEach(function(l){return map[l] = program.size++;});})();}return new BlockSymbolTable(parent,program,localsMap);}function symbols(named,yields,hasPartials){var yieldsMap=null;var namedMap=null;var size=1;if(yields.length !== 0){(function(){var map=yieldsMap = _glimmerUtil.dict();yields.forEach(function(y){return map[y] = size++;});})();}if(named.length !== 0){(function(){var map=namedMap = _glimmerUtil.dict();named.forEach(function(y){return map[y] = size++;});})();}var partialSymbol=hasPartials?size++:null;return {named:namedMap,yields:yieldsMap,partialSymbol:partialSymbol,size:size};}var ProgramSymbolTable=(function(){function ProgramSymbolTable(meta){var named=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var yields=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var partialArgs=arguments.length <= 3 || arguments[3] === undefined?null:arguments[3];var size=arguments.length <= 4 || arguments[4] === undefined?1:arguments[4];this.meta = meta;this.named = named;this.yields = yields;this.partialArgs = partialArgs;this.size = size;this.program = this;}ProgramSymbolTable.prototype.getMeta = function getMeta(){return this.meta;};ProgramSymbolTable.prototype.getSymbols = function getSymbols(){return {named:this.named,yields:this.yields,locals:null,partialArgs:this.partialArgs};};ProgramSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local')return null;return this[kind] && this[kind][name];};ProgramSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.partialArgs || 0;};return ProgramSymbolTable;})();var BlockSymbolTable=(function(){function BlockSymbolTable(parent,program,locals){this.parent = parent;this.program = program;this.locals = locals;}BlockSymbolTable.prototype.getMeta = function getMeta(){return this.program.getMeta();};BlockSymbolTable.prototype.getSymbols = function getSymbols(){return {named:null,yields:null,locals:this.locals,partialArgs:null};};BlockSymbolTable.prototype.getSymbol = function getSymbol(kind,name){if(kind === 'local'){return this.getLocal(name);}else {return this.program.getSymbol(kind,name);}};BlockSymbolTable.prototype.getLocal = function getLocal(name){var locals=this.locals;var parent=this.parent;var symbol=locals && locals[name];if(!symbol && parent){symbol = parent.getSymbol('local',name);}return symbol;};BlockSymbolTable.prototype.getPartialArgs = function getPartialArgs(){return this.program.getPartialArgs();};return BlockSymbolTable;})();var Specialize=(function(){function Specialize(){this.names = _glimmerUtil.dict();this.funcs = [];}Specialize.prototype.add = function add(name,func){this.funcs.push(func);this.names[name] = this.funcs.length - 1;};Specialize.prototype.specialize = function specialize(sexp,table){var name=sexp[0];var index=this.names[name];if(index === undefined)return sexp;var func=this.funcs[index];_glimmerUtil.assert(!!func,'expected a specialization for ' + sexp[0]);return func(sexp,table);};return Specialize;})();var SPECIALIZE=new Specialize();var E=_glimmerWireFormat.Expressions;SPECIALIZE.add('append',function(sexp,_symbolTable){var path=sexp[1];if(Array.isArray(path) && (E.isUnknown(path) || E.isGet(path))){if(path[1].length !== 1){return ['unoptimized-append',sexp[1],sexp[2]];}}return ['optimized-append',sexp[1],sexp[2]];});SPECIALIZE.add('dynamic-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],false];});SPECIALIZE.add('trusting-attr',function(sexp,_symbolTable){return ['any-dynamic-attr',sexp[1],sexp[2],sexp[3],true];});SPECIALIZE.add('partial',function(sexp,_table){var expression=sexp[1];if(typeof expression === 'string'){return ['static-partial',expression];}else {return ['dynamic-partial',expression];}});function compileStatement(statement,builder){var refined=SPECIALIZE.specialize(statement,builder.symbolTable);STATEMENTS.compile(refined,builder);}var Template=function Template(statements,symbolTable){this.statements = statements;this.symbolTable = symbolTable;};var Layout=(function(_Template){babelHelpers.inherits(Layout,_Template);function Layout(){_Template.apply(this,arguments);}return Layout;})(Template);var EntryPoint=(function(_Template2){babelHelpers.inherits(EntryPoint,_Template2);function EntryPoint(){_Template2.apply(this,arguments);}EntryPoint.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),this.symbolTable.size);};return EntryPoint;})(Template);var InlineBlock=(function(_Template3){babelHelpers.inherits(InlineBlock,_Template3);function InlineBlock(){_Template3.apply(this,arguments);}InlineBlock.prototype.splat = function splat(builder){var table=builder.symbolTable;var locals=table.getSymbols().locals;if(locals){builder.pushChildScope();builder.bindPositionalArgsForLocals(locals);}for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,builder);}if(locals){builder.popScope();}};InlineBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);this.splat(b);return new CompiledBlock(b.toSlice());};return InlineBlock;})(Template);var PartialBlock=(function(_Template4){babelHelpers.inherits(PartialBlock,_Template4);function PartialBlock(){_Template4.apply(this,arguments);}PartialBlock.prototype.compile = function compile(env){var table=this.symbolTable;var b=builder(env,table);for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];var refined=SPECIALIZE.specialize(statement,table);STATEMENTS.compile(refined,b);}return new CompiledProgram(b.toSlice(),table.size);};return PartialBlock;})(Template);var Scanner=(function(){function Scanner(block,meta,env){this.block = block;this.meta = meta;this.env = env;}Scanner.prototype.scanEntryPoint = function scanEntryPoint(){var block=this.block;var meta=this.meta;var symbolTable=entryPoint(meta);var child=scanBlock(block,symbolTable,this.env);return new EntryPoint(child.statements,symbolTable);};Scanner.prototype.scanLayout = function scanLayout(){var block=this.block;var meta=this.meta;var named=block.named;var yields=block.yields;var hasPartials=block.hasPartials;var symbolTable=layout(meta,named,yields,hasPartials);var child=scanBlock(block,symbolTable,this.env);return new Layout(child.statements,symbolTable);};Scanner.prototype.scanPartial = function scanPartial(symbolTable){var block=this.block;var child=scanBlock(block,symbolTable,this.env);return new PartialBlock(child.statements,symbolTable);};return Scanner;})();function scanBlock(_ref30,symbolTable,env){var statements=_ref30.statements;return new RawInlineBlock(env,symbolTable,statements).scan();}var BaselineSyntax;(function(BaselineSyntax){BaselineSyntax.isScannedComponent = _glimmerWireFormat.is('scanned-component');BaselineSyntax.isPrimitiveElement = _glimmerWireFormat.is('open-primitive-element');BaselineSyntax.isOptimizedAppend = _glimmerWireFormat.is('optimized-append');BaselineSyntax.isUnoptimizedAppend = _glimmerWireFormat.is('unoptimized-append');BaselineSyntax.isAnyAttr = _glimmerWireFormat.is('any-dynamic-attr');BaselineSyntax.isStaticPartial = _glimmerWireFormat.is('static-partial');BaselineSyntax.isDynamicPartial = _glimmerWireFormat.is('dynamic-partial');BaselineSyntax.isFunctionExpression = _glimmerWireFormat.is('function');BaselineSyntax.isNestedBlock = _glimmerWireFormat.is('nested-block');BaselineSyntax.isScannedBlock = _glimmerWireFormat.is('scanned-block');BaselineSyntax.isDebugger = _glimmerWireFormat.is('debugger');var NestedBlock;(function(NestedBlock){function defaultBlock(sexp){return sexp[4];}NestedBlock.defaultBlock = defaultBlock;function inverseBlock(sexp){return sexp[5];}NestedBlock.inverseBlock = inverseBlock;function params(sexp){return sexp[2];}NestedBlock.params = params;function hash(sexp){return sexp[3];}NestedBlock.hash = hash;})(NestedBlock = BaselineSyntax.NestedBlock || (BaselineSyntax.NestedBlock = {}));})(BaselineSyntax || (exports.BaselineSyntax = BaselineSyntax = {}));var RawInlineBlock=(function(){function RawInlineBlock(env,table,statements){this.env = env;this.table = table;this.statements = statements;}RawInlineBlock.prototype.scan = function scan(){var buffer=[];for(var i=0;i < this.statements.length;i++) {var statement=this.statements[i];if(_glimmerWireFormat.Statements.isBlock(statement)){buffer.push(this.specializeBlock(statement));}else if(_glimmerWireFormat.Statements.isComponent(statement)){buffer.push.apply(buffer,this.specializeComponent(statement));}else {buffer.push(statement);}}return new InlineBlock(buffer,this.table);};RawInlineBlock.prototype.specializeBlock = function specializeBlock(block$$){var path=block$$[1];var params=block$$[2];var hash=block$$[3];var template=block$$[4];var inverse=block$$[5];return ['scanned-block',path,params,hash,this.child(template),this.child(inverse)];};RawInlineBlock.prototype.specializeComponent = function specializeComponent(sexp){var tag=sexp[1];var component=sexp[2];if(this.env.hasComponentDefinition([tag],this.table)){var child=this.child(component);var attrs=new RawInlineBlock(this.env,this.table,component.attrs);return [['scanned-component',tag,attrs,component.args,child]];}else {var buf=[];buf.push(['open-element',tag,[]]);buf.push.apply(buf,component.attrs);buf.push(['flush-element']);buf.push.apply(buf,component.statements);buf.push(['close-element']);return buf;}};RawInlineBlock.prototype.child = function child(block$$){if(!block$$)return null;var table=block(this.table,block$$.locals);return new RawInlineBlock(this.env,table,block$$.statements);};return RawInlineBlock;})();function compileLayout(compilable,env){var builder=new ComponentLayoutBuilder(env);compilable.compile(builder);return builder.compile();}var ComponentLayoutBuilder=(function(){function ComponentLayoutBuilder(env){this.env = env;}ComponentLayoutBuilder.prototype.wrapLayout = function wrapLayout(layout){this.inner = new WrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.fromLayout = function fromLayout(layout){this.inner = new UnwrappedBuilder(this.env,layout);};ComponentLayoutBuilder.prototype.compile = function compile(){return this.inner.compile();};babelHelpers.createClass(ComponentLayoutBuilder,[{key:'tag',get:function(){return this.inner.tag;}},{key:'attrs',get:function(){return this.inner.attrs;}}]);return ComponentLayoutBuilder;})();var WrappedBuilder=(function(){function WrappedBuilder(env,layout){this.env = env;this.layout = layout;this.tag = new ComponentTagBuilder();this.attrs = new ComponentAttrsBuilder();}WrappedBuilder.prototype.compile = function compile(){ //========DYNAMIC +// PutValue(TagExpr) +// Test +// JumpUnless(BODY) +// OpenDynamicPrimitiveElement +// DidCreateElement +// ...attr statements... +// FlushElement +// BODY: Noop +// ...body statements... +// PutValue(TagExpr) +// Test +// JumpUnless(END) +// CloseElement +// END: Noop +// DidRenderLayout +// Exit +// +//========STATIC +// OpenPrimitiveElementOpcode +// DidCreateElement +// ...attr statements... +// FlushElement +// ...body statements... +// CloseElement +// DidRenderLayout +// Exit +var env=this.env;var layout=this.layout;var symbolTable=layout.symbolTable;var b=builder(env,layout.symbolTable);b.startLabels();var dynamicTag=this.tag.getDynamic();var staticTag=undefined;if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('BODY');b.openDynamicPrimitiveElement();b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();b.label('BODY');}else if(staticTag = this.tag.getStatic()){b.openPrimitiveElement(staticTag);b.didCreateElement();this.attrs['buffer'].forEach(function(statement){return compileStatement(statement,b);});b.flushElement();}b.preludeForLayout(layout);layout.statements.forEach(function(statement){return compileStatement(statement,b);});if(dynamicTag){b.putValue(dynamicTag);b.test('simple');b.jumpUnless('END');b.closeElement();b.label('END');}else if(staticTag){b.closeElement();}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),symbolTable.size);};return WrappedBuilder;})();function isOpenElement(value){var type=value[0];return type === 'open-element' || type === 'open-primitive-element';}var UnwrappedBuilder=(function(){function UnwrappedBuilder(env,layout){this.env = env;this.layout = layout;this.attrs = new ComponentAttrsBuilder();}UnwrappedBuilder.prototype.compile = function compile(){var env=this.env;var layout=this.layout;var b=builder(env,layout.symbolTable);b.startLabels();b.preludeForLayout(layout);var attrs=this.attrs['buffer'];var attrsInserted=false;for(var i=0;i < layout.statements.length;i++) {var statement=layout.statements[i];if(!attrsInserted && isOpenElement(statement)){b.openComponentElement(statement[1]);b.didCreateElement();b.shadowAttributes();attrs.forEach(function(statement){return compileStatement(statement,b);});attrsInserted = true;}else {compileStatement(statement,b);}}b.didRenderLayout();b.stopLabels();return new CompiledProgram(b.toSlice(),layout.symbolTable.size);};babelHelpers.createClass(UnwrappedBuilder,[{key:'tag',get:function(){throw new Error('BUG: Cannot call `tag` on an UnwrappedBuilder');}}]);return UnwrappedBuilder;})();var ComponentTagBuilder=(function(){function ComponentTagBuilder(){this.isDynamic = null;this.isStatic = null;this.staticTagName = null;this.dynamicTagName = null;}ComponentTagBuilder.prototype.getDynamic = function getDynamic(){if(this.isDynamic){return this.dynamicTagName;}};ComponentTagBuilder.prototype.getStatic = function getStatic(){if(this.isStatic){return this.staticTagName;}};ComponentTagBuilder.prototype.static = function _static(tagName){this.isStatic = true;this.staticTagName = tagName;};ComponentTagBuilder.prototype.dynamic = function dynamic(tagName){this.isDynamic = true;this.dynamicTagName = ['function',tagName];};return ComponentTagBuilder;})();var ComponentAttrsBuilder=(function(){function ComponentAttrsBuilder(){this.buffer = [];}ComponentAttrsBuilder.prototype.static = function _static(name,value){this.buffer.push(['static-attr',name,value,null]);};ComponentAttrsBuilder.prototype.dynamic = function dynamic(name,value){this.buffer.push(['dynamic-attr',name,['function',value],null]);};return ComponentAttrsBuilder;})();var ComponentBuilder=(function(){function ComponentBuilder(builder){this.builder = builder;this.env = builder.env;}ComponentBuilder.prototype.static = function _static(definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putComponentDefinition(definition);b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();});};ComponentBuilder.prototype.dynamic = function dynamic(definitionArgs,definition,args,_symbolTable,shadow){this.builder.unit(function(b){b.putArgs(compileArgs(definitionArgs[0],definitionArgs[1],b));b.putValue(['function',definition]);b.test('simple');b.enter('BEGIN','END');b.label('BEGIN');b.jumpUnless('END');b.putDynamicComponentDefinition();b.openComponent(compileBaselineArgs(args,b),shadow);b.closeComponent();b.label('END');b.exit();});};return ComponentBuilder;})();function builder(env,symbolTable){return new OpcodeBuilder(symbolTable,env);}function appendOpcode(name,op1,op2,op3){return APPEND_OPCODES.construct(name,null,op1,op2,op3);}var Labels=(function(){function Labels(){this.labels = _glimmerUtil.dict();this.jumps = [];this.ranges = [];}Labels.prototype.label = function label(name,index){this.labels[name] = index;};Labels.prototype.jump = function jump(at,Target,target){this.jumps.push({at:at,target:target,Target:Target});};Labels.prototype.range = function range(at,Range,start,end){this.ranges.push({at:at,start:start,end:end,Range:Range});};Labels.prototype.patch = function patch(constants,opcodes){for(var i=0;i < this.jumps.length;i++) {var _jumps$i=this.jumps[i];var at=_jumps$i.at;var target=_jumps$i.target;var Target=_jumps$i.Target;opcodes.set(at,APPEND_OPCODES.construct(Target,null,this.labels[target]));}for(var i=0;i < this.ranges.length;i++) {var _ranges$i=this.ranges[i];var at=_ranges$i.at;var start=_ranges$i.start;var end=_ranges$i.end;var _Range=_ranges$i.Range;var slice=constants.slice([this.labels[start],this.labels[end] - 1]);opcodes.set(at,APPEND_OPCODES.construct(_Range,null,slice));}};return Labels;})();var BasicOpcodeBuilder=(function(){function BasicOpcodeBuilder(symbolTable,env,program){this.symbolTable = symbolTable;this.env = env;this.program = program;this.labelsStack = new _glimmerUtil.Stack();this.constants = env.constants;this.start = program.next;}BasicOpcodeBuilder.prototype.opcode = function opcode(name,op1,op2,op3){this.push(appendOpcode(name,op1,op2,op3));};BasicOpcodeBuilder.prototype.push = function push(op){ // console.log(`pushing ${op && op.type}`); +if(op === null){this.program.push([0,0,0,0]);}else {this.program.push(op);}};BasicOpcodeBuilder.prototype.toSlice = function toSlice(){return [this.start,this.program.current];}; // helpers +BasicOpcodeBuilder.prototype.startLabels = function startLabels(){this.labelsStack.push(new Labels());};BasicOpcodeBuilder.prototype.stopLabels = function stopLabels(){var label=_glimmerUtil.expect(this.labelsStack.pop(),'unbalanced push and pop labels');label.patch(this.constants,this.program);}; // partials +BasicOpcodeBuilder.prototype.putPartialDefinition = function putPartialDefinition(_definition){var definition=this.constants.other(_definition);this.opcode(50, /* PutPartial */definition);};BasicOpcodeBuilder.prototype.putDynamicPartialDefinition = function putDynamicPartialDefinition(){this.opcode(49, /* PutDynamicPartial */this.constants.other(this.symbolTable));};BasicOpcodeBuilder.prototype.evaluatePartial = function evaluatePartial(){this.opcode(51, /* EvaluatePartial */this.constants.other(this.symbolTable),this.constants.other(_glimmerUtil.dict()));}; // components +BasicOpcodeBuilder.prototype.putComponentDefinition = function putComponentDefinition(definition){this.opcode(23, /* PutComponent */this.other(definition));};BasicOpcodeBuilder.prototype.putDynamicComponentDefinition = function putDynamicComponentDefinition(){this.opcode(22 /* PutDynamicComponent */);};BasicOpcodeBuilder.prototype.openComponent = function openComponent(args,shadow){this.opcode(24, /* OpenComponent */this.args(args),shadow?this.block(shadow):0);};BasicOpcodeBuilder.prototype.didCreateElement = function didCreateElement(){this.opcode(25 /* DidCreateElement */);};BasicOpcodeBuilder.prototype.shadowAttributes = function shadowAttributes(){this.opcode(26 /* ShadowAttributes */);this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.didRenderLayout = function didRenderLayout(){this.opcode(27 /* DidRenderLayout */);};BasicOpcodeBuilder.prototype.closeComponent = function closeComponent(){this.opcode(28 /* CloseComponent */);}; // content +BasicOpcodeBuilder.prototype.dynamicContent = function dynamicContent(Opcode){this.opcode(31, /* DynamicContent */this.other(Opcode));};BasicOpcodeBuilder.prototype.cautiousAppend = function cautiousAppend(){this.dynamicContent(new OptimizedCautiousAppendOpcode());};BasicOpcodeBuilder.prototype.trustingAppend = function trustingAppend(){this.dynamicContent(new OptimizedTrustingAppendOpcode());};BasicOpcodeBuilder.prototype.guardedCautiousAppend = function guardedCautiousAppend(expression){this.dynamicContent(new GuardedCautiousAppendOpcode(this.compileExpression(expression),this.symbolTable));};BasicOpcodeBuilder.prototype.guardedTrustingAppend = function guardedTrustingAppend(expression){this.dynamicContent(new GuardedTrustingAppendOpcode(this.compileExpression(expression),this.symbolTable));}; // dom +BasicOpcodeBuilder.prototype.text = function text(_text){this.opcode(29, /* Text */this.constants.string(_text));};BasicOpcodeBuilder.prototype.openPrimitiveElement = function openPrimitiveElement(tag){this.opcode(32, /* OpenElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openComponentElement = function openComponentElement(tag){this.opcode(35, /* OpenComponentElement */this.constants.string(tag));};BasicOpcodeBuilder.prototype.openDynamicPrimitiveElement = function openDynamicPrimitiveElement(){this.opcode(36 /* OpenDynamicElement */);};BasicOpcodeBuilder.prototype.flushElement = function flushElement(){this.opcode(37 /* FlushElement */);};BasicOpcodeBuilder.prototype.closeElement = function closeElement(){this.opcode(38 /* CloseElement */);};BasicOpcodeBuilder.prototype.staticAttr = function staticAttr(_name,_namespace,_value){var name=this.constants.string(_name);var namespace=_namespace?this.constants.string(_namespace):0;var value=this.constants.string(_value);this.opcode(40, /* StaticAttr */name,value,namespace);};BasicOpcodeBuilder.prototype.dynamicAttrNS = function dynamicAttrNS(_name,_namespace,trusting){var name=this.constants.string(_name);var namespace=this.constants.string(_namespace);this.opcode(42, /* DynamicAttrNS */name,namespace,trusting | 0);};BasicOpcodeBuilder.prototype.dynamicAttr = function dynamicAttr(_name,trusting){var name=this.constants.string(_name);this.opcode(43, /* DynamicAttr */name,trusting | 0);};BasicOpcodeBuilder.prototype.comment = function comment(_comment){var comment=this.constants.string(_comment);this.opcode(30, /* Comment */comment);};BasicOpcodeBuilder.prototype.modifier = function modifier(_name,_args){var args=this.constants.expression(this.compile(_args));var _modifierManager=this.env.lookupModifier([_name],this.symbolTable);var modifierManager=this.constants.other(_modifierManager);var name=this.constants.string(_name);this.opcode(41, /* Modifier */name,modifierManager,args);}; // lists +BasicOpcodeBuilder.prototype.putIterator = function putIterator(){this.opcode(44 /* PutIterator */);};BasicOpcodeBuilder.prototype.enterList = function enterList(start,end){this.push(null);this.labels.range(this.pos,45, /* EnterList */start,end);};BasicOpcodeBuilder.prototype.exitList = function exitList(){this.opcode(46 /* ExitList */);};BasicOpcodeBuilder.prototype.enterWithKey = function enterWithKey(start,end){this.push(null);this.labels.range(this.pos,47, /* EnterWithKey */start,end);};BasicOpcodeBuilder.prototype.nextIter = function nextIter(end){this.push(null);this.labels.jump(this.pos,48, /* NextIter */end);}; // vm +BasicOpcodeBuilder.prototype.openBlock = function openBlock(_args,_inner){var args=this.constants.expression(this.compile(_args));var inner=this.constants.other(_inner);this.opcode(20, /* OpenBlock */inner,args);};BasicOpcodeBuilder.prototype.closeBlock = function closeBlock(){this.opcode(21 /* CloseBlock */);};BasicOpcodeBuilder.prototype.pushRemoteElement = function pushRemoteElement(){this.opcode(33 /* PushRemoteElement */);};BasicOpcodeBuilder.prototype.popRemoteElement = function popRemoteElement(){this.opcode(34 /* PopRemoteElement */);};BasicOpcodeBuilder.prototype.popElement = function popElement(){this.opcode(39 /* PopElement */);};BasicOpcodeBuilder.prototype.label = function label(name){this.labels.label(name,this.nextPos);};BasicOpcodeBuilder.prototype.pushChildScope = function pushChildScope(){this.opcode(0 /* PushChildScope */);};BasicOpcodeBuilder.prototype.popScope = function popScope(){this.opcode(1 /* PopScope */);};BasicOpcodeBuilder.prototype.pushDynamicScope = function pushDynamicScope(){this.opcode(2 /* PushDynamicScope */);};BasicOpcodeBuilder.prototype.popDynamicScope = function popDynamicScope(){this.opcode(3 /* PopDynamicScope */);};BasicOpcodeBuilder.prototype.putNull = function putNull(){this.opcode(4, /* Put */this.constants.NULL_REFERENCE);};BasicOpcodeBuilder.prototype.putValue = function putValue(_expression){var expr=this.constants.expression(this.compileExpression(_expression));this.opcode(5, /* EvaluatePut */expr);};BasicOpcodeBuilder.prototype.putArgs = function putArgs(_args){var args=this.constants.expression(this.compile(_args));this.opcode(6, /* PutArgs */args);};BasicOpcodeBuilder.prototype.bindDynamicScope = function bindDynamicScope(_names){this.opcode(12, /* BindDynamicScope */this.names(_names));};BasicOpcodeBuilder.prototype.bindPositionalArgs = function bindPositionalArgs(_names,_symbols){this.opcode(7, /* BindPositionalArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindNamedArgs = function bindNamedArgs(_names,_symbols){this.opcode(8, /* BindNamedArgs */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.bindBlocks = function bindBlocks(_names,_symbols){this.opcode(9, /* BindBlocks */this.names(_names),this.symbols(_symbols));};BasicOpcodeBuilder.prototype.enter = function enter(_enter,exit){this.push(null);this.labels.range(this.pos,13, /* Enter */_enter,exit);};BasicOpcodeBuilder.prototype.exit = function exit(){this.opcode(14 /* Exit */);};BasicOpcodeBuilder.prototype.evaluate = function evaluate(_block){var block=this.constants.block(_block);this.opcode(15, /* Evaluate */block);};BasicOpcodeBuilder.prototype.test = function test(testFunc){var _func=undefined;if(testFunc === 'const'){_func = ConstTest;}else if(testFunc === 'simple'){_func = SimpleTest;}else if(testFunc === 'environment'){_func = EnvironmentTest;}else if(typeof testFunc === 'function'){_func = testFunc;}else {throw new Error('unreachable');}var func=this.constants.function(_func);this.opcode(19, /* Test */func);};BasicOpcodeBuilder.prototype.jump = function jump(target){this.push(null);this.labels.jump(this.pos,16, /* Jump */target);};BasicOpcodeBuilder.prototype.jumpIf = function jumpIf(target){this.push(null);this.labels.jump(this.pos,17, /* JumpIf */target);};BasicOpcodeBuilder.prototype.jumpUnless = function jumpUnless(target){this.push(null);this.labels.jump(this.pos,18, /* JumpUnless */target);};BasicOpcodeBuilder.prototype.names = function names(_names){var _this=this;var names=_names.map(function(n){return _this.constants.string(n);});return this.constants.array(names);};BasicOpcodeBuilder.prototype.symbols = function symbols(_symbols2){return this.constants.array(_symbols2);};BasicOpcodeBuilder.prototype.other = function other(value){return this.constants.other(value);};BasicOpcodeBuilder.prototype.args = function args(_args2){return this.constants.expression(this.compile(_args2));};BasicOpcodeBuilder.prototype.block = function block(_block3){return this.constants.block(_block3);};babelHelpers.createClass(BasicOpcodeBuilder,[{key:'pos',get:function(){return this.program.current;}},{key:'nextPos',get:function(){return this.program.next;}},{key:'labels',get:function(){return _glimmerUtil.expect(this.labelsStack.current,'bug: not in a label stack');}}]);return BasicOpcodeBuilder;})();function isCompilableExpression(expr){return expr && typeof expr['compile'] === 'function';}var OpcodeBuilder=(function(_BasicOpcodeBuilder){babelHelpers.inherits(OpcodeBuilder,_BasicOpcodeBuilder);function OpcodeBuilder(symbolTable,env){var program=arguments.length <= 2 || arguments[2] === undefined?env.program:arguments[2];return (function(){_BasicOpcodeBuilder.call(this,symbolTable,env,program);this.component = new ComponentBuilder(this);}).apply(this,arguments);}OpcodeBuilder.prototype.compile = function compile(expr){if(isCompilableExpression(expr)){return expr.compile(this);}else {return expr;}};OpcodeBuilder.prototype.compileExpression = function compileExpression(expression){if(expression instanceof CompiledExpression){return expression;}else {return expr(expression,this);}};OpcodeBuilder.prototype.bindPositionalArgsForLocals = function bindPositionalArgsForLocals(locals){var symbols=Object.keys(locals).map(function(name){return locals[name];});this.opcode(7, /* BindPositionalArgs */this.symbols(symbols));};OpcodeBuilder.prototype.preludeForLayout = function preludeForLayout(layout){var _this2=this;var symbols=layout.symbolTable.getSymbols();if(symbols.named){(function(){var named=symbols.named;var namedNames=Object.keys(named);var namedSymbols=namedNames.map(function(n){return named[n];});_this2.opcode(8, /* BindNamedArgs */_this2.names(namedNames),_this2.symbols(namedSymbols));})();}this.opcode(11 /* BindCallerScope */);if(symbols.yields){(function(){var yields=symbols.yields;var yieldNames=Object.keys(yields);var yieldSymbols=yieldNames.map(function(n){return yields[n];});_this2.opcode(9, /* BindBlocks */_this2.names(yieldNames),_this2.symbols(yieldSymbols));})();}if(symbols.partialArgs){this.opcode(10, /* BindPartialArgs */symbols.partialArgs);}};OpcodeBuilder.prototype.yield = function _yield(args,to){var yields=undefined,partial=undefined;var inner=undefined;if(yields = this.symbolTable.getSymbol('yields',to)){inner = new CompiledGetBlockBySymbol(yields,to);}else if(partial = this.symbolTable.getPartialArgs()){inner = new CompiledInPartialGetBlock(partial,to);}else {throw new Error('[BUG] ${to} is not a valid block name.');}this.openBlock(args,inner);this.closeBlock();}; // TODO +// come back to this +OpcodeBuilder.prototype.labelled = function labelled(args,callback){if(args)this.putArgs(args);this.startLabels();this.enter('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.iter = function iter(callback){this.startLabels();this.enterList('BEGIN','END');this.label('ITER');this.nextIter('BREAK');this.enterWithKey('BEGIN','END');this.label('BEGIN');callback(this,'BEGIN','END');this.label('END');this.exit();this.jump('ITER');this.label('BREAK');this.exitList();this.stopLabels();}; // TODO +// come back to this +OpcodeBuilder.prototype.unit = function unit(callback){this.startLabels();callback(this);this.stopLabels();};return OpcodeBuilder;})(BasicOpcodeBuilder);APPEND_OPCODES.add(31, /* DynamicContent */function(vm,_ref31){var append=_ref31.op1;var opcode=vm.constants.getOther(append);opcode.evaluate(vm);});function isEmpty(value){return value === null || value === undefined || typeof value['toString'] !== 'function';}function normalizeTextValue(value){if(isEmpty(value)){return '';}return String(value);}function normalizeTrustedValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value)){return value.toHTML();}if(isNode(value)){return value;}return String(value);}function normalizeValue(value){if(isEmpty(value)){return '';}if(isString(value)){return value;}if(isSafeString(value) || isNode(value)){return value;}return String(value);}var AppendDynamicOpcode=(function(){function AppendDynamicOpcode(){}AppendDynamicOpcode.prototype.evaluate = function evaluate(vm){var reference=vm.frame.getOperand();var normalized=this.normalize(reference);var value=undefined,cache=undefined;if(_glimmerReference.isConst(reference)){value = normalized.value();}else {cache = new _glimmerReference.ReferenceCache(normalized);value = cache.peek();}var stack=vm.stack();var upsert=this.insert(vm.env.getAppendOperations(),stack,value);var bounds=new Fragment(upsert.bounds);stack.newBounds(bounds);if(cache /* i.e. !isConst(reference) */){vm.updateWith(this.updateWith(vm,reference,cache,bounds,upsert));}};return AppendDynamicOpcode;})();var GuardedAppendOpcode=(function(_AppendDynamicOpcode){babelHelpers.inherits(GuardedAppendOpcode,_AppendDynamicOpcode);function GuardedAppendOpcode(expression,symbolTable){_AppendDynamicOpcode.call(this);this.expression = expression;this.symbolTable = symbolTable;this.deopted = null;}GuardedAppendOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.pushEvalFrame(this.deopted);}else {vm.evaluateOperand(this.expression);var value=vm.frame.getOperand().value();if(isComponentDefinition(value)){vm.pushEvalFrame(this.deopt(vm.env));}else {_AppendDynamicOpcode.prototype.evaluate.call(this,vm);}}};GuardedAppendOpcode.prototype.deopt = function deopt(env){var _this3=this; // At compile time, we determined that this append callsite might refer +// to a local variable/property lookup that resolves to a component +// definition at runtime. +// +// We could have eagerly compiled this callsite into something like this: +// +// {{#if (is-component-definition foo)}} +// {{component foo}} +// {{else}} +// {{foo}} +// {{/if}} +// +// However, in practice, there might be a large amout of these callsites +// and most of them would resolve to a simple value lookup. Therefore, we +// tried to be optimistic and assumed that the callsite will resolve to +// appending a simple value. +// +// However, we have reached here because at runtime, the guard conditional +// have detected that this callsite is indeed referring to a component +// definition object. Since this is likely going to be true for other +// instances of the same callsite, it is now appropiate to deopt into the +// expanded version that handles both cases. The compilation would look +// like this: +// +// PutValue(expression) +// Test(is-component-definition) +// Enter(BEGIN, END) +// BEGIN: Noop +// JumpUnless(VALUE) +// PutDynamicComponentDefinitionOpcode +// OpenComponent +// CloseComponent +// Jump(END) +// VALUE: Noop +// OptimizedAppend +// END: Noop +// Exit +// +// Keep in mind that even if we *don't* reach here at initial render time, +// it is still possible (although quite rare) that the simple value we +// encounter during initial render could later change into a component +// definition object at update time. That is handled by the "lazy deopt" +// code on the update side (scroll down for the next big block of comment). +var dsl=new OpcodeBuilder(this.symbolTable,env);dsl.putValue(this.expression);dsl.test(IsComponentDefinitionReference.create);dsl.labelled(null,function(dsl,_BEGIN,END){dsl.jumpUnless('VALUE');dsl.putDynamicComponentDefinition();dsl.openComponent(CompiledArgs.empty());dsl.closeComponent();dsl.jump(END);dsl.label('VALUE');dsl.dynamicContent(new _this3.AppendOpcode());});var deopted=this.deopted = dsl.toSlice(); // From this point on, we have essentially replaced ourselves with a new set +// of opcodes. Since we will always be executing the new/deopted code, it's +// a good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this.expression = null;return deopted;};return GuardedAppendOpcode;})(AppendDynamicOpcode);var IsComponentDefinitionReference=(function(_ConditionalReference){babelHelpers.inherits(IsComponentDefinitionReference,_ConditionalReference);function IsComponentDefinitionReference(){_ConditionalReference.apply(this,arguments);}IsComponentDefinitionReference.create = function create(inner){return new IsComponentDefinitionReference(inner);};IsComponentDefinitionReference.prototype.toBool = function toBool(value){return isComponentDefinition(value);};return IsComponentDefinitionReference;})(ConditionalReference);var UpdateOpcode=(function(_UpdatingOpcode9){babelHelpers.inherits(UpdateOpcode,_UpdatingOpcode9);function UpdateOpcode(cache,bounds,upsert){_UpdatingOpcode9.call(this);this.cache = cache;this.bounds = bounds;this.upsert = upsert;this.tag = cache.tag;}UpdateOpcode.prototype.evaluate = function evaluate(vm){var value=this.cache.revalidate();if(_glimmerReference.isModified(value)){var bounds=this.bounds;var upsert=this.upsert;var dom=vm.dom;if(!this.upsert.update(dom,value)){var cursor=new Cursor(bounds.parentElement(),clear(bounds));upsert = this.upsert = this.insert(vm.env.getAppendOperations(),cursor,value);}bounds.update(upsert.bounds);}};UpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var cache=this.cache;return {guid:guid,type:type,details:{lastValue:JSON.stringify(cache.peek())}};};return UpdateOpcode;})(UpdatingOpcode);var GuardedUpdateOpcode=(function(_UpdateOpcode){babelHelpers.inherits(GuardedUpdateOpcode,_UpdateOpcode);function GuardedUpdateOpcode(reference,cache,bounds,upsert,appendOpcode,state){_UpdateOpcode.call(this,cache,bounds,upsert);this.reference = reference;this.appendOpcode = appendOpcode;this.state = state;this.deopted = null;this.tag = this._tag = new _glimmerReference.UpdatableTag(this.tag);}GuardedUpdateOpcode.prototype.evaluate = function evaluate(vm){if(this.deopted){vm.evaluateOpcode(this.deopted);}else {if(isComponentDefinition(this.reference.value())){this.lazyDeopt(vm);}else {_UpdateOpcode.prototype.evaluate.call(this,vm);}}};GuardedUpdateOpcode.prototype.lazyDeopt = function lazyDeopt(vm){ // Durign initial render, we know that the reference does not contain a +// component definition, so we optimistically assumed that this append +// is just a normal append. However, at update time, we discovered that +// the reference has switched into containing a component definition, so +// we need to do a "lazy deopt", simulating what would have happened if +// we had decided to perform the deopt in the first place during initial +// render. +// +// More concretely, we would have expanded the curly into a if/else, and +// based on whether the value is a component definition or not, we would +// have entered either the dynamic component branch or the simple value +// branch. +// +// Since we rendered a simple value during initial render (and all the +// updates up until this point), we need to pretend that the result is +// produced by the "VALUE" branch of the deopted append opcode: +// +// Try(BEGIN, END) +// Assert(IsComponentDefinition, expected=false) +// OptimizedUpdate +// +// In this case, because the reference has switched from being a simple +// value into a component definition, what would have happened is that +// the assert would throw, causing the Try opcode to teardown the bounds +// and rerun the original append opcode. +// +// Since the Try opcode would have nuked the updating opcodes anyway, we +// wouldn't have to worry about simulating those. All we have to do is to +// execute the Try opcode and immediately throw. +var bounds=this.bounds;var appendOpcode=this.appendOpcode;var state=this.state;var env=vm.env;var slice=appendOpcode.deopt(env);var enter=_glimmerUtil.expect(env.program.opcode(slice[0] + 8),'hardcoded deopt location');var ops=vm.constants.getSlice(enter.op1);var tracker=new UpdatableBlockTracker(bounds.parentElement());tracker.newBounds(this.bounds);var children=new _glimmerUtil.LinkedList();state.frame['condition'] = IsComponentDefinitionReference.create(_glimmerUtil.expect(state.frame['operand'],'operand should be populated'));var deopted=this.deopted = new TryOpcode(ops,state,tracker,children);this._tag.update(deopted.tag);vm.evaluateOpcode(deopted);vm.throw(); // From this point on, we have essentially replaced ourselve with a new +// opcode. Since we will always be executing the new/deopted code, it's a +// good idea (as a pattern) to null out any unneeded fields here to avoid +// holding on to unneeded/stale objects: +// QUESTION: Shouldn't this whole object be GCed? If not, why not? +this._tag = null;this.reference = null;this.cache = null;this.bounds = null;this.upsert = null;this.appendOpcode = null;this.state = null;};GuardedUpdateOpcode.prototype.toJSON = function toJSON(){var guid=this._guid;var type=this.type;var deopted=this.deopted;if(deopted){return {guid:guid,type:type,deopted:true,children:[deopted.toJSON()]};}else {return _UpdateOpcode.prototype.toJSON.call(this);}};return GuardedUpdateOpcode;})(UpdateOpcode);var OptimizedCautiousAppendOpcode=(function(_AppendDynamicOpcode2){babelHelpers.inherits(OptimizedCautiousAppendOpcode,_AppendDynamicOpcode2);function OptimizedCautiousAppendOpcode(){_AppendDynamicOpcode2.apply(this,arguments);this.type = 'optimized-cautious-append';}OptimizedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};OptimizedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};OptimizedCautiousAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedCautiousUpdateOpcode(cache,bounds,upsert);};return OptimizedCautiousAppendOpcode;})(AppendDynamicOpcode);var OptimizedCautiousUpdateOpcode=(function(_UpdateOpcode2){babelHelpers.inherits(OptimizedCautiousUpdateOpcode,_UpdateOpcode2);function OptimizedCautiousUpdateOpcode(){_UpdateOpcode2.apply(this,arguments);this.type = 'optimized-cautious-update';}OptimizedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return OptimizedCautiousUpdateOpcode;})(UpdateOpcode);var GuardedCautiousAppendOpcode=(function(_GuardedAppendOpcode){babelHelpers.inherits(GuardedCautiousAppendOpcode,_GuardedAppendOpcode);function GuardedCautiousAppendOpcode(){_GuardedAppendOpcode.apply(this,arguments);this.type = 'guarded-cautious-append';this.AppendOpcode = OptimizedCautiousAppendOpcode;}GuardedCautiousAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeValue);};GuardedCautiousAppendOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};GuardedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedCautiousUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedCautiousAppendOpcode;})(GuardedAppendOpcode);var GuardedCautiousUpdateOpcode=(function(_GuardedUpdateOpcode){babelHelpers.inherits(GuardedCautiousUpdateOpcode,_GuardedUpdateOpcode);function GuardedCautiousUpdateOpcode(){_GuardedUpdateOpcode.apply(this,arguments);this.type = 'guarded-cautious-update';}GuardedCautiousUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return cautiousInsert(dom,cursor,value);};return GuardedCautiousUpdateOpcode;})(GuardedUpdateOpcode);var OptimizedTrustingAppendOpcode=(function(_AppendDynamicOpcode3){babelHelpers.inherits(OptimizedTrustingAppendOpcode,_AppendDynamicOpcode3);function OptimizedTrustingAppendOpcode(){_AppendDynamicOpcode3.apply(this,arguments);this.type = 'optimized-trusting-append';}OptimizedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};OptimizedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};OptimizedTrustingAppendOpcode.prototype.updateWith = function updateWith(_vm,_reference,cache,bounds,upsert){return new OptimizedTrustingUpdateOpcode(cache,bounds,upsert);};return OptimizedTrustingAppendOpcode;})(AppendDynamicOpcode);var OptimizedTrustingUpdateOpcode=(function(_UpdateOpcode3){babelHelpers.inherits(OptimizedTrustingUpdateOpcode,_UpdateOpcode3);function OptimizedTrustingUpdateOpcode(){_UpdateOpcode3.apply(this,arguments);this.type = 'optimized-trusting-update';}OptimizedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return OptimizedTrustingUpdateOpcode;})(UpdateOpcode);var GuardedTrustingAppendOpcode=(function(_GuardedAppendOpcode2){babelHelpers.inherits(GuardedTrustingAppendOpcode,_GuardedAppendOpcode2);function GuardedTrustingAppendOpcode(){_GuardedAppendOpcode2.apply(this,arguments);this.type = 'guarded-trusting-append';this.AppendOpcode = OptimizedTrustingAppendOpcode;}GuardedTrustingAppendOpcode.prototype.normalize = function normalize(reference){return _glimmerReference.map(reference,normalizeTrustedValue);};GuardedTrustingAppendOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};GuardedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm,reference,cache,bounds,upsert){return new GuardedTrustingUpdateOpcode(reference,cache,bounds,upsert,this,vm.capture());};return GuardedTrustingAppendOpcode;})(GuardedAppendOpcode);var GuardedTrustingUpdateOpcode=(function(_GuardedUpdateOpcode2){babelHelpers.inherits(GuardedTrustingUpdateOpcode,_GuardedUpdateOpcode2);function GuardedTrustingUpdateOpcode(){_GuardedUpdateOpcode2.apply(this,arguments);this.type = 'trusting-update';}GuardedTrustingUpdateOpcode.prototype.insert = function insert(dom,cursor,value){return trustingInsert(dom,cursor,value);};return GuardedTrustingUpdateOpcode;})(GuardedUpdateOpcode);APPEND_OPCODES.add(49, /* PutDynamicPartial */function(vm,_ref32){var _symbolTable=_ref32.op1;var env=vm.env;var symbolTable=vm.constants.getOther(_symbolTable);function lookupPartial(name){var normalized=String(name);if(!env.hasPartial(normalized,symbolTable)){throw new Error('Could not find a partial named "' + normalized + '"');}return env.lookupPartial(normalized,symbolTable);}var reference=_glimmerReference.map(vm.frame.getOperand(),lookupPartial);var cache=_glimmerReference.isConst(reference)?undefined:new _glimmerReference.ReferenceCache(reference);var definition=cache?cache.peek():reference.value();vm.frame.setImmediate(definition);if(cache){vm.updateWith(new Assert(cache));}});APPEND_OPCODES.add(50, /* PutPartial */function(vm,_ref33){var _definition=_ref33.op1;var definition=vm.constants.getOther(_definition);vm.frame.setImmediate(definition);});APPEND_OPCODES.add(51, /* EvaluatePartial */function(vm,_ref34){var _symbolTable=_ref34.op1;var _cache=_ref34.op2;var symbolTable=vm.constants.getOther(_symbolTable);var cache=vm.constants.getOther(_cache);var _vm$frame$getImmediate=vm.frame.getImmediate();var template=_vm$frame$getImmediate.template;var block=cache[template.id];if(!block){block = template.asPartial(symbolTable);}vm.invokePartial(block);});var IterablePresenceReference=(function(){function IterablePresenceReference(artifacts){this.tag = artifacts.tag;this.artifacts = artifacts;}IterablePresenceReference.prototype.value = function value(){return !this.artifacts.isEmpty();};return IterablePresenceReference;})();APPEND_OPCODES.add(44, /* PutIterator */function(vm){var listRef=vm.frame.getOperand();var args=_glimmerUtil.expect(vm.frame.getArgs(),'PutIteratorOpcode expects a populated args register');var iterable=vm.env.iterableFor(listRef,args);var iterator=new _glimmerReference.ReferenceIterator(iterable);vm.frame.setIterator(iterator);vm.frame.setCondition(new IterablePresenceReference(iterator.artifacts));});APPEND_OPCODES.add(45, /* EnterList */function(vm,_ref35){var _slice=_ref35.op1;vm.enterList(vm.constants.getSlice(_slice));});APPEND_OPCODES.add(46, /* ExitList */function(vm){return vm.exitList();});APPEND_OPCODES.add(47, /* EnterWithKey */function(vm,_ref36){var _slice=_ref36.op2;var key=_glimmerUtil.expect(vm.frame.getKey(),'EnterWithKeyOpcode expects a populated key register');var slice=vm.constants.getSlice(_slice);vm.enterWithKey(key,slice);});var TRUE_REF=new _glimmerReference.ConstReference(true);var FALSE_REF=new _glimmerReference.ConstReference(false);APPEND_OPCODES.add(48, /* NextIter */function(vm,_ref37){var end=_ref37.op1;var item=vm.frame.getIterator().next();if(item){vm.frame.setCondition(TRUE_REF);vm.frame.setKey(item.key);vm.frame.setOperand(item.value);vm.frame.setArgs(EvaluatedArgs.positional([item.value,item.memo]));}else {vm.frame.setCondition(FALSE_REF);vm.goto(end);}});var clientId=0;function templateFactory(_ref38){var templateId=_ref38.id;var meta=_ref38.meta;var block=_ref38.block;var parsedBlock=undefined;var id=templateId || 'client-' + clientId++;var create=function(env,envMeta){var newMeta=envMeta?_glimmerUtil.assign({},envMeta,meta):meta;if(!parsedBlock){parsedBlock = JSON.parse(block);}return template(parsedBlock,id,newMeta,env);};return {id:id,meta:meta,create:create};}function template(block,id,meta,env){var scanner=new Scanner(block,meta,env);var entryPoint=undefined;var asEntryPoint=function(){if(!entryPoint)entryPoint = scanner.scanEntryPoint();return entryPoint;};var layout=undefined;var asLayout=function(){if(!layout)layout = scanner.scanLayout();return layout;};var asPartial=function(symbols){return scanner.scanPartial(symbols);};var render=function(self,appendTo,dynamicScope){var elementStack=ElementStack.forInitialRender(env,appendTo,null);var compiled=asEntryPoint().compile(env);var vm=VM.initial(env,self,dynamicScope,elementStack,compiled.symbols);return vm.execute(compiled.slice);};return {id:id,meta:meta,_block:block,asEntryPoint:asEntryPoint,asLayout:asLayout,asPartial:asPartial,render:render};}var DynamicVarReference=(function(){function DynamicVarReference(scope,nameRef){this.scope = scope;this.nameRef = nameRef;var varTag=this.varTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG);this.tag = _glimmerReference.combine([nameRef.tag,varTag]);}DynamicVarReference.prototype.value = function value(){return this.getVar().value();};DynamicVarReference.prototype.get = function get(key){return this.getVar().get(key);};DynamicVarReference.prototype.getVar = function getVar(){var name=String(this.nameRef.value());var ref=this.scope.get(name);this.varTag.update(ref.tag);return ref;};return DynamicVarReference;})();function getDynamicVar(vm,args,_symbolTable){var scope=vm.dynamicScope();var nameRef=args.positional.at(0);return new DynamicVarReference(scope,nameRef);}var PartialDefinition=function PartialDefinition(name,template){this.name = name;this.template = template;};var NodeType;(function(NodeType){NodeType[NodeType["Element"] = 0] = "Element";NodeType[NodeType["Attribute"] = 1] = "Attribute";NodeType[NodeType["Text"] = 2] = "Text";NodeType[NodeType["CdataSection"] = 3] = "CdataSection";NodeType[NodeType["EntityReference"] = 4] = "EntityReference";NodeType[NodeType["Entity"] = 5] = "Entity";NodeType[NodeType["ProcessingInstruction"] = 6] = "ProcessingInstruction";NodeType[NodeType["Comment"] = 7] = "Comment";NodeType[NodeType["Document"] = 8] = "Document";NodeType[NodeType["DocumentType"] = 9] = "DocumentType";NodeType[NodeType["DocumentFragment"] = 10] = "DocumentFragment";NodeType[NodeType["Notation"] = 11] = "Notation";})(NodeType || (NodeType = {}));var Simple=Object.freeze({get NodeType(){return NodeType;}});exports.Simple = Simple;exports.templateFactory = templateFactory;exports.NULL_REFERENCE = NULL_REFERENCE;exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE;exports.PrimitiveReference = PrimitiveReference;exports.ConditionalReference = ConditionalReference;exports.OpcodeBuilderDSL = OpcodeBuilder;exports.compileLayout = compileLayout;exports.CompiledBlock = CompiledBlock;exports.CompiledProgram = CompiledProgram;exports.IAttributeManager = AttributeManager;exports.AttributeManager = AttributeManager;exports.PropertyManager = PropertyManager;exports.INPUT_VALUE_PROPERTY_MANAGER = INPUT_VALUE_PROPERTY_MANAGER;exports.defaultManagers = defaultManagers;exports.defaultAttributeManagers = defaultAttributeManagers;exports.defaultPropertyManagers = defaultPropertyManagers;exports.readDOMAttr = readDOMAttr;exports.normalizeTextValue = normalizeTextValue;exports.CompiledExpression = CompiledExpression;exports.CompiledArgs = CompiledArgs;exports.CompiledNamedArgs = CompiledNamedArgs;exports.CompiledPositionalArgs = CompiledPositionalArgs;exports.EvaluatedArgs = EvaluatedArgs;exports.EvaluatedNamedArgs = EvaluatedNamedArgs;exports.EvaluatedPositionalArgs = EvaluatedPositionalArgs;exports.getDynamicVar = getDynamicVar;exports.BlockMacros = Blocks;exports.InlineMacros = Inlines;exports.compileArgs = compileArgs;exports.setDebuggerCallback = setDebuggerCallback;exports.resetDebuggerCallback = resetDebuggerCallback;exports.BaselineSyntax = BaselineSyntax;exports.Layout = Layout;exports.UpdatingVM = UpdatingVM;exports.RenderResult = RenderResult;exports.isSafeString = isSafeString;exports.Scope = Scope;exports.Environment = Environment;exports.PartialDefinition = PartialDefinition;exports.ComponentDefinition = ComponentDefinition;exports.isComponentDefinition = isComponentDefinition;exports.DOMChanges = helper$1;exports.IDOMChanges = DOMChanges;exports.DOMTreeConstruction = DOMTreeConstruction;exports.isWhitespace = isWhitespace;exports.insertHTMLBefore = _insertHTMLBefore;exports.ElementStack = ElementStack;exports.ConcreteBounds = ConcreteBounds;}); +enifed('@glimmer/util', ['exports'], function (exports) { + // There is a small whitelist of namespaced attributes specially + // enumerated in + // https://www.w3.org/TR/html/syntax.html#attributes-0 + // + // > When a foreign element has one of the namespaced attributes given by + // > the local name and namespace of the first and second cells of a row + // > from the following table, it must be written using the name given by + // > the third cell from the same row. + // + // In all other cases, colons are interpreted as a regular character + // with no special meaning: + // + // > No other namespaced attribute can be expressed in the HTML syntax. + 'use strict'; - this._throttlers.push(throttler); + var XLINK = 'http://www.w3.org/1999/xlink'; + var XML = 'http://www.w3.org/XML/1998/namespace'; + var XMLNS = 'http://www.w3.org/2000/xmlns/'; + var WHITELIST = { + 'xlink:actuate': XLINK, + 'xlink:arcrole': XLINK, + 'xlink:href': XLINK, + 'xlink:role': XLINK, + 'xlink:show': XLINK, + 'xlink:title': XLINK, + 'xlink:type': XLINK, + 'xml:base': XML, + 'xml:lang': XML, + 'xml:space': XML, + 'xmlns': XMLNS, + 'xmlns:xlink': XMLNS + }; + function getAttrNamespace(attrName) { + return WHITELIST[attrName] || null; + } - return throttler; - }, + // tslint:disable-line + function unwrap(val) { + if (val === null || val === undefined) throw new Error('Expected value to be present'); + return val; + } + function expect(val, message) { + if (val === null || val === undefined) throw new Error(message); + return val; + } + function unreachable() { + return new Error('unreachable'); + } - debounce: function(target, method /* , args, wait, [immediate] */) { - var backburner = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; + // import Logger from './logger'; + // let alreadyWarned = false; + // import Logger from './logger'; + function debugAssert(test, msg) { + // if (!alreadyWarned) { + // alreadyWarned = true; + // Logger.warn("Don't leave debug assertions on in public builds"); + // } + if (!test) { + throw new Error(msg || "assertion failure"); + } } - var immediate = args.pop(); - var wait, index, debouncee, timer; + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["Trace"] = 0] = "Trace"; + LogLevel[LogLevel["Debug"] = 1] = "Debug"; + LogLevel[LogLevel["Warn"] = 2] = "Warn"; + LogLevel[LogLevel["Error"] = 3] = "Error"; + })(LogLevel || (exports.LogLevel = LogLevel = {})); - if (isNumber(immediate) || isString(immediate)) { - wait = immediate; - immediate = false; - } else { - wait = args.pop(); - } + var NullConsole = (function () { + function NullConsole() {} - wait = parseInt(wait, 10); - // Remove debouncee - index = findDebouncee(target, method, this._debouncees); + NullConsole.prototype.log = function log(_message) {}; - if (index > -1) { - debouncee = this._debouncees[index]; - this._debouncees.splice(index, 1); - this._platform.clearTimeout(debouncee[2]); - } + NullConsole.prototype.warn = function warn(_message) {}; - timer = this._platform.setTimeout(function() { - if (!immediate) { - backburner.run.apply(backburner, args); - } - var index = findDebouncee(target, method, backburner._debouncees); - if (index > -1) { - backburner._debouncees.splice(index, 1); - } - }, wait); + NullConsole.prototype.error = function error(_message) {}; - if (immediate && index === -1) { - backburner.run.apply(backburner, args); - } + NullConsole.prototype.trace = function trace() {}; - debouncee = [ - target, - method, - timer - ]; + return NullConsole; + })(); - backburner._debouncees.push(debouncee); + var ALWAYS = undefined; - return debouncee; - }, + var Logger = (function () { + function Logger(_ref) { + var console = _ref.console; + var level = _ref.level; - cancelTimers: function() { - each(this._throttlers, this._boundClearItems); - this._throttlers = []; + this.f = ALWAYS; + this.force = ALWAYS; + this.console = console; + this.level = level; + } - each(this._debouncees, this._boundClearItems); - this._debouncees = []; + Logger.prototype.skipped = function skipped(level) { + return level < this.level; + }; - this._clearTimerTimeout(); - this._timers = []; + Logger.prototype.trace = function trace(message) { + var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (this._autorun) { - this._platform.clearTimeout(this._autorun); - this._autorun = null; - } - }, + var _ref2$stackTrace = _ref2.stackTrace; + var stackTrace = _ref2$stackTrace === undefined ? false : _ref2$stackTrace; - hasTimers: function() { - return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; - }, + if (this.skipped(LogLevel.Trace)) return; + this.console.log(message); + if (stackTrace) this.console.trace(); + }; - cancel: function (timer) { - var timerType = typeof timer; + Logger.prototype.debug = function debug(message) { + var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce - return timer.queue.cancel(timer); - } else if (timerType === 'function') { // we're cancelling a setTimeout - for (var i = 0, l = this._timers.length; i < l; i += 2) { - if (this._timers[i + 1] === timer) { - this._timers.splice(i, 2); // remove the two elements - if (i === 0) { - this._reinstallTimerTimeout(); - } - return true; - } - } - } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce - return this._cancelItem(findThrottler, this._throttlers, timer) || - this._cancelItem(findDebouncee, this._debouncees, timer); - } else { - return; // timer was null or not a timer - } - }, + var _ref3$stackTrace = _ref3.stackTrace; + var stackTrace = _ref3$stackTrace === undefined ? false : _ref3$stackTrace; - _cancelItem: function(findMethod, array, timer){ - var item, index; + if (this.skipped(LogLevel.Debug)) return; + this.console.log(message); + if (stackTrace) this.console.trace(); + }; - if (timer.length < 3) { return false; } + Logger.prototype.warn = function warn(message) { + var _ref4 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - index = findMethod(timer[0], timer[1], array); + var _ref4$stackTrace = _ref4.stackTrace; + var stackTrace = _ref4$stackTrace === undefined ? false : _ref4$stackTrace; - if (index > -1) { + if (this.skipped(LogLevel.Warn)) return; + this.console.warn(message); + if (stackTrace) this.console.trace(); + }; - item = array[index]; + Logger.prototype.error = function error(message) { + if (this.skipped(LogLevel.Error)) return; + this.console.error(message); + }; - if (item[2] === timer[2]) { - array.splice(index, 1); - this._platform.clearTimeout(timer[2]); - return true; - } - } + return Logger; + })(); - return false; - }, + var _console = typeof console === 'undefined' ? new NullConsole() : console; + ALWAYS = new Logger({ console: _console, level: LogLevel.Trace }); + var LOG_LEVEL = LogLevel.Warn; + var logger = new Logger({ console: _console, level: LOG_LEVEL }); - _runExpiredTimers: function () { - this._timerTimeoutId = undefined; - this.run(this, this._scheduleExpiredTimers); - }, + var objKeys = Object.keys; - _scheduleExpiredTimers: function () { - var n = Date.now(); - var timers = this._timers; - var i = 0; - var l = timers.length; - for (; i < l; i += 2) { - var executeAt = timers[i]; - var fn = timers[i+1]; - if (executeAt <= n) { - this.schedule(this.options.defaultQueue, null, fn); - } else { - break; - } + function assign(obj) { + for (var i = 1; i < arguments.length; i++) { + var assignment = arguments[i]; + if (assignment === null || typeof assignment !== 'object') continue; + var keys = objKeys(assignment); + for (var j = 0; j < keys.length; j++) { + var key = keys[j]; + obj[key] = assignment[key]; + } + } + return obj; + } + function fillNulls(count) { + var arr = new Array(count); + for (var i = 0; i < count; i++) { + arr[i] = null; + } + return arr; } - timers.splice(0, i); - this._installTimerTimeout(); - }, - - _reinstallTimerTimeout: function () { - this._clearTimerTimeout(); - this._installTimerTimeout(); - }, - _clearTimerTimeout: function () { - if (!this._timerTimeoutId) { - return; + var GUID = 0; + function initializeGuid(object) { + return object._guid = ++GUID; + } + function ensureGuid(object) { + return object._guid || initializeGuid(object); } - this._platform.clearTimeout(this._timerTimeoutId); - this._timerTimeoutId = undefined; - }, - _installTimerTimeout: function () { - if (!this._timers.length) { - return; + var proto = Object.create(null, { + // without this, we will always still end up with (new + // EmptyObject()).constructor === Object + constructor: { + value: undefined, + enumerable: false, + writable: true + } + }); + function EmptyObject() {} + EmptyObject.prototype = proto; + function dict() { + // let d = Object.create(null); + // d.x = 1; + // delete d.x; + // return d; + return new EmptyObject(); } - var minExpiresAt = this._timers[0]; - var n = Date.now(); - var wait = Math.max(0, minExpiresAt - n); - this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); - } -}; -Backburner.prototype.schedule = Backburner.prototype.defer; -Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; -Backburner.prototype.later = Backburner.prototype.setTimeout; + var DictSet = (function () { + function DictSet() { + this.dict = dict(); + } -function getOnError(options) { - return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); -} + DictSet.prototype.add = function add(obj) { + if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj; + return this; + }; -function createAutorun(backburner) { - var setTimeout = backburner._platform.setTimeout; - backburner.begin(); - backburner._autorun = setTimeout(function() { - backburner._autorun = null; - backburner.end(); - }, 0); -} + DictSet.prototype.delete = function _delete(obj) { + if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; + }; -function findDebouncee(target, method, debouncees) { - return findItem(target, method, debouncees); -} + DictSet.prototype.forEach = function forEach(callback) { + var dict = this.dict; -function findThrottler(target, method, throttlers) { - return findItem(target, method, throttlers); -} + Object.keys(dict).forEach(function (key) { + return callback(dict[key]); + }); + }; -function findItem(target, method, collection) { - var item; - var index = -1; + DictSet.prototype.toArray = function toArray() { + return Object.keys(this.dict); + }; - for (var i = 0, l = collection.length; i < l; i++) { - item = collection[i]; - if (item[0] === target && item[1] === method) { - index = i; - break; - } - } + return DictSet; + })(); - return index; -} + var Stack = (function () { + function Stack() { + this.stack = []; + this.current = null; + } -function clearItems(item) { - this._platform.clearTimeout(item[2]); -} + Stack.prototype.toArray = function toArray() { + return this.stack; + }; -exports['default'] = Backburner; + Stack.prototype.push = function push(item) { + this.current = item; + this.stack.push(item); + }; -Object.defineProperty(exports, '__esModule', { value: true }); + Stack.prototype.pop = function pop() { + var item = this.stack.pop(); + var len = this.stack.length; + this.current = len === 0 ? null : this.stack[len - 1]; + return item === undefined ? null : item; + }; -}); -enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) { - 'use strict'; + Stack.prototype.isEmpty = function isEmpty() { + return this.stack.length === 0; + }; - exports.default = Container; - exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations; + return Stack; + })(); - var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE'); + var ListNode = function ListNode(value) { + this.next = null; + this.prev = null; + this.value = value; + }; - /** - A container used to instantiate and cache objects. - - Every `Container` must be associated with a `Registry`, which is referenced - to determine the factory and options that should be used to instantiate - objects. - - The public API for `Container` is still in flux and should not be considered - stable. - - @private - @class Container - */ + var LinkedList = (function () { + function LinkedList() { + this.clear(); + } - function Container(registry, options) { - this.registry = registry; - this.owner = options && options.owner ? options.owner : null; - this.cache = _emberUtils.dictionary(options && options.cache ? options.cache : null); - this.factoryCache = _emberUtils.dictionary(options && options.factoryCache ? options.factoryCache : null); - this.validationCache = _emberUtils.dictionary(options && options.validationCache ? options.validationCache : null); - this._fakeContainerToInject = buildFakeContainerWithDeprecations(this); - this[CONTAINER_OVERRIDE] = undefined; - this.isDestroyed = false; - } + LinkedList.fromSlice = function fromSlice(slice) { + var list = new LinkedList(); + slice.forEachNode(function (n) { + return list.append(n.clone()); + }); + return list; + }; - Container.prototype = { - /** - @private - @property owner - @type Object - */ - owner: null, + LinkedList.prototype.head = function head() { + return this._head; + }; - /** - @private - @property registry - @type Registry - @since 1.11.0 - */ - registry: null, + LinkedList.prototype.tail = function tail() { + return this._tail; + }; - /** - @private - @property cache - @type InheritingDict - */ - cache: null, + LinkedList.prototype.clear = function clear() { + this._head = this._tail = null; + }; - /** - @private - @property factoryCache - @type InheritingDict - */ - factoryCache: null, + LinkedList.prototype.isEmpty = function isEmpty() { + return this._head === null; + }; - /** - @private - @property validationCache - @type InheritingDict - */ - validationCache: null, + LinkedList.prototype.toArray = function toArray() { + var out = []; + this.forEachNode(function (n) { + return out.push(n); + }); + return out; + }; - /** - Given a fullName return a corresponding instance. - The default behaviour is for lookup to return a singleton instance. - The singleton is scoped to the container, allowing multiple containers - to all have their own locally scoped singletons. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter'); - twitter instanceof Twitter; // => true - // by default the container will return singletons - let twitter2 = container.lookup('api:twitter'); - twitter2 instanceof Twitter; // => true - twitter === twitter2; //=> true - ``` - If singletons are not wanted, an optional flag can be provided at lookup. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter', { singleton: false }); - let twitter2 = container.lookup('api:twitter', { singleton: false }); - twitter === twitter2; //=> false - ``` - @private - @method lookup - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] The fullname of the request source (used for local lookup) - @return {any} - */ - lookup: function (fullName, options) { - return lookup(this, this.registry.normalize(fullName), options); - }, + LinkedList.prototype.splice = function splice(start, end, reference) { + var before = undefined; + if (reference === null) { + before = this._tail; + this._tail = end; + } else { + before = reference.prev; + end.next = reference; + reference.prev = end; + } + if (before) { + before.next = start; + start.prev = before; + } + }; - /** - Given a fullName, return the corresponding factory. - @private - @method lookupFactory - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] The fullname of the request source (used for local lookup) - @return {any} - */ - lookupFactory: function (fullName, options) { - return factoryFor(this, this.registry.normalize(fullName), options); - }, + LinkedList.prototype.nextNode = function nextNode(node) { + return node.next; + }; - /** - A depth first traversal, destroying the container, its descendant containers and all - their managed objects. - @private - @method destroy - */ - destroy: function () { - eachDestroyable(this, function (item) { - if (item.destroy) { - item.destroy(); - } - }); + LinkedList.prototype.prevNode = function prevNode(node) { + return node.prev; + }; - this.isDestroyed = true; - }, + LinkedList.prototype.forEachNode = function forEachNode(callback) { + var node = this._head; + while (node !== null) { + callback(node); + node = node.next; + } + }; - /** - Clear either the entire cache or just the cache for a particular key. - @private - @method reset - @param {String} fullName optional key to reset; if missing, resets everything - */ - reset: function (fullName) { - if (arguments.length > 0) { - resetMember(this, this.registry.normalize(fullName)); - } else { - resetCache(this); - } - }, + LinkedList.prototype.contains = function contains(needle) { + var node = this._head; + while (node !== null) { + if (node === needle) return true; + node = node.next; + } + return false; + }; - /** - Returns an object that can be used to provide an owner to a - manually created instance. - @private - @method ownerInjection - @returns { Object } - */ - ownerInjection: function () { - var _ref; + LinkedList.prototype.insertBefore = function insertBefore(node) { + var reference = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; - } - }; + if (reference === null) return this.append(node); + if (reference.prev) reference.prev.next = node;else this._head = node; + node.prev = reference.prev; + node.next = reference; + reference.prev = node; + return node; + }; - function isSingleton(container, fullName) { - return container.registry.getOption(fullName, 'singleton') !== false; - } + LinkedList.prototype.append = function append(node) { + var tail = this._tail; + if (tail) { + tail.next = node; + node.prev = tail; + node.next = null; + } else { + this._head = node; + } + return this._tail = node; + }; - function lookup(container, fullName) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + LinkedList.prototype.pop = function pop() { + if (this._tail) return this.remove(this._tail); + return null; + }; - if (options.source) { - fullName = container.registry.expandLocalLookup(fullName, options); + LinkedList.prototype.prepend = function prepend(node) { + if (this._head) return this.insertBefore(node, this._head); + return this._head = this._tail = node; + }; - // if expandLocalLookup returns falsey, we do not support local lookup - if (!fullName) { - return; - } - } + LinkedList.prototype.remove = function remove(node) { + if (node.prev) node.prev.next = node.next;else this._head = node.next; + if (node.next) node.next.prev = node.prev;else this._tail = node.prev; + return node; + }; - if (container.cache[fullName] !== undefined && options.singleton !== false) { - return container.cache[fullName]; - } + return LinkedList; + })(); - var value = instantiate(container, fullName); + var ListSlice = (function () { + function ListSlice(head, tail) { + this._head = head; + this._tail = tail; + } - if (value === undefined) { - return; - } + ListSlice.toList = function toList(slice) { + var list = new LinkedList(); + slice.forEachNode(function (n) { + return list.append(n.clone()); + }); + return list; + }; - if (isSingleton(container, fullName) && options.singleton !== false) { - container.cache[fullName] = value; - } + ListSlice.prototype.forEachNode = function forEachNode(callback) { + var node = this._head; + while (node !== null) { + callback(node); + node = this.nextNode(node); + } + }; - return value; - } + ListSlice.prototype.contains = function contains(needle) { + var node = this._head; + while (node !== null) { + if (node === needle) return true; + node = node.next; + } + return false; + }; - function markInjectionsAsDynamic(injections) { - injections._dynamic = true; - } + ListSlice.prototype.head = function head() { + return this._head; + }; - function areInjectionsDynamic(injections) { - return !!injections._dynamic; - } + ListSlice.prototype.tail = function tail() { + return this._tail; + }; - function buildInjections() /* container, ...injections */{ - var hash = {}; + ListSlice.prototype.toArray = function toArray() { + var out = []; + this.forEachNode(function (n) { + return out.push(n); + }); + return out; + }; - if (arguments.length > 1) { - var container = arguments[0]; - var injections = []; - var injection = undefined; + ListSlice.prototype.nextNode = function nextNode(node) { + if (node === this._tail) return null; + return node.next; + }; - for (var i = 1; i < arguments.length; i++) { - if (arguments[i]) { - injections = injections.concat(arguments[i]); - } - } + ListSlice.prototype.prevNode = function prevNode(node) { + if (node === this._head) return null; + return node.prev; + }; - container.registry.validateInjections(injections); + ListSlice.prototype.isEmpty = function isEmpty() { + return false; + }; - for (var i = 0; i < injections.length; i++) { - injection = injections[i]; - hash[injection.property] = lookup(container, injection.fullName); - if (!isSingleton(container, injection.fullName)) { - markInjectionsAsDynamic(hash); - } - } - } + return ListSlice; + })(); - return hash; - } + var EMPTY_SLICE = new ListSlice(null, null); - function factoryFor(container, fullName) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + var HAS_TYPED_ARRAYS = typeof Uint32Array !== 'undefined'; + var A = undefined; + if (HAS_TYPED_ARRAYS) { + A = Uint32Array; + } else { + A = Array; + } + var A$1 = A; - var registry = container.registry; + var HAS_NATIVE_WEAKMAP = (function () { + // detect if `WeakMap` is even present + var hasWeakMap = typeof WeakMap === 'function'; + if (!hasWeakMap) { + return false; + } + var instance = new WeakMap(); + // use `Object`'s `.toString` directly to prevent us from detecting + // polyfills as native weakmaps + return Object.prototype.toString.call(instance) === '[object WeakMap]'; + })(); - if (options.source) { - fullName = registry.expandLocalLookup(fullName, options); + exports.getAttrNamespace = getAttrNamespace; + exports.assert = debugAssert; + exports.LOGGER = logger; + exports.Logger = Logger; + exports.LogLevel = LogLevel; + exports.assign = assign; + exports.fillNulls = fillNulls; + exports.ensureGuid = ensureGuid; + exports.initializeGuid = initializeGuid; + exports.Stack = Stack; + exports.DictSet = DictSet; + exports.dict = dict; + exports.EMPTY_SLICE = EMPTY_SLICE; + exports.LinkedList = LinkedList; + exports.ListNode = ListNode; + exports.ListSlice = ListSlice; + exports.A = A$1; + exports.HAS_NATIVE_WEAKMAP = HAS_NATIVE_WEAKMAP; + exports.unwrap = unwrap; + exports.expect = expect; + exports.unreachable = unreachable; +}); +enifed('@glimmer/wire-format', ['exports'], function (exports) { + 'use strict'; - // if expandLocalLookup returns falsey, we do not support local lookup - if (!fullName) { - return; - } + function is(variant) { + return function (value) { + return value[0] === variant; + }; } + var Expressions; + (function (Expressions) { + Expressions.isUnknown = is('unknown'); + Expressions.isArg = is('arg'); + Expressions.isGet = is('get'); + Expressions.isConcat = is('concat'); + Expressions.isHelper = is('helper'); + Expressions.isHasBlock = is('has-block'); + Expressions.isHasBlockParams = is('has-block-params'); + Expressions.isUndefined = is('undefined'); + function isPrimitiveValue(value) { + if (value === null) { + return true; + } + return typeof value !== 'object'; + } + Expressions.isPrimitiveValue = isPrimitiveValue; + })(Expressions || (exports.Expressions = Expressions = {})); + var Statements; + (function (Statements) { + Statements.isText = is('text'); + Statements.isAppend = is('append'); + Statements.isComment = is('comment'); + Statements.isModifier = is('modifier'); + Statements.isBlock = is('block'); + Statements.isComponent = is('component'); + Statements.isOpenElement = is('open-element'); + Statements.isFlushElement = is('flush-element'); + Statements.isCloseElement = is('close-element'); + Statements.isStaticAttr = is('static-attr'); + Statements.isDynamicAttr = is('dynamic-attr'); + Statements.isYield = is('yield'); + Statements.isPartial = is('partial'); + Statements.isDynamicArg = is('dynamic-arg'); + Statements.isStaticArg = is('static-arg'); + Statements.isTrustingAttr = is('trusting-attr'); + Statements.isDebugger = is('debugger'); + function isAttribute(val) { + return val[0] === 'static-attr' || val[0] === 'dynamic-attr'; + } + Statements.isAttribute = isAttribute; + function isArgument(val) { + return val[0] === 'static-arg' || val[0] === 'dynamic-arg'; + } + Statements.isArgument = isArgument; + function isParameter(val) { + return isAttribute(val) || isArgument(val); + } + Statements.isParameter = isParameter; + function getParameterName(s) { + return s[1]; + } + Statements.getParameterName = getParameterName; + })(Statements || (exports.Statements = Statements = {})); - var cache = container.factoryCache; - if (cache[fullName]) { - return cache[fullName]; - } - var factory = registry.resolve(fullName); - if (factory === undefined) { - return; - } + exports.is = is; + exports.Expressions = Expressions; + exports.Statements = Statements; +}); +enifed('backburner', ['exports'], function (exports) { 'use strict'; - var type = fullName.split(':')[0]; - if (!factory || typeof factory.extend !== 'function' || !_emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS && type === 'model') { - if (factory && typeof factory._onLookup === 'function') { - factory._onLookup(fullName); - } +var NUMBER = /\d+/; - // TODO: think about a 'safe' merge style extension - // for now just fallback to create time injection - cache[fullName] = factory; - return factory; - } else { - var injections = injectionsFor(container, fullName); - var factoryInjections = factoryInjectionsFor(container, fullName); - var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); +function each(collection, callback) { + for (var i = 0; i < collection.length; i++) { + callback(collection[i]); + } +} - factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); +function isString(suspect) { + return typeof suspect === 'string'; +} - var injectedFactory = factory.extend(injections); +function isFunction(suspect) { + return typeof suspect === 'function'; +} - // TODO - remove all `container` injections when Ember reaches v3.0.0 - injectDeprecatedContainer(injectedFactory.prototype, container); - injectedFactory.reopenClass(factoryInjections); +function isNumber(suspect) { + return typeof suspect === 'number'; +} - if (factory && typeof factory._onLookup === 'function') { - factory._onLookup(fullName); - } +function isCoercableNumber(number) { + return isNumber(number) || NUMBER.test(number); +} - if (cacheable) { - cache[fullName] = injectedFactory; - } +function binarySearch(time, timers) { + var start = 0; + var end = timers.length - 2; + var middle, l; - return injectedFactory; + while (start < end) { + // since timers is an array of pairs 'l' will always + // be an integer + l = (end - start) / 2; + + // compensate for the index in case even number + // of pairs inside timers + middle = start + l - (l % 2); + + if (time >= timers[middle]) { + start = middle + 2; + } else { + end = middle; } } - function injectionsFor(container, fullName) { - var registry = container.registry; - var splitName = fullName.split(':'); - var type = splitName[0]; + return (time >= timers[start]) ? start + 2 : start; +} - var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); - injections._debugContainerKey = fullName; +function Queue(name, options, globalOptions) { + this.name = name; + this.globalOptions = globalOptions || {}; + this.options = options; + this._queue = []; + this.targetQueues = {}; + this._queueBeingFlushed = undefined; +} - _emberUtils.setOwner(injections, container.owner); +Queue.prototype = { + push: function(target, method, args, stack) { + var queue = this._queue; + queue.push(target, method, args, stack); - return injections; - } + return { + queue: this, + target: target, + method: method + }; + }, - function factoryInjectionsFor(container, fullName) { - var registry = container.registry; - var splitName = fullName.split(':'); - var type = splitName[0]; + pushUniqueWithoutGuid: function(target, method, args, stack) { + var queue = this._queue; - var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); - factoryInjections._debugContainerKey = fullName; + for (var i = 0, l = queue.length; i < l; i += 4) { + var currentTarget = queue[i]; + var currentMethod = queue[i+1]; - return factoryInjections; - } + if (currentTarget === target && currentMethod === method) { + queue[i+2] = args; // replace args + queue[i+3] = stack; // replace stack + return; + } + } - function instantiate(container, fullName) { - var factory = factoryFor(container, fullName); - var lazyInjections = undefined, - validationCache = undefined; + queue.push(target, method, args, stack); + }, - if (container.registry.getOption(fullName, 'instantiate') === false) { - return factory; - } + targetQueue: function(targetQueue, target, method, args, stack) { + var queue = this._queue; - if (factory) { - if (typeof factory.create !== 'function') { - throw new Error('Failed to create an instance of \'' + fullName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); + for (var i = 0, l = targetQueue.length; i < l; i += 2) { + var currentMethod = targetQueue[i]; + var currentIndex = targetQueue[i + 1]; + + if (currentMethod === method) { + queue[currentIndex + 2] = args; // replace args + queue[currentIndex + 3] = stack; // replace stack + return; } + } - validationCache = container.validationCache; + targetQueue.push( + method, + queue.push(target, method, args, stack) - 4 + ); + }, - validationCache[fullName] = true; + pushUniqueWithGuid: function(guid, target, method, args, stack) { + var hasLocalQueue = this.targetQueues[guid]; - var obj = undefined; + if (hasLocalQueue) { + this.targetQueue(hasLocalQueue, target, method, args, stack); + } else { + this.targetQueues[guid] = [ + method, + this._queue.push(target, method, args, stack) - 4 + ]; + } - if (typeof factory.extend === 'function') { - // assume the factory was extendable and is already injected - obj = factory.create(); - } else { - // assume the factory was extendable - // to create time injections - // TODO: support new'ing for instantiation and merge injections for pure JS Functions - var injections = injectionsFor(container, fullName); + return { + queue: this, + target: target, + method: method + }; + }, - // Ensure that a container is available to an object during instantiation. - // TODO - remove when Ember reaches v3.0.0 - // This "fake" container will be replaced after instantiation with a - // property that raises deprecations every time it is accessed. - injections.container = container._fakeContainerToInject; - obj = factory.create(injections); + pushUnique: function(target, method, args, stack) { + var KEY = this.globalOptions.GUID_KEY; - // TODO - remove when Ember reaches v3.0.0 - if (!Object.isFrozen(obj) && 'container' in obj) { - injectDeprecatedContainer(obj, container); - } + if (target && KEY) { + var guid = target[KEY]; + if (guid) { + return this.pushUniqueWithGuid(guid, target, method, args, stack); } - - return obj; } - } - // TODO - remove when Ember reaches v3.0.0 - function injectDeprecatedContainer(object, container) { - Object.defineProperty(object, 'container', { - configurable: true, - enumerable: false, - get: function () { - return this[CONTAINER_OVERRIDE] || container; - }, + this.pushUniqueWithoutGuid(target, method, args, stack); - set: function (value) { + return { + queue: this, + target: target, + method: method + }; + }, - this[CONTAINER_OVERRIDE] = value; + invoke: function(target, method, args /*, onError, errorRecordedForStack */) { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); + } + }, - return value; + invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { + try { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); } - }); - } - - function eachDestroyable(container, callback) { - var cache = container.cache; - var keys = Object.keys(cache); + } catch(error) { + onError(error, errorRecordedForStack); + } + }, - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var value = cache[key]; + flush: function(sync) { + var queue = this._queue; + var length = queue.length; - if (container.registry.getOption(key, 'instantiate') !== false) { - callback(value); - } + if (length === 0) { + return; } - } - function resetCache(container) { - eachDestroyable(container, function (value) { - if (value.destroy) { - value.destroy(); - } - }); + var globalOptions = this.globalOptions; + var options = this.options; + var before = options && options.before; + var after = options && options.after; + var onError = globalOptions.onError || (globalOptions.onErrorTarget && + globalOptions.onErrorTarget[globalOptions.onErrorMethod]); + var target, method, args, errorRecordedForStack; + var invoke = onError ? this.invokeWithOnError : this.invoke; - container.cache.dict = _emberUtils.dictionary(null); - } + this.targetQueues = Object.create(null); + var queueItems = this._queueBeingFlushed = this._queue.slice(); + this._queue = []; - function resetMember(container, fullName) { - var member = container.cache[fullName]; + if (before) { + before(); + } - delete container.factoryCache[fullName]; + for (var i = 0; i < length; i += 4) { + target = queueItems[i]; + method = queueItems[i+1]; + args = queueItems[i+2]; + errorRecordedForStack = queueItems[i+3]; // Debugging assistance - if (member) { - delete container.cache[fullName]; + if (isString(method)) { + method = target[method]; + } - if (member.destroy) { - member.destroy(); + // method could have been nullified / canceled during flush + if (method) { + // + // ** Attention intrepid developer ** + // + // To find out the stack of this task when it was scheduled onto + // the run loop, add the following to your app.js: + // + // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. + // + // Once that is in place, when you are at a breakpoint and navigate + // here in the stack explorer, you can look at `errorRecordedForStack.stack`, + // which will be the captured stack when this job was scheduled. + // + // One possible long-term solution is the following Chrome issue: + // https://bugs.chromium.org/p/chromium/issues/detail?id=332624 + // + invoke(target, method, args, onError, errorRecordedForStack); } } - } - - function buildFakeContainerWithDeprecations(container) { - var fakeContainer = {}; - var propertyMappings = { - lookup: 'lookup', - lookupFactory: '_lookupFactory' - }; - for (var containerProperty in propertyMappings) { - fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]); + if (after) { + after(); } - return fakeContainer; - } + this._queueBeingFlushed = undefined; - function buildFakeContainerFunction(container, containerProperty, ownerProperty) { - return function () { - return container[containerProperty].apply(container, arguments); - }; - } -}); + if (sync !== false && + this._queue.length > 0) { + // check if new items have been added + this.flush(true); + } + }, -// Ensure that all lazy injections are valid at instantiation time -enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) { - /* - Public API for the container is still in flux. - The public API, specified on the application namespace should be considered the stable API. - // @module container - @private - */ + cancel: function(actionToCancel) { + var queue = this._queue, currentTarget, currentMethod, i, l; + var target = actionToCancel.target; + var method = actionToCancel.method; + var GUID_KEY = this.globalOptions.GUID_KEY; - 'use strict'; + if (GUID_KEY && this.targetQueues && target) { + var targetQueue = this.targetQueues[target[GUID_KEY]]; - exports.Registry = _containerRegistry.default; - exports.privatize = _containerRegistry.privatize; - exports.Container = _containerContainer.default; - exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations; -}); -enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) { - 'use strict'; + if (targetQueue) { + for (i = 0, l = targetQueue.length; i < l; i++) { + if (targetQueue[i] === method) { + targetQueue.splice(i, 1); + } + } + } + } - exports.default = Registry; - exports.privatize = privatize; + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; - var VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/; + if (currentTarget === target && + currentMethod === method) { + queue.splice(i, 4); + return true; + } + } - /** - A registry used to store factory and option information keyed - by type. - - A `Registry` stores the factory and option information needed by a - `Container` to instantiate and cache objects. - - The API for `Registry` is still in flux and should not be considered stable. - - @private - @class Registry - @since 1.11.0 - */ + // if not found in current queue + // could be in the queue that is being flushed + queue = this._queueBeingFlushed; - function Registry(options) { - this.fallback = options && options.fallback ? options.fallback : null; + if (!queue) { + return; + } - if (options && options.resolver) { - this.resolver = options.resolver; + for (i = 0, l = queue.length; i < l; i += 4) { + currentTarget = queue[i]; + currentMethod = queue[i+1]; - if (typeof this.resolver === 'function') { - deprecateResolverFunction(this); + if (currentTarget === target && + currentMethod === method) { + // don't mess with array during flush + // just nullify the method + queue[i+1] = null; + return true; } } + } +}; - this.registrations = _emberUtils.dictionary(options && options.registrations ? options.registrations : null); +function DeferredActionQueues(queueNames, options) { + var queues = this.queues = {}; + this.queueNames = queueNames = queueNames || []; - this._typeInjections = _emberUtils.dictionary(null); - this._injections = _emberUtils.dictionary(null); - this._factoryTypeInjections = _emberUtils.dictionary(null); - this._factoryInjections = _emberUtils.dictionary(null); + this.options = options; - this._localLookupCache = new _emberUtils.EmptyObject(); - this._normalizeCache = _emberUtils.dictionary(null); - this._resolveCache = _emberUtils.dictionary(null); - this._failCache = _emberUtils.dictionary(null); + each(queueNames, function(queueName) { + queues[queueName] = new Queue(queueName, options[queueName], options); + }); +} - this._options = _emberUtils.dictionary(null); - this._typeOptions = _emberUtils.dictionary(null); - } +function noSuchQueue(name) { + throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist'); +} - Registry.prototype = { - /** - A backup registry for resolving registrations when no matches can be found. - @private - @property fallback - @type Registry - */ - fallback: null, +function noSuchMethod(name) { + throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist'); +} - /** - An object that has a `resolve` method that resolves a name. - @private - @property resolver - @type Resolver - */ - resolver: null, +DeferredActionQueues.prototype = { + schedule: function(name, target, method, args, onceFlag, stack) { + var queues = this.queues; + var queue = queues[name]; - /** - @private - @property registrations - @type InheritingDict - */ - registrations: null, + if (!queue) { + noSuchQueue(name); + } - /** - @private - @property _typeInjections - @type InheritingDict - */ - _typeInjections: null, + if (!method) { + noSuchMethod(name); + } - /** - @private - @property _injections - @type InheritingDict - */ - _injections: null, + if (onceFlag) { + return queue.pushUnique(target, method, args, stack); + } else { + return queue.push(target, method, args, stack); + } + }, - /** - @private - @property _factoryTypeInjections - @type InheritingDict - */ - _factoryTypeInjections: null, + flush: function() { + var queues = this.queues; + var queueNames = this.queueNames; + var queueName, queue; + var queueNameIndex = 0; + var numberOfQueues = queueNames.length; - /** - @private - @property _factoryInjections - @type InheritingDict - */ - _factoryInjections: null, + while (queueNameIndex < numberOfQueues) { + queueName = queueNames[queueNameIndex]; + queue = queues[queueName]; - /** - @private - @property _normalizeCache - @type InheritingDict - */ - _normalizeCache: null, + var numberOfQueueItems = queue._queue.length; - /** - @private - @property _resolveCache - @type InheritingDict - */ - _resolveCache: null, + if (numberOfQueueItems === 0) { + queueNameIndex++; + } else { + queue.flush(false /* async */); + queueNameIndex = 0; + } + } + } +}; - /** - @private - @property _options - @type InheritingDict - */ - _options: null, +function Backburner(queueNames, options) { + this.queueNames = queueNames; + this.options = options || {}; + if (!this.options.defaultQueue) { + this.options.defaultQueue = queueNames[0]; + } + this.instanceStack = []; + this._debouncees = []; + this._throttlers = []; + this._eventCallbacks = { + end: [], + begin: [] + }; - /** - @private - @property _typeOptions - @type InheritingDict - */ - _typeOptions: null, + var _this = this; + this._boundClearItems = function() { + clearItems(); + }; - /** - Creates a container based on this registry. - @private - @method container - @param {Object} options - @return {Container} created container - */ - container: function (options) { - return new _containerContainer.default(this, options); + this._timerTimeoutId = undefined; + this._timers = []; + + this._platform = this.options._platform || { + setTimeout: function (fn, ms) { + return setTimeout(fn, ms); }, + clearTimeout: function (id) { + clearTimeout(id); + } + }; - /** - Registers a factory for later injection. - Example: - ```javascript - let registry = new Registry(); - registry.register('model:user', Person, {singleton: false }); - registry.register('fruit:favorite', Orange); - registry.register('communication:main', Email, {singleton: false}); - ``` - @private - @method register - @param {String} fullName - @param {Function} factory - @param {Object} options - */ - register: function (fullName, factory) { - var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - - if (factory === undefined) { - throw new TypeError('Attempting to register an unknown factory: \'' + fullName + '\''); - } - - var normalizedName = this.normalize(fullName); - - if (this._resolveCache[normalizedName]) { - throw new Error('Cannot re-register: \'' + fullName + '\', as it has already been resolved.'); - } + this._boundRunExpiredTimers = function () { + _this._runExpiredTimers(); + }; +} - delete this._failCache[normalizedName]; - this.registrations[normalizedName] = factory; - this._options[normalizedName] = options; - }, +Backburner.prototype = { + begin: function() { + var options = this.options; + var onBegin = options && options.onBegin; + var previousInstance = this.currentInstance; - /** - Unregister a fullName - ```javascript - let registry = new Registry(); - registry.register('model:user', User); - registry.resolve('model:user').create() instanceof User //=> true - registry.unregister('model:user') - registry.resolve('model:user') === undefined //=> true - ``` - @private - @method unregister - @param {String} fullName - */ - unregister: function (fullName) { + if (previousInstance) { + this.instanceStack.push(previousInstance); + } - var normalizedName = this.normalize(fullName); + this.currentInstance = new DeferredActionQueues(this.queueNames, options); + this._trigger('begin', this.currentInstance, previousInstance); + if (onBegin) { + onBegin(this.currentInstance, previousInstance); + } + }, - this._localLookupCache = new _emberUtils.EmptyObject(); + end: function() { + var options = this.options; + var onEnd = options && options.onEnd; + var currentInstance = this.currentInstance; + var nextInstance = null; - delete this.registrations[normalizedName]; - delete this._resolveCache[normalizedName]; - delete this._failCache[normalizedName]; - delete this._options[normalizedName]; - }, + // Prevent double-finally bug in Safari 6.0.2 and iOS 6 + // This bug appears to be resolved in Safari 6.0.5 and iOS 7 + var finallyAlreadyCalled = false; + try { + currentInstance.flush(); + } finally { + if (!finallyAlreadyCalled) { + finallyAlreadyCalled = true; - /** - Given a fullName return the corresponding factory. - By default `resolve` will retrieve the factory from - the registry. - ```javascript - let registry = new Registry(); - registry.register('api:twitter', Twitter); - registry.resolve('api:twitter') // => Twitter - ``` - Optionally the registry can be provided with a custom resolver. - If provided, `resolve` will first provide the custom resolver - the opportunity to resolve the fullName, otherwise it will fallback - to the registry. - ```javascript - let registry = new Registry(); - registry.resolver = function(fullName) { - // lookup via the module system of choice - }; - // the twitter factory is added to the module system - registry.resolve('api:twitter') // => Twitter - ``` - @private - @method resolve - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {Function} fullName's factory - */ - resolve: function (fullName, options) { - var factory = resolve(this, this.normalize(fullName), options); - if (factory === undefined && this.fallback) { - var _fallback; + this.currentInstance = null; - factory = (_fallback = this.fallback).resolve.apply(_fallback, arguments); + if (this.instanceStack.length) { + nextInstance = this.instanceStack.pop(); + this.currentInstance = nextInstance; + } + this._trigger('end', currentInstance, nextInstance); + if (onEnd) { + onEnd(currentInstance, nextInstance); + } } - return factory; - }, + } + }, - /** - A hook that can be used to describe how the resolver will - attempt to find the factory. - For example, the default Ember `.describe` returns the full - class name (including namespace) where Ember's resolver expects - to find the `fullName`. - @private - @method describe - @param {String} fullName - @return {string} described fullName - */ - describe: function (fullName) { - if (this.resolver && this.resolver.lookupDescription) { - return this.resolver.lookupDescription(fullName); - } else if (this.fallback) { - return this.fallback.describe(fullName); - } else { - return fullName; - } - }, + /** + Trigger an event. Supports up to two arguments. Designed around + triggering transition events from one run loop instance to the + next, which requires an argument for the first instance and then + an argument for the next instance. - /** - A hook to enable custom fullName normalization behaviour - @private - @method normalizeFullName - @param {String} fullName - @return {string} normalized fullName - */ - normalizeFullName: function (fullName) { - if (this.resolver && this.resolver.normalize) { - return this.resolver.normalize(fullName); - } else if (this.fallback) { - return this.fallback.normalizeFullName(fullName); - } else { - return fullName; + @private + @method _trigger + @param {String} eventName + @param {any} arg1 + @param {any} arg2 + */ + _trigger: function(eventName, arg1, arg2) { + var callbacks = this._eventCallbacks[eventName]; + if (callbacks) { + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](arg1, arg2); } - }, + } + }, - /** - Normalize a fullName based on the application's conventions - @private - @method normalize - @param {String} fullName - @return {string} normalized fullName - */ - normalize: function (fullName) { - return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName)); - }, + on: function(eventName, callback) { + if (typeof callback !== 'function') { + throw new TypeError('Callback must be a function'); + } + var callbacks = this._eventCallbacks[eventName]; + if (callbacks) { + callbacks.push(callback); + } else { + throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist'); + } + }, - /** - @method makeToString - @private - @param {any} factory - @param {string} fullName - @return {function} toString function - */ - makeToString: function (factory, fullName) { - if (this.resolver && this.resolver.makeToString) { - return this.resolver.makeToString(factory, fullName); - } else if (this.fallback) { - return this.fallback.makeToString(factory, fullName); - } else { - return factory.toString(); + off: function(eventName, callback) { + if (eventName) { + var callbacks = this._eventCallbacks[eventName]; + var callbackFound = false; + if (!callbacks) return; + if (callback) { + for (var i = 0; i < callbacks.length; i++) { + if (callbacks[i] === callback) { + callbackFound = true; + callbacks.splice(i, 1); + i--; + } + } } - }, - - /** - Given a fullName check if the container is aware of its factory - or singleton instance. - @private - @method has - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {Boolean} - */ - has: function (fullName, options) { - if (!this.isValidFullName(fullName)) { - return false; + if (!callbackFound) { + throw new TypeError('Cannot off() callback that does not exist'); } + } else { + throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist'); + } + }, - var source = options && options.source && this.normalize(options.source); + run: function(/* target, method, args */) { + var length = arguments.length; + var method, target, args; - return has(this, this.normalize(fullName), source); - }, + if (length === 1) { + method = arguments[0]; + target = null; + } else { + target = arguments[0]; + method = arguments[1]; + } - /** - Allow registering options for all factories of a type. - ```javascript - let registry = new Registry(); - let container = registry.container(); - // if all of type `connection` must not be singletons - registry.optionsForType('connection', { singleton: false }); - registry.register('connection:twitter', TwitterConnection); - registry.register('connection:facebook', FacebookConnection); - let twitter = container.lookup('connection:twitter'); - let twitter2 = container.lookup('connection:twitter'); - twitter === twitter2; // => false - let facebook = container.lookup('connection:facebook'); - let facebook2 = container.lookup('connection:facebook'); - facebook === facebook2; // => false - ``` - @private - @method optionsForType - @param {String} type - @param {Object} options - */ - optionsForType: function (type, options) { - this._typeOptions[type] = options; - }, + if (isString(method)) { + method = target[method]; + } - getOptionsForType: function (type) { - var optionsForType = this._typeOptions[type]; - if (optionsForType === undefined && this.fallback) { - optionsForType = this.fallback.getOptionsForType(type); + if (length > 2) { + args = new Array(length - 2); + for (var i = 0, l = length - 2; i < l; i++) { + args[i] = arguments[i + 2]; } - return optionsForType; - }, + } else { + args = []; + } - /** - @private - @method options - @param {String} fullName - @param {Object} options - */ - options: function (fullName) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var onError = getOnError(this.options); - var normalizedName = this.normalize(fullName); - this._options[normalizedName] = options; - }, + this.begin(); - getOptions: function (fullName) { - var normalizedName = this.normalize(fullName); - var options = this._options[normalizedName]; + // guard against Safari 6's double-finally bug + var didFinally = false; - if (options === undefined && this.fallback) { - options = this.fallback.getOptions(fullName); + if (onError) { + try { + return method.apply(target, args); + } catch(error) { + onError(error); + } finally { + if (!didFinally) { + didFinally = true; + this.end(); + } } - return options; - }, + } else { + try { + return method.apply(target, args); + } finally { + if (!didFinally) { + didFinally = true; + this.end(); + } + } + } + }, - getOption: function (fullName, optionName) { - var options = this._options[fullName]; + /* + Join the passed method with an existing queue and execute immediately, + if there isn't one use `Backburner#run`. - if (options && options[optionName] !== undefined) { - return options[optionName]; - } + The join method is like the run method except that it will schedule into + an existing queue if one already exists. In either case, the join method will + immediately execute the passed in function and return its result. - var type = fullName.split(':')[0]; - options = this._typeOptions[type]; + @method join + @param {Object} target + @param {Function} method The method to be executed + @param {any} args The method arguments + @return method result + */ + join: function(/* target, method, args */) { + if (!this.currentInstance) { + return this.run.apply(this, arguments); + } - if (options && options[optionName] !== undefined) { - return options[optionName]; - } else if (this.fallback) { - return this.fallback.getOption(fullName, optionName); - } - }, + var length = arguments.length; + var method, target; - /** - Used only via `injection`. - Provides a specialized form of injection, specifically enabling - all objects of one type to be injected with a reference to another - object. - For example, provided each object of type `controller` needed a `router`. - one would do the following: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('router:main', Router); - registry.register('controller:user', UserController); - registry.register('controller:post', PostController); - registry.typeInjection('controller', 'router', 'router:main'); - let user = container.lookup('controller:user'); - let post = container.lookup('controller:post'); - user.router instanceof Router; //=> true - post.router instanceof Router; //=> true - // both controllers share the same router - user.router === post.router; //=> true - ``` - @private - @method typeInjection - @param {String} type - @param {String} property - @param {String} fullName - */ - typeInjection: function (type, property, fullName) { + if (length === 1) { + method = arguments[0]; + target = null; + } else { + target = arguments[0]; + method = arguments[1]; + } - var fullNameType = fullName.split(':')[0]; - if (fullNameType === type) { - throw new Error('Cannot inject a \'' + fullName + '\' on other ' + type + '(s).'); + if (isString(method)) { + method = target[method]; + } + + if (length === 1) { + return method(); + } else if (length === 2) { + return method.call(target); + } else { + var args = new Array(length - 2); + for (var i = 0, l = length - 2; i < l; i++) { + args[i] = arguments[i + 2]; } + return method.apply(target, args); + } + }, - var injections = this._typeInjections[type] || (this._typeInjections[type] = []); - injections.push({ - property: property, - fullName: fullName - }); - }, + /* + Defer the passed function to run inside the specified queue. - /** - Defines injection rules. - These rules are used to inject dependencies onto objects when they - are instantiated. - Two forms of injections are possible: - * Injecting one fullName on another fullName - * Injecting one fullName on a type - Example: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('source:main', Source); - registry.register('model:user', User); - registry.register('model:post', Post); - // injecting one fullName on another fullName - // eg. each user model gets a post model - registry.injection('model:user', 'post', 'model:post'); - // injecting one fullName on another type - registry.injection('model', 'source', 'source:main'); - let user = container.lookup('model:user'); - let post = container.lookup('model:post'); - user.source instanceof Source; //=> true - post.source instanceof Source; //=> true - user.post instanceof Post; //=> true - // and both models share the same source - user.source === post.source; //=> true - ``` - @private - @method injection - @param {String} factoryName - @param {String} property - @param {String} injectionName - */ - injection: function (fullName, property, injectionName) { - this.validateFullName(injectionName); - var normalizedInjectionName = this.normalize(injectionName); + @method defer + @param {String} queueName + @param {Object} target + @param {Function|String} method The method or method name to be executed + @param {any} args The method arguments + @return method result + */ + defer: function(queueName /* , target, method, args */) { + var length = arguments.length; + var method, target, args; - if (fullName.indexOf(':') === -1) { - return this.typeInjection(fullName, property, normalizedInjectionName); - } + if (length === 2) { + method = arguments[1]; + target = null; + } else { + target = arguments[1]; + method = arguments[2]; + } - var normalizedName = this.normalize(fullName); + if (isString(method)) { + method = target[method]; + } - var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); + var stack = this.DEBUG ? new Error() : undefined; - injections.push({ - property: property, - fullName: normalizedInjectionName - }); - }, + if (length > 3) { + args = new Array(length - 3); + for (var i = 3; i < length; i++) { + args[i-3] = arguments[i]; + } + } else { + args = undefined; + } - /** - Used only via `factoryInjection`. - Provides a specialized form of injection, specifically enabling - all factory of one type to be injected with a reference to another - object. - For example, provided each factory of type `model` needed a `store`. - one would do the following: - ```javascript - let registry = new Registry(); - registry.register('store:main', SomeStore); - registry.factoryTypeInjection('model', 'store', 'store:main'); - let store = registry.lookup('store:main'); - let UserFactory = registry.lookupFactory('model:user'); - UserFactory.store instanceof SomeStore; //=> true - ``` - @private - @method factoryTypeInjection - @param {String} type - @param {String} property - @param {String} fullName - */ - factoryTypeInjection: function (type, property, fullName) { - var injections = this._factoryTypeInjections[type] || (this._factoryTypeInjections[type] = []); + if (!this.currentInstance) { createAutorun(this); } + return this.currentInstance.schedule(queueName, target, method, args, false, stack); + }, - injections.push({ - property: property, - fullName: this.normalize(fullName) - }); - }, + deferOnce: function(queueName /* , target, method, args */) { + var length = arguments.length; + var method, target, args; - /** - Defines factory injection rules. - Similar to regular injection rules, but are run against factories, via - `Registry#lookupFactory`. - These rules are used to inject objects onto factories when they - are looked up. - Two forms of injections are possible: - * Injecting one fullName on another fullName - * Injecting one fullName on a type - Example: - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('store:main', Store); - registry.register('store:secondary', OtherStore); - registry.register('model:user', User); - registry.register('model:post', Post); - // injecting one fullName on another type - registry.factoryInjection('model', 'store', 'store:main'); - // injecting one fullName on another fullName - registry.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); - let UserFactory = container.lookupFactory('model:user'); - let PostFactory = container.lookupFactory('model:post'); - let store = container.lookup('store:main'); - UserFactory.store instanceof Store; //=> true - UserFactory.secondaryStore instanceof OtherStore; //=> false - PostFactory.store instanceof Store; //=> true - PostFactory.secondaryStore instanceof OtherStore; //=> true - // and both models share the same source instance - UserFactory.store === PostFactory.store; //=> true - ``` - @private - @method factoryInjection - @param {String} factoryName - @param {String} property - @param {String} injectionName - */ - factoryInjection: function (fullName, property, injectionName) { - var normalizedName = this.normalize(fullName); - var normalizedInjectionName = this.normalize(injectionName); + if (length === 2) { + method = arguments[1]; + target = null; + } else { + target = arguments[1]; + method = arguments[2]; + } - this.validateFullName(injectionName); + if (isString(method)) { + method = target[method]; + } - if (fullName.indexOf(':') === -1) { - return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); + var stack = this.DEBUG ? new Error() : undefined; + + if (length > 3) { + args = new Array(length - 3); + for (var i = 3; i < length; i++) { + args[i-3] = arguments[i]; } + } else { + args = undefined; + } - var injections = this._factoryInjections[normalizedName] || (this._factoryInjections[normalizedName] = []); + if (!this.currentInstance) { + createAutorun(this); + } + return this.currentInstance.schedule(queueName, target, method, args, true, stack); + }, - injections.push({ - property: property, - fullName: normalizedInjectionName - }); - }, + setTimeout: function() { + var l = arguments.length; + var args = new Array(l); - /** - @private - @method knownForType - @param {String} type the type to iterate over - */ - knownForType: function (type) { - var fallbackKnown = undefined, - resolverKnown = undefined; + for (var x = 0; x < l; x++) { + args[x] = arguments[x]; + } - var localKnown = _emberUtils.dictionary(null); - var registeredNames = Object.keys(this.registrations); - for (var index = 0; index < registeredNames.length; index++) { - var fullName = registeredNames[index]; - var itemType = fullName.split(':')[0]; + var length = args.length, + method, wait, target, + methodOrTarget, methodOrWait, methodOrArgs; - if (itemType === type) { - localKnown[fullName] = true; - } - } + if (length === 0) { + return; + } else if (length === 1) { + method = args.shift(); + wait = 0; + } else if (length === 2) { + methodOrTarget = args[0]; + methodOrWait = args[1]; - if (this.fallback) { - fallbackKnown = this.fallback.knownForType(type); + if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) { + target = args.shift(); + method = args.shift(); + wait = 0; + } else if (isCoercableNumber(methodOrWait)) { + method = args.shift(); + wait = args.shift(); + } else { + method = args.shift(); + wait = 0; } + } else { + var last = args[args.length - 1]; - if (this.resolver && this.resolver.knownForType) { - resolverKnown = this.resolver.knownForType(type); + if (isCoercableNumber(last)) { + wait = args.pop(); + } else { + wait = 0; } - return _emberUtils.assign({}, fallbackKnown, localKnown, resolverKnown); - }, + methodOrTarget = args[0]; + methodOrArgs = args[1]; - validateFullName: function (fullName) { - if (!this.isValidFullName(fullName)) { - throw new TypeError('Invalid Fullname, expected: \'type:name\' got: ' + fullName); + if (isFunction(methodOrArgs) || (isString(methodOrArgs) && + methodOrTarget !== null && + methodOrArgs in methodOrTarget)) { + target = args.shift(); + method = args.shift(); + } else { + method = args.shift(); } + } - return true; - }, + var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); - isValidFullName: function (fullName) { - return !!VALID_FULL_NAME_REGEXP.test(fullName); - }, + if (isString(method)) { + method = target[method]; + } - validateInjections: function (injections) { - if (!injections) { - return; + var onError = getOnError(this.options); + + function fn() { + if (onError) { + try { + method.apply(target, args); + } catch (e) { + onError(e); + } + } else { + method.apply(target, args); } + } - var fullName = undefined; + return this._setTimeout(fn, executeAt); + }, - for (var i = 0; i < injections.length; i++) { - fullName = injections[i].fullName; + _setTimeout: function (fn, executeAt) { + if (this._timers.length === 0) { + this._timers.push(executeAt, fn); + this._installTimerTimeout(); + return fn; + } - if (!this.has(fullName)) { - throw new Error('Attempting to inject an unknown injection: \'' + fullName + '\''); - } - } - }, + // find position to insert + var i = binarySearch(executeAt, this._timers); - normalizeInjectionsHash: function (hash) { - var injections = []; + this._timers.splice(i, 0, executeAt, fn); - for (var key in hash) { - if (hash.hasOwnProperty(key)) { + // we should be the new earliest timer if i == 0 + if (i === 0) { + this._reinstallTimerTimeout(); + } - injections.push({ - property: key, - fullName: hash[key] - }); - } - } + return fn; + }, - return injections; - }, + throttle: function(target, method /* , args, wait, [immediate] */) { + var backburner = this; + var args = new Array(arguments.length); + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + var immediate = args.pop(); + var wait, throttler, index, timer; - getInjections: function (fullName) { - var injections = this._injections[fullName] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getInjections(fullName)); - } - return injections; - }, + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = true; + } else { + wait = args.pop(); + } - getTypeInjections: function (type) { - var injections = this._typeInjections[type] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getTypeInjections(type)); - } - return injections; - }, + wait = parseInt(wait, 10); - getFactoryInjections: function (fullName) { - var injections = this._factoryInjections[fullName] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getFactoryInjections(fullName)); - } - return injections; - }, + index = findThrottler(target, method, this._throttlers); + if (index > -1) { return this._throttlers[index]; } // throttled - getFactoryTypeInjections: function (type) { - var injections = this._factoryTypeInjections[type] || []; - if (this.fallback) { - injections = injections.concat(this.fallback.getFactoryTypeInjections(type)); + timer = this._platform.setTimeout(function() { + if (!immediate) { + backburner.run.apply(backburner, args); } - return injections; + var index = findThrottler(target, method, backburner._throttlers); + if (index > -1) { + backburner._throttlers.splice(index, 1); + } + }, wait); + + if (immediate) { + this.run.apply(this, args); } - }; - function deprecateResolverFunction(registry) { - registry.resolver = { - resolve: registry.resolver - }; - } + throttler = [target, method, timer]; - /** - Given a fullName and a source fullName returns the fully resolved - fullName. Used to allow for local lookup. - - ```javascript - let registry = new Registry(); - - // the twitter factory is added to the module system - registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title - ``` - - @private - @method expandLocalLookup - @param {String} fullName - @param {Object} [options] - @param {String} [options.source] the fullname of the request source (used for local lookups) - @return {String} fullName - */ - Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) { - if (this.resolver && this.resolver.expandLocalLookup) { + this._throttlers.push(throttler); - var normalizedFullName = this.normalize(fullName); - var normalizedSource = this.normalize(options.source); + return throttler; + }, - return expandLocalLookup(this, normalizedFullName, normalizedSource); - } else if (this.fallback) { - return this.fallback.expandLocalLookup(fullName, options); + debounce: function(target, method /* , args, wait, [immediate] */) { + var backburner = this; + var args = new Array(arguments.length); + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + + var immediate = args.pop(); + var wait, index, debouncee, timer; + + if (isNumber(immediate) || isString(immediate)) { + wait = immediate; + immediate = false; } else { - return null; + wait = args.pop(); } - }; - function expandLocalLookup(registry, normalizedName, normalizedSource) { - var cache = registry._localLookupCache; - var normalizedNameCache = cache[normalizedName]; + wait = parseInt(wait, 10); + // Remove debouncee + index = findDebouncee(target, method, this._debouncees); - if (!normalizedNameCache) { - normalizedNameCache = cache[normalizedName] = new _emberUtils.EmptyObject(); + if (index > -1) { + debouncee = this._debouncees[index]; + this._debouncees.splice(index, 1); + this._platform.clearTimeout(debouncee[2]); } - var cached = normalizedNameCache[normalizedSource]; + timer = this._platform.setTimeout(function() { + if (!immediate) { + backburner.run.apply(backburner, args); + } + var index = findDebouncee(target, method, backburner._debouncees); + if (index > -1) { + backburner._debouncees.splice(index, 1); + } + }, wait); - if (cached !== undefined) { - return cached; + if (immediate && index === -1) { + backburner.run.apply(backburner, args); } - var expanded = registry.resolver.expandLocalLookup(normalizedName, normalizedSource); + debouncee = [ + target, + method, + timer + ]; - return normalizedNameCache[normalizedSource] = expanded; - } + backburner._debouncees.push(debouncee); - function resolve(registry, normalizedName, options) { - if (options && options.source) { - // when `source` is provided expand normalizedName - // and source into the full normalizedName - normalizedName = registry.expandLocalLookup(normalizedName, options); + return debouncee; + }, - // if expandLocalLookup returns falsey, we do not support local lookup - if (!normalizedName) { - return; - } - } + cancelTimers: function() { + each(this._throttlers, this._boundClearItems); + this._throttlers = []; - var cached = registry._resolveCache[normalizedName]; - if (cached !== undefined) { - return cached; - } - if (registry._failCache[normalizedName]) { - return; - } + each(this._debouncees, this._boundClearItems); + this._debouncees = []; - var resolved = undefined; + this._clearTimerTimeout(); + this._timers = []; - if (registry.resolver) { - resolved = registry.resolver.resolve(normalizedName); + if (this._autorun) { + this._platform.clearTimeout(this._autorun); + this._autorun = null; } + }, - if (resolved === undefined) { - resolved = registry.registrations[normalizedName]; - } + hasTimers: function() { + return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun; + }, - if (resolved === undefined) { - registry._failCache[normalizedName] = true; + cancel: function (timer) { + var timerType = typeof timer; + + if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce + return timer.queue.cancel(timer); + } else if (timerType === 'function') { // we're cancelling a setTimeout + for (var i = 0, l = this._timers.length; i < l; i += 2) { + if (this._timers[i + 1] === timer) { + this._timers.splice(i, 2); // remove the two elements + if (i === 0) { + this._reinstallTimerTimeout(); + } + return true; + } + } + } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce + return this._cancelItem(findThrottler, this._throttlers, timer) || + this._cancelItem(findDebouncee, this._debouncees, timer); } else { - registry._resolveCache[normalizedName] = resolved; + return; // timer was null or not a timer } + }, - return resolved; - } + _cancelItem: function(findMethod, array, timer){ + var item, index; - function has(registry, fullName, source) { - return registry.resolve(fullName, { source: source }) !== undefined; - } + if (timer.length < 3) { return false; } - var privateNames = _emberUtils.dictionary(null); - var privateSuffix = '' + Math.random() + Date.now(); + index = findMethod(timer[0], timer[1], array); - function privatize(_ref) { - var fullName = _ref[0]; + if (index > -1) { - var name = privateNames[fullName]; - if (name) { - return name; + item = array[index]; + + if (item[2] === timer[2]) { + array.splice(index, 1); + this._platform.clearTimeout(timer[2]); + return true; + } } - var _fullName$split = fullName.split(':'); + return false; + }, - var type = _fullName$split[0]; - var rawName = _fullName$split[1]; + _runExpiredTimers: function () { + this._timerTimeoutId = undefined; + this.run(this, this._scheduleExpiredTimers); + }, - return privateNames[fullName] = _emberUtils.intern(type + ':' + rawName + '-' + privateSuffix); - } -}); -enifed('dag-map', ['exports'], function (exports) { 'use strict'; + _scheduleExpiredTimers: function () { + var n = Date.now(); + var timers = this._timers; + var i = 0; + var l = timers.length; + for (; i < l; i += 2) { + var executeAt = timers[i]; + var fn = timers[i+1]; + if (executeAt <= n) { + this.schedule(this.options.defaultQueue, null, fn); + } else { + break; + } + } + timers.splice(0, i); + this._installTimerTimeout(); + }, -/** - * A map of key/value pairs with dependencies contraints that can be traversed - * in topological order and is checked for cycles. - * - * @class DAG - * @constructor - */ -var DAG = (function () { - function DAG() { - this._vertices = new Vertices(); + _reinstallTimerTimeout: function () { + this._clearTimerTimeout(); + this._installTimerTimeout(); + }, + + _clearTimerTimeout: function () { + if (!this._timerTimeoutId) { + return; } - /** - * Adds a key/value pair with dependencies on other key/value pairs. - * - * @public - * @method addEdges - * @param {string[]} key The key of the vertex to be added. - * @param {any} value The value of that vertex. - * @param {string[]|string|undefined} before A key or array of keys of the vertices that must - * be visited before this vertex. - * @param {string[]|string|undefined} after An string or array of strings with the keys of the - * vertices that must be after this vertex is visited. - */ - DAG.prototype.add = function (key, value, before, after) { - var vertices = this._vertices; - var v = vertices.add(key); - v.val = value; - if (before) { - if (typeof before === "string") { - vertices.addEdge(v, vertices.add(before)); - } - else { - for (var i = 0; i < before.length; i++) { - vertices.addEdge(v, vertices.add(before[i])); - } - } - } - if (after) { - if (typeof after === "string") { - vertices.addEdge(vertices.add(after), v); - } - else { - for (var i = 0; i < after.length; i++) { - vertices.addEdge(vertices.add(after[i]), v); - } - } - } - }; - /** - * Visits key/value pairs in topological order. - * - * @public - * @method topsort - * @param {Function} fn The function to be invoked with each key/value. - */ - DAG.prototype.topsort = function (callback) { - this._vertices.topsort(callback); - }; - return DAG; -}()); -var Vertices = (function () { - function Vertices() { - this.stack = new IntStack(); - this.result = new IntStack(); - this.vertices = []; - } - Vertices.prototype.add = function (key) { - if (!key) - throw new Error("missing key"); - var vertices = this.vertices; - var i = 0; - var vertex; - for (; i < vertices.length; i++) { - vertex = vertices[i]; - if (vertex.key === key) - return vertex; - } - return vertices[i] = { - id: i, - key: key, - val: null, - inc: null, - out: false, - mark: false - }; - }; - Vertices.prototype.addEdge = function (v, w) { - this.check(v, w.key); - var inc = w.inc; - if (!inc) { - w.inc = [v.id]; - } - else { - var i = 0; - for (; i < inc.length; i++) { - if (inc[i] === v.id) - return; - } - inc[i] = v.id; - } - v.out = true; - }; - Vertices.prototype.topsort = function (cb) { - this.reset(); - var vertices = this.vertices; - for (var i = 0; i < vertices.length; i++) { - var vertex = vertices[i]; - if (vertex.out) - continue; - this.visit(vertex, undefined); - } - this.each(cb); - }; - Vertices.prototype.check = function (v, w) { - if (v.key === w) { - throw new Error("cycle detected: " + w + " <- " + w); - } - var inc = v.inc; - // quick check - if (!inc || inc.length === 0) - return; - var vertices = this.vertices; - // shallow check - for (var i = 0; i < inc.length; i++) { - var key = vertices[inc[i]].key; - if (key === w) { - throw new Error("cycle detected: " + w + " <- " + v.key + " <- " + w); - } - } - // deep check - this.reset(); - this.visit(v, w); - if (this.result.len > 0) { - var msg_1 = "cycle detected: " + w; - this.each(function (key) { - msg_1 += " <- " + key; - }); - throw new Error(msg_1); - } - }; - Vertices.prototype.each = function (cb) { - var _a = this, result = _a.result, vertices = _a.vertices; - for (var i = 0; i < result.len; i++) { - var vertex = vertices[result.stack[i]]; - cb(vertex.key, vertex.val); - } - }; - // reuse between cycle check and topsort - Vertices.prototype.reset = function () { - this.stack.len = 0; - this.result.len = 0; - var vertices = this.vertices; - for (var i = 0; i < vertices.length; i++) { - vertices[i].mark = false; - } - }; - Vertices.prototype.visit = function (start, search) { - var _a = this, stack = _a.stack, result = _a.result, vertices = _a.vertices; - stack.push(start.id); - while (stack.len) { - var index = stack.pop(); - if (index < 0) { - index = ~index; - if (search) { - result.pop(); - } - else { - result.push(index); - } - } - else { - var vertex = vertices[index]; - if (vertex.mark) { - continue; - } - if (search) { - result.push(index); - if (search === vertex.key) { - return; - } - } - vertex.mark = true; - stack.push(~index); - var incoming = vertex.inc; - if (incoming) { - var i = incoming.length; - while (i--) { - index = incoming[i]; - if (!vertices[index].mark) { - stack.push(index); - } - } - } - } - } - }; - return Vertices; -}()); -var IntStack = (function () { - function IntStack() { - this.stack = [0, 0, 0, 0, 0, 0]; - this.len = 0; + this._platform.clearTimeout(this._timerTimeoutId); + this._timerTimeoutId = undefined; + }, + + _installTimerTimeout: function () { + if (!this._timers.length) { + return; } - IntStack.prototype.push = function (n) { - this.stack[this.len++] = n; - }; - IntStack.prototype.pop = function () { - return this.stack[--this.len]; - }; - return IntStack; -}()); + var minExpiresAt = this._timers[0]; + var n = Date.now(); + var wait = Math.max(0, minExpiresAt - n); + this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); + } +}; -exports['default'] = DAG; +Backburner.prototype.schedule = Backburner.prototype.defer; +Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; +Backburner.prototype.later = Backburner.prototype.setTimeout; -Object.defineProperty(exports, '__esModule', { value: true }); +function getOnError(options) { + return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); +} -}); -enifed('ember-application/index', ['exports', 'ember-application/initializers/dom-templates', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/resolver', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (exports, _emberApplicationInitializersDomTemplates, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberApplicationSystemResolver, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent) { - /** - @module ember - @submodule ember-application - */ +function createAutorun(backburner) { + var setTimeout = backburner._platform.setTimeout; + backburner.begin(); + backburner._autorun = setTimeout(function() { + backburner._autorun = null; + backburner.end(); + }, 0); +} - 'use strict'; +function findDebouncee(target, method, debouncees) { + return findItem(target, method, debouncees); +} - exports.Application = _emberApplicationSystemApplication.default; - exports.ApplicationInstance = _emberApplicationSystemApplicationInstance.default; - exports.Resolver = _emberApplicationSystemResolver.default; - exports.Engine = _emberApplicationSystemEngine.default; - exports.EngineInstance = _emberApplicationSystemEngineInstance.default; - exports.getEngineParent = _emberApplicationSystemEngineParent.getEngineParent; - exports.setEngineParent = _emberApplicationSystemEngineParent.setEngineParent; +function findThrottler(target, method, throttlers) { + return findItem(target, method, throttlers); +} - // add domTemplates initializer (only does something if `ember-template-compiler` - // is loaded already) -}); -enifed('ember-application/initializers/dom-templates', ['exports', 'require', 'ember-glimmer', 'ember-environment', 'ember-application/system/application'], function (exports, _require, _emberGlimmer, _emberEnvironment, _emberApplicationSystemApplication) { - 'use strict'; +function findItem(target, method, collection) { + var item; + var index = -1; - var bootstrap = function () {}; + for (var i = 0, l = collection.length; i < l; i++) { + item = collection[i]; + if (item[0] === target && item[1] === method) { + index = i; + break; + } + } - _emberApplicationSystemApplication.default.initializer({ - name: 'domTemplates', - initialize: function () { - var bootstrapModuleId = 'ember-template-compiler/system/bootstrap'; - var context = undefined; - if (_emberEnvironment.environment.hasDOM && _require.has(bootstrapModuleId)) { - bootstrap = _require.default(bootstrapModuleId).default; - context = document; - } + return index; +} - bootstrap({ context: context, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); - } - }); -}); -enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberViews, _emberApplicationSystemEngineInstance) { - /** - @module ember - @submodule ember-application - */ +function clearItems(item) { + this._platform.clearTimeout(item[2]); +} + +exports['default'] = Backburner; + +Object.defineProperty(exports, '__esModule', { value: true }); +}); +enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) { + /* globals Proxy */ 'use strict'; - var BootOptions = undefined; + var _Container$prototype; + + exports.default = Container; + exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations; + + var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE'); + var FACTORY_FOR = _emberUtils.symbol('FACTORY_FOR'); + exports.FACTORY_FOR = FACTORY_FOR; + var LOOKUP_FACTORY = _emberUtils.symbol('LOOKUP_FACTORY'); + exports.LOOKUP_FACTORY = LOOKUP_FACTORY; /** - The `ApplicationInstance` encapsulates all of the stateful aspects of a - running `Application`. - - At a high-level, we break application boot into two distinct phases: - - * Definition time, where all of the classes, templates, and other - dependencies are loaded (typically in the browser). - * Run time, where we begin executing the application once everything - has loaded. + A container used to instantiate and cache objects. - Definition time can be expensive and only needs to happen once since it is - an idempotent operation. For example, between test runs and FastBoot - requests, the application stays the same. It is only the state that we want - to reset. + Every `Container` must be associated with a `Registry`, which is referenced + to determine the factory and options that should be used to instantiate + objects. - That state is what the `ApplicationInstance` manages: it is responsible for - creating the container that contains all application state, and disposing of - it once the particular test run or FastBoot request has finished. + The public API for `Container` is still in flux and should not be considered + stable. - @public - @class Ember.ApplicationInstance - @extends Ember.EngineInstance - */ + @private + @class Container + */ - var ApplicationInstance = _emberApplicationSystemEngineInstance.default.extend({ + function Container(registry, options) { + this.registry = registry; + this.owner = options && options.owner ? options.owner : null; + this.cache = _emberUtils.dictionary(options && options.cache ? options.cache : null); + this.factoryCache = _emberUtils.dictionary(options && options.factoryCache ? options.factoryCache : null); + this.validationCache = _emberUtils.dictionary(options && options.validationCache ? options.validationCache : null); + this._fakeContainerToInject = buildFakeContainerWithDeprecations(this); + this[CONTAINER_OVERRIDE] = undefined; + this.isDestroyed = false; + } + + Container.prototype = (_Container$prototype = { /** - The `Application` for which this is an instance. - @property {Ember.Application} application - @private - */ - application: null, + @private + @property owner + @type Object + */ + owner: null, /** - The DOM events for which the event dispatcher should listen. - By default, the application's `Ember.EventDispatcher` listens - for a set of standard DOM events, such as `mousedown` and - `keyup`, and delegates them to your application's `Ember.View` - instances. - @private - @property {Object} customEvents - */ - customEvents: null, + @private + @property registry + @type Registry + @since 1.11.0 + */ + registry: null, /** - The root DOM element of the Application as an element or a - [jQuery-compatible selector - string](http://api.jquery.com/category/selectors/). - @private - @property {String|DOMElement} rootElement - */ - rootElement: null, + @private + @property cache + @type InheritingDict + */ + cache: null, - init: function () { - this._super.apply(this, arguments); + /** + @private + @property factoryCache + @type InheritingDict + */ + factoryCache: null, - // Register this instance in the per-instance registry. - // - // Why do we need to register the instance in the first place? - // Because we need a good way for the root route (a.k.a ApplicationRoute) - // to notify us when it has created the root-most view. That view is then - // appended to the rootElement, in the case of apps, to the fixture harness - // in tests, or rendered to a string in the case of FastBoot. - this.register('-application-instance:main', this, { instantiate: false }); + /** + @private + @property validationCache + @type InheritingDict + */ + validationCache: null, + + /** + Given a fullName return a corresponding instance. + The default behaviour is for lookup to return a singleton instance. + The singleton is scoped to the container, allowing multiple containers + to all have their own locally scoped singletons. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter'); + twitter instanceof Twitter; // => true + // by default the container will return singletons + let twitter2 = container.lookup('api:twitter'); + twitter2 instanceof Twitter; // => true + twitter === twitter2; //=> true + ``` + If singletons are not wanted, an optional flag can be provided at lookup. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter', { singleton: false }); + let twitter2 = container.lookup('api:twitter', { singleton: false }); + twitter === twitter2; //=> false + ``` + @private + @method lookup + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + lookup: function (fullName, options) { + return lookup(this, this.registry.normalize(fullName), options); }, /** - Overrides the base `EngineInstance._bootSync` method with concerns relevant - to booting application (instead of engine) instances. - This method should only contain synchronous boot concerns. Asynchronous - boot concerns should eventually be moved to the `boot` method, which - returns a promise. - Until all boot code has been made asynchronous, we need to continue to - expose this method for use *internally* in places where we need to boot an - instance synchronously. - @private - */ - _bootSync: function (options) { - if (this._booted) { - return this; - } + Given a fullName, return the corresponding factory. + @private + @method lookupFactory + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + lookupFactory: function (fullName, options) { - options = new BootOptions(options); + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + } - this.setupRegistry(options); + }, _Container$prototype[LOOKUP_FACTORY] = function (fullName, options) { + return deprecatedFactoryFor(this, this.registry.normalize(fullName), options); + }, _Container$prototype[FACTORY_FOR] = function (fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (options.rootElement) { - this.rootElement = options.rootElement; + if (_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + if (true) { + return this.factoryFor(fullName, options); } else { - this.rootElement = this.application.rootElement; + /* This throws in case of a poorly designed build */ + throw new Error('If ember-no-double-extend is enabled, ember-factory-for must also be enabled'); } + } + var factory = this[LOOKUP_FACTORY](fullName, options); + if (factory === undefined) { + return; + } + var manager = new DeprecatedFactoryManager(this, factory, fullName); - if (options.location) { - var router = _emberMetal.get(this, 'router'); - _emberMetal.set(router, 'location', options.location); + return manager; + }, _Container$prototype.destroy = function () { + eachDestroyable(this, function (item) { + if (item.destroy) { + item.destroy(); } + }); - this.application.runInstanceInitializers(this); + this.isDestroyed = true; + }, _Container$prototype.reset = function (fullName) { + if (arguments.length > 0) { + resetMember(this, this.registry.normalize(fullName)); + } else { + resetCache(this); + } + }, _Container$prototype.ownerInjection = function () { + var _ref; - if (options.isInteractive) { - this.setupEventDispatcher(); - } + return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref; + }, _Container$prototype); - this._booted = true; + /* + * Wrap a factory manager in a proxy which will not permit properties to be + * set on the manager. + */ + function wrapManagerInDeprecationProxy(manager) { + if (_emberUtils.HAS_NATIVE_PROXY) { + var _ret = (function () { + var validator = { + get: function (obj, prop) { + if (prop !== 'class' && prop !== 'create') { + throw new Error('You attempted to access "' + prop + '" on a factory manager created by container#factoryFor. "' + prop + '" is not a member of a factory manager."'); + } - return this; - }, + return obj[prop]; + }, + set: function (obj, prop, value) { + throw new Error('You attempted to set "' + prop + '" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.'); + } + }; - setupRegistry: function (options) { - this.constructor.setupRegistry(this.__registry__, options); - }, + // Note: + // We have to proxy access to the manager here so that private property + // access doesn't cause the above errors to occur. + var m = manager; + var proxiedManager = { + class: m.class, + create: function (props) { + return m.create(props); + } + }; - router: _emberMetal.computed(function () { - return this.lookup('router:main'); - }).readOnly(), + return { + v: new Proxy(proxiedManager, validator) + }; + })(); - /** - This hook is called by the root-most Route (a.k.a. the ApplicationRoute) - when it has finished creating the root View. By default, we simply take the - view and append it to the `rootElement` specified on the Application. - In cases like FastBoot and testing, we can override this hook and implement - custom behavior, such as serializing to a string and sending over an HTTP - socket rather than appending to DOM. - @param view {Ember.View} the root-most view - @private - */ - didCreateRootView: function (view) { - view.appendTo(this.rootElement); - }, + if (typeof _ret === 'object') return _ret.v; + } - /** - Tells the router to start routing. The router will ask the location for the - current URL of the page to determine the initial URL to start routing to. - To start the app at a specific URL, call `handleURL` instead. - @private - */ - startRouting: function () { - var router = _emberMetal.get(this, 'router'); - router.startRouting(); - this._didSetupRouter = true; - }, + return manager; + } + if (true) { /** - @private - Sets up the router, initializing the child router and configuring the - location before routing begins. - Because setup should only occur once, multiple calls to `setupRouter` - beyond the first call have no effect. - */ - setupRouter: function () { - if (this._didSetupRouter) { - return; + Given a fullName, return the corresponding factory. The consumer of the factory + is responsible for the destruction of any factory instances, as there is no + way for the container to ensure instances are destroyed when it itself is + destroyed. + @public + @method factoryFor + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] The fullname of the request source (used for local lookup) + @return {any} + */ + Container.prototype.factoryFor = function _factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var normalizedName = this.registry.normalize(fullName); + + if (options.source) { + normalizedName = this.registry.expandLocalLookup(fullName, options); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!normalizedName) { + return; + } } - this._didSetupRouter = true; - var router = _emberMetal.get(this, 'router'); - router.setupRouter(); - }, + var factory = this.registry.resolve(normalizedName); - /** - Directs the router to route to a particular URL. This is useful in tests, - for example, to tell the app to start at a particular URL. - @param url {String} the URL the router should route to - @private - */ - handleURL: function (url) { - var router = _emberMetal.get(this, 'router'); + if (factory === undefined) { + return; + } - this.setupRouter(); - return router.handleURL(url); - }, + var manager = new FactoryManager(this, factory, fullName, normalizedName); - /** - @private - */ - setupEventDispatcher: function () { - var dispatcher = this.lookup('event_dispatcher:main'); - var applicationCustomEvents = _emberMetal.get(this.application, 'customEvents'); - var instanceCustomEvents = _emberMetal.get(this, 'customEvents'); + return manager; + }; + } - var customEvents = _emberUtils.assign({}, applicationCustomEvents, instanceCustomEvents); - dispatcher.setup(customEvents, this.rootElement); + function isSingleton(container, fullName) { + return container.registry.getOption(fullName, 'singleton') !== false; + } - return dispatcher; - }, + function shouldInstantiate(container, fullName) { + return container.registry.getOption(fullName, 'instantiate') !== false; + } - /** - Returns the current URL of the app instance. This is useful when your - app does not update the browsers URL bar (i.e. it uses the `'none'` - location adapter). - @public - @return {String} the current URL - */ - getURL: function () { - var router = _emberMetal.get(this, 'router'); - return _emberMetal.get(router, 'url'); - }, + function lookup(container, fullName) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - // `instance.visit(url)` should eventually replace `instance.handleURL()`; - // the test helpers can probably be switched to use this implementation too + if (options.source) { + fullName = container.registry.expandLocalLookup(fullName, options); - /** - Navigate the instance to a particular URL. This is useful in tests, for - example, or to tell the app to start at a particular URL. This method - returns a promise that resolves with the app instance when the transition - is complete, or rejects if the transion was aborted due to an error. - @public - @param url {String} the destination URL - @return {Promise} - */ - visit: function (url) { - var _this = this; + // if expandLocalLookup returns falsey, we do not support local lookup + if (!fullName) { + return; + } + } - this.setupRouter(); + if (container.cache[fullName] !== undefined && options.singleton !== false) { + return container.cache[fullName]; + } - var bootOptions = this.__container__.lookup('-environment:main'); + if (true) { + return instantiateFactory(container, fullName, options); + } else { + var factory = deprecatedFactoryFor(container, fullName); + var value = instantiate(factory, {}, container, fullName); - var router = _emberMetal.get(this, 'router'); + if (value === undefined) { + return; + } - var handleTransitionResolve = function () { - if (!bootOptions.options.shouldRender) { - // No rendering is needed, and routing has completed, simply return. - return _this; - } else { - return new _emberRuntime.RSVP.Promise(function (resolve) { - // Resolve once rendering is completed. `router.handleURL` returns the transition (as a thennable) - // which resolves once the transition is completed, but the transition completion only queues up - // a scheduled revalidation (into the `render` queue) in the Renderer. - // - // This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed. - _emberMetal.run.schedule('afterRender', null, resolve, _this); - }); - } - }; + if (isSingleton(container, fullName) && options.singleton !== false) { + container.cache[fullName] = value; + } - var handleTransitionReject = function (error) { - if (error.error) { - throw error.error; - } else if (error.name === 'TransitionAborted' && router.router.activeTransition) { - return router.router.activeTransition.then(handleTransitionResolve, handleTransitionReject); - } else if (error.name === 'TransitionAborted') { - throw new Error(error.message); - } else { - throw error; - } - }; + return value; + } + } - var location = _emberMetal.get(router, 'location'); + function isSingletonClass(container, fullName, _ref2) { + var instantiate = _ref2.instantiate; + var singleton = _ref2.singleton; - // Keeps the location adapter's internal URL in-sync - location.setURL(url); + return singleton !== false && isSingleton(container, fullName) && !instantiate && !shouldInstantiate(container, fullName); + } - // getURL returns the set url with the rootURL stripped off - return router.handleURL(location.getURL()).then(handleTransitionResolve, handleTransitionReject); - } - }); + function isSingletonInstance(container, fullName, _ref3) { + var instantiate = _ref3.instantiate; + var singleton = _ref3.singleton; - ApplicationInstance.reopenClass({ - /** - @private - @method setupRegistry - @param {Registry} registry - @param {BootOptions} options - */ - setupRegistry: function (registry) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + return singleton !== false && isSingleton(container, fullName) && instantiate !== false && shouldInstantiate(container, fullName); + } - if (!options.toEnvironment) { - options = new BootOptions(options); - } + function isFactoryClass(container, fullname, _ref4) { + var instantiate = _ref4.instantiate; + var singleton = _ref4.singleton; - registry.register('-environment:main', options.toEnvironment(), { instantiate: false }); - registry.register('service:-document', options.document, { instantiate: false }); + return (singleton === false || !isSingleton(container, fullname)) && instantiate === false && !shouldInstantiate(container, fullname); + } - this._super(registry, options); - } - }); + function isFactoryInstance(container, fullName, _ref5) { + var instantiate = _ref5.instantiate; + var singleton = _ref5.singleton; - /** - A list of boot-time configuration options for customizing the behavior of - an `Ember.ApplicationInstance`. - - This is an interface class that exists purely to document the available - options; you do not need to construct it manually. Simply pass a regular - JavaScript object containing the desired options into methods that require - one of these options object: - - ```javascript - MyApp.visit("/", { location: "none", rootElement: "#container" }); - ``` - - Not all combinations of the supported options are valid. See the documentation - on `Ember.Application#visit` for the supported configurations. - - Internal, experimental or otherwise unstable flags are marked as private. - - @class BootOptions - @namespace Ember.ApplicationInstance - @public - */ - BootOptions = function BootOptions() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + return (singleton !== false || isSingleton(container, fullName)) && instantiate !== false && shouldInstantiate(container, fullName); + } - /** - Provide a specific instance of jQuery. This is useful in conjunction with - the `document` option, as it allows you to use a copy of `jQuery` that is - appropriately bound to the foreign `document` (e.g. a jsdom). - This is highly experimental and support very incomplete at the moment. - @property jQuery - @type Object - @default auto-detected - @private - */ - this.jQuery = _emberViews.jQuery; // This default is overridable below + function instantiateFactory(container, fullName, options) { + var factoryManager = container[FACTORY_FOR](fullName); - /** - Interactive mode: whether we need to set up event delegation and invoke - lifecycle callbacks on Components. - @property isInteractive - @type boolean - @default auto-detected - @private - */ - this.isInteractive = _emberEnvironment.environment.hasDOM; // This default is overridable below + if (factoryManager === undefined) { + return; + } - /** - Run in a full browser environment. - When this flag is set to `false`, it will disable most browser-specific - and interactive features. Specifically: - * It does not use `jQuery` to append the root view; the `rootElement` - (either specified as a subsequent option or on the application itself) - must already be an `Element` in the given `document` (as opposed to a - string selector). - * It does not set up an `EventDispatcher`. - * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). - * It sets the `location` option to `"none"`. (If you would like to use - the location adapter specified in the app's router instead, you can also - specify `{ location: null }` to specifically opt-out.) - @property isBrowser - @type boolean - @default auto-detected - @public - */ - if (options.isBrowser !== undefined) { - this.isBrowser = !!options.isBrowser; - } else { - this.isBrowser = _emberEnvironment.environment.hasDOM; + // SomeClass { singleton: true, instantiate: true } | { singleton: true } | { instantiate: true } | {} + // By default majority of objects fall into this case + if (isSingletonInstance(container, fullName, options)) { + return container.cache[fullName] = factoryManager.create(); } - if (!this.isBrowser) { - this.jQuery = null; - this.isInteractive = false; - this.location = 'none'; + // SomeClass { singleton: false, instantiate: true } + if (isFactoryInstance(container, fullName, options)) { + return factoryManager.create(); } - /** - Disable rendering completely. - When this flag is set to `true`, it will disable the entire rendering - pipeline. Essentially, this puts the app into "routing-only" mode. No - templates will be rendered, and no Components will be created. - @property shouldRender - @type boolean - @default true - @public - */ - if (options.shouldRender !== undefined) { - this.shouldRender = !!options.shouldRender; - } else { - this.shouldRender = true; + // SomeClass { singleton: true, instantiate: false } | { instantiate: false } | { singleton: false, instantiation: false } + if (isSingletonClass(container, fullName, options) || isFactoryClass(container, fullName, options)) { + return factoryManager.class; } - if (!this.shouldRender) { - this.jQuery = null; - this.isInteractive = false; + throw new Error('Could not create factory'); + } + + function markInjectionsAsDynamic(injections) { + injections._dynamic = true; + } + + function areInjectionsDynamic(injections) { + return !!injections._dynamic; + } + + function buildInjections() /* container, ...injections */{ + var hash = {}; + + if (arguments.length > 1) { + var container = arguments[0]; + var injections = []; + var injection = undefined; + + for (var i = 1; i < arguments.length; i++) { + if (arguments[i]) { + injections = injections.concat(arguments[i]); + } + } + + for (var i = 0; i < injections.length; i++) { + injection = injections[i]; + hash[injection.property] = lookup(container, injection.fullName); + if (!isSingleton(container, injection.fullName)) { + markInjectionsAsDynamic(hash); + } + } } - /** - If present, render into the given `Document` object instead of the - global `window.document` object. - In practice, this is only useful in non-browser environment or in - non-interactive mode, because Ember's `jQuery` dependency is - implicitly bound to the current document, causing event delegation - to not work properly when the app is rendered into a foreign - document object (such as an iframe's `contentDocument`). - In non-browser mode, this could be a "`Document`-like" object as - Ember only interact with a small subset of the DOM API in non- - interactive mode. While the exact requirements have not yet been - formalized, the `SimpleDOM` library's implementation is known to - work. - @property document - @type Document - @default the global `document` object - @public - */ - if (options.document) { - this.document = options.document; - } else { - this.document = typeof document !== 'undefined' ? document : null; + return hash; + } + + function deprecatedFactoryFor(container, fullName) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + + var registry = container.registry; + + if (options.source) { + fullName = registry.expandLocalLookup(fullName, options); + // if expandLocalLookup returns falsey, we do not support local lookup + if (!fullName) { + return; + } } - /** - If present, overrides the application's `rootElement` property on - the instance. This is useful for testing environment, where you - might want to append the root view to a fixture area. - In non-browser mode, because Ember does not have access to jQuery, - this options must be specified as a DOM `Element` object instead of - a selector string. - See the documentation on `Ember.Applications`'s `rootElement` for - details. - @property rootElement - @type String|Element - @default null - @public - */ - if (options.rootElement) { - this.rootElement = options.rootElement; + var cache = container.factoryCache; + if (cache[fullName]) { + return cache[fullName]; + } + var factory = registry.resolve(fullName); + if (factory === undefined) { + return; } - // Set these options last to give the user a chance to override the - // defaults from the "combo" options like `isBrowser` (although in - // practice, the resulting combination is probably invalid) + var type = fullName.split(':')[0]; + if (!factory || typeof factory.extend !== 'function' || !_emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS && type === 'model') { + if (factory && typeof factory._onLookup === 'function') { + factory._onLookup(fullName); + } - /** - If present, overrides the router's `location` property with this - value. This is useful for environments where trying to modify the - URL would be inappropriate. - @property location - @type string - @default null - @public - */ - if (options.location !== undefined) { - this.location = options.location; - } + // TODO: think about a 'safe' merge style extension + // for now just fallback to create time injection + cache[fullName] = factory; + return factory; + } else { + var injections = injectionsFor(container, fullName); + var factoryInjections = factoryInjectionsFor(container, fullName); + var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); - if (options.jQuery !== undefined) { - this.jQuery = options.jQuery; + factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); + + var injectedFactory = factory.extend(injections); + + // TODO - remove all `container` injections when Ember reaches v3.0.0 + injectDeprecatedContainer(injectedFactory.prototype, container); + injectedFactory.reopenClass(factoryInjections); + + if (factory && typeof factory._onLookup === 'function') { + factory._onLookup(fullName); + } + + if (cacheable) { + cache[fullName] = injectedFactory; + } + + return injectedFactory; } + } - if (options.isInteractive !== undefined) { - this.isInteractive = !!options.isInteractive; + function injectionsFor(container, fullName) { + var registry = container.registry; + var splitName = fullName.split(':'); + var type = splitName[0]; + + var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); + injections._debugContainerKey = fullName; + + _emberUtils.setOwner(injections, container.owner); + + return injections; + } + + function instantiate(factory, props, container, fullName) { + var lazyInjections = undefined, + validationCache = undefined; + + props = props || {}; + + if (container.registry.getOption(fullName, 'instantiate') === false) { + return factory; } - }; - BootOptions.prototype.toEnvironment = function () { - var env = _emberUtils.assign({}, _emberEnvironment.environment); - // For compatibility with existing code - env.hasDOM = this.isBrowser; - env.isInteractive = this.isInteractive; - env.options = this; - return env; - }; + if (factory) { + if (typeof factory.create !== 'function') { + throw new Error('Failed to create an instance of \'' + fullName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); + } - Object.defineProperty(ApplicationInstance.prototype, 'container', { - configurable: true, - enumerable: false, - get: function () { - var instance = this; - return { - lookup: function () { - return instance.lookup.apply(instance, arguments); + validationCache = container.validationCache; + + validationCache[fullName] = true; + + var obj = undefined; + + if (typeof factory.extend === 'function') { + // assume the factory was extendable and is already injected + obj = factory.create(props); + } else { + // assume the factory was extendable + // to create time injections + // TODO: support new'ing for instantiation and merge injections for pure JS Functions + var injections = injectionsFor(container, fullName); + + // Ensure that a container is available to an object during instantiation. + // TODO - remove when Ember reaches v3.0.0 + // This "fake" container will be replaced after instantiation with a + // property that raises deprecations every time it is accessed. + injections.container = container._fakeContainerToInject; + obj = factory.create(_emberUtils.assign({}, injections, props)); + + // TODO - remove when Ember reaches v3.0.0 + if (!Object.isFrozen(obj) && 'container' in obj) { + injectDeprecatedContainer(obj, container); } - }; - } - }); + } - Object.defineProperty(ApplicationInstance.prototype, 'registry', { - configurable: true, - enumerable: false, - get: function () { - return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'ApplicationInstance'); + return obj; } - }); + } - exports.default = ApplicationInstance; -}); -enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application/system/application-instance', 'container', 'ember-application/system/engine', 'ember-glimmer'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRuntime, _emberViews, _emberRouting, _emberApplicationSystemApplicationInstance, _container, _emberApplicationSystemEngine, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + function factoryInjectionsFor(container, fullName) { + var registry = container.registry; + var splitName = fullName.split(':'); + var type = splitName[0]; - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); + factoryInjections._debugContainerKey = fullName; - var librariesRegistered = false; + return factoryInjections; + } - /** - An instance of `Ember.Application` is the starting point for every Ember - application. It helps to instantiate, initialize and coordinate the many - objects that make up your app. - - Each Ember app has one and only one `Ember.Application` object. In fact, the - very first thing you should do in your application is create the instance: - - ```javascript - window.App = Ember.Application.create(); - ``` - - Typically, the application object is the only global variable. All other - classes in your app should be properties on the `Ember.Application` instance, - which highlights its first role: a global namespace. - - For example, if you define a view class, it might look like this: - - ```javascript - App.MyView = Ember.View.extend(); - ``` - - By default, calling `Ember.Application.create()` will automatically initialize - your application by calling the `Ember.Application.initialize()` method. If - you need to delay initialization, you can call your app's `deferReadiness()` - method. When you are ready for your app to be initialized, call its - `advanceReadiness()` method. - - You can define a `ready` method on the `Ember.Application` instance, which - will be run by Ember when the application is initialized. - - Because `Ember.Application` inherits from `Ember.Namespace`, any classes - you create will have useful string representations when calling `toString()`. - See the `Ember.Namespace` documentation for more information. - - While you can think of your `Ember.Application` as a container that holds the - other classes in your application, there are several other responsibilities - going on under-the-hood that you may want to understand. - - ### Event Delegation - - Ember uses a technique called _event delegation_. This allows the framework - to set up a global, shared event listener instead of requiring each view to - do it manually. For example, instead of each view registering its own - `mousedown` listener on its associated element, Ember sets up a `mousedown` - listener on the `body`. - - If a `mousedown` event occurs, Ember will look at the target of the event and - start walking up the DOM node tree, finding corresponding views and invoking - their `mouseDown` method as it goes. - - `Ember.Application` has a number of default events that it listens for, as - well as a mapping from lowercase events to camel-cased view method names. For - example, the `keypress` event causes the `keyPress` method on the view to be - called, the `dblclick` event causes `doubleClick` to be called, and so on. - - If there is a bubbling browser event that Ember does not listen for by - default, you can specify custom events and their corresponding view method - names by setting the application's `customEvents` property: - - ```javascript - let App = Ember.Application.create({ - customEvents: { - // add support for the paste event - paste: 'paste' - } - }); - ``` - - To prevent Ember from setting up a listener for a default event, - specify the event name with a `null` value in the `customEvents` - property: - - ```javascript - let App = Ember.Application.create({ - customEvents: { - // prevent listeners for mouseenter/mouseleave events - mouseenter: null, - mouseleave: null - } - }); - ``` - - By default, the application sets up these event listeners on the document - body. However, in cases where you are embedding an Ember application inside - an existing page, you may want it to set up the listeners on an element - inside the body. - - For example, if only events inside a DOM element with the ID of `ember-app` - should be delegated, set your application's `rootElement` property: - - ```javascript - let App = Ember.Application.create({ - rootElement: '#ember-app' - }); - ``` - - The `rootElement` can be either a DOM element or a jQuery-compatible selector - string. Note that *views appended to the DOM outside the root element will - not receive events.* If you specify a custom root element, make sure you only - append views inside it! - - To learn more about the events Ember components use, see - [components/handling-events](https://guides.emberjs.com/v2.6.0/components/handling-events/#toc_event-names). - - ### Initializers - - Libraries on top of Ember can add initializers, like so: - - ```javascript - Ember.Application.initializer({ - name: 'api-adapter', - - initialize: function(application) { - application.register('api-adapter:main', ApiAdapter); - } - }); - ``` - - Initializers provide an opportunity to access the internal registry, which - organizes the different components of an Ember application. Additionally - they provide a chance to access the instantiated application. Beyond - being used for libraries, initializers are also a great way to organize - dependency injection or setup in your own application. - - ### Routing - - In addition to creating your application's router, `Ember.Application` is - also responsible for telling the router when to start routing. Transitions - between routes can be logged with the `LOG_TRANSITIONS` flag, and more - detailed intra-transition logging can be logged with - the `LOG_TRANSITIONS_INTERNAL` flag: - - ```javascript - let App = Ember.Application.create({ - LOG_TRANSITIONS: true, // basic logging of successful transitions - LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps - }); - ``` - - By default, the router will begin trying to translate the current URL into - application state once the browser emits the `DOMContentReady` event. If you - need to defer routing, you can call the application's `deferReadiness()` - method. Once routing can begin, call the `advanceReadiness()` method. - - If there is any setup required before routing begins, you can implement a - `ready()` method on your app that will be invoked immediately before routing - begins. - - @class Application - @namespace Ember - @extends Ember.Engine - @uses RegistryProxyMixin - @public - */ - - var Application = _emberApplicationSystemEngine.default.extend({ - _suppressDeferredDeprecation: true, + // TODO - remove when Ember reaches v3.0.0 + function injectDeprecatedContainer(object, container) { + Object.defineProperty(object, 'container', { + configurable: true, + enumerable: false, + get: function () { + return this[CONTAINER_OVERRIDE] || container; + }, - /** - The root DOM element of the Application. This can be specified as an - element or a - [jQuery-compatible selector string](http://api.jquery.com/category/selectors/). - This is the element that will be passed to the Application's, - `eventDispatcher`, which sets up the listeners for event delegation. Every - view in your application should be a child of the element you specify here. - @property rootElement - @type DOMElement - @default 'body' - @public - */ - rootElement: 'body', + set: function (value) { - /** - The `Ember.EventDispatcher` responsible for delegating events to this - application's views. - The event dispatcher is created by the application at initialization time - and sets up event listeners on the DOM element described by the - application's `rootElement` property. - See the documentation for `Ember.EventDispatcher` for more information. - @property eventDispatcher - @type Ember.EventDispatcher - @default null - @public - */ - eventDispatcher: null, + this[CONTAINER_OVERRIDE] = value; - /** - The DOM events for which the event dispatcher should listen. - By default, the application's `Ember.EventDispatcher` listens - for a set of standard DOM events, such as `mousedown` and - `keyup`, and delegates them to your application's `Ember.View` - instances. - If you would like additional bubbling events to be delegated to your - views, set your `Ember.Application`'s `customEvents` property - to a hash containing the DOM event name as the key and the - corresponding view method name as the value. Setting an event to - a value of `null` will prevent a default event listener from being - added for that event. - To add new events to be listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - // add support for the paste event - paste: 'paste' - } - }); - ``` - To prevent default events from being listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - // remove support for mouseenter / mouseleave events - mouseenter: null, - mouseleave: null - } - }); - ``` - @property customEvents - @type Object - @default null - @public - */ - customEvents: null, + return value; + } + }); + } - /** - Whether the application should automatically start routing and render - templates to the `rootElement` on DOM ready. While default by true, - other environments such as FastBoot or a testing harness can set this - property to `false` and control the precise timing and behavior of the boot - process. - @property autoboot - @type Boolean - @default true - @private - */ - autoboot: true, + function eachDestroyable(container, callback) { + var cache = container.cache; + var keys = Object.keys(cache); - /** - Whether the application should be configured for the legacy "globals mode". - Under this mode, the Application object serves as a global namespace for all - classes. - ```javascript - let App = Ember.Application.create({ - ... - }); - App.Router.reopen({ - location: 'none' - }); - App.Router.map({ - ... - }); - App.MyComponent = Ember.Component.extend({ - ... - }); - ``` - This flag also exposes other internal APIs that assumes the existence of - a special "default instance", like `App.__container__.lookup(...)`. - This option is currently not configurable, its value is derived from - the `autoboot` flag – disabling `autoboot` also implies opting-out of - globals mode support, although they are ultimately orthogonal concerns. - Some of the global modes features are already deprecated in 1.x. The - existence of this flag is to untangle the globals mode code paths from - the autoboot code paths, so that these legacy features can be reviewed - for deprecation/removal separately. - Forcing the (autoboot=true, _globalsMode=false) here and running the tests - would reveal all the places where we are still relying on these legacy - behavior internally (mostly just tests). - @property _globalsMode - @type Boolean - @default true - @private - */ - _globalsMode: true, + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = cache[key]; - init: function (options) { - this._super.apply(this, arguments); + if (container.registry.getOption(key, 'instantiate') !== false) { + callback(value); + } + } + } - if (!this.$) { - this.$ = _emberViews.jQuery; + function resetCache(container) { + eachDestroyable(container, function (value) { + if (value.destroy) { + value.destroy(); } + }); - registerLibraries(); - logLibraryVersions(); + container.cache.dict = _emberUtils.dictionary(null); + } - // Start off the number of deferrals at 1. This will be decremented by - // the Application's own `boot` method. - this._readinessDeferrals = 1; - this._booted = false; + function resetMember(container, fullName) { + var member = container.cache[fullName]; - this.autoboot = this._globalsMode = !!this.autoboot; + delete container.factoryCache[fullName]; - if (this._globalsMode) { - this._prepareForGlobalsMode(); - } + if (member) { + delete container.cache[fullName]; - if (this.autoboot) { - this.waitForDOMReady(); + if (member.destroy) { + member.destroy(); } - }, + } + } - /** - Create an ApplicationInstance for this application. - @private - @method buildInstance - @return {Ember.ApplicationInstance} the application instance - */ - buildInstance: function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + function buildFakeContainerWithDeprecations(container) { + var fakeContainer = {}; + var propertyMappings = { + lookup: 'lookup', + lookupFactory: '_lookupFactory' + }; - options.base = this; - options.application = this; - return _emberApplicationSystemApplicationInstance.default.create(options); - }, + for (var containerProperty in propertyMappings) { + fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]); + } - /** - Enable the legacy globals mode by allowing this application to act - as a global namespace. See the docs on the `_globalsMode` property - for details. - Most of these features are already deprecated in 1.x, so we can - stop using them internally and try to remove them. - @private - @method _prepareForGlobalsMode - */ - _prepareForGlobalsMode: function () { - // Create subclass of Ember.Router for this Application instance. - // This is to ensure that someone reopening `App.Router` does not - // tamper with the default `Ember.Router`. - this.Router = (this.Router || _emberRouting.Router).extend(); + return fakeContainer; + } - this._buildDeprecatedInstance(); - }, + function buildFakeContainerFunction(container, containerProperty, ownerProperty) { + return function () { + return container[containerProperty].apply(container, arguments); + }; + } - /* - Build the deprecated instance for legacy globals mode support. - Called when creating and resetting the application. - This is orthogonal to autoboot: the deprecated instance needs to - be created at Application construction (not boot) time to expose - App.__container__. If autoboot sees that this instance exists, - it will continue booting it to avoid doing unncessary work (as - opposed to building a new instance at boot time), but they are - otherwise unrelated. - @private - @method _buildDeprecatedInstance - */ - _buildDeprecatedInstance: function () { - // Build a default instance - var instance = this.buildInstance(); + var DeprecatedFactoryManager = (function () { + function DeprecatedFactoryManager(container, factory, fullName) { + this.container = container; + this.class = factory; + this.fullName = fullName; + } - // Legacy support for App.__container__ and other global methods - // on App that rely on a single, default instance. - this.__deprecatedInstance__ = instance; - this.__container__ = instance.__container__; - }, + DeprecatedFactoryManager.prototype.create = function create() { + var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - /** - Automatically kick-off the boot process for the application once the - DOM has become ready. - The initialization itself is scheduled on the actions queue which - ensures that code-loading finishes before booting. - If you are asynchronously loading code, you should call `deferReadiness()` - to defer booting, and then call `advanceReadiness()` once all of your code - has finished loading. - @private - @method waitForDOMReady - */ - waitForDOMReady: function () { - if (!this.$ || this.$.isReady) { - _emberMetal.run.schedule('actions', this, 'domReady'); - } else { - this.$().ready(_emberMetal.run.bind(this, 'domReady')); - } - }, + return instantiate(this.class, props, this.container, this.fullName); + }; - /** - This is the autoboot flow: - 1. Boot the app by calling `this.boot()` - 2. Create an instance (or use the `__deprecatedInstance__` in globals mode) - 3. Boot the instance by calling `instance.boot()` - 4. Invoke the `App.ready()` callback - 5. Kick-off routing on the instance - Ideally, this is all we would need to do: - ```javascript - _autoBoot() { - this.boot().then(() => { - let instance = (this._globalsMode) ? this.__deprecatedInstance__ : this.buildInstance(); - return instance.boot(); - }).then((instance) => { - App.ready(); - instance.startRouting(); - }); - } - ``` - Unfortunately, we cannot actually write this because we need to participate - in the "synchronous" boot process. While the code above would work fine on - the initial boot (i.e. DOM ready), when `App.reset()` is called, we need to - boot a new instance synchronously (see the documentation on `_bootSync()` - for details). - Because of this restriction, the actual logic of this method is located - inside `didBecomeReady()`. - @private - @method domReady - */ - domReady: function () { - if (this.isDestroyed) { - return; - } + return DeprecatedFactoryManager; + })(); - this._bootSync(); + var FactoryManager = (function () { + function FactoryManager(container, factory, fullName, normalizedName) { + this.container = container; + this.class = factory; + this.fullName = fullName; + this.normalizedName = normalizedName; + } - // Continues to `didBecomeReady` - }, + FactoryManager.prototype.create = function create() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - /** - Use this to defer readiness until some condition is true. - Example: - ```javascript - let App = Ember.Application.create(); - App.deferReadiness(); - // Ember.$ is a reference to the jQuery object/function - Ember.$.getJSON('/auth-token', function(token) { - App.token = token; - App.advanceReadiness(); - }); - ``` - This allows you to perform asynchronous setup logic and defer - booting your application until the setup has finished. - However, if the setup requires a loading UI, it might be better - to use the router for this purpose. - @method deferReadiness - @public - */ - deferReadiness: function () { - this._readinessDeferrals++; - }, + var injections = injectionsFor(this.container, this.normalizedName); + var props = _emberUtils.assign({}, injections, options); - /** - Call `advanceReadiness` after any asynchronous setup logic has completed. - Each call to `deferReadiness` must be matched by a call to `advanceReadiness` - or the application will never become ready and routing will not begin. - @method advanceReadiness - @see {Ember.Application#deferReadiness} - @public - */ - advanceReadiness: function () { - this._readinessDeferrals--; + props[_emberUtils.NAME_KEY] = this.container.registry.makeToString(this.class, this.fullName); - if (this._readinessDeferrals === 0) { - _emberMetal.run.once(this, this.didBecomeReady); + if (!this.class.create) { + throw new Error('Failed to create an instance of \'' + this.normalizedName + '\'. Most likely an improperly defined class or' + ' an invalid module export.'); } - }, - /** - Initialize the application and return a promise that resolves with the `Ember.Application` - object when the boot process is complete. - Run any application initializers and run the application load hook. These hooks may - choose to defer readiness. For example, an authentication hook might want to defer - readiness until the auth token has been retrieved. - By default, this method is called automatically on "DOM ready"; however, if autoboot - is disabled, this is automatically called when the first application instance is - created via `visit`. - @private - @method boot - @return {Promise} - */ - boot: function () { - if (this._bootPromise) { - return this._bootPromise; + if (this.class.prototype) { + injectDeprecatedContainer(this.class.prototype, this.container); } - try { - this._bootSync(); - } catch (_) { - // Ignore th error: in the asynchronous boot path, the error is already reflected - // in the promise rejection - } + return this.class.create(props); + }; - return this._bootPromise; - }, + return FactoryManager; + })(); +}); - /** - Unfortunately, a lot of existing code assumes the booting process is - "synchronous". Specifically, a lot of tests assumes the last call to - `app.advanceReadiness()` or `app.reset()` will result in the app being - fully-booted when the current runloop completes. - We would like new code (like the `visit` API) to stop making this assumption, - so we created the asynchronous version above that returns a promise. But until - we have migrated all the code, we would have to expose this method for use - *internally* in places where we need to boot an app "synchronously". - @private - */ - _bootSync: function () { - if (this._booted) { - return; - } +/* + * This internal version of factoryFor swaps between the public API for + * factoryFor (class is the registered class) and a transition implementation + * (class is the double-extended class). It is *not* the public API version + * of factoryFor, which always returns the registered class. + */ - // Even though this returns synchronously, we still need to make sure the - // boot promise exists for book-keeping purposes: if anything went wrong in - // the boot process, we need to store the error as a rejection on the boot - // promise so that a future caller of `boot()` can tell what failed. - var defer = this._bootResolver = new _emberRuntime.RSVP.defer(); - this._bootPromise = defer.promise; +/** + A depth first traversal, destroying the container, its descendant containers and all + their managed objects. + @private + @method destroy + */ - try { - this.runInitializers(); - _emberRuntime.runLoadHooks('application', this); - this.advanceReadiness(); - // Continues to `didBecomeReady` - } catch (error) { - // For the asynchronous boot path - defer.reject(error); +/** + Clear either the entire cache or just the cache for a particular key. + @private + @method reset + @param {String} fullName optional key to reset; if missing, resets everything + */ - // For the synchronous boot path - throw error; - } - }, +/** + Returns an object that can be used to provide an owner to a + manually created instance. + @private + @method ownerInjection + @returns { Object } +*/ - /** - Reset the application. This is typically used only in tests. It cleans up - the application in the following order: - 1. Deactivate existing routes - 2. Destroy all objects in the container - 3. Create a new application container - 4. Re-route to the existing url - Typical Example: - ```javascript - let App; - run(function() { - App = Ember.Application.create(); - }); - module('acceptance test', { - setup: function() { - App.reset(); - } - }); - test('first test', function() { - // App is freshly reset - }); - test('second test', function() { - // App is again freshly reset - }); - ``` - Advanced Example: - Occasionally you may want to prevent the app from initializing during - setup. This could enable extra configuration, or enable asserting prior - to the app becoming ready. - ```javascript - let App; - run(function() { - App = Ember.Application.create(); - }); - module('acceptance test', { - setup: function() { - run(function() { - App.reset(); - App.deferReadiness(); - }); - } - }); - test('first test', function() { - ok(true, 'something before app is initialized'); - run(function() { - App.advanceReadiness(); - }); - ok(true, 'something after app is initialized'); - }); - ``` - @method reset - @public - */ - reset: function () { +// Ensure that all lazy injections are valid at instantiation time - var instance = this.__deprecatedInstance__; +// Ensure that all lazy injections are valid at instantiation time +enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) { + /* + Public API for the container is still in flux. + The public API, specified on the application namespace should be considered the stable API. + // @module container + @private + */ - this._readinessDeferrals = 1; - this._bootPromise = null; - this._bootResolver = null; - this._booted = false; + 'use strict'; - function handleReset() { - _emberMetal.run(instance, 'destroy'); - this._buildDeprecatedInstance(); - _emberMetal.run.schedule('actions', this, '_bootSync'); - } + exports.Registry = _containerRegistry.default; + exports.privatize = _containerRegistry.privatize; + exports.Container = _containerContainer.default; + exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations; + exports.FACTORY_FOR = _containerContainer.FACTORY_FOR; + exports.LOOKUP_FACTORY = _containerContainer.LOOKUP_FACTORY; +}); +enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) { + 'use strict'; - _emberMetal.run.join(this, handleReset); - }, + exports.default = Registry; + exports.privatize = privatize; - /** - @private - @method didBecomeReady - */ - didBecomeReady: function () { - try { - // TODO: Is this still needed for _globalsMode = false? - if (!_emberMetal.isTesting()) { - // Eagerly name all classes that are already loaded - _emberRuntime.Namespace.processAll(); - _emberRuntime.setNamespaceSearchDisabled(true); - } + var VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/; - // See documentation on `_autoboot()` for details - if (this.autoboot) { - var instance = undefined; + /** + A registry used to store factory and option information keyed + by type. + + A `Registry` stores the factory and option information needed by a + `Container` to instantiate and cache objects. + + The API for `Registry` is still in flux and should not be considered stable. + + @private + @class Registry + @since 1.11.0 + */ - if (this._globalsMode) { - // If we already have the __deprecatedInstance__ lying around, boot it to - // avoid unnecessary work - instance = this.__deprecatedInstance__; - } else { - // Otherwise, build an instance and boot it. This is currently unreachable, - // because we forced _globalsMode to === autoboot; but having this branch - // allows us to locally toggle that flag for weeding out legacy globals mode - // dependencies independently - instance = this.buildInstance(); - } + function Registry(options) { + this.fallback = options && options.fallback ? options.fallback : null; - instance._bootSync(); + if (options && options.resolver) { + this.resolver = options.resolver; - // TODO: App.ready() is not called when autoboot is disabled, is this correct? - this.ready(); + if (typeof this.resolver === 'function') { + deprecateResolverFunction(this); + } + } - instance.startRouting(); - } + this.registrations = _emberUtils.dictionary(options && options.registrations ? options.registrations : null); - // For the asynchronous boot path - this._bootResolver.resolve(this); + this._typeInjections = _emberUtils.dictionary(null); + this._injections = _emberUtils.dictionary(null); + this._factoryTypeInjections = _emberUtils.dictionary(null); + this._factoryInjections = _emberUtils.dictionary(null); - // For the synchronous boot path - this._booted = true; - } catch (error) { - // For the asynchronous boot path - this._bootResolver.reject(error); + this._localLookupCache = new _emberUtils.EmptyObject(); + this._normalizeCache = _emberUtils.dictionary(null); + this._resolveCache = _emberUtils.dictionary(null); + this._failCache = _emberUtils.dictionary(null); - // For the synchronous boot path - throw error; - } - }, + this._options = _emberUtils.dictionary(null); + this._typeOptions = _emberUtils.dictionary(null); + } + Registry.prototype = { /** - Called when the Application has become ready, immediately before routing - begins. The call will be delayed until the DOM has become ready. - @event ready - @public - */ - ready: function () { - return this; - }, - - // This method must be moved to the application instance object - willDestroy: function () { - this._super.apply(this, arguments); - _emberRuntime.setNamespaceSearchDisabled(false); - this._booted = false; - this._bootPromise = null; - this._bootResolver = null; - - if (_emberRuntime._loaded.application === this) { - _emberRuntime._loaded.application = undefined; - } + A backup registry for resolving registrations when no matches can be found. + @private + @property fallback + @type Registry + */ + fallback: null, - if (this._globalsMode && this.__deprecatedInstance__) { - this.__deprecatedInstance__.destroy(); - } - }, + /** + An object that has a `resolve` method that resolves a name. + @private + @property resolver + @type Resolver + */ + resolver: null, /** - Boot a new instance of `Ember.ApplicationInstance` for the current - application and navigate it to the given `url`. Returns a `Promise` that - resolves with the instance when the initial routing and rendering is - complete, or rejects with any error that occured during the boot process. - When `autoboot` is disabled, calling `visit` would first cause the - application to boot, which runs the application initializers. - This method also takes a hash of boot-time configuration options for - customizing the instance's behavior. See the documentation on - `Ember.ApplicationInstance.BootOptions` for details. - `Ember.ApplicationInstance.BootOptions` is an interface class that exists - purely to document the available options; you do not need to construct it - manually. Simply pass a regular JavaScript object containing of the - desired options: - ```javascript - MyApp.visit("/", { location: "none", rootElement: "#container" }); - ``` - ### Supported Scenarios - While the `BootOptions` class exposes a large number of knobs, not all - combinations of them are valid; certain incompatible combinations might - result in unexpected behavior. - For example, booting the instance in the full browser environment - while specifying a foriegn `document` object (e.g. `{ isBrowser: true, - document: iframe.contentDocument }`) does not work correctly today, - largely due to Ember's jQuery dependency. - Currently, there are three officially supported scenarios/configurations. - Usages outside of these scenarios are not guaranteed to work, but please - feel free to file bug reports documenting your experience and any issues - you encountered to help expand support. - #### Browser Applications (Manual Boot) - The setup is largely similar to how Ember works out-of-the-box. Normally, - Ember will boot a default instance for your Application on "DOM ready". - However, you can customize this behavior by disabling `autoboot`. - For example, this allows you to render a miniture demo of your application - into a specific area on your marketing website: - ```javascript - import MyApp from 'my-app'; - $(function() { - let App = MyApp.create({ autoboot: false }); - let options = { - // Override the router's location adapter to prevent it from updating - // the URL in the address bar - location: 'none', - // Override the default `rootElement` on the app to render into a - // specific `div` on the page - rootElement: '#demo' - }; - // Start the app at the special demo URL - App.visit('/demo', options); - }); - ```` - Or perhaps you might want to boot two instances of your app on the same - page for a split-screen multiplayer experience: - ```javascript - import MyApp from 'my-app'; - $(function() { - let App = MyApp.create({ autoboot: false }); - let sessionId = MyApp.generateSessionID(); - let player1 = App.visit(`/matches/join?name=Player+1&session=${sessionId}`, { rootElement: '#left', location: 'none' }); - let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#right', location: 'none' }); - Promise.all([player1, player2]).then(() => { - // Both apps have completed the initial render - $('#loading').fadeOut(); - }); - }); - ``` - Do note that each app instance maintains their own registry/container, so - they will run in complete isolation by default. - #### Server-Side Rendering (also known as FastBoot) - This setup allows you to run your Ember app in a server environment using - Node.js and render its content into static HTML for SEO purposes. - ```javascript - const HTMLSerializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); - function renderURL(url) { - let dom = new SimpleDOM.Document(); - let rootElement = dom.body; - let options = { isBrowser: false, document: dom, rootElement: rootElement }; - return MyApp.visit(options).then(instance => { - try { - return HTMLSerializer.serialize(rootElement.firstChild); - } finally { - instance.destroy(); - } - }); - } - ``` - In this scenario, because Ember does not have access to a global `document` - object in the Node.js environment, you must provide one explicitly. In practice, - in the non-browser environment, the stand-in `document` object only need to - implement a limited subset of the full DOM API. The `SimpleDOM` library is known - to work. - Since there is no access to jQuery in the non-browser environment, you must also - specify a DOM `Element` object in the same `document` for the `rootElement` option - (as opposed to a selector string like `"body"`). - See the documentation on the `isBrowser`, `document` and `rootElement` properties - on `Ember.ApplicationInstance.BootOptions` for details. - #### Server-Side Resource Discovery - This setup allows you to run the routing layer of your Ember app in a server - environment using Node.js and completely disable rendering. This allows you - to simulate and discover the resources (i.e. AJAX requests) needed to fufill - a given request and eagerly "push" these resources to the client. - ```app/initializers/network-service.js - import BrowserNetworkService from 'app/services/network/browser'; - import NodeNetworkService from 'app/services/network/node'; - // Inject a (hypothetical) service for abstracting all AJAX calls and use - // the appropiate implementaion on the client/server. This also allows the - // server to log all the AJAX calls made during a particular request and use - // that for resource-discovery purpose. - export function initialize(application) { - if (window) { // browser - application.register('service:network', BrowserNetworkService); - } else { // node - application.register('service:network', NodeNetworkService); - } - application.inject('route', 'network', 'service:network'); - }; - export default { - name: 'network-service', - initialize: initialize - }; - ``` - ```app/routes/post.js - import Ember from 'ember'; - // An example of how the (hypothetical) service is used in routes. - export default Ember.Route.extend({ - model(params) { - return this.network.fetch(`/api/posts/${params.post_id}.json`); - }, - afterModel(post) { - if (post.isExternalContent) { - return this.network.fetch(`/api/external/?url=${post.externalURL}`); - } else { - return post; - } - } - }); - ``` - ```javascript - // Finally, put all the pieces together - function discoverResourcesFor(url) { - return MyApp.visit(url, { isBrowser: false, shouldRender: false }).then(instance => { - let networkService = instance.lookup('service:network'); - return networkService.requests; // => { "/api/posts/123.json": "..." } - }); - } - ``` - @public - @method visit - @param url {String} The initial URL to navigate to - @param options {Ember.ApplicationInstance.BootOptions} - @return {Promise} - */ - visit: function (url, options) { - var _this = this; + @private + @property registrations + @type InheritingDict + */ + registrations: null, - return this.boot().then(function () { - var instance = _this.buildInstance(); + /** + @private + @property _typeInjections + @type InheritingDict + */ + _typeInjections: null, - return instance.boot(options).then(function () { - return instance.visit(url); - }).catch(function (error) { - _emberMetal.run(instance, 'destroy'); - throw error; - }); - }); - } - }); + /** + @private + @property _injections + @type InheritingDict + */ + _injections: null, - Object.defineProperty(Application.prototype, 'registry', { - configurable: true, - enumerable: false, - get: function () { - return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'Application'); - } - }); + /** + @private + @property _factoryTypeInjections + @type InheritingDict + */ + _factoryTypeInjections: null, - Application.reopenClass({ /** - This creates a registry with the default Ember naming conventions. - It also configures the registry: - * registered views are created every time they are looked up (they are - not singletons) - * registered templates are not factories; the registered value is - returned directly. - * the router receives the application as its `namespace` property - * all controllers receive the router as their `target` and `controllers` - properties - * all controllers receive the application as their `namespace` property - * the application view receives the application controller as its - `controller` property - * the application view receives the application template as its - `defaultTemplate` property - @method buildRegistry - @static - @param {Ember.Application} namespace the application for which to - build the registry - @return {Ember.Registry} the built registry - @private - */ - buildRegistry: function (application) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + @private + @property _factoryInjections + @type InheritingDict + */ + _factoryInjections: null, - var registry = this._super.apply(this, arguments); + /** + @private + @property _normalizeCache + @type InheritingDict + */ + _normalizeCache: null, - commonSetupRegistry(registry); + /** + @private + @property _resolveCache + @type InheritingDict + */ + _resolveCache: null, - _emberGlimmer.setupApplicationRegistry(registry); + /** + @private + @property _options + @type InheritingDict + */ + _options: null, - return registry; - } - }); + /** + @private + @property _typeOptions + @type InheritingDict + */ + _typeOptions: null, - function commonSetupRegistry(registry) { - registry.register('-view-registry:main', { create: function () { - return _emberUtils.dictionary(null); - } }); + /** + Creates a container based on this registry. + @private + @method container + @param {Object} options + @return {Container} created container + */ + container: function (options) { + return new _containerContainer.default(this, options); + }, - registry.register('route:basic', _emberRouting.Route); - registry.register('event_dispatcher:main', _emberViews.EventDispatcher); + /** + Registers a factory for later injection. + Example: + ```javascript + let registry = new Registry(); + registry.register('model:user', Person, {singleton: false }); + registry.register('fruit:favorite', Orange); + registry.register('communication:main', Email, {singleton: false}); + ``` + @private + @method register + @param {String} fullName + @param {Function} factory + @param {Object} options + */ + register: function (fullName, factory) { + var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - registry.injection('router:main', 'namespace', 'application:main'); + if (factory === undefined) { + throw new TypeError('Attempting to register an unknown factory: \'' + fullName + '\''); + } - registry.register('location:auto', _emberRouting.AutoLocation); - registry.register('location:hash', _emberRouting.HashLocation); - registry.register('location:history', _emberRouting.HistoryLocation); - registry.register('location:none', _emberRouting.NoneLocation); + var normalizedName = this.normalize(fullName); - registry.register(_container.privatize(_templateObject), _emberRouting.BucketCache); - } + if (this._resolveCache[normalizedName]) { + throw new Error('Cannot re-register: \'' + fullName + '\', as it has already been resolved.'); + } - function registerLibraries() { - if (!librariesRegistered) { - librariesRegistered = true; + delete this._failCache[normalizedName]; + this.registrations[normalizedName] = factory; + this._options[normalizedName] = options; + }, - if (_emberEnvironment.environment.hasDOM && typeof _emberViews.jQuery === 'function') { - _emberMetal.libraries.registerCoreLibrary('jQuery', _emberViews.jQuery().jquery); - } - } - } + /** + Unregister a fullName + ```javascript + let registry = new Registry(); + registry.register('model:user', User); + registry.resolve('model:user').create() instanceof User //=> true + registry.unregister('model:user') + registry.resolve('model:user') === undefined //=> true + ``` + @private + @method unregister + @param {String} fullName + */ + unregister: function (fullName) { + + var normalizedName = this.normalize(fullName); - function logLibraryVersions() { - if (_emberEnvironment.ENV.LOG_VERSION) { - // we only need to see this once per Application#init - _emberEnvironment.ENV.LOG_VERSION = false; - var libs = _emberMetal.libraries._registry; + this._localLookupCache = new _emberUtils.EmptyObject(); - var nameLengths = libs.map(function (item) { - return _emberMetal.get(item, 'name.length'); - }); + delete this.registrations[normalizedName]; + delete this._resolveCache[normalizedName]; + delete this._failCache[normalizedName]; + delete this._options[normalizedName]; + }, - var maxNameLength = Math.max.apply(this, nameLengths); + /** + Given a fullName return the corresponding factory. + By default `resolve` will retrieve the factory from + the registry. + ```javascript + let registry = new Registry(); + registry.register('api:twitter', Twitter); + registry.resolve('api:twitter') // => Twitter + ``` + Optionally the registry can be provided with a custom resolver. + If provided, `resolve` will first provide the custom resolver + the opportunity to resolve the fullName, otherwise it will fallback + to the registry. + ```javascript + let registry = new Registry(); + registry.resolver = function(fullName) { + // lookup via the module system of choice + }; + // the twitter factory is added to the module system + registry.resolve('api:twitter') // => Twitter + ``` + @private + @method resolve + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {Function} fullName's factory + */ + resolve: function (fullName, options) { + var factory = resolve(this, this.normalize(fullName), options); + if (factory === undefined && this.fallback) { + var _fallback; - for (var i = 0; i < libs.length; i++) { - var lib = libs[i]; - var spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); + factory = (_fallback = this.fallback).resolve.apply(_fallback, arguments); } - } - } + return factory; + }, - exports.default = Application; -}); -enifed('ember-application/system/engine-instance', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'container', 'ember-application/system/engine-parent'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _container, _emberApplicationSystemEngineParent) { - /** - @module ember - @submodule ember-application - */ + /** + A hook that can be used to describe how the resolver will + attempt to find the factory. + For example, the default Ember `.describe` returns the full + class name (including namespace) where Ember's resolver expects + to find the `fullName`. + @private + @method describe + @param {String} fullName + @return {string} described fullName + */ + describe: function (fullName) { + if (this.resolver && this.resolver.lookupDescription) { + return this.resolver.lookupDescription(fullName); + } else if (this.fallback) { + return this.fallback.describe(fullName); + } else { + return fullName; + } + }, - 'use strict'; + /** + A hook to enable custom fullName normalization behaviour + @private + @method normalizeFullName + @param {String} fullName + @return {string} normalized fullName + */ + normalizeFullName: function (fullName) { + if (this.resolver && this.resolver.normalize) { + return this.resolver.normalize(fullName); + } else if (this.fallback) { + return this.fallback.normalizeFullName(fullName); + } else { + return fullName; + } + }, - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + /** + Normalize a fullName based on the application's conventions + @private + @method normalize + @param {String} fullName + @return {string} normalized fullName + */ + normalize: function (fullName) { + return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName)); + }, - /** - The `EngineInstance` encapsulates all of the stateful aspects of a - running `Engine`. - - @public - @class Ember.EngineInstance - @extends Ember.Object - @uses RegistryProxyMixin - @uses ContainerProxyMixin - */ + /** + @method makeToString + @private + @param {any} factory + @param {string} fullName + @return {function} toString function + */ + makeToString: function (factory, fullName) { + if (this.resolver && this.resolver.makeToString) { + return this.resolver.makeToString(factory, fullName); + } else if (this.fallback) { + return this.fallback.makeToString(factory, fullName); + } else { + return factory.toString(); + } + }, - var EngineInstance = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, { /** - The base `Engine` for which this is an instance. - @property {Ember.Engine} engine + Given a fullName check if the container is aware of its factory + or singleton instance. @private - */ - base: null, + @method has + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {Boolean} + */ + has: function (fullName, options) { + if (!this.isValidFullName(fullName)) { + return false; + } - init: function () { - this._super.apply(this, arguments); + var source = options && options.source && this.normalize(options.source); - _emberUtils.guidFor(this); + return has(this, this.normalize(fullName), source); + }, - var base = this.base; + /** + Allow registering options for all factories of a type. + ```javascript + let registry = new Registry(); + let container = registry.container(); + // if all of type `connection` must not be singletons + registry.optionsForType('connection', { singleton: false }); + registry.register('connection:twitter', TwitterConnection); + registry.register('connection:facebook', FacebookConnection); + let twitter = container.lookup('connection:twitter'); + let twitter2 = container.lookup('connection:twitter'); + twitter === twitter2; // => false + let facebook = container.lookup('connection:facebook'); + let facebook2 = container.lookup('connection:facebook'); + facebook === facebook2; // => false + ``` + @private + @method optionsForType + @param {String} type + @param {Object} options + */ + optionsForType: function (type, options) { + this._typeOptions[type] = options; + }, - if (!base) { - base = this.application; - this.base = base; + getOptionsForType: function (type) { + var optionsForType = this._typeOptions[type]; + if (optionsForType === undefined && this.fallback) { + optionsForType = this.fallback.getOptionsForType(type); } + return optionsForType; + }, - // Create a per-instance registry that will use the application's registry - // as a fallback for resolving registrations. - var registry = this.__registry__ = new _container.Registry({ - fallback: base.__registry__ - }); + /** + @private + @method options + @param {String} fullName + @param {Object} options + */ + options: function (fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - // Create a per-instance container from the instance's registry - this.__container__ = registry.container({ owner: this }); + var normalizedName = this.normalize(fullName); + this._options[normalizedName] = options; + }, - this._booted = false; + getOptions: function (fullName) { + var normalizedName = this.normalize(fullName); + var options = this._options[normalizedName]; + + if (options === undefined && this.fallback) { + options = this.fallback.getOptions(fullName); + } + return options; }, - /** - Initialize the `Ember.EngineInstance` and return a promise that resolves - with the instance itself when the boot process is complete. - The primary task here is to run any registered instance initializers. - See the documentation on `BootOptions` for the options it takes. - @private - @method boot - @param options {Object} - @return {Promise} - */ - boot: function (options) { - var _this = this; + getOption: function (fullName, optionName) { + var options = this._options[fullName]; - if (this._bootPromise) { - return this._bootPromise; + if (options && options[optionName] !== undefined) { + return options[optionName]; } - this._bootPromise = new _emberRuntime.RSVP.Promise(function (resolve) { - return resolve(_this._bootSync(options)); - }); + var type = fullName.split(':')[0]; + options = this._typeOptions[type]; - return this._bootPromise; + if (options && options[optionName] !== undefined) { + return options[optionName]; + } else if (this.fallback) { + return this.fallback.getOption(fullName, optionName); + } }, /** - Unfortunately, a lot of existing code assumes booting an instance is - synchronous – specifically, a lot of tests assume the last call to - `app.advanceReadiness()` or `app.reset()` will result in a new instance - being fully-booted when the current runloop completes. - We would like new code (like the `visit` API) to stop making this - assumption, so we created the asynchronous version above that returns a - promise. But until we have migrated all the code, we would have to expose - this method for use *internally* in places where we need to boot an instance - synchronously. - @private - */ - _bootSync: function (options) { - if (this._booted) { - return this; + Used only via `injection`. + Provides a specialized form of injection, specifically enabling + all objects of one type to be injected with a reference to another + object. + For example, provided each object of type `controller` needed a `router`. + one would do the following: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('router:main', Router); + registry.register('controller:user', UserController); + registry.register('controller:post', PostController); + registry.typeInjection('controller', 'router', 'router:main'); + let user = container.lookup('controller:user'); + let post = container.lookup('controller:post'); + user.router instanceof Router; //=> true + post.router instanceof Router; //=> true + // both controllers share the same router + user.router === post.router; //=> true + ``` + @private + @method typeInjection + @param {String} type + @param {String} property + @param {String} fullName + */ + typeInjection: function (type, property, fullName) { + + var fullNameType = fullName.split(':')[0]; + if (fullNameType === type) { + throw new Error('Cannot inject a \'' + fullName + '\' on other ' + type + '(s).'); } - this.cloneParentDependencies(); + var injections = this._typeInjections[type] || (this._typeInjections[type] = []); - this.setupRegistry(options); + injections.push({ + property: property, + fullName: fullName + }); + }, - this.base.runInstanceInitializers(this); + /** + Defines injection rules. + These rules are used to inject dependencies onto objects when they + are instantiated. + Two forms of injections are possible: + * Injecting one fullName on another fullName + * Injecting one fullName on a type + Example: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('source:main', Source); + registry.register('model:user', User); + registry.register('model:post', Post); + // injecting one fullName on another fullName + // eg. each user model gets a post model + registry.injection('model:user', 'post', 'model:post'); + // injecting one fullName on another type + registry.injection('model', 'source', 'source:main'); + let user = container.lookup('model:user'); + let post = container.lookup('model:post'); + user.source instanceof Source; //=> true + post.source instanceof Source; //=> true + user.post instanceof Post; //=> true + // and both models share the same source + user.source === post.source; //=> true + ``` + @private + @method injection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + injection: function (fullName, property, injectionName) { + this.validateFullName(injectionName); + var normalizedInjectionName = this.normalize(injectionName); - this._booted = true; + if (fullName.indexOf(':') === -1) { + return this.typeInjection(fullName, property, normalizedInjectionName); + } - return this; - }, + var normalizedName = this.normalize(fullName); - setupRegistry: function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? this.__container__.lookup('-environment:main') : arguments[0]; + var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); - this.constructor.setupRegistry(this.__registry__, options); + injections.push({ + property: property, + fullName: normalizedInjectionName + }); }, /** - Unregister a factory. - Overrides `RegistryProxy#unregister` in order to clear any cached instances - of the unregistered factory. - @public - @method unregister + Used only via `factoryInjection`. + Provides a specialized form of injection, specifically enabling + all factory of one type to be injected with a reference to another + object. + For example, provided each factory of type `model` needed a `store`. + one would do the following: + ```javascript + let registry = new Registry(); + registry.register('store:main', SomeStore); + registry.factoryTypeInjection('model', 'store', 'store:main'); + let store = registry.lookup('store:main'); + let UserFactory = registry.lookupFactory('model:user'); + UserFactory.store instanceof SomeStore; //=> true + ``` + @private + @method factoryTypeInjection + @param {String} type + @param {String} property @param {String} fullName */ - unregister: function (fullName) { - this.__container__.reset(fullName); - this._super.apply(this, arguments); - }, + factoryTypeInjection: function (type, property, fullName) { + var injections = this._factoryTypeInjections[type] || (this._factoryTypeInjections[type] = []); - /** - @private - */ - willDestroy: function () { - this._super.apply(this, arguments); - _emberMetal.run(this.__container__, 'destroy'); + injections.push({ + property: property, + fullName: this.normalize(fullName) + }); }, /** - Build a new `Ember.EngineInstance` that's a child of this instance. - Engines must be registered by name with their parent engine - (or application). - @private - @method buildChildEngineInstance - @param name {String} the registered name of the engine. - @param options {Object} options provided to the engine instance. - @return {Ember.EngineInstance,Error} - */ - buildChildEngineInstance: function (name) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + Defines factory injection rules. + Similar to regular injection rules, but are run against factories, via + `Registry#lookupFactory`. + These rules are used to inject objects onto factories when they + are looked up. + Two forms of injections are possible: + * Injecting one fullName on another fullName + * Injecting one fullName on a type + Example: + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('store:main', Store); + registry.register('store:secondary', OtherStore); + registry.register('model:user', User); + registry.register('model:post', Post); + // injecting one fullName on another type + registry.factoryInjection('model', 'store', 'store:main'); + // injecting one fullName on another fullName + registry.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); + let UserFactory = container.lookupFactory('model:user'); + let PostFactory = container.lookupFactory('model:post'); + let store = container.lookup('store:main'); + UserFactory.store instanceof Store; //=> true + UserFactory.secondaryStore instanceof OtherStore; //=> false + PostFactory.store instanceof Store; //=> true + PostFactory.secondaryStore instanceof OtherStore; //=> true + // and both models share the same source instance + UserFactory.store === PostFactory.store; //=> true + ``` + @private + @method factoryInjection + @param {String} factoryName + @param {String} property + @param {String} injectionName + */ + factoryInjection: function (fullName, property, injectionName) { + var normalizedName = this.normalize(fullName); + var normalizedInjectionName = this.normalize(injectionName); - var Engine = this.lookup('engine:' + name); + this.validateFullName(injectionName); - if (!Engine) { - throw new _emberMetal.Error('You attempted to mount the engine \'' + name + '\', but it is not registered with its parent.'); + if (fullName.indexOf(':') === -1) { + return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); } - var engineInstance = Engine.buildInstance(options); - - _emberApplicationSystemEngineParent.setEngineParent(engineInstance, this); + var injections = this._factoryInjections[normalizedName] || (this._factoryInjections[normalizedName] = []); - return engineInstance; + injections.push({ + property: property, + fullName: normalizedInjectionName + }); }, /** - Clone dependencies shared between an engine instance and its parent. - @private - @method cloneParentDependencies + @private + @method knownForType + @param {String} type the type to iterate over */ - cloneParentDependencies: function () { - var _this2 = this; + knownForType: function (type) { + var fallbackKnown = undefined, + resolverKnown = undefined; - var parent = _emberApplicationSystemEngineParent.getEngineParent(this); + var localKnown = _emberUtils.dictionary(null); + var registeredNames = Object.keys(this.registrations); + for (var index = 0; index < registeredNames.length; index++) { + var fullName = registeredNames[index]; + var itemType = fullName.split(':')[0]; - var registrations = ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment']; + if (itemType === type) { + localKnown[fullName] = true; + } + } - registrations.forEach(function (key) { - return _this2.register(key, parent.resolveRegistration(key)); - }); + if (this.fallback) { + fallbackKnown = this.fallback.knownForType(type); + } - var env = parent.lookup('-environment:main'); - this.register('-environment:main', env, { instantiate: false }); + if (this.resolver && this.resolver.knownForType) { + resolverKnown = this.resolver.knownForType(type); + } - var singletons = ['router:main', _container.privatize(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert')]; + return _emberUtils.assign({}, fallbackKnown, localKnown, resolverKnown); + }, - singletons.forEach(function (key) { - return _this2.register(key, parent.lookup(key), { instantiate: false }); - }); + validateFullName: function (fullName) { + if (!this.isValidFullName(fullName)) { + throw new TypeError('Invalid Fullname, expected: \'type:name\' got: ' + fullName); + } - this.inject('view', '_environment', '-environment:main'); - this.inject('route', '_environment', '-environment:main'); - } - }); + return true; + }, - EngineInstance.reopenClass({ - /** - @private - @method setupRegistry - @param {Registry} registry - @param {BootOptions} options - */ - setupRegistry: function (registry, options) { - // when no options/environment is present, do nothing - if (!options) { + isValidFullName: function (fullName) { + return !!VALID_FULL_NAME_REGEXP.test(fullName); + }, + + validateInjections: function (injections) { + if (!injections) { return; } - registry.injection('view', '_environment', '-environment:main'); - registry.injection('route', '_environment', '-environment:main'); + var fullName = undefined; - if (options.isInteractive) { - registry.injection('view', 'renderer', 'renderer:-dom'); - registry.injection('component', 'renderer', 'renderer:-dom'); - } else { - registry.injection('view', 'renderer', 'renderer:-inert'); - registry.injection('component', 'renderer', 'renderer:-inert'); + for (var i = 0; i < injections.length; i++) { + fullName = injections[i].fullName; } - } - }); - - exports.default = EngineInstance; -}); -enifed('ember-application/system/engine-parent', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + }, - exports.getEngineParent = getEngineParent; - exports.setEngineParent = setEngineParent; - var ENGINE_PARENT = _emberUtils.symbol('ENGINE_PARENT'); + normalizeInjectionsHash: function (hash) { + var injections = []; - exports.ENGINE_PARENT = ENGINE_PARENT; - /** - `getEngineParent` retrieves an engine instance's parent instance. - - @method getEngineParent - @param {EngineInstance} engine An engine instance. - @return {EngineInstance} The parent engine instance. - @for Ember - @public - */ + for (var key in hash) { + if (hash.hasOwnProperty(key)) { - function getEngineParent(engine) { - return engine[ENGINE_PARENT]; - } + injections.push({ + property: key, + fullName: hash[key] + }); + } + } - /** - `setEngineParent` sets an engine instance's parent instance. - - @method setEngineParent - @param {EngineInstance} engine An engine instance. - @param {EngineInstance} parent The parent engine instance. - @private - */ + return injections; + }, - function setEngineParent(engine, parent) { - engine[ENGINE_PARENT] = parent; - } -}); -enifed('ember-application/system/engine', ['exports', 'ember-utils', 'ember-runtime', 'container', 'dag-map', 'ember-metal', 'ember-application/system/resolver', 'ember-application/system/engine-instance', 'ember-routing', 'ember-extension-support', 'ember-views', 'ember-glimmer'], function (exports, _emberUtils, _emberRuntime, _container, _dagMap, _emberMetal, _emberApplicationSystemResolver, _emberApplicationSystemEngineInstance, _emberRouting, _emberExtensionSupport, _emberViews, _emberGlimmer) { - /** - @module ember - @submodule ember-application - */ - 'use strict'; + getInjections: function (fullName) { + var injections = this._injections[fullName] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getInjections(fullName)); + } + return injections; + }, - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + getTypeInjections: function (type) { + var injections = this._typeInjections[type] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getTypeInjections(type)); + } + return injections; + }, - function props(obj) { - var properties = []; + getFactoryInjections: function (fullName) { + var injections = this._factoryInjections[fullName] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getFactoryInjections(fullName)); + } + return injections; + }, - for (var key in obj) { - properties.push(key); + getFactoryTypeInjections: function (type) { + var injections = this._factoryTypeInjections[type] || []; + if (this.fallback) { + injections = injections.concat(this.fallback.getFactoryTypeInjections(type)); + } + return injections; } + }; - return properties; + function deprecateResolverFunction(registry) { + registry.resolver = { + resolve: registry.resolver + }; } /** - The `Engine` class contains core functionality for both applications and - engines. - - Each engine manages a registry that's used for dependency injection and - exposed through `RegistryProxy`. + Given a fullName and a source fullName returns the fully resolved + fullName. Used to allow for local lookup. - Engines also manage initializers and instance initializers. + ```javascript + let registry = new Registry(); - Engines can spawn `EngineInstance` instances via `buildInstance()`. + // the twitter factory is added to the module system + registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title + ``` - @class Engine - @namespace Ember - @extends Ember.Namespace - @uses RegistryProxy - @public - */ - var Engine = _emberRuntime.Namespace.extend(_emberRuntime.RegistryProxyMixin, { - init: function () { - this._super.apply(this, arguments); - - this.buildRegistry(); - }, - - /** - A private flag indicating whether an engine's initializers have run yet. - @private - @property _initializersRan - */ - _initializersRan: false, - - /** - Ensure that initializers are run once, and only once, per engine. - @private - @method ensureInitializers - */ - ensureInitializers: function () { - if (!this._initializersRan) { - this.runInitializers(); - this._initializersRan = true; - } - }, + @private + @method expandLocalLookup + @param {String} fullName + @param {Object} [options] + @param {String} [options.source] the fullname of the request source (used for local lookups) + @return {String} fullName + */ + Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) { + if (this.resolver && this.resolver.expandLocalLookup) { - /** - Create an EngineInstance for this engine. - @private - @method buildInstance - @return {Ember.EngineInstance} the engine instance - */ - buildInstance: function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + var normalizedFullName = this.normalize(fullName); + var normalizedSource = this.normalize(options.source); - this.ensureInitializers(); - options.base = this; - return _emberApplicationSystemEngineInstance.default.create(options); - }, + return expandLocalLookup(this, normalizedFullName, normalizedSource); + } else if (this.fallback) { + return this.fallback.expandLocalLookup(fullName, options); + } else { + return null; + } + }; - /** - Build and configure the registry for the current engine. - @private - @method buildRegistry - @return {Ember.Registry} the configured registry - */ - buildRegistry: function () { - var registry = this.__registry__ = this.constructor.buildRegistry(this); + function expandLocalLookup(registry, normalizedName, normalizedSource) { + var cache = registry._localLookupCache; + var normalizedNameCache = cache[normalizedName]; - return registry; - }, + if (!normalizedNameCache) { + normalizedNameCache = cache[normalizedName] = new _emberUtils.EmptyObject(); + } - /** - @private - @method initializer - */ - initializer: function (options) { - this.constructor.initializer(options); - }, + var cached = normalizedNameCache[normalizedSource]; - /** - @private - @method instanceInitializer - */ - instanceInitializer: function (options) { - this.constructor.instanceInitializer(options); - }, + if (cached !== undefined) { + return cached; + } - /** - @private - @method runInitializers - */ - runInitializers: function () { - var _this = this; + var expanded = registry.resolver.expandLocalLookup(normalizedName, normalizedSource); - this._runInitializer('initializers', function (name, initializer) { - if (initializer.initialize.length === 2) { + return normalizedNameCache[normalizedSource] = expanded; + } - initializer.initialize(_this.__registry__, _this); - } else { - initializer.initialize(_this); - } - }); - }, + function resolve(registry, normalizedName, options) { + if (options && options.source) { + // when `source` is provided expand normalizedName + // and source into the full normalizedName + normalizedName = registry.expandLocalLookup(normalizedName, options); - /** - @private - @since 1.12.0 - @method runInstanceInitializers - */ - runInstanceInitializers: function (instance) { - this._runInitializer('instanceInitializers', function (name, initializer) { - initializer.initialize(instance); - }); - }, + // if expandLocalLookup returns falsey, we do not support local lookup + if (!normalizedName) { + return; + } + } - _runInitializer: function (bucketName, cb) { - var initializersByName = _emberMetal.get(this.constructor, bucketName); - var initializers = props(initializersByName); - var graph = new _dagMap.default(); - var initializer = undefined; + var cached = registry._resolveCache[normalizedName]; + if (cached !== undefined) { + return cached; + } + if (registry._failCache[normalizedName]) { + return; + } - for (var i = 0; i < initializers.length; i++) { - initializer = initializersByName[initializers[i]]; - graph.add(initializer.name, initializer, initializer.before, initializer.after); - } + var resolved = undefined; - graph.topsort(cb); + if (registry.resolver) { + resolved = registry.resolver.resolve(normalizedName); } - }); - Engine.reopenClass({ - initializers: new _emberUtils.EmptyObject(), - instanceInitializers: new _emberUtils.EmptyObject(), + if (resolved === undefined) { + resolved = registry.registrations[normalizedName]; + } - /** - The goal of initializers should be to register dependencies and injections. - This phase runs once. Because these initializers may load code, they are - allowed to defer application readiness and advance it. If you need to access - the container or store you should use an InstanceInitializer that will be run - after all initializers and therefore after all code is loaded and the app is - ready. - Initializer receives an object which has the following attributes: - `name`, `before`, `after`, `initialize`. The only required attribute is - `initialize`, all others are optional. - * `name` allows you to specify under which name the initializer is registered. - This must be a unique name, as trying to register two initializers with the - same name will result in an error. - ```javascript - Ember.Application.initializer({ - name: 'namedInitializer', - initialize: function(application) { - Ember.debug('Running namedInitializer!'); - } - }); - ``` - * `before` and `after` are used to ensure that this initializer is ran prior - or after the one identified by the value. This value can be a single string - or an array of strings, referencing the `name` of other initializers. - An example of ordering initializers, we create an initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'first', - initialize: function(application) { - Ember.debug('First initializer!'); - } - }); - // DEBUG: First initializer! - ``` - We add another initializer named `second`, specifying that it should run - after the initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'second', - after: 'first', - initialize: function(application) { - Ember.debug('Second initializer!'); - } - }); - // DEBUG: First initializer! - // DEBUG: Second initializer! - ``` - Afterwards we add a further initializer named `pre`, this time specifying - that it should run before the initializer named `first`: - ```javascript - Ember.Application.initializer({ - name: 'pre', - before: 'first', - initialize: function(application) { - Ember.debug('Pre initializer!'); - } - }); - // DEBUG: Pre initializer! - // DEBUG: First initializer! - // DEBUG: Second initializer! - ``` - Finally we add an initializer named `post`, specifying it should run after - both the `first` and the `second` initializers: - ```javascript - Ember.Application.initializer({ - name: 'post', - after: ['first', 'second'], - initialize: function(application) { - Ember.debug('Post initializer!'); - } - }); - // DEBUG: Pre initializer! - // DEBUG: First initializer! - // DEBUG: Second initializer! - // DEBUG: Post initializer! - ``` - * `initialize` is a callback function that receives one argument, - `application`, on which you can operate. - Example of using `application` to register an adapter: - ```javascript - Ember.Application.initializer({ - name: 'api-adapter', - initialize: function(application) { - application.register('api-adapter:main', ApiAdapter); - } - }); - ``` - @method initializer - @param initializer {Object} - @public - */ + if (resolved === undefined) { + registry._failCache[normalizedName] = true; + } else { + registry._resolveCache[normalizedName] = resolved; + } - initializer: buildInitializerMethod('initializers', 'initializer'), + return resolved; + } - /** - Instance initializers run after all initializers have run. Because - instance initializers run after the app is fully set up. We have access - to the store, container, and other items. However, these initializers run - after code has loaded and are not allowed to defer readiness. - Instance initializer receives an object which has the following attributes: - `name`, `before`, `after`, `initialize`. The only required attribute is - `initialize`, all others are optional. - * `name` allows you to specify under which name the instanceInitializer is - registered. This must be a unique name, as trying to register two - instanceInitializer with the same name will result in an error. - ```javascript - Ember.Application.instanceInitializer({ - name: 'namedinstanceInitializer', - initialize: function(application) { - Ember.debug('Running namedInitializer!'); - } - }); - ``` - * `before` and `after` are used to ensure that this initializer is ran prior - or after the one identified by the value. This value can be a single string - or an array of strings, referencing the `name` of other initializers. - * See Ember.Application.initializer for discussion on the usage of before - and after. - Example instanceInitializer to preload data into the store. - ```javascript - Ember.Application.initializer({ - name: 'preload-data', - initialize: function(application) { - var userConfig, userConfigEncoded, store; - // We have a HTML escaped JSON representation of the user's basic - // configuration generated server side and stored in the DOM of the main - // index.html file. This allows the app to have access to a set of data - // without making any additional remote calls. Good for basic data that is - // needed for immediate rendering of the page. Keep in mind, this data, - // like all local models and data can be manipulated by the user, so it - // should not be relied upon for security or authorization. - // - // Grab the encoded data from the meta tag - userConfigEncoded = Ember.$('head meta[name=app-user-config]').attr('content'); - // Unescape the text, then parse the resulting JSON into a real object - userConfig = JSON.parse(unescape(userConfigEncoded)); - // Lookup the store - store = application.lookup('service:store'); - // Push the encoded JSON into the store - store.pushPayload(userConfig); - } - }); - ``` - @method instanceInitializer - @param instanceInitializer - @public - */ - instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer'), + function has(registry, fullName, source) { + return registry.resolve(fullName, { source: source }) !== undefined; + } - /** - This creates a registry with the default Ember naming conventions. - It also configures the registry: - * registered views are created every time they are looked up (they are - not singletons) - * registered templates are not factories; the registered value is - returned directly. - * the router receives the application as its `namespace` property - * all controllers receive the router as their `target` and `controllers` - properties - * all controllers receive the application as their `namespace` property - * the application view receives the application controller as its - `controller` property - * the application view receives the application template as its - `defaultTemplate` property - @method buildRegistry - @static - @param {Ember.Application} namespace the application for which to - build the registry - @return {Ember.Registry} the built registry - @private - */ - buildRegistry: function (namespace) { - var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var privateNames = _emberUtils.dictionary(null); + var privateSuffix = '' + Math.random() + Date.now(); - var registry = new _container.Registry({ - resolver: resolverFor(namespace) - }); + function privatize(_ref) { + var fullName = _ref[0]; - registry.set = _emberMetal.set; + var name = privateNames[fullName]; + if (name) { + return name; + } - registry.register('application:main', namespace, { instantiate: false }); + var _fullName$split = fullName.split(':'); - commonSetupRegistry(registry); - _emberGlimmer.setupEngineRegistry(registry); + var type = _fullName$split[0]; + var rawName = _fullName$split[1]; - return registry; - }, + return privateNames[fullName] = _emberUtils.intern(type + ':' + rawName + '-' + privateSuffix); + } +}); +enifed('dag-map', ['exports'], function (exports) { 'use strict'; +/** + * A map of key/value pairs with dependencies contraints that can be traversed + * in topological order and is checked for cycles. + * + * @class DAG + * @constructor + */ +var DAG = (function () { + function DAG() { + this._vertices = new Vertices(); + } /** - Set this to provide an alternate class to `Ember.DefaultResolver` - @deprecated Use 'Resolver' instead - @property resolver - @public - */ - resolver: null, - + * Adds a key/value pair with dependencies on other key/value pairs. + * + * @public + * @method addEdges + * @param {string[]} key The key of the vertex to be added. + * @param {any} value The value of that vertex. + * @param {string[]|string|undefined} before A key or array of keys of the vertices that must + * be visited before this vertex. + * @param {string[]|string|undefined} after An string or array of strings with the keys of the + * vertices that must be after this vertex is visited. + */ + DAG.prototype.add = function (key, value, before, after) { + var vertices = this._vertices; + var v = vertices.add(key); + v.val = value; + if (before) { + if (typeof before === "string") { + vertices.addEdge(v, vertices.add(before)); + } + else { + for (var i = 0; i < before.length; i++) { + vertices.addEdge(v, vertices.add(before[i])); + } + } + } + if (after) { + if (typeof after === "string") { + vertices.addEdge(vertices.add(after), v); + } + else { + for (var i = 0; i < after.length; i++) { + vertices.addEdge(vertices.add(after[i]), v); + } + } + } + }; /** - Set this to provide an alternate class to `Ember.DefaultResolver` - @property resolver - @public - */ - Resolver: null - }); - - /** - This function defines the default lookup rules for container lookups: - - * templates are looked up on `Ember.TEMPLATES` - * other names are looked up on the application after classifying the name. - For example, `controller:post` looks up `App.PostController` by default. - * if the default lookup fails, look for registered classes on the container - - This allows the application to register default injections in the container - that could be overridden by the normal naming convention. - - @private - @method resolverFor - @param {Ember.Namespace} namespace the namespace to look for classes - @return {*} the resolved value for a given lookup - */ - function resolverFor(namespace) { - var ResolverClass = namespace.get('Resolver') || _emberApplicationSystemResolver.default; - - return ResolverClass.create({ - namespace: namespace - }); - } - - function buildInitializerMethod(bucketName, humanName) { - return function (initializer) { - // If this is the first initializer being added to a subclass, we are going to reopen the class - // to make sure we have a new `initializers` object, which extends from the parent class' using - // prototypal inheritance. Without this, attempting to add initializers to the subclass would - // pollute the parent class as well as other subclasses. - if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) { - var attrs = {}; - attrs[bucketName] = Object.create(this[bucketName]); - this.reopenClass(attrs); - } - - this[bucketName][initializer.name] = initializer; + * Visits key/value pairs in topological order. + * + * @public + * @method topsort + * @param {Function} fn The function to be invoked with each key/value. + */ + DAG.prototype.topsort = function (callback) { + this._vertices.topsort(callback); }; - } - - function commonSetupRegistry(registry) { - registry.optionsForType('component', { singleton: false }); - registry.optionsForType('view', { singleton: false }); - - registry.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); - - registry.injection('view', '_viewRegistry', '-view-registry:main'); - registry.injection('renderer', '_viewRegistry', '-view-registry:main'); - registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); - - registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); + return DAG; +}()); +var Vertices = (function () { + function Vertices() { + this.stack = new IntStack(); + this.result = new IntStack(); + this.vertices = []; + } + Vertices.prototype.add = function (key) { + if (!key) + throw new Error("missing key"); + var vertices = this.vertices; + var i = 0; + var vertex; + for (; i < vertices.length; i++) { + vertex = vertices[i]; + if (vertex.key === key) + return vertex; + } + return vertices[i] = { + id: i, + key: key, + val: null, + inc: null, + out: false, + mark: false + }; + }; + Vertices.prototype.addEdge = function (v, w) { + this.check(v, w.key); + var inc = w.inc; + if (!inc) { + w.inc = [v.id]; + } + else { + var i = 0; + for (; i < inc.length; i++) { + if (inc[i] === v.id) + return; + } + inc[i] = v.id; + } + v.out = true; + }; + Vertices.prototype.topsort = function (cb) { + this.reset(); + var vertices = this.vertices; + for (var i = 0; i < vertices.length; i++) { + var vertex = vertices[i]; + if (vertex.out) + continue; + this.visit(vertex, undefined); + } + this.each(cb); + }; + Vertices.prototype.check = function (v, w) { + if (v.key === w) { + throw new Error("cycle detected: " + w + " <- " + w); + } + var inc = v.inc; + // quick check + if (!inc || inc.length === 0) + return; + var vertices = this.vertices; + // shallow check + for (var i = 0; i < inc.length; i++) { + var key = vertices[inc[i]].key; + if (key === w) { + throw new Error("cycle detected: " + w + " <- " + v.key + " <- " + w); + } + } + // deep check + this.reset(); + this.visit(v, w); + if (this.result.len > 0) { + var msg_1 = "cycle detected: " + w; + this.each(function (key) { + msg_1 += " <- " + key; + }); + throw new Error(msg_1); + } + }; + Vertices.prototype.each = function (cb) { + var _a = this, result = _a.result, vertices = _a.vertices; + for (var i = 0; i < result.len; i++) { + var vertex = vertices[result.stack[i]]; + cb(vertex.key, vertex.val); + } + }; + // reuse between cycle check and topsort + Vertices.prototype.reset = function () { + this.stack.len = 0; + this.result.len = 0; + var vertices = this.vertices; + for (var i = 0; i < vertices.length; i++) { + vertices[i].mark = false; + } + }; + Vertices.prototype.visit = function (start, search) { + var _a = this, stack = _a.stack, result = _a.result, vertices = _a.vertices; + stack.push(start.id); + while (stack.len) { + var index = stack.pop(); + if (index < 0) { + index = ~index; + if (search) { + result.pop(); + } + else { + result.push(index); + } + } + else { + var vertex = vertices[index]; + if (vertex.mark) { + continue; + } + if (search) { + result.push(index); + if (search === vertex.key) { + return; + } + } + vertex.mark = true; + stack.push(~index); + var incoming = vertex.inc; + if (incoming) { + var i = incoming.length; + while (i--) { + index = incoming[i]; + if (!vertices[index].mark) { + stack.push(index); + } + } + } + } + } + }; + return Vertices; +}()); +var IntStack = (function () { + function IntStack() { + this.stack = [0, 0, 0, 0, 0, 0]; + this.len = 0; + } + IntStack.prototype.push = function (n) { + this.stack[this.len++] = n; + }; + IntStack.prototype.pop = function () { + return this.stack[--this.len]; + }; + return IntStack; +}()); - registry.injection('view:-outlet', 'namespace', 'application:main'); +exports['default'] = DAG; - registry.injection('controller', 'target', 'router:main'); - registry.injection('controller', 'namespace', 'application:main'); +Object.defineProperty(exports, '__esModule', { value: true }); - registry.injection('router', '_bucketCache', _container.privatize(_templateObject)); - registry.injection('route', '_bucketCache', _container.privatize(_templateObject)); +}); +enifed('ember-application/index', ['exports', 'ember-application/initializers/dom-templates', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/resolver', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (exports, _emberApplicationInitializersDomTemplates, _emberApplicationSystemApplication, _emberApplicationSystemApplicationInstance, _emberApplicationSystemResolver, _emberApplicationSystemEngine, _emberApplicationSystemEngineInstance, _emberApplicationSystemEngineParent) { + /** + @module ember + @submodule ember-application + */ - registry.injection('route', 'router', 'router:main'); + 'use strict'; - // Register the routing service... - registry.register('service:-routing', _emberRouting.RoutingService); - // Then inject the app router into it - registry.injection('service:-routing', 'router', 'router:main'); + exports.Application = _emberApplicationSystemApplication.default; + exports.ApplicationInstance = _emberApplicationSystemApplicationInstance.default; + exports.Resolver = _emberApplicationSystemResolver.default; + exports.Engine = _emberApplicationSystemEngine.default; + exports.EngineInstance = _emberApplicationSystemEngineInstance.default; + exports.getEngineParent = _emberApplicationSystemEngineParent.getEngineParent; + exports.setEngineParent = _emberApplicationSystemEngineParent.setEngineParent; - // DEBUGGING - registry.register('resolver-for-debugging:main', registry.resolver, { instantiate: false }); - registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); - registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); - // Custom resolver authors may want to register their own ContainerDebugAdapter with this key + // add domTemplates initializer (only does something if `ember-template-compiler` + // is loaded already) +}); +enifed('ember-application/initializers/dom-templates', ['exports', 'require', 'ember-glimmer', 'ember-environment', 'ember-application/system/application'], function (exports, _require, _emberGlimmer, _emberEnvironment, _emberApplicationSystemApplication) { + 'use strict'; - registry.register('container-debug-adapter:main', _emberExtensionSupport.ContainerDebugAdapter); + var bootstrap = function () {}; - registry.register('component-lookup:main', _emberViews.ComponentLookup); - } + _emberApplicationSystemApplication.default.initializer({ + name: 'domTemplates', + initialize: function () { + var bootstrapModuleId = 'ember-template-compiler/system/bootstrap'; + var context = undefined; + if (_emberEnvironment.environment.hasDOM && _require.has(bootstrapModuleId)) { + bootstrap = _require.default(bootstrapModuleId).default; + context = document; + } - exports.default = Engine; + bootstrap({ context: context, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); + } + }); }); -enifed('ember-application/system/resolver', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application/utils/validate-type', 'ember-glimmer'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplicationUtilsValidateType, _emberGlimmer) { +enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberViews, _emberApplicationSystemEngineInstance) { /** @module ember @submodule ember-application @@ -4814,47143 +4490,38441 @@ enifed('ember-application/system/resolver', ['exports', 'ember-utils', 'ember-me 'use strict'; - var Resolver = _emberRuntime.Object.extend({ - /* - This will be set to the Application instance when it is - created. - @property namespace - */ - namespace: null, - normalize: null, // required - resolve: null, // required - parseName: null, // required - lookupDescription: null, // required - makeToString: null, // required - resolveOther: null, // required - _logLookup: null // required - }); + var BootOptions = undefined; - exports.Resolver = Resolver; /** - The DefaultResolver defines the default lookup rules to resolve - container lookups before consulting the container for registered - items: - - * templates are looked up on `Ember.TEMPLATES` - * other names are looked up on the application after converting - the name. For example, `controller:post` looks up - `App.PostController` by default. - * there are some nuances (see examples below) - - ### How Resolving Works - - The container calls this object's `resolve` method with the - `fullName` argument. - - It first parses the fullName into an object using `parseName`. - - Then it checks for the presence of a type-specific instance - method of the form `resolve[Type]` and calls it if it exists. - For example if it was resolving 'template:post', it would call - the `resolveTemplate` method. - - Its last resort is to call the `resolveOther` method. + The `ApplicationInstance` encapsulates all of the stateful aspects of a + running `Application`. - The methods of this object are designed to be easy to override - in a subclass. For example, you could enhance how a template - is resolved like so: + At a high-level, we break application boot into two distinct phases: - ```javascript - App = Ember.Application.create({ - Resolver: Ember.DefaultResolver.extend({ - resolveTemplate: function(parsedName) { - let resolvedTemplate = this._super(parsedName); - if (resolvedTemplate) { return resolvedTemplate; } - return Ember.TEMPLATES['not_found']; - } - }) - }); - ``` + * Definition time, where all of the classes, templates, and other + dependencies are loaded (typically in the browser). + * Run time, where we begin executing the application once everything + has loaded. - Some examples of how names are resolved: + Definition time can be expensive and only needs to happen once since it is + an idempotent operation. For example, between test runs and FastBoot + requests, the application stays the same. It is only the state that we want + to reset. - ``` - 'template:post' //=> Ember.TEMPLATES['post'] - 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] - 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] - 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] - // OR - // Ember.TEMPLATES['blog_post'] - 'controller:post' //=> App.PostController - 'controller:posts.index' //=> App.PostsIndexController - 'controller:blog/post' //=> Blog.PostController - 'controller:basic' //=> Ember.Controller - 'route:post' //=> App.PostRoute - 'route:posts.index' //=> App.PostsIndexRoute - 'route:blog/post' //=> Blog.PostRoute - 'route:basic' //=> Ember.Route - 'view:post' //=> App.PostView - 'view:posts.index' //=> App.PostsIndexView - 'view:blog/post' //=> Blog.PostView - 'view:basic' //=> Ember.View - 'foo:post' //=> App.PostFoo - 'model:post' //=> App.Post - ``` + That state is what the `ApplicationInstance` manages: it is responsible for + creating the container that contains all application state, and disposing of + it once the particular test run or FastBoot request has finished. - @class DefaultResolver - @namespace Ember - @extends Ember.Object @public + @class Ember.ApplicationInstance + @extends Ember.EngineInstance */ - exports.default = _emberRuntime.Object.extend({ + var ApplicationInstance = _emberApplicationSystemEngineInstance.default.extend({ /** - This will be set to the Application instance when it is - created. - @property namespace - @public + The `Application` for which this is an instance. + @property {Ember.Application} application + @private */ - namespace: null, - - init: function () { - this._parseNameCache = _emberUtils.dictionary(null); - }, - normalize: function (fullName) { - var _fullName$split = fullName.split(':', 2); - - var type = _fullName$split[0]; - var name = _fullName$split[1]; - - if (type !== 'template') { - var result = name; + application: null, - if (result.indexOf('.') > -1) { - result = result.replace(/\.(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } + /** + The DOM events for which the event dispatcher should listen. + By default, the application's `Ember.EventDispatcher` listens + for a set of standard DOM events, such as `mousedown` and + `keyup`, and delegates them to your application's `Ember.View` + instances. + @private + @property {Object} customEvents + */ + customEvents: null, - if (name.indexOf('_') > -1) { - result = result.replace(/_(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } + /** + The root DOM element of the Application as an element or a + [jQuery-compatible selector + string](http://api.jquery.com/category/selectors/). + @private + @property {String|DOMElement} rootElement + */ + rootElement: null, - if (name.indexOf('-') > -1) { - result = result.replace(/-(.)/g, function (m) { - return m.charAt(1).toUpperCase(); - }); - } + init: function () { + this._super.apply(this, arguments); - return type + ':' + result; - } else { - return fullName; - } + // Register this instance in the per-instance registry. + // + // Why do we need to register the instance in the first place? + // Because we need a good way for the root route (a.k.a ApplicationRoute) + // to notify us when it has created the root-most view. That view is then + // appended to the rootElement, in the case of apps, to the fixture harness + // in tests, or rendered to a string in the case of FastBoot. + this.register('-application-instance:main', this, { instantiate: false }); }, /** - This method is called via the container's resolver method. - It parses the provided `fullName` and then looks up and - returns the appropriate template or class. - @method resolve - @param {String} fullName the lookup string - @return {Object} the resolved factory - @public + Overrides the base `EngineInstance._bootSync` method with concerns relevant + to booting application (instead of engine) instances. + This method should only contain synchronous boot concerns. Asynchronous + boot concerns should eventually be moved to the `boot` method, which + returns a promise. + Until all boot code has been made asynchronous, we need to continue to + expose this method for use *internally* in places where we need to boot an + instance synchronously. + @private */ - resolve: function (fullName) { - var parsedName = this.parseName(fullName); - var resolveMethodName = parsedName.resolveMethodName; - var resolved; - - if (this[resolveMethodName]) { - resolved = this[resolveMethodName](parsedName); + _bootSync: function (options) { + if (this._booted) { + return this; } - resolved = resolved || this.resolveOther(parsedName); + options = new BootOptions(options); - if (parsedName.root && parsedName.root.LOG_RESOLVER) { - this._logLookup(resolved, parsedName); - } + this.setupRegistry(options); - if (resolved) { - _emberApplicationUtilsValidateType.default(resolved, parsedName); - } - - return resolved; - }, - - /** - Convert the string name of the form 'type:name' to - a Javascript object with the parsed aspects of the name - broken out. - @param {String} fullName the lookup string - @method parseName - @protected - */ - - parseName: function (fullName) { - return this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)); - }, - - _parseName: function (fullName) { - var _fullName$split2 = fullName.split(':'); - - var type = _fullName$split2[0]; - var fullNameWithoutType = _fullName$split2[1]; - - var name = fullNameWithoutType; - var namespace = _emberMetal.get(this, 'namespace'); - var root = namespace; - var lastSlashIndex = name.lastIndexOf('/'); - var dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null; - - if (type !== 'template' && lastSlashIndex !== -1) { - var parts = name.split('/'); - name = parts[parts.length - 1]; - var namespaceName = _emberRuntime.String.capitalize(parts.slice(0, -1).join('.')); - root = _emberRuntime.Namespace.byName(namespaceName); - } - - var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : _emberRuntime.String.classify(type); - - if (!(name && type)) { - throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); + if (options.rootElement) { + this.rootElement = options.rootElement; + } else { + this.rootElement = this.application.rootElement; } - return { - fullName: fullName, - type: type, - fullNameWithoutType: fullNameWithoutType, - dirname: dirname, - name: name, - root: root, - resolveMethodName: 'resolve' + resolveMethodName - }; - }, - - /** - Returns a human-readable description for a fullName. Used by the - Application namespace in assertions to describe the - precise name of the class that Ember is looking for, rather than - container keys. - @param {String} fullName the lookup string - @method lookupDescription - @protected - */ - lookupDescription: function (fullName) { - var parsedName = this.parseName(fullName); - var description = undefined; - - if (parsedName.type === 'template') { - return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + if (options.location) { + var router = _emberMetal.get(this, 'router'); + _emberMetal.set(router, 'location', options.location); } - description = parsedName.root + '.' + _emberRuntime.String.classify(parsedName.name).replace(/\./g, ''); + this.application.runInstanceInitializers(this); - if (parsedName.type !== 'model') { - description += _emberRuntime.String.classify(parsedName.type); + if (options.isInteractive) { + this.setupEventDispatcher(); } - return description; - }, + this._booted = true; - makeToString: function (factory, fullName) { - return factory.toString(); + return this; }, - /** - Given a parseName object (output from `parseName`), apply - the conventions expected by `Ember.Router` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method useRouterNaming - @protected - */ - useRouterNaming: function (parsedName) { - parsedName.name = parsedName.name.replace(/\./g, '_'); - if (parsedName.name === 'basic') { - parsedName.name = ''; - } + setupRegistry: function (options) { + this.constructor.setupRegistry(this.__registry__, options); }, - /** - Look up the template in Ember.TEMPLATES - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveTemplate - @protected - */ - resolveTemplate: function (parsedName) { - var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); - return _emberGlimmer.getTemplate(templateName) || _emberGlimmer.getTemplate(_emberRuntime.String.decamelize(templateName)); - }, + router: _emberMetal.computed(function () { + return this.lookup('router:main'); + }).readOnly(), /** - Lookup the view using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveView - @protected + This hook is called by the root-most Route (a.k.a. the ApplicationRoute) + when it has finished creating the root View. By default, we simply take the + view and append it to the `rootElement` specified on the Application. + In cases like FastBoot and testing, we can override this hook and implement + custom behavior, such as serializing to a string and sending over an HTTP + socket rather than appending to DOM. + @param view {Ember.View} the root-most view + @private */ - resolveView: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); + didCreateRootView: function (view) { + view.appendTo(this.rootElement); }, /** - Lookup the controller using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveController - @protected - */ - resolveController: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); - }, - /** - Lookup the route using `resolveOther` - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveRoute - @protected + Tells the router to start routing. The router will ask the location for the + current URL of the page to determine the initial URL to start routing to. + To start the app at a specific URL, call `handleURL` instead. + @private */ - resolveRoute: function (parsedName) { - this.useRouterNaming(parsedName); - return this.resolveOther(parsedName); + startRouting: function () { + var router = _emberMetal.get(this, 'router'); + router.startRouting(); + this._didSetupRouter = true; }, /** - Lookup the model on the Application namespace - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveModel - @protected + @private + Sets up the router, initializing the child router and configuring the + location before routing begins. + Because setup should only occur once, multiple calls to `setupRouter` + beyond the first call have no effect. */ - resolveModel: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.name); - var factory = _emberMetal.get(parsedName.root, className); + setupRouter: function () { + if (this._didSetupRouter) { + return; + } + this._didSetupRouter = true; - return factory; - }, - /** - Look up the specified object (from parsedName) on the appropriate - namespace (usually on the Application) - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveHelper - @protected - */ - resolveHelper: function (parsedName) { - return this.resolveOther(parsedName); + var router = _emberMetal.get(this, 'router'); + router.setupRouter(); }, + /** - Look up the specified object (from parsedName) on the appropriate - namespace (usually on the Application) - @param {Object} parsedName a parseName object with the parsed - fullName lookup string - @method resolveOther - @protected + Directs the router to route to a particular URL. This is useful in tests, + for example, to tell the app to start at a particular URL. + @param url {String} the URL the router should route to + @private */ - resolveOther: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.name) + _emberRuntime.String.classify(parsedName.type); - var factory = _emberMetal.get(parsedName.root, className); - return factory; - }, + handleURL: function (url) { + var router = _emberMetal.get(this, 'router'); - resolveMain: function (parsedName) { - var className = _emberRuntime.String.classify(parsedName.type); - return _emberMetal.get(parsedName.root, className); + this.setupRouter(); + return router.handleURL(url); }, /** - @method _logLookup - @param {Boolean} found - @param {Object} parsedName - @private + @private */ - _logLookup: function (found, parsedName) { - var symbol = undefined, - padding = undefined; + setupEventDispatcher: function () { + var dispatcher = this.lookup('event_dispatcher:main'); + var applicationCustomEvents = _emberMetal.get(this.application, 'customEvents'); + var instanceCustomEvents = _emberMetal.get(this, 'customEvents'); - if (found) { - symbol = '[✓]'; - } else { - symbol = '[ ]'; - } + var customEvents = _emberUtils.assign({}, applicationCustomEvents, instanceCustomEvents); + dispatcher.setup(customEvents, this.rootElement); - if (parsedName.fullName.length > 60) { - padding = '.'; - } else { - padding = new Array(60 - parsedName.fullName.length).join('.'); - } + return dispatcher; }, /** - Used to iterate all items of a given type. - @method knownForType - @param {String} type the type to search for - @private - */ - knownForType: function (type) { - var namespace = _emberMetal.get(this, 'namespace'); - var suffix = _emberRuntime.String.classify(type); - var typeRegexp = new RegExp(suffix + '$'); - - var known = _emberUtils.dictionary(null); - var knownKeys = Object.keys(namespace); - for (var index = 0; index < knownKeys.length; index++) { - var _name = knownKeys[index]; - - if (typeRegexp.test(_name)) { - var containerName = this.translateToContainerFullname(type, _name); - - known[containerName] = true; - } - } - - return known; + Returns the current URL of the app instance. This is useful when your + app does not update the browsers URL bar (i.e. it uses the `'none'` + location adapter). + @public + @return {String} the current URL + */ + getURL: function () { + var router = _emberMetal.get(this, 'router'); + return _emberMetal.get(router, 'url'); }, - /** - Converts provided name from the backing namespace into a container lookup name. - Examples: - App.FooBarHelper -> helper:foo-bar - App.THelper -> helper:t - @method translateToContainerFullname - @param {String} type - @param {String} name - @private - */ - - translateToContainerFullname: function (type, name) { - var suffix = _emberRuntime.String.classify(type); - var namePrefix = name.slice(0, suffix.length * -1); - var dasherizedName = _emberRuntime.String.dasherize(namePrefix); - - return type + ':' + dasherizedName; - } - }); -}); -enifed('ember-application/utils/validate-type', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-application - */ + // `instance.visit(url)` should eventually replace `instance.handleURL()`; + // the test helpers can probably be switched to use this implementation too - 'use strict'; + /** + Navigate the instance to a particular URL. This is useful in tests, for + example, or to tell the app to start at a particular URL. This method + returns a promise that resolves with the app instance when the transition + is complete, or rejects if the transion was aborted due to an error. + @public + @param url {String} the destination URL + @return {Promise} + */ + visit: function (url) { + var _this = this; - exports.default = validateType; + this.setupRouter(); - var VALIDATED_TYPES = { - route: ['assert', 'isRouteFactory', 'Ember.Route'], - component: ['deprecate', 'isComponentFactory', 'Ember.Component'], - view: ['deprecate', 'isViewFactory', 'Ember.View'], - service: ['deprecate', 'isServiceFactory', 'Ember.Service'] - }; + var bootOptions = this.__container__.lookup('-environment:main'); - function validateType(resolvedType, parsedName) { - var validationAttributes = VALIDATED_TYPES[parsedName.type]; + var router = _emberMetal.get(this, 'router'); - if (!validationAttributes) { - return; - } + var handleTransitionResolve = function () { + if (!bootOptions.options.shouldRender) { + // No rendering is needed, and routing has completed, simply return. + return _this; + } else { + return new _emberRuntime.RSVP.Promise(function (resolve) { + // Resolve once rendering is completed. `router.handleURL` returns the transition (as a thennable) + // which resolves once the transition is completed, but the transition completion only queues up + // a scheduled revalidation (into the `render` queue) in the Renderer. + // + // This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed. + _emberMetal.run.schedule('afterRender', null, resolve, _this); + }); + } + }; - var action = validationAttributes[0]; - var factoryFlag = validationAttributes[1]; - var expectedType = validationAttributes[2]; + var handleTransitionReject = function (error) { + if (error.error) { + throw error.error; + } else if (error.name === 'TransitionAborted' && router.router.activeTransition) { + return router.router.activeTransition.then(handleTransitionResolve, handleTransitionReject); + } else if (error.name === 'TransitionAborted') { + throw new Error(error.message); + } else { + throw error; + } + }; - if (action === 'deprecate') {} else {} - } -}); -enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - 'use strict'; + var location = _emberMetal.get(router, 'location'); - function K() {} + // Keeps the location adapter's internal URL in-sync + location.setURL(url); - function consoleMethod(name) { - var consoleObj = undefined; - if (_emberEnvironment.context.imports.console) { - consoleObj = _emberEnvironment.context.imports.console; - } else if (typeof console !== 'undefined') { - consoleObj = console; + // getURL returns the set url with the rootURL stripped off + return router.handleURL(location.getURL()).then(handleTransitionResolve, handleTransitionReject); } + }); - var method = typeof consoleObj === 'object' ? consoleObj[name] : null; - - if (typeof method !== 'function') { - return; - } + ApplicationInstance.reopenClass({ + /** + @private + @method setupRegistry + @param {Registry} registry + @param {BootOptions} options + */ + setupRegistry: function (registry) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - if (typeof method.bind === 'function') { - return method.bind(consoleObj); - } + if (!options.toEnvironment) { + options = new BootOptions(options); + } - return function () { - method.apply(consoleObj, arguments); - }; - } + registry.register('-environment:main', options.toEnvironment(), { instantiate: false }); + registry.register('service:-document', options.document, { instantiate: false }); - function assertPolyfill(test, message) { - if (!test) { - try { - // attempt to preserve the stack - throw new Error('assertion failed: ' + message); - } catch (error) { - setTimeout(function () { - throw error; - }, 0); - } + this._super(registry, options); } - } + }); /** - Inside Ember-Metal, simply uses the methods from `imports.console`. - Override this to provide more robust logging functionality. + A list of boot-time configuration options for customizing the behavior of + an `Ember.ApplicationInstance`. - @class Logger - @namespace Ember + This is an interface class that exists purely to document the available + options; you do not need to construct it manually. Simply pass a regular + JavaScript object containing the desired options into methods that require + one of these options object: + + ```javascript + MyApp.visit("/", { location: "none", rootElement: "#container" }); + ``` + + Not all combinations of the supported options are valid. See the documentation + on `Ember.Application#visit` for the supported configurations. + + Internal, experimental or otherwise unstable flags are marked as private. + + @class BootOptions + @namespace Ember.ApplicationInstance @public */ - exports.default = { + BootOptions = function BootOptions() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.log('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method log - @for Ember.Logger - @param {*} arguments - @public + Provide a specific instance of jQuery. This is useful in conjunction with + the `document` option, as it allows you to use a copy of `jQuery` that is + appropriately bound to the foreign `document` (e.g. a jsdom). + This is highly experimental and support very incomplete at the moment. + @property jQuery + @type Object + @default auto-detected + @private */ - log: consoleMethod('log') || K, + this.jQuery = _emberViews.jQuery; // This default is overridable below /** - Prints the arguments to the console with a warning icon. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - Ember.Logger.warn('Something happened!'); - // "Something happened!" will be printed to the console with a warning icon. - ``` - @method warn - @for Ember.Logger - @param {*} arguments - @public + Interactive mode: whether we need to set up event delegation and invoke + lifecycle callbacks on Components. + @property isInteractive + @type boolean + @default auto-detected + @private */ - warn: consoleMethod('warn') || K, + this.isInteractive = _emberEnvironment.environment.hasDOM; // This default is overridable below /** - Prints the arguments to the console with an error icon, red text and a stack trace. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - Ember.Logger.error('Danger! Danger!'); - // "Danger! Danger!" will be printed to the console in red text. - ``` - @method error - @for Ember.Logger - @param {*} arguments - @public + Run in a full browser environment. + When this flag is set to `false`, it will disable most browser-specific + and interactive features. Specifically: + * It does not use `jQuery` to append the root view; the `rootElement` + (either specified as a subsequent option or on the application itself) + must already be an `Element` in the given `document` (as opposed to a + string selector). + * It does not set up an `EventDispatcher`. + * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). + * It sets the `location` option to `"none"`. (If you would like to use + the location adapter specified in the app's router instead, you can also + specify `{ location: null }` to specifically opt-out.) + @property isBrowser + @type boolean + @default auto-detected + @public */ - error: consoleMethod('error') || K, + if (options.isBrowser !== undefined) { + this.isBrowser = !!options.isBrowser; + } else { + this.isBrowser = _emberEnvironment.environment.hasDOM; + } - /** - Logs the arguments to the console. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.info('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method info - @for Ember.Logger - @param {*} arguments - @public - */ - info: consoleMethod('info') || K, + if (!this.isBrowser) { + this.jQuery = null; + this.isInteractive = false; + this.location = 'none'; + } /** - Logs the arguments to the console in blue text. - You can pass as many arguments as you want and they will be joined together with a space. - ```javascript - var foo = 1; - Ember.Logger.debug('log value of foo:', foo); - // "log value of foo: 1" will be printed to the console - ``` - @method debug - @for Ember.Logger - @param {*} arguments - @public + Disable rendering completely. + When this flag is set to `true`, it will disable the entire rendering + pipeline. Essentially, this puts the app into "routing-only" mode. No + templates will be rendered, and no Components will be created. + @property shouldRender + @type boolean + @default true + @public */ - debug: consoleMethod('debug') || consoleMethod('info') || K, + if (options.shouldRender !== undefined) { + this.shouldRender = !!options.shouldRender; + } else { + this.shouldRender = true; + } + + if (!this.shouldRender) { + this.jQuery = null; + this.isInteractive = false; + } /** - If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. - ```javascript - Ember.Logger.assert(true); // undefined - Ember.Logger.assert(true === false); // Throws an Assertion failed error. - Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message. - ``` - @method assert - @for Ember.Logger - @param {Boolean} bool Value to test - @param {String} message Assertion message on failed - @public + If present, render into the given `Document` object instead of the + global `window.document` object. + In practice, this is only useful in non-browser environment or in + non-interactive mode, because Ember's `jQuery` dependency is + implicitly bound to the current document, causing event delegation + to not work properly when the app is rendered into a foreign + document object (such as an iframe's `contentDocument`). + In non-browser mode, this could be a "`Document`-like" object as + Ember only interact with a small subset of the DOM API in non- + interactive mode. While the exact requirements have not yet been + formalized, the `SimpleDOM` library's implementation is known to + work. + @property document + @type Document + @default the global `document` object + @public */ - assert: consoleMethod('assert') || assertPolyfill - }; -}); -enifed('ember-environment/global', ['exports'], function (exports) { - /* globals global, window, self, mainContext */ - - // from lodash to catch fake globals - 'use strict'; - - function checkGlobal(value) { - return value && value.Object === Object ? value : undefined; - } - - // element ids can ruin global miss checks - function checkElementIdShadowing(value) { - return value && value.nodeType === undefined ? value : undefined; - } - - // export real global - exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper - new Function('return this')(); - // eval outside of strict mode -}); -enifed('ember-environment/index', ['exports', 'ember-environment/global', 'ember-environment/utils'], function (exports, _emberEnvironmentGlobal, _emberEnvironmentUtils) { - /* globals module */ - 'use strict'; - - /** - 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 - backwards compatibility with earlier versions of Ember). The `EmberENV` - hash must be created before loading Ember. - - @class EmberENV - @type Object - @public - */ - var ENV = typeof _emberEnvironmentGlobal.default.EmberENV === 'object' && _emberEnvironmentGlobal.default.EmberENV || typeof _emberEnvironmentGlobal.default.ENV === 'object' && _emberEnvironmentGlobal.default.ENV || {}; - - exports.ENV = ENV; - // ENABLE_ALL_FEATURES was documented, but you can't actually enable non optional features. - if (ENV.ENABLE_ALL_FEATURES) { - ENV.ENABLE_OPTIONAL_FEATURES = true; - } - - /** - Determines whether Ember should add to `Array`, `Function`, and `String` - native object prototypes, a few extra methods in order to provide a more - friendly API. - - We generally recommend leaving this option set to true however, if you need - to turn it off, you can add the configuration property - `EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`. - - Note, when disabled (the default configuration for Ember Addons), you will - instead have to access all methods and functions from the Ember - namespace. - - @property EXTEND_PROTOTYPES - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.EXTEND_PROTOTYPES = _emberEnvironmentUtils.normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); - - /** - The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log - a full stack trace during deprecation warnings. - - @property LOG_STACKTRACE_ON_DEPRECATION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_STACKTRACE_ON_DEPRECATION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); - - /** - The `LOG_VERSION` property, when true, tells Ember to log versions of all - dependent libraries in use. - - @property LOG_VERSION - @type Boolean - @default true - @for EmberENV - @public - */ - ENV.LOG_VERSION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_VERSION); - - // default false - ENV.MODEL_FACTORY_INJECTIONS = _emberEnvironmentUtils.defaultFalse(ENV.MODEL_FACTORY_INJECTIONS); + if (options.document) { + this.document = options.document; + } else { + this.document = typeof document !== 'undefined' ? document : null; + } - /** - Debug parameter you can turn on. This will log all bindings that fire to - the console. This should be disabled in production code. Note that you - can also enable this from the console or temporarily. - - @property LOG_BINDINGS - @for EmberENV - @type Boolean - @default false - @public - */ - ENV.LOG_BINDINGS = _emberEnvironmentUtils.defaultFalse(ENV.LOG_BINDINGS); + /** + If present, overrides the application's `rootElement` property on + the instance. This is useful for testing environment, where you + might want to append the root view to a fixture area. + In non-browser mode, because Ember does not have access to jQuery, + this options must be specified as a DOM `Element` object instead of + a selector string. + See the documentation on `Ember.Applications`'s `rootElement` for + details. + @property rootElement + @type String|Element + @default null + @public + */ + if (options.rootElement) { + this.rootElement = options.rootElement; + } - ENV.RAISE_ON_DEPRECATION = _emberEnvironmentUtils.defaultFalse(ENV.RAISE_ON_DEPRECATION); + // Set these options last to give the user a chance to override the + // defaults from the "combo" options like `isBrowser` (although in + // practice, the resulting combination is probably invalid) - // check if window exists and actually is the global - var hasDOM = typeof window !== 'undefined' && window === _emberEnvironmentGlobal.default && window.document && window.document.createElement && !ENV.disableBrowserEnvironment; // is this a public thing? + /** + If present, overrides the router's `location` property with this + value. This is useful for environments where trying to modify the + URL would be inappropriate. + @property location + @type string + @default null + @public + */ + if (options.location !== undefined) { + this.location = options.location; + } - // legacy imports/exports/lookup stuff (should we keep this??) - var originalContext = _emberEnvironmentGlobal.default.Ember || {}; + if (options.jQuery !== undefined) { + this.jQuery = options.jQuery; + } - var context = { - // import jQuery - imports: originalContext.imports || _emberEnvironmentGlobal.default, - // export Ember - exports: originalContext.exports || _emberEnvironmentGlobal.default, - // search for Namespaces - lookup: originalContext.lookup || _emberEnvironmentGlobal.default + if (options.isInteractive !== undefined) { + this.isInteractive = !!options.isInteractive; + } }; - exports.context = context; - // TODO: cleanup single source of truth issues with this stuff - var environment = hasDOM ? { - hasDOM: true, - isChrome: !!window.chrome && !window.opera, - isFirefox: typeof InstallTrigger !== 'undefined', - isPhantom: !!window.callPhantom, - location: window.location, - history: window.history, - userAgent: window.navigator.userAgent, - window: window - } : { - hasDOM: false, - isChrome: false, - isFirefox: false, - isPhantom: false, - location: null, - history: null, - userAgent: 'Lynx (textmode)', - window: null + BootOptions.prototype.toEnvironment = function () { + var env = _emberUtils.assign({}, _emberEnvironment.environment); + // For compatibility with existing code + env.hasDOM = this.isBrowser; + env.isInteractive = this.isInteractive; + env.options = this; + return env; }; - exports.environment = environment; -}); -enifed("ember-environment/utils", ["exports"], function (exports) { - "use strict"; - - exports.defaultTrue = defaultTrue; - exports.defaultFalse = defaultFalse; - exports.normalizeExtendPrototypes = normalizeExtendPrototypes; - - function defaultTrue(v) { - return v === false ? false : true; - } - function defaultFalse(v) { - return v === true ? true : false; - } - - function normalizeExtendPrototypes(obj) { - if (obj === false) { - return { String: false, Array: false, Function: false }; - } else if (!obj || obj === true) { - return { String: true, Array: true, Function: true }; - } else { + Object.defineProperty(ApplicationInstance.prototype, 'container', { + configurable: true, + enumerable: false, + get: function () { + var instance = this; return { - String: defaultTrue(obj.String), - Array: defaultTrue(obj.Array), - Function: defaultTrue(obj.Function) + lookup: function () { + return instance.lookup.apply(instance, arguments); + } }; } - } -}); -enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { - 'use strict'; + }); + + Object.defineProperty(ApplicationInstance.prototype, 'registry', { + configurable: true, + enumerable: false, + get: function () { + return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'ApplicationInstance'); + } + }); + exports.default = ApplicationInstance; +}); +enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember-environment', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-routing', 'ember-application/system/application-instance', 'container', 'ember-application/system/engine', 'ember-glimmer'], function (exports, _emberUtils, _emberEnvironment, _emberMetal, _emberRuntime, _emberViews, _emberRouting, _emberApplicationSystemApplicationInstance, _container, _emberApplicationSystemEngine, _emberGlimmer) { /** @module ember - @submodule ember-extension-support + @submodule ember-application */ + 'use strict'; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + + var librariesRegistered = false; /** - The `ContainerDebugAdapter` helps the container and resolver interface - with tools that debug Ember such as the - [Ember Extension](https://github.com/tildeio/ember-extension) - for Chrome and Firefox. + An instance of `Ember.Application` is the starting point for every Ember + application. It helps to instantiate, initialize and coordinate the many + objects that make up your app. - This class can be extended by a custom resolver implementer - to override some of the methods with library-specific code. + Each Ember app has one and only one `Ember.Application` object. In fact, the + very first thing you should do in your application is create the instance: - The methods likely to be overridden are: + ```javascript + window.App = Ember.Application.create(); + ``` - * `canCatalogEntriesByType` - * `catalogEntriesByType` + Typically, the application object is the only global variable. All other + classes in your app should be properties on the `Ember.Application` instance, + which highlights its first role: a global namespace. - The adapter will need to be registered - in the application's container as `container-debug-adapter:main`. + For example, if you define a view class, it might look like this: - Example: + ```javascript + App.MyView = Ember.View.extend(); + ``` + + By default, calling `Ember.Application.create()` will automatically initialize + your application by calling the `Ember.Application.initialize()` method. If + you need to delay initialization, you can call your app's `deferReadiness()` + method. When you are ready for your app to be initialized, call its + `advanceReadiness()` method. + + You can define a `ready` method on the `Ember.Application` instance, which + will be run by Ember when the application is initialized. + + Because `Ember.Application` inherits from `Ember.Namespace`, any classes + you create will have useful string representations when calling `toString()`. + See the `Ember.Namespace` documentation for more information. + + While you can think of your `Ember.Application` as a container that holds the + other classes in your application, there are several other responsibilities + going on under-the-hood that you may want to understand. + + ### Event Delegation + + Ember uses a technique called _event delegation_. This allows the framework + to set up a global, shared event listener instead of requiring each view to + do it manually. For example, instead of each view registering its own + `mousedown` listener on its associated element, Ember sets up a `mousedown` + listener on the `body`. + + If a `mousedown` event occurs, Ember will look at the target of the event and + start walking up the DOM node tree, finding corresponding views and invoking + their `mouseDown` method as it goes. + + `Ember.Application` has a number of default events that it listens for, as + well as a mapping from lowercase events to camel-cased view method names. For + example, the `keypress` event causes the `keyPress` method on the view to be + called, the `dblclick` event causes `doubleClick` to be called, and so on. + + If there is a bubbling browser event that Ember does not listen for by + default, you can specify custom events and their corresponding view method + names by setting the application's `customEvents` property: ```javascript - Application.initializer({ - name: "containerDebugAdapter", + let App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: 'paste' + } + }); + ``` - initialize(application) { - application.register('container-debug-adapter:main', require('app/container-debug-adapter')); + To prevent Ember from setting up a listener for a default event, + specify the event name with a `null` value in the `customEvents` + property: + + ```javascript + let App = Ember.Application.create({ + customEvents: { + // prevent listeners for mouseenter/mouseleave events + mouseenter: null, + mouseleave: null } }); ``` - @class ContainerDebugAdapter + By default, the application sets up these event listeners on the document + body. However, in cases where you are embedding an Ember application inside + an existing page, you may want it to set up the listeners on an element + inside the body. + + For example, if only events inside a DOM element with the ID of `ember-app` + should be delegated, set your application's `rootElement` property: + + ```javascript + let App = Ember.Application.create({ + rootElement: '#ember-app' + }); + ``` + + The `rootElement` can be either a DOM element or a jQuery-compatible selector + string. Note that *views appended to the DOM outside the root element will + not receive events.* If you specify a custom root element, make sure you only + append views inside it! + + To learn more about the events Ember components use, see + [components/handling-events](https://guides.emberjs.com/v2.6.0/components/handling-events/#toc_event-names). + + ### Initializers + + Libraries on top of Ember can add initializers, like so: + + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + + initialize: function(application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + + Initializers provide an opportunity to access the internal registry, which + organizes the different components of an Ember application. Additionally + they provide a chance to access the instantiated application. Beyond + being used for libraries, initializers are also a great way to organize + dependency injection or setup in your own application. + + ### Routing + + In addition to creating your application's router, `Ember.Application` is + also responsible for telling the router when to start routing. Transitions + between routes can be logged with the `LOG_TRANSITIONS` flag, and more + detailed intra-transition logging can be logged with + the `LOG_TRANSITIONS_INTERNAL` flag: + + ```javascript + let App = Ember.Application.create({ + LOG_TRANSITIONS: true, // basic logging of successful transitions + LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps + }); + ``` + + By default, the router will begin trying to translate the current URL into + application state once the browser emits the `DOMContentReady` event. If you + need to defer routing, you can call the application's `deferReadiness()` + method. Once routing can begin, call the `advanceReadiness()` method. + + If there is any setup required before routing begins, you can implement a + `ready()` method on your app that will be invoked immediately before routing + begins. + + @class Application @namespace Ember - @extends Ember.Object - @since 1.5.0 + @extends Ember.Engine + @uses RegistryProxyMixin @public */ - exports.default = _emberRuntime.Object.extend({ + + var Application = _emberApplicationSystemEngine.default.extend({ /** - The resolver instance of the application - being debugged. This property will be injected - on creation. - @property resolver - @default null + The root DOM element of the Application. This can be specified as an + element or a + [jQuery-compatible selector string](http://api.jquery.com/category/selectors/). + This is the element that will be passed to the Application's, + `eventDispatcher`, which sets up the listeners for event delegation. Every + view in your application should be a child of the element you specify here. + @property rootElement + @type DOMElement + @default 'body' @public */ - resolver: null, + rootElement: 'body', /** - Returns true if it is possible to catalog a list of available - classes in the resolver for a given type. - @method canCatalogEntriesByType - @param {String} type The type. e.g. "model", "controller", "route". - @return {boolean} whether a list is available for this type. + The `Ember.EventDispatcher` responsible for delegating events to this + application's views. + The event dispatcher is created by the application at initialization time + and sets up event listeners on the DOM element described by the + application's `rootElement` property. + See the documentation for `Ember.EventDispatcher` for more information. + @property eventDispatcher + @type Ember.EventDispatcher + @default null @public */ - canCatalogEntriesByType: function (type) { - if (type === 'model' || type === 'template') { - return false; - } - - return true; - }, + eventDispatcher: null, /** - Returns the available classes a given type. - @method catalogEntriesByType - @param {String} type The type. e.g. "model", "controller", "route". - @return {Array} An array of strings. + The DOM events for which the event dispatcher should listen. + By default, the application's `Ember.EventDispatcher` listens + for a set of standard DOM events, such as `mousedown` and + `keyup`, and delegates them to your application's `Ember.View` + instances. + If you would like additional bubbling events to be delegated to your + views, set your `Ember.Application`'s `customEvents` property + to a hash containing the DOM event name as the key and the + corresponding view method name as the value. Setting an event to + a value of `null` will prevent a default event listener from being + added for that event. + To add new events to be listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + // add support for the paste event + paste: 'paste' + } + }); + ``` + To prevent default events from being listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + // remove support for mouseenter / mouseleave events + mouseenter: null, + mouseleave: null + } + }); + ``` + @property customEvents + @type Object + @default null @public */ - catalogEntriesByType: function (type) { - var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); - var types = _emberRuntime.A(); - var typeSuffixRegex = new RegExp(_emberRuntime.String.classify(type) + '$'); + customEvents: null, - namespaces.forEach(function (namespace) { - if (namespace !== _emberMetal.default) { - for (var key in namespace) { - if (!namespace.hasOwnProperty(key)) { - continue; - } - if (typeSuffixRegex.test(key)) { - var klass = namespace[key]; - if (_emberRuntime.typeOf(klass) === 'class') { - types.push(_emberRuntime.String.dasherize(key.replace(typeSuffixRegex, ''))); - } - } - } - } + /** + Whether the application should automatically start routing and render + templates to the `rootElement` on DOM ready. While default by true, + other environments such as FastBoot or a testing harness can set this + property to `false` and control the precise timing and behavior of the boot + process. + @property autoboot + @type Boolean + @default true + @private + */ + autoboot: true, + + /** + Whether the application should be configured for the legacy "globals mode". + Under this mode, the Application object serves as a global namespace for all + classes. + ```javascript + let App = Ember.Application.create({ + ... }); - return types; - } - }); -}); -// Ember as namespace -enifed('ember-extension-support/data_adapter', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplication) { - 'use strict'; + App.Router.reopen({ + location: 'none' + }); + App.Router.map({ + ... + }); + App.MyComponent = Ember.Component.extend({ + ... + }); + ``` + This flag also exposes other internal APIs that assumes the existence of + a special "default instance", like `App.__container__.lookup(...)`. + This option is currently not configurable, its value is derived from + the `autoboot` flag – disabling `autoboot` also implies opting-out of + globals mode support, although they are ultimately orthogonal concerns. + Some of the global modes features are already deprecated in 1.x. The + existence of this flag is to untangle the globals mode code paths from + the autoboot code paths, so that these legacy features can be reviewed + for deprecation/removal separately. + Forcing the (autoboot=true, _globalsMode=false) here and running the tests + would reveal all the places where we are still relying on these legacy + behavior internally (mostly just tests). + @property _globalsMode + @type Boolean + @default true + @private + */ + _globalsMode: true, - /** - @module ember - @submodule ember-extension-support - */ + init: function (options) { + this._super.apply(this, arguments); - /** - The `DataAdapter` helps a data persistence library - interface with tools that debug Ember such - as the [Ember Extension](https://github.com/tildeio/ember-extension) - for Chrome and Firefox. - - This class will be extended by a persistence library - which will override some of the methods with - library-specific code. - - The methods likely to be overridden are: - - * `getFilters` - * `detect` - * `columnsForType` - * `getRecords` - * `getRecordColumnValues` - * `getRecordKeywords` - * `getRecordFilterValues` - * `getRecordColor` - * `observeRecord` - - The adapter will need to be registered - in the application's container as `dataAdapter:main`. - - Example: - - ```javascript - Application.initializer({ - name: "data-adapter", - - initialize: function(application) { - application.register('data-adapter:main', DS.DataAdapter); + if (!this.$) { + this.$ = _emberViews.jQuery; } - }); - ``` - - @class DataAdapter - @namespace Ember - @extends EmberObject - @public - */ - exports.default = _emberRuntime.Object.extend({ - init: function () { - this._super.apply(this, arguments); - this.releaseMethods = _emberRuntime.A(); - }, - /** - The container-debug-adapter which is used - to list all models. - @property containerDebugAdapter - @default undefined - @since 1.5.0 - @public - **/ - containerDebugAdapter: undefined, + registerLibraries(); - /** - The number of attributes to send - as columns. (Enough to make the record - identifiable). - @private - @property attributeLimit - @default 3 - @since 1.3.0 - */ - attributeLimit: 3, + // Start off the number of deferrals at 1. This will be decremented by + // the Application's own `boot` method. + this._readinessDeferrals = 1; + this._booted = false; - /** - Ember Data > v1.0.0-beta.18 - requires string model names to be passed - around instead of the actual factories. - This is a stamp for the Ember Inspector - to differentiate between the versions - to be able to support older versions too. - @public - @property acceptsModelName - */ - acceptsModelName: true, + this.autoboot = this._globalsMode = !!this.autoboot; + + if (this._globalsMode) { + this._prepareForGlobalsMode(); + } + + if (this.autoboot) { + this.waitForDOMReady(); + } + }, /** - Stores all methods that clear observers. - These methods will be called on destruction. + Create an ApplicationInstance for this application. @private - @property releaseMethods - @since 1.3.0 + @method buildInstance + @return {Ember.ApplicationInstance} the application instance */ - releaseMethods: _emberRuntime.A(), + buildInstance: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - /** - Specifies how records can be filtered. - Records returned will need to have a `filterValues` - property with a key for every name in the returned array. - @public - @method getFilters - @return {Array} List of objects defining filters. - The object should have a `name` and `desc` property. - */ - getFilters: function () { - return _emberRuntime.A(); + options.base = this; + options.application = this; + return _emberApplicationSystemApplicationInstance.default.create(options); }, /** - Fetch the model types and observe them for changes. - @public - @method watchModelTypes - @param {Function} typesAdded Callback to call to add types. - Takes an array of objects containing wrapped types (returned from `wrapModelType`). - @param {Function} typesUpdated Callback to call when a type has changed. - Takes an array of objects containing wrapped types. - @return {Function} Method to call to remove all observers + Enable the legacy globals mode by allowing this application to act + as a global namespace. See the docs on the `_globalsMode` property + for details. + Most of these features are already deprecated in 1.x, so we can + stop using them internally and try to remove them. + @private + @method _prepareForGlobalsMode */ - watchModelTypes: function (typesAdded, typesUpdated) { - var _this = this; - - var modelTypes = this.getModelTypes(); - var releaseMethods = _emberRuntime.A(); - var typesToSend = undefined; + _prepareForGlobalsMode: function () { + // Create subclass of Ember.Router for this Application instance. + // This is to ensure that someone reopening `App.Router` does not + // tamper with the default `Ember.Router`. + this.Router = (this.Router || _emberRouting.Router).extend(); - typesToSend = modelTypes.map(function (type) { - var klass = type.klass; - var wrapped = _this.wrapModelType(klass, type.name); - releaseMethods.push(_this.observeModelType(type.name, typesUpdated)); - return wrapped; - }); + this._buildDeprecatedInstance(); + }, - typesAdded(typesToSend); + /* + Build the deprecated instance for legacy globals mode support. + Called when creating and resetting the application. + This is orthogonal to autoboot: the deprecated instance needs to + be created at Application construction (not boot) time to expose + App.__container__. If autoboot sees that this instance exists, + it will continue booting it to avoid doing unncessary work (as + opposed to building a new instance at boot time), but they are + otherwise unrelated. + @private + @method _buildDeprecatedInstance + */ + _buildDeprecatedInstance: function () { + // Build a default instance + var instance = this.buildInstance(); - var release = function () { - releaseMethods.forEach(function (fn) { - return fn(); - }); - _this.releaseMethods.removeObject(release); - }; - this.releaseMethods.pushObject(release); - return release; + // Legacy support for App.__container__ and other global methods + // on App that rely on a single, default instance. + this.__deprecatedInstance__ = instance; + this.__container__ = instance.__container__; }, - _nameToClass: function (type) { - if (typeof type === 'string') { - type = _emberUtils.getOwner(this)._lookupFactory('model:' + type); + /** + Automatically kick-off the boot process for the application once the + DOM has become ready. + The initialization itself is scheduled on the actions queue which + ensures that code-loading finishes before booting. + If you are asynchronously loading code, you should call `deferReadiness()` + to defer booting, and then call `advanceReadiness()` once all of your code + has finished loading. + @private + @method waitForDOMReady + */ + waitForDOMReady: function () { + if (!this.$ || this.$.isReady) { + _emberMetal.run.schedule('actions', this, 'domReady'); + } else { + this.$().ready(_emberMetal.run.bind(this, 'domReady')); } - return type; }, /** - Fetch the records of a given type and observe them for changes. - @public - @method watchRecords - @param {String} modelName The model name. - @param {Function} recordsAdded Callback to call to add records. - Takes an array of objects containing wrapped records. - The object should have the following properties: - columnValues: {Object} The key and value of a table cell. - object: {Object} The actual record object. - @param {Function} recordsUpdated Callback to call when a record has changed. - Takes an array of objects containing wrapped records. - @param {Function} recordsRemoved Callback to call when a record has removed. - Takes the following parameters: - index: The array index where the records were removed. - count: The number of records removed. - @return {Function} Method to call to remove all observers. + This is the autoboot flow: + 1. Boot the app by calling `this.boot()` + 2. Create an instance (or use the `__deprecatedInstance__` in globals mode) + 3. Boot the instance by calling `instance.boot()` + 4. Invoke the `App.ready()` callback + 5. Kick-off routing on the instance + Ideally, this is all we would need to do: + ```javascript + _autoBoot() { + this.boot().then(() => { + let instance = (this._globalsMode) ? this.__deprecatedInstance__ : this.buildInstance(); + return instance.boot(); + }).then((instance) => { + App.ready(); + instance.startRouting(); + }); + } + ``` + Unfortunately, we cannot actually write this because we need to participate + in the "synchronous" boot process. While the code above would work fine on + the initial boot (i.e. DOM ready), when `App.reset()` is called, we need to + boot a new instance synchronously (see the documentation on `_bootSync()` + for details). + Because of this restriction, the actual logic of this method is located + inside `didBecomeReady()`. + @private + @method domReady */ - watchRecords: function (modelName, recordsAdded, recordsUpdated, recordsRemoved) { - var _this2 = this; - - var releaseMethods = _emberRuntime.A(); - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); - var release = undefined; - - function recordUpdated(updatedRecord) { - recordsUpdated([updatedRecord]); + domReady: function () { + if (this.isDestroyed) { + return; } - var recordsToSend = records.map(function (record) { - releaseMethods.push(_this2.observeRecord(record, recordUpdated)); - return _this2.wrapRecord(record); - }); - - var contentDidChange = function (array, idx, removedCount, addedCount) { - for (var i = idx; i < idx + addedCount; i++) { - var record = _emberRuntime.objectAt(array, i); - var wrapped = _this2.wrapRecord(record); - releaseMethods.push(_this2.observeRecord(record, recordUpdated)); - recordsAdded([wrapped]); - } - - if (removedCount) { - recordsRemoved(idx, removedCount); - } - }; - - var observer = { didChange: contentDidChange, willChange: function () { - return this; - } }; - _emberRuntime.addArrayObserver(records, this, observer); - - release = function () { - releaseMethods.forEach(function (fn) { - return fn(); - }); - _emberRuntime.removeArrayObserver(records, _this2, observer); - _this2.releaseMethods.removeObject(release); - }; - - recordsAdded(recordsToSend); + this._bootSync(); - this.releaseMethods.pushObject(release); - return release; + // Continues to `didBecomeReady` }, /** - Clear all observers before destruction - @private - @method willDestroy - */ - willDestroy: function () { - this._super.apply(this, arguments); - this.releaseMethods.forEach(function (fn) { - return fn(); + Use this to defer readiness until some condition is true. + Example: + ```javascript + let App = Ember.Application.create(); + App.deferReadiness(); + // Ember.$ is a reference to the jQuery object/function + Ember.$.getJSON('/auth-token', function(token) { + App.token = token; + App.advanceReadiness(); }); + ``` + This allows you to perform asynchronous setup logic and defer + booting your application until the setup has finished. + However, if the setup requires a loading UI, it might be better + to use the router for this purpose. + @method deferReadiness + @public + */ + deferReadiness: function () { + this._readinessDeferrals++; }, /** - Detect whether a class is a model. - Test that against the model class - of your persistence library. - @private - @method detect - @param {Class} klass The class to test. - @return boolean Whether the class is a model class or not. + Call `advanceReadiness` after any asynchronous setup logic has completed. + Each call to `deferReadiness` must be matched by a call to `advanceReadiness` + or the application will never become ready and routing will not begin. + @method advanceReadiness + @see {Ember.Application#deferReadiness} + @public */ - detect: function (klass) { - return false; + advanceReadiness: function () { + this._readinessDeferrals--; + + if (this._readinessDeferrals === 0) { + _emberMetal.run.once(this, this.didBecomeReady); + } }, /** - Get the columns for a given model type. + Initialize the application and return a promise that resolves with the `Ember.Application` + object when the boot process is complete. + Run any application initializers and run the application load hook. These hooks may + choose to defer readiness. For example, an authentication hook might want to defer + readiness until the auth token has been retrieved. + By default, this method is called automatically on "DOM ready"; however, if autoboot + is disabled, this is automatically called when the first application instance is + created via `visit`. @private - @method columnsForType - @param {Class} type The model type. - @return {Array} An array of columns of the following format: - name: {String} The name of the column. - desc: {String} Humanized description (what would show in a table column name). + @method boot + @return {Promise} */ - columnsForType: function (type) { - return _emberRuntime.A(); + boot: function () { + if (this._bootPromise) { + return this._bootPromise; + } + + try { + this._bootSync(); + } catch (_) { + // Ignore th error: in the asynchronous boot path, the error is already reflected + // in the promise rejection + } + + return this._bootPromise; }, /** - Adds observers to a model type class. + Unfortunately, a lot of existing code assumes the booting process is + "synchronous". Specifically, a lot of tests assumes the last call to + `app.advanceReadiness()` or `app.reset()` will result in the app being + fully-booted when the current runloop completes. + We would like new code (like the `visit` API) to stop making this assumption, + so we created the asynchronous version above that returns a promise. But until + we have migrated all the code, we would have to expose this method for use + *internally* in places where we need to boot an app "synchronously". @private - @method observeModelType - @param {String} modelName The model type name. - @param {Function} typesUpdated Called when a type is modified. - @return {Function} The function to call to remove observers. */ + _bootSync: function () { + if (this._booted) { + return; + } - observeModelType: function (modelName, typesUpdated) { - var _this3 = this; - - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); - - function onChange() { - typesUpdated([this.wrapModelType(klass, modelName)]); + // Even though this returns synchronously, we still need to make sure the + // boot promise exists for book-keeping purposes: if anything went wrong in + // the boot process, we need to store the error as a rejection on the boot + // promise so that a future caller of `boot()` can tell what failed. + var defer = this._bootResolver = new _emberRuntime.RSVP.defer(); + this._bootPromise = defer.promise; + + try { + this.runInitializers(); + _emberRuntime.runLoadHooks('application', this); + this.advanceReadiness(); + // Continues to `didBecomeReady` + } catch (error) { + // For the asynchronous boot path + defer.reject(error); + + // For the synchronous boot path + throw error; } + }, - var observer = { - didChange: function () { - _emberMetal.run.scheduleOnce('actions', this, onChange); - }, - willChange: function () { - return this; + /** + Reset the application. This is typically used only in tests. It cleans up + the application in the following order: + 1. Deactivate existing routes + 2. Destroy all objects in the container + 3. Create a new application container + 4. Re-route to the existing url + Typical Example: + ```javascript + let App; + run(function() { + App = Ember.Application.create(); + }); + module('acceptance test', { + setup: function() { + App.reset(); } - }; + }); + test('first test', function() { + // App is freshly reset + }); + test('second test', function() { + // App is again freshly reset + }); + ``` + Advanced Example: + Occasionally you may want to prevent the app from initializing during + setup. This could enable extra configuration, or enable asserting prior + to the app becoming ready. + ```javascript + let App; + run(function() { + App = Ember.Application.create(); + }); + module('acceptance test', { + setup: function() { + run(function() { + App.reset(); + App.deferReadiness(); + }); + } + }); + test('first test', function() { + ok(true, 'something before app is initialized'); + run(function() { + App.advanceReadiness(); + }); + ok(true, 'something after app is initialized'); + }); + ``` + @method reset + @public + */ + reset: function () { - _emberRuntime.addArrayObserver(records, this, observer); + var instance = this.__deprecatedInstance__; - var release = function () { - return _emberRuntime.removeArrayObserver(records, _this3, observer); - }; + this._readinessDeferrals = 1; + this._bootPromise = null; + this._bootResolver = null; + this._booted = false; - return release; + function handleReset() { + _emberMetal.run(instance, 'destroy'); + this._buildDeprecatedInstance(); + _emberMetal.run.schedule('actions', this, '_bootSync'); + } + + _emberMetal.run.join(this, handleReset); }, /** - Wraps a given model type and observes changes to it. - @private - @method wrapModelType - @param {Class} klass A model class. - @param {String} modelName Name of the class. - @return {Object} Contains the wrapped type and the function to remove observers - Format: - type: {Object} The wrapped type. - The wrapped type has the following format: - name: {String} The name of the type. - count: {Integer} The number of records available. - columns: {Columns} An array of columns to describe the record. - object: {Class} The actual Model type class. - release: {Function} The function to remove observers. + @private + @method didBecomeReady */ - wrapModelType: function (klass, name) { - var records = this.getRecords(klass, name); - var typeToSend = undefined; + didBecomeReady: function () { + try { + // TODO: Is this still needed for _globalsMode = false? + if (!_emberMetal.isTesting()) { + // Eagerly name all classes that are already loaded + _emberRuntime.Namespace.processAll(); + _emberRuntime.setNamespaceSearchDisabled(true); + } - typeToSend = { - name: name, - count: _emberMetal.get(records, 'length'), - columns: this.columnsForType(klass), - object: klass - }; + // See documentation on `_autoboot()` for details + if (this.autoboot) { + var instance = undefined; - return typeToSend; - }, + if (this._globalsMode) { + // If we already have the __deprecatedInstance__ lying around, boot it to + // avoid unnecessary work + instance = this.__deprecatedInstance__; + } else { + // Otherwise, build an instance and boot it. This is currently unreachable, + // because we forced _globalsMode to === autoboot; but having this branch + // allows us to locally toggle that flag for weeding out legacy globals mode + // dependencies independently + instance = this.buildInstance(); + } - /** - Fetches all models defined in the application. - @private - @method getModelTypes - @return {Array} Array of model types. - */ - getModelTypes: function () { - var _this4 = this; + instance._bootSync(); - var containerDebugAdapter = this.get('containerDebugAdapter'); - var types = undefined; + // TODO: App.ready() is not called when autoboot is disabled, is this correct? + this.ready(); - if (containerDebugAdapter.canCatalogEntriesByType('model')) { - types = containerDebugAdapter.catalogEntriesByType('model'); - } else { - types = this._getObjectsOnNamespaces(); - } + instance.startRouting(); + } - // New adapters return strings instead of classes. - types = _emberRuntime.A(types).map(function (name) { - return { - klass: _this4._nameToClass(name), - name: name - }; - }); - types = _emberRuntime.A(types).filter(function (type) { - return _this4.detect(type.klass); - }); + // For the asynchronous boot path + this._bootResolver.resolve(this); - return _emberRuntime.A(types); + // For the synchronous boot path + this._booted = true; + } catch (error) { + // For the asynchronous boot path + this._bootResolver.reject(error); + + // For the synchronous boot path + throw error; + } }, /** - Loops over all namespaces and all objects - attached to them. - @private - @method _getObjectsOnNamespaces - @return {Array} Array of model type strings. + Called when the Application has become ready, immediately before routing + begins. The call will be delayed until the DOM has become ready. + @event ready + @public */ - _getObjectsOnNamespaces: function () { - var _this5 = this; + ready: function () { + return this; + }, - var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); - var types = _emberRuntime.A(); + // This method must be moved to the application instance object + willDestroy: function () { + this._super.apply(this, arguments); + _emberRuntime.setNamespaceSearchDisabled(false); + this._booted = false; + this._bootPromise = null; + this._bootResolver = null; - namespaces.forEach(function (namespace) { - for (var key in namespace) { - if (!namespace.hasOwnProperty(key)) { - continue; - } - // Even though we will filter again in `getModelTypes`, - // we should not call `lookupFactory` on non-models - // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) - if (!_this5.detect(namespace[key])) { - continue; + if (_emberRuntime._loaded.application === this) { + _emberRuntime._loaded.application = undefined; + } + + if (this._globalsMode && this.__deprecatedInstance__) { + this.__deprecatedInstance__.destroy(); + } + }, + + /** + Boot a new instance of `Ember.ApplicationInstance` for the current + application and navigate it to the given `url`. Returns a `Promise` that + resolves with the instance when the initial routing and rendering is + complete, or rejects with any error that occured during the boot process. + When `autoboot` is disabled, calling `visit` would first cause the + application to boot, which runs the application initializers. + This method also takes a hash of boot-time configuration options for + customizing the instance's behavior. See the documentation on + `Ember.ApplicationInstance.BootOptions` for details. + `Ember.ApplicationInstance.BootOptions` is an interface class that exists + purely to document the available options; you do not need to construct it + manually. Simply pass a regular JavaScript object containing of the + desired options: + ```javascript + MyApp.visit("/", { location: "none", rootElement: "#container" }); + ``` + ### Supported Scenarios + While the `BootOptions` class exposes a large number of knobs, not all + combinations of them are valid; certain incompatible combinations might + result in unexpected behavior. + For example, booting the instance in the full browser environment + while specifying a foriegn `document` object (e.g. `{ isBrowser: true, + document: iframe.contentDocument }`) does not work correctly today, + largely due to Ember's jQuery dependency. + Currently, there are three officially supported scenarios/configurations. + Usages outside of these scenarios are not guaranteed to work, but please + feel free to file bug reports documenting your experience and any issues + you encountered to help expand support. + #### Browser Applications (Manual Boot) + The setup is largely similar to how Ember works out-of-the-box. Normally, + Ember will boot a default instance for your Application on "DOM ready". + However, you can customize this behavior by disabling `autoboot`. + For example, this allows you to render a miniture demo of your application + into a specific area on your marketing website: + ```javascript + import MyApp from 'my-app'; + $(function() { + let App = MyApp.create({ autoboot: false }); + let options = { + // Override the router's location adapter to prevent it from updating + // the URL in the address bar + location: 'none', + // Override the default `rootElement` on the app to render into a + // specific `div` on the page + rootElement: '#demo' + }; + // Start the app at the special demo URL + App.visit('/demo', options); + }); + ```` + Or perhaps you might want to boot two instances of your app on the same + page for a split-screen multiplayer experience: + ```javascript + import MyApp from 'my-app'; + $(function() { + let App = MyApp.create({ autoboot: false }); + let sessionId = MyApp.generateSessionID(); + let player1 = App.visit(`/matches/join?name=Player+1&session=${sessionId}`, { rootElement: '#left', location: 'none' }); + let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#right', location: 'none' }); + Promise.all([player1, player2]).then(() => { + // Both apps have completed the initial render + $('#loading').fadeOut(); + }); + }); + ``` + Do note that each app instance maintains their own registry/container, so + they will run in complete isolation by default. + #### Server-Side Rendering (also known as FastBoot) + This setup allows you to run your Ember app in a server environment using + Node.js and render its content into static HTML for SEO purposes. + ```javascript + const HTMLSerializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); + function renderURL(url) { + let dom = new SimpleDOM.Document(); + let rootElement = dom.body; + let options = { isBrowser: false, document: dom, rootElement: rootElement }; + return MyApp.visit(options).then(instance => { + try { + return HTMLSerializer.serialize(rootElement.firstChild); + } finally { + instance.destroy(); } - var _name = _emberRuntime.String.dasherize(key); - if (!(namespace instanceof _emberApplication.Application) && namespace.toString()) { - _name = namespace + '/' + _name; + }); + } + ``` + In this scenario, because Ember does not have access to a global `document` + object in the Node.js environment, you must provide one explicitly. In practice, + in the non-browser environment, the stand-in `document` object only need to + implement a limited subset of the full DOM API. The `SimpleDOM` library is known + to work. + Since there is no access to jQuery in the non-browser environment, you must also + specify a DOM `Element` object in the same `document` for the `rootElement` option + (as opposed to a selector string like `"body"`). + See the documentation on the `isBrowser`, `document` and `rootElement` properties + on `Ember.ApplicationInstance.BootOptions` for details. + #### Server-Side Resource Discovery + This setup allows you to run the routing layer of your Ember app in a server + environment using Node.js and completely disable rendering. This allows you + to simulate and discover the resources (i.e. AJAX requests) needed to fufill + a given request and eagerly "push" these resources to the client. + ```app/initializers/network-service.js + import BrowserNetworkService from 'app/services/network/browser'; + import NodeNetworkService from 'app/services/network/node'; + // Inject a (hypothetical) service for abstracting all AJAX calls and use + // the appropiate implementaion on the client/server. This also allows the + // server to log all the AJAX calls made during a particular request and use + // that for resource-discovery purpose. + export function initialize(application) { + if (window) { // browser + application.register('service:network', BrowserNetworkService); + } else { // node + application.register('service:network', NodeNetworkService); + } + application.inject('route', 'network', 'service:network'); + }; + export default { + name: 'network-service', + initialize: initialize + }; + ``` + ```app/routes/post.js + import Ember from 'ember'; + // An example of how the (hypothetical) service is used in routes. + export default Ember.Route.extend({ + model(params) { + return this.network.fetch(`/api/posts/${params.post_id}.json`); + }, + afterModel(post) { + if (post.isExternalContent) { + return this.network.fetch(`/api/external/?url=${post.externalURL}`); + } else { + return post; } - types.push(_name); } }); - return types; - }, - - /** - Fetches all loaded records for a given type. - @private - @method getRecords - @return {Array} An array of records. - This array will be observed for changes, - so it should update when new records are added/removed. + ``` + ```javascript + // Finally, put all the pieces together + function discoverResourcesFor(url) { + return MyApp.visit(url, { isBrowser: false, shouldRender: false }).then(instance => { + let networkService = instance.lookup('service:network'); + return networkService.requests; // => { "/api/posts/123.json": "..." } + }); + } + ``` + @public + @method visit + @param url {String} The initial URL to navigate to + @param options {Ember.ApplicationInstance.BootOptions} + @return {Promise} */ - getRecords: function (type) { - return _emberRuntime.A(); - }, + visit: function (url, options) { + var _this = this; - /** - Wraps a record and observers changes to it. - @private - @method wrapRecord - @param {Object} record The record instance. - @return {Object} The wrapped record. Format: - columnValues: {Array} - searchKeywords: {Array} - */ - wrapRecord: function (record) { - var recordToSend = { object: record }; + return this.boot().then(function () { + var instance = _this.buildInstance(); - recordToSend.columnValues = this.getRecordColumnValues(record); - recordToSend.searchKeywords = this.getRecordKeywords(record); - recordToSend.filterValues = this.getRecordFilterValues(record); - recordToSend.color = this.getRecordColor(record); + return instance.boot(options).then(function () { + return instance.visit(url); + }).catch(function (error) { + _emberMetal.run(instance, 'destroy'); + throw error; + }); + }); + } + }); - return recordToSend; - }, + Object.defineProperty(Application.prototype, 'registry', { + configurable: true, + enumerable: false, + get: function () { + return _emberRuntime.buildFakeRegistryWithDeprecations(this, 'Application'); + } + }); + Application.reopenClass({ /** - Gets the values for each column. - @private - @method getRecordColumnValues - @return {Object} Keys should match column names defined - by the model type. + This creates a registry with the default Ember naming conventions. + It also configures the registry: + * registered views are created every time they are looked up (they are + not singletons) + * registered templates are not factories; the registered value is + returned directly. + * the router receives the application as its `namespace` property + * all controllers receive the router as their `target` and `controllers` + properties + * all controllers receive the application as their `namespace` property + * the application view receives the application controller as its + `controller` property + * the application view receives the application template as its + `defaultTemplate` property + @method buildRegistry + @static + @param {Ember.Application} namespace the application for which to + build the registry + @return {Ember.Registry} the built registry + @private */ - getRecordColumnValues: function (record) { - return {}; - }, + buildRegistry: function (application) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - /** - Returns keywords to match when searching records. - @private - @method getRecordKeywords - @return {Array} Relevant keywords for search. - */ - getRecordKeywords: function (record) { - return _emberRuntime.A(); - }, + var registry = this._super.apply(this, arguments); - /** - Returns the values of filters defined by `getFilters`. - @private - @method getRecordFilterValues - @param {Object} record The record instance. - @return {Object} The filter values. - */ - getRecordFilterValues: function (record) { - return {}; - }, + commonSetupRegistry(registry); - /** - Each record can have a color that represents its state. - @private - @method getRecordColor - @param {Object} record The record instance - @return {String} The records color. - Possible options: black, red, blue, green. - */ - getRecordColor: function (record) { - return null; - }, + _emberGlimmer.setupApplicationRegistry(registry); - /** - Observes all relevant properties and re-sends the wrapped record - when a change occurs. - @private - @method observerRecord - @param {Object} record The record instance. - @param {Function} recordUpdated The callback to call when a record is updated. - @return {Function} The function to call to remove all observers. - */ - observeRecord: function (record, recordUpdated) { - return function () {}; + return registry; } }); -}); -enifed('ember-extension-support/index', ['exports', 'ember-extension-support/data_adapter', 'ember-extension-support/container_debug_adapter'], function (exports, _emberExtensionSupportData_adapter, _emberExtensionSupportContainer_debug_adapter) { - /** - @module ember - @submodule ember-extension-support - */ - 'use strict'; + function commonSetupRegistry(registry) { + registry.register('-view-registry:main', { create: function () { + return _emberUtils.dictionary(null); + } }); - exports.DataAdapter = _emberExtensionSupportData_adapter.default; - exports.ContainerDebugAdapter = _emberExtensionSupportContainer_debug_adapter.default; -}); -enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'ember-runtime', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference', 'glimmer-runtime'], function (exports, _emberUtils, _emberViews, _emberRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference, _glimmerRuntime) { - 'use strict'; + registry.register('route:basic', _emberRouting.Route); + registry.register('event_dispatcher:main', _emberViews.EventDispatcher); - var _CoreView$extend; + registry.injection('router:main', 'namespace', 'application:main'); - var DIRTY_TAG = _emberUtils.symbol('DIRTY_TAG'); - exports.DIRTY_TAG = DIRTY_TAG; - var ARGS = _emberUtils.symbol('ARGS'); - exports.ARGS = ARGS; - var ROOT_REF = _emberUtils.symbol('ROOT_REF'); - exports.ROOT_REF = ROOT_REF; - var IS_DISPATCHING_ATTRS = _emberUtils.symbol('IS_DISPATCHING_ATTRS'); - exports.IS_DISPATCHING_ATTRS = IS_DISPATCHING_ATTRS; - var HAS_BLOCK = _emberUtils.symbol('HAS_BLOCK'); - exports.HAS_BLOCK = HAS_BLOCK; - var BOUNDS = _emberUtils.symbol('BOUNDS'); + registry.register('location:auto', _emberRouting.AutoLocation); + registry.register('location:hash', _emberRouting.HashLocation); + registry.register('location:history', _emberRouting.HistoryLocation); + registry.register('location:none', _emberRouting.NoneLocation); - exports.BOUNDS = BOUNDS; + registry.register(_container.privatize(_templateObject), _emberRouting.BucketCache); + + if (_emberMetal.isFeatureEnabled('ember-routing-router-service')) { + registry.register('service:router', _emberRouting.RouterService); + registry.injection('service:router', 'router', 'router:main'); + } + } + + function registerLibraries() { + if (!librariesRegistered) { + librariesRegistered = true; + + if (_emberEnvironment.environment.hasDOM && typeof _emberViews.jQuery === 'function') { + _emberMetal.libraries.registerCoreLibrary('jQuery', _emberViews.jQuery().jquery); + } + } + } + + function logLibraryVersions() {} + + exports.default = Application; +}); + +// we only need to see this once per Application#init +enifed('ember-application/system/engine-instance', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'container', 'ember-application/system/engine-parent'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _container, _emberApplicationSystemEngineParent) { /** @module ember - @submodule ember-glimmer + @submodule ember-application */ + 'use strict'; + + var _EmberObject$extend; + + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + /** - An `Ember.Component` is a view that is completely - isolated. Properties accessed in its templates go - to the view object and actions are targeted at - the view object. There is no access to the - surrounding context or outer controller; all - contextual information must be passed in. - - The easiest way to create an `Ember.Component` is via - a template. If you name a template - `components/my-foo`, you will be able to use - `{{my-foo}}` in other templates, which will make - an instance of the isolated component. - - ```handlebars - {{app-profile person=currentUser}} - ``` - - ```handlebars - -

    {{person.title}}

    - -

    {{person.signature}}

    - ``` - - You can use `yield` inside a template to - include the **contents** of any block attached to - the component. The block will be executed in the - context of the surrounding context or outer controller: - - ```handlebars - {{#app-profile person=currentUser}} -

    Admin mode

    - {{! Executed in the controller's context. }} - {{/app-profile}} - ``` - - ```handlebars - -

    {{person.title}}

    - {{! Executed in the component's context. }} - {{yield}} {{! block contents }} - ``` - - If you want to customize the component, in order to - handle events or actions, you implement a subclass - of `Ember.Component` named after the name of the - component. Note that `Component` needs to be appended to the name of - your subclass like `AppProfileComponent`. - - For example, you could implement the action - `hello` for the `app-profile` component: - - ```javascript - App.AppProfileComponent = Ember.Component.extend({ - actions: { - hello: function(name) { - console.log("Hello", name); - } - } - }); - ``` - - And then use it in the component's template: - - ```handlebars - -

    {{person.title}}

    - {{yield}} - - ``` - Components must have a `-` in their name to avoid - conflicts with built-in controls that wrap HTML - elements. This is consistent with the same - requirement in web components. + The `EngineInstance` encapsulates all of the stateful aspects of a + running `Engine`. - @class Component - @namespace Ember - @extends Ember.CoreView - @uses Ember.TargetActionSupport - @uses Ember.ClassNamesSupport - @uses Ember.ActionSupport - @uses Ember.ViewMixin @public + @class Ember.EngineInstance + @extends Ember.Object + @uses RegistryProxyMixin + @uses ContainerProxyMixin */ - var Component = _emberViews.CoreView.extend(_emberViews.ChildViewsSupport, _emberViews.ViewStateSupport, _emberViews.ClassNamesSupport, _emberRuntime.TargetActionSupport, _emberViews.ActionSupport, _emberViews.ViewMixin, (_CoreView$extend = { - isComponent: true, + + var EngineInstance = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, (_EmberObject$extend = { + /** + The base `Engine` for which this is an instance. + @property {Ember.Engine} engine + @private + */ + base: null, init: function () { this._super.apply(this, arguments); - this[IS_DISPATCHING_ATTRS] = false; - this[DIRTY_TAG] = new _glimmerReference.DirtyableTag(); - this[ROOT_REF] = new _emberGlimmerUtilsReferences.RootReference(this); - this[BOUNDS] = null; - // If a `defaultLayout` was specified move it to the `layout` prop. - // `layout` is no longer a CP, so this just ensures that the `defaultLayout` - // logic is supported with a deprecation - if (this.defaultLayout && !this.layout) { + _emberUtils.guidFor(this); - this.layout = this.defaultLayout; + var base = this.base; + + if (!base) { + base = this.application; + this.base = base; } - // If in a tagless component, assert that no event handlers are defined - }, + // Create a per-instance registry that will use the application's registry + // as a fallback for resolving registrations. + var registry = this.__registry__ = new _container.Registry({ + fallback: base.__registry__ + }); - // indicate that the assertion should be triggered - rerender: function () { - this[DIRTY_TAG].dirty(); - this._super(); + // Create a per-instance container from the instance's registry + this.__container__ = registry.container({ owner: this }); + + this._booted = false; }, - __defineNonEnumerable: function (property) { - this[property.name] = property.descriptor.value; - } + /** + Initialize the `Ember.EngineInstance` and return a promise that resolves + with the instance itself when the boot process is complete. + The primary task here is to run any registered instance initializers. + See the documentation on `BootOptions` for the options it takes. + @private + @method boot + @param options {Object} + @return {Promise} + */ + boot: function (options) { + var _this = this; - }, _CoreView$extend[_emberMetal.PROPERTY_DID_CHANGE] = function (key) { - if (this[IS_DISPATCHING_ATTRS]) { - return; - } + if (this._bootPromise) { + return this._bootPromise; + } - var args = undefined, - reference = undefined; + this._bootPromise = new _emberRuntime.RSVP.Promise(function (resolve) { + return resolve(_this._bootSync(options)); + }); - if ((args = this[ARGS]) && (reference = args[key])) { - if (reference[_emberGlimmerUtilsReferences.UPDATE]) { - reference[_emberGlimmerUtilsReferences.UPDATE](_emberMetal.get(this, key)); + return this._bootPromise; + }, + + /** + Unfortunately, a lot of existing code assumes booting an instance is + synchronous – specifically, a lot of tests assume the last call to + `app.advanceReadiness()` or `app.reset()` will result in a new instance + being fully-booted when the current runloop completes. + We would like new code (like the `visit` API) to stop making this + assumption, so we created the asynchronous version above that returns a + promise. But until we have migrated all the code, we would have to expose + this method for use *internally* in places where we need to boot an instance + synchronously. + @private + */ + _bootSync: function (options) { + if (this._booted) { + return this; } - } - }, _CoreView$extend.getAttr = function (key) { - // TODO Intimate API should be deprecated - return this.get(key); - }, _CoreView$extend.readDOMAttr = function (name) { - var element = _emberViews.getViewElement(this); - return _glimmerRuntime.readDOMAttr(element, name); - }, _CoreView$extend)); - /** - The WAI-ARIA role of the control represented by this view. For example, a - button may have a role of type 'button', or a pane may have a role of - type 'alertdialog'. This property is used by assistive software to help - visually challenged users navigate rich web applications. - The full list of valid WAI-ARIA roles is available at: - [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization) - @property ariaRole - @type String - @default null - @public - */ + this.cloneParentDependencies(); - /** - Enables components to take a list of parameters as arguments. - For example, a component that takes two parameters with the names - `name` and `age`: - ```javascript - let MyComponent = Ember.Component.extend; - MyComponent.reopenClass({ - positionalParams: ['name', 'age'] - }); - ``` - It can then be invoked like this: - ```hbs - {{my-component "John" 38}} - ``` - The parameters can be referred to just like named parameters: - ```hbs - Name: {{attrs.name}}, Age: {{attrs.age}}. - ``` - Using a string instead of an array allows for an arbitrary number of - parameters: - ```javascript - let MyComponent = Ember.Component.extend; - MyComponent.reopenClass({ - positionalParams: 'names' - }); - ``` - It can then be invoked like this: - ```hbs - {{my-component "John" "Michael" "Scott"}} - ``` - The parameters can then be referred to by enumerating over the list: - ```hbs - {{#each attrs.names as |name|}}{{name}}{{/each}} - ``` - @static - @public - @property positionalParams - @since 1.13.0 - */ + this.setupRegistry(options); - /** - Called when the attributes passed into the component have been updated. - Called both during the initial render of a container and during a rerender. - Can be used in place of an observer; code placed here will be executed - every time any attribute updates. - @method didReceiveAttrs - @public - @since 1.13.0 - */ + this.base.runInstanceInitializers(this); - /** - Called when the attributes passed into the component have been updated. - Called both during the initial render of a container and during a rerender. - Can be used in place of an observer; code placed here will be executed - every time any attribute updates. - @event didReceiveAttrs - @public - @since 1.13.0 - */ + this._booted = true; - /** - Called after a component has been rendered, both on initial render and - in subsequent rerenders. - @method didRender - @public - @since 1.13.0 - */ + return this; + }, - /** - Called after a component has been rendered, both on initial render and - in subsequent rerenders. - @event didRender - @public - @since 1.13.0 - */ + setupRegistry: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? this.__container__.lookup('-environment:main') : arguments[0]; - /** - Called before a component has been rendered, both on initial render and - in subsequent rerenders. - @method willRender - @public - @since 1.13.0 - */ + this.constructor.setupRegistry(this.__registry__, options); + }, - /** - Called before a component has been rendered, both on initial render and - in subsequent rerenders. - @event willRender - @public - @since 1.13.0 - */ + /** + Unregister a factory. + Overrides `RegistryProxy#unregister` in order to clear any cached instances + of the unregistered factory. + @public + @method unregister + @param {String} fullName + */ + unregister: function (fullName) { + this.__container__.reset(fullName); + this._super.apply(this, arguments); + }, - /** - Called when the attributes passed into the component have been changed. - Called only during a rerender, not during an initial render. - @method didUpdateAttrs - @public - @since 1.13.0 - */ + /** + @private + */ + willDestroy: function () { + this._super.apply(this, arguments); + _emberMetal.run(this.__container__, 'destroy'); + }, - /** - Called when the attributes passed into the component have been changed. - Called only during a rerender, not during an initial render. - @event didUpdateAttrs - @public - @since 1.13.0 - */ + /** + Build a new `Ember.EngineInstance` that's a child of this instance. + Engines must be registered by name with their parent engine + (or application). + @private + @method buildChildEngineInstance + @param name {String} the registered name of the engine. + @param options {Object} options provided to the engine instance. + @return {Ember.EngineInstance,Error} + */ + buildChildEngineInstance: function (name) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - /** - Called when the component is about to update and rerender itself. - Called only during a rerender, not during an initial render. - @method willUpdate - @public - @since 1.13.0 - */ + var Engine = this.lookup('engine:' + name); - /** - Called when the component is about to update and rerender itself. - Called only during a rerender, not during an initial render. - @event willUpdate - @public - @since 1.13.0 - */ + if (!Engine) { + throw new _emberMetal.Error('You attempted to mount the engine \'' + name + '\', but it is not registered with its parent.'); + } - /** - Called when the component has updated and rerendered itself. - Called only during a rerender, not during an initial render. - @method didUpdate - @public - @since 1.13.0 - */ + var engineInstance = Engine.buildInstance(options); - /** - Called when the component has updated and rerendered itself. - Called only during a rerender, not during an initial render. - @event didUpdate - @public - @since 1.13.0 - */ + _emberApplicationSystemEngineParent.setEngineParent(engineInstance, this); - /** - If `false`, the view will appear hidden in DOM. - @property isVisible - @type Boolean - @default null - @public - */ - Component[_emberUtils.NAME_KEY] = 'Ember.Component'; + return engineInstance; + }, - Component.reopenClass({ - isComponentFactory: true, - positionalParams: [] - }); + /** + Clone dependencies shared between an engine instance and its parent. + @private + @method cloneParentDependencies + */ + cloneParentDependencies: function () { + var _this2 = this; - exports.default = Component; -}); + var parent = _emberApplicationSystemEngineParent.getEngineParent(this); -/** - Normally, Ember's component model is "write-only". The component takes a - bunch of attributes that it got passed in, and uses them to render its - template. - One nice thing about this model is that if you try to set a value to the - same thing as last time, Ember (through HTMLBars) will avoid doing any - work on the DOM. - This is not just a performance optimization. If an attribute has not - changed, it is important not to clobber the element's "hidden state". - For example, if you set an input's `value` to the same value as before, - it will clobber selection state and cursor position. In other words, - setting an attribute is not **always** idempotent. - This method provides a way to read an element's attribute and also - update the last value Ember knows about at the same time. This makes - setting an attribute idempotent. - In particular, what this means is that if you get an `` element's - `value` attribute and then re-render the template with the same value, - it will avoid clobbering the cursor and selection position. - Since most attribute sets are idempotent in the browser, you typically - can get away with reading attributes using jQuery, but the most reliable - way to do so is through this method. - @method readDOMAttr - @param {String} name the name of the attribute - @return String - @public - */ -enifed('ember-glimmer/components/checkbox', ['exports', 'ember-metal', 'ember-glimmer/component', 'ember-glimmer/templates/empty'], function (exports, _emberMetal, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty) { - 'use strict'; + var registrations = ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment']; - /** - @module ember - @submodule ember-views - */ + registrations.forEach(function (key) { + return _this2.register(key, parent.resolveRegistration(key)); + }); - /** - The internal class used to create text inputs when the `{{input}}` - helper is used with `type` of `checkbox`. - - See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. - - ## Direct manipulation of `checked` - - The `checked` attribute of an `Ember.Checkbox` object should always be set - through the Ember object or by interacting with its rendered element - representation via the mouse, keyboard, or touch. Updating the value of the - checkbox via jQuery will result in the checked value of the object and its - element losing synchronization. - - ## Layout and LayoutName properties - - Because HTML `input` elements are self closing `layout` and `layoutName` - properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. - - @class Checkbox - @namespace Ember - @extends Ember.Component - @public - */ - exports.default = _emberGlimmerComponent.default.extend({ - layout: _emberGlimmerTemplatesEmpty.default, - classNames: ['ember-checkbox'], + var env = parent.lookup('-environment:main'); + this.register('-environment:main', env, { instantiate: false }); - tagName: 'input', + var singletons = ['router:main', _container.privatize(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert')]; - attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name', 'autofocus', 'required', 'form'], + singletons.forEach(function (key) { + return _this2.register(key, parent.lookup(key), { instantiate: false }); + }); - type: 'checkbox', - checked: false, - disabled: false, - indeterminate: false, + this.inject('view', '_environment', '-environment:main'); + this.inject('route', '_environment', '-environment:main'); + } - didInsertElement: function () { - this._super.apply(this, arguments); - _emberMetal.get(this, 'element').indeterminate = !!_emberMetal.get(this, 'indeterminate'); - }, + }, _EmberObject$extend[_container.FACTORY_FOR] = function (fullName, options) { + return this.__container__[_container.FACTORY_FOR](fullName, options); + }, _EmberObject$extend[_container.LOOKUP_FACTORY] = function (fullName, options) { + return this.__container__[_container.LOOKUP_FACTORY](fullName, options); + }, _EmberObject$extend)); - change: function () { - _emberMetal.set(this, 'checked', this.$().prop('checked')); + EngineInstance.reopenClass({ + /** + @private + @method setupRegistry + @param {Registry} registry + @param {BootOptions} options + */ + setupRegistry: function (registry, options) { + // when no options/environment is present, do nothing + if (!options) { + return; + } + + registry.injection('view', '_environment', '-environment:main'); + registry.injection('route', '_environment', '-environment:main'); + + if (options.isInteractive) { + registry.injection('view', 'renderer', 'renderer:-dom'); + registry.injection('component', 'renderer', 'renderer:-dom'); + } else { + registry.injection('view', 'renderer', 'renderer:-inert'); + registry.injection('component', 'renderer', 'renderer:-inert'); + } } }); + + exports.default = EngineInstance; }); -enifed('ember-glimmer/components/link-to', ['exports', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-glimmer/templates/link-to', 'ember-glimmer/component'], function (exports, _emberConsole, _emberMetal, _emberRuntime, _emberViews, _emberGlimmerTemplatesLinkTo, _emberGlimmerComponent) { +enifed('ember-application/system/engine-parent', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; + + exports.getEngineParent = getEngineParent; + exports.setEngineParent = setEngineParent; + var ENGINE_PARENT = _emberUtils.symbol('ENGINE_PARENT'); + + exports.ENGINE_PARENT = ENGINE_PARENT; /** - @module ember - @submodule ember-glimmer + `getEngineParent` retrieves an engine instance's parent instance. + + @method getEngineParent + @param {EngineInstance} engine An engine instance. + @return {EngineInstance} The parent engine instance. + @for Ember + @public */ + function getEngineParent(engine) { + return engine[ENGINE_PARENT]; + } + /** - The `{{link-to}}` component renders a link to the supplied - `routeName` passing an optionally supplied model to the - route as its `model` context of the route. The block - for `{{link-to}}` becomes the innerHTML of the rendered - element: - - ```handlebars - {{#link-to 'photoGallery'}} - Great Hamster Photos - {{/link-to}} - ``` - - You can also use an inline form of `{{link-to}}` component by - passing the link text as the first argument - to the component: - - ```handlebars - {{link-to 'Great Hamster Photos' 'photoGallery'}} - ``` - - Both will result in: - - ```html - - Great Hamster Photos - - ``` - - ### Supplying a tagName - By default `{{link-to}}` renders an `` element. This can - be overridden for a single use of `{{link-to}}` by supplying - a `tagName` option: - - ```handlebars - {{#link-to 'photoGallery' tagName="li"}} - Great Hamster Photos - {{/link-to}} - ``` - - ```html -
  • - Great Hamster Photos -
  • - ``` - - To override this option for your entire application, see - "Overriding Application-wide Defaults". - - ### Disabling the `link-to` component - By default `{{link-to}}` is enabled. - any passed value to the `disabled` component property will disable - the `link-to` component. - - static use: the `disabled` option: - - ```handlebars - {{#link-to 'photoGallery' disabled=true}} - Great Hamster Photos - {{/link-to}} - ``` - - dynamic use: the `disabledWhen` option: - - ```handlebars - {{#link-to 'photoGallery' disabledWhen=controller.someProperty}} - Great Hamster Photos - {{/link-to}} - ``` - - any passed value to `disabled` will disable it except `undefined`. - to ensure that only `true` disable the `link-to` component you can - override the global behaviour of `Ember.LinkComponent`. - - ```javascript - Ember.LinkComponent.reopen({ - disabled: Ember.computed(function(key, value) { - if (value !== undefined) { - this.set('_isDisabled', value === true); - } - return value === true ? get(this, 'disabledClass') : false; - }) - }); - ``` - - see "Overriding Application-wide Defaults" for more. - - ### Handling `href` - `{{link-to}}` will use your application's Router to - fill the element's `href` property with a url that - matches the path to the supplied `routeName` for your - router's configured `Location` scheme, which defaults - to Ember.HashLocation. - - ### Handling current route - `{{link-to}}` will apply a CSS class name of 'active' - when the application's current route matches - the supplied routeName. For example, if the application's - current route is 'photoGallery.recent' the following - use of `{{link-to}}`: - - ```handlebars - {{#link-to 'photoGallery.recent'}} - Great Hamster Photos - {{/link-to}} - ``` - - will result in - - ```html -
    - Great Hamster Photos - - ``` - - The CSS class name used for active classes can be customized - for a single use of `{{link-to}}` by passing an `activeClass` - option: - - ```handlebars - {{#link-to 'photoGallery.recent' activeClass="current-url"}} - Great Hamster Photos - {{/link-to}} - ``` - - ```html - - Great Hamster Photos - - ``` - - To override this option for your entire application, see - "Overriding Application-wide Defaults". - - ### Keeping a link active for other routes - - If you need a link to be 'active' even when it doesn't match - the current route, you can use the `current-when` argument. - - ```handlebars - {{#link-to 'photoGallery' current-when='photos'}} - Photo Gallery - {{/link-to}} - ``` - - This may be helpful for keeping links active for: - - * non-nested routes that are logically related - * some secondary menu approaches - * 'top navigation' with 'sub navigation' scenarios - - A link will be active if `current-when` is `true` or the current - route is the route this link would transition to. - - To match multiple routes 'space-separate' the routes: - - ```handlebars - {{#link-to 'gallery' current-when='photos drawings paintings'}} - Art Gallery - {{/link-to}} - ``` - - ### Supplying a model - An optional model argument can be used for routes whose - paths contain dynamic segments. This argument will become - the model context of the linked route: - - ```javascript - Router.map(function() { - this.route("photoGallery", {path: "hamster-photos/:photo_id"}); - }); - ``` - - ```handlebars - {{#link-to 'photoGallery' aPhoto}} - {{aPhoto.title}} - {{/link-to}} - ``` - - ```html - - Tomster - - ``` - - ### Supplying multiple models - For deep-linking to route paths that contain multiple - dynamic segments, multiple model arguments can be used. - As the router transitions through the route path, each - supplied model argument will become the context for the - route with the dynamic segments: - - ```javascript - Router.map(function() { - this.route("photoGallery", { path: "hamster-photos/:photo_id" }, function() { - this.route("comment", {path: "comments/:comment_id"}); - }); - }); - ``` - This argument will become the model context of the linked route: - - ```handlebars - {{#link-to 'photoGallery.comment' aPhoto comment}} - {{comment.body}} - {{/link-to}} - ``` - - ```html - - A+++ would snuggle again. - - ``` - - ### Supplying an explicit dynamic segment value - If you don't have a model object available to pass to `{{link-to}}`, - an optional string or integer argument can be passed for routes whose - paths contain dynamic segments. This argument will become the value - of the dynamic segment: - - ```javascript - Router.map(function() { - this.route("photoGallery", { path: "hamster-photos/:photo_id" }); - }); - ``` - - ```handlebars - {{#link-to 'photoGallery' aPhotoId}} - {{aPhoto.title}} - {{/link-to}} - ``` - - ```html - - Tomster - - ``` - - When transitioning into the linked route, the `model` hook will - be triggered with parameters including this passed identifier. - - ### Allowing Default Action - - By default the `{{link-to}}` component prevents the default browser action - by calling `preventDefault()` as this sort of action bubbling is normally - handled internally and we do not want to take the browser to a new URL (for - example). - - If you need to override this behavior specify `preventDefault=false` in - your template: - - ```handlebars - {{#link-to 'photoGallery' aPhotoId preventDefault=false}} - {{aPhotoId.title}} - {{/link-to}} - ``` - - ### Overriding attributes - You can override any given property of the `Ember.LinkComponent` - that is generated by the `{{link-to}}` component by passing - key/value pairs, like so: - - ```handlebars - {{#link-to aPhoto tagName='li' title='Following this link will change your life' classNames='pic sweet'}} - Uh-mazing! - {{/link-to}} - ``` - - See [Ember.LinkComponent](/api/classes/Ember.LinkComponent.html) for a - complete list of overrideable properties. Be sure to also - check out inherited properties of `LinkComponent`. - - ### Overriding Application-wide Defaults - ``{{link-to}}`` creates an instance of `Ember.LinkComponent` - for rendering. To override options for your entire - application, reopen `Ember.LinkComponent` and supply the - desired values: - - ``` javascript - Ember.LinkComponent.reopen({ - activeClass: "is-active", - tagName: 'li' - }) - ``` - - It is also possible to override the default event in - this manner: - - ``` javascript - Ember.LinkComponent.reopen({ - eventName: 'customEventName' - }); - ``` + `setEngineParent` sets an engine instance's parent instance. - @method link-to - @for Ember.Templates.helpers - @param {String} routeName - @param {Object} [context]* - @param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkComponent - @return {String} HTML string - @see {Ember.LinkComponent} - @public + @method setEngineParent + @param {EngineInstance} engine An engine instance. + @param {EngineInstance} parent The parent engine instance. + @private */ + function setEngineParent(engine, parent) { + engine[ENGINE_PARENT] = parent; + } +}); +enifed('ember-application/system/engine', ['exports', 'ember-utils', 'ember-runtime', 'container', 'dag-map', 'ember-metal', 'ember-application/system/resolver', 'ember-application/system/engine-instance', 'ember-routing', 'ember-extension-support', 'ember-views', 'ember-glimmer'], function (exports, _emberUtils, _emberRuntime, _container, _dagMap, _emberMetal, _emberApplicationSystemResolver, _emberApplicationSystemEngineInstance, _emberRouting, _emberExtensionSupport, _emberViews, _emberGlimmer) { + /** + @module ember + @submodule ember-application + */ 'use strict'; + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); + + function props(obj) { + var properties = []; + + for (var key in obj) { + properties.push(key); + } + + return properties; + } + /** - `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. + The `Engine` class contains core functionality for both applications and + engines. - `Ember.LinkComponent` components are invoked with {{#link-to}}. Properties - of this class can be overridden with `reopen` to customize application-wide - behavior. + Each engine manages a registry that's used for dependency injection and + exposed through `RegistryProxy`. - @class LinkComponent + Engines also manage initializers and instance initializers. + + Engines can spawn `EngineInstance` instances via `buildInstance()`. + + @class Engine @namespace Ember - @extends Ember.Component - @see {Ember.Templates.helpers.link-to} - @private - **/ - var LinkComponent = _emberGlimmerComponent.default.extend({ - layout: _emberGlimmerTemplatesLinkTo.default, + @extends Ember.Namespace + @uses RegistryProxy + @public + */ + var Engine = _emberRuntime.Namespace.extend(_emberRuntime.RegistryProxyMixin, { + init: function () { + this._super.apply(this, arguments); - tagName: 'a', + this.buildRegistry(); + }, /** - @deprecated Use current-when instead. - @property currentWhen - @private + A private flag indicating whether an engine's initializers have run yet. + @private + @property _initializersRan */ - currentWhen: _emberRuntime.deprecatingAlias('current-when', { id: 'ember-routing-view.deprecated-current-when', until: '3.0.0' }), + _initializersRan: false, /** - Used to determine when this `LinkComponent` is active. - @property currentWhen - @public + Ensure that initializers are run once, and only once, per engine. + @private + @method ensureInitializers */ - 'current-when': null, - - /** - Sets the `title` attribute of the `LinkComponent`'s HTML element. - @property title - @default null - @public - **/ - title: null, + ensureInitializers: function () { + if (!this._initializersRan) { + this.runInitializers(); + this._initializersRan = true; + } + }, /** - Sets the `rel` attribute of the `LinkComponent`'s HTML element. - @property rel - @default null - @public - **/ - rel: null, + Create an EngineInstance for this engine. + @private + @method buildInstance + @return {Ember.EngineInstance} the engine instance + */ + buildInstance: function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - /** - Sets the `tabindex` attribute of the `LinkComponent`'s HTML element. - @property tabindex - @default null - @public - **/ - tabindex: null, + this.ensureInitializers(); + options.base = this; + return _emberApplicationSystemEngineInstance.default.create(options); + }, /** - Sets the `target` attribute of the `LinkComponent`'s HTML element. - @since 1.8.0 - @property target - @default null - @public - **/ - target: null, + Build and configure the registry for the current engine. + @private + @method buildRegistry + @return {Ember.Registry} the configured registry + */ + buildRegistry: function () { + var registry = this.__registry__ = this.constructor.buildRegistry(this); - /** - The CSS class to apply to `LinkComponent`'s element when its `active` - property is `true`. - @property activeClass - @type String - @default active - @public - **/ - activeClass: 'active', + return registry; + }, /** - The CSS class to apply to `LinkComponent`'s element when its `loading` - property is `true`. - @property loadingClass - @type String - @default loading @private - **/ - loadingClass: 'loading', + @method initializer + */ + initializer: function (options) { + this.constructor.initializer(options); + }, /** - The CSS class to apply to a `LinkComponent`'s element when its `disabled` - property is `true`. - @property disabledClass - @type String - @default disabled @private - **/ - disabledClass: 'disabled', - _isDisabled: false, + @method instanceInitializer + */ + instanceInitializer: function (options) { + this.constructor.instanceInitializer(options); + }, /** - Determines whether the `LinkComponent` will trigger routing via - the `replaceWith` routing strategy. - @property replace - @type Boolean - @default false - @public - **/ - replace: false, - - /** - By default the `{{link-to}}` component will bind to the `href` and - `title` attributes. It's discouraged that you override these defaults, - however you can push onto the array if needed. - @property attributeBindings - @type Array | String - @default ['title', 'rel', 'tabindex', 'target'] - @public + @private + @method runInitializers */ - attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'], + runInitializers: function () { + var _this = this; - /** - By default the `{{link-to}}` component will bind to the `active`, `loading`, - and `disabled` classes. It is discouraged to override these directly. - @property classNameBindings - @type Array - @default ['active', 'loading', 'disabled', 'ember-transitioning-in', 'ember-transitioning-out'] - @public - */ - classNameBindings: ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'], + this._runInitializer('initializers', function (name, initializer) { + if (initializer.initialize.length === 2) { - /** - By default the `{{link-to}}` component responds to the `click` event. You - can override this globally by setting this property to your custom - event name. - This is particularly useful on mobile when one wants to avoid the 300ms - click delay using some sort of custom `tap` event. - @property eventName - @type String - @default click - @private - */ - eventName: 'click', + initializer.initialize(_this.__registry__, _this); + } else { + initializer.initialize(_this); + } + }); + }, - // this is doc'ed here so it shows up in the events - // section of the API documentation, which is where - // people will likely go looking for it. /** - Triggers the `LinkComponent`'s routing behavior. If - `eventName` is changed to a value other than `click` - the routing behavior will trigger on that custom event - instead. - @event click @private + @since 1.12.0 + @method runInstanceInitializers */ + runInstanceInitializers: function (instance) { + this._runInitializer('instanceInitializers', function (name, initializer) { + initializer.initialize(instance); + }); + }, + + _runInitializer: function (bucketName, cb) { + var initializersByName = _emberMetal.get(this.constructor, bucketName); + var initializers = props(initializersByName); + var graph = new _dagMap.default(); + var initializer = undefined; + + for (var i = 0; i < initializers.length; i++) { + initializer = initializersByName[initializers[i]]; + graph.add(initializer.name, initializer, initializer.before, initializer.after); + } + + graph.topsort(cb); + } + }); + + Engine.reopenClass({ + initializers: new _emberUtils.EmptyObject(), + instanceInitializers: new _emberUtils.EmptyObject(), /** - An overridable method called when `LinkComponent` objects are instantiated. - Example: + The goal of initializers should be to register dependencies and injections. + This phase runs once. Because these initializers may load code, they are + allowed to defer application readiness and advance it. If you need to access + the container or store you should use an InstanceInitializer that will be run + after all initializers and therefore after all code is loaded and the app is + ready. + Initializer receives an object which has the following attributes: + `name`, `before`, `after`, `initialize`. The only required attribute is + `initialize`, all others are optional. + * `name` allows you to specify under which name the initializer is registered. + This must be a unique name, as trying to register two initializers with the + same name will result in an error. ```javascript - App.MyLinkComponent = Ember.LinkComponent.extend({ - init: function() { - this._super(...arguments); - Ember.Logger.log('Event is ' + this.get('eventName')); + Ember.Application.initializer({ + name: 'namedInitializer', + initialize: function(application) { + Ember.debug('Running namedInitializer!'); } }); ``` - NOTE: If you do override `init` for a framework class like `Ember.View`, - be sure to call `this._super(...arguments)` in your - `init` declaration! If you don't, Ember may not have an opportunity to - do important setup work, and you'll see strange behavior in your - application. - @method init - @private + * `before` and `after` are used to ensure that this initializer is ran prior + or after the one identified by the value. This value can be a single string + or an array of strings, referencing the `name` of other initializers. + An example of ordering initializers, we create an initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'first', + initialize: function(application) { + Ember.debug('First initializer!'); + } + }); + // DEBUG: First initializer! + ``` + We add another initializer named `second`, specifying that it should run + after the initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'second', + after: 'first', + initialize: function(application) { + Ember.debug('Second initializer!'); + } + }); + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + Afterwards we add a further initializer named `pre`, this time specifying + that it should run before the initializer named `first`: + ```javascript + Ember.Application.initializer({ + name: 'pre', + before: 'first', + initialize: function(application) { + Ember.debug('Pre initializer!'); + } + }); + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + ``` + Finally we add an initializer named `post`, specifying it should run after + both the `first` and the `second` initializers: + ```javascript + Ember.Application.initializer({ + name: 'post', + after: ['first', 'second'], + initialize: function(application) { + Ember.debug('Post initializer!'); + } + }); + // DEBUG: Pre initializer! + // DEBUG: First initializer! + // DEBUG: Second initializer! + // DEBUG: Post initializer! + ``` + * `initialize` is a callback function that receives one argument, + `application`, on which you can operate. + Example of using `application` to register an adapter: + ```javascript + Ember.Application.initializer({ + name: 'api-adapter', + initialize: function(application) { + application.register('api-adapter:main', ApiAdapter); + } + }); + ``` + @method initializer + @param initializer {Object} + @public */ - init: function () { - this._super.apply(this, arguments); - // Map desired event name to invoke function - var eventName = _emberMetal.get(this, 'eventName'); - this.on(eventName, this, this._invoke); - }, + initializer: buildInitializerMethod('initializers', 'initializer'), - _routing: _emberRuntime.inject.service('-routing'), + /** + Instance initializers run after all initializers have run. Because + instance initializers run after the app is fully set up. We have access + to the store, container, and other items. However, these initializers run + after code has loaded and are not allowed to defer readiness. + Instance initializer receives an object which has the following attributes: + `name`, `before`, `after`, `initialize`. The only required attribute is + `initialize`, all others are optional. + * `name` allows you to specify under which name the instanceInitializer is + registered. This must be a unique name, as trying to register two + instanceInitializer with the same name will result in an error. + ```javascript + Ember.Application.instanceInitializer({ + name: 'namedinstanceInitializer', + initialize: function(application) { + Ember.debug('Running namedInitializer!'); + } + }); + ``` + * `before` and `after` are used to ensure that this initializer is ran prior + or after the one identified by the value. This value can be a single string + or an array of strings, referencing the `name` of other initializers. + * See Ember.Application.initializer for discussion on the usage of before + and after. + Example instanceInitializer to preload data into the store. + ```javascript + Ember.Application.initializer({ + name: 'preload-data', + initialize: function(application) { + var userConfig, userConfigEncoded, store; + // We have a HTML escaped JSON representation of the user's basic + // configuration generated server side and stored in the DOM of the main + // index.html file. This allows the app to have access to a set of data + // without making any additional remote calls. Good for basic data that is + // needed for immediate rendering of the page. Keep in mind, this data, + // like all local models and data can be manipulated by the user, so it + // should not be relied upon for security or authorization. + // + // Grab the encoded data from the meta tag + userConfigEncoded = Ember.$('head meta[name=app-user-config]').attr('content'); + // Unescape the text, then parse the resulting JSON into a real object + userConfig = JSON.parse(unescape(userConfigEncoded)); + // Lookup the store + store = application.lookup('service:store'); + // Push the encoded JSON into the store + store.pushPayload(userConfig); + } + }); + ``` + @method instanceInitializer + @param instanceInitializer + @public + */ + instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer'), /** - Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass` - CSS `class` to the element when the link is disabled. - When `true` interactions with the element will not trigger route changes. - @property disabled + This creates a registry with the default Ember naming conventions. + It also configures the registry: + * registered views are created every time they are looked up (they are + not singletons) + * registered templates are not factories; the registered value is + returned directly. + * the router receives the application as its `namespace` property + * all controllers receive the router as their `target` and `controllers` + properties + * all controllers receive the application as their `namespace` property + * the application view receives the application controller as its + `controller` property + * the application view receives the application template as its + `defaultTemplate` property + @method buildRegistry + @static + @param {Ember.Application} namespace the application for which to + build the registry + @return {Ember.Registry} the built registry @private */ - disabled: _emberMetal.computed({ - get: function (key, value) { - return false; - }, - set: function (key, value) { - if (value !== undefined) { - this.set('_isDisabled', value); - } - - return value ? _emberMetal.get(this, 'disabledClass') : false; - } - }), + buildRegistry: function (namespace) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - _computeActive: function (routerState) { - if (_emberMetal.get(this, 'loading')) { - return false; - } + var registry = new _container.Registry({ + resolver: resolverFor(namespace) + }); - var routing = _emberMetal.get(this, '_routing'); - var models = _emberMetal.get(this, 'models'); - var resolvedQueryParams = _emberMetal.get(this, 'resolvedQueryParams'); + registry.set = _emberMetal.set; - var currentWhen = _emberMetal.get(this, 'current-when'); - var isCurrentWhenSpecified = !!currentWhen; - currentWhen = currentWhen || _emberMetal.get(this, 'qualifiedRouteName'); - currentWhen = currentWhen.split(' '); + registry.register('application:main', namespace, { instantiate: false }); - for (var i = 0; i < currentWhen.length; i++) { - if (routing.isActiveForRoute(models, resolvedQueryParams, currentWhen[i], routerState, isCurrentWhenSpecified)) { - return _emberMetal.get(this, 'activeClass'); - } - } + commonSetupRegistry(registry); + _emberGlimmer.setupEngineRegistry(registry); - return false; + return registry; }, /** - Accessed as a classname binding to apply the `LinkComponent`'s `activeClass` - CSS `class` to the element when the link is active. - A `LinkComponent` is considered active when its `currentWhen` property is `true` - or the application's current route is the route the `LinkComponent` would trigger - transitions into. - The `currentWhen` property can match against multiple routes by separating - route names using the ` ` (space) character. - @property active - @private + Set this to provide an alternate class to `Ember.DefaultResolver` + @deprecated Use 'Resolver' instead + @property resolver + @public */ - active: _emberMetal.computed('attrs.params', '_routing.currentState', function computeLinkToComponentActive() { - var currentState = _emberMetal.get(this, '_routing.currentState'); - if (!currentState) { - return false; - } - - return this._computeActive(currentState); - }), - - willBeActive: _emberMetal.computed('_routing.targetState', function computeLinkToComponentWillBeActive() { - var routing = _emberMetal.get(this, '_routing'); - var targetState = _emberMetal.get(routing, 'targetState'); - if (_emberMetal.get(routing, 'currentState') === targetState) { - return; - } + resolver: null, - return !!this._computeActive(targetState); - }), + /** + Set this to provide an alternate class to `Ember.DefaultResolver` + @property resolver + @public + */ + Resolver: null + }); - transitioningIn: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningIn() { - var willBeActive = _emberMetal.get(this, 'willBeActive'); - if (typeof willBeActive === 'undefined') { - return false; - } + /** + This function defines the default lookup rules for container lookups: + + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after classifying the name. + For example, `controller:post` looks up `App.PostController` by default. + * if the default lookup fails, look for registered classes on the container + + This allows the application to register default injections in the container + that could be overridden by the normal naming convention. + + @private + @method resolverFor + @param {Ember.Namespace} namespace the namespace to look for classes + @return {*} the resolved value for a given lookup + */ + function resolverFor(namespace) { + var ResolverClass = namespace.get('Resolver') || _emberApplicationSystemResolver.default; - return !_emberMetal.get(this, 'active') && willBeActive && 'ember-transitioning-in'; - }), + return ResolverClass.create({ + namespace: namespace + }); + } - transitioningOut: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningOut() { - var willBeActive = _emberMetal.get(this, 'willBeActive'); - if (typeof willBeActive === 'undefined') { - return false; + function buildInitializerMethod(bucketName, humanName) { + return function (initializer) { + // If this is the first initializer being added to a subclass, we are going to reopen the class + // to make sure we have a new `initializers` object, which extends from the parent class' using + // prototypal inheritance. Without this, attempting to add initializers to the subclass would + // pollute the parent class as well as other subclasses. + if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) { + var attrs = {}; + attrs[bucketName] = Object.create(this[bucketName]); + this.reopenClass(attrs); } - return _emberMetal.get(this, 'active') && !willBeActive && 'ember-transitioning-out'; - }), + this[bucketName][initializer.name] = initializer; + }; + } - /** - Event handler that invokes the link, activating the associated route. - @method _invoke - @param {Event} event - @private - */ - _invoke: function (event) { - if (!_emberViews.isSimpleClick(event)) { - return true; - } + function commonSetupRegistry(registry) { + registry.optionsForType('component', { singleton: false }); + registry.optionsForType('view', { singleton: false }); - var preventDefault = _emberMetal.get(this, 'preventDefault'); - var targetAttribute = _emberMetal.get(this, 'target'); + registry.register('controller:basic', _emberRuntime.Controller, { instantiate: false }); - if (preventDefault !== false) { - if (!targetAttribute || targetAttribute === '_self') { - event.preventDefault(); - } - } + registry.injection('view', '_viewRegistry', '-view-registry:main'); + registry.injection('renderer', '_viewRegistry', '-view-registry:main'); + registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); - if (_emberMetal.get(this, 'bubbles') === false) { - event.stopPropagation(); - } + registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); - if (_emberMetal.get(this, '_isDisabled')) { - return false; - } + registry.injection('view:-outlet', 'namespace', 'application:main'); - if (_emberMetal.get(this, 'loading')) { - _emberConsole.default.warn('This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'); - return false; - } + registry.injection('controller', 'target', 'router:main'); + registry.injection('controller', 'namespace', 'application:main'); - if (targetAttribute && targetAttribute !== '_self') { - return false; - } + registry.injection('router', '_bucketCache', _container.privatize(_templateObject)); + registry.injection('route', '_bucketCache', _container.privatize(_templateObject)); - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var models = _emberMetal.get(this, 'models'); - var queryParams = _emberMetal.get(this, 'queryParams.values'); - var shouldReplace = _emberMetal.get(this, 'replace'); + registry.injection('route', 'router', 'router:main'); - var payload = { - queryParams: queryParams, - routeName: qualifiedRouteName - }; + // Register the routing service... + registry.register('service:-routing', _emberRouting.RoutingService); + // Then inject the app router into it + registry.injection('service:-routing', 'router', 'router:main'); - _emberMetal.flaggedInstrument('interaction.link-to', payload, this._generateTransition(payload, qualifiedRouteName, models, queryParams, shouldReplace)); - }, + // DEBUGGING + registry.register('resolver-for-debugging:main', registry.resolver, { instantiate: false }); + registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); + registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); + // Custom resolver authors may want to register their own ContainerDebugAdapter with this key - _generateTransition: function (payload, qualifiedRouteName, models, queryParams, shouldReplace) { - var routing = _emberMetal.get(this, '_routing'); - return function () { - payload.transition = routing.transitionTo(qualifiedRouteName, models, queryParams, shouldReplace); - }; - }, + registry.register('container-debug-adapter:main', _emberExtensionSupport.ContainerDebugAdapter); - queryParams: null, + registry.register('component-lookup:main', _emberViews.ComponentLookup); + } - qualifiedRouteName: _emberMetal.computed('targetRouteName', '_routing.currentState', function computeLinkToComponentQualifiedRouteName() { - var params = _emberMetal.get(this, 'params').slice(); - var lastParam = params[params.length - 1]; - if (lastParam && lastParam.isQueryParams) { - params.pop(); - } - var onlyQueryParamsSupplied = this[_emberGlimmerComponent.HAS_BLOCK] ? params.length === 0 : params.length === 1; - if (onlyQueryParamsSupplied) { - return _emberMetal.get(this, '_routing.currentRouteName'); - } - return _emberMetal.get(this, 'targetRouteName'); - }), + exports.default = Engine; +}); +enifed('ember-application/system/resolver', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-application/utils/validate-type', 'ember-glimmer'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberApplicationUtilsValidateType, _emberGlimmer) { + /** + @module ember + @submodule ember-application + */ - resolvedQueryParams: _emberMetal.computed('queryParams', function computeLinkToComponentResolvedQueryParams() { - var resolvedQueryParams = {}; - var queryParams = _emberMetal.get(this, 'queryParams'); + 'use strict'; - if (!queryParams) { - return resolvedQueryParams; - } + var Resolver = _emberRuntime.Object.extend({ + /* + This will be set to the Application instance when it is + created. + @property namespace + */ + namespace: null, + normalize: null, // required + resolve: null, // required + parseName: null, // required + lookupDescription: null, // required + makeToString: null, // required + resolveOther: null, // required + _logLookup: null // required + }); - var values = queryParams.values; - for (var key in values) { - if (!values.hasOwnProperty(key)) { - continue; - } - resolvedQueryParams[key] = values[key]; - } + exports.Resolver = Resolver; + /** + The DefaultResolver defines the default lookup rules to resolve + container lookups before consulting the container for registered + items: + + * templates are looked up on `Ember.TEMPLATES` + * other names are looked up on the application after converting + the name. For example, `controller:post` looks up + `App.PostController` by default. + * there are some nuances (see examples below) + + ### How Resolving Works + + The container calls this object's `resolve` method with the + `fullName` argument. + + It first parses the fullName into an object using `parseName`. + + Then it checks for the presence of a type-specific instance + method of the form `resolve[Type]` and calls it if it exists. + For example if it was resolving 'template:post', it would call + the `resolveTemplate` method. + + Its last resort is to call the `resolveOther` method. + + The methods of this object are designed to be easy to override + in a subclass. For example, you could enhance how a template + is resolved like so: + + ```javascript + App = Ember.Application.create({ + Resolver: Ember.DefaultResolver.extend({ + resolveTemplate: function(parsedName) { + let resolvedTemplate = this._super(parsedName); + if (resolvedTemplate) { return resolvedTemplate; } + return Ember.TEMPLATES['not_found']; + } + }) + }); + ``` + + Some examples of how names are resolved: + + ``` + 'template:post' //=> Ember.TEMPLATES['post'] + 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] + 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] + // OR + // Ember.TEMPLATES['blog_post'] + 'controller:post' //=> App.PostController + 'controller:posts.index' //=> App.PostsIndexController + 'controller:blog/post' //=> Blog.PostController + 'controller:basic' //=> Ember.Controller + 'route:post' //=> App.PostRoute + 'route:posts.index' //=> App.PostsIndexRoute + 'route:blog/post' //=> Blog.PostRoute + 'route:basic' //=> Ember.Route + 'view:post' //=> App.PostView + 'view:posts.index' //=> App.PostsIndexView + 'view:blog/post' //=> Blog.PostView + 'view:basic' //=> Ember.View + 'foo:post' //=> App.PostFoo + 'model:post' //=> App.Post + ``` + + @class DefaultResolver + @namespace Ember + @extends Ember.Object + @public + */ - return resolvedQueryParams; - }), + exports.default = _emberRuntime.Object.extend({ + /** + This will be set to the Application instance when it is + created. + @property namespace + @public + */ + namespace: null, + + init: function () { + this._parseNameCache = _emberUtils.dictionary(null); + }, + normalize: function (fullName) { + var _fullName$split = fullName.split(':', 2); + + var type = _fullName$split[0]; + var name = _fullName$split[1]; + + if (type !== 'template') { + var result = name; + + if (result.indexOf('.') > -1) { + result = result.replace(/\.(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); + } + + if (name.indexOf('_') > -1) { + result = result.replace(/_(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); + } + + if (name.indexOf('-') > -1) { + result = result.replace(/-(.)/g, function (m) { + return m.charAt(1).toUpperCase(); + }); + } + + return type + ':' + result; + } else { + return fullName; + } + }, /** - Sets the element's `href` attribute to the url for - the `LinkComponent`'s targeted route. - If the `LinkComponent`'s `tagName` is changed to a value other - than `a`, this property will be ignored. - @property href - @private + This method is called via the container's resolver method. + It parses the provided `fullName` and then looks up and + returns the appropriate template or class. + @method resolve + @param {String} fullName the lookup string + @return {Object} the resolved factory + @public */ - href: _emberMetal.computed('models', 'qualifiedRouteName', function computeLinkToComponentHref() { - if (_emberMetal.get(this, 'tagName') !== 'a') { - return; + resolve: function (fullName) { + var parsedName = this.parseName(fullName); + var resolveMethodName = parsedName.resolveMethodName; + var resolved = undefined; + + if (this[resolveMethodName]) { + resolved = this[resolveMethodName](parsedName); } - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var models = _emberMetal.get(this, 'models'); + resolved = resolved || this.resolveOther(parsedName); - if (_emberMetal.get(this, 'loading')) { - return _emberMetal.get(this, 'loadingHref'); + if (resolved) { + _emberApplicationUtilsValidateType.default(resolved, parsedName); } - var routing = _emberMetal.get(this, '_routing'); - var queryParams = _emberMetal.get(this, 'queryParams.values'); + return resolved; + }, - return routing.generateURL(qualifiedRouteName, models, queryParams); - }), + /** + Convert the string name of the form 'type:name' to + a Javascript object with the parsed aspects of the name + broken out. + @param {String} fullName the lookup string + @method parseName + @protected + */ - loading: _emberMetal.computed('_modelsAreLoaded', 'qualifiedRouteName', function computeLinkToComponentLoading() { - var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); - var modelsAreLoaded = _emberMetal.get(this, '_modelsAreLoaded'); + parseName: function (fullName) { + return this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)); + }, - if (!modelsAreLoaded || qualifiedRouteName == null) { - return _emberMetal.get(this, 'loadingClass'); + _parseName: function (fullName) { + var _fullName$split2 = fullName.split(':'); + + var type = _fullName$split2[0]; + var fullNameWithoutType = _fullName$split2[1]; + + var name = fullNameWithoutType; + var namespace = _emberMetal.get(this, 'namespace'); + var root = namespace; + var lastSlashIndex = name.lastIndexOf('/'); + var dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null; + + if (type !== 'template' && lastSlashIndex !== -1) { + var parts = name.split('/'); + name = parts[parts.length - 1]; + var namespaceName = _emberRuntime.String.capitalize(parts.slice(0, -1).join('.')); + root = _emberRuntime.Namespace.byName(namespaceName); } - }), - _modelsAreLoaded: _emberMetal.computed('models', function computeLinkToComponentModelsAreLoaded() { - var models = _emberMetal.get(this, 'models'); - for (var i = 0; i < models.length; i++) { - if (models[i] == null) { - return false; - } + var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : _emberRuntime.String.classify(type); + + if (!(name && type)) { + throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); } - return true; - }), + return { + fullName: fullName, + type: type, + fullNameWithoutType: fullNameWithoutType, + dirname: dirname, + name: name, + root: root, + resolveMethodName: 'resolve' + resolveMethodName + }; + }, - _getModels: function (params) { - var modelCount = params.length - 1; - var models = new Array(modelCount); + /** + Returns a human-readable description for a fullName. Used by the + Application namespace in assertions to describe the + precise name of the class that Ember is looking for, rather than + container keys. + @param {String} fullName the lookup string + @method lookupDescription + @protected + */ + lookupDescription: function (fullName) { + var parsedName = this.parseName(fullName); + var description = undefined; - for (var i = 0; i < modelCount; i++) { - var value = params[i + 1]; + if (parsedName.type === 'template') { + return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + } - while (_emberRuntime.ControllerMixin.detect(value)) { - value = value.get('model'); - } + description = parsedName.root + '.' + _emberRuntime.String.classify(parsedName.name).replace(/\./g, ''); - models[i] = value; + if (parsedName.type !== 'model') { + description += _emberRuntime.String.classify(parsedName.type); } - return models; + return description; + }, + + makeToString: function (factory, fullName) { + return factory.toString(); }, /** - The default href value to use while a link-to is loading. - Only applies when tagName is 'a' - @property loadingHref - @type String - @default # - @private + Given a parseName object (output from `parseName`), apply + the conventions expected by `Ember.Router` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method useRouterNaming + @protected */ - loadingHref: '#', + useRouterNaming: function (parsedName) { + parsedName.name = parsedName.name.replace(/\./g, '_'); + if (parsedName.name === 'basic') { + parsedName.name = ''; + } + }, + /** + Look up the template in Ember.TEMPLATES + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveTemplate + @protected + */ + resolveTemplate: function (parsedName) { + var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); - didReceiveAttrs: function () { - var queryParams = undefined; + return _emberGlimmer.getTemplate(templateName) || _emberGlimmer.getTemplate(_emberRuntime.String.decamelize(templateName)); + }, - var params = _emberMetal.get(this, 'params'); + /** + Lookup the view using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveView + @protected + */ + resolveView: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, - if (params) { - // Do not mutate params in place - params = params.slice(); - } + /** + Lookup the controller using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveController + @protected + */ + resolveController: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, + /** + Lookup the route using `resolveOther` + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveRoute + @protected + */ + resolveRoute: function (parsedName) { + this.useRouterNaming(parsedName); + return this.resolveOther(parsedName); + }, - var disabledWhen = _emberMetal.get(this, 'disabledWhen'); - if (disabledWhen !== undefined) { - this.set('disabled', disabledWhen); - } + /** + Lookup the model on the Application namespace + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveModel + @protected + */ + resolveModel: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.name); + var factory = _emberMetal.get(parsedName.root, className); - // Process the positional arguments, in order. - // 1. Inline link title comes first, if present. - if (!this[_emberGlimmerComponent.HAS_BLOCK]) { - this.set('linkTitle', params.shift()); - } + return factory; + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveHelper + @protected + */ + resolveHelper: function (parsedName) { + return this.resolveOther(parsedName); + }, + /** + Look up the specified object (from parsedName) on the appropriate + namespace (usually on the Application) + @param {Object} parsedName a parseName object with the parsed + fullName lookup string + @method resolveOther + @protected + */ + resolveOther: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.name) + _emberRuntime.String.classify(parsedName.type); + var factory = _emberMetal.get(parsedName.root, className); + return factory; + }, - // 2. `targetRouteName` is now always at index 0. - this.set('targetRouteName', params[0]); + resolveMain: function (parsedName) { + var className = _emberRuntime.String.classify(parsedName.type); + return _emberMetal.get(parsedName.root, className); + }, - // 3. The last argument (if still remaining) is the `queryParams` object. - var lastParam = params[params.length - 1]; + /** + @method _logLookup + @param {Boolean} found + @param {Object} parsedName + @private + */ + _logLookup: function (found, parsedName) { + var symbol = undefined, + padding = undefined; - if (lastParam && lastParam.isQueryParams) { - queryParams = params.pop(); + if (found) { + symbol = '[✓]'; } else { - queryParams = { values: {} }; + symbol = '[ ]'; } - this.set('queryParams', queryParams); - // 4. Any remaining indices (excepting `targetRouteName` at 0) are `models`. - if (params.length > 1) { - this.set('models', this._getModels(params)); + if (parsedName.fullName.length > 60) { + padding = '.'; } else { - this.set('models', []); + padding = new Array(60 - parsedName.fullName.length).join('.'); } - } - }); + }, - LinkComponent.toString = function () { - return 'LinkComponent'; - }; + /** + Used to iterate all items of a given type. + @method knownForType + @param {String} type the type to search for + @private + */ + knownForType: function (type) { + var namespace = _emberMetal.get(this, 'namespace'); + var suffix = _emberRuntime.String.classify(type); + var typeRegexp = new RegExp(suffix + '$'); - LinkComponent.reopenClass({ - positionalParams: 'params' - }); + var known = _emberUtils.dictionary(null); + var knownKeys = Object.keys(namespace); + for (var index = 0; index < knownKeys.length; index++) { + var _name = knownKeys[index]; - exports.default = LinkComponent; -}); + if (typeRegexp.test(_name)) { + var containerName = this.translateToContainerFullname(type, _name); -/* - * Unfortunately, to get decent error messages, we need to do this. - * In some future state we should be able to use a "feature flag" - * which allows us to strip this without needing to call it twice. - * - * if (isDebugBuild()) { - * // Do the useful debug thing, probably including try/catch. - * } else { - * // Do the performant thing. - * } - */ -enifed('ember-glimmer/components/text_area', ['exports', 'ember-glimmer/component', 'ember-views', 'ember-glimmer/templates/empty'], function (exports, _emberGlimmerComponent, _emberViews, _emberGlimmerTemplatesEmpty) { + known[containerName] = true; + } + } + + return known; + }, + + /** + Converts provided name from the backing namespace into a container lookup name. + Examples: + App.FooBarHelper -> helper:foo-bar + App.THelper -> helper:t + @method translateToContainerFullname + @param {String} type + @param {String} name + @private + */ + + translateToContainerFullname: function (type, name) { + var suffix = _emberRuntime.String.classify(type); + var namePrefix = name.slice(0, suffix.length * -1); + var dasherizedName = _emberRuntime.String.dasherize(namePrefix); + + return type + ':' + dasherizedName; + } + }); +}); +enifed('ember-application/utils/validate-type', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** @module ember - @submodule ember-glimmer + @submodule ember-application */ + 'use strict'; - /** - `{{textarea}}` inserts a new instance of ` - ``` - - Bound: - - In the following example, the `writtenWords` property on `App.ApplicationController` - will be updated live as the user types 'Lots of text that IS bound' into - the text area of their browser's window. - - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound" - }); - ``` - - ```handlebars - {{textarea value=writtenWords}} - ``` - - Would result in the following HTML: - - ```html - - ``` - - If you wanted a one way binding between the text area and a div tag - somewhere else on your screen, you could use `Ember.computed.oneWay`: - - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound", - outputWrittenWords: Ember.computed.oneWay("writtenWords") - }); - ``` - - ```handlebars - {{textarea value=writtenWords}} -
    - {{outputWrittenWords}} -
    - ``` - - Would result in the following HTML: - - ```html - - <-- the following div will be updated in real time as you type --> -
    - Lots of text that IS bound -
    - ``` - - Finally, this example really shows the power and ease of Ember when two - properties are bound to eachother via `Ember.computed.alias`. Type into - either text area box and they'll both stay in sync. Note that - `Ember.computed.alias` costs more in terms of performance, so only use it when - your really binding in both directions: - - ```javascript - App.ApplicationController = Ember.Controller.extend({ - writtenWords: "Lots of text that IS bound", - twoWayWrittenWords: Ember.computed.alias("writtenWords") - }); - ``` - - ```handlebars - {{textarea value=writtenWords}} - {{textarea value=twoWayWrittenWords}} - ``` - - ```html - - <-- both updated in real time --> - - ``` - - ### Actions - - The helper can send multiple actions based on user events. - The action property defines the action which is send when - the user presses the return key. - - ```handlebars - {{input action="submit"}} - ``` - - The helper allows some user events to send actions. - - * `enter` - * `insert-newline` - * `escape-press` - * `focus-in` - * `focus-out` - * `key-press` - - For example, if you desire an action to be sent when the input is blurred, - you only need to setup the action name to the event name property. - - ```handlebars - {{textarea focus-in="alertMessage"}} - ``` - - See more about [Text Support Actions](/api/classes/Ember.TextArea.html) - - ### Extension - - Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing - arguments from the helper to `Ember.TextArea`'s `create` method. You can - extend the capabilities of text areas in your application by reopening this - class. For example, if you are building a Bootstrap project where `data-*` - attributes are used, you can globally add support for a `data-*` attribute - on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or - `Ember.TextSupport` and adding it to the `attributeBindings` concatenated - property: - - ```javascript - Ember.TextArea.reopen({ - attributeBindings: ['data-error'] - }); - ``` - - Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` - itself extends `Ember.Component`. Expect isolated component semantics, not - legacy 1.x view semantics (like `controller` being present). - - See more about [Ember components](/api/classes/Ember.Component.html) - - @method textarea - @for Ember.Templates.helpers - @param {Hash} options - @public - */ + exports.default = validateType; - /** - The internal class used to create textarea element when the `{{textarea}}` - helper is used. - - See [Ember.Templates.helpers.textarea](/api/classes/Ember.Templates.helpers.html#method_textarea) for usage details. - - ## Layout and LayoutName properties - - Because HTML `textarea` elements do not contain inner HTML the `layout` and - `layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. - - @class TextArea - @namespace Ember - @extends Ember.Component - @uses Ember.TextSupport - @public - */ - exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { - classNames: ['ember-text-area'], + var VALIDATED_TYPES = { + route: ['assert', 'isRouteFactory', 'Ember.Route'], + component: ['deprecate', 'isComponentFactory', 'Ember.Component'], + view: ['deprecate', 'isViewFactory', 'Ember.View'], + service: ['deprecate', 'isServiceFactory', 'Ember.Service'] + }; - layout: _emberGlimmerTemplatesEmpty.default, + function validateType(resolvedType, parsedName) { + var validationAttributes = VALIDATED_TYPES[parsedName.type]; - tagName: 'textarea', - attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir', 'value'], - rows: null, - cols: null - }); + if (!validationAttributes) { + return; + } + + var action = validationAttributes[0]; + var factoryFlag = validationAttributes[1]; + var expectedType = validationAttributes[2]; + + if (action === 'deprecate') {} else {} + } }); -enifed('ember-glimmer/components/text_field', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-glimmer/component', 'ember-glimmer/templates/empty', 'ember-views'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty, _emberViews) { - /** - @module ember - @submodule ember-views - */ +enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { 'use strict'; - var inputTypeTestElement = undefined; - var inputTypes = new _emberUtils.EmptyObject(); - function canSetTypeOfInput(type) { - if (type in inputTypes) { - return inputTypes[type]; + function K() {} + + function consoleMethod(name) { + var consoleObj = undefined; + if (_emberEnvironment.context.imports.console) { + consoleObj = _emberEnvironment.context.imports.console; + } else if (typeof console !== 'undefined') { + consoleObj = console; } - // if running in outside of a browser always return the - // original type - if (!_emberEnvironment.environment.hasDOM) { - inputTypes[type] = type; + var method = typeof consoleObj === 'object' ? consoleObj[name] : null; - return type; + if (typeof method !== 'function') { + return; } - if (!inputTypeTestElement) { - inputTypeTestElement = document.createElement('input'); + if (typeof method.bind === 'function') { + return method.bind(consoleObj); } - try { - inputTypeTestElement.type = type; - } catch (e) {} + return function () { + method.apply(consoleObj, arguments); + }; + } - return inputTypes[type] = inputTypeTestElement.type === type; + function assertPolyfill(test, message) { + if (!test) { + try { + // attempt to preserve the stack + throw new Error('assertion failed: ' + message); + } catch (error) { + setTimeout(function () { + throw error; + }, 0); + } + } } /** + Inside Ember-Metal, simply uses the methods from `imports.console`. + Override this to provide more robust logging functionality. - The internal class used to create text inputs when the `{{input}}` - helper is used with `type` of `text`. - - See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. - - ## Layout and LayoutName properties - - Because HTML `input` elements are self closing `layout` and `layoutName` - properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s - layout section for more information. - - @class TextField + @class Logger @namespace Ember - @extends Ember.Component - @uses Ember.TextSupport @public */ - exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { - layout: _emberGlimmerTemplatesEmpty.default, - classNames: ['ember-text-field'], - tagName: 'input', - attributeBindings: ['accept', 'autocomplete', 'autosave', 'dir', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'inputmode', 'lang', 'list', 'max', 'min', 'multiple', 'name', 'pattern', 'size', 'step', 'type', 'value', 'width'], - + exports.default = { /** - The `value` attribute of the input element. As the user inputs text, this - property is updated live. - @property value - @type String - @default "" - @public + Logs the arguments to the console. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.log('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method log + @for Ember.Logger + @param {*} arguments + @public */ - value: '', + log: consoleMethod('log') || K, /** - The `type` attribute of the input element. - @property type - @type String - @default "text" - @public + Prints the arguments to the console with a warning icon. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + Ember.Logger.warn('Something happened!'); + // "Something happened!" will be printed to the console with a warning icon. + ``` + @method warn + @for Ember.Logger + @param {*} arguments + @public */ - type: _emberMetal.computed({ - get: function () { - return 'text'; - }, - - set: function (key, value) { - var type = 'text'; - - if (canSetTypeOfInput(value)) { - type = value; - } - - return type; - } - }), + warn: consoleMethod('warn') || K, /** - The `size` of the text field in characters. - @property size - @type String - @default null - @public + Prints the arguments to the console with an error icon, red text and a stack trace. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + Ember.Logger.error('Danger! Danger!'); + // "Danger! Danger!" will be printed to the console in red text. + ``` + @method error + @for Ember.Logger + @param {*} arguments + @public */ - size: null, + error: consoleMethod('error') || K, /** - The `pattern` attribute of input element. - @property pattern - @type String - @default null - @public + Logs the arguments to the console. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.info('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method info + @for Ember.Logger + @param {*} arguments + @public */ - pattern: null, + info: consoleMethod('info') || K, /** - The `min` attribute of input element used with `type="number"` or `type="range"`. - @property min - @type String - @default null - @since 1.4.0 - @public + Logs the arguments to the console in blue text. + You can pass as many arguments as you want and they will be joined together with a space. + ```javascript + var foo = 1; + Ember.Logger.debug('log value of foo:', foo); + // "log value of foo: 1" will be printed to the console + ``` + @method debug + @for Ember.Logger + @param {*} arguments + @public */ - min: null, + debug: consoleMethod('debug') || consoleMethod('info') || K, /** - The `max` attribute of input element used with `type="number"` or `type="range"`. - @property max - @type String - @default null - @since 1.4.0 - @public + If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. + ```javascript + Ember.Logger.assert(true); // undefined + Ember.Logger.assert(true === false); // Throws an Assertion failed error. + Ember.Logger.assert(true === false, 'Something invalid'); // Throws an Assertion failed error with message. + ``` + @method assert + @for Ember.Logger + @param {Boolean} bool Value to test + @param {String} message Assertion message on failed + @public */ - max: null - }); + assert: consoleMethod('assert') || assertPolyfill + }; }); -enifed('ember-glimmer/dom', ['exports', 'glimmer-runtime', 'glimmer-node'], function (exports, _glimmerRuntime, _glimmerNode) { - 'use strict'; +enifed('ember-environment/global', ['exports'], function (exports) { + /* globals global, window, self, mainContext */ - exports.DOMChanges = _glimmerRuntime.DOMChanges; - exports.DOMTreeConstruction = _glimmerRuntime.DOMTreeConstruction; - exports.NodeDOMTreeConstruction = _glimmerNode.NodeDOMTreeConstruction; -}); -enifed('ember-glimmer/environment', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'glimmer-runtime', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/if-unless', 'ember-glimmer/utils/bindings', 'ember-glimmer/helpers/action', 'ember-glimmer/helpers/component', 'ember-glimmer/helpers/concat', 'ember-glimmer/helpers/debugger', 'ember-glimmer/helpers/get', 'ember-glimmer/helpers/hash', 'ember-glimmer/helpers/loc', 'ember-glimmer/helpers/log', 'ember-glimmer/helpers/mut', 'ember-glimmer/helpers/readonly', 'ember-glimmer/helpers/unbound', 'ember-glimmer/helpers/-class', 'ember-glimmer/helpers/-input-type', 'ember-glimmer/helpers/query-param', 'ember-glimmer/helpers/each-in', 'ember-glimmer/helpers/-normalize-class', 'ember-glimmer/helpers/-html-safe', 'ember-glimmer/protocol-for-url', 'ember-glimmer/modifiers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _glimmerRuntime, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntax, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerHelpersIfUnless, _emberGlimmerUtilsBindings, _emberGlimmerHelpersAction, _emberGlimmerHelpersComponent, _emberGlimmerHelpersConcat, _emberGlimmerHelpersDebugger, _emberGlimmerHelpersGet, _emberGlimmerHelpersHash, _emberGlimmerHelpersLoc, _emberGlimmerHelpersLog, _emberGlimmerHelpersMut, _emberGlimmerHelpersReadonly, _emberGlimmerHelpersUnbound, _emberGlimmerHelpersClass, _emberGlimmerHelpersInputType, _emberGlimmerHelpersQueryParam, _emberGlimmerHelpersEachIn, _emberGlimmerHelpersNormalizeClass, _emberGlimmerHelpersHtmlSafe, _emberGlimmerProtocolForUrl, _emberGlimmerModifiersAction) { + // from lodash to catch fake globals 'use strict'; - var builtInComponents = { - textarea: '-text-area' - }; + function checkGlobal(value) { + return value && value.Object === Object ? value : undefined; + } - var Environment = (function (_GlimmerEnvironment) { - babelHelpers.inherits(Environment, _GlimmerEnvironment); + // element ids can ruin global miss checks + function checkElementIdShadowing(value) { + return value && value.nodeType === undefined ? value : undefined; + } - Environment.create = function create(options) { - return new Environment(options); - }; + // export real global + exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper + new Function('return this')(); + // eval outside of strict mode +}); +enifed('ember-environment/index', ['exports', 'ember-environment/global', 'ember-environment/utils'], function (exports, _emberEnvironmentGlobal, _emberEnvironmentUtils) { + /* globals module */ + 'use strict'; - function Environment(_ref) { - var _this = this; + /** + 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 + backwards compatibility with earlier versions of Ember). The `EmberENV` + hash must be created before loading Ember. + + @class EmberENV + @type Object + @public + */ + var ENV = typeof _emberEnvironmentGlobal.default.EmberENV === 'object' && _emberEnvironmentGlobal.default.EmberENV || typeof _emberEnvironmentGlobal.default.ENV === 'object' && _emberEnvironmentGlobal.default.ENV || {}; - var owner = _ref[_emberUtils.OWNER]; + exports.ENV = ENV; + // ENABLE_ALL_FEATURES was documented, but you can't actually enable non optional features. + if (ENV.ENABLE_ALL_FEATURES) { + ENV.ENABLE_OPTIONAL_FEATURES = true; + } - _GlimmerEnvironment.apply(this, arguments); - this.owner = owner; - this.isInteractive = owner.lookup('-environment:main').isInteractive; + /** + Determines whether Ember should add to `Array`, `Function`, and `String` + native object prototypes, a few extra methods in order to provide a more + friendly API. + + We generally recommend leaving this option set to true however, if you need + to turn it off, you can add the configuration property + `EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`. + + Note, when disabled (the default configuration for Ember Addons), you will + instead have to access all methods and functions from the Ember + namespace. + + @property EXTEND_PROTOTYPES + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.EXTEND_PROTOTYPES = _emberEnvironmentUtils.normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); - // can be removed once https://github.com/tildeio/glimmer/pull/305 lands - this.destroyedComponents = undefined; + /** + The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log + a full stack trace during deprecation warnings. + + @property LOG_STACKTRACE_ON_DEPRECATION + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.LOG_STACKTRACE_ON_DEPRECATION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); - _emberGlimmerProtocolForUrl.default(this); + /** + The `LOG_VERSION` property, when true, tells Ember to log versions of all + dependent libraries in use. + + @property LOG_VERSION + @type Boolean + @default true + @for EmberENV + @public + */ + ENV.LOG_VERSION = _emberEnvironmentUtils.defaultTrue(ENV.LOG_VERSION); - this._definitionCache = new _emberMetal.Cache(2000, function (_ref2) { - var name = _ref2.name; - var source = _ref2.source; - var owner = _ref2.owner; + // default false + ENV.MODEL_FACTORY_INJECTIONS = _emberEnvironmentUtils.defaultFalse(ENV.MODEL_FACTORY_INJECTIONS); - var _lookupComponent = _emberViews.lookupComponent(owner, name, { source: source }); + /** + Debug parameter you can turn on. This will log all bindings that fire to + the console. This should be disabled in production code. Note that you + can also enable this from the console or temporarily. + + @property LOG_BINDINGS + @for EmberENV + @type Boolean + @default false + @public + */ + ENV.LOG_BINDINGS = _emberEnvironmentUtils.defaultFalse(ENV.LOG_BINDINGS); - var ComponentClass = _lookupComponent.component; - var layout = _lookupComponent.layout; + ENV.RAISE_ON_DEPRECATION = _emberEnvironmentUtils.defaultFalse(ENV.RAISE_ON_DEPRECATION); - if (ComponentClass || layout) { - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(name, ComponentClass, layout); - } - }, function (_ref3) { - var name = _ref3.name; - var source = _ref3.source; - var owner = _ref3.owner; + // check if window exists and actually is the global + var hasDOM = typeof window !== 'undefined' && window === _emberEnvironmentGlobal.default && window.document && window.document.createElement && !ENV.disableBrowserEnvironment; // is this a public thing? - var expandedName = source && owner._resolveLocalLookupName(name, source) || name; - var ownerGuid = _emberUtils.guidFor(owner); + // legacy imports/exports/lookup stuff (should we keep this??) + var originalContext = _emberEnvironmentGlobal.default.Ember || {}; - return ownerGuid + '|' + expandedName; - }); + var context = { + // import jQuery + imports: originalContext.imports || _emberEnvironmentGlobal.default, + // export Ember + exports: originalContext.exports || _emberEnvironmentGlobal.default, + // search for Namespaces + lookup: originalContext.lookup || _emberEnvironmentGlobal.default + }; - this._templateCache = new _emberMetal.Cache(1000, function (_ref4) { - var Template = _ref4.Template; - var owner = _ref4.owner; - - if (Template.create) { - var _Template$create; + exports.context = context; + // TODO: cleanup single source of truth issues with this stuff + var environment = hasDOM ? { + hasDOM: true, + isChrome: !!window.chrome && !window.opera, + isFirefox: typeof InstallTrigger !== 'undefined', + isPhantom: !!window.callPhantom, + location: window.location, + history: window.history, + userAgent: window.navigator.userAgent, + window: window + } : { + hasDOM: false, + isChrome: false, + isFirefox: false, + isPhantom: false, + location: null, + history: null, + userAgent: 'Lynx (textmode)', + window: null + }; + exports.environment = environment; +}); +enifed("ember-environment/utils", ["exports"], function (exports) { + "use strict"; - // we received a factory - return Template.create((_Template$create = { env: _this }, _Template$create[_emberUtils.OWNER] = owner, _Template$create)); - } else { - // we were provided an instance already - return Template; - } - }, function (_ref5) { - var Template = _ref5.Template; - var owner = _ref5.owner; - return _emberUtils.guidFor(owner) + '|' + Template.id; - }); + exports.defaultTrue = defaultTrue; + exports.defaultFalse = defaultFalse; + exports.normalizeExtendPrototypes = normalizeExtendPrototypes; - this._compilerCache = new _emberMetal.Cache(10, function (Compiler) { - return new _emberMetal.Cache(2000, function (template) { - var compilable = new Compiler(template); - return _glimmerRuntime.compileLayout(compilable, _this); - }, function (template) { - var owner = template.meta.owner; - return _emberUtils.guidFor(owner) + '|' + template.id; - }); - }, function (Compiler) { - return Compiler.id; - }); + function defaultTrue(v) { + return v === false ? false : true; + } - this.builtInModifiers = { - action: new _emberGlimmerModifiersAction.default() - }; + function defaultFalse(v) { + return v === true ? true : false; + } - this.builtInHelpers = { - if: _emberGlimmerHelpersIfUnless.inlineIf, - action: _emberGlimmerHelpersAction.default, - component: _emberGlimmerHelpersComponent.default, - concat: _emberGlimmerHelpersConcat.default, - debugger: _emberGlimmerHelpersDebugger.default, - get: _emberGlimmerHelpersGet.default, - hash: _emberGlimmerHelpersHash.default, - loc: _emberGlimmerHelpersLoc.default, - log: _emberGlimmerHelpersLog.default, - mut: _emberGlimmerHelpersMut.default, - 'query-params': _emberGlimmerHelpersQueryParam.default, - readonly: _emberGlimmerHelpersReadonly.default, - unbound: _emberGlimmerHelpersUnbound.default, - unless: _emberGlimmerHelpersIfUnless.inlineUnless, - '-class': _emberGlimmerHelpersClass.default, - '-each-in': _emberGlimmerHelpersEachIn.default, - '-input-type': _emberGlimmerHelpersInputType.default, - '-normalize-class': _emberGlimmerHelpersNormalizeClass.default, - '-html-safe': _emberGlimmerHelpersHtmlSafe.default, - '-get-dynamic-var': _glimmerRuntime.getDynamicVar + function normalizeExtendPrototypes(obj) { + if (obj === false) { + return { String: false, Array: false, Function: false }; + } else if (!obj || obj === true) { + return { String: true, Array: true, Function: true }; + } else { + return { + String: defaultTrue(obj.String), + Array: defaultTrue(obj.Array), + Function: defaultTrue(obj.Function) }; } + } +}); +enifed('ember-extension-support/container_debug_adapter', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; - // Hello future traveler, welcome to the world of syntax refinement. - // The method below is called by Glimmer's runtime compiler to allow - // us to take generic statement syntax and refine it to more meaniful - // syntax for Ember's use case. This on the fly switch-a-roo sounds fine - // and dandy, however Ember has precedence on statement refinement that you - // need to be aware of. The presendence for language constructs is as follows: - // - // ------------------------ - // Native & Built-in Syntax - // ------------------------ - // User-land components - // ------------------------ - // User-land helpers - // ------------------------ - // - // The one caveat here is that Ember also allows for dashed references that are - // not a component or helper: - // - // export default Component.extend({ - // 'foo-bar': 'LAME' - // }); - // - // {{foo-bar}} - // - // The heuristic for the above situation is a dashed "key" in inline form - // that does not resolve to a defintion. In this case refine statement simply - // isn't going to return any syntax and the Glimmer engine knows how to handle - // this case. - - Environment.prototype.refineStatement = function refineStatement(statement, symbolTable) { - // 1. resolve any native syntax – if, unless, with, each, and partial - var nativeSyntax = _GlimmerEnvironment.prototype.refineStatement.call(this, statement, symbolTable); + /** + @module ember + @submodule ember-extension-support + */ - if (nativeSyntax) { - return nativeSyntax; + /** + The `ContainerDebugAdapter` helps the container and resolver interface + with tools that debug Ember such as the + [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class can be extended by a custom resolver implementer + to override some of the methods with library-specific code. + + The methods likely to be overridden are: + + * `canCatalogEntriesByType` + * `catalogEntriesByType` + + The adapter will need to be registered + in the application's container as `container-debug-adapter:main`. + + Example: + + ```javascript + Application.initializer({ + name: "containerDebugAdapter", + + initialize(application) { + application.register('container-debug-adapter:main', require('app/container-debug-adapter')); } + }); + ``` + + @class ContainerDebugAdapter + @namespace Ember + @extends Ember.Object + @since 1.5.0 + @public + */ + exports.default = _emberRuntime.Object.extend({ + /** + The resolver instance of the application + being debugged. This property will be injected + on creation. + @property resolver + @default null + @public + */ + resolver: null, - var appendType = statement.appendType; - var isSimple = statement.isSimple; - var isInline = statement.isInline; - var isBlock = statement.isBlock; - var isModifier = statement.isModifier; - var key = statement.key; - var path = statement.path; - var args = statement.args; - - if (isSimple && (isInline || isBlock) && appendType !== 'get') { - // 2. built-in syntax + /** + Returns true if it is possible to catalog a list of available + classes in the resolver for a given type. + @method canCatalogEntriesByType + @param {String} type The type. e.g. "model", "controller", "route". + @return {boolean} whether a list is available for this type. + @public + */ + canCatalogEntriesByType: function (type) { + if (type === 'model' || type === 'template') { + return false; + } - var RefinedSyntax = _emberGlimmerSyntax.findSyntaxBuilder(key); - if (RefinedSyntax) { - return RefinedSyntax.create(this, args, symbolTable); - } + return true; + }, - var internalKey = builtInComponents[key]; - var definition = null; + /** + Returns the available classes a given type. + @method catalogEntriesByType + @param {String} type The type. e.g. "model", "controller", "route". + @return {Array} An array of strings. + @public + */ + catalogEntriesByType: function (type) { + var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); + var types = _emberRuntime.A(); + var typeSuffixRegex = new RegExp(_emberRuntime.String.classify(type) + '$'); - if (internalKey) { - definition = this.getComponentDefinition([internalKey], symbolTable); - } else if (key.indexOf('-') >= 0) { - definition = this.getComponentDefinition(path, symbolTable); + namespaces.forEach(function (namespace) { + if (namespace !== _emberMetal.default) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { + continue; + } + if (typeSuffixRegex.test(key)) { + var klass = namespace[key]; + if (_emberRuntime.typeOf(klass) === 'class') { + types.push(_emberRuntime.String.dasherize(key.replace(typeSuffixRegex, ''))); + } + } + } } + }); + return types; + } + }); +}); +// Ember as namespace +enifed('ember-extension-support/data_adapter', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'container', 'ember-application'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _container, _emberApplication) { + 'use strict'; - if (definition) { - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); + /** + @module ember + @submodule ember-extension-support + */ - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } + /** + The `DataAdapter` helps a data persistence library + interface with tools that debug Ember such + as the [Ember Extension](https://github.com/tildeio/ember-extension) + for Chrome and Firefox. + + This class will be extended by a persistence library + which will override some of the methods with + library-specific code. + + The methods likely to be overridden are: + + * `getFilters` + * `detect` + * `columnsForType` + * `getRecords` + * `getRecordColumnValues` + * `getRecordKeywords` + * `getRecordFilterValues` + * `getRecordColor` + * `observeRecord` + + The adapter will need to be registered + in the application's container as `dataAdapter:main`. + + Example: + + ```javascript + Application.initializer({ + name: "data-adapter", + + initialize: function(application) { + application.register('data-adapter:main', DS.DataAdapter); } + }); + ``` + + @class DataAdapter + @namespace Ember + @extends EmberObject + @public + */ + exports.default = _emberRuntime.Object.extend({ + init: function () { + this._super.apply(this, arguments); + this.releaseMethods = _emberRuntime.A(); + }, - if (isInline && !isSimple && appendType !== 'helper') { - return statement.original.deopt(); - } + /** + The container-debug-adapter which is used + to list all models. + @property containerDebugAdapter + @default undefined + @since 1.5.0 + @public + **/ + containerDebugAdapter: undefined, - if (!isSimple && path) { - return _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax.fromPath(this, path, args, symbolTable); - } - }; + /** + The number of attributes to send + as columns. (Enough to make the record + identifiable). + @private + @property attributeLimit + @default 3 + @since 1.3.0 + */ + attributeLimit: 3, - Environment.prototype.hasComponentDefinition = function hasComponentDefinition() { - return false; - }; + /** + Ember Data > v1.0.0-beta.18 + requires string model names to be passed + around instead of the actual factories. + This is a stamp for the Ember Inspector + to differentiate between the versions + to be able to support older versions too. + @public + @property acceptsModelName + */ + acceptsModelName: true, - Environment.prototype.getComponentDefinition = function getComponentDefinition(path, symbolTable) { - var name = path[0]; - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var source = blockMeta.moduleName && 'template:' + blockMeta.moduleName; + /** + Stores all methods that clear observers. + These methods will be called on destruction. + @private + @property releaseMethods + @since 1.3.0 + */ + releaseMethods: _emberRuntime.A(), - return this._definitionCache.get({ name: name, source: source, owner: owner }); - }; + /** + Specifies how records can be filtered. + Records returned will need to have a `filterValues` + property with a key for every name in the returned array. + @public + @method getFilters + @return {Array} List of objects defining filters. + The object should have a `name` and `desc` property. + */ + getFilters: function () { + return _emberRuntime.A(); + }, - // normally templates should be exported at the proper module name - // and cached in the container, but this cache supports templates - // that have been set directly on the component's layout property + /** + Fetch the model types and observe them for changes. + @public + @method watchModelTypes + @param {Function} typesAdded Callback to call to add types. + Takes an array of objects containing wrapped types (returned from `wrapModelType`). + @param {Function} typesUpdated Callback to call when a type has changed. + Takes an array of objects containing wrapped types. + @return {Function} Method to call to remove all observers + */ + watchModelTypes: function (typesAdded, typesUpdated) { + var _this = this; - Environment.prototype.getTemplate = function getTemplate(Template, owner) { - return this._templateCache.get({ Template: Template, owner: owner }); - }; + var modelTypes = this.getModelTypes(); + var releaseMethods = _emberRuntime.A(); + var typesToSend = undefined; - // a Compiler can wrap the template so it needs its own cache + typesToSend = modelTypes.map(function (type) { + var klass = type.klass; + var wrapped = _this.wrapModelType(klass, type.name); + releaseMethods.push(_this.observeModelType(type.name, typesUpdated)); + return wrapped; + }); - Environment.prototype.getCompiledBlock = function getCompiledBlock(Compiler, template) { - var compilerCache = this._compilerCache.get(Compiler); - return compilerCache.get(template); - }; + typesAdded(typesToSend); - Environment.prototype.hasPartial = function hasPartial(name, symbolTable) { - var _symbolTable$getMeta = symbolTable.getMeta(); + var release = function () { + releaseMethods.forEach(function (fn) { + return fn(); + }); + _this.releaseMethods.removeObject(release); + }; + this.releaseMethods.pushObject(release); + return release; + }, - var owner = _symbolTable$getMeta.owner; + _nameToClass: function (type) { + if (typeof type === 'string') { + var owner = _emberUtils.getOwner(this); + type = owner[_container.FACTORY_FOR]('model:' + type).class; + } + return type; + }, - return _emberViews.hasPartial(name, owner); - }; + /** + Fetch the records of a given type and observe them for changes. + @public + @method watchRecords + @param {String} modelName The model name. + @param {Function} recordsAdded Callback to call to add records. + Takes an array of objects containing wrapped records. + The object should have the following properties: + columnValues: {Object} The key and value of a table cell. + object: {Object} The actual record object. + @param {Function} recordsUpdated Callback to call when a record has changed. + Takes an array of objects containing wrapped records. + @param {Function} recordsRemoved Callback to call when a record has removed. + Takes the following parameters: + index: The array index where the records were removed. + count: The number of records removed. + @return {Function} Method to call to remove all observers. + */ + watchRecords: function (modelName, recordsAdded, recordsUpdated, recordsRemoved) { + var _this2 = this; - Environment.prototype.lookupPartial = function lookupPartial(name, symbolTable) { - var _symbolTable$getMeta2 = symbolTable.getMeta(); + var releaseMethods = _emberRuntime.A(); + var klass = this._nameToClass(modelName); + var records = this.getRecords(klass, modelName); + var release = undefined; - var owner = _symbolTable$getMeta2.owner; + function recordUpdated(updatedRecord) { + recordsUpdated([updatedRecord]); + } - var partial = { - template: _emberViews.lookupPartial(name, owner) - }; + var recordsToSend = records.map(function (record) { + releaseMethods.push(_this2.observeRecord(record, recordUpdated)); + return _this2.wrapRecord(record); + }); - if (partial.template) { - return partial; - } else { - throw new Error(name + ' is not a partial'); - } - }; + var contentDidChange = function (array, idx, removedCount, addedCount) { + for (var i = idx; i < idx + addedCount; i++) { + var record = _emberRuntime.objectAt(array, i); + var wrapped = _this2.wrapRecord(record); + releaseMethods.push(_this2.observeRecord(record, recordUpdated)); + recordsAdded([wrapped]); + } - Environment.prototype.hasHelper = function hasHelper(nameParts, symbolTable) { + if (removedCount) { + recordsRemoved(idx, removedCount); + } + }; - // helpers are not allowed to include a dot in their invocation - if (nameParts.length > 1) { - return false; - } + var observer = { didChange: contentDidChange, willChange: function () { + return this; + } }; + _emberRuntime.addArrayObserver(records, this, observer); - var name = nameParts[0]; + release = function () { + releaseMethods.forEach(function (fn) { + return fn(); + }); + _emberRuntime.removeArrayObserver(records, _this2, observer); + _this2.releaseMethods.removeObject(release); + }; - if (this.builtInHelpers[name]) { - return true; - } + recordsAdded(recordsToSend); - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var options = { source: 'template:' + blockMeta.moduleName }; + this.releaseMethods.pushObject(release); + return release; + }, - return owner.hasRegistration('helper:' + name, options) || owner.hasRegistration('helper:' + name); - }; + /** + Clear all observers before destruction + @private + @method willDestroy + */ + willDestroy: function () { + this._super.apply(this, arguments); + this.releaseMethods.forEach(function (fn) { + return fn(); + }); + }, - Environment.prototype.lookupHelper = function lookupHelper(nameParts, symbolTable) { + /** + Detect whether a class is a model. + Test that against the model class + of your persistence library. + @private + @method detect + @param {Class} klass The class to test. + @return boolean Whether the class is a model class or not. + */ + detect: function (klass) { + return false; + }, - var name = nameParts[0]; - var helper = this.builtInHelpers[name]; + /** + Get the columns for a given model type. + @private + @method columnsForType + @param {Class} type The model type. + @return {Array} An array of columns of the following format: + name: {String} The name of the column. + desc: {String} Humanized description (what would show in a table column name). + */ + columnsForType: function (type) { + return _emberRuntime.A(); + }, - if (helper) { - return helper; - } + /** + Adds observers to a model type class. + @private + @method observeModelType + @param {String} modelName The model type name. + @param {Function} typesUpdated Called when a type is modified. + @return {Function} The function to call to remove observers. + */ - var blockMeta = symbolTable.getMeta(); - var owner = blockMeta.owner; - var options = blockMeta.moduleName && { source: 'template:' + blockMeta.moduleName } || {}; + observeModelType: function (modelName, typesUpdated) { + var _this3 = this; - helper = owner.lookup('helper:' + name, options) || owner.lookup('helper:' + name); + var klass = this._nameToClass(modelName); + var records = this.getRecords(klass, modelName); - // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations - if (helper.isHelperInstance) { - return function (vm, args) { - return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helper.compute, args); - }; - } else if (helper.isHelperFactory) { - return function (vm, args) { - return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helper, vm, args); - }; - } else { - throw new Error(nameParts + ' is not a helper'); + function onChange() { + typesUpdated([this.wrapModelType(klass, modelName)]); } - }; - - Environment.prototype.hasModifier = function hasModifier(nameParts) { - // modifiers are not allowed to include a dot in their invocation - if (nameParts.length > 1) { - return false; - } - - return !!this.builtInModifiers[nameParts[0]]; - }; - - Environment.prototype.lookupModifier = function lookupModifier(nameParts) { - - var modifier = this.builtInModifiers[nameParts[0]]; - - if (modifier) { - return modifier; - } else { - throw new Error(nameParts + ' is not a modifier'); - } - }; - - Environment.prototype.toConditionalReference = function toConditionalReference(reference) { - return _emberGlimmerUtilsReferences.ConditionalReference.create(reference); - }; - - Environment.prototype.iterableFor = function iterableFor(ref, args) { - var keyPath = args.named.get('key').value(); - return _emberGlimmerUtilsIterable.default(ref, keyPath); - }; + var observer = { + didChange: function () { + _emberMetal.run.scheduleOnce('actions', this, onChange); + }, + willChange: function () { + return this; + } + }; - Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier() { - if (this.isInteractive) { - var _GlimmerEnvironment$prototype$scheduleInstallModifier; + _emberRuntime.addArrayObserver(records, this, observer); - (_GlimmerEnvironment$prototype$scheduleInstallModifier = _GlimmerEnvironment.prototype.scheduleInstallModifier).call.apply(_GlimmerEnvironment$prototype$scheduleInstallModifier, [this].concat(babelHelpers.slice.call(arguments))); - } - }; + var release = function () { + return _emberRuntime.removeArrayObserver(records, _this3, observer); + }; - Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier() { - if (this.isInteractive) { - var _GlimmerEnvironment$prototype$scheduleUpdateModifier; + return release; + }, - (_GlimmerEnvironment$prototype$scheduleUpdateModifier = _GlimmerEnvironment.prototype.scheduleUpdateModifier).call.apply(_GlimmerEnvironment$prototype$scheduleUpdateModifier, [this].concat(babelHelpers.slice.call(arguments))); - } - }; + /** + Wraps a given model type and observes changes to it. + @private + @method wrapModelType + @param {Class} klass A model class. + @param {String} modelName Name of the class. + @return {Object} Contains the wrapped type and the function to remove observers + Format: + type: {Object} The wrapped type. + The wrapped type has the following format: + name: {String} The name of the type. + count: {Integer} The number of records available. + columns: {Columns} An array of columns to describe the record. + object: {Class} The actual Model type class. + release: {Function} The function to remove observers. + */ + wrapModelType: function (klass, name) { + var records = this.getRecords(klass, name); + var typeToSend = undefined; - Environment.prototype.didDestroy = function didDestroy(destroyable) { - destroyable.destroy(); - }; + typeToSend = { + name: name, + count: _emberMetal.get(records, 'length'), + columns: this.columnsForType(klass), + object: klass + }; - Environment.prototype.begin = function begin() { - this.inTransaction = true; + return typeToSend; + }, - _GlimmerEnvironment.prototype.begin.call(this); + /** + Fetches all models defined in the application. + @private + @method getModelTypes + @return {Array} Array of model types. + */ + getModelTypes: function () { + var _this4 = this; - this.destroyedComponents = []; - }; + var containerDebugAdapter = this.get('containerDebugAdapter'); + var types = undefined; - Environment.prototype.commit = function commit() { - // components queued for destruction must be destroyed before firing - // `didCreate` to prevent errors when removing and adding a component - // with the same name (would throw an error when added to view registry) - for (var i = 0; i < this.destroyedComponents.length; i++) { - this.destroyedComponents[i].destroy(); + if (containerDebugAdapter.canCatalogEntriesByType('model')) { + types = containerDebugAdapter.catalogEntriesByType('model'); + } else { + types = this._getObjectsOnNamespaces(); } - _GlimmerEnvironment.prototype.commit.call(this); - - this.inTransaction = false; - }; - - return Environment; - })(_glimmerRuntime.Environment); - - exports.default = Environment; -}); -enifed('ember-glimmer/helper', ['exports', 'ember-utils', 'ember-runtime', 'glimmer-reference'], function (exports, _emberUtils, _emberRuntime, _glimmerReference) { - /** - @module ember - @submodule ember-glimmer - */ + // New adapters return strings instead of classes. + types = _emberRuntime.A(types).map(function (name) { + return { + klass: _this4._nameToClass(name), + name: name + }; + }); + types = _emberRuntime.A(types).filter(function (type) { + return _this4.detect(type.klass); + }); - 'use strict'; + return _emberRuntime.A(types); + }, - exports.helper = helper; - var RECOMPUTE_TAG = _emberUtils.symbol('RECOMPUTE_TAG'); + /** + Loops over all namespaces and all objects + attached to them. + @private + @method _getObjectsOnNamespaces + @return {Array} Array of model type strings. + */ + _getObjectsOnNamespaces: function () { + var _this5 = this; - exports.RECOMPUTE_TAG = RECOMPUTE_TAG; - /** - Ember Helpers are functions that can compute values, and are used in templates. - For example, this code calls a helper named `format-currency`: - - ```handlebars -
    {{format-currency cents currency="$"}}
    - ``` - - Additionally a helper can be called as a nested helper (sometimes called a - subexpression). In this example, the computed value of a helper is passed - to a component named `show-money`: - - ```handlebars - {{show-money amount=(format-currency cents currency="$")}} - ``` - - Helpers defined using a class must provide a `compute` function. For example: - - ```js - export default Ember.Helper.extend({ - compute(params, hash) { - let cents = params[0]; - let currency = hash.currency; - return `${currency}${cents * 0.01}`; - } - }); - ``` - - Each time the input to a helper changes, the `compute` function will be - called again. - - As instances, these helpers also have access to the container an will accept - injected dependencies. - - Additionally, class helpers can call `recompute` to force a new computation. - - @class Ember.Helper - @public - @since 1.13.0 - */ - var Helper = _emberRuntime.FrameworkObject.extend({ - isHelperInstance: true, + var namespaces = _emberRuntime.A(_emberRuntime.Namespace.NAMESPACES); + var types = _emberRuntime.A(); - init: function () { - this._super.apply(this, arguments); - this[RECOMPUTE_TAG] = new _glimmerReference.DirtyableTag(); + namespaces.forEach(function (namespace) { + for (var key in namespace) { + if (!namespace.hasOwnProperty(key)) { + continue; + } + // Even though we will filter again in `getModelTypes`, + // we should not call `lookupFactory` on non-models + // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) + if (!_this5.detect(namespace[key])) { + continue; + } + var _name = _emberRuntime.String.dasherize(key); + if (!(namespace instanceof _emberApplication.Application) && namespace.toString()) { + _name = namespace + '/' + _name; + } + types.push(_name); + } + }); + return types; }, /** - On a class-based helper, it may be useful to force a recomputation of that - helpers value. This is akin to `rerender` on a component. - For example, this component will rerender when the `currentUser` on a - session service changes: - ```js - // app/helpers/current-user-email.js - export default Ember.Helper.extend({ - session: Ember.inject.service(), - onNewUser: Ember.observer('session.currentUser', function() { - this.recompute(); - }), - compute() { - return this.get('session.currentUser.email'); - } - }); - ``` - @method recompute - @public - @since 1.13.0 + Fetches all loaded records for a given type. + @private + @method getRecords + @return {Array} An array of records. + This array will be observed for changes, + so it should update when new records are added/removed. */ - recompute: function () { - this[RECOMPUTE_TAG].dirty(); - } + getRecords: function (type) { + return _emberRuntime.A(); + }, /** - Override this function when writing a class-based helper. - @method compute - @param {Array} params The positional arguments to the helper - @param {Object} hash The named arguments to the helper - @public - @since 1.13.0 + Wraps a record and observers changes to it. + @private + @method wrapRecord + @param {Object} record The record instance. + @return {Object} The wrapped record. Format: + columnValues: {Array} + searchKeywords: {Array} */ - }); - - Helper.reopenClass({ - isHelperFactory: true - }); + wrapRecord: function (record) { + var recordToSend = { object: record }; - /** - In many cases, the ceremony of a full `Ember.Helper` class is not required. - The `helper` method create pure-function helpers without instances. For - example: - - ```js - // app/helpers/format-currency.js - export default Ember.Helper.helper(function(params, hash) { - let cents = params[0]; - let currency = hash.currency; - return `${currency}${cents * 0.01}`; - }); - ``` - - @static - @param {Function} helper The helper function - @method helper - @public - @since 1.13.0 - */ + recordToSend.columnValues = this.getRecordColumnValues(record); + recordToSend.searchKeywords = this.getRecordKeywords(record); + recordToSend.filterValues = this.getRecordFilterValues(record); + recordToSend.color = this.getRecordColor(record); - function helper(helperFn) { - return { - isHelperInstance: true, - compute: helperFn - }; - } + return recordToSend; + }, - exports.default = Helper; -}); -enifed('ember-glimmer/helpers/-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - 'use strict'; + /** + Gets the values for each column. + @private + @method getRecordColumnValues + @return {Object} Keys should match column names defined + by the model type. + */ + getRecordColumnValues: function (record) { + return {}; + }, - function classHelper(_ref) { - var positional = _ref.positional; + /** + Returns keywords to match when searching records. + @private + @method getRecordKeywords + @return {Array} Relevant keywords for search. + */ + getRecordKeywords: function (record) { + return _emberRuntime.A(); + }, - var path = positional.at(0); - var args = positional.length; - var value = path.value(); + /** + Returns the values of filters defined by `getFilters`. + @private + @method getRecordFilterValues + @param {Object} record The record instance. + @return {Object} The filter values. + */ + getRecordFilterValues: function (record) { + return {}; + }, - if (value === true) { - if (args > 1) { - return _emberRuntime.String.dasherize(positional.at(1).value()); - } + /** + Each record can have a color that represents its state. + @private + @method getRecordColor + @param {Object} record The record instance + @return {String} The records color. + Possible options: black, red, blue, green. + */ + getRecordColor: function (record) { return null; - } + }, - if (value === false) { - if (args > 2) { - return _emberRuntime.String.dasherize(positional.at(2).value()); - } - return null; + /** + Observes all relevant properties and re-sends the wrapped record + when a change occurs. + @private + @method observerRecord + @param {Object} record The record instance. + @param {Function} recordUpdated The callback to call when a record is updated. + @return {Function} The function to call to remove all observers. + */ + observeRecord: function (record, recordUpdated) { + return function () {}; } - - return value; - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(classHelper, args); - }; + }); }); -enifed('ember-glimmer/helpers/-html-safe', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/utils/string'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerUtilsString) { - 'use strict'; - - function htmlSafe(_ref) { - var positional = _ref.positional; - - var path = positional.at(0); - return new _emberGlimmerUtilsString.SafeString(path.value()); - } +enifed('ember-extension-support/index', ['exports', 'ember-extension-support/data_adapter', 'ember-extension-support/container_debug_adapter'], function (exports, _emberExtensionSupportData_adapter, _emberExtensionSupportContainer_debug_adapter) { + /** + @module ember + @submodule ember-extension-support + */ - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(htmlSafe, args); - }; -}); -enifed('ember-glimmer/helpers/-input-type', ['exports', 'ember-glimmer/utils/references'], function (exports, _emberGlimmerUtilsReferences) { 'use strict'; - function inputTypeHelper(_ref) { - var positional = _ref.positional; - var named = _ref.named; - - var type = positional.at(0).value(); - if (type === 'checkbox') { - return '-checkbox'; - } - return '-text-field'; - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(inputTypeHelper, args); - }; + exports.DataAdapter = _emberExtensionSupportData_adapter.default; + exports.ContainerDebugAdapter = _emberExtensionSupportContainer_debug_adapter.default; }); -enifed('ember-glimmer/helpers/-normalize-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { +enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'ember-runtime', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference', '@glimmer/runtime'], function (exports, _emberUtils, _emberViews, _emberRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference, _glimmerRuntime) { 'use strict'; - function normalizeClass(_ref) { - var positional = _ref.positional; - var named = _ref.named; - - var classNameParts = positional.at(0).value().split('.'); - var className = classNameParts[classNameParts.length - 1]; - var value = positional.at(1).value(); + var _CoreView$extend; - if (value === true) { - return _emberRuntime.String.dasherize(className); - } else if (!value && value !== 0) { - return ''; - } else { - return String(value); - } - } + var DIRTY_TAG = _emberUtils.symbol('DIRTY_TAG'); + exports.DIRTY_TAG = DIRTY_TAG; + var ARGS = _emberUtils.symbol('ARGS'); + exports.ARGS = ARGS; + var ROOT_REF = _emberUtils.symbol('ROOT_REF'); + exports.ROOT_REF = ROOT_REF; + var IS_DISPATCHING_ATTRS = _emberUtils.symbol('IS_DISPATCHING_ATTRS'); + exports.IS_DISPATCHING_ATTRS = IS_DISPATCHING_ATTRS; + var HAS_BLOCK = _emberUtils.symbol('HAS_BLOCK'); + exports.HAS_BLOCK = HAS_BLOCK; + var BOUNDS = _emberUtils.symbol('BOUNDS'); - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(normalizeClass, args); - }; -}); -enifed('ember-glimmer/helpers/action', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal) { + exports.BOUNDS = BOUNDS; /** @module ember @submodule ember-glimmer */ - 'use strict'; - - exports.createClosureAction = createClosureAction; - var INVOKE = _emberUtils.symbol('INVOKE'); - exports.INVOKE = INVOKE; - var ACTION = _emberUtils.symbol('ACTION'); - exports.ACTION = ACTION; /** - The `{{action}}` helper provides a way to pass triggers for behavior (usually - just a function) between components, and into components from controllers. - - ### Passing functions with the action helper + An `Ember.Component` is a view that is completely + isolated. Properties accessed in its templates go + to the view object and actions are targeted at + the view object. There is no access to the + surrounding context or outer controller; all + contextual information must be passed in. - There are three contexts an action helper can be used in. The first two - contexts to discuss are attribute context, and Handlebars value context. + The easiest way to create an `Ember.Component` is via + a template. If you name a template + `app/components/my-foo.hbs`, you will be able to use + `{{my-foo}}` in other templates, which will make + an instance of the isolated component. - ```handlebars - {{! An example of attribute context }} -
    - {{! Examples of Handlebars value context }} - {{input on-input=(action "save")}} - {{yield (action "refreshData") andAnotherParam}} + ```app/components/my-foo.hbs + {{person-profile person=currentUser}} ``` - In these contexts, - the helper is called a "closure action" helper. Its behavior is simple: - If passed a function name, read that function off the `actions` property - of the current context. Once that function is read (or if a function was - passed), create a closure over that function and any arguments. - The resulting value of an action helper used this way is simply a function. + ```app/components/person-profile.hbs +

    {{person.title}}

    + +

    {{person.signature}}

    + ``` - For example, in the attribute context: + You can use `yield` inside a template to + include the **contents** of any block attached to + the component. The block will be executed in the + context of the surrounding context or outer controller: ```handlebars - {{! An example of attribute context }} -
    + {{#person-profile person=currentUser}} +

    Admin mode

    + {{! Executed in the controller's context. }} + {{/person-profile}} ``` - The resulting template render logic would be: - - ```js - var div = document.createElement('div'); - var actionFunction = (function(context){ - return function() { - return context.actions.save.apply(context, arguments); - }; - })(context); - div.onclick = actionFunction; + ```app/components/person-profile.hbs +

    {{person.title}}

    + {{! Executed in the component's context. }} + {{yield}} {{! block contents }} ``` - Thus when the div is clicked, the action on that context is called. - Because the `actionFunction` is just a function, closure actions can be - passed between components and still execute in the correct context. + If you want to customize the component, in order to + handle events or actions, you implement a subclass + of `Ember.Component` named after the name of the + component. - Here is an example action handler on a component: + For example, you could implement the action + `hello` for the `person-profile` component: + + ```app/components/person-profile.js + import Ember from 'ember'; - ```js export default Ember.Component.extend({ actions: { - save() { - this.get('model').save(); + hello(name) { + console.log("Hello", name); } } }); ``` - Actions are always looked up on the `actions` property of the current context. - This avoids collisions in the naming of common actions, such as `destroy`. - Two options can be passed to the `action` helper when it is used in this way. + And then use it in the component's template: - * `target=someProperty` will look to `someProperty` instead of the current - context for the `actions` hash. This can be useful when targetting a - service for actions. - * `value="target.value"` will read the path `target.value` off the first - argument to the action when it is called and rewrite the first argument - to be that value. This is useful when attaching actions to event listeners. + ```app/templates/components/person-profile.hbs +

    {{person.title}}

    + {{yield}} + + ``` - ### Invoking an action + Components must have a `-` in their name to avoid + conflicts with built-in controls that wrap HTML + elements. This is consistent with the same + requirement in web components. - Closure actions curry both their scope and any arguments. When invoked, any - additional arguments are added to the already curried list. - Actions should be invoked using the [sendAction](/api/classes/Ember.Component.html#method_sendAction) - method. The first argument to `sendAction` is the action to be called, and - additional arguments are passed to the action function. This has interesting - properties combined with currying of arguments. For example: - ```js + ## HTML Tag + + The default HTML tag name used for a component's DOM representation is `div`. + This can be customized by setting the `tagName` property. + The following component class: + + ```app/components/emphasized-paragraph.js + import Ember from 'ember'; + export default Ember.Component.extend({ - actions: { - // Usage {{input on-input=(action (action 'setName' model) value="target.value")}} - setName(model, name) { - model.set('name', name); - } - } + tagName: 'em' }); ``` - The first argument (`model`) was curried over, and the run-time argument (`event`) - becomes a second argument. Action calls can be nested this way because each simply - returns a function. Any function can be passed to the `{{action}}` helper, including - other actions. + Would result in instances with the following HTML: - Actions invoked with `sendAction` have the same currying behavior as demonstrated - with `on-input` above. For example: + ```html + + ``` + + + ## HTML `class` Attribute + + The HTML `class` attribute of a component's tag can be set by providing a + `classNames` property that is set to an array of strings: + + ```app/components/my-widget.js + import Ember from 'ember'; - ```js export default Ember.Component.extend({ - actions: { - setName(model, name) { - model.set('name', name); - } - } + classNames: ['my-class', 'my-other-class'] }); ``` - ```handlebars - {{my-input submit=(action 'setName' model)}} + Will result in component instances with an HTML representation of: + + ```html +
    ``` - ```js - // app/components/my-component.js + `class` attribute values can also be set by providing a `classNameBindings` + property set to an array of properties names for the component. The return value + of these properties will be added as part of the value for the components's `class` + attribute. These properties can be computed properties: + + ```app/components/my-widget.js + import Ember from 'ember'; + export default Ember.Component.extend({ - click() { - // Note that model is not passed, it was curried in the template - this.sendAction('submit', 'bob'); - } + classNameBindings: ['propertyA', 'propertyB'], + propertyA: 'from-a', + propertyB: Ember.computed(function() { + if (someLogic) { return 'from-b'; } + }) }); ``` - ### Attaching actions to DOM elements + Will result in component instances with an HTML representation of: - The third context of the `{{action}}` helper can be called "element space". - For example: + ```html +
    + ``` - ```handlebars - {{! An example of element space }} -
    + If the value of a class name binding returns a boolean the property name + itself will be used as the class name if the property is true. + The class name will not be added if the value is `false` or `undefined`. + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['hovered'], + hovered: true + }); ``` - Used this way, the `{{action}}` helper provides a useful shortcut for - registering an HTML element in a template for a single DOM event and - forwarding that interaction to the template's context (controller or component). - If the context of a template is a controller, actions used this way will - bubble to routes when the controller does not implement the specified action. - Once an action hits a route, it will bubble through the route hierarchy. + Will result in component instances with an HTML representation of: - ### Event Propagation + ```html +
    + ``` - `{{action}}` helpers called in element space can control event bubbling. Note - that the closure style actions cannot. + When using boolean class name bindings you can supply a string value other + than the property name for use as the `class` HTML attribute by appending the + preferred value after a ":" character when defining the binding: - Events triggered through the action helper will automatically have - `.preventDefault()` called on them. You do not need to do so in your event - handlers. If you need to allow event propagation (to handle file inputs for - example) you can supply the `preventDefault=false` option to the `{{action}}` helper: + ```app/components/my-widget.js + import Ember from 'ember'; - ```handlebars -
    - - -
    + export default Ember.Component.extend({ + classNameBindings: ['awesome:so-very-cool'], + awesome: true + }); ``` - To disable bubbling, pass `bubbles=false` to the helper: + Will result in component instances with an HTML representation of: - ```handlebars - + ```html +
    ``` - To disable bubbling with closure style actions you must create your own - wrapper helper that makes use of `event.stopPropagation()`: + Boolean value class name bindings whose property names are in a + camelCase-style format will be converted to a dasherized format: - ```handlebars -
    Hello
    + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['isUrgent'], + isUrgent: true + }); ``` - ```js - // app/helpers/disable-bubbling.js + Will result in component instances with an HTML representation of: + + ```html +
    + ``` + + Class name bindings can also refer to object values that are found by + traversing a path relative to the component itself: + + ```app/components/my-widget.js import Ember from 'ember'; - export function disableBubbling([action]) { - return function(event) { - event.stopPropagation(); - return action(event); - }; - } - export default Ember.Helper.helper(disableBubbling); + + export default Ember.Component.extend({ + classNameBindings: ['messages.empty'], + messages: Ember.Object.create({ + empty: true + }) + }); ``` - If you need the default handler to trigger you should either register your - own event handler, or use event methods on your view class. See - ["Responding to Browser Events"](/api/classes/Ember.View.html#toc_responding-to-browser-events) - in the documentation for Ember.View for more information. + Will result in component instances with an HTML representation of: - ### Specifying DOM event type + ```html +
    + ``` - `{{action}}` helpers called in element space can specify an event type. - By default the `{{action}}` helper registers for DOM `click` events. You can - supply an `on` option to the helper to specify a different DOM event name: + If you want to add a class name for a property which evaluates to true and + and a different class name if it evaluates to false, you can pass a binding + like this: - ```handlebars -
    - click me -
    + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + classNameBindings: ['isEnabled:enabled:disabled'], + isEnabled: true + }); ``` - See ["Event Names"](/api/classes/Ember.View.html#toc_event-names) for a list of - acceptable DOM event names. + Will result in component instances with an HTML representation of: - ### Specifying whitelisted modifier keys + ```html +
    + ``` - `{{action}}` helpers called in element space can specify modifier keys. - By default the `{{action}}` helper will ignore click events with pressed modifier - keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. + When isEnabled is `false`, the resulting HTML representation looks like + this: - ```handlebars -
    - click me -
    + ```html +
    ``` - This way the action will fire when clicking with the alt key pressed down. - Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. + This syntax offers the convenience to add a class if a property is `false`: - ```handlebars -
    - click me with any key pressed -
    + ```app/components/my-widget.js + import Ember from 'ember'; + + // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false + export default Ember.Component.extend({ + classNameBindings: ['isEnabled::disabled'], + isEnabled: true + }); ``` - ### Specifying a Target + Will result in component instances with an HTML representation of: - A `target` option can be provided to the helper to change - which object will receive the method call. This option must be a path - to an object, accessible in the current context: + ```html +
    + ``` - ```handlebars - {{! app/templates/application.hbs }} -
    - click me -
    + When the `isEnabled` property on the component is set to `false`, it will result + in component instances with an HTML representation of: + + ```html +
    ``` - ```javascript - // app/controllers/application.js - export default Ember.Controller.extend({ - someService: Ember.inject.service() + Updates to the value of a class name binding will result in automatic + update of the HTML `class` attribute in the component's rendered HTML + representation. If the value becomes `false` or `undefined` the class name + will be removed. + Both `classNames` and `classNameBindings` are concatenated properties. See + [Ember.Object](/api/classes/Ember.Object.html) documentation for more + information about concatenated properties. + + + ## HTML Attributes + + The HTML attribute section of a component's tag can be set by providing an + `attributeBindings` property set to an array of property names on the component. + The return value of these properties will be used as the value of the component's + HTML associated attribute: + + ```app/components/my-anchor.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'a', + attributeBindings: ['href'], + href: 'http://google.com' }); ``` - @method action - @for Ember.Templates.helpers - @public - */ - - var ClosureActionReference = (function (_CachedReference) { - babelHelpers.inherits(ClosureActionReference, _CachedReference); - - ClosureActionReference.create = function create(args) { - // TODO: Const reference optimization. - return new ClosureActionReference(args); - }; - - function ClosureActionReference(args) { - _CachedReference.call(this); - - this.args = args; - this.tag = args.tag; - } - - ClosureActionReference.prototype.compute = function compute() { - var _args = this.args; - var named = _args.named; - var positional = _args.positional; - - var positionalValues = positional.value(); - - var target = positionalValues[0]; - var rawActionRef = positional.at(1); - var rawAction = positionalValues[1]; - - // The first two argument slots are reserved. - // pos[0] is the context (or `this`) - // pos[1] is the action name or function - // Anything else is an action argument. - var actionArgs = positionalValues.slice(2); - - // on-change={{action setName}} - // element-space actions look to "controller" then target. Here we only - // look to "target". - var actionType = typeof rawAction; - var action = rawAction; - - if (rawActionRef[INVOKE]) { - target = rawActionRef; - action = rawActionRef[INVOKE]; - } else if (_emberMetal.isNone(rawAction)) { - throw new _emberMetal.Error('Action passed is null or undefined in (action) from ' + target + '.'); - } else if (actionType === 'string') { - // on-change={{action 'setName'}} - var actionName = rawAction; - - action = null; - - if (named.has('target')) { - // on-change={{action 'setName' target=alternativeComponent}} - target = named.get('target').value(); - } - - if (target['actions']) { - action = target.actions[actionName]; - } - - if (!action) { - throw new _emberMetal.Error('An action named \'' + actionName + '\' was not found in ' + target); - } - } else if (action && typeof action[INVOKE] === 'function') { - target = action; - action = action[INVOKE]; - } else if (actionType !== 'function') { - // TODO: Is there a better way of doing this? - var rawActionLabel = rawActionRef._propertyKey || rawAction; - throw new _emberMetal.Error('An action could not be made for `' + rawActionLabel + '` in ' + target + '. Please confirm that you are using either a quoted action name (i.e. `(action \'' + rawActionLabel + '\')`) or a function available in ' + target + '.'); - } - - var valuePath = named.get('value').value(); - - return createClosureAction(target, action, valuePath, actionArgs); - }; - - return ClosureActionReference; - })(_emberGlimmerUtilsReferences.CachedReference); - - exports.ClosureActionReference = ClosureActionReference; - - exports.default = function (vm, args) { - return ClosureActionReference.create(args); - }; - - function createClosureAction(target, action, valuePath, actionArgs) { - var closureAction = undefined; - var actionArgLength = actionArgs.length; - - if (actionArgLength > 0) { - closureAction = function () { - for (var _len = arguments.length, passedArguments = Array(_len), _key = 0; _key < _len; _key++) { - passedArguments[_key] = arguments[_key]; - } - - var args = new Array(actionArgLength + passedArguments.length); - - for (var i = 0; i < actionArgLength; i++) { - args[i] = actionArgs[i]; - } - - for (var i = 0; i < passedArguments.length; i++) { - args[i + actionArgLength] = passedArguments[i]; - } - - if (valuePath && args.length > 0) { - args[0] = _emberMetal.get(args[0], valuePath); - } - - var payload = { target: target, args: args, label: 'glimmer-closure-action' }; - return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - return _emberMetal.run.join.apply(_emberMetal.run, [target, action].concat(args)); - }); - }; - } else { - closureAction = function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - if (valuePath && args.length > 0) { - args[0] = _emberMetal.get(args[0], valuePath); - } - - var payload = { target: target, args: args, label: 'glimmer-closure-action' }; - return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - return _emberMetal.run.join.apply(_emberMetal.run, [target, action].concat(args)); - }); - }; - } - - closureAction[ACTION] = true; - return closureAction; - } -}); -enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/curly-component', 'glimmer-runtime', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxCurlyComponent, _glimmerRuntime, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - /** - The `{{component}}` helper lets you add instances of `Ember.Component` to a - template. See [Ember.Component](/api/classes/Ember.Component.html) for - additional information on how a `Component` functions. - `{{component}}`'s primary use is for cases where you want to dynamically - change which type of component is rendered as the state of your application - changes. This helper has three modes: inline, block, and nested. + Will result in component instances with an HTML representation of: - ### Inline Form + ```html + + ``` - Given the following template: + One property can be mapped on to another by placing a ":" between + the source property and the destination property: - ```app/application.hbs - {{component infographicComponentName}} + ```app/components/my-anchor.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'a', + attributeBindings: ['url:href'], + url: 'http://google.com' + }); ``` - And the following application code: + Will result in component instances with an HTML representation of: - ```app/controllers/application.js - export default Ember.Controller.extend({ - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) + ```html + + ``` + + Namespaced attributes (e.g. `xlink:href`) are supported, but have to be + mapped, since `:` is not a valid character for properties in Javascript: + + ```app/components/my-use.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'use', + attributeBindings: ['xlinkHref:xlink:href'], + xlinkHref: '#triangle' }); ``` - The `live-updating-chart` component will be appended when `isMarketOpen` is - `true`, and the `market-close-summary` component will be appended when - `isMarketOpen` is `false`. If the value changes while the app is running, - the component will be automatically swapped out accordingly. - Note: You should not use this helper when you are consistently rendering the same - component. In that case, use standard component syntax, for example: + Will result in component instances with an HTML representation of: - ```app/templates/application.hbs - {{live-updating-chart}} + ```html + ``` - ### Block Form + If the return value of an `attributeBindings` monitored property is a boolean + the attribute will be present or absent depending on the value: - Using the block form of this helper is similar to using the block form - of a component. Given the following application template: + ```app/components/my-text-input.js + import Ember from 'ember'; - ```app/templates/application.hbs - {{#component infographicComponentName}} - Last update: {{lastUpdateTimestamp}} - {{/component}} + export default Ember.Component.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: false + }); ``` - The following controller code: + Will result in a component instance with an HTML representation of: - ```app/controllers/application.js - export default Ember.Controller.extend({ - lastUpdateTimestamp: computed(function() { - return new Date(); - }), + ```html + + ``` - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } + `attributeBindings` can refer to computed properties: + + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'input', + attributeBindings: ['disabled'], + disabled: Ember.computed(function() { + if (someLogic) { + return true; + } else { + return false; } }) }); ``` - And the following component template: + To prevent setting an attribute altogether, use `null` or `undefined` as the + return value of the `attributeBindings` monitored property: - ```app/templates/components/live-updating-chart.hbs - {{! chart }} - {{yield}} + ```app/components/my-text-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + tagName: 'form', + attributeBindings: ['novalidate'], + novalidate: null + }); ``` - The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. + Updates to the property of an attribute binding will result in automatic + update of the HTML attribute in the component's rendered HTML representation. + `attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html) + documentation for more information about concatenated properties. - ### Nested Usage - The `component` helper can be used to package a component path with initial attrs. - The included attrs can then be merged during the final invocation. - For example, given a `person-form` component with the following template: + ## Layouts - ```app/templates/components/person-form.hbs - {{yield (hash - nameInput=(component "my-input-component" value=model.name placeholder="First Name") - )}} - ``` + See [Ember.Templates.helpers.yield](/api/classes/Ember.Templates.helpers.html#method_yield) + for more information. - When yielding the component via the `hash` helper, the component is invocked directly. - See the following snippet: - ``` - {{#person-form as |form|}} - {{form.nameInput placeholder="Username"}} - {{/person-form}} - ``` + ## Responding to Browser Events - Which outputs an input whose value is already bound to `model.name` and `placeholder` - is "Username". + Components can respond to user-initiated events in one of three ways: method + implementation, through an event manager, and through `{{action}}` helper use + in their template or layout. - When yielding the component without the hash helper use the `component` helper. - For example, below is a `full-name` component template: - ```handlebars - {{yield (component "my-input-component" value=model.name placeholder="Name")}} - ``` + ### Method Implementation - ``` - {{#full-name as |field|}} - {{component field placeholder="Full name"}} - {{/full-name}} + Components can respond to user-initiated events by implementing a method that + matches the event name. A `jQuery.Event` object will be passed as the + argument to this method. + + ```app/components/my-widget.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + click(event) { + // will be called when an instance's + // rendered element is clicked + } + }); ``` - @method component - @since 1.11.0 - @for Ember.Templates.helpers + + ### `{{action}}` Helper + + See [Ember.Templates.helpers.action](/api/classes/Ember.Templates.helpers.html#method_action). + + + ### Event Names + + All of the event handling approaches described above respond to the same set + of events. The names of the built-in events are listed below. (The hash of + built-in events exists in `Ember.EventDispatcher`.) Additional, custom events + can be registered by using `Ember.Application.customEvents`. + + Touch events: + + * `touchStart` + * `touchMove` + * `touchEnd` + * `touchCancel` + + Keyboard events: + + * `keyDown` + * `keyUp` + * `keyPress` + + Mouse events: + + * `mouseDown` + * `mouseUp` + * `contextMenu` + * `click` + * `doubleClick` + * `mouseMove` + * `focusIn` + * `focusOut` + * `mouseEnter` + * `mouseLeave` + + Form events: + + * `submit` + * `change` + * `focusIn` + * `focusOut` + * `input` + + HTML5 drag and drop events: + + * `dragStart` + * `drag` + * `dragEnter` + * `dragLeave` + * `dragOver` + * `dragEnd` + * `drop` + + @class Component + @namespace Ember + @extends Ember.CoreView + @uses Ember.TargetActionSupport + @uses Ember.ClassNamesSupport + @uses Ember.ActionSupport + @uses Ember.ViewMixin + @uses Ember.ViewStateSupport @public */ + var Component = _emberViews.CoreView.extend(_emberViews.ChildViewsSupport, _emberViews.ViewStateSupport, _emberViews.ClassNamesSupport, _emberRuntime.TargetActionSupport, _emberViews.ActionSupport, _emberViews.ViewMixin, (_CoreView$extend = { + isComponent: true, - var ClosureComponentReference = (function (_CachedReference) { - babelHelpers.inherits(ClosureComponentReference, _CachedReference); - - ClosureComponentReference.create = function create(args, symbolTable, env) { - return new ClosureComponentReference(args, symbolTable, env); - }; - - function ClosureComponentReference(args, symbolTable, env) { - _CachedReference.call(this); - this.defRef = args.positional.at(0); - this.env = env; - this.tag = args.positional.at(0).tag; - this.symbolTable = symbolTable; - this.args = args; - this.lastDefinition = undefined; - this.lastName = undefined; - } - - ClosureComponentReference.prototype.compute = function compute() { - // TODO: Figure out how to extract this because it's nearly identical to - // DynamicComponentReference::compute(). The only differences besides - // currying are in the assertion messages. - var args = this.args; - var defRef = this.defRef; - var env = this.env; - var symbolTable = this.symbolTable; - var lastDefinition = this.lastDefinition; - var lastName = this.lastName; - - var nameOrDef = defRef.value(); - var definition = null; - - if (nameOrDef && nameOrDef === lastName) { - return lastDefinition; - } + init: function () { + this._super.apply(this, arguments); + this[IS_DISPATCHING_ATTRS] = false; + this[DIRTY_TAG] = new _glimmerReference.DirtyableTag(); + this[ROOT_REF] = new _emberGlimmerUtilsReferences.RootReference(this); + this[BOUNDS] = null; - this.lastName = nameOrDef; + // If a `defaultLayout` was specified move it to the `layout` prop. + // `layout` is no longer a CP, so this just ensures that the `defaultLayout` + // logic is supported with a deprecation + if (this.defaultLayout && !this.layout) { - if (typeof nameOrDef === 'string') { - definition = env.getComponentDefinition([nameOrDef], symbolTable); - } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { - definition = nameOrDef; - } else { - return null; + this.layout = this.defaultLayout; } - var newDef = createCurriedDefinition(definition, args); + // If in a tagless component, assert that no event handlers are defined + // indicate that the assertion should be triggered + }, - this.lastDefinition = newDef; + rerender: function () { + this[DIRTY_TAG].dirty(); + this._super(); + }, - return newDef; - }; + __defineNonEnumerable: function (property) { + this[property.name] = property.descriptor.value; + } - return ClosureComponentReference; - })(_emberGlimmerUtilsReferences.CachedReference); + }, _CoreView$extend[_emberMetal.PROPERTY_DID_CHANGE] = function (key) { + if (this[IS_DISPATCHING_ATTRS]) { + return; + } - exports.ClosureComponentReference = ClosureComponentReference; + var args = undefined, + reference = undefined; - function createCurriedDefinition(definition, args) { - var curriedArgs = curryArgs(definition, args); + if ((args = this[ARGS]) && (reference = args[key])) { + if (reference[_emberGlimmerUtilsReferences.UPDATE]) { + reference[_emberGlimmerUtilsReferences.UPDATE](_emberMetal.get(this, key)); + } + } + }, _CoreView$extend.getAttr = function (key) { + // TODO Intimate API should be deprecated + return this.get(key); + }, _CoreView$extend.readDOMAttr = function (name) { + var element = _emberViews.getViewElement(this); + return _glimmerRuntime.readDOMAttr(element, name); + }, _CoreView$extend)); - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(definition.name, definition.ComponentClass, definition.template, curriedArgs); - } - - function curryArgs(definition, newArgs) { - var args = definition.args; - var ComponentClass = definition.ComponentClass; - var positionalParams = ComponentClass.positionalParams; - - // The args being passed in are from the (component ...) invocation, - // so the first positional argument is actually the name or component - // definition. It needs to be dropped in order for any actual positional - // args to coincide with the ComponentClass's positionParams. + /** + The WAI-ARIA role of the control represented by this view. For example, a + button may have a role of type 'button', or a pane may have a role of + type 'alertdialog'. This property is used by assistive software to help + visually challenged users navigate rich web applications. + The full list of valid WAI-ARIA roles is available at: + [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization) + @property ariaRole + @type String + @default null + @public + */ - // For "normal" curly components this slicing is done at the syntax layer, - // but we don't have that luxury here. + /** + Enables components to take a list of parameters as arguments. + For example, a component that takes two parameters with the names + `name` and `age`: + ```javascript + let MyComponent = Ember.Component.extend; + MyComponent.reopenClass({ + positionalParams: ['name', 'age'] + }); + ``` + It can then be invoked like this: + ```hbs + {{my-component "John" 38}} + ``` + The parameters can be referred to just like named parameters: + ```hbs + Name: {{name}}, Age: {{age}}. + ``` + Using a string instead of an array allows for an arbitrary number of + parameters: + ```javascript + let MyComponent = Ember.Component.extend; + MyComponent.reopenClass({ + positionalParams: 'names' + }); + ``` + It can then be invoked like this: + ```hbs + {{my-component "John" "Michael" "Scott"}} + ``` + The parameters can then be referred to by enumerating over the list: + ```hbs + {{#each names as |name|}}{{name}}{{/each}} + ``` + @static + @public + @property positionalParams + @since 1.13.0 + */ - var _newArgs$positional$values = newArgs.positional.values; + /** + Called when the attributes passed into the component have been updated. + Called both during the initial render of a container and during a rerender. + Can be used in place of an observer; code placed here will be executed + every time any attribute updates. + @method didReceiveAttrs + @public + @since 1.13.0 + */ - var slicedPositionalArgs = _newArgs$positional$values.slice(1); + /** + Called when the attributes passed into the component have been updated. + Called both during the initial render of a container and during a rerender. + Can be used in place of an observer; code placed here will be executed + every time any attribute updates. + @event didReceiveAttrs + @public + @since 1.13.0 + */ - if (positionalParams && slicedPositionalArgs.length) { - _emberGlimmerSyntaxCurlyComponent.validatePositionalParameters(newArgs.named, slicedPositionalArgs, positionalParams); - } + /** + Called after a component has been rendered, both on initial render and + in subsequent rerenders. + @method didRender + @public + @since 1.13.0 + */ - var isRest = typeof positionalParams === 'string'; + /** + Called after a component has been rendered, both on initial render and + in subsequent rerenders. + @event didRender + @public + @since 1.13.0 + */ - // For non-rest position params, we need to perform the position -> name mapping - // at each layer to avoid a collision later when the args are used to construct - // the component instance (inside of processArgs(), inside of create()). - var positionalToNamedParams = {}; + /** + Called before a component has been rendered, both on initial render and + in subsequent rerenders. + @method willRender + @public + @since 1.13.0 + */ - if (!isRest && positionalParams && positionalParams.length > 0) { - var limit = Math.min(positionalParams.length, slicedPositionalArgs.length); + /** + Called before a component has been rendered, both on initial render and + in subsequent rerenders. + @event willRender + @public + @since 1.13.0 + */ - for (var i = 0; i < limit; i++) { - var _name = positionalParams[i]; - positionalToNamedParams[_name] = slicedPositionalArgs[i]; - } + /** + Called when the attributes passed into the component have been changed. + Called only during a rerender, not during an initial render. + @method didUpdateAttrs + @public + @since 1.13.0 + */ - slicedPositionalArgs.length = 0; // Throw them away since you're merged in. - } + /** + Called when the attributes passed into the component have been changed. + Called only during a rerender, not during an initial render. + @event didUpdateAttrs + @public + @since 1.13.0 + */ - // args (aka 'oldArgs') may be undefined or simply be empty args, so - // we need to fall back to an empty array or object. - var oldNamed = args && args.named && args.named.map || {}; - var oldPositional = args && args.positional && args.positional.values || []; + /** + Called when the component is about to update and rerender itself. + Called only during a rerender, not during an initial render. + @method willUpdate + @public + @since 1.13.0 + */ - // Merge positional arrays - var mergedPositional = new Array(Math.max(oldPositional.length, slicedPositionalArgs.length)); - mergedPositional.splice.apply(mergedPositional, [0, oldPositional.length].concat(oldPositional)); - mergedPositional.splice.apply(mergedPositional, [0, slicedPositionalArgs.length].concat(slicedPositionalArgs)); + /** + Called when the component is about to update and rerender itself. + Called only during a rerender, not during an initial render. + @event willUpdate + @public + @since 1.13.0 + */ - // Merge named maps - var mergedNamed = _emberUtils.assign({}, oldNamed, positionalToNamedParams, newArgs.named.map); + /** + Called when the component has updated and rerendered itself. + Called only during a rerender, not during an initial render. + @method didUpdate + @public + @since 1.13.0 + */ - var mergedArgs = _glimmerRuntime.EvaluatedArgs.create(_glimmerRuntime.EvaluatedPositionalArgs.create(mergedPositional), _glimmerRuntime.EvaluatedNamedArgs.create(mergedNamed), _glimmerRuntime.Blocks.empty()); + /** + Called when the component has updated and rerendered itself. + Called only during a rerender, not during an initial render. + @event didUpdate + @public + @since 1.13.0 + */ - return mergedArgs; - } + /** + A component may contain a layout. A layout is a regular template but + supersedes the `template` property during rendering. It is the + responsibility of the layout template to retrieve the `template` + property from the component (or alternatively, call `Handlebars.helpers.yield`, + `{{yield}}`) to render it in the correct location. + This is useful for a component that has a shared wrapper, but which delegates + the rendering of the contents of the wrapper to the `template` property + on a subclass. + @property layout + @type Function + @public + */ - exports.default = function (vm, args, symbolTable) { - return ClosureComponentReference.create(args, symbolTable, vm.env); - }; -}); -enifed('ember-glimmer/helpers/concat', ['exports', 'ember-glimmer/utils/references', 'glimmer-runtime'], function (exports, _emberGlimmerUtilsReferences, _glimmerRuntime) { - 'use strict'; + /** + The name of the layout to lookup if no layout is provided. + By default `Ember.Component` will lookup a template with this name in + `Ember.TEMPLATES` (a shared global object). + @property layoutName + @type String + @default null + @private + */ /** - @module ember - @submodule ember-glimmer + Returns a jQuery object for this component's element. If you pass in a selector + string, this method will return a jQuery object, using the current element + as its buffer. + For example, calling `component.$('li')` will return a jQuery object containing + all of the `li` elements inside the DOM element of this component. + @method $ + @param {String} [selector] a jQuery-compatible selector string + @return {jQuery} the jQuery object for the DOM node + @public */ /** - Concatenates the given arguments into a string. - - Example: - - ```handlebars - {{some-component name=(concat firstName " " lastName)}} - - {{! would pass name=" " to the component}} + The HTML `id` of the component's element in the DOM. You can provide this + value yourself but it must be unique (just as in HTML): + ```handlebars + {{my-component elementId="a-really-cool-id"}} ``` - + If not manually set a default value will be provided by the framework. + Once rendered an element's `elementId` is considered immutable and you + should never change it. If you need to compute a dynamic value for the + `elementId`, you should do this when the component or element is being + instantiated: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + var index = this.get('index'); + this.set('elementId', `component-id${index}`); + } + }); + ``` + @property elementId + @type String @public - @method concat - @for Ember.Templates.helpers - @since 1.13.0 */ - function concat(_ref) { - var positional = _ref.positional; - return positional.value().map(_glimmerRuntime.normalizeTextValue).join(''); - } + /** + If `false`, the view will appear hidden in DOM. + @property isVisible + @type Boolean + @default null + @public + */ + Component[_emberUtils.NAME_KEY] = 'Ember.Component'; - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(concat, args); - }; + Component.reopenClass({ + isComponentFactory: true, + positionalParams: [] + }); + + exports.default = Component; }); -enifed('ember-glimmer/helpers/debugger', ['exports', 'ember-metal/debug', 'glimmer-runtime'], function (exports, _emberMetalDebug, _glimmerRuntime) { - /*jshint debug:true*/ + +/** + Normally, Ember's component model is "write-only". The component takes a + bunch of attributes that it got passed in, and uses them to render its + template. + One nice thing about this model is that if you try to set a value to the + same thing as last time, Ember (through HTMLBars) will avoid doing any + work on the DOM. + This is not just a performance optimization. If an attribute has not + changed, it is important not to clobber the element's "hidden state". + For example, if you set an input's `value` to the same value as before, + it will clobber selection state and cursor position. In other words, + setting an attribute is not **always** idempotent. + This method provides a way to read an element's attribute and also + update the last value Ember knows about at the same time. This makes + setting an attribute idempotent. + In particular, what this means is that if you get an `` element's + `value` attribute and then re-render the template with the same value, + it will avoid clobbering the cursor and selection position. + Since most attribute sets are idempotent in the browser, you typically + can get away with reading attributes using jQuery, but the most reliable + way to do so is through this method. + @method readDOMAttr + @param {String} name the name of the attribute + @return String + @public + */ +enifed('ember-glimmer/components/checkbox', ['exports', 'ember-metal', 'ember-glimmer/component', 'ember-glimmer/templates/empty'], function (exports, _emberMetal, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty) { + 'use strict'; /** @module ember - @submodule ember-htmlbars + @submodule ember-views */ - 'use strict'; - - exports.default = debuggerHelper; - exports.setDebuggerCallback = setDebuggerCallback; - exports.resetDebuggerCallback = resetDebuggerCallback; - /** - Execute the `debugger` statement in the current template's context. - - ```handlebars - {{debugger}} - ``` - - When using the debugger helper you will have access to a `get` function. This - function retrieves values available in the context of the template. - For example, if you're wondering why a value `{{foo}}` isn't rendering as - expected within a template, you could place a `{{debugger}}` statement and, - when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: - - ``` - > get('foo') - ``` - - `get` is also aware of block variables. So in this situation + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `checkbox`. - ```handlebars - {{#each items as |item|}} - {{debugger}} - {{/each}} - ``` + See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. - You'll be able to get values from the current item: + ## Direct manipulation of `checked` - ``` - > get('item.name') - ``` + The `checked` attribute of an `Ember.Checkbox` object should always be set + through the Ember object or by interacting with its rendered element + representation via the mouse, keyboard, or touch. Updating the value of the + checkbox via jQuery will result in the checked value of the object and its + element losing synchronization. - You can also access the context of the view to make sure it is the object that - you expect: + ## Layout and LayoutName properties - ``` - > context - ``` + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. - @method debugger - @for Ember.Templates.helpers + @class Checkbox + @namespace Ember + @extends Ember.Component @public */ - function defaultCallback(context, get) { - - debugger; + exports.default = _emberGlimmerComponent.default.extend({ + layout: _emberGlimmerTemplatesEmpty.default, + classNames: ['ember-checkbox'], - /* jshint debug: true */ - } + tagName: 'input', - var callback = defaultCallback; + attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name', 'autofocus', 'required', 'form'], - function debuggerHelper(vm, args, symbolTable) { - var context = vm.getSelf().value(); + type: 'checkbox', + checked: false, + disabled: false, + indeterminate: false, - // Note: this is totally an overkill since we are only compiling - // expressions, but this is the only kind of SymbolLookup we can - // construct. The symbol table itself should really be sufficient - // here – we should refactor the Glimmer code to make that possible. - var symbolLookup = new _glimmerRuntime.CompileIntoList(vm.env, symbolTable); + didInsertElement: function () { + this._super.apply(this, arguments); + _emberMetal.get(this, 'element').indeterminate = !!_emberMetal.get(this, 'indeterminate'); + }, - function get(path) { - // Problem: technically, we are getting a `PublicVM` here, but to - // evaluate an expression it requires the full VM. We happen to know - // that they are the same thing, so this would work for now. However - // this might break in the future. - return _glimmerRuntime.GetSyntax.build(path).compile(symbolLookup).evaluate(vm).value(); + change: function () { + _emberMetal.set(this, 'checked', this.$().prop('checked')); } - - callback(context, get); - - return _glimmerRuntime.UNDEFINED_REFERENCE; - } - - // These are exported for testing - - function setDebuggerCallback(newCallback) { - callback = newCallback; - } - - function resetDebuggerCallback() { - callback = defaultCallback; - } + }); }); -enifed('ember-glimmer/helpers/each-in', ['exports', 'ember-utils'], function (exports, _emberUtils) { +enifed('ember-glimmer/components/link-to', ['exports', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-views', 'ember-glimmer/templates/link-to', 'ember-glimmer/component'], function (exports, _emberConsole, _emberMetal, _emberRuntime, _emberViews, _emberGlimmerTemplatesLinkTo, _emberGlimmerComponent) { /** @module ember @submodule ember-glimmer */ - 'use strict'; - - exports.isEachIn = isEachIn; /** - The `{{#each}}` helper loops over elements in a collection. It is an extension - of the base Handlebars `{{#each}}` helper. - The default behavior of `{{#each}}` is to yield its inner block once for every - item in an array passing the item as the first block parameter. + The `{{link-to}}` component renders a link to the supplied + `routeName` passing an optionally supplied model to the + route as its `model` context of the route. The block + for `{{link-to}}` becomes the innerHTML of the rendered + element: - ```javascript - var developers = [{ name: 'Yehuda' },{ name: 'Tom' }, { name: 'Paul' }]; + ```handlebars + {{#link-to 'photoGallery'}} + Great Hamster Photos + {{/link-to}} ``` + You can also use an inline form of `{{link-to}}` component by + passing the link text as the first argument + to the component: + ```handlebars - {{#each developers key="name" as |person|}} - {{person.name}} - {{! `this` is whatever it was outside the #each }} - {{/each}} + {{link-to 'Great Hamster Photos' 'photoGallery'}} ``` - The same rules apply to arrays of primitives. + Both will result in: - ```javascript - var developerNames = ['Yehuda', 'Tom', 'Paul'] + ```html + + Great Hamster Photos + ``` + ### Supplying a tagName + By default `{{link-to}}` renders an `` element. This can + be overridden for a single use of `{{link-to}}` by supplying + a `tagName` option: + ```handlebars - {{#each developerNames key="@index" as |name|}} - {{name}} - {{/each}} + {{#link-to 'photoGallery' tagName="li"}} + Great Hamster Photos + {{/link-to}} ``` - During iteration, the index of each item in the array is provided as a second block parameter. + ```html +
  • + Great Hamster Photos +
  • + ``` + + To override this option for your entire application, see + "Overriding Application-wide Defaults". + + ### Disabling the `link-to` component + By default `{{link-to}}` is enabled. + any passed value to the `disabled` component property will disable + the `link-to` component. + + static use: the `disabled` option: ```handlebars -
      - {{#each people as |person index|}} -
    • Hello, {{person.name}}! You're number {{index}} in line
    • - {{/each}} -
    + {{#link-to 'photoGallery' disabled=true}} + Great Hamster Photos + {{/link-to}} ``` - ### Specifying Keys + dynamic use: the `disabledWhen` option: - The `key` option is used to tell Ember how to determine if the array being - iterated over with `{{#each}}` has changed between renders. By helping Ember - detect that some elements in the array are the same, DOM elements can be - re-used, significantly improving rendering speed. + ```handlebars + {{#link-to 'photoGallery' disabledWhen=controller.someProperty}} + Great Hamster Photos + {{/link-to}} + ``` - For example, here's the `{{#each}}` helper with its `key` set to `id`: + any passed value to `disabled` will disable it except `undefined`. + to ensure that only `true` disable the `link-to` component you can + override the global behaviour of `Ember.LinkComponent`. - ```handlebars - {{#each model key="id" as |item|}} - {{/each}} + ```javascript + Ember.LinkComponent.reopen({ + disabled: Ember.computed(function(key, value) { + if (value !== undefined) { + this.set('_isDisabled', value === true); + } + return value === true ? get(this, 'disabledClass') : false; + }) + }); ``` - When this `{{#each}}` re-renders, Ember will match up the previously rendered - items (and reorder the generated DOM elements) based on each item's `id` - property. - By default the item's own reference is used. + see "Overriding Application-wide Defaults" for more. - ### {{else}} condition + ### Handling `href` + `{{link-to}}` will use your application's Router to + fill the element's `href` property with a url that + matches the path to the supplied `routeName` for your + router's configured `Location` scheme, which defaults + to Ember.HashLocation. - `{{#each}}` can have a matching `{{else}}`. The contents of this block will render - if the collection is empty. + ### Handling current route + `{{link-to}}` will apply a CSS class name of 'active' + when the application's current route matches + the supplied routeName. For example, if the application's + current route is 'photoGallery.recent' the following + use of `{{link-to}}`: ```handlebars - {{#each developers as |person|}} - {{person.name}} - {{else}} -

    Sorry, nobody is available for this task.

    - {{/each}} + {{#link-to 'photoGallery.recent'}} + Great Hamster Photos + {{/link-to}} ``` - @method each - @for Ember.Templates.helpers - @public - */ - - /** - The `{{each-in}}` helper loops over properties on an object. - - For example, given a `user` object that looks like: + will result in - ```javascript - { - "name": "Shelly Sails", - "age": 42 - } + ```html +
    + Great Hamster Photos + ``` - This template would display all properties on the `user` - object in a list: + The CSS class name used for active classes can be customized + for a single use of `{{link-to}}` by passing an `activeClass` + option: ```handlebars -
      - {{#each-in user as |key value|}} -
    • {{key}}: {{value}}
    • - {{/each-in}} -
    + {{#link-to 'photoGallery.recent' activeClass="current-url"}} + Great Hamster Photos + {{/link-to}} ``` - Outputting their name and age. + ```html + + Great Hamster Photos + + ``` - @method each-in - @for Ember.Templates.helpers - @public - @since 2.1.0 - */ - var EACH_IN_REFERENCE = _emberUtils.symbol('EACH_IN'); - - function isEachIn(ref) { - return ref && ref[EACH_IN_REFERENCE]; - } - - exports.default = function (vm, args) { - var ref = Object.create(args.positional.at(0)); - ref[EACH_IN_REFERENCE] = true; - return ref; - }; -}); -enifed('ember-glimmer/helpers/get', ['exports', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - 'use strict'; - - /** - @module ember - @submodule ember-glimmer - */ - - /** - Dynamically look up a property on an object. The second argument to `{{get}}` - should have a string value, although it can be bound. + To override this option for your entire application, see + "Overriding Application-wide Defaults". - For example, these two usages are equivilent: + ### Keeping a link active for other routes + + If you need a link to be 'active' even when it doesn't match + the current route, you can use the `current-when` argument. ```handlebars - {{person.height}} - {{get person "height"}} + {{#link-to 'photoGallery' current-when='photos'}} + Photo Gallery + {{/link-to}} ``` - If there were several facts about a person, the `{{get}}` helper can dynamically - pick one: + This may be helpful for keeping links active for: - ```handlebars - {{get person factName}} - ``` + * non-nested routes that are logically related + * some secondary menu approaches + * 'top navigation' with 'sub navigation' scenarios - For a more complex example, this template would allow the user to switch - between showing the user's height and weight with a click: + A link will be active if `current-when` is `true` or the current + route is the route this link would transition to. + + To match multiple routes 'space-separate' the routes: ```handlebars - {{get person factName}} - - + {{#link-to 'gallery' current-when='photos drawings paintings'}} + Art Gallery + {{/link-to}} ``` - The `{{get}}` helper can also respect mutable values itself. For example: + ### Supplying a model + An optional model argument can be used for routes whose + paths contain dynamic segments. This argument will become + the model context of the linked route: + + ```javascript + Router.map(function() { + this.route("photoGallery", {path: "hamster-photos/:photo_id"}); + }); + ``` ```handlebars - {{input value=(mut (get person factName)) type="text"}} - - + {{#link-to 'photoGallery' aPhoto}} + {{aPhoto.title}} + {{/link-to}} ``` - Would allow the user to swap what fact is being displayed, and also edit - that fact via a two-way mutable binding. + ```html + + Tomster + + ``` - @public - @method get - @for Ember.Templates.helpers - @since 2.1.0 - */ - - exports.default = function (vm, args) { - return GetHelperReference.create(args.positional.at(0), args.positional.at(1)); - }; - - var GetHelperReference = (function (_CachedReference) { - babelHelpers.inherits(GetHelperReference, _CachedReference); - - GetHelperReference.create = function create(sourceReference, pathReference) { - if (_glimmerReference.isConst(pathReference)) { - var parts = pathReference.value().split('.'); - return _glimmerReference.referenceFromParts(sourceReference, parts); - } else { - return new GetHelperReference(sourceReference, pathReference); - } - }; - - function GetHelperReference(sourceReference, pathReference) { - _CachedReference.call(this); - this.sourceReference = sourceReference; - this.pathReference = pathReference; - - this.lastPath = null; - this.innerReference = null; - - var innerTag = this.innerTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - - this.tag = _glimmerReference.combine([sourceReference.tag, pathReference.tag, innerTag]); - } - - GetHelperReference.prototype.compute = function compute() { - var lastPath = this.lastPath; - var innerReference = this.innerReference; - var innerTag = this.innerTag; - - var path = this.lastPath = this.pathReference.value(); - - if (path !== lastPath) { - if (path) { - var pathType = typeof path; - - if (pathType === 'string') { - innerReference = this.innerReference = _glimmerReference.referenceFromParts(this.sourceReference, path.split('.')); - } else if (pathType === 'number') { - innerReference = this.innerReference = this.sourceReference.get(path); - } - - innerTag.update(innerReference.tag); - } else { - innerReference = this.innerReference = null; - innerTag.update(_glimmerReference.CONSTANT_TAG); - } - } - - return innerReference ? innerReference.value() : null; - }; - - GetHelperReference.prototype[_emberGlimmerUtilsReferences.UPDATE] = function (value) { - _emberMetal.set(this.sourceReference.value(), this.pathReference.value(), value); - }; - - return GetHelperReference; - })(_emberGlimmerUtilsReferences.CachedReference); -}); -enifed("ember-glimmer/helpers/hash", ["exports"], function (exports) { - /** - @module ember - @submodule ember-glimmer - */ - - /** - Use the `{{hash}}` helper to create a hash to pass as an option to your - components. This is specially useful for contextual components where you can - just yield a hash: - - ```handlebars - {{yield (hash - name='Sarah' - title=office - )}} - ``` - - Would result in an object such as: - - ```js - { name: 'Sarah', title: this.get('office') } - ``` - - Where the `title` is bound to updates of the `office` property. - - @method hash - @for Ember.Templates.helpers - @param {Object} options - @return {Object} Hash - @public - */ - - "use strict"; - - exports.default = function (vm, args) { - return args.named; - }; -}); -enifed('ember-glimmer/helpers/if-unless', ['exports', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { - /** - @module ember - @submodule ember-glimmer - */ - - 'use strict'; - - exports.inlineIf = inlineIf; - exports.inlineUnless = inlineUnless; - - /** - Use the `if` block helper to conditionally render a block depending on a - property. If the property is "falsey", for example: `false`, `undefined`, - `null`, `""`, `0`, `NaN` or an empty array, the block will not be rendered. + ### Supplying multiple models + For deep-linking to route paths that contain multiple + dynamic segments, multiple model arguments can be used. + As the router transitions through the route path, each + supplied model argument will become the context for the + route with the dynamic segments: - ```handlebars - {{! will not render if foo is falsey}} - {{#if foo}} - Welcome to the {{foo.bar}} - {{/if}} + ```javascript + Router.map(function() { + this.route("photoGallery", { path: "hamster-photos/:photo_id" }, function() { + this.route("comment", {path: "comments/:comment_id"}); + }); + }); ``` - - You can also specify a template to show if the property is falsey by using - the `else` helper. + This argument will become the model context of the linked route: ```handlebars - {{! is it raining outside?}} - {{#if isRaining}} - Yes, grab an umbrella! - {{else}} - No, it's lovely outside! - {{/if}} + {{#link-to 'photoGallery.comment' aPhoto comment}} + {{comment.body}} + {{/link-to}} ``` - You are also able to combine `else` and `if` helpers to create more complex - conditional logic. - - ```handlebars - {{#if isMorning}} - Good morning - {{else if isAfternoon}} - Good afternoon - {{else}} - Good night - {{/if}} + ```html + + A+++ would snuggle again. + ``` - You can use `if` inline to conditionally render a single property or string. - This helper acts like a ternary operator. If the first property is truthy, - the second argument will be displayed, if not, the third argument will be - displayed + ### Supplying an explicit dynamic segment value + If you don't have a model object available to pass to `{{link-to}}`, + an optional string or integer argument can be passed for routes whose + paths contain dynamic segments. This argument will become the value + of the dynamic segment: - ```handlebars - {{if useLongGreeting "Hello" "Hi"}} Dave + ```javascript + Router.map(function() { + this.route("photoGallery", { path: "hamster-photos/:photo_id" }); + }); ``` - Finally, you can use the `if` helper inside another helper as a subexpression. - ```handlebars - {{some-component height=(if isBig "100" "10")}} + {{#link-to 'photoGallery' aPhotoId}} + {{aPhoto.title}} + {{/link-to}} ``` - @method if - @for Ember.Templates.helpers - @public - */ - - var ConditionalHelperReference = (function (_CachedReference) { - babelHelpers.inherits(ConditionalHelperReference, _CachedReference); - - ConditionalHelperReference.create = function create(_condRef, _truthyRef, _falsyRef) { - var condRef = _emberGlimmerUtilsReferences.ConditionalReference.create(_condRef); - var truthyRef = _truthyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; - var falsyRef = _falsyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; - - if (_glimmerReference.isConst(condRef)) { - return condRef.value() ? truthyRef : falsyRef; - } else { - return new ConditionalHelperReference(condRef, truthyRef, falsyRef); - } - }; - - function ConditionalHelperReference(cond, truthy, falsy) { - _CachedReference.call(this); - - this.branchTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([cond.tag, this.branchTag]); - - this.cond = cond; - this.truthy = truthy; - this.falsy = falsy; - } - - /** - The inline `if` helper conditionally renders a single property or string. - This helper acts like a ternary operator. If the first property is truthy, - the second argument will be displayed, otherwise, the third argument will be - displayed - - ```handlebars - {{if useLongGreeting "Hello" "Hi"}} Alex - ``` - - You can use the `if` helper inside another helper as a subexpression. - - ```handlebars - {{some-component height=(if isBig "100" "10")}} - ``` - - @method if - @for Ember.Templates.helpers - @public - */ - - ConditionalHelperReference.prototype.compute = function compute() { - var cond = this.cond; - var truthy = this.truthy; - var falsy = this.falsy; - - var branch = cond.value() ? truthy : falsy; - - this.branchTag.update(branch.tag); - - return branch.value(); - }; - - return ConditionalHelperReference; - })(_emberGlimmerUtilsReferences.CachedReference); - - function inlineIf(vm, _ref) { - var positional = _ref.positional; - - switch (positional.length) { - case 2: - return ConditionalHelperReference.create(positional.at(0), positional.at(1), null); - case 3: - return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); - default: - } - } - - /** - The inline `unless` helper conditionally renders a single property or string. - This helper acts like a ternary operator. If the first property is falsy, - the second argument will be displayed, otherwise, the third argument will be - displayed + ```html + + Tomster + + ``` + + When transitioning into the linked route, the `model` hook will + be triggered with parameters including this passed identifier. + + ### Allowing Default Action + + By default the `{{link-to}}` component prevents the default browser action + by calling `preventDefault()` as this sort of action bubbling is normally + handled internally and we do not want to take the browser to a new URL (for + example). + + If you need to override this behavior specify `preventDefault=false` in + your template: ```handlebars - {{unless useLongGreeting "Hi" "Hello"}} Ben + {{#link-to 'photoGallery' aPhotoId preventDefault=false}} + {{aPhotoId.title}} + {{/link-to}} ``` - You can use the `unless` helper inside another helper as a subexpression. + ### Overriding attributes + You can override any given property of the `Ember.LinkComponent` + that is generated by the `{{link-to}}` component by passing + key/value pairs, like so: ```handlebars - {{some-component height=(unless isBig "10" "100")}} + {{#link-to aPhoto tagName='li' title='Following this link will change your life' classNames='pic sweet'}} + Uh-mazing! + {{/link-to}} ``` - @method unless - @for Ember.Templates.helpers - @public - */ - - function inlineUnless(vm, _ref2) { - var positional = _ref2.positional; - - switch (positional.length) { - case 2: - return ConditionalHelperReference.create(positional.at(0), null, positional.at(1)); - case 3: - return ConditionalHelperReference.create(positional.at(0), positional.at(2), positional.at(1)); - default: - } - } -}); -enifed('ember-glimmer/helpers/loc', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; - - /** - Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the - provided string. This is a convenient way to localize text within a template. - For example: + See [Ember.LinkComponent](/api/classes/Ember.LinkComponent.html) for a + complete list of overrideable properties. Be sure to also + check out inherited properties of `LinkComponent`. - ```javascript - Ember.STRINGS = { - '_welcome_': 'Bonjour' - }; - ``` + ### Overriding Application-wide Defaults + ``{{link-to}}`` creates an instance of `Ember.LinkComponent` + for rendering. To override options for your entire + application, reopen `Ember.LinkComponent` and supply the + desired values: - ```handlebars -
    - {{loc '_welcome_'}} -
    + ``` javascript + Ember.LinkComponent.reopen({ + activeClass: "is-active", + tagName: 'li' + }) ``` - ```html -
    - Bonjour -
    - ``` + It is also possible to override the default event in + this manner: - See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to - set up localized string references. + ``` javascript + Ember.LinkComponent.reopen({ + eventName: 'customEventName' + }); + ``` - @method loc + @method link-to @for Ember.Templates.helpers - @param {String} str The string to format. - @see {Ember.String#loc} + @param {String} routeName + @param {Object} [context]* + @param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkComponent + @return {String} HTML string + @see {Ember.LinkComponent} @public */ - function locHelper(_ref) { - var positional = _ref.positional; - - return _emberRuntime.String.loc.apply(null, positional.value()); - } - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(locHelper, args); - }; -}); -enifed('ember-glimmer/helpers/log', ['exports', 'ember-glimmer/utils/references', 'ember-console'], function (exports, _emberGlimmerUtilsReferences, _emberConsole) { 'use strict'; /** - `log` allows you to output the value of variables in the current rendering - context. `log` also accepts primitive types such as strings or numbers. + `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. - ```handlebars - {{log "myVariable:" myVariable }} - ``` + `Ember.LinkComponent` components are invoked with {{#link-to}}. Properties + of this class can be overridden with `reopen` to customize application-wide + behavior. - @method log - @for Ember.Templates.helpers - @param {Array} params + @class LinkComponent + @namespace Ember + @extends Ember.Component + @see {Ember.Templates.helpers.link-to} @public - */ - function log(_ref) { - var positional = _ref.positional; - - _emberConsole.default.log.apply(null, positional.value()); - } - - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(log, args); - }; -}); + **/ + var LinkComponent = _emberGlimmerComponent.default.extend({ + layout: _emberGlimmerTemplatesLinkTo.default, -/** -@module ember -@submodule ember-glimmer -*/ -enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerHelpersAction) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; + tagName: 'a', - exports.isMut = isMut; - exports.unMut = unMut; + /** + @deprecated Use current-when instead. + @property currentWhen + @private + */ + currentWhen: _emberRuntime.deprecatingAlias('current-when', { id: 'ember-routing-view.deprecated-current-when', until: '3.0.0' }), - /** - The `mut` helper lets you __clearly specify__ that a child `Component` can update the - (mutable) value passed to it, which will __change the value of the parent component__. - - To specify that a parameter is mutable, when invoking the child `Component`: - - ```handlebars - {{my-child childClickCount=(mut totalClicks)}} - ``` - - The child `Component` can then modify the parent's value just by modifying its own - property: - - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.incrementProperty('childClickCount'); - } - }); - ``` - - Note that for curly components (`{{my-component}}`) the bindings are already mutable, - making the `mut` unnecessary. - - Additionally, the `mut` helper can be combined with the `action` helper to - mutate a value. For example: - - ```handlebars - {{my-child childClickCount=totalClicks click-count-change=(action (mut totalClicks))}} - ``` - - The child `Component` would invoke the action with the new click value: - - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.get('click-count-change')(this.get('childClickCount') + 1); - } - }); - ``` - - The `mut` helper changes the `totalClicks` value to what was provided as the action argument. - - The `mut` helper, when used with `action`, will return a function that - sets the value passed to `mut` to its first argument. This works like any other - closure action and interacts with the other features `action` provides. - As an example, we can create a button that increments a value passing the value - directly to the `action`: - - ```handlebars - {{! inc helper is not provided by Ember }} - - ``` - - You can also use the `value` option: - - ```handlebars - - ``` - - @method mut - @param {Object} [attr] the "two-way" attribute that can be modified. - @for Ember.Templates.helpers - @public - */ - var MUT_REFERENCE = _emberUtils.symbol('MUT'); - var SOURCE = _emberUtils.symbol('SOURCE'); + /** + Used to determine when this `LinkComponent` is active. + @property currentWhen + @public + */ + 'current-when': null, - function isMut(ref) { - return ref && ref[MUT_REFERENCE]; - } + /** + Sets the `title` attribute of the `LinkComponent`'s HTML element. + @property title + @default null + @public + **/ + title: null, - function unMut(ref) { - return ref[SOURCE] || ref; - } + /** + Sets the `rel` attribute of the `LinkComponent`'s HTML element. + @property rel + @default null + @public + **/ + rel: null, - exports.default = function (vm, args) { - var rawRef = args.positional.at(0); + /** + Sets the `tabindex` attribute of the `LinkComponent`'s HTML element. + @property tabindex + @default null + @public + **/ + tabindex: null, - if (isMut(rawRef)) { - return rawRef; - } + /** + Sets the `target` attribute of the `LinkComponent`'s HTML element. + @since 1.8.0 + @property target + @default null + @public + **/ + target: null, - // TODO: Improve this error message. This covers at least two distinct - // cases: - // - // 1. (mut "not a path") – passing a literal, result from a helper - // invocation, etc - // - // 2. (mut receivedValue) – passing a value received from the caller - // that was originally derived from a literal, result from a helper - // invocation, etc - // - // This message is alright for the first case, but could be quite - // confusing for the second case. + /** + The CSS class to apply to `LinkComponent`'s element when its `active` + property is `true`. + @property activeClass + @type String + @default active + @public + **/ + activeClass: 'active', - var wrappedRef = Object.create(rawRef); + /** + The CSS class to apply to `LinkComponent`'s element when its `loading` + property is `true`. + @property loadingClass + @type String + @default loading + @private + **/ + loadingClass: 'loading', - wrappedRef[SOURCE] = rawRef; - wrappedRef[_emberGlimmerHelpersAction.INVOKE] = rawRef[_emberGlimmerUtilsReferences.UPDATE]; - wrappedRef[MUT_REFERENCE] = true; + /** + The CSS class to apply to a `LinkComponent`'s element when its `disabled` + property is `true`. + @property disabledClass + @type String + @default disabled + @private + **/ + disabledClass: 'disabled', + _isDisabled: false, - return wrappedRef; - }; -}); -enifed('ember-glimmer/helpers/query-param', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal, _emberRouting) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; + /** + Determines whether the `LinkComponent` will trigger routing via + the `replaceWith` routing strategy. + @property replace + @type Boolean + @default false + @public + **/ + replace: false, - /** - This is a helper to be used in conjunction with the link-to helper. - It will supply url query parameters to the target route. - - Example - - ```handlebars - {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} - ``` - - @method query-params - @for Ember.Templates.helpers - @param {Object} hash takes a hash of query parameters - @return {Object} A `QueryParams` object for `{{link-to}}` - @public - */ - function queryParams(_ref) { - var positional = _ref.positional; - var named = _ref.named; + /** + By default the `{{link-to}}` component will bind to the `href` and + `title` attributes. It's discouraged that you override these defaults, + however you can push onto the array if needed. + @property attributeBindings + @type Array | String + @default ['title', 'rel', 'tabindex', 'target'] + @public + */ + attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'], - return _emberRouting.QueryParams.create({ - values: _emberUtils.assign({}, named.value()) - }); - } + /** + By default the `{{link-to}}` component will bind to the `active`, `loading`, + and `disabled` classes. It is discouraged to override these directly. + @property classNameBindings + @type Array + @default ['active', 'loading', 'disabled', 'ember-transitioning-in', 'ember-transitioning-out'] + @public + */ + classNameBindings: ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'], - exports.default = function (vm, args) { - return new _emberGlimmerUtilsReferences.InternalHelperReference(queryParams, args); - }; -}); -enifed('ember-glimmer/helpers/readonly', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/mut'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerHelpersMut) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; + /** + By default the `{{link-to}}` component responds to the `click` event. You + can override this globally by setting this property to your custom + event name. + This is particularly useful on mobile when one wants to avoid the 300ms + click delay using some sort of custom `tap` event. + @property eventName + @type String + @default click + @private + */ + eventName: 'click', - /** - The `readonly` helper let's you specify that a binding is one-way only, - instead of two-way. - When you pass a `readonly` binding from an outer context (e.g. parent component), - to to an inner context (e.g. child component), you are saying that changing that - property in the inner context does not change the value in the outer context. - - To specify that a binding is read-only, when invoking the child `Component`: - - ```app/components/my-parent.js - export default Component.extend({ - totalClicks: 3 - }); - ``` - - ```app/templates/components/my-parent.hbs - {{log totalClicks}} // -> 3 - {{my-child childClickCount=(readonly totalClicks)}} - ``` - - Now, when you update `childClickCount`: - - ```app/components/my-child.js - export default Component.extend({ - click() { - this.incrementProperty('childClickCount'); + // this is doc'ed here so it shows up in the events + // section of the API documentation, which is where + // people will likely go looking for it. + /** + Triggers the `LinkComponent`'s routing behavior. If + `eventName` is changed to a value other than `click` + the routing behavior will trigger on that custom event + instead. + @event click + @private + */ + + /** + An overridable method called when `LinkComponent` objects are instantiated. + Example: + ```javascript + App.MyLinkComponent = Ember.LinkComponent.extend({ + init: function() { + this._super(...arguments); + Ember.Logger.log('Event is ' + this.get('eventName')); + } + }); + ``` + NOTE: If you do override `init` for a framework class like `Ember.View`, + be sure to call `this._super(...arguments)` in your + `init` declaration! If you don't, Ember may not have an opportunity to + do important setup work, and you'll see strange behavior in your + application. + @method init + @private + */ + init: function () { + this._super.apply(this, arguments); + + // Map desired event name to invoke function + var eventName = _emberMetal.get(this, 'eventName'); + this.on(eventName, this, this._invoke); + }, + + _routing: _emberRuntime.inject.service('-routing'), + + /** + Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass` + CSS `class` to the element when the link is disabled. + When `true` interactions with the element will not trigger route changes. + @property disabled + @private + */ + disabled: _emberMetal.computed({ + get: function (key, value) { + return false; + }, + set: function (key, value) { + if (value !== undefined) { + this.set('_isDisabled', value); + } + + return value ? _emberMetal.get(this, 'disabledClass') : false; } - }); - ``` - - The value updates in the child component, but not the parent component: - - ```app/templates/components/my-child.hbs - {{log childClickCount}} //-> 4 - ``` - - ```app/templates/components/my-parent.hbs - {{log totalClicks}} //-> 3 - {{my-child childClickCount=(readonly totalClicks)}} - ``` - - ### Objects and Arrays - - When passing a property that is a complex object (e.g. object, array) instead of a primitive object (e.g. number, string), - only the reference to the object is protected using the readonly helper. - This means that you can change properties of the object both on the parent component, as well as the child component. - The `readonly` binding behaves similar to the `const` keyword in JavaScript. - - Let's look at an example: - - First let's set up the parent component: - - ```app/components/my-parent.js - export default Ember.Component.extend({ - clicks: null, - - init() { - this._super(...arguments); - this.set('clicks', { total: 3 }); + }), + + _computeActive: function (routerState) { + if (_emberMetal.get(this, 'loading')) { + return false; } - }); - ``` - - ```app/templates/components/my-parent.hbs - {{log clicks.total}} //-> 3 - {{my-child childClicks=(readonly clicks)}} - ``` - - Now, if you update the `total` property of `childClicks`: - - ```app/components/my-child.js - export default Ember.Component.extend({ - click() { - this.get('clicks').incrementProperty('total'); + + var routing = _emberMetal.get(this, '_routing'); + var models = _emberMetal.get(this, 'models'); + var resolvedQueryParams = _emberMetal.get(this, 'resolvedQueryParams'); + + var currentWhen = _emberMetal.get(this, 'current-when'); + var isCurrentWhenSpecified = !!currentWhen; + currentWhen = currentWhen || _emberMetal.get(this, 'qualifiedRouteName'); + currentWhen = currentWhen.split(' '); + + for (var i = 0; i < currentWhen.length; i++) { + if (routing.isActiveForRoute(models, resolvedQueryParams, currentWhen[i], routerState, isCurrentWhenSpecified)) { + return _emberMetal.get(this, 'activeClass'); + } } - }); - ``` - - You will see the following happen: - - ```app/templates/components/my-parent.hbs - {{log clicks.total}} //-> 4 - {{my-child childClicks=(readonly clicks)}} - ``` - - ```app/templates/components/my-child.hbs - {{log childClicks.total}} //-> 4 - ``` - - @method readonly - @param {Object} [attr] the read-only attribute. - @for Ember.Templates.helpers - @private - */ - exports.default = function (vm, args) { - var ref = _emberGlimmerHelpersMut.unMut(args.positional.at(0)); + return false; + }, - var wrapped = Object.create(ref); + /** + Accessed as a classname binding to apply the `LinkComponent`'s `activeClass` + CSS `class` to the element when the link is active. + A `LinkComponent` is considered active when its `currentWhen` property is `true` + or the application's current route is the route the `LinkComponent` would trigger + transitions into. + The `currentWhen` property can match against multiple routes by separating + route names using the ` ` (space) character. + @property active + @private + */ + active: _emberMetal.computed('attrs.params', '_routing.currentState', function computeLinkToComponentActive() { + var currentState = _emberMetal.get(this, '_routing.currentState'); + if (!currentState) { + return false; + } - wrapped[_emberGlimmerUtilsReferences.UPDATE] = undefined; + return this._computeActive(currentState); + }), - return wrapped; - }; -}); -enifed('ember-glimmer/helpers/unbound', ['exports', 'ember-metal', 'ember-glimmer/utils/references'], function (exports, _emberMetal, _emberGlimmerUtilsReferences) { - /** - @module ember - @submodule ember-glimmer - */ + willBeActive: _emberMetal.computed('_routing.targetState', function computeLinkToComponentWillBeActive() { + var routing = _emberMetal.get(this, '_routing'); + var targetState = _emberMetal.get(routing, 'targetState'); + if (_emberMetal.get(routing, 'currentState') === targetState) { + return; + } - 'use strict'; + return !!this._computeActive(targetState); + }), - /** - The `{{unbound}}` helper disconnects the one-way binding of a property, - essentially freezing its value at the moment of rendering. For example, - in this example the display of the variable `name` will not change even - if it is set with a new value: - - ```handlebars - {{unbound name}} - ``` - - Like any helper, the `unbound` helper can accept a nested helper expression. - This allows for custom helpers to be rendered unbound: - - ```handlebars - {{unbound (some-custom-helper)}} - {{unbound (capitalize name)}} - {{! You can use any helper, including unbound, in a nested expression }} - {{capitalize (unbound name)}} - ``` - - The `unbound` helper only accepts a single argument, and it return an - unbound value. - - @method unbound - @for Ember.Templates.helpers - @public - */ + transitioningIn: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningIn() { + var willBeActive = _emberMetal.get(this, 'willBeActive'); + if (typeof willBeActive === 'undefined') { + return false; + } - exports.default = function (vm, args) { + return !_emberMetal.get(this, 'active') && willBeActive && 'ember-transitioning-in'; + }), - return _emberGlimmerUtilsReferences.UnboundReference.create(args.positional.at(0).value()); - }; -}); -enifed('ember-glimmer/index', ['exports', 'ember-glimmer/helpers/action', 'ember-glimmer/templates/root', 'ember-glimmer/syntax', 'ember-glimmer/template', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/helper', 'ember-glimmer/environment', 'ember-glimmer/make-bound-helper', 'ember-glimmer/utils/string', 'ember-glimmer/renderer', 'ember-glimmer/template_registry', 'ember-glimmer/setup-registry', 'ember-glimmer/dom'], function (exports, _emberGlimmerHelpersAction, _emberGlimmerTemplatesRoot, _emberGlimmerSyntax, _emberGlimmerTemplate, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerHelper, _emberGlimmerEnvironment, _emberGlimmerMakeBoundHelper, _emberGlimmerUtilsString, _emberGlimmerRenderer, _emberGlimmerTemplate_registry, _emberGlimmerSetupRegistry, _emberGlimmerDom) { - /** - [Glimmer](https://github.com/tildeio/glimmer) is a [Handlebars](http://handlebarsjs.com/) - compatible templating engine used by Ember.js. - Any valid Handlebars syntax is valid in an Ember template. - - ### Showing a property - - Templates manage the flow of an application's UI, and display state (through - the DOM) to a user. For example, given a component with the property "name", - that component's template can use the name in several ways: - - ```javascript - // app/components/person.js - export default Ember.Component.extend({ - name: 'Jill' - }); - ``` - - ```handlebars - {{! app/components/person.hbs }} - {{name}} -
    {{name}}
    - - ``` - - Any time the "name" property on the component changes, the DOM will be - updated. - - Properties can be chained as well: - - ```handlebars - {{aUserModel.name}} -
    {{listOfUsers.firstObject.name}}
    - ``` - - ### Using Ember helpers - - When content is passed in mustaches `{{}}`, Ember will first try to find a helper - or component with that name. For example, the `if` helper: - - ```handlebars - {{if name "I have a name" "I have no name"}} - - ``` - - The returned value is placed where the `{{}}` is called. The above style is - called "inline". A second style of helper usage is called "block". For example: - - ```handlebars - {{#if name}} - I have a name - {{else}} - I have no name - {{/if}} - ``` - - The block form of helpers allows you to control how the UI is created based - on the values of properties. - A third form of helper is called "nested". For example here the concat - helper will add " Doe" to a displayed name if the person has no last name: - - ```handlebars - - ``` - - Ember's built-in helpers are described under the [Ember.Templates.helpers](/api/classes/Ember.Templates.helpers.html) - namespace. Documentation on creating custom helpers can be found under - [Ember.Helper](/api/classes/Ember.Helper.html). - - ### Invoking a Component - - Ember components represent state to the UI of an application. Further - reading on components can be found under [Ember.Component](/api/classes/Ember.Component.html). - - @module ember - @submodule ember-glimmer - @main ember-glimmer - @public - */ - - /** - Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful - for semantic clarity as it allows you to retain default scope or to reference a property from another - `{{with}}` block. - - If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0`, NaN or - an empty array, the block will not be rendered. - - ```handlebars - {{! Will only render if user.posts contains items}} - {{#with user.posts as |blogPosts|}} -
    - There are {{blogPosts.length}} blog posts written by {{user.name}}. -
    - {{#each blogPosts as |post|}} -
  • {{post.title}}
  • - {{/each}} - {{/with}} - ``` - - Without the `as` operator, it would be impossible to reference `user.name` in the example above. - - NOTE: The alias should not reuse a name from the bound property path. - - For example: `{{#with foo.bar as |foo|}}` is not supported because it attempts to alias using - the first part of the property path, `foo`. Instead, use `{{#with foo.bar as |baz|}}`. - - @method with - @for Ember.Templates.helpers - @param {Object} options - @return {String} HTML string - @public - */ - - /** - Execute the `debugger` statement in the current template's context. - - ```handlebars - {{debugger}} - ``` - - When using the debugger helper you will have access to a `get` function. This - function retrieves values available in the context of the template. - For example, if you're wondering why a value `{{foo}}` isn't rendering as - expected within a template, you could place a `{{debugger}}` statement and, - when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: - - ``` - > get('foo') - ``` - - `get` is also aware of keywords. So in this situation - - ```handlebars - {{#each items as |item|}} - {{debugger}} - {{/each}} - ``` - - You'll be able to get values from the current item: - - ``` - > get('item.name') - ``` - - You can also access the context of the view to make sure it is the object that - you expect: - - ``` - > context - ``` - - @method debugger - @for Ember.Templates.helpers - @public - */ - - /** - The `partial` helper renders another template without - changing the template context: - - ```handlebars - {{foo}} - {{partial "nav"}} - ``` - - The above example template will render a template named - "-nav", which has the same context as the parent template - it's rendered into, so if the "-nav" template also referenced - `{{foo}}`, it would print the same thing as the `{{foo}}` - in the above example. - - If a "-nav" template isn't found, the `partial` helper will - fall back to a template named "nav". - - ### Bound template names - - The parameter supplied to `partial` can also be a path - to a property containing a template name, e.g.: - - ```handlebars - {{partial someTemplateName}} - ``` - - The above example will look up the value of `someTemplateName` - on the template context (e.g. a controller) and use that - value as the name of the template to render. If the resolved - value is falsy, nothing will be rendered. If `someTemplateName` - changes, the partial will be re-rendered using the new template - name. - - @method partial - @for Ember.Templates.helpers - @param {String} partialName The name of the template to render minus the leading underscore. - @public - */ - - 'use strict'; + transitioningOut: _emberMetal.computed('active', 'willBeActive', function computeLinkToComponentTransitioningOut() { + var willBeActive = _emberMetal.get(this, 'willBeActive'); + if (typeof willBeActive === 'undefined') { + return false; + } - exports.INVOKE = _emberGlimmerHelpersAction.INVOKE; - exports.RootTemplate = _emberGlimmerTemplatesRoot.default; - exports.registerSyntax = _emberGlimmerSyntax.registerSyntax; - exports.template = _emberGlimmerTemplate.default; - exports.Checkbox = _emberGlimmerComponentsCheckbox.default; - exports.TextField = _emberGlimmerComponentsText_field.default; - exports.TextArea = _emberGlimmerComponentsText_area.default; - exports.LinkComponent = _emberGlimmerComponentsLinkTo.default; - exports.Component = _emberGlimmerComponent.default; - exports.Helper = _emberGlimmerHelper.default; - exports.helper = _emberGlimmerHelper.helper; - exports.Environment = _emberGlimmerEnvironment.default; - exports.makeBoundHelper = _emberGlimmerMakeBoundHelper.default; - exports.SafeString = _emberGlimmerUtilsString.SafeString; - exports.escapeExpression = _emberGlimmerUtilsString.escapeExpression; - exports.htmlSafe = _emberGlimmerUtilsString.htmlSafe; - exports.isHTMLSafe = _emberGlimmerUtilsString.isHTMLSafe; - exports._getSafeString = _emberGlimmerUtilsString.getSafeString; - exports.Renderer = _emberGlimmerRenderer.Renderer; - exports.InertRenderer = _emberGlimmerRenderer.InertRenderer; - exports.InteractiveRenderer = _emberGlimmerRenderer.InteractiveRenderer; - exports.getTemplate = _emberGlimmerTemplate_registry.getTemplate; - exports.setTemplate = _emberGlimmerTemplate_registry.setTemplate; - exports.hasTemplate = _emberGlimmerTemplate_registry.hasTemplate; - exports.getTemplates = _emberGlimmerTemplate_registry.getTemplates; - exports.setTemplates = _emberGlimmerTemplate_registry.setTemplates; - exports.setupEngineRegistry = _emberGlimmerSetupRegistry.setupEngineRegistry; - exports.setupApplicationRegistry = _emberGlimmerSetupRegistry.setupApplicationRegistry; - exports.DOMChanges = _emberGlimmerDom.DOMChanges; - exports.NodeDOMTreeConstruction = _emberGlimmerDom.NodeDOMTreeConstruction; - exports.DOMTreeConstruction = _emberGlimmerDom.DOMTreeConstruction; -}); -enifed('ember-glimmer/make-bound-helper', ['exports', 'ember-metal', 'ember-glimmer/helper'], function (exports, _emberMetal, _emberGlimmerHelper) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; + return _emberMetal.get(this, 'active') && !willBeActive && 'ember-transitioning-out'; + }), - exports.default = makeBoundHelper; + /** + Event handler that invokes the link, activating the associated route. + @method _invoke + @param {Event} event + @private + */ + _invoke: function (event) { + if (!_emberViews.isSimpleClick(event)) { + return true; + } - /** - Create a bound helper. Accepts a function that receives the ordered and hash parameters - from the template. If a bound property was provided in the template, it will be resolved to its - value and any changes to the bound property cause the helper function to be re-run with the updated - values. - - * `params` - An array of resolved ordered parameters. - * `hash` - An object containing the hash parameters. - - For example: - - * With an unquoted ordered parameter: - - ```javascript - {{x-capitalize foo}} - ``` - - Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and - an empty hash as its second. - - * With a quoted ordered parameter: - - ```javascript - {{x-capitalize "foo"}} - ``` - - The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. - - * With an unquoted hash parameter: - - ```javascript - {{x-repeat "foo" count=repeatCount}} - ``` - - Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, - and { count: 2 } as its second. - - @private - @method makeBoundHelper - @for Ember.HTMLBars - @param {Function} fn - @since 1.10.0 - */ + var preventDefault = _emberMetal.get(this, 'preventDefault'); + var targetAttribute = _emberMetal.get(this, 'target'); - function makeBoundHelper(fn) { - return _emberGlimmerHelper.helper(fn); - } -}); -enifed('ember-glimmer/modifiers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _emberGlimmerHelpersAction) { - 'use strict'; + if (preventDefault !== false) { + if (!targetAttribute || targetAttribute === '_self') { + event.preventDefault(); + } + } - var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; - var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; + if (_emberMetal.get(this, 'bubbles') === false) { + event.stopPropagation(); + } - function isAllowedEvent(event, allowedKeys) { - if (allowedKeys === null || typeof allowedKeys === 'undefined') { - if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { - return _emberViews.isSimpleClick(event); - } else { - allowedKeys = ''; + if (_emberMetal.get(this, '_isDisabled')) { + return false; } - } - if (allowedKeys.indexOf('any') >= 0) { - return true; - } + if (_emberMetal.get(this, 'loading')) { + _emberConsole.default.warn('This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'); + return false; + } - for (var i = 0; i < MODIFIERS.length; i++) { - if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { + if (targetAttribute && targetAttribute !== '_self') { return false; } - } - return true; - } + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var models = _emberMetal.get(this, 'models'); + var queryParams = _emberMetal.get(this, 'queryParams.values'); + var shouldReplace = _emberMetal.get(this, 'replace'); - var ActionHelper = { - // registeredActions is re-exported for compatibility with older plugins - // that were using this undocumented API. - registeredActions: _emberViews.ActionManager.registeredActions, + var payload = { + queryParams: queryParams, + routeName: qualifiedRouteName + }; - registerAction: function (actionState) { - var actionId = actionState.actionId; + _emberMetal.flaggedInstrument('interaction.link-to', payload, this._generateTransition(payload, qualifiedRouteName, models, queryParams, shouldReplace)); + }, + + _generateTransition: function (payload, qualifiedRouteName, models, queryParams, shouldReplace) { + var routing = _emberMetal.get(this, '_routing'); + return function () { + payload.transition = routing.transitionTo(qualifiedRouteName, models, queryParams, shouldReplace); + }; + }, - var actions = _emberViews.ActionManager.registeredActions[actionId]; + queryParams: null, - if (!actions) { - actions = _emberViews.ActionManager.registeredActions[actionId] = []; + qualifiedRouteName: _emberMetal.computed('targetRouteName', '_routing.currentState', function computeLinkToComponentQualifiedRouteName() { + var params = _emberMetal.get(this, 'params').slice(); + var lastParam = params[params.length - 1]; + if (lastParam && lastParam.isQueryParams) { + params.pop(); + } + var onlyQueryParamsSupplied = this[_emberGlimmerComponent.HAS_BLOCK] ? params.length === 0 : params.length === 1; + if (onlyQueryParamsSupplied) { + return _emberMetal.get(this, '_routing.currentRouteName'); } + return _emberMetal.get(this, 'targetRouteName'); + }), - actions.push(actionState); + resolvedQueryParams: _emberMetal.computed('queryParams', function computeLinkToComponentResolvedQueryParams() { + var resolvedQueryParams = {}; + var queryParams = _emberMetal.get(this, 'queryParams'); - return actionId; - }, + if (!queryParams) { + return resolvedQueryParams; + } - unregisterAction: function (actionState) { - var actionId = actionState.actionId; + var values = queryParams.values; + for (var key in values) { + if (!values.hasOwnProperty(key)) { + continue; + } + resolvedQueryParams[key] = values[key]; + } - var actions = _emberViews.ActionManager.registeredActions[actionId]; + return resolvedQueryParams; + }), - if (!actions) { + /** + Sets the element's `href` attribute to the url for + the `LinkComponent`'s targeted route. + If the `LinkComponent`'s `tagName` is changed to a value other + than `a`, this property will be ignored. + @property href + @private + */ + href: _emberMetal.computed('models', 'qualifiedRouteName', function computeLinkToComponentHref() { + if (_emberMetal.get(this, 'tagName') !== 'a') { return; } - var index = actions.indexOf(actionState); + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var models = _emberMetal.get(this, 'models'); - if (index !== -1) { - actions.splice(index, 1); + if (_emberMetal.get(this, 'loading')) { + return _emberMetal.get(this, 'loadingHref'); } - if (actions.length === 0) { - delete _emberViews.ActionManager.registeredActions[actionId]; + var routing = _emberMetal.get(this, '_routing'); + var queryParams = _emberMetal.get(this, 'queryParams.values'); + + return routing.generateURL(qualifiedRouteName, models, queryParams); + }), + + loading: _emberMetal.computed('_modelsAreLoaded', 'qualifiedRouteName', function computeLinkToComponentLoading() { + var qualifiedRouteName = _emberMetal.get(this, 'qualifiedRouteName'); + var modelsAreLoaded = _emberMetal.get(this, '_modelsAreLoaded'); + + if (!modelsAreLoaded || qualifiedRouteName == null) { + return _emberMetal.get(this, 'loadingClass'); } - } - }; + }), - exports.ActionHelper = ActionHelper; + _modelsAreLoaded: _emberMetal.computed('models', function computeLinkToComponentModelsAreLoaded() { + var models = _emberMetal.get(this, 'models'); + for (var i = 0; i < models.length; i++) { + if (models[i] == null) { + return false; + } + } - var ActionState = (function () { - function ActionState(element, actionId, actionName, actionArgs, namedArgs, positionalArgs, implicitTarget, dom) { - this.element = element; - this.actionId = actionId; - this.actionName = actionName; - this.actionArgs = actionArgs; - this.namedArgs = namedArgs; - this.positional = positionalArgs; - this.implicitTarget = implicitTarget; - this.dom = dom; - this.eventName = this.getEventName(); - } + return true; + }), - // implements ModifierManager + _getModels: function (params) { + var modelCount = params.length - 1; + var models = new Array(modelCount); - ActionState.prototype.getEventName = function getEventName() { - return this.namedArgs.get('on').value() || 'click'; - }; + for (var i = 0; i < modelCount; i++) { + var value = params[i + 1]; - ActionState.prototype.getActionArgs = function getActionArgs() { - var result = new Array(this.actionArgs.length); + while (_emberRuntime.ControllerMixin.detect(value)) { + value = value.get('model'); + } - for (var i = 0; i < this.actionArgs.length; i++) { - result[i] = this.actionArgs[i].value(); + models[i] = value; } - return result; - }; + return models; + }, - ActionState.prototype.getTarget = function getTarget() { - var implicitTarget = this.implicitTarget; - var namedArgs = this.namedArgs; + /** + The default href value to use while a link-to is loading. + Only applies when tagName is 'a' + @property loadingHref + @type String + @default # + @private + */ + loadingHref: '#', - var target = undefined; + didReceiveAttrs: function () { + var queryParams = undefined; - if (namedArgs.has('target')) { - target = namedArgs.get('target').value(); - } else { - target = implicitTarget.value(); + var params = _emberMetal.get(this, 'params'); + + if (params) { + // Do not mutate params in place + params = params.slice(); } - return target; - }; + var disabledWhen = _emberMetal.get(this, 'disabledWhen'); + if (disabledWhen !== undefined) { + this.set('disabled', disabledWhen); + } - ActionState.prototype.handler = function handler(event) { - var _this = this; + // Process the positional arguments, in order. + // 1. Inline link title comes first, if present. + if (!this[_emberGlimmerComponent.HAS_BLOCK]) { + this.set('linkTitle', params.shift()); + } - var actionName = this.actionName; - var namedArgs = this.namedArgs; + // 2. `targetRouteName` is now always at index 0. + this.set('targetRouteName', params[0]); - var bubbles = namedArgs.get('bubbles'); - var preventDefault = namedArgs.get('preventDefault'); - var allowedKeys = namedArgs.get('allowedKeys'); - var target = this.getTarget(); + // 3. The last argument (if still remaining) is the `queryParams` object. + var lastParam = params[params.length - 1]; - if (!isAllowedEvent(event, allowedKeys.value())) { - return true; + if (lastParam && lastParam.isQueryParams) { + queryParams = params.pop(); + } else { + queryParams = { values: {} }; } + this.set('queryParams', queryParams); - if (preventDefault.value() !== false) { - event.preventDefault(); + // 4. Any remaining indices (excepting `targetRouteName` at 0) are `models`. + if (params.length > 1) { + this.set('models', this._getModels(params)); + } else { + this.set('models', []); } + } + }); - if (bubbles.value() === false) { - event.stopPropagation(); - } + LinkComponent.toString = function () { + return 'LinkComponent'; + }; - _emberMetal.run(function () { - var args = _this.getActionArgs(); - var payload = { - args: args, - target: target - }; - if (typeof actionName[_emberGlimmerHelpersAction.INVOKE] === 'function') { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - actionName[_emberGlimmerHelpersAction.INVOKE].apply(actionName, args); - }); - return; - } - if (typeof actionName === 'function') { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - actionName.apply(target, args); - }); - return; - } - payload.name = actionName; - if (target.send) { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - target.send.apply(target, [actionName].concat(args)); - }); - } else { - _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { - target[actionName].apply(target, args); - }); - } - }); - }; + LinkComponent.reopenClass({ + positionalParams: 'params' + }); - ActionState.prototype.destroy = function destroy() { - ActionHelper.unregisterAction(this); - }; + exports.default = LinkComponent; +}); - return ActionState; - })(); +/* + * Unfortunately, to get decent error messages, we need to do this. + * In some future state we should be able to use a "feature flag" + * which allows us to strip this without needing to call it twice. + * + * if (isDebugBuild()) { + * // Do the useful debug thing, probably including try/catch. + * } else { + * // Do the performant thing. + * } + */ +enifed('ember-glimmer/components/text_area', ['exports', 'ember-glimmer/component', 'ember-views', 'ember-glimmer/templates/empty'], function (exports, _emberGlimmerComponent, _emberViews, _emberGlimmerTemplatesEmpty) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - exports.ActionState = ActionState; + /** + `{{textarea}}` inserts a new instance of ` + ``` + + Bound: + + In the following example, the `writtenWords` property on `App.ApplicationController` + will be updated live as the user types 'Lots of text that IS bound' into + the text area of their browser's window. + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound" + }); + ``` + + ```handlebars + {{textarea value=writtenWords}} + ``` + + Would result in the following HTML: + + ```html + + ``` + + If you wanted a one way binding between the text area and a div tag + somewhere else on your screen, you could use `Ember.computed.oneWay`: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + outputWrittenWords: Ember.computed.oneWay("writtenWords") + }); + ``` + + ```handlebars + {{textarea value=writtenWords}} +
    + {{outputWrittenWords}} +
    + ``` + + Would result in the following HTML: + + ```html + + <-- the following div will be updated in real time as you type --> +
    + Lots of text that IS bound +
    + ``` + + Finally, this example really shows the power and ease of Ember when two + properties are bound to eachother via `Ember.computed.alias`. Type into + either text area box and they'll both stay in sync. Note that + `Ember.computed.alias` costs more in terms of performance, so only use it when + your really binding in both directions: + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + writtenWords: "Lots of text that IS bound", + twoWayWrittenWords: Ember.computed.alias("writtenWords") + }); + ``` + + ```handlebars + {{textarea value=writtenWords}} + {{textarea value=twoWayWrittenWords}} + ``` + + ```html + + <-- both updated in real time --> + + ``` + + ### Actions + + The helper can send multiple actions based on user events. + The action property defines the action which is send when + the user presses the return key. + + ```handlebars + {{input action="submit"}} + ``` + + The helper allows some user events to send actions. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. + + ```handlebars + {{textarea focus-in="alertMessage"}} + ``` + + See more about [Text Support Actions](/api/classes/Ember.TextArea.html) + + ### Extension + + Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing + arguments from the helper to `Ember.TextArea`'s `create` method. You can + extend the capabilities of text areas in your application by reopening this + class. For example, if you are building a Bootstrap project where `data-*` + attributes are used, you can globally add support for a `data-*` attribute + on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or + `Ember.TextSupport` and adding it to the `attributeBindings` concatenated + property: + + ```javascript + Ember.TextArea.reopen({ + attributeBindings: ['data-error'] + }); + ``` + + Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` + itself extends `Ember.Component`. Expect isolated component semantics, not + legacy 1.x view semantics (like `controller` being present). + + See more about [Ember components](/api/classes/Ember.Component.html) + + @method textarea + @for Ember.Templates.helpers + @param {Hash} options + @public + */ - var ActionModifierManager = (function () { - function ActionModifierManager() {} + /** + The internal class used to create textarea element when the `{{textarea}}` + helper is used. + + See [Ember.Templates.helpers.textarea](/api/classes/Ember.Templates.helpers.html#method_textarea) for usage details. + + ## Layout and LayoutName properties + + Because HTML `textarea` elements do not contain inner HTML the `layout` and + `layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextArea + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + @public + */ + exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { + classNames: ['ember-text-area'], - ActionModifierManager.prototype.create = function create(element, args, dynamicScope, dom) { - var named = args.named; - var positional = args.positional; + layout: _emberGlimmerTemplatesEmpty.default, - var implicitTarget = undefined; - var actionName = undefined; - var actionNameRef = undefined; - if (positional.length > 1) { - implicitTarget = positional.at(0); - actionNameRef = positional.at(1); + tagName: 'textarea', + attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir', 'value'], + rows: null, + cols: null + }); +}); +enifed('ember-glimmer/components/text_field', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-glimmer/component', 'ember-glimmer/templates/empty', 'ember-views'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberGlimmerComponent, _emberGlimmerTemplatesEmpty, _emberViews) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - if (actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { - actionName = actionNameRef; - } else { - var actionLabel = actionNameRef._propertyKey; - actionName = actionNameRef.value(); - } - } + var inputTypeTestElement = undefined; + var inputTypes = new _emberUtils.EmptyObject(); + function canSetTypeOfInput(type) { + if (type in inputTypes) { + return inputTypes[type]; + } - var actionArgs = []; - // The first two arguments are (1) `this` and (2) the action name. - // Everything else is a param. - for (var i = 2; i < positional.length; i++) { - actionArgs.push(positional.at(i)); - } + // if running in outside of a browser always return the + // original type + if (!_emberEnvironment.environment.hasDOM) { + inputTypes[type] = type; - var actionId = _emberUtils.uuid(); - return new ActionState(element, actionId, actionName, actionArgs, named, positional, implicitTarget, dom); - }; + return type; + } - ActionModifierManager.prototype.install = function install(actionState) { - var dom = actionState.dom; - var element = actionState.element; - var actionId = actionState.actionId; + if (!inputTypeTestElement) { + inputTypeTestElement = document.createElement('input'); + } - ActionHelper.registerAction(actionState); + try { + inputTypeTestElement.type = type; + } catch (e) { + // ignored + } - dom.setAttribute(element, 'data-ember-action', ''); - dom.setAttribute(element, 'data-ember-action-' + actionId, actionId); - }; + return inputTypes[type] = inputTypeTestElement.type === type; + } - ActionModifierManager.prototype.update = function update(actionState) { - var positional = actionState.positional; + /** + + The internal class used to create text inputs when the `{{input}}` + helper is used with `type` of `text`. + + See [Ember.Templates.helpers.input](/api/classes/Ember.Templates.helpers.html#method_input) for usage details. + + ## Layout and LayoutName properties + + Because HTML `input` elements are self closing `layout` and `layoutName` + properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s + layout section for more information. + + @class TextField + @namespace Ember + @extends Ember.Component + @uses Ember.TextSupport + @public + */ + exports.default = _emberGlimmerComponent.default.extend(_emberViews.TextSupport, { + layout: _emberGlimmerTemplatesEmpty.default, + classNames: ['ember-text-field'], + tagName: 'input', + attributeBindings: ['accept', 'autocomplete', 'autosave', 'dir', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'inputmode', 'lang', 'list', 'max', 'min', 'multiple', 'name', 'pattern', 'size', 'step', 'type', 'value', 'width'], - var actionNameRef = positional.at(1); + /** + The `value` attribute of the input element. As the user inputs text, this + property is updated live. + @property value + @type String + @default "" + @public + */ + value: '', - if (!actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { - actionState.actionName = actionNameRef.value(); + /** + The `type` attribute of the input element. + @property type + @type String + @default "text" + @public + */ + type: _emberMetal.computed({ + get: function () { + return 'text'; + }, + + set: function (key, value) { + var type = 'text'; + + if (canSetTypeOfInput(value)) { + type = value; + } + + return type; } - actionState.eventName = actionState.getEventName(); + }), - // Not sure if this is needed? If we mutate the actionState is that good enough? - ActionHelper.unregisterAction(actionState); - ActionHelper.registerAction(actionState); - }; + /** + The `size` of the text field in characters. + @property size + @type String + @default null + @public + */ + size: null, - ActionModifierManager.prototype.getDestructor = function getDestructor(modifier) { - return modifier; - }; + /** + The `pattern` attribute of input element. + @property pattern + @type String + @default null + @public + */ + pattern: null, - return ActionModifierManager; - })(); + /** + The `min` attribute of input element used with `type="number"` or `type="range"`. + @property min + @type String + @default null + @since 1.4.0 + @public + */ + min: null, - exports.default = ActionModifierManager; + /** + The `max` attribute of input element used with `type="number"` or `type="range"`. + @property max + @type String + @default null + @since 1.4.0 + @public + */ + max: null + }); }); -enifed('ember-glimmer/protocol-for-url', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - /* globals module, URL */ - +enifed('ember-glimmer/dom', ['exports', '@glimmer/runtime', '@glimmer/node'], function (exports, _glimmerRuntime, _glimmerNode) { 'use strict'; - exports.default = installProtocolForURL; + exports.DOMChanges = _glimmerRuntime.DOMChanges; + exports.DOMTreeConstruction = _glimmerRuntime.DOMTreeConstruction; + exports.NodeDOMTreeConstruction = _glimmerNode.NodeDOMTreeConstruction; +}); +enifed('ember-glimmer/environment', ['exports', 'ember-utils', 'ember-metal', 'ember-views', '@glimmer/runtime', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax', 'ember-glimmer/utils/iterable', 'ember-glimmer/utils/references', 'ember-glimmer/utils/debug-stack', 'ember-glimmer/helpers/if-unless', 'ember-glimmer/helpers/action', 'ember-glimmer/helpers/component', 'ember-glimmer/helpers/concat', 'ember-glimmer/helpers/get', 'ember-glimmer/helpers/hash', 'ember-glimmer/helpers/loc', 'ember-glimmer/helpers/log', 'ember-glimmer/helpers/mut', 'ember-glimmer/helpers/readonly', 'ember-glimmer/helpers/unbound', 'ember-glimmer/helpers/-class', 'ember-glimmer/helpers/-input-type', 'ember-glimmer/helpers/query-param', 'ember-glimmer/helpers/each-in', 'ember-glimmer/helpers/-normalize-class', 'ember-glimmer/helpers/-html-safe', 'ember-glimmer/protocol-for-url', 'container', 'ember-glimmer/modifiers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _glimmerRuntime, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntax, _emberGlimmerUtilsIterable, _emberGlimmerUtilsReferences, _emberGlimmerUtilsDebugStack, _emberGlimmerHelpersIfUnless, _emberGlimmerHelpersAction, _emberGlimmerHelpersComponent, _emberGlimmerHelpersConcat, _emberGlimmerHelpersGet, _emberGlimmerHelpersHash, _emberGlimmerHelpersLoc, _emberGlimmerHelpersLog, _emberGlimmerHelpersMut, _emberGlimmerHelpersReadonly, _emberGlimmerHelpersUnbound, _emberGlimmerHelpersClass, _emberGlimmerHelpersInputType, _emberGlimmerHelpersQueryParam, _emberGlimmerHelpersEachIn, _emberGlimmerHelpersNormalizeClass, _emberGlimmerHelpersHtmlSafe, _emberGlimmerProtocolForUrl, _container, _emberGlimmerModifiersAction) { + 'use strict'; - var nodeURL = undefined; - var parsingNode = undefined; + var Environment = (function (_GlimmerEnvironment) { + babelHelpers.inherits(Environment, _GlimmerEnvironment); - function installProtocolForURL(environment) { - var protocol = undefined; + Environment.create = function create(options) { + return new Environment(options); + }; - if (_emberEnvironment.environment.hasDOM) { - protocol = browserProtocolForURL.call(environment, 'foobar:baz'); - } + function Environment(_ref) { + var _this = this; - // Test to see if our DOM implementation parses - // and normalizes URLs. - if (protocol === 'foobar:') { - // Swap in the method that doesn't do this test now that - // we know it works. - environment.protocolForURL = browserProtocolForURL; - } else if (typeof URL === 'object') { - // URL globally provided, likely from FastBoot's sandbox - nodeURL = URL; - environment.protocolForURL = nodeProtocolForURL; - } else if (typeof module === 'object' && typeof module.require === 'function') { - // Otherwise, we need to fall back to our own URL parsing. - // Global `require` is shadowed by Ember's loader so we have to use the fully - // qualified `module.require`. - nodeURL = module.require('url'); - environment.protocolForURL = nodeProtocolForURL; - } else { - throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); - } - } + var owner = _ref[_emberUtils.OWNER]; - function browserProtocolForURL(url) { - if (!parsingNode) { - parsingNode = document.createElement('a'); - } + _GlimmerEnvironment.apply(this, arguments); + this.owner = owner; + this.isInteractive = owner.lookup('-environment:main').isInteractive; - parsingNode.href = url; - return parsingNode.protocol; - } + // can be removed once https://github.com/tildeio/glimmer/pull/305 lands + this.destroyedComponents = undefined; - function nodeProtocolForURL(url) { - var protocol = null; - if (typeof url === 'string') { - protocol = nodeURL.parse(url).protocol; - } - return protocol === null ? ':' : protocol; - } -}); -enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', 'ember-metal', 'glimmer-reference', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/outlet'], function (exports, _emberGlimmerUtilsReferences, _emberMetal, _glimmerReference, _emberViews, _emberGlimmerComponent, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxOutlet) { - 'use strict'; + _emberGlimmerProtocolForUrl.default(this); - var runInTransaction = undefined; + this._definitionCache = new _emberMetal.Cache(2000, function (_ref2) { + var name = _ref2.name; + var source = _ref2.source; + var owner = _ref2.owner; - if (false || false) { - runInTransaction = _emberMetal.runInTransaction; - } else { - runInTransaction = function (context, methodName) { - context[methodName](); - return false; - }; - } + var _lookupComponent = _emberViews.lookupComponent(owner, name, { source: source }); - var backburner = _emberMetal.run.backburner; + var componentFactory = _lookupComponent.component; + var layout = _lookupComponent.layout; - var DynamicScope = (function () { - function DynamicScope(view, outletState, rootOutletState, targetObject) { - this.view = view; - this.outletState = outletState; - this.rootOutletState = rootOutletState; - } + if (componentFactory || layout) { + return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(name, componentFactory, layout); + } + }, function (_ref3) { + var name = _ref3.name; + var source = _ref3.source; + var owner = _ref3.owner; - DynamicScope.prototype.child = function child() { - return new DynamicScope(this.view, this.outletState, this.rootOutletState); - }; + var expandedName = source && owner._resolveLocalLookupName(name, source) || name; + var ownerGuid = _emberUtils.guidFor(owner); - DynamicScope.prototype.get = function get(key) { - return this.outletState; - }; + return ownerGuid + '|' + expandedName; + }); - DynamicScope.prototype.set = function set(key, value) { - this.outletState = value; - return value; - }; + this._templateCache = new _emberMetal.Cache(1000, function (_ref4) { + var Template = _ref4.Template; + var owner = _ref4.owner; - return DynamicScope; - })(); + if (Template.create) { + var _Template$create; - var RootState = (function () { - function RootState(root, env, template, self, parentElement, dynamicScope) { - var _this = this; + // we received a factory + return Template.create((_Template$create = { env: _this }, _Template$create[_emberUtils.OWNER] = owner, _Template$create)); + } else { + // we were provided an instance already + return Template; + } + }, function (_ref5) { + var Template = _ref5.Template; + var owner = _ref5.owner; + return _emberUtils.guidFor(owner) + '|' + Template.id; + }); - this.id = _emberViews.getViewId(root); - this.env = env; - this.root = root; - this.result = undefined; - this.shouldReflush = false; - this.destroyed = false; - this._removing = false; + this._compilerCache = new _emberMetal.Cache(10, function (Compiler) { + return new _emberMetal.Cache(2000, function (template) { + var compilable = new Compiler(template); + return _glimmerRuntime.compileLayout(compilable, _this); + }, function (template) { + var owner = template.meta.owner; + return _emberUtils.guidFor(owner) + '|' + template.id; + }); + }, function (Compiler) { + return Compiler.id; + }); - var options = this.options = { - alwaysRevalidate: false + this.builtInModifiers = { + action: new _emberGlimmerModifiersAction.default() }; - this.render = function () { - var result = _this.result = template.render(self, parentElement, dynamicScope); - - // override .render function after initial render - _this.render = function () { - result.rerender(options); - }; + this.builtInHelpers = { + if: _emberGlimmerHelpersIfUnless.inlineIf, + action: _emberGlimmerHelpersAction.default, + component: _emberGlimmerHelpersComponent.default, + concat: _emberGlimmerHelpersConcat.default, + get: _emberGlimmerHelpersGet.default, + hash: _emberGlimmerHelpersHash.default, + loc: _emberGlimmerHelpersLoc.default, + log: _emberGlimmerHelpersLog.default, + mut: _emberGlimmerHelpersMut.default, + 'query-params': _emberGlimmerHelpersQueryParam.default, + readonly: _emberGlimmerHelpersReadonly.default, + unbound: _emberGlimmerHelpersUnbound.default, + unless: _emberGlimmerHelpersIfUnless.inlineUnless, + '-class': _emberGlimmerHelpersClass.default, + '-each-in': _emberGlimmerHelpersEachIn.default, + '-input-type': _emberGlimmerHelpersInputType.default, + '-normalize-class': _emberGlimmerHelpersNormalizeClass.default, + '-html-safe': _emberGlimmerHelpersHtmlSafe.default, + '-get-dynamic-var': _glimmerRuntime.getDynamicVar }; } - RootState.prototype.isFor = function isFor(possibleRoot) { - return this.root === possibleRoot; + Environment.prototype.macros = function macros() { + var macros = _GlimmerEnvironment.prototype.macros.call(this); + _emberGlimmerSyntax.populateMacros(macros.blocks, macros.inlines); + return macros; }; - RootState.prototype.destroy = function destroy() { - var result = this.result; - var env = this.env; - - this.destroyed = true; - - this.env = null; - this.root = null; - this.result = null; - this.render = null; - - if (result) { - /* - Handles these scenarios: - * When roots are removed during standard rendering process, a transaction exists already - `.begin()` / `.commit()` are not needed. - * When roots are being destroyed manually (`component.append(); component.destroy() case), no - transaction exists already. - * When roots are being destroyed during `Renderer#destroy`, no transaction exists - */ - var needsTransaction = !env.inTransaction; - - if (needsTransaction) { - env.begin(); - } - - result.destroy(); - - if (needsTransaction) { - env.commit(); - } - } + Environment.prototype.hasComponentDefinition = function hasComponentDefinition() { + return false; }; - return RootState; - })(); - - var renderers = []; - - _emberMetal.setHasViews(function () { - return renderers.length > 0; - }); - - function register(renderer) { - renderers.push(renderer); - } - - function deregister(renderer) { - var index = renderers.indexOf(renderer); - - renderers.splice(index, 1); - } - - function loopBegin() { - for (var i = 0; i < renderers.length; i++) { - renderers[i]._scheduleRevalidate(); - } - } - - function K() {} - - var loops = 0; - function loopEnd(current, next) { - for (var i = 0; i < renderers.length; i++) { - if (!renderers[i]._isValid()) { - if (loops > 10) { - loops = 0; - // TODO: do something better - renderers[i].destroy(); - throw new Error('infinite rendering invalidation detected'); - } - loops++; - return backburner.join(null, K); - } - } - loops = 0; - } - - backburner.on('begin', loopBegin); - backburner.on('end', loopEnd); - - var Renderer = (function () { - function Renderer(env, rootTemplate) { - var _viewRegistry = arguments.length <= 2 || arguments[2] === undefined ? _emberViews.fallbackViewRegistry : arguments[2]; - - var destinedForDOM = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; - - this._env = env; - this._rootTemplate = rootTemplate; - this._viewRegistry = _viewRegistry; - this._destinedForDOM = destinedForDOM; - this._destroyed = false; - this._roots = []; - this._lastRevision = null; - this._isRenderingRoots = false; - this._removedRoots = []; - } - - // renderer HOOKS - - Renderer.prototype.appendOutletView = function appendOutletView(view, target) { - var definition = new _emberGlimmerSyntaxOutlet.TopLevelOutletComponentDefinition(view); - var outletStateReference = view.toReference(); - var targetObject = view.outletState.render.controller; + Environment.prototype.getComponentDefinition = function getComponentDefinition(path, symbolTable) { + var name = path[0]; + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var source = blockMeta.moduleName && 'template:' + blockMeta.moduleName; - this._appendDefinition(view, definition, target, outletStateReference, targetObject); + return this._definitionCache.get({ name: name, source: source, owner: owner }); }; - Renderer.prototype.appendTo = function appendTo(view, target) { - var rootDef = new _emberGlimmerSyntaxCurlyComponent.RootComponentDefinition(view); + // normally templates should be exported at the proper module name + // and cached in the container, but this cache supports templates + // that have been set directly on the component's layout property - this._appendDefinition(view, rootDef, target); + Environment.prototype.getTemplate = function getTemplate(Template, owner) { + return this._templateCache.get({ Template: Template, owner: owner }); }; - Renderer.prototype._appendDefinition = function _appendDefinition(root, definition, target) { - var outletStateReference = arguments.length <= 3 || arguments[3] === undefined ? _glimmerReference.UNDEFINED_REFERENCE : arguments[3]; - var targetObject = arguments.length <= 4 || arguments[4] === undefined ? null : arguments[4]; - - var self = new _emberGlimmerUtilsReferences.RootReference(definition); - var dynamicScope = new DynamicScope(null, outletStateReference, outletStateReference, true, targetObject); - var rootState = new RootState(root, this._env, this._rootTemplate, self, target, dynamicScope); - - this._renderRoot(rootState); - }; + // a Compiler can wrap the template so it needs its own cache - Renderer.prototype.rerender = function rerender(view) { - this._scheduleRevalidate(); + Environment.prototype.getCompiledBlock = function getCompiledBlock(Compiler, template) { + var compilerCache = this._compilerCache.get(Compiler); + return compilerCache.get(template); }; - Renderer.prototype.register = function register(view) { - var id = _emberViews.getViewId(view); + Environment.prototype.hasPartial = function hasPartial(name, symbolTable) { + var _symbolTable$getMeta = symbolTable.getMeta(); - this._viewRegistry[id] = view; - }; + var owner = _symbolTable$getMeta.owner; - Renderer.prototype.unregister = function unregister(view) { - delete this._viewRegistry[_emberViews.getViewId(view)]; + return _emberViews.hasPartial(name, owner); }; - Renderer.prototype.remove = function remove(view) { - view._transitionTo('destroying'); - - this.cleanupRootFor(view); + Environment.prototype.lookupPartial = function lookupPartial(name, symbolTable) { + var _symbolTable$getMeta2 = symbolTable.getMeta(); - _emberViews.setViewElement(view, null); + var owner = _symbolTable$getMeta2.owner; - if (this._destinedForDOM) { - view.trigger('didDestroyElement'); - } + var partial = { + template: _emberViews.lookupPartial(name, owner) + }; - if (!view.isDestroying) { - view.destroy(); + if (partial.template) { + return partial; + } else { + throw new Error(name + ' is not a partial'); } }; - Renderer.prototype.cleanupRootFor = function cleanupRootFor(view) { - // no need to cleanup roots if we have already been destroyed - if (this._destroyed) { - return; - } - - var roots = this._roots; - - // traverse in reverse so we can remove items - // without mucking up the index - var i = this._roots.length; - while (i--) { - var root = roots[i]; - if (root.isFor(view)) { - root.destroy(); - } - } - }; + Environment.prototype.hasHelper = function hasHelper(nameParts, symbolTable) { - Renderer.prototype.destroy = function destroy() { - if (this._destroyed) { - return; + // helpers are not allowed to include a dot in their invocation + if (nameParts.length > 1) { + return false; } - this._destroyed = true; - this._clearAllRoots(); - }; - - Renderer.prototype.getElement = function getElement(view) { - // overriden in the subclasses - }; - Renderer.prototype.getBounds = function getBounds(view) { - var bounds = view[_emberGlimmerComponent.BOUNDS]; + var name = nameParts[0]; - var parentElement = bounds.parentElement(); - var firstNode = bounds.firstNode(); - var lastNode = bounds.lastNode(); + if (this.builtInHelpers[name]) { + return true; + } - return { parentElement: parentElement, firstNode: firstNode, lastNode: lastNode }; - }; + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var options = { source: 'template:' + blockMeta.moduleName }; - Renderer.prototype.createElement = function createElement(tagName) { - return this._env.getAppendOperations().createElement(tagName); + return owner.hasRegistration('helper:' + name, options) || owner.hasRegistration('helper:' + name); }; - Renderer.prototype._renderRoot = function _renderRoot(root) { - var roots = this._roots; + Environment.prototype.lookupHelper = function lookupHelper(nameParts, symbolTable) { - roots.push(root); + var name = nameParts[0]; + var helper = this.builtInHelpers[name]; - if (roots.length === 1) { - register(this); + if (helper) { + return helper; } - this._renderRootsTransaction(); - }; - - Renderer.prototype._renderRoots = function _renderRoots() { - var roots = this._roots; - var env = this._env; - var removedRoots = this._removedRoots; - - var globalShouldReflush = undefined, - initialRootsLength = undefined; - - do { - env.begin(); - - // ensure that for the first iteration of the loop - // each root is processed - initialRootsLength = roots.length; - globalShouldReflush = false; - - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; + var blockMeta = symbolTable.getMeta(); + var owner = blockMeta.owner; + var options = blockMeta.moduleName && { source: 'template:' + blockMeta.moduleName } || {}; - if (root.destroyed) { - // add to the list of roots to be removed - // they will be removed from `this._roots` later - removedRoots.push(root); + if (true) { + var _ret = (function () { + var helperFactory = owner[_container.FACTORY_FOR]('helper:' + name, options) || owner[_container.FACTORY_FOR]('helper:' + name); - // skip over roots that have been marked as destroyed - continue; + // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations + if (helperFactory.class.isHelperInstance) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helperFactory.class.compute, args); + } + }; + } else if (helperFactory.class.isHelperFactory) { + if (!_emberMetal.isFeatureEnabled('ember-no-double-extend')) { + helperFactory = helperFactory.create(); + } + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helperFactory, vm, args); + } + }; + } else { + throw new Error(nameParts + ' is not a helper'); } + })(); - var shouldReflush = root.shouldReflush; + if (typeof _ret === 'object') return _ret.v; + } else { + var _ret2 = (function () { + var helperFactory = owner.lookup('helper:' + name, options) || owner.lookup('helper:' + name); - // when processing non-initial reflush loops, - // do not process more roots than needed - if (i >= initialRootsLength && !shouldReflush) { - continue; + // TODO: try to unify this into a consistent protocol to avoid wasteful closure allocations + if (helperFactory.isHelperInstance) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.SimpleHelperReference.create(helperFactory.compute, args); + } + }; + } else if (helperFactory.isHelperFactory) { + return { + v: function (vm, args) { + return _emberGlimmerUtilsReferences.ClassBasedHelperReference.create(helperFactory, vm, args); + } + }; + } else { + throw new Error(nameParts + ' is not a helper'); } + })(); - root.options.alwaysRevalidate = shouldReflush; - // track shouldReflush based on this roots render result - shouldReflush = root.shouldReflush = runInTransaction(root, 'render'); - - // globalShouldReflush should be `true` if *any* of - // the roots need to reflush - globalShouldReflush = globalShouldReflush || shouldReflush; - } - - this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - - env.commit(); - } while (globalShouldReflush || roots.length > initialRootsLength); - - // remove any roots that were destroyed during this transaction - while (removedRoots.length) { - var root = removedRoots.pop(); - - var rootIndex = roots.indexOf(root); - roots.splice(rootIndex, 1); - } - - if (this._roots.length === 0) { - deregister(this); + if (typeof _ret2 === 'object') return _ret2.v; } }; - Renderer.prototype._renderRootsTransaction = function _renderRootsTransaction() { - if (this._isRenderingRoots) { - // currently rendering roots, a new root was added and will - // be processed by the existing _renderRoots invocation - return; - } - - // used to prevent calling _renderRoots again (see above) - // while we are actively rendering roots - this._isRenderingRoots = true; + Environment.prototype.hasModifier = function hasModifier(nameParts) { - var completedWithoutError = false; - try { - this._renderRoots(); - completedWithoutError = true; - } finally { - if (!completedWithoutError) { - this._lastRevision = _glimmerReference.CURRENT_TAG.value(); - } - this._isRenderingRoots = false; + // modifiers are not allowed to include a dot in their invocation + if (nameParts.length > 1) { + return false; } + + return !!this.builtInModifiers[nameParts[0]]; }; - Renderer.prototype._clearAllRoots = function _clearAllRoots() { - var roots = this._roots; - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; - root.destroy(); - } + Environment.prototype.lookupModifier = function lookupModifier(nameParts) { - this._removedRoots.length = 0; - this._roots = null; + var modifier = this.builtInModifiers[nameParts[0]]; - // if roots were present before destroying - // deregister this renderer instance - if (roots.length) { - deregister(this); + if (modifier) { + return modifier; + } else { + throw new Error(nameParts + ' is not a modifier'); } }; - Renderer.prototype._scheduleRevalidate = function _scheduleRevalidate() { - backburner.scheduleOnce('render', this, this._revalidate); + Environment.prototype.toConditionalReference = function toConditionalReference(reference) { + return _emberGlimmerUtilsReferences.ConditionalReference.create(reference); }; - Renderer.prototype._isValid = function _isValid() { - return this._destroyed || this._roots.length === 0 || _glimmerReference.CURRENT_TAG.validate(this._lastRevision); + Environment.prototype.iterableFor = function iterableFor(ref, args) { + var keyPath = args.named.get('key').value(); + return _emberGlimmerUtilsIterable.default(ref, keyPath); }; - Renderer.prototype._revalidate = function _revalidate() { - if (this._isValid()) { - return; + Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier() { + if (this.isInteractive) { + var _GlimmerEnvironment$prototype$scheduleInstallModifier; + + (_GlimmerEnvironment$prototype$scheduleInstallModifier = _GlimmerEnvironment.prototype.scheduleInstallModifier).call.apply(_GlimmerEnvironment$prototype$scheduleInstallModifier, [this].concat(babelHelpers.slice.call(arguments))); } - this._renderRootsTransaction(); }; - return Renderer; - })(); - - var InertRenderer = (function (_Renderer) { - babelHelpers.inherits(InertRenderer, _Renderer); - - function InertRenderer() { - _Renderer.apply(this, arguments); - } - - InertRenderer.create = function create(_ref) { - var env = _ref.env; - var rootTemplate = _ref.rootTemplate; - var _viewRegistry = _ref._viewRegistry; + Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier() { + if (this.isInteractive) { + var _GlimmerEnvironment$prototype$scheduleUpdateModifier; - return new this(env, rootTemplate, _viewRegistry, false); + (_GlimmerEnvironment$prototype$scheduleUpdateModifier = _GlimmerEnvironment.prototype.scheduleUpdateModifier).call.apply(_GlimmerEnvironment$prototype$scheduleUpdateModifier, [this].concat(babelHelpers.slice.call(arguments))); + } }; - InertRenderer.prototype.getElement = function getElement(view) { - throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); + Environment.prototype.didDestroy = function didDestroy(destroyable) { + destroyable.destroy(); }; - return InertRenderer; - })(Renderer); + Environment.prototype.begin = function begin() { + this.inTransaction = true; - exports.InertRenderer = InertRenderer; + _GlimmerEnvironment.prototype.begin.call(this); - var InteractiveRenderer = (function (_Renderer2) { - babelHelpers.inherits(InteractiveRenderer, _Renderer2); + this.destroyedComponents = []; + }; - function InteractiveRenderer() { - _Renderer2.apply(this, arguments); - } + Environment.prototype.commit = function commit() { + // components queued for destruction must be destroyed before firing + // `didCreate` to prevent errors when removing and adding a component + // with the same name (would throw an error when added to view registry) + for (var i = 0; i < this.destroyedComponents.length; i++) { + this.destroyedComponents[i].destroy(); + } - InteractiveRenderer.create = function create(_ref2) { - var env = _ref2.env; - var rootTemplate = _ref2.rootTemplate; - var _viewRegistry = _ref2._viewRegistry; + _GlimmerEnvironment.prototype.commit.call(this); - return new this(env, rootTemplate, _viewRegistry, true); + this.inTransaction = false; }; - InteractiveRenderer.prototype.getElement = function getElement(view) { - return _emberViews.getViewElement(view); - }; - - return InteractiveRenderer; - })(Renderer); + return Environment; + })(_glimmerRuntime.Environment); - exports.InteractiveRenderer = InteractiveRenderer; + exports.default = Environment; }); -enifed('ember-glimmer/setup-registry', ['exports', 'ember-environment', 'container', 'ember-glimmer/renderer', 'ember-glimmer/dom', 'ember-glimmer/views/outlet', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/templates/component', 'ember-glimmer/templates/root', 'ember-glimmer/templates/outlet', 'ember-glimmer/environment'], function (exports, _emberEnvironment, _container, _emberGlimmerRenderer, _emberGlimmerDom, _emberGlimmerViewsOutlet, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerTemplatesComponent, _emberGlimmerTemplatesRoot, _emberGlimmerTemplatesOutlet, _emberGlimmerEnvironment) { - 'use strict'; - - exports.setupApplicationRegistry = setupApplicationRegistry; - exports.setupEngineRegistry = setupEngineRegistry; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:-root'], ['template:-root']), - _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']), - _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - - function setupApplicationRegistry(registry) { - registry.injection('service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); - registry.injection('renderer', 'env', 'service:-glimmer-environment'); - - registry.register(_container.privatize(_templateObject), _emberGlimmerTemplatesRoot.default); - registry.injection('renderer', 'rootTemplate', _container.privatize(_templateObject)); - - registry.register('renderer:-dom', _emberGlimmerRenderer.InteractiveRenderer); - registry.register('renderer:-inert', _emberGlimmerRenderer.InertRenderer); - - if (_emberEnvironment.environment.hasDOM) { - registry.injection('service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); - } +enifed('ember-glimmer/helper', ['exports', 'ember-utils', 'ember-runtime', '@glimmer/reference'], function (exports, _emberUtils, _emberRuntime, _glimmerReference) { + /** + @module ember + @submodule ember-glimmer + */ - registry.register('service:-dom-changes', { - create: function (_ref) { - var document = _ref.document; - return new _emberGlimmerDom.DOMChanges(document); - } - }); + 'use strict'; - registry.register('service:-dom-tree-construction', { - create: function (_ref2) { - var document = _ref2.document; + exports.helper = helper; + var RECOMPUTE_TAG = _emberUtils.symbol('RECOMPUTE_TAG'); - var Implementation = _emberEnvironment.environment.hasDOM ? _emberGlimmerDom.DOMTreeConstruction : _emberGlimmerDom.NodeDOMTreeConstruction; - return new Implementation(document); + exports.RECOMPUTE_TAG = RECOMPUTE_TAG; + /** + Ember Helpers are functions that can compute values, and are used in templates. + For example, this code calls a helper named `format-currency`: + + ```handlebars +
    {{format-currency cents currency="$"}}
    + ``` + + Additionally a helper can be called as a nested helper (sometimes called a + subexpression). In this example, the computed value of a helper is passed + to a component named `show-money`: + + ```handlebars + {{show-money amount=(format-currency cents currency="$")}} + ``` + + Helpers defined using a class must provide a `compute` function. For example: + + ```js + export default Ember.Helper.extend({ + compute(params, hash) { + let cents = params[0]; + let currency = hash.currency; + return `${currency}${cents * 0.01}`; } }); - } - - function setupEngineRegistry(registry) { - registry.register('view:-outlet', _emberGlimmerViewsOutlet.default); - registry.register('template:-outlet', _emberGlimmerTemplatesOutlet.default); - registry.injection('view:-outlet', 'template', 'template:-outlet'); - - registry.injection('service:-dom-changes', 'document', 'service:-document'); - registry.injection('service:-dom-tree-construction', 'document', 'service:-document'); - - registry.register(_container.privatize(_templateObject2), _emberGlimmerTemplatesComponent.default); - - registry.register('service:-glimmer-environment', _emberGlimmerEnvironment.default); - registry.injection('template', 'env', 'service:-glimmer-environment'); - - registry.optionsForType('helper', { instantiate: false }); - - registry.register('component:-text-field', _emberGlimmerComponentsText_field.default); - registry.register('component:-text-area', _emberGlimmerComponentsText_area.default); - registry.register('component:-checkbox', _emberGlimmerComponentsCheckbox.default); - registry.register('component:link-to', _emberGlimmerComponentsLinkTo.default); - registry.register(_container.privatize(_templateObject3), _emberGlimmerComponent.default); - } -}); -enifed('ember-glimmer/syntax', ['exports', 'ember-glimmer/syntax/render', 'ember-glimmer/syntax/outlet', 'ember-glimmer/syntax/mount', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/syntax/input', 'glimmer-runtime'], function (exports, _emberGlimmerSyntaxRender, _emberGlimmerSyntaxOutlet, _emberGlimmerSyntaxMount, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerSyntaxInput, _glimmerRuntime) { - 'use strict'; - - exports.registerSyntax = registerSyntax; - exports.findSyntaxBuilder = findSyntaxBuilder; - - var syntaxKeys = []; - var syntaxes = []; - - function registerSyntax(key, syntax) { - syntaxKeys.push(key); - syntaxes.push(syntax); - } + ``` + + Each time the input to a helper changes, the `compute` function will be + called again. + + As instances, these helpers also have access to the container an will accept + injected dependencies. + + Additionally, class helpers can call `recompute` to force a new computation. + + @class Ember.Helper + @public + @since 1.13.0 + */ + var Helper = _emberRuntime.FrameworkObject.extend({ + isHelperInstance: true, - function findSyntaxBuilder(key) { - var index = syntaxKeys.indexOf(key); + init: function () { + this._super.apply(this, arguments); + this[RECOMPUTE_TAG] = new _glimmerReference.DirtyableTag(); + }, - if (index > -1) { - return syntaxes[index]; + /** + On a class-based helper, it may be useful to force a recomputation of that + helpers value. This is akin to `rerender` on a component. + For example, this component will rerender when the `currentUser` on a + session service changes: + ```js + // app/helpers/current-user-email.js + export default Ember.Helper.extend({ + session: Ember.inject.service(), + onNewUser: Ember.observer('session.currentUser', function() { + this.recompute(); + }), + compute() { + return this.get('session.currentUser.email'); + } + }); + ``` + @method recompute + @public + @since 1.13.0 + */ + recompute: function () { + this[RECOMPUTE_TAG].dirty(); } - } - - registerSyntax('render', _emberGlimmerSyntaxRender.RenderSyntax); - registerSyntax('outlet', _emberGlimmerSyntaxOutlet.OutletSyntax); - registerSyntax('mount', _emberGlimmerSyntaxMount.MountSyntax); - registerSyntax('component', _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax); - registerSyntax('input', _emberGlimmerSyntaxInput.InputSyntax); - registerSyntax('-with-dynamic-vars', (function () { - function _class() {} - - _class.create = function create(environment, args, symbolTable) { - return new _glimmerRuntime.WithDynamicVarsSyntax(args); - }; + /** + Override this function when writing a class-based helper. + @method compute + @param {Array} params The positional arguments to the helper + @param {Object} hash The named arguments to the helper + @public + @since 1.13.0 + */ + }); - return _class; - })()); + Helper.reopenClass({ + isHelperFactory: true + }); - registerSyntax('-in-element', (function () { - function _class2() {} + /** + In many cases, the ceremony of a full `Ember.Helper` class is not required. + The `helper` method create pure-function helpers without instances. For + example: + + ```js + // app/helpers/format-currency.js + export default Ember.Helper.helper(function(params, hash) { + let cents = params[0]; + let currency = hash.currency; + return `${currency}${cents * 0.01}`; + }); + ``` + + @static + @param {Function} helper The helper function + @method helper + @public + @since 1.13.0 + */ - _class2.create = function create(environment, args, symbolTable) { - return new _glimmerRuntime.InElementSyntax(args); + function helper(helperFn) { + return { + isHelperInstance: true, + compute: helperFn }; + } - return _class2; - })()); + exports.default = Helper; }); -enifed('ember-glimmer/syntax/curly-component', ['exports', 'ember-utils', 'glimmer-runtime', 'ember-glimmer/utils/bindings', 'ember-glimmer/component', 'ember-metal', 'ember-views', 'ember-glimmer/utils/process-args', 'container'], function (exports, _emberUtils, _glimmerRuntime, _emberGlimmerUtilsBindings, _emberGlimmerComponent, _emberMetal, _emberViews, _emberGlimmerUtilsProcessArgs, _container) { +enifed('ember-glimmer/helpers/-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { 'use strict'; - exports.validatePositionalParameters = validatePositionalParameters; - - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); - - var DEFAULT_LAYOUT = _container.privatize(_templateObject); - - function processComponentInitializationAssertions(component, props) {} - - function validatePositionalParameters(named, positional, positionalParamsDefinition) {} - - function aliasIdToElementId(args, props) { - if (args.named.has('id')) { - props.elementId = props.id; - } - } - - // We must traverse the attributeBindings in reverse keeping track of - // what has already been applied. This is essentially refining the concated - // properties applying right to left. - function applyAttributeBindings(element, attributeBindings, component, operations) { - var seen = []; - var i = attributeBindings.length - 1; + function classHelper(_ref) { + var positional = _ref.positional; - while (i !== -1) { - var binding = attributeBindings[i]; - var parsed = _emberGlimmerUtilsBindings.AttributeBinding.parse(binding); - var attribute = parsed[1]; + var path = positional.at(0); + var args = positional.length; + var value = path.value(); - if (seen.indexOf(attribute) === -1) { - seen.push(attribute); - _emberGlimmerUtilsBindings.AttributeBinding.install(element, component, parsed, operations); + if (value === true) { + if (args > 1) { + return _emberRuntime.String.dasherize(positional.at(1).value()); } - - i--; + return null; } - if (seen.indexOf('id') === -1) { - operations.addStaticAttribute(element, 'id', component.elementId); + if (value === false) { + if (args > 2) { + return _emberRuntime.String.dasherize(positional.at(2).value()); + } + return null; } - if (seen.indexOf('style') === -1) { - _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); - } + return value; } - var CurlyComponentSyntax = (function (_StatementSyntax) { -babelHelpers.inherits(CurlyComponentSyntax, _StatementSyntax); - - function CurlyComponentSyntax(args, definition, symbolTable) { - _StatementSyntax.call(this); - this.args = args; - this.definition = definition; - this.symbolTable = symbolTable; - this.shadow = null; - } + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(classHelper, args); + }; +}); +enifed('ember-glimmer/helpers/-html-safe', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/utils/string'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerUtilsString) { + 'use strict'; - CurlyComponentSyntax.prototype.compile = function compile(builder) { - builder.component.static(this.definition, this.args, this.symbolTable, this.shadow); - }; + function htmlSafe(_ref) { + var positional = _ref.positional; - return CurlyComponentSyntax; - })(_glimmerRuntime.StatementSyntax); + var path = positional.at(0); + return new _emberGlimmerUtilsString.SafeString(path.value()); + } - exports.CurlyComponentSyntax = CurlyComponentSyntax; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(htmlSafe, args); + }; +}); +enifed('ember-glimmer/helpers/-input-type', ['exports', 'ember-glimmer/utils/references'], function (exports, _emberGlimmerUtilsReferences) { + 'use strict'; - function NOOP() {} + function inputTypeHelper(_ref) { + var positional = _ref.positional; + var named = _ref.named; - var ComponentStateBucket = (function () { - function ComponentStateBucket(environment, component, args, finalizer) { - this.environment = environment; - this.component = component; - this.classRef = null; - this.args = args; - this.argsRevision = args.tag.value(); - this.finalizer = finalizer; + var type = positional.at(0).value(); + if (type === 'checkbox') { + return '-checkbox'; } - - ComponentStateBucket.prototype.destroy = function destroy() { - var component = this.component; - var environment = this.environment; - - if (environment.isInteractive) { - component.trigger('willDestroyElement'); - component.trigger('willClearRender'); - } - - environment.destroyedComponents.push(component); - }; - - ComponentStateBucket.prototype.finalize = function finalize() { - var finalizer = this.finalizer; - - finalizer(); - this.finalizer = NOOP; - }; - - return ComponentStateBucket; - })(); - - function initialRenderInstrumentDetails(component) { - return component.instrumentDetails({ initialRender: true }); - } - - function rerenderInstrumentDetails(component) { - return component.instrumentDetails({ initialRender: false }); + return '-text-field'; } - var CurlyComponentManager = (function () { - function CurlyComponentManager() {} - - CurlyComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { - validatePositionalParameters(args.named, args.positional.values, definition.ComponentClass.positionalParams); - - return _emberGlimmerUtilsProcessArgs.gatherArgs(args, definition); - }; - - CurlyComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, callerSelfRef, hasBlock) { - var parentView = dynamicScope.view; - - var klass = definition.ComponentClass; - var processedArgs = _emberGlimmerUtilsProcessArgs.ComponentArgs.create(args); - - var _processedArgs$value = processedArgs.value(); - - var props = _processedArgs$value.props; - - aliasIdToElementId(args, props); - - props.parentView = parentView; - props[_emberGlimmerComponent.HAS_BLOCK] = hasBlock; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(inputTypeHelper, args); + }; +}); +enifed('ember-glimmer/helpers/-normalize-class', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { + 'use strict'; - props._targetObject = callerSelfRef.value(); + function normalizeClass(_ref) { + var positional = _ref.positional; + var named = _ref.named; - var component = klass.create(props); + var classNameParts = positional.at(0).value().split('.'); + var className = classNameParts[classNameParts.length - 1]; + var value = positional.at(1).value(); - var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); + if (value === true) { + return _emberRuntime.String.dasherize(className); + } else if (!value && value !== 0) { + return ''; + } else { + return String(value); + } + } - dynamicScope.view = component; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(normalizeClass, args); + }; +}); +enifed('ember-glimmer/helpers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/runtime', '@glimmer/reference'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _glimmerRuntime, _glimmerReference) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - if (parentView !== null) { - parentView.appendChild(component); - } + var INVOKE = _emberUtils.symbol('INVOKE'); + exports.INVOKE = INVOKE; + var ACTION = _emberUtils.symbol('ACTION'); - // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components - if (component.tagName === '') { - if (environment.isInteractive) { - component.trigger('willRender'); + exports.ACTION = ACTION; + /** + The `{{action}}` helper provides a way to pass triggers for behavior (usually + just a function) between components, and into components from controllers. + + ### Passing functions with the action helper + + There are three contexts an action helper can be used in. The first two + contexts to discuss are attribute context, and Handlebars value context. + + ```handlebars + {{! An example of attribute context }} +
    + {{! Examples of Handlebars value context }} + {{input on-input=(action "save")}} + {{yield (action "refreshData") andAnotherParam}} + ``` + + In these contexts, + the helper is called a "closure action" helper. Its behavior is simple: + If passed a function name, read that function off the `actions` property + of the current context. Once that function is read (or if a function was + passed), create a closure over that function and any arguments. + The resulting value of an action helper used this way is simply a function. + + For example, in the attribute context: + + ```handlebars + {{! An example of attribute context }} +
    + ``` + + The resulting template render logic would be: + + ```js + var div = document.createElement('div'); + var actionFunction = (function(context){ + return function() { + return context.actions.save.apply(context, arguments); + }; + })(context); + div.onclick = actionFunction; + ``` + + Thus when the div is clicked, the action on that context is called. + Because the `actionFunction` is just a function, closure actions can be + passed between components and still execute in the correct context. + + Here is an example action handler on a component: + + ```js + import Ember from 'ember'; + + export default Ember.Component.extend({ + actions: { + save() { + this.get('model').save(); } - - component._transitionTo('hasElement'); - - if (environment.isInteractive) { - component.trigger('willInsertElement'); + } + }); + ``` + + Actions are always looked up on the `actions` property of the current context. + This avoids collisions in the naming of common actions, such as `destroy`. + Two options can be passed to the `action` helper when it is used in this way. + + * `target=someProperty` will look to `someProperty` instead of the current + context for the `actions` hash. This can be useful when targetting a + service for actions. + * `value="target.value"` will read the path `target.value` off the first + argument to the action when it is called and rewrite the first argument + to be that value. This is useful when attaching actions to event listeners. + + ### Invoking an action + + Closure actions curry both their scope and any arguments. When invoked, any + additional arguments are added to the already curried list. + Actions should be invoked using the [sendAction](/api/classes/Ember.Component.html#method_sendAction) + method. The first argument to `sendAction` is the action to be called, and + additional arguments are passed to the action function. This has interesting + properties combined with currying of arguments. For example: + + ```js + export default Ember.Component.extend({ + actions: { + // Usage {{input on-input=(action (action 'setName' model) value="target.value")}} + setName(model, name) { + model.set('name', name); } } - - var bucket = new ComponentStateBucket(environment, component, processedArgs, finalizer); - - if (args.named.has('class')) { - bucket.classRef = args.named.get('class'); + }); + ``` + + The first argument (`model`) was curried over, and the run-time argument (`event`) + becomes a second argument. Action calls can be nested this way because each simply + returns a function. Any function can be passed to the `{{action}}` helper, including + other actions. + + Actions invoked with `sendAction` have the same currying behavior as demonstrated + with `on-input` above. For example: + + ```app/components/my-input.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + actions: { + setName(model, name) { + model.set('name', name); + } } - - processComponentInitializationAssertions(component, props); - - if (environment.isInteractive && component.tagName !== '') { - component.trigger('willRender'); + }); + ``` + + ```handlebars + {{my-input submit=(action 'setName' model)}} + ``` + + ```app/components/my-component.js + import Ember from 'ember'; + + export default Ember.Component.extend({ + click() { + // Note that model is not passed, it was curried in the template + this.sendAction('submit', 'bob'); } + }); + ``` + + ### Attaching actions to DOM elements + + The third context of the `{{action}}` helper can be called "element space". + For example: + + ```handlebars + {{! An example of element space }} +
    + ``` + + Used this way, the `{{action}}` helper provides a useful shortcut for + registering an HTML element in a template for a single DOM event and + forwarding that interaction to the template's context (controller or component). + If the context of a template is a controller, actions used this way will + bubble to routes when the controller does not implement the specified action. + Once an action hits a route, it will bubble through the route hierarchy. + + ### Event Propagation + + `{{action}}` helpers called in element space can control event bubbling. Note + that the closure style actions cannot. + + Events triggered through the action helper will automatically have + `.preventDefault()` called on them. You do not need to do so in your event + handlers. If you need to allow event propagation (to handle file inputs for + example) you can supply the `preventDefault=false` option to the `{{action}}` helper: + + ```handlebars +
    + + +
    + ``` + + To disable bubbling, pass `bubbles=false` to the helper: + + ```handlebars + + ``` + + To disable bubbling with closure style actions you must create your own + wrapper helper that makes use of `event.stopPropagation()`: + + ```handlebars +
    Hello
    + ``` + + ```app/helpers/disable-bubbling.js + import Ember from 'ember'; + + export function disableBubbling([action]) { + return function(event) { + event.stopPropagation(); + return action(event); + }; + } + export default Ember.Helper.helper(disableBubbling); + ``` + + If you need the default handler to trigger you should either register your + own event handler, or use event methods on your view class. See + ["Responding to Browser Events"](/api/classes/Ember.View.html#toc_responding-to-browser-events) + in the documentation for Ember.View for more information. + + ### Specifying DOM event type + + `{{action}}` helpers called in element space can specify an event type. + By default the `{{action}}` helper registers for DOM `click` events. You can + supply an `on` option to the helper to specify a different DOM event name: + + ```handlebars +
    + click me +
    + ``` + + See ["Event Names"](/api/classes/Ember.View.html#toc_event-names) for a list of + acceptable DOM event names. + + ### Specifying whitelisted modifier keys + + `{{action}}` helpers called in element space can specify modifier keys. + By default the `{{action}}` helper will ignore click events with pressed modifier + keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. + + ```handlebars +
    + click me +
    + ``` + + This way the action will fire when clicking with the alt key pressed down. + Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. + + ```handlebars +
    + click me with any key pressed +
    + ``` + + ### Specifying a Target + + A `target` option can be provided to the helper to change + which object will receive the method call. This option must be a path + to an object, accessible in the current context: + + ```app/templates/application.hbs +
    + click me +
    + ``` + + ```app/controllers/application.js + import Ember from 'ember'; + + export default Ember.Controller.extend({ + someService: Ember.inject.service() + }); + ``` + + @method action + @for Ember.Templates.helpers + @public + */ - return bucket; - }; - - CurlyComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - var template = definition.template; - if (!template) { - var component = bucket.component; - - template = this.templateFor(component, env); - } - return env.getCompiledBlock(CurlyComponentLayoutCompiler, template); - }; - - CurlyComponentManager.prototype.templateFor = function templateFor(component, env) { - var Template = _emberMetal.get(component, 'layout'); - var owner = component[_emberUtils.OWNER]; - if (Template) { - return env.getTemplate(Template, owner); - } - var layoutName = _emberMetal.get(component, 'layoutName'); - if (layoutName) { - var template = owner.lookup('template:' + layoutName); - if (template) { - return template; - } - } - return owner.lookup(DEFAULT_LAYOUT); - }; - - CurlyComponentManager.prototype.getSelf = function getSelf(_ref) { - var component = _ref.component; - - return component[_emberGlimmerComponent.ROOT_REF]; - }; + exports.default = function (vm, args) { + var named = args.named; + var positional = args.positional; - CurlyComponentManager.prototype.didCreateElement = function didCreateElement(_ref2, element, operations) { - var component = _ref2.component; - var classRef = _ref2.classRef; - var environment = _ref2.environment; + // The first two argument slots are reserved. + // pos[0] is the context (or `this`) + // pos[1] is the action name or function + // Anything else is an action argument. + var context = positional.at(0); + var action = positional.at(1); - _emberViews.setViewElement(component, element); + // TODO: Is there a better way of doing this? + var debugKey = action._propertyKey; - var attributeBindings = component.attributeBindings; - var classNames = component.classNames; - var classNameBindings = component.classNameBindings; + var restArgs = undefined; - if (attributeBindings && attributeBindings.length) { - applyAttributeBindings(element, attributeBindings, component, operations); - } else { - operations.addStaticAttribute(element, 'id', component.elementId); - _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); - } + if (positional.length === 2) { + restArgs = _glimmerRuntime.EvaluatedPositionalArgs.empty(); + } else { + restArgs = _glimmerRuntime.EvaluatedPositionalArgs.create(positional.values.slice(2)); + } - if (classRef) { - operations.addDynamicAttribute(element, 'class', classRef); - } + var target = named.has('target') ? named.get('target') : context; + var processArgs = makeArgsProcessor(named.has('value') && named.get('value'), restArgs); - if (classNames && classNames.length) { - classNames.forEach(function (name) { - operations.addStaticAttribute(element, 'class', name); - }); - } + var fn = undefined; - if (classNameBindings && classNameBindings.length) { - classNameBindings.forEach(function (binding) { - _emberGlimmerUtilsBindings.ClassNameBinding.install(element, component, binding, operations); - }); - } + if (typeof action[INVOKE] === 'function') { + fn = makeClosureAction(action, action, action[INVOKE], processArgs, debugKey); + } else if (_glimmerReference.isConst(target) && _glimmerReference.isConst(action)) { + fn = makeClosureAction(context.value(), target.value(), action.value(), processArgs, debugKey); + } else { + fn = makeDynamicClosureAction(context.value(), target, action, processArgs, debugKey); + } - component._transitionTo('hasElement'); + fn[ACTION] = true; - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } - }; + return new _emberGlimmerUtilsReferences.UnboundReference(fn); + }; - CurlyComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket, bounds) { - bucket.component[_emberGlimmerComponent.BOUNDS] = bounds; - bucket.finalize(); - }; + function NOOP(args) { + return args; + } - CurlyComponentManager.prototype.getTag = function getTag(_ref3) { - var component = _ref3.component; + function makeArgsProcessor(valuePathRef, actionArgsRef) { + var mergeArgs = null; - return component[_emberGlimmerComponent.DIRTY_TAG]; - }; + if (actionArgsRef.length > 0) { + mergeArgs = function (args) { + return actionArgsRef.value().concat(args); + }; + } - CurlyComponentManager.prototype.didCreate = function didCreate(_ref4) { - var component = _ref4.component; - var environment = _ref4.environment; + var readValue = null; - if (environment.isInteractive) { - component._transitionTo('inDOM'); - component.trigger('didInsertElement'); - component.trigger('didRender'); - } - }; + if (valuePathRef) { + readValue = function (args) { + var valuePath = valuePathRef.value(); - CurlyComponentManager.prototype.update = function update(bucket, _, dynamicScope) { - var component = bucket.component; - var args = bucket.args; - var argsRevision = bucket.argsRevision; - var environment = bucket.environment; + if (valuePath && args.length > 0) { + args[0] = _emberMetal.get(args[0], valuePath); + } - bucket.finalizer = _emberMetal._instrumentStart('render.component', rerenderInstrumentDetails, component); + return args; + }; + } - if (!args.tag.validate(argsRevision)) { - var _args$value = args.value(); + if (mergeArgs && readValue) { + return function (args) { + return readValue(mergeArgs(args)); + }; + } else { + return mergeArgs || readValue || NOOP; + } + } - var attrs = _args$value.attrs; - var props = _args$value.props; + function makeDynamicClosureAction(context, targetRef, actionRef, processArgs, debugKey) { - bucket.argsRevision = args.tag.value(); + return function () { + return makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey).apply(undefined, arguments); + }; - var oldAttrs = component.attrs; - var newAttrs = attrs; + // We don't allow undefined/null values, so this creates a throw-away action to trigger the assertions + } - component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = true; - component.setProperties(props); - component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = false; + function makeClosureAction(context, target, action, processArgs, debugKey) { + var self = undefined, + fn = undefined; - component.trigger('didUpdateAttrs', { oldAttrs: oldAttrs, newAttrs: newAttrs }); - component.trigger('didReceiveAttrs', { oldAttrs: oldAttrs, newAttrs: newAttrs }); - } + if (typeof action[INVOKE] === 'function') { + self = action; + fn = action[INVOKE]; + } else { + var typeofAction = typeof action; + + if (typeofAction === 'string') { + self = target; + fn = target.actions && target.actions[action]; + } else if (typeofAction === 'function') { + self = context; + fn = action; + } else {} + } - if (environment.isInteractive) { - component.trigger('willUpdate'); - component.trigger('willRender'); + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - }; - CurlyComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) { - bucket.finalize(); + var payload = { target: self, args: args, label: '@glimmer/closure-action' }; + return _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + return _emberMetal.run.join.apply(_emberMetal.run, [self, fn].concat(processArgs(args))); + }); }; + } +}); +enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/curly-component', '@glimmer/runtime', 'ember-metal'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxCurlyComponent, _glimmerRuntime, _emberMetal) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - CurlyComponentManager.prototype.didUpdate = function didUpdate(_ref5) { - var component = _ref5.component; - var environment = _ref5.environment; + /** + The `{{component}}` helper lets you add instances of `Ember.Component` to a + template. See [Ember.Component](/api/classes/Ember.Component.html) for + additional information on how a `Component` functions. + `{{component}}`'s primary use is for cases where you want to dynamically + change which type of component is rendered as the state of your application + changes. This helper has three modes: inline, block, and nested. + + ### Inline Form + + Given the following template: + + ```app/application.hbs + {{component infographicComponentName}} + ``` + + And the following application code: + + ```app/controllers/application.js + export default Ember.Controller.extend({ + infographicComponentName: computed('isMarketOpen', { + get() { + if (this.get('isMarketOpen')) { + return 'live-updating-chart'; + } else { + return 'market-close-summary'; + } + } + }) + }); + ``` + + The `live-updating-chart` component will be appended when `isMarketOpen` is + `true`, and the `market-close-summary` component will be appended when + `isMarketOpen` is `false`. If the value changes while the app is running, + the component will be automatically swapped out accordingly. + Note: You should not use this helper when you are consistently rendering the same + component. In that case, use standard component syntax, for example: + + ```app/templates/application.hbs + {{live-updating-chart}} + ``` + + ### Block Form + + Using the block form of this helper is similar to using the block form + of a component. Given the following application template: + + ```app/templates/application.hbs + {{#component infographicComponentName}} + Last update: {{lastUpdateTimestamp}} + {{/component}} + ``` + + The following controller code: + + ```app/controllers/application.js + export default Ember.Controller.extend({ + lastUpdateTimestamp: computed(function() { + return new Date(); + }), + + infographicComponentName: computed('isMarketOpen', { + get() { + if (this.get('isMarketOpen')) { + return 'live-updating-chart'; + } else { + return 'market-close-summary'; + } + } + }) + }); + ``` + + And the following component template: + + ```app/templates/components/live-updating-chart.hbs + {{! chart }} + {{yield}} + ``` + + The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. + + ### Nested Usage + + The `component` helper can be used to package a component path with initial attrs. + The included attrs can then be merged during the final invocation. + For example, given a `person-form` component with the following template: + + ```app/templates/components/person-form.hbs + {{yield (hash + nameInput=(component "my-input-component" value=model.name placeholder="First Name") + )}} + ``` + + When yielding the component via the `hash` helper, the component is invocked directly. + See the following snippet: + + ``` + {{#person-form as |form|}} + {{form.nameInput placeholder="Username"}} + {{/person-form}} + ``` + + Which outputs an input whose value is already bound to `model.name` and `placeholder` + is "Username". + + When yielding the component without the hash helper use the `component` helper. + For example, below is a `full-name` component template: + + ```handlebars + {{yield (component "my-input-component" value=model.name placeholder="Name")}} + ``` + + ``` + {{#full-name as |field|}} + {{component field placeholder="Full name"}} + {{/full-name}} + ``` + + @method component + @since 1.11.0 + @for Ember.Templates.helpers + @public + */ - if (environment.isInteractive) { - component.trigger('didUpdate'); - component.trigger('didRender'); - } - }; + var ClosureComponentReference = (function (_CachedReference) { + babelHelpers.inherits(ClosureComponentReference, _CachedReference); - CurlyComponentManager.prototype.getDestructor = function getDestructor(stateBucket) { - return stateBucket; + ClosureComponentReference.create = function create(args, symbolTable, env) { + return new ClosureComponentReference(args, symbolTable, env); }; - return CurlyComponentManager; - })(); - - var MANAGER = new CurlyComponentManager(); - - var TopComponentManager = (function (_CurlyComponentManager) { -babelHelpers.inherits(TopComponentManager, _CurlyComponentManager); - - function TopComponentManager() { - _CurlyComponentManager.apply(this, arguments); + function ClosureComponentReference(args, symbolTable, env) { + _CachedReference.call(this); + this.defRef = args.positional.at(0); + this.env = env; + this.tag = args.positional.at(0).tag; + this.symbolTable = symbolTable; + this.args = args; + this.lastDefinition = undefined; + this.lastName = undefined; } - TopComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, currentScope, hasBlock) { - var component = definition.ComponentClass; - - var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); + ClosureComponentReference.prototype.compute = function compute() { + // TODO: Figure out how to extract this because it's nearly identical to + // DynamicComponentReference::compute(). The only differences besides + // currying are in the assertion messages. + var args = this.args; + var defRef = this.defRef; + var env = this.env; + var symbolTable = this.symbolTable; + var lastDefinition = this.lastDefinition; + var lastName = this.lastName; - dynamicScope.view = component; + var nameOrDef = defRef.value(); + var definition = null; - // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components - if (component.tagName === '') { - if (environment.isInteractive) { - component.trigger('willRender'); - } + if (nameOrDef && nameOrDef === lastName) { + return lastDefinition; + } - component._transitionTo('hasElement'); + this.lastName = nameOrDef; - if (environment.isInteractive) { - component.trigger('willInsertElement'); - } + if (typeof nameOrDef === 'string') { + definition = env.getComponentDefinition([nameOrDef], symbolTable); + } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { + definition = nameOrDef; + } else { + return null; } - processComponentInitializationAssertions(component, {}); + var newDef = createCurriedDefinition(definition, args); - return new ComponentStateBucket(environment, component, args, finalizer); + this.lastDefinition = newDef; + + return newDef; }; - return TopComponentManager; - })(CurlyComponentManager); + return ClosureComponentReference; + })(_emberGlimmerUtilsReferences.CachedReference); - var ROOT_MANAGER = new TopComponentManager(); + exports.ClosureComponentReference = ClosureComponentReference; - function tagName(vm) { - var tagName = vm.dynamicScope().view.tagName; + function createCurriedDefinition(definition, args) { + var curriedArgs = curryArgs(definition, args); - return _glimmerRuntime.PrimitiveReference.create(tagName === '' ? null : tagName || 'div'); + return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentDefinition(definition.name, definition.ComponentClass, definition.template, curriedArgs); } - function ariaRole(vm) { - return vm.getSelf().get('ariaRole'); - } + var EMPTY_BLOCKS = { + default: null, + inverse: null + }; - var CurlyComponentDefinition = (function (_ComponentDefinition) { -babelHelpers.inherits(CurlyComponentDefinition, _ComponentDefinition); + function curryArgs(definition, newArgs) { + var args = definition.args; + var ComponentClass = definition.ComponentClass; - function CurlyComponentDefinition(name, ComponentClass, template, args) { - _ComponentDefinition.call(this, name, MANAGER, ComponentClass); - this.template = template; - this.args = args; - } + var positionalParams = ComponentClass.class.positionalParams; - return CurlyComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); + // The args being passed in are from the (component ...) invocation, + // so the first positional argument is actually the name or component + // definition. It needs to be dropped in order for any actual positional + // args to coincide with the ComponentClass's positionParams. - exports.CurlyComponentDefinition = CurlyComponentDefinition; + // For "normal" curly components this slicing is done at the syntax layer, + // but we don't have that luxury here. - var RootComponentDefinition = (function (_ComponentDefinition2) { -babelHelpers.inherits(RootComponentDefinition, _ComponentDefinition2); + var _newArgs$positional$values = newArgs.positional.values; - function RootComponentDefinition(instance) { - _ComponentDefinition2.call(this, '-root', ROOT_MANAGER, instance); - this.template = undefined; - this.args = undefined; - } + var slicedPositionalArgs = _newArgs$positional$values.slice(1); - return RootComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); + if (positionalParams && slicedPositionalArgs.length) { + _emberGlimmerSyntaxCurlyComponent.validatePositionalParameters(newArgs.named, slicedPositionalArgs, positionalParams); + } - exports.RootComponentDefinition = RootComponentDefinition; + var isRest = typeof positionalParams === 'string'; - var CurlyComponentLayoutCompiler = (function () { - function CurlyComponentLayoutCompiler(template) { - this.template = template; - } - - CurlyComponentLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - builder.tag.dynamic(tagName); - builder.attrs.dynamic('role', ariaRole); - builder.attrs.static('class', 'ember-view'); - }; - - return CurlyComponentLayoutCompiler; - })(); - - CurlyComponentLayoutCompiler.id = 'curly'; -}); -enifed('ember-glimmer/syntax/dynamic-component', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal) { - 'use strict'; - - function dynamicComponentFor(vm, symbolTable) { - var env = vm.env; - var args = vm.getArgs(); - var nameRef = args.positional.at(0); - - return new DynamicComponentReference({ nameRef: nameRef, env: env, symbolTable: symbolTable }); - } - - var DynamicComponentSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(DynamicComponentSyntax, _StatementSyntax); - - // for {{component componentName}} - - DynamicComponentSyntax.create = function create(environment, args, symbolTable) { - var definitionArgs = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1)); - var invocationArgs = _glimmerRuntime.ArgsSyntax.build(args.positional.slice(1), args.named, args.blocks); - - return new this(definitionArgs, invocationArgs, symbolTable); - }; - - // Transforms {{foo.bar with=args}} or {{#foo.bar with=args}}{{/foo.bar}} - // into {{component foo.bar with=args}} or - // {{#component foo.bar with=args}}{{/component}} - // with all of it's arguments + // For non-rest position params, we need to perform the position -> name mapping + // at each layer to avoid a collision later when the args are used to construct + // the component instance (inside of processArgs(), inside of create()). + var positionalToNamedParams = {}; - DynamicComponentSyntax.fromPath = function fromPath(environment, path, args, symbolTable) { - var positional = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(_glimmerRuntime.PositionalArgsSyntax.build([_glimmerRuntime.GetSyntax.build(path.join('.'))])); + if (!isRest && positionalParams && positionalParams.length > 0) { + var limit = Math.min(positionalParams.length, slicedPositionalArgs.length); - return new this(positional, args, symbolTable); - }; + for (var i = 0; i < limit; i++) { + var _name = positionalParams[i]; + positionalToNamedParams[_name] = slicedPositionalArgs[i]; + } - function DynamicComponentSyntax(definitionArgs, args, symbolTable) { - _StatementSyntax.call(this); - this.definition = dynamicComponentFor; - this.definitionArgs = definitionArgs; - this.args = args; - this.symbolTable = symbolTable; - this.shadow = null; + slicedPositionalArgs.length = 0; // Throw them away since you're merged in. } - DynamicComponentSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return DynamicComponentSyntax; - })(_glimmerRuntime.StatementSyntax); + // args (aka 'oldArgs') may be undefined or simply be empty args, so + // we need to fall back to an empty array or object. + var oldNamed = args && args.named && args.named.map || {}; + var oldPositional = args && args.positional && args.positional.values || []; - exports.DynamicComponentSyntax = DynamicComponentSyntax; + // Merge positional arrays + var mergedPositional = new Array(Math.max(oldPositional.length, slicedPositionalArgs.length)); + mergedPositional.splice.apply(mergedPositional, [0, oldPositional.length].concat(oldPositional)); + mergedPositional.splice.apply(mergedPositional, [0, slicedPositionalArgs.length].concat(slicedPositionalArgs)); - var DynamicComponentReference = (function () { - function DynamicComponentReference(_ref) { - var nameRef = _ref.nameRef; - var env = _ref.env; - var symbolTable = _ref.symbolTable; - var args = _ref.args; + // Merge named maps + var mergedNamed = _emberUtils.assign({}, oldNamed, positionalToNamedParams, newArgs.named.map); - this.tag = nameRef.tag; - this.nameRef = nameRef; - this.env = env; - this.symbolTable = symbolTable; - this.args = args; - } + var mergedArgs = _glimmerRuntime.EvaluatedArgs.create(_glimmerRuntime.EvaluatedPositionalArgs.create(mergedPositional), _glimmerRuntime.EvaluatedNamedArgs.create(mergedNamed), EMPTY_BLOCKS); - DynamicComponentReference.prototype.value = function value() { - var env = this.env; - var nameRef = this.nameRef; - var symbolTable = this.symbolTable; + return mergedArgs; + } - var nameOrDef = nameRef.value(); + exports.default = function (vm, args, symbolTable) { + return ClosureComponentReference.create(args, symbolTable, vm.env); + }; +}); +enifed('ember-glimmer/helpers/concat', ['exports', 'ember-glimmer/utils/references', '@glimmer/runtime'], function (exports, _emberGlimmerUtilsReferences, _glimmerRuntime) { + 'use strict'; - if (typeof nameOrDef === 'string') { - var definition = env.getComponentDefinition([nameOrDef], symbolTable); + /** + @module ember + @submodule ember-glimmer + */ - return definition; - } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { - return nameOrDef; - } else { - return null; - } - }; + /** + Concatenates the given arguments into a string. + + Example: + + ```handlebars + {{some-component name=(concat firstName " " lastName)}} + + {{! would pass name=" " to the component}} + ``` + + @public + @method concat + @for Ember.Templates.helpers + @since 1.13.0 + */ + function concat(_ref) { + var positional = _ref.positional; - DynamicComponentReference.prototype.get = function get() { - return _glimmerReference.UNDEFINED_REFERENCE; - }; + return positional.value().map(_glimmerRuntime.normalizeTextValue).join(''); + } - return DynamicComponentReference; - })(); + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(concat, args); + }; }); -enifed('ember-glimmer/syntax/input', ['exports', 'ember-metal', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/bindings'], function (exports, _emberMetal, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsBindings) { +enifed('ember-glimmer/helpers/each-in', ['exports', 'ember-utils'], function (exports, _emberUtils) { /** @module ember @submodule ember-glimmer */ 'use strict'; - function buildTextFieldSyntax(args, getDefinition, symbolTable) { - var definition = getDefinition('-text-field'); - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } + exports.isEachIn = isEachIn; /** - The `{{input}}` helper lets you create an HTML `` component. - It causes an `Ember.TextField` component to be rendered. For more info, - see the [Ember.TextField](/api/classes/Ember.TextField.html) docs and - the [templates guide](http://emberjs.com/guides/templates/input-helpers/). + The `{{#each}}` helper loops over elements in a collection. It is an extension + of the base Handlebars `{{#each}}` helper. + The default behavior of `{{#each}}` is to yield its inner block once for every + item in an array passing the item as the first block parameter. + + ```javascript + var developers = [{ name: 'Yehuda' },{ name: 'Tom' }, { name: 'Paul' }]; + ``` ```handlebars - {{input value="987"}} + {{#each developers key="name" as |person|}} + {{person.name}} + {{! `this` is whatever it was outside the #each }} + {{/each}} ``` - renders as: + The same rules apply to arrays of primitives. - ```HTML - + ```javascript + var developerNames = ['Yehuda', 'Tom', 'Paul'] ``` - ### Text field + ```handlebars + {{#each developerNames key="@index" as |name|}} + {{name}} + {{/each}} + ``` - If no `type` option is specified, a default of type 'text' is used. - Many of the standard HTML attributes may be passed to this helper. - - - - - - - - - - - -
    `readonly``required``autofocus`
    `value``placeholder``disabled`
    `size``tabindex``maxlength`
    `name``min``max`
    `pattern``accept``autocomplete`
    `autosave``formaction``formenctype`
    `formmethod``formnovalidate``formtarget`
    `height``inputmode``multiple`
    `step``width``form`
    `selectionDirection``spellcheck` 
    - When set to a quoted string, these values will be directly applied to the HTML - element. When left unquoted, these values will be bound to a property on the - template's current rendering context (most typically a controller instance). - A very common use of this helper is to bind the `value` of an input to an Object's attribute: + During iteration, the index of each item in the array is provided as a second block parameter. ```handlebars - Search: - {{input value=searchWord}} +
      + {{#each people as |person index|}} +
    • Hello, {{person.name}}! You're number {{index}} in line
    • + {{/each}} +
    ``` - In this example, the inital value in the `` will be set to the value of `searchWord`. - If the user changes the text, the value of `searchWord` will also be updated. + ### Specifying Keys - ### Actions + The `key` option is used to tell Ember how to determine if the array being + iterated over with `{{#each}}` has changed between renders. By helping Ember + detect that some elements in the array are the same, DOM elements can be + re-used, significantly improving rendering speed. - The helper can send multiple actions based on user events. - The action property defines the action which is sent when - the user presses the return key. + For example, here's the `{{#each}}` helper with its `key` set to `id`: ```handlebars - {{input action="submit"}} + {{#each model key="id" as |item|}} + {{/each}} ``` - The helper allows some user events to send actions. + When this `{{#each}}` re-renders, Ember will match up the previously rendered + items (and reorder the generated DOM elements) based on each item's `id` + property. + By default the item's own reference is used. - * `enter` - * `insert-newline` - * `escape-press` - * `focus-in` - * `focus-out` - * `key-press` - * `key-up` + ### {{else}} condition - For example, if you desire an action to be sent when the input is blurred, - you only need to setup the action name to the event name property. + `{{#each}}` can have a matching `{{else}}`. The contents of this block will render + if the collection is empty. ```handlebars - {{input focus-out="alertMessage"}} + {{#each developers as |person|}} + {{person.name}} + {{else}} +

    Sorry, nobody is available for this task.

    + {{/each}} ``` - See more about [Text Support Actions](/api/classes/Ember.TextField.html) - ### Extending `Ember.TextField` + @method each + @for Ember.Templates.helpers + @public + */ + + /** + The `{{each-in}}` helper loops over properties on an object. - Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing - arguments from the helper to `Ember.TextField`'s `create` method. You can extend the - capabilities of text inputs in your applications by reopening this class. For example, - if you are building a Bootstrap project where `data-*` attributes are used, you - can add one to the `TextField`'s `attributeBindings` property: + For example, given a `user` object that looks like: ```javascript - Ember.TextField.reopen({ - attributeBindings: ['data-error'] - }); + { + "name": "Shelly Sails", + "age": 42 + } ``` - Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` - itself extends `Ember.Component`. Expect isolated component semantics, not - legacy 1.x view semantics (like `controller` being present). - See more about [Ember components](/api/classes/Ember.Component.html) - - ### Checkbox - - Checkboxes are special forms of the `{{input}}` helper. To create a ``: + This template would display all properties on the `user` + object in a list: ```handlebars - Emberize Everything: - {{input type="checkbox" name="isEmberized" checked=isEmberized}} +
      + {{#each-in user as |key value|}} +
    • {{key}}: {{value}}
    • + {{/each-in}} +
    ``` - This will bind checked state of this checkbox to the value of `isEmberized` -- if either one changes, - it will be reflected in the other. - - The following HTML attributes can be set via the helper: - - * `checked` - * `disabled` - * `tabindex` - * `indeterminate` - * `name` - * `autofocus` - * `form` - - ### Extending `Ember.Checkbox` - - Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing - arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the - capablilties of checkbox inputs in your applications by reopening this class. For example, - if you wanted to add a css class to all checkboxes in your application: - - ```javascript - Ember.Checkbox.reopen({ - classNames: ['my-app-checkbox'] - }); - ``` + Outputting their name and age. - @method input + @method each-in @for Ember.Templates.helpers - @param {Hash} options @public + @since 2.1.0 */ - var InputSyntax = { - create: function (environment, args, symbolTable) { - var getDefinition = function (path) { - return environment.getComponentDefinition([path], symbolTable); - }; - - if (args.named.has('type')) { - var typeArg = args.named.at('type'); - if (typeArg.type === 'value') { - if (typeArg.value === 'checkbox') { + var EACH_IN_REFERENCE = _emberUtils.symbol('EACH_IN'); - _emberGlimmerUtilsBindings.wrapComponentClassAttribute(args); - var definition = getDefinition('-checkbox'); - return new _emberGlimmerSyntaxCurlyComponent.CurlyComponentSyntax(args, definition, symbolTable); - } else { - return buildTextFieldSyntax(args, getDefinition, symbolTable); - } - } - } else { - return buildTextFieldSyntax(args, getDefinition, symbolTable); - } + function isEachIn(ref) { + return ref && ref[EACH_IN_REFERENCE]; + } - return _emberGlimmerSyntaxDynamicComponent.DynamicComponentSyntax.create(environment, args, symbolTable); - } + exports.default = function (vm, args) { + var ref = Object.create(args.positional.at(0)); + ref[EACH_IN_REFERENCE] = true; + return ref; }; - exports.InputSyntax = InputSyntax; }); -enifed('ember-glimmer/syntax/mount', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet) { +enifed('ember-glimmer/helpers/get', ['exports', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { + 'use strict'; + /** @module ember @submodule ember-glimmer */ - 'use strict'; /** - The `{{mount}}` helper lets you embed a routeless engine in a template. - Mounting an engine will cause an instance to be booted and its `application` - template to be rendered. + Dynamically look up a property on an object. The second argument to `{{get}}` + should have a string value, although it can be bound. - For example, the following template mounts the `ember-chat` engine: + For example, these two usages are equivilent: ```handlebars - {{! application.hbs }} - {{mount "ember-chat"}} + {{person.height}} + {{get person "height"}} ``` - Currently, the engine name is the only argument that can be passed to - `{{mount}}`. + If there were several facts about a person, the `{{get}}` helper can dynamically + pick one: + + ```handlebars + {{get person factName}} + ``` + + For a more complex example, this template would allow the user to switch + between showing the user's height and weight with a click: + + ```handlebars + {{get person factName}} + + + ``` + + The `{{get}}` helper can also respect mutable values itself. For example: + + ```handlebars + {{input value=(mut (get person factName)) type="text"}} + + + ``` + + Would allow the user to swap what fact is being displayed, and also edit + that fact via a two-way mutable binding. - @method mount - @for Ember.Templates.helpers - @category ember-application-engines @public - */ - - var MountSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(MountSyntax, _StatementSyntax); - - MountSyntax.create = function create(env, args, symbolTable) { - - var name = args.positional.at(0).inner(); - - var definition = new MountDefinition(name, env); - - return new MountSyntax(definition, symbolTable); - }; - - function MountSyntax(definition, symbolTable) { - _StatementSyntax.call(this); - this.definition = definition; - this.symbolTable = symbolTable; - } - - MountSyntax.prototype.compile = function compile(builder) { - builder.component.static(this.definition, _glimmerRuntime.ArgsSyntax.empty(), null, this.symbolTable, null); - }; - - return MountSyntax; - })(_glimmerRuntime.StatementSyntax); + @method get + @for Ember.Templates.helpers + @since 2.1.0 + */ - exports.MountSyntax = MountSyntax; + exports.default = function (vm, args) { + return GetHelperReference.create(args.positional.at(0), args.positional.at(1)); + }; - var MountManager = (function () { - function MountManager() {} + var GetHelperReference = (function (_CachedReference) { + babelHelpers.inherits(GetHelperReference, _CachedReference); - MountManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; + GetHelperReference.create = function create(sourceReference, pathReference) { + if (_glimmerReference.isConst(pathReference)) { + var parts = pathReference.value().split('.'); + return _glimmerReference.referenceFromParts(sourceReference, parts); + } else { + return new GetHelperReference(sourceReference, pathReference); + } }; - MountManager.prototype.create = function create(environment, _ref, args, dynamicScope) { - var name = _ref.name; - var env = _ref.env; + function GetHelperReference(sourceReference, pathReference) { + _CachedReference.call(this); + this.sourceReference = sourceReference; + this.pathReference = pathReference; - dynamicScope.outletState = _glimmerReference.UNDEFINED_REFERENCE; + this.lastPath = null; + this.innerReference = null; - var engine = env.owner.buildChildEngineInstance(name); + var innerTag = this.innerTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - engine.boot(); + this.tag = _glimmerReference.combine([sourceReference.tag, pathReference.tag, innerTag]); + } - return { engine: engine }; - }; + GetHelperReference.prototype.compute = function compute() { + var lastPath = this.lastPath; + var innerReference = this.innerReference; + var innerTag = this.innerTag; - MountManager.prototype.layoutFor = function layoutFor(definition, _ref2, env) { - var engine = _ref2.engine; + var path = this.lastPath = this.pathReference.value(); - var template = engine.lookup('template:application'); - return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, template); - }; + if (path !== lastPath) { + if (path) { + var pathType = typeof path; - MountManager.prototype.getSelf = function getSelf(_ref3) { - var engine = _ref3.engine; + if (pathType === 'string') { + innerReference = this.innerReference = _glimmerReference.referenceFromParts(this.sourceReference, path.split('.')); + } else if (pathType === 'number') { + innerReference = this.innerReference = this.sourceReference.get(path); + } - var factory = engine._lookupFactory('controller:application') || _emberRouting.generateControllerFactory(engine, 'application'); - return new _emberGlimmerUtilsReferences.RootReference(factory.create()); - }; + innerTag.update(innerReference.tag); + } else { + innerReference = this.innerReference = null; + innerTag.update(_glimmerReference.CONSTANT_TAG); + } + } - MountManager.prototype.getTag = function getTag() { - return null; + return innerReference ? innerReference.value() : null; }; - MountManager.prototype.getDestructor = function getDestructor(_ref4) { - var engine = _ref4.engine; - - return engine; + GetHelperReference.prototype[_emberGlimmerUtilsReferences.UPDATE] = function (value) { + _emberMetal.set(this.sourceReference.value(), this.pathReference.value(), value); }; - MountManager.prototype.didCreateElement = function didCreateElement() {}; - - MountManager.prototype.didRenderLayout = function didRenderLayout() {}; - - MountManager.prototype.didCreate = function didCreate(state) {}; - - MountManager.prototype.update = function update(state, args, dynamicScope) {}; - - MountManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - - MountManager.prototype.didUpdate = function didUpdate(state) {}; - - return MountManager; - })(); - - var MOUNT_MANAGER = new MountManager(); + return GetHelperReference; + })(_emberGlimmerUtilsReferences.CachedReference); +}); +enifed("ember-glimmer/helpers/hash", ["exports"], function (exports) { + /** + @module ember + @submodule ember-glimmer + */ - var MountDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(MountDefinition, _ComponentDefinition); + /** + Use the `{{hash}}` helper to create a hash to pass as an option to your + components. This is specially useful for contextual components where you can + just yield a hash: + + ```handlebars + {{yield (hash + name='Sarah' + title=office + )}} + ``` + + Would result in an object such as: + + ```js + { name: 'Sarah', title: this.get('office') } + ``` + + Where the `title` is bound to updates of the `office` property. + + @method hash + @for Ember.Templates.helpers + @param {Object} options + @return {Object} Hash + @since 2.3.0 + @public + */ - function MountDefinition(name, env) { - _ComponentDefinition.call(this, name, MOUNT_MANAGER, null); - this.env = env; - } + "use strict"; - return MountDefinition; - })(_glimmerRuntime.ComponentDefinition); + exports.default = function (vm, args) { + return args.named; + }; }); -enifed('ember-glimmer/syntax/outlet', ['exports', 'ember-utils', 'glimmer-runtime', 'ember-metal', 'ember-glimmer/utils/references', 'glimmer-reference'], function (exports, _emberUtils, _glimmerRuntime, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { +enifed('ember-glimmer/helpers/if-unless', ['exports', 'ember-metal', 'ember-glimmer/utils/references', '@glimmer/reference'], function (exports, _emberMetal, _emberGlimmerUtilsReferences, _glimmerReference) { /** @module ember @submodule ember-glimmer */ - 'use strict'; - - function outletComponentFor(vm) { - var _vm$dynamicScope = vm.dynamicScope(); - - var outletState = _vm$dynamicScope.outletState; - var args = vm.getArgs(); - var outletNameRef = undefined; - if (args.positional.length === 0) { - outletNameRef = new _glimmerReference.ConstReference('main'); - } else { - outletNameRef = args.positional.at(0); - } + 'use strict'; - return new OutletComponentReference(outletNameRef, outletState); - } + exports.inlineIf = inlineIf; + exports.inlineUnless = inlineUnless; /** - The `{{outlet}}` helper lets you specify where a child route will render in - your template. An important use of the `{{outlet}}` helper is in your - application's `application.hbs` file: + Use the `if` block helper to conditionally render a block depending on a + property. If the property is "falsey", for example: `false`, `undefined`, + `null`, `""`, `0`, `NaN` or an empty array, the block will not be rendered. ```handlebars - {{! app/templates/application.hbs }} - - {{my-header}} -
    - - {{outlet}} -
    - - {{my-footer}} + {{! will not render if foo is falsey}} + {{#if foo}} + Welcome to the {{foo.bar}} + {{/if}} ``` - See [templates guide](http://emberjs.com/guides/templates/the-application-template/) for - additional information on using `{{outlet}}` in `application.hbs`. - You may also specify a name for the `{{outlet}}`, which is useful when using more than one - `{{outlet}}` in a template: + You can also specify a template to show if the property is falsey by using + the `else` helper. ```handlebars - {{outlet "menu"}} - {{outlet "sidebar"}} - {{outlet "main"}} + {{! is it raining outside?}} + {{#if isRaining}} + Yes, grab an umbrella! + {{else}} + No, it's lovely outside! + {{/if}} ``` - Your routes can then render into a specific one of these `outlet`s by specifying the `outlet` - attribute in your `renderTemplate` function: + You are also able to combine `else` and `if` helpers to create more complex + conditional logic. - ```javascript - // app/routes/menu.js - export default Ember.Route.extend({ - renderTemplate() { - this.render({ outlet: 'menu' }); - } - }); + ```handlebars + {{#if isMorning}} + Good morning + {{else if isAfternoon}} + Good afternoon + {{else}} + Good night + {{/if}} ``` - See the [routing guide](http://emberjs.com/guides/routing/rendering-a-template/) for more - information on how your `route` interacts with the `{{outlet}}` helper. - Note: Your content __will not render__ if there isn't an `{{outlet}}` for it. + You can use `if` inline to conditionally render a single property or string. + This helper acts like a ternary operator. If the first property is truthy, + the second argument will be displayed, if not, the third argument will be + displayed - @method outlet - @param {String} [name] + ```handlebars + {{if useLongGreeting "Hello" "Hi"}} Dave + ``` + + Finally, you can use the `if` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(if isBig "100" "10")}} + ``` + + @method if @for Ember.Templates.helpers @public */ - var OutletSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(OutletSyntax, _StatementSyntax); - - OutletSyntax.create = function create(environment, args, symbolTable) { - var definitionArgs = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1)); - return new this(environment, definitionArgs, symbolTable); - }; - - function OutletSyntax(environment, args, symbolTable) { - _StatementSyntax.call(this); - this.definitionArgs = args; - this.definition = outletComponentFor; - this.args = _glimmerRuntime.ArgsSyntax.empty(); - this.symbolTable = symbolTable; - this.shadow = null; - } - - OutletSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return OutletSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.OutletSyntax = OutletSyntax; - - var OutletComponentReference = (function () { - function OutletComponentReference(outletNameRef, parentOutletStateRef) { - this.outletNameRef = outletNameRef; - this.parentOutletStateRef = parentOutletStateRef; - this.definition = null; - this.lastState = null; - var outletStateTag = this.outletStateTag = new _glimmerReference.UpdatableTag(parentOutletStateRef.tag); - this.tag = _glimmerReference.combine([outletStateTag.tag, outletNameRef.tag]); - } - - OutletComponentReference.prototype.value = function value() { - var outletNameRef = this.outletNameRef; - var parentOutletStateRef = this.parentOutletStateRef; - var definition = this.definition; - var lastState = this.lastState; - - var outletName = outletNameRef.value(); - var outletStateRef = parentOutletStateRef.get('outlets').get(outletName); - var newState = this.lastState = outletStateRef.value(); - - this.outletStateTag.update(outletStateRef.tag); - - definition = revalidate(definition, lastState, newState); + var ConditionalHelperReference = (function (_CachedReference) { + babelHelpers.inherits(ConditionalHelperReference, _CachedReference); - var hasTemplate = newState && newState.render.template; + ConditionalHelperReference.create = function create(_condRef, _truthyRef, _falsyRef) { + var condRef = _emberGlimmerUtilsReferences.ConditionalReference.create(_condRef); + var truthyRef = _truthyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; + var falsyRef = _falsyRef || _emberGlimmerUtilsReferences.UNDEFINED_REFERENCE; - if (definition) { - return definition; - } else if (hasTemplate) { - return this.definition = new OutletComponentDefinition(outletName, newState.render.template); + if (_glimmerReference.isConst(condRef)) { + return condRef.value() ? truthyRef : falsyRef; } else { - return this.definition = null; + return new ConditionalHelperReference(condRef, truthyRef, falsyRef); } }; - return OutletComponentReference; - })(); - - function revalidate(definition, lastState, newState) { - if (!lastState && !newState) { - return definition; - } - - if (!lastState && newState || lastState && !newState) { - return null; - } - - if (newState.render.template === lastState.render.template && newState.render.controller === lastState.render.controller) { - return definition; - } - - return null; - } - - function instrumentationPayload(_ref) { - var _ref$render = _ref.render; - var name = _ref$render.name; - var outlet = _ref$render.outlet; - - return { object: name + ':' + outlet }; - } + function ConditionalHelperReference(cond, truthy, falsy) { + _CachedReference.call(this); - function NOOP() {} + this.branchTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + this.tag = _glimmerReference.combine([cond.tag, this.branchTag]); - var StateBucket = (function () { - function StateBucket(outletState) { - this.outletState = outletState; - this.instrument(); + this.cond = cond; + this.truthy = truthy; + this.falsy = falsy; } - StateBucket.prototype.instrument = function instrument() { - this.finalizer = _emberMetal._instrumentStart('render.outlet', instrumentationPayload, this.outletState); - }; - - StateBucket.prototype.finalize = function finalize() { - var finalizer = this.finalizer; - - finalizer(); - this.finalizer = NOOP; - }; - - return StateBucket; - })(); - - var OutletComponentManager = (function () { - function OutletComponentManager() {} - - OutletComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - OutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var outletStateReference = dynamicScope.outletState = dynamicScope.outletState.get('outlets').get(definition.outletName); - var outletState = outletStateReference.value(); - return new StateBucket(outletState); - }; - - OutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(OutletLayoutCompiler, definition.template); - }; - - OutletComponentManager.prototype.getSelf = function getSelf(_ref2) { - var outletState = _ref2.outletState; - - return new _emberGlimmerUtilsReferences.RootReference(outletState.render.controller); - }; - - OutletComponentManager.prototype.getTag = function getTag() { - return null; - }; - - OutletComponentManager.prototype.getDestructor = function getDestructor() { - return null; - }; - - OutletComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket) { - bucket.finalize(); - }; - - OutletComponentManager.prototype.didCreateElement = function didCreateElement() {}; - - OutletComponentManager.prototype.didCreate = function didCreate(state) {}; - - OutletComponentManager.prototype.update = function update(bucket) {}; - - OutletComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) {}; - - OutletComponentManager.prototype.didUpdate = function didUpdate(state) {}; - - return OutletComponentManager; - })(); - - var MANAGER = new OutletComponentManager(); + /** + The inline `if` helper conditionally renders a single property or string. + This helper acts like a ternary operator. If the first property is truthy, + the second argument will be displayed, otherwise, the third argument will be + displayed + + ```handlebars + {{if useLongGreeting "Hello" "Hi"}} Alex + ``` + + You can use the `if` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(if isBig "100" "10")}} + ``` + + @method if + @for Ember.Templates.helpers + @public + */ - var TopLevelOutletComponentManager = (function (_OutletComponentManager) { - babelHelpers.inherits(TopLevelOutletComponentManager, _OutletComponentManager); + ConditionalHelperReference.prototype.compute = function compute() { + var cond = this.cond; + var truthy = this.truthy; + var falsy = this.falsy; - function TopLevelOutletComponentManager() { - _OutletComponentManager.apply(this, arguments); - } + var branch = cond.value() ? truthy : falsy; - TopLevelOutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - return new StateBucket(dynamicScope.outletState.value()); - }; + this.branchTag.update(branch.tag); - TopLevelOutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(TopLevelOutletLayoutCompiler, definition.template); + return branch.value(); }; - return TopLevelOutletComponentManager; - })(OutletComponentManager); - - var TOP_LEVEL_MANAGER = new TopLevelOutletComponentManager(); - - var TopLevelOutletComponentDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(TopLevelOutletComponentDefinition, _ComponentDefinition); - - function TopLevelOutletComponentDefinition(instance) { - _ComponentDefinition.call(this, 'outlet', TOP_LEVEL_MANAGER, instance); - this.template = instance.template; - _emberUtils.generateGuid(this); - } - - return TopLevelOutletComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); + return ConditionalHelperReference; + })(_emberGlimmerUtilsReferences.CachedReference); - exports.TopLevelOutletComponentDefinition = TopLevelOutletComponentDefinition; + function inlineIf(vm, _ref) { + var positional = _ref.positional; - var TopLevelOutletLayoutCompiler = (function () { - function TopLevelOutletLayoutCompiler(template) { - this.template = template; + switch (positional.length) { + case 2: + return ConditionalHelperReference.create(positional.at(0), positional.at(1), null); + case 3: + return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); + default: } + } - TopLevelOutletLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - builder.tag.static('div'); - builder.attrs.static('id', _emberUtils.guidFor(this)); - builder.attrs.static('class', 'ember-view'); - }; - - return TopLevelOutletLayoutCompiler; - })(); - - TopLevelOutletLayoutCompiler.id = 'top-level-outlet'; - - var OutletComponentDefinition = (function (_ComponentDefinition2) { - babelHelpers.inherits(OutletComponentDefinition, _ComponentDefinition2); - - function OutletComponentDefinition(outletName, template) { - _ComponentDefinition2.call(this, 'outlet', MANAGER, null); - this.outletName = outletName; - this.template = template; - _emberUtils.generateGuid(this); - } + /** + The inline `unless` helper conditionally renders a single property or string. + This helper acts like a ternary operator. If the first property is falsy, + the second argument will be displayed, otherwise, the third argument will be + displayed + + ```handlebars + {{unless useLongGreeting "Hi" "Hello"}} Ben + ``` + + You can use the `unless` helper inside another helper as a subexpression. + + ```handlebars + {{some-component height=(unless isBig "10" "100")}} + ``` + + @method unless + @for Ember.Templates.helpers + @public + */ - return OutletComponentDefinition; - })(_glimmerRuntime.ComponentDefinition); + function inlineUnless(vm, _ref2) { + var positional = _ref2.positional; - var OutletLayoutCompiler = (function () { - function OutletLayoutCompiler(template) { - this.template = template; + switch (positional.length) { + case 2: + return ConditionalHelperReference.create(positional.at(0), null, positional.at(1)); + case 3: + return ConditionalHelperReference.create(positional.at(0), positional.at(2), positional.at(1)); + default: } - - OutletLayoutCompiler.prototype.compile = function compile(builder) { - builder.wrapLayout(this.template.asLayout()); - }; - - return OutletLayoutCompiler; - })(); - - exports.OutletLayoutCompiler = OutletLayoutCompiler; - - OutletLayoutCompiler.id = 'outlet'; + } }); -enifed('ember-glimmer/syntax/render', ['exports', 'glimmer-runtime', 'glimmer-reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet) { +enifed('ember-glimmer/helpers/loc', ['exports', 'ember-glimmer/utils/references', 'ember-runtime'], function (exports, _emberGlimmerUtilsReferences, _emberRuntime) { /** @module ember @submodule ember-glimmer */ 'use strict'; - function makeComponentDefinition(vm) { - var env = vm.env; - var args = vm.getArgs(); - var nameRef = args.positional.at(0); - - var templateName = nameRef.value(); - - var template = env.owner.lookup('template:' + templateName); - - var controllerName = undefined; - - if (args.named.has('controller')) { - var controllerNameRef = args.named.get('controller'); - - controllerName = controllerNameRef.value(); - } else { - controllerName = templateName; - } - - if (args.positional.length === 1) { - return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, SINGLETON_RENDER_MANAGER)); - } else { - return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, NON_SINGLETON_RENDER_MANAGER)); - } - } - /** - Calling ``{{render}}`` from within a template will insert another - template that matches the provided name. The inserted template will - access its properties on its own controller (rather than the controller - of the parent template). - - If a view class with the same name exists, the view class also will be used. - Note: A given controller may only be used *once* in your app in this manner. - A singleton instance of the controller will be created for you. - - Example: + Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the + provided string. This is a convenient way to localize text within a template. + For example: ```javascript - App.NavigationController = Ember.Controller.extend({ - who: "world" - }); - ``` - - ```handlebars - - Hello, {{who}}. + Ember.STRINGS = { + '_welcome_': 'Bonjour' + }; ``` ```handlebars - -

    My great app

    - {{render "navigation"}} +
    + {{loc '_welcome_'}} +
    ``` ```html -

    My great app

    -
    - Hello, world. +
    + Bonjour
    ``` - Optionally you may provide a second argument: a property path - that will be bound to the `model` property of the controller. - If a `model` property path is specified, then a new instance of the - controller will be created and `{{render}}` can be used multiple times - with the same name. - - For example if you had this `author` template. - - ```handlebars -
    - Written by {{firstName}} {{lastName}}. - Total Posts: {{postCount}} -
    - ``` + See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to + set up localized string references. - You could render it inside the `post` template using the `render` helper. + @method loc + @for Ember.Templates.helpers + @param {String} str The string to format. + @see {Ember.String#loc} + @public + */ + function locHelper(_ref) { + var positional = _ref.positional; + + return _emberRuntime.String.loc.apply(null, positional.value()); + } + + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(locHelper, args); + }; +}); +enifed('ember-glimmer/helpers/log', ['exports', 'ember-glimmer/utils/references', 'ember-console'], function (exports, _emberGlimmerUtilsReferences, _emberConsole) { + 'use strict'; + + /** + `log` allows you to output the value of variables in the current rendering + context. `log` also accepts primitive types such as strings or numbers. ```handlebars -
    -

    {{title}}

    -
    {{body}}
    - {{render "author" author}} -
    + {{log "myVariable:" myVariable }} ``` - @method render + @method log @for Ember.Templates.helpers - @param {String} name - @param {Object?} context - @param {Hash} options - @return {String} HTML string + @param {Array} params @public */ + function log(_ref) { + var positional = _ref.positional; - var RenderSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(RenderSyntax, _StatementSyntax); - - RenderSyntax.create = function create(environment, args, symbolTable) { - return new this(environment, args, symbolTable); - }; - - function RenderSyntax(environment, args, symbolTable) { - _StatementSyntax.call(this); - this.definitionArgs = args; - this.definition = makeComponentDefinition; - this.args = _glimmerRuntime.ArgsSyntax.fromPositionalArgs(args.positional.slice(1, 2)); - this.symbolTable = symbolTable; - this.shadow = null; - } - - RenderSyntax.prototype.compile = function compile(builder) { - builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow); - }; - - return RenderSyntax; - })(_glimmerRuntime.StatementSyntax); - - exports.RenderSyntax = RenderSyntax; - - var AbstractRenderManager = (function () { - function AbstractRenderManager() {} - - AbstractRenderManager.prototype.prepareArgs = function prepareArgs(definition, args) { - return args; - }; - - /* abstract create(environment, definition, args, dynamicScope); */ + _emberConsole.default.log.apply(null, positional.value()); + } - AbstractRenderManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { - return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, definition.template); - }; + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(log, args); + }; +}); - AbstractRenderManager.prototype.getSelf = function getSelf(_ref) { - var controller = _ref.controller; +/** +@module ember +@submodule ember-glimmer +*/ +enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerHelpersAction) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - return new _emberGlimmerUtilsReferences.RootReference(controller); - }; + exports.isMut = isMut; + exports.unMut = unMut; - AbstractRenderManager.prototype.getTag = function getTag() { - return null; - }; - - AbstractRenderManager.prototype.getDestructor = function getDestructor() { - return null; - }; - - AbstractRenderManager.prototype.didCreateElement = function didCreateElement() {}; - - AbstractRenderManager.prototype.didRenderLayout = function didRenderLayout() {}; - - AbstractRenderManager.prototype.didCreate = function didCreate() {}; - - AbstractRenderManager.prototype.update = function update() {}; - - AbstractRenderManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - - AbstractRenderManager.prototype.didUpdate = function didUpdate() {}; - - return AbstractRenderManager; - })(); - - var SingletonRenderManager = (function (_AbstractRenderManager) { - babelHelpers.inherits(SingletonRenderManager, _AbstractRenderManager); - - function SingletonRenderManager() { - _AbstractRenderManager.apply(this, arguments); - } - - SingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var name = definition.name; - var env = definition.env; - - var controller = env.owner.lookup('controller:' + name) || _emberRouting.generateController(env.owner, name); - - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); + /** + The `mut` helper lets you __clearly specify__ that a child `Component` can update the + (mutable) value passed to it, which will __change the value of the parent component__. + + To specify that a parameter is mutable, when invoking the child `Component`: + + ```handlebars + {{my-child childClickCount=(mut totalClicks)}} + ``` + + The child `Component` can then modify the parent's value just by modifying its own + property: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.incrementProperty('childClickCount'); } - - return { controller: controller }; - }; - - return SingletonRenderManager; - })(AbstractRenderManager); - - var SINGLETON_RENDER_MANAGER = new SingletonRenderManager(); - - var NonSingletonRenderManager = (function (_AbstractRenderManager2) { - babelHelpers.inherits(NonSingletonRenderManager, _AbstractRenderManager2); - - function NonSingletonRenderManager() { - _AbstractRenderManager2.apply(this, arguments); - } - - NonSingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { - var name = definition.name; - var env = definition.env; - - var modelRef = args.positional.at(0); - - var factory = env.owner._lookupFactory('controller:' + name) || _emberRouting.generateControllerFactory(env.owner, name); - var controller = factory.create({ model: modelRef.value() }); - - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); + }); + ``` + + Note that for curly components (`{{my-component}}`) the bindings are already mutable, + making the `mut` unnecessary. + + Additionally, the `mut` helper can be combined with the `action` helper to + mutate a value. For example: + + ```handlebars + {{my-child childClickCount=totalClicks click-count-change=(action (mut totalClicks))}} + ``` + + The child `Component` would invoke the action with the new click value: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.get('click-count-change')(this.get('childClickCount') + 1); } + }); + ``` + + The `mut` helper changes the `totalClicks` value to what was provided as the action argument. + + The `mut` helper, when used with `action`, will return a function that + sets the value passed to `mut` to its first argument. This works like any other + closure action and interacts with the other features `action` provides. + As an example, we can create a button that increments a value passing the value + directly to the `action`: + + ```handlebars + {{! inc helper is not provided by Ember }} + + ``` + + You can also use the `value` option: + + ```handlebars + + ``` + + @method mut + @param {Object} [attr] the "two-way" attribute that can be modified. + @for Ember.Templates.helpers + @public + */ + var MUT_REFERENCE = _emberUtils.symbol('MUT'); + var SOURCE = _emberUtils.symbol('SOURCE'); - return { controller: controller }; - }; - - NonSingletonRenderManager.prototype.update = function update(_ref2, args, dynamicScope) { - var controller = _ref2.controller; - - controller.set('model', args.positional.at(0).value()); - }; - - NonSingletonRenderManager.prototype.getDestructor = function getDestructor(_ref3) { - var controller = _ref3.controller; - - return controller; - }; - - return NonSingletonRenderManager; - })(AbstractRenderManager); - - var NON_SINGLETON_RENDER_MANAGER = new NonSingletonRenderManager(); - - var RenderDefinition = (function (_ComponentDefinition) { - babelHelpers.inherits(RenderDefinition, _ComponentDefinition); - - function RenderDefinition(name, template, env, manager) { - _ComponentDefinition.call(this, 'render', manager, null); - - this.name = name; - this.template = template; - this.env = env; - } - - return RenderDefinition; - })(_glimmerRuntime.ComponentDefinition); -}); -enifed('ember-glimmer/template', ['exports', 'ember-utils', 'glimmer-runtime'], function (exports, _emberUtils, _glimmerRuntime) { - 'use strict'; - - exports.default = template; - - function template(json) { - var factory = _glimmerRuntime.templateFactory(json); - - return { - id: factory.id, - meta: factory.meta, - create: function (props) { - return factory.create(props.env, { owner: props[_emberUtils.OWNER] }); - } - }; + function isMut(ref) { + return ref && ref[MUT_REFERENCE]; } -}); -enifed("ember-glimmer/template_registry", ["exports"], function (exports) { - // STATE within a module is frowned apon, this exists - // to support Ember.TEMPLATES but shield ember internals from this legacy - // global API. - "use strict"; - - exports.setTemplates = setTemplates; - exports.getTemplates = getTemplates; - exports.getTemplate = getTemplate; - exports.hasTemplate = hasTemplate; - exports.setTemplate = setTemplate; - var TEMPLATES = {}; - function setTemplates(templates) { - TEMPLATES = templates; + function unMut(ref) { + return ref[SOURCE] || ref; } - function getTemplates() { - return TEMPLATES; - } + exports.default = function (vm, args) { + var rawRef = args.positional.at(0); - function getTemplate(name) { - if (TEMPLATES.hasOwnProperty(name)) { - return TEMPLATES[name]; + if (isMut(rawRef)) { + return rawRef; } - } - - function hasTemplate(name) { - return TEMPLATES.hasOwnProperty(name); - } - - function setTemplate(name, template) { - return TEMPLATES[name] = template; - } -}); -enifed("ember-glimmer/templates/component", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - - exports.default = _emberGlimmerTemplate.default({ "id": "ZoGfVsSJ", "block": "{\"statements\":[[\"yield\",\"default\"]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/component.hbs" } }); -}); -enifed("ember-glimmer/templates/empty", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; - exports.default = _emberGlimmerTemplate.default({ "id": "qEHL4OLi", "block": "{\"statements\":[],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/empty.hbs" } }); -}); -enifed("ember-glimmer/templates/link-to", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; + // TODO: Improve this error message. This covers at least two distinct + // cases: + // + // 1. (mut "not a path") – passing a literal, result from a helper + // invocation, etc + // + // 2. (mut receivedValue) – passing a value received from the caller + // that was originally derived from a literal, result from a helper + // invocation, etc + // + // This message is alright for the first case, but could be quite + // confusing for the second case. - exports.default = _emberGlimmerTemplate.default({ "id": "Ca7iQMR7", "block": "{\"statements\":[[\"block\",[\"if\"],[[\"get\",[\"linkTitle\"]]],null,1,0]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"blocks\":[{\"statements\":[[\"yield\",\"default\"]],\"locals\":[]},{\"statements\":[[\"append\",[\"unknown\",[\"linkTitle\"]],false]],\"locals\":[]}],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/link-to.hbs" } }); -}); -enifed("ember-glimmer/templates/outlet", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; + var wrappedRef = Object.create(rawRef); - exports.default = _emberGlimmerTemplate.default({ "id": "sYQo9vi/", "block": "{\"statements\":[[\"append\",[\"unknown\",[\"outlet\"]],false]],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/outlet.hbs" } }); -}); -enifed("ember-glimmer/templates/root", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { - "use strict"; + wrappedRef[SOURCE] = rawRef; + wrappedRef[_emberGlimmerHelpersAction.INVOKE] = rawRef[_emberGlimmerUtilsReferences.UPDATE]; + wrappedRef[MUT_REFERENCE] = true; - exports.default = _emberGlimmerTemplate.default({ "id": "Eaf3RPY3", "block": "{\"statements\":[[\"append\",[\"helper\",[\"component\"],[[\"get\",[null]]],null],false]],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/root.hbs" } }); + return wrappedRef; + }; }); -enifed('ember-glimmer/utils/bindings', ['exports', 'glimmer-reference', 'glimmer-runtime', 'ember-metal', 'ember-runtime', 'ember-glimmer/component', 'ember-glimmer/utils/string'], function (exports, _glimmerReference, _glimmerRuntime, _emberMetal, _emberRuntime, _emberGlimmerComponent, _emberGlimmerUtilsString) { +enifed('ember-glimmer/helpers/query-param', ['exports', 'ember-utils', 'ember-glimmer/utils/references', 'ember-metal', 'ember-routing'], function (exports, _emberUtils, _emberGlimmerUtilsReferences, _emberMetal, _emberRouting) { + /** + @module ember + @submodule ember-glimmer + */ 'use strict'; - exports.wrapComponentClassAttribute = wrapComponentClassAttribute; + /** + This is a helper to be used in conjunction with the link-to helper. + It will supply url query parameters to the target route. + + Example + + ```handlebars + {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} + ``` + + @method query-params + @for Ember.Templates.helpers + @param {Object} hash takes a hash of query parameters + @return {Object} A `QueryParams` object for `{{link-to}}` + @public + */ + function queryParams(_ref) { + var positional = _ref.positional; + var named = _ref.named; - function referenceForKey(component, key) { - return component[_emberGlimmerComponent.ROOT_REF].get(key); + return _emberRouting.QueryParams.create({ + values: _emberUtils.assign({}, named.value()) + }); } - function referenceForParts(component, parts) { - var isAttrs = parts[0] === 'attrs'; - - // TODO deprecate this - if (isAttrs) { - parts.shift(); + exports.default = function (vm, args) { + return new _emberGlimmerUtilsReferences.InternalHelperReference(queryParams, args); + }; +}); +enifed('ember-glimmer/helpers/readonly', ['exports', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/mut'], function (exports, _emberGlimmerUtilsReferences, _emberGlimmerHelpersMut) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - if (parts.length === 1) { - return referenceForKey(component, parts[0]); + /** + The `readonly` helper let's you specify that a binding is one-way only, + instead of two-way. + When you pass a `readonly` binding from an outer context (e.g. parent component), + to to an inner context (e.g. child component), you are saying that changing that + property in the inner context does not change the value in the outer context. + + To specify that a binding is read-only, when invoking the child `Component`: + + ```app/components/my-parent.js + export default Component.extend({ + totalClicks: 3 + }); + ``` + + ```app/templates/components/my-parent.hbs + {{log totalClicks}} // -> 3 + {{my-child childClickCount=(readonly totalClicks)}} + ``` + + Now, when you update `childClickCount`: + + ```app/components/my-child.js + export default Component.extend({ + click() { + this.incrementProperty('childClickCount'); } - } - - return _glimmerReference.referenceFromParts(component[_emberGlimmerComponent.ROOT_REF], parts); - } - - // TODO we should probably do this transform at build time - - function wrapComponentClassAttribute(args) { - var named = args.named; - - var index = named.keys.indexOf('class'); - - if (index !== -1) { - var _named$values$index = named.values[index]; - var ref = _named$values$index.ref; - var type = _named$values$index.type; - - if (type === 'get') { - var propName = ref.parts[ref.parts.length - 1]; - named.values[index] = _glimmerRuntime.HelperSyntax.fromSpec(['helper', ['-class'], [['get', ref.parts], propName], null]); + }); + ``` + + The value updates in the child component, but not the parent component: + + ```app/templates/components/my-child.hbs + {{log childClickCount}} //-> 4 + ``` + + ```app/templates/components/my-parent.hbs + {{log totalClicks}} //-> 3 + {{my-child childClickCount=(readonly totalClicks)}} + ``` + + ### Objects and Arrays + + When passing a property that is a complex object (e.g. object, array) instead of a primitive object (e.g. number, string), + only the reference to the object is protected using the readonly helper. + This means that you can change properties of the object both on the parent component, as well as the child component. + The `readonly` binding behaves similar to the `const` keyword in JavaScript. + + Let's look at an example: + + First let's set up the parent component: + + ```app/components/my-parent.js + export default Ember.Component.extend({ + clicks: null, + + init() { + this._super(...arguments); + this.set('clicks', { total: 3 }); } - } - - return args; - } - - var AttributeBinding = { - parse: function (microsyntax) { - var colonIndex = microsyntax.indexOf(':'); - - if (colonIndex === -1) { - return [microsyntax, microsyntax, true]; - } else { - var prop = microsyntax.substring(0, colonIndex); - var attribute = microsyntax.substring(colonIndex + 1); - - return [prop, attribute, false]; + }); + ``` + + ```app/templates/components/my-parent.hbs + {{log clicks.total}} //-> 3 + {{my-child childClicks=(readonly clicks)}} + ``` + + Now, if you update the `total` property of `childClicks`: + + ```app/components/my-child.js + export default Ember.Component.extend({ + click() { + this.get('clicks').incrementProperty('total'); } - }, - - install: function (element, component, parsed, operations) { - var prop = parsed[0]; - var attribute = parsed[1]; - var isSimple = parsed[2]; + }); + ``` + + You will see the following happen: + + ```app/templates/components/my-parent.hbs + {{log clicks.total}} //-> 4 + {{my-child childClicks=(readonly clicks)}} + ``` + + ```app/templates/components/my-child.hbs + {{log childClicks.total}} //-> 4 + ``` + + @method readonly + @param {Object} [attr] the read-only attribute. + @for Ember.Templates.helpers + @private + */ - if (attribute === 'id') { - var elementId = _emberMetal.get(component, prop); - if (elementId === undefined || elementId === null) { - elementId = component.elementId; - } - operations.addStaticAttribute(element, 'id', elementId); - return; - } + exports.default = function (vm, args) { + var ref = _emberGlimmerHelpersMut.unMut(args.positional.at(0)); - var isPath = prop.indexOf('.') > -1; - var reference = isPath ? referenceForParts(component, prop.split('.')) : referenceForKey(component, prop); + var wrapped = Object.create(ref); - if (attribute === 'style') { - reference = new StyleBindingReference(reference, referenceForKey(component, 'isVisible')); - } + wrapped[_emberGlimmerUtilsReferences.UPDATE] = undefined; - operations.addDynamicAttribute(element, attribute, reference); - } + return wrapped; }; +}); +enifed('ember-glimmer/helpers/unbound', ['exports', 'ember-metal', 'ember-glimmer/utils/references'], function (exports, _emberMetal, _emberGlimmerUtilsReferences) { + /** + @module ember + @submodule ember-glimmer + */ - exports.AttributeBinding = AttributeBinding; - var DISPLAY_NONE = 'display: none;'; - var SAFE_DISPLAY_NONE = _emberGlimmerUtilsString.htmlSafe(DISPLAY_NONE); - - var StyleBindingReference = (function (_CachedReference) { - babelHelpers.inherits(StyleBindingReference, _CachedReference); - - function StyleBindingReference(inner, isVisible) { - _CachedReference.call(this); - - this.tag = _glimmerReference.combine([inner.tag, isVisible.tag]); - this.inner = inner; - this.isVisible = isVisible; - } - - StyleBindingReference.prototype.compute = function compute() { - var value = this.inner.value(); - var isVisible = this.isVisible.value(); + 'use strict'; - if (isVisible !== false) { - return value; - } else if (!value && value !== 0) { - return SAFE_DISPLAY_NONE; - } else { - var style = value + ' ' + DISPLAY_NONE; - return _emberGlimmerUtilsString.isHTMLSafe(value) ? _emberGlimmerUtilsString.htmlSafe(style) : style; - } - }; + /** + The `{{unbound}}` helper disconnects the one-way binding of a property, + essentially freezing its value at the moment of rendering. For example, + in this example the display of the variable `name` will not change even + if it is set with a new value: + + ```handlebars + {{unbound name}} + ``` + + Like any helper, the `unbound` helper can accept a nested helper expression. + This allows for custom helpers to be rendered unbound: + + ```handlebars + {{unbound (some-custom-helper)}} + {{unbound (capitalize name)}} + {{! You can use any helper, including unbound, in a nested expression }} + {{capitalize (unbound name)}} + ``` + + The `unbound` helper only accepts a single argument, and it return an + unbound value. + + @method unbound + @for Ember.Templates.helpers + @public + */ - return StyleBindingReference; - })(_glimmerReference.CachedReference); + exports.default = function (vm, args) { - var IsVisibleBinding = { - install: function (element, component, operations) { - operations.addDynamicAttribute(element, 'style', _glimmerReference.map(referenceForKey(component, 'isVisible'), this.mapStyleValue)); - }, - - mapStyleValue: function (isVisible) { - return isVisible === false ? SAFE_DISPLAY_NONE : null; - } + return _emberGlimmerUtilsReferences.UnboundReference.create(args.positional.at(0).value()); }; +}); +enifed('ember-glimmer/index', ['exports', 'ember-glimmer/helpers/action', 'ember-glimmer/templates/root', 'ember-glimmer/template', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/helper', 'ember-glimmer/environment', 'ember-glimmer/make-bound-helper', 'ember-glimmer/utils/string', 'ember-glimmer/renderer', 'ember-glimmer/template_registry', 'ember-glimmer/setup-registry', 'ember-glimmer/dom'], function (exports, _emberGlimmerHelpersAction, _emberGlimmerTemplatesRoot, _emberGlimmerTemplate, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerHelper, _emberGlimmerEnvironment, _emberGlimmerMakeBoundHelper, _emberGlimmerUtilsString, _emberGlimmerRenderer, _emberGlimmerTemplate_registry, _emberGlimmerSetupRegistry, _emberGlimmerDom) { + /** + [Glimmer](https://github.com/tildeio/glimmer) is a [Handlebars](http://handlebarsjs.com/) + compatible templating engine used by Ember.js. + Any valid Handlebars syntax is valid in an Ember template. + + ### Showing a property + + Templates manage the flow of an application's UI, and display state (through + the DOM) to a user. For example, given a component with the property "name", + that component's template can use the name in several ways: + + ```javascript + // app/components/person.js + export default Ember.Component.extend({ + name: 'Jill' + }); + ``` + + ```handlebars + {{! app/components/person.hbs }} + {{name}} +
    {{name}}
    + + ``` + + Any time the "name" property on the component changes, the DOM will be + updated. + + Properties can be chained as well: + + ```handlebars + {{aUserModel.name}} +
    {{listOfUsers.firstObject.name}}
    + ``` + + ### Using Ember helpers + + When content is passed in mustaches `{{}}`, Ember will first try to find a helper + or component with that name. For example, the `if` helper: + + ```handlebars + {{if name "I have a name" "I have no name"}} + + ``` + + The returned value is placed where the `{{}}` is called. The above style is + called "inline". A second style of helper usage is called "block". For example: + + ```handlebars + {{#if name}} + I have a name + {{else}} + I have no name + {{/if}} + ``` + + The block form of helpers allows you to control how the UI is created based + on the values of properties. + A third form of helper is called "nested". For example here the concat + helper will add " Doe" to a displayed name if the person has no last name: + + ```handlebars + + ``` + + Ember's built-in helpers are described under the [Ember.Templates.helpers](/api/classes/Ember.Templates.helpers.html) + namespace. Documentation on creating custom helpers can be found under + [Ember.Helper](/api/classes/Ember.Helper.html). + + ### Invoking a Component + + Ember components represent state to the UI of an application. Further + reading on components can be found under [Ember.Component](/api/classes/Ember.Component.html). + + @module ember + @submodule ember-glimmer + @main ember-glimmer + @public + */ - exports.IsVisibleBinding = IsVisibleBinding; - var ClassNameBinding = { - install: function (element, component, microsyntax, operations) { - var _microsyntax$split = microsyntax.split(':'); - - var prop = _microsyntax$split[0]; - var truthy = _microsyntax$split[1]; - var falsy = _microsyntax$split[2]; - - var isStatic = prop === ''; - - if (isStatic) { - operations.addStaticAttribute(element, 'class', truthy); - } else { - var isPath = prop.indexOf('.') > -1; - var parts = isPath && prop.split('.'); - var value = isPath ? referenceForParts(component, parts) : referenceForKey(component, prop); - var ref = undefined; + /** + Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful + for semantic clarity as it allows you to retain default scope or to reference a property from another + `{{with}}` block. + + If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0`, NaN or + an empty array, the block will not be rendered. + + ```handlebars + {{! Will only render if user.posts contains items}} + {{#with user.posts as |blogPosts|}} +
    + There are {{blogPosts.length}} blog posts written by {{user.name}}. +
    + {{#each blogPosts as |post|}} +
  • {{post.title}}
  • + {{/each}} + {{/with}} + ``` + + Without the `as` operator, it would be impossible to reference `user.name` in the example above. + + NOTE: The alias should not reuse a name from the bound property path. + + For example: `{{#with foo.bar as |foo|}}` is not supported because it attempts to alias using + the first part of the property path, `foo`. Instead, use `{{#with foo.bar as |baz|}}`. + + @method with + @for Ember.Templates.helpers + @param {Object} options + @return {String} HTML string + @public + */ - if (truthy === undefined) { - ref = new SimpleClassNameBindingReference(value, isPath ? parts[parts.length - 1] : prop); - } else { - ref = new ColonClassNameBindingReference(value, truthy, falsy); - } + /** + Execute the `debugger` statement in the current template's context. + + ```handlebars + {{debugger}} + ``` + + When using the debugger helper you will have access to a `get` function. This + function retrieves values available in the context of the template. + For example, if you're wondering why a value `{{foo}}` isn't rendering as + expected within a template, you could place a `{{debugger}}` statement and, + when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: + + ``` + > get('foo') + ``` + + `get` is also aware of keywords. So in this situation + + ```handlebars + {{#each items as |item|}} + {{debugger}} + {{/each}} + ``` + + You'll be able to get values from the current item: + + ``` + > get('item.name') + ``` + + You can also access the context of the view to make sure it is the object that + you expect: + + ``` + > context + ``` + + @method debugger + @for Ember.Templates.helpers + @public + */ - operations.addDynamicAttribute(element, 'class', ref); - } - } - }; + /** + The `partial` helper renders another template without + changing the template context: + + ```handlebars + {{foo}} + {{partial "nav"}} + ``` + + The above example template will render a template named + "-nav", which has the same context as the parent template + it's rendered into, so if the "-nav" template also referenced + `{{foo}}`, it would print the same thing as the `{{foo}}` + in the above example. + + If a "-nav" template isn't found, the `partial` helper will + fall back to a template named "nav". + + ### Bound template names + + The parameter supplied to `partial` can also be a path + to a property containing a template name, e.g.: + + ```handlebars + {{partial someTemplateName}} + ``` + + The above example will look up the value of `someTemplateName` + on the template context (e.g. a controller) and use that + value as the name of the template to render. If the resolved + value is falsy, nothing will be rendered. If `someTemplateName` + changes, the partial will be re-rendered using the new template + name. + + @method partial + @for Ember.Templates.helpers + @param {String} partialName The name of the template to render minus the leading underscore. + @public + */ - exports.ClassNameBinding = ClassNameBinding; + 'use strict'; - var SimpleClassNameBindingReference = (function (_CachedReference2) { - babelHelpers.inherits(SimpleClassNameBindingReference, _CachedReference2); + exports.INVOKE = _emberGlimmerHelpersAction.INVOKE; + exports.RootTemplate = _emberGlimmerTemplatesRoot.default; + exports.template = _emberGlimmerTemplate.default; + exports.Checkbox = _emberGlimmerComponentsCheckbox.default; + exports.TextField = _emberGlimmerComponentsText_field.default; + exports.TextArea = _emberGlimmerComponentsText_area.default; + exports.LinkComponent = _emberGlimmerComponentsLinkTo.default; + exports.Component = _emberGlimmerComponent.default; + exports.Helper = _emberGlimmerHelper.default; + exports.helper = _emberGlimmerHelper.helper; + exports.Environment = _emberGlimmerEnvironment.default; + exports.makeBoundHelper = _emberGlimmerMakeBoundHelper.default; + exports.SafeString = _emberGlimmerUtilsString.SafeString; + exports.escapeExpression = _emberGlimmerUtilsString.escapeExpression; + exports.htmlSafe = _emberGlimmerUtilsString.htmlSafe; + exports.isHTMLSafe = _emberGlimmerUtilsString.isHTMLSafe; + exports._getSafeString = _emberGlimmerUtilsString.getSafeString; + exports.Renderer = _emberGlimmerRenderer.Renderer; + exports.InertRenderer = _emberGlimmerRenderer.InertRenderer; + exports.InteractiveRenderer = _emberGlimmerRenderer.InteractiveRenderer; + exports.getTemplate = _emberGlimmerTemplate_registry.getTemplate; + exports.setTemplate = _emberGlimmerTemplate_registry.setTemplate; + exports.hasTemplate = _emberGlimmerTemplate_registry.hasTemplate; + exports.getTemplates = _emberGlimmerTemplate_registry.getTemplates; + exports.setTemplates = _emberGlimmerTemplate_registry.setTemplates; + exports.setupEngineRegistry = _emberGlimmerSetupRegistry.setupEngineRegistry; + exports.setupApplicationRegistry = _emberGlimmerSetupRegistry.setupApplicationRegistry; + exports.DOMChanges = _emberGlimmerDom.DOMChanges; + exports.NodeDOMTreeConstruction = _emberGlimmerDom.NodeDOMTreeConstruction; + exports.DOMTreeConstruction = _emberGlimmerDom.DOMTreeConstruction; +}); +enifed('ember-glimmer/make-bound-helper', ['exports', 'ember-metal', 'ember-glimmer/helper'], function (exports, _emberMetal, _emberGlimmerHelper) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - function SimpleClassNameBindingReference(inner, path) { - _CachedReference2.call(this); + exports.default = makeBoundHelper; - this.tag = inner.tag; - this.inner = inner; - this.path = path; - this.dasherizedPath = null; - } + /** + Create a bound helper. Accepts a function that receives the ordered and hash parameters + from the template. If a bound property was provided in the template, it will be resolved to its + value and any changes to the bound property cause the helper function to be re-run with the updated + values. + + * `params` - An array of resolved ordered parameters. + * `hash` - An object containing the hash parameters. + + For example: + + * With an unquoted ordered parameter: + + ```javascript + {{x-capitalize foo}} + ``` + + Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and + an empty hash as its second. + + * With a quoted ordered parameter: + + ```javascript + {{x-capitalize "foo"}} + ``` + + The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. + + * With an unquoted hash parameter: + + ```javascript + {{x-repeat "foo" count=repeatCount}} + ``` + + Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, + and { count: 2 } as its second. + + @private + @method makeBoundHelper + @for Ember.HTMLBars + @param {Function} fn + @since 1.10.0 + */ - SimpleClassNameBindingReference.prototype.compute = function compute() { - var value = this.inner.value(); + function makeBoundHelper(fn) { + return _emberGlimmerHelper.helper(fn); + } +}); +enifed('ember-glimmer/modifiers/action', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'ember-glimmer/helpers/action'], function (exports, _emberUtils, _emberMetal, _emberViews, _emberGlimmerHelpersAction) { + 'use strict'; - if (value === true) { - var path = this.path; - var dasherizedPath = this.dasherizedPath; + var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; + var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; - return dasherizedPath || (this.dasherizedPath = _emberRuntime.String.dasherize(path)); - } else if (value || value === 0) { - return value; + function isAllowedEvent(event, allowedKeys) { + if (allowedKeys === null || typeof allowedKeys === 'undefined') { + if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { + return _emberViews.isSimpleClick(event); } else { - return null; + allowedKeys = ''; } - }; - - return SimpleClassNameBindingReference; - })(_glimmerReference.CachedReference); - - var ColonClassNameBindingReference = (function (_CachedReference3) { - babelHelpers.inherits(ColonClassNameBindingReference, _CachedReference3); - - function ColonClassNameBindingReference(inner, truthy, falsy) { - _CachedReference3.call(this); + } - this.tag = inner.tag; - this.inner = inner; - this.truthy = truthy || null; - this.falsy = falsy || null; + if (allowedKeys.indexOf('any') >= 0) { + return true; } - ColonClassNameBindingReference.prototype.compute = function compute() { - var inner = this.inner; - var truthy = this.truthy; - var falsy = this.falsy; + for (var i = 0; i < MODIFIERS.length; i++) { + if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { + return false; + } + } - return inner.value() ? truthy : falsy; - }; + return true; + } - return ColonClassNameBindingReference; - })(_glimmerReference.CachedReference); -}); -enifed('ember-glimmer/utils/iterable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', 'glimmer-reference'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerReference) { - 'use strict'; + var ActionHelper = { + // registeredActions is re-exported for compatibility with older plugins + // that were using this undocumented API. + registeredActions: _emberViews.ActionManager.registeredActions, - exports.default = iterableFor; + registerAction: function (actionState) { + var actionId = actionState.actionId; - var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; + _emberViews.ActionManager.registeredActions[actionId] = actionState; - function iterableFor(ref, keyPath) { - if (_emberGlimmerHelpersEachIn.isEachIn(ref)) { - return new EachInIterable(ref, keyForEachIn(keyPath)); - } else { - return new ArrayIterable(ref, keyForArray(keyPath)); - } - } + return actionId; + }, - function keyForEachIn(keyPath) { - switch (keyPath) { - case '@index': - case undefined: - case null: - return index; - case '@identity': - return identity; - default: - return function (item) { - return _emberMetal.get(item, keyPath); - }; - } - } + unregisterAction: function (actionState) { + var actionId = actionState.actionId; - function keyForArray(keyPath) { - switch (keyPath) { - case '@index': - return index; - case '@identity': - case undefined: - case null: - return identity; - default: - return function (item) { - return _emberMetal.get(item, keyPath); - }; + delete _emberViews.ActionManager.registeredActions[actionId]; } - } + }; - function index(item, index) { - return String(index); - } + exports.ActionHelper = ActionHelper; - function identity(item) { - switch (typeof item) { - case 'string': - case 'number': - return String(item); - default: - return _emberUtils.guidFor(item); + var ActionState = (function () { + function ActionState(element, actionId, actionName, actionArgs, namedArgs, positionalArgs, implicitTarget, dom) { + this.element = element; + this.actionId = actionId; + this.actionName = actionName; + this.actionArgs = actionArgs; + this.namedArgs = namedArgs; + this.positional = positionalArgs; + this.implicitTarget = implicitTarget; + this.dom = dom; + this.eventName = this.getEventName(); } - } - function ensureUniqueKey(seen, key) { - var seenCount = seen[key]; + // implements ModifierManager - if (seenCount) { - seen[key]++; - return '' + key + ITERATOR_KEY_GUID + seenCount; - } else { - seen[key] = 1; - } + ActionState.prototype.getEventName = function getEventName() { + return this.namedArgs.get('on').value() || 'click'; + }; - return key; - } + ActionState.prototype.getActionArgs = function getActionArgs() { + var result = new Array(this.actionArgs.length); - var ArrayIterator = (function () { - function ArrayIterator(array, keyFor) { - this.array = array; - this.length = array.length; - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } + for (var i = 0; i < this.actionArgs.length; i++) { + result[i] = this.actionArgs[i].value(); + } - ArrayIterator.prototype.isEmpty = function isEmpty() { - return false; + return result; }; - ArrayIterator.prototype.next = function next() { - var array = this.array; - var length = this.length; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; - - if (position >= length) { - return null; - } + ActionState.prototype.getTarget = function getTarget() { + var implicitTarget = this.implicitTarget; + var namedArgs = this.namedArgs; - var value = array[position]; - var memo = position; - var key = ensureUniqueKey(seen, keyFor(value, memo)); + var target = undefined; - this.position++; + if (namedArgs.has('target')) { + target = namedArgs.get('target').value(); + } else { + target = implicitTarget.value(); + } - return { key: key, value: value, memo: memo }; + return target; }; - return ArrayIterator; - })(); + ActionState.prototype.handler = function handler(event) { + var _this = this; - var EmberArrayIterator = (function () { - function EmberArrayIterator(array, keyFor) { - this.array = array; - this.length = _emberMetal.get(array, 'length'); - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } + var actionName = this.actionName; + var namedArgs = this.namedArgs; - EmberArrayIterator.prototype.isEmpty = function isEmpty() { - return this.length === 0; - }; + var bubbles = namedArgs.get('bubbles'); + var preventDefault = namedArgs.get('preventDefault'); + var allowedKeys = namedArgs.get('allowedKeys'); + var target = this.getTarget(); - EmberArrayIterator.prototype.next = function next() { - var array = this.array; - var length = this.length; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; + if (!isAllowedEvent(event, allowedKeys.value())) { + return true; + } - if (position >= length) { - return null; + if (preventDefault.value() !== false) { + event.preventDefault(); } - var value = _emberRuntime.objectAt(array, position); - var memo = position; - var key = ensureUniqueKey(seen, keyFor(value, memo)); + if (bubbles.value() === false) { + event.stopPropagation(); + } - this.position++; + _emberMetal.run(function () { + var args = _this.getActionArgs(); + var payload = { + args: args, + target: target + }; + if (typeof actionName[_emberGlimmerHelpersAction.INVOKE] === 'function') { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + actionName[_emberGlimmerHelpersAction.INVOKE].apply(actionName, args); + }); + return; + } + if (typeof actionName === 'function') { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + actionName.apply(target, args); + }); + return; + } + payload.name = actionName; + if (target.send) { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + target.send.apply(target, [actionName].concat(args)); + }); + } else { + _emberMetal.flaggedInstrument('interaction.ember-action', payload, function () { + target[actionName].apply(target, args); + }); + } + }); + }; - return { key: key, value: value, memo: memo }; + ActionState.prototype.destroy = function destroy() { + ActionHelper.unregisterAction(this); }; - return EmberArrayIterator; + return ActionState; })(); - var ObjectKeysIterator = (function () { - function ObjectKeysIterator(keys, values, keyFor) { - this.keys = keys; - this.values = values; - this.keyFor = keyFor; - this.position = 0; - this.seen = new _emberUtils.EmptyObject(); - } + exports.ActionState = ActionState; - ObjectKeysIterator.prototype.isEmpty = function isEmpty() { - return this.keys.length === 0; - }; + var ActionModifierManager = (function () { + function ActionModifierManager() {} - ObjectKeysIterator.prototype.next = function next() { - var keys = this.keys; - var values = this.values; - var keyFor = this.keyFor; - var position = this.position; - var seen = this.seen; + ActionModifierManager.prototype.create = function create(element, args, dynamicScope, dom) { + var named = args.named; + var positional = args.positional; - if (position >= keys.length) { - return null; + var implicitTarget = undefined; + var actionName = undefined; + var actionNameRef = undefined; + if (positional.length > 1) { + implicitTarget = positional.at(0); + actionNameRef = positional.at(1); + + if (actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { + actionName = actionNameRef; + } else { + var actionLabel = actionNameRef._propertyKey; + actionName = actionNameRef.value(); + } } - var value = values[position]; - var memo = keys[position]; - var key = ensureUniqueKey(seen, keyFor(value, memo)); + var actionArgs = []; + // The first two arguments are (1) `this` and (2) the action name. + // Everything else is a param. + for (var i = 2; i < positional.length; i++) { + actionArgs.push(positional.at(i)); + } - this.position++; + var actionId = _emberUtils.uuid(); + return new ActionState(element, actionId, actionName, actionArgs, named, positional, implicitTarget, dom); + }; - return { key: key, value: value, memo: memo }; + ActionModifierManager.prototype.install = function install(actionState) { + var dom = actionState.dom; + var element = actionState.element; + var actionId = actionState.actionId; + + ActionHelper.registerAction(actionState); + + dom.setAttribute(element, 'data-ember-action', ''); + dom.setAttribute(element, 'data-ember-action-' + actionId, actionId); }; - return ObjectKeysIterator; - })(); + ActionModifierManager.prototype.update = function update(actionState) { + var positional = actionState.positional; - var EmptyIterator = (function () { - function EmptyIterator() {} + var actionNameRef = positional.at(1); - EmptyIterator.prototype.isEmpty = function isEmpty() { - return true; + if (!actionNameRef[_emberGlimmerHelpersAction.INVOKE]) { + actionState.actionName = actionNameRef.value(); + } + actionState.eventName = actionState.getEventName(); + + // Not sure if this is needed? If we mutate the actionState is that good enough? + ActionHelper.unregisterAction(actionState); + ActionHelper.registerAction(actionState); }; - EmptyIterator.prototype.next = function next() { - throw new Error('Cannot call next() on an empty iterator'); + ActionModifierManager.prototype.getDestructor = function getDestructor(modifier) { + return modifier; }; - return EmptyIterator; + return ActionModifierManager; })(); - var EMPTY_ITERATOR = new EmptyIterator(); + exports.default = ActionModifierManager; +}); +enifed('ember-glimmer/protocol-for-url', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + /* globals module, URL */ - var EachInIterable = (function () { - function EachInIterable(ref, keyFor) { - this.ref = ref; - this.keyFor = keyFor; + 'use strict'; - var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + exports.default = installProtocolForURL; - this.tag = _glimmerReference.combine([ref.tag, valueTag]); - } + var nodeURL = undefined; + var parsingNode = undefined; - EachInIterable.prototype.iterate = function iterate() { - var ref = this.ref; - var keyFor = this.keyFor; - var valueTag = this.valueTag; + function installProtocolForURL(environment) { + var protocol = undefined; - var iterable = ref.value(); + if (_emberEnvironment.environment.hasDOM) { + protocol = browserProtocolForURL.call(environment, 'foobar:baz'); + } - valueTag.update(_emberMetal.tagFor(iterable)); + // Test to see if our DOM implementation parses + // and normalizes URLs. + if (protocol === 'foobar:') { + // Swap in the method that doesn't do this test now that + // we know it works. + environment.protocolForURL = browserProtocolForURL; + } else if (typeof URL === 'object') { + // URL globally provided, likely from FastBoot's sandbox + nodeURL = URL; + environment.protocolForURL = nodeProtocolForURL; + } else if (typeof module === 'object' && typeof module.require === 'function') { + // Otherwise, we need to fall back to our own URL parsing. + // Global `require` is shadowed by Ember's loader so we have to use the fully + // qualified `module.require`. + nodeURL = module.require('url'); + environment.protocolForURL = nodeProtocolForURL; + } else { + throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); + } + } - if (_emberMetal.isProxy(iterable)) { - iterable = _emberMetal.get(iterable, 'content'); - } + function browserProtocolForURL(url) { + if (!parsingNode) { + parsingNode = document.createElement('a'); + } - var typeofIterable = typeof iterable; + parsingNode.href = url; + return parsingNode.protocol; + } - if (iterable && (typeofIterable === 'object' || typeofIterable === 'function')) { - var keys = Object.keys(iterable); - var values = keys.map(function (key) { - return iterable[key]; - }); - return keys.length > 0 ? new ObjectKeysIterator(keys, values, keyFor) : EMPTY_ITERATOR; - } else { - return EMPTY_ITERATOR; - } - }; + function nodeProtocolForURL(url) { + var protocol = null; + if (typeof url === 'string') { + protocol = nodeURL.parse(url).protocol; + } + return protocol === null ? ':' : protocol; + } +}); +enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', 'ember-metal', '@glimmer/reference', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/syntax/curly-component', 'ember-glimmer/syntax/outlet'], function (exports, _emberGlimmerUtilsReferences, _emberMetal, _glimmerReference, _emberViews, _emberGlimmerComponent, _emberGlimmerSyntaxCurlyComponent, _emberGlimmerSyntaxOutlet) { + 'use strict'; - // {{each-in}} yields |key value| instead of |value key|, so the memo and - // value are flipped + var backburner = _emberMetal.run.backburner; - EachInIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); - }; + var DynamicScope = (function () { + function DynamicScope(view, outletState, rootOutletState, targetObject) { + this.view = view; + this.outletState = outletState; + this.rootOutletState = rootOutletState; + } - EachInIterable.prototype.updateValueReference = function updateValueReference(reference, item) { - reference.update(item.memo); + DynamicScope.prototype.child = function child() { + return new DynamicScope(this.view, this.outletState, this.rootOutletState); }; - EachInIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); + DynamicScope.prototype.get = function get(key) { + return this.outletState; }; - EachInIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { - reference.update(item.value); + DynamicScope.prototype.set = function set(key, value) { + this.outletState = value; + return value; }; - return EachInIterable; + return DynamicScope; })(); - var ArrayIterable = (function () { - function ArrayIterable(ref, keyFor) { - this.ref = ref; - this.keyFor = keyFor; + var RootState = (function () { + function RootState(root, env, template, self, parentElement, dynamicScope) { + var _this = this; - var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + this.id = _emberViews.getViewId(root); + this.env = env; + this.root = root; + this.result = undefined; + this.shouldReflush = false; + this.destroyed = false; + this._removing = false; - this.tag = _glimmerReference.combine([ref.tag, valueTag]); - } + var options = this.options = { + alwaysRevalidate: false + }; - ArrayIterable.prototype.iterate = function iterate() { - var ref = this.ref; - var keyFor = this.keyFor; - var valueTag = this.valueTag; + this.render = function () { + var result = _this.result = template.render(self, parentElement, dynamicScope); - var iterable = ref.value(); + // override .render function after initial render + _this.render = function () { + result.rerender(options); + }; + }; + } - valueTag.update(_emberMetal.tagForProperty(iterable, '[]')); + RootState.prototype.isFor = function isFor(possibleRoot) { + return this.root === possibleRoot; + }; - if (!iterable || typeof iterable !== 'object') { - return EMPTY_ITERATOR; - } + RootState.prototype.destroy = function destroy() { + var result = this.result; + var env = this.env; - if (Array.isArray(iterable)) { - return iterable.length > 0 ? new ArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; - } else if (_emberRuntime.isEmberArray(iterable)) { - return _emberMetal.get(iterable, 'length') > 0 ? new EmberArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; - } else if (typeof iterable.forEach === 'function') { - var _ret = (function () { - var array = []; - iterable.forEach(function (item) { - array.push(item); - }); - return { - v: array.length > 0 ? new ArrayIterator(array, keyFor) : EMPTY_ITERATOR - }; - })(); + this.destroyed = true; - if (typeof _ret === 'object') return _ret.v; - } else { - return EMPTY_ITERATOR; - } - }; + this.env = null; + this.root = null; + this.result = null; + this.render = null; - ArrayIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); - }; + if (result) { + /* + Handles these scenarios: + * When roots are removed during standard rendering process, a transaction exists already + `.begin()` / `.commit()` are not needed. + * When roots are being destroyed manually (`component.append(); component.destroy() case), no + transaction exists already. + * When roots are being destroyed during `Renderer#destroy`, no transaction exists + */ + var needsTransaction = !env.inTransaction; - ArrayIterable.prototype.updateValueReference = function updateValueReference(reference, item) { - reference.update(item.value); - }; + if (needsTransaction) { + env.begin(); + } - ArrayIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { - return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); - }; + result.destroy(); - ArrayIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { - reference.update(item.memo); + if (needsTransaction) { + env.commit(); + } + } }; - return ArrayIterable; + return RootState; })(); -}); -enifed('ember-glimmer/utils/process-args', ['exports', 'ember-utils', 'glimmer-reference', 'ember-glimmer/component', 'ember-glimmer/utils/references', 'ember-views', 'ember-glimmer/helpers/action', 'glimmer-runtime'], function (exports, _emberUtils, _glimmerReference, _emberGlimmerComponent, _emberGlimmerUtilsReferences, _emberViews, _emberGlimmerHelpersAction, _glimmerRuntime) { - 'use strict'; - exports.gatherArgs = gatherArgs; + var renderers = []; - // Maps all variants of positional and dynamically scoped arguments - // into the named arguments. Input `args` and return value are both - // `EvaluatedArgs`. + _emberMetal.setHasViews(function () { + return renderers.length > 0; + }); - function gatherArgs(args, definition) { - var namedMap = gatherNamedMap(args, definition); - var positionalValues = gatherPositionalValues(args, definition); - return mergeArgs(namedMap, positionalValues, args.blocks, definition.ComponentClass); + function register(renderer) { + renderers.push(renderer); } - function gatherNamedMap(args, definition) { - var namedMap = args.named.map; - if (definition.args) { - return _emberUtils.assign({}, definition.args.named.map, namedMap); - } else { - return namedMap; - } + function deregister(renderer) { + var index = renderers.indexOf(renderer); + + renderers.splice(index, 1); } - function gatherPositionalValues(args, definition) { - var positionalValues = args.positional.values; - if (definition.args) { - var oldPositional = definition.args.positional.values; - var newPositional = []; - newPositional.push.apply(newPositional, oldPositional); - newPositional.splice.apply(newPositional, [0, positionalValues.length].concat(positionalValues)); - return newPositional; - } else { - return positionalValues; + function loopBegin() { + for (var i = 0; i < renderers.length; i++) { + renderers[i]._scheduleRevalidate(); } } - function mergeArgs(namedMap, positionalValues, blocks, componentClass) { - var positionalParamsDefinition = componentClass.positionalParams; + function K() {} - if (positionalParamsDefinition && positionalParamsDefinition.length > 0 && positionalValues.length > 0) { - if (typeof positionalParamsDefinition === 'string') { - namedMap = mergeRestArg(namedMap, positionalValues, positionalParamsDefinition); - } else { - namedMap = mergePositionalParams(namedMap, positionalValues, positionalParamsDefinition); + var loops = 0; + function loopEnd(current, next) { + for (var i = 0; i < renderers.length; i++) { + if (!renderers[i]._isValid()) { + if (loops > 10) { + loops = 0; + // TODO: do something better + renderers[i].destroy(); + throw new Error('infinite rendering invalidation detected'); + } + loops++; + return backburner.join(null, K); } } - return _glimmerRuntime.EvaluatedArgs.named(namedMap, blocks); + loops = 0; } - var EMPTY_ARGS = { - tag: _glimmerReference.CONSTANT_TAG, - value: function () { - var _props; + backburner.on('begin', loopBegin); + backburner.on('end', loopEnd); - return { attrs: {}, props: (_props = { attrs: {} }, _props[_emberGlimmerComponent.ARGS] = {}, _props) }; + var Renderer = (function () { + function Renderer(env, rootTemplate) { + var _viewRegistry = arguments.length <= 2 || arguments[2] === undefined ? _emberViews.fallbackViewRegistry : arguments[2]; + + var destinedForDOM = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; + + this._env = env; + this._rootTemplate = rootTemplate; + this._viewRegistry = _viewRegistry; + this._destinedForDOM = destinedForDOM; + this._destroyed = false; + this._roots = []; + this._lastRevision = null; + this._isRenderingRoots = false; + this._removedRoots = []; } - }; - // ComponentArgs takes EvaluatedNamedArgs and converts them into the - // inputs needed by CurlyComponents (attrs and props, with mutable - // cells, etc). + // renderer HOOKS - var ComponentArgs = (function () { - ComponentArgs.create = function create(args) { - if (args.named.keys.length === 0) { - return EMPTY_ARGS; - } else { - return new ComponentArgs(args.named); - } + Renderer.prototype.appendOutletView = function appendOutletView(view, target) { + var definition = new _emberGlimmerSyntaxOutlet.TopLevelOutletComponentDefinition(view); + var outletStateReference = view.toReference(); + var targetObject = view.outletState.render.controller; + + this._appendDefinition(view, definition, target, outletStateReference, targetObject); }; - function ComponentArgs(namedArgs) { - this.tag = namedArgs.tag; - this.namedArgs = namedArgs; - } + Renderer.prototype.appendTo = function appendTo(view, target) { + var rootDef = new _emberGlimmerSyntaxCurlyComponent.RootComponentDefinition(view); - ComponentArgs.prototype.value = function value() { - var namedArgs = this.namedArgs; + this._appendDefinition(view, rootDef, target); + }; - var keys = namedArgs.keys; - var attrs = namedArgs.value(); - var props = new _emberUtils.EmptyObject(); - var args = new _emberUtils.EmptyObject(); + Renderer.prototype._appendDefinition = function _appendDefinition(root, definition, target) { + var outletStateReference = arguments.length <= 3 || arguments[3] === undefined ? _glimmerReference.UNDEFINED_REFERENCE : arguments[3]; + var targetObject = arguments.length <= 4 || arguments[4] === undefined ? null : arguments[4]; - props[_emberGlimmerComponent.ARGS] = args; + var self = new _emberGlimmerUtilsReferences.RootReference(definition); + var dynamicScope = new DynamicScope(null, outletStateReference, outletStateReference, true, targetObject); + var rootState = new RootState(root, this._env, this._rootTemplate, self, target, dynamicScope); - for (var i = 0, l = keys.length; i < l; i++) { - var _name = keys[i]; - var ref = namedArgs.get(_name); - var value = attrs[_name]; + this._renderRoot(rootState); + }; - if (typeof value === 'function' && value[_emberGlimmerHelpersAction.ACTION]) { - attrs[_name] = value; - } else if (ref[_emberGlimmerUtilsReferences.UPDATE]) { - attrs[_name] = new MutableCell(ref, value); - } + Renderer.prototype.rerender = function rerender(view) { + this._scheduleRevalidate(); + }; - args[_name] = ref; - props[_name] = value; - } + Renderer.prototype.register = function register(view) { + var id = _emberViews.getViewId(view); - props.attrs = attrs; + this._viewRegistry[id] = view; + }; - return { attrs: attrs, props: props }; + Renderer.prototype.unregister = function unregister(view) { + delete this._viewRegistry[_emberViews.getViewId(view)]; }; - return ComponentArgs; - })(); + Renderer.prototype.remove = function remove(view) { + view._transitionTo('destroying'); - exports.ComponentArgs = ComponentArgs; + this.cleanupRootFor(view); - function mergeRestArg(namedMap, positionalValues, restArgName) { - var mergedNamed = _emberUtils.assign({}, namedMap); - mergedNamed[restArgName] = _glimmerRuntime.EvaluatedPositionalArgs.create(positionalValues); - return mergedNamed; - } + _emberViews.setViewElement(view, null); - function mergePositionalParams(namedMap, values, positionalParamNames) { - var mergedNamed = _emberUtils.assign({}, namedMap); - var length = Math.min(values.length, positionalParamNames.length); - for (var i = 0; i < length; i++) { - var _name2 = positionalParamNames[i]; - mergedNamed[_name2] = values[i]; - } - return mergedNamed; - } - - var REF = _emberUtils.symbol('REF'); - - var MutableCell = (function () { - function MutableCell(ref, value) { - this[_emberViews.MUTABLE_CELL] = true; - this[REF] = ref; - this.value = value; - } + if (this._destinedForDOM) { + view.trigger('didDestroyElement'); + } - MutableCell.prototype.update = function update(val) { - this[REF][_emberGlimmerUtilsReferences.UPDATE](val); + if (!view.isDestroying) { + view.destroy(); + } }; - return MutableCell; - })(); -}); -enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal', 'glimmer-reference', 'glimmer-runtime', 'ember-glimmer/utils/to-bool', 'ember-glimmer/helper'], function (exports, _emberUtils, _emberMetal, _glimmerReference, _glimmerRuntime, _emberGlimmerUtilsToBool, _emberGlimmerHelper) { - 'use strict'; + Renderer.prototype.cleanupRootFor = function cleanupRootFor(view) { + // no need to cleanup roots if we have already been destroyed + if (this._destroyed) { + return; + } - var UPDATE = _emberUtils.symbol('UPDATE'); + var roots = this._roots; - exports.UPDATE = UPDATE; - exports.NULL_REFERENCE = _glimmerRuntime.NULL_REFERENCE; - exports.UNDEFINED_REFERENCE = _glimmerRuntime.UNDEFINED_REFERENCE; + // traverse in reverse so we can remove items + // without mucking up the index + var i = this._roots.length; + while (i--) { + var root = roots[i]; + if (root.isFor(view)) { + root.destroy(); + } + } + }; - // @abstract - // @implements PathReference + Renderer.prototype.destroy = function destroy() { + if (this._destroyed) { + return; + } + this._destroyed = true; + this._clearAllRoots(); + }; - var EmberPathReference = (function () { - function EmberPathReference() {} + Renderer.prototype.getElement = function getElement(view) { + // overriden in the subclasses + }; - // @abstract + Renderer.prototype.getBounds = function getBounds(view) { + var bounds = view[_emberGlimmerComponent.BOUNDS]; - // @abstract get tag() - // @abstract value() + var parentElement = bounds.parentElement(); + var firstNode = bounds.firstNode(); + var lastNode = bounds.lastNode(); - EmberPathReference.prototype.get = function get(key) { - return PropertyReference.create(this, key); + return { parentElement: parentElement, firstNode: firstNode, lastNode: lastNode }; }; - return EmberPathReference; - })(); - - var CachedReference = (function (_EmberPathReference) { - babelHelpers.inherits(CachedReference, _EmberPathReference); - - function CachedReference() { - _EmberPathReference.call(this); - this._lastRevision = null; - this._lastValue = null; - } + Renderer.prototype.createElement = function createElement(tagName) { + return this._env.getAppendOperations().createElement(tagName); + }; - // @implements PathReference + Renderer.prototype._renderRoot = function _renderRoot(root) { + var roots = this._roots; - CachedReference.prototype.value = function value() { - var tag = this.tag; - var _lastRevision = this._lastRevision; - var _lastValue = this._lastValue; + roots.push(root); - if (!_lastRevision || !tag.validate(_lastRevision)) { - _lastValue = this._lastValue = this.compute(); - this._lastRevision = tag.value(); + if (roots.length === 1) { + register(this); } - return _lastValue; + this._renderRootsTransaction(); }; - // @abstract compute() - return CachedReference; - })(EmberPathReference); + Renderer.prototype._renderRoots = function _renderRoots() { + var roots = this._roots; + var env = this._env; + var removedRoots = this._removedRoots; - exports.CachedReference = CachedReference; + var globalShouldReflush = undefined, + initialRootsLength = undefined; - var RootReference = (function (_ConstReference) { - babelHelpers.inherits(RootReference, _ConstReference); + do { + env.begin(); - function RootReference(value) { - _ConstReference.call(this, value); - this.children = new _emberUtils.EmptyObject(); - } + // ensure that for the first iteration of the loop + // each root is processed + initialRootsLength = roots.length; + globalShouldReflush = false; - RootReference.prototype.get = function get(propertyKey) { - var ref = this.children[propertyKey]; + for (var i = 0; i < roots.length; i++) { + var root = roots[i]; - if (!ref) { - ref = this.children[propertyKey] = new RootPropertyReference(this.inner, propertyKey); - } + if (root.destroyed) { + // add to the list of roots to be removed + // they will be removed from `this._roots` later + removedRoots.push(root); - return ref; - }; + // skip over roots that have been marked as destroyed + continue; + } - return RootReference; - })(_glimmerReference.ConstReference); + var shouldReflush = root.shouldReflush; - exports.RootReference = RootReference; + // when processing non-initial reflush loops, + // do not process more roots than needed + if (i >= initialRootsLength && !shouldReflush) { + continue; + } - var TwoWayFlushDetectionTag = undefined; + root.options.alwaysRevalidate = shouldReflush; + // track shouldReflush based on this roots render result + shouldReflush = root.shouldReflush = _emberMetal.runInTransaction(root, 'render'); - if (false || false) { - TwoWayFlushDetectionTag = (function () { - function _class(tag, key, ref) { - this.tag = tag; - this.parent = null; - this.key = key; - this.ref = ref; + // globalShouldReflush should be `true` if *any* of + // the roots need to reflush + globalShouldReflush = globalShouldReflush || shouldReflush; + } + + this._lastRevision = _glimmerReference.CURRENT_TAG.value(); + + env.commit(); + } while (globalShouldReflush || roots.length > initialRootsLength); + + // remove any roots that were destroyed during this transaction + while (removedRoots.length) { + var root = removedRoots.pop(); + + var rootIndex = roots.indexOf(root); + roots.splice(rootIndex, 1); } - _class.prototype.value = function value() { - return this.tag.value(); - }; + if (this._roots.length === 0) { + deregister(this); + } + }; - _class.prototype.validate = function validate(ticket) { - var parent = this.parent; - var key = this.key; + Renderer.prototype._renderRootsTransaction = function _renderRootsTransaction() { + if (this._isRenderingRoots) { + // currently rendering roots, a new root was added and will + // be processed by the existing _renderRoots invocation + return; + } - var isValid = this.tag.validate(ticket); + // used to prevent calling _renderRoots again (see above) + // while we are actively rendering roots + this._isRenderingRoots = true; - if (isValid && parent) { - _emberMetal.didRender(parent, key, this.ref); + var completedWithoutError = false; + try { + this._renderRoots(); + completedWithoutError = true; + } finally { + if (!completedWithoutError) { + this._lastRevision = _glimmerReference.CURRENT_TAG.value(); } + this._isRenderingRoots = false; + } + }; - return isValid; - }; + Renderer.prototype._clearAllRoots = function _clearAllRoots() { + var roots = this._roots; + for (var i = 0; i < roots.length; i++) { + var root = roots[i]; + root.destroy(); + } - _class.prototype.didCompute = function didCompute(parent) { - this.parent = parent; - _emberMetal.didRender(parent, this.key, this.ref); - }; + this._removedRoots.length = 0; + this._roots = null; - return _class; - })(); - } + // if roots were present before destroying + // deregister this renderer instance + if (roots.length) { + deregister(this); + } + }; - var PropertyReference = (function (_CachedReference) { - babelHelpers.inherits(PropertyReference, _CachedReference); + Renderer.prototype._scheduleRevalidate = function _scheduleRevalidate() { + backburner.scheduleOnce('render', this, this._revalidate); + }; - function PropertyReference() { - _CachedReference.apply(this, arguments); - } + Renderer.prototype._isValid = function _isValid() { + return this._destroyed || this._roots.length === 0 || _glimmerReference.CURRENT_TAG.validate(this._lastRevision); + }; - PropertyReference.create = function create(parentReference, propertyKey) { - if (_glimmerReference.isConst(parentReference)) { - return new RootPropertyReference(parentReference.value(), propertyKey); - } else { - return new NestedPropertyReference(parentReference, propertyKey); + Renderer.prototype._revalidate = function _revalidate() { + if (this._isValid()) { + return; } + this._renderRootsTransaction(); }; - PropertyReference.prototype.get = function get(key) { - return new NestedPropertyReference(this, key); - }; + return Renderer; + })(); - return PropertyReference; - })(CachedReference); + var InertRenderer = (function (_Renderer) { + babelHelpers.inherits(InertRenderer, _Renderer); - exports.PropertyReference = PropertyReference; + function InertRenderer() { + _Renderer.apply(this, arguments); + } - var RootPropertyReference = (function (_PropertyReference) { - babelHelpers.inherits(RootPropertyReference, _PropertyReference); + InertRenderer.create = function create(_ref) { + var env = _ref.env; + var rootTemplate = _ref.rootTemplate; + var _viewRegistry = _ref._viewRegistry; - function RootPropertyReference(parentValue, propertyKey) { - _PropertyReference.call(this); + return new this(env, rootTemplate, _viewRegistry, false); + }; - this._parentValue = parentValue; - this._propertyKey = propertyKey; + InertRenderer.prototype.getElement = function getElement(view) { + throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); + }; - if (false || false) { - this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); - } else { - this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); - } + return InertRenderer; + })(Renderer); - if (false) { - _emberMetal.watchKey(parentValue, propertyKey); - } - } + exports.InertRenderer = InertRenderer; - RootPropertyReference.prototype.compute = function compute() { - var _parentValue = this._parentValue; - var _propertyKey = this._propertyKey; + var InteractiveRenderer = (function (_Renderer2) { + babelHelpers.inherits(InteractiveRenderer, _Renderer2); - if (false || false) { - this.tag.didCompute(_parentValue); - } + function InteractiveRenderer() { + _Renderer2.apply(this, arguments); + } - return _emberMetal.get(_parentValue, _propertyKey); + InteractiveRenderer.create = function create(_ref2) { + var env = _ref2.env; + var rootTemplate = _ref2.rootTemplate; + var _viewRegistry = _ref2._viewRegistry; + + return new this(env, rootTemplate, _viewRegistry, true); }; - RootPropertyReference.prototype[UPDATE] = function (value) { - _emberMetal.set(this._parentValue, this._propertyKey, value); + InteractiveRenderer.prototype.getElement = function getElement(view) { + return _emberViews.getViewElement(view); }; - return RootPropertyReference; - })(PropertyReference); + return InteractiveRenderer; + })(Renderer); - exports.RootPropertyReference = RootPropertyReference; + exports.InteractiveRenderer = InteractiveRenderer; +}); +enifed('ember-glimmer/setup-registry', ['exports', 'ember-environment', 'container', 'ember-glimmer/renderer', 'ember-glimmer/dom', 'ember-glimmer/views/outlet', 'ember-glimmer/components/text_field', 'ember-glimmer/components/text_area', 'ember-glimmer/components/checkbox', 'ember-glimmer/components/link-to', 'ember-glimmer/component', 'ember-glimmer/templates/component', 'ember-glimmer/templates/root', 'ember-glimmer/templates/outlet', 'ember-glimmer/environment'], function (exports, _emberEnvironment, _container, _emberGlimmerRenderer, _emberGlimmerDom, _emberGlimmerViewsOutlet, _emberGlimmerComponentsText_field, _emberGlimmerComponentsText_area, _emberGlimmerComponentsCheckbox, _emberGlimmerComponentsLinkTo, _emberGlimmerComponent, _emberGlimmerTemplatesComponent, _emberGlimmerTemplatesRoot, _emberGlimmerTemplatesOutlet, _emberGlimmerEnvironment) { + 'use strict'; - var NestedPropertyReference = (function (_PropertyReference2) { - babelHelpers.inherits(NestedPropertyReference, _PropertyReference2); + exports.setupApplicationRegistry = setupApplicationRegistry; + exports.setupEngineRegistry = setupEngineRegistry; - function NestedPropertyReference(parentReference, propertyKey) { - _PropertyReference2.call(this); + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:-root'], ['template:-root']), + _templateObject2 = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']), + _templateObject3 = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - var parentReferenceTag = parentReference.tag; - var parentObjectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + function setupApplicationRegistry(registry) { + registry.injection('service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); + registry.injection('renderer', 'env', 'service:-glimmer-environment'); - this._parentReference = parentReference; - this._parentObjectTag = parentObjectTag; - this._propertyKey = propertyKey; + registry.register(_container.privatize(_templateObject), _emberGlimmerTemplatesRoot.default); + registry.injection('renderer', 'rootTemplate', _container.privatize(_templateObject)); - if (false || false) { - var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); - this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); - } else { - this.tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); - } + registry.register('renderer:-dom', _emberGlimmerRenderer.InteractiveRenderer); + registry.register('renderer:-inert', _emberGlimmerRenderer.InertRenderer); + + if (_emberEnvironment.environment.hasDOM) { + registry.injection('service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); } - NestedPropertyReference.prototype.compute = function compute() { - var _parentReference = this._parentReference; - var _parentObjectTag = this._parentObjectTag; - var _propertyKey = this._propertyKey; + registry.register('service:-dom-changes', { + create: function (_ref) { + var document = _ref.document; - var parentValue = _parentReference.value(); + return new _emberGlimmerDom.DOMChanges(document); + } + }); - _parentObjectTag.update(_emberMetal.tagForProperty(parentValue, _propertyKey)); + registry.register('service:-dom-tree-construction', { + create: function (_ref2) { + var document = _ref2.document; - if (typeof parentValue === 'string' && _propertyKey === 'length') { - return parentValue.length; + var Implementation = _emberEnvironment.environment.hasDOM ? _emberGlimmerDom.DOMTreeConstruction : _emberGlimmerDom.NodeDOMTreeConstruction; + return new Implementation(document); } + }); + } - if (typeof parentValue === 'object' && parentValue) { - if (false) { - _emberMetal.watchKey(parentValue, _propertyKey); - } + function setupEngineRegistry(registry) { + registry.register('view:-outlet', _emberGlimmerViewsOutlet.default); + registry.register('template:-outlet', _emberGlimmerTemplatesOutlet.default); + registry.injection('view:-outlet', 'template', 'template:-outlet'); - if (false || false) { - this.tag.didCompute(parentValue); - } + registry.injection('service:-dom-changes', 'document', 'service:-document'); + registry.injection('service:-dom-tree-construction', 'document', 'service:-document'); - return _emberMetal.get(parentValue, _propertyKey); - } else { - return undefined; - } - }; + registry.register(_container.privatize(_templateObject2), _emberGlimmerTemplatesComponent.default); - NestedPropertyReference.prototype[UPDATE] = function (value) { - var parent = this._parentReference.value(); - _emberMetal.set(parent, this._propertyKey, value); - }; + registry.register('service:-glimmer-environment', _emberGlimmerEnvironment.default); + registry.injection('template', 'env', 'service:-glimmer-environment'); - return NestedPropertyReference; - })(PropertyReference); + registry.optionsForType('helper', { instantiate: false }); - exports.NestedPropertyReference = NestedPropertyReference; + registry.register('component:-text-field', _emberGlimmerComponentsText_field.default); + registry.register('component:-text-area', _emberGlimmerComponentsText_area.default); + registry.register('component:-checkbox', _emberGlimmerComponentsCheckbox.default); + registry.register('component:link-to', _emberGlimmerComponentsLinkTo.default); + registry.register(_container.privatize(_templateObject3), _emberGlimmerComponent.default); + } +}); +enifed('ember-glimmer/syntax', ['exports', 'ember-glimmer/syntax/render', 'ember-glimmer/syntax/outlet', 'ember-glimmer/syntax/mount', 'ember-glimmer/syntax/dynamic-component', 'ember-glimmer/utils/bindings', 'ember-glimmer/syntax/-with-dynamic-vars', 'ember-glimmer/syntax/-in-element', 'ember-glimmer/syntax/input', 'ember-glimmer/syntax/-text-area', 'ember-metal'], function (exports, _emberGlimmerSyntaxRender, _emberGlimmerSyntaxOutlet, _emberGlimmerSyntaxMount, _emberGlimmerSyntaxDynamicComponent, _emberGlimmerUtilsBindings, _emberGlimmerSyntaxWithDynamicVars, _emberGlimmerSyntaxInElement, _emberGlimmerSyntaxInput, _emberGlimmerSyntaxTextArea, _emberMetal) { + 'use strict'; - var UpdatableReference = (function (_EmberPathReference2) { - babelHelpers.inherits(UpdatableReference, _EmberPathReference2); + exports.registerMacros = registerMacros; + exports.populateMacros = populateMacros; - function UpdatableReference(value) { - _EmberPathReference2.call(this); + function refineInlineSyntax(path, params, hash, builder) { + var name = path[0]; - this.tag = new _glimmerReference.DirtyableTag(); - this._value = value; + if (path.length > 1) { + return _emberGlimmerSyntaxDynamicComponent.closureComponentMacro(path, params, hash, null, null, builder); } - UpdatableReference.prototype.value = function value() { - return this._value; - }; + var symbolTable = builder.symbolTable; - UpdatableReference.prototype.update = function update(value) { - var _value = this._value; + var definition = undefined; + if (name.indexOf('-') > -1) { + definition = builder.env.getComponentDefinition(path, symbolTable); + } - if (value !== _value) { - this.tag.dirty(); - this._value = value; - } - }; + if (definition) { + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, null, null], symbolTable); + return true; + } - return UpdatableReference; - })(EmberPathReference); + return false; + } - exports.UpdatableReference = UpdatableReference; + function refineBlockSyntax(sexp, builder) { + var path = sexp[1]; + var params = sexp[2]; + var hash = sexp[3]; + var _default = sexp[4]; + var inverse = sexp[5]; + var name = path[0]; - var UpdatablePrimitiveReference = (function (_UpdatableReference) { - babelHelpers.inherits(UpdatablePrimitiveReference, _UpdatableReference); + if (path.length > 1) { + return _emberGlimmerSyntaxDynamicComponent.closureComponentMacro(path, params, hash, _default, inverse, builder); + } - function UpdatablePrimitiveReference() { - _UpdatableReference.apply(this, arguments); + if (name.indexOf('-') === -1) { + return false; } - UpdatablePrimitiveReference.prototype.get = function get() { - return _glimmerRuntime.UNDEFINED_REFERENCE; - }; + var symbolTable = builder.symbolTable; - return UpdatablePrimitiveReference; - })(UpdatableReference); + var definition = undefined; + if (name.indexOf('-') > -1) { + definition = builder.env.getComponentDefinition(path, symbolTable); + } - exports.UpdatablePrimitiveReference = UpdatablePrimitiveReference; + if (definition) { + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, _default, inverse], symbolTable); + return true; + } - var ConditionalReference = (function (_GlimmerConditionalReference) { - babelHelpers.inherits(ConditionalReference, _GlimmerConditionalReference); + return false; + } - ConditionalReference.create = function create(reference) { - if (_glimmerReference.isConst(reference)) { - var value = reference.value(); + var experimentalMacros = []; - if (_emberMetal.isProxy(value)) { - return new RootPropertyReference(value, 'isTruthy'); - } else { - return _glimmerRuntime.PrimitiveReference.create(_emberGlimmerUtilsToBool.default(value)); - } - } + // This is a private API to allow for expiremental macros + // to be created in user space. Registering a macro should + // should be done in an initializer. - return new ConditionalReference(reference); - }; + function registerMacros(macro) { + experimentalMacros.push(macro); + } - function ConditionalReference(reference) { - _GlimmerConditionalReference.call(this, reference); + function populateMacros(blocks, inlines) { + inlines.add('outlet', _emberGlimmerSyntaxOutlet.outletMacro); + inlines.add('component', _emberGlimmerSyntaxDynamicComponent.inlineComponentMacro); + inlines.add('render', _emberGlimmerSyntaxRender.renderMacro); + inlines.add('mount', _emberGlimmerSyntaxMount.mountMacro); + inlines.add('input', _emberGlimmerSyntaxInput.inputMacro); + inlines.add('textarea', _emberGlimmerSyntaxTextArea.textAreaMacro); + inlines.addMissing(refineInlineSyntax); + blocks.add('component', _emberGlimmerSyntaxDynamicComponent.blockComponentMacro); + blocks.add('-with-dynamic-vars', _emberGlimmerSyntaxWithDynamicVars._withDynamicVarsMacro); + blocks.add('-in-element', _emberGlimmerSyntaxInElement._inElementMacro); + blocks.addMissing(refineBlockSyntax); - this.objectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([reference.tag, this.objectTag]); + for (var i = 0; i < experimentalMacros.length; i++) { + var macro = experimentalMacros[i]; + macro(blocks, inlines); } - ConditionalReference.prototype.toBool = function toBool(predicate) { - if (_emberMetal.isProxy(predicate)) { - this.objectTag.update(_emberMetal.tagForProperty(predicate, 'isTruthy')); - return _emberMetal.get(predicate, 'isTruthy'); - } else { - this.objectTag.update(_emberMetal.tagFor(predicate)); - return _emberGlimmerUtilsToBool.default(predicate); - } - }; - - return ConditionalReference; - })(_glimmerRuntime.ConditionalReference); + experimentalMacros = []; - exports.ConditionalReference = ConditionalReference; + return { blocks: blocks, inlines: inlines }; + } +}); +enifed('ember-glimmer/syntax/-in-element', ['exports', '@glimmer/runtime', '@glimmer/util'], function (exports, _glimmerRuntime, _glimmerUtil) { + 'use strict'; - var SimpleHelperReference = (function (_CachedReference2) { - babelHelpers.inherits(SimpleHelperReference, _CachedReference2); + exports._inElementMacro = _inElementMacro; + var _BaselineSyntax$NestedBlock = _glimmerRuntime.BaselineSyntax.NestedBlock; + var defaultBlock = _BaselineSyntax$NestedBlock.defaultBlock; + var params = _BaselineSyntax$NestedBlock.params; + var hash = _BaselineSyntax$NestedBlock.hash; - SimpleHelperReference.create = function create(helper, args) { - if (_glimmerReference.isConst(args)) { - var positional = args.positional; - var named = args.named; + function _inElementMacro(sexp, builder) { + var block = defaultBlock(sexp); + var args = _glimmerRuntime.compileArgs(params(sexp), hash(sexp), builder); - var positionalValue = positional.value(); - var namedValue = named.value(); + builder.putArgs(args); + builder.test('simple'); - var result = helper(positionalValue, namedValue); + builder.labelled(null, function (b) { + b.jumpUnless('END'); + b.pushRemoteElement(); + b.evaluate(_glimmerUtil.unwrap(block)); + b.popRemoteElement(); + }); + } +}); +enifed('ember-glimmer/syntax/-text-area', ['exports', 'ember-glimmer/utils/bindings'], function (exports, _emberGlimmerUtilsBindings) { + 'use strict'; - if (result === null) { - return _glimmerRuntime.NULL_REFERENCE; - } else if (result === undefined) { - return _glimmerRuntime.UNDEFINED_REFERENCE; - } else if (typeof result === 'object') { - return new RootReference(result); - } else { - return _glimmerRuntime.PrimitiveReference.create(result); - } - } else { - return new SimpleHelperReference(helper, args); - } - }; + exports.textAreaMacro = textAreaMacro; - function SimpleHelperReference(helper, args) { - _CachedReference2.call(this); + function textAreaMacro(path, params, hash, builder) { + var definition = builder.env.getComponentDefinition(['-text-area'], builder.symbolTable); + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; + } +}); +enifed('ember-glimmer/syntax/-with-dynamic-vars', ['exports', '@glimmer/runtime', '@glimmer/util'], function (exports, _glimmerRuntime, _glimmerUtil) { + 'use strict'; - this.tag = args.tag; - this.helper = helper; - this.args = args; - } + exports._withDynamicVarsMacro = _withDynamicVarsMacro; + var _BaselineSyntax$NestedBlock = _glimmerRuntime.BaselineSyntax.NestedBlock; + var defaultBlock = _BaselineSyntax$NestedBlock.defaultBlock; + var params = _BaselineSyntax$NestedBlock.params; + var hash = _BaselineSyntax$NestedBlock.hash; - SimpleHelperReference.prototype.compute = function compute() { - var helper = this.helper; - var _args = this.args; - var positional = _args.positional; - var named = _args.named; + function _withDynamicVarsMacro(sexp, builder) { + var block = defaultBlock(sexp); + var args = _glimmerRuntime.compileArgs(params(sexp), hash(sexp), builder); - var positionalValue = positional.value(); - var namedValue = named.value(); + builder.unit(function (b) { + b.putArgs(args); + b.pushDynamicScope(); + b.bindDynamicScope(args.named.keys); + b.evaluate(_glimmerUtil.unwrap(block)); + b.popDynamicScope(); + }); + } +}); +enifed('ember-glimmer/syntax/abstract-manager', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - return helper(positionalValue, namedValue); - }; + var AbstractManager = function AbstractManager() {}; - return SimpleHelperReference; - })(CachedReference); + exports.default = AbstractManager; +}); +enifed('ember-glimmer/syntax/curly-component', ['exports', 'ember-utils', '@glimmer/runtime', 'ember-glimmer/utils/bindings', 'ember-glimmer/component', 'ember-metal', 'ember-views', 'ember-glimmer/utils/process-args', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _emberUtils, _glimmerRuntime, _emberGlimmerUtilsBindings, _emberGlimmerComponent, _emberMetal, _emberViews, _emberGlimmerUtilsProcessArgs, _container, _emberGlimmerSyntaxAbstractManager) { + 'use strict'; - exports.SimpleHelperReference = SimpleHelperReference; + exports.validatePositionalParameters = validatePositionalParameters; - var ClassBasedHelperReference = (function (_CachedReference3) { - babelHelpers.inherits(ClassBasedHelperReference, _CachedReference3); + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['template:components/-default'], ['template:components/-default']); - ClassBasedHelperReference.create = function create(helperClass, vm, args) { - var instance = helperClass.create(); - vm.newDestroyable(instance); - return new ClassBasedHelperReference(instance, args); - }; + var DEFAULT_LAYOUT = _container.privatize(_templateObject); - function ClassBasedHelperReference(instance, args) { - _CachedReference3.call(this); + function processComponentInitializationAssertions(component, props) {} - this.tag = _glimmerReference.combine([instance[_emberGlimmerHelper.RECOMPUTE_TAG], args.tag]); - this.instance = instance; - this.args = args; + function validatePositionalParameters(named, positional, positionalParamsDefinition) {} + + function aliasIdToElementId(args, props) { + if (args.named.has('id')) { + props.elementId = props.id; } + } - ClassBasedHelperReference.prototype.compute = function compute() { - var instance = this.instance; - var _args2 = this.args; - var positional = _args2.positional; - var named = _args2.named; + // We must traverse the attributeBindings in reverse keeping track of + // what has already been applied. This is essentially refining the concated + // properties applying right to left. + function applyAttributeBindings(element, attributeBindings, component, operations) { + var seen = []; + var i = attributeBindings.length - 1; - var positionalValue = positional.value(); - var namedValue = named.value(); + while (i !== -1) { + var binding = attributeBindings[i]; + var parsed = _emberGlimmerUtilsBindings.AttributeBinding.parse(binding); + var attribute = parsed[1]; - return instance.compute(positionalValue, namedValue); - }; + if (seen.indexOf(attribute) === -1) { + seen.push(attribute); + _emberGlimmerUtilsBindings.AttributeBinding.install(element, component, parsed, operations); + } - return ClassBasedHelperReference; - })(CachedReference); + i--; + } - exports.ClassBasedHelperReference = ClassBasedHelperReference; + if (seen.indexOf('id') === -1) { + operations.addStaticAttribute(element, 'id', component.elementId); + } - var InternalHelperReference = (function (_CachedReference4) { - babelHelpers.inherits(InternalHelperReference, _CachedReference4); + if (seen.indexOf('style') === -1) { + _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); + } + } - function InternalHelperReference(helper, args) { - _CachedReference4.call(this); + function NOOP() {} - this.tag = args.tag; - this.helper = helper; + var ComponentStateBucket = (function () { + function ComponentStateBucket(environment, component, args, finalizer) { + this.environment = environment; + this.component = component; + this.classRef = null; this.args = args; + this.argsRevision = args.tag.value(); + this.finalizer = finalizer; } - // @implements PathReference + ComponentStateBucket.prototype.destroy = function destroy() { + var component = this.component; + var environment = this.environment; - InternalHelperReference.prototype.compute = function compute() { - var helper = this.helper; - var args = this.args; + if (environment.isInteractive) { + component.trigger('willDestroyElement'); + component.trigger('willClearRender'); + } - return helper(args); + environment.destroyedComponents.push(component); }; - return InternalHelperReference; - })(CachedReference); - - exports.InternalHelperReference = InternalHelperReference; - - var UnboundReference = (function (_ConstReference2) { - babelHelpers.inherits(UnboundReference, _ConstReference2); - - function UnboundReference() { - _ConstReference2.apply(this, arguments); - } - - UnboundReference.create = function create(value) { - if (value === null) { - return _glimmerRuntime.NULL_REFERENCE; - } else if (value === undefined) { - return _glimmerRuntime.UNDEFINED_REFERENCE; - } else if (typeof value === 'object') { - return new UnboundReference(value); - } else { - return _glimmerRuntime.PrimitiveReference.create(value); - } - }; + ComponentStateBucket.prototype.finalize = function finalize() { + var finalizer = this.finalizer; - UnboundReference.prototype.get = function get(key) { - return new UnboundReference(_emberMetal.get(this.inner, key)); + finalizer(); + this.finalizer = NOOP; }; - return UnboundReference; - })(_glimmerReference.ConstReference); + return ComponentStateBucket; + })(); - exports.UnboundReference = UnboundReference; -}); -enifed('ember-glimmer/utils/string', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ + function initialRenderInstrumentDetails(component) { + return component.instrumentDetails({ initialRender: true }); + } - 'use strict'; + function rerenderInstrumentDetails(component) { + return component.instrumentDetails({ initialRender: false }); + } - exports.getSafeString = getSafeString; - exports.escapeExpression = escapeExpression; - exports.htmlSafe = htmlSafe; - exports.isHTMLSafe = isHTMLSafe; + var CurlyComponentManager = (function (_AbstractManager) { +babelHelpers.inherits(CurlyComponentManager, _AbstractManager); - var SafeString = (function () { - function SafeString(string) { - this.string = string; + function CurlyComponentManager() { + _AbstractManager.apply(this, arguments); } - SafeString.prototype.toString = function toString() { - return '' + this.string; - }; + CurlyComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { + if (definition.ComponentClass) { + validatePositionalParameters(args.named, args.positional.values, definition.ComponentClass.class.positionalParams); + } - SafeString.prototype.toHTML = function toHTML() { - return this.toString(); + return _emberGlimmerUtilsProcessArgs.gatherArgs(args, definition); }; - return SafeString; - })(); - - exports.SafeString = SafeString; + CurlyComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, callerSelfRef, hasBlock) { - function getSafeString() { + var parentView = dynamicScope.view; - return SafeString; - } + var factory = definition.ComponentClass; - var escape = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - // jscs:disable - "'": ''', - // jscs:enable - '`': '`', - '=': '=' - }; + var processedArgs = _emberGlimmerUtilsProcessArgs.ComponentArgs.create(args); - var possible = /[&<>"'`=]/; - var badChars = /[&<>"'`=]/g; + var _processedArgs$value = processedArgs.value(); - function escapeChar(chr) { - return escape[chr]; - } + var props = _processedArgs$value.props; - function escapeExpression(string) { - if (typeof string !== 'string') { - // don't escape SafeStrings, since they're already safe - if (string && string.toHTML) { - return string.toHTML(); - } else if (string == null) { - return ''; - } else if (!string) { - return string + ''; - } + aliasIdToElementId(args, props); - // Force a string conversion as this will be done by the append regardless and - // the regex test will do this transparently behind the scenes, causing issues if - // an object's to string has escaped characters in it. - string = '' + string; - } + props.parentView = parentView; + props[_emberGlimmerComponent.HAS_BLOCK] = hasBlock; - if (!possible.test(string)) { - return string; - } - return string.replace(badChars, escapeChar); - } + props._targetObject = callerSelfRef.value(); - /** - Mark a string as safe for unescaped output with Ember templates. If you - return HTML from a helper, use this function to - ensure Ember's rendering layer does not escape the HTML. - - ```javascript - Ember.String.htmlSafe('
    someString
    ') - ``` - - @method htmlSafe - @for Ember.String - @static - @return {Handlebars.SafeString} A string that will not be HTML escaped by Handlebars. - @public - */ + var component = factory.create(props); - function htmlSafe(str) { - if (str === null || str === undefined) { - str = ''; - } else if (typeof str !== 'string') { - str = '' + str; - } - return new SafeString(str); - } + var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - /** - Detects if a string was decorated using `Ember.String.htmlSafe`. - - ```javascript - var plainString = 'plain string', - safeString = Ember.String.htmlSafe('
    someValue
    '); - - Ember.String.isHTMLSafe(plainString); // false - Ember.String.isHTMLSafe(safeString); // true - ``` - - @method isHTMLSafe - @for Ember.String - @static - @return {Boolean} `true` if the string was decorated with `htmlSafe`, `false` otherwise. - @public - */ + dynamicScope.view = component; - function isHTMLSafe(str) { - return str && typeof str.toHTML === 'function'; - } -}); -enifed('ember-glimmer/utils/to-bool', ['exports', 'ember-runtime', 'ember-metal'], function (exports, _emberRuntime, _emberMetal) { - 'use strict'; + if (parentView !== null) { + parentView.appendChild(component); + } - exports.default = toBool; + // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components + if (component.tagName === '') { + if (environment.isInteractive) { + component.trigger('willRender'); + } - function toBool(predicate) { - if (!predicate) { - return false; - } + component._transitionTo('hasElement'); - if (predicate === true) { - return true; - } + if (environment.isInteractive) { + component.trigger('willInsertElement'); + } + } - if (_emberRuntime.isArray(predicate)) { - return _emberMetal.get(predicate, 'length') !== 0; - } + var bucket = new ComponentStateBucket(environment, component, processedArgs, finalizer); - return true; - } -}); -enifed('ember-glimmer/views/outlet', ['exports', 'ember-utils', 'glimmer-reference', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _glimmerReference, _emberEnvironment, _emberMetal) { - /** - @module ember - @submodule ember-glimmer - */ - 'use strict'; + if (args.named.has('class')) { + bucket.classRef = args.named.get('class'); + } - var OutletStateReference = (function () { - function OutletStateReference(outletView) { - this.outletView = outletView; - this.tag = outletView._tag; - } + processComponentInitializationAssertions(component, props); - // So this is a relic of the past that SHOULD go away - // in 3.0. Preferably it is deprecated in the release that - // follows the Glimmer release. + if (environment.isInteractive && component.tagName !== '') { + component.trigger('willRender'); + } - OutletStateReference.prototype.get = function get(key) { - return new ChildOutletStateReference(this, key); + return bucket; }; - OutletStateReference.prototype.value = function value() { - return this.outletView.outletState; - }; + CurlyComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + var template = definition.template; + if (!template) { + var component = bucket.component; - OutletStateReference.prototype.getOrphan = function getOrphan(name) { - return new OrphanedOutletStateReference(this, name); + template = this.templateFor(component, env); + } + return env.getCompiledBlock(CurlyComponentLayoutCompiler, template); }; - OutletStateReference.prototype.update = function update(state) { - this.outletView.setOutletState(state); + CurlyComponentManager.prototype.templateFor = function templateFor(component, env) { + var Template = _emberMetal.get(component, 'layout'); + var owner = component[_emberUtils.OWNER]; + if (Template) { + return env.getTemplate(Template, owner); + } + var layoutName = _emberMetal.get(component, 'layoutName'); + if (layoutName) { + var template = owner.lookup('template:' + layoutName); + if (template) { + return template; + } + } + return owner.lookup(DEFAULT_LAYOUT); }; - return OutletStateReference; - })(); + CurlyComponentManager.prototype.getSelf = function getSelf(_ref) { + var component = _ref.component; - var OrphanedOutletStateReference = (function (_OutletStateReference) { - babelHelpers.inherits(OrphanedOutletStateReference, _OutletStateReference); + return component[_emberGlimmerComponent.ROOT_REF]; + }; - function OrphanedOutletStateReference(root, name) { - _OutletStateReference.call(this, root.outletView); - this.root = root; - this.name = name; - } + CurlyComponentManager.prototype.didCreateElement = function didCreateElement(_ref2, element, operations) { + var component = _ref2.component; + var classRef = _ref2.classRef; + var environment = _ref2.environment; - OrphanedOutletStateReference.prototype.value = function value() { - var rootState = this.root.value(); + _emberViews.setViewElement(component, element); - var orphans = rootState.outlets.main.outlets.__ember_orphans__; + var attributeBindings = component.attributeBindings; + var classNames = component.classNames; + var classNameBindings = component.classNameBindings; - if (!orphans) { - return null; + if (attributeBindings && attributeBindings.length) { + applyAttributeBindings(element, attributeBindings, component, operations); + } else { + operations.addStaticAttribute(element, 'id', component.elementId); + _emberGlimmerUtilsBindings.IsVisibleBinding.install(element, component, operations); } - var matched = orphans.outlets[this.name]; + if (classRef) { + operations.addDynamicAttribute(element, 'class', classRef); + } - if (!matched) { - return null; + if (classNames && classNames.length) { + classNames.forEach(function (name) { + operations.addStaticAttribute(element, 'class', name); + }); } - var state = new _emberUtils.EmptyObject(); - state[matched.render.outlet] = matched; - matched.wasUsed = true; - return { outlets: state }; - }; + if (classNameBindings && classNameBindings.length) { + classNameBindings.forEach(function (binding) { + _emberGlimmerUtilsBindings.ClassNameBinding.install(element, component, binding, operations); + }); + } - return OrphanedOutletStateReference; - })(OutletStateReference); + component._transitionTo('hasElement'); - var ChildOutletStateReference = (function () { - function ChildOutletStateReference(parent, key) { - this.parent = parent; - this.key = key; - this.tag = parent.tag; - } + if (environment.isInteractive) { + component.trigger('willInsertElement'); + } + }; - ChildOutletStateReference.prototype.get = function get(key) { - return new ChildOutletStateReference(this, key); + CurlyComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket, bounds) { + bucket.component[_emberGlimmerComponent.BOUNDS] = bounds; + bucket.finalize(); }; - ChildOutletStateReference.prototype.value = function value() { - return this.parent.value()[this.key]; + CurlyComponentManager.prototype.getTag = function getTag(_ref3) { + var component = _ref3.component; + + return component[_emberGlimmerComponent.DIRTY_TAG]; }; - return ChildOutletStateReference; - })(); + CurlyComponentManager.prototype.didCreate = function didCreate(_ref4) { + var component = _ref4.component; + var environment = _ref4.environment; - var OutletView = (function () { - OutletView.extend = function extend(injections) { - return (function (_OutletView) { - babelHelpers.inherits(_class, _OutletView); + if (environment.isInteractive) { + component._transitionTo('inDOM'); + component.trigger('didInsertElement'); + component.trigger('didRender'); + } + }; - function _class() { - _OutletView.apply(this, arguments); - } + CurlyComponentManager.prototype.update = function update(bucket, _, dynamicScope) { + var component = bucket.component; + var args = bucket.args; + var argsRevision = bucket.argsRevision; + var environment = bucket.environment; - _class.create = function create(options) { - if (options) { - return _OutletView.create.call(this, _emberUtils.assign({}, injections, options)); - } else { - return _OutletView.create.call(this, injections); - } - }; + bucket.finalizer = _emberMetal._instrumentStart('render.component', rerenderInstrumentDetails, component); - return _class; - })(OutletView); - }; + if (!args.tag.validate(argsRevision)) { + var _args$value = args.value(); - OutletView.reopenClass = function reopenClass(injections) { - _emberUtils.assign(this, injections); - }; + var attrs = _args$value.attrs; + var props = _args$value.props; - OutletView.create = function create(options) { - var _environment = options._environment; - var renderer = options.renderer; - var template = options.template; + bucket.argsRevision = args.tag.value(); - var owner = options[_emberUtils.OWNER]; - return new OutletView(_environment, renderer, owner, template); - }; + var oldAttrs = component.attrs; + var newAttrs = attrs; - function OutletView(_environment, renderer, owner, template) { - this._environment = _environment; - this.renderer = renderer; - this.owner = owner; - this.template = template; - this.outletState = null; - this._tag = new _glimmerReference.DirtyableTag(); - } + component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = true; + component.setProperties(props); + component[_emberGlimmerComponent.IS_DISPATCHING_ATTRS] = false; - OutletView.prototype.appendTo = function appendTo(selector) { - var env = this._environment || _emberEnvironment.environment; - var target = undefined; + _emberViews.dispatchLifeCycleHook(component, 'didUpdateAttrs', oldAttrs, newAttrs); + _emberViews.dispatchLifeCycleHook(component, 'didReceiveAttrs', oldAttrs, newAttrs); + } - if (env.hasDOM) { - target = typeof selector === 'string' ? document.querySelector(selector) : selector; - } else { - target = selector; + if (environment.isInteractive) { + component.trigger('willUpdate'); + component.trigger('willRender'); } + }; - _emberMetal.run.schedule('render', this.renderer, 'appendOutletView', this, target); + CurlyComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) { + bucket.finalize(); }; - OutletView.prototype.rerender = function rerender() {}; + CurlyComponentManager.prototype.didUpdate = function didUpdate(_ref5) { + var component = _ref5.component; + var environment = _ref5.environment; - OutletView.prototype.setOutletState = function setOutletState(state) { - this.outletState = { - outlets: { - main: state - }, - render: { - owner: undefined, - into: undefined, - outlet: 'main', - name: '-top-level', - controller: undefined, - ViewClass: undefined, - template: undefined - } - }; - this._tag.dirty(); + if (environment.isInteractive) { + component.trigger('didUpdate'); + component.trigger('didRender'); + } }; - OutletView.prototype.toReference = function toReference() { - return new OutletStateReference(this); + CurlyComponentManager.prototype.getDestructor = function getDestructor(stateBucket) { + return stateBucket; }; - OutletView.prototype.destroy = function destroy() {}; - - return OutletView; - })(); - - exports.default = OutletView; -}); -enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) { - 'use strict'; - - exports.default = alias; - exports.AliasedProperty = AliasedProperty; - - function alias(altKey) { - return new AliasedProperty(altKey); - } - - function AliasedProperty(altKey) { - this.isDescriptor = true; - this.altKey = altKey; - this._dependentKeys = [altKey]; - } - - AliasedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); + return CurlyComponentManager; + })(_emberGlimmerSyntaxAbstractManager.default); - AliasedProperty.prototype.setup = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (meta.peekWatching(keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; + var MANAGER = new CurlyComponentManager(); - AliasedProperty.prototype._addDependentKeyIfMissing = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (!meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - } - }; + var TopComponentManager = (function (_CurlyComponentManager) { +babelHelpers.inherits(TopComponentManager, _CurlyComponentManager); - AliasedProperty.prototype._removeDependentKeyIfAdded = function (obj, keyName) { - var meta = _emberMetalMeta.meta(obj); - if (meta.peekDeps(this.altKey, keyName)) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + function TopComponentManager() { + _CurlyComponentManager.apply(this, arguments); } - }; - - AliasedProperty.prototype.willWatch = AliasedProperty.prototype._addDependentKeyIfMissing; - AliasedProperty.prototype.didUnwatch = AliasedProperty.prototype._removeDependentKeyIfAdded; - AliasedProperty.prototype.teardown = AliasedProperty.prototype._removeDependentKeyIfAdded; - - AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) { - this._addDependentKeyIfMissing(obj, keyName); - return _emberMetalProperty_get.get(obj, this.altKey); - }; + TopComponentManager.prototype.create = function create(environment, definition, args, dynamicScope, currentScope, hasBlock) { + var component = definition.ComponentClass.create(); - AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) { - return _emberMetalProperty_set.set(obj, this.altKey, value); - }; + var finalizer = _emberMetal._instrumentStart('render.component', initialRenderInstrumentDetails, component); - AliasedProperty.prototype.readOnly = function () { - this.set = AliasedProperty_readOnlySet; - return this; - }; + dynamicScope.view = component; - function AliasedProperty_readOnlySet(obj, keyName, value) { - throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); - } + // We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components + if (component.tagName === '') { + if (environment.isInteractive) { + component.trigger('willRender'); + } - AliasedProperty.prototype.oneWay = function () { - this.set = AliasedProperty_oneWaySet; - return this; - }; + component._transitionTo('hasElement'); - function AliasedProperty_oneWaySet(obj, keyName, value) { - _emberMetalProperties.defineProperty(obj, keyName, null); - return _emberMetalProperty_set.set(obj, keyName, value); - } + if (environment.isInteractive) { + component.trigger('willInsertElement'); + } + } - // Backwards compatibility with Ember Data. - AliasedProperty.prototype._meta = undefined; - AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta; -}); -enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) { - 'use strict'; + processComponentInitializationAssertions(component, {}); - exports.bind = bind; + return new ComponentStateBucket(environment, component, args, finalizer); + }; - /** - @module ember - @submodule ember-metal - */ + return TopComponentManager; + })(CurlyComponentManager); - // .......................................................... - // BINDING - // + var ROOT_MANAGER = new TopComponentManager(); - function Binding(toPath, fromPath) { - // Configuration - this._from = fromPath; - this._to = toPath; - this._oneWay = undefined; + function tagName(vm) { + var tagName = vm.dynamicScope().view.tagName; - // State - this._direction = undefined; - this._readyToSync = undefined; - this._fromObj = undefined; - this._fromPath = undefined; - this._toObj = undefined; + return _glimmerRuntime.PrimitiveReference.create(tagName === '' ? null : tagName || 'div'); } - /** - @class Binding - @namespace Ember - @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding - @public - */ - - Binding.prototype = { - /** - This copies the Binding so it can be connected to another object. - @method copy - @return {Ember.Binding} `this` - @public - */ - copy: function () { - var copy = new Binding(this._to, this._from); - if (this._oneWay) { - copy._oneWay = true; - } - return copy; - }, - - // .......................................................... - // CONFIG - // - - /** - This will set `from` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method from - @param {String} path The property path to connect to. - @return {Ember.Binding} `this` - @public - */ - from: function (path) { - this._from = path; - return this; - }, - - /** - This will set the `to` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method to - @param {String|Tuple} path A property path or tuple. - @return {Ember.Binding} `this` - @public - */ - to: function (path) { - this._to = path; - return this; - }, - - /** - Configures the binding as one way. A one-way binding will relay changes - on the `from` side to the `to` side, but not the other way around. This - means that if you change the `to` side directly, the `from` side may have - a different value. - @method oneWay - @return {Ember.Binding} `this` - @public - */ - oneWay: function () { - this._oneWay = true; - return this; - }, + function ariaRole(vm) { + return vm.getSelf().get('ariaRole'); + } - /** - @method toString - @return {String} string representation of binding - @public - */ - toString: function () { - var oneWay = this._oneWay ? '[oneWay]' : ''; - return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; - }, + var CurlyComponentDefinition = (function (_ComponentDefinition) { +babelHelpers.inherits(CurlyComponentDefinition, _ComponentDefinition); - // .......................................................... - // CONNECT AND SYNC - // + function CurlyComponentDefinition(name, ComponentClass, template, args) { + _ComponentDefinition.call(this, name, MANAGER, ComponentClass); + this.template = template; + this.args = args; + } - /** - Attempts to connect this binding instance so that it can receive and relay - changes. This method will raise an exception if you have not set the - from/to properties yet. - @method connect - @param {Object} obj The root object for this binding. - @return {Ember.Binding} `this` - @public - */ - connect: function (obj) { + return CurlyComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - var fromObj = undefined, - fromPath = undefined, - possibleGlobal = undefined; + exports.CurlyComponentDefinition = CurlyComponentDefinition; - // If the binding's "from" path could be interpreted as a global, verify - // whether the path refers to a global or not by consulting `Ember.lookup`. - if (_emberMetalPath_cache.isGlobalPath(this._from)) { - var _name = _emberMetalPath_cache.getFirstKey(this._from); - possibleGlobal = _emberEnvironment.context.lookup[_name]; + var RootComponentDefinition = (function (_ComponentDefinition2) { +babelHelpers.inherits(RootComponentDefinition, _ComponentDefinition2); - if (possibleGlobal) { - fromObj = possibleGlobal; - fromPath = _emberMetalPath_cache.getTailPath(this._from); + function RootComponentDefinition(instance) { + _ComponentDefinition2.call(this, '-root', ROOT_MANAGER, { + class: instance.constructor, + create: function () { + return instance; } - } - - if (fromObj === undefined) { - fromObj = obj; - fromPath = this._from; - } + }); + this.template = undefined; + this.args = undefined; + } - _emberMetalProperty_set.trySet(obj, this._to, _emberMetalProperty_get.get(fromObj, fromPath)); + return RootComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - // Add an observer on the object to be notified when the binding should be updated. - _emberMetalObserver.addObserver(fromObj, fromPath, this, 'fromDidChange'); + exports.RootComponentDefinition = RootComponentDefinition; - // If the binding is a two-way binding, also set up an observer on the target. - if (!this._oneWay) { - _emberMetalObserver.addObserver(obj, this._to, this, 'toDidChange'); - } + var CurlyComponentLayoutCompiler = (function () { + function CurlyComponentLayoutCompiler(template) { + this.template = template; + } - _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect'); + CurlyComponentLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + builder.tag.dynamic(tagName); + builder.attrs.dynamic('role', ariaRole); + builder.attrs.static('class', 'ember-view'); + }; - fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); + return CurlyComponentLayoutCompiler; + })(); - this._readyToSync = true; - this._fromObj = fromObj; - this._fromPath = fromPath; - this._toObj = obj; + CurlyComponentLayoutCompiler.id = 'curly'; +}); +enifed('ember-glimmer/syntax/dynamic-component', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal) { + 'use strict'; - return this; - }, + exports.closureComponentMacro = closureComponentMacro; + exports.dynamicComponentMacro = dynamicComponentMacro; + exports.blockComponentMacro = blockComponentMacro; + exports.inlineComponentMacro = inlineComponentMacro; - /** - Disconnects the binding instance. Changes will no longer be relayed. You - will not usually need to call this method. - @method disconnect - @return {Ember.Binding} `this` - @public - */ - disconnect: function () { + function dynamicComponentFor(vm, symbolTable) { + var env = vm.env; + var args = vm.getArgs(); + var nameRef = args.positional.at(0); - // Remove an observer on the object so we're no longer notified of - // changes that should update bindings. - _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); + return new DynamicComponentReference({ nameRef: nameRef, env: env, symbolTable: symbolTable }); + } - // If the binding is two-way, remove the observer from the target as well. - if (!this._oneWay) { - _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); - } + function closureComponentMacro(path, params, hash, _default, inverse, builder) { + var definitionArgs = [[['get', path]], hash, _default, inverse]; + var args = [params, hash, _default, inverse]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - this._readyToSync = false; // Disable scheduled syncs... - return this; - }, + function dynamicComponentMacro(params, hash, _default, inverse, builder) { + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - // .......................................................... - // PRIVATE - // + function blockComponentMacro(sexp, builder) { + var params = sexp[2]; + var hash = sexp[3]; + var _default = sexp[4]; + var inverse = sexp[5]; - /* Called when the from side changes. */ - fromDidChange: function (target) { - this._scheduleSync('fwd'); - }, + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, _default, inverse]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - /* Called when the to side changes. */ - toDidChange: function (target) { - this._scheduleSync('back'); - }, + function inlineComponentMacro(path, params, hash, builder) { + var definitionArgs = [params.slice(0, 1), null, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, dynamicComponentFor, args, builder.symbolTable); + return true; + } - _scheduleSync: function (dir) { - var existingDir = this._direction; + var DynamicComponentReference = (function () { + function DynamicComponentReference(_ref) { + var nameRef = _ref.nameRef; + var env = _ref.env; + var symbolTable = _ref.symbolTable; + var args = _ref.args; - // If we haven't scheduled the binding yet, schedule it. - if (existingDir === undefined) { - _emberMetalRun_loop.default.schedule('sync', this, '_sync'); - this._direction = dir; - } + this.tag = nameRef.tag; + this.nameRef = nameRef; + this.env = env; + this.symbolTable = symbolTable; + this.args = args; + } - // If both a 'back' and 'fwd' sync have been scheduled on the same object, - // default to a 'fwd' sync so that it remains deterministic. - if (existingDir === 'back' && dir === 'fwd') { - this._direction = 'fwd'; - } - }, + DynamicComponentReference.prototype.value = function value() { + var env = this.env; + var nameRef = this.nameRef; + var symbolTable = this.symbolTable; - _sync: function () { - var log = _emberEnvironment.ENV.LOG_BINDINGS; + var nameOrDef = nameRef.value(); - var toObj = this._toObj; + if (typeof nameOrDef === 'string') { + var definition = env.getComponentDefinition([nameOrDef], symbolTable); - // Don't synchronize destroyed objects or disconnected bindings. - if (toObj.isDestroyed || !this._readyToSync) { - return; + return definition; + } else if (_glimmerRuntime.isComponentDefinition(nameOrDef)) { + return nameOrDef; + } else { + return null; } + }; - // Get the direction of the binding for the object we are - // synchronizing from. - var direction = this._direction; - - var fromObj = this._fromObj; - var fromPath = this._fromPath; - - this._direction = undefined; - - // If we're synchronizing from the remote object... - if (direction === 'fwd') { - var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); - if (log) { - _emberConsole.default.log(' ', this.toString(), '->', fromValue, fromObj); - } - if (this._oneWay) { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - } else { - _emberMetalObserver._suspendObserver(toObj, this._to, this, 'toDidChange', function () { - _emberMetalProperty_set.trySet(toObj, this._to, fromValue); - }); - } - // If we're synchronizing *to* the remote object. - } else if (direction === 'back') { - var toValue = _emberMetalProperty_get.get(toObj, this._to); - if (log) { - _emberConsole.default.log(' ', this.toString(), '<-', toValue, toObj); - } - _emberMetalObserver._suspendObserver(fromObj, fromPath, this, 'fromDidChange', function () { - _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); - }); - } - } - - }; + DynamicComponentReference.prototype.get = function get() { + return _glimmerReference.UNDEFINED_REFERENCE; + }; - function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { - var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; - var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; - var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; + return DynamicComponentReference; + })(); +}); +enifed('ember-glimmer/syntax/input', ['exports', 'ember-metal', 'ember-glimmer/utils/bindings', 'ember-glimmer/syntax/dynamic-component'], function (exports, _emberMetal, _emberGlimmerUtilsBindings, _emberGlimmerSyntaxDynamicComponent) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; - } + exports.inputMacro = inputMacro; - function mixinProperties(to, from) { - for (var key in from) { - if (from.hasOwnProperty(key)) { - to[key] = from[key]; - } - } + function buildTextFieldSyntax(params, hash, builder) { + var definition = builder.env.getComponentDefinition(['-text-field'], builder.symbolTable); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; } - mixinProperties(Binding, { - - /* - See `Ember.Binding.from`. - @method from - @static - */ - from: function (from) { - var C = this; - return new C(undefined, from); - }, - - /* - See `Ember.Binding.to`. - @method to - @static - */ - to: function (to) { - var C = this; - return new C(to, undefined); - } - }); /** - An `Ember.Binding` connects the properties of two objects so that whenever - the value of one property changes, the other property will be changed also. - - ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. + The `{{input}}` helper lets you create an HTML `` component. + It causes an `Ember.TextField` component to be rendered. For more info, + see the [Ember.TextField](/api/classes/Ember.TextField.html) docs and + the [templates guide](http://emberjs.com/guides/templates/input-helpers/). - You do not usually create Binding objects directly but instead describe - bindings in your class or object definition using automatic binding - detection. + ```handlebars + {{input value="987"}} + ``` - Properties ending in a `Binding` suffix will be converted to `Ember.Binding` - instances. The value of this property should be a string representing a path - to another object or a custom binding instance created using Binding helpers - (see "One Way Bindings"): + renders as: + ```HTML + ``` - valueBinding: "MyApp.someController.title" - ``` - - This will create a binding from `MyApp.someController.title` to the `value` - property of your object instance automatically. Now the two values will be - kept in sync. - ## One Way Bindings + ### Text field - One especially useful binding customization you can use is the `oneWay()` - helper. This helper tells Ember that you are only interested in - receiving changes on the object you are binding from. For example, if you - are binding to a preference and you want to be notified if the preference - has changed, but your object will not be changing the preference itself, you - could do: + If no `type` option is specified, a default of type 'text' is used. + Many of the standard HTML attributes may be passed to this helper. + + + + + + + + + + + +
    `readonly``required``autofocus`
    `value``placeholder``disabled`
    `size``tabindex``maxlength`
    `name``min``max`
    `pattern``accept``autocomplete`
    `autosave``formaction``formenctype`
    `formmethod``formnovalidate``formtarget`
    `height``inputmode``multiple`
    `step``width``form`
    `selectionDirection``spellcheck` 
    + When set to a quoted string, these values will be directly applied to the HTML + element. When left unquoted, these values will be bound to a property on the + template's current rendering context (most typically a controller instance). + A very common use of this helper is to bind the `value` of an input to an Object's attribute: - ``` - bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") + ```handlebars + Search: + {{input value=searchWord}} ``` - This way if the value of `MyApp.preferencesController.bigTitles` changes the - `bigTitles` property of your object will change also. However, if you - change the value of your `bigTitles` property, it will not update the - `preferencesController`. + In this example, the inital value in the `` will be set to the value of `searchWord`. + If the user changes the text, the value of `searchWord` will also be updated. - One way bindings are almost twice as fast to setup and twice as fast to - execute because the binding only has to worry about changes to one side. + ### Actions - You should consider using one way bindings anytime you have an object that - may be created frequently and you do not intend to change a property; only - to monitor it for changes (such as in the example above). + The helper can send multiple actions based on user events. + The action property defines the action which is sent when + the user presses the return key. - ## Adding Bindings Manually + ```handlebars + {{input action="submit"}} + ``` - All of the examples above show you how to configure a custom binding, but the - result of these customizations will be a binding template, not a fully active - Binding instance. The binding will actually become active only when you - instantiate the object the binding belongs to. It is useful, however, to - understand what actually happens when the binding is activated. + The helper allows some user events to send actions. - For a binding to function it must have at least a `from` property and a `to` - property. The `from` property path points to the object/key that you want to - bind from while the `to` path points to the object/key you want to bind to. + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-press` + * `key-up` - When you define a custom binding, you are usually describing the property - you want to bind from (such as `MyApp.someController.value` in the examples - above). When your object is created, it will automatically assign the value - you want to bind `to` based on the name of your binding key. In the - examples above, during init, Ember objects will effectively call - something like this on your binding: + For example, if you desire an action to be sent when the input is blurred, + you only need to setup the action name to the event name property. - ```javascript - binding = Ember.Binding.from("valueBinding").to("value"); + ```handlebars + {{input focus-out="alertMessage"}} ``` + See more about [Text Support Actions](/api/classes/Ember.TextField.html) - This creates a new binding instance based on the template you provide, and - sets the to path to the `value` property of the new object. Now that the - binding is fully configured with a `from` and a `to`, it simply needs to be - connected to become active. This is done through the `connect()` method: + ### Extending `Ember.TextField` + + Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing + arguments from the helper to `Ember.TextField`'s `create` method. You can extend the + capabilities of text inputs in your applications by reopening this class. For example, + if you are building a Bootstrap project where `data-*` attributes are used, you + can add one to the `TextField`'s `attributeBindings` property: ```javascript - binding.connect(this); + Ember.TextField.reopen({ + attributeBindings: ['data-error'] + }); ``` - Note that when you connect a binding you pass the object you want it to be - connected to. This object will be used as the root for both the from and - to side of the binding when inspecting relative paths. This allows the - binding to be automatically inherited by subclassed objects as well. + Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` + itself extends `Ember.Component`. Expect isolated component semantics, not + legacy 1.x view semantics (like `controller` being present). + See more about [Ember components](/api/classes/Ember.Component.html) - This also allows you to bind between objects using the paths you declare in - `from` and `to`: + ### Checkbox - ```javascript - // Example 1 - binding = Ember.Binding.from("App.someObject.value").to("value"); - binding.connect(this); + Checkboxes are special forms of the `{{input}}` helper. To create a ``: - // Example 2 - binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); - binding.connect(this); + ```handlebars + Emberize Everything: + {{input type="checkbox" name="isEmberized" checked=isEmberized}} ``` - Now that the binding is connected, it will observe both the from and to side - and relay changes. + This will bind checked state of this checkbox to the value of `isEmberized` -- if either one changes, + it will be reflected in the other. - If you ever needed to do so (you almost never will, but it is useful to - understand this anyway), you could manually create an active binding by - using the `Ember.bind()` helper method. (This is the same method used by - to setup your bindings on objects): + The following HTML attributes can be set via the helper: - ```javascript - Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); - ``` + * `checked` + * `disabled` + * `tabindex` + * `indeterminate` + * `name` + * `autofocus` + * `form` - Both of these code fragments have the same effect as doing the most friendly - form of binding creation like so: + ### Extending `Ember.Checkbox` - ```javascript - MyApp.anotherObject = Ember.Object.create({ - valueBinding: "MyApp.someController.value", + Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing + arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the + capablilties of checkbox inputs in your applications by reopening this class. For example, + if you wanted to add a css class to all checkboxes in your application: - // OTHER CODE FOR THIS OBJECT... + ```javascript + Ember.Checkbox.reopen({ + classNames: ['my-app-checkbox'] }); ``` - Ember's built in binding creation method makes it easy to automatically - create bindings for you. You should always use the highest-level APIs - available, even if you understand how it works underneath. - - @class Binding - @namespace Ember - @since Ember 0.9 + @method input + @for Ember.Templates.helpers + @param {Hash} options @public */ - // Ember.Binding = Binding; ES6TODO: where to put this? + function inputMacro(path, params, hash, builder) { + var keys = undefined; + var values = undefined; + var typeIndex = -1; + var valueIndex = -1; + + if (hash) { + keys = hash[0]; + values = hash[1]; + typeIndex = keys.indexOf('type'); + valueIndex = keys.indexOf('value'); + } + + if (!params) { + params = []; + } + + if (typeIndex > -1) { + var typeArg = values[typeIndex]; + if (!Array.isArray(typeArg)) { + if (typeArg === 'checkbox') { + + _emberGlimmerUtilsBindings.wrapComponentClassAttribute(hash); + + var definition = builder.env.getComponentDefinition(['-checkbox'], builder.symbolTable); + builder.component.static(definition, [params, hash, null, null], builder.symbolTable); + return true; + } else { + return buildTextFieldSyntax(params, hash, builder); + } + } + } else { + return buildTextFieldSyntax(params, hash, builder); + } + + return _emberGlimmerSyntaxDynamicComponent.dynamicComponentMacro(params, hash, null, null, builder); + } +}); +enifed('ember-glimmer/syntax/mount', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet, _container, _emberGlimmerSyntaxAbstractManager) { /** - Global helper method to create a new binding. Just pass the root object - along with a `to` and `from` path to create and connect the binding. + @module ember + @submodule ember-glimmer + */ + 'use strict'; + + exports.mountMacro = mountMacro; + + /** + The `{{mount}}` helper lets you embed a routeless engine in a template. + Mounting an engine will cause an instance to be booted and its `application` + template to be rendered. - @method bind - @for Ember - @param {Object} obj The root object of the transform. - @param {String} to The path to the 'to' side of the binding. - Must be relative to obj. - @param {String} from The path to the 'from' side of the binding. - Must be relative to obj or a global path. - @return {Ember.Binding} binding instance + For example, the following template mounts the `ember-chat` engine: + + ```handlebars + {{! application.hbs }} + {{mount "ember-chat"}} + ``` + + Currently, the engine name is the only argument that can be passed to + `{{mount}}`. + + @method mount + @for Ember.Templates.helpers + @category ember-application-engines @public */ - function bind(obj, to, from) { - return new Binding(to, from).connect(obj); + function mountMacro(path, params, hash, builder) { + + var name = params[0]; + + builder.component.static(new MountDefinition(name, builder.env), [params, hash, null, null], builder.symbolTable); + return true; } - exports.Binding = Binding; -}); -enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; + var MountManager = (function (_AbstractManager) { + babelHelpers.inherits(MountManager, _AbstractManager); - var Cache = (function () { - function Cache(limit, func, key, store) { - this.size = 0; - this.misses = 0; - this.hits = 0; - this.limit = limit; - this.func = func; - this.key = key; - this.store = store || new DefaultStore(); + function MountManager() { + _AbstractManager.apply(this, arguments); } - Cache.prototype.get = function get(obj) { - var key = this.key === undefined ? obj : this.key(obj); - var value = this.store.get(key); - if (value === undefined) { - this.misses++; - value = this._set(key, this.func(obj)); - } else if (value === _emberMetalMeta.UNDEFINED) { - this.hits++; - value = undefined; - } else { - this.hits++; - // nothing to translate - } - - return value; + MountManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; }; - Cache.prototype.set = function set(obj, value) { - var key = this.key === undefined ? obj : this.key(obj); - return this._set(key, value); - }; + MountManager.prototype.create = function create(environment, _ref, args, dynamicScope) { + var name = _ref.name; + var env = _ref.env; - Cache.prototype._set = function _set(key, value) { - if (this.limit > this.size) { - this.size++; - if (value === undefined) { - this.store.set(key, _emberMetalMeta.UNDEFINED); - } else { - this.store.set(key, value); - } - } + dynamicScope.outletState = _glimmerReference.UNDEFINED_REFERENCE; - return value; - }; + var engine = env.owner.buildChildEngineInstance(name); - Cache.prototype.purge = function purge() { - this.store.clear(); - this.size = 0; - this.hits = 0; - this.misses = 0; + engine.boot(); + + return { engine: engine }; }; - return Cache; - })(); + MountManager.prototype.layoutFor = function layoutFor(definition, _ref2, env) { + var engine = _ref2.engine; - exports.default = Cache; + var template = engine.lookup('template:application'); + return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, template); + }; - var DefaultStore = (function () { - function DefaultStore() { - this.data = new _emberUtils.EmptyObject(); - } + MountManager.prototype.getSelf = function getSelf(_ref3) { + var engine = _ref3.engine; - DefaultStore.prototype.get = function get(key) { - return this.data[key]; + var applicationFactory = engine[_container.FACTORY_FOR]('controller:application'); + var factory = applicationFactory || _emberRouting.generateControllerFactory(engine, 'application'); + return new _emberGlimmerUtilsReferences.RootReference(factory.create()); }; - DefaultStore.prototype.set = function set(key, value) { - this.data[key] = value; + MountManager.prototype.getTag = function getTag() { + return null; }; - DefaultStore.prototype.clear = function clear() { - this.data = new _emberUtils.EmptyObject(); + MountManager.prototype.getDestructor = function getDestructor(_ref4) { + var engine = _ref4.engine; + + return engine; }; - return DefaultStore; - })(); -}); -enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalWatch_path) { - 'use strict'; + MountManager.prototype.didCreateElement = function didCreateElement() {}; - exports.finishChains = finishChains; + MountManager.prototype.didRenderLayout = function didRenderLayout() {}; - var FIRST_KEY = /^([^\.]+)/; + MountManager.prototype.didCreate = function didCreate(state) {}; - function firstKey(path) { - return path.match(FIRST_KEY)[0]; - } + MountManager.prototype.update = function update(state, args, dynamicScope) {}; - function isObject(obj) { - return typeof obj === 'object' && obj; - } + MountManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - function isVolatile(obj) { - return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); - } + MountManager.prototype.didUpdate = function didUpdate(state) {}; - function ChainWatchers() { - // chain nodes that reference a key in this obj by key - // we only create ChainWatchers when we are going to add them - // so create this upfront - this.chains = new _emberUtils.EmptyObject(); - } + return MountManager; + })(_emberGlimmerSyntaxAbstractManager.default); - ChainWatchers.prototype = { - add: function (key, node) { - var nodes = this.chains[key]; - if (nodes === undefined) { - this.chains[key] = [node]; - } else { - nodes.push(node); - } - }, + var MOUNT_MANAGER = new MountManager(); - remove: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - nodes.splice(i, 1); - break; - } - } - } - }, + var MountDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(MountDefinition, _ComponentDefinition); - has: function (key, node) { - var nodes = this.chains[key]; - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] === node) { - return true; - } - } - } - return false; - }, + function MountDefinition(name, env) { + _ComponentDefinition.call(this, name, MOUNT_MANAGER, null); + this.env = env; + } - revalidateAll: function () { - for (var key in this.chains) { - this.notify(key, true, undefined); - } - }, + return MountDefinition; + })(_glimmerRuntime.ComponentDefinition); +}); +enifed('ember-glimmer/syntax/outlet', ['exports', 'ember-utils', '@glimmer/runtime', 'ember-metal', 'ember-glimmer/utils/references', 'ember-glimmer/syntax/abstract-manager', '@glimmer/reference'], function (exports, _emberUtils, _glimmerRuntime, _emberMetal, _emberGlimmerUtilsReferences, _emberGlimmerSyntaxAbstractManager, _glimmerReference) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - revalidate: function (key) { - this.notify(key, true, undefined); - }, + exports.outletMacro = outletMacro; - // key: the string key that is part of a path changed - // revalidate: boolean; the chains that are watching this value should revalidate - // callback: function that will be called with the object and path that - // will be/are invalidated by this key change, depending on - // whether the revalidate flag is passed - notify: function (key, revalidate, callback) { - var nodes = this.chains[key]; - if (nodes === undefined || nodes.length === 0) { - return; - } + function outletComponentFor(vm) { + var _vm$dynamicScope = vm.dynamicScope(); - var affected = undefined; + var outletState = _vm$dynamicScope.outletState; - if (callback) { - affected = []; - } + var args = vm.getArgs(); + var outletNameRef = undefined; + if (args.positional.length === 0) { + outletNameRef = new _glimmerReference.ConstReference('main'); + } else { + outletNameRef = args.positional.at(0); + } - for (var i = 0; i < nodes.length; i++) { - nodes[i].notify(revalidate, affected); - } + return new OutletComponentReference(outletNameRef, outletState); + } - if (callback === undefined) { - return; + /** + The `{{outlet}}` helper lets you specify where a child route will render in + your template. An important use of the `{{outlet}}` helper is in your + application's `application.hbs` file: + + ```handlebars + {{! app/templates/application.hbs }} + + {{my-header}} +
    + + {{outlet}} +
    + + {{my-footer}} + ``` + + See [templates guide](http://emberjs.com/guides/templates/the-application-template/) for + additional information on using `{{outlet}}` in `application.hbs`. + You may also specify a name for the `{{outlet}}`, which is useful when using more than one + `{{outlet}}` in a template: + + ```handlebars + {{outlet "menu"}} + {{outlet "sidebar"}} + {{outlet "main"}} + ``` + + Your routes can then render into a specific one of these `outlet`s by specifying the `outlet` + attribute in your `renderTemplate` function: + + ```javascript + // app/routes/menu.js + export default Ember.Route.extend({ + renderTemplate() { + this.render({ outlet: 'menu' }); } + }); + ``` + + See the [routing guide](http://emberjs.com/guides/routing/rendering-a-template/) for more + information on how your `route` interacts with the `{{outlet}}` helper. + Note: Your content __will not render__ if there isn't an `{{outlet}}` for it. + + @method outlet + @param {String} [name] + @for Ember.Templates.helpers + @public + */ - // we gather callbacks so we don't notify them during revalidation - for (var i = 0; i < affected.length; i += 2) { - var obj = affected[i]; - var path = affected[i + 1]; - callback(obj, path); - } + function outletMacro(path, params, hash, builder) { + if (!params) { + params = []; } - }; - - function makeChainWatcher() { - return new ChainWatchers(); + var definitionArgs = [params.slice(0, 1), null, null, null]; + builder.component.dynamic(definitionArgs, outletComponentFor, _glimmerRuntime.CompiledArgs.empty(), builder.symbolTable, null); + return true; } - function addChainWatcher(obj, keyName, node) { - var m = _emberMetalMeta.meta(obj); - m.writableChainWatchers(makeChainWatcher).add(keyName, node); - _emberMetalWatch_key.watchKey(obj, keyName, m); - } + var OutletComponentReference = (function () { + function OutletComponentReference(outletNameRef, parentOutletStateRef) { + this.outletNameRef = outletNameRef; + this.parentOutletStateRef = parentOutletStateRef; + this.definition = null; + this.lastState = null; + var outletStateTag = this.outletStateTag = new _glimmerReference.UpdatableTag(parentOutletStateRef.tag); + this.tag = _glimmerReference.combine([outletStateTag.tag, outletNameRef.tag]); + } - function removeChainWatcher(obj, keyName, node, _meta) { - if (!isObject(obj)) { - return; + OutletComponentReference.prototype.value = function value() { + var outletNameRef = this.outletNameRef; + var parentOutletStateRef = this.parentOutletStateRef; + var definition = this.definition; + var lastState = this.lastState; + + var outletName = outletNameRef.value(); + var outletStateRef = parentOutletStateRef.get('outlets').get(outletName); + var newState = this.lastState = outletStateRef.value(); + + this.outletStateTag.update(outletStateRef.tag); + + definition = revalidate(definition, lastState, newState); + + var hasTemplate = newState && newState.render.template; + + if (definition) { + return definition; + } else if (hasTemplate) { + return this.definition = new OutletComponentDefinition(outletName, newState.render.template); + } else { + return this.definition = null; + } + }; + + return OutletComponentReference; + })(); + + function revalidate(definition, lastState, newState) { + if (!lastState && !newState) { + return definition; } - var meta = _meta || _emberMetalMeta.peekMeta(obj); + if (!lastState && newState || lastState && !newState) { + return null; + } - if (!meta || !meta.readableChainWatchers()) { - return; + if (newState.render.template === lastState.render.template && newState.render.controller === lastState.render.controller) { + return definition; } - // make meta writable - meta = _emberMetalMeta.meta(obj); + return null; + } - meta.readableChainWatchers().remove(keyName, node); + function instrumentationPayload(_ref) { + var _ref$render = _ref.render; + var name = _ref$render.name; + var outlet = _ref$render.outlet; - _emberMetalWatch_key.unwatchKey(obj, keyName, meta); + return { object: name + ':' + outlet }; } - // A ChainNode watches a single key on an object. If you provide a starting - // value for the key then the node won't actually watch it. For a root node - // pass null for parent and key and object for value. - function ChainNode(parent, key, value) { - this._parent = parent; - this._key = key; + function NOOP() {} - // _watching is true when calling get(this._parent, this._key) will - // return the value of this node. - // - // It is false for the root of a chain (because we have no parent) - // and for global paths (because the parent node is the object with - // the observer on it) - this._watching = value === undefined; + var StateBucket = (function () { + function StateBucket(outletState) { + this.outletState = outletState; + this.instrument(); + } - this._chains = undefined; - this._object = undefined; - this.count = 0; + StateBucket.prototype.instrument = function instrument() { + this.finalizer = _emberMetal._instrumentStart('render.outlet', instrumentationPayload, this.outletState); + }; - this._value = value; - this._paths = {}; - if (this._watching) { - var obj = parent.value(); + StateBucket.prototype.finalize = function finalize() { + var finalizer = this.finalizer; - if (!isObject(obj)) { - return; - } + finalizer(); + this.finalizer = NOOP; + }; - this._object = obj; + return StateBucket; + })(); - addChainWatcher(this._object, this._key, this); - } - } + var OutletComponentManager = (function (_AbstractManager) { + babelHelpers.inherits(OutletComponentManager, _AbstractManager); - function lazyGet(obj, key) { - if (!isObject(obj)) { - return; + function OutletComponentManager() { + _AbstractManager.apply(this, arguments); } - var meta = _emberMetalMeta.peekMeta(obj); + OutletComponentManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - // check if object meant only to be a prototype - if (meta && meta.proto === obj) { - return; - } + OutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - // Use `get` if the return value is an EachProxy or an uncacheable value. - if (isVolatile(obj[key])) { - return _emberMetalProperty_get.get(obj, key); - // Otherwise attempt to get the cached value of the computed property - } else { - var cache = meta.readableCache(); - if (cache && key in cache) { - return cache[key]; - } - } - } + var outletStateReference = dynamicScope.outletState = dynamicScope.outletState.get('outlets').get(definition.outletName); + var outletState = outletStateReference.value(); + return new StateBucket(outletState); + }; - ChainNode.prototype = { - value: function () { - if (this._value === undefined && this._watching) { - var obj = this._parent.value(); - this._value = lazyGet(obj, this._key); - } - return this._value; - }, + OutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(OutletLayoutCompiler, definition.template); + }; - destroy: function () { - if (this._watching) { - var obj = this._object; - if (obj) { - removeChainWatcher(obj, this._key, this); - } - this._watching = false; // so future calls do nothing - } - }, + OutletComponentManager.prototype.getSelf = function getSelf(_ref2) { + var outletState = _ref2.outletState; - // copies a top level object only - copy: function (obj) { - var ret = new ChainNode(null, null, obj); - var paths = this._paths; - var path = undefined; + return new _emberGlimmerUtilsReferences.RootReference(outletState.render.controller); + }; - for (path in paths) { - // this check will also catch non-number vals. - if (paths[path] <= 0) { - continue; - } - ret.add(path); - } - return ret; - }, + OutletComponentManager.prototype.getTag = function getTag() { + return null; + }; - // called on the root node of a chain to setup watchers on the specified - // path. - add: function (path) { - var paths = this._paths; - paths[path] = (paths[path] || 0) + 1; + OutletComponentManager.prototype.getDestructor = function getDestructor() { + return null; + }; - var key = firstKey(path); - var tail = path.slice(key.length + 1); + OutletComponentManager.prototype.didRenderLayout = function didRenderLayout(bucket) { + bucket.finalize(); + }; - this.chain(key, tail); - }, + OutletComponentManager.prototype.didCreateElement = function didCreateElement() {}; - // called on the root node of a chain to teardown watcher on the specified - // path - remove: function (path) { - var paths = this._paths; - if (paths[path] > 0) { - paths[path]--; - } + OutletComponentManager.prototype.didCreate = function didCreate(state) {}; - var key = firstKey(path); - var tail = path.slice(key.length + 1); + OutletComponentManager.prototype.update = function update(bucket) {}; - this.unchain(key, tail); - }, + OutletComponentManager.prototype.didUpdateLayout = function didUpdateLayout(bucket) {}; - chain: function (key, path) { - var chains = this._chains; - var node = undefined; - if (chains === undefined) { - chains = this._chains = new _emberUtils.EmptyObject(); - } else { - node = chains[key]; - } + OutletComponentManager.prototype.didUpdate = function didUpdate(state) {}; - if (node === undefined) { - node = chains[key] = new ChainNode(this, key, undefined); - } + return OutletComponentManager; + })(_emberGlimmerSyntaxAbstractManager.default); - node.count++; // count chains... + var MANAGER = new OutletComponentManager(); - // chain rest of path if there is one - if (path) { - key = firstKey(path); - path = path.slice(key.length + 1); - node.chain(key, path); - } - }, + var TopLevelOutletComponentManager = (function (_OutletComponentManager) { + babelHelpers.inherits(TopLevelOutletComponentManager, _OutletComponentManager); - unchain: function (key, path) { - var chains = this._chains; - var node = chains[key]; + function TopLevelOutletComponentManager() { + _OutletComponentManager.apply(this, arguments); + } - // unchain rest of path first... - if (path && path.length > 1) { - var nextKey = firstKey(path); - var nextPath = path.slice(nextKey.length + 1); - node.unchain(nextKey, nextPath); - } + TopLevelOutletComponentManager.prototype.create = function create(environment, definition, args, dynamicScope) { - // delete node if needed. - node.count--; - if (node.count <= 0) { - chains[node._key] = undefined; - node.destroy(); - } - }, + return new StateBucket(dynamicScope.outletState.value()); + }; - notify: function (revalidate, affected) { - if (revalidate && this._watching) { - var parentValue = this._parent.value(); + TopLevelOutletComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(TopLevelOutletLayoutCompiler, definition.template); + }; - if (parentValue !== this._object) { - if (this._object) { - removeChainWatcher(this._object, this._key, this); - } + return TopLevelOutletComponentManager; + })(OutletComponentManager); - if (isObject(parentValue)) { - this._object = parentValue; - addChainWatcher(parentValue, this._key, this); - } else { - this._object = undefined; - } - } - this._value = undefined; - } + var TOP_LEVEL_MANAGER = new TopLevelOutletComponentManager(); - // then notify chains... - var chains = this._chains; - var node = undefined; - if (chains) { - for (var key in chains) { - node = chains[key]; - if (node !== undefined) { - node.notify(revalidate, affected); - } - } - } + var TopLevelOutletComponentDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(TopLevelOutletComponentDefinition, _ComponentDefinition); - if (affected && this._parent) { - this._parent.populateAffected(this._key, 1, affected); - } - }, + function TopLevelOutletComponentDefinition(instance) { + _ComponentDefinition.call(this, 'outlet', TOP_LEVEL_MANAGER, instance); + this.template = instance.template; + _emberUtils.generateGuid(this); + } - populateAffected: function (path, depth, affected) { - if (this._key) { - path = this._key + '.' + path; - } + return TopLevelOutletComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - if (this._parent) { - this._parent.populateAffected(path, depth + 1, affected); - } else { - if (depth > 1) { - affected.push(this.value(), path); - } - } + exports.TopLevelOutletComponentDefinition = TopLevelOutletComponentDefinition; + + var TopLevelOutletLayoutCompiler = (function () { + function TopLevelOutletLayoutCompiler(template) { + this.template = template; } - }; - function finishChains(obj) { - // We only create meta if we really have to - var m = _emberMetalMeta.peekMeta(obj); - if (m) { - m = _emberMetalMeta.meta(obj); + TopLevelOutletLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + builder.tag.static('div'); + builder.attrs.static('id', _emberUtils.guidFor(this)); + builder.attrs.static('class', 'ember-view'); + }; - // finish any current chains node watchers that reference obj - var chainWatchers = m.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidateAll(); - } - // ensure that if we have inherited any chains they have been - // copied onto our own meta. - if (m.readableChains()) { - m.writableChains(_emberMetalWatch_path.makeChainNode); - } + return TopLevelOutletLayoutCompiler; + })(); + + TopLevelOutletLayoutCompiler.id = 'top-level-outlet'; + + var OutletComponentDefinition = (function (_ComponentDefinition2) { + babelHelpers.inherits(OutletComponentDefinition, _ComponentDefinition2); + + function OutletComponentDefinition(outletName, template) { + _ComponentDefinition2.call(this, 'outlet', MANAGER, null); + this.outletName = outletName; + this.template = template; + _emberUtils.generateGuid(this); } - } - exports.removeChainWatcher = removeChainWatcher; - exports.ChainNode = ChainNode; -}); -enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) { - 'use strict'; + return OutletComponentDefinition; + })(_glimmerRuntime.ComponentDefinition); - exports.default = computed; + var OutletLayoutCompiler = (function () { + function OutletLayoutCompiler(template) { + this.template = template; + } + + OutletLayoutCompiler.prototype.compile = function compile(builder) { + builder.wrapLayout(this.template.asLayout()); + }; + + return OutletLayoutCompiler; + })(); + exports.OutletLayoutCompiler = OutletLayoutCompiler; + + OutletLayoutCompiler.id = 'outlet'; +}); +enifed('ember-glimmer/syntax/render', ['exports', '@glimmer/runtime', '@glimmer/reference', 'ember-metal', 'ember-glimmer/utils/references', 'ember-routing', 'ember-glimmer/syntax/outlet', 'container', 'ember-glimmer/syntax/abstract-manager'], function (exports, _glimmerRuntime, _glimmerReference, _emberMetal, _emberGlimmerUtilsReferences, _emberRouting, _emberGlimmerSyntaxOutlet, _container, _emberGlimmerSyntaxAbstractManager) { /** @module ember - @submodule ember-metal + @submodule ember-glimmer */ + 'use strict'; - var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; + exports.renderMacro = renderMacro; - /** - A computed property transforms an object literal with object's accessor function(s) 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 - `fullName` - by calling - `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter 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 - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', function() { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }) - }); - - let 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 by providing additional function (`set`) in hash argument. - If you try to set a computed property, it will try to invoke setter accessor function with the key and - value you want to set it to as arguments. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'), - lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - }, - set(key, value) { - let [firstName, lastName] = value.split(' '); - - this.set('firstName', firstName); - this.set('lastName', lastName); - - return value; - } - }) - }); - - let person = Person.create(); - - person.set('fullName', 'Peter Wagenet'); - person.get('firstName'); // 'Peter' - person.get('lastName'); // 'Wagenet' - ``` - - You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined. - - You can also mark computed property as `.readOnly()` and block all attempts to set it. - - ```javascript - let Person = Ember.Object.extend({ - // these will be supplied by `create` - firstName: null, - lastName: null, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - let firstName = this.get('firstName'); - let lastName = this.get('lastName'); - - return firstName + ' ' + lastName; - } - }).readOnly() - }); - - let person = Person.create(); - person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX> - ``` - - Additional resources: - - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md) - - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax) - - @class ComputedProperty - @namespace Ember - @public - */ - function ComputedProperty(config, opts) { - this.isDescriptor = true; - if (typeof config === 'function') { - this._getter = config; + function makeComponentDefinition(vm) { + var env = vm.env; + var args = vm.getArgs(); + var nameRef = args.positional.at(0); + + var templateName = nameRef.value(); + + var template = env.owner.lookup('template:' + templateName); + + var controllerName = undefined; + + if (args.named.has('controller')) { + var controllerNameRef = args.named.get('controller'); + + controllerName = controllerNameRef.value(); } else { - this._getter = config.get; - this._setter = config.set; + controllerName = templateName; } - this._dependentKeys = undefined; - this._suspended = undefined; - this._meta = undefined; - this._volatile = false; - this._dependentKeys = opts && opts.dependentKeys; - this._readOnly = false; + if (args.positional.length === 1) { + return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, SINGLETON_RENDER_MANAGER)); + } else { + return new _glimmerReference.ConstReference(new RenderDefinition(controllerName, template, env, NON_SINGLETON_RENDER_MANAGER)); + } } - ComputedProperty.prototype = new _emberMetalProperties.Descriptor(); - ComputedProperty.prototype.constructor = ComputedProperty; - - var ComputedPropertyPrototype = ComputedProperty.prototype; - /** - 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. + Calling ``{{render}}`` from within a template will insert another + template that matches the provided name. The inserted template will + access its properties on its own controller (rather than the controller + of the parent template). - It also does not automatically fire any change events. You must manually notify - any changes if you want to observe this property. + If a view class with the same name exists, the view class also will be used. + Note: A given controller may only be used *once* in your app in this manner. + A singleton instance of the controller will be created for you. - Dependency keys have no effect on volatile properties as they are for cache - invalidation and notification when cached value is invalidated. + Example: ```javascript - let outsideService = Ember.Object.extend({ - value: Ember.computed(function() { - return OutsideService.getValue(); - }).volatile() - }).create(); + App.NavigationController = Ember.Controller.extend({ + who: "world" + }); ``` - @method volatile - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.volatile = function () { - this._volatile = true; - 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 - let Person = Ember.Object.extend({ - guid: Ember.computed(function() { - return 'guid-guid-guid'; - }).readOnly() - }); + ```handlebars + + Hello, {{who}}. + ``` - let person = Person.create(); + ```handlebars + +

    My great app

    + {{render "navigation"}} + ``` - person.set('guid', 'new-guid'); // will throw an exception + ```html +

    My great app

    +
    + Hello, world. +
    ``` - @method readOnly - @return {Ember.ComputedProperty} this - @chainable - @public - */ - ComputedPropertyPrototype.readOnly = function () { - this._readOnly = true; - - return this; - }; - - /** - Sets the dependent keys on this computed property. Pass any number of - arguments containing key paths that this computed property depends on. + Optionally you may provide a second argument: a property path + that will be bound to the `model` property of the controller. + If a `model` property path is specified, then a new instance of the + controller will be created and `{{render}}` can be used multiple times + with the same name. - ```javascript - let President = Ember.Object.extend({ - fullName: Ember.computed(function() { - return this.get('firstName') + ' ' + this.get('lastName'); + For example if you had this `author` template. - // Tell Ember that this computed property depends on firstName - // and lastName - }).property('firstName', 'lastName') - }); + ```handlebars +
    + Written by {{firstName}} {{lastName}}. + Total Posts: {{postCount}} +
    + ``` - let president = President.create({ - firstName: 'Barack', - lastName: 'Obama' - }); + You could render it inside the `post` template using the `render` helper. - president.get('fullName'); // 'Barack Obama' + ```handlebars +
    +

    {{title}}

    +
    {{body}}
    + {{render "author" author}} +
    ``` - @method property - @param {String} path* zero or more property paths - @return {Ember.ComputedProperty} this - @chainable + @method render + @for Ember.Templates.helpers + @param {String} name + @param {Object?} context + @param {Hash} options + @return {String} HTML string @public */ - ComputedPropertyPrototype.property = function () { - var args = []; - function addArg(property) { - args.push(property); + function renderMacro(path, params, hash, builder) { + if (!params) { + params = []; } + var definitionArgs = [params.slice(0), hash, null, null]; + var args = [params.slice(1), hash, null, null]; + builder.component.dynamic(definitionArgs, makeComponentDefinition, args, builder.symbolTable); + return true; + } - for (var i = 0; i < arguments.length; i++) { - _emberMetalExpand_properties.default(arguments[i], addArg); + var AbstractRenderManager = (function (_AbstractManager) { + babelHelpers.inherits(AbstractRenderManager, _AbstractManager); + + function AbstractRenderManager() { + _AbstractManager.apply(this, arguments); } - this._dependentKeys = args; - return this; - }; + AbstractRenderManager.prototype.prepareArgs = function prepareArgs(definition, args) { + return args; + }; - /** - 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: Ember.computed(function() { - let personId = this.get('personId'); - return App.Person.create({ id: personId }); - }).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; - } - }; - - // invalidate cache when CP key changes - 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._volatile || this._suspended === obj) { - return; - } + /* abstract create(environment, definition, args, dynamicScope); */ - // don't create objects just to invalidate - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta || meta.source !== obj) { - return; - } + AbstractRenderManager.prototype.layoutFor = function layoutFor(definition, bucket, env) { + return env.getCompiledBlock(_emberGlimmerSyntaxOutlet.OutletLayoutCompiler, definition.template); + }; - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - cache[keyName] = undefined; - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - } - }; + AbstractRenderManager.prototype.getSelf = function getSelf(_ref) { + var controller = _ref.controller; - ComputedPropertyPrototype.get = function (obj, keyName) { - if (this._volatile) { - return this._getter.call(obj, keyName); - } + return new _emberGlimmerUtilsReferences.RootReference(controller); + }; - var meta = _emberMetalMeta.meta(obj); - var cache = meta.writableCache(); + AbstractRenderManager.prototype.getTag = function getTag() { + return null; + }; - var result = cache[keyName]; - if (result === _emberMetalMeta.UNDEFINED) { - return undefined; - } else if (result !== undefined) { - return result; - } + AbstractRenderManager.prototype.getDestructor = function getDestructor() { + return null; + }; - var ret = this._getter.call(obj, keyName); - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } + AbstractRenderManager.prototype.didCreateElement = function didCreateElement() {}; - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + AbstractRenderManager.prototype.didRenderLayout = function didRenderLayout() {}; - return ret; - }; + AbstractRenderManager.prototype.didCreate = function didCreate() {}; - ComputedPropertyPrototype.set = function computedPropertySetEntry(obj, keyName, value) { - if (this._readOnly) { - this._throwReadOnlyError(obj, keyName); - } + AbstractRenderManager.prototype.update = function update() {}; - if (!this._setter) { - return this.clobberSet(obj, keyName, value); - } + AbstractRenderManager.prototype.didUpdateLayout = function didUpdateLayout() {}; - if (this._volatile) { - return this.volatileSet(obj, keyName, value); - } + AbstractRenderManager.prototype.didUpdate = function didUpdate() {}; - return this.setWithSuspend(obj, keyName, value); - }; + return AbstractRenderManager; + })(_emberGlimmerSyntaxAbstractManager.default); - ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) { - throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj)); - }; + var SingletonRenderManager = (function (_AbstractRenderManager) { + babelHelpers.inherits(SingletonRenderManager, _AbstractRenderManager); - ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) { - var cachedValue = cacheFor(obj, keyName); - _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue); - _emberMetalProperty_set.set(obj, keyName, value); - return value; - }; + function SingletonRenderManager() { + _AbstractRenderManager.apply(this, arguments); + } - ComputedPropertyPrototype.volatileSet = function computedPropertyVolatileSet(obj, keyName, value) { - return this._setter.call(obj, keyName, value); - }; + SingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var name = definition.name; + var env = definition.env; - ComputedPropertyPrototype.setWithSuspend = function computedPropertySetWithSuspend(obj, keyName, value) { - var oldSuspended = this._suspended; - this._suspended = obj; - try { - return this._set(obj, keyName, value); - } finally { - this._suspended = oldSuspended; - } - }; + var controller = env.owner.lookup('controller:' + name) || _emberRouting.generateController(env.owner, name); - ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { - // cache requires own meta - var meta = _emberMetalMeta.meta(obj); - // either there is a writable cache or we need one to update - var cache = meta.writableCache(); - var hadCachedValue = false; - var cachedValue = undefined; - if (cache[keyName] !== undefined) { - if (cache[keyName] !== _emberMetalMeta.UNDEFINED) { - cachedValue = cache[keyName]; + if (dynamicScope.rootOutletState) { + dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); } - hadCachedValue = true; - } - var ret = this._setter.call(obj, keyName, value, cachedValue); + return { controller: controller }; + }; - // allows setter to return the same value that is cached already - if (hadCachedValue && cachedValue === ret) { - return ret; - } + return SingletonRenderManager; + })(AbstractRenderManager); - _emberMetalProperty_events.propertyWillChange(obj, keyName); + var SINGLETON_RENDER_MANAGER = new SingletonRenderManager(); - if (hadCachedValue) { - cache[keyName] = undefined; - } + var NonSingletonRenderManager = (function (_AbstractRenderManager2) { + babelHelpers.inherits(NonSingletonRenderManager, _AbstractRenderManager2); - if (!hadCachedValue) { - _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + function NonSingletonRenderManager() { + _AbstractRenderManager2.apply(this, arguments); } - if (ret === undefined) { - cache[keyName] = _emberMetalMeta.UNDEFINED; - } else { - cache[keyName] = ret; - } + NonSingletonRenderManager.prototype.create = function create(environment, definition, args, dynamicScope) { + var name = definition.name; + var env = definition.env; - _emberMetalProperty_events.propertyDidChange(obj, keyName); + var modelRef = args.positional.at(0); + var controllerFactory = env.owner[_container.FACTORY_FOR]('controller:' + name); - return ret; - }; + var factory = controllerFactory || _emberRouting.generateControllerFactory(env.owner, name); + var controller = factory.create({ model: modelRef.value() }); - /* called before property is overridden */ - ComputedPropertyPrototype.teardown = function (obj, keyName) { - if (this._volatile) { - return; - } - var meta = _emberMetalMeta.meta(obj); - var cache = meta.readableCache(); - if (cache && cache[keyName] !== undefined) { - _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); - cache[keyName] = undefined; - } - }; + if (dynamicScope.rootOutletState) { + dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); + } - /** - This helper returns a new property descriptor that wraps the passed - computed property function. You can use this helper to define properties - with mixins or via `Ember.defineProperty()`. - - If you pass a function as an argument, it will be used as a getter. A computed - property defined in this way might look like this: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', function() { - return `${this.get('firstName')} ${this.get('lastName')}`; - }) - }); - - let client = Person.create(); - - client.get('fullName'); // 'Betty Jones' - - client.set('lastName', 'Fuller'); - client.get('fullName'); // 'Betty Fuller' - ``` - - You can pass a hash with two functions, `get` and `set`, as an - argument to provide both a getter and setter: - - ```js - let Person = Ember.Object.extend({ - init() { - this._super(...arguments); - - this.firstName = 'Betty'; - this.lastName = 'Jones'; - }, - - fullName: Ember.computed('firstName', 'lastName', { - get(key) { - return `${this.get('firstName')} ${this.get('lastName')}`; - }, - set(key, value) { - let [firstName, lastName] = value.split(/\s+/); - this.setProperties({ firstName, lastName }); - return value; - } - }); - }) - - let client = Person.create(); - client.get('firstName'); // 'Betty' - - client.set('fullName', 'Carroll Fuller'); - client.get('firstName'); // 'Carroll' - ``` - - The `set` function should accept two parameters, `key` and `value`. The value - returned from `set` will be the new value of the property. - - _Note: This is the preferred way to define computed properties when writing third-party - libraries that depend on or use Ember, since there is no guarantee that the user - will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._ - - The alternative syntax, with prototype extensions, might look like: - - ```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 - */ + return { controller: controller }; + }; - function computed(func) { - var args = undefined; + NonSingletonRenderManager.prototype.update = function update(_ref2, args, dynamicScope) { + var controller = _ref2.controller; - if (arguments.length > 1) { - args = [].slice.call(arguments); - func = args.pop(); - } + controller.set('model', args.positional.at(0).value()); + }; - var cp = new ComputedProperty(func); + NonSingletonRenderManager.prototype.getDestructor = function getDestructor(_ref3) { + var controller = _ref3.controller; - if (args) { - cp.property.apply(cp, args); - } + return controller; + }; - return cp; - } + return NonSingletonRenderManager; + })(AbstractRenderManager); - /** - 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 = _emberMetalMeta.peekMeta(obj); - var cache = meta && meta.source === obj && meta.readableCache(); - var ret = cache && cache[key]; + var NON_SINGLETON_RENDER_MANAGER = new NonSingletonRenderManager(); - if (ret === _emberMetalMeta.UNDEFINED) { - return undefined; - } - return ret; - } + var RenderDefinition = (function (_ComponentDefinition) { + babelHelpers.inherits(RenderDefinition, _ComponentDefinition); - cacheFor.set = function (cache, key, value) { - if (value === undefined) { - cache[key] = _emberMetalMeta.UNDEFINED; - } else { - cache[key] = value; - } - }; + function RenderDefinition(name, template, env, manager) { + _ComponentDefinition.call(this, 'render', manager, null); - cacheFor.get = function (cache, key) { - var ret = cache[key]; - if (ret === _emberMetalMeta.UNDEFINED) { - return undefined; + this.name = name; + this.template = template; + this.env = env; } - return ret; - }; - - cacheFor.remove = function (cache, key) { - cache[key] = undefined; - }; - exports.ComputedProperty = ComputedProperty; - exports.computed = computed; - exports.cacheFor = cacheFor; + return RenderDefinition; + })(_glimmerRuntime.ComponentDefinition); }); -enifed('ember-metal/core', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { +enifed('ember-glimmer/template', ['exports', 'ember-utils', '@glimmer/runtime'], function (exports, _emberUtils, _glimmerRuntime) { 'use strict'; - /** - @module ember - @submodule ember-metal - */ - - /** - This namespace contains all Ember methods and functions. Future versions of - Ember may overwrite this namespace and therefore, you should avoid adding any - new properties. - - At the heart of Ember is Ember-Runtime, a set of core functions that provide - cross-platform compatibility and object property observing. Ember-Runtime is - small and performance-focused so you can use it alongside other - cross-platform libraries such as jQuery. For more details, see - [Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html). - - @class Ember - @static - @public - */ - var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {}; - - // Make sure these are set whether Ember was already defined or not - Ember.isNamespace = true; - Ember.toString = function () { - return 'Ember'; - }; + exports.default = template; - // .......................................................... - // BOOTSTRAP - // + function template(json) { + var factory = _glimmerRuntime.templateFactory(json); - exports.default = Ember; + return { + id: factory.id, + meta: factory.meta, + create: function (props) { + return factory.create(props.env, { owner: props[_emberUtils.OWNER] }); + } + }; + } }); -enifed("ember-metal/debug", ["exports"], function (exports) { +enifed("ember-glimmer/template_registry", ["exports"], function (exports) { + // STATE within a module is frowned apon, this exists + // to support Ember.TEMPLATES but shield ember internals from this legacy + // global API. "use strict"; - exports.getDebugFunction = getDebugFunction; - exports.setDebugFunction = setDebugFunction; - exports.assert = assert; - exports.info = info; - exports.warn = warn; - exports.debug = debug; - exports.deprecate = deprecate; - exports.deprecateFunc = deprecateFunc; - exports.runInDebug = runInDebug; - exports.debugSeal = debugSeal; - exports.debugFreeze = debugFreeze; - var debugFunctions = { - assert: function () {}, - info: function () {}, - warn: function () {}, - debug: function () {}, - deprecate: function () {}, - deprecateFunc: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return args[args.length - 1]; - }, - runInDebug: function () {}, - debugSeal: function () {}, - debugFreeze: function () {} - }; - - exports.debugFunctions = debugFunctions; - - function getDebugFunction(name) { - return debugFunctions[name]; - } + exports.setTemplates = setTemplates; + exports.getTemplates = getTemplates; + exports.getTemplate = getTemplate; + exports.hasTemplate = hasTemplate; + exports.setTemplate = setTemplate; + var TEMPLATES = {}; - function setDebugFunction(name, fn) { - debugFunctions[name] = fn; + function setTemplates(templates) { + TEMPLATES = templates; } - function assert() { - return debugFunctions.assert.apply(undefined, arguments); + function getTemplates() { + return TEMPLATES; } - function info() { - return debugFunctions.info.apply(undefined, arguments); + function getTemplate(name) { + if (TEMPLATES.hasOwnProperty(name)) { + return TEMPLATES[name]; + } } - function warn() { - return debugFunctions.warn.apply(undefined, arguments); + function hasTemplate(name) { + return TEMPLATES.hasOwnProperty(name); } - function debug() { - return debugFunctions.debug.apply(undefined, arguments); + function setTemplate(name, template) { + return TEMPLATES[name] = template; } +}); +enifed("ember-glimmer/templates/component", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - function deprecate() { - return debugFunctions.deprecate.apply(undefined, arguments); - } + exports.default = _emberGlimmerTemplate.default({ "id": "2aYM5QYc", "block": "{\"statements\":[[\"yield\",\"default\"]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/component.hbs" } }); +}); +enifed("ember-glimmer/templates/empty", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - function deprecateFunc() { - return debugFunctions.deprecateFunc.apply(undefined, arguments); - } + exports.default = _emberGlimmerTemplate.default({ "id": "5QJJjniM", "block": "{\"statements\":[],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/empty.hbs" } }); +}); +enifed("ember-glimmer/templates/link-to", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - function runInDebug() { - return debugFunctions.runInDebug.apply(undefined, arguments); - } + exports.default = _emberGlimmerTemplate.default({ "id": "Y2DX6qHQ", "block": "{\"statements\":[[\"block\",[\"if\"],[[\"get\",[\"linkTitle\"]]],null,{\"statements\":[[\"append\",[\"unknown\",[\"linkTitle\"]],false]],\"locals\":[]},{\"statements\":[[\"yield\",\"default\"]],\"locals\":[]}]],\"locals\":[],\"named\":[],\"yields\":[\"default\"],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/link-to.hbs" } }); +}); +enifed("ember-glimmer/templates/outlet", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - function debugSeal() { - return debugFunctions.debugSeal.apply(undefined, arguments); - } + exports.default = _emberGlimmerTemplate.default({ "id": "xyZMyWzn", "block": "{\"statements\":[[\"append\",[\"unknown\",[\"outlet\"]],false]],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/outlet.hbs" } }); +}); +enifed("ember-glimmer/templates/root", ["exports", "ember-glimmer/template"], function (exports, _emberGlimmerTemplate) { + "use strict"; - function debugFreeze() { - return debugFunctions.debugFreeze.apply(undefined, arguments); - } + exports.default = _emberGlimmerTemplate.default({ "id": "/KBRNPqv", "block": "{\"statements\":[[\"append\",[\"helper\",[\"component\"],[[\"get\",[null]]],null],false]],\"locals\":[],\"named\":[],\"yields\":[],\"hasPartials\":false}", "meta": { "moduleName": "ember-glimmer/templates/root.hbs" } }); }); -enifed('ember-metal/dependent_keys', ['exports', 'ember-metal/watching'], function (exports, _emberMetalWatching) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed +enifed('ember-glimmer/utils/bindings', ['exports', '@glimmer/reference', 'ember-metal', 'ember-runtime', 'ember-glimmer/component', 'ember-glimmer/utils/string'], function (exports, _glimmerReference, _emberMetal, _emberRuntime, _emberGlimmerComponent, _emberGlimmerUtilsString) { + 'use strict'; - exports.addDependentKeys = addDependentKeys; - exports.removeDependentKeys = removeDependentKeys; + exports.wrapComponentClassAttribute = wrapComponentClassAttribute; - /** - @module ember - @submodule ember-metal - */ + function referenceForKey(component, key) { + return component[_emberGlimmerComponent.ROOT_REF].get(key); + } - // .......................................................... - // DEPENDENT KEYS - // + function referenceForParts(component, parts) { + var isAttrs = parts[0] === 'attrs'; - function addDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // add all of its dependent keys. - var idx = undefined, - depKey = undefined; - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; - } + // TODO deprecate this + if (isAttrs) { + parts.shift(); - for (idx = 0; idx < depKeys.length; idx++) { - depKey = depKeys[idx]; - // Increment the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1); - // Watch the depKey - _emberMetalWatching.watch(obj, depKey, meta); + if (parts.length === 1) { + return referenceForKey(component, parts[0]); + } } + + return _glimmerReference.referenceFromParts(component[_emberGlimmerComponent.ROOT_REF], parts); } - function removeDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // remove all of its dependent keys. - var depKeys = desc._dependentKeys; - if (!depKeys) { - return; + // TODO we should probably do this transform at build time + + function wrapComponentClassAttribute(hash) { + if (!hash) { + return hash; } - for (var idx = 0; idx < depKeys.length; idx++) { - var depKey = depKeys[idx]; - // Decrement the number of times depKey depends on keyName. - meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1); - // Unwatch the depKey - _emberMetalWatching.unwatch(obj, depKey, meta); + var keys = hash[0]; + var values = hash[1]; + + var index = keys.indexOf('class'); + + if (index !== -1) { + var _values$index = values[index]; + var type = _values$index[0]; + + if (type === 'get') { + var getExp = values[index]; + var path = getExp[1]; + var propName = path[path.length - 1]; + hash[1][index] = ['helper', ['-class'], [getExp, propName]]; + } } + + return hash; } -}); -enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set) { - /** - @module ember - @submodule ember-metal - */ - 'use strict'; + var AttributeBinding = { + parse: function (microsyntax) { + var colonIndex = microsyntax.indexOf(':'); - exports.deprecateProperty = deprecateProperty; + if (colonIndex === -1) { + return [microsyntax, microsyntax, true]; + } else { + var prop = microsyntax.substring(0, colonIndex); + var attribute = microsyntax.substring(colonIndex + 1); - /** - Used internally to allow changing properties in a backwards compatible way, and print a helpful - deprecation warning. - - @method deprecateProperty - @param {Object} object The object to add the deprecated property to. - @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). - @param {String} newKey The property that will be aliased. - @private - @since 1.7.0 - */ + return [prop, attribute, false]; + } + }, - function deprecateProperty(object, deprecatedKey, newKey, options) { - function _deprecate() {} + install: function (element, component, parsed, operations) { + var prop = parsed[0]; + var attribute = parsed[1]; + var isSimple = parsed[2]; - Object.defineProperty(object, deprecatedKey, { - configurable: true, - enumerable: false, - set: function (value) { - _deprecate(); - _emberMetalProperty_set.set(this, newKey, value); - }, - get: function () { - _deprecate(); - return _emberMetalProperty_get.get(this, newKey); + if (attribute === 'id') { + var elementId = _emberMetal.get(component, prop); + if (elementId === undefined || elementId === null) { + elementId = component.elementId; + } + operations.addStaticAttribute(element, 'id', elementId); + return; } - }); - } -}); -enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) { - 'use strict'; - exports.default = descriptor; + var isPath = prop.indexOf('.') > -1; + var reference = isPath ? referenceForParts(component, prop.split('.')) : referenceForKey(component, prop); - function descriptor(desc) { - return new Descriptor(desc); - } + if (attribute === 'style') { + reference = new StyleBindingReference(reference, referenceForKey(component, 'isVisible')); + } - /** - A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need - this at all, however, the way we currently flatten/merge our mixins require - a special value to denote a descriptor. - - @class Descriptor - @private - */ + operations.addDynamicAttribute(element, attribute, reference); + } + }; - var Descriptor = (function (_EmberDescriptor) { - babelHelpers.inherits(Descriptor, _EmberDescriptor); + exports.AttributeBinding = AttributeBinding; + var DISPLAY_NONE = 'display: none;'; + var SAFE_DISPLAY_NONE = _emberGlimmerUtilsString.htmlSafe(DISPLAY_NONE); - function Descriptor(desc) { - _EmberDescriptor.call(this); - this.desc = desc; + var StyleBindingReference = (function (_CachedReference) { + babelHelpers.inherits(StyleBindingReference, _CachedReference); + + function StyleBindingReference(inner, isVisible) { + _CachedReference.call(this); + + this.tag = _glimmerReference.combine([inner.tag, isVisible.tag]); + this.inner = inner; + this.isVisible = isVisible; } - Descriptor.prototype.setup = function setup(obj, key) { - Object.defineProperty(obj, key, this.desc); + StyleBindingReference.prototype.compute = function compute() { + var value = this.inner.value(); + var isVisible = this.isVisible.value(); + + if (isVisible !== false) { + return value; + } else if (!value && value !== 0) { + return SAFE_DISPLAY_NONE; + } else { + var style = value + ' ' + DISPLAY_NONE; + return _emberGlimmerUtilsString.isHTMLSafe(value) ? _emberGlimmerUtilsString.htmlSafe(style) : style; + } }; - Descriptor.prototype.teardown = function teardown(obj, key) {}; + return StyleBindingReference; + })(_glimmerReference.CachedReference); - return Descriptor; - })(_emberMetalProperties.Descriptor); -}); -enifed("ember-metal/error", ["exports"], function (exports) { + var IsVisibleBinding = { + install: function (element, component, operations) { + operations.addDynamicAttribute(element, 'style', _glimmerReference.map(referenceForKey(component, 'isVisible'), this.mapStyleValue)); + }, - /** - A subclass of the JavaScript Error object for use in Ember. - - @class Error - @namespace Ember - @extends Error - @constructor - @public - */ - "use strict"; + mapStyleValue: function (isVisible) { + return isVisible === false ? SAFE_DISPLAY_NONE : null; + } + }; - exports.default = EmberError; + exports.IsVisibleBinding = IsVisibleBinding; + var ClassNameBinding = { + install: function (element, component, microsyntax, operations) { + var _microsyntax$split = microsyntax.split(':'); + + var prop = _microsyntax$split[0]; + var truthy = _microsyntax$split[1]; + var falsy = _microsyntax$split[2]; - function EmberError(message) { - if (!(this instanceof EmberError)) { - return new EmberError(message); + var isStatic = prop === ''; + + if (isStatic) { + operations.addStaticAttribute(element, 'class', truthy); + } else { + var isPath = prop.indexOf('.') > -1; + var parts = isPath && prop.split('.'); + var value = isPath ? referenceForParts(component, parts) : referenceForKey(component, prop); + var ref = undefined; + + if (truthy === undefined) { + ref = new SimpleClassNameBindingReference(value, isPath ? parts[parts.length - 1] : prop); + } else { + ref = new ColonClassNameBindingReference(value, truthy, falsy); + } + + operations.addDynamicAttribute(element, 'class', ref); + } } + }; + + exports.ClassNameBinding = ClassNameBinding; - var error = Error.call(this, message); + var SimpleClassNameBindingReference = (function (_CachedReference2) { + babelHelpers.inherits(SimpleClassNameBindingReference, _CachedReference2); - if (Error.captureStackTrace) { - Error.captureStackTrace(this, EmberError); - } else { - this.stack = error.stack; + function SimpleClassNameBindingReference(inner, path) { + _CachedReference2.call(this); + + this.tag = inner.tag; + this.inner = inner; + this.path = path; + this.dasherizedPath = null; } - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message; - this.name = error.name; - this.number = error.number; - this.code = error.code; - } + SimpleClassNameBindingReference.prototype.compute = function compute() { + var value = this.inner.value(); - EmberError.prototype = Object.create(Error.prototype); -}); -enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { - 'use strict'; + if (value === true) { + var path = this.path; + var dasherizedPath = this.dasherizedPath; - exports.getOnerror = getOnerror; - exports.setOnerror = setOnerror; - exports.dispatchError = dispatchError; - exports.setDispatchOverride = setDispatchOverride; + return dasherizedPath || (this.dasherizedPath = _emberRuntime.String.dasherize(path)); + } else if (value || value === 0) { + return value; + } else { + return null; + } + }; - // To maintain stacktrace consistency across browsers - var getStack = function (error) { - var stack = error.stack; - var message = error.message; + return SimpleClassNameBindingReference; + })(_glimmerReference.CachedReference); - if (stack && stack.indexOf(message) === -1) { - stack = message + '\n' + stack; + var ColonClassNameBindingReference = (function (_CachedReference3) { + babelHelpers.inherits(ColonClassNameBindingReference, _CachedReference3); + + function ColonClassNameBindingReference(inner, truthy, falsy) { + _CachedReference3.call(this); + + this.tag = inner.tag; + this.inner = inner; + this.truthy = truthy || null; + this.falsy = falsy || null; } - return stack; - }; + ColonClassNameBindingReference.prototype.compute = function compute() { + var inner = this.inner; + var truthy = this.truthy; + var falsy = this.falsy; - var onerror = undefined; - // Ember.onerror getter + return inner.value() ? truthy : falsy; + }; - function getOnerror() { - return onerror; - } + return ColonClassNameBindingReference; + })(_glimmerReference.CachedReference); +}); +enifed('ember-glimmer/utils/debug-stack', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - // Ember.onerror setter + var DebugStack = undefined; - function setOnerror(handler) { - onerror = handler; - } + exports.default = DebugStack; +}); +enifed('ember-glimmer/utils/iterable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-glimmer/utils/references', 'ember-glimmer/helpers/each-in', '@glimmer/reference'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberGlimmerUtilsReferences, _emberGlimmerHelpersEachIn, _glimmerReference) { + 'use strict'; - var dispatchOverride = undefined; - // dispatch error + exports.default = iterableFor; - function dispatchError(error) { - if (dispatchOverride) { - dispatchOverride(error); + var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; + + function iterableFor(ref, keyPath) { + if (_emberGlimmerHelpersEachIn.isEachIn(ref)) { + return new EachInIterable(ref, keyForEachIn(keyPath)); } else { - defaultDispatch(error); + return new ArrayIterable(ref, keyForArray(keyPath)); } } - // allows testing adapter to override dispatch - - function setDispatchOverride(handler) { - dispatchOverride = handler; + function keyForEachIn(keyPath) { + switch (keyPath) { + case '@index': + case undefined: + case null: + return index; + case '@identity': + return identity; + default: + return function (item) { + return _emberMetal.get(item, keyPath); + }; + } } - function defaultDispatch(error) { - if (_emberMetalTesting.isTesting()) { - throw error; - } - if (onerror) { - onerror(error); - } else { - _emberConsole.default.error(getStack(error)); + function keyForArray(keyPath) { + switch (keyPath) { + case '@index': + return index; + case '@identity': + case undefined: + case null: + return identity; + default: + return function (item) { + return _emberMetal.get(item, keyPath); + }; } } -}); -enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - /** - @module ember - @submodule ember-metal - */ - exports.accumulateListeners = accumulateListeners; - exports.addListener = addListener; - exports.removeListener = removeListener; - exports.suspendListener = suspendListener; - exports.suspendListeners = suspendListeners; - exports.watchedEvents = watchedEvents; - exports.sendEvent = sendEvent; - exports.hasListeners = hasListeners; - exports.listenersFor = listenersFor; - exports.on = on; + function index(item, index) { + return String(index); + } - /* - The event system uses a series of nested hashes to store listeners on an - object. When a listener is registered, or when an event arrives, these - hashes are consulted to determine which target and action pair to invoke. - - The hashes are stored in the object's meta hash, and look like this: - - // Object's meta hash - { - listeners: { // variable name: `listenerSet` - "foo:changed": [ // variable name: `actions` - target, method, flags - ] - } - } - - */ + function identity(item) { + switch (typeof item) { + case 'string': + case 'number': + return String(item); + default: + return _emberUtils.guidFor(item); + } + } - function indexOf(array, target, method) { - var index = -1; - // hashes are added to the end of the event array - // so it makes sense to start searching at the end - // of the array and search in reverse - for (var i = array.length - 3; i >= 0; i -= 3) { - if (target === array[i] && method === array[i + 1]) { - index = i; - break; - } + function ensureUniqueKey(seen, key) { + var seenCount = seen[key]; + + if (seenCount) { + seen[key]++; + return '' + key + ITERATOR_KEY_GUID + seenCount; + } else { + seen[key] = 1; } - return index; + + return key; } - function accumulateListeners(obj, eventName, otherActions) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return; + var ArrayIterator = (function () { + function ArrayIterator(array, keyFor) { + this.array = array; + this.length = array.length; + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); } - var actions = meta.matchingListeners(eventName); - var newActions = []; - for (var i = actions.length - 3; i >= 0; i -= 3) { - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - var actionIndex = indexOf(otherActions, target, method); + ArrayIterator.prototype.isEmpty = function isEmpty() { + return false; + }; - if (actionIndex === -1) { - otherActions.push(target, method, flags); - newActions.push(target, method, flags); + ArrayIterator.prototype.next = function next() { + var array = this.array; + var length = this.length; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; + + if (position >= length) { + return null; } - } - return newActions; - } + var value = array[position]; + var memo = position; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - /** - Add an event listener - - @method addListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Boolean} once A flag whether a function should only be called once - @public - */ + this.position++; - function addListener(obj, eventName, target, method, once) { + return { key: key, value: value, memo: memo }; + }; - if (!method && 'function' === typeof target) { - method = target; - target = null; - } + return ArrayIterator; + })(); - var flags = 0; - if (once) { - flags |= _emberMetalMeta_listeners.ONCE; + var EmberArrayIterator = (function () { + function EmberArrayIterator(array, keyFor) { + this.array = array; + this.length = _emberMetal.get(array, 'length'); + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); } - _emberMetalMeta.meta(obj).addToListeners(eventName, target, method, flags); + EmberArrayIterator.prototype.isEmpty = function isEmpty() { + return this.length === 0; + }; - if ('function' === typeof obj.didAddListener) { - obj.didAddListener(eventName, target, method); - } - } + EmberArrayIterator.prototype.next = function next() { + var array = this.array; + var length = this.length; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; - /** - Remove an event listener - - Arguments should match those passed to `Ember.addListener`. - - @method removeListener - @for Ember - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @public - */ + if (position >= length) { + return null; + } - function removeListener(obj, eventName, target, method) { + var value = _emberRuntime.objectAt(array, position); + var memo = position; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - if (!method && 'function' === typeof target) { - method = target; - target = null; - } + this.position++; - _emberMetalMeta.meta(obj).removeFromListeners(eventName, target, method, function () { - if ('function' === typeof obj.didRemoveListener) { - obj.didRemoveListener.apply(obj, arguments); + return { key: key, value: value, memo: memo }; + }; + + return EmberArrayIterator; + })(); + + var ObjectKeysIterator = (function () { + function ObjectKeysIterator(keys, values, keyFor) { + this.keys = keys; + this.values = values; + this.keyFor = keyFor; + this.position = 0; + this.seen = new _emberUtils.EmptyObject(); + } + + ObjectKeysIterator.prototype.isEmpty = function isEmpty() { + return this.keys.length === 0; + }; + + ObjectKeysIterator.prototype.next = function next() { + var keys = this.keys; + var values = this.values; + var keyFor = this.keyFor; + var position = this.position; + var seen = this.seen; + + if (position >= keys.length) { + return null; } - }); - } - /** - Suspend listener during callback. - - This should only be used by the target of the event listener - when it is taking an action that would cause the event, e.g. - an object might suspend its property change listener while it is - setting that property. - - @method suspendListener - @for Ember - - @private - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ + var value = values[position]; + var memo = keys[position]; + var key = ensureUniqueKey(seen, keyFor(value, memo)); - function suspendListener(obj, eventName, target, method, callback) { - return suspendListeners(obj, [eventName], target, method, callback); - } + this.position++; - /** - Suspends multiple listeners during a callback. - - @method suspendListeners - @for Ember - - @private - @param obj - @param {Array} eventNames Array of event names - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Function} callback - */ + return { key: key, value: value, memo: memo }; + }; - function suspendListeners(obj, eventNames, target, method, callback) { - if (!method && 'function' === typeof target) { - method = target; - target = null; - } - return _emberMetalMeta.meta(obj).suspendListeners(eventNames, target, method, callback); - } + return ObjectKeysIterator; + })(); - /** - Return a list of currently watched events - - @private - @method watchedEvents - @for Ember - @param obj - */ + var EmptyIterator = (function () { + function EmptyIterator() {} - function watchedEvents(obj) { - return _emberMetalMeta.meta(obj).watchedEvents(); - } + EmptyIterator.prototype.isEmpty = function isEmpty() { + return true; + }; - /** - Send an event. The execution of suspended listeners - is skipped, and once listeners are removed. A listener without - a target is executed on the passed object. If an array of actions - is not passed, the actions stored on the passed object are invoked. - - @method sendEvent - @for Ember - @param obj - @param {String} eventName - @param {Array} params Optional parameters for each listener. - @param {Array} actions Optional array of actions (listeners). - @return true - @public - */ + EmptyIterator.prototype.next = function next() { + throw new Error('Cannot call next() on an empty iterator'); + }; - function sendEvent(obj, eventName, params, actions) { - if (!actions) { - var meta = _emberMetalMeta.peekMeta(obj); - actions = meta && meta.matchingListeners(eventName); - } + return EmptyIterator; + })(); - if (!actions || actions.length === 0) { - return; + var EMPTY_ITERATOR = new EmptyIterator(); + + var EachInIterable = (function () { + function EachInIterable(ref, keyFor) { + this.ref = ref; + this.keyFor = keyFor; + + var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + + this.tag = _glimmerReference.combine([ref.tag, valueTag]); } - for (var i = actions.length - 3; i >= 0; i -= 3) { - // looping in reverse for once listeners - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; + EachInIterable.prototype.iterate = function iterate() { + var ref = this.ref; + var keyFor = this.keyFor; + var valueTag = this.valueTag; - if (!method) { - continue; - } - if (flags & _emberMetalMeta_listeners.SUSPENDED) { - continue; - } - if (flags & _emberMetalMeta_listeners.ONCE) { - removeListener(obj, eventName, target, method); - } - if (!target) { - target = obj; + var iterable = ref.value(); + + valueTag.update(_emberMetal.tagFor(iterable)); + + if (_emberMetal.isProxy(iterable)) { + iterable = _emberMetal.get(iterable, 'content'); } - if ('string' === typeof method) { - if (params) { - _emberUtils.applyStr(target, method, params); - } else { - target[method](); - } + + var typeofIterable = typeof iterable; + + if (iterable && (typeofIterable === 'object' || typeofIterable === 'function')) { + var keys = Object.keys(iterable); + var values = keys.map(function (key) { + return iterable[key]; + }); + return keys.length > 0 ? new ObjectKeysIterator(keys, values, keyFor) : EMPTY_ITERATOR; } else { - if (params) { - method.apply(target, params); - } else { - method.call(target); - } + return EMPTY_ITERATOR; } - } - return true; - } + }; - /** - @private - @method hasListeners - @for Ember - @param obj - @param {String} eventName - */ + // {{each-in}} yields |key value| instead of |value key|, so the memo and + // value are flipped - function hasListeners(obj, eventName) { - var meta = _emberMetalMeta.peekMeta(obj); - if (!meta) { - return false; - } - return meta.matchingListeners(eventName).length > 0; - } + EachInIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); + }; - /** - @private - @method listenersFor - @for Ember - @param obj - @param {String} eventName - */ + EachInIterable.prototype.updateValueReference = function updateValueReference(reference, item) { + reference.update(item.memo); + }; - function listenersFor(obj, eventName) { - var ret = []; - var meta = _emberMetalMeta.peekMeta(obj); - var actions = meta && meta.matchingListeners(eventName); + EachInIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); + }; - if (!actions) { - return ret; - } + EachInIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { + reference.update(item.value); + }; - for (var i = 0; i < actions.length; i += 3) { - var target = actions[i]; - var method = actions[i + 1]; - ret.push([target, method]); - } + return EachInIterable; + })(); - return ret; - } + var ArrayIterable = (function () { + function ArrayIterable(ref, keyFor) { + this.ref = ref; + this.keyFor = keyFor; - /** - Define a property as a function that should be executed when - a specified event or events are triggered. - - - ``` javascript - let Job = Ember.Object.extend({ - logCompleted: Ember.on('completed', function() { - console.log('Job completed!'); - }) - }); - - let job = Job.create(); - - Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' - ``` - - @method on - @for Ember - @param {String} eventNames* - @param {Function} func - @return func - @public - */ + var valueTag = this.valueTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - function on() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + this.tag = _glimmerReference.combine([ref.tag, valueTag]); } - var func = args.pop(); - var events = args; - func.__ember_listens__ = events; - return func; - } -}); -enifed('ember-metal/expand_properties', ['exports', 'ember-metal/debug'], function (exports, _emberMetalDebug) { - 'use strict'; - - exports.default = expandProperties; - - /** - @module ember - @submodule ember-metal - */ + ArrayIterable.prototype.iterate = function iterate() { + var ref = this.ref; + var keyFor = this.keyFor; + var valueTag = this.valueTag; - var SPLIT_REGEX = /\{|\}/; - var END_WITH_EACH_REGEX = /\.@each$/; + var iterable = ref.value(); - /** - Expands `pattern`, invoking `callback` for each expansion. - - The only pattern supported is brace-expansion, anything else will be passed - once to `callback` directly. - - Example - - ```js - function echo(arg){ console.log(arg); } - - Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' - Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' - Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' - Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' - Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' - Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' - Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' - ``` - - @method expandProperties - @for Ember - @private - @param {String} pattern The property pattern to expand. - @param {Function} callback The callback to invoke. It is invoked once per - expansion, and is passed the expansion. - */ + valueTag.update(_emberMetal.tagForProperty(iterable, '[]')); - function expandProperties(pattern, callback) { + if (!iterable || typeof iterable !== 'object') { + return EMPTY_ITERATOR; + } - var parts = pattern.split(SPLIT_REGEX); - var properties = [parts]; + if (Array.isArray(iterable)) { + return iterable.length > 0 ? new ArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; + } else if (_emberRuntime.isEmberArray(iterable)) { + return _emberMetal.get(iterable, 'length') > 0 ? new EmberArrayIterator(iterable, keyFor) : EMPTY_ITERATOR; + } else if (typeof iterable.forEach === 'function') { + var _ret = (function () { + var array = []; + iterable.forEach(function (item) { + array.push(item); + }); + return { + v: array.length > 0 ? new ArrayIterator(array, keyFor) : EMPTY_ITERATOR + }; + })(); - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part.indexOf(',') >= 0) { - properties = duplicateAndReplace(properties, part.split(','), i); + if (typeof _ret === 'object') return _ret.v; + } else { + return EMPTY_ITERATOR; } - } + }; - for (var i = 0; i < properties.length; i++) { - callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); - } - } + ArrayIterable.prototype.valueReferenceFor = function valueReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatableReference(item.value); + }; - function duplicateAndReplace(properties, currentParts, index) { - var all = []; + ArrayIterable.prototype.updateValueReference = function updateValueReference(reference, item) { + reference.update(item.value); + }; - properties.forEach(function (property) { - currentParts.forEach(function (part) { - var current = property.slice(0); - current[index] = part; - all.push(current); - }); - }); + ArrayIterable.prototype.memoReferenceFor = function memoReferenceFor(item) { + return new _emberGlimmerUtilsReferences.UpdatablePrimitiveReference(item.memo); + }; - return all; - } + ArrayIterable.prototype.updateMemoReference = function updateMemoReference(reference, item) { + reference.update(item.memo); + }; + + return ArrayIterable; + })(); }); -enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) { +enifed('ember-glimmer/utils/process-args', ['exports', 'ember-utils', '@glimmer/reference', 'ember-glimmer/component', 'ember-glimmer/utils/references', 'ember-views', 'ember-glimmer/helpers/action', '@glimmer/runtime'], function (exports, _emberUtils, _glimmerReference, _emberGlimmerComponent, _emberGlimmerUtilsReferences, _emberViews, _emberGlimmerHelpersAction, _glimmerRuntime) { 'use strict'; - exports.default = isEnabled; - - /** - The hash of enabled Canary features. Add to this, any canary features - before creating your application. - - Alternatively (and recommended), you can also define `EmberENV.FEATURES` - if you need to enable features flagged at runtime. - - @class FEATURES - @namespace Ember - @static - @since 1.1.0 - @public - */ - var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES); + exports.gatherArgs = gatherArgs; - exports.FEATURES = FEATURES; - /** - Determine whether the specified `feature` is enabled. Used by Ember's - build tools to exclude experimental features from beta/stable builds. - - You can define the following configuration options: - - * `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly - enabled/disabled. - - @method isEnabled - @param {String} feature The feature to check - @return {Boolean} - @for Ember.FEATURES - @since 1.1.0 - @public - */ + // Maps all variants of positional and dynamically scoped arguments + // into the named arguments. Input `args` and return value are both + // `EvaluatedArgs`. - function isEnabled(feature) { - var featureValue = FEATURES[feature]; + function gatherArgs(args, definition) { + var namedMap = gatherNamedMap(args, definition); + var positionalValues = gatherPositionalValues(args, definition); + return mergeArgs(namedMap, positionalValues, args.blocks, definition.ComponentClass.class); + } - if (featureValue === true || featureValue === false || featureValue === undefined) { - return featureValue; - } else if (_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES) { - return true; + function gatherNamedMap(args, definition) { + var namedMap = args.named.map; + if (definition.args) { + return _emberUtils.assign({}, definition.args.named.map, namedMap); } else { - return false; + return namedMap; } } - exports.DEFAULT_FEATURES = _emberFeatures.default; -}); -enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { - 'use strict'; + function gatherPositionalValues(args, definition) { + var positionalValues = args.positional.values; + if (definition.args) { + var oldPositional = definition.args.positional.values; + var newPositional = []; + newPositional.push.apply(newPositional, oldPositional); + newPositional.splice.apply(newPositional, [0, positionalValues.length].concat(positionalValues)); + return newPositional; + } else { + return positionalValues; + } + } - exports.default = getProperties; + function mergeArgs(namedMap, positionalValues, blocks, componentClass) { + var positionalParamsDefinition = componentClass.positionalParams; - /** - To get multiple properties at once, call `Ember.getProperties` - with an object followed by a list of strings or an array: - - ```javascript - Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - is equivalent to: - - ```javascript - Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - - @method getProperties - @for Ember - @param {Object} obj - @param {String...|Array} list of keys to get - @return {Object} - @public - */ + if (positionalParamsDefinition && positionalParamsDefinition.length > 0 && positionalValues.length > 0) { + if (typeof positionalParamsDefinition === 'string') { + namedMap = mergeRestArg(namedMap, positionalValues, positionalParamsDefinition); + } else { + namedMap = mergePositionalParams(namedMap, positionalValues, positionalParamsDefinition); + } + } + return _glimmerRuntime.EvaluatedArgs.named(namedMap, blocks); + } - function getProperties(obj) { - var ret = {}; - var propertyNames = arguments; - var i = 1; + var EMPTY_ARGS = { + tag: _glimmerReference.CONSTANT_TAG, + value: function () { + var _props; - if (arguments.length === 2 && Array.isArray(arguments[1])) { - i = 0; - propertyNames = arguments[1]; - } - for (; i < propertyNames.length; i++) { - ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]); + return { attrs: {}, props: (_props = { attrs: {} }, _props[_emberGlimmerComponent.ARGS] = {}, _props) }; } - return ret; - } -}); -enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/is_proxy', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalIs_proxy, _emberMetalDescriptor) { - /** - @module ember - @submodule ember-metal - */ + }; - 'use strict'; + // ComponentArgs takes EvaluatedNamedArgs and converts them into the + // inputs needed by CurlyComponents (attrs and props, with mutable + // cells, etc). - exports.default = _emberMetalCore.default; - // reexports - exports.computed = _emberMetalComputed.default; - exports.cacheFor = _emberMetalComputed.cacheFor; - exports.ComputedProperty = _emberMetalComputed.ComputedProperty; - exports.alias = _emberMetalAlias.default; - exports.merge = _emberMetalMerge.default; - exports.assert = _emberMetalDebug.assert; - exports.info = _emberMetalDebug.info; - exports.warn = _emberMetalDebug.warn; - exports.debug = _emberMetalDebug.debug; - exports.deprecate = _emberMetalDebug.deprecate; - exports.deprecateFunc = _emberMetalDebug.deprecateFunc; - exports.runInDebug = _emberMetalDebug.runInDebug; - exports.setDebugFunction = _emberMetalDebug.setDebugFunction; - exports.getDebugFunction = _emberMetalDebug.getDebugFunction; - exports.debugSeal = _emberMetalDebug.debugSeal; - exports.debugFreeze = _emberMetalDebug.debugFreeze; - exports.instrument = _emberMetalInstrumentation.instrument; - exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument; - exports._instrumentStart = _emberMetalInstrumentation._instrumentStart; - exports.instrumentationReset = _emberMetalInstrumentation.reset; - exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe; - exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe; - exports.isTesting = _emberMetalTesting.isTesting; - exports.setTesting = _emberMetalTesting.setTesting; - exports.getOnerror = _emberMetalError_handler.getOnerror; - exports.setOnerror = _emberMetalError_handler.setOnerror; - exports.dispatchError = _emberMetalError_handler.dispatchError; - exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride; - exports.META_DESC = _emberMetalMeta.META_DESC; - exports.meta = _emberMetalMeta.meta; - exports.peekMeta = _emberMetalMeta.peekMeta; - exports.Error = _emberMetalError.default; - exports.Cache = _emberMetalCache.default; - exports.isFeatureEnabled = _emberMetalFeatures.default; - exports.FEATURES = _emberMetalFeatures.FEATURES; - exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES; - exports._getPath = _emberMetalProperty_get._getPath; - exports.get = _emberMetalProperty_get.get; - exports.getWithDefault = _emberMetalProperty_get.getWithDefault; - exports.set = _emberMetalProperty_set.set; - exports.trySet = _emberMetalProperty_set.trySet; - exports.WeakMap = _emberMetalWeak_map.default; - exports.accumulateListeners = _emberMetalEvents.accumulateListeners; - exports.addListener = _emberMetalEvents.addListener; - exports.hasListeners = _emberMetalEvents.hasListeners; - exports.listenersFor = _emberMetalEvents.listenersFor; - exports.on = _emberMetalEvents.on; - exports.removeListener = _emberMetalEvents.removeListener; - exports.sendEvent = _emberMetalEvents.sendEvent; - exports.suspendListener = _emberMetalEvents.suspendListener; - exports.suspendListeners = _emberMetalEvents.suspendListeners; - exports.watchedEvents = _emberMetalEvents.watchedEvents; - exports.isNone = _emberMetalIs_none.default; - exports.isEmpty = _emberMetalIs_empty.default; - exports.isBlank = _emberMetalIs_blank.default; - exports.isPresent = _emberMetalIs_present.default; - exports.run = _emberMetalRun_loop.default; - exports.ObserverSet = _emberMetalObserver_set.default; - exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges; - exports.changeProperties = _emberMetalProperty_events.changeProperties; - exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges; - exports.overrideChains = _emberMetalProperty_events.overrideChains; - exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; - exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; - exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; - exports.defineProperty = _emberMetalProperties.defineProperty; - exports.Descriptor = _emberMetalProperties.Descriptor; - exports.watchKey = _emberMetalWatch_key.watchKey; - exports.unwatchKey = _emberMetalWatch_key.unwatchKey; - exports.ChainNode = _emberMetalChains.ChainNode; - exports.finishChains = _emberMetalChains.finishChains; - exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; - exports.watchPath = _emberMetalWatch_path.watchPath; - exports.unwatchPath = _emberMetalWatch_path.unwatchPath; - exports.destroy = _emberMetalWatching.destroy; - exports.isWatching = _emberMetalWatching.isWatching; - exports.unwatch = _emberMetalWatching.unwatch; - exports.watch = _emberMetalWatching.watch; - exports.watcherCount = _emberMetalWatching.watcherCount; - exports.libraries = _emberMetalLibraries.default; - exports.Map = _emberMetalMap.Map; - exports.MapWithDefault = _emberMetalMap.MapWithDefault; - exports.OrderedSet = _emberMetalMap.OrderedSet; - exports.getProperties = _emberMetalGet_properties.default; - exports.setProperties = _emberMetalSet_properties.default; - exports.expandProperties = _emberMetalExpand_properties.default; - exports._suspendObserver = _emberMetalObserver._suspendObserver; - exports._suspendObservers = _emberMetalObserver._suspendObservers; - exports.addObserver = _emberMetalObserver.addObserver; - exports.observersFor = _emberMetalObserver.observersFor; - exports.removeObserver = _emberMetalObserver.removeObserver; - exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; - exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; - exports.Mixin = _emberMetalMixin.Mixin; - exports.aliasMethod = _emberMetalMixin.aliasMethod; - exports._immediateObserver = _emberMetalMixin._immediateObserver; - exports._beforeObserver = _emberMetalMixin._beforeObserver; - exports.mixin = _emberMetalMixin.mixin; - exports.observer = _emberMetalMixin.observer; - exports.required = _emberMetalMixin.required; - exports.REQUIRED = _emberMetalMixin.REQUIRED; - exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins; - exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins; - exports.detectBinding = _emberMetalMixin.detectBinding; - exports.Binding = _emberMetalBinding.Binding; - exports.bind = _emberMetalBinding.bind; - exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath; - exports.InjectedProperty = _emberMetalInjected_property.default; - exports.setHasViews = _emberMetalTags.setHasViews; - exports.tagForProperty = _emberMetalTags.tagForProperty; - exports.tagFor = _emberMetalTags.tagFor; - exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty; - exports.replace = _emberMetalReplace.default; - exports.runInTransaction = _emberMetalTransaction.default; - exports.didRender = _emberMetalTransaction.didRender; - exports.assertNotRendered = _emberMetalTransaction.assertNotRendered; - exports.isProxy = _emberMetalIs_proxy.isProxy; - exports.descriptor = _emberMetalDescriptor.default; + var ComponentArgs = (function () { + ComponentArgs.create = function create(args) { + if (args.named.keys.length === 0) { + return EMPTY_ARGS; + } else { + return new ComponentArgs(args.named); + } + }; - // TODO: this needs to be deleted once we refactor the build tooling - // do this for side-effects of updating Ember.assert, warn, etc when - // ember-debug is present - // This needs to be called before any deprecateFunc + function ComponentArgs(namedArgs) { + this.tag = namedArgs.tag; + this.namedArgs = namedArgs; + } - if (_require.has('ember-debug')) { - _require.default('ember-debug'); - } -}); -enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) { - 'use strict'; + ComponentArgs.prototype.value = function value() { + var namedArgs = this.namedArgs; - exports.default = InjectedProperty; + var keys = namedArgs.keys; + var attrs = namedArgs.value(); + var props = new _emberUtils.EmptyObject(); + var args = new _emberUtils.EmptyObject(); - /** - Read-only property that returns the result of a container lookup. - - @class InjectedProperty - @namespace Ember - @constructor - @param {String} type The container type the property will lookup - @param {String} name (optional) The name the property will lookup, defaults - to the property's name - @private - */ + props[_emberGlimmerComponent.ARGS] = args; - function InjectedProperty(type, name) { - this.type = type; - this.name = name; + for (var i = 0, l = keys.length; i < l; i++) { + var _name = keys[i]; + var ref = namedArgs.get(_name); + var value = attrs[_name]; - this._super$Constructor(injectedPropertyGet); - AliasedPropertyPrototype.oneWay.call(this); - } + if (typeof value === 'function' && value[_emberGlimmerHelpersAction.ACTION]) { + attrs[_name] = value; + } else if (ref[_emberGlimmerUtilsReferences.UPDATE]) { + attrs[_name] = new MutableCell(ref, value); + } - function injectedPropertyGet(keyName) { - var desc = this[keyName]; - var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat + args[_name] = ref; + props[_name] = value; + } - return owner.lookup(desc.type + ':' + (desc.name || keyName)); + props.attrs = attrs; + + return { attrs: attrs, props: props }; + }; + + return ComponentArgs; + })(); + + exports.ComponentArgs = ComponentArgs; + + function mergeRestArg(namedMap, positionalValues, restArgName) { + var mergedNamed = _emberUtils.assign({}, namedMap); + mergedNamed[restArgName] = _glimmerRuntime.EvaluatedPositionalArgs.create(positionalValues); + return mergedNamed; } - InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); + function mergePositionalParams(namedMap, values, positionalParamNames) { + var mergedNamed = _emberUtils.assign({}, namedMap); + var length = Math.min(values.length, positionalParamNames.length); + for (var i = 0; i < length; i++) { + var _name2 = positionalParamNames[i]; + mergedNamed[_name2] = values[i]; + } + return mergedNamed; + } - var InjectedPropertyPrototype = InjectedProperty.prototype; - var ComputedPropertyPrototype = _emberMetalComputed.ComputedProperty.prototype; - var AliasedPropertyPrototype = _emberMetalAlias.AliasedProperty.prototype; + var REF = _emberUtils.symbol('REF'); - InjectedPropertyPrototype._super$Constructor = _emberMetalComputed.ComputedProperty; + var MutableCell = (function () { + function MutableCell(ref, value) { + this[_emberViews.MUTABLE_CELL] = true; + this[REF] = ref; + this.value = value; + } - InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; - InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; - InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; + MutableCell.prototype.update = function update(val) { + this[REF][_emberGlimmerUtilsReferences.UPDATE](val); + }; + + return MutableCell; + })(); }); -enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { +enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal', '@glimmer/reference', '@glimmer/runtime', 'ember-glimmer/utils/to-bool', 'ember-glimmer/helper'], function (exports, _emberUtils, _emberMetal, _glimmerReference, _glimmerRuntime, _emberGlimmerUtilsToBool, _emberGlimmerHelper) { 'use strict'; - exports.instrument = instrument; - exports._instrumentStart = _instrumentStart; - exports.subscribe = subscribe; - exports.unsubscribe = unsubscribe; - exports.reset = reset; + var UPDATE = _emberUtils.symbol('UPDATE'); - /** - The purpose of the Ember Instrumentation module is - to provide efficient, general-purpose instrumentation - for Ember. - - Subscribe to a listener by using `Ember.subscribe`: - - ```javascript - Ember.subscribe("render", { - before(name, timestamp, payload) { - - }, - - after(name, timestamp, payload) { - - } - }); - ``` - - If you return a value from the `before` callback, that same - value will be passed as a fourth parameter to the `after` - callback. - - Instrument a block of code by using `Ember.instrument`: - - ```javascript - Ember.instrument("render.handlebars", payload, function() { - // rendering logic - }, binding); - ``` - - Event names passed to `Ember.instrument` are namespaced - by periods, from more general to more specific. Subscribers - can listen for events by whatever level of granularity they - are interested in. - - In the above example, the event is `render.handlebars`, - and the subscriber listened for all events beginning with - `render`. It would receive callbacks for events named - `render`, `render.handlebars`, `render.container`, or - even `render.handlebars.layout`. - - @class Instrumentation - @namespace Ember - @static - @private - */ - var subscribers = []; - exports.subscribers = subscribers; - var cache = {}; + exports.UPDATE = UPDATE; + exports.NULL_REFERENCE = _glimmerRuntime.NULL_REFERENCE; + exports.UNDEFINED_REFERENCE = _glimmerRuntime.UNDEFINED_REFERENCE; - function populateListeners(name) { - var listeners = []; - var subscriber = undefined; + // @abstract + // @implements PathReference - for (var i = 0; i < subscribers.length; i++) { - subscriber = subscribers[i]; - if (subscriber.regex.test(name)) { - listeners.push(subscriber.object); - } - } + var EmberPathReference = (function () { + function EmberPathReference() {} - cache[name] = listeners; - return listeners; - } + // @abstract - var time = (function () { - var perf = 'undefined' !== typeof window ? window.performance || {} : {}; - var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; - // fn.bind will be available in all the browsers that support the advanced window.performance... ;-) - return fn ? fn.bind(perf) : function () { - return +new Date(); + // @abstract get tag() + // @abstract value() + + EmberPathReference.prototype.get = function get(key) { + return PropertyReference.create(this, key); }; + + return EmberPathReference; })(); - /** - Notifies event's subscribers, calls `before` and `after` hooks. - - @method instrument - @namespace Ember.Instrumentation - - @param {String} [name] Namespaced event name. - @param {Object} _payload - @param {Function} callback Function that you're instrumenting. - @param {Object} binding Context that instrument function is called with. - @private - */ + var CachedReference = (function (_EmberPathReference) { + babelHelpers.inherits(CachedReference, _EmberPathReference); - function instrument(name, _payload, callback, binding) { - if (arguments.length <= 3 && typeof _payload === 'function') { - binding = callback; - callback = _payload; - _payload = undefined; - } - if (subscribers.length === 0) { - return callback.call(binding); + function CachedReference() { + _EmberPathReference.call(this); + this._lastRevision = null; + this._lastValue = null; } - var payload = _payload || {}; - var finalizer = _instrumentStart(name, function () { - return payload; - }); - if (finalizer) { - return withFinalizer(callback, finalizer, payload, binding); - } else { - return callback.call(binding); - } - } + // @implements PathReference - var flaggedInstrument = undefined; - if (false) { - exports.flaggedInstrument = flaggedInstrument = instrument; - } else { - exports.flaggedInstrument = flaggedInstrument = function (name, payload, callback) { - return callback(); - }; - } - exports.flaggedInstrument = flaggedInstrument; + CachedReference.prototype.value = function value() { + var tag = this.tag; + var _lastRevision = this._lastRevision; + var _lastValue = this._lastValue; - function withFinalizer(callback, finalizer, payload, binding) { - var result = undefined; - try { - result = callback.call(binding); - } catch (e) { - payload.exception = e; - result = payload; - } finally { - finalizer(); - return result; - } - } + if (!_lastRevision || !tag.validate(_lastRevision)) { + _lastValue = this._lastValue = this.compute(); + this._lastRevision = tag.value(); + } - function NOOP() {} + return _lastValue; + }; - // private for now + // @abstract compute() + return CachedReference; + })(EmberPathReference); - function _instrumentStart(name, _payload, _payloadParam) { - if (subscribers.length === 0) { - return NOOP; - } + exports.CachedReference = CachedReference; - var listeners = cache[name]; + var RootReference = (function (_ConstReference) { + babelHelpers.inherits(RootReference, _ConstReference); - if (!listeners) { - listeners = populateListeners(name); + function RootReference(value) { + _ConstReference.call(this, value); + this.children = new _emberUtils.EmptyObject(); } - if (listeners.length === 0) { - return NOOP; - } + RootReference.prototype.get = function get(propertyKey) { + var ref = this.children[propertyKey]; - var payload = _payload(_payloadParam); + if (!ref) { + ref = this.children[propertyKey] = new RootPropertyReference(this.inner, propertyKey); + } - var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE; - var timeName = undefined; - if (STRUCTURED_PROFILE) { - timeName = name + ': ' + payload.object; - console.time(timeName); - } + return ref; + }; - var beforeValues = new Array(listeners.length); - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - beforeValues[i] = listener.before(name, timestamp, payload); - } + return RootReference; + })(_glimmerReference.ConstReference); - return function _instrumentEnd() { - var i = undefined, - listener = undefined; - var timestamp = time(); - for (i = 0; i < listeners.length; i++) { - listener = listeners[i]; - if (typeof listener.after === 'function') { - listener.after(name, timestamp, payload, beforeValues[i]); - } - } + exports.RootReference = RootReference; - if (STRUCTURED_PROFILE) { - console.timeEnd(timeName); + var TwoWayFlushDetectionTag = undefined; + + if (false || false) { + TwoWayFlushDetectionTag = (function () { + function _class(tag, key, ref) { + this.tag = tag; + this.parent = null; + this.key = key; + this.ref = ref; } - }; - } - /** - Subscribes to a particular event or instrumented block of code. - - @method subscribe - @namespace Ember.Instrumentation - - @param {String} [pattern] Namespaced event name. - @param {Object} [object] Before and After hooks. - - @return {Subscriber} - @private - */ + _class.prototype.value = function value() { + return this.tag.value(); + }; - function subscribe(pattern, object) { - var paths = pattern.split('.'); - var path = undefined; - var regex = []; + _class.prototype.validate = function validate(ticket) { + var parent = this.parent; + var key = this.key; - for (var i = 0; i < paths.length; i++) { - path = paths[i]; - if (path === '*') { - regex.push('[^\\.]*'); - } else { - regex.push(path); - } - } + var isValid = this.tag.validate(ticket); - regex = regex.join('\\.'); - regex = regex + '(\\..*)?'; + if (isValid && parent) { + _emberMetal.didRender(parent, key, this.ref); + } - var subscriber = { - pattern: pattern, - regex: new RegExp('^' + regex + '$'), - object: object - }; + return isValid; + }; - subscribers.push(subscriber); - cache = {}; + _class.prototype.didCompute = function didCompute(parent) { + this.parent = parent; + _emberMetal.didRender(parent, this.key, this.ref); + }; - return subscriber; + return _class; + })(); } - /** - Unsubscribes from a particular event or instrumented block of code. - - @method unsubscribe - @namespace Ember.Instrumentation - - @param {Object} [subscriber] - @private - */ - - function unsubscribe(subscriber) { - var index = undefined; + var PropertyReference = (function (_CachedReference) { + babelHelpers.inherits(PropertyReference, _CachedReference); - for (var i = 0; i < subscribers.length; i++) { - if (subscribers[i] === subscriber) { - index = i; - } + function PropertyReference() { + _CachedReference.apply(this, arguments); } - subscribers.splice(index, 1); - cache = {}; - } - - /** - Resets `Ember.Instrumentation` by flushing list of subscribers. - - @method reset - @namespace Ember.Instrumentation - @private - */ - - function reset() { - subscribers.length = 0; - cache = {}; - } -}); -enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, _emberMetalIs_empty) { - 'use strict'; - - exports.default = isBlank; + PropertyReference.create = function create(parentReference, propertyKey) { + if (_glimmerReference.isConst(parentReference)) { + return new RootPropertyReference(parentReference.value(), propertyKey); + } else { + return new NestedPropertyReference(parentReference, propertyKey); + } + }; - /** - A value is blank if it is empty or a whitespace string. - - ```javascript - Ember.isBlank(); // true - Ember.isBlank(null); // true - Ember.isBlank(undefined); // true - Ember.isBlank(''); // true - Ember.isBlank([]); // true - Ember.isBlank('\n\t'); // true - Ember.isBlank(' '); // true - Ember.isBlank({}); // false - Ember.isBlank('\n\t Hello'); // false - Ember.isBlank('Hello world'); // false - Ember.isBlank([1,2,3]); // false - ``` - - @method isBlank - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.5.0 - @public - */ + PropertyReference.prototype.get = function get(key) { + return new NestedPropertyReference(this, key); + }; - function isBlank(obj) { - return _emberMetalIs_empty.default(obj) || typeof obj === 'string' && obj.match(/\S/) === null; - } -}); -enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, _emberMetalProperty_get, _emberMetalIs_none) { - 'use strict'; + return PropertyReference; + })(CachedReference); - exports.default = isEmpty; + exports.PropertyReference = PropertyReference; - /** - Verifies that a value is `null` or an empty string, empty array, - or empty function. - - Constrains the rules on `Ember.isNone` by returning true for empty - string and empty arrays. - - ```javascript - Ember.isEmpty(); // true - Ember.isEmpty(null); // true - Ember.isEmpty(undefined); // true - Ember.isEmpty(''); // true - Ember.isEmpty([]); // true - Ember.isEmpty({}); // false - Ember.isEmpty('Adam Hawkins'); // false - Ember.isEmpty([0,1,2]); // false - Ember.isEmpty('\n\t'); // false - Ember.isEmpty(' '); // false - ``` - - @method isEmpty - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ + var RootPropertyReference = (function (_PropertyReference) { + babelHelpers.inherits(RootPropertyReference, _PropertyReference); - function isEmpty(obj) { - var none = _emberMetalIs_none.default(obj); - if (none) { - return none; - } + function RootPropertyReference(parentValue, propertyKey) { + _PropertyReference.call(this); - if (typeof obj.size === 'number') { - return !obj.size; - } + this._parentValue = parentValue; + this._propertyKey = propertyKey; - var objectType = typeof obj; + if (false || false) { + this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); + } else { + this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); + } - if (objectType === 'object') { - var size = _emberMetalProperty_get.get(obj, 'size'); - if (typeof size === 'number') { - return !size; + if (false) { + _emberMetal.watchKey(parentValue, propertyKey); } } - if (typeof obj.length === 'number' && objectType !== 'function') { - return !obj.length; - } + RootPropertyReference.prototype.compute = function compute() { + var _parentValue = this._parentValue; + var _propertyKey = this._propertyKey; - if (objectType === 'object') { - var _length = _emberMetalProperty_get.get(obj, 'length'); - if (typeof _length === 'number') { - return !_length; + if (false || false) { + this.tag.didCompute(_parentValue); } - } - return false; - } -}); -enifed("ember-metal/is_none", ["exports"], function (exports) { - /** - Returns true if the passed value is null or undefined. This avoids errors - from JSLint complaining about use of ==, which can be technically - confusing. - - ```javascript - Ember.isNone(); // true - Ember.isNone(null); // true - Ember.isNone(undefined); // true - Ember.isNone(''); // false - Ember.isNone([]); // false - Ember.isNone(function() {}); // false - ``` - - @method isNone - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @public - */ - "use strict"; + return _emberMetal.get(_parentValue, _propertyKey); + }; - exports.default = isNone; + RootPropertyReference.prototype[UPDATE] = function (value) { + _emberMetal.set(this._parentValue, this._propertyKey, value); + }; - function isNone(obj) { - return obj === null || obj === undefined; - } -}); -enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { - 'use strict'; + return RootPropertyReference; + })(PropertyReference); - exports.default = isPresent; + exports.RootPropertyReference = RootPropertyReference; - /** - A value is present if it not `isBlank`. - - ```javascript - Ember.isPresent(); // false - Ember.isPresent(null); // false - Ember.isPresent(undefined); // false - Ember.isPresent(''); // false - Ember.isPresent(' '); // false - Ember.isPresent('\n\t'); // false - Ember.isPresent([]); // false - Ember.isPresent({ length: 0 }) // false - Ember.isPresent(false); // true - Ember.isPresent(true); // true - Ember.isPresent('string'); // true - Ember.isPresent(0); // true - Ember.isPresent(function() {}) // true - Ember.isPresent({}); // true - Ember.isPresent(false); // true - Ember.isPresent('\n\t Hello'); // true - Ember.isPresent([1,2,3]); // true - ``` - - @method isPresent - @for Ember - @param {Object} obj Value to test - @return {Boolean} - @since 1.8.0 - @public - */ + var NestedPropertyReference = (function (_PropertyReference2) { + babelHelpers.inherits(NestedPropertyReference, _PropertyReference2); - function isPresent(obj) { - return !_emberMetalIs_blank.default(obj); - } -}); -enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { - 'use strict'; + function NestedPropertyReference(parentReference, propertyKey) { + _PropertyReference2.call(this); - exports.isProxy = isProxy; + var parentReferenceTag = parentReference.tag; + var parentObjectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - function isProxy(value) { - if (typeof value === 'object' && value) { - var meta = _emberMetalMeta.peekMeta(value); - return meta && meta.isProxy(); - } + this._parentReference = parentReference; + this._parentObjectTag = parentObjectTag; + this._propertyKey = propertyKey; - return false; - } -}); -enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; + if (false || false) { + var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); + this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); + } else { + this.tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); + } + } - exports.Libraries = Libraries; + NestedPropertyReference.prototype.compute = function compute() { + var _parentReference = this._parentReference; + var _parentObjectTag = this._parentObjectTag; + var _propertyKey = this._propertyKey; - /** - Helper class that allows you to register your library with Ember. - - Singleton created at `Ember.libraries`. - - @class Libraries - @constructor - @private - */ + var parentValue = _parentReference.value(); - function Libraries() { - this._registry = []; - this._coreLibIndex = 0; - } + _parentObjectTag.update(_emberMetal.tagForProperty(parentValue, _propertyKey)); - Libraries.prototype = { - constructor: Libraries, + if (typeof parentValue === 'string' && _propertyKey === 'length') { + return parentValue.length; + } - _getLibraryByName: function (name) { - var libs = this._registry; - var count = libs.length; + if (typeof parentValue === 'object' && parentValue) { + if (false) { + _emberMetal.watchKey(parentValue, _propertyKey); + } - for (var i = 0; i < count; i++) { - if (libs[i].name === name) { - return libs[i]; + if (false || false) { + this.tag.didCompute(parentValue); } + + return _emberMetal.get(parentValue, _propertyKey); + } else { + return undefined; } - }, + }; - register: function (name, version, isCoreLibrary) { - var index = this._registry.length; + NestedPropertyReference.prototype[UPDATE] = function (value) { + var parent = this._parentReference.value(); + _emberMetal.set(parent, this._propertyKey, value); + }; - if (!this._getLibraryByName(name)) { - if (isCoreLibrary) { - index = this._coreLibIndex++; - } - this._registry.splice(index, 0, { name: name, version: version }); - } else {} - }, + return NestedPropertyReference; + })(PropertyReference); - registerCoreLibrary: function (name, version) { - this.register(name, version, true); - }, + exports.NestedPropertyReference = NestedPropertyReference; - deRegister: function (name) { - var lib = this._getLibraryByName(name); - var index = undefined; + var UpdatableReference = (function (_EmberPathReference2) { + babelHelpers.inherits(UpdatableReference, _EmberPathReference2); - if (lib) { - index = this._registry.indexOf(lib); - this._registry.splice(index, 1); - } + function UpdatableReference(value) { + _EmberPathReference2.call(this); + + this.tag = new _glimmerReference.DirtyableTag(); + this._value = value; } - }; - if (false) { - Libraries.prototype.isRegistered = function (name) { - return !!this._getLibraryByName(name); + UpdatableReference.prototype.value = function value() { + return this._value; }; - } - exports.default = new Libraries(); -}); -enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) { - /** - @module ember - @submodule ember-metal - */ + UpdatableReference.prototype.update = function update(value) { + var _value = this._value; - /* - JavaScript (before ES6) does not have a Map implementation. Objects, - which are often used as dictionaries, may only have Strings as keys. - - Because Ember has a way to get a unique identifier for every object - via `Ember.guidFor`, we can implement a performant Map with arbitrary - keys. Because it is commonly used in low-level bookkeeping, Map is - implemented as a pure JavaScript object for performance. - - This implementation follows the current iteration of the ES6 proposal for - maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets), - with one exception: as we do not have the luxury of in-VM iteration, we implement a - forEach method for iteration. - - Map is mocked out to look like an Ember object, so you can do - `Ember.Map.create()` for symmetry with other Ember classes. - */ - 'use strict'; + if (value !== _value) { + this.tag.dirty(); + this._value = value; + } + }; - function missingFunction(fn) { - throw new TypeError(Object.prototype.toString.call(fn) + ' is not a function'); - } + return UpdatableReference; + })(EmberPathReference); - function missingNew(name) { - throw new TypeError('Constructor ' + name + ' requires \'new\''); - } + exports.UpdatableReference = UpdatableReference; - function copyNull(obj) { - var output = new _emberUtils.EmptyObject(); + var UpdatablePrimitiveReference = (function (_UpdatableReference) { + babelHelpers.inherits(UpdatablePrimitiveReference, _UpdatableReference); - for (var prop in obj) { - // hasOwnPropery is not needed because obj is new EmptyObject(); - output[prop] = obj[prop]; + function UpdatablePrimitiveReference() { + _UpdatableReference.apply(this, arguments); } - return output; - } + UpdatablePrimitiveReference.prototype.get = function get() { + return _glimmerRuntime.UNDEFINED_REFERENCE; + }; - function copyMap(original, newObject) { - var keys = original._keys.copy(); - var values = copyNull(original._values); + return UpdatablePrimitiveReference; + })(UpdatableReference); - newObject._keys = keys; - newObject._values = values; - newObject.size = original.size; + exports.UpdatablePrimitiveReference = UpdatablePrimitiveReference; - return newObject; - } + var ConditionalReference = (function (_GlimmerConditionalReference) { + babelHelpers.inherits(ConditionalReference, _GlimmerConditionalReference); - /** - This class is used internally by Ember and Ember Data. - Please do not use it at this time. We plan to clean it up - and add many tests soon. - - @class OrderedSet - @namespace Ember - @constructor - @private - */ - function OrderedSet() { - if (this instanceof OrderedSet) { - this.clear(); - this._silenceRemoveDeprecation = false; - } else { - missingNew('OrderedSet'); - } - } + ConditionalReference.create = function create(reference) { + if (_glimmerReference.isConst(reference)) { + var value = reference.value(); - /** - @method create - @static - @return {Ember.OrderedSet} - @private - */ - OrderedSet.create = function () { - var Constructor = this; + if (_emberMetal.isProxy(value)) { + return new RootPropertyReference(value, 'isTruthy'); + } else { + return _glimmerRuntime.PrimitiveReference.create(_emberGlimmerUtilsToBool.default(value)); + } + } - return new Constructor(); - }; + return new ConditionalReference(reference); + }; - OrderedSet.prototype = { - constructor: OrderedSet, - /** - @method clear - @private - */ - clear: function () { - this.presenceSet = new _emberUtils.EmptyObject(); - this.list = []; - this.size = 0; - }, + function ConditionalReference(reference) { + _GlimmerConditionalReference.call(this, reference); - /** - @method add - @param obj - @param guid (optional, and for internal use) - @return {Ember.OrderedSet} - @private - */ - add: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; + this.objectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); + this.tag = _glimmerReference.combine([reference.tag, this.objectTag]); + } - if (presenceSet[guid] !== true) { - presenceSet[guid] = true; - this.size = list.push(obj); + ConditionalReference.prototype.toBool = function toBool(predicate) { + if (_emberMetal.isProxy(predicate)) { + this.objectTag.update(_emberMetal.tagForProperty(predicate, 'isTruthy')); + return _emberMetal.get(predicate, 'isTruthy'); + } else { + this.objectTag.update(_emberMetal.tagFor(predicate)); + return _emberGlimmerUtilsToBool.default(predicate); } + }; - return this; - }, + return ConditionalReference; + })(_glimmerRuntime.ConditionalReference); - /** - @since 1.8.0 - @method delete - @param obj - @param _guid (optional and for internal use only) - @return {Boolean} - @private - */ - delete: function (obj, _guid) { - var guid = _guid || _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; + exports.ConditionalReference = ConditionalReference; - if (presenceSet[guid] === true) { - delete presenceSet[guid]; - var index = list.indexOf(obj); - if (index > -1) { - list.splice(index, 1); - } - this.size = list.length; - return true; - } else { - return false; - } - }, + var SimpleHelperReference = (function (_CachedReference2) { + babelHelpers.inherits(SimpleHelperReference, _CachedReference2); - /** - @method isEmpty - @return {Boolean} - @private - */ - isEmpty: function () { - return this.size === 0; - }, + SimpleHelperReference.create = function create(helper, args) { + if (_glimmerReference.isConst(args)) { + var positional = args.positional; + var named = args.named; - /** - @method has - @param obj - @return {Boolean} - @private - */ - has: function (obj) { - if (this.size === 0) { - return false; + var positionalValue = positional.value(); + var namedValue = named.value(); + + var result = helper(positionalValue, namedValue); + + if (result === null) { + return _glimmerRuntime.NULL_REFERENCE; + } else if (result === undefined) { + return _glimmerRuntime.UNDEFINED_REFERENCE; + } else if (typeof result === 'object') { + return new RootReference(result); + } else { + return _glimmerRuntime.PrimitiveReference.create(result); + } + } else { + return new SimpleHelperReference(helper, args); } + }; - var guid = _emberUtils.guidFor(obj); - var presenceSet = this.presenceSet; + function SimpleHelperReference(helper, args) { + _CachedReference2.call(this); - return presenceSet[guid] === true; - }, + this.tag = args.tag; + this.helper = helper; + this.args = args; + } - /** - @method forEach - @param {Function} fn - @param self - @private - */ - forEach: function (fn /*, ...thisArg*/) { - if (typeof fn !== 'function') { - missingFunction(fn); - } + SimpleHelperReference.prototype.compute = function compute() { + var helper = this.helper; + var _args = this.args; + var positional = _args.positional; + var named = _args.named; - if (this.size === 0) { - return; - } + var positionalValue = positional.value(); + var namedValue = named.value(); - var list = this.list; + return helper(positionalValue, namedValue); + }; - if (arguments.length === 2) { - for (var i = 0; i < list.length; i++) { - fn.call(arguments[1], list[i]); - } - } else { - for (var i = 0; i < list.length; i++) { - fn(list[i]); - } - } - }, + return SimpleHelperReference; + })(CachedReference); - /** - @method toArray - @return {Array} - @private - */ - toArray: function () { - return this.list.slice(); - }, + exports.SimpleHelperReference = SimpleHelperReference; - /** - @method copy - @return {Ember.OrderedSet} - @private - */ - copy: function () { - var Constructor = this.constructor; - var set = new Constructor(); + var ClassBasedHelperReference = (function (_CachedReference3) { + babelHelpers.inherits(ClassBasedHelperReference, _CachedReference3); - set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; - set.presenceSet = copyNull(this.presenceSet); - set.list = this.toArray(); - set.size = this.size; + ClassBasedHelperReference.create = function create(helperClass, vm, args) { + var instance = helperClass.create(); + vm.newDestroyable(instance); + return new ClassBasedHelperReference(instance, args); + }; - return set; - } - }; + function ClassBasedHelperReference(instance, args) { + _CachedReference3.call(this); - /** - A Map stores values indexed by keys. Unlike JavaScript's - default Objects, the keys of a Map can be any JavaScript - object. - - Internally, a Map has two data structures: - - 1. `keys`: an OrderedSet of all of the existing keys - 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)` - - When a key/value pair is added for the first time, we - add the key to the `keys` OrderedSet, and create or - replace an entry in `values`. When an entry is deleted, - we delete its entry in `keys` and `values`. - - @class Map - @namespace Ember - @private - @constructor - */ - function Map() { - if (this instanceof Map) { - this._keys = OrderedSet.create(); - this._keys._silenceRemoveDeprecation = true; - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - } else { - missingNew('Map'); + this.tag = _glimmerReference.combine([instance[_emberGlimmerHelper.RECOMPUTE_TAG], args.tag]); + this.instance = instance; + this.args = args; } - } - /** - @method create - @static - @private - */ - Map.create = function () { - var Constructor = this; - return new Constructor(); - }; + ClassBasedHelperReference.prototype.compute = function compute() { + var instance = this.instance; + var _args2 = this.args; + var positional = _args2.positional; + var named = _args2.named; - Map.prototype = { - constructor: Map, + var positionalValue = positional.value(); + var namedValue = named.value(); - /** - This property will change as the number of objects in the map changes. - @since 1.8.0 - @property size - @type number - @default 0 - @private - */ - size: 0, + return instance.compute(positionalValue, namedValue); + }; - /** - Retrieve the value associated with a given key. - @method get - @param {*} key - @return {*} the value associated with the key, or `undefined` - @private - */ - get: function (key) { - if (this.size === 0) { - return; - } + return ClassBasedHelperReference; + })(CachedReference); - var values = this._values; - var guid = _emberUtils.guidFor(key); + exports.ClassBasedHelperReference = ClassBasedHelperReference; - return values[guid]; - }, + var InternalHelperReference = (function (_CachedReference4) { + babelHelpers.inherits(InternalHelperReference, _CachedReference4); - /** - Adds a value to the map. If a value for the given key has already been - provided, the new value will replace the old value. - @method set - @param {*} key - @param {*} value - @return {Ember.Map} - @private - */ - set: function (key, value) { - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); + function InternalHelperReference(helper, args) { + _CachedReference4.call(this); - // ensure we don't store -0 - var k = key === -0 ? 0 : key; + this.tag = args.tag; + this.helper = helper; + this.args = args; + } - keys.add(k, guid); + // @implements PathReference - values[guid] = value; + InternalHelperReference.prototype.compute = function compute() { + var helper = this.helper; + var args = this.args; - this.size = keys.size; + return helper(args); + }; - return this; - }, + return InternalHelperReference; + })(CachedReference); - /** - Removes a value from the map for an associated key. - @since 1.8.0 - @method delete - @param {*} key - @return {Boolean} true if an item was removed, false otherwise - @private - */ - delete: function (key) { - if (this.size === 0) { - return false; - } - // don't use ES6 "delete" because it will be annoying - // to use in browsers that are not ES6 friendly; - var keys = this._keys; - var values = this._values; - var guid = _emberUtils.guidFor(key); + exports.InternalHelperReference = InternalHelperReference; - if (keys.delete(key, guid)) { - delete values[guid]; - this.size = keys.size; - return true; - } else { - return false; - } - }, + var UnboundReference = (function (_ConstReference2) { + babelHelpers.inherits(UnboundReference, _ConstReference2); - /** - Check whether a key is present. - @method has - @param {*} key - @return {Boolean} true if the item was present, false otherwise - @private - */ - has: function (key) { - return this._keys.has(key); - }, + function UnboundReference() { + _ConstReference2.apply(this, arguments); + } - /** - Iterate over all the keys and values. Calls the function once - for each key, passing in value, key, and the map being iterated over, - in that order. - The keys are guaranteed to be iterated over in insertion order. - @method forEach - @param {Function} callback - @param {*} self if passed, the `this` value inside the - callback. By default, `this` is the map. - @private - */ - forEach: function (callback /*, ...thisArg*/) { - if (typeof callback !== 'function') { - missingFunction(callback); + UnboundReference.create = function create(value) { + if (value === null) { + return _glimmerRuntime.NULL_REFERENCE; + } else if (value === undefined) { + return _glimmerRuntime.UNDEFINED_REFERENCE; + } else if (typeof value === 'object') { + return new UnboundReference(value); + } else { + return _glimmerRuntime.PrimitiveReference.create(value); } + }; - if (this.size === 0) { - return; - } + UnboundReference.prototype.get = function get(key) { + return new UnboundReference(_emberMetal.get(this.inner, key)); + }; - var map = this; - var cb = undefined, - thisArg = undefined; + return UnboundReference; + })(_glimmerReference.ConstReference); - if (arguments.length === 2) { - thisArg = arguments[1]; - cb = function (key) { - return callback.call(thisArg, map.get(key), key, map); - }; - } else { - cb = function (key) { - return callback(map.get(key), key, map); - }; - } + exports.UnboundReference = UnboundReference; +}); +enifed('ember-glimmer/utils/string', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-glimmer + */ - this._keys.forEach(cb); - }, + 'use strict'; - /** - @method clear - @private - */ - clear: function () { - this._keys.clear(); - this._values = new _emberUtils.EmptyObject(); - this.size = 0; - }, + exports.getSafeString = getSafeString; + exports.escapeExpression = escapeExpression; + exports.htmlSafe = htmlSafe; + exports.isHTMLSafe = isHTMLSafe; - /** - @method copy - @return {Ember.Map} - @private - */ - copy: function () { - return copyMap(this, new Map()); + var SafeString = (function () { + function SafeString(string) { + this.string = string; } + + SafeString.prototype.toString = function toString() { + return '' + this.string; + }; + + SafeString.prototype.toHTML = function toHTML() { + return this.toString(); + }; + + return SafeString; + })(); + + exports.SafeString = SafeString; + + function getSafeString() { + + return SafeString; + } + + var escape = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + // jscs:disable + "'": ''', + // jscs:enable + '`': '`', + '=': '=' }; - /** - @class MapWithDefault - @namespace Ember - @extends Ember.Map - @private - @constructor - @param [options] - @param {*} [options.defaultValue] - */ - function MapWithDefault(options) { - this._super$constructor(); - this.defaultValue = options.defaultValue; + var possible = /[&<>"'`=]/; + var badChars = /[&<>"'`=]/g; + + function escapeChar(chr) { + return escape[chr]; } - /** - @method create - @static - @param [options] - @param {*} [options.defaultValue] - @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns - `Ember.MapWithDefault` otherwise returns `Ember.Map` - @private - */ - MapWithDefault.create = function (options) { - if (options) { - return new MapWithDefault(options); - } else { - return new Map(); + function escapeExpression(string) { + if (typeof string !== 'string') { + // don't escape SafeStrings, since they're already safe + if (string && string.toHTML) { + return string.toHTML(); + } else if (string == null) { + return ''; + } else if (!string) { + return string + ''; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = '' + string; } - }; - MapWithDefault.prototype = Object.create(Map.prototype); - MapWithDefault.prototype.constructor = MapWithDefault; - MapWithDefault.prototype._super$constructor = Map; - MapWithDefault.prototype._super$get = Map.prototype.get; + if (!possible.test(string)) { + return string; + } + return string.replace(badChars, escapeChar); + } /** - Retrieve the value associated with a given key. + Mark a string as safe for unescaped output with Ember templates. If you + return HTML from a helper, use this function to + ensure Ember's rendering layer does not escape the HTML. - @method get - @param {*} key - @return {*} the value associated with the key, or the default value - @private + ```javascript + Ember.String.htmlSafe('
    someString
    ') + ``` + + @method htmlSafe + @for Ember.String + @static + @return {Handlebars.SafeString} A string that will not be HTML escaped by Handlebars. + @public */ - MapWithDefault.prototype.get = function (key) { - var hasValue = this.has(key); - if (hasValue) { - return this._super$get(key); - } else { - var defaultValue = this.defaultValue(key); - this.set(key, defaultValue); - return defaultValue; + function htmlSafe(str) { + if (str === null || str === undefined) { + str = ''; + } else if (typeof str !== 'string') { + str = '' + str; } - }; - - /** - @method copy - @return {Ember.MapWithDefault} - @private - */ - MapWithDefault.prototype.copy = function () { - var Constructor = this.constructor; - return copyMap(this, new Constructor({ - defaultValue: this.defaultValue - })); - }; + return new SafeString(str); + } - exports.default = Map; - exports.OrderedSet = OrderedSet; - exports.Map = Map; - exports.MapWithDefault = MapWithDefault; -}); -enifed('ember-metal/merge', ['exports'], function (exports) { /** - Merge the contents of two objects together into the first object. + Detects if a string was decorated using `Ember.String.htmlSafe`. ```javascript - Ember.merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' } - var a = { first: 'Yehuda' }; - var b = { last: 'Katz' }; - Ember.merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' } + var plainString = 'plain string', + safeString = Ember.String.htmlSafe('
    someValue
    '); + + Ember.String.isHTMLSafe(plainString); // false + Ember.String.isHTMLSafe(safeString); // true ``` - @method merge - @for Ember - @param {Object} original The object to merge into - @param {Object} updates The object to copy properties from - @return {Object} + @method isHTMLSafe + @for Ember.String + @static + @return {Boolean} `true` if the string was decorated with `htmlSafe`, `false` otherwise. @public */ + + function isHTMLSafe(str) { + return str && typeof str.toHTML === 'function'; + } +}); +enifed('ember-glimmer/utils/to-bool', ['exports', 'ember-runtime', 'ember-metal'], function (exports, _emberRuntime, _emberMetal) { 'use strict'; - exports.default = merge; + exports.default = toBool; - function merge(original, updates) { - if (!updates || typeof updates !== 'object') { - return original; + function toBool(predicate) { + if (!predicate) { + return false; } - var props = Object.keys(updates); - var prop = undefined; + if (predicate === true) { + return true; + } - for (var i = 0; i < props.length; i++) { - prop = props[i]; - original[prop] = updates[prop]; + if (_emberRuntime.isArray(predicate)) { + return _emberMetal.get(predicate, 'length') !== 0; } - return original; + return true; } }); -enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed +enifed('ember-glimmer/views/outlet', ['exports', 'ember-utils', '@glimmer/reference', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _glimmerReference, _emberEnvironment, _emberMetal) { + /** + @module ember + @submodule ember-glimmer + */ + 'use strict'; - exports.Meta = Meta; - exports.deleteMeta = deleteMeta; - exports.meta = meta; + var OutletStateReference = (function () { + function OutletStateReference(outletView) { + this.outletView = outletView; + this.tag = outletView._tag; + } - var counters = { - peekCalls: 0, - peekParentCalls: 0, - peekPrototypeWalks: 0, - setCalls: 0, - deleteCalls: 0, - metaCalls: 0, - metaInstantiated: 0 - }; + // So this is a relic of the past that SHOULD go away + // in 3.0. Preferably it is deprecated in the release that + // follows the Glimmer release. - /** - @module ember-metal - */ + OutletStateReference.prototype.get = function get(key) { + return new ChildOutletStateReference(this, key); + }; - /* - This declares several meta-programmed members on the Meta class. Such - meta! - - In general, the `readable` variants will give you an object (if it - already exists) that you can read but should not modify. The - `writable` variants will give you a mutable object, and they will - create it if it didn't already exist. - - The following methods will get generated metaprogrammatically, and - I'm including them here for greppability: - - writableCache, readableCache, writeWatching, - peekWatching, clearWatching, writeMixins, - peekMixins, clearMixins, writeBindings, - peekBindings, clearBindings, writeValues, - peekValues, clearValues, writeDeps, forEachInDeps - writableChainWatchers, readableChainWatchers, writableChains, - readableChains, writableTag, readableTag, writableTags, - readableTags - */ - var members = { - cache: ownMap, - weak: ownMap, - watching: inheritedMap, - mixins: inheritedMap, - bindings: inheritedMap, - values: inheritedMap, - chainWatchers: ownCustomObject, - chains: inheritedCustomObject, - tag: ownCustomObject, - tags: ownMap - }; + OutletStateReference.prototype.value = function value() { + return this.outletView.outletState; + }; - // FLAGS - var SOURCE_DESTROYING = 1 << 1; - var SOURCE_DESTROYED = 1 << 2; - var META_DESTROYED = 1 << 3; - var IS_PROXY = 1 << 4; + OutletStateReference.prototype.getOrphan = function getOrphan(name) { + return new OrphanedOutletStateReference(this, name); + }; - if (false || false) { - members.lastRendered = ownMap; - members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds - } + OutletStateReference.prototype.update = function update(state) { + this.outletView.setOutletState(state); + }; - var memberNames = Object.keys(members); - var META_FIELD = '__ember_meta__'; + return OutletStateReference; + })(); - 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; - this._chainWatchers = undefined; - this._chains = undefined; - this._tag = undefined; - this._tags = undefined; - - // initial value for all flags right now is false - // see FLAGS const for detailed list of flags used - this._flags = 0; - - // used only internally - this.source = obj; - - // when meta(obj).proto === obj, the object is intended to be only a - // prototype and doesn't need to actually be observable itself - this.proto = undefined; - - // The next meta in our inheritance chain. We (will) track this - // explicitly instead of using prototypical inheritance because we - // have detailed knowledge of how each property should really be - // inherited, and we can optimize it much better than JS runtimes. - this.parent = parentMeta; + var OrphanedOutletStateReference = (function (_OutletStateReference) { + babelHelpers.inherits(OrphanedOutletStateReference, _OutletStateReference); - if (false || false) { - this._lastRendered = undefined; - this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds + function OrphanedOutletStateReference(root, name) { + _OutletStateReference.call(this, root.outletView); + this.root = root; + this.name = name; } - this._initializeListeners(); - } - - Meta.prototype.isInitialized = function (obj) { - return this.proto !== obj; - }; + OrphanedOutletStateReference.prototype.value = function value() { + var rootState = this.root.value(); - var NODE_STACK = []; + var orphans = rootState.outlets.main.outlets.__ember_orphans__; - Meta.prototype.destroy = function () { - if (this.isMetaDestroyed()) { - return; - } + if (!orphans) { + return null; + } - // remove chainWatchers to remove circular references that would prevent GC - var node = undefined, - nodes = undefined, - key = undefined, - nodeObject = undefined; - node = this.readableChains(); - if (node) { - NODE_STACK.push(node); - // process tree - while (NODE_STACK.length > 0) { - node = NODE_STACK.pop(); - // push children - nodes = node._chains; - if (nodes) { - for (key in nodes) { - if (nodes[key] !== undefined) { - NODE_STACK.push(nodes[key]); - } - } - } + var matched = orphans.outlets[this.name]; - // remove chainWatcher in node object - if (node._watching) { - nodeObject = node._object; - if (nodeObject) { - var foreignMeta = peekMeta(nodeObject); - // avoid cleaning up chain watchers when both current and - // foreign objects are being destroyed - // if both are being destroyed manual cleanup is not needed - // as they will be GC'ed and no non-destroyed references will - // be remaining - if (foreignMeta && !foreignMeta.isSourceDestroying()) { - _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); - } - } - } + if (!matched) { + return null; } - } - this.setMetaDestroyed(); - }; + var state = new _emberUtils.EmptyObject(); + state[matched.render.outlet] = matched; + matched.wasUsed = true; + return { outlets: state }; + }; - for (var _name in _emberMetalMeta_listeners.protoMethods) { - Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; - } - memberNames.forEach(function (name) { - return members[name](name, Meta); - }); + return OrphanedOutletStateReference; + })(OutletStateReference); - Meta.prototype.isSourceDestroying = function isSourceDestroying() { - return (this._flags & SOURCE_DESTROYING) !== 0; - }; + var ChildOutletStateReference = (function () { + function ChildOutletStateReference(parent, key) { + this.parent = parent; + this.key = key; + this.tag = parent.tag; + } - Meta.prototype.setSourceDestroying = function setSourceDestroying() { - this._flags |= SOURCE_DESTROYING; - }; + ChildOutletStateReference.prototype.get = function get(key) { + return new ChildOutletStateReference(this, key); + }; - Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { - return (this._flags & SOURCE_DESTROYED) !== 0; - }; + ChildOutletStateReference.prototype.value = function value() { + return this.parent.value()[this.key]; + }; - Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { - this._flags |= SOURCE_DESTROYED; - }; + return ChildOutletStateReference; + })(); - Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { - return (this._flags & META_DESTROYED) !== 0; - }; + var OutletView = (function () { + OutletView.extend = function extend(injections) { + return (function (_OutletView) { + babelHelpers.inherits(_class, _OutletView); - Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { - this._flags |= META_DESTROYED; - }; + function _class() { + _OutletView.apply(this, arguments); + } - Meta.prototype.isProxy = function isProxy() { - return (this._flags & IS_PROXY) !== 0; - }; + _class.create = function create(options) { + if (options) { + return _OutletView.create.call(this, _emberUtils.assign({}, injections, options)); + } else { + return _OutletView.create.call(this, injections); + } + }; - Meta.prototype.setProxy = function setProxy() { - this._flags |= IS_PROXY; - }; + return _class; + })(OutletView); + }; - // Implements a member that is a lazily created, non-inheritable - // POJO. - function ownMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function () { - return this._getOrCreateOwnMap(key); + OutletView.reopenClass = function reopenClass(injections) { + _emberUtils.assign(this, injections); }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; + + OutletView.create = function create(options) { + var _environment = options._environment; + var renderer = options.renderer; + var template = options.template; + + var owner = options[_emberUtils.OWNER]; + return new OutletView(_environment, renderer, owner, template); }; - } - Meta.prototype._getOrCreateOwnMap = function (key) { - var ret = this[key]; - if (!ret) { - ret = this[key] = new _emberUtils.EmptyObject(); + function OutletView(_environment, renderer, owner, template) { + this._environment = _environment; + this.renderer = renderer; + this.owner = owner; + this.template = template; + this.outletState = null; + this._tag = new _glimmerReference.DirtyableTag(); } - return ret; - }; - // Implements a member that is a lazily created POJO with inheritable - // values. - function inheritedMap(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); + OutletView.prototype.appendTo = function appendTo(selector) { + var env = this._environment || _emberEnvironment.environment; + var target = undefined; - Meta.prototype['write' + capitalized] = function (subkey, value) { + if (env.hasDOM) { + target = typeof selector === 'string' ? document.querySelector(selector) : selector; + } else { + target = selector; + } - var map = this._getOrCreateOwnMap(key); - map[subkey] = value; + _emberMetal.run.schedule('render', this.renderer, 'appendOutletView', this, target); }; - Meta.prototype['peek' + capitalized] = function (subkey) { - return this._findInherited(key, subkey); - }; + OutletView.prototype.rerender = function rerender() {}; - Meta.prototype['forEach' + capitalized] = function (fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - for (var _key in map) { - if (!seen[_key]) { - seen[_key] = true; - fn(_key, map[_key]); - } - } + OutletView.prototype.setOutletState = function setOutletState(state) { + this.outletState = { + outlets: { + main: state + }, + render: { + owner: undefined, + into: undefined, + outlet: 'main', + name: '-top-level', + controller: undefined, + ViewClass: undefined, + template: undefined } - pointer = pointer.parent; - } + }; + this._tag.dirty(); }; - Meta.prototype['clear' + capitalized] = function () { - - this[key] = undefined; + OutletView.prototype.toReference = function toReference() { + return new OutletStateReference(this); }; - Meta.prototype['deleteFrom' + capitalized] = function (subkey) { - delete this._getOrCreateOwnMap(key)[subkey]; - }; + OutletView.prototype.destroy = function destroy() {}; - Meta.prototype['hasIn' + capitalized] = function (subkey) { - return this._findInherited(key, subkey) !== undefined; - }; - } + return OutletView; + })(); - Meta.prototype._getInherited = function (key) { - var pointer = this; - while (pointer !== undefined) { - if (pointer[key]) { - return pointer[key]; - } - pointer = pointer.parent; - } - }; + exports.default = OutletView; +}); +enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) { + 'use strict'; - Meta.prototype._findInherited = function (key, subkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var value = map[subkey]; - if (value !== undefined) { - return value; - } - } - pointer = pointer.parent; - } - }; + exports.default = alias; - var UNDEFINED = _emberUtils.symbol('undefined'); + var CONSUMED = {}; - exports.UNDEFINED = UNDEFINED; - // Implements a member that provides a lazily created map of maps, - // with inheritance at both levels. - Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { + function alias(altKey) { + return new AliasedProperty(altKey); + } - var outerMap = this._getOrCreateOwnMap('_deps'); - var innerMap = outerMap[subkey]; - if (!innerMap) { - innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); - } - innerMap[itemkey] = value; - }; + var AliasedProperty = (function (_Descriptor) { + babelHelpers.inherits(AliasedProperty, _Descriptor); - Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { - var pointer = this; - while (pointer !== undefined) { - var map = pointer._deps; - if (map) { - var value = map[subkey]; - if (value) { - if (value[itemkey] !== undefined) { - return value[itemkey]; - } - } - } - pointer = pointer.parent; + function AliasedProperty(altKey) { + _Descriptor.call(this); + this.isDescriptor = true; + this.altKey = altKey; + this._dependentKeys = [altKey]; } - }; - Meta.prototype.hasDeps = function hasDeps(subkey) { - var pointer = this; - while (pointer !== undefined) { - if (pointer._deps && pointer._deps[subkey]) { - return true; + AliasedProperty.prototype.setup = function setup(obj, keyName) { + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); } - pointer = pointer.parent; - } - return false; - }; - - Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { - return this._forEachIn('_deps', subkey, fn); - }; + }; - Meta.prototype._forEachIn = function (key, subkey, fn) { - var pointer = this; - var seen = new _emberUtils.EmptyObject(); - var calls = []; - while (pointer !== undefined) { - var map = pointer[key]; - if (map) { - var innerMap = map[subkey]; - if (innerMap) { - for (var innerKey in innerMap) { - if (!seen[innerKey]) { - seen[innerKey] = true; - calls.push([innerKey, innerMap[innerKey]]); - } - } - } + AliasedProperty.prototype.teardown = function teardown(obj, keyName) { + var meta = _emberMetalMeta.meta(obj); + if (meta.peekWatching(keyName)) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); } - pointer = pointer.parent; - } - for (var i = 0; i < calls.length; i++) { - var _calls$i = calls[i]; - var innerKey = _calls$i[0]; - var value = _calls$i[1]; + }; - fn(innerKey, value); - } - }; + AliasedProperty.prototype.willWatch = function willWatch(obj, keyName) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); + }; - // Implements a member that provides a non-heritable, lazily-created - // object using the method you provide. - function ownCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { + AliasedProperty.prototype.didUnwatch = function didUnwatch(obj, keyName) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj)); + }; - var ret = this[key]; - if (!ret) { - ret = this[key] = create(this.source); + AliasedProperty.prototype.get = function get(obj, keyName) { + var ret = _emberMetalProperty_get.get(obj, this.altKey); + var meta = _emberMetalMeta.meta(obj); + var cache = meta.writableCache(); + if (cache[keyName] !== CONSUMED) { + cache[keyName] = CONSUMED; + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); } return ret; }; - Meta.prototype['readable' + capitalized] = function () { - return this[key]; - }; - } - // Implements a member that provides an inheritable, lazily-created - // object using the method you provide. We will derived children from - // their parents by calling your object's `copy()` method. - function inheritedCustomObject(name, Meta) { - var key = memberProperty(name); - var capitalized = capitalize(name); - Meta.prototype['writable' + capitalized] = function (create) { + AliasedProperty.prototype.set = function set(obj, keyName, value) { + return _emberMetalProperty_set.set(obj, this.altKey, value); + }; - var ret = this[key]; - if (!ret) { - if (this.parent) { - ret = this[key] = this.parent['writable' + capitalized](create).copy(this.source); - } else { - ret = this[key] = create(this.source); - } - } - return ret; + AliasedProperty.prototype.readOnly = function readOnly() { + this.set = AliasedProperty_readOnlySet; + return this; }; - Meta.prototype['readable' + capitalized] = function () { - return this._getInherited(key); + + AliasedProperty.prototype.oneWay = function oneWay() { + this.set = AliasedProperty_oneWaySet; + return this; }; - } - function memberProperty(name) { - return '_' + name; + return AliasedProperty; + })(_emberMetalProperties.Descriptor); + + exports.AliasedProperty = AliasedProperty; + + function AliasedProperty_readOnlySet(obj, keyName, value) { + throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj)); } - // there's a more general-purpose capitalize in ember-runtime, but we - // don't want to make ember-metal depend on ember-runtime. - function capitalize(name) { - return name.replace(/^\w/, function (m) { - return m.toUpperCase(); - }); + function AliasedProperty_oneWaySet(obj, keyName, value) { + _emberMetalProperties.defineProperty(obj, keyName, null); + return _emberMetalProperty_set.set(obj, keyName, value); } - var META_DESC = { - writable: true, - configurable: true, - enumerable: false, - value: null - }; + // Backwards compatibility with Ember Data. + AliasedProperty.prototype._meta = undefined; + AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta; +}); +enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) { + 'use strict'; - exports.META_DESC = META_DESC; - var EMBER_META_PROPERTY = { - name: META_FIELD, - descriptor: META_DESC - }; + exports.bind = bind; - if (false) { - Meta.prototype.readInheritedValue = function (key, subkey) { - var internalKey = '_' + key; + /** + @module ember + @submodule ember-metal + */ - var pointer = this; + // .......................................................... + // BINDING + // - while (pointer !== undefined) { - var map = pointer[internalKey]; - if (map) { - var value = map[subkey]; - if (value !== undefined || subkey in map) { - return map[subkey]; - } - } - pointer = pointer.parent; - } + var Binding = (function () { + function Binding(toPath, fromPath) { + // Configuration + this._from = fromPath; + this._to = toPath; + this._oneWay = undefined; - return UNDEFINED; - }; + // State + this._direction = undefined; + this._readyToSync = undefined; + this._fromObj = undefined; + this._fromPath = undefined; + this._toObj = undefined; + } - Meta.prototype.writeValue = function (obj, key, value) { - var descriptor = _emberUtils.lookupDescriptor(obj, key); - var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; + /** + @class Binding + @namespace Ember + @deprecated See http://emberjs.com/deprecations/v2.x#toc_ember-binding + @public + */ - if (isMandatorySetter) { - this.writeValues(key, value); - } else { - obj[key] = value; + /** + This copies the Binding so it can be connected to another object. + @method copy + @return {Ember.Binding} `this` + @public + */ + + Binding.prototype.copy = function copy() { + var copy = new Binding(this._to, this._from); + if (this._oneWay) { + copy._oneWay = true; } + return copy; }; - } - var HAS_NATIVE_WEAKMAP = (function () { - // detect if `WeakMap` is even present - var hasWeakMap = typeof WeakMap === 'function'; - if (!hasWeakMap) { - return false; - } + // .......................................................... + // CONFIG + // - var instance = new WeakMap(); - // use `Object`'s `.toString` directly to prevent us from detecting - // polyfills as native weakmaps - return Object.prototype.toString.call(instance) === '[object WeakMap]'; - })(); + /** + This will set `from` property path to the specified value. It will not + attempt to resolve this property path to an actual object until you + connect the binding. + The binding will search for the property path starting at the root object + you pass when you `connect()` the binding. It follows the same rules as + `get()` - see that method for more information. + @method from + @param {String} path The property path to connect to. + @return {Ember.Binding} `this` + @public + */ - var setMeta = undefined, - peekMeta = undefined; + Binding.prototype.from = function from(path) { + this._from = path; + return this; + }; - // choose the one appropriate for given platform - if (HAS_NATIVE_WEAKMAP) { - (function () { - var getPrototypeOf = Object.getPrototypeOf; - var metaStore = new WeakMap(); + /** + This will set the `to` property path to the specified value. It will not + attempt to resolve this property path to an actual object until you + connect the binding. + The binding will search for the property path starting at the root object + you pass when you `connect()` the binding. It follows the same rules as + `get()` - see that method for more information. + @method to + @param {String|Tuple} path A property path or tuple. + @return {Ember.Binding} `this` + @public + */ - exports.setMeta = setMeta = function WeakMap_setMeta(obj, meta) { - metaStore.set(obj, meta); - }; + Binding.prototype.to = function to(path) { + this._to = path; + return this; + }; - exports.peekMeta = peekMeta = function WeakMap_peekMeta(obj) { + /** + Configures the binding as one way. A one-way binding will relay changes + on the `from` side to the `to` side, but not the other way around. This + means that if you change the `to` side directly, the `from` side may have + a different value. + @method oneWay + @return {Ember.Binding} `this` + @public + */ - return metaStore.get(obj); - }; + Binding.prototype.oneWay = function oneWay() { + this._oneWay = true; + return this; + }; - exports.peekMeta = peekMeta = function WeakMap_peekParentMeta(obj) { - var pointer = obj; - var meta = undefined; - while (pointer) { - meta = metaStore.get(pointer); - // jshint loopfunc:true - - // stop if we find a `null` value, since - // that means the meta was deleted - // any other truthy value is a "real" meta - if (meta === null || meta) { - return meta; - } - - pointer = getPrototypeOf(pointer); - } - }; - })(); - } else { - exports.setMeta = setMeta = function Fallback_setMeta(obj, meta) { - // if `null` already, just set it to the new value - // otherwise define property first - if (obj[META_FIELD] !== null) { - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(EMBER_META_PROPERTY); - } else { - Object.defineProperty(obj, META_FIELD, META_DESC); - } - } - - obj[META_FIELD] = meta; - }; + /** + @method toString + @return {String} string representation of binding + @public + */ - exports.peekMeta = peekMeta = function Fallback_peekMeta(obj) { - return obj[META_FIELD]; + Binding.prototype.toString = function toString() { + var oneWay = this._oneWay ? '[oneWay]' : ''; + return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; }; - } - - function deleteMeta(obj) { - - var meta = peekMeta(obj); - if (meta) { - meta.destroy(); - } - } - - /** - Retrieves the meta hash for an object. If `writable` is true ensures the - hash is writable for this object as well. - - The meta object contains information about computed property descriptors as - well as any watched properties and other information. You generally will - not access this information directly but instead work with higher level - methods that manipulate this hash indirectly. - - @method meta - @for Ember - @private - - @param {Object} obj The object to retrieve meta for - @param {Boolean} [writable=true] Pass `false` if you do not intend to modify - the meta hash, allowing the method to avoid making an unnecessary copy. - @return {Object} the meta hash for an object - */ - - function meta(obj) { - - var maybeMeta = peekMeta(obj); - var parent = undefined; - - // remove this code, in-favor of explicit parent - if (maybeMeta) { - if (maybeMeta.source === obj) { - return maybeMeta; - } - parent = maybeMeta; - } - - var newMeta = new Meta(obj, parent); - setMeta(obj, newMeta); - return newMeta; - } - exports.peekMeta = peekMeta; - exports.setMeta = setMeta; - exports.counters = counters; -}); -enifed('ember-metal/meta_listeners', ['exports'], function (exports) { - /* - When we render a rich template hierarchy, the set of events that - *might* happen tends to be much larger than the set of events that - actually happen. This implies that we should make listener creation & - destruction cheap, even at the cost of making event dispatch more - expensive. - - Thus we store a new listener with a single push and no new - allocations, without even bothering to do deduplication -- we can - save that for dispatch time, if an event actually happens. - */ + // .......................................................... + // CONNECT AND SYNC + // - /* listener flags */ - 'use strict'; + /** + Attempts to connect this binding instance so that it can receive and relay + changes. This method will raise an exception if you have not set the + from/to properties yet. + @method connect + @param {Object} obj The root object for this binding. + @return {Ember.Binding} `this` + @public + */ - var ONCE = 1; - exports.ONCE = ONCE; - var SUSPENDED = 2; + Binding.prototype.connect = function connect(obj) { - exports.SUSPENDED = SUSPENDED; - var protoMethods = { + var fromObj = undefined, + fromPath = undefined, + possibleGlobal = undefined; - addToListeners: function (eventName, target, method, flags) { - if (!this._listeners) { - this._listeners = []; - } - this._listeners.push(eventName, target, method, flags); - }, + // If the binding's "from" path could be interpreted as a global, verify + // whether the path refers to a global or not by consulting `Ember.lookup`. + if (_emberMetalPath_cache.isGlobalPath(this._from)) { + var _name = _emberMetalPath_cache.getFirstKey(this._from); + possibleGlobal = _emberEnvironment.context.lookup[_name]; - _finalizeListeners: function () { - if (this._listenersFinalized) { - return; - } - if (!this._listeners) { - this._listeners = []; - } - var pointer = this.parent; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - this._listeners = this._listeners.concat(listeners); - } - if (pointer._listenersFinalized) { - break; + if (possibleGlobal) { + fromObj = possibleGlobal; + fromPath = _emberMetalPath_cache.getTailPath(this._from); } - pointer = pointer.parent; } - this._listenersFinalized = true; - }, - removeFromListeners: function (eventName, target, method, didRemove) { - var pointer = this; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = listeners.length - 4; index >= 0; index -= 4) { - if (listeners[index] === eventName && (!method || listeners[index + 1] === target && listeners[index + 2] === method)) { - if (pointer === this) { - // we are modifying our own list, so we edit directly - if (typeof didRemove === 'function') { - didRemove(eventName, target, listeners[index + 2]); - } - listeners.splice(index, 4); - } else { - // we are trying to remove an inherited listener, so we do - // just-in-time copying to detach our own listeners from - // our inheritance chain. - this._finalizeListeners(); - return this.removeFromListeners(eventName, target, method); - } - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; + if (fromObj === undefined) { + fromObj = obj; + fromPath = this._from; } - }, - matchingListeners: function (eventName) { - var pointer = this; - var result = []; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - if (listeners[index] === eventName) { - pushUniqueListener(result, listeners, index); - } - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; - } - var sus = this._suspendedListeners; - if (sus) { - for (var susIndex = 0; susIndex < sus.length - 2; susIndex += 3) { - if (eventName === sus[susIndex]) { - for (var resultIndex = 0; resultIndex < result.length - 2; resultIndex += 3) { - if (result[resultIndex] === sus[susIndex + 1] && result[resultIndex + 1] === sus[susIndex + 2]) { - result[resultIndex + 2] |= SUSPENDED; - } - } - } - } - } - return result; - }, + _emberMetalProperty_set.trySet(obj, this._to, _emberMetalProperty_get.get(fromObj, fromPath)); - suspendListeners: function (eventNames, target, method, callback) { - var sus = this._suspendedListeners; - if (!sus) { - sus = this._suspendedListeners = []; - } - for (var i = 0; i < eventNames.length; i++) { - sus.push(eventNames[i], target, method); - } - try { - return callback.call(target); - } finally { - if (sus.length === eventNames.length) { - this._suspendedListeners = undefined; - } else { - for (var i = sus.length - 3; i >= 0; i -= 3) { - if (sus[i + 1] === target && sus[i + 2] === method && eventNames.indexOf(sus[i]) !== -1) { - sus.splice(i, 3); - } - } - } - } - }, + // Add an observer on the object to be notified when the binding should be updated. + _emberMetalObserver.addObserver(fromObj, fromPath, this, 'fromDidChange'); - watchedEvents: function () { - var pointer = this; - var names = {}; - while (pointer) { - var listeners = pointer._listeners; - if (listeners) { - for (var index = 0; index < listeners.length - 3; index += 4) { - names[listeners[index]] = true; - } - } - if (pointer._listenersFinalized) { - break; - } - pointer = pointer.parent; + // If the binding is a two-way binding, also set up an observer on the target. + if (!this._oneWay) { + _emberMetalObserver.addObserver(obj, this._to, this, 'toDidChange'); } - return Object.keys(names); - }, - - _initializeListeners: function () { - this._listeners = undefined; - this._listenersFinalized = undefined; - this._suspendedListeners = undefined; - } - }; - exports.protoMethods = protoMethods; - function pushUniqueListener(destination, source, index) { - var target = source[index + 1]; - var method = source[index + 2]; - for (var destinationIndex = 0; destinationIndex < destination.length - 2; destinationIndex += 3) { - if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { - return; - } - } - destination.push(target, method, source[index + 3]); - } -}); -enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed + _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect'); - /** - @module ember - @submodule ember-metal - */ - exports.detectBinding = detectBinding; - exports.mixin = mixin; - exports.default = Mixin; - exports.hasUnprocessedMixins = hasUnprocessedMixins; - exports.clearUnprocessedMixins = clearUnprocessedMixins; - exports.required = required; - exports.aliasMethod = aliasMethod; - exports.observer = observer; - exports._immediateObserver = _immediateObserver; - exports._beforeObserver = _beforeObserver; + fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); - function ROOT() {} - ROOT.__hasSuper = false; + this._readyToSync = true; + this._fromObj = fromObj; + this._fromPath = fromPath; + this._toObj = obj; - var a_slice = [].slice; + return this; + }; - function isMethod(obj) { - return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; - } + /** + Disconnects the binding instance. Changes will no longer be relayed. You + will not usually need to call this method. + @method disconnect + @return {Ember.Binding} `this` + @public + */ - var CONTINUE = {}; + Binding.prototype.disconnect = function disconnect() { - function mixinProperties(mixinsMeta, mixin) { - var guid = undefined; + // Remove an observer on the object so we're no longer notified of + // changes that should update bindings. + _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); - if (mixin instanceof Mixin) { - guid = _emberUtils.guidFor(mixin); - if (mixinsMeta.peekMixins(guid)) { - return CONTINUE; + // If the binding is two-way, remove the observer from the target as well. + if (!this._oneWay) { + _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); } - mixinsMeta.writeMixins(guid, mixin); - return mixin.properties; - } else { - return mixin; // apply anonymous mixin properties - } - } - function concatenatedMixinProperties(concatProp, props, values, base) { - var concats = undefined; + this._readyToSync = false; // Disable scheduled syncs... + return this; + }; - // reset before adding each new mixin to pickup concats from previous - concats = values[concatProp] || base[concatProp]; - if (props[concatProp]) { - concats = concats ? concats.concat(props[concatProp]) : props[concatProp]; - } + // .......................................................... + // PRIVATE + // - return concats; - } + /* Called when the from side changes. */ - function giveDescriptorSuper(meta, key, property, values, descs, base) { - var superProperty = undefined; + Binding.prototype.fromDidChange = function fromDidChange(target) { + this._scheduleSync('fwd'); + }; - // Computed properties override methods, and do not call super to them - if (values[key] === undefined) { - // Find the original descriptor in a parent mixin - superProperty = descs[key]; - } + /* Called when the to side changes. */ - // If we didn't find the original descriptor in a parent mixin, find - // it on the original object. - if (!superProperty) { - var possibleDesc = base[key]; - var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + Binding.prototype.toDidChange = function toDidChange(target) { + this._scheduleSync('back'); + }; - superProperty = superDesc; - } + Binding.prototype._scheduleSync = function _scheduleSync(dir) { + var existingDir = this._direction; - if (superProperty === undefined || !(superProperty instanceof _emberMetalComputed.ComputedProperty)) { - return property; - } + // If we haven't scheduled the binding yet, schedule it. + if (existingDir === undefined) { + _emberMetalRun_loop.default.schedule('sync', this, '_sync'); + this._direction = dir; + } - // Since multiple mixins may inherit from the same parent, we need - // to clone the computed property so that other mixins do not receive - // the wrapped version. - property = Object.create(property); - property._getter = _emberUtils.wrap(property._getter, superProperty._getter); - if (superProperty._setter) { - if (property._setter) { - property._setter = _emberUtils.wrap(property._setter, superProperty._setter); - } else { - property._setter = superProperty._setter; + // If both a 'back' and 'fwd' sync have been scheduled on the same object, + // default to a 'fwd' sync so that it remains deterministic. + if (existingDir === 'back' && dir === 'fwd') { + this._direction = 'fwd'; } - } + }; - return property; - } + Binding.prototype._sync = function _sync() { + var _this = this; - function giveMethodSuper(obj, key, method, values, descs) { - var superMethod = undefined; + var log = _emberEnvironment.ENV.LOG_BINDINGS; - // Methods overwrite computed properties, and do not call super to them. - if (descs[key] === undefined) { - // Find the original method in a parent mixin - superMethod = values[key]; - } + var toObj = this._toObj; - // If we didn't find the original value in a parent mixin, find it in - // the original object - superMethod = superMethod || obj[key]; + // Don't synchronize destroyed objects or disconnected bindings. + if (toObj.isDestroyed || !this._readyToSync) { + return; + } - // Only wrap the new method if the original method was a function - if (superMethod === undefined || 'function' !== typeof superMethod) { - return method; - } + // Get the direction of the binding for the object we are + // synchronizing from. + var direction = this._direction; - return _emberUtils.wrap(method, superMethod); - } + var fromObj = this._fromObj; + var fromPath = this._fromPath; - function applyConcatenatedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; - var ret = undefined; + this._direction = undefined; - if (baseValue) { - if ('function' === typeof baseValue.concat) { - if (value === null || value === undefined) { - ret = baseValue; - } else { - ret = baseValue.concat(value); + // If we're synchronizing from the remote object... + if (direction === 'fwd') { + (function () { + var fromValue = _emberMetalProperty_get.get(fromObj, fromPath); + if (log) { + _emberConsole.default.log(' ', _this.toString(), '->', fromValue, fromObj); + } + if (_this._oneWay) { + _emberMetalProperty_set.trySet(toObj, _this._to, fromValue); + } else { + _emberMetalObserver._suspendObserver(toObj, _this._to, _this, 'toDidChange', function () { + _emberMetalProperty_set.trySet(toObj, this._to, fromValue); + }); + } + // If we're synchronizing *to* the remote object. + })(); + } else if (direction === 'back') { + (function () { + var toValue = _emberMetalProperty_get.get(toObj, _this._to); + if (log) { + _emberConsole.default.log(' ', _this.toString(), '<-', toValue, toObj); + } + _emberMetalObserver._suspendObserver(fromObj, fromPath, _this, 'fromDidChange', function () { + _emberMetalProperty_set.trySet(fromObj, fromPath, toValue); + }); + })(); } - } else { - ret = _emberUtils.makeArray(baseValue).concat(value); - } - } else { - ret = _emberUtils.makeArray(value); - } - - return ret; - } - - function applyMergedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; + }; - if (!baseValue) { - return value; - } + return Binding; + })(); - var newBase = _emberUtils.assign({}, baseValue); - var hasFunction = false; + function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { + var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; + var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; + var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - for (var prop in value) { - if (!value.hasOwnProperty(prop)) { - continue; - } + var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; + } - var propValue = value[prop]; - if (isMethod(propValue)) { - // TODO: support for Computed Properties, etc? - hasFunction = true; - newBase[prop] = giveMethodSuper(obj, prop, propValue, baseValue, {}); - } else { - newBase[prop] = propValue; + function mixinProperties(to, from) { + for (var key in from) { + if (from.hasOwnProperty(key)) { + to[key] = from[key]; } } - - if (hasFunction) { - newBase._super = ROOT; - } - - return newBase; } - function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { - if (value instanceof _emberMetalProperties.Descriptor) { - if (value === REQUIRED && descs[key]) { - return CONTINUE; - } + mixinProperties(Binding, { - // Wrap descriptor function to implement - // _super() if needed - if (value._getter) { - value = giveDescriptorSuper(meta, key, value, values, descs, base); - } + /* + See `Ember.Binding.from`. + @method from + @static + */ + from: function (from) { + var C = this; + return new C(undefined, from); + }, - descs[key] = value; - values[key] = undefined; - } else { - if (concats && concats.indexOf(key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') { - value = applyConcatenatedProperties(base, key, value, values); - } else if (mergings && mergings.indexOf(key) >= 0) { - value = applyMergedProperties(base, key, value, values); - } else if (isMethod(value)) { - value = giveMethodSuper(base, key, value, values, descs); - } - - descs[key] = undefined; - values[key] = value; + /* + See `Ember.Binding.to`. + @method to + @static + */ + to: function (to) { + var C = this; + return new C(to, undefined); } + }); + /** + An `Ember.Binding` connects the properties of two objects so that whenever + the value of one property changes, the other property will be changed also. + + ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. + + You do not usually create Binding objects directly but instead describe + bindings in your class or object definition using automatic binding + detection. + + Properties ending in a `Binding` suffix will be converted to `Ember.Binding` + instances. The value of this property should be a string representing a path + to another object or a custom binding instance created using Binding helpers + (see "One Way Bindings"): + + ``` + valueBinding: "MyApp.someController.title" + ``` + + This will create a binding from `MyApp.someController.title` to the `value` + property of your object instance automatically. Now the two values will be + kept in sync. + + ## One Way Bindings + + One especially useful binding customization you can use is the `oneWay()` + helper. This helper tells Ember that you are only interested in + receiving changes on the object you are binding from. For example, if you + are binding to a preference and you want to be notified if the preference + has changed, but your object will not be changing the preference itself, you + could do: + + ``` + bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") + ``` + + This way if the value of `MyApp.preferencesController.bigTitles` changes the + `bigTitles` property of your object will change also. However, if you + change the value of your `bigTitles` property, it will not update the + `preferencesController`. + + One way bindings are almost twice as fast to setup and twice as fast to + execute because the binding only has to worry about changes to one side. + + You should consider using one way bindings anytime you have an object that + may be created frequently and you do not intend to change a property; only + to monitor it for changes (such as in the example above). + + ## Adding Bindings Manually + + All of the examples above show you how to configure a custom binding, but the + result of these customizations will be a binding template, not a fully active + Binding instance. The binding will actually become active only when you + instantiate the object the binding belongs to. It is useful, however, to + understand what actually happens when the binding is activated. + + For a binding to function it must have at least a `from` property and a `to` + property. The `from` property path points to the object/key that you want to + bind from while the `to` path points to the object/key you want to bind to. + + When you define a custom binding, you are usually describing the property + you want to bind from (such as `MyApp.someController.value` in the examples + above). When your object is created, it will automatically assign the value + you want to bind `to` based on the name of your binding key. In the + examples above, during init, Ember objects will effectively call + something like this on your binding: + + ```javascript + binding = Ember.Binding.from("valueBinding").to("value"); + ``` + + This creates a new binding instance based on the template you provide, and + sets the to path to the `value` property of the new object. Now that the + binding is fully configured with a `from` and a `to`, it simply needs to be + connected to become active. This is done through the `connect()` method: + + ```javascript + binding.connect(this); + ``` + + Note that when you connect a binding you pass the object you want it to be + connected to. This object will be used as the root for both the from and + to side of the binding when inspecting relative paths. This allows the + binding to be automatically inherited by subclassed objects as well. + + This also allows you to bind between objects using the paths you declare in + `from` and `to`: + + ```javascript + // Example 1 + binding = Ember.Binding.from("App.someObject.value").to("value"); + binding.connect(this); + + // Example 2 + binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); + binding.connect(this); + ``` + + Now that the binding is connected, it will observe both the from and to side + and relay changes. + + If you ever needed to do so (you almost never will, but it is useful to + understand this anyway), you could manually create an active binding by + using the `Ember.bind()` helper method. (This is the same method used by + to setup your bindings on objects): + + ```javascript + Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); + ``` + + Both of these code fragments have the same effect as doing the most friendly + form of binding creation like so: + + ```javascript + MyApp.anotherObject = Ember.Object.create({ + valueBinding: "MyApp.someController.value", + + // OTHER CODE FOR THIS OBJECT... + }); + ``` + + Ember's built in binding creation method makes it easy to automatically + create bindings for you. You should always use the highest-level APIs + available, even if you understand how it works underneath. + + @class Binding + @namespace Ember + @since Ember 0.9 + @public + */ + // Ember.Binding = Binding; ES6TODO: where to put this? + + /** + Global helper method to create a new binding. Just pass the root object + along with a `to` and `from` path to create and connect the binding. + + @method bind + @for Ember + @param {Object} obj The root object of the transform. + @param {String} to The path to the 'to' side of the binding. + Must be relative to obj. + @param {String} from The path to the 'from' side of the binding. + Must be relative to obj or a global path. + @return {Ember.Binding} binding instance + @public + */ + + function bind(obj, to, from) { + return new Binding(to, from).connect(obj); } - function mergeMixins(mixins, m, descs, values, base, keys) { - var currentMixin = undefined, - props = undefined, - key = undefined, - concats = undefined, - mergings = undefined; + exports.Binding = Binding; +}); +enifed('ember-metal/cache', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { + 'use strict'; - function removeKeys(keyName) { - delete descs[keyName]; - delete values[keyName]; + var Cache = (function () { + function Cache(limit, func, key, store) { + this.size = 0; + this.misses = 0; + this.hits = 0; + this.limit = limit; + this.func = func; + this.key = key; + this.store = store || new DefaultStore(); } - for (var i = 0; i < mixins.length; i++) { - currentMixin = mixins[i]; - - props = mixinProperties(m, currentMixin); - if (props === CONTINUE) { - continue; + Cache.prototype.get = function get(obj) { + var key = this.key === undefined ? obj : this.key(obj); + var value = this.store.get(key); + if (value === undefined) { + this.misses++; + value = this._set(key, this.func(obj)); + } else if (value === _emberMetalMeta.UNDEFINED) { + this.hits++; + value = undefined; + } else { + this.hits++; + // nothing to translate } - if (props) { - if (base.willMergeMixin) { - base.willMergeMixin(props); - } - concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); - mergings = concatenatedMixinProperties('mergedProperties', props, values, base); + return value; + }; - for (key in props) { - if (!props.hasOwnProperty(key)) { - continue; - } - keys.push(key); - addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings); - } + Cache.prototype.set = function set(obj, value) { + var key = this.key === undefined ? obj : this.key(obj); + return this._set(key, value); + }; - // manually copy toString() because some JS engines do not enumerate it - if (props.hasOwnProperty('toString')) { - base.toString = props.toString; - } - } else if (currentMixin.mixins) { - mergeMixins(currentMixin.mixins, m, descs, values, base, keys); - if (currentMixin._without) { - currentMixin._without.forEach(removeKeys); + Cache.prototype._set = function _set(key, value) { + if (this.limit > this.size) { + this.size++; + if (value === undefined) { + this.store.set(key, _emberMetalMeta.UNDEFINED); + } else { + this.store.set(key, value); } } - } - } - - function detectBinding(key) { - var length = key.length; - return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; - } + return value; + }; - // warm both paths of above function - detectBinding('notbound'); - detectBinding('fooBinding'); + Cache.prototype.purge = function purge() { + this.store.clear(); + this.size = 0; + this.hits = 0; + this.misses = 0; + }; - function connectBindings(obj, m) { - // TODO Mixin.apply(instance) should disconnect binding if exists - m.forEachBindings(function (key, binding) { - if (binding) { - var to = key.slice(0, -7); // strip Binding off end - if (binding instanceof _emberMetalBinding.Binding) { - binding = binding.copy(); // copy prototypes' instance - binding.to(to); - } else { - // binding is string path - binding = new _emberMetalBinding.Binding(to, binding); - } - binding.connect(obj); - obj[key] = binding; - } - }); - // mark as applied - m.clearBindings(); - } + return Cache; + })(); - function finishPartial(obj, m) { - connectBindings(obj, m || _emberMetalMeta.meta(obj)); - return obj; - } + exports.default = Cache; - function followAlias(obj, desc, m, descs, values) { - var altKey = desc.methodName; - var value = undefined; - var possibleDesc = undefined; - if (descs[altKey] || values[altKey]) { - value = values[altKey]; - desc = descs[altKey]; - } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - value = undefined; - } else { - desc = undefined; - value = obj[altKey]; + var DefaultStore = (function () { + function DefaultStore() { + this.data = new _emberUtils.EmptyObject(); } - return { desc: desc, value: value }; - } + DefaultStore.prototype.get = function get(key) { + return this.data[key]; + }; - function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { - var paths = observerOrListener[pathsKey]; + DefaultStore.prototype.set = function set(key, value) { + this.data[key] = value; + }; - if (paths) { - for (var i = 0; i < paths.length; i++) { - updateMethod(obj, paths[i], null, key); - } - } + DefaultStore.prototype.clear = function clear() { + this.data = new _emberUtils.EmptyObject(); + }; + + return DefaultStore; + })(); +}); +enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/computed', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalComputed, _emberMetalWatch_path) { + 'use strict'; + + exports.finishChains = finishChains; + + var FIRST_KEY = /^([^\.]+)/; + + function firstKey(path) { + return path.match(FIRST_KEY)[0]; } - function replaceObserversAndListeners(obj, key, observerOrListener) { - var prev = obj[key]; + function isObject(obj) { + return typeof obj === 'object' && obj; + } - if ('function' === typeof prev) { - updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _emberMetalObserver._removeBeforeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_observes__', _emberMetalObserver.removeObserver); - updateObserversAndListeners(obj, key, prev, '__ember_listens__', _emberMetalEvents.removeListener); - } + function isVolatile(obj) { + return !(isObject(obj) && obj.isDescriptor && obj._volatile === false); + } - if ('function' === typeof observerOrListener) { - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', _emberMetalObserver._addBeforeObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', _emberMetalObserver.addObserver); - updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', _emberMetalEvents.addListener); + var ChainWatchers = (function () { + function ChainWatchers() { + // chain nodes that reference a key in this obj by key + // we only create ChainWatchers when we are going to add them + // so create this upfront + this.chains = new _emberUtils.EmptyObject(); } - } - function applyMixin(obj, mixins, partial) { - var descs = {}; - var values = {}; - var m = _emberMetalMeta.meta(obj); - var keys = []; - var key = undefined, - value = undefined, - desc = undefined; + ChainWatchers.prototype.add = function add(key, node) { + var nodes = this.chains[key]; + if (nodes === undefined) { + this.chains[key] = [node]; + } else { + nodes.push(node); + } + }; - obj._super = ROOT; + ChainWatchers.prototype.remove = function remove(key, node) { + var nodes = this.chains[key]; + if (nodes) { + for (var i = 0; i < nodes.length; i++) { + if (nodes[i] === node) { + nodes.splice(i, 1); + break; + } + } + } + }; - // Go through all mixins and hashes passed in, and: - // - // * Handle concatenated properties - // * Handle merged properties - // * Set up _super wrapping if necessary - // * Set up computed property descriptors - // * Copying `toString` in broken browsers - mergeMixins(mixins, m, descs, values, obj, keys); + ChainWatchers.prototype.has = function has(key, node) { + var nodes = this.chains[key]; + if (nodes) { + for (var i = 0; i < nodes.length; i++) { + if (nodes[i] === node) { + return true; + } + } + } + return false; + }; - for (var i = 0; i < keys.length; i++) { - key = keys[i]; - if (key === 'constructor' || !values.hasOwnProperty(key)) { - continue; + ChainWatchers.prototype.revalidateAll = function revalidateAll() { + for (var key in this.chains) { + this.notify(key, true, undefined); } + }; - desc = descs[key]; - value = values[key]; + ChainWatchers.prototype.revalidate = function revalidate(key) { + this.notify(key, true, undefined); + }; - if (desc === REQUIRED) { - continue; + // key: the string key that is part of a path changed + // revalidate: boolean; the chains that are watching this value should revalidate + // callback: function that will be called with the object and path that + // will be/are invalidated by this key change, depending on + // whether the revalidate flag is passed + + ChainWatchers.prototype.notify = function notify(key, revalidate, callback) { + var nodes = this.chains[key]; + if (nodes === undefined || nodes.length === 0) { + return; } - while (desc && desc instanceof Alias) { - var followed = followAlias(obj, desc, m, descs, values); - desc = followed.desc; - value = followed.value; + var affected = undefined; + + if (callback) { + affected = []; } - if (desc === undefined && value === undefined) { - continue; + for (var i = 0; i < nodes.length; i++) { + nodes[i].notify(revalidate, affected); } - replaceObserversAndListeners(obj, key, value); + if (callback === undefined) { + return; + } - if (detectBinding(key)) { - m.writeBindings(key, value); + // we gather callbacks so we don't notify them during revalidation + for (var i = 0; i < affected.length; i += 2) { + var obj = affected[i]; + var path = affected[i + 1]; + callback(obj, path); } + }; - _emberMetalProperties.defineProperty(obj, key, desc, value, m); + return ChainWatchers; + })(); + + function makeChainWatcher() { + return new ChainWatchers(); + } + + function addChainWatcher(obj, keyName, node) { + var m = _emberMetalMeta.meta(obj); + m.writableChainWatchers(makeChainWatcher).add(keyName, node); + _emberMetalWatch_key.watchKey(obj, keyName, m); + } + + function removeChainWatcher(obj, keyName, node, _meta) { + if (!isObject(obj)) { + return; } - if (!partial) { - // don't apply to prototype - finishPartial(obj, m); + var meta = _meta || _emberMetalMeta.peekMeta(obj); + + if (!meta || !meta.readableChainWatchers()) { + return; } - return obj; + // make meta writable + meta = _emberMetalMeta.meta(obj); + + meta.readableChainWatchers().remove(keyName, node); + + _emberMetalWatch_key.unwatchKey(obj, keyName, meta); } - /** - @method mixin - @for Ember - @param obj - @param mixins* - @return obj - @private - */ + // A ChainNode watches a single key on an object. If you provide a starting + // value for the key then the node won't actually watch it. For a root node + // pass null for parent and key and object for value. - function mixin(obj) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + var ChainNode = (function () { + function ChainNode(parent, key, value) { + this._parent = parent; + this._key = key; + + // _watching is true when calling get(this._parent, this._key) will + // return the value of this node. + // + // It is false for the root of a chain (because we have no parent) + // and for global paths (because the parent node is the object with + // the observer on it) + this._watching = value === undefined; + + this._chains = undefined; + this._object = undefined; + this.count = 0; + + this._value = value; + this._paths = {}; + if (this._watching) { + var obj = parent.value(); + + if (!isObject(obj)) { + return; + } + + this._object = obj; + + addChainWatcher(this._object, this._key, this); + } } - applyMixin(obj, args, false); - return obj; - } + ChainNode.prototype.value = function value() { + if (this._value === undefined && this._watching) { + var obj = this._parent.value(); + this._value = lazyGet(obj, this._key); + } + return this._value; + }; - /** - The `Ember.Mixin` class allows you to create mixins, whose properties can be - added to other classes. For instance, - - ```javascript - const EditableMixin = Ember.Mixin.create({ - edit() { - console.log('starting to edit'); - this.set('isEditing', true); - }, - isEditing: false - }); - - // Mix mixins into classes by passing them as the first arguments to - // `.extend.` - const Comment = Ember.Object.extend(EditableMixin, { - post: null - }); - - let comment = Comment.create(post: somePost); - comment.edit(); // outputs 'starting to edit' - ``` - - Note that Mixins are created with `Ember.Mixin.create`, not - `Ember.Mixin.extend`. - - Note that mixins extend a constructor's prototype so arrays and object literals - defined as properties will be shared amongst objects that implement the mixin. - If you want to define a property in a mixin that is not shared, you can define - it either as a computed property or have it be created on initialization of the object. - - ```javascript - // filters array will be shared amongst any object implementing mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.A() - }); - - // filters will be a separate array for every object implementing the mixin - const FilterableMixin = Ember.Mixin.create({ - filters: Ember.computed(function() { - return Ember.A(); - }) - }); - - // filters will be created as a separate array during the object's initialization - const Filterable = Ember.Mixin.create({ - init() { - this._super(...arguments); - this.set("filters", Ember.A()); + ChainNode.prototype.destroy = function destroy() { + if (this._watching) { + var obj = this._object; + if (obj) { + removeChainWatcher(obj, this._key, this); + } + this._watching = false; // so future calls do nothing } - }); - ``` - - @class Mixin - @namespace Ember - @public - */ - - function Mixin(args, properties) { - this.properties = properties; + }; - var length = args && args.length; + // copies a top level object only - if (length > 0) { - var m = new Array(length); + ChainNode.prototype.copy = function copy(obj) { + var ret = new ChainNode(null, null, obj); + var paths = this._paths; + var path = undefined; - for (var i = 0; i < length; i++) { - var x = args[i]; - if (x instanceof Mixin) { - m[i] = x; - } else { - m[i] = new Mixin(undefined, x); + for (path in paths) { + // this check will also catch non-number vals. + if (paths[path] <= 0) { + continue; } + ret.add(path); } + return ret; + }; - this.mixins = m; - } else { - this.mixins = undefined; - } - this.ownerConstructor = undefined; - this._without = undefined; - this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; - } - - Mixin._apply = applyMixin; - - Mixin.applyPartial = function (obj) { - var args = a_slice.call(arguments, 1); - return applyMixin(obj, args, true); - }; + // called on the root node of a chain to setup watchers on the specified + // path. - Mixin.finishPartial = finishPartial; + ChainNode.prototype.add = function add(path) { + var paths = this._paths; + paths[path] = (paths[path] || 0) + 1; - var unprocessedFlag = false; + var key = firstKey(path); + var tail = path.slice(key.length + 1); - function hasUnprocessedMixins() { - return unprocessedFlag; - } + this.chain(key, tail); + }; - function clearUnprocessedMixins() { - unprocessedFlag = false; - } + // called on the root node of a chain to teardown watcher on the specified + // path - /** - @method create - @static - @param arguments* - @public - */ - Mixin.create = function () { - // ES6TODO: this relies on a global state? - unprocessedFlag = true; - var M = this; + ChainNode.prototype.remove = function remove(path) { + var paths = this._paths; + if (paths[path] > 0) { + paths[path]--; + } - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + var key = firstKey(path); + var tail = path.slice(key.length + 1); - return new M(args, undefined); - }; + this.unchain(key, tail); + }; - var MixinPrototype = Mixin.prototype; + ChainNode.prototype.chain = function chain(key, path) { + var chains = this._chains; + var node = undefined; + if (chains === undefined) { + chains = this._chains = new _emberUtils.EmptyObject(); + } else { + node = chains[key]; + } - /** - @method reopen - @param arguments* - @private - */ - MixinPrototype.reopen = function () { - var currentMixin = undefined; + if (node === undefined) { + node = chains[key] = new ChainNode(this, key, undefined); + } - if (this.properties) { - currentMixin = new Mixin(undefined, this.properties); - this.properties = undefined; - this.mixins = [currentMixin]; - } else if (!this.mixins) { - this.mixins = []; - } + node.count++; // count chains... - var mixins = this.mixins; - var idx = undefined; + // chain rest of path if there is one + if (path) { + key = firstKey(path); + path = path.slice(key.length + 1); + node.chain(key, path); + } + }; - for (idx = 0; idx < arguments.length; idx++) { - currentMixin = arguments[idx]; + ChainNode.prototype.unchain = function unchain(key, path) { + var chains = this._chains; + var node = chains[key]; - if (currentMixin instanceof Mixin) { - mixins.push(currentMixin); - } else { - mixins.push(new Mixin(undefined, currentMixin)); + // unchain rest of path first... + if (path && path.length > 1) { + var nextKey = firstKey(path); + var nextPath = path.slice(nextKey.length + 1); + node.unchain(nextKey, nextPath); } - } - return this; - }; + // delete node if needed. + node.count--; + if (node.count <= 0) { + chains[node._key] = undefined; + node.destroy(); + } + }; - /** - @method apply - @param obj - @return applied object - @private - */ - MixinPrototype.apply = function (obj) { - return applyMixin(obj, [this], false); - }; + ChainNode.prototype.notify = function notify(revalidate, affected) { + if (revalidate && this._watching) { + var parentValue = this._parent.value(); - MixinPrototype.applyPartial = function (obj) { - return applyMixin(obj, [this], true); - }; + if (parentValue !== this._object) { + if (this._object) { + removeChainWatcher(this._object, this._key, this); + } - MixinPrototype.toString = Object.toString; + if (isObject(parentValue)) { + this._object = parentValue; + addChainWatcher(parentValue, this._key, this); + } else { + this._object = undefined; + } + } + this._value = undefined; + } - function _detect(curMixin, targetMixin, seen) { - var guid = _emberUtils.guidFor(curMixin); + // then notify chains... + var chains = this._chains; + var node = undefined; + if (chains) { + for (var key in chains) { + node = chains[key]; + if (node !== undefined) { + node.notify(revalidate, affected); + } + } + } - if (seen[guid]) { - return false; - } - seen[guid] = true; + if (affected && this._parent) { + this._parent.populateAffected(this._key, 1, affected); + } + }; - if (curMixin === targetMixin) { - return true; - } - var mixins = curMixin.mixins; - var loc = mixins ? mixins.length : 0; - while (--loc >= 0) { - if (_detect(mixins[loc], targetMixin, seen)) { - return true; + ChainNode.prototype.populateAffected = function populateAffected(path, depth, affected) { + if (this._key) { + path = this._key + '.' + path; } - } - return false; - } - /** - @method detect - @param obj - @return {Boolean} - @private - */ - MixinPrototype.detect = function (obj) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - if (obj instanceof Mixin) { - return _detect(obj, this, {}); - } - var m = _emberMetalMeta.peekMeta(obj); - if (!m) { - return false; - } - return !!m.peekMixins(_emberUtils.guidFor(this)); - }; + if (this._parent) { + this._parent.populateAffected(path, depth + 1, affected); + } else { + if (depth > 1) { + affected.push(this.value(), path); + } + } + }; - MixinPrototype.without = function () { - var ret = new Mixin([this]); + return ChainNode; + })(); - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; + function lazyGet(obj, key) { + if (!isObject(obj)) { + return; } - ret._without = args; - return ret; - }; + var meta = _emberMetalMeta.peekMeta(obj); - function _keys(ret, mixin, seen) { - if (seen[_emberUtils.guidFor(mixin)]) { + // check if object meant only to be a prototype + if (meta && meta.proto === obj) { return; } - seen[_emberUtils.guidFor(mixin)] = true; - if (mixin.properties) { - var props = Object.keys(mixin.properties); - for (var i = 0; i < props.length; i++) { - var key = props[i]; - ret[key] = true; + // Use `get` if the return value is an EachProxy or an uncacheable value. + if (isVolatile(obj[key])) { + return _emberMetalProperty_get.get(obj, key); + // Otherwise attempt to get the cached value of the computed property + } else { + var cache = meta.readableCache(); + if (cache) { + return _emberMetalComputed.cacheFor.get(cache, key); + } } - } else if (mixin.mixins) { - mixin.mixins.forEach(function (x) { - return _keys(ret, x, seen); - }); - } } - MixinPrototype.keys = function () { - var keys = {}; - var seen = {}; - - _keys(keys, this, seen); - var ret = Object.keys(keys); - return ret; - }; - - // returns the mixins currently applied to the specified object - // TODO: Make Ember.mixin - Mixin.mixins = function (obj) { + function finishChains(obj) { + // We only create meta if we really have to var m = _emberMetalMeta.peekMeta(obj); - var ret = []; - if (!m) { - return ret; - } + if (m) { + m = _emberMetalMeta.meta(obj); - m.forEachMixins(function (key, currentMixin) { - // skip primitive mixins since these are always anonymous - if (!currentMixin.properties) { - ret.push(currentMixin); + // finish any current chains node watchers that reference obj + var chainWatchers = m.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidateAll(); } - }); + // ensure that if we have inherited any chains they have been + // copied onto our own meta. + if (m.readableChains()) { + m.writableChains(_emberMetalWatch_path.makeChainNode); + } + } + } - return ret; - }; + exports.removeChainWatcher = removeChainWatcher; + exports.ChainNode = ChainNode; +}); +enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) { + 'use strict'; - var REQUIRED = new _emberMetalProperties.Descriptor(); - REQUIRED.toString = function () { - return '(Required Property)'; - }; + exports.default = computed; /** - Denotes a required property for a mixin - - @method required - @for Ember - @private + @module ember + @submodule ember-metal */ - function required() { - return REQUIRED; - } - - function Alias(methodName) { - this.isDescriptor = true; - this.methodName = methodName; - } - - Alias.prototype = new _emberMetalProperties.Descriptor(); + var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; /** - Makes a method available via an additional name. + A computed property transforms an object literal with object's accessor function(s) 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 - `fullName` - by calling + `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter 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 - App.Person = Ember.Object.extend({ - name: function() { - return 'Tomhuda Katzdale'; - }, - moniker: Ember.aliasMethod('name') + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', function() { + let firstName = this.get('firstName'), + lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + }) }); - let goodGuy = App.Person.create(); + let tom = Person.create({ + firstName: 'Tom', + lastName: 'Dale' + }); - goodGuy.name(); // 'Tomhuda Katzdale' - goodGuy.moniker(); // 'Tomhuda Katzdale' + tom.get('fullName') // 'Tom Dale' ``` - @method aliasMethod - @for Ember - @param {String} methodName name of the method to alias - @public - */ - - function aliasMethod(methodName) { - return new Alias(methodName); - } - - // .......................................................... - // OBSERVER HELPER - // - - /** - Specify a method that observes property changes. + You can also define what Ember should do when setting a computed property by providing additional function (`set`) in hash argument. + If you try to set a computed property, it will try to invoke setter accessor function with the key and + value you want to set it to as arguments. ```javascript - Ember.Object.extend({ - valueObserver: Ember.observer('value', function() { - // Executes whenever the "value" property changes + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + let firstName = this.get('firstName'), + lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + }, + set(key, value) { + let [firstName, lastName] = value.split(' '); + + this.set('firstName', firstName); + this.set('lastName', lastName); + + return value; + } }) }); + + let person = Person.create(); + + person.set('fullName', 'Peter Wagenet'); + person.get('firstName'); // 'Peter' + person.get('lastName'); // 'Wagenet' ``` - Also available as `Function.prototype.observes` if prototype extensions are - enabled. + You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined. - @method observer - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func + You can also mark computed property as `.readOnly()` and block all attempts to set it. + + ```javascript + let Person = Ember.Object.extend({ + // these will be supplied by `create` + firstName: null, + lastName: null, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + let firstName = this.get('firstName'); + let lastName = this.get('lastName'); + + return firstName + ' ' + lastName; + } + }).readOnly() + }); + + let person = Person.create(); + person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX> + ``` + + Additional resources: + - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md) + - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax) + + @class ComputedProperty + @namespace Ember @public */ - - function observer() { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; + function ComputedProperty(config, opts) { + this.isDescriptor = true; + if (typeof config === 'function') { + this._getter = config; + } else { + this._getter = config.get; + this._setter = config.set; } - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - - func = args[0]; - - // revert to old, soft-deprecated argument ordering - _paths = args.slice(1); - } + this._dependentKeys = undefined; + this._suspended = undefined; + this._meta = undefined; + this._volatile = false; + this._dependentKeys = opts && opts.dependentKeys; + this._readOnly = false; + } - paths = []; + ComputedProperty.prototype = new _emberMetalProperties.Descriptor(); + ComputedProperty.prototype.constructor = ComputedProperty; - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('Ember.observer called without a function'); - } - - func.__ember_observes__ = paths; - return func; - } + var ComputedPropertyPrototype = ComputedProperty.prototype; /** - Specify a method that observes property changes. + 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 - Ember.Object.extend({ - valueObserver: Ember.immediateObserver('value', function() { - // Executes whenever the "value" property changes - }) - }); - ``` + It also does not automatically fire any change events. You must manually notify + any changes if you want to observe this property. - In the future, `Ember.observer` may become asynchronous. In this event, - `Ember.immediateObserver` will maintain the synchronous behavior. + Dependency keys have no effect on volatile properties as they are for cache + invalidation and notification when cached value is invalidated. - Also available as `Function.prototype.observesImmediately` if prototype extensions are - enabled. + ```javascript + let outsideService = Ember.Object.extend({ + value: Ember.computed(function() { + return OutsideService.getValue(); + }).volatile() + }).create(); + ``` - @method _immediateObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @deprecated Use `Ember.observer` instead. - @return func - @private + @method volatile + @return {Ember.ComputedProperty} this + @chainable + @public */ - - function _immediateObserver() { - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - } - - return observer.apply(this, arguments); - } + ComputedPropertyPrototype.volatile = function () { + this._volatile = true; + return this; + }; /** - When observers fire, they are called with the arguments `obj`, `keyName`. + 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. - Note, `@each.property` observer is called per each add or replace of an element - and it's not called with a specific enumeration item. + ```javascript + let Person = Ember.Object.extend({ + guid: Ember.computed(function() { + return 'guid-guid-guid'; + }).readOnly() + }); - A `_beforeObserver` fires before a property changes. + let person = Person.create(); - @method beforeObserver - @for Ember - @param {String} propertyNames* - @param {Function} func - @return func - @deprecated - @private - */ - - function _beforeObserver() { - for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { - args[_key5] = arguments[_key5]; - } - - var func = args.slice(-1)[0]; - var paths = undefined; - - var addWatchedProperty = function (path) { - paths.push(path); - }; - - var _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - - for (var i = 0; i < _paths.length; ++i) { - _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); - } - - if (typeof func !== 'function') { - throw new _emberMetalError.default('_beforeObserver called without a function'); - } - - func.__ember_observesBefore__ = paths; - return func; - } - - exports.Mixin = Mixin; - exports.required = required; - exports.REQUIRED = REQUIRED; -}); - -// it is possible to use concatenatedProperties with strings (which cannot be frozen) -// only freeze objects... - -// prevent mutating `concatenatedProperties` array after it is applied -// use conditional to avoid stringifying every time -enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { - 'use strict'; - - exports.addObserver = addObserver; - exports.observersFor = observersFor; - exports.removeObserver = removeObserver; - exports._addBeforeObserver = _addBeforeObserver; - exports._suspendObserver = _suspendObserver; - exports._suspendObservers = _suspendObservers; - exports._removeBeforeObserver = _removeBeforeObserver; - - /** - @module ember-metal - */ - - var AFTER_OBSERVERS = ':change'; - var BEFORE_OBSERVERS = ':before'; - - function changeEvent(keyName) { - return keyName + AFTER_OBSERVERS; - } - - function beforeEvent(keyName) { - return keyName + BEFORE_OBSERVERS; - } - - /** - @method addObserver - @for Ember - @param obj - @param {String} _path - @param {Object|Function} target - @param {Function|String} [method] + person.set('guid', 'new-guid'); // will throw an exception + ``` + + @method readOnly + @return {Ember.ComputedProperty} this + @chainable @public */ - - function addObserver(obj, _path, target, method) { - _emberMetalEvents.addListener(obj, changeEvent(_path), target, method); - _emberMetalWatching.watch(obj, _path); + ComputedPropertyPrototype.readOnly = function () { + this._readOnly = true; return this; - } - - function observersFor(obj, path) { - return _emberMetalEvents.listenersFor(obj, changeEvent(path)); - } + }; /** - @method removeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] + Sets the dependent keys on this computed property. Pass any number of + arguments containing key paths that this computed property depends on. + + ```javascript + let President = Ember.Object.extend({ + fullName: Ember.computed(function() { + return this.get('firstName') + ' ' + this.get('lastName'); + + // Tell Ember that this computed property depends on firstName + // and lastName + }).property('firstName', 'lastName') + }); + + let 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 = []; - function removeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, changeEvent(path), target, method); - - return this; - } - - /** - @method _addBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _addBeforeObserver(obj, path, target, method) { - _emberMetalEvents.addListener(obj, beforeEvent(path), target, method); - _emberMetalWatching.watch(obj, path); - - return this; - } - - // Suspend observer during callback. - // - // This should only be used by the target of the observer - // while it is setting the observed path. - - function _suspendObserver(obj, path, target, method, callback) { - return _emberMetalEvents.suspendListener(obj, changeEvent(path), target, method, callback); - } - - function _suspendObservers(obj, paths, target, method, callback) { - var events = paths.map(changeEvent); - return _emberMetalEvents.suspendListeners(obj, events, target, method, callback); - } - - /** - @method removeBeforeObserver - @for Ember - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @deprecated - @private - */ - - function _removeBeforeObserver(obj, path, target, method) { - _emberMetalWatching.unwatch(obj, path); - _emberMetalEvents.removeListener(obj, beforeEvent(path), target, method); - - return this; - } -}); -enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { - 'use strict'; - - exports.default = ObserverSet; - - /* - this.observerSet = { - [senderGuid]: { // variable name: `keySet` - [keyName]: listIndex - } - }, - this.observers = [ - { - sender: obj, - keyName: keyName, - eventName: eventName, - listeners: [ - [target, method, flags] - ] - }, - ... - ] - */ - - function ObserverSet() { - this.clear(); - } - - ObserverSet.prototype.add = function (sender, keyName, eventName) { - var observerSet = this.observerSet; - var observers = this.observers; - var senderGuid = _emberUtils.guidFor(sender); - var keySet = observerSet[senderGuid]; - var index = undefined; - - 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 = undefined, - observer = undefined, - sender = undefined; - this.clear(); - for (i = 0; i < observers.length; ++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; - exports.hasThis = hasThis; - exports.isPath = isPath; - exports.getFirstKey = getFirstKey; - exports.getTailPath = getTailPath; - - var IS_GLOBAL = /^[A-Z$]/; - var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; - var HAS_THIS = 'this.'; - - var isGlobalCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL.test(key); - }); - var isGlobalPathCache = new _emberMetalCache.default(1000, function (key) { - return IS_GLOBAL_PATH.test(key); - }); - var hasThisCache = new _emberMetalCache.default(1000, function (key) { - return key.lastIndexOf(HAS_THIS, 0) === 0; - }); - var firstDotIndexCache = new _emberMetalCache.default(1000, function (key) { - return key.indexOf('.'); - }); - - var firstKeyCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index === -1) { - return path; - } else { - return path.slice(0, index); + function addArg(property) { + args.push(property); } - }); - var tailPathCache = new _emberMetalCache.default(1000, function (path) { - var index = firstDotIndexCache.get(path); - if (index !== -1) { - return path.slice(index + 1); + for (var i = 0; i < arguments.length; i++) { + _emberMetalExpand_properties.default(arguments[i], addArg); } - }); - var caches = { - isGlobalCache: isGlobalCache, - isGlobalPathCache: isGlobalPathCache, - hasThisCache: hasThisCache, - firstDotIndexCache: firstDotIndexCache, - firstKeyCache: firstKeyCache, - tailPathCache: tailPathCache + this._dependentKeys = args; + return this; }; - exports.caches = caches; - - function isGlobal(path) { - return isGlobalCache.get(path); - } - - function isGlobalPath(path) { - return isGlobalPathCache.get(path); - } - - function hasThis(path) { - return hasThisCache.get(path); - } - - function isPath(path) { - return firstDotIndexCache.get(path) !== -1; - } - - function getFirstKey(path) { - return firstKeyCache.get(path); - } - - function getTailPath(path) { - return tailPathCache.get(path); - } -}); -enifed('ember-metal/properties', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/property_events'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperty_events) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.Descriptor = Descriptor; - exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; - exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; - exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; - exports.defineProperty = defineProperty; - - // .......................................................... - // DESCRIPTOR - // - /** - Objects of this type can implement an interface to respond to requests to - get and set. The default implementation handles simple properties. + 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. - @class Descriptor - @private + You can pass a hash of these values to a computed property like this: + + ``` + person: Ember.computed(function() { + let personId = this.get('personId'); + return App.Person.create({ id: personId }); + }).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 */ - - function Descriptor() { - this.isDescriptor = true; - } - - var REDEFINE_SUPPORTED = (function () { - // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 - var a = Object.create(Object.prototype, { - prop: { - configurable: true, - value: 1 - } - }); - - Object.defineProperty(a, 'prop', { - configurable: true, - value: 2 - }); - - return a.prop === 2; - })(); - // .......................................................... - // DEFINING PROPERTIES API - // - - function MANDATORY_SETTER_FUNCTION(name) { - function SETTER_FUNCTION(value) { - var m = _emberMetalMeta.peekMeta(this); - if (!m.isInitialized(this)) { - m.writeValues(name, value); - } else {} + ComputedPropertyPrototype.meta = function (meta) { + if (arguments.length === 0) { + return this._meta || {}; + } else { + this._meta = meta; + return this; } + }; - SETTER_FUNCTION.isMandatorySetter = true; - return SETTER_FUNCTION; - } - - function DEFAULT_GETTER_FUNCTION(name) { - return function GETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - return meta && meta.peekValues(name); - }; - } - - function INHERITING_GETTER_FUNCTION(name) { - function IGETTER_FUNCTION() { - var meta = _emberMetalMeta.peekMeta(this); - var val = meta && meta.readInheritedValue('values', name); - - if (val === _emberMetalMeta.UNDEFINED) { - var proto = Object.getPrototypeOf(this); - return proto && proto[name]; - } else { - return val; - } + // invalidate cache when CP key changes + 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._volatile || this._suspended === obj) { + return; } - IGETTER_FUNCTION.isInheritingGetter = true; - return IGETTER_FUNCTION; - } + // don't create objects just to invalidate + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta || meta.source !== obj) { + return; + } - /** - NOTE: This is a low-level method used by other parts of the API. You almost - never want to call this method directly. Instead you should use - `Ember.mixin()` to define new properties. - - Defines a property on an object. This method works much like the ES5 - `Object.defineProperty()` method except that it can also accept computed - properties and other special descriptors. - - Normally this method takes only three parameters. However if you pass an - instance of `Descriptor` as the third param then you can pass an - optional value as the fourth parameter. This is often more efficient than - creating new descriptor hashes for each property. - - ## Examples - - ```javascript - // ES5 compatible mode - Ember.defineProperty(contact, 'firstName', { - writable: true, - configurable: false, - enumerable: true, - value: 'Charles' - }); - - // define a simple property - Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); - - // define a computed property - Ember.defineProperty(contact, 'fullName', Ember.computed('firstName', 'lastName', function() { - return this.firstName+' '+this.lastName; - })); - ``` - - @private - @method defineProperty - @for Ember - @param {Object} obj the object to define this property on. This may be a prototype. - @param {String} keyName the name of the property - @param {Descriptor} [desc] an instance of `Descriptor` (typically a - computed property) or an ES5 descriptor. - You must provide this or `data` but not both. - @param {*} [data] something other than a descriptor, that will - become the explicit value of this property. - */ - - function defineProperty(obj, keyName, desc, data, meta) { - var possibleDesc = undefined, - existingDesc = undefined, - watching = undefined, - value = undefined; - - if (!meta) { - meta = _emberMetalMeta.meta(obj); - } - var watchEntry = meta.peekWatching(keyName); - possibleDesc = obj[keyName]; - existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - watching = watchEntry !== undefined && watchEntry > 0; - - if (existingDesc) { - existingDesc.teardown(obj, keyName); - } - - if (desc instanceof Descriptor) { - value = desc; - if (false) { - if (watching) { - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: true, - writable: true, - value: value - }); - } else { - obj[keyName] = value; - } - } else { - obj[keyName] = value; - } - if (desc.setup) { - desc.setup(obj, keyName); - } - } else { - if (desc == null) { - value = data; - - if (false) { - if (watching) { - meta.writeValues(keyName, data); - - var defaultDescriptor = { - configurable: true, - enumerable: true, - set: MANDATORY_SETTER_FUNCTION(keyName), - get: DEFAULT_GETTER_FUNCTION(keyName) - }; - - if (REDEFINE_SUPPORTED) { - Object.defineProperty(obj, keyName, defaultDescriptor); - } else { - handleBrokenPhantomDefineProperty(obj, keyName, defaultDescriptor); - } - } else { - obj[keyName] = data; - } - } else { - obj[keyName] = data; - } - } else { - value = desc; - - // fallback to ES5 - Object.defineProperty(obj, keyName, desc); - } - } - - // if key is being watched, override chains that - // were initialized with the prototype - if (watching) { - _emberMetalProperty_events.overrideChains(obj, keyName, meta); - } - - // The `value` passed to the `didDefineProperty` hook is - // either the descriptor or data, whichever was passed. - if (obj.didDefineProperty) { - obj.didDefineProperty(obj, keyName, value); - } - - return this; - } - - function handleBrokenPhantomDefineProperty(obj, keyName, desc) { - // https://github.com/ariya/phantomjs/issues/11856 - Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); - Object.defineProperty(obj, keyName, desc); - } -}); -enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) { - 'use strict'; - - var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE'); - - exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; - var beforeObserverSet = new _emberMetalObserver_set.default(); - var observerSet = new _emberMetalObserver_set.default(); - var deferred = 0; - - // .......................................................... - // PROPERTY CHANGES - // - - /** - This function is called just before an object property is about to change. - It will notify any before observers and prepare caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyDidChange()` which you should call just - after the property value changes. - - @method propertyWillChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @return {void} - @private - */ - function propertyWillChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.willChange) { - desc.willChange(obj, keyName); - } - - if (watching) { - dependentKeysWillChange(obj, keyName, meta); - chainsWillChange(obj, keyName, meta); - notifyBeforeObservers(obj, keyName, meta); - } - } - - /** - This function is called just after an object property has changed. - It will notify any observers and clear caches among other things. - - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually along with `Ember.propertyWillChange()` which you should call just - before the property value changes. - - @method propertyDidChange - @for Ember - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @param {Meta} meta The objects meta. - @return {void} - @private - */ - function propertyDidChange(obj, keyName, _meta) { - var meta = _meta || _emberMetalMeta.peekMeta(obj); - - if (meta && !meta.isInitialized(obj)) { - return; - } - - var watching = meta && meta.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - // shouldn't this mean that we're watching this key? - if (desc && desc.didChange) { - desc.didChange(obj, keyName); - } - - if (watching) { - if (meta.hasDeps(keyName)) { - dependentKeysDidChange(obj, keyName, meta); - } - - chainsDidChange(obj, keyName, meta, false); - notifyObservers(obj, keyName, meta); - } - - if (obj[PROPERTY_DID_CHANGE]) { - obj[PROPERTY_DID_CHANGE](keyName); - } - - if (meta && meta.isSourceDestroying()) { - return; - } - - _emberMetalTags.markObjectAsDirty(meta, keyName); - - if (false || false) { - _emberMetalTransaction.assertNotRendered(obj, keyName, meta); - } - } - - var WILL_SEEN = undefined, - DID_SEEN = undefined; - // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) - function dependentKeysWillChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = WILL_SEEN; - var _top = !seen; - - if (_top) { - seen = WILL_SEEN = {}; - } - - iterDeps(propertyWillChange, obj, depKey, seen, meta); - - if (_top) { - WILL_SEEN = null; - } - } - } - - // called whenever a property has just changed to update dependent keys - function dependentKeysDidChange(obj, depKey, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - if (meta && meta.hasDeps(depKey)) { - var seen = DID_SEEN; - var _top2 = !seen; - - if (_top2) { - seen = DID_SEEN = {}; - } - - iterDeps(propertyDidChange, obj, depKey, seen, meta); - - if (_top2) { - DID_SEEN = null; - } - } - } - - function iterDeps(method, obj, depKey, seen, meta) { - var possibleDesc = undefined, - desc = undefined; - var guid = _emberUtils.guidFor(obj); - var current = seen[guid]; - - if (!current) { - current = seen[guid] = {}; - } - - if (current[depKey]) { - return; - } - - current[depKey] = true; - - meta.forEachInDeps(depKey, function (key, value) { - if (!value) { - return; - } - - possibleDesc = obj[key]; - desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc._suspended === obj) { - return; - } - - method(obj, key, meta); - }); - } - - function chainsWillChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, false, propertyWillChange); - } - } - - function chainsDidChange(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.notify(keyName, true, propertyDidChange); - } - } - - function overrideChains(obj, keyName, meta) { - var chainWatchers = meta.readableChainWatchers(); - if (chainWatchers) { - chainWatchers.revalidate(keyName); - } - } - - /** - @method beginPropertyChanges - @chainable - @private - */ - function beginPropertyChanges() { - deferred++; - } - - /** - @method endPropertyChanges - @private - */ - function endPropertyChanges() { - deferred--; - if (deferred <= 0) { - beforeObserverSet.clear(); - observerSet.flush(); - } - } - - /** - Make a series of property changes together in an - exception-safe way. - - ```javascript - Ember.changeProperties(function() { - obj1.set('foo', mayBlowUpWhenSet); - obj2.set('bar', baz); - }); - ``` - - @method changeProperties - @param {Function} callback - @param [binding] - @private - */ - function changeProperties(callback, binding) { - beginPropertyChanges(); - try { - callback.call(binding); - } finally { - endPropertyChanges.call(binding); - } - } - - function notifyBeforeObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':before'; - var listeners = undefined, - added = undefined; - if (deferred) { - listeners = beforeObserverSet.add(obj, keyName, eventName); - added = _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName], added); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - function notifyObservers(obj, keyName, meta) { - if (meta && meta.isSourceDestroying()) { - return; - } - - var eventName = keyName + ':change'; - var listeners = undefined; - if (deferred) { - listeners = observerSet.add(obj, keyName, eventName); - _emberMetalEvents.accumulateListeners(obj, eventName, listeners); - } else { - _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); - } - } - - exports.propertyWillChange = propertyWillChange; - exports.propertyDidChange = propertyDidChange; - exports.overrideChains = overrideChains; - exports.beginPropertyChanges = beginPropertyChanges; - exports.endPropertyChanges = endPropertyChanges; - exports.changeProperties = changeProperties; -}); -enifed('ember-metal/property_get', ['exports', 'ember-metal/debug', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalPath_cache) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.get = get; - exports._getPath = _getPath; - exports.getWithDefault = getWithDefault; - - var ALLOWABLE_TYPES = { - object: true, - function: true, - string: true - }; - - // .......................................................... - // GET AND SET - // - // If we are on a platform that supports accessors we can use those. - // Otherwise simulate accessors by looking up the property directly on the - // object. - - /** - Gets the value of a property on an object. If the property is computed, - the function will be invoked. If the property is not defined but the - object implements the `unknownProperty` method then that will be invoked. - - ```javascript - Ember.get(obj, "name"); - ``` - - If you plan to run on IE8 and older browsers then you should use this - method anytime you want to retrieve a property on an object that you don't - know for sure is private. (Properties beginning with an underscore '_' - are considered private.) - - On all newer browsers, you only need to use this method to retrieve - properties if the property might not be defined on the object and you want - to respect the `unknownProperty` handler. Otherwise you can ignore this - method. - - Note that if the object itself is `undefined`, this method will throw - an error. - - @method get - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The property key to retrieve - @return {Object} the property value or `null`. - @public - */ - - function get(obj, keyName) { - - var value = obj[keyName]; - var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined; - var ret = undefined; - - if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) { - return _getPath(obj, keyName); - } - - if (desc) { - return desc.get(obj, keyName); - } else { - ret = value; - - if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { - return obj.unknownProperty(keyName); - } - - return ret; - } - } - - function _getPath(root, path) { - var obj = root; - var parts = path.split('.'); - - for (var i = 0; i < parts.length; i++) { - if (!isGettable(obj)) { - return undefined; - } - - obj = get(obj, parts[i]); - - if (obj && obj.isDestroyed) { - return undefined; - } - } - - return obj; - } - - function isGettable(obj) { - if (obj == null) { - return false; - } - - return ALLOWABLE_TYPES[typeof obj]; - } - - /** - Retrieves the value of a property from an Object, or a default value in the - case that the property returns `undefined`. - - ```javascript - Ember.getWithDefault(person, 'lastName', 'Doe'); - ``` - - @method getWithDefault - @for Ember - @param {Object} obj The object to retrieve from. - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public - */ - - function getWithDefault(root, key, defaultValue) { - var value = get(root, key); - - if (value === undefined) { - return defaultValue; - } - return value; - } - - exports.default = get; -}); -enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) { - 'use strict'; - - exports.set = set; - exports.trySet = trySet; - - /** - Sets the value of a property on an object, respecting computed properties - and notifying observers and other listeners of the change. If the - property is not defined but the object implements the `setUnknownProperty` - method then that will be invoked as well. - - ```javascript - Ember.set(obj, "name", value); - ``` - - @method set - @for Ember - @param {Object} obj The object to modify. - @param {String} keyName The property key to set - @param {Object} value The value to set - @return {Object} the passed value. - @public - */ - - function set(obj, keyName, value, tolerant) { - - if (_emberMetalPath_cache.isPath(keyName)) { - return setPath(obj, keyName, value, tolerant); - } - - var meta = _emberMetalMeta.peekMeta(obj); - var possibleDesc = obj[keyName]; - - var desc = undefined, - currentValue = undefined; - if (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { - desc = possibleDesc; - } else { - currentValue = possibleDesc; - } - - if (desc) { - /* computed property */ - desc.set(obj, keyName, value); - } else if (obj.setUnknownProperty && currentValue === undefined && !(keyName in obj)) { - obj.setUnknownProperty(keyName, value); - /* unknown property */ - } else if (currentValue === value) { - /* no change */ - return value; - } else { - _emberMetalProperty_events.propertyWillChange(obj, keyName); - - if (false) { - setWithMandatorySetter(meta, obj, keyName, value); - } else { - obj[keyName] = value; - } - - _emberMetalProperty_events.propertyDidChange(obj, keyName); - } - - return value; - } - - if (false) { - var setWithMandatorySetter = function (meta, obj, keyName, value) { - if (meta && meta.peekWatching(keyName) > 0) { - makeEnumerable(obj, keyName); - meta.writeValue(obj, keyName, value); - } else { - obj[keyName] = value; - } - }; - - var makeEnumerable = function (obj, key) { - var desc = Object.getOwnPropertyDescriptor(obj, key); - - if (desc && desc.set && desc.set.isMandatorySetter) { - desc.enumerable = true; - Object.defineProperty(obj, key, desc); - } - }; - } - - function setPath(root, path, value, tolerant) { - // get the last part of the path - var keyName = path.slice(path.lastIndexOf('.') + 1); - - // get the first part of the part - path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); - - // unless the path is this, look up the first part to - // get the root - if (path !== 'this') { - root = _emberMetalProperty_get._getPath(root, path); - } - - if (!keyName || keyName.length === 0) { - throw new _emberMetalError.default('Property set failed: You passed an empty path'); - } - - if (!root) { - if (tolerant) { - return; - } else { - throw new _emberMetalError.default('Property set failed: object in path "' + path + '" could not be found or was destroyed.'); - } - } - - return set(root, keyName, value); - } - - /** - Error-tolerant form of `Ember.set`. Will not blow up if any part of the - chain is `undefined`, `null`, or destroyed. - - This is primarily used when syncing bindings, which may try to update after - an object has been destroyed. - - @method trySet - @for Ember - @param {Object} root The object to modify. - @param {String} path The property path to set - @param {Object} value The value to set - @public - */ - - function trySet(root, path, value) { - return set(root, path, value, true); - } -}); -enifed("ember-metal/replace", ["exports"], function (exports) { - "use strict"; - - exports.default = replace; - var splice = Array.prototype.splice; - - function replace(array, idx, amt, objects) { - var args = [].concat(objects); - var ret = []; - // https://code.google.com/p/chromium/issues/detail?id=56588 - var size = 60000; - var start = idx; - var ends = amt; - var count = undefined, - chunk = undefined; - - while (args.length) { - count = ends > size ? size : ends; - if (count <= 0) { - count = 0; - } - - chunk = args.splice(0, size); - chunk = [start, count].concat(chunk); - - start += size; - ends -= count; - - ret = ret.concat(splice.apply(array, chunk)); - } - return ret; - } -}); -enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) { - 'use strict'; - - exports.default = run; - - function onBegin(current) { - run.currentRunLoop = current; - } - - function onEnd(current, next) { - run.currentRunLoop = next; - } - - var onErrorTarget = { - get onerror() { - return _emberMetalError_handler.getOnerror(); - }, - set onerror(handler) { - return _emberMetalError_handler.setOnerror(handler); - } - }; - - var backburner = new _backburner.default(['sync', 'actions', 'destroy'], { - GUID_KEY: _emberUtils.GUID_KEY, - sync: { - before: _emberMetalProperty_events.beginPropertyChanges, - after: _emberMetalProperty_events.endPropertyChanges - }, - defaultQueue: 'actions', - onBegin: onBegin, - onEnd: onEnd, - onErrorTarget: onErrorTarget, - onErrorMethod: 'onerror' - }); - - // .......................................................... - // run - this is ideally the only public API the dev sees - // - - /** - Runs the passed target and method inside of a RunLoop, ensuring any - deferred actions including bindings and views updates are flushed at the - end. - - Normally you should not need to invoke this method yourself. However if - you are implementing raw event handlers when interfacing with other - libraries or plugins, you should probably wrap all of your code inside this - call. - - ```javascript - run(function() { - // code to be executed within a RunLoop - }); - ``` - - @class run - @namespace Ember - @static - @constructor - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} return value from invoking the passed function. - @public - */ - - function run() { - return backburner.run.apply(backburner, arguments); - } - - /** - If no run-loop is present, it creates a new one. If a run loop is - present it will queue itself to run on the existing run-loops action - queue. - - Please note: This is not for normal usage, and should be used sparingly. - - If invoked when not within a run loop: - - ```javascript - run.join(function() { - // creates a new run-loop - }); - ``` - - Alternatively, if called within an existing run loop: - - ```javascript - run(function() { - // creates a new run-loop - run.join(function() { - // joins with the existing run-loop, and queues for invocation on - // the existing run-loops action queue. - }); - }); - ``` - - @method join - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Object} Return value from invoking the passed function. Please note, - when called within an existing loop, no return value is possible. - @public - */ - run.join = function () { - return backburner.join.apply(backburner, arguments); - }; - - /** - Allows you to specify which context to call the specified function in while - adding the execution of that function to the Ember run loop. This ability - makes this method a great way to asynchronously integrate third-party libraries - into your Ember application. - - `run.bind` takes two main arguments, the desired context and the function to - invoke in that context. Any additional arguments will be supplied as arguments - to the function that is passed in. - - Let's use the creation of a TinyMCE component as an example. Currently, - TinyMCE provides a setup configuration option we can use to do some processing - after the TinyMCE instance is initialized but before it is actually rendered. - We can use that setup option to do some additional setup for our component. - The component itself could look something like the following: - - ```javascript - App.RichTextEditorComponent = Ember.Component.extend({ - initializeTinyMCE: Ember.on('didInsertElement', function() { - tinymce.init({ - selector: '#' + this.$().prop('id'), - setup: Ember.run.bind(this, this.setupEditor) - }); - }), - - setupEditor: function(editor) { - this.set('editor', editor); - - editor.on('change', function() { - console.log('content changed!'); - }); - } - }); - ``` - - In this example, we use Ember.run.bind to bind the setupEditor method to the - context of the App.RichTextEditorComponent and to have the invocation of that - method be safely handled and executed by the Ember run loop. - - @method bind - @namespace Ember - @param {Object} [target] target of method to call - @param {Function|String} method Method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Any additional arguments you wish to pass to the method. - @return {Function} returns a new function that will always have a particular context - @since 1.4.0 - @public - */ - run.bind = function () { - for (var _len = arguments.length, curried = Array(_len), _key = 0; _key < _len; _key++) { - curried[_key] = arguments[_key]; - } - - return function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return run.join.apply(run, curried.concat(args)); - }; - }; - - run.backburner = backburner; - run.currentRunLoop = null; - run.queues = backburner.queueNames; - - /** - Begins a new RunLoop. Any deferred actions invoked after the begin will - be buffered until you invoke a matching call to `run.end()`. This is - a lower-level way to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method begin - @return {void} - @public - */ - run.begin = function () { - backburner.begin(); - }; - - /** - Ends a RunLoop. This must be called sometime after you call - `run.begin()` to flush any deferred actions. This is a lower-level way - to use a RunLoop instead of using `run()`. - - ```javascript - run.begin(); - // code to be executed within a RunLoop - run.end(); - ``` - - @method end - @return {void} - @public - */ - run.end = function () { - backburner.end(); - }; - - /** - Array of named queues. This array determines the order in which queues - are flushed at the end of the RunLoop. You can define your own queues by - simply adding the queue name to this array. Normally you should not need - to inspect or modify this property. - - @property queues - @type Array - @default ['sync', 'actions', 'destroy'] - @private - */ - - /** - Adds the passed target/method and any optional arguments to the named - queue to be executed at the end of the RunLoop. If you have not already - started a RunLoop when calling this method one will be started for you - automatically. - - At the end of a RunLoop, any methods scheduled in this way will be invoked. - Methods will be invoked in an order matching the named queues defined in - the `run.queues` property. - - ```javascript - run.schedule('sync', this, function() { - // this will be executed in the first RunLoop queue, when bindings are synced - console.log('scheduled on sync queue'); - }); - - run.schedule('actions', this, function() { - // this will be executed in the 'actions' queue, after bindings have synced. - console.log('scheduled on actions queue'); - }); - - // Note the functions will be run in order based on the run queues order. - // Output would be: - // scheduled on sync queue - // scheduled on actions queue - ``` - - @method schedule - @param {String} queue The name of the queue to schedule against. - Default queues are 'sync' and 'actions' - @param {Object} [target] target object to use as the context when invoking a method. - @param {String|Function} method The method to invoke. If you pass a string it - will be resolved on the target object at the time the scheduled item is - invoked allowing you to change the target function. - @param {Object} [arguments*] Optional arguments to be passed to the queued method. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.schedule = function () /* queue, target, method */{ - - return backburner.schedule.apply(backburner, arguments); - }; - - // Used by global test teardown - run.hasScheduledTimers = function () { - return backburner.hasTimers(); - }; - - // Used by global test teardown - run.cancelTimers = function () { - backburner.cancelTimers(); - }; - - /** - Immediately flushes any events scheduled in the 'sync' queue. Bindings - use this queue so this method is a useful way to immediately force all - bindings in the application to sync. - - You should call this method anytime you need any changed state to propagate - throughout the app immediately without repainting the UI (which happens - in the later 'render' queue added by the `ember-views` package). - - ```javascript - run.sync(); - ``` - - @method sync - @return {void} - @private - */ - run.sync = function () { - if (backburner.currentInstance) { - backburner.currentInstance.queues.sync.flush(); - } - }; - - /** - Invokes the passed target/method and optional arguments after a specified - period of time. The last parameter of this method must always be a number - of milliseconds. - - You should use this method whenever you need to run some action after a - period of time instead of using `setTimeout()`. This method will ensure that - items that expire during the same script execution cycle all execute - together, which is often more efficient than using a real setTimeout. - - ```javascript - run.later(myContext, function() { - // code here will execute within a RunLoop in about 500ms with this == myContext - }, 500); - ``` - - @method later - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @return {*} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.later = function () /*target, method*/{ - return backburner.later.apply(backburner, arguments); - }; - - /** - Schedule a function to run one time during the current RunLoop. This is equivalent - to calling `scheduleOnce` with the "actions" queue. - - @method once - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.once = function () { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - args.unshift('actions'); - return backburner.scheduleOnce.apply(backburner, args); - }; - - /** - Schedules a function to run one time in a given queue of the current RunLoop. - Calling this method with the same queue/target/method combination will have - no effect (past the initial call). - - Note that although you can pass optional arguments these will not be - considered when looking for duplicates. New arguments will replace previous - calls. - - ```javascript - function sayHi() { - console.log('hi'); - } - - run(function() { - run.scheduleOnce('afterRender', myContext, sayHi); - run.scheduleOnce('afterRender', myContext, sayHi); - // sayHi will only be executed once, in the afterRender queue of the RunLoop - }); - ``` - - Also note that passing an anonymous function to `run.scheduleOnce` will - not prevent additional calls with an identical anonymous function from - scheduling the items multiple times, e.g.: - - ```javascript - function scheduleIt() { - run.scheduleOnce('actions', myContext, function() { - console.log('Closure'); - }); - } - - scheduleIt(); - scheduleIt(); - - // "Closure" will print twice, even though we're using `run.scheduleOnce`, - // because the function we pass to it is anonymous and won't match the - // previously scheduled operation. - ``` - - Available queues, and their order, can be found at `run.queues` - - @method scheduleOnce - @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'. - @param {Object} [target] The target of the method to invoke. - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.scheduleOnce = function () /*queue, target, method*/{ - return backburner.scheduleOnce.apply(backburner, arguments); - }; - - /** - Schedules an item to run from within a separate run loop, after - control has been returned to the system. This is equivalent to calling - `run.later` with a wait time of 1ms. - - ```javascript - run.next(myContext, function() { - // code to be executed in the next run loop, - // which will be scheduled after the current one - }); - ``` - - Multiple operations scheduled with `run.next` will coalesce - into the same later run loop, along with any other operations - scheduled by `run.later` that expire right around the same - time that `run.next` operations will fire. - - Note that there are often alternatives to using `run.next`. - For instance, if you'd like to schedule an operation to happen - after all DOM element operations have completed within the current - run loop, you can make use of the `afterRender` run loop queue (added - by the `ember-views` package, along with the preceding `render` queue - where all the DOM element operations happen). - - Example: - - ```javascript - export default Ember.Component.extend({ - didInsertElement() { - this._super(...arguments); - run.scheduleOnce('afterRender', this, 'processChildElements'); - }, - - processChildElements() { - // ... do something with component's child component - // elements after they've finished rendering, which - // can't be done within this component's - // `didInsertElement` hook because that gets run - // before the child elements have been added to the DOM. - } - }); - ``` - - One benefit of the above approach compared to using `run.next` is - that you will be able to perform DOM/CSS operations before unprocessed - elements are rendered to the screen, which may prevent flickering or - other artifacts caused by delaying processing until after rendering. - - The other major benefit to the above approach is that `run.next` - introduces an element of non-determinism, which can make things much - harder to test, due to its reliance on `setTimeout`; it's much harder - to guarantee the order of scheduled operations when they are scheduled - outside of the current run loop, i.e. with `run.next`. - - @method next - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - If you pass a string it will be resolved on the - target at the time the method is invoked. - @param {Object} [args*] Optional arguments to pass to the timeout. - @return {Object} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.next = function () { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - args.push(1); - return backburner.later.apply(backburner, args); - }; - - /** - Cancels a scheduled item. Must be a value returned by `run.later()`, - `run.once()`, `run.scheduleOnce()`, `run.next()`, `run.debounce()`, or - `run.throttle()`. - - ```javascript - let runNext = run.next(myContext, function() { - // will not be executed - }); - - run.cancel(runNext); - - let runLater = run.later(myContext, function() { - // will not be executed - }, 500); - - run.cancel(runLater); - - let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { - // will not be executed - }); - - run.cancel(runScheduleOnce); - - let runOnce = run.once(myContext, function() { - // will not be executed - }); - - run.cancel(runOnce); - - let throttle = run.throttle(myContext, function() { - // will not be executed - }, 1, false); - - run.cancel(throttle); - - let debounce = run.debounce(myContext, function() { - // will not be executed - }, 1); - - run.cancel(debounce); - - let debounceImmediate = run.debounce(myContext, function() { - // will be executed since we passed in true (immediate) - }, 100, true); - - // the 100ms delay until this method can be called again will be cancelled - run.cancel(debounceImmediate); - ``` - - @method cancel - @param {Object} timer Timer object to cancel - @return {Boolean} true if cancelled or false/undefined if it wasn't found - @public - */ - run.cancel = function (timer) { - return backburner.cancel(timer); - }; - - /** - Delay calling the target method until the debounce period has elapsed - with no additional debounce calls. If `debounce` is called again before - the specified time has elapsed, the timer is reset and the entire period - must pass again before the target method is called. - - This method should be used when an event may be called multiple times - but the action should only be called once when the event is done firing. - A common example is for scroll events where you only want updates to - happen once scrolling has ceased. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150); - - // less than 150ms passes - run.debounce(myContext, whoRan, 150); - - // 150ms passes - // whoRan is invoked with context myContext - // console logs 'debounce ran.' one time. - ``` - - Immediate allows you to run the function immediately, but debounce - other calls for this function until the wait time has elapsed. If - `debounce` is called again before the specified time has elapsed, - the timer is reset and the entire period must pass again before - the method can be called again. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'debounce' }; - - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 100ms passes - run.debounce(myContext, whoRan, 150, true); - - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - run.debounce(myContext, whoRan, 150, true); - - // console logs 'debounce ran.' one time immediately. - // 150ms passes and nothing else is logged to the console and - // the debouncee is no longer being watched - - ``` - - @method debounce - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} wait Number of milliseconds to wait. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to false. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.debounce = function () { - return backburner.debounce.apply(backburner, arguments); - }; - - /** - Ensure that the target method is never called more frequently than - the specified spacing period. The target method is called immediately. - - ```javascript - function whoRan() { - console.log(this.name + ' ran.'); - } - - let myContext = { name: 'throttle' }; - - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 50ms passes - run.throttle(myContext, whoRan, 150); - - // 150ms passes - run.throttle(myContext, whoRan, 150); - // whoRan is invoked with context myContext - // console logs 'throttle ran.' - ``` - - @method throttle - @param {Object} [target] target of method to invoke - @param {Function|String} method The method to invoke. - May be a function or a string. If you pass a string - then it will be looked up on the passed target. - @param {Object} [args*] Optional arguments to pass to the timeout. - @param {Number} spacing Number of milliseconds to space out requests. - @param {Boolean} immediate Trigger the function on the leading instead - of the trailing edge of the wait interval. Defaults to true. - @return {Array} Timer information for use in cancelling, see `run.cancel`. - @public - */ - run.throttle = function () { - return backburner.throttle.apply(backburner, arguments); - }; - - /** - Add a new named queue after the specified queue. - - The queue to add will only be added once. - - @method _addQueue - @param {String} name the name of the queue to add. - @param {String} after the name of the queue to add after. - @private - */ - run._addQueue = function (name, after) { - if (run.queues.indexOf(name) === -1) { - run.queues.splice(run.queues.indexOf(after) + 1, 0, name); - } - }; -}); -enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set'], function (exports, _emberMetalProperty_events, _emberMetalProperty_set) { - 'use strict'; - - exports.default = setProperties; - - /** - Set a list of properties on an object. These properties are set inside - a single `beginPropertyChanges` and `endPropertyChanges` batch, so - observers will be buffered. - - ```javascript - let anObject = Ember.Object.create(); - - anObject.setProperties({ - firstName: 'Stanley', - lastName: 'Stuart', - age: 21 - }); - ``` - - @method setProperties - @param obj - @param {Object} properties - @return properties - @public - */ - - function setProperties(obj, properties) { - if (!properties || typeof properties !== 'object') { - return properties; - } - _emberMetalProperty_events.changeProperties(function () { - var props = Object.keys(properties); - var propertyName = undefined; - - for (var i = 0; i < props.length; i++) { - propertyName = props[i]; - - _emberMetalProperty_set.set(obj, propertyName, properties[propertyName]); - } - }); - return properties; - } -}); -enifed('ember-metal/tags', ['exports', 'glimmer-reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { - 'use strict'; - - exports.setHasViews = setHasViews; - exports.tagForProperty = tagForProperty; - exports.tagFor = tagFor; - exports.markObjectAsDirty = markObjectAsDirty; - - var hasViews = function () { - return false; - }; - - function setHasViews(fn) { - hasViews = fn; - } - - function makeTag() { - return new _glimmerReference.DirtyableTag(); - } - - function tagForProperty(object, propertyKey, _meta) { - if (_emberMetalIs_proxy.isProxy(object)) { - return tagFor(object, _meta); - } - - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - var tags = meta.writableTags(); - var tag = tags[propertyKey]; - if (tag) { - return tag; - } - - return tags[propertyKey] = makeTag(); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function tagFor(object, _meta) { - if (typeof object === 'object' && object) { - var meta = _meta || _emberMetalMeta.meta(object); - return meta.writableTag(makeTag); - } else { - return _glimmerReference.CONSTANT_TAG; - } - } - - function markObjectAsDirty(meta, propertyKey) { - var objectTag = meta && meta.readableTag(); - - if (objectTag) { - objectTag.dirty(); - } - - var tags = meta && meta.readableTags(); - var propertyTag = tags && tags[propertyKey]; - - if (propertyTag) { - propertyTag.dirty(); - } - - if (objectTag || propertyTag) { - ensureRunloop(); - } - } - - var run = undefined; - - function K() {} - - function ensureRunloop() { - if (!run) { - run = _require.default('ember-metal/run_loop').default; - } - - if (hasViews() && !run.backburner.currentInstance) { - run.schedule('actions', K); - } - } -}); -enifed("ember-metal/testing", ["exports"], function (exports) { - "use strict"; - - exports.isTesting = isTesting; - exports.setTesting = setTesting; - var testing = false; - - function isTesting() { - return testing; - } - - function setTesting(value) { - testing = !!value; - } -}); -enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) { - 'use strict'; - - var runInTransaction = undefined, - didRender = undefined, - assertNotRendered = undefined; - - var raise = _emberMetalDebug.assert; - if (false) { - raise = function (message, test) {}; - } - - var implication = undefined; - if (false) { - implication = 'will be removed in Ember 3.0.'; - } else if (false) { - implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; - } - - if (false || false) { - (function () { - var counter = 0; - var inTransaction = false; - var shouldReflush = undefined; - - exports.default = runInTransaction = function (context, methodName) { - shouldReflush = false; - inTransaction = true; - context[methodName](); - inTransaction = false; - counter++; - return shouldReflush; - }; - - exports.didRender = didRender = function (object, key, reference) { - if (!inTransaction) { - return; - } - var meta = _emberMetalMeta.meta(object); - var lastRendered = meta.writableLastRendered(); - lastRendered[key] = counter; - }; - - exports.assertNotRendered = assertNotRendered = function (object, key, _meta) { - var meta = _meta || _emberMetalMeta.meta(object); - var lastRendered = meta.readableLastRendered(); - - if (lastRendered && lastRendered[key] === counter) { - raise((function () { - var ref = meta.readableLastRenderedFrom(); - var parts = []; - var lastRef = ref[key]; - - var label = undefined; - - if (lastRef) { - while (lastRef && lastRef._propertyKey) { - parts.unshift(lastRef._propertyKey); - lastRef = lastRef._parentReference; - } - - label = parts.join(); - } else { - label = 'the same value'; - } - - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; - })(), false); - - shouldReflush = true; - } - }; - })(); - } else { - exports.default = runInTransaction = function () { - throw new Error('Cannot call runInTransaction without Glimmer'); - }; - - exports.didRender = didRender = function () { - throw new Error('Cannot call didRender without Glimmer'); - }; - - exports.assertNotRendered = assertNotRendered = function () { - throw new Error('Cannot call assertNotRendered without Glimmer'); - }; - } - - exports.default = runInTransaction; - exports.didRender = didRender; - exports.assertNotRendered = assertNotRendered; -}); -enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) { - 'use strict'; - - exports.watchKey = watchKey; - exports.unwatchKey = unwatchKey; - - var handleMandatorySetter = undefined; - - function watchKey(obj, keyName, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - - // activate watching first time - if (!m.peekWatching(keyName)) { - m.writeWatching(keyName, 1); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - if (desc && desc.willWatch) { - desc.willWatch(obj, keyName); - } - - if ('function' === typeof obj.willWatchProperty) { - obj.willWatchProperty(keyName); - } - - if (false) { - // NOTE: this is dropped for prod + minified builds - handleMandatorySetter(m, obj, keyName); - } - } else { - m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1); - } - } - - if (false) { - (function () { - var hasOwnProperty = function (obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - }; - - var propertyIsEnumerable = function (obj, key) { - return Object.prototype.propertyIsEnumerable.call(obj, key); - }; - - // Future traveler, although this code looks scary. It merely exists in - // development to aid in development asertions. Production builds of - // ember strip this entire block out - handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { - var descriptor = _emberUtils.lookupDescriptor(obj, keyName); - var configurable = descriptor ? descriptor.configurable : true; - var isWritable = descriptor ? descriptor.writable : true; - var hasValue = descriptor ? 'value' in descriptor : true; - var possibleDesc = descriptor && descriptor.value; - var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; - - if (isDescriptor) { - return; - } - - // this x in Y deopts, so keeping it in this function is better; - if (configurable && isWritable && hasValue && keyName in obj) { - var desc = { - configurable: true, - set: _emberMetalProperties.MANDATORY_SETTER_FUNCTION(keyName), - enumerable: propertyIsEnumerable(obj, keyName), - get: undefined - }; - - if (hasOwnProperty(obj, keyName)) { - m.writeValues(keyName, obj[keyName]); - desc.get = _emberMetalProperties.DEFAULT_GETTER_FUNCTION(keyName); - } else { - desc.get = _emberMetalProperties.INHERITING_GETTER_FUNCTION(keyName); - } - - Object.defineProperty(obj, keyName, desc); - } - }; - })(); - } - - function unwatchKey(obj, keyName, _meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var meta = _meta || _emberMetalMeta.meta(obj); - - // do nothing of this object has already been destroyed - if (meta.isSourceDestroyed()) { - return; - } - - var count = meta.peekWatching(keyName); - if (count === 1) { - meta.writeWatching(keyName, 0); - - var possibleDesc = obj[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - - if (desc && desc.didUnwatch) { - desc.didUnwatch(obj, keyName); - } - - if ('function' === typeof obj.didUnwatchProperty) { - obj.didUnwatchProperty(keyName); - } - - if (false) { - // It is true, the following code looks quite WAT. But have no fear, It - // exists purely to improve development ergonomics and is removed from - // ember.min.js and ember.prod.js builds. - // - // Some further context: Once a property is watched by ember, bypassing `set` - // for mutation, will bypass observation. This code exists to assert when - // that occurs, and attempt to provide more helpful feedback. The alternative - // is tricky to debug partially observable properties. - if (!desc && keyName in obj) { - var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName); - - if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { - if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { - var possibleValue = meta.readInheritedValue('values', keyName); - if (possibleValue === _emberMetalMeta.UNDEFINED) { - delete obj[keyName]; - return; - } - } - - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), - writable: true, - value: meta.peekValues(keyName) - }); - meta.deleteFromValues(keyName); - } - } - } - } else if (count > 1) { - meta.writeWatching(keyName, count - 1); - } - } -}); -enifed('ember-metal/watch_path', ['exports', 'ember-metal/meta', 'ember-metal/chains'], function (exports, _emberMetalMeta, _emberMetalChains) { - 'use strict'; - - exports.makeChainNode = makeChainNode; - exports.watchPath = watchPath; - exports.unwatchPath = unwatchPath; - - // get the chains for the current object. If the current object has - // chains inherited from the proto they will be cloned and reconfigured for - // the current object. - function chainsFor(obj, meta) { - return (meta || _emberMetalMeta.meta(obj)).writableChains(makeChainNode); - } - - function makeChainNode(obj) { - return new _emberMetalChains.ChainNode(null, null, obj); - } - - function watchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - if (!counter) { - // activate watching first time - m.writeWatching(keyPath, 1); - chainsFor(obj, m).add(keyPath); - } else { - m.writeWatching(keyPath, counter + 1); - } - } - - function unwatchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } - var m = meta || _emberMetalMeta.meta(obj); - var counter = m.peekWatching(keyPath) || 0; - - if (counter === 1) { - m.writeWatching(keyPath, 0); - chainsFor(obj, m).remove(keyPath); - } else if (counter > 1) { - m.writeWatching(keyPath, counter - 1); - } - } -}); -enifed('ember-metal/watching', ['exports', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) { - /** - @module ember-metal - */ - - 'use strict'; - - exports.isWatching = isWatching; - exports.watcherCount = watcherCount; - exports.unwatch = unwatch; - exports.destroy = destroy; - - /** - Starts watching a property on an object. Whenever the property changes, - invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the - primitive used by observers and dependent keys; usually you will never call - this method directly but instead use higher level methods like - `Ember.addObserver()` - - @private - @method watch - @for Ember - @param obj - @param {String} _keyPath - */ - function watch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.watchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.watchPath(obj, _keyPath, m); - } - } - - exports.watch = watch; - - function isWatching(obj, key) { - if (typeof obj !== 'object' || obj === null) { - return false; - } - var meta = _emberMetalMeta.peekMeta(obj); - return (meta && meta.peekWatching(key)) > 0; - } - - function watcherCount(obj, key) { - var meta = _emberMetalMeta.peekMeta(obj); - return meta && meta.peekWatching(key) || 0; - } - - function unwatch(obj, _keyPath, m) { - if (!_emberMetalPath_cache.isPath(_keyPath)) { - _emberMetalWatch_key.unwatchKey(obj, _keyPath, m); - } else { - _emberMetalWatch_path.unwatchPath(obj, _keyPath, m); - } - } - - /** - Tears down the meta on an object so that it can be garbage collected. - Multiple calls will have no effect. - - @method destroy - @for Ember - @param {Object} obj the object to destroy - @return {void} - @private - */ - - function destroy(obj) { - _emberMetalMeta.deleteMeta(obj); - } -}); -enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { - 'use strict'; - - exports.default = WeakMap; - - var id = 0; - - // Returns whether Type(value) is Object according to the terminology in the spec - function isObject(value) { - return typeof value === 'object' && value !== null || typeof value === 'function'; - } - - /* - * @class Ember.WeakMap - * @public - * @category ember-metal-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(iterable) { - if (!(this instanceof WeakMap)) { - throw new TypeError('Constructor WeakMap requires \'new\''); - } - - this._id = _emberUtils.GUID_KEY + id++; - - if (iterable === null || iterable === undefined) { - return; - } else if (Array.isArray(iterable)) { - for (var i = 0; i < iterable.length; i++) { - var _iterable$i = iterable[i]; - var key = _iterable$i[0]; - var value = _iterable$i[1]; - - this.set(key, value); - } - } else { - throw new TypeError('The weak map constructor polyfill only supports an array argument'); - } - } - - /* - * @method get - * @param key {Object | Function} - * @return {Any} stored value - */ - WeakMap.prototype.get = function (obj) { - if (!isObject(obj)) { - return undefined; - } - - var meta = _emberMetalMeta.peekMeta(obj); - if (meta) { - var map = meta.readableWeak(); - if (map) { - if (map[this._id] === _emberMetalMeta.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 (!isObject(obj)) { - throw new TypeError('Invalid value used as weak map key'); - } - - if (value === undefined) { - value = _emberMetalMeta.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) { - if (!isObject(obj)) { - return false; - } - - 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; - } - }; - - /* - * @method toString - * @return {String} - */ - WeakMap.prototype.toString = function () { - return '[object WeakMap]'; - }; -}); -enifed('ember-routing/ext/controller', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/utils'], function (exports, _emberMetal, _emberRuntime, _emberRoutingUtils) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - _emberRuntime.ControllerMixin.reopen({ - concatenatedProperties: ['queryParams'], - - /** - Defines which query parameters the controller accepts. - If you give the names `['category','page']` it will bind - the values of these query parameters to the variables - `this.category` and `this.page` - @property queryParams - @public - */ - queryParams: null, - - /** - This property is updated to various different callback functions depending on - the current "state" of the backing route. It is used by - `Ember.Controller.prototype._qpChanged`. - The methods backing each state can be found in the `Ember.Route.prototype._qp` computed - property return value (the `.states` property). The current values are listed here for - the sanity of future travelers: - * `inactive` - This state is used when this controller instance is not part of the active - route heirarchy. Set in `Ember.Route.prototype._reset` (a `router.js` microlib hook) and - `Ember.Route.prototype.actions.finalizeQueryParamChange`. - * `active` - This state is used when this controller instance is part of the active - route heirarchy. Set in `Ember.Route.prototype.actions.finalizeQueryParamChange`. - * `allowOverrides` - This state is used in `Ember.Route.prototype.setup` (`route.js` microlib hook). - @method _qpDelegate - @private - */ - _qpDelegate: null, // set by route - - /** - During `Ember.Route#setup` observers are created to invoke this method - when any of the query params declared in `Ember.Controller#queryParams` property - are changed. - When invoked this method uses the currently active query param update delegate - (see `Ember.Controller.prototype._qpDelegate` for details) and invokes it with - the QP key/value being changed. - @method _qpChanged - @private - */ - _qpChanged: function (controller, _prop) { - var prop = _prop.substr(0, _prop.length - 3); - - var delegate = controller._qpDelegate; - var value = _emberMetal.get(controller, prop); - delegate(prop, value); - }, - - /** - Transition the application into another route. The route may - be either a single route or route path: - ```javascript - aController.transitionToRoute('blogPosts'); - aController.transitionToRoute('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - aController.transitionToRoute('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - aController.transitionToRoute('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```javascript - App.Router.map(function() { - this.route('blogPost', { path: ':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); - }); - }); - aController.transitionToRoute('blogComment', aPost, aComment); - aController.transitionToRoute('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - aController.transitionToRoute('/'); - aController.transitionToRoute('/blog/post/1/comment/13'); - aController.transitionToRoute('/blog/posts?sort=title'); - ``` - An options hash with a `queryParams` property may be provided as - the final argument to add query parameters to the destination URL. - ```javascript - aController.transitionToRoute('blogPost', 1, { - queryParams: { showComments: 'true' } - }); - // if you just want to transition the query parameters without changing the route - aController.transitionToRoute({ queryParams: { sort: 'date' } }); - ``` - See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). - @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 - @for Ember.ControllerMixin - @method transitionToRoute - @public - */ - transitionToRoute: function () { - // target may be either another controller or a router - var target = _emberMetal.get(this, 'target'); - var method = target.transitionToRoute || target.transitionTo; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(this, args)); - }, - - /** - Transition into another route while replacing the current URL, if possible. - This will replace the current history entry instead of adding a new one. - Beside that, it is identical to `transitionToRoute` in all other respects. - ```javascript - aController.replaceRoute('blogPosts'); - aController.replaceRoute('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - aController.replaceRoute('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - aController.replaceRoute('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```javascript - App.Router.map(function() { - this.route('blogPost', { path: ':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); - }); - }); - aController.replaceRoute('blogComment', aPost, aComment); - aController.replaceRoute('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - aController.replaceRoute('/'); - aController.replaceRoute('/blog/post/1/comment/13'); - ``` - @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. - @for Ember.ControllerMixin - @method replaceRoute - @public - */ - replaceRoute: function () { - // target may be either another controller or a router - var target = _emberMetal.get(this, 'target'); - var method = target.replaceRoute || target.replaceWith; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(target, args)); - } - }); - - exports.default = _emberRuntime.ControllerMixin; -}); -enifed('ember-routing/ext/run_loop', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - /** - @module ember - @submodule ember-views - */ - - // Add a new named queue after the 'actions' queue (where RSVP promises - // resolve), which is used in router transitions to prevent unnecessary - // loading state entry if all context promises resolve on the - // 'actions' queue first. - _emberMetal.run._addQueue('routerTransitions', 'actions'); -}); -enifed('ember-routing/index', ['exports', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route', 'ember-routing/system/query_params', 'ember-routing/services/routing', 'ember-routing/system/cache'], function (exports, _emberRoutingExtRun_loop, _emberRoutingExtController, _emberRoutingLocationApi, _emberRoutingLocationNone_location, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingSystemGenerate_controller, _emberRoutingSystemController_for, _emberRoutingSystemDsl, _emberRoutingSystemRouter, _emberRoutingSystemRoute, _emberRoutingSystemQuery_params, _emberRoutingServicesRouting, _emberRoutingSystemCache) { - /** - @module ember - @submodule ember-routing - */ - - // ES6TODO: Cleanup modules with side-effects below - 'use strict'; - - exports.Location = _emberRoutingLocationApi.default; - exports.NoneLocation = _emberRoutingLocationNone_location.default; - exports.HashLocation = _emberRoutingLocationHash_location.default; - exports.HistoryLocation = _emberRoutingLocationHistory_location.default; - exports.AutoLocation = _emberRoutingLocationAuto_location.default; - exports.generateController = _emberRoutingSystemGenerate_controller.default; - exports.generateControllerFactory = _emberRoutingSystemGenerate_controller.generateControllerFactory; - exports.controllerFor = _emberRoutingSystemController_for.default; - exports.RouterDSL = _emberRoutingSystemDsl.default; - exports.Router = _emberRoutingSystemRouter.default; - exports.Route = _emberRoutingSystemRoute.default; - exports.QueryParams = _emberRoutingSystemQuery_params.default; - exports.RoutingService = _emberRoutingServicesRouting.default; - exports.BucketCache = _emberRoutingSystemCache.default; -}); -enifed('ember-routing/location/api', ['exports', 'ember-metal', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberMetal, _emberEnvironment, _emberRoutingLocationUtil) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - /** - Ember.Location returns an instance of the correct implementation of - the `location` API. - - ## Implementations - - You can pass an implementation name (`hash`, `history`, `none`) to force a - particular implementation to be used in your application. - - ### HashLocation - - Using `HashLocation` results in URLs with a `#` (hash sign) separating the - server side URL portion of the URL from the portion that is used by Ember. - This relies upon the `hashchange` event existing in the browser. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'hash' - }); - ``` - - This will result in a posts.new url of `/#/posts/new`. - - ### HistoryLocation - - Using `HistoryLocation` results in URLs that are indistinguishable from a - standard URL. This relies upon the browser's `history` API. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'history' - }); - ``` - - This will result in a posts.new url of `/posts/new`. - - Keep in mind that your server must serve the Ember app at all the routes you - define. - - ### AutoLocation - - Using `AutoLocation`, the router will use the best Location class supported by - the browser it is running in. - - Browsers that support the `history` API will use `HistoryLocation`, those that - do not, but still support the `hashchange` event will use `HashLocation`, and - in the rare case neither is supported will use `NoneLocation`. - - Example: - - ```javascript - App.Router.map(function() { - this.route('posts', function() { - this.route('new'); - }); - }); - - App.Router.reopen({ - location: 'auto' - }); - ``` - - This will result in a posts.new url of `/posts/new` for modern browsers that - support the `history` api or `/#/posts/new` for older ones, like Internet - Explorer 9 and below. - - When a user visits a link to your application, they will be automatically - upgraded or downgraded to the appropriate `Location` class, with the URL - transformed accordingly, if needed. - - Keep in mind that since some of your users will use `HistoryLocation`, your - server must serve the Ember app at all the routes you define. - - ### NoneLocation - - Using `NoneLocation` causes Ember to not store the applications URL state - in the actual URL. This is generally used for testing purposes, and is one - of the changes made when calling `App.setupForTesting()`. - - ## Location API - - Each location implementation must provide the following methods: - - * implementation: returns the string name used to reference the implementation. - * getURL: returns the current URL. - * setURL(path): sets the current URL. - * replaceURL(path): replace the current URL (optional). - * onUpdateURL(callback): triggers the callback when the URL changes. - * formatURL(url): formats `url` to be placed into `href` attribute. - * detect() (optional): instructs the location to do any feature detection - necessary. If the location needs to redirect to a different URL, it - can cancel routing by setting the `cancelRouterSetup` property on itself - to `false`. - - Calling setURL or replaceURL will not trigger onUpdateURL callbacks. - - ## Custom implementation - - Ember scans `app/locations/*` for extending the Location API. - - Example: - - ```javascript - import Ember from 'ember'; - - export default Ember.HistoryLocation.extend({ - implementation: 'history-url-logging', - - pushState: function (path) { - console.log(path); - this._super.apply(this, arguments); - } - }); - ``` - - @class Location - @namespace Ember - @static - @private - */ - exports.default = { - /** - This is deprecated in favor of using the container to lookup the location - implementation as desired. - For example: - ```javascript - // Given a location registered as follows: - container.register('location:history-test', HistoryTestLocation); - // You could create a new instance via: - container.lookup('location:history-test'); - ``` - @method create - @param {Object} options - @return {Object} an instance of an implementation of the `location` API - @deprecated Use the container to lookup the location implementation that you - need. - @private - */ - create: function (options) { - var implementation = options && options.implementation; - - var implementationClass = this.implementations[implementation]; - - return implementationClass.create.apply(implementationClass, arguments); - }, - - implementations: {}, - _location: _emberEnvironment.environment.location, - - /** - Returns the current `location.hash` by parsing location.href since browsers - inconsistently URL-decode `location.hash`. - https://bugzilla.mozilla.org/show_bug.cgi?id=483304 - @private - @method getHash - @since 1.4.0 - */ - _getHash: function () { - return _emberRoutingLocationUtil.getHash(this.location); - } - }; -}); -enifed('ember-routing/location/auto_location', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberRoutingLocationUtil) { - 'use strict'; - - exports.getHistoryPath = getHistoryPath; - exports.getHashPath = getHashPath; - - /** - @module ember - @submodule ember-routing - */ - - /** - Ember.AutoLocation will select the best location option based off browser - support with the priority order: history, hash, none. - - Clean pushState paths accessed by hashchange-only browsers will be redirected - to the hash-equivalent and vice versa so future transitions are consistent. - - Keep in mind that since some of your users will use `HistoryLocation`, your - server must serve the Ember app at all the routes you define. - - @class AutoLocation - @namespace Ember - @static - @private - */ - exports.default = _emberRuntime.Object.extend({ - /** - @private - The browser's `location` object. This is typically equivalent to - `window.location`, but may be overridden for testing. - @property location - @default environment.location - */ - location: _emberEnvironment.environment.location, - - /** - @private - The browser's `history` object. This is typically equivalent to - `window.history`, but may be overridden for testing. - @since 1.5.1 - @property history - @default environment.history - */ - history: _emberEnvironment.environment.history, - - /** - @private - The user agent's global variable. In browsers, this will be `window`. - @since 1.11 - @property global - @default window - */ - global: _emberEnvironment.environment.window, - - /** - @private - The browser's `userAgent`. This is typically equivalent to - `navigator.userAgent`, but may be overridden for testing. - @since 1.5.1 - @property userAgent - @default environment.history - */ - userAgent: _emberEnvironment.environment.userAgent, - - /** - @private - This property is used by the router to know whether to cancel the routing - setup process, which is needed while we redirect the browser. - @since 1.5.1 - @property cancelRouterSetup - @default false - */ - cancelRouterSetup: false, - - /** - @private - Will be pre-pended to path upon state change. - @since 1.5.1 - @property rootURL - @default '/' - */ - rootURL: '/', - - /** - Called by the router to instruct the location to do any feature detection - necessary. In the case of AutoLocation, we detect whether to use history - or hash concrete implementations. - @private - */ - detect: function () { - var rootURL = this.rootURL; - - var implementation = detectImplementation({ - location: this.location, - history: this.history, - userAgent: this.userAgent, - rootURL: rootURL, - documentMode: this.documentMode, - global: this.global - }); - - if (implementation === false) { - _emberMetal.set(this, 'cancelRouterSetup', true); - implementation = 'none'; - } - - var concrete = _emberUtils.getOwner(this).lookup('location:' + implementation); - _emberMetal.set(concrete, 'rootURL', rootURL); - - _emberMetal.set(this, 'concreteImplementation', concrete); - }, - - initState: delegateToConcreteImplementation('initState'), - getURL: delegateToConcreteImplementation('getURL'), - setURL: delegateToConcreteImplementation('setURL'), - replaceURL: delegateToConcreteImplementation('replaceURL'), - onUpdateURL: delegateToConcreteImplementation('onUpdateURL'), - formatURL: delegateToConcreteImplementation('formatURL'), - - willDestroy: function () { - var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - - if (concreteImplementation) { - concreteImplementation.destroy(); - } - } - }); - - function delegateToConcreteImplementation(methodName) { - return function () { - var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _emberUtils.tryInvoke(concreteImplementation, methodName, args); - }; - } - - /* - Given the browser's `location`, `history` and `userAgent`, and a configured - root URL, this function detects whether the browser supports the [History - API](https://developer.mozilla.org/en-US/docs/Web/API/History) and returns a - string representing the Location object to use based on its determination. - - For example, if the page loads in an evergreen browser, this function would - return the string "history", meaning the history API and thus HistoryLocation - should be used. If the page is loaded in IE8, it will return the string - "hash," indicating that the History API should be simulated by manipulating the - hash portion of the location. - - */ - - function detectImplementation(options) { - var location = options.location; - var userAgent = options.userAgent; - var history = options.history; - var documentMode = options.documentMode; - var global = options.global; - var rootURL = options.rootURL; - - var implementation = 'none'; - var cancelRouterSetup = false; - var currentPath = _emberRoutingLocationUtil.getFullPath(location); - - if (_emberRoutingLocationUtil.supportsHistory(userAgent, history)) { - var historyPath = getHistoryPath(rootURL, location); - - // If the browser supports history and we have a history path, we can use - // the history location with no redirects. - if (currentPath === historyPath) { - return 'history'; - } else { - if (currentPath.substr(0, 2) === '/#') { - history.replaceState({ path: historyPath }, null, historyPath); - implementation = 'history'; - } else { - cancelRouterSetup = true; - _emberRoutingLocationUtil.replacePath(location, historyPath); - } - } - } else if (_emberRoutingLocationUtil.supportsHashChange(documentMode, global)) { - var hashPath = getHashPath(rootURL, location); - - // Be sure we're using a hashed path, otherwise let's switch over it to so - // we start off clean and consistent. We'll count an index path with no - // hash as "good enough" as well. - if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') { - implementation = 'hash'; - } else { - // Our URL isn't in the expected hash-supported format, so we want to - // cancel the router setup and replace the URL to start off clean - cancelRouterSetup = true; - _emberRoutingLocationUtil.replacePath(location, hashPath); - } - } - - if (cancelRouterSetup) { - return false; - } - - return implementation; - } - - /** - @private - - Returns the current path as it should appear for HistoryLocation supported - browsers. This may very well differ from the real current path (e.g. if it - starts off as a hashed URL) - */ - - function getHistoryPath(rootURL, location) { - var path = _emberRoutingLocationUtil.getPath(location); - var hash = _emberRoutingLocationUtil.getHash(location); - var query = _emberRoutingLocationUtil.getQuery(location); - var rootURLIndex = path.indexOf(rootURL); - var routeHash = undefined, - hashParts = undefined; - - // By convention, Ember.js routes using HashLocation are required to start - // with `#/`. Anything else should NOT be considered a route and should - // be passed straight through, without transformation. - if (hash.substr(0, 2) === '#/') { - // There could be extra hash segments after the route - hashParts = hash.substr(1).split('#'); - // The first one is always the route url - routeHash = hashParts.shift(); - - // If the path already has a trailing slash, remove the one - // from the hashed route so we don't double up. - if (path.slice(-1) === '/') { - routeHash = routeHash.substr(1); - } - - // This is the "expected" final order - path = path + routeHash + query; - - if (hashParts.length) { - path += '#' + hashParts.join('#'); - } - } else { - path = path + query + hash; - } - - return path; - } - - /** - @private - - Returns the current path as it should appear for HashLocation supported - browsers. This may very well differ from the real current path. - - @method _getHashPath - */ - - function getHashPath(rootURL, location) { - var path = rootURL; - var historyPath = getHistoryPath(rootURL, location); - var routePath = historyPath.substr(rootURL.length); - - if (routePath !== '') { - if (routePath.charAt(0) !== '/') { - routePath = '/' + routePath; - } - - path += '#' + routePath; - } - - return path; - } -}); -enifed('ember-routing/location/hash_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - /** - `Ember.HashLocation` implements the location API using the browser's - hash. At present, it relies on a `hashchange` event existing in the - browser. - - @class HashLocation - @namespace Ember - @extends Ember.Object - @private - */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'hash', - - init: function () { - _emberMetal.set(this, 'location', _emberMetal.get(this, '_location') || window.location); - - this._hashchangeHandler = undefined; - }, - - /** - @private - Returns normalized location.hash - @since 1.5.1 - @method getHash - */ - getHash: _emberRoutingLocationApi.default._getHash, - - /** - Returns the normalized URL, constructed from `location.hash`. - e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. - By convention, hashed paths must begin with a forward slash, otherwise they - are not treated as a path so we can distinguish intent. - @private - @method getURL - */ - getURL: function () { - var originalPath = this.getHash().substr(1); - var outPath = originalPath; - - if (outPath.charAt(0) !== '/') { - outPath = '/'; - - // Only add the # if the path isn't empty. - // We do NOT want `/#` since the ampersand - // is only included (conventionally) when - // the location.hash has a value - if (originalPath) { - outPath += '#' + originalPath; - } - } - - return outPath; - }, - - /** - Set the `location.hash` and remembers what was set. This prevents - `onUpdateURL` callbacks from triggering when the hash was set by - `HashLocation`. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - _emberMetal.get(this, 'location').hash = path; - _emberMetal.set(this, 'lastSetURL', path); - }, - - /** - Uses location.replace to update the url without a page reload - or history modification. - @private - @method replaceURL - @param path {String} - */ - replaceURL: function (path) { - _emberMetal.get(this, 'location').replace('#' + path); - _emberMetal.set(this, 'lastSetURL', path); - }, - - /** - Register a callback to be invoked when the hash changes. These - callbacks will execute when the user presses the back or forward - button, but not after `setURL` is invoked. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - var _this = this; - - this._removeEventListener(); - - this._hashchangeHandler = function () { - _emberMetal.run(function () { - var path = _this.getURL(); - if (_emberMetal.get(_this, 'lastSetURL') === path) { - return; - } - - _emberMetal.set(_this, 'lastSetURL', null); - - callback(path); - }); - }; - - window.addEventListener('hashchange', this._hashchangeHandler); - }, - - /** - Given a URL, formats it to be placed into the page as part - of an element's `href` attribute. - This is used, for example, when using the {{action}} helper - to generate a URL based on an event. - @private - @method formatURL - @param url {String} - */ - formatURL: function (url) { - return '#' + url; - }, - - /** - Cleans up the HashLocation event listener. - @private - @method willDestroy - */ - willDestroy: function () { - this._removeEventListener(); - }, - - _removeEventListener: function () { - if (this._hashchangeHandler) { - window.removeEventListener('hashchange', this._hashchangeHandler); - } - } - }); -}); -enifed('ember-routing/location/history_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - var popstateFired = false; - - /** - Ember.HistoryLocation implements the location API using the browser's - history.pushState API. - - @class HistoryLocation - @namespace Ember - @extends Ember.Object - @private - */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'history', - - init: function () { - this._super.apply(this, arguments); - - var base = document.querySelector('base'); - var baseURL = base ? base.getAttribute('href') : ''; - - _emberMetal.set(this, 'baseURL', baseURL); - _emberMetal.set(this, 'location', _emberMetal.get(this, 'location') || window.location); - - this._popstateHandler = undefined; - }, - - /** - Used to set state on first call to setURL - @private - @method initState - */ - initState: function () { - var history = _emberMetal.get(this, 'history') || window.history; - _emberMetal.set(this, 'history', history); - - if (history && 'state' in history) { - this.supportsHistory = true; - } - - this.replaceState(this.formatURL(this.getURL())); - }, - - /** - Will be pre-pended to path upon state change - @property rootURL - @default '/' - @private - */ - rootURL: '/', - - /** - Returns the current `location.pathname` without `rootURL` or `baseURL` - @private - @method getURL - @return url {String} - */ - getURL: function () { - var location = _emberMetal.get(this, 'location'); - var path = location.pathname; - - var rootURL = _emberMetal.get(this, 'rootURL'); - var baseURL = _emberMetal.get(this, 'baseURL'); - - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - baseURL = baseURL.replace(/\/$/, ''); - - // remove baseURL and rootURL from start of path - var url = path.replace(new RegExp('^' + baseURL + '(?=/|$)'), '').replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - - var search = location.search || ''; - url += search; - url += this.getHash(); - - return url; - }, - - /** - Uses `history.pushState` to update the url without a page reload. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - var state = this.getState(); - path = this.formatURL(path); - - if (!state || state.path !== path) { - this.pushState(path); - } - }, - - /** - Uses `history.replaceState` to update the url without a page reload - or history modification. - @private - @method replaceURL - @param path {String} - */ - replaceURL: function (path) { - var state = this.getState(); - path = this.formatURL(path); - - if (!state || state.path !== path) { - this.replaceState(path); - } - }, - - /** - Get the current `history.state`. Checks for if a polyfill is - required and if so fetches this._historyState. The state returned - from getState may be null if an iframe has changed a window's - history. - @private - @method getState - @return state {Object} - */ - getState: function () { - if (this.supportsHistory) { - return _emberMetal.get(this, 'history').state; - } - - return this._historyState; - }, - - /** - Pushes a new state. - @private - @method pushState - @param path {String} - */ - pushState: function (path) { - var state = { path: path }; - - _emberMetal.get(this, 'history').pushState(state, null, path); - - this._historyState = state; - - // used for webkit workaround - this._previousURL = this.getURL(); - }, - - /** - Replaces the current state. - @private - @method replaceState - @param path {String} - */ - replaceState: function (path) { - var state = { path: path }; - _emberMetal.get(this, 'history').replaceState(state, null, path); - - this._historyState = state; - - // used for webkit workaround - this._previousURL = this.getURL(); - }, - - /** - Register a callback to be invoked whenever the browser - history changes, including using forward and back buttons. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - var _this = this; - - this._removeEventListener(); - - this._popstateHandler = function () { - // Ignore initial page load popstate event in Chrome - if (!popstateFired) { - popstateFired = true; - if (_this.getURL() === _this._previousURL) { - return; - } - } - callback(_this.getURL()); - }; - - window.addEventListener('popstate', this._popstateHandler); - }, - - /** - Used when using `{{action}}` helper. The url is always appended to the rootURL. - @private - @method formatURL - @param url {String} - @return formatted url {String} - */ - formatURL: function (url) { - var rootURL = _emberMetal.get(this, 'rootURL'); - var baseURL = _emberMetal.get(this, 'baseURL'); - - if (url !== '') { - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - baseURL = baseURL.replace(/\/$/, ''); - } else if (baseURL.match(/^\//) && rootURL.match(/^\//)) { - // if baseURL and rootURL both start with a slash - // ... remove trailing slash from baseURL if it exists - baseURL = baseURL.replace(/\/$/, ''); - } - - return baseURL + rootURL + url; - }, - - /** - Cleans up the HistoryLocation event listener. - @private - @method willDestroy - */ - willDestroy: function () { - this._removeEventListener(); - }, - - /** - @private - Returns normalized location.hash - @method getHash - */ - getHash: _emberRoutingLocationApi.default._getHash, - - _removeEventListener: function () { - if (this._popstateHandler) { - window.removeEventListener('popstate', this._popstateHandler); - } - } - }); -}); -enifed('ember-routing/location/none_location', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - /** - Ember.NoneLocation does not interact with the browser. It is useful for - testing, or when you need to manage state with your Router, but temporarily - don't want it to muck with the URL (for example when you embed your - application in a larger page). - - @class NoneLocation - @namespace Ember - @extends Ember.Object - @private - */ - exports.default = _emberRuntime.Object.extend({ - implementation: 'none', - path: '', - - detect: function () { - var rootURL = this.rootURL; - }, - - /** - Will be pre-pended to path. - @private - @property rootURL - @default '/' - */ - rootURL: '/', - - /** - Returns the current path without `rootURL`. - @private - @method getURL - @return {String} path - */ - getURL: function () { - var path = _emberMetal.get(this, 'path'); - var rootURL = _emberMetal.get(this, 'rootURL'); - - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - - // remove rootURL from url - return path.replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - }, - - /** - Set the path and remembers what was set. Using this method - to change the path will not invoke the `updateURL` callback. - @private - @method setURL - @param path {String} - */ - setURL: function (path) { - _emberMetal.set(this, 'path', path); - }, - - /** - Register a callback to be invoked when the path changes. These - callbacks will execute when the user presses the back or forward - button, but not after `setURL` is invoked. - @private - @method onUpdateURL - @param callback {Function} - */ - onUpdateURL: function (callback) { - this.updateCallback = callback; - }, - - /** - Sets the path and calls the `updateURL` callback. - @private - @method handleURL - @param callback {Function} - */ - handleURL: function (url) { - _emberMetal.set(this, 'path', url); - this.updateCallback(url); - }, - - /** - Given a URL, formats it to be placed into the page as part - of an element's `href` attribute. - This is used, for example, when using the {{action}} helper - to generate a URL based on an event. - @private - @method formatURL - @param url {String} - @return {String} url - */ - formatURL: function (url) { - var rootURL = _emberMetal.get(this, 'rootURL'); - - if (url !== '') { - // remove trailing slashes if they exists - rootURL = rootURL.replace(/\/$/, ''); - } - - return rootURL + url; - } - }); -}); -enifed('ember-routing/location/util', ['exports'], function (exports) { - /** - @private - - Returns the current `location.pathname`, normalized for IE inconsistencies. - */ - 'use strict'; - - exports.getPath = getPath; - exports.getQuery = getQuery; - exports.getHash = getHash; - exports.getFullPath = getFullPath; - exports.getOrigin = getOrigin; - exports.supportsHashChange = supportsHashChange; - exports.supportsHistory = supportsHistory; - exports.replacePath = replacePath; - - function getPath(location) { - var pathname = location.pathname; - // Various versions of IE/Opera don't always return a leading slash - if (pathname.charAt(0) !== '/') { - pathname = '/' + pathname; - } - - return pathname; - } - - /** - @private - - Returns the current `location.search`. - */ - - function getQuery(location) { - return location.search; - } - - /** - @private - - Returns the current `location.hash` by parsing location.href since browsers - inconsistently URL-decode `location.hash`. - - Should be passed the browser's `location` object as the first argument. - - https://bugzilla.mozilla.org/show_bug.cgi?id=483304 - */ - - function getHash(location) { - var href = location.href; - var hashIndex = href.indexOf('#'); - - if (hashIndex === -1) { - return ''; - } else { - return href.substr(hashIndex); - } - } - - function getFullPath(location) { - return getPath(location) + getQuery(location) + getHash(location); - } - - function getOrigin(location) { - var origin = location.origin; - - // Older browsers, especially IE, don't have origin - if (!origin) { - origin = location.protocol + '//' + location.hostname; - - if (location.port) { - origin += ':' + location.port; - } - } - - return origin; - } - - /* - `documentMode` only exist in Internet Explorer, and it's tested because IE8 running in - IE7 compatibility mode claims to support `onhashchange` but actually does not. - - `global` is an object that may have an `onhashchange` property. - - @private - @function supportsHashChange - */ - - function supportsHashChange(documentMode, global) { - return 'onhashchange' in global && (documentMode === undefined || documentMode > 7); - } - - /* - `userAgent` is a user agent string. We use user agent testing here, because - the stock Android browser is known to have buggy versions of the History API, - in some Android versions. - - @private - @function supportsHistory - */ - - function supportsHistory(userAgent, history) { - // Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js - // The stock browser on Android 2.2 & 2.3, and 4.0.x returns positive on history support - // Unfortunately support is really buggy and there is no clean way to detect - // these bugs, so we fall back to a user agent sniff :( - - // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies - // itself as 'Mobile Safari' as well, nor Windows Phone. - if ((userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 4.0') !== -1) && userAgent.indexOf('Mobile Safari') !== -1 && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Windows Phone') === -1) { - return false; - } - - return !!(history && 'pushState' in history); - } - - /** - Replaces the current location, making sure we explicitly include the origin - to prevent redirecting to a different origin. - - @private - */ - - function replacePath(location, path) { - location.replace(getOrigin(location) + path); - } -}); -enifed('ember-routing/services/routing', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'ember-routing/utils'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _emberRoutingUtils) { - /** - @module ember - @submodule ember-routing - */ - - 'use strict'; - - /** - The Routing service is used by LinkComponent, and provides facilities for - the component/view layer to interact with the router. - - While still private, this service can eventually be opened up, and provides - the set of API needed for components to control routing without interacting - with router internals. - - @private - @class RoutingService - */ - exports.default = _emberRuntime.Service.extend({ - router: null, - - targetState: _emberRuntime.readOnly('router.targetState'), - currentState: _emberRuntime.readOnly('router.currentState'), - currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), - currentPath: _emberRuntime.readOnly('router.currentPath'), - - availableRoutes: function () { - return Object.keys(_emberMetal.get(this, 'router').router.recognizer.names); - }, - - hasRoute: function (routeName) { - return _emberMetal.get(this, 'router').hasRoute(routeName); - }, - - transitionTo: function (routeName, models, queryParams, shouldReplace) { - var router = _emberMetal.get(this, 'router'); - - var transition = router._doTransition(routeName, models, queryParams); - - if (shouldReplace) { - transition.method('replace'); - } - - return transition; - }, - - normalizeQueryParams: function (routeName, models, queryParams) { - var router = _emberMetal.get(this, 'router'); - router._prepareQueryParams(routeName, models, queryParams); - }, - - generateURL: function (routeName, models, queryParams) { - var router = _emberMetal.get(this, 'router'); - if (!router.router) { - return; - } - - var visibleQueryParams = {}; - _emberUtils.assign(visibleQueryParams, queryParams); - - this.normalizeQueryParams(routeName, models, visibleQueryParams); - - var args = _emberRoutingUtils.routeArgs(routeName, models, visibleQueryParams); - return router.generate.apply(router, args); - }, - - isActiveForRoute: function (contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { - var router = _emberMetal.get(this, 'router'); - - var handlers = router.router.recognizer.handlersFor(routeName); - var leafName = handlers[handlers.length - 1].handler; - var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); - - // NOTE: any ugliness in the calculation of activeness is largely - // due to the fact that we support automatic normalizing of - // `resource` -> `resource.index`, even though there might be - // dynamic segments / query params defined on `resource.index` - // which complicates (and makes somewhat ambiguous) the calculation - // of activeness for links that link to `resource` instead of - // directly to `resource.index`. - - // if we don't have enough contexts revert back to full route name - // this is because the leaf route will use one of the contexts - if (contexts.length > maximumContexts) { - routeName = leafName; - } - - return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified); - } - }); - - function numberOfContextsAcceptedByHandler(handler, handlerInfos) { - var req = 0; - for (var i = 0; i < handlerInfos.length; i++) { - req = req + handlerInfos[i].names.length; - if (handlerInfos[i].handler === handler) { - break; - } - } - - return req; - } -}); -enifed('ember-routing/system/cache', ['exports', 'ember-utils', 'ember-runtime'], function (exports, _emberUtils, _emberRuntime) { - 'use strict'; - - /** - A two-tiered cache with support for fallback values when doing lookups. - Uses "buckets" and then "keys" to cache values. - - @private - @class BucketCache - */ - exports.default = _emberRuntime.Object.extend({ - init: function () { - this.cache = new _emberUtils.EmptyObject(); - }, - - has: function (bucketKey) { - return !!this.cache[bucketKey]; - }, - - stash: function (bucketKey, key, value) { - var bucket = this.cache[bucketKey]; - - if (!bucket) { - bucket = this.cache[bucketKey] = new _emberUtils.EmptyObject(); - } - - bucket[key] = value; - }, - - lookup: function (bucketKey, prop, defaultValue) { - var cache = this.cache; - if (!this.has(bucketKey)) { - return defaultValue; - } - - var bucket = cache[bucketKey]; - if (prop in bucket && bucket[prop] !== undefined) { - return bucket[prop]; - } else { - return defaultValue; - } - } - }); -}); -enifed("ember-routing/system/controller_for", ["exports"], function (exports) { - /** - @module ember - @submodule ember-routing - */ - - /** - Finds a controller instance. - - @for Ember - @method controllerFor - @private - */ - "use strict"; - - exports.default = controllerFor; - - function controllerFor(container, controllerName, lookupOptions) { - return container.lookup("controller:" + controllerName, lookupOptions); - } -}); -enifed('ember-routing/system/dsl', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { - 'use strict'; - - /** - @module ember - @submodule ember-routing - */ - - function DSL(name, options) { - this.parent = name; - this.enableLoadingSubstates = options && options.enableLoadingSubstates; - this.matches = []; - this.explicitIndex = undefined; - this.options = options; - } - - exports.default = DSL; - - DSL.prototype = { - route: function (name, options, callback) { - var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; - if (arguments.length === 2 && typeof options === 'function') { - callback = options; - options = {}; - } - - if (arguments.length === 1) { - options = {}; - } - - if (this.enableLoadingSubstates) { - createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace }); - createRoute(this, name + '_error', { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); - } - - if (callback) { - var fullName = getFullName(this, name, options.resetNamespace); - var dsl = new DSL(fullName, this.options); - - createRoute(dsl, 'loading'); - createRoute(dsl, 'error', { path: dummyErrorRoute }); - - callback.call(dsl); - - createRoute(this, name, options, dsl.generate()); - } else { - createRoute(this, name, options); - } - }, - - push: function (url, name, callback, serialize) { - var parts = name.split('.'); - - if (this.options.engineInfo) { - var localFullName = name.slice(this.options.engineInfo.fullName.length + 1); - var routeInfo = _emberUtils.assign({ localFullName: localFullName }, this.options.engineInfo); - - if (serialize) { - routeInfo.serializeMethod = serialize; - } - - this.options.addRouteForEngine(name, routeInfo); - } else if (serialize) { - throw new Error('Defining a route serializer on route \'' + name + '\' outside an Engine is not allowed.'); - } - - if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { - this.explicitIndex = true; - } - - this.matches.push([url, name, callback]); - }, - - resource: function (name, options, callback) { - if (arguments.length === 2 && typeof options === 'function') { - callback = options; - options = {}; - } - - if (arguments.length === 1) { - options = {}; - } - - options.resetNamespace = true; - - this.route(name, options, callback); - }, - - generate: function () { - var dslMatches = this.matches; - - if (!this.explicitIndex) { - this.route('index', { path: '/' }); - } - - return function (match) { - for (var i = 0; i < dslMatches.length; i++) { - var dslMatch = dslMatches[i]; - match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); - } - }; - } - }; - - function canNest(dsl) { - return dsl.parent && dsl.parent !== 'application'; - } - - function getFullName(dsl, name, resetNamespace) { - if (canNest(dsl) && resetNamespace !== true) { - return dsl.parent + '.' + name; - } else { - return name; - } - } - - function createRoute(dsl, name, options, callback) { - options = options || {}; - - var fullName = getFullName(dsl, name, options.resetNamespace); - - if (typeof options.path !== 'string') { - options.path = '/' + name; - } - - dsl.push(options.path, fullName, callback, options.serialize); - } - - DSL.map = function (callback) { - var dsl = new DSL(); - callback.call(dsl); - return dsl; - }; - - var uuid = 0; - - DSL.prototype.mount = function (_name, _options) { - var options = _options || {}; - var engineRouteMap = this.options.resolveRouteMap(_name); - var name = _name; - - if (options.as) { - name = options.as; - } - - var fullName = getFullName(this, name, options.resetNamespace); - - var engineInfo = { - name: _name, - instanceId: uuid++, - mountPoint: fullName, - fullName: fullName - }; - - var path = options.path; - - if (typeof path !== 'string') { - path = '/' + name; - } - - var callback = undefined; - var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; - if (engineRouteMap) { - var shouldResetEngineInfo = false; - var oldEngineInfo = this.options.engineInfo; - if (oldEngineInfo) { - shouldResetEngineInfo = true; - this.options.engineInfo = engineInfo; - } - - var optionsForChild = _emberUtils.assign({ engineInfo: engineInfo }, this.options); - var childDSL = new DSL(fullName, optionsForChild); - - createRoute(childDSL, 'loading'); - createRoute(childDSL, 'error', { path: dummyErrorRoute }); - - engineRouteMap.call(childDSL); - - callback = childDSL.generate(); - - if (shouldResetEngineInfo) { - this.options.engineInfo = oldEngineInfo; - } - } - - var localFullName = 'application'; - var routeInfo = _emberUtils.assign({ localFullName: localFullName }, engineInfo); - - if (this.enableLoadingSubstates) { - // These values are important to register the loading routes under their - // proper names for the Router and within the Engine's registry. - var substateName = name + '_loading'; - var _localFullName = 'application_loading'; - var _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); - createRoute(this, substateName, { resetNamespace: options.resetNamespace }); - this.options.addRouteForEngine(substateName, _routeInfo); - - substateName = name + '_error'; - _localFullName = 'application_error'; - _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); - createRoute(this, substateName, { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); - this.options.addRouteForEngine(substateName, _routeInfo); - } - - this.options.addRouteForEngine(fullName, routeInfo); - - this.push(path, fullName, callback); - }; -}); -enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - exports.generateControllerFactory = generateControllerFactory; - exports.default = generateController; - - /** - @module ember - @submodule ember-routing - */ - - /** - Generates a controller factory - - @for Ember - @method generateControllerFactory - @private - */ - - function generateControllerFactory(owner, controllerName) { - var Factory = owner._lookupFactory('controller:basic').extend({ - isGenerated: true, - toString: function () { - return '(generated ' + controllerName + ' controller)'; - } - }); - - var fullName = 'controller:' + controllerName; - - owner.register(fullName, Factory); - - return Factory; - } - - /** - Generates and instantiates a controller extending from `controller:basic` - if present, or `Ember.Controller` if not. - - @for Ember - @method generateController - @private - @since 1.3.0 - */ - - function generateController(owner, controllerName) { - generateControllerFactory(owner, controllerName); - - var fullName = 'controller:' + controllerName; - var instance = owner.lookup(fullName); - - if (_emberMetal.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) {} - - return instance; - } -}); -enifed('ember-routing/system/query_params', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { - 'use strict'; - - exports.default = _emberRuntime.Object.extend({ - isQueryParams: true, - values: null - }); -}); -enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-routing/system/generate_controller', 'ember-routing/utils'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberRoutingSystemGenerate_controller, _emberRoutingUtils) { - 'use strict'; - - exports.defaultSerialize = defaultSerialize; - exports.hasDefaultSerialize = hasDefaultSerialize; - var slice = Array.prototype.slice; - - function K() { - return this; - } - - function defaultSerialize(model, params) { - if (params.length < 1) { - return; - } - if (!model) { - return; - } - - var name = params[0]; - var object = {}; - - if (params.length === 1) { - if (name in model) { - object[name] = _emberMetal.get(model, name); - } else if (/_id$/.test(name)) { - object[name] = _emberMetal.get(model, 'id'); - } - } else { - object = _emberMetal.getProperties(model, params); - } - - return object; - } - - var DEFAULT_SERIALIZE = _emberUtils.symbol('DEFAULT_SERIALIZE'); - - defaultSerialize[DEFAULT_SERIALIZE] = true; - - function hasDefaultSerialize(route) { - return !!route.serialize[DEFAULT_SERIALIZE]; - } - - /** - @module ember - @submodule ember-routing - */ - - /** - The `Ember.Route` class is used to define individual routes. Refer to - the [routing guide](http://emberjs.com/guides/routing/) for documentation. - - @class Route - @namespace Ember - @extends Ember.Object - @uses Ember.ActionHandler - @uses Ember.Evented - @since 1.0.0 - @public - */ - var Route = _emberRuntime.Object.extend(_emberRuntime.ActionHandler, _emberRuntime.Evented, { - /** - Configuration hash for this route's queryParams. The possible - configuration options and their defaults are as follows - (assuming a query param whose controller property is `page`): - ```javascript - queryParams: { - page: { - // By default, controller query param properties don't - // cause a full transition when they are changed, but - // rather only cause the URL to update. Setting - // `refreshModel` to true will cause an "in-place" - // transition to occur, whereby the model hooks for - // this route (and any child routes) will re-fire, allowing - // you to reload models (e.g., from the server) using the - // updated query param values. - refreshModel: false, - // By default, changes to controller query param properties - // cause the URL to update via `pushState`, which means an - // item will be added to the browser's history, allowing - // you to use the back button to restore the app to the - // previous state before the query param property was changed. - // Setting `replace` to true will use `replaceState` (or its - // hash location equivalent), which causes no browser history - // item to be added. This options name and default value are - // the same as the `link-to` helper's `replace` option. - replace: false, - // By default, the query param URL key is the same name as - // the controller property name. Use `as` to specify a - // different URL key. - as: 'page' - } - } - ``` - @property queryParams - @for Ember.Route - @type Object - @since 1.6.0 - @public - */ - queryParams: {}, - - /** - The name of the route, dot-delimited. - For example, a route found at `app/routes/posts/post.js` will have - a `routeName` of `posts.post`. - @property routeName - @for Ember.Route - @type String - @since 1.0.0 - @public - */ - - /** - Sets the name for this route, including a fully resolved name for routes - inside engines. - @private - @method _setRouteName - @param {String} name - */ - _setRouteName: function (name) { - this.routeName = name; - this.fullRouteName = getEngineRouteName(_emberUtils.getOwner(this), name); - }, - - /** - Populates the QP meta information in the BucketCache. - @private - @method _populateQPMeta - */ - _populateQPMeta: function () { - this._bucketCache.stash('route-meta', this.fullRouteName, this.get('_qp')); - }, - - /** - @private - @property _qp - */ - _qp: _emberMetal.computed(function () { - var _this = this; - - var controllerProto = undefined, - combinedQueryParameterConfiguration = undefined; - - var controllerName = this.controllerName || this.routeName; - var definedControllerClass = _emberUtils.getOwner(this)._lookupFactory('controller:' + controllerName); - var queryParameterConfiguraton = _emberMetal.get(this, 'queryParams'); - var hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; - - if (definedControllerClass) { - // the developer has authored a controller class in their application for this route - // access the prototype, find its query params and normalize their object shape - // them merge in the query params for the route. As a mergedProperty, Route#queryParams is always - // at least `{}` - controllerProto = definedControllerClass.proto(); - - var controllerDefinedQueryParameterConfiguration = _emberMetal.get(controllerProto, 'queryParams'); - var normalizedControllerQueryParameterConfiguration = _emberRoutingUtils.normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); - combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton); - } else if (hasRouterDefinedQueryParams) { - // the developer has not defined a controller but *has* supplied route query params. - // Generate a class for them so we can later insert default values - var generatedControllerClass = _emberRoutingSystemGenerate_controller.generateControllerFactory(_emberUtils.getOwner(this), controllerName); - controllerProto = generatedControllerClass.proto(); - combinedQueryParameterConfiguration = queryParameterConfiguraton; - } - - var qps = []; - var map = {}; - var propertyNames = []; - - for (var propName in combinedQueryParameterConfiguration) { - if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { - continue; - } - - // to support the dubious feature of using unknownProperty - // on queryParams configuration - if (propName === 'unknownProperty' || propName === '_super') { - // possible todo: issue deprecation warning? - continue; - } - - var desc = combinedQueryParameterConfiguration[propName]; - var scope = desc.scope || 'model'; - var parts = undefined; - - if (scope === 'controller') { - parts = []; - } - - var urlKey = desc.as || this.serializeQueryParamKey(propName); - var defaultValue = _emberMetal.get(controllerProto, propName); - - if (Array.isArray(defaultValue)) { - defaultValue = _emberRuntime.A(defaultValue.slice()); - } - - var type = desc.type || _emberRuntime.typeOf(defaultValue); - - var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); - var scopedPropertyName = controllerName + ':' + propName; - var qp = { - undecoratedDefaultValue: _emberMetal.get(controllerProto, propName), - defaultValue: defaultValue, - serializedDefaultValue: defaultValueSerialized, - serializedValue: defaultValueSerialized, - - type: type, - urlKey: urlKey, - prop: propName, - scopedPropertyName: scopedPropertyName, - controllerName: controllerName, - route: this, - parts: parts, // provided later when stashNames is called if 'model' scope - values: null, // provided later when setup is called. no idea why. - scope: scope - }; - - map[propName] = map[urlKey] = map[scopedPropertyName] = qp; - qps.push(qp); - propertyNames.push(propName); - } - - return { - qps: qps, - map: map, - propertyNames: propertyNames, - states: { - /* - Called when a query parameter changes in the URL, this route cares - about that query parameter, but the route is not currently - in the active route hierarchy. - */ - inactive: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - }, - /* - Called when a query parameter changes in the URL, this route cares - about that query parameter, and the route is currently - in the active route hierarchy. - */ - active: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - return _this._activeQPChanged(map[prop], value); - }, - /* - Called when a value of a query parameter this route handles changes in a controller - and the route is currently in the active route hierarchy. - */ - allowOverrides: function (prop, value) { - var qp = map[prop]; - _this._qpChanged(prop, value, qp); - return _this._updatingQPChanged(map[prop]); - } - } - }; - }), - - /** - @private - @property _names - */ - _names: null, - - /** - @private - @method _stashNames - */ - _stashNames: function (_handlerInfo, dynamicParent) { - var handlerInfo = _handlerInfo; - if (this._names) { - return; - } - var names = this._names = handlerInfo._names; - - if (!names.length) { - handlerInfo = dynamicParent; - names = handlerInfo && handlerInfo._names || []; - } - - var qps = _emberMetal.get(this, '_qp.qps'); - - var namePaths = new Array(names.length); - for (var a = 0; a < names.length; ++a) { - namePaths[a] = handlerInfo.name + '.' + names[a]; - } - - for (var i = 0; i < qps.length; ++i) { - var qp = qps[i]; - if (qp.scope === 'model') { - qp.parts = namePaths; - } - } - }, - - /** - @private - @property _activeQPChanged - */ - _activeQPChanged: function (qp, value) { - var router = this.router; - router._activeQPChanged(qp.scopedPropertyName, value); - }, - - /** - @private - @method _updatingQPChanged - */ - _updatingQPChanged: function (qp) { - var router = this.router; - router._updatingQPChanged(qp.urlKey); - }, - - mergedProperties: ['queryParams'], - - /** - Returns a hash containing the parameters of an ancestor route. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('member', { path: ':name' }, function() { - this.route('interest', { path: ':interest' }); - }); - }); - ``` - ```app/routes/member.js - export default Ember.Route.extend({ - queryParams: { - memberQp: { refreshModel: true } - } - }); - ``` - ```app/routes/member/interest.js - export default Ember.Route.extend({ - queryParams: { - interestQp: { refreshModel: true } - }, - model() { - return this.paramsFor('member'); - } - }); - ``` - If we visit `/turing/maths?memberQp=member&interestQp=interest` the model for - the `member.interest` route is hash with: - * `name`: `turing` - * `memberQp`: `member` - @method paramsFor - @param {String} name - @return {Object} hash containing the parameters of the route `name` - @since 1.4.0 - @public - */ - paramsFor: function (name) { - var route = _emberUtils.getOwner(this).lookup('route:' + name); - - if (!route) { - return {}; - } - - var transition = this.router.router.activeTransition; - var state = transition ? transition.state : this.router.router.state; - - var fullName = route.fullRouteName; - var params = _emberUtils.assign({}, state.params[fullName]); - var queryParams = getQueryParamsFor(route, state); - - return Object.keys(queryParams).reduce(function (params, key) { - params[key] = queryParams[key]; - return params; - }, params); - }, - - /** - Serializes the query parameter key - @method serializeQueryParamKey - @param {String} controllerPropertyName - @private - */ - serializeQueryParamKey: function (controllerPropertyName) { - return controllerPropertyName; - }, - - /** - Serializes value of the query parameter based on defaultValueType - @method serializeQueryParam - @param {Object} value - @param {String} urlKey - @param {String} defaultValueType - @private - */ - serializeQueryParam: function (value, urlKey, defaultValueType) { - // urlKey isn't used here, but anyone overriding - // can use it to provide serialization specific - // to a certain query param. - return this.router._serializeQueryParam(value, defaultValueType); - }, - - /** - Deserializes value of the query parameter based on defaultValueType - @method deserializeQueryParam - @param {Object} value - @param {String} urlKey - @param {String} defaultValueType - @private - */ - deserializeQueryParam: function (value, urlKey, defaultValueType) { - // urlKey isn't used here, but anyone overriding - // can use it to provide deserialization specific - // to a certain query param. - return this.router._deserializeQueryParam(value, defaultValueType); - }, - - /** - @private - @property _optionsForQueryParam - */ - _optionsForQueryParam: function (qp) { - return _emberMetal.get(this, 'queryParams.' + qp.urlKey) || _emberMetal.get(this, 'queryParams.' + qp.prop) || {}; - }, - - /** - A hook you can use to reset controller values either when the model - changes or the route is exiting. - ```app/routes/articles.js - import Ember from 'ember'; - export default Ember.Route.extend({ - resetController(controller, isExiting, transition) { - if (isExiting) { - controller.set('page', 1); - } - } - }); - ``` - @method resetController - @param {Controller} controller instance - @param {Boolean} isExiting - @param {Object} transition - @since 1.7.0 - @public - */ - resetController: K, - - /** - @private - @method exit - */ - exit: function () { - this.deactivate(); - this.trigger('deactivate'); - this.teardownViews(); - }, - - /** - @private - @method _reset - @since 1.7.0 - */ - _reset: function (isExiting, transition) { - var controller = this.controller; - controller._qpDelegate = _emberMetal.get(this, '_qp.states.inactive'); - - this.resetController(controller, isExiting, transition); - }, - - /** - @private - @method enter - */ - enter: function () { - this.connections = []; - this.activate(); - this.trigger('activate'); - }, - - /** - The name of the template to use by default when rendering this routes - template. - ```app/routes/posts/list.js - import Ember from 'ember'; - export default Ember.Route.extend({ - templateName: 'posts/list' - }); - ``` - ```app/routes/posts/index.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - ```app/routes/posts/archived.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - @property templateName - @type String - @default null - @since 1.4.0 - @public - */ - templateName: null, - - /** - The name of the controller to associate with this route. - By default, Ember will lookup a route's controller that matches the name - of the route (i.e. `App.PostController` for `App.PostRoute`). However, - if you would like to define a specific controller to use, you can do so - using this property. - This is useful in many ways, as the controller specified will be: - * passed to the `setupController` method. - * used as the controller for the template being rendered by the route. - * returned from a call to `controllerFor` for the route. - @property controllerName - @type String - @default null - @since 1.4.0 - @public - */ - controllerName: null, - - /** - The `willTransition` action is fired at the beginning of any - attempted transition with a `Transition` object as the sole - argument. This action can be used for aborting, redirecting, - or decorating the transition from the currently active routes. - A good example is preventing navigation when a form is - half-filled out: - ```app/routes/contact-form.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - willTransition(transition) { - if (this.controller.get('userHasEnteredData')) { - this.controller.displayNavigationConfirm(); - transition.abort(); - } - } - } - }); - ``` - You can also redirect elsewhere by calling - `this.transitionTo('elsewhere')` from within `willTransition`. - Note that `willTransition` will not be fired for the - redirecting `transitionTo`, since `willTransition` doesn't - fire when there is already a transition underway. If you want - subsequent `willTransition` actions to fire for the redirecting - transition, you must first explicitly call - `transition.abort()`. - To allow the `willTransition` event to continue bubbling to the parent - route, use `return true;`. When the `willTransition` method has a - return value of `true` then the parent route's `willTransition` method - will be fired, enabling "bubbling" behavior for the event. - @event willTransition - @param {Transition} transition - @since 1.0.0 - @public - */ - - /** - The `didTransition` action is fired after a transition has - successfully been completed. This occurs after the normal model - hooks (`beforeModel`, `model`, `afterModel`, `setupController`) - have resolved. The `didTransition` action has no arguments, - however, it can be useful for tracking page views or resetting - state on the controller. - ```app/routes/login.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - didTransition() { - this.controller.get('errors.base').clear(); - return true; // Bubble the didTransition event - } - } - }); - ``` - @event didTransition - @since 1.2.0 - @public - */ - - /** - The `loading` action is fired on the route when a route's `model` - hook returns a promise that is not already resolved. The current - `Transition` object is the first parameter and the route that - triggered the loading event is the second parameter. - ```app/routes/application.js - export default Ember.Route.extend({ - actions: { - loading(transition, route) { - let controller = this.controllerFor('foo'); - controller.set('currentlyLoading', true); - transition.finally(function() { - controller.set('currentlyLoading', false); - }); - } - } - }); - ``` - @event loading - @param {Transition} transition - @param {Ember.Route} route The route that triggered the loading event - @since 1.2.0 - @public - */ - - /** - When attempting to transition into a route, any of the hooks - may return a promise that rejects, at which point an `error` - action will be fired on the partially-entered routes, allowing - for per-route error handling logic, or shared error handling - logic defined on a parent route. - Here is an example of an error handler that will be invoked - for rejected promises from the various hooks on the route, - as well as any unhandled errors from child routes: - ```app/routes/admin.js - import Ember from 'ember'; - export default Ember.Route.extend({ - beforeModel() { - return Ember.RSVP.reject('bad things!'); - }, - actions: { - error(error, transition) { - // Assuming we got here due to the error in `beforeModel`, - // we can expect that error === "bad things!", - // but a promise model rejecting would also - // call this hook, as would any errors encountered - // in `afterModel`. - // The `error` hook is also provided the failed - // `transition`, which can be stored and later - // `.retry()`d if desired. - this.transitionTo('login'); - } - } - }); - ``` - `error` actions that bubble up all the way to `ApplicationRoute` - will fire a default error handler that logs the error. You can - specify your own global default error handler by overriding the - `error` handler on `ApplicationRoute`: - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - error(error, transition) { - this.controllerFor('banner').displayError(error.message); - } - } - }); - ``` - @event error - @param {Error} error - @param {Transition} transition - @since 1.0.0 - @public - */ - - /** - This event is triggered when the router enters the route. It is - not executed when the model for the route changes. - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - collectAnalytics: Ember.on('activate', function(){ - collectAnalytics(); - }) - }); - ``` - @event activate - @since 1.9.0 - @public - */ - - /** - This event is triggered when the router completely exits this - route. It is not executed when the model for the route changes. - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - trackPageLeaveAnalytics: Ember.on('deactivate', function(){ - trackPageLeaveAnalytics(); - }) - }); - ``` - @event deactivate - @since 1.9.0 - @public - */ - - /** - The controller associated with this route. - Example - ```app/routes/form.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - willTransition(transition) { - if (this.controller.get('userHasEnteredData') && - !confirm('Are you sure you want to abandon progress?')) { - transition.abort(); - } else { - // Bubble the `willTransition` action so that - // parent routes can decide whether or not to abort. - return true; - } - } - } - }); - ``` - @property controller - @type Ember.Controller - @since 1.6.0 - @public - */ - - actions: { - - /** - This action is called when one or more query params have changed. Bubbles. - @method queryParamsDidChange - @param changed {Object} Keys are names of query params that have changed. - @param totalPresent {Object} Keys are names of query params that are currently set. - @param removed {Object} Keys are names of query params that have been removed. - @returns {boolean} - @private - */ - queryParamsDidChange: function (changed, totalPresent, removed) { - var qpMap = _emberMetal.get(this, '_qp').map; - - var totalChanged = Object.keys(changed).concat(Object.keys(removed)); - for (var i = 0; i < totalChanged.length; ++i) { - var qp = qpMap[totalChanged[i]]; - if (qp && _emberMetal.get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) { - this.refresh(); - } - } - - return true; - }, - - finalizeQueryParamChange: function (params, finalParams, transition) { - if (this.fullRouteName !== 'application') { - return true; - } - - // Transition object is absent for intermediate transitions. - if (!transition) { - return; - } - - var handlerInfos = transition.state.handlerInfos; - var router = this.router; - var qpMeta = router._queryParamsFor(handlerInfos); - var changes = router._qpUpdates; - var replaceUrl = undefined; - - _emberRoutingUtils.stashParamNames(router, handlerInfos); - - for (var i = 0; i < qpMeta.qps.length; ++i) { - var qp = qpMeta.qps[i]; - var route = qp.route; - var controller = route.controller; - var presentKey = qp.urlKey in params && qp.urlKey; - - // Do a reverse lookup to see if the changed query - // param URL key corresponds to a QP property on - // this controller. - var value = undefined, - svalue = undefined; - if (changes && qp.urlKey in changes) { - // Value updated in/before setupController - value = _emberMetal.get(controller, qp.prop); - svalue = route.serializeQueryParam(value, qp.urlKey, qp.type); - } else { - if (presentKey) { - svalue = params[presentKey]; - value = route.deserializeQueryParam(svalue, qp.urlKey, qp.type); - } else { - // No QP provided; use default value. - svalue = qp.serializedDefaultValue; - value = copyDefaultValue(qp.defaultValue); - } - } - - controller._qpDelegate = _emberMetal.get(route, '_qp.states.inactive'); - - var thisQueryParamChanged = svalue !== qp.serializedValue; - if (thisQueryParamChanged) { - if (transition.queryParamsOnly && replaceUrl !== false) { - var options = route._optionsForQueryParam(qp); - var replaceConfigValue = _emberMetal.get(options, 'replace'); - if (replaceConfigValue) { - replaceUrl = true; - } else if (replaceConfigValue === false) { - // Explicit pushState wins over any other replaceStates. - replaceUrl = false; - } - } - - _emberMetal.set(controller, qp.prop, value); - } - - // Stash current serialized value of controller. - qp.serializedValue = svalue; - - var thisQueryParamHasDefaultValue = qp.serializedDefaultValue === svalue; - if (!thisQueryParamHasDefaultValue) { - finalParams.push({ - value: svalue, - visible: true, - key: presentKey || qp.urlKey - }); - } - } - - if (replaceUrl) { - transition.method('replace'); - } - - qpMeta.qps.forEach(function (qp) { - var routeQpMeta = _emberMetal.get(qp.route, '_qp'); - var finalizedController = qp.route.controller; - finalizedController._qpDelegate = _emberMetal.get(routeQpMeta, 'states.active'); - }); - - router._qpUpdates = null; - } - }, - - /** - This hook is executed when the router completely exits this route. It is - not executed when the model for the route changes. - @method deactivate - @since 1.0.0 - @public - */ - deactivate: K, - - /** - This hook is executed when the router enters the route. It is not executed - when the model for the route changes. - @method activate - @since 1.0.0 - @public - */ - activate: K, - - /** - Transition the application into another route. The route may - be either a single route or route path: - ```javascript - this.transitionTo('blogPosts'); - this.transitionTo('blogPosts.recentEntries'); - ``` - Optionally supply a model for the route in question. The model - will be serialized into the URL using the `serialize` hook of - the route: - ```javascript - this.transitionTo('blogPost', aPost); - ``` - If a literal is passed (such as a number or a string), it will - be treated as an identifier instead. In this case, the `model` - hook of the route will be triggered: - ```javascript - this.transitionTo('blogPost', 1); - ``` - Multiple models will be applied last to first recursively up the - route tree. - ```app/routes.js - // ... - Router.map(function() { - this.route('blogPost', { path:':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId' }); - }); - }); - export default Router; - ``` - ```javascript - this.transitionTo('blogComment', aPost, aComment); - this.transitionTo('blogComment', 1, 13); - ``` - It is also possible to pass a URL (a string that starts with a - `/`). This is intended for testing and debugging purposes and - should rarely be used in production code. - ```javascript - this.transitionTo('/'); - this.transitionTo('/blog/post/1/comment/13'); - this.transitionTo('/blog/posts?sort=title'); - ``` - An options hash with a `queryParams` property may be provided as - the final argument to add query parameters to the destination URL. - ```javascript - this.transitionTo('blogPost', 1, { - queryParams: { showComments: 'true' } - }); - // if you just want to transition the query parameters without changing the route - this.transitionTo({ queryParams: { sort: 'date' } }); - ``` - See also [replaceWith](#method_replaceWith). - Simple Transition Example - ```app/routes.js - // ... - Router.map(function() { - this.route('index'); - this.route('secret'); - this.route('fourOhFour', { path: '*:' }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember': - export Ember.Route.extend({ - actions: { - moveToSecret(context) { - if (authorized()) { - this.transitionTo('secret', context); - } else { - this.transitionTo('fourOhFour'); - } - } - } - }); - ``` - Transition to a nested route - ```app/router.js - // ... - Router.map(function() { - this.route('articles', { path: '/articles' }, function() { - this.route('new'); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - transitionToNewArticle() { - this.transitionTo('articles.new'); - } - } - }); - ``` - Multiple Models Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('breakfast', { path: ':breakfastId' }, function() { - this.route('cereal', { path: ':cerealId' }); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - moveToChocolateCereal() { - let cereal = { cerealId: 'ChocolateYumminess' }; - let breakfast = { breakfastId: 'CerealAndMilk' }; - this.transitionTo('breakfast.cereal', breakfast, cereal); - } - } - }); - ``` - Nested Route with Query String Example - ```app/routes.js - // ... - Router.map(function() { - this.route('fruits', function() { - this.route('apples'); - }); - }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - transitionToApples() { - this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); - } - } - }); - ``` - @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 - @since 1.0.0 - @public - */ - transitionTo: function (name, context) { - var router = this.router; - return router.transitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, - - /** - Perform a synchronous transition into another route without attempting - to resolve promises, update the URL, or abort any currently active - asynchronous transitions (i.e. regular transitions caused by - `transitionTo` or URL changes). - This method is handy for performing intermediate transitions on the - way to a final destination route, and is called internally by the - default implementations of the `error` and `loading` handlers. - @method intermediateTransitionTo - @param {String} name the name of the route - @param {...Object} models the model(s) to be used while transitioning - to the route. - @since 1.2.0 - @public - */ - intermediateTransitionTo: function () { - var router = this.router; - router.intermediateTransitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, - - /** - Refresh the model on this route and any child routes, firing the - `beforeModel`, `model`, and `afterModel` hooks in a similar fashion - to how routes are entered when transitioning in from other route. - The current route params (e.g. `article_id`) will be passed in - to the respective model hooks, and if a different model is returned, - `setupController` and associated route hooks will re-fire as well. - An example usage of this method is re-querying the server for the - latest information using the same parameters as when the route - was first entered. - Note that this will cause `model` hooks to fire even on routes - that were provided a model object when the route was initially - entered. - @method refresh - @return {Transition} the transition object associated with this - attempted transition - @since 1.4.0 - @public - */ - refresh: function () { - return this.router.router.refresh(this); - }, - - /** - Transition into another route while replacing the current URL, if possible. - This will replace the current history entry instead of adding a new one. - Beside that, it is identical to `transitionTo` in all other respects. See - 'transitionTo' for additional information regarding multiple models. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('secret'); - }); - export default Router; - ``` - ```app/routes/secret.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { - if (!authorized()){ - this.replaceWith('index'); - } - } - }); - ``` - @method replaceWith - @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. - @return {Transition} the transition object associated with this - attempted transition - @since 1.0.0 - @public - */ - replaceWith: function () { - var router = this.router; - return router.replaceWith.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); - }, - - /** - Sends an action to the router, which will delegate it to the currently - active route hierarchy per the bubbling rules explained under `actions`. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - }); - export default Router; - ``` - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - track(arg) { - console.log(arg, 'was clicked'); - } - } - }); - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - actions: { - trackIfDebug(arg) { - if (debug) { - this.send('track', arg); - } - } - } - }); - ``` - @method send - @param {String} name the name of the action to trigger - @param {...*} args - @since 1.0.0 - @public - */ - send: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - if (this.router && this.router.router || !_emberMetal.isTesting()) { - var _router; - - (_router = this.router).send.apply(_router, args); - } else { - var _name2 = args[0]; - args = slice.call(args, 1); - var action = this.actions[_name2]; - if (action) { - return this.actions[_name2].apply(this, args); - } - } - }, - - /** - This hook is the entry point for router.js - @private - @method setup - */ - setup: function (context, transition) { - var _this2 = this; - - var controller = undefined; - - var controllerName = this.controllerName || this.routeName; - var definedController = this.controllerFor(controllerName, true); - - if (!definedController) { - controller = this.generateController(controllerName); - } else { - controller = definedController; - } - - // Assign the route's controller so that it can more easily be - // referenced in action handlers. Side effects. Side effects everywhere. - if (!this.controller) { - var propNames = _emberMetal.get(this, '_qp.propertyNames'); - addQueryParamsObservers(controller, propNames); - this.controller = controller; - } - - var queryParams = _emberMetal.get(this, '_qp'); - - var states = queryParams.states; - - controller._qpDelegate = states.allowOverrides; - - if (transition) { - (function () { - // Update the model dep values used to calculate cache keys. - _emberRoutingUtils.stashParamNames(_this2.router, transition.state.handlerInfos); - - var params = transition.params; - var allParams = queryParams.propertyNames; - var cache = _this2._bucketCache; - - allParams.forEach(function (prop) { - var aQp = queryParams.map[prop]; - - aQp.values = params; - var cacheKey = _emberRoutingUtils.calculateCacheKey(aQp.controllerName, aQp.parts, aQp.values); - - if (cache) { - var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); - _emberMetal.set(controller, prop, value); - } - }); - })(); - } - - if (transition) { - var qpValues = getQueryParamsFor(this, transition.state); - controller.setProperties(qpValues); - } - - this.setupController(controller, context, transition); - - if (this._environment.options.shouldRender) { - this.renderTemplate(controller, context); - } - }, - - /* - Called when a query parameter for this route changes, regardless of whether the route - is currently part of the active route hierarchy. This will update the query parameter's - value in the cache so if this route becomes active, the cache value has been updated. - */ - _qpChanged: function (prop, value, qp) { - if (!qp) { - return; - } - - var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.controllerName, qp.parts, qp.values); - - // Update model-dep cache - var cache = this._bucketCache; - if (cache) { - cache.stash(cacheKey, prop, value); - } - }, - - /** - This hook is the first of the route entry validation hooks - called when an attempt is made to transition into a route - or one of its children. It is called before `model` and - `afterModel`, and is appropriate for cases when: - 1) A decision can be made to redirect elsewhere without - needing to resolve the model first. - 2) Any async operations need to occur first before the - model is attempted to be resolved. - This hook is provided the current `transition` attempt - as a parameter, which can be used to `.abort()` the transition, - save it for a later `.retry()`, or retrieve values set - on it from a previous hook. You can also just call - `this.transitionTo` to another route to implicitly - abort the `transition`. - You can return a promise from this hook to pause the - transition until the promise resolves (or rejects). This could - be useful, for instance, for retrieving async code from - the server that is required to enter a route. - @method beforeModel - @param {Transition} transition - @return {Promise} if the value returned from this hook is - a promise, the transition will pause until the transition - resolves. Otherwise, non-promise return values are not - utilized in any way. - @since 1.0.0 - @public - */ - beforeModel: K, - - /** - This hook is called after this route's model has resolved. - It follows identical async/promise semantics to `beforeModel` - but is provided the route's resolved model in addition to - the `transition`, and is therefore suited to performing - logic that can only take place after the model has already - resolved. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel(posts, transition) { - if (posts.get('length') === 1) { - this.transitionTo('post.show', posts.get('firstObject')); - } - } - }); - ``` - Refer to documentation for `beforeModel` for a description - of transition-pausing semantics when a promise is returned - from this hook. - @method afterModel - @param {Object} resolvedModel the value returned from `model`, - or its resolved value if it was a promise - @param {Transition} transition - @return {Promise} if the value returned from this hook is - a promise, the transition will pause until the transition - resolves. Otherwise, non-promise return values are not - utilized in any way. - @since 1.0.0 - @public - */ - afterModel: K, - - /** - A hook you can implement to optionally redirect to another route. - If you call `this.transitionTo` from inside of this hook, this route - will not be entered in favor of the other hook. - `redirect` and `afterModel` behave very similarly and are - called almost at the same time, but they have an important - distinction in the case that, from one of these hooks, a - redirect into a child route of this route occurs: redirects - from `afterModel` essentially invalidate the current attempt - to enter this route, and will result in this route's `beforeModel`, - `model`, and `afterModel` hooks being fired again within - the new, redirecting transition. Redirects that occur within - the `redirect` hook, on the other hand, will _not_ cause - these hooks to be fired again the second time around; in - other words, by the time the `redirect` hook has been called, - both the resolved model and attempted entry into this route - are considered to be fully validated. - @method redirect - @param {Object} model the model for this route - @param {Transition} transition the transition object associated with the current transition - @since 1.0.0 - @public - */ - redirect: K, - - /** - Called when the context is changed by router.js. - @private - @method contextDidChange - */ - contextDidChange: function () { - this.currentModel = this.context; - }, - - /** - A hook you can implement to convert the URL into the model for - this route. - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - The model for the `post` route is `store.findRecord('post', params.post_id)`. - By default, if your route has a dynamic segment ending in `_id`: - * The model class is determined from the segment (`post_id`'s - class is `App.Post`) - * The find method is called on the model class with the value of - the dynamic segment. - Note that for routes with dynamic segments, this hook is not always - executed. If the route is entered through a transition (e.g. when - using the `link-to` Handlebars helper or the `transitionTo` method - of routes), and a model context is already provided this hook - is not called. - A model context does not include a primitive string or number, - which does cause the model hook to be called. - Routes without dynamic segments will always execute the model hook. - ```javascript - // no dynamic segment, model hook always called - this.transitionTo('posts'); - // model passed in, so model hook not called - thePost = store.findRecord('post', 1); - this.transitionTo('post', thePost); - // integer passed in, model hook is called - this.transitionTo('post', 1); - // model id passed in, model hook is called - // useful for forcing the hook to execute - thePost = store.findRecord('post', 1); - this.transitionTo('post', thePost.id); - ``` - This hook follows the asynchronous/promise semantics - described in the documentation for `beforeModel`. In particular, - if a promise returned from `model` fails, the error will be - handled by the `error` hook on `Ember.Route`. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { - return this.store.findRecord('post', params.post_id); - } - }); - ``` - @method model - @param {Object} params the parameters extracted from the URL - @param {Transition} transition - @return {Object|Promise} the model for this route. If - a promise is returned, the transition will pause until - the promise resolves, and the resolved value of the promise - will be used as the model for this route. - @since 1.0.0 - @public - */ - model: function (params, transition) { - var name = undefined, - sawParams = undefined, - value = undefined; - var queryParams = _emberMetal.get(this, '_qp.map'); - - for (var prop in params) { - if (prop === 'queryParams' || queryParams && prop in queryParams) { - continue; - } - - var match = prop.match(/^(.*)_id$/); - if (match) { - name = match[1]; - value = params[prop]; - } - sawParams = true; - } - - if (!name && sawParams) { - return _emberRuntime.copy(params); - } else if (!name) { - if (transition.resolveIndex < 1) { - return; - } - - var parentModel = transition.state.handlerInfos[transition.resolveIndex - 1].context; - - return parentModel; - } - - return this.findModel(name, value); - }, - - /** - @private - @method deserialize - @param {Object} params the parameters extracted from the URL - @param {Transition} transition - @return {Object|Promise} the model for this route. - Router.js hook. - */ - deserialize: function (params, transition) { - return this.model(this.paramsFor(this.routeName), transition); - }, - - /** - @method findModel - @param {String} type the model type - @param {Object} value the value passed to find - @private - */ - findModel: function () { - var store = _emberMetal.get(this, 'store'); - return store.find.apply(store, arguments); - }, - - /** - Store property provides a hook for data persistence libraries to inject themselves. - By default, this store property provides the exact same functionality previously - in the model hook. - Currently, the required interface is: - `store.find(modelName, findArguments)` - @method store - @param {Object} store - @private - */ - store: _emberMetal.computed(function () { - var owner = _emberUtils.getOwner(this); - var routeName = this.routeName; - var namespace = _emberMetal.get(this, 'router.namespace'); - - return { - find: function (name, value) { - var modelClass = owner._lookupFactory('model:' + name); - - if (!modelClass) { - return; - } - - return modelClass.find(value); - } - }; - }), - - /** - A hook you can implement to convert the route's model into parameters - for the URL. - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { - // the server returns `{ id: 12 }` - return Ember.$.getJSON('/posts/' + params.post_id); - }, - serialize(model) { - // this will make the URL `/posts/12` - return { post_id: model.id }; - } - }); - ``` - The default `serialize` method will insert the model's `id` into the - route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'. - If the route has multiple dynamic segments or does not contain '_id', `serialize` - will return `Ember.getProperties(model, params)` - This method is called when `transitionTo` is called with a context - in order to populate the URL. - @method serialize - @param {Object} model the routes model - @param {Array} params an Array of parameter names for the current - route (in the example, `['post_id']`. - @return {Object} the serialized parameters - @since 1.0.0 - @public - */ - serialize: defaultSerialize, - - /** - A hook you can use to setup the controller for the current route. - This method is called with the controller for the current route and the - model supplied by the `model` hook. - By default, the `setupController` hook sets the `model` property of - the controller to the `model`. - If you implement the `setupController` hook in your Route, it will - prevent this default behavior. If you want to preserve that behavior - when implementing your `setupController` function, make sure to call - `_super`: - ```app/routes/photos.js - import Ember from 'ebmer'; - export default Ember.Route.extend({ - model() { - return this.store.findAll('photo'); - }, - setupController(controller, model) { - // Call _super for default behavior - this._super(controller, model); - // Implement your custom setup after - this.controllerFor('application').set('showingPhotos', true); - } - }); - ``` - The provided controller will be one resolved based on the name - of this route. - If no explicit controller is defined, Ember will automatically create one. - As an example, consider the router: - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - For the `post` route, a controller named `App.PostController` would - be used if it is defined. If it is not defined, a basic `Ember.Controller` - instance would be used. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, model) { - controller.set('model', model); - } - }); - ``` - @method setupController - @param {Controller} controller instance - @param {Object} model - @since 1.0.0 - @public - */ - setupController: function (controller, context, transition) { - if (controller && context !== undefined) { - _emberMetal.set(controller, 'model', context); - } - }, - - /** - Returns the resolved model of the current route, or a parent (or any ancestor) - route in a route hierarchy. - The controller instance must already have been created, either through entering the - associated route or using `generateController`. - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { - this._super(controller, post); - this.controllerFor('posts').set('currentPost', post); - } - }); - ``` - @method controllerFor - @param {String} name the name of the route or controller - @return {Ember.Controller} - @since 1.0.0 - @public - */ - controllerFor: function (name, _skipAssert) { - var owner = _emberUtils.getOwner(this); - var route = owner.lookup('route:' + name); - var controller = undefined; - - if (route && route.controllerName) { - name = route.controllerName; - } - - controller = owner.lookup('controller:' + name); - - // NOTE: We're specifically checking that skipAssert is true, because according - // to the old API the second parameter was model. We do not want people who - // passed a model to skip the assertion. - - return controller; - }, - - /** - Generates a controller for a route. - Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { - this._super(controller, post); - this.generateController('posts'); - } - }); - ``` - @method generateController - @param {String} name the name of the controller - @private - */ - generateController: function (name) { - var owner = _emberUtils.getOwner(this); - - return _emberRoutingSystemGenerate_controller.default(owner, name); - }, - - /** - Returns the resolved model of a parent (or any ancestor) route - in a route hierarchy. During a transition, all routes - must resolve a model object, and if a route - needs access to a parent route's model in order to - resolve a model (or just reuse the model from a parent), - it can call `this.modelFor(theNameOfParentRoute)` to - retrieve it. If the ancestor route's model was a promise, - its resolved result is returned. - Example - ```app/router.js - // ... - Router.map(function() { - this.route('post', { path: '/post/:post_id' }, function() { - this.route('comments', { resetNamespace: true }); - }); - }); - export default Router; - ``` - ```app/routes/comments.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { - this.set('post', this.modelFor('post')); - } - }); - ``` - @method modelFor - @param {String} name the name of the route - @return {Object} the model object - @since 1.0.0 - @public - */ - modelFor: function (_name) { - var name = undefined; - var owner = _emberUtils.getOwner(this); - - // Only change the route name when there is an active transition. - // Otherwise, use the passed in route name. - if (owner.routable && this.router && this.router.router.activeTransition) { - name = getEngineRouteName(owner, _name); - } else { - name = _name; - } - - var route = _emberUtils.getOwner(this).lookup('route:' + name); - var transition = this.router ? this.router.router.activeTransition : null; - - // If we are mid-transition, we want to try and look up - // resolved parent contexts on the current transitionEvent. - if (transition) { - var modelLookupName = route && route.routeName || name; - if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { - return transition.resolvedModels[modelLookupName]; - } - } - - return route && route.currentModel; - }, - - /** - A hook you can use to render the template for the current route. - This method is called with the controller for the current route and the - model supplied by the `model` hook. By default, it renders the route's - template, configured with the controller for the route. - This method can be overridden to set up and render additional or - alternative templates. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model) { - let favController = this.controllerFor('favoritePost'); - // Render the `favoritePost` template into - // the outlet `posts`, and display the `favoritePost` - // controller. - this.render('favoritePost', { - outlet: 'posts', - controller: favController - }); - } - }); - ``` - @method renderTemplate - @param {Object} controller the route's controller - @param {Object} model the route's model - @since 1.0.0 - @public - */ - renderTemplate: function (controller, model) { - this.render(); - }, - - /** - `render` is used to render a template into a region of another template - (indicated by an `{{outlet}}`). `render` is used both during the entry - phase of routing (via the `renderTemplate` hook) and later in response to - user interaction. - For example, given the following minimal router and templates: - ```app/router.js - // ... - Router.map(function() { - this.route('photos'); - }); - export default Router; - ``` - ```handlebars - -
    - {{outlet "anOutletName"}} -
    - ``` - ```handlebars - -

    Photos

    - ``` - You can render `photos.hbs` into the `"anOutletName"` outlet of - `application.hbs` by calling `render`: - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { - this.render('photos', { - into: 'application', - outlet: 'anOutletName' - }) - } - }); - ``` - `render` additionally allows you to supply which `controller` and - `model` objects should be loaded and associated with the rendered template. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model){ - this.render('posts', { // the template to render, referenced by name - into: 'application', // the template to render into, referenced by name - outlet: 'anOutletName', // the outlet inside `options.template` to render into. - controller: 'someControllerName', // the controller to use for this template, referenced by name - model: model // the model to set on `options.controller`. - }) - } - }); - ``` - The string values provided for the template name, and controller - will eventually pass through to the resolver for lookup. See - Ember.Resolver for how these are mapped to JavaScript objects in your - application. The template to render into needs to be related to either the - current route or one of its ancestors. - Not all options need to be passed to `render`. Default values will be used - based on the name of the route specified in the router or the Route's - `controllerName` and `templateName` properties. - For example: - ```app/router.js - // ... - Router.map(function() { - this.route('index'); - this.route('post', { path: '/posts/:post_id' }); - }); - export default Router; - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { - this.render(); // all defaults apply - } - }); - ``` - The name of the route, defined by the router, is `post`. - The following equivalent default options will be applied when - the Route calls `render`: - ```javascript - this.render('post', { // the template name associated with 'post' Route - into: 'application', // the parent route to 'post' Route - outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, - controller: 'post', // the controller associated with the 'post' Route - }) - ``` - By default the controller's `model` will be the route's model, so it does not - need to be passed unless you wish to change which model is being used. - @method render - @param {String} name the name of the template to render - @param {Object} [options] the options - @param {String} [options.into] the template to render into, - referenced by name. Defaults to the parent template - @param {String} [options.outlet] the outlet inside `options.template` to render into. - Defaults to 'main' - @param {String|Object} [options.controller] the controller to use for this template, - referenced by name or as a controller instance. Defaults to the Route's paired controller - @param {Object} [options.model] the model object to set on `options.controller`. - Defaults to the return value of the Route's model hook - @since 1.0.0 - @public - */ - render: function (_name, options) { - - var namePassed = typeof _name === 'string' && !!_name; - var isDefaultRender = arguments.length === 0 || _emberMetal.isEmpty(arguments[0]); - var name = undefined; - - if (typeof _name === 'object' && !options) { - name = this.templateName || this.routeName; - options = _name; - } else { - name = _name; - } - - var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); - this.connections.push(renderOptions); - _emberMetal.run.once(this.router, '_setOutlets'); - }, - - /** - Disconnects a view that has been rendered into an outlet. - You may pass any or all of the following options to `disconnectOutlet`: - * `outlet`: the name of the outlet to clear (default: 'main') - * `parentView`: the name of the view containing the outlet to clear - (default: the view rendered by the parent route) - Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - this.render(evt.modalName, { - outlet: 'modal', - into: 'application' - }); - }, - hideModal(evt) { - this.disconnectOutlet({ - outlet: 'modal', - parentView: 'application' - }); - } - } - }); - ``` - Alternatively, you can pass the `outlet` name directly as a string. - Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - // ... - }, - hideModal(evt) { - this.disconnectOutlet('modal'); - } - } - }); - @method disconnectOutlet - @param {Object|String} options the options hash or outlet name - @since 1.0.0 - @public - */ - disconnectOutlet: function (options) { - var outletName = undefined; - var parentView = undefined; - if (!options || typeof options === 'string') { - outletName = options; - } else { - outletName = options.outlet; - parentView = options.parentView; - - if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { - throw new _emberMetal.Error('You passed undefined as the outlet name.'); - } - } - parentView = parentView && parentView.replace(/\//g, '.'); - outletName = outletName || 'main'; - this._disconnectOutlet(outletName, parentView); - for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { - // This non-local state munging is sadly necessary to maintain - // backward compatibility with our existing semantics, which allow - // any route to disconnectOutlet things originally rendered by any - // other route. This should all get cut in 2.0. - this.router.router.currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); - } - }, - - _disconnectOutlet: function (outletName, parentView) { - var parent = parentRoute(this); - if (parent && parentView === parent.routeName) { - parentView = undefined; - } - for (var i = 0; i < this.connections.length; i++) { - var connection = this.connections[i]; - if (connection.outlet === outletName && connection.into === parentView) { - // This neuters the disconnected outlet such that it doesn't - // render anything, but it leaves an entry in the outlet - // hierarchy so that any existing other renders that target it - // don't suddenly blow up. They will still stick themselves - // into its outlets, which won't render anywhere. All of this - // statefulness should get the machete in 2.0. - this.connections[i] = { - owner: connection.owner, - into: connection.into, - outlet: connection.outlet, - name: connection.name, - controller: undefined, - template: undefined, - ViewClass: undefined - }; - _emberMetal.run.once(this.router, '_setOutlets'); - } - } - }, - - willDestroy: function () { - this.teardownViews(); - }, - - /** - @private - @method teardownViews - */ - teardownViews: function () { - if (this.connections && this.connections.length > 0) { - this.connections = []; - _emberMetal.run.once(this.router, '_setOutlets'); - } - } - }); - - _emberRuntime.deprecateUnderscoreActions(Route); - - Route.reopenClass({ - isRouteFactory: true - }); - - function parentRoute(route) { - var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); - return handlerInfo && handlerInfo.handler; - } - - function handlerInfoFor(route, handlerInfos, _offset) { - if (!handlerInfos) { - return; - } - - var offset = _offset || 0; - var current = undefined; - for (var i = 0; i < handlerInfos.length; i++) { - current = handlerInfos[i].handler; - if (current === route) { - return handlerInfos[i + offset]; - } - } - } - - function buildRenderOptions(route, namePassed, isDefaultRender, _name, options) { - var into = options && options.into && options.into.replace(/\//g, '.'); - var outlet = options && options.outlet || 'main'; - - var name = undefined, - templateName = undefined; - if (_name) { - name = _name.replace(/\//g, '.'); - templateName = name; - } else { - name = route.routeName; - templateName = route.templateName || name; - } - - var owner = _emberUtils.getOwner(route); - var controller = options && options.controller; - if (!controller) { - if (namePassed) { - controller = owner.lookup('controller:' + name) || route.controllerName || route.routeName; - } else { - controller = route.controllerName || owner.lookup('controller:' + name); - } - } - - if (typeof controller === 'string') { - var controllerName = controller; - controller = owner.lookup('controller:' + controllerName); - if (!controller) { - throw new _emberMetal.Error('You passed `controller: \'' + controllerName + '\'` into the `render` method, but no such controller could be found.'); - } - } - - if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { - throw new _emberMetal.Error('You passed undefined as the outlet name.'); - } - - if (options && options.model) { - controller.set('model', options.model); - } - - var template = owner.lookup('template:' + templateName); - - var parent = undefined; - if (into && (parent = parentRoute(route)) && into === parent.routeName) { - into = undefined; - } - - var renderOptions = { - owner: owner, - into: into, - outlet: outlet, - name: name, - controller: controller, - template: template || route._topLevelViewTemplate, - ViewClass: undefined - }; - - var LOG_VIEW_LOOKUPS = _emberMetal.get(route.router, 'namespace.LOG_VIEW_LOOKUPS'); - if (LOG_VIEW_LOOKUPS && !template) {} - - return renderOptions; - } - - function getFullQueryParams(router, state) { - if (state.fullQueryParams) { - return state.fullQueryParams; - } - - state.fullQueryParams = {}; - _emberUtils.assign(state.fullQueryParams, state.queryParams); - - router._deserializeQueryParams(state.handlerInfos, state.fullQueryParams); - return state.fullQueryParams; - } - - function getQueryParamsFor(route, state) { - state.queryParamsFor = state.queryParamsFor || {}; - var name = route.fullRouteName; - - if (state.queryParamsFor[name]) { - return state.queryParamsFor[name]; - } - - var fullQueryParams = getFullQueryParams(route.router, state); - - var params = state.queryParamsFor[name] = {}; - - // Copy over all the query params for this route/controller into params hash. - var qpMeta = _emberMetal.get(route, '_qp'); - var qps = qpMeta.qps; - for (var i = 0; i < qps.length; ++i) { - // Put deserialized qp on params hash. - var qp = qps[i]; - - var qpValueWasPassedIn = (qp.prop in fullQueryParams); - params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.defaultValue); - } - - return params; - } - - function copyDefaultValue(value) { - if (Array.isArray(value)) { - return _emberRuntime.A(value.slice()); - } - return value; - } - - /* - Merges all query parameters from a controller with those from - a route, returning a new object and avoiding any mutations to - the existing objects. - */ - function mergeEachQueryParams(controllerQP, routeQP) { - var keysAlreadyMergedOrSkippable = undefined; - var qps = {}; - - keysAlreadyMergedOrSkippable = { - defaultValue: true, - type: true, - scope: true, - as: true - }; - - // first loop over all controller qps, merging them with any matching route qps - // into a new empty object to avoid mutating. - for (var cqpName in controllerQP) { - if (!controllerQP.hasOwnProperty(cqpName)) { - continue; - } - - var newControllerParameterConfiguration = {}; - _emberUtils.assign(newControllerParameterConfiguration, controllerQP[cqpName]); - _emberUtils.assign(newControllerParameterConfiguration, routeQP[cqpName]); - - qps[cqpName] = newControllerParameterConfiguration; - - // allows us to skip this QP when we check route QPs. - keysAlreadyMergedOrSkippable[cqpName] = true; - } - - // loop over all route qps, skipping those that were merged in the first pass - // because they also appear in controller qps - for (var rqpName in routeQP) { - if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { - continue; - } - - var newRouteParameterConfiguration = {}; - _emberUtils.assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); - qps[rqpName] = newRouteParameterConfiguration; - } - - return qps; - } - - function addQueryParamsObservers(controller, propNames) { - propNames.forEach(function (prop) { - controller.addObserver(prop + '.[]', controller, controller._qpChanged); - }); - } - - function getEngineRouteName(engine, routeName) { - if (engine.routable) { - var prefix = engine.mountPoint; - - if (routeName === 'application') { - return prefix; - } else { - return prefix + '.' + routeName; - } - } - - return routeName; - } - - exports.default = Route; -}); -enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-routing/system/route', 'ember-routing/system/dsl', 'ember-routing/location/api', 'ember-routing/utils', 'ember-routing/system/router_state', 'router'], function (exports, _emberUtils, _emberConsole, _emberMetal, _emberRuntime, _emberRoutingSystemRoute, _emberRoutingSystemDsl, _emberRoutingLocationApi, _emberRoutingUtils, _emberRoutingSystemRouter_state, _router4) { - 'use strict'; - - exports.triggerEvent = triggerEvent; - - function K() { - return this; - } - - var slice = Array.prototype.slice; - - /** - The `Ember.Router` class manages the application state and URLs. Refer to - the [routing guide](http://emberjs.com/guides/routing/) for documentation. - - @class Router - @namespace Ember - @extends Ember.Object - @uses Ember.Evented - @public - */ - var EmberRouter = _emberRuntime.Object.extend(_emberRuntime.Evented, { - /** - The `location` property determines the type of URL's that your - application will use. - The following location types are currently available: - * `history` - use the browser's history API to make the URLs look just like any standard URL - * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new` - * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing) - * `auto` - use the best option based on browser capabilites: `history` if possible, then `hash` if possible, otherwise `none` - Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js` - @property location - @default 'hash' - @see {Ember.Location} - @public - */ - location: 'hash', - - /** - Represents the URL of the root of the application, often '/'. This prefix is - assumed on all routes defined on this router. - @property rootURL - @default '/' - @public - */ - rootURL: '/', - - _initRouterJs: function () { - var router = this.router = new _router4.default(); - router.triggerEvent = triggerEvent; - - router._triggerWillChangeContext = K; - router._triggerWillLeave = K; - - var dslCallbacks = this.constructor.dslCallbacks || [K]; - var dsl = this._buildDSL(); - - dsl.route('application', { path: '/', resetNamespace: true, overrideNameAssertion: true }, function () { - for (var i = 0; i < dslCallbacks.length; i++) { - dslCallbacks[i].call(this); - } - }); - - if (_emberMetal.get(this, 'namespace.LOG_TRANSITIONS_INTERNAL')) { - router.log = _emberConsole.default.debug; - } - - router.map(dsl.generate()); - }, - - _buildDSL: function () { - var moduleBasedResolver = this._hasModuleBasedResolver(); - var options = { - enableLoadingSubstates: !!moduleBasedResolver - }; - - var owner = _emberUtils.getOwner(this); - var router = this; - - options.resolveRouteMap = function (name) { - return owner._lookupFactory('route-map:' + name); - }; - - options.addRouteForEngine = function (name, engineInfo) { - if (!router._engineInfoByRoute[name]) { - router._engineInfoByRoute[name] = engineInfo; - } - }; - - return new _emberRoutingSystemDsl.default(null, options); - }, - - init: function () { - this._super.apply(this, arguments); - - this._qpCache = new _emberUtils.EmptyObject(); - this._resetQueuedQueryParameterChanges(); - this._handledErrors = _emberUtils.dictionary(null); - this._engineInstances = new _emberUtils.EmptyObject(); - this._engineInfoByRoute = new _emberUtils.EmptyObject(); - }, - - /* - Resets all pending query paramter changes. - Called after transitioning to a new route - based on query parameter changes. - */ - _resetQueuedQueryParameterChanges: function () { - this._queuedQPChanges = {}; - }, - - /** - Represents the current URL. - @method url - @return {String} The current URL. - @private - */ - url: _emberMetal.computed(function () { - return _emberMetal.get(this, 'location').getURL(); - }), - - _hasModuleBasedResolver: function () { - var owner = _emberUtils.getOwner(this); - - if (!owner) { - return false; - } - - var resolver = owner.application && owner.application.__registry__ && owner.application.__registry__.resolver; - - if (!resolver) { - return false; - } - - return !!resolver.moduleBasedResolver; - }, - - /** - Initializes the current router instance and sets up the change handling - event listeners used by the instances `location` implementation. - A property named `initialURL` will be used to determine the initial URL. - If no value is found `/` will be used. - @method startRouting - @private - */ - startRouting: function () { - var initialURL = _emberMetal.get(this, 'initialURL'); - - if (this.setupRouter()) { - if (typeof initialURL === 'undefined') { - initialURL = _emberMetal.get(this, 'location').getURL(); - } - var initialTransition = this.handleURL(initialURL); - if (initialTransition && initialTransition.error) { - throw initialTransition.error; - } - } - }, - - setupRouter: function () { - var _this = this; - - this._initRouterJs(); - this._setupLocation(); - - var router = this.router; - var location = _emberMetal.get(this, 'location'); - - // Allow the Location class to cancel the router setup while it refreshes - // the page - if (_emberMetal.get(location, 'cancelRouterSetup')) { - return false; - } - - this._setupRouter(router, location); - - location.onUpdateURL(function (url) { - _this.handleURL(url); - }); - - return true; - }, - - /** - Handles updating the paths and notifying any listeners of the URL - change. - Triggers the router level `didTransition` hook. - For example, to notify google analytics when the route changes, - you could use this hook. (Note: requires also including GA scripts, etc.) - ```javascript - let Router = Ember.Router.extend({ - location: config.locationType, - didTransition: function() { - this._super(...arguments); - return ga('send', 'pageview', { - 'page': this.get('url'), - 'title': this.get('url') - }); - } - }); - ``` - @method didTransition - @public - @since 1.2.0 - */ - didTransition: function (infos) { - updatePaths(this); - - this._cancelSlowTransitionTimer(); - - this.notifyPropertyChange('url'); - this.set('currentState', this.targetState); - - // Put this in the runloop so url will be accurate. Seems - // less surprising than didTransition being out of sync. - _emberMetal.run.once(this, this.trigger, 'didTransition'); - - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Transitioned into \'' + EmberRouter._routePath(infos) + '\''); - } - }, - - _setOutlets: function () { - // This is triggered async during Ember.Route#willDestroy. - // If the router is also being destroyed we do not want to - // to create another this._toplevelView (and leak the renderer) - if (this.isDestroying || this.isDestroyed) { - return; - } - - var handlerInfos = this.router.currentHandlerInfos; - var route = undefined; - var defaultParentState = undefined; - var liveRoutes = null; - - if (!handlerInfos) { - return; - } - - for (var i = 0; i < handlerInfos.length; i++) { - route = handlerInfos[i].handler; - var connections = route.connections; - var ownState = undefined; - for (var j = 0; j < connections.length; j++) { - var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); - liveRoutes = appended.liveRoutes; - if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { - ownState = appended.ownState; - } - } - if (connections.length === 0) { - ownState = representEmptyRoute(liveRoutes, defaultParentState, route); - } - defaultParentState = ownState; - } - - // when a transitionTo happens after the validation phase - // during the initial transition _setOutlets is called - // when no routes are active. However, it will get called - // again with the correct values during the next turn of - // the runloop - if (!liveRoutes) { - return; - } - - if (!this._toplevelView) { - var owner = _emberUtils.getOwner(this); - var OutletView = owner._lookupFactory('view:-outlet'); - this._toplevelView = OutletView.create(); - this._toplevelView.setOutletState(liveRoutes); - var instance = owner.lookup('-application-instance:main'); - instance.didCreateRootView(this._toplevelView); - } else { - this._toplevelView.setOutletState(liveRoutes); - } - }, - - /** - Handles notifying any listeners of an impending URL - change. - Triggers the router level `willTransition` hook. - @method willTransition - @public - @since 1.11.0 - */ - willTransition: function (oldInfos, newInfos, transition) { - _emberMetal.run.once(this, this.trigger, 'willTransition', transition); - - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Preparing to transition from \'' + EmberRouter._routePath(oldInfos) + '\' to \'' + EmberRouter._routePath(newInfos) + '\''); - } - }, - - handleURL: function (url) { - // Until we have an ember-idiomatic way of accessing #hashes, we need to - // remove it because router.js doesn't know how to handle it. - url = url.split(/#(.+)?/)[0]; - return this._doURLTransition('handleURL', url); - }, - - _doURLTransition: function (routerJsMethod, url) { - var transition = this.router[routerJsMethod](url || '/'); - 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 - @public - */ - transitionTo: function () { - var queryParams = undefined; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - if (resemblesURL(args[0])) { - return this._doURLTransition('transitionTo', args[0]); - } - - var possibleQueryParams = args[args.length - 1]; - if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { - queryParams = args.pop().queryParams; - } else { - queryParams = {}; - } - - var targetRouteName = args.shift(); - return this._doTransition(targetRouteName, args, queryParams); - }, - - intermediateTransitionTo: function () { - var _router; - - (_router = this.router).intermediateTransitionTo.apply(_router, arguments); - - updatePaths(this); - - var infos = this.router.currentHandlerInfos; - if (_emberMetal.get(this, 'namespace').LOG_TRANSITIONS) { - _emberConsole.default.log('Intermediate-transitioned into \'' + EmberRouter._routePath(infos) + '\''); - } - }, - - replaceWith: function () { - return this.transitionTo.apply(this, arguments).method('replace'); - }, - - generate: function () { - var _router2; - - var url = (_router2 = this.router).generate.apply(_router2, arguments); - return this.location.formatURL(url); - }, - - /** - Determines if the supplied route is currently active. - @method isActive - @param routeName - @return {Boolean} - @private - */ - isActive: function (routeName) { - var router = this.router; - return router.isActive.apply(router, arguments); - }, - - /** - An alternative form of `isActive` that doesn't require - manual concatenation of the arguments into a single - array. - @method isActiveIntent - @param routeName - @param models - @param queryParams - @return {Boolean} - @private - @since 1.7.0 - */ - isActiveIntent: function (routeName, models, queryParams) { - return this.currentState.isActiveIntent(routeName, models, queryParams); - }, - - send: function (name, context) { - var _router3; - - (_router3 = this.router).trigger.apply(_router3, arguments); - }, - - /** - Does this router instance have the given route. - @method hasRoute - @return {Boolean} - @private - */ - hasRoute: function (route) { - return this.router.hasRoute(route); - }, - - /** - Resets the state of the router by clearing the current route - handlers and deactivating them. - @private - @method reset - */ - reset: function () { - if (this.router) { - this.router.reset(); - } - }, - - willDestroy: function () { - if (this._toplevelView) { - this._toplevelView.destroy(); - this._toplevelView = null; - } - - this._super.apply(this, arguments); - - this.reset(); - - var instances = this._engineInstances; - for (var _name in instances) { - for (var id in instances[_name]) { - _emberMetal.run(instances[_name][id], 'destroy'); - } - } - }, - - /* - Called when an active route's query parameter has changed. - These changes are batched into a runloop run and trigger - a single transition. - */ - _activeQPChanged: function (queryParameterName, newValue) { - this._queuedQPChanges[queryParameterName] = newValue; - _emberMetal.run.once(this, this._fireQueryParamTransition); - }, - - _updatingQPChanged: function (queryParameterName) { - if (!this._qpUpdates) { - this._qpUpdates = {}; - } - this._qpUpdates[queryParameterName] = true; - }, - - /* - Triggers a transition to a route based on query parameter changes. - This is called once per runloop, to batch changes. - e.g. - if these methods are called in succession: - this._activeQPChanged('foo', '10'); - // results in _queuedQPChanges = { foo: '10' } - this._activeQPChanged('bar', false); - // results in _queuedQPChanges = { foo: '10', bar: false } - _queuedQPChanges will represent both of these changes - and the transition using `transitionTo` will be triggered - once. - */ - _fireQueryParamTransition: function () { - this.transitionTo({ queryParams: this._queuedQPChanges }); - this._resetQueuedQueryParameterChanges(); - }, - - _setupLocation: function () { - var location = _emberMetal.get(this, 'location'); - var rootURL = _emberMetal.get(this, 'rootURL'); - var owner = _emberUtils.getOwner(this); - - if ('string' === typeof location && owner) { - var resolvedLocation = owner.lookup('location:' + location); - - if ('undefined' !== typeof resolvedLocation) { - location = _emberMetal.set(this, 'location', resolvedLocation); - } else { - // Allow for deprecated registration of custom location API's - var options = { - implementation: location - }; - - location = _emberMetal.set(this, 'location', _emberRoutingLocationApi.default.create(options)); - } - } - - if (location !== null && typeof location === 'object') { - if (rootURL) { - _emberMetal.set(location, 'rootURL', rootURL); - } - - // Allow the location to do any feature detection, such as AutoLocation - // detecting history support. This gives it a chance to set its - // `cancelRouterSetup` property which aborts routing. - if (typeof location.detect === 'function') { - location.detect(); - } - - // ensure that initState is called AFTER the rootURL is set on - // the location instance - if (typeof location.initState === 'function') { - location.initState(); - } - } - }, - - _getHandlerFunction: function () { - var _this2 = this; - - var seen = new _emberUtils.EmptyObject(); - var owner = _emberUtils.getOwner(this); - - return function (name) { - var routeName = name; - var routeOwner = owner; - var engineInfo = _this2._engineInfoByRoute[routeName]; - - if (engineInfo) { - var engineInstance = _this2._getEngineInstance(engineInfo); - - routeOwner = engineInstance; - routeName = engineInfo.localFullName; - } - - var fullRouteName = 'route:' + routeName; - - var handler = routeOwner.lookup(fullRouteName); - - if (seen[name]) { - return handler; - } - - seen[name] = true; - - if (!handler) { - var DefaultRoute = routeOwner._lookupFactory('route:basic'); - - routeOwner.register(fullRouteName, DefaultRoute.extend()); - handler = routeOwner.lookup(fullRouteName); - - if (_emberMetal.get(_this2, 'namespace.LOG_ACTIVE_GENERATION')) {} - } - - handler._setRouteName(routeName); - handler._populateQPMeta(); - - if (engineInfo && !_emberRoutingSystemRoute.hasDefaultSerialize(handler)) { - throw new Error('Defining a custom serialize method on an Engine route is not supported.'); - } - - return handler; - }; - }, - - _getSerializerFunction: function () { - var _this3 = this; - - return function (name) { - var engineInfo = _this3._engineInfoByRoute[name]; - - // If this is not an Engine route, we fall back to the handler for serialization - if (!engineInfo) { - return; - } - - return engineInfo.serializeMethod || _emberRoutingSystemRoute.defaultSerialize; - }; - }, - - _setupRouter: function (router, location) { - var lastURL = undefined; - var emberRouter = this; - - router.getHandler = this._getHandlerFunction(); - router.getSerializer = this._getSerializerFunction(); - - var doUpdateURL = function () { - location.setURL(lastURL); - }; - - router.updateURL = function (path) { - lastURL = path; - _emberMetal.run.once(doUpdateURL); - }; - - if (location.replaceURL) { - (function () { - var doReplaceURL = function () { - location.replaceURL(lastURL); - }; - - router.replaceURL = function (path) { - lastURL = path; - _emberMetal.run.once(doReplaceURL); - }; - })(); - } - - router.didTransition = function (infos) { - emberRouter.didTransition(infos); - }; - - router.willTransition = function (oldInfos, newInfos, transition) { - emberRouter.willTransition(oldInfos, newInfos, transition); - }; - }, - - /** - Serializes the given query params according to their QP meta information. - @private - @method _serializeQueryParams - @param {Arrray} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _serializeQueryParams: function (handlerInfos, queryParams) { - var _this4 = this; - - forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { - if (qp) { - delete queryParams[key]; - queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); - } else if (value === undefined) { - return; // We don't serialize undefined values - } else { - queryParams[key] = _this4._serializeQueryParam(value, _emberRuntime.typeOf(value)); - } - }); - }, - - /** - Serializes the value of a query parameter based on a type - @private - @method _serializeQueryParam - @param {Object} value - @param {String} type - */ - _serializeQueryParam: function (value, type) { - if (type === 'array') { - return JSON.stringify(value); - } - - return '' + value; - }, - - /** - Deserializes the given query params according to their QP meta information. - @private - @method _deserializeQueryParams - @param {Array} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _deserializeQueryParams: function (handlerInfos, queryParams) { - forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { - // If we don't have QP meta info for a given key, then we do nothing - // because all values will be treated as strings - if (qp) { - delete queryParams[key]; - queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); - } - }); - }, - - /** - Deserializes the value of a query parameter based on a default type - @private - @method _deserializeQueryParam - @param {Object} value - @param {String} defaultType - */ - _deserializeQueryParam: function (value, defaultType) { - if (defaultType === 'boolean') { - return value === 'true' ? true : false; - } else if (defaultType === 'number') { - return Number(value).valueOf(); - } else if (defaultType === 'array') { - return _emberRuntime.A(JSON.parse(value)); - } - - return value; - }, - - /** - Removes (prunes) any query params with default values from the given QP - object. Default values are determined from the QP meta information per key. - @private - @method _pruneDefaultQueryParamValues - @param {Array} handlerInfos - @param {Object} queryParams - @return {Void} - */ - _pruneDefaultQueryParamValues: function (handlerInfos, queryParams) { - var qps = this._queryParamsFor(handlerInfos); - for (var key in queryParams) { - var qp = qps.map[key]; - if (qp && qp.serializedDefaultValue === queryParams[key]) { - delete queryParams[key]; - } - } - }, - - _doTransition: function (_targetRouteName, models, _queryParams) { - var targetRouteName = _targetRouteName || _emberRoutingUtils.getActiveTargetName(this.router); - - var queryParams = {}; - - this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); - - _emberUtils.assign(queryParams, _queryParams); - this._prepareQueryParams(targetRouteName, models, queryParams); - - var transitionArgs = _emberRoutingUtils.routeArgs(targetRouteName, models, queryParams); - var transition = this.router.transitionTo.apply(this.router, transitionArgs); - - didBeginTransition(transition, this); - - return transition; - }, - - _processActiveTransitionQueryParams: function (targetRouteName, models, queryParams, _queryParams) { - // merge in any queryParams from the active transition which could include - // queryParams from the url on initial load. - if (!this.router.activeTransition) { - return; - } - - var unchangedQPs = {}; - var qpUpdates = this._qpUpdates || {}; - for (var key in this.router.activeTransition.queryParams) { - if (!qpUpdates[key]) { - unchangedQPs[key] = this.router.activeTransition.queryParams[key]; - } - } - - // We need to fully scope queryParams so that we can create one object - // that represents both pased in queryParams and ones that aren't changed - // from the active transition. - this._fullyScopeQueryParams(targetRouteName, models, _queryParams); - this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs); - _emberUtils.assign(queryParams, unchangedQPs); - }, - - /** - Prepares the query params for a URL or Transition. Restores any undefined QP - keys/values, serializes all values, and then prunes any default values. - @private - @method _prepareQueryParams - @param {String} targetRouteName - @param {Array} models - @param {Object} queryParams - @return {Void} - */ - _prepareQueryParams: function (targetRouteName, models, queryParams) { - var state = calculatePostTransitionState(this, targetRouteName, models); - this._hydrateUnsuppliedQueryParams(state, queryParams); - this._serializeQueryParams(state.handlerInfos, queryParams); - this._pruneDefaultQueryParamValues(state.handlerInfos, queryParams); - }, - - /** - Returns the meta information for the query params of a given route. This - will be overriden to allow support for lazy routes. - @private - @method _getQPMeta - @param {HandlerInfo} handlerInfo - @return {Object} - */ - _getQPMeta: function (handlerInfo) { - var route = handlerInfo.handler; - return route && _emberMetal.get(route, '_qp'); - }, - - /** - Returns a merged query params meta object for a given set of handlerInfos. - Useful for knowing what query params are available for a given route hierarchy. - @private - @method _queryParamsFor - @param {Array} handlerInfos - @return {Object} - */ - _queryParamsFor: function (handlerInfos) { - var leafRouteName = handlerInfos[handlerInfos.length - 1].name; - if (this._qpCache[leafRouteName]) { - return this._qpCache[leafRouteName]; - } - - var shouldCache = true; - var qpsByUrlKey = {}; - var map = {}; - var qps = []; - - for (var i = 0; i < handlerInfos.length; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); - - if (!qpMeta) { - shouldCache = false; - continue; - } - - // Loop over each QP to make sure we don't have any collisions by urlKey - for (var _i = 0; _i < qpMeta.qps.length; _i++) { - var qp = qpMeta.qps[_i]; - var urlKey = qp.urlKey; - - if (qpsByUrlKey[urlKey]) { - var otherQP = qpsByUrlKey[urlKey]; - } - - qpsByUrlKey[urlKey] = qp; - qps.push(qp); - } - - _emberUtils.assign(map, qpMeta.map); - } - - var finalQPMeta = { - qps: qps, - map: map - }; - - if (shouldCache) { - this._qpCache[leafRouteName] = finalQPMeta; - } - - return finalQPMeta; - }, - - /** - Maps all query param keys to their fully scoped property name of the form - `controllerName:propName`. - @private - @method _fullyScopeQueryParams - @param {String} leafRouteName - @param {Array} contexts - @param {Object} queryParams - @return {Void} - */ - _fullyScopeQueryParams: function (leafRouteName, contexts, queryParams) { - var state = calculatePostTransitionState(this, leafRouteName, contexts); - var handlerInfos = state.handlerInfos; - - for (var i = 0, len = handlerInfos.length; i < len; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); - - if (!qpMeta) { - continue; - } - - for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { - var qp = qpMeta.qps[j]; - - var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; - - if (presentProp) { - if (presentProp !== qp.scopedPropertyName) { - queryParams[qp.scopedPropertyName] = queryParams[presentProp]; - delete queryParams[presentProp]; - } - } - } - } - }, - - /** - Hydrates (adds/restores) any query params that have pre-existing values into - the given queryParams hash. This is what allows query params to be "sticky" - and restore their last known values for their scope. - @private - @method _hydrateUnsuppliedQueryParams - @param {TransitionState} state - @param {Object} queryParams - @return {Void} - */ - _hydrateUnsuppliedQueryParams: function (state, queryParams) { - var handlerInfos = state.handlerInfos; - var appCache = this._bucketCache; - - for (var i = 0; i < handlerInfos.length; ++i) { - var qpMeta = this._getQPMeta(handlerInfos[i]); - - if (!qpMeta) { - continue; - } - - for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { - var qp = qpMeta.qps[j]; - - var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; - - if (presentProp) { - if (presentProp !== qp.scopedPropertyName) { - queryParams[qp.scopedPropertyName] = queryParams[presentProp]; - delete queryParams[presentProp]; - } - } else { - var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.controllerName, qp.parts, state.params); - queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); - } - } - } - }, - - _scheduleLoadingEvent: function (transition, originRoute) { - this._cancelSlowTransitionTimer(); - this._slowTransitionTimer = _emberMetal.run.scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute); - }, - - currentState: null, - targetState: null, - - _handleSlowTransition: function (transition, originRoute) { - if (!this.router.activeTransition) { - // Don't fire an event if we've since moved on from - // the transition that put us in a loading state. - return; - } - - this.set('targetState', _emberRoutingSystemRouter_state.default.create({ - emberRouter: this, - routerJs: this.router, - routerJsState: this.router.activeTransition.state - })); - - transition.trigger(true, 'loading', transition, originRoute); - }, - - _cancelSlowTransitionTimer: function () { - if (this._slowTransitionTimer) { - _emberMetal.run.cancel(this._slowTransitionTimer); - } - this._slowTransitionTimer = null; - }, - - // These three helper functions are used to ensure errors aren't - // re-raised if they're handled in a route's error action. - _markErrorAsHandled: function (errorGuid) { - this._handledErrors[errorGuid] = true; - }, - - _isErrorHandled: function (errorGuid) { - return this._handledErrors[errorGuid]; - }, - - _clearHandledError: function (errorGuid) { - delete this._handledErrors[errorGuid]; - }, - - _getEngineInstance: function (_ref) { - var name = _ref.name; - var instanceId = _ref.instanceId; - var mountPoint = _ref.mountPoint; - - var engineInstances = this._engineInstances; - - if (!engineInstances[name]) { - engineInstances[name] = new _emberUtils.EmptyObject(); - } - - var engineInstance = engineInstances[name][instanceId]; - - if (!engineInstance) { - var owner = _emberUtils.getOwner(this); - - engineInstance = owner.buildChildEngineInstance(name, { - routable: true, - mountPoint: mountPoint - }); - - engineInstance.boot(); - - engineInstances[name][instanceId] = engineInstance; - } - - return engineInstance; - } - }); - - /* - Helper function for iterating over routes in a set of handlerInfos that are - at or above the given origin route. Example: if `originRoute` === 'foo.bar' - and the handlerInfos given were for 'foo.bar.baz', then the given callback - will be invoked with the routes for 'foo.bar', 'foo', and 'application' - individually. - - If the callback returns anything other than `true`, then iteration will stop. - - @private - @param {Route} originRoute - @param {Array} handlerInfos - @param {Function} callback - @return {Void} - */ - function forEachRouteAbove(originRoute, handlerInfos, callback) { - var originRouteFound = false; - - for (var i = handlerInfos.length - 1; i >= 0; --i) { - var handlerInfo = handlerInfos[i]; - var route = handlerInfo.handler; - - if (originRoute === route) { - originRouteFound = true; - } - - if (!originRouteFound) { - continue; - } - - if (callback(route) !== true) { - return; - } - } - } - - // These get invoked when an action bubbles above ApplicationRoute - // and are not meant to be overridable. - var defaultActionHandlers = { - - willResolveModel: function (transition, originRoute) { - originRoute.router._scheduleLoadingEvent(transition, originRoute); - }, - - // Attempt to find an appropriate error route or substate to enter. - error: function (error, transition, originRoute) { - var handlerInfos = transition.state.handlerInfos; - var router = originRoute.router; - - forEachRouteAbove(originRoute, handlerInfos, function (route) { - // Check for the existence of an 'error' route. - // We don't check for an 'error' route on the originRoute, since that would - // technically be below where we're at in the route hierarchy. - if (originRoute !== route) { - var errorRouteName = findRouteStateName(route, 'error'); - if (errorRouteName) { - router.intermediateTransitionTo(errorRouteName, error); - return false; - } - } - - // Check for an 'error' substate route - var errorSubstateName = findRouteSubstateName(route, 'error'); - if (errorSubstateName) { - router.intermediateTransitionTo(errorSubstateName, error); - return false; - } - - return true; - }); - - logError(error, 'Error while processing route: ' + transition.targetName); - }, - - // Attempt to find an appropriate loading route or substate to enter. - loading: function (transition, originRoute) { - var handlerInfos = transition.state.handlerInfos; - var router = originRoute.router; - - forEachRouteAbove(originRoute, handlerInfos, function (route) { - // Check for the existence of a 'loading' route. - // We don't check for a 'loading' route on the originRoute, since that would - // technically be below where we're at in the route hierarchy. - if (originRoute !== route) { - var loadingRouteName = findRouteStateName(route, 'loading'); - if (loadingRouteName) { - router.intermediateTransitionTo(loadingRouteName); - return false; - } - } - - // Check for loading substate - var loadingSubstateName = findRouteSubstateName(route, 'loading'); - if (loadingSubstateName) { - router.intermediateTransitionTo(loadingSubstateName); - return false; - } - - // Don't bubble above pivot route. - return transition.pivotHandler !== route; - }); - } - }; - - function logError(_error, initialMessage) { - var errorArgs = []; - var error = undefined; - if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { - error = _error.errorThrown; - } else { - error = _error; - } - - if (initialMessage) { - errorArgs.push(initialMessage); - } - - if (error) { - if (error.message) { - errorArgs.push(error.message); - } - if (error.stack) { - errorArgs.push(error.stack); - } - - if (typeof error === 'string') { - errorArgs.push(error); - } - } - - _emberConsole.default.error.apply(this, errorArgs); - } - - /** - Finds the name of the substate route if it exists for the given route. A - substate route is of the form `route_state`, such as `foo_loading`. - - @private - @param {Route} route - @param {String} state - @return {String} - */ - function findRouteSubstateName(route, state) { - var router = route.router; - var owner = _emberUtils.getOwner(route); - - var routeName = route.routeName; - var substateName = routeName + '_' + state; - - var routeNameFull = route.fullRouteName; - var substateNameFull = routeNameFull + '_' + state; - - return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; - } - - /** - Finds the name of the state route if it exists for the given route. A state - route is of the form `route.state`, such as `foo.loading`. Properly Handles - `application` named routes. - - @private - @param {Route} route - @param {String} state - @return {String} - */ - function findRouteStateName(route, state) { - var router = route.router; - var owner = _emberUtils.getOwner(route); - - var routeName = route.routeName; - var stateName = routeName === 'application' ? state : routeName + '.' + state; - - var routeNameFull = route.fullRouteName; - var stateNameFull = routeNameFull === 'application' ? state : routeNameFull + '.' + state; - - return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; - } - - /** - Determines whether or not a route has been defined by checking that the route - is in the Router's map and the owner has a registration for that route. - - @private - @param {Owner} owner - @param {Ember.Router} router - @param {String} localName - @param {String} fullName - @return {Boolean} - */ - function routeHasBeenDefined(owner, router, localName, fullName) { - var routerHasRoute = router.hasRoute(fullName); - var ownerHasRoute = owner.hasRegistration('template:' + localName) || owner.hasRegistration('route:' + localName); - return routerHasRoute && ownerHasRoute; - } - - function triggerEvent(handlerInfos, ignoreFailure, args) { - var name = args.shift(); - - if (!handlerInfos) { - if (ignoreFailure) { - return; - } - throw new _emberMetal.Error('Can\'t trigger action \'' + name + '\' because your app hasn\'t finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.'); - } - - var eventWasHandled = false; - var handlerInfo = undefined, - handler = undefined; - - for (var i = handlerInfos.length - 1; i >= 0; i--) { - handlerInfo = handlerInfos[i]; - handler = handlerInfo.handler; - - if (handler && handler.actions && handler.actions[name]) { - if (handler.actions[name].apply(handler, args) === true) { - eventWasHandled = true; - } else { - // Should only hit here if a non-bubbling error action is triggered on a route. - if (name === 'error') { - var errorId = _emberUtils.guidFor(args[0]); - handler.router._markErrorAsHandled(errorId); - } - return; - } - } - } - - if (defaultActionHandlers[name]) { - defaultActionHandlers[name].apply(null, args); - return; - } - - if (!eventWasHandled && !ignoreFailure) { - throw new _emberMetal.Error('Nothing handled the action \'' + name + '\'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.'); - } - } - - function calculatePostTransitionState(emberRouter, leafRouteName, contexts) { - var routerjs = emberRouter.router; - var state = routerjs.applyIntent(leafRouteName, contexts); - var handlerInfos = state.handlerInfos; - var params = state.params; - - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; - - // If the handlerInfo is not resolved, we serialize the context into params - if (!handlerInfo.isResolved) { - params[handlerInfo.name] = handlerInfo.serialize(handlerInfo.context); - } else { - params[handlerInfo.name] = handlerInfo.params; - } - } - return state; - } - - function updatePaths(router) { - var infos = router.router.currentHandlerInfos; - if (infos.length === 0) { - return; - } - - var path = EmberRouter._routePath(infos); - var currentRouteName = infos[infos.length - 1].name; - - _emberMetal.set(router, 'currentPath', path); - _emberMetal.set(router, 'currentRouteName', currentRouteName); - - var appController = _emberUtils.getOwner(router).lookup('controller:application'); - - if (!appController) { - // appController might not exist when top-level loading/error - // substates have been entered since ApplicationRoute hasn't - // actually been entered at that point. - return; - } - - if (!('currentPath' in appController)) { - _emberMetal.defineProperty(appController, 'currentPath'); - } - - _emberMetal.set(appController, 'currentPath', path); - - if (!('currentRouteName' in appController)) { - _emberMetal.defineProperty(appController, 'currentRouteName'); - } - - _emberMetal.set(appController, 'currentRouteName', currentRouteName); - } - - EmberRouter.reopenClass({ - router: null, - - /** - The `Router.map` function allows you to define mappings from URLs to routes - in your application. These mappings are defined within the - supplied callback function using `this.route`. - The first parameter is the name of the route which is used by default as the - path name as well. - The second parameter is the optional options hash. Available options are: - * `path`: allows you to provide your own path as well as mark dynamic - segments. - * `resetNamespace`: false by default; when nesting routes, ember will - combine the route names to form the fully-qualified route name, which is - used with `{{link-to}}` or manually transitioning to routes. Setting - `resetNamespace: true` will cause the route not to inherit from its - parent route's names. This is handy for preventing extremely long route names. - Keep in mind that the actual URL path behavior is still retained. - The third parameter is a function, which can be used to nest routes. - Nested routes, by default, will have the parent route tree's route name and - path prepended to it's own. - ```javascript - App.Router.map(function(){ - this.route('post', { path: '/post/:post_id' }, function() { - this.route('edit'); - this.route('comments', { resetNamespace: true }, function() { - this.route('new'); - }); - }); - }); - ``` - For more detailed documentation and examples please see - [the guides](http://emberjs.com/guides/routing/defining-your-routes/). - @method map - @param callback - @public - */ - map: function (callback) { - if (!this.dslCallbacks) { - this.dslCallbacks = []; - this.reopenClass({ dslCallbacks: this.dslCallbacks }); - } - - this.dslCallbacks.push(callback); - - return this; - }, - - _routePath: function (handlerInfos) { - var path = []; - - // We have to handle coalescing resource names that - // are prefixed with their parent's names, e.g. - // ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz' - - function intersectionMatches(a1, a2) { - for (var i = 0; i < a1.length; ++i) { - if (a1[i] !== a2[i]) { - return false; - } - } - return true; - } - - var name = undefined, - nameParts = undefined, - oldNameParts = undefined; - for (var i = 1; i < handlerInfos.length; i++) { - name = handlerInfos[i].name; - nameParts = name.split('.'); - oldNameParts = slice.call(path); - - while (oldNameParts.length) { - if (intersectionMatches(oldNameParts, nameParts)) { - break; - } - oldNameParts.shift(); - } - - path.push.apply(path, nameParts.slice(oldNameParts.length)); - } - - return path.join('.'); - } - }); - - function didBeginTransition(transition, router) { - var routerState = _emberRoutingSystemRouter_state.default.create({ - emberRouter: router, - routerJs: router.router, - routerJsState: transition.state - }); - - if (!router.currentState) { - router.set('currentState', routerState); - } - router.set('targetState', routerState); - - transition.promise = transition.catch(function (error) { - var errorId = _emberUtils.guidFor(error); - - if (router._isErrorHandled(errorId)) { - router._clearHandledError(errorId); - } else { - throw error; - } - }); - } - - function resemblesURL(str) { - return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); - } - - function forEachQueryParam(router, handlerInfos, queryParams, callback) { - var qpCache = router._queryParamsFor(handlerInfos); - - for (var key in queryParams) { - if (!queryParams.hasOwnProperty(key)) { - continue; - } - var value = queryParams[key]; - var qp = qpCache.map[key]; - - callback(key, value, qp); - } - } - - function findLiveRoute(liveRoutes, name) { - if (!liveRoutes) { - return; - } - var stack = [liveRoutes]; - while (stack.length > 0) { - var test = stack.shift(); - if (test.render.name === name) { - return test; - } - var outlets = test.outlets; - for (var outletName in outlets) { - stack.push(outlets[outletName]); - } - } - } - - function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { - var target = undefined; - var myState = { - render: renderOptions, - outlets: new _emberUtils.EmptyObject(), - wasUsed: false - }; - if (renderOptions.into) { - target = findLiveRoute(liveRoutes, renderOptions.into); - } else { - target = defaultParentState; - } - if (target) { - _emberMetal.set(target.outlets, renderOptions.outlet, myState); - } else { - if (renderOptions.into) { - - // Megahax time. Post-3.0-breaking-changes, we will just assert - // right here that the user tried to target a nonexistent - // thing. But for now we still need to support the `render` - // helper, and people are allowed to target templates rendered - // by the render helper. So instead we defer doing anyting with - // these orphan renders until afterRender. - appendOrphan(liveRoutes, renderOptions.into, myState); - } else { - liveRoutes = myState; - } - } - return { - liveRoutes: liveRoutes, - ownState: myState - }; - } - - function appendOrphan(liveRoutes, into, myState) { - if (!liveRoutes.outlets.__ember_orphans__) { - liveRoutes.outlets.__ember_orphans__ = { - render: { - name: '__ember_orphans__' - }, - outlets: new _emberUtils.EmptyObject() - }; - } - liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; - _emberMetal.run.schedule('afterRender', function () {}); - } - - function representEmptyRoute(liveRoutes, defaultParentState, route) { - // the route didn't render anything - var alreadyAppended = findLiveRoute(liveRoutes, route.routeName); - if (alreadyAppended) { - // But some other route has already rendered our default - // template, so that becomes the default target for any - // children we may have. - return alreadyAppended; - } else { - // Create an entry to represent our default template name, - // just so other routes can target it and inherit its place - // in the outlet hierarchy. - defaultParentState.outlets.main = { - render: { - name: route.routeName, - outlet: 'main' - }, - outlets: {} - }; - return defaultParentState; - } - } - - exports.default = EmberRouter; -}); - -/** -@module ember -@submodule ember-routing -*/ - -// `wasUsed` gets set by the render helper. -enifed('ember-routing/system/router_state', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime'], function (exports, _emberUtils, _emberMetal, _emberRuntime) { - 'use strict'; - - exports.default = _emberRuntime.Object.extend({ - emberRouter: null, - routerJs: null, - routerJsState: null, - - isActiveIntent: function (routeName, models, queryParams, queryParamsMustMatch) { - var state = this.routerJsState; - if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { - return false; - } - - var emptyQueryParams = _emberMetal.isEmpty(Object.keys(queryParams)); - - if (queryParamsMustMatch && !emptyQueryParams) { - var visibleQueryParams = {}; - _emberUtils.assign(visibleQueryParams, queryParams); - - this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); - return shallowEqual(visibleQueryParams, state.queryParams); - } - - return true; - } - }); - - function shallowEqual(a, b) { - var k = undefined; - for (k in a) { - if (a.hasOwnProperty(k) && a[k] !== b[k]) { - return false; - } - } - for (k in b) { - if (b.hasOwnProperty(k) && a[k] !== b[k]) { - return false; - } - } - return true; - } -}); -enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { - 'use strict'; - - exports.routeArgs = routeArgs; - exports.getActiveTargetName = getActiveTargetName; - exports.stashParamNames = stashParamNames; - exports.calculateCacheKey = calculateCacheKey; - exports.normalizeControllerQueryParams = normalizeControllerQueryParams; - exports.prefixRouteNameArg = prefixRouteNameArg; - - var ALL_PERIODS_REGEX = /\./g; - - function routeArgs(targetRouteName, models, queryParams) { - var args = []; - if (typeof targetRouteName === 'string') { - args.push('' + targetRouteName); - } - args.push.apply(args, models); - args.push({ queryParams: queryParams }); - return args; - } - - function getActiveTargetName(router) { - var handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; - return handlerInfos[handlerInfos.length - 1].name; - } - - function stashParamNames(router, handlerInfos) { - if (handlerInfos._namesStashed) { - return; - } - - // This helper exists because router.js/route-recognizer.js awkwardly - // keeps separate a handlerInfo's list of parameter names depending - // on whether a URL transition or named transition is happening. - // Hopefully we can remove this in the future. - var targetRouteName = handlerInfos[handlerInfos.length - 1].name; - var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); - var dynamicParent = null; - - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; - var names = recogHandlers[i].names; - - if (names.length) { - dynamicParent = handlerInfo; - } - - handlerInfo._names = names; - - var route = handlerInfo.handler; - route._stashNames(handlerInfo, dynamicParent); - } - - handlerInfos._namesStashed = true; - } - - function _calculateCacheValuePrefix(prefix, part) { - // calculates the dot seperated sections from prefix that are also - // at the start of part - which gives us the route name - - // given : prefix = site.article.comments, part = site.article.id - // - returns: site.article (use get(values[site.article], 'id') to get the dynamic part - used below) - - // given : prefix = site.article, part = site.article.id - // - returns: site.article. (use get(values[site.article], 'id') to get the dynamic part - used below) - - var prefixParts = prefix.split('.'); - var currPrefix = ''; - - for (var i = 0; i < prefixParts.length; i++) { - var currPart = prefixParts.slice(0, i + 1).join('.'); - if (part.indexOf(currPart) !== 0) { - break; - } - currPrefix = currPart; - } - - return currPrefix; - } - - /* - Stolen from Controller - */ - - function calculateCacheKey(prefix, _parts, values) { - var parts = _parts || []; - var suffixes = ''; - for (var i = 0; i < parts.length; ++i) { - var part = parts[i]; - var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); - var value = undefined; - if (values) { - if (cacheValuePrefix && cacheValuePrefix in values) { - var partRemovedPrefix = part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part; - value = _emberMetal.get(values[cacheValuePrefix], partRemovedPrefix); - } else { - value = _emberMetal.get(values, part); - } - } - suffixes += '::' + part + ':' + value; - } - return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); - } - - /* - Controller-defined query parameters can come in three shapes: - - Array - queryParams: ['foo', 'bar'] - Array of simple objects where value is an alias - queryParams: [ - { - 'foo': 'rename_foo_to_this' - }, - { - 'bar': 'call_bar_this_instead' - } - ] - Array of fully defined objects - queryParams: [ - { - 'foo': { - as: 'rename_foo_to_this' - }, - } - { - 'bar': { - as: 'call_bar_this_instead', - scope: 'controller' - } - } - ] - - This helper normalizes all three possible styles into the - 'Array of fully defined objects' style. - */ - - function normalizeControllerQueryParams(queryParams) { - var qpMap = {}; - - for (var i = 0; i < queryParams.length; ++i) { - accumulateQueryParamDescriptors(queryParams[i], qpMap); - } - - return qpMap; - } - - function accumulateQueryParamDescriptors(_desc, accum) { - var desc = _desc; - var tmp = undefined; - if (typeof desc === 'string') { - tmp = {}; - tmp[desc] = { as: null }; - desc = tmp; - } - - for (var key in desc) { - if (!desc.hasOwnProperty(key)) { - return; - } - - var singleDesc = desc[key]; - if (typeof singleDesc === 'string') { - singleDesc = { as: singleDesc }; - } - - tmp = accum[key] || { as: null, scope: 'model' }; - _emberUtils.assign(tmp, singleDesc); - - accum[key] = tmp; - } - } - - /* - Check if a routeName resembles a url instead - - @private - */ - function resemblesURL(str) { - return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); - } - - /* - Returns an arguments array where the route name arg is prefixed based on the mount point - - @private - */ - - function prefixRouteNameArg(route, args) { - var routeName = args[0]; - var owner = _emberUtils.getOwner(route); - var prefix = owner.mountPoint; - - // only alter the routeName if it's actually referencing a route. - if (owner.routable && typeof routeName === 'string') { - if (resemblesURL(routeName)) { - throw new _emberMetal.Error('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'); - } else { - routeName = prefix + '.' + routeName; - args[0] = routeName; - } - } - - return args; - } -}); -enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeMixinsComparable) { - 'use strict'; - - exports.default = compare; - - var TYPE_ORDER = { - 'undefined': 0, - 'null': 1, - 'boolean': 2, - 'number': 3, - 'string': 4, - 'array': 5, - 'object': 6, - 'instance': 7, - 'function': 8, - 'class': 9, - 'date': 10 - }; - - // - // the spaceship operator - // - // `. ___ - // __,' __`. _..----....____ - // __...--.'``;. ,. ;``--..__ .' ,-._ _.-' - // _..-''-------' `' `' `' O ``-''._ (,;') _,' - // ,'________________ \`-._`-',' - // `._ ```````````------...___ '-.._'-: - // ```--.._ ,. ````--...__\-. - // `.--. `-` "INFINITY IS LESS ____ | |` - // `. `. THAN BEYOND" ,'`````. ; ;` - // `._`. __________ `. \'__/` - // `-:._____/______/___/____`. \ ` - // | `._ `. \ - // `._________`-. `. `.___ - // SSt `------'` - function spaceship(a, b) { - var diff = a - b; - return (diff > 0) - (diff < 0); - } - - /** - Compares two javascript values and returns: - - - -1 if the first is smaller than the second, - - 0 if both are equal, - - 1 if the first is greater than the second. - - ```javascript - Ember.compare('hello', 'hello'); // 0 - Ember.compare('abc', 'dfg'); // -1 - Ember.compare(2, 1); // 1 - ``` - - If the types of the two objects are different precedence occurs in the - following order, with types earlier in the list considered `<` types - later in the list: - - - undefined - - null - - boolean - - number - - string - - array - - object - - instance - - function - - class - - date - - ```javascript - Ember.compare('hello', 50); // 1 - Ember.compare(50, 'hello'); // -1 - ``` - - @method compare - @for Ember - @param {Object} v First value to compare - @param {Object} w Second value to compare - @return {Number} -1 if v < w, 0 if v = w and 1 if v > w. - @public - */ - - function compare(v, w) { - if (v === w) { - return 0; - } - - var type1 = _emberRuntimeUtils.typeOf(v); - var type2 = _emberRuntimeUtils.typeOf(w); - - if (_emberRuntimeMixinsComparable.default) { - if (type1 === 'instance' && _emberRuntimeMixinsComparable.default.detect(v) && v.constructor.compare) { - return v.constructor.compare(v, w); - } - - if (type2 === 'instance' && _emberRuntimeMixinsComparable.default.detect(w) && w.constructor.compare) { - return w.constructor.compare(w, v) * -1; - } - } - - var res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); - - if (res !== 0) { - return res; - } - - // types are equal - so we have to check values now - switch (type1) { - case 'boolean': - case 'number': - return spaceship(v, w); - - case 'string': - return spaceship(v.localeCompare(w), 0); - - case 'array': - var vLen = v.length; - var wLen = w.length; - var len = Math.min(vLen, wLen); - - for (var i = 0; i < len; i++) { - var r = compare(v[i], w[i]); - if (r !== 0) { - return r; - } - } - - // all elements are equal now - // shorter array should be ordered first - return spaceship(vLen, wLen); - - case 'instance': - if (_emberRuntimeMixinsComparable.default && _emberRuntimeMixinsComparable.default.detect(v)) { - return v.compare(v, w); - } - return 0; - - case 'date': - return spaceship(v.getTime(), w.getTime()); - - default: - return 0; - } - } -}); -enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - exports.empty = empty; - exports.notEmpty = notEmpty; - exports.none = none; - exports.not = not; - exports.bool = bool; - exports.match = match; - exports.equal = equal; - exports.gt = gt; - exports.gte = gte; - exports.lt = lt; - exports.lte = lte; - exports.oneWay = oneWay; - exports.readOnly = readOnly; - exports.deprecatingAlias = deprecatingAlias; - - /** - @module ember - @submodule ember-metal - */ - - function expandPropertiesToArray(predicateName, properties) { - var expandedProperties = []; - - function extractProperty(entry) { - expandedProperties.push(entry); - } - - for (var i = 0; i < properties.length; i++) { - var property = properties[i]; - - _emberMetal.expandProperties(property, extractProperty); - } - - return expandedProperties; - } - - function generateComputedWithPredicate(name, predicate) { - return function () { - for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) { - properties[_key] = arguments[_key]; - } - - var expandedProperties = expandPropertiesToArray(name, properties); - - var computedFunc = _emberMetal.computed(function () { - var lastIdx = expandedProperties.length - 1; - - for (var i = 0; i < lastIdx; i++) { - var value = _emberMetal.get(this, expandedProperties[i]); - if (!predicate(value)) { - return value; - } - } - - return _emberMetal.get(this, expandedProperties[lastIdx]); - }); - - return computedFunc.property.apply(computedFunc, expandedProperties); - }; - } - - /** - A computed property that returns true if the value of the dependent - property is null, an empty string, empty array, or empty function. - - Example - - ```javascript - let ToDoList = Ember.Object.extend({ - isDone: Ember.computed.empty('todos') - }); - - let todoList = ToDoList.create({ - todos: ['Unit Test', 'Documentation', 'Release'] - }); - - todoList.get('isDone'); // false - todoList.get('todos').clear(); - todoList.get('isDone'); // true - ``` - - @since 1.6.0 - @method empty - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which negate - the original value for property - @public - */ - - function empty(dependentKey) { - return _emberMetal.computed(dependentKey + '.length', function () { - return _emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); - }); - } - - /** - A computed property that returns true if the value of the dependent - property is NOT null, an empty string, empty array, or empty function. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasStuff: Ember.computed.notEmpty('backpack') - }); - - let hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); - - hamster.get('hasStuff'); // true - hamster.get('backpack').clear(); // [] - hamster.get('hasStuff'); // false - ``` - - @method notEmpty - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which returns true if - original value for property is not empty. - @public - */ - - function notEmpty(dependentKey) { - return _emberMetal.computed(dependentKey + '.length', function () { - return !_emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); - }); - } - - /** - A computed property that returns true if the value of the dependent - property is null or undefined. This avoids errors from JSLint complaining - about use of ==, which can be technically confusing. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - isHungry: Ember.computed.none('food') - }); - - let hamster = Hamster.create(); - - hamster.get('isHungry'); // true - hamster.set('food', 'Banana'); - hamster.get('isHungry'); // false - hamster.set('food', null); - hamster.get('isHungry'); // true - ``` - - @method none - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which - returns true if original value for property is null or undefined. - @public - */ - - function none(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.isNone(_emberMetal.get(this, dependentKey)); - }); - } - - /** - A computed property that returns the inverse boolean value - of the original value for the dependent property. - - Example - - ```javascript - let User = Ember.Object.extend({ - isAnonymous: Ember.computed.not('loggedIn') - }); - - let user = User.create({loggedIn: false}); - - user.get('isAnonymous'); // true - user.set('loggedIn', true); - user.get('isAnonymous'); // false - ``` - - @method not - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which returns - inverse of the original value for property - @public - */ - - function not(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return !_emberMetal.get(this, dependentKey); - }); - } - - /** - A computed property that converts the provided dependent property - into a boolean value. - - ```javascript - let Hamster = Ember.Object.extend({ - hasBananas: Ember.computed.bool('numBananas') - }); - - let hamster = Hamster.create(); - - hamster.get('hasBananas'); // false - hamster.set('numBananas', 0); - hamster.get('hasBananas'); // false - hamster.set('numBananas', 1); - hamster.get('hasBananas'); // true - hamster.set('numBananas', null); - hamster.get('hasBananas'); // false - ``` - - @method bool - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which converts - to boolean the original value for property - @public - */ - - function bool(dependentKey) { - return _emberMetal.computed(dependentKey, function () { - return !!_emberMetal.get(this, dependentKey); - }); - } - - /** - A computed property which matches the original value for the - dependent property against a given RegExp, returning `true` - if the value matches the RegExp and `false` if it does not. - - Example - - ```javascript - let User = Ember.Object.extend({ - hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) - }); - - let user = User.create({loggedIn: false}); - - user.get('hasValidEmail'); // false - user.set('email', ''); - user.get('hasValidEmail'); // false - user.set('email', 'ember_hamster@example.com'); - user.get('hasValidEmail'); // true - ``` - - @method match - @for Ember.computed - @param {String} dependentKey - @param {RegExp} regexp - @return {Ember.ComputedProperty} computed property which match - the original value for property against a given RegExp - @public - */ - - function match(dependentKey, regexp) { - return _emberMetal.computed(dependentKey, function () { - var value = _emberMetal.get(this, dependentKey); - - return typeof value === 'string' ? regexp.test(value) : false; - }); - } - - /** - A computed property that returns true if the provided dependent property - is equal to the given value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - napTime: Ember.computed.equal('state', 'sleepy') - }); - - let hamster = Hamster.create(); - - hamster.get('napTime'); // false - hamster.set('state', 'sleepy'); - hamster.get('napTime'); // true - hamster.set('state', 'hungry'); - hamster.get('napTime'); // false - ``` - - @method equal - @for Ember.computed - @param {String} dependentKey - @param {String|Number|Object} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is equal to the given value. - @public - */ - - function equal(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) === value; - }); - } - - /** - A computed property that returns true if the provided dependent property - is greater than the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasTooManyBananas: Ember.computed.gt('numBananas', 10) - }); - - let hamster = Hamster.create(); - - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 3); - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 11); - hamster.get('hasTooManyBananas'); // true - ``` - - @method gt - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is greater than given value. - @public - */ - - function gt(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) > value; - }); - } - - /** - A computed property that returns true if the provided dependent property - is greater than or equal to the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - hasTooManyBananas: Ember.computed.gte('numBananas', 10) - }); - - let hamster = Hamster.create(); - - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 3); - hamster.get('hasTooManyBananas'); // false - hamster.set('numBananas', 10); - hamster.get('hasTooManyBananas'); // true - ``` - - @method gte - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is greater or equal then given value. - @public - */ - - function gte(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) >= value; - }); - } - - /** - A computed property that returns true if the provided dependent property - is less than the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - needsMoreBananas: Ember.computed.lt('numBananas', 3) - }); - - let hamster = Hamster.create(); - - hamster.get('needsMoreBananas'); // true - hamster.set('numBananas', 3); - hamster.get('needsMoreBananas'); // false - hamster.set('numBananas', 2); - hamster.get('needsMoreBananas'); // true - ``` - - @method lt - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is less then given value. - @public - */ - - function lt(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) < value; - }); - } - - /** - A computed property that returns true if the provided dependent property - is less than or equal to the provided value. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - needsMoreBananas: Ember.computed.lte('numBananas', 3) - }); - - let hamster = Hamster.create(); - - hamster.get('needsMoreBananas'); // true - hamster.set('numBananas', 5); - hamster.get('needsMoreBananas'); // false - hamster.set('numBananas', 3); - hamster.get('needsMoreBananas'); // true - ``` - - @method lte - @for Ember.computed - @param {String} dependentKey - @param {Number} value - @return {Ember.ComputedProperty} computed property which returns true if - the original value for property is less or equal than given value. - @public - */ - - function lte(dependentKey, value) { - return _emberMetal.computed(dependentKey, function () { - return _emberMetal.get(this, dependentKey) <= value; - }); - } - - /** - A computed property that performs a logical `and` on the - original values for the provided dependent properties. - - You may pass in more than two properties and even use - property brace expansion. The computed property will - return the first falsy value or last truthy value - just like JavaScript's `&&` operator. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), - readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') - }); - - let tomster = Hamster.create(); - - tomster.get('readyForCamp'); // false - tomster.set('hasTent', true); - tomster.get('readyForCamp'); // false - tomster.set('hasBackpack', true); - tomster.get('readyForCamp'); // true - tomster.set('hasBackpack', 'Yes'); - tomster.get('readyForCamp'); // 'Yes' - tomster.set('hasWalkingStick', null); - tomster.get('readyForHike'); // null - ``` - - @method and - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which performs - a logical `and` on the values of all the original values for properties. - @public - */ - var and = generateComputedWithPredicate('and', function (value) { - return value; - }); - - exports.and = and; - /** - A computed property which performs a logical `or` on the - original values for the provided dependent properties. - - You may pass in more than two properties and even use - property brace expansion. The computed property will - return the first truthy value or last falsy value just - like JavaScript's `||` operator. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'), - readyForBeach: Ember.computed.or('{hasSunscreen,hasUmbrella}') - }); - - let tomster = Hamster.create(); - - tomster.get('readyForRain'); // undefined - tomster.set('hasUmbrella', true); - tomster.get('readyForRain'); // true - tomster.set('hasJacket', 'Yes'); - tomster.get('readyForRain'); // 'Yes' - tomster.set('hasSunscreen', 'Check'); - tomster.get('readyForBeach'); // 'Check' - ``` - - @method or - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which performs - a logical `or` on the values of all the original values for properties. - @public - */ - var or = generateComputedWithPredicate('or', function (value) { - return !value; - }); - - exports.or = or; - /** - Creates a new property that is an alias for another property - on an object. Calls to `get` or `set` this property behave as - though they were called on the original property. - - ```javascript - let Person = Ember.Object.extend({ - name: 'Alex Matchneer', - nomen: Ember.computed.alias('name') - }); - - let alex = Person.create(); - - alex.get('nomen'); // 'Alex Matchneer' - alex.get('name'); // 'Alex Matchneer' - - alex.set('nomen', '@machty'); - alex.get('name'); // '@machty' - ``` - - @method alias - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates an - alias to the original value for property. - @public - */ - - /** - Where `computed.alias` aliases `get` and `set`, and allows for bidirectional - data flow, `computed.oneWay` only provides an aliased `get`. The `set` will - not mutate the upstream property, rather causes the current property to - become the value set. This causes the downstream property to permanently - diverge from the upstream property. - - Example - - ```javascript - let User = Ember.Object.extend({ - firstName: null, - lastName: null, - nickName: Ember.computed.oneWay('firstName') - }); - - let teddy = User.create({ - firstName: 'Teddy', - lastName: 'Zeenny' - }); - - teddy.get('nickName'); // 'Teddy' - teddy.set('nickName', 'TeddyBear'); // 'TeddyBear' - teddy.get('firstName'); // 'Teddy' - ``` - - @method oneWay - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @public - */ - - function oneWay(dependentKey) { - return _emberMetal.alias(dependentKey).oneWay(); - } - - /** - This is a more semantically meaningful alias of `computed.oneWay`, - whose name is somewhat ambiguous as to which direction the data flows. - - @method reads - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @public - */ - - /** - Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides - a readOnly one way binding. Very often when using `computed.oneWay` one does - not also want changes to propagate back up, as they will replace the value. - - This prevents the reverse flow, and also throws an exception when it occurs. - - Example - - ```javascript - let User = Ember.Object.extend({ - firstName: null, - lastName: null, - nickName: Ember.computed.readOnly('firstName') - }); - - let teddy = User.create({ - firstName: 'Teddy', - lastName: 'Zeenny' - }); - - teddy.get('nickName'); // 'Teddy' - teddy.set('nickName', 'TeddyBear'); // throws Exception - // throw new Ember.Error('Cannot Set: nickName on: ' );` - teddy.get('firstName'); // 'Teddy' - ``` - - @method readOnly - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computed property which creates a - one way computed property to the original value for property. - @since 1.5.0 - @public - */ - - function readOnly(dependentKey) { - return _emberMetal.alias(dependentKey).readOnly(); - } - - /** - Creates a new property that is an alias for another property - on an object. Calls to `get` or `set` this property behave as - though they were called on the original property, but also - print a deprecation warning. - - ```javascript - let Hamster = Ember.Object.extend({ - bananaCount: Ember.computed.deprecatingAlias('cavendishCount', { - id: 'hamster.deprecate-banana', - until: '3.0.0' - }) - }); - - let hamster = Hamster.create(); - - hamster.set('bananaCount', 5); // Prints a deprecation warning. - hamster.get('cavendishCount'); // 5 - ``` - - @method deprecatingAlias - @for Ember.computed - @param {String} dependentKey - @param {Object} options Options for `Ember.deprecate`. - @return {Ember.ComputedProperty} computed property which creates an - alias with a deprecation to the original value for property. - @since 1.7.0 - @public - */ - - function deprecatingAlias(dependentKey, options) { - return _emberMetal.computed(dependentKey, { - get: function (key) { - return _emberMetal.get(this, dependentKey); - }, - set: function (key, value) { - _emberMetal.set(this, dependentKey, value); - return value; - } - }); - } -}); -enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - exports.sum = sum; - exports.max = max; - exports.min = min; - exports.map = map; - exports.mapBy = mapBy; - exports.filter = filter; - exports.filterBy = filterBy; - exports.uniq = uniq; - exports.uniqBy = uniqBy; - exports.intersect = intersect; - exports.setDiff = setDiff; - exports.collect = collect; - exports.sort = sort; - - function reduceMacro(dependentKey, callback, initialValue) { - return _emberMetal.computed(dependentKey + '.[]', function () { - var _this = this; - - var arr = _emberMetal.get(this, dependentKey); - - if (arr === null || typeof arr !== 'object') { - return initialValue; - } - - return arr.reduce(function (previousValue, currentValue, index, array) { - return callback.call(_this, previousValue, currentValue, index, array); - }, initialValue); - }).readOnly(); - } - - function arrayMacro(dependentKey, callback) { - // This is a bit ugly - var propertyName = undefined; - if (/@each/.test(dependentKey)) { - propertyName = dependentKey.replace(/\.@each.*$/, ''); - } else { - propertyName = dependentKey; - dependentKey += '.[]'; - } - - return _emberMetal.computed(dependentKey, function () { - var value = _emberMetal.get(this, propertyName); - if (_emberRuntimeUtils.isArray(value)) { - return _emberRuntimeSystemNative_array.A(callback.call(this, value)); - } else { - return _emberRuntimeSystemNative_array.A(); - } - }).readOnly(); - } - - function multiArrayMacro(dependentKeys, callback) { - var args = dependentKeys.map(function (key) { - return key + '.[]'; - }); - - args.push(function () { - return _emberRuntimeSystemNative_array.A(callback.call(this, dependentKeys)); - }); - - return _emberMetal.computed.apply(this, args).readOnly(); - } - - /** - A computed property that returns the sum of the values - in the dependent array. - - @method sum - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the sum of all values in the dependentKey's array - @since 1.4.0 - @public - */ - - function sum(dependentKey) { - return reduceMacro(dependentKey, function (sum, item) { - return sum + item; - }, 0); - } - - /** - A computed property that calculates the maximum value in the - dependent array. This will return `-Infinity` when the dependent - array is empty. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age'), - maxChildAge: Ember.computed.max('childAges') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('maxChildAge'); // -Infinity - lordByron.get('children').pushObject({ - name: 'Augusta Ada Byron', age: 7 - }); - lordByron.get('maxChildAge'); // 7 - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('maxChildAge'); // 8 - ``` - - If the types of the arguments are not numbers, - they will be converted to numbers and the type - of the return value will always be `Number`. - For example, the max of a list of Date objects will be - the highest timestamp as a `Number`. - This behavior is consistent with `Math.max`. - - @method max - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array - @public - */ - - function max(dependentKey) { - return reduceMacro(dependentKey, function (max, item) { - return Math.max(max, item); - }, -Infinity); - } - - /** - A computed property that calculates the minimum value in the - dependent array. This will return `Infinity` when the dependent - array is empty. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age'), - minChildAge: Ember.computed.min('childAges') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('minChildAge'); // Infinity - lordByron.get('children').pushObject({ - name: 'Augusta Ada Byron', age: 7 - }); - lordByron.get('minChildAge'); // 7 - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('minChildAge'); // 5 - ``` - - If the types of the arguments are not numbers, - they will be converted to numbers and the type - of the return value will always be `Number`. - For example, the min of a list of Date objects will be - the lowest timestamp as a `Number`. - This behavior is consistent with `Math.min`. - - @method min - @for Ember.computed - @param {String} dependentKey - @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array - @public - */ - - function min(dependentKey) { - return reduceMacro(dependentKey, function (min, item) { - return Math.min(min, item); - }, Infinity); - } - - /** - Returns an array mapped via the callback - - The callback method you provide should have the following signature. - `item` is the current item in the iteration. - `index` is the integer index of the current item in the iteration. - - ```javascript - function(item, index); - ``` - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - excitingChores: Ember.computed.map('chores', function(chore, index) { - return chore.toUpperCase() + '!'; - }) - }); - - let hamster = Hamster.create({ - chores: ['clean', 'write more unit tests'] - }); - - hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] - ``` - - @method map - @for Ember.computed - @param {String} dependentKey - @param {Function} callback - @return {Ember.ComputedProperty} an array mapped via the callback - @public - */ - - function map(dependentKey, callback) { - return arrayMacro(dependentKey, function (value) { - return value.map(callback, this); - }); - } - - /** - Returns an array mapped to the specified key. - - ```javascript - let Person = Ember.Object.extend({ - childAges: Ember.computed.mapBy('children', 'age') - }); - - let lordByron = Person.create({ children: [] }); - - lordByron.get('childAges'); // [] - lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); - lordByron.get('childAges'); // [7] - lordByron.get('children').pushObjects([{ - name: 'Allegra Byron', - age: 5 - }, { - name: 'Elizabeth Medora Leigh', - age: 8 - }]); - lordByron.get('childAges'); // [7, 5, 8] - ``` - - @method mapBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @return {Ember.ComputedProperty} an array mapped to the specified key - @public - */ - - function mapBy(dependentKey, propertyKey) { - - return map(dependentKey + '.@each.' + propertyKey, function (item) { - return _emberMetal.get(item, propertyKey); - }); - } - - /** - Filters the array by the callback. - - The callback method you provide should have the following signature. - `item` is the current item in the iteration. - `index` is the integer index of the current item in the iteration. - `array` is the dependant array itself. - - ```javascript - function(item, index, array); - ``` - - ```javascript - let Hamster = Ember.Object.extend({ - remainingChores: Ember.computed.filter('chores', function(chore, index, array) { - return !chore.done; - }) - }); - - let hamster = Hamster.create({ - chores: [ - { name: 'cook', done: true }, - { name: 'clean', done: true }, - { name: 'write more unit tests', done: false } - ] - }); - - hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] - ``` - - @method filter - @for Ember.computed - @param {String} dependentKey - @param {Function} callback - @return {Ember.ComputedProperty} the filtered array - @public - */ - - function filter(dependentKey, callback) { - return arrayMacro(dependentKey, function (value) { - return value.filter(callback, this); - }); - } - - /** - Filters the array by the property and value - - ```javascript - let Hamster = Ember.Object.extend({ - remainingChores: Ember.computed.filterBy('chores', 'done', false) - }); - - let hamster = Hamster.create({ - chores: [ - { name: 'cook', done: true }, - { name: 'clean', done: true }, - { name: 'write more unit tests', done: false } - ] - }); - - hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] - ``` - - @method filterBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @param {*} value - @return {Ember.ComputedProperty} the filtered array - @public - */ - - function filterBy(dependentKey, propertyKey, value) { - var callback = undefined; - - if (arguments.length === 2) { - callback = function (item) { - return _emberMetal.get(item, propertyKey); - }; - } else { - callback = function (item) { - return _emberMetal.get(item, propertyKey) === value; - }; - } - - return filter(dependentKey + '.@each.' + propertyKey, callback); - } - - /** - A computed property which returns a new array with all the unique - elements from one or more dependent arrays. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - uniqueFruits: Ember.computed.uniq('fruits') - }); - - let hamster = Hamster.create({ - fruits: [ - 'banana', - 'grape', - 'kale', - 'banana' - ] - }); - - hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale'] - ``` - - @method uniq - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ - - function uniq() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return multiArrayMacro(args, function (dependentKeys) { - var _this2 = this; - - var uniq = _emberRuntimeSystemNative_array.A(); - - dependentKeys.forEach(function (dependentKey) { - var value = _emberMetal.get(_this2, dependentKey); - if (_emberRuntimeUtils.isArray(value)) { - value.forEach(function (item) { - if (uniq.indexOf(item) === -1) { - uniq.push(item); - } - }); - } - }); - - return uniq; - }); - } - - /** - A computed property which returns a new array with all the unique - elements from an array, with uniqueness determined by specific key. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - uniqueFruits: Ember.computed.uniqBy('fruits', 'id') - }); - let hamster = Hamster.create({ - fruits: [ - { id: 1, 'banana' }, - { id: 2, 'grape' }, - { id: 3, 'peach' }, - { id: 1, 'banana' } - ] - }); - hamster.get('uniqueFruits'); // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }] - ``` - - @method uniqBy - @for Ember.computed - @param {String} dependentKey - @param {String} propertyKey - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ - - function uniqBy(dependentKey, propertyKey) { - return _emberMetal.computed(dependentKey + '.[]', function () { - var uniq = _emberRuntimeSystemNative_array.A(); - var seen = new _emberUtils.EmptyObject(); - var list = _emberMetal.get(this, dependentKey); - if (_emberRuntimeUtils.isArray(list)) { - list.forEach(function (item) { - var guid = _emberUtils.guidFor(_emberMetal.get(item, propertyKey)); - if (!(guid in seen)) { - seen[guid] = true; - uniq.push(item); - } - }); - } - return uniq; - }).readOnly(); - } - - /** - Alias for [Ember.computed.uniq](/api/#method_computed_uniq). - - @method union - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - unique elements from the dependent array - @public - */ - var union = uniq; - - exports.union = union; - /** - A computed property which returns a new array with all the duplicated - elements from two or more dependent arrays. - - Example - - ```javascript - let obj = Ember.Object.extend({ - friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') - }).create({ - adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], - charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'] - }); - - obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] - ``` - - @method intersect - @for Ember.computed - @param {String} propertyKey* - @return {Ember.ComputedProperty} computes a new array with all the - duplicated elements from the dependent arrays - @public - */ - - function intersect() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return multiArrayMacro(args, function (dependentKeys) { - var _this3 = this; - - var arrays = dependentKeys.map(function (dependentKey) { - var array = _emberMetal.get(_this3, dependentKey); - - return _emberRuntimeUtils.isArray(array) ? array : []; - }); - - var results = arrays.pop().filter(function (candidate) { - for (var i = 0; i < arrays.length; i++) { - var found = false; - var array = arrays[i]; - for (var j = 0; j < array.length; j++) { - if (array[j] === candidate) { - found = true; - break; - } - } - - if (found === false) { - return false; - } - } - - return true; - }); - - return _emberRuntimeSystemNative_array.A(results); - }); - } - - /** - A computed property which returns a new array with all the - properties from the first dependent array that are not in the second - dependent array. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - likes: ['banana', 'grape', 'kale'], - wants: Ember.computed.setDiff('likes', 'fruits') - }); - - let hamster = Hamster.create({ - fruits: [ - 'grape', - 'kale', - ] - }); - - hamster.get('wants'); // ['banana'] - ``` - - @method setDiff - @for Ember.computed - @param {String} setAProperty - @param {String} setBProperty - @return {Ember.ComputedProperty} computes a new array with all the - items from the first dependent array that are not in the second - dependent array - @public - */ - - function setDiff(setAProperty, setBProperty) { - if (arguments.length !== 2) { - throw new _emberMetal.Error('setDiff requires exactly two dependent arrays.'); - } - - return _emberMetal.computed(setAProperty + '.[]', setBProperty + '.[]', function () { - var setA = this.get(setAProperty); - var setB = this.get(setBProperty); - - if (!_emberRuntimeUtils.isArray(setA)) { - return _emberRuntimeSystemNative_array.A(); - } - if (!_emberRuntimeUtils.isArray(setB)) { - return _emberRuntimeSystemNative_array.A(setA); - } - - return setA.filter(function (x) { - return setB.indexOf(x) === -1; - }); - }).readOnly(); - } - - /** - A computed property that returns the array of values - for the provided dependent properties. - - Example - - ```javascript - let Hamster = Ember.Object.extend({ - clothes: Ember.computed.collect('hat', 'shirt') - }); - - let hamster = Hamster.create(); - - hamster.get('clothes'); // [null, null] - hamster.set('hat', 'Camp Hat'); - hamster.set('shirt', 'Camp Shirt'); - hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] - ``` - - @method collect - @for Ember.computed - @param {String} dependentKey* - @return {Ember.ComputedProperty} computed property which maps - values of all passed in properties to an array. - @public - */ - - function collect() { - for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - dependentKeys[_key3] = arguments[_key3]; - } - - return multiArrayMacro(dependentKeys, function () { - var properties = _emberMetal.getProperties(this, dependentKeys); - var res = _emberRuntimeSystemNative_array.A(); - for (var key in properties) { - if (properties.hasOwnProperty(key)) { - if (_emberMetal.isNone(properties[key])) { - res.push(null); - } else { - res.push(properties[key]); - } - } - } - return res; - }); - } - - /** - A computed property which returns a new array with all the - properties from the first dependent array sorted based on a property - or sort function. - - The callback method you provide should have the following signature: - - ```javascript - function(itemA, itemB); - ``` - - - `itemA` the first item to compare. - - `itemB` the second item to compare. - - This function should return negative number (e.g. `-1`) when `itemA` should come before - `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after - `itemB`. If the `itemA` and `itemB` are equal this function should return `0`. - - Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or - `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`. - - Example - - ```javascript - let ToDoList = Ember.Object.extend({ - // using standard ascending sort - todosSorting: ['name'], - sortedTodos: Ember.computed.sort('todos', 'todosSorting'), - - // using descending sort - todosSortingDesc: ['name:desc'], - sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), - - // using a custom sort function - priorityTodos: Ember.computed.sort('todos', function(a, b){ - if (a.priority > b.priority) { - return 1; - } else if (a.priority < b.priority) { - return -1; - } - - return 0; - }) - }); - - let todoList = ToDoList.create({todos: [ - { name: 'Unit Test', priority: 2 }, - { name: 'Documentation', priority: 3 }, - { name: 'Release', priority: 1 } - ]}); - - todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }] - todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }] - todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }] - ``` - - @method sort - @for Ember.computed - @param {String} itemsKey - @param {String or Function} sortDefinition a dependent key to an - array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting - @return {Ember.ComputedProperty} computes a new sorted array based - on the sort property array or callback function - @public - */ - - function sort(itemsKey, sortDefinition) { - - if (typeof sortDefinition === 'function') { - return customSort(itemsKey, sortDefinition); - } else { - return propertySort(itemsKey, sortDefinition); - } - } - - function customSort(itemsKey, comparator) { - return arrayMacro(itemsKey, function (value) { - var _this4 = this; - - return value.slice().sort(function (x, y) { - return comparator.call(_this4, x, y); - }); - }); - } - - // This one needs to dynamically set up and tear down observers on the itemsKey - // depending on the sortProperties - function propertySort(itemsKey, sortPropertiesKey) { - var cp = new _emberMetal.ComputedProperty(function (key) { - var _this5 = this; - - var itemsKeyIsAtThis = itemsKey === '@this'; - var sortProperties = _emberMetal.get(this, sortPropertiesKey); - - var normalizedSortProperties = normalizeSortProperties(sortProperties); - - // Add/remove property observers as required. - var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetal.WeakMap()); - var activeObservers = activeObserversMap.get(this); - - if (activeObservers) { - activeObservers.forEach(function (args) { - return _emberMetal.removeObserver.apply(null, args); - }); - } - - function sortPropertyDidChange() { - this.notifyPropertyChange(key); - } - - activeObservers = normalizedSortProperties.map(function (_ref) { - var prop = _ref[0]; - - var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; - var args = [_this5, path, sortPropertyDidChange]; - _emberMetal.addObserver.apply(null, args); - return args; - }); - - activeObserversMap.set(this, activeObservers); - - // Sort and return the array. - var items = itemsKeyIsAtThis ? this : _emberMetal.get(this, itemsKey); - - if (_emberRuntimeUtils.isArray(items)) { - return sortByNormalizedSortProperties(items, normalizedSortProperties); - } else { - return _emberRuntimeSystemNative_array.A(); - } - }); - - cp._activeObserverMap = undefined; - - return cp.property(sortPropertiesKey + '.[]').readOnly(); - } - - 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]; - }); - } - - 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(_emberMetal.get(itemA, prop), _emberMetal.get(itemB, prop)); - if (result !== 0) { - return direction === 'desc' ? -1 * result : result; - } - } - - return 0; - })); - } -}); -enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) { - 'use strict'; - - /** - @module ember - @submodule ember-runtime - */ - - /** - @class Controller - @namespace Ember - @extends Ember.Object - @uses Ember.ControllerMixin - @public - */ - var Controller = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsController.default); - - _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions(Controller); - - function controllerInjectionHelper(factory) {} - - /** - Creates a property that lazily looks up another controller in the container. - Can only be used when defining another controller. - - Example: - - ```javascript - App.PostController = Ember.Controller.extend({ - posts: Ember.inject.controller() - }); - ``` - - This example will create a `posts` property on the `post` controller that - looks up the `posts` controller in the container, making it easy to - reference other controllers. This is functionally equivalent to: - - ```javascript - App.PostController = Ember.Controller.extend({ - needs: 'posts', - posts: Ember.computed.alias('controllers.posts') - }); - ``` - - @method controller - @since 1.10.0 - @for Ember.inject - @param {String} name (optional) name of the controller to inject, defaults - to the property's name - @return {Ember.InjectedProperty} injection descriptor instance - @public - */ - _emberRuntimeInject.createInjectionHelper('controller', controllerInjectionHelper); - - exports.default = Controller; -}); -enifed('ember-runtime/copy', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) { - 'use strict'; - - exports.default = copy; - - function _copy(obj, deep, seen, copies) { - var ret = undefined, - loc = undefined, - key = undefined; - - // primitive data types are immutable, just return them. - if (typeof obj !== 'object' || obj === null) { - return obj; - } - - // avoid cyclical loops - if (deep && (loc = seen.indexOf(obj)) >= 0) { - return copies[loc]; - } - - // IMPORTANT: this specific test will detect a native array only. Any other - // object will need to implement Copyable. - if (Array.isArray(obj)) { - ret = obj.slice(); - - if (deep) { - loc = ret.length; - - while (--loc >= 0) { - ret[loc] = _copy(ret[loc], deep, seen, copies); - } - } - } else if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { - ret = obj.copy(deep, seen, copies); - } else if (obj instanceof Date) { - ret = new Date(obj.getTime()); - } else { - ret = {}; - - for (key in obj) { - // support Null prototype - if (!Object.prototype.hasOwnProperty.call(obj, key)) { - continue; - } - - // Prevents browsers that don't respect non-enumerability from - // copying internal Ember properties - if (key.substring(0, 2) === '__') { - continue; - } - - ret[key] = deep ? _copy(obj[key], deep, seen, copies) : obj[key]; - } - } - - if (deep) { - seen.push(obj); - copies.push(ret); - } - - return ret; - } - - /** - Creates a shallow copy of the passed object. A deep copy of the object is - returned if the optional `deep` argument is `true`. - - If the passed object implements the `Ember.Copyable` interface, then this - function will delegate to the object's `copy()` method and return the - result. See `Ember.Copyable` for further details. - - For primitive values (which are immutable in JavaScript), the passed object - is simply returned. - - @method copy - @for Ember - @param {Object} obj The object to clone - @param {Boolean} [deep=false] If true, a deep copy of the object is made. - @return {Object} The copied object - @public - */ - - function copy(obj, deep) { - // fast paths - if ('object' !== typeof obj || obj === null) { - return obj; // can't copy primitives - } - - if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { - return obj.copy(deep); - } - - return _copy(obj, deep, deep ? [] : null, deep ? [] : null); - } -}); -enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - var a_slice = Array.prototype.slice; - var FunctionPrototype = Function.prototype; - - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { - /** - The `property` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - `true`, which is the default. - Computed properties allow you to treat a function like a property: - ```javascript - MyApp.President = Ember.Object.extend({ - firstName: '', - lastName: '', - fullName: function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }.property() // Call this flag to mark the function as a property - }); - let president = MyApp.President.create({ - firstName: 'Barack', - lastName: 'Obama' - }); - president.get('fullName'); // 'Barack Obama' - ``` - Treating a function like a property is useful because they can work with - bindings, just like any other property. - Many computed properties have dependencies on other properties. For - example, in the above example, the `fullName` property depends on - `firstName` and `lastName` to determine its value. You can tell Ember - about these dependencies like this: - ```javascript - MyApp.President = Ember.Object.extend({ - firstName: '', - lastName: '', - fullName: function() { - return this.get('firstName') + ' ' + this.get('lastName'); - // Tell Ember.js that this computed property depends on firstName - // and lastName - }.property('firstName', 'lastName') - }); - ``` - Make sure you list these dependencies so Ember knows when to update - bindings that connect to a computed property. Changing a dependency - will not immediately trigger an update of the computed property, but - will instead clear the cache so that it is updated when the next `get` - is called on the property. - See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/classes/Ember.computed.html). - @method property - @for Function - @public - */ - FunctionPrototype.property = function () { - var ret = _emberMetal.computed(this); - // ComputedProperty.prototype.property expands properties; no need for us to - // do so here. - return ret.property.apply(ret, arguments); - }; - - /** - The `observes` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - true, which is the default. - You can observe property changes simply by adding the `observes` - call to the end of your method declarations in classes that you write. - For example: - ```javascript - Ember.Object.extend({ - valueObserver: function() { - // Executes whenever the "value" property changes - }.observes('value') - }); - ``` - In the future this method may become asynchronous. - See `Ember.observer`. - @method observes - @for Function - @public - */ - FunctionPrototype.observes = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - args.push(this); - return _emberMetal.observer.apply(this, args); - }; - - FunctionPrototype._observesImmediately = function () { - - // observes handles property expansion - return this.observes.apply(this, arguments); - }; - /** - The `observesImmediately` extension of Javascript's Function prototype is - available when `EmberENV.EXTEND_PROTOTYPES` or - `EmberENV.EXTEND_PROTOTYPES.Function` is true, which is the default. - You can observe property changes simply by adding the `observesImmediately` - call to the end of your method declarations in classes that you write. - For example: - ```javascript - Ember.Object.extend({ - valueObserver: function() { - // Executes immediately after the "value" property changes - }.observesImmediately('value') - }); - ``` - In the future, `observes` may become asynchronous. In this event, - `observesImmediately` will maintain the synchronous behavior. - See `Ember.immediateObserver`. - @method observesImmediately - @for Function - @deprecated - @private - */ - FunctionPrototype.observesImmediately = _emberMetal.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately); - - /** - The `on` extension of Javascript's Function prototype is available - when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is - true, which is the default. - You can listen for events simply by adding the `on` call to the end of - your method declarations in classes or mixins that you write. For example: - ```javascript - Ember.Mixin.create({ - doSomethingWithElement: function() { - // Executes whenever the "didInsertElement" event fires - }.on('didInsertElement') - }); - ``` - See `Ember.on`. - @method on - @for Function - @public - */ - FunctionPrototype.on = function () { - var events = a_slice.call(arguments); - this.__ember_listens__ = events; - - return this; - }; - } -}); -enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal'], function (exports, _rsvp, _emberMetal) { - 'use strict'; - - exports.onerrorDefault = onerrorDefault; - - var backburner = _emberMetal.run.backburner; - _emberMetal.run._addQueue('rsvpAfter', 'destroy'); - - _rsvp.configure('async', function (callback, promise) { - backburner.schedule('actions', null, callback, promise); - }); - - _rsvp.configure('after', function (cb) { - backburner.schedule('rsvpAfter', null, cb); - }); - - _rsvp.on('error', onerrorDefault); - - function onerrorDefault(reason) { - var error = errorFor(reason); - if (error) { - _emberMetal.dispatchError(error); - } - } - - function errorFor(reason) { - if (!reason) return; - - if (reason.errorThrown) { - return unwrapErrorThrown(reason); - } - - if (reason.name === 'UnrecognizedURLError') { - return; - } - - if (reason.name === 'TransitionAborted') { - return; - } - - return reason; - } - - function unwrapErrorThrown(reason) { - var error = reason.errorThrown; - if (typeof error === 'string') { - error = new Error(error); - } - Object.defineProperty(error, '__reason_with_error_thrown__', { - value: reason, - enumerable: false - }); - return error; - } - - exports.default = _rsvp; -}); -enifed('ember-runtime/ext/string', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - var StringPrototype = String.prototype; - - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { - /** - See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt). - @method fmt - @for String - @private - @deprecated - */ - StringPrototype.fmt = function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _emberRuntimeSystemString.fmt(this, args); - }; - - /** - See [Ember.String.w](/api/classes/Ember.String.html#method_w). - @method w - @for String - @private - */ - StringPrototype.w = function () { - return _emberRuntimeSystemString.w(this); - }; - - /** - See [Ember.String.loc](/api/classes/Ember.String.html#method_loc). - @method loc - @for String - @private - */ - StringPrototype.loc = function () { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return _emberRuntimeSystemString.loc(this, args); - }; - - /** - See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize). - @method camelize - @for String - @private - */ - StringPrototype.camelize = function () { - return _emberRuntimeSystemString.camelize(this); - }; - - /** - See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize). - @method decamelize - @for String - @private - */ - StringPrototype.decamelize = function () { - return _emberRuntimeSystemString.decamelize(this); - }; - - /** - See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize). - @method dasherize - @for String - @private - */ - StringPrototype.dasherize = function () { - return _emberRuntimeSystemString.dasherize(this); - }; - - /** - See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore). - @method underscore - @for String - @private - */ - StringPrototype.underscore = function () { - return _emberRuntimeSystemString.underscore(this); - }; - - /** - See [Ember.String.classify](/api/classes/Ember.String.html#method_classify). - @method classify - @for String - @private - */ - StringPrototype.classify = function () { - return _emberRuntimeSystemString.classify(this); - }; - - /** - See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize). - @method capitalize - @for String - @private - */ - StringPrototype.capitalize = function () { - return _emberRuntimeSystemString.capitalize(this); - }; - } -}); -enifed('ember-runtime/index', ['exports', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/system/object', 'ember-runtime/system/string', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/compare', 'ember-runtime/is-equal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/system/namespace', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeSystemObject, _emberRuntimeSystemString, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeCompare, _emberRuntimeIsEqual, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeSystemNamespace, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsObservable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeUtils, _emberRuntimeString_registry) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - exports.Object = _emberRuntimeSystemObject.default; - exports.FrameworkObject = _emberRuntimeSystemObject.FrameworkObject; - exports.String = _emberRuntimeSystemString.default; - exports.RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default; - exports.buildFakeRegistryWithDeprecations = _emberRuntimeMixinsRegistry_proxy.buildFakeRegistryWithDeprecations; - exports.ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default; - exports.copy = _emberRuntimeCopy.default; - exports.inject = _emberRuntimeInject.default; - exports.compare = _emberRuntimeCompare.default; - exports.isEqual = _emberRuntimeIsEqual.default; - exports.Array = _emberRuntimeMixinsArray.default; - exports.objectAt = _emberRuntimeMixinsArray.objectAt; - exports.isEmberArray = _emberRuntimeMixinsArray.isEmberArray; - exports.addArrayObserver = _emberRuntimeMixinsArray.addArrayObserver; - exports.removeArrayObserver = _emberRuntimeMixinsArray.removeArrayObserver; - exports.Comparable = _emberRuntimeMixinsComparable.default; - exports.Namespace = _emberRuntimeSystemNamespace.default; - exports.isNamespaceSearchDisabled = _emberRuntimeSystemNamespace.isSearchDisabled; - exports.setNamespaceSearchDisabled = _emberRuntimeSystemNamespace.setSearchDisabled; - exports.ArrayProxy = _emberRuntimeSystemArray_proxy.default; - exports.ObjectProxy = _emberRuntimeSystemObject_proxy.default; - exports.CoreObject = _emberRuntimeSystemCore_object.default; - exports.NativeArray = _emberRuntimeSystemNative_array.default; - exports.A = _emberRuntimeSystemNative_array.A; - exports.ActionHandler = _emberRuntimeMixinsAction_handler.default; - exports.deprecateUnderscoreActions = _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions; - exports.Copyable = _emberRuntimeMixinsCopyable.default; - exports.Enumerable = _emberRuntimeMixinsEnumerable.default; - exports.Freezable = _emberRuntimeMixinsFreezable.Freezable; - exports.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR; - exports._ProxyMixin = _emberRuntimeMixinsProxy.default; - exports.onLoad = _emberRuntimeSystemLazy_load.onLoad; - exports.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks; - exports._loaded = _emberRuntimeSystemLazy_load._loaded; - exports.Observable = _emberRuntimeMixinsObservable.default; - exports.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default; - exports.MutableArray = _emberRuntimeMixinsMutable_array.default; - exports.removeAt = _emberRuntimeMixinsMutable_array.removeAt; - exports.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default; - exports.Evented = _emberRuntimeMixinsEvented.default; - exports.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default; - exports.empty = _emberRuntimeComputedComputed_macros.empty; - exports.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty; - exports.none = _emberRuntimeComputedComputed_macros.none; - exports.not = _emberRuntimeComputedComputed_macros.not; - exports.bool = _emberRuntimeComputedComputed_macros.bool; - exports.match = _emberRuntimeComputedComputed_macros.match; - exports.equal = _emberRuntimeComputedComputed_macros.equal; - exports.gt = _emberRuntimeComputedComputed_macros.gt; - exports.gte = _emberRuntimeComputedComputed_macros.gte; - exports.lt = _emberRuntimeComputedComputed_macros.lt; - exports.lte = _emberRuntimeComputedComputed_macros.lte; - exports.oneWay = _emberRuntimeComputedComputed_macros.oneWay; - exports.readOnly = _emberRuntimeComputedComputed_macros.readOnly; - exports.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias; - exports.and = _emberRuntimeComputedComputed_macros.and; - exports.or = _emberRuntimeComputedComputed_macros.or; - exports.sum = _emberRuntimeComputedReduce_computed_macros.sum; - exports.min = _emberRuntimeComputedReduce_computed_macros.min; - exports.max = _emberRuntimeComputedReduce_computed_macros.max; - exports.map = _emberRuntimeComputedReduce_computed_macros.map; - exports.sort = _emberRuntimeComputedReduce_computed_macros.sort; - exports.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff; - exports.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy; - exports.filter = _emberRuntimeComputedReduce_computed_macros.filter; - exports.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy; - exports.uniq = _emberRuntimeComputedReduce_computed_macros.uniq; - exports.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy; - exports.union = _emberRuntimeComputedReduce_computed_macros.union; - exports.intersect = _emberRuntimeComputedReduce_computed_macros.intersect; - exports.collect = _emberRuntimeComputedReduce_computed_macros.collect; - exports.Controller = _emberRuntimeControllersController.default; - exports.ControllerMixin = _emberRuntimeMixinsController.default; - exports.Service = _emberRuntimeSystemService.default; - exports.RSVP = _emberRuntimeExtRsvp.default; - exports.onerrorDefault = _emberRuntimeExtRsvp.onerrorDefault; - // just for side effect of extending Ember.RSVP - exports.isArray = _emberRuntimeUtils.isArray; - exports.typeOf = _emberRuntimeUtils.typeOf; - exports.getStrings = _emberRuntimeString_registry.getStrings; - exports.setStrings = _emberRuntimeString_registry.setStrings; -}); -// just for side effect of extending String.prototype -// just for side effect of extending Function.prototype -enifed('ember-runtime/inject', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - exports.default = inject; - exports.createInjectionHelper = createInjectionHelper; - exports.validatePropertyInjections = validatePropertyInjections; - - /** - Namespace for injection helper methods. - - @class inject - @namespace Ember - @static - @public - */ - - function inject() {} - - // Dictionary of injection validations by type, added to by `createInjectionHelper` - var typeValidators = {}; - - /** - This method allows other Ember modules to register injection helpers for a - given container type. Helpers are exported to the `inject` namespace as the - container type itself. - - @private - @method createInjectionHelper - @since 1.10.0 - @for Ember - @param {String} type The container type the helper will inject - @param {Function} validator A validation callback that is executed at mixin-time - */ - - function createInjectionHelper(type, validator) { - typeValidators[type] = validator; - - inject[type] = function (name) { - return new _emberMetal.InjectedProperty(type, name); - }; - } - - /** - Validation function that runs per-type validation functions once for each - injected type encountered. - - @private - @method validatePropertyInjections - @since 1.10.0 - @for Ember - @param {Object} factory The factory object - */ - - function validatePropertyInjections(factory) { - var proto = factory.proto(); - var types = []; - - for (var key in proto) { - var desc = proto[key]; - if (desc instanceof _emberMetal.InjectedProperty && types.indexOf(desc.type) === -1) { - types.push(desc.type); - } - } - - if (types.length) { - for (var i = 0; i < types.length; i++) { - var validator = typeValidators[types[i]]; - - if (typeof validator === 'function') { - validator(factory); - } - } - } - - return true; - } -}); -enifed('ember-runtime/is-equal', ['exports'], function (exports) { - /** - Compares two objects, returning true if they are equal. - - ```javascript - Ember.isEqual('hello', 'hello'); // true - Ember.isEqual(1, 2); // false - ``` - - `isEqual` is a more specific comparison than a triple equal comparison. - It will call the `isEqual` instance method on the objects being - compared, allowing finer control over when objects should be considered - equal to each other. - - ```javascript - let Person = Ember.Object.extend({ - isEqual(other) { return this.ssn == other.ssn; } - }); - - let personA = Person.create({name: 'Muhammad Ali', ssn: '123-45-6789'}); - let personB = Person.create({name: 'Cassius Clay', ssn: '123-45-6789'}); - - Ember.isEqual(personA, personB); // true - ``` - - Due to the expense of array comparisons, collections will never be equal to - each other even if each of their items are equal to each other. - - ```javascript - Ember.isEqual([4, 2], [4, 2]); // false - ``` - - @method isEqual - @for Ember - @param {Object} a first object to compare - @param {Object} b second object to compare - @return {Boolean} - @public - */ - 'use strict'; - - exports.default = isEqual; - - function isEqual(a, b) { - if (a && typeof a.isEqual === 'function') { - return a.isEqual(b); - } - - if (a instanceof Date && b instanceof Date) { - return a.getTime() === b.getTime(); - } - - return a === b; - } -}); -enifed('ember-runtime/mixins/-proxy', ['exports', 'glimmer-reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - function contentPropertyWillChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { - return; - } // if shadowed in proxy - _emberMetal.propertyWillChange(this, key); - } - - function contentPropertyDidChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { - return; - } // if shadowed in proxy - _emberMetal.propertyDidChange(this, key); - } - - var ProxyTag = (function (_CachedTag) { - babelHelpers.inherits(ProxyTag, _CachedTag); - - function ProxyTag(proxy) { - _CachedTag.call(this); - - var content = _emberMetal.get(proxy, 'content'); - - this.proxy = proxy; - this.proxyWrapperTag = new _glimmerReference.DirtyableTag(); - this.proxyContentTag = new _glimmerReference.UpdatableTag(_emberMetal.tagFor(content)); - } - - /** - `Ember.ProxyMixin` forwards all properties not defined by the proxy itself - to a proxied `content` object. See Ember.ObjectProxy for more details. - - @class ProxyMixin - @namespace Ember - @private - */ - - ProxyTag.prototype.compute = function compute() { - return Math.max(this.proxyWrapperTag.value(), this.proxyContentTag.value()); - }; - - ProxyTag.prototype.dirty = function dirty() { - this.proxyWrapperTag.dirty(); - }; - - ProxyTag.prototype.contentDidChange = function contentDidChange() { - var content = _emberMetal.get(this.proxy, 'content'); - this.proxyContentTag.update(_emberMetal.tagFor(content)); - }; - - return ProxyTag; - })(_glimmerReference.CachedTag); - - exports.default = _emberMetal.Mixin.create({ - /** - The object whose properties will be forwarded. - @property content - @type Ember.Object - @default null - @private - */ - content: null, - - init: function () { - this._super.apply(this, arguments); - _emberMetal.meta(this).setProxy(); - }, - - _initializeTag: _emberMetal.on('init', function () { - _emberMetal.meta(this)._tag = new ProxyTag(this); - }), - - _contentDidChange: _emberMetal.observer('content', function () { - _emberMetal.tagFor(this).contentDidChange(); - }), - - isTruthy: _emberRuntimeComputedComputed_macros.bool('content'), - - _debugContainerKey: null, - - willWatchProperty: function (key) { - var contentKey = 'content.' + key; - _emberMetal._addBeforeObserver(this, contentKey, null, contentPropertyWillChange); - _emberMetal.addObserver(this, contentKey, null, contentPropertyDidChange); - }, - - didUnwatchProperty: function (key) { - var contentKey = 'content.' + key; - _emberMetal._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); - _emberMetal.removeObserver(this, contentKey, null, contentPropertyDidChange); - }, - - unknownProperty: function (key) { - var content = _emberMetal.get(this, 'content'); - if (content) { - return _emberMetal.get(content, key); - } - }, - - setUnknownProperty: function (key, value) { - var m = _emberMetal.meta(this); - if (m.proto === this) { - // if marked as prototype then just defineProperty - // rather than delegate - _emberMetal.defineProperty(this, key, null, value); - return value; - } - - var content = _emberMetal.get(this, 'content'); - - return _emberMetal.set(content, key, value); - } - }); -}); -enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - exports.deprecateUnderscoreActions = deprecateUnderscoreActions; - - /** - `Ember.ActionHandler` is available on some familiar classes including - `Ember.Route`, `Ember.Component`, and `Ember.Controller`. - (Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`, - and `Ember.Route` and available to the above classes through - inheritance.) - - @class ActionHandler - @namespace Ember - @private - */ - var ActionHandler = _emberMetal.Mixin.create({ - mergedProperties: ['actions'], - - /** - The collection of functions, keyed by name, available on this - `ActionHandler` as action targets. - These functions will be invoked when a matching `{{action}}` is triggered - from within a template and the application's current route is this route. - Actions can also be invoked from other parts of your application - via `ActionHandler#send`. - The `actions` hash will inherit action handlers from - the `actions` hash defined on extended parent classes - or mixins rather than just replace the entire hash, e.g.: - ```js - App.CanDisplayBanner = Ember.Mixin.create({ - actions: { - displayBanner(msg) { - // ... - } - } - }); - App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { - actions: { - playMusic() { - // ... - } - } - }); - // `WelcomeRoute`, when active, will be able to respond - // to both actions, since the actions hash is merged rather - // then replaced when extending mixins / parent classes. - this.send('displayBanner'); - this.send('playMusic'); - ``` - Within a Controller, Route or Component's action handler, - the value of the `this` context is the Controller, Route or - Component object: - ```js - App.SongRoute = Ember.Route.extend({ - actions: { - myAction() { - this.controllerFor("song"); - this.transitionTo("other.route"); - ... - } - } - }); - ``` - It is also possible to call `this._super(...arguments)` from within an - action handler if it overrides a handler defined on a parent - class or mixin: - Take for example the following routes: - ```js - App.DebugRoute = Ember.Mixin.create({ - actions: { - debugRouteInformation() { - console.debug("trololo"); - } - } - }); - App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { - actions: { - debugRouteInformation() { - // also call the debugRouteInformation of mixed in App.DebugRoute - this._super(...arguments); - // show additional annoyance - window.alert(...); - } - } - }); - ``` - ## Bubbling - By default, an action will stop bubbling once a handler defined - on the `actions` hash handles it. To continue bubbling the action, - you must return `true` from the handler: - ```js - App.Router.map(function() { - this.route("album", function() { - this.route("song"); - }); - }); - App.AlbumRoute = Ember.Route.extend({ - actions: { - startPlaying: function() { - } - } - }); - App.AlbumSongRoute = Ember.Route.extend({ - actions: { - startPlaying() { - // ... - if (actionShouldAlsoBeTriggeredOnParentRoute) { - return true; - } - } - } - }); - ``` - @property actions - @type Object - @default null - @public - */ - - /** - Triggers a named action on the `ActionHandler`. Any parameters - supplied after the `actionName` string will be passed as arguments - to the action target function. - If the `ActionHandler` has its `target` property set, actions may - bubble to the `target`. Bubbling happens when an `actionName` can - not be found in the `ActionHandler`'s `actions` hash or if the - action target function returns `true`. - Example - ```js - App.WelcomeRoute = Ember.Route.extend({ - actions: { - playTheme() { - this.send('playMusic', 'theme.mp3'); - }, - playMusic(track) { - // ... - } - } - }); - ``` - @method send - @param {String} actionName The action to trigger - @param {*} context a context to send with the action - @public - */ - send: function (actionName) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - if (this.actions && this.actions[actionName]) { - var shouldBubble = this.actions[actionName].apply(this, args) === true; - if (!shouldBubble) { - return; - } - } - - var target = _emberMetal.get(this, 'target'); - if (target) { - target.send.apply(target, arguments); - } - }, - - willMergeMixin: function (props) { - - if (props._actions) { - - props.actions = props._actions; - delete props._actions; - } - } - }); - - exports.default = ActionHandler; - - function deprecateUnderscoreActions(factory) { - Object.defineProperty(factory.prototype, '_actions', { - configurable: true, - enumerable: false, - set: function (value) {}, - get: function () { - return _emberMetal.get(this, 'actions'); - } - }); - } -}); -enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/each_proxy'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsEnumerable, _emberRuntimeSystemEach_proxy) { - /** - @module ember - @submodule ember-runtime - */ - - // .......................................................... - // HELPERS - // - 'use strict'; - - var _Mixin$create; - - exports.addArrayObserver = addArrayObserver; - exports.removeArrayObserver = removeArrayObserver; - exports.objectAt = objectAt; - exports.arrayContentWillChange = arrayContentWillChange; - exports.arrayContentDidChange = arrayContentDidChange; - exports.isEmberArray = isEmberArray; - - function arrayObserversHelper(obj, target, opts, operation, notify) { - var willChange = opts && opts.willChange || 'arrayWillChange'; - var didChange = opts && opts.didChange || 'arrayDidChange'; - var hasObservers = _emberMetal.get(obj, 'hasArrayObservers'); - - if (hasObservers === notify) { - _emberMetal.propertyWillChange(obj, 'hasArrayObservers'); - } - - operation(obj, '@array:before', target, willChange); - operation(obj, '@array:change', target, didChange); - - if (hasObservers === notify) { - _emberMetal.propertyDidChange(obj, 'hasArrayObservers'); - } - - return obj; - } - - function addArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, _emberMetal.addListener, false); - } - - function removeArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, _emberMetal.removeListener, true); - } - - function objectAt(content, idx) { - if (content.objectAt) { - return content.objectAt(idx); - } - - return content[idx]; - } - - function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { - var removing = undefined, - lim = undefined; - - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; - } - - if (addAmt === undefined) { - addAmt = -1; - } - } - - if (array.__each) { - array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt); - } - - _emberMetal.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); - - if (startIdx >= 0 && removeAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { - removing = []; - lim = startIdx + removeAmt; - - for (var idx = startIdx; idx < lim; idx++) { - removing.push(objectAt(array, idx)); - } - } else { - removing = removeAmt; - } - - array.enumerableContentWillChange(removing, addAmt); - - return array; - } - - function arrayContentDidChange(array, startIdx, removeAmt, addAmt) { - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; - } - - if (addAmt === undefined) { - addAmt = -1; - } - } - - var adding = undefined; - if (startIdx >= 0 && addAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { - adding = []; - var lim = startIdx + addAmt; - - for (var idx = startIdx; idx < lim; idx++) { - adding.push(objectAt(array, idx)); - } - } else { - adding = addAmt; - } - - array.enumerableContentDidChange(removeAmt, adding); - - if (array.__each) { - array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt); - } - - _emberMetal.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); - - var meta = _emberMetal.peekMeta(array); - var cache = meta && meta.readableCache(); - - if (cache) { - if (cache.firstObject !== undefined && objectAt(array, 0) !== _emberMetal.cacheFor.get(cache, 'firstObject')) { - _emberMetal.propertyWillChange(array, 'firstObject'); - _emberMetal.propertyDidChange(array, 'firstObject'); - } - if (cache.lastObject !== undefined && objectAt(array, _emberMetal.get(array, 'length') - 1) !== _emberMetal.cacheFor.get(cache, 'lastObject')) { - _emberMetal.propertyWillChange(array, 'lastObject'); - _emberMetal.propertyDidChange(array, 'lastObject'); - } - } - return array; - } - - var EMBER_ARRAY = _emberUtils.symbol('EMBER_ARRAY'); - - function isEmberArray(obj) { - return obj && !!obj[EMBER_ARRAY]; - } - - // .......................................................... - // ARRAY - // - /** - This mixin implements Observer-friendly Array-like behavior. It is not a - concrete implementation, but it can be used up by other classes that want - to appear like arrays. - - For example, ArrayProxy is a concrete classes that can - be instantiated to implement array-like behavior. Both of these classes use - the Array Mixin by way of the MutableArray mixin, which allows observable - changes to be made to the underlying array. - - Unlike `Ember.Enumerable,` this mixin defines methods specifically for - collections that provide index-ordered access to their contents. When you - are designing code that needs to accept any kind of Array-like object, you - should use these methods instead of Array primitives because these will - properly notify observers of changes to the array. - - Although these methods are efficient, they do add a layer of indirection to - your application so it is a good idea to use them only when you need the - flexibility of using both true JavaScript arrays and "virtual" arrays such - as controllers and collections. - - You can use the methods defined in this module to access and modify array - contents in a KVO-friendly way. You can also be notified whenever the - membership of an array changes by using `.observes('myArray.[]')`. - - To support `Ember.Array` in your own class, you must override two - primitives to use it: `length()` and `objectAt()`. - - Note that the Ember.Array mixin also incorporates the `Ember.Enumerable` - mixin. All `Ember.Array`-like objects are also enumerable. - - @class Array - @namespace Ember - @uses Ember.Enumerable - @since Ember 0.9.0 - @public - */ - var ArrayMixin = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) { - if (idx < 0 || idx >= _emberMetal.get(this, 'length')) { - return undefined; - } - - return _emberMetal.get(this, idx); - }, _Mixin$create.objectsAt = function (indexes) { - var _this = this; - - return indexes.map(function (idx) { - return objectAt(_this, idx); - }); - }, _Mixin$create.nextObject = function (idx) { - return objectAt(this, idx); - }, _Mixin$create['[]'] = _emberMetal.computed({ - get: function (key) { - return this; - }, - set: function (key, value) { - this.replace(0, _emberMetal.get(this, 'length'), value); - return this; - } - }), _Mixin$create.firstObject = _emberMetal.computed(function () { - return objectAt(this, 0); - }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () { - return objectAt(this, _emberMetal.get(this, 'length') - 1); - }).readOnly(), _Mixin$create.contains = function (obj) { - if (true) {} - - return this.indexOf(obj) >= 0; - }, _Mixin$create.slice = function (beginIndex, endIndex) { - var ret = _emberMetal.default.A(); - var length = _emberMetal.get(this, 'length'); - - if (_emberMetal.isNone(beginIndex)) { - beginIndex = 0; - } - - if (_emberMetal.isNone(endIndex) || endIndex > length) { - endIndex = length; - } - - if (beginIndex < 0) { - beginIndex = length + beginIndex; - } - - if (endIndex < 0) { - endIndex = length + endIndex; - } - - while (beginIndex < endIndex) { - ret[ret.length] = objectAt(this, beginIndex++); - } - - return ret; - }, _Mixin$create.indexOf = function (object, startAt) { - var len = _emberMetal.get(this, 'length'); - - if (startAt === undefined) { - startAt = 0; - } - - if (startAt < 0) { - startAt += len; - } - - for (var idx = startAt; idx < len; idx++) { - if (objectAt(this, idx) === object) { - return idx; - } - } - - return -1; - }, _Mixin$create.lastIndexOf = function (object, startAt) { - var len = _emberMetal.get(this, 'length'); - - if (startAt === undefined || startAt >= len) { - startAt = len - 1; - } - - if (startAt < 0) { - startAt += len; - } - - for (var idx = startAt; idx >= 0; idx--) { - if (objectAt(this, idx) === object) { - return idx; - } - } - - return -1; - }, _Mixin$create.addArrayObserver = function (target, opts) { - return addArrayObserver(this, target, opts); - }, _Mixin$create.removeArrayObserver = function (target, opts) { - return removeArrayObserver(this, target, opts); - }, _Mixin$create.hasArrayObservers = _emberMetal.computed(function () { - return _emberMetal.hasListeners(this, '@array:change') || _emberMetal.hasListeners(this, '@array:before'); - }), _Mixin$create.arrayContentWillChange = function (startIdx, removeAmt, addAmt) { - return arrayContentWillChange(this, startIdx, removeAmt, addAmt); - }, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) { - return arrayContentDidChange(this, startIdx, removeAmt, addAmt); - }, _Mixin$create['@each'] = _emberMetal.computed(function () { - // TODO use Symbol or add to meta - if (!this.__each) { - this.__each = new _emberRuntimeSystemEach_proxy.default(this); - } - - return this.__each; - }).volatile().readOnly(), _Mixin$create)); - - if (true) { - ArrayMixin.reopen({ - /** - Returns `true` if the passed object can be found in the array. - This method is a Polyfill for ES 2016 Array.includes. - If no `startAt` argument is given, the starting location to - search is 0. If it's negative, searches from the index of - `this.length + startAt` by asc. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, 3].includes(3, 2); // true - [1, 2, 3].includes(3, 3); // false - [1, 2, 3].includes(3, -1); // true - [1, 2, 3].includes(1, -1); // false - [1, 2, 3].includes(1, -4); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @param {Number} startAt optional starting location to search, default 0 - @return {Boolean} `true` if object is found in the array. - @public - */ - includes: function (obj, startAt) { - var len = _emberMetal.get(this, 'length'); - - if (startAt === undefined) { - startAt = 0; - } - - if (startAt < 0) { - startAt += len; - } - - for (var idx = startAt; idx < len; idx++) { - var currentObj = objectAt(this, idx); - - // SameValueZero comparison (NaN !== NaN) - if (obj === currentObj || obj !== obj && currentObj !== currentObj) { - return true; - } - } - - return false; - } - }); - } - - exports.default = ArrayMixin; -}); -// ES6TODO: Ember.A - -/** - __Required.__ You must implement this method to apply this mixin. - Your array must support the `length` property. Your replace methods should - set this property whenever it changes. - @property {Number} length - @public -*/ - -/** - Returns the object at the given `index`. If the given `index` is negative - or is greater or equal than the array length, returns `undefined`. - This is one of the primitives you must implement to support `Ember.Array`. - If your object supports retrieving the value of an array item using `get()` - (i.e. `myArray.get(0)`), then you do not need to implement this method - yourself. - ```javascript - let arr = ['a', 'b', 'c', 'd']; - arr.objectAt(0); // 'a' - arr.objectAt(3); // 'd' - arr.objectAt(-1); // undefined - arr.objectAt(4); // undefined - arr.objectAt(5); // undefined - ``` - @method objectAt - @param {Number} idx The index of the item to return. - @return {*} item at index or undefined - @public -*/ - -/** - This returns the objects at the specified indexes, using `objectAt`. - ```javascript - let arr = ['a', 'b', 'c', 'd']; - arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] - arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] - ``` - @method objectsAt - @param {Array} indexes An array of indexes of items to return. - @return {Array} - @public - */ - -// overrides Ember.Enumerable version - -/** - 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 - array, it will replace the current content. - This property overrides the default property defined in `Ember.Enumerable`. - @property [] - @return this - @public -*/ - -// optimized version from Enumerable - -// Add any extra methods to Ember.Array that are native to the built-in Array. -/** - Returns a new array that is a slice of the receiver. This implementation - uses the observable array methods to retrieve the objects for the new - slice. - ```javascript - let arr = ['red', 'green', 'blue']; - arr.slice(0); // ['red', 'green', 'blue'] - arr.slice(0, 2); // ['red', 'green'] - arr.slice(1, 100); // ['green', 'blue'] - ``` - @method slice - @param {Number} beginIndex (Optional) index to begin slicing from. - @param {Number} endIndex (Optional) index to end the slice at (but not included). - @return {Array} New array with specified slice - @public -*/ - -/** - Returns the index of the given object's first occurrence. - If no `startAt` argument is given, the starting location to - search is 0. If it's negative, will count backward from - the end of the array. Returns -1 if no match is found. - ```javascript - let arr = ['a', 'b', 'c', 'd', 'a']; - arr.indexOf('a'); // 0 - arr.indexOf('z'); // -1 - arr.indexOf('a', 2); // 4 - arr.indexOf('a', -1); // 4 - arr.indexOf('b', 3); // -1 - arr.indexOf('a', 100); // -1 - ``` - @method indexOf - @param {Object} object the item to search for - @param {Number} startAt optional starting location to search, default 0 - @return {Number} index or -1 if not found - @public -*/ - -/** - Returns the index of the given object's last occurrence. - If no `startAt` argument is given, the search starts from - the last position. If it's negative, will count backward - from the end of the array. Returns -1 if no match is found. - ```javascript - let arr = ['a', 'b', 'c', 'd', 'a']; - arr.lastIndexOf('a'); // 4 - arr.lastIndexOf('z'); // -1 - arr.lastIndexOf('a', 2); // 0 - arr.lastIndexOf('a', -1); // 4 - arr.lastIndexOf('b', 3); // 1 - arr.lastIndexOf('a', 100); // 4 - ``` - @method lastIndexOf - @param {Object} object the item to search for - @param {Number} startAt optional starting location to search, default 0 - @return {Number} index or -1 if not found - @public -*/ - -// .......................................................... -// ARRAY OBSERVERS -// - -/** - Adds an array observer to the receiving array. The array observer object - normally must implement two methods: - * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be - called just before the array is modified. - * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be - called just after the array is modified. - Both callbacks will be passed the observed object, starting index of the - change as well as a count of the items to be removed and added. You can use - these callbacks to optionally inspect the array during the change, clear - caches, or do any other bookkeeping necessary. - In addition to passing a target, you can also include an options hash - which you can use to override the method names that will be invoked on the - target. - @method addArrayObserver - @param {Object} target The observer object. - @param {Object} opts Optional hash of configuration options including - `willChange` and `didChange` option. - @return {Ember.Array} receiver - @public -*/ - -/** - Removes an array observer from the object if the observer is current - registered. Calling this method multiple times with the same object will - have no effect. - @method removeArrayObserver - @param {Object} target The object observing the array. - @param {Object} opts Optional hash of configuration options including - `willChange` and `didChange` option. - @return {Ember.Array} receiver - @public -*/ - -/** - Becomes true whenever the array currently has observers watching changes - on the array. - @property {Boolean} hasArrayObservers - @public -*/ - -/** - If you are implementing an object that supports `Ember.Array`, call this - method just before the array content changes to notify any observers and - invalidate any related properties. Pass the starting index of the change - as well as a delta of the amounts to change. - @method arrayContentWillChange - @param {Number} startIdx The starting index in the array that will change. - @param {Number} removeAmt The number of items that will be removed. If you - pass `null` assumes 0 - @param {Number} addAmt The number of items that will be added. If you - pass `null` assumes 0. - @return {Ember.Array} receiver - @public -*/ - -/** - If you are implementing an object that supports `Ember.Array`, call this - method just after the array content changes to notify any observers and - invalidate any related properties. Pass the starting index of the change - as well as a delta of the amounts to change. - @method arrayContentDidChange - @param {Number} startIdx The starting index in the array that did change. - @param {Number} removeAmt The number of items that were removed. If you - pass `null` assumes 0 - @param {Number} addAmt The number of items that were added. If you - pass `null` assumes 0. - @return {Ember.Array} receiver - @public -*/ - -/** - Returns a special object that can be used to observe individual properties - on the array. Just get an equivalent property on this object and it will - return an enumerable that maps automatically to the named key on the - member objects. - `@each` should only be used in a non-terminal context. Example: - ```javascript - myMethod: computed('posts.@each.author', function(){ - ... - }); - ``` - If you merely want to watch for the array being changed, like an object being - replaced, added or removed, use `[]` instead of `@each`. - ```javascript - myMethod: computed('posts.[]', function(){ - ... - }); - ``` - @property @each - @public -*/ -enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - /** - @module ember - @submodule ember-runtime - */ - - /** - Implements some standard methods for comparing objects. Add this mixin to - any class you create that can compare its instances. - - You should implement the `compare()` method. - - @class Comparable - @namespace Ember - @since Ember 0.9 - @private - */ - exports.default = _emberMetal.Mixin.create({ - - /** - __Required.__ You must implement this method to apply this mixin. - Override to return the result of the comparison of the two parameters. The - compare method should return: - - `-1` if `a < b` - - `0` if `a == b` - - `1` if `a > b` - Default implementation raises an exception. - @method compare - @param a {Object} the first object to compare - @param b {Object} the second object to compare - @return {Number} the result of the comparison - @private - */ - compare: null - }); -}); -enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ - 'use strict'; - - /** - ContainerProxyMixin is used to provide public access to specific - container functionality. - - @class ContainerProxyMixin - @private - */ - exports.default = _emberMetal.Mixin.create({ - /** - The container stores state. - @private - @property {Ember.Container} __container__ - */ - __container__: null, - - /** - Returns an object that can be used to provide an owner to a - manually created instance. - Example: - ``` - let owner = Ember.getOwner(this); - User.create( - owner.ownerInjection(), - { username: 'rwjblue' } - ) - ``` - @public - @method ownerInjection - @return {Object} - */ - ownerInjection: function () { - return this.__container__.ownerInjection(); - }, - - /** - Given a fullName return a corresponding instance. - The default behaviour is for lookup to return a singleton instance. - The singleton is scoped to the container, allowing multiple containers - to all have their own locally scoped singletons. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter'); - twitter instanceof Twitter; // => true - // by default the container will return singletons - let twitter2 = container.lookup('api:twitter'); - twitter2 instanceof Twitter; // => true - twitter === twitter2; //=> true - ``` - If singletons are not wanted an optional flag can be provided at lookup. - ```javascript - let registry = new Registry(); - let container = registry.container(); - registry.register('api:twitter', Twitter); - let twitter = container.lookup('api:twitter', { singleton: false }); - let twitter2 = container.lookup('api:twitter', { singleton: false }); - twitter === twitter2; //=> false - ``` - @public - @method lookup - @param {String} fullName - @param {Object} options - @return {any} - */ - lookup: function (fullName, options) { - return this.__container__.lookup(fullName, options); - }, - - /** - Given a fullName return the corresponding factory. - @private - @method _lookupFactory - @param {String} fullName - @return {any} - */ - _lookupFactory: function (fullName, options) { - return this.__container__.lookupFactory(fullName, options); - }, - - /** - Given a name and a source path, resolve the fullName - @private - @method _resolveLocalLookupName - @param {String} fullName - @param {String} source - @return {String} - */ - _resolveLocalLookupName: function (name, source) { - return this.__container__.registry.expandLocalLookup('component:' + name, { - source: source - }); - }, - - /** - @private - */ - willDestroy: function () { - this._super.apply(this, arguments); - - if (this.__container__) { - _emberMetal.run(this.__container__, 'destroy'); - } - } - }); -}); -enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) { - 'use strict'; - - /** - @class ControllerMixin - @namespace Ember - @uses Ember.ActionHandler - @private - */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, { - /* ducktype as a controller */ - isController: true, - - /** - The object to which actions from the view should be sent. - For example, when a Handlebars template uses the `{{action}}` helper, - it will attempt to send the action to the view's controller's `target`. - By default, the value of the target property is set to the router, and - is injected when a controller is instantiated. This injection is applied - as part of the application's initialization process. In most cases the - `target` property will automatically be set to the logical consumer of - actions for the controller. - @property target - @default null - @public - */ - target: null, - - store: null, - - /** - The controller's current model. When retrieving or modifying a controller's - model, this property should be used instead of the `content` property. - @property model - @public - */ - model: null, - - /** - @private - */ - content: _emberMetal.alias('model') - - }); -}); -enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; - - /* - The ControllerContentModelAliasDeprecation mixin is used to provide a useful - deprecation warning when specifying `content` directly on a `Ember.Controller` - (without also specifying `model`). - - Ember versions prior to 1.7 used `model` as an alias of `content`, but due to - much confusion this alias was reversed (so `content` is now an alias of `model). - - This change reduces many caveats with model/content, and also sets a - simple ground rule: Never set a controllers content, rather always set - its model and ember will do the right thing. - - Used internally by Ember in `Ember.Controller`. - */ - exports.default = _emberMetal.Mixin.create({ - /** - @private - Moves `content` to `model` at extend time if a `model` is not also specified. - Note that this currently modifies the mixin themselves, which is technically - dubious but is practically of little consequence. This may change in the - future. - @method willMergeMixin - @since 1.4.0 - */ - willMergeMixin: function (props) { - // Calling super is only OK here since we KNOW that - // there is another Mixin loaded first. - this._super.apply(this, arguments); - - var modelSpecified = !!props.model; - - if (props.content && !modelSpecified) { - props.model = props.content; - delete props['content']; - } - } - }); -}); -enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal', 'ember-runtime/mixins/freezable'], function (exports, _emberMetal, _emberRuntimeMixinsFreezable) { - /** - @module ember - @submodule ember-runtime - */ - - 'use strict'; - - /** - Implements some standard methods for copying an object. Add this mixin to - any object you create that can create a copy of itself. This mixin is - added automatically to the built-in array. - - You should generally implement the `copy()` method to return a copy of the - receiver. - - Note that `frozenCopy()` will only work if you also implement - `Ember.Freezable`. - - @class Copyable - @namespace Ember - @since Ember 0.9 - @private - */ - exports.default = _emberMetal.Mixin.create({ - /** - __Required.__ You must implement this method to apply this mixin. - Override to return a copy of the receiver. Default implementation raises - an exception. - @method copy - @param {Boolean} deep if `true`, a deep copy of the object should be made - @return {Object} copy of receiver - @private - */ - copy: null, - - /** - If the object implements `Ember.Freezable`, then this will return a new - copy if the object is not frozen and the receiver if the object is frozen. - Raises an exception if you try to call this method on a object that does - not support freezing. - You should use this method whenever you want a copy of a freezable object - since a freezable object can simply return itself without actually - consuming more memory. - @method frozenCopy - @return {Object} copy of receiver or receiver - @deprecated Use `Object.freeze` instead. - @private - */ - frozenCopy: function () { - if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) { - return _emberMetal.get(this, 'isFrozen') ? this : this.copy().freeze(); - } else { - throw new _emberMetal.Error(this + ' does not support freezing'); - } - } - }); -}); -enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'require'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _require) { - /** - @module ember - @submodule ember-runtime - */ - - // .......................................................... - // HELPERS - // - - 'use strict'; - - var _emberA = undefined; - - function emberA() { - return (_emberA || (_emberA = _require.default('ember-runtime/system/native_array').A))(); - } - - var contexts = []; - - function popCtx() { - return contexts.length === 0 ? {} : contexts.pop(); - } - - function pushCtx(ctx) { - contexts.push(ctx); - return null; - } - - function iter(key, value) { - var valueProvided = arguments.length === 2; - - function i(item) { - var cur = _emberMetal.get(item, key); - return valueProvided ? value === cur : !!cur; - } - - return i; - } - - /** - This mixin defines the common interface implemented by enumerable objects - in Ember. Most of these methods follow the standard Array iteration - API defined up to JavaScript 1.8 (excluding language-specific features that - cannot be emulated in older versions of JavaScript). - - This mixin is applied automatically to the Array class on page load, so you - can use any of these methods on simple arrays. If Array already implements - one of these methods, the mixin will not override them. - - ## Writing Your Own Enumerable - - To make your own custom class enumerable, you need two items: - - 1. You must have a length property. This property should change whenever - the number of items in your enumerable object changes. If you use this - with an `Ember.Object` subclass, you should be sure to change the length - property using `set().` - - 2. You must implement `nextObject().` See documentation. - - Once you have these two methods implemented, apply the `Ember.Enumerable` mixin - to your class and you will be able to enumerate the contents of your object - like any other collection. - - ## Using Ember Enumeration with Other Libraries - - Many other libraries provide some kind of iterator or enumeration like - facility. This is often where the most common API conflicts occur. - Ember's API is designed to be as friendly as possible with other - libraries by implementing only methods that mostly correspond to the - JavaScript 1.8 API. - - @class Enumerable - @namespace Ember - @since Ember 0.9 - @private - */ - var Enumerable = _emberMetal.Mixin.create({ - - /** - __Required.__ You must implement this method to apply this mixin. - Implement this method to make your class enumerable. - This method will be called repeatedly during enumeration. The index value - will always begin with 0 and increment monotonically. You don't have to - rely on the index value to determine what object to return, but you should - always check the value and start from the beginning when you see the - requested index is 0. - The `previousObject` is the object that was returned from the last call - to `nextObject` for the current iteration. This is a useful way to - manage iteration if you are tracing a linked list, for example. - Finally the context parameter will always contain a hash you can use as - a "scratchpad" to maintain any other state you need in order to iterate - properly. The context object is reused and is not reset between - iterations so make sure you setup the context with a fresh state whenever - the index parameter is 0. - Generally iterators will continue to call `nextObject` until the index - reaches the current length-1. If you run out of data before this - time for some reason, you should simply return undefined. - The default implementation of this method simply looks up the index. - This works great on any Array-like objects. - @method nextObject - @param {Number} index the current index of the iteration - @param {Object} previousObject the value returned by the last call to - `nextObject`. - @param {Object} context a context object you can use to maintain state. - @return {Object} the next object in the iteration or undefined - @private - */ - nextObject: null, - - /** - Helper method returns the first object from a collection. This is usually - used by bindings and other parts of the framework to extract a single - object if the enumerable contains only one item. - If you override this method, you should implement it so that it will - always return the same value each time it is called. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - ```javascript - let arr = ['a', 'b', 'c']; - arr.get('firstObject'); // 'a' - let arr = []; - arr.get('firstObject'); // undefined - ``` - @property firstObject - @return {Object} the object or undefined - @readOnly - @public - */ - firstObject: _emberMetal.computed('[]', function () { - if (_emberMetal.get(this, 'length') === 0) { - return undefined; - } - - // handle generic enumerables - var context = popCtx(); - var ret = this.nextObject(0, null, context); - - pushCtx(context); - - return ret; - }).readOnly(), - - /** - Helper method returns the last object from a collection. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - ```javascript - let arr = ['a', 'b', 'c']; - arr.get('lastObject'); // 'c' - let arr = []; - arr.get('lastObject'); // undefined - ``` - @property lastObject - @return {Object} the last object or undefined - @readOnly - @public - */ - lastObject: _emberMetal.computed('[]', function () { - var len = _emberMetal.get(this, 'length'); - - if (len === 0) { - return undefined; - } - - var context = popCtx(); - var idx = 0; - var last = null; - var cur = undefined; - - do { - last = cur; - cur = this.nextObject(idx++, last, context); - } while (cur !== undefined); - - pushCtx(context); - - return last; - }).readOnly(), - - /** - Returns `true` if the passed object can be found in the receiver. The - default version will iterate through the enumerable until the object - is found. You may want to override this with a more efficient version. - ```javascript - let arr = ['a', 'b', 'c']; - arr.contains('a'); // true - arr.contains('z'); // false - ``` - @method contains - @deprecated Use `Enumerable#includes` instead. See http://emberjs.com/deprecations/v2.x#toc_enumerable-contains - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in enumerable. - @public - */ - contains: function (obj) { - if (true) {} - - var found = this.find(function (item) { - return item === obj; - }); - - return found !== undefined; - }, - - /** - Iterates through the enumerable, calling the passed function on each - item. This method corresponds to the `forEach()` method defined in - JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method forEach - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Object} receiver - @public - */ - forEach: function (callback, target) { - if (typeof callback !== 'function') { - throw new TypeError(); - } - - var context = popCtx(); - var len = _emberMetal.get(this, 'length'); - var last = null; - - if (target === undefined) { - target = null; - } - - for (var idx = 0; idx < len; idx++) { - var next = this.nextObject(idx, last, context); - callback.call(target, next, idx, this); - last = next; - } - - last = null; - context = pushCtx(context); - - return this; - }, - - /** - Alias for `mapBy` - @method getEach - @param {String} key name of the property - @return {Array} The mapped array. - @public - */ - getEach: _emberMetal.aliasMethod('mapBy'), - - /** - Sets the value on the named property for each member. This is more - ergonomic than using other methods defined on this helper. If the object - implements Ember.Observable, the value will be changed to `set(),` otherwise - it will be set directly. `null` objects are skipped. - @method setEach - @param {String} key The key to set - @param {Object} value The object to set - @return {Object} receiver - @public - */ - setEach: function (key, value) { - return this.forEach(function (item) { - return _emberMetal.set(item, key, value); - }); - }, - - /** - Maps all of the items in the enumeration to another value, returning - a new array. This method corresponds to `map()` defined in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the mapped value. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method map - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} The mapped array. - @public - */ - map: function (callback, target) { - var ret = emberA(); - - this.forEach(function (x, idx, i) { - return ret[idx] = callback.call(target, x, idx, i); - }); - - return ret; - }, - - /** - Similar to map, this specialized function returns the value of the named - property on all items in the enumeration. - @method mapBy - @param {String} key name of the property - @return {Array} The mapped array. - @public - */ - mapBy: function (key) { - return this.map(function (next) { - return _emberMetal.get(next, key); - }); - }, - - /** - Returns an array with all of the items in the enumeration that the passed - function returns true for. This method corresponds to `filter()` defined in - JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method filter - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} A filtered array. - @public - */ - filter: function (callback, target) { - var ret = emberA(); - - this.forEach(function (x, idx, i) { - if (callback.call(target, x, idx, i)) { - ret.push(x); - } - }); - - return ret; - }, - - /** - Returns an array with all of the items in the enumeration where the passed - function returns false. This method is the inverse of filter(). - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - *item* is the current item in the iteration. - - *index* is the current index in the iteration - - *enumerable* is the enumerable object itself. - It should return a falsey value to include the item in the results. - Note that in addition to a callback, you can also pass an optional target - object that will be set as "this" on the context. This is a good way - to give your iterator function access to the current object. - @method reject - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Array} A rejected array. - @public - */ - reject: function (callback, target) { - return this.filter(function () { - return !callback.apply(target, arguments); - }); - }, - - /** - Returns an array with just the items with the matched property. You - can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to `true`. - @method filterBy - @param {String} key the property to test - @param {*} [value] optional value to test against. - @return {Array} filtered array - @public - */ - filterBy: function (key, value) { - return this.filter(iter.apply(this, arguments)); - }, - - /** - Returns an array with the items that do not have truthy values for - key. You can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to false. - @method rejectBy - @param {String} key the property to test - @param {String} [value] optional value to test against. - @return {Array} rejected array - @public - */ - rejectBy: function (key, value) { - var exactValue = function (item) { - return _emberMetal.get(item, key) === value; - }; - var hasValue = function (item) { - return !!_emberMetal.get(item, key); - }; - var use = arguments.length === 2 ? exactValue : hasValue; - - return this.reject(use); - }, - - /** - Returns the first item in the array for which the callback returns true. - This method works similar to the `filter()` method defined in JavaScript 1.6 - except that it will stop working on the array once a match is found. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - @method find - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Object} Found item or `undefined`. - @public - */ - find: function (callback, target) { - var len = _emberMetal.get(this, 'length'); - - if (target === undefined) { - target = null; - } - - var context = popCtx(); - var found = false; - var last = null; - var next = undefined, - ret = undefined; - - for (var idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); - - found = callback.call(target, next, idx, this); - if (found) { - ret = next; - } - - last = next; - } - - next = last = null; - context = pushCtx(context); - - return ret; - }, - - /** - Returns the first item with a property matching the passed value. You - can pass an optional second argument with the target value. Otherwise - this will match any property that evaluates to `true`. - This method works much like the more generic `find()` method. - @method findBy - @param {String} key the property to test - @param {String} [value] optional value to test against. - @return {Object} found item or `undefined` - @public - */ - findBy: function (key, value) { - return this.find(iter.apply(this, arguments)); - }, - - /** - Returns `true` if the passed function returns true for every item in the - enumeration. This corresponds with the `every()` method in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` or `false`. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - Example Usage: - ```javascript - if (people.every(isEngineer)) { - Paychecks.addBigBonus(); - } - ``` - @method every - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Boolean} - @public - */ - every: function (callback, target) { - return !this.find(function (x, idx, i) { - return !callback.call(target, x, idx, i); - }); - }, + var cache = meta.readableCache(); + if (cache && cache[keyName] !== undefined) { + cache[keyName] = undefined; + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + } + }; - /** - Returns `true` if the passed property resolves to the value of the second - argument for all items in the enumerable. This method is often simpler/faster - than using a callback. - @method isEvery - @param {String} key the property to test - @param {String} [value] optional value to test against. Defaults to `true` - @return {Boolean} - @since 1.3.0 - @public - */ - isEvery: function (key, value) { - return this.every(iter.apply(this, arguments)); - }, + ComputedPropertyPrototype.get = function (obj, keyName) { + if (this._volatile) { + return this._getter.call(obj, keyName); + } - /** - Returns `true` if the passed function returns true for any item in the - enumeration. This corresponds with the `some()` method in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(item, index, enumerable); - ``` - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - It should return the `true` to include the item in the results, `false` - otherwise. - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - Usage Example: - ```javascript - if (people.any(isManager)) { - Paychecks.addBiggerBonus(); - } - ``` - @method any - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Boolean} `true` if the passed function returns `true` for any item - @public - */ - any: function (callback, target) { - var len = _emberMetal.get(this, 'length'); - var context = popCtx(); - var found = false; - var last = null; - var next = undefined; + var meta = _emberMetalMeta.meta(obj); + var cache = meta.writableCache(); - if (target === undefined) { - target = null; - } + var result = cache[keyName]; + if (result === _emberMetalMeta.UNDEFINED) { + return undefined; + } else if (result !== undefined) { + return result; + } - for (var idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); - found = callback.call(target, next, idx, this); - last = next; - } + var ret = this._getter.call(obj, keyName); + if (ret === undefined) { + cache[keyName] = _emberMetalMeta.UNDEFINED; + } else { + cache[keyName] = ret; + } - next = last = null; - context = pushCtx(context); - return found; - }, + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidate(keyName); + } + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); - /** - Returns `true` if the passed property resolves to the value of the second - argument for any item in 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. Defaults to `true` - @return {Boolean} - @since 1.3.0 - @public - */ - isAny: function (key, value) { - return this.any(iter.apply(this, arguments)); - }, + return ret; + }; - /** - This will combine the values of the enumerator into a single value. It - is a useful way to collect a summary value from an enumeration. This - corresponds to the `reduce()` method defined in JavaScript 1.8. - The callback method you provide should have the following signature (all - parameters are optional): - ```javascript - function(previousValue, item, index, enumerable); - ``` - - `previousValue` is the value returned by the last call to the iterator. - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - Return the new cumulative value. - In addition to the callback you can also pass an `initialValue`. An error - will be raised if you do not pass an initial value and the enumerator is - empty. - Note that unlike the other methods, this method does not allow you to - pass a target object to set as this for the callback. It's part of the - spec. Sorry. - @method reduce - @param {Function} callback The callback to execute - @param {Object} initialValue Initial value for the reduce - @param {String} reducerProperty internal use only. - @return {Object} The reduced value. - @public - */ - reduce: function (callback, initialValue, reducerProperty) { - if (typeof callback !== 'function') { - throw new TypeError(); - } + ComputedPropertyPrototype.set = function computedPropertySetEntry(obj, keyName, value) { + if (this._readOnly) { + this._throwReadOnlyError(obj, keyName); + } - var ret = initialValue; + if (!this._setter) { + return this.clobberSet(obj, keyName, value); + } - this.forEach(function (item, i) { - ret = callback(ret, item, i, this, reducerProperty); - }, this); + if (this._volatile) { + return this.volatileSet(obj, keyName, value); + } - return ret; - }, + return this.setWithSuspend(obj, keyName, value); + }; - /** - Invokes the named method on every object in the receiver that - implements it. This method corresponds to the implementation in - Prototype 1.6. - @method invoke - @param {String} methodName the name of the method - @param {Object...} args optional arguments to pass as well. - @return {Array} return values from calling invoke. - @public - */ - invoke: function (methodName) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } + ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) { + throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj)); + }; - var ret = emberA(); + ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) { + var cachedValue = cacheFor(obj, keyName); + _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue); + _emberMetalProperty_set.set(obj, keyName, value); + return value; + }; - this.forEach(function (x, idx) { - var method = x && x[methodName]; + ComputedPropertyPrototype.volatileSet = function computedPropertyVolatileSet(obj, keyName, value) { + return this._setter.call(obj, keyName, value); + }; - if ('function' === typeof method) { - ret[idx] = args ? method.apply(x, args) : x[methodName](); - } - }, this); + ComputedPropertyPrototype.setWithSuspend = function computedPropertySetWithSuspend(obj, keyName, value) { + var oldSuspended = this._suspended; + this._suspended = obj; + try { + return this._set(obj, keyName, value); + } finally { + this._suspended = oldSuspended; + } + }; + + ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { + // cache requires own meta + var meta = _emberMetalMeta.meta(obj); + // either there is a writable cache or we need one to update + var cache = meta.writableCache(); + var hadCachedValue = false; + var cachedValue = undefined; + if (cache[keyName] !== undefined) { + if (cache[keyName] !== _emberMetalMeta.UNDEFINED) { + cachedValue = cache[keyName]; + } + hadCachedValue = true; + } + + var ret = this._setter.call(obj, keyName, value, cachedValue); + // allows setter to return the same value that is cached already + if (hadCachedValue && cachedValue === ret) { return ret; - }, + } - /** - Simply converts the enumerable into a genuine array. The order is not - guaranteed. Corresponds to the method implemented by Prototype. - @method toArray - @return {Array} the enumerable as an array. - @public - */ - toArray: function () { - var ret = emberA(); + _emberMetalProperty_events.propertyWillChange(obj, keyName); - this.forEach(function (o, idx) { - return ret[idx] = o; - }); + if (hadCachedValue) { + cache[keyName] = undefined; + } - return ret; - }, + if (!hadCachedValue) { + _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta); + } - /** - Returns a copy of the array with all `null` and `undefined` elements removed. - ```javascript - let arr = ['a', null, 'c', undefined]; - arr.compact(); // ['a', 'c'] - ``` - @method compact - @return {Array} the array without null and undefined elements. - @public - */ - compact: function () { - return this.filter(function (value) { - return value != null; - }); - }, + if (ret === undefined) { + cache[keyName] = _emberMetalMeta.UNDEFINED; + } else { + cache[keyName] = ret; + } - /** - Returns a new enumerable that excludes the passed value. The default - implementation returns an array regardless of the receiver type. - If the receiver does not contain the value it returns the original enumerable. - ```javascript - let arr = ['a', 'b', 'a', 'c']; - arr.without('a'); // ['b', 'c'] - ``` - @method without - @param {Object} value - @return {Ember.Enumerable} - @public - */ - without: function (value) { - if (!this.contains(value)) { - return this; // nothing to do - } + _emberMetalProperty_events.propertyDidChange(obj, keyName); - var ret = emberA(); + return ret; + }; - this.forEach(function (k) { - if (k !== value) { - ret[ret.length] = k; + /* called before property is overridden */ + ComputedPropertyPrototype.teardown = function (obj, keyName) { + if (this._volatile) { + return; + } + var meta = _emberMetalMeta.meta(obj); + var cache = meta.readableCache(); + if (cache && cache[keyName] !== undefined) { + _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta); + cache[keyName] = undefined; + } + }; + + /** + This helper returns a new property descriptor that wraps the passed + computed property function. You can use this helper to define properties + with mixins or via `Ember.defineProperty()`. + + If you pass a function as an argument, it will be used as a getter. A computed + property defined in this way might look like this: + + ```js + let Person = Ember.Object.extend({ + init() { + this._super(...arguments); + + this.firstName = 'Betty'; + this.lastName = 'Jones'; + }, + + fullName: Ember.computed('firstName', 'lastName', function() { + return `${this.get('firstName')} ${this.get('lastName')}`; + }) + }); + + let client = Person.create(); + + client.get('fullName'); // 'Betty Jones' + + client.set('lastName', 'Fuller'); + client.get('fullName'); // 'Betty Fuller' + ``` + + You can pass a hash with two functions, `get` and `set`, as an + argument to provide both a getter and setter: + + ```js + let Person = Ember.Object.extend({ + init() { + this._super(...arguments); + + this.firstName = 'Betty'; + this.lastName = 'Jones'; + }, + + fullName: Ember.computed('firstName', 'lastName', { + get(key) { + return `${this.get('firstName')} ${this.get('lastName')}`; + }, + set(key, value) { + let [firstName, lastName] = value.split(/\s+/); + this.setProperties({ firstName, lastName }); + return value; } - }); + }) + }); + + let client = Person.create(); + client.get('firstName'); // 'Betty' + + client.set('fullName', 'Carroll Fuller'); + client.get('firstName'); // 'Carroll' + ``` + + The `set` function should accept two parameters, `key` and `value`. The value + returned from `set` will be the new value of the property. + + _Note: This is the preferred way to define computed properties when writing third-party + libraries that depend on or use Ember, since there is no guarantee that the user + will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._ + + The alternative syntax, with prototype extensions, might look like: + + ```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 + */ - return ret; - }, + function computed(func) { + var args = undefined; - /** - Returns a new enumerable that contains only unique values. The default - implementation returns an array regardless of the receiver type. - ```javascript - let arr = ['a', 'a', 'b', 'b']; - arr.uniq(); // ['a', 'b'] - ``` - This only works on primitive data types, e.g. Strings, Numbers, etc. - @method uniq - @return {Ember.Enumerable} - @public - */ - uniq: function () { - var ret = emberA(); + if (arguments.length > 1) { + args = [].slice.call(arguments); + func = args.pop(); + } - this.forEach(function (k) { - if (ret.indexOf(k) < 0) { - ret.push(k); - } - }); + var cp = new ComputedProperty(func); - return ret; - }, + if (args) { + cp.property.apply(cp, args); + } - /** - This property will trigger anytime the enumerable's content changes. - You can observe this property to be notified of changes to the enumerable's - content. - For plain enumerables, this property is read only. `Array` overrides - this method. - @property [] - @type Array - @return this - @private - */ - '[]': _emberMetal.computed({ - get: function (key) { - return this; - } - }), + return cp; + } - // .......................................................... - // ENUMERABLE OBSERVERS - // + /** + 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 = _emberMetalMeta.peekMeta(obj); + var cache = meta && meta.source === obj && meta.readableCache(); + var ret = cache && cache[key]; - /** - Registers an enumerable observer. Must implement `Ember.EnumerableObserver` - mixin. - @method addEnumerableObserver - @param {Object} target - @param {Object} [opts] - @return this - @private - */ - addEnumerableObserver: function (target, opts) { - var willChange = opts && opts.willChange || 'enumerableWillChange'; - var didChange = opts && opts.didChange || 'enumerableDidChange'; - var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); + if (ret === _emberMetalMeta.UNDEFINED) { + return undefined; + } + return ret; + } + + cacheFor.set = function (cache, key, value) { + if (value === undefined) { + cache[key] = _emberMetalMeta.UNDEFINED; + } else { + cache[key] = value; + } + }; + + cacheFor.get = function (cache, key) { + var ret = cache[key]; + if (ret === _emberMetalMeta.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', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; + + /** + @module ember + @submodule ember-metal + */ + + /** + This namespace contains all Ember methods and functions. Future versions of + Ember may overwrite this namespace and therefore, you should avoid adding any + new properties. + + At the heart of Ember is Ember-Runtime, a set of core functions that provide + cross-platform compatibility and object property observing. Ember-Runtime is + small and performance-focused so you can use it alongside other + cross-platform libraries such as jQuery. For more details, see + [Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html). + + @class Ember + @static + @public + */ + var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {}; - if (!hasObservers) { - _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); - } + // Make sure these are set whether Ember was already defined or not + Ember.isNamespace = true; + Ember.toString = function () { + return 'Ember'; + }; - _emberMetal.addListener(this, '@enumerable:before', target, willChange); - _emberMetal.addListener(this, '@enumerable:change', target, didChange); + // .......................................................... + // BOOTSTRAP + // - if (!hasObservers) { - _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); + exports.default = Ember; +}); +enifed("ember-metal/debug", ["exports"], function (exports) { + "use strict"; + + exports.getDebugFunction = getDebugFunction; + exports.setDebugFunction = setDebugFunction; + exports.assert = assert; + exports.info = info; + exports.warn = warn; + exports.debug = debug; + exports.deprecate = deprecate; + exports.deprecateFunc = deprecateFunc; + exports.runInDebug = runInDebug; + exports.debugSeal = debugSeal; + exports.debugFreeze = debugFreeze; + var debugFunctions = { + assert: function () {}, + info: function () {}, + warn: function () {}, + debug: function () {}, + deprecate: function () {}, + deprecateFunc: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - return this; + return args[args.length - 1]; }, + runInDebug: function () {}, + debugSeal: function () {}, + debugFreeze: function () {} + }; - /** - Removes a registered enumerable observer. - @method removeEnumerableObserver - @param {Object} target - @param {Object} [opts] - @return this - @private - */ - removeEnumerableObserver: function (target, opts) { - var willChange = opts && opts.willChange || 'enumerableWillChange'; - var didChange = opts && opts.didChange || 'enumerableDidChange'; - var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); + exports.debugFunctions = debugFunctions; - if (hasObservers) { - _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); - } + function getDebugFunction(name) { + return debugFunctions[name]; + } - _emberMetal.removeListener(this, '@enumerable:before', target, willChange); - _emberMetal.removeListener(this, '@enumerable:change', target, didChange); + function setDebugFunction(name, fn) { + debugFunctions[name] = fn; + } - if (hasObservers) { - _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); - } + function assert() { + return debugFunctions.assert.apply(undefined, arguments); + } - return this; - }, + function info() { + return debugFunctions.info.apply(undefined, arguments); + } - /** - Becomes true whenever the array currently has observers watching changes - on the array. - @property hasEnumerableObservers - @type Boolean - @private - */ - hasEnumerableObservers: _emberMetal.computed(function () { - return _emberMetal.hasListeners(this, '@enumerable:change') || _emberMetal.hasListeners(this, '@enumerable:before'); - }), + function warn() { + return debugFunctions.warn.apply(undefined, arguments); + } - /** - Invoke this method just before the contents of your enumerable will - change. You can either omit the parameters completely or pass the objects - to be removed or added if available or just a count. - @method enumerableContentWillChange - @param {Ember.Enumerable|Number} removing An enumerable of the objects to - be removed or the number of items to be removed. - @param {Ember.Enumerable|Number} adding An enumerable of the objects to be - added or the number of items to be added. - @chainable - @private - */ - enumerableContentWillChange: function (removing, adding) { - var removeCnt = undefined, - addCnt = undefined, - hasDelta = undefined; + function debug() { + return debugFunctions.debug.apply(undefined, arguments); + } - if ('number' === typeof removing) { - removeCnt = removing; - } else if (removing) { - removeCnt = _emberMetal.get(removing, 'length'); - } else { - removeCnt = removing = -1; - } + function deprecate() { + return debugFunctions.deprecate.apply(undefined, arguments); + } - if ('number' === typeof adding) { - addCnt = adding; - } else if (adding) { - addCnt = _emberMetal.get(adding, 'length'); - } else { - addCnt = adding = -1; - } + function deprecateFunc() { + return debugFunctions.deprecateFunc.apply(undefined, arguments); + } - hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; + function runInDebug() { + return debugFunctions.runInDebug.apply(undefined, arguments); + } - if (removing === -1) { - removing = null; - } + function debugSeal() { + return debugFunctions.debugSeal.apply(undefined, arguments); + } - if (adding === -1) { - adding = null; - } + function debugFreeze() { + return debugFunctions.debugFreeze.apply(undefined, arguments); + } +}); +enifed('ember-metal/dependent_keys', ['exports', 'ember-metal/watching'], function (exports, _emberMetalWatching) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - _emberMetal.propertyWillChange(this, '[]'); + exports.addDependentKeys = addDependentKeys; + exports.removeDependentKeys = removeDependentKeys; - if (hasDelta) { - _emberMetal.propertyWillChange(this, 'length'); - } + /** + @module ember + @submodule ember-metal + */ - _emberMetal.sendEvent(this, '@enumerable:before', [this, removing, adding]); + // .......................................................... + // DEPENDENT KEYS + // - return this; - }, + function addDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // add all of its dependent keys. + var idx = undefined, + depKey = undefined; + var depKeys = desc._dependentKeys; + if (!depKeys) { + return; + } - /** - Invoke this method when the contents of your enumerable has changed. - This will notify any observers watching for content changes. If you are - implementing an ordered enumerable (such as an array), also pass the - start and end values where the content changed so that it can be used to - notify range observers. - @method enumerableContentDidChange - @param {Ember.Enumerable|Number} removing An enumerable of the objects to - be removed or the number of items to be removed. - @param {Ember.Enumerable|Number} adding An enumerable of the objects to - be added or the number of items to be added. - @chainable - @private - */ - enumerableContentDidChange: function (removing, adding) { - var removeCnt = undefined, - addCnt = undefined, - hasDelta = undefined; + for (idx = 0; idx < depKeys.length; idx++) { + depKey = depKeys[idx]; + // Increment the number of times depKey depends on keyName. + meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1); + // Watch the depKey + _emberMetalWatching.watch(obj, depKey, meta); + } + } - if ('number' === typeof removing) { - removeCnt = removing; - } else if (removing) { - removeCnt = _emberMetal.get(removing, 'length'); - } else { - removeCnt = removing = -1; - } + function removeDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // remove all of its dependent keys. + var depKeys = desc._dependentKeys; + if (!depKeys) { + return; + } - if ('number' === typeof adding) { - addCnt = adding; - } else if (adding) { - addCnt = _emberMetal.get(adding, 'length'); - } else { - addCnt = adding = -1; - } + for (var idx = 0; idx < depKeys.length; idx++) { + var depKey = depKeys[idx]; + // Decrement the number of times depKey depends on keyName. + meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1); + // Unwatch the depKey + _emberMetalWatching.unwatch(obj, depKey, meta); + } + } +}); +enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set) { + /** + @module ember + @submodule ember-metal + */ - hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; + 'use strict'; - if (removing === -1) { - removing = null; - } + exports.deprecateProperty = deprecateProperty; - if (adding === -1) { - adding = null; - } + /** + Used internally to allow changing properties in a backwards compatible way, and print a helpful + deprecation warning. + + @method deprecateProperty + @param {Object} object The object to add the deprecated property to. + @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). + @param {String} newKey The property that will be aliased. + @private + @since 1.7.0 + */ - _emberMetal.sendEvent(this, '@enumerable:change', [this, removing, adding]); + function deprecateProperty(object, deprecatedKey, newKey, options) { + function _deprecate() {} - if (hasDelta) { - _emberMetal.propertyDidChange(this, 'length'); + Object.defineProperty(object, deprecatedKey, { + configurable: true, + enumerable: false, + set: function (value) { + _deprecate(); + _emberMetalProperty_set.set(this, newKey, value); + }, + get: function () { + _deprecate(); + return _emberMetalProperty_get.get(this, newKey); } + }); + } +}); +enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) { + 'use strict'; - _emberMetal.propertyDidChange(this, '[]'); + exports.default = descriptor; - return this; - }, + function descriptor(desc) { + return new Descriptor(desc); + } - /** - Converts the enumerable into an array and sorts by the keys - specified in the argument. - You may provide multiple arguments to sort by multiple properties. - @method sortBy - @param {String} property name(s) to sort on - @return {Array} The sorted array. - @since 1.2.0 - @public - */ - sortBy: function () { - var sortKeys = arguments; + /** + A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need + this at all, however, the way we currently flatten/merge our mixins require + a special value to denote a descriptor. + + @class Descriptor + @private + */ - return this.toArray().sort(function (a, b) { - for (var i = 0; i < sortKeys.length; i++) { - var key = sortKeys[i]; - var propA = _emberMetal.get(a, key); - var propB = _emberMetal.get(b, key); - // return 1 or -1 else continue to the next sortKey - var compareValue = _emberRuntimeCompare.default(propA, propB); + var Descriptor = (function (_EmberDescriptor) { + babelHelpers.inherits(Descriptor, _EmberDescriptor); - if (compareValue) { - return compareValue; - } - } - return 0; - }); + function Descriptor(desc) { + _EmberDescriptor.call(this); + this.desc = desc; } - }); - - if (true) { - Enumerable.reopen({ - /** - Returns a new enumerable that contains only items containing a unique property value. - The default implementation returns an array regardless of the receiver type. - ```javascript - let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; - arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] - ``` - @method uniqBy - @return {Ember.Enumerable} - @public - */ - uniqBy: function (key) { - var ret = emberA(); - var seen = new _emberUtils.EmptyObject(); + Descriptor.prototype.setup = function setup(obj, key) { + Object.defineProperty(obj, key, this.desc); + }; - this.forEach(function (item) { - var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); - if (!(guid in seen)) { - seen[guid] = true; - ret.push(item); - } - }); + Descriptor.prototype.teardown = function teardown(obj, key) {}; - return ret; - } - }); - } + return Descriptor; + })(_emberMetalProperties.Descriptor); +}); +enifed("ember-metal/error", ["exports"], function (exports) { - if (true) { - Enumerable.reopen({ - /** - Returns `true` if the passed object can be found in the enumerable. - ```javascript - [1, 2, 3].includes(2); // true - [1, 2, 3].includes(4); // false - [1, 2, undefined].includes(undefined); // true - [1, 2, null].includes(null); // true - [1, 2, NaN].includes(NaN); // true - ``` - @method includes - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in the enumerable. - @public - */ - includes: function (obj) { + /** + A subclass of the JavaScript Error object for use in Ember. + + @class Error + @namespace Ember + @extends Error + @constructor + @public + */ + "use strict"; - var len = _emberMetal.get(this, 'length'); - var idx = undefined, - next = undefined; - var last = null; - var found = false; + var EmberError = (function (_Error) { + babelHelpers.inherits(EmberError, _Error); - var context = popCtx(); + function EmberError(message) { + _Error.call(this); - for (idx = 0; idx < len && !found; idx++) { - next = this.nextObject(idx, last, context); + if (!(this instanceof EmberError)) { + return new EmberError(message); + } - found = obj === next || obj !== obj && next !== next; + var error = Error.call(this, message); - last = next; - } + if (Error.captureStackTrace) { + Error.captureStackTrace(this, EmberError); + } else { + this.stack = error.stack; + } - next = last = null; - context = pushCtx(context); + this.description = error.description; + this.fileName = error.fileName; + this.lineNumber = error.lineNumber; + this.message = error.message; + this.name = error.name; + this.number = error.number; + this.code = error.code; + } - return found; - }, + return EmberError; + })(Error); - without: function (value) { - if (!this.includes(value)) { - return this; // nothing to do - } + exports.default = EmberError; +}); +enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) { + 'use strict'; - var ret = emberA(); + exports.getOnerror = getOnerror; + exports.setOnerror = setOnerror; + exports.dispatchError = dispatchError; + exports.setDispatchOverride = setDispatchOverride; - this.forEach(function (k) { - // SameValueZero comparison (NaN !== NaN) - if (!(k === value || k !== k && value !== value)) { - ret[ret.length] = k; - } - }); + // To maintain stacktrace consistency across browsers + var getStack = function (error) { + var stack = error.stack; + var message = error.message; - return ret; - } - }); - } + if (stack && !stack.includes(message)) { + stack = message + '\n' + stack; + } - exports.default = Enumerable; -}); -enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + return stack; + }; - /** - @module ember - @submodule ember-runtime - */ + var onerror = undefined; + // Ember.onerror getter - /** - This mixin allows for Ember objects to subscribe to and emit events. - - ```javascript - App.Person = Ember.Object.extend(Ember.Evented, { - greet: function() { - // ... - this.trigger('greet'); - } - }); - - var person = App.Person.create(); - - person.on('greet', function() { - console.log('Our person has greeted'); - }); - - person.greet(); - - // outputs: 'Our person has greeted' - ``` - - You can also chain multiple event subscriptions: - - ```javascript - person.on('greet', function() { - console.log('Our person has greeted'); - }).one('greet', function() { - console.log('Offer one-time special'); - }).off('event', this, forgetThis); - ``` - - @class Evented - @namespace Ember - @public - */ - exports.default = _emberMetal.Mixin.create({ + function getOnerror() { + return onerror; + } - /** - Subscribes to a named event with given function. - ```javascript - person.on('didLoad', function() { - // fired once the person has loaded - }); - ``` - An optional target can be passed in as the 2nd argument that will - be set as the "this" for the callback. This is a good way to give your - function access to the object triggering the event. When the target - parameter is used the callback becomes the third argument. - @method on - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - @public - */ - on: function (name, target, method) { - _emberMetal.addListener(this, name, target, method); - return this; - }, + // Ember.onerror setter - /** - Subscribes a function to a named event and then cancels the subscription - after the first time the event is triggered. It is good to use ``one`` when - you only care about the first time an event has taken place. - This function takes an optional 2nd argument that will become the "this" - value for the callback. If this argument is passed then the 3rd argument - becomes the function. - @method one - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - @public - */ - one: function (name, target, method) { - if (!method) { - method = target; - target = null; - } + function setOnerror(handler) { + onerror = handler; + } - _emberMetal.addListener(this, name, target, method, true); - return this; - }, + var dispatchOverride = undefined; + // dispatch error - /** - Triggers a named event for the object. Any additional arguments - will be passed as parameters to the functions that are subscribed to the - event. - ```javascript - person.on('didEat', function(food) { - console.log('person ate some ' + food); - }); - person.trigger('didEat', 'broccoli'); - // outputs: person ate some broccoli - ``` - @method trigger - @param {String} name The name of the event - @param {Object...} args Optional arguments to pass on - @public - */ - trigger: function (name) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } + function dispatchError(error) { + if (dispatchOverride) { + dispatchOverride(error); + } else { + defaultDispatch(error); + } + } - _emberMetal.sendEvent(this, name, args); - }, + // allows testing adapter to override dispatch - /** - Cancels subscription for given name, target, and method. - @method off - @param {String} name The name of the event - @param {Object} target The target of the subscription - @param {Function} method The function of the subscription - @return this - @public - */ - off: function (name, target, method) { - _emberMetal.removeListener(this, name, target, method); - return this; - }, + function setDispatchOverride(handler) { + dispatchOverride = handler; + } - /** - Checks to see if object has any subscriptions for named event. - @method has - @param {String} name The name of the event - @return {Boolean} does the object have a subscription for event - @public - */ - has: function (name) { - return _emberMetal.hasListeners(this, name); + function defaultDispatch(error) { + if (_emberMetalTesting.isTesting()) { + throw error; } - }); + if (onerror) { + onerror(error); + } else { + _emberConsole.default.error(getStack(error)); + } + } }); -enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed + /** @module ember - @submodule ember-runtime + @submodule ember-metal */ + exports.accumulateListeners = accumulateListeners; + exports.addListener = addListener; + exports.removeListener = removeListener; + exports.suspendListener = suspendListener; + exports.suspendListeners = suspendListeners; + exports.watchedEvents = watchedEvents; + exports.sendEvent = sendEvent; + exports.hasListeners = hasListeners; + exports.listenersFor = listenersFor; + exports.on = on; - 'use strict'; - - /** - The `Ember.Freezable` mixin implements some basic methods for marking an - object as frozen. Once an object is frozen it should be read only. No changes - may be made the internal state of the object. - - ## Enforcement - - To fully support freezing in your subclass, you must include this mixin and - override any method that might alter any property on the object to instead - raise an exception. You can check the state of an object by checking the - `isFrozen` property. - - Although future versions of JavaScript may support language-level freezing - object objects, that is not the case today. Even if an object is freezable, - it is still technically possible to modify the object, even though it could - break other parts of your application that do not expect a frozen object to - change. It is, therefore, very important that you always respect the - `isFrozen` property on all freezable objects. - - ## Example Usage - - The example below shows a simple object that implement the `Ember.Freezable` - protocol. - - ```javascript - Contact = Ember.Object.extend(Ember.Freezable, { - firstName: null, - lastName: null, - - // swaps the names - swapNames: function() { - if (this.get('isFrozen')) throw Ember.FROZEN_ERROR; - var tmp = this.get('firstName'); - this.set('firstName', this.get('lastName')); - this.set('lastName', tmp); - return this; - } - - }); - - c = Contact.create({ firstName: "John", lastName: "Doe" }); - c.swapNames(); // returns c - c.freeze(); - c.swapNames(); // EXCEPTION - ``` + /* + The event system uses a series of nested hashes to store listeners on an + object. When a listener is registered, or when an event arrives, these + hashes are consulted to determine which target and action pair to invoke. - ## Copying + The hashes are stored in the object's meta hash, and look like this: - Usually the `Ember.Freezable` protocol is implemented in cooperation with the - `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will - return a frozen object, if the object implements this method as well. + // Object's meta hash + { + listeners: { // variable name: `listenerSet` + "foo:changed": [ // variable name: `actions` + target, method, flags + ] + } + } - @class Freezable - @namespace Ember - @since Ember 0.9 - @deprecated Use `Object.freeze` instead. - @private */ - var Freezable = _emberMetal.Mixin.create({ - init: function () { - this._super.apply(this, arguments); - }, + function indexOf(array, target, method) { + var index = -1; + // hashes are added to the end of the event array + // so it makes sense to start searching at the end + // of the array and search in reverse + for (var i = array.length - 3; i >= 0; i -= 3) { + if (target === array[i] && method === array[i + 1]) { + index = i; + break; + } + } + return index; + } - /** - Set to `true` when the object is frozen. Use this property to detect - whether your object is frozen or not. - @property isFrozen - @type Boolean - @private - */ - isFrozen: false, + function accumulateListeners(obj, eventName, otherActions) { + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta) { + return; + } + var actions = meta.matchingListeners(eventName); + var newActions = []; - /** - Freezes the object. Once this method has been called the object should - no longer allow any properties to be edited. - @method freeze - @return {Object} receiver - @private - */ - freeze: function () { - if (_emberMetal.get(this, 'isFrozen')) { - return this; - } + for (var i = actions.length - 3; i >= 0; i -= 3) { + var target = actions[i]; + var method = actions[i + 1]; + var flags = actions[i + 2]; + var actionIndex = indexOf(otherActions, target, method); - _emberMetal.set(this, 'isFrozen', true); - return this; + if (actionIndex === -1) { + otherActions.push(target, method, flags); + newActions.push(target, method, flags); + } } - }); + return newActions; + } - exports.Freezable = Freezable; - var FROZEN_ERROR = 'Frozen object cannot be modified.'; - exports.FROZEN_ERROR = FROZEN_ERROR; -}); -enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable'], function (exports, _emberMetal, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable) { /** - @module ember - @submodule ember-runtime + Add an event listener + + @method addListener + @for Ember + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Boolean} once A flag whether a function should only be called once + @public */ - 'use strict'; + function addListener(obj, eventName, target, method, once) { - exports.removeAt = removeAt; - var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; - var EMPTY = []; + if (!method && 'function' === typeof target) { + method = target; + target = null; + } - // .......................................................... - // HELPERS - // + var flags = 0; + if (once) { + flags |= _emberMetalMeta_listeners.ONCE; + } - function removeAt(array, start, len) { - if ('number' === typeof start) { - if (start < 0 || start >= _emberMetal.get(array, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } + _emberMetalMeta.meta(obj).addToListeners(eventName, target, method, flags); - // fast case - if (len === undefined) { - len = 1; - } + if ('function' === typeof obj.didAddListener) { + obj.didAddListener(eventName, target, method); + } + } - array.replace(start, len, EMPTY); + /** + Remove an event listener + + Arguments should match those passed to `Ember.addListener`. + + @method removeListener + @for Ember + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @public + */ + + function removeListener(obj, eventName, target, method) { + + if (!method && 'function' === typeof target) { + method = target; + target = null; } - return array; + _emberMetalMeta.meta(obj).removeFromListeners(eventName, target, method, function () { + if ('function' === typeof obj.didRemoveListener) { + obj.didRemoveListener.apply(obj, arguments); + } + }); } /** - This mixin defines the API for modifying array-like objects. These methods - can be applied only to a collection that keeps its items in an ordered set. - It builds upon the Array mixin and adds methods to modify the array. - One concrete implementations of this class include ArrayProxy. + Suspend listener during callback. - It is important to use the methods in this class to modify arrays so that - changes are observable. This allows the binding system in Ember to function - correctly. + This should only be used by the target of the event listener + when it is taking an action that would cause the event, e.g. + an object might suspend its property change listener while it is + setting that property. + @method suspendListener + @for Ember - Note that an Array can change even if it does not implement this mixin. - For example, one might implement a SparseArray that cannot be directly - modified, but if its underlying enumerable changes, it will change also. + @private + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Function} callback + */ + + function suspendListener(obj, eventName, target, method, callback) { + return suspendListeners(obj, [eventName], target, method, callback); + } + + /** + Suspends multiple listeners during a callback. - @class MutableArray - @namespace Ember - @uses Ember.Array - @uses Ember.MutableEnumerable - @public + @method suspendListeners + @for Ember + + @private + @param obj + @param {Array} eventNames Array of event names + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Function} callback */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, { - /** - __Required.__ You must implement this method to apply this mixin. - This is one of the primitives you must implement to support `Ember.Array`. - You should replace amt objects started at idx with the objects in the - passed array. You should also call `this.enumerableContentDidChange()` - @method replace - @param {Number} idx Starting index in the array to replace. If - idx >= length, then append to the end of the array. - @param {Number} amt Number of elements that should be removed from - the array, starting at *idx*. - @param {Array} objects An array of zero or more objects that should be - inserted into the array at *idx* - @public - */ - replace: null, + function suspendListeners(obj, eventNames, target, method, callback) { + if (!method && 'function' === typeof target) { + method = target; + target = null; + } + return _emberMetalMeta.meta(obj).suspendListeners(eventNames, target, method, callback); + } - /** - Remove all elements from the array. This is useful if you - want to reuse an existing array without having to recreate it. - ```javascript - let colors = ['red', 'green', 'blue']; - color.length(); // 3 - colors.clear(); // [] - colors.length(); // 0 - ``` - @method clear - @return {Ember.Array} An empty Array. - @public - */ - clear: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return this; - } + /** + Return a list of currently watched events + + @private + @method watchedEvents + @for Ember + @param obj + */ - this.replace(0, len, EMPTY); - return this; - }, + function watchedEvents(obj) { + return _emberMetalMeta.meta(obj).watchedEvents(); + } - /** - This will use the primitive `replace()` method to insert an object at the - specified index. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue'] - colors.insertAt(5, 'orange'); // Error: Index out of range - ``` - @method insertAt - @param {Number} idx index of insert the object at. - @param {Object} object object to insert - @return {Ember.Array} receiver - @public - */ - insertAt: function (idx, object) { - if (idx > _emberMetal.get(this, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } + /** + Send an event. The execution of suspended listeners + is skipped, and once listeners are removed. A listener without + a target is executed on the passed object. If an array of actions + is not passed, the actions stored on the passed object are invoked. + + @method sendEvent + @for Ember + @param obj + @param {String} eventName + @param {Array} params Optional parameters for each listener. + @param {Array} actions Optional array of actions (listeners). + @return true + @public + */ - this.replace(idx, 0, [object]); - return this; - }, + function sendEvent(obj, eventName, params, actions) { + if (!actions) { + var meta = _emberMetalMeta.peekMeta(obj); + actions = meta && meta.matchingListeners(eventName); + } - /** - Remove an object at the specified index using the `replace()` primitive - method. You can pass either a single index, or a start and a length. - If you pass a start and length that is beyond the - length this method will throw an `OUT_OF_RANGE_EXCEPTION`. - ```javascript - let colors = ['red', 'green', 'blue', 'yellow', 'orange']; - colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] - colors.removeAt(2, 2); // ['green', 'blue'] - colors.removeAt(4, 2); // Error: Index out of range - ``` - @method removeAt - @param {Number} start index, start of range - @param {Number} len length of passing range - @return {Ember.Array} receiver - @public - */ - removeAt: function (start, len) { - return removeAt(this, start, len); - }, + if (!actions || actions.length === 0) { + return; + } - /** - Push the object onto the end of the array. Works just like `push()` but it - is KVO-compliant. - ```javascript - let colors = ['red', 'green']; - colors.pushObject('black'); // ['red', 'green', 'black'] - colors.pushObject(['yellow']); // ['red', 'green', ['yellow']] - ``` - @method pushObject - @param {*} obj object to push - @return object same object passed as a param - @public - */ - pushObject: function (obj) { - this.insertAt(_emberMetal.get(this, 'length'), obj); - return obj; - }, + for (var i = actions.length - 3; i >= 0; i -= 3) { + // looping in reverse for once listeners + var target = actions[i]; + var method = actions[i + 1]; + var flags = actions[i + 2]; - /** - Add the objects in the passed numerable to the end of the array. Defers - notifying observers of the change until all objects are added. - ```javascript - let colors = ['red']; - colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange'] - ``` - @method pushObjects - @param {Ember.Enumerable} objects the objects to add - @return {Ember.Array} receiver - @public - */ - pushObjects: function (objects) { - if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || Array.isArray(objects))) { - throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + if (!method) { + continue; } - this.replace(_emberMetal.get(this, 'length'), 0, objects); - return this; - }, - - /** - Pop object from array or nil if none are left. Works just like `pop()` but - it is KVO-compliant. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.popObject(); // 'blue' - console.log(colors); // ['red', 'green'] - ``` - @method popObject - @return object - @public - */ - popObject: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return null; + if (flags & _emberMetalMeta_listeners.SUSPENDED) { + continue; + } + if (flags & _emberMetalMeta_listeners.ONCE) { + removeListener(obj, eventName, target, method); + } + if (!target) { + target = obj; + } + if ('string' === typeof method) { + if (params) { + _emberUtils.applyStr(target, method, params); + } else { + target[method](); + } + } else { + if (params) { + method.apply(target, params); + } else { + method.call(target); + } } + } + return true; + } + + /** + @private + @method hasListeners + @for Ember + @param obj + @param {String} eventName + */ + + function hasListeners(obj, eventName) { + var meta = _emberMetalMeta.peekMeta(obj); + if (!meta) { + return false; + } + return meta.matchingListeners(eventName).length > 0; + } - var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1); - this.removeAt(len - 1, 1); - return ret; - }, + /** + @private + @method listenersFor + @for Ember + @param obj + @param {String} eventName + */ - /** - Shift an object from start of array or nil if none are left. Works just - like `shift()` but it is KVO-compliant. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.shiftObject(); // 'red' - console.log(colors); // ['green', 'blue'] - ``` - @method shiftObject - @return object - @public - */ - shiftObject: function () { - if (_emberMetal.get(this, 'length') === 0) { - return null; - } + function listenersFor(obj, eventName) { + var ret = []; + var meta = _emberMetalMeta.peekMeta(obj); + var actions = meta && meta.matchingListeners(eventName); - var ret = _emberRuntimeMixinsArray.objectAt(this, 0); - this.removeAt(0); + if (!actions) { return ret; - }, + } - /** - Unshift an object to start of array. Works just like `unshift()` but it is - KVO-compliant. - ```javascript - let colors = ['red']; - colors.unshiftObject('yellow'); // ['yellow', 'red'] - colors.unshiftObject(['black']); // [['black'], 'yellow', 'red'] - ``` - @method unshiftObject - @param {*} obj object to unshift - @return object same object passed as a param - @public - */ - unshiftObject: function (obj) { - this.insertAt(0, obj); - return obj; - }, + for (var i = 0; i < actions.length; i += 3) { + var target = actions[i]; + var method = actions[i + 1]; + ret.push([target, method]); + } - /** - Adds the named objects to the beginning of the array. Defers notifying - observers until all objects have been added. - ```javascript - let colors = ['red']; - colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red'] - colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function - ``` - @method unshiftObjects - @param {Ember.Enumerable} objects the objects to add - @return {Ember.Array} receiver - @public - */ - unshiftObjects: function (objects) { - this.replace(0, 0, objects); - return this; - }, + return ret; + } - /** - Reverse objects in the array. Works just like `reverse()` but it is - KVO-compliant. - @method reverseObjects - @return {Ember.Array} receiver - @public - */ - reverseObjects: function () { - var len = _emberMetal.get(this, 'length'); - if (len === 0) { - return this; - } + /** + Define a property as a function that should be executed when + a specified event or events are triggered. + + + ``` javascript + let Job = Ember.Object.extend({ + logCompleted: Ember.on('completed', function() { + console.log('Job completed!'); + }) + }); + + let job = Job.create(); + + Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' + ``` + + @method on + @for Ember + @param {String} eventNames* + @param {Function} func + @return func + @public + */ - var objects = this.toArray().reverse(); - this.replace(0, len, objects); - return this; - }, + function on() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - /** - Replace all the receiver's content with content of the argument. - If argument is an empty array receiver will be cleared. - ```javascript - let colors = ['red', 'green', 'blue']; - colors.setObjects(['black', 'white']); // ['black', 'white'] - colors.setObjects([]); // [] - ``` - @method setObjects - @param {Ember.Array} objects array whose content will be used for replacing - the content of the receiver - @return {Ember.Array} receiver with the new content - @public - */ - setObjects: function (objects) { - if (objects.length === 0) { - return this.clear(); - } + var func = args.pop(); + var events = args; + func.__ember_listens__ = events; + return func; + } +}); +enifed('ember-metal/expand_properties', ['exports', 'ember-metal/debug'], function (exports, _emberMetalDebug) { + 'use strict'; - var len = _emberMetal.get(this, 'length'); - this.replace(0, len, objects); - return this; - }, + exports.default = expandProperties; - // .......................................................... - // IMPLEMENT Ember.MutableEnumerable - // + /** + @module ember + @submodule ember-metal + */ - /** - Remove all occurrences of an object in the array. - ```javascript - let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; - cities.removeObject('Chicago'); // ['Berlin', 'Lima'] - cities.removeObject('Lima'); // ['Berlin'] - cities.removeObject('Tokyo') // ['Berlin'] - ``` - @method removeObject - @param {*} obj object to remove - @return {Ember.Array} receiver - @public - */ - removeObject: function (obj) { - var loc = _emberMetal.get(this, 'length') || 0; - while (--loc >= 0) { - var curObject = _emberRuntimeMixinsArray.objectAt(this, loc); + var SPLIT_REGEX = /\{|\}/; + var END_WITH_EACH_REGEX = /\.@each$/; - if (curObject === obj) { - this.removeAt(loc); - } - } - return this; - }, + /** + Expands `pattern`, invoking `callback` for each expansion. + + The only pattern supported is brace-expansion, anything else will be passed + once to `callback` directly. + + Example + + ```js + function echo(arg){ console.log(arg); } + + Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' + Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' + Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' + Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' + Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' + Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' + Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' + ``` + + @method expandProperties + @for Ember + @private + @param {String} pattern The property pattern to expand. + @param {Function} callback The callback to invoke. It is invoked once per + expansion, and is passed the expansion. + */ - /** - Push the object onto the end of the array if it is not already - present in the array. - ```javascript - let cities = ['Chicago', 'Berlin']; - cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] - cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] - ``` - @method addObject - @param {*} obj object to add, if not already present - @return {Ember.Array} receiver - @public - */ - addObject: function (obj) { - var included = undefined; + function expandProperties(pattern, callback) { - if (true) { - included = this.includes(obj); - } else { - included = this.contains(obj); - } + var parts = pattern.split(SPLIT_REGEX); + var properties = [parts]; - if (!included) { - this.pushObject(obj); + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part.indexOf(',') >= 0) { + properties = duplicateAndReplace(properties, part.split(','), i); } + } - return this; + for (var i = 0; i < properties.length; i++) { + callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); } - }); + } + + function duplicateAndReplace(properties, currentParts, index) { + var all = []; + + properties.forEach(function (property) { + currentParts.forEach(function (part) { + var current = property.slice(0); + current[index] = part; + all.push(current); + }); + }); + + return all; + } }); -enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetal) { +enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) { 'use strict'; + exports.default = isEnabled; + /** - @module ember - @submodule ember-runtime + The hash of enabled Canary features. Add to this, any canary features + before creating your application. + + Alternatively (and recommended), you can also define `EmberENV.FEATURES` + if you need to enable features flagged at runtime. + + @class FEATURES + @namespace Ember + @static + @since 1.1.0 + @public */ + var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES); + exports.FEATURES = FEATURES; /** - This mixin defines the API for modifying generic enumerables. These methods - can be applied to an object regardless of whether it is ordered or - unordered. + Determine whether the specified `feature` is enabled. Used by Ember's + build tools to exclude experimental features from beta/stable builds. - Note that an Enumerable can change even if it does not implement this mixin. - For example, a MappedEnumerable cannot be directly modified but if its - underlying enumerable changes, it will change also. + You can define the following configuration options: - ## Adding Objects + * `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly + enabled/disabled. - To add an object to an enumerable, use the `addObject()` method. This - method will only add the object to the enumerable if the object is not - already present and is of a type supported by the enumerable. + @method isEnabled + @param {String} feature The feature to check + @return {Boolean} + @for Ember.FEATURES + @since 1.1.0 + @public + */ + + function isEnabled(feature) { + var featureValue = FEATURES[feature]; + + if (featureValue === true || featureValue === false || featureValue === undefined) { + return featureValue; + } else if (_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES) { + return true; + } else { + return false; + } + } + + exports.DEFAULT_FEATURES = _emberFeatures.default; +}); +enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get'], function (exports, _emberMetalProperty_get) { + 'use strict'; + + exports.default = getProperties; + + /** + To get multiple properties at once, call `Ember.getProperties` + with an object followed by a list of strings or an array: ```javascript - set.addObject(contact); + Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` - ## Removing Objects - - To remove an object from an enumerable, use the `removeObject()` method. This - will only remove the object if it is present in the enumerable, otherwise - this method has no effect. + is equivalent to: ```javascript - set.removeObject(contact); + Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` - ## Implementing In Your Own Code - - If you are implementing an object and want to support this API, just include - this mixin in your class and implement the required methods. In your unit - tests, be sure to apply the Ember.MutableEnumerableTests to your object. + @method getProperties + @for Ember + @param {Object} obj + @param {String...|Array} list of keys to get + @return {Object} + @public + */ + + function getProperties(obj) { + var ret = {}; + var propertyNames = arguments; + var i = 1; + + if (arguments.length === 2 && Array.isArray(arguments[1])) { + i = 0; + propertyNames = arguments[1]; + } + for (; i < propertyNames.length; i++) { + ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]); + } + return ret; + } +}); +enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/is_proxy', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalIs_proxy, _emberMetalDescriptor) { + /** + @module ember + @submodule ember-metal + */ + + 'use strict'; + + exports.default = _emberMetalCore.default; + // reexports + exports.computed = _emberMetalComputed.default; + exports.cacheFor = _emberMetalComputed.cacheFor; + exports.ComputedProperty = _emberMetalComputed.ComputedProperty; + exports.alias = _emberMetalAlias.default; + exports.merge = _emberMetalMerge.default; + exports.assert = _emberMetalDebug.assert; + exports.info = _emberMetalDebug.info; + exports.warn = _emberMetalDebug.warn; + exports.debug = _emberMetalDebug.debug; + exports.deprecate = _emberMetalDebug.deprecate; + exports.deprecateFunc = _emberMetalDebug.deprecateFunc; + exports.runInDebug = _emberMetalDebug.runInDebug; + exports.setDebugFunction = _emberMetalDebug.setDebugFunction; + exports.getDebugFunction = _emberMetalDebug.getDebugFunction; + exports.debugSeal = _emberMetalDebug.debugSeal; + exports.debugFreeze = _emberMetalDebug.debugFreeze; + exports.instrument = _emberMetalInstrumentation.instrument; + exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument; + exports._instrumentStart = _emberMetalInstrumentation._instrumentStart; + exports.instrumentationReset = _emberMetalInstrumentation.reset; + exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe; + exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe; + exports.isTesting = _emberMetalTesting.isTesting; + exports.setTesting = _emberMetalTesting.setTesting; + exports.getOnerror = _emberMetalError_handler.getOnerror; + exports.setOnerror = _emberMetalError_handler.setOnerror; + exports.dispatchError = _emberMetalError_handler.dispatchError; + exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride; + exports.META_DESC = _emberMetalMeta.META_DESC; + exports.meta = _emberMetalMeta.meta; + exports.peekMeta = _emberMetalMeta.peekMeta; + exports.Error = _emberMetalError.default; + exports.Cache = _emberMetalCache.default; + exports.isFeatureEnabled = _emberMetalFeatures.default; + exports.FEATURES = _emberMetalFeatures.FEATURES; + exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES; + exports._getPath = _emberMetalProperty_get._getPath; + exports.get = _emberMetalProperty_get.get; + exports.getWithDefault = _emberMetalProperty_get.getWithDefault; + exports.set = _emberMetalProperty_set.set; + exports.trySet = _emberMetalProperty_set.trySet; + exports.WeakMap = _emberMetalWeak_map.default; + exports.accumulateListeners = _emberMetalEvents.accumulateListeners; + exports.addListener = _emberMetalEvents.addListener; + exports.hasListeners = _emberMetalEvents.hasListeners; + exports.listenersFor = _emberMetalEvents.listenersFor; + exports.on = _emberMetalEvents.on; + exports.removeListener = _emberMetalEvents.removeListener; + exports.sendEvent = _emberMetalEvents.sendEvent; + exports.suspendListener = _emberMetalEvents.suspendListener; + exports.suspendListeners = _emberMetalEvents.suspendListeners; + exports.watchedEvents = _emberMetalEvents.watchedEvents; + exports.isNone = _emberMetalIs_none.default; + exports.isEmpty = _emberMetalIs_empty.default; + exports.isBlank = _emberMetalIs_blank.default; + exports.isPresent = _emberMetalIs_present.default; + exports.run = _emberMetalRun_loop.default; + exports.ObserverSet = _emberMetalObserver_set.default; + exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges; + exports.changeProperties = _emberMetalProperty_events.changeProperties; + exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges; + exports.overrideChains = _emberMetalProperty_events.overrideChains; + exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; + exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; + exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; + exports.defineProperty = _emberMetalProperties.defineProperty; + exports.Descriptor = _emberMetalProperties.Descriptor; + exports.watchKey = _emberMetalWatch_key.watchKey; + exports.unwatchKey = _emberMetalWatch_key.unwatchKey; + exports.ChainNode = _emberMetalChains.ChainNode; + exports.finishChains = _emberMetalChains.finishChains; + exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; + exports.watchPath = _emberMetalWatch_path.watchPath; + exports.unwatchPath = _emberMetalWatch_path.unwatchPath; + exports.destroy = _emberMetalWatching.destroy; + exports.isWatching = _emberMetalWatching.isWatching; + exports.unwatch = _emberMetalWatching.unwatch; + exports.watch = _emberMetalWatching.watch; + exports.watcherCount = _emberMetalWatching.watcherCount; + exports.libraries = _emberMetalLibraries.default; + exports.Map = _emberMetalMap.Map; + exports.MapWithDefault = _emberMetalMap.MapWithDefault; + exports.OrderedSet = _emberMetalMap.OrderedSet; + exports.getProperties = _emberMetalGet_properties.default; + exports.setProperties = _emberMetalSet_properties.default; + exports.expandProperties = _emberMetalExpand_properties.default; + exports._suspendObserver = _emberMetalObserver._suspendObserver; + exports._suspendObservers = _emberMetalObserver._suspendObservers; + exports.addObserver = _emberMetalObserver.addObserver; + exports.observersFor = _emberMetalObserver.observersFor; + exports.removeObserver = _emberMetalObserver.removeObserver; + exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; + exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.Mixin = _emberMetalMixin.Mixin; + exports.aliasMethod = _emberMetalMixin.aliasMethod; + exports._immediateObserver = _emberMetalMixin._immediateObserver; + exports._beforeObserver = _emberMetalMixin._beforeObserver; + exports.mixin = _emberMetalMixin.mixin; + exports.observer = _emberMetalMixin.observer; + exports.required = _emberMetalMixin.required; + exports.REQUIRED = _emberMetalMixin.REQUIRED; + exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins; + exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins; + exports.detectBinding = _emberMetalMixin.detectBinding; + exports.Binding = _emberMetalBinding.Binding; + exports.bind = _emberMetalBinding.bind; + exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath; + exports.InjectedProperty = _emberMetalInjected_property.default; + exports.setHasViews = _emberMetalTags.setHasViews; + exports.tagForProperty = _emberMetalTags.tagForProperty; + exports.tagFor = _emberMetalTags.tagFor; + exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty; + exports.replace = _emberMetalReplace.default; + exports.runInTransaction = _emberMetalTransaction.default; + exports.didRender = _emberMetalTransaction.didRender; + exports.assertNotRendered = _emberMetalTransaction.assertNotRendered; + exports.isProxy = _emberMetalIs_proxy.isProxy; + exports.descriptor = _emberMetalDescriptor.default; + + // TODO: this needs to be deleted once we refactor the build tooling + // do this for side-effects of updating Ember.assert, warn, etc when + // ember-debug is present + // This needs to be called before any deprecateFunc + + if (_require.has('ember-debug')) { + _require.default('ember-debug'); + } +}); +enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) { + 'use strict'; + + exports.default = InjectedProperty; + + /** + Read-only property that returns the result of a container lookup. - @class MutableEnumerable + @class InjectedProperty @namespace Ember - @uses Ember.Enumerable - @public + @constructor + @param {String} type The container type the property will lookup + @param {String} name (optional) The name the property will lookup, defaults + to the property's name + @private */ - exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, { - /** - __Required.__ You must implement this method to apply this mixin. - Attempts to add the passed object to the receiver if the object is not - already present in the collection. If the object is present, this method - has no effect. - If the passed object is of a type not supported by the receiver, - then this method should raise an exception. - @method addObject - @param {Object} object The object to add to the enumerable. - @return {Object} the passed object - @public - */ - addObject: null, + function InjectedProperty(type, name) { + this.type = type; + this.name = name; - /** - Adds each object in the passed enumerable to the receiver. - @method addObjects - @param {Ember.Enumerable} objects the objects to add. - @return {Object} receiver - @public - */ - addObjects: function (objects) { - var _this = this; + this._super$Constructor(injectedPropertyGet); + AliasedPropertyPrototype.oneWay.call(this); + } - _emberMetal.beginPropertyChanges(this); - objects.forEach(function (obj) { - return _this.addObject(obj); - }); - _emberMetal.endPropertyChanges(this); - return this; - }, + function injectedPropertyGet(keyName) { + var desc = this[keyName]; + var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat - /** - __Required.__ You must implement this method to apply this mixin. - Attempts to remove the passed object from the receiver collection if the - object is present in the collection. If the object is not present, - this method has no effect. - If the passed object is of a type not supported by the receiver, - then this method should raise an exception. - @method removeObject - @param {Object} object The object to remove from the enumerable. - @return {Object} the passed object - @public - */ - removeObject: null, + return owner.lookup(desc.type + ':' + (desc.name || keyName)); + } - /** - Removes each object in the passed enumerable from the receiver. - @method removeObjects - @param {Ember.Enumerable} objects the objects to remove - @return {Object} receiver - @public - */ - removeObjects: function (objects) { - _emberMetal.beginPropertyChanges(this); - for (var i = objects.length - 1; i >= 0; i--) { - this.removeObject(objects[i]); - } - _emberMetal.endPropertyChanges(this); - return this; - } - }); + InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype); + + var InjectedPropertyPrototype = InjectedProperty.prototype; + var ComputedPropertyPrototype = _emberMetalComputed.ComputedProperty.prototype; + var AliasedPropertyPrototype = _emberMetalAlias.AliasedProperty.prototype; + + InjectedPropertyPrototype._super$Constructor = _emberMetalComputed.ComputedProperty; + + InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; + InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; + InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; }); -enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ +enifed('ember-metal/instrumentation', ['exports', 'ember-environment', 'ember-metal/features'], function (exports, _emberEnvironment, _emberMetalFeatures) { + /* eslint no-console:off */ + /* global console */ 'use strict'; + exports.instrument = instrument; + exports._instrumentStart = _instrumentStart; + exports.subscribe = subscribe; + exports.unsubscribe = unsubscribe; + exports.reset = reset; + /** - ## Overview - - This mixin provides properties and property observing functionality, core - features of the Ember object model. - - Properties and observers allow one object to observe changes to a - property on another object. This is one of the fundamental ways that - models, controllers and views communicate with each other in an Ember - application. - - Any object that has this mixin applied can be used in observer - operations. That includes `Ember.Object` and most objects you will - interact with as you write your Ember application. - - Note that you will not generally apply this mixin to classes yourself, - but you will use the features provided by this module frequently, so it - is important to understand how to use it. - - ## Using `get()` and `set()` - - Because of Ember's support for bindings and observers, you will always - access properties using the get method, and set properties using the - set method. This allows the observing objects to be notified and - computed properties to be handled properly. + The purpose of the Ember Instrumentation module is + to provide efficient, general-purpose instrumentation + for Ember. - More documentation about `get` and `set` are below. + Subscribe to a listener by using `Ember.subscribe`: - ## Observing Property Changes + ```javascript + Ember.subscribe("render", { + before(name, timestamp, payload) { - You typically observe property changes simply by using the `Ember.observer` - function in classes that you write. + }, - For example: + after(name, timestamp, payload) { - ```javascript - Ember.Object.extend({ - valueObserver: Ember.observer('value', function(sender, key, value, rev) { - // Executes whenever the "value" property changes - // See the addObserver method for more information about the callback arguments - }) + } }); ``` - Although this is the most common way to add an observer, this capability - is actually built into the `Ember.Object` class on top of two methods - defined in this mixin: `addObserver` and `removeObserver`. You can use - these two methods to add and remove observers yourself if you need to - do so at runtime. + If you return a value from the `before` callback, that same + value will be passed as a fourth parameter to the `after` + callback. - To add an observer for a property, call: + Instrument a block of code by using `Ember.instrument`: ```javascript - object.addObserver('propertyKey', targetObject, targetAction) + Ember.instrument("render.handlebars", payload, function() { + // rendering logic + }, binding); ``` - This will call the `targetAction` method on the `targetObject` whenever - the value of the `propertyKey` changes. + Event names passed to `Ember.instrument` are namespaced + by periods, from more general to more specific. Subscribers + can listen for events by whatever level of granularity they + are interested in. - Note that if `propertyKey` is a computed property, the observer will be - called when any of the property dependencies are changed, even if the - resulting value of the computed property is unchanged. This is necessary - because computed properties are not computed until `get` is called. + In the above example, the event is `render.handlebars`, + and the subscriber listened for all events beginning with + `render`. It would receive callbacks for events named + `render`, `render.handlebars`, `render.container`, or + even `render.handlebars.layout`. - @class Observable + @class Instrumentation @namespace Ember - @public + @static + @private */ - exports.default = _emberMetal.Mixin.create({ + var subscribers = []; + exports.subscribers = subscribers; + var cache = {}; - /** - Retrieves the value of a property from the object. - This method is usually similar to using `object[keyName]` or `object.keyName`, - however it supports both computed properties and the unknownProperty - handler. - Because `get` unifies the syntax for accessing all these kinds - of properties, it can make many refactorings easier, such as replacing a - simple property with a computed property, or vice versa. - ### Computed Properties - Computed properties are methods defined with the `property` modifier - declared at the end, such as: - ```javascript - fullName: Ember.computed('firstName', 'lastName', function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }) - ``` - When you call `get` on a computed property, the function will be - called and the return value will be returned instead of the function - itself. - ### Unknown Properties - Likewise, if you try to call `get` on a property whose value is - `undefined`, the `unknownProperty()` method will be called on the object. - If this method returns any value other than `undefined`, it will be returned - instead. This allows you to implement "virtual" properties that are - not defined upfront. - @method get - @param {String} keyName The property to retrieve - @return {Object} The property value or undefined. - @public - */ - get: function (keyName) { - return _emberMetal.get(this, keyName); - }, + function populateListeners(name) { + var listeners = []; + var subscriber = undefined; - /** - To get the values of multiple properties at once, call `getProperties` - with a list of strings or an array: - ```javascript - record.getProperties('firstName', 'lastName', 'zipCode'); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - is equivalent to: - ```javascript - record.getProperties(['firstName', 'lastName', 'zipCode']); - // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } - ``` - @method getProperties - @param {String...|Array} list of keys to get - @return {Object} - @public - */ - getProperties: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var i = 0; i < subscribers.length; i++) { + subscriber = subscribers[i]; + if (subscriber.regex.test(name)) { + listeners.push(subscriber.object); } + } - return _emberMetal.getProperties.apply(null, [this].concat(args)); - }, + cache[name] = listeners; + return listeners; + } - /** - Sets the provided key or path to the value. - ```javascript - record.set("key", value); - ``` - This method is generally very similar to calling `object["key"] = value` or - `object.key = value`, except that it provides support for computed - properties, the `setUnknownProperty()` method and property observers. - ### Computed Properties - If you try to set a value on a key that has a computed property handler - defined (see the `get()` method for an example), then `set()` will call - that method, passing both the value and key instead of simply changing - the value itself. This is useful for those times when you need to - implement a property that is composed of one or more member - properties. - ### Unknown Properties - If you try to set a value on a key that is undefined in the target - object, then the `setUnknownProperty()` handler will be called instead. This - gives you an opportunity to implement complex "virtual" properties that - are not predefined on the object. If `setUnknownProperty()` returns - undefined, then `set()` will simply set the value on the object. - ### Property Observers - In addition to changing the property, `set()` will also register a property - change with the object. Unless you have placed this call inside of a - `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers - (i.e. observer methods declared on the same object), will be called - immediately. Any "remote" observers (i.e. observer methods declared on - another object) will be placed in a queue and called at a later time in a - coalesced manner. - @method set - @param {String} keyName The property to set - @param {Object} value The value to set or `null`. - @return {Object} The passed value - @public - */ - set: function (keyName, value) { - return _emberMetal.set(this, keyName, value); - }, + var time = (function () { + var perf = 'undefined' !== typeof window ? window.performance || {} : {}; + var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; + // fn.bind will be available in all the browsers that support the advanced window.performance... ;-) + return fn ? fn.bind(perf) : function () { + return +new Date(); + }; + })(); - /** - Sets a list of properties at once. These properties are set inside - a single `beginPropertyChanges` and `endPropertyChanges` batch, so - observers will be buffered. - ```javascript - record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); - ``` - @method setProperties - @param {Object} hash the hash of keys and values to set - @return {Object} The passed in hash - @public - */ - setProperties: function (hash) { - return _emberMetal.setProperties(this, hash); - }, + /** + Notifies event's subscribers, calls `before` and `after` hooks. + + @method instrument + @namespace Ember.Instrumentation + + @param {String} [name] Namespaced event name. + @param {Object} _payload + @param {Function} callback Function that you're instrumenting. + @param {Object} binding Context that instrument function is called with. + @private + */ - /** - Begins a grouping of property changes. - You can use this method to group property changes so that notifications - will not be sent until the changes are finished. If you plan to make a - large number of changes to an object at one time, you should call this - method at the beginning of the changes to begin deferring change - notifications. When you are done making changes, call - `endPropertyChanges()` to deliver the deferred change notifications and end - deferring. - @method beginPropertyChanges - @return {Ember.Observable} - @private - */ - beginPropertyChanges: function () { - _emberMetal.beginPropertyChanges(); - return this; - }, + function instrument(name, _payload, callback, binding) { + if (arguments.length <= 3 && typeof _payload === 'function') { + binding = callback; + callback = _payload; + _payload = undefined; + } + if (subscribers.length === 0) { + return callback.call(binding); + } + var payload = _payload || {}; + var finalizer = _instrumentStart(name, function () { + return payload; + }); - /** - Ends a grouping of property changes. - You can use this method to group property changes so that notifications - will not be sent until the changes are finished. If you plan to make a - large number of changes to an object at one time, you should call - `beginPropertyChanges()` at the beginning of the changes to defer change - notifications. When you are done making changes, call this method to - deliver the deferred change notifications and end deferring. - @method endPropertyChanges - @return {Ember.Observable} - @private - */ - endPropertyChanges: function () { - _emberMetal.endPropertyChanges(); - return this; - }, + if (finalizer) { + return withFinalizer(callback, finalizer, payload, binding); + } else { + return callback.call(binding); + } + } - /** - Notify the observer system that a property is about to change. - Sometimes you need to change a value directly or indirectly without - actually calling `get()` or `set()` on it. In this case, you can use this - method and `propertyDidChange()` instead. Calling these two methods - together will notify all observers that the property has potentially - changed value. - Note that you must always call `propertyWillChange` and `propertyDidChange` - as a pair. If you do not, it may get the property change groups out of - order and cause notifications to be delivered more often than you would - like. - @method propertyWillChange - @param {String} keyName The property key that is about to change. - @return {Ember.Observable} - @private - */ - propertyWillChange: function (keyName) { - _emberMetal.propertyWillChange(this, keyName); - return this; - }, + var flaggedInstrument = undefined; + if (_emberMetalFeatures.default('ember-improved-instrumentation')) { + exports.flaggedInstrument = flaggedInstrument = instrument; + } else { + exports.flaggedInstrument = flaggedInstrument = function (name, payload, callback) { + return callback(); + }; + } + exports.flaggedInstrument = flaggedInstrument; - /** - Notify the observer system that a property has just changed. - Sometimes you need to change a value directly or indirectly without - actually calling `get()` or `set()` on it. In this case, you can use this - method and `propertyWillChange()` instead. Calling these two methods - together will notify all observers that the property has potentially - changed value. - Note that you must always call `propertyWillChange` and `propertyDidChange` - as a pair. If you do not, it may get the property change groups out of - order and cause notifications to be delivered more often than you would - like. - @method propertyDidChange - @param {String} keyName The property key that has just changed. - @return {Ember.Observable} - @private - */ - propertyDidChange: function (keyName) { - _emberMetal.propertyDidChange(this, keyName); - return this; - }, + function withFinalizer(callback, finalizer, payload, binding) { + var result = undefined; + try { + result = callback.call(binding); + } catch (e) { + payload.exception = e; + result = payload; + } finally { + finalizer(); + } + return result; + } - /** - Convenience method to call `propertyWillChange` and `propertyDidChange` in - succession. - @method notifyPropertyChange - @param {String} keyName The property key to be notified about. - @return {Ember.Observable} - @public - */ - notifyPropertyChange: function (keyName) { - this.propertyWillChange(keyName); - this.propertyDidChange(keyName); - return this; - }, + function NOOP() {} - /** - Adds an observer on a property. - This is the core method used to register an observer for a property. - Once you call this method, any time the key's value is set, your observer - will be notified. Note that the observers are triggered any time the - value is set, regardless of whether it has actually changed. Your - observer should be prepared to handle that. - You can also pass an optional context parameter to this method. The - context will be passed to your observer method whenever it is triggered. - Note that if you add the same target/method pair on a key multiple times - with different context parameters, your observer will only be called once - with the last context you passed. - ### Observer Methods - Observer methods you pass should generally have the following signature if - you do not pass a `context` parameter: - ```javascript - fooDidChange: function(sender, key, value, rev) { }; - ``` - The sender is the object that changed. The key is the property that - changes. The value property is currently reserved and unused. The rev - is the last property revision of the object when it changed, which you can - use to detect if the key value has really changed or not. - If you pass a `context` parameter, the context will be passed before the - revision like so: - ```javascript - fooDidChange: function(sender, key, value, context, rev) { }; - ``` - Usually you will not need the value, context or revision parameters at - the end. In this case, it is common to write observer methods that take - only a sender and key value as parameters or, if you aren't interested in - any of these values, to write an observer that has no parameters at all. - @method addObserver - @param {String} key The key to observer - @param {Object} target The target object to invoke - @param {String|Function} method The method to invoke. - @public - */ - addObserver: function (key, target, method) { - _emberMetal.addObserver(this, key, target, method); - }, + // private for now - /** - Remove an observer you have previously registered on this object. Pass - the same key, target, and method you passed to `addObserver()` and your - target will no longer receive notifications. - @method removeObserver - @param {String} key The key to observer - @param {Object} target The target object to invoke - @param {String|Function} method The method to invoke. - @public - */ - removeObserver: function (key, target, method) { - _emberMetal.removeObserver(this, key, target, method); - }, + function _instrumentStart(name, _payload, _payloadParam) { + if (subscribers.length === 0) { + return NOOP; + } + + var listeners = cache[name]; + + if (!listeners) { + listeners = populateListeners(name); + } + + if (listeners.length === 0) { + return NOOP; + } + + var payload = _payload(_payloadParam); + + var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE; + var timeName = undefined; + if (STRUCTURED_PROFILE) { + timeName = name + ': ' + payload.object; + console.time(timeName); + } - /** - Returns `true` if the object currently has observers registered for a - particular key. You can use this method to potentially defer performing - an expensive action until someone begins observing a particular property - on the object. - @method hasObserverFor - @param {String} key Key to check - @return {Boolean} - @private - */ - hasObserverFor: function (key) { - return _emberMetal.hasListeners(this, key + ':change'); - }, + var beforeValues = new Array(listeners.length); + var i = undefined, + listener = undefined; + var timestamp = time(); + for (i = 0; i < listeners.length; i++) { + listener = listeners[i]; + beforeValues[i] = listener.before(name, timestamp, payload); + } - /** - Retrieves the value of a property, or a default value in the case that the - property returns `undefined`. - ```javascript - person.getWithDefault('lastName', 'Doe'); - ``` - @method getWithDefault - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public - */ - getWithDefault: function (keyName, defaultValue) { - return _emberMetal.getWithDefault(this, keyName, defaultValue); - }, + return function _instrumentEnd() { + var i = undefined, + listener = undefined; + var timestamp = time(); + for (i = 0; i < listeners.length; i++) { + listener = listeners[i]; + if (typeof listener.after === 'function') { + listener.after(name, timestamp, payload, beforeValues[i]); + } + } - /** - Set the value of a property to the current value plus some amount. - ```javascript - person.incrementProperty('age'); - team.incrementProperty('score', 2); - ``` - @method incrementProperty - @param {String} keyName The name of the property to increment - @param {Number} increment The amount to increment by. Defaults to 1 - @return {Number} The new property value - @public - */ - incrementProperty: function (keyName, increment) { - if (_emberMetal.isNone(increment)) { - increment = 1; + if (STRUCTURED_PROFILE) { + console.timeEnd(timeName); } + }; + } - return _emberMetal.set(this, keyName, (parseFloat(_emberMetal.get(this, keyName)) || 0) + increment); - }, + /** + Subscribes to a particular event or instrumented block of code. + + @method subscribe + @namespace Ember.Instrumentation + + @param {String} [pattern] Namespaced event name. + @param {Object} [object] Before and After hooks. + + @return {Subscriber} + @private + */ - /** - Set the value of a property to the current value minus some amount. - ```javascript - player.decrementProperty('lives'); - orc.decrementProperty('health', 5); - ``` - @method decrementProperty - @param {String} keyName The name of the property to decrement - @param {Number} decrement The amount to decrement by. Defaults to 1 - @return {Number} The new property value - @public - */ - decrementProperty: function (keyName, decrement) { - if (_emberMetal.isNone(decrement)) { - decrement = 1; + function subscribe(pattern, object) { + var paths = pattern.split('.'); + var path = undefined; + var regex = []; + + for (var i = 0; i < paths.length; i++) { + path = paths[i]; + if (path === '*') { + regex.push('[^\\.]*'); + } else { + regex.push(path); } + } - return _emberMetal.set(this, keyName, (_emberMetal.get(this, keyName) || 0) - decrement); - }, + regex = regex.join('\\.'); + regex = regex + '(\\..*)?'; - /** - Set the value of a boolean property to the opposite of its - current value. - ```javascript - starship.toggleProperty('warpDriveEngaged'); - ``` - @method toggleProperty - @param {String} keyName The name of the property to toggle - @return {Boolean} The new property value - @public - */ - toggleProperty: function (keyName) { - return _emberMetal.set(this, keyName, !_emberMetal.get(this, keyName)); - }, + var subscriber = { + pattern: pattern, + regex: new RegExp('^' + regex + '$'), + object: object + }; - /** - Returns the cached value of a computed property, if it exists. - This allows you to inspect the value of a computed property - without accidentally invoking it if it is intended to be - generated lazily. - @method cacheFor - @param {String} keyName - @return {Object} The cached value of the computed property, if any - @public - */ - cacheFor: function (keyName) { - return _emberMetal.cacheFor(this, keyName); - }, + subscribers.push(subscriber); + cache = {}; - // intended for debugging purposes - observersForKey: function (keyName) { - return _emberMetal.observersFor(this, keyName); - } - }); -}); -enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros) { - 'use strict'; + return subscriber; + } /** - @module ember - @submodule ember-runtime + Unsubscribes from a particular event or instrumented block of code. + + @method unsubscribe + @namespace Ember.Instrumentation + + @param {Object} [subscriber] + @private */ - function tap(proxy, promise) { - _emberMetal.setProperties(proxy, { - isFulfilled: false, - isRejected: false - }); + function unsubscribe(subscriber) { + var index = undefined; - return promise.then(function (value) { - if (!proxy.isDestroyed && !proxy.isDestroying) { - _emberMetal.setProperties(proxy, { - content: value, - isFulfilled: true - }); - } - return value; - }, function (reason) { - if (!proxy.isDestroyed && !proxy.isDestroying) { - _emberMetal.setProperties(proxy, { - reason: reason, - isRejected: true - }); + for (var i = 0; i < subscribers.length; i++) { + if (subscribers[i] === subscriber) { + index = i; } - throw reason; - }, 'Ember: PromiseProxy'); + } + + subscribers.splice(index, 1); + cache = {}; } /** - A low level mixin making ObjectProxy promise-aware. - - ```javascript - let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); + Resets `Ember.Instrumentation` by flushing list of subscribers. - let proxy = ObjectPromiseProxy.create({ - promise: Ember.RSVP.cast($.getJSON('/some/remote/data.json')) - }); + @method reset + @namespace Ember.Instrumentation + @private + */ + + function reset() { + subscribers.length = 0; + cache = {}; + } +}); +enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (exports, _emberMetalIs_empty) { + 'use strict'; + + exports.default = isBlank; + + /** + A value is blank if it is empty or a whitespace string. - proxy.then(function(json){ - // the json - }, function(reason) { - // the reason why you have no json - }); + ```javascript + Ember.isBlank(); // true + Ember.isBlank(null); // true + Ember.isBlank(undefined); // true + Ember.isBlank(''); // true + Ember.isBlank([]); // true + Ember.isBlank('\n\t'); // true + Ember.isBlank(' '); // true + Ember.isBlank({}); // false + Ember.isBlank('\n\t Hello'); // false + Ember.isBlank('Hello world'); // false + Ember.isBlank([1,2,3]); // false ``` - the proxy has bindable attributes which - track the promises life cycle + @method isBlank + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @since 1.5.0 + @public + */ + + function isBlank(obj) { + return _emberMetalIs_empty.default(obj) || typeof obj === 'string' && obj.match(/\S/) === null; + } +}); +enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, _emberMetalProperty_get, _emberMetalIs_none) { + 'use strict'; + + exports.default = isEmpty; + + /** + Verifies that a value is `null` or an empty string, empty array, + or empty function. + + Constrains the rules on `Ember.isNone` by returning true for empty + string and empty arrays. ```javascript - proxy.get('isPending') //=> true - proxy.get('isSettled') //=> false - proxy.get('isRejected') //=> false - proxy.get('isFulfilled') //=> false + Ember.isEmpty(); // true + Ember.isEmpty(null); // true + Ember.isEmpty(undefined); // true + Ember.isEmpty(''); // true + Ember.isEmpty([]); // true + Ember.isEmpty({}); // false + Ember.isEmpty('Adam Hawkins'); // false + Ember.isEmpty([0,1,2]); // false + Ember.isEmpty('\n\t'); // false + Ember.isEmpty(' '); // false ``` - When the $.getJSON completes, and the promise is fulfilled - with json, the life cycle attributes will update accordingly. - Note that $.getJSON doesn't return an ECMA specified promise, - it is useful to wrap this with an `RSVP.cast` so that it behaves - as a spec compliant promise. + @method isEmpty + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @public + */ + + function isEmpty(obj) { + var none = _emberMetalIs_none.default(obj); + if (none) { + return none; + } + + if (typeof obj.size === 'number') { + return !obj.size; + } + + var objectType = typeof obj; + + if (objectType === 'object') { + var size = _emberMetalProperty_get.get(obj, 'size'); + if (typeof size === 'number') { + return !size; + } + } + + if (typeof obj.length === 'number' && objectType !== 'function') { + return !obj.length; + } + + if (objectType === 'object') { + var _length = _emberMetalProperty_get.get(obj, 'length'); + if (typeof _length === 'number') { + return !_length; + } + } + + return false; + } +}); +enifed("ember-metal/is_none", ["exports"], function (exports) { + /** + Returns true if the passed value is null or undefined. This avoids errors + from JSLint complaining about use of ==, which can be technically + confusing. ```javascript - proxy.get('isPending') //=> false - proxy.get('isSettled') //=> true - proxy.get('isRejected') //=> false - proxy.get('isFulfilled') //=> true + Ember.isNone(); // true + Ember.isNone(null); // true + Ember.isNone(undefined); // true + Ember.isNone(''); // false + Ember.isNone([]); // false + Ember.isNone(function() {}); // false ``` - As the proxy is an ObjectProxy, and the json now its content, - all the json properties will be available directly from the proxy. + @method isNone + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @public + */ + "use strict"; + + exports.default = isNone; + + function isNone(obj) { + return obj === null || obj === undefined; + } +}); +enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (exports, _emberMetalIs_blank) { + 'use strict'; + + exports.default = isPresent; + + /** + A value is present if it not `isBlank`. ```javascript - // Assuming the following json: - { - firstName: 'Stefan', - lastName: 'Penner' - } - - // both properties will accessible on the proxy - proxy.get('firstName') //=> 'Stefan' - proxy.get('lastName') //=> 'Penner' + Ember.isPresent(); // false + Ember.isPresent(null); // false + Ember.isPresent(undefined); // false + Ember.isPresent(''); // false + Ember.isPresent(' '); // false + Ember.isPresent('\n\t'); // false + Ember.isPresent([]); // false + Ember.isPresent({ length: 0 }) // false + Ember.isPresent(false); // true + Ember.isPresent(true); // true + Ember.isPresent('string'); // true + Ember.isPresent(0); // true + Ember.isPresent(function() {}) // true + Ember.isPresent({}); // true + Ember.isPresent(false); // true + Ember.isPresent('\n\t Hello'); // true + Ember.isPresent([1,2,3]); // true ``` - @class Ember.PromiseProxyMixin + @method isPresent + @for Ember + @param {Object} obj Value to test + @return {Boolean} + @since 1.8.0 @public */ - exports.default = _emberMetal.Mixin.create({ - /** - If the proxied promise is rejected this will contain the reason - provided. - @property reason - @default null - @public - */ - reason: null, - /** - Once the proxied promise has settled this will become `false`. - @property isPending - @default true - @public - */ - isPending: _emberRuntimeComputedComputed_macros.not('isSettled').readOnly(), + function isPresent(obj) { + return !_emberMetalIs_blank.default(obj); + } +}); +enifed('ember-metal/is_proxy', ['exports', 'ember-metal/meta'], function (exports, _emberMetalMeta) { + 'use strict'; - /** - Once the proxied promise has settled this will become `true`. - @property isSettled - @default false - @public - */ - isSettled: _emberRuntimeComputedComputed_macros.or('isRejected', 'isFulfilled').readOnly(), + exports.isProxy = isProxy; - /** - Will become `true` if the proxied promise is rejected. - @property isRejected - @default false - @public - */ - isRejected: false, + function isProxy(value) { + if (typeof value === 'object' && value) { + var meta = _emberMetalMeta.peekMeta(value); + return meta && meta.isProxy(); + } - /** - Will become `true` if the proxied promise is fulfilled. - @property isFulfilled - @default false - @public - */ - isFulfilled: false, + return false; + } +}); +enifed('ember-metal/libraries', ['exports', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalDebug, _emberMetalFeatures) { + 'use strict'; - /** - The promise whose fulfillment value is being proxied by this object. - This property must be specified upon creation, and should not be - changed once created. - Example: - ```javascript - Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({ - promise: - }); - ``` - @property promise - @public - */ - promise: _emberMetal.computed({ - get: function () { - throw new _emberMetal.Error('PromiseProxy\'s promise must be set'); - }, - set: function (key, promise) { - return tap(this, promise); + /** + Helper class that allows you to register your library with Ember. + + Singleton created at `Ember.libraries`. + + @class Libraries + @constructor + @private + */ + + var Libraries = (function () { + function Libraries() { + this._registry = []; + this._coreLibIndex = 0; + } + + Libraries.prototype.isRegistered = function isRegistered(name) { + return !!this._getLibraryByName(name); + }; + + return Libraries; + })(); + + exports.Libraries = Libraries; + + Libraries.prototype = { + constructor: Libraries, + + _getLibraryByName: function (name) { + var libs = this._registry; + var count = libs.length; + + for (var i = 0; i < count; i++) { + if (libs[i].name === name) { + return libs[i]; + } } - }), + }, - /** - An alias to the proxied promise's `then`. - See RSVP.Promise.then. - @method then - @param {Function} callback - @return {RSVP.Promise} - @public - */ - then: promiseAlias('then'), + register: function (name, version, isCoreLibrary) { + var index = this._registry.length; + + if (!this._getLibraryByName(name)) { + if (isCoreLibrary) { + index = this._coreLibIndex++; + } + this._registry.splice(index, 0, { name: name, version: version }); + } else {} + }, - /** - An alias to the proxied promise's `catch`. - See RSVP.Promise.catch. - @method catch - @param {Function} callback - @return {RSVP.Promise} - @since 1.3.0 - @public - */ - 'catch': promiseAlias('catch'), + registerCoreLibrary: function (name, version) { + this.register(name, version, true); + }, - /** - An alias to the proxied promise's `finally`. - See RSVP.Promise.finally. - @method finally - @param {Function} callback - @return {RSVP.Promise} - @since 1.3.0 - @public - */ - 'finally': promiseAlias('finally') + deRegister: function (name) { + var lib = this._getLibraryByName(name); + var index = undefined; - }); + if (lib) { + index = this._registry.indexOf(lib); + this._registry.splice(index, 1); + } + } + }; - function promiseAlias(name) { - return function () { - var promise = _emberMetal.get(this, 'promise'); - return promise[name].apply(promise, arguments); + if (_emberMetalFeatures.default('ember-libraries-isregistered')) { + Libraries.prototype.isRegistered = function (name) { + return !!this._getLibraryByName(name); }; } + + exports.default = new Libraries(); }); -enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) { /** @module ember - @submodule ember-runtime + @submodule ember-metal */ + /* + JavaScript (before ES6) does not have a Map implementation. Objects, + which are often used as dictionaries, may only have Strings as keys. + + Because Ember has a way to get a unique identifier for every object + via `Ember.guidFor`, we can implement a performant Map with arbitrary + keys. Because it is commonly used in low-level bookkeeping, Map is + implemented as a pure JavaScript object for performance. + + This implementation follows the current iteration of the ES6 proposal for + maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets), + with one exception: as we do not have the luxury of in-VM iteration, we implement a + forEach method for iteration. + + Map is mocked out to look like an Ember object, so you can do + `Ember.Map.create()` for symmetry with other Ember classes. + */ 'use strict'; - exports.buildFakeRegistryWithDeprecations = buildFakeRegistryWithDeprecations; + function missingFunction(fn) { + throw new TypeError(Object.prototype.toString.call(fn) + ' is not a function'); + } + + function missingNew(name) { + throw new TypeError('Constructor ' + name + ' requires \'new\''); + } + + function copyNull(obj) { + var output = new _emberUtils.EmptyObject(); + + for (var prop in obj) { + // hasOwnPropery is not needed because obj is new EmptyObject(); + output[prop] = obj[prop]; + } + + return output; + } + + function copyMap(original, newObject) { + var keys = original._keys.copy(); + var values = copyNull(original._values); + + newObject._keys = keys; + newObject._values = values; + newObject.size = original.size; + + return newObject; + } /** - RegistryProxyMixin is used to provide public access to specific - registry functionality. + This class is used internally by Ember and Ember Data. + Please do not use it at this time. We plan to clean it up + and add many tests soon. - @class RegistryProxyMixin + @class OrderedSet + @namespace Ember + @constructor @private */ - exports.default = _emberMetal.Mixin.create({ - __registry__: null, + function OrderedSet() { + if (this instanceof OrderedSet) { + this.clear(); + this._silenceRemoveDeprecation = false; + } else { + missingNew('OrderedSet'); + } + } - /** - Given a fullName return the corresponding factory. - @public - @method resolveRegistration - @param {String} fullName - @return {Function} fullName's factory - */ - resolveRegistration: registryAlias('resolve'), + /** + @method create + @static + @return {Ember.OrderedSet} + @private + */ + OrderedSet.create = function () { + var Constructor = this; - /** - Registers a factory that can be used for dependency injection (with - `inject`) or for service lookup. Each factory is registered with - a full name including two parts: `type:name`. - A simple example: - ```javascript - let App = Ember.Application.create(); - App.Orange = Ember.Object.extend(); - App.register('fruit:favorite', App.Orange); - ``` - Ember will resolve factories from the `App` namespace automatically. - For example `App.CarsController` will be discovered and returned if - an application requests `controller:cars`. - An example of registering a controller with a non-standard name: - ```javascript - let App = Ember.Application.create(); - let Session = Ember.Controller.extend(); - App.register('controller:session', Session); - // The Session controller can now be treated like a normal controller, - // despite its non-standard name. - App.ApplicationController = Ember.Controller.extend({ - needs: ['session'] - }); - ``` - Registered factories are **instantiated** by having `create` - called on them. Additionally they are **singletons**, each time - they are looked up they return the same instance. - Some examples modifying that default behavior: - ```javascript - let App = Ember.Application.create(); - App.Person = Ember.Object.extend(); - App.Orange = Ember.Object.extend(); - App.Email = Ember.Object.extend(); - App.session = Ember.Object.create(); - App.register('model:user', App.Person, { singleton: false }); - App.register('fruit:favorite', App.Orange); - App.register('communication:main', App.Email, { singleton: false }); - App.register('session', App.session, { instantiate: false }); - ``` - @method register - @param fullName {String} type:name (e.g., 'model:user') - @param factory {Function} (e.g., App.Person) - @param options {Object} (optional) disable instantiation or singleton usage - @public - */ - register: registryAlias('register'), + return new Constructor(); + }; + OrderedSet.prototype = { + constructor: OrderedSet, /** - Unregister a factory. - ```javascript - let App = Ember.Application.create(); - let User = Ember.Object.extend(); - App.register('model:user', User); - App.resolveRegistration('model:user').create() instanceof User //=> true - App.unregister('model:user') - App.resolveRegistration('model:user') === undefined //=> true - ``` - @public - @method unregister - @param {String} fullName - */ - unregister: registryAlias('unregister'), + @method clear + @private + */ + clear: function () { + this.presenceSet = new _emberUtils.EmptyObject(); + this.list = []; + this.size = 0; + }, /** - Check if a factory is registered. - @public - @method hasRegistration - @param {String} fullName - @return {Boolean} - */ - hasRegistration: registryAlias('has'), + @method add + @param obj + @param guid (optional, and for internal use) + @return {Ember.OrderedSet} + @private + */ + add: function (obj, _guid) { + var guid = _guid || _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; + var list = this.list; - /** - Register an option for a particular factory. - @public - @method registerOption - @param {String} fullName - @param {String} optionName - @param {Object} options - */ - registerOption: registryAlias('option'), + if (presenceSet[guid] !== true) { + presenceSet[guid] = true; + this.size = list.push(obj); + } - /** - Return a specific registered option for a particular factory. - @public - @method registeredOption - @param {String} fullName - @param {String} optionName - @return {Object} options - */ - registeredOption: registryAlias('getOption'), + return this; + }, /** - Register options for a particular factory. - @public - @method registerOptions - @param {String} fullName - @param {Object} options - */ - registerOptions: registryAlias('options'), + @since 1.8.0 + @method delete + @param obj + @param _guid (optional and for internal use only) + @return {Boolean} + @private + */ + delete: function (obj, _guid) { + var guid = _guid || _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; + var list = this.list; - /** - Return registered options for a particular factory. - @public - @method registeredOptions - @param {String} fullName - @return {Object} options - */ - registeredOptions: registryAlias('getOptions'), + if (presenceSet[guid] === true) { + delete presenceSet[guid]; + var index = list.indexOf(obj); + if (index > -1) { + list.splice(index, 1); + } + this.size = list.length; + return true; + } else { + return false; + } + }, /** - Allow registering options for all factories of a type. - ```javascript - let App = Ember.Application.create(); - let appInstance = App.buildInstance(); - // if all of type `connection` must not be singletons - appInstance.optionsForType('connection', { singleton: false }); - appInstance.register('connection:twitter', TwitterConnection); - appInstance.register('connection:facebook', FacebookConnection); - let twitter = appInstance.lookup('connection:twitter'); - let twitter2 = appInstance.lookup('connection:twitter'); - twitter === twitter2; // => false - let facebook = appInstance.lookup('connection:facebook'); - let facebook2 = appInstance.lookup('connection:facebook'); - facebook === facebook2; // => false - ``` - @public - @method registerOptionsForType - @param {String} type - @param {Object} options - */ - registerOptionsForType: registryAlias('optionsForType'), + @method isEmpty + @return {Boolean} + @private + */ + isEmpty: function () { + return this.size === 0; + }, /** - Return the registered options for all factories of a type. - @public - @method registeredOptionsForType - @param {String} type - @return {Object} options - */ - registeredOptionsForType: registryAlias('getOptionsForType'), + @method has + @param obj + @return {Boolean} + @private + */ + has: function (obj) { + if (this.size === 0) { + return false; + } + + var guid = _emberUtils.guidFor(obj); + var presenceSet = this.presenceSet; + + return presenceSet[guid] === true; + }, /** - Define a dependency injection onto a specific factory or all factories - of a type. - When Ember instantiates a controller, view, or other framework component - it can attach a dependency to that component. This is often used to - provide services to a set of framework components. - An example of providing a session object to all controllers: - ```javascript - let App = Ember.Application.create(); - let Session = Ember.Object.extend({ isAuthenticated: false }); - // A factory must be registered before it can be injected - App.register('session:main', Session); - // Inject 'session:main' onto all factories of the type 'controller' - // with the name 'session' - App.inject('controller', 'session', 'session:main'); - App.IndexController = Ember.Controller.extend({ - isLoggedIn: Ember.computed.alias('session.isAuthenticated') - }); - ``` - Injections can also be performed on specific factories. - ```javascript - App.inject(, , ) - App.inject('route', 'source', 'source:main') - App.inject('route:application', 'email', 'model:email') - ``` - It is important to note that injections can only be performed on - classes that are instantiated by Ember itself. Instantiating a class - directly (via `create` or `new`) bypasses the dependency injection - system. - **Note:** Ember-Data instantiates its models in a unique manner, and consequently - injections onto models (or all models) will not work as expected. Injections - on models can be enabled by setting `EmberENV.MODEL_FACTORY_INJECTIONS` - to `true`. - @public - @method inject - @param factoryNameOrType {String} - @param property {String} - @param injectionName {String} - **/ - inject: registryAlias('injection') - }); + @method forEach + @param {Function} fn + @param self + @private + */ + forEach: function (fn /*, ...thisArg*/) { + if (typeof fn !== 'function') { + missingFunction(fn); + } - function registryAlias(name) { - return function () { - var _registry__; + if (this.size === 0) { + return; + } - return (_registry__ = this.__registry__)[name].apply(_registry__, arguments); - }; - } + var list = this.list; - function buildFakeRegistryWithDeprecations(instance, typeForMessage) { - var fakeRegistry = {}; - var registryProps = { - resolve: 'resolveRegistration', - register: 'register', - unregister: 'unregister', - has: 'hasRegistration', - option: 'registerOption', - options: 'registerOptions', - getOptions: 'registeredOptions', - optionsForType: 'registerOptionsForType', - getOptionsForType: 'registeredOptionsForType', - injection: 'inject' - }; + if (arguments.length === 2) { + for (var i = 0; i < list.length; i++) { + fn.call(arguments[1], list[i]); + } + } else { + for (var i = 0; i < list.length; i++) { + fn(list[i]); + } + } + }, - for (var deprecatedProperty in registryProps) { - fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]); - } + /** + @method toArray + @return {Array} + @private + */ + toArray: function () { + return this.list.slice(); + }, - return fakeRegistry; - } + /** + @method copy + @return {Ember.OrderedSet} + @private + */ + copy: function () { + var Constructor = this.constructor; + var set = new Constructor(); - function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) { - return function () { - return instance[nonDeprecatedProperty].apply(instance, arguments); - }; - } -}); -enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { - /** - @module ember - @submodule ember-runtime - */ + set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; + set.presenceSet = copyNull(this.presenceSet); + set.list = this.toArray(); + set.size = this.size; - 'use strict'; + return set; + } + }; /** - `Ember.TargetActionSupport` is a mixin that can be included in a class - to add a `triggerAction` method with semantics similar to the Handlebars - `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is - usually the best choice. This mixin is most often useful when you are - doing more complex event handling in Components. + A Map stores values indexed by keys. Unlike JavaScript's + default Objects, the keys of a Map can be any JavaScript + object. - @class TargetActionSupport - @namespace Ember - @extends Ember.Mixin - @private + Internally, a Map has two data structures: + + 1. `keys`: an OrderedSet of all of the existing keys + 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)` + + When a key/value pair is added for the first time, we + add the key to the `keys` OrderedSet, and create or + replace an entry in `values`. When an entry is deleted, + we delete its entry in `keys` and `values`. + + @class Map + @namespace Ember + @private + @constructor */ - exports.default = _emberMetal.Mixin.create({ - target: null, - action: null, - actionContext: null, - - actionContextObject: _emberMetal.computed('actionContext', function () { - var actionContext = _emberMetal.get(this, 'actionContext'); + function Map() { + if (this instanceof Map) { + this._keys = OrderedSet.create(); + this._keys._silenceRemoveDeprecation = true; + this._values = new _emberUtils.EmptyObject(); + this.size = 0; + } else { + missingNew('Map'); + } + } - if (typeof actionContext === 'string') { - var value = _emberMetal.get(this, actionContext); - if (value === undefined) { - value = _emberMetal.get(_emberEnvironment.context.lookup, actionContext); - } - return value; - } else { - return actionContext; - } - }), + /** + @method create + @static + @private + */ + Map.create = function () { + var Constructor = this; + return new Constructor(); + }; + + Map.prototype = { + constructor: Map, /** - Send an `action` with an `actionContext` to a `target`. The action, actionContext - and target will be retrieved from properties of the object. For example: - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - target: Ember.computed.alias('controller'), - action: 'save', - actionContext: Ember.computed.alias('context'), - click() { - this.triggerAction(); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - The `target`, `action`, and `actionContext` can be provided as properties of - an optional object argument to `triggerAction` as well. - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - click() { - this.triggerAction({ - action: 'save', - target: this.get('controller'), - actionContext: this.get('context') - }); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. - But `target` and `action` must be specified either as properties or with the argument - to `triggerAction`, or a combination: - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - target: Ember.computed.alias('controller'), - click() { - this.triggerAction({ - action: 'save' - }); // Sends the `save` action, along with a reference to `this`, - // to the current controller - } - }); - ``` - @method triggerAction - @param opts {Object} (optional, with the optional keys action, target and/or actionContext) - @return {Boolean} true if the action was sent successfully and did not return false - @private + This property will change as the number of objects in the map changes. + @since 1.8.0 + @property size + @type number + @default 0 + @private */ - triggerAction: function () { - var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - var action = opts.action || _emberMetal.get(this, 'action'); - var target = opts.target; + size: 0, - if (!target) { - target = getTarget(this); + /** + Retrieve the value associated with a given key. + @method get + @param {*} key + @return {*} the value associated with the key, or `undefined` + @private + */ + get: function (key) { + if (this.size === 0) { + return; } - var actionContext = opts.actionContext; + var values = this._values; + var guid = _emberUtils.guidFor(key); - function args(options, actionName) { - var ret = []; - if (actionName) { - ret.push(actionName); - } + return values[guid]; + }, - return ret.concat(options); - } + /** + Adds a value to the map. If a value for the given key has already been + provided, the new value will replace the old value. + @method set + @param {*} key + @param {*} value + @return {Ember.Map} + @private + */ + set: function (key, value) { + var keys = this._keys; + var values = this._values; + var guid = _emberUtils.guidFor(key); - if (typeof actionContext === 'undefined') { - actionContext = _emberMetal.get(this, 'actionContextObject') || this; - } + // ensure we don't store -0 + var k = key === -0 ? 0 : key; - if (target && action) { - var ret = undefined; + keys.add(k, guid); - if (target.send) { - ret = target.send.apply(target, args(actionContext, action)); - } else { - ret = target[action].apply(target, args(actionContext)); - } + values[guid] = value; - if (ret !== false) { - ret = true; - } + this.size = keys.size; - return ret; + return this; + }, + + /** + Removes a value from the map for an associated key. + @since 1.8.0 + @method delete + @param {*} key + @return {Boolean} true if an item was removed, false otherwise + @private + */ + delete: function (key) { + if (this.size === 0) { + return false; + } + // don't use ES6 "delete" because it will be annoying + // to use in browsers that are not ES6 friendly; + var keys = this._keys; + var values = this._values; + var guid = _emberUtils.guidFor(key); + + if (keys.delete(key, guid)) { + delete values[guid]; + this.size = keys.size; + return true; } else { return false; } - } - }); + }, - function getTarget(instance) { - // TODO: Deprecate specifying `targetObject` - var target = _emberMetal.get(instance, 'targetObject'); + /** + Check whether a key is present. + @method has + @param {*} key + @return {Boolean} true if the item was present, false otherwise + @private + */ + has: function (key) { + return this._keys.has(key); + }, - // if a `targetObject` CP was provided, use it - if (target) { - return target; - } + /** + Iterate over all the keys and values. Calls the function once + for each key, passing in value, key, and the map being iterated over, + in that order. + The keys are guaranteed to be iterated over in insertion order. + @method forEach + @param {Function} callback + @param {*} self if passed, the `this` value inside the + callback. By default, `this` is the map. + @private + */ + forEach: function (callback /*, ...thisArg*/) { + if (typeof callback !== 'function') { + missingFunction(callback); + } - // if _targetObject use it - if (instance._targetObject) { - return instance._targetObject; - } + if (this.size === 0) { + return; + } - target = _emberMetal.get(instance, 'target'); - if (target) { - if (typeof target === 'string') { - var value = _emberMetal.get(instance, target); - if (value === undefined) { - value = _emberMetal.get(_emberEnvironment.context.lookup, target); - } + var map = this; + var cb = undefined, + thisArg = undefined; - return value; + if (arguments.length === 2) { + thisArg = arguments[1]; + cb = function (key) { + return callback.call(thisArg, map.get(key), key, map); + }; } else { - return target; + cb = function (key) { + return callback(map.get(key), key, map); + }; } - } - return null; - } -}); -enifed("ember-runtime/string_registry", ["exports"], function (exports) { - // STATE within a module is frowned apon, this exists - // to support Ember.STRINGS but shield ember internals from this legacy global - // API. - "use strict"; + this._keys.forEach(cb); + }, - exports.setStrings = setStrings; - exports.getStrings = getStrings; - exports.get = get; - var STRINGS = {}; + /** + @method clear + @private + */ + clear: function () { + this._keys.clear(); + this._values = new _emberUtils.EmptyObject(); + this.size = 0; + }, - function setStrings(strings) { - STRINGS = strings; - } + /** + @method copy + @return {Ember.Map} + @private + */ + copy: function () { + return copyMap(this, new Map()); + } + }; - function getStrings() { - return STRINGS; + /** + @class MapWithDefault + @namespace Ember + @extends Ember.Map + @private + @constructor + @param [options] + @param {*} [options.defaultValue] + */ + function MapWithDefault(options) { + this._super$constructor(); + this.defaultValue = options.defaultValue; } - function get(name) { - return STRINGS[name]; - } -}); -enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) { - 'use strict'; + /** + @method create + @static + @param [options] + @param {*} [options.defaultValue] + @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns + `Ember.MapWithDefault` otherwise returns `Ember.Map` + @private + */ + MapWithDefault.create = function (options) { + if (options) { + return new MapWithDefault(options); + } else { + return new Map(); + } + }; - exports.default = _emberRuntimeSystemNamespace.default.extend(); -}); -enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray) { - 'use strict'; + MapWithDefault.prototype = Object.create(Map.prototype); + MapWithDefault.prototype.constructor = MapWithDefault; + MapWithDefault.prototype._super$constructor = Map; + MapWithDefault.prototype._super$get = Map.prototype.get; /** - @module ember - @submodule ember-runtime + Retrieve the value associated with a given key. + + @method get + @param {*} key + @return {*} the value associated with the key, or the default value + @private */ + MapWithDefault.prototype.get = function (key) { + var hasValue = this.has(key); - var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; - var EMPTY = []; + if (hasValue) { + return this._super$get(key); + } else { + var defaultValue = this.defaultValue(key); + this.set(key, defaultValue); + return defaultValue; + } + }; - function K() { - return this; - } + /** + @method copy + @return {Ember.MapWithDefault} + @private + */ + MapWithDefault.prototype.copy = function () { + var Constructor = this.constructor; + return copyMap(this, new Constructor({ + defaultValue: this.defaultValue + })); + }; + exports.default = Map; + exports.OrderedSet = OrderedSet; + exports.Map = Map; + exports.MapWithDefault = MapWithDefault; +}); +enifed('ember-metal/merge', ['exports'], function (exports) { /** - An ArrayProxy wraps any other object that implements `Ember.Array` and/or - `Ember.MutableArray,` forwarding all requests. This makes it very useful for - a number of binding use cases or other cases where being able to swap - out the underlying array is useful. - - A simple example of usage: - - ```javascript - let pets = ['dog', 'cat', 'fish']; - let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); - - ap.get('firstObject'); // 'dog' - ap.set('content', ['amoeba', 'paramecium']); - ap.get('firstObject'); // 'amoeba' - ``` - - This class can also be useful as a layer to transform the contents of - an array, as they are accessed. This can be done by overriding - `objectAtContent`: + Merge the contents of two objects together into the first object. ```javascript - let pets = ['dog', 'cat', 'fish']; - let ap = Ember.ArrayProxy.create({ - content: Ember.A(pets), - objectAtContent: function(idx) { - return this.get('content').objectAt(idx).toUpperCase(); - } - }); - - ap.get('firstObject'); // . 'DOG' + Ember.merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' } + var a = { first: 'Yehuda' }; + var b = { last: 'Katz' }; + Ember.merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' } ``` - @class ArrayProxy - @namespace Ember - @extends Ember.Object - @uses Ember.MutableArray + @method merge + @for Ember + @param {Object} original The object to merge into + @param {Object} updates The object to copy properties from + @return {Object} @public */ - exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { + 'use strict'; - /** - The content array. Must be an object that implements `Ember.Array` and/or - `Ember.MutableArray.` - @property content - @type Ember.Array - @private - */ - content: null, + exports.default = merge; - /** - The array that the proxy pretends to be. In the default `ArrayProxy` - implementation, this and `content` are the same. Subclasses of `ArrayProxy` - can override this property to provide things like sorting and filtering. - @property arrangedContent - @private - */ - arrangedContent: _emberMetal.alias('content'), + function merge(original, updates) { + if (!updates || typeof updates !== 'object') { + return original; + } - /** - Should actually retrieve the object at the specified index from the - content. You can override this method in subclasses to transform the - content item to something new. - This method will only be called if content is non-`null`. - @method objectAtContent - @param {Number} idx The index to retrieve. - @return {Object} the value or undefined if none found - @public - */ - objectAtContent: function (idx) { - return _emberRuntimeMixinsArray.objectAt(_emberMetal.get(this, 'arrangedContent'), idx); - }, + var props = Object.keys(updates); + var prop = undefined; - /** - Should actually replace the specified objects on the content array. - You can override this method in subclasses to transform the content item - into something new. - This method will only be called if content is non-`null`. - @method replaceContent - @param {Number} idx The starting index - @param {Number} amt The number of items to remove from the content. - @param {Array} objects Optional array of objects to insert or null if no - objects. - @return {void} - @private - */ - replaceContent: function (idx, amt, objects) { - _emberMetal.get(this, 'content').replace(idx, amt, objects); - }, + for (var i = 0; i < props.length; i++) { + prop = props[i]; + original[prop] = updates[prop]; + } - /** - Invoked when the content property is about to change. Notifies observers that the - entire array content will change. - @private - @method _contentWillChange - */ - _contentWillChange: _emberMetal._beforeObserver('content', function () { - this._teardownContent(); - }), + return original; + } +}); +enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/debug', 'ember-metal/chains', 'require'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalDebug, _emberMetalChains, _require) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - _teardownContent: function () { - var content = _emberMetal.get(this, 'content'); + exports.deleteMeta = deleteMeta; + exports.meta = meta; - if (content) { - _emberRuntimeMixinsArray.removeArrayObserver(content, this, { - willChange: 'contentArrayWillChange', - didChange: 'contentArrayDidChange' - }); - } - }, + var counters = { + peekCalls: 0, + peekParentCalls: 0, + peekPrototypeWalks: 0, + setCalls: 0, + deleteCalls: 0, + metaCalls: 0, + metaInstantiated: 0 + }; - /** - Override to implement content array `willChange` observer. - @method contentArrayWillChange - @param {Ember.Array} contentArray the content array - @param {Number} start starting index of the change - @param {Number} removeCount count of items removed - @param {Number} addCount count of items added - @private - */ - contentArrayWillChange: K, - /** - Override to implement content array `didChange` observer. - @method contentArrayDidChange - @param {Ember.Array} contentArray the content array - @param {Number} start starting index of the change - @param {Number} removeCount count of items removed - @param {Number} addCount count of items added - @private - */ - contentArrayDidChange: K, + /** + @module ember-metal + */ + + /* + This declares several meta-programmed members on the Meta class. Such + meta! + + In general, the `readable` variants will give you an object (if it + already exists) that you can read but should not modify. The + `writable` variants will give you a mutable object, and they will + create it if it didn't already exist. + + The following methods will get generated metaprogrammatically, and + I'm including them here for greppability: + + writableCache, readableCache, writeWatching, + peekWatching, clearWatching, writeMixins, + peekMixins, clearMixins, writeBindings, + peekBindings, clearBindings, writeValues, + peekValues, clearValues, writeDeps, forEachInDeps + writableChainWatchers, readableChainWatchers, writableChains, + readableChains, writableTag, readableTag, writableTags, + readableTags + */ + var members = { + cache: ownMap, + weak: ownMap, + watching: inheritedMap, + mixins: inheritedMap, + bindings: inheritedMap, + values: inheritedMap, + chainWatchers: ownCustomObject, + chains: inheritedCustomObject, + tag: ownCustomObject, + tags: ownMap + }; - /** - Invoked when the content property changes. Notifies observers that the - entire array content has changed. - @private - @method _contentDidChange - */ - _contentDidChange: _emberMetal.observer('content', function () { - var content = _emberMetal.get(this, 'content'); + // FLAGS + var SOURCE_DESTROYING = 1 << 1; + var SOURCE_DESTROYED = 1 << 2; + var META_DESTROYED = 1 << 3; + var IS_PROXY = 1 << 4; - this._setupContent(); - }), + if (false || false) { + members.lastRendered = ownMap; + if (_require.has('ember-debug')) { + //https://github.com/emberjs/ember.js/issues/14732 + members.lastRenderedReferenceMap = ownMap; + members.lastRenderedTemplateMap = ownMap; + } + } - _setupContent: function () { - var content = _emberMetal.get(this, 'content'); + var memberNames = Object.keys(members); + var META_FIELD = '__ember_meta__'; - if (content) { + var Meta = (function () { + 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; + this._chainWatchers = undefined; + this._chains = undefined; + this._tag = undefined; + this._tags = undefined; + + // initial value for all flags right now is false + // see FLAGS const for detailed list of flags used + this._flags = 0; + + // used only internally + this.source = obj; + + // when meta(obj).proto === obj, the object is intended to be only a + // prototype and doesn't need to actually be observable itself + this.proto = undefined; + + // The next meta in our inheritance chain. We (will) track this + // explicitly instead of using prototypical inheritance because we + // have detailed knowledge of how each property should really be + // inherited, and we can optimize it much better than JS runtimes. + this.parent = parentMeta; - _emberRuntimeMixinsArray.addArrayObserver(content, this, { - willChange: 'contentArrayWillChange', - didChange: 'contentArrayDidChange' - }); + if (false || false) { + this._lastRendered = undefined; } - }, - _arrangedContentWillChange: _emberMetal._beforeObserver('arrangedContent', function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + this._initializeListeners(); + } - this.arrangedContentArrayWillChange(this, 0, len, undefined); - this.arrangedContentWillChange(this); + Meta.prototype.isInitialized = function isInitialized(obj) { + return this.proto !== obj; + }; - this._teardownArrangedContent(arrangedContent); - }), + Meta.prototype.destroy = function destroy() { + if (this.isMetaDestroyed()) { + return; + } - _arrangedContentDidChange: _emberMetal.observer('arrangedContent', function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + // remove chainWatchers to remove circular references that would prevent GC + var nodes = undefined, + key = undefined, + nodeObject = undefined; + var node = this.readableChains(); + if (node) { + NODE_STACK.push(node); + // process tree + while (NODE_STACK.length > 0) { + node = NODE_STACK.pop(); + // push children + nodes = node._chains; + if (nodes) { + for (key in nodes) { + if (nodes[key] !== undefined) { + NODE_STACK.push(nodes[key]); + } + } + } - this._setupArrangedContent(); + // remove chainWatcher in node object + if (node._watching) { + nodeObject = node._object; + if (nodeObject) { + var foreignMeta = peekMeta(nodeObject); + // avoid cleaning up chain watchers when both current and + // foreign objects are being destroyed + // if both are being destroyed manual cleanup is not needed + // as they will be GC'ed and no non-destroyed references will + // be remaining + if (foreignMeta && !foreignMeta.isSourceDestroying()) { + _emberMetalChains.removeChainWatcher(nodeObject, node._key, node, foreignMeta); + } + } + } + } + } - this.arrangedContentDidChange(this); - this.arrangedContentArrayDidChange(this, 0, undefined, len); - }), + this.setMetaDestroyed(); + }; - _setupArrangedContent: function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + Meta.prototype.isSourceDestroying = function isSourceDestroying() { + return (this._flags & SOURCE_DESTROYING) !== 0; + }; - if (arrangedContent) { + Meta.prototype.setSourceDestroying = function setSourceDestroying() { + this._flags |= SOURCE_DESTROYING; + }; - _emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, { - willChange: 'arrangedContentArrayWillChange', - didChange: 'arrangedContentArrayDidChange' - }); - } - }, + Meta.prototype.isSourceDestroyed = function isSourceDestroyed() { + return (this._flags & SOURCE_DESTROYED) !== 0; + }; - _teardownArrangedContent: function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + Meta.prototype.setSourceDestroyed = function setSourceDestroyed() { + this._flags |= SOURCE_DESTROYED; + }; - if (arrangedContent) { - _emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, { - willChange: 'arrangedContentArrayWillChange', - didChange: 'arrangedContentArrayDidChange' - }); - } - }, + Meta.prototype.isMetaDestroyed = function isMetaDestroyed() { + return (this._flags & META_DESTROYED) !== 0; + }; - arrangedContentWillChange: K, - arrangedContentDidChange: K, + Meta.prototype.setMetaDestroyed = function setMetaDestroyed() { + this._flags |= META_DESTROYED; + }; - objectAt: function (idx) { - return _emberMetal.get(this, 'content') && this.objectAtContent(idx); - }, + Meta.prototype.isProxy = function isProxy() { + return (this._flags & IS_PROXY) !== 0; + }; - length: _emberMetal.computed(function () { - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - return arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - // No dependencies since Enumerable notifies length of change - }), + Meta.prototype.setProxy = function setProxy() { + this._flags |= IS_PROXY; + }; - _replace: function (idx, amt, objects) { - var content = _emberMetal.get(this, 'content'); + Meta.prototype._getOrCreateOwnMap = function _getOrCreateOwnMap(key) { + return this[key] || (this[key] = new _emberUtils.EmptyObject()); + }; - if (content) { - this.replaceContent(idx, amt, objects); + Meta.prototype._getInherited = function _getInherited(key) { + var pointer = this; + while (pointer !== undefined) { + if (pointer[key]) { + return pointer[key]; + } + pointer = pointer.parent; } + }; - return this; - }, - - replace: function () { - if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { - this._replace.apply(this, arguments); - } else { - throw new _emberMetal.Error('Using replace on an arranged ArrayProxy is not allowed.'); + Meta.prototype._findInherited = function _findInherited(key, subkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var value = map[subkey]; + if (value !== undefined) { + return value; + } + } + pointer = pointer.parent; } - }, + }; - _insertAt: function (idx, object) { - if (idx > _emberMetal.get(this, 'content.length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } + // Implements a member that provides a lazily created map of maps, + // with inheritance at both levels. - this._replace(idx, 0, [object]); - return this; - }, + Meta.prototype.writeDeps = function writeDeps(subkey, itemkey, value) { - insertAt: function (idx, object) { - if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { - return this._insertAt(idx, object); - } else { - throw new _emberMetal.Error('Using insertAt on an arranged ArrayProxy is not allowed.'); + var outerMap = this._getOrCreateOwnMap('_deps'); + var innerMap = outerMap[subkey]; + if (!innerMap) { + innerMap = outerMap[subkey] = new _emberUtils.EmptyObject(); } - }, - - removeAt: function (start, len) { - if ('number' === typeof start) { - var content = _emberMetal.get(this, 'content'); - var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var indices = []; - - if (start < 0 || start >= _emberMetal.get(this, 'length')) { - throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); - } - - if (len === undefined) { - len = 1; - } + innerMap[itemkey] = value; + }; - // Get a list of indices in original content to remove - for (var i = start; i < start + len; i++) { - // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent - indices.push(content.indexOf(_emberRuntimeMixinsArray.objectAt(arrangedContent, i))); + Meta.prototype.peekDeps = function peekDeps(subkey, itemkey) { + var pointer = this; + while (pointer !== undefined) { + var map = pointer._deps; + if (map) { + var value = map[subkey]; + if (value) { + if (value[itemkey] !== undefined) { + return value[itemkey]; + } + } } + pointer = pointer.parent; + } + }; - // Replace in reverse order since indices will change - indices.sort(function (a, b) { - return b - a; - }); - - _emberMetal.beginPropertyChanges(); - for (var i = 0; i < indices.length; i++) { - this._replace(indices[i], 1, EMPTY); + Meta.prototype.hasDeps = function hasDeps(subkey) { + var pointer = this; + while (pointer !== undefined) { + if (pointer._deps && pointer._deps[subkey]) { + return true; } - _emberMetal.endPropertyChanges(); + pointer = pointer.parent; } + return false; + }; - return this; - }, - - pushObject: function (obj) { - this._insertAt(_emberMetal.get(this, 'content.length'), obj); - return obj; - }, + Meta.prototype.forEachInDeps = function forEachInDeps(subkey, fn) { + return this._forEachIn('_deps', subkey, fn); + }; - pushObjects: function (objects) { - if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || _emberRuntimeUtils.isArray(objects))) { - throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + Meta.prototype._forEachIn = function _forEachIn(key, subkey, fn) { + var pointer = this; + var seen = new _emberUtils.EmptyObject(); + var calls = []; + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + var innerMap = map[subkey]; + if (innerMap) { + for (var innerKey in innerMap) { + if (!seen[innerKey]) { + seen[innerKey] = true; + calls.push([innerKey, innerMap[innerKey]]); + } + } + } + } + pointer = pointer.parent; } - this._replace(_emberMetal.get(this, 'length'), 0, objects); - return this; - }, + for (var i = 0; i < calls.length; i++) { + var _calls$i = calls[i]; + var innerKey = _calls$i[0]; + var value = _calls$i[1]; - setObjects: function (objects) { - if (objects.length === 0) { - return this.clear(); + fn(innerKey, value); } + }; - var len = _emberMetal.get(this, 'length'); - this._replace(0, len, objects); - return this; - }, - - unshiftObject: function (obj) { - this._insertAt(0, obj); - return obj; - }, - - unshiftObjects: function (objects) { - this._replace(0, 0, objects); - return this; - }, - - slice: function () { - var arr = this.toArray(); - return arr.slice.apply(arr, arguments); - }, - - arrangedContentArrayWillChange: function (item, idx, removedCnt, addedCnt) { - this.arrayContentWillChange(idx, removedCnt, addedCnt); - }, - - arrangedContentArrayDidChange: function (item, idx, removedCnt, addedCnt) { - this.arrayContentDidChange(idx, removedCnt, addedCnt); - }, - - init: function () { - this._super.apply(this, arguments); - this._setupContent(); - this._setupArrangedContent(); - }, - - willDestroy: function () { - this._teardownArrangedContent(); - this._teardownContent(); - } - }); -}); -enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/inject'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeInject) { - 'no use strict'; - // Remove "use strict"; from transpiled module until - // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - - /** - @module ember - @submodule ember-runtime - */ - - // using ember-metal/lib/main here to ensure that ember-debug is setup - // if present - - var _Mixin$create, _ClassMixinProps; - - var schedule = _emberMetal.run.schedule; - var applyMixin = _emberMetal.Mixin._apply; - var finishPartial = _emberMetal.Mixin.finishPartial; - var reopen = _emberMetal.Mixin.prototype.reopen; - var hasCachedComputedProperties = false; - - var POST_INIT = _emberUtils.symbol('POST_INIT'); - - exports.POST_INIT = POST_INIT; - function makeCtor() { - // Note: avoid accessing any properties on the object since it makes the - // method a lot faster. This is glue code so we want it to be as fast as - // possible. - - var wasApplied = false; - var initProperties; + Meta.prototype.readInheritedValue = function readInheritedValue(key, subkey) { + var internalKey = '_' + key; - var Class = function () { - if (!wasApplied) { - Class.proto(); // prepare prototype... - } + var pointer = this; - if (arguments.length > 0) { - initProperties = [arguments[0]]; + while (pointer !== undefined) { + var map = pointer[internalKey]; + if (map) { + var value = map[subkey]; + if (value !== undefined || subkey in map) { + return map[subkey]; + } + } + pointer = pointer.parent; } - this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); - var m = _emberMetal.meta(this); - var proto = m.proto; - m.proto = this; - if (initProperties) { - // capture locally so we can clear the closed over variable - var props = initProperties; - initProperties = null; - - var concatenatedProperties = this.concatenatedProperties; - var mergedProperties = this.mergedProperties; + return UNDEFINED; + }; - for (var i = 0; i < props.length; i++) { - var properties = props[i]; + Meta.prototype.writeValue = function writeValue(obj, key, value) { + var descriptor = _emberUtils.lookupDescriptor(obj, key); + var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - if (typeof properties !== 'object' && properties !== undefined) { - throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); - } + if (isMandatorySetter) { + this.writeValues(key, value); + } else { + obj[key] = value; + } + }; - if (!properties) { - continue; - } + return Meta; + })(); - var keyNames = Object.keys(properties); + exports.Meta = Meta; - for (var j = 0; j < keyNames.length; j++) { - var keyName = keyNames[j]; - var value = properties[keyName]; + var NODE_STACK = []; - if (_emberMetal.detectBinding(keyName)) { - m.writeBindings(keyName, value); - } + for (var _name in _emberMetalMeta_listeners.protoMethods) { + Meta.prototype[_name] = _emberMetalMeta_listeners.protoMethods[_name]; + } + memberNames.forEach(function (name) { + return members[name](name, Meta); + }); - var possibleDesc = this[keyName]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + // Implements a member that is a lazily created, non-inheritable + // POJO. + function ownMap(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function () { + return this._getOrCreateOwnMap(key); + }; + Meta.prototype['readable' + capitalized] = function () { + return this[key]; + }; + } - if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { - var baseValue = this[keyName]; + // Implements a member that is a lazily created POJO with inheritable + // values. + function inheritedMap(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); - if (baseValue) { - if ('function' === typeof baseValue.concat) { - value = baseValue.concat(value); - } else { - value = _emberUtils.makeArray(baseValue).concat(value); - } - } else { - value = _emberUtils.makeArray(value); - } - } + Meta.prototype['write' + capitalized] = function (subkey, value) { - if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { - var originalValue = this[keyName]; + var map = this._getOrCreateOwnMap(key); + map[subkey] = value; + }; - value = _emberUtils.assign({}, originalValue, value); - } + Meta.prototype['peek' + capitalized] = function (subkey) { + return this._findInherited(key, subkey); + }; - if (desc) { - desc.set(this, keyName, value); - } else { - if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { - this.setUnknownProperty(keyName, value); - } else { - if (false) { - _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter - } else { - this[keyName] = value; - } - } + Meta.prototype['forEach' + capitalized] = function (fn) { + var pointer = this; + var seen = new _emberUtils.EmptyObject(); + while (pointer !== undefined) { + var map = pointer[key]; + if (map) { + for (var _key in map) { + if (!seen[_key]) { + seen[_key] = true; + fn(_key, map[_key]); } } } + pointer = pointer.parent; } + }; - finishPartial(this, m); - - this.init.apply(this, arguments); - - this[POST_INIT](); + Meta.prototype['clear' + capitalized] = function () { - m.proto = proto; - _emberMetal.finishChains(this); - _emberMetal.sendEvent(this, 'init'); + this[key] = undefined; }; - Class.toString = _emberMetal.Mixin.prototype.toString; - Class.willReopen = function () { - if (wasApplied) { - Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); - } - - wasApplied = false; + Meta.prototype['deleteFrom' + capitalized] = function (subkey) { + delete this._getOrCreateOwnMap(key)[subkey]; }; - Class._initProperties = function (args) { - initProperties = args; + Meta.prototype['hasIn' + capitalized] = function (subkey) { + return this._findInherited(key, subkey) !== undefined; }; + } - Class.proto = function () { - var superclass = Class.superclass; - if (superclass) { - superclass.proto(); - } + var UNDEFINED = _emberUtils.symbol('undefined'); - if (!wasApplied) { - wasApplied = true; - Class.PrototypeMixin.applyPartial(Class.prototype); - } + exports.UNDEFINED = UNDEFINED; + // Implements a member that provides a non-heritable, lazily-created + // object using the method you provide. + function ownCustomObject(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function (create) { - return this.prototype; + var ret = this[key]; + if (!ret) { + ret = this[key] = create(this.source); + } + return ret; + }; + Meta.prototype['readable' + capitalized] = function () { + return this[key]; }; - - return Class; } - /** - @class CoreObject - @namespace Ember - @public - */ - var CoreObject = makeCtor(); - CoreObject.toString = function () { - return 'Ember.CoreObject'; - }; - CoreObject.PrototypeMixin = _emberMetal.Mixin.create((_Mixin$create = { - reopen: function () { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - applyMixin(this, args, true); - return this; - }, + // Implements a member that provides an inheritable, lazily-created + // object using the method you provide. We will derived children from + // their parents by calling your object's `copy()` method. + function inheritedCustomObject(name, Meta) { + var key = memberProperty(name); + var capitalized = capitalize(name); + Meta.prototype['writable' + capitalized] = function (create) { - /** - An overridable method called when objects are instantiated. By default, - does nothing unless it is overridden during class definition. - Example: - ```javascript - const Person = Ember.Object.extend({ - init() { - alert(`Name is ${this.get('name')}`); + var ret = this[key]; + if (!ret) { + if (this.parent) { + ret = this[key] = this.parent['writable' + capitalized](create).copy(this.source); + } else { + ret = this[key] = create(this.source); } - }); - let steve = Person.create({ - name: "Steve" - }); - // alerts 'Name is Steve'. - ``` - NOTE: If you do override `init` for a framework class like `Ember.View`, - be sure to call `this._super(...arguments)` in your - `init` declaration! If you don't, Ember may not have an opportunity to - do important setup work, and you'll see strange behavior in your - application. - @method init - @public - */ - init: function () {} - - }, _Mixin$create[POST_INIT] = function () {}, _Mixin$create.__defineNonEnumerable = function (property) { - Object.defineProperty(this, property.name, property.descriptor); - //this[property.name] = property.descriptor.value; - }, _Mixin$create.concatenatedProperties = null, _Mixin$create.mergedProperties = null, _Mixin$create.isDestroyed = _emberMetal.descriptor({ - get: function () { - return _emberMetal.meta(this).isSourceDestroyed(); - }, - - set: function (value) { - // prevent setting while applying mixins - if (typeof value === 'object' && value !== null && value.isDescriptor) { - return; - } - } - }), _Mixin$create.isDestroying = _emberMetal.descriptor({ - get: function () { - return _emberMetal.meta(this).isSourceDestroying(); - }, - - set: function (value) { - // prevent setting while applying mixins - if (typeof value === 'object' && value !== null && value.isDescriptor) { - return; } - } - }), _Mixin$create.destroy = function () { - var m = _emberMetal.meta(this); - if (m.isSourceDestroying()) { - return; - } - - m.setSourceDestroying(); - - schedule('actions', this, this.willDestroy); - schedule('destroy', this, this._scheduledDestroy, m); - - return this; - }, _Mixin$create.willDestroy = function () {}, _Mixin$create._scheduledDestroy = function (m) { - if (m.isSourceDestroyed()) { - return; - } - _emberMetal.destroy(this); - m.setSourceDestroyed(); - }, _Mixin$create.bind = function (to, from) { - if (!(from instanceof _emberMetal.Binding)) { - from = _emberMetal.Binding.from(from); - } - from.to(to).connect(this); - return from; - }, _Mixin$create.toString = function () { - var hasToStringExtension = typeof this.toStringExtension === 'function'; - var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; - var ret = '<' + this.constructor.toString() + ':' + _emberUtils.guidFor(this) + extension + '>'; + return ret; + }; + Meta.prototype['readable' + capitalized] = function () { + return this._getInherited(key); + }; + } - return ret; - }, _Mixin$create)); + function memberProperty(name) { + return '_' + name; + } - CoreObject.PrototypeMixin.ownerConstructor = CoreObject; + // there's a more general-purpose capitalize in ember-runtime, but we + // don't want to make ember-metal depend on ember-runtime. + function capitalize(name) { + return name.replace(/^\w/, function (m) { + return m.toUpperCase(); + }); + } - CoreObject.__super__ = null; + var META_DESC = { + writable: true, + configurable: true, + enumerable: false, + value: null + }; - var ClassMixinProps = (_ClassMixinProps = { + exports.META_DESC = META_DESC; + var EMBER_META_PROPERTY = { + name: META_FIELD, + descriptor: META_DESC + }; - ClassMixin: _emberMetal.REQUIRED, + if (false) { + Meta.prototype.readInheritedValue = function (key, subkey) { + var internalKey = '_' + key; - PrototypeMixin: _emberMetal.REQUIRED, + var pointer = this; - isClass: true, + while (pointer !== undefined) { + var map = pointer[internalKey]; + if (map) { + var value = map[subkey]; + if (value !== undefined || subkey in map) { + return map[subkey]; + } + } + pointer = pointer.parent; + } - isMethod: false - }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { - var Class = makeCtor(); - var proto; - Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); - Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); + return UNDEFINED; + }; - Class.ClassMixin.ownerConstructor = Class; - Class.PrototypeMixin.ownerConstructor = Class; + Meta.prototype.writeValue = function (obj, key, value) { + var descriptor = _emberUtils.lookupDescriptor(obj, key); + var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter; - reopen.apply(Class.PrototypeMixin, arguments); + if (isMandatorySetter) { + this.writeValues(key, value); + } else { + obj[key] = value; + } + }; + } - Class.superclass = this; - Class.__super__ = this.prototype; + var setMeta = undefined, + peekMeta = undefined; - proto = Class.prototype = Object.create(this.prototype); - proto.constructor = Class; - _emberUtils.generateGuid(proto); - _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype + // choose the one appropriate for given platform + if (_emberUtils.HAS_NATIVE_WEAKMAP) { + (function () { + var getPrototypeOf = Object.getPrototypeOf; + var metaStore = new WeakMap(); - Class.ClassMixin.apply(Class); - return Class; - }, _ClassMixinProps.create = function () { - var C = this; + exports.setMeta = setMeta = function WeakMap_setMeta(obj, meta) { + metaStore.set(obj, meta); + }; - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + exports.peekMeta = peekMeta = function WeakMap_peekMeta(obj) { - if (args.length > 0) { - this._initProperties(args); - } - return new C(); - }, _ClassMixinProps.reopen = function () { - this.willReopen(); - reopen.apply(this.PrototypeMixin, arguments); - return this; - }, _ClassMixinProps.reopenClass = function () { - reopen.apply(this.ClassMixin, arguments); - applyMixin(this, arguments, false); - return this; - }, _ClassMixinProps.detect = function (obj) { - if ('function' !== typeof obj) { - return false; - } - while (obj) { - if (obj === this) { - return true; - } - obj = obj.superclass; - } - return false; - }, _ClassMixinProps.detectInstance = function (obj) { - return obj instanceof this; - }, _ClassMixinProps.metaForProperty = function (key) { - var proto = this.proto(); - var possibleDesc = proto[key]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + return metaStore.get(obj); + }; - return desc._meta || {}; - }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; - var proto = this.proto(); - var property; - var properties = []; + exports.peekMeta = peekMeta = function WeakMap_peekParentMeta(obj) { + var pointer = obj; + var meta = undefined; + while (pointer) { + meta = metaStore.get(pointer); + // jshint loopfunc:true - for (var name in proto) { - property = proto[name]; + // stop if we find a `null` value, since + // that means the meta was deleted + // any other truthy value is a "real" meta + if (meta === null || meta) { + return meta; + } - if (property && property.isDescriptor) { - properties.push({ - name: name, - meta: property._meta - }); + pointer = getPrototypeOf(pointer); + } + }; + })(); + } else { + exports.setMeta = setMeta = function Fallback_setMeta(obj, meta) { + // if `null` already, just set it to the new value + // otherwise define property first + if (obj[META_FIELD] !== null) { + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(EMBER_META_PROPERTY); + } else { + Object.defineProperty(obj, META_FIELD, META_DESC); + } } - } - return properties; - }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; - var empty = {}; - var properties = _emberMetal.get(this, '_computedProperties'); + obj[META_FIELD] = meta; + }; - for (var i = 0; i < properties.length; i++) { - property = properties[i]; - callback.call(binding || this, property.name, property.meta || empty); - } - }, _ClassMixinProps); + exports.peekMeta = peekMeta = function Fallback_peekMeta(obj) { + return obj[META_FIELD]; + }; + } - function injectedPropertyAssertion() {} + function deleteMeta(obj) { + + var meta = peekMeta(obj); + if (meta) { + meta.destroy(); + } + } /** - Returns a hash of property names and container names that injected - properties will lookup on the container lazily. + Retrieves the meta hash for an object. If `writable` is true ensures the + hash is writable for this object as well. - @method _lazyInjections - @return {Object} Hash of all lazy injected property keys to container names + The meta object contains information about computed property descriptors as + well as any watched properties and other information. You generally will + not access this information directly but instead work with higher level + methods that manipulate this hash indirectly. + + @method meta + @for Ember @private + + @param {Object} obj The object to retrieve meta for + @param {Boolean} [writable=true] Pass `false` if you do not intend to modify + the meta hash, allowing the method to avoid making an unnecessary copy. + @return {Object} the meta hash for an object */ - ClassMixinProps._lazyInjections = function () { - var injections = {}; - var proto = this.proto(); - var key, desc; - for (key in proto) { - desc = proto[key]; - if (desc instanceof _emberMetal.InjectedProperty) { - injections[key] = desc.type + ':' + (desc.name || key); + function meta(obj) { + + var maybeMeta = peekMeta(obj); + var parent = undefined; + + // remove this code, in-favor of explicit parent + if (maybeMeta) { + if (maybeMeta.source === obj) { + return maybeMeta; } + parent = maybeMeta; } - return injections; - }; + var newMeta = new Meta(obj, parent); + setMeta(obj, newMeta); + return newMeta; + } - var ClassMixin = _emberMetal.Mixin.create(ClassMixinProps); + exports.peekMeta = peekMeta; + exports.setMeta = setMeta; + exports.counters = counters; +}); +enifed('ember-metal/meta_listeners', ['exports'], function (exports) { + /* + When we render a rich template hierarchy, the set of events that + *might* happen tends to be much larger than the set of events that + actually happen. This implies that we should make listener creation & + destruction cheap, even at the cost of making event dispatch more + expensive. + + Thus we store a new listener with a single push and no new + allocations, without even bothering to do deduplication -- we can + save that for dispatch time, if an event actually happens. + */ - ClassMixin.ownerConstructor = CoreObject; + /* listener flags */ + 'use strict'; - CoreObject.ClassMixin = ClassMixin; + var ONCE = 1; + exports.ONCE = ONCE; + var SUSPENDED = 2; - ClassMixin.apply(CoreObject); + exports.SUSPENDED = SUSPENDED; + var protoMethods = { - CoreObject.reopen({ - didDefineProperty: function (proto, key, value) { - if (hasCachedComputedProperties === false) { + addToListeners: function (eventName, target, method, flags) { + if (!this._listeners) { + this._listeners = []; + } + this._listeners.push(eventName, target, method, flags); + }, + + _finalizeListeners: function () { + if (this._listenersFinalized) { return; } - if (value instanceof _emberMetal.ComputedProperty) { - var cache = _emberMetal.meta(this.constructor).readableCache(); + if (!this._listeners) { + this._listeners = []; + } + var pointer = this.parent; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + this._listeners = this._listeners.concat(listeners); + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + this._listenersFinalized = true; + }, - if (cache && cache._computedProperties !== undefined) { - cache._computedProperties = undefined; + removeFromListeners: function (eventName, target, method, didRemove) { + var pointer = this; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = listeners.length - 4; index >= 0; index -= 4) { + if (listeners[index] === eventName && (!method || listeners[index + 1] === target && listeners[index + 2] === method)) { + if (pointer === this) { + // we are modifying our own list, so we edit directly + if (typeof didRemove === 'function') { + didRemove(eventName, target, listeners[index + 2]); + } + listeners.splice(index, 4); + } else { + // we are trying to remove an inherited listener, so we do + // just-in-time copying to detach our own listeners from + // our inheritance chain. + this._finalizeListeners(); + return this.removeFromListeners(eventName, target, method); + } + } + } + } + if (pointer._listenersFinalized) { + break; } + pointer = pointer.parent; } - } - }); + }, - exports.default = CoreObject; -}); -// Private, and only for didInitAttrs willRecieveAttrs + matchingListeners: function (eventName) { + var pointer = this; + var result = []; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = 0; index < listeners.length - 3; index += 4) { + if (listeners[index] === eventName) { + pushUniqueListener(result, listeners, index); + } + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + var sus = this._suspendedListeners; + if (sus) { + for (var susIndex = 0; susIndex < sus.length - 2; susIndex += 3) { + if (eventName === sus[susIndex]) { + for (var resultIndex = 0; resultIndex < result.length - 2; resultIndex += 3) { + if (result[resultIndex] === sus[susIndex + 1] && result[resultIndex + 1] === sus[susIndex + 2]) { + result[resultIndex + 2] |= SUSPENDED; + } + } + } + } + } + return result; + }, -/** - Defines the properties that will be concatenated from the superclass - (instead of overridden). - By default, when you extend an Ember class a property defined in - the subclass overrides a property with the same name that is defined - in the superclass. However, there are some cases where it is preferable - to build up a property's value by combining the superclass' property - value with the subclass' value. An example of this in use within Ember - is the `classNames` property of `Ember.View`. - Here is some sample code showing the difference between a concatenated - property and a normal one: - ```javascript - const Bar = Ember.Object.extend({ - // Configure which properties to concatenate - concatenatedProperties: ['concatenatedProperty'], - someNonConcatenatedProperty: ['bar'], - concatenatedProperty: ['bar'] - }); - const FooBar = Bar.extend({ - someNonConcatenatedProperty: ['foo'], - concatenatedProperty: ['foo'] - }); - let fooBar = FooBar.create(); - fooBar.get('someNonConcatenatedProperty'); // ['foo'] - fooBar.get('concatenatedProperty'); // ['bar', 'foo'] - ``` - This behavior extends to object creation as well. Continuing the - above example: - ```javascript - let fooBar = FooBar.create({ - someNonConcatenatedProperty: ['baz'], - concatenatedProperty: ['baz'] - }) - fooBar.get('someNonConcatenatedProperty'); // ['baz'] - fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] - ``` - Adding a single property that is not an array will just add it in the array: - ```javascript - let fooBar = FooBar.create({ - concatenatedProperty: 'baz' - }) - view.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] - ``` - Using the `concatenatedProperties` property, we can tell Ember to mix the - content of the properties. - In `Ember.Component` the `classNames`, `classNameBindings` and - `attributeBindings` properties are concatenated. - This feature is available for you to use throughout the Ember object model, - although typical app developers are likely to use it infrequently. Since - it changes expectations about behavior of properties, you should properly - document its usage in each individual concatenated property (to not - mislead your users to think they can override the property in a subclass). - @property concatenatedProperties - @type Array - @default null - @public -*/ + suspendListeners: function (eventNames, target, method, callback) { + var sus = this._suspendedListeners; + if (!sus) { + sus = this._suspendedListeners = []; + } + for (var i = 0; i < eventNames.length; i++) { + sus.push(eventNames[i], target, method); + } + try { + return callback.call(target); + } finally { + if (sus.length === eventNames.length) { + this._suspendedListeners = undefined; + } else { + for (var i = sus.length - 3; i >= 0; i -= 3) { + if (sus[i + 1] === target && sus[i + 2] === method && eventNames.indexOf(sus[i]) !== -1) { + sus.splice(i, 3); + } + } + } + } + }, -/** - Defines the properties that will be merged from the superclass - (instead of overridden). - By default, when you extend an Ember class a property defined in - the subclass overrides a property with the same name that is defined - in the superclass. However, there are some cases where it is preferable - to build up a property's value by merging the superclass property value - with the subclass property's value. An example of this in use within Ember - is the `queryParams` property of routes. - Here is some sample code showing the difference between a merged - property and a normal one: - ```javascript - const Bar = Ember.Object.extend({ - // Configure which properties are to be merged - mergedProperties: ['mergedProperty'], - someNonMergedProperty: { - nonMerged: 'superclass value of nonMerged' + watchedEvents: function () { + var pointer = this; + var names = {}; + while (pointer) { + var listeners = pointer._listeners; + if (listeners) { + for (var index = 0; index < listeners.length - 3; index += 4) { + names[listeners[index]] = true; + } + } + if (pointer._listenersFinalized) { + break; + } + pointer = pointer.parent; + } + return Object.keys(names); }, - mergedProperty: { - page: {replace: false}, - limit: {replace: true} + + _initializeListeners: function () { + this._listeners = undefined; + this._listenersFinalized = undefined; + this._suspendedListeners = undefined; } - }); - const FooBar = Bar.extend({ - someNonMergedProperty: { - completelyNonMerged: 'subclass value of nonMerged' - }, - mergedProperty: { - limit: {replace: false} + }; + + exports.protoMethods = protoMethods; + function pushUniqueListener(destination, source, index) { + var target = source[index + 1]; + var method = source[index + 2]; + for (var destinationIndex = 0; destinationIndex < destination.length - 2; destinationIndex += 3) { + if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { + return; + } } - }); - let fooBar = FooBar.create(); - fooBar.get('someNonMergedProperty'); - // => { completelyNonMerged: 'subclass value of nonMerged' } - // - // Note the entire object, including the nonMerged property of - // the superclass object, has been replaced - fooBar.get('mergedProperty'); - // => { - // page: {replace: false}, - // limit: {replace: false} - // } - // - // Note the page remains from the superclass, and the - // `limit` property's value of `false` has been merged from - // the subclass. - ``` - This behavior is not available during object `create` calls. It is only - available at `extend` time. - In `Ember.Route` the `queryParams` property is merged. - This feature is available for you to use throughout the Ember object model, - although typical app developers are likely to use it infrequently. Since - it changes expectations about behavior of properties, you should properly - document its usage in each individual merged property (to not - mislead your users to think they can override the property in a subclass). - @property mergedProperties - @type Array - @default null - @public -*/ + destination.push(target, method, source[index + 3]); + } +}); +enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed + + /** + @module ember + @submodule ember-metal + */ + exports.detectBinding = detectBinding; + exports.mixin = mixin; + exports.hasUnprocessedMixins = hasUnprocessedMixins; + exports.clearUnprocessedMixins = clearUnprocessedMixins; + exports.required = required; + exports.aliasMethod = aliasMethod; + exports.observer = observer; + exports._immediateObserver = _immediateObserver; + exports._beforeObserver = _beforeObserver; -/** - Destroyed object property flag. - if this property is `true` the observers and bindings were already - removed by the effect of calling the `destroy()` method. - @property isDestroyed - @default false - @public -*/ + function ROOT() {} + ROOT.__hasSuper = false; -/** - Destruction scheduled flag. The `destroy()` method has been called. - The object stays intact until the end of the run loop at which point - the `isDestroyed` flag is set. - @property isDestroying - @default false - @public -*/ + var a_slice = Array.prototype.slice; + var a_concat = Array.prototype.concat; + var isArray = Array.isArray; -/** - Destroys an object by setting the `isDestroyed` flag and removing its - metadata, which effectively destroys observers and bindings. - If you try to set a property on a destroyed object, an exception will be - raised. - Note that destruction is scheduled for the end of the run loop and does not - happen immediately. It will set an isDestroying flag immediately. - @method destroy - @return {Ember.Object} receiver - @public -*/ + function isMethod(obj) { + return 'function' === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; + } -/** - Override to implement teardown. - @method willDestroy - @public -*/ + var CONTINUE = {}; -/** - Invoked by the run loop to actually destroy the object. This is - scheduled for execution by the `destroy` method. - @private - @method _scheduledDestroy -*/ + function mixinProperties(mixinsMeta, mixin) { + var guid = undefined; -/** - Returns a string representation which attempts to provide more information - than Javascript's `toString` typically does, in a generic way for all Ember - objects. - ```javascript - const Person = Ember.Object.extend() - person = Person.create() - person.toString() //=> "" - ``` - If the object's class is not defined on an Ember namespace, it will - indicate it is a subclass of the registered superclass: - ```javascript - const Student = Person.extend() - let student = Student.create() - student.toString() //=> "<(subclass of Person):ember1025>" - ``` - If the method `toStringExtension` is defined, its return value will be - included in the output. - ```javascript - const Teacher = Person.extend({ - toStringExtension() { - return this.get('fullName'); + if (mixin instanceof Mixin) { + guid = _emberUtils.guidFor(mixin); + if (mixinsMeta.peekMixins(guid)) { + return CONTINUE; + } + mixinsMeta.writeMixins(guid, mixin); + return mixin.properties; + } else { + return mixin; // apply anonymous mixin properties } - }); - teacher = Teacher.create() - teacher.toString(); //=> "" - ``` - @method toString - @return {String} string representation - @public -*/ + } -/** - Creates a new subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(thing); - } - }); - ``` - This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. - You can also create a subclass from any existing class by calling its `extend()` method. - For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: - ```javascript - const PersonComponent = Ember.Component.extend({ - tagName: 'li', - classNameBindings: ['isAdministrator'] - }); - ``` - When defining a subclass, you can override methods but still access the - implementation of your parent class by calling the special `_super()` method: - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - var name = this.get('name'); - alert(`${name} says: ${thing}`); - } - }); - const Soldier = Person.extend({ - say(thing) { - this._super(`${thing}, sir!`); - }, - march(numberOfHours) { - alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + function concatenatedMixinProperties(concatProp, props, values, base) { + // reset before adding each new mixin to pickup concats from previous + var concats = values[concatProp] || base[concatProp]; + if (props[concatProp]) { + concats = concats ? a_concat.call(concats, props[concatProp]) : props[concatProp]; } - }); - let yehuda = Soldier.create({ - name: "Yehuda Katz" - }); - yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" - ``` - The `create()` on line #17 creates an *instance* of the `Soldier` class. - The `extend()` on line #8 creates a *subclass* of `Person`. Any instance - of the `Person` class will *not* have the `march()` method. - You can also pass `Mixin` classes to add additional properties to the subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(`${this.get('name')} says: ${thing}`); + return concats; + } + + function giveDescriptorSuper(meta, key, property, values, descs, base) { + var superProperty = undefined; + + // Computed properties override methods, and do not call super to them + if (values[key] === undefined) { + // Find the original descriptor in a parent mixin + superProperty = descs[key]; } - }); - const SingingMixin = Mixin.create({ - sing(thing){ - alert(`${this.get('name')} sings: la la la ${thing}`); + + // If we didn't find the original descriptor in a parent mixin, find + // it on the original object. + if (!superProperty) { + var possibleDesc = base[key]; + var superDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + superProperty = superDesc; } - }); - const BroadwayStar = Person.extend(SingingMixin, { - dance() { - alert(`${this.get('name')} dances: tap tap tap tap `); + + if (superProperty === undefined || !(superProperty instanceof _emberMetalComputed.ComputedProperty)) { + return property; } - }); - ``` - The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. - @method extend - @static - @param {Mixin} [mixins]* One or more Mixin classes - @param {Object} [arguments]* Object containing values to use within the new class - @public -*/ -/** - Creates an instance of a class. Accepts either no arguments, or an object - containing values to initialize the newly instantiated object with. - ```javascript - const Person = Ember.Object.extend({ - helloWorld() { - alert(`Hi, my name is ${this.get('name')}`); + // Since multiple mixins may inherit from the same parent, we need + // to clone the computed property so that other mixins do not receive + // the wrapped version. + property = Object.create(property); + property._getter = _emberUtils.wrap(property._getter, superProperty._getter); + if (superProperty._setter) { + if (property._setter) { + property._setter = _emberUtils.wrap(property._setter, superProperty._setter); + } else { + property._setter = superProperty._setter; + } } - }); - let tom = Person.create({ - name: 'Tom Dale' - }); - tom.helloWorld(); // alerts "Hi, my name is Tom Dale". - ``` - `create` will call the `init` function if defined during - `Ember.AnyObject.extend` - If no arguments are passed to `create`, it will not set values to the new - instance during initialization: - ```javascript - let noName = Person.create(); - noName.helloWorld(); // alerts undefined - ``` - NOTE: For performance reasons, you cannot declare methods or computed - properties during `create`. You should instead declare methods and computed - properties when using `extend`. - @method create - @static - @param [arguments]* - @public -*/ -/** - Augments a constructor's prototype with additional - properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - o = MyObject.create(); - o.get('name'); // 'an object' - MyObject.reopen({ - say(msg){ - console.log(msg); + return property; + } + + function giveMethodSuper(obj, key, method, values, descs) { + var superMethod = undefined; + + // Methods overwrite computed properties, and do not call super to them. + if (descs[key] === undefined) { + // Find the original method in a parent mixin + superMethod = values[key]; } - }) - o2 = MyObject.create(); - o2.say("hello"); // logs "hello" - o.say("goodbye"); // logs "goodbye" - ``` - To add functions and properties to the constructor itself, - see `reopenClass` - @method reopen - @public -*/ -/** - Augments a constructor's own properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - MyObject.reopenClass({ - canBuild: false - }); - MyObject.canBuild; // false - o = MyObject.create(); - ``` - In other words, this creates static properties and functions for the class. - These are only available on the class and not on any instance of that class. - ```javascript - const Person = Ember.Object.extend({ - name: "", - sayHello() { - alert("Hello. My name is " + this.get('name')); + // If we didn't find the original value in a parent mixin, find it in + // the original object + superMethod = superMethod || obj[key]; + + // Only wrap the new method if the original method was a function + if (superMethod === undefined || 'function' !== typeof superMethod) { + return method; } - }); - Person.reopenClass({ - species: "Homo sapiens", - createPerson(newPersonsName){ - return Person.create({ - name:newPersonsName - }); + + return _emberUtils.wrap(method, superMethod); + } + + function applyConcatenatedProperties(obj, key, value, values) { + var baseValue = values[key] || obj[key]; + var ret = undefined; + + if (baseValue === null || baseValue === undefined) { + ret = _emberUtils.makeArray(value); + } else { + if (isArray(baseValue)) { + if (value === null || value === undefined) { + ret = baseValue; + } else { + ret = a_concat.call(baseValue, value); + } + } else { + ret = a_concat.call(_emberUtils.makeArray(baseValue), value); + } } - }); - let tom = Person.create({ - name: "Tom Dale" - }); - let yehuda = Person.createPerson("Yehuda Katz"); - tom.sayHello(); // "Hello. My name is Tom Dale" - yehuda.sayHello(); // "Hello. My name is Yehuda Katz" - alert(Person.species); // "Homo sapiens" - ``` - Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` - variables. They are only valid on `Person`. - To add functions and properties to instances of - a constructor by extending the constructor's prototype - see `reopen` - @method reopenClass - @public -*/ -/** - 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: - ```javascript - person: Ember.computed(function() { - var personId = this.get('personId'); - return Person.create({ id: personId }); - }).meta({ type: Person }) - ``` - Once you've done this, you can retrieve the values saved to the computed - property from your class like this: - ```javascript - MyClass.metaForProperty('person'); - ``` - This will return the original hash that was passed to `meta()`. - @static - @method metaForProperty - @param key {String} property name - @private -*/ + return ret; + } -/** - Iterate over each computed property for the class, passing its name - and any associated metadata (see `metaForProperty`) to the callback. - @static - @method eachComputedProperty - @param {Function} callback - @param {Object} binding - @private -*/ + function applyMergedProperties(obj, key, value, values) { + var baseValue = values[key] || obj[key]; -/** - Provides lookup-time type validation for injected properties. - @private - @method _onLookup -*/ -enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { - 'use strict'; + if (!baseValue) { + return value; + } - exports.default = EachProxy; + var newBase = _emberUtils.assign({}, baseValue); + var hasFunction = false; - /** - This is the object instance returned when you get the `@each` property on an - array. It uses the unknownProperty handler to automatically create - EachArray instances for property names. - @class EachProxy - @private - */ + for (var prop in value) { + if (!value.hasOwnProperty(prop)) { + continue; + } - function EachProxy(content) { - this._content = content; - this._keys = undefined; - this.__ember_meta__ = null; - } + var propValue = value[prop]; + if (isMethod(propValue)) { + // TODO: support for Computed Properties, etc? + hasFunction = true; + newBase[prop] = giveMethodSuper(obj, prop, propValue, baseValue, {}); + } else { + newBase[prop] = propValue; + } + } - EachProxy.prototype = { - __defineNonEnumerable: function (property) { - this[property.name] = property.descriptor.value; - }, + if (hasFunction) { + newBase._super = ROOT; + } - // .......................................................... - // ARRAY CHANGES - // Invokes whenever the content array itself changes. + return newBase; + } - arrayWillChange: function (content, idx, removedCnt, addedCnt) { - var keys = this._keys; - var lim = removedCnt > 0 ? idx + removedCnt : -1; - for (var key in keys) { - if (lim > 0) { - removeObserverForContentKey(content, key, this, idx, lim); - } - _emberMetal.propertyWillChange(this, key); + function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { + if (value instanceof _emberMetalProperties.Descriptor) { + if (value === REQUIRED && descs[key]) { + return CONTINUE; } - }, - arrayDidChange: function (content, idx, removedCnt, addedCnt) { - var keys = this._keys; - var lim = addedCnt > 0 ? idx + addedCnt : -1; - for (var key in keys) { - if (lim > 0) { - addObserverForContentKey(content, key, this, idx, lim); - } - _emberMetal.propertyDidChange(this, key); + // Wrap descriptor function to implement + // _super() if needed + if (value._getter) { + value = giveDescriptorSuper(meta, key, value, values, descs, base); } - }, - // .......................................................... - // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS - // Start monitoring keys based on who is listening... + descs[key] = value; + values[key] = undefined; + } else { + if (concats && concats.indexOf(key) >= 0 || key === 'concatenatedProperties' || key === 'mergedProperties') { + value = applyConcatenatedProperties(base, key, value, values); + } else if (mergings && mergings.indexOf(key) >= 0) { + value = applyMergedProperties(base, key, value, values); + } else if (isMethod(value)) { + value = giveMethodSuper(base, key, value, values, descs); + } - willWatchProperty: function (property) { - this.beginObservingContentKey(property); - }, + descs[key] = undefined; + values[key] = value; + } + } - didUnwatchProperty: function (property) { - this.stopObservingContentKey(property); - }, + function mergeMixins(mixins, m, descs, values, base, keys) { + var currentMixin = undefined, + props = undefined, + key = undefined, + concats = undefined, + mergings = undefined; - // .......................................................... - // CONTENT KEY OBSERVING - // Actual watch keys on the source content. + function removeKeys(keyName) { + delete descs[keyName]; + delete values[keyName]; + } - beginObservingContentKey: function (keyName) { - var keys = this._keys; - if (!keys) { - keys = this._keys = new _emberUtils.EmptyObject(); + for (var i = 0; i < mixins.length; i++) { + currentMixin = mixins[i]; + + props = mixinProperties(m, currentMixin); + if (props === CONTINUE) { + continue; } - if (!keys[keyName]) { - keys[keyName] = 1; - var content = this._content; - var len = _emberMetal.get(content, 'length'); + if (props) { + if (base.willMergeMixin) { + base.willMergeMixin(props); + } + concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); + mergings = concatenatedMixinProperties('mergedProperties', props, values, base); + + for (key in props) { + if (!props.hasOwnProperty(key)) { + continue; + } + keys.push(key); + addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings); + } + + // manually copy toString() because some JS engines do not enumerate it + if (props.hasOwnProperty('toString')) { + base.toString = props.toString; + } + } else if (currentMixin.mixins) { + mergeMixins(currentMixin.mixins, m, descs, values, base, keys); + if (currentMixin._without) { + currentMixin._without.forEach(removeKeys); + } + } + } + } + + function detectBinding(key) { + var length = key.length; - addObserverForContentKey(content, keyName, this, 0, len); - } else { - keys[keyName]++; - } - }, + return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; + } - stopObservingContentKey: function (keyName) { - var keys = this._keys; - if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) { - var content = this._content; - var len = _emberMetal.get(content, 'length'); + // warm both paths of above function + detectBinding('notbound'); + detectBinding('fooBinding'); - removeObserverForContentKey(content, keyName, this, 0, len); + function connectBindings(obj, m) { + // TODO Mixin.apply(instance) should disconnect binding if exists + m.forEachBindings(function (key, binding) { + if (binding) { + var to = key.slice(0, -7); // strip Binding off end + if (binding instanceof _emberMetalBinding.Binding) { + binding = binding.copy(); // copy prototypes' instance + binding.to(to); + } else { + // binding is string path + binding = new _emberMetalBinding.Binding(to, binding); + } + binding.connect(obj); + obj[key] = binding; } - }, + }); + // mark as applied + m.clearBindings(); + } - contentKeyWillChange: function (obj, keyName) { - _emberMetal.propertyWillChange(this, keyName); - }, + function finishPartial(obj, m) { + connectBindings(obj, m || _emberMetalMeta.meta(obj)); + return obj; + } - contentKeyDidChange: function (obj, keyName) { - _emberMetal.propertyDidChange(this, keyName); + function followAlias(obj, desc, m, descs, values) { + var altKey = desc.methodName; + var value = undefined; + var possibleDesc = undefined; + if (descs[altKey] || values[altKey]) { + value = values[altKey]; + desc = descs[altKey]; + } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { + desc = possibleDesc; + value = undefined; + } else { + desc = undefined; + value = obj[altKey]; } - }; - function addObserverForContentKey(content, keyName, proxy, idx, loc) { - while (--loc >= idx) { - var item = _emberRuntimeMixinsArray.objectAt(content, loc); - if (item) { - _emberMetal._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); - _emberMetal.addObserver(item, keyName, proxy, 'contentKeyDidChange'); + return { desc: desc, value: value }; + } + + function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { + var paths = observerOrListener[pathsKey]; + + if (paths) { + for (var i = 0; i < paths.length; i++) { + updateMethod(obj, paths[i], null, key); } } } - function removeObserverForContentKey(content, keyName, proxy, idx, loc) { - while (--loc >= idx) { - var item = _emberRuntimeMixinsArray.objectAt(content, loc); - if (item) { - _emberMetal._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); - _emberMetal.removeObserver(item, keyName, proxy, 'contentKeyDidChange'); - } + function replaceObserversAndListeners(obj, key, observerOrListener) { + var prev = obj[key]; + + if ('function' === typeof prev) { + updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _emberMetalObserver._removeBeforeObserver); + updateObserversAndListeners(obj, key, prev, '__ember_observes__', _emberMetalObserver.removeObserver); + updateObserversAndListeners(obj, key, prev, '__ember_listens__', _emberMetalEvents.removeListener); + } + + if ('function' === typeof observerOrListener) { + updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', _emberMetalObserver._addBeforeObserver); + updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', _emberMetalObserver.addObserver); + updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', _emberMetalEvents.addListener); } } -}); -enifed('ember-runtime/system/lazy_load', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - /*globals CustomEvent */ - 'use strict'; + function applyMixin(obj, mixins, partial) { + var descs = {}; + var values = {}; + var m = _emberMetalMeta.meta(obj); + var keys = []; + var key = undefined, + value = undefined, + desc = undefined; - exports.onLoad = onLoad; - exports.runLoadHooks = runLoadHooks; + obj._super = ROOT; - /** - @module ember - @submodule ember-runtime - */ + // Go through all mixins and hashes passed in, and: + // + // * Handle concatenated properties + // * Handle merged properties + // * Set up _super wrapping if necessary + // * Set up computed property descriptors + // * Copying `toString` in broken browsers + mergeMixins(mixins, m, descs, values, obj, keys); - var loadHooks = _emberEnvironment.ENV.EMBER_LOAD_HOOKS || {}; - var loaded = {}; - var _loaded = loaded; + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + if (key === 'constructor' || !values.hasOwnProperty(key)) { + continue; + } - exports._loaded = _loaded; - /** - Detects when a specific package of Ember (e.g. 'Ember.Application') - has fully loaded and is available for extension. - - The provided `callback` will be called with the `name` passed - resolved from a string into the object: - - ``` javascript - Ember.onLoad('Ember.Application' function(hbars) { - hbars.registerHelper(...); - }); - ``` - - @method onLoad - @for Ember - @param name {String} name of hook - @param callback {Function} callback to be called - @private - */ + desc = descs[key]; + value = values[key]; - function onLoad(name, callback) { - var object = loaded[name]; + if (desc === REQUIRED) { + continue; + } - loadHooks[name] = loadHooks[name] || []; - loadHooks[name].push(callback); + while (desc && desc instanceof Alias) { + var followed = followAlias(obj, desc, m, descs, values); + desc = followed.desc; + value = followed.value; + } - if (object) { - callback(object); - } - } + if (desc === undefined && value === undefined) { + continue; + } - /** - Called when an Ember.js package (e.g Ember.Application) has finished - loading. Triggers any callbacks registered for this event. - - @method runLoadHooks - @for Ember - @param name {String} name of hook - @param object {Object} object to pass to callbacks - @private - */ + replaceObserversAndListeners(obj, key, value); - function runLoadHooks(name, object) { - loaded[name] = object; - var window = _emberEnvironment.environment.window; + if (detectBinding(key)) { + m.writeBindings(key, value); + } - if (window && typeof CustomEvent === 'function') { - var _event = new CustomEvent(name, { detail: object, name: name }); - window.dispatchEvent(_event); + _emberMetalProperties.defineProperty(obj, key, desc, value, m); } - if (loadHooks[name]) { - loadHooks[name].forEach(function (callback) { - return callback(object); - }); + if (!partial) { + // don't apply to prototype + finishPartial(obj, m); } + + return obj; } -}); -enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-runtime/system/object'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberRuntimeSystemObject) { + /** - @module ember - @submodule ember-runtime + @method mixin + @for Ember + @param obj + @param mixins* + @return obj + @private */ - 'use strict'; - - exports.isSearchDisabled = isSearchDisabled; - exports.setSearchDisabled = setSearchDisabled; - - var searchDisabled = false; - function isSearchDisabled() { - return searchDisabled; - } + function mixin(obj) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - function setSearchDisabled(flag) { - searchDisabled = !!flag; + applyMixin(obj, args, false); + return obj; } /** - A Namespace is an object usually used to contain other objects or methods - such as an application or framework. Create a namespace anytime you want - to define one of these new containers. + The `Ember.Mixin` class allows you to create mixins, whose properties can be + added to other classes. For instance, - # Example Usage + ```javascript + const EditableMixin = Ember.Mixin.create({ + edit() { + console.log('starting to edit'); + this.set('isEditing', true); + }, + isEditing: false + }); + + // Mix mixins into classes by passing them as the first arguments to + // `.extend.` + const Comment = Ember.Object.extend(EditableMixin, { + post: null + }); + + let comment = Comment.create(post: somePost); + comment.edit(); // outputs 'starting to edit' + ``` + + Note that Mixins are created with `Ember.Mixin.create`, not + `Ember.Mixin.extend`. + + Note that mixins extend a constructor's prototype so arrays and object literals + defined as properties will be shared amongst objects that implement the mixin. + If you want to define a property in a mixin that is not shared, you can define + it either as a computed property or have it be created on initialization of the object. ```javascript - MyFramework = Ember.Namespace.create({ - VERSION: '1.0.0' + // filters array will be shared amongst any object implementing mixin + const FilterableMixin = Ember.Mixin.create({ + filters: Ember.A() + }); + + // filters will be a separate array for every object implementing the mixin + const FilterableMixin = Ember.Mixin.create({ + filters: Ember.computed(function() { + return Ember.A(); + }) + }); + + // filters will be created as a separate array during the object's initialization + const Filterable = Ember.Mixin.create({ + init() { + this._super(...arguments); + this.set("filters", Ember.A()); + } }); ``` - @class Namespace + @class Mixin @namespace Ember - @extends Ember.Object @public */ - var Namespace = _emberRuntimeSystemObject.default.extend({ - isNamespace: true, - - init: function () { - Namespace.NAMESPACES.push(this); - Namespace.PROCESSED = false; - }, - toString: function () { - var name = _emberMetal.get(this, 'name') || _emberMetal.get(this, 'modulePrefix'); - if (name) { - return name; - } + var Mixin = (function () { + function Mixin(args, properties) { + this.properties = properties; - findNamespaces(); - return this[_emberUtils.NAME_KEY]; - }, + var length = args && args.length; - nameClasses: function () { - processNamespace([this.toString()], this, {}); - }, + if (length > 0) { + var m = new Array(length); - destroy: function () { - var namespaces = Namespace.NAMESPACES; - var toString = this.toString(); + for (var i = 0; i < length; i++) { + var x = args[i]; + if (x instanceof Mixin) { + m[i] = x; + } else { + m[i] = new Mixin(undefined, x); + } + } - if (toString) { - _emberEnvironment.context.lookup[toString] = undefined; - delete Namespace.NAMESPACES_BY_ID[toString]; + this.mixins = m; + } else { + this.mixins = undefined; } - namespaces.splice(namespaces.indexOf(this), 1); - this._super.apply(this, arguments); + this.ownerConstructor = undefined; + this._without = undefined; + this[_emberUtils.GUID_KEY] = null; + this[_emberUtils.NAME_KEY] = null; } - }); - Namespace.reopenClass({ - NAMESPACES: [_emberMetal.default], - NAMESPACES_BY_ID: { - Ember: _emberMetal.default - }, - PROCESSED: false, - processAll: processAllNamespaces, - byName: function (name) { - if (!searchDisabled) { - processAllNamespaces(); - } + Mixin.applyPartial = function applyPartial(obj) { + var args = a_slice.call(arguments, 1); + return applyMixin(obj, args, true); + }; - return NAMESPACES_BY_ID[name]; - } - }); + /** + @method create + @static + @param arguments* + @public + */ - var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; + Mixin.create = function create() { + // ES6TODO: this relies on a global state? + unprocessedFlag = true; + var M = this; - var hasOwnProp = ({}).hasOwnProperty; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - function processNamespace(paths, root, seen) { - var idx = paths.length; + return new M(args, undefined); + }; - NAMESPACES_BY_ID[paths.join('.')] = root; + // returns the mixins currently applied to the specified object + // TODO: Make Ember.mixin - // Loop over all of the keys in the namespace, looking for classes - for (var key in root) { - if (!hasOwnProp.call(root, key)) { - continue; + Mixin.mixins = function mixins(obj) { + var m = _emberMetalMeta.peekMeta(obj); + var ret = []; + if (!m) { + return ret; } - var obj = root[key]; - // If we are processing the `Ember` namespace, for example, the - // `paths` will start with `["Ember"]`. Every iteration through - // the loop will update the **second** element of this list with - // the key, so processing `Ember.View` will make the Array - // `['Ember', 'View']`. - paths[idx] = key; + m.forEachMixins(function (key, currentMixin) { + // skip primitive mixins since these are always anonymous + if (!currentMixin.properties) { + ret.push(currentMixin); + } + }); - // If we have found an unprocessed class - if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { - // Replace the class' `toString` with the dot-separated path - // and set its `NAME_KEY` - obj[_emberUtils.NAME_KEY] = paths.join('.'); + return ret; + }; - // Support nested namespaces - } else if (obj && obj.isNamespace) { - // Skip aliased namespaces - if (seen[_emberUtils.guidFor(obj)]) { - continue; - } - seen[_emberUtils.guidFor(obj)] = true; + return Mixin; + })(); - // Process the child namespace - processNamespace(paths, obj, seen); - } - } + exports.default = Mixin; - paths.length = idx; // cut out last item - } + Mixin._apply = applyMixin; - function isUppercase(code) { - return code >= 65 && // A - code <= 90; // Z + Mixin.finishPartial = finishPartial; + + var unprocessedFlag = false; + + function hasUnprocessedMixins() { + return unprocessedFlag; } - function tryIsNamespace(lookup, prop) { - try { - var obj = lookup[prop]; - return obj && obj.isNamespace && obj; - } catch (e) { - // continue - } + function clearUnprocessedMixins() { + unprocessedFlag = false; } - function findNamespaces() { - if (Namespace.PROCESSED) { - return; + var MixinPrototype = Mixin.prototype; + + /** + @method reopen + @param arguments* + @private + */ + MixinPrototype.reopen = function () { + var currentMixin = undefined; + + if (this.properties) { + currentMixin = new Mixin(undefined, this.properties); + this.properties = undefined; + this.mixins = [currentMixin]; + } else if (!this.mixins) { + this.mixins = []; } - var lookup = _emberEnvironment.context.lookup; - var keys = Object.keys(lookup); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - // Only process entities that start with uppercase A-Z - if (!isUppercase(key.charCodeAt(0))) { - continue; - } - var obj = tryIsNamespace(lookup, key); - if (obj) { - obj[_emberUtils.NAME_KEY] = key; + + var mixins = this.mixins; + var idx = undefined; + + for (idx = 0; idx < arguments.length; idx++) { + currentMixin = arguments[idx]; + + if (currentMixin instanceof Mixin) { + mixins.push(currentMixin); + } else { + mixins.push(new Mixin(undefined, currentMixin)); } } - } - function superClassString(mixin) { - var superclass = mixin.superclass; - if (superclass) { - if (superclass[_emberUtils.NAME_KEY]) { - return superclass[_emberUtils.NAME_KEY]; + return this; + }; + + /** + @method apply + @param obj + @return applied object + @private + */ + MixinPrototype.apply = function (obj) { + return applyMixin(obj, [this], false); + }; + + MixinPrototype.applyPartial = function (obj) { + return applyMixin(obj, [this], true); + }; + + MixinPrototype.toString = Object.toString; + + function _detect(curMixin, targetMixin, seen) { + var guid = _emberUtils.guidFor(curMixin); + + if (seen[guid]) { + return false; + } + seen[guid] = true; + + if (curMixin === targetMixin) { + return true; + } + var mixins = curMixin.mixins; + var loc = mixins ? mixins.length : 0; + while (--loc >= 0) { + if (_detect(mixins[loc], targetMixin, seen)) { + return true; } - return superClassString(superclass); } + return false; } - function calculateToString(target) { - var str = undefined; - - if (!searchDisabled) { - processAllNamespaces(); - // can also be set by processAllNamespaces - str = target[_emberUtils.NAME_KEY]; - if (str) { - return str; - } else { - str = superClassString(target); - str = str ? '(subclass of ' + str + ')' : str; - } + /** + @method detect + @param obj + @return {Boolean} + @private + */ + MixinPrototype.detect = function (obj) { + if (typeof obj !== 'object' || obj === null) { + return false; } - if (str) { - return str; - } else { - return '(unknown mixin)'; + if (obj instanceof Mixin) { + return _detect(obj, this, {}); + } + var m = _emberMetalMeta.peekMeta(obj); + if (!m) { + return false; } - } + return !!m.peekMixins(_emberUtils.guidFor(this)); + }; - function classToString() { - var name = this[_emberUtils.NAME_KEY]; - if (name) { - return name; - } + MixinPrototype.without = function () { + var ret = new Mixin([this]); - return this[_emberUtils.NAME_KEY] = calculateToString(this); - } + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } - function processAllNamespaces() { - var unprocessedNamespaces = !Namespace.PROCESSED; - var unprocessedMixins = _emberMetal.hasUnprocessedMixins(); + ret._without = args; + return ret; + }; - if (unprocessedNamespaces) { - findNamespaces(); - Namespace.PROCESSED = true; + function _keys(ret, mixin, seen) { + if (seen[_emberUtils.guidFor(mixin)]) { + return; } + seen[_emberUtils.guidFor(mixin)] = true; - if (unprocessedNamespaces || unprocessedMixins) { - var namespaces = Namespace.NAMESPACES; - var namespace = undefined; - - for (var i = 0; i < namespaces.length; i++) { - namespace = namespaces[i]; - processNamespace([namespace.toString()], namespace, {}); + if (mixin.properties) { + var props = Object.keys(mixin.properties); + for (var i = 0; i < props.length; i++) { + var key = props[i]; + ret[key] = true; } - - _emberMetal.clearUnprocessedMixins(); + } else if (mixin.mixins) { + mixin.mixins.forEach(function (x) { + return _keys(ret, x, seen); + }); } } - _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. + MixinPrototype.keys = function () { + var keys = {}; + var seen = {}; + + _keys(keys, this, seen); + var ret = Object.keys(keys); + return ret; + }; + + var REQUIRED = new _emberMetalProperties.Descriptor(); + REQUIRED.toString = function () { + return '(Required Property)'; + }; - exports.default = Namespace; -}); -// Preloaded into namespaces -enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) { /** - @module ember - @submodule ember-runtime + Denotes a required property for a mixin + + @method required + @for Ember + @private */ - 'use strict'; - // Add Ember.Array to Array.prototype. Remove methods with native - // implementations and supply some more optimized versions of generic methods - // because they are so common. + function required() { + return REQUIRED; + } + + function Alias(methodName) { + this.isDescriptor = true; + this.methodName = methodName; + } + + Alias.prototype = new _emberMetalProperties.Descriptor(); /** - The NativeArray mixin contains the properties needed to make the native - Array support Ember.MutableArray and all of its dependent APIs. Unless you - have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to - false, this will be applied automatically. Otherwise you can apply the mixin - at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. + Makes a method available via an additional name. - @class NativeArray - @namespace Ember - @uses Ember.MutableArray - @uses Ember.Observable - @uses Ember.Copyable + ```javascript + App.Person = Ember.Object.extend({ + name: function() { + return 'Tomhuda Katzdale'; + }, + moniker: Ember.aliasMethod('name') + }); + + let goodGuy = App.Person.create(); + + goodGuy.name(); // 'Tomhuda Katzdale' + goodGuy.moniker(); // 'Tomhuda Katzdale' + ``` + + @method aliasMethod + @for Ember + @param {String} methodName name of the method to alias @public */ - var NativeArray = _emberMetal.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, { - // because length is a built-in property we need to know to just get the - // original property. - get: function (key) { - if ('number' === typeof key) { - return this[key]; - } else { - return this._super(key); - } - }, + function aliasMethod(methodName) { + return new Alias(methodName); + } - objectAt: function (idx) { - return this[idx]; - }, + // .......................................................... + // OBSERVER HELPER + // - // primitive for array support. - replace: function (idx, amt, objects) { - if (this.isFrozen) { - throw _emberRuntimeMixinsFreezable.FROZEN_ERROR; - } + /** + Specify a method that observes property changes. + + ```javascript + Ember.Object.extend({ + valueObserver: Ember.observer('value', function() { + // Executes whenever the "value" property changes + }) + }); + ``` + + Also available as `Function.prototype.observes` if prototype extensions are + enabled. + + @method observer + @for Ember + @param {String} propertyNames* + @param {Function} func + @return func + @public + */ - // if we replaced exactly the same number of items, then pass only the - // replaced range. Otherwise, pass the full remaining array length - // since everything has shifted - var len = objects ? _emberMetal.get(objects, 'length') : 0; - _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, amt, len); + function observer() { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } - if (len === 0) { - this.splice(idx, amt); - } else { - _emberMetal.replace(this, idx, amt, objects); - } + var func = args.slice(-1)[0]; + var paths = undefined; - _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, amt, len); - return this; - }, + var addWatchedProperty = function (path) { + paths.push(path); + }; + var _paths = args.slice(0, -1); - // If you ask for an unknown property, then try to collect the value - // from member items. - unknownProperty: function (key, value) { - var ret = undefined; // = this.reducedProperty(key, value); - if (value !== undefined && ret === undefined) { - ret = this[key] = value; - } - return ret; - }, + if (typeof func !== 'function') { - indexOf: Array.prototype.indexOf, - lastIndexOf: Array.prototype.lastIndexOf, + func = args[0]; - copy: function (deep) { - if (deep) { - return this.map(function (item) { - return _emberRuntimeCopy.default(item, true); - }); - } + // revert to old, soft-deprecated argument ordering + _paths = args.slice(1); + } - return this.slice(); + paths = []; + + for (var i = 0; i < _paths.length; ++i) { + _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); } - }); - // Remove any methods implemented natively so we don't override them - var ignore = ['length']; - NativeArray.keys().forEach(function (methodName) { - if (Array.prototype[methodName]) { - ignore.push(methodName); + if (typeof func !== 'function') { + throw new _emberMetalError.default('Ember.observer called without a function'); } - }); - exports.NativeArray // TODO: only use default export - = NativeArray = NativeArray.without.apply(NativeArray, ignore); + func.__ember_observes__ = paths; + return func; + } /** - Creates an `Ember.NativeArray` from an Array like object. - Does not modify the original object. Ember.A is not needed if - `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However, - it is recommended that you use Ember.A when creating addons for - ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES` - will be `true`. + Specify a method that observes property changes. - Example + ```javascript + Ember.Object.extend({ + valueObserver: Ember.immediateObserver('value', function() { + // Executes whenever the "value" property changes + }) + }); + ``` - ```js - export default Ember.Component.extend({ - tagName: 'ul', - classNames: ['pagination'], + In the future, `Ember.observer` may become asynchronous. In this event, + `Ember.immediateObserver` will maintain the synchronous behavior. - init() { - this._super(...arguments); + Also available as `Function.prototype.observesImmediately` if prototype extensions are + enabled. - if (!this.get('content')) { - this.set('content', Ember.A()); - } - } - }); - ``` + @method _immediateObserver + @for Ember + @param {String} propertyNames* + @param {Function} func + @deprecated Use `Ember.observer` instead. + @return func + @private + */ + + function _immediateObserver() { + + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + } + + return observer.apply(this, arguments); + } + + /** + When observers fire, they are called with the arguments `obj`, `keyName`. - @method A + Note, `@each.property` observer is called per each add or replace of an element + and it's not called with a specific enumeration item. + + A `_beforeObserver` fires before a property changes. + + @method beforeObserver @for Ember - @return {Ember.NativeArray} - @public + @param {String} propertyNames* + @param {Function} func + @return func + @deprecated + @private */ - var A = undefined; - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Array) { - NativeArray.apply(Array.prototype); - exports.A = A = function (arr) { - return arr || []; - }; - } else { - exports.A = A = function (arr) { - if (!arr) { - arr = []; - } - return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr); + function _beforeObserver() { + for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; + } + + var func = args.slice(-1)[0]; + var paths = undefined; + + var addWatchedProperty = function (path) { + paths.push(path); }; + + var _paths = args.slice(0, -1); + + if (typeof func !== 'function') { + // revert to old, soft-deprecated argument ordering + + func = args[0]; + _paths = args.slice(1); + } + + paths = []; + + for (var i = 0; i < _paths.length; ++i) { + _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); + } + + if (typeof func !== 'function') { + throw new _emberMetalError.default('_beforeObserver called without a function'); + } + + func.__ember_observesBefore__ = paths; + return func; } - _emberMetal.default.A = A; - exports.A = A; - exports.NativeArray = NativeArray; - exports.default = NativeArray; + exports.Mixin = Mixin; + exports.REQUIRED = REQUIRED; }); -// Ember.A circular -enifed('ember-runtime/system/object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberUtils, _emberMetal, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) { - /** - @module ember - @submodule ember-runtime - */ +// it is possible to use concatenatedProperties with strings (which cannot be frozen) +// only freeze objects... + +// prevent mutating `concatenatedProperties` array after it is applied +// use conditional to avoid stringifying every time +enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { 'use strict'; + exports.addObserver = addObserver; + exports.observersFor = observersFor; + exports.removeObserver = removeObserver; + exports._addBeforeObserver = _addBeforeObserver; + exports._suspendObserver = _suspendObserver; + exports._suspendObservers = _suspendObservers; + exports._removeBeforeObserver = _removeBeforeObserver; + /** - `Ember.Object` is the main base class for all Ember objects. It is a subclass - of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, - see the documentation for each of these. - - @class Object - @namespace Ember - @extends Ember.CoreObject - @uses Ember.Observable - @public + @module ember-metal */ - var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default); - EmberObject.toString = function () { - return 'Ember.Object'; - }; - var FrameworkObject = EmberObject; + var AFTER_OBSERVERS = ':change'; + var BEFORE_OBSERVERS = ':before'; - exports.FrameworkObject = FrameworkObject; - exports.default = EmberObject; -}); -enifed('ember-runtime/system/object_proxy', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/-proxy'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsProxy) { - 'use strict'; + function changeEvent(keyName) { + return keyName + AFTER_OBSERVERS; + } + + function beforeEvent(keyName) { + return keyName + BEFORE_OBSERVERS; + } /** - `Ember.ObjectProxy` forwards all properties not defined by the proxy itself - to a proxied `content` object. - - ```javascript - object = Ember.Object.create({ - name: 'Foo' - }); - - proxy = Ember.ObjectProxy.create({ - content: object - }); - - // Access and change existing properties - proxy.get('name') // 'Foo' - proxy.set('name', 'Bar'); - object.get('name') // 'Bar' - - // Create new 'description' property on `object` - proxy.set('description', 'Foo is a whizboo baz'); - object.get('description') // 'Foo is a whizboo baz' - ``` - - While `content` is unset, setting a property to be delegated will throw an - Error. - - ```javascript - proxy = Ember.ObjectProxy.create({ - content: null, - flag: null - }); - proxy.set('flag', true); - proxy.get('flag'); // true - proxy.get('foo'); // undefined - proxy.set('foo', 'data'); // throws Error - ``` - - Delegated properties can be bound to and will change when content is updated. - - Computed properties on the proxy itself can depend on delegated properties. - - ```javascript - ProxyWithComputedProperty = Ember.ObjectProxy.extend({ - fullName: Ember.computed('firstName', 'lastName', function() { - var firstName = this.get('firstName'), - lastName = this.get('lastName'); - if (firstName && lastName) { - return firstName + ' ' + lastName; - } - return firstName || lastName; - }) - }); - - proxy = ProxyWithComputedProperty.create(); - - proxy.get('fullName'); // undefined - proxy.set('content', { - firstName: 'Tom', lastName: 'Dale' - }); // triggers property change for fullName on proxy - - proxy.get('fullName'); // 'Tom Dale' - ``` - - @class ObjectProxy - @namespace Ember - @extends Ember.Object - @extends Ember._ProxyMixin + @method addObserver + @for Ember + @param obj + @param {String} _path + @param {Object|Function} target + @param {Function|String} [method] @public */ - exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsProxy.default); -}); -enifed('ember-runtime/system/service', ['exports', 'ember-runtime/system/object', 'ember-runtime/inject'], function (exports, _emberRuntimeSystemObject, _emberRuntimeInject) { - 'use strict'; + function addObserver(obj, _path, target, method) { + _emberMetalEvents.addListener(obj, changeEvent(_path), target, method); + _emberMetalWatching.watch(obj, _path); + + return this; + } + + function observersFor(obj, path) { + return _emberMetalEvents.listenersFor(obj, changeEvent(path)); + } /** - Creates a property that lazily looks up a service in the container. There - are no restrictions as to what objects a service can be injected into. - - Example: - - ```javascript - App.ApplicationRoute = Ember.Route.extend({ - authManager: Ember.inject.service('auth'), - - model: function() { - return this.get('authManager').findCurrentUser(); - } - }); - ``` - - This example will create an `authManager` property on the application route - that looks up the `auth` service in the container, making it easily - accessible in the `model` hook. - - @method service - @since 1.10.0 - @for Ember.inject - @param {String} name (optional) name of the service to inject, defaults to - the property's name - @return {Ember.InjectedProperty} injection descriptor instance + @method removeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] @public */ - _emberRuntimeInject.createInjectionHelper('service'); + + function removeObserver(obj, path, target, method) { + _emberMetalWatching.unwatch(obj, path); + _emberMetalEvents.removeListener(obj, changeEvent(path), target, method); + + return this; + } /** - @class Service - @namespace Ember - @extends Ember.Object - @since 1.10.0 - @public + @method _addBeforeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @deprecated + @private */ - var Service = _emberRuntimeSystemObject.default.extend(); - Service.reopenClass({ - isServiceFactory: true - }); + function _addBeforeObserver(obj, path, target, method) { + _emberMetalEvents.addListener(obj, beforeEvent(path), target, method); + _emberMetalWatching.watch(obj, path); + + return this; + } + + // Suspend observer during callback. + // + // This should only be used by the target of the observer + // while it is setting the observed path. + + function _suspendObserver(obj, path, target, method, callback) { + return _emberMetalEvents.suspendListener(obj, changeEvent(path), target, method, callback); + } + + function _suspendObservers(obj, paths, target, method, callback) { + var events = paths.map(changeEvent); + return _emberMetalEvents.suspendListeners(obj, events, target, method, callback); + } - exports.default = Service; -}); -enifed('ember-runtime/system/string', ['exports', 'ember-metal', 'ember-utils', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberUtils, _emberRuntimeUtils, _emberRuntimeString_registry) { /** - @module ember - @submodule ember-runtime + @method removeBeforeObserver + @for Ember + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @deprecated + @private */ - 'use strict'; - var STRING_DASHERIZE_REGEXP = /[ _]/g; + function _removeBeforeObserver(obj, path, target, method) { + _emberMetalWatching.unwatch(obj, path); + _emberMetalEvents.removeListener(obj, beforeEvent(path), target, method); - var STRING_DASHERIZE_CACHE = new _emberMetal.Cache(1000, function (key) { - return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-'); - }); + return this; + } +}); +enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) { + 'use strict'; - var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; - var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; + /* + this.observerSet = { + [senderGuid]: { // variable name: `keySet` + [keyName]: listIndex + } + }, + this.observers = [ + { + sender: obj, + keyName: keyName, + eventName: eventName, + listeners: [ + [target, method, flags] + ] + }, + ... + ] + */ - var CAMELIZE_CACHE = new _emberMetal.Cache(1000, function (key) { - return key.replace(STRING_CAMELIZE_REGEXP_1, function (match, separator, chr) { - return chr ? chr.toUpperCase() : ''; - }).replace(STRING_CAMELIZE_REGEXP_2, function (match, separator, chr) { - return match.toLowerCase(); - }); - }); + var ObserverSet = (function () { + function ObserverSet() { + this.clear(); + } - var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; - var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; - var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; + ObserverSet.prototype.add = function add(sender, keyName, eventName) { + var observerSet = this.observerSet; + var observers = this.observers; + var senderGuid = _emberUtils.guidFor(sender); + var keySet = observerSet[senderGuid]; + var index = undefined; - var CLASSIFY_CACHE = new _emberMetal.Cache(1000, function (str) { - var replace1 = function (match, separator, chr) { - return chr ? '_' + chr.toUpperCase() : ''; + 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; }; - var replace2 = function (match, initialChar, separator, chr) { - return initialChar + (chr ? chr.toUpperCase() : ''); + + ObserverSet.prototype.flush = function flush() { + var observers = this.observers; + var i = undefined, + observer = undefined, + sender = undefined; + this.clear(); + for (i = 0; i < observers.length; ++i) { + observer = observers[i]; + sender = observer.sender; + if (sender.isDestroying || sender.isDestroyed) { + continue; + } + _emberMetalEvents.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners); + } }; - var parts = str.split('/'); - for (var i = 0; i < parts.length; i++) { - parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); - } - return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, function (match, separator, chr) { - return match.toUpperCase(); - }); - }); - var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; - var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; + ObserverSet.prototype.clear = function clear() { + this.observerSet = {}; + this.observers = []; + }; - var UNDERSCORE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase(); - }); + return ObserverSet; + })(); - var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z])/g; + exports.default = ObserverSet; +}); +enifed('ember-metal/path_cache', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) { + 'use strict'; - var CAPITALIZE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_CAPITALIZE_REGEXP, function (match, separator, chr) { - return match.toUpperCase(); - }); - }); + exports.isGlobal = isGlobal; + exports.isGlobalPath = isGlobalPath; + exports.hasThis = hasThis; + exports.isPath = isPath; + exports.getFirstKey = getFirstKey; + exports.getTailPath = getTailPath; - var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; + var IS_GLOBAL = /^[A-Z$]/; + var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; + var HAS_THIS = 'this.'; - var DECAMELIZE_CACHE = new _emberMetal.Cache(1000, function (str) { - return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase(); + var isGlobalCache = new _emberMetalCache.default(1000, function (key) { + return IS_GLOBAL.test(key); + }); + var isGlobalPathCache = new _emberMetalCache.default(1000, function (key) { + return IS_GLOBAL_PATH.test(key); + }); + var hasThisCache = new _emberMetalCache.default(1000, function (key) { + return key.lastIndexOf(HAS_THIS, 0) === 0; + }); + var firstDotIndexCache = new _emberMetalCache.default(1000, function (key) { + return key.indexOf('.'); }); - function _fmt(str, formats) { - var cachedFormats = formats; - - if (!_emberRuntimeUtils.isArray(cachedFormats) || arguments.length > 2) { - cachedFormats = new Array(arguments.length - 1); - - for (var i = 1; i < arguments.length; i++) { - cachedFormats[i - 1] = arguments[i]; - } + var firstKeyCache = new _emberMetalCache.default(1000, function (path) { + var index = firstDotIndexCache.get(path); + if (index === -1) { + return path; + } else { + return path.slice(0, index); } + }); - // first, replace any ORDERED replacements. - var idx = 0; // the current index for non-numerical replacements - return str.replace(/%@([0-9]+)?/g, function (s, argIndex) { - argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++; - s = cachedFormats[argIndex]; - return s === null ? '(null)' : s === undefined ? '' : _emberUtils.inspect(s); - }); - } - - function fmt(str, formats) { - return _fmt.apply(undefined, arguments); - } - - function loc(str, formats) { - if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) { - formats = Array.prototype.slice.call(arguments, 1); + var tailPathCache = new _emberMetalCache.default(1000, function (path) { + var index = firstDotIndexCache.get(path); + if (index !== -1) { + return path.slice(index + 1); } + }); - str = _emberRuntimeString_registry.get(str) || str; - return _fmt(str, formats); - } + var caches = { + isGlobalCache: isGlobalCache, + isGlobalPathCache: isGlobalPathCache, + hasThisCache: hasThisCache, + firstDotIndexCache: firstDotIndexCache, + firstKeyCache: firstKeyCache, + tailPathCache: tailPathCache + }; - function w(str) { - return str.split(/\s+/); - } + exports.caches = caches; - function decamelize(str) { - return DECAMELIZE_CACHE.get(str); + function isGlobal(path) { + return isGlobalCache.get(path); } - function dasherize(str) { - return STRING_DASHERIZE_CACHE.get(str); + function isGlobalPath(path) { + return isGlobalPathCache.get(path); } - function camelize(str) { - return CAMELIZE_CACHE.get(str); + function hasThis(path) { + return hasThisCache.get(path); } - function classify(str) { - return CLASSIFY_CACHE.get(str); + function isPath(path) { + return firstDotIndexCache.get(path) !== -1; } - function underscore(str) { - return UNDERSCORE_CACHE.get(str); + function getFirstKey(path) { + return firstKeyCache.get(path); } - function capitalize(str) { - return CAPITALIZE_CACHE.get(str); + function getTailPath(path) { + return tailPathCache.get(path); } - +}); +enifed('ember-metal/properties', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/property_events'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperty_events) { /** - Defines string helper methods including string formatting and localization. - Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be - added to the `String.prototype` as well. - - @class String - @namespace Ember - @static - @public + @module ember-metal */ - exports.default = { - /** - Apply formatting options to the string. This will look for occurrences - of "%@" in your string and substitute them with the arguments you pass into - this method. If you want to control the specific order of replacement, - you can add a number after the key as well to indicate which argument - you want to insert. - Ordered insertions are most useful when building loc strings where values - you need to insert may appear in different orders. - ```javascript - "Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe" - "Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John" - ``` - @method fmt - @param {String} str The string to format - @param {Array} formats An array of parameters to interpolate into string. - @return {String} formatted string - @public - @deprecated Use ES6 template strings instead: http://babeljs.io/docs/learn-es2015/#template-strings - */ - fmt: fmt, - - /** - Formats the passed string, but first looks up the string in the localized - strings hash. This is a convenient way to localize text. See - `Ember.String.fmt()` for more information on formatting. - Note that it is traditional but not required to prefix localized string - keys with an underscore or other character so you can easily identify - localized strings. - ```javascript - Ember.STRINGS = { - '_Hello World': 'Bonjour le monde', - '_Hello %@ %@': 'Bonjour %@ %@' - }; - Ember.String.loc("_Hello World"); // 'Bonjour le monde'; - Ember.String.loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; - ``` - @method loc - @param {String} str The string to format - @param {Array} formats Optional array of parameters to interpolate into string. - @return {String} formatted string - @public - */ - loc: loc, - - /** - Splits a string into separate units separated by spaces, eliminating any - empty strings in the process. This is a convenience method for split that - is mostly useful when applied to the `String.prototype`. - ```javascript - Ember.String.w("alpha beta gamma").forEach(function(key) { - console.log(key); - }); - // > alpha - // > beta - // > gamma - ``` - @method w - @param {String} str The string to split - @return {Array} array containing the split strings - @public - */ - w: w, - /** - Converts a camelized string into all lower case separated by underscores. - ```javascript - 'innerHTML'.decamelize(); // 'inner_html' - 'action_name'.decamelize(); // 'action_name' - 'css-class-name'.decamelize(); // 'css-class-name' - 'my favorite items'.decamelize(); // 'my favorite items' - ``` - @method decamelize - @param {String} str The string to decamelize. - @return {String} the decamelized string. - @public - */ - decamelize: decamelize, + 'use strict'; - /** - Replaces underscores, spaces, or camelCase with dashes. - ```javascript - 'innerHTML'.dasherize(); // 'inner-html' - 'action_name'.dasherize(); // 'action-name' - 'css-class-name'.dasherize(); // 'css-class-name' - 'my favorite items'.dasherize(); // 'my-favorite-items' - 'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice' - ``` - @method dasherize - @param {String} str The string to dasherize. - @return {String} the dasherized string. - @public - */ - dasherize: dasherize, + exports.Descriptor = Descriptor; + exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; + exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; + exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; + exports.defineProperty = defineProperty; - /** - Returns the lowerCamelCase form of a string. - ```javascript - 'innerHTML'.camelize(); // 'innerHTML' - 'action_name'.camelize(); // 'actionName' - 'css-class-name'.camelize(); // 'cssClassName' - 'my favorite items'.camelize(); // 'myFavoriteItems' - 'My Favorite Items'.camelize(); // 'myFavoriteItems' - 'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice' - ``` - @method camelize - @param {String} str The string to camelize. - @return {String} the camelized string. - @public - */ - camelize: camelize, + // .......................................................... + // DESCRIPTOR + // - /** - Returns the UpperCamelCase form of a string. - ```javascript - 'innerHTML'.classify(); // 'InnerHTML' - 'action_name'.classify(); // 'ActionName' - 'css-class-name'.classify(); // 'CssClassName' - 'my favorite items'.classify(); // 'MyFavoriteItems' - 'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice' - ``` - @method classify - @param {String} str the string to classify - @return {String} the classified string - @public - */ - classify: classify, + /** + Objects of this type can implement an interface to respond to requests to + get and set. The default implementation handles simple properties. + + @class Descriptor + @private + */ - /** - More general than decamelize. Returns the lower\_case\_and\_underscored - form of a string. - ```javascript - 'innerHTML'.underscore(); // 'inner_html' - 'action_name'.underscore(); // 'action_name' - 'css-class-name'.underscore(); // 'css_class_name' - 'my favorite items'.underscore(); // 'my_favorite_items' - 'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice' - ``` - @method underscore - @param {String} str The string to underscore. - @return {String} the underscored string. - @public - */ - underscore: underscore, + function Descriptor() { + this.isDescriptor = true; + } - /** - Returns the Capitalized form of a string - ```javascript - 'innerHTML'.capitalize() // 'InnerHTML' - 'action_name'.capitalize() // 'Action_name' - 'css-class-name'.capitalize() // 'Css-class-name' - 'my favorite items'.capitalize() // 'My favorite items' - 'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice' - ``` - @method capitalize - @param {String} str The string to capitalize. - @return {String} The capitalized string. - @public - */ - capitalize: capitalize - }; - exports.fmt = fmt; - exports.loc = loc; - exports.w = w; - exports.decamelize = decamelize; - exports.dasherize = dasherize; - exports.camelize = camelize; - exports.classify = classify; - exports.underscore = underscore; - exports.capitalize = capitalize; -}); -enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemObject) { - 'use strict'; + var REDEFINE_SUPPORTED = (function () { + // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 + var a = Object.create(Object.prototype, { + prop: { + configurable: true, + value: 1 + } + }); - exports.isArray = isArray; - exports.typeOf = typeOf; + Object.defineProperty(a, 'prop', { + configurable: true, + value: 2 + }); - // ........................................ - // TYPING & ARRAY MESSAGING + return a.prop === 2; + })(); + // .......................................................... + // DEFINING PROPERTIES API // - var TYPE_MAP = { - '[object Boolean]': 'boolean', - '[object Number]': 'number', - '[object String]': 'string', - '[object Function]': 'function', - '[object Array]': 'array', - '[object Date]': 'date', - '[object RegExp]': 'regexp', - '[object Object]': 'object', - '[object FileList]': 'filelist' - }; - var toString = Object.prototype.toString; + function MANDATORY_SETTER_FUNCTION(name) { + function SETTER_FUNCTION(value) { + var m = _emberMetalMeta.peekMeta(this); + if (!m.isInitialized(this)) { + m.writeValues(name, value); + } else {} + } - /** - Returns true if the passed object is an array or Array-like. - - Objects are considered Array-like if any of the following are true: - - - the object is a native Array - - the object has an objectAt property - - the object is an Object, and has a length property - - Unlike `Ember.typeOf` this method returns true even if the passed object is - not formally an array but appears to be array-like (i.e. implements `Ember.Array`) - - ```javascript - Ember.isArray(); // false - Ember.isArray([]); // true - Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true - ``` - - @method isArray - @for Ember - @param {Object} obj The object to test - @return {Boolean} true if the passed object is an array or Array-like - @public - */ + SETTER_FUNCTION.isMandatorySetter = true; + return SETTER_FUNCTION; + } - function isArray(obj) { - if (!obj || obj.setInterval) { - return false; - } - if (Array.isArray(obj)) { - return true; - } - if (_emberRuntimeMixinsArray.default.detect(obj)) { - return true; - } + function DEFAULT_GETTER_FUNCTION(name) { + return function GETTER_FUNCTION() { + var meta = _emberMetalMeta.peekMeta(this); + return meta && meta.peekValues(name); + }; + } - var type = typeOf(obj); - if ('array' === type) { - return true; - } - if (obj.length !== undefined && 'object' === type) { - return true; + function INHERITING_GETTER_FUNCTION(name) { + function IGETTER_FUNCTION() { + var meta = _emberMetalMeta.peekMeta(this); + var val = meta && meta.readInheritedValue('values', name); + + if (val === _emberMetalMeta.UNDEFINED) { + var proto = Object.getPrototypeOf(this); + return proto && proto[name]; + } else { + return val; + } } - return false; + + IGETTER_FUNCTION.isInheritingGetter = true; + return IGETTER_FUNCTION; } /** - Returns a consistent type for the passed object. + NOTE: This is a low-level method used by other parts of the API. You almost + never want to call this method directly. Instead you should use + `Ember.mixin()` to define new properties. - Use this instead of the built-in `typeof` to get the type of an item. - It will return the same result across all browsers and includes a bit - more detail. Here is what will be returned: + Defines a property on an object. This method works much like the ES5 + `Object.defineProperty()` method except that it can also accept computed + properties and other special descriptors. - | Return Value | Meaning | - |---------------|------------------------------------------------------| - | 'string' | String primitive or String object. | - | 'number' | Number primitive or Number object. | - | 'boolean' | Boolean primitive or Boolean object. | - | 'null' | Null value | - | 'undefined' | Undefined value | - | 'function' | A function | - | 'array' | An instance of Array | - | 'regexp' | An instance of RegExp | - | 'date' | An instance of Date | - | 'filelist' | An instance of FileList | - | 'class' | An Ember class (created using Ember.Object.extend()) | - | 'instance' | An Ember object instance | - | 'error' | An instance of the Error object | - | 'object' | A JavaScript object not inheriting from Ember.Object | + Normally this method takes only three parameters. However if you pass an + instance of `Descriptor` as the third param then you can pass an + optional value as the fourth parameter. This is often more efficient than + creating new descriptor hashes for each property. - Examples: + ## Examples ```javascript - Ember.typeOf(); // 'undefined' - Ember.typeOf(null); // 'null' - Ember.typeOf(undefined); // 'undefined' - Ember.typeOf('michael'); // 'string' - Ember.typeOf(new String('michael')); // 'string' - Ember.typeOf(101); // 'number' - Ember.typeOf(new Number(101)); // 'number' - Ember.typeOf(true); // 'boolean' - Ember.typeOf(new Boolean(true)); // 'boolean' - Ember.typeOf(Ember.makeArray); // 'function' - Ember.typeOf([1, 2, 90]); // 'array' - Ember.typeOf(/abc/); // 'regexp' - Ember.typeOf(new Date()); // 'date' - Ember.typeOf(event.target.files); // 'filelist' - Ember.typeOf(Ember.Object.extend()); // 'class' - Ember.typeOf(Ember.Object.create()); // 'instance' - Ember.typeOf(new Error('teamocil')); // 'error' + // ES5 compatible mode + Ember.defineProperty(contact, 'firstName', { + writable: true, + configurable: false, + enumerable: true, + value: 'Charles' + }); - // 'normal' JavaScript object - Ember.typeOf({ a: 'b' }); // 'object' + // define a simple property + Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); + + // define a computed property + Ember.defineProperty(contact, 'fullName', Ember.computed('firstName', 'lastName', function() { + return this.firstName+' '+this.lastName; + })); ``` - @method typeOf + @private + @method defineProperty @for Ember - @param {Object} item the item to check - @return {String} the type - @public + @param {Object} obj the object to define this property on. This may be a prototype. + @param {String} keyName the name of the property + @param {Descriptor} [desc] an instance of `Descriptor` (typically a + computed property) or an ES5 descriptor. + You must provide this or `data` but not both. + @param {*} [data] something other than a descriptor, that will + become the explicit value of this property. */ - function typeOf(item) { - if (item === null) { - return 'null'; + function defineProperty(obj, keyName, desc, data, meta) { + var possibleDesc = undefined, + existingDesc = undefined, + watching = undefined, + value = undefined; + + if (!meta) { + meta = _emberMetalMeta.meta(obj); } - if (item === undefined) { - return 'undefined'; + var watchEntry = meta.peekWatching(keyName); + possibleDesc = obj[keyName]; + existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + watching = watchEntry !== undefined && watchEntry > 0; + + if (existingDesc) { + existingDesc.teardown(obj, keyName); } - var ret = TYPE_MAP[toString.call(item)] || 'object'; - if (ret === 'function') { - if (_emberRuntimeSystemObject.default.detect(item)) { - ret = 'class'; + if (desc instanceof Descriptor) { + value = desc; + if (false) { + if (watching) { + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable: true, + writable: true, + value: value + }); + } else { + obj[keyName] = value; + } + } else { + obj[keyName] = value; } - } else if (ret === 'object') { - if (item instanceof Error) { - ret = 'error'; - } else if (item instanceof _emberRuntimeSystemObject.default) { - ret = 'instance'; - } else if (item instanceof Date) { - ret = 'date'; + if (desc.setup) { + desc.setup(obj, keyName); } - } - - return ret; - } -}); -enifed("ember-utils/apply-str", ["exports"], function (exports) { - /** - @param {Object} t target - @param {String} m method - @param {Array} a args - @private - */ - "use strict"; + } else { + if (desc == null) { + value = data; - exports.default = applyStr; + if (false) { + if (watching) { + meta.writeValues(keyName, data); - function applyStr(t, m, a) { - var l = a && a.length; - if (!a || !l) { - return t[m](); - } - switch (l) { - case 1: - return t[m](a[0]); - case 2: - return t[m](a[0], a[1]); - case 3: - return t[m](a[0], a[1], a[2]); - case 4: - return t[m](a[0], a[1], a[2], a[3]); - case 5: - return t[m](a[0], a[1], a[2], a[3], a[4]); - default: - return t[m].apply(t, a); - } - } -}); -enifed("ember-utils/assign", ["exports"], function (exports) { - /** - Copy properties from a source object to a target object. - - ```javascript - var a = { first: 'Yehuda' }; - var b = { last: 'Katz' }; - var c = { company: 'Tilde Inc.' }; - Ember.assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' } - ``` - - @method assign - @for Ember - @param {Object} original The object to assign into - @param {Object} ...args The objects to copy properties from - @return {Object} - @public - */ - "use strict"; + var defaultDescriptor = { + configurable: true, + enumerable: true, + set: MANDATORY_SETTER_FUNCTION(keyName), + get: DEFAULT_GETTER_FUNCTION(keyName) + }; - exports.default = assign; + if (REDEFINE_SUPPORTED) { + Object.defineProperty(obj, keyName, defaultDescriptor); + } else { + handleBrokenPhantomDefineProperty(obj, keyName, defaultDescriptor); + } + } else { + obj[keyName] = data; + } + } else { + obj[keyName] = data; + } + } else { + value = desc; - function assign(original) { - for (var i = 1; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) { - continue; + // fallback to ES5 + Object.defineProperty(obj, keyName, desc); } + } - var updates = Object.keys(arg); + // if key is being watched, override chains that + // were initialized with the prototype + if (watching) { + _emberMetalProperty_events.overrideChains(obj, keyName, meta); + } - for (var _i = 0; _i < updates.length; _i++) { - var prop = updates[_i]; - original[prop] = arg[prop]; - } + // The `value` passed to the `didDefineProperty` hook is + // either the descriptor or data, whichever was passed. + if (obj.didDefineProperty) { + obj.didDefineProperty(obj, keyName, value); } - return original; + return this; } -}); -enifed('ember-utils/dictionary', ['exports', 'ember-utils/empty-object'], function (exports, _emberUtilsEmptyObject) { - 'use strict'; - exports.default = makeDictionary; - - // the delete is meant to hint at runtimes that this object should remain in - // dictionary mode. This is clearly a runtime specific hack, but currently it - // appears worthwhile in some usecases. Please note, these deletes do increase - // the cost of creation dramatically over a plain Object.create. And as this - // only makes sense for long-lived dictionaries that aren't instantiated often. - - function makeDictionary(parent) { - var dict = undefined; - if (parent === null) { - dict = new _emberUtilsEmptyObject.default(); - } else { - dict = Object.create(parent); - } - dict['_dict'] = null; - delete dict['_dict']; - return dict; + function handleBrokenPhantomDefineProperty(obj, keyName, desc) { + // https://github.com/ariya/phantomjs/issues/11856 + Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); + Object.defineProperty(obj, keyName, desc); } }); -enifed("ember-utils/empty-object", ["exports"], function (exports) { - // This exists because `Object.create(null)` is absurdly slow compared - // to `new EmptyObject()`. In either case, you want a null prototype - // when you're treating the object instances as arbitrary dictionaries - // and don't want your keys colliding with build-in methods on the - // default object prototype. - - "use strict"; +enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) { + 'use strict'; - var proto = Object.create(null, { - // without this, we will always still end up with (new - // EmptyObject()).constructor === Object - constructor: { - value: undefined, - enumerable: false, - writable: true - } - }); + var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE'); - function EmptyObject() {} - EmptyObject.prototype = proto; - exports.default = EmptyObject; -}); -enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, _emberUtilsIntern) { - 'use strict'; + exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; + var beforeObserverSet = new _emberMetalObserver_set.default(); + var observerSet = new _emberMetalObserver_set.default(); + var deferred = 0; - exports.uuid = uuid; - exports.generateGuid = generateGuid; - exports.guidFor = guidFor; + // .......................................................... + // PROPERTY CHANGES + // /** - Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from - jQuery master. We'll just bootstrap our own uuid now. + This function is called just before an object property is about to change. + It will notify any before observers and prepare caches among other things. - @private - @return {Number} the uuid - */ - var _uuid = 0; - - /** - Generates a universally unique identifier. This method - is used internally by Ember for assisting with - the generation of GUID's and other unique identifiers. + Normally you will not need to call this method directly but if for some + reason you can't directly watch a property you can invoke this method + manually along with `Ember.propertyDidChange()` which you should call just + after the property value changes. - @public - @return {Number} [description] - */ + @method propertyWillChange + @for Ember + @param {Object} obj The object with the property that will change + @param {String} keyName The property key (or path) that will change. + @return {void} + @private + */ + function propertyWillChange(obj, keyName, _meta) { + var meta = _meta || _emberMetalMeta.peekMeta(obj); - function uuid() { - return ++_uuid; - } + if (meta && !meta.isInitialized(obj)) { + return; + } - /** - Prefix used for guids through out Ember. - @private - @property GUID_PREFIX - @for Ember - @type String - @final - */ - var GUID_PREFIX = 'ember'; + var watching = meta && meta.peekWatching(keyName) > 0; + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - // Used for guid generation... - var numberCache = []; - var stringCache = {}; + if (desc && desc.willChange) { + desc.willChange(obj, keyName); + } + + if (watching) { + dependentKeysWillChange(obj, keyName, meta); + chainsWillChange(obj, keyName, meta); + notifyBeforeObservers(obj, keyName, meta); + } + } /** - A unique key used to assign guids and other private metadata to objects. - If you inspect an object in your browser debugger you will often see these. - They can be safely ignored. + This function is called just after an object property has changed. + It will notify any observers and clear caches among other things. - On browsers that support it, these properties are added with enumeration - disabled so they won't show up when you iterate over your properties. + Normally you will not need to call this method directly but if for some + reason you can't directly watch a property you can invoke this method + manually along with `Ember.propertyWillChange()` which you should call just + before the property value changes. - @private - @property GUID_KEY + @method propertyDidChange @for Ember - @type String - @final + @param {Object} obj The object with the property that will change + @param {String} keyName The property key (or path) that will change. + @param {Meta} meta The objects meta. + @return {void} + @private */ - var GUID_KEY = _emberUtilsIntern.default('__ember' + +new Date()); + function propertyDidChange(obj, keyName, _meta) { + var meta = _meta || _emberMetalMeta.peekMeta(obj); - exports.GUID_KEY = GUID_KEY; - var GUID_DESC = { - writable: true, - configurable: true, - enumerable: false, - value: null - }; + if (meta && !meta.isInitialized(obj)) { + return; + } - exports.GUID_DESC = GUID_DESC; - var nullDescriptor = { - configurable: true, - writable: true, - enumerable: false, - value: null - }; + var watching = meta && meta.peekWatching(keyName) > 0; + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - var GUID_KEY_PROPERTY = { - name: GUID_KEY, - descriptor: nullDescriptor - }; + // shouldn't this mean that we're watching this key? + if (desc && desc.didChange) { + desc.didChange(obj, keyName); + } - exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY; - /** - Generates a new guid, optionally saving the guid to the object that you - pass in. You will rarely need to use this method. Instead you should - call `Ember.guidFor(obj)`, which return an existing guid if available. - - @private - @method generateGuid - @for Ember - @param {Object} [obj] Object the guid will be used for. If passed in, the guid will - be saved on the object and reused whenever you pass the same object - again. - - If no object is passed, just generate a new guid. - @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to - separate the guid into separate namespaces. - @return {String} the guid - */ + if (watching) { + if (meta.hasDeps(keyName)) { + dependentKeysDidChange(obj, keyName, meta); + } - function generateGuid(obj, prefix) { - if (!prefix) { - prefix = GUID_PREFIX; + chainsDidChange(obj, keyName, meta, false); + notifyObservers(obj, keyName, meta); } - var ret = prefix + uuid(); - if (obj) { - if (obj[GUID_KEY] === null) { - obj[GUID_KEY] = ret; - } else { - GUID_DESC.value = ret; - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(GUID_KEY_PROPERTY); - } else { - Object.defineProperty(obj, GUID_KEY, GUID_DESC); - } - } + if (obj[PROPERTY_DID_CHANGE]) { + obj[PROPERTY_DID_CHANGE](keyName); + } + + if (meta && meta.isSourceDestroying()) { + return; + } + + _emberMetalTags.markObjectAsDirty(meta, keyName); + + if (false || false) { + _emberMetalTransaction.assertNotRendered(obj, keyName, meta); } - return ret; } - /** - Returns a unique id for the object. If the object does not yet have a guid, - one will be assigned to it. You can call this on any object, - `Ember.Object`-based or not, but be aware that it will add a `_guid` - property. - - You can also use this method on DOM Element objects. - - @public - @method guidFor - @for Ember - @param {Object} obj any object, string, number, Element, or primitive - @return {String} the unique guid for this instance. - */ + var WILL_SEEN = undefined, + DID_SEEN = undefined; + // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) + function dependentKeysWillChange(obj, depKey, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - function guidFor(obj) { - var type = typeof obj; - var isObject = type === 'object' && obj !== null; - var isFunction = type === 'function'; + if (meta && meta.hasDeps(depKey)) { + var seen = WILL_SEEN; + var _top = !seen; + + if (_top) { + seen = WILL_SEEN = {}; + } + + iterDeps(propertyWillChange, obj, depKey, seen, meta); - if ((isObject || isFunction) && obj[GUID_KEY]) { - return obj[GUID_KEY]; + if (_top) { + WILL_SEEN = null; + } } + } - // special cases where we don't want to add a key to object - if (obj === undefined) { - return '(undefined)'; + // called whenever a property has just changed to update dependent keys + function dependentKeysDidChange(obj, depKey, meta) { + if (meta && meta.isSourceDestroying()) { + return; } - if (obj === null) { - return '(null)'; - } + if (meta && meta.hasDeps(depKey)) { + var seen = DID_SEEN; + var _top2 = !seen; - var ret = undefined; + if (_top2) { + seen = DID_SEEN = {}; + } - // Don't allow prototype changes to String etc. to change the guidFor - switch (type) { - case 'number': - ret = numberCache[obj]; + iterDeps(propertyDidChange, obj, depKey, seen, meta); - if (!ret) { - ret = numberCache[obj] = 'nu' + obj; - } + if (_top2) { + DID_SEEN = null; + } + } + } - return ret; + function iterDeps(method, obj, depKey, seen, meta) { + var possibleDesc = undefined, + desc = undefined; + var guid = _emberUtils.guidFor(obj); + var current = seen[guid]; - case 'string': - ret = stringCache[obj]; + if (!current) { + current = seen[guid] = {}; + } - if (!ret) { - ret = stringCache[obj] = 'st' + uuid(); - } + if (current[depKey]) { + return; + } - return ret; + current[depKey] = true; - case 'boolean': - return obj ? '(true)' : '(false)'; + meta.forEachInDeps(depKey, function (key, value) { + if (!value) { + return; + } - default: - if (obj === Object) { - return '(Object)'; - } + possibleDesc = obj[key]; + desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - if (obj === Array) { - return '(Array)'; - } + if (desc && desc._suspended === obj) { + return; + } - ret = GUID_PREFIX + uuid(); + method(obj, key, meta); + }); + } - if (obj[GUID_KEY] === null) { - obj[GUID_KEY] = ret; - } else { - GUID_DESC.value = ret; + function chainsWillChange(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.notify(keyName, false, propertyWillChange); + } + } - if (obj.__defineNonEnumerable) { - obj.__defineNonEnumerable(GUID_KEY_PROPERTY); - } else { - Object.defineProperty(obj, GUID_KEY, GUID_DESC); - } - } - return ret; + function chainsDidChange(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.notify(keyName, true, propertyDidChange); } } -}); -enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString) { - /* - This package will be eagerly parsed and should have no dependencies on external - packages. - - It is intended to be used to share utility methods that will be needed - by every Ember application (and is **not** a dumping ground of useful utilities). - - Utility methods that are needed in < 80% of cases should be placed - elsewhere (so they can be lazily evaluated / parsed). - */ - 'use strict'; - exports.symbol = _emberUtilsSymbol.default; - exports.getOwner = _emberUtilsOwner.getOwner; - exports.setOwner = _emberUtilsOwner.setOwner; - exports.OWNER = _emberUtilsOwner.OWNER; - exports.assign = _emberUtilsAssign.default; - exports.EmptyObject = _emberUtilsEmptyObject.default; - exports.dictionary = _emberUtilsDictionary.default; - exports.uuid = _emberUtilsGuid.uuid; - exports.GUID_KEY = _emberUtilsGuid.GUID_KEY; - exports.GUID_DESC = _emberUtilsGuid.GUID_DESC; - exports.GUID_KEY_PROPERTY = _emberUtilsGuid.GUID_KEY_PROPERTY; - exports.generateGuid = _emberUtilsGuid.generateGuid; - exports.guidFor = _emberUtilsGuid.guidFor; - exports.intern = _emberUtilsIntern.default; - exports.checkHasSuper = _emberUtilsSuper.checkHasSuper; - exports.ROOT = _emberUtilsSuper.ROOT; - exports.wrap = _emberUtilsSuper.wrap; - exports.inspect = _emberUtilsInspect.default; - exports.lookupDescriptor = _emberUtilsLookupDescriptor.default; - exports.canInvoke = _emberUtilsInvoke.canInvoke; - exports.tryInvoke = _emberUtilsInvoke.tryInvoke; - exports.makeArray = _emberUtilsMakeArray.default; - exports.applyStr = _emberUtilsApplyStr.default; - exports.NAME_KEY = _emberUtilsName.default; - exports.toString = _emberUtilsToString.default; -}); -enifed('ember-utils/inspect', ['exports'], function (exports) { - 'use strict'; + function overrideChains(obj, keyName, meta) { + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers) { + chainWatchers.revalidate(keyName); + } + } - exports.default = inspect; - var objectToString = Object.prototype.toString; + /** + @method beginPropertyChanges + @chainable + @private + */ + function beginPropertyChanges() { + deferred++; + } /** - Convenience method to inspect an object. This method will attempt to - convert the object into a useful string description. + @method endPropertyChanges + @private + */ + function endPropertyChanges() { + deferred--; + if (deferred <= 0) { + beforeObserverSet.clear(); + observerSet.flush(); + } + } + + /** + Make a series of property changes together in an + exception-safe way. - It is a pretty simple implementation. If you want something more robust, - use something like JSDump: https://github.com/NV/jsDump + ```javascript + Ember.changeProperties(function() { + obj1.set('foo', mayBlowUpWhenSet); + obj2.set('bar', baz); + }); + ``` - @method inspect - @for Ember - @param {Object} obj The object you want to inspect. - @return {String} A description of the object - @since 1.4.0 + @method changeProperties + @param {Function} callback + @param [binding] @private */ - - function inspect(obj) { - if (obj === null) { - return 'null'; - } - if (obj === undefined) { - return 'undefined'; - } - if (Array.isArray(obj)) { - return '[' + obj + ']'; + function changeProperties(callback, binding) { + beginPropertyChanges(); + try { + callback.call(binding); + } finally { + endPropertyChanges.call(binding); } - // for non objects - var type = typeof obj; - if (type !== 'object' && type !== 'symbol') { - return '' + obj; + } + + function notifyBeforeObservers(obj, keyName, meta) { + if (meta && meta.isSourceDestroying()) { + return; } - // overridden toString - if (typeof obj.toString === 'function' && obj.toString !== objectToString) { - return obj.toString(); + + var eventName = keyName + ':before'; + var listeners = undefined, + added = undefined; + if (deferred) { + listeners = beforeObserverSet.add(obj, keyName, eventName); + added = _emberMetalEvents.accumulateListeners(obj, eventName, listeners); + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName], added); + } else { + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); } + } - // Object.prototype.toString === {}.toString - var v = undefined; - var ret = []; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - v = obj[key]; - if (v === 'toString') { - continue; - } // ignore useless items - if (typeof v === 'function') { - v = 'function() { ... }'; - } + function notifyObservers(obj, keyName, meta) { + if (meta && meta.isSourceDestroying()) { + return; + } - if (v && typeof v.toString !== 'function') { - ret.push(key + ': ' + objectToString.call(v)); - } else { - ret.push(key + ': ' + v); - } - } + var eventName = keyName + ':change'; + var listeners = undefined; + if (deferred) { + listeners = observerSet.add(obj, keyName, eventName); + _emberMetalEvents.accumulateListeners(obj, eventName, listeners); + } else { + _emberMetalEvents.sendEvent(obj, eventName, [obj, keyName]); } - return '{' + ret.join(', ') + '}'; } + + exports.propertyWillChange = propertyWillChange; + exports.propertyDidChange = propertyDidChange; + exports.overrideChains = overrideChains; + exports.beginPropertyChanges = beginPropertyChanges; + exports.endPropertyChanges = endPropertyChanges; + exports.changeProperties = changeProperties; }); -enifed("ember-utils/intern", ["exports"], function (exports) { +enifed('ember-metal/property_get', ['exports', 'ember-metal/debug', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalPath_cache) { /** - Strongly hint runtimes to intern the provided string. - - When do I need to use this function? - - For the most part, never. Pre-mature optimization is bad, and often the - runtime does exactly what you need it to, and more often the trade-off isn't - worth it. - - Why? - - Runtimes store strings in at least 2 different representations: - Ropes and Symbols (interned strings). The Rope provides a memory efficient - data-structure for strings created from concatenation or some other string - manipulation like splitting. - - Unfortunately checking equality of different ropes can be quite costly as - runtimes must resort to clever string comparison algorithms. These - algorithms typically cost in proportion to the length of the string. - Luckily, this is where the Symbols (interned strings) shine. As Symbols are - unique by their string content, equality checks can be done by pointer - comparison. - - How do I know if my string is a rope or symbol? - - Typically (warning general sweeping statement, but truthy in runtimes at - present) static strings created as part of the JS source are interned. - Strings often used for comparisons can be interned at runtime if some - criteria are met. One of these criteria can be the size of the entire rope. - For example, in chrome 38 a rope longer then 12 characters will not - intern, nor will segments of that rope. - - Some numbers: http://jsperf.com/eval-vs-keys/8 - - Known Trick™ - - @private - @return {String} interned version of the provided string + @module ember-metal */ - "use strict"; - - exports.default = intern; - function intern(str) { - var obj = {}; - obj[str] = 1; - for (var key in obj) { - if (key === str) { - return key; - } - } - return str; - } -}); -enifed('ember-utils/invoke', ['exports', 'ember-utils/apply-str'], function (exports, _emberUtilsApplyStr) { 'use strict'; - exports.canInvoke = canInvoke; - exports.tryInvoke = tryInvoke; + exports.get = get; + exports._getPath = _getPath; + exports.getWithDefault = getWithDefault; + + var ALLOWABLE_TYPES = { + object: true, + function: true, + string: true + }; + + // .......................................................... + // GET AND SET + // + // If we are on a platform that supports accessors we can use those. + // Otherwise simulate accessors by looking up the property directly on the + // object. /** - Checks to see if the `methodName` exists on the `obj`. + Gets the value of a property on an object. If the property is computed, + the function will be invoked. If the property is not defined but the + object implements the `unknownProperty` method then that will be invoked. ```javascript - let foo = { bar: function() { return 'bar'; }, baz: null }; - - Ember.canInvoke(foo, 'bar'); // true - Ember.canInvoke(foo, 'baz'); // false - Ember.canInvoke(foo, 'bat'); // false + Ember.get(obj, "name"); ``` - @method canInvoke - @for Ember - @param {Object} obj The object to check for the method - @param {String} methodName The method name to check for - @return {Boolean} - @private - */ - - function canInvoke(obj, methodName) { - return !!(obj && typeof obj[methodName] === 'function'); - } - - /** - Checks to see if the `methodName` exists on the `obj`, - and if it does, invokes it with the arguments passed. + If you plan to run on IE8 and older browsers then you should use this + method anytime you want to retrieve a property on an object that you don't + know for sure is private. (Properties beginning with an underscore '_' + are considered private.) - ```javascript - let d = new Date('03/15/2013'); + On all newer browsers, you only need to use this method to retrieve + properties if the property might not be defined on the object and you want + to respect the `unknownProperty` handler. Otherwise you can ignore this + method. - Ember.tryInvoke(d, 'getTime'); // 1363320000000 - Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 - Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined - ``` + Note that if the object itself is `undefined`, this method will throw + an error. - @method tryInvoke + @method get @for Ember - @param {Object} obj The object to check for the method - @param {String} methodName The method name to check for - @param {Array} [args] The arguments to pass to the method - @return {*} the return value of the invoked method or undefined if it cannot be invoked + @param {Object} obj The object to retrieve from. + @param {String} keyName The property key to retrieve + @return {Object} the property value or `null`. @public */ - function tryInvoke(obj, methodName, args) { - if (canInvoke(obj, methodName)) { - return args ? _emberUtilsApplyStr.default(obj, methodName, args) : _emberUtilsApplyStr.default(obj, methodName); - } - } -}); -enifed("ember-utils/lookup-descriptor", ["exports"], function (exports) { - "use strict"; - - exports.default = lookupDescriptor; - - function lookupDescriptor(obj, keyName) { - var current = obj; - while (current) { - var descriptor = Object.getOwnPropertyDescriptor(current, keyName); + function get(obj, keyName) { - if (descriptor) { - return descriptor; - } + var value = obj[keyName]; + var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined; + var ret = undefined; - current = Object.getPrototypeOf(current); + if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) { + return _getPath(obj, keyName); } - return null; - } -}); -enifed("ember-utils/make-array", ["exports"], function (exports) { - /** - Forces the passed object to be part of an array. If the object is already - an array, it will return the object. Otherwise, it will add the object to - an array. If obj is `null` or `undefined`, it will return an empty array. - - ```javascript - Ember.makeArray(); // [] - Ember.makeArray(null); // [] - Ember.makeArray(undefined); // [] - Ember.makeArray('lindsay'); // ['lindsay'] - Ember.makeArray([1, 2, 42]); // [1, 2, 42] - - let controller = Ember.ArrayProxy.create({ content: [] }); - - Ember.makeArray(controller) === controller; // true - ``` - - @method makeArray - @for Ember - @param {Object} obj the object - @return {Array} - @private - */ - "use strict"; + if (desc) { + return desc.get(obj, keyName); + } else { + ret = value; - exports.default = makeArray; + if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { + return obj.unknownProperty(keyName); + } - function makeArray(obj) { - if (obj === null || obj === undefined) { - return []; + return ret; } - return Array.isArray(obj) ? obj : [obj]; } -}); -enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - 'use strict'; - exports.default = _emberUtilsSymbol.default('NAME_KEY'); -}); -enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - /** - @module ember - @submodule ember-runtime - */ + function _getPath(root, path) { + var obj = root; + var parts = path.split('.'); - 'use strict'; + for (var i = 0; i < parts.length; i++) { + if (!isGettable(obj)) { + return undefined; + } - exports.getOwner = getOwner; - exports.setOwner = setOwner; - var OWNER = _emberUtilsSymbol.default('OWNER'); + obj = get(obj, parts[i]); - exports.OWNER = OWNER; - /** - Framework objects in an Ember application (components, services, routes, etc.) - are created via a factory and dependency injection system. Each of these - objects is the responsibility of an "owner", which handled its - instantiation and manages its lifetime. - - `getOwner` fetches the owner object responsible for an instance. This can - be used to lookup or resolve other class instances, or register new factories - into the owner. - - For example, this component dynamically looks up a service based on the - `audioType` passed as an attribute: - - ``` - // app/components/play-audio.js - import Ember from 'ember'; - - // Usage: - // - // {{play-audio audioType=model.audioType audioFile=model.file}} - // - export default Ember.Component.extend({ - audioService: Ember.computed('audioType', function() { - let owner = Ember.getOwner(this); - return owner.lookup(`service:${this.get('audioType')}`); - }), - click() { - let player = this.get('audioService'); - player.play(this.get('audioFile')); + if (obj && obj.isDestroyed) { + return undefined; } - }); + } + + return obj; + } + + function isGettable(obj) { + if (obj == null) { + return false; + } + + return ALLOWABLE_TYPES[typeof obj]; + } + + /** + Retrieves the value of a property from an Object, or a default value in the + case that the property returns `undefined`. + + ```javascript + Ember.getWithDefault(person, 'lastName', 'Doe'); ``` - @method getOwner + @method getWithDefault @for Ember - @param {Object} object An object with an owner. - @return {Object} An owner object. - @since 2.3.0 + @param {Object} obj The object to retrieve from. + @param {String} keyName The name of the property to retrieve + @param {Object} defaultValue The value to return if the property value is undefined + @return {Object} The property value or the defaultValue. @public */ - function getOwner(object) { - return object[OWNER]; + function getWithDefault(root, key, defaultValue) { + var value = get(root, key); + + if (value === undefined) { + return defaultValue; + } + return value; } + exports.default = get; +}); +enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) { + 'use strict'; + + exports.set = set; + exports.trySet = trySet; + /** - `setOwner` forces a new owner on a given object instance. This is primarily - useful in some testing cases. + Sets the value of a property on an object, respecting computed properties + and notifying observers and other listeners of the change. If the + property is not defined but the object implements the `setUnknownProperty` + method then that will be invoked as well. - @method setOwner + ```javascript + Ember.set(obj, "name", value); + ``` + + @method set @for Ember - @param {Object} object An object with an owner. - @return {Object} An owner object. - @since 2.3.0 + @param {Object} obj The object to modify. + @param {String} keyName The property key to set + @param {Object} value The value to set + @return {Object} the passed value. @public */ - function setOwner(object, owner) { - object[OWNER] = owner; - } -}); -enifed('ember-utils/super', ['exports'], function (exports) { - 'use strict'; + function set(obj, keyName, value, tolerant) { - exports.wrap = wrap; - var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/; - var fnToString = Function.prototype.toString; + if (_emberMetalPath_cache.isPath(keyName)) { + return setPath(obj, keyName, value, tolerant); + } - var checkHasSuper = (function () { - var sourceAvailable = fnToString.call(function () { - return this; - }).indexOf('return this') > -1; + var meta = _emberMetalMeta.peekMeta(obj); + var possibleDesc = obj[keyName]; - if (sourceAvailable) { - return function checkHasSuper(func) { - return HAS_SUPER_PATTERN.test(fnToString.call(func)); - }; + var desc = undefined, + currentValue = undefined; + if (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { + desc = possibleDesc; + } else { + currentValue = possibleDesc; } - return function checkHasSuper() { - return true; - }; - })(); + if (desc) { + /* computed property */ + desc.set(obj, keyName, value); + } else if (obj.setUnknownProperty && currentValue === undefined && !(keyName in obj)) { + obj.setUnknownProperty(keyName, value); + /* unknown property */ + } else if (currentValue === value) { + /* no change */ + return value; + } else { + _emberMetalProperty_events.propertyWillChange(obj, keyName); - exports.checkHasSuper = checkHasSuper; - function ROOT() {} - ROOT.__hasSuper = false; + if (false) { + setWithMandatorySetter(meta, obj, keyName, value); + } else { + obj[keyName] = value; + } - function hasSuper(func) { - if (func.__hasSuper === undefined) { - func.__hasSuper = checkHasSuper(func); + _emberMetalProperty_events.propertyDidChange(obj, keyName); } - return func.__hasSuper; + + return value; } - /** - Wraps the passed function so that `this._super` will point to the superFunc - when the function is invoked. This is the primitive we use to implement - calls to super. - - @private - @method wrap - @for Ember - @param {Function} func The function to call - @param {Function} superFunc The super function. - @return {Function} wrapped function. - */ + if (false) { + var setWithMandatorySetter = function (meta, obj, keyName, value) { + if (meta && meta.peekWatching(keyName) > 0) { + makeEnumerable(obj, keyName); + meta.writeValue(obj, keyName, value); + } else { + obj[keyName] = value; + } + }; - function wrap(func, superFunc) { - if (!hasSuper(func)) { - return func; + var makeEnumerable = function (obj, key) { + var desc = Object.getOwnPropertyDescriptor(obj, key); + + if (desc && desc.set && desc.set.isMandatorySetter) { + desc.enumerable = true; + Object.defineProperty(obj, key, desc); + } + }; + } + + function setPath(root, path, value, tolerant) { + // get the last part of the path + var keyName = path.slice(path.lastIndexOf('.') + 1); + + // get the first part of the part + path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); + + // unless the path is this, look up the first part to + // get the root + if (path !== 'this') { + root = _emberMetalProperty_get._getPath(root, path); } - // ensure an unwrapped super that calls _super is wrapped with a terminal _super - if (!superFunc.wrappedFunction && hasSuper(superFunc)) { - return _wrap(func, _wrap(superFunc, ROOT)); + + if (!keyName || keyName.length === 0) { + throw new _emberMetalError.default('Property set failed: You passed an empty path'); } - return _wrap(func, superFunc); - } - function _wrap(func, superFunc) { - function superWrapper() { - var orig = this._super; - this._super = superFunc; - var ret = func.apply(this, arguments); - this._super = orig; - return ret; + if (!root) { + if (tolerant) { + return; + } else { + throw new _emberMetalError.default('Property set failed: object in path "' + path + '" could not be found or was destroyed.'); + } } - superWrapper.wrappedFunction = func; - superWrapper.__ember_observes__ = func.__ember_observes__; - superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__; - superWrapper.__ember_listens__ = func.__ember_listens__; + return set(root, keyName, value); + } - return superWrapper; + /** + Error-tolerant form of `Ember.set`. Will not blow up if any part of the + chain is `undefined`, `null`, or destroyed. + + This is primarily used when syncing bindings, which may try to update after + an object has been destroyed. + + @method trySet + @for Ember + @param {Object} root The object to modify. + @param {String} path The property path to set + @param {Object} value The value to set + @public + */ + + function trySet(root, path, value) { + return set(root, path, value, true); } }); -enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern'], function (exports, _emberUtilsGuid, _emberUtilsIntern) { - 'use strict'; +enifed("ember-metal/replace", ["exports"], function (exports) { + "use strict"; - exports.default = symbol; + exports.default = replace; + var splice = Array.prototype.splice; - function symbol(debugName) { - // TODO: Investigate using platform symbols, but we do not - // want to require non-enumerability for this API, which - // would introduce a large cost. + function replace(array, idx, amt, objects) { + var args = [].concat(objects); + var ret = []; + // https://code.google.com/p/chromium/issues/detail?id=56588 + var size = 60000; + var start = idx; + var ends = amt; + var count = undefined, + chunk = undefined; - return _emberUtilsIntern.default(debugName + ' [id=' + _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()) + ']'); - } -}); -enifed('ember-utils/to-string', ['exports'], function (exports) { - 'use strict'; + while (args.length) { + count = ends > size ? size : ends; + if (count <= 0) { + count = 0; + } - exports.default = toString; - var objectToString = Object.prototype.toString; + chunk = args.splice(0, size); + chunk = [start, count].concat(chunk); - /* - A `toString` util function that supports objects without a `toString` - method, e.g. an object created with `Object.create(null)`. - */ + start += size; + ends -= count; - function toString(obj) { - if (obj && typeof obj.toString === 'function') { - return obj.toString(); - } else { - return objectToString.call(obj); + ret = ret.concat(splice.apply(array, chunk)); } + return ret; } }); -enifed('ember-views/compat/attrs', ['exports', 'ember-utils'], function (exports, _emberUtils) { +enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) { 'use strict'; - var MUTABLE_CELL = _emberUtils.symbol('MUTABLE_CELL'); - exports.MUTABLE_CELL = MUTABLE_CELL; -}); -enifed('ember-views/compat/fallback-view-registry', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + exports.default = run; - exports.default = _emberUtils.dictionary(null); -}); -enifed('ember-views/component_lookup', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { - 'use strict'; + function onBegin(current) { + run.currentRunLoop = current; + } - exports.default = _emberRuntime.Object.extend({ - componentFor: function (name, owner, options) { + function onEnd(current, next) { + run.currentRunLoop = next; + } - var fullName = 'component:' + name; - return owner._lookupFactory(fullName, options); + var onErrorTarget = { + get onerror() { + return _emberMetalError_handler.getOnerror(); }, - - layoutFor: function (name, owner, options) { - - var templateFullName = 'template:components/' + name; - return owner.lookup(templateFullName, options); + set onerror(handler) { + return _emberMetalError_handler.setOnerror(handler); } + }; + + var backburner = new _backburner.default(['sync', 'actions', 'destroy'], { + GUID_KEY: _emberUtils.GUID_KEY, + sync: { + before: _emberMetalProperty_events.beginPropertyChanges, + after: _emberMetalProperty_events.endPropertyChanges + }, + defaultQueue: 'actions', + onBegin: onBegin, + onEnd: onEnd, + onErrorTarget: onErrorTarget, + onErrorMethod: 'onerror' }); -}); -enifed('ember-views/index', ['exports', 'ember-views/system/ext', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/system/event_dispatcher', 'ember-views/component_lookup', 'ember-views/mixins/text_support', 'ember-views/views/core_view', 'ember-views/mixins/class_names_support', 'ember-views/mixins/child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/view_support', 'ember-views/mixins/action_support', 'ember-views/compat/attrs', 'ember-views/system/lookup_partial', 'ember-views/utils/lookup-component', 'ember-views/system/action_manager', 'ember-views/compat/fallback-view-registry'], function (exports, _emberViewsSystemExt, _emberViewsSystemJquery, _emberViewsSystemUtils, _emberViewsSystemEvent_dispatcher, _emberViewsComponent_lookup, _emberViewsMixinsText_support, _emberViewsViewsCore_view, _emberViewsMixinsClass_names_support, _emberViewsMixinsChild_views_support, _emberViewsMixinsView_state_support, _emberViewsMixinsView_support, _emberViewsMixinsAction_support, _emberViewsCompatAttrs, _emberViewsSystemLookup_partial, _emberViewsUtilsLookupComponent, _emberViewsSystemAction_manager, _emberViewsCompatFallbackViewRegistry) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; + // .......................................................... + // run - this is ideally the only public API the dev sees + // - exports.jQuery = _emberViewsSystemJquery.default; - exports.isSimpleClick = _emberViewsSystemUtils.isSimpleClick; - exports.getViewBounds = _emberViewsSystemUtils.getViewBounds; - exports.getViewClientRects = _emberViewsSystemUtils.getViewClientRects; - exports.getViewBoundingClientRect = _emberViewsSystemUtils.getViewBoundingClientRect; - exports.getRootViews = _emberViewsSystemUtils.getRootViews; - exports.getChildViews = _emberViewsSystemUtils.getChildViews; - exports.getViewId = _emberViewsSystemUtils.getViewId; - exports.getViewElement = _emberViewsSystemUtils.getViewElement; - exports.setViewElement = _emberViewsSystemUtils.setViewElement; - exports.STYLE_WARNING = _emberViewsSystemUtils.STYLE_WARNING; - exports.EventDispatcher = _emberViewsSystemEvent_dispatcher.default; - exports.ComponentLookup = _emberViewsComponent_lookup.default; - exports.TextSupport = _emberViewsMixinsText_support.default; - exports.CoreView = _emberViewsViewsCore_view.default; - exports.ClassNamesSupport = _emberViewsMixinsClass_names_support.default; - exports.ChildViewsSupport = _emberViewsMixinsChild_views_support.default; - exports.ViewStateSupport = _emberViewsMixinsView_state_support.default; - exports.ViewMixin = _emberViewsMixinsView_support.default; - exports.ActionSupport = _emberViewsMixinsAction_support.default; - exports.MUTABLE_CELL = _emberViewsCompatAttrs.MUTABLE_CELL; - exports.lookupPartial = _emberViewsSystemLookup_partial.default; - exports.hasPartial = _emberViewsSystemLookup_partial.hasPartial; - exports.lookupComponent = _emberViewsUtilsLookupComponent.default; - exports.ActionManager = _emberViewsSystemAction_manager.default; - exports.fallbackViewRegistry = _emberViewsCompatFallbackViewRegistry.default; -}); -// for the side effect of extending Ember.run.queues -enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/compat/attrs'], function (exports, _emberUtils, _emberMetal, _emberViewsCompatAttrs) { /** - @module ember - @submodule ember-views + Runs the passed target and method inside of a RunLoop, ensuring any + deferred actions including bindings and views updates are flushed at the + end. + + Normally you should not need to invoke this method yourself. However if + you are implementing raw event handlers when interfacing with other + libraries or plugins, you should probably wrap all of your code inside this + call. + + ```javascript + run(function() { + // code to be executed within a RunLoop + }); + ``` + + @class run + @namespace Ember + @static + @constructor + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Object} return value from invoking the passed function. + @public */ - 'use strict'; - - function validateAction(component, actionName) { - if (actionName && actionName[_emberViewsCompatAttrs.MUTABLE_CELL]) { - actionName = actionName.value; - } - return actionName; + function run() { + return backburner.run.apply(backburner, arguments); } /** - @class ActionSupport - @namespace Ember - @private - */ - exports.default = _emberMetal.Mixin.create({ - /** - Calls an action passed to a component. - For example a component for playing or pausing music may translate click events - into action notifications of "play" or "stop" depending on some internal state - of the component: - ```javascript - // app/components/play-button.js - export default Ember.Component.extend({ - click() { - if (this.get('isPlaying')) { - this.sendAction('play'); - } else { - this.sendAction('stop'); - } - } - }); - ``` - The actions "play" and "stop" must be passed to this `play-button` component: - ```handlebars - {{! app/templates/application.hbs }} - {{play-button play=(action "musicStarted") stop=(action "musicStopped")}} - ``` - When the component receives a browser `click` event it translate this - interaction into application-specific semantics ("play" or "stop") and - calls the specified action. - ```javascript - // app/controller/application.js - export default Ember.Controller.extend({ - actions: { - musicStarted() { - // called when the play button is clicked - // and the music started playing - }, - musicStopped() { - // called when the play button is clicked - // and the music stopped playing - } - } - }); - ``` - If no action is passed to `sendAction` a default name of "action" - is assumed. - ```javascript - // app/components/next-button.js - export default Ember.Component.extend({ - click() { - this.sendAction(); - } - }); - ``` - ```handlebars - {{! app/templates/application.hbs }} - {{next-button action=(action "playNextSongInAlbum")}} - ``` - ```javascript - // app/controllers/application.js - App.ApplicationController = Ember.Controller.extend({ - actions: { - playNextSongInAlbum() { - ... - } - } + If no run-loop is present, it creates a new one. If a run loop is + present it will queue itself to run on the existing run-loops action + queue. + + Please note: This is not for normal usage, and should be used sparingly. + + If invoked when not within a run loop: + + ```javascript + run.join(function() { + // creates a new run-loop + }); + ``` + + Alternatively, if called within an existing run loop: + + ```javascript + run(function() { + // creates a new run-loop + run.join(function() { + // joins with the existing run-loop, and queues for invocation on + // the existing run-loops action queue. }); - ``` - @method sendAction - @param [action] {String} the action to call - @param [params] {*} arguments for the action - @public - */ - sendAction: function (action) { - for (var _len = arguments.length, contexts = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - contexts[_key - 1] = arguments[_key]; - } - - var actionName = undefined; - - // Send the default action - if (action === undefined) { - action = 'action'; - } - actionName = _emberMetal.get(this, 'attrs.' + action) || _emberMetal.get(this, action); - actionName = validateAction(this, actionName); - - // If no action name for that action could be found, just abort. - if (actionName === undefined) { - return; - } + }); + ``` + + @method join + @namespace Ember + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Object} Return value from invoking the passed function. Please note, + when called within an existing loop, no return value is possible. + @public + */ + run.join = function () { + return backburner.join.apply(backburner, arguments); + }; - if (typeof actionName === 'function') { - actionName.apply(undefined, contexts); - } else { - this.triggerAction({ - action: actionName, - actionContext: contexts + /** + Allows you to specify which context to call the specified function in while + adding the execution of that function to the Ember run loop. This ability + makes this method a great way to asynchronously integrate third-party libraries + into your Ember application. + + `run.bind` takes two main arguments, the desired context and the function to + invoke in that context. Any additional arguments will be supplied as arguments + to the function that is passed in. + + Let's use the creation of a TinyMCE component as an example. Currently, + TinyMCE provides a setup configuration option we can use to do some processing + after the TinyMCE instance is initialized but before it is actually rendered. + We can use that setup option to do some additional setup for our component. + The component itself could look something like the following: + + ```javascript + App.RichTextEditorComponent = Ember.Component.extend({ + initializeTinyMCE: Ember.on('didInsertElement', function() { + tinymce.init({ + selector: '#' + this.$().prop('id'), + setup: Ember.run.bind(this, this.setupEditor) + }); + }), + + setupEditor: function(editor) { + this.set('editor', editor); + + editor.on('change', function() { + console.log('content changed!'); }); } - }, + }); + ``` + + In this example, we use Ember.run.bind to bind the setupEditor method to the + context of the App.RichTextEditorComponent and to have the invocation of that + method be safely handled and executed by the Ember run loop. + + @method bind + @namespace Ember + @param {Object} [target] target of method to call + @param {Function|String} method Method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Any additional arguments you wish to pass to the method. + @return {Function} returns a new function that will always have a particular context + @since 1.4.0 + @public + */ + run.bind = function () { + for (var _len = arguments.length, curried = Array(_len), _key = 0; _key < _len; _key++) { + curried[_key] = arguments[_key]; + } - send: function (actionName) { - for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - args[_key2 - 1] = arguments[_key2]; + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - var action = this.actions && this.actions[actionName]; + return run.join.apply(run, curried.concat(args)); + }; + }; - if (action) { - var shouldBubble = action.apply(this, args) === true; - if (!shouldBubble) { - return; - } - } + run.backburner = backburner; + run.currentRunLoop = null; + run.queues = backburner.queueNames; - var target = _emberMetal.get(this, 'target'); - if (target) { - target.send.apply(target, arguments); - } else {} - } - }); -}); -enifed('ember-views/mixins/child_views_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/system/utils'], function (exports, _emberUtils, _emberMetal, _emberViewsSystemUtils) { /** - @module ember - @submodule ember-views + Begins a new RunLoop. Any deferred actions invoked after the begin will + be buffered until you invoke a matching call to `run.end()`. This is + a lower-level way to use a RunLoop instead of using `run()`. + + ```javascript + run.begin(); + // code to be executed within a RunLoop + run.end(); + ``` + + @method begin + @return {void} + @public */ - 'use strict'; - - exports.default = _emberMetal.Mixin.create({ - init: function () { - this._super.apply(this, arguments); - _emberViewsSystemUtils.initChildViews(this); - }, + run.begin = function () { + backburner.begin(); + }; - /** - Array of child views. You should never edit this array directly. - @property childViews - @type Array - @default [] - @private - */ - childViews: _emberMetal.descriptor({ - configurable: false, - enumerable: false, - get: function () { - return _emberViewsSystemUtils.getChildViews(this); - } - }), + /** + Ends a RunLoop. This must be called sometime after you call + `run.begin()` to flush any deferred actions. This is a lower-level way + to use a RunLoop instead of using `run()`. + + ```javascript + run.begin(); + // code to be executed within a RunLoop + run.end(); + ``` + + @method end + @return {void} + @public + */ + run.end = function () { + backburner.end(); + }; - appendChild: function (view) { - this.linkChild(view); - _emberViewsSystemUtils.addChildView(this, view); - }, + /** + Array of named queues. This array determines the order in which queues + are flushed at the end of the RunLoop. You can define your own queues by + simply adding the queue name to this array. Normally you should not need + to inspect or modify this property. + + @property queues + @type Array + @default ['sync', 'actions', 'destroy'] + @private + */ - linkChild: function (instance) { - if (!_emberUtils.getOwner(instance)) { - _emberUtils.setOwner(instance, _emberUtils.getOwner(this)); - } - } - }); -}); -enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { /** - @module ember - @submodule ember-views + Adds the passed target/method and any optional arguments to the named + queue to be executed at the end of the RunLoop. If you have not already + started a RunLoop when calling this method one will be started for you + automatically. + + At the end of a RunLoop, any methods scheduled in this way will be invoked. + Methods will be invoked in an order matching the named queues defined in + the `run.queues` property. + + ```javascript + run.schedule('sync', this, function() { + // this will be executed in the first RunLoop queue, when bindings are synced + console.log('scheduled on sync queue'); + }); + + run.schedule('actions', this, function() { + // this will be executed in the 'actions' queue, after bindings have synced. + console.log('scheduled on actions queue'); + }); + + // Note the functions will be run in order based on the run queues order. + // Output would be: + // scheduled on sync queue + // scheduled on actions queue + ``` + + @method schedule + @param {String} queue The name of the queue to schedule against. + Default queues are 'sync' and 'actions' + @param {Object} [target] target object to use as the context when invoking a method. + @param {String|Function} method The method to invoke. If you pass a string it + will be resolved on the target object at the time the scheduled item is + invoked allowing you to change the target function. + @param {Object} [arguments*] Optional arguments to be passed to the queued method. + @return {*} Timer information for use in cancelling, see `run.cancel`. + @public */ + run.schedule = function () /* queue, target, method */{ - 'use strict'; + return backburner.schedule.apply(backburner, arguments); + }; - var EMPTY_ARRAY = Object.freeze([]); + // Used by global test teardown + run.hasScheduledTimers = function () { + return backburner.hasTimers(); + }; + + // Used by global test teardown + run.cancelTimers = function () { + backburner.cancelTimers(); + }; /** - @class ClassNamesSupport - @namespace Ember + Immediately flushes any events scheduled in the 'sync' queue. Bindings + use this queue so this method is a useful way to immediately force all + bindings in the application to sync. + + You should call this method anytime you need any changed state to propagate + throughout the app immediately without repainting the UI (which happens + in the later 'render' queue added by the `ember-views` package). + + ```javascript + run.sync(); + ``` + + @method sync + @return {void} @private */ - exports.default = _emberMetal.Mixin.create({ - concatenatedProperties: ['classNames', 'classNameBindings'], + run.sync = function () { + if (backburner.currentInstance) { + backburner.currentInstance.queues.sync.flush(); + } + }; - init: function () { - this._super.apply(this, arguments); - }, + /** + Invokes the passed target/method and optional arguments after a specified + period of time. The last parameter of this method must always be a number + of milliseconds. + + You should use this method whenever you need to run some action after a + period of time instead of using `setTimeout()`. This method will ensure that + items that expire during the same script execution cycle all execute + together, which is often more efficient than using a real setTimeout. + + ```javascript + run.later(myContext, function() { + // code here will execute within a RunLoop in about 500ms with this == myContext + }, 500); + ``` + + @method later + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} wait Number of milliseconds to wait. + @return {*} Timer information for use in cancelling, see `run.cancel`. + @public + */ + run.later = function () /*target, method*/{ + return backburner.later.apply(backburner, arguments); + }; - /** - Standard CSS class names to apply to the view's outer element. This - property automatically inherits any class names defined by the view's - superclasses as well. - @property classNames - @type Array - @default ['ember-view'] - @public - */ - classNames: EMPTY_ARRAY, + /** + Schedule a function to run one time during the current RunLoop. This is equivalent + to calling `scheduleOnce` with the "actions" queue. + + @method once + @param {Object} [target] The target of the method to invoke. + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. + @public + */ + run.once = function () { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } - /** - A list of properties of the view to apply as class names. If the property - is a string value, the value of that string will be applied as a class - name. - ```javascript - // Applies the 'high' class to the view element - Ember.Component.extend({ - classNameBindings: ['priority'], - priority: 'high' - }); - ``` - If the value of the property is a Boolean, the name of that property is - added as a dasherized class name. - ```javascript - // Applies the 'is-urgent' class to the view element - Ember.Component.extend({ - classNameBindings: ['isUrgent'], - isUrgent: true - }); - ``` - If you would prefer to use a custom value instead of the dasherized - property name, you can pass a binding like this: - ```javascript - // Applies the 'urgent' class to the view element - Ember.Component.extend({ - classNameBindings: ['isUrgent:urgent'], - isUrgent: true + args.unshift('actions'); + return backburner.scheduleOnce.apply(backburner, args); + }; + + /** + Schedules a function to run one time in a given queue of the current RunLoop. + Calling this method with the same queue/target/method combination will have + no effect (past the initial call). + + Note that although you can pass optional arguments these will not be + considered when looking for duplicates. New arguments will replace previous + calls. + + ```javascript + function sayHi() { + console.log('hi'); + } + + run(function() { + run.scheduleOnce('afterRender', myContext, sayHi); + run.scheduleOnce('afterRender', myContext, sayHi); + // sayHi will only be executed once, in the afterRender queue of the RunLoop + }); + ``` + + Also note that passing an anonymous function to `run.scheduleOnce` will + not prevent additional calls with an identical anonymous function from + scheduling the items multiple times, e.g.: + + ```javascript + function scheduleIt() { + run.scheduleOnce('actions', myContext, function() { + console.log('Closure'); }); - ``` - This list of properties is inherited from the component's superclasses as well. - @property classNameBindings - @type Array - @default [] - @public - */ - classNameBindings: EMPTY_ARRAY - }); -}); -enifed('ember-views/mixins/text_support', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + } + + scheduleIt(); + scheduleIt(); + + // "Closure" will print twice, even though we're using `run.scheduleOnce`, + // because the function we pass to it is anonymous and won't match the + // previously scheduled operation. + ``` + + Available queues, and their order, can be found at `run.queues` + + @method scheduleOnce + @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'. + @param {Object} [target] The target of the method to invoke. + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. + @public + */ + run.scheduleOnce = function () /*queue, target, method*/{ + return backburner.scheduleOnce.apply(backburner, arguments); + }; + /** - @module ember - @submodule ember-views + Schedules an item to run from within a separate run loop, after + control has been returned to the system. This is equivalent to calling + `run.later` with a wait time of 1ms. + + ```javascript + run.next(myContext, function() { + // code to be executed in the next run loop, + // which will be scheduled after the current one + }); + ``` + + Multiple operations scheduled with `run.next` will coalesce + into the same later run loop, along with any other operations + scheduled by `run.later` that expire right around the same + time that `run.next` operations will fire. + + Note that there are often alternatives to using `run.next`. + For instance, if you'd like to schedule an operation to happen + after all DOM element operations have completed within the current + run loop, you can make use of the `afterRender` run loop queue (added + by the `ember-views` package, along with the preceding `render` queue + where all the DOM element operations happen). + + Example: + + ```javascript + export default Ember.Component.extend({ + didInsertElement() { + this._super(...arguments); + run.scheduleOnce('afterRender', this, 'processChildElements'); + }, + + processChildElements() { + // ... do something with component's child component + // elements after they've finished rendering, which + // can't be done within this component's + // `didInsertElement` hook because that gets run + // before the child elements have been added to the DOM. + } + }); + ``` + + One benefit of the above approach compared to using `run.next` is + that you will be able to perform DOM/CSS operations before unprocessed + elements are rendered to the screen, which may prevent flickering or + other artifacts caused by delaying processing until after rendering. + + The other major benefit to the above approach is that `run.next` + introduces an element of non-determinism, which can make things much + harder to test, due to its reliance on `setTimeout`; it's much harder + to guarantee the order of scheduled operations when they are scheduled + outside of the current run loop, i.e. with `run.next`. + + @method next + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + If you pass a string it will be resolved on the + target at the time the method is invoked. + @param {Object} [args*] Optional arguments to pass to the timeout. + @return {Object} Timer information for use in cancelling, see `run.cancel`. + @public */ + run.next = function () { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } - 'use strict'; + args.push(1); + return backburner.later.apply(backburner, args); + }; - var KEY_EVENTS = { - 13: 'insertNewline', - 27: 'cancel' + /** + Cancels a scheduled item. Must be a value returned by `run.later()`, + `run.once()`, `run.scheduleOnce()`, `run.next()`, `run.debounce()`, or + `run.throttle()`. + + ```javascript + let runNext = run.next(myContext, function() { + // will not be executed + }); + + run.cancel(runNext); + + let runLater = run.later(myContext, function() { + // will not be executed + }, 500); + + run.cancel(runLater); + + let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { + // will not be executed + }); + + run.cancel(runScheduleOnce); + + let runOnce = run.once(myContext, function() { + // will not be executed + }); + + run.cancel(runOnce); + + let throttle = run.throttle(myContext, function() { + // will not be executed + }, 1, false); + + run.cancel(throttle); + + let debounce = run.debounce(myContext, function() { + // will not be executed + }, 1); + + run.cancel(debounce); + + let debounceImmediate = run.debounce(myContext, function() { + // will be executed since we passed in true (immediate) + }, 100, true); + + // the 100ms delay until this method can be called again will be cancelled + run.cancel(debounceImmediate); + ``` + + @method cancel + @param {Object} timer Timer object to cancel + @return {Boolean} true if cancelled or false/undefined if it wasn't found + @public + */ + run.cancel = function (timer) { + return backburner.cancel(timer); }; /** - `TextSupport` is a shared mixin used by both `Ember.TextField` and - `Ember.TextArea`. `TextSupport` adds a number of methods that allow you to - specify a controller action to invoke when a certain event is fired on your - text field or textarea. The specifed controller action would get the current - value of the field passed in as the only argument unless the value of - the field is empty. In that case, the instance of the field itself is passed - in as the only argument. + Delay calling the target method until the debounce period has elapsed + with no additional debounce calls. If `debounce` is called again before + the specified time has elapsed, the timer is reset and the entire period + must pass again before the target method is called. - Let's use the pressing of the escape key as an example. If you wanted to - invoke a controller action when a user presses the escape key while on your - field, you would use the `escape-press` attribute on your field like so: + This method should be used when an event may be called multiple times + but the action should only be called once when the event is done firing. + A common example is for scroll events where you only want updates to + happen once scrolling has ceased. - ```handlebars - {{! application.hbs}} + ```javascript + function whoRan() { + console.log(this.name + ' ran.'); + } - {{input escape-press='alertUser'}} + let myContext = { name: 'debounce' }; + + run.debounce(myContext, whoRan, 150); + + // less than 150ms passes + run.debounce(myContext, whoRan, 150); + + // 150ms passes + // whoRan is invoked with context myContext + // console logs 'debounce ran.' one time. ``` + Immediate allows you to run the function immediately, but debounce + other calls for this function until the wait time has elapsed. If + `debounce` is called again before the specified time has elapsed, + the timer is reset and the entire period must pass again before + the method can be called again. + ```javascript - App = Ember.Application.create(); + function whoRan() { + console.log(this.name + ' ran.'); + } - App.ApplicationController = Ember.Controller.extend({ - actions: { - alertUser: function ( currentValue ) { - alert( 'escape pressed, current value: ' + currentValue ); - } - } - }); - ``` + let myContext = { name: 'debounce' }; - The following chart is a visual representation of what takes place when the - escape key is pressed in this scenario: + run.debounce(myContext, whoRan, 150, true); - ``` - The Template - +---------------------------+ - | | - | escape-press='alertUser' | - | | TextSupport Mixin - +----+----------------------+ +-------------------------------+ - | | cancel method | - | escape button pressed | | - +-------------------------------> | checks for the `escape-press` | - | attribute and pulls out the | - +-------------------------------+ | `alertUser` value | - | action name 'alertUser' +-------------------------------+ - | sent to controller - v - Controller - +------------------------------------------ + - | | - | actions: { | - | alertUser: function( currentValue ){ | - | alert( 'the esc key was pressed!' ) | - | } | - | } | - | | - +-------------------------------------------+ - ``` + // console logs 'debounce ran.' one time immediately. + // 100ms passes + run.debounce(myContext, whoRan, 150, true); - Here are the events that we currently support along with the name of the - attribute you would need to use on your field. To reiterate, you would use the - attribute name like so: + // 150ms passes and nothing else is logged to the console and + // the debouncee is no longer being watched + run.debounce(myContext, whoRan, 150, true); - ```handlebars - {{input attribute-name='controllerAction'}} - ``` + // console logs 'debounce ran.' one time immediately. + // 150ms passes and nothing else is logged to the console and + // the debouncee is no longer being watched - ``` - +--------------------+----------------+ - | | | - | event | attribute name | - +--------------------+----------------+ - | new line inserted | insert-newline | - | | | - | enter key pressed | insert-newline | - | | | - | cancel key pressed | escape-press | - | | | - | focusin | focus-in | - | | | - | focusout | focus-out | - | | | - | keypress | key-press | - | | | - | keyup | key-up | - | | | - | keydown | key-down | - +--------------------+----------------+ ``` - @class TextSupport - @namespace Ember - @uses Ember.TargetActionSupport - @extends Ember.Mixin - @private + @method debounce + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} wait Number of milliseconds to wait. + @param {Boolean} immediate Trigger the function on the leading instead + of the trailing edge of the wait interval. Defaults to false. + @return {Array} Timer information for use in cancelling, see `run.cancel`. + @public */ - exports.default = _emberMetal.Mixin.create(_emberRuntime.TargetActionSupport, { - value: '', + run.debounce = function () { + return backburner.debounce.apply(backburner, arguments); + }; - attributeBindings: ['autocapitalize', 'autocorrect', 'autofocus', 'disabled', 'form', 'maxlength', 'placeholder', 'readonly', 'required', 'selectionDirection', 'spellcheck', 'tabindex', 'title'], - placeholder: null, - disabled: false, - maxlength: null, + /** + Ensure that the target method is never called more frequently than + the specified spacing period. The target method is called immediately. + + ```javascript + function whoRan() { + console.log(this.name + ' ran.'); + } + + let myContext = { name: 'throttle' }; + + run.throttle(myContext, whoRan, 150); + // whoRan is invoked with context myContext + // console logs 'throttle ran.' + + // 50ms passes + run.throttle(myContext, whoRan, 150); + + // 50ms passes + run.throttle(myContext, whoRan, 150); + + // 150ms passes + run.throttle(myContext, whoRan, 150); + // whoRan is invoked with context myContext + // console logs 'throttle ran.' + ``` + + @method throttle + @param {Object} [target] target of method to invoke + @param {Function|String} method The method to invoke. + May be a function or a string. If you pass a string + then it will be looked up on the passed target. + @param {Object} [args*] Optional arguments to pass to the timeout. + @param {Number} spacing Number of milliseconds to space out requests. + @param {Boolean} immediate Trigger the function on the leading instead + of the trailing edge of the wait interval. Defaults to true. + @return {Array} Timer information for use in cancelling, see `run.cancel`. + @public + */ + run.throttle = function () { + return backburner.throttle.apply(backburner, arguments); + }; - init: function () { - this._super.apply(this, arguments); - this.on('paste', this, this._elementValueDidChange); - this.on('cut', this, this._elementValueDidChange); - this.on('input', this, this._elementValueDidChange); - }, + /** + Add a new named queue after the specified queue. + + The queue to add will only be added once. + + @method _addQueue + @param {String} name the name of the queue to add. + @param {String} after the name of the queue to add after. + @private + */ + run._addQueue = function (name, after) { + if (run.queues.indexOf(name) === -1) { + run.queues.splice(run.queues.indexOf(after) + 1, 0, name); + } + }; +}); +enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set'], function (exports, _emberMetalProperty_events, _emberMetalProperty_set) { + 'use strict'; - /** - The action to be sent when the user presses the return key. - This is similar to the `{{action}}` helper, but is fired when - the user presses the return key when editing a text field, and sends - the value of the field as the context. - @property action - @type String - @default null - @private - */ - action: null, + exports.default = setProperties; - /** - The event that should send the action. - Options are: - * `enter`: the user pressed enter - * `keyPress`: the user pressed a key - @property onEvent - @type String - @default enter - @private - */ - onEvent: 'enter', + /** + Set a list of properties on an object. These properties are set inside + a single `beginPropertyChanges` and `endPropertyChanges` batch, so + observers will be buffered. + + ```javascript + let anObject = Ember.Object.create(); + + anObject.setProperties({ + firstName: 'Stanley', + lastName: 'Stuart', + age: 21 + }); + ``` + + @method setProperties + @param obj + @param {Object} properties + @return properties + @public + */ - /** - Whether the `keyUp` event that triggers an `action` to be sent continues - propagating to other views. - By default, when the user presses the return key on their keyboard and - the text field has an `action` set, the action will be sent to the view's - controller and the key event will stop propagating. - If you would like parent views to receive the `keyUp` event even after an - action has been dispatched, set `bubbles` to true. - @property bubbles - @type Boolean - @default false - @private - */ - bubbles: false, + function setProperties(obj, properties) { + if (!properties || typeof properties !== 'object') { + return properties; + } + _emberMetalProperty_events.changeProperties(function () { + var props = Object.keys(properties); + var propertyName = undefined; - interpretKeyEvents: function (event) { - var map = KEY_EVENTS; - var method = map[event.keyCode]; + for (var i = 0; i < props.length; i++) { + propertyName = props[i]; - this._elementValueDidChange(); - if (method) { - return this[method](event); + _emberMetalProperty_set.set(obj, propertyName, properties[propertyName]); } - }, + }); + return properties; + } +}); +enifed('ember-metal/tags', ['exports', '@glimmer/reference', 'ember-metal/meta', 'require', 'ember-metal/is_proxy'], function (exports, _glimmerReference, _emberMetalMeta, _require, _emberMetalIs_proxy) { + 'use strict'; - _elementValueDidChange: function () { - _emberMetal.set(this, 'value', this.element.value); - }, + exports.setHasViews = setHasViews; + exports.tagForProperty = tagForProperty; + exports.tagFor = tagFor; + exports.markObjectAsDirty = markObjectAsDirty; - change: function (event) { - this._elementValueDidChange(event); - }, + var hasViews = function () { + return false; + }; - /** - Allows you to specify a controller action to invoke when either the `enter` - key is pressed or, in the case of the field being a textarea, when a newline - is inserted. To use this method, give your field an `insert-newline` - attribute. The value of that attribute should be the name of the action - in your controller that you wish to invoke. - For an example on how to use the `insert-newline` attribute, please - reference the example near the top of this file. - @method insertNewline - @param {Event} event - @private - */ - insertNewline: function (event) { - sendAction('enter', this, event); - sendAction('insert-newline', this, event); - }, + function setHasViews(fn) { + hasViews = fn; + } - /** - Allows you to specify a controller action to invoke when the escape button - is pressed. To use this method, give your field an `escape-press` - attribute. The value of that attribute should be the name of the action - in your controller that you wish to invoke. - For an example on how to use the `escape-press` attribute, please reference - the example near the top of this file. - @method cancel - @param {Event} event - @private - */ - cancel: function (event) { - sendAction('escape-press', this, event); - }, + function makeTag() { + return new _glimmerReference.DirtyableTag(); + } - /** - Allows you to specify a controller action to invoke when a field receives - focus. To use this method, give your field a `focus-in` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `focus-in` attribute, please reference the - example near the top of this file. - @method focusIn - @param {Event} event - @private - */ - focusIn: function (event) { - sendAction('focus-in', this, event); - }, + function tagForProperty(object, propertyKey, _meta) { + if (_emberMetalIs_proxy.isProxy(object)) { + return tagFor(object, _meta); + } - /** - Allows you to specify a controller action to invoke when a field loses - focus. To use this method, give your field a `focus-out` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `focus-out` attribute, please reference the - example near the top of this file. - @method focusOut - @param {Event} event - @private - */ - focusOut: function (event) { - this._elementValueDidChange(event); - sendAction('focus-out', this, event); - }, + if (typeof object === 'object' && object) { + var meta = _meta || _emberMetalMeta.meta(object); + var tags = meta.writableTags(); + var tag = tags[propertyKey]; + if (tag) { + return tag; + } - /** - Allows you to specify a controller action to invoke when a key is pressed. - To use this method, give your field a `key-press` attribute. The value of - that attribute should be the name of the action in your controller you - that wish to invoke. - For an example on how to use the `key-press` attribute, please reference the - example near the top of this file. - @method keyPress - @param {Event} event - @private - */ - keyPress: function (event) { - sendAction('key-press', this, event); - }, + return tags[propertyKey] = makeTag(); + } else { + return _glimmerReference.CONSTANT_TAG; + } + } - /** - Allows you to specify a controller action to invoke when a key-up event is - fired. To use this method, give your field a `key-up` attribute. The value - of that attribute should be the name of the action in your controller - that you wish to invoke. - For an example on how to use the `key-up` attribute, please reference the - example near the top of this file. - @method keyUp - @param {Event} event - @private - */ - keyUp: function (event) { - this.interpretKeyEvents(event); + function tagFor(object, _meta) { + if (typeof object === 'object' && object) { + var meta = _meta || _emberMetalMeta.meta(object); + return meta.writableTag(makeTag); + } else { + return _glimmerReference.CONSTANT_TAG; + } + } - this.sendAction('key-up', _emberMetal.get(this, 'value'), event); - }, + function markObjectAsDirty(meta, propertyKey) { + var objectTag = meta && meta.readableTag(); - /** - Allows you to specify a controller action to invoke when a key-down event is - fired. To use this method, give your field a `key-down` attribute. The value - of that attribute should be the name of the action in your controller that - you wish to invoke. - For an example on how to use the `key-down` attribute, please reference the - example near the top of this file. - @method keyDown - @param {Event} event - @private - */ - keyDown: function (event) { - this.sendAction('key-down', _emberMetal.get(this, 'value'), event); + if (objectTag) { + objectTag.dirty(); } - }); - // In principle, this shouldn't be necessary, but the legacy - // sendAction semantics for TextField are different from - // the component semantics so this method normalizes them. - function sendAction(eventName, view, event) { - var action = _emberMetal.get(view, 'attrs.' + eventName) || _emberMetal.get(view, eventName); - var on = _emberMetal.get(view, 'onEvent'); - var value = _emberMetal.get(view, 'value'); + var tags = meta && meta.readableTags(); + var propertyTag = tags && tags[propertyKey]; - // back-compat support for keyPress as an event name even though - // it's also a method name that consumes the event (and therefore - // incompatible with sendAction semantics). - if (on === eventName || on === 'keyPress' && eventName === 'key-press') { - view.sendAction('action', value); + if (propertyTag) { + propertyTag.dirty(); } - view.sendAction(eventName, value); + if (objectTag || propertyTag) { + ensureRunloop(); + } + } - if (action || on === eventName) { - if (!_emberMetal.get(view, 'bubbles')) { - event.stopPropagation(); - } + var run = undefined; + + function K() {} + + function ensureRunloop() { + if (!run) { + run = _require.default('ember-metal/run_loop').default; + } + + if (hasViews() && !run.backburner.currentInstance) { + run.schedule('actions', K); } } }); -enifed('ember-views/mixins/view_state_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { - /** - @module ember - @submodule ember-views - */ - 'use strict'; +enifed("ember-metal/testing", ["exports"], function (exports) { + "use strict"; - exports.default = _emberMetal.Mixin.create({ - _transitionTo: function (state) { - var priorState = this._currentState; - var currentState = this._currentState = this._states[state]; - this._state = state; + exports.isTesting = isTesting; + exports.setTesting = setTesting; + var testing = false; - if (priorState && priorState.exit) { - priorState.exit(this); - } - if (currentState.enter) { - currentState.enter(this); - } - } - }); + function isTesting() { + return testing; + } + + function setTesting(value) { + testing = !!value; + } }); -enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-views/system/utils', 'ember-runtime/system/core_object', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberViewsSystemUtils, _emberRuntimeSystemCore_object, _emberViewsSystemJquery) { +enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) { 'use strict'; - var _Mixin$create; - - function K() { - return this; - } + var runInTransaction = undefined, + didRender = undefined, + assertNotRendered = undefined; - /** - @class ViewMixin - @namespace Ember - @private - */ - exports.default = _emberMetal.Mixin.create((_Mixin$create = { - concatenatedProperties: ['attributeBindings'] - }, _Mixin$create[_emberRuntimeSystemCore_object.POST_INIT] = function () { - this.trigger('didInitAttrs', { attrs: this.attrs }); - this.trigger('didReceiveAttrs', { newAttrs: this.attrs }); - }, _Mixin$create.nearestOfType = function (klass) { - var view = this.parentView; - var isOfType = klass instanceof _emberMetal.Mixin ? function (view) { - return klass.detect(view); - } : function (view) { - return klass.detect(view.constructor); - }; + // detect-backtracking-rerender by default is debug build only + // detect-glimmer-allow-backtracking-rerender can be enabled in custom builds + if (false || false) { + (function () { + var counter = 0; + var inTransaction = false; + var shouldReflush = undefined; + var debugStack = undefined; - while (view) { - if (isOfType(view)) { - return view; - } - view = view.parentView; - } - }, _Mixin$create.nearestWithProperty = function (property) { - var view = this.parentView; + exports.default = runInTransaction = function (context, methodName) { + shouldReflush = false; + inTransaction = true; - while (view) { - if (property in view) { - return view; - } - view = view.parentView; - } - }, _Mixin$create.rerender = function () { - return this._currentState.rerender(this); - }, _Mixin$create.element = _emberMetal.descriptor({ - configurable: false, - enumerable: false, - get: function () { - return this.renderer.getElement(this); - } - }), _Mixin$create.$ = function (sel) { - return this._currentState.$(this, sel); - }, _Mixin$create.appendTo = function (selector) { - var env = this._environment || _emberEnvironment.environment; - var target = undefined; + context[methodName](); + inTransaction = false; + counter++; + return shouldReflush; + }; - if (env.hasDOM) { - target = typeof selector === 'string' ? document.querySelector(selector) : selector; - } else { - target = selector; - } + exports.didRender = didRender = function (object, key, reference) { + if (!inTransaction) { + return; + } + var meta = _emberMetalMeta.meta(object); + var lastRendered = meta.writableLastRendered(); + lastRendered[key] = counter; + }; - this.renderer.appendTo(this, target); + exports.assertNotRendered = assertNotRendered = function (object, key, _meta) { + var meta = _meta || _emberMetalMeta.meta(object); + var lastRendered = meta.readableLastRendered(); - return this; - }, _Mixin$create.renderToElement = function (tagName) { - tagName = tagName || 'body'; + if (lastRendered && lastRendered[key] === counter) { - var element = this.renderer.createElement(tagName); + shouldReflush = true; + } + }; + })(); + } else { + // in production do nothing to detect reflushes + exports.default = runInTransaction = function (context, methodName) { + context[methodName](); + return false; + }; + } - this.renderer.appendTo(this, element); - return element; - }, _Mixin$create.replaceIn = function (selector) { - var target = _emberViewsSystemJquery.default(selector); + exports.default = runInTransaction; + exports.didRender = didRender; + exports.assertNotRendered = assertNotRendered; +}); +enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) { + 'use strict'; - this.renderer.replaceIn(this, target[0]); + exports.watchKey = watchKey; + exports.unwatchKey = unwatchKey; - return this; - }, _Mixin$create.append = function () { - return this.appendTo(document.body); - }, _Mixin$create.elementId = null, _Mixin$create.findElementInParentElement = function (parentElem) { - var id = '#' + this.elementId; - return _emberViewsSystemJquery.default(id)[0] || _emberViewsSystemJquery.default(id, parentElem)[0]; - }, _Mixin$create.willInsertElement = K, _Mixin$create.didInsertElement = K, _Mixin$create.willClearRender = K, _Mixin$create.destroy = function () { - this._super.apply(this, arguments); - this._currentState.destroy(this); - }, _Mixin$create.willDestroyElement = K, _Mixin$create.parentViewDidChange = K, _Mixin$create.tagName = null, _Mixin$create.init = function () { - this._super.apply(this, arguments); + var handleMandatorySetter = undefined; - if (!this.elementId && this.tagName !== '') { - this.elementId = _emberUtils.guidFor(this); + function watchKey(obj, keyName, meta) { + if (typeof obj !== 'object' || obj === null) { + return; } - }, _Mixin$create.__defineNonEnumerable = function (property) { - this[property.name] = property.descriptor.value; - }, _Mixin$create.handleEvent = function (eventName, evt) { - return this._currentState.handleEvent(this, eventName, evt); - }, _Mixin$create)); -}); + var m = meta || _emberMetalMeta.meta(obj); -// .......................................................... -// TEMPLATE SUPPORT -// + // activate watching first time + if (!m.peekWatching(keyName)) { + m.writeWatching(keyName, 1); -/** - Return the nearest ancestor that is an instance of the provided - class or mixin. - @method nearestOfType - @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself), - or an instance of Ember.Mixin. - @return Ember.View - @deprecated use `yield` and contextual components for composition instead. - @private -*/ + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + if (desc && desc.willWatch) { + desc.willWatch(obj, keyName); + } -/** - Return the nearest ancestor that has a given property. - @method nearestWithProperty - @param {String} property A property name - @return Ember.View - @deprecated use `yield` and contextual components for composition instead. - @private -*/ + if ('function' === typeof obj.willWatchProperty) { + obj.willWatchProperty(keyName); + } -/** - Renders the view again. This will work regardless of whether the - view is already in the DOM or not. If the view is in the DOM, the - rendering process will be deferred to give bindings a chance - to synchronize. - If children were added during the rendering process using `appendChild`, - `rerender` will remove them, because they will be added again - if needed by the next `render`. - In general, if the display of your view changes, you should modify - the DOM element directly instead of manually calling `rerender`, which can - be slow. - @method rerender - @public -*/ + if (false) { + // NOTE: this is dropped for prod + minified builds + handleMandatorySetter(m, obj, keyName); + } + } else { + m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1); + } + } -// .......................................................... -// ELEMENT SUPPORT -// + if (false) { + (function () { + var hasOwnProperty = function (obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + }; -/** - Returns the current DOM element for the view. - @property element - @type DOMElement - @public -*/ + var propertyIsEnumerable = function (obj, key) { + return Object.prototype.propertyIsEnumerable.call(obj, key); + }; -/** - Returns a jQuery object for this view's element. If you pass in a selector - string, this method will return a jQuery object, using the current element - as its buffer. - For example, calling `view.$('li')` will return a jQuery object containing - all of the `li` elements inside the DOM element of this view. - @method $ - @param {String} [selector] a jQuery-compatible selector string - @return {jQuery} the jQuery object for the DOM node - @public -*/ + // Future traveler, although this code looks scary. It merely exists in + // development to aid in development asertions. Production builds of + // ember strip this entire block out + handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { + var descriptor = _emberUtils.lookupDescriptor(obj, keyName); + var configurable = descriptor ? descriptor.configurable : true; + var isWritable = descriptor ? descriptor.writable : true; + var hasValue = descriptor ? 'value' in descriptor : true; + var possibleDesc = descriptor && descriptor.value; + var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; -/** - Appends the view's element to the specified parent element. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the given element until all bindings have - finished synchronizing. - This is not typically a function that you will need to call directly when - building your application. If you do need to use `appendTo`, be sure that - the target element you are providing is associated with an `Ember.Application` - and does not have an ancestor element that is associated with an Ember view. - @method appendTo - @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object - @return {Ember.View} receiver - @private -*/ + if (isDescriptor) { + return; + } -/** - Creates a new DOM element, renders the view into it, then returns the - element. - By default, the element created and rendered into will be a `BODY` element, - since this is the default context that views are rendered into when being - inserted directly into the DOM. - ```js - let element = view.renderToElement(); - element.tagName; // => "BODY" - ``` - You can override the kind of element rendered into and returned by - specifying an optional tag name as the first argument. - ```js - let element = view.renderToElement('table'); - element.tagName; // => "TABLE" - ``` - This method is useful if you want to render the view into an element that - is not in the document's body. Instead, a new `body` element, detached from - the DOM is returned. FastBoot uses this to serialize the rendered view into - a string for transmission over the network. - ```js - app.visit('/').then(function(instance) { - let element; - Ember.run(function() { - element = renderToElement(instance); - }); - res.send(serialize(element)); - }); - ``` - @method renderToElement - @param {String} tagName The tag of the element to create and render into. Defaults to "body". - @return {HTMLBodyElement} element - @deprecated Use appendTo instead. - @private -*/ + // this x in Y deopts, so keeping it in this function is better; + if (configurable && isWritable && hasValue && keyName in obj) { + var desc = { + configurable: true, + set: _emberMetalProperties.MANDATORY_SETTER_FUNCTION(keyName), + enumerable: propertyIsEnumerable(obj, keyName), + get: undefined + }; -/** - Replaces the content of the specified parent element with this view's - element. If the view does not have an HTML representation yet, - the element will be generated automatically. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the given element until all bindings have - finished synchronizing - @method replaceIn - @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object - @return {Ember.View} received - @private -*/ + if (hasOwnProperty(obj, keyName)) { + m.writeValues(keyName, obj[keyName]); + desc.get = _emberMetalProperties.DEFAULT_GETTER_FUNCTION(keyName); + } else { + desc.get = _emberMetalProperties.INHERITING_GETTER_FUNCTION(keyName); + } -/** - Appends the view's element to the document body. If the view does - not have an HTML representation yet - the element will be generated automatically. - If your application uses the `rootElement` property, you must append - the view within that element. Rendering views outside of the `rootElement` - is not supported. - Note that this method just schedules the view to be appended; the DOM - element will not be appended to the document body until all bindings have - finished synchronizing. - @method append - @return {Ember.View} receiver - @private -*/ + Object.defineProperty(obj, keyName, desc); + } + }; + })(); + } -/** - The HTML `id` of the view's element in the DOM. You can provide this - value yourself but it must be unique (just as in HTML): - ```handlebars - {{my-component elementId="a-really-cool-id"}} - ``` - If not manually set a default value will be provided by the framework. - Once rendered an element's `elementId` is considered immutable and you - should never change it. If you need to compute a dynamic value for the - `elementId`, you should do this when the component or element is being - instantiated: - ```javascript - export default Ember.Component.extend({ - init() { - this._super(...arguments); - let index = this.get('index'); - this.set('elementId', 'component-id' + index); - } - }); - ``` - @property elementId - @type String - @public -*/ + function unwatchKey(obj, keyName, _meta) { + if (typeof obj !== 'object' || obj === null) { + return; + } + var meta = _meta || _emberMetalMeta.meta(obj); -/** - Attempts to discover the element in the parent element. The default - implementation looks for an element with an ID of `elementId` (or the - view's guid if `elementId` is null). You can override this method to - provide your own form of lookup. For example, if you want to discover your - element using a CSS class name instead of an ID. - @method findElementInParentElement - @param {DOMElement} parentElement The parent's DOM element - @return {DOMElement} The discovered element - @private -*/ + // do nothing of this object has already been destroyed + if (meta.isSourceDestroyed()) { + return; + } -/** - Called when a view is going to insert an element into the DOM. - @event willInsertElement - @public -*/ + var count = meta.peekWatching(keyName); + if (count === 1) { + meta.writeWatching(keyName, 0); -/** - Called when the element of the view has been inserted into the DOM. - Override this function to do any set up that requires an element - in the document body. - When a view has children, didInsertElement will be called on the - child view(s) first and on itself afterwards. - @event didInsertElement - @public -*/ + var possibleDesc = obj[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; -/** - Called when the view is about to rerender, but before anything has - been torn down. This is a good opportunity to tear down any manual - observers you have installed based on the DOM state - @event willClearRender - @public -*/ + if (desc && desc.didUnwatch) { + desc.didUnwatch(obj, keyName); + } -/** - You must call `destroy` on a view to destroy the view (and all of its - child views). This will remove the view from any parent node, then make - sure that the DOM element managed by the view can be released by the - memory manager. - @method destroy - @private -*/ + if ('function' === typeof obj.didUnwatchProperty) { + obj.didUnwatchProperty(keyName); + } -/** - Called when the element of the view is going to be destroyed. Override - this function to do any teardown that requires an element, like removing - event listeners. - Please note: any property changes made during this event will have no - effect on object observers. - @event willDestroyElement - @public -*/ + if (false) { + // It is true, the following code looks quite WAT. But have no fear, It + // exists purely to improve development ergonomics and is removed from + // ember.min.js and ember.prod.js builds. + // + // Some further context: Once a property is watched by ember, bypassing `set` + // for mutation, will bypass observation. This code exists to assert when + // that occurs, and attempt to provide more helpful feedback. The alternative + // is tricky to debug partially observable properties. + if (!desc && keyName in obj) { + var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName); -/** - Called when the parentView property has changed. - @event parentViewDidChange - @private -*/ + if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { + if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { + var possibleValue = meta.readInheritedValue('values', keyName); + if (possibleValue === _emberMetalMeta.UNDEFINED) { + delete obj[keyName]; + return; + } + } -// .......................................................... -// STANDARD RENDER PROPERTIES -// + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), + writable: true, + value: meta.peekValues(keyName) + }); + meta.deleteFromValues(keyName); + } + } + } + } else if (count > 1) { + meta.writeWatching(keyName, count - 1); + } + } +}); +enifed('ember-metal/watch_path', ['exports', 'ember-metal/meta', 'ember-metal/chains'], function (exports, _emberMetalMeta, _emberMetalChains) { + 'use strict'; -/** - Tag name for the view's outer element. The tag name is only used when an - element is first created. If you change the `tagName` for an element, you - must destroy and recreate the view element. - By default, the render buffer will use a `
    ` tag for views. - @property tagName - @type String - @default null - @public -*/ + exports.makeChainNode = makeChainNode; + exports.watchPath = watchPath; + exports.unwatchPath = unwatchPath; -// We leave this null by default so we can tell the difference between -// the default case and a user-specified tag. + // get the chains for the current object. If the current object has + // chains inherited from the proto they will be cloned and reconfigured for + // the current object. + function chainsFor(obj, meta) { + return (meta || _emberMetalMeta.meta(obj)).writableChains(makeChainNode); + } -// ....................................................... -// CORE DISPLAY METHODS -// + function makeChainNode(obj) { + return new _emberMetalChains.ChainNode(null, null, obj); + } -/** - Setup a view, but do not finish waking it up. - * configure `childViews` - * register the view with the global views hash, which is used for event - dispatch - @method init - @private -*/ + function watchPath(obj, keyPath, meta) { + if (typeof obj !== 'object' || obj === null) { + return; + } + var m = meta || _emberMetalMeta.meta(obj); + var counter = m.peekWatching(keyPath) || 0; + if (!counter) { + // activate watching first time + m.writeWatching(keyPath, 1); + chainsFor(obj, m).add(keyPath); + } else { + m.writeWatching(keyPath, counter + 1); + } + } -// ....................................................... -// EVENT HANDLING -// + function unwatchPath(obj, keyPath, meta) { + if (typeof obj !== 'object' || obj === null) { + return; + } + var m = meta || _emberMetalMeta.meta(obj); + var counter = m.peekWatching(keyPath) || 0; -/** - Handle events from `Ember.EventDispatcher` - @method handleEvent - @param eventName {String} - @param evt {Event} - @private -*/ -enifed("ember-views/system/action_manager", ["exports"], function (exports) { + if (counter === 1) { + m.writeWatching(keyPath, 0); + chainsFor(obj, m).remove(keyPath); + } else if (counter > 1) { + m.writeWatching(keyPath, counter - 1); + } + } +}); +enifed('ember-metal/watching', ['exports', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) { /** - @module ember - @submodule ember-views + @module ember-metal */ - "use strict"; - - exports.default = ActionManager; + 'use strict'; - function ActionManager() {} + exports.isWatching = isWatching; + exports.watcherCount = watcherCount; + exports.unwatch = unwatch; + exports.destroy = destroy; /** - Global action id hash. + Starts watching a property on an object. Whenever the property changes, + invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the + primitive used by observers and dependent keys; usually you will never call + this method directly but instead use higher level methods like + `Ember.addObserver()` @private - @property registeredActions - @type Object - */ - ActionManager.registeredActions = {}; -}); -enifed('ember-views/system/event_dispatcher', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-environment', 'ember-views/compat/fallback-view-registry'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberViewsSystemJquery, _emberViewsSystemAction_manager, _emberEnvironment, _emberViewsCompatFallbackViewRegistry) { - /** - @module ember - @submodule ember-views + @method watch + @for Ember + @param obj + @param {String} _keyPath */ + function watch(obj, _keyPath, m) { + if (!_emberMetalPath_cache.isPath(_keyPath)) { + _emberMetalWatch_key.watchKey(obj, _keyPath, m); + } else { + _emberMetalWatch_path.watchPath(obj, _keyPath, m); + } + } - 'use strict'; + exports.watch = watch; - var ROOT_ELEMENT_CLASS = 'ember-application'; - var ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; + function isWatching(obj, key) { + if (typeof obj !== 'object' || obj === null) { + return false; + } + var meta = _emberMetalMeta.peekMeta(obj); + return (meta && meta.peekWatching(key)) > 0; + } + + function watcherCount(obj, key) { + var meta = _emberMetalMeta.peekMeta(obj); + return meta && meta.peekWatching(key) || 0; + } + + function unwatch(obj, _keyPath, m) { + if (!_emberMetalPath_cache.isPath(_keyPath)) { + _emberMetalWatch_key.unwatchKey(obj, _keyPath, m); + } else { + _emberMetalWatch_path.unwatchPath(obj, _keyPath, m); + } + } /** - `Ember.EventDispatcher` handles delegating browser events to their - corresponding `Ember.Views.` For example, when you click on a view, - `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets - called. + Tears down the meta on an object so that it can be garbage collected. + Multiple calls will have no effect. - @class EventDispatcher - @namespace Ember + @method destroy + @for Ember + @param {Object} obj the object to destroy + @return {void} @private - @extends Ember.Object */ - exports.default = _emberRuntime.Object.extend({ - /** - The set of events names (and associated handler function names) to be setup - and dispatched by the `EventDispatcher`. Modifications to this list can be done - at setup time, generally via the `Ember.Application.customEvents` hash. - To add new events to be listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - paste: 'paste' - } - }); - ``` - To prevent default events from being listened to: - ```javascript - let App = Ember.Application.create({ - customEvents: { - mouseenter: null, - mouseleave: null - } - }); - ``` - @property events - @type Object - @private - */ - events: { - touchstart: 'touchStart', - touchmove: 'touchMove', - touchend: 'touchEnd', - touchcancel: 'touchCancel', - keydown: 'keyDown', - keyup: 'keyUp', - keypress: 'keyPress', - mousedown: 'mouseDown', - mouseup: 'mouseUp', - contextmenu: 'contextMenu', - click: 'click', - dblclick: 'doubleClick', - mousemove: 'mouseMove', - focusin: 'focusIn', - focusout: 'focusOut', - mouseenter: 'mouseEnter', - mouseleave: 'mouseLeave', - submit: 'submit', - input: 'input', - change: 'change', - dragstart: 'dragStart', - drag: 'drag', - dragenter: 'dragEnter', - dragleave: 'dragLeave', - dragover: 'dragOver', - drop: 'drop', - dragend: 'dragEnd' - }, + function destroy(obj) { + _emberMetalMeta.deleteMeta(obj); + } +}); +enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) { + 'use strict'; - /** - The root DOM element to which event listeners should be attached. Event - listeners will be attached to the document unless this is overridden. - Can be specified as a DOMElement or a selector string. - The default body is a string since this may be evaluated before document.body - exists in the DOM. - @private - @property rootElement - @type DOMElement - @default 'body' - */ - rootElement: 'body', + exports.default = WeakMap; - /** - It enables events to be dispatched to the view's `eventManager.` When present, - this object takes precedence over handling of events on the view itself. - Note that most Ember applications do not use this feature. If your app also - does not use it, consider setting this property to false to gain some performance - improvement by allowing the EventDispatcher to skip the search for the - `eventManager` on the view tree. - ```javascript - let EventDispatcher = Em.EventDispatcher.extend({ - events: { - click : 'click', - focusin : 'focusIn', - focusout : 'focusOut', - change : 'change' - }, - canDispatchToEventManager: false - }); - container.register('event_dispatcher:main', EventDispatcher); - ``` - @property canDispatchToEventManager - @type boolean - @default 'true' - @since 1.7.0 - @private - */ - canDispatchToEventManager: true, + var id = 0; - init: function () { - this._super(); - }, + // Returns whether Type(value) is Object according to the terminology in the spec + function isObject(value) { + return typeof value === 'object' && value !== null || typeof value === 'function'; + } - /** - Sets up event listeners for standard browser events. - This will be called after the browser sends a `DOMContentReady` event. By - default, it will set up all of the listeners on the document body. If you - would like to register the listeners on a different element, set the event - dispatcher's `root` property. - @private - @method setup - @param addedEvents {Object} - */ - setup: function (addedEvents, rootElement) { - var event = undefined; - var events = this._finalEvents = _emberUtils.assign({}, _emberMetal.get(this, 'events'), addedEvents); + /* + * @class Ember.WeakMap + * @public + * @category ember-metal-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. + */ - if (!_emberMetal.isNone(rootElement)) { - _emberMetal.set(this, 'rootElement', rootElement); - } + function WeakMap(iterable) { + if (!(this instanceof WeakMap)) { + throw new TypeError('Constructor WeakMap requires \'new\''); + } - rootElement = _emberViewsSystemJquery.default(_emberMetal.get(this, 'rootElement')); + this._id = _emberUtils.GUID_KEY + id++; - rootElement.addClass(ROOT_ELEMENT_CLASS); + if (iterable === null || iterable === undefined) { + return; + } else if (Array.isArray(iterable)) { + for (var i = 0; i < iterable.length; i++) { + var _iterable$i = iterable[i]; + var key = _iterable$i[0]; + var value = _iterable$i[1]; - if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) { - throw new TypeError('Unable to add \'' + ROOT_ELEMENT_CLASS + '\' class to root element (' + (rootElement.selector || rootElement[0].tagName) + '). Make sure you set rootElement to the body or an element in the body.'); + this.set(key, value); } + } else { + throw new TypeError('The weak map constructor polyfill only supports an array argument'); + } + } - for (event in events) { - if (events.hasOwnProperty(event)) { - this.setupHandler(rootElement, event, events[event]); + /* + * @method get + * @param key {Object | Function} + * @return {Any} stored value + */ + WeakMap.prototype.get = function (obj) { + if (!isObject(obj)) { + return undefined; + } + + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + if (map[this._id] === _emberMetalMeta.UNDEFINED) { + return undefined; } + + return map[this._id]; } - }, + } + }; - /** - Registers an event listener on the rootElement. If the given event is - triggered, the provided event handler will be triggered on the target view. - If the target view does not implement the event handler, or if the handler - returns `false`, the parent view will be called. The event will continue to - bubble to each successive parent view until it reaches the top. - @private - @method setupHandler - @param {Element} rootElement - @param {String} event the browser-originated event to listen to - @param {String} eventName the name of the method to call on the view - */ - setupHandler: function (rootElement, event, eventName) { - var self = this; + /* + * @method set + * @param key {Object | Function} + * @param value {Any} + * @return {WeakMap} the weak map + */ + WeakMap.prototype.set = function (obj, value) { + if (!isObject(obj)) { + throw new TypeError('Invalid value used as weak map key'); + } - var owner = _emberUtils.getOwner(this); - var viewRegistry = owner && owner.lookup('-view-registry:main') || _emberViewsCompatFallbackViewRegistry.default; + if (value === undefined) { + value = _emberMetalMeta.UNDEFINED; + } - if (eventName === null) { - return; - } + _emberMetalMeta.meta(obj).writableWeak()[this._id] = value; - rootElement.on(event + '.ember', '.ember-view', function (evt, triggeringManager) { - var view = viewRegistry[this.id]; - var result = true; + return this; + }; - var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; + /* + * @method has + * @param key {Object | Function} + * @return {boolean} if the key exists + */ + WeakMap.prototype.has = function (obj) { + if (!isObject(obj)) { + return false; + } - if (manager && manager !== triggeringManager) { - result = self._dispatchEvent(manager, evt, eventName, view); - } else if (view) { - result = self._bubbleEvent(view, evt, eventName); - } + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + return map[this._id] !== undefined; + } + } - return result; - }); + return false; + }; - rootElement.on(event + '.ember', '[data-ember-action]', function (evt) { - var actionId = _emberViewsSystemJquery.default(evt.currentTarget).attr('data-ember-action'); - var actions = _emberViewsSystemAction_manager.default.registeredActions[actionId]; + /* + * @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; + } + }; - // In Glimmer2 this attribute is set to an empty string and an additional - // attribute it set for each action on a given element. In this case, the - // attributes need to be read so that a proper set of action handlers can - // be coalesced. - if (actionId === '') { - var attributes = evt.currentTarget.attributes; - var attributeCount = attributes.length; + /* + * @method toString + * @return {String} + */ + WeakMap.prototype.toString = function () { + return '[object WeakMap]'; + }; +}); +enifed('ember-routing/ext/controller', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/utils'], function (exports, _emberMetal, _emberRuntime, _emberRoutingUtils) { + 'use strict'; - actions = []; + /** + @module ember + @submodule ember-routing + */ - for (var i = 0; i < attributeCount; i++) { - var attr = attributes.item(i); - var attrName = attr.name; + _emberRuntime.ControllerMixin.reopen({ + concatenatedProperties: ['queryParams'], - if (attrName.indexOf('data-ember-action-') === 0) { - actions = actions.concat(_emberViewsSystemAction_manager.default.registeredActions[attr.value]); - } - } - } + /** + Defines which query parameters the controller accepts. + If you give the names `['category','page']` it will bind + the values of these query parameters to the variables + `this.category` and `this.page` + @property queryParams + @public + */ + queryParams: null, - // We have to check for actions here since in some cases, jQuery will trigger - // an event on `removeChild` (i.e. focusout) after we've already torn down the - // action handlers for the view. - if (!actions) { - return; - } + /** + This property is updated to various different callback functions depending on + the current "state" of the backing route. It is used by + `Ember.Controller.prototype._qpChanged`. + The methods backing each state can be found in the `Ember.Route.prototype._qp` computed + property return value (the `.states` property). The current values are listed here for + the sanity of future travelers: + * `inactive` - This state is used when this controller instance is not part of the active + route heirarchy. Set in `Ember.Route.prototype._reset` (a `router.js` microlib hook) and + `Ember.Route.prototype.actions.finalizeQueryParamChange`. + * `active` - This state is used when this controller instance is part of the active + route heirarchy. Set in `Ember.Route.prototype.actions.finalizeQueryParamChange`. + * `allowOverrides` - This state is used in `Ember.Route.prototype.setup` (`route.js` microlib hook). + @method _qpDelegate + @private + */ + _qpDelegate: null, // set by route - for (var index = 0; index < actions.length; index++) { - var action = actions[index]; + /** + During `Ember.Route#setup` observers are created to invoke this method + when any of the query params declared in `Ember.Controller#queryParams` property + are changed. + When invoked this method uses the currently active query param update delegate + (see `Ember.Controller.prototype._qpDelegate` for details) and invokes it with + the QP key/value being changed. + @method _qpChanged + @private + */ + _qpChanged: function (controller, _prop) { + var prop = _prop.substr(0, _prop.length - 3); - if (action && action.eventName === eventName) { - return action.handler(evt); - } - } - }); + var delegate = controller._qpDelegate; + var value = _emberMetal.get(controller, prop); + delegate(prop, value); }, - _findNearestEventManager: function (view, eventName) { - var manager = null; - - while (view) { - manager = _emberMetal.get(view, 'eventManager'); - if (manager && manager[eventName]) { - break; - } + /** + Transition the application into another route. The route may + be either a single route or route path: + ```javascript + aController.transitionToRoute('blogPosts'); + aController.transitionToRoute('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + aController.transitionToRoute('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + aController.transitionToRoute('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```javascript + App.Router.map(function() { + this.route('blogPost', { path: ':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); + }); + }); + aController.transitionToRoute('blogComment', aPost, aComment); + aController.transitionToRoute('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + aController.transitionToRoute('/'); + aController.transitionToRoute('/blog/post/1/comment/13'); + aController.transitionToRoute('/blog/posts?sort=title'); + ``` + An options hash with a `queryParams` property may be provided as + the final argument to add query parameters to the destination URL. + ```javascript + aController.transitionToRoute('blogPost', 1, { + queryParams: { showComments: 'true' } + }); + // if you just want to transition the query parameters without changing the route + aController.transitionToRoute({ queryParams: { sort: 'date' } }); + ``` + See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). + @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 + @for Ember.ControllerMixin + @method transitionToRoute + @public + */ + transitionToRoute: function () { + // target may be either another controller or a router + var target = _emberMetal.get(this, 'target'); + var method = target.transitionToRoute || target.transitionTo; - view = _emberMetal.get(view, 'parentView'); + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - return manager; + return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(this, args)); }, - _dispatchEvent: function (object, evt, eventName, view) { - var result = true; + /** + Transition into another route while replacing the current URL, if possible. + This will replace the current history entry instead of adding a new one. + Beside that, it is identical to `transitionToRoute` in all other respects. + ```javascript + aController.replaceRoute('blogPosts'); + aController.replaceRoute('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + aController.replaceRoute('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + aController.replaceRoute('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```javascript + App.Router.map(function() { + this.route('blogPost', { path: ':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); + }); + }); + aController.replaceRoute('blogComment', aPost, aComment); + aController.replaceRoute('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + aController.replaceRoute('/'); + aController.replaceRoute('/blog/post/1/comment/13'); + ``` + @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. + @for Ember.ControllerMixin + @method replaceRoute + @public + */ + replaceRoute: function () { + // target may be either another controller or a router + var target = _emberMetal.get(this, 'target'); + var method = target.replaceRoute || target.replaceWith; - var handler = object[eventName]; - if (typeof handler === 'function') { - result = _emberMetal.run(object, handler, evt, view); - // Do not preventDefault in eventManagers. - evt.stopPropagation(); - } else { - result = this._bubbleEvent(view, evt, eventName); + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - return result; - }, - - _bubbleEvent: function (view, evt, eventName) { - return view.handleEvent(eventName, evt); - }, - - destroy: function () { - var rootElement = _emberMetal.get(this, 'rootElement'); - _emberViewsSystemJquery.default(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); - return this._super.apply(this, arguments); - }, - - toString: function () { - return '(EventDispatcher)'; + return method.apply(target, _emberRoutingUtils.prefixRouteNameArg(target, args)); } }); + + exports.default = _emberRuntime.ControllerMixin; }); -enifed('ember-views/system/ext', ['exports', 'ember-metal'], function (exports, _emberMetal) { +enifed('ember-routing/ext/run_loop', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; + /** @module ember @submodule ember-views */ - 'use strict'; - - // Add a new named queue for rendering views that happens - // after bindings have synced, and a queue for scheduling actions - // that should occur after view rendering. - _emberMetal.run._addQueue('render', 'actions'); - _emberMetal.run._addQueue('afterRender', 'render'); + // Add a new named queue after the 'actions' queue (where RSVP promises + // resolve), which is used in router transitions to prevent unnecessary + // loading state entry if all context promises resolve on the + // 'actions' queue first. + _emberMetal.run._addQueue('routerTransitions', 'actions'); }); -enifed('ember-views/system/jquery', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { - 'use strict'; - - var jQuery = undefined; - - if (_emberEnvironment.environment.hasDOM) { - jQuery = _emberEnvironment.context.imports.jQuery; - - if (jQuery) { - if (jQuery.event.addProp) { - jQuery.event.addProp('dataTransfer'); - } else { - // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents - ['dragstart', 'drag', 'dragenter', 'dragleave', 'dragover', 'drop', 'dragend'].forEach(function (eventName) { - jQuery.event.fixHooks[eventName] = { - props: ['dataTransfer'] - }; - }); - } - } - } +enifed('ember-routing/index', ['exports', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route', 'ember-routing/system/query_params', 'ember-routing/services/routing', 'ember-routing/services/router', 'ember-routing/system/cache'], function (exports, _emberRoutingExtRun_loop, _emberRoutingExtController, _emberRoutingLocationApi, _emberRoutingLocationNone_location, _emberRoutingLocationHash_location, _emberRoutingLocationHistory_location, _emberRoutingLocationAuto_location, _emberRoutingSystemGenerate_controller, _emberRoutingSystemController_for, _emberRoutingSystemDsl, _emberRoutingSystemRouter, _emberRoutingSystemRoute, _emberRoutingSystemQuery_params, _emberRoutingServicesRouting, _emberRoutingServicesRouter, _emberRoutingSystemCache) { + /** + @module ember + @submodule ember-routing + */ - exports.default = jQuery; -}); -enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal'], function (exports, _emberMetal) { + // ES6TODO: Cleanup modules with side-effects below 'use strict'; - exports.default = lookupPartial; - exports.hasPartial = hasPartial; - - function parseUnderscoredName(templateName) { - var nameParts = templateName.split('/'); - var lastPart = nameParts[nameParts.length - 1]; - - nameParts[nameParts.length - 1] = '_' + lastPart; - - return nameParts.join('/'); - } - - function lookupPartial(templateName, owner) { - if (templateName == null) { - return; - } - - var template = templateFor(owner, parseUnderscoredName(templateName), templateName); - - return template; - } - - function hasPartial(name, owner) { - if (!owner) { - throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); - } - - return owner.hasRegistration('template:' + parseUnderscoredName(name)) || owner.hasRegistration('template:' + name); - } - - function templateFor(owner, underscored, name) { - if (!name) { - return; - } - - if (!owner) { - throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); - } - - return owner.lookup('template:' + underscored) || owner.lookup('template:' + name); - } + exports.Location = _emberRoutingLocationApi.default; + exports.NoneLocation = _emberRoutingLocationNone_location.default; + exports.HashLocation = _emberRoutingLocationHash_location.default; + exports.HistoryLocation = _emberRoutingLocationHistory_location.default; + exports.AutoLocation = _emberRoutingLocationAuto_location.default; + exports.generateController = _emberRoutingSystemGenerate_controller.default; + exports.generateControllerFactory = _emberRoutingSystemGenerate_controller.generateControllerFactory; + exports.controllerFor = _emberRoutingSystemController_for.default; + exports.RouterDSL = _emberRoutingSystemDsl.default; + exports.Router = _emberRoutingSystemRouter.default; + exports.Route = _emberRoutingSystemRoute.default; + exports.QueryParams = _emberRoutingSystemQuery_params.default; + exports.RoutingService = _emberRoutingServicesRouting.default; + exports.RouterService = _emberRoutingServicesRouter.default; + exports.BucketCache = _emberRoutingSystemCache.default; }); -enifed('ember-views/system/utils', ['exports', 'ember-utils'], function (exports, _emberUtils) { - /* globals Element */ +enifed('ember-routing/location/api', ['exports', 'ember-metal', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberMetal, _emberEnvironment, _emberRoutingLocationUtil) { 'use strict'; - exports.isSimpleClick = isSimpleClick; - exports.getRootViews = getRootViews; - exports.getViewId = getViewId; - exports.getViewElement = getViewElement; - exports.initViewElement = initViewElement; - exports.setViewElement = setViewElement; - exports.getChildViews = getChildViews; - exports.initChildViews = initChildViews; - exports.addChildView = addChildView; - exports.collectChildViews = collectChildViews; - exports.getViewBounds = getViewBounds; - exports.getViewRange = getViewRange; - exports.getViewClientRects = getViewClientRects; - exports.getViewBoundingClientRect = getViewBoundingClientRect; - exports.matches = matches; - /** @module ember - @submodule ember-views + @submodule ember-routing */ - function isSimpleClick(event) { - var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; - var secondaryClick = event.which > 1; // IE9 may return undefined - - return !modifier && !secondaryClick; - } - - var STYLE_WARNING = '' + 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + 'please ensure that values being bound are properly escaped. For more information, ' + 'including how to disable this warning, see ' + 'http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.'; - - exports.STYLE_WARNING = STYLE_WARNING; /** + Ember.Location returns an instance of the correct implementation of + the `location` API. + + ## Implementations + + You can pass an implementation name (`hash`, `history`, `none`) to force a + particular implementation to be used in your application. + + ### HashLocation + + Using `HashLocation` results in URLs with a `#` (hash sign) separating the + server side URL portion of the URL from the portion that is used by Ember. + This relies upon the `hashchange` event existing in the browser. + + Example: + + ```javascript + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); + + App.Router.reopen({ + location: 'hash' + }); + ``` + + This will result in a posts.new url of `/#/posts/new`. + + ### HistoryLocation + + Using `HistoryLocation` results in URLs that are indistinguishable from a + standard URL. This relies upon the browser's `history` API. + + Example: + + ```javascript + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); + + App.Router.reopen({ + location: 'history' + }); + ``` + + This will result in a posts.new url of `/posts/new`. + + Keep in mind that your server must serve the Ember app at all the routes you + define. + + ### AutoLocation + + Using `AutoLocation`, the router will use the best Location class supported by + the browser it is running in. + + Browsers that support the `history` API will use `HistoryLocation`, those that + do not, but still support the `hashchange` event will use `HashLocation`, and + in the rare case neither is supported will use `NoneLocation`. + + Example: + + ```javascript + App.Router.map(function() { + this.route('posts', function() { + this.route('new'); + }); + }); + + App.Router.reopen({ + location: 'auto' + }); + ``` + + This will result in a posts.new url of `/posts/new` for modern browsers that + support the `history` api or `/#/posts/new` for older ones, like Internet + Explorer 9 and below. + + When a user visits a link to your application, they will be automatically + upgraded or downgraded to the appropriate `Location` class, with the URL + transformed accordingly, if needed. + + Keep in mind that since some of your users will use `HistoryLocation`, your + server must serve the Ember app at all the routes you define. + + ### NoneLocation + + Using `NoneLocation` causes Ember to not store the applications URL state + in the actual URL. This is generally used for testing purposes, and is one + of the changes made when calling `App.setupForTesting()`. + + ## Location API + + Each location implementation must provide the following methods: + + * implementation: returns the string name used to reference the implementation. + * getURL: returns the current URL. + * setURL(path): sets the current URL. + * replaceURL(path): replace the current URL (optional). + * onUpdateURL(callback): triggers the callback when the URL changes. + * formatURL(url): formats `url` to be placed into `href` attribute. + * detect() (optional): instructs the location to do any feature detection + necessary. If the location needs to redirect to a different URL, it + can cancel routing by setting the `cancelRouterSetup` property on itself + to `false`. + + Calling setURL or replaceURL will not trigger onUpdateURL callbacks. + + ## Custom implementation + + Ember scans `app/locations/*` for extending the Location API. + + Example: + + ```javascript + import Ember from 'ember'; + + export default Ember.HistoryLocation.extend({ + implementation: 'history-url-logging', + + pushState: function (path) { + console.log(path); + this._super.apply(this, arguments); + } + }); + ``` + + @class Location + @namespace Ember + @static @private - @method getRootViews - @param {Object} owner */ + exports.default = { + /** + This is deprecated in favor of using the container to lookup the location + implementation as desired. + For example: + ```javascript + // Given a location registered as follows: + container.register('location:history-test', HistoryTestLocation); + // You could create a new instance via: + container.lookup('location:history-test'); + ``` + @method create + @param {Object} options + @return {Object} an instance of an implementation of the `location` API + @deprecated Use the container to lookup the location implementation that you + need. + @private + */ + create: function (options) { + var implementation = options && options.implementation; - function getRootViews(owner) { - var registry = owner.lookup('-view-registry:main'); - - var rootViews = []; - - Object.keys(registry).forEach(function (id) { - var view = registry[id]; - - if (view.parentView === null) { - rootViews.push(view); - } - }); + var implementationClass = this.implementations[implementation]; - return rootViews; - } + return implementationClass.create.apply(implementationClass, arguments); + }, - /** - @private - @method getViewId - @param {Ember.View} view - */ + implementations: {}, + _location: _emberEnvironment.environment.location, - function getViewId(view) { - if (view.tagName === '') { - return _emberUtils.guidFor(view); - } else { - return view.elementId || _emberUtils.guidFor(view); + /** + Returns the current `location.hash` by parsing location.href since browsers + inconsistently URL-decode `location.hash`. + https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + @private + @method getHash + @since 1.4.0 + */ + _getHash: function () { + return _emberRoutingLocationUtil.getHash(this.location); } - } + }; +}); +enifed('ember-routing/location/auto_location', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-routing/location/util'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberRoutingLocationUtil) { + 'use strict'; - var VIEW_ELEMENT = _emberUtils.symbol('VIEW_ELEMENT'); + exports.getHistoryPath = getHistoryPath; + exports.getHashPath = getHashPath; /** - @private - @method getViewElement - @param {Ember.View} view - */ - - function getViewElement(view) { - return view[VIEW_ELEMENT]; - } - - function initViewElement(view) { - view[VIEW_ELEMENT] = null; - } - - function setViewElement(view, element) { - return view[VIEW_ELEMENT] = element; - } - - var CHILD_VIEW_IDS = _emberUtils.symbol('CHILD_VIEW_IDS'); + @module ember + @submodule ember-routing + */ /** + Ember.AutoLocation will select the best location option based off browser + support with the priority order: history, hash, none. + + Clean pushState paths accessed by hashchange-only browsers will be redirected + to the hash-equivalent and vice versa so future transitions are consistent. + + Keep in mind that since some of your users will use `HistoryLocation`, your + server must serve the Ember app at all the routes you define. + + @class AutoLocation + @namespace Ember + @static @private - @method getChildViews - @param {Ember.View} view */ + exports.default = _emberRuntime.Object.extend({ + /** + @private + The browser's `location` object. This is typically equivalent to + `window.location`, but may be overridden for testing. + @property location + @default environment.location + */ + location: _emberEnvironment.environment.location, - function getChildViews(view) { - var owner = _emberUtils.getOwner(view); - var registry = owner.lookup('-view-registry:main'); - return collectChildViews(view, registry); - } + /** + @private + The browser's `history` object. This is typically equivalent to + `window.history`, but may be overridden for testing. + @since 1.5.1 + @property history + @default environment.history + */ + history: _emberEnvironment.environment.history, - function initChildViews(view) { - view[CHILD_VIEW_IDS] = []; - } + /** + @private + The user agent's global variable. In browsers, this will be `window`. + @since 1.11 + @property global + @default window + */ + global: _emberEnvironment.environment.window, - function addChildView(parent, child) { - parent[CHILD_VIEW_IDS].push(getViewId(child)); - } + /** + @private + The browser's `userAgent`. This is typically equivalent to + `navigator.userAgent`, but may be overridden for testing. + @since 1.5.1 + @property userAgent + @default environment.history + */ + userAgent: _emberEnvironment.environment.userAgent, - function collectChildViews(view, registry) { - var ids = []; - var views = []; + /** + @private + This property is used by the router to know whether to cancel the routing + setup process, which is needed while we redirect the browser. + @since 1.5.1 + @property cancelRouterSetup + @default false + */ + cancelRouterSetup: false, - view[CHILD_VIEW_IDS].forEach(function (id) { - var view = registry[id]; + /** + @private + Will be pre-pended to path upon state change. + @since 1.5.1 + @property rootURL + @default '/' + */ + rootURL: '/', - if (view && !view.isDestroying && !view.isDestroyed && ids.indexOf(id) === -1) { - ids.push(id); - views.push(view); + /** + Called by the router to instruct the location to do any feature detection + necessary. In the case of AutoLocation, we detect whether to use history + or hash concrete implementations. + @private + */ + detect: function () { + var rootURL = this.rootURL; + + var implementation = detectImplementation({ + location: this.location, + history: this.history, + userAgent: this.userAgent, + rootURL: rootURL, + documentMode: this.documentMode, + global: this.global + }); + + if (implementation === false) { + _emberMetal.set(this, 'cancelRouterSetup', true); + implementation = 'none'; } - }); - view[CHILD_VIEW_IDS] = ids; + var concrete = _emberUtils.getOwner(this).lookup('location:' + implementation); + _emberMetal.set(concrete, 'rootURL', rootURL); - return views; - } + _emberMetal.set(this, 'concreteImplementation', concrete); + }, - /** - @private - @method getViewBounds - @param {Ember.View} view - */ + initState: delegateToConcreteImplementation('initState'), + getURL: delegateToConcreteImplementation('getURL'), + setURL: delegateToConcreteImplementation('setURL'), + replaceURL: delegateToConcreteImplementation('replaceURL'), + onUpdateURL: delegateToConcreteImplementation('onUpdateURL'), + formatURL: delegateToConcreteImplementation('formatURL'), - function getViewBounds(view) { - return view.renderer.getBounds(view); - } + willDestroy: function () { + var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - /** - @private - @method getViewRange - @param {Ember.View} view - */ + if (concreteImplementation) { + concreteImplementation.destroy(); + } + } + }); - function getViewRange(view) { - var bounds = getViewBounds(view); + function delegateToConcreteImplementation(methodName) { + return function () { + var concreteImplementation = _emberMetal.get(this, 'concreteImplementation'); - var range = document.createRange(); - range.setStartBefore(bounds.firstNode); - range.setEndAfter(bounds.lastNode); + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - return range; + return _emberUtils.tryInvoke(concreteImplementation, methodName, args); + }; } - /** - `getViewClientRects` provides information about the position of the border - box edges of a view relative to the viewport. + /* + Given the browser's `location`, `history` and `userAgent`, and a configured + root URL, this function detects whether the browser supports the [History + API](https://developer.mozilla.org/en-US/docs/Web/API/History) and returns a + string representing the Location object to use based on its determination. - It is only intended to be used by development tools like the Ember Inspector - and may not work on older browsers. + For example, if the page loads in an evergreen browser, this function would + return the string "history", meaning the history API and thus HistoryLocation + should be used. If the page is loaded in IE8, it will return the string + "hash," indicating that the History API should be simulated by manipulating the + hash portion of the location. - @private - @method getViewClientRects - @param {Ember.View} view */ - function getViewClientRects(view) { - var range = getViewRange(view); - return range.getClientRects(); - } + function detectImplementation(options) { + var location = options.location; + var userAgent = options.userAgent; + var history = options.history; + var documentMode = options.documentMode; + var global = options.global; + var rootURL = options.rootURL; - /** - `getViewBoundingClientRect` provides information about the position of the - bounding border box edges of a view relative to the viewport. - - It is only intended to be used by development tools like the Ember Inpsector - and may not work on older browsers. - - @private - @method getViewBoundingClientRect - @param {Ember.View} view - */ + var implementation = 'none'; + var cancelRouterSetup = false; + var currentPath = _emberRoutingLocationUtil.getFullPath(location); - function getViewBoundingClientRect(view) { - var range = getViewRange(view); - return range.getBoundingClientRect(); + if (_emberRoutingLocationUtil.supportsHistory(userAgent, history)) { + var historyPath = getHistoryPath(rootURL, location); + + // If the browser supports history and we have a history path, we can use + // the history location with no redirects. + if (currentPath === historyPath) { + return 'history'; + } else { + if (currentPath.substr(0, 2) === '/#') { + history.replaceState({ path: historyPath }, null, historyPath); + implementation = 'history'; + } else { + cancelRouterSetup = true; + _emberRoutingLocationUtil.replacePath(location, historyPath); + } + } + } else if (_emberRoutingLocationUtil.supportsHashChange(documentMode, global)) { + var hashPath = getHashPath(rootURL, location); + + // Be sure we're using a hashed path, otherwise let's switch over it to so + // we start off clean and consistent. We'll count an index path with no + // hash as "good enough" as well. + if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') { + implementation = 'hash'; + } else { + // Our URL isn't in the expected hash-supported format, so we want to + // cancel the router setup and replace the URL to start off clean + cancelRouterSetup = true; + _emberRoutingLocationUtil.replacePath(location, hashPath); + } + } + + if (cancelRouterSetup) { + return false; + } + + return implementation; } /** - Determines if the element matches the specified selector. - @private - @method matches - @param {DOMElement} el - @param {String} selector + + Returns the current path as it should appear for HistoryLocation supported + browsers. This may very well differ from the real current path (e.g. if it + starts off as a hashed URL) */ - var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector); - - exports.elMatches = elMatches; - - function matches(el, selector) { - return elMatches.call(el, selector); - } -}); -enifed('ember-views/utils/lookup-component', ['exports', 'container'], function (exports, _container) { - 'use strict'; - exports.default = lookupComponent; + function getHistoryPath(rootURL, location) { + var path = _emberRoutingLocationUtil.getPath(location); + var hash = _emberRoutingLocationUtil.getHash(location); + var query = _emberRoutingLocationUtil.getQuery(location); + var rootURLIndex = path.indexOf(rootURL); + var routeHash = undefined, + hashParts = undefined; - var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); + // By convention, Ember.js routes using HashLocation are required to start + // with `#/`. Anything else should NOT be considered a route and should + // be passed straight through, without transformation. + if (hash.substr(0, 2) === '#/') { + // There could be extra hash segments after the route + hashParts = hash.substr(1).split('#'); + // The first one is always the route url + routeHash = hashParts.shift(); - function lookupComponentPair(componentLookup, owner, name, options) { - var component = componentLookup.componentFor(name, owner, options); - var layout = componentLookup.layoutFor(name, owner, options); + // If the path already has a trailing slash, remove the one + // from the hashed route so we don't double up. + if (path.charAt(path.length - 1) === '/') { + routeHash = routeHash.substr(1); + } - var result = { layout: layout, component: component }; + // This is the "expected" final order + path += routeHash + query; - if (layout && !component) { - result.component = owner._lookupFactory(_container.privatize(_templateObject)); + if (hashParts.length) { + path += '#' + hashParts.join('#'); + } + } else { + path += query + hash; } - return result; + return path; } - function lookupComponent(owner, name, options) { - var componentLookup = owner.lookup('component-lookup:main'); - - var source = options && options.source; + /** + @private + + Returns the current path as it should appear for HashLocation supported + browsers. This may very well differ from the real current path. + + @method _getHashPath + */ - if (source) { - var localResult = lookupComponentPair(componentLookup, owner, name, options); + function getHashPath(rootURL, location) { + var path = rootURL; + var historyPath = getHistoryPath(rootURL, location); + var routePath = historyPath.substr(rootURL.length); - if (localResult.component || localResult.layout) { - return localResult; + if (routePath !== '') { + if (routePath[0] !== '/') { + routePath = '/' + routePath; } + + path += '#' + routePath; } - return lookupComponentPair(componentLookup, owner, name); + return path; } }); -enifed('ember-views/views/core_view', ['exports', 'ember-runtime', 'ember-views/system/utils', 'ember-views/views/states'], function (exports, _emberRuntime, _emberViewsSystemUtils, _emberViewsViewsStates) { +enifed('ember-routing/location/hash_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { 'use strict'; /** - `Ember.CoreView` is an abstract class that exists to give view-like behavior - to both Ember's main view class `Ember.Component` and other classes that don't need - the full functionality of `Ember.Component`. - - Unless you have specific needs for `CoreView`, you will use `Ember.Component` - in your applications. + @module ember + @submodule ember-routing + */ + + /** + `Ember.HashLocation` implements the location API using the browser's + hash. At present, it relies on a `hashchange` event existing in the + browser. - @class CoreView + @class HashLocation @namespace Ember @extends Ember.Object - @deprecated Use `Ember.Component` instead. - @uses Ember.Evented - @uses Ember.ActionHandler @private */ - var CoreView = _emberRuntime.FrameworkObject.extend(_emberRuntime.Evented, _emberRuntime.ActionHandler, { - isView: true, - - _states: _emberViewsViewsStates.cloneStates(_emberViewsViewsStates.states), + exports.default = _emberRuntime.Object.extend({ + implementation: 'hash', init: function () { - this._super.apply(this, arguments); - this._state = 'preRender'; - this._currentState = this._states.preRender; - - _emberViewsSystemUtils.initViewElement(this); + _emberMetal.set(this, 'location', _emberMetal.get(this, '_location') || window.location); - if (!this.renderer) { - throw new Error('Cannot instantiate a component without a renderer. Please ensure that you are creating ' + this + ' with a proper container/registry.'); - } + this._hashchangeHandler = undefined; }, /** - If the view is currently inserted into the DOM of a parent view, this - property will point to the parent of the view. - @property parentView - @type Ember.View - @default null @private + Returns normalized location.hash + @since 1.5.1 + @method getHash */ - parentView: null, - - instrumentDetails: function (hash) { - hash.object = this.toString(); - hash.containerKey = this._debugContainerKey; - hash.view = this; - return hash; - }, + getHash: _emberRoutingLocationApi.default._getHash, /** - Override the default event firing from `Ember.Evented` to - also call methods with the given name. - @method trigger - @param name {String} - @private + Returns the normalized URL, constructed from `location.hash`. + e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. + By convention, hashed paths must begin with a forward slash, otherwise they + are not treated as a path so we can distinguish intent. + @private + @method getURL */ - trigger: function () { - this._super.apply(this, arguments); - var name = arguments[0]; - var method = this[name]; - if (method) { - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - return method.apply(this, args); - } - }, + getURL: function () { + var originalPath = this.getHash().substr(1); + var outPath = originalPath; - has: function (name) { - return _emberRuntime.typeOf(this[name]) === 'function' || this._super(name); - } - }); + if (outPath[0] !== '/') { + outPath = '/'; - _emberRuntime.deprecateUnderscoreActions(CoreView); + // Only add the # if the path isn't empty. + // We do NOT want `/#` since the ampersand + // is only included (conventionally) when + // the location.hash has a value + if (originalPath) { + outPath += '#' + originalPath; + } + } - CoreView.reopenClass({ - isViewFactory: true - }); + return outPath; + }, - exports.default = CoreView; -}); -enifed('ember-views/views/states', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberViewsViewsStatesPre_render, _emberViewsViewsStatesHas_element, _emberViewsViewsStatesIn_dom, _emberViewsViewsStatesDestroying) { - 'use strict'; + /** + Set the `location.hash` and remembers what was set. This prevents + `onUpdateURL` callbacks from triggering when the hash was set by + `HashLocation`. + @private + @method setURL + @param path {String} + */ + setURL: function (path) { + _emberMetal.get(this, 'location').hash = path; + _emberMetal.set(this, 'lastSetURL', path); + }, - exports.cloneStates = cloneStates; + /** + Uses location.replace to update the url without a page reload + or history modification. + @private + @method replaceURL + @param path {String} + */ + replaceURL: function (path) { + _emberMetal.get(this, 'location').replace('#' + path); + _emberMetal.set(this, 'lastSetURL', path); + }, - function cloneStates(from) { - var into = {}; + /** + Register a callback to be invoked when the hash changes. These + callbacks will execute when the user presses the back or forward + button, but not after `setURL` is invoked. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + var _this = this; - into._default = {}; - into.preRender = Object.create(into._default); - into.destroying = Object.create(into._default); - into.hasElement = Object.create(into._default); - into.inDOM = Object.create(into.hasElement); + this._removeEventListener(); - for (var stateName in from) { - if (!from.hasOwnProperty(stateName)) { - continue; - } - _emberUtils.assign(into[stateName], from[stateName]); - } + this._hashchangeHandler = function () { + _emberMetal.run(function () { + var path = _this.getURL(); + if (_emberMetal.get(_this, 'lastSetURL') === path) { + return; + } - return into; - } + _emberMetal.set(_this, 'lastSetURL', null); - /* - Describe how the specified actions should behave in the various - states that a view can exist in. Possible states: - - * preRender: when a view is first instantiated, and after its - element was destroyed, it is in the preRender state - * hasElement: the DOM representation of the view is created, - and is ready to be inserted - * inDOM: once a view has been inserted into the DOM it is in - the inDOM state. A view spends the vast majority of its - existence in this state. - * destroyed: once a view has been destroyed (using the destroy - method), it is in this state. No further actions can be invoked - on a destroyed view. - */ - var states = { - _default: _emberViewsViewsStatesDefault.default, - preRender: _emberViewsViewsStatesPre_render.default, - inDOM: _emberViewsViewsStatesIn_dom.default, - hasElement: _emberViewsViewsStatesHas_element.default, - destroying: _emberViewsViewsStatesDestroying.default - }; - exports.states = states; -}); -enifed('ember-views/views/states/default', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + callback(path); + }); + }; - /** - @module ember - @submodule ember-views - */ - exports.default = { - // appendChild is only legal while rendering the buffer. - appendChild: function () { - throw new _emberMetal.Error('You can\'t use appendChild outside of the rendering process'); + window.addEventListener('hashchange', this._hashchangeHandler); }, - $: function () { - return undefined; + /** + Given a URL, formats it to be placed into the page as part + of an element's `href` attribute. + This is used, for example, when using the {{action}} helper + to generate a URL based on an event. + @private + @method formatURL + @param url {String} + */ + formatURL: function (url) { + return '#' + url; }, - // Handle events from `Ember.EventDispatcher` - handleEvent: function () { - return true; // continue event propagation + /** + Cleans up the HashLocation event listener. + @private + @method willDestroy + */ + willDestroy: function () { + this._removeEventListener(); }, - rerender: function () {}, - - destroy: function () {} - }; + _removeEventListener: function () { + if (this._hashchangeHandler) { + window.removeEventListener('hashchange', this._hashchangeHandler); + } + } + }); }); -enifed('ember-views/views/states/destroying', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/default'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesDefault) { +enifed('ember-routing/location/history_location', ['exports', 'ember-metal', 'ember-runtime', 'ember-routing/location/api'], function (exports, _emberMetal, _emberRuntime, _emberRoutingLocationApi) { 'use strict'; /** @module ember - @submodule ember-views + @submodule ember-routing */ - var destroying = Object.create(_emberViewsViewsStatesDefault.default); - - _emberUtils.assign(destroying, { - appendChild: function () { - throw new _emberMetal.Error('You can\'t call appendChild on a view being destroyed'); - }, - rerender: function () { - throw new _emberMetal.Error('You can\'t call rerender on a view being destroyed'); - } - }); - - exports.default = destroying; -}); -enifed('ember-views/views/states/has_element', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-metal', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberMetal, _emberViewsSystemJquery) { - 'use strict'; + var popstateFired = false; - var hasElement = Object.create(_emberViewsViewsStatesDefault.default); + var _uuid = undefined; - _emberUtils.assign(hasElement, { - $: function (view, sel) { - var elem = view.element; - return sel ? _emberViewsSystemJquery.default(sel, elem) : _emberViewsSystemJquery.default(elem); - }, + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + _uuid = function _uuid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r, v; + r = Math.random() * 16 | 0; + v = c === 'x' ? r : r & 3 | 8; + return v.toString(16); + }); + }; + } - rerender: function (view) { - view.renderer.rerender(view); - }, + /** + Ember.HistoryLocation implements the location API using the browser's + history.pushState API. + + @class HistoryLocation + @namespace Ember + @extends Ember.Object + @private + */ + exports.default = _emberRuntime.Object.extend({ + implementation: 'history', - destroy: function (view) { - view.renderer.remove(view); - }, + init: function () { + this._super.apply(this, arguments); - // Handle events from `Ember.EventDispatcher` - handleEvent: function (view, eventName, event) { - if (view.has(eventName)) { - // Handler should be able to re-dispatch events, so we don't - // preventDefault or stopPropagation. - return _emberMetal.flaggedInstrument('interaction.' + eventName, { event: event, view: view }, function () { - return _emberMetal.run.join(view, view.trigger, eventName, event); - }); - } else { - return true; // continue event propagation + var base = document.querySelector('base'); + var baseURL = ''; + if (base) { + baseURL = base.getAttribute('href'); } - } - }); - exports.default = hasElement; -}); -enifed('ember-views/views/states/in_dom', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/has_element'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesHas_element) { - 'use strict'; + _emberMetal.set(this, 'baseURL', baseURL); + _emberMetal.set(this, 'location', _emberMetal.get(this, 'location') || window.location); - /** - @module ember - @submodule ember-views - */ + this._popstateHandler = undefined; + }, + + /** + Used to set state on first call to setURL + @private + @method initState + */ + initState: function () { + var history = _emberMetal.get(this, 'history') || window.history; + _emberMetal.set(this, 'history', history); - var inDOM = Object.create(_emberViewsViewsStatesHas_element.default); + if (history && 'state' in history) { + this.supportsHistory = true; + } - _emberUtils.assign(inDOM, { - enter: function (view) { - // Register the view for event handling. This hash is used by - // Ember.EventDispatcher to dispatch incoming events. - view.renderer.register(view); + this.replaceState(this.formatURL(this.getURL())); }, - exit: function (view) { - view.renderer.unregister(view); - } - }); + /** + Will be pre-pended to path upon state change + @property rootURL + @default '/' + @private + */ + rootURL: '/', - exports.default = inDOM; -}); -enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default'], function (exports, _emberViewsViewsStatesDefault) { - 'use strict'; + /** + Returns the current `location.pathname` without `rootURL` or `baseURL` + @private + @method getURL + @return url {String} + */ + getURL: function () { + var location = _emberMetal.get(this, 'location'); + var path = location.pathname; - /** - @module ember - @submodule ember-views - */ + var rootURL = _emberMetal.get(this, 'rootURL'); + var baseURL = _emberMetal.get(this, 'baseURL'); - exports.default = Object.create(_emberViewsViewsStatesDefault.default); -}); -enifed("ember-views/views/view", ["exports"], function (exports) { - "use strict"; -}); -/** -@module ember -@submodule ember-views -*/ + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); + baseURL = baseURL.replace(/\/$/, ''); -/** - `Ember.View` is the class in Ember responsible for encapsulating templates of - HTML content, combining templates with data to render as sections of a page's - DOM, and registering and responding to user-initiated events. + // remove baseURL and rootURL from start of path + var url = path.replace(new RegExp('^' + baseURL + '(?=/|$)'), '').replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); - ## HTML Tag + var search = location.search || ''; + url += search + this.getHash(); - The default HTML tag name used for a view's DOM representation is `div`. This - can be customized by setting the `tagName` property. The following view - class: + return url; + }, - ```javascript - ParagraphView = Ember.View.extend({ - tagName: 'em' - }); - ``` + /** + Uses `history.pushState` to update the url without a page reload. + @private + @method setURL + @param path {String} + */ + setURL: function (path) { + var state = this.getState(); + path = this.formatURL(path); - Would result in instances with the following HTML: + if (!state || state.path !== path) { + this.pushState(path); + } + }, - ```html - - ``` + /** + Uses `history.replaceState` to update the url without a page reload + or history modification. + @private + @method replaceURL + @param path {String} + */ + replaceURL: function (path) { + var state = this.getState(); + path = this.formatURL(path); - ## HTML `class` Attribute + if (!state || state.path !== path) { + this.replaceState(path); + } + }, - The HTML `class` attribute of a view's tag can be set by providing a - `classNames` property that is set to an array of strings: + /** + Get the current `history.state`. Checks for if a polyfill is + required and if so fetches this._historyState. The state returned + from getState may be null if an iframe has changed a window's + history. + The object returned will contain a `path` for the given state as well + as a unique state `id`. The state index will allow the app to distinguish + between two states with similar paths but should be unique from one another. + @private + @method getState + @return state {Object} + */ + getState: function () { + if (this.supportsHistory) { + return _emberMetal.get(this, 'history').state; + } - ```javascript - MyView = Ember.View.extend({ - classNames: ['my-class', 'my-other-class'] - }); - ``` + return this._historyState; + }, - Will result in view instances with an HTML representation of: + /** + Pushes a new state. + @private + @method pushState + @param path {String} + */ + pushState: function (path) { + var state = { path: path }; + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + state.uuid = _uuid(); + } - ```html -
    - ``` + _emberMetal.get(this, 'history').pushState(state, null, path); - `class` attribute values can also be set by providing a `classNameBindings` - property set to an array of properties names for the view. The return value - of these properties will be added as part of the value for the view's `class` - attribute. These properties can be computed properties: + this._historyState = state; - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['propertyA', 'propertyB'], - propertyA: 'from-a', - propertyB: Ember.computed(function() { - if (someLogic) { return 'from-b'; } - }) - }); - ``` + // used for webkit workaround + this._previousURL = this.getURL(); + }, - Will result in view instances with an HTML representation of: + /** + Replaces the current state. + @private + @method replaceState + @param path {String} + */ + replaceState: function (path) { + var state = { path: path }; + if (_emberMetal.isFeatureEnabled('ember-unique-location-history-state')) { + state.uuid = _uuid(); + } - ```html -
    - ``` + _emberMetal.get(this, 'history').replaceState(state, null, path); - If the value of a class name binding returns a boolean the property name - itself will be used as the class name if the property is true. The class name - will not be added if the value is `false` or `undefined`. + this._historyState = state; - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['hovered'], - hovered: true - }); - ``` + // used for webkit workaround + this._previousURL = this.getURL(); + }, - Will result in view instances with an HTML representation of: + /** + Register a callback to be invoked whenever the browser + history changes, including using forward and back buttons. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + var _this = this; - ```html -
    - ``` + this._removeEventListener(); - When using boolean class name bindings you can supply a string value other - than the property name for use as the `class` HTML attribute by appending the - preferred value after a ":" character when defining the binding: + this._popstateHandler = function () { + // Ignore initial page load popstate event in Chrome + if (!popstateFired) { + popstateFired = true; + if (_this.getURL() === _this._previousURL) { + return; + } + } + callback(_this.getURL()); + }; - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['awesome:so-very-cool'], - awesome: true - }); - ``` + window.addEventListener('popstate', this._popstateHandler); + }, - Will result in view instances with an HTML representation of: + /** + Used when using `{{action}}` helper. The url is always appended to the rootURL. + @private + @method formatURL + @param url {String} + @return formatted url {String} + */ + formatURL: function (url) { + var rootURL = _emberMetal.get(this, 'rootURL'); + var baseURL = _emberMetal.get(this, 'baseURL'); - ```html -
    - ``` + if (url !== '') { + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); + baseURL = baseURL.replace(/\/$/, ''); + } else if (baseURL[0] === '/' && rootURL[0] === '/') { + // if baseURL and rootURL both start with a slash + // ... remove trailing slash from baseURL if it exists + baseURL = baseURL.replace(/\/$/, ''); + } - Boolean value class name bindings whose property names are in a - camelCase-style format will be converted to a dasherized format: + return baseURL + rootURL + url; + }, - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['isUrgent'], - isUrgent: true - }); - ``` + /** + Cleans up the HistoryLocation event listener. + @private + @method willDestroy + */ + willDestroy: function () { + this._removeEventListener(); + }, - Will result in view instances with an HTML representation of: + /** + @private + Returns normalized location.hash + @method getHash + */ + getHash: _emberRoutingLocationApi.default._getHash, - ```html -
    - ``` + _removeEventListener: function () { + if (this._popstateHandler) { + window.removeEventListener('popstate', this._popstateHandler); + } + } + }); +}); +enifed('ember-routing/location/none_location', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + 'use strict'; - Class name bindings can also refer to object values that are found by - traversing a path relative to the view itself: + /** + @module ember + @submodule ember-routing + */ - ```javascript - MyView = Ember.View.extend({ - classNameBindings: ['messages.empty'] - messages: Ember.Object.create({ - empty: true - }) - }); - ``` + /** + Ember.NoneLocation does not interact with the browser. It is useful for + testing, or when you need to manage state with your Router, but temporarily + don't want it to muck with the URL (for example when you embed your + application in a larger page). + + @class NoneLocation + @namespace Ember + @extends Ember.Object + @private + */ + exports.default = _emberRuntime.Object.extend({ + implementation: 'none', + path: '', - Will result in view instances with an HTML representation of: + detect: function () { + var rootURL = this.rootURL; + }, - ```html -
    - ``` + /** + Will be pre-pended to path. + @private + @property rootURL + @default '/' + */ + rootURL: '/', - If you want to add a class name for a property which evaluates to true and - and a different class name if it evaluates to false, you can pass a binding - like this: + /** + Returns the current path without `rootURL`. + @private + @method getURL + @return {String} path + */ + getURL: function () { + var path = _emberMetal.get(this, 'path'); + var rootURL = _emberMetal.get(this, 'rootURL'); - ```javascript - // Applies 'enabled' class when isEnabled is true and 'disabled' when isEnabled is false - Ember.View.extend({ - classNameBindings: ['isEnabled:enabled:disabled'] - isEnabled: true - }); - ``` + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); - Will result in view instances with an HTML representation of: + // remove rootURL from url + return path.replace(new RegExp('^' + rootURL + '(?=/|$)'), ''); + }, - ```html -
    - ``` + /** + Set the path and remembers what was set. Using this method + to change the path will not invoke the `updateURL` callback. + @private + @method setURL + @param path {String} + */ + setURL: function (path) { + _emberMetal.set(this, 'path', path); + }, + + /** + Register a callback to be invoked when the path changes. These + callbacks will execute when the user presses the back or forward + button, but not after `setURL` is invoked. + @private + @method onUpdateURL + @param callback {Function} + */ + onUpdateURL: function (callback) { + this.updateCallback = callback; + }, - When isEnabled is `false`, the resulting HTML representation looks like - this: + /** + Sets the path and calls the `updateURL` callback. + @private + @method handleURL + @param callback {Function} + */ + handleURL: function (url) { + _emberMetal.set(this, 'path', url); + this.updateCallback(url); + }, - ```html -
    - ``` + /** + Given a URL, formats it to be placed into the page as part + of an element's `href` attribute. + This is used, for example, when using the {{action}} helper + to generate a URL based on an event. + @private + @method formatURL + @param url {String} + @return {String} url + */ + formatURL: function (url) { + var rootURL = _emberMetal.get(this, 'rootURL'); - This syntax offers the convenience to add a class if a property is `false`: + if (url !== '') { + // remove trailing slashes if they exists + rootURL = rootURL.replace(/\/$/, ''); + } - ```javascript - // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false - Ember.View.extend({ - classNameBindings: ['isEnabled::disabled'] - isEnabled: true + return rootURL + url; + } }); - ``` +}); +enifed('ember-routing/location/util', ['exports'], function (exports) { + /** + @private + + Returns the current `location.pathname`, normalized for IE inconsistencies. + */ + 'use strict'; - Will result in view instances with an HTML representation of: + exports.getPath = getPath; + exports.getQuery = getQuery; + exports.getHash = getHash; + exports.getFullPath = getFullPath; + exports.getOrigin = getOrigin; + exports.supportsHashChange = supportsHashChange; + exports.supportsHistory = supportsHistory; + exports.replacePath = replacePath; - ```html -
    - ``` + function getPath(location) { + var pathname = location.pathname; + // Various versions of IE/Opera don't always return a leading slash + if (pathname[0] !== '/') { + pathname = '/' + pathname; + } - When the `isEnabled` property on the view is set to `false`, it will result - in view instances with an HTML representation of: + return pathname; + } - ```html -
    - ``` + /** + @private + + Returns the current `location.search`. + */ - Updates to the value of a class name binding will result in automatic - update of the HTML `class` attribute in the view's rendered HTML - representation. If the value becomes `false` or `undefined` the class name - will be removed. + function getQuery(location) { + return location.search; + } - Both `classNames` and `classNameBindings` are concatenated properties. See - [Ember.Object](/api/classes/Ember.Object.html) documentation for more - information about concatenated properties. + /** + @private + + Returns the current `location.hash` by parsing location.href since browsers + inconsistently URL-decode `location.hash`. + + Should be passed the browser's `location` object as the first argument. + + https://bugzilla.mozilla.org/show_bug.cgi?id=483304 + */ - ## HTML Attributes + function getHash(location) { + var href = location.href; + var hashIndex = href.indexOf('#'); - The HTML attribute section of a view's tag can be set by providing an - `attributeBindings` property set to an array of property names on the view. - The return value of these properties will be used as the value of the view's - HTML associated attribute: + if (hashIndex === -1) { + return ''; + } else { + return href.substr(hashIndex); + } + } - ```javascript - AnchorView = Ember.View.extend({ - tagName: 'a', - attributeBindings: ['href'], - href: 'http://google.com' - }); - ``` + function getFullPath(location) { + return getPath(location) + getQuery(location) + getHash(location); + } - Will result in view instances with an HTML representation of: + function getOrigin(location) { + var origin = location.origin; - ```html - - ``` + // Older browsers, especially IE, don't have origin + if (!origin) { + origin = location.protocol + '//' + location.hostname; - One property can be mapped on to another by placing a ":" between - the source property and the destination property: + if (location.port) { + origin += ':' + location.port; + } + } - ```javascript - AnchorView = Ember.View.extend({ - tagName: 'a', - attributeBindings: ['url:href'], - url: 'http://google.com' - }); - ``` + return origin; + } - Will result in view instances with an HTML representation of: + /* + `documentMode` only exist in Internet Explorer, and it's tested because IE8 running in + IE7 compatibility mode claims to support `onhashchange` but actually does not. + + `global` is an object that may have an `onhashchange` property. + + @private + @function supportsHashChange + */ - ```html - - ``` + function supportsHashChange(documentMode, global) { + return 'onhashchange' in global && (documentMode === undefined || documentMode > 7); + } - Namespaced attributes (e.g. `xlink:href`) are supported, but have to be - mapped, since `:` is not a valid character for properties in Javascript: + /* + `userAgent` is a user agent string. We use user agent testing here, because + the stock Android browser is known to have buggy versions of the History API, + in some Android versions. + + @private + @function supportsHistory + */ - ```javascript - UseView = Ember.View.extend({ - tagName: 'use', - attributeBindings: ['xlinkHref:xlink:href'], - xlinkHref: '#triangle' - }); - ``` - Will result in view instances with an HTML representation of: + function supportsHistory(userAgent, history) { + // Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + // The stock browser on Android 2.2 & 2.3, and 4.0.x returns positive on history support + // Unfortunately support is really buggy and there is no clean way to detect + // these bugs, so we fall back to a user agent sniff :( - ```html - - ``` + // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies + // itself as 'Mobile Safari' as well, nor Windows Phone. + if ((userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 4.0') !== -1) && userAgent.indexOf('Mobile Safari') !== -1 && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Windows Phone') === -1) { + return false; + } - If the return value of an `attributeBindings` monitored property is a boolean - the attribute will be present or absent depending on the value: + return !!(history && 'pushState' in history); + } - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'input', - attributeBindings: ['disabled'], - disabled: false - }); - ``` + /** + Replaces the current location, making sure we explicitly include the origin + to prevent redirecting to a different origin. + + @private + */ - Will result in a view instance with an HTML representation of: + function replacePath(location, path) { + location.replace(getOrigin(location) + path); + } +}); +enifed('ember-routing/services/router', ['exports', 'ember-runtime', 'ember-metal', 'ember-routing/system/dsl'], function (exports, _emberRuntime, _emberMetal, _emberRoutingSystemDsl) { + /** + @module ember + @submodule ember-routing + */ - ```html - - ``` + 'use strict'; - `attributeBindings` can refer to computed properties: + /** + The Router service is the public API that provides component/view layer + access to the router. + + @public + @class RouterService + @category ember-routing-router-service + */ + var RouterService = _emberRuntime.Service.extend({ + currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), + currentURL: _emberRuntime.readOnly('router.currentURL'), + location: _emberRuntime.readOnly('router.location'), + rootURL: _emberRuntime.readOnly('router.rootURL'), - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'input', - attributeBindings: ['disabled'], - disabled: Ember.computed(function() { - if (someLogic) { - return true; - } else { - return false; - } - }) - }); - ``` + /** + 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 + @category ember-routing-router-service + @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 + @public + */ + transitionTo: function () { + var _router; - To prevent setting an attribute altogether, use `null` or `undefined` as the - return value of the `attributeBindings` monitored property: + return (_router = this.router).transitionTo.apply(_router, arguments); + }, - ```javascript - MyTextInput = Ember.View.extend({ - tagName: 'form', - attributeBindings: ['novalidate'], - novalidate: null + /** + Transition into another route while replacing the current URL, if possible. + The route may be either a single route or route path: + See [Route.replaceWith](http://emberjs.com/api/classes/Ember.Route.html#method_replaceWith) for more info. + @method replaceWith + @category ember-routing-router-service + @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 + @public + */ + replaceWith: function () { + var _router2; + + return (_router2 = this.router).replaceWith.apply(_router2, arguments); + } }); - ``` - Updates to the property of an attribute binding will result in automatic - update of the HTML attribute in the view's rendered HTML representation. + exports.default = RouterService; +}); +enifed('ember-routing/services/routing', ['exports', 'ember-utils', 'ember-runtime', 'ember-metal', 'ember-routing/utils'], function (exports, _emberUtils, _emberRuntime, _emberMetal, _emberRoutingUtils) { + /** + @module ember + @submodule ember-routing + */ - `attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html) - documentation for more information about concatenated properties. + 'use strict'; - ## Layouts + /** + The Routing service is used by LinkComponent, and provides facilities for + the component/view layer to interact with the router. + + While still private, this service can eventually be opened up, and provides + the set of API needed for components to control routing without interacting + with router internals. + + @private + @class RoutingService + */ + exports.default = _emberRuntime.Service.extend({ + router: null, - Views can have a secondary template that wraps their main template. Like - primary templates, layouts can be any function that accepts an optional - context parameter and returns a string of HTML that will be inserted inside - view's tag. Views whose HTML element is self closing (e.g. ``) - cannot have a layout and this property will be ignored. + targetState: _emberRuntime.readOnly('router.targetState'), + currentState: _emberRuntime.readOnly('router.currentState'), + currentRouteName: _emberRuntime.readOnly('router.currentRouteName'), + currentPath: _emberRuntime.readOnly('router.currentPath'), - Most typically in Ember a layout will be a compiled template. + availableRoutes: function () { + return Object.keys(_emberMetal.get(this, 'router').router.recognizer.names); + }, - A view's layout can be set directly with the `layout` property or reference - an existing template by name with the `layoutName` property. + hasRoute: function (routeName) { + return _emberMetal.get(this, 'router').hasRoute(routeName); + }, - A template used as a layout must contain a single use of the - `{{yield}}` helper. The HTML contents of a view's rendered `template` will be - inserted at this location: + transitionTo: function (routeName, models, queryParams, shouldReplace) { + var router = _emberMetal.get(this, 'router'); - ```javascript - AViewWithLayout = Ember.View.extend({ - layout: Ember.HTMLBars.compile("
    {{yield}}
    "), - template: Ember.HTMLBars.compile("I got wrapped") - }); - ``` + var transition = router._doTransition(routeName, models, queryParams); - Will result in view instances with an HTML representation of: + if (shouldReplace) { + transition.method('replace'); + } - ```html -
    -
    - I got wrapped -
    -
    - ``` + return transition; + }, - See [Ember.Templates.helpers.yield](/api/classes/Ember.Templates.helpers.html#method_yield) - for more information. + normalizeQueryParams: function (routeName, models, queryParams) { + var router = _emberMetal.get(this, 'router'); + router._prepareQueryParams(routeName, models, queryParams); + }, - ## Responding to Browser Events + generateURL: function (routeName, models, queryParams) { + var router = _emberMetal.get(this, 'router'); + if (!router.router) { + return; + } - Views can respond to user-initiated events in one of three ways: method - implementation, through an event manager, and through `{{action}}` helper use - in their template or layout. + var visibleQueryParams = {}; + _emberUtils.assign(visibleQueryParams, queryParams); - ### Method Implementation + this.normalizeQueryParams(routeName, models, visibleQueryParams); - Views can respond to user-initiated events by implementing a method that - matches the event name. A `jQuery.Event` object will be passed as the - argument to this method. + var args = _emberRoutingUtils.routeArgs(routeName, models, visibleQueryParams); + return router.generate.apply(router, args); + }, - ```javascript - AView = Ember.View.extend({ - click: function(event) { - // will be called when an instance's - // rendered element is clicked - } - }); - ``` + isActiveForRoute: function (contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { + var router = _emberMetal.get(this, 'router'); - ### Event Managers + var handlers = router.router.recognizer.handlersFor(routeName); + var leafName = handlers[handlers.length - 1].handler; + var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); - Views can define an object as their `eventManager` property. This object can - then implement methods that match the desired event names. Matching events - that occur on the view's rendered HTML or the rendered HTML of any of its DOM - descendants will trigger this method. A `jQuery.Event` object will be passed - as the first argument to the method and an `Ember.View` object as the - second. The `Ember.View` will be the view whose rendered HTML was interacted - with. This may be the view with the `eventManager` property or one of its - descendant views. + // NOTE: any ugliness in the calculation of activeness is largely + // due to the fact that we support automatic normalizing of + // `resource` -> `resource.index`, even though there might be + // dynamic segments / query params defined on `resource.index` + // which complicates (and makes somewhat ambiguous) the calculation + // of activeness for links that link to `resource` instead of + // directly to `resource.index`. - ```javascript - AView = Ember.View.extend({ - eventManager: Ember.Object.create({ - doubleClick: function(event, view) { - // will be called when an instance's - // rendered element or any rendering - // of this view's descendant - // elements is clicked + // if we don't have enough contexts revert back to full route name + // this is because the leaf route will use one of the contexts + if (contexts.length > maximumContexts) { + routeName = leafName; } - }) - }); - ``` - - An event defined for an event manager takes precedence over events of the - same name handled through methods on the view. - ```javascript - AView = Ember.View.extend({ - mouseEnter: function(event) { - // will never trigger. - }, - eventManager: Ember.Object.create({ - mouseEnter: function(event, view) { - // takes precedence over AView#mouseEnter - } - }) + return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified); + } }); - ``` - - Similarly a view's event manager will take precedence for events of any views - rendered as a descendant. A method name that matches an event name will not - be called if the view instance was rendered inside the HTML representation of - a view that has an `eventManager` property defined that handles events of the - name. Events not handled by the event manager will still trigger method calls - on the descendant. - ```javascript - var App = Ember.Application.create(); - App.OuterView = Ember.View.extend({ - template: Ember.HTMLBars.compile("outer {{#view 'inner'}}inner{{/view}} outer"), - eventManager: Ember.Object.create({ - mouseEnter: function(event, view) { - // view might be instance of either - // OuterView or InnerView depending on - // where on the page the user interaction occurred + function numberOfContextsAcceptedByHandler(handler, handlerInfos) { + var req = 0; + for (var i = 0; i < handlerInfos.length; i++) { + req += handlerInfos[i].names.length; + if (handlerInfos[i].handler === handler) { + break; } - }) - }); - - App.InnerView = Ember.View.extend({ - click: function(event) { - // will be called if rendered inside - // an OuterView because OuterView's - // eventManager doesn't handle click events - }, - mouseEnter: function(event) { - // will never be called if rendered inside - // an OuterView. } - }); - ``` - ### `{{action}}` Helper - - See [Ember.Templates.helpers.action](/api/classes/Ember.Templates.helpers.html#method_action). + return req; + } +}); +enifed('ember-routing/system/cache', ['exports', 'ember-utils', 'ember-runtime'], function (exports, _emberUtils, _emberRuntime) { + 'use strict'; - ### Event Names + /** + A two-tiered cache with support for fallback values when doing lookups. + Uses "buckets" and then "keys" to cache values. + + @private + @class BucketCache + */ + exports.default = _emberRuntime.Object.extend({ + init: function () { + this.cache = new _emberUtils.EmptyObject(); + }, - All of the event handling approaches described above respond to the same set - of events. The names of the built-in events are listed below. (The hash of - built-in events exists in `Ember.EventDispatcher`.) Additional, custom events - can be registered by using `Ember.Application.customEvents`. + has: function (bucketKey) { + return !!this.cache[bucketKey]; + }, - Touch events: + stash: function (bucketKey, key, value) { + var bucket = this.cache[bucketKey]; - * `touchStart` - * `touchMove` - * `touchEnd` - * `touchCancel` + if (!bucket) { + bucket = this.cache[bucketKey] = new _emberUtils.EmptyObject(); + } - Keyboard events + bucket[key] = value; + }, - * `keyDown` - * `keyUp` - * `keyPress` + lookup: function (bucketKey, prop, defaultValue) { + var cache = this.cache; + if (!this.has(bucketKey)) { + return defaultValue; + } - Mouse events + var bucket = cache[bucketKey]; + if (prop in bucket && bucket[prop] !== undefined) { + return bucket[prop]; + } else { + return defaultValue; + } + } + }); +}); +enifed("ember-routing/system/controller_for", ["exports"], function (exports) { + /** + @module ember + @submodule ember-routing + */ - * `mouseDown` - * `mouseUp` - * `contextMenu` - * `click` - * `doubleClick` - * `mouseMove` - * `focusIn` - * `focusOut` - * `mouseEnter` - * `mouseLeave` + /** + Finds a controller instance. + + @for Ember + @method controllerFor + @private + */ + "use strict"; - Form events: + exports.default = controllerFor; - * `submit` - * `change` - * `focusIn` - * `focusOut` - * `input` + function controllerFor(container, controllerName, lookupOptions) { + return container.lookup("controller:" + controllerName, lookupOptions); + } +}); +enifed('ember-routing/system/dsl', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { + 'use strict'; - HTML5 drag and drop events: + /** + @module ember + @submodule ember-routing + */ - * `dragStart` - * `drag` - * `dragEnter` - * `dragLeave` - * `dragOver` - * `dragEnd` - * `drop` + var uuid = 0; - @class View - @namespace Ember - @extends Ember.CoreView - @deprecated See http://emberjs.com/deprecations/v1.x/#toc_ember-view - @uses Ember.ViewSupport - @uses Ember.ChildViewsSupport - @uses Ember.ClassNamesSupport - @uses Ember.AttributeBindingsSupport - @private -*/ -enifed("ember/features", ["exports"], function (exports) { - "use strict"; + var DSL = (function () { + function DSL(name, options) { + this.parent = name; + this.enableLoadingSubstates = options && options.enableLoadingSubstates; + this.matches = []; + this.explicitIndex = undefined; + this.options = options; + } - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": false, "ember-glimmer-detect-backtracking-rerender": false }; -}); -enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { - 'use strict'; + DSL.prototype.route = function route(name, options, callback) { + if (options === undefined) options = {}; - // ember-utils exports - _emberMetal.default.getOwner = _emberUtils.getOwner; - _emberMetal.default.setOwner = _emberUtils.setOwner; - _emberMetal.default.generateGuid = _emberUtils.generateGuid; - _emberMetal.default.GUID_KEY = _emberUtils.GUID_KEY; - _emberMetal.default.guidFor = _emberUtils.guidFor; - _emberMetal.default.inspect = _emberUtils.inspect; - _emberMetal.default.makeArray = _emberUtils.makeArray; - _emberMetal.default.canInvoke = _emberUtils.canInvoke; - _emberMetal.default.tryInvoke = _emberUtils.tryInvoke; - _emberMetal.default.wrap = _emberUtils.wrap; - _emberMetal.default.applyStr = _emberUtils.applyStr; - _emberMetal.default.uuid = _emberUtils.uuid; - _emberMetal.default.assign = Object.assign || _emberUtils.assign; + var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; + if (arguments.length === 2 && typeof options === 'function') { + callback = options; + options = {}; + } - // container exports - _emberMetal.default.Container = _container.Container; - _emberMetal.default.Registry = _container.Registry; + if (this.enableLoadingSubstates) { + createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace }); + createRoute(this, name + '_error', { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); + } - // need to import this directly, to ensure the babel feature - // flag plugin works properly + if (callback) { + var fullName = getFullName(this, name, options.resetNamespace); + var dsl = new DSL(fullName, this.options); - var computed = _emberMetal.computed; - computed.alias = _emberMetal.alias; - _emberMetal.default.computed = computed; - _emberMetal.default.ComputedProperty = _emberMetal.ComputedProperty; - _emberMetal.default.cacheFor = _emberMetal.cacheFor; + createRoute(dsl, 'loading'); + createRoute(dsl, 'error', { path: dummyErrorRoute }); - _emberMetal.default.assert = _emberMetal.assert; - _emberMetal.default.warn = _emberMetal.warn; - _emberMetal.default.debug = _emberMetal.debug; - _emberMetal.default.deprecate = _emberMetal.deprecate; - _emberMetal.default.deprecateFunc = _emberMetal.deprecateFunc; - _emberMetal.default.runInDebug = _emberMetal.runInDebug; - _emberMetal.default.merge = _emberMetal.merge; + callback.call(dsl); - _emberMetal.default.instrument = _emberMetal.instrument; - _emberMetal.default.subscribe = _emberMetal.instrumentationSubscribe; - _emberMetal.default.Instrumentation = { - instrument: _emberMetal.instrument, - subscribe: _emberMetal.instrumentationSubscribe, - unsubscribe: _emberMetal.instrumentationUnsubscribe, - reset: _emberMetal.instrumentationReset - }; + createRoute(this, name, options, dsl.generate()); + } else { + createRoute(this, name, options); + } + }; - _emberMetal.default.Error = _emberMetal.Error; - _emberMetal.default.META_DESC = _emberMetal.META_DESC; - _emberMetal.default.meta = _emberMetal.meta; - _emberMetal.default.get = _emberMetal.get; - _emberMetal.default.getWithDefault = _emberMetal.getWithDefault; - _emberMetal.default._getPath = _emberMetal._getPath; - _emberMetal.default.set = _emberMetal.set; - _emberMetal.default.trySet = _emberMetal.trySet; - _emberMetal.default.FEATURES = _emberMetal.FEATURES; - _emberMetal.default.FEATURES.isEnabled = _emberMetal.isFeatureEnabled; - _emberMetal.default._Cache = _emberMetal.Cache; - _emberMetal.default.on = _emberMetal.on; - _emberMetal.default.addListener = _emberMetal.addListener; - _emberMetal.default.removeListener = _emberMetal.removeListener; - _emberMetal.default._suspendListener = _emberMetal.suspendListener; - _emberMetal.default._suspendListeners = _emberMetal.suspendListeners; - _emberMetal.default.sendEvent = _emberMetal.sendEvent; - _emberMetal.default.hasListeners = _emberMetal.hasListeners; - _emberMetal.default.watchedEvents = _emberMetal.watchedEvents; - _emberMetal.default.listenersFor = _emberMetal.listenersFor; - _emberMetal.default.accumulateListeners = _emberMetal.accumulateListeners; - _emberMetal.default.isNone = _emberMetal.isNone; - _emberMetal.default.isEmpty = _emberMetal.isEmpty; - _emberMetal.default.isBlank = _emberMetal.isBlank; - _emberMetal.default.isPresent = _emberMetal.isPresent; - _emberMetal.default.run = _emberMetal.run; - _emberMetal.default._ObserverSet = _emberMetal.ObserverSet; - _emberMetal.default.propertyWillChange = _emberMetal.propertyWillChange; - _emberMetal.default.propertyDidChange = _emberMetal.propertyDidChange; - _emberMetal.default.overrideChains = _emberMetal.overrideChains; - _emberMetal.default.beginPropertyChanges = _emberMetal.beginPropertyChanges; - _emberMetal.default.endPropertyChanges = _emberMetal.endPropertyChanges; - _emberMetal.default.changeProperties = _emberMetal.changeProperties; - _emberMetal.default.platform = { - defineProperty: true, - hasPropertyAccessors: true - }; - _emberMetal.default.defineProperty = _emberMetal.defineProperty; - _emberMetal.default.watchKey = _emberMetal.watchKey; - _emberMetal.default.unwatchKey = _emberMetal.unwatchKey; - _emberMetal.default.removeChainWatcher = _emberMetal.removeChainWatcher; - _emberMetal.default._ChainNode = _emberMetal.ChainNode; - _emberMetal.default.finishChains = _emberMetal.finishChains; - _emberMetal.default.watchPath = _emberMetal.watchPath; - _emberMetal.default.unwatchPath = _emberMetal.unwatchPath; - _emberMetal.default.watch = _emberMetal.watch; - _emberMetal.default.isWatching = _emberMetal.isWatching; - _emberMetal.default.unwatch = _emberMetal.unwatch; - _emberMetal.default.destroy = _emberMetal.destroy; - _emberMetal.default.libraries = _emberMetal.libraries; - _emberMetal.default.OrderedSet = _emberMetal.OrderedSet; - _emberMetal.default.Map = _emberMetal.Map; - _emberMetal.default.MapWithDefault = _emberMetal.MapWithDefault; - _emberMetal.default.getProperties = _emberMetal.getProperties; - _emberMetal.default.setProperties = _emberMetal.setProperties; - _emberMetal.default.expandProperties = _emberMetal.expandProperties; - _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; - _emberMetal.default.addObserver = _emberMetal.addObserver; - _emberMetal.default.observersFor = _emberMetal.observersFor; - _emberMetal.default.removeObserver = _emberMetal.removeObserver; - _emberMetal.default._suspendObserver = _emberMetal._suspendObserver; - _emberMetal.default._suspendObservers = _emberMetal._suspendObservers; - _emberMetal.default.required = _emberMetal.required; - _emberMetal.default.aliasMethod = _emberMetal.aliasMethod; - _emberMetal.default.observer = _emberMetal.observer; - _emberMetal.default.immediateObserver = _emberMetal._immediateObserver; - _emberMetal.default.mixin = _emberMetal.mixin; - _emberMetal.default.Mixin = _emberMetal.Mixin; - _emberMetal.default.bind = _emberMetal.bind; - _emberMetal.default.Binding = _emberMetal.Binding; - _emberMetal.default.isGlobalPath = _emberMetal.isGlobalPath; + DSL.prototype.push = function push(url, name, callback, serialize) { + var parts = name.split('.'); - if (false) { - _emberMetal.default.WeakMap = _emberMetal.WeakMap; - } + if (this.options.engineInfo) { + var localFullName = name.slice(this.options.engineInfo.fullName.length + 1); + var routeInfo = _emberUtils.assign({ localFullName: localFullName }, this.options.engineInfo); - Object.defineProperty(_emberMetal.default, 'ENV', { - get: function () { - return _emberEnvironment.ENV; - }, - enumerable: false - }); + if (serialize) { + routeInfo.serializeMethod = serialize; + } - /** - The context that Ember searches for namespace instances on. - - @private - */ - Object.defineProperty(_emberMetal.default, 'lookup', { - get: function () { - return _emberEnvironment.context.lookup; - }, - set: function (value) { - _emberEnvironment.context.lookup = value; - }, - enumerable: false - }); + this.options.addRouteForEngine(name, routeInfo); + } else if (serialize) { + throw new Error('Defining a route serializer on route \'' + name + '\' outside an Engine is not allowed.'); + } - _emberMetal.default.EXTEND_PROTOTYPES = _emberEnvironment.ENV.EXTEND_PROTOTYPES; + if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { + this.explicitIndex = true; + } - // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS - Object.defineProperty(_emberMetal.default, 'LOG_STACKTRACE_ON_DEPRECATION', { - get: function () { - return _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; - }, - enumerable: false - }); + this.matches.push([url, name, callback]); + }; - Object.defineProperty(_emberMetal.default, 'LOG_VERSION', { - get: function () { - return _emberEnvironment.ENV.LOG_VERSION; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_VERSION = !!value; - }, - enumerable: false - }); + DSL.prototype.resource = function resource(name, options, callback) { + if (options === undefined) options = {}; - Object.defineProperty(_emberMetal.default, 'MODEL_FACTORY_INJECTIONS', { - get: function () { - return _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; - }, - set: function (value) { - _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = !!value; - }, - enumerable: false - }); + if (arguments.length === 2 && typeof options === 'function') { + callback = options; + options = {}; + } - Object.defineProperty(_emberMetal.default, 'LOG_BINDINGS', { - get: function () { - return _emberEnvironment.ENV.LOG_BINDINGS; - }, - set: function (value) { - _emberEnvironment.ENV.LOG_BINDINGS = !!value; - }, - enumerable: false - }); + options.resetNamespace = true; - /** - A function may be assigned to `Ember.onerror` to be called when Ember - internals encounter an error. This is useful for specialized error handling - and reporting code. - - ```javascript - Ember.onerror = function(error) { - Em.$.ajax('/report-error', 'POST', { - stack: error.stack, - otherInformation: 'whatever app state you want to provide' - }); + this.route(name, options, callback); }; - ``` - - Internally, `Ember.onerror` is used as Backburner's error handler. - - @event onerror - @for Ember - @param {Exception} error the error object - @public - */ - Object.defineProperty(_emberMetal.default, 'onerror', { - get: _emberMetal.getOnerror, - set: _emberMetal.setOnerror, - enumerable: false - }); - /** - An empty function useful for some operations. Always returns `this`. - - @method K - @return {Object} - @public - */ - _emberMetal.default.K = function K() { - return this; - }; + DSL.prototype.generate = function generate() { + var dslMatches = this.matches; - Object.defineProperty(_emberMetal.default, 'testing', { - get: _emberMetal.isTesting, - set: _emberMetal.setTesting, - enumerable: false - }); + if (!this.explicitIndex) { + this.route('index', { path: '/' }); + } - if (!_require.has('ember-debug')) { - _emberMetal.default.Debug = { - registerDeprecationHandler: function () {}, - registerWarnHandler: function () {} + return function (match) { + for (var i = 0; i < dslMatches.length; i++) { + var dslMatch = dslMatches[i]; + match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); + } + }; }; - } - - /** - @class Backburner - @for Ember - @private - */ - _emberMetal.default.Backburner = function () { - function BackburnerAlias(args) { - return _backburner.default.apply(this, args); - } + DSL.prototype.mount = function mount(_name) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - BackburnerAlias.prototype = _backburner.default.prototype; + var engineRouteMap = this.options.resolveRouteMap(_name); + var name = _name; - return new BackburnerAlias(arguments); - }; + if (options.as) { + name = options.as; + } - _emberMetal.default._Backburner = _backburner.default; + var fullName = getFullName(this, name, options.resetNamespace); - _emberMetal.default.Logger = _emberConsole.default; + var engineInfo = { + name: _name, + instanceId: uuid++, + mountPoint: fullName, + fullName: fullName + }; - // ****ember-runtime**** + var path = options.path; - _emberMetal.default.String = _emberRuntime.String; - _emberMetal.default.Object = _emberRuntime.Object; - _emberMetal.default._RegistryProxyMixin = _emberRuntime.RegistryProxyMixin; - _emberMetal.default._ContainerProxyMixin = _emberRuntime.ContainerProxyMixin; - _emberMetal.default.compare = _emberRuntime.compare; - _emberMetal.default.copy = _emberRuntime.copy; - _emberMetal.default.isEqual = _emberRuntime.isEqual; - _emberMetal.default.inject = _emberRuntime.inject; - _emberMetal.default.Array = _emberRuntime.Array; - _emberMetal.default.Comparable = _emberRuntime.Comparable; - _emberMetal.default.Enumerable = _emberRuntime.Enumerable; - _emberMetal.default.ArrayProxy = _emberRuntime.ArrayProxy; - _emberMetal.default.ObjectProxy = _emberRuntime.ObjectProxy; - _emberMetal.default.ActionHandler = _emberRuntime.ActionHandler; - _emberMetal.default.CoreObject = _emberRuntime.CoreObject; - _emberMetal.default.NativeArray = _emberRuntime.NativeArray; - _emberMetal.default.Copyable = _emberRuntime.Copyable; - _emberMetal.default.Freezable = _emberRuntime.Freezable; - _emberMetal.default.FROZEN_ERROR = _emberRuntime.FROZEN_ERROR; - _emberMetal.default.MutableEnumerable = _emberRuntime.MutableEnumerable; - _emberMetal.default.MutableArray = _emberRuntime.MutableArray; - _emberMetal.default.TargetActionSupport = _emberRuntime.TargetActionSupport; - _emberMetal.default.Evented = _emberRuntime.Evented; - _emberMetal.default.PromiseProxyMixin = _emberRuntime.PromiseProxyMixin; - _emberMetal.default.Observable = _emberRuntime.Observable; - _emberMetal.default.typeOf = _emberRuntime.typeOf; - _emberMetal.default.isArray = _emberRuntime.isArray; - _emberMetal.default.Object = _emberRuntime.Object; - _emberMetal.default.onLoad = _emberRuntime.onLoad; - _emberMetal.default.runLoadHooks = _emberRuntime.runLoadHooks; - _emberMetal.default.Controller = _emberRuntime.Controller; - _emberMetal.default.ControllerMixin = _emberRuntime.ControllerMixin; - _emberMetal.default.Service = _emberRuntime.Service; - _emberMetal.default._ProxyMixin = _emberRuntime._ProxyMixin; - _emberMetal.default.RSVP = _emberRuntime.RSVP; - _emberMetal.default.Namespace = _emberRuntime.Namespace; + if (typeof path !== 'string') { + path = '/' + name; + } - // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed - computed.empty = _emberRuntime.empty; - computed.notEmpty = _emberRuntime.notEmpty; - computed.none = _emberRuntime.none; - computed.not = _emberRuntime.not; - computed.bool = _emberRuntime.bool; - computed.match = _emberRuntime.match; - computed.equal = _emberRuntime.equal; - computed.gt = _emberRuntime.gt; - computed.gte = _emberRuntime.gte; - computed.lt = _emberRuntime.lt; - computed.lte = _emberRuntime.lte; - computed.oneWay = _emberRuntime.oneWay; - computed.reads = _emberRuntime.oneWay; - computed.readOnly = _emberRuntime.readOnly; - computed.deprecatingAlias = _emberRuntime.deprecatingAlias; - computed.and = _emberRuntime.and; - computed.or = _emberRuntime.or; - computed.any = _emberRuntime.any; + var callback = undefined; + var dummyErrorRoute = '/_unused_dummy_error_path_route_' + name + '/:error'; + if (engineRouteMap) { + var shouldResetEngineInfo = false; + var oldEngineInfo = this.options.engineInfo; + if (oldEngineInfo) { + shouldResetEngineInfo = true; + this.options.engineInfo = engineInfo; + } - computed.sum = _emberRuntime.sum; - computed.min = _emberRuntime.min; - computed.max = _emberRuntime.max; - computed.map = _emberRuntime.map; - computed.sort = _emberRuntime.sort; - computed.setDiff = _emberRuntime.setDiff; - computed.mapBy = _emberRuntime.mapBy; - computed.filter = _emberRuntime.filter; - computed.filterBy = _emberRuntime.filterBy; - computed.uniq = _emberRuntime.uniq; + var optionsForChild = _emberUtils.assign({ engineInfo: engineInfo }, this.options); + var childDSL = new DSL(fullName, optionsForChild); - if (true) { - computed.uniqBy = _emberRuntime.uniqBy; - } - computed.union = _emberRuntime.union; - computed.intersect = _emberRuntime.intersect; - computed.collect = _emberRuntime.collect; + createRoute(childDSL, 'loading'); + createRoute(childDSL, 'error', { path: dummyErrorRoute }); - /** - Defines the hash of localized strings for the current language. Used by - the `Ember.String.loc()` helper. To localize, add string values to this - hash. - - @property STRINGS - @for Ember - @type Object - @private - */ - Object.defineProperty(_emberMetal.default, 'STRINGS', { - configurable: false, - get: _emberRuntime.getStrings, - set: _emberRuntime.setStrings - }); + engineRouteMap.class.call(childDSL); - /** - Whether searching on the global for new Namespace instances is enabled. - - This is only exported here as to not break any addons. Given the new - visit API, you will have issues if you treat this as a indicator of - booted. - - Internally this is only exposing a flag in Namespace. - - @property BOOTED - @for Ember - @type Boolean - @private - */ - Object.defineProperty(_emberMetal.default, 'BOOTED', { - configurable: false, - enumerable: false, - get: _emberRuntime.isNamespaceSearchDisabled, - set: _emberRuntime.setNamespaceSearchDisabled - }); + callback = childDSL.generate(); - _emberMetal.default.Component = _emberGlimmer.Component; - _emberGlimmer.Helper.helper = _emberGlimmer.helper; - _emberMetal.default.Helper = _emberGlimmer.Helper; - _emberMetal.default.Checkbox = _emberGlimmer.Checkbox; - _emberMetal.default.TextField = _emberGlimmer.TextField; - _emberMetal.default.TextArea = _emberGlimmer.TextArea; - _emberMetal.default.LinkComponent = _emberGlimmer.LinkComponent; + if (shouldResetEngineInfo) { + this.options.engineInfo = oldEngineInfo; + } + } - if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { - String.prototype.htmlSafe = function () { - return _emberGlimmer.htmlSafe(this); + var localFullName = 'application'; + var routeInfo = _emberUtils.assign({ localFullName: localFullName }, engineInfo); + + if (this.enableLoadingSubstates) { + // These values are important to register the loading routes under their + // proper names for the Router and within the Engine's registry. + var substateName = name + '_loading'; + var _localFullName = 'application_loading'; + var _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); + createRoute(this, substateName, { resetNamespace: options.resetNamespace }); + this.options.addRouteForEngine(substateName, _routeInfo); + + substateName = name + '_error'; + _localFullName = 'application_error'; + _routeInfo = _emberUtils.assign({ localFullName: _localFullName }, engineInfo); + createRoute(this, substateName, { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); + this.options.addRouteForEngine(substateName, _routeInfo); + } + + this.options.addRouteForEngine(fullName, routeInfo); + + this.push(path, fullName, callback); }; + + return DSL; + })(); + + exports.default = DSL; + + function canNest(dsl) { + return dsl.parent && dsl.parent !== 'application'; } - var EmberHandlebars = _emberMetal.default.Handlebars = _emberMetal.default.Handlebars || {}; - var EmberHTMLBars = _emberMetal.default.HTMLBars = _emberMetal.default.HTMLBars || {}; - var EmberHandleBarsUtils = EmberHandlebars.Utils = EmberHandlebars.Utils || {}; + function getFullName(dsl, name, resetNamespace) { + if (canNest(dsl) && resetNamespace !== true) { + return dsl.parent + '.' + name; + } else { + return name; + } + } - Object.defineProperty(EmberHandlebars, 'SafeString', { - get: _emberGlimmer._getSafeString - }); + function createRoute(dsl, name, options, callback) { + if (options === undefined) options = {}; - EmberHTMLBars.template = EmberHandlebars.template = _emberGlimmer.template; - EmberHandleBarsUtils.escapeExpression = _emberGlimmer.escapeExpression; - _emberRuntime.String.htmlSafe = _emberGlimmer.htmlSafe; + var fullName = getFullName(dsl, name, options.resetNamespace); - if (true) { - _emberRuntime.String.isHTMLSafe = _emberGlimmer.isHTMLSafe; + if (typeof options.path !== 'string') { + options.path = '/' + name; + } + + dsl.push(options.path, fullName, callback, options.serialize); } - EmberHTMLBars.makeBoundHelper = _emberGlimmer.makeBoundHelper; + + DSL.map = function (callback) { + var dsl = new DSL(); + callback.call(dsl); + return dsl; + }; +}); +enifed('ember-routing/system/generate_controller', ['exports', 'ember-metal', 'container'], function (exports, _emberMetal, _container) { + 'use strict'; + + exports.generateControllerFactory = generateControllerFactory; + exports.default = generateController; /** - Global hash of shared templates. This will automatically be populated - by the build tools so that you can store your Handlebars templates in - separate files that get loaded into JavaScript at buildtime. + @module ember + @submodule ember-routing + */ + + /** + Generates a controller factory - @property TEMPLATES - @for Ember - @type Object - @private - */ - Object.defineProperty(_emberMetal.default, 'TEMPLATES', { - get: _emberGlimmer.getTemplates, - set: _emberGlimmer.setTemplates, - configurable: false, - enumerable: false - }); + @for Ember + @method generateControllerFactory + @private + */ - exports.VERSION = _emberVersion.default; + function generateControllerFactory(owner, controllerName, context) { + var Factory = owner[_container.FACTORY_FOR]('controller:basic').class; - /** - The semantic version - @property VERSION - @type String - @public - */ - _emberMetal.default.VERSION = _emberVersion.default; + Factory = Factory.extend({ + toString: function () { + return '(generated ' + controllerName + ' controller)'; + } + }); - _emberMetal.libraries.registerCoreLibrary('Ember', _emberVersion.default); + var fullName = 'controller:' + controllerName; - _emberMetal.default.create = _emberMetal.deprecateFunc('Ember.create is deprecated in favor of Object.create', { id: 'ember-metal.ember-create', until: '3.0.0' }, Object.create); - _emberMetal.default.keys = _emberMetal.deprecateFunc('Ember.keys is deprecated in favor of Object.keys', { id: 'ember-metal.ember.keys', until: '3.0.0' }, Object.keys); + owner.register(fullName, Factory); - // require the main entry points for each of these packages - // this is so that the global exports occur properly + return Factory; + } /** - Alias for jQuery + Generates and instantiates a controller extending from `controller:basic` + if present, or `Ember.Controller` if not. - @method $ - @for Ember - @public - */ - _emberMetal.default.$ = _emberViews.jQuery; + @for Ember + @method generateController + @private + @since 1.3.0 + */ - _emberMetal.default.ViewTargetActionSupport = _emberViews.ViewTargetActionSupport; + function generateController(owner, controllerName) { + generateControllerFactory(owner, controllerName); - _emberMetal.default.ViewUtils = { - isSimpleClick: _emberViews.isSimpleClick, - getViewElement: _emberViews.getViewElement, - getViewBounds: _emberViews.getViewBounds, - getViewClientRects: _emberViews.getViewClientRects, - getViewBoundingClientRect: _emberViews.getViewBoundingClientRect, - getRootViews: _emberViews.getRootViews, - getChildViews: _emberViews.getChildViews - }; + var fullName = 'controller:' + controllerName; + var instance = owner.lookup(fullName); - _emberMetal.default.TextSupport = _emberViews.TextSupport; - _emberMetal.default.ComponentLookup = _emberViews.ComponentLookup; - _emberMetal.default.EventDispatcher = _emberViews.EventDispatcher; + return instance; + } +}); +enifed('ember-routing/system/query_params', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { + 'use strict'; - _emberMetal.default.Location = _emberRouting.Location; - _emberMetal.default.AutoLocation = _emberRouting.AutoLocation; - _emberMetal.default.HashLocation = _emberRouting.HashLocation; - _emberMetal.default.HistoryLocation = _emberRouting.HistoryLocation; - _emberMetal.default.NoneLocation = _emberRouting.NoneLocation; - _emberMetal.default.controllerFor = _emberRouting.controllerFor; - _emberMetal.default.generateControllerFactory = _emberRouting.generateControllerFactory; - _emberMetal.default.generateController = _emberRouting.generateController; - _emberMetal.default.RouterDSL = _emberRouting.RouterDSL; - _emberMetal.default.Router = _emberRouting.Router; - _emberMetal.default.Route = _emberRouting.Route; + exports.default = _emberRuntime.Object.extend({ + isQueryParams: true, + values: null + }); +}); +enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-routing/system/generate_controller', 'ember-routing/utils', 'container'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberRoutingSystemGenerate_controller, _emberRoutingUtils, _container) { + 'use strict'; - _emberMetal.default.Application = _emberApplication.Application; - _emberMetal.default.ApplicationInstance = _emberApplication.ApplicationInstance; - _emberMetal.default.Engine = _emberApplication.Engine; - _emberMetal.default.EngineInstance = _emberApplication.EngineInstance; - _emberMetal.default.DefaultResolver = _emberMetal.default.Resolver = _emberApplication.Resolver; + exports.defaultSerialize = defaultSerialize; + exports.hasDefaultSerialize = hasDefaultSerialize; + var slice = Array.prototype.slice; - _emberRuntime.runLoadHooks('Ember.Application', _emberApplication.Application); + function K() { + return this; + } - _emberMetal.default.DataAdapter = _emberExtensionSupport.DataAdapter; - _emberMetal.default.ContainerDebugAdapter = _emberExtensionSupport.ContainerDebugAdapter; + function defaultSerialize(model, params) { + if (params.length < 1 || !model) { + return; + } - if (_require.has('ember-template-compiler')) { - _require.default('ember-template-compiler'); - } + var name = params[0]; + var object = {}; - // do this to ensure that Ember.Test is defined properly on the global - // if it is present. - if (_require.has('ember-testing')) { - var testing = _require.default('ember-testing'); + if (params.length === 1) { + if (name in model) { + object[name] = _emberMetal.get(model, name); + } else if (/_id$/.test(name)) { + object[name] = _emberMetal.get(model, 'id'); + } + } else { + object = _emberMetal.getProperties(model, params); + } - _emberMetal.default.Test = testing.Test; - _emberMetal.default.Test.Adapter = testing.Adapter; - _emberMetal.default.Test.QUnitAdapter = testing.QUnitAdapter; - _emberMetal.default.setupForTesting = testing.setupForTesting; + return object; } - _emberRuntime.runLoadHooks('Ember'); + var DEFAULT_SERIALIZE = _emberUtils.symbol('DEFAULT_SERIALIZE'); + + defaultSerialize[DEFAULT_SERIALIZE] = true; + + function hasDefaultSerialize(route) { + return !!route.serialize[DEFAULT_SERIALIZE]; + } /** @module ember + @submodule ember-routing */ - exports.default = _emberMetal.default; - /* globals module */ - if (typeof module === 'object' && module.exports) { - module.exports = _emberMetal.default; - } else { - _emberEnvironment.context.exports.Ember = _emberEnvironment.context.exports.Em = _emberMetal.default; - } -}); + /** + The `Ember.Route` class is used to define individual routes. Refer to + the [routing guide](http://emberjs.com/guides/routing/) for documentation. + + @class Route + @namespace Ember + @extends Ember.Object + @uses Ember.ActionHandler + @uses Ember.Evented + @since 1.0.0 + @public + */ + var Route = _emberRuntime.Object.extend(_emberRuntime.ActionHandler, _emberRuntime.Evented, { + /** + Configuration hash for this route's queryParams. The possible + configuration options and their defaults are as follows + (assuming a query param whose controller property is `page`): + ```javascript + queryParams: { + page: { + // By default, controller query param properties don't + // cause a full transition when they are changed, but + // rather only cause the URL to update. Setting + // `refreshModel` to true will cause an "in-place" + // transition to occur, whereby the model hooks for + // this route (and any child routes) will re-fire, allowing + // you to reload models (e.g., from the server) using the + // updated query param values. + refreshModel: false, + // By default, changes to controller query param properties + // cause the URL to update via `pushState`, which means an + // item will be added to the browser's history, allowing + // you to use the back button to restore the app to the + // previous state before the query param property was changed. + // Setting `replace` to true will use `replaceState` (or its + // hash location equivalent), which causes no browser history + // item to be added. This options name and default value are + // the same as the `link-to` helper's `replace` option. + replace: false, + // By default, the query param URL key is the same name as + // the controller property name. Use `as` to specify a + // different URL key. + as: 'page' + } + } + ``` + @property queryParams + @for Ember.Route + @type Object + @since 1.6.0 + @public + */ + queryParams: {}, -// ****ember-environment**** + /** + The name of the route, dot-delimited. + For example, a route found at `app/routes/posts/post.js` will have + a `routeName` of `posts.post`. + @property routeName + @for Ember.Route + @type String + @since 1.0.0 + @public + */ -// ****ember-metal**** + /** + Sets the name for this route, including a fully resolved name for routes + inside engines. + @private + @method _setRouteName + @param {String} name + */ + _setRouteName: function (name) { + this.routeName = name; + this.fullRouteName = getEngineRouteName(_emberUtils.getOwner(this), name); + }, -// computed macros + /** + Populates the QP meta information in the BucketCache. + @private + @method _populateQPMeta + */ + _populateQPMeta: function () { + this._bucketCache.stash('route-meta', this.fullRouteName, this.get('_qp')); + }, -// reduced computed macros -enifed("ember/version", ["exports"], function (exports) { - "use strict"; + /** + @private + @property _qp + */ + _qp: _emberMetal.computed(function () { + var _this = this; - exports.default = "2.11.0-beta.2"; -}); -enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { - 'use strict'; + var controllerProto = undefined, + combinedQueryParameterConfiguration = undefined; - exports.default = applyMixins; + var controllerName = this.controllerName || this.routeName; + var owner = _emberUtils.getOwner(this); + var definedControllerClass = owner[_container.LOOKUP_FACTORY]('controller:' + controllerName); + var queryParameterConfiguraton = _emberMetal.get(this, 'queryParams'); + var hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; - function isGenerator(mixin) { - return Array.isArray(mixin.cases) && typeof mixin.generate === 'function'; - } + if (definedControllerClass) { + // the developer has authored a controller class in their application for this route + // access the prototype, find its query params and normalize their object shape + // them merge in the query params for the route. As a mergedProperty, Route#queryParams is always + // at least `{}` + controllerProto = definedControllerClass.proto(); - function applyMixins(TestClass) { - for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - mixins[_key - 1] = arguments[_key]; - } + var controllerDefinedQueryParameterConfiguration = _emberMetal.get(controllerProto, 'queryParams'); + var normalizedControllerQueryParameterConfiguration = _emberRoutingUtils.normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); + combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton); + } else if (hasRouterDefinedQueryParams) { + // the developer has not defined a controller but *has* supplied route query params. + // Generate a class for them so we can later insert default values + var generatedControllerClass = _emberRoutingSystemGenerate_controller.generateControllerFactory(_emberUtils.getOwner(this), controllerName); + controllerProto = generatedControllerClass.proto(); + combinedQueryParameterConfiguration = queryParameterConfiguraton; + } - mixins.forEach(function (mixinOrGenerator) { - var mixin = undefined; + var qps = []; + var map = {}; + var propertyNames = []; - if (isGenerator(mixinOrGenerator)) { - (function () { - var generator = mixinOrGenerator; - mixin = {}; + for (var propName in combinedQueryParameterConfiguration) { + if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { + continue; + } - generator.cases.forEach(function (value, idx) { - _emberUtils.assign(mixin, generator.generate(value, idx)); - }); - })(); - } else { - mixin = mixinOrGenerator; + // to support the dubious feature of using unknownProperty + // on queryParams configuration + if (propName === 'unknownProperty' || propName === '_super') { + // possible todo: issue deprecation warning? + continue; + } + + var desc = combinedQueryParameterConfiguration[propName]; + var scope = desc.scope || 'model'; + var parts = undefined; + + if (scope === 'controller') { + parts = []; + } + + var urlKey = desc.as || this.serializeQueryParamKey(propName); + var defaultValue = _emberMetal.get(controllerProto, propName); + + if (Array.isArray(defaultValue)) { + defaultValue = _emberRuntime.A(defaultValue.slice()); + } + + var type = desc.type || _emberRuntime.typeOf(defaultValue); + + var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); + var scopedPropertyName = controllerName + ':' + propName; + var qp = { + undecoratedDefaultValue: _emberMetal.get(controllerProto, propName), + defaultValue: defaultValue, + serializedDefaultValue: defaultValueSerialized, + serializedValue: defaultValueSerialized, + + type: type, + urlKey: urlKey, + prop: propName, + scopedPropertyName: scopedPropertyName, + controllerName: controllerName, + route: this, + parts: parts, // provided later when stashNames is called if 'model' scope + values: null, // provided later when setup is called. no idea why. + scope: scope + }; + + map[propName] = map[urlKey] = map[scopedPropertyName] = qp; + qps.push(qp); + propertyNames.push(propName); + } + + return { + qps: qps, + map: map, + propertyNames: propertyNames, + states: { + /* + Called when a query parameter changes in the URL, this route cares + about that query parameter, but the route is not currently + in the active route hierarchy. + */ + inactive: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + }, + /* + Called when a query parameter changes in the URL, this route cares + about that query parameter, and the route is currently + in the active route hierarchy. + */ + active: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + return _this._activeQPChanged(map[prop], value); + }, + /* + Called when a value of a query parameter this route handles changes in a controller + and the route is currently in the active route hierarchy. + */ + allowOverrides: function (prop, value) { + var qp = map[prop]; + _this._qpChanged(prop, value, qp); + return _this._updatingQPChanged(map[prop]); + } + } + }; + }), + + /** + @private + @property _names + */ + _names: null, + + /** + @private + @method _stashNames + */ + _stashNames: function (handlerInfo, dynamicParent) { + if (this._names) { + return; + } + var names = this._names = handlerInfo._names; + + if (!names.length) { + handlerInfo = dynamicParent; + names = handlerInfo && handlerInfo._names || []; } - _emberUtils.assign(TestClass.prototype, mixin); - }); + var qps = _emberMetal.get(this, '_qp.qps'); - return TestClass; - } -}); -enifed('internal-test-helpers/build-owner', ['exports', 'container', 'ember-routing', 'ember-application', 'ember-runtime'], function (exports, _container, _emberRouting, _emberApplication, _emberRuntime) { - 'use strict'; + var namePaths = new Array(names.length); + for (var a = 0; a < names.length; ++a) { + namePaths[a] = handlerInfo.name + '.' + names[a]; + } - exports.default = buildOwner; + for (var i = 0; i < qps.length; ++i) { + var qp = qps[i]; + if (qp.scope === 'model') { + qp.parts = namePaths; + } + } + }, - function buildOwner() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + /** + @private + @property _activeQPChanged + */ + _activeQPChanged: function (qp, value) { + var router = this.router; + router._activeQPChanged(qp.scopedPropertyName, value); + }, - var ownerOptions = options.ownerOptions || {}; - var resolver = options.resolver; - var bootOptions = options.bootOptions || {}; + /** + @private + @method _updatingQPChanged + */ + _updatingQPChanged: function (qp) { + var router = this.router; + router._updatingQPChanged(qp.urlKey); + }, - var Owner = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin); + mergedProperties: ['queryParams'], - var namespace = _emberRuntime.Object.create({ - Resolver: { create: function () { - return resolver; - } } - }); + /** + Returns a hash containing the parameters of an ancestor route. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('member', { path: ':name' }, function() { + this.route('interest', { path: ':interest' }); + }); + }); + ``` + ```app/routes/member.js + export default Ember.Route.extend({ + queryParams: { + memberQp: { refreshModel: true } + } + }); + ``` + ```app/routes/member/interest.js + export default Ember.Route.extend({ + queryParams: { + interestQp: { refreshModel: true } + }, + model() { + return this.paramsFor('member'); + } + }); + ``` + If we visit `/turing/maths?memberQp=member&interestQp=interest` the model for + the `member.interest` route is hash with: + * `name`: `turing` + * `memberQp`: `member` + @method paramsFor + @param {String} name + @return {Object} hash containing the parameters of the route `name` + @since 1.4.0 + @public + */ + paramsFor: function (name) { + var route = _emberUtils.getOwner(this).lookup('route:' + name); - var fallbackRegistry = _emberApplication.Application.buildRegistry(namespace); - fallbackRegistry.register('router:main', _emberRouting.Router); + if (!route) { + return {}; + } - var registry = new _container.Registry({ - fallback: fallbackRegistry - }); + var transition = this.router.router.activeTransition; + var state = transition ? transition.state : this.router.router.state; - _emberApplication.ApplicationInstance.setupRegistry(registry, bootOptions); + var fullName = route.fullRouteName; + var params = _emberUtils.assign({}, state.params[fullName]); + var queryParams = getQueryParamsFor(route, state); - var owner = Owner.create({ - __registry__: registry, - __container__: null - }, ownerOptions); + return Object.keys(queryParams).reduce(function (params, key) { + params[key] = queryParams[key]; + return params; + }, params); + }, - var container = registry.container({ owner: owner }); - owner.__container__ = container; + /** + Serializes the query parameter key + @method serializeQueryParamKey + @param {String} controllerPropertyName + @private + */ + serializeQueryParamKey: function (controllerPropertyName) { + return controllerPropertyName; + }, - return owner; - } -}); -enifed('internal-test-helpers/confirm-export', ['exports', 'require'], function (exports, _require) { - 'use strict'; + /** + Serializes value of the query parameter based on defaultValueType + @method serializeQueryParam + @param {Object} value + @param {String} urlKey + @param {String} defaultValueType + @private + */ + serializeQueryParam: function (value, urlKey, defaultValueType) { + // urlKey isn't used here, but anyone overriding + // can use it to provide serialization specific + // to a certain query param. + return this.router._serializeQueryParam(value, defaultValueType); + }, - exports.default = confirmExport; + /** + Deserializes value of the query parameter based on defaultValueType + @method deserializeQueryParam + @param {Object} value + @param {String} urlKey + @param {String} defaultValueType + @private + */ + deserializeQueryParam: function (value, urlKey, defaultValueType) { + // urlKey isn't used here, but anyone overriding + // can use it to provide deserialization specific + // to a certain query param. + return this.router._deserializeQueryParam(value, defaultValueType); + }, - function getDescriptor(obj, path) { - var parts = path.split('.'); - var value = obj; - for (var i = 0; i < parts.length - 1; i++) { - var part = parts[i]; - value = value[part]; - if (!value) { - return undefined; - } - } - var last = parts[parts.length - 1]; - return Object.getOwnPropertyDescriptor(value, last); - } + /** + @private + @property _optionsForQueryParam + */ + _optionsForQueryParam: function (qp) { + return _emberMetal.get(this, 'queryParams.' + qp.urlKey) || _emberMetal.get(this, 'queryParams.' + qp.prop) || {}; + }, - function confirmExport(Ember, assert, path, moduleId, exportName) { - var desc = getDescriptor(Ember, path); - assert.ok(desc, 'the property exists on the global'); + /** + A hook you can use to reset controller values either when the model + changes or the route is exiting. + ```app/routes/articles.js + import Ember from 'ember'; + export default Ember.Route.extend({ + resetController(controller, isExiting, transition) { + if (isExiting) { + controller.set('page', 1); + } + } + }); + ``` + @method resetController + @param {Controller} controller instance + @param {Boolean} isExiting + @param {Object} transition + @since 1.7.0 + @public + */ + resetController: K, - var mod = _require.default(moduleId); - if (typeof exportName === 'string') { - assert.equal(desc.value, mod[exportName], 'Ember.' + path + ' is exported correctly'); - assert.notEqual(mod[exportName], undefined, 'Ember.' + path + ' is not `undefined`'); - } else { - assert.equal(desc.get, mod[exportName.get], 'Ember.' + path + ' getter is exported correctly'); - assert.notEqual(desc.get, undefined, 'Ember.' + path + ' getter is not undefined'); + /** + @private + @method exit + */ + exit: function () { + this.deactivate(); + this.trigger('deactivate'); + this.teardownViews(); + }, - if (exportName.set) { - assert.equal(desc.set, mod[exportName.set], 'Ember.' + path + ' setter is exported correctly'); - assert.notEqual(desc.set, undefined, 'Ember.' + path + ' setter is not undefined'); - } - } - } -}); -enifed('internal-test-helpers/equal-inner-html', ['exports'], function (exports) { - // detect side-effects of cloning svg elements in IE9-11 - 'use strict'; + /** + @private + @method _reset + @since 1.7.0 + */ + _reset: function (isExiting, transition) { + var controller = this.controller; + controller._qpDelegate = _emberMetal.get(this, '_qp.states.inactive'); - exports.default = equalInnerHTML; - var ieSVGInnerHTML = (function () { - if (!document.createElementNS) { - return false; - } - var div = document.createElement('div'); - var node = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - div.appendChild(node); - var clone = div.cloneNode(true); - return clone.innerHTML === ''; - })(); + this.resetController(controller, isExiting, transition); + }, - function normalizeInnerHTML(actualHTML) { - if (ieSVGInnerHTML) { - // Replace `` with ``, etc. - // drop namespace attribute - actualHTML = actualHTML.replace(/ xmlns="[^"]+"/, ''); - // replace self-closing elements - actualHTML = actualHTML.replace(/<([^ >]+) [^\/>]*\/>/gi, function (tag, tagName) { - return tag.slice(0, tag.length - 3) + '>'; + /** + @private + @method enter + */ + enter: function () { + this.connections = []; + this.activate(); + this.trigger('activate'); + }, + + /** + The name of the template to use by default when rendering this routes + template. + ```app/routes/posts/list.js + import Ember from 'ember'; + export default Ember.Route.extend({ + templateName: 'posts/list' }); - } + ``` + ```app/routes/posts/index.js + import PostsList from '../posts/list'; + export default PostsList.extend(); + ``` + ```app/routes/posts/archived.js + import PostsList from '../posts/list'; + export default PostsList.extend(); + ``` + @property templateName + @type String + @default null + @since 1.4.0 + @public + */ + templateName: null, - return actualHTML; - } + /** + The name of the controller to associate with this route. + By default, Ember will lookup a route's controller that matches the name + of the route (i.e. `App.PostController` for `App.PostRoute`). However, + if you would like to define a specific controller to use, you can do so + using this property. + This is useful in many ways, as the controller specified will be: + * passed to the `setupController` method. + * used as the controller for the template being rendered by the route. + * returned from a call to `controllerFor` for the route. + @property controllerName + @type String + @default null + @since 1.4.0 + @public + */ + controllerName: null, - function equalInnerHTML(fragment, html) { - var actualHTML = normalizeInnerHTML(fragment.innerHTML); - QUnit.push(actualHTML === html, actualHTML, html); - } -}); -enifed('internal-test-helpers/equal-tokens', ['exports', 'simple-html-tokenizer'], function (exports, _simpleHtmlTokenizer) { - 'use strict'; + /** + The `willTransition` action is fired at the beginning of any + attempted transition with a `Transition` object as the sole + argument. This action can be used for aborting, redirecting, + or decorating the transition from the currently active routes. + A good example is preventing navigation when a form is + half-filled out: + ```app/routes/contact-form.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + willTransition(transition) { + if (this.controller.get('userHasEnteredData')) { + this.controller.displayNavigationConfirm(); + transition.abort(); + } + } + } + }); + ``` + You can also redirect elsewhere by calling + `this.transitionTo('elsewhere')` from within `willTransition`. + Note that `willTransition` will not be fired for the + redirecting `transitionTo`, since `willTransition` doesn't + fire when there is already a transition underway. If you want + subsequent `willTransition` actions to fire for the redirecting + transition, you must first explicitly call + `transition.abort()`. + To allow the `willTransition` event to continue bubbling to the parent + route, use `return true;`. When the `willTransition` method has a + return value of `true` then the parent route's `willTransition` method + will be fired, enabling "bubbling" behavior for the event. + @event willTransition + @param {Transition} transition + @since 1.0.0 + @public + */ - exports.default = equalTokens; + /** + The `didTransition` action is fired after a transition has + successfully been completed. This occurs after the normal model + hooks (`beforeModel`, `model`, `afterModel`, `setupController`) + have resolved. The `didTransition` action has no arguments, + however, it can be useful for tracking page views or resetting + state on the controller. + ```app/routes/login.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + didTransition() { + this.controller.get('errors.base').clear(); + return true; // Bubble the didTransition event + } + } + }); + ``` + @event didTransition + @since 1.2.0 + @public + */ - function generateTokens(containerOrHTML) { - if (typeof containerOrHTML === 'string') { - return { - tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML), - html: containerOrHTML - }; - } else { - return { - tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML.innerHTML), - html: containerOrHTML.innerHTML - }; - } - } + /** + The `loading` action is fired on the route when a route's `model` + hook returns a promise that is not already resolved. The current + `Transition` object is the first parameter and the route that + triggered the loading event is the second parameter. + ```app/routes/application.js + export default Ember.Route.extend({ + actions: { + loading(transition, route) { + let controller = this.controllerFor('foo'); + controller.set('currentlyLoading', true); + transition.finally(function() { + controller.set('currentlyLoading', false); + }); + } + } + }); + ``` + @event loading + @param {Transition} transition + @param {Ember.Route} route The route that triggered the loading event + @since 1.2.0 + @public + */ - function normalizeTokens(tokens) { - tokens.forEach(function (token) { - if (token.type === 'StartTag') { - token.attributes = token.attributes.sort(function (a, b) { - if (a[0] > b[0]) { - return 1; + /** + When attempting to transition into a route, any of the hooks + may return a promise that rejects, at which point an `error` + action will be fired on the partially-entered routes, allowing + for per-route error handling logic, or shared error handling + logic defined on a parent route. + Here is an example of an error handler that will be invoked + for rejected promises from the various hooks on the route, + as well as any unhandled errors from child routes: + ```app/routes/admin.js + import Ember from 'ember'; + export default Ember.Route.extend({ + beforeModel() { + return Ember.RSVP.reject('bad things!'); + }, + actions: { + error(error, transition) { + // Assuming we got here due to the error in `beforeModel`, + // we can expect that error === "bad things!", + // but a promise model rejecting would also + // call this hook, as would any errors encountered + // in `afterModel`. + // The `error` hook is also provided the failed + // `transition`, which can be stored and later + // `.retry()`d if desired. + this.transitionTo('login'); } - if (a[0] < b[0]) { - return -1; + } + }); + ``` + `error` actions that bubble up all the way to `ApplicationRoute` + will fire a default error handler that logs the error. You can + specify your own global default error handler by overriding the + `error` handler on `ApplicationRoute`: + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + error(error, transition) { + this.controllerFor('banner').displayError(error.message); + } + } + }); + ``` + @event error + @param {Error} error + @param {Transition} transition + @since 1.0.0 + @public + */ + + /** + This event is triggered when the router enters the route. It is + not executed when the model for the route changes. + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + collectAnalytics: Ember.on('activate', function(){ + collectAnalytics(); + }) + }); + ``` + @event activate + @since 1.9.0 + @public + */ + + /** + This event is triggered when the router completely exits this + route. It is not executed when the model for the route changes. + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + trackPageLeaveAnalytics: Ember.on('deactivate', function(){ + trackPageLeaveAnalytics(); + }) + }); + ``` + @event deactivate + @since 1.9.0 + @public + */ + + /** + The controller associated with this route. + Example + ```app/routes/form.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + willTransition(transition) { + if (this.controller.get('userHasEnteredData') && + !confirm('Are you sure you want to abandon progress?')) { + transition.abort(); + } else { + // Bubble the `willTransition` action so that + // parent routes can decide whether or not to abort. + return true; + } } - return 0; - }); - } - }); - } - - function equalTokens(actualContainer, expectedHTML) { - var message = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + } + }); + ``` + @property controller + @type Ember.Controller + @since 1.6.0 + @public + */ - var actual = generateTokens(actualContainer); - var expected = generateTokens(expectedHTML); + actions: { - normalizeTokens(actual.tokens); - normalizeTokens(expected.tokens); + /** + This action is called when one or more query params have changed. Bubbles. + @method queryParamsDidChange + @param changed {Object} Keys are names of query params that have changed. + @param totalPresent {Object} Keys are names of query params that are currently set. + @param removed {Object} Keys are names of query params that have been removed. + @returns {boolean} + @private + */ + queryParamsDidChange: function (changed, totalPresent, removed) { + var qpMap = _emberMetal.get(this, '_qp').map; - var equiv = QUnit.equiv(actual.tokens, expected.tokens); + var totalChanged = Object.keys(changed).concat(Object.keys(removed)); + for (var i = 0; i < totalChanged.length; ++i) { + var qp = qpMap[totalChanged[i]]; + if (qp && _emberMetal.get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) { + this.refresh(); + break; + } + } - if (equiv && expected.html !== actual.html) { - deepEqual(actual.tokens, expected.tokens, message); - } else { - QUnit.push(QUnit.equiv(actual.tokens, expected.tokens), actual.html, expected.html, message); - } - } -}); -enifed('internal-test-helpers/factory', ['exports'], function (exports) { - 'use strict'; + return true; + }, - exports.default = factory; - function setProperties(object, properties) { - for (var key in properties) { - if (properties.hasOwnProperty(key)) { - object[key] = properties[key]; - } - } - } + finalizeQueryParamChange: function (params, finalParams, transition) { + if (this.fullRouteName !== 'application') { + return true; + } - var guids = 0; + // Transition object is absent for intermediate transitions. + if (!transition) { + return; + } - function factory() { - /*jshint validthis: true */ + var handlerInfos = transition.state.handlerInfos; + var router = this.router; + var qpMeta = router._queryParamsFor(handlerInfos); + var changes = router._qpUpdates; + var replaceUrl = undefined; - function Klass(options) { - setProperties(this, options); - this._guid = guids++; - this.isDestroyed = false; - } + _emberRoutingUtils.stashParamNames(router, handlerInfos); - Klass.prototype.constructor = Klass; - Klass.prototype.destroy = function () { - this.isDestroyed = true; - }; + for (var i = 0; i < qpMeta.qps.length; ++i) { + var qp = qpMeta.qps[i]; + var route = qp.route; + var controller = route.controller; + var presentKey = qp.urlKey in params && qp.urlKey; - Klass.prototype.toString = function () { - return ''; - }; + // Do a reverse lookup to see if the changed query + // param URL key corresponds to a QP property on + // this controller. + var value = undefined, + svalue = undefined; + if (changes && qp.urlKey in changes) { + // Value updated in/before setupController + value = _emberMetal.get(controller, qp.prop); + svalue = route.serializeQueryParam(value, qp.urlKey, qp.type); + } else { + if (presentKey) { + svalue = params[presentKey]; + value = route.deserializeQueryParam(svalue, qp.urlKey, qp.type); + } else { + // No QP provided; use default value. + svalue = qp.serializedDefaultValue; + value = copyDefaultValue(qp.defaultValue); + } + } - Klass.create = create; - Klass.extend = extend; - Klass.reopen = extend; - Klass.reopenClass = reopenClass; + controller._qpDelegate = _emberMetal.get(route, '_qp.states.inactive'); - return Klass; + var thisQueryParamChanged = svalue !== qp.serializedValue; + if (thisQueryParamChanged) { + if (transition.queryParamsOnly && replaceUrl !== false) { + var options = route._optionsForQueryParam(qp); + var replaceConfigValue = _emberMetal.get(options, 'replace'); + if (replaceConfigValue) { + replaceUrl = true; + } else if (replaceConfigValue === false) { + // Explicit pushState wins over any other replaceStates. + replaceUrl = false; + } + } - function create(options) { - return new this.prototype.constructor(options); - } + _emberMetal.set(controller, qp.prop, value); + } - function reopenClass(options) { - setProperties(this, options); - } + // Stash current serialized value of controller. + qp.serializedValue = svalue; - function extend(options) { - function Child(options) { - Klass.call(this, options); - } + var thisQueryParamHasDefaultValue = qp.serializedDefaultValue === svalue; + if (!thisQueryParamHasDefaultValue) { + finalParams.push({ + value: svalue, + visible: true, + key: presentKey || qp.urlKey + }); + } + } - var Parent = this; + if (replaceUrl) { + transition.method('replace'); + } - Child.prototype = new Parent(); - Child.prototype.constructor = Child; + qpMeta.qps.forEach(function (qp) { + var routeQpMeta = _emberMetal.get(qp.route, '_qp'); + var finalizedController = qp.route.controller; + finalizedController._qpDelegate = _emberMetal.get(routeQpMeta, 'states.active'); + }); - setProperties(Child, Klass); - setProperties(Child.prototype, options); + router._qpUpdates = null; + } + }, - Child.create = create; - Child.extend = extend; - Child.reopen = extend; + /** + This hook is executed when the router completely exits this route. It is + not executed when the model for the route changes. + @method deactivate + @since 1.0.0 + @public + */ + deactivate: K, - Child.reopenClass = reopenClass; + /** + This hook is executed when the router enters the route. It is not executed + when the model for the route changes. + @method activate + @since 1.0.0 + @public + */ + activate: K, - return Child; - } - } -}); -enifed('internal-test-helpers/index', ['exports', 'internal-test-helpers/factory', 'internal-test-helpers/build-owner', 'internal-test-helpers/confirm-export', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/module-for', 'internal-test-helpers/strip', 'internal-test-helpers/apply-mixins', 'internal-test-helpers/matchers', 'internal-test-helpers/run', 'internal-test-helpers/test-groups', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/test-cases/abstract-application', 'internal-test-helpers/test-cases/application', 'internal-test-helpers/test-cases/query-param', 'internal-test-helpers/test-cases/abstract-rendering', 'internal-test-helpers/test-cases/rendering'], function (exports, _internalTestHelpersFactory, _internalTestHelpersBuildOwner, _internalTestHelpersConfirmExport, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersModuleFor, _internalTestHelpersStrip, _internalTestHelpersApplyMixins, _internalTestHelpersMatchers, _internalTestHelpersRun, _internalTestHelpersTestGroups, _internalTestHelpersTestCasesAbstract, _internalTestHelpersTestCasesAbstractApplication, _internalTestHelpersTestCasesApplication, _internalTestHelpersTestCasesQueryParam, _internalTestHelpersTestCasesAbstractRendering, _internalTestHelpersTestCasesRendering) { - 'use strict'; + /** + Transition the application into another route. The route may + be either a single route or route path: + ```javascript + this.transitionTo('blogPosts'); + this.transitionTo('blogPosts.recentEntries'); + ``` + Optionally supply a model for the route in question. The model + will be serialized into the URL using the `serialize` hook of + the route: + ```javascript + this.transitionTo('blogPost', aPost); + ``` + If a literal is passed (such as a number or a string), it will + be treated as an identifier instead. In this case, the `model` + hook of the route will be triggered: + ```javascript + this.transitionTo('blogPost', 1); + ``` + Multiple models will be applied last to first recursively up the + route tree. + ```app/routes.js + // ... + Router.map(function() { + this.route('blogPost', { path:':blogPostId' }, function() { + this.route('blogComment', { path: ':blogCommentId' }); + }); + }); + export default Router; + ``` + ```javascript + this.transitionTo('blogComment', aPost, aComment); + this.transitionTo('blogComment', 1, 13); + ``` + It is also possible to pass a URL (a string that starts with a + `/`). This is intended for testing and debugging purposes and + should rarely be used in production code. + ```javascript + this.transitionTo('/'); + this.transitionTo('/blog/post/1/comment/13'); + this.transitionTo('/blog/posts?sort=title'); + ``` + An options hash with a `queryParams` property may be provided as + the final argument to add query parameters to the destination URL. + ```javascript + this.transitionTo('blogPost', 1, { + queryParams: { showComments: 'true' } + }); + // if you just want to transition the query parameters without changing the route + this.transitionTo({ queryParams: { sort: 'date' } }); + ``` + See also [replaceWith](#method_replaceWith). + Simple Transition Example + ```app/routes.js + // ... + Router.map(function() { + this.route('index'); + this.route('secret'); + this.route('fourOhFour', { path: '*:' }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember': + export Ember.Route.extend({ + actions: { + moveToSecret(context) { + if (authorized()) { + this.transitionTo('secret', context); + } else { + this.transitionTo('fourOhFour'); + } + } + } + }); + ``` + Transition to a nested route + ```app/router.js + // ... + Router.map(function() { + this.route('articles', { path: '/articles' }, function() { + this.route('new'); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + transitionToNewArticle() { + this.transitionTo('articles.new'); + } + } + }); + ``` + Multiple Models Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('breakfast', { path: ':breakfastId' }, function() { + this.route('cereal', { path: ':cerealId' }); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + moveToChocolateCereal() { + let cereal = { cerealId: 'ChocolateYumminess' }; + let breakfast = { breakfastId: 'CerealAndMilk' }; + this.transitionTo('breakfast.cereal', breakfast, cereal); + } + } + }); + ``` + Nested Route with Query String Example + ```app/routes.js + // ... + Router.map(function() { + this.route('fruits', function() { + this.route('apples'); + }); + }); + export default Router; + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + transitionToApples() { + this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); + } + } + }); + ``` + @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 + @since 1.0.0 + @public + */ + transitionTo: function (name, context) { + var router = this.router; + return router.transitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - exports.factory = _internalTestHelpersFactory.default; - exports.buildOwner = _internalTestHelpersBuildOwner.default; - exports.confirmExport = _internalTestHelpersConfirmExport.default; - exports.equalInnerHTML = _internalTestHelpersEqualInnerHtml.default; - exports.equalTokens = _internalTestHelpersEqualTokens.default; - exports.moduleFor = _internalTestHelpersModuleFor.default; - exports.strip = _internalTestHelpersStrip.default; - exports.applyMixins = _internalTestHelpersApplyMixins.default; - exports.equalsElement = _internalTestHelpersMatchers.equalsElement; - exports.classes = _internalTestHelpersMatchers.classes; - exports.styles = _internalTestHelpersMatchers.styles; - exports.regex = _internalTestHelpersMatchers.regex; - exports.runAppend = _internalTestHelpersRun.runAppend; - exports.runDestroy = _internalTestHelpersRun.runDestroy; - exports.testBoth = _internalTestHelpersTestGroups.testBoth; - exports.testWithDefault = _internalTestHelpersTestGroups.testWithDefault; - exports.AbstractTestCase = _internalTestHelpersTestCasesAbstract.default; - exports.AbstractApplicationTestCase = _internalTestHelpersTestCasesAbstractApplication.default; - exports.ApplicationTestCase = _internalTestHelpersTestCasesApplication.default; - exports.QueryParamTestCase = _internalTestHelpersTestCasesQueryParam.default; - exports.AbstractRenderingTestCase = _internalTestHelpersTestCasesAbstractRendering.default; - exports.RenderingTestCase = _internalTestHelpersTestCasesRendering.default; -}); -enifed('internal-test-helpers/matchers', ['exports'], function (exports) { - 'use strict'; + /** + Perform a synchronous transition into another route without attempting + to resolve promises, update the URL, or abort any currently active + asynchronous transitions (i.e. regular transitions caused by + `transitionTo` or URL changes). + This method is handy for performing intermediate transitions on the + way to a final destination route, and is called internally by the + default implementations of the `error` and `loading` handlers. + @method intermediateTransitionTo + @param {String} name the name of the route + @param {...Object} models the model(s) to be used while transitioning + to the route. + @since 1.2.0 + @public + */ + intermediateTransitionTo: function () { + var router = this.router; + router.intermediateTransitionTo.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - exports.regex = regex; - exports.classes = classes; - exports.styles = styles; - exports.equalsElement = equalsElement; - var HTMLElement = window.HTMLElement; - var MATCHER_BRAND = '3d4ef194-13be-4ccf-8dc7-862eea02c93e'; + /** + Refresh the model on this route and any child routes, firing the + `beforeModel`, `model`, and `afterModel` hooks in a similar fashion + to how routes are entered when transitioning in from other route. + The current route params (e.g. `article_id`) will be passed in + to the respective model hooks, and if a different model is returned, + `setupController` and associated route hooks will re-fire as well. + An example usage of this method is re-querying the server for the + latest information using the same parameters as when the route + was first entered. + Note that this will cause `model` hooks to fire even on routes + that were provided a model object when the route was initially + entered. + @method refresh + @return {Transition} the transition object associated with this + attempted transition + @since 1.4.0 + @public + */ + refresh: function () { + return this.router.router.refresh(this); + }, - function isMatcher(obj) { - return typeof obj === 'object' && obj !== null && MATCHER_BRAND in obj; - } + /** + Transition into another route while replacing the current URL, if possible. + This will replace the current history entry instead of adding a new one. + Beside that, it is identical to `transitionTo` in all other respects. See + 'transitionTo' for additional information regarding multiple models. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('secret'); + }); + export default Router; + ``` + ```app/routes/secret.js + import Ember from 'ember'; + export default Ember.Route.extend({ + afterModel() { + if (!authorized()){ + this.replaceWith('index'); + } + } + }); + ``` + @method replaceWith + @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. + @return {Transition} the transition object associated with this + attempted transition + @since 1.0.0 + @public + */ + replaceWith: function () { + var router = this.router; + return router.replaceWith.apply(router, _emberRoutingUtils.prefixRouteNameArg(this, arguments)); + }, - function equalsAttr(expected) { - var _ref; + /** + Sends an action to the router, which will delegate it to the currently + active route hierarchy per the bubbling rules explained under `actions`. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + }); + export default Router; + ``` + ```app/routes/application.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + track(arg) { + console.log(arg, 'was clicked'); + } + } + }); + ``` + ```app/routes/index.js + import Ember from 'ember'; + export default Ember.Route.extend({ + actions: { + trackIfDebug(arg) { + if (debug) { + this.send('track', arg); + } + } + } + }); + ``` + @method send + @param {String} name the name of the action to trigger + @param {...*} args + @since 1.0.0 + @public + */ + send: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - return _ref = {}, _ref[MATCHER_BRAND] = true, _ref.match = function (actual) { - return expected === actual; - }, _ref.expected = function () { - return expected; - }, _ref.message = function () { - return 'should equal ' + this.expected(); - }, _ref; - } + if (this.router && this.router.router || !_emberMetal.isTesting()) { + var _router; - function regex(r) { - var _ref2; + (_router = this.router).send.apply(_router, args); + } else { + var _name2 = args[0]; + args = slice.call(args, 1); + var action = this.actions[_name2]; + if (action) { + return this.actions[_name2].apply(this, args); + } + } + }, - return _ref2 = {}, _ref2[MATCHER_BRAND] = true, _ref2.match = function (v) { - return r.test(v); - }, _ref2.expected = function () { - return r.toString(); - }, _ref2.message = function () { - return 'should match ' + this.expected(); - }, _ref2; - } + /** + This hook is the entry point for router.js + @private + @method setup + */ + setup: function (context, transition) { + var _this2 = this; - function classes(expected) { - var _ref3; + var controller = undefined; - return _ref3 = {}, _ref3[MATCHER_BRAND] = true, _ref3.match = function (actual) { - actual = actual.trim(); - return actual && expected.split(/\s+/).sort().join(' ') === actual.trim().split(/\s+/).sort().join(' '); - }, _ref3.expected = function () { - return expected; - }, _ref3.message = function () { - return 'should match ' + this.expected(); - }, _ref3; - } + var controllerName = this.controllerName || this.routeName; + var definedController = this.controllerFor(controllerName, true); - function styles(expected) { - var _ref4; + if (!definedController) { + controller = this.generateController(controllerName); + } else { + controller = definedController; + } - return _ref4 = {}, _ref4[MATCHER_BRAND] = true, _ref4.match = function (actual) { - // coerce `null` or `undefined` to an empty string - // needed for matching empty styles on IE9 - IE11 - actual = actual || ''; - actual = actual.trim(); + // Assign the route's controller so that it can more easily be + // referenced in action handlers. Side effects. Side effects everywhere. + if (!this.controller) { + var propNames = _emberMetal.get(this, '_qp.propertyNames'); + addQueryParamsObservers(controller, propNames); + this.controller = controller; + } - return expected.split(';').map(function (s) { - return s.trim(); - }).filter(function (s) { - return s; - }).sort().join('; ') === actual.split(';').map(function (s) { - return s.trim(); - }).filter(function (s) { - return s; - }).sort().join('; '); - }, _ref4.expected = function () { - return expected; - }, _ref4.message = function () { - return 'should match ' + this.expected(); - }, _ref4; - } + var queryParams = _emberMetal.get(this, '_qp'); - function equalsElement(element, tagName, attributes, content) { - QUnit.push(element.tagName === tagName.toUpperCase(), element.tagName.toLowerCase(), tagName, 'expect tagName to be ' + tagName); + var states = queryParams.states; - var expectedAttrs = {}; - var expectedCount = 0; + controller._qpDelegate = states.allowOverrides; - for (var _name in attributes) { - var expected = attributes[_name]; - if (expected !== null) { - expectedCount++; - } + if (transition) { + (function () { + // Update the model dep values used to calculate cache keys. + _emberRoutingUtils.stashParamNames(_this2.router, transition.state.handlerInfos); - var matcher = isMatcher(expected) ? expected : equalsAttr(expected); + var params = transition.params; + var allParams = queryParams.propertyNames; + var cache = _this2._bucketCache; - expectedAttrs[_name] = matcher; + allParams.forEach(function (prop) { + var aQp = queryParams.map[prop]; - QUnit.push(expectedAttrs[_name].match(element.getAttribute(_name)), element.getAttribute(_name), matcher.expected(), 'Element\'s ' + _name + ' attribute ' + matcher.message()); - } + aQp.values = params; + var cacheKey = _emberRoutingUtils.calculateCacheKey(aQp.route.fullRouteName, aQp.parts, aQp.values); - var actualAttributes = {}; + if (cache) { + var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); + _emberMetal.set(controller, prop, value); + } + }); + })(); + } - for (var i = 0, l = element.attributes.length; i < l; i++) { - actualAttributes[element.attributes[i].name] = element.attributes[i].value; - } + if (transition) { + var qpValues = getQueryParamsFor(this, transition.state); + controller.setProperties(qpValues); + } - if (!(element instanceof HTMLElement)) { - QUnit.push(element instanceof HTMLElement, null, null, 'Element must be an HTML Element, not an SVG Element'); - } else { - QUnit.push(element.attributes.length === expectedCount || !attributes, element.attributes.length, expectedCount, 'Expected ' + expectedCount + ' attributes; got ' + element.outerHTML); + this.setupController(controller, context, transition); - if (content !== null) { - QUnit.push(element.innerHTML === content, element.innerHTML, content, 'The element had \'' + content + '\' as its content'); + if (this._environment.options.shouldRender) { + this.renderTemplate(controller, context); } - } - } -}); -enifed('internal-test-helpers/module-for', ['exports', 'internal-test-helpers/apply-mixins'], function (exports, _internalTestHelpersApplyMixins) { - 'use strict'; - - exports.default = moduleFor; + }, - function moduleFor(description, TestClass) { - var context = undefined; + /* + Called when a query parameter for this route changes, regardless of whether the route + is currently part of the active route hierarchy. This will update the query parameter's + value in the cache so if this route becomes active, the cache value has been updated. + */ + _qpChanged: function (prop, value, qp) { + if (!qp) { + return; + } - QUnit.module(description, { - setup: function () { - context = new TestClass(); - }, + var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.route.fullRouteName, qp.parts, qp.values); - teardown: function () { - context.teardown(); + // Update model-dep cache + var cache = this._bucketCache; + if (cache) { + cache.stash(cacheKey, prop, value); } - }); + }, - for (var _len = arguments.length, mixins = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - mixins[_key - 2] = arguments[_key]; - } + /** + This hook is the first of the route entry validation hooks + called when an attempt is made to transition into a route + or one of its children. It is called before `model` and + `afterModel`, and is appropriate for cases when: + 1) A decision can be made to redirect elsewhere without + needing to resolve the model first. + 2) Any async operations need to occur first before the + model is attempted to be resolved. + This hook is provided the current `transition` attempt + as a parameter, which can be used to `.abort()` the transition, + save it for a later `.retry()`, or retrieve values set + on it from a previous hook. You can also just call + `this.transitionTo` to another route to implicitly + abort the `transition`. + You can return a promise from this hook to pause the + transition until the promise resolves (or rejects). This could + be useful, for instance, for retrieving async code from + the server that is required to enter a route. + @method beforeModel + @param {Transition} transition + @return {Promise} if the value returned from this hook is + a promise, the transition will pause until the transition + resolves. Otherwise, non-promise return values are not + utilized in any way. + @since 1.0.0 + @public + */ + beforeModel: K, - _internalTestHelpersApplyMixins.default(TestClass, mixins); + /** + This hook is called after this route's model has resolved. + It follows identical async/promise semantics to `beforeModel` + but is provided the route's resolved model in addition to + the `transition`, and is therefore suited to performing + logic that can only take place after the model has already + resolved. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + afterModel(posts, transition) { + if (posts.get('length') === 1) { + this.transitionTo('post.show', posts.get('firstObject')); + } + } + }); + ``` + Refer to documentation for `beforeModel` for a description + of transition-pausing semantics when a promise is returned + from this hook. + @method afterModel + @param {Object} resolvedModel the value returned from `model`, + or its resolved value if it was a promise + @param {Transition} transition + @return {Promise} if the value returned from this hook is + a promise, the transition will pause until the transition + resolves. Otherwise, non-promise return values are not + utilized in any way. + @since 1.0.0 + @public + */ + afterModel: K, - var proto = TestClass.prototype; + /** + A hook you can implement to optionally redirect to another route. + If you call `this.transitionTo` from inside of this hook, this route + will not be entered in favor of the other hook. + `redirect` and `afterModel` behave very similarly and are + called almost at the same time, but they have an important + distinction in the case that, from one of these hooks, a + redirect into a child route of this route occurs: redirects + from `afterModel` essentially invalidate the current attempt + to enter this route, and will result in this route's `beforeModel`, + `model`, and `afterModel` hooks being fired again within + the new, redirecting transition. Redirects that occur within + the `redirect` hook, on the other hand, will _not_ cause + these hooks to be fired again the second time around; in + other words, by the time the `redirect` hook has been called, + both the resolved model and attempted entry into this route + are considered to be fully validated. + @method redirect + @param {Object} model the model for this route + @param {Transition} transition the transition object associated with the current transition + @since 1.0.0 + @public + */ + redirect: K, - while (proto !== Object.prototype) { - Object.keys(proto).forEach(generateTest); - proto = Object.getPrototypeOf(proto); - } + /** + Called when the context is changed by router.js. + @private + @method contextDidChange + */ + contextDidChange: function () { + this.currentModel = this.context; + }, - function generateTest(name) { - if (name.indexOf('@test ') === 0) { - QUnit.test(name.slice(5), function (assert) { - return context[name](assert); - }); - } else if (name.indexOf('@skip ') === 0) { - QUnit.skip(name.slice(5), function (assert) { - return context[name](assert); - }); - } - } - } -}); -enifed('internal-test-helpers/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { - 'use strict'; + /** + A hook you can implement to convert the URL into the model for + this route. + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); + }); + export default Router; + ``` + The model for the `post` route is `store.findRecord('post', params.post_id)`. + By default, if your route has a dynamic segment ending in `_id`: + * The model class is determined from the segment (`post_id`'s + class is `App.Post`) + * The find method is called on the model class with the value of + the dynamic segment. + Note that for routes with dynamic segments, this hook is not always + executed. If the route is entered through a transition (e.g. when + using the `link-to` Handlebars helper or the `transitionTo` method + of routes), and a model context is already provided this hook + is not called. + A model context does not include a primitive string or number, + which does cause the model hook to be called. + Routes without dynamic segments will always execute the model hook. + ```javascript + // no dynamic segment, model hook always called + this.transitionTo('posts'); + // model passed in, so model hook not called + thePost = store.findRecord('post', 1); + this.transitionTo('post', thePost); + // integer passed in, model hook is called + this.transitionTo('post', 1); + // model id passed in, model hook is called + // useful for forcing the hook to execute + thePost = store.findRecord('post', 1); + this.transitionTo('post', thePost.id); + ``` + This hook follows the asynchronous/promise semantics + described in the documentation for `beforeModel`. In particular, + if a promise returned from `model` fails, the error will be + handled by the `error` hook on `Ember.Route`. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model(params) { + return this.store.findRecord('post', params.post_id); + } + }); + ``` + @method model + @param {Object} params the parameters extracted from the URL + @param {Transition} transition + @return {Object|Promise} the model for this route. If + a promise is returned, the transition will pause until + the promise resolves, and the resolved value of the promise + will be used as the model for this route. + @since 1.0.0 + @public + */ + model: function (params, transition) { + var name = undefined, + sawParams = undefined, + value = undefined; + var queryParams = _emberMetal.get(this, '_qp.map'); - exports.runAppend = runAppend; - exports.runDestroy = runDestroy; + for (var prop in params) { + if (prop === 'queryParams' || queryParams && prop in queryParams) { + continue; + } - function runAppend(view) { - _emberMetal.run(view, 'appendTo', '#qunit-fixture'); - } + var match = prop.match(/^(.*)_id$/); + if (match) { + name = match[1]; + value = params[prop]; + } + sawParams = true; + } - function runDestroy(toDestroy) { - if (toDestroy) { - _emberMetal.run(toDestroy, 'destroy'); - } - } -}); -enifed('internal-test-helpers/strip', ['exports'], function (exports) { - 'use strict'; + if (!name && sawParams) { + return _emberRuntime.copy(params); + } else if (!name) { + if (transition.resolveIndex < 1) { + return; + } - exports.default = strip; + return transition.state.handlerInfos[transition.resolveIndex - 1].context; + } - function strip(_ref) { - for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - values[_key - 1] = arguments[_key]; - } + return this.findModel(name, value); + }, - var strings = _ref; + /** + @private + @method deserialize + @param {Object} params the parameters extracted from the URL + @param {Transition} transition + @return {Object|Promise} the model for this route. + Router.js hook. + */ + deserialize: function (params, transition) { + return this.model(this.paramsFor(this.routeName), transition); + }, - var str = strings.map(function (string, index) { - var interpolated = values[index]; - return string + (interpolated !== undefined ? interpolated : ''); - }).join(''); - return str.split('\n').map(function (s) { - return s.trim(); - }).join(''); - } -}); -enifed('internal-test-helpers/test-cases/abstract-application', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-routing', 'ember-template-compiler', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/run'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberRouting, _emberTemplateCompiler, _internalTestHelpersTestCasesAbstract, _internalTestHelpersRun) { - 'use strict'; + /** + @method findModel + @param {String} type the model type + @param {Object} value the value passed to find + @private + */ + findModel: function () { + var store = _emberMetal.get(this, 'store'); + return store.find.apply(store, arguments); + }, - var AbstractApplicationTestCase = (function (_AbstractTestCase) { - babelHelpers.inherits(AbstractApplicationTestCase, _AbstractTestCase); + /** + Store property provides a hook for data persistence libraries to inject themselves. + By default, this store property provides the exact same functionality previously + in the model hook. + Currently, the required interface is: + `store.find(modelName, findArguments)` + @method store + @param {Object} store + @private + */ + store: _emberMetal.computed(function () { + var owner = _emberUtils.getOwner(this); + var routeName = this.routeName; + var namespace = _emberMetal.get(this, 'router.namespace'); - function AbstractApplicationTestCase() { - _AbstractTestCase.call(this); + return { + find: function (name, value) { + var modelClass = owner[_container.FACTORY_FOR]('model:' + name); - this.element = _emberViews.jQuery('#qunit-fixture')[0]; + if (!modelClass) { + return; + } - this.application = _emberMetal.run(_emberApplication.Application, 'create', this.applicationOptions); + modelClass = modelClass.class; - this.router = this.application.Router = _emberRouting.Router.extend(this.routerOptions); + return modelClass.find(value); + } + }; + }), - this.applicationInstance = null; - } + /** + A hook you can implement to convert the route's model into parameters + for the URL. + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); + }); + ``` + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model(params) { + // the server returns `{ id: 12 }` + return Ember.$.getJSON('/posts/' + params.post_id); + }, + serialize(model) { + // this will make the URL `/posts/12` + return { post_id: model.id }; + } + }); + ``` + The default `serialize` method will insert the model's `id` into the + route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'. + If the route has multiple dynamic segments or does not contain '_id', `serialize` + will return `Ember.getProperties(model, params)` + This method is called when `transitionTo` is called with a context + in order to populate the URL. + @method serialize + @param {Object} model the routes model + @param {Array} params an Array of parameter names for the current + route (in the example, `['post_id']`. + @return {Object} the serialized parameters + @since 1.0.0 + @public + */ + serialize: defaultSerialize, - AbstractApplicationTestCase.prototype.teardown = function teardown() { - if (this.applicationInstance) { - _internalTestHelpersRun.runDestroy(this.applicationInstance); + /** + A hook you can use to setup the controller for the current route. + This method is called with the controller for the current route and the + model supplied by the `model` hook. + By default, the `setupController` hook sets the `model` property of + the controller to the `model`. + If you implement the `setupController` hook in your Route, it will + prevent this default behavior. If you want to preserve that behavior + when implementing your `setupController` function, make sure to call + `_super`: + ```app/routes/photos.js + import Ember from 'ebmer'; + export default Ember.Route.extend({ + model() { + return this.store.findAll('photo'); + }, + setupController(controller, model) { + // Call _super for default behavior + this._super(controller, model); + // Implement your custom setup after + this.controllerFor('application').set('showingPhotos', true); + } + }); + ``` + The provided controller will be one resolved based on the name + of this route. + If no explicit controller is defined, Ember will automatically create one. + As an example, consider the router: + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }); + }); + export default Router; + ``` + For the `post` route, a controller named `App.PostController` would + be used if it is defined. If it is not defined, a basic `Ember.Controller` + instance would be used. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, model) { + controller.set('model', model); + } + }); + ``` + @method setupController + @param {Controller} controller instance + @param {Object} model + @since 1.0.0 + @public + */ + setupController: function (controller, context, transition) { + if (controller && context !== undefined) { + _emberMetal.set(controller, 'model', context); } + }, - _internalTestHelpersRun.runDestroy(this.application); - }; - - AbstractApplicationTestCase.prototype.visit = function visit(url, options) { - var _this = this; - - var applicationInstance = this.applicationInstance; + /** + Returns the resolved model of the current route, or a parent (or any ancestor) + route in a route hierarchy. + The controller instance must already have been created, either through entering the + associated route or using `generateController`. + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, post) { + this._super(controller, post); + this.controllerFor('posts').set('currentPost', post); + } + }); + ``` + @method controllerFor + @param {String} name the name of the route or controller + @return {Ember.Controller} + @since 1.0.0 + @public + */ + controllerFor: function (name, _skipAssert) { + var owner = _emberUtils.getOwner(this); + var route = owner.lookup('route:' + name); + var controller = undefined; - if (applicationInstance) { - return _emberMetal.run(applicationInstance, 'visit', url, options); - } else { - return _emberMetal.run(this.application, 'visit', url, options).then(function (instance) { - _this.applicationInstance = instance; - }); + if (route && route.controllerName) { + name = route.controllerName; } - }; - AbstractApplicationTestCase.prototype.transitionTo = function transitionTo() { - return _emberMetal.run.apply(undefined, [this.appRouter, 'transitionTo'].concat(babelHelpers.slice.call(arguments))); - }; + controller = owner.lookup('controller:' + name); - AbstractApplicationTestCase.prototype.compile = function compile(string, options) { - return _emberTemplateCompiler.compile.apply(undefined, arguments); - }; + // NOTE: We're specifically checking that skipAssert is true, because according + // to the old API the second parameter was model. We do not want people who + // passed a model to skip the assertion. - AbstractApplicationTestCase.prototype.registerRoute = function registerRoute(name, route) { - this.application.register('route:' + name, route); - }; + return controller; + }, - AbstractApplicationTestCase.prototype.registerTemplate = function registerTemplate(name, template) { - this.application.register('template:' + name, this.compile(template, { - moduleName: name - })); - }; + /** + Generates a controller for a route. + Example + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + setupController(controller, post) { + this._super(controller, post); + this.generateController('posts'); + } + }); + ``` + @method generateController + @param {String} name the name of the controller + @private + */ + generateController: function (name) { + var owner = _emberUtils.getOwner(this); - AbstractApplicationTestCase.prototype.registerComponent = function registerComponent(name, _ref) { - var _ref$ComponentClass = _ref.ComponentClass; - var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; - var _ref$template = _ref.template; - var template = _ref$template === undefined ? null : _ref$template; + return _emberRoutingSystemGenerate_controller.default(owner, name); + }, - if (ComponentClass) { - this.application.register('component:' + name, ComponentClass); - } + /** + Returns the resolved model of a parent (or any ancestor) route + in a route hierarchy. During a transition, all routes + must resolve a model object, and if a route + needs access to a parent route's model in order to + resolve a model (or just reuse the model from a parent), + it can call `this.modelFor(theNameOfParentRoute)` to + retrieve it. If the ancestor route's model was a promise, + its resolved result is returned. + Example + ```app/router.js + // ... + Router.map(function() { + this.route('post', { path: '/posts/:post_id' }, function() { + this.route('comments'); + }); + }); + export default Router; + ``` + ```app/routes/comments.js + import Ember from 'ember'; + export default Ember.Route.extend({ + model() { + let post = this.modelFor('post'); + return post.get('comments'); + } + }); + ``` + @method modelFor + @param {String} name the name of the route + @return {Object} the model object + @since 1.0.0 + @public + */ + modelFor: function (_name) { + var name = undefined; + var owner = _emberUtils.getOwner(this); - if (typeof template === 'string') { - this.application.register('template:components/' + name, this.compile(template, { - moduleName: 'components/' + name - })); + // Only change the route name when there is an active transition. + // Otherwise, use the passed in route name. + if (owner.routable && this.router && this.router.router.activeTransition) { + name = getEngineRouteName(owner, _name); + } else { + name = _name; } - }; - AbstractApplicationTestCase.prototype.registerController = function registerController(name, controller) { - this.application.register('controller:' + name, controller); - }; - - AbstractApplicationTestCase.prototype.registerEngine = function registerEngine(name, engine) { - this.application.register('engine:' + name, engine); - }; + var route = _emberUtils.getOwner(this).lookup('route:' + name); + var transition = this.router ? this.router.router.activeTransition : null; - babelHelpers.createClass(AbstractApplicationTestCase, [{ - key: 'applicationOptions', - get: function () { - return { - rootElement: '#qunit-fixture', - autoboot: false - }; - } - }, { - key: 'routerOptions', - get: function () { - return { - location: 'none' - }; - } - }, { - key: 'appRouter', - get: function () { - return this.applicationInstance.lookup('router:main'); + // If we are mid-transition, we want to try and look up + // resolved parent contexts on the current transitionEvent. + if (transition) { + var modelLookupName = route && route.routeName || name; + if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { + return transition.resolvedModels[modelLookupName]; + } } - }]); - return AbstractApplicationTestCase; - })(_internalTestHelpersTestCasesAbstract.default); - - exports.default = AbstractApplicationTestCase; -}); -enifed('internal-test-helpers/test-cases/abstract-rendering', ['exports', 'ember-utils', 'ember-template-compiler', 'ember-views', 'ember-glimmer', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/build-owner', 'internal-test-helpers/run'], function (exports, _emberUtils, _emberTemplateCompiler, _emberViews, _emberGlimmer, _internalTestHelpersTestCasesAbstract, _internalTestHelpersBuildOwner, _internalTestHelpersRun) { - 'use strict'; - - var TextNode = window.Text; - var AbstractRenderingTestCase = (function (_AbstractTestCase) { - babelHelpers.inherits(AbstractRenderingTestCase, _AbstractTestCase); + return route && route.currentModel; + }, - function AbstractRenderingTestCase() { - _AbstractTestCase.call(this); - var owner = this.owner = _internalTestHelpersBuildOwner.default({ - ownerOptions: this.getOwnerOptions(), - bootOptions: this.getBootOptions(), - resolver: this.getResolver() + /** + A hook you can use to render the template for the current route. + This method is called with the controller for the current route and the + model supplied by the `model` hook. By default, it renders the route's + template, configured with the controller for the route. + This method can be overridden to set up and render additional or + alternative templates. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate(controller, model) { + let favController = this.controllerFor('favoritePost'); + // Render the `favoritePost` template into + // the outlet `posts`, and display the `favoritePost` + // controller. + this.render('favoritePost', { + outlet: 'posts', + controller: favController + }); + } }); + ``` + @method renderTemplate + @param {Object} controller the route's controller + @param {Object} model the route's model + @since 1.0.0 + @public + */ + renderTemplate: function (controller, model) { + this.render(); + }, - this.renderer = this.owner.lookup('renderer:-dom'); - this.element = _emberViews.jQuery('#qunit-fixture')[0]; - this.component = null; - - owner.register('event_dispatcher:main', _emberViews.EventDispatcher); - owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); - owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); - } - - AbstractRenderingTestCase.prototype.compile = function compile() { - return _emberTemplateCompiler.compile.apply(undefined, arguments); - }; + /** + `render` is used to render a template into a region of another template + (indicated by an `{{outlet}}`). `render` is used both during the entry + phase of routing (via the `renderTemplate` hook) and later in response to + user interaction. + For example, given the following minimal router and templates: + ```app/router.js + // ... + Router.map(function() { + this.route('photos'); + }); + export default Router; + ``` + ```handlebars + +
    + {{outlet "anOutletName"}} +
    + ``` + ```handlebars + +

    Photos

    + ``` + You can render `photos.hbs` into the `"anOutletName"` outlet of + `application.hbs` by calling `render`: + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate() { + this.render('photos', { + into: 'application', + outlet: 'anOutletName' + }) + } + }); + ``` + `render` additionally allows you to supply which `controller` and + `model` objects should be loaded and associated with the rendered template. + ```app/routes/posts.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate(controller, model){ + this.render('posts', { // the template to render, referenced by name + into: 'application', // the template to render into, referenced by name + outlet: 'anOutletName', // the outlet inside `options.template` to render into. + controller: 'someControllerName', // the controller to use for this template, referenced by name + model: model // the model to set on `options.controller`. + }) + } + }); + ``` + The string values provided for the template name, and controller + will eventually pass through to the resolver for lookup. See + Ember.Resolver for how these are mapped to JavaScript objects in your + application. The template to render into needs to be related to either the + current route or one of its ancestors. + Not all options need to be passed to `render`. Default values will be used + based on the name of the route specified in the router or the Route's + `controllerName` and `templateName` properties. + For example: + ```app/router.js + // ... + Router.map(function() { + this.route('index'); + this.route('post', { path: '/posts/:post_id' }); + }); + export default Router; + ``` + ```app/routes/post.js + import Ember from 'ember'; + export default Ember.Route.extend({ + renderTemplate() { + this.render(); // all defaults apply + } + }); + ``` + The name of the route, defined by the router, is `post`. + The following equivalent default options will be applied when + the Route calls `render`: + ```javascript + this.render('post', { // the template name associated with 'post' Route + into: 'application', // the parent route to 'post' Route + outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, + controller: 'post', // the controller associated with the 'post' Route + }) + ``` + By default the controller's `model` will be the route's model, so it does not + need to be passed unless you wish to change which model is being used. + @method render + @param {String} name the name of the template to render + @param {Object} [options] the options + @param {String} [options.into] the template to render into, + referenced by name. Defaults to the parent template + @param {String} [options.outlet] the outlet inside `options.template` to render into. + Defaults to 'main' + @param {String|Object} [options.controller] the controller to use for this template, + referenced by name or as a controller instance. Defaults to the Route's paired controller + @param {Object} [options.model] the model object to set on `options.controller`. + Defaults to the return value of the Route's model hook + @since 1.0.0 + @public + */ + render: function (_name, options) { - AbstractRenderingTestCase.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { - return {}; - }; + var namePassed = typeof _name === 'string' && !!_name; + var isDefaultRender = arguments.length === 0 || _emberMetal.isEmpty(arguments[0]); + var name = undefined; - AbstractRenderingTestCase.prototype.getOwnerOptions = function getOwnerOptions() {}; + if (typeof _name === 'object' && !options) { + name = this.templateName || this.routeName; + options = _name; + } else { + name = _name; + } - AbstractRenderingTestCase.prototype.getBootOptions = function getBootOptions() {}; + var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); + this.connections.push(renderOptions); + _emberMetal.run.once(this.router, '_setOutlets'); + }, - AbstractRenderingTestCase.prototype.getResolver = function getResolver() {}; + /** + Disconnects a view that has been rendered into an outlet. + You may pass any or all of the following options to `disconnectOutlet`: + * `outlet`: the name of the outlet to clear (default: 'main') + * `parentView`: the name of the view containing the outlet to clear + (default: the view rendered by the parent route) + Example: + ```app/routes/application.js + import Ember from 'ember'; + export default App.Route.extend({ + actions: { + showModal(evt) { + this.render(evt.modalName, { + outlet: 'modal', + into: 'application' + }); + }, + hideModal(evt) { + this.disconnectOutlet({ + outlet: 'modal', + parentView: 'application' + }); + } + } + }); + ``` + Alternatively, you can pass the `outlet` name directly as a string. + Example: + ```app/routes/application.js + import Ember from 'ember'; + export default App.Route.extend({ + actions: { + showModal(evt) { + // ... + }, + hideModal(evt) { + this.disconnectOutlet('modal'); + } + } + }); + @method disconnectOutlet + @param {Object|String} options the options hash or outlet name + @since 1.0.0 + @public + */ + disconnectOutlet: function (options) { + var outletName = undefined; + var parentView = undefined; + if (!options || typeof options === 'string') { + outletName = options; + } else { + outletName = options.outlet; + parentView = options.parentView; - AbstractRenderingTestCase.prototype.teardown = function teardown() { - if (this.component) { - _internalTestHelpersRun.runDestroy(this.component); + if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { + throw new _emberMetal.Error('You passed undefined as the outlet name.'); + } } - if (this.owner) { - _internalTestHelpersRun.runDestroy(this.owner); + parentView = parentView && parentView.replace(/\//g, '.'); + outletName = outletName || 'main'; + this._disconnectOutlet(outletName, parentView); + for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { + // This non-local state munging is sadly necessary to maintain + // backward compatibility with our existing semantics, which allow + // any route to disconnectOutlet things originally rendered by any + // other route. This should all get cut in 2.0. + this.router.router.currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); } - }; + }, - AbstractRenderingTestCase.prototype.render = function render(templateStr) { - var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var owner = this.owner; + _disconnectOutlet: function (outletName, parentView) { + var parent = parentRoute(this); + if (parent && parentView === parent.routeName) { + parentView = undefined; + } + for (var i = 0; i < this.connections.length; i++) { + var connection = this.connections[i]; + if (connection.outlet === outletName && connection.into === parentView) { + // This neuters the disconnected outlet such that it doesn't + // render anything, but it leaves an entry in the outlet + // hierarchy so that any existing other renders that target it + // don't suddenly blow up. They will still stick themselves + // into its outlets, which won't render anywhere. All of this + // statefulness should get the machete in 2.0. + this.connections[i] = { + owner: connection.owner, + into: connection.into, + outlet: connection.outlet, + name: connection.name, + controller: undefined, + template: undefined, + ViewClass: undefined + }; + _emberMetal.run.once(this.router, '_setOutlets'); + } + } + }, - owner.register('template:-top-level', this.compile(templateStr, { - moduleName: '-top-level' - })); + willDestroy: function () { + this.teardownViews(); + }, - var attrs = _emberUtils.assign({}, context, { - tagName: '', - layoutName: '-top-level' - }); + /** + @private + @method teardownViews + */ + teardownViews: function () { + if (this.connections && this.connections.length > 0) { + this.connections = []; + _emberMetal.run.once(this.router, '_setOutlets'); + } + } + }); - owner.register('component:-top-level', _emberGlimmer.Component.extend(attrs)); + _emberRuntime.deprecateUnderscoreActions(Route); - this.component = owner.lookup('component:-top-level'); + Route.reopenClass({ + isRouteFactory: true + }); - _internalTestHelpersRun.runAppend(this.component); - }; + function parentRoute(route) { + var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); + return handlerInfo && handlerInfo.handler; + } - AbstractRenderingTestCase.prototype.rerender = function rerender() { - this.component.rerender(); - }; + function handlerInfoFor(route, handlerInfos) { + var offset = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2]; - AbstractRenderingTestCase.prototype.registerHelper = function registerHelper(name, funcOrClassBody) { - var type = typeof funcOrClassBody; + if (!handlerInfos) { + return; + } - if (type === 'function') { - this.owner.register('helper:' + name, _emberGlimmer.helper(funcOrClassBody)); - } else if (type === 'object' && type !== null) { - this.owner.register('helper:' + name, _emberGlimmer.Helper.extend(funcOrClassBody)); - } else { - throw new Error('Cannot register ' + funcOrClassBody + ' as a helper'); + var current = undefined; + for (var i = 0; i < handlerInfos.length; i++) { + current = handlerInfos[i].handler; + if (current === route) { + return handlerInfos[i + offset]; } - }; + } + } - AbstractRenderingTestCase.prototype.registerPartial = function registerPartial(name, template) { - var owner = this.env.owner || this.owner; - if (typeof template === 'string') { - var moduleName = 'template:' + name; - owner.register(moduleName, this.compile(template, { moduleName: moduleName })); - } - }; + function buildRenderOptions(route, namePassed, isDefaultRender, _name, options) { + var into = options && options.into && options.into.replace(/\//g, '.'); + var outlet = options && options.outlet || 'main'; - AbstractRenderingTestCase.prototype.registerComponent = function registerComponent(name, _ref) { - var _ref$ComponentClass = _ref.ComponentClass; - var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; - var _ref$template = _ref.template; - var template = _ref$template === undefined ? null : _ref$template; - var owner = this.owner; + var name = undefined, + templateName = undefined; + if (_name) { + name = _name.replace(/\//g, '.'); + templateName = name; + } else { + name = route.routeName; + templateName = route.templateName || name; + } - if (ComponentClass) { - owner.register('component:' + name, ComponentClass); + var owner = _emberUtils.getOwner(route); + var controller = options && options.controller; + if (!controller) { + if (namePassed) { + controller = owner.lookup('controller:' + name) || route.controllerName || route.routeName; + } else { + controller = route.controllerName || owner.lookup('controller:' + name); } + } - if (typeof template === 'string') { - owner.register('template:components/' + name, this.compile(template, { - moduleName: 'components/' + name - })); + if (typeof controller === 'string') { + var controllerName = controller; + controller = owner.lookup('controller:' + controllerName); + if (!controller) { + throw new _emberMetal.Error('You passed `controller: \'' + controllerName + '\'` into the `render` method, but no such controller could be found.'); } - }; + } - AbstractRenderingTestCase.prototype.registerTemplate = function registerTemplate(name, template) { - var owner = this.owner; + if (options && Object.keys(options).indexOf('outlet') !== -1 && typeof options.outlet === 'undefined') { + throw new _emberMetal.Error('You passed undefined as the outlet name.'); + } - if (typeof template === 'string') { - owner.register('template:' + name, this.compile(template, { - moduleName: name - })); - } else { - throw new Error('Registered template "' + name + '" must be a string'); - } - }; + if (options && options.model) { + controller.set('model', options.model); + } - AbstractRenderingTestCase.prototype.registerService = function registerService(name, klass) { - this.owner.register('service:' + name, klass); - }; + var template = owner.lookup('template:' + templateName); - AbstractRenderingTestCase.prototype.assertTextNode = function assertTextNode(node, text) { - if (!(node instanceof TextNode)) { - throw new Error('Expecting a text node, but got ' + node); - } + var parent = undefined; + if (into && (parent = parentRoute(route)) && into === parent.routeName) { + into = undefined; + } - this.assert.strictEqual(node.textContent, text, 'node.textContent'); + var renderOptions = { + owner: owner, + into: into, + outlet: outlet, + name: name, + controller: controller, + template: template || route._topLevelViewTemplate, + ViewClass: undefined }; - babelHelpers.createClass(AbstractRenderingTestCase, [{ - key: 'context', - get: function () { - return this.component; - } - }]); - return AbstractRenderingTestCase; - })(_internalTestHelpersTestCasesAbstract.default); - - exports.default = AbstractRenderingTestCase; -}); -enifed('internal-test-helpers/test-cases/abstract', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/matchers'], function (exports, _emberUtils, _emberMetal, _emberViews, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersMatchers) { - 'use strict'; - - var TextNode = window.Text; - var HTMLElement = window.HTMLElement; - var Comment = window.Comment; + return renderOptions; + } - function isMarker(node) { - if (node instanceof Comment && node.textContent === '') { - return true; + function getFullQueryParams(router, state) { + if (state.fullQueryParams) { + return state.fullQueryParams; } - if (node instanceof TextNode && node.textContent === '') { - return true; - } + state.fullQueryParams = {}; + _emberUtils.assign(state.fullQueryParams, state.queryParams); - return false; + router._deserializeQueryParams(state.handlerInfos, state.fullQueryParams); + return state.fullQueryParams; } - var AbstractTestCase = (function () { - function AbstractTestCase() { - this.element = null; - this.snapshot = null; - this.assert = QUnit.config.current.assert; - } + function getQueryParamsFor(route, state) { + state.queryParamsFor = state.queryParamsFor || {}; + var name = route.fullRouteName; - AbstractTestCase.prototype.teardown = function teardown() {}; + if (state.queryParamsFor[name]) { + return state.queryParamsFor[name]; + } - AbstractTestCase.prototype.runTask = function runTask(callback) { - _emberMetal.run(callback); - }; + var fullQueryParams = getFullQueryParams(route.router, state); - AbstractTestCase.prototype.runTaskNext = function runTaskNext(callback) { - _emberMetal.run.next(callback); - }; + var params = state.queryParamsFor[name] = {}; - // The following methods require `this.element` to work + // Copy over all the query params for this route/controller into params hash. + var qpMeta = _emberMetal.get(route, '_qp'); + var qps = qpMeta.qps; + for (var i = 0; i < qps.length; ++i) { + // Put deserialized qp on params hash. + var qp = qps[i]; - AbstractTestCase.prototype.nthChild = function nthChild(n) { - var i = 0; - var node = this.element.firstChild; + var qpValueWasPassedIn = (qp.prop in fullQueryParams); + params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.defaultValue); + } - while (node) { - if (!isMarker(node)) { - i++; - } + return params; + } - if (i > n) { - break; - } else { - node = node.nextSibling; - } - } + function copyDefaultValue(value) { + if (Array.isArray(value)) { + return _emberRuntime.A(value.slice()); + } + return value; + } - return node; - }; + /* + Merges all query parameters from a controller with those from + a route, returning a new object and avoiding any mutations to + the existing objects. + */ + function mergeEachQueryParams(controllerQP, routeQP) { + var keysAlreadyMergedOrSkippable = undefined; + var qps = {}; - AbstractTestCase.prototype.$ = function $(sel) { - return sel ? _emberViews.jQuery(sel, this.element) : _emberViews.jQuery(this.element); + keysAlreadyMergedOrSkippable = { + defaultValue: true, + type: true, + scope: true, + as: true }; - AbstractTestCase.prototype.textValue = function textValue() { - return this.$().text(); - }; + // first loop over all controller qps, merging them with any matching route qps + // into a new empty object to avoid mutating. + for (var cqpName in controllerQP) { + if (!controllerQP.hasOwnProperty(cqpName)) { + continue; + } - AbstractTestCase.prototype.takeSnapshot = function takeSnapshot() { - var snapshot = this.snapshot = []; + var newControllerParameterConfiguration = {}; + _emberUtils.assign(newControllerParameterConfiguration, controllerQP[cqpName]); + _emberUtils.assign(newControllerParameterConfiguration, routeQP[cqpName]); - var node = this.element.firstChild; + qps[cqpName] = newControllerParameterConfiguration; - while (node) { - if (!isMarker(node)) { - snapshot.push(node); - } + // allows us to skip this QP when we check route QPs. + keysAlreadyMergedOrSkippable[cqpName] = true; + } - node = node.nextSibling; + // loop over all route qps, skipping those that were merged in the first pass + // because they also appear in controller qps + for (var rqpName in routeQP) { + if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { + continue; } - return snapshot; - }; - - AbstractTestCase.prototype.assertText = function assertText(text) { - this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content should be: `' + text + '`'); - }; + var newRouteParameterConfiguration = {}; + _emberUtils.assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); + qps[rqpName] = newRouteParameterConfiguration; + } - AbstractTestCase.prototype.assertInnerHTML = function assertInnerHTML(html) { - _internalTestHelpersEqualInnerHtml.default(this.element, html); - }; + return qps; + } - AbstractTestCase.prototype.assertHTML = function assertHTML(html) { - _internalTestHelpersEqualTokens.default(this.element, html, '#qunit-fixture content should be: `' + html + '`'); - }; + function addQueryParamsObservers(controller, propNames) { + propNames.forEach(function (prop) { + controller.addObserver(prop + '.[]', controller, controller._qpChanged); + }); + } - AbstractTestCase.prototype.assertElement = function assertElement(node, _ref) { - var _ref$ElementType = _ref.ElementType; - var ElementType = _ref$ElementType === undefined ? HTMLElement : _ref$ElementType; - var tagName = _ref.tagName; - var _ref$attrs = _ref.attrs; - var attrs = _ref$attrs === undefined ? null : _ref$attrs; - var _ref$content = _ref.content; - var content = _ref$content === undefined ? null : _ref$content; + function getEngineRouteName(engine, routeName) { + if (engine.routable) { + var prefix = engine.mountPoint; - if (!(node instanceof ElementType)) { - throw new Error('Expecting a ' + ElementType.name + ', but got ' + node); + if (routeName === 'application') { + return prefix; + } else { + return prefix + '.' + routeName; } + } - _internalTestHelpersMatchers.equalsElement(node, tagName, attrs, content); - }; + return routeName; + } - AbstractTestCase.prototype.assertComponentElement = function assertComponentElement(node, _ref2) { - var _ref2$ElementType = _ref2.ElementType; - var ElementType = _ref2$ElementType === undefined ? HTMLElement : _ref2$ElementType; - var _ref2$tagName = _ref2.tagName; - var tagName = _ref2$tagName === undefined ? 'div' : _ref2$tagName; - var _ref2$attrs = _ref2.attrs; - var attrs = _ref2$attrs === undefined ? null : _ref2$attrs; - var _ref2$content = _ref2.content; - var content = _ref2$content === undefined ? null : _ref2$content; + exports.default = Route; +}); +enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console', 'ember-metal', 'ember-runtime', 'ember-routing/system/route', 'ember-routing/system/dsl', 'ember-routing/location/api', 'ember-routing/utils', 'ember-routing/system/router_state', 'container', 'router'], function (exports, _emberUtils, _emberConsole, _emberMetal, _emberRuntime, _emberRoutingSystemRoute, _emberRoutingSystemDsl, _emberRoutingLocationApi, _emberRoutingUtils, _emberRoutingSystemRouter_state, _container, _router5) { + 'use strict'; - attrs = _emberUtils.assign({}, { id: _internalTestHelpersMatchers.regex(/^ember\d*$/), class: _internalTestHelpersMatchers.classes('ember-view') }, attrs || {}); - this.assertElement(node, { ElementType: ElementType, tagName: tagName, attrs: attrs, content: content }); - }; + exports.triggerEvent = triggerEvent; - AbstractTestCase.prototype.assertSameNode = function assertSameNode(actual, expected) { - this.assert.strictEqual(actual, expected, 'DOM node stability'); - }; + function K() { + return this; + } - AbstractTestCase.prototype.assertInvariants = function assertInvariants(oldSnapshot, newSnapshot) { - oldSnapshot = oldSnapshot || this.snapshot; - newSnapshot = newSnapshot || this.takeSnapshot(); + var slice = Array.prototype.slice; - this.assert.strictEqual(newSnapshot.length, oldSnapshot.length, 'Same number of nodes'); + /** + The `Ember.Router` class manages the application state and URLs. Refer to + the [routing guide](http://emberjs.com/guides/routing/) for documentation. + + @class Router + @namespace Ember + @extends Ember.Object + @uses Ember.Evented + @public + */ + var EmberRouter = _emberRuntime.Object.extend(_emberRuntime.Evented, { + /** + The `location` property determines the type of URL's that your + application will use. + The following location types are currently available: + * `history` - use the browser's history API to make the URLs look just like any standard URL + * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new` + * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing) + * `auto` - use the best option based on browser capabilites: `history` if possible, then `hash` if possible, otherwise `none` + Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js` + @property location + @default 'hash' + @see {Ember.Location} + @public + */ + location: 'hash', - for (var i = 0; i < oldSnapshot.length; i++) { - this.assertSameNode(newSnapshot[i], oldSnapshot[i]); - } - }; + /** + Represents the URL of the root of the application, often '/'. This prefix is + assumed on all routes defined on this router. + @property rootURL + @default '/' + @public + */ + rootURL: '/', - AbstractTestCase.prototype.assertPartialInvariants = function assertPartialInvariants(start, end) { - this.assertInvariants(this.snapshot, this.takeSnapshot().slice(start, end)); - }; + _initRouterJs: function () { + var router = this.router = new _router5.default(); + router.triggerEvent = triggerEvent; - AbstractTestCase.prototype.assertStableRerender = function assertStableRerender() { - var _this = this; + router._triggerWillChangeContext = K; + router._triggerWillLeave = K; - this.takeSnapshot(); - this.runTask(function () { - return _this.rerender(); + var dslCallbacks = this.constructor.dslCallbacks || [K]; + var dsl = this._buildDSL(); + + dsl.route('application', { path: '/', resetNamespace: true, overrideNameAssertion: true }, function () { + for (var i = 0; i < dslCallbacks.length; i++) { + dslCallbacks[i].call(this); + } }); - this.assertInvariants(); - }; - babelHelpers.createClass(AbstractTestCase, [{ - key: 'firstChild', - get: function () { - return this.nthChild(0); - } - }, { - key: 'nodesCount', - get: function () { - var count = 0; - var node = this.element.firstChild; + router.map(dsl.generate()); + }, - while (node) { - if (!isMarker(node)) { - count++; - } + _buildDSL: function () { + var moduleBasedResolver = this._hasModuleBasedResolver(); + var options = { + enableLoadingSubstates: !!moduleBasedResolver + }; - node = node.nextSibling; - } + var owner = _emberUtils.getOwner(this); + var router = this; - return count; - } - }]); - return AbstractTestCase; - })(); + options.resolveRouteMap = function (name) { + return owner[_container.FACTORY_FOR]('route-map:' + name); + }; - exports.default = AbstractTestCase; -}); -enifed('internal-test-helpers/test-cases/application', ['exports', 'internal-test-helpers/test-cases/abstract-application'], function (exports, _internalTestHelpersTestCasesAbstractApplication) { - 'use strict'; + options.addRouteForEngine = function (name, engineInfo) { + if (!router._engineInfoByRoute[name]) { + router._engineInfoByRoute[name] = engineInfo; + } + }; - var ApplicationTestCase = (function (_AbstractApplicationTestCase) { - babelHelpers.inherits(ApplicationTestCase, _AbstractApplicationTestCase); + return new _emberRoutingSystemDsl.default(null, options); + }, - function ApplicationTestCase() { - _AbstractApplicationTestCase.apply(this, arguments); - } + init: function () { + this._super.apply(this, arguments); - return ApplicationTestCase; - })(_internalTestHelpersTestCasesAbstractApplication.default); + this.currentURL = null; + this.currentRouteName = null; + this.currentPath = null; - exports.default = ApplicationTestCase; -}); -enifed('internal-test-helpers/test-cases/query-param', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers/test-cases/application'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpersTestCasesApplication) { - 'use strict'; + this._qpCache = new _emberUtils.EmptyObject(); + this._resetQueuedQueryParameterChanges(); + this._handledErrors = _emberUtils.dictionary(null); + this._engineInstances = new _emberUtils.EmptyObject(); + this._engineInfoByRoute = new _emberUtils.EmptyObject(); + }, - var QueryParamTestCase = (function (_ApplicationTestCase) { - babelHelpers.inherits(QueryParamTestCase, _ApplicationTestCase); + /* + Resets all pending query paramter changes. + Called after transitioning to a new route + based on query parameter changes. + */ + _resetQueuedQueryParameterChanges: function () { + this._queuedQPChanges = {}; + }, - function QueryParamTestCase() { - _ApplicationTestCase.call(this); + /** + Represents the current URL. + @method url + @return {String} The current URL. + @private + */ + url: _emberMetal.computed(function () { + return _emberMetal.get(this, 'location').getURL(); + }), - var testCase = this; - testCase.expectedPushURL = null; - testCase.expectedReplaceURL = null; - this.application.register('location:test', _emberRouting.NoneLocation.extend({ - setURL: function (path) { - if (testCase.expectedReplaceURL) { - testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); - } + _hasModuleBasedResolver: function () { + var owner = _emberUtils.getOwner(this); - if (testCase.expectedPushURL) { - testCase.assert.equal(path, testCase.expectedPushURL, 'an expected pushState occurred'); - testCase.expectedPushURL = null; - } + if (!owner) { + return false; + } - this.set('path', path); - }, + var resolver = owner.application && owner.application.__registry__ && owner.application.__registry__.resolver; - replaceURL: function (path) { - if (testCase.expectedPushURL) { - testCase.assert.ok(false, 'replaceState occurred but a pushState was expected'); - } + if (!resolver) { + return false; + } - if (testCase.expectedReplaceURL) { - testCase.assert.equal(path, testCase.expectedReplaceURL, 'an expected replaceState occurred'); - testCase.expectedReplaceURL = null; - } + return !!resolver.moduleBasedResolver; + }, - this.set('path', path); + /** + Initializes the current router instance and sets up the change handling + event listeners used by the instances `location` implementation. + A property named `initialURL` will be used to determine the initial URL. + If no value is found `/` will be used. + @method startRouting + @private + */ + startRouting: function () { + var initialURL = _emberMetal.get(this, 'initialURL'); + + if (this.setupRouter()) { + if (typeof initialURL === 'undefined') { + initialURL = _emberMetal.get(this, 'location').getURL(); + } + var initialTransition = this.handleURL(initialURL); + if (initialTransition && initialTransition.error) { + throw initialTransition.error; } - })); - } + } + }, - QueryParamTestCase.prototype.visitAndAssert = function visitAndAssert(path) { + setupRouter: function () { var _this = this; - return this.visit.apply(this, arguments).then(function () { - _this.assertCurrentPath(path); - }); - }; + this._initRouterJs(); + this._setupLocation(); - QueryParamTestCase.prototype.getController = function getController(name) { - return this.applicationInstance.lookup('controller:' + name); - }; + var router = this.router; + var location = _emberMetal.get(this, 'location'); - QueryParamTestCase.prototype.getRoute = function getRoute(name) { - return this.applicationInstance.lookup('route:' + name); - }; + // Allow the Location class to cancel the router setup while it refreshes + // the page + if (_emberMetal.get(location, 'cancelRouterSetup')) { + return false; + } - QueryParamTestCase.prototype.setAndFlush = function setAndFlush(obj, prop, value) { - return _emberMetal.run(obj, 'set', prop, value); - }; + this._setupRouter(router, location); - QueryParamTestCase.prototype.assertCurrentPath = function assertCurrentPath(path) { - var message = arguments.length <= 1 || arguments[1] === undefined ? 'current path equals \'' + path + '\'' : arguments[1]; - return (function () { - this.assert.equal(this.appRouter.get('location.path'), path, message); - }).apply(this, arguments); - }; + location.onUpdateURL(function (url) { + _this.handleURL(url); + }); + + return true; + }, /** - Sets up a Controller for a given route with a single query param and default - value. Can optionally extend the controller with an object. - @public - @method setSingleQPController + Handles updating the paths and notifying any listeners of the URL + change. + Triggers the router level `didTransition` hook. + For example, to notify google analytics when the route changes, + you could use this hook. (Note: requires also including GA scripts, etc.) + ```javascript + let Router = Ember.Router.extend({ + location: config.locationType, + didTransition: function() { + this._super(...arguments); + return ga('send', 'pageview', { + 'page': this.get('url'), + 'title': this.get('url') + }); + } + }); + ``` + @method didTransition + @public + @since 1.2.0 */ + didTransition: function (infos) { + updatePaths(this); - QueryParamTestCase.prototype.setSingleQPController = function setSingleQPController(routeName) { - var param = arguments.length <= 1 || arguments[1] === undefined ? 'foo' : arguments[1]; - var defaultValue = arguments.length <= 2 || arguments[2] === undefined ? 'bar' : arguments[2]; + this._cancelSlowTransitionTimer(); - var _Controller$extend; + this.notifyPropertyChange('url'); + this.set('currentState', this.targetState); - var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; + // Put this in the runloop so url will be accurate. Seems + // less surprising than didTransition being out of sync. + _emberMetal.run.once(this, this.trigger, 'didTransition'); + }, - this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend = { - queryParams: [param] - }, _Controller$extend[param] = defaultValue, _Controller$extend), options)); - }; + _setOutlets: function () { + // This is triggered async during Ember.Route#willDestroy. + // If the router is also being destroyed we do not want to + // to create another this._toplevelView (and leak the renderer) + if (this.isDestroying || this.isDestroyed) { + return; + } + + var handlerInfos = this.router.currentHandlerInfos; + var route = undefined; + var defaultParentState = undefined; + var liveRoutes = null; + + if (!handlerInfos) { + return; + } + + for (var i = 0; i < handlerInfos.length; i++) { + route = handlerInfos[i].handler; + var connections = route.connections; + var ownState = undefined; + for (var j = 0; j < connections.length; j++) { + var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); + liveRoutes = appended.liveRoutes; + if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { + ownState = appended.ownState; + } + } + if (connections.length === 0) { + ownState = representEmptyRoute(liveRoutes, defaultParentState, route); + } + defaultParentState = ownState; + } + + // when a transitionTo happens after the validation phase + // during the initial transition _setOutlets is called + // when no routes are active. However, it will get called + // again with the correct values during the next turn of + // the runloop + if (!liveRoutes) { + return; + } + + if (!this._toplevelView) { + var owner = _emberUtils.getOwner(this); + var OutletView = owner[_container.FACTORY_FOR]('view:-outlet'); + this._toplevelView = OutletView.create(); + this._toplevelView.setOutletState(liveRoutes); + var instance = owner.lookup('-application-instance:main'); + instance.didCreateRootView(this._toplevelView); + } else { + this._toplevelView.setOutletState(liveRoutes); + } + }, /** - Sets up a Controller for a given route with a custom property/url key mapping. - @public - @method setMappedQPController + Handles notifying any listeners of an impending URL + change. + Triggers the router level `willTransition` hook. + @method willTransition + @public + @since 1.11.0 */ + willTransition: function (oldInfos, newInfos, transition) { + _emberMetal.run.once(this, this.trigger, 'willTransition', transition); + }, - QueryParamTestCase.prototype.setMappedQPController = function setMappedQPController(routeName) { - var prop = arguments.length <= 1 || arguments[1] === undefined ? 'page' : arguments[1]; - var urlKey = arguments.length <= 2 || arguments[2] === undefined ? 'parentPage' : arguments[2]; - var defaultValue = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3]; + handleURL: function (url) { + // Until we have an ember-idiomatic way of accessing #hashes, we need to + // remove it because router.js doesn't know how to handle it. + url = url.split(/#(.+)?/)[0]; + return this._doURLTransition('handleURL', url); + }, - var _queryParams, _Controller$extend2; + _doURLTransition: function (routerJsMethod, url) { + var transition = this.router[routerJsMethod](url || '/'); + didBeginTransition(transition, this); + return transition; + }, - var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; + /** + 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 + @public + */ + transitionTo: function () { + var queryParams = undefined; - this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend2 = { - queryParams: (_queryParams = {}, _queryParams[prop] = urlKey, _queryParams) - }, _Controller$extend2[prop] = defaultValue, _Controller$extend2), options)); - }; + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - babelHelpers.createClass(QueryParamTestCase, [{ - key: 'routerOptions', - get: function () { - return { - location: 'test' - }; + if (resemblesURL(args[0])) { + return this._doURLTransition('transitionTo', args[0]); } - }]); - return QueryParamTestCase; - })(_internalTestHelpersTestCasesApplication.default); - exports.default = QueryParamTestCase; -}); -enifed('internal-test-helpers/test-cases/rendering', ['exports', 'ember-views', 'internal-test-helpers/test-cases/abstract-rendering'], function (exports, _emberViews, _internalTestHelpersTestCasesAbstractRendering) { - 'use strict'; + var possibleQueryParams = args[args.length - 1]; + if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { + queryParams = args.pop().queryParams; + } else { + queryParams = {}; + } - var RenderingTestCase = (function (_AbstractRenderingTestCase) { - babelHelpers.inherits(RenderingTestCase, _AbstractRenderingTestCase); + var targetRouteName = args.shift(); + return this._doTransition(targetRouteName, args, queryParams); + }, - function RenderingTestCase() { - _AbstractRenderingTestCase.call(this); - var owner = this.owner; + intermediateTransitionTo: function () { + var _router; - this.env = owner.lookup('service:-glimmer-environment'); - owner.register('component-lookup:main', _emberViews.ComponentLookup); - owner.registerOptionsForType('helper', { instantiate: false }); - owner.registerOptionsForType('component', { singleton: false }); - } + (_router = this.router).intermediateTransitionTo.apply(_router, arguments); - return RenderingTestCase; - })(_internalTestHelpersTestCasesAbstractRendering.default); + updatePaths(this); + }, - exports.default = RenderingTestCase; -}); -enifed('internal-test-helpers/test-groups', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { - 'use strict'; + replaceWith: function () { + return this.transitionTo.apply(this, arguments).method('replace'); + }, - exports.testBoth = testBoth; - exports.testWithDefault = testWithDefault; + generate: function () { + var _router2; - // used by unit tests to test both accessor mode and non-accessor mode + var url = (_router2 = this.router).generate.apply(_router2, arguments); + return this.location.formatURL(url); + }, - function testBoth(testname, callback) { - function emberget(x, y) { - return _emberMetal.get(x, y); - } - function emberset(x, y, z) { - return _emberMetal.set(x, y, z); - } - function aget(x, y) { - return x[y]; - } - function aset(x, y, z) { - return x[y] = z; - } + /** + Determines if the supplied route is currently active. + @method isActive + @param routeName + @return {Boolean} + @private + */ + isActive: function (routeName) { + var router = this.router; + return router.isActive.apply(router, arguments); + }, - QUnit.test(testname + ' using getFromEmberMetal()/Ember.set()', function () { - callback(emberget, emberset); - }); + /** + An alternative form of `isActive` that doesn't require + manual concatenation of the arguments into a single + array. + @method isActiveIntent + @param routeName + @param models + @param queryParams + @return {Boolean} + @private + @since 1.7.0 + */ + isActiveIntent: function (routeName, models, queryParams) { + return this.currentState.isActiveIntent(routeName, models, queryParams); + }, - QUnit.test(testname + ' using accessors', function () { - if (_emberEnvironment.ENV.USES_ACCESSORS) { - callback(aget, aset); - } else { - ok('SKIPPING ACCESSORS'); - } - }); - } + send: function (name, context) { + var _router3; - function testWithDefault(testname, callback) { - function emberget(x, y) { - return _emberMetal.get(x, y); - } - function embergetwithdefault(x, y, z) { - return _emberMetal.getWithDefault(x, y, z); - } - function getwithdefault(x, y, z) { - return x.getWithDefault(y, z); - } - function emberset(x, y, z) { - return _emberMetal.set(x, y, z); - } - function aget(x, y) { - return x[y]; - } - function aset(x, y, z) { - return x[y] = z; - } + (_router3 = this.router).trigger.apply(_router3, arguments); + }, - QUnit.test(testname + ' using obj.get()', function () { - callback(emberget, emberset); - }); + /** + Does this router instance have the given route. + @method hasRoute + @return {Boolean} + @private + */ + hasRoute: function (route) { + return this.router.hasRoute(route); + }, - QUnit.test(testname + ' using obj.getWithDefault()', function () { - callback(getwithdefault, emberset); - }); + /** + Resets the state of the router by clearing the current route + handlers and deactivating them. + @private + @method reset + */ + reset: function () { + if (this.router) { + this.router.reset(); + } + }, - QUnit.test(testname + ' using getFromEmberMetal()', function () { - callback(emberget, emberset); - }); + willDestroy: function () { + if (this._toplevelView) { + this._toplevelView.destroy(); + this._toplevelView = null; + } - QUnit.test(testname + ' using Ember.getWithDefault()', function () { - callback(embergetwithdefault, emberset); - }); + this._super.apply(this, arguments); - QUnit.test(testname + ' using accessors', function () { - if (_emberEnvironment.ENV.USES_ACCESSORS) { - callback(aget, aset); - } else { - ok('SKIPPING ACCESSORS'); + this.reset(); + + var instances = this._engineInstances; + for (var _name in instances) { + for (var id in instances[_name]) { + _emberMetal.run(instances[_name][id], 'destroy'); + } } - }); - } -}); -enifed('glimmer-node/index', ['exports', 'glimmer-node/lib/node-dom-helper'], function (exports, _glimmerNodeLibNodeDomHelper) { - 'use strict'; + }, - exports.NodeDOMTreeConstruction = _glimmerNodeLibNodeDomHelper.default; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItbm9kZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFBb0IsdUJBQXVCLGdDQUFsQyxPQUFPIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBOb2RlRE9NVHJlZUNvbnN0cnVjdGlvbiB9IGZyb20gJy4vbGliL25vZGUtZG9tLWhlbHBlcic7XG4iXX0= -enifed('glimmer-node/lib/node-dom-helper', ['exports', 'glimmer-runtime'], function (exports, _glimmerRuntime) { - 'use strict'; + /* + Called when an active route's query parameter has changed. + These changes are batched into a runloop run and trigger + a single transition. + */ + _activeQPChanged: function (queryParameterName, newValue) { + this._queuedQPChanges[queryParameterName] = newValue; + _emberMetal.run.once(this, this._fireQueryParamTransition); + }, - var NodeDOMTreeConstruction = (function (_DOMTreeConstruction) { - babelHelpers.inherits(NodeDOMTreeConstruction, _DOMTreeConstruction); + _updatingQPChanged: function (queryParameterName) { + if (!this._qpUpdates) { + this._qpUpdates = {}; + } + this._qpUpdates[queryParameterName] = true; + }, - function NodeDOMTreeConstruction(doc) { - _DOMTreeConstruction.call(this, doc); - } + /* + Triggers a transition to a route based on query parameter changes. + This is called once per runloop, to batch changes. + e.g. + if these methods are called in succession: + this._activeQPChanged('foo', '10'); + // results in _queuedQPChanges = { foo: '10' } + this._activeQPChanged('bar', false); + // results in _queuedQPChanges = { foo: '10', bar: false } + _queuedQPChanges will represent both of these changes + and the transition using `transitionTo` will be triggered + once. + */ + _fireQueryParamTransition: function () { + this.transitionTo({ queryParams: this._queuedQPChanges }); + this._resetQueuedQueryParameterChanges(); + }, - // override to prevent usage of `this.document` until after the constructor + _setupLocation: function () { + var location = _emberMetal.get(this, 'location'); + var rootURL = _emberMetal.get(this, 'rootURL'); + var owner = _emberUtils.getOwner(this); - NodeDOMTreeConstruction.prototype.setupUselessElement = function setupUselessElement() {}; + if ('string' === typeof location && owner) { + var resolvedLocation = owner.lookup('location:' + location); - NodeDOMTreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - var prev = reference ? reference.previousSibling : parent.lastChild; - var raw = this.document.createRawHTMLSection(html); - parent.insertBefore(raw, reference); - var first = prev ? prev.nextSibling : parent.firstChild; - var last = reference ? reference.previousSibling : parent.lastChild; - return new _glimmerRuntime.ConcreteBounds(parent, first, last); - }; + if ('undefined' !== typeof resolvedLocation) { + location = _emberMetal.set(this, 'location', resolvedLocation); + } else { + // Allow for deprecated registration of custom location API's + var options = { + implementation: location + }; - // override to avoid SVG detection/work when in node (this is not needed in SSR) + location = _emberMetal.set(this, 'location', _emberRoutingLocationApi.default.create(options)); + } + } - NodeDOMTreeConstruction.prototype.createElement = function createElement(tag) { - return this.document.createElement(tag); - }; + if (location !== null && typeof location === 'object') { + if (rootURL) { + _emberMetal.set(location, 'rootURL', rootURL); + } - // override to avoid namespace shenanigans when in node (this is not needed in SSR) + // Allow the location to do any feature detection, such as AutoLocation + // detecting history support. This gives it a chance to set its + // `cancelRouterSetup` property which aborts routing. + if (typeof location.detect === 'function') { + location.detect(); + } - NodeDOMTreeConstruction.prototype.setAttribute = function setAttribute(element, name, value) { - element.setAttribute(name, value); - }; + // ensure that initState is called AFTER the rootURL is set on + // the location instance + if (typeof location.initState === 'function') { + location.initState(); + } + } + }, - return NodeDOMTreeConstruction; - })(_glimmerRuntime.DOMTreeConstruction); + _getHandlerFunction: function () { + var _this2 = this; - exports.default = NodeDOMTreeConstruction; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItbm9kZS9saWIvbm9kZS1kb20taGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQUlBLHVCQUFBOzhCQUFBLHVCQUFBOztBQUVFLGlCQUZGLHVCQUFBLENBRWMsR0FBb0IsRUFBQTtBQUM5Qiw0Q0FBTSxHQUFHLENBQUMsQ0FBQztTQUNaOzs7O0FBSkgsK0JBQUEsV0FPWSxtQkFBbUIsR0FBQSwrQkFBQSxFQUFNOztBQVByQywrQkFBQSxXQVNFLGdCQUFnQixHQUFBLDBCQUFDLE1BQXNCLEVBQUUsSUFBWSxFQUFFLFNBQXNCLEVBQUE7QUFDM0UsZ0JBQU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xhc3RDaGlsZDtcblxuICAgIHJldHVybiBuZXcgQ29uY3JldGVCb3VuZHMocGFyZW50LCBmaXJzdCwgbGFzdCk7XG4gIH1cblxuICAvLyBvdmVycmlkZSB0byBhdm9pZCBTVkcgZGV0ZWN0aW9uL3dvcmsgd2hlbiBpbiBub2RlICh0aGlzIGlzIG5vdCBuZWVkZWQgaW4gU1NSKVxuICBjcmVhdGVFbGVtZW50KHRhZzogc3RyaW5nKSB7XG4gICAgcmV0dXJuIHRoaXMuZG9jdW1lbnQuY3JlYXRlRWxlbWVudCh0YWcpO1xuICB9XG5cbiAgLy8gb3ZlcnJpZGUgdG8gYXZvaWQgbmFtZXNwYWNlIHNoZW5hbmlnYW5zIHdoZW4gaW4gbm9kZSAodGhpcyBpcyBub3QgbmVlZGVkIGluIFNTUilcbiAgc2V0QXR0cmlidXRlKGVsZW1lbnQ6IEVsZW1lbnQsIG5hbWU6IHN0cmluZywgdmFsdWU6IHN0cmluZykge1xuICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKG5hbWUsIHZhbHVlKTtcbiAgfVxufVxuIl19 -enifed('glimmer-reference/index', ['exports', 'glimmer-reference/lib/reference', 'glimmer-reference/lib/const', 'glimmer-reference/lib/validators', 'glimmer-reference/lib/utils', 'glimmer-reference/lib/iterable'], function (exports, _glimmerReferenceLibReference, _glimmerReferenceLibConst, _glimmerReferenceLibValidators, _glimmerReferenceLibUtils, _glimmerReferenceLibIterable) { - 'use strict'; + var seen = new _emberUtils.EmptyObject(); + var owner = _emberUtils.getOwner(this); - exports.BasicReference = _glimmerReferenceLibReference.Reference; - exports.BasicPathReference = _glimmerReferenceLibReference.PathReference; - exports.ConstReference = _glimmerReferenceLibConst.ConstReference; - exports.isConst = _glimmerReferenceLibConst.isConst; - babelHelpers.defaults(exports, babelHelpers.interopExportWildcard(_glimmerReferenceLibValidators, babelHelpers.defaults)); - exports.Reference = _glimmerReferenceLibValidators.VersionedReference; - exports.PathReference = _glimmerReferenceLibValidators.VersionedPathReference; - exports.referenceFromParts = _glimmerReferenceLibUtils.referenceFromParts; - exports.IterationItem = _glimmerReferenceLibIterable.IterationItem; - exports.Iterator = _glimmerReferenceLibIterable.Iterator; - exports.Iterable = _glimmerReferenceLibIterable.Iterable; - exports.OpaqueIterator = _glimmerReferenceLibIterable.OpaqueIterator; - exports.OpaqueIterable = _glimmerReferenceLibIterable.OpaqueIterable; - exports.AbstractIterator = _glimmerReferenceLibIterable.AbstractIterator; - exports.AbstractIterable = _glimmerReferenceLibIterable.AbstractIterable; - exports.IterationArtifacts = _glimmerReferenceLibIterable.IterationArtifacts; - exports.ReferenceIterator = _glimmerReferenceLibIterable.ReferenceIterator; - exports.IteratorSynchronizer = _glimmerReferenceLibIterable.IteratorSynchronizer; - exports.IteratorSynchronizerDelegate = _glimmerReferenceLibIterable.IteratorSynchronizerDelegate; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztVQUNlLGNBQWMsaUNBQTNCLFNBQVM7VUFDUSxrQkFBa0IsaUNBQW5DLGFBQWE7VUFJYixjQUFjLDZCQUFkLGNBQWM7VUFDZCxPQUFPLDZCQUFQLE9BQU87O1VBTWUsU0FBUyxrQ0FBL0Isa0JBQWtCO1VBQ1EsYUFBYSxrQ0FBdkMsc0JBQXNCO1VBSXRCLGtCQUFrQiw2QkFBbEIsa0JBQWtCO1VBSWxCLGFBQWEsZ0NBQWIsYUFBYTtVQUNiLFFBQVEsZ0NBQVIsUUFBUTtVQUNSLFFBQVEsZ0NBQVIsUUFBUTtVQUNSLGNBQWMsZ0NBQWQsY0FBYztVQUNkLGNBQWMsZ0NBQWQsY0FBYztVQUNkLGdCQUFnQixnQ0FBaEIsZ0JBQWdCO1VBQ2hCLGdCQUFnQixnQ0FBaEIsZ0JBQWdCO1VBQ2hCLGtCQUFrQixnQ0F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ed('glimmer-reference/lib/const', ['exports', 'glimmer-reference/lib/validators'], function (exports, _glimmerReferenceLibValidators) { - 'use strict'; + return function (name) { + var routeName = name; + var routeOwner = owner; + var engineInfo = _this2._engineInfoByRoute[routeName]; - exports.isConst = isConst; + if (engineInfo) { + var engineInstance = _this2._getEngineInstance(engineInfo); - var ConstReference = (function () { - function ConstReference(inner) { - this.inner = inner; - this.tag = _glimmerReferenceLibValidators.CONSTANT_TAG; + routeOwner = engineInstance; + routeName = engineInfo.localFullName; } - ConstReference.prototype.value = function value() { - return this.inner; - }; - - return ConstReference; - })(); + var fullRouteName = 'route:' + routeName; - exports.ConstReference = ConstReference; + var handler = routeOwner.lookup(fullRouteName); - function isConst(reference) { - return reference.tag === _glimmerReferenceLibValidators.CONSTANT_TAG; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9jb25zdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztRQUdBLGNBQUE7QUFHRSxpQkFIRixjQUFBLENBR3dCLEtBQVEsRUFBQTtBQUFSLGdCQUFBLENBQUEsS0FBSyxHQUFMLEtBQUssQ0FBRztBQUZ2QixnQkFBQSxDQUFBLEdBQUcsa0NBSkgsWUFBWSxBQUltQixDQUFDO1NBRUo7O0FBSHJDLHNCQUFBLFdBS0UsS0FBSyxHQUFBLGlCQUFBO0FBQVEsbUJBQU8sSUFBSSxDQUFDLEtBQUssQ0FBQztTQUFFOztlQUxuQyxjQUFBOzs7OztBQVFBLGFBQUEsT0FBQSxDQUF3QixTQUFxQyxFQUFBO0FBQzNELGVBQU8sU0FBUyxDQUFDLEdBQUcsb0NBWmIsWUFBWSxBQVlrQixDQUFDO0tBQ3ZDIiwiZmlsZSI6ImNvbnN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ09OU1RBTlRfVEFHLCBWZXJzaW9uZWRSZWZlcmVuY2UsIFJldmlzaW9uVGFnIH0gZnJvbSAnLi92YWxpZGF0b3JzJztcbmltcG9ydCB7IE9wYXF1ZSB9IGZyb20gJ2dsaW1tZXItdXRpbCc7XG5cbmV4cG9ydCBjbGFzcyBDb25zdFJlZmVyZW5jZTxUPiBpbXBsZW1lbnRzIFZlcnNpb25lZFJlZmVyZW5jZTxUPiB7XG4gIHB1YmxpYyB0YWc6IFJldmlzaW9uVGFnID0gQ09OU1RBTlRfVEFHO1xuXG4gIGNvbnN0cnVjdG9yKHByb3RlY3RlZCBpbm5lcjogVCkgeyB9XG5cbiAgdmFsdWUoKTogVCB7IHJldHVybiB0aGlzLmlubmVyOyB9XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBpc0NvbnN0KHJlZmVyZW5jZTogVmVyc2lvbmVkUmVmZXJlbmNlPE9wYXF1ZT4pOiBib29sZWFuIHtcbiAgcmV0dXJuIHJlZmVyZW5jZS50YWcgPT09IENPTlNUQU5UX1RBRztcbn1cbiJdfQ== -enifed("glimmer-reference/lib/iterable", ["exports", "glimmer-util"], function (exports, _glimmerUtil) { - "use strict"; + if (seen[name]) { + return handler; + } - var ListItem = (function (_ListNode) { - babelHelpers.inherits(ListItem, _ListNode); + seen[name] = true; - function ListItem(iterable, result) { - _ListNode.call(this, iterable.valueReferenceFor(result)); - this.retained = false; - this.seen = false; - this.key = result.key; - this.iterable = iterable; - this.memo = iterable.memoReferenceFor(result); + if (!handler) { + var DefaultRoute = routeOwner[_container.FACTORY_FOR]('route:basic').class; + routeOwner.register(fullRouteName, DefaultRoute.extend()); + handler = routeOwner.lookup(fullRouteName); } - ListItem.prototype.update = function update(item) { - this.retained = true; - this.iterable.updateValueReference(this.value, item); - this.iterable.updateMemoReference(this.memo, item); - }; + handler._setRouteName(routeName); + handler._populateQPMeta(); - ListItem.prototype.shouldRemove = function shouldRemove() { - return !this.retained; - }; + if (engineInfo && !_emberRoutingSystemRoute.hasDefaultSerialize(handler)) { + throw new Error('Defining a custom serialize method on an Engine route is not supported.'); + } - ListItem.prototype.reset = function reset() { - this.retained = false; - this.seen = false; - }; + return handler; + }; + }, - return ListItem; - })(_glimmerUtil.ListNode); + _getSerializerFunction: function () { + var _this3 = this; - exports.ListItem = ListItem; + return function (name) { + var engineInfo = _this3._engineInfoByRoute[name]; - var IterationArtifacts = (function () { - function IterationArtifacts(iterable) { - this.map = _glimmerUtil.dict(); - this.list = new _glimmerUtil.LinkedList(); - this.tag = iterable.tag; - this.iterable = iterable; + // If this is not an Engine route, we fall back to the handler for serialization + if (!engineInfo) { + return; } - IterationArtifacts.prototype.isEmpty = function isEmpty() { - var iterator = this.iterator = this.iterable.iterate(); - return iterator.isEmpty(); - }; - - IterationArtifacts.prototype.iterate = function iterate() { - var iterator = this.iterator || this.iterable.iterate(); - this.iterator = null; - return iterator; - }; - - IterationArtifacts.prototype.has = function has(key) { - return !!this.map[key]; - }; + return engineInfo.serializeMethod || _emberRoutingSystemRoute.defaultSerialize; + }; + }, - IterationArtifacts.prototype.get = function get(key) { - return this.map[key]; - }; + _setupRouter: function (router, location) { + var lastURL = undefined; + var emberRouter = this; - IterationArtifacts.prototype.wasSeen = function wasSeen(key) { - var node = this.map[key]; - return node && node.seen; - }; + router.getHandler = this._getHandlerFunction(); + router.getSerializer = this._getSerializerFunction(); - IterationArtifacts.prototype.append = function append(item) { - var map = this.map; - var list = this.list; - var iterable = this.iterable; + var doUpdateURL = function () { + location.setURL(lastURL); + _emberMetal.set(emberRouter, 'currentURL', lastURL); + }; - var node = map[item.key] = new ListItem(iterable, item); - list.append(node); - return node; - }; + router.updateURL = function (path) { + lastURL = path; + _emberMetal.run.once(doUpdateURL); + }; - IterationArtifacts.prototype.insertBefore = function insertBefore(item, reference) { - var map = this.map; - var list = this.list; - var iterable = this.iterable; + if (location.replaceURL) { + (function () { + var doReplaceURL = function () { + location.replaceURL(lastURL); + _emberMetal.set(emberRouter, 'currentURL', lastURL); + }; - var node = map[item.key] = new ListItem(iterable, item); - node.retained = true; - list.insertBefore(node, reference); - return node; - }; + router.replaceURL = function (path) { + lastURL = path; + _emberMetal.run.once(doReplaceURL); + }; + })(); + } - IterationArtifacts.prototype.move = function move(item, reference) { - var list = this.list; + router.didTransition = function (infos) { + emberRouter.didTransition(infos); + }; - item.retained = true; - list.remove(item); - list.insertBefore(item, reference); - }; + router.willTransition = function (oldInfos, newInfos, transition) { + emberRouter.willTransition(oldInfos, newInfos, transition); + }; + }, - IterationArtifacts.prototype.remove = function remove(item) { - var list = this.list; + /** + Serializes the given query params according to their QP meta information. + @private + @method _serializeQueryParams + @param {Arrray} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _serializeQueryParams: function (handlerInfos, queryParams) { + var _this4 = this; - list.remove(item); - delete this.map[item.key]; - }; + forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { + if (qp) { + delete queryParams[key]; + queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); + } else if (value === undefined) { + return; // We don't serialize undefined values + } else { + queryParams[key] = _this4._serializeQueryParam(value, _emberRuntime.typeOf(value)); + } + }); + }, - IterationArtifacts.prototype.nextNode = function nextNode(item) { - return this.list.nextNode(item); - }; + /** + Serializes the value of a query parameter based on a type + @private + @method _serializeQueryParam + @param {Object} value + @param {String} type + */ + _serializeQueryParam: function (value, type) { + if (type === 'array') { + return JSON.stringify(value); + } - IterationArtifacts.prototype.head = function head() { - return this.list.head(); - }; + return '' + value; + }, - return IterationArtifacts; - })(); + /** + Deserializes the given query params according to their QP meta information. + @private + @method _deserializeQueryParams + @param {Array} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _deserializeQueryParams: function (handlerInfos, queryParams) { + forEachQueryParam(this, handlerInfos, queryParams, function (key, value, qp) { + // If we don't have QP meta info for a given key, then we do nothing + // because all values will be treated as strings + if (qp) { + delete queryParams[key]; + queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); + } + }); + }, - exports.IterationArtifacts = IterationArtifacts; + /** + Deserializes the value of a query parameter based on a default type + @private + @method _deserializeQueryParam + @param {Object} value + @param {String} defaultType + */ + _deserializeQueryParam: function (value, defaultType) { + if (defaultType === 'boolean') { + return value === 'true' ? true : false; + } else if (defaultType === 'number') { + return Number(value).valueOf(); + } else if (defaultType === 'array') { + return _emberRuntime.A(JSON.parse(value)); + } - var ReferenceIterator = (function () { - // if anyone needs to construct this object with something other than - // an iterable, let @wycats know. + return value; + }, - function ReferenceIterator(iterable) { - this.iterator = null; - var artifacts = new IterationArtifacts(iterable); - this.artifacts = artifacts; + /** + Removes (prunes) any query params with default values from the given QP + object. Default values are determined from the QP meta information per key. + @private + @method _pruneDefaultQueryParamValues + @param {Array} handlerInfos + @param {Object} queryParams + @return {Void} + */ + _pruneDefaultQueryParamValues: function (handlerInfos, queryParams) { + var qps = this._queryParamsFor(handlerInfos); + for (var key in queryParams) { + var qp = qps.map[key]; + if (qp && qp.serializedDefaultValue === queryParams[key]) { + delete queryParams[key]; } + } + }, - ReferenceIterator.prototype.next = function next() { - var artifacts = this.artifacts; + _doTransition: function (_targetRouteName, models, _queryParams) { + var _router4; - var iterator = this.iterator = this.iterator || artifacts.iterate(); - var item = iterator.next(); - if (!item) return null; - return artifacts.append(item); - }; + var targetRouteName = _targetRouteName || _emberRoutingUtils.getActiveTargetName(this.router); - return ReferenceIterator; - })(); + var queryParams = {}; - exports.ReferenceIterator = ReferenceIterator; + this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); - var Phase; - (function (Phase) { - Phase[Phase["Append"] = 0] = "Append"; - Phase[Phase["Prune"] = 1] = "Prune"; - Phase[Phase["Done"] = 2] = "Done"; - })(Phase || (Phase = {})); + _emberUtils.assign(queryParams, _queryParams); + this._prepareQueryParams(targetRouteName, models, queryParams); - var IteratorSynchronizer = (function () { - function IteratorSynchronizer(_ref) { - var target = _ref.target; - var artifacts = _ref.artifacts; + var transitionArgs = _emberRoutingUtils.routeArgs(targetRouteName, models, queryParams); + var transition = (_router4 = this.router).transitionTo.apply(_router4, transitionArgs); - this.target = target; - this.artifacts = artifacts; - this.iterator = artifacts.iterate(); - this.current = artifacts.head(); - } + didBeginTransition(transition, this); - IteratorSynchronizer.prototype.sync = function sync() { - var phase = Phase.Append; - while (true) { - switch (phase) { - case Phase.Append: - phase = this.nextAppend(); - break; - case Phase.Prune: - phase = this.nextPrune(); - break; - case Phase.Done: - this.nextDone(); - return; - } - } - }; + return transition; + }, - IteratorSynchronizer.prototype.advanceToKey = function advanceToKey(key) { - var current = this.current; - var artifacts = this.artifacts; + _processActiveTransitionQueryParams: function (targetRouteName, models, queryParams, _queryParams) { + // merge in any queryParams from the active transition which could include + // queryParams from the url on initial load. + if (!this.router.activeTransition) { + return; + } - var seek = current; - while (seek && seek.key !== key) { - seek.seen = true; - seek = artifacts.nextNode(seek); - } - this.current = seek && artifacts.nextNode(seek); - }; + var unchangedQPs = {}; + var qpUpdates = this._qpUpdates || {}; + for (var key in this.router.activeTransition.queryParams) { + if (!qpUpdates[key]) { + unchangedQPs[key] = this.router.activeTransition.queryParams[key]; + } + } - IteratorSynchronizer.prototype.nextAppend = function nextAppend() { - var iterator = this.iterator; - var current = this.current; - var artifacts = this.artifacts; + // We need to fully scope queryParams so that we can create one object + // that represents both pased in queryParams and ones that aren't changed + // from the active transition. + this._fullyScopeQueryParams(targetRouteName, models, _queryParams); + this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs); + _emberUtils.assign(queryParams, unchangedQPs); + }, - var item = iterator.next(); - if (item === null) { - return this.startPrune(); - } - var key = item.key; + /** + Prepares the query params for a URL or Transition. Restores any undefined QP + keys/values, serializes all values, and then prunes any default values. + @private + @method _prepareQueryParams + @param {String} targetRouteName + @param {Array} models + @param {Object} queryParams + @return {Void} + */ + _prepareQueryParams: function (targetRouteName, models, queryParams) { + var state = calculatePostTransitionState(this, targetRouteName, models); + this._hydrateUnsuppliedQueryParams(state, queryParams); + this._serializeQueryParams(state.handlerInfos, queryParams); + this._pruneDefaultQueryParamValues(state.handlerInfos, queryParams); + }, - if (current && current.key === key) { - this.nextRetain(item); - } else if (artifacts.has(key)) { - this.nextMove(item); - } else { - this.nextInsert(item); - } - return Phase.Append; - }; + /** + Returns the meta information for the query params of a given route. This + will be overriden to allow support for lazy routes. + @private + @method _getQPMeta + @param {HandlerInfo} handlerInfo + @return {Object} + */ + _getQPMeta: function (handlerInfo) { + var route = handlerInfo.handler; + return route && _emberMetal.get(route, '_qp'); + }, - IteratorSynchronizer.prototype.nextRetain = function nextRetain(item) { - var artifacts = this.artifacts; - var current = this.current; + /** + Returns a merged query params meta object for a given set of handlerInfos. + Useful for knowing what query params are available for a given route hierarchy. + @private + @method _queryParamsFor + @param {Array} handlerInfos + @return {Object} + */ + _queryParamsFor: function (handlerInfos) { + var leafRouteName = handlerInfos[handlerInfos.length - 1].name; + if (this._qpCache[leafRouteName]) { + return this._qpCache[leafRouteName]; + } - current.update(item); - this.current = artifacts.nextNode(current); - this.target.retain(item.key, current.value, current.memo); - }; + var shouldCache = true; + var qpsByUrlKey = {}; + var map = {}; + var qps = []; - IteratorSynchronizer.prototype.nextMove = function nextMove(item) { - var current = this.current; - var artifacts = this.artifacts; - var target = this.target; - var key = item.key; + for (var i = 0; i < handlerInfos.length; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - var found = artifacts.get(item.key); - found.update(item); - if (artifacts.wasSeen(item.key)) { - artifacts.move(found, current); - target.move(found.key, found.value, found.memo, current ? current.key : null); - } else { - this.advanceToKey(key); - } - }; + if (!qpMeta) { + shouldCache = false; + continue; + } - IteratorSynchronizer.prototype.nextInsert = function nextInsert(item) { - var artifacts = this.artifacts; - var target = this.target; - var current = this.current; + // Loop over each QP to make sure we don't have any collisions by urlKey + for (var _i = 0; _i < qpMeta.qps.length; _i++) { + var qp = qpMeta.qps[_i]; + var urlKey = qp.urlKey; + var qpOther = qpsByUrlKey[urlKey]; - var node = artifacts.insertBefore(item, current); - target.insert(node.key, node.value, node.memo, current ? current.key : null); - }; + if (qpOther && qpOther.controllerName !== qp.controllerName) { + var otherQP = qpsByUrlKey[urlKey]; + } - IteratorSynchronizer.prototype.startPrune = function startPrune() { - this.current = this.artifacts.head(); - return Phase.Prune; - }; + qpsByUrlKey[urlKey] = qp; + qps.push(qp); + } - IteratorSynchronizer.prototype.nextPrune = function nextPrune() { - var artifacts = this.artifacts; - var target = this.target; - var current = this.current; + _emberUtils.assign(map, qpMeta.map); + } - if (current === null) { - return Phase.Done; - } - var node = current; - this.current = artifacts.nextNode(node); - if (node.shouldRemove()) { - artifacts.remove(node); - target.delete(node.key); - } else { - node.reset(); - } - return Phase.Prune; - }; + var finalQPMeta = { + qps: qps, + map: map + }; - IteratorSynchronizer.prototype.nextDone = function nextDone() { - this.target.done(); - }; + if (shouldCache) { + this._qpCache[leafRouteName] = finalQPMeta; + } - return IteratorSynchronizer; - })(); + return finalQPMeta; + }, - exports.IteratorSynchronizer = IteratorSynchronizer; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9pdGVyYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFrQ0EsUUFBQTs4QkFBQSxRQUFBOztBQU9FLGlCQVBGLFFBQUEsQ0FPYyxRQUF3QixFQUFFLE1BQTJCLEVBQUE7QUFDL0QsaUNBQU0sUUFBUSxDQUFDLGlCQUFpQixDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7QUFMckMsZ0JBQUEsQ0FBQSxRQUFRLEdBQVksS0FBSyxDQUFDO0FBQzFCLGdCQUFBLENBQUEsSUFBSSxHQUFZLEtBQUssQ0FBQztBQUszQixnQkFBSSxDQUFDLEdBQUcsR0FBRyxNQUFNLENBQUMsR0FBRyxDQUFDO0FBQ3RCLGdCQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztBQUN6QixnQkFBSSxDQUFDLElBQUksR0FBRyxRQUFRLENBQUMsZ0JBQW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ZSgpKSB7XG4gICAgICBhcnRpZmFjdHMucmVtb3ZlKG5vZGUpO1xuICAgICAgdGFyZ2V0LmRlbGV0ZShub2RlLmtleSk7XG4gICAgfSBlbHNlIHtcbiAgICAgIG5vZGUucmVzZXQoKTtcbiAgICB9XG5cbiAgICByZXR1cm4gUGhhc2UuUHJ1bmU7XG4gIH1cblxuICBwcml2YXRlIG5leHREb25lKCkge1xuICAgIHRoaXMudGFyZ2V0LmRvbmUoKTtcbiAgfVxufVxuIl19 -enifed("glimmer-reference/lib/reference", ["exports"], function (exports) { - "use strict"; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi9yZWZlcmVuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJyZWZlcmVuY2UuanMiLCJzb3VyY2VzQ29udGVudCI6W119 -enifed("glimmer-reference/lib/utils", ["exports"], function (exports) { - "use strict"; + /** + Maps all query param keys to their fully scoped property name of the form + `controllerName:propName`. + @private + @method _fullyScopeQueryParams + @param {String} leafRouteName + @param {Array} contexts + @param {Object} queryParams + @return {Void} + */ + _fullyScopeQueryParams: function (leafRouteName, contexts, queryParams) { + var state = calculatePostTransitionState(this, leafRouteName, contexts); + var handlerInfos = state.handlerInfos; - exports.referenceFromParts = referenceFromParts; + for (var i = 0, len = handlerInfos.length; i < len; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - function referenceFromParts(root, parts) { - var reference = root; - for (var i = 0; i < parts.length; i++) { - reference = reference.get(parts[i]); + if (!qpMeta) { + continue; } - return reference; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUdBLGFBQUEsa0JBQUEsQ0FBbUMsSUFBb0MsRUFBRSxLQUFlLEVBQUE7QUFDdEYsWUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDO0FBRXJCLGFBQUssSUFBSSxDQUFDLEdBQUMsQ0FBQyxFQUFFLENBQUMsR0FBQyxLQUFLLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO0FBQ2pDLHFCQUFTLEdBQUcsU0FBUyxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztTQUNyQztBQUVELGVBQU8sU0FBUyxDQUFDO0tBQ2xCIiwiZmlsZSI6InV0aWxzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgVmVyc2lvbmVkUGF0aFJlZmVyZW5jZSB9IGZyb20gJy4vdmFsaWRhdG9ycyc7XG5pbXBvcnQgeyBPcGFxdWUgfSBmcm9tICdnbGltbWVyLXV0aWwnO1xuXG5leHBvcnQgZnVuY3Rpb24gcmVmZXJlbmNlRnJvbVBhcnRzKHJvb3Q6IFZlcnNpb25lZFBhdGhSZWZlcmVuY2U8T3BhcXVlPiwgcGFydHM6IHN0cmluZ1tdKTogVmVyc2lvbmVkUGF0aFJlZmVyZW5jZTxPcGFxdWU+IHtcbiAgbGV0IHJlZmVyZW5jZSA9IHJvb3Q7XG5cbiAgZm9yIChsZXQgaT0wOyBpPHBhcnRzLmxlbmd0aDsgaSsrKSB7XG4gICAgcmVmZXJlbmNlID0gcmVmZXJlbmNlLmdldChwYXJ0c1tpXSk7XG4gIH1cblxuICByZXR1cm4gcmVmZXJlbmNlO1xufVxuIl19 -enifed("glimmer-reference/lib/validators", ["exports"], function (exports) { - "use strict"; - exports.combineTagged = combineTagged; - exports.combineSlice = combineSlice; - exports.combine = combine; - exports.map = map; - exports.isModified = isModified; - var CONSTANT = 0; - exports.CONSTANT = CONSTANT; - var INITIAL = 1; - exports.INITIAL = INITIAL; - var VOLATILE = NaN; - exports.VOLATILE = VOLATILE; + for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { + var qp = qpMeta.qps[j]; - var RevisionTag = (function () { - function RevisionTag() {} + var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; - RevisionTag.prototype.validate = function validate(snapshot) { - return this.value() === snapshot; - }; + if (presentProp) { + if (presentProp !== qp.scopedPropertyName) { + queryParams[qp.scopedPropertyName] = queryParams[presentProp]; + delete queryParams[presentProp]; + } + } + } + } + }, - return RevisionTag; - })(); + /** + Hydrates (adds/restores) any query params that have pre-existing values into + the given queryParams hash. This is what allows query params to be "sticky" + and restore their last known values for their scope. + @private + @method _hydrateUnsuppliedQueryParams + @param {TransitionState} state + @param {Object} queryParams + @return {Void} + */ + _hydrateUnsuppliedQueryParams: function (state, queryParams) { + var handlerInfos = state.handlerInfos; + var appCache = this._bucketCache; - exports.RevisionTag = RevisionTag; + for (var i = 0; i < handlerInfos.length; ++i) { + var qpMeta = this._getQPMeta(handlerInfos[i]); - var $REVISION = INITIAL; + if (!qpMeta) { + continue; + } - var DirtyableTag = (function (_RevisionTag) { - babelHelpers.inherits(DirtyableTag, _RevisionTag); + for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { + var qp = qpMeta.qps[j]; - function DirtyableTag() { - var revision = arguments.length <= 0 || arguments[0] === undefined ? $REVISION : arguments[0]; + var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey; - _RevisionTag.call(this); - this.revision = revision; + if (presentProp) { + if (presentProp !== qp.scopedPropertyName) { + queryParams[qp.scopedPropertyName] = queryParams[presentProp]; + delete queryParams[presentProp]; + } + } else { + var cacheKey = _emberRoutingUtils.calculateCacheKey(qp.route.fullRouteName, qp.parts, state.params); + queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); + } } + } + }, - DirtyableTag.prototype.value = function value() { - return this.revision; - }; + _scheduleLoadingEvent: function (transition, originRoute) { + this._cancelSlowTransitionTimer(); + this._slowTransitionTimer = _emberMetal.run.scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute); + }, - DirtyableTag.prototype.dirty = function dirty() { - this.revision = ++$REVISION; - }; + currentState: null, + targetState: null, - return DirtyableTag; - })(RevisionTag); + _handleSlowTransition: function (transition, originRoute) { + if (!this.router.activeTransition) { + // Don't fire an event if we've since moved on from + // the transition that put us in a loading state. + return; + } - exports.DirtyableTag = DirtyableTag; + this.set('targetState', _emberRoutingSystemRouter_state.default.create({ + emberRouter: this, + routerJs: this.router, + routerJsState: this.router.activeTransition.state + })); - function combineTagged(tagged) { - var optimized = []; - for (var i = 0, l = tagged.length; i < l; i++) { - var tag = tagged[i].tag; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); - } - return _combine(optimized); - } + transition.trigger(true, 'loading', transition, originRoute); + }, - function combineSlice(slice) { - var optimized = []; - var node = slice.head(); - while (node !== null) { - var tag = node.tag; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag !== CONSTANT_TAG) optimized.push(tag); - node = slice.nextNode(node); - } - return _combine(optimized); - } + _cancelSlowTransitionTimer: function () { + if (this._slowTransitionTimer) { + _emberMetal.run.cancel(this._slowTransitionTimer); + } + this._slowTransitionTimer = null; + }, - function combine(tags) { - var optimized = []; - for (var i = 0, l = tags.length; i < l; i++) { - var tag = tags[i]; - if (tag === VOLATILE_TAG) return VOLATILE_TAG; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); - } - return _combine(optimized); - } + // These three helper functions are used to ensure errors aren't + // re-raised if they're handled in a route's error action. + _markErrorAsHandled: function (errorGuid) { + this._handledErrors[errorGuid] = true; + }, - function _combine(tags) { - switch (tags.length) { - case 0: - return CONSTANT_TAG; - case 1: - return tags[0]; - case 2: - return new TagsPair(tags[0], tags[1]); - default: - return new TagsCombinator(tags); - } - ; - } + _isErrorHandled: function (errorGuid) { + return this._handledErrors[errorGuid]; + }, - var CachedTag = (function (_RevisionTag2) { - babelHelpers.inherits(CachedTag, _RevisionTag2); + _clearHandledError: function (errorGuid) { + delete this._handledErrors[errorGuid]; + }, - function CachedTag() { - _RevisionTag2.apply(this, arguments); - this.lastChecked = null; - this.lastValue = null; - } + _getEngineInstance: function (_ref) { + var name = _ref.name; + var instanceId = _ref.instanceId; + var mountPoint = _ref.mountPoint; - CachedTag.prototype.value = function value() { - var lastChecked = this.lastChecked; - var lastValue = this.lastValue; + var engineInstances = this._engineInstances; - if (lastChecked !== $REVISION) { - this.lastChecked = $REVISION; - this.lastValue = lastValue = this.compute(); - } - return this.lastValue; - }; + if (!engineInstances[name]) { + engineInstances[name] = new _emberUtils.EmptyObject(); + } - CachedTag.prototype.invalidate = function invalidate() { - this.lastChecked = null; - }; + var engineInstance = engineInstances[name][instanceId]; - return CachedTag; - })(RevisionTag); + if (!engineInstance) { + var owner = _emberUtils.getOwner(this); - exports.CachedTag = CachedTag; + engineInstance = owner.buildChildEngineInstance(name, { + routable: true, + mountPoint: mountPoint + }); - var TagsPair = (function (_CachedTag) { - babelHelpers.inherits(TagsPair, _CachedTag); + engineInstance.boot(); - function TagsPair(first, second) { - _CachedTag.call(this); - this.first = first; - this.second = second; - } + engineInstances[name][instanceId] = engineInstance; + } - TagsPair.prototype.compute = function compute() { - return Math.max(this.first.value(), this.second.value()); - }; + return engineInstance; + } + }); - return TagsPair; - })(CachedTag); + /* + Helper function for iterating over routes in a set of handlerInfos that are + at or above the given origin route. Example: if `originRoute` === 'foo.bar' + and the handlerInfos given were for 'foo.bar.baz', then the given callback + will be invoked with the routes for 'foo.bar', 'foo', and 'application' + individually. + + If the callback returns anything other than `true`, then iteration will stop. + + @private + @param {Route} originRoute + @param {Array} handlerInfos + @param {Function} callback + @return {Void} + */ + function forEachRouteAbove(originRoute, handlerInfos, callback) { + var originRouteFound = false; - var TagsCombinator = (function (_CachedTag2) { - babelHelpers.inherits(TagsCombinator, _CachedTag2); + for (var i = handlerInfos.length - 1; i >= 0; --i) { + var handlerInfo = handlerInfos[i]; + var route = handlerInfo.handler; - function TagsCombinator(tags) { - _CachedTag2.call(this); - this.tags = tags; - } + if (originRoute === route) { + originRouteFound = true; + } - TagsCombinator.prototype.compute = function compute() { - var tags = this.tags; + if (!originRouteFound) { + continue; + } - var max = -1; - for (var i = 0; i < tags.length; i++) { - var value = tags[i].value(); - max = Math.max(value, max); - } - return max; - }; + if (callback(route) !== true) { + return; + } + } + } - return TagsCombinator; - })(CachedTag); + // These get invoked when an action bubbles above ApplicationRoute + // and are not meant to be overridable. + var defaultActionHandlers = { - var UpdatableTag = (function (_CachedTag3) { - babelHelpers.inherits(UpdatableTag, _CachedTag3); + willResolveModel: function (transition, originRoute) { + originRoute.router._scheduleLoadingEvent(transition, originRoute); + }, - function UpdatableTag(tag) { - _CachedTag3.call(this); - this.tag = tag; - this.lastUpdated = INITIAL; - } + // Attempt to find an appropriate error route or substate to enter. + error: function (error, transition, originRoute) { + var handlerInfos = transition.state.handlerInfos; + var router = originRoute.router; - ////////// + forEachRouteAbove(originRoute, handlerInfos, function (route) { + // Check for the existence of an 'error' route. + // We don't check for an 'error' route on the originRoute, since that would + // technically be below where we're at in the route hierarchy. + if (originRoute !== route) { + var errorRouteName = findRouteStateName(route, 'error'); + if (errorRouteName) { + router.intermediateTransitionTo(errorRouteName, error); + return false; + } + } - UpdatableTag.prototype.compute = function compute() { - return Math.max(this.lastUpdated, this.tag.value()); - }; + // Check for an 'error' substate route + var errorSubstateName = findRouteSubstateName(route, 'error'); + if (errorSubstateName) { + router.intermediateTransitionTo(errorSubstateName, error); + return false; + } - UpdatableTag.prototype.update = function update(tag) { - if (tag !== this.tag) { - this.tag = tag; - this.lastUpdated = $REVISION; - this.invalidate(); - } - }; + return true; + }); - return UpdatableTag; - })(CachedTag); + logError(error, 'Error while processing route: ' + transition.targetName); + }, - exports.UpdatableTag = UpdatableTag; - var CONSTANT_TAG = new ((function (_RevisionTag3) { - babelHelpers.inherits(ConstantTag, _RevisionTag3); + // Attempt to find an appropriate loading route or substate to enter. + loading: function (transition, originRoute) { + var handlerInfos = transition.state.handlerInfos; + var router = originRoute.router; - function ConstantTag() { - _RevisionTag3.apply(this, arguments); + forEachRouteAbove(originRoute, handlerInfos, function (route) { + // Check for the existence of a 'loading' route. + // We don't check for a 'loading' route on the originRoute, since that would + // technically be below where we're at in the route hierarchy. + if (originRoute !== route) { + var loadingRouteName = findRouteStateName(route, 'loading'); + if (loadingRouteName) { + router.intermediateTransitionTo(loadingRouteName); + return false; + } } - ConstantTag.prototype.value = function value() { - return CONSTANT; - }; - - return ConstantTag; - })(RevisionTag))(); - exports.CONSTANT_TAG = CONSTANT_TAG; - var VOLATILE_TAG = new ((function (_RevisionTag4) { - babelHelpers.inherits(VolatileTag, _RevisionTag4); - - function VolatileTag() { - _RevisionTag4.apply(this, arguments); + // Check for loading substate + var loadingSubstateName = findRouteSubstateName(route, 'loading'); + if (loadingSubstateName) { + router.intermediateTransitionTo(loadingSubstateName); + return false; } - VolatileTag.prototype.value = function value() { - return VOLATILE; - }; + // Don't bubble above pivot route. + return transition.pivotHandler !== route; + }); + } + }; - return VolatileTag; - })(RevisionTag))(); - exports.VOLATILE_TAG = VOLATILE_TAG; - var CURRENT_TAG = new ((function (_DirtyableTag) { - babelHelpers.inherits(CurrentTag, _DirtyableTag); + function logError(_error, initialMessage) { + var errorArgs = []; + var error = undefined; + if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { + error = _error.errorThrown; + } else { + error = _error; + } - function CurrentTag() { - _DirtyableTag.apply(this, arguments); - } + if (initialMessage) { + errorArgs.push(initialMessage); + } - CurrentTag.prototype.value = function value() { - return $REVISION; - }; + if (error) { + if (error.message) { + errorArgs.push(error.message); + } + if (error.stack) { + errorArgs.push(error.stack); + } - return CurrentTag; - })(DirtyableTag))(); - exports.CURRENT_TAG = CURRENT_TAG; + if (typeof error === 'string') { + errorArgs.push(error); + } + } - var CachedReference = (function () { - function CachedReference() { - this.lastRevision = null; - this.lastValue = null; - } + _emberConsole.default.error.apply(this, errorArgs); + } - CachedReference.prototype.value = function value() { - var tag = this.tag; - var lastRevision = this.lastRevision; - var lastValue = this.lastValue; + /** + Finds the name of the substate route if it exists for the given route. A + substate route is of the form `route_state`, such as `foo_loading`. + + @private + @param {Route} route + @param {String} state + @return {String} + */ + function findRouteSubstateName(route, state) { + var router = route.router; + var owner = _emberUtils.getOwner(route); - if (!lastRevision || !tag.validate(lastRevision)) { - lastValue = this.lastValue = this.compute(); - this.lastRevision = tag.value(); - } - return lastValue; - }; + var routeName = route.routeName; + var substateName = routeName + '_' + state; - CachedReference.prototype.invalidate = function invalidate() { - this.lastRevision = null; - }; + var routeNameFull = route.fullRouteName; + var substateNameFull = routeNameFull + '_' + state; - return CachedReference; - })(); + return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; + } - exports.CachedReference = CachedReference; + /** + Finds the name of the state route if it exists for the given route. A state + route is of the form `route.state`, such as `foo.loading`. Properly Handles + `application` named routes. + + @private + @param {Route} route + @param {String} state + @return {String} + */ + function findRouteStateName(route, state) { + var router = route.router; + var owner = _emberUtils.getOwner(route); - var MapperReference = (function (_CachedReference) { - babelHelpers.inherits(MapperReference, _CachedReference); + var routeName = route.routeName; + var stateName = routeName === 'application' ? state : routeName + '.' + state; - function MapperReference(reference, mapper) { - _CachedReference.call(this); - this.tag = reference.tag; - this.reference = reference; - this.mapper = mapper; - } + var routeNameFull = route.fullRouteName; + var stateNameFull = routeNameFull === 'application' ? state : routeNameFull + '.' + state; - MapperReference.prototype.compute = function compute() { - var reference = this.reference; - var mapper = this.mapper; + return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; + } - return mapper(reference.value()); - }; + /** + Determines whether or not a route has been defined by checking that the route + is in the Router's map and the owner has a registration for that route. + + @private + @param {Owner} owner + @param {Ember.Router} router + @param {String} localName + @param {String} fullName + @return {Boolean} + */ + function routeHasBeenDefined(owner, router, localName, fullName) { + var routerHasRoute = router.hasRoute(fullName); + var ownerHasRoute = owner.hasRegistration('template:' + localName) || owner.hasRegistration('route:' + localName); + return routerHasRoute && ownerHasRoute; + } - return MapperReference; - })(CachedReference); + function triggerEvent(handlerInfos, ignoreFailure, args) { + var name = args.shift(); - function map(reference, mapper) { - return new MapperReference(reference, mapper); + if (!handlerInfos) { + if (ignoreFailure) { + return; + } + throw new _emberMetal.Error('Can\'t trigger action \'' + name + '\' because your app hasn\'t finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.'); } - ////////// + var eventWasHandled = false; + var handlerInfo = undefined, + handler = undefined; - var ReferenceCache = (function () { - function ReferenceCache(reference) { - this.lastValue = null; - this.lastRevision = null; - this.initialized = false; - this.tag = reference.tag; - this.reference = reference; + for (var i = handlerInfos.length - 1; i >= 0; i--) { + handlerInfo = handlerInfos[i]; + handler = handlerInfo.handler; + + if (handler && handler.actions && handler.actions[name]) { + if (handler.actions[name].apply(handler, args) === true) { + eventWasHandled = true; + } else { + // Should only hit here if a non-bubbling error action is triggered on a route. + if (name === 'error') { + var errorId = _emberUtils.guidFor(args[0]); + handler.router._markErrorAsHandled(errorId); + } + return; } + } + } - ReferenceCache.prototype.peek = function peek() { - if (!this.initialized) { - return this.initialize(); - } - return this.lastValue; - }; + if (defaultActionHandlers[name]) { + defaultActionHandlers[name].apply(null, args); + return; + } - ReferenceCache.prototype.revalidate = function revalidate() { - if (!this.initialized) { - return this.initialize(); - } - var reference = this.reference; - var lastRevision = this.lastRevision; + if (!eventWasHandled && !ignoreFailure) { + throw new _emberMetal.Error('Nothing handled the action \'' + name + '\'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.'); + } + } - var tag = reference.tag; - if (tag.validate(lastRevision)) return NOT_MODIFIED; - this.lastRevision = tag.value(); - var lastValue = this.lastValue; + function calculatePostTransitionState(emberRouter, leafRouteName, contexts) { + var routerjs = emberRouter.router; + var state = routerjs.applyIntent(leafRouteName, contexts); + var handlerInfos = state.handlerInfos; + var params = state.params; + + for (var i = 0; i < handlerInfos.length; ++i) { + var handlerInfo = handlerInfos[i]; - var value = reference.value(); - if (value === lastValue) return NOT_MODIFIED; - this.lastValue = value; - return value; - }; + // If the handlerInfo is not resolved, we serialize the context into params + if (!handlerInfo.isResolved) { + params[handlerInfo.name] = handlerInfo.serialize(handlerInfo.context); + } else { + params[handlerInfo.name] = handlerInfo.params; + } + } + return state; + } - ReferenceCache.prototype.initialize = function initialize() { - var reference = this.reference; + function updatePaths(router) { + var infos = router.router.currentHandlerInfos; + if (infos.length === 0) { + return; + } - var value = this.lastValue = reference.value(); - this.lastRevision = reference.tag.value(); - this.initialized = true; - return value; - }; + var path = EmberRouter._routePath(infos); + var currentRouteName = infos[infos.length - 1].name; + var currentURL = router.get('location').getURL(); - return ReferenceCache; - })(); + _emberMetal.set(router, 'currentPath', path); + _emberMetal.set(router, 'currentRouteName', currentRouteName); + _emberMetal.set(router, 'currentURL', currentURL); - exports.ReferenceCache = ReferenceCache; + var appController = _emberUtils.getOwner(router).lookup('controller:application'); - var NOT_MODIFIED = "adb3b78e-3d22-4e4b-877a-6317c2c5c145"; + if (!appController) { + // appController might not exist when top-level loading/error + // substates have been entered since ApplicationRoute hasn't + // actually been entered at that point. + return; + } - function isModified(value) { - return value !== NOT_MODIFIED; + if (!('currentPath' in appController)) { + _emberMetal.defineProperty(appController, 'currentPath'); } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcmVmZXJlbmNlL2xpYi92YWxpZGF0b3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBa0JPLFFBQU0sUUFBUSxHQUFhLENBQUMsQ0FBQzs7QUFDN0IsUUFBTSxPQUFPLEdBQWMsQ0FBQyxDQUFDOztBQUM3QixRQUFNLFFBQVEsR0FBYSxHQUFHLENBQUM7OztRQUV0QyxXQUFBO2lCQUFBLFdBQUE7O0FBQUEsbUJBQUEsV0FHRSxRQUFRLEdBQUEsa0JBQUMsUUFBa0IsRUFBQTtBQUN6QixtQkFBTyxJQUFJLENBQUMsS0FBSyxFQUFFLEtBQUssUUFBUSxDQUFDO1NBQ2xDOztlQUxILFdBQUE7Ozs7O0FBUUEsUUFBSSxTQUFTLEdBQUcsT0FBTyxDQUFDOztRQUV4QixZQUFBOzhCQUFBLFlBQUE7O0FBR0UsaUJBSEYsWUFBQSxHQUdrQztnQkFBcEIsUUFBUSx5REFBRyxTQUFTOztBQUM5QixtQ0FBTyxDQUFDO0FBQ1IsZ0JBQUksQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDO1NBQzFCOztBQU5ILG9CQUFBLFd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A9IFQgfCBOb3RNb2RpZmllZDtcblxuZXhwb3J0IHR5cGUgTm90TW9kaWZpZWQgPSBcImFkYjNiNzhlLTNkMjItNGU0Yi04NzdhLTYzMTdjMmM1YzE0NVwiO1xuXG5jb25zdCBOT1RfTU9ESUZJRUQ6IE5vdE1vZGlmaWVkID0gXCJhZGIzYjc4ZS0zZDIyLTRlNGItODc3YS02MzE3YzJjNWMxNDVcIjtcblxuZXhwb3J0IGZ1bmN0aW9uIGlzTW9kaWZpZWQ8VD4odmFsdWU6IFZhbGlkYXRpb248VD4pOiB2YWx1ZSBpcyBUIHtcbiAgcmV0dXJuIHZhbHVlICE9PSBOT1RfTU9ESUZJRUQ7XG59XG4iXX0= -enifed('glimmer-runtime/index', ['exports', 'glimmer-runtime/lib/dom/interfaces', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/template', 'glimmer-runtime/lib/symbol-table', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/compiled/opcodes/builder', 'glimmer-runtime/lib/compiler', 'glimmer-runtime/lib/opcode-builder', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-runtime/lib/dom/attribute-managers', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/compiled/expressions/function', 'glimmer-runtime/lib/helpers/get-dynamic-var', 'glimmer-runtime/lib/syntax/builtins/with-dynamic-vars', 'glimmer-runtime/lib/syntax/builtins/in-element', 'glimmer-runtime/lib/vm', 'glimmer-runtime/lib/upsert', 'glimmer-runtime/lib/environment', 'glimmer-runtime/lib/partial', 'glimmer-runtime/lib/component/interfaces', 'glimmer-runtime/lib/modifier/interfaces', 'glimmer-runtime/lib/dom/helper', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/bounds'], function (exports, _glimmerRuntimeLibDomInterfaces, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibTemplate, _glimmerRuntimeLibSymbolTable, _glimmerRuntimeLibReferences, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibCompiledOpcodesBuilder, _glimmerRuntimeLibCompiler, _glimmerRuntimeLibOpcodeBuilder, _glimmerRuntimeLibCompiledBlocks, _glimmerRuntimeLibDomAttributeManagers, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibCompiledExpressionsFunction, _glimmerRuntimeLibHelpersGetDynamicVar, _glimmerRuntimeLibSyntaxBuiltinsWithDynamicVars, _glimmerRuntimeLibSyntaxBuiltinsInElement, _glimmerRuntimeLibVm, _glimmerRuntimeLibUpsert, _glimmerRuntimeLibEnvironment, _glimmerRuntimeLibPartial, _glimmerRuntimeLibComponentInterfaces, _glimmerRuntimeLibModifierInterfaces, _glimmerRuntimeLibDomHelper, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibBounds) { - 'use strict'; - exports.ATTRIBUTE_SYNTAX = _glimmerRuntimeLibSyntax.ATTRIBUTE; - exports.StatementSyntax = _glimmerRuntimeLibSyntax.Statement; - exports.ExpressionSyntax = _glimmerRuntimeLibSyntax.Expression; - exports.AttributeSyntax = _glimmerRuntimeLibSyntax.Attribute; - exports.StatementCompilationBuffer = _glimmerRuntimeLibSyntax.StatementCompilationBuffer; - exports.SymbolLookup = _glimmerRuntimeLibSyntax.SymbolLookup; - exports.CompileInto = _glimmerRuntimeLibSyntax.CompileInto; - exports.isAttribute = _glimmerRuntimeLibSyntax.isAttribute; - exports.templateFactory = _glimmerRuntimeLibTemplate.default; - exports.TemplateFactory = _glimmerRuntimeLibTemplate.TemplateFactory; - exports.Template = _glimmerRuntimeLibTemplate.Template; - exports.SymbolTable = _glimmerRuntimeLibSymbolTable.default; - exports.NULL_REFERENCE = _glimmerRuntimeLibReferences.NULL_REFERENCE; - exports.UNDEFINED_REFERENCE = _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - exports.PrimitiveReference = _glimmerRuntimeLibReferences.PrimitiveReference; - exports.ConditionalReference = _glimmerRuntimeLibReferences.ConditionalReference; - exports.Blocks = _glimmerRuntimeLibSyntaxCore.Blocks; - exports.OptimizedAppend = _glimmerRuntimeLibSyntaxCore.OptimizedAppend; - exports.UnoptimizedAppend = _glimmerRuntimeLibSyntaxCore.UnoptimizedAppend; - exports.Unknown = _glimmerRuntimeLibSyntaxCore.Unknown; - exports.StaticAttr = _glimmerRuntimeLibSyntaxCore.StaticAttr; - exports.DynamicAttr = _glimmerRuntimeLibSyntaxCore.DynamicAttr; - exports.ArgsSyntax = _glimmerRuntimeLibSyntaxCore.Args; - exports.NamedArgsSyntax = _glimmerRuntimeLibSyntaxCore.NamedArgs; - exports.PositionalArgsSyntax = _glimmerRuntimeLibSyntaxCore.PositionalArgs; - exports.RefSyntax = _glimmerRuntimeLibSyntaxCore.Ref; - exports.GetNamedParameterSyntax = _glimmerRuntimeLibSyntaxCore.GetArgument; - exports.GetSyntax = _glimmerRuntimeLibSyntaxCore.Get; - exports.ValueSyntax = _glimmerRuntimeLibSyntaxCore.Value; - exports.OpenElement = _glimmerRuntimeLibSyntaxCore.OpenElement; - exports.HelperSyntax = _glimmerRuntimeLibSyntaxCore.Helper; - exports.BlockSyntax = _glimmerRuntimeLibSyntaxCore.Block; - exports.OpenPrimitiveElementSyntax = _glimmerRuntimeLibSyntaxCore.OpenPrimitiveElement; - exports.CloseElementSyntax = _glimmerRuntimeLibSyntaxCore.CloseElement; - exports.OpcodeBuilderDSL = _glimmerRuntimeLibCompiledOpcodesBuilder.default; - exports.Compiler = _glimmerRuntimeLibCompiler.default; - exports.Compilable = _glimmerRuntimeLibCompiler.Compilable; - exports.CompileIntoList = _glimmerRuntimeLibCompiler.CompileIntoList; - exports.compileLayout = _glimmerRuntimeLibCompiler.compileLayout; - exports.ComponentBuilder = _glimmerRuntimeLibOpcodeBuilder.ComponentBuilder; - exports.StaticDefinition = _glimmerRuntimeLibOpcodeBuilder.StaticDefinition; - exports.DynamicDefinition = _glimmerRuntimeLibOpcodeBuilder.DynamicDefinition; - exports.Block = _glimmerRuntimeLibCompiledBlocks.Block; - exports.CompiledBlock = _glimmerRuntimeLibCompiledBlocks.CompiledBlock; - exports.Layout = _glimmerRuntimeLibCompiledBlocks.Layout; - exports.InlineBlock = _glimmerRuntimeLibCompiledBlocks.InlineBlock; - exports.EntryPoint = _glimmerRuntimeLibCompiledBlocks.EntryPoint; - exports.IAttributeManager = _glimmerRuntimeLibDomAttributeManagers.AttributeManager; - exports.AttributeManager = _glimmerRuntimeLibDomAttributeManagers.AttributeManager; - exports.PropertyManager = _glimmerRuntimeLibDomAttributeManagers.PropertyManager; - exports.INPUT_VALUE_PROPERTY_MANAGER = _glimmerRuntimeLibDomAttributeManagers.INPUT_VALUE_PROPERTY_MANAGER; - exports.defaultManagers = _glimmerRuntimeLibDomAttributeManagers.defaultManagers; - exports.defaultAttributeManagers = _glimmerRuntimeLibDomAttributeManagers.defaultAttributeManagers; - exports.defaultPropertyManagers = _glimmerRuntimeLibDomAttributeManagers.defaultPropertyManagers; - exports.readDOMAttr = _glimmerRuntimeLibDomAttributeManagers.readDOMAttr; - exports.normalizeTextValue = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue; - exports.CompiledExpression = _glimmerRuntimeLibCompiledExpressions.CompiledExpression; - exports.CompiledArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs; - exports.CompiledNamedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs; - exports.CompiledPositionalArgs = _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs; - exports.EvaluatedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs; - exports.EvaluatedNamedArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedNamedArgs; - exports.EvaluatedPositionalArgs = _glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedPositionalArgs; - exports.FunctionExpression = _glimmerRuntimeLibCompiledExpressionsFunction.FunctionExpression; - exports.getDynamicVar = _glimmerRuntimeLibHelpersGetDynamicVar.default; - exports.WithDynamicVarsSyntax = _glimmerRuntimeLibSyntaxBuiltinsWithDynamicVars.default; - exports.InElementSyntax = _glimmerRuntimeLibSyntaxBuiltinsInElement.default; - exports.VM = _glimmerRuntimeLibVm.PublicVM; - exports.UpdatingVM = _glimmerRuntimeLibVm.UpdatingVM; - exports.RenderResult = _glimmerRuntimeLibVm.RenderResult; - exports.SafeString = _glimmerRuntimeLibUpsert.SafeString; - exports.isSafeString = _glimmerRuntimeLibUpsert.isSafeString; - exports.Scope = _glimmerRuntimeLibEnvironment.Scope; - exports.Environment = _glimmerRuntimeLibEnvironment.default; - exports.Helper = _glimmerRuntimeLibEnvironment.Helper; - exports.ParsedStatement = _glimmerRuntimeLibEnvironment.ParsedStatement; - exports.DynamicScope = _glimmerRuntimeLibEnvironment.DynamicScope; - exports.PartialDefinition = _glimmerRuntimeLibPartial.PartialDefinition; - exports.Component = _glimmerRuntimeLibComponentInterfaces.Component; - exports.ComponentClass = _glimmerRuntimeLibComponentInterfaces.ComponentClass; - exports.ComponentManager = _glimmerRuntimeLibComponentInterfaces.ComponentManager; - exports.ComponentDefinition = _glimmerRuntimeLibComponentInterfaces.ComponentDefinition; - exports.ComponentLayoutBuilder = _glimmerRuntimeLibComponentInterfaces.ComponentLayoutBuilder; - exports.ComponentAttrsBuilder = _glimmerRuntimeLibComponentInterfaces.ComponentAttrsBuilder; - exports.isComponentDefinition = _glimmerRuntimeLibComponentInterfaces.isComponentDefinition; - exports.ModifierManager = _glimmerRuntimeLibModifierInterfaces.ModifierManager; - exports.DOMChanges = _glimmerRuntimeLibDomHelper.default; - exports.IDOMChanges = _glimmerRuntimeLibDomHelper.DOMChanges; - exports.DOMTreeConstruction = _glimmerRuntimeLibDomHelper.DOMTreeConstruction; - exports.isWhitespace = _glimmerRuntimeLibDomHelper.isWhitespace; - exports.insertHTMLBefore = _glimmerRuntimeLibDomHelper.insertHTMLBefore; - exports.Simple = _glimmerRuntimeLibDomInterfaces; - exports.ElementStack = _glimmerRuntimeLibBuilder.ElementStack; - exports.ElementOperations = _glimmerRuntimeLibBuilder.ElementOperations; - exports.Bounds = _glimmerRuntimeLibBounds.default; - exports.ConcreteBounds = _glimmerRuntimeLibBounds.ConcreteBounds; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFDZSxnQkFBZ0IsNEJBQTdCLFNBQVM7VUFDSSxlQUFlLDRCQUE1QixTQUFTO1VBQ0ssZ0JBQWdCLDRCQUE5QixVQUFVO1VBQ0csZUFBZSw0QkFBNUIsU0FBUztVQUNULDBCQUEwQiw0QkFBMUIsMEJBQTBCO1VBQzFCLFlBQVksNEJBQVosWUFBWTtVQUNaLFdBQVcsNEJBQVgsV0FBVztVQUNYLFdBQVcsNEJBQVgsV0FBVztVQUdPLGVBQWUsOEJBQTFCLE9BQU87VUFBcUIsZUFBZSw4QkFBZixlQUFlO1VBQUUsUUFBUSw4QkFBUixRQUFRO1VBRTFDLFdBQVcsaUNBQXRCLE9BQU87VUFFUCxjQUFjLGdDQUFkLGNBQWM7VUFBRSxtQkFBbUIsZ0NBQW5CLG1CQUFtQjtVQUFFLGtCQUFrQixnQ0FBbEIsa0JBQWtCO1VBQUUsb0JBQW9CLGdDQUFwQixvQkFBb0I7VUFHcEYsTUFBTSxnQ0FBTixNQUFNO1VBQ04sZUFBZSxnQ0FBZixlQUFlO1VBQ2YsaUJBQWlCLGdDQUFqQixpQkFBaUI7VUFDakIsT0FBTyxnQ0FBUCxPQUFPO1VBQ1AsVUFBVSxnQ0FBVixVQUFVO1VBQ1YsV0FBVyxnQ0FBWCxXQUFXO1VBQ0gsVUFBVSxnQ0FBbEIsSUFBSTtVQUNTLGVBQWUsZ0NBQTVCLFNBQVM7VUFD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ZnJvbSAnLi9saWIvZG9tL2hlbHBlcic7XG5pbXBvcnQgICogYXMgU2ltcGxlIGZyb20gJy4vbGliL2RvbS9pbnRlcmZhY2VzJztcbmV4cG9ydCB7IFNpbXBsZSB9O1xuZXhwb3J0IHsgRWxlbWVudFN0YWNrLCBFbGVtZW50T3BlcmF0aW9ucyB9IGZyb20gJy4vbGliL2J1aWxkZXInO1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBCb3VuZHMsIENvbmNyZXRlQm91bmRzIH0gZnJvbSAnLi9saWIvYm91bmRzJztcbiJdfQ== -enifed("glimmer-runtime/lib/bounds", ["exports"], function (exports) { - "use strict"; + _emberMetal.set(appController, 'currentPath', path); - exports.bounds = bounds; - exports.single = single; - exports.move = move; - exports.clear = clear; + if (!('currentRouteName' in appController)) { + _emberMetal.defineProperty(appController, 'currentRouteName'); + } - var Cursor = function Cursor(element, nextSibling) { - this.element = element; - this.nextSibling = nextSibling; - }; + _emberMetal.set(appController, 'currentRouteName', currentRouteName); + } - exports.Cursor = Cursor; + EmberRouter.reopenClass({ + router: null, - var RealDOMBounds = (function () { - function RealDOMBounds(bounds) { - this.bounds = bounds; - } + /** + The `Router.map` function allows you to define mappings from URLs to routes + in your application. These mappings are defined within the + supplied callback function using `this.route`. + The first parameter is the name of the route which is used by default as the + path name as well. + The second parameter is the optional options hash. Available options are: + * `path`: allows you to provide your own path as well as mark dynamic + segments. + * `resetNamespace`: false by default; when nesting routes, ember will + combine the route names to form the fully-qualified route name, which is + used with `{{link-to}}` or manually transitioning to routes. Setting + `resetNamespace: true` will cause the route not to inherit from its + parent route's names. This is handy for preventing extremely long route names. + Keep in mind that the actual URL path behavior is still retained. + The third parameter is a function, which can be used to nest routes. + Nested routes, by default, will have the parent route tree's route name and + path prepended to it's own. + ```javascript + App.Router.map(function(){ + this.route('post', { path: '/post/:post_id' }, function() { + this.route('edit'); + this.route('comments', { resetNamespace: true }, function() { + this.route('new'); + }); + }); + }); + ``` + For more detailed documentation and examples please see + [the guides](http://emberjs.com/guides/routing/defining-your-routes/). + @method map + @param callback + @public + */ + map: function (callback) { + if (!this.dslCallbacks) { + this.dslCallbacks = []; + this.reopenClass({ dslCallbacks: this.dslCallbacks }); + } - RealDOMBounds.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + this.dslCallbacks.push(callback); - RealDOMBounds.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + return this; + }, - RealDOMBounds.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + _routePath: function (handlerInfos) { + var path = []; - return RealDOMBounds; - })(); + // We have to handle coalescing resource names that + // are prefixed with their parent's names, e.g. + // ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz' + + function intersectionMatches(a1, a2) { + for (var i = 0; i < a1.length; ++i) { + if (a1[i] !== a2[i]) { + return false; + } + } + return true; + } - exports.RealDOMBounds = RealDOMBounds; + var name = undefined, + nameParts = undefined, + oldNameParts = undefined; + for (var i = 1; i < handlerInfos.length; i++) { + name = handlerInfos[i].name; + nameParts = name.split('.'); + oldNameParts = slice.call(path); - var ConcreteBounds = (function () { - function ConcreteBounds(parentNode, first, last) { - this.parentNode = parentNode; - this.first = first; - this.last = last; + while (oldNameParts.length) { + if (intersectionMatches(oldNameParts, nameParts)) { + break; + } + oldNameParts.shift(); } - ConcreteBounds.prototype.parentElement = function parentElement() { - return this.parentNode; - }; + path.push.apply(path, nameParts.slice(oldNameParts.length)); + } - ConcreteBounds.prototype.firstNode = function firstNode() { - return this.first; - }; + return path.join('.'); + } + }); - ConcreteBounds.prototype.lastNode = function lastNode() { - return this.last; - }; + function didBeginTransition(transition, router) { + var routerState = _emberRoutingSystemRouter_state.default.create({ + emberRouter: router, + routerJs: router.router, + routerJsState: transition.state + }); - return ConcreteBounds; - })(); + if (!router.currentState) { + router.set('currentState', routerState); + } + router.set('targetState', routerState); - exports.ConcreteBounds = ConcreteBounds; + transition.promise = transition.catch(function (error) { + var errorId = _emberUtils.guidFor(error); - var SingleNodeBounds = (function () { - function SingleNodeBounds(parentNode, node) { - this.parentNode = parentNode; - this.node = node; - } + if (router._isErrorHandled(errorId)) { + router._clearHandledError(errorId); + } else { + throw error; + } + }); + } - SingleNodeBounds.prototype.parentElement = function parentElement() { - return this.parentNode; - }; + function resemblesURL(str) { + return typeof str === 'string' && (str === '' || str[0] === '/'); + } - SingleNodeBounds.prototype.firstNode = function firstNode() { - return this.node; - }; + function forEachQueryParam(router, handlerInfos, queryParams, callback) { + var qpCache = router._queryParamsFor(handlerInfos); - SingleNodeBounds.prototype.lastNode = function lastNode() { - return this.node; - }; + for (var key in queryParams) { + if (!queryParams.hasOwnProperty(key)) { + continue; + } + var value = queryParams[key]; + var qp = qpCache.map[key]; - return SingleNodeBounds; - })(); + callback(key, value, qp); + } + } - exports.SingleNodeBounds = SingleNodeBounds; + function findLiveRoute(liveRoutes, name) { + if (!liveRoutes) { + return; + } + var stack = [liveRoutes]; + while (stack.length > 0) { + var test = stack.shift(); + if (test.render.name === name) { + return test; + } + var outlets = test.outlets; + for (var outletName in outlets) { + stack.push(outlets[outletName]); + } + } + } - function bounds(parent, first, last) { - return new ConcreteBounds(parent, first, last); + function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { + var target = undefined; + var myState = { + render: renderOptions, + outlets: new _emberUtils.EmptyObject(), + wasUsed: false + }; + if (renderOptions.into) { + target = findLiveRoute(liveRoutes, renderOptions.into); + } else { + target = defaultParentState; } + if (target) { + _emberMetal.set(target.outlets, renderOptions.outlet, myState); + } else { + if (renderOptions.into) { - function single(parent, node) { - return new SingleNodeBounds(parent, node); + // Megahax time. Post-3.0-breaking-changes, we will just assert + // right here that the user tried to target a nonexistent + // thing. But for now we still need to support the `render` + // helper, and people are allowed to target templates rendered + // by the render helper. So instead we defer doing anyting with + // these orphan renders until afterRender. + appendOrphan(liveRoutes, renderOptions.into, myState); + } else { + liveRoutes = myState; + } } + return { + liveRoutes: liveRoutes, + ownState: myState + }; + } - function move(bounds, reference) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var node = first; - while (node) { - var next = node.nextSibling; - parent.insertBefore(node, reference); - if (node === last) return next; - node = next; - } - return null; + function appendOrphan(liveRoutes, into, myState) { + if (!liveRoutes.outlets.__ember_orphans__) { + liveRoutes.outlets.__ember_orphans__ = { + render: { + name: '__ember_orphans__' + }, + outlets: new _emberUtils.EmptyObject() + }; } + liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; + _emberMetal.run.schedule('afterRender', function () {}); + } - function clear(bounds) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var node = first; - while (node) { - var next = node.nextSibling; - parent.removeChild(node); - if (node === last) return next; - node = next; - } - return null; + function representEmptyRoute(liveRoutes, defaultParentState, route) { + // the route didn't render anything + var alreadyAppended = findLiveRoute(liveRoutes, route.routeName); + if (alreadyAppended) { + // But some other route has already rendered our default + // template, so that becomes the default target for any + // children we may have. + return alreadyAppended; + } else { + // Create an entry to represent our default template name, + // just so other routes can target it and inherit its place + // in the outlet hierarchy. + defaultParentState.outlets.main = { + render: { + name: route.routeName, + outlet: 'main' + }, + outlets: {} + }; + return defaultParentState; } + } + + exports.default = EmberRouter; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvYm91bmRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O1FBVUEsTUFBQSxHQUNFLFNBREYsTUFBQSxDQUNxQixPQUF1QixFQUFTLFdBQXdCLEVBQUE7QUFBeEQsWUFBQSxDQUFBLE9BQU8sR0FBUCxPQUFPLENBQWdCO0FBQVMsWUFBQSxDQUFBLFdBQVcsR0FBWCxXQUFXLENBQWE7S0FBSTs7OztRQU9qRixhQUFBO0FBQ0UsaUJBREYsYUFBQSxDQUNzQixNQUFjLEVBQUE7QUFBZCxnQkFBQSxDQUFBLE1BQ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ge1xuICBsZXQgcGFyZW50ID0gYm91bmRzLnBhcmVudEVsZW1lbnQoKTtcbiAgbGV0IGZpcnN0ID0gYm91bmRzLmZpcnN0Tm9kZSgpO1xuICBsZXQgbGFzdCA9IGJvdW5kcy5sYXN0Tm9kZSgpO1xuXG4gIGxldCBub2RlID0gZmlyc3Q7XG5cbiAgd2hpbGUgKG5vZGUpIHtcbiAgICBsZXQgbmV4dCA9IG5vZGUubmV4dFNpYmxpbmc7XG4gICAgcGFyZW50Lmluc2VydEJlZm9yZShub2RlLCByZWZlcmVuY2UpO1xuICAgIGlmIChub2RlID09PSBsYXN0KSByZXR1cm4gbmV4dDtcbiAgICBub2RlID0gbmV4dDtcbiAgfVxuXG4gIHJldHVybiBudWxsO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gY2xlYXIoYm91bmRzOiBCb3VuZHMpOiBTaW1wbGUuTm9kZSB7XG4gIGxldCBwYXJlbnQgPSBib3VuZHMucGFyZW50RWxlbWVudCgpO1xuICBsZXQgZmlyc3QgPSBib3VuZHMuZmlyc3ROb2RlKCk7XG4gIGxldCBsYXN0ID0gYm91bmRzLmxhc3ROb2RlKCk7XG5cbiAgbGV0IG5vZGUgPSBmaXJzdDtcblxuICB3aGlsZSAobm9kZSkge1xuICAgIGxldCBuZXh0ID0gbm9kZS5uZXh0U2libGluZztcbiAgICBwYXJlbnQucmVtb3ZlQ2hpbGQobm9kZSk7XG4gICAgaWYgKG5vZGUgPT09IGxhc3QpIHJldHVybiBuZXh0O1xuICAgIG5vZGUgPSBuZXh0O1xuICB9XG5cbiAgcmV0dXJuIG51bGw7XG59XG4iXX0= -enifed('glimmer-runtime/lib/builder', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-util', 'glimmer-runtime/lib/compiled/opcodes/dom'], function (exports, _glimmerRuntimeLibBounds, _glimmerUtil, _glimmerRuntimeLibCompiledOpcodesDom) { - 'use strict'; - var First = (function () { - function First(node) { - this.node = node; - } +/** +@module ember +@submodule ember-routing +*/ - First.prototype.firstNode = function firstNode() { - return this.node; - }; +// `wasUsed` gets set by the render helper. +enifed('ember-routing/system/router_state', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime'], function (exports, _emberUtils, _emberMetal, _emberRuntime) { + 'use strict'; - return First; - })(); + exports.default = _emberRuntime.Object.extend({ + emberRouter: null, + routerJs: null, + routerJsState: null, - var Last = (function () { - function Last(node) { - this.node = node; - } + isActiveIntent: function (routeName, models, queryParams, queryParamsMustMatch) { + var state = this.routerJsState; + if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { + return false; + } - Last.prototype.lastNode = function lastNode() { - return this.node; - }; + var emptyQueryParams = _emberMetal.isEmpty(Object.keys(queryParams)); - return Last; - })(); + if (queryParamsMustMatch && !emptyQueryParams) { + var visibleQueryParams = {}; + _emberUtils.assign(visibleQueryParams, queryParams); - var Fragment = (function () { - function Fragment(bounds) { - this.bounds = bounds; - } + this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); + return shallowEqual(visibleQueryParams, state.queryParams); + } - Fragment.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + return true; + } + }); - Fragment.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + function shallowEqual(a, b) { + var k = undefined; + for (k in a) { + if (a.hasOwnProperty(k) && a[k] !== b[k]) { + return false; + } + } + for (k in b) { + if (b.hasOwnProperty(k) && a[k] !== b[k]) { + return false; + } + } + return true; + } +}); +enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], function (exports, _emberUtils, _emberMetal) { + 'use strict'; - Fragment.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + exports.routeArgs = routeArgs; + exports.getActiveTargetName = getActiveTargetName; + exports.stashParamNames = stashParamNames; + exports.calculateCacheKey = calculateCacheKey; + exports.normalizeControllerQueryParams = normalizeControllerQueryParams; + exports.prefixRouteNameArg = prefixRouteNameArg; - Fragment.prototype.update = function update(bounds) { - this.bounds = bounds; - }; + var ALL_PERIODS_REGEX = /\./g; - return Fragment; - })(); + function routeArgs(targetRouteName, models, queryParams) { + var args = []; + if (typeof targetRouteName === 'string') { + args.push('' + targetRouteName); + } + args.push.apply(args, models); + args.push({ queryParams: queryParams }); + return args; + } - exports.Fragment = Fragment; - - var ElementStack = (function () { - function ElementStack(env, parentNode, nextSibling) { - this.constructing = null; - this.operations = null; - this.elementStack = new _glimmerUtil.Stack(); - this.nextSiblingStack = new _glimmerUtil.Stack(); - this.blockStack = new _glimmerUtil.Stack(); - this.env = env; - this.dom = env.getAppendOperations(); - this.updateOperations = env.getDOM(); - this.element = parentNode; - this.nextSibling = nextSibling; - this.defaultOperations = new _glimmerRuntimeLibCompiledOpcodesDom.SimpleElementOperations(env); - this.elementStack.push(this.element); - this.nextSiblingStack.push(this.nextSibling); - } - - ElementStack.forInitialRender = function forInitialRender(env, parentNode, nextSibling) { - return new ElementStack(env, parentNode, nextSibling); - }; + function getActiveTargetName(router) { + var handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; + return handlerInfos[handlerInfos.length - 1].name; + } - ElementStack.resume = function resume(env, tracker, nextSibling) { - var parentNode = tracker.parentElement(); - var stack = new ElementStack(env, parentNode, nextSibling); - stack.pushBlockTracker(tracker); - return stack; - }; + function stashParamNames(router, handlerInfos) { + if (handlerInfos._namesStashed) { + return; + } - ElementStack.prototype.block = function block() { - return this.blockStack.current; - }; + // This helper exists because router.js/route-recognizer.js awkwardly + // keeps separate a handlerInfo's list of parameter names depending + // on whether a URL transition or named transition is happening. + // Hopefully we can remove this in the future. + var targetRouteName = handlerInfos[handlerInfos.length - 1].name; + var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); + var dynamicParent = null; - ElementStack.prototype.popElement = function popElement() { - var elementStack = this.elementStack; - var nextSiblingStack = this.nextSiblingStack; + for (var i = 0; i < handlerInfos.length; ++i) { + var handlerInfo = handlerInfos[i]; + var names = recogHandlers[i].names; - var topElement = elementStack.pop(); - nextSiblingStack.pop(); - this.element = elementStack.current; - this.nextSibling = nextSiblingStack.current; - return topElement; - }; + if (names.length) { + dynamicParent = handlerInfo; + } - ElementStack.prototype.pushSimpleBlock = function pushSimpleBlock() { - var tracker = new SimpleBlockTracker(this.element); - this.pushBlockTracker(tracker); - return tracker; - }; + handlerInfo._names = names; - ElementStack.prototype.pushUpdatableBlock = function pushUpdatableBlock() { - var tracker = new UpdatableBlockTracker(this.element); - this.pushBlockTracker(tracker); - return tracker; - }; + var route = handlerInfo.handler; + route._stashNames(handlerInfo, dynamicParent); + } - ElementStack.prototype.pushBlockTracker = function pushBlockTracker(tracker) { - var isRemote = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + handlerInfos._namesStashed = true; + } - var current = this.blockStack.current; - if (current !== null) { - current.newDestroyable(tracker); - if (!isRemote) { - current.newBounds(tracker); - } - } - this.blockStack.push(tracker); - return tracker; - }; + function _calculateCacheValuePrefix(prefix, part) { + // calculates the dot seperated sections from prefix that are also + // at the start of part - which gives us the route name - ElementStack.prototype.pushBlockList = function pushBlockList(list) { - var tracker = new BlockListTracker(this.element, list); - var current = this.blockStack.current; - if (current !== null) { - current.newDestroyable(tracker); - current.newBounds(tracker); - } - this.blockStack.push(tracker); - return tracker; - }; + // given : prefix = site.article.comments, part = site.article.id + // - returns: site.article (use get(values[site.article], 'id') to get the dynamic part - used below) - ElementStack.prototype.popBlock = function popBlock() { - this.blockStack.current.finalize(this); - return this.blockStack.pop(); - }; + // given : prefix = site.article, part = site.article.id + // - returns: site.article. (use get(values[site.article], 'id') to get the dynamic part - used below) + + var prefixParts = prefix.split('.'); + var currPrefix = ''; - ElementStack.prototype.openElement = function openElement(tag) { - var operations = arguments.length <= 1 || arguments[1] === undefined ? this.defaultOperations : arguments[1]; + for (var i = 0; i < prefixParts.length; i++) { + var currPart = prefixParts.slice(0, i + 1).join('.'); + if (part.indexOf(currPart) !== 0) { + break; + } + currPrefix = currPart; + } - var element = this.dom.createElement(tag, this.element); - this.constructing = element; - this.operations = operations; - return element; - }; + return currPrefix; + } - ElementStack.prototype.flushElement = function flushElement() { - var parent = this.element; - var element = this.constructing; - this.dom.insertBefore(parent, element, this.nextSibling); - this.constructing = null; - this.operations = null; - this.pushElement(element); - this.blockStack.current.openElement(element); - }; + /* + Stolen from Controller + */ - ElementStack.prototype.pushRemoteElement = function pushRemoteElement(element) { - this.pushElement(element); - var tracker = new RemoteBlockTracker(element); - this.pushBlockTracker(tracker, true); - }; + function calculateCacheKey(prefix, parts, values) { + if (parts === undefined) parts = []; - ElementStack.prototype.popRemoteElement = function popRemoteElement() { - this.popBlock(); - this.popElement(); - }; + var suffixes = ''; + for (var i = 0; i < parts.length; ++i) { + var part = parts[i]; + var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); + var value = undefined; + if (values) { + if (cacheValuePrefix && cacheValuePrefix in values) { + var partRemovedPrefix = part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part; + value = _emberMetal.get(values[cacheValuePrefix], partRemovedPrefix); + } else { + value = _emberMetal.get(values, part); + } + } + suffixes += '::' + part + ':' + value; + } + return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); + } - ElementStack.prototype.pushElement = function pushElement(element) { - this.element = element; - this.elementStack.push(element); - this.nextSibling = null; - this.nextSiblingStack.push(null); - }; + /* + Controller-defined query parameters can come in three shapes: + + Array + queryParams: ['foo', 'bar'] + Array of simple objects where value is an alias + queryParams: [ + { + 'foo': 'rename_foo_to_this' + }, + { + 'bar': 'call_bar_this_instead' + } + ] + Array of fully defined objects + queryParams: [ + { + 'foo': { + as: 'rename_foo_to_this' + }, + } + { + 'bar': { + as: 'call_bar_this_instead', + scope: 'controller' + } + } + ] + + This helper normalizes all three possible styles into the + 'Array of fully defined objects' style. + */ - ElementStack.prototype.newDestroyable = function newDestroyable(d) { - this.blockStack.current.newDestroyable(d); - }; + function normalizeControllerQueryParams(queryParams) { + var qpMap = {}; - ElementStack.prototype.newBounds = function newBounds(bounds) { - this.blockStack.current.newBounds(bounds); - }; + for (var i = 0; i < queryParams.length; ++i) { + accumulateQueryParamDescriptors(queryParams[i], qpMap); + } - ElementStack.prototype.appendText = function appendText(string) { - var dom = this.dom; + return qpMap; + } - var text = dom.createTextNode(string); - dom.insertBefore(this.element, text, this.nextSibling); - this.blockStack.current.newNode(text); - return text; - }; + function accumulateQueryParamDescriptors(_desc, accum) { + var desc = _desc; + var tmp = undefined; + if (typeof desc === 'string') { + tmp = {}; + tmp[desc] = { as: null }; + desc = tmp; + } - ElementStack.prototype.appendComment = function appendComment(string) { - var dom = this.dom; + for (var key in desc) { + if (!desc.hasOwnProperty(key)) { + return; + } - var comment = dom.createComment(string); - dom.insertBefore(this.element, comment, this.nextSibling); - this.blockStack.current.newNode(comment); - return comment; - }; + var singleDesc = desc[key]; + if (typeof singleDesc === 'string') { + singleDesc = { as: singleDesc }; + } - ElementStack.prototype.setStaticAttribute = function setStaticAttribute(name, value) { - this.operations.addStaticAttribute(this.constructing, name, value); - }; + tmp = accum[key] || { as: null, scope: 'model' }; + _emberUtils.assign(tmp, singleDesc); - ElementStack.prototype.setStaticAttributeNS = function setStaticAttributeNS(namespace, name, value) { - this.operations.addStaticAttributeNS(this.constructing, namespace, name, value); - }; + accum[key] = tmp; + } + } - ElementStack.prototype.setDynamicAttribute = function setDynamicAttribute(name, reference, isTrusting) { - this.operations.addDynamicAttribute(this.constructing, name, reference, isTrusting); - }; + /* + Check if a routeName resembles a url instead + + @private + */ + function resemblesURL(str) { + return typeof str === 'string' && (str === '' || str.charAt(0) === '/'); + } - ElementStack.prototype.setDynamicAttributeNS = function setDynamicAttributeNS(namespace, name, reference, isTrusting) { - this.operations.addDynamicAttributeNS(this.constructing, namespace, name, reference, isTrusting); - }; + /* + Returns an arguments array where the route name arg is prefixed based on the mount point + + @private + */ - ElementStack.prototype.closeElement = function closeElement() { - this.blockStack.current.closeElement(); - this.popElement(); - }; + function prefixRouteNameArg(route, args) { + var routeName = args[0]; + var owner = _emberUtils.getOwner(route); + var prefix = owner.mountPoint; + + // only alter the routeName if it's actually referencing a route. + if (owner.routable && typeof routeName === 'string') { + if (resemblesURL(routeName)) { + throw new _emberMetal.Error('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'); + } else { + routeName = prefix + '.' + routeName; + args[0] = routeName; + } + } - return ElementStack; - })(); + return args; + } +}); +enifed('ember-runtime/compare', ['exports', 'ember-runtime/utils', 'ember-runtime/mixins/comparable'], function (exports, _emberRuntimeUtils, _emberRuntimeMixinsComparable) { + 'use strict'; - exports.ElementStack = ElementStack; + exports.default = compare; - var SimpleBlockTracker = (function () { - function SimpleBlockTracker(parent) { - this.parent = parent; - this.first = null; - this.last = null; - this.destroyables = null; - this.nesting = 0; - } + var TYPE_ORDER = { + 'undefined': 0, + 'null': 1, + 'boolean': 2, + 'number': 3, + 'string': 4, + 'array': 5, + 'object': 6, + 'instance': 7, + 'function': 8, + 'class': 9, + 'date': 10 + }; - SimpleBlockTracker.prototype.destroy = function destroy() { - var destroyables = this.destroyables; + // + // the spaceship operator + // + // `. ___ + // __,' __`. _..----....____ + // __...--.'``;. ,. ;``--..__ .' ,-._ _.-' + // _..-''-------' `' `' `' O ``-''._ (,;') _,' + // ,'________________ \`-._`-',' + // `._ ```````````------...___ '-.._'-: + // ```--.._ ,. ````--...__\-. + // `.--. `-` "INFINITY IS LESS ____ | |` + // `. `. THAN BEYOND" ,'`````. ; ;` + // `._`. __________ `. \'__/` + // `-:._____/______/___/____`. \ ` + // | `._ `. \ + // `._________`-. `. `.___ + // SSt `------'` + function spaceship(a, b) { + var diff = a - b; + return (diff > 0) - (diff < 0); + } - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - destroyables[i].destroy(); - } - } - }; + /** + Compares two javascript values and returns: + + - -1 if the first is smaller than the second, + - 0 if both are equal, + - 1 if the first is greater than the second. + + ```javascript + Ember.compare('hello', 'hello'); // 0 + Ember.compare('abc', 'dfg'); // -1 + Ember.compare(2, 1); // 1 + ``` + + If the types of the two objects are different precedence occurs in the + following order, with types earlier in the list considered `<` types + later in the list: + + - undefined + - null + - boolean + - number + - string + - array + - object + - instance + - function + - class + - date + + ```javascript + Ember.compare('hello', 50); // 1 + Ember.compare(50, 'hello'); // -1 + ``` + + @method compare + @for Ember + @param {Object} v First value to compare + @param {Object} w Second value to compare + @return {Number} -1 if v < w, 0 if v = w and 1 if v > w. + @public + */ - SimpleBlockTracker.prototype.parentElement = function parentElement() { - return this.parent; - }; + function compare(v, w) { + if (v === w) { + return 0; + } - SimpleBlockTracker.prototype.firstNode = function firstNode() { - return this.first && this.first.firstNode(); - }; + var type1 = _emberRuntimeUtils.typeOf(v); + var type2 = _emberRuntimeUtils.typeOf(w); - SimpleBlockTracker.prototype.lastNode = function lastNode() { - return this.last && this.last.lastNode(); - }; + if (_emberRuntimeMixinsComparable.default) { + if (type1 === 'instance' && _emberRuntimeMixinsComparable.default.detect(v) && v.constructor.compare) { + return v.constructor.compare(v, w); + } - SimpleBlockTracker.prototype.openElement = function openElement(element) { - this.newNode(element); - this.nesting++; - }; + if (type2 === 'instance' && _emberRuntimeMixinsComparable.default.detect(w) && w.constructor.compare) { + return w.constructor.compare(w, v) * -1; + } + } - SimpleBlockTracker.prototype.closeElement = function closeElement() { - this.nesting--; - }; + var res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); - SimpleBlockTracker.prototype.newNode = function newNode(node) { - if (this.nesting !== 0) return; - if (!this.first) { - this.first = new First(node); - } - this.last = new Last(node); - }; + if (res !== 0) { + return res; + } - SimpleBlockTracker.prototype.newBounds = function newBounds(bounds) { - if (this.nesting !== 0) return; - if (!this.first) { - this.first = bounds; - } - this.last = bounds; - }; + // types are equal - so we have to check values now + switch (type1) { + case 'boolean': + case 'number': + return spaceship(v, w); - SimpleBlockTracker.prototype.newDestroyable = function newDestroyable(d) { - this.destroyables = this.destroyables || []; - this.destroyables.push(d); - }; + case 'string': + return spaceship(v.localeCompare(w), 0); - SimpleBlockTracker.prototype.finalize = function finalize(stack) { - if (!this.first) { - stack.appendComment(''); + case 'array': + { + var vLen = v.length; + var wLen = w.length; + var len = Math.min(vLen, wLen); + + for (var i = 0; i < len; i++) { + var r = compare(v[i], w[i]); + if (r !== 0) { + return r; } - }; - - return SimpleBlockTracker; - })(); - - exports.SimpleBlockTracker = SimpleBlockTracker; - - var RemoteBlockTracker = (function (_SimpleBlockTracker) { - babelHelpers.inherits(RemoteBlockTracker, _SimpleBlockTracker); + } - function RemoteBlockTracker() { - _SimpleBlockTracker.apply(this, arguments); + // all elements are equal now + // shorter array should be ordered first + return spaceship(vLen, wLen); } - - RemoteBlockTracker.prototype.destroy = function destroy() { - _SimpleBlockTracker.prototype.destroy.call(this); - _glimmerRuntimeLibBounds.clear(this); - }; - - return RemoteBlockTracker; - })(SimpleBlockTracker); - - var UpdatableBlockTracker = (function (_SimpleBlockTracker2) { - babelHelpers.inherits(UpdatableBlockTracker, _SimpleBlockTracker2); - - function UpdatableBlockTracker() { - _SimpleBlockTracker2.apply(this, arguments); + case 'instance': + if (_emberRuntimeMixinsComparable.default && _emberRuntimeMixinsComparable.default.detect(v)) { + return v.compare(v, w); } + return 0; - UpdatableBlockTracker.prototype.reset = function reset(env) { - var destroyables = this.destroyables; + case 'date': + return spaceship(v.getTime(), w.getTime()); - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - env.didDestroy(destroyables[i]); - } - } - var nextSibling = _glimmerRuntimeLibBounds.clear(this); - this.destroyables = null; - this.first = null; - this.last = null; - return nextSibling; - }; + default: + return 0; + } + } +}); +enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - return UpdatableBlockTracker; - })(SimpleBlockTracker); + exports.empty = empty; + exports.notEmpty = notEmpty; + exports.none = none; + exports.not = not; + exports.bool = bool; + exports.match = match; + exports.equal = equal; + exports.gt = gt; + exports.gte = gte; + exports.lt = lt; + exports.lte = lte; + exports.oneWay = oneWay; + exports.readOnly = readOnly; + exports.deprecatingAlias = deprecatingAlias; - exports.UpdatableBlockTracker = UpdatableBlockTracker; + /** + @module ember + @submodule ember-metal + */ - var BlockListTracker = (function () { - function BlockListTracker(parent, boundList) { - this.parent = parent; - this.boundList = boundList; - this.parent = parent; - this.boundList = boundList; - } + function expandPropertiesToArray(predicateName, properties) { + var expandedProperties = []; - BlockListTracker.prototype.destroy = function destroy() { - this.boundList.forEachNode(function (node) { - return node.destroy(); - }); - }; + function extractProperty(entry) { + expandedProperties.push(entry); + } - BlockListTracker.prototype.parentElement = function parentElement() { - return this.parent; - }; + for (var i = 0; i < properties.length; i++) { + var property = properties[i]; - BlockListTracker.prototype.firstNode = function firstNode() { - return this.boundList.head().firstNode(); - }; + _emberMetal.expandProperties(property, extractProperty); + } - BlockListTracker.prototype.lastNode = function lastNode() { - return this.boundList.tail().lastNode(); - }; + return expandedProperties; + } - BlockListTracker.prototype.openElement = function openElement(element) { - _glimmerUtil.assert(false, 'Cannot openElement directly inside a block list'); - }; + function generateComputedWithPredicate(name, predicate) { + return function () { + for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) { + properties[_key] = arguments[_key]; + } - BlockListTracker.prototype.closeElement = function closeElement() { - _glimmerUtil.assert(false, 'Cannot closeElement directly inside a block list'); - }; + var expandedProperties = expandPropertiesToArray(name, properties); - BlockListTracker.prototype.newNode = function newNode(node) { - _glimmerUtil.assert(false, 'Cannot create a new node directly inside a block list'); - }; + var computedFunc = _emberMetal.computed(function () { + var lastIdx = expandedProperties.length - 1; - BlockListTracker.prototype.newBounds = function newBounds(bounds) {}; + for (var i = 0; i < lastIdx; i++) { + var value = _emberMetal.get(this, expandedProperties[i]); + if (!predicate(value)) { + return value; + } + } - BlockListTracker.prototype.newDestroyable = function newDestroyable(d) {}; + return _emberMetal.get(this, expandedProperties[lastIdx]); + }); - BlockListTracker.prototype.finalize = function finalize(stack) {}; + return computedFunc.property.apply(computedFunc, expandedProperties); + }; + } - return BlockListTracker; - })(); -}); -//# sourceMappingURL=data:application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GUoKTtcbiAgfVxuXG4gIG9wZW5FbGVtZW50KGVsZW1lbnQ6IEVsZW1lbnQpIHtcbiAgICBhc3NlcnQoZmFsc2UsICdDYW5ub3Qgb3BlbkVsZW1lbnQgZGlyZWN0bHkgaW5zaWRlIGEgYmxvY2sgbGlzdCcpO1xuICB9XG5cbiAgY2xvc2VFbGVtZW50KCkge1xuICAgIGFzc2VydChmYWxzZSwgJ0Nhbm5vdCBjbG9zZUVsZW1lbnQgZGlyZWN0bHkgaW5zaWRlIGEgYmxvY2sgbGlzdCcpO1xuICB9XG5cbiAgbmV3Tm9kZShub2RlOiBOb2RlKSB7XG4gICAgYXNzZXJ0KGZhbHNlLCAnQ2Fubm90IGNyZWF0ZSBhIG5ldyBub2RlIGRpcmVjdGx5IGluc2lkZSBhIGJsb2NrIGxpc3QnKTtcbiAgfVxuXG4gIG5ld0JvdW5kcyhib3VuZHM6IEJvdW5kcykge1xuICB9XG5cbiAgbmV3RGVzdHJveWFibGUoZDogRGVzdHJveWFibGUpIHtcbiAgfVxuXG4gIGZpbmFsaXplKHN0YWNrOiBFbGVtZW50U3RhY2spIHtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compat/inner-html-fix', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/dom/helper'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibDomHelper) { - 'use strict'; + /** + A computed property that returns true if the value of the dependent + property is null, an empty string, empty array, or empty function. + + Example + + ```javascript + let ToDoList = Ember.Object.extend({ + isDone: Ember.computed.empty('todos') + }); + + let todoList = ToDoList.create({ + todos: ['Unit Test', 'Documentation', 'Release'] + }); + + todoList.get('isDone'); // false + todoList.get('todos').clear(); + todoList.get('isDone'); // true + ``` + + @since 1.6.0 + @method empty + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which negate + the original value for property + @public + */ - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; - - var innerHTMLWrapper = { - colgroup: { depth: 2, before: '', after: '
    ' }, - table: { depth: 1, before: '', after: '
    ' }, - tbody: { depth: 2, before: '', after: '
    ' }, - tfoot: { depth: 2, before: '', after: '
    ' }, - thead: { depth: 2, before: '', after: '
    ' }, - tr: { depth: 3, before: '', after: '
    ' } - }; - // Patch: innerHTML Fix - // Browsers: IE9 - // Reason: IE9 don't allow us to set innerHTML on col, colgroup, frameset, - // html, style, table, tbody, tfoot, thead, title, tr. - // Fix: Wrap the innerHTML we are about to set in its parents, apply the - // wrapped innerHTML on a div, then move the unwrapped nodes into the - // target position. - - function domChanges(document, DOMChangesClass) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document)) { - return DOMChangesClass; - } - var div = document.createElement('div'); - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithInnerHTMLFix, _DOMChangesClass); - - function DOMChangesWithInnerHTMLFix() { - _DOMChangesClass.apply(this, arguments); - } + function empty(dependentKey) { + return _emberMetal.computed(dependentKey + '.length', function () { + return _emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); + }); + } - DOMChangesWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null || html === '') { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - var parentTag = parent.tagName.toLowerCase(); - var wrapper = innerHTMLWrapper[parentTag]; - if (wrapper === undefined) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - return fixInnerHTML(parent, wrapper, div, html, nextSibling); - }; + /** + A computed property that returns true if the value of the dependent + property is NOT null, an empty string, empty array, or empty function. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasStuff: Ember.computed.notEmpty('backpack') + }); + + let hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); + + hamster.get('hasStuff'); // true + hamster.get('backpack').clear(); // [] + hamster.get('hasStuff'); // false + ``` + + @method notEmpty + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which returns true if + original value for property is not empty. + @public + */ - return DOMChangesWithInnerHTMLFix; - })(DOMChangesClass); - } + function notEmpty(dependentKey) { + return _emberMetal.computed(dependentKey + '.length', function () { + return !_emberMetal.isEmpty(_emberMetal.get(this, dependentKey)); + }); + } - function treeConstruction(document, DOMTreeConstructionClass) { - if (!document) return DOMTreeConstructionClass; - if (!shouldApplyFix(document)) { - return DOMTreeConstructionClass; - } - var div = document.createElement('div'); - return (function (_DOMTreeConstructionClass) { - babelHelpers.inherits(DOMTreeConstructionWithInnerHTMLFix, _DOMTreeConstructionClass); + /** + A computed property that returns true if the value of the dependent + property is null or undefined. This avoids errors from JSLint complaining + about use of ==, which can be technically confusing. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + isHungry: Ember.computed.none('food') + }); + + let hamster = Hamster.create(); + + hamster.get('isHungry'); // true + hamster.set('food', 'Banana'); + hamster.get('isHungry'); // false + hamster.set('food', null); + hamster.get('isHungry'); // true + ``` + + @method none + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which + returns true if original value for property is null or undefined. + @public + */ - function DOMTreeConstructionWithInnerHTMLFix() { - _DOMTreeConstructionClass.apply(this, arguments); - } + function none(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.isNone(_emberMetal.get(this, dependentKey)); + }); + } - DOMTreeConstructionWithInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null || html === '') { - return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - var parentTag = parent.tagName.toLowerCase(); - var wrapper = innerHTMLWrapper[parentTag]; - if (wrapper === undefined) { - return _DOMTreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - return fixInnerHTML(parent, wrapper, div, html, reference); - }; + /** + A computed property that returns the inverse boolean value + of the original value for the dependent property. + + Example + + ```javascript + let User = Ember.Object.extend({ + isAnonymous: Ember.computed.not('loggedIn') + }); + + let user = User.create({loggedIn: false}); + + user.get('isAnonymous'); // true + user.set('loggedIn', true); + user.get('isAnonymous'); // false + ``` + + @method not + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which returns + inverse of the original value for property + @public + */ - return DOMTreeConstructionWithInnerHTMLFix; - })(DOMTreeConstructionClass); - } + function not(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return !_emberMetal.get(this, dependentKey); + }); + } - function fixInnerHTML(parent, wrapper, div, html, reference) { - var wrappedHtml = wrapper.before + html + wrapper.after; - div.innerHTML = wrappedHtml; - var parentNode = div; - for (var i = 0; i < wrapper.depth; i++) { - parentNode = parentNode.childNodes[0]; - } + /** + A computed property that converts the provided dependent property + into a boolean value. + + ```javascript + let Hamster = Ember.Object.extend({ + hasBananas: Ember.computed.bool('numBananas') + }); + + let hamster = Hamster.create(); + + hamster.get('hasBananas'); // false + hamster.set('numBananas', 0); + hamster.get('hasBananas'); // false + hamster.set('numBananas', 1); + hamster.get('hasBananas'); // true + hamster.set('numBananas', null); + hamster.get('hasBananas'); // false + ``` + + @method bool + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which converts + to boolean the original value for property + @public + */ - var _moveNodesBefore = _glimmerRuntimeLibDomHelper.moveNodesBefore(parentNode, parent, reference); + function bool(dependentKey) { + return _emberMetal.computed(dependentKey, function () { + return !!_emberMetal.get(this, dependentKey); + }); + } - var first = _moveNodesBefore[0]; - var last = _moveNodesBefore[1]; + /** + A computed property which matches the original value for the + dependent property against a given RegExp, returning `true` + if the value matches the RegExp and `false` if it does not. + + Example + + ```javascript + let User = Ember.Object.extend({ + hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) + }); + + let user = User.create({loggedIn: false}); + + user.get('hasValidEmail'); // false + user.set('email', ''); + user.get('hasValidEmail'); // false + user.set('email', 'ember_hamster@example.com'); + user.get('hasValidEmail'); // true + ``` + + @method match + @for Ember.computed + @param {String} dependentKey + @param {RegExp} regexp + @return {Ember.ComputedProperty} computed property which match + the original value for property against a given RegExp + @public + */ - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - function shouldApplyFix(document) { - var table = document.createElement('table'); - try { - table.innerHTML = ''; - } catch (e) {} finally { - if (table.childNodes.length !== 0) { - // It worked as expected, no fix required - return false; - } - } - return true; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L2lubmVyLWh0bWwtZml4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQVNBLFFBQUksZ0JBQWdCLEdBQUc7QUFDckIsZ0JBQVEsRUFBRSxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsTUFBTSxFQUFFLG1CQUFtQixFQUFFLEtBQUssRUFBRSxxQkFBcUIsRUFBRTtBQUNqRixhQUFLLEVBQUssRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFFLFVBQVUsRUFBRTtBQUM1RCxhQUFLLEVBQUssRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxnQkFBZ0IsRUFBRSxLQUFLLEVBQUUsa0JBQWtCLEVBQUU7QUFDM0UsYUFBSyxFQUFLLEVBQUUsS0FBSyxFQUFFLENBQUMsRUFBRSxNQUFNLEVBQUUsZ0JBQWdCLEVBQUUsS0FBSyxFQUFFLGtCQUFrQixFQUFFO0FBQzNFLGFBQUssRUFBSyxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsTUFBTSxFQUFFLGdCQUFnQixFQUFFLEtBQUssRUFBRSxrQkFBa0IsRUFBRTtBQUMzRSxVQUFFLEVBQVEsRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxvQkFBb0IsRUFBRSxLQUFLLEVBQUUsdUJBQXVCLEVBQUU7S0FDckYsQ0FBQzs7Oz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zdF0gPSBtb3ZlTm9kZXNCZWZvcmUocGFyZW50Tm9kZSwgcGFyZW50LCByZWZlcmVuY2UpO1xuICByZXR1cm4gbmV3IENvbmNyZXRlQm91bmRzKHBhcmVudCwgZmlyc3QsIGxhc3QpO1xufVxuXG5mdW5jdGlvbiBzaG91bGRBcHBseUZpeChkb2N1bWVudCkge1xuICBsZXQgdGFibGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCd0YWJsZScpO1xuICB0cnkge1xuICAgIHRhYmxlLmlubmVySFRNTCA9ICc8dGJvZHk+PC90Ym9keT4nO1xuICB9IGNhdGNoIChlKSB7XG4gIH0gZmluYWxseSB7XG4gICAgaWYgKHRhYmxlLmNoaWxkTm9kZXMubGVuZ3RoICE9PSAwKSB7XG4gICAgICAvLyBJdCB3b3JrZWQgYXMgZXhwZWN0ZWQsIG5vIGZpeCByZXF1aXJlZFxuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgfVxuXG4gIHJldHVybiB0cnVlO1xufVxuIl19 -enifed('glimmer-runtime/lib/compat/svg-inner-html-fix', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/dom/helper'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibDomHelper) { - 'use strict'; + function match(dependentKey, regexp) { + return _emberMetal.computed(dependentKey, function () { + var value = _emberMetal.get(this, dependentKey); - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; - - var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - // Patch: insertAdjacentHTML on SVG Fix - // Browsers: Safari, IE, Edge, Firefox ~33-34 - // Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is - // present but throws an exception on IE and Edge. Old versions of - // Firefox create nodes in the incorrect namespace. - // Fix: Since IE and Edge silently fail to create SVG nodes using - // innerHTML, and because Firefox may create nodes in the incorrect - // namespace using innerHTML on SVG elements, an HTML-string wrapping - // approach is used. A pre/post SVG tag is added to the string, then - // that whole string is added to a div. The created nodes are plucked - // out and applied to the target location on DOM. - - function domChanges(document, DOMChangesClass, svgNamespace) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document, svgNamespace)) { - return DOMChangesClass; - } - var div = document.createElement('div'); - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithSVGInnerHTMLFix, _DOMChangesClass); - - function DOMChangesWithSVGInnerHTMLFix() { - _DOMChangesClass.apply(this, arguments); - } + return typeof value === 'string' ? regexp.test(value) : false; + }); + } - DOMChangesWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null || html === '') { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - if (parent.namespaceURI !== svgNamespace) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - return fixSVG(parent, div, html, nextSibling); - }; + /** + A computed property that returns true if the provided dependent property + is equal to the given value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + satisfied: Ember.computed.equal('percentCarrotsEaten', 100) + }); + + let hamster = Hamster.create(); + + hamster.get('satisfied'); // false + hamster.set('percentCarrotsEaten', 100); + hamster.get('satisfied'); // true + hamster.set('percentCarrotsEaten', 50); + hamster.get('satisfied'); // false + ``` + + @method equal + @for Ember.computed + @param {String} dependentKey + @param {String|Number|Object} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is equal to the given value. + @public + */ - return DOMChangesWithSVGInnerHTMLFix; - })(DOMChangesClass); - } + function equal(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) === value; + }); + } - function treeConstruction(document, TreeConstructionClass, svgNamespace) { - if (!document) return TreeConstructionClass; - if (!shouldApplyFix(document, svgNamespace)) { - return TreeConstructionClass; - } - var div = document.createElement('div'); - return (function (_TreeConstructionClass) { - babelHelpers.inherits(TreeConstructionWithSVGInnerHTMLFix, _TreeConstructionClass); + /** + A computed property that returns true if the provided dependent property + is greater than the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasTooManyBananas: Ember.computed.gt('numBananas', 10) + }); + + let hamster = Hamster.create(); + + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 3); + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 11); + hamster.get('hasTooManyBananas'); // true + ``` + + @method gt + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is greater than given value. + @public + */ - function TreeConstructionWithSVGInnerHTMLFix() { - _TreeConstructionClass.apply(this, arguments); - } + function gt(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) > value; + }); + } - TreeConstructionWithSVGInnerHTMLFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null || html === '') { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - if (parent.namespaceURI !== svgNamespace) { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - return fixSVG(parent, div, html, reference); - }; + /** + A computed property that returns true if the provided dependent property + is greater than or equal to the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + hasTooManyBananas: Ember.computed.gte('numBananas', 10) + }); + + let hamster = Hamster.create(); + + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 3); + hamster.get('hasTooManyBananas'); // false + hamster.set('numBananas', 10); + hamster.get('hasTooManyBananas'); // true + ``` + + @method gte + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is greater or equal then given value. + @public + */ - return TreeConstructionWithSVGInnerHTMLFix; - })(TreeConstructionClass); - } + function gte(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) >= value; + }); + } - function fixSVG(parent, div, html, reference) { - // IE, Edge: also do not correctly support using `innerHTML` on SVG - // namespaced elements. So here a wrapper is used. - var wrappedHtml = '' + html + ''; - div.innerHTML = wrappedHtml; + /** + A computed property that returns true if the provided dependent property + is less than the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + needsMoreBananas: Ember.computed.lt('numBananas', 3) + }); + + let hamster = Hamster.create(); + + hamster.get('needsMoreBananas'); // true + hamster.set('numBananas', 3); + hamster.get('needsMoreBananas'); // false + hamster.set('numBananas', 2); + hamster.get('needsMoreBananas'); // true + ``` + + @method lt + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is less then given value. + @public + */ - var _moveNodesBefore = _glimmerRuntimeLibDomHelper.moveNodesBefore(div.firstChild, parent, reference); + function lt(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) < value; + }); + } - var first = _moveNodesBefore[0]; - var last = _moveNodesBefore[1]; + /** + A computed property that returns true if the provided dependent property + is less than or equal to the provided value. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + needsMoreBananas: Ember.computed.lte('numBananas', 3) + }); + + let hamster = Hamster.create(); + + hamster.get('needsMoreBananas'); // true + hamster.set('numBananas', 5); + hamster.get('needsMoreBananas'); // false + hamster.set('numBananas', 3); + hamster.get('needsMoreBananas'); // true + ``` + + @method lte + @for Ember.computed + @param {String} dependentKey + @param {Number} value + @return {Ember.ComputedProperty} computed property which returns true if + the original value for property is less or equal than given value. + @public + */ - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - function shouldApplyFix(document, svgNamespace) { - var svg = document.createElementNS(svgNamespace, 'svg'); - try { - svg['insertAdjacentHTML']('beforeEnd', ''); - } catch (e) {} finally { - // FF: Old versions will create a node in the wrong namespace - if (svg.childNodes.length === 1 && svg.firstChild.namespaceURI === SVG_NAMESPACE) { - // The test worked as expected, no fix required - return false; - } - svg = null; - return true; - } - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L3N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AgfSBmaW5hbGx5IHtcbiAgICAvLyBGRjogT2xkIHZlcnNpb25zIHdpbGwgY3JlYXRlIGEgbm9kZSBpbiB0aGUgd3JvbmcgbmFtZXNwYWNlXG4gICAgaWYgKHN2Zy5jaGlsZE5vZGVzLmxlbmd0aCA9PT0gMSAmJiBzdmcuZmlyc3RDaGlsZC5uYW1lc3BhY2VVUkkgPT09IFNWR19OQU1FU1BBQ0UpIHtcbiAgICAgIC8vIFRoZSB0ZXN0IHdvcmtlZCBhcyBleHBlY3RlZCwgbm8gZml4IHJlcXVpcmVkXG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIHN2ZyA9IG51bGw7XG5cbiAgICByZXR1cm4gdHJ1ZTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compat/text-node-merging-fix', ['exports'], function (exports) { - // Patch: Adjacent text node merging fix - // Browsers: IE, Edge, Firefox w/o inspector open - // Reason: These browsers will merge adjacent text nodes. For exmaple given - //
    Hello
    with div.insertAdjacentHTML(' world') browsers - // with proper behavior will populate div.childNodes with two items. - // These browsers will populate it with one merged node instead. - // Fix: Add these nodes to a wrapper element, then iterate the childNodes - // of that wrapper and move the nodes to their target location. Note - // that potential SVG bugs will have been handled before this fix. - // Note that this fix must only apply to the previous text node, as - // the base implementation of `insertHTMLBefore` already handles - // following text nodes correctly. - 'use strict'; + function lte(dependentKey, value) { + return _emberMetal.computed(dependentKey, function () { + return _emberMetal.get(this, dependentKey) <= value; + }); + } - exports.domChanges = domChanges; - exports.treeConstruction = treeConstruction; + /** + A computed property that performs a logical `and` on the + original values for the provided dependent properties. + + You may pass in more than two properties and even use + property brace expansion. The computed property will + return the first falsy value or last truthy value + just like JavaScript's `&&` operator. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), + readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') + }); + + let tomster = Hamster.create(); + + tomster.get('readyForCamp'); // false + tomster.set('hasTent', true); + tomster.get('readyForCamp'); // false + tomster.set('hasBackpack', true); + tomster.get('readyForCamp'); // true + tomster.set('hasBackpack', 'Yes'); + tomster.get('readyForCamp'); // 'Yes' + tomster.set('hasWalkingStick', null); + tomster.get('readyForHike'); // null + ``` + + @method and + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which performs + a logical `and` on the values of all the original values for properties. + @public + */ + var and = generateComputedWithPredicate('and', function (value) { + return value; + }); - function domChanges(document, DOMChangesClass) { - if (!document) return DOMChangesClass; - if (!shouldApplyFix(document)) { - return DOMChangesClass; - } - return (function (_DOMChangesClass) { - babelHelpers.inherits(DOMChangesWithTextNodeMergingFix, _DOMChangesClass); + exports.and = and; + /** + A computed property which performs a logical `or` on the + original values for the provided dependent properties. + + You may pass in more than two properties and even use + property brace expansion. The computed property will + return the first truthy value or last falsy value just + like JavaScript's `||` operator. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'), + readyForBeach: Ember.computed.or('{hasSunscreen,hasUmbrella}') + }); + + let tomster = Hamster.create(); + + tomster.get('readyForRain'); // undefined + tomster.set('hasUmbrella', true); + tomster.get('readyForRain'); // true + tomster.set('hasJacket', 'Yes'); + tomster.get('readyForRain'); // 'Yes' + tomster.set('hasSunscreen', 'Check'); + tomster.get('readyForBeach'); // 'Check' + ``` + + @method or + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which performs + a logical `or` on the values of all the original values for properties. + @public + */ + var or = generateComputedWithPredicate('or', function (value) { + return !value; + }); - function DOMChangesWithTextNodeMergingFix(document) { - _DOMChangesClass.call(this, document); - this.uselessComment = document.createComment(''); - } + exports.or = or; + /** + Creates a new property that is an alias for another property + on an object. Calls to `get` or `set` this property behave as + though they were called on the original property. + + ```javascript + let Person = Ember.Object.extend({ + name: 'Alex Matchneer', + nomen: Ember.computed.alias('name') + }); + + let alex = Person.create(); + + alex.get('nomen'); // 'Alex Matchneer' + alex.get('name'); // 'Alex Matchneer' + + alex.set('nomen', '@machty'); + alex.get('name'); // '@machty' + ``` + + @method alias + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates an + alias to the original value for property. + @public + */ - DOMChangesWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, nextSibling, html) { - if (html === null) { - return _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - } - var didSetUselessComment = false; - var nextPrevious = nextSibling ? nextSibling.previousSibling : parent.lastChild; - if (nextPrevious && nextPrevious instanceof Text) { - didSetUselessComment = true; - parent.insertBefore(this.uselessComment, nextSibling); - } - var bounds = _DOMChangesClass.prototype.insertHTMLBefore.call(this, parent, nextSibling, html); - if (didSetUselessComment) { - parent.removeChild(this.uselessComment); - } - return bounds; - }; + /** + Where `computed.alias` aliases `get` and `set`, and allows for bidirectional + data flow, `computed.oneWay` only provides an aliased `get`. The `set` will + not mutate the upstream property, rather causes the current property to + become the value set. This causes the downstream property to permanently + diverge from the upstream property. + + Example + + ```javascript + let User = Ember.Object.extend({ + firstName: null, + lastName: null, + nickName: Ember.computed.oneWay('firstName') + }); + + let teddy = User.create({ + firstName: 'Teddy', + lastName: 'Zeenny' + }); + + teddy.get('nickName'); // 'Teddy' + teddy.set('nickName', 'TeddyBear'); // 'TeddyBear' + teddy.get('firstName'); // 'Teddy' + ``` + + @method oneWay + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @public + */ - return DOMChangesWithTextNodeMergingFix; - })(DOMChangesClass); - } + function oneWay(dependentKey) { + return _emberMetal.alias(dependentKey).oneWay(); + } - function treeConstruction(document, TreeConstructionClass) { - if (!document) return TreeConstructionClass; - if (!shouldApplyFix(document)) { - return TreeConstructionClass; - } - return (function (_TreeConstructionClass) { - babelHelpers.inherits(TreeConstructionWithTextNodeMergingFix, _TreeConstructionClass); + /** + This is a more semantically meaningful alias of `computed.oneWay`, + whose name is somewhat ambiguous as to which direction the data flows. + + @method reads + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @public + */ - function TreeConstructionWithTextNodeMergingFix(document) { - _TreeConstructionClass.call(this, document); - this.uselessComment = this.createComment(''); - } + /** + Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides + a readOnly one way binding. Very often when using `computed.oneWay` one does + not also want changes to propagate back up, as they will replace the value. + + This prevents the reverse flow, and also throws an exception when it occurs. + + Example + + ```javascript + let User = Ember.Object.extend({ + firstName: null, + lastName: null, + nickName: Ember.computed.readOnly('firstName') + }); + + let teddy = User.create({ + firstName: 'Teddy', + lastName: 'Zeenny' + }); + + teddy.get('nickName'); // 'Teddy' + teddy.set('nickName', 'TeddyBear'); // throws Exception + // throw new Ember.Error('Cannot Set: nickName on: ' );` + teddy.get('firstName'); // 'Teddy' + ``` + + @method readOnly + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computed property which creates a + one way computed property to the original value for property. + @since 1.5.0 + @public + */ - TreeConstructionWithTextNodeMergingFix.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - if (html === null) { - return _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - } - var didSetUselessComment = false; - var nextPrevious = reference ? reference.previousSibling : parent.lastChild; - if (nextPrevious && nextPrevious instanceof Text) { - didSetUselessComment = true; - parent.insertBefore(this.uselessComment, reference); - } - var bounds = _TreeConstructionClass.prototype.insertHTMLBefore.call(this, parent, html, reference); - if (didSetUselessComment) { - parent.removeChild(this.uselessComment); - } - return bounds; - }; + function readOnly(dependentKey) { + return _emberMetal.alias(dependentKey).readOnly(); + } - return TreeConstructionWithTextNodeMergingFix; - })(TreeConstructionClass); - } + /** + Creates a new property that is an alias for another property + on an object. Calls to `get` or `set` this property behave as + though they were called on the original property, but also + print a deprecation warning. + + ```javascript + let Hamster = Ember.Object.extend({ + bananaCount: Ember.computed.deprecatingAlias('cavendishCount', { + id: 'hamster.deprecate-banana', + until: '3.0.0' + }) + }); + + let hamster = Hamster.create(); + + hamster.set('bananaCount', 5); // Prints a deprecation warning. + hamster.get('cavendishCount'); // 5 + ``` + + @method deprecatingAlias + @for Ember.computed + @param {String} dependentKey + @param {Object} options Options for `Ember.deprecate`. + @return {Ember.ComputedProperty} computed property which creates an + alias with a deprecation to the original value for property. + @since 1.7.0 + @public + */ - function shouldApplyFix(document) { - var mergingTextDiv = document.createElement('div'); - mergingTextDiv.innerHTML = 'first'; - mergingTextDiv.insertAdjacentHTML('beforeEnd', 'second'); - if (mergingTextDiv.childNodes.length === 2) { - mergingTextDiv = null; - // It worked as expected, no fix required - return false; - } - mergingTextDiv = null; - return true; - } + function deprecatingAlias(dependentKey, options) { + return _emberMetal.computed(dependentKey, { + get: function (key) { + return _emberMetal.get(this, dependentKey); + }, + set: function (key, value) { + _emberMetal.set(this, dependentKey, value); + return value; + } + }); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGF0L3RleHQtbm9kZS1tZXJnaW5nLWZpeC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFlQSxhQUFBLFVBQUEsQ0FBMkIsUUFBa0IsRUFBRSxlQUFrQyxFQUFBO0FBQy9FLFlBQUksQ0FBQyxRQUFRLEVBQUUsT0FBTyxlQUFlLENBQUM7QUFFdEMsWUFBSSxDQUFDLGNBQWMsQ0FBQyxRQUFRLENBQUMsRUFBRTtBQUM3QixtQkFBTyxlQUFlLENBQUM7U0FDeEI7QUFFRDtrQ0FBTyxnQ0FBQTs7QUFHTCxxQkFISyxnQ0FBQSxDQUdPLFFBQVEsRUFBQTtBQUNsQiw0Q0FBTSxRQUFRLENBQUMsQ0FBQztBQUNoQixvQkFBSSxDQUFDLGNBQWMsR0FBRyxRQUFRLENBQUMsY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biAgICAvLyBJdCB3b3JrZWQgYXMgZXhwZWN0ZWQsIG5vIGZpeCByZXF1aXJlZFxuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuXG4gIG1lcmdpbmdUZXh0RGl2ID0gbnVsbDtcblxuICByZXR1cm4gdHJ1ZTtcbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/blocks', ['exports', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/compiler'], function (exports, _glimmerRuntimeLibUtils, _glimmerRuntimeLibCompiler) { - 'use strict'; +enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) { + /** + @module ember + @submodule ember-runtime + */ - var CompiledBlock = function CompiledBlock(ops, symbols) { - this.ops = ops; - this.symbols = symbols; - }; + 'use strict'; - exports.CompiledBlock = CompiledBlock; + exports.sum = sum; + exports.max = max; + exports.min = min; + exports.map = map; + exports.mapBy = mapBy; + exports.filter = filter; + exports.filterBy = filterBy; + exports.uniq = uniq; + exports.uniqBy = uniqBy; + exports.intersect = intersect; + exports.setDiff = setDiff; + exports.collect = collect; + exports.sort = sort; - var Block = function Block(program, symbolTable) { - this.program = program; - this.symbolTable = symbolTable; - this.compiled = null; - }; + function reduceMacro(dependentKey, callback, initialValue) { + return _emberMetal.computed(dependentKey + '.[]', function () { + var _this = this; - exports.Block = Block; + var arr = _emberMetal.get(this, dependentKey); - var InlineBlock = (function (_Block) { - babelHelpers.inherits(InlineBlock, _Block); + if (arr === null || typeof arr !== 'object') { + return initialValue; + } - function InlineBlock(program, symbolTable) { - var locals = arguments.length <= 2 || arguments[2] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[2]; + return arr.reduce(function (previousValue, currentValue, index, array) { + return callback.call(_this, previousValue, currentValue, index, array); + }, initialValue); + }).readOnly(); + } - _Block.call(this, program, symbolTable); - this.locals = locals; - } + function arrayMacro(dependentKey, callback) { + // This is a bit ugly + var propertyName = undefined; + if (/@each/.test(dependentKey)) { + propertyName = dependentKey.replace(/\.@each.*$/, ''); + } else { + propertyName = dependentKey; + dependentKey += '.[]'; + } - InlineBlock.prototype.hasPositionalParameters = function hasPositionalParameters() { - return !!this.locals.length; - }; + return _emberMetal.computed(dependentKey, function () { + var value = _emberMetal.get(this, propertyName); + if (_emberRuntimeUtils.isArray(value)) { + return _emberRuntimeSystemNative_array.A(callback.call(this, value)); + } else { + return _emberRuntimeSystemNative_array.A(); + } + }).readOnly(); + } - InlineBlock.prototype.compile = function compile(env) { - var compiled = this.compiled; - if (compiled) return compiled; - var ops = new _glimmerRuntimeLibCompiler.InlineBlockCompiler(this, env).compile(); - return this.compiled = new CompiledBlock(ops, this.symbolTable.size); - }; + function multiArrayMacro(dependentKeys, callback) { + var args = dependentKeys.map(function (key) { + return key + '.[]'; + }); - return InlineBlock; - })(Block); + args.push(function () { + return _emberRuntimeSystemNative_array.A(callback.call(this, dependentKeys)); + }); - exports.InlineBlock = InlineBlock; + return _emberMetal.computed.apply(this, args).readOnly(); + } - var PartialBlock = (function (_InlineBlock) { - babelHelpers.inherits(PartialBlock, _InlineBlock); + /** + A computed property that returns the sum of the values + in the dependent array. + + @method sum + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the sum of all values in the dependentKey's array + @since 1.4.0 + @public + */ - function PartialBlock() { - _InlineBlock.apply(this, arguments); - } + function sum(dependentKey) { + return reduceMacro(dependentKey, function (sum, item) { + return sum + item; + }, 0); + } - return PartialBlock; - })(InlineBlock); + /** + A computed property that calculates the maximum value in the + dependent array. This will return `-Infinity` when the dependent + array is empty. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age'), + maxChildAge: Ember.computed.max('childAges') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('maxChildAge'); // -Infinity + lordByron.get('children').pushObject({ + name: 'Augusta Ada Byron', age: 7 + }); + lordByron.get('maxChildAge'); // 7 + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('maxChildAge'); // 8 + ``` + + If the types of the arguments are not numbers, + they will be converted to numbers and the type + of the return value will always be `Number`. + For example, the max of a list of Date objects will be + the highest timestamp as a `Number`. + This behavior is consistent with `Math.max`. + + @method max + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array + @public + */ - exports.PartialBlock = PartialBlock; + function max(dependentKey) { + return reduceMacro(dependentKey, function (max, item) { + return Math.max(max, item); + }, -Infinity); + } - var TopLevelTemplate = (function (_Block2) { - babelHelpers.inherits(TopLevelTemplate, _Block2); + /** + A computed property that calculates the minimum value in the + dependent array. This will return `Infinity` when the dependent + array is empty. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age'), + minChildAge: Ember.computed.min('childAges') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('minChildAge'); // Infinity + lordByron.get('children').pushObject({ + name: 'Augusta Ada Byron', age: 7 + }); + lordByron.get('minChildAge'); // 7 + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('minChildAge'); // 5 + ``` + + If the types of the arguments are not numbers, + they will be converted to numbers and the type + of the return value will always be `Number`. + For example, the min of a list of Date objects will be + the lowest timestamp as a `Number`. + This behavior is consistent with `Math.min`. + + @method min + @for Ember.computed + @param {String} dependentKey + @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array + @public + */ - function TopLevelTemplate() { - _Block2.apply(this, arguments); - } + function min(dependentKey) { + return reduceMacro(dependentKey, function (min, item) { + return Math.min(min, item); + }, Infinity); + } - return TopLevelTemplate; - })(Block); + /** + Returns an array mapped via the callback + + The callback method you provide should have the following signature. + `item` is the current item in the iteration. + `index` is the integer index of the current item in the iteration. + + ```javascript + function(item, index); + ``` + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + excitingChores: Ember.computed.map('chores', function(chore, index) { + return chore.toUpperCase() + '!'; + }) + }); + + let hamster = Hamster.create({ + chores: ['clean', 'write more unit tests'] + }); + + hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] + ``` + + @method map + @for Ember.computed + @param {String} dependentKey + @param {Function} callback + @return {Ember.ComputedProperty} an array mapped via the callback + @public + */ - exports.TopLevelTemplate = TopLevelTemplate; + function map(dependentKey, callback) { + return arrayMacro(dependentKey, function (value) { + return value.map(callback, this); + }); + } - var EntryPoint = (function (_TopLevelTemplate) { - babelHelpers.inherits(EntryPoint, _TopLevelTemplate); + /** + Returns an array mapped to the specified key. + + ```javascript + let Person = Ember.Object.extend({ + childAges: Ember.computed.mapBy('children', 'age') + }); + + let lordByron = Person.create({ children: [] }); + + lordByron.get('childAges'); // [] + lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); + lordByron.get('childAges'); // [7] + lordByron.get('children').pushObjects([{ + name: 'Allegra Byron', + age: 5 + }, { + name: 'Elizabeth Medora Leigh', + age: 8 + }]); + lordByron.get('childAges'); // [7, 5, 8] + ``` + + @method mapBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @return {Ember.ComputedProperty} an array mapped to the specified key + @public + */ - function EntryPoint() { - _TopLevelTemplate.apply(this, arguments); - } + function mapBy(dependentKey, propertyKey) { - EntryPoint.prototype.compile = function compile(env) { - var compiled = this.compiled; - if (compiled) return compiled; - var ops = new _glimmerRuntimeLibCompiler.EntryPointCompiler(this, env).compile(); - return this.compiled = new CompiledBlock(ops, this.symbolTable.size); - }; + return map(dependentKey + '.@each.' + propertyKey, function (item) { + return _emberMetal.get(item, propertyKey); + }); + } - return EntryPoint; - })(TopLevelTemplate); + /** + Filters the array by the callback. + + The callback method you provide should have the following signature. + `item` is the current item in the iteration. + `index` is the integer index of the current item in the iteration. + `array` is the dependant array itself. + + ```javascript + function(item, index, array); + ``` + + ```javascript + let Hamster = Ember.Object.extend({ + remainingChores: Ember.computed.filter('chores', function(chore, index, array) { + return !chore.done; + }) + }); + + let hamster = Hamster.create({ + chores: [ + { name: 'cook', done: true }, + { name: 'clean', done: true }, + { name: 'write more unit tests', done: false } + ] + }); + + hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] + ``` + + @method filter + @for Ember.computed + @param {String} dependentKey + @param {Function} callback + @return {Ember.ComputedProperty} the filtered array + @public + */ - exports.EntryPoint = EntryPoint; + function filter(dependentKey, callback) { + return arrayMacro(dependentKey, function (value) { + return value.filter(callback, this); + }); + } - var Layout = (function (_TopLevelTemplate2) { - babelHelpers.inherits(Layout, _TopLevelTemplate2); + /** + Filters the array by the property and value + + ```javascript + let Hamster = Ember.Object.extend({ + remainingChores: Ember.computed.filterBy('chores', 'done', false) + }); + + let hamster = Hamster.create({ + chores: [ + { name: 'cook', done: true }, + { name: 'clean', done: true }, + { name: 'write more unit tests', done: false } + ] + }); + + hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] + ``` + + @method filterBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @param {*} value + @return {Ember.ComputedProperty} the filtered array + @public + */ - function Layout(program, symbolTable, named, yields, hasPartials) { - _TopLevelTemplate2.call(this, program, symbolTable); - this.named = named; - this.yields = yields; - this.hasPartials = hasPartials; - this.hasNamedParameters = !!this.named.length; - this.hasYields = !!this.yields.length; - ; - } + function filterBy(dependentKey, propertyKey, value) { + var callback = undefined; - return Layout; - })(TopLevelTemplate); + if (arguments.length === 2) { + callback = function (item) { + return _emberMetal.get(item, propertyKey); + }; + } else { + callback = function (item) { + return _emberMetal.get(item, propertyKey) === value; + }; + } - exports.Layout = Layout; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvYm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VudHJ5UG9pbnQgZXh0ZW5kcyBUb3BMZXZlbFRlbXBsYXRlIHtcbiAgY29tcGlsZShlbnY6IEVudmlyb25tZW50KSB7XG4gICAgbGV0IGNvbXBpbGVkID0gdGhpcy5jb21waWxlZDtcbiAgICBpZiAoY29tcGlsZWQpIHJldHVybiBjb21waWxlZDtcblxuICAgIGxldCBvcHMgPSBuZXcgRW50cnlQb2ludENvbXBpbGVyKHRoaXMsIGVudikuY29tcGlsZSgpO1xuICAgIHJldHVybiB0aGlzLmNvbXBpbGVkID0gbmV3IENvbXBpbGVkQmxvY2sob3BzLCB0aGlzLnN5bWJvbFRhYmxlLnNpemUpO1xuICB9XG59XG5cbmV4cG9ydCBjbGFzcyBMYXlvdXQgZXh0ZW5kcyBUb3BMZXZlbFRlbXBsYXRlIHtcbiAgcHVibGljIGhhc05hbWVkUGFyYW1ldGVyczogYm9vbGVhbjtcbiAgcHVibGljIGhhc1lpZWxkczogYm9vbGVhbjtcbiAgY29uc3RydWN0b3IocHJvZ3JhbTogUHJvZ3JhbSwgc3ltYm9sVGFibGU6IFN5bWJvbFRhYmxlLCBwdWJsaWMgbmFtZWQ6IHN0cmluZ1tdLCBwdWJsaWMgeWllbGRzOiBzdHJpbmdbXSwgcHVibGljIGhhc1BhcnRpYWxzOiBib29sZWFuKSB7XG4gICAgc3VwZXIocHJvZ3JhbSwgc3ltYm9sVGFibGUpO1xuICAgIHRoaXMuaGFzTmFtZWRQYXJhbWV0ZXJzID0gISF0aGlzLm5hbWVkLmxlbmd0aDtcbiAgICB0aGlzLmhhc1lpZWxkcyA9ICEhdGhpcy55aWVsZHMubGVuZ3RoOztcbiAgfVxufVxuIl19 -enifed("glimmer-runtime/lib/compiled/expressions", ["exports"], function (exports) { - "use strict"; + return filter(dependentKey + '.@each.' + propertyKey, callback); + } - var CompiledExpression = (function () { - function CompiledExpression() {} + /** + A computed property which returns a new array with all the unique + elements from one or more dependent arrays. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + uniqueFruits: Ember.computed.uniq('fruits') + }); + + let hamster = Hamster.create({ + fruits: [ + 'banana', + 'grape', + 'kale', + 'banana' + ] + }); + + hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale'] + ``` + + @method uniq + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ - CompiledExpression.prototype.toJSON = function toJSON() { - return "UNIMPL: " + this.type.toUpperCase(); - }; + function uniq() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - return CompiledExpression; - })(); + return multiArrayMacro(args, function (dependentKeys) { + var _this2 = this; - exports.CompiledExpression = CompiledExpression; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBR0Esa0JBQUE7aUJBQUEsa0JBQUE7O0FBQUEsMEJBQUEsV0FJRSxNQUFNLEdBQUEsa0JBQUE7QUFDSixnQ0FBa0IsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBRztTQUM3Qzs7ZUFOSCxrQkFBQSIsImZpbGUiOiJleHByZXNzaW9ucy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBWTSBmcm9tICcuLi92bS9hcHBlbmQnO1xuaW1wb3J0IHsgUGF0aFJlZmVyZW5jZSB9IGZyb20gJ2dsaW1tZXItcmVmZXJlbmNlJztcblxuZXhwb3J0IGFic3RyYWN0IGNsYXNzIENvbXBpbGVkRXhwcmVzc2lvbjxUPiB7XG4gIHR5cGU6IHN0cmluZztcbiAgYWJzdHJhY3QgZXZhbHVhdGUodm06IFZNKTogUGF0aFJlZmVyZW5jZTxUPjtcblxuICB0b0pTT04oKTogc3RyaW5nIHtcbiAgICByZXR1cm4gYFVOSU1QTDogJHt0aGlzLnR5cGUudG9VcHBlckNhc2UoKX1gO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/args', ['exports', 'glimmer-runtime/lib/compiled/expressions/positional-args', 'glimmer-runtime/lib/compiled/expressions/named-args', 'glimmer-runtime/lib/syntax/core', 'glimmer-reference'], function (exports, _glimmerRuntimeLibCompiledExpressionsPositionalArgs, _glimmerRuntimeLibCompiledExpressionsNamedArgs, _glimmerRuntimeLibSyntaxCore, _glimmerReference) { - 'use strict'; + var uniq = _emberRuntimeSystemNative_array.A(); - var CompiledArgs = (function () { - function CompiledArgs(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; + dependentKeys.forEach(function (dependentKey) { + var value = _emberMetal.get(_this2, dependentKey); + if (_emberRuntimeUtils.isArray(value)) { + value.forEach(function (item) { + if (uniq.indexOf(item) === -1) { + uniq.push(item); + } + }); } + }); - CompiledArgs.create = function create(positional, named, blocks) { - if (positional === _glimmerRuntimeLibCompiledExpressionsPositionalArgs.COMPILED_EMPTY_POSITIONAL_ARGS && named === _glimmerRuntimeLibCompiledExpressionsNamedArgs.COMPILED_EMPTY_NAMED_ARGS && blocks === _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS) { - return this.empty(); - } else { - return new this(positional, named, blocks); - } - }; + return uniq; + }); + } - CompiledArgs.empty = function empty() { - return COMPILED_EMPTY_ARGS; - }; + /** + A computed property which returns a new array with all the unique + elements from an array, with uniqueness determined by specific key. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + uniqueFruits: Ember.computed.uniqBy('fruits', 'id') + }); + let hamster = Hamster.create({ + fruits: [ + { id: 1, 'banana' }, + { id: 2, 'grape' }, + { id: 3, 'peach' }, + { id: 1, 'banana' } + ] + }); + hamster.get('uniqueFruits'); // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }] + ``` + + @method uniqBy + @for Ember.computed + @param {String} dependentKey + @param {String} propertyKey + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ - CompiledArgs.prototype.evaluate = function evaluate(vm) { - var positional = this.positional; - var named = this.named; - var blocks = this.blocks; + function uniqBy(dependentKey, propertyKey) { + return _emberMetal.computed(dependentKey + '.[]', function () { + var uniq = _emberRuntimeSystemNative_array.A(); + var seen = new _emberUtils.EmptyObject(); + var list = _emberMetal.get(this, dependentKey); + if (_emberRuntimeUtils.isArray(list)) { + list.forEach(function (item) { + var guid = _emberUtils.guidFor(_emberMetal.get(item, propertyKey)); + if (!(guid in seen)) { + seen[guid] = true; + uniq.push(item); + } + }); + } + return uniq; + }).readOnly(); + } - return EvaluatedArgs.create(positional.evaluate(vm), named.evaluate(vm), blocks); - }; + /** + Alias for [Ember.computed.uniq](/api/#method_computed_uniq). + + @method union + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + unique elements from the dependent array + @public + */ + var union = uniq; - return CompiledArgs; - })(); + exports.union = union; + /** + A computed property which returns a new array with all the duplicated + elements from two or more dependent arrays. + + Example + + ```javascript + let obj = Ember.Object.extend({ + friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') + }).create({ + adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], + charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'] + }); + + obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] + ``` + + @method intersect + @for Ember.computed + @param {String} propertyKey* + @return {Ember.ComputedProperty} computes a new array with all the + duplicated elements from the dependent arrays + @public + */ - exports.CompiledArgs = CompiledArgs; + function intersect() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - var COMPILED_EMPTY_ARGS = new ((function (_CompiledArgs) { - babelHelpers.inherits(_class, _CompiledArgs); + return multiArrayMacro(args, function (dependentKeys) { + var _this3 = this; - function _class() { - _CompiledArgs.call(this, _glimmerRuntimeLibCompiledExpressionsPositionalArgs.COMPILED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.COMPILED_EMPTY_NAMED_ARGS, _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS); - } + var arrays = dependentKeys.map(function (dependentKey) { + var array = _emberMetal.get(_this3, dependentKey); - _class.prototype.evaluate = function evaluate(vm) { - return EMPTY_EVALUATED_ARGS; - }; + return _emberRuntimeUtils.isArray(array) ? array : []; + }); - return _class; - })(CompiledArgs))(); + var results = arrays.pop().filter(function (candidate) { + for (var i = 0; i < arrays.length; i++) { + var found = false; + var array = arrays[i]; + for (var j = 0; j < array.length; j++) { + if (array[j] === candidate) { + found = true; + break; + } + } - var EvaluatedArgs = (function () { - function EvaluatedArgs(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; - this.tag = _glimmerReference.combineTagged([positional, named]); + if (found === false) { + return false; + } } - EvaluatedArgs.empty = function empty() { - return EMPTY_EVALUATED_ARGS; - }; - - EvaluatedArgs.create = function create(positional, named, blocks) { - return new this(positional, named, blocks); - }; - - EvaluatedArgs.positional = function positional(values) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS : arguments[1]; - - return new this(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EvaluatedPositionalArgs.create(values), _glimmerRuntimeLibCompiledExpressionsNamedArgs.EVALUATED_EMPTY_NAMED_ARGS, blocks); - }; - - EvaluatedArgs.named = function named(map) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS : arguments[1]; - - return new this(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EVALUATED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.EvaluatedNamedArgs.create(map), blocks); - }; - - return EvaluatedArgs; - })(); + return true; + }); - exports.EvaluatedArgs = EvaluatedArgs; + return _emberRuntimeSystemNative_array.A(results); + }); + } - var EMPTY_EVALUATED_ARGS = new EvaluatedArgs(_glimmerRuntimeLibCompiledExpressionsPositionalArgs.EVALUATED_EMPTY_POSITIONAL_ARGS, _glimmerRuntimeLibCompiledExpressionsNamedArgs.EVALUATED_EMPTY_NAMED_ARGS, _glimmerRuntimeLibSyntaxCore.EMPTY_BLOCKS); - exports.CompiledPositionalArgs = _glimmerRuntimeLibCompiledExpressionsPositionalArgs.CompiledPositionalArgs; - exports.EvaluatedPositionalArgs = _glimmerRuntimeLibCompiledExpressionsPositionalArgs.EvaluatedPositionalArgs; - exports.CompiledNamedArgs = _glimmerRuntimeLibCompiledExpressionsNamedArgs.CompiledNamedArgs; - exports.EvaluatedNamedArgs = _glimmerRuntimeLibCompiledExpressionsNamedArgs.EvaluatedNamedArgs; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvYXJncy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFPQSxZQUFBO0FBYUUsaUJBYkYsWUFBQSxDQWNXLFVBQWtDLEVBQ2xDLEtBQXdCLEVBQ3hCLE1BQWMsRUFBQTtBQUZkLGdCQUFBLENBQUEsVUFBVSxHQUFWLFVBQVUsQ0FBd0I7QUFDbEMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUFtQjtBQUN4QixnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQVE7U0FFdEI7O0FBbEJILG9CQUFBLENBQ1MsTUFBTSxHQUFBLGdCQUFDLFVBQWtDLEVBQUUsS0FBd0IsRUFBRSxNQUFjLEVBQUE7QUFDeEYsZ0JBQUksVUFBVSx5REFSVCw4QkFBOEIsQUFRYyxJQUFJLEtBQUssb0RBUHJELHlCQUF5QixBQU8wRCxJQUFJLE1BQU0sa0NBTnJGLFlBQVksQUFNMEYsRUFBRTtBQUNuSC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HB1YmxpYyBwb3NpdGlvbmFsOiBFdmFsdWF0ZWRQb3NpdGlvbmFsQXJncyxcbiAgICBwdWJsaWMgbmFtZWQ6IEV2YWx1YXRlZE5hbWVkQXJncyxcbiAgICBwdWJsaWMgYmxvY2tzOiBCbG9ja3NcbiAgKSB7XG4gICAgdGhpcy50YWcgPSBjb21iaW5lVGFnZ2VkKFtwb3NpdGlvbmFsLCBuYW1lZF0pO1xuICB9XG59XG5cbmNvbnN0IEVNUFRZX0VWQUxVQVRFRF9BUkdTID0gbmV3IEV2YWx1YXRlZEFyZ3MoRVZBTFVBVEVEX0VNUFRZX1BPU0lUSU9OQUxfQVJHUywgRVZBTFVBVEVEX0VNUFRZX05BTUVEX0FSR1MsIEVNUFRZX0JMT0NLUyk7XG5cbmV4cG9ydCB7IENvbXBpbGVkUG9zaXRpb25hbEFyZ3MsIEV2YWx1YXRlZFBvc2l0aW9uYWxBcmdzLCBDb21waWxlZE5hbWVkQXJncywgRXZhbHVhdGVkTmFtZWRBcmdzIH07XG4iXX0= -enifed("glimmer-runtime/lib/compiled/expressions/concat", ["exports", "glimmer-reference"], function (exports, _glimmerReference) { - "use strict"; + /** + A computed property which returns a new array with all the + properties from the first dependent array that are not in the second + dependent array. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + likes: ['banana', 'grape', 'kale'], + wants: Ember.computed.setDiff('likes', 'fruits') + }); + + let hamster = Hamster.create({ + fruits: [ + 'grape', + 'kale', + ] + }); + + hamster.get('wants'); // ['banana'] + ``` + + @method setDiff + @for Ember.computed + @param {String} setAProperty + @param {String} setBProperty + @return {Ember.ComputedProperty} computes a new array with all the + items from the first dependent array that are not in the second + dependent array + @public + */ - var CompiledConcat = (function () { - function CompiledConcat(parts) { - this.parts = parts; - this.type = "concat"; - } + function setDiff(setAProperty, setBProperty) { + if (arguments.length !== 2) { + throw new _emberMetal.Error('setDiff requires exactly two dependent arrays.'); + } - CompiledConcat.prototype.evaluate = function evaluate(vm) { - var parts = new Array(this.parts.length); - for (var i = 0; i < this.parts.length; i++) { - parts[i] = this.parts[i].evaluate(vm); - } - return new ConcatReference(parts); - }; + return _emberMetal.computed(setAProperty + '.[]', setBProperty + '.[]', function () { + var setA = this.get(setAProperty); + var setB = this.get(setBProperty); - CompiledConcat.prototype.toJSON = function toJSON() { - return "concat(" + this.parts.map(function (expr) { - return expr.toJSON(); - }).join(", ") + ")"; - }; + if (!_emberRuntimeUtils.isArray(setA)) { + return _emberRuntimeSystemNative_array.A(); + } + if (!_emberRuntimeUtils.isArray(setB)) { + return _emberRuntimeSystemNative_array.A(setA); + } - return CompiledConcat; - })(); + return setA.filter(function (x) { + return setB.indexOf(x) === -1; + }); + }).readOnly(); + } - exports.default = CompiledConcat; + /** + A computed property that returns the array of values + for the provided dependent properties. + + Example + + ```javascript + let Hamster = Ember.Object.extend({ + clothes: Ember.computed.collect('hat', 'shirt') + }); + + let hamster = Hamster.create(); + + hamster.get('clothes'); // [null, null] + hamster.set('hat', 'Camp Hat'); + hamster.set('shirt', 'Camp Shirt'); + hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] + ``` + + @method collect + @for Ember.computed + @param {String} dependentKey* + @return {Ember.ComputedProperty} computed property which maps + values of all passed in properties to an array. + @public + */ - var ConcatReference = (function (_CachedReference) { - babelHelpers.inherits(ConcatReference, _CachedReference); + function collect() { + for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + dependentKeys[_key3] = arguments[_key3]; + } - function ConcatReference(parts) { - _CachedReference.call(this); - this.parts = parts; - this.tag = _glimmerReference.combineTagged(parts); + return multiArrayMacro(dependentKeys, function () { + var properties = _emberMetal.getProperties(this, dependentKeys); + var res = _emberRuntimeSystemNative_array.A(); + for (var key in properties) { + if (properties.hasOwnProperty(key)) { + if (_emberMetal.isNone(properties[key])) { + res.push(null); + } else { + res.push(properties[key]); + } } + } + return res; + }); + } - ConcatReference.prototype.compute = function compute() { - var parts = new Array(); - for (var i = 0; i < this.parts.length; i++) { - var value = this.parts[i].value(); - if (value !== null && value !== undefined) { - parts[i] = castToString(this.parts[i].value()); - } - } - if (parts.length > 0) { - return parts.join(''); - } - return null; - }; - - return ConcatReference; - })(_glimmerReference.CachedReference); - - function castToString(value) { - if (typeof value['toString'] !== 'function') { - return ''; + /** + A computed property which returns a new array with all the + properties from the first dependent array sorted based on a property + or sort function. + + The callback method you provide should have the following signature: + + ```javascript + function(itemA, itemB); + ``` + + - `itemA` the first item to compare. + - `itemB` the second item to compare. + + This function should return negative number (e.g. `-1`) when `itemA` should come before + `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after + `itemB`. If the `itemA` and `itemB` are equal this function should return `0`. + + Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or + `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`. + + Example + + ```javascript + let ToDoList = Ember.Object.extend({ + // using standard ascending sort + todosSorting: ['name'], + sortedTodos: Ember.computed.sort('todos', 'todosSorting'), + + // using descending sort + todosSortingDesc: ['name:desc'], + sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), + + // using a custom sort function + priorityTodos: Ember.computed.sort('todos', function(a, b){ + if (a.priority > b.priority) { + return 1; + } else if (a.priority < b.priority) { + return -1; } - return String(value); - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvY29uY2F0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQU1BLGNBQUE7QUFHRSxpQkFIRixjQUFBLENBR3NCLEtBQW1DLEVBQUE7QUFBbkMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUE4QjtBQUZoRCxnQkFBQSxDQUFBLElBQUksR0FBRyxRQUFRLENBQUM7U0FFb0M7O0FBSDdELHNCQUFBLFdBS0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUF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HMpO1xuICB9XG5cbiAgcHJvdGVjdGVkIGNvbXB1dGUoKTogc3RyaW5nIHtcbiAgICBsZXQgcGFydHMgPSBuZXcgQXJyYXk8c3RyaW5nPigpO1xuXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLnBhcnRzLmxlbmd0aDsgaSsrKSB7XG4gICAgICBsZXQgdmFsdWUgPSB0aGlzLnBhcnRzW2ldLnZhbHVlKCk7XG5cbiAgICAgIGlmICh2YWx1ZSAhPT0gbnVsbCAmJiB2YWx1ZSAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIHBhcnRzW2ldID0gY2FzdFRvU3RyaW5nKHRoaXMucGFydHNbaV0udmFsdWUoKSkgYXMgRklYTUU8c3RyaW5nLCAnQ29lcmNlIGZhbHN5IHZhbHVlcyB0byBzdHJpbmdzJz47XG4gICAgICB9XG4gICAgfVxuXG4gICAgaWYgKHBhcnRzLmxlbmd0aCA+IDApIHtcbiAgICAgIHJldHVybiBwYXJ0cy5qb2luKCcnKTtcbiAgICB9XG5cbiAgICByZXR1cm4gbnVsbDtcbiAgfVxufVxuXG5mdW5jdGlvbiBjYXN0VG9TdHJpbmcodmFsdWUpIHtcbiAgaWYgKHR5cGVvZiB2YWx1ZVsndG9TdHJpbmcnXSAhPT0gJ2Z1bmN0aW9uJykge1xuICAgIHJldHVybiAnJztcbiAgfVxuXG4gIHJldHVybiBTdHJpbmcodmFsdWUpO1xufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/function', ['exports', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/compiled/expressions'], function (exports, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibCompiledExpressions) { - 'use strict'; + + return 0; + }) + }); + + let todoList = ToDoList.create({todos: [ + { name: 'Unit Test', priority: 2 }, + { name: 'Documentation', priority: 3 }, + { name: 'Release', priority: 1 } + ]}); + + todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }] + todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }] + todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }] + ``` + + @method sort + @for Ember.computed + @param {String} itemsKey + @param {String or Function} sortDefinition a dependent key to an + array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting + @return {Ember.ComputedProperty} computes a new sorted array based + on the sort property array or callback function + @public + */ - exports.default = make; + function sort(itemsKey, sortDefinition) { - function make(func) { - return new FunctionExpressionSyntax(func); + if (typeof sortDefinition === 'function') { + return customSort(itemsKey, sortDefinition); + } else { + return propertySort(itemsKey, sortDefinition); } + } - var FunctionExpressionSyntax = (function (_ExpressionSyntax) { - babelHelpers.inherits(FunctionExpressionSyntax, _ExpressionSyntax); - - function FunctionExpressionSyntax(func) { - _ExpressionSyntax.call(this); - this.type = "function-expression"; - this.func = func; - } - - FunctionExpressionSyntax.prototype.compile = function compile(lookup, env, symbolTable) { - return new CompiledFunctionExpression(this.func, symbolTable); - }; - - return FunctionExpressionSyntax; - })(_glimmerRuntimeLibSyntax.Expression); - - var CompiledFunctionExpression = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledFunctionExpression, _CompiledExpression); - - function CompiledFunctionExpression(func, symbolTable) { - _CompiledExpression.call(this); - this.func = func; - this.symbolTable = symbolTable; - this.type = "function"; - this.func = func; - } - - CompiledFunctionExpression.prototype.evaluate = function evaluate(vm) { - var func = this.func; - var symbolTable = this.symbolTable; - - return func(vm, symbolTable); - }; - - CompiledFunctionExpression.prototype.toJSON = function toJSON() { - var func = this.func; + function customSort(itemsKey, comparator) { + return arrayMacro(itemsKey, function (value) { + var _this4 = this; - if (func.name) { - return '`' + func.name + '(...)`'; - } else { - return "`func(...)`"; - } - }; + return value.slice().sort(function (x, y) { + return comparator.call(_this4, x, y); + }); + }); + } - return CompiledFunctionExpression; - })(_glimmerRu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B9ID0gdGhpcztcbiAgICByZXR1cm4gZnVuYyh2bSwgc3ltYm9sVGFibGUpO1xuICB9XG5cbiAgdG9KU09OKCk6IHN0cmluZyB7XG4gICAgbGV0IHsgZnVuYyB9ID0gdGhpcztcblxuICAgIGlmIChmdW5jLm5hbWUpIHtcbiAgICAgIHJldHVybiBgXFxgJHtmdW5jLm5hbWV9KC4uLilcXGBgO1xuICAgIH0gZWxzZSB7XG4gICAgICByZXR1cm4gXCJgZnVuYyguLi4pYFwiO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/has-block', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/references'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibReferences) { - 'use strict'; + // This one needs to dynamically set up and tear down observers on the itemsKey + // depending on the sortProperties + function propertySort(itemsKey, sortPropertiesKey) { + var cp = new _emberMetal.ComputedProperty(function (key) { + var _this5 = this; - var CompiledHasBlock = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledHasBlock, _CompiledExpression); + var itemsKeyIsAtThis = itemsKey === '@this'; + var sortProperties = _emberMetal.get(this, sortPropertiesKey); - function CompiledHasBlock(inner) { - _CompiledExpression.call(this); - this.inner = inner; - this.type = "has-block"; - } + var normalizedSortProperties = normalizeSortProperties(sortProperties); - CompiledHasBlock.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - return _glimmerRuntimeLibReferences.PrimitiveReference.create(!!block); - }; + // Add/remove property observers as required. + var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetal.WeakMap()); + var activeObservers = activeObserversMap.get(this); - CompiledHasBlock.prototype.toJSON = function toJSON() { - return 'has-block(' + this.inner.toJSON() + ')'; - }; + if (activeObservers) { + activeObservers.forEach(function (args) { + return _emberMetal.removeObserver.apply(undefined, args); + }); + } - return CompiledHasBlock; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + function sortPropertyDidChange() { + this.notifyPropertyChange(key); + } - exports.default = CompiledHasBlock; + activeObservers = normalizedSortProperties.map(function (_ref) { + var prop = _ref[0]; - var CompiledHasBlockParams = (function (_CompiledExpression2) { - babelHelpers.inherits(CompiledHasBlockParams, _CompiledExpression2); + var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; + var args = [_this5, path, sortPropertyDidChange]; + _emberMetal.addObserver.apply(undefined, args); + return args; + }); - function CompiledHasBlockParams(inner) { - _CompiledExpression2.call(this); - this.inner = inner; - this.type = "has-block-params"; - } + activeObserversMap.set(this, activeObservers); - CompiledHasBlockParams.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - return _glimmerRuntimeLibReferences.PrimitiveReference.create(!!(block && block.locals.length > 0)); - }; + // Sort and return the array. + var items = itemsKeyIsAtThis ? this : _emberMetal.get(this, itemsKey); - CompiledHasBlockParams.prototype.toJSON = function toJSON() { - return 'has-block-params(' + this.inner.toJSON() + ')'; - }; + if (_emberRuntimeUtils.isArray(items)) { + return sortByNormalizedSortProperties(items, normalizedSortProperties); + } else { + return _emberRuntimeSystemNative_array.A(); + } + }); - return CompiledHasBlockParams; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + cp._activeObserverMap = undefined; - exports.CompiledHasBlockParams = CompiledHasBlockParams; + return cp.property(sortPropertiesKey + '.[]').readOnly(); + } - var CompiledGetBlockBySymbol = (function () { - function CompiledGetBlockBySymbol(symbol, debug) { - this.symbol = symbol; - this.debug = debug; - } + function normalizeSortProperties(sortProperties) { + return sortProperties.map(function (p) { + var _p$split = p.split(':'); - CompiledGetBlockBySymbol.prototype.evaluate = function evaluate(vm) { - return vm.scope().getBlock(this.symbol); - }; + var prop = _p$split[0]; + var direction = _p$split[1]; - CompiledGetBlockBySymbol.prototype.toJSON = function toJSON() { - return 'get-block($' + this.symbol + '(' + this.debug + '))'; - }; + direction = direction || 'asc'; - return CompiledGetBlockBySymbol; - })(); + return [prop, direction]; + }); + } - exports.CompiledGetBlockBySymbol = CompiledGetBlockBySymbol; + 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 CompiledInPartialGetBlock = (function () { - function CompiledInPartialGetBlock(symbol, name) { - this.symbol = symbol; - this.name = name; + var result = _emberRuntimeCompare.default(_emberMetal.get(itemA, prop), _emberMetal.get(itemB, prop)); + if (result !== 0) { + return direction === 'desc' ? -1 * result : result; } + } - CompiledInPartialGetBlock.prototype.evaluate = function evaluate(vm) { - var symbol = this.symbol; - var name = this.name; - - var args = vm.scope().getPartialArgs(symbol); - return args.blocks[name]; - }; - - CompiledInPartialGetBlock.prototype.toJSON = function toJSON() { - return 'get-block($' + this.symbol + '($ARGS).' + this.name + '))'; - }; - - return CompiledInPartialGetBlock; - })(); - - exports.CompiledInPartialGetBlock = CompiledInPartialGetBlock; + return 0; + })); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvaGFzLWJsb2NrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQU1BLGdCQUFBOzhCQUFBLGdCQUFBOztBQUdFLGlCQUhGLGdCQUFBLENBR3NCLEtBQXVCLEVBQUE7QUFDekMsMENBQU8sQ0FBQztBQURVLGdCQUFBLENBQUEsS0FBSyxHQUFMLEtBQUssQ0FBa0I7QUFGcEMsZ0JBQUEsQ0FBQSxJQUFJLEdBQUcsV0FBVyxDQUFDO1NBSXpCOztBQUxILHdCQUFBLFdBT0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGdCQUFJLEtBQUssR0FBRyxJQUFJLENBQUMsS0F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vbnN0cnVjdG9yKHByaXZhdGUgc3ltYm9sOiBudW1iZXIsIHByaXZhdGUgbmFtZTogc3RyaW5nKSB7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBJbmxpbmVCbG9jayB7XG4gICAgbGV0IHsgc3ltYm9sLCBuYW1lIH0gPSB0aGlzO1xuICAgIGxldCBhcmdzID0gdm0uc2NvcGUoKS5nZXRQYXJ0aWFsQXJncyhzeW1ib2wpO1xuICAgIHJldHVybiBhcmdzLmJsb2Nrc1tuYW1lXTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgZ2V0LWJsb2NrKCQke3RoaXMuc3ltYm9sfSgkQVJHUykuJHt0aGlzLm5hbWV9KSlgO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/helper', ['exports', 'glimmer-runtime/lib/compiled/expressions'], function (exports, _glimmerRuntimeLibCompiledExpressions) { - 'use strict'; - - var CompiledHelper = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledHelper, _CompiledExpression); +enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) { + 'use strict'; - function CompiledHelper(name, helper, args, symbolTable) { - _CompiledExpression.call(this); - this.name = name; - this.helper = helper; - this.args = args; - this.symbolTable = symbolTable; - this.type = "helper"; - } + /** + @module ember + @submodule ember-runtime + */ - CompiledHelper.prototype.evaluate = function evaluate(vm) { - var helper = this.helper; + /** + @class Controller + @namespace Ember + @extends Ember.Object + @uses Ember.ControllerMixin + @public + */ + var Controller = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsController.default); - return helper(vm, this.args.evaluate(vm), this.symbolTable); - }; + _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions(Controller); - CompiledHelper.prototype.toJSON = function toJSON() { - return '`' + this.name.join('.') + '($ARGS)`'; - }; + function controllerInjectionHelper(factory) {} - return CompiledHelper; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + /** + Creates a property that lazily looks up another controller in the container. + Can only be used when defining another controller. + + Example: + + ```javascript + App.PostController = Ember.Controller.extend({ + posts: Ember.inject.controller() + }); + ``` + + This example will create a `posts` property on the `post` controller that + looks up the `posts` controller in the container, making it easy to + reference other controllers. This is functionally equivalent to: + + ```javascript + App.PostController = Ember.Controller.extend({ + needs: 'posts', + posts: Ember.computed.alias('controllers.posts') + }); + ``` + + @method controller + @since 1.10.0 + @for Ember.inject + @param {String} name (optional) name of the controller to inject, defaults + to the property's name + @return {Ember.InjectedProperty} injection descriptor instance + @public + */ + _emberRuntimeInject.createInjectionHelper('controller', controllerInjectionHelper); - exports.default = CompiledHelper; + exports.default = Controller; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvaGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLGNBQUE7OEJBQUEsY0FBQTs7QUFHRSxpQkFIRixjQUFBLENBR3FCLElBQWMsRUFBUyxNQUFjLEVBQVMsSUFBa0IsRUFBUyxXQUF3QixFQUFBO0FBQ2xILDBDQUFPLENBQUM7QUFEUyxnQkFBQSxDQUFBLElBQUksR0FBSixJQUFJLENBQVU7QUFBUyxnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQVE7QUFBUyxnQkFBQSxDQUFBLElBQUksR0FBSixJQUFJLENBQWM7QUFBUyxnQkFBQSxDQUFBLFdBQVcsR0FBWCxXQUFXLENBQWE7QUFGN0csZ0JBQUEsQ0FBQSxJQUFJLEdBQUcsUUFBUSxDQUFDO1NBSXRCOztBQUxILHNCQUFBLFdBT0UsUUFBUSxHQUF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yBoZWxwZXI6IEhlbHBlciwgcHVibGljIGFyZ3M6IENvbXBpbGVkQXJncywgcHVibGljIHN5bWJvbFRhYmxlOiBTeW1ib2xUYWJsZSkge1xuICAgIHN1cGVyKCk7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIGxldCB7IGhlbHBlciB9ID0gdGhpcztcbiAgICByZXR1cm4gaGVscGVyKHZtLCB0aGlzLmFyZ3MuZXZhbHVhdGUodm0pLCB0aGlzLnN5bWJvbFRhYmxlKTtcbiAgfVxuXG4gIHRvSlNPTigpOiBzdHJpbmcge1xuICAgIHJldHVybiBgXFxgJHt0aGlzLm5hbWUuam9pbignLicpfSgkQVJHUylcXGBgO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/lookups', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-reference'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerReference) { - 'use strict'; - - var CompiledLookup = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledLookup, _CompiledExpression); - - function CompiledLookup(base, path) { - _CompiledExpression.call(this); - this.base = base; - this.path = path; - this.type = "lookup"; - } +enifed('ember-runtime/copy', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) { + 'use strict'; - CompiledLookup.create = function create(base, path) { - if (path.length === 0) { - return base; - } else { - return new this(base, path); - } - }; + exports.default = copy; - CompiledLookup.prototype.evaluate = function evaluate(vm) { - var base = this.base; - var path = this.path; + function _copy(obj, deep, seen, copies) { + var ret = undefined, + loc = undefined, + key = undefined; - return _glimmerReference.referenceFromParts(base.evaluate(vm), path); - }; + // primitive data types are immutable, just return them. + if (typeof obj !== 'object' || obj === null) { + return obj; + } - CompiledLookup.prototype.toJSON = function toJSON() { - return this.base.toJSON() + '.' + this.path.join('.'); - }; + // avoid cyclical loops + if (deep && (loc = seen.indexOf(obj)) >= 0) { + return copies[loc]; + } - return CompiledLookup; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + // IMPORTANT: this specific test will detect a native array only. Any other + // object will need to implement Copyable. + if (Array.isArray(obj)) { + ret = obj.slice(); - exports.default = CompiledLookup; + if (deep) { + loc = ret.length; - var CompiledSelf = (function (_CompiledExpression2) { - babelHelpers.inherits(CompiledSelf, _CompiledExpression2); + while (--loc >= 0) { + ret[loc] = _copy(ret[loc], deep, seen, copies); + } + } + } else if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { + ret = obj.copy(deep, seen, copies); + } else if (obj instanceof Date) { + ret = new Date(obj.getTime()); + } else { + ret = {}; - function CompiledSelf() { - _CompiledExpression2.apply(this, arguments); + for (key in obj) { + // support Null prototype + if (!Object.prototype.hasOwnProperty.call(obj, key)) { + continue; } - CompiledSelf.prototype.evaluate = function evaluate(vm) { - return vm.getSelf(); - }; + // Prevents browsers that don't respect non-enumerability from + // copying internal Ember properties + if (key.substring(0, 2) === '__') { + continue; + } - CompiledSelf.prototype.toJSON = function toJSON() { - return 'self'; - }; + ret[key] = deep ? _copy(obj[key], deep, seen, copies) : obj[key]; + } + } - return CompiledSelf; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + if (deep) { + seen.push(obj); + copies.push(ret); + } - exports.CompiledSelf = CompiledSelf; + return ret; + } - var CompiledSymbol = (function (_CompiledExpression3) { - babelHelpers.inherits(CompiledSymbol, _CompiledExpression3); + /** + Creates a shallow copy of the passed object. A deep copy of the object is + returned if the optional `deep` argument is `true`. + + If the passed object implements the `Ember.Copyable` interface, then this + function will delegate to the object's `copy()` method and return the + result. See `Ember.Copyable` for further details. + + For primitive values (which are immutable in JavaScript), the passed object + is simply returned. + + @method copy + @for Ember + @param {Object} obj The object to clone + @param {Boolean} [deep=false] If true, a deep copy of the object is made. + @return {Object} The copied object + @public + */ - function CompiledSymbol(symbol, debug) { - _CompiledExpression3.call(this); - this.symbol = symbol; - this.debug = debug; - } + function copy(obj, deep) { + // fast paths + if ('object' !== typeof obj || obj === null) { + return obj; // can't copy primitives + } - CompiledSymbol.prototype.evaluate = function evaluate(vm) { - return vm.referenceForSymbol(this.symbol); - }; + if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { + return obj.copy(deep); + } - CompiledSymbol.prototype.toJSON = function toJSON() { - return '$' + this.symbol + '(' + this.debug + ')'; - }; + return _copy(obj, deep, deep ? [] : null, deep ? [] : null); + } +}); +enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - return CompiledSymbol; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + 'use strict'; - exports.CompiledSymbol = CompiledSymbol; + var a_slice = Array.prototype.slice; + var FunctionPrototype = Function.prototype; - var CompiledInPartialName = (function (_CompiledExpression4) { - babelHelpers.inherits(CompiledInPartialName, _CompiledExpression4); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Function) { + /** + The `property` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + `true`, which is the default. + Computed properties allow you to treat a function like a property: + ```javascript + MyApp.President = Ember.Object.extend({ + firstName: '', + lastName: '', + fullName: function() { + return this.get('firstName') + ' ' + this.get('lastName'); + }.property() // Call this flag to mark the function as a property + }); + let president = MyApp.President.create({ + firstName: 'Barack', + lastName: 'Obama' + }); + president.get('fullName'); // 'Barack Obama' + ``` + Treating a function like a property is useful because they can work with + bindings, just like any other property. + Many computed properties have dependencies on other properties. For + example, in the above example, the `fullName` property depends on + `firstName` and `lastName` to determine its value. You can tell Ember + about these dependencies like this: + ```javascript + MyApp.President = Ember.Object.extend({ + firstName: '', + lastName: '', + fullName: function() { + return this.get('firstName') + ' ' + this.get('lastName'); + // Tell Ember.js that this computed property depends on firstName + // and lastName + }.property('firstName', 'lastName') + }); + ``` + Make sure you list these dependencies so Ember knows when to update + bindings that connect to a computed property. Changing a dependency + will not immediately trigger an update of the computed property, but + will instead clear the cache so that it is updated when the next `get` + is called on the property. + See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/classes/Ember.computed.html). + @method property + @for Function + @public + */ + FunctionPrototype.property = function () { + var ret = _emberMetal.computed(this); + // ComputedProperty.prototype.property expands properties; no need for us to + // do so here. + return ret.property.apply(ret, arguments); + }; - function CompiledInPartialName(symbol, name) { - _CompiledExpression4.call(this); - this.symbol = symbol; - this.name = name; - } + /** + The `observes` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + true, which is the default. + You can observe property changes simply by adding the `observes` + call to the end of your method declarations in classes that you write. + For example: + ```javascript + Ember.Object.extend({ + valueObserver: function() { + // Executes whenever the "value" property changes + }.observes('value') + }); + ``` + In the future this method may become asynchronous. + See `Ember.observer`. + @method observes + @for Function + @public + */ + FunctionPrototype.observes = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - CompiledInPartialName.prototype.evaluate = function evaluate(vm) { - var symbol = this.symbol; - var name = this.name; + args.push(this); + return _emberMetal.observer.apply(this, args); + }; - var args = vm.scope().getPartialArgs(symbol); - return args.named.get(name); - }; + FunctionPrototype._observesImmediately = function () { - CompiledInPartialName.prototype.toJSON = function toJSON() { - return '$' + this.symbol + '($ARGS).' + this.name; - }; + // observes handles property expansion + return this.observes.apply(this, arguments); + }; + /** + The `observesImmediately` extension of Javascript's Function prototype is + available when `EmberENV.EXTEND_PROTOTYPES` or + `EmberENV.EXTEND_PROTOTYPES.Function` is true, which is the default. + You can observe property changes simply by adding the `observesImmediately` + call to the end of your method declarations in classes that you write. + For example: + ```javascript + Ember.Object.extend({ + valueObserver: function() { + // Executes immediately after the "value" property changes + }.observesImmediately('value') + }); + ``` + In the future, `observes` may become asynchronous. In this event, + `observesImmediately` will maintain the synchronous behavior. + See `Ember.immediateObserver`. + @method observesImmediately + @for Function + @deprecated + @private + */ + FunctionPrototype.observesImmediately = _emberMetal.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately); - return CompiledInPartialName; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + /** + The `on` extension of Javascript's Function prototype is available + when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is + true, which is the default. + You can listen for events simply by adding the `on` call to the end of + your method declarations in classes or mixins that you write. For example: + ```javascript + Ember.Mixin.create({ + doSomethingWithElement: function() { + // Executes whenever the "didInsertElement" event fires + }.on('didInsertElement') + }); + ``` + See `Ember.on`. + @method on + @for Function + @public + */ + FunctionPrototype.on = function () { + var events = a_slice.call(arguments); + this.__ember_listens__ = events; - exports.CompiledInPartialName = CompiledInPartialName; + return this; + }; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvbG9va3Vwcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFNQSxjQUFBOzhCQUFBLGNBQUE7O0FBV0UsaUJBWEYsY0FBQSxDQVlZLElBQWdDLEVBQ2hDLElBQWMsRUFBQTtBQUV0QiwwQ0FBTyxDQUFDO0FBSEEsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUE0QjtBQUNoQyxnQkFBQSxDQUFBLElBQUksR0FBSixJQUFJLENBQVU7QUFaakIsZ0JBQUEsQ0FBQSxJQUFJLEdBQUcsUUFBUSxDQUFDO1NBZXRCOztBQWhCSCxzQkFBQSxDQUdTLE1BQU0sR0FBQSxnQkFBQyxJQUFnQyxFQUFFLElBQW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4ge1xuICBjb25zdHJ1Y3Rvcihwcml2YXRlIHN5bWJvbDogbnVtYmVyLCBwcml2YXRlIG5hbWU6IHN0cmluZykge1xuICAgIHN1cGVyKCk7XG4gIH1cblxuICBldmFsdWF0ZSh2bTogVk0pOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIGxldCB7IHN5bWJvbCwgbmFtZSB9ID0gdGhpcztcbiAgICBsZXQgYXJncyA9IHZtLnNjb3BlKCkuZ2V0UGFydGlhbEFyZ3Moc3ltYm9sKTtcbiAgICByZXR1cm4gYXJncy5uYW1lZC5nZXQobmFtZSk7XG4gIH1cblxuICB0b0pTT04oKTogc3RyaW5nIHtcbiAgICByZXR1cm4gYCQke3RoaXMuc3ltYm9sfSgkQVJHUykuJHt0aGlzLm5hbWV9YDtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/named-args', ['exports', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/utils', 'glimmer-reference', 'glimmer-util'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibUtils, _glimmerReference, _glimmerUtil) { - 'use strict'; +enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal'], function (exports, _rsvp, _emberMetal) { + 'use strict'; - var CompiledNamedArgs = (function () { - function CompiledNamedArgs(keys, values) { - this.keys = keys; - this.values = values; - this.length = keys.length; - _glimmerUtil.assert(keys.length === values.length, 'Keys and values do not have the same length'); - } + exports.onerrorDefault = onerrorDefault; - CompiledNamedArgs.empty = function empty() { - return COMPILED_EMPTY_NAMED_ARGS; - }; + var backburner = _emberMetal.run.backburner; + _emberMetal.run._addQueue('rsvpAfter', 'destroy'); - CompiledNamedArgs.create = function create(map) { - var keys = Object.keys(map); - var length = keys.length; - if (length > 0) { - var values = []; - for (var i = 0; i < length; i++) { - values[i] = map[keys[i]]; - } - return new this(keys, values); - } else { - return COMPILED_EMPTY_NAMED_ARGS; - } - }; + _rsvp.configure('async', function (callback, promise) { + backburner.schedule('actions', null, callback, promise); + }); - CompiledNamedArgs.prototype.evaluate = function evaluate(vm) { - var keys = this.keys; - var values = this.values; - var length = this.length; + _rsvp.configure('after', function (cb) { + backburner.schedule('rsvpAfter', null, cb); + }); - var evaluated = new Array(length); - for (var i = 0; i < length; i++) { - evaluated[i] = values[i].evaluate(vm); - } - return new EvaluatedNamedArgs(keys, evaluated); - }; + _rsvp.on('error', onerrorDefault); - CompiledNamedArgs.prototype.toJSON = function toJSON() { - var keys = this.keys; - var values = this.values; + function onerrorDefault(reason) { + var error = errorFor(reason); + if (error) { + _emberMetal.dispatchError(error); + } + } - var inner = keys.map(function (key, i) { - return key + ': ' + values[i].toJSON(); - }).join(", "); - return '{' + inner + '}'; - }; + function errorFor(reason) { + if (!reason) return; - return CompiledNamedArgs; - })(); + if (reason.errorThrown) { + return unwrapErrorThrown(reason); + } - exports.CompiledNamedArgs = CompiledNamedArgs; - var COMPILED_EMPTY_NAMED_ARGS = new ((function (_CompiledNamedArgs) { - babelHelpers.inherits(_class, _CompiledNamedArgs); + if (reason.name === 'UnrecognizedURLError') { + return; + } - function _class() { - _CompiledNamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + if (reason.name === 'TransitionAborted') { + return; + } - _class.prototype.evaluate = function evaluate(vm) { - return EVALUATED_EMPTY_NAMED_ARGS; - }; + return reason; + } - _class.prototype.toJSON = function toJSON() { - return ''; - }; + function unwrapErrorThrown(reason) { + var error = reason.errorThrown; + if (typeof error === 'string') { + error = new Error(error); + } + Object.defineProperty(error, '__reason_with_error_thrown__', { + value: reason, + enumerable: false + }); + return error; + } - return _class; - })(CompiledNamedArgs))(); - exports.COMPILED_EMPTY_NAMED_ARGS = COMPILED_EMPTY_NAMED_ARGS; - - var EvaluatedNamedArgs = (function () { - function EvaluatedNamedArgs(keys, values) { - var _map = arguments.length <= 2 || arguments[2] === undefined ? undefined : arguments[2]; - - this.keys = keys; - this.values = values; - this._map = _map; - this.tag = _glimmerReference.combineTagged(values); - this.length = keys.length; - _glimmerUtil.assert(keys.length === values.length, 'Keys and values do not have the same length'); - } - - EvaluatedNamedArgs.create = function create(map) { - var keys = Object.keys(map); - var length = keys.length; - if (length > 0) { - var values = new Array(length); - for (var i = 0; i < length; i++) { - values[i] = map[keys[i]]; - } - return new this(keys, values, map); - } else { - return EVALUATED_EMPTY_NAMED_ARGS; - } - }; + exports.default = _rsvp; +}); +enifed('ember-runtime/ext/string', ['exports', 'ember-environment', 'ember-runtime/system/string'], function (exports, _emberEnvironment, _emberRuntimeSystemString) { + /** + @module ember + @submodule ember-runtime + */ - EvaluatedNamedArgs.empty = function empty() { - return EVALUATED_EMPTY_NAMED_ARGS; - }; + 'use strict'; - EvaluatedNamedArgs.prototype.get = function get(key) { - var keys = this.keys; - var values = this.values; + var StringPrototype = String.prototype; - var index = keys.indexOf(key); - return index === -1 ? _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE : values[index]; - }; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + /** + See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt). + @method fmt + @for String + @private + @deprecated + */ + StringPrototype.fmt = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - EvaluatedNamedArgs.prototype.has = function has(key) { - return this.keys.indexOf(key) !== -1; - }; + return _emberRuntimeSystemString.fmt(this, args); + }; - EvaluatedNamedArgs.prototype.value = function value() { - var keys = this.keys; - var values = this.values; + /** + See [Ember.String.w](/api/classes/Ember.String.html#method_w). + @method w + @for String + @private + */ + StringPrototype.w = function () { + return _emberRuntimeSystemString.w(this); + }; - var out = _glimmerUtil.dict(); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var ref = values[i]; - out[key] = ref.value(); - } - return out; - }; + /** + See [Ember.String.loc](/api/classes/Ember.String.html#method_loc). + @method loc + @for String + @private + */ + StringPrototype.loc = function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - babelHelpers.createClass(EvaluatedNamedArgs, [{ - key: 'map', - get: function () { - var map = this._map; + return _emberRuntimeSystemString.loc(this, args); + }; - if (map) { - return map; - } - map = this._map = _glimmerUtil.dict(); - var keys = this.keys; - var values = this.values; - var length = this.length; + /** + See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize). + @method camelize + @for String + @private + */ + StringPrototype.camelize = function () { + return _emberRuntimeSystemString.camelize(this); + }; - for (var i = 0; i < length; i++) { - map[keys[i]] = values[i]; - } - return map; - } - }]); - return EvaluatedNamedArgs; - })(); + /** + See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize). + @method decamelize + @for String + @private + */ + StringPrototype.decamelize = function () { + return _emberRuntimeSystemString.decamelize(this); + }; - exports.EvaluatedNamedArgs = EvaluatedNamedArgs; - var EVALUATED_EMPTY_NAMED_ARGS = new ((function (_EvaluatedNamedArgs) { - babelHelpers.inherits(_class2, _EvaluatedNamedArgs); + /** + See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize). + @method dasherize + @for String + @private + */ + StringPrototype.dasherize = function () { + return _emberRuntimeSystemString.dasherize(this); + }; - function _class2() { - _EvaluatedNamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_DICT); - } + /** + See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore). + @method underscore + @for String + @private + */ + StringPrototype.underscore = function () { + return _emberRuntimeSystemString.underscore(this); + }; - _class2.prototype.get = function get() { - return _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + /** + See [Ember.String.classify](/api/classes/Ember.String.html#method_classify). + @method classify + @for String + @private + */ + StringPrototype.classify = function () { + return _emberRuntimeSystemString.classify(this); + }; - _class2.prototype.has = function has(key) { - return false; - }; + /** + See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize). + @method capitalize + @for String + @private + */ + StringPrototype.capitalize = function () { + return _emberRuntimeSystemString.capitalize(this); + }; + } +}); +enifed('ember-runtime/index', ['exports', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/system/object', 'ember-runtime/system/string', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/compare', 'ember-runtime/is-equal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/system/namespace', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeSystemObject, _emberRuntimeSystemString, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeCompare, _emberRuntimeIsEqual, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeSystemNamespace, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsObservable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeUtils, _emberRuntimeString_registry) { + /** + @module ember + @submodule ember-runtime + */ - _class2.prototype.value = function value() { - return _glimmerRuntimeLibUtils.EMPTY_DICT; - }; + 'use strict'; - return _class2; - })(EvaluatedNamedArgs))(); - exports.EVALUATED_EMPTY_NAMED_ARGS = EVALUATED_EMPTY_NAMED_ARGS; + exports.Object = _emberRuntimeSystemObject.default; + exports.FrameworkObject = _emberRuntimeSystemObject.FrameworkObject; + exports.String = _emberRuntimeSystemString.default; + exports.RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default; + exports.buildFakeRegistryWithDeprecations = _emberRuntimeMixinsRegistry_proxy.buildFakeRegistryWithDeprecations; + exports.ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default; + exports.copy = _emberRuntimeCopy.default; + exports.inject = _emberRuntimeInject.default; + exports.compare = _emberRuntimeCompare.default; + exports.isEqual = _emberRuntimeIsEqual.default; + exports.Array = _emberRuntimeMixinsArray.default; + exports.objectAt = _emberRuntimeMixinsArray.objectAt; + exports.isEmberArray = _emberRuntimeMixinsArray.isEmberArray; + exports.addArrayObserver = _emberRuntimeMixinsArray.addArrayObserver; + exports.removeArrayObserver = _emberRuntimeMixinsArray.removeArrayObserver; + exports.Comparable = _emberRuntimeMixinsComparable.default; + exports.Namespace = _emberRuntimeSystemNamespace.default; + exports.isNamespaceSearchDisabled = _emberRuntimeSystemNamespace.isSearchDisabled; + exports.setNamespaceSearchDisabled = _emberRuntimeSystemNamespace.setSearchDisabled; + exports.ArrayProxy = _emberRuntimeSystemArray_proxy.default; + exports.ObjectProxy = _emberRuntimeSystemObject_proxy.default; + exports.CoreObject = _emberRuntimeSystemCore_object.default; + exports.NativeArray = _emberRuntimeSystemNative_array.default; + exports.A = _emberRuntimeSystemNative_array.A; + exports.ActionHandler = _emberRuntimeMixinsAction_handler.default; + exports.deprecateUnderscoreActions = _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions; + exports.Copyable = _emberRuntimeMixinsCopyable.default; + exports.Enumerable = _emberRuntimeMixinsEnumerable.default; + exports.Freezable = _emberRuntimeMixinsFreezable.Freezable; + exports.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR; + exports._ProxyMixin = _emberRuntimeMixinsProxy.default; + exports.onLoad = _emberRuntimeSystemLazy_load.onLoad; + exports.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks; + exports._loaded = _emberRuntimeSystemLazy_load._loaded; + exports.Observable = _emberRuntimeMixinsObservable.default; + exports.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default; + exports.MutableArray = _emberRuntimeMixinsMutable_array.default; + exports.removeAt = _emberRuntimeMixinsMutable_array.removeAt; + exports.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default; + exports.Evented = _emberRuntimeMixinsEvented.default; + exports.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default; + exports.empty = _emberRuntimeComputedComputed_macros.empty; + exports.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty; + exports.none = _emberRuntimeComputedComputed_macros.none; + exports.not = _emberRuntimeComputedComputed_macros.not; + exports.bool = _emberRuntimeComputedComputed_macros.bool; + exports.match = _emberRuntimeComputedComputed_macros.match; + exports.equal = _emberRuntimeComputedComputed_macros.equal; + exports.gt = _emberRuntimeComputedComputed_macros.gt; + exports.gte = _emberRuntimeComputedComputed_macros.gte; + exports.lt = _emberRuntimeComputedComputed_macros.lt; + exports.lte = _emberRuntimeComputedComputed_macros.lte; + exports.oneWay = _emberRuntimeComputedComputed_macros.oneWay; + exports.readOnly = _emberRuntimeComputedComputed_macros.readOnly; + exports.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias; + exports.and = _emberRuntimeComputedComputed_macros.and; + exports.or = _emberRuntimeComputedComputed_macros.or; + exports.sum = _emberRuntimeComputedReduce_computed_macros.sum; + exports.min = _emberRuntimeComputedReduce_computed_macros.min; + exports.max = _emberRuntimeComputedReduce_computed_macros.max; + exports.map = _emberRuntimeComputedReduce_computed_macros.map; + exports.sort = _emberRuntimeComputedReduce_computed_macros.sort; + exports.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff; + exports.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy; + exports.filter = _emberRuntimeComputedReduce_computed_macros.filter; + exports.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy; + exports.uniq = _emberRuntimeComputedReduce_computed_macros.uniq; + exports.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy; + exports.union = _emberRuntimeComputedReduce_computed_macros.union; + exports.intersect = _emberRuntimeComputedReduce_computed_macros.intersect; + exports.collect = _emberRuntimeComputedReduce_computed_macros.collect; + exports.Controller = _emberRuntimeControllersController.default; + exports.ControllerMixin = _emberRuntimeMixinsController.default; + exports.Service = _emberRuntimeSystemService.default; + exports.RSVP = _emberRuntimeExtRsvp.default; + exports.onerrorDefault = _emberRuntimeExtRsvp.onerrorDefault; + // just for side effect of extending Ember.RSVP + exports.isArray = _emberRuntimeUtils.isArray; + exports.typeOf = _emberRuntimeUtils.typeOf; + exports.getStrings = _emberRuntimeString_registry.getStrings; + exports.setStrings = _emberRuntimeString_registry.setStrings; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvbmFtZWQtYXJncy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFPQSxpQkFBQTtBQXdCRSx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HMgRXZhbHVhdGVkTmFtZWRBcmdzIHtcbiAgY29uc3RydWN0b3IoKSB7XG4gICAgc3VwZXIoRU1QVFlfQVJSQVksIEVNUFRZX0FSUkFZLCBFTVBUWV9ESUNUKTtcbiAgfVxuXG4gIGdldCgpOiBQYXRoUmVmZXJlbmNlPE9wYXF1ZT4ge1xuICAgIHJldHVybiBVTkRFRklORURfUkVGRVJFTkNFO1xuICB9XG5cbiAgaGFzKGtleTogc3RyaW5nKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuIGZhbHNlO1xuICB9XG5cbiAgdmFsdWUoKTogRGljdDxPcGFxdWU+IHtcbiAgICByZXR1cm4gRU1QVFlfRElDVDtcbiAgfVxufSk7XG4iXX0= -enifed('glimmer-runtime/lib/compiled/expressions/positional-args', ['exports', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/utils', 'glimmer-reference'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibUtils, _glimmerReference) { - 'use strict'; - - var CompiledPositionalArgs = (function () { - function CompiledPositionalArgs(values) { - this.values = values; - this.length = values.length; - } +// just for side effect of extending String.prototype +// just for side effect of extending Function.prototype +enifed('ember-runtime/inject', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - CompiledPositionalArgs.create = function create(values) { - if (values.length) { - return new this(values); - } else { - return COMPILED_EMPTY_POSITIONAL_ARGS; - } - }; + exports.default = inject; + exports.createInjectionHelper = createInjectionHelper; + exports.validatePropertyInjections = validatePropertyInjections; - CompiledPositionalArgs.empty = function empty() { - return COMPILED_EMPTY_POSITIONAL_ARGS; - }; + /** + Namespace for injection helper methods. + + @class inject + @namespace Ember + @static + @public + */ - CompiledPositionalArgs.prototype.evaluate = function evaluate(vm) { - var values = this.values; - var length = this.length; + function inject() {} - var references = new Array(length); - for (var i = 0; i < length; i++) { - references[i] = values[i].evaluate(vm); - } - return EvaluatedPositionalArgs.create(references); - }; + // Dictionary of injection validations by type, added to by `createInjectionHelper` + var typeValidators = {}; - CompiledPositionalArgs.prototype.toJSON = function toJSON() { - return '[' + this.values.map(function (value) { - return value.toJSON(); - }).join(", ") + ']'; - }; + /** + This method allows other Ember modules to register injection helpers for a + given container type. Helpers are exported to the `inject` namespace as the + container type itself. + + @private + @method createInjectionHelper + @since 1.10.0 + @for Ember + @param {String} type The container type the helper will inject + @param {Function} validator A validation callback that is executed at mixin-time + */ - return CompiledPositionalArgs; - })(); + function createInjectionHelper(type, validator) { + typeValidators[type] = validator; - exports.CompiledPositionalArgs = CompiledPositionalArgs; - var COMPILED_EMPTY_POSITIONAL_ARGS = new ((function (_CompiledPositionalArgs) { - babelHelpers.inherits(_class, _CompiledPositionalArgs); + inject[type] = function (name) { + return new _emberMetal.InjectedProperty(type, name); + }; + } - function _class() { - _CompiledPositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + /** + Validation function that runs per-type validation functions once for each + injected type encountered. + + @private + @method validatePropertyInjections + @since 1.10.0 + @for Ember + @param {Object} factory The factory object + */ - _class.prototype.evaluate = function evaluate(vm) { - return EVALUATED_EMPTY_POSITIONAL_ARGS; - }; + function validatePropertyInjections(factory) { + var proto = factory.proto(); + var types = []; - _class.prototype.toJSON = function toJSON() { - return ''; - }; + for (var key in proto) { + var desc = proto[key]; + if (desc instanceof _emberMetal.InjectedProperty && types.indexOf(desc.type) === -1) { + types.push(desc.type); + } + } - return _class; - })(CompiledPositionalArgs))(); - exports.COMPILED_EMPTY_POSITIONAL_ARGS = COMPILED_EMPTY_POSITIONAL_ARGS; + if (types.length) { + for (var i = 0; i < types.length; i++) { + var validator = typeValidators[types[i]]; - var EvaluatedPositionalArgs = (function () { - function EvaluatedPositionalArgs(values) { - this.values = values; - this.tag = _glimmerReference.combineTagged(values); - this.length = values.length; + if (typeof validator === 'function') { + validator(factory); } + } + } - EvaluatedPositionalArgs.create = function create(values) { - return new this(values); - }; + return true; + } +}); +enifed('ember-runtime/is-equal', ['exports'], function (exports) { + /** + Compares two objects, returning true if they are equal. + + ```javascript + Ember.isEqual('hello', 'hello'); // true + Ember.isEqual(1, 2); // false + ``` + + `isEqual` is a more specific comparison than a triple equal comparison. + It will call the `isEqual` instance method on the objects being + compared, allowing finer control over when objects should be considered + equal to each other. + + ```javascript + let Person = Ember.Object.extend({ + isEqual(other) { return this.ssn == other.ssn; } + }); + + let personA = Person.create({name: 'Muhammad Ali', ssn: '123-45-6789'}); + let personB = Person.create({name: 'Cassius Clay', ssn: '123-45-6789'}); + + Ember.isEqual(personA, personB); // true + ``` + + Due to the expense of array comparisons, collections will never be equal to + each other even if each of their items are equal to each other. + + ```javascript + Ember.isEqual([4, 2], [4, 2]); // false + ``` + + @method isEqual + @for Ember + @param {Object} a first object to compare + @param {Object} b second object to compare + @return {Boolean} + @public + */ + 'use strict'; - EvaluatedPositionalArgs.empty = function empty() { - return EVALUATED_EMPTY_POSITIONAL_ARGS; - }; + exports.default = isEqual; - EvaluatedPositionalArgs.prototype.at = function at(index) { - var values = this.values; - var length = this.length; + function isEqual(a, b) { + if (a && typeof a.isEqual === 'function') { + return a.isEqual(b); + } - return index < length ? values[index] : _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime(); + } - EvaluatedPositionalArgs.prototype.value = function value() { - var values = this.values; - var length = this.length; + return a === b; + } +}); +enifed('ember-runtime/mixins/-proxy', ['exports', '@glimmer/reference', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberMetal, _emberRuntimeComputedComputed_macros) { + /** + @module ember + @submodule ember-runtime + */ - var ret = new Array(length); - for (var i = 0; i < length; i++) { - ret[i] = values[i].value(); - } - return ret; - }; + 'use strict'; - return EvaluatedPositionalArgs; - })(); + function contentPropertyWillChange(content, contentKey) { + var key = contentKey.slice(8); // remove "content." + if (key in this) { + return; + } // if shadowed in proxy + _emberMetal.propertyWillChange(this, key); + } - exports.EvaluatedPositionalArgs = EvaluatedPositionalArgs; - var EVALUATED_EMPTY_POSITIONAL_ARGS = new ((function (_EvaluatedPositionalArgs) { - babelHelpers.inherits(_class2, _EvaluatedPositionalArgs); + function contentPropertyDidChange(content, contentKey) { + var key = contentKey.slice(8); // remove "content." + if (key in this) { + return; + } // if shadowed in proxy + _emberMetal.propertyDidChange(this, key); + } - function _class2() { - _EvaluatedPositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + var ProxyTag = (function (_CachedTag) { + babelHelpers.inherits(ProxyTag, _CachedTag); - _class2.prototype.at = function at() { - return _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - }; + function ProxyTag(proxy) { + _CachedTag.call(this); - _class2.prototype.value = function value() { - return this.values; - }; + var content = _emberMetal.get(proxy, 'content'); - return _class2; - })(EvaluatedPositionalArgs))(); - exports.EVALUATED_EMPTY_POSITIONAL_ARGS = EVALUATED_EMPTY_POSITIONAL_ARGS; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvcG9zaXRpb25hbC1hcmdzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQU9BLHNCQUFBO0FBZUUsaUJBZkYsc0JBQUEsQ0FlcUIsTUFBb0MsRUFBQTtBQUFwQyxnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQThCO0FBQ3JELGdCQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUM7U0FDN0I7O0FBakJILDhCQUFBLENBQ1MsTUFBTSxHQUFBLGdCQUFDLE1BQW9DLEVBQUE7QUFDaEQsZ0JBQUksTUFBTSxDQUFDLE1BQU0sRUFBRTtBQUNqQix1QkFBTyxJQUFJLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQzthQUN6QixNQUFNO0FBQ0wsdUJBQU8sOEJBQThCLENBQUM7YUFDdkM7U0FDRjs7QUFQSC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uICAgIHJldHVybiAoaW5kZXggPCBsZW5ndGgpID8gdmFsdWVzW2luZGV4XSA6IFVOREVGSU5FRF9SRUZFUkVOQ0U7XG4gIH1cblxuICB2YWx1ZSgpOiBPcGFxdWVbXSB7XG4gICAgbGV0IHsgdmFsdWVzLCBsZW5ndGggfSA9IHRoaXM7XG4gICAgbGV0IHJldDogT3BhcXVlW10gPSBuZXcgQXJyYXkobGVuZ3RoKTtcblxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHtcbiAgICAgIHJldFtpXSA9IHZhbHVlc1tpXS52YWx1ZSgpO1xuICAgIH1cblxuICAgIHJldHVybiByZXQ7XG4gIH1cbn1cblxuZXhwb3J0IGNvbnN0IEVWQUxVQVRFRF9FTVBUWV9QT1NJVElPTkFMX0FSR1M6IEV2YWx1YXRlZFBvc2l0aW9uYWxBcmdzID0gbmV3IChjbGFzcyBleHRlbmRzIEV2YWx1YXRlZFBvc2l0aW9uYWxBcmdzIHtcbiAgY29uc3RydWN0b3IoKSB7XG4gICAgc3VwZXIoRU1QVFlfQVJSQVkpO1xuICB9XG5cbiAgYXQoKTogUGF0aFJlZmVyZW5jZTxPcGFxdWU+IHtcbiAgICByZXR1cm4gVU5ERUZJTkVEX1JFRkVSRU5DRTtcbiAgfVxuXG4gIHZhbHVlKCk6IE9wYXF1ZVtdIHtcbiAgICByZXR1cm4gdGhpcy52YWx1ZXM7XG4gIH1cbn0pO1xuIl19 -enifed('glimmer-runtime/lib/compiled/expressions/value', ['exports', 'glimmer-runtime/lib/compiled/expressions', 'glimmer-runtime/lib/references'], function (exports, _glimmerRuntimeLibCompiledExpressions, _glimmerRuntimeLibReferences) { - 'use strict'; + this.proxy = proxy; + this.proxyWrapperTag = new _glimmerReference.DirtyableTag(); + this.proxyContentTag = new _glimmerReference.UpdatableTag(_emberMetal.tagFor(content)); + } - var CompiledValue = (function (_CompiledExpression) { - babelHelpers.inherits(CompiledValue, _CompiledExpression); + /** + `Ember.ProxyMixin` forwards all properties not defined by the proxy itself + to a proxied `content` object. See Ember.ObjectProxy for more details. + + @class ProxyMixin + @namespace Ember + @private + */ - function CompiledValue(value) { - _CompiledExpression.call(this); - this.type = "value"; - this.reference = _glimmerRuntimeLibReferences.PrimitiveReference.create(value); - } + ProxyTag.prototype.compute = function compute() { + return Math.max(this.proxyWrapperTag.value(), this.proxyContentTag.value()); + }; - CompiledValue.prototype.evaluate = function evaluate(vm) { - return this.reference; - }; + ProxyTag.prototype.dirty = function dirty() { + this.proxyWrapperTag.dirty(); + }; - CompiledValue.prototype.toJSON = function toJSON() { - return JSON.stringify(this.reference.value()); - }; + ProxyTag.prototype.contentDidChange = function contentDidChange() { + var content = _emberMetal.get(this.proxy, 'content'); + this.proxyContentTag.update(_emberMetal.tagFor(content)); + }; - return CompiledValue; - })(_glimmerRuntimeLibCompiledExpressions.CompiledExpression); + return ProxyTag; + })(_glimmerReference.CachedTag); - exports.default = CompiledValue; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvZXhwcmVzc2lvbnMvdmFsdWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBSUEsYUFBQTs4QkFBQSxhQUFBOztBQUlFLGlCQUpGLGFBQUEsQ0FJYyxLQUFRLEVBQUE7QUFDbEIsMENBQU8sQ0FBQztBQUpILGdCQUFBLENBQUEsSUFBSSxHQUFHLE9BQU8sQ0FBQztBQUtwQixnQkFBSSxDQUFDLFNBQVMsR0FBRyw2QkFSRCxrQkFBa0IsQ0FRRSxNQUFNLENBQUMsS0FBWSxDQUFDLENBQUM7U0FDMUQ7O0FBUEgscUJBQUEsV0FTRSxRQUFRLEdBQUEsa0JBQUMsRUFBTSxFQUFBO0FBQ2IsbUJBQU8sSUFBSSxDQUFDLFNBQVMsQ0FBQztTQUN2Qjs7QUFYSCxxQkFBQSxXQWFFLE1BQU0s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-runtime/lib/compiled/opcodes/component', 'glimmer-runtime/lib/compiled/opcodes/partial', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/compiled/opcodes/dom', 'glimmer-runtime/lib/compiled/opcodes/lists', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-util', 'glimmer-runtime/lib/utils'], function (exports, _glimmerRuntimeLibCompiledOpcodesComponent, _glimmerRuntimeLibCompiledOpcodesPartial, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibCompiledOpcodesDom, _glimmerRuntimeLibCompiledOpcodesLists, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerUtil, _glimmerRuntimeLibUtils) { - 'use strict'; + exports.default = _emberMetal.Mixin.create({ + /** + The object whose properties will be forwarded. + @property content + @type Ember.Object + @default null + @private + */ + content: null, - var StatementCompilationBufferProxy = (function () { - function StatementCompilationBufferProxy(inner) { - this.inner = inner; - } + init: function () { + this._super.apply(this, arguments); + _emberMetal.meta(this).setProxy(); + }, - StatementCompilationBufferProxy.prototype.toOpSeq = function toOpSeq() { - return this.inner.toOpSeq(); - }; + _initializeTag: _emberMetal.on('init', function () { + _emberMetal.meta(this)._tag = new ProxyTag(this); + }), - StatementCompilationBufferProxy.prototype.append = function append(opcode) { - this.inner.append(opcode); - }; + _contentDidChange: _emberMetal.observer('content', function () { + _emberMetal.tagFor(this).contentDidChange(); + }), - StatementCompilationBufferProxy.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.inner.getLocalSymbol(name); - }; + isTruthy: _emberRuntimeComputedComputed_macros.bool('content'), - StatementCompilationBufferProxy.prototype.hasLocalSymbol = function hasLocalSymbol(name) { - return this.inner.hasLocalSymbol(name); - }; + _debugContainerKey: null, - StatementCompilationBufferProxy.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.inner.getNamedSymbol(name); - }; + willWatchProperty: function (key) { + var contentKey = 'content.' + key; + _emberMetal._addBeforeObserver(this, contentKey, null, contentPropertyWillChange); + _emberMetal.addObserver(this, contentKey, null, contentPropertyDidChange); + }, - StatementCompilationBufferProxy.prototype.hasNamedSymbol = function hasNamedSymbol(name) { - return this.inner.hasNamedSymbol(name); - }; + didUnwatchProperty: function (key) { + var contentKey = 'content.' + key; + _emberMetal._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); + _emberMetal.removeObserver(this, contentKey, null, contentPropertyDidChange); + }, - StatementCompilationBufferProxy.prototype.getBlockSymbol = function getBlockSymbol(name) { - return this.inner.getBlockSymbol(name); - }; + unknownProperty: function (key) { + var content = _emberMetal.get(this, 'content'); + if (content) { + return _emberMetal.get(content, key); + } + }, - StatementCompilationBufferProxy.prototype.hasBlockSymbol = function hasBlockSymbol(name) { - return this.inner.hasBlockSymbol(name); - }; + setUnknownProperty: function (key, value) { + var m = _emberMetal.meta(this); + if (m.proto === this) { + // if marked as prototype then just defineProperty + // rather than delegate + _emberMetal.defineProperty(this, key, null, value); + return value; + } - StatementCompilationBufferProxy.prototype.getPartialArgsSymbol = function getPartialArgsSymbol() { - return this.inner.getPartialArgsSymbol(); - }; + var content = _emberMetal.get(this, 'content'); - StatementCompilationBufferProxy.prototype.hasPartialArgsSymbol = function hasPartialArgsSymbol() { - return this.inner.hasPartialArgsSymbol(); - }; + return _emberMetal.set(content, key, value); + } + }); +}); +enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - babelHelpers.createClass(StatementCompilationBufferProxy, [{ - key: 'component', - get: function () { - return this.inner.component; - } - }]); - return StatementCompilationBufferProxy; - })(); + 'use strict'; - exports.StatementCompilationBufferProxy = StatementCompilationBufferProxy; + exports.deprecateUnderscoreActions = deprecateUnderscoreActions; - var BasicOpcodeBuilder = (function (_StatementCompilationBufferProxy) { - babelHelpers.inherits(BasicOpcodeBuilder, _StatementCompilationBufferProxy); + /** + `Ember.ActionHandler` is available on some familiar classes including + `Ember.Route`, `Ember.Component`, and `Ember.Controller`. + (Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`, + and `Ember.Route` and available to the above classes through + inheritance.) + + @class ActionHandler + @namespace Ember + @private + */ + var ActionHandler = _emberMetal.Mixin.create({ + mergedProperties: ['actions'], - function BasicOpcodeBuilder(inner, symbolTable, env) { - _StatementCompilationBufferProxy.call(this, inner); - this.symbolTable = symbolTable; - this.env = env; - this.labelsStack = new _glimmerUtil.Stack(); + /** + The collection of functions, keyed by name, available on this + `ActionHandler` as action targets. + These functions will be invoked when a matching `{{action}}` is triggered + from within a template and the application's current route is this route. + Actions can also be invoked from other parts of your application + via `ActionHandler#send`. + The `actions` hash will inherit action handlers from + the `actions` hash defined on extended parent classes + or mixins rather than just replace the entire hash, e.g.: + ```js + App.CanDisplayBanner = Ember.Mixin.create({ + actions: { + displayBanner(msg) { + // ... + } + } + }); + App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { + actions: { + playMusic() { + // ... + } + } + }); + // `WelcomeRoute`, when active, will be able to respond + // to both actions, since the actions hash is merged rather + // then replaced when extending mixins / parent classes. + this.send('displayBanner'); + this.send('playMusic'); + ``` + Within a Controller, Route or Component's action handler, + the value of the `this` context is the Controller, Route or + Component object: + ```js + App.SongRoute = Ember.Route.extend({ + actions: { + myAction() { + this.controllerFor("song"); + this.transitionTo("other.route"); + ... + } + } + }); + ``` + It is also possible to call `this._super(...arguments)` from within an + action handler if it overrides a handler defined on a parent + class or mixin: + Take for example the following routes: + ```js + App.DebugRoute = Ember.Mixin.create({ + actions: { + debugRouteInformation() { + console.debug("trololo"); + } + } + }); + App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { + actions: { + debugRouteInformation() { + // also call the debugRouteInformation of mixed in App.DebugRoute + this._super(...arguments); + // show additional annoyance + window.alert(...); + } + } + }); + ``` + ## Bubbling + By default, an action will stop bubbling once a handler defined + on the `actions` hash handles it. To continue bubbling the action, + you must return `true` from the handler: + ```js + App.Router.map(function() { + this.route("album", function() { + this.route("song"); + }); + }); + App.AlbumRoute = Ember.Route.extend({ + actions: { + startPlaying: function() { + } } - - // helpers - - BasicOpcodeBuilder.prototype.startLabels = function startLabels() { - this.labelsStack.push(_glimmerUtil.dict()); - }; - - BasicOpcodeBuilder.prototype.stopLabels = function stopLabels() { - this.labelsStack.pop(); - }; - - BasicOpcodeBuilder.prototype.labelFor = function labelFor(name) { - var labels = this.labels; - var label = labels[name]; - if (!label) { - label = labels[name] = new _glimmerRuntimeLibCompiledOpcodesVm.LabelOpcode(name); + }); + App.AlbumSongRoute = Ember.Route.extend({ + actions: { + startPlaying() { + // ... + if (actionShouldAlsoBeTriggeredOnParentRoute) { + return true; } - return label; - }; - - // partials - - BasicOpcodeBuilder.prototype.putPartialDefinition = function putPartialDefinition(definition) { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.PutPartialDefinitionOpcode(definition)); - }; - - BasicOpcodeBuilder.prototype.putDynamicPartialDefinition = function putDynamicPartialDefinition() { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.PutDynamicPartialDefinitionOpcode(this.symbolTable)); - }; - - BasicOpcodeBuilder.prototype.evaluatePartial = function evaluatePartial() { - this.append(new _glimmerRuntimeLibCompiledOpcodesPartial.EvaluatePartialOpcode(this.symbolTable)); - }; + } + } + }); + ``` + @property actions + @type Object + @default null + @public + */ - // components + /** + Triggers a named action on the `ActionHandler`. Any parameters + supplied after the `actionName` string will be passed as arguments + to the action target function. + If the `ActionHandler` has its `target` property set, actions may + bubble to the `target`. Bubbling happens when an `actionName` can + not be found in the `ActionHandler`'s `actions` hash or if the + action target function returns `true`. + Example + ```js + App.WelcomeRoute = Ember.Route.extend({ + actions: { + playTheme() { + this.send('playMusic', 'theme.mp3'); + }, + playMusic(track) { + // ... + } + } + }); + ``` + @method send + @param {String} actionName The action to trigger + @param {*} context a context to send with the action + @public + */ + send: function (actionName) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - BasicOpcodeBuilder.prototype.putComponentDefinition = function putComponentDefinition(definition) { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutComponentDefinitionOpcode(definition)); - }; + if (this.actions && this.actions[actionName]) { + var shouldBubble = this.actions[actionName].apply(this, args) === true; + if (!shouldBubble) { + return; + } + } - BasicOpcodeBuilder.prototype.putDynamicComponentDefinition = function putDynamicComponentDefinition() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutDynamicComponentDefinitionOpcode()); - }; + var target = _emberMetal.get(this, 'target'); + if (target) { + target.send.apply(target, arguments); + } + }, - BasicOpcodeBuilder.prototype.openComponent = function openComponent(args) { - var shadow = arguments.length <= 1 || arguments[1] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[1]; + willMergeMixin: function (props) { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.OpenComponentOpcode(this.compile(args), shadow)); - }; + if (props._actions) { - BasicOpcodeBuilder.prototype.didCreateElement = function didCreateElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.DidCreateElementOpcode()); - }; + props.actions = props._actions; + delete props._actions; + } + } + }); - BasicOpcodeBuilder.prototype.shadowAttributes = function shadowAttributes() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.ShadowAttributesOpcode()); - }; + exports.default = ActionHandler; - BasicOpcodeBuilder.prototype.didRenderLayout = function didRenderLayout() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.DidRenderLayoutOpcode()); - }; + function deprecateUnderscoreActions(factory) { + Object.defineProperty(factory.prototype, '_actions', { + configurable: true, + enumerable: false, + set: function (value) {}, + get: function () { + return _emberMetal.get(this, 'actions'); + } + }); + } +}); +enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/each_proxy'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsEnumerable, _emberRuntimeSystemEach_proxy) { + /** + @module ember + @submodule ember-runtime + */ - BasicOpcodeBuilder.prototype.closeComponent = function closeComponent() { - this.append(new _glimmerRuntimeLibCompiledOpcodesComponent.CloseComponentOpcode()); - }; + // .......................................................... + // HELPERS + // + 'use strict'; - // content + var _Mixin$create; - BasicOpcodeBuilder.prototype.cautiousAppend = function cautiousAppend() { - this.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedCautiousAppendOpcode()); - }; + exports.addArrayObserver = addArrayObserver; + exports.removeArrayObserver = removeArrayObserver; + exports.objectAt = objectAt; + exports.arrayContentWillChange = arrayContentWillChange; + exports.arrayContentDidChange = arrayContentDidChange; + exports.isEmberArray = isEmberArray; - BasicOpcodeBuilder.prototype.trustingAppend = function trustingAppend() { - this.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedTrustingAppendOpcode()); - }; + function arrayObserversHelper(obj, target, opts, operation, notify) { + var willChange = opts && opts.willChange || 'arrayWillChange'; + var didChange = opts && opts.didChange || 'arrayDidChange'; + var hasObservers = _emberMetal.get(obj, 'hasArrayObservers'); - // dom + if (hasObservers === notify) { + _emberMetal.propertyWillChange(obj, 'hasArrayObservers'); + } - BasicOpcodeBuilder.prototype.text = function text(_text) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.TextOpcode(_text)); - }; + operation(obj, '@array:before', target, willChange); + operation(obj, '@array:change', target, didChange); - BasicOpcodeBuilder.prototype.openPrimitiveElement = function openPrimitiveElement(tag) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(tag)); - }; + if (hasObservers === notify) { + _emberMetal.propertyDidChange(obj, 'hasArrayObservers'); + } - BasicOpcodeBuilder.prototype.openComponentElement = function openComponentElement(tag) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenComponentElementOpcode(tag)); - }; + return obj; + } - BasicOpcodeBuilder.prototype.openDynamicPrimitiveElement = function openDynamicPrimitiveElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenDynamicPrimitiveElementOpcode()); - }; + function addArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetal.addListener, false); + } - BasicOpcodeBuilder.prototype.flushElement = function flushElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.FlushElementOpcode()); - }; + function removeArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetal.removeListener, true); + } - BasicOpcodeBuilder.prototype.closeElement = function closeElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.CloseElementOpcode()); - }; + function objectAt(content, idx) { + if (content.objectAt) { + return content.objectAt(idx); + } - BasicOpcodeBuilder.prototype.staticAttr = function staticAttr(name, namespace, value) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.StaticAttrOpcode(name, namespace, value)); - }; + return content[idx]; + } - BasicOpcodeBuilder.prototype.dynamicAttrNS = function dynamicAttrNS(name, namespace, isTrusting) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrNSOpcode(name, namespace, isTrusting)); - }; + function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { + var removing = undefined, + lim = undefined; - BasicOpcodeBuilder.prototype.dynamicAttr = function dynamicAttr(name, isTrusting) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrOpcode(name, isTrusting)); - }; + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; + } else { + if (removeAmt === undefined) { + removeAmt = -1; + } - BasicOpcodeBuilder.prototype.comment = function comment(_comment) { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.CommentOpcode(_comment)); - }; + if (addAmt === undefined) { + addAmt = -1; + } + } - // lists + if (array.__each) { + array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt); + } - BasicOpcodeBuilder.prototype.putIterator = function putIterator() { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.PutIteratorOpcode()); - }; + _emberMetal.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); - BasicOpcodeBuilder.prototype.enterList = function enterList(start, end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.EnterListOpcode(this.labelFor(start), this.labelFor(end))); - }; + if (startIdx >= 0 && removeAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { + removing = []; + lim = startIdx + removeAmt; - BasicOpcodeBuilder.prototype.exitList = function exitList() { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.ExitListOpcode()); - }; + for (var idx = startIdx; idx < lim; idx++) { + removing.push(objectAt(array, idx)); + } + } else { + removing = removeAmt; + } - BasicOpcodeBuilder.prototype.enterWithKey = function enterWithKey(start, end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.EnterWithKeyOpcode(this.labelFor(start), this.labelFor(end))); - }; + array.enumerableContentWillChange(removing, addAmt); - BasicOpcodeBuilder.prototype.nextIter = function nextIter(end) { - this.append(new _glimmerRuntimeLibCompiledOpcodesLists.NextIterOpcode(this.labelFor(end))); - }; + return array; + } - // vm + function arrayContentDidChange(array, startIdx, removeAmt, addAmt) { + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; + } else { + if (removeAmt === undefined) { + removeAmt = -1; + } - BasicOpcodeBuilder.prototype.pushRemoteElement = function pushRemoteElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PushRemoteElementOpcode()); - }; + if (addAmt === undefined) { + addAmt = -1; + } + } - BasicOpcodeBuilder.prototype.popRemoteElement = function popRemoteElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PopRemoteElementOpcode()); - }; + var adding = undefined; + if (startIdx >= 0 && addAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) { + adding = []; + var lim = startIdx + addAmt; - BasicOpcodeBuilder.prototype.popElement = function popElement() { - this.append(new _glimmerRuntimeLibCompiledOpcodesDom.PopElementOpcode()); - }; + for (var idx = startIdx; idx < lim; idx++) { + adding.push(objectAt(array, idx)); + } + } else { + adding = addAmt; + } - BasicOpcodeBuilder.prototype.label = function label(name) { - this.append(this.labelFor(name)); - }; + array.enumerableContentDidChange(removeAmt, adding); - BasicOpcodeBuilder.prototype.pushChildScope = function pushChildScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PushChildScopeOpcode()); - }; + if (array.__each) { + array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt); + } - BasicOpcodeBuilder.prototype.popScope = function popScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PopScopeOpcode()); - }; + _emberMetal.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); - BasicOpcodeBuilder.prototype.pushDynamicScope = function pushDynamicScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PushDynamicScopeOpcode()); - }; + var meta = _emberMetal.peekMeta(array); + var cache = meta && meta.readableCache(); - BasicOpcodeBuilder.prototype.popDynamicScope = function popDynamicScope() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PopDynamicScopeOpcode()); - }; + if (cache) { + if (cache.firstObject !== undefined && objectAt(array, 0) !== _emberMetal.cacheFor.get(cache, 'firstObject')) { + _emberMetal.propertyWillChange(array, 'firstObject'); + _emberMetal.propertyDidChange(array, 'firstObject'); + } + if (cache.lastObject !== undefined && objectAt(array, _emberMetal.get(array, 'length') - 1) !== _emberMetal.cacheFor.get(cache, 'lastObject')) { + _emberMetal.propertyWillChange(array, 'lastObject'); + _emberMetal.propertyDidChange(array, 'lastObject'); + } + } + return array; + } - BasicOpcodeBuilder.prototype.putNull = function putNull() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutNullOpcode()); - }; + var EMBER_ARRAY = _emberUtils.symbol('EMBER_ARRAY'); - BasicOpcodeBuilder.prototype.putValue = function putValue(expression) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(this.compile(expression))); - }; + function isEmberArray(obj) { + return obj && !!obj[EMBER_ARRAY]; + } - BasicOpcodeBuilder.prototype.putArgs = function putArgs(args) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutArgsOpcode(this.compile(args))); - }; + // .......................................................... + // ARRAY + // + /** + This mixin implements Observer-friendly Array-like behavior. It is not a + concrete implementation, but it can be used up by other classes that want + to appear like arrays. + + For example, ArrayProxy is a concrete classes that can + be instantiated to implement array-like behavior. Both of these classes use + the Array Mixin by way of the MutableArray mixin, which allows observable + changes to be made to the underlying array. + + Unlike `Ember.Enumerable,` this mixin defines methods specifically for + collections that provide index-ordered access to their contents. When you + are designing code that needs to accept any kind of Array-like object, you + should use these methods instead of Array primitives because these will + properly notify observers of changes to the array. + + Although these methods are efficient, they do add a layer of indirection to + your application so it is a good idea to use them only when you need the + flexibility of using both true JavaScript arrays and "virtual" arrays such + as controllers and collections. + + You can use the methods defined in this module to access and modify array + contents in a KVO-friendly way. You can also be notified whenever the + membership of an array changes by using `.observes('myArray.[]')`. + + To support `Ember.Array` in your own class, you must override two + primitives to use it: `length()` and `objectAt()`. + + Note that the Ember.Array mixin also incorporates the `Ember.Enumerable` + mixin. All `Ember.Array`-like objects are also enumerable. + + @class Array + @namespace Ember + @uses Ember.Enumerable + @since Ember 0.9.0 + @public + */ + var ArrayMixin = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) { + if (idx < 0 || idx >= _emberMetal.get(this, 'length')) { + return undefined; + } - BasicOpcodeBuilder.prototype.bindDynamicScope = function bindDynamicScope(names) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindDynamicScopeOpcode(names)); - }; + return _emberMetal.get(this, idx); + }, _Mixin$create.objectsAt = function (indexes) { + var _this = this; - BasicOpcodeBuilder.prototype.bindPositionalArgs = function bindPositionalArgs(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindPositionalArgsOpcode(names, symbols)); - }; + return indexes.map(function (idx) { + return objectAt(_this, idx); + }); + }, _Mixin$create.nextObject = function (idx) { + return objectAt(this, idx); + }, _Mixin$create['[]'] = _emberMetal.computed({ + get: function (key) { + return this; + }, + set: function (key, value) { + this.replace(0, _emberMetal.get(this, 'length'), value); + return this; + } + }), _Mixin$create.firstObject = _emberMetal.computed(function () { + return objectAt(this, 0); + }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () { + return objectAt(this, _emberMetal.get(this, 'length') - 1); + }).readOnly(), _Mixin$create.contains = function (obj) { - BasicOpcodeBuilder.prototype.bindNamedArgs = function bindNamedArgs(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindNamedArgsOpcode(names, symbols)); - }; + return this.indexOf(obj) >= 0; + }, _Mixin$create.slice = function (beginIndex, endIndex) { + var ret = _emberMetal.default.A(); + var length = _emberMetal.get(this, 'length'); - BasicOpcodeBuilder.prototype.bindBlocks = function bindBlocks(names, symbols) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindBlocksOpcode(names, symbols)); - }; + if (_emberMetal.isNone(beginIndex)) { + beginIndex = 0; + } - BasicOpcodeBuilder.prototype.enter = function enter(_enter, exit) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.EnterOpcode(this.labelFor(_enter), this.labelFor(exit))); - }; + if (_emberMetal.isNone(endIndex) || endIndex > length) { + endIndex = length; + } - BasicOpcodeBuilder.prototype.exit = function exit() { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.ExitOpcode()); - }; + if (beginIndex < 0) { + beginIndex = length + beginIndex; + } - BasicOpcodeBuilder.prototype.evaluate = function evaluate(name, block) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.EvaluateOpcode(name, block)); - }; + if (endIndex < 0) { + endIndex = length + endIndex; + } - BasicOpcodeBuilder.prototype.test = function test(testFunc) { - if (testFunc === 'const') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.ConstTest)); - } else if (testFunc === 'simple') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.SimpleTest)); - } else if (testFunc === 'environment') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(_glimmerRuntimeLibCompiledOpcodesVm.EnvironmentTest)); - } else if (typeof testFunc === 'function') { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.TestOpcode(testFunc)); - } else { - throw new Error('unreachable'); - } - }; + while (beginIndex < endIndex) { + ret[ret.length] = objectAt(this, beginIndex++); + } - BasicOpcodeBuilder.prototype.jump = function jump(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpOpcode(this.labelFor(target))); - }; + return ret; + }, _Mixin$create.indexOf = function (object, startAt) { + var len = _emberMetal.get(this, 'length'); - BasicOpcodeBuilder.prototype.jumpIf = function jumpIf(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpIfOpcode(this.labelFor(target))); - }; + if (startAt === undefined) { + startAt = 0; + } - BasicOpcodeBuilder.prototype.jumpUnless = function jumpUnless(target) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.JumpUnlessOpcode(this.labelFor(target))); - }; + if (startAt < 0) { + startAt += len; + } - babelHelpers.createClass(BasicOpcodeBuilder, [{ - key: 'labels', - get: function () { - return this.labelsStack.current; - } - }]); - return BasicOpcodeBuilder; - })(StatementCompilationBufferProxy); + for (var idx = startAt; idx < len; idx++) { + if (objectAt(this, idx) === object) { + return idx; + } + } - exports.BasicOpcodeBuilder = BasicOpcodeBuilder; + return -1; + }, _Mixin$create.lastIndexOf = function (object, startAt) { + var len = _emberMetal.get(this, 'length'); - function isCompilableExpression(expr) { - return expr && typeof expr['compile'] === 'function'; + if (startAt === undefined || startAt >= len) { + startAt = len - 1; } - var OpcodeBuilder = (function (_BasicOpcodeBuilder) { - babelHelpers.inherits(OpcodeBuilder, _BasicOpcodeBuilder); - - function OpcodeBuilder() { - _BasicOpcodeBuilder.apply(this, arguments); - } + if (startAt < 0) { + startAt += len; + } - OpcodeBuilder.prototype.compile = function compile(expr) { - if (isCompilableExpression(expr)) { - return expr.compile(this, this.env, this.symbolTable); - } else { - return expr; - } - }; + for (var idx = startAt; idx >= 0; idx--) { + if (objectAt(this, idx) === object) { + return idx; + } + } - OpcodeBuilder.prototype.bindPositionalArgsForBlock = function bindPositionalArgsForBlock(block) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindPositionalArgsOpcode.create(block)); - }; + return -1; + }, _Mixin$create.addArrayObserver = function (target, opts) { + return addArrayObserver(this, target, opts); + }, _Mixin$create.removeArrayObserver = function (target, opts) { + return removeArrayObserver(this, target, opts); + }, _Mixin$create.hasArrayObservers = _emberMetal.computed(function () { + return _emberMetal.hasListeners(this, '@array:change') || _emberMetal.hasListeners(this, '@array:before'); + }), _Mixin$create.arrayContentWillChange = function (startIdx, removeAmt, addAmt) { + return arrayContentWillChange(this, startIdx, removeAmt, addAmt); + }, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) { + return arrayContentDidChange(this, startIdx, removeAmt, addAmt); + }, _Mixin$create.includes = function (obj, startAt) { + var len = _emberMetal.get(this, 'length'); - OpcodeBuilder.prototype.preludeForLayout = function preludeForLayout(layout) { - if (layout.hasNamedParameters) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindNamedArgsOpcode.create(layout)); - } - if (layout.hasYields || layout.hasPartials) { - this.append(new _glimmerRuntimeLibCompiledOpcodesVm.BindCallerScopeOpcode()); - } - if (layout.hasYields) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindBlocksOpcode.create(layout)); - } - if (layout.hasPartials) { - this.append(_glimmerRuntimeLibCompiledOpcodesVm.BindPartialArgsOpcode.create(layout)); - } - }; + if (startAt === undefined) { + startAt = 0; + } - // TODO - // come back to this - - OpcodeBuilder.prototype.block = function block(args, callback) { - if (args) this.putArgs(args); - this.startLabels(); - this.enter('BEGIN', 'END'); - this.label('BEGIN'); - callback(this, 'BEGIN', 'END'); - this.label('END'); - this.exit(); - this.stopLabels(); - }; + if (startAt < 0) { + startAt += len; + } - // TODO - // come back to this - - OpcodeBuilder.prototype.iter = function iter(callback) { - this.startLabels(); - this.enterList('BEGIN', 'END'); - this.label('ITER'); - this.nextIter('BREAK'); - this.enterWithKey('BEGIN', 'END'); - this.label('BEGIN'); - callback(this, 'BEGIN', 'END'); - this.label('END'); - this.exit(); - this.jump('ITER'); - this.label('BREAK'); - this.exitList(); - this.stopLabels(); - }; + for (var idx = startAt; idx < len; idx++) { + var currentObj = objectAt(this, idx); - // TODO - // come back to this + // SameValueZero comparison (NaN !== NaN) + if (obj === currentObj || obj !== obj && currentObj !== currentObj) { + return true; + } + } - OpcodeBuilder.prototype.unit = function unit(callback) { - this.startLabels(); - callback(this); - this.stopLabels(); - }; + return false; + }, _Mixin$create['@each'] = _emberMetal.computed(function () { + // TODO use Symbol or add to meta + if (!this.__each) { + this.__each = new _emberRuntimeSystemEach_proxy.default(this); + } - return OpcodeBuilder; - })(BasicOpcodeBuilder); + return this.__each; + }).volatile().readOnly(), _Mixin$create)); - exports.default = OpcodeBuilder; + exports.default = ArrayMixin; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQXlCQSwrQkFBQTtBQUVFLGlCQUZGLCtCQUFBLENBRXdCLEtBQWlDLEVBQUE7QUFBakMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUE0QjtTQUFJOztBQUY3RCx1Q0FBQSxXQVFFLE9BQU8sR0FBQSxtQkFBQTtBQUNMLG1CQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsT0FBTyxFQUFFLENBQUM7U0FDN0I7O0FBVkgsdUNBQUEsV0FZRSxNQUFNLEdBQUEsZ0JBQW1CLE1BQVMsRUFBQTtBQUNoQyxnQkFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQU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T3Bjb2RlQnVpbGRlcikgPT4gdm9pZCkge1xuICAgIHRoaXMuc3RhcnRMYWJlbHMoKTtcbiAgICBjYWxsYmFjayh0aGlzKTtcbiAgICB0aGlzLnN0b3BMYWJlbHMoKTtcbiAgfVxufVxuXG5leHBvcnQgdHlwZSBCbG9ja0NhbGxiYWNrID0gKGRzbDogT3Bjb2RlQnVpbGRlciwgQkVHSU46IExhYmVsLCBFTkQ6IExhYmVsKSA9PiB2b2lkO1xuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/component', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-reference'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerReference) { - 'use strict'; - - var PutDynamicComponentDefinitionOpcode = (function (_Opcode) { - babelHelpers.inherits(PutDynamicComponentDefinitionOpcode, _Opcode); - - function PutDynamicComponentDefinitionOpcode() { - _Opcode.apply(this, arguments); - this.type = "put-dynamic-component-definition"; - } - - PutDynamicComponentDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var definition = cache ? cache.peek() : reference.value(); - vm.frame.setImmediate(definition); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; - - PutDynamicComponentDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; +// ES6TODO: Ember.A - return PutDynamicComponentDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); +/** + __Required.__ You must implement this method to apply this mixin. + Your array must support the `length` property. Your replace methods should + set this property whenever it changes. + @property {Number} length + @public +*/ - exports.PutDynamicComponentDefinitionOpcode = PutDynamicComponentDefinitionOpcode; +/** + Returns the object at the given `index`. If the given `index` is negative + or is greater or equal than the array length, returns `undefined`. + This is one of the primitives you must implement to support `Ember.Array`. + If your object supports retrieving the value of an array item using `get()` + (i.e. `myArray.get(0)`), then you do not need to implement this method + yourself. + ```javascript + let arr = ['a', 'b', 'c', 'd']; + arr.objectAt(0); // 'a' + arr.objectAt(3); // 'd' + arr.objectAt(-1); // undefined + arr.objectAt(4); // undefined + arr.objectAt(5); // undefined + ``` + @method objectAt + @param {Number} idx The index of the item to return. + @return {*} item at index or undefined + @public +*/ - var PutComponentDefinitionOpcode = (function (_Opcode2) { - babelHelpers.inherits(PutComponentDefinitionOpcode, _Opcode2); +/** + This returns the objects at the specified indexes, using `objectAt`. + ```javascript + let arr = ['a', 'b', 'c', 'd']; + arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] + arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] + ``` + @method objectsAt + @param {Array} indexes An array of indexes of items to return. + @return {Array} + @public + */ - function PutComponentDefinitionOpcode(definition) { - _Opcode2.call(this); - this.definition = definition; - this.type = "put-component-definition"; - } +// overrides Ember.Enumerable version - PutComponentDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setImmediate(this.definition); - }; +/** + 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 + array, it will replace the current content. + This property overrides the default property defined in `Ember.Enumerable`. + @property [] + @return this + @public +*/ - PutComponentDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.definition.name)] - }; - }; +// optimized version from Enumerable - return PutComponentDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.PutComponentDefinitionOpcode = PutComponentDefinitionOpcode; - - var OpenComponentOpcode = (function (_Opcode3) { - babelHelpers.inherits(OpenComponentOpcode, _Opcode3); - - function OpenComponentOpcode(args, shadow) { - _Opcode3.call(this); - this.args = args; - this.shadow = shadow; - this.type = "open-component"; - } - - OpenComponentOpcode.prototype.evaluate = function evaluate(vm) { - var rawArgs = this.args; - var shadow = this.shadow; - - var definition = vm.frame.getImmediate(); - var dynamicScope = vm.pushDynamicScope(); - var callerScope = vm.scope(); - var manager = definition.manager; - var args = manager.prepareArgs(definition, rawArgs.evaluate(vm), dynamicScope); - var hasDefaultBlock = !!args.blocks.default; // TODO Cleanup? - var component = manager.create(vm.env, definition, args, dynamicScope, vm.getSelf(), hasDefaultBlock); - var destructor = manager.getDestructor(component); - if (destructor) vm.newDestroyable(destructor); - var layout = manager.layoutFor(definition, component, vm.env); - var selfRef = manager.getSelf(component); - vm.beginCacheGroup(); - vm.stack().pushSimpleBlock(); - vm.pushRootScope(selfRef, layout.symbols); - vm.invokeLayout(args, layout, callerScope, component, manager, shadow); - vm.updateWith(new UpdateComponentOpcode(definition.name, component, manager, args, dynamicScope)); - }; +// Add any extra methods to Ember.Array that are native to the built-in Array. +/** + Returns a new array that is a slice of the receiver. This implementation + uses the observable array methods to retrieve the objects for the new + slice. + ```javascript + let arr = ['red', 'green', 'blue']; + arr.slice(0); // ['red', 'green', 'blue'] + arr.slice(0, 2); // ['red', 'green'] + arr.slice(1, 100); // ['green', 'blue'] + ``` + @method slice + @param {Number} beginIndex (Optional) index to begin slicing from. + @param {Number} endIndex (Optional) index to end the slice at (but not included). + @return {Array} New array with specified slice + @public +*/ - OpenComponentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; +/** + Returns the index of the given object's first occurrence. + If no `startAt` argument is given, the starting location to + search is 0. If it's negative, will count backward from + the end of the array. Returns -1 if no match is found. + ```javascript + let arr = ['a', 'b', 'c', 'd', 'a']; + arr.indexOf('a'); // 0 + arr.indexOf('z'); // -1 + arr.indexOf('a', 2); // 4 + arr.indexOf('a', -1); // 4 + arr.indexOf('b', 3); // -1 + arr.indexOf('a', 100); // -1 + ``` + @method indexOf + @param {Object} object the item to search for + @param {Number} startAt optional starting location to search, default 0 + @return {Number} index or -1 if not found + @public +*/ - return OpenComponentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.OpenComponentOpcode = OpenComponentOpcode; - - var UpdateComponentOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateComponentOpcode, _UpdatingOpcode); - - function UpdateComponentOpcode(name, component, manager, args, dynamicScope) { - _UpdatingOpcode.call(this); - this.name = name; - this.component = component; - this.manager = manager; - this.args = args; - this.dynamicScope = dynamicScope; - this.type = "update-component"; - var componentTag = manager.getTag(component); - if (componentTag) { - this.tag = _glimmerReference.combine([args.tag, componentTag]); - } else { - this.tag = args.tag; - } - } +/** + Returns the index of the given object's last occurrence. + If no `startAt` argument is given, the search starts from + the last position. If it's negative, will count backward + from the end of the array. Returns -1 if no match is found. + ```javascript + let arr = ['a', 'b', 'c', 'd', 'a']; + arr.lastIndexOf('a'); // 4 + arr.lastIndexOf('z'); // -1 + arr.lastIndexOf('a', 2); // 0 + arr.lastIndexOf('a', -1); // 4 + arr.lastIndexOf('b', 3); // 1 + arr.lastIndexOf('a', 100); // 4 + ``` + @method lastIndexOf + @param {Object} object the item to search for + @param {Number} startAt optional starting location to search, default 0 + @return {Number} index or -1 if not found + @public +*/ - UpdateComponentOpcode.prototype.evaluate = function evaluate(vm) { - var component = this.component; - var manager = this.manager; - var args = this.args; - var dynamicScope = this.dynamicScope; +// .......................................................... +// ARRAY OBSERVERS +// - manager.update(component, args, dynamicScope); - }; +/** + Adds an array observer to the receiving array. The array observer object + normally must implement two methods: + * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be + called just before the array is modified. + * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be + called just after the array is modified. + Both callbacks will be passed the observed object, starting index of the + change as well as a count of the items to be removed and added. You can use + these callbacks to optionally inspect the array during the change, clear + caches, or do any other bookkeeping necessary. + In addition to passing a target, you can also include an options hash + which you can use to override the method names that will be invoked on the + target. + @method addArrayObserver + @param {Object} target The observer object. + @param {Object} opts Optional hash of configuration options including + `willChange` and `didChange` option. + @return {Ember.Array} receiver + @public +*/ - UpdateComponentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.name)] - }; - }; +/** + Removes an array observer from the object if the observer is current + registered. Calling this method multiple times with the same object will + have no effect. + @method removeArrayObserver + @param {Object} target The object observing the array. + @param {Object} opts Optional hash of configuration options including + `willChange` and `didChange` option. + @return {Ember.Array} receiver + @public +*/ - return UpdateComponentOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); +/** + Becomes true whenever the array currently has observers watching changes + on the array. + @property {Boolean} hasArrayObservers + @public +*/ - exports.UpdateComponentOpcode = UpdateComponentOpcode; +/** + If you are implementing an object that supports `Ember.Array`, call this + method just before the array content changes to notify any observers and + invalidate any related properties. Pass the starting index of the change + as well as a delta of the amounts to change. + @method arrayContentWillChange + @param {Number} startIdx The starting index in the array that will change. + @param {Number} removeAmt The number of items that will be removed. If you + pass `null` assumes 0 + @param {Number} addAmt The number of items that will be added. If you + pass `null` assumes 0. + @return {Ember.Array} receiver + @public +*/ - var DidCreateElementOpcode = (function (_Opcode4) { - babelHelpers.inherits(DidCreateElementOpcode, _Opcode4); +/** + If you are implementing an object that supports `Ember.Array`, call this + method just after the array content changes to notify any observers and + invalidate any related properties. Pass the starting index of the change + as well as a delta of the amounts to change. + @method arrayContentDidChange + @param {Number} startIdx The starting index in the array that did change. + @param {Number} removeAmt The number of items that were removed. If you + pass `null` assumes 0 + @param {Number} addAmt The number of items that were added. If you + pass `null` assumes 0. + @return {Ember.Array} receiver + @public +*/ - function DidCreateElementOpcode() { - _Opcode4.apply(this, arguments); - this.type = "did-create-element"; - } +/** + Returns `true` if the passed object can be found in the array. + This method is a Polyfill for ES 2016 Array.includes. + If no `startAt` argument is given, the starting location to + search is 0. If it's negative, searches from the index of + `this.length + startAt` by asc. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, 3].includes(3, 2); // true + [1, 2, 3].includes(3, 3); // false + [1, 2, 3].includes(3, -1); // true + [1, 2, 3].includes(1, -1); // false + [1, 2, 3].includes(1, -4); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @param {Number} startAt optional starting location to search, default 0 + @return {Boolean} `true` if object is found in the array. + @public +*/ - // Slow path for non-specialized component invocations. Uses an internal - // named lookup on the args. +/** + Returns a special object that can be used to observe individual properties + on the array. Just get an equivalent property on this object and it will + return an enumerable that maps automatically to the named key on the + member objects. + `@each` should only be used in a non-terminal context. Example: + ```javascript + myMethod: computed('posts.@each.author', function(){ + ... + }); + ``` + If you merely want to watch for the array being changed, like an object being + replaced, added or removed, use `[]` instead of `@each`. + ```javascript + myMethod: computed('posts.[]', function(){ + ... + }); + ``` + @property @each + @public +*/ +enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - DidCreateElementOpcode.prototype.evaluate = function evaluate(vm) { - var manager = vm.frame.getManager(); - var component = vm.frame.getComponent(); - manager.didCreateElement(component, vm.stack().constructing, vm.stack().operations); - }; + /** + @module ember + @submodule ember-runtime + */ - DidCreateElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$ARGS"] - }; - }; + /** + Implements some standard methods for comparing objects. Add this mixin to + any class you create that can compare its instances. + + You should implement the `compare()` method. + + @class Comparable + @namespace Ember + @since Ember 0.9 + @private + */ + exports.default = _emberMetal.Mixin.create({ - return DidCreateElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + __Required.__ You must implement this method to apply this mixin. + Override to return the result of the comparison of the two parameters. The + compare method should return: + - `-1` if `a < b` + - `0` if `a == b` + - `1` if `a > b` + Default implementation raises an exception. + @method compare + @param a {Object} the first object to compare + @param b {Object} the second object to compare + @return {Number} the result of the comparison + @private + */ + compare: null + }); +}); +enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal', 'container'], function (exports, _emberMetal, _container) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - exports.DidCreateElementOpcode = DidCreateElementOpcode; + var _containerProxyMixin; - var ShadowAttributesOpcode = (function (_Opcode5) { - babelHelpers.inherits(ShadowAttributesOpcode, _Opcode5); + /** + ContainerProxyMixin is used to provide public access to specific + container functionality. + + @class ContainerProxyMixin + @private + */ + var containerProxyMixin = (_containerProxyMixin = { + /** + The container stores state. + @private + @property {Ember.Container} __container__ + */ + __container__: null, - function ShadowAttributesOpcode() { - _Opcode5.apply(this, arguments); - this.type = "shadow-attributes"; - } + /** + Returns an object that can be used to provide an owner to a + manually created instance. + Example: + ``` + let owner = Ember.getOwner(this); + User.create( + owner.ownerInjection(), + { username: 'rwjblue' } + ) + ``` + @public + @method ownerInjection + @since 2.3.0 + @return {Object} + */ + ownerInjection: function () { + return this.__container__.ownerInjection(); + }, - ShadowAttributesOpcode.prototype.evaluate = function evaluate(vm) { - var shadow = vm.frame.getShadow(); - if (!shadow) return; + /** + Given a fullName return a corresponding instance. + The default behaviour is for lookup to return a singleton instance. + The singleton is scoped to the container, allowing multiple containers + to all have their own locally scoped singletons. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter'); + twitter instanceof Twitter; // => true + // by default the container will return singletons + let twitter2 = container.lookup('api:twitter'); + twitter2 instanceof Twitter; // => true + twitter === twitter2; //=> true + ``` + If singletons are not wanted an optional flag can be provided at lookup. + ```javascript + let registry = new Registry(); + let container = registry.container(); + registry.register('api:twitter', Twitter); + let twitter = container.lookup('api:twitter', { singleton: false }); + let twitter2 = container.lookup('api:twitter', { singleton: false }); + twitter === twitter2; //=> false + ``` + @public + @method lookup + @param {String} fullName + @param {Object} options + @return {any} + */ + lookup: function (fullName, options) { + return this.__container__.lookup(fullName, options); + }, - var _vm$frame$getArgs = vm.frame.getArgs(); + /** + Given a fullName return the corresponding factory. + @private + @method _lookupFactory + @param {String} fullName + @return {any} + */ + _lookupFactory: function (fullName, options) { + return this.__container__.lookupFactory(fullName, options); + } - var named = _vm$frame$getArgs.named; + }, _containerProxyMixin[_container.FACTORY_FOR] = function () { + var _container__; - shadow.forEach(function (name) { - vm.stack().setDynamicAttribute(name, named.get(name), false); - }); - }; + return (_container__ = this.__container__)[_container.FACTORY_FOR].apply(_container__, arguments); + }, _containerProxyMixin[_container.LOOKUP_FACTORY] = function () { + var _container__2; - ShadowAttributesOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$ARGS"] - }; - }; + return (_container__2 = this.__container__)[_container.LOOKUP_FACTORY].apply(_container__2, arguments); + }, _containerProxyMixin._resolveLocalLookupName = function (name, source) { + return this.__container__.registry.expandLocalLookup('component:' + name, { + source: source + }); + }, _containerProxyMixin.willDestroy = function () { + this._super.apply(this, arguments); - return ShadowAttributesOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (this.__container__) { + _emberMetal.run(this.__container__, 'destroy'); + } + }, _containerProxyMixin); - exports.ShadowAttributesOpcode = ShadowAttributesOpcode; + if (true) { + containerProxyMixin.factoryFor = function ContainerProxyMixin_factoryFor(fullName) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var DidRenderLayoutOpcode = (function (_Opcode6) { - babelHelpers.inherits(DidRenderLayoutOpcode, _Opcode6); + return this.__container__.factoryFor(fullName, options); + }; + } - function DidRenderLayoutOpcode() { - _Opcode6.apply(this, arguments); - this.type = "did-render-layout"; - } + exports.default = _emberMetal.Mixin.create(containerProxyMixin); +}); - DidRenderLayoutOpcode.prototype.evaluate = function evaluate(vm) { - var manager = vm.frame.getManager(); - var component = vm.frame.getComponent(); - var bounds = vm.stack().popBlock(); - manager.didRenderLayout(component, bounds); - vm.env.didCreate(component, manager); - vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); - }; +/** + Given a name and a source path, resolve the fullName + @private + @method _resolveLocalLookupName + @param {String} fullName + @param {String} source + @return {String} + */ - return DidRenderLayoutOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); +/** + @private + */ +enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) { + 'use strict'; - exports.DidRenderLayoutOpcode = DidRenderLayoutOpcode; + /** + @class ControllerMixin + @namespace Ember + @uses Ember.ActionHandler + @private + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, { + /* ducktype as a controller */ + isController: true, - var DidUpdateLayoutOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(DidUpdateLayoutOpcode, _UpdatingOpcode2); + /** + The object to which actions from the view should be sent. + For example, when a Handlebars template uses the `{{action}}` helper, + it will attempt to send the action to the view's controller's `target`. + By default, the value of the target property is set to the router, and + is injected when a controller is instantiated. This injection is applied + as part of the application's initialization process. In most cases the + `target` property will automatically be set to the logical consumer of + actions for the controller. + @property target + @default null + @public + */ + target: null, - function DidUpdateLayoutOpcode(manager, component, bounds) { - _UpdatingOpcode2.call(this); - this.manager = manager; - this.component = component; - this.bounds = bounds; - this.type = "did-update-layout"; - this.tag = _glimmerReference.CONSTANT_TAG; - } + store: null, - DidUpdateLayoutOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; - var component = this.component; - var bounds = this.bounds; + /** + The controller's current model. When retrieving or modifying a controller's + model, this property should be used instead of the `content` property. + @property model + @public + */ + model: null, - manager.didUpdateLayout(component, bounds); - vm.env.didUpdate(component, manager); - }; + /** + @private + */ + content: _emberMetal.alias('model') - return DidUpdateLayoutOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + }); +}); +enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - exports.DidUpdateLayoutOpcode = DidUpdateLayoutOpcode; + /* + The ControllerContentModelAliasDeprecation mixin is used to provide a useful + deprecation warning when specifying `content` directly on a `Ember.Controller` + (without also specifying `model`). + + Ember versions prior to 1.7 used `model` as an alias of `content`, but due to + much confusion this alias was reversed (so `content` is now an alias of `model). + + This change reduces many caveats with model/content, and also sets a + simple ground rule: Never set a controllers content, rather always set + its model and ember will do the right thing. + + Used internally by Ember in `Ember.Controller`. + */ + exports.default = _emberMetal.Mixin.create({ + /** + @private + Moves `content` to `model` at extend time if a `model` is not also specified. + Note that this currently modifies the mixin themselves, which is technically + dubious but is practically of little consequence. This may change in the + future. + @method willMergeMixin + @since 1.4.0 + */ + willMergeMixin: function (props) { + // Calling super is only OK here since we KNOW that + // there is another Mixin loaded first. + this._super.apply(this, arguments); - var CloseComponentOpcode = (function (_Opcode7) { - babelHelpers.inherits(CloseComponentOpcode, _Opcode7); + var modelSpecified = !!props.model; - function CloseComponentOpcode() { - _Opcode7.apply(this, arguments); - this.type = "close-component"; - } + if (props.content && !modelSpecified) { + props.model = props.content; + delete props['content']; + } + } + }); +}); +enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal', 'ember-runtime/mixins/freezable'], function (exports, _emberMetal, _emberRuntimeMixinsFreezable) { + /** + @module ember + @submodule ember-runtime + */ - CloseComponentOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - vm.popDynamicScope(); - vm.commitCacheGroup(); - }; + 'use strict'; - return CloseComponentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Implements some standard methods for copying an object. Add this mixin to + any object you create that can create a copy of itself. This mixin is + added automatically to the built-in array. + + You should generally implement the `copy()` method to return a copy of the + receiver. + + Note that `frozenCopy()` will only work if you also implement + `Ember.Freezable`. + + @class Copyable + @namespace Ember + @since Ember 0.9 + @private + */ + exports.default = _emberMetal.Mixin.create({ + /** + __Required.__ You must implement this method to apply this mixin. + Override to return a copy of the receiver. Default implementation raises + an exception. + @method copy + @param {Boolean} deep if `true`, a deep copy of the object should be made + @return {Object} copy of receiver + @private + */ + copy: null, - exports.CloseComponentOpcode = CloseComponentOpcode; + /** + If the object implements `Ember.Freezable`, then this will return a new + copy if the object is not frozen and the receiver if the object is frozen. + Raises an exception if you try to call this method on a object that does + not support freezing. + You should use this method whenever you want a copy of a freezable object + since a freezable object can simply return itself without actually + consuming more memory. + @method frozenCopy + @return {Object} copy of receiver or receiver + @deprecated Use `Object.freeze` instead. + @private + */ + frozenCopy: function () { + if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) { + return _emberMetal.get(this, 'isFrozen') ? this : this.copy().freeze(); + } else { + throw new _emberMetal.Error(this + ' does not support freezing'); + } + } + }); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBVUEsbUNBQUE7OEJBQUEsbUNBQUE7O0FBQUEsaUJBQUEsbUNBQUEsR0FBQTtBQUF5RCxnQ0FBQSxTQUFBLENBQUEsQ0FBTTtBQUN0RCxnQkFBQSxDQUFBLElBQUksR0FBRyxrQ0FBa0MsQ0FBQztTQXFCbEQ7O0FBdEJELDJDQUFBLFdBR0UsUUFBUSxHQUFBLGtCQUFDLEVBQU0sRUFBQTtBQUNiLGdCQUFJLFNBQVMsR0FBRyxFQUFFLENBQUMsS0FBSyxDQUFDLFVBQVUsRUFBa0MsQ0FBQztBQUN0RSxnQkFBSSxLQUFLLEdBQUcsa0JBUitDLE9BQU8sQ0FROUMsU0FBUyxDQUFDLEdBQUcsU0FBUyxHQUFHLHNCQVJYLGNBQWMsQ0FRZ0IsU0FBUyxDQUFDLENBQUM7QUFDM0UsZ0JBQUksVUFBVSxHQUFHLEtBQUssR0FBRyxLQUFLLENBQUMsSUFBSSxFQUFFLEdBQUcsU0FBUyxDQUFDLEtBQUssRUFBRSxDQUFDO0FBRTFELGNBQUUsQ0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLFVBQVUsQ0FBQ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2VyKTtcbiAgfVxufVxuXG5leHBvcnQgY2xhc3MgQ2xvc2VDb21wb25lbnRPcGNvZGUgZXh0ZW5kcyBPcGNvZGUge1xuICBwdWJsaWMgdHlwZSA9IFwiY2xvc2UtY29tcG9uZW50XCI7XG5cbiAgZXZhbHVhdGUodm06IFZNKSB7XG4gICAgdm0ucG9wU2NvcGUoKTtcbiAgICB2bS5wb3BEeW5hbWljU2NvcGUoKTtcbiAgICB2bS5jb21taXRDYWNoZUdyb3VwKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/opcodes/content', ['exports', 'glimmer-runtime/lib/upsert', 'glimmer-runtime/lib/component/interfaces', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/vm/update', 'glimmer-reference', 'glimmer-util', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/compiler', 'glimmer-runtime/lib/compiled/opcodes/builder', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/syntax/core'], function (exports, _glimmerRuntimeLibUpsert, _glimmerRuntimeLibComponentInterfaces, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibVmUpdate, _glimmerReference, _glimmerUtil, _glimmerRuntimeLibBounds, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibCompiler, _glimmerRuntimeLibCompiledOpcodesBuilder, _glimmerRuntimeLibReferences, _glimmerRuntimeLibSyntaxCore) { - 'use strict'; +enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'require'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _require) { + /** + @module ember + @submodule ember-runtime + */ - exports.normalizeTextValue = normalizeTextValue; + // .......................................................... + // HELPERS + // - function isEmpty(value) { - return value === null || value === undefined || typeof value['toString'] !== 'function'; - } + 'use strict'; - function normalizeTextValue(value) { - if (isEmpty(value)) { - return ''; - } - return String(value); - } + var _emberA = undefined; - function normalizeTrustedValue(value) { - if (isEmpty(value)) { - return ''; - } - if (_glimmerRuntimeLibUpsert.isString(value)) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value)) { - return value.toHTML(); - } - if (_glimmerRuntimeLibUpsert.isNode(value)) { - return value; - } - return String(value); - } - function normalizeValue(value) { - if (isEmpty(value)) { - return ''; - } - if (_glimmerRuntimeLibUpsert.isString(value)) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value) || _glimmerRuntimeLibUpsert.isNode(value)) { - return value; - } - return String(value); - } + function emberA() { + return (_emberA || (_emberA = _require.default('ember-runtime/system/native_array').A))(); + } - var AppendOpcode = (function (_Opcode) { - babelHelpers.inherits(AppendOpcode, _Opcode); + var contexts = []; - function AppendOpcode() { - _Opcode.apply(this, arguments); - } + function popCtx() { + return contexts.length === 0 ? {} : contexts.pop(); + } - AppendOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var normalized = this.normalize(reference); - var value = undefined, - cache = undefined; - if (_glimmerReference.isConst(reference)) { - value = normalized.value(); - } else { - cache = new _glimmerReference.ReferenceCache(normalized); - value = cache.peek(); - } - var stack = vm.stack(); - var upsert = this.insert(vm.env.getAppendOperations(), stack, value); - var bounds = new _glimmerRuntimeLibBuilder.Fragment(upsert.bounds); - stack.newBounds(bounds); - if (cache /* i.e. !isConst(reference) */) { - vm.updateWith(this.updateWith(vm, reference, cache, bounds, upsert)); - } - }; + function pushCtx(ctx) { + contexts.push(ctx); + return null; + } - AppendOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + function iter(key, value) { + var valueProvided = arguments.length === 2; - return AppendOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function i(item) { + var cur = _emberMetal.get(item, key); + return valueProvided ? value === cur : !!cur; + } - exports.AppendOpcode = AppendOpcode; + return i; + } + + /** + This mixin defines the common interface implemented by enumerable objects + in Ember. Most of these methods follow the standard Array iteration + API defined up to JavaScript 1.8 (excluding language-specific features that + cannot be emulated in older versions of JavaScript). + + This mixin is applied automatically to the Array class on page load, so you + can use any of these methods on simple arrays. If Array already implements + one of these methods, the mixin will not override them. + + ## Writing Your Own Enumerable + + To make your own custom class enumerable, you need two items: + + 1. You must have a length property. This property should change whenever + the number of items in your enumerable object changes. If you use this + with an `Ember.Object` subclass, you should be sure to change the length + property using `set().` + + 2. You must implement `nextObject().` See documentation. + + Once you have these two methods implemented, apply the `Ember.Enumerable` mixin + to your class and you will be able to enumerate the contents of your object + like any other collection. + + ## Using Ember Enumeration with Other Libraries + + Many other libraries provide some kind of iterator or enumeration like + facility. This is often where the most common API conflicts occur. + Ember's API is designed to be as friendly as possible with other + libraries by implementing only methods that mostly correspond to the + JavaScript 1.8 API. + + @class Enumerable + @namespace Ember + @since Ember 0.9 + @private + */ + var Enumerable = _emberMetal.Mixin.create({ - var GuardedAppendOpcode = (function (_AppendOpcode) { - babelHelpers.inherits(GuardedAppendOpcode, _AppendOpcode); + /** + __Required.__ You must implement this method to apply this mixin. + Implement this method to make your class enumerable. + This method will be called repeatedly during enumeration. The index value + will always begin with 0 and increment monotonically. You don't have to + rely on the index value to determine what object to return, but you should + always check the value and start from the beginning when you see the + requested index is 0. + The `previousObject` is the object that was returned from the last call + to `nextObject` for the current iteration. This is a useful way to + manage iteration if you are tracing a linked list, for example. + Finally the context parameter will always contain a hash you can use as + a "scratchpad" to maintain any other state you need in order to iterate + properly. The context object is reused and is not reset between + iterations so make sure you setup the context with a fresh state whenever + the index parameter is 0. + Generally iterators will continue to call `nextObject` until the index + reaches the current length-1. If you run out of data before this + time for some reason, you should simply return undefined. + The default implementation of this method simply looks up the index. + This works great on any Array-like objects. + @method nextObject + @param {Number} index the current index of the iteration + @param {Object} previousObject the value returned by the last call to + `nextObject`. + @param {Object} context a context object you can use to maintain state. + @return {Object} the next object in the iteration or undefined + @private + */ + nextObject: null, - function GuardedAppendOpcode(expression, symbolTable) { - _AppendOpcode.call(this); - this.expression = expression; - this.symbolTable = symbolTable; - this.deopted = null; - } + /** + Helper method returns the first object from a collection. This is usually + used by bindings and other parts of the framework to extract a single + object if the enumerable contains only one item. + If you override this method, you should implement it so that it will + always return the same value each time it is called. If your enumerable + contains only one object, this method should always return that object. + If your enumerable is empty, this method should return `undefined`. + ```javascript + let arr = ['a', 'b', 'c']; + arr.get('firstObject'); // 'a' + let arr = []; + arr.get('firstObject'); // undefined + ``` + @property firstObject + @return {Object} the object or undefined + @readOnly + @public + */ + firstObject: _emberMetal.computed('[]', function () { + if (_emberMetal.get(this, 'length') === 0) { + return undefined; + } - GuardedAppendOpcode.prototype.evaluate = function evaluate(vm) { - if (this.deopted) { - vm.pushEvalFrame(this.deopted); - } else { - vm.evaluateOperand(this.expression); - var value = vm.frame.getOperand().value(); - if (_glimmerRuntimeLibComponentInterfaces.isComponentDefinition(value)) { - vm.pushEvalFrame(this.deopt(vm.env)); - } else { - _AppendOpcode.prototype.evaluate.call(this, vm); - } - } - }; + // handle generic enumerables + var context = popCtx(); + var ret = this.nextObject(0, null, context); - GuardedAppendOpcode.prototype.deopt = function deopt(env) { - var _this = this; + pushCtx(context); - // At compile time, we determined that this append callsite might refer - // to a local variable/property lookup that resolves to a component - // definition at runtime. - // - // We could have eagerly compiled this callsite into something like this: - // - // {{#if (is-component-definition foo)}} - // {{component foo}} - // {{else}} - // {{foo}} - // {{/if}} - // - // However, in practice, there might be a large amout of these callsites - // and most of them would resolve to a simple value lookup. Therefore, we - // tried to be optimistic and assumed that the callsite will resolve to - // appending a simple value. - // - // However, we have reached here because at runtime, the guard conditional - // have detected that this callsite is indeed referring to a component - // definition object. Since this is likely going to be true for other - // instances of the same callsite, it is now appropiate to deopt into the - // expanded version that handles both cases. The compilation would look - // like this: - // - // PutValue(expression) - // Test(is-component-definition) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(VALUE) - // PutDynamicComponentDefinitionOpcode - // OpenComponent - // CloseComponent - // Jump(END) - // VALUE: Noop - // OptimizedAppend - // END: Noop - // Exit - // - // Keep in mind that even if we *don't* reach here at initial render time, - // it is still possible (although quite rare) that the simple value we - // encounter during initial render could later change into a component - // definition object at update time. That is handled by the "lazy deopt" - // code on the update side (scroll down for the next big block of comment). - var buffer = new _glimmerRuntimeLibCompiler.CompileIntoList(env, null); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, this.symbolTable, env); - dsl.putValue(this.expression); - dsl.test(IsComponentDefinitionReference.create); - dsl.block(null, function (dsl, BEGIN, END) { - dsl.jumpUnless('VALUE'); - dsl.putDynamicComponentDefinition(); - dsl.openComponent(_glimmerRuntimeLibSyntaxCore.Args.empty()); - dsl.closeComponent(); - dsl.jump(END); - dsl.label('VALUE'); - dsl.append(new _this.AppendOpcode()); - }); - var deopted = this.deopted = dsl.toOpSeq(); - // From this point on, we have essentially replaced ourselve with a new set - // of opcodes. Since we will always be executing the new/deopted code, it's - // a good idea (as a pattern) to null out any unneeded fields here to avoid - // holding on to unneeded/stale objects: - this.expression = null; - return deopted; - }; + return ret; + }).readOnly(), - GuardedAppendOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var deopted = this.deopted; - - if (deopted) { - return { - guid: guid, - type: type, - deopted: true, - children: deopted.toArray().map(function (op) { - return op.toJSON(); - }) - }; - } else { - return { - guid: guid, - type: type, - args: [this.expression.toJSON()] - }; - } - }; + /** + Helper method returns the last object from a collection. If your enumerable + contains only one object, this method should always return that object. + If your enumerable is empty, this method should return `undefined`. + ```javascript + let arr = ['a', 'b', 'c']; + arr.get('lastObject'); // 'c' + let arr = []; + arr.get('lastObject'); // undefined + ``` + @property lastObject + @return {Object} the last object or undefined + @readOnly + @public + */ + lastObject: _emberMetal.computed('[]', function () { + var len = _emberMetal.get(this, 'length'); - return GuardedAppendOpcode; - })(AppendOpcode); + if (len === 0) { + return undefined; + } - exports.GuardedAppendOpcode = GuardedAppendOpcode; + var context = popCtx(); + var idx = 0; + var last = null; + var cur = undefined; - var IsComponentDefinitionReference = (function (_ConditionalReference) { - babelHelpers.inherits(IsComponentDefinitionReference, _ConditionalReference); + do { + last = cur; + cur = this.nextObject(idx++, last, context); + } while (cur !== undefined); - function IsComponentDefinitionReference() { - _ConditionalReference.apply(this, arguments); - } + pushCtx(context); - IsComponentDefinitionReference.create = function create(inner) { - return new IsComponentDefinitionReference(inner); - }; + return last; + }).readOnly(), - IsComponentDefinitionReference.prototype.toBool = function toBool(value) { - return _glimmerRuntimeLibComponentInterfaces.isComponentDefinition(value); - }; + /** + Returns `true` if the passed object can be found in the receiver. The + default version will iterate through the enumerable until the object + is found. You may want to override this with a more efficient version. + ```javascript + let arr = ['a', 'b', 'c']; + arr.contains('a'); // true + arr.contains('z'); // false + ``` + @method contains + @deprecated Use `Enumerable#includes` instead. See http://emberjs.com/deprecations/v2.x#toc_enumerable-contains + @param {Object} obj The object to search for. + @return {Boolean} `true` if object is found in enumerable. + @public + */ + contains: function (obj) { - return IsComponentDefinitionReference; - })(_glimmerRuntimeLibReferences.ConditionalReference); + var found = this.find(function (item) { + return item === obj; + }); - var UpdateOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateOpcode, _UpdatingOpcode); + return found !== undefined; + }, - function UpdateOpcode(cache, bounds, upsert) { - _UpdatingOpcode.call(this); - this.cache = cache; - this.bounds = bounds; - this.upsert = upsert; - this.tag = cache.tag; - } + /** + Iterates through the enumerable, calling the passed function on each + item. This method corresponds to the `forEach()` method defined in + JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method forEach + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Object} receiver + @public + */ + forEach: function (callback, target) { + if (typeof callback !== 'function') { + throw new TypeError(); + } - UpdateOpcode.prototype.evaluate = function evaluate(vm) { - var value = this.cache.revalidate(); - if (_glimmerReference.isModified(value)) { - var bounds = this.bounds; - var upsert = this.upsert; - var dom = vm.dom; + var context = popCtx(); + var len = _emberMetal.get(this, 'length'); + var last = null; - if (!this.upsert.update(dom, value)) { - var cursor = new _glimmerRuntimeLibBounds.Cursor(bounds.parentElement(), _glimmerRuntimeLibBounds.clear(bounds)); - upsert = this.upsert = this.insert(vm.env.getAppendOperations(), cursor, value); - } - bounds.update(upsert.bounds); - } - }; + if (target === undefined) { + target = null; + } - UpdateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var cache = this.cache; + for (var idx = 0; idx < len; idx++) { + var next = this.nextObject(idx, last, context); + callback.call(target, next, idx, this); + last = next; + } - return { - guid: guid, - type: type, - details: { lastValue: JSON.stringify(cache.peek()) } - }; - }; + last = null; + context = pushCtx(context); - return UpdateOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + return this; + }, - var GuardedUpdateOpcode = (function (_UpdateOpcode) { - babelHelpers.inherits(GuardedUpdateOpcode, _UpdateOpcode); + /** + Alias for `mapBy` + @method getEach + @param {String} key name of the property + @return {Array} The mapped array. + @public + */ + getEach: _emberMetal.aliasMethod('mapBy'), - function GuardedUpdateOpcode(reference, cache, bounds, upsert, appendOpcode, state) { - _UpdateOpcode.call(this, cache, bounds, upsert); - this.reference = reference; - this.appendOpcode = appendOpcode; - this.state = state; - this.deopted = null; - this.tag = this._tag = new _glimmerReference.UpdatableTag(this.tag); - } + /** + Sets the value on the named property for each member. This is more + ergonomic than using other methods defined on this helper. If the object + implements Ember.Observable, the value will be changed to `set(),` otherwise + it will be set directly. `null` objects are skipped. + @method setEach + @param {String} key The key to set + @param {Object} value The object to set + @return {Object} receiver + @public + */ + setEach: function (key, value) { + return this.forEach(function (item) { + return _emberMetal.set(item, key, value); + }); + }, - GuardedUpdateOpcode.prototype.evaluate = function evaluate(vm) { - if (this.deopted) { - vm.evaluateOpcode(this.deopted); - } else { - if (_glimmerRuntimeLibComponentInterfaces.isComponentDefinition(this.reference.value())) { - this.lazyDeopt(vm); - } else { - _UpdateOpcode.prototype.evaluate.call(this, vm); - } - } - }; + /** + Maps all of the items in the enumeration to another value, returning + a new array. This method corresponds to `map()` defined in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the mapped value. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method map + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} The mapped array. + @public + */ + map: function (callback, target) { + var ret = emberA(); - GuardedUpdateOpcode.prototype.lazyDeopt = function lazyDeopt(vm) { - // Durign initial render, we know that the reference does not contain a - // component definition, so we optimistically assumed that this append - // is just a normal append. However, at update time, we discovered that - // the reference has switched into containing a component definition, so - // we need to do a "lazy deopt", simulating what would have happened if - // we had decided to perform the deopt in the first place during initial - // render. - // - // More concretely, we would have expanded the curly into a if/else, and - // based on whether the value is a component definition or not, we would - // have entered either the dynamic component branch or the simple value - // branch. - // - // Since we rendered a simple value during initial render (and all the - // updates up until this point), we need to pretend that the result is - // produced by the "VALUE" branch of the deopted append opcode: - // - // Try(BEGIN, END) - // Assert(IsComponentDefinition, expected=false) - // OptimizedUpdate - // - // In this case, because the reference has switched from being a simple - // value into a component definition, what would have happened is that - // the assert would throw, causing the Try opcode to teardown the bounds - // and rerun the original append opcode. - // - // Since the Try opcode would have nuked the updating opcodes anyway, we - // wouldn't have to worry about simulating those. All we have to do is to - // execute the Try opcode and immediately throw. - var bounds = this.bounds; - var appendOpcode = this.appendOpcode; - var state = this.state; - - var appendOps = appendOpcode.deopt(vm.env); - var enter = appendOps.head().next.next; - var ops = enter.slice; - var tracker = new _glimmerRuntimeLibBuilder.UpdatableBlockTracker(bounds.parentElement()); - tracker.newBounds(this.bounds); - var children = new _glimmerUtil.LinkedList(); - state.frame['condition'] = IsComponentDefinitionReference.create(state.frame['operand']); - var deopted = this.deopted = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, children); - this._tag.update(deopted.tag); - vm.evaluateOpcode(deopted); - vm.throw(); - // From this point on, we have essentially replaced ourselve with a new - // opcode. Since we will always be executing the new/deopted code, it's a - // good idea (as a pattern) to null out any unneeded fields here to avoid - // holding on to unneeded/stale objects: - this._tag = null; - this.reference = null; - this.cache = null; - this.bounds = null; - this.upsert = null; - this.appendOpcode = null; - this.state = null; - }; + this.forEach(function (x, idx, i) { + return ret[idx] = callback.call(target, x, idx, i); + }); - GuardedUpdateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var deopted = this.deopted; - - if (deopted) { - return { - guid: guid, - type: type, - deopted: true, - children: [deopted.toJSON()] - }; - } else { - return _UpdateOpcode.prototype.toJSON.call(this); - } - }; + return ret; + }, - return GuardedUpdateOpcode; - })(UpdateOpcode); + /** + Similar to map, this specialized function returns the value of the named + property on all items in the enumeration. + @method mapBy + @param {String} key name of the property + @return {Array} The mapped array. + @public + */ + mapBy: function (key) { + return this.map(function (next) { + return _emberMetal.get(next, key); + }); + }, - var OptimizedCautiousAppendOpcode = (function (_AppendOpcode2) { - babelHelpers.inherits(OptimizedCautiousAppendOpcode, _AppendOpcode2); + /** + Returns an array with all of the items in the enumeration that the passed + function returns true for. This method corresponds to `filter()` defined in + JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method filter + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} A filtered array. + @public + */ + filter: function (callback, target) { + var ret = emberA(); - function OptimizedCautiousAppendOpcode() { - _AppendOpcode2.apply(this, arguments); - this.type = 'optimized-cautious-append'; + this.forEach(function (x, idx, i) { + if (callback.call(target, x, idx, i)) { + ret.push(x); } + }); - OptimizedCautiousAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeValue); - }; - - OptimizedCautiousAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + return ret; + }, - OptimizedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new OptimizedCautiousUpdateOpcode(cache, bounds, upsert); - }; + /** + Returns an array with all of the items in the enumeration where the passed + function returns false. This method is the inverse of filter(). + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - *item* is the current item in the iteration. + - *index* is the current index in the iteration + - *enumerable* is the enumerable object itself. + It should return a falsey value to include the item in the results. + Note that in addition to a callback, you can also pass an optional target + object that will be set as "this" on the context. This is a good way + to give your iterator function access to the current object. + @method reject + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Array} A rejected array. + @public + */ + reject: function (callback, target) { + return this.filter(function () { + return !callback.apply(target, arguments); + }); + }, - return OptimizedCautiousAppendOpcode; - })(AppendOpcode); + /** + Returns an array with just the items with the matched property. You + can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to `true`. + @method filterBy + @param {String} key the property to test + @param {*} [value] optional value to test against. + @return {Array} filtered array + @public + */ + filterBy: function (key, value) { + return this.filter(iter.apply(this, arguments)); + }, - exports.OptimizedCautiousAppendOpcode = OptimizedCautiousAppendOpcode; + /** + Returns an array with the items that do not have truthy values for + key. You can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to false. + @method rejectBy + @param {String} key the property to test + @param {String} [value] optional value to test against. + @return {Array} rejected array + @public + */ + rejectBy: function (key, value) { + var exactValue = function (item) { + return _emberMetal.get(item, key) === value; + }; + var hasValue = function (item) { + return !!_emberMetal.get(item, key); + }; + var use = arguments.length === 2 ? exactValue : hasValue; - var OptimizedCautiousUpdateOpcode = (function (_UpdateOpcode2) { - babelHelpers.inherits(OptimizedCautiousUpdateOpcode, _UpdateOpcode2); + return this.reject(use); + }, - function OptimizedCautiousUpdateOpcode() { - _UpdateOpcode2.apply(this, arguments); - this.type = 'optimized-cautious-update'; - } + /** + Returns the first item in the array for which the callback returns true. + This method works similar to the `filter()` method defined in JavaScript 1.6 + except that it will stop working on the array once a match is found. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @method find + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Object} Found item or `undefined`. + @public + */ + find: function (callback, target) { + var len = _emberMetal.get(this, 'length'); - OptimizedCautiousUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + if (target === undefined) { + target = null; + } - return OptimizedCautiousUpdateOpcode; - })(UpdateOpcode); + var context = popCtx(); + var found = false; + var last = null; + var next = undefined, + ret = undefined; - var GuardedCautiousAppendOpcode = (function (_GuardedAppendOpcode) { - babelHelpers.inherits(GuardedCautiousAppendOpcode, _GuardedAppendOpcode); + for (var idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); - function GuardedCautiousAppendOpcode() { - _GuardedAppendOpcode.apply(this, arguments); - this.type = 'guarded-cautious-append'; - this.AppendOpcode = OptimizedCautiousAppendOpcode; + found = callback.call(target, next, idx, this); + if (found) { + ret = next; } - GuardedCautiousAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeValue); - }; - - GuardedCautiousAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; - - GuardedCautiousAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new GuardedCautiousUpdateOpcode(reference, cache, bounds, upsert, this, vm.capture()); - }; - - return GuardedCautiousAppendOpcode; - })(GuardedAppendOpcode); - - exports.GuardedCautiousAppendOpcode = GuardedCautiousAppendOpcode; - - var GuardedCautiousUpdateOpcode = (function (_GuardedUpdateOpcode) { - babelHelpers.inherits(GuardedCautiousUpdateOpcode, _GuardedUpdateOpcode); - - function GuardedCautiousUpdateOpcode() { - _GuardedUpdateOpcode.apply(this, arguments); - this.type = 'guarded-cautious-update'; - } + last = next; + } - GuardedCautiousUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.cautiousInsert(dom, cursor, value); - }; + next = last = null; + context = pushCtx(context); - return GuardedCautiousUpdateOpcode; - })(GuardedUpdateOpcode); + return ret; + }, - var OptimizedTrustingAppendOpcode = (function (_AppendOpcode3) { - babelHelpers.inherits(OptimizedTrustingAppendOpcode, _AppendOpcode3); + /** + Returns the first item with a property matching the passed value. You + can pass an optional second argument with the target value. Otherwise + this will match any property that evaluates to `true`. + This method works much like the more generic `find()` method. + @method findBy + @param {String} key the property to test + @param {String} [value] optional value to test against. + @return {Object} found item or `undefined` + @public + */ + findBy: function (key, value) { + return this.find(iter.apply(this, arguments)); + }, - function OptimizedTrustingAppendOpcode() { - _AppendOpcode3.apply(this, arguments); - this.type = 'optimized-trusting-append'; - } + /** + Returns `true` if the passed function returns true for every item in the + enumeration. This corresponds with the `every()` method in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` or `false`. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + Example Usage: + ```javascript + if (people.every(isEngineer)) { + Paychecks.addBigBonus(); + } + ``` + @method every + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Boolean} + @public + */ + every: function (callback, target) { + return !this.find(function (x, idx, i) { + return !callback.call(target, x, idx, i); + }); + }, - OptimizedTrustingAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeTrustedValue); - }; + /** + Returns `true` if the passed property resolves to the value of the second + argument for all items in the enumerable. This method is often simpler/faster + than using a callback. + @method isEvery + @param {String} key the property to test + @param {String} [value] optional value to test against. Defaults to `true` + @return {Boolean} + @since 1.3.0 + @public + */ + isEvery: function (key, value) { + return this.every(iter.apply(this, arguments)); + }, - OptimizedTrustingAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + /** + Returns `true` if the passed function returns true for any item in the + enumeration. This corresponds with the `some()` method in JavaScript 1.6. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + Usage Example: + ```javascript + if (people.any(isManager)) { + Paychecks.addBiggerBonus(); + } + ``` + @method any + @param {Function} callback The callback to execute + @param {Object} [target] The target object to use + @return {Boolean} `true` if the passed function returns `true` for any item + @public + */ + any: function (callback, target) { + var len = _emberMetal.get(this, 'length'); + var context = popCtx(); + var found = false; + var last = null; + var next = undefined; - OptimizedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new OptimizedTrustingUpdateOpcode(cache, bounds, upsert); - }; + if (target === undefined) { + target = null; + } - return OptimizedTrustingAppendOpcode; - })(AppendOpcode); + for (var idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); + found = callback.call(target, next, idx, this); + last = next; + } - exports.OptimizedTrustingAppendOpcode = OptimizedTrustingAppendOpcode; + next = last = null; + context = pushCtx(context); + return found; + }, - var OptimizedTrustingUpdateOpcode = (function (_UpdateOpcode3) { - babelHelpers.inherits(OptimizedTrustingUpdateOpcode, _UpdateOpcode3); + /** + Returns `true` if the passed property resolves to the value of the second + argument for any item in 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. Defaults to `true` + @return {Boolean} + @since 1.3.0 + @public + */ + isAny: function (key, value) { + return this.any(iter.apply(this, arguments)); + }, - function OptimizedTrustingUpdateOpcode() { - _UpdateOpcode3.apply(this, arguments); - this.type = 'optimized-trusting-update'; - } + /** + This will combine the values of the enumerator into a single value. It + is a useful way to collect a summary value from an enumeration. This + corresponds to the `reduce()` method defined in JavaScript 1.8. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(previousValue, item, index, enumerable); + ``` + - `previousValue` is the value returned by the last call to the iterator. + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + Return the new cumulative value. + In addition to the callback you can also pass an `initialValue`. An error + will be raised if you do not pass an initial value and the enumerator is + empty. + Note that unlike the other methods, this method does not allow you to + pass a target object to set as this for the callback. It's part of the + spec. Sorry. + @method reduce + @param {Function} callback The callback to execute + @param {Object} initialValue Initial value for the reduce + @param {String} reducerProperty internal use only. + @return {Object} The reduced value. + @public + */ + reduce: function (callback, initialValue, reducerProperty) { + if (typeof callback !== 'function') { + throw new TypeError(); + } - OptimizedTrustingUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + var ret = initialValue; - return OptimizedTrustingUpdateOpcode; - })(UpdateOpcode); + this.forEach(function (item, i) { + ret = callback(ret, item, i, this, reducerProperty); + }, this); - var GuardedTrustingAppendOpcode = (function (_GuardedAppendOpcode2) { - babelHelpers.inherits(GuardedTrustingAppendOpcode, _GuardedAppendOpcode2); + return ret; + }, - function GuardedTrustingAppendOpcode() { - _GuardedAppendOpcode2.apply(this, arguments); - this.type = 'guarded-trusting-append'; - this.AppendOpcode = OptimizedTrustingAppendOpcode; - } + /** + Invokes the named method on every object in the receiver that + implements it. This method corresponds to the implementation in + Prototype 1.6. + @method invoke + @param {String} methodName the name of the method + @param {Object...} args optional arguments to pass as well. + @return {Array} return values from calling invoke. + @public + */ + invoke: function (methodName) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - GuardedTrustingAppendOpcode.prototype.normalize = function normalize(reference) { - return _glimmerReference.map(reference, normalizeTrustedValue); - }; + var ret = emberA(); - GuardedTrustingAppendOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + this.forEach(function (x, idx) { + var method = x && x[methodName]; - GuardedTrustingAppendOpcode.prototype.updateWith = function updateWith(vm, reference, cache, bounds, upsert) { - return new GuardedTrustingUpdateOpcode(reference, cache, bounds, upsert, this, vm.capture()); - }; + if ('function' === typeof method) { + ret[idx] = args ? method.apply(x, args) : x[methodName](); + } + }, this); - return GuardedTrustingAppendOpcode; - })(GuardedAppendOpcode); + return ret; + }, - exports.GuardedTrustingAppendOpcode = GuardedTrustingAppendOpcode; + /** + Simply converts the enumerable into a genuine array. The order is not + guaranteed. Corresponds to the method implemented by Prototype. + @method toArray + @return {Array} the enumerable as an array. + @public + */ + toArray: function () { + var ret = emberA(); - var GuardedTrustingUpdateOpcode = (function (_GuardedUpdateOpcode2) { - babelHelpers.inherits(GuardedTrustingUpdateOpcode, _GuardedUpdateOpcode2); + this.forEach(function (o, idx) { + return ret[idx] = o; + }); - function GuardedTrustingUpdateOpcode() { - _GuardedUpdateOpcode2.apply(this, arguments); - this.type = 'trusting-update'; - } + return ret; + }, - GuardedTrustingUpdateOpcode.prototype.insert = function insert(dom, cursor, value) { - return _glimmerRuntimeLibUpsert.trustingInsert(dom, cursor, value); - }; + /** + Returns a copy of the array with all `null` and `undefined` elements removed. + ```javascript + let arr = ['a', null, 'c', undefined]; + arr.compact(); // ['a', 'c'] + ``` + @method compact + @return {Array} the array without null and undefined elements. + @public + */ + compact: function () { + return this.filter(function (value) { + return value != null; + }); + }, - return GuardedTrustingUpdateOpcode; - })(GuardedUpdateOpcode); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9jb250ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBK0JBLGFBQUEsT0FBQSxDQUFpQixLQUFhLEVBQUE7QUFDNUIsZUFBTyxLQUFLLEtBQUssSUFBSSxJQUFJLEtBQUssS0FBSyxTQUFTLElBQUksT0FBTyxLQUFLLENBQUMsVUFBVSxDQUFDLEtBQUssVUFBVSxDQUFDO0tBQ3pGOztBQUVELGFBQUEsa0JBQUEsQ0FBbUMsS0FBYSxFQUFBO0FBQzlDLFlBQUksT0FBTyxDQUFDLEtBQUssQ0FBQyxFQUFFO0FBQ2xCLG1CQUFPLEVBQUUsQ0FBQztTQUNYO0FBQ0QsZUFBTyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUM7S0FDdEI7O0FBRUQsYUFBQSxxQkFBQSxDQUErQixLQUFhLEVBQUE7QUFDMUMsWUFBSSxPQUFPLENBQUMsS0FBSyxDQUFDLEVBQUU7QUFDbEIsbUJBQU8sRUFBRSxDQUFDO1NBQ1g7QUFDRCxZQUFJLHlCQXZDSixRQUFRLENBdUNLLEtBQUssQ0FBQyxFQUFFO0FBQ25CLG1CQUFPLEtBQUssQ0FBQztTQUNkO0FBQ0QsWUFBSSx5QkE1Q0osWUFBWSxDQTRDSyxLQUFLLENBQUMsRUFBRTtBQUN2QixtQkFBTyxLQUFLLENBQUMsTUFBTSxFQUFFLENBQUM7U0FDdkI7QUFDRCxZQUFJLHlCQTlDSixNQUFNLENBOENLLEtBQUssQ0FBQyxFQUFFO0FBQ2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aW5nSW5zZXJ0KGRvbSwgY3Vyc29yLCB2YWx1ZSk7XG4gIH1cblxuICBwcm90ZWN0ZWQgdXBkYXRlV2l0aCh2bTogVk0sIHJlZmVyZW5jZTogUmVmZXJlbmNlPE9wYXF1ZT4sIGNhY2hlOiBSZWZlcmVuY2VDYWNoZTxUcnVzdGluZ0luc2VydGlvbj4sIGJvdW5kczogRnJhZ21lbnQsIHVwc2VydDogVXBzZXJ0KTogVXBkYXRpbmdPcGNvZGUge1xuICAgIHJldHVybiBuZXcgR3VhcmRlZFRydXN0aW5nVXBkYXRlT3Bjb2RlKHJlZmVyZW5jZSwgY2FjaGUsIGJvdW5kcywgdXBzZXJ0LCB0aGlzLCB2bS5jYXB0dXJlKCkpO1xuICB9XG59XG5cbmNsYXNzIEd1YXJkZWRUcnVzdGluZ1VwZGF0ZU9wY29kZSBleHRlbmRzIEd1YXJkZWRVcGRhdGVPcGNvZGU8VHJ1c3RpbmdJbnNlcnRpb24+IHtcbiAgdHlwZSA9ICd0cnVzdGluZy11cGRhdGUnO1xuXG4gIHByb3RlY3RlZCBpbnNlcnQoZG9tOiBET01UcmVlQ29uc3RydWN0aW9uLCBjdXJzb3I6IEN1cnNvciwgdmFsdWU6IFRydXN0aW5nSW5zZXJ0aW9uKTogVXBzZXJ0IHtcbiAgICByZXR1cm4gdHJ1c3RpbmdJbnNlcnQoZG9tLCBjdXJzb3IsIHZhbHVlKTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/dom', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/compiled/opcodes/vm'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibReferences, _glimmerRuntimeLibCompiledOpcodesVm) { - 'use strict'; + /** + Returns a new enumerable that excludes the passed value. The default + implementation returns an array regardless of the receiver type. + If the receiver does not contain the value it returns the original enumerable. + ```javascript + let arr = ['a', 'b', 'a', 'c']; + arr.without('a'); // ['b', 'c'] + ``` + @method without + @param {Object} value + @return {Ember.Enumerable} + @public + */ + without: function (value) { + if (!this.includes(value)) { + return this; // nothing to do + } - var TextOpcode = (function (_Opcode) { - babelHelpers.inherits(TextOpcode, _Opcode); + var ret = emberA(); - function TextOpcode(text) { - _Opcode.call(this); - this.text = text; - this.type = "text"; + this.forEach(function (k) { + // SameValueZero comparison (NaN !== NaN) + if (!(k === value || k !== k && value !== value)) { + ret[ret.length] = k; } + }); - TextOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().appendText(this.text); - }; - - TextOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.text)] - }; - }; + return ret; + }, - return TextOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Returns a new enumerable that contains only unique values. The default + implementation returns an array regardless of the receiver type. + ```javascript + let arr = ['a', 'a', 'b', 'b']; + arr.uniq(); // ['a', 'b'] + ``` + This only works on primitive data types, e.g. Strings, Numbers, etc. + @method uniq + @return {Ember.Enumerable} + @public + */ + uniq: function () { + var ret = emberA(); - exports.TextOpcode = TextOpcode; + this.forEach(function (k) { + if (ret.indexOf(k) < 0) { + ret.push(k); + } + }); - var OpenPrimitiveElementOpcode = (function (_Opcode2) { - babelHelpers.inherits(OpenPrimitiveElementOpcode, _Opcode2); + return ret; + }, - function OpenPrimitiveElementOpcode(tag) { - _Opcode2.call(this); - this.tag = tag; - this.type = "open-primitive-element"; - } + /** + This property will trigger anytime the enumerable's content changes. + You can observe this property to be notified of changes to the enumerable's + content. + For plain enumerables, this property is read only. `Array` overrides + this method. + @property [] + @type Array + @return this + @private + */ + '[]': _emberMetal.computed({ + get: function (key) { + return this; + } + }), - OpenPrimitiveElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().openElement(this.tag); - }; + // .......................................................... + // ENUMERABLE OBSERVERS + // - OpenPrimitiveElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.tag)] - }; - }; + /** + Registers an enumerable observer. Must implement `Ember.EnumerableObserver` + mixin. + @method addEnumerableObserver + @param {Object} target + @param {Object} [opts] + @return this + @private + */ + addEnumerableObserver: function (target, opts) { + var willChange = opts && opts.willChange || 'enumerableWillChange'; + var didChange = opts && opts.didChange || 'enumerableDidChange'; + var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); - return OpenPrimitiveElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (!hasObservers) { + _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); + } - exports.OpenPrimitiveElementOpcode = OpenPrimitiveElementOpcode; + _emberMetal.addListener(this, '@enumerable:before', target, willChange); + _emberMetal.addListener(this, '@enumerable:change', target, didChange); - var PushRemoteElementOpcode = (function (_Opcode3) { - babelHelpers.inherits(PushRemoteElementOpcode, _Opcode3); + if (!hasObservers) { + _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); + } - function PushRemoteElementOpcode() { - _Opcode3.apply(this, arguments); - this.type = "push-remote-element"; - } + return this; + }, - PushRemoteElementOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getOperand(); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var element = cache ? cache.peek() : reference.value(); - vm.stack().pushRemoteElement(element); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; + /** + Removes a registered enumerable observer. + @method removeEnumerableObserver + @param {Object} target + @param {Object} [opts] + @return this + @private + */ + removeEnumerableObserver: function (target, opts) { + var willChange = opts && opts.willChange || 'enumerableWillChange'; + var didChange = opts && opts.didChange || 'enumerableDidChange'; + var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers'); - PushRemoteElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ['$OPERAND'] - }; - }; + if (hasObservers) { + _emberMetal.propertyWillChange(this, 'hasEnumerableObservers'); + } - return PushRemoteElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberMetal.removeListener(this, '@enumerable:before', target, willChange); + _emberMetal.removeListener(this, '@enumerable:change', target, didChange); - exports.PushRemoteElementOpcode = PushRemoteElementOpcode; + if (hasObservers) { + _emberMetal.propertyDidChange(this, 'hasEnumerableObservers'); + } - var PopRemoteElementOpcode = (function (_Opcode4) { - babelHelpers.inherits(PopRemoteElementOpcode, _Opcode4); + return this; + }, - function PopRemoteElementOpcode() { - _Opcode4.apply(this, arguments); - this.type = "pop-remote-element"; - } + /** + Becomes true whenever the array currently has observers watching changes + on the array. + @property hasEnumerableObservers + @type Boolean + @private + */ + hasEnumerableObservers: _emberMetal.computed(function () { + return _emberMetal.hasListeners(this, '@enumerable:change') || _emberMetal.hasListeners(this, '@enumerable:before'); + }), - PopRemoteElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().popRemoteElement(); - }; + /** + Invoke this method just before the contents of your enumerable will + change. You can either omit the parameters completely or pass the objects + to be removed or added if available or just a count. + @method enumerableContentWillChange + @param {Ember.Enumerable|Number} removing An enumerable of the objects to + be removed or the number of items to be removed. + @param {Ember.Enumerable|Number} adding An enumerable of the objects to be + added or the number of items to be added. + @chainable + @private + */ + enumerableContentWillChange: function (removing, adding) { + var removeCnt = undefined, + addCnt = undefined, + hasDelta = undefined; - return PopRemoteElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if ('number' === typeof removing) { + removeCnt = removing; + } else if (removing) { + removeCnt = _emberMetal.get(removing, 'length'); + } else { + removeCnt = removing = -1; + } - exports.PopRemoteElementOpcode = PopRemoteElementOpcode; + if ('number' === typeof adding) { + addCnt = adding; + } else if (adding) { + addCnt = _emberMetal.get(adding, 'length'); + } else { + addCnt = adding = -1; + } - var OpenComponentElementOpcode = (function (_Opcode5) { - babelHelpers.inherits(OpenComponentElementOpcode, _Opcode5); + hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; - function OpenComponentElementOpcode(tag) { - _Opcode5.call(this); - this.tag = tag; - this.type = "open-component-element"; - } + if (removing === -1) { + removing = null; + } - OpenComponentElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().openElement(this.tag, new ComponentElementOperations(vm.env)); - }; + if (adding === -1) { + adding = null; + } - OpenComponentElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.tag)] - }; - }; + _emberMetal.propertyWillChange(this, '[]'); - return OpenComponentElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (hasDelta) { + _emberMetal.propertyWillChange(this, 'length'); + } - exports.OpenComponentElementOpcode = OpenComponentElementOpcode; + _emberMetal.sendEvent(this, '@enumerable:before', [this, removing, adding]); - var OpenDynamicPrimitiveElementOpcode = (function (_Opcode6) { - babelHelpers.inherits(OpenDynamicPrimitiveElementOpcode, _Opcode6); + return this; + }, - function OpenDynamicPrimitiveElementOpcode() { - _Opcode6.apply(this, arguments); - this.type = "open-dynamic-primitive-element"; - } + /** + Invoke this method when the contents of your enumerable has changed. + This will notify any observers watching for content changes. If you are + implementing an ordered enumerable (such as an array), also pass the + start and end values where the content changed so that it can be used to + notify range observers. + @method enumerableContentDidChange + @param {Ember.Enumerable|Number} removing An enumerable of the objects to + be removed or the number of items to be removed. + @param {Ember.Enumerable|Number} adding An enumerable of the objects to + be added or the number of items to be added. + @chainable + @private + */ + enumerableContentDidChange: function (removing, adding) { + var removeCnt = undefined, + addCnt = undefined, + hasDelta = undefined; - OpenDynamicPrimitiveElementOpcode.prototype.evaluate = function evaluate(vm) { - var tagName = vm.frame.getOperand().value(); - vm.stack().openElement(tagName); - }; + if ('number' === typeof removing) { + removeCnt = removing; + } else if (removing) { + removeCnt = _emberMetal.get(removing, 'length'); + } else { + removeCnt = removing = -1; + } - OpenDynamicPrimitiveElementOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + if ('number' === typeof adding) { + addCnt = adding; + } else if (adding) { + addCnt = _emberMetal.get(adding, 'length'); + } else { + addCnt = adding = -1; + } - return OpenDynamicPrimitiveElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0; - exports.OpenDynamicPrimitiveElementOpcode = OpenDynamicPrimitiveElementOpcode; + if (removing === -1) { + removing = null; + } - var ClassList = (function () { - function ClassList() { - this.list = null; - this.isConst = true; - } + if (adding === -1) { + adding = null; + } - ClassList.prototype.append = function append(reference) { - var list = this.list; - var isConst = this.isConst; + _emberMetal.sendEvent(this, '@enumerable:change', [this, removing, adding]); - if (list === null) list = this.list = []; - list.push(reference); - this.isConst = isConst && _glimmerReference.isConst(reference); - }; + if (hasDelta) { + _emberMetal.propertyDidChange(this, 'length'); + } - ClassList.prototype.toReference = function toReference() { - var list = this.list; - var isConst = this.isConst; + _emberMetal.propertyDidChange(this, '[]'); - if (!list) return _glimmerRuntimeLibReferences.NULL_REFERENCE; - if (isConst) return _glimmerRuntimeLibReferences.PrimitiveReference.create(toClassName(list)); - return new ClassListReference(list); - }; + return this; + }, - return ClassList; - })(); + /** + Converts the enumerable into an array and sorts by the keys + specified in the argument. + You may provide multiple arguments to sort by multiple properties. + @method sortBy + @param {String} property name(s) to sort on + @return {Array} The sorted array. + @since 1.2.0 + @public + */ + sortBy: function () { + var sortKeys = arguments; - var ClassListReference = (function (_CachedReference) { - babelHelpers.inherits(ClassListReference, _CachedReference); + return this.toArray().sort(function (a, b) { + for (var i = 0; i < sortKeys.length; i++) { + var key = sortKeys[i]; + var propA = _emberMetal.get(a, key); + var propB = _emberMetal.get(b, key); + // return 1 or -1 else continue to the next sortKey + var compareValue = _emberRuntimeCompare.default(propA, propB); - function ClassListReference(list) { - _CachedReference.call(this); - this.list = []; - this.tag = _glimmerReference.combineTagged(list); - this.list = list; + if (compareValue) { + return compareValue; + } } + return 0; + }); + }, - ClassListReference.prototype.compute = function compute() { - return toClassName(this.list); - }; - - return ClassListReference; - })(_glimmerReference.CachedReference); + /** + Returns a new enumerable that contains only items containing a unique property value. + The default implementation returns an array regardless of the receiver type. + ```javascript + let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; + arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] + ``` + @method uniqBy + @return {Ember.Enumerable} + @public + */ - function toClassName(list) { - var ret = []; - for (var i = 0; i < list.length; i++) { - var value = list[i].value(); - if (value !== false && value !== null && value !== undefined) ret.push(value); - } - return ret.length === 0 ? null : ret.join(' '); - } + uniqBy: function (key) { + var ret = emberA(); + var seen = new _emberUtils.EmptyObject(); - var SimpleElementOperations = (function () { - function SimpleElementOperations(env) { - this.env = env; - this.opcodes = null; - this.classList = null; + this.forEach(function (item) { + var guid = _emberUtils.guidFor(_emberMetal.get(item, key)); + if (!(guid in seen)) { + seen[guid] = true; + ret.push(item); } + }); - SimpleElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element, name, value) { - if (name === 'class') { - this.addClass(_glimmerRuntimeLibReferences.PrimitiveReference.create(value)); - } else { - this.env.getAppendOperations().setAttribute(element, name, value); - } - }; + return ret; + }, - SimpleElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element, namespace, name, value) { - this.env.getAppendOperations().setAttribute(element, name, value, namespace); - }; + /** + Returns `true` if the passed object can be found in the enumerable. + ```javascript + [1, 2, 3].includes(2); // true + [1, 2, 3].includes(4); // false + [1, 2, undefined].includes(undefined); // true + [1, 2, null].includes(null); // true + [1, 2, NaN].includes(NaN); // true + ``` + @method includes + @param {Object} obj The object to search for. + @return {Boolean} `true` if object is found in the enumerable. + @public + */ + includes: function (obj) { - SimpleElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element, name, reference, isTrusting) { - if (name === 'class') { - this.addClass(reference); - } else { - var attributeManager = this.env.attributeFor(element, name, isTrusting); - var attribute = new DynamicAttribute(element, attributeManager, name, reference); - this.addAttribute(attribute); - } - }; + var len = _emberMetal.get(this, 'length'); + var idx = undefined, + next = undefined; + var last = null; + var found = false; - SimpleElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element, namespace, name, reference, isTrusting) { - var attributeManager = this.env.attributeFor(element, name, isTrusting, namespace); - var nsAttribute = new DynamicAttribute(element, attributeManager, name, reference, namespace); - this.addAttribute(nsAttribute); - }; + var context = popCtx(); - SimpleElementOperations.prototype.flush = function flush(element, vm) { - var env = vm.env; - var opcodes = this.opcodes; - var classList = this.classList; + for (idx = 0; idx < len && !found; idx++) { + next = this.nextObject(idx, last, context); - for (var i = 0; opcodes && i < opcodes.length; i++) { - vm.updateWith(opcodes[i]); - } - if (classList) { - var attributeManager = env.attributeFor(element, 'class', false); - var attribute = new DynamicAttribute(element, attributeManager, 'class', classList.toReference()); - var opcode = attribute.flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - this.opcodes = null; - this.classList = null; - }; + found = obj === next || obj !== obj && next !== next; - SimpleElementOperations.prototype.addClass = function addClass(reference) { - var classList = this.classList; + last = next; + } - if (!classList) { - classList = this.classList = new ClassList(); - } - classList.append(reference); - }; + next = last = null; + context = pushCtx(context); - SimpleElementOperations.prototype.addAttribute = function addAttribute(attribute) { - var opcode = attribute.flush(this.env); - if (opcode) { - var opcodes = this.opcodes; + return found; + } + }); - if (!opcodes) { - opcodes = this.opcodes = []; - } - opcodes.push(opcode); - } - }; + exports.default = Enumerable; +}); +enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - return SimpleElementOperations; - })(); + /** + @module ember + @submodule ember-runtime + */ - exports.SimpleElementOperations = SimpleElementOperations; + /** + This mixin allows for Ember objects to subscribe to and emit events. + + ```javascript + App.Person = Ember.Object.extend(Ember.Evented, { + greet: function() { + // ... + this.trigger('greet'); + } + }); + + var person = App.Person.create(); + + person.on('greet', function() { + console.log('Our person has greeted'); + }); + + person.greet(); + + // outputs: 'Our person has greeted' + ``` + + You can also chain multiple event subscriptions: + + ```javascript + person.on('greet', function() { + console.log('Our person has greeted'); + }).one('greet', function() { + console.log('Offer one-time special'); + }).off('event', this, forgetThis); + ``` + + @class Evented + @namespace Ember + @public + */ + exports.default = _emberMetal.Mixin.create({ - var ComponentElementOperations = (function () { - function ComponentElementOperations(env) { - this.env = env; - this.attributeNames = null; - this.attributes = null; - this.classList = null; - } + /** + Subscribes to a named event with given function. + ```javascript + person.on('didLoad', function() { + // fired once the person has loaded + }); + ``` + An optional target can be passed in as the 2nd argument that will + be set as the "this" for the callback. This is a good way to give your + function access to the object triggering the event. When the target + parameter is used the callback becomes the third argument. + @method on + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute + @return this + @public + */ + on: function (name, target, method) { + _emberMetal.addListener(this, name, target, method); + return this; + }, - ComponentElementOperations.prototype.addStaticAttribute = function addStaticAttribute(element, name, value) { - if (name === 'class') { - this.addClass(_glimmerRuntimeLibReferences.PrimitiveReference.create(value)); - } else if (this.shouldAddAttribute(name)) { - this.addAttribute(name, new StaticAttribute(element, name, value)); - } - }; + /** + Subscribes a function to a named event and then cancels the subscription + after the first time the event is triggered. It is good to use ``one`` when + you only care about the first time an event has taken place. + This function takes an optional 2nd argument that will become the "this" + value for the callback. If this argument is passed then the 3rd argument + becomes the function. + @method one + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute + @return this + @public + */ + one: function (name, target, method) { + if (!method) { + method = target; + target = null; + } - ComponentElementOperations.prototype.addStaticAttributeNS = function addStaticAttributeNS(element, namespace, name, value) { - if (this.shouldAddAttribute(name)) { - this.addAttribute(name, new StaticAttribute(element, name, value, namespace)); - } - }; + _emberMetal.addListener(this, name, target, method, true); + return this; + }, - ComponentElementOperations.prototype.addDynamicAttribute = function addDynamicAttribute(element, name, reference, isTrusting) { - if (name === 'class') { - this.addClass(reference); - } else if (this.shouldAddAttribute(name)) { - var attributeManager = this.env.attributeFor(element, name, isTrusting); - var attribute = new DynamicAttribute(element, attributeManager, name, reference); - this.addAttribute(name, attribute); - } - }; + /** + Triggers a named event for the object. Any additional arguments + will be passed as parameters to the functions that are subscribed to the + event. + ```javascript + person.on('didEat', function(food) { + console.log('person ate some ' + food); + }); + person.trigger('didEat', 'broccoli'); + // outputs: person ate some broccoli + ``` + @method trigger + @param {String} name The name of the event + @param {Object...} args Optional arguments to pass on + @public + */ + trigger: function (name) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - ComponentElementOperations.prototype.addDynamicAttributeNS = function addDynamicAttributeNS(element, namespace, name, reference, isTrusting) { - if (this.shouldAddAttribute(name)) { - var attributeManager = this.env.attributeFor(element, name, isTrusting, namespace); - var nsAttribute = new DynamicAttribute(element, attributeManager, name, reference, namespace); - this.addAttribute(name, nsAttribute); - } - }; + _emberMetal.sendEvent(this, name, args); + }, - ComponentElementOperations.prototype.flush = function flush(element, vm) { - var env = this.env; - var attributes = this.attributes; - var classList = this.classList; + /** + Cancels subscription for given name, target, and method. + @method off + @param {String} name The name of the event + @param {Object} target The target of the subscription + @param {Function} method The function of the subscription + @return this + @public + */ + off: function (name, target, method) { + _emberMetal.removeListener(this, name, target, method); + return this; + }, - for (var i = 0; attributes && i < attributes.length; i++) { - var opcode = attributes[i].flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - if (classList) { - var attributeManager = env.attributeFor(element, 'class', false); - var attribute = new DynamicAttribute(element, attributeManager, 'class', classList.toReference()); - var opcode = attribute.flush(env); - if (opcode) { - vm.updateWith(opcode); - } - } - }; + /** + Checks to see if object has any subscriptions for named event. + @method has + @param {String} name The name of the event + @return {Boolean} does the object have a subscription for event + @public + */ + has: function (name) { + return _emberMetal.hasListeners(this, name); + } + }); +}); +enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - ComponentElementOperations.prototype.shouldAddAttribute = function shouldAddAttribute(name) { - return !this.attributeNames || this.attributeNames.indexOf(name) === -1; - }; + 'use strict'; - ComponentElementOperations.prototype.addClass = function addClass(reference) { - var classList = this.classList; + /** + The `Ember.Freezable` mixin implements some basic methods for marking an + object as frozen. Once an object is frozen it should be read only. No changes + may be made the internal state of the object. + + ## Enforcement + + To fully support freezing in your subclass, you must include this mixin and + override any method that might alter any property on the object to instead + raise an exception. You can check the state of an object by checking the + `isFrozen` property. + + Although future versions of JavaScript may support language-level freezing + object objects, that is not the case today. Even if an object is freezable, + it is still technically possible to modify the object, even though it could + break other parts of your application that do not expect a frozen object to + change. It is, therefore, very important that you always respect the + `isFrozen` property on all freezable objects. + + ## Example Usage + + The example below shows a simple object that implement the `Ember.Freezable` + protocol. + + ```javascript + Contact = Ember.Object.extend(Ember.Freezable, { + firstName: null, + lastName: null, + + // swaps the names + swapNames: function() { + if (this.get('isFrozen')) throw Ember.FROZEN_ERROR; + var tmp = this.get('firstName'); + this.set('firstName', this.get('lastName')); + this.set('lastName', tmp); + return this; + } + + }); + + c = Contact.create({ firstName: "John", lastName: "Doe" }); + c.swapNames(); // returns c + c.freeze(); + c.swapNames(); // EXCEPTION + ``` + + ## Copying + + Usually the `Ember.Freezable` protocol is implemented in cooperation with the + `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will + return a frozen object, if the object implements this method as well. + + @class Freezable + @namespace Ember + @since Ember 0.9 + @deprecated Use `Object.freeze` instead. + @private + */ + var Freezable = _emberMetal.Mixin.create({ - if (!classList) { - classList = this.classList = new ClassList(); - } - classList.append(reference); - }; + init: function () { + this._super.apply(this, arguments); + }, - ComponentElementOperations.prototype.addAttribute = function addAttribute(name, attribute) { - var attributeNames = this.attributeNames; - var attributes = this.attributes; + /** + Set to `true` when the object is frozen. Use this property to detect + whether your object is frozen or not. + @property isFrozen + @type Boolean + @private + */ + isFrozen: false, - if (!attributeNames) { - attributeNames = this.attributeNames = []; - attributes = this.attributes = []; - } - attributeNames.push(name); - attributes.push(attribute); - }; + /** + Freezes the object. Once this method has been called the object should + no longer allow any properties to be edited. + @method freeze + @return {Object} receiver + @private + */ + freeze: function () { + if (_emberMetal.get(this, 'isFrozen')) { + return this; + } - return ComponentElementOperations; - })(); + _emberMetal.set(this, 'isFrozen', true); + return this; + } - exports.ComponentElementOperations = ComponentElementOperations; + }); - var FlushElementOpcode = (function (_Opcode7) { - babelHelpers.inherits(FlushElementOpcode, _Opcode7); + exports.Freezable = Freezable; + var FROZEN_ERROR = 'Frozen object cannot be modified.'; + exports.FROZEN_ERROR = FROZEN_ERROR; +}); +enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable'], function (exports, _emberMetal, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable) { + /** + @module ember + @submodule ember-runtime + */ - function FlushElementOpcode() { - _Opcode7.apply(this, arguments); - this.type = "flush-element"; - } + 'use strict'; - FlushElementOpcode.prototype.evaluate = function evaluate(vm) { - var stack = vm.stack(); - stack.operations.flush(stack.constructing, vm); - stack.flushElement(); - }; + exports.removeAt = removeAt; + var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; + var EMPTY = []; - return FlushElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + // .......................................................... + // HELPERS + // - exports.FlushElementOpcode = FlushElementOpcode; + function removeAt(array, start, len) { + if ('number' === typeof start) { + if (start < 0 || start >= _emberMetal.get(array, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - var CloseElementOpcode = (function (_Opcode8) { - babelHelpers.inherits(CloseElementOpcode, _Opcode8); + // fast case + if (len === undefined) { + len = 1; + } - function CloseElementOpcode() { - _Opcode8.apply(this, arguments); - this.type = "close-element"; - } + array.replace(start, len, EMPTY); + } - CloseElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().closeElement(); - }; + return array; + } - return CloseElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + This mixin defines the API for modifying array-like objects. These methods + can be applied only to a collection that keeps its items in an ordered set. + It builds upon the Array mixin and adds methods to modify the array. + One concrete implementations of this class include ArrayProxy. + + It is important to use the methods in this class to modify arrays so that + changes are observable. This allows the binding system in Ember to function + correctly. + + + Note that an Array can change even if it does not implement this mixin. + For example, one might implement a SparseArray that cannot be directly + modified, but if its underlying enumerable changes, it will change also. + + @class MutableArray + @namespace Ember + @uses Ember.Array + @uses Ember.MutableEnumerable + @public + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, { - exports.CloseElementOpcode = CloseElementOpcode; + /** + __Required.__ You must implement this method to apply this mixin. + This is one of the primitives you must implement to support `Ember.Array`. + You should replace amt objects started at idx with the objects in the + passed array. You should also call `this.enumerableContentDidChange()` + @method replace + @param {Number} idx Starting index in the array to replace. If + idx >= length, then append to the end of the array. + @param {Number} amt Number of elements that should be removed from + the array, starting at *idx*. + @param {Array} objects An array of zero or more objects that should be + inserted into the array at *idx* + @public + */ + replace: null, - var PopElementOpcode = (function (_Opcode9) { - babelHelpers.inherits(PopElementOpcode, _Opcode9); + /** + Remove all elements from the array. This is useful if you + want to reuse an existing array without having to recreate it. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.length; // 3 + colors.clear(); // [] + colors.length; // 0 + ``` + @method clear + @return {Ember.Array} An empty Array. + @public + */ + clear: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return this; + } - function PopElementOpcode() { - _Opcode9.apply(this, arguments); - this.type = "pop-element"; - } + this.replace(0, len, EMPTY); + return this; + }, - PopElementOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().popElement(); - }; + /** + This will use the primitive `replace()` method to insert an object at the + specified index. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue'] + colors.insertAt(5, 'orange'); // Error: Index out of range + ``` + @method insertAt + @param {Number} idx index of insert the object at. + @param {Object} object object to insert + @return {Ember.Array} receiver + @public + */ + insertAt: function (idx, object) { + if (idx > _emberMetal.get(this, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - return PopElementOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + this.replace(idx, 0, [object]); + return this; + }, - exports.PopElementOpcode = PopElementOpcode; + /** + Remove an object at the specified index using the `replace()` primitive + method. You can pass either a single index, or a start and a length. + If you pass a start and length that is beyond the + length this method will throw an `OUT_OF_RANGE_EXCEPTION`. + ```javascript + let colors = ['red', 'green', 'blue', 'yellow', 'orange']; + colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] + colors.removeAt(2, 2); // ['green', 'blue'] + colors.removeAt(4, 2); // Error: Index out of range + ``` + @method removeAt + @param {Number} start index, start of range + @param {Number} len length of passing range + @return {Ember.Array} receiver + @public + */ + removeAt: function (start, len) { + return removeAt(this, start, len); + }, - var StaticAttrOpcode = (function (_Opcode10) { - babelHelpers.inherits(StaticAttrOpcode, _Opcode10); + /** + Push the object onto the end of the array. Works just like `push()` but it + is KVO-compliant. + ```javascript + let colors = ['red', 'green']; + colors.pushObject('black'); // ['red', 'green', 'black'] + colors.pushObject(['yellow']); // ['red', 'green', ['yellow']] + ``` + @method pushObject + @param {*} obj object to push + @return object same object passed as a param + @public + */ + pushObject: function (obj) { + this.insertAt(_emberMetal.get(this, 'length'), obj); + return obj; + }, - function StaticAttrOpcode(namespace, name, value) { - _Opcode10.call(this); - this.namespace = namespace; - this.name = name; - this.value = value; - this.type = "static-attr"; - } + /** + Add the objects in the passed numerable to the end of the array. Defers + notifying observers of the change until all objects are added. + ```javascript + let colors = ['red']; + colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange'] + ``` + @method pushObjects + @param {Ember.Enumerable} objects the objects to add + @return {Ember.Array} receiver + @public + */ + pushObjects: function (objects) { + if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || Array.isArray(objects))) { + throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + } + this.replace(_emberMetal.get(this, 'length'), 0, objects); + return this; + }, - StaticAttrOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var value = this.value; - var namespace = this.namespace; + /** + Pop object from array or nil if none are left. Works just like `pop()` but + it is KVO-compliant. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.popObject(); // 'blue' + console.log(colors); // ['red', 'green'] + ``` + @method popObject + @return object + @public + */ + popObject: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return null; + } - if (namespace) { - vm.stack().setStaticAttributeNS(namespace, name, value); - } else { - vm.stack().setStaticAttribute(name, value); - } - }; + var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1); + this.removeAt(len - 1, 1); + return ret; + }, - StaticAttrOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var namespace = this.namespace; - var name = this.name; - var value = this.value; + /** + Shift an object from start of array or nil if none are left. Works just + like `shift()` but it is KVO-compliant. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.shiftObject(); // 'red' + console.log(colors); // ['green', 'blue'] + ``` + @method shiftObject + @return object + @public + */ + shiftObject: function () { + if (_emberMetal.get(this, 'length') === 0) { + return null; + } - var details = _glimmerUtil.dict(); - if (namespace) { - details["namespace"] = JSON.stringify(namespace); - } - details["name"] = JSON.stringify(name); - details["value"] = JSON.stringify(value); - return { guid: guid, type: type, details: details }; - }; + var ret = _emberRuntimeMixinsArray.objectAt(this, 0); + this.removeAt(0); + return ret; + }, - return StaticAttrOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Unshift an object to start of array. Works just like `unshift()` but it is + KVO-compliant. + ```javascript + let colors = ['red']; + colors.unshiftObject('yellow'); // ['yellow', 'red'] + colors.unshiftObject(['black']); // [['black'], 'yellow', 'red'] + ``` + @method unshiftObject + @param {*} obj object to unshift + @return object same object passed as a param + @public + */ + unshiftObject: function (obj) { + this.insertAt(0, obj); + return obj; + }, - exports.StaticAttrOpcode = StaticAttrOpcode; + /** + Adds the named objects to the beginning of the array. Defers notifying + observers until all objects have been added. + ```javascript + let colors = ['red']; + colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red'] + colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function + ``` + @method unshiftObjects + @param {Ember.Enumerable} objects the objects to add + @return {Ember.Array} receiver + @public + */ + unshiftObjects: function (objects) { + this.replace(0, 0, objects); + return this; + }, - var ModifierOpcode = (function (_Opcode11) { - babelHelpers.inherits(ModifierOpcode, _Opcode11); + /** + Reverse objects in the array. Works just like `reverse()` but it is + KVO-compliant. + @method reverseObjects + @return {Ember.Array} receiver + @public + */ + reverseObjects: function () { + var len = _emberMetal.get(this, 'length'); + if (len === 0) { + return this; + } - function ModifierOpcode(name, manager, args) { - _Opcode11.call(this); - this.name = name; - this.manager = manager; - this.args = args; - this.type = "modifier"; - } + var objects = this.toArray().reverse(); + this.replace(0, len, objects); + return this; + }, - ModifierOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; + /** + Replace all the receiver's content with content of the argument. + If argument is an empty array receiver will be cleared. + ```javascript + let colors = ['red', 'green', 'blue']; + colors.setObjects(['black', 'white']); // ['black', 'white'] + colors.setObjects([]); // [] + ``` + @method setObjects + @param {Ember.Array} objects array whose content will be used for replacing + the content of the receiver + @return {Ember.Array} receiver with the new content + @public + */ + setObjects: function (objects) { + if (objects.length === 0) { + return this.clear(); + } - var stack = vm.stack(); - var element = stack.constructing; - var updateOperations = stack.updateOperations; + var len = _emberMetal.get(this, 'length'); + this.replace(0, len, objects); + return this; + }, - var args = this.args.evaluate(vm); - var dynamicScope = vm.dynamicScope(); - var modifier = manager.create(element, args, dynamicScope, updateOperations); - vm.env.scheduleInstallModifier(modifier, manager); - var destructor = manager.getDestructor(modifier); - if (destructor) { - vm.newDestroyable(destructor); - } - vm.updateWith(new UpdateModifierOpcode(manager, modifier, args)); - }; + // .......................................................... + // IMPLEMENT Ember.MutableEnumerable + // - ModifierOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; - var args = this.args; - - var details = _glimmerUtil.dict(); - details["type"] = JSON.stringify(type); - details["name"] = JSON.stringify(name); - details["args"] = JSON.stringify(args); - return { guid: guid, type: type, details: details }; - }; + /** + Remove all occurrences of an object in the array. + ```javascript + let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; + cities.removeObject('Chicago'); // ['Berlin', 'Lima'] + cities.removeObject('Lima'); // ['Berlin'] + cities.removeObject('Tokyo') // ['Berlin'] + ``` + @method removeObject + @param {*} obj object to remove + @return {Ember.Array} receiver + @public + */ + removeObject: function (obj) { + var loc = _emberMetal.get(this, 'length') || 0; + while (--loc >= 0) { + var curObject = _emberRuntimeMixinsArray.objectAt(this, loc); - return ModifierOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (curObject === obj) { + this.removeAt(loc); + } + } + return this; + }, - exports.ModifierOpcode = ModifierOpcode; + /** + Push the object onto the end of the array if it is not already + present in the array. + ```javascript + let cities = ['Chicago', 'Berlin']; + cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] + cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] + ``` + @method addObject + @param {*} obj object to add, if not already present + @return {Ember.Array} receiver + @public + */ + addObject: function (obj) { + var included = this.includes(obj); - var UpdateModifierOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(UpdateModifierOpcode, _UpdatingOpcode); + if (!included) { + this.pushObject(obj); + } - function UpdateModifierOpcode(manager, modifier, args) { - _UpdatingOpcode.call(this); - this.manager = manager; - this.modifier = modifier; - this.args = args; - this.type = "update-modifier"; - this.tag = args.tag; - this.lastUpdated = args.tag.value(); - } + return this; + } + }); +}); +enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetal) { + 'use strict'; - UpdateModifierOpcode.prototype.evaluate = function evaluate(vm) { - var manager = this.manager; - var modifier = this.modifier; - var tag = this.tag; - var lastUpdated = this.lastUpdated; + /** + @module ember + @submodule ember-runtime + */ - if (!tag.validate(lastUpdated)) { - vm.env.scheduleUpdateModifier(modifier, manager); - this.lastUpdated = tag.value(); - } - }; + /** + This mixin defines the API for modifying generic enumerables. These methods + can be applied to an object regardless of whether it is ordered or + unordered. + + Note that an Enumerable can change even if it does not implement this mixin. + For example, a MappedEnumerable cannot be directly modified but if its + underlying enumerable changes, it will change also. + + ## Adding Objects + + To add an object to an enumerable, use the `addObject()` method. This + method will only add the object to the enumerable if the object is not + already present and is of a type supported by the enumerable. + + ```javascript + set.addObject(contact); + ``` + + ## Removing Objects + + To remove an object from an enumerable, use the `removeObject()` method. This + will only remove the object if it is present in the enumerable, otherwise + this method has no effect. + + ```javascript + set.removeObject(contact); + ``` + + ## Implementing In Your Own Code + + If you are implementing an object and want to support this API, just include + this mixin in your class and implement the required methods. In your unit + tests, be sure to apply the Ember.MutableEnumerableTests to your object. + + @class MutableEnumerable + @namespace Ember + @uses Ember.Enumerable + @public + */ + exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, { - UpdateModifierOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.args)] - }; - }; + /** + __Required.__ You must implement this method to apply this mixin. + Attempts to add the passed object to the receiver if the object is not + already present in the collection. If the object is present, this method + has no effect. + If the passed object is of a type not supported by the receiver, + then this method should raise an exception. + @method addObject + @param {Object} object The object to add to the enumerable. + @return {Object} the passed object + @public + */ + addObject: null, - return UpdateModifierOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + Adds each object in the passed enumerable to the receiver. + @method addObjects + @param {Ember.Enumerable} objects the objects to add. + @return {Object} receiver + @public + */ + addObjects: function (objects) { + var _this = this; - exports.UpdateModifierOpcode = UpdateModifierOpcode; + _emberMetal.beginPropertyChanges(this); + objects.forEach(function (obj) { + return _this.addObject(obj); + }); + _emberMetal.endPropertyChanges(this); + return this; + }, - var StaticAttribute = (function () { - function StaticAttribute(element, name, value, namespace) { - this.element = element; - this.name = name; - this.value = value; - this.namespace = namespace; - } + /** + __Required.__ You must implement this method to apply this mixin. + Attempts to remove the passed object from the receiver collection if the + object is present in the collection. If the object is not present, + this method has no effect. + If the passed object is of a type not supported by the receiver, + then this method should raise an exception. + @method removeObject + @param {Object} object The object to remove from the enumerable. + @return {Object} the passed object + @public + */ + removeObject: null, - StaticAttribute.prototype.flush = function flush(env) { - env.getAppendOperations().setAttribute(this.element, this.name, this.value, this.namespace); - return null; - }; + /** + Removes each object in the passed enumerable from the receiver. + @method removeObjects + @param {Ember.Enumerable} objects the objects to remove + @return {Object} receiver + @public + */ + removeObjects: function (objects) { + _emberMetal.beginPropertyChanges(this); + for (var i = objects.length - 1; i >= 0; i--) { + this.removeObject(objects[i]); + } + _emberMetal.endPropertyChanges(this); + return this; + } + }); +}); +enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - return StaticAttribute; - })(); + 'use strict'; - exports.StaticAttribute = StaticAttribute; + /** + ## Overview + + This mixin provides properties and property observing functionality, core + features of the Ember object model. + + Properties and observers allow one object to observe changes to a + property on another object. This is one of the fundamental ways that + models, controllers and views communicate with each other in an Ember + application. + + Any object that has this mixin applied can be used in observer + operations. That includes `Ember.Object` and most objects you will + interact with as you write your Ember application. + + Note that you will not generally apply this mixin to classes yourself, + but you will use the features provided by this module frequently, so it + is important to understand how to use it. + + ## Using `get()` and `set()` + + Because of Ember's support for bindings and observers, you will always + access properties using the get method, and set properties using the + set method. This allows the observing objects to be notified and + computed properties to be handled properly. + + More documentation about `get` and `set` are below. + + ## Observing Property Changes + + 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) { + // Executes whenever the "value" property changes + // See the addObserver method for more information about the callback arguments + }) + }); + ``` + + Although this is the most common way to add an observer, this capability + is actually built into the `Ember.Object` class on top of two methods + defined in this mixin: `addObserver` and `removeObserver`. You can use + these two methods to add and remove observers yourself if you need to + do so at runtime. + + To add an observer for a property, call: + + ```javascript + object.addObserver('propertyKey', targetObject, targetAction) + ``` + + This will call the `targetAction` method on the `targetObject` whenever + the value of the `propertyKey` changes. + + Note that if `propertyKey` is a computed property, the observer will be + called when any of the property dependencies are changed, even if the + resulting value of the computed property is unchanged. This is necessary + because computed properties are not computed until `get` is called. + + @class Observable + @namespace Ember + @public + */ + exports.default = _emberMetal.Mixin.create({ - var DynamicAttribute = (function () { - function DynamicAttribute(element, attributeManager, name, reference, namespace) { - this.element = element; - this.attributeManager = attributeManager; - this.name = name; - this.reference = reference; - this.namespace = namespace; - this.tag = reference.tag; - this.cache = null; - } + /** + Retrieves the value of a property from the object. + This method is usually similar to using `object[keyName]` or `object.keyName`, + however it supports both computed properties and the unknownProperty + handler. + Because `get` unifies the syntax for accessing all these kinds + of properties, it can make many refactorings easier, such as replacing a + simple property with a computed property, or vice versa. + ### Computed Properties + Computed properties are methods defined with the `property` modifier + declared at the end, such as: + ```javascript + fullName: Ember.computed('firstName', 'lastName', function() { + return this.get('firstName') + ' ' + this.get('lastName'); + }) + ``` + When you call `get` on a computed property, the function will be + called and the return value will be returned instead of the function + itself. + ### Unknown Properties + Likewise, if you try to call `get` on a property whose value is + `undefined`, the `unknownProperty()` method will be called on the object. + If this method returns any value other than `undefined`, it will be returned + instead. This allows you to implement "virtual" properties that are + not defined upfront. + @method get + @param {String} keyName The property to retrieve + @return {Object} The property value or undefined. + @public + */ + get: function (keyName) { + return _emberMetal.get(this, keyName); + }, - DynamicAttribute.prototype.patch = function patch(env) { - var element = this.element; - var cache = this.cache; + /** + To get the values of multiple properties at once, call `getProperties` + with a list of strings or an array: + ```javascript + record.getProperties('firstName', 'lastName', 'zipCode'); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + is equivalent to: + ```javascript + record.getProperties(['firstName', 'lastName', 'zipCode']); + // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } + ``` + @method getProperties + @param {String...|Array} list of keys to get + @return {Object} + @public + */ + getProperties: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - var value = cache.revalidate(); - if (_glimmerReference.isModified(value)) { - this.attributeManager.updateAttribute(env, element, value, this.namespace); - } - }; + return _emberMetal.getProperties.apply(undefined, [this].concat(args)); + }, - DynamicAttribute.prototype.flush = function flush(env) { - var reference = this.reference; - var element = this.element; + /** + Sets the provided key or path to the value. + ```javascript + record.set("key", value); + ``` + This method is generally very similar to calling `object["key"] = value` or + `object.key = value`, except that it provides support for computed + properties, the `setUnknownProperty()` method and property observers. + ### Computed Properties + If you try to set a value on a key that has a computed property handler + defined (see the `get()` method for an example), then `set()` will call + that method, passing both the value and key instead of simply changing + the value itself. This is useful for those times when you need to + implement a property that is composed of one or more member + properties. + ### Unknown Properties + If you try to set a value on a key that is undefined in the target + object, then the `setUnknownProperty()` handler will be called instead. This + gives you an opportunity to implement complex "virtual" properties that + are not predefined on the object. If `setUnknownProperty()` returns + undefined, then `set()` will simply set the value on the object. + ### Property Observers + In addition to changing the property, `set()` will also register a property + change with the object. Unless you have placed this call inside of a + `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers + (i.e. observer methods declared on the same object), will be called + immediately. Any "remote" observers (i.e. observer methods declared on + another object) will be placed in a queue and called at a later time in a + coalesced manner. + @method set + @param {String} keyName The property to set + @param {Object} value The value to set or `null`. + @return {Object} The passed value + @public + */ + set: function (keyName, value) { + return _emberMetal.set(this, keyName, value); + }, - if (_glimmerReference.isConst(reference)) { - var value = reference.value(); - this.attributeManager.setAttribute(env, element, value, this.namespace); - return null; - } else { - var cache = this.cache = new _glimmerReference.ReferenceCache(reference); - var value = cache.peek(); - this.attributeManager.setAttribute(env, element, value, this.namespace); - return new PatchElementOpcode(this); - } - }; + /** + Sets a list of properties at once. These properties are set inside + a single `beginPropertyChanges` and `endPropertyChanges` batch, so + observers will be buffered. + ```javascript + record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); + ``` + @method setProperties + @param {Object} hash the hash of keys and values to set + @return {Object} The passed in hash + @public + */ + setProperties: function (hash) { + return _emberMetal.setProperties(this, hash); + }, - DynamicAttribute.prototype.toJSON = function toJSON() { - var element = this.element; - var namespace = this.namespace; - var name = this.name; - var cache = this.cache; - - var formattedElement = formatElement(element); - var lastValue = cache.peek(); - if (namespace) { - return { - element: formattedElement, - type: 'attribute', - namespace: namespace, - name: name, - lastValue: lastValue - }; - } - return { - element: formattedElement, - type: 'attribute', - namespace: namespace, - name: name, - lastValue: lastValue - }; - }; + /** + Begins a grouping of property changes. + You can use this method to group property changes so that notifications + will not be sent until the changes are finished. If you plan to make a + large number of changes to an object at one time, you should call this + method at the beginning of the changes to begin deferring change + notifications. When you are done making changes, call + `endPropertyChanges()` to deliver the deferred change notifications and end + deferring. + @method beginPropertyChanges + @return {Ember.Observable} + @private + */ + beginPropertyChanges: function () { + _emberMetal.beginPropertyChanges(); + return this; + }, - return DynamicAttribute; - })(); + /** + Ends a grouping of property changes. + You can use this method to group property changes so that notifications + will not be sent until the changes are finished. If you plan to make a + large number of changes to an object at one time, you should call + `beginPropertyChanges()` at the beginning of the changes to defer change + notifications. When you are done making changes, call this method to + deliver the deferred change notifications and end deferring. + @method endPropertyChanges + @return {Ember.Observable} + @private + */ + endPropertyChanges: function () { + _emberMetal.endPropertyChanges(); + return this; + }, - exports.DynamicAttribute = DynamicAttribute; + /** + Notify the observer system that a property is about to change. + Sometimes you need to change a value directly or indirectly without + actually calling `get()` or `set()` on it. In this case, you can use this + method and `propertyDidChange()` instead. Calling these two methods + together will notify all observers that the property has potentially + changed value. + Note that you must always call `propertyWillChange` and `propertyDidChange` + as a pair. If you do not, it may get the property change groups out of + order and cause notifications to be delivered more often than you would + like. + @method propertyWillChange + @param {String} keyName The property key that is about to change. + @return {Ember.Observable} + @private + */ + propertyWillChange: function (keyName) { + _emberMetal.propertyWillChange(this, keyName); + return this; + }, - function formatElement(element) { - return JSON.stringify('<' + element.tagName.toLowerCase() + ' />'); - } + /** + Notify the observer system that a property has just changed. + Sometimes you need to change a value directly or indirectly without + actually calling `get()` or `set()` on it. In this case, you can use this + method and `propertyWillChange()` instead. Calling these two methods + together will notify all observers that the property has potentially + changed value. + Note that you must always call `propertyWillChange` and `propertyDidChange` + as a pair. If you do not, it may get the property change groups out of + order and cause notifications to be delivered more often than you would + like. + @method propertyDidChange + @param {String} keyName The property key that has just changed. + @return {Ember.Observable} + @private + */ + propertyDidChange: function (keyName) { + _emberMetal.propertyDidChange(this, keyName); + return this; + }, - var DynamicAttrNSOpcode = (function (_Opcode12) { - babelHelpers.inherits(DynamicAttrNSOpcode, _Opcode12); + /** + Convenience method to call `propertyWillChange` and `propertyDidChange` in + succession. + @method notifyPropertyChange + @param {String} keyName The property key to be notified about. + @return {Ember.Observable} + @public + */ + notifyPropertyChange: function (keyName) { + this.propertyWillChange(keyName); + this.propertyDidChange(keyName); + return this; + }, - function DynamicAttrNSOpcode(name, namespace, isTrusting) { - _Opcode12.call(this); - this.name = name; - this.namespace = namespace; - this.isTrusting = isTrusting; - this.type = "dynamic-attr"; + /** + Adds an observer on a property. + This is the core method used to register an observer for a property. + Once you call this method, any time the key's value is set, your observer + will be notified. Note that the observers are triggered any time the + value is set, regardless of whether it has actually changed. Your + observer should be prepared to handle that. + ### Observer Methods + Observer methods have the following signature: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + this.addObserver('foo', this, 'fooDidChange'); + }, + fooDidChange(sender, key, value, rev) { + // your code } + }); + ``` + The `sender` is the object that changed. The `key` is the property that + changes. The `value` property is currently reserved and unused. The `rev` + is the last property revision of the object when it changed, which you can + use to detect if the key value has really changed or not. + Usually you will not need the value or revision parameters at + the end. In this case, it is common to write observer methods that take + only a sender and key value as parameters or, if you aren't interested in + any of these values, to write an observer that has no parameters at all. + @method addObserver + @param {String} key The key to observer + @param {Object} target The target object to invoke + @param {String|Function} method The method to invoke. + @public + */ + addObserver: function (key, target, method) { + _emberMetal.addObserver(this, key, target, method); + }, - DynamicAttrNSOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var namespace = this.namespace; - var isTrusting = this.isTrusting; - - var reference = vm.frame.getOperand(); - vm.stack().setDynamicAttributeNS(namespace, name, reference, isTrusting); - }; - - DynamicAttrNSOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; - var namespace = this.namespace; - - var details = _glimmerUtil.dict(); - details["name"] = JSON.stringify(name); - details["value"] = "$OPERAND"; - if (namespace) { - details["namespace"] = JSON.stringify(namespace); - } - return { guid: guid, type: type, details: details }; - }; + /** + Remove an observer you have previously registered on this object. Pass + the same key, target, and method you passed to `addObserver()` and your + target will no longer receive notifications. + @method removeObserver + @param {String} key The key to observer + @param {Object} target The target object to invoke + @param {String|Function} method The method to invoke. + @public + */ + removeObserver: function (key, target, method) { + _emberMetal.removeObserver(this, key, target, method); + }, - return DynamicAttrNSOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Returns `true` if the object currently has observers registered for a + particular key. You can use this method to potentially defer performing + an expensive action until someone begins observing a particular property + on the object. + @method hasObserverFor + @param {String} key Key to check + @return {Boolean} + @private + */ + hasObserverFor: function (key) { + return _emberMetal.hasListeners(this, key + ':change'); + }, - exports.DynamicAttrNSOpcode = DynamicAttrNSOpcode; + /** + Retrieves the value of a property, or a default value in the case that the + property returns `undefined`. + ```javascript + person.getWithDefault('lastName', 'Doe'); + ``` + @method getWithDefault + @param {String} keyName The name of the property to retrieve + @param {Object} defaultValue The value to return if the property value is undefined + @return {Object} The property value or the defaultValue. + @public + */ + getWithDefault: function (keyName, defaultValue) { + return _emberMetal.getWithDefault(this, keyName, defaultValue); + }, - var DynamicAttrOpcode = (function (_Opcode13) { - babelHelpers.inherits(DynamicAttrOpcode, _Opcode13); + /** + Set the value of a property to the current value plus some amount. + ```javascript + person.incrementProperty('age'); + team.incrementProperty('score', 2); + ``` + @method incrementProperty + @param {String} keyName The name of the property to increment + @param {Number} increment The amount to increment by. Defaults to 1 + @return {Number} The new property value + @public + */ + incrementProperty: function (keyName, increment) { + if (_emberMetal.isNone(increment)) { + increment = 1; + } - function DynamicAttrOpcode(name, isTrusting) { - _Opcode13.call(this); - this.name = name; - this.isTrusting = isTrusting; - this.type = "dynamic-attr"; - } + return _emberMetal.set(this, keyName, (parseFloat(_emberMetal.get(this, keyName)) || 0) + increment); + }, - DynamicAttrOpcode.prototype.evaluate = function evaluate(vm) { - var name = this.name; - var isTrusting = this.isTrusting; + /** + Set the value of a property to the current value minus some amount. + ```javascript + player.decrementProperty('lives'); + orc.decrementProperty('health', 5); + ``` + @method decrementProperty + @param {String} keyName The name of the property to decrement + @param {Number} decrement The amount to decrement by. Defaults to 1 + @return {Number} The new property value + @public + */ + decrementProperty: function (keyName, decrement) { + if (_emberMetal.isNone(decrement)) { + decrement = 1; + } - var reference = vm.frame.getOperand(); - vm.stack().setDynamicAttribute(name, reference, isTrusting); - }; + return _emberMetal.set(this, keyName, (_emberMetal.get(this, keyName) || 0) - decrement); + }, - DynamicAttrOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var name = this.name; + /** + Set the value of a boolean property to the opposite of its + current value. + ```javascript + starship.toggleProperty('warpDriveEngaged'); + ``` + @method toggleProperty + @param {String} keyName The name of the property to toggle + @return {Boolean} The new property value + @public + */ + toggleProperty: function (keyName) { + return _emberMetal.set(this, keyName, !_emberMetal.get(this, keyName)); + }, - var details = _glimmerUtil.dict(); - details["name"] = JSON.stringify(name); - details["value"] = "$OPERAND"; - return { guid: guid, type: type, details: details }; - }; + /** + Returns the cached value of a computed property, if it exists. + This allows you to inspect the value of a computed property + without accidentally invoking it if it is intended to be + generated lazily. + @method cacheFor + @param {String} keyName + @return {Object} The cached value of the computed property, if any + @public + */ + cacheFor: function (keyName) { + return _emberMetal.cacheFor(this, keyName); + }, - return DynamicAttrOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + // intended for debugging purposes + observersForKey: function (keyName) { + return _emberMetal.observersFor(this, keyName); + } + }); +}); +enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros) { + 'use strict'; - exports.DynamicAttrOpcode = DynamicAttrOpcode; + /** + @module ember + @submodule ember-runtime + */ - var PatchElementOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(PatchElementOpcode, _UpdatingOpcode2); + function tap(proxy, promise) { + _emberMetal.setProperties(proxy, { + isFulfilled: false, + isRejected: false + }); - function PatchElementOpcode(operation) { - _UpdatingOpcode2.call(this); - this.type = "patch-element"; - this.tag = operation.tag; - this.operation = operation; - } + return promise.then(function (value) { + if (!proxy.isDestroyed && !proxy.isDestroying) { + _emberMetal.setProperties(proxy, { + content: value, + isFulfilled: true + }); + } + return value; + }, function (reason) { + if (!proxy.isDestroyed && !proxy.isDestroying) { + _emberMetal.setProperties(proxy, { + reason: reason, + isRejected: true + }); + } + throw reason; + }, 'Ember: PromiseProxy'); + } - PatchElementOpcode.prototype.evaluate = function evaluate(vm) { - this.operation.patch(vm.env); - }; + /** + A low level mixin making ObjectProxy promise-aware. + + ```javascript + let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); + + let proxy = ObjectPromiseProxy.create({ + promise: Ember.RSVP.cast($.getJSON('/some/remote/data.json')) + }); + + proxy.then(function(json){ + // the json + }, function(reason) { + // the reason why you have no json + }); + ``` + + the proxy has bindable attributes which + track the promises life cycle + + ```javascript + proxy.get('isPending') //=> true + proxy.get('isSettled') //=> false + proxy.get('isRejected') //=> false + proxy.get('isFulfilled') //=> false + ``` + + When the $.getJSON completes, and the promise is fulfilled + with json, the life cycle attributes will update accordingly. + Note that $.getJSON doesn't return an ECMA specified promise, + it is useful to wrap this with an `RSVP.cast` so that it behaves + as a spec compliant promise. + + ```javascript + proxy.get('isPending') //=> false + proxy.get('isSettled') //=> true + proxy.get('isRejected') //=> false + proxy.get('isFulfilled') //=> true + ``` + + As the proxy is an ObjectProxy, and the json now its content, + all the json properties will be available directly from the proxy. + + ```javascript + // Assuming the following json: + { + firstName: 'Stefan', + lastName: 'Penner' + } + + // both properties will accessible on the proxy + proxy.get('firstName') //=> 'Stefan' + proxy.get('lastName') //=> 'Penner' + ``` + + @class Ember.PromiseProxyMixin + @public + */ + exports.default = _emberMetal.Mixin.create({ + /** + If the proxied promise is rejected this will contain the reason + provided. + @property reason + @default null + @public + */ + reason: null, - PatchElementOpcode.prototype.toJSON = function toJSON() { - var _guid = this._guid; - var type = this.type; - var operation = this.operation; + /** + Once the proxied promise has settled this will become `false`. + @property isPending + @default true + @public + */ + isPending: _emberRuntimeComputedComputed_macros.not('isSettled').readOnly(), - return { - guid: _guid, - type: type, - details: operation.toJSON() - }; - }; + /** + Once the proxied promise has settled this will become `true`. + @property isSettled + @default false + @public + */ + isSettled: _emberRuntimeComputedComputed_macros.or('isRejected', 'isFulfilled').readOnly(), - return PatchElementOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + /** + Will become `true` if the proxied promise is rejected. + @property isRejected + @default false + @public + */ + isRejected: false, - exports.PatchElementOpcode = PatchElementOpcode; + /** + Will become `true` if the proxied promise is fulfilled. + @property isFulfilled + @default false + @public + */ + isFulfilled: false, - var CommentOpcode = (function (_Opcode14) { - babelHelpers.inherits(CommentOpcode, _Opcode14); + /** + The promise whose fulfillment value is being proxied by this object. + This property must be specified upon creation, and should not be + changed once created. + Example: + ```javascript + Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({ + promise: + }); + ``` + @property promise + @public + */ + promise: _emberMetal.computed({ + get: function () { + throw new _emberMetal.Error('PromiseProxy\'s promise must be set'); + }, + set: function (key, promise) { + return tap(this, promise); + } + }), - function CommentOpcode(comment) { - _Opcode14.call(this); - this.comment = comment; - this.type = "comment"; - } + /** + An alias to the proxied promise's `then`. + See RSVP.Promise.then. + @method then + @param {Function} callback + @return {RSVP.Promise} + @public + */ + then: promiseAlias('then'), - CommentOpcode.prototype.evaluate = function evaluate(vm) { - vm.stack().appendComment(this.comment); - }; + /** + An alias to the proxied promise's `catch`. + See RSVP.Promise.catch. + @method catch + @param {Function} callback + @return {RSVP.Promise} + @since 1.3.0 + @public + */ + 'catch': promiseAlias('catch'), - CommentOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.comment)] - }; - }; + /** + An alias to the proxied promise's `finally`. + See RSVP.Promise.finally. + @method finally + @param {Function} callback + @return {RSVP.Promise} + @since 1.3.0 + @public + */ + 'finally': promiseAlias('finally') - return CommentOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + }); - exports.CommentOpcode = CommentOpcode; + function promiseAlias(name) { + return function () { + var promise = _emberMetal.get(this, 'promise'); + return promise[name].apply(promise, arguments); + }; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9kb20udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBd0JBLFVBQUE7OEJBQUEsVUFBQTs7QUFHRSxpQkFIRixVQUFBLENBR3NCLElBQVksRUFBQTtBQUM5Qiw4QkFBTyxDQUFDO0FBRFUsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFRO0FBRnpCLGdCQUFBLENBQUEsSUFBSSxHQUFHLE1BQU0sQ0FBQztTQUlwQjs7QUFMSCxrQkFBQSxXQU9FLFFBQVEsR0FBQSxrQkFBQyxFQUFNLEVBQUE7QUFDYixjQUFFLENBQUMsS0FBSyxFQUFFLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztTQUNsQzs7QUFUSCx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AgIHJldHVybiB7XG4gICAgICBndWlkOiB0aGlzLl9ndWlkLFxuICAgICAgdHlwZTogdGhpcy50eXBlLFxuICAgICAgYXJnczogW0pTT04uc3RyaW5naWZ5KHRoaXMuY29tbWVudCldXG4gICAgfTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/lists', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-util', 'glimmer-reference'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerUtil, _glimmerReference) { - 'use strict'; - - var IterablePresenceReference = (function () { - function IterablePresenceReference(artifacts) { - this.tag = artifacts.tag; - this.artifacts = artifacts; - } - - IterablePresenceReference.prototype.value = function value() { - return !this.artifacts.isEmpty(); - }; - - return IterablePresenceReference; - })(); - - var PutIteratorOpcode = (function (_Opcode) { - babelHelpers.inherits(PutIteratorOpcode, _Opcode); - - function PutIteratorOpcode() { - _Opcode.apply(this, arguments); - this.type = "put-iterator"; - } - - PutIteratorOpcode.prototype.evaluate = function evaluate(vm) { - var listRef = vm.frame.getOperand(); - var args = vm.frame.getArgs(); - var iterable = vm.env.iterableFor(listRef, args); - var iterator = new _glimmerReference.ReferenceIterator(iterable); - vm.frame.setIterator(iterator); - vm.frame.setCondition(new IterablePresenceReference(iterator.artifacts)); - }; +enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - return PutIteratorOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + 'use strict'; - exports.PutIteratorOpcode = PutIteratorOpcode; + exports.buildFakeRegistryWithDeprecations = buildFakeRegistryWithDeprecations; - var EnterListOpcode = (function (_Opcode2) { - babelHelpers.inherits(EnterListOpcode, _Opcode2); + /** + RegistryProxyMixin is used to provide public access to specific + registry functionality. + + @class RegistryProxyMixin + @private + */ + exports.default = _emberMetal.Mixin.create({ + __registry__: null, - function EnterListOpcode(start, end) { - _Opcode2.call(this); - this.type = "enter-list"; - this.slice = new _glimmerUtil.ListSlice(start, end); - } + /** + Given a fullName return the corresponding factory. + @public + @method resolveRegistration + @param {String} fullName + @return {Function} fullName's factory + */ + resolveRegistration: registryAlias('resolve'), - EnterListOpcode.prototype.evaluate = function evaluate(vm) { - vm.enterList(this.slice); - }; + /** + Registers a factory that can be used for dependency injection (with + `inject`) or for service lookup. Each factory is registered with + a full name including two parts: `type:name`. + A simple example: + ```javascript + let App = Ember.Application.create(); + App.Orange = Ember.Object.extend(); + App.register('fruit:favorite', App.Orange); + ``` + Ember will resolve factories from the `App` namespace automatically. + For example `App.CarsController` will be discovered and returned if + an application requests `controller:cars`. + An example of registering a controller with a non-standard name: + ```javascript + let App = Ember.Application.create(); + let Session = Ember.Controller.extend(); + App.register('controller:session', Session); + // The Session controller can now be treated like a normal controller, + // despite its non-standard name. + App.ApplicationController = Ember.Controller.extend({ + needs: ['session'] + }); + ``` + Registered factories are **instantiated** by having `create` + called on them. Additionally they are **singletons**, each time + they are looked up they return the same instance. + Some examples modifying that default behavior: + ```javascript + let App = Ember.Application.create(); + App.Person = Ember.Object.extend(); + App.Orange = Ember.Object.extend(); + App.Email = Ember.Object.extend(); + App.session = Ember.Object.create(); + App.register('model:user', App.Person, { singleton: false }); + App.register('fruit:favorite', App.Orange); + App.register('communication:main', App.Email, { singleton: false }); + App.register('session', App.session, { instantiate: false }); + ``` + @method register + @param fullName {String} type:name (e.g., 'model:user') + @param factory {Function} (e.g., App.Person) + @param options {Object} (optional) disable instantiation or singleton usage + @public + */ + register: registryAlias('register'), - EnterListOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var type = this.type; - var _guid = this._guid; + /** + Unregister a factory. + ```javascript + let App = Ember.Application.create(); + let User = Ember.Object.extend(); + App.register('model:user', User); + App.resolveRegistration('model:user').create() instanceof User //=> true + App.unregister('model:user') + App.resolveRegistration('model:user') === undefined //=> true + ``` + @public + @method unregister + @param {String} fullName + */ + unregister: registryAlias('unregister'), - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + /** + Check if a factory is registered. + @public + @method hasRegistration + @param {String} fullName + @return {Boolean} + */ + hasRegistration: registryAlias('has'), - return EnterListOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Register an option for a particular factory. + @public + @method registerOption + @param {String} fullName + @param {String} optionName + @param {Object} options + */ + registerOption: registryAlias('option'), - exports.EnterListOpcode = EnterListOpcode; + /** + Return a specific registered option for a particular factory. + @public + @method registeredOption + @param {String} fullName + @param {String} optionName + @return {Object} options + */ + registeredOption: registryAlias('getOption'), - var ExitListOpcode = (function (_Opcode3) { - babelHelpers.inherits(ExitListOpcode, _Opcode3); + /** + Register options for a particular factory. + @public + @method registerOptions + @param {String} fullName + @param {Object} options + */ + registerOptions: registryAlias('options'), - function ExitListOpcode() { - _Opcode3.apply(this, arguments); - this.type = "exit-list"; - } + /** + Return registered options for a particular factory. + @public + @method registeredOptions + @param {String} fullName + @return {Object} options + */ + registeredOptions: registryAlias('getOptions'), - ExitListOpcode.prototype.evaluate = function evaluate(vm) { - vm.exitList(); - }; + /** + Allow registering options for all factories of a type. + ```javascript + let App = Ember.Application.create(); + let appInstance = App.buildInstance(); + // if all of type `connection` must not be singletons + appInstance.registerOptionsForType('connection', { singleton: false }); + appInstance.register('connection:twitter', TwitterConnection); + appInstance.register('connection:facebook', FacebookConnection); + let twitter = appInstance.lookup('connection:twitter'); + let twitter2 = appInstance.lookup('connection:twitter'); + twitter === twitter2; // => false + let facebook = appInstance.lookup('connection:facebook'); + let facebook2 = appInstance.lookup('connection:facebook'); + facebook === facebook2; // => false + ``` + @public + @method registerOptionsForType + @param {String} type + @param {Object} options + */ + registerOptionsForType: registryAlias('optionsForType'), - return ExitListOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + Return the registered options for all factories of a type. + @public + @method registeredOptionsForType + @param {String} type + @return {Object} options + */ + registeredOptionsForType: registryAlias('getOptionsForType'), - exports.ExitListOpcode = ExitListOpcode; + /** + Define a dependency injection onto a specific factory or all factories + of a type. + When Ember instantiates a controller, view, or other framework component + it can attach a dependency to that component. This is often used to + provide services to a set of framework components. + An example of providing a session object to all controllers: + ```javascript + let App = Ember.Application.create(); + let Session = Ember.Object.extend({ isAuthenticated: false }); + // A factory must be registered before it can be injected + App.register('session:main', Session); + // Inject 'session:main' onto all factories of the type 'controller' + // with the name 'session' + App.inject('controller', 'session', 'session:main'); + App.IndexController = Ember.Controller.extend({ + isLoggedIn: Ember.computed.alias('session.isAuthenticated') + }); + ``` + Injections can also be performed on specific factories. + ```javascript + App.inject(, , ) + App.inject('route', 'source', 'source:main') + App.inject('route:application', 'email', 'model:email') + ``` + It is important to note that injections can only be performed on + classes that are instantiated by Ember itself. Instantiating a class + directly (via `create` or `new`) bypasses the dependency injection + system. + **Note:** Ember-Data instantiates its models in a unique manner, and consequently + injections onto models (or all models) will not work as expected. Injections + on models can be enabled by setting `EmberENV.MODEL_FACTORY_INJECTIONS` + to `true`. + @public + @method inject + @param factoryNameOrType {String} + @param property {String} + @param injectionName {String} + **/ + inject: registryAlias('injection') + }); - var EnterWithKeyOpcode = (function (_Opcode4) { - babelHelpers.inherits(EnterWithKeyOpcode, _Opcode4); + function registryAlias(name) { + return function () { + var _registry__; - function EnterWithKeyOpcode(start, end) { - _Opcode4.call(this); - this.type = "enter-with-key"; - this.slice = new _glimmerUtil.ListSlice(start, end); - } + return (_registry__ = this.__registry__)[name].apply(_registry__, arguments); + }; + } - EnterWithKeyOpcode.prototype.evaluate = function evaluate(vm) { - vm.enterWithKey(vm.frame.getKey(), this.slice); - }; + function buildFakeRegistryWithDeprecations(instance, typeForMessage) { + var fakeRegistry = {}; + var registryProps = { + resolve: 'resolveRegistration', + register: 'register', + unregister: 'unregister', + has: 'hasRegistration', + option: 'registerOption', + options: 'registerOptions', + getOptions: 'registeredOptions', + optionsForType: 'registerOptionsForType', + getOptionsForType: 'registeredOptionsForType', + injection: 'inject' + }; - EnterWithKeyOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var _guid = this._guid; - var type = this.type; + for (var deprecatedProperty in registryProps) { + fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]); + } - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + return fakeRegistry; + } - return EnterWithKeyOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) { + return function () { + return instance[nonDeprecatedProperty].apply(instance, arguments); + }; + } +}); +enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + /** + @module ember + @submodule ember-runtime + */ - exports.EnterWithKeyOpcode = EnterWithKeyOpcode; + 'use strict'; - var TRUE_REF = new _glimmerReference.ConstReference(true); - var FALSE_REF = new _glimmerReference.ConstReference(false); + /** + `Ember.TargetActionSupport` is a mixin that can be included in a class + to add a `triggerAction` method with semantics similar to the Handlebars + `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is + usually the best choice. This mixin is most often useful when you are + doing more complex event handling in Components. + + @class TargetActionSupport + @namespace Ember + @extends Ember.Mixin + @private + */ + exports.default = _emberMetal.Mixin.create({ + target: null, + action: null, + actionContext: null, - var NextIterOpcode = (function (_Opcode5) { - babelHelpers.inherits(NextIterOpcode, _Opcode5); + actionContextObject: _emberMetal.computed('actionContext', function () { + var actionContext = _emberMetal.get(this, 'actionContext'); - function NextIterOpcode(end) { - _Opcode5.call(this); - this.type = "next-iter"; - this.end = end; + if (typeof actionContext === 'string') { + var value = _emberMetal.get(this, actionContext); + if (value === undefined) { + value = _emberMetal.get(_emberEnvironment.context.lookup, actionContext); } + return value; + } else { + return actionContext; + } + }), - NextIterOpcode.prototype.evaluate = function evaluate(vm) { - var item = vm.frame.getIterator().next(); - if (item) { - vm.frame.setCondition(TRUE_REF); - vm.frame.setKey(item.key); - vm.frame.setOperand(item.value); - vm.frame.setArgs(_glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs.positional([item.value, item.memo])); - } else { - vm.frame.setCondition(FALSE_REF); - vm.goto(this.end); - } - }; + /** + Send an `action` with an `actionContext` to a `target`. The action, actionContext + and target will be retrieved from properties of the object. For example: + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + action: 'save', + actionContext: Ember.computed.alias('context'), + click() { + this.triggerAction(); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + The `target`, `action`, and `actionContext` can be provided as properties of + an optional object argument to `triggerAction` as well. + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + click() { + this.triggerAction({ + action: 'save', + target: this.get('controller'), + actionContext: this.get('context') + }); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. + But `target` and `action` must be specified either as properties or with the argument + to `triggerAction`, or a combination: + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + click() { + this.triggerAction({ + action: 'save' + }); // Sends the `save` action, along with a reference to `this`, + // to the current controller + } + }); + ``` + @method triggerAction + @param opts {Object} (optional, with the optional keys action, target and/or actionContext) + @return {Boolean} true if the action was sent successfully and did not return false + @private + */ + triggerAction: function () { + var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - return NextIterOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var action = opts.action || _emberMetal.get(this, 'action'); + var target = opts.target; - exports.NextIterOpcode = NextIterOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIv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FtZS5nZXRJdGVyYXRvcigpLm5leHQoKTtcblxuICAgIGlmIChpdGVtKSB7XG4gICAgICB2bS5mcmFtZS5zZXRDb25kaXRpb24oVFJVRV9SRUYpO1xuICAgICAgdm0uZnJhbWUuc2V0S2V5KGl0ZW0ua2V5KTtcbiAgICAgIHZtLmZyYW1lLnNldE9wZXJhbmQoaXRlbS52YWx1ZSk7XG4gICAgICB2bS5mcmFtZS5zZXRBcmdzKEV2YWx1YXRlZEFyZ3MucG9zaXRpb25hbChbaXRlbS52YWx1ZSwgaXRlbS5tZW1vXSkpO1xuICAgIH0gZWxzZSB7XG4gICAgICB2bS5mcmFtZS5zZXRDb25kaXRpb24oRkFMU0VfUkVGKTtcbiAgICAgIHZtLmdvdG8odGhpcy5lbmQpO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/compiled/opcodes/partial', ['exports', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm'], function (exports, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm) { - 'use strict'; + if (!target) { + target = getTarget(this); + } - var PutDynamicPartialDefinitionOpcode = (function (_Opcode) { - babelHelpers.inherits(PutDynamicPartialDefinitionOpcode, _Opcode); + var actionContext = opts.actionContext; - function PutDynamicPartialDefinitionOpcode(symbolTable) { - _Opcode.call(this); - this.symbolTable = symbolTable; - this.type = "put-dynamic-partial-definition"; + function args(options, actionName) { + var ret = []; + if (actionName) { + ret.push(actionName); } - PutDynamicPartialDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - var env = vm.env; - var symbolTable = this.symbolTable; - - function lookupPartial(name) { - var normalized = String(name); - if (!env.hasPartial(normalized, symbolTable)) { - throw new Error('Could not find a partial named "' + normalized + '"'); - } - return env.lookupPartial(normalized, symbolTable); - } - var reference = _glimmerReference.map(vm.frame.getOperand(), lookupPartial); - var cache = _glimmerReference.isConst(reference) ? undefined : new _glimmerReference.ReferenceCache(reference); - var definition = cache ? cache.peek() : reference.value(); - vm.frame.setImmediate(definition); - if (cache) { - vm.updateWith(new _glimmerRuntimeLibCompiledOpcodesVm.Assert(cache)); - } - }; + return ret.concat(options); + } - PutDynamicPartialDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + if (typeof actionContext === 'undefined') { + actionContext = _emberMetal.get(this, 'actionContextObject') || this; + } - return PutDynamicPartialDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (target && action) { + var ret = undefined; - exports.PutDynamicPartialDefinitionOpcode = PutDynamicPartialDefinitionOpcode; + if (target.send) { + var _target; - var PutPartialDefinitionOpcode = (function (_Opcode2) { - babelHelpers.inherits(PutPartialDefinitionOpcode, _Opcode2); + ret = (_target = target).send.apply(_target, args(actionContext, action)); + } else { + var _target2; - function PutPartialDefinitionOpcode(definition) { - _Opcode2.call(this); - this.definition = definition; - this.type = "put-partial-definition"; + ret = (_target2 = target)[action].apply(_target2, args(actionContext)); } - PutPartialDefinitionOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setImmediate(this.definition); - }; + if (ret !== false) { + ret = true; + } - PutPartialDefinitionOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.definition.name)] - }; - }; + return ret; + } else { + return false; + } + } + }); - return PutPartialDefinitionOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function getTarget(instance) { + // TODO: Deprecate specifying `targetObject` + var target = _emberMetal.get(instance, 'targetObject'); - exports.PutPartialDefinitionOpcode = PutPartialDefinitionOpcode; + // if a `targetObject` CP was provided, use it + if (target) { + return target; + } - var EvaluatePartialOpcode = (function (_Opcode3) { - babelHelpers.inherits(EvaluatePartialOpcode, _Opcode3); + // if _targetObject use it + if (instance._targetObject) { + return instance._targetObject; + } - function EvaluatePartialOpcode(symbolTable) { - _Opcode3.call(this); - this.symbolTable = symbolTable; - this.type = "evaluate-partial"; - this.cache = _glimmerUtil.dict(); + target = _emberMetal.get(instance, 'target'); + if (target) { + if (typeof target === 'string') { + var value = _emberMetal.get(instance, target); + if (value === undefined) { + value = _emberMetal.get(_emberEnvironment.context.lookup, target); } - EvaluatePartialOpcode.prototype.evaluate = function evaluate(vm) { - var _vm$frame$getImmediate = vm.frame.getImmediate(); + return value; + } else { + return target; + } + } - var template = _vm$frame$getImmediate.template; + return null; + } +}); +enifed("ember-runtime/string_registry", ["exports"], function (exports) { + // STATE within a module is frowned apon, this exists + // to support Ember.STRINGS but shield ember internals from this legacy global + // API. + "use strict"; - var block = this.cache[template.id]; - if (!block) { - block = template.asPartial(this.symbolTable); - } - vm.invokePartial(block); - }; + exports.setStrings = setStrings; + exports.getStrings = getStrings; + exports.get = get; + var STRINGS = {}; - EvaluatePartialOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND"] - }; - }; + function setStrings(strings) { + STRINGS = strings; + } - return EvaluatePartialOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + function getStrings() { + return STRINGS; + } - exports.EvaluatePartialOpcode = EvaluatePartialOpcode; + function get(name) { + return STRINGS[name]; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy9wYXJ0aWFsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVNBLGlDQUFBOzhCQUFBLGlDQUFBOztBQUdFLGlCQUhGLGlDQUFBLENBR3NCLFdBQXdCLEVBQUE7QUFDMUMsOEJBQU8sQ0FBQztBQURVLGdCQUFBLENBQUEsV0FBVyxHQUFYLFdBQVcsQ0FBYTtBQUZyQyxnQkFBQSxDQUFBLElBQUksR0FBRyxnQ0FBZ0MsQ0FBQztTQUk5Qzs7QUFMSCx5Q0FBQSxXQU9FLFFBQVEsR0F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lZmluaXRpb24ubmFtZSldXG4gICAgfTtcbiAgfVxufVxuXG5leHBvcnQgY2xhc3MgRXZhbHVhdGVQYXJ0aWFsT3Bjb2RlIGV4dGVuZHMgT3Bjb2RlIHtcbiAgcHVibGljIHR5cGUgPSBcImV2YWx1YXRlLXBhcnRpYWxcIjtcbiAgcHJpdmF0ZSBjYWNoZSA9IGRpY3Q8UGFydGlhbEJsb2NrPigpO1xuXG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgc3ltYm9sVGFibGU6IFN5bWJvbFRhYmxlKSB7XG4gICAgc3VwZXIoKTtcbiAgfVxuXG4gIGV2YWx1YXRlKHZtOiBWTSkge1xuICAgIGxldCB7IHRlbXBsYXRlIH0gPSB2bS5mcmFtZS5nZXRJbW1lZGlhdGU8UGFydGlhbERlZmluaXRpb248T3BhcXVlPj4oKTtcblxuICAgIGxldCBibG9jayA9IHRoaXMuY2FjaGVbdGVtcGxhdGUuaWRdO1xuXG4gICAgaWYgKCFibG9jaykge1xuICAgICAgYmxvY2sgPSB0ZW1wbGF0ZS5hc1BhcnRpYWwodGhpcy5zeW1ib2xUYWJsZSk7XG4gICAgfVxuXG4gICAgdm0uaW52b2tlUGFydGlhbChibG9jayk7XG4gIH1cblxuICB0b0pTT04oKTogT3Bjb2RlSlNPTiB7XG4gICAgcmV0dXJuIHtcbiAgICAgIGd1aWQ6IHRoaXMuX2d1aWQsXG4gICAgICB0eXBlOiB0aGlzLnR5cGUsXG4gICAgICBhcmdzOiBbXCIkT1BFUkFORFwiXVxuICAgIH07XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiled/opcodes/vm', ['exports', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/references', 'glimmer-reference', 'glimmer-util'], function (exports, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibReferences, _glimmerReference, _glimmerUtil) { - 'use strict'; - - var PushChildScopeOpcode = (function (_Opcode) { - babelHelpers.inherits(PushChildScopeOpcode, _Opcode); - - function PushChildScopeOpcode() { - _Opcode.apply(this, arguments); - this.type = "push-child-scope"; - } +enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) { + 'use strict'; - PushChildScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.pushChildScope(); - }; + exports.default = _emberRuntimeSystemNamespace.default.extend(); +}); +enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray) { + 'use strict'; - return PushChildScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + @module ember + @submodule ember-runtime + */ - exports.PushChildScopeOpcode = PushChildScopeOpcode; + var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; + var EMPTY = []; - var PopScopeOpcode = (function (_Opcode2) { - babelHelpers.inherits(PopScopeOpcode, _Opcode2); + function K() { + return this; + } - function PopScopeOpcode() { - _Opcode2.apply(this, arguments); - this.type = "pop-scope"; + /** + An ArrayProxy wraps any other object that implements `Ember.Array` and/or + `Ember.MutableArray,` forwarding all requests. This makes it very useful for + a number of binding use cases or other cases where being able to swap + out the underlying array is useful. + + A simple example of usage: + + ```javascript + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); + + ap.get('firstObject'); // 'dog' + ap.set('content', ['amoeba', 'paramecium']); + ap.get('firstObject'); // 'amoeba' + ``` + + This class can also be useful as a layer to transform the contents of + an array, as they are accessed. This can be done by overriding + `objectAtContent`: + + ```javascript + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ + content: Ember.A(pets), + objectAtContent: function(idx) { + return this.get('content').objectAt(idx).toUpperCase(); } + }); + + ap.get('firstObject'); // . 'DOG' + ``` + + @class ArrayProxy + @namespace Ember + @extends Ember.Object + @uses Ember.MutableArray + @public + */ + exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsMutable_array.default, { - PopScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - }; - - return PopScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + The content array. Must be an object that implements `Ember.Array` and/or + `Ember.MutableArray.` + @property content + @type Ember.Array + @private + */ + content: null, - exports.PopScopeOpcode = PopScopeOpcode; + /** + The array that the proxy pretends to be. In the default `ArrayProxy` + implementation, this and `content` are the same. Subclasses of `ArrayProxy` + can override this property to provide things like sorting and filtering. + @property arrangedContent + @private + */ + arrangedContent: _emberMetal.alias('content'), - var PushDynamicScopeOpcode = (function (_Opcode3) { - babelHelpers.inherits(PushDynamicScopeOpcode, _Opcode3); + /** + Should actually retrieve the object at the specified index from the + content. You can override this method in subclasses to transform the + content item to something new. + This method will only be called if content is non-`null`. + @method objectAtContent + @param {Number} idx The index to retrieve. + @return {Object} the value or undefined if none found + @public + */ + objectAtContent: function (idx) { + return _emberRuntimeMixinsArray.objectAt(_emberMetal.get(this, 'arrangedContent'), idx); + }, - function PushDynamicScopeOpcode() { - _Opcode3.apply(this, arguments); - this.type = "push-dynamic-scope"; - } + /** + Should actually replace the specified objects on the content array. + You can override this method in subclasses to transform the content item + into something new. + This method will only be called if content is non-`null`. + @method replaceContent + @param {Number} idx The starting index + @param {Number} amt The number of items to remove from the content. + @param {Array} objects Optional array of objects to insert or null if no + objects. + @return {void} + @private + */ + replaceContent: function (idx, amt, objects) { + _emberMetal.get(this, 'content').replace(idx, amt, objects); + }, - PushDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.pushDynamicScope(); - }; + /** + Invoked when the content property is about to change. Notifies observers that the + entire array content will change. + @private + @method _contentWillChange + */ + _contentWillChange: _emberMetal._beforeObserver('content', function () { + this._teardownContent(); + }), - return PushDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _teardownContent: function () { + var content = _emberMetal.get(this, 'content'); - exports.PushDynamicScopeOpcode = PushDynamicScopeOpcode; + if (content) { + _emberRuntimeMixinsArray.removeArrayObserver(content, this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + } + }, - var PopDynamicScopeOpcode = (function (_Opcode4) { - babelHelpers.inherits(PopDynamicScopeOpcode, _Opcode4); + /** + Override to implement content array `willChange` observer. + @method contentArrayWillChange + @param {Ember.Array} contentArray the content array + @param {Number} start starting index of the change + @param {Number} removeCount count of items removed + @param {Number} addCount count of items added + @private + */ + contentArrayWillChange: K, + /** + Override to implement content array `didChange` observer. + @method contentArrayDidChange + @param {Ember.Array} contentArray the content array + @param {Number} start starting index of the change + @param {Number} removeCount count of items removed + @param {Number} addCount count of items added + @private + */ + contentArrayDidChange: K, - function PopDynamicScopeOpcode() { - _Opcode4.apply(this, arguments); - this.type = "pop-dynamic-scope"; - } + /** + Invoked when the content property changes. Notifies observers that the + entire array content has changed. + @private + @method _contentDidChange + */ + _contentDidChange: _emberMetal.observer('content', function () { + var content = _emberMetal.get(this, 'content'); - PopDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.popDynamicScope(); - }; + this._setupContent(); + }), - return PopDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _setupContent: function () { + var content = _emberMetal.get(this, 'content'); - exports.PopDynamicScopeOpcode = PopDynamicScopeOpcode; + if (content) { - var PutNullOpcode = (function (_Opcode5) { - babelHelpers.inherits(PutNullOpcode, _Opcode5); + _emberRuntimeMixinsArray.addArrayObserver(content, this, { + willChange: 'contentArrayWillChange', + didChange: 'contentArrayDidChange' + }); + } + }, - function PutNullOpcode() { - _Opcode5.apply(this, arguments); - this.type = "put-null"; - } + _arrangedContentWillChange: _emberMetal._beforeObserver('arrangedContent', function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - PutNullOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setOperand(_glimmerRuntimeLibReferences.NULL_REFERENCE); - }; + this.arrangedContentArrayWillChange(this, 0, len, undefined); + this.arrangedContentWillChange(this); - return PutNullOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + this._teardownArrangedContent(arrangedContent); + }), - exports.PutNullOpcode = PutNullOpcode; + _arrangedContentDidChange: _emberMetal.observer('arrangedContent', function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; - var PutValueOpcode = (function (_Opcode6) { - babelHelpers.inherits(PutValueOpcode, _Opcode6); + this._setupArrangedContent(); - function PutValueOpcode(expression) { - _Opcode6.call(this); - this.expression = expression; - this.type = "put-value"; - } + this.arrangedContentDidChange(this); + this.arrangedContentArrayDidChange(this, 0, undefined, len); + }), - PutValueOpcode.prototype.evaluate = function evaluate(vm) { - vm.evaluateOperand(this.expression); - }; + _setupArrangedContent: function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - PutValueOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [this.expression.toJSON()] - }; - }; + if (arrangedContent) { - return PutValueOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, { + willChange: 'arrangedContentArrayWillChange', + didChange: 'arrangedContentArrayDidChange' + }); + } + }, - exports.PutValueOpcode = PutValueOpcode; + _teardownArrangedContent: function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); - var PutArgsOpcode = (function (_Opcode7) { - babelHelpers.inherits(PutArgsOpcode, _Opcode7); + if (arrangedContent) { + _emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, { + willChange: 'arrangedContentArrayWillChange', + didChange: 'arrangedContentArrayDidChange' + }); + } + }, - function PutArgsOpcode(args) { - _Opcode7.call(this); - this.args = args; - this.type = "put-args"; - } + arrangedContentWillChange: K, + arrangedContentDidChange: K, - PutArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.evaluateArgs(this.args); - }; + objectAt: function (idx) { + return _emberMetal.get(this, 'content') && this.objectAtContent(idx); + }, - PutArgsOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - details: { - "positional": this.args.positional.toJSON(), - "named": this.args.named.toJSON() - } - }; - }; + length: _emberMetal.computed(function () { + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + return arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0; + // No dependencies since Enumerable notifies length of change + }), - return PutArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + _replace: function (idx, amt, objects) { + var content = _emberMetal.get(this, 'content'); - exports.PutArgsOpcode = PutArgsOpcode; + if (content) { + this.replaceContent(idx, amt, objects); + } - var BindPositionalArgsOpcode = (function (_Opcode8) { - babelHelpers.inherits(BindPositionalArgsOpcode, _Opcode8); + return this; + }, - function BindPositionalArgsOpcode(names, symbols) { - _Opcode8.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-positional-args"; - } + replace: function () { + if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { + this._replace.apply(this, arguments); + } else { + throw new _emberMetal.Error('Using replace on an arranged ArrayProxy is not allowed.'); + } + }, - BindPositionalArgsOpcode.create = function create(block) { - var names = block.locals; - var symbols = names.map(function (name) { - return block.symbolTable.getLocal(name); - }); - return new this(names, symbols); - }; + _insertAt: function (idx, object) { + if (idx > _emberMetal.get(this, 'content.length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - BindPositionalArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindPositionalArgs(this.symbols); - }; + this._replace(idx, 0, [object]); + return this; + }, - BindPositionalArgsOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ['[' + this.names.map(function (name) { - return JSON.stringify(name); - }).join(", ") + ']'] - }; - }; + insertAt: function (idx, object) { + if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) { + return this._insertAt(idx, object); + } else { + throw new _emberMetal.Error('Using insertAt on an arranged ArrayProxy is not allowed.'); + } + }, - return BindPositionalArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + removeAt: function (start, len) { + if ('number' === typeof start) { + var content = _emberMetal.get(this, 'content'); + var arrangedContent = _emberMetal.get(this, 'arrangedContent'); + var indices = []; - exports.BindPositionalArgsOpcode = BindPositionalArgsOpcode; + if (start < 0 || start >= _emberMetal.get(this, 'length')) { + throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION); + } - var BindNamedArgsOpcode = (function (_Opcode9) { - babelHelpers.inherits(BindNamedArgsOpcode, _Opcode9); + if (len === undefined) { + len = 1; + } - function BindNamedArgsOpcode(names, symbols) { - _Opcode9.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-named-args"; + // Get a list of indices in original content to remove + for (var i = start; i < start + len; i++) { + // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent + indices.push(content.indexOf(_emberRuntimeMixinsArray.objectAt(arrangedContent, i))); } - BindNamedArgsOpcode.create = function create(layout) { - var names = layout.named; - var symbols = names.map(function (name) { - return layout.symbolTable.getNamed(name); - }); - return new this(names, symbols); - }; + // Replace in reverse order since indices will change + indices.sort(function (a, b) { + return b - a; + }); - BindNamedArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindNamedArgs(this.names, this.symbols); - }; + _emberMetal.beginPropertyChanges(); + for (var i = 0; i < indices.length; i++) { + this._replace(indices[i], 1, EMPTY); + } + _emberMetal.endPropertyChanges(); + } - BindNamedArgsOpcode.prototype.toJSON = function toJSON() { - var names = this.names; - var symbols = this.symbols; + return this; + }, - var args = names.map(function (name, i) { - return '$' + symbols[i] + ': $ARGS[' + name + ']'; - }); - return { - guid: this._guid, - type: this.type, - args: args - }; - }; + pushObject: function (obj) { + this._insertAt(_emberMetal.get(this, 'content.length'), obj); + return obj; + }, - return BindNamedArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + pushObjects: function (objects) { + if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || _emberRuntimeUtils.isArray(objects))) { + throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects'); + } + this._replace(_emberMetal.get(this, 'length'), 0, objects); + return this; + }, - exports.BindNamedArgsOpcode = BindNamedArgsOpcode; + setObjects: function (objects) { + if (objects.length === 0) { + return this.clear(); + } - var BindBlocksOpcode = (function (_Opcode10) { - babelHelpers.inherits(BindBlocksOpcode, _Opcode10); + var len = _emberMetal.get(this, 'length'); + this._replace(0, len, objects); + return this; + }, - function BindBlocksOpcode(names, symbols) { - _Opcode10.call(this); - this.names = names; - this.symbols = symbols; - this.type = "bind-blocks"; - } + unshiftObject: function (obj) { + this._insertAt(0, obj); + return obj; + }, - BindBlocksOpcode.create = function create(layout) { - var names = layout.yields; - var symbols = names.map(function (name) { - return layout.symbolTable.getYield(name); - }); - return new this(names, symbols); - }; + unshiftObjects: function (objects) { + this._replace(0, 0, objects); + return this; + }, - BindBlocksOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindBlocks(this.names, this.symbols); - }; + slice: function () { + var arr = this.toArray(); + return arr.slice.apply(arr, arguments); + }, - BindBlocksOpcode.prototype.toJSON = function toJSON() { - var names = this.names; - var symbols = this.symbols; + arrangedContentArrayWillChange: function (item, idx, removedCnt, addedCnt) { + this.arrayContentWillChange(idx, removedCnt, addedCnt); + }, - var args = names.map(function (name, i) { - return '$' + symbols[i] + ': $BLOCKS[' + name + ']'; - }); - return { - guid: this._guid, - type: this.type, - args: args - }; - }; + arrangedContentArrayDidChange: function (item, idx, removedCnt, addedCnt) { + this.arrayContentDidChange(idx, removedCnt, addedCnt); + }, - return BindBlocksOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + init: function () { + this._super.apply(this, arguments); + this._setupContent(); + this._setupArrangedContent(); + }, - exports.BindBlocksOpcode = BindBlocksOpcode; + willDestroy: function () { + this._teardownArrangedContent(); + this._teardownContent(); + } + }); +}); +enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/inject'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeInject) { + 'no use strict'; + // Remove "use strict"; from transpiled module until + // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed - var BindPartialArgsOpcode = (function (_Opcode11) { - babelHelpers.inherits(BindPartialArgsOpcode, _Opcode11); + /** + @module ember + @submodule ember-runtime + */ - function BindPartialArgsOpcode(symbol) { - _Opcode11.call(this); - this.symbol = symbol; - this.type = "bind-partial-args"; - } + // using ember-metal/lib/main here to ensure that ember-debug is setup + // if present - BindPartialArgsOpcode.create = function create(layout) { - return new this(layout.symbolTable.getPartialArgs()); - }; + var _Mixin$create, _ClassMixinProps; - BindPartialArgsOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindPartialArgs(this.symbol); - }; + var schedule = _emberMetal.run.schedule; + var applyMixin = _emberMetal.Mixin._apply; + var finishPartial = _emberMetal.Mixin.finishPartial; + var reopen = _emberMetal.Mixin.prototype.reopen; + var hasCachedComputedProperties = false; - return BindPartialArgsOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + var POST_INIT = _emberUtils.symbol('POST_INIT'); - exports.BindPartialArgsOpcode = BindPartialArgsOpcode; + exports.POST_INIT = POST_INIT; + function makeCtor() { + // Note: avoid accessing any properties on the object since it makes the + // method a lot faster. This is glue code so we want it to be as fast as + // possible. - var BindCallerScopeOpcode = (function (_Opcode12) { - babelHelpers.inherits(BindCallerScopeOpcode, _Opcode12); + var wasApplied = false; + var initProperties = undefined; - function BindCallerScopeOpcode() { - _Opcode12.apply(this, arguments); - this.type = "bind-caller-scope"; + var Class = (function () { + function Class() { + if (!wasApplied) { + Class.proto(); // prepare prototype... } - BindCallerScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindCallerScope(); - }; - - return BindCallerScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); - - exports.BindCallerScopeOpcode = BindCallerScopeOpcode; + if (arguments.length > 0) { + initProperties = [arguments[0]]; + } - var BindDynamicScopeOpcode = (function (_Opcode13) { - babelHelpers.inherits(BindDynamicScopeOpcode, _Opcode13); + this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); + var m = _emberMetal.meta(this); + var proto = m.proto; + m.proto = this; + if (initProperties) { + // capture locally so we can clear the closed over variable + var props = initProperties; + initProperties = null; - function BindDynamicScopeOpcode(names) { - _Opcode13.call(this); - this.names = names; - this.type = "bind-dynamic-scope"; - } + var concatenatedProperties = this.concatenatedProperties; + var mergedProperties = this.mergedProperties; - BindDynamicScopeOpcode.prototype.evaluate = function evaluate(vm) { - vm.bindDynamicScope(this.names); - }; + for (var i = 0; i < props.length; i++) { + var properties = props[i]; - return BindDynamicScopeOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (typeof properties !== 'object' && properties !== undefined) { + throw new _emberMetal.Error('Ember.Object.create only accepts objects.'); + } - exports.BindDynamicScopeOpcode = BindDynamicScopeOpcode; + if (!properties) { + continue; + } - var EnterOpcode = (function (_Opcode14) { - babelHelpers.inherits(EnterOpcode, _Opcode14); + var keyNames = Object.keys(properties); - function EnterOpcode(begin, end) { - _Opcode14.call(this); - this.type = "enter"; - this.slice = new _glimmerUtil.ListSlice(begin, end); - } + for (var j = 0; j < keyNames.length; j++) { + var keyName = keyNames[j]; + var value = properties[keyName]; - EnterOpcode.prototype.evaluate = function evaluate(vm) { - vm.enter(this.slice); - }; + if (_emberMetal.detectBinding(keyName)) { + m.writeBindings(keyName, value); + } - EnterOpcode.prototype.toJSON = function toJSON() { - var slice = this.slice; - var type = this.type; - var _guid = this._guid; + var possibleDesc = this[keyName]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - var begin = slice.head(); - var end = slice.tail(); - return { - guid: _guid, - type: type, - args: [JSON.stringify(begin.inspect()), JSON.stringify(end.inspect())] - }; - }; + if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) { + var baseValue = this[keyName]; - return EnterOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + if (baseValue) { + if ('function' === typeof baseValue.concat) { + value = baseValue.concat(value); + } else { + value = _emberUtils.makeArray(baseValue).concat(value); + } + } else { + value = _emberUtils.makeArray(value); + } + } - exports.EnterOpcode = EnterOpcode; + if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) { + var originalValue = this[keyName]; - var ExitOpcode = (function (_Opcode15) { - babelHelpers.inherits(ExitOpcode, _Opcode15); + value = _emberUtils.assign({}, originalValue, value); + } - function ExitOpcode() { - _Opcode15.apply(this, arguments); - this.type = "exit"; + if (desc) { + desc.set(this, keyName, value); + } else { + if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { + this.setUnknownProperty(keyName, value); + } else { + if (false) { + _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter + } else { + this[keyName] = value; + } + } + } + } + } } - ExitOpcode.prototype.evaluate = function evaluate(vm) { - vm.exit(); - }; + finishPartial(this, m); - return ExitOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + this.init.apply(this, arguments); - exports.ExitOpcode = ExitOpcode; + this[POST_INIT](); - var LabelOpcode = (function (_Opcode16) { - babelHelpers.inherits(LabelOpcode, _Opcode16); + m.proto = proto; + _emberMetal.finishChains(this); + _emberMetal.sendEvent(this, 'init'); + } - function LabelOpcode(label) { - _Opcode16.call(this); - this.tag = _glimmerReference.CONSTANT_TAG; - this.type = "label"; - this.label = null; - this.prev = null; - this.next = null; - if (label) this.label = label; + Class.willReopen = function willReopen() { + if (wasApplied) { + Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin); } - LabelOpcode.prototype.evaluate = function evaluate() {}; - - LabelOpcode.prototype.inspect = function inspect() { - return this.label + ' [' + this._guid + ']'; - }; - - LabelOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.inspect())] - }; - }; - - return LabelOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + wasApplied = false; + }; - exports.LabelOpcode = LabelOpcode; + Class._initProperties = function _initProperties(args) { + initProperties = args; + }; - var EvaluateOpcode = (function (_Opcode17) { - babelHelpers.inherits(EvaluateOpcode, _Opcode17); + Class.proto = function proto() { + var superclass = Class.superclass; + if (superclass) { + superclass.proto(); + } - function EvaluateOpcode(debug, block) { - _Opcode17.call(this); - this.debug = debug; - this.block = block; - this.type = "evaluate"; + if (!wasApplied) { + wasApplied = true; + Class.PrototypeMixin.applyPartial(Class.prototype); } - EvaluateOpcode.prototype.evaluate = function evaluate(vm) { - vm.invokeBlock(this.block, vm.frame.getArgs()); - }; + return this.prototype; + }; - EvaluateOpcode.prototype.toJSON = function toJSON() { - var guid = this._guid; - var type = this.type; - var debug = this.debug; - var block = this.block; - - var compiled = block['compiled']; - var children = undefined; - if (compiled) { - children = compiled.ops.toArray().map(function (op) { - return op.toJSON(); - }); - } else { - children = [{ guid: null, type: '[ UNCOMPILED BLOCK ]' }]; - } - return { - guid: guid, - type: type, - args: [debug], - children: children - }; - }; + return Class; + })(); - return EvaluateOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + Class.toString = _emberMetal.Mixin.prototype.toString; - exports.EvaluateOpcode = EvaluateOpcode; - var ConstTest = function (ref, env) { - return new _glimmerReference.ConstReference(!!ref.value()); - }; - exports.ConstTest = ConstTest; - var SimpleTest = function (ref, env) { - return ref; - }; - exports.SimpleTest = SimpleTest; - var EnvironmentTest = function (ref, env) { - return env.toConditionalReference(ref); - }; - exports.EnvironmentTest = EnvironmentTest; + return Class; + } + + /** + @class CoreObject + @namespace Ember + @public + */ + var CoreObject = makeCtor(); + CoreObject.toString = function () { + return 'Ember.CoreObject'; + }; + CoreObject.PrototypeMixin = _emberMetal.Mixin.create((_Mixin$create = { + reopen: function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - var TestOpcode = (function (_Opcode18) { - babelHelpers.inherits(TestOpcode, _Opcode18); + applyMixin(this, args, true); + return this; + }, - function TestOpcode(testFunc) { - _Opcode18.call(this); - this.testFunc = testFunc; - this.type = "test"; + /** + An overridable method called when objects are instantiated. By default, + does nothing unless it is overridden during class definition. + Example: + ```javascript + const Person = Ember.Object.extend({ + init() { + alert(`Name is ${this.get('name')}`); } + }); + let steve = Person.create({ + name: "Steve" + }); + // alerts 'Name is Steve'. + ``` + NOTE: If you do override `init` for a framework class like `Ember.View`, + be sure to call `this._super(...arguments)` in your + `init` declaration! If you don't, Ember may not have an opportunity to + do important setup work, and you'll see strange behavior in your + application. + @method init + @public + */ + init: function () {} - TestOpcode.prototype.evaluate = function evaluate(vm) { - vm.frame.setCondition(this.testFunc(vm.frame.getOperand(), vm.env)); - }; + }, _Mixin$create[POST_INIT] = function () {}, _Mixin$create.__defineNonEnumerable = function (property) { + Object.defineProperty(this, property.name, property.descriptor); + //this[property.name] = property.descriptor.value; + }, _Mixin$create.concatenatedProperties = null, _Mixin$create.mergedProperties = null, _Mixin$create.isDestroyed = _emberMetal.descriptor({ + get: function () { + return _emberMetal.meta(this).isSourceDestroyed(); + }, - TestOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: ["$OPERAND", this.testFunc.name] - }; - }; + set: function (value) { + // prevent setting while applying mixins + if (typeof value === 'object' && value !== null && value.isDescriptor) { + return; + } + } + }), _Mixin$create.isDestroying = _emberMetal.descriptor({ + get: function () { + return _emberMetal.meta(this).isSourceDestroying(); + }, - return TestOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + set: function (value) { + // prevent setting while applying mixins + if (typeof value === 'object' && value !== null && value.isDescriptor) { + return; + } + } + }), _Mixin$create.destroy = function () { + var m = _emberMetal.meta(this); + if (m.isSourceDestroying()) { + return; + } - exports.TestOpcode = TestOpcode; + m.setSourceDestroying(); - var JumpOpcode = (function (_Opcode19) { - babelHelpers.inherits(JumpOpcode, _Opcode19); + schedule('actions', this, this.willDestroy); + schedule('destroy', this, this._scheduledDestroy, m); - function JumpOpcode(target) { - _Opcode19.call(this); - this.target = target; - this.type = "jump"; - } + return this; + }, _Mixin$create.willDestroy = function () {}, _Mixin$create._scheduledDestroy = function (m) { + if (m.isSourceDestroyed()) { + return; + } + _emberMetal.destroy(this); + m.setSourceDestroyed(); + }, _Mixin$create.bind = function (to, from) { + if (!(from instanceof _emberMetal.Binding)) { + from = _emberMetal.Binding.from(from); + } + from.to(to).connect(this); + return from; + }, _Mixin$create.toString = function () { + var hasToStringExtension = typeof this.toStringExtension === 'function'; + var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; + var ret = '<' + (this[_emberUtils.NAME_KEY] || this.constructor.toString()) + ':' + _emberUtils.guidFor(this) + extension + '>'; - JumpOpcode.prototype.evaluate = function evaluate(vm) { - vm.goto(this.target); - }; + return ret; + }, _Mixin$create)); - JumpOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.target.inspect())] - }; - }; + CoreObject.PrototypeMixin.ownerConstructor = CoreObject; - return JumpOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + CoreObject.__super__ = null; - exports.JumpOpcode = JumpOpcode; + var ClassMixinProps = (_ClassMixinProps = { - var JumpIfOpcode = (function (_JumpOpcode) { - babelHelpers.inherits(JumpIfOpcode, _JumpOpcode); + ClassMixin: _emberMetal.REQUIRED, - function JumpIfOpcode() { - _JumpOpcode.apply(this, arguments); - this.type = "jump-if"; - } + PrototypeMixin: _emberMetal.REQUIRED, - JumpIfOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getCondition(); - if (_glimmerReference.isConst(reference)) { - if (reference.value()) { - _JumpOpcode.prototype.evaluate.call(this, vm); - } - } else { - var cache = new _glimmerReference.ReferenceCache(reference); - if (cache.peek()) { - _JumpOpcode.prototype.evaluate.call(this, vm); - } - vm.updateWith(new Assert(cache)); - } - }; + isClass: true, - return JumpIfOpcode; - })(JumpOpcode); + isMethod: false + }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { + var Class = makeCtor(); + var proto = undefined; + Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); + Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); - exports.JumpIfOpcode = JumpIfOpcode; + Class.ClassMixin.ownerConstructor = Class; + Class.PrototypeMixin.ownerConstructor = Class; - var JumpUnlessOpcode = (function (_JumpOpcode2) { - babelHelpers.inherits(JumpUnlessOpcode, _JumpOpcode2); + reopen.apply(Class.PrototypeMixin, arguments); - function JumpUnlessOpcode() { - _JumpOpcode2.apply(this, arguments); - this.type = "jump-unless"; - } + Class.superclass = this; + Class.__super__ = this.prototype; - JumpUnlessOpcode.prototype.evaluate = function evaluate(vm) { - var reference = vm.frame.getCondition(); - if (_glimmerReference.isConst(reference)) { - if (!reference.value()) { - _JumpOpcode2.prototype.evaluate.call(this, vm); - } - } else { - var cache = new _glimmerReference.ReferenceCache(reference); - if (!cache.peek()) { - _JumpOpcode2.prototype.evaluate.call(this, vm); - } - vm.updateWith(new Assert(cache)); - } - }; + proto = Class.prototype = Object.create(this.prototype); + proto.constructor = Class; + _emberUtils.generateGuid(proto); + _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype - return JumpUnlessOpcode; - })(JumpOpcode); + Class.ClassMixin.apply(Class); + return Class; + }, _ClassMixinProps.create = function () { + var C = this; - exports.JumpUnlessOpcode = JumpUnlessOpcode; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - var Assert = (function (_UpdatingOpcode) { - babelHelpers.inherits(Assert, _UpdatingOpcode); + if (args.length > 0) { + this._initProperties(args); + } + return new C(); + }, _ClassMixinProps.reopen = function () { + this.willReopen(); + reopen.apply(this.PrototypeMixin, arguments); + return this; + }, _ClassMixinProps.reopenClass = function () { + reopen.apply(this.ClassMixin, arguments); + applyMixin(this, arguments, false); + return this; + }, _ClassMixinProps.detect = function (obj) { + if ('function' !== typeof obj) { + return false; + } + while (obj) { + if (obj === this) { + return true; + } + obj = obj.superclass; + } + return false; + }, _ClassMixinProps.detectInstance = function (obj) { + return obj instanceof this; + }, _ClassMixinProps.metaForProperty = function (key) { + var proto = this.proto(); + var possibleDesc = proto[key]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - function Assert(cache) { - _UpdatingOpcode.call(this); - this.type = "assert"; - this.tag = cache.tag; - this.cache = cache; - } + return desc._meta || {}; + }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { + hasCachedComputedProperties = true; + var proto = this.proto(); + var property = undefined; + var properties = []; - Assert.prototype.evaluate = function evaluate(vm) { - var cache = this.cache; + for (var _name in proto) { + property = proto[_name]; - if (_glimmerReference.isModified(cache.revalidate())) { - vm.throw(); - } - }; + if (property && property.isDescriptor) { + properties.push({ + name: _name, + meta: property._meta + }); + } + } + return properties; + }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { + var property = undefined; + var empty = {}; - Assert.prototype.toJSON = function toJSON() { - var type = this.type; - var _guid = this._guid; - var cache = this.cache; + var properties = _emberMetal.get(this, '_computedProperties'); - var expected = undefined; - try { - expected = JSON.stringify(cache.peek()); - } catch (e) { - expected = String(cache.peek()); - } - return { - guid: _guid, - type: type, - args: [], - details: { expected: expected } - }; - }; + for (var i = 0; i < properties.length; i++) { + property = properties[i]; + callback.call(binding || this, property.name, property.meta || empty); + } + }, _ClassMixinProps); - return Assert; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + function injectedPropertyAssertion() {} - exports.Assert = Assert; + /** + Returns a hash of property names and container names that injected + properties will lookup on the container lazily. + + @method _lazyInjections + @return {Object} Hash of all lazy injected property keys to container names + @private + */ + ClassMixinProps._lazyInjections = function () { + var injections = {}; + var proto = this.proto(); + var key = undefined; + var desc = undefined; - var JumpIfNotModifiedOpcode = (function (_UpdatingOpcode2) { - babelHelpers.inherits(JumpIfNotModifiedOpcode, _UpdatingOpcode2); + for (key in proto) { + desc = proto[key]; + if (desc instanceof _emberMetal.InjectedProperty) { + injections[key] = desc.type + ':' + (desc.name || key); + } + } - function JumpIfNotModifiedOpcode(tag, target) { - _UpdatingOpcode2.call(this); - this.target = target; - this.type = "jump-if-not-modified"; - this.tag = tag; - this.lastRevision = tag.value(); - } + return injections; + }; - JumpIfNotModifiedOpcode.prototype.evaluate = function evaluate(vm) { - var tag = this.tag; - var target = this.target; - var lastRevision = this.lastRevision; + var ClassMixin = _emberMetal.Mixin.create(ClassMixinProps); - if (!vm.alwaysRevalidate && tag.validate(lastRevision)) { - vm.goto(target); - } - }; + ClassMixin.ownerConstructor = CoreObject; - JumpIfNotModifiedOpcode.prototype.didModify = function didModify() { - this.lastRevision = this.tag.value(); - }; + CoreObject.ClassMixin = ClassMixin; - JumpIfNotModifiedOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - args: [JSON.stringify(this.target.inspect())] - }; - }; + ClassMixin.apply(CoreObject); - return JumpIfNotModifiedOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + CoreObject.reopen({ + didDefineProperty: function (proto, key, value) { + if (hasCachedComputedProperties === false) { + return; + } + if (value instanceof _emberMetal.ComputedProperty) { + var cache = _emberMetal.meta(this.constructor).readableCache(); - exports.JumpIfNotModifiedOpcode = JumpIfNotModifiedOpcode; + if (cache && cache._computedProperties !== undefined) { + cache._computedProperties = undefined; + } + } + } + }); - var DidModifyOpcode = (function (_UpdatingOpcode3) { - babelHelpers.inherits(DidModifyOpcode, _UpdatingOpcode3); + exports.default = CoreObject; +}); +// Private, and only for didInitAttrs willRecieveAttrs - function DidModifyOpcode(target) { - _UpdatingOpcode3.call(this); - this.target = target; - this.type = "did-modify"; - this.tag = _glimmerReference.CONSTANT_TAG; - } +/** + Defines the properties that will be concatenated from the superclass + (instead of overridden). + By default, when you extend an Ember class a property defined in + the subclass overrides a property with the same name that is defined + in the superclass. However, there are some cases where it is preferable + to build up a property's value by combining the superclass' property + value with the subclass' value. An example of this in use within Ember + is the `classNames` property of `Ember.View`. + Here is some sample code showing the difference between a concatenated + property and a normal one: + ```javascript + const Bar = Ember.Object.extend({ + // Configure which properties to concatenate + concatenatedProperties: ['concatenatedProperty'], + someNonConcatenatedProperty: ['bar'], + concatenatedProperty: ['bar'] + }); + const FooBar = Bar.extend({ + someNonConcatenatedProperty: ['foo'], + concatenatedProperty: ['foo'] + }); + let fooBar = FooBar.create(); + fooBar.get('someNonConcatenatedProperty'); // ['foo'] + fooBar.get('concatenatedProperty'); // ['bar', 'foo'] + ``` + This behavior extends to object creation as well. Continuing the + above example: + ```javascript + let fooBar = FooBar.create({ + someNonConcatenatedProperty: ['baz'], + concatenatedProperty: ['baz'] + }) + fooBar.get('someNonConcatenatedProperty'); // ['baz'] + fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] + ``` + Adding a single property that is not an array will just add it in the array: + ```javascript + let fooBar = FooBar.create({ + concatenatedProperty: 'baz' + }) + view.get('concatenatedProperty'); // ['bar', 'foo', 'baz'] + ``` + Using the `concatenatedProperties` property, we can tell Ember to mix the + content of the properties. + In `Ember.Component` the `classNames`, `classNameBindings` and + `attributeBindings` properties are concatenated. + This feature is available for you to use throughout the Ember object model, + although typical app developers are likely to use it infrequently. Since + it changes expectations about behavior of properties, you should properly + document its usage in each individual concatenated property (to not + mislead your users to think they can override the property in a subclass). + @property concatenatedProperties + @type Array + @default null + @public +*/ - DidModifyOpcode.prototype.evaluate = function evaluate() { - this.target.didModify(); - }; +/** + Defines the properties that will be merged from the superclass + (instead of overridden). + By default, when you extend an Ember class a property defined in + the subclass overrides a property with the same name that is defined + in the superclass. However, there are some cases where it is preferable + to build up a property's value by merging the superclass property value + with the subclass property's value. An example of this in use within Ember + is the `queryParams` property of routes. + Here is some sample code showing the difference between a merged + property and a normal one: + ```javascript + const Bar = Ember.Object.extend({ + // Configure which properties are to be merged + mergedProperties: ['mergedProperty'], + someNonMergedProperty: { + nonMerged: 'superclass value of nonMerged' + }, + mergedProperty: { + page: {replace: false}, + limit: {replace: true} + } + }); + const FooBar = Bar.extend({ + someNonMergedProperty: { + completelyNonMerged: 'subclass value of nonMerged' + }, + mergedProperty: { + limit: {replace: false} + } + }); + let fooBar = FooBar.create(); + fooBar.get('someNonMergedProperty'); + // => { completelyNonMerged: 'subclass value of nonMerged' } + // + // Note the entire object, including the nonMerged property of + // the superclass object, has been replaced + fooBar.get('mergedProperty'); + // => { + // page: {replace: false}, + // limit: {replace: false} + // } + // + // Note the page remains from the superclass, and the + // `limit` property's value of `false` has been merged from + // the subclass. + ``` + This behavior is not available during object `create` calls. It is only + available at `extend` time. + In `Ember.Route` the `queryParams` property is merged. + This feature is available for you to use throughout the Ember object model, + although typical app developers are likely to use it infrequently. Since + it changes expectations about behavior of properties, you should properly + document its usage in each individual merged property (to not + mislead your users to think they can override the property in a subclass). + @property mergedProperties + @type Array + @default null + @public +*/ - return DidModifyOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); +/** + Destroyed object property flag. + if this property is `true` the observers and bindings were already + removed by the effect of calling the `destroy()` method. + @property isDestroyed + @default false + @public +*/ - exports.DidModifyOpcode = DidModifyOpcode; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZWQvb3Bjb2Rlcy92bS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFXQSxvQkFBQTs4QkFBQSxvQkFBQTs7QUFBQSxpQkFBQSxvQkFBQSxHQUFBO0FBQTBDLGdDQUFBLFNBQUEsQ0FBQSxDQUFNO0FBQ3ZDLGdCQUFBLENBQUEsSUFBSSxHQUFHL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ZGlkTW9kaWZ5KCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/compiler', ['exports', 'glimmer-util', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-runtime/lib/compiled/expressions/function', 'glimmer-runtime/lib/compiled/opcodes/builder'], function (exports, _glimmerUtil, _glimmerRuntimeLibUtils, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibCompiledBlocks, _glimmerRuntimeLibCompiledExpressionsFunction, _glimmerRuntimeLibCompiledOpcodesBuilder) { - 'use strict'; +/** + Destruction scheduled flag. The `destroy()` method has been called. + The object stays intact until the end of the run loop at which point + the `isDestroyed` flag is set. + @property isDestroying + @default false + @public +*/ - exports.compileLayout = compileLayout; +/** + Destroys an object by setting the `isDestroyed` flag and removing its + metadata, which effectively destroys observers and bindings. + If you try to set a property on a destroyed object, an exception will be + raised. + Note that destruction is scheduled for the end of the run loop and does not + happen immediately. It will set an isDestroying flag immediately. + @method destroy + @return {Ember.Object} receiver + @public +*/ - var Compiler = (function () { - function Compiler(block, env) { - this.block = block; - this.env = env; - this.current = block.program.head(); - this.symbolTable = block.symbolTable; - } +/** + Override to implement teardown. + @method willDestroy + @public +*/ - Compiler.prototype.compileStatement = function compileStatement(statement, ops) { - this.env.statement(statement, this.symbolTable).compile(ops, this.env, this.symbolTable); - }; +/** + Invoked by the run loop to actually destroy the object. This is + scheduled for execution by the `destroy` method. + @private + @method _scheduledDestroy +*/ - return Compiler; - })(); +/** + Returns a string representation which attempts to provide more information + than Javascript's `toString` typically does, in a generic way for all Ember + objects. + ```javascript + const Person = Ember.Object.extend() + person = Person.create() + person.toString() //=> "" + ``` + If the object's class is not defined on an Ember namespace, it will + indicate it is a subclass of the registered superclass: + ```javascript + const Student = Person.extend() + let student = Student.create() + student.toString() //=> "<(subclass of Person):ember1025>" + ``` + If the method `toStringExtension` is defined, its return value will be + included in the output. + ```javascript + const Teacher = Person.extend({ + toStringExtension() { + return this.get('fullName'); + } + }); + teacher = Teacher.create() + teacher.toString(); //=> "" + ``` + @method toString + @return {String} string representation + @public +*/ - function compileStatement(env, statement, ops, layout) { - env.statement(statement, layout.symbolTable).compile(ops, env, layout.symbolTable); +/** + Creates a new subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(thing); + } + }); + ``` + This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. + You can also create a subclass from any existing class by calling its `extend()` method. + For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: + ```javascript + const PersonComponent = Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isAdministrator'] + }); + ``` + When defining a subclass, you can override methods but still access the + implementation of your parent class by calling the special `_super()` method: + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + let name = this.get('name'); + alert(`${name} says: ${thing}`); + } + }); + const Soldier = Person.extend({ + say(thing) { + this._super(`${thing}, sir!`); + }, + march(numberOfHours) { + alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + } + }); + let yehuda = Soldier.create({ + name: "Yehuda Katz" + }); + yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" + ``` + The `create()` on line #17 creates an *instance* of the `Soldier` class. + The `extend()` on line #8 creates a *subclass* of `Person`. Any instance + of the `Person` class will *not* have the `march()` method. + You can also pass `Mixin` classes to add additional properties to the subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(`${this.get('name')} says: ${thing}`); + } + }); + const SingingMixin = Mixin.create({ + sing(thing){ + alert(`${this.get('name')} sings: la la la ${thing}`); + } + }); + const BroadwayStar = Person.extend(SingingMixin, { + dance() { + alert(`${this.get('name')} dances: tap tap tap tap `); } - exports.default = Compiler; + }); + ``` + The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. + @method extend + @static + @param {Mixin} [mixins]* One or more Mixin classes + @param {Object} [arguments]* Object containing values to use within the new class + @public +*/ - var EntryPointCompiler = (function (_Compiler) { - babelHelpers.inherits(EntryPointCompiler, _Compiler); +/** + Creates an instance of a class. Accepts either no arguments, or an object + containing values to initialize the newly instantiated object with. + ```javascript + const Person = Ember.Object.extend({ + helloWorld() { + alert(`Hi, my name is ${this.get('name')}`); + } + }); + let tom = Person.create({ + name: 'Tom Dale' + }); + tom.helloWorld(); // alerts "Hi, my name is Tom Dale". + ``` + `create` will call the `init` function if defined during + `Ember.AnyObject.extend` + If no arguments are passed to `create`, it will not set values to the new + instance during initialization: + ```javascript + let noName = Person.create(); + noName.helloWorld(); // alerts undefined + ``` + NOTE: For performance reasons, you cannot declare methods or computed + properties during `create`. You should instead declare methods and computed + properties when using `extend`. + @method create + @static + @param [arguments]* + @public +*/ - function EntryPointCompiler(template, env) { - _Compiler.call(this, template, env); - var list = new CompileIntoList(env, template.symbolTable); - this.ops = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(list, template.symbolTable, env); - } +/** + Augments a constructor's prototype with additional + properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + o = MyObject.create(); + o.get('name'); // 'an object' + MyObject.reopen({ + say(msg){ + console.log(msg); + } + }) + o2 = MyObject.create(); + o2.say("hello"); // logs "hello" + o.say("goodbye"); // logs "goodbye" + ``` + To add functions and properties to the constructor itself, + see `reopenClass` + @method reopen + @public +*/ - EntryPointCompiler.prototype.compile = function compile() { - var block = this.block; - var ops = this.ops; - var program = block.program; +/** + Augments a constructor's own properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + MyObject.reopenClass({ + canBuild: false + }); + MyObject.canBuild; // false + o = MyObject.create(); + ``` + In other words, this creates static properties and functions for the class. + These are only available on the class and not on any instance of that class. + ```javascript + const Person = Ember.Object.extend({ + name: "", + sayHello() { + alert("Hello. My name is " + this.get('name')); + } + }); + Person.reopenClass({ + species: "Homo sapiens", + createPerson(newPersonsName){ + return Person.create({ + name:newPersonsName + }); + } + }); + let tom = Person.create({ + name: "Tom Dale" + }); + let yehuda = Person.createPerson("Yehuda Katz"); + tom.sayHello(); // "Hello. My name is Tom Dale" + yehuda.sayHello(); // "Hello. My name is Yehuda Katz" + alert(Person.species); // "Homo sapiens" + ``` + Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` + variables. They are only valid on `Person`. + To add functions and properties to instances of + a constructor by extending the constructor's prototype + see `reopen` + @method reopenClass + @public +*/ - var current = program.head(); - while (current) { - var next = program.nextNode(current); - this.compileStatement(current, ops); - current = next; - } - return ops.toOpSeq(); - }; +/** + 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: + ```javascript + person: Ember.computed(function() { + let personId = this.get('personId'); + return Person.create({ id: personId }); + }).meta({ type: Person }) + ``` + Once you've done this, you can retrieve the values saved to the computed + property from your class like this: + ```javascript + MyClass.metaForProperty('person'); + ``` + This will return the original hash that was passed to `meta()`. + @static + @method metaForProperty + @param key {String} property name + @private +*/ - EntryPointCompiler.prototype.append = function append(op) { - this.ops.append(op); - }; +/** + Iterate over each computed property for the class, passing its name + and any associated metadata (see `metaForProperty`) to the callback. + @static + @method eachComputedProperty + @param {Function} callback + @param {Object} binding + @private +*/ - EntryPointCompiler.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.symbolTable.getLocal(name); - }; +/** + Provides lookup-time type validation for injected properties. + @private + @method _onLookup +*/ +enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { + 'use strict'; - EntryPointCompiler.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.symbolTable.getNamed(name); - }; + exports.default = EachProxy; - EntryPointCompiler.prototype.getYieldSymbol = function getYieldSymbol(name) { - return this.symbolTable.getYield(name); - }; + /** + This is the object instance returned when you get the `@each` property on an + array. It uses the unknownProperty handler to automatically create + EachArray instances for property names. + @class EachProxy + @private + */ - return EntryPointCompiler; - })(Compiler); + function EachProxy(content) { + this._content = content; + this._keys = undefined; + this.__ember_meta__ = null; + } - exports.EntryPointCompiler = EntryPointCompiler; + EachProxy.prototype = { + __defineNonEnumerable: function (property) { + this[property.name] = property.descriptor.value; + }, - var InlineBlockCompiler = (function (_Compiler2) { - babelHelpers.inherits(InlineBlockCompiler, _Compiler2); + // .......................................................... + // ARRAY CHANGES + // Invokes whenever the content array itself changes. - function InlineBlockCompiler(block, env) { - _Compiler2.call(this, block, env); - this.block = block; - var list = new CompileIntoList(env, block.symbolTable); - this.ops = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(list, block.symbolTable, env); + arrayWillChange: function (content, idx, removedCnt, addedCnt) { + var keys = this._keys; + var lim = removedCnt > 0 ? idx + removedCnt : -1; + for (var key in keys) { + if (lim > 0) { + removeObserverForContentKey(content, key, this, idx, lim); } + _emberMetal.propertyWillChange(this, key); + } + }, - InlineBlockCompiler.prototype.compile = function compile() { - var block = this.block; - var ops = this.ops; - var program = block.program; - - var hasPositionalParameters = block.hasPositionalParameters(); - if (hasPositionalParameters) { - ops.pushChildScope(); - ops.bindPositionalArgsForBlock(block); - } - var current = program.head(); - while (current) { - var next = program.nextNode(current); - this.compileStatement(current, ops); - current = next; - } - if (hasPositionalParameters) { - ops.popScope(); - } - return ops.toOpSeq(); - }; - - return InlineBlockCompiler; - })(Compiler); - - exports.InlineBlockCompiler = InlineBlockCompiler; - - function compileLayout(compilable, env) { - var builder = new ComponentLayoutBuilder(env); - compilable.compile(builder); - return builder.compile(); - } - - var ComponentLayoutBuilder = (function () { - function ComponentLayoutBuilder(env) { - this.env = env; + arrayDidChange: function (content, idx, removedCnt, addedCnt) { + var keys = this._keys; + var lim = addedCnt > 0 ? idx + addedCnt : -1; + for (var key in keys) { + if (lim > 0) { + addObserverForContentKey(content, key, this, idx, lim); } + _emberMetal.propertyDidChange(this, key); + } + }, - ComponentLayoutBuilder.prototype.empty = function empty() { - this.inner = new EmptyBuilder(this.env); - }; - - ComponentLayoutBuilder.prototype.wrapLayout = function wrapLayout(layout) { - this.inner = new WrappedBuilder(this.env, layout); - }; - - ComponentLayoutBuilder.prototype.fromLayout = function fromLayout(layout) { - this.inner = new UnwrappedBuilder(this.env, layout); - }; - - ComponentLayoutBuilder.prototype.compile = function compile() { - return this.inner.compile(); - }; + // .......................................................... + // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS + // Start monitoring keys based on who is listening... - babelHelpers.createClass(ComponentLayoutBuilder, [{ - key: 'tag', - get: function () { - return this.inner.tag; - } - }, { - key: 'attrs', - get: function () { - return this.inner.attrs; - } - }]); - return ComponentLayoutBuilder; - })(); + willWatchProperty: function (property) { + this.beginObservingContentKey(property); + }, - var EmptyBuilder = (function () { - function EmptyBuilder(env) { - this.env = env; - } + didUnwatchProperty: function (property) { + this.stopObservingContentKey(property); + }, - EmptyBuilder.prototype.compile = function compile() { - var env = this.env; + // .......................................................... + // CONTENT KEY OBSERVING + // Actual watch keys on the source content. - var list = new CompileIntoList(env, null); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(list, 0); - }; + beginObservingContentKey: function (keyName) { + var keys = this._keys; + if (!keys) { + keys = this._keys = new _emberUtils.EmptyObject(); + } - babelHelpers.createClass(EmptyBuilder, [{ - key: 'tag', - get: function () { - throw new Error('Nope'); - } - }, { - key: 'attrs', - get: function () { - throw new Error('Nope'); - } - }]); - return EmptyBuilder; - })(); + if (!keys[keyName]) { + keys[keyName] = 1; + var content = this._content; + var len = _emberMetal.get(content, 'length'); - var WrappedBuilder = (function () { - function WrappedBuilder(env, layout) { - this.env = env; - this.layout = layout; - this.tag = new ComponentTagBuilder(); - this.attrs = new ComponentAttrsBuilder(); - } - - WrappedBuilder.prototype.compile = function compile() { - //========DYNAMIC - // PutValue(TagExpr) - // Test - // JumpUnless(BODY) - // OpenDynamicPrimitiveElement - // DidCreateElement - // ...attr statements... - // FlushElement - // BODY: Noop - // ...body statements... - // PutValue(TagExpr) - // Test - // JumpUnless(END) - // CloseElement - // END: Noop - // DidRenderLayout - // Exit - // - //========STATIC - // OpenPrimitiveElementOpcode - // DidCreateElement - // ...attr statements... - // FlushElement - // ...body statements... - // CloseElement - // DidRenderLayout - // Exit - var env = this.env; - var layout = this.layout; - - var symbolTable = layout.symbolTable; - var buffer = new CompileIntoList(env, layout.symbolTable); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, layout.symbolTable, env); - dsl.startLabels(); - if (this.tag.isDynamic) { - dsl.putValue(this.tag.dynamicTagName); - dsl.test('simple'); - dsl.jumpUnless('BODY'); - dsl.openDynamicPrimitiveElement(); - dsl.didCreateElement(); - this.attrs['buffer'].forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - dsl.flushElement(); - dsl.label('BODY'); - } else if (this.tag.isStatic) { - var tag = this.tag.staticTagName; - dsl.openPrimitiveElement(tag); - dsl.didCreateElement(); - this.attrs['buffer'].forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - dsl.flushElement(); - } - dsl.preludeForLayout(layout); - layout.program.forEachNode(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - if (this.tag.isDynamic) { - dsl.putValue(this.tag.dynamicTagName); - dsl.test('simple'); - dsl.jumpUnless('END'); - dsl.closeElement(); - dsl.label('END'); - } else if (this.tag.isStatic) { - dsl.closeElement(); - } - dsl.didRenderLayout(); - dsl.stopLabels(); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(dsl.toOpSeq(), symbolTable.size); - }; + addObserverForContentKey(content, keyName, this, 0, len); + } else { + keys[keyName]++; + } + }, - return WrappedBuilder; - })(); + stopObservingContentKey: function (keyName) { + var keys = this._keys; + if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) { + var content = this._content; + var len = _emberMetal.get(content, 'length'); - var UnwrappedBuilder = (function () { - function UnwrappedBuilder(env, layout) { - this.env = env; - this.layout = layout; - this.attrs = new ComponentAttrsBuilder(); - } - - UnwrappedBuilder.prototype.compile = function compile() { - var env = this.env; - var layout = this.layout; - - var buffer = new CompileIntoList(env, layout.symbolTable); - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(buffer, layout.symbolTable, env); - dsl.startLabels(); - dsl.preludeForLayout(layout); - var attrs = this.attrs['buffer']; - var attrsInserted = false; - this.layout.program.forEachNode(function (statement) { - if (!attrsInserted && isOpenElement(statement)) { - dsl.openComponentElement(statement.tag); - dsl.didCreateElement(); - dsl.shadowAttributes(); - attrs.forEach(function (statement) { - return compileStatement(env, statement, dsl, layout); - }); - attrsInserted = true; - } else { - compileStatement(env, statement, dsl, layout); - } - }); - dsl.didRenderLayout(); - dsl.stopLabels(); - return new _glimmerRuntimeLibCompiledBlocks.CompiledBlock(dsl.toOpSeq(), layout.symbolTable.size); - }; + removeObserverForContentKey(content, keyName, this, 0, len); + } + }, - babelHelpers.createClass(UnwrappedBuilder, [{ - key: 'tag', - get: function () { - throw new Error('BUG: Cannot call `tag` on an UnwrappedBuilder'); - } - }]); - return UnwrappedBuilder; - })(); + contentKeyWillChange: function (obj, keyName) { + _emberMetal.propertyWillChange(this, keyName); + }, - function isOpenElement(syntax) { - return syntax instanceof _glimmerRuntimeLibSyntaxCore.OpenElement || syntax instanceof _glimmerRuntimeLibSyntaxCore.OpenPrimitiveElement; + contentKeyDidChange: function (obj, keyName) { + _emberMetal.propertyDidChange(this, keyName); } + }; - var ComponentTagBuilder = (function () { - function ComponentTagBuilder() { - this.isDynamic = null; - this.isStatic = null; - this.staticTagName = null; - this.dynamicTagName = null; - } - - ComponentTagBuilder.prototype.static = function _static(tagName) { - this.isStatic = true; - this.staticTagName = tagName; - }; - - ComponentTagBuilder.prototype.dynamic = function dynamic(tagName) { - this.isDynamic = true; - this.dynamicTagName = _glimmerRuntimeLibCompiledExpressionsFunction.default(tagName); - }; - - return ComponentTagBuilder; - })(); - - var ComponentAttrsBuilder = (function () { - function ComponentAttrsBuilder() { - this.buffer = []; - } - - ComponentAttrsBuilder.prototype.static = function _static(name, value) { - this.buffer.push(new _glimmerRuntimeLibSyntaxCore.StaticAttr(name, value, null)); - }; - - ComponentAttrsBuilder.prototype.dynamic = function dynamic(name, value) { - this.buffer.push(new _glimmerRuntimeLibSyntaxCore.DynamicAttr(name, _glimmerRuntimeLibCompiledExpressionsFunction.default(value), null, false)); - }; - - return ComponentAttrsBuilder; - })(); - - var ComponentBuilder = (function () { - function ComponentBuilder(dsl) { - this.dsl = dsl; - this.env = dsl.env; - } - - ComponentBuilder.prototype.static = function _static(definition, args, symbolTable) { - var shadow = arguments.length <= 3 || arguments[3] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[3]; - - this.dsl.unit(function (dsl) { - dsl.putComponentDefinition(definition); - dsl.openComponent(args, shadow); - dsl.closeComponent(); - }); - }; - - ComponentBuilder.prototype.dynamic = function dynamic(definitionArgs, definition, args, symbolTable) { - var shadow = arguments.length <= 4 || arguments[4] === undefined ? _glimmerRuntimeLibUtils.EMPTY_ARRAY : arguments[4]; - - this.dsl.unit(function (dsl) { - dsl.putArgs(definitionArgs); - dsl.putValue(_glimmerRuntimeLibCompiledExpressionsFunction.default(definition)); - dsl.test('simple'); - dsl.enter('BEGIN', 'END'); - dsl.label('BEGIN'); - dsl.jumpUnless('END'); - dsl.putDynamicComponentDefinition(); - dsl.openComponent(args, shadow); - dsl.closeComponent(); - dsl.label('END'); - dsl.exit(); - }); - }; - - return ComponentBuilder; - })(); + function addObserverForContentKey(content, keyName, proxy, idx, loc) { + while (--loc >= idx) { + var item = _emberRuntimeMixinsArray.objectAt(content, loc); + if (item) { + _emberMetal._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); + _emberMetal.addObserver(item, keyName, proxy, 'contentKeyDidChange'); + } + } + } - var CompileIntoList = (function (_LinkedList) { - babelHelpers.inherits(CompileIntoList, _LinkedList); + function removeObserverForContentKey(content, keyName, proxy, idx, loc) { + while (--loc >= idx) { + var item = _emberRuntimeMixinsArray.objectAt(content, loc); + if (item) { + _emberMetal._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); + _emberMetal.removeObserver(item, keyName, proxy, 'contentKeyDidChange'); + } + } + } +}); +enifed('ember-runtime/system/lazy_load', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + /*globals CustomEvent */ - function CompileIntoList(env, symbolTable) { - _LinkedList.call(this); - this.env = env; - this.symbolTable = symbolTable; - var dsl = new _glimmerRuntimeLibCompiledOpcodesBuilder.default(this, symbolTable, env); - this.component = new ComponentBuilder(dsl); - } + 'use strict'; - CompileIntoList.prototype.getLocalSymbol = function getLocalSymbol(name) { - return this.symbolTable.getLocal(name); - }; + exports.onLoad = onLoad; + exports.runLoadHooks = runLoadHooks; - CompileIntoList.prototype.hasLocalSymbol = function hasLocalSymbol(name) { - return typeof this.symbolTable.getLocal(name) === 'number'; - }; + /** + @module ember + @submodule ember-runtime + */ - CompileIntoList.prototype.getNamedSymbol = function getNamedSymbol(name) { - return this.symbolTable.getNamed(name); - }; + var loadHooks = _emberEnvironment.ENV.EMBER_LOAD_HOOKS || {}; + var loaded = {}; + var _loaded = loaded; - CompileIntoList.prototype.hasNamedSymbol = function hasNamedSymbol(name) { - return typeof this.symbolTable.getNamed(name) === 'number'; - }; + exports._loaded = _loaded; + /** + Detects when a specific package of Ember (e.g. 'Ember.Application') + has fully loaded and is available for extension. + + The provided `callback` will be called with the `name` passed + resolved from a string into the object: + + ``` javascript + Ember.onLoad('Ember.Application' function(hbars) { + hbars.registerHelper(...); + }); + ``` + + @method onLoad + @for Ember + @param name {String} name of hook + @param callback {Function} callback to be called + @private + */ - CompileIntoList.prototype.getBlockSymbol = function getBlockSymbol(name) { - return this.symbolTable.getYield(name); - }; + function onLoad(name, callback) { + var object = loaded[name]; - CompileIntoList.prototype.hasBlockSymbol = function hasBlockSymbol(name) { - return typeof this.symbolTable.getYield(name) === 'number'; - }; + loadHooks[name] = loadHooks[name] || []; + loadHooks[name].push(callback); - CompileIntoList.prototype.getPartialArgsSymbol = function getPartialArgsSymbol() { - return this.symbolTable.getPartialArgs(); - }; + if (object) { + callback(object); + } + } - CompileIntoList.prototype.hasPartialArgsSymbol = function hasPartialArgsSymbol() { - return typeof this.symbolTable.getPartialArgs() === 'number'; - }; + /** + Called when an Ember.js package (e.g Ember.Application) has finished + loading. Triggers any callbacks registered for this event. + + @method runLoadHooks + @for Ember + @param name {String} name of hook + @param object {Object} object to pass to callbacks + @private + */ - CompileIntoList.prototype.toOpSeq = function toOpSeq() { - return this; - }; + function runLoadHooks(name, object) { + loaded[name] = object; + var window = _emberEnvironment.environment.window; - return CompileIntoList; - })(_glimmerUtil.LinkedList); + if (window && typeof CustomEvent === 'function') { + var _event = new CustomEvent(name, { detail: object, name: name }); + window.dispatchEvent(_event); + } - exports.CompileIntoList = CompileIntoList; + if (loadHooks[name]) { + loadHooks[name].forEach(function (callback) { + return callback(object); + }); + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcGlsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7UUFrQ0EsUUFBQTtBQUlFLGlCQUpGLFFBQUEsQ0FJd0IsS0FBWSxFQUFTLEdBQWdCLEVBQUE7QUFBckMsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUFPO0FBQVMsZ0JBQUEsQ0FBQSxHQUFHLEdBQUgsR0FBRyxDQUFhO0FBQ3pELGdCQUFJLENBQUMsT0FBTyxHQUFHLEtBQUssQ0FBQyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUM7QUFDcEMsZ0JBQUksQ0FBQyxXQUFXLEdBQUcsS0FBSyxDQUFDLFdBQVcsQ0FBQztTQUN0Qzs7QUFQSCxnQkFBQSxXQVNZLGdCQUFnQixHQUFBLDBCQUFDLFNBQTBCLEVBQUUsR0FBcUIsRUFBQTtBQUMxRSxnQkFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsU0FBUyxFQUFFLElBQUksQ0FB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9vbGVhbiB7XG4gICAgcmV0dXJuIHR5cGVvZiB0aGlzLnN5bWJvbFRhYmxlLmdldExvY2FsKG5hbWUpID09PSAnbnVtYmVyJztcbiAgfVxuXG4gIGdldE5hbWVkU3ltYm9sKG5hbWU6IHN0cmluZyk6IG51bWJlciB7XG4gICAgcmV0dXJuIHRoaXMuc3ltYm9sVGFibGUuZ2V0TmFtZWQobmFtZSk7XG4gIH1cblxuICBoYXNOYW1lZFN5bWJvbChuYW1lOiBzdHJpbmcpOiBib29sZWFuIHtcbiAgICByZXR1cm4gdHlwZW9mIHRoaXMuc3ltYm9sVGFibGUuZ2V0TmFtZWQobmFtZSkgPT09ICdudW1iZXInO1xuICB9XG5cbiAgZ2V0QmxvY2tTeW1ib2wobmFtZTogc3RyaW5nKTogbnVtYmVyIHtcbiAgICByZXR1cm4gdGhpcy5zeW1ib2xUYWJsZS5nZXRZaWVsZChuYW1lKTtcbiAgfVxuXG4gIGhhc0Jsb2NrU3ltYm9sKG5hbWU6IHN0cmluZyk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0eXBlb2YgdGhpcy5zeW1ib2xUYWJsZS5nZXRZaWVsZChuYW1lKSA9PT0gJ251bWJlcic7XG4gIH1cblxuICBnZXRQYXJ0aWFsQXJnc1N5bWJvbCgpOiBudW1iZXIge1xuICAgIHJldHVybiB0aGlzLnN5bWJvbFRhYmxlLmdldFBhcnRpYWxBcmdzKCk7XG4gIH1cblxuICBoYXNQYXJ0aWFsQXJnc1N5bWJvbCgpOiBib29sZWFuIHtcbiAgICByZXR1cm4gdHlwZW9mIHRoaXMuc3ltYm9sVGFibGUuZ2V0UGFydGlhbEFyZ3MoKSA9PT0gJ251bWJlcic7XG4gIH1cblxuICB0b09wU2VxKCk6IE9wU2VxIHtcbiAgICByZXR1cm4gdGhpcztcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/component/interfaces', ['exports'], function (exports) { - 'use strict'; +enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-runtime/system/object'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberRuntimeSystemObject) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - exports.isComponentDefinition = isComponentDefinition; - var COMPONENT_DEFINITION_BRAND = 'COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]'; + exports.isSearchDisabled = isSearchDisabled; + exports.setSearchDisabled = setSearchDisabled; - function isComponentDefinition(obj) { - return typeof obj === 'object' && obj && obj[COMPONENT_DEFINITION_BRAND]; - } + var searchDisabled = false; - var ComponentDefinition = function ComponentDefinition(name, manager, ComponentClass) { - this['COMPONENT DEFINITION [id=e59c754e-61eb-4392-8c4a-2c0ac72bfcd4]'] = true; - this.name = name; - this.manager = manager; - this.ComponentClass = ComponentClass; - }; + function isSearchDisabled() { + return searchDisabled; + } - exports.ComponentDefinition = ComponentDefinition; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvY29tcG9uZW50L2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQXFHQSxRQUFNLDBCQUEwQixHQUFHLGdFQUFnRSxDQUFDOztBQUVwRyxhQUFBLHFCQUFBLENBQXNDLEdBQVEsRUFBQTtBQUM1QyxlQUFPLE9BQU8sR0FBRyxLQUFLLFFBQVEsSUFBSSxHQUFHLElBQUksR0FBRyxDQUFDLDBCQUEwQixDQUFDLENBQUM7S0FDMUU7O1FBRUQsbUJBQUEsR0FPRSxTQVBGLG1CQUFBLENBT2MsSUFBWSxFQUFFLE9BQTRCLEVBQUUsY0FBOEIsRUFBQTtBQUY5RSxZQUFBLENBQUMsZ0VBQWdFLENBQUMsR0FBRyxJQUFJLENBQUM7QUFHaEYsWUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7QUFDakIsWUFBSSxDQUFDLE9BQU8sR0FBR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N0JyAmJiBvYmogJiYgb2JqW0NPTVBPTkVOVF9ERUZJTklUSU9OX0JSQU5EXTtcbn1cblxuZXhwb3J0IGFic3RyYWN0IGNsYXNzIENvbXBvbmVudERlZmluaXRpb248VD4ge1xuICBwdWJsaWMgbmFtZTogc3RyaW5nOyAvLyBmb3IgZGVidWdnaW5nXG4gIHB1YmxpYyBtYW5hZ2VyOiBDb21wb25lbnRNYW5hZ2VyPFQ+O1xuICBwdWJsaWMgQ29tcG9uZW50Q2xhc3M6IENvbXBvbmVudENsYXNzO1xuXG4gIHByaXZhdGUgWydDT01QT05FTlQgREVGSU5JVElPTiBbaWQ9ZTU5Yzc1NGUtNjFlYi00MzkyLThjNGEtMmMwYWM3MmJmY2Q0XSddID0gdHJ1ZTtcblxuICBjb25zdHJ1Y3RvcihuYW1lOiBzdHJpbmcsIG1hbmFnZXI6IENvbXBvbmVudE1hbmFnZXI8VD4sIENvbXBvbmVudENsYXNzOiBDb21wb25lbnRDbGFzcykge1xuICAgIHRoaXMubmFtZSA9IG5hbWU7XG4gICAgdGhpcy5tYW5hZ2VyID0gbWFuYWdlcjtcbiAgICB0aGlzLkNvbXBvbmVudENsYXNzID0gQ29tcG9uZW50Q2xhc3M7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/dom/attribute-managers', ['exports', 'glimmer-runtime/lib/dom/sanitized-values', 'glimmer-runtime/lib/dom/props', 'glimmer-runtime/lib/dom/helper', 'glimmer-runtime/lib/compiled/opcodes/content'], function (exports, _glimmerRuntimeLibDomSanitizedValues, _glimmerRuntimeLibDomProps, _glimmerRuntimeLibDomHelper, _glimmerRuntimeLibCompiledOpcodesContent) { - 'use strict'; + function setSearchDisabled(flag) { + searchDisabled = !!flag; + } - exports.defaultManagers = defaultManagers; - exports.defaultPropertyManagers = defaultPropertyManagers; - exports.defaultAttributeManagers = defaultAttributeManagers; - exports.readDOMAttr = readDOMAttr; + /** + A Namespace is an object usually used to contain other objects or methods + such as an application or framework. Create a namespace anytime you want + to define one of these new containers. + + # Example Usage + + ```javascript + MyFramework = Ember.Namespace.create({ + VERSION: '1.0.0' + }); + ``` + + @class Namespace + @namespace Ember + @extends Ember.Object + @public + */ + var Namespace = _emberRuntimeSystemObject.default.extend({ + isNamespace: true, - function defaultManagers(element, attr, isTrusting, namespace) { - var tagName = element.tagName; - var isSVG = element.namespaceURI === _glimmerRuntimeLibDomHelper.SVG_NAMESPACE; - if (isSVG) { - return defaultAttributeManagers(tagName, attr); - } + init: function () { + Namespace.NAMESPACES.push(this); + Namespace.PROCESSED = false; + }, - var _normalizeProperty = _glimmerRuntimeLibDomProps.normalizeProperty(element, attr); + toString: function () { + var name = _emberMetal.get(this, 'name') || _emberMetal.get(this, 'modulePrefix'); + if (name) { + return name; + } - var type = _normalizeProperty.type; - var normalized = _normalizeProperty.normalized; + findNamespaces(); + return this[_emberUtils.NAME_KEY]; + }, - if (type === 'attr') { - return defaultAttributeManagers(tagName, normalized); - } else { - return defaultPropertyManagers(tagName, normalized); - } - } + nameClasses: function () { + processNamespace([this.toString()], this, {}); + }, - function defaultPropertyManagers(tagName, attr) { - if (_glimmerRuntimeLibDomSanitizedValues.requiresSanitization(tagName, attr)) { - return new SafePropertyManager(attr); - } - if (isUserInputValue(tagName, attr)) { - return INPUT_VALUE_PROPERTY_MANAGER; - } - if (isOptionSelected(tagName, attr)) { - return OPTION_SELECTED_MANAGER; - } - return new PropertyManager(attr); - } + destroy: function () { + var namespaces = Namespace.NAMESPACES; + var toString = this.toString(); - function defaultAttributeManagers(tagName, attr) { - if (_glimmerRuntimeLibDomSanitizedValues.requiresSanitization(tagName, attr)) { - return new SafeAttributeManager(attr); - } - return new AttributeManager(attr); + if (toString) { + _emberEnvironment.context.lookup[toString] = undefined; + delete Namespace.NAMESPACES_BY_ID[toString]; + } + namespaces.splice(namespaces.indexOf(this), 1); + this._super.apply(this, arguments); } + }); - function readDOMAttr(element, attr) { - var isSVG = element.namespaceURI === _glimmerRuntimeLibDomHelper.SVG_NAMESPACE; - - var _normalizeProperty2 = _glimmerRuntimeLibDomProps.normalizeProperty(element, attr); - - var type = _normalizeProperty2.type; - var normalized = _normalizeProperty2.normalized; + Namespace.reopenClass({ + NAMESPACES: [_emberMetal.default], + NAMESPACES_BY_ID: { + Ember: _emberMetal.default + }, + PROCESSED: false, + processAll: processAllNamespaces, + byName: function (name) { + if (!searchDisabled) { + processAllNamespaces(); + } - if (isSVG) { - return element.getAttribute(normalized); - } - if (type === 'attr') { - return element.getAttribute(normalized); - } - { - return element[normalized]; - } + return NAMESPACES_BY_ID[name]; } + }); - ; + var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; - var AttributeManager = (function () { - function AttributeManager(attr) { - this.attr = attr; - } + var hasOwnProp = ({}).hasOwnProperty; - AttributeManager.prototype.setAttribute = function setAttribute(env, element, value, namespace) { - var dom = env.getAppendOperations(); - var normalizedValue = normalizeAttributeValue(value); - if (!isAttrRemovalValue(normalizedValue)) { - dom.setAttribute(element, this.attr, normalizedValue, namespace); - } - }; + function processNamespace(paths, root, seen) { + var idx = paths.length; - AttributeManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - if (value === null || value === undefined || value === false) { - if (namespace) { - env.getDOM().removeAttributeNS(element, namespace, this.attr); - } else { - env.getDOM().removeAttribute(element, this.attr); - } - } else { - this.setAttribute(env, element, value); - } - }; + NAMESPACES_BY_ID[paths.join('.')] = root; - return AttributeManager; - })(); + // Loop over all of the keys in the namespace, looking for classes + for (var key in root) { + if (!hasOwnProp.call(root, key)) { + continue; + } + var obj = root[key]; - exports.AttributeManager = AttributeManager; + // If we are processing the `Ember` namespace, for example, the + // `paths` will start with `["Ember"]`. Every iteration through + // the loop will update the **second** element of this list with + // the key, so processing `Ember.View` will make the Array + // `['Ember', 'View']`. + paths[idx] = key; - ; + // If we have found an unprocessed class + if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { + // Replace the class' `toString` with the dot-separated path + // and set its `NAME_KEY` + obj[_emberUtils.NAME_KEY] = paths.join('.'); - var PropertyManager = (function (_AttributeManager) { - babelHelpers.inherits(PropertyManager, _AttributeManager); + // Support nested namespaces + } else if (obj && obj.isNamespace) { + // Skip aliased namespaces + if (seen[_emberUtils.guidFor(obj)]) { + continue; + } + seen[_emberUtils.guidFor(obj)] = true; - function PropertyManager() { - _AttributeManager.apply(this, arguments); + // Process the child namespace + processNamespace(paths, obj, seen); } + } - PropertyManager.prototype.setAttribute = function setAttribute(env, element, value, namespace) { - if (!isAttrRemovalValue(value)) { - element[this.attr] = value; - } - }; - - PropertyManager.prototype.removeAttribute = function removeAttribute(env, element, namespace) { - // TODO this sucks but to preserve properties first and to meet current - // semantics we must do this. - var attr = this.attr; - - if (namespace) { - env.getDOM().removeAttributeNS(element, namespace, attr); - } else { - env.getDOM().removeAttribute(element, attr); - } - }; - - PropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - // ensure the property is always updated - element[this.attr] = value; - if (isAttrRemovalValue(value)) { - this.removeAttribute(env, element, namespace); - } - }; + paths.length = idx; // cut out last item + } - return PropertyManager; - })(AttributeManager); + function isUppercase(code) { + return code >= 65 && // A + code <= 90; // Z + } - exports.PropertyManager = PropertyManager; + function tryIsNamespace(lookup, prop) { + try { + var obj = lookup[prop]; + return obj && obj.isNamespace && obj; + } catch (e) { + // continue + } + } - ; - function normalizeAttributeValue(value) { - if (value === false || value === undefined || value === null) { - return null; - } - if (value === true) { - return ''; - } - // onclick function etc in SSR - if (typeof value === 'function') { - return null; - } - return String(value); + function findNamespaces() { + if (Namespace.PROCESSED) { + return; } - function isAttrRemovalValue(value) { - return value === null || value === undefined; + var lookup = _emberEnvironment.context.lookup; + var keys = Object.keys(lookup); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + // Only process entities that start with uppercase A-Z + if (!isUppercase(key.charCodeAt(0))) { + continue; + } + var obj = tryIsNamespace(lookup, key); + if (obj) { + obj[_emberUtils.NAME_KEY] = key; + } } + } - var SafePropertyManager = (function (_PropertyManager) { - babelHelpers.inherits(SafePropertyManager, _PropertyManager); - - function SafePropertyManager() { - _PropertyManager.apply(this, arguments); - } - - SafePropertyManager.prototype.setAttribute = function setAttribute(env, element, value) { - _PropertyManager.prototype.setAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + function superClassString(mixin) { + var superclass = mixin.superclass; + if (superclass) { + if (superclass[_emberUtils.NAME_KEY]) { + return superclass[_emberUtils.NAME_KEY]; + } + return superClassString(superclass); + } + } - SafePropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - _PropertyManager.prototype.updateAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + function calculateToString(target) { + var str = undefined; - return SafePropertyManager; - })(PropertyManager); + if (!searchDisabled) { + processAllNamespaces(); + // can also be set by processAllNamespaces + str = target[_emberUtils.NAME_KEY]; + if (str) { + return str; + } else { + str = superClassString(target); + str = str ? '(subclass of ' + str + ')' : str; + } + } + if (str) { + return str; + } else { + return '(unknown mixin)'; + } + } - function isUserInputValue(tagName, attribute) { - return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value'; + function classToString() { + var name = this[_emberUtils.NAME_KEY]; + if (name) { + return name; } - var InputValuePropertyManager = (function (_AttributeManager2) { - babelHelpers.inherits(InputValuePropertyManager, _AttributeManager2); + return this[_emberUtils.NAME_KEY] = calculateToString(this); + } - function InputValuePropertyManager() { - _AttributeManager2.apply(this, arguments); - } + function processAllNamespaces() { + var unprocessedNamespaces = !Namespace.PROCESSED; + var unprocessedMixins = _emberMetal.hasUnprocessedMixins(); - InputValuePropertyManager.prototype.setAttribute = function setAttribute(env, element, value) { - var input = element; - input.value = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - }; + if (unprocessedNamespaces) { + findNamespaces(); + Namespace.PROCESSED = true; + } - InputValuePropertyManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - var input = element; - var currentValue = input.value; - var normalizedValue = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - if (currentValue !== normalizedValue) { - input.value = normalizedValue; - } - }; + if (unprocessedNamespaces || unprocessedMixins) { + var namespaces = Namespace.NAMESPACES; + var namespace = undefined; - return InputValuePropertyManager; - })(AttributeManager); + for (var i = 0; i < namespaces.length; i++) { + namespace = namespaces[i]; + processNamespace([namespace.toString()], namespace, {}); + } - var INPUT_VALUE_PROPERTY_MANAGER = new InputValuePropertyManager('value'); - exports.INPUT_VALUE_PROPERTY_MANAGER = INPUT_VALUE_PROPERTY_MANAGER; - function isOptionSelected(tagName, attribute) { - return tagName === 'OPTION' && attribute === 'selected'; + _emberMetal.clearUnprocessedMixins(); } + } - var OptionSelectedManager = (function (_PropertyManager2) { - babelHelpers.inherits(OptionSelectedManager, _PropertyManager2); - - function OptionSelectedManager() { - _PropertyManager2.apply(this, arguments); - } - - OptionSelectedManager.prototype.setAttribute = function setAttribute(env, element, value) { - if (value !== null && value !== undefined && value !== false) { - var option = element; - option.selected = true; - } - }; + _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. - OptionSelectedManager.prototype.updateAttribute = function updateAttribute(env, element, value) { - var option = element; - if (value) { - option.selected = true; - } else { - option.selected = false; - } - }; + exports.default = Namespace; +}); +// Preloaded into namespaces +enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - return OptionSelectedManager; - })(PropertyManager); + var _NativeArray; - var OPTION_SELECTED_MANAGER = new OptionSelectedManager('selected'); - exports.OPTION_SELECTED_MANAGER = OPTION_SELECTED_MANAGER; + // Add Ember.Array to Array.prototype. Remove methods with native + // implementations and supply some more optimized versions of generic methods + // because they are so common. - var SafeAttributeManager = (function (_AttributeManager3) { - babelHelpers.inherits(SafeAttributeManager, _AttributeManager3); + /** + The NativeArray mixin contains the properties needed to make the native + Array support Ember.MutableArray and all of its dependent APIs. Unless you + have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to + false, this will be applied automatically. Otherwise you can apply the mixin + at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. + + @class NativeArray + @namespace Ember + @uses Ember.MutableArray + @uses Ember.Observable + @uses Ember.Copyable + @public + */ + var NativeArray = _emberMetal.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, { - function SafeAttributeManager() { - _AttributeManager3.apply(this, arguments); - } + // because length is a built-in property we need to know to just get the + // original property. + get: function (key) { + if ('number' === typeof key) { + return this[key]; + } else { + return this._super(key); + } + }, - SafeAttributeManager.prototype.setAttribute = function setAttribute(env, element, value) { - _AttributeManager3.prototype.setAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + objectAt: function (idx) { + return this[idx]; + }, - SafeAttributeManager.prototype.updateAttribute = function updateAttribute(env, element, value, namespace) { - _AttributeManager3.prototype.updateAttribute.call(this, env, element, _glimmerRuntimeLibDomSanitizedValues.sanitizeAttributeValue(env, element, this.attr, value)); - }; + // primitive for array support. + replace: function (idx, amt, objects) { + if (this.isFrozen) { + throw _emberRuntimeMixinsFreezable.FROZEN_ERROR; + } - return SafeAttributeManager; - })(AttributeManager); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2F0dHJpYnV0ZS1tYW5hZ2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cbmV4cG9ydCBjb25zdCBPUFRJT05fU0VMRUNURURfTUFOQUdFUjogQXR0cmlidXRlTWFuYWdlciA9IG5ldyBPcHRpb25TZWxlY3RlZE1hbmFnZXIoJ3NlbGVjdGVkJyk7XG5cbmNsYXNzIFNhZmVBdHRyaWJ1dGVNYW5hZ2VyIGV4dGVuZHMgQXR0cmlidXRlTWFuYWdlciB7XG4gIHNldEF0dHJpYnV0ZShlbnY6IEVudmlyb25tZW50LCBlbGVtZW50OiBFbGVtZW50LCB2YWx1ZTogT3BhcXVlKSB7XG4gICAgc3VwZXIuc2V0QXR0cmlidXRlKGVudiwgZWxlbWVudCwgc2FuaXRpemVBdHRyaWJ1dGVWYWx1ZShlbnYsIGVsZW1lbnQsIHRoaXMuYXR0ciwgdmFsdWUpKTtcbiAgfVxuXG4gIHVwZGF0ZUF0dHJpYnV0ZShlbnY6IEVudmlyb25tZW50LCBlbGVtZW50OiBFbGVtZW50LCB2YWx1ZTogT3BhcXVlLCBuYW1lc3BhY2U/OiBET01OYW1lc3BhY2UpIHtcbiAgICBzdXBlci51cGRhdGVBdHRyaWJ1dGUoZW52LCBlbGVtZW50LCBzYW5pdGl6ZUF0dHJpYnV0ZVZhbHVlKGVudiwgZWxlbWVudCwgdGhpcy5hdHRyLCB2YWx1ZSkpO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/dom/helper', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/compat/inner-html-fix', 'glimmer-runtime/lib/compat/svg-inner-html-fix', 'glimmer-runtime/lib/compat/text-node-merging-fix', 'glimmer-runtime/lib/dom/interfaces'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibCompatInnerHtmlFix, _glimmerRuntimeLibCompatSvgInnerHtmlFix, _glimmerRuntimeLibCompatTextNodeMergingFix, _glimmerRuntimeLibDomInterfaces) { - 'use strict'; + // if we replaced exactly the same number of items, then pass only the + // replaced range. Otherwise, pass the full remaining array length + // since everything has shifted + var len = objects ? _emberMetal.get(objects, 'length') : 0; + _emberRuntimeMixinsArray.arrayContentWillChange(this, idx, amt, len); - exports.isWhitespace = isWhitespace; - exports.moveNodesBefore = moveNodesBefore; - exports.insertHTMLBefore = _insertHTMLBefore; - var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - exports.SVG_NAMESPACE = SVG_NAMESPACE; - // http://www.w3.org/TR/html/syntax.html#html-integration-point - var SVG_INTEGRATION_POINTS = { foreignObject: 1, desc: 1, title: 1 }; - // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes - // TODO: Adjust SVG attributes - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - // TODO: Adjust SVG elements - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - var BLACKLIST_TABLE = Object.create(null); - exports.BLACKLIST_TABLE = BLACKLIST_TABLE; - ["b", "big", "blockquote", "body", "br", "center", "code", "dd", "div", "dl", "dt", "em", "embed", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "i", "img", "li", "listing", "main", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", "span", "strong", "strike", "sub", "sup", "table", "tt", "u", "ul", "var"].forEach(function (tag) { - return BLACKLIST_TABLE[tag] = 1; - }); - var WHITESPACE = /[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/; - var doc = typeof document === 'undefined' ? undefined : document; - - function isWhitespace(string) { - return WHITESPACE.test(string); - } - - function moveNodesBefore(source, target, nextSibling) { - var first = source.firstChild; - var last = null; - var current = first; - while (current) { - last = current; - current = current.nextSibling; - target.insertBefore(last, nextSibling); - } - return [first, last]; - } - - var DOM; - exports.DOM = DOM; - (function (DOM) { - var TreeConstruction = (function () { - function TreeConstruction(document) { - this.document = document; - this.uselessElement = null; - this.setupUselessElement(); - } + if (len === 0) { + this.splice(idx, amt); + } else { + _emberMetal.replace(this, idx, amt, objects); + } - TreeConstruction.prototype.setupUselessElement = function setupUselessElement() { - this.uselessElement = this.document.createElement('div'); - }; + _emberRuntimeMixinsArray.arrayContentDidChange(this, idx, amt, len); + return this; + }, - TreeConstruction.prototype.createElement = function createElement(tag, context) { - var isElementInSVGNamespace = undefined, - isHTMLIntegrationPoint = undefined; - if (context) { - isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg'; - isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName]; - } else { - isElementInSVGNamespace = tag === 'svg'; - isHTMLIntegrationPoint = false; - } - if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { - // FIXME: This does not properly handle with color, face, or - // size attributes, which is also disallowed by the spec. We should fix - // this. - if (BLACKLIST_TABLE[tag]) { - throw new Error('Cannot create a ' + tag + ' inside an SVG context'); - } - return this.document.createElementNS(SVG_NAMESPACE, tag); - } else { - return this.document.createElement(tag); - } - }; + // If you ask for an unknown property, then try to collect the value + // from member items. + unknownProperty: function (key, value) { + var ret = undefined; // = this.reducedProperty(key, value); + if (value !== undefined && ret === undefined) { + ret = this[key] = value; + } + return ret; + }, - TreeConstruction.prototype.createElementNS = function createElementNS(namespace, tag) { - return this.document.createElementNS(namespace, tag); - }; + indexOf: Array.prototype.indexOf, + lastIndexOf: Array.prototype.lastIndexOf, - TreeConstruction.prototype.setAttribute = function setAttribute(element, name, value, namespace) { - if (namespace) { - element.setAttributeNS(namespace, name, value); - } else { - element.setAttribute(name, value); - } - }; + copy: function (deep) { + if (deep) { + return this.map(function (item) { + return _emberRuntimeCopy.default(item, true); + }); + } - TreeConstruction.prototype.createTextNode = function createTextNode(text) { - return this.document.createTextNode(text); - }; + return this.slice(); + } + }); - TreeConstruction.prototype.createComment = function createComment(data) { - return this.document.createComment(data); - }; + // Remove any methods implemented natively so we don't override them + var ignore = ['length']; + NativeArray.keys().forEach(function (methodName) { + if (Array.prototype[methodName]) { + ignore.push(methodName); + } + }); - TreeConstruction.prototype.insertBefore = function insertBefore(parent, node, reference) { - parent.insertBefore(node, reference); - }; + exports.NativeArray // TODO: only use default export + = NativeArray = (_NativeArray = NativeArray).without.apply(_NativeArray, ignore); - TreeConstruction.prototype.insertHTMLBefore = function insertHTMLBefore(parent, html, reference) { - return _insertHTMLBefore(this.uselessElement, parent, reference, html); - }; + /** + Creates an `Ember.NativeArray` from an Array like object. + Does not modify the original object. Ember.A is not needed if + `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However, + it is recommended that you use Ember.A when creating addons for + ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES` + will be `true`. + + Example + + ```js + export default Ember.Component.extend({ + tagName: 'ul', + classNames: ['pagination'], + + init() { + this._super(...arguments); + + if (!this.get('content')) { + this.set('content', Ember.A()); + } + } + }); + ``` + + @method A + @for Ember + @return {Ember.NativeArray} + @public + */ + var A = undefined; - return TreeConstruction; - })(); + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Array) { + NativeArray.apply(Array.prototype); + exports.A = A = function (arr) { + return arr || []; + }; + } else { + exports.A = A = function (arr) { + if (!arr) { + arr = []; + } + return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr); + }; + } - DOM.TreeConstruction = TreeConstruction; - var appliedTreeContruction = TreeConstruction; - appliedTreeContruction = _glimmerRuntimeLibCompatTextNodeMergingFix.treeConstruction(doc, appliedTreeContruction); - appliedTreeContruction = _glimmerRuntimeLibCompatInnerHtmlFix.treeConstruction(doc, appliedTreeContruction); - appliedTreeContruction = _glimmerRuntimeLibCompatSvgInnerHtmlFix.treeConstruction(doc, appliedTreeContruction, SVG_NAMESPACE); - DOM.DOMTreeConstruction = appliedTreeContruction; - })(DOM || (exports.DOM = DOM = {})); + _emberMetal.default.A = A; + exports.A = A; + exports.NativeArray = NativeArray; + exports.default = NativeArray; +}); +// Ember.A circular +enifed('ember-runtime/system/object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberUtils, _emberMetal, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) { + /** + @module ember + @submodule ember-runtime + */ - var DOMChanges = (function () { - function DOMChanges(document) { - this.document = document; - this.uselessElement = null; - this.namespace = null; - this.uselessElement = this.document.createElement('div'); - } + 'use strict'; - DOMChanges.prototype.setAttribute = function setAttribute(element, name, value) { - element.setAttribute(name, value); - }; + /** + `Ember.Object` is the main base class for all Ember objects. It is a subclass + of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, + see the documentation for each of these. + + @class Object + @namespace Ember + @extends Ember.CoreObject + @uses Ember.Observable + @public + */ + var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default); + EmberObject.toString = function () { + return 'Ember.Object'; + }; - DOMChanges.prototype.setAttributeNS = function setAttributeNS(element, namespace, name, value) { - element.setAttributeNS(namespace, name, value); - }; + var FrameworkObject = EmberObject; - DOMChanges.prototype.removeAttribute = function removeAttribute(element, name) { - element.removeAttribute(name); - }; + exports.FrameworkObject = FrameworkObject; + exports.default = EmberObject; +}); +enifed('ember-runtime/system/object_proxy', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/-proxy'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsProxy) { + 'use strict'; - DOMChanges.prototype.removeAttributeNS = function removeAttributeNS(element, namespace, name) { - element.removeAttributeNS(namespace, name); - }; + /** + `Ember.ObjectProxy` forwards all properties not defined by the proxy itself + to a proxied `content` object. + + ```javascript + object = Ember.Object.create({ + name: 'Foo' + }); + + proxy = Ember.ObjectProxy.create({ + content: object + }); + + // Access and change existing properties + proxy.get('name') // 'Foo' + proxy.set('name', 'Bar'); + object.get('name') // 'Bar' + + // Create new 'description' property on `object` + proxy.set('description', 'Foo is a whizboo baz'); + object.get('description') // 'Foo is a whizboo baz' + ``` + + While `content` is unset, setting a property to be delegated will throw an + Error. + + ```javascript + proxy = Ember.ObjectProxy.create({ + content: null, + flag: null + }); + proxy.set('flag', true); + proxy.get('flag'); // true + proxy.get('foo'); // undefined + proxy.set('foo', 'data'); // throws Error + ``` + + Delegated properties can be bound to and will change when content is updated. + + Computed properties on the proxy itself can depend on delegated properties. + + ```javascript + ProxyWithComputedProperty = Ember.ObjectProxy.extend({ + fullName: Ember.computed('firstName', 'lastName', function() { + var firstName = this.get('firstName'), + lastName = this.get('lastName'); + if (firstName && lastName) { + return firstName + ' ' + lastName; + } + return firstName || lastName; + }) + }); + + proxy = ProxyWithComputedProperty.create(); + + proxy.get('fullName'); // undefined + proxy.set('content', { + firstName: 'Tom', lastName: 'Dale' + }); // triggers property change for fullName on proxy + + proxy.get('fullName'); // 'Tom Dale' + ``` + + @class ObjectProxy + @namespace Ember + @extends Ember.Object + @extends Ember._ProxyMixin + @public + */ - DOMChanges.prototype.createTextNode = function createTextNode(text) { - return this.document.createTextNode(text); - }; + exports.default = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsProxy.default); +}); +enifed('ember-runtime/system/service', ['exports', 'ember-runtime/system/object', 'ember-runtime/inject'], function (exports, _emberRuntimeSystemObject, _emberRuntimeInject) { + 'use strict'; - DOMChanges.prototype.createComment = function createComment(data) { - return this.document.createComment(data); - }; + /** + Creates a property that lazily looks up a service in the container. There + are no restrictions as to what objects a service can be injected into. + + Example: + + ```javascript + App.ApplicationRoute = Ember.Route.extend({ + authManager: Ember.inject.service('auth'), + + model: function() { + return this.get('authManager').findCurrentUser(); + } + }); + ``` + + This example will create an `authManager` property on the application route + that looks up the `auth` service in the container, making it easily + accessible in the `model` hook. + + @method service + @since 1.10.0 + @for Ember.inject + @param {String} name (optional) name of the service to inject, defaults to + the property's name + @return {Ember.InjectedProperty} injection descriptor instance + @public + */ + _emberRuntimeInject.createInjectionHelper('service'); - DOMChanges.prototype.createElement = function createElement(tag, context) { - var isElementInSVGNamespace = undefined, - isHTMLIntegrationPoint = undefined; - if (context) { - isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg'; - isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName]; - } else { - isElementInSVGNamespace = tag === 'svg'; - isHTMLIntegrationPoint = false; - } - if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { - // FIXME: This does not properly handle with color, face, or - // size attributes, which is also disallowed by the spec. We should fix - // this. - if (BLACKLIST_TABLE[tag]) { - throw new Error('Cannot create a ' + tag + ' inside an SVG context'); - } - return this.document.createElementNS(SVG_NAMESPACE, tag); - } else { - return this.document.createElement(tag); - } - }; + /** + @class Service + @namespace Ember + @extends Ember.Object + @since 1.10.0 + @public + */ + var Service = _emberRuntimeSystemObject.default.extend(); - DOMChanges.prototype.insertHTMLBefore = function insertHTMLBefore(_parent, nextSibling, html) { - return _insertHTMLBefore(this.uselessElement, _parent, nextSibling, html); - }; + Service.reopenClass({ + isServiceFactory: true + }); - DOMChanges.prototype.insertNodeBefore = function insertNodeBefore(parent, node, reference) { - if (isDocumentFragment(node)) { - var firstChild = node.firstChild; - var lastChild = node.lastChild; + exports.default = Service; +}); +enifed('ember-runtime/system/string', ['exports', 'ember-metal', 'ember-utils', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberUtils, _emberRuntimeUtils, _emberRuntimeString_registry) { + /** + @module ember + @submodule ember-runtime + */ + 'use strict'; - this.insertBefore(parent, node, reference); - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, firstChild, lastChild); - } else { - this.insertBefore(parent, node, reference); - return new _glimmerRuntimeLibBounds.SingleNodeBounds(parent, node); - } - }; + var STRING_DASHERIZE_REGEXP = /[ _]/g; - DOMChanges.prototype.insertTextBefore = function insertTextBefore(parent, nextSibling, text) { - var textNode = this.createTextNode(text); - this.insertBefore(parent, textNode, nextSibling); - return textNode; - }; + var STRING_DASHERIZE_CACHE = new _emberMetal.Cache(1000, function (key) { + return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-'); + }); - DOMChanges.prototype.insertBefore = function insertBefore(element, node, reference) { - element.insertBefore(node, reference); - }; + var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; + var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; - DOMChanges.prototype.insertAfter = function insertAfter(element, node, reference) { - this.insertBefore(element, node, reference.nextSibling); - }; + var CAMELIZE_CACHE = new _emberMetal.Cache(1000, function (key) { + return key.replace(STRING_CAMELIZE_REGEXP_1, function (match, separator, chr) { + return chr ? chr.toUpperCase() : ''; + }).replace(STRING_CAMELIZE_REGEXP_2, function (match, separator, chr) { + return match.toLowerCase(); + }); + }); - return DOMChanges; - })(); + var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; + var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; + var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; - exports.DOMChanges = DOMChanges; - - function _insertHTMLBefore(_useless, _parent, _nextSibling, html) { - // TypeScript vendored an old version of the DOM spec where `insertAdjacentHTML` - // only exists on `HTMLElement` but not on `Element`. We actually work with the - // newer version of the DOM API here (and monkey-patch this method in `./compat` - // when we detect older browsers). This is a hack to work around this limitation. - var parent = _parent; - var useless = _useless; - var nextSibling = _nextSibling; - var prev = nextSibling ? nextSibling.previousSibling : parent.lastChild; - var last = undefined; - if (html === null || html === '') { - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, null, null); - } - if (nextSibling === null) { - parent.insertAdjacentHTML('beforeEnd', html); - last = parent.lastChild; - } else if (nextSibling instanceof HTMLElement) { - nextSibling.insertAdjacentHTML('beforeBegin', html); - last = nextSibling.previousSibling; - } else { - // Non-element nodes do not support insertAdjacentHTML, so add an - // element and call it on that element. Then remove the element. - // - // This also protects Edge, IE and Firefox w/o the inspector open - // from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts - parent.insertBefore(useless, nextSibling); - useless.insertAdjacentHTML('beforeBegin', html); - last = useless.previousSibling; - parent.removeChild(useless); - } - var first = prev ? prev.nextSibling : parent.firstChild; - return new _glimmerRuntimeLibBounds.ConcreteBounds(parent, first, last); - } - - function isDocumentFragment(node) { - return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE; - } - var helper = DOMChanges; - helper = _glimmerRuntimeLibCompatTextNodeMergingFix.domChanges(doc, helper); - helper = _glimmerRuntimeLibCompatInnerHtmlFix.domChanges(doc, helper); - helper = _glimmerRuntimeLibCompatSvgInnerHtmlFix.domChanges(doc, helper, SVG_NAMESPACE); - exports.default = helper; - var DOMTreeConstruction = DOM.DOMTreeConstruction; - exports.DOMTreeConstruction = DOMTreeConstruction; - exports.DOMNamespace = _glimmerRuntimeLibDomInterfaces.Namespace; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2hlbHBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFlTyxRQUFNLGFBQWEsR0FBRyw0QkFBNEIsQ0FBQzs7O0FBRzFELFFBQU0sc0JBQXNCLEdBQUcsRUFBRSxhQUFhLEVBQUUsQ0FBQyxFQUFFLElBQUksRUFBRSxDQUFDLEVBQUUsS0FBSyxFQUFFLENBQUMsRUFBRSxDQUFDOzs7Ozs7QUFTaEUsUUFBTSxlQUFlLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQzs7QUFFbkQsQUFBQyxLQUNDLEdBQUcsRUFBRSxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsUUFBUSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFDaEcsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxHQUFHLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxTQUFTLEVBQUUsTUFBTSxFQUF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2hpbGQ7XG4gIHJldHVybiBuZXcgQ29uY3JldGVCb3VuZHMocGFyZW50LCBmaXJzdCwgbGFzdCk7XG59XG5cbmZ1bmN0aW9uIGlzRG9jdW1lbnRGcmFnbWVudChub2RlOiBTaW1wbGUuTm9kZSk6IG5vZGUgaXMgRG9jdW1lbnRGcmFnbWVudCB7XG4gIHJldHVybiBub2RlLm5vZGVUeXBlID09PSBOb2RlLkRPQ1VNRU5UX0ZSQUdNRU5UX05PREU7XG59XG5cbmxldCBoZWxwZXIgPSBET01DaGFuZ2VzO1xuXG5oZWxwZXIgPSBkb21DaGFuZ2VzTm9kZU1lcmdpbmdGaXgoZG9jLCBoZWxwZXIpO1xuaGVscGVyID0gZG9tQ2hhbmdlc1RhYmxlRWxlbWVudEZpeChkb2MsIGhlbHBlcik7XG5oZWxwZXIgPSBkb21DaGFuZ2VzU3ZnRWxlbWVudEZpeChkb2MsIGhlbHBlciwgU1ZHX05BTUVTUEFDRSk7XG5cbmV4cG9ydCBkZWZhdWx0IGhlbHBlcjtcbmV4cG9ydCBjb25zdCBET01UcmVlQ29uc3RydWN0aW9uID0gRE9NLkRPTVRyZWVDb25zdHJ1Y3Rpb247XG5leHBvcnQgdHlwZSBET01UcmVlQ29uc3RydWN0aW9uID0gRE9NLkRPTVRyZWVDb25zdHJ1Y3Rpb247XG5leHBvcnQgeyBOYW1lc3BhY2UgYXMgRE9NTmFtZXNwYWNlIH0gZnJvbSAnLi9pbnRlcmZhY2VzJztcbiJdfQ== -enifed("glimmer-runtime/lib/dom/interfaces", ["exports"], function (exports) { - "use strict"; + var CLASSIFY_CACHE = new _emberMetal.Cache(1000, function (str) { + var replace1 = function (match, separator, chr) { + return chr ? '_' + chr.toUpperCase() : ''; + }; + var replace2 = function (match, initialChar, separator, chr) { + return initialChar + (chr ? chr.toUpperCase() : ''); + }; + var parts = str.split('/'); + for (var i = 0; i < parts.length; i++) { + parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); + } + return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, function (match, separator, chr) { + return match.toUpperCase(); + }); + }); - var NodeType; - exports.NodeType = NodeType; - (function (NodeType) { - NodeType[NodeType["Element"] = 0] = "Element"; - NodeType[NodeType["Attribute"] = 1] = "Attribute"; - NodeType[NodeType["Text"] = 2] = "Text"; - NodeType[NodeType["CdataSection"] = 3] = "CdataSection"; - NodeType[NodeType["EntityReference"] = 4] = "EntityReference"; - NodeType[NodeType["Entity"] = 5] = "Entity"; - NodeType[NodeType["ProcessingInstruction"] = 6] = "ProcessingInstruction"; - NodeType[NodeType["Comment"] = 7] = "Comment"; - NodeType[NodeType["Document"] = 8] = "Document"; - NodeType[NodeType["DocumentType"] = 9] = "DocumentType"; - NodeType[NodeType["DocumentFragment"] = 10] = "DocumentFragment"; - NodeType[NodeType["Notation"] = 11] = "Notation"; - })(NodeType || (exports.NodeType = NodeType = {})); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBV0EsUUFBWSxRQWFYLENBQUE7O0FBYkQsS0FBQSxVQUFZLFFBQVEsRUFBQTtBQUNsQixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxTQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxTQUFPLENBQUE7QUFDUCxnQkFBQSxDQUFBLFFBQUEsQ0FBQSxXQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxXQUFTLENBQUE7QUFDVCxnQkFBQSxDQUFBLFFBQUEsQ0FBQSxNQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxNQUFJLENBQUE7QUFDSixnQkFBQSxDQUFBLFFBQUEsQ0FBQSxjQUFBLENBQUEsR0FBQSxDQUFBLENBQUEsR0FBQSxjQUF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ZXJ0QmVmb3JlKG5vZGU6IE5vZGUsIHJlZmVyZW5jZTogTm9kZSk6IHZvaWQ7XG4gIHJlbW92ZUNoaWxkKG5vZGU6IE5vZGUpOiB2b2lkO1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIFNWR0VsZW1lbnQgZXh0ZW5kcyBFbGVtZW50IHt9XG5cbmV4cG9ydCBpbnRlcmZhY2UgSFRNTEVsZW1lbnQgZXh0ZW5kcyBFbGVtZW50IHt9XG4iXX0= -enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { - /* - * @method normalizeProperty - * @param element {HTMLElement} - * @param slotName {String} - * @returns {Object} { name, type } - */ - 'use strict'; + var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; + var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; - exports.normalizeProperty = normalizeProperty; - exports.normalizePropertyValue = normalizePropertyValue; + var UNDERSCORE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase(); + }); - function normalizeProperty(element, slotName) { - var type = undefined, - normalized = undefined; - if (slotName in element) { - normalized = slotName; - type = 'prop'; - } else { - var lower = slotName.toLowerCase(); - if (lower in element) { - type = 'prop'; - normalized = lower; - } else { - type = 'attr'; - normalized = slotName; - } - } - if (type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName, normalized))) { - type = 'attr'; - } - return { normalized: normalized, type: type }; - } + var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z])/g; - function normalizePropertyValue(value) { - if (value === '') { - return true; - } - return value; - } + var CAPITALIZE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_CAPITALIZE_REGEXP, function (match, separator, chr) { + return match.toUpperCase(); + }); + }); - // properties that MUST be set as attributes, due to: - // * browser bug - // * strange spec outlier - var ATTR_OVERRIDES = { - // phantomjs < 2.0 lets you set it as a prop but won't reflect it - // back to the attribute. button.getAttribute('type') === null - BUTTON: { type: true, form: true }, - INPUT: { - // Some version of IE (like IE9) actually throw an exception - // if you set input.type = 'something-unknown' - type: true, - form: true, - // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false - // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false - // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true - }, - // element.form is actually a legitimate readOnly property, that is to be - // mutated, but must be mutated by setAttribute... - SELECT: { form: true }, - OPTION: { form: true }, - TEXTAREA: { form: true }, - LABEL: { form: true }, - FIELDSET: { form: true }, - LEGEND: { form: true }, - OBJECT: { form: true } - }; - function preferAttr(tagName, propName) { - var tag = ATTR_OVERRIDES[tagName.toUpperCase()]; - return tag && tag[propName.toLowerCase()] || false; - } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUF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WF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gU2FmYXJpIDguMC43OiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gTW9iaWxlIFNhZmFyaSAoaU9TIDguNCBzaW11bGF0b3IpOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IHRydWVcbiAgICBhdXRvY29ycmVjdDogdHJ1ZVxuICB9LFxuXG4gIC8vIGVsZW1lbnQuZm9ybSBpcyBhY3R1YWxseSBhIGxlZ2l0aW1hdGUgcmVhZE9ubHkgcHJvcGVydHksIHRoYXQgaXMgdG8gYmVcbiAgLy8gbXV0YXRlZCwgYnV0IG11c3QgYmUgbXV0YXRlZCBieSBzZXRBdHRyaWJ1dGUuLi5cbiAgU0VMRUNUOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPUFRJT046ICAgeyBmb3JtOiB0cnVlIH0sXG4gIFRFWFRBUkVBOiB7IGZvcm06IHRydWUgfSxcbiAgTEFCRUw6ICAgIHsgZm9ybTogdHJ1ZSB9LFxuICBGSUVMRFNFVDogeyBmb3JtOiB0cnVlIH0sXG4gIExFR0VORDogICB7IGZvcm06IHRydWUgfSxcbiAgT0JKRUNUOiAgIHsgZm9ybTogdHJ1ZSB9XG59O1xuXG5mdW5jdGlvbiBwcmVmZXJBdHRyKHRhZ05hbWUsIHByb3BOYW1lKSB7XG4gIGxldCB0YWcgPSBBVFRSX09WRVJSSURFU1t0YWdOYW1lLnRvVXBwZXJDYXNlKCldO1xuICByZXR1cm4gdGFnICYmIHRhZ1twcm9wTmFtZS50b0xvd2VyQ2FzZSgpXSB8fCBmYWxzZTtcbn1cbiJdfQ== -enifed('glimmer-runtime/lib/dom/sanitized-values', ['exports', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/upsert'], function (exports, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibUpsert) { - 'use strict'; + var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; - exports.requiresSanitization = requiresSanitization; - exports.sanitizeAttributeValue = sanitizeAttributeValue; + var DECAMELIZE_CACHE = new _emberMetal.Cache(1000, function (str) { + return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase(); + }); - var badProtocols = ['javascript:', 'vbscript:']; - var badTags = ['A', 'BODY', 'LINK', 'IMG', 'IFRAME', 'BASE', 'FORM']; - var badTagsForDataURI = ['EMBED']; - var badAttributes = ['href', 'src', 'background', 'action']; - var badAttributesForDataURI = ['src']; - function has(array, item) { - return array.indexOf(item) !== -1; - } - function checkURI(tagName, attribute) { - return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute); - } - function checkDataURI(tagName, attribute) { - return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute); - } + function _fmt(str, formats) { + var cachedFormats = formats; - function requiresSanitization(tagName, attribute) { - return checkURI(tagName, attribute) || checkDataURI(tagName, attribute); - } + if (!_emberRuntimeUtils.isArray(cachedFormats) || arguments.length > 2) { + cachedFormats = new Array(arguments.length - 1); - function sanitizeAttributeValue(env, element, attribute, value) { - var tagName = undefined; - if (value === null || value === undefined) { - return value; - } - if (_glimmerRuntimeLibUpsert.isSafeString(value)) { - return value.toHTML(); - } - if (!element) { - tagName = null; - } else { - tagName = element.tagName.toUpperCase(); - } - var str = _glimmerRuntimeLibCompiledOpcodesContent.normalizeTextValue(value); - if (checkURI(tagName, attribute)) { - var protocol = env.protocolForURL(str); - if (has(badProtocols, protocol)) { - return 'unsafe:' + str; - } - } - if (checkDataURI(tagName, attribute)) { - return 'unsafe:' + str; - } - return str; + for (var i = 1; i < arguments.length; i++) { + cachedFormats[i - 1] = arguments[i]; + } } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItc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bnVsbDtcbiAgfSBlbHNlIHtcbiAgICB0YWdOYW1lID0gZWxlbWVudC50YWdOYW1lLnRvVXBwZXJDYXNlKCk7XG4gIH1cblxuICBsZXQgc3RyID0gbm9ybWFsaXplVGV4dFZhbHVlKHZhbHVlKTtcblxuICBpZiAoY2hlY2tVUkkodGFnTmFtZSwgYXR0cmlidXRlKSkge1xuICAgIGxldCBwcm90b2NvbCA9IGVudi5wcm90b2NvbEZvclVSTChzdHIpO1xuICAgIGlmIChoYXMoYmFkUHJvdG9jb2xzLCBwcm90b2NvbCkpIHtcbiAgICAgIHJldHVybiBgdW5zYWZlOiR7c3RyfWA7XG4gICAgfVxuICB9XG5cbiAgaWYgKGNoZWNrRGF0YVVSSSh0YWdOYW1lLCBhdHRyaWJ1dGUpKSB7XG4gICAgcmV0dXJuIGB1bnNhZmU6JHtzdHJ9YDtcbiAgfVxuXG4gIHJldHVybiBzdHI7XG59XG4iXX0= -enifed('glimmer-runtime/lib/environment', ['exports', 'glimmer-runtime/lib/references', 'glimmer-runtime/lib/dom/attribute-managers', 'glimmer-util', 'glimmer-runtime/lib/syntax/core', 'glimmer-runtime/lib/syntax/builtins/if', 'glimmer-runtime/lib/syntax/builtins/unless', 'glimmer-runtime/lib/syntax/builtins/with', 'glimmer-runtime/lib/syntax/builtins/each'], function (exports, _glimmerRuntimeLibReferences, _glimmerRuntimeLibDomAttributeManagers, _glimmerUtil, _glimmerRuntimeLibSyntaxCore, _glimmerRuntimeLibSyntaxBuiltinsIf, _glimmerRuntimeLibSyntaxBuiltinsUnless, _glimmerRuntimeLibSyntaxBuiltinsWith, _glimmerRuntimeLibSyntaxBuiltinsEach) { - 'use strict'; - var Scope = (function () { - function Scope(references) { - var callerScope = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + // first, replace any ORDERED replacements. + var idx = 0; // the current index for non-numerical replacements + return str.replace(/%@([0-9]+)?/g, function (s, argIndex) { + argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++; + s = cachedFormats[argIndex]; + return s === null ? '(null)' : s === undefined ? '' : _emberUtils.inspect(s); + }); + } - this.callerScope = null; - this.slots = references; - this.callerScope = callerScope; - } + function fmt(str, formats) { + return _fmt.apply(undefined, arguments); + } - Scope.root = function root(self) { - var size = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; + function loc(str, formats) { + if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) { + formats = Array.prototype.slice.call(arguments, 1); + } - var refs = new Array(size + 1); - for (var i = 0; i <= size; i++) { - refs[i] = _glimmerRuntimeLibReferences.UNDEFINED_REFERENCE; - } - return new Scope(refs).init({ self: self }); - }; + str = _emberRuntimeString_registry.get(str) || str; + return _fmt(str, formats); + } - Scope.prototype.init = function init(_ref) { - var self = _ref.self; + function w(str) { + return str.split(/\s+/); + } - this.slots[0] = self; - return this; - }; + function decamelize(str) { + return DECAMELIZE_CACHE.get(str); + } - Scope.prototype.getSelf = function getSelf() { - return this.slots[0]; - }; + function dasherize(str) { + return STRING_DASHERIZE_CACHE.get(str); + } - Scope.prototype.getSymbol = function getSymbol(symbol) { - return this.slots[symbol]; - }; + function camelize(str) { + return CAMELIZE_CACHE.get(str); + } - Scope.prototype.getBlock = function getBlock(symbol) { - return this.slots[symbol]; - }; + function classify(str) { + return CLASSIFY_CACHE.get(str); + } - Scope.prototype.getPartialArgs = function getPartialArgs(symbol) { - return this.slots[symbol]; - }; + function underscore(str) { + return UNDERSCORE_CACHE.get(str); + } - Scope.prototype.bindSymbol = function bindSymbol(symbol, value) { - this.slots[symbol] = value; - }; + function capitalize(str) { + return CAPITALIZE_CACHE.get(str); + } - Scope.prototype.bindBlock = function bindBlock(symbol, value) { - this.slots[symbol] = value; - }; + /** + Defines string helper methods including string formatting and localization. + Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be + added to the `String.prototype` as well. + + @class String + @namespace Ember + @static + @public + */ + exports.default = { + /** + Apply formatting options to the string. This will look for occurrences + of "%@" in your string and substitute them with the arguments you pass into + this method. If you want to control the specific order of replacement, + you can add a number after the key as well to indicate which argument + you want to insert. + Ordered insertions are most useful when building loc strings where values + you need to insert may appear in different orders. + ```javascript + "Hello %@ %@".fmt('John', 'Doe'); // "Hello John Doe" + "Hello %@2, %@1".fmt('John', 'Doe'); // "Hello Doe, John" + ``` + @method fmt + @param {String} str The string to format + @param {Array} formats An array of parameters to interpolate into string. + @return {String} formatted string + @public + @deprecated Use ES6 template strings instead: http://babeljs.io/docs/learn-es2015/#template-strings + */ + fmt: fmt, - Scope.prototype.bindPartialArgs = function bindPartialArgs(symbol, value) { - this.slots[symbol] = value; - }; + /** + Formats the passed string, but first looks up the string in the localized + strings hash. This is a convenient way to localize text. See + `Ember.String.fmt()` for more information on formatting. + Note that it is traditional but not required to prefix localized string + keys with an underscore or other character so you can easily identify + localized strings. + ```javascript + Ember.STRINGS = { + '_Hello World': 'Bonjour le monde', + '_Hello %@ %@': 'Bonjour %@ %@' + }; + Ember.String.loc("_Hello World"); // 'Bonjour le monde'; + Ember.String.loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; + ``` + @method loc + @param {String} str The string to format + @param {Array} formats Optional array of parameters to interpolate into string. + @return {String} formatted string + @public + */ + loc: loc, - Scope.prototype.bindCallerScope = function bindCallerScope(scope) { - this.callerScope = scope; - }; + /** + Splits a string into separate units separated by spaces, eliminating any + empty strings in the process. This is a convenience method for split that + is mostly useful when applied to the `String.prototype`. + ```javascript + Ember.String.w("alpha beta gamma").forEach(function(key) { + console.log(key); + }); + // > alpha + // > beta + // > gamma + ``` + @method w + @param {String} str The string to split + @return {Array} array containing the split strings + @public + */ + w: w, - Scope.prototype.getCallerScope = function getCallerScope() { - return this.callerScope; - }; + /** + Converts a camelized string into all lower case separated by underscores. + ```javascript + 'innerHTML'.decamelize(); // 'inner_html' + 'action_name'.decamelize(); // 'action_name' + 'css-class-name'.decamelize(); // 'css-class-name' + 'my favorite items'.decamelize(); // 'my favorite items' + ``` + @method decamelize + @param {String} str The string to decamelize. + @return {String} the decamelized string. + @public + */ + decamelize: decamelize, - Scope.prototype.child = function child() { - return new Scope(this.slots.slice(), this.callerScope); - }; + /** + Replaces underscores, spaces, or camelCase with dashes. + ```javascript + 'innerHTML'.dasherize(); // 'inner-html' + 'action_name'.dasherize(); // 'action-name' + 'css-class-name'.dasherize(); // 'css-class-name' + 'my favorite items'.dasherize(); // 'my-favorite-items' + 'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice' + ``` + @method dasherize + @param {String} str The string to dasherize. + @return {String} the dasherized string. + @public + */ + dasherize: dasherize, - return Scope; - })(); + /** + Returns the lowerCamelCase form of a string. + ```javascript + 'innerHTML'.camelize(); // 'innerHTML' + 'action_name'.camelize(); // 'actionName' + 'css-class-name'.camelize(); // 'cssClassName' + 'my favorite items'.camelize(); // 'myFavoriteItems' + 'My Favorite Items'.camelize(); // 'myFavoriteItems' + 'private-docs/owner-invoice'.camelize(); // 'privateDocs/ownerInvoice' + ``` + @method camelize + @param {String} str The string to camelize. + @return {String} the camelized string. + @public + */ + camelize: camelize, - exports.Scope = Scope; + /** + Returns the UpperCamelCase form of a string. + ```javascript + 'innerHTML'.classify(); // 'InnerHTML' + 'action_name'.classify(); // 'ActionName' + 'css-class-name'.classify(); // 'CssClassName' + 'my favorite items'.classify(); // 'MyFavoriteItems' + 'private-docs/owner-invoice'.classify(); // 'PrivateDocs/OwnerInvoice' + ``` + @method classify + @param {String} str the string to classify + @return {String} the classified string + @public + */ + classify: classify, - var Environment = (function () { - function Environment(_ref2) { - var appendOperations = _ref2.appendOperations; - var updateOperations = _ref2.updateOperations; + /** + More general than decamelize. Returns the lower\_case\_and\_underscored + form of a string. + ```javascript + 'innerHTML'.underscore(); // 'inner_html' + 'action_name'.underscore(); // 'action_name' + 'css-class-name'.underscore(); // 'css_class_name' + 'my favorite items'.underscore(); // 'my_favorite_items' + 'privateDocs/ownerInvoice'.underscore(); // 'private_docs/owner_invoice' + ``` + @method underscore + @param {String} str The string to underscore. + @return {String} the underscored string. + @public + */ + underscore: underscore, - this.scheduledInstallManagers = null; - this.scheduledInstallModifiers = null; - this.scheduledUpdateModifierManagers = null; - this.scheduledUpdateModifiers = null; - this.createdComponents = null; - this.createdManagers = null; - this.updatedComponents = null; - this.updatedManagers = null; - this.destructors = null; - this.appendOperations = appendOperations; - this.updateOperations = updateOperations; - } + /** + Returns the Capitalized form of a string + ```javascript + 'innerHTML'.capitalize() // 'InnerHTML' + 'action_name'.capitalize() // 'Action_name' + 'css-class-name'.capitalize() // 'Css-class-name' + 'my favorite items'.capitalize() // 'My favorite items' + 'privateDocs/ownerInvoice'.capitalize(); // 'PrivateDocs/ownerInvoice' + ``` + @method capitalize + @param {String} str The string to capitalize. + @return {String} The capitalized string. + @public + */ + capitalize: capitalize + }; + exports.fmt = fmt; + exports.loc = loc; + exports.w = w; + exports.decamelize = decamelize; + exports.dasherize = dasherize; + exports.camelize = camelize; + exports.classify = classify; + exports.underscore = underscore; + exports.capitalize = capitalize; +}); +enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemObject) { + 'use strict'; - Environment.prototype.toConditionalReference = function toConditionalReference(reference) { - return new _glimmerRuntimeLibReferences.ConditionalReference(reference); - }; + exports.isArray = isArray; + exports.typeOf = typeOf; - Environment.prototype.getAppendOperations = function getAppendOperations() { - return this.appendOperations; - }; + // ........................................ + // TYPING & ARRAY MESSAGING + // + var TYPE_MAP = { + '[object Boolean]': 'boolean', + '[object Number]': 'number', + '[object String]': 'string', + '[object Function]': 'function', + '[object Array]': 'array', + '[object Date]': 'date', + '[object RegExp]': 'regexp', + '[object Object]': 'object', + '[object FileList]': 'filelist' + }; - Environment.prototype.getDOM = function getDOM() { - return this.updateOperations; - }; + var toString = Object.prototype.toString; - Environment.prototype.getIdentity = function getIdentity(object) { - return _glimmerUtil.ensureGuid(object) + ''; - }; + /** + Returns true if the passed object is an array or Array-like. + + Objects are considered Array-like if any of the following are true: + + - the object is a native Array + - the object has an objectAt property + - the object is an Object, and has a length property + + Unlike `Ember.typeOf` this method returns true even if the passed object is + not formally an array but appears to be array-like (i.e. implements `Ember.Array`) + + ```javascript + Ember.isArray(); // false + Ember.isArray([]); // true + Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true + ``` + + @method isArray + @for Ember + @param {Object} obj The object to test + @return {Boolean} true if the passed object is an array or Array-like + @public + */ - Environment.prototype.statement = function statement(_statement, symbolTable) { - return this.refineStatement(parseStatement(_statement), symbolTable) || _statement; - }; + function isArray(obj) { + if (!obj || obj.setInterval) { + return false; + } + if (Array.isArray(obj)) { + return true; + } + if (_emberRuntimeMixinsArray.default.detect(obj)) { + return true; + } - Environment.prototype.refineStatement = function refineStatement(statement, symbolTable) { - var isSimple = statement.isSimple; - var isBlock = statement.isBlock; - var key = statement.key; - var args = statement.args; - - if (isSimple && isBlock) { - switch (key) { - case 'each': - return new _glimmerRuntimeLibSyntaxBuiltinsEach.default(args); - case 'if': - return new _glimmerRuntimeLibSyntaxBuiltinsIf.default(args); - case 'with': - return new _glimmerRuntimeLibSyntaxBuiltinsWith.default(args); - case 'unless': - return new _glimmerRuntimeLibSyntaxBuiltinsUnless.default(args); - } - } - }; + var type = typeOf(obj); + if ('array' === type) { + return true; + } + if (obj.length !== undefined && 'object' === type) { + return true; + } + return false; + } - Environment.prototype.begin = function begin() { - this.createdComponents = []; - this.createdManagers = []; - this.updatedComponents = []; - this.updatedManagers = []; - this.destructors = []; - this.scheduledInstallManagers = []; - this.scheduledInstallModifiers = []; - this.scheduledUpdateModifierManagers = []; - this.scheduledUpdateModifiers = []; - }; + /** + Returns a consistent type for the passed object. + + Use this instead of the built-in `typeof` to get the type of an item. + It will return the same result across all browsers and includes a bit + more detail. Here is what will be returned: + + | Return Value | Meaning | + |---------------|------------------------------------------------------| + | 'string' | String primitive or String object. | + | 'number' | Number primitive or Number object. | + | 'boolean' | Boolean primitive or Boolean object. | + | 'null' | Null value | + | 'undefined' | Undefined value | + | 'function' | A function | + | 'array' | An instance of Array | + | 'regexp' | An instance of RegExp | + | 'date' | An instance of Date | + | 'filelist' | An instance of FileList | + | 'class' | An Ember class (created using Ember.Object.extend()) | + | 'instance' | An Ember object instance | + | 'error' | An instance of the Error object | + | 'object' | A JavaScript object not inheriting from Ember.Object | + + Examples: + + ```javascript + Ember.typeOf(); // 'undefined' + Ember.typeOf(null); // 'null' + Ember.typeOf(undefined); // 'undefined' + Ember.typeOf('michael'); // 'string' + Ember.typeOf(new String('michael')); // 'string' + Ember.typeOf(101); // 'number' + Ember.typeOf(new Number(101)); // 'number' + Ember.typeOf(true); // 'boolean' + Ember.typeOf(new Boolean(true)); // 'boolean' + Ember.typeOf(Ember.makeArray); // 'function' + Ember.typeOf([1, 2, 90]); // 'array' + Ember.typeOf(/abc/); // 'regexp' + Ember.typeOf(new Date()); // 'date' + Ember.typeOf(event.target.files); // 'filelist' + Ember.typeOf(Ember.Object.extend()); // 'class' + Ember.typeOf(Ember.Object.create()); // 'instance' + Ember.typeOf(new Error('teamocil')); // 'error' + + // 'normal' JavaScript object + Ember.typeOf({ a: 'b' }); // 'object' + ``` + + @method typeOf + @for Ember + @param {Object} item the item to check + @return {String} the type + @public + */ - Environment.prototype.didCreate = function didCreate(component, manager) { - this.createdComponents.push(component); - this.createdManagers.push(manager); - }; + function typeOf(item) { + if (item === null) { + return 'null'; + } + if (item === undefined) { + return 'undefined'; + } + var ret = TYPE_MAP[toString.call(item)] || 'object'; - Environment.prototype.didUpdate = function didUpdate(component, manager) { - this.updatedComponents.push(component); - this.updatedManagers.push(manager); - }; + if (ret === 'function') { + if (_emberRuntimeSystemObject.default.detect(item)) { + ret = 'class'; + } + } else if (ret === 'object') { + if (item instanceof Error) { + ret = 'error'; + } else if (item instanceof _emberRuntimeSystemObject.default) { + ret = 'instance'; + } else if (item instanceof Date) { + ret = 'date'; + } + } - Environment.prototype.scheduleInstallModifier = function scheduleInstallModifier(modifier, manager) { - this.scheduledInstallManagers.push(manager); - this.scheduledInstallModifiers.push(modifier); - }; + return ret; + } +}); +enifed("ember-utils/apply-str", ["exports"], function (exports) { + /** + @param {Object} t target + @param {String} m method + @param {Array} a args + @private + */ + "use strict"; - Environment.prototype.scheduleUpdateModifier = function scheduleUpdateModifier(modifier, manager) { - this.scheduledUpdateModifierManagers.push(manager); - this.scheduledUpdateModifiers.push(modifier); - }; + exports.default = applyStr; - Environment.prototype.didDestroy = function didDestroy(d) { - this.destructors.push(d); - }; + function applyStr(t, m, a) { + var l = a && a.length; + if (!a || !l) { + return t[m](); + } + switch (l) { + case 1: + return t[m](a[0]); + case 2: + return t[m](a[0], a[1]); + case 3: + return t[m](a[0], a[1], a[2]); + case 4: + return t[m](a[0], a[1], a[2], a[3]); + case 5: + return t[m](a[0], a[1], a[2], a[3], a[4]); + default: + return t[m].apply(t, a); + } + } +}); +enifed("ember-utils/assign", ["exports"], function (exports) { + /** + Copy properties from a source object to a target object. + + ```javascript + var a = { first: 'Yehuda' }; + var b = { last: 'Katz' }; + var c = { company: 'Tilde Inc.' }; + Ember.assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' } + ``` + + @method assign + @for Ember + @param {Object} original The object to assign into + @param {Object} ...args The objects to copy properties from + @return {Object} + @public + */ + "use strict"; - Environment.prototype.commit = function commit() { - for (var i = 0; i < this.createdComponents.length; i++) { - var component = this.createdComponents[i]; - var manager = this.createdManagers[i]; - manager.didCreate(component); - } - for (var i = 0; i < this.updatedComponents.length; i++) { - var component = this.updatedComponents[i]; - var manager = this.updatedManagers[i]; - manager.didUpdate(component); - } - for (var i = 0; i < this.destructors.length; i++) { - this.destructors[i].destroy(); - } - for (var i = 0; i < this.scheduledInstallManagers.length; i++) { - var manager = this.scheduledInstallManagers[i]; - var modifier = this.scheduledInstallModifiers[i]; - manager.install(modifier); - } - for (var i = 0; i < this.scheduledUpdateModifierManagers.length; i++) { - var manager = this.scheduledUpdateModifierManagers[i]; - var modifier = this.scheduledUpdateModifiers[i]; - manager.update(modifier); - } - this.createdComponents = null; - this.createdManagers = null; - this.updatedComponents = null; - this.updatedManagers = null; - this.destructors = null; - this.scheduledInstallManagers = null; - this.scheduledInstallModifiers = null; - this.scheduledUpdateModifierManagers = null; - this.scheduledUpdateModifiers = null; - }; + exports.default = assign; - Environment.prototype.attributeFor = function attributeFor(element, attr, isTrusting, namespace) { - return _glimmerRuntimeLibDomAttributeManagers.defaultManagers(element, attr, isTrusting, namespace); - }; + function assign(original) { + for (var i = 1; i < arguments.length; i++) { + var arg = arguments[i]; + if (!arg) { + continue; + } - return Environment; - })(); + var updates = Object.keys(arg); - exports.Environment = Environment; - exports.default = Environment; - - function parseStatement(statement) { - var type = statement.type; - var block = type === 'block' ? statement : null; - var append = type === 'optimized-append' ? statement : null; - var modifier = type === 'modifier' ? statement : null; - var appendType = append && append.value.type; - var args = undefined; - var path = undefined; - if (block) { - args = block.args; - path = block.path; - } else if (append && (appendType === 'unknown' || appendType === 'get')) { - var appendValue = append.value; - args = _glimmerRuntimeLibSyntaxCore.Args.empty(); - path = appendValue.ref.parts; - } else if (append && append.value.type === 'helper') { - var helper = append.value; - args = helper.args; - path = helper.ref.parts; - } else if (modifier) { - path = modifier.path; - args = modifier.args; - } - var key = undefined, - isSimple = undefined; - if (path) { - isSimple = path.length === 1; - key = path[0]; - } - return { - isSimple: isSimple, - path: path, - key: key, - args: args, - appendType: appendType, - original: statement, - isInline: !!append, - isBlock: !!block, - isModifier: !!modifier - }; + for (var _i = 0; _i < updates.length; _i++) { + var prop = updates[_i]; + original[prop] = arg[prop]; + } } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZW52aXJvbm1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBMkRBLEtBQUE7QUFlRSxpQkFmRixLQUFB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BsZXQga2V5OiBzdHJpbmcsIGlzU2ltcGxlOiBib29sZWFuO1xuXG4gICAgaWYgKHBhdGgpIHtcbiAgICAgIGlzU2ltcGxlID0gcGF0aC5sZW5ndGggPT09IDE7XG4gICAgICBrZXkgPSBwYXRoWzBdO1xuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICBpc1NpbXBsZSxcbiAgICAgIHBhdGgsXG4gICAgICBrZXksXG4gICAgICBhcmdzLFxuICAgICAgYXBwZW5kVHlwZSxcbiAgICAgIG9yaWdpbmFsOiBzdGF0ZW1lbnQsXG4gICAgICBpc0lubGluZTogISFhcHBlbmQsXG4gICAgICBpc0Jsb2NrOiAhIWJsb2NrLFxuICAgICAgaXNNb2RpZmllcjogISFtb2RpZmllclxuICAgIH07XG59XG4iXX0= -enifed('glimmer-runtime/lib/helpers/get-dynamic-var', ['exports', 'glimmer-reference'], function (exports, _glimmerReference) { - 'use strict'; - - var DynamicVarReference = (function () { - function DynamicVarReference(scope, nameRef) { - this.scope = scope; - this.nameRef = nameRef; - var varTag = this.varTag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([nameRef.tag, varTag]); - } - - DynamicVarReference.prototype.value = function value() { - return this.getVar().value(); - }; - DynamicVarReference.prototype.get = function get(key) { - return this.getVar().get(key); - }; + return original; + } +}); +enifed('ember-utils/dictionary', ['exports', 'ember-utils/empty-object'], function (exports, _emberUtilsEmptyObject) { + 'use strict'; - DynamicVarReference.prototype.getVar = function getVar() { - var name = String(this.nameRef.value()); - var ref = this.scope.get(name); - this.varTag.update(ref.tag); - return ref; - }; + exports.default = makeDictionary; - return DynamicVarReference; - })(); + // the delete is meant to hint at runtimes that this object should remain in + // dictionary mode. This is clearly a runtime specific hack, but currently it + // appears worthwhile in some usecases. Please note, these deletes do increase + // the cost of creation dramatically over a plain Object.create. And as this + // only makes sense for long-lived dictionaries that aren't instantiated often. - function getDynamicVar(vm, args, symbolTable) { - var scope = vm.dynamicScope(); - var nameRef = args.positional.at(0); - return new DynamicVarReference(scope, nameRef); + function makeDictionary(parent) { + var dict = undefined; + if (parent === null) { + dict = new _emberUtilsEmptyObject.default(); + } else { + dict = Object.create(parent); } - exports.default = getDynamicVar; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvaGVscGVycy9nZXQtZHluYW1pYy12YXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBT0EsbUJBQUE7QUFJRSxpQkFKRixtQkFBQSxDQUlzQixLQUFtQixFQUFVLE9BQThCLEVBQUE7QUFBM0QsZ0JBQUEsQ0FBQSxLQUFLLEdBQUwsS0FBSyxDQUFjO0FBQVUsZ0JBQUEsQ0FBQSxPQUFPLEdBQVAsT0FBTyxDQUF1QjtBQUM3RSxnQkFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLE1BQU0sR0FBRyxzQkFSb0IsWUFBWSxtQkFBdEQsWUFBWSxDQVF3QyxDQUFDO0FBQzFELGdCQUFJLENBQUMsR0FBRyxHQUFHLGtCQVRrRCxPQUFPLENBU2pELENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDO1NBQzNDOztBQVBILDJCQUFBLFdBU0UsS0FBSyxHQUFBLGlCQUFBO0FBQ0gsbUJBQU8sSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDO1NBQzlCOztBQVhILDJCQUFBLFdBYUUsR0FBRyxHQUFBLGFBQUMsR0FBVyxFQUFBO0FBQ2IsbUJBQU8sSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztTQUMvQjs7QUFmSCwyQkFBQSxXQWlCVSxNQUFNLEdBQUEsa0JBQUE7QUFDWixnQkFBSSxJQUFJLEdBQUcsTUFBTSxDQUFDLElBQUksQ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GF0aFJlZmVyZW5jZTxPcGFxdWU+IHtcbiAgbGV0IHNjb3BlID0gdm0uZHluYW1pY1Njb3BlKCk7XG4gIGxldCBuYW1lUmVmID0gYXJncy5wb3NpdGlvbmFsLmF0KDApO1xuXG4gIHJldHVybiBuZXcgRHluYW1pY1ZhclJlZmVyZW5jZShzY29wZSwgbmFtZVJlZik7XG59XG5cbmV4cG9ydCBkZWZhdWx0IChnZXREeW5hbWljVmFyIGFzIEhlbHBlcik7XG4iXX0= -enifed("glimmer-runtime/lib/modifier/interfaces", ["exports"], function (exports) { - "use strict"; + dict['_dict'] = null; + delete dict['_dict']; + return dict; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvbW9kaWZpZXIvaW50ZXJmYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwiZmlsZSI6ImludGVyZmFjZXMuanMiLCJzb3VyY2VzQ29udGVudCI6W119 -enifed("glimmer-runtime/lib/opcode-builder", ["exports"], function (exports) { +enifed("ember-utils/empty-object", ["exports"], function (exports) { + // This exists because `Object.create(null)` is absurdly slow compared + // to `new EmptyObject()`. In either case, you want a null prototype + // when you're treating the object instances as arbitrary dictionaries + // and don't want your keys colliding with build-in methods on the + // default object prototype. + "use strict"; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvb3Bjb2RlLWJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJvcGNvZGUtYnVpbGRlci5qcyIsInNvdXJjZXNDb250ZW50IjpbXX0= -enifed('glimmer-runtime/lib/opcodes', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; - exports.inspect = inspect; + var proto = Object.create(null, { + // without this, we will always still end up with (new + // EmptyObject()).constructor === Object + constructor: { + value: undefined, + enumerable: false, + writable: true + } + }); - var AbstractOpcode = (function () { - function AbstractOpcode() { - _glimmerUtil.initializeGuid(this); - } + function EmptyObject() {} + EmptyObject.prototype = proto; + exports.default = EmptyObject; +}); +enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, _emberUtilsIntern) { + 'use strict'; - AbstractOpcode.prototype.toJSON = function toJSON() { - return { guid: this._guid, type: this.type }; - }; + exports.uuid = uuid; + exports.generateGuid = generateGuid; + exports.guidFor = guidFor; - return AbstractOpcode; - })(); + /** + Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from + jQuery master. We'll just bootstrap our own uuid now. + + @private + @return {Number} the uuid + */ + var _uuid = 0; - exports.AbstractOpcode = AbstractOpcode; + /** + Generates a universally unique identifier. This method + is used internally by Ember for assisting with + the generation of GUID's and other unique identifiers. + + @public + @return {Number} [description] + */ - var Opcode = (function (_AbstractOpcode) { - babelHelpers.inherits(Opcode, _AbstractOpcode); + function uuid() { + return ++_uuid; + } - function Opcode() { - _AbstractOpcode.apply(this, arguments); - this.next = null; - this.prev = null; - } + /** + Prefix used for guids through out Ember. + @private + @property GUID_PREFIX + @for Ember + @type String + @final + */ + var GUID_PREFIX = 'ember'; - return Opcode; - })(AbstractOpcode); + // Used for guid generation... + var numberCache = []; + var stringCache = {}; - exports.Opcode = Opcode; + /** + A unique key used to assign guids and other private metadata to objects. + If you inspect an object in your browser debugger you will often see these. + They can be safely ignored. + + On browsers that support it, these properties are added with enumeration + disabled so they won't show up when you iterate over your properties. + + @private + @property GUID_KEY + @for Ember + @type String + @final + */ + var GUID_KEY = _emberUtilsIntern.default('__ember' + +new Date()); - var UpdatingOpcode = (function (_AbstractOpcode2) { - babelHelpers.inherits(UpdatingOpcode, _AbstractOpcode2); + exports.GUID_KEY = GUID_KEY; + var GUID_DESC = { + writable: true, + configurable: true, + enumerable: false, + value: null + }; - function UpdatingOpcode() { - _AbstractOpcode2.apply(this, arguments); - this.next = null; - this.prev = null; - } + exports.GUID_DESC = GUID_DESC; + var nullDescriptor = { + configurable: true, + writable: true, + enumerable: false, + value: null + }; - return UpdatingOpcode; - })(AbstractOpcode); + var GUID_KEY_PROPERTY = { + name: GUID_KEY, + descriptor: nullDescriptor + }; - exports.UpdatingOpcode = UpdatingOpcode; + exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY; + /** + Generates a new guid, optionally saving the guid to the object that you + pass in. You will rarely need to use this method. Instead you should + call `Ember.guidFor(obj)`, which return an existing guid if available. + + @private + @method generateGuid + @for Ember + @param {Object} [obj] Object the guid will be used for. If passed in, the guid will + be saved on the object and reused whenever you pass the same object + again. + + If no object is passed, just generate a new guid. + @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to + separate the guid into separate namespaces. + @return {String} the guid + */ - function inspect(opcodes) { - var buffer = []; - opcodes.toArray().forEach(function (opcode, i) { - _inspect(opcode.toJSON(), buffer, 0, i); - }); - return buffer.join(''); + function generateGuid(obj, prefix) { + if (!prefix) { + prefix = GUID_PREFIX; } - function _inspect(opcode, buffer, level, index) { - var indentation = []; - for (var i = 0; i < level; i++) { - indentation.push(' '); - } - buffer.push.apply(buffer, indentation); - buffer.push(index + 1 + '. ' + opcode.type.toUpperCase()); - if (opcode.args || opcode.details) { - buffer.push('('); - if (opcode.args) { - buffer.push(opcode.args.join(', ')); - } - if (opcode.details) { - var keys = Object.keys(opcode.details); - if (keys.length) { - if (opcode.args && opcode.args.length) { - buffer.push(', '); - } - buffer.push(keys.map(function (key) { - return key + '=' + opcode.details[key]; - }).join(', ')); - } - } - buffer.push(')'); - } - buffer.push('\n'); - if (opcode.children && opcode.children.length) { - for (var i = 0; i < opcode.children.length; i++) { - _inspect(opcode.children[i], buffer, level + 1, i); - } + var ret = prefix + uuid(); + if (obj) { + if (obj[GUID_KEY] === null) { + obj[GUID_KEY] = ret; + } else { + GUID_DESC.value = ret; + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(GUID_KEY_PROPERTY); + } else { + Object.defineProperty(obj, GUID_KEY, GUID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iAgYnVmZmVyLnB1c2goYCR7aW5kZXgrMX0uICR7b3Bjb2RlLnR5cGUudG9VcHBlckNhc2UoKX1gKTtcblxuICBpZiAob3Bjb2RlLmFyZ3MgfHwgb3Bjb2RlLmRldGFpbHMpIHtcbiAgICBidWZmZXIucHVzaCgnKCcpO1xuXG4gICAgaWYgKG9wY29kZS5hcmdzKSB7XG4gICAgICBidWZmZXIucHVzaChvcGNvZGUuYXJncy5qb2luKCcsICcpKTtcbiAgICB9XG5cbiAgICBpZiAob3Bjb2RlLmRldGFpbHMpIHtcbiAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob3Bjb2RlLmRldGFpbHMpO1xuXG4gICAgICBpZiAoa2V5cy5sZW5ndGgpIHtcbiAgICAgICAgaWYgKG9wY29kZS5hcmdzICYmIG9wY29kZS5hcmdzLmxlbmd0aCkge1xuICAgICAgICAgIGJ1ZmZlci5wdXNoKCcsICcpO1xuICAgICAgICB9XG5cbiAgICAgICAgYnVmZmVyLnB1c2goa2V5cy5tYXAoa2V5ID0+IGAke2tleX09JHtvcGNvZGUuZGV0YWlsc1trZXldfWApLmpvaW4oJywgJykpO1xuICAgICAgfVxuICAgIH1cblxuICAgIGJ1ZmZlci5wdXNoKCcpJyk7XG4gIH1cblxuICBidWZmZXIucHVzaCgnXFxuJyk7XG5cbiAgaWYgKG9wY29kZS5jaGlsZHJlbiAmJiBvcGNvZGUuY2hpbGRyZW4ubGVuZ3RoKSB7XG4gICAgZm9yIChsZXQgaT0wOyBpPG9wY29kZS5jaGlsZHJlbi5sZW5ndGg7IGkrKykge1xuICAgICAgX2luc3BlY3Qob3Bjb2RlLmNoaWxkcmVuW2ldLCBidWZmZXIsIGxldmVsKzEsIGkpO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed("glimmer-runtime/lib/partial", ["exports"], function (exports) { - "use strict"; - - var PartialDefinition = function PartialDefinition(name, template) { - this.name = name; - this.template = template; - }; - - exports.PartialDefinition = PartialDefinition; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvcGFydGlhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFFQSxpQkFBQSxHQUlFLFNBSkYsaUJBQUEsQ0FJYyxJQUFZLEVBQUUsUUFBcUIsRUFBQTtBQUM3QyxZQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztBQUNqQixZQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztLQUMxQiIsImZpbGUiOiJwYXJ0aWFsLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgVGVtcGxhdGUgfSBmcm9tICcuL3RlbXBsYXRlJztcblxuZXhwb3J0IGNsYXNzIFBhcnRpYWxEZWZpbml0aW9uPFQ+IHtcbiAgbmFtZTogc3RyaW5nOyAvLyBmb3IgZGVidWdnaW5nXG4gIHRlbXBsYXRlOiBUZW1wbGF0ZTxUPjtcblxuICBjb25zdHJ1Y3RvcihuYW1lOiBzdHJpbmcsIHRlbXBsYXRlOiBUZW1wbGF0ZTxUPikge1xuICAgIHRoaXMubmFtZSA9IG5hbWU7XG4gICAgdGhpcy50ZW1wbGF0ZSA9IHRlbXBsYXRlO1xuICB9XG59XG4iXX0= -enifed('glimmer-runtime/lib/references', ['exports', 'glimmer-reference'], function (exports, _glimmerReference) { - 'use strict'; + return ret; + } - var PrimitiveReference = (function (_ConstReference) { - babelHelpers.inherits(PrimitiveReference, _ConstReference); + /** + Returns a unique id for the object. If the object does not yet have a guid, + one will be assigned to it. You can call this on any object, + `Ember.Object`-based or not, but be aware that it will add a `_guid` + property. + + You can also use this method on DOM Element objects. + + @public + @method guidFor + @for Ember + @param {Object} obj any object, string, number, Element, or primitive + @return {String} the unique guid for this instance. + */ - function PrimitiveReference(value) { - _ConstReference.call(this, value); - } + function guidFor(obj) { + var type = typeof obj; + var isObject = type === 'object' && obj !== null; + var isFunction = type === 'function'; - PrimitiveReference.create = function create(value) { - if (value === undefined) { - return UNDEFINED_REFERENCE; - } else if (value === null) { - return NULL_REFERENCE; - } else if (value === true) { - return TRUE_REFERENCE; - } else if (value === false) { - return FALSE_REFERENCE; - } else if (typeof value === 'number') { - return new ValueReference(value); - } else { - return new StringReference(value); - } - }; + if ((isObject || isFunction) && obj[GUID_KEY]) { + return obj[GUID_KEY]; + } - PrimitiveReference.prototype.get = function get(key) { - return UNDEFINED_REFERENCE; - }; + // special cases where we don't want to add a key to object + if (obj === undefined) { + return '(undefined)'; + } - return PrimitiveReference; - })(_glimmerReference.ConstReference); + if (obj === null) { + return '(null)'; + } - exports.PrimitiveReference = PrimitiveReference; + var ret = undefined; - var StringReference = (function (_PrimitiveReference) { - babelHelpers.inherits(StringReference, _PrimitiveReference); + // Don't allow prototype changes to String etc. to change the guidFor + switch (type) { + case 'number': + ret = numberCache[obj]; - function StringReference() { - _PrimitiveReference.apply(this, arguments); - this.lengthReference = null; + if (!ret) { + ret = numberCache[obj] = 'nu' + obj; } - StringReference.prototype.get = function get(key) { - if (key === 'length') { - var lengthReference = this.lengthReference; - - if (lengthReference === null) { - lengthReference = this.lengthReference = new ValueReference(this.inner.length); - } - return lengthReference; - } else { - return _PrimitiveReference.prototype.get.call(this, key); - } - }; - - return StringReference; - })(PrimitiveReference); + return ret; - var ValueReference = (function (_PrimitiveReference2) { - babelHelpers.inherits(ValueReference, _PrimitiveReference2); + case 'string': + ret = stringCache[obj]; - function ValueReference(value) { - _PrimitiveReference2.call(this, value); + if (!ret) { + ret = stringCache[obj] = 'st' + uuid(); } - return ValueReference; - })(PrimitiveReference); + return ret; - var UNDEFINED_REFERENCE = new ValueReference(undefined); - exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE; - var NULL_REFERENCE = new ValueReference(null); - exports.NULL_REFERENCE = NULL_REFERENCE; - var TRUE_REFERENCE = new ValueReference(true); - var FALSE_REFERENCE = new ValueReference(false); + case 'boolean': + return obj ? '(true)' : '(false)'; - var ConditionalReference = (function () { - function ConditionalReference(inner) { - this.inner = inner; - this.tag = inner.tag; + default: + if (obj === Object) { + return '(Object)'; } - ConditionalReference.prototype.value = function value() { - return this.toBool(this.inner.value()); - }; - - ConditionalReference.prototype.toBool = function toBool(value) { - return !!value; - }; - - return ConditionalReference; - })(); - - exports.ConditionalReference = ConditionalReference; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvcmVmZXJlbmNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFLQSxrQkFBQTs4QkFBQSxrQkFBQTs7QUFzQkUsaUJBdEJGLGtCQUFBLENBc0J3QixLQUFRLEVBQUE7QUFDNUIsdUNBQU0sS0FBSyxDQUFDLENBQUM7U0FDZDs7QUF4QkgsMEJBQUEsQ0FNUyxNQUFNLEdBQUEsZ0JBQUMsS0FBZ0IsRUFBQTtBQUM1QixnQkFBSSxLQUFLLEtBQUssU0FBUyxFQUFFO0FBQ3ZCLHVCQUFPLG1CQUFtQixDQUFDO2FBQzVCLE1BQU0sSUFBSSxLQUFLLEtBQUssSUFBSSxFQUFFO0FBQ3pCLHVCQUFPLGNBQWMsQ0FBQzthQUN2QixNQUFNLElBQUksS0FBSyxLQUFLLElBQUksRUFBRTtBQUN6Qix1QkFBTyxjQUFjLENBQUM7YUFDdkIsTUFBTSxJQUFJLEtBQUssS0FBSyxLQUFLLEVBQUU7QUFDMUIsdUJBQU8sZUFBZSxDQUFDO2FBQ3hCLE1BQU0sSUFBSSxPQUFPLEtBQUssS0FBSyxRQUFRLEVBQUU7QUFDcEMsdUJBQU8sSUFBSSxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUM7YUFDbEMsTUFBTTtBQUNMLHVCQUFPLElBQUksZUFBZSxDQUFDLEtBQUssQ0FBQyxDQUFDO2FBQ25DO1NBQ0Y7O0FBcEJILDBCQUFBLFdBMEJFLEdBQUcsR0F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HBvcnQgY29uc3QgVU5ERUZJTkVEX1JFRkVSRU5DRTogUHJpbWl0aXZlUmVmZXJlbmNlPHVuZGVmaW5lZD4gPSBuZXcgVmFsdWVSZWZlcmVuY2UodW5kZWZpbmVkKTtcbmV4cG9ydCBjb25zdCBOVUxMX1JFRkVSRU5DRTogUHJpbWl0aXZlUmVmZXJlbmNlPG51bGw+ID0gbmV3IFZhbHVlUmVmZXJlbmNlKG51bGwpO1xuY29uc3QgVFJVRV9SRUZFUkVOQ0U6IFByaW1pdGl2ZVJlZmVyZW5jZTxib29sZWFuPiA9IG5ldyBWYWx1ZVJlZmVyZW5jZSh0cnVlKTtcbmNvbnN0IEZBTFNFX1JFRkVSRU5DRTogUHJpbWl0aXZlUmVmZXJlbmNlPGJvb2xlYW4+ID0gbmV3IFZhbHVlUmVmZXJlbmNlKGZhbHNlKTtcblxuZXhwb3J0IGNsYXNzIENvbmRpdGlvbmFsUmVmZXJlbmNlIGltcGxlbWVudHMgUmVmZXJlbmNlPGJvb2xlYW4+IHtcbiAgcHVibGljIHRhZzogUmV2aXNpb25UYWc7XG5cbiAgY29uc3RydWN0b3IocHJpdmF0ZSBpbm5lcjogUmVmZXJlbmNlPE9wYXF1ZT4pIHtcbiAgICB0aGlzLnRhZyA9IGlubmVyLnRhZztcbiAgfVxuXG4gIHZhbHVlKCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLnRvQm9vbCh0aGlzLmlubmVyLnZhbHVlKCkpO1xuICB9XG5cbiAgcHJvdGVjdGVkIHRvQm9vbCh2YWx1ZTogT3BhcXVlKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuICEhdmFsdWU7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/scanner', ['exports', 'glimmer-runtime/lib/syntax/statements', 'glimmer-runtime/lib/compiled/blocks', 'glimmer-util', 'glimmer-runtime/lib/symbol-table'], function (exports, _glimmerRuntimeLibSyntaxStatements, _glimmerRuntimeLibCompiledBlocks, _glimmerUtil, _glimmerRuntimeLibSymbolTable) { - 'use strict'; - - var Scanner = (function () { - function Scanner(block, meta, env) { - this.block = block; - this.meta = meta; - this.env = env; + if (obj === Array) { + return '(Array)'; } - Scanner.prototype.scanEntryPoint = function scanEntryPoint() { - var block = this.block; - var meta = this.meta; - - var symbolTable = _glimmerRuntimeLibSymbolTable.default.forEntryPoint(meta); - var program = buildStatements(block, block.blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.EntryPoint(program, symbolTable); - }; - - Scanner.prototype.scanLayout = function scanLayout() { - var block = this.block; - var meta = this.meta; - var blocks = block.blocks; - var named = block.named; - var yields = block.yields; - var hasPartials = block.hasPartials; - - var symbolTable = _glimmerRuntimeLibSymbolTable.default.forLayout(named, yields, hasPartials, meta); - var program = buildStatements(block, blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.Layout(program, symbolTable, named, yields, hasPartials); - }; + ret = GUID_PREFIX + uuid(); - Scanner.prototype.scanPartial = function scanPartial(symbolTable) { - var block = this.block; - var blocks = block.blocks; - var locals = block.locals; + if (obj[GUID_KEY] === null) { + obj[GUID_KEY] = ret; + } else { + GUID_DESC.value = ret; - var program = buildStatements(block, blocks, symbolTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.PartialBlock(program, symbolTable, locals); - }; + if (obj.__defineNonEnumerable) { + obj.__defineNonEnumerable(GUID_KEY_PROPERTY); + } else { + Object.defineProperty(obj, GUID_KEY, GUID_DESC); + } + } + return ret; + } + } +}); +enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string', 'ember-utils/weak-map-utils', 'ember-utils/proxy-utils'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString, _emberUtilsWeakMapUtils, _emberUtilsProxyUtils) { + /* + This package will be eagerly parsed and should have no dependencies on external + packages. + + It is intended to be used to share utility methods that will be needed + by every Ember application (and is **not** a dumping ground of useful utilities). + + Utility methods that are needed in < 80% of cases should be placed + elsewhere (so they can be lazily evaluated / parsed). + */ + 'use strict'; - return Scanner; - })(); + exports.symbol = _emberUtilsSymbol.default; + exports.getOwner = _emberUtilsOwner.getOwner; + exports.setOwner = _emberUtilsOwner.setOwner; + exports.OWNER = _emberUtilsOwner.OWNER; + exports.assign = _emberUtilsAssign.default; + exports.EmptyObject = _emberUtilsEmptyObject.default; + exports.dictionary = _emberUtilsDictionary.default; + exports.uuid = _emberUtilsGuid.uuid; + exports.GUID_KEY = _emberUtilsGuid.GUID_KEY; + exports.GUID_DESC = _emberUtilsGuid.GUID_DESC; + exports.GUID_KEY_PROPERTY = _emberUtilsGuid.GUID_KEY_PROPERTY; + exports.generateGuid = _emberUtilsGuid.generateGuid; + exports.guidFor = _emberUtilsGuid.guidFor; + exports.intern = _emberUtilsIntern.default; + exports.checkHasSuper = _emberUtilsSuper.checkHasSuper; + exports.ROOT = _emberUtilsSuper.ROOT; + exports.wrap = _emberUtilsSuper.wrap; + exports.inspect = _emberUtilsInspect.default; + exports.lookupDescriptor = _emberUtilsLookupDescriptor.default; + exports.canInvoke = _emberUtilsInvoke.canInvoke; + exports.tryInvoke = _emberUtilsInvoke.tryInvoke; + exports.makeArray = _emberUtilsMakeArray.default; + exports.applyStr = _emberUtilsApplyStr.default; + exports.NAME_KEY = _emberUtilsName.default; + exports.toString = _emberUtilsToString.default; + exports.HAS_NATIVE_WEAKMAP = _emberUtilsWeakMapUtils.HAS_NATIVE_WEAKMAP; + exports.HAS_NATIVE_PROXY = _emberUtilsProxyUtils.HAS_NATIVE_PROXY; +}); +enifed('ember-utils/inspect', ['exports'], function (exports) { + 'use strict'; - exports.default = Scanner; + exports.default = inspect; + var objectToString = Object.prototype.toString; - function buildStatements(_ref, blocks, symbolTable, env) { - var statements = _ref.statements; + /** + Convenience method to inspect an object. This method will attempt to + convert the object into a useful string description. + + It is a pretty simple implementation. If you want something more robust, + use something like JSDump: https://github.com/NV/jsDump + + @method inspect + @for Ember + @param {Object} obj The object you want to inspect. + @return {String} A description of the object + @since 1.4.0 + @private + */ - if (statements.length === 0) return EMPTY_PROGRAM; - return new BlockScanner(statements, blocks, symbolTable, env).scan(); + function inspect(obj) { + if (obj === null) { + return 'null'; + } + if (obj === undefined) { + return 'undefined'; + } + if (Array.isArray(obj)) { + return '[' + obj + ']'; + } + // for non objects + var type = typeof obj; + if (type !== 'object' && type !== 'symbol') { + return '' + obj; + } + // overridden toString + if (typeof obj.toString === 'function' && obj.toString !== objectToString) { + return obj.toString(); } - var EMPTY_PROGRAM = _glimmerUtil.EMPTY_SLICE; - var BlockScanner = (function () { - function BlockScanner(statements, blocks, symbolTable, env) { - this.blocks = blocks; - this.symbolTable = symbolTable; - this.stack = new _glimmerUtil.Stack(); - this.stack.push(new ChildBlockScanner(symbolTable)); - this.reader = new SyntaxReader(statements, symbolTable, this); - this.env = env; + // Object.prototype.toString === {}.toString + var v = undefined; + var ret = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + v = obj[key]; + if (v === 'toString') { + continue; + } // ignore useless items + if (typeof v === 'function') { + v = 'function() { ... }'; } - BlockScanner.prototype.scan = function scan() { - var statement = undefined; - while (statement = this.reader.next()) { - this.addStatement(statement); - } - return this.stack.current.program; - }; - - BlockScanner.prototype.blockFor = function blockFor(symbolTable, id) { - var block = this.blocks[id]; - var childTable = _glimmerRuntimeLibSymbolTable.default.forBlock(this.symbolTable, block.locals); - var program = buildStatements(block, this.blocks, childTable, this.env); - return new _glimmerRuntimeLibCompiledBlocks.InlineBlock(program, childTable, block.locals); - }; - - BlockScanner.prototype.startBlock = function startBlock(locals) { - var childTable = _glimmerRuntimeLibSymbolTable.default.forBlock(this.symbolTable, locals); - this.stack.push(new ChildBlockScanner(childTable)); - }; - - BlockScanner.prototype.endBlock = function endBlock(locals) { - var _stack$pop = this.stack.pop(); - - var program = _stack$pop.program; - var symbolTable = _stack$pop.symbolTable; - - var block = new _glimmerRuntimeLibCompiledBlocks.InlineBlock(program, symbolTable, locals); - this.addChild(block); - return block; - }; - - BlockScanner.prototype.addChild = function addChild(block) { - this.stack.current.addChild(block); - }; - - BlockScanner.prototype.addStatement = function addStatement(statement) { - this.stack.current.addStatement(statement.scan(this)); - }; - - BlockScanner.prototype.next = function next() { - return this.reader.next(); - }; - - return BlockScanner; - })(); - - exports.BlockScanner = BlockScanner; - - var ChildBlockScanner = (function () { - function ChildBlockScanner(symbolTable) { - this.symbolTable = symbolTable; - this.children = []; - this.program = new _glimmerUtil.LinkedList(); + if (v && typeof v.toString !== 'function') { + ret.push(key + ': ' + objectToString.call(v)); + } else { + ret.push(key + ': ' + v); } - - ChildBlockScanner.prototype.addChild = function addChild(block) { - this.children.push(block); - }; - - ChildBlockScanner.prototype.addStatement = function addStatement(statement) { - this.program.append(statement); - }; - - return ChildBlockScanner; - })(); - - var SyntaxReader = (function () { - function SyntaxReader(statements, symbolTable, scanner) { - this.statements = statements; - this.symbolTable = symbolTable; - this.scanner = scanner; - this.current = 0; - this.last = null; - } - - SyntaxReader.prototype.next = function next() { - var last = this.last; - if (last) { - this.last = null; - return last; - } else if (this.current === this.statements.length) { - return null; - } - var sexp = this.statements[this.current++]; - return _glimmerRuntimeLibSyntaxStatements.default(sexp, this.symbolTable, this.scanner); - }; - - return SyntaxReader; - })(); + } + } + return '{' + ret.join(', ') + '}'; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcn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HRoaXMuc3RhdGVtZW50c1t0aGlzLmN1cnJlbnQrK107XG4gICAgcmV0dXJuIGJ1aWxkU3RhdGVtZW50KHNleHAsIHRoaXMuc3ltYm9sVGFibGUsIHRoaXMuc2Nhbm5lcik7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/symbol-table', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; - - var SymbolTable = (function () { - function SymbolTable(parent) { - var meta = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - - this.parent = parent; - this.meta = meta; - this.locals = _glimmerUtil.dict(); - this.named = _glimmerUtil.dict(); - this.yields = _glimmerUtil.dict(); - this.partialArgs = null; - this.size = 1; - this.top = parent ? parent.top : this; - } - - SymbolTable.forEntryPoint = function forEntryPoint(meta) { - return new SymbolTable(null, meta).initEntryPoint(); - }; - - SymbolTable.forLayout = function forLayout(named, yields, hasPartials, meta) { - return new SymbolTable(null, meta).initLayout(named, yields, hasPartials); - }; - - SymbolTable.forBlock = function forBlock(parent, locals) { - return new SymbolTable(parent, null).initBlock(locals); - }; - - SymbolTable.prototype.initEntryPoint = function initEntryPoint() { - return this; - }; - - SymbolTable.prototype.initBlock = function initBlock(locals) { - this.initPositionals(locals); - return this; - }; - - SymbolTable.prototype.initLayout = function initLayout(named, yields, hasPartials) { - this.initNamed(named); - this.initYields(yields); - this.initPartials(hasPartials); - return this; - }; - - SymbolTable.prototype.initPositionals = function initPositionals(positionals) { - var _this = this; - - if (positionals) positionals.forEach(function (s) { - return _this.locals[s] = _this.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initNamed = function initNamed(named) { - var _this2 = this; - - if (named) named.forEach(function (s) { - return _this2.named[s] = _this2.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initYields = function initYields(yields) { - var _this3 = this; - - if (yields) yields.forEach(function (b) { - return _this3.yields[b] = _this3.top.size++; - }); - return this; - }; - - SymbolTable.prototype.initPartials = function initPartials(hasPartials) { - if (hasPartials) this.top.partialArgs = this.top.size++; - return this; - }; - - SymbolTable.prototype.getMeta = function getMeta() { - var meta = this.meta; - var parent = this.parent; - - if (!meta && parent) { - meta = parent.getMeta(); - } - return meta; - }; - - SymbolTable.prototype.getYield = function getYield(name) { - var yields = this.yields; - var parent = this.parent; - - var symbol = yields[name]; - if (!symbol && parent) { - symbol = parent.getYield(name); - } - return symbol; - }; - - SymbolTable.prototype.getNamed = function getNamed(name) { - var named = this.named; - var parent = this.parent; - - var symbol = named[name]; - if (!symbol && parent) { - symbol = parent.getNamed(name); - } - return symbol; - }; - - SymbolTable.prototype.getLocal = function getLocal(name) { - var locals = this.locals; - var parent = this.parent; - - var symbol = locals[name]; - if (!symbol && parent) { - symbol = parent.getLocal(name); - } - return symbol; - }; - - SymbolTable.prototype.getPartialArgs = function getPartialArgs() { - return this.top.partialArgs; - }; - - SymbolTable.prototype.isTop = function isTop() { - return this.top === this; - }; +enifed("ember-utils/intern", ["exports"], function (exports) { + /** + Strongly hint runtimes to intern the provided string. + + When do I need to use this function? + + For the most part, never. Pre-mature optimization is bad, and often the + runtime does exactly what you need it to, and more often the trade-off isn't + worth it. + + Why? + + Runtimes store strings in at least 2 different representations: + Ropes and Symbols (interned strings). The Rope provides a memory efficient + data-structure for strings created from concatenation or some other string + manipulation like splitting. + + Unfortunately checking equality of different ropes can be quite costly as + runtimes must resort to clever string comparison algorithms. These + algorithms typically cost in proportion to the length of the string. + Luckily, this is where the Symbols (interned strings) shine. As Symbols are + unique by their string content, equality checks can be done by pointer + comparison. + + How do I know if my string is a rope or symbol? + + Typically (warning general sweeping statement, but truthy in runtimes at + present) static strings created as part of the JS source are interned. + Strings often used for comparisons can be interned at runtime if some + criteria are met. One of these criteria can be the size of the entire rope. + For example, in chrome 38 a rope longer then 12 characters will not + intern, nor will segments of that rope. + + Some numbers: http://jsperf.com/eval-vs-keys/8 + + Known Trick™ + + @private + @return {String} interned version of the provided string + */ + "use strict"; - return SymbolTable; - })(); + exports.default = intern; - exports.default = SymbolTable; + function intern(str) { + var obj = {}; + obj[str] = 1; + for (var key in obj) { + if (key === str) { + return key; + } + } + return str; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ltYm9sLXRhYmxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQUdBLFdBQUE7QUFvQkUsaUJBcEJGLFdBQUEsQ0FvQnNCLE1BQW1CLEVBQW1DO2dCQUF6QixJQUFJLHlEQUFpQixJQUFJOztBQUF0RCxnQkFBQSxDQUFBLE1BQU0sR0FBTixNQUFNLENBQWE7QUFBVSxnQkFBQSxDQUFBLElBQUksR0FBSixJQUFJLENBQXFCO0FBTmxFLGdCQUFBLENBQUEsTUFBTSxHQUFHLGFBakJWLElBQUksRUFpQm9CLENBQUM7QUFDeEIsZ0JBQUEsQ0FBQSxLQUFLLEdBQUcsYUFsQlQsSUFBSSxFQWtCbUIsQ0FBQztBQUN2QixnQkFBQSxDQUFBLE1BQU0sR0FBRyxhQW5CVixJQUFJLEVBbUJvQixDQUFDO0FBQ3hCLGdCQUFBLENBQUEsV0FBVyxHQUFXLElBQUksQ0FBQztBQUM1QixnQkFBQSxDQUFBLElBQUksR0FBRyxDQUFDLENBQUM7QUFHZCxnQkFBSSxDQUFDLEdBQUcsR0FBRyxNQUFNLEdBQUcsTUFBTSxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUM7U0FDdkM7O0FBdEJILG1CQUFBLENBQ1MsYUFBYSxHQUFBLHVCQUFDLElBQWtCLEVBQUE7QUFDckMsbUJBQU8sSUFBSSxXQUFXLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLGNBQWMsRUFBRSxDQUFDO1NBQ3JEOztBQUhILG1CQUFBLENBS1MsU0FBUyxHQUFBLG1CQUFDLEtBQWUsRUFBRSxNQUFnQixFQUFFLFdBQW9CLEVBQUUsSUFBa0IsRUFBQTtBQUMxRixtQk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AgIHN5bWJvbCA9IHBhcmVudC5nZXRZaWVsZChuYW1lKTtcbiAgICB9XG5cbiAgICByZXR1cm4gc3ltYm9sO1xuICB9XG5cbiAgZ2V0TmFtZWQobmFtZTogc3RyaW5nKTogbnVtYmVyIHtcbiAgICBsZXQgeyBuYW1lZCwgcGFyZW50IH0gPSB0aGlzO1xuXG4gICAgbGV0IHN5bWJvbCA9IG5hbWVkW25hbWVdO1xuXG4gICAgaWYgKCFzeW1ib2wgJiYgcGFyZW50KSB7XG4gICAgICBzeW1ib2wgPSBwYXJlbnQuZ2V0TmFtZWQobmFtZSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHN5bWJvbDtcbiAgfVxuXG4gIGdldExvY2FsKG5hbWU6IHN0cmluZyk6IG51bWJlciB7XG4gICAgbGV0IHsgbG9jYWxzLCBwYXJlbnQgfSA9IHRoaXM7XG5cbiAgICBsZXQgc3ltYm9sID0gbG9jYWxzW25hbWVdO1xuXG4gICAgaWYgKCFzeW1ib2wgJiYgcGFyZW50KSB7XG4gICAgICBzeW1ib2wgPSBwYXJlbnQuZ2V0TG9jYWwobmFtZSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHN5bWJvbDtcbiAgfVxuXG4gIGdldFBhcnRpYWxBcmdzKCk6IG51bWJlciB7XG4gICAgcmV0dXJuIHRoaXMudG9wLnBhcnRpYWxBcmdzO1xuICB9XG5cbiAgaXNUb3AoKTogYm9vbGVhbiB7XG4gICAgcmV0dXJuIHRoaXMudG9wID09PSB0aGlzO1xuICB9XG59XG4iXX0= -enifed("glimmer-runtime/lib/syntax", ["exports"], function (exports) { - "use strict"; - - exports.isAttribute = isAttribute; - - var Statement = (function () { - function Statement() { - this.next = null; - this.prev = null; - } - - Statement.fromSpec = function fromSpec(spec, symbolTable, scanner) { - throw new Error("You need to implement fromSpec on " + this); - }; - - Statement.prototype.clone = function clone() { - // not type safe but the alternative is extreme boilerplate per - // syntax subclass. - return new this.constructor(this); - }; - - Statement.prototype.scan = function scan(scanner) { - return this; - }; - - return Statement; - })(); - - exports.Statement = Statement; +enifed('ember-utils/invoke', ['exports', 'ember-utils/apply-str'], function (exports, _emberUtilsApplyStr) { + 'use strict'; - var Expression = (function () { - function Expression() {} + exports.canInvoke = canInvoke; + exports.tryInvoke = tryInvoke; - Expression.fromSpec = function fromSpec(spec, blocks) { - throw new Error("You need to implement fromSpec on " + this); - }; + /** + Checks to see if the `methodName` exists on the `obj`. + + ```javascript + let foo = { bar: function() { return 'bar'; }, baz: null }; + + Ember.canInvoke(foo, 'bar'); // true + Ember.canInvoke(foo, 'baz'); // false + Ember.canInvoke(foo, 'bat'); // false + ``` + + @method canInvoke + @for Ember + @param {Object} obj The object to check for the method + @param {String} methodName The method name to check for + @return {Boolean} + @private + */ - return Expression; - })(); + function canInvoke(obj, methodName) { + return !!(obj && typeof obj[methodName] === 'function'); + } - exports.Expression = Expression; - var ATTRIBUTE = "e1185d30-7cac-4b12-b26a-35327d905d92"; - exports.ATTRIBUTE = ATTRIBUTE; - var ARGUMENT = "0f3802314-d747-bbc5-0168-97875185c3rt"; - exports.ARGUMENT = ARGUMENT; + /** + Checks to see if the `methodName` exists on the `obj`, + and if it does, invokes it with the arguments passed. + + ```javascript + let d = new Date('03/15/2013'); + + Ember.tryInvoke(d, 'getTime'); // 1363320000000 + Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 + Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined + ``` + + @method tryInvoke + @for Ember + @param {Object} obj The object to check for the method + @param {String} methodName The method name to check for + @param {Array} [args] The arguments to pass to the method + @return {*} the return value of the invoked method or undefined if it cannot be invoked + @public + */ - var Attribute = (function (_Statement) { - babelHelpers.inherits(Attribute, _Statement); + function tryInvoke(obj, methodName, args) { + if (canInvoke(obj, methodName)) { + return args ? _emberUtilsApplyStr.default(obj, methodName, args) : _emberUtilsApplyStr.default(obj, methodName); + } + } +}); +enifed("ember-utils/lookup-descriptor", ["exports"], function (exports) { + "use strict"; - function Attribute() { - _Statement.apply(this, arguments); - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - } + exports.default = lookupDescriptor; - return Attribute; - })(Statement); + function lookupDescriptor(obj, keyName) { + var current = obj; + while (current) { + var descriptor = Object.getOwnPropertyDescriptor(current, keyName); - exports.Attribute = Attribute; + if (descriptor) { + return descriptor; + } - var Argument = (function (_Statement2) { - babelHelpers.inherits(Argument, _Statement2); + current = Object.getPrototypeOf(current); + } - function Argument() { - _Statement2.apply(this, arguments); - this["0f3802314-d747-bbc5-0168-97875185c3rt"] = true; - } + return null; + } +}); +enifed("ember-utils/make-array", ["exports"], function (exports) { + "use strict"; - return Argument; - })(Statement); + exports.default = makeArray; + var isArray = Array.isArray; - exports.Argument = Argument; + /** + Forces the passed object to be part of an array. If the object is already + an array, it will return the object. Otherwise, it will add the object to + an array. If obj is `null` or `undefined`, it will return an empty array. + + ```javascript + Ember.makeArray(); // [] + Ember.makeArray(null); // [] + Ember.makeArray(undefined); // [] + Ember.makeArray('lindsay'); // ['lindsay'] + Ember.makeArray([1, 2, 42]); // [1, 2, 42] + + let controller = Ember.ArrayProxy.create({ content: [] }); + + Ember.makeArray(controller) === controller; // true + ``` + + @method makeArray + @for Ember + @param {Object} obj the object + @return {Array} + @private + */ - function isAttribute(value) { - return value && value[ATTRIBUTE] === true; + function makeArray(obj) { + if (obj === null || obj === undefined) { + return []; } + return isArray(obj) ? obj : [obj]; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O1FBbUJBLFNBQUE7QUFBQSxpQkFBQSxTQUFBLEdBQUE7QUFNUyxnQkFBQSxDQUFBLElBQUksR0FBYyxJQUFJLENBQUM7QUFDdkIsZ0JBQUEsQ0FBQSxJQUFJLEdBQWMsSUFBSSxDQUFDO1NBYS9COztBQXBCRCxpQkFBQSx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N0YXRlbWVudCB7XG4gIFwiMGYzODAyMzE0LWQ3NDctYmJjNS0wMTY4LTk3ODc1MTg1YzNydFwiID0gdHJ1ZTtcbiAgbmFtZTogc3RyaW5nO1xuICBuYW1lc3BhY2U6IHN0cmluZztcbiAgYWJzdHJhY3QgdmFsdWVTeW50YXgoKTogRXhwcmVzc2lvbjxUPjtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGlzQXR0cmlidXRlKHZhbHVlOiBTdGF0ZW1lbnQpOiB2YWx1ZSBpcyBBdHRyaWJ1dGU8YW55PiB7XG4gIHJldHVybiB2YWx1ZSAmJiB2YWx1ZVtBVFRSSUJVVEVdID09PSB0cnVlO1xufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/each', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var EachSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(EachSyntax, _StatementSyntax); - - function EachSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "each-statement"; - } - - EachSyntax.prototype.compile = function compile(dsl, env) { - // Enter(BEGIN, END) - // BEGIN: Noop - // PutArgs - // PutIterable - // JumpUnless(ELSE) - // EnterList(BEGIN2, END2) - // ITER: Noop - // NextIter(BREAK) - // EnterWithKey(BEGIN2, END2) - // BEGIN2: Noop - // PushChildScope - // Evaluate(default) - // PopScope - // END2: Noop - // Exit - // Jump(ITER) - // BREAK: Noop - // ExitList - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.block(args, function (dsl, BEGIN, END) { - dsl.putIterator(); - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - } else { - dsl.jumpUnless(END); - } - dsl.iter(function (dsl, BEGIN, END) { - dsl.evaluate('default', blocks.default); - }); - if (blocks.inverse) { - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } - }); - }; - - return EachSyntax; - })(_glimmerRuntimeLibSyntax.Statement); +enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { + 'use strict'; - exports.default = EachSyntax; + exports.default = _emberUtilsSymbol.default('NAME_KEY'); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL2VhY2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBVUEsVUFBQTs4QkFBQSxVQUFBOztBQUdFLGlCQUhGLFVBQUEsQ0FHcUIsSUFBaUIsRUFBQTtBQUNsQyx1Q0FBTyxDQUFDO0FBRFMsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFhO0FBRnBDLGdCQUFBLENBQUEsSUFBSSxHQUFHLGdCQUFnQixDQUFDO1NBSXZCOztBQUxILGtCQUFBLFdBT0UsT0FBTyxHQUFBLGlCQUFDLEdBQXFCLEVBQUUsR0FBZ0IsRUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O2dCQXlCdkMsSUFBSSxHQUF1QixJQUFJLENBQS9CLElBQUk7Z0JBQVUsTUFBTSxHQUFPLElBQUksQ0FBekIsSUFBSSxDQUFJLE1BQU07O0FBRTFCLGVBQUcsQ0FBQyxLQUFLLENBQUMsSUFBSSxFQUFFLFVBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxHQUFHLEVBQUE7QUFDOUIsbUJBQUcsQ0FBQyxXQUFXLEVBQUUsQ0FBQztBQUVsQixvQkFBSSxNQUFNLENBQUMsT0FBTyxFQUFFO0FBQ2xCLHVCQUFHLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFDO2lCQUN4QixNQUFNO0FBQ0wsdUJBQUcsQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDLENBQUM7aUJBQ3JCO0FBRUQsbUJBQUcsQ0FBQyxJQUFJL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NMLCBlbnY6IEVudmlyb25tZW50KSB7XG4gICAgLy8gICAgICAgICBFbnRlcihCRUdJTiwgRU5EKVxuICAgIC8vIEJFR0lOOiAgTm9vcFxuICAgIC8vICAgICAgICAgUHV0QXJnc1xuICAgIC8vICAgICAgICAgUHV0SXRlcmFibGVcbiAgICAvLyAgICAgICAgIEp1bXBVbmxlc3MoRUxTRSlcbiAgICAvLyAgICAgICAgIEVudGVyTGlzdChCRUdJTjIsIEVORDIpXG4gICAgLy8gSVRFUjogICBOb29wXG4gICAgLy8gICAgICAgICBOZXh0SXRlcihCUkVBSylcbiAgICAvLyAgICAgICAgIEVudGVyV2l0aEtleShCRUdJTjIsIEVORDIpXG4gICAgLy8gQkVHSU4yOiBOb29wXG4gICAgLy8gICAgICAgICBQdXNoQ2hpbGRTY29wZVxuICAgIC8vICAgICAgICAgRXZhbHVhdGUoZGVmYXVsdClcbiAgICAvLyAgICAgICAgIFBvcFNjb3BlXG4gICAgLy8gRU5EMjogICBOb29wXG4gICAgLy8gICAgICAgICBFeGl0XG4gICAgLy8gICAgICAgICBKdW1wKElURVIpXG4gICAgLy8gQlJFQUs6ICBOb29wXG4gICAgLy8gICAgICAgICBFeGl0TGlzdFxuICAgIC8vICAgICAgICAgSnVtcChFTkQpXG4gICAgLy8gRUxTRTogICBOb29wXG4gICAgLy8gICAgICAgICBFdmFsdWxhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgIE5vb3BcbiAgICAvLyAgICAgICAgIEV4aXRcblxuICAgIGxldCB7IGFyZ3MsIGFyZ3M6IHsgYmxvY2tzIH0gfSA9IHRoaXM7XG5cbiAgICBkc2wuYmxvY2soYXJncywgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgZHNsLnB1dEl0ZXJhdG9yKCk7XG5cbiAgICAgIGlmIChibG9ja3MuaW52ZXJzZSkge1xuICAgICAgICBkc2wuanVtcFVubGVzcygnRUxTRScpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgZHNsLmp1bXBVbmxlc3MoRU5EKTtcbiAgICAgIH1cblxuICAgICAgZHNsLml0ZXIoKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgICBkc2wuZXZhbHVhdGUoJ2RlZmF1bHQnLCBibG9ja3MuZGVmYXVsdCk7XG4gICAgICB9KTtcblxuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wKEVORCk7XG4gICAgICAgIGRzbC5sYWJlbCgnRUxTRScpO1xuICAgICAgICBkc2wuZXZhbHVhdGUoJ2ludmVyc2UnLCBibG9ja3MuaW52ZXJzZSk7XG4gICAgICB9XG4gICAgfSk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/syntax/builtins/if', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var IfSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(IfSyntax, _StatementSyntax); - - function IfSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "if-statement"; - } - - IfSyntax.prototype.compile = function compile(dsl) { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl, BEGIN, END) { - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpUnless(END); - dsl.evaluate('default', blocks.default); - } - }); - }; - - return IfSyntax; - })(_glimmerRuntimeLibSyntax.Statement); +enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { + /** + @module ember + @submodule ember-runtime + */ - exports.default = IfSyntax; -}); -//# sourceMapping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TFNFOiAgTm9vcFxuICAgIC8vICAgICAgICBFdmFsdWxhdGUoaW52ZXJzZSlcbiAgICAvLyBFTkQ6ICAgTm9vcFxuICAgIC8vICAgICAgICBFeGl0XG5cbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoRU5EKTtcbiAgICAgICAgZHNsLmxhYmVsKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnaW52ZXJzZScsIGJsb2Nrcy5pbnZlcnNlKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/in-element', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; + 'use strict'; - var InElementSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(InElementSyntax, _StatementSyntax); + exports.getOwner = getOwner; + exports.setOwner = setOwner; + var OWNER = _emberUtilsSymbol.default('OWNER'); - function InElementSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "in-element-statement"; - } + exports.OWNER = OWNER; + /** + Framework objects in an Ember application (components, services, routes, etc.) + are created via a factory and dependency injection system. Each of these + objects is the responsibility of an "owner", which handled its + instantiation and manages its lifetime. + + `getOwner` fetches the owner object responsible for an instance. This can + be used to lookup or resolve other class instances, or register new factories + into the owner. + + For example, this component dynamically looks up a service based on the + `audioType` passed as an attribute: + + ``` + // app/components/play-audio.js + import Ember from 'ember'; + + // Usage: + // + // {{play-audio audioType=model.audioType audioFile=model.file}} + // + export default Ember.Component.extend({ + audioService: Ember.computed('audioType', function() { + let owner = Ember.getOwner(this); + return owner.lookup(`service:${this.get('audioType')}`); + }), + click() { + let player = this.get('audioService'); + player.play(this.get('audioFile')); + } + }); + ``` + + @method getOwner + @for Ember + @param {Object} object An object with an owner. + @return {Object} An owner object. + @since 2.3.0 + @public + */ - InElementSyntax.prototype.compile = function compile(dsl, env) { - var args = this.args; - var blocks = this.args.blocks; + function getOwner(object) { + return object[OWNER]; + } - dsl.putArgs(args); - dsl.test('simple'); - dsl.block(null, function (dsl, BEGIN, END) { - dsl.jumpUnless(END); - dsl.pushRemoteElement(); - dsl.evaluate('default', blocks.default); - dsl.popRemoteElement(); - }); - }; + /** + `setOwner` forces a new owner on a given object instance. This is primarily + useful in some testing cases. + + @method setOwner + @for Ember + @param {Object} object An object instance. + @param {Object} object The new owner object of the object instance. + @since 2.3.0 + @public + */ - return InElementSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + function setOwner(object, owner) { + object[OWNER] = owner; + } +}); +enifed('ember-utils/proxy-utils', ['exports'], function (exports) { + 'use strict'; - exports.default = InElementSyntax; + var HAS_NATIVE_PROXY = typeof Proxy === 'function'; + exports.HAS_NATIVE_PROXY = HAS_NATIVE_PROXY; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL2luLWVsZW1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBUUEsZUFBQTs4QkFBQSxlQUFBO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y4uLy4uL2NvbXBpbGVkL29wY29kZXMvYnVpbGRlcic7XG5pbXBvcnQgKiBhcyBTeW50YXggZnJvbSAnLi4vY29yZSc7XG5pbXBvcnQgRW52aXJvbm1lbnQgZnJvbSAnLi4vLi4vZW52aXJvbm1lbnQnO1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBJbkVsZW1lbnRTeW50YXggZXh0ZW5kcyBTdGF0ZW1lbnRTeW50YXgge1xuICB0eXBlID0gXCJpbi1lbGVtZW50LXN0YXRlbWVudFwiO1xuXG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgYXJnczogU3ludGF4LkFyZ3MpIHtcbiAgICBzdXBlcigpO1xuICB9XG5cbiAgY29tcGlsZShkc2w6IE9wY29kZUJ1aWxkZXJEU0wsIGVudjogRW52aXJvbm1lbnQpIHtcbiAgICBsZXQgeyBhcmdzLCBhcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ3NpbXBsZScpO1xuXG4gICAgZHNsLmJsb2NrKG51bGwsIChkc2wsIEJFR0lOLCBFTkQpID0+IHtcbiAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICBkc2wucHVzaFJlbW90ZUVsZW1lbnQoKTtcbiAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIGRzbC5wb3BSZW1vdGVFbGVtZW50KCk7XG4gICAgfSk7XG4gIH1cbn1cbiJdfQ== -enifed("glimmer-runtime/lib/syntax/builtins/partial", ["exports", "glimmer-runtime/lib/syntax"], function (exports, _glimmerRuntimeLibSyntax) { - "use strict"; +enifed('ember-utils/super', ['exports'], function (exports) { + 'use strict'; - var StaticPartialSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(StaticPartialSyntax, _StatementSyntax); + exports.wrap = wrap; + var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/; + var fnToString = Function.prototype.toString; - function StaticPartialSyntax(name) { - _StatementSyntax.call(this); - this.name = name; - this.type = "static-partial"; - } + var checkHasSuper = (function () { + var sourceAvailable = fnToString.call(function () { + return this; + }).indexOf('return this') > -1; - StaticPartialSyntax.prototype.compile = function compile(dsl, env, symbolTable) { - var name = String(this.name.inner()); - if (!env.hasPartial(name, symbolTable)) { - throw new Error("Compile Error: " + name + " is not a partial"); - } - var definition = env.lookupPartial(name, symbolTable); - dsl.putPartialDefinition(definition); - dsl.evaluatePartial(); - }; + if (sourceAvailable) { + return function checkHasSuper(func) { + return HAS_SUPER_PATTERN.test(fnToString.call(func)); + }; + } - return StaticPartialSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + return function checkHasSuper() { + return true; + }; + })(); - exports.StaticPartialSyntax = StaticPartialSyntax; + exports.checkHasSuper = checkHasSuper; + function ROOT() {} + ROOT.__hasSuper = false; - var DynamicPartialSyntax = (function (_StatementSyntax2) { - babelHelpers.inherits(DynamicPartialSyntax, _StatementSyntax2); + function hasSuper(func) { + if (func.__hasSuper === undefined) { + func.__hasSuper = checkHasSuper(func); + } + return func.__hasSuper; + } - function DynamicPartialSyntax(name) { - _StatementSyntax2.call(this); - this.name = name; - this.type = "dynamic-partial"; - } + /** + Wraps the passed function so that `this._super` will point to the superFunc + when the function is invoked. This is the primitive we use to implement + calls to super. + + @private + @method wrap + @for Ember + @param {Function} func The function to call + @param {Function} superFunc The super function. + @return {Function} wrapped function. + */ - DynamicPartialSyntax.prototype.compile = function compile(dsl) { - var name = this.name; + function wrap(func, superFunc) { + if (!hasSuper(func)) { + return func; + } + // ensure an unwrapped super that calls _super is wrapped with a terminal _super + if (!superFunc.wrappedFunction && hasSuper(superFunc)) { + return _wrap(func, _wrap(superFunc, ROOT)); + } + return _wrap(func, superFunc); + } - dsl.startLabels(); - dsl.putValue(name); - dsl.test('simple'); - dsl.enter('BEGIN', 'END'); - dsl.label('BEGIN'); - dsl.jumpUnless('END'); - dsl.putDynamicPartialDefinition(); - dsl.evaluatePartial(); - dsl.label('END'); - dsl.exit(); - dsl.stopLabels(); - }; + function _wrap(func, superFunc) { + function superWrapper() { + var orig = this._super; + this._super = superFunc; + var ret = func.apply(this, arguments); + this._super = orig; + return ret; + } - return DynamicPartialSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + superWrapper.wrappedFunction = func; + superWrapper.__ember_observes__ = func.__ember_observes__; + superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__; + superWrapper.__ember_listens__ = func.__ember_listens__; - exports.DynamicPartialSyntax = DynamicPartialSyntax; + return superWrapper; + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3BhcnRpYWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBY0EsbUJBQUE7OEJBQUEsbUJBQUE7O0FBR0UsaUJBSEYsbUJBQUEsQ0FHc0IsSUFBdUIsRUFBQTtBQUN6Qyx1Q0FBTyxDQUFDO0FBRFUsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFtQjtBQUZwQyxnQkFBQSxDQUFBLElBQUksR0FBRyxnQkFBZ0IsQ0FBQztTQUk5Qjs7QUFMSCwyQkFBQSxXQU9FLE9BQU8sR0FBQSxpQkFBQyxHQUFxQixFQUFFLEdBQWdCLEVBQUUsV0FBd0IsRUFBQTtBQUN2RSxnQkFBSSxJQUFJLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQztBQUVyQyxnQkFBSSxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsSUFBSSxFQUFFLFdBQVcsQ0FBQyxFQUFFO0FBQ3RDLHNCQUFNLElBQUksS0FBSyxxQkFBbUIsSUFBSSx1QkFBb0IsQ0FBQzthQUM1RDtBQUVELGdCQU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pbGUgRXJyb3I6ICR7bmFtZX0gaXMgbm90IGEgcGFydGlhbGApO1xuICAgIH1cblxuICAgIGxldCBkZWZpbml0aW9uID0gZW52Lmxvb2t1cFBhcnRpYWwobmFtZSwgc3ltYm9sVGFibGUpO1xuXG4gICAgZHNsLnB1dFBhcnRpYWxEZWZpbml0aW9uKGRlZmluaXRpb24pO1xuICAgIGRzbC5ldmFsdWF0ZVBhcnRpYWwoKTtcbiAgfVxufVxuXG5leHBvcnQgY2xhc3MgRHluYW1pY1BhcnRpYWxTeW50YXggZXh0ZW5kcyBTdGF0ZW1lbnRTeW50YXgge1xuICBwdWJsaWMgdHlwZSA9IFwiZHluYW1pYy1wYXJ0aWFsXCI7XG5cbiAgY29uc3RydWN0b3IocHJpdmF0ZSBuYW1lOiBFeHByZXNzaW9uU3ludGF4PE9wYXF1ZT4pIHtcbiAgICBzdXBlcigpO1xuICB9XG5cbiAgY29tcGlsZShkc2w6IE9wY29kZUJ1aWxkZXJEU0wpIHtcbiAgICBsZXQgeyBuYW1lIH0gPSB0aGlzO1xuXG4gICAgZHNsLnN0YXJ0TGFiZWxzKCk7XG5cbiAgICBkc2wucHV0VmFsdWUobmFtZSk7XG4gICAgZHNsLnRlc3QoJ3NpbXBsZScpO1xuICAgIGRzbC5lbnRlcignQkVHSU4nLCAnRU5EJyk7XG4gICAgZHNsLmxhYmVsKCdCRUdJTicpO1xuICAgIGRzbC5qdW1wVW5sZXNzKCdFTkQnKTtcbiAgICBkc2wucHV0RHluYW1pY1BhcnRpYWxEZWZpbml0aW9uKCk7XG4gICAgZHNsLmV2YWx1YXRlUGFydGlhbCgpO1xuICAgIGRzbC5sYWJlbCgnRU5EJyk7XG4gICAgZHNsLmV4aXQoKTtcblxuICAgIGRzbC5zdG9wTGFiZWxzKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/syntax/builtins/unless', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var UnlessSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(UnlessSyntax, _StatementSyntax); - - function UnlessSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "unless-statement"; - } - - UnlessSyntax.prototype.compile = function compile(dsl, env) { - // PutArgs - // Enter(BEGIN, END) - // BEGIN: Noop - // Test(Environment) - // JumpIf(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl) { - if (blocks.inverse) { - dsl.jumpIf('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump('END'); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpIf('END'); - dsl.evaluate('default', blocks.default); - } - }); - }; +enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern'], function (exports, _emberUtilsGuid, _emberUtilsIntern) { + 'use strict'; - return UnlessSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + exports.default = symbol; - exports.default = UnlessSyntax; + function symbol(debugName) { + // TODO: Investigate using platform symbols, but we do not + // want to require non-enumerability for this API, which + // would introduce a large cost. + var id = _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()); + return _emberUtilsIntern.default('__' + debugName + '__ [id=' + id + ']'); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3VubGVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFVQSxZQUFBOzhCQUFBLFlBQUE7O0FBR0UsaUJBSEYsWUFBQSxDQUdxQixJQUFpQixFQUFBO0FBQ2xDLHVDQUFPLENBQUM7QUFEUyxnQkFBQSxDQUFBLElBQUksR0FBSixJQUFJLENBQWE7QUFGcEMsZ0JBQUEsQ0FBQSx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c3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgZHNsID0+IHtcbiAgICAgIGlmIChibG9ja3MuaW52ZXJzZSkge1xuICAgICAgICBkc2wuanVtcElmKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoJ0VORCcpO1xuICAgICAgICBkc2wubGFiZWwoJ0VMU0UnKTtcbiAgICAgICAgZHNsLmV2YWx1YXRlKCdpbnZlcnNlJywgYmxvY2tzLmludmVyc2UpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgZHNsLmp1bXBJZignRU5EJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/with-dynamic-vars', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var WithDynamicVarsSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(WithDynamicVarsSyntax, _StatementSyntax); - - function WithDynamicVarsSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "with-dynamic-vars-statement"; - } - - WithDynamicVarsSyntax.prototype.compile = function compile(dsl, env) { - var args = this.args; - var blocks = this.args.blocks; +enifed('ember-utils/to-string', ['exports'], function (exports) { + 'use strict'; - dsl.unit(function (dsl) { - dsl.putArgs(args); - dsl.pushDynamicScope(); - dsl.bindDynamicScope(args.named.keys); - dsl.evaluate('default', blocks.default); - dsl.popDynamicScope(); - }); - }; + exports.default = toString; + var objectToString = Object.prototype.toString; - return WithDynamicVarsSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + /* + A `toString` util function that supports objects without a `toString` + method, e.g. an object created with `Object.create(null)`. + */ - exports.default = WithDynamicVarsSyntax; + function toString(obj) { + if (obj && typeof obj.toString === 'function') { + return obj.toString(); + } else { + return objectToString.call(obj); + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3dpdGgtZHluYW1pYy12YXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQVFBLHFCQUFBOzhCQUFBLHFCQUFBOztBQUdFLGlCQUhGLHFCQUFBLENBR3NCLElBQWlCLEVBQUE7QUFDbkMsdUNBQU8sQ0FBQztBQURVLGdCQUFBLENBQUEsSUFBSSxHQUFKLElBQUksQ0FBYTtBQUZyQyxnQkFBQSxDQUFBLElBQUksR0FBRyw2QkFBNkIsQ0FBQztTQUlwQzs7QUFMSCw2QkFBQSxXQU9FLE9BQU8sR0FBQSxpQkFBQyxHQUFxQixFQUFFLEdBQWdCLEVBQUE7Z0JBQ3ZDLElBQUksR0FBdUIsSUFBSSxDQUEvQixJQUFJO2dCQUFVLE1BQU0sR0FBTyxJQUFJLENBQXpCLElBQUksQ0FBSSxNQUFNOztBQUUxQixlQUFHLENBQUMsSUFBSSxDQUFDLFVBQUEsR0FBRyxFQUFBO0FBQ1YsbUJBQUcsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7QUFDbEIsbUJBQUcsQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDO0FBQ3ZCLG1CQUFHLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUN0QyxtQkFBRyxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUUsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQ3hDLG1CQUFHLENBQUMsZUFBZSxFQUFFLENBQUM7YUFDdkIsQ0FBQyxDQUFDO1NBQ0o7O2VBakJILHFCQUFBO2dDQVBFLFNBQVM7O3NCQU9YLHFCQUFBIiwiZmlsZSI6IndpdGgtZHluYW1pYy12YXJzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHtcbiAgU3RhdGVtZW50IGFzIFN0YXRlbWVudFN5bnRheFxufSBmcm9tICcuLi8uLi9zeW50YXgnO1xuXG5pbXBvcnQgT3Bjb2RlQnVpbGRlckRTTCBmcm9tICcuLi8uLi9jb21waWxlZC9vcGNvZGVzL2J1aWxkZXInO1xuaW1wb3J0ICogYXMgU3ludGF4IGZyb20gJy4uL2NvcmUnO1xuaW1wb3J0IEVudmlyb25tZW50IGZyb20gJy4uLy4uL2Vudmlyb25tZW50JztcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgV2l0aER5bmFtaWNWYXJzU3ludGF4IGV4dGVuZHMgU3RhdGVtZW50U3ludGF4IHtcbiAgdHlwZSA9IFwid2l0aC1keW5hbWljLXZhcnMtc3RhdGVtZW50XCI7XG5cbiAgY29uc3RydWN0b3IocHJpdmF0ZSBhcmdzOiBTeW50YXguQXJncykge1xuICAgIHN1cGVyKCk7XG4gIH1cblxuICBjb21waWxlKGRzbDogT3Bjb2RlQnVpbGRlckRTTCwgZW52OiBFbnZpcm9ubWVudCkge1xuICAgIGxldCB7IGFyZ3MsIGFyZ3M6IHsgYmxvY2tzIH0gfSA9IHRoaXM7XG5cbiAgICBkc2wudW5pdChkc2wgPT4ge1xuICAgICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgICBkc2wucHVzaER5bmFtaWNTY29wZSgpO1xuICAgICAgZHNsLmJpbmREeW5hbWljU2NvcGUoYXJncy5uYW1lZC5rZXlzKTtcbiAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIGRzbC5wb3BEeW5hbWljU2NvcGUoKTtcbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/builtins/with', ['exports', 'glimmer-runtime/lib/syntax'], function (exports, _glimmerRuntimeLibSyntax) { - 'use strict'; - - var WithSyntax = (function (_StatementSyntax) { - babelHelpers.inherits(WithSyntax, _StatementSyntax); - - function WithSyntax(args) { - _StatementSyntax.call(this); - this.args = args; - this.type = "with-statement"; - } - - WithSyntax.prototype.compile = function compile(dsl, env) { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evaluate(inverse) - // END: Noop - // Exit - var args = this.args; - var blocks = this.args.blocks; - - dsl.putArgs(args); - dsl.test('environment'); - dsl.block(null, function (dsl, BEGIN, END) { - if (blocks.inverse) { - dsl.jumpUnless('ELSE'); - dsl.evaluate('default', blocks.default); - dsl.jump(END); - dsl.label('ELSE'); - dsl.evaluate('inverse', blocks.inverse); - } else { - dsl.jumpUnless(END); - dsl.evaluate('default', blocks.default); - } - }); - }; +enifed('ember-utils/weak-map-utils', ['exports'], function (exports) { + 'use strict'; - return WithSyntax; - })(_glimmerRuntimeLibSyntax.Statement); + var HAS_NATIVE_WEAKMAP = (function () { + // detect if `WeakMap` is even present + var hasWeakMap = typeof WeakMap === 'function'; + if (!hasWeakMap) { + return false; + } - exports.default = WithSyntax; + var instance = new WeakMap(); + // use `Object`'s `.toString` directly to prevent us from detecting + // polyfills as native weakmaps + return Object.prototype.toString.call(instance) === '[object WeakMap]'; + })(); + exports.HAS_NATIVE_WEAKMAP = HAS_NATIVE_WEAKMAP; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2J1aWx0aW5zL3dpdGgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBU0EsVUFBQTs4QkFBQSxVQUFBOztBQUdFLGlCQUhGLFVBQUEsQ0FHcUIsSUFBaUIsRUFBQTtBQUNsQyx1Q0FBTyxDQUFDO0FBRFMsZ0JBQUEsQ0FBQ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hcmdzOiB7IGJsb2NrcyB9IH0gPSB0aGlzO1xuXG4gICAgZHNsLnB1dEFyZ3MoYXJncyk7XG4gICAgZHNsLnRlc3QoJ2Vudmlyb25tZW50Jyk7XG5cbiAgICBkc2wuYmxvY2sobnVsbCwgKGRzbCwgQkVHSU4sIEVORCkgPT4ge1xuICAgICAgaWYgKGJsb2Nrcy5pbnZlcnNlKSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgICAgZHNsLmp1bXAoRU5EKTtcbiAgICAgICAgZHNsLmxhYmVsKCdFTFNFJyk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnaW52ZXJzZScsIGJsb2Nrcy5pbnZlcnNlKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGRzbC5qdW1wVW5sZXNzKEVORCk7XG4gICAgICAgIGRzbC5ldmFsdWF0ZSgnZGVmYXVsdCcsIGJsb2Nrcy5kZWZhdWx0KTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/syntax/core', ['exports', 'glimmer-runtime/lib/syntax', 'glimmer-runtime/lib/syntax/builtins/partial', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-runtime/lib/compiled/opcodes/component', 'glimmer-runtime/lib/compiled/opcodes/dom', 'glimmer-runtime/lib/syntax/expressions', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/compiled/expressions/value', 'glimmer-runtime/lib/compiled/expressions/lookups', 'glimmer-runtime/lib/compiled/expressions/has-block', 'glimmer-runtime/lib/compiled/expressions/helper', 'glimmer-runtime/lib/compiled/expressions/concat', 'glimmer-runtime/lib/utils', 'glimmer-runtime/lib/compiled/opcodes/content'], function (exports, _glimmerRuntimeLibSyntax, _glimmerRuntimeLibSyntaxBuiltinsPartial, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerRuntimeLibCompiledOpcodesComponent, _glimmerRuntimeLibCompiledOpcodesDom, _glimmerRuntimeLibSyntaxExpressions, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibCompiledExpressionsValue, _glimmerRuntimeLibCompiledExpressionsLookups, _glimmerRuntimeLibCompiledExpressionsHasBlock, _glimmerRuntimeLibCompiledExpressionsHelper, _glimmerRuntimeLibCompiledExpressionsConcat, _glimmerRuntimeLibUtils, _glimmerRuntimeLibCompiledOpcodesContent) { - 'use strict'; - - var Block = (function (_StatementSyntax) { - babelHelpers.inherits(Block, _StatementSyntax); - - function Block(path, args) { - _StatementSyntax.call(this); - this.path = path; - this.args = args; - this.type = "block"; - } - - Block.fromSpec = function fromSpec(sexp, symbolTable, scanner) { - var path = sexp[1]; - var params = sexp[2]; - var hash = sexp[3]; - var templateId = sexp[4]; - var inverseId = sexp[5]; - - var template = scanner.blockFor(symbolTable, templateId); - var inverse = typeof inverseId === 'number' ? scanner.blockFor(symbolTable, inverseId) : null; - var blocks = Blocks.fromSpec(template, inverse); - return new Block(path, Args.fromSpec(params, hash, blocks)); - }; - - Block.build = function build(path, args) { - return new this(path, args); - }; - - Block.prototype.scan = function scan(scanner) { - var _args$blocks = this.args.blocks; - var _default = _args$blocks.default; - var inverse = _args$blocks.inverse; - - if (_default) scanner.addChild(_default); - if (inverse) scanner.addChild(inverse); - return this; - }; - - Block.prototype.compile = function compile(ops) { - throw new Error("SyntaxError"); - }; - - return Block; - })(_glimmerRuntimeLibSyntax.Statement); - - exports.Block = Block; - - var Append = (function (_StatementSyntax2) { - babelHelpers.inherits(Append, _StatementSyntax2); - - function Append(_ref) { - var value = _ref.value; - var trustingMorph = _ref.trustingMorph; - - _StatementSyntax2.call(this); - this.value = value; - this.trustingMorph = trustingMorph; - } - - Append.fromSpec = function fromSpec(sexp) { - var value = sexp[1]; - var trustingMorph = sexp[2]; - - return new OptimizedAppend({ value: _glimmerRuntimeLibSyntaxExpressions.default(value), trustingMorph: trustingMorph }); - }; +enifed('ember-views/compat/attrs', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; - return Append; - })(_glimmerRuntimeLibSyntax.Statement); + var MUTABLE_CELL = _emberUtils.symbol('MUTABLE_CELL'); + exports.MUTABLE_CELL = MUTABLE_CELL; +}); +enifed('ember-views/compat/fallback-view-registry', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; - exports.Append = Append; + exports.default = _emberUtils.dictionary(null); +}); +enifed('ember-views/component_lookup', ['exports', 'ember-metal', 'ember-runtime', 'container'], function (exports, _emberMetal, _emberRuntime, _container) { + 'use strict'; - var OptimizedAppend = (function (_Append) { - babelHelpers.inherits(OptimizedAppend, _Append); + exports.default = _emberRuntime.Object.extend({ + componentFor: function (name, owner, options) { + var fullName = 'component:' + name; + return owner[_container.FACTORY_FOR](fullName, options); + }, - function OptimizedAppend() { - _Append.apply(this, arguments); - this.type = "optimized-append"; - } + layoutFor: function (name, owner, options) { - OptimizedAppend.prototype.deopt = function deopt() { - return new UnoptimizedAppend(this); - }; + var templateFullName = 'template:components/' + name; + return owner.lookup(templateFullName, options); + } + }); +}); +enifed('ember-views/index', ['exports', 'ember-views/system/ext', 'ember-views/system/jquery', 'ember-views/system/utils', 'ember-views/system/event_dispatcher', 'ember-views/component_lookup', 'ember-views/mixins/text_support', 'ember-views/views/core_view', 'ember-views/mixins/class_names_support', 'ember-views/mixins/child_views_support', 'ember-views/mixins/view_state_support', 'ember-views/mixins/view_support', 'ember-views/mixins/action_support', 'ember-views/compat/attrs', 'ember-views/system/lookup_partial', 'ember-views/utils/lookup-component', 'ember-views/system/action_manager', 'ember-views/compat/fallback-view-registry'], function (exports, _emberViewsSystemExt, _emberViewsSystemJquery, _emberViewsSystemUtils, _emberViewsSystemEvent_dispatcher, _emberViewsComponent_lookup, _emberViewsMixinsText_support, _emberViewsViewsCore_view, _emberViewsMixinsClass_names_support, _emberViewsMixinsChild_views_support, _emberViewsMixinsView_state_support, _emberViewsMixinsView_support, _emberViewsMixinsAction_support, _emberViewsCompatAttrs, _emberViewsSystemLookup_partial, _emberViewsUtilsLookupComponent, _emberViewsSystemAction_manager, _emberViewsCompatFallbackViewRegistry) { + /** + @module ember + @submodule ember-views + */ - OptimizedAppend.prototype.compile = function compile(compiler, env, symbolTable) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(this.value.compile(compiler, env, symbolTable))); - if (this.trustingMorph) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedTrustingAppendOpcode()); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.OptimizedCautiousAppendOpcode()); - } - }; + 'use strict'; - return OptimizedAppend; - })(Append); + exports.jQuery = _emberViewsSystemJquery.default; + exports.isSimpleClick = _emberViewsSystemUtils.isSimpleClick; + exports.getViewBounds = _emberViewsSystemUtils.getViewBounds; + exports.getViewClientRects = _emberViewsSystemUtils.getViewClientRects; + exports.getViewBoundingClientRect = _emberViewsSystemUtils.getViewBoundingClientRect; + exports.getRootViews = _emberViewsSystemUtils.getRootViews; + exports.getChildViews = _emberViewsSystemUtils.getChildViews; + exports.getViewId = _emberViewsSystemUtils.getViewId; + exports.getViewElement = _emberViewsSystemUtils.getViewElement; + exports.setViewElement = _emberViewsSystemUtils.setViewElement; + exports.STYLE_WARNING = _emberViewsSystemUtils.STYLE_WARNING; + exports.EventDispatcher = _emberViewsSystemEvent_dispatcher.default; + exports.ComponentLookup = _emberViewsComponent_lookup.default; + exports.TextSupport = _emberViewsMixinsText_support.default; + exports.CoreView = _emberViewsViewsCore_view.default; + exports.ClassNamesSupport = _emberViewsMixinsClass_names_support.default; + exports.ChildViewsSupport = _emberViewsMixinsChild_views_support.default; + exports.ViewStateSupport = _emberViewsMixinsView_state_support.default; + exports.ViewMixin = _emberViewsMixinsView_support.default; + exports.dispatchLifeCycleHook = _emberViewsMixinsView_support.dispatchLifeCycleHook; + exports.ActionSupport = _emberViewsMixinsAction_support.default; + exports.MUTABLE_CELL = _emberViewsCompatAttrs.MUTABLE_CELL; + exports.lookupPartial = _emberViewsSystemLookup_partial.default; + exports.hasPartial = _emberViewsSystemLookup_partial.hasPartial; + exports.lookupComponent = _emberViewsUtilsLookupComponent.default; + exports.ActionManager = _emberViewsSystemAction_manager.default; + exports.fallbackViewRegistry = _emberViewsCompatFallbackViewRegistry.default; +}); +// for the side effect of extending Ember.run.queues +enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/compat/attrs'], function (exports, _emberUtils, _emberMetal, _emberViewsCompatAttrs) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - exports.OptimizedAppend = OptimizedAppend; + function validateAction(component, actionName) { + if (actionName && actionName[_emberViewsCompatAttrs.MUTABLE_CELL]) { + actionName = actionName.value; + } - var UnoptimizedAppend = (function (_Append2) { - babelHelpers.inherits(UnoptimizedAppend, _Append2); + return actionName; + } - function UnoptimizedAppend() { - _Append2.apply(this, arguments); - this.type = "unoptimized-append"; + /** + @class ActionSupport + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create({ + /** + Calls an action passed to a component. + For example a component for playing or pausing music may translate click events + into action notifications of "play" or "stop" depending on some internal state + of the component: + ```javascript + // app/components/play-button.js + export default Ember.Component.extend({ + click() { + if (this.get('isPlaying')) { + this.sendAction('play'); + } else { + this.sendAction('stop'); + } } - - UnoptimizedAppend.prototype.compile = function compile(compiler, env, symbolTable) { - var expression = this.value.compile(compiler, env, symbolTable); - if (this.trustingMorph) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.GuardedTrustingAppendOpcode(expression, symbolTable)); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesContent.GuardedCautiousAppendOpcode(expression, symbolTable)); - } - }; - - return UnoptimizedAppend; - })(Append); - - exports.UnoptimizedAppend = UnoptimizedAppend; - - var MODIFIER_SYNTAX = "c0420397-8ff1-4241-882b-4b7a107c9632"; - - var Modifier = (function (_StatementSyntax3) { - babelHelpers.inherits(Modifier, _StatementSyntax3); - - function Modifier(options) { - _StatementSyntax3.call(this); - this["c0420397-8ff1-4241-882b-4b7a107c9632"] = true; - this.type = "modifier"; - this.path = options.path; - this.args = options.args; + }); + ``` + The actions "play" and "stop" must be passed to this `play-button` component: + ```handlebars + {{! app/templates/application.hbs }} + {{play-button play=(action "musicStarted") stop=(action "musicStopped")}} + ``` + When the component receives a browser `click` event it translate this + interaction into application-specific semantics ("play" or "stop") and + calls the specified action. + ```javascript + // app/controller/application.js + export default Ember.Controller.extend({ + actions: { + musicStarted() { + // called when the play button is clicked + // and the music started playing + }, + musicStopped() { + // called when the play button is clicked + // and the music stopped playing + } } - - Modifier.fromSpec = function fromSpec(node) { - var path = node[1]; - var params = node[2]; - var hash = node[3]; - - return new Modifier({ - path: path, - args: Args.fromSpec(params, hash, EMPTY_BLOCKS) - }); - }; - - Modifier.build = function build(path, options) { - return new Modifier({ - path: path, - params: options.params, - hash: options.hash - }); - }; - - Modifier.prototype.compile = function compile(compiler, env, symbolTable) { - var args = this.args.compile(compiler, env, symbolTable); - if (env.hasModifier(this.path, symbolTable)) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.ModifierOpcode(this.path[0], env.lookupModifier(this.path, symbolTable), args)); - } else { - throw new Error('Compile Error: ' + this.path.join('.') + ' is not a modifier'); - } - }; - - return Modifier; - })(_glimmerRuntimeLibSyntax.Statement); - - exports.Modifier = Modifier; - - var StaticArg = (function (_ArgumentSyntax) { - babelHelpers.inherits(StaticArg, _ArgumentSyntax); - - function StaticArg(name, value) { - _ArgumentSyntax.call(this); - this.name = name; - this.value = value; - this.type = "static-arg"; + }); + ``` + If no action is passed to `sendAction` a default name of "action" + is assumed. + ```javascript + // app/components/next-button.js + export default Ember.Component.extend({ + click() { + this.sendAction(); } - - StaticArg.fromSpec = function fromSpec(node) { - var name = node[1]; - var value = node[2]; - - return new StaticArg(name, value); - }; - - StaticArg.build = function build(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - - return new this(name, value); - }; - - StaticArg.prototype.compile = function compile() { - throw new Error('Cannot compiler StaticArg "' + this.name + '" as it is a delegate for ValueSyntax.'); - }; - - StaticArg.prototype.valueSyntax = function valueSyntax() { - return Value.build(this.value); - }; - - return StaticArg; - })(_glimmerRuntimeLibSyntax.Argument); - - exports.StaticArg = StaticArg; - - var DynamicArg = (function (_ArgumentSyntax2) { - babelHelpers.inherits(DynamicArg, _ArgumentSyntax2); - - function DynamicArg(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - - _ArgumentSyntax2.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this.type = 'dynamic-arg'; + }); + ``` + ```handlebars + {{! app/templates/application.hbs }} + {{next-button action=(action "playNextSongInAlbum")}} + ``` + ```javascript + // app/controllers/application.js + App.ApplicationController = Ember.Controller.extend({ + actions: { + playNextSongInAlbum() { + ... + } } + }); + ``` + @method sendAction + @param [action] {String} the action to call + @param [params] {*} arguments for the action + @public + */ + sendAction: function (action) { + for (var _len = arguments.length, contexts = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + contexts[_key - 1] = arguments[_key]; + } - DynamicArg.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; - - return new DynamicArg(name, _glimmerRuntimeLibSyntaxExpressions.default(value)); - }; - - DynamicArg.build = function build(name, value) { - return new this(name, value); - }; - - DynamicArg.prototype.compile = function compile() { - throw new Error('Cannot compile DynamicArg for "' + this.name + '" as it is delegate for ExpressionSyntax.'); - }; - - DynamicArg.prototype.valueSyntax = function valueSyntax() { - return this.value; - }; - - return DynamicArg; - })(_glimmerRuntimeLibSyntax.Argument); - - exports.DynamicArg = DynamicArg; - - var TrustingAttr = (function () { - function TrustingAttr() {} - - TrustingAttr.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; - var namespace = sexp[3]; + var actionName = undefined; - return new DynamicAttr(name, _glimmerRuntimeLibSyntaxExpressions.default(value), namespace, true); - }; + // Send the default action + if (action === undefined) { + action = 'action'; + } + actionName = _emberMetal.get(this, 'attrs.' + action) || _emberMetal.get(this, action); + actionName = validateAction(this, actionName); - TrustingAttr.build = function build(name, value, isTrusting) { - var namespace = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + // If no action name for that action could be found, just abort. + if (actionName === undefined) { + return; + } - return new DynamicAttr(name, value, namespace, isTrusting); - }; + if (typeof actionName === 'function') { + actionName.apply(undefined, contexts); + } else { + this.triggerAction({ + action: actionName, + actionContext: contexts + }); + } + }, - TrustingAttr.prototype.compile = function compile() { - throw new Error('Attempting to compile a TrustingAttr which is just a delegate for DynamicAttr.'); - }; + send: function (actionName) { + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } - return TrustingAttr; - })(); + var action = this.actions && this.actions[actionName]; - exports.TrustingAttr = TrustingAttr; + if (action) { + var shouldBubble = action.apply(this, args) === true; + if (!shouldBubble) { + return; + } + } - var StaticAttr = (function (_AttributeSyntax) { - babelHelpers.inherits(StaticAttr, _AttributeSyntax); + var target = _emberMetal.get(this, 'target'); + if (target) { + target.send.apply(target, arguments); + } else {} + } + }); +}); +enifed('ember-views/mixins/child_views_support', ['exports', 'ember-utils', 'ember-metal', 'ember-views/system/utils'], function (exports, _emberUtils, _emberMetal, _emberViewsSystemUtils) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - function StaticAttr(name, value, namespace) { - _AttributeSyntax.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - this.type = "static-attr"; - this.isTrusting = false; - } + exports.default = _emberMetal.Mixin.create({ + init: function () { + this._super.apply(this, arguments); + _emberViewsSystemUtils.initChildViews(this); + }, - StaticAttr.fromSpec = function fromSpec(node) { - var name = node[1]; - var value = node[2]; - var namespace = node[3]; + /** + Array of child views. You should never edit this array directly. + @property childViews + @type Array + @default [] + @private + */ + childViews: _emberMetal.descriptor({ + configurable: false, + enumerable: false, + get: function () { + return _emberViewsSystemUtils.getChildViews(this); + } + }), - return new StaticAttr(name, value, namespace); - }; + appendChild: function (view) { + this.linkChild(view); + _emberViewsSystemUtils.addChildView(this, view); + }, - StaticAttr.build = function build(name, value) { - var namespace = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + linkChild: function (instance) { + if (!_emberUtils.getOwner(instance)) { + _emberUtils.setOwner(instance, _emberUtils.getOwner(this)); + } + } + }); +}); +enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ - return new this(name, value, namespace); - }; + 'use strict'; - StaticAttr.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.StaticAttrOpcode(this.namespace, this.name, this.value)); - }; + var EMPTY_ARRAY = Object.freeze([]); - StaticAttr.prototype.valueSyntax = function valueSyntax() { - return Value.build(this.value); - }; + /** + @class ClassNamesSupport + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create({ + concatenatedProperties: ['classNames', 'classNameBindings'], - return StaticAttr; - })(_glimmerRuntimeLibSyntax.Attribute); + init: function () { + this._super.apply(this, arguments); + }, - exports.StaticAttr = StaticAttr; + /** + Standard CSS class names to apply to the view's outer element. This + property automatically inherits any class names defined by the view's + superclasses as well. + @property classNames + @type Array + @default ['ember-view'] + @public + */ + classNames: EMPTY_ARRAY, - var DynamicAttr = (function (_AttributeSyntax2) { - babelHelpers.inherits(DynamicAttr, _AttributeSyntax2); + /** + A list of properties of the view to apply as class names. If the property + is a string value, the value of that string will be applied as a class + name. + ```javascript + // Applies the 'high' class to the view element + Ember.Component.extend({ + classNameBindings: ['priority'], + priority: 'high' + }); + ``` + If the value of the property is a Boolean, the name of that property is + added as a dasherized class name. + ```javascript + // Applies the 'is-urgent' class to the view element + Ember.Component.extend({ + classNameBindings: ['isUrgent'], + isUrgent: true + }); + ``` + If you would prefer to use a custom value instead of the dasherized + property name, you can pass a binding like this: + ```javascript + // Applies the 'urgent' class to the view element + Ember.Component.extend({ + classNameBindings: ['isUrgent:urgent'], + isUrgent: true + }); + ``` + This list of properties is inherited from the component's superclasses as well. + @property classNameBindings + @type Array + @default [] + @public + */ + classNameBindings: EMPTY_ARRAY + }); +}); +enifed('ember-views/mixins/text_support', ['exports', 'ember-metal', 'ember-runtime'], function (exports, _emberMetal, _emberRuntime) { + /** + @module ember + @submodule ember-views + */ - function DynamicAttr(name, value, namespace, isTrusting) { - if (namespace === undefined) namespace = undefined; + 'use strict'; - _AttributeSyntax2.call(this); - this.name = name; - this.value = value; - this.namespace = namespace; - this.isTrusting = isTrusting; - this["e1185d30-7cac-4b12-b26a-35327d905d92"] = true; - this.type = "dynamic-attr"; - } + var KEY_EVENTS = { + 13: 'insertNewline', + 27: 'cancel' + }; - DynamicAttr.fromSpec = function fromSpec(sexp) { - var name = sexp[1]; - var value = sexp[2]; - var namespace = sexp[3]; + /** + `TextSupport` is a shared mixin used by both `Ember.TextField` and + `Ember.TextArea`. `TextSupport` adds a number of methods that allow you to + specify a controller action to invoke when a certain event is fired on your + text field or textarea. The specifed controller action would get the current + value of the field passed in as the only argument unless the value of + the field is empty. In that case, the instance of the field itself is passed + in as the only argument. + + Let's use the pressing of the escape key as an example. If you wanted to + invoke a controller action when a user presses the escape key while on your + field, you would use the `escape-press` attribute on your field like so: + + ```handlebars + {{! application.hbs}} + + {{input escape-press='alertUser'}} + ``` + + ```javascript + App = Ember.Application.create(); + + App.ApplicationController = Ember.Controller.extend({ + actions: { + alertUser: function ( currentValue ) { + alert( 'escape pressed, current value: ' + currentValue ); + } + } + }); + ``` + + The following chart is a visual representation of what takes place when the + escape key is pressed in this scenario: + + ``` + The Template + +---------------------------+ + | | + | escape-press='alertUser' | + | | TextSupport Mixin + +----+----------------------+ +-------------------------------+ + | | cancel method | + | escape button pressed | | + +-------------------------------> | checks for the `escape-press` | + | attribute and pulls out the | + +-------------------------------+ | `alertUser` value | + | action name 'alertUser' +-------------------------------+ + | sent to controller + v + Controller + +------------------------------------------ + + | | + | actions: { | + | alertUser: function( currentValue ){ | + | alert( 'the esc key was pressed!' ) | + | } | + | } | + | | + +-------------------------------------------+ + ``` + + Here are the events that we currently support along with the name of the + attribute you would need to use on your field. To reiterate, you would use the + attribute name like so: + + ```handlebars + {{input attribute-name='controllerAction'}} + ``` + + ``` + +--------------------+----------------+ + | | | + | event | attribute name | + +--------------------+----------------+ + | new line inserted | insert-newline | + | | | + | enter key pressed | insert-newline | + | | | + | cancel key pressed | escape-press | + | | | + | focusin | focus-in | + | | | + | focusout | focus-out | + | | | + | keypress | key-press | + | | | + | keyup | key-up | + | | | + | keydown | key-down | + +--------------------+----------------+ + ``` + + @class TextSupport + @namespace Ember + @uses Ember.TargetActionSupport + @extends Ember.Mixin + @private + */ + exports.default = _emberMetal.Mixin.create(_emberRuntime.TargetActionSupport, { + value: '', - return new DynamicAttr(name, _glimmerRuntimeLibSyntaxExpressions.default(value), namespace); - }; + attributeBindings: ['autocapitalize', 'autocorrect', 'autofocus', 'disabled', 'form', 'maxlength', 'placeholder', 'readonly', 'required', 'selectionDirection', 'spellcheck', 'tabindex', 'title'], + placeholder: null, + disabled: false, + maxlength: null, - DynamicAttr.build = function build(name, value) { - var isTrusting = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; - var namespace = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + init: function () { + this._super.apply(this, arguments); + this.on('paste', this, this._elementValueDidChange); + this.on('cut', this, this._elementValueDidChange); + this.on('input', this, this._elementValueDidChange); + }, - return new this(name, value, namespace, isTrusting); - }; + /** + The action to be sent when the user presses the return key. + This is similar to the `{{action}}` helper, but is fired when + the user presses the return key when editing a text field, and sends + the value of the field as the context. + @property action + @type String + @default null + @private + */ + action: null, - DynamicAttr.prototype.compile = function compile(compiler, env, symbolTable) { - var namespace = this.namespace; - var value = this.value; + /** + The event that should send the action. + Options are: + * `enter`: the user pressed enter + * `keyPress`: the user pressed a key + @property onEvent + @type String + @default enter + @private + */ + onEvent: 'enter', - compiler.append(new _glimmerRuntimeLibCompiledOpcodesVm.PutValueOpcode(value.compile(compiler, env, symbolTable))); - if (namespace) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrNSOpcode(this.name, this.namespace, this.isTrusting)); - } else { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.DynamicAttrOpcode(this.name, this.isTrusting)); - } - }; + /** + Whether the `keyUp` event that triggers an `action` to be sent continues + propagating to other views. + By default, when the user presses the return key on their keyboard and + the text field has an `action` set, the action will be sent to the view's + controller and the key event will stop propagating. + If you would like parent views to receive the `keyUp` event even after an + action has been dispatched, set `bubbles` to true. + @property bubbles + @type Boolean + @default false + @private + */ + bubbles: false, - DynamicAttr.prototype.valueSyntax = function valueSyntax() { - return this.value; - }; + interpretKeyEvents: function (event) { + var map = KEY_EVENTS; + var method = map[event.keyCode]; - return DynamicAttr; - })(_glimmerRuntimeLibSyntax.Attribute); + this._elementValueDidChange(); + if (method) { + return this[method](event); + } + }, - exports.DynamicAttr = DynamicAttr; + _elementValueDidChange: function () { + _emberMetal.set(this, 'value', this.element.value); + }, - var FlushElement = (function (_StatementSyntax4) { - babelHelpers.inherits(FlushElement, _StatementSyntax4); + change: function (event) { + this._elementValueDidChange(event); + }, - function FlushElement() { - _StatementSyntax4.apply(this, arguments); - this.type = "flush-element"; - } + /** + Allows you to specify a controller action to invoke when either the `enter` + key is pressed or, in the case of the field being a textarea, when a newline + is inserted. To use this method, give your field an `insert-newline` + attribute. The value of that attribute should be the name of the action + in your controller that you wish to invoke. + For an example on how to use the `insert-newline` attribute, please + reference the example near the top of this file. + @method insertNewline + @param {Event} event + @private + */ + insertNewline: function (event) { + sendAction('enter', this, event); + sendAction('insert-newline', this, event); + }, - FlushElement.fromSpec = function fromSpec() { - return new FlushElement(); - }; + /** + Allows you to specify a controller action to invoke when the escape button + is pressed. To use this method, give your field an `escape-press` + attribute. The value of that attribute should be the name of the action + in your controller that you wish to invoke. + For an example on how to use the `escape-press` attribute, please reference + the example near the top of this file. + @method cancel + @param {Event} event + @private + */ + cancel: function (event) { + sendAction('escape-press', this, event); + }, - FlushElement.build = function build() { - return new this(); - }; + /** + Allows you to specify a controller action to invoke when a field receives + focus. To use this method, give your field a `focus-in` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `focus-in` attribute, please reference the + example near the top of this file. + @method focusIn + @param {Event} event + @private + */ + focusIn: function (event) { + sendAction('focus-in', this, event); + }, - FlushElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.FlushElementOpcode()); - }; + /** + Allows you to specify a controller action to invoke when a field loses + focus. To use this method, give your field a `focus-out` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `focus-out` attribute, please reference the + example near the top of this file. + @method focusOut + @param {Event} event + @private + */ + focusOut: function (event) { + this._elementValueDidChange(event); + sendAction('focus-out', this, event); + }, - return FlushElement; - })(_glimmerRuntimeLibSyntax.Statement); + /** + Allows you to specify a controller action to invoke when a key is pressed. + To use this method, give your field a `key-press` attribute. The value of + that attribute should be the name of the action in your controller you + that wish to invoke. + For an example on how to use the `key-press` attribute, please reference the + example near the top of this file. + @method keyPress + @param {Event} event + @private + */ + keyPress: function (event) { + sendAction('key-press', this, event); + }, - exports.FlushElement = FlushElement; + /** + Allows you to specify a controller action to invoke when a key-up event is + fired. To use this method, give your field a `key-up` attribute. The value + of that attribute should be the name of the action in your controller + that you wish to invoke. + For an example on how to use the `key-up` attribute, please reference the + example near the top of this file. + @method keyUp + @param {Event} event + @private + */ + keyUp: function (event) { + this.interpretKeyEvents(event); - var CloseElement = (function (_StatementSyntax5) { - babelHelpers.inherits(CloseElement, _StatementSyntax5); + this.sendAction('key-up', _emberMetal.get(this, 'value'), event); + }, - function CloseElement() { - _StatementSyntax5.apply(this, arguments); - this.type = "close-element"; - } + /** + Allows you to specify a controller action to invoke when a key-down event is + fired. To use this method, give your field a `key-down` attribute. The value + of that attribute should be the name of the action in your controller that + you wish to invoke. + For an example on how to use the `key-down` attribute, please reference the + example near the top of this file. + @method keyDown + @param {Event} event + @private + */ + keyDown: function (event) { + this.sendAction('key-down', _emberMetal.get(this, 'value'), event); + } + }); - CloseElement.fromSpec = function fromSpec() { - return new CloseElement(); - }; + // In principle, this shouldn't be necessary, but the legacy + // sendAction semantics for TextField are different from + // the component semantics so this method normalizes them. + function sendAction(eventName, view, event) { + var action = _emberMetal.get(view, 'attrs.' + eventName) || _emberMetal.get(view, eventName); + var on = _emberMetal.get(view, 'onEvent'); + var value = _emberMetal.get(view, 'value'); - CloseElement.build = function build() { - return new this(); - }; + // back-compat support for keyPress as an event name even though + // it's also a method name that consumes the event (and therefore + // incompatible with sendAction semantics). + if (on === eventName || on === 'keyPress' && eventName === 'key-press') { + view.sendAction('action', value); + } - CloseElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.CloseElementOpcode()); - }; + view.sendAction(eventName, value); - return CloseElement; - })(_glimmerRuntimeLibSyntax.Statement); + if (action || on === eventName) { + if (!_emberMetal.get(view, 'bubbles')) { + event.stopPropagation(); + } + } + } +}); +enifed('ember-views/mixins/view_state_support', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ + 'use strict'; - exports.CloseElement = CloseElement; + exports.default = _emberMetal.Mixin.create({ + _transitionTo: function (state) { + var priorState = this._currentState; + var currentState = this._currentState = this._states[state]; + this._state = state; - var Text = (function (_StatementSyntax6) { - babelHelpers.inherits(Text, _StatementSyntax6); + if (priorState && priorState.exit) { + priorState.exit(this); + } + if (currentState.enter) { + currentState.enter(this); + } + } + }); +}); +enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-views/system/utils', 'ember-runtime/system/core_object', 'ember-views/system/jquery'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberViewsSystemUtils, _emberRuntimeSystemCore_object, _emberViewsSystemJquery) { + 'use strict'; - function Text(content) { - _StatementSyntax6.call(this); - this.content = content; - this.type = "text"; - } + var _Mixin$create; - Text.fromSpec = function fromSpec(node) { - var content = node[1]; + function K() { + return this; + } - return new Text(content); - }; + var dispatchLifeCycleHook = function (component, hook, oldAttrs, newAttrs) { + component.trigger(hook, { attrs: newAttrs, oldAttrs: oldAttrs, newAttrs: newAttrs }); + }; - Text.build = function build(content) { - return new this(content); - }; + exports.dispatchLifeCycleHook = dispatchLifeCycleHook; - Text.prototype.compile = function compile(dsl) { - dsl.text(this.content); - }; + /** + @class ViewMixin + @namespace Ember + @private + */ + exports.default = _emberMetal.Mixin.create((_Mixin$create = { + concatenatedProperties: ['attributeBindings'] + }, _Mixin$create[_emberRuntimeSystemCore_object.POST_INIT] = function () { + dispatchLifeCycleHook(this, 'didInitAttrs', undefined, this.attrs); + dispatchLifeCycleHook(this, 'didReceiveAttrs', undefined, this.attrs); + }, _Mixin$create.nearestOfType = function (klass) { + var view = this.parentView; + var isOfType = klass instanceof _emberMetal.Mixin ? function (view) { + return klass.detect(view); + } : function (view) { + return klass.detect(view.constructor); + }; - return Text; - })(_glimmerRuntimeLibSyntax.Statement); + while (view) { + if (isOfType(view)) { + return view; + } + view = view.parentView; + } + }, _Mixin$create.nearestWithProperty = function (property) { + var view = this.parentView; - exports.Text = Text; + while (view) { + if (property in view) { + return view; + } + view = view.parentView; + } + }, _Mixin$create.rerender = function () { + return this._currentState.rerender(this); + }, _Mixin$create.element = _emberMetal.descriptor({ + configurable: false, + enumerable: false, + get: function () { + return this.renderer.getElement(this); + } + }), _Mixin$create.$ = function (sel) { + if (this.element) { + return sel ? _emberViewsSystemJquery.default(sel, this.element) : _emberViewsSystemJquery.default(this.element); + } + }, _Mixin$create.appendTo = function (selector) { + var env = this._environment || _emberEnvironment.environment; + var target = undefined; - var Comment = (function (_StatementSyntax7) { - babelHelpers.inherits(Comment, _StatementSyntax7); + if (env.hasDOM) { + target = typeof selector === 'string' ? document.querySelector(selector) : selector; + } else { + target = selector; + } - function Comment(comment) { - _StatementSyntax7.call(this); - this.comment = comment; - this.type = "comment"; - } + this.renderer.appendTo(this, target); - Comment.fromSpec = function fromSpec(sexp) { - var value = sexp[1]; + return this; + }, _Mixin$create.renderToElement = function () { + var tagName = arguments.length <= 0 || arguments[0] === undefined ? 'body' : arguments[0]; - return new Comment(value); - }; + var element = this.renderer.createElement(tagName); - Comment.build = function build(value) { - return new this(value); - }; + this.renderer.appendTo(this, element); + return element; + }, _Mixin$create.replaceIn = function (selector) { + var target = _emberViewsSystemJquery.default(selector); - Comment.prototype.compile = function compile(dsl) { - dsl.comment(this.comment); - }; + this.renderer.replaceIn(this, target[0]); - return Comment; - })(_glimmerRuntimeLibSyntax.Statement); + return this; + }, _Mixin$create.append = function () { + return this.appendTo(document.body); + }, _Mixin$create.elementId = null, _Mixin$create.findElementInParentElement = function (parentElem) { + var id = '#' + this.elementId; + return _emberViewsSystemJquery.default(id)[0] || _emberViewsSystemJquery.default(id, parentElem)[0]; + }, _Mixin$create.willInsertElement = K, _Mixin$create.didInsertElement = K, _Mixin$create.willClearRender = K, _Mixin$create.destroy = function () { + this._super.apply(this, arguments); + this._currentState.destroy(this); + }, _Mixin$create.willDestroyElement = K, _Mixin$create.parentViewDidChange = K, _Mixin$create.tagName = null, _Mixin$create.init = function () { + this._super.apply(this, arguments); - exports.Comment = Comment; + if (!this.elementId && this.tagName !== '') { + this.elementId = _emberUtils.guidFor(this); + } - var OpenElement = (function (_StatementSyntax8) { - babelHelpers.inherits(OpenElement, _StatementSyntax8); + // if we find an `eventManager` property, deopt the + // `EventDispatcher`'s `canDispatchToEventManager` property + // if `null` + if (this.eventManager) { + var owner = _emberUtils.getOwner(this); + var dispatcher = owner && owner.lookup('event_dispatcher:main'); - function OpenElement(tag, blockParams, symbolTable) { - _StatementSyntax8.call(this); - this.tag = tag; - this.blockParams = blockParams; - this.symbolTable = symbolTable; - this.type = "open-element"; - } + if (dispatcher && dispatcher.canDispatchToEventManager === null) { + dispatcher.canDispatchToEventManager = true; + } + } + }, _Mixin$create.__defineNonEnumerable = function (property) { + this[property.name] = property.descriptor.value; + }, _Mixin$create.handleEvent = function (eventName, evt) { + return this._currentState.handleEvent(this, eventName, evt); + }, _Mixin$create)); +}); - OpenElement.fromSpec = function fromSpec(sexp, symbolTable) { - var tag = sexp[1]; - var blockParams = sexp[2]; +// Already warned in init - return new OpenElement(tag, blockParams, symbolTable); - }; +// .......................................................... +// TEMPLATE SUPPORT +// - OpenElement.build = function build(tag, blockParams, symbolTable) { - return new this(tag, blockParams, symbolTable); - }; +/** + Return the nearest ancestor that is an instance of the provided + class or mixin. + @method nearestOfType + @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself), + or an instance of Ember.Mixin. + @return Ember.View + @deprecated use `yield` and contextual components for composition instead. + @private +*/ - OpenElement.prototype.scan = function scan(scanner) { - var tag = this.tag; +/** + Return the nearest ancestor that has a given property. + @method nearestWithProperty + @param {String} property A property name + @return Ember.View + @deprecated use `yield` and contextual components for composition instead. + @private +*/ - if (scanner.env.hasComponentDefinition([tag], this.symbolTable)) { - var _parameters = this.parameters(scanner); +/** + Renders the view again. This will work regardless of whether the + view is already in the DOM or not. If the view is in the DOM, the + rendering process will be deferred to give bindings a chance + to synchronize. + If children were added during the rendering process using `appendChild`, + `rerender` will remove them, because they will be added again + if needed by the next `render`. + In general, if the display of your view changes, you should modify + the DOM element directly instead of manually calling `rerender`, which can + be slow. + @method rerender + @public +*/ - var args = _parameters.args; - var attrs = _parameters.attrs; +// .......................................................... +// ELEMENT SUPPORT +// - scanner.startBlock(this.blockParams); - this.tagContents(scanner); - var template = scanner.endBlock(this.blockParams); - args.blocks = Blocks.fromSpec(template); - return new Component(tag, attrs, args); - } else { - return new OpenPrimitiveElement(tag); - } - }; +/** + Returns the current DOM element for the view. + @property element + @type DOMElement + @public +*/ - OpenElement.prototype.compile = function compile(list, env) { - list.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(this.tag)); - }; +/** + Returns a jQuery object for this view's element. If you pass in a selector + string, this method will return a jQuery object, using the current element + as its buffer. + For example, calling `view.$('li')` will return a jQuery object containing + all of the `li` elements inside the DOM element of this view. + @method $ + @param {String} [selector] a jQuery-compatible selector string + @return {jQuery} the jQuery object for the DOM node + @public +*/ - OpenElement.prototype.toIdentity = function toIdentity() { - var tag = this.tag; +/** + Appends the view's element to the specified parent element. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing. + This is not typically a function that you will need to call directly when + building your application. If you do need to use `appendTo`, be sure that + the target element you are providing is associated with an `Ember.Application` + and does not have an ancestor element that is associated with an Ember view. + @method appendTo + @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object + @return {Ember.View} receiver + @private +*/ - return new OpenPrimitiveElement(tag); - }; +/** + Creates a new DOM element, renders the view into it, then returns the + element. + By default, the element created and rendered into will be a `BODY` element, + since this is the default context that views are rendered into when being + inserted directly into the DOM. + ```js + let element = view.renderToElement(); + element.tagName; // => "BODY" + ``` + You can override the kind of element rendered into and returned by + specifying an optional tag name as the first argument. + ```js + let element = view.renderToElement('table'); + element.tagName; // => "TABLE" + ``` + This method is useful if you want to render the view into an element that + is not in the document's body. Instead, a new `body` element, detached from + the DOM is returned. FastBoot uses this to serialize the rendered view into + a string for transmission over the network. + ```js + app.visit('/').then(function(instance) { + let element; + Ember.run(function() { + element = renderToElement(instance); + }); + res.send(serialize(element)); + }); + ``` + @method renderToElement + @param {String} tagName The tag of the element to create and render into. Defaults to "body". + @return {HTMLBodyElement} element + @deprecated Use appendTo instead. + @private +*/ - OpenElement.prototype.parameters = function parameters(scanner) { - var current = scanner.next(); - var attrs = []; - var argKeys = []; - var argValues = []; - while (!(current instanceof FlushElement)) { - if (current[MODIFIER_SYNTAX]) { - throw new Error('Compile Error: Element modifiers are not allowed in components'); - } - var param = current; - if (current[_glimmerRuntimeLibSyntax.ATTRIBUTE]) { - attrs.push(param.name); - // REMOVE ME: attributes should not be treated as args - argKeys.push(param.name); - argValues.push(param.valueSyntax()); - } else if (current[_glimmerRuntimeLibSyntax.ARGUMENT]) { - argKeys.push(param.name); - argValues.push(param.valueSyntax()); - } else { - throw new Error("Expected FlushElement, but got ${current}"); - } - current = scanner.next(); - } - return { args: Args.fromNamedArgs(NamedArgs.build(argKeys, argValues)), attrs: attrs }; - }; +/** + Replaces the content of the specified parent element with this view's + element. If the view does not have an HTML representation yet, + the element will be generated automatically. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the given element until all bindings have + finished synchronizing + @method replaceIn + @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object + @return {Ember.View} received + @private +*/ - OpenElement.prototype.tagContents = function tagContents(scanner) { - var nesting = 1; - while (true) { - var current = scanner.next(); - if (current instanceof CloseElement && --nesting === 0) { - break; - } - scanner.addStatement(current); - if (current instanceof OpenElement || current instanceof OpenPrimitiveElement) { - nesting++; - } - } - }; +/** + Appends the view's element to the document body. If the view does + not have an HTML representation yet + the element will be generated automatically. + If your application uses the `rootElement` property, you must append + the view within that element. Rendering views outside of the `rootElement` + is not supported. + Note that this method just schedules the view to be appended; the DOM + element will not be appended to the document body until all bindings have + finished synchronizing. + @method append + @return {Ember.View} receiver + @private +*/ - return OpenElement; - })(_glimmerRuntimeLibSyntax.Statement); +/** + The HTML `id` of the view's element in the DOM. You can provide this + value yourself but it must be unique (just as in HTML): + ```handlebars + {{my-component elementId="a-really-cool-id"}} + ``` + If not manually set a default value will be provided by the framework. + Once rendered an element's `elementId` is considered immutable and you + should never change it. If you need to compute a dynamic value for the + `elementId`, you should do this when the component or element is being + instantiated: + ```javascript + export default Ember.Component.extend({ + init() { + this._super(...arguments); + let index = this.get('index'); + this.set('elementId', 'component-id' + index); + } + }); + ``` + @property elementId + @type String + @public +*/ - exports.OpenElement = OpenElement; +/** + Attempts to discover the element in the parent element. The default + implementation looks for an element with an ID of `elementId` (or the + view's guid if `elementId` is null). You can override this method to + provide your own form of lookup. For example, if you want to discover your + element using a CSS class name instead of an ID. + @method findElementInParentElement + @param {DOMElement} parentElement The parent's DOM element + @return {DOMElement} The discovered element + @private +*/ - var Component = (function (_StatementSyntax9) { - babelHelpers.inherits(Component, _StatementSyntax9); +/** + Called when a view is going to insert an element into the DOM. + @event willInsertElement + @public +*/ - function Component(tag, attrs, args) { - _StatementSyntax9.call(this); - this.tag = tag; - this.attrs = attrs; - this.args = args; - this.type = 'component'; - } - - Component.prototype.compile = function compile(list, env, symbolTable) { - var definition = env.getComponentDefinition([this.tag], symbolTable); - var args = this.args.compile(list, env, symbolTable); - var shadow = this.attrs; - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.PutComponentDefinitionOpcode(definition)); - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.OpenComponentOpcode(args, shadow)); - list.append(new _glimmerRuntimeLibCompiledOpcodesComponent.CloseComponentOpcode()); - }; +/** + Called when the element of the view has been inserted into the DOM. + Override this function to do any set up that requires an element + in the document body. + When a view has children, didInsertElement will be called on the + child view(s) first and on itself afterwards. + @event didInsertElement + @public +*/ - return Component; - })(_glimmerRuntimeLibSyntax.Statement); +/** + Called when the view is about to rerender, but before anything has + been torn down. This is a good opportunity to tear down any manual + observers you have installed based on the DOM state + @event willClearRender + @public +*/ - exports.Component = Component; +/** + You must call `destroy` on a view to destroy the view (and all of its + child views). This will remove the view from any parent node, then make + sure that the DOM element managed by the view can be released by the + memory manager. + @method destroy + @private +*/ - var OpenPrimitiveElement = (function (_StatementSyntax10) { - babelHelpers.inherits(OpenPrimitiveElement, _StatementSyntax10); +/** + Called when the element of the view is going to be destroyed. Override + this function to do any teardown that requires an element, like removing + event listeners. + Please note: any property changes made during this event will have no + effect on object observers. + @event willDestroyElement + @public +*/ - function OpenPrimitiveElement(tag) { - _StatementSyntax10.call(this); - this.tag = tag; - this.type = "open-primitive-element"; - } +/** + Called when the parentView property has changed. + @event parentViewDidChange + @private +*/ - OpenPrimitiveElement.build = function build(tag) { - return new this(tag); - }; +// .......................................................... +// STANDARD RENDER PROPERTIES +// - OpenPrimitiveElement.prototype.compile = function compile(compiler) { - compiler.append(new _glimmerRuntimeLibCompiledOpcodesDom.OpenPrimitiveElementOpcode(this.tag)); - }; +/** + Tag name for the view's outer element. The tag name is only used when an + element is first created. If you change the `tagName` for an element, you + must destroy and recreate the view element. + By default, the render buffer will use a `
    ` tag for views. + @property tagName + @type String + @default null + @public +*/ - return OpenPrimitiveElement; - })(_glimmerRuntimeLibSyntax.Statement); +// We leave this null by default so we can tell the difference between +// the default case and a user-specified tag. - exports.OpenPrimitiveElement = OpenPrimitiveElement; +// ....................................................... +// CORE DISPLAY METHODS +// - var Yield = (function (_StatementSyntax11) { - babelHelpers.inherits(Yield, _StatementSyntax11); +/** + Setup a view, but do not finish waking it up. + * configure `childViews` + * register the view with the global views hash, which is used for event + dispatch + @method init + @private +*/ - function Yield(to, args) { - _StatementSyntax11.call(this); - this.to = to; - this.args = args; - this.type = "yield"; - } +// ....................................................... +// EVENT HANDLING +// - Yield.fromSpec = function fromSpec(sexp) { - var to = sexp[1]; - var params = sexp[2]; +/** + Handle events from `Ember.EventDispatcher` + @method handleEvent + @param eventName {String} + @param evt {Event} + @private +*/ +enifed("ember-views/system/action_manager", ["exports"], function (exports) { + /** + @module ember + @submodule ember-views + */ - var args = Args.fromSpec(params, null, EMPTY_BLOCKS); - return new Yield(to, args); - }; + "use strict"; - Yield.build = function build(params, to) { - var args = Args.fromPositionalArgs(PositionalArgs.build(params)); - return new this(to, args); - }; + exports.default = ActionManager; - Yield.prototype.compile = function compile(dsl, env, symbolTable) { - var to = this.to; - - var args = this.args.compile(dsl, env, symbolTable); - if (dsl.hasBlockSymbol(to)) { - var symbol = dsl.getBlockSymbol(to); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, to); - dsl.append(new OpenBlockOpcode(inner, args)); - dsl.append(new CloseBlockOpcode()); - } else if (dsl.hasPartialArgsSymbol()) { - var symbol = dsl.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, to); - dsl.append(new OpenBlockOpcode(inner, args)); - dsl.append(new CloseBlockOpcode()); - } else { - throw new Error('[BUG] ${to} is not a valid block name.'); - } - }; + function ActionManager() {} - return Yield; - })(_glimmerRuntimeLibSyntax.Statement); + /** + Global action id hash. + + @private + @property registeredActions + @type Object + */ + ActionManager.registeredActions = {}; +}); +enifed('ember-views/system/event_dispatcher', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-views/system/jquery', 'ember-views/system/action_manager', 'ember-environment', 'ember-views/compat/fallback-view-registry'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberViewsSystemJquery, _emberViewsSystemAction_manager, _emberEnvironment, _emberViewsCompatFallbackViewRegistry) { + /** + @module ember + @submodule ember-views + */ - exports.Yield = Yield; + 'use strict'; - function isStaticPartialName(exp) { - return exp.type === 'value'; - } + var ROOT_ELEMENT_CLASS = 'ember-application'; + var ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; - var Partial = (function (_StatementSyntax12) { - babelHelpers.inherits(Partial, _StatementSyntax12); + /** + `Ember.EventDispatcher` handles delegating browser events to their + corresponding `Ember.Views.` For example, when you click on a view, + `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets + called. + + @class EventDispatcher + @namespace Ember + @private + @extends Ember.Object + */ + exports.default = _emberRuntime.Object.extend({ - function Partial() { - _StatementSyntax12.apply(this, arguments); + /** + The set of events names (and associated handler function names) to be setup + and dispatched by the `EventDispatcher`. Modifications to this list can be done + at setup time, generally via the `Ember.Application.customEvents` hash. + To add new events to be listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + paste: 'paste' } - - Partial.fromSpec = function fromSpec(sexp) { - var exp = sexp[1]; - - var name = _glimmerRuntimeLibSyntaxExpressions.default(exp); - if (isStaticPartialName(name)) { - return new _glimmerRuntimeLibSyntaxBuiltinsPartial.StaticPartialSyntax(name); - } else { - return new _glimmerRuntimeLibSyntaxBuiltinsPartial.DynamicPartialSyntax(name); - } - }; - - return Partial; - })(_glimmerRuntimeLibSyntax.Statement); - - exports.Partial = Partial; - - var OpenBlockOpcode = (function (_Opcode) { - babelHelpers.inherits(OpenBlockOpcode, _Opcode); - - function OpenBlockOpcode(inner, args) { - _Opcode.call(this); - this.inner = inner; - this.args = args; - this.type = "open-block"; + }); + ``` + To prevent default events from being listened to: + ```javascript + let App = Ember.Application.create({ + customEvents: { + mouseenter: null, + mouseleave: null } + }); + ``` + @property events + @type Object + @private + */ + events: { + touchstart: 'touchStart', + touchmove: 'touchMove', + touchend: 'touchEnd', + touchcancel: 'touchCancel', + keydown: 'keyDown', + keyup: 'keyUp', + keypress: 'keyPress', + mousedown: 'mouseDown', + mouseup: 'mouseUp', + contextmenu: 'contextMenu', + click: 'click', + dblclick: 'doubleClick', + mousemove: 'mouseMove', + focusin: 'focusIn', + focusout: 'focusOut', + mouseenter: 'mouseEnter', + mouseleave: 'mouseLeave', + submit: 'submit', + input: 'input', + change: 'change', + dragstart: 'dragStart', + drag: 'drag', + dragenter: 'dragEnter', + dragleave: 'dragLeave', + dragover: 'dragOver', + drop: 'drop', + dragend: 'dragEnd' + }, - OpenBlockOpcode.prototype.evaluate = function evaluate(vm) { - var block = this.inner.evaluate(vm); - var args = undefined; - if (block) { - args = this.args.evaluate(vm); - } - // FIXME: can we avoid doing this when we don't have a block? - vm.pushCallerScope(); - if (block) { - vm.invokeBlock(block, args); - } - }; - - OpenBlockOpcode.prototype.toJSON = function toJSON() { - return { - guid: this._guid, - type: this.type, - details: { - "block": this.inner.toJSON(), - "positional": this.args.positional.toJSON(), - "named": this.args.named.toJSON() - } - }; - }; + /** + The root DOM element to which event listeners should be attached. Event + listeners will be attached to the document unless this is overridden. + Can be specified as a DOMElement or a selector string. + The default body is a string since this may be evaluated before document.body + exists in the DOM. + @private + @property rootElement + @type DOMElement + @default 'body' + */ + rootElement: 'body', - return OpenBlockOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + /** + It enables events to be dispatched to the view's `eventManager.` When present, + this object takes precedence over handling of events on the view itself. + Note that most Ember applications do not use this feature. If your app also + does not use it, consider setting this property to false to gain some performance + improvement by allowing the EventDispatcher to skip the search for the + `eventManager` on the view tree. + ```javascript + let EventDispatcher = Em.EventDispatcher.extend({ + events: { + click : 'click', + focusin : 'focusIn', + focusout : 'focusOut', + change : 'change' + }, + canDispatchToEventManager: false + }); + container.register('event_dispatcher:main', EventDispatcher); + ``` + @property canDispatchToEventManager + @type boolean + @default false + @since 1.7.0 + @private + */ + canDispatchToEventManager: null, - var CloseBlockOpcode = (function (_Opcode2) { - babelHelpers.inherits(CloseBlockOpcode, _Opcode2); + init: function () { + this._super(); + }, - function CloseBlockOpcode() { - _Opcode2.apply(this, arguments); - this.type = "close-block"; - } + /** + Sets up event listeners for standard browser events. + This will be called after the browser sends a `DOMContentReady` event. By + default, it will set up all of the listeners on the document body. If you + would like to register the listeners on a different element, set the event + dispatcher's `root` property. + @private + @method setup + @param addedEvents {Object} + */ + setup: function (addedEvents, rootElement) { + var event = undefined; + var events = this._finalEvents = _emberUtils.assign({}, _emberMetal.get(this, 'events'), addedEvents); - CloseBlockOpcode.prototype.evaluate = function evaluate(vm) { - vm.popScope(); - }; + if (_emberMetal.isNone(rootElement)) { + rootElement = _emberMetal.get(this, 'rootElement'); + } else { + _emberMetal.set(this, 'rootElement', rootElement); + } - return CloseBlockOpcode; - })(_glimmerRuntimeLibOpcodes.Opcode); + rootElement = _emberViewsSystemJquery.default(rootElement); - exports.CloseBlockOpcode = CloseBlockOpcode; + rootElement.addClass(ROOT_ELEMENT_CLASS); - var Value = (function (_ExpressionSyntax) { - babelHelpers.inherits(Value, _ExpressionSyntax); + if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) { + throw new TypeError('Unable to add \'' + ROOT_ELEMENT_CLASS + '\' class to root element (' + (rootElement.selector || rootElement[0].tagName) + '). Make sure you set rootElement to the body or an element in the body.'); + } - function Value(value) { - _ExpressionSyntax.call(this); - this.value = value; - this.type = "value"; + for (event in events) { + if (events.hasOwnProperty(event)) { + this.setupHandler(rootElement, event, events[event]); } + } + }, - Value.fromSpec = function fromSpec(value) { - return new Value(value); - }; - - Value.build = function build(value) { - return new this(value); - }; - - Value.prototype.inner = function inner() { - return this.value; - }; + /** + Registers an event listener on the rootElement. If the given event is + triggered, the provided event handler will be triggered on the target view. + If the target view does not implement the event handler, or if the handler + returns `false`, the parent view will be called. The event will continue to + bubble to each successive parent view until it reaches the top. + @private + @method setupHandler + @param {Element} rootElement + @param {String} event the browser-originated event to listen to + @param {String} eventName the name of the method to call on the view + */ + setupHandler: function (rootElement, event, eventName) { + var self = this; - Value.prototype.compile = function compile(compiler) { - return new _glimmerRuntimeLibCompiledExpressionsValue.default(this.value); - }; + var owner = _emberUtils.getOwner(this); + var viewRegistry = owner && owner.lookup('-view-registry:main') || _emberViewsCompatFallbackViewRegistry.default; - return Value; - })(_glimmerRuntimeLibSyntax.Expression); + if (eventName === null) { + return; + } - exports.Value = Value; + rootElement.on(event + '.ember', '.ember-view', function (evt, triggeringManager) { + var view = viewRegistry[this.id]; + var result = true; - var GetArgument = (function (_ExpressionSyntax2) { - babelHelpers.inherits(GetArgument, _ExpressionSyntax2); + var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; - function GetArgument(parts) { - _ExpressionSyntax2.call(this); - this.parts = parts; - this.type = "get-argument"; + if (manager && manager !== triggeringManager) { + result = self._dispatchEvent(manager, evt, eventName, view); + } else if (view) { + result = self._bubbleEvent(view, evt, eventName); } - // this is separated out from Get because Unknown also has a ref, but it - // may turn out to be a helper + return result; + }); - GetArgument.fromSpec = function fromSpec(sexp) { - var parts = sexp[1]; + rootElement.on(event + '.ember', '[data-ember-action]', function (evt) { + var attributes = evt.currentTarget.attributes; - return new GetArgument(parts); - }; + for (var i = 0; i < attributes.length; i++) { + var attr = attributes.item(i); + var attrName = attr.name; - GetArgument.build = function build(path) { - return new this(path.split('.')); - }; + if (attrName.lastIndexOf('data-ember-action-', 0) !== -1) { + var action = _emberViewsSystemAction_manager.default.registeredActions[attr.value]; - GetArgument.prototype.compile = function compile(lookup) { - var parts = this.parts; - - var head = parts[0]; - if (lookup.hasNamedSymbol(head)) { - var symbol = lookup.getNamedSymbol(head); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSymbol(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else if (lookup.hasPartialArgsSymbol()) { - var symbol = lookup.getPartialArgsSymbol(); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledInPartialName(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else { - throw new Error('[BUG] @' + this.parts.join('.') + ' is not a valid lookup path.'); + if (action.eventName === eventName) { + action.handler(evt); } - }; - - return GetArgument; - })(_glimmerRuntimeLibSyntax.Expression); - - exports.GetArgument = GetArgument; - - var Ref = (function (_ExpressionSyntax3) { - babelHelpers.inherits(Ref, _ExpressionSyntax3); - - function Ref(parts) { - _ExpressionSyntax3.call(this); - this.parts = parts; - this.type = "ref"; + } } + }); + }, - Ref.build = function build(path) { - var parts = path.split('.'); - if (parts[0] === 'this') { - parts[0] = null; - } - return new this(parts); - }; - - Ref.prototype.compile = function compile(lookup) { - var parts = this.parts; - - var head = parts[0]; - if (head === null) { - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSelf(); - var path = parts.slice(1); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else if (lookup.hasLocalSymbol(head)) { - var symbol = lookup.getLocalSymbol(head); - var path = parts.slice(1); - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSymbol(symbol, head); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, path); - } else { - var inner = new _glimmerRuntimeLibCompiledExpressionsLookups.CompiledSelf(); - return _glimmerRuntimeLibCompiledExpressionsLookups.default.create(inner, parts); - } - }; - - return Ref; - })(_glimmerRuntimeLibSyntax.Expression); + _findNearestEventManager: function (view, eventName) { + var manager = null; - exports.Ref = Ref; + while (view) { + manager = _emberMetal.get(view, 'eventManager'); + if (manager && manager[eventName]) { + break; + } - var Get = (function (_ExpressionSyntax4) { - babelHelpers.inherits(Get, _ExpressionSyntax4); + view = _emberMetal.get(view, 'parentView'); + } - function Get(ref) { - _ExpressionSyntax4.call(this); - this.ref = ref; - this.type = "get"; - } + return manager; + }, - Get.fromSpec = function fromSpec(sexp) { - var parts = sexp[1]; + _dispatchEvent: function (object, evt, eventName, view) { + var result = true; - return new this(new Ref(parts)); - }; + var handler = object[eventName]; + if (typeof handler === 'function') { + result = _emberMetal.run(object, handler, evt, view); + // Do not preventDefault in eventManagers. + evt.stopPropagation(); + } else { + result = this._bubbleEvent(view, evt, eventName); + } - Get.build = function build(path) { - return new this(Ref.build(path)); - }; + return result; + }, - Get.prototype.compile = function compile(compiler) { - return this.ref.compile(compiler); - }; + _bubbleEvent: function (view, evt, eventName) { + return view.handleEvent(eventName, evt); + }, - return Get; - })(_glimmerRuntimeLibSyntax.Expression); + destroy: function () { + var rootElement = _emberMetal.get(this, 'rootElement'); + _emberViewsSystemJquery.default(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); + return this._super.apply(this, arguments); + }, - exports.Get = Get; + toString: function () { + return '(EventDispatcher)'; + } + }); +}); +enifed('ember-views/system/ext', ['exports', 'ember-metal'], function (exports, _emberMetal) { + /** + @module ember + @submodule ember-views + */ - var Unknown = (function (_ExpressionSyntax5) { - babelHelpers.inherits(Unknown, _ExpressionSyntax5); + 'use strict'; - function Unknown(ref) { - _ExpressionSyntax5.call(this); - this.ref = ref; - this.type = "unknown"; - } + // Add a new named queue for rendering views that happens + // after bindings have synced, and a queue for scheduling actions + // that should occur after view rendering. + _emberMetal.run._addQueue('render', 'actions'); + _emberMetal.run._addQueue('afterRender', 'render'); +}); +enifed('ember-views/system/jquery', ['exports', 'ember-environment'], function (exports, _emberEnvironment) { + 'use strict'; - Unknown.fromSpec = function fromSpec(sexp) { - var path = sexp[1]; + var jQuery = undefined; - return new this(new Ref(path)); - }; + if (_emberEnvironment.environment.hasDOM) { + jQuery = _emberEnvironment.context.imports.jQuery; - Unknown.build = function build(path) { - return new this(Ref.build(path)); - }; + if (jQuery) { + if (jQuery.event.addProp) { + jQuery.event.addProp('dataTransfer'); + } else { + // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents + ['dragstart', 'drag', 'dragenter', 'dragleave', 'dragover', 'drop', 'dragend'].forEach(function (eventName) { + jQuery.event.fixHooks[eventName] = { + props: ['dataTransfer'] + }; + }); + } + } + } - Unknown.prototype.compile = function compile(compiler, env, symbolTable) { - var ref = this.ref; + exports.default = jQuery; +}); +enifed('ember-views/system/lookup_partial', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - if (env.hasHelper(ref.parts, symbolTable)) { - return new _glimmerRuntimeLibCompiledExpressionsHelper.default(ref.parts, env.lookupHelper(ref.parts, symbolTable), _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.empty(), symbolTable); - } else { - return this.ref.compile(compiler); - } - }; + exports.default = lookupPartial; + exports.hasPartial = hasPartial; - return Unknown; - })(_glimmerRuntimeLibSyntax.Expression); + function parseUnderscoredName(templateName) { + var nameParts = templateName.split('/'); + var lastPart = nameParts[nameParts.length - 1]; - exports.Unknown = Unknown; + nameParts[nameParts.length - 1] = '_' + lastPart; - var Helper = (function (_ExpressionSyntax6) { - babelHelpers.inherits(Helper, _ExpressionSyntax6); + return nameParts.join('/'); + } - function Helper(ref, args) { - _ExpressionSyntax6.call(this); - this.ref = ref; - this.args = args; - this.type = "helper"; - } + function lookupPartial(templateName, owner) { + if (templateName == null) { + return; + } - Helper.fromSpec = function fromSpec(sexp) { - var path = sexp[1]; - var params = sexp[2]; - var hash = sexp[3]; + var template = templateFor(owner, parseUnderscoredName(templateName), templateName); - return new Helper(new Ref(path), Args.fromSpec(params, hash, EMPTY_BLOCKS)); - }; + return template; + } - Helper.build = function build(path, positional, named) { - return new this(Ref.build(path), Args.build(positional, named, EMPTY_BLOCKS)); - }; + function hasPartial(name, owner) { + if (!owner) { + throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); + } - Helper.prototype.compile = function compile(compiler, env, symbolTable) { - if (env.hasHelper(this.ref.parts, symbolTable)) { - var args = this.args; - var ref = this.ref; + return owner.hasRegistration('template:' + parseUnderscoredName(name)) || owner.hasRegistration('template:' + name); + } - return new _glimmerRuntimeLibCompiledExpressionsHelper.default(ref.parts, env.lookupHelper(ref.parts, symbolTable), args.compile(compiler, env, symbolTable), symbolTable); - } else { - throw new Error('Compile Error: ' + this.ref.parts.join('.') + ' is not a helper'); - } - }; + function templateFor(owner, underscored, name) { + if (!name) { + return; + } - return Helper; - })(_glimmerRuntimeLibSyntax.Expression); + if (!owner) { + throw new _emberMetal.Error('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); + } - exports.Helper = Helper; + return owner.lookup('template:' + underscored) || owner.lookup('template:' + name); + } +}); +enifed('ember-views/system/utils', ['exports', 'ember-utils'], function (exports, _emberUtils) { + /* globals Element */ + 'use strict'; - var HasBlock = (function (_ExpressionSyntax7) { - babelHelpers.inherits(HasBlock, _ExpressionSyntax7); + exports.isSimpleClick = isSimpleClick; + exports.getRootViews = getRootViews; + exports.getViewId = getViewId; + exports.getViewElement = getViewElement; + exports.initViewElement = initViewElement; + exports.setViewElement = setViewElement; + exports.getChildViews = getChildViews; + exports.initChildViews = initChildViews; + exports.addChildView = addChildView; + exports.collectChildViews = collectChildViews; + exports.getViewBounds = getViewBounds; + exports.getViewRange = getViewRange; + exports.getViewClientRects = getViewClientRects; + exports.getViewBoundingClientRect = getViewBoundingClientRect; + exports.matches = matches; - function HasBlock(blockName) { - _ExpressionSyntax7.call(this); - this.blockName = blockName; - this.type = "has-block"; - } + /** + @module ember + @submodule ember-views + */ - HasBlock.fromSpec = function fromSpec(sexp) { - var blockName = sexp[1]; + function isSimpleClick(event) { + var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; + var secondaryClick = event.which > 1; // IE9 may return undefined - return new HasBlock(blockName); - }; + return !modifier && !secondaryClick; + } - HasBlock.build = function build(blockName) { - return new this(blockName); - }; + var STYLE_WARNING = '' + 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + 'please ensure that values being bound are properly escaped. For more information, ' + 'including how to disable this warning, see ' + 'http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.'; - HasBlock.prototype.compile = function compile(compiler, env) { - var blockName = this.blockName; - - if (compiler.hasBlockSymbol(blockName)) { - var symbol = compiler.getBlockSymbol(blockName); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.default(inner); - } else if (compiler.hasPartialArgsSymbol()) { - var symbol = compiler.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.default(inner); - } else { - throw new Error('[BUG] ${blockName} is not a valid block name.'); - } - }; + exports.STYLE_WARNING = STYLE_WARNING; + /** + @private + @method getRootViews + @param {Object} owner + */ - return HasBlock; - })(_glimmerRuntimeLibSyntax.Expression); + function getRootViews(owner) { + var registry = owner.lookup('-view-registry:main'); - exports.HasBlock = HasBlock; + var rootViews = []; - var HasBlockParams = (function (_ExpressionSyntax8) { - babelHelpers.inherits(HasBlockParams, _ExpressionSyntax8); + Object.keys(registry).forEach(function (id) { + var view = registry[id]; - function HasBlockParams(blockName) { - _ExpressionSyntax8.call(this); - this.blockName = blockName; - this.type = "has-block-params"; - } + if (view.parentView === null) { + rootViews.push(view); + } + }); - HasBlockParams.fromSpec = function fromSpec(sexp) { - var blockName = sexp[1]; + return rootViews; + } - return new HasBlockParams(blockName); - }; + /** + @private + @method getViewId + @param {Ember.View} view + */ - HasBlockParams.build = function build(blockName) { - return new this(blockName); - }; + function getViewId(view) { + if (view.tagName === '') { + return _emberUtils.guidFor(view); + } else { + return view.elementId || _emberUtils.guidFor(view); + } + } - HasBlockParams.prototype.compile = function compile(compiler, env) { - var blockName = this.blockName; - - if (compiler.hasBlockSymbol(blockName)) { - var symbol = compiler.getBlockSymbol(blockName); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledGetBlockBySymbol(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledHasBlockParams(inner); - } else if (compiler.hasPartialArgsSymbol()) { - var symbol = compiler.getPartialArgsSymbol(); - var inner = new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledInPartialGetBlock(symbol, blockName); - return new _glimmerRuntimeLibCompiledExpressionsHasBlock.CompiledHasBlockParams(inner); - } else { - throw new Error('[BUG] ${blockName} is not a valid block name.'); - } - }; + var VIEW_ELEMENT = _emberUtils.symbol('VIEW_ELEMENT'); - return HasBlockParams; - })(_glimmerRuntimeLibSyntax.Expression); + /** + @private + @method getViewElement + @param {Ember.View} view + */ - exports.HasBlockParams = HasBlockParams; + function getViewElement(view) { + return view[VIEW_ELEMENT]; + } - var Concat = (function () { - function Concat(parts) { - this.parts = parts; - this.type = "concat"; - } + function initViewElement(view) { + view[VIEW_ELEMENT] = null; + } - Concat.fromSpec = function fromSpec(sexp) { - var params = sexp[1]; + function setViewElement(view, element) { + return view[VIEW_ELEMENT] = element; + } - return new Concat(params.map(_glimmerRuntimeLibSyntaxExpressions.default)); - }; + var CHILD_VIEW_IDS = _emberUtils.symbol('CHILD_VIEW_IDS'); - Concat.build = function build(parts) { - return new this(parts); - }; + /** + @private + @method getChildViews + @param {Ember.View} view + */ - Concat.prototype.compile = function compile(compiler, env, symbolTable) { - return new _glimmerRuntimeLibCompiledExpressionsConcat.default(this.parts.map(function (p) { - return p.compile(compiler, env, symbolTable); - })); - }; + function getChildViews(view) { + var owner = _emberUtils.getOwner(view); + var registry = owner.lookup('-view-registry:main'); + return collectChildViews(view, registry); + } - return Concat; - })(); + function initChildViews(view) { + view[CHILD_VIEW_IDS] = []; + } - exports.Concat = Concat; + function addChildView(parent, child) { + parent[CHILD_VIEW_IDS].push(getViewId(child)); + } - var Blocks = (function () { - function Blocks(_default) { - var inverse = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + function collectChildViews(view, registry) { + var ids = []; + var views = []; - this.type = "blocks"; - this.default = _default; - this.inverse = inverse; - } + view[CHILD_VIEW_IDS].forEach(function (id) { + var view = registry[id]; - Blocks.fromSpec = function fromSpec(_default) { - var inverse = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + if (view && !view.isDestroying && !view.isDestroyed && ids.indexOf(id) === -1) { + ids.push(id); + views.push(view); + } + }); - return new Blocks(_default, inverse); - }; + view[CHILD_VIEW_IDS] = ids; - Blocks.empty = function empty() { - return EMPTY_BLOCKS; - }; + return views; + } - return Blocks; - })(); + /** + @private + @method getViewBounds + @param {Ember.View} view + */ - exports.Blocks = Blocks; - var EMPTY_BLOCKS = new ((function (_Blocks) { - babelHelpers.inherits(_class, _Blocks); + function getViewBounds(view) { + return view.renderer.getBounds(view); + } - function _class() { - _Blocks.call(this, null, null); - } + /** + @private + @method getViewRange + @param {Ember.View} view + */ - return _class; - })(Blocks))(); - exports.EMPTY_BLOCKS = EMPTY_BLOCKS; + function getViewRange(view) { + var bounds = getViewBounds(view); - var Args = (function () { - function Args(positional, named, blocks) { - this.positional = positional; - this.named = named; - this.blocks = blocks; - this.type = "args"; - } + var range = document.createRange(); + range.setStartBefore(bounds.firstNode); + range.setEndAfter(bounds.lastNode); - Args.empty = function empty() { - return EMPTY_ARGS; - }; + return range; + } - Args.fromSpec = function fromSpec(positional, named, blocks) { - return new Args(PositionalArgs.fromSpec(positional), NamedArgs.fromSpec(named), blocks); - }; + /** + `getViewClientRects` provides information about the position of the border + box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inspector + and may not work on older browsers. + + @private + @method getViewClientRects + @param {Ember.View} view + */ - Args.fromPositionalArgs = function fromPositionalArgs(positional) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? EMPTY_BLOCKS : arguments[1]; + function getViewClientRects(view) { + var range = getViewRange(view); + return range.getClientRects(); + } - return new Args(positional, EMPTY_NAMED_ARGS, blocks); - }; + /** + `getViewBoundingClientRect` provides information about the position of the + bounding border box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inpsector + and may not work on older browsers. + + @private + @method getViewBoundingClientRect + @param {Ember.View} view + */ - Args.fromNamedArgs = function fromNamedArgs(named) { - var blocks = arguments.length <= 1 || arguments[1] === undefined ? EMPTY_BLOCKS : arguments[1]; + function getViewBoundingClientRect(view) { + var range = getViewRange(view); + return range.getBoundingClientRect(); + } - return new Args(EMPTY_POSITIONAL_ARGS, named, blocks); - }; + /** + Determines if the element matches the specified selector. + + @private + @method matches + @param {DOMElement} el + @param {String} selector + */ + var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector); - Args.build = function build(positional, named, blocks) { - if (positional === EMPTY_POSITIONAL_ARGS && named === EMPTY_NAMED_ARGS && blocks === EMPTY_BLOCKS) { - return EMPTY_ARGS; - } else { - return new this(positional, named, blocks); - } - }; + exports.elMatches = elMatches; - Args.prototype.compile = function compile(compiler, env, symbolTable) { - var positional = this.positional; - var named = this.named; - var blocks = this.blocks; + function matches(el, selector) { + return elMatches.call(el, selector); + } +}); +enifed('ember-views/utils/lookup-component', ['exports', 'container'], function (exports, _container) { + 'use strict'; - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.create(positional.compile(compiler, env, symbolTable), named.compile(compiler, env, symbolTable), blocks); - }; + exports.default = lookupComponent; - return Args; - })(); + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['component:-default'], ['component:-default']); - exports.Args = Args; + function lookupComponentPair(componentLookup, owner, name, options) { + var component = componentLookup.componentFor(name, owner, options); + var layout = componentLookup.layoutFor(name, owner, options); - var PositionalArgs = (function () { - function PositionalArgs(values) { - this.values = values; - this.type = "positional"; - this.length = values.length; - } + var result = { layout: layout, component: component }; - PositionalArgs.empty = function empty() { - return EMPTY_POSITIONAL_ARGS; - }; + if (layout && !component) { + result.component = owner[_container.FACTORY_FOR](_container.privatize(_templateObject)); + } - PositionalArgs.fromSpec = function fromSpec(sexp) { - if (!sexp || sexp.length === 0) return EMPTY_POSITIONAL_ARGS; - return new PositionalArgs(sexp.map(_glimmerRuntimeLibSyntaxExpressions.default)); - }; + return result; + } - PositionalArgs.build = function build(exprs) { - if (exprs.length === 0) { - return EMPTY_POSITIONAL_ARGS; - } else { - return new this(exprs); - } - }; + function lookupComponent(owner, name, options) { + var componentLookup = owner.lookup('component-lookup:main'); - PositionalArgs.prototype.slice = function slice(start, end) { - return PositionalArgs.build(this.values.slice(start, end)); - }; + var source = options && options.source; - PositionalArgs.prototype.at = function at(index) { - return this.values[index]; - }; + if (source) { + var localResult = lookupComponentPair(componentLookup, owner, name, options); - PositionalArgs.prototype.compile = function compile(compiler, env, symbolTable) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs.create(this.values.map(function (v) { - return v.compile(compiler, env, symbolTable); - })); - }; + if (localResult.component || localResult.layout) { + return localResult; + } + } - return PositionalArgs; - })(); + return lookupComponentPair(componentLookup, owner, name); + } +}); +enifed('ember-views/views/core_view', ['exports', 'ember-runtime', 'ember-views/system/utils', 'ember-views/views/states'], function (exports, _emberRuntime, _emberViewsSystemUtils, _emberViewsViewsStates) { + 'use strict'; - exports.PositionalArgs = PositionalArgs; + /** + `Ember.CoreView` is an abstract class that exists to give view-like behavior + to both Ember's main view class `Ember.Component` and other classes that don't need + the full functionality of `Ember.Component`. + + Unless you have specific needs for `CoreView`, you will use `Ember.Component` + in your applications. + + @class CoreView + @namespace Ember + @extends Ember.Object + @deprecated Use `Ember.Component` instead. + @uses Ember.Evented + @uses Ember.ActionHandler + @private + */ + var CoreView = _emberRuntime.FrameworkObject.extend(_emberRuntime.Evented, _emberRuntime.ActionHandler, { + isView: true, - var EMPTY_POSITIONAL_ARGS = new ((function (_PositionalArgs) { - babelHelpers.inherits(_class2, _PositionalArgs); + _states: _emberViewsViewsStates.cloneStates(_emberViewsViewsStates.states), - function _class2() { - _PositionalArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + init: function () { + this._super.apply(this, arguments); + this._state = 'preRender'; + this._currentState = this._states.preRender; - _class2.prototype.slice = function slice(start, end) { - return this; - }; + _emberViewsSystemUtils.initViewElement(this); - _class2.prototype.at = function at(index) { - return undefined; // ??! - }; + if (!this.renderer) { + throw new Error('Cannot instantiate a component without a renderer. Please ensure that you are creating ' + this + ' with a proper container/registry.'); + } + }, - _class2.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledPositionalArgs.empty(); - }; + /** + If the view is currently inserted into the DOM of a parent view, this + property will point to the parent of the view. + @property parentView + @type Ember.View + @default null + @private + */ + parentView: null, - return _class2; - })(PositionalArgs))(); + instrumentDetails: function (hash) { + hash.object = this.toString(); + hash.containerKey = this._debugContainerKey; + hash.view = this; + return hash; + }, - var NamedArgs = (function () { - function NamedArgs(keys, values) { - this.keys = keys; - this.values = values; - this.type = "named"; - this.length = keys.length; + /** + Override the default event firing from `Ember.Evented` to + also call methods with the given name. + @method trigger + @param name {String} + @private + */ + trigger: function () { + this._super.apply(this, arguments); + var name = arguments[0]; + var method = this[name]; + if (method) { + var args = new Array(arguments.length - 1); + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; } + return method.apply(this, args); + } + }, - NamedArgs.empty = function empty() { - return EMPTY_NAMED_ARGS; - }; + has: function (name) { + return _emberRuntime.typeOf(this[name]) === 'function' || this._super(name); + } + }); - NamedArgs.fromSpec = function fromSpec(sexp) { - if (sexp === null || sexp === undefined) { - return EMPTY_NAMED_ARGS; - } - var keys = sexp[0]; - var exprs = sexp[1]; + _emberRuntime.deprecateUnderscoreActions(CoreView); - if (keys.length === 0) { - return EMPTY_NAMED_ARGS; - } - return new this(keys, exprs.map(function (expr) { - return _glimmerRuntimeLibSyntaxExpressions.default(expr); - })); - }; + CoreView.reopenClass({ + isViewFactory: true + }); - NamedArgs.build = function build(keys, values) { - if (keys.length === 0) { - return EMPTY_NAMED_ARGS; - } else { - return new this(keys, values); - } - }; + exports.default = CoreView; +}); +enifed('ember-views/views/states', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-views/views/states/pre_render', 'ember-views/views/states/has_element', 'ember-views/views/states/in_dom', 'ember-views/views/states/destroying'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberViewsViewsStatesPre_render, _emberViewsViewsStatesHas_element, _emberViewsViewsStatesIn_dom, _emberViewsViewsStatesDestroying) { + 'use strict'; - NamedArgs.prototype.at = function at(key) { - var keys = this.keys; - var values = this.values; + exports.cloneStates = cloneStates; - var index = keys.indexOf(key); - return values[index]; - }; + function cloneStates(from) { + var into = {}; - NamedArgs.prototype.has = function has(key) { - return this.keys.indexOf(key) !== -1; - }; + into._default = {}; + into.preRender = Object.create(into._default); + into.destroying = Object.create(into._default); + into.hasElement = Object.create(into._default); + into.inDOM = Object.create(into.hasElement); - NamedArgs.prototype.compile = function compile(compiler, env, symbolTable) { - var keys = this.keys; - var values = this.values; + for (var stateName in from) { + if (!from.hasOwnProperty(stateName)) { + continue; + } + _emberUtils.assign(into[stateName], from[stateName]); + } - return new _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs(keys, values.map(function (value) { - return value.compile(compiler, env, symbolTable); - })); - }; + return into; + } - return NamedArgs; - })(); + /* + Describe how the specified actions should behave in the various + states that a view can exist in. Possible states: + + * preRender: when a view is first instantiated, and after its + element was destroyed, it is in the preRender state + * hasElement: the DOM representation of the view is created, + and is ready to be inserted + * inDOM: once a view has been inserted into the DOM it is in + the inDOM state. A view spends the vast majority of its + existence in this state. + * destroyed: once a view has been destroyed (using the destroy + method), it is in this state. No further actions can be invoked + on a destroyed view. + */ + var states = { + _default: _emberViewsViewsStatesDefault.default, + preRender: _emberViewsViewsStatesPre_render.default, + inDOM: _emberViewsViewsStatesIn_dom.default, + hasElement: _emberViewsViewsStatesHas_element.default, + destroying: _emberViewsViewsStatesDestroying.default + }; + exports.states = states; +}); +enifed('ember-views/views/states/default', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - exports.NamedArgs = NamedArgs; + /** + @module ember + @submodule ember-views + */ + exports.default = { + // appendChild is only legal while rendering the buffer. + appendChild: function () { + throw new _emberMetal.Error('You can\'t use appendChild outside of the rendering process'); + }, - var EMPTY_NAMED_ARGS = new ((function (_NamedArgs) { - babelHelpers.inherits(_class3, _NamedArgs); + // Handle events from `Ember.EventDispatcher` + handleEvent: function () { + return true; // continue event propagation + }, - function _class3() { - _NamedArgs.call(this, _glimmerRuntimeLibUtils.EMPTY_ARRAY, _glimmerRuntimeLibUtils.EMPTY_ARRAY); - } + rerender: function () {}, - _class3.prototype.at = function at(key) { - return undefined; // ??! - }; + destroy: function () {} + }; +}); +enifed('ember-views/views/states/destroying', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/default'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesDefault) { + 'use strict'; - _class3.prototype.has = function has(key) { - return false; - }; + /** + @module ember + @submodule ember-views + */ - _class3.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledNamedArgs.empty(); - }; + var destroying = Object.create(_emberViewsViewsStatesDefault.default); - return _class3; - })(NamedArgs))(); - var EMPTY_ARGS = new ((function (_Args) { - babelHelpers.inherits(_class4, _Args); + _emberUtils.assign(destroying, { + appendChild: function () { + throw new _emberMetal.Error('You can\'t call appendChild on a view being destroyed'); + }, + rerender: function () { + throw new _emberMetal.Error('You can\'t call rerender on a view being destroyed'); + } + }); - function _class4() { - _Args.call(this, EMPTY_POSITIONAL_ARGS, EMPTY_NAMED_ARGS, EMPTY_BLOCKS); - } + exports.default = destroying; +}); +enifed('ember-views/views/states/has_element', ['exports', 'ember-utils', 'ember-views/views/states/default', 'ember-metal'], function (exports, _emberUtils, _emberViewsViewsStatesDefault, _emberMetal) { + 'use strict'; - _class4.prototype.compile = function compile(compiler, env) { - return _glimmerRuntimeLibCompiledExpressionsArgs.CompiledArgs.empty(); - }; + var hasElement = Object.create(_emberViewsViewsStatesDefault.default); - return _class4; - })(Args))(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L2NvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBMEdBLEtBQUE7OEJBQUEsS0FBQTs7QUFxQkUsaUJBckJGLEtBQUEsQ0FzQlcsSUFBYyxFQUNkLElBQVUsRUFBQTtBQUVqQix1Q0FBTyxDQUFDO0FBSEQsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFVO0FBQ2QsZ0JBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFNO0FBdEJaLGdCQUFBLENBQUEsSUFBSSxHQUFHLE9BQU8sQ0FBQztTQXlCckI7O0FBMUJILGFBQUEsQ0FHUyxRQUFRLEdBQUEsa0JBQUMsSUFBZ0MsRUFBRSxXQUF3QixFQUFFLE9BQXFCLEVBQUE7Z0JBQ3hGLElBQUksR0FBeUMsSUFBSTtnQkFBM0MsTUFBTSxHQUF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m9ubWVudCk6IENvbXBpbGVkQXJncyB7XG4gICAgcmV0dXJuIENvbXBpbGVkQXJncy5lbXB0eSgpO1xuICB9XG59KTtcbiJdfQ== -enifed('glimmer-runtime/lib/syntax/expressions', ['exports', 'glimmer-runtime/lib/syntax/core', 'glimmer-wire-format'], function (exports, _glimmerRuntimeLibSyntaxCore, _glimmerWireFormat) { - 'use strict'; + _emberUtils.assign(hasElement, { - var isArg = _glimmerWireFormat.Expressions.isArg; - var isConcat = _glimmerWireFormat.Expressions.isConcat; - var isGet = _glimmerWireFormat.Expressions.isGet; - var isHasBlock = _glimmerWireFormat.Expressions.isHasBlock; - var isHasBlockParams = _glimmerWireFormat.Expressions.isHasBlockParams; - var isHelper = _glimmerWireFormat.Expressions.isHelper; - var isUnknown = _glimmerWireFormat.Expressions.isUnknown; - var isPrimitiveValue = _glimmerWireFormat.Expressions.isPrimitiveValue; - var isUndefined = _glimmerWireFormat.Expressions.isUndefined; - - exports.default = function (sexp) { - if (isPrimitiveValue(sexp)) return _glimmerRuntimeLibSyntaxCore.Value.fromSpec(sexp); - if (isUndefined(sexp)) return _glimmerRuntimeLibSyntaxCore.Value.build(undefined); - if (isArg(sexp)) return _glimmerRuntimeLibSyntaxCore.GetArgument.fromSpec(sexp); - if (isConcat(sexp)) return _glimmerRuntimeLibSyntaxCore.Concat.fromSpec(sexp); - if (isGet(sexp)) return _glimmerRuntimeLibSyntaxCore.Get.fromSpec(sexp); - if (isHelper(sexp)) return _glimmerRuntimeLibSyntaxCore.Helper.fromSpec(sexp); - if (isUnknown(sexp)) return _glimmerRuntimeLibSyntaxCore.Unknown.fromSpec(sexp); - if (isHasBlock(sexp)) return _glimmerRuntimeLibSyntaxCore.HasBlock.fromSpec(sexp); - if (isHasBlockParams(sexp)) return _glimmerRuntimeLibSyntaxCore.HasBlockParams.fromSpec(sexp); - throw new Error('Unexpected wire format: ' + JSON.stringify(sexp)); - }; + rerender: function (view) { + view.renderer.rerender(view); + }, - ; -}); -//# sourceMapp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yb21TcGVjKHNleHApO1xuICBpZiAoaXNIYXNCbG9ja1BhcmFtcyhzZXhwKSkgcmV0dXJuIEhhc0Jsb2NrUGFyYW1zU3ludGF4LmZyb21TcGVjKHNleHApO1xuXG4gIHRocm93IG5ldyBFcnJvcihgVW5leHBlY3RlZCB3aXJlIGZvcm1hdDogJHtKU09OLnN0cmluZ2lmeShzZXhwKX1gKTtcbn07XG4iXX0= -enifed('glimmer-runtime/lib/syntax/statements', ['exports', 'glimmer-runtime/lib/syntax/core', 'glimmer-wire-format'], function (exports, _glimmerRuntimeLibSyntaxCore, _glimmerWireFormat) { - 'use strict'; + destroy: function (view) { + view.renderer.remove(view); + }, - var isYield = _glimmerWireFormat.Statements.isYield; - var isBlock = _glimmerWireFormat.Statements.isBlock; - var isPartial = _glimmerWireFormat.Statements.isPartial; - var isAppend = _glimmerWireFormat.Statements.isAppend; - var isDynamicAttr = _glimmerWireFormat.Statements.isDynamicAttr; - var isText = _glimmerWireFormat.Statements.isText; - var isComment = _glimmerWireFormat.Statements.isComment; - var isOpenElement = _glimmerWireFormat.Statements.isOpenElement; - var isFlushElement = _glimmerWireFormat.Statements.isFlushElement; - var isCloseElement = _glimmerWireFormat.Statements.isCloseElement; - var isStaticAttr = _glimmerWireFormat.Statements.isStaticAttr; - var isModifier = _glimmerWireFormat.Statements.isModifier; - var isDynamicArg = _glimmerWireFormat.Statements.isDynamicArg; - var isStaticArg = _glimmerWireFormat.Statements.isStaticArg; - var isTrustingAttr = _glimmerWireFormat.Statements.isTrustingAttr; - - exports.default = function (sexp, symbolTable, scanner) { - if (isYield(sexp)) return _glimmerRuntimeLibSyntaxCore.Yield.fromSpec(sexp); - if (isPartial(sexp)) return _glimmerRuntimeLibSyntaxCore.Partial.fromSpec(sexp); - if (isBlock(sexp)) return _glimmerRuntimeLibSyntaxCore.Block.fromSpec(sexp, symbolTable, scanner); - if (isAppend(sexp)) return _glimmerRuntimeLibSyntaxCore.OptimizedAppend.fromSpec(sexp); - if (isDynamicAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.DynamicAttr.fromSpec(sexp); - if (isDynamicArg(sexp)) return _glimmerRuntimeLibSyntaxCore.DynamicArg.fromSpec(sexp); - if (isTrustingAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.TrustingAttr.fromSpec(sexp); - if (isText(sexp)) return _glimmerRuntimeLibSyntaxCore.Text.fromSpec(sexp); - if (isComment(sexp)) return _glimmerRuntimeLibSyntaxCore.Comment.fromSpec(sexp); - if (isOpenElement(sexp)) return _glimmerRuntimeLibSyntaxCore.OpenElement.fromSpec(sexp, symbolTable); - if (isFlushElement(sexp)) return _glimmerRuntimeLibSyntaxCore.FlushElement.fromSpec(); - if (isCloseElement(sexp)) return _glimmerRuntimeLibSyntaxCore.CloseElement.fromSpec(); - if (isStaticAttr(sexp)) return _glimmerRuntimeLibSyntaxCore.StaticAttr.fromSpec(sexp); - if (isStaticArg(sexp)) return _glimmerRuntimeLibSyntaxCore.StaticArg.fromSpec(sexp); - if (isModifier(sexp)) return _glimmerRuntimeLibSyntaxCore.Modifier.fromSpec(sexp); - }; + // Handle events from `Ember.EventDispatcher` + handleEvent: function (view, eventName, event) { + if (view.has(eventName)) { + // Handler should be able to re-dispatch events, so we don't + // preventDefault or stopPropagation. + return _emberMetal.flaggedInstrument('interaction.' + eventName, { event: event, view: view }, function () { + return _emberMetal.run.join(view, view.trigger, eventName, event); + }); + } else { + return true; // continue event propagation + } + } + }); - ; + exports.default = hasElement; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvc3ludGF4L3N0YXRlbWVudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBMkJFLE9BQU8sc0JBTlAsVUFBVSxDQU1WLE9BQU87UUFDUCxPQUFPLHNCQVBQLFVBQVUsQ0FPVixPQUFPO1FBQ1AsU0FBUyxzQkFSVCxVQUFVLENBUVYsU0FBUztRQ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XhwKSkgcmV0dXJuIENvbW1lbnQuZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc09wZW5FbGVtZW50KHNleHApKSByZXR1cm4gT3BlbkVsZW1lbnQuZnJvbVNwZWMoc2V4cCwgc3ltYm9sVGFibGUpO1xuICBpZiAoaXNGbHVzaEVsZW1lbnQoc2V4cCkpIHJldHVybiBGbHVzaEVsZW1lbnQuZnJvbVNwZWMoKTtcbiAgaWYgKGlzQ2xvc2VFbGVtZW50KHNleHApKSByZXR1cm4gQ2xvc2VFbGVtZW50LmZyb21TcGVjKCk7XG4gIGlmIChpc1N0YXRpY0F0dHIoc2V4cCkpIHJldHVybiBTdGF0aWNBdHRyLmZyb21TcGVjKHNleHApO1xuICBpZiAoaXNTdGF0aWNBcmcoc2V4cCkpIHJldHVybiBTdGF0aWNBcmcuZnJvbVNwZWMoc2V4cCk7XG4gIGlmIChpc01vZGlmaWVyKHNleHApKSByZXR1cm4gTW9kaWZpZXIuZnJvbVNwZWMoc2V4cCk7XG59O1xuIl19 -enifed('glimmer-runtime/lib/template', ['exports', 'glimmer-util', 'glimmer-runtime/lib/builder', 'glimmer-runtime/lib/vm', 'glimmer-runtime/lib/scanner'], function (exports, _glimmerUtil, _glimmerRuntimeLibBuilder, _glimmerRuntimeLibVm, _glimmerRuntimeLibScanner) { - 'use strict'; +enifed('ember-views/views/states/in_dom', ['exports', 'ember-utils', 'ember-metal', 'ember-views/views/states/has_element'], function (exports, _emberUtils, _emberMetal, _emberViewsViewsStatesHas_element) { + 'use strict'; - exports.default = templateFactory; + /** + @module ember + @submodule ember-views + */ - var clientId = 0; + var inDOM = Object.create(_emberViewsViewsStatesHas_element.default); - function templateFactory(_ref) { - var id = _ref.id; - var meta = _ref.meta; - var block = _ref.block; + _emberUtils.assign(inDOM, { + enter: function (view) { + // Register the view for event handling. This hash is used by + // Ember.EventDispatcher to dispatch incoming events. + view.renderer.register(view); + }, - var parsedBlock = undefined; - if (!id) { - id = 'client-' + clientId++; - } - var create = function (env, envMeta) { - var newMeta = envMeta ? _glimmerUtil.assign({}, envMeta, meta) : meta; - if (!parsedBlock) { - parsedBlock = JSON.parse(block); - } - return template(parsedBlock, id, newMeta, env); - }; - return { id: id, meta: meta, create: create }; + exit: function (view) { + view.renderer.unregister(view); } + }); - function template(block, id, meta, env) { - var scanner = new _glimmerRuntimeLibScanner.default(block, meta, env); - var entryPoint = undefined; - var asEntryPoint = function () { - if (!entryPoint) entryPoint = scanner.scanEntryPoint(); - return entryPoint; - }; - var layout = undefined; - var asLayout = function () { - if (!layout) layout = scanner.scanLayout(); - return layout; - }; - var asPartial = function (symbols) { - return scanner.scanPartial(symbols); - }; - var render = function (self, appendTo, dynamicScope) { - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.forInitialRender(env, appendTo, null); - var compiled = asEntryPoint().compile(env); - var vm = _glimmerRuntimeLibVm.VM.initial(env, self, dynamicScope, elementStack, compiled.symbols); - return vm.execute(compiled.ops); - }; - return { id: id, meta: meta, _block: block, asEntryPoint: asEntryPoint, asLayout: asLayout, asPartial: asPartial, render: render }; - } + exports.default = inDOM; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdGVtcGxhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O3NCQWtGQSxlQUFBOztBQVRBLFFBQUksUUFBUSxHQUFHLENBQUMsQ0FBQzs7QUFTakIsYUFBQSxlQUFBLENBQXdDLElBQXlELEVBQUE7WUFBdkQsRUFBRSxHQUFKLElBQXlELENBQXZELEVBQUU7WUFBRSxJQUFJLEdBQVYsSUFBeUQsQ0FBbkQsSUFBSTtZQUFFLEtBQUssR0FBakIsSUFBeUQsQ0FBN0MsS0FBSzs7QUFDdkQsWUFBSSxXQUFvQyxZQUFBLENBQUM7QUFDekMsWUFBSSxDQUFDLEVBQUUsRUFBRTtBQUNQLGNBQUUsZUFBYSxRQUFRLEVBQUcsQ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XIuc2NhbkxheW91dCgpO1xuICAgIHJldHVybiBsYXlvdXQ7XG4gIH07XG4gIGxldCBhc1BhcnRpYWwgPSBzeW1ib2xzID0+IHNjYW5uZXIuc2NhblBhcnRpYWwoc3ltYm9scyk7XG4gIGxldCByZW5kZXIgPSAoc2VsZjogUGF0aFJlZmVyZW5jZTxhbnk+LCBhcHBlbmRUbzogU2ltcGxlLkVsZW1lbnQsIGR5bmFtaWNTY29wZTogRHluYW1pY1Njb3BlKSA9PiB7XG4gICAgbGV0IGVsZW1lbnRTdGFjayA9IEVsZW1lbnRTdGFjay5mb3JJbml0aWFsUmVuZGVyKGVudiwgYXBwZW5kVG8sIG51bGwpO1xuICAgIGxldCBjb21waWxlZCA9IGFzRW50cnlQb2ludCgpLmNvbXBpbGUoZW52KTtcbiAgICBsZXQgdm0gPSBWTS5pbml0aWFsKGVudiwgc2VsZiwgZHluYW1pY1Njb3BlLCBlbGVtZW50U3RhY2ssIGNvbXBpbGVkLnN5bWJvbHMpO1xuICAgIHJldHVybiB2bS5leGVjdXRlKGNvbXBpbGVkLm9wcyk7XG4gIH07XG4gIHJldHVybiB7IGlkLCBtZXRhLCBfYmxvY2s6IGJsb2NrLCBhc0VudHJ5UG9pbnQsIGFzTGF5b3V0LCBhc1BhcnRpYWwsIHJlbmRlciB9O1xufVxuIl19 -enifed('glimmer-runtime/lib/upsert', ['exports', 'glimmer-runtime/lib/bounds'], function (exports, _glimmerRuntimeLibBounds) { - 'use strict'; +enifed('ember-views/views/states/pre_render', ['exports', 'ember-views/views/states/default'], function (exports, _emberViewsViewsStatesDefault) { + 'use strict'; - exports.isSafeString = isSafeString; - exports.isNode = isNode; - exports.isString = isString; - exports.cautiousInsert = cautiousInsert; - exports.trustingInsert = trustingInsert; + /** + @module ember + @submodule ember-views + */ - function isSafeString(value) { - return value && typeof value['toHTML'] === 'function'; - } + exports.default = Object.create(_emberViewsViewsStatesDefault.default); +}); +enifed("ember-views/views/view", ["exports"], function (exports) { + "use strict"; +}); +/** +@module ember +@submodule ember-views +*/ - function isNode(value) { - return value !== null && typeof value === 'object' && typeof value['nodeType'] === 'number'; - } +/** + @class View + @namespace Ember + @extends Ember.CoreView + @deprecated See http://emberjs.com/deprecations/v1.x/#toc_ember-view + @uses Ember.ViewSupport + @uses Ember.ChildViewsSupport + @uses Ember.ClassNamesSupport + @uses Ember.AttributeBindingsSupport + @private +*/ +enifed("ember/features", ["exports"], function (exports) { + "use strict"; - function isString(value) { - return typeof value === 'string'; - } + exports.default = { "features-stripped-test": null, "ember-libraries-isregistered": null, "ember-improved-instrumentation": null, "ember-metal-weakmap": null, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": null, "ember-factory-for": true, "ember-no-double-extend": null, "ember-routing-router-service": null, "ember-unique-location-history-state": null, "mandatory-setter": false, "ember-glimmer-detect-backtracking-rerender": false }; +}); +enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { + 'use strict'; - var Upsert = function Upsert(bounds) { - this.bounds = bounds; - }; + // ember-utils exports + _emberMetal.default.getOwner = _emberUtils.getOwner; + _emberMetal.default.setOwner = _emberUtils.setOwner; + _emberMetal.default.generateGuid = _emberUtils.generateGuid; + _emberMetal.default.GUID_KEY = _emberUtils.GUID_KEY; + _emberMetal.default.guidFor = _emberUtils.guidFor; + _emberMetal.default.inspect = _emberUtils.inspect; + _emberMetal.default.makeArray = _emberUtils.makeArray; + _emberMetal.default.canInvoke = _emberUtils.canInvoke; + _emberMetal.default.tryInvoke = _emberUtils.tryInvoke; + _emberMetal.default.wrap = _emberUtils.wrap; + _emberMetal.default.applyStr = _emberUtils.applyStr; + _emberMetal.default.uuid = _emberUtils.uuid; + _emberMetal.default.assign = Object.assign || _emberUtils.assign; - exports.default = Upsert; + // container exports + _emberMetal.default.Container = _container.Container; + _emberMetal.default.Registry = _container.Registry; - function cautiousInsert(dom, cursor, value) { - if (isString(value)) { - return TextUpsert.insert(dom, cursor, value); - } - if (isSafeString(value)) { - return SafeStringUpsert.insert(dom, cursor, value); - } - if (isNode(value)) { - return NodeUpsert.insert(dom, cursor, value); - } - } + // need to import this directly, to ensure the babel feature + // flag plugin works properly - function trustingInsert(dom, cursor, value) { - if (isString(value)) { - return HTMLUpsert.insert(dom, cursor, value); - } - if (isNode(value)) { - return NodeUpsert.insert(dom, cursor, value); - } - } + var computed = _emberMetal.computed; + computed.alias = _emberMetal.alias; + _emberMetal.default.computed = computed; + _emberMetal.default.ComputedProperty = _emberMetal.ComputedProperty; + _emberMetal.default.cacheFor = _emberMetal.cacheFor; - var TextUpsert = (function (_Upsert) { - babelHelpers.inherits(TextUpsert, _Upsert); + _emberMetal.default.assert = _emberMetal.assert; + _emberMetal.default.warn = _emberMetal.warn; + _emberMetal.default.debug = _emberMetal.debug; + _emberMetal.default.deprecate = _emberMetal.deprecate; + _emberMetal.default.deprecateFunc = _emberMetal.deprecateFunc; + _emberMetal.default.runInDebug = _emberMetal.runInDebug; + _emberMetal.default.merge = _emberMetal.merge; - function TextUpsert(bounds, textNode) { - _Upsert.call(this, bounds); - this.textNode = textNode; - } + _emberMetal.default.instrument = _emberMetal.instrument; + _emberMetal.default.subscribe = _emberMetal.instrumentationSubscribe; + _emberMetal.default.Instrumentation = { + instrument: _emberMetal.instrument, + subscribe: _emberMetal.instrumentationSubscribe, + unsubscribe: _emberMetal.instrumentationUnsubscribe, + reset: _emberMetal.instrumentationReset + }; - TextUpsert.insert = function insert(dom, cursor, value) { - var textNode = dom.createTextNode(value); - dom.insertBefore(cursor.element, textNode, cursor.nextSibling); - var bounds = new _glimmerRuntimeLibBounds.SingleNodeBounds(cursor.element, textNode); - return new TextUpsert(bounds, textNode); - }; + _emberMetal.default.Error = _emberMetal.Error; + _emberMetal.default.META_DESC = _emberMetal.META_DESC; + _emberMetal.default.meta = _emberMetal.meta; + _emberMetal.default.get = _emberMetal.get; + _emberMetal.default.getWithDefault = _emberMetal.getWithDefault; + _emberMetal.default._getPath = _emberMetal._getPath; + _emberMetal.default.set = _emberMetal.set; + _emberMetal.default.trySet = _emberMetal.trySet; + _emberMetal.default.FEATURES = _emberMetal.FEATURES; + _emberMetal.default.FEATURES.isEnabled = _emberMetal.isFeatureEnabled; + _emberMetal.default._Cache = _emberMetal.Cache; + _emberMetal.default.on = _emberMetal.on; + _emberMetal.default.addListener = _emberMetal.addListener; + _emberMetal.default.removeListener = _emberMetal.removeListener; + _emberMetal.default._suspendListener = _emberMetal.suspendListener; + _emberMetal.default._suspendListeners = _emberMetal.suspendListeners; + _emberMetal.default.sendEvent = _emberMetal.sendEvent; + _emberMetal.default.hasListeners = _emberMetal.hasListeners; + _emberMetal.default.watchedEvents = _emberMetal.watchedEvents; + _emberMetal.default.listenersFor = _emberMetal.listenersFor; + _emberMetal.default.accumulateListeners = _emberMetal.accumulateListeners; + _emberMetal.default.isNone = _emberMetal.isNone; + _emberMetal.default.isEmpty = _emberMetal.isEmpty; + _emberMetal.default.isBlank = _emberMetal.isBlank; + _emberMetal.default.isPresent = _emberMetal.isPresent; + _emberMetal.default.run = _emberMetal.run; + _emberMetal.default._ObserverSet = _emberMetal.ObserverSet; + _emberMetal.default.propertyWillChange = _emberMetal.propertyWillChange; + _emberMetal.default.propertyDidChange = _emberMetal.propertyDidChange; + _emberMetal.default.overrideChains = _emberMetal.overrideChains; + _emberMetal.default.beginPropertyChanges = _emberMetal.beginPropertyChanges; + _emberMetal.default.endPropertyChanges = _emberMetal.endPropertyChanges; + _emberMetal.default.changeProperties = _emberMetal.changeProperties; + _emberMetal.default.platform = { + defineProperty: true, + hasPropertyAccessors: true + }; + _emberMetal.default.defineProperty = _emberMetal.defineProperty; + _emberMetal.default.watchKey = _emberMetal.watchKey; + _emberMetal.default.unwatchKey = _emberMetal.unwatchKey; + _emberMetal.default.removeChainWatcher = _emberMetal.removeChainWatcher; + _emberMetal.default._ChainNode = _emberMetal.ChainNode; + _emberMetal.default.finishChains = _emberMetal.finishChains; + _emberMetal.default.watchPath = _emberMetal.watchPath; + _emberMetal.default.unwatchPath = _emberMetal.unwatchPath; + _emberMetal.default.watch = _emberMetal.watch; + _emberMetal.default.isWatching = _emberMetal.isWatching; + _emberMetal.default.unwatch = _emberMetal.unwatch; + _emberMetal.default.destroy = _emberMetal.destroy; + _emberMetal.default.libraries = _emberMetal.libraries; + _emberMetal.default.OrderedSet = _emberMetal.OrderedSet; + _emberMetal.default.Map = _emberMetal.Map; + _emberMetal.default.MapWithDefault = _emberMetal.MapWithDefault; + _emberMetal.default.getProperties = _emberMetal.getProperties; + _emberMetal.default.setProperties = _emberMetal.setProperties; + _emberMetal.default.expandProperties = _emberMetal.expandProperties; + _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; + _emberMetal.default.addObserver = _emberMetal.addObserver; + _emberMetal.default.observersFor = _emberMetal.observersFor; + _emberMetal.default.removeObserver = _emberMetal.removeObserver; + _emberMetal.default._suspendObserver = _emberMetal._suspendObserver; + _emberMetal.default._suspendObservers = _emberMetal._suspendObservers; + _emberMetal.default.required = _emberMetal.required; + _emberMetal.default.aliasMethod = _emberMetal.aliasMethod; + _emberMetal.default.observer = _emberMetal.observer; + _emberMetal.default.immediateObserver = _emberMetal._immediateObserver; + _emberMetal.default.mixin = _emberMetal.mixin; + _emberMetal.default.Mixin = _emberMetal.Mixin; + _emberMetal.default.bind = _emberMetal.bind; + _emberMetal.default.Binding = _emberMetal.Binding; + _emberMetal.default.isGlobalPath = _emberMetal.isGlobalPath; - TextUpsert.prototype.update = function update(dom, value) { - if (isString(value)) { - var textNode = this.textNode; + if (_emberMetal.isFeatureEnabled('ember-metal-weakmap')) { + _emberMetal.default.WeakMap = _emberMetal.WeakMap; + } - textNode.nodeValue = value; - return true; - } else { - return false; - } - }; + Object.defineProperty(_emberMetal.default, 'ENV', { + get: function () { + return _emberEnvironment.ENV; + }, + enumerable: false + }); - return TextUpsert; - })(Upsert); + /** + The context that Ember searches for namespace instances on. + + @private + */ + Object.defineProperty(_emberMetal.default, 'lookup', { + get: function () { + return _emberEnvironment.context.lookup; + }, + set: function (value) { + _emberEnvironment.context.lookup = value; + }, + enumerable: false + }); - var HTMLUpsert = (function (_Upsert2) { - babelHelpers.inherits(HTMLUpsert, _Upsert2); + _emberMetal.default.EXTEND_PROTOTYPES = _emberEnvironment.ENV.EXTEND_PROTOTYPES; - function HTMLUpsert() { - _Upsert2.apply(this, arguments); - } + // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS + Object.defineProperty(_emberMetal.default, 'LOG_STACKTRACE_ON_DEPRECATION', { + get: function () { + return _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; + }, + enumerable: false + }); - HTMLUpsert.insert = function insert(dom, cursor, value) { - var bounds = dom.insertHTMLBefore(cursor.element, value, cursor.nextSibling); - return new HTMLUpsert(bounds); - }; + Object.defineProperty(_emberMetal.default, 'LOG_VERSION', { + get: function () { + return _emberEnvironment.ENV.LOG_VERSION; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_VERSION = !!value; + }, + enumerable: false + }); - HTMLUpsert.prototype.update = function update(dom, value) { - if (isString(value)) { - var bounds = this.bounds; + Object.defineProperty(_emberMetal.default, 'MODEL_FACTORY_INJECTIONS', { + get: function () { + return _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS; + }, + set: function (value) { + _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = !!value; + }, + enumerable: false + }); - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertHTMLBefore(parentElement, nextSibling, value); - return true; - } else { - return false; - } - }; + Object.defineProperty(_emberMetal.default, 'LOG_BINDINGS', { + get: function () { + return _emberEnvironment.ENV.LOG_BINDINGS; + }, + set: function (value) { + _emberEnvironment.ENV.LOG_BINDINGS = !!value; + }, + enumerable: false + }); - return HTMLUpsert; - })(Upsert); + /** + A function may be assigned to `Ember.onerror` to be called when Ember + internals encounter an error. This is useful for specialized error handling + and reporting code. + + ```javascript + Ember.onerror = function(error) { + Em.$.ajax('/report-error', 'POST', { + stack: error.stack, + otherInformation: 'whatever app state you want to provide' + }); + }; + ``` + + Internally, `Ember.onerror` is used as Backburner's error handler. + + @event onerror + @for Ember + @param {Exception} error the error object + @public + */ + Object.defineProperty(_emberMetal.default, 'onerror', { + get: _emberMetal.getOnerror, + set: _emberMetal.setOnerror, + enumerable: false + }); - var SafeStringUpsert = (function (_Upsert3) { - babelHelpers.inherits(SafeStringUpsert, _Upsert3); + /** + An empty function useful for some operations. Always returns `this`. + + @method K + @return {Object} + @public + */ + function deprecatedEmberK() { + return this; + } - function SafeStringUpsert(bounds, lastStringValue) { - _Upsert3.call(this, bounds); - this.lastStringValue = lastStringValue; - } + Object.defineProperty(_emberMetal.default, 'K', { + get: function () { - SafeStringUpsert.insert = function insert(dom, cursor, value) { - var stringValue = value.toHTML(); - var bounds = dom.insertHTMLBefore(cursor.element, stringValue, cursor.nextSibling); - return new SafeStringUpsert(bounds, stringValue); - }; + return deprecatedEmberK; + } + }); - SafeStringUpsert.prototype.update = function update(dom, value) { - if (isSafeString(value)) { - var stringValue = value.toHTML(); - if (stringValue !== this.lastStringValue) { - var bounds = this.bounds; + Object.defineProperty(_emberMetal.default, 'testing', { + get: _emberMetal.isTesting, + set: _emberMetal.setTesting, + enumerable: false + }); - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertHTMLBefore(parentElement, nextSibling, stringValue); - this.lastStringValue = stringValue; - } - return true; - } else { - return false; - } - }; + if (!_require.has('ember-debug')) { + _emberMetal.default.Debug = { + registerDeprecationHandler: function () {}, + registerWarnHandler: function () {} + }; + } - return SafeStringUpsert; - })(Upsert); + /** + @class Backburner + @for Ember + @private + */ + _emberMetal.default.Backburner = function () { - var NodeUpsert = (function (_Upsert4) { - babelHelpers.inherits(NodeUpsert, _Upsert4); + function BackburnerAlias(args) { + return _backburner.default.apply(this, args); + } - function NodeUpsert() { - _Upsert4.apply(this, arguments); - } + BackburnerAlias.prototype = _backburner.default.prototype; - NodeUpsert.insert = function insert(dom, cursor, node) { - dom.insertBefore(cursor.element, node, cursor.nextSibling); - return new NodeUpsert(_glimmerRuntimeLibBounds.single(cursor.element, node)); - }; + return new BackburnerAlias(arguments); + }; - NodeUpsert.prototype.update = function update(dom, value) { - if (isNode(value)) { - var bounds = this.bounds; + _emberMetal.default._Backburner = _backburner.default; - var parentElement = bounds.parentElement(); - var nextSibling = _glimmerRuntimeLibBounds.clear(bounds); - this.bounds = dom.insertNodeBefore(parentElement, value, nextSibling); - return true; - } else { - return false; - } - }; + _emberMetal.default.Logger = _emberConsole.default; - return NodeUpsert; - })(Upsert); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdXBzZXJ0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQVVBLGFBQUEsWUFBQSxDQUE2QixLQUFhLEVBQUE7QUFDeEMsZUFBTyxLQUFLLElBQUksT0FBTyxLQUFLLENBQUMsUUFBUSxDQUFDLEtBQUssVUFBVSxDQUFDO0tBQ3ZEOztBQUVELGFBQUEsTUFBQSxDQUF1QixLQUFhLEVBQUE7QUFDbEMsZUFBTyxLQUFLLEtBQUssSUFBSSxJQUFJLE9BQU8sS0FBSyxLQUFLLFFBQVEsSUFBSSxPQUFPLEtBQUssQ0FBQyxVQUFVLENBQUMsS0FBSyxRQUFRLENBQUM7S0FDN0Y7O0FBRUQsYUFBQSxRQUFBLENBQXlCLEtBQWEs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MgTm9kZVVwc2VydCBleHRlbmRzIFVwc2VydCB7XG4gIHN0YXRpYyBpbnNlcnQoZG9tOiBET01UcmVlQ29uc3RydWN0aW9uLCBjdXJzb3I6IEN1cnNvciwgbm9kZTogU2ltcGxlLk5vZGUpOiBVcHNlcnQge1xuICAgIGRvbS5pbnNlcnRCZWZvcmUoY3Vyc29yLmVsZW1lbnQsIG5vZGUsIGN1cnNvci5uZXh0U2libGluZyk7XG4gICAgcmV0dXJuIG5ldyBOb2RlVXBzZXJ0KHNpbmdsZShjdXJzb3IuZWxlbWVudCwgbm9kZSkpO1xuICB9XG5cbiAgdXBkYXRlKGRvbTogRE9NQ2hhbmdlcywgdmFsdWU6IEluc2VydGlvbik6IGJvb2xlYW4ge1xuICAgIGlmIChpc05vZGUodmFsdWUpKSB7XG4gICAgICBsZXQgeyBib3VuZHMgfSA9IHRoaXM7XG5cbiAgICAgIGxldCBwYXJlbnRFbGVtZW50ID0gYm91bmRzLnBhcmVudEVsZW1lbnQoKTtcbiAgICAgIGxldCBuZXh0U2libGluZyA9IGNsZWFyKGJvdW5kcyk7XG5cbiAgICAgIHRoaXMuYm91bmRzID0gZG9tLmluc2VydE5vZGVCZWZvcmUocGFyZW50RWxlbWVudCBhcyBGSVhfUkVJRklDQVRJT048RWxlbWVudD4sIHZhbHVlLCBuZXh0U2libGluZyBhcyBGSVhfUkVJRklDQVRJT048Tm9kZT4pO1xuXG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9IGVsc2Uge1xuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/utils', ['exports', 'glimmer-util'], function (exports, _glimmerUtil) { - 'use strict'; + // ****ember-runtime**** - var EMPTY_ARRAY = Object.freeze([]); - exports.EMPTY_ARRAY = EMPTY_ARRAY; - var EMPTY_DICT = Object.freeze(_glimmerUtil.dict()); - exports.EMPTY_DICT = EMPTY_DICT; + _emberMetal.default.String = _emberRuntime.String; + _emberMetal.default.Object = _emberRuntime.Object; + _emberMetal.default._RegistryProxyMixin = _emberRuntime.RegistryProxyMixin; + _emberMetal.default._ContainerProxyMixin = _emberRuntime.ContainerProxyMixin; + _emberMetal.default.compare = _emberRuntime.compare; + _emberMetal.default.copy = _emberRuntime.copy; + _emberMetal.default.isEqual = _emberRuntime.isEqual; + _emberMetal.default.inject = _emberRuntime.inject; + _emberMetal.default.Array = _emberRuntime.Array; + _emberMetal.default.Comparable = _emberRuntime.Comparable; + _emberMetal.default.Enumerable = _emberRuntime.Enumerable; + _emberMetal.default.ArrayProxy = _emberRuntime.ArrayProxy; + _emberMetal.default.ObjectProxy = _emberRuntime.ObjectProxy; + _emberMetal.default.ActionHandler = _emberRuntime.ActionHandler; + _emberMetal.default.CoreObject = _emberRuntime.CoreObject; + _emberMetal.default.NativeArray = _emberRuntime.NativeArray; + _emberMetal.default.Copyable = _emberRuntime.Copyable; + _emberMetal.default.Freezable = _emberRuntime.Freezable; + _emberMetal.default.FROZEN_ERROR = _emberRuntime.FROZEN_ERROR; + _emberMetal.default.MutableEnumerable = _emberRuntime.MutableEnumerable; + _emberMetal.default.MutableArray = _emberRuntime.MutableArray; + _emberMetal.default.TargetActionSupport = _emberRuntime.TargetActionSupport; + _emberMetal.default.Evented = _emberRuntime.Evented; + _emberMetal.default.PromiseProxyMixin = _emberRuntime.PromiseProxyMixin; + _emberMetal.default.Observable = _emberRuntime.Observable; + _emberMetal.default.typeOf = _emberRuntime.typeOf; + _emberMetal.default.isArray = _emberRuntime.isArray; + _emberMetal.default.Object = _emberRuntime.Object; + _emberMetal.default.onLoad = _emberRuntime.onLoad; + _emberMetal.default.runLoadHooks = _emberRuntime.runLoadHooks; + _emberMetal.default.Controller = _emberRuntime.Controller; + _emberMetal.default.ControllerMixin = _emberRuntime.ControllerMixin; + _emberMetal.default.Service = _emberRuntime.Service; + _emberMetal.default._ProxyMixin = _emberRuntime._ProxyMixin; + _emberMetal.default.RSVP = _emberRuntime.RSVP; + _emberMetal.default.Namespace = _emberRuntime.Namespace; - var ListRange = (function () { - function ListRange(list, start, end) { - this.list = list; - this.start = start; - this.end = end; - } + // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed + computed.empty = _emberRuntime.empty; + computed.notEmpty = _emberRuntime.notEmpty; + computed.none = _emberRuntime.none; + computed.not = _emberRuntime.not; + computed.bool = _emberRuntime.bool; + computed.match = _emberRuntime.match; + computed.equal = _emberRuntime.equal; + computed.gt = _emberRuntime.gt; + computed.gte = _emberRuntime.gte; + computed.lt = _emberRuntime.lt; + computed.lte = _emberRuntime.lte; + computed.oneWay = _emberRuntime.oneWay; + computed.reads = _emberRuntime.oneWay; + computed.readOnly = _emberRuntime.readOnly; + computed.deprecatingAlias = _emberRuntime.deprecatingAlias; + computed.and = _emberRuntime.and; + computed.or = _emberRuntime.or; + computed.any = _emberRuntime.any; - ListRange.prototype.at = function at(index) { - if (index >= this.list.length) return null; - return this.list[index]; - }; + computed.sum = _emberRuntime.sum; + computed.min = _emberRuntime.min; + computed.max = _emberRuntime.max; + computed.map = _emberRuntime.map; + computed.sort = _emberRuntime.sort; + computed.setDiff = _emberRuntime.setDiff; + computed.mapBy = _emberRuntime.mapBy; + computed.filter = _emberRuntime.filter; + computed.filterBy = _emberRuntime.filterBy; + computed.uniq = _emberRuntime.uniq; - ListRange.prototype.min = function min() { - return this.start; - }; + computed.uniqBy = _emberRuntime.uniqBy; + computed.union = _emberRuntime.union; + computed.intersect = _emberRuntime.intersect; + computed.collect = _emberRuntime.collect; - ListRange.prototype.max = function max() { - return this.end; - }; + /** + Defines the hash of localized strings for the current language. Used by + the `Ember.String.loc()` helper. To localize, add string values to this + hash. + + @property STRINGS + @for Ember + @type Object + @private + */ + Object.defineProperty(_emberMetal.default, 'STRINGS', { + configurable: false, + get: _emberRuntime.getStrings, + set: _emberRuntime.setStrings + }); - return ListRange; - })(); + /** + Whether searching on the global for new Namespace instances is enabled. + + This is only exported here as to not break any addons. Given the new + visit API, you will have issues if you treat this as a indicator of + booted. + + Internally this is only exposing a flag in Namespace. + + @property BOOTED + @for Ember + @type Boolean + @private + */ + Object.defineProperty(_emberMetal.default, 'BOOTED', { + configurable: false, + enumerable: false, + get: _emberRuntime.isNamespaceSearchDisabled, + set: _emberRuntime.setNamespaceSearchDisabled + }); - exports.ListRange = ListRange; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRU8sUUFBTSxXQUFXLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQzs7QUFDdEMsUUFBTSxVQUFVLEdBQWMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxhQUhwQyxJQUFJLEVBRzJDLENBQUMsQ0FBQzs7O1FBb0JoRSxTQUFBO0FBT0UsaUJBUEYsU0FBQSxDQU9jLElBQVMsRUFBRSxLQUFhLEVBQUUsR0FBVyxFQUFBO0FBQy9DLGdCQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztBQUNqQixnQkFBSSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUM7QUFDbkIsZ0JBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO1NBQ2hCOztBQVhILGlCQUFBLFdBYUUsRUFBRSxHQUFBLFlBQUMsS0FBYSxFQUFBO0FBQ2QsZ0JBQUksS0FBSyxJQUFJLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLE9BQU8sSUFBSSxDQUFDO0FBQzNDLG1CQUFPLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUM7U0FDekI7O0FBaEJILGlCQUFBLFdBa0JFLEdBQUcsR0FBQSxlQUFBO0FBQ0QsbUJBQU8sSUFBSSxDQUFDLEtBQUssQ0FBQztTQUNuQjs7QUFwQkgsaUJBQUEsV0FzQkUsR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biAgICB0aGlzLmVuZCA9IGVuZDtcbiAgfVxuXG4gIGF0KGluZGV4OiBudW1iZXIpOiBUIHtcbiAgICBpZiAoaW5kZXggPj0gdGhpcy5saXN0Lmxlbmd0aCkgcmV0dXJuIG51bGw7XG4gICAgcmV0dXJuIHRoaXMubGlzdFtpbmRleF07XG4gIH1cblxuICBtaW4oKTogbnVtYmVyIHtcbiAgICByZXR1cm4gdGhpcy5zdGFydDtcbiAgfVxuXG4gIG1heCgpOiBudW1iZXIge1xuICAgIHJldHVybiB0aGlzLmVuZDtcbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/vm', ['exports', 'glimmer-runtime/lib/vm/append', 'glimmer-runtime/lib/vm/update', 'glimmer-runtime/lib/vm/render-result'], function (exports, _glimmerRuntimeLibVmAppend, _glimmerRuntimeLibVmUpdate, _glimmerRuntimeLibVmRenderResult) { - 'use strict'; + _emberMetal.default.Component = _emberGlimmer.Component; + _emberGlimmer.Helper.helper = _emberGlimmer.helper; + _emberMetal.default.Helper = _emberGlimmer.Helper; + _emberMetal.default.Checkbox = _emberGlimmer.Checkbox; + _emberMetal.default.TextField = _emberGlimmer.TextField; + _emberMetal.default.TextArea = _emberGlimmer.TextArea; + _emberMetal.default.LinkComponent = _emberGlimmer.LinkComponent; - exports.VM = _glimmerRuntimeLibVmAppend.default; - exports.PublicVM = _glimmerRuntimeLibVmAppend.PublicVM; - exports.UpdatingVM = _glimmerRuntimeLibVmUpdate.default; - exports.RenderResult = _glimmerRuntimeLibVmRenderResult.default; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1VBQW9CLEVBQUUsOEJBQWIsT0FBTztVQUFRLFFBQVEsOEJBQVIsUUFBUTtVQUNaLFVBQVUsOEJBQXJCLE9BQU87VUFDSSxZQUFZLG9DQUF2QixPQUFPIiwiZmlsZSI6InZtLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBWTSwgUHVibGljVk0gfSBmcm9tICcuL3ZtL2FwcGVuZCc7XG5leHBvcnQgeyBkZWZhdWx0IGFzIFVwZGF0aW5nVk0gfSBmcm9tICcuL3ZtL3VwZGF0ZSc7XG5leHBvcnQgeyBkZWZhdWx0IGFzIFJlbmRlclJlc3VsdCB9IGZyb20gJy4vdm0vcmVuZGVyLXJlc3VsdCc7XG4iXX0= -enifed('glimmer-runtime/lib/vm/append', ['exports', 'glimmer-runtime/lib/environment', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/compiled/opcodes/vm', 'glimmer-runtime/lib/vm/update', 'glimmer-runtime/lib/vm/render-result', 'glimmer-runtime/lib/vm/frame'], function (exports, _glimmerRuntimeLibEnvironment, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibCompiledOpcodesVm, _glimmerRuntimeLibVmUpdate, _glimmerRuntimeLibVmRenderResult, _glimmerRuntimeLibVmFrame) { - 'use strict'; + if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.String) { + String.prototype.htmlSafe = function () { + return _emberGlimmer.htmlSafe(this); + }; + } - var VM = (function () { - function VM(env, scope, dynamicScope, elementStack) { - this.env = env; - this.elementStack = elementStack; - this.dynamicScopeStack = new _glimmerUtil.Stack(); - this.scopeStack = new _glimmerUtil.Stack(); - this.updatingOpcodeStack = new _glimmerUtil.Stack(); - this.cacheGroups = new _glimmerUtil.Stack(); - this.listBlockStack = new _glimmerUtil.Stack(); - this.frame = new _glimmerRuntimeLibVmFrame.FrameStack(); - this.env = env; - this.elementStack = elementStack; - this.scopeStack.push(scope); - this.dynamicScopeStack.push(dynamicScope); - } - - VM.initial = function initial(env, self, dynamicScope, elementStack, size) { - var scope = _glimmerRuntimeLibEnvironment.Scope.root(self, size); - return new VM(env, scope, dynamicScope, elementStack); - }; + var EmberHandlebars = _emberMetal.default.Handlebars = _emberMetal.default.Handlebars || {}; + var EmberHTMLBars = _emberMetal.default.HTMLBars = _emberMetal.default.HTMLBars || {}; + var EmberHandleBarsUtils = EmberHandlebars.Utils = EmberHandlebars.Utils || {}; - VM.prototype.capture = function capture() { - return { - env: this.env, - scope: this.scope(), - dynamicScope: this.dynamicScope(), - frame: this.frame.capture() - }; - }; + Object.defineProperty(EmberHandlebars, 'SafeString', { + get: _emberGlimmer._getSafeString + }); - VM.prototype.goto = function goto(op) { - // assert(this.frame.getOps().contains(op), `Illegal jump to ${op.label}`); - this.frame.goto(op); - }; + EmberHTMLBars.template = EmberHandlebars.template = _emberGlimmer.template; + EmberHandleBarsUtils.escapeExpression = _emberGlimmer.escapeExpression; + _emberRuntime.String.htmlSafe = _emberGlimmer.htmlSafe; - VM.prototype.beginCacheGroup = function beginCacheGroup() { - this.cacheGroups.push(this.updatingOpcodeStack.current.tail()); - }; + _emberRuntime.String.isHTMLSafe = _emberGlimmer.isHTMLSafe; + EmberHTMLBars.makeBoundHelper = _emberGlimmer.makeBoundHelper; - VM.prototype.commitCacheGroup = function commitCacheGroup() { - // JumpIfNotModified(END) - // (head) - // (....) - // (tail) - // DidModify - // END: Noop - var END = new _glimmerRuntimeLibCompiledOpcodesVm.LabelOpcode("END"); - var opcodes = this.updatingOpcodeStack.current; - var marker = this.cacheGroups.pop(); - var head = marker ? opcodes.nextNode(marker) : opcodes.head(); - var tail = opcodes.tail(); - var tag = _glimmerReference.combineSlice(new _glimmerUtil.ListSlice(head, tail)); - var guard = new _glimmerRuntimeLibCompiledOpcodesVm.JumpIfNotModifiedOpcode(tag, END); - opcodes.insertBefore(guard, head); - opcodes.append(new _glimmerRuntimeLibCompiledOpcodesVm.DidModifyOpcode(guard)); - opcodes.append(END); - }; + /** + Global hash of shared templates. This will automatically be populated + by the build tools so that you can store your Handlebars templates in + separate files that get loaded into JavaScript at buildtime. + + @property TEMPLATES + @for Ember + @type Object + @private + */ + Object.defineProperty(_emberMetal.default, 'TEMPLATES', { + get: _emberGlimmer.getTemplates, + set: _emberGlimmer.setTemplates, + configurable: false, + enumerable: false + }); - VM.prototype.enter = function enter(ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushUpdatableBlock(); - var state = this.capture(); - var tryOpcode = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, updating); - this.didEnter(tryOpcode, updating); - }; + exports.VERSION = _emberVersion.default; - VM.prototype.enterWithKey = function enterWithKey(key, ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushUpdatableBlock(); - var state = this.capture(); - var tryOpcode = new _glimmerRuntimeLibVmUpdate.TryOpcode(ops, state, tracker, updating); - this.listBlockStack.current.map[key] = tryOpcode; - this.didEnter(tryOpcode, updating); - }; + /** + The semantic version + @property VERSION + @type String + @public + */ + _emberMetal.default.VERSION = _emberVersion.default; - VM.prototype.enterList = function enterList(ops) { - var updating = new _glimmerUtil.LinkedList(); - var tracker = this.stack().pushBlockList(updating); - var state = this.capture(); - var artifacts = this.frame.getIterator().artifacts; - var opcode = new _glimmerRuntimeLibVmUpdate.ListBlockOpcode(ops, state, tracker, updating, artifacts); - this.listBlockStack.push(opcode); - this.didEnter(opcode, updating); - }; + _emberMetal.libraries.registerCoreLibrary('Ember', _emberVersion.default); - VM.prototype.didEnter = function didEnter(opcode, updating) { - this.updateWith(opcode); - this.updatingOpcodeStack.push(updating); - }; + _emberMetal.default.create = _emberMetal.deprecateFunc('Ember.create is deprecated in favor of Object.create', { id: 'ember-metal.ember-create', until: '3.0.0' }, Object.create); + _emberMetal.default.keys = _emberMetal.deprecateFunc('Ember.keys is deprecated in favor of Object.keys', { id: 'ember-metal.ember.keys', until: '3.0.0' }, Object.keys); - VM.prototype.exit = function exit() { - this.stack().popBlock(); - this.updatingOpcodeStack.pop(); - var parent = this.updatingOpcodeStack.current.tail(); - parent.didInitializeChildren(); - }; + // require the main entry points for each of these packages + // this is so that the global exports occur properly - VM.prototype.exitList = function exitList() { - this.exit(); - this.listBlockStack.pop(); - }; + /** + Alias for jQuery + + @method $ + @for Ember + @public + */ + _emberMetal.default.$ = _emberViews.jQuery; - VM.prototype.updateWith = function updateWith(opcode) { - this.updatingOpcodeStack.current.append(opcode); - }; + _emberMetal.default.ViewTargetActionSupport = _emberViews.ViewTargetActionSupport; - VM.prototype.stack = function stack() { - return this.elementStack; - }; + _emberMetal.default.ViewUtils = { + isSimpleClick: _emberViews.isSimpleClick, + getViewElement: _emberViews.getViewElement, + getViewBounds: _emberViews.getViewBounds, + getViewClientRects: _emberViews.getViewClientRects, + getViewBoundingClientRect: _emberViews.getViewBoundingClientRect, + getRootViews: _emberViews.getRootViews, + getChildViews: _emberViews.getChildViews + }; - VM.prototype.scope = function scope() { - return this.scopeStack.current; - }; + _emberMetal.default.TextSupport = _emberViews.TextSupport; + _emberMetal.default.ComponentLookup = _emberViews.ComponentLookup; + _emberMetal.default.EventDispatcher = _emberViews.EventDispatcher; - VM.prototype.dynamicScope = function dynamicScope() { - return this.dynamicScopeStack.current; - }; + _emberMetal.default.Location = _emberRouting.Location; + _emberMetal.default.AutoLocation = _emberRouting.AutoLocation; + _emberMetal.default.HashLocation = _emberRouting.HashLocation; + _emberMetal.default.HistoryLocation = _emberRouting.HistoryLocation; + _emberMetal.default.NoneLocation = _emberRouting.NoneLocation; + _emberMetal.default.controllerFor = _emberRouting.controllerFor; + _emberMetal.default.generateControllerFactory = _emberRouting.generateControllerFactory; + _emberMetal.default.generateController = _emberRouting.generateController; + _emberMetal.default.RouterDSL = _emberRouting.RouterDSL; + _emberMetal.default.Router = _emberRouting.Router; + _emberMetal.default.Route = _emberRouting.Route; - VM.prototype.pushFrame = function pushFrame(block, args, callerScope) { - this.frame.push(block.ops); - if (args) this.frame.setArgs(args); - if (args && args.blocks) this.frame.setBlocks(args.blocks); - if (callerScope) this.frame.setCallerScope(callerScope); - }; + _emberMetal.default.Application = _emberApplication.Application; + _emberMetal.default.ApplicationInstance = _emberApplication.ApplicationInstance; + _emberMetal.default.Engine = _emberApplication.Engine; + _emberMetal.default.EngineInstance = _emberApplication.EngineInstance; + _emberMetal.default.DefaultResolver = _emberMetal.default.Resolver = _emberApplication.Resolver; - VM.prototype.pushComponentFrame = function pushComponentFrame(layout, args, callerScope, component, manager, shadow) { - this.frame.push(layout.ops, component, manager, shadow); - if (args) this.frame.setArgs(args); - if (args && args.blocks) this.frame.setBlocks(args.blocks); - if (callerScope) this.frame.setCallerScope(callerScope); - }; + _emberRuntime.runLoadHooks('Ember.Application', _emberApplication.Application); - VM.prototype.pushEvalFrame = function pushEvalFrame(ops) { - this.frame.push(ops); - }; + _emberMetal.default.DataAdapter = _emberExtensionSupport.DataAdapter; + _emberMetal.default.ContainerDebugAdapter = _emberExtensionSupport.ContainerDebugAdapter; - VM.prototype.pushChildScope = function pushChildScope() { - this.scopeStack.push(this.scopeStack.current.child()); - }; + if (_require.has('ember-template-compiler')) { + _require.default('ember-template-compiler'); + } - VM.prototype.pushCallerScope = function pushCallerScope() { - this.scopeStack.push(this.scope().getCallerScope()); - }; + // do this to ensure that Ember.Test is defined properly on the global + // if it is present. + if (_require.has('ember-testing')) { + var testing = _require.default('ember-testing'); - VM.prototype.pushDynamicScope = function pushDynamicScope() { - var child = this.dynamicScopeStack.current.child(); - this.dynamicScopeStack.push(child); - return child; - }; + _emberMetal.default.Test = testing.Test; + _emberMetal.default.Test.Adapter = testing.Adapter; + _emberMetal.default.Test.QUnitAdapter = testing.QUnitAdapter; + _emberMetal.default.setupForTesting = testing.setupForTesting; + } - VM.prototype.pushRootScope = function pushRootScope(self, size) { - var scope = _glimmerRuntimeLibEnvironment.Scope.root(self, size); - this.scopeStack.push(scope); - return scope; - }; + _emberRuntime.runLoadHooks('Ember'); - VM.prototype.popScope = function popScope() { - this.scopeStack.pop(); - }; + /** + @module ember + */ + exports.default = _emberMetal.default; - VM.prototype.popDynamicScope = function popDynamicScope() { - this.dynamicScopeStack.pop(); - }; + /* globals module */ + if (typeof module === 'object' && module.exports) { + module.exports = _emberMetal.default; + } else { + _emberEnvironment.context.exports.Ember = _emberEnvironment.context.exports.Em = _emberMetal.default; + } +}); - VM.prototype.newDestroyable = function newDestroyable(d) { - this.stack().newDestroyable(d); - }; +// ****ember-environment**** - /// SCOPE HELPERS +// ****ember-metal**** - VM.prototype.getSelf = function getSelf() { - return this.scope().getSelf(); - }; +// computed macros - VM.prototype.referenceForSymbol = function referenceForSymbol(symbol) { - return this.scope().getSymbol(symbol); - }; +// reduced computed macros +enifed("ember/version", ["exports"], function (exports) { + "use strict"; - VM.prototype.getArgs = function getArgs() { - return this.frame.getArgs(); - }; + exports.default = "2.12.0-canary"; +}); +enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { + 'use strict'; - /// EXECUTION + exports.default = applyMixins; - VM.prototype.resume = function resume(opcodes, frame) { - return this.execute(opcodes, function (vm) { - return vm.frame.restore(frame); - }); - }; + function isGenerator(mixin) { + return Array.isArray(mixin.cases) && typeof mixin.generate === 'function'; + } - VM.prototype.execute = function execute(opcodes, initialize) { - _glimmerUtil.LOGGER.debug("[VM] Begin program execution"); - var elementStack = this.elementStack; - var frame = this.frame; - var updatingOpcodeStack = this.updatingOpcodeStack; - var env = this.env; - - elementStack.pushSimpleBlock(); - updatingOpcodeStack.push(new _glimmerUtil.LinkedList()); - frame.push(opcodes); - if (initialize) initialize(this); - var opcode = undefined; - while (frame.hasOpcodes()) { - if (opcode = frame.nextStatement()) { - _glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type); - _glimmerUtil.LOGGER.trace(opcode); - opcode.evaluate(this); - } - } - _glimmerUtil.LOGGER.debug("[VM] Completed program execution"); - return new _glimmerRuntimeLibVmRenderResult.default(env, updatingOpcodeStack.pop(), elementStack.popBlock()); - }; + function applyMixins(TestClass) { + for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + mixins[_key - 1] = arguments[_key]; + } - VM.prototype.evaluateOpcode = function evaluateOpcode(opcode) { - opcode.evaluate(this); - }; + mixins.forEach(function (mixinOrGenerator) { + var mixin = undefined; - // Make sure you have opcodes that push and pop a scope around this opcode - // if you need to change the scope. + if (isGenerator(mixinOrGenerator)) { + (function () { + var generator = mixinOrGenerator; + mixin = {}; - VM.prototype.invokeBlock = function invokeBlock(block, args) { - var compiled = block.compile(this.env); - this.pushFrame(compiled, args); - }; + generator.cases.forEach(function (value, idx) { + _emberUtils.assign(mixin, generator.generate(value, idx)); + }); + })(); + } else { + mixin = mixinOrGenerator; + } - VM.prototype.invokePartial = function invokePartial(block) { - var compiled = block.compile(this.env); - this.pushFrame(compiled); - }; + _emberUtils.assign(TestClass.prototype, mixin); + }); - VM.prototype.invokeLayout = function invokeLayout(args, layout, callerScope, component, manager, shadow) { - this.pushComponentFrame(layout, args, callerScope, component, manager, shadow); - }; + return TestClass; + } +}); +enifed('internal-test-helpers/build-owner', ['exports', 'container', 'ember-routing', 'ember-application', 'ember-metal', 'ember-runtime'], function (exports, _container, _emberRouting, _emberApplication, _emberMetal, _emberRuntime) { + 'use strict'; - VM.prototype.evaluateOperand = function evaluateOperand(expr) { - this.frame.setOperand(expr.evaluate(this)); - }; + exports.default = buildOwner; - VM.prototype.evaluateArgs = function evaluateArgs(args) { - var evaledArgs = this.frame.setArgs(args.evaluate(this)); - this.frame.setOperand(evaledArgs.positional.at(0)); - }; + function buildOwner() { + var _EmberObject$extend; - VM.prototype.bindPositionalArgs = function bindPositionalArgs(symbols) { - var args = this.frame.getArgs(); - _glimmerUtil.assert(args, "Cannot bind positional args"); - var positional = args.positional; + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - var scope = this.scope(); - for (var i = 0; i < symbols.length; i++) { - scope.bindSymbol(symbols[i], positional.at(i)); - } - }; + var ownerOptions = options.ownerOptions || {}; + var resolver = options.resolver; + var bootOptions = options.bootOptions || {}; - VM.prototype.bindNamedArgs = function bindNamedArgs(names, symbols) { - var args = this.frame.getArgs(); - var scope = this.scope(); - _glimmerUtil.assert(args, "Cannot bind named args"); - var named = args.named; + var Owner = _emberRuntime.Object.extend(_emberRuntime.RegistryProxyMixin, _emberRuntime.ContainerProxyMixin, (_EmberObject$extend = {}, _EmberObject$extend[_container.FACTORY_FOR] = function () { + var _container__; - for (var i = 0; i < names.length; i++) { - scope.bindSymbol(symbols[i], named.get(names[i])); - } - }; + return (_container__ = this.__container__)[_container.FACTORY_FOR].apply(_container__, arguments); + }, _EmberObject$extend[_container.LOOKUP_FACTORY] = function () { + var _container__2; - VM.prototype.bindBlocks = function bindBlocks(names, symbols) { - var blocks = this.frame.getBlocks(); - var scope = this.scope(); - for (var i = 0; i < names.length; i++) { - scope.bindBlock(symbols[i], blocks && blocks[names[i]] || null); - } - }; + return (_container__2 = this.__container__)[_container.LOOKUP_FACTORY].apply(_container__2, arguments); + }, _EmberObject$extend)); - VM.prototype.bindPartialArgs = function bindPartialArgs(symbol) { - var args = this.frame.getArgs(); - var scope = this.scope(); - _glimmerUtil.assert(args, "Cannot bind named args"); - scope.bindPartialArgs(symbol, args); - }; + if (true) { + Owner.reopen({ + factoryFor: function () { + var _container__3; - VM.prototype.bindCallerScope = function bindCallerScope() { - var callerScope = this.frame.getCallerScope(); - var scope = this.scope(); - _glimmerUtil.assert(callerScope, "Cannot bind caller scope"); - scope.bindCallerScope(callerScope); - }; + return (_container__3 = this.__container__).factoryFor.apply(_container__3, arguments); + } + }); + } - VM.prototype.bindDynamicScope = function bindDynamicScope(names) { - var args = this.frame.getArgs(); - var scope = this.dynamicScope(); - _glimmerUtil.assert(args, "Cannot bind dynamic scope"); - for (var i = 0; i < names.length; i++) { - scope.set(names[i], args.named.get(names[i])); - } - }; + var namespace = _emberRuntime.Object.create({ + Resolver: { create: function () { + return resolver; + } } + }); - return VM; - })(); + var fallbackRegistry = _emberApplication.Application.buildRegistry(namespace); + fallbackRegistry.register('router:main', _emberRouting.Router); - exports.default = VM; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjp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ICAgIGZvcihsZXQgaT0wOyBpIDwgbmFtZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgIHNjb3BlLnNldChuYW1lc1tpXSwgYXJncy5uYW1lZC5nZXQobmFtZXNbaV0pKTtcbiAgICB9XG4gIH1cbn1cblxuaW50ZXJmYWNlIEV4Y2VwdGlvbkhhbmRsZXIge1xuICBoYW5kbGVFeGNlcHRpb24oaW5pdGlhbGl6ZT86ICh2bTogVk0pID0+IHZvaWQpO1xufVxuXG5pbnRlcmZhY2UgUmV0dXJuSGFuZGxlciB7XG4gIHNldFJlbmRlclJlc3VsdChyZW5kZXJSZXN1bHQ6IFJlbmRlclJlc3VsdCk7XG59XG4iXX0= -enifed('glimmer-runtime/lib/vm/frame', ['exports'], function (exports) { - 'use strict'; + var registry = new _container.Registry({ + fallback: fallbackRegistry + }); - var CapturedFrame = function CapturedFrame(operand, args, condition) { - this.operand = operand; - this.args = args; - this.condition = condition; - }; - - exports.CapturedFrame = CapturedFrame; - - var Frame = (function () { - function Frame(ops) { - var component = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - var manager = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - var shadow = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; - - this.component = component; - this.manager = manager; - this.shadow = shadow; - this.operand = null; - this.immediate = null; - this.args = null; - this.callerScope = null; - this.blocks = null; - this.condition = null; - this.iterator = null; - this.key = null; - this.ops = ops; - this.op = ops.head(); - } + _emberApplication.ApplicationInstance.setupRegistry(registry, bootOptions); - Frame.prototype.capture = function capture() { - return new CapturedFrame(this.operand, this.args, this.condition); - }; + var owner = Owner.create({ + __registry__: registry, + __container__: null + }, ownerOptions); - Frame.prototype.restore = function restore(frame) { - this.operand = frame['operand']; - this.args = frame['args']; - this.condition = frame['condition']; - }; + var container = registry.container({ owner: owner }); + owner.__container__ = container; - return Frame; - })(); + return owner; + } +}); +enifed('internal-test-helpers/confirm-export', ['exports', 'require'], function (exports, _require) { + 'use strict'; - var FrameStack = (function () { - function FrameStack() { - this.frames = []; - this.frame = undefined; - } + exports.default = confirmExport; - FrameStack.prototype.push = function push(ops) { - var component = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - var manager = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - var shadow = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + function getDescriptor(obj, path) { + var parts = path.split('.'); + var value = obj; + for (var i = 0; i < parts.length - 1; i++) { + var part = parts[i]; + value = value[part]; + if (!value) { + return undefined; + } + } + var last = parts[parts.length - 1]; + return Object.getOwnPropertyDescriptor(value, last); + } - var frame = this.frame === undefined ? this.frame = 0 : ++this.frame; - if (this.frames.length <= frame) { - this.frames.push(null); - } - this.frames[frame] = new Frame(ops, component, manager, shadow); - }; + function confirmExport(Ember, assert, path, moduleId, exportName) { + var desc = getDescriptor(Ember, path); + assert.ok(desc, 'the property exists on the global'); - FrameStack.prototype.pop = function pop() { - var frames = this.frames; - var frame = this.frame; + var mod = _require.default(moduleId); + if (typeof exportName === 'string') { + assert.equal(desc.value, mod[exportName], 'Ember.' + path + ' is exported correctly'); + assert.notEqual(mod[exportName], undefined, 'Ember.' + path + ' is not `undefined`'); + } else { + assert.equal(desc.get, mod[exportName.get], 'Ember.' + path + ' getter is exported correctly'); + assert.notEqual(desc.get, undefined, 'Ember.' + path + ' getter is not undefined'); - frames[frame] = null; - this.frame = frame === 0 ? undefined : frame - 1; - }; + if (exportName.set) { + assert.equal(desc.set, mod[exportName.set], 'Ember.' + path + ' setter is exported correctly'); + assert.notEqual(desc.set, undefined, 'Ember.' + path + ' setter is not undefined'); + } + } + } +}); +enifed('internal-test-helpers/equal-inner-html', ['exports'], function (exports) { + // detect side-effects of cloning svg elements in IE9-11 + 'use strict'; - FrameStack.prototype.capture = function capture() { - return this.frames[this.frame].capture(); - }; + exports.default = equalInnerHTML; + var ieSVGInnerHTML = (function () { + if (!document.createElementNS) { + return false; + } + var div = document.createElement('div'); + var node = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + div.appendChild(node); + var clone = div.cloneNode(true); + return clone.innerHTML === ''; + })(); - FrameStack.prototype.restore = function restore(frame) { - this.frames[this.frame].restore(frame); - }; + function normalizeInnerHTML(actualHTML) { + if (ieSVGInnerHTML) { + // Replace `` with ``, etc. + // drop namespace attribute + actualHTML = actualHTML.replace(/ xmlns="[^"]+"/, ''); + // replace self-closing elements + actualHTML = actualHTML.replace(/<([^ >]+) [^\/>]*\/>/gi, function (tag, tagName) { + return tag.slice(0, tag.length - 3) + '>'; + }); + } - FrameStack.prototype.getOps = function getOps() { - return this.frames[this.frame].ops; - }; + return actualHTML; + } - FrameStack.prototype.getCurrent = function getCurrent() { - return this.frames[this.frame].op; - }; + function equalInnerHTML(fragment, html) { + var actualHTML = normalizeInnerHTML(fragment.innerHTML); + QUnit.push(actualHTML === html, actualHTML, html); + } +}); +enifed('internal-test-helpers/equal-tokens', ['exports', 'simple-html-tokenizer'], function (exports, _simpleHtmlTokenizer) { + 'use strict'; - FrameStack.prototype.setCurrent = function setCurrent(op) { - return this.frames[this.frame].op = op; - }; + exports.default = equalTokens; - FrameStack.prototype.getOperand = function getOperand() { - return this.frames[this.frame].operand; - }; + function generateTokens(containerOrHTML) { + if (typeof containerOrHTML === 'string') { + return { + tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML), + html: containerOrHTML + }; + } else { + return { + tokens: _simpleHtmlTokenizer.tokenize(containerOrHTML.innerHTML), + html: containerOrHTML.innerHTML + }; + } + } - FrameStack.prototype.setOperand = function setOperand(operand) { - return this.frames[this.frame].operand = operand; - }; + function normalizeTokens(tokens) { + tokens.forEach(function (token) { + if (token.type === 'StartTag') { + token.attributes = token.attributes.sort(function (a, b) { + if (a[0] > b[0]) { + return 1; + } + if (a[0] < b[0]) { + return -1; + } + return 0; + }); + } + }); + } - FrameStack.prototype.getImmediate = function getImmediate() { - return this.frames[this.frame].immediate; - }; + function equalTokens(actualContainer, expectedHTML) { + var message = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - FrameStack.prototype.setImmediate = function setImmediate(value) { - return this.frames[this.frame].immediate = value; - }; + var actual = generateTokens(actualContainer); + var expected = generateTokens(expectedHTML); - FrameStack.prototype.getArgs = function getArgs() { - return this.frames[this.frame].args; - }; + normalizeTokens(actual.tokens); + normalizeTokens(expected.tokens); - FrameStack.prototype.setArgs = function setArgs(args) { - var frame = this.frames[this.frame]; - return frame.args = args; - }; + var equiv = QUnit.equiv(actual.tokens, expected.tokens); - FrameStack.prototype.getCondition = function getCondition() { - return this.frames[this.frame].condition; - }; + if (equiv && expected.html !== actual.html) { + deepEqual(actual.tokens, expected.tokens, message); + } else { + QUnit.push(QUnit.equiv(actual.tokens, expected.tokens), actual.html, expected.html, message); + } + } +}); +enifed('internal-test-helpers/factory', ['exports'], function (exports) { + 'use strict'; - FrameStack.prototype.setCondition = function setCondition(condition) { - return this.frames[this.frame].condition = condition; - }; + exports.default = factory; + function setProperties(object, properties) { + for (var key in properties) { + if (properties.hasOwnProperty(key)) { + object[key] = properties[key]; + } + } + } - FrameStack.prototype.getIterator = function getIterator() { - return this.frames[this.frame].iterator; - }; + var guids = 0; - FrameStack.prototype.setIterator = function setIterator(iterator) { - return this.frames[this.frame].iterator = iterator; - }; + function factory() { + /*jshint validthis: true */ - FrameStack.prototype.getKey = function getKey() { - return this.frames[this.frame].key; - }; + function Klass(options) { + setProperties(this, options); + this._guid = guids++; + this.isDestroyed = false; + } - FrameStack.prototype.setKey = function setKey(key) { - return this.frames[this.frame].key = key; - }; + Klass.prototype.constructor = Klass; + Klass.prototype.destroy = function () { + this.isDestroyed = true; + }; - FrameStack.prototype.getBlocks = function getBlocks() { - return this.frames[this.frame].blocks; - }; + Klass.prototype.toString = function () { + return ''; + }; - FrameStack.prototype.setBlocks = function setBlocks(blocks) { - return this.frames[this.frame].blocks = blocks; - }; + Klass.create = create; + Klass.extend = extend; + Klass.reopen = extend; + Klass.reopenClass = reopenClass; - FrameStack.prototype.getCallerScope = function getCallerScope() { - return this.frames[this.frame].callerScope; - }; + return Klass; - FrameStack.prototype.setCallerScope = function setCallerScope(callerScope) { - return this.frames[this.frame].callerScope = callerScope; - }; + function create(options) { + return new this.prototype.constructor(options); + } - FrameStack.prototype.getComponent = function getComponent() { - return this.frames[this.frame].component; - }; + function reopenClass(options) { + setProperties(this, options); + } - FrameStack.prototype.getManager = function getManager() { - return this.frames[this.frame].manager; - }; + function extend(options) { + function Child(options) { + Klass.call(this, options); + } - FrameStack.prototype.getShadow = function getShadow() { - return this.frames[this.frame].shadow; - }; + var Parent = this; - FrameStack.prototype.goto = function goto(op) { - this.setCurrent(op); - }; + Child.prototype = new Parent(); + Child.prototype.constructor = Child; - FrameStack.prototype.hasOpcodes = function hasOpcodes() { - return this.frame !== undefined; - }; + setProperties(Child, Klass); + setProperties(Child.prototype, options); - FrameStack.prototype.nextStatement = function nextStatement() { - var op = this.frames[this.frame].op; - var ops = this.getOps(); - if (op) { - this.setCurrent(ops.nextNode(op)); - return op; - } else { - this.pop(); - return null; - } - }; + Child.create = create; + Child.extend = extend; + Child.reopen = extend; - return FrameStack; - })(); + Child.reopenClass = reopenClass; - exports.FrameStack = FrameStack; + return Child; + } + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vZnJhbWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O1FBUUEsYUFBQSxHQUNFLFNBREYsYUFBQSxDQUVZLE9BQTJCLEVBQzNCLElBQW1CLEVBQ25CLFNBQTZCLEVBQUE7QUFGN0IsWUFBQSxDQUFBLE9BQU8sR0FBUCxPQUFPLENBQW9CO0FBQzNCLFlBQUEsQ0FBQSxJQUFJLEdBQUosSUFBSSxDQUFlO0FBQ25CLFlBQUEsQ0FBQSxTQUFTLEdBQVQsU0FBUyxDQUFvQjtLQUNuQzs7OztRQUdOLEtBQUE7QUFZRSxpQkFaRixLQUF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ge1xuICAgIHJldHVybiB0aGlzLmZyYW1lICE9PSB1bmRlZmluZWQ7XG4gIH1cblxuICBuZXh0U3RhdGVtZW50KCk6IE9wY29kZSB7XG4gICAgbGV0IG9wID0gdGhpcy5mcmFtZXNbdGhpcy5mcmFtZV0ub3A7XG4gICAgbGV0IG9wcyA9IHRoaXMuZ2V0T3BzKCk7XG5cbiAgICBpZiAob3ApIHtcbiAgICAgIHRoaXMuc2V0Q3VycmVudChvcHMubmV4dE5vZGUob3ApKTtcbiAgICAgIHJldHVybiBvcDtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhpcy5wb3AoKTtcbiAgICAgIHJldHVybiBudWxsO1xuICAgIH1cbiAgfVxufVxuIl19 -enifed('glimmer-runtime/lib/vm/render-result', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/vm/update'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibVmUpdate) { - 'use strict'; +enifed('internal-test-helpers/index', ['exports', 'internal-test-helpers/factory', 'internal-test-helpers/build-owner', 'internal-test-helpers/confirm-export', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/module-for', 'internal-test-helpers/strip', 'internal-test-helpers/apply-mixins', 'internal-test-helpers/matchers', 'internal-test-helpers/run', 'internal-test-helpers/test-groups', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/test-cases/abstract-application', 'internal-test-helpers/test-cases/application', 'internal-test-helpers/test-cases/query-param', 'internal-test-helpers/test-cases/abstract-rendering', 'internal-test-helpers/test-cases/rendering', 'internal-test-helpers/test-cases/router'], function (exports, _internalTestHelpersFactory, _internalTestHelpersBuildOwner, _internalTestHelpersConfirmExport, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersModuleFor, _internalTestHelpersStrip, _internalTestHelpersApplyMixins, _internalTestHelpersMatchers, _internalTestHelpersRun, _internalTestHelpersTestGroups, _internalTestHelpersTestCasesAbstract, _internalTestHelpersTestCasesAbstractApplication, _internalTestHelpersTestCasesApplication, _internalTestHelpersTestCasesQueryParam, _internalTestHelpersTestCasesAbstractRendering, _internalTestHelpersTestCasesRendering, _internalTestHelpersTestCasesRouter) { + 'use strict'; - var RenderResult = (function () { - function RenderResult(env, updating, bounds) { - this.env = env; - this.updating = updating; - this.bounds = bounds; - } + exports.factory = _internalTestHelpersFactory.default; + exports.buildOwner = _internalTestHelpersBuildOwner.default; + exports.confirmExport = _internalTestHelpersConfirmExport.default; + exports.equalInnerHTML = _internalTestHelpersEqualInnerHtml.default; + exports.equalTokens = _internalTestHelpersEqualTokens.default; + exports.moduleFor = _internalTestHelpersModuleFor.default; + exports.strip = _internalTestHelpersStrip.default; + exports.applyMixins = _internalTestHelpersApplyMixins.default; + exports.equalsElement = _internalTestHelpersMatchers.equalsElement; + exports.classes = _internalTestHelpersMatchers.classes; + exports.styles = _internalTestHelpersMatchers.styles; + exports.regex = _internalTestHelpersMatchers.regex; + exports.runAppend = _internalTestHelpersRun.runAppend; + exports.runDestroy = _internalTestHelpersRun.runDestroy; + exports.testBoth = _internalTestHelpersTestGroups.testBoth; + exports.testWithDefault = _internalTestHelpersTestGroups.testWithDefault; + exports.AbstractTestCase = _internalTestHelpersTestCasesAbstract.default; + exports.AbstractApplicationTestCase = _internalTestHelpersTestCasesAbstractApplication.default; + exports.ApplicationTestCase = _internalTestHelpersTestCasesApplication.default; + exports.QueryParamTestCase = _internalTestHelpersTestCasesQueryParam.default; + exports.AbstractRenderingTestCase = _internalTestHelpersTestCasesAbstractRendering.default; + exports.RenderingTestCase = _internalTestHelpersTestCasesRendering.default; + exports.RouterTestCase = _internalTestHelpersTestCasesRouter.default; +}); +enifed('internal-test-helpers/matchers', ['exports'], function (exports) { + 'use strict'; - RenderResult.prototype.rerender = function rerender() { - var _ref = arguments.length <= 0 || arguments[0] === undefined ? { alwaysRevalidate: false } : arguments[0]; + exports.regex = regex; + exports.classes = classes; + exports.styles = styles; + exports.equalsElement = equalsElement; + var HTMLElement = window.HTMLElement; + var MATCHER_BRAND = '3d4ef194-13be-4ccf-8dc7-862eea02c93e'; - var _ref$alwaysRevalidate = _ref.alwaysRevalidate; - var alwaysRevalidate = _ref$alwaysRevalidate === undefined ? false : _ref$alwaysRevalidate; - var env = this.env; - var updating = this.updating; + function isMatcher(obj) { + return typeof obj === 'object' && obj !== null && MATCHER_BRAND in obj; + } - var vm = new _glimmerRuntimeLibVmUpdate.default(env, { alwaysRevalidate: alwaysRevalidate }); - vm.execute(updating, this); - }; + function equalsAttr(expected) { + var _ref; - RenderResult.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + return _ref = {}, _ref[MATCHER_BRAND] = true, _ref.match = function (actual) { + return expected === actual; + }, _ref.expected = function () { + return expected; + }, _ref.message = function () { + return 'should equal ' + this.expected(); + }, _ref; + } - RenderResult.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + function regex(r) { + var _ref2; - RenderResult.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + return _ref2 = {}, _ref2[MATCHER_BRAND] = true, _ref2.match = function (v) { + return r.test(v); + }, _ref2.expected = function () { + return r.toString(); + }, _ref2.message = function () { + return 'should match ' + this.expected(); + }, _ref2; + } - RenderResult.prototype.opcodes = function opcodes() { - return this.updating; - }; + function classes(expected) { + var _ref3; - RenderResult.prototype.handleException = function handleException() { - throw "this should never happen"; - }; + return _ref3 = {}, _ref3[MATCHER_BRAND] = true, _ref3.match = function (actual) { + actual = actual.trim(); + return actual && expected.split(/\s+/).sort().join(' ') === actual.trim().split(/\s+/).sort().join(' '); + }, _ref3.expected = function () { + return expected; + }, _ref3.message = function () { + return 'should match ' + this.expected(); + }, _ref3; + } - RenderResult.prototype.destroy = function destroy() { - this.bounds.destroy(); - _glimmerRuntimeLibBounds.clear(this.bounds); - }; + function styles(expected) { + var _ref4; - return RenderResult; - })(); + return _ref4 = {}, _ref4[MATCHER_BRAND] = true, _ref4.match = function (actual) { + // coerce `null` or `undefined` to an empty string + // needed for matching empty styles on IE9 - IE11 + actual = actual || ''; + actual = actual.trim(); - exports.default = RenderResult; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vcmVuZGVyLXJlc3VsdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFPQSxZQUFBO0FBQ0UsaUJBREYsWUFBQSxDQUVZLEdBQWdCLEVBQ2hCLFFBQW9DLEVBQ3BDLE1BQXlCLEVBQUE7QUFGekIsZ0JBQUEsQ0FBQSxHQUFHLEdBQUgsR0FBRyxDQUFhO0FBQ2hCLGdCQUFBLENBQUEsUUFBUSxHQUFSLFFBQVEsQ0FBNEI7QUFDcEMsZ0JBQUEsQ0FBQSxNQUFNLEdBQU4sTUFBTSxDQUFtQjtTQUMvQjs7QUFMTixvQkFBQSxXQU9FLFFBQVEsR0FBQSxvQkFBMkQ7NkVBQTNCLEVBQUUsZ0JBQWdCLEVBQUUsS0FBSyxFQUFFOzs2Q0FBeEQsZ0JBQWdCO2dCQUFoQixnQkFBZ0IseUNBQUcsS0FBSztnQkFDM0IsR0FBRyxHQUFlLElBQUksQ0FBdEIsR0FBRztnQkFBRSxRQUFRLEdBQUssSUFBSSxDQUFqQixRQUFROztBQUNuQixnQkFBSSxFQUFFLEdBQUcsdUNBQWUsR0FBRyxFQUFFLEVBQUUsZ0JBQWdCLEVBQWhCLGdCQUFnQixFQUFFLENBQUMsQ0FBQztBQUNuRCxjQUFFLENBQUMsT0FBTyxDQUFDLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQztTQUM1Qjs7QUFYSCxvQkFBQSxXQWFFLGFBQWEsR0FBQSx5QkFBQTtBQUNYLG1CQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsYUFBYSxFQUFFLENBQUM7U0FDcEM7O0FBZkgsb0JBQUEsV0FpQkUsU0FBUyxHQUFBLHFCQUFBO0FBQ1AsbUJBQU8sSU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Ym91bmRzLmRlc3Ryb3koKTtcbiAgICBjbGVhcih0aGlzLmJvdW5kcyk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-runtime/lib/vm/update', ['exports', 'glimmer-runtime/lib/bounds', 'glimmer-runtime/lib/builder', 'glimmer-util', 'glimmer-reference', 'glimmer-runtime/lib/compiled/expressions/args', 'glimmer-runtime/lib/opcodes', 'glimmer-runtime/lib/vm/append'], function (exports, _glimmerRuntimeLibBounds, _glimmerRuntimeLibBuilder, _glimmerUtil, _glimmerReference, _glimmerRuntimeLibCompiledExpressionsArgs, _glimmerRuntimeLibOpcodes, _glimmerRuntimeLibVmAppend) { - 'use strict'; + return expected.split(';').map(function (s) { + return s.trim(); + }).filter(function (s) { + return s; + }).sort().join('; ') === actual.split(';').map(function (s) { + return s.trim(); + }).filter(function (s) { + return s; + }).sort().join('; '); + }, _ref4.expected = function () { + return expected; + }, _ref4.message = function () { + return 'should match ' + this.expected(); + }, _ref4; + } - var UpdatingVM = (function () { - function UpdatingVM(env, _ref) { - var _ref$alwaysRevalidate = _ref.alwaysRevalidate; - var alwaysRevalidate = _ref$alwaysRevalidate === undefined ? false : _ref$alwaysRevalidate; + function equalsElement(element, tagName, attributes, content) { + QUnit.push(element.tagName === tagName.toUpperCase(), element.tagName.toLowerCase(), tagName, 'expect tagName to be ' + tagName); - this.frameStack = new _glimmerUtil.Stack(); - this.env = env; - this.dom = env.getDOM(); - this.alwaysRevalidate = alwaysRevalidate; - } + var expectedAttrs = {}; + var expectedCount = 0; - UpdatingVM.prototype.execute = function execute(opcodes, handler) { - var frameStack = this.frameStack; + for (var _name in attributes) { + var expected = attributes[_name]; + if (expected !== null) { + expectedCount++; + } - this.try(opcodes, handler); - while (true) { - if (frameStack.isEmpty()) break; - var opcode = this.frameStack.current.nextStatement(); - if (opcode === null) { - this.frameStack.pop(); - continue; - } - _glimmerUtil.LOGGER.debug('[VM] OP ' + opcode.type); - _glimmerUtil.LOGGER.trace(opcode); - opcode.evaluate(this); - } - }; + var matcher = isMatcher(expected) ? expected : equalsAttr(expected); - UpdatingVM.prototype.goto = function goto(op) { - this.frameStack.current.goto(op); - }; + expectedAttrs[_name] = matcher; - UpdatingVM.prototype.try = function _try(ops, handler) { - this.frameStack.push(new UpdatingVMFrame(this, ops, handler)); - }; + QUnit.push(expectedAttrs[_name].match(element.getAttribute(_name)), element.getAttribute(_name), matcher.expected(), 'Element\'s ' + _name + ' attribute ' + matcher.message()); + } - UpdatingVM.prototype.throw = function _throw() { - this.frameStack.current.handleException(); - this.frameStack.pop(); - }; + var actualAttributes = {}; - UpdatingVM.prototype.evaluateOpcode = function evaluateOpcode(opcode) { - opcode.evaluate(this); - }; + for (var i = 0, l = element.attributes.length; i < l; i++) { + actualAttributes[element.attributes[i].name] = element.attributes[i].value; + } - return UpdatingVM; - })(); + if (!(element instanceof HTMLElement)) { + QUnit.push(element instanceof HTMLElement, null, null, 'Element must be an HTML Element, not an SVG Element'); + } else { + QUnit.push(element.attributes.length === expectedCount || !attributes, element.attributes.length, expectedCount, 'Expected ' + expectedCount + ' attributes; got ' + element.outerHTML); - exports.default = UpdatingVM; + if (content !== null) { + QUnit.push(element.innerHTML === content, element.innerHTML, content, 'The element had \'' + content + '\' as its content'); + } + } + } +}); +enifed('internal-test-helpers/module-for', ['exports', 'internal-test-helpers/apply-mixins'], function (exports, _internalTestHelpersApplyMixins) { + 'use strict'; - var BlockOpcode = (function (_UpdatingOpcode) { - babelHelpers.inherits(BlockOpcode, _UpdatingOpcode); + exports.default = moduleFor; - function BlockOpcode(ops, state, bounds, children) { - _UpdatingOpcode.call(this); - this.type = "block"; - this.next = null; - this.prev = null; - var env = state.env; - var scope = state.scope; - var dynamicScope = state.dynamicScope; - var frame = state.frame; + function moduleFor(description, TestClass) { + var context = undefined; - this.ops = ops; - this.children = children; - this.env = env; - this.scope = scope; - this.dynamicScope = dynamicScope; - this.frame = frame; - this.bounds = bounds; - } + QUnit.module(description, { + setup: function () { + context = new TestClass(); + }, - BlockOpcode.prototype.parentElement = function parentElement() { - return this.bounds.parentElement(); - }; + teardown: function () { + context.teardown(); + } + }); - BlockOpcode.prototype.firstNode = function firstNode() { - return this.bounds.firstNode(); - }; + for (var _len = arguments.length, mixins = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + mixins[_key - 2] = arguments[_key]; + } - BlockOpcode.prototype.lastNode = function lastNode() { - return this.bounds.lastNode(); - }; + _internalTestHelpersApplyMixins.default(TestClass, mixins); - BlockOpcode.prototype.evaluate = function evaluate(vm) { - vm.try(this.children, null); - }; + var proto = TestClass.prototype; - BlockOpcode.prototype.destroy = function destroy() { - this.bounds.destroy(); - }; + while (proto !== Object.prototype) { + Object.keys(proto).forEach(generateTest); + proto = Object.getPrototypeOf(proto); + } - BlockOpcode.prototype.didDestroy = function didDestroy() { - this.env.didDestroy(this.bounds); - }; + function generateTest(name) { + if (name.indexOf('@test ') === 0) { + QUnit.test(name.slice(5), function (assert) { + return context[name](assert); + }); + } else if (name.indexOf('@skip ') === 0) { + QUnit.skip(name.slice(5), function (assert) { + return context[name](assert); + }); + } + } + } +}); +enifed('internal-test-helpers/run', ['exports', 'ember-metal'], function (exports, _emberMetal) { + 'use strict'; - BlockOpcode.prototype.toJSON = function toJSON() { - var begin = this.ops.head(); - var end = this.ops.tail(); - var details = _glimmerUtil.dict(); - details["guid"] = '' + this._guid; - details["begin"] = begin.inspect(); - details["end"] = end.inspect(); - return { - guid: this._guid, - type: this.type, - details: details, - children: this.children.toArray().map(function (op) { - return op.toJSON(); - }) - }; - }; + exports.runAppend = runAppend; + exports.runDestroy = runDestroy; - return BlockOpcode; - })(_glimmerRuntimeLibOpcodes.UpdatingOpcode); + function runAppend(view) { + _emberMetal.run(view, 'appendTo', '#qunit-fixture'); + } - exports.BlockOpcode = BlockOpcode; + function runDestroy(toDestroy) { + if (toDestroy) { + _emberMetal.run(toDestroy, 'destroy'); + } + } +}); +enifed('internal-test-helpers/strip', ['exports'], function (exports) { + 'use strict'; - var TryOpcode = (function (_BlockOpcode) { - babelHelpers.inherits(TryOpcode, _BlockOpcode); + exports.default = strip; - function TryOpcode(ops, state, bounds, children) { - _BlockOpcode.call(this, ops, state, bounds, children); - this.type = "try"; - this.tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - } + function strip(_ref) { + for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + values[_key - 1] = arguments[_key]; + } - TryOpcode.prototype.didInitializeChildren = function didInitializeChildren() { - this._tag.update(_glimmerReference.combineSlice(this.children)); - }; + var strings = _ref; - TryOpcode.prototype.evaluate = function evaluate(vm) { - vm.try(this.children, this); - }; + var str = strings.map(function (string, index) { + var interpolated = values[index]; + return string + (interpolated !== undefined ? interpolated : ''); + }).join(''); + return str.split('\n').map(function (s) { + return s.trim(); + }).join(''); + } +}); +enifed('internal-test-helpers/test-cases/abstract-application', ['exports', 'ember-metal', 'ember-views', 'ember-application', 'ember-routing', 'ember-template-compiler', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/run'], function (exports, _emberMetal, _emberViews, _emberApplication, _emberRouting, _emberTemplateCompiler, _internalTestHelpersTestCasesAbstract, _internalTestHelpersRun) { + 'use strict'; - TryOpcode.prototype.handleException = function handleException() { - var env = this.env; - var scope = this.scope; - var ops = this.ops; - var dynamicScope = this.dynamicScope; - var frame = this.frame; - - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.resume(this.env, this.bounds, this.bounds.reset(env)); - var vm = new _glimmerRuntimeLibVmAppend.default(env, scope, dynamicScope, elementStack); - var result = vm.resume(ops, frame); - this.children = result.opcodes(); - this.didInitializeChildren(); - }; + var AbstractApplicationTestCase = (function (_AbstractTestCase) { + babelHelpers.inherits(AbstractApplicationTestCase, _AbstractTestCase); - TryOpcode.prototype.toJSON = function toJSON() { - var json = _BlockOpcode.prototype.toJSON.call(this); - var begin = this.ops.head(); - var end = this.ops.tail(); - json["details"]["begin"] = JSON.stringify(begin.inspect()); - json["details"]["end"] = JSON.stringify(end.inspect()); - return _BlockOpcode.prototype.toJSON.call(this); - }; + function AbstractApplicationTestCase() { + _AbstractTestCase.call(this); - return TryOpcode; - })(BlockOpcode); + this.element = _emberViews.jQuery('#qunit-fixture')[0]; - exports.TryOpcode = TryOpcode; + this.application = _emberMetal.run(_emberApplication.Application, 'create', this.applicationOptions); - var ListRevalidationDelegate = (function () { - function ListRevalidationDelegate(opcode, marker) { - this.opcode = opcode; - this.marker = marker; - this.didInsert = false; - this.didDelete = false; - this.map = opcode.map; - this.updating = opcode['children']; - } + this.router = this.application.Router = _emberRouting.Router.extend(this.routerOptions); - ListRevalidationDelegate.prototype.insert = function insert(key, item, memo, before) { - var map = this.map; - var opcode = this.opcode; - var updating = this.updating; + this.applicationInstance = null; + } - var nextSibling = null; - var reference = null; - if (before) { - reference = map[before]; - nextSibling = reference.bounds.firstNode(); - } else { - nextSibling = this.marker; - } - var vm = opcode.vmForInsertion(nextSibling); - var tryOpcode = undefined; - vm.execute(opcode.ops, function (vm) { - vm.frame.setArgs(_glimmerRuntimeLibCompiledExpressionsArgs.EvaluatedArgs.positional([item, memo])); - vm.frame.setOperand(item); - vm.frame.setCondition(new _glimmerReference.ConstReference(true)); - vm.frame.setKey(key); - var state = vm.capture(); - var tracker = vm.stack().pushUpdatableBlock(); - tryOpcode = new TryOpcode(opcode.ops, state, tracker, vm.updatingOpcodeStack.current); - }); - tryOpcode.didInitializeChildren(); - updating.insertBefore(tryOpcode, reference); - map[key] = tryOpcode; - this.didInsert = true; - }; + AbstractApplicationTestCase.prototype.teardown = function teardown() { + if (this.applicationInstance) { + _internalTestHelpersRun.runDestroy(this.applicationInstance); + } - ListRevalidationDelegate.prototype.retain = function retain(key, item, memo) {}; + _internalTestHelpersRun.runDestroy(this.application); + }; - ListRevalidationDelegate.prototype.move = function move(key, item, memo, before) { - var map = this.map; - var updating = this.updating; + AbstractApplicationTestCase.prototype.visit = function visit(url, options) { + var _this = this; - var entry = map[key]; - var reference = map[before] || null; - if (before) { - _glimmerRuntimeLibBounds.move(entry, reference.firstNode()); - } else { - _glimmerRuntimeLibBounds.move(entry, this.marker); - } - updating.remove(entry); - updating.insertBefore(entry, reference); - }; + var applicationInstance = this.applicationInstance; - ListRevalidationDelegate.prototype.delete = function _delete(key) { - var map = this.map; + if (applicationInstance) { + return _emberMetal.run(applicationInstance, 'visit', url, options); + } else { + return _emberMetal.run(this.application, 'visit', url, options).then(function (instance) { + _this.applicationInstance = instance; + }); + } + }; - var opcode = map[key]; - opcode.didDestroy(); - _glimmerRuntimeLibBounds.clear(opcode); - this.updating.remove(opcode); - delete map[key]; - this.didDelete = true; - }; + AbstractApplicationTestCase.prototype.transitionTo = function transitionTo() { + return _emberMetal.run.apply(undefined, [this.appRouter, 'transitionTo'].concat(babelHelpers.slice.call(arguments))); + }; - ListRevalidationDelegate.prototype.done = function done() { - this.opcode.didInitializeChildren(this.didInsert || this.didDelete); - }; + AbstractApplicationTestCase.prototype.compile = function compile(string, options) { + return _emberTemplateCompiler.compile.apply(undefined, arguments); + }; - return ListRevalidationDelegate; - })(); + AbstractApplicationTestCase.prototype.registerRoute = function registerRoute(name, route) { + this.application.register('route:' + name, route); + }; - var ListBlockOpcode = (function (_BlockOpcode2) { - babelHelpers.inherits(ListBlockOpcode, _BlockOpcode2); + AbstractApplicationTestCase.prototype.registerTemplate = function registerTemplate(name, template) { + this.application.register('template:' + name, this.compile(template, { + moduleName: name + })); + }; - function ListBlockOpcode(ops, state, bounds, children, artifacts) { - _BlockOpcode2.call(this, ops, state, bounds, children); - this.type = "list-block"; - this.map = _glimmerUtil.dict(); - this.lastIterated = _glimmerReference.INITIAL; - this.artifacts = artifacts; - var _tag = this._tag = new _glimmerReference.UpdatableTag(_glimmerReference.CONSTANT_TAG); - this.tag = _glimmerReference.combine([artifacts.tag, _tag]); - } + AbstractApplicationTestCase.prototype.registerComponent = function registerComponent(name, _ref) { + var _ref$ComponentClass = _ref.ComponentClass; + var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; - ListBlockOpcode.prototype.didInitializeChildren = function didInitializeChildren() { - var listDidChange = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; + if (ComponentClass) { + this.application.register('component:' + name, ComponentClass); + } - this.lastIterated = this.artifacts.tag.value(); - if (listDidChange) { - this._tag.update(_glimmerReference.combineSlice(this.children)); - } - }; + if (typeof template === 'string') { + this.application.register('template:components/' + name, this.compile(template, { + moduleName: 'components/' + name + })); + } + }; - ListBlockOpcode.prototype.evaluate = function evaluate(vm) { - var artifacts = this.artifacts; - var lastIterated = this.lastIterated; - - if (!artifacts.tag.validate(lastIterated)) { - var bounds = this.bounds; - var dom = vm.dom; - - var marker = dom.createComment(''); - dom.insertAfter(bounds.parentElement(), marker, bounds.lastNode()); - var target = new ListRevalidationDelegate(this, marker); - var synchronizer = new _glimmerReference.IteratorSynchronizer({ target: target, artifacts: artifacts }); - synchronizer.sync(); - this.parentElement().removeChild(marker); - } - // Run now-updated updating opcodes - _BlockOpcode2.prototype.evaluate.call(this, vm); - }; + AbstractApplicationTestCase.prototype.registerController = function registerController(name, controller) { + this.application.register('controller:' + name, controller); + }; - ListBlockOpcode.prototype.vmForInsertion = function vmForInsertion(nextSibling) { - var env = this.env; - var scope = this.scope; - var dynamicScope = this.dynamicScope; + AbstractApplicationTestCase.prototype.registerEngine = function registerEngine(name, engine) { + this.application.register('engine:' + name, engine); + }; - var elementStack = _glimmerRuntimeLibBuilder.ElementStack.forInitialRender(this.env, this.bounds.parentElement(), nextSibling); - return new _glimmerRuntimeLibVmAppend.default(env, scope, dynamicScope, elementStack); + babelHelpers.createClass(AbstractApplicationTestCase, [{ + key: 'applicationOptions', + get: function () { + return { + rootElement: '#qunit-fixture', + autoboot: false }; - - ListBlockOpcode.prototype.toJSON = function toJSON() { - var json = _BlockOpcode2.prototype.toJSON.call(this); - var map = this.map; - var inner = Object.keys(map).map(function (key) { - return JSON.stringify(key) + ': ' + map[key]._guid; - }).join(", "); - json["details"]["map"] = '{' + inner + '}'; - return json; + } + }, { + key: 'routerOptions', + get: function () { + return { + location: 'none' }; + } + }, { + key: 'appRouter', + get: function () { + return this.applicationInstance.lookup('router:main'); + } + }]); + return AbstractApplicationTestCase; + })(_internalTestHelpersTestCasesAbstract.default); - return ListBlockOpcode; - })(BlockOpcode); + exports.default = AbstractApplicationTestCase; +}); +enifed('internal-test-helpers/test-cases/abstract-rendering', ['exports', 'ember-utils', 'ember-template-compiler', 'ember-views', 'ember-glimmer', 'internal-test-helpers/test-cases/abstract', 'internal-test-helpers/build-owner', 'internal-test-helpers/run'], function (exports, _emberUtils, _emberTemplateCompiler, _emberViews, _emberGlimmer, _internalTestHelpersTestCasesAbstract, _internalTestHelpersBuildOwner, _internalTestHelpersRun) { + 'use strict'; - exports.ListBlockOpcode = ListBlockOpcode; + var TextNode = window.Text; - var UpdatingVMFrame = (function () { - function UpdatingVMFrame(vm, ops, handler) { - this.vm = vm; - this.ops = ops; - this.current = ops.head(); - this.exceptionHandler = handler; - } + var AbstractRenderingTestCase = (function (_AbstractTestCase) { + babelHelpers.inherits(AbstractRenderingTestCase, _AbstractTestCase); - UpdatingVMFrame.prototype.goto = function goto(op) { - this.current = op; - }; + function AbstractRenderingTestCase() { + _AbstractTestCase.call(this); + var owner = this.owner = _internalTestHelpersBuildOwner.default({ + ownerOptions: this.getOwnerOptions(), + bootOptions: this.getBootOptions(), + resolver: this.getResolver() + }); - UpdatingVMFrame.prototype.nextStatement = function nextStatement() { - var current = this.current; - var ops = this.ops; + this.renderer = this.owner.lookup('renderer:-dom'); + this.element = _emberViews.jQuery('#qunit-fixture')[0]; + this.component = null; - if (current) this.current = ops.nextNode(current); - return current; - }; + owner.register('event_dispatcher:main', _emberViews.EventDispatcher); + owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); + owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); + } - UpdatingVMFrame.prototype.handleException = function handleException() { - this.exceptionHandler.handleException(); - }; + AbstractRenderingTestCase.prototype.compile = function compile() { + return _emberTemplateCompiler.compile.apply(undefined, arguments); + }; - return UpdatingVMFrame; - })(); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvdm0vdXBkYXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztRQTRCQSxVQUFBO0FBTUUsaUJBTkYsVUFBQSxDQU1jLEdBQWdCLEVBQUUsSUFBNEIsRUFBQTt3Q0FBNUIsSUFBNEIsQ0FBMUIsZ0JBQWdCO2dCQUFoQixnQkFBZ0IseUNBQUcsS0FBSzs7QUFGaEQsZ0JBQUEsQ0FBQSxVQUFVLEdBQTJCLGlCQTdCdEIsS0FBSyxFQTZCNkMsQ0FBQztBQUd4RSxnQkFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUM7QUFDZixnQkFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsTUFBTSxFQUFFLENBQUM7QUFDeEIsZ0JBQUksQ0FBQyxnQkFBZ0IsR0FBRyxnQkFBZ0IsQ0FBQztTQUMxQzs7QUFWSCxrQkFBQSxXQVlFLE9BQU8sR0FBQSxpQkFBQyxPQUFzQixFQUFFLE9BQXlCLEVBQUE7Z0JBQ2pELFVBQVUsR0FBSyxJQUFJLENBQW5CLFVBQVU7O0FBRWhCLGdCQUFJLENBQUMsR0FBRyxDQUFDLE9BQU8sRUFBRSxPQUFPLENBQUMsQ0FBQztBQUUzQixtQkFBTyxJQUFJLEVBQUU7QUFDWCxvQkFBSSxVQUFVLENBQUMsT0FBTyxFQUFFLEVBQUUsTUFBTTtBQUVoQyxvQkFBSSxNQUFNLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsYUFBYSxFQUFFLENBQUM7QUFFckQsb0JBQUksTUFBTSxLQUFL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Y3VycmVudDogVXBkYXRpbmdPcGNvZGU7XG4gIHByaXZhdGUgZXhjZXB0aW9uSGFuZGxlcjogRXhjZXB0aW9uSGFuZGxlcjtcblxuICBjb25zdHJ1Y3Rvcih2bTogVXBkYXRpbmdWTSwgb3BzOiBVcGRhdGluZ09wU2VxLCBoYW5kbGVyOiBFeGNlcHRpb25IYW5kbGVyKSB7XG4gICAgdGhpcy52bSA9IHZtO1xuICAgIHRoaXMub3BzID0gb3BzO1xuICAgIHRoaXMuY3VycmVudCA9IG9wcy5oZWFkKCk7XG4gICAgdGhpcy5leGNlcHRpb25IYW5kbGVyID0gaGFuZGxlcjtcbiAgfVxuXG4gIGdvdG8ob3A6IFVwZGF0aW5nT3Bjb2RlKSB7XG4gICAgdGhpcy5jdXJyZW50ID0gb3A7XG4gIH1cblxuICBuZXh0U3RhdGVtZW50KCk6IFVwZGF0aW5nT3Bjb2RlIHtcbiAgICBsZXQgeyBjdXJyZW50LCBvcHMgfSA9IHRoaXM7XG4gICAgaWYgKGN1cnJlbnQpIHRoaXMuY3VycmVudCA9IG9wcy5uZXh0Tm9kZShjdXJyZW50KTtcbiAgICByZXR1cm4gY3VycmVudDtcbiAgfVxuXG4gIGhhbmRsZUV4Y2VwdGlvbigpIHtcbiAgICB0aGlzLmV4Y2VwdGlvbkhhbmRsZXIuaGFuZGxlRXhjZXB0aW9uKCk7XG4gIH1cbn1cbiJdfQ== -enifed('glimmer-util/index', ['exports', 'glimmer-util/lib/namespaces', 'glimmer-util/lib/platform-utils', 'glimmer-util/lib/assert', 'glimmer-util/lib/logger', 'glimmer-util/lib/object-utils', 'glimmer-util/lib/guid', 'glimmer-util/lib/collections', 'glimmer-util/lib/list-utils'], function (exports, _glimmerUtilLibNamespaces, _glimmerUtilLibPlatformUtils, _glimmerUtilLibAssert, _glimmerUtilLibLogger, _glimmerUtilLibObjectUtils, _glimmerUtilLibGuid, _glimmerUtilLibCollections, _glimmerUtilLibListUtils) { - 'use strict'; + AbstractRenderingTestCase.prototype.getCustomDispatcherEvents = function getCustomDispatcherEvents() { + return {}; + }; - exports.getAttrNamespace = _glimmerUtilLibNamespaces.getAttrNamespace; - exports.Option = _glimmerUtilLibPlatformUtils.Option; - exports.Maybe = _glimmerUtilLibPlatformUtils.Maybe; - exports.Opaque = _glimmerUtilLibPlatformUtils.Opaque; - exports.assert = _glimmerUtilLibAssert.default; - exports.LOGGER = _glimmerUtilLibLogger.default; - exports.Logger = _glimmerUtilLibLogger.Logger; - exports.LogLevel = _glimmerUtilLibLogger.LogLevel; - exports.assign = _glimmerUtilLibObjectUtils.assign; - exports.ensureGuid = _glimmerUtilLibGuid.ensureGuid; - exports.initializeGuid = _glimmerUtilLibGuid.initializeGuid; - exports.HasGuid = _glimmerUtilLibGuid.HasGuid; - exports.Stack = _glimmerUtilLibCollections.Stack; - exports.Dict = _glimmerUtilLibCollections.Dict; - exports.Set = _glimmerUtilLibCollections.Set; - exports.DictSet = _glimmerUtilLibCollections.DictSet; - exports.dict = _glimmerUtilLibCollections.dict; - exports.EMPTY_SLICE = _glimmerUtilLibListUtils.EMPTY_SLICE; - exports.LinkedList = _glimmerUtilLibListUtils.LinkedList; - exports.LinkedListNode = _glimmerUtilLibListUtils.LinkedListNode; - exports.ListNode = _glimmerUtilLibListUtils.ListNode; - exports.CloneableListNode = _glimmerUtilLibListUtils.CloneableListNode; - exports.ListSlice = _glimmerUtilLibListUtils.ListSlice; - exports.Slice = _glimmerUtilLibListUtils.Slice; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7VUFJUyxnQkFBZ0IsNkJBQWhCLGdCQUFnQjtVQUNoQixNQUFNLGdDQUFOLE1BQU07VUFBRSxLQUFLLGdDQUFMLEtBQUs7VUFBRSxNQUFNLGdDQUFOLE1BQU07VUFDVixNQUFNLHlCQUFqQixPQUFPO1VBQ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zdXJlR3VpZCwgaW5pdGlhbGl6ZUd1aWQsIEhhc0d1aWQgfSBmcm9tICcuL2xpYi9ndWlkJztcblxuZXhwb3J0IHsgU3RhY2ssIERpY3QsIFNldCwgRGljdFNldCwgZGljdCB9IGZyb20gJy4vbGliL2NvbGxlY3Rpb25zJztcbmV4cG9ydCB7IEVNUFRZX1NMSUNFLCBMaW5rZWRMaXN0LCBMaW5rZWRMaXN0Tm9kZSwgTGlzdE5vZGUsIENsb25lYWJsZUxpc3ROb2RlLCBMaXN0U2xpY2UsIFNsaWNlIH0gZnJvbSAnLi9saWIvbGlzdC11dGlscyc7XG5cbmV4cG9ydCB0eXBlIEZJWE1FPFQsIHN0cmluZz4gPSBUO1xuIl19 -enifed("glimmer-util/lib/assert", ["exports"], function (exports) { - // import Logger from './logger'; - // let alreadyWarned = false; - "use strict"; + AbstractRenderingTestCase.prototype.getOwnerOptions = function getOwnerOptions() {}; - exports.debugAssert = debugAssert; - exports.prodAssert = prodAssert; + AbstractRenderingTestCase.prototype.getBootOptions = function getBootOptions() {}; - function debugAssert(test, msg) { - // if (!alreadyWarned) { - // alreadyWarned = true; - // Logger.warn("Don't leave debug assertions on in public builds"); - // } - if (!test) { - throw new Error(msg || "assertion failure"); - } - } + AbstractRenderingTestCase.prototype.getResolver = function getResolver() {}; + + AbstractRenderingTestCase.prototype.teardown = function teardown() { + if (this.component) { + _internalTestHelpersRun.runDestroy(this.component); + } + if (this.owner) { + _internalTestHelpersRun.runDestroy(this.owner); + } + }; - function prodAssert() {} + AbstractRenderingTestCase.prototype.render = function render(templateStr) { + var context = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var owner = this.owner; - exports.default = debugAssert; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvYXNzZXJ0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBSUEsYUFBQSxXQUFBLENBQTRCLElBQUksRUFBRSxHQUFHLEVBQUE7Ozs7O0FBTW5DLFlBQUksQ0FBQyxJQUFJLEVBQUU7QUFDVCxrQkFBTSxJQUFJLEtBQUssQ0FBQyxHQUFHLElBQUksbUJBQW1CLENBQUMsQ0FBQztTQUM3QztLQUNGOztBQUVELGFBQUEsVUFBQSxHQUFBLEVBQStCOztzQkFFaEIsV0FBVyIsImZpbGUiOiJhc3NlcnQuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBpbXBvcnQgTG9nZ2VyIGZyb20gJy4vbG9nZ2VyJztcblxuLy8gbGV0IGFscmVhZHlXYXJuZWQgPSBmYWxzZTtcblxuZXhwb3J0IGZ1bmN0aW9uIGRlYnVnQXNzZXJ0KHRlc3QsIG1zZykge1xuICAvLyBpZiAoIWFscmVhZHlXYXJuZWQpIHtcbiAgLy8gICBhbHJlYWR5V2FybmVkID0gdHJ1ZTtcbiAgLy8gICBMb2dnZXIud2FybihcIkRvbid0IGxlYXZlIGRlYnVnIGFzc2VydGlvbnMgb24gaW4gcHVibGljIGJ1aWxkc1wiKTtcbiAgLy8gfVxuXG4gIGlmICghdGVzdCkge1xuICAgIHRocm93IG5ldyBFcnJvcihtc2cgfHwgXCJhc3NlcnRpb24gZmFpbHVyZVwiKTtcbiAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gcHJvZEFzc2VydCgpIHt9XG5cbmV4cG9ydCBkZWZhdWx0IGRlYnVnQXNzZXJ0O1xuIl19 -enifed('glimmer-util/lib/collections', ['exports', 'glimmer-util/lib/guid'], function (exports, _glimmerUtilLibGuid) { - 'use strict'; + owner.register('template:-top-level', this.compile(templateStr, { + moduleName: '-top-level' + })); - exports.dict = dict; + var attrs = _emberUtils.assign({}, context, { + tagName: '', + layoutName: '-top-level' + }); - var proto = Object.create(null, { - // without this, we will always still end up with (new - // EmptyObject()).constructor === Object - constructor: { - value: undefined, - enumerable: false, - writable: true - } - }); - function EmptyObject() {} - EmptyObject.prototype = proto; + owner.register('component:-top-level', _emberGlimmer.Component.extend(attrs)); - function dict() { - // let d = Object.create(null); - // d.x = 1; - // delete d.x; - // return d; - return new EmptyObject(); - } + this.component = owner.lookup('component:-top-level'); - var DictSet = (function () { - function DictSet() { - this.dict = dict(); - } + _internalTestHelpersRun.runAppend(this.component); + }; - DictSet.prototype.add = function add(obj) { - if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[_glimmerUtilLibGuid.ensureGuid(obj)] = obj; - return this; - }; + AbstractRenderingTestCase.prototype.rerender = function rerender() { + this.component.rerender(); + }; - DictSet.prototype.delete = function _delete(obj) { - if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; - }; + AbstractRenderingTestCase.prototype.registerHelper = function registerHelper(name, funcOrClassBody) { + var type = typeof funcOrClassBody; - DictSet.prototype.forEach = function forEach(callback) { - var dict = this.dict; + if (type === 'function') { + this.owner.register('helper:' + name, _emberGlimmer.helper(funcOrClassBody)); + } else if (type === 'object' && type !== null) { + this.owner.register('helper:' + name, _emberGlimmer.Helper.extend(funcOrClassBody)); + } else { + throw new Error('Cannot register ' + funcOrClassBody + ' as a helper'); + } + }; - Object.keys(dict).forEach(function (key) { - return callback(dict[key]); - }); - }; + AbstractRenderingTestCase.prototype.registerPartial = function registerPartial(name, template) { + var owner = this.env.owner || this.owner; + if (typeof template === 'string') { + var moduleName = 'template:' + name; + owner.register(moduleName, this.compile(template, { moduleName: moduleName })); + } + }; - DictSet.prototype.toArray = function toArray() { - return Object.keys(this.dict); - }; + AbstractRenderingTestCase.prototype.registerComponent = function registerComponent(name, _ref) { + var _ref$ComponentClass = _ref.ComponentClass; + var ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass; + var _ref$template = _ref.template; + var template = _ref$template === undefined ? null : _ref$template; + var owner = this.owner; - return DictSet; - })(); + if (ComponentClass) { + owner.register('component:' + name, ComponentClass); + } - exports.DictSet = DictSet; + if (typeof template === 'string') { + owner.register('template:components/' + name, this.compile(template, { + moduleName: 'components/' + name + })); + } + }; - var Stack = (function () { - function Stack() { - this.stack = []; - this.current = null; - } + AbstractRenderingTestCase.prototype.registerTemplate = function registerTemplate(name, template) { + var owner = this.owner; - Stack.prototype.push = function push(item) { - this.current = item; - this.stack.push(item); - }; + if (typeof template === 'string') { + owner.register('template:' + name, this.compile(template, { + moduleName: name + })); + } else { + throw new Error('Registered template "' + name + '" must be a string'); + } + }; - Stack.prototype.pop = function pop() { - var item = this.stack.pop(); - var len = this.stack.length; - this.current = len === 0 ? null : this.stack[len - 1]; - return item; - }; + AbstractRenderingTestCase.prototype.registerService = function registerService(name, klass) { + this.owner.register('service:' + name, klass); + }; - Stack.prototype.isEmpty = function isEmpty() { - return this.stack.length === 0; - }; + AbstractRenderingTestCase.prototype.assertTextNode = function assertTextNode(node, text) { + if (!(node instanceof TextNode)) { + throw new Error('Expecting a text node, but got ' + node); + } - return Stack; - })(); + this.assert.strictEqual(node.textContent, text, 'node.textContent'); + }; - exports.Stack = Stack; + babelHelpers.createClass(AbstractRenderingTestCase, [{ + key: 'context', + get: function () { + return this.component; + } + }]); + return AbstractRenderingTestCase; + })(_internalTestHelpersTestCasesAbstract.default); + + exports.default = AbstractRenderingTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvY29sbGVjdGlvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFZQSxRQUFJLEtBQUssR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRTs7O0FBRzlCLG1CQUFXLEVBQUU7QUFDWCxpQkFBSyxFQUFFLFNBQVM7QUFDaEIsc0JBQVUsRUFBRSxLQUFLO0FBQ2pCLG9CQUFRLEVBQUUsSUFBSTtTQUNmO0tBQ0YsQ0FBQyxDQUFDO0FBRUgsYUFBQSxXQUFBLEdBQUEsRUFBeUI7QUFDekIsZUFBVyxDQUFDLFN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uc3RhY2subGVuZ3RoO1xuICAgIHRoaXMuY3VycmVudCA9IGxlbiA9PT0gMCA/IG51bGwgOiB0aGlzLnN0YWNrW2xlbiAtIDFdO1xuXG4gICAgcmV0dXJuIGl0ZW07XG4gIH1cblxuICBpc0VtcHR5KCk6IGJvb2xlYW4ge1xuICAgIHJldHVybiB0aGlzLnN0YWNrLmxlbmd0aCA9PT0gMDtcbiAgfVxufVxuIl19 -enifed("glimmer-util/lib/guid", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-cases/abstract', ['exports', 'ember-utils', 'ember-metal', 'ember-views', 'internal-test-helpers/equal-inner-html', 'internal-test-helpers/equal-tokens', 'internal-test-helpers/matchers'], function (exports, _emberUtils, _emberMetal, _emberViews, _internalTestHelpersEqualInnerHtml, _internalTestHelpersEqualTokens, _internalTestHelpersMatchers) { + 'use strict'; - exports.initializeGuid = initializeGuid; - exports.ensureGuid = ensureGuid; - var GUID = 0; + var TextNode = window.Text; + var HTMLElement = window.HTMLElement; + var Comment = window.Comment; - function initializeGuid(object) { - return object._guid = ++GUID; + function isMarker(node) { + if (node instanceof Comment && node.textContent === '') { + return true; } - function ensureGuid(object) { - return object._guid || initializeGuid(object); + if (node instanceof TextNode && node.textContent === '') { + return true; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvZ3VpZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLFFBQUksSUFBSSxHQUFHLENBQUMsQ0FBQzs7QUFNYixhQUFBLGNBQUEsQ0FBK0IsTUFBZSxFQUFBO0FBQzVDLGVBQVEsTUFBTSxDQUFDLEtBQUssR0FBRyxFQUFFLElBQUksQ0FBRTtLQUNoQzs7QUFFRCxhQUFBLFVBQUEsQ0FBMkIsTUFBZSxFQUFBO0FBQ3hDLGVBQU8sTUFBTSxDQUFDLEtBQUssSUFBSSxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUM7S0FDL0MiLCJmaWxlIjoiZ3VpZC5qcyIsInNvdXJjZXNDb250ZW50IjpbImxldCBHVUlEID0gMDtcblxuZXhwb3J0IGludGVyZmFjZSBIYXNHdWlkIHtcbiAgX2d1aWQ6IG51bWJlcjtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGluaXRpYWxpemVHdWlkKG9iamVjdDogSGFzR3VpZCk6IG51bWJlciB7XG4gIHJldHVybiAob2JqZWN0Ll9ndWlkID0gKytHVUlEKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGVuc3VyZUd1aWQob2JqZWN0OiBIYXNHdWlkKTogbnVtYmVyIHtcbiAgcmV0dXJuIG9iamVjdC5fZ3VpZCB8fCBpbml0aWFsaXplR3VpZChvYmplY3QpO1xufSJdfQ== -enifed("glimmer-util/lib/list-utils", ["exports"], function (exports) { - "use strict"; - var ListNode = function ListNode(value) { - this.next = null; - this.prev = null; - this.value = value; - }; + return false; + } - exports.ListNode = ListNode; + var AbstractTestCase = (function () { + function AbstractTestCase() { + this.element = null; + this.snapshot = null; + this.assert = QUnit.config.current.assert; + } - var LinkedList = (function () { - function LinkedList() { - this.clear(); - } + AbstractTestCase.prototype.teardown = function teardown() {}; - LinkedList.fromSlice = function fromSlice(slice) { - var list = new LinkedList(); - slice.forEachNode(function (n) { - return list.append(n.clone()); - }); - return list; - }; + AbstractTestCase.prototype.runTask = function runTask(callback) { + _emberMetal.run(callback); + }; - LinkedList.prototype.head = function head() { - return this._head; - }; + AbstractTestCase.prototype.runTaskNext = function runTaskNext(callback) { + _emberMetal.run.next(callback); + }; - LinkedList.prototype.tail = function tail() { - return this._tail; - }; + // The following methods require `this.element` to work - LinkedList.prototype.clear = function clear() { - this._head = this._tail = null; - }; + AbstractTestCase.prototype.nthChild = function nthChild(n) { + var i = 0; + var node = this.element.firstChild; - LinkedList.prototype.isEmpty = function isEmpty() { - return this._head === null; - }; + while (node) { + if (!isMarker(node)) { + i++; + } - LinkedList.prototype.toArray = function toArray() { - var out = []; - this.forEachNode(function (n) { - return out.push(n); - }); - return out; - }; + if (i > n) { + break; + } else { + node = node.nextSibling; + } + } - LinkedList.prototype.splice = function splice(start, end, reference) { - var before = undefined; - if (reference === null) { - before = this._tail; - this._tail = end; - } else { - before = reference.prev; - end.next = reference; - reference.prev = end; - } - if (before) { - before.next = start; - start.prev = before; - } - }; + return node; + }; - LinkedList.prototype.spliceList = function spliceList(list, reference) { - if (list.isEmpty()) return; - this.splice(list.head(), list.tail(), reference); - }; + AbstractTestCase.prototype.$ = function $(sel) { + return sel ? _emberViews.jQuery(sel, this.element) : _emberViews.jQuery(this.element); + }; - LinkedList.prototype.nextNode = function nextNode(node) { - return node.next; - }; + AbstractTestCase.prototype.textValue = function textValue() { + return this.$().text(); + }; - LinkedList.prototype.prevNode = function prevNode(node) { - return node.prev; - }; + AbstractTestCase.prototype.takeSnapshot = function takeSnapshot() { + var snapshot = this.snapshot = []; - LinkedList.prototype.forEachNode = function forEachNode(callback) { - var node = this._head; - while (node !== null) { - callback(node); - node = node.next; - } - }; + var node = this.element.firstChild; - LinkedList.prototype.contains = function contains(needle) { - var node = this._head; - while (node !== null) { - if (node === needle) return true; - node = node.next; - } - return false; - }; + while (node) { + if (!isMarker(node)) { + snapshot.push(node); + } - LinkedList.prototype.insertBefore = function insertBefore(node) { - var reference = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + node = node.nextSibling; + } - if (reference === null) return this.append(node); - if (reference.prev) reference.prev.next = node;else this._head = node; - node.prev = reference.prev; - node.next = reference; - reference.prev = node; - return node; - }; + return snapshot; + }; - LinkedList.prototype.append = function append(node) { - var tail = this._tail; - if (tail) { - tail.next = node; - node.prev = tail; - node.next = null; - } else { - this._head = node; - } - return this._tail = node; - }; + AbstractTestCase.prototype.assertText = function assertText(text) { + this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content should be: `' + text + '`'); + }; - LinkedList.prototype.pop = function pop() { - if (this._tail) return this.remove(this._tail); - return null; - }; + AbstractTestCase.prototype.assertInnerHTML = function assertInnerHTML(html) { + _internalTestHelpersEqualInnerHtml.default(this.element, html); + }; - LinkedList.prototype.prepend = function prepend(node) { - if (this._head) return this.insertBefore(node, this._head); - return this._head = this._tail = node; - }; + AbstractTestCase.prototype.assertHTML = function assertHTML(html) { + _internalTestHelpersEqualTokens.default(this.element, html, '#qunit-fixture content should be: `' + html + '`'); + }; - LinkedList.prototype.remove = function remove(node) { - if (node.prev) node.prev.next = node.next;else this._head = node.next; - if (node.next) node.next.prev = node.prev;else this._tail = node.prev; - return node; - }; + AbstractTestCase.prototype.assertElement = function assertElement(node, _ref) { + var _ref$ElementType = _ref.ElementType; + var ElementType = _ref$ElementType === undefined ? HTMLElement : _ref$ElementType; + var tagName = _ref.tagName; + var _ref$attrs = _ref.attrs; + var attrs = _ref$attrs === undefined ? null : _ref$attrs; + var _ref$content = _ref.content; + var content = _ref$content === undefined ? null : _ref$content; - return LinkedList; - })(); + if (!(node instanceof ElementType)) { + throw new Error('Expecting a ' + ElementType.name + ', but got ' + node); + } - exports.LinkedList = LinkedList; + _internalTestHelpersMatchers.equalsElement(node, tagName, attrs, content); + }; - var LinkedListRemover = (function () { - function LinkedListRemover(node) { - this.node = node; - } + AbstractTestCase.prototype.assertComponentElement = function assertComponentElement(node, _ref2) { + var _ref2$ElementType = _ref2.ElementType; + var ElementType = _ref2$ElementType === undefined ? HTMLElement : _ref2$ElementType; + var _ref2$tagName = _ref2.tagName; + var tagName = _ref2$tagName === undefined ? 'div' : _ref2$tagName; + var _ref2$attrs = _ref2.attrs; + var attrs = _ref2$attrs === undefined ? null : _ref2$attrs; + var _ref2$content = _ref2.content; + var content = _ref2$content === undefined ? null : _ref2$content; - LinkedListRemover.prototype.destroy = function destroy() { - var _node = this.node; - var prev = _node.prev; - var next = _node.next; + attrs = _emberUtils.assign({}, { id: _internalTestHelpersMatchers.regex(/^ember\d*$/), class: _internalTestHelpersMatchers.classes('ember-view') }, attrs || {}); + this.assertElement(node, { ElementType: ElementType, tagName: tagName, attrs: attrs, content: content }); + }; - prev.next = next; - next.prev = prev; - }; + AbstractTestCase.prototype.assertSameNode = function assertSameNode(actual, expected) { + this.assert.strictEqual(actual, expected, 'DOM node stability'); + }; - return LinkedListRemover; - })(); + AbstractTestCase.prototype.assertInvariants = function assertInvariants(oldSnapshot, newSnapshot) { + oldSnapshot = oldSnapshot || this.snapshot; + newSnapshot = newSnapshot || this.takeSnapshot(); - var ListSlice = (function () { - function ListSlice(head, tail) { - this._head = head; - this._tail = tail; - } + this.assert.strictEqual(newSnapshot.length, oldSnapshot.length, 'Same number of nodes'); - ListSlice.toList = function toList(slice) { - var list = new LinkedList(); - slice.forEachNode(function (n) { - return list.append(n.clone()); - }); - return list; - }; + for (var i = 0; i < oldSnapshot.length; i++) { + this.assertSameNode(newSnapshot[i], oldSnapshot[i]); + } + }; - ListSlice.prototype.forEachNode = function forEachNode(callback) { - var node = this._head; - while (node !== null) { - callback(node); - node = this.nextNode(node); - } - }; + AbstractTestCase.prototype.assertPartialInvariants = function assertPartialInvariants(start, end) { + this.assertInvariants(this.snapshot, this.takeSnapshot().slice(start, end)); + }; - ListSlice.prototype.contains = function contains(needle) { - var node = this._head; - while (node !== null) { - if (node === needle) return true; - node = node.next; - } - return false; - }; + AbstractTestCase.prototype.assertStableRerender = function assertStableRerender() { + var _this = this; - ListSlice.prototype.head = function head() { - return this._head; - }; + this.takeSnapshot(); + this.runTask(function () { + return _this.rerender(); + }); + this.assertInvariants(); + }; - ListSlice.prototype.tail = function tail() { - return this._tail; - }; + babelHelpers.createClass(AbstractTestCase, [{ + key: 'firstChild', + get: function () { + return this.nthChild(0); + } + }, { + key: 'nodesCount', + get: function () { + var count = 0; + var node = this.element.firstChild; - ListSlice.prototype.toArray = function toArray() { - var out = []; - this.forEachNode(function (n) { - return out.push(n); - }); - return out; - }; + while (node) { + if (!isMarker(node)) { + count++; + } - ListSlice.prototype.nextNode = function nextNode(node) { - if (node === this._tail) return null; - return node.next; - }; + node = node.nextSibling; + } - ListSlice.prototype.prevNode = function prevNode(node) { - if (node === this._head) return null; - return node.prev; - }; + return count; + } + }]); + return AbstractTestCase; + })(); - ListSlice.prototype.isEmpty = function isEmpty() { - return false; - }; + exports.default = AbstractTestCase; +}); +enifed('internal-test-helpers/test-cases/application', ['exports', 'internal-test-helpers/test-cases/abstract-application'], function (exports, _internalTestHelpersTestCasesAbstractApplication) { + 'use strict'; - return ListSlice; - })(); + var ApplicationTestCase = (function (_AbstractApplicationTestCase) { + babelHelpers.inherits(ApplicationTestCase, _AbstractApplicationTestCase); - exports.ListSlice = ListSlice; - var EMPTY_SLICE = new ListSlice(null, null); - exports.EMPTY_SLICE = EMPTY_SLICE; -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbGlzdC11dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7UUFTQSxRQUFBLEdBS0UsU0FMRixRQUFBLENBS2MsS0FBUSxFQUFBO0FBSmIsWUFBQSxDQUFBLElBQUksR0FBZ0IsSUFBSSxDQUFDO0FBQ3pCLFlBQUEsQ0FBQSxJQUFJLEdBQWdCLElBQUksQ0FBQztBQUk5QixZQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQztLQUNwQjs7OztRQU9ILFVBQUE7QUFVRSxpQkFWRixVQUFBLEdBVUU7QUFDRSxnQkFBSSxDQUFDLEtBQUssRUFBRSxDQUFDO1NBQ2Q7O0FBWkgsa0JBQUEsQ0FDUyxTQUFTLEdBQUEsbUJBQThCLEtBQWUsRUFBQTtBQUMzRCxnQkFBSSxJQUFJLEdBQUcsSUFBSSxVQUFVLEVBQUssQ0FBQztBQUMvQixpQkFBSyxDQUFDLFdBQVcsQ0FBQyxVQUFBLENBQUM7dUJBQUksSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7YUF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4gICAgcmV0dXJuIHRoaXMuX2hlYWQ7XG4gIH1cblxuICB0YWlsKCk6IFQge1xuICAgIHJldHVybiB0aGlzLl90YWlsO1xuICB9XG5cbiAgdG9BcnJheSgpOiBUW10ge1xuICAgIGxldCBvdXQgPSBbXTtcbiAgICB0aGlzLmZvckVhY2hOb2RlKG4gPT4gb3V0LnB1c2gobikpO1xuICAgIHJldHVybiBvdXQ7XG4gIH1cblxuICBuZXh0Tm9kZShub2RlOiBUKTogVCB7XG4gICAgaWYgKG5vZGUgPT09IHRoaXMuX3RhaWwpIHJldHVybiBudWxsO1xuICAgIHJldHVybiA8VD5ub2RlLm5leHQ7XG4gIH1cblxuICBwcmV2Tm9kZShub2RlOiBUKTogVCB7XG4gICAgaWYgKG5vZGUgPT09IHRoaXMuX2hlYWQpIHJldHVybiBudWxsO1xuICAgIHJldHVybiA8VD5ub2RlLnByZXY7XG4gIH1cblxuICBpc0VtcHR5KCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxufVxuXG5leHBvcnQgY29uc3QgRU1QVFlfU0xJQ0UgPSBuZXcgTGlzdFNsaWNlKG51bGwsIG51bGwpO1xuIl19 -enifed("glimmer-util/lib/logger", ["exports"], function (exports) { - "use strict"; + function ApplicationTestCase() { + _AbstractApplicationTestCase.apply(this, arguments); + } - var LogLevel; - exports.LogLevel = LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["Trace"] = 0] = "Trace"; - LogLevel[LogLevel["Debug"] = 1] = "Debug"; - LogLevel[LogLevel["Warn"] = 2] = "Warn"; - LogLevel[LogLevel["Error"] = 3] = "Error"; - })(LogLevel || (exports.LogLevel = LogLevel = {})); + return ApplicationTestCase; + })(_internalTestHelpersTestCasesAbstractApplication.default); - var NullConsole = (function () { - function NullConsole() {} + exports.default = ApplicationTestCase; +}); +enifed('internal-test-helpers/test-cases/query-param', ['exports', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers/test-cases/application'], function (exports, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpersTestCasesApplication) { + 'use strict'; - NullConsole.prototype.log = function log(message) {}; + var QueryParamTestCase = (function (_ApplicationTestCase) { + babelHelpers.inherits(QueryParamTestCase, _ApplicationTestCase); - NullConsole.prototype.warn = function warn(message) {}; + function QueryParamTestCase() { + _ApplicationTestCase.call(this); - NullConsole.prototype.error = function error(message) {}; + var testCase = this; + testCase.expectedPushURL = null; + testCase.expectedReplaceURL = null; + this.application.register('location:test', _emberRouting.NoneLocation.extend({ + setURL: function (path) { + if (testCase.expectedReplaceURL) { + testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); + } - NullConsole.prototype.trace = function trace() {}; + if (testCase.expectedPushURL) { + testCase.assert.equal(path, testCase.expectedPushURL, 'an expected pushState occurred'); + testCase.expectedPushURL = null; + } - return NullConsole; - })(); + this.set('path', path); + }, - var Logger = (function () { - function Logger(_ref) { - var console = _ref.console; - var level = _ref.level; + replaceURL: function (path) { + if (testCase.expectedPushURL) { + testCase.assert.ok(false, 'replaceState occurred but a pushState was expected'); + } - this.f = ALWAYS; - this.force = ALWAYS; - this.console = console; - this.level = level; + if (testCase.expectedReplaceURL) { + testCase.assert.equal(path, testCase.expectedReplaceURL, 'an expected replaceState occurred'); + testCase.expectedReplaceURL = null; + } + + this.set('path', path); } + })); + } - Logger.prototype.skipped = function skipped(level) { - return level < this.level; - }; + QueryParamTestCase.prototype.visitAndAssert = function visitAndAssert(path) { + var _this = this; - Logger.prototype.trace = function trace(message) { - var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + return this.visit.apply(this, arguments).then(function () { + _this.assertCurrentPath(path); + }); + }; - var _ref2$stackTrace = _ref2.stackTrace; - var stackTrace = _ref2$stackTrace === undefined ? false : _ref2$stackTrace; + QueryParamTestCase.prototype.getController = function getController(name) { + return this.applicationInstance.lookup('controller:' + name); + }; - if (this.skipped(LogLevel.Trace)) return; - this.console.log(message); - if (stackTrace) this.console.trace(); - }; + QueryParamTestCase.prototype.getRoute = function getRoute(name) { + return this.applicationInstance.lookup('route:' + name); + }; - Logger.prototype.debug = function debug(message) { - var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + QueryParamTestCase.prototype.setAndFlush = function setAndFlush(obj, prop, value) { + return _emberMetal.run(obj, 'set', prop, value); + }; - var _ref3$stackTrace = _ref3.stackTrace; - var stackTrace = _ref3$stackTrace === undefined ? false : _ref3$stackTrace; + QueryParamTestCase.prototype.assertCurrentPath = function assertCurrentPath(path) { + var message = arguments.length <= 1 || arguments[1] === undefined ? 'current path equals \'' + path + '\'' : arguments[1]; + return (function () { + this.assert.equal(this.appRouter.get('location.path'), path, message); + }).apply(this, arguments); + }; - if (this.skipped(LogLevel.Debug)) return; - this.console.log(message); - if (stackTrace) this.console.trace(); - }; + /** + Sets up a Controller for a given route with a single query param and default + value. Can optionally extend the controller with an object. + @public + @method setSingleQPController + */ - Logger.prototype.warn = function warn(message) { - var _ref4 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + QueryParamTestCase.prototype.setSingleQPController = function setSingleQPController(routeName) { + var param = arguments.length <= 1 || arguments[1] === undefined ? 'foo' : arguments[1]; + var defaultValue = arguments.length <= 2 || arguments[2] === undefined ? 'bar' : arguments[2]; - var _ref4$stackTrace = _ref4.stackTrace; - var stackTrace = _ref4$stackTrace === undefined ? false : _ref4$stackTrace; + var _Controller$extend; - if (this.skipped(LogLevel.Warn)) return; - this.console.warn(message); - if (stackTrace) this.console.trace(); - }; + var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; - Logger.prototype.error = function error(message) { - if (this.skipped(LogLevel.Error)) return; - this.console.error(message); - }; + this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend = { + queryParams: [param] + }, _Controller$extend[param] = defaultValue, _Controller$extend), options)); + }; - return Logger; - })(); + /** + Sets up a Controller for a given route with a custom property/url key mapping. + @public + @method setMappedQPController + */ - exports.Logger = Logger; + QueryParamTestCase.prototype.setMappedQPController = function setMappedQPController(routeName) { + var prop = arguments.length <= 1 || arguments[1] === undefined ? 'page' : arguments[1]; + var urlKey = arguments.length <= 2 || arguments[2] === undefined ? 'parentPage' : arguments[2]; + var defaultValue = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3]; - var _console = typeof console === 'undefined' ? new NullConsole() : console; - var ALWAYS = new Logger({ console: _console, level: LogLevel.Trace }); - var LOG_LEVEL = LogLevel.Warn; - exports.default = new Logger({ console: _console, level: LOG_LEVEL }); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbG9nZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLFFBQVksUUFLWCxDQUFBOztBQUxELEtBQUEsVUFBWSxRQUFRLEVBQUE7QUFDbEIsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsT0FBSyxDQUFBO0FBQ0wsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsT0FBSyxDQUFBO0FBQ0wsZ0JBQUEsQ0FBQSxRQUFBLENBQUEsTUFBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsTUFBSSxDQUFBO0FBQ0osZ0JBQUEsQ0FBQSxRQUFBLENBQUEsT0FBQSxDQUFBLEdBQUEsQ0FBQSxDQUFBLEdBQUEsT0FBSyxDQUFBO0tBQ04sQ0FBQSxDQUxXLFFBQVEsYUFBUixRQUtYLEdBTFcsUUFBUSxHQUFBLEVBQUEsQ0FBQSxDQUFBLENBS25COztRQVNELFdBQUE7aUJBQUEsV0FBQTs7QUFBQSxtQkFBQSxXQUNFLEdBQUcsR0FBQSxhQUFDLE9BQWUsRUFBQSxFQUFJOztBQUR6QixtQkFBQSxXQUVFLElBQUksR0FBQSxjQUFDLE9BQWUs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tcblxuY29uc3QgQUxXQVlTID0gbmV3IExvZ2dlcih7IGNvbnNvbGU6IF9jb25zb2xlLCBsZXZlbDogTG9nTGV2ZWwuVHJhY2UgfSk7XG5jb25zdCBMT0dfTEVWRUwgPSBMb2dMZXZlbC5XYXJuO1xuXG5leHBvcnQgZGVmYXVsdCBuZXcgTG9nZ2VyKHsgY29uc29sZTogX2NvbnNvbGUsIGxldmVsOiBMT0dfTEVWRUwgfSk7XG4iXX0= -enifed('glimmer-util/lib/namespaces', ['exports'], function (exports) { - // There is a small whitelist of namespaced attributes specially - // enumerated in - // https://www.w3.org/TR/html/syntax.html#attributes-0 - // - // > When a foreign element has one of the namespaced attributes given by - // > the local name and namespace of the first and second cells of a row - // > from the following table, it must be written using the name given by - // > the third cell from the same row. - // - // In all other cases, colons are interpreted as a regular character - // with no special meaning: - // - // > No other namespaced attribute can be expressed in the HTML syntax. - 'use strict'; + var _queryParams, _Controller$extend2; - exports.getAttrNamespace = getAttrNamespace; - var XLINK = 'http://www.w3.org/1999/xlink'; - var XML = 'http://www.w3.org/XML/1998/namespace'; - var XMLNS = 'http://www.w3.org/2000/xmlns/'; - var WHITELIST = { - 'xlink:actuate': XLINK, - 'xlink:arcrole': XLINK, - 'xlink:href': XLINK, - 'xlink:role': XLINK, - 'xlink:show': XLINK, - 'xlink:title': XLINK, - 'xlink:type': XLINK, - 'xml:base': XML, - 'xml:lang': XML, - 'xml:space': XML, - 'xmlns': XMLNS, - 'xmlns:xlink': XMLNS + var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; + + this.registerController(routeName, _emberRuntime.Controller.extend((_Controller$extend2 = { + queryParams: (_queryParams = {}, _queryParams[prop] = urlKey, _queryParams) + }, _Controller$extend2[prop] = defaultValue, _Controller$extend2), options)); }; - function getAttrNamespace(attrName) { - return WHITELIST[attrName] || null; - } + babelHelpers.createClass(QueryParamTestCase, [{ + key: 'routerOptions', + get: function () { + return { + location: 'test' + }; + } + }]); + return QueryParamTestCase; + })(_internalTestHelpersTestCasesApplication.default); + + exports.default = QueryParamTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvbmFtZXNwYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7OztBQWNBLFFBQU0sS0FBSyxHQUFHLDhCQUE4QixDQUFDO0FBQzdDLFFBQU0sR0FBRyxHQUFHLHNDQUFzQyxDQUFDO0FBQ25ELFFBQU0sS0FBSyxHQUFHLCtCQUErQixDQUFDO0FBRTlDLFFBQU0sU0FBUyxHQUFHO0FBQ2hCLHVCQUFlLEVBQUUsS0FBSztBQUN0Qix1QkFBZSxFQUFFLEtBQUs7QUFDdEIsb0JBQVksRUFBRSxLQUFLO0FBQ25CLG9CQUFZLEVBQUUsS0FBSztBQUNuQixvQkFBWSxFQUFFLEtBQUs7QUFDbkIscUJBQWEsRUFBRSxLQUFLO0FBQ3BCLG9CQUFZLEVBQUUsS0FBSztBQUNuQixrQkFBVSxFQUFFLEdBQUc7QUFDZixrQkFBVSxFQUFFLEdBQUc7QUFDZixtQkFBVyxFQUFFLEdBQUc7QUFDaEIsZUFBTyxFQUFFLEtBQUs7QUFDZCxxQkFBYSxFQUFFLEtBQUs7S0FDckIsQ0FBQzs7QUFFRixhQUFBLGdCQUFBLENBQWlDLFFBQVEsRUFBQTtBQUN2QyxlQUFPLFNBQVMsQ0FBQyxRQUFRLENBQUMsSUFBSSxJQUFJLENBQUM7S0FDcEMiLCJmaWxlIjoibmFtZXNwYWNlcy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vIFRoZXJlIGlzIGEgc21hbGwgd2hpdGVsaXN0IG9mIG5hbWVzcGFjZWQgYXR0cmlidXRlcyBzcGVjaWFsbHlcbi8vIGVudW1lcmF0ZWQgaW5cbi8vIGh0dHBzOi8vd3d3LnczLm9yZy9UUi9odG1sL3N5bnRheC5odG1s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SyxcbiAgJ3htbDpiYXNlJzogWE1MLFxuICAneG1sOmxhbmcnOiBYTUwsXG4gICd4bWw6c3BhY2UnOiBYTUwsXG4gICd4bWxucyc6IFhNTE5TLFxuICAneG1sbnM6eGxpbmsnOiBYTUxOU1xufTtcblxuZXhwb3J0IGZ1bmN0aW9uIGdldEF0dHJOYW1lc3BhY2UoYXR0ck5hbWUpIHtcbiAgcmV0dXJuIFdISVRFTElTVFthdHRyTmFtZV0gfHwgbnVsbDtcbn0iXX0= -enifed('glimmer-util/lib/object-utils', ['exports'], function (exports) { - 'use strict'; +enifed('internal-test-helpers/test-cases/rendering', ['exports', 'ember-views', 'internal-test-helpers/test-cases/abstract-rendering'], function (exports, _emberViews, _internalTestHelpersTestCasesAbstractRendering) { + 'use strict'; - exports.assign = assign; - var objKeys = Object.keys; + var RenderingTestCase = (function (_AbstractRenderingTestCase) { + babelHelpers.inherits(RenderingTestCase, _AbstractRenderingTestCase); - function assign(obj) { - for (var i = 1; i < arguments.length; i++) { - var assignment = arguments[i]; - if (assignment === null || typeof assignment !== 'object') continue; - var keys = objKeys(assignment); - for (var j = 0; j < keys.length; j++) { - var key = keys[j]; - obj[key] = assignment[key]; - } - } - return obj; + function RenderingTestCase() { + _AbstractRenderingTestCase.call(this); + var owner = this.owner; + + this.env = owner.lookup('service:-glimmer-environment'); + owner.register('component-lookup:main', _emberViews.ComponentLookup); + owner.registerOptionsForType('helper', { instantiate: false }); + owner.registerOptionsForType('component', { singleton: false }); } + + return RenderingTestCase; + })(_internalTestHelpersTestCasesAbstractRendering.default); + + exports.default = RenderingTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvb2JqZWN0LXV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7UUFBYyxPQUFPLEdBQUssTUFBTSxDQUF4QixJQUFJOztBQVNaLGFBQUEsTUFBQSxDQUF1Qix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KG9iajogVCwgYTogVSwgYjogViwgYzogVywgZDogWCk6IFQgJiBVICYgViAmIFcgJiBYO1xuZXhwb3J0IGZ1bmN0aW9uIGFzc2lnbjxULCBVLCBWLCBXLCBYLCBZPihvYmo6IFQsIGE6IFUsIGI6IFYsIGM6IFcsIGQ6IFgsIGU6IFkpOiBUICYgVSAmIFYgJiBXICYgWCAmIFk7XG5leHBvcnQgZnVuY3Rpb24gYXNzaWduPFQsIFUsIFYsIFcsIFgsIFksIFo+KG9iajogVCwgYTogVSwgYjogViwgYzogVywgZDogWCwgZTogWSwgZjogWik6IFQgJiBVICYgViAmIFcgJiBYICYgWSAmIFo7XG5leHBvcnQgZnVuY3Rpb24gYXNzaWduKHRhcmdldDogYW55LCAuLi5hcmdzOiBhbnlbXSk6IGFueTtcbmV4cG9ydCBmdW5jdGlvbiBhc3NpZ24ob2JqKSB7XG4gIGZvciAobGV0IGkgPSAxOyBpIDwgYXJndW1lbnRzLmxlbmd0aDsgaSsrKSB7XG4gICAgbGV0IGFzc2lnbm1lbnQgPSBhcmd1bWVudHNbaV07XG4gICAgaWYgKGFzc2lnbm1lbnQgPT09IG51bGwgfHwgdHlwZW9mIGFzc2lnbm1lbnQgIT09ICdvYmplY3QnKSBjb250aW51ZTtcbiAgICBsZXQga2V5cyA9IG9iaktleXMoYXNzaWdubWVudCk7XG4gICAgZm9yIChsZXQgaiA9IDA7IGogPCBrZXlzLmxlbmd0aDsgaisrKSB7XG4gICAgICBsZXQga2V5ID0ga2V5c1tqXTtcbiAgICAgIG9ialtrZXldID0gYXNzaWdubWVudFtrZXldO1xuICAgIH1cbiAgfVxuICByZXR1cm4gb2JqO1xufVxuIl19 -enifed("glimmer-util/lib/platform-utils", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-cases/router', ['exports', 'internal-test-helpers/test-cases/application'], function (exports, _internalTestHelpersTestCasesApplication) { + 'use strict'; - exports.unwrap = unwrap; + var RouterTestCase = (function (_ApplicationTestCase) { + babelHelpers.inherits(RouterTestCase, _ApplicationTestCase); - function unwrap(val) { - if (val === null || val === undefined) throw new Error("Expected value to be present"); - return val; + function RouterTestCase() { + _ApplicationTestCase.call(this); + + this.router.map(function () { + this.route('parent', { path: '/' }, function () { + this.route('child'); + this.route('sister'); + this.route('brother'); + }); + this.route('dynamic', { path: '/dynamic/:post_id' }); + }); } + + babelHelpers.createClass(RouterTestCase, [{ + key: 'routerService', + get: function () { + return this.applicationInstance.lookup('service:router'); + } + }]); + return RouterTestCase; + })(_internalTestHelpersTestCasesApplication.default); + + exports.default = RouterTestCase; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvcGxhdGZvcm0tdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFJQSxhQUFBLE1BQUEsQ0FBMEIsR0FBYSxFQUFBO0FBQ3JDLFlBQUksR0FBRyxLQUFLLElBQUksSUFBSSxHQUFHLEtBQUssU0FBUyxFQUFFLE1BQU0sSUFBSSxLQUFLLGdDQUFnQyxDQUFDO0FBQ3ZGLGVBQU8sR0FBRyxDQUFDO0tBQ1oiLCJmaWxlIjoicGxhdGZvcm0tdXRpbHMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgdHlwZSBPcGFxdWUgPSB7fSB8IHZvaWQ7XG5leHBvcnQgdHlwZSBPcHRpb248VD4gPSBUIHwgbnVsbDsgLy8gdHNsaW50OmRpc2FibGUtbGluZVxuZXhwb3J0IHR5cGUgTWF5YmU8VD4gPSBPcHRpb248VD4gfCB1bmRlZmluZWQ7IC8vIHRzbGludDpkaXNhYmxlLWxpbmVcblxuZXhwb3J0IGZ1bmN0aW9uIHVud3JhcDxUPih2YWw6IE1heWJlPFQ+KTogVCB7XG4gIGlmICh2YWwgPT09IG51bGwgfHwgdmFsID09PSB1bmRlZmluZWQpIHRocm93IG5ldyBFcnJvcihgRXhwZWN0ZWQgdmFsdWUgdG8gYmUgcHJlc2VudGApO1xuICByZXR1cm4gdmFsO1xufVxuIl19 -enifed("glimmer-util/lib/quoting", ["exports"], function (exports) { - "use strict"; +enifed('internal-test-helpers/test-groups', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) { + 'use strict'; - exports.hash = hash; - exports.repeat = repeat; - function escapeString(str) { - str = str.replace(/\\/g, "\\\\"); - str = str.replace(/"/g, '\\"'); - str = str.replace(/\n/g, "\\n"); - return str; - } - exports.escapeString = escapeString; + exports.testBoth = testBoth; + exports.testWithDefault = testWithDefault; - function string(str) { - return '"' + escapeString(str) + '"'; - } - exports.string = string; + // used by unit tests to test both accessor mode and non-accessor mode - function array(a) { - return "[" + a + "]"; + function testBoth(testname, callback) { + function emberget(x, y) { + return _emberMetal.get(x, y); } - exports.array = array; - - function hash(pairs) { - return "{" + pairs.join(", ") + "}"; + function emberset(x, y, z) { + return _emberMetal.set(x, y, z); } - - function repeat(chars, times) { - var str = ""; - while (times--) { - str += chars; - } - return str; + function aget(x, y) { + return x[y]; + } + function aset(x, y, z) { + return x[y] = z; } -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItdXRpbC9saWIvcXVvdGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLGFBQUEsWUFBQSxDQUFzQixHQUFHLEVBQUE7QUFDdkIsV0FBRyxHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLE1BQU0sQ0FBQyxDQUFDO0FBQ2pDLFdBQUcsR0FBRyxHQUFHLENBQUMsT0FBTyxDQUFDLElBQUksRUFBRSxLQUFLLENBQUMsQ0FBQztBQUMvQixXQUFHLEdBQUcsR0FBRyxDQUFDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsS0FBSyxDQUFDLENBQUM7QUFDaEMsZUFBTyxHQUFHLENBQUM7S0FDWjtZQUV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ufVxuXG5leHBvcnQgeyBzdHJpbmcgfTtcblxuZnVuY3Rpb24gYXJyYXkoYSkge1xuICByZXR1cm4gXCJbXCIgKyBhICsgXCJdXCI7XG59XG5cbmV4cG9ydCB7IGFycmF5IH07XG5cbmV4cG9ydCBmdW5jdGlvbiBoYXNoKHBhaXJzKSB7XG4gIHJldHVybiBcIntcIiArIHBhaXJzLmpvaW4oXCIsIFwiKSArIFwifVwiO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gcmVwZWF0KGNoYXJzLCB0aW1lcykge1xuICBsZXQgc3RyID0gXCJcIjtcbiAgd2hpbGUgKHRpbWVzLS0pIHtcbiAgICBzdHIgKz0gY2hhcnM7XG4gIH1cbiAgcmV0dXJuIHN0cjtcbn1cbiJdfQ== -enifed('glimmer-wire-format/index', ['exports'], function (exports) { - 'use strict'; - function is(variant) { - return function (value) { - return value[0] === variant; - }; + QUnit.test(testname + ' using getFromEmberMetal()/Ember.set()', function () { + callback(emberget, emberset); + }); + + QUnit.test(testname + ' using accessors', function () { + if (_emberEnvironment.ENV.USES_ACCESSORS) { + callback(aget, aset); + } else { + ok('SKIPPING ACCESSORS'); + } + }); + } + + function testWithDefault(testname, callback) { + function emberget(x, y) { + return _emberMetal.get(x, y); } - var Expressions; - exports.Expressions = Expressions; - (function (Expressions) { - Expressions.isUnknown = is('unknown'); - Expressions.isArg = is('arg'); - Expressions.isGet = is('get'); - Expressions.isConcat = is('concat'); - Expressions.isHelper = is('helper'); - Expressions.isHasBlock = is('has-block'); - Expressions.isHasBlockParams = is('has-block-params'); - Expressions.isUndefined = is('undefined'); - function isPrimitiveValue(value) { - if (value === null) { - return true; - } - return typeof value !== 'object'; - } - Expressions.isPrimitiveValue = isPrimitiveValue; - })(Expressions || (exports.Expressions = Expressions = {})); - var Statements; - exports.Statements = Statements; - (function (Statements) { - Statements.isText = is('text'); - Statements.isAppend = is('append'); - Statements.isComment = is('comment'); - Statements.isModifier = is('modifier'); - Statements.isBlock = is('block'); - Statements.isOpenElement = is('open-element'); - Statements.isFlushElement = is('flush-element'); - Statements.isCloseElement = is('close-element'); - Statements.isStaticAttr = is('static-attr'); - Statements.isDynamicAttr = is('dynamic-attr'); - Statements.isYield = is('yield'); - Statements.isPartial = is('partial'); - Statements.isDynamicArg = is('dynamic-arg'); - Statements.isStaticArg = is('static-arg'); - Statements.isTrustingAttr = is('trusting-attr'); - })(Statements || (exports.Statements = Statements = {})); -}); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItd2lyZS1mb3JtYXQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBbUJBLGFBQUEsRUFBQSxDQUE2QixPQUFlLEVBQUE7QUFDMUMsZUFBTyxVQUFTLEtBQVksRUFBQTtBQUMxQixtQkFBTyxLQUFLLENBQUMsQ0FBQyxDQUFDLEtBQUssT0FBTyxDQUFDO1NBQzdCLENBQUM7S0FDSDtBQVVELFFBQWlCLFdBQVcsQ0FvRDNCOztBQXBERCxLQUFBLFVBQWlCLFdBQVcsRUFBQztBQXFDZCxtQkFBQSxDQUFBLFNBQVMsR0FBVSxFQUFFLENBQVUsU0FBUyxDQUFDLENBQUM7QUFDMUMsbUJBQUEsQ0FBQSxLQUFLLEdBQWMsRUFBRSxDQUFNLEtBQUssQ0FBQyxDQUFDO0FBQ2xDLG1CQUFBLENBQUEsS0FBSyxHQUFjLEVBQUUsQ0FBTSxLQUFLLENBQUMsQ0FBQztBQUNsQyxtQkFBQSxDQUFBLFFBQVEsR0FBVyxFQUFFLENBQVMsUUFBUSxDQUFDLENBQUM7QUFDeEMsbUJBQUEsQ0FBQSxRQUFRLEdBQVcsRUFBRSxDQUFTLFFBQVEsQ0FBQyxDQUFDO0FBQ3hDLG1CQUFBLENBQUEsVUFBVSxHQUFTLEVBQUUsQ0FBVyxXQUFXLENBQUMsQ0FBQztBQUM3QyxtQkFBQSxDQUFBLGdCQUFnQixHQUFHLE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SBTZXJpYWxpemVkVGVtcGxhdGVXaXRoTGF6eUJsb2NrIHRvIGJlXG4gKiBjb25jYXRlbmF0ZWQgaW50byBhIEphdmFzY3JpcHQgbW9kdWxlLlxuICogQHR5cGVkZWYge3N0cmluZ30gVGVtcGxhdGVKYXZhc2NyaXB0XG4gKi9cbmV4cG9ydCB0eXBlIFRlbXBsYXRlSmF2YXNjcmlwdCA9IHN0cmluZztcbiJdfQ== -enifed('glimmer/index', ['exports', 'glimmer-compiler'], function (exports, _glimmerCompiler) { - /* - * @overview Glimmer - * @copyright Copyright 2011-2015 Tilde Inc. and contributors - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/tildeio/glimmer/master/LICENSE - * @version VERSION_STRING_PLACEHOLDER - */ - 'use strict'; + function embergetwithdefault(x, y, z) { + return _emberMetal.getWithDefault(x, y, z); + } + function getwithdefault(x, y, z) { + return x.getWithDefault(y, z); + } + function emberset(x, y, z) { + return _emberMetal.set(x, y, z); + } + function aget(x, y) { + return x[y]; + } + function aset(x, y, z) { + return x[y] = z; + } + + QUnit.test(testname + ' using obj.get()', function () { + callback(emberget, emberset); + }); + + QUnit.test(testname + ' using obj.getWithDefault()', function () { + callback(getwithdefault, emberset); + }); + + QUnit.test(testname + ' using getFromEmberMetal()', function () { + callback(emberget, emberset); + }); + + QUnit.test(testname + ' using Ember.getWithDefault()', function () { + callback(embergetwithdefault, emberset); + }); - exports.precompile = _glimmerCompiler.precompile; + QUnit.test(testname + ' using accessors', function () { + if (_emberEnvironment.ENV.USES_ACCESSORS) { + callback(aget, aset); + } else { + ok('SKIPPING ACCESSORS'); + } + }); + } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztVQU9TLFVBQVUsb0JBQVYsVUFBVSIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBAb3ZlcnZpZXcgIEdsaW1tZXJcbiAqIEBjb3B5cmlnaHQgQ29weXJpZ2h0IDIwMTEtMjAxNSBUaWxkZSBJbmMuIGFuZCBjb250cmlidXRvcnNcbiAqIEBsaWNlbnNlICAgTGljZW5zZWQgdW5kZXIgTUlUIGxpY2Vuc2VcbiAqICAgICAgICAgICAgU2VlIGh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS90aWxkZWlvL2dsaW1tZXIvbWFzdGVyL0xJQ0VOU0VcbiAqIEB2ZXJzaW9uICAgVkVSU0lPTl9TVFJJTkdfUExBQ0VIT0xERVJcbiAqL1xuZXhwb3J0IHsgcHJlY29tcGlsZSB9IGZyb20gJ2dsaW1tZXItY29tcGlsZXInO1xuIl19 enifed('route-recognizer', ['exports'], function (exports) { 'use strict'; -function Target(path, matcher, delegate) { - this.path = path; - this.matcher = matcher; - this.delegate = delegate; +var createObject = Object.create; +function createMap() { + var map = createObject(null); + map["__"] = undefined; + delete map["__"]; + return map; } -Target.prototype = { - to: function(target, callback) { +var Target = function Target(path, matcher, delegate) { + this.path = path; + this.matcher = matcher; + this.delegate = delegate; +}; +Target.prototype.to = function to (target, callback) { var delegate = this.delegate; - if (delegate && delegate.willAddRoute) { - target = delegate.willAddRoute(this.matcher.target, target); + target = delegate.willAddRoute(this.matcher.target, target); } - this.matcher.add(this.path, target); - if (callback) { - if (callback.length === 0) { throw new Error("You must have an argument in the function passed to `to`"); } - this.matcher.addChild(this.path, target, callback, this.delegate); + if (callback.length === 0) { + throw new Error("You must have an argument in the function passed to `to`"); + } + this.matcher.addChild(this.path, target, callback, this.delegate); } - return this; - } }; - -function Matcher(target) { - this.routes = {}; - this.children = {}; - this.target = target; -} - -Matcher.prototype = { - add: function(path, handler) { - this.routes[path] = handler; - }, - - addChild: function(path, target, callback, delegate) { +var Matcher = function Matcher(target) { + this.routes = createMap(); + this.children = createMap(); + this.target = target; +}; +Matcher.prototype.add = function add (path, target) { + this.routes[path] = target; +}; +Matcher.prototype.addChild = function addChild (path, target, callback, delegate) { var matcher = new Matcher(target); this.children[path] = matcher; - var match = generateMatch(path, matcher, delegate); - if (delegate && delegate.contextEntered) { - delegate.contextEntered(target, match); + delegate.contextEntered(target, match); } - callback(match); - } }; - function generateMatch(startingPath, matcher, delegate) { - return function(path, nestedCallback) { - var fullPath = startingPath + path; - - if (nestedCallback) { - nestedCallback(generateMatch(fullPath, matcher, delegate)); - } else { - return new Target(startingPath + path, matcher, delegate); + function match(path, callback) { + var fullPath = startingPath + path; + if (callback) { + callback(generateMatch(fullPath, matcher, delegate)); + } + else { + return new Target(fullPath, matcher, delegate); + } } - }; + ; + return match; } - function addRoute(routeArray, path, handler) { - var len = 0; - for (var i=0; i 0 && route.charCodeAt(0) === 47 /* SLASH */) { + route = route.substr(1); + } + var parts = route.split("/"); + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + var flags = 0; + var type = 0; + if (part === "") { + type = 4 /* Epsilon */; + } + else if (part.charCodeAt(0) === 58 /* COLON */) { + type = 1 /* Dynamic */; + } + else if (part.charCodeAt(0) === 42 /* STAR */) { + type = 2 /* Star */; + } + else { + type = 0 /* Static */; + } + flags = 2 << type; + if (flags & 12 /* Named */) { + part = part.slice(1); + names.push(part); + shouldDecodes.push((flags & 4 /* Decoded */) !== 0); + } + if (flags & 14 /* Counted */) { + types[type]++; + } + segments.push({ type: type, value: normalizeSegment(part) }); } - } - - return results; } - -function isEqualCharSpec(specA, specB) { - return specA.validChars === specB.validChars && - specA.invalidChars === specB.invalidChars; +function isEqualCharSpec(spec, char, negate) { + return spec.char === char && spec.negate === negate; } - // A State has a character specification and (`charSpec`) and a list of possible // subsequent states (`nextStates`). // @@ -52132,75 +43065,95 @@ function isEqualCharSpec(specA, specB) { // Currently, State is implemented naively by looping over `nextStates` and // comparing a character specification against a character. A more efficient // implementation would use a hash of keys pointing at one or more next states. +var State = function State(states, id, char, negate, repeat) { + this.states = states; + this.id = id; + this.char = char; + this.negate = negate; + this.nextStates = repeat ? id : null; + this.pattern = ""; + this._regex = undefined; + this.handlers = undefined; + this.types = undefined; +}; +State.prototype.regex = function regex$1 () { + if (!this._regex) { + this._regex = new RegExp(this.pattern); + } + return this._regex; +}; +State.prototype.get = function get (char, negate) { + var this$1 = this; -function State(charSpec) { - this.charSpec = charSpec; - this.nextStates = []; - this.regex = undefined; - this.handlers = undefined; - this.specificity = undefined; -} - -State.prototype = { - get: function(charSpec) { var nextStates = this.nextStates; - - for (var i=0; i 2 && key.slice(keyLength -2) === '[]') { - isArray = true; - key = key.slice(0, keyLength - 2); - if(!queryParams[key]) { - queryParams[key] = []; - } +}; +RouteRecognizer.prototype.parseQueryString = function parseQueryString (queryString) { + var pairs = queryString.split("&"); + var queryParams = {}; + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i].split("="), key = decodeQueryParamPart(pair[0]), keyLength = key.length, isArray = false, value = (void 0); + if (pair.length === 1) { + value = "true"; + } + else { + // Handle arrays + if (keyLength > 2 && key.slice(keyLength - 2) === "[]") { + isArray = true; + key = key.slice(0, keyLength - 2); + if (!queryParams[key]) { + queryParams[key] = []; + } + } + value = pair[1] ? decodeQueryParamPart(pair[1]) : ""; + } + if (isArray) { + queryParams[key].push(value); + } + else { + queryParams[key] = value; } - value = pair[1] ? decodeQueryParamPart(pair[1]) : ''; - } - if (isArray) { - queryParams[key].push(value); - } else { - queryParams[key] = value; - } } return queryParams; - }, - - recognize: function(path) { - var states = [ this.rootState ], - pathLen, i, queryStart, queryParams = {}, - hashStart, - isSlashDropped = false; - - hashStart = path.indexOf('#'); +}; +RouteRecognizer.prototype.recognize = function recognize (path) { + var results; + var states = [this.rootState]; + var queryParams = {}; + var isSlashDropped = false; + var hashStart = path.indexOf("#"); if (hashStart !== -1) { - path = path.substr(0, hashStart); + path = path.substr(0, hashStart); } - - queryStart = path.indexOf('?'); + var queryStart = path.indexOf("?"); if (queryStart !== -1) { - var queryString = path.substr(queryStart + 1, path.length); - path = path.substr(0, queryStart); - queryParams = this.parseQueryString(queryString); + var queryString = path.substr(queryStart + 1, path.length); + path = path.substr(0, queryStart); + queryParams = this.parseQueryString(queryString); + } + if (path.charAt(0) !== "/") { + path = "/" + path; } - - if (path.charAt(0) !== "/") { path = "/" + path; } var originalPath = path; - if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) { - path = normalizePath(path); - } else { - path = decodeURI(path); - originalPath = decodeURI(originalPath); + path = normalizePath(path); } - - pathLen = path.length; + else { + path = decodeURI(path); + originalPath = decodeURI(originalPath); + } + var pathLen = path.length; if (pathLen > 1 && path.charAt(pathLen - 1) === "/") { - path = path.substr(0, pathLen - 1); - originalPath = originalPath.substr(0, originalPath.length - 1); - isSlashDropped = true; + path = path.substr(0, pathLen - 1); + originalPath = originalPath.substr(0, originalPath.length - 1); + isSlashDropped = true; } - - for (i=0; i